Archilyzer · Source

archilyzer

Archilyzer
git clone https://archilyzer.pages.dev/source/archilyzer.git
Log | Files | Refs | README | LICENSE

commit b0e9bc93e01cf65883b297958939419764011fc7
parent d1e695e3fee12cab44835668b733dfe36e9b09b9
Author: I Mean I'm Just Saying <imeanimjustsaying@kiwifarms.st>
Date:   Fri, 16 Oct 2026 23:35:47 -0400

mcp: fetch_clip takes storedUrl (fallback | only), sent with a window to the editor's fetch-window route

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

Diffstat:
Mmcp/src/fetchClip.test.ts | 20++++++++++++++++++++
Mmcp/src/fetchClip.tool.test.ts | 2+-
Mmcp/src/fetchClip.ts | 21++++++++++++++++++++-
Mmcp/src/server.ts | 11+++++++++++
4 files changed, 52 insertions(+), 2 deletions(-)

diff --git a/mcp/src/fetchClip.test.ts b/mcp/src/fetchClip.test.ts @@ -823,3 +823,23 @@ test("full: a finished recording taller than maxHeight says why", async () => { assert.equal(r.isError, false); assert.match(r.text, /\nheight: 1080p — taller than the maxHeight 720 asked for; a whole recording is saved at 720p/); }); + +// ─── storedUrl (release 32 R6) ─── + +test("storedUrl: fallback and only ride on a window's target and its POST; never and absent send nothing", async () => { + const base = { channel: "chan", video: "vid", start: 10, end: 20, reason: "why" }; + const bad = validateFetchClipArgs({ ...base, storedUrl: "always" }); + assert.equal(bad.ok ? "" : bad.error, 'fetch_clip: storedUrl "always" must be one of "never", "fallback", "only"'); + for (const [given, sent] of [["fallback", "fallback"], ["only", "only"], ["never", undefined], [undefined, undefined]] as const) { + const { deps, calls } = editor( + seq({ status: 202, body: { cached: false, jobId: "j9", file: null, from: 0, to: 0 } }), + ); + await fetchClip({ ...windowRequest(given ? { storedUrl: given } : {}), waitSeconds: 0 } as FetchClipRequest, deps); + const body = calls[0].body as Record<string, unknown>; + assert.equal(body.storedUrl, sent, String(given)); + assert.equal("storedUrl" in body, sent !== undefined); + } + // A whole recording has no window to cut: the field is not carried. + const full = validateFetchClipArgs({ ...base, full: true, storedUrl: "only" }); + assert.ok(full.ok && "target" in full.request && !("storedUrl" in full.request.target)); +}); diff --git a/mcp/src/fetchClip.tool.test.ts b/mcp/src/fetchClip.tool.test.ts @@ -265,7 +265,7 @@ test("the tool is advertised with job-only calls allowed", async () => { assert.ok(tool, "fetch_clip is listed"); assert.deepEqual(tool.inputSchema.required ?? [], []); const props = Object.keys(tool.inputSchema.properties ?? {}); - for (const p of ["source", "channel", "video", "start", "end", "pad", "full", "maxHeight", "reason", "report", "wait_seconds", "job"]) { + for (const p of ["source", "channel", "video", "start", "end", "pad", "full", "maxHeight", "storedUrl", "reason", "report", "wait_seconds", "job"]) { assert.ok(props.includes(p), `has ${p}`); } assert.match(tool.description ?? "", /NEVER run yt-dlp/); diff --git a/mcp/src/fetchClip.ts b/mcp/src/fetchClip.ts @@ -4,6 +4,11 @@ import { MIN_FETCH_MAX_HEIGHT, isFetchMaxHeight, } from "yt-dlp-transcript-common/lib/clipWindow"; +import { + STORED_URL_MODES, + isStoredUrlMode, + type StoredUrlMode, +} from "yt-dlp-transcript-common/lib/storedMediaUrl"; // ─── fetch_clip: ask the local Archilyzer editor for a clip's media ─── // @@ -160,6 +165,9 @@ export type ClipTarget = to: number; pad: number; maxHeight?: number; + // Cut from the record's stored media URL (release 32 R6; the editor's + // fetch-window `storedUrl`): "fallback" | "only". Absent is "never". + storedUrl?: Exclude<StoredUrlMode, "never">; } | { kind: "full"; channel: string; video: string; maxHeight?: number }; @@ -258,7 +266,17 @@ export function validateFetchClipArgs( } const w = planWindow({ video, start: times.start, end: times.end, pad }); if ("error" in w) return { ok: false, error: w.error }; - target = { kind: "window", channel, video, from: w.from, to: w.to, pad, ...capped }; + const rawStored = args.storedUrl; + if (rawStored !== undefined && rawStored !== null && !isStoredUrlMode(rawStored)) { + return { + ok: false, + error: + `fetch_clip: storedUrl "${String(rawStored)}" must be one of ` + + STORED_URL_MODES.map((m) => `"${m}"`).join(", "), + }; + } + const stored = isStoredUrlMode(rawStored) && rawStored !== "never" ? { storedUrl: rawStored } : {}; + target = { kind: "window", channel, video, from: w.from, to: w.to, pad, ...capped, ...stored }; } const reason = trimmed(args.reason); @@ -530,6 +548,7 @@ export async function fetchClip( to: target.to, pad: target.pad, ...capped, + ...(target.storedUrl ? { storedUrl: target.storedUrl } : {}), ...provenance, }; const res = await call(`${editor.url}/api/media/fetch-window`, { diff --git a/mcp/src/server.ts b/mcp/src/server.ts @@ -882,6 +882,17 @@ export const TOOLS: Tool[] = [ "file already on disk is returned as it is, and the answer gives " + "its height, so a taller one can be seen.", }, + storedUrl: { + type: "string", + enum: ["never", "fallback", "only"], + description: + "Optional, a window only: cut it from the media file address the " + + "record stored when it was archived (Odysee only), the way the " + + "platform's own player reads it. \"fallback\": the page first, and " + + "the stored file when the platform refuses the lookup (a rate limit, " + + "a hold or a cooldown). \"only\": no page request. Default " + + "\"never\". A record with no stored address is fetched as usual.", + }, reason: { type: "string", description: