@tmhs/screencast-mcp 0.39.0 → 0.45.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (344) hide show
  1. package/README.md +95 -17
  2. package/assets/icon.png +0 -0
  3. package/assets/ui/player.html +47 -302
  4. package/assets/ui/player.js +402 -0
  5. package/dist/context.js +0 -5
  6. package/dist/index.js +17 -21
  7. package/dist/prompts.js +18 -8
  8. package/dist/resources.js +2 -14
  9. package/dist/server.js +49 -11
  10. package/dist/tools/addMarker.js +89 -0
  11. package/dist/tools/assembleHighlights.js +12 -7
  12. package/dist/tools/backdrop.js +89 -0
  13. package/dist/tools/bugReport.js +266 -0
  14. package/dist/tools/burnSubtitles.js +12 -6
  15. package/dist/tools/callout.js +32 -16
  16. package/dist/tools/chapters.js +156 -0
  17. package/dist/tools/clip.js +12 -9
  18. package/dist/tools/compress.js +10 -5
  19. package/dist/tools/concat.js +16 -15
  20. package/dist/tools/contactSheet.js +39 -33
  21. package/dist/tools/convert.js +12 -6
  22. package/dist/tools/crop.js +12 -7
  23. package/dist/tools/cutIdle.js +15 -9
  24. package/dist/tools/denoise.js +12 -6
  25. package/dist/tools/doctor.js +133 -0
  26. package/dist/tools/exportGif.js +14 -10
  27. package/dist/tools/exportPreset.js +11 -8
  28. package/dist/tools/extractAudio.js +10 -8
  29. package/dist/tools/findText.js +52 -98
  30. package/dist/tools/getMediaInfo.js +17 -3
  31. package/dist/tools/getSession.js +15 -3
  32. package/dist/tools/keystrokeOverlay.js +131 -0
  33. package/dist/tools/listAudioDevices.js +14 -7
  34. package/dist/tools/listSessions.js +13 -3
  35. package/dist/tools/listTargets.js +76 -0
  36. package/dist/tools/musicBed.js +14 -10
  37. package/dist/tools/normalizeAudio.js +12 -8
  38. package/dist/tools/overlay.js +16 -12
  39. package/dist/tools/pipeline.js +86 -25
  40. package/dist/tools/readEvents.js +21 -12
  41. package/dist/tools/redactRegion.js +19 -17
  42. package/dist/tools/reframe.js +9 -5
  43. package/dist/tools/reviewRecording.js +75 -22
  44. package/dist/tools/sampleFrames.js +33 -40
  45. package/dist/tools/saveReplay.js +90 -0
  46. package/dist/tools/scale.js +9 -3
  47. package/dist/tools/screenDiff.js +23 -17
  48. package/dist/tools/screenshot.js +21 -17
  49. package/dist/tools/speed.js +15 -4
  50. package/dist/tools/startRecording.js +96 -59
  51. package/dist/tools/stopRecording.js +35 -10
  52. package/dist/tools/titleCard.js +19 -11
  53. package/dist/tools/transcribe.js +13 -7
  54. package/dist/tools/trim.js +11 -10
  55. package/dist/tools/waitForChange.js +37 -22
  56. package/dist/tools/xfadeTransition.js +12 -8
  57. package/dist/tools/zoom.js +26 -29
  58. package/dist/utils/anim.js +1 -21
  59. package/dist/utils/animExport.js +5 -10
  60. package/dist/utils/audio.js +4 -33
  61. package/dist/utils/audioDevices.js +1 -48
  62. package/dist/utils/backdrop.js +151 -0
  63. package/dist/utils/bugReport.js +246 -0
  64. package/dist/utils/callout.js +1 -19
  65. package/dist/utils/calloutAssets.js +21 -11
  66. package/dist/utils/capabilities.js +95 -0
  67. package/dist/utils/captions.js +9 -26
  68. package/dist/utils/chapters.js +222 -0
  69. package/dist/utils/consent.js +29 -0
  70. package/dist/utils/diff.js +0 -46
  71. package/dist/utils/errors.js +5 -13
  72. package/dist/utils/events.js +21 -77
  73. package/dist/utils/expr.js +11 -0
  74. package/dist/utils/ffmpeg.js +119 -48
  75. package/dist/utils/fontCoverage.js +177 -0
  76. package/dist/utils/fonts.js +139 -23
  77. package/dist/utils/idle.js +12 -24
  78. package/dist/utils/images.js +0 -17
  79. package/dist/utils/jobs.js +42 -41
  80. package/dist/utils/keystrokes.js +170 -0
  81. package/dist/utils/lifecycle.js +11 -31
  82. package/dist/utils/logging.js +75 -0
  83. package/dist/utils/media.js +16 -124
  84. package/dist/utils/monitors.js +7 -43
  85. package/dist/utils/ocr.js +53 -71
  86. package/dist/utils/ocrScan.js +77 -0
  87. package/dist/utils/paths.js +68 -31
  88. package/dist/utils/pipeline.js +39 -25
  89. package/dist/utils/player.js +50 -27
  90. package/dist/utils/produce.js +6 -66
  91. package/dist/utils/replay.js +278 -0
  92. package/dist/utils/resolveTarget.js +0 -19
  93. package/dist/utils/retention.js +1 -15
  94. package/dist/utils/roots.js +42 -0
  95. package/dist/utils/sessions.js +195 -160
  96. package/dist/utils/sheet.js +0 -19
  97. package/dist/utils/still.js +0 -15
  98. package/dist/utils/targetList.js +63 -0
  99. package/dist/utils/targets.js +5 -70
  100. package/dist/utils/toolSpec.js +25 -0
  101. package/dist/utils/toolsets.js +122 -0
  102. package/dist/utils/validate.js +0 -22
  103. package/dist/utils/wgc.js +0 -46
  104. package/dist/utils/windows.js +5 -50
  105. package/dist/utils/zoom.js +55 -85
  106. package/dist/wgcRecorder.js +1 -30
  107. package/package.json +7 -3
  108. package/dist/context.d.ts +0 -9
  109. package/dist/context.d.ts.map +0 -1
  110. package/dist/context.js.map +0 -1
  111. package/dist/index.d.ts +0 -3
  112. package/dist/index.d.ts.map +0 -1
  113. package/dist/index.js.map +0 -1
  114. package/dist/prompts.d.ts +0 -10
  115. package/dist/prompts.d.ts.map +0 -1
  116. package/dist/prompts.js.map +0 -1
  117. package/dist/resources.d.ts +0 -3
  118. package/dist/resources.d.ts.map +0 -1
  119. package/dist/resources.js.map +0 -1
  120. package/dist/server.d.ts +0 -3
  121. package/dist/server.d.ts.map +0 -1
  122. package/dist/server.js.map +0 -1
  123. package/dist/tools/assembleHighlights.d.ts +0 -3
  124. package/dist/tools/assembleHighlights.d.ts.map +0 -1
  125. package/dist/tools/assembleHighlights.js.map +0 -1
  126. package/dist/tools/burnSubtitles.d.ts +0 -3
  127. package/dist/tools/burnSubtitles.d.ts.map +0 -1
  128. package/dist/tools/burnSubtitles.js.map +0 -1
  129. package/dist/tools/callout.d.ts +0 -37
  130. package/dist/tools/callout.d.ts.map +0 -1
  131. package/dist/tools/callout.js.map +0 -1
  132. package/dist/tools/clip.d.ts +0 -3
  133. package/dist/tools/clip.d.ts.map +0 -1
  134. package/dist/tools/clip.js.map +0 -1
  135. package/dist/tools/compress.d.ts +0 -3
  136. package/dist/tools/compress.d.ts.map +0 -1
  137. package/dist/tools/compress.js.map +0 -1
  138. package/dist/tools/concat.d.ts +0 -3
  139. package/dist/tools/concat.d.ts.map +0 -1
  140. package/dist/tools/concat.js.map +0 -1
  141. package/dist/tools/contactSheet.d.ts +0 -3
  142. package/dist/tools/contactSheet.d.ts.map +0 -1
  143. package/dist/tools/contactSheet.js.map +0 -1
  144. package/dist/tools/convert.d.ts +0 -3
  145. package/dist/tools/convert.d.ts.map +0 -1
  146. package/dist/tools/convert.js.map +0 -1
  147. package/dist/tools/crop.d.ts +0 -3
  148. package/dist/tools/crop.d.ts.map +0 -1
  149. package/dist/tools/crop.js.map +0 -1
  150. package/dist/tools/cutIdle.d.ts +0 -3
  151. package/dist/tools/cutIdle.d.ts.map +0 -1
  152. package/dist/tools/cutIdle.js.map +0 -1
  153. package/dist/tools/denoise.d.ts +0 -3
  154. package/dist/tools/denoise.d.ts.map +0 -1
  155. package/dist/tools/denoise.js.map +0 -1
  156. package/dist/tools/exportGif.d.ts +0 -3
  157. package/dist/tools/exportGif.d.ts.map +0 -1
  158. package/dist/tools/exportGif.js.map +0 -1
  159. package/dist/tools/exportPreset.d.ts +0 -3
  160. package/dist/tools/exportPreset.d.ts.map +0 -1
  161. package/dist/tools/exportPreset.js.map +0 -1
  162. package/dist/tools/extractAudio.d.ts +0 -3
  163. package/dist/tools/extractAudio.d.ts.map +0 -1
  164. package/dist/tools/extractAudio.js.map +0 -1
  165. package/dist/tools/findText.d.ts +0 -6
  166. package/dist/tools/findText.d.ts.map +0 -1
  167. package/dist/tools/findText.js.map +0 -1
  168. package/dist/tools/getMediaInfo.d.ts +0 -3
  169. package/dist/tools/getMediaInfo.d.ts.map +0 -1
  170. package/dist/tools/getMediaInfo.js.map +0 -1
  171. package/dist/tools/getSession.d.ts +0 -3
  172. package/dist/tools/getSession.d.ts.map +0 -1
  173. package/dist/tools/getSession.js.map +0 -1
  174. package/dist/tools/listAudioDevices.d.ts +0 -3
  175. package/dist/tools/listAudioDevices.d.ts.map +0 -1
  176. package/dist/tools/listAudioDevices.js.map +0 -1
  177. package/dist/tools/listSessions.d.ts +0 -3
  178. package/dist/tools/listSessions.d.ts.map +0 -1
  179. package/dist/tools/listSessions.js.map +0 -1
  180. package/dist/tools/musicBed.d.ts +0 -3
  181. package/dist/tools/musicBed.d.ts.map +0 -1
  182. package/dist/tools/musicBed.js.map +0 -1
  183. package/dist/tools/normalizeAudio.d.ts +0 -3
  184. package/dist/tools/normalizeAudio.d.ts.map +0 -1
  185. package/dist/tools/normalizeAudio.js.map +0 -1
  186. package/dist/tools/overlay.d.ts +0 -3
  187. package/dist/tools/overlay.d.ts.map +0 -1
  188. package/dist/tools/overlay.js.map +0 -1
  189. package/dist/tools/pipeline.d.ts +0 -3
  190. package/dist/tools/pipeline.d.ts.map +0 -1
  191. package/dist/tools/pipeline.js.map +0 -1
  192. package/dist/tools/readEvents.d.ts +0 -6
  193. package/dist/tools/readEvents.d.ts.map +0 -1
  194. package/dist/tools/readEvents.js.map +0 -1
  195. package/dist/tools/redactRegion.d.ts +0 -13
  196. package/dist/tools/redactRegion.d.ts.map +0 -1
  197. package/dist/tools/redactRegion.js.map +0 -1
  198. package/dist/tools/reframe.d.ts +0 -3
  199. package/dist/tools/reframe.d.ts.map +0 -1
  200. package/dist/tools/reframe.js.map +0 -1
  201. package/dist/tools/reviewRecording.d.ts +0 -5
  202. package/dist/tools/reviewRecording.d.ts.map +0 -1
  203. package/dist/tools/reviewRecording.js.map +0 -1
  204. package/dist/tools/sampleFrames.d.ts +0 -3
  205. package/dist/tools/sampleFrames.d.ts.map +0 -1
  206. package/dist/tools/sampleFrames.js.map +0 -1
  207. package/dist/tools/scale.d.ts +0 -3
  208. package/dist/tools/scale.d.ts.map +0 -1
  209. package/dist/tools/scale.js.map +0 -1
  210. package/dist/tools/screenDiff.d.ts +0 -3
  211. package/dist/tools/screenDiff.d.ts.map +0 -1
  212. package/dist/tools/screenDiff.js.map +0 -1
  213. package/dist/tools/screenshot.d.ts +0 -3
  214. package/dist/tools/screenshot.d.ts.map +0 -1
  215. package/dist/tools/screenshot.js.map +0 -1
  216. package/dist/tools/speed.d.ts +0 -3
  217. package/dist/tools/speed.d.ts.map +0 -1
  218. package/dist/tools/speed.js.map +0 -1
  219. package/dist/tools/startRecording.d.ts +0 -3
  220. package/dist/tools/startRecording.d.ts.map +0 -1
  221. package/dist/tools/startRecording.js.map +0 -1
  222. package/dist/tools/stopRecording.d.ts +0 -3
  223. package/dist/tools/stopRecording.d.ts.map +0 -1
  224. package/dist/tools/stopRecording.js.map +0 -1
  225. package/dist/tools/titleCard.d.ts +0 -3
  226. package/dist/tools/titleCard.d.ts.map +0 -1
  227. package/dist/tools/titleCard.js.map +0 -1
  228. package/dist/tools/transcribe.d.ts +0 -3
  229. package/dist/tools/transcribe.d.ts.map +0 -1
  230. package/dist/tools/transcribe.js.map +0 -1
  231. package/dist/tools/trim.d.ts +0 -3
  232. package/dist/tools/trim.d.ts.map +0 -1
  233. package/dist/tools/trim.js.map +0 -1
  234. package/dist/tools/waitForChange.d.ts +0 -3
  235. package/dist/tools/waitForChange.d.ts.map +0 -1
  236. package/dist/tools/waitForChange.js.map +0 -1
  237. package/dist/tools/xfadeTransition.d.ts +0 -3
  238. package/dist/tools/xfadeTransition.d.ts.map +0 -1
  239. package/dist/tools/xfadeTransition.js.map +0 -1
  240. package/dist/tools/zoom.d.ts +0 -15
  241. package/dist/tools/zoom.d.ts.map +0 -1
  242. package/dist/tools/zoom.js.map +0 -1
  243. package/dist/utils/anim.d.ts +0 -33
  244. package/dist/utils/anim.d.ts.map +0 -1
  245. package/dist/utils/anim.js.map +0 -1
  246. package/dist/utils/animExport.d.ts +0 -27
  247. package/dist/utils/animExport.d.ts.map +0 -1
  248. package/dist/utils/animExport.js.map +0 -1
  249. package/dist/utils/audio.d.ts +0 -49
  250. package/dist/utils/audio.d.ts.map +0 -1
  251. package/dist/utils/audio.js.map +0 -1
  252. package/dist/utils/audioDevices.d.ts +0 -33
  253. package/dist/utils/audioDevices.d.ts.map +0 -1
  254. package/dist/utils/audioDevices.js.map +0 -1
  255. package/dist/utils/callout.d.ts +0 -72
  256. package/dist/utils/callout.d.ts.map +0 -1
  257. package/dist/utils/callout.js.map +0 -1
  258. package/dist/utils/calloutAssets.d.ts +0 -3
  259. package/dist/utils/calloutAssets.d.ts.map +0 -1
  260. package/dist/utils/calloutAssets.js.map +0 -1
  261. package/dist/utils/captions.d.ts +0 -26
  262. package/dist/utils/captions.d.ts.map +0 -1
  263. package/dist/utils/captions.js.map +0 -1
  264. package/dist/utils/diff.d.ts +0 -112
  265. package/dist/utils/diff.d.ts.map +0 -1
  266. package/dist/utils/diff.js.map +0 -1
  267. package/dist/utils/errors.d.ts +0 -33
  268. package/dist/utils/errors.d.ts.map +0 -1
  269. package/dist/utils/errors.js.map +0 -1
  270. package/dist/utils/events.d.ts +0 -143
  271. package/dist/utils/events.d.ts.map +0 -1
  272. package/dist/utils/events.js.map +0 -1
  273. package/dist/utils/ffmpeg.d.ts +0 -50
  274. package/dist/utils/ffmpeg.d.ts.map +0 -1
  275. package/dist/utils/ffmpeg.js.map +0 -1
  276. package/dist/utils/fonts.d.ts +0 -17
  277. package/dist/utils/fonts.d.ts.map +0 -1
  278. package/dist/utils/fonts.js.map +0 -1
  279. package/dist/utils/idle.d.ts +0 -23
  280. package/dist/utils/idle.d.ts.map +0 -1
  281. package/dist/utils/idle.js.map +0 -1
  282. package/dist/utils/images.d.ts +0 -21
  283. package/dist/utils/images.d.ts.map +0 -1
  284. package/dist/utils/images.js.map +0 -1
  285. package/dist/utils/jobs.d.ts +0 -44
  286. package/dist/utils/jobs.d.ts.map +0 -1
  287. package/dist/utils/jobs.js.map +0 -1
  288. package/dist/utils/lifecycle.d.ts +0 -29
  289. package/dist/utils/lifecycle.d.ts.map +0 -1
  290. package/dist/utils/lifecycle.js.map +0 -1
  291. package/dist/utils/media.d.ts +0 -272
  292. package/dist/utils/media.d.ts.map +0 -1
  293. package/dist/utils/media.js.map +0 -1
  294. package/dist/utils/monitors.d.ts +0 -47
  295. package/dist/utils/monitors.d.ts.map +0 -1
  296. package/dist/utils/monitors.js.map +0 -1
  297. package/dist/utils/ocr.d.ts +0 -50
  298. package/dist/utils/ocr.d.ts.map +0 -1
  299. package/dist/utils/ocr.js.map +0 -1
  300. package/dist/utils/paths.d.ts +0 -28
  301. package/dist/utils/paths.d.ts.map +0 -1
  302. package/dist/utils/paths.js.map +0 -1
  303. package/dist/utils/pipeline.d.ts +0 -69
  304. package/dist/utils/pipeline.d.ts.map +0 -1
  305. package/dist/utils/pipeline.js.map +0 -1
  306. package/dist/utils/player.d.ts +0 -30
  307. package/dist/utils/player.d.ts.map +0 -1
  308. package/dist/utils/player.js.map +0 -1
  309. package/dist/utils/produce.d.ts +0 -126
  310. package/dist/utils/produce.d.ts.map +0 -1
  311. package/dist/utils/produce.js.map +0 -1
  312. package/dist/utils/resolveTarget.d.ts +0 -32
  313. package/dist/utils/resolveTarget.d.ts.map +0 -1
  314. package/dist/utils/resolveTarget.js.map +0 -1
  315. package/dist/utils/retention.d.ts +0 -10
  316. package/dist/utils/retention.d.ts.map +0 -1
  317. package/dist/utils/retention.js.map +0 -1
  318. package/dist/utils/sessions.d.ts +0 -154
  319. package/dist/utils/sessions.d.ts.map +0 -1
  320. package/dist/utils/sessions.js.map +0 -1
  321. package/dist/utils/sheet.d.ts +0 -26
  322. package/dist/utils/sheet.d.ts.map +0 -1
  323. package/dist/utils/sheet.js.map +0 -1
  324. package/dist/utils/still.d.ts +0 -7
  325. package/dist/utils/still.d.ts.map +0 -1
  326. package/dist/utils/still.js.map +0 -1
  327. package/dist/utils/targets.d.ts +0 -113
  328. package/dist/utils/targets.d.ts.map +0 -1
  329. package/dist/utils/targets.js.map +0 -1
  330. package/dist/utils/validate.d.ts +0 -15
  331. package/dist/utils/validate.d.ts.map +0 -1
  332. package/dist/utils/validate.js.map +0 -1
  333. package/dist/utils/wgc.d.ts +0 -46
  334. package/dist/utils/wgc.d.ts.map +0 -1
  335. package/dist/utils/wgc.js.map +0 -1
  336. package/dist/utils/windows.d.ts +0 -94
  337. package/dist/utils/windows.d.ts.map +0 -1
  338. package/dist/utils/windows.js.map +0 -1
  339. package/dist/utils/zoom.d.ts +0 -95
  340. package/dist/utils/zoom.d.ts.map +0 -1
  341. package/dist/utils/zoom.js.map +0 -1
  342. package/dist/wgcRecorder.d.ts +0 -2
  343. package/dist/wgcRecorder.d.ts.map +0 -1
  344. package/dist/wgcRecorder.js.map +0 -1
@@ -2,6 +2,7 @@ import { z } from "zod";
2
2
  import { dirname } from "node:path";
3
3
  import { existsSync } from "node:fs";
4
4
  import { errorResponse, okResponse, ScreencastError } from "../utils/errors.js";
5
+ import { OUTPUT_PATH, WRITES_FILE } from "../utils/toolSpec.js";
5
6
  import { requireFfmpeg, probeMedia, hasFilter } from "../utils/ffmpeg.js";
6
7
  import { runEditJob } from "../utils/jobs.js";
7
8
  import { buildBurnSubtitlesArgs } from "../utils/captions.js";
@@ -14,13 +15,19 @@ const inputSchema = {
14
15
  style: z
15
16
  .enum(["clean", "social"])
16
17
  .optional()
17
- .describe("'clean' (default): a modest outlined line. 'social': large bold text on a dark box, for muted autoplay."),
18
+ .describe("clean (default for .srt): outlined line. social: big bold text on a dark box. .ass keeps its own " +
19
+ "styling unless set."),
18
20
  output: z.string().optional().describe("Optional output path. Defaults under SCREENCAST_HOME/edits."),
19
21
  overwrite: z.boolean().optional().describe("Allow replacing an existing file at the output path (default false)."),
20
22
  };
21
23
  export function register(server) {
22
- server.tool("burn_subtitles", "Burn subtitles (an SRT from transcribe, or any SRT/ASS) permanently into a video, in " +
23
- "the bundled font, in a clean or social-media style. Returns the output path.", inputSchema, async (args, extra) => {
24
+ server.registerTool("burn_subtitles", {
25
+ title: "Burn In Subtitles",
26
+ description: "Burn SRT/ASS subtitles (e.g. from transcribe) into a video in the bundled font.",
27
+ inputSchema,
28
+ outputSchema: OUTPUT_PATH,
29
+ annotations: WRITES_FILE,
30
+ }, async (args, extra) => {
24
31
  try {
25
32
  requireFfmpeg();
26
33
  for (const f of [args.input, args.subtitles]) {
@@ -34,17 +41,16 @@ export function register(server) {
34
41
  const ext = editOutputExt(args.input);
35
42
  const output = resolveOutput(args.output, subdir("edits"), `subtitled-${stamp()}-${rand()}${ext}`, args.overwrite);
36
43
  const fontsDir = dirname(bundledFontPath("regular"));
37
- const style = args.style ?? "clean";
44
+ const style = args.style ?? (/\.(ass|ssa)$/i.test(args.subtitles) ? null : "clean");
38
45
  await runEditJob(buildBurnSubtitlesArgs(args.input, args.subtitles, output, fontsDir, style), {
39
46
  output,
40
47
  durationSec: (await probeMedia(args.input)).durationSec,
41
48
  extra,
42
49
  });
43
- return okResponse({ outputPath: output, style });
50
+ return okResponse({ outputPath: output, style: style ?? "file" });
44
51
  }
45
52
  catch (error) {
46
53
  return errorResponse(error);
47
54
  }
48
55
  });
49
56
  }
50
- //# sourceMappingURL=burnSubtitles.js.map
@@ -3,6 +3,7 @@ import { join } from "node:path";
3
3
  import { existsSync, mkdtempSync, rmSync } from "node:fs";
4
4
  import { tmpdir } from "node:os";
5
5
  import { errorResponse, okResponse, ScreencastError } from "../utils/errors.js";
6
+ import { OUTPUT_PATH, WRITES_FILE } from "../utils/toolSpec.js";
6
7
  import { requireFfmpeg } from "../utils/ffmpeg.js";
7
8
  import { runEditJob, probeDuration } from "../utils/jobs.js";
8
9
  import { buildCalloutArgs } from "../utils/callout.js";
@@ -10,11 +11,16 @@ import { prepareCalloutAssets } from "../utils/calloutAssets.js";
10
11
  import { editOutputExt, assertEditContainer } from "../utils/media.js";
11
12
  import { resolveOutput, subdir, stamp, rand } from "../utils/paths.js";
12
13
  const timing = {
13
- from: z.number().nonnegative().optional().describe("Show from this second (default: start)."),
14
- to: z.number().positive().optional().describe("Hide after this second (default: end)."),
15
- color: z.string().optional().describe("Color name, #RRGGBB, or name@alpha."),
14
+ from: z.number().nonnegative().optional(),
15
+ to: z.number().positive().optional(),
16
+ color: z.string().optional(),
16
17
  };
17
- /** One callout; shared with pipeline. */
18
+ export const fontFileSchema = z
19
+ .string()
20
+ .min(1)
21
+ .optional()
22
+ .describe("Font: a .ttf/.otf/.ttc path or a C:\\Windows\\Fonts file name. Default: bundled Inter, with a " +
23
+ "covering system font for scripts it lacks (CJK, emoji, Arabic, ...).");
18
24
  export const calloutItemSchema = z.discriminatedUnion("type", [
19
25
  z.object({
20
26
  type: z.literal("box"),
@@ -37,10 +43,10 @@ export const calloutItemSchema = z.discriminatedUnion("type", [
37
43
  }),
38
44
  z.object({
39
45
  type: z.literal("arrow"),
40
- x1: z.number().describe("Tail x."),
41
- y1: z.number().describe("Tail y."),
42
- x2: z.number().describe("Head x: the point the arrow points at."),
43
- y2: z.number().describe("Head y."),
46
+ x1: z.number(),
47
+ y1: z.number(),
48
+ x2: z.number().describe("Head (x2,y2) is the point the arrow points at."),
49
+ y2: z.number(),
44
50
  thickness: z.number().positive().optional().describe("Shaft px (default 8)."),
45
51
  ...timing,
46
52
  }),
@@ -51,14 +57,21 @@ const inputSchema = {
51
57
  .array(calloutItemSchema)
52
58
  .min(1)
53
59
  .max(50)
54
- .describe("Annotations, drawn in order (later on top). Each is a box, a text label, or an arrow, " +
55
- "shown between from and to (seconds). Coordinates are video pixels."),
60
+ .describe("Boxes, text labels, and arrows, drawn in order (later on top), in video pixels. Each shows " +
61
+ "from..to seconds (default: whole video); color is a name, #RRGGBB, or name@alpha."),
62
+ fontFile: fontFileSchema,
56
63
  output: z.string().optional().describe("Optional output path. Defaults under SCREENCAST_HOME/edits."),
57
64
  overwrite: z.boolean().optional().describe("Allow replacing an existing file at the output path (default false)."),
58
65
  };
59
66
  export function register(server) {
60
- server.tool("callout", "Annotate a video with timed boxes, text labels, and arrows (e.g. 'click here', a box " +
61
- "around the bug), each shown between two timestamps. Returns the output path.", inputSchema, async (args, extra) => {
67
+ server.registerTool("callout", {
68
+ title: "Add Callouts",
69
+ description: "Annotate a video with timed boxes, text labels, and arrows. Fallback fonts used are listed in " +
70
+ "fallbackFonts; characters no font covers are reported in warnings.",
71
+ inputSchema,
72
+ outputSchema: OUTPUT_PATH,
73
+ annotations: WRITES_FILE,
74
+ }, async (args, extra) => {
62
75
  try {
63
76
  requireFfmpeg();
64
77
  if (!existsSync(args.input)) {
@@ -68,21 +81,24 @@ export function register(server) {
68
81
  assertEditContainer(args.output);
69
82
  const ext = editOutputExt(args.input);
70
83
  const output = resolveOutput(args.output, subdir("edits"), `callout-${stamp()}-${rand()}${ext}`, args.overwrite);
71
- // Text files and rendered arrows live in a private temp dir.
72
84
  const work = mkdtempSync(join(tmpdir(), "screencast-callout-"));
73
85
  try {
74
- const assets = await prepareCalloutAssets(items, work);
86
+ const assets = await prepareCalloutAssets(items, work, "", args.fontFile);
75
87
  const ffArgs = buildCalloutArgs(args.input, output, items, assets);
76
88
  await runEditJob(ffArgs, { output, durationSec: await probeDuration(args.input), extra });
89
+ return okResponse({
90
+ outputPath: output,
91
+ callouts: items.length,
92
+ ...(assets.fallbackFonts.length > 0 && { fallbackFonts: assets.fallbackFonts }),
93
+ ...(assets.warnings.length > 0 && { warnings: assets.warnings }),
94
+ });
77
95
  }
78
96
  finally {
79
97
  rmSync(work, { recursive: true, force: true });
80
98
  }
81
- return okResponse({ outputPath: output, callouts: items.length });
82
99
  }
83
100
  catch (error) {
84
101
  return errorResponse(error);
85
102
  }
86
103
  });
87
104
  }
88
- //# sourceMappingURL=callout.js.map
@@ -0,0 +1,156 @@
1
+ import { z } from "zod";
2
+ import { extname, join } from "node:path";
3
+ import { existsSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from "node:fs";
4
+ import { tmpdir } from "node:os";
5
+ import { errorResponse, okResponse, ScreencastError } from "../utils/errors.js";
6
+ import { WRITES_FILE, looseOutput } from "../utils/toolSpec.js";
7
+ import { requireFfmpeg, probeMedia, runCapture } from "../utils/ffmpeg.js";
8
+ import { jobTimeoutMs, runEditJob } from "../utils/jobs.js";
9
+ import { buildSceneScanArgs, parseSceneScan, editOutputExt, DEFAULT_SCENE_THRESHOLD } from "../utils/media.js";
10
+ import { parseSrt } from "../utils/captions.js";
11
+ import { buildChapters, buildChaptersMuxArgs, ffmetadata, markerPoints, markersOrChapters, scenePoints, transcriptPoints, youtubeChapters, YOUTUBE_MIN_CHAPTER_SEC, } from "../utils/chapters.js";
12
+ import { resolveOutput, subdir, stamp, rand } from "../utils/paths.js";
13
+ import { getStore } from "../context.js";
14
+ const CONTAINERS = new Set([".mp4", ".mkv", ".mov"]);
15
+ const MAX_SCENE_CHAPTERS = 12;
16
+ const inputSchema = {
17
+ input: z.string().min(1).optional().describe("Path to the video."),
18
+ sessionId: z.string().min(1).optional().describe("Or a stopped recording's id."),
19
+ from: z
20
+ .enum(["markers", "scenes", "transcript"])
21
+ .optional()
22
+ .describe("markers (default; add_marker, else the file's chapters), scenes (screen changes), or transcript (SRT sections)."),
23
+ chapters: z
24
+ .array(z.object({ start: z.number().min(0), title: z.string().min(1).max(100) }))
25
+ .min(1)
26
+ .max(200)
27
+ .optional()
28
+ .describe("Or explicit { start, title } chapters."),
29
+ transcript: z.string().optional().describe("The .srt for from: transcript."),
30
+ minChapterSec: z
31
+ .number()
32
+ .min(0)
33
+ .optional()
34
+ .describe(`Shortest chapter (default 1; scenes ${YOUTUBE_MIN_CHAPTER_SEC}, transcript 30).`),
35
+ subtitles: z.string().optional().describe("Also mux this .srt/.vtt/.ass as a soft subtitle track."),
36
+ subtitleLanguage: z.string().regex(/^[a-z]{3}$/).optional().describe('ISO 639-2, e.g. "eng".'),
37
+ textOnly: z.boolean().optional().describe("Return chapters and YouTube text only; write no file."),
38
+ output: z.string().optional().describe("Optional .mp4/.mkv/.mov path. Defaults under SCREENCAST_HOME/edits."),
39
+ overwrite: z.boolean().optional().describe("Allow replacing an existing output file."),
40
+ };
41
+ export function register(server) {
42
+ server.registerTool("chapters", {
43
+ title: "Chapters",
44
+ description: "Write chapters (markers, scene changes, transcript, or a list) into an mp4/mkv/mov copy without " +
45
+ "re-encoding; returns YouTube chapter text. Can mux an SRT as soft subtitles.",
46
+ inputSchema,
47
+ outputSchema: looseOutput({
48
+ chapters: z.array(looseOutput({ start: z.number(), end: z.number(), title: z.string() })),
49
+ youtube: z.string(),
50
+ }),
51
+ annotations: WRITES_FILE,
52
+ }, async (args, extra) => {
53
+ try {
54
+ requireFfmpeg();
55
+ let input = args.input;
56
+ let sessionMarkers;
57
+ if (args.sessionId) {
58
+ const record = getStore().get(args.sessionId);
59
+ if (!record)
60
+ throw new ScreencastError(`No session with id "${args.sessionId}".`);
61
+ if (record.status === "recording")
62
+ throw new ScreencastError("The recording is still running; stop it first.");
63
+ input ??= record.outputPath;
64
+ sessionMarkers = record.markers;
65
+ }
66
+ if (!input)
67
+ throw new ScreencastError("Pass input or sessionId.");
68
+ if (!existsSync(input))
69
+ throw new ScreencastError(`Input file not found: ${input}`);
70
+ for (const f of [args.transcript, args.subtitles]) {
71
+ if (f !== undefined && !existsSync(f))
72
+ throw new ScreencastError(`File not found: ${f}`);
73
+ }
74
+ if (args.subtitles && !/\.(srt|vtt|ass|ssa)$/i.test(args.subtitles)) {
75
+ throw new ScreencastError("subtitles must be an .srt, .vtt, or .ass file.");
76
+ }
77
+ const info = await probeMedia(input);
78
+ const durationSec = info.durationSec;
79
+ if (!durationSec || durationSec <= 0)
80
+ throw new ScreencastError(`Could not read the duration of ${input}.`);
81
+ const from = args.chapters ? "list" : (args.from ?? "markers");
82
+ let points;
83
+ let minDefault = 1;
84
+ let source = from;
85
+ if (args.chapters) {
86
+ points = args.chapters;
87
+ }
88
+ else if (from === "scenes") {
89
+ minDefault = YOUTUBE_MIN_CHAPTER_SEC;
90
+ const { ffmpeg } = requireFfmpeg();
91
+ const scan = await runCapture(ffmpeg, buildSceneScanArgs(input, DEFAULT_SCENE_THRESHOLD), jobTimeoutMs(durationSec), { signal: extra.signal });
92
+ if (scan.code !== 0) {
93
+ throw new ScreencastError(`Scene scan failed (exit ${scan.code}): ${scan.stderr.trim().slice(-400)}`);
94
+ }
95
+ points = scenePoints(parseSceneScan(scan.stdout), args.minChapterSec ?? minDefault, MAX_SCENE_CHAPTERS);
96
+ }
97
+ else if (from === "transcript") {
98
+ if (!args.transcript)
99
+ throw new ScreencastError("from: transcript needs transcript (an .srt path).");
100
+ minDefault = 30;
101
+ points = transcriptPoints(parseSrt(readFileSync(args.transcript, "utf8")), { minChapterSec: args.minChapterSec ?? minDefault });
102
+ if (points.length === 0)
103
+ throw new ScreencastError(`No cues in ${args.transcript}.`);
104
+ }
105
+ else {
106
+ let markers = sessionMarkers ?? [];
107
+ if (markers.length === 0) {
108
+ const found = await markersOrChapters(input, extra.signal);
109
+ markers = found.markers;
110
+ if (found.from === "chapters")
111
+ source = "embedded chapters";
112
+ }
113
+ if (markers.length === 0) {
114
+ throw new ScreencastError(`No markers for ${input}.`, "Add some with add_marker, or use from: scenes / transcript, or pass chapters.");
115
+ }
116
+ points = markerPoints(markers);
117
+ }
118
+ const chapters = buildChapters(points, durationSec, { minChapterSec: args.minChapterSec ?? minDefault });
119
+ if (chapters.length === 0)
120
+ throw new ScreencastError("No chapter falls inside the video.");
121
+ const yt = youtubeChapters(chapters, durationSec);
122
+ const result = {
123
+ source,
124
+ chapters,
125
+ youtube: yt.text,
126
+ ...(yt.issues.length > 0 ? { youtubeIssues: yt.issues } : {}),
127
+ };
128
+ if (args.textOnly)
129
+ return okResponse(result);
130
+ const ext = (args.output ? extname(args.output).toLowerCase() : editOutputExt(input));
131
+ if (!CONTAINERS.has(ext)) {
132
+ throw new ScreencastError(`Chapters can be written to .mp4, .mkv, or .mov, not ${ext || "a file without an extension"}.`);
133
+ }
134
+ const output = resolveOutput(args.output, subdir("edits"), `chapters-${stamp()}-${rand()}${ext}`, args.overwrite);
135
+ const work = mkdtempSync(join(tmpdir(), "screencast-chapters-"));
136
+ try {
137
+ const meta = join(work, "chapters.txt");
138
+ writeFileSync(meta, ffmetadata(chapters));
139
+ await runEditJob(buildChaptersMuxArgs(input, meta, output, { container: ext, subtitles: args.subtitles, language: args.subtitleLanguage }), { output, durationSec, extra });
140
+ }
141
+ finally {
142
+ rmSync(work, { recursive: true, force: true });
143
+ }
144
+ return okResponse({
145
+ outputPath: output,
146
+ ...result,
147
+ ...(args.subtitles
148
+ ? { subtitleTrack: { file: args.subtitles, codec: ext === ".mkv" ? "copy" : "mov_text", ...(args.subtitleLanguage ? { language: args.subtitleLanguage } : {}) } }
149
+ : {}),
150
+ });
151
+ }
152
+ catch (error) {
153
+ return errorResponse(error);
154
+ }
155
+ });
156
+ }
@@ -1,6 +1,7 @@
1
1
  import { z } from "zod";
2
2
  import { existsSync } from "node:fs";
3
3
  import { errorResponse, okResponse, ScreencastError } from "../utils/errors.js";
4
+ import { WRITES_FILE, looseOutput } from "../utils/toolSpec.js";
4
5
  import { requireFfmpeg } from "../utils/ffmpeg.js";
5
6
  import { runEditJob } from "../utils/jobs.js";
6
7
  import { buildClipArgs, editOutputExt, assertEditContainer } from "../utils/media.js";
@@ -9,11 +10,11 @@ const inputSchema = {
9
10
  input: z.string().min(1).describe("Path to the source video."),
10
11
  segments: z
11
12
  .array(z.object({
12
- start: z.number().nonnegative().describe("Segment start in seconds."),
13
- end: z.number().positive().describe("Segment end in seconds."),
13
+ start: z.number().nonnegative(),
14
+ end: z.number().positive(),
14
15
  }))
15
16
  .min(1)
16
- .describe("One or more {start, end} segments. Each becomes its own output file."),
17
+ .describe("{start, end} segments in seconds; each becomes its own file."),
17
18
  output: z
18
19
  .string()
19
20
  .optional()
@@ -21,9 +22,13 @@ const inputSchema = {
21
22
  overwrite: z.boolean().optional().describe("Allow replacing an existing file at the output path (default false)."),
22
23
  };
23
24
  export function register(server) {
24
- server.tool("clip", "Extract one or more frame-accurate sub-segments to separate files. Unlike " +
25
- "trim (fast stream copy that snaps to a keyframe), clip re-encodes so cuts " +
26
- "land exactly on the given times.", inputSchema, async (args, extra) => {
25
+ server.registerTool("clip", {
26
+ title: "Extract Clips",
27
+ description: "Extract several frame-exact segments, each to its own file. For one segment, trim does the same.",
28
+ inputSchema,
29
+ outputSchema: looseOutput({ outputs: z.array(z.string()), count: z.number().int() }),
30
+ annotations: WRITES_FILE,
31
+ }, async (args, extra) => {
27
32
  try {
28
33
  requireFfmpeg();
29
34
  if (!existsSync(args.input)) {
@@ -33,8 +38,7 @@ export function register(server) {
33
38
  const ext = editOutputExt(args.input);
34
39
  const single = args.segments.length === 1;
35
40
  const outputs = [];
36
- for (let i = 0; i < args.segments.length; i++) {
37
- const seg = args.segments[i];
41
+ for (const [i, seg] of args.segments.entries()) {
38
42
  const output = resolveOutput(single ? args.output : undefined, subdir("edits"), `clip-${stamp()}-${rand()}-${String(i).padStart(2, "0")}${ext}`, args.overwrite);
39
43
  await runEditJob(buildClipArgs(args.input, output, seg), { output, durationSec: seg.end - seg.start, extra });
40
44
  outputs.push(output);
@@ -46,4 +50,3 @@ export function register(server) {
46
50
  }
47
51
  });
48
52
  }
49
- //# sourceMappingURL=clip.js.map
@@ -1,6 +1,7 @@
1
1
  import { z } from "zod";
2
2
  import { existsSync } from "node:fs";
3
3
  import { errorResponse, okResponse, ScreencastError } from "../utils/errors.js";
4
+ import { OUTPUT_PATH, WRITES_FILE } from "../utils/toolSpec.js";
4
5
  import { requireFfmpeg } from "../utils/ffmpeg.js";
5
6
  import { runEditJob, probeDuration } from "../utils/jobs.js";
6
7
  import { buildCompressArgs, editOutputExt, assertEditContainer } from "../utils/media.js";
@@ -10,19 +11,24 @@ const inputSchema = {
10
11
  level: z
11
12
  .enum(["light", "medium", "heavy"])
12
13
  .optional()
13
- .describe("How hard to compress (CRF 23 / 28 / 32). Default medium."),
14
+ .describe("CRF 23 / 28 / 32 (default medium)."),
14
15
  maxWidth: z
15
16
  .number()
16
17
  .int()
17
18
  .positive()
18
19
  .optional()
19
- .describe("Optional width cap in px; only ever downscales. Height follows aspect."),
20
+ .describe("Width cap in px (only downscales)."),
20
21
  output: z.string().optional().describe("Optional output path. Defaults under SCREENCAST_HOME/edits."),
21
22
  overwrite: z.boolean().optional().describe("Allow replacing an existing file at the output path (default false)."),
22
23
  };
23
24
  export function register(server) {
24
- server.tool("compress", "Re-encode a video to a smaller file with a CRF quality ladder and an " +
25
- "optional width cap. Returns the output path.", inputSchema, async (args, extra) => {
25
+ server.registerTool("compress", {
26
+ title: "Compress Video",
27
+ description: "Re-encode a video smaller (H.264 CRF ladder, optional width cap). For a platform target use export_preset.",
28
+ inputSchema,
29
+ outputSchema: OUTPUT_PATH,
30
+ annotations: WRITES_FILE,
31
+ }, async (args, extra) => {
26
32
  try {
27
33
  requireFfmpeg();
28
34
  if (!existsSync(args.input)) {
@@ -43,4 +49,3 @@ export function register(server) {
43
49
  }
44
50
  });
45
51
  }
46
- //# sourceMappingURL=compress.js.map
@@ -2,6 +2,7 @@ import { z } from "zod";
2
2
  import { extname, resolve } from "node:path";
3
3
  import { existsSync, writeFileSync, rmSync } from "node:fs";
4
4
  import { errorResponse, okResponse, ScreencastError } from "../utils/errors.js";
5
+ import { OUTPUT_PATH, WRITES_FILE } from "../utils/toolSpec.js";
5
6
  import { requireFfmpeg, probeMedia } from "../utils/ffmpeg.js";
6
7
  import { runEditJob } from "../utils/jobs.js";
7
8
  import { buildConcatArgs, buildConcatListContent, concatCopyBlocker, editOutputExt, assertEditContainer, } from "../utils/media.js";
@@ -11,42 +12,43 @@ const inputSchema = {
11
12
  inputs: z
12
13
  .array(z.string().min(1))
13
14
  .min(2)
14
- .describe("Two or more video paths to join, in order. Matching inputs are stream-copied; others are re-encoded."),
15
+ .describe("Video paths to join, in order."),
15
16
  output: z.string().optional().describe("Optional output path. Defaults under SCREENCAST_HOME/edits."),
16
17
  overwrite: z.boolean().optional().describe("Allow replacing an existing file at the output path (default false)."),
17
18
  };
18
19
  export function register(server) {
19
- server.tool("concat", "Concatenate two or more videos into a single file. Matching inputs are " +
20
- "joined by stream copy (fast, lossless). Inputs that differ in codec, size, " +
21
- "pixel format, frame rate or audio layout, or that hold frames hidden behind " +
22
- "an edit list (a trim with exact: false), are re-encoded with hard cuts " +
23
- "instead, so the result is always a valid file; `mode` in the result says which.", inputSchema, async (args, extra) => {
20
+ server.registerTool("concat", {
21
+ title: "Concatenate Videos",
22
+ description: "Join videos end to end with hard cuts: stream copy when they match, else a re-encode (`mode` " +
23
+ "says which). For transitions use xfade_transition or assemble_highlights.",
24
+ inputSchema,
25
+ outputSchema: OUTPUT_PATH,
26
+ annotations: WRITES_FILE,
27
+ }, async (args, extra) => {
24
28
  try {
25
29
  requireFfmpeg();
26
- // The concat demuxer resolves relative list entries against the list
27
- // file's directory (the OS temp dir), not our cwd, so inputs must be
28
- // absolute by the time they are written to the list.
29
30
  const inputs = args.inputs.map((f) => resolve(f));
30
31
  for (const f of inputs) {
31
32
  if (!existsSync(f))
32
33
  throw new ScreencastError(`Input file not found: ${f}`);
33
34
  }
34
35
  const infos = await Promise.all(inputs.map((f) => probeMedia(f)));
36
+ const [firstInput] = inputs;
37
+ const [first] = infos;
38
+ if (firstInput === undefined || first === undefined)
39
+ throw new ScreencastError("concat needs at least two inputs.");
35
40
  const durations = infos.map((i) => clipLength(i));
36
41
  const durationSec = durations.every((d) => d !== null) ? durations.reduce((a, d) => a + d, 0) : null;
37
- // Mismatched inputs make the concat demuxer write a broken file (#206),
38
- // and a copy carries any hidden frames along (#203): re-encode then.
39
42
  const reason = concatCopyBlocker(inputs, infos);
40
43
  if (reason !== null) {
41
44
  assertEditContainer(args.output);
42
- const output = resolveOutput(args.output, subdir("edits"), `concat-${stamp()}-${rand()}${editOutputExt(inputs[0])}`, args.overwrite);
43
- const first = infos[0];
45
+ const output = resolveOutput(args.output, subdir("edits"), `concat-${stamp()}-${rand()}${editOutputExt(firstInput)}`, args.overwrite);
44
46
  const even = (n) => (n !== null && n >= 2 ? n - (n % 2) : undefined);
45
47
  const ffArgs = buildAssembleArgs(inputs, durations.map((d) => d ?? 0), output, { transition: "cut", width: even(first.width), height: even(first.height), fps: first.fps ?? undefined }, infos.map((i) => i.audioCodec !== null));
46
48
  await runEditJob(ffArgs, { output, durationSec, extra });
47
49
  return okResponse({ outputPath: output, inputCount: inputs.length, mode: "reencode", reason });
48
50
  }
49
- const ext = extname(inputs[0]) || ".mp4";
51
+ const ext = extname(firstInput) || ".mp4";
50
52
  const output = resolveOutput(args.output, subdir("edits"), `concat-${stamp()}-${rand()}${ext}`, args.overwrite);
51
53
  const listFile = tempPath(".txt");
52
54
  writeFileSync(listFile, buildConcatListContent(inputs));
@@ -63,4 +65,3 @@ export function register(server) {
63
65
  }
64
66
  });
65
67
  }
66
- //# sourceMappingURL=concat.js.map
@@ -3,6 +3,7 @@ import { join } from "node:path";
3
3
  import { existsSync, mkdtempSync, rmSync, writeFileSync } from "node:fs";
4
4
  import { tmpdir } from "node:os";
5
5
  import { errorResponse, okResponse, ScreencastError } from "../utils/errors.js";
6
+ import { WRITES_FILE, looseOutput } from "../utils/toolSpec.js";
6
7
  import { requireFfmpeg, runFfmpeg, runCapture, probeMedia } from "../utils/ffmpeg.js";
7
8
  import { jobTimeoutMs } from "../utils/jobs.js";
8
9
  import { buildSceneScanArgs, parseSceneScan, pickSceneFrames, DEFAULT_SCENE_THRESHOLD, } from "../utils/media.js";
@@ -18,18 +19,17 @@ const inputSchema = {
18
19
  .min(1)
19
20
  .max(MAX_SHEET_COUNT)
20
21
  .optional()
21
- .describe(`How many frames to tile (default ${DEFAULT_SHEET_COUNT}, max ${MAX_SHEET_COUNT}).`),
22
+ .describe(`Frames to tile (default ${DEFAULT_SHEET_COUNT}).`),
22
23
  mode: z
23
24
  .enum(["even", "scenes"])
24
25
  .optional()
25
- .describe("'even' spreads frames evenly across the video (default); 'scenes' uses the " +
26
- "opening frame plus the strongest scene changes, so static stretches take no tiles."),
26
+ .describe("even (default) or scenes (strongest changes; static stretches take no tiles)."),
27
27
  sceneThreshold: z
28
28
  .number()
29
29
  .gt(0)
30
30
  .lt(1)
31
31
  .optional()
32
- .describe(`Mode 'scenes': how much a frame must change to count (default ${DEFAULT_SCENE_THRESHOLD}).`),
32
+ .describe(`Mode scenes: change needed, 0-1 (default ${DEFAULT_SCENE_THRESHOLD}).`),
33
33
  columns: z.number().int().min(1).max(12).optional().describe("Tiles per row (default: roughly square)."),
34
34
  tileWidth: z
35
35
  .number()
@@ -37,30 +37,51 @@ const inputSchema = {
37
37
  .min(64)
38
38
  .max(1920)
39
39
  .optional()
40
- .describe(`Width of each tile in px (default ${DEFAULT_TILE_WIDTH}).`),
40
+ .describe(`Tile width in px (default ${DEFAULT_TILE_WIDTH}).`),
41
41
  poster: z
42
42
  .boolean()
43
43
  .optional()
44
- .describe("Instead of a sheet, write one representative poster frame (ffmpeg's thumbnail " +
45
- "filter over 30 candidates spread across the video), e.g. for a video thumbnail."),
44
+ .describe("Write one representative poster frame instead of a sheet."),
46
45
  output: z.string().optional().describe("Optional output .png path. Defaults under SCREENCAST_HOME/frames."),
47
46
  overwrite: z.boolean().optional().describe("Allow replacing an existing file at the output path (default false)."),
48
47
  returnImage: z
49
48
  .boolean()
50
49
  .optional()
51
- .describe("Also return the sheet inline as an image the model can view directly (default true)."),
50
+ .describe("Return the sheet inline (default true)."),
52
51
  maxImageWidth: z
53
52
  .number()
54
53
  .int()
55
54
  .min(16)
56
55
  .optional()
57
- .describe(`Downscale the inline image to at most this width (default ${DEFAULT_MAX_IMAGE_WIDTH}).`),
56
+ .describe(`Max inline image width (default ${DEFAULT_MAX_IMAGE_WIDTH}).`),
58
57
  };
58
+ export async function renderContactSheet(input, times, output, opts, signal) {
59
+ const grid = sheetGrid(times.length, opts.columns);
60
+ const work = mkdtempSync(join(tmpdir(), "screencast-sheet-"));
61
+ try {
62
+ const font = bundledFontPath("bold");
63
+ for (const [i, t] of times.entries()) {
64
+ const labelFile = join(work, `label_${i}.txt`);
65
+ writeFileSync(labelFile, formatTimecode(t));
66
+ const tile = join(work, `tile_${String(i).padStart(3, "0")}.png`);
67
+ await runFfmpeg(buildTileArgs(input, t, tile, opts.tileWidth, font, labelFile), 60_000, { signal });
68
+ }
69
+ await runFfmpeg(buildSheetArgs(sequencePattern(work, "tile_%03d.png"), grid, output), 60_000, { signal });
70
+ }
71
+ finally {
72
+ rmSync(work, { recursive: true, force: true });
73
+ }
74
+ return grid;
75
+ }
59
76
  export function register(server) {
60
- server.tool("contact_sheet", "Tile timestamped frames of a video into ONE image, so the agent can see a whole " +
61
- "recording in a single look: evenly spaced, or at the scene changes. Returns the " +
62
- "image path and the sheet inline. poster: true writes a single representative " +
63
- "frame instead.", inputSchema, async (args) => {
77
+ server.registerTool("contact_sheet", {
78
+ title: "Contact Sheet",
79
+ description: "Tile timestamped frames of a video into one image to see a whole recording at a glance " +
80
+ "(the cheapest first look).",
81
+ inputSchema,
82
+ outputSchema: looseOutput({ outputPath: z.string(), inlineImages: z.number().int() }),
83
+ annotations: WRITES_FILE,
84
+ }, async (args, extra) => {
64
85
  try {
65
86
  const { ffmpeg } = requireFfmpeg();
66
87
  if (!existsSync(args.input)) {
@@ -74,14 +95,16 @@ export function register(server) {
74
95
  const tileWidth = args.tileWidth ?? DEFAULT_TILE_WIDTH;
75
96
  let result;
76
97
  if (args.poster) {
77
- await runFfmpeg(buildPosterArgs(args.input, durationSec, output, Math.max(tileWidth, 1280)), jobTimeoutMs(durationSec));
98
+ await runFfmpeg(buildPosterArgs(args.input, durationSec, output, Math.max(tileWidth, 1280)), jobTimeoutMs(durationSec), {
99
+ signal: extra.signal,
100
+ });
78
101
  result = { outputPath: output, poster: true };
79
102
  }
80
103
  else {
81
104
  const count = args.count ?? DEFAULT_SHEET_COUNT;
82
105
  let times;
83
106
  if (args.mode === "scenes") {
84
- const scan = await runCapture(ffmpeg, buildSceneScanArgs(args.input, args.sceneThreshold ?? DEFAULT_SCENE_THRESHOLD), jobTimeoutMs(durationSec));
107
+ const scan = await runCapture(ffmpeg, buildSceneScanArgs(args.input, args.sceneThreshold ?? DEFAULT_SCENE_THRESHOLD), jobTimeoutMs(durationSec), { signal: extra.signal });
85
108
  if (scan.code !== 0) {
86
109
  throw new ScreencastError(`Scene scan failed (exit ${scan.code}): ${scan.stderr.trim().slice(-400)}`);
87
110
  }
@@ -90,23 +113,7 @@ export function register(server) {
90
113
  else {
91
114
  times = evenTimes(durationSec, count);
92
115
  }
93
- const grid = sheetGrid(times.length, args.columns);
94
- // Tiles and their label files live in a private temp dir, removed
95
- // whatever happens.
96
- const work = mkdtempSync(join(tmpdir(), "screencast-sheet-"));
97
- try {
98
- const font = bundledFontPath("bold");
99
- for (let i = 0; i < times.length; i++) {
100
- const labelFile = join(work, `label_${i}.txt`);
101
- writeFileSync(labelFile, formatTimecode(times[i]));
102
- const tile = join(work, `tile_${String(i).padStart(3, "0")}.png`);
103
- await runFfmpeg(buildTileArgs(args.input, times[i], tile, tileWidth, font, labelFile), 60_000);
104
- }
105
- await runFfmpeg(buildSheetArgs(sequencePattern(work, "tile_%03d.png"), grid, output), 60_000);
106
- }
107
- finally {
108
- rmSync(work, { recursive: true, force: true });
109
- }
116
+ const grid = await renderContactSheet(args.input, times, output, { tileWidth, columns: args.columns }, extra.signal);
110
117
  result = {
111
118
  outputPath: output,
112
119
  mode: args.mode ?? "even",
@@ -125,4 +132,3 @@ export function register(server) {
125
132
  }
126
133
  });
127
134
  }
128
- //# sourceMappingURL=contactSheet.js.map