summaryrefslogtreecommitdiffhomepage
path: root/packages/tool-youtube-transcript/src/extension.ts
diff options
context:
space:
mode:
authorAdam Malczewski <[email protected]>2026-06-21 14:58:38 +0900
committerAdam Malczewski <[email protected]>2026-06-21 14:58:38 +0900
commitdfb3a61afa545b67b85dbefe6b217affd14c16a7 (patch)
treefbe0d18323136cc19d971e18f0801428bcd2e4a7 /packages/tool-youtube-transcript/src/extension.ts
parentd56fe9cf64719bb330c17b2daee58c0bafa057c9 (diff)
downloaddispatch-dfb3a61afa545b67b85dbefe6b217affd14c16a7.tar.gz
dispatch-dfb3a61afa545b67b85dbefe6b217affd14c16a7.zip
feat(tool-youtube-transcript): YouTube transcription tool
New standard tool extension backed by a self-hosted transcriber service (http://100.102.55.49:41090, Tailscale, no API key). One tool youtube_transcript — fetches transcripts for YouTube videos. Returns completed (full text + timestamped segments), queued/processing (position + ETA + .youtube_subtitles_pending retry convention), or failed (error). Pure core: validateUrl + format* functions + truncateOutput. Injected edge: TranscriptClient (injectable fetchFn, AbortSignal.any for cancellation). concurrencySafe true, capabilities network. 30 tests. Verified: tsc EXIT 0, 1152 vitest, biome clean (327 files). Boot smoke clean.
Diffstat (limited to 'packages/tool-youtube-transcript/src/extension.ts')
-rw-r--r--packages/tool-youtube-transcript/src/extension.ts32
1 files changed, 32 insertions, 0 deletions
diff --git a/packages/tool-youtube-transcript/src/extension.ts b/packages/tool-youtube-transcript/src/extension.ts
new file mode 100644
index 0000000..0669fa5
--- /dev/null
+++ b/packages/tool-youtube-transcript/src/extension.ts
@@ -0,0 +1,32 @@
+/**
+ * tool-youtube-transcript extension — registers the `youtube_transcript` tool
+ * backed by a self-hosted transcriber service on activation.
+ *
+ * The base URL comes from `YOUTUBE_TRANSCRIBER_URL` (env) with a Tailscale
+ * default. Effects (`globalThis.fetch`) come from the ambient edge here, in
+ * the shell — never in the pure core. Logging is left to the host via
+ * `host.logger`/`ctx.log` (no `console.*`, no hand-rolled logger).
+ */
+
+import type { Extension, HostAPI, Manifest } from "@dispatch/kernel";
+import { createTranscriptClient, DEFAULT_BASE_URL } from "./client.js";
+import { createYoutubeTranscriptTool } from "./tool.js";
+
+export const manifest: Manifest = {
+ id: "tool-youtube-transcript",
+ name: "YouTube Transcript Tool",
+ version: "0.0.0",
+ apiVersion: "^0.1.0",
+ trust: "bundled",
+ activation: "eager",
+ capabilities: { network: true },
+ contributes: { tools: ["youtube_transcript"] },
+};
+
+export function activate(host: HostAPI): void {
+ const baseUrl = process.env.YOUTUBE_TRANSCRIBER_URL ?? DEFAULT_BASE_URL;
+ const client = createTranscriptClient({ baseUrl, fetchFn: globalThis.fetch });
+ host.defineTool(createYoutubeTranscriptTool({ client }));
+}
+
+export const extension: Extension = { manifest, activate };