summaryrefslogtreecommitdiffhomepage
path: root/packages/tool-youtube-transcript/src/tool.ts
diff options
context:
space:
mode:
authorAdam Malczewski <[email protected]>2026-06-21 15:15:59 +0900
committerAdam Malczewski <[email protected]>2026-06-21 15:15:59 +0900
commit6cfe0dc1df99c46407b0784576c3d4b0f1cb7349 (patch)
treeb9c3bb058037e9841e474b16034ca28316f42fb6 /packages/tool-youtube-transcript/src/tool.ts
parent64823e68e8c6c3bc199f9cb82d97321c830687c3 (diff)
downloaddispatch-6cfe0dc1df99c46407b0784576c3d4b0f1cb7349.tar.gz
dispatch-6cfe0dc1df99c46407b0784576c3d4b0f1cb7349.zip
refactor(tool-youtube-transcript): always save full transcript, fix description
- Always write the full transcript to /tmp/dispatch/youtube-transcribe/{video_id}.txt (not just on truncation) - Description no longer claims to return the full transcript; instead says it returns transcript text (truncated if very long) and the full version is always saved to the file path
Diffstat (limited to 'packages/tool-youtube-transcript/src/tool.ts')
-rw-r--r--packages/tool-youtube-transcript/src/tool.ts16
1 files changed, 10 insertions, 6 deletions
diff --git a/packages/tool-youtube-transcript/src/tool.ts b/packages/tool-youtube-transcript/src/tool.ts
index a47d693..a11f739 100644
--- a/packages/tool-youtube-transcript/src/tool.ts
+++ b/packages/tool-youtube-transcript/src/tool.ts
@@ -20,7 +20,7 @@ import {
import { validateUrl } from "./validate.js";
const OUTPUT_CAP = 50_000;
-const FULL_OUTPUT_DIR = "/tmp/dispatch";
+const FULL_OUTPUT_DIR = "/tmp/dispatch/youtube-transcribe";
export interface YoutubeTranscriptToolDeps {
readonly client: TranscriptClient;
@@ -33,8 +33,10 @@ const DESCRIPTION =
"Fetch the transcript/subtitles for a YouTube video from the local transcriber " +
"service. If the transcript has not been downloaded before, the video will be " +
"queued for processing and the tool will return the estimated time when the " +
- "transcript will be available. Once available, the tool returns the full " +
- "transcript text and timestamped segments. Accepted URL formats: " +
+ "transcript will be available. Once available, the tool returns the transcript " +
+ "text and timestamped segments (truncated if very long). The full transcript " +
+ "is always saved to /tmp/dispatch/youtube-transcribe/{video_id}.txt — use " +
+ "read_file to access it. Accepted URL formats: " +
"youtube.com/watch?v=, youtu.be/, youtube.com/embed/, youtube.com/shorts/";
/**
@@ -91,13 +93,15 @@ export function createYoutubeTranscriptTool(deps: YoutubeTranscriptToolDeps): To
}
span.end();
- if (output.length > cap && videoId !== undefined) {
+ if (videoId !== undefined) {
const filePath = `${FULL_OUTPUT_DIR}/${videoId}.txt`;
try {
writeFile(filePath, output);
- return { content: truncateOutput(output, cap, filePath) };
} catch {
- return { content: truncateOutput(output, cap) };
+ // File write failed — continue with truncated output only.
+ }
+ if (output.length > cap) {
+ return { content: truncateOutput(output, cap, filePath) };
}
}
return { content: truncateOutput(output, cap) };