@tmhs/screencast-mcp 0.38.0 → 0.44.2

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 (329) hide show
  1. package/README.md +58 -14
  2. package/assets/icon.png +0 -0
  3. package/assets/ui/player.html +38 -302
  4. package/assets/ui/player.js +382 -0
  5. package/dist/context.js +0 -5
  6. package/dist/index.js +7 -115
  7. package/dist/prompts.js +0 -7
  8. package/dist/resources.js +2 -14
  9. package/dist/server.js +129 -0
  10. package/dist/tools/assembleHighlights.js +12 -7
  11. package/dist/tools/burnSubtitles.js +12 -6
  12. package/dist/tools/callout.js +32 -16
  13. package/dist/tools/clip.js +12 -9
  14. package/dist/tools/compress.js +10 -5
  15. package/dist/tools/concat.js +16 -15
  16. package/dist/tools/contactSheet.js +26 -22
  17. package/dist/tools/convert.js +12 -6
  18. package/dist/tools/crop.js +12 -7
  19. package/dist/tools/cutIdle.js +15 -9
  20. package/dist/tools/denoise.js +12 -6
  21. package/dist/tools/doctor.js +133 -0
  22. package/dist/tools/exportGif.js +14 -10
  23. package/dist/tools/exportPreset.js +11 -8
  24. package/dist/tools/extractAudio.js +10 -8
  25. package/dist/tools/findText.js +69 -65
  26. package/dist/tools/getMediaInfo.js +17 -3
  27. package/dist/tools/getSession.js +15 -3
  28. package/dist/tools/listAudioDevices.js +14 -7
  29. package/dist/tools/listSessions.js +13 -3
  30. package/dist/tools/listTargets.js +76 -0
  31. package/dist/tools/musicBed.js +14 -10
  32. package/dist/tools/normalizeAudio.js +12 -8
  33. package/dist/tools/overlay.js +16 -12
  34. package/dist/tools/pipeline.js +31 -22
  35. package/dist/tools/readEvents.js +21 -12
  36. package/dist/tools/redactRegion.js +19 -17
  37. package/dist/tools/reframe.js +9 -5
  38. package/dist/tools/reviewRecording.js +63 -22
  39. package/dist/tools/sampleFrames.js +33 -40
  40. package/dist/tools/scale.js +9 -3
  41. package/dist/tools/screenDiff.js +23 -17
  42. package/dist/tools/screenshot.js +21 -17
  43. package/dist/tools/speed.js +15 -4
  44. package/dist/tools/startRecording.js +48 -52
  45. package/dist/tools/stopRecording.js +10 -9
  46. package/dist/tools/titleCard.js +19 -11
  47. package/dist/tools/transcribe.js +13 -7
  48. package/dist/tools/trim.js +11 -10
  49. package/dist/tools/waitForChange.js +37 -22
  50. package/dist/tools/xfadeTransition.js +12 -8
  51. package/dist/tools/zoom.js +26 -29
  52. package/dist/utils/anim.js +1 -21
  53. package/dist/utils/animExport.js +5 -10
  54. package/dist/utils/audio.js +4 -33
  55. package/dist/utils/audioDevices.js +1 -48
  56. package/dist/utils/callout.js +1 -19
  57. package/dist/utils/calloutAssets.js +21 -11
  58. package/dist/utils/capabilities.js +95 -0
  59. package/dist/utils/captions.js +9 -26
  60. package/dist/utils/consent.js +29 -0
  61. package/dist/utils/diff.js +0 -46
  62. package/dist/utils/errors.js +5 -13
  63. package/dist/utils/events.js +21 -77
  64. package/dist/utils/expr.js +11 -0
  65. package/dist/utils/ffmpeg.js +119 -48
  66. package/dist/utils/fontCoverage.js +177 -0
  67. package/dist/utils/fonts.js +139 -23
  68. package/dist/utils/idle.js +12 -24
  69. package/dist/utils/images.js +0 -17
  70. package/dist/utils/jobs.js +42 -41
  71. package/dist/utils/lifecycle.js +0 -29
  72. package/dist/utils/logging.js +75 -0
  73. package/dist/utils/media.js +11 -122
  74. package/dist/utils/monitors.js +7 -43
  75. package/dist/utils/ocr.js +53 -71
  76. package/dist/utils/paths.js +68 -31
  77. package/dist/utils/pipeline.js +0 -23
  78. package/dist/utils/player.js +50 -27
  79. package/dist/utils/produce.js +6 -66
  80. package/dist/utils/resolveTarget.js +0 -19
  81. package/dist/utils/retention.js +1 -15
  82. package/dist/utils/roots.js +42 -0
  83. package/dist/utils/sessions.js +195 -160
  84. package/dist/utils/sheet.js +0 -19
  85. package/dist/utils/still.js +0 -15
  86. package/dist/utils/targetList.js +63 -0
  87. package/dist/utils/targets.js +5 -70
  88. package/dist/utils/toolSpec.js +25 -0
  89. package/dist/utils/toolsets.js +102 -0
  90. package/dist/utils/validate.js +0 -22
  91. package/dist/utils/wgc.js +0 -46
  92. package/dist/utils/windows.js +5 -50
  93. package/dist/utils/zoom.js +55 -85
  94. package/dist/wgcRecorder.js +1 -30
  95. package/package.json +7 -3
  96. package/dist/context.d.ts +0 -9
  97. package/dist/context.d.ts.map +0 -1
  98. package/dist/context.js.map +0 -1
  99. package/dist/index.d.ts +0 -3
  100. package/dist/index.d.ts.map +0 -1
  101. package/dist/index.js.map +0 -1
  102. package/dist/prompts.d.ts +0 -10
  103. package/dist/prompts.d.ts.map +0 -1
  104. package/dist/prompts.js.map +0 -1
  105. package/dist/resources.d.ts +0 -3
  106. package/dist/resources.d.ts.map +0 -1
  107. package/dist/resources.js.map +0 -1
  108. package/dist/tools/assembleHighlights.d.ts +0 -3
  109. package/dist/tools/assembleHighlights.d.ts.map +0 -1
  110. package/dist/tools/assembleHighlights.js.map +0 -1
  111. package/dist/tools/burnSubtitles.d.ts +0 -3
  112. package/dist/tools/burnSubtitles.d.ts.map +0 -1
  113. package/dist/tools/burnSubtitles.js.map +0 -1
  114. package/dist/tools/callout.d.ts +0 -37
  115. package/dist/tools/callout.d.ts.map +0 -1
  116. package/dist/tools/callout.js.map +0 -1
  117. package/dist/tools/clip.d.ts +0 -3
  118. package/dist/tools/clip.d.ts.map +0 -1
  119. package/dist/tools/clip.js.map +0 -1
  120. package/dist/tools/compress.d.ts +0 -3
  121. package/dist/tools/compress.d.ts.map +0 -1
  122. package/dist/tools/compress.js.map +0 -1
  123. package/dist/tools/concat.d.ts +0 -3
  124. package/dist/tools/concat.d.ts.map +0 -1
  125. package/dist/tools/concat.js.map +0 -1
  126. package/dist/tools/contactSheet.d.ts +0 -3
  127. package/dist/tools/contactSheet.d.ts.map +0 -1
  128. package/dist/tools/contactSheet.js.map +0 -1
  129. package/dist/tools/convert.d.ts +0 -3
  130. package/dist/tools/convert.d.ts.map +0 -1
  131. package/dist/tools/convert.js.map +0 -1
  132. package/dist/tools/crop.d.ts +0 -3
  133. package/dist/tools/crop.d.ts.map +0 -1
  134. package/dist/tools/crop.js.map +0 -1
  135. package/dist/tools/cutIdle.d.ts +0 -3
  136. package/dist/tools/cutIdle.d.ts.map +0 -1
  137. package/dist/tools/cutIdle.js.map +0 -1
  138. package/dist/tools/denoise.d.ts +0 -3
  139. package/dist/tools/denoise.d.ts.map +0 -1
  140. package/dist/tools/denoise.js.map +0 -1
  141. package/dist/tools/exportGif.d.ts +0 -3
  142. package/dist/tools/exportGif.d.ts.map +0 -1
  143. package/dist/tools/exportGif.js.map +0 -1
  144. package/dist/tools/exportPreset.d.ts +0 -3
  145. package/dist/tools/exportPreset.d.ts.map +0 -1
  146. package/dist/tools/exportPreset.js.map +0 -1
  147. package/dist/tools/extractAudio.d.ts +0 -3
  148. package/dist/tools/extractAudio.d.ts.map +0 -1
  149. package/dist/tools/extractAudio.js.map +0 -1
  150. package/dist/tools/findText.d.ts +0 -6
  151. package/dist/tools/findText.d.ts.map +0 -1
  152. package/dist/tools/findText.js.map +0 -1
  153. package/dist/tools/getMediaInfo.d.ts +0 -3
  154. package/dist/tools/getMediaInfo.d.ts.map +0 -1
  155. package/dist/tools/getMediaInfo.js.map +0 -1
  156. package/dist/tools/getSession.d.ts +0 -3
  157. package/dist/tools/getSession.d.ts.map +0 -1
  158. package/dist/tools/getSession.js.map +0 -1
  159. package/dist/tools/listAudioDevices.d.ts +0 -3
  160. package/dist/tools/listAudioDevices.d.ts.map +0 -1
  161. package/dist/tools/listAudioDevices.js.map +0 -1
  162. package/dist/tools/listSessions.d.ts +0 -3
  163. package/dist/tools/listSessions.d.ts.map +0 -1
  164. package/dist/tools/listSessions.js.map +0 -1
  165. package/dist/tools/musicBed.d.ts +0 -3
  166. package/dist/tools/musicBed.d.ts.map +0 -1
  167. package/dist/tools/musicBed.js.map +0 -1
  168. package/dist/tools/normalizeAudio.d.ts +0 -3
  169. package/dist/tools/normalizeAudio.d.ts.map +0 -1
  170. package/dist/tools/normalizeAudio.js.map +0 -1
  171. package/dist/tools/overlay.d.ts +0 -3
  172. package/dist/tools/overlay.d.ts.map +0 -1
  173. package/dist/tools/overlay.js.map +0 -1
  174. package/dist/tools/pipeline.d.ts +0 -3
  175. package/dist/tools/pipeline.d.ts.map +0 -1
  176. package/dist/tools/pipeline.js.map +0 -1
  177. package/dist/tools/readEvents.d.ts +0 -6
  178. package/dist/tools/readEvents.d.ts.map +0 -1
  179. package/dist/tools/readEvents.js.map +0 -1
  180. package/dist/tools/redactRegion.d.ts +0 -13
  181. package/dist/tools/redactRegion.d.ts.map +0 -1
  182. package/dist/tools/redactRegion.js.map +0 -1
  183. package/dist/tools/reframe.d.ts +0 -3
  184. package/dist/tools/reframe.d.ts.map +0 -1
  185. package/dist/tools/reframe.js.map +0 -1
  186. package/dist/tools/reviewRecording.d.ts +0 -5
  187. package/dist/tools/reviewRecording.d.ts.map +0 -1
  188. package/dist/tools/reviewRecording.js.map +0 -1
  189. package/dist/tools/sampleFrames.d.ts +0 -3
  190. package/dist/tools/sampleFrames.d.ts.map +0 -1
  191. package/dist/tools/sampleFrames.js.map +0 -1
  192. package/dist/tools/scale.d.ts +0 -3
  193. package/dist/tools/scale.d.ts.map +0 -1
  194. package/dist/tools/scale.js.map +0 -1
  195. package/dist/tools/screenDiff.d.ts +0 -3
  196. package/dist/tools/screenDiff.d.ts.map +0 -1
  197. package/dist/tools/screenDiff.js.map +0 -1
  198. package/dist/tools/screenshot.d.ts +0 -3
  199. package/dist/tools/screenshot.d.ts.map +0 -1
  200. package/dist/tools/screenshot.js.map +0 -1
  201. package/dist/tools/speed.d.ts +0 -3
  202. package/dist/tools/speed.d.ts.map +0 -1
  203. package/dist/tools/speed.js.map +0 -1
  204. package/dist/tools/startRecording.d.ts +0 -3
  205. package/dist/tools/startRecording.d.ts.map +0 -1
  206. package/dist/tools/startRecording.js.map +0 -1
  207. package/dist/tools/stopRecording.d.ts +0 -3
  208. package/dist/tools/stopRecording.d.ts.map +0 -1
  209. package/dist/tools/stopRecording.js.map +0 -1
  210. package/dist/tools/titleCard.d.ts +0 -3
  211. package/dist/tools/titleCard.d.ts.map +0 -1
  212. package/dist/tools/titleCard.js.map +0 -1
  213. package/dist/tools/transcribe.d.ts +0 -3
  214. package/dist/tools/transcribe.d.ts.map +0 -1
  215. package/dist/tools/transcribe.js.map +0 -1
  216. package/dist/tools/trim.d.ts +0 -3
  217. package/dist/tools/trim.d.ts.map +0 -1
  218. package/dist/tools/trim.js.map +0 -1
  219. package/dist/tools/waitForChange.d.ts +0 -3
  220. package/dist/tools/waitForChange.d.ts.map +0 -1
  221. package/dist/tools/waitForChange.js.map +0 -1
  222. package/dist/tools/xfadeTransition.d.ts +0 -3
  223. package/dist/tools/xfadeTransition.d.ts.map +0 -1
  224. package/dist/tools/xfadeTransition.js.map +0 -1
  225. package/dist/tools/zoom.d.ts +0 -15
  226. package/dist/tools/zoom.d.ts.map +0 -1
  227. package/dist/tools/zoom.js.map +0 -1
  228. package/dist/utils/anim.d.ts +0 -33
  229. package/dist/utils/anim.d.ts.map +0 -1
  230. package/dist/utils/anim.js.map +0 -1
  231. package/dist/utils/animExport.d.ts +0 -27
  232. package/dist/utils/animExport.d.ts.map +0 -1
  233. package/dist/utils/animExport.js.map +0 -1
  234. package/dist/utils/audio.d.ts +0 -49
  235. package/dist/utils/audio.d.ts.map +0 -1
  236. package/dist/utils/audio.js.map +0 -1
  237. package/dist/utils/audioDevices.d.ts +0 -33
  238. package/dist/utils/audioDevices.d.ts.map +0 -1
  239. package/dist/utils/audioDevices.js.map +0 -1
  240. package/dist/utils/callout.d.ts +0 -72
  241. package/dist/utils/callout.d.ts.map +0 -1
  242. package/dist/utils/callout.js.map +0 -1
  243. package/dist/utils/calloutAssets.d.ts +0 -3
  244. package/dist/utils/calloutAssets.d.ts.map +0 -1
  245. package/dist/utils/calloutAssets.js.map +0 -1
  246. package/dist/utils/captions.d.ts +0 -26
  247. package/dist/utils/captions.d.ts.map +0 -1
  248. package/dist/utils/captions.js.map +0 -1
  249. package/dist/utils/diff.d.ts +0 -112
  250. package/dist/utils/diff.d.ts.map +0 -1
  251. package/dist/utils/diff.js.map +0 -1
  252. package/dist/utils/errors.d.ts +0 -33
  253. package/dist/utils/errors.d.ts.map +0 -1
  254. package/dist/utils/errors.js.map +0 -1
  255. package/dist/utils/events.d.ts +0 -143
  256. package/dist/utils/events.d.ts.map +0 -1
  257. package/dist/utils/events.js.map +0 -1
  258. package/dist/utils/ffmpeg.d.ts +0 -50
  259. package/dist/utils/ffmpeg.d.ts.map +0 -1
  260. package/dist/utils/ffmpeg.js.map +0 -1
  261. package/dist/utils/fonts.d.ts +0 -17
  262. package/dist/utils/fonts.d.ts.map +0 -1
  263. package/dist/utils/fonts.js.map +0 -1
  264. package/dist/utils/idle.d.ts +0 -23
  265. package/dist/utils/idle.d.ts.map +0 -1
  266. package/dist/utils/idle.js.map +0 -1
  267. package/dist/utils/images.d.ts +0 -21
  268. package/dist/utils/images.d.ts.map +0 -1
  269. package/dist/utils/images.js.map +0 -1
  270. package/dist/utils/jobs.d.ts +0 -44
  271. package/dist/utils/jobs.d.ts.map +0 -1
  272. package/dist/utils/jobs.js.map +0 -1
  273. package/dist/utils/lifecycle.d.ts +0 -29
  274. package/dist/utils/lifecycle.d.ts.map +0 -1
  275. package/dist/utils/lifecycle.js.map +0 -1
  276. package/dist/utils/media.d.ts +0 -272
  277. package/dist/utils/media.d.ts.map +0 -1
  278. package/dist/utils/media.js.map +0 -1
  279. package/dist/utils/monitors.d.ts +0 -47
  280. package/dist/utils/monitors.d.ts.map +0 -1
  281. package/dist/utils/monitors.js.map +0 -1
  282. package/dist/utils/ocr.d.ts +0 -50
  283. package/dist/utils/ocr.d.ts.map +0 -1
  284. package/dist/utils/ocr.js.map +0 -1
  285. package/dist/utils/paths.d.ts +0 -28
  286. package/dist/utils/paths.d.ts.map +0 -1
  287. package/dist/utils/paths.js.map +0 -1
  288. package/dist/utils/pipeline.d.ts +0 -69
  289. package/dist/utils/pipeline.d.ts.map +0 -1
  290. package/dist/utils/pipeline.js.map +0 -1
  291. package/dist/utils/player.d.ts +0 -30
  292. package/dist/utils/player.d.ts.map +0 -1
  293. package/dist/utils/player.js.map +0 -1
  294. package/dist/utils/produce.d.ts +0 -126
  295. package/dist/utils/produce.d.ts.map +0 -1
  296. package/dist/utils/produce.js.map +0 -1
  297. package/dist/utils/resolveTarget.d.ts +0 -32
  298. package/dist/utils/resolveTarget.d.ts.map +0 -1
  299. package/dist/utils/resolveTarget.js.map +0 -1
  300. package/dist/utils/retention.d.ts +0 -10
  301. package/dist/utils/retention.d.ts.map +0 -1
  302. package/dist/utils/retention.js.map +0 -1
  303. package/dist/utils/sessions.d.ts +0 -154
  304. package/dist/utils/sessions.d.ts.map +0 -1
  305. package/dist/utils/sessions.js.map +0 -1
  306. package/dist/utils/sheet.d.ts +0 -26
  307. package/dist/utils/sheet.d.ts.map +0 -1
  308. package/dist/utils/sheet.js.map +0 -1
  309. package/dist/utils/still.d.ts +0 -7
  310. package/dist/utils/still.d.ts.map +0 -1
  311. package/dist/utils/still.js.map +0 -1
  312. package/dist/utils/targets.d.ts +0 -113
  313. package/dist/utils/targets.d.ts.map +0 -1
  314. package/dist/utils/targets.js.map +0 -1
  315. package/dist/utils/validate.d.ts +0 -15
  316. package/dist/utils/validate.d.ts.map +0 -1
  317. package/dist/utils/validate.js.map +0 -1
  318. package/dist/utils/wgc.d.ts +0 -46
  319. package/dist/utils/wgc.d.ts.map +0 -1
  320. package/dist/utils/wgc.js.map +0 -1
  321. package/dist/utils/windows.d.ts +0 -94
  322. package/dist/utils/windows.d.ts.map +0 -1
  323. package/dist/utils/windows.js.map +0 -1
  324. package/dist/utils/zoom.d.ts +0 -95
  325. package/dist/utils/zoom.d.ts.map +0 -1
  326. package/dist/utils/zoom.js.map +0 -1
  327. package/dist/wgcRecorder.d.ts +0 -2
  328. package/dist/wgcRecorder.d.ts.map +0 -1
  329. package/dist/wgcRecorder.js.map +0 -1
@@ -1,31 +1,31 @@
1
1
  import { spawn } from "node:child_process";
2
2
  import { z } from "zod";
3
3
  import { errorResponse, okResponse, ScreencastError } from "../utils/errors.js";
4
+ import { WRITES_FILE, looseOutput } from "../utils/toolSpec.js";
4
5
  import { requireFfmpeg, wgcAvailable } from "../utils/ffmpeg.js";
5
6
  import { fileURLToPath } from "node:url";
6
7
  import { buildCaptureArgs, captureFrame, resolveQuality, DEFAULT_FPS, DEFAULT_QUALITY, DEFAULT_MAX_RECORDING_SEC, MAX_RECORDING_CAP_SEC, resolveMaxDuration, captureKeyframeArgs, } from "../utils/targets.js";
7
8
  import { resolveCaptureTarget } from "../utils/resolveTarget.js";
8
9
  import { windowMatchReport } from "../utils/windows.js";
9
10
  import { resolveLoopbackDevice } from "../utils/audioDevices.js";
11
+ import { confirmCapture, describeTarget } from "../utils/consent.js";
12
+ import { logMessage, StderrWatch } from "../utils/logging.js";
10
13
  import { resolveOutput, subdir, stamp, rand } from "../utils/paths.js";
11
14
  import { getStore } from "../context.js";
12
- import { classifyUnrequestedExit, killPid } from "../utils/sessions.js";
15
+ import { classifyUnrequestedExit, killPid, serverIdentity } from "../utils/sessions.js";
13
16
  import { rmSync } from "node:fs";
14
17
  import { basename } from "node:path";
15
- import { DEFAULT_KEY_MODE, eventPaths, parseCaptureStart, startEventLogger, stopEventLogger, summarizeEvents, trackFinalizer, writeEventsFile, } from "../utils/events.js";
18
+ import { DEFAULT_KEY_MODE, eventPaths, parseCaptureStart, prepareEventPaths, startEventLogger, stopEventLogger, summarizeEvents, trackFinalizer, writeEventsFile, } from "../utils/events.js";
16
19
  const inputSchema = {
17
20
  target: z
18
21
  .string()
19
- .describe("Capture target: 'full' | 'monitor:<index>' (0 = primary) | " +
20
- "'window:<title>' (or window:exe=<app.exe> / window:hwnd=<handle>, without relying on the title) | 'region:<x>,<y>,<w>,<h>' (absolute pixels). " +
21
- "window: records the on-screen rectangle the window occupies, resolved " +
22
- "ONCE at start (it must be visible, on top, not minimized); it does not " +
23
- "follow a window moved or resized mid-recording."),
22
+ .describe("full | monitor:<i> (0 = primary) | window:<title> (or window:exe=<app.exe> / window:hwnd=<n>) | " +
23
+ "region:<x>,<y>,<w>,<h>. With gdigrab a window's rectangle is resolved once at start (visible, " +
24
+ "on top); it does not follow the window."),
24
25
  exactTitle: z
25
26
  .boolean()
26
27
  .optional()
27
- .describe("For window: targets, match only a window whose title equals the given " +
28
- "title (case-insensitive); never fall back to a substring match. Default false."),
28
+ .describe("window: targets match the whole title only, never a substring (default false)."),
29
29
  fps: z
30
30
  .number()
31
31
  .int()
@@ -41,20 +41,18 @@ const inputSchema = {
41
41
  .object({
42
42
  source: z
43
43
  .enum(["system", "none"])
44
- .describe("system captures what is playing on the machine; none is video-only."),
44
+ .describe("system = what the machine plays (needs a loopback device); none = video only."),
45
45
  device: z
46
46
  .string()
47
47
  .optional()
48
- .describe("Optional dshow loopback device name (from list_audio_devices). When " +
49
- "omitted, a loopback device is auto-detected."),
48
+ .describe("dshow loopback device (from list_audio_devices); auto-detected if omitted."),
50
49
  })
51
50
  .optional()
52
- .describe("Audio capture (default none, video-only). source 'system' needs a " +
53
- "loopback device; microphone capture is not supported."),
51
+ .describe("Audio (default none). No microphone capture."),
54
52
  output: z
55
53
  .string()
56
54
  .optional()
57
- .describe("Optional output .mp4 path. Defaults to a file under SCREENCAST_HOME/recordings."),
55
+ .describe("Output .mp4 path (default under SCREENCAST_HOME/recordings)."),
58
56
  overwrite: z.boolean().optional().describe("Allow replacing an existing file at the output path (default false)."),
59
57
  maxDurationSec: z
60
58
  .number()
@@ -62,34 +60,38 @@ const inputSchema = {
62
60
  .min(0)
63
61
  .max(MAX_RECORDING_CAP_SEC)
64
62
  .optional()
65
- .describe(`Stop automatically after this many seconds, finalizing the file (default ` +
66
- `${DEFAULT_MAX_RECORDING_SEC}, or SCREENCAST_MAX_RECORDING_SEC; at most ${MAX_RECORDING_CAP_SEC}, 7 days). 0 = no cap. ` +
67
- "A safety net against a recording that is never stopped."),
63
+ .describe(`Auto-stop after this many seconds (default ${DEFAULT_MAX_RECORDING_SEC} or ` +
64
+ "SCREENCAST_MAX_RECORDING_SEC; max 7 days; 0 = no cap)."),
68
65
  events: z
69
66
  .boolean()
70
67
  .optional()
71
- .describe("Also log mouse clicks, scroll, cursor positions, and typing to " +
72
- "<recording>.events.jsonl, timed to the video and in video pixels (default " +
73
- "false). Read it with read_events. Adds about a second to start."),
68
+ .describe("Also log clicks, scroll, cursor, and typing (video-timed, video pixels) for read_events " +
69
+ "(default false; ~1 s slower start)."),
74
70
  keys: z
75
71
  .enum(["masked", "shortcuts"])
76
72
  .optional()
77
- .describe("With events: masked (default) logs typing only as bursts (start and length on a 0.5 s grid), " +
78
- "never which keys or when each one was pressed. shortcuts also names chords made with Ctrl, Alt, " +
79
- "or Win (e.g. Ctrl+S), with their times; typed text is never logged."),
73
+ .describe("With events: masked (default) logs typing only as 0.5 s-grid bursts, never keys; shortcuts " +
74
+ "also names Ctrl/Alt/Win chords. Typed text is never logged."),
80
75
  backend: z
81
76
  .enum(["gdigrab", "wgc"])
82
77
  .optional()
83
- .describe("gdigrab (default) records the screen rectangle. wgc (window: targets, FFmpeg 8+) records the " +
84
- "window's own surface through Windows Graphics Capture: it keeps recording the window when " +
85
- "it is covered, moved, or in the background, and frames only its client area. No audio with wgc."),
78
+ .describe("gdigrab (default): the screen rectangle. wgc (window: targets, FFmpeg 8+): the window's own " +
79
+ "surface, even when covered or moved; client area only, no audio."),
86
80
  };
87
81
  export function register(server) {
88
- server.tool("start_recording", "Start a screen recording (Windows gdigrab) as a background ffmpeg process. " +
89
- "Returns a session id and output path. Recording is explicit and never " +
90
- "auto-starts. Use stop_recording with the id to finalize the file. " +
91
- "Audio is video-only by default; set audio.source = 'system' to also " +
92
- "capture system (loopback) audio. Microphone capture is not supported.", inputSchema, async (args) => {
82
+ server.registerTool("start_recording", {
83
+ title: "Start Recording",
84
+ description: "Start a background screen recording. Returns a session id; finalize it with stop_recording. " +
85
+ "Never auto-starts.",
86
+ inputSchema,
87
+ outputSchema: looseOutput({
88
+ sessionId: z.string(),
89
+ status: z.string(),
90
+ backend: z.string(),
91
+ outputPath: z.string(),
92
+ }),
93
+ annotations: WRITES_FILE,
94
+ }, async (args, extra) => {
93
95
  try {
94
96
  const { ffmpeg } = requireFfmpeg();
95
97
  const { target, monitors, window } = await resolveCaptureTarget(args.target, {
@@ -110,11 +112,14 @@ export function register(server) {
110
112
  const quality = args.quality ?? DEFAULT_QUALITY;
111
113
  const maxDurationSec = resolveMaxDuration(args.maxDurationSec);
112
114
  const output = resolveOutput(args.output, subdir("recordings"), `rec-${stamp()}-${rand()}.mp4`, args.overwrite);
113
- // Resolve a loopback device up front so a missing one fails before the
114
- // ffmpeg child is spawned, with a clear install hint.
115
115
  const audio = args.audio?.source === "system"
116
116
  ? { device: await resolveLoopbackDevice(args.audio.device) }
117
117
  : undefined;
118
+ await confirmCapture(server, `Record ${describeTarget(args.target, window)} ` +
119
+ (maxDurationSec > 0 ? `for up to ${maxDurationSec} s` : "with no time limit") +
120
+ (audio ? `, with system audio (${audio.device})` : ", without audio") +
121
+ (args.events ? ", logging mouse clicks and typing" : "") +
122
+ `, saved to ${output}?`, extra.signal);
118
123
  const ffArgs = buildCaptureArgs(target, {
119
124
  fps,
120
125
  quality,
@@ -123,10 +128,10 @@ export function register(server) {
123
128
  audio,
124
129
  maxDurationSec,
125
130
  });
126
- // The event logger starts first so the first frames have events (#118).
127
131
  const keyMode = args.keys ?? DEFAULT_KEY_MODE;
128
132
  const evPaths = args.events ? eventPaths(output) : null;
129
- // wgc frames the client area; its size is known once the recorder starts.
133
+ if (evPaths)
134
+ prepareEventPaths(evPaths, args.overwrite);
130
135
  let frame = args.events
131
136
  ? captureFrame(target, monitors)
132
137
  : null;
@@ -141,18 +146,17 @@ export function register(server) {
141
146
  stdio: ["pipe", "ignore", "pipe"],
142
147
  windowsHide: true,
143
148
  });
144
- // Detect an immediate failure (bad window title, busy device, etc.).
145
- // The head keeps the input banner, whose start: time aligns events.
146
149
  let stderrTail = "";
147
150
  let stderrHead = "";
151
+ const id = `rec-${stamp()}-${rand(6)}`;
152
+ const watch = new StderrWatch(() => ({ sessionId: id }));
148
153
  child.stderr?.on("data", (d) => {
149
154
  const text = d.toString();
150
155
  stderrTail = (stderrTail + text).slice(-2000);
151
156
  if (stderrHead.length < 8000)
152
157
  stderrHead += text;
158
+ watch.feed(text);
153
159
  });
154
- // gdigrab is running once it survives a moment; the wgc recorder says
155
- // so when its first frame is written (a repaint can take a second).
156
160
  const settled = await new Promise((resolve) => {
157
161
  const timer = setTimeout(() => resolve("running"), backend === "wgc" ? 15_000 : 1200);
158
162
  if (backend === "wgc") {
@@ -173,7 +177,6 @@ export function register(server) {
173
177
  resolve("exited");
174
178
  });
175
179
  });
176
- const id = `rec-${stamp()}-${rand(6)}`;
177
180
  if (settled === "exited") {
178
181
  if (logger)
179
182
  await stopEventLogger(logger);
@@ -193,7 +196,7 @@ export function register(server) {
193
196
  fps,
194
197
  quality,
195
198
  pid: child.pid ?? null,
196
- serverPid: process.pid,
199
+ ...serverIdentity(),
197
200
  status: "recording",
198
201
  startedAt: new Date().toISOString(),
199
202
  ...(maxDurationSec > 0 ? { maxDurationSec } : {}),
@@ -203,8 +206,6 @@ export function register(server) {
203
206
  processImage: backend === "wgc" ? basename(process.execPath).toLowerCase() : "ffmpeg.exe",
204
207
  };
205
208
  const store = getStore();
206
- // Register the child for shutdown first; if the registry write fails,
207
- // stop the capture rather than leave one nothing can reach (#207).
208
209
  store.attachChild(id, child);
209
210
  try {
210
211
  store.create(record);
@@ -239,19 +240,15 @@ export function register(server) {
239
240
  process.stderr.write(`Event log for ${id} failed: ${err instanceof Error ? err.message : String(err)}\n`);
240
241
  }));
241
242
  }
242
- // Keep the on-disk record consistent if the child dies on its own. A
243
- // non-zero exit is a crash (disk full, encoder failure), not a clean
244
- // stop - record it as "failed" with the stderr tail so the caller can
245
- // tell the two apart. A clean exit nobody requested is the
246
- // maxDurationSec cap, or the recorded window closing (#240).
247
243
  child.on("exit", (code) => {
248
244
  store.detachChild(id);
249
245
  const cur = store.get(id);
250
- // A deliberate stop (stop_recording / shutdown) records its own final
251
- // state; only an exit nobody asked for is classified here.
252
246
  if (!cur || cur.status !== "recording" || store.isStopping(id))
253
247
  return;
254
248
  const verdict = classifyUnrequestedExit({ code, backend, maxDurationSec, elapsedMs: Date.now() - spawnedAt });
249
+ logMessage(verdict.status === "failed" ? "error" : "notice", verdict.status === "failed"
250
+ ? `Recording ${id} failed: the recorder exited with code ${code}.`
251
+ : `Recording ${id} ended on its own (${verdict.endReason}).`, { sessionId: id, ...verdict });
255
252
  store.tryUpdate(id, {
256
253
  ...verdict,
257
254
  stoppedAt: new Date().toISOString(),
@@ -283,4 +280,3 @@ export function register(server) {
283
280
  }
284
281
  });
285
282
  }
286
- //# sourceMappingURL=startRecording.js.map
@@ -1,23 +1,25 @@
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 { STOPS_SESSION, looseOutput } from "../utils/toolSpec.js";
4
5
  import { requireFfmpeg } from "../utils/ffmpeg.js";
5
6
  import { probeDuration, stopSession } from "../utils/lifecycle.js";
6
7
  import { getStore } from "../context.js";
7
- import { PLAYER_TOOL_META } from "../utils/player.js";
8
8
  const inputSchema = {
9
9
  sessionId: z.string().min(1).describe("Session id returned by start_recording."),
10
10
  };
11
11
  export function register(server) {
12
12
  server.registerTool("stop_recording", {
13
- description: "Stop a recording by session id. Sends ffmpeg a graceful quit so the file " +
14
- "is finalized rather than truncated, then returns the final path and " +
15
- "duration. Falls back to terminating the process by pid if the live " +
16
- "handle was lost (for example after a server restart). Clients with MCP " +
17
- "Apps show the review player for the result.",
13
+ title: "Stop Recording",
14
+ description: "Stop a recording gracefully so the file is finalized; returns the path and duration.",
18
15
  inputSchema,
19
- // The review player (#128) renders for this result in Apps-capable hosts.
20
- _meta: PLAYER_TOOL_META,
16
+ outputSchema: looseOutput({
17
+ sessionId: z.string(),
18
+ status: z.string(),
19
+ outputPath: z.string(),
20
+ durationSec: z.number().nullable(),
21
+ }),
22
+ annotations: STOPS_SESSION,
21
23
  }, async (args) => {
22
24
  try {
23
25
  const store = getStore();
@@ -65,4 +67,3 @@ export function register(server) {
65
67
  }
66
68
  });
67
69
  }
68
- //# sourceMappingURL=stopRecording.js.map
@@ -1,10 +1,12 @@
1
1
  import { z } from "zod";
2
2
  import { writeFileSync, rmSync } from "node:fs";
3
3
  import { errorResponse, okResponse } 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 } from "../utils/jobs.js";
6
7
  import { buildTitleCardArgs, DEFAULT_TITLE_DURATION } from "../utils/produce.js";
7
- import { bundledFontPath } from "../utils/fonts.js";
8
+ import { resolveTextFont } from "../utils/fonts.js";
9
+ import { fontFileSchema } from "./callout.js";
8
10
  import { resolveOutput, subdir, stamp, rand, tempPath } from "../utils/paths.js";
9
11
  const inputSchema = {
10
12
  text: z.string().min(1).describe("Title text. Multiple lines are allowed (use \\n)."),
@@ -16,24 +18,27 @@ const inputSchema = {
16
18
  fontColor: z.string().optional().describe("Text color (default white)."),
17
19
  fontSize: z.number().int().positive().optional().describe("Text size in px (default 96)."),
18
20
  bold: z.boolean().optional().describe("Use the bold weight (default true)."),
21
+ fontFile: fontFileSchema,
19
22
  output: z.string().optional().describe("Optional output path. Defaults under SCREENCAST_HOME/edits."),
20
23
  overwrite: z.boolean().optional().describe("Allow replacing an existing file at the output path (default false)."),
21
24
  };
22
25
  export function register(server) {
23
- server.tool("title_card", "Generate a standalone title card: centered text on a solid background, with " +
24
- "a silent audio track so it composes with audio-bearing clips (use " +
25
- "assemble_highlights to stitch it in). Text is rendered with a bundled " +
26
- "font, so no system font is required.", inputSchema, async (args, extra) => {
26
+ server.registerTool("title_card", {
27
+ title: "Title Card",
28
+ description: "Generate a title card clip (centered text on a solid background, silent audio track) to stitch " +
29
+ "in with assemble_highlights. Uncoverable characters are reported in warnings.",
30
+ inputSchema,
31
+ outputSchema: OUTPUT_PATH,
32
+ annotations: WRITES_FILE,
33
+ }, async (args, extra) => {
27
34
  try {
28
35
  requireFfmpeg();
29
36
  const output = resolveOutput(args.output, subdir("edits"), `title-${stamp()}-${rand()}.mp4`, args.overwrite);
30
- const fontFile = bundledFontPath(args.bold === false ? "regular" : "bold");
31
- // Write the text to a temp file so arbitrary content (quotes, colons,
32
- // percent signs) needs no inline filtergraph escaping.
37
+ const font = resolveTextFont(args.text, { weight: args.bold === false ? "regular" : "bold", fontFile: args.fontFile });
33
38
  const textFile = tempPath(".txt");
34
39
  writeFileSync(textFile, args.text);
35
40
  try {
36
- const ffArgs = buildTitleCardArgs(textFile, fontFile, output, {
41
+ const ffArgs = buildTitleCardArgs(textFile, font.fontFile, output, {
37
42
  duration: args.duration,
38
43
  width: args.width,
39
44
  height: args.height,
@@ -47,11 +52,14 @@ export function register(server) {
47
52
  finally {
48
53
  rmSync(textFile, { force: true });
49
54
  }
50
- return okResponse({ outputPath: output });
55
+ return okResponse({
56
+ outputPath: output,
57
+ ...((font.fallback || args.fontFile) && { fontFile: font.fontFile }),
58
+ ...(font.warning && { warnings: [font.warning] }),
59
+ });
51
60
  }
52
61
  catch (error) {
53
62
  return errorResponse(error);
54
63
  }
55
64
  });
56
65
  }
57
- //# sourceMappingURL=titleCard.js.map
@@ -1,6 +1,7 @@
1
1
  import { z } from "zod";
2
2
  import { existsSync, readFileSync, rmSync, writeFileSync } 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, runFfmpeg, probeMedia, hasFilter } from "../utils/ffmpeg.js";
5
6
  import { jobTimeoutMs } from "../utils/jobs.js";
6
7
  import { resolveWhisperModel, buildTranscribeArgs, parseSrt, normalizeCues, formatSrt, WHISPER_MODEL_ENV, } from "../utils/captions.js";
@@ -16,9 +17,15 @@ const inputSchema = {
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("transcribe", "Transcribe a recording's speech to an SRT subtitle file, locally, with FFmpeg 8's " +
20
- "whisper filter (needs a whisper.cpp model file). Returns the SRT path and the text. " +
21
- "Pair with burn_subtitles to caption the video.", inputSchema, async (args) => {
20
+ server.registerTool("transcribe", {
21
+ title: "Transcribe Speech",
22
+ description: "Transcribe a recording's speech to an SRT subtitle file, locally, with FFmpeg 8's " +
23
+ "whisper filter (needs a whisper.cpp model file). Returns the SRT path and the text. " +
24
+ "Pair with burn_subtitles to caption the video.",
25
+ inputSchema,
26
+ outputSchema: looseOutput({ srtPath: z.string(), cues: z.number().int(), text: z.string() }),
27
+ annotations: WRITES_FILE,
28
+ }, async (args, extra) => {
22
29
  try {
23
30
  requireFfmpeg();
24
31
  if (!existsSync(args.input))
@@ -32,11 +39,11 @@ export function register(server) {
32
39
  if (!info.audioCodec)
33
40
  throw new ScreencastError(`Input has no audio to transcribe: ${args.input}`);
34
41
  const output = resolveOutput(args.output, subdir("edits"), `captions-${stamp()}-${rand()}.srt`, args.overwrite);
35
- // whisper writes (appends) to its destination; use a fresh temp file,
36
- // then tidy it into the output.
37
42
  const raw = tempPath(".srt");
38
43
  try {
39
- await runFfmpeg(buildTranscribeArgs(args.input, model, raw, args.language ?? "auto"), jobTimeoutMs(info.durationSec));
44
+ await runFfmpeg(buildTranscribeArgs(args.input, model, raw, args.language ?? "auto"), jobTimeoutMs(info.durationSec), {
45
+ signal: extra.signal,
46
+ });
40
47
  const cues = existsSync(raw) ? normalizeCues(parseSrt(readFileSync(raw, "utf8"))) : [];
41
48
  writeFileSync(output, formatSrt(cues));
42
49
  const text = cues.map((c) => c.text.replace(/\n/g, " ")).join(" ");
@@ -56,4 +63,3 @@ export function register(server) {
56
63
  }
57
64
  });
58
65
  }
59
- //# sourceMappingURL=transcribe.js.map
@@ -2,6 +2,7 @@ import { z } from "zod";
2
2
  import { extname } 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 } from "../utils/ffmpeg.js";
6
7
  import { runEditJob, probeDuration } from "../utils/jobs.js";
7
8
  import { buildTrimArgs, editOutputExt, assertEditContainer } from "../utils/media.js";
@@ -14,23 +15,25 @@ const inputSchema = {
14
15
  exact: z
15
16
  .boolean()
16
17
  .optional()
17
- .describe("Re-encode so the cut is frame-exact and nothing before start stays in the file (default true). " +
18
- "false stream-copies: much faster, but the cut snaps to a keyframe and the frames before start " +
19
- "still ship in the file, hidden only by an edit list. Never use false to remove sensitive content."),
18
+ .describe("Re-encode for a frame-exact cut with the removed content really gone (default true). false = fast " +
19
+ "stream copy that snaps to a keyframe and keeps hidden earlier frames; never use it to remove secrets."),
20
20
  output: z.string().optional().describe("Optional output path. Defaults under SCREENCAST_HOME/edits."),
21
21
  overwrite: z.boolean().optional().describe("Allow replacing an existing file at the output path (default false)."),
22
22
  };
23
23
  export function register(server) {
24
- server.tool("trim", "Trim a video to a sub-clip by start + (end or duration). Re-encodes by default, " +
25
- "so the cut is frame-exact and the removed content is really gone; set exact: false " +
26
- "for a fast stream copy that keeps hidden frames from before start in the file.", inputSchema, async (args, extra) => {
24
+ server.registerTool("trim", {
25
+ title: "Trim Video",
26
+ description: "Cut a video down to one sub-clip by start + (end or duration). For several segments use clip; " +
27
+ "to combine with other edits use pipeline.",
28
+ inputSchema,
29
+ outputSchema: OUTPUT_PATH,
30
+ annotations: WRITES_FILE,
31
+ }, async (args, extra) => {
27
32
  try {
28
33
  requireFfmpeg();
29
34
  if (!existsSync(args.input)) {
30
35
  throw new ScreencastError(`Input file not found: ${args.input}`);
31
36
  }
32
- // A stream copy keeps the input's container; a re-encode needs one that
33
- // holds libx264/AAC.
34
37
  if (args.exact !== false)
35
38
  assertEditContainer(args.output);
36
39
  const ext = args.exact === false ? extname(args.input) || ".mp4" : editOutputExt(args.input);
@@ -41,7 +44,6 @@ export function register(server) {
41
44
  duration: args.duration,
42
45
  exact: args.exact,
43
46
  });
44
- // Length of the trimmed clip, which sizes the job's timeout and progress.
45
47
  const start = args.start ?? 0;
46
48
  const end = args.end ?? (await probeDuration(args.input));
47
49
  const durationSec = args.duration ?? (end !== null ? end - start : null);
@@ -53,4 +55,3 @@ export function register(server) {
53
55
  }
54
56
  });
55
57
  }
56
- //# sourceMappingURL=trim.js.map
@@ -1,10 +1,12 @@
1
1
  import { z } from "zod";
2
2
  import { errorResponse, okResponse } from "../utils/errors.js";
3
+ import { READ_ONLY, looseOutput } from "../utils/toolSpec.js";
3
4
  import { requireFfmpeg, runFfmpeg, runFfmpegBuffer } from "../utils/ffmpeg.js";
4
5
  import { resolveCaptureTarget } from "../utils/resolveTarget.js";
5
6
  import { buildScreenshotArgs } from "../utils/targets.js";
6
7
  import { detectionSize, targetSize, diffFrames, buildRawGrabArgs, SettleTracker, targetDiffOptions, DEFAULT_PIXEL_THRESHOLD, } from "../utils/diff.js";
7
8
  import { windowMatchReport } from "../utils/windows.js";
9
+ import { confirmCapture, describeTarget } from "../utils/consent.js";
8
10
  import { subdir, stamp, rand } from "../utils/paths.js";
9
11
  import { join } from "node:path";
10
12
  import { rmSync } from "node:fs";
@@ -13,66 +15,73 @@ import { encodeInlineImages, DEFAULT_MAX_IMAGE_WIDTH } from "../utils/images.js"
13
15
  const inputSchema = {
14
16
  target: z
15
17
  .string()
16
- .describe("What to watch: 'full' | 'monitor:<index>' | 'window:<title>' (or window:exe=<app.exe> / window:hwnd=<handle>) | 'region:<x>,<y>,<w>,<h>'."),
17
- exactTitle: z.boolean().optional().describe("For window: targets, match the title exactly (default false)."),
18
+ .describe("What to watch: full | monitor:<i> | window:<title> (or exe=/hwnd=) | region:<x>,<y>,<w>,<h>."),
19
+ exactTitle: z.boolean().optional().describe("window: targets match the whole title only (default false)."),
18
20
  mode: z
19
21
  .enum(["change", "settle"])
20
22
  .optional()
21
- .describe("'change' (default) returns as soon as the target differs from when the call started " +
22
- "(a dialog opened, a page responded). 'settle' returns once the target has stopped " +
23
- "changing for settleSec (a build finished, a page finished loading)."),
23
+ .describe("change (default): return once it differs from the start. settle: once it has been still for settleSec."),
24
24
  timeoutSec: z
25
25
  .number()
26
26
  .positive()
27
27
  .max(600)
28
28
  .optional()
29
- .describe("Give up after this many seconds (default 30). A timeout is a normal result, not an error."),
29
+ .describe("Give up after this many seconds (default 30; a timeout is a result, not an error)."),
30
30
  settleSec: z
31
31
  .number()
32
32
  .positive()
33
33
  .max(60)
34
34
  .optional()
35
- .describe("Mode 'settle': how long the screen must stay still (default 1)."),
35
+ .describe("Mode settle: seconds of stillness (default 1)."),
36
36
  intervalMs: z
37
37
  .number()
38
38
  .int()
39
39
  .min(100)
40
40
  .max(5000)
41
41
  .optional()
42
- .describe("Pause between checks in ms (default 250); each check itself takes ~0.2 s."),
42
+ .describe("Pause between checks in ms (default 250)."),
43
43
  pixelThreshold: z
44
44
  .number()
45
45
  .min(0)
46
46
  .max(255)
47
47
  .optional()
48
- .describe(`How different (0-255 mean) a cell of about 32x32 screen pixels must be to count as changed ` +
49
- `(default ${DEFAULT_PIXEL_THRESHOLD}: catches a changed label or a toast).`),
48
+ .describe(`Mean 0-255 difference for a ~32x32 cell to count as changed (default ${DEFAULT_PIXEL_THRESHOLD}).`),
50
49
  returnImage: z
51
50
  .boolean()
52
51
  .optional()
53
- .describe("Also return a screenshot of the final state inline (default true)."),
52
+ .describe("Return the final state inline (default true)."),
54
53
  keep: z
55
54
  .boolean()
56
55
  .optional()
57
- .describe("Keep the final screenshot on disk and return its path (default false: it is only returned inline)."),
56
+ .describe("Keep the final screenshot on disk and return its path (default false)."),
58
57
  };
59
58
  const sleep = (ms) => new Promise((r) => setTimeout(r, ms));
60
59
  export function register(server) {
61
- server.tool("wait_for_change", "Watch part of the screen and return when it changes (mode 'change') or when it has " +
62
- "stopped changing (mode 'settle'), instead of guessing a sleep. Reports how long it " +
63
- "took, where the screen changed, and the final state as an inline screenshot. `regions` " +
64
- "are in the screenshot's pixels (like find_text and screen_diff); add `origin` for desktop coordinates.", inputSchema, async (args, extra) => {
60
+ server.registerTool("wait_for_change", {
61
+ title: "Wait for Screen Change",
62
+ description: "Wait until part of the screen changes or settles, instead of guessing a sleep. Returns the " +
63
+ "elapsed time, changed regions (screenshot pixels; add `origin` for desktop), and the final state.",
64
+ inputSchema,
65
+ outputSchema: looseOutput({
66
+ outcome: z.string(),
67
+ mode: z.string(),
68
+ elapsedSec: z.number(),
69
+ regions: z.array(z.unknown()),
70
+ origin: looseOutput({ x: z.number(), y: z.number() }),
71
+ }),
72
+ annotations: READ_ONLY,
73
+ }, async (args, extra) => {
65
74
  try {
66
75
  requireFfmpeg();
67
76
  const mode = args.mode ?? "change";
68
77
  const timeoutMs = (args.timeoutSec ?? 30) * 1000;
69
78
  const settleMs = (args.settleSec ?? 1) * 1000;
70
79
  const interval = args.intervalMs ?? 250;
71
- // The target (and a window's rectangle) is resolved once, up front.
72
80
  const { target, monitors, window } = await resolveCaptureTarget(args.target, { exactTitle: args.exactTitle });
81
+ await confirmCapture(server, `Watch ${describeTarget(args.target, window)} for up to ${timeoutMs / 1000} s, until it ${mode === "settle" ? "stops changing" : "changes"}?`, extra.signal);
73
82
  const area = targetSize(target, monitors);
74
83
  const size = detectionSize(area.width, area.height);
75
- const grab = () => runFfmpegBuffer(buildRawGrabArgs(target, monitors, size), 15_000);
84
+ const grab = () => runFfmpegBuffer(buildRawGrabArgs(target, monitors, size), 15_000, { signal: extra.signal });
76
85
  const opts = targetDiffOptions(area, size, args.pixelThreshold);
77
86
  const started = Date.now();
78
87
  const baseline = await grab();
@@ -87,7 +96,15 @@ export function register(server) {
87
96
  break;
88
97
  }
89
98
  await sleep(interval);
90
- const current = await grab();
99
+ const current = await grab().catch((error) => {
100
+ if (extra.signal.aborted)
101
+ return null;
102
+ throw error;
103
+ });
104
+ if (!current) {
105
+ outcome = "cancelled";
106
+ break;
107
+ }
91
108
  if (mode === "change") {
92
109
  const d = diffFrames(baseline, current, size.width, size.height, opts);
93
110
  if (d.regions.length > 0) {
@@ -120,12 +137,11 @@ export function register(server) {
120
137
  };
121
138
  const images = [];
122
139
  if (args.returnImage !== false && outcome !== "cancelled") {
123
- // Not kept by default, so screenshots do not pile up on disk (#209).
124
140
  const shot = args.keep
125
141
  ? join(subdir("screenshots"), `wait-${stamp()}-${rand()}.png`)
126
142
  : join(tmpdir(), `screencast-wait-${stamp()}-${rand()}.png`);
127
143
  try {
128
- await runFfmpeg(buildScreenshotArgs(target, shot, monitors), 60_000);
144
+ await runFfmpeg(buildScreenshotArgs(target, shot, monitors), 60_000, { signal: extra.signal });
129
145
  if (args.keep)
130
146
  result.screenshotPath = shot;
131
147
  images.push(...(await encodeInlineImages([shot], DEFAULT_MAX_IMAGE_WIDTH, 1)).images);
@@ -142,4 +158,3 @@ export function register(server) {
142
158
  }
143
159
  });
144
160
  }
145
- //# sourceMappingURL=waitForChange.js.map
@@ -1,17 +1,18 @@
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, probeMedia } from "../utils/ffmpeg.js";
5
6
  import { runEditJob } from "../utils/jobs.js";
6
7
  import { buildXfadeArgs, clipLength, DEFAULT_TRANSITION_DUR } from "../utils/produce.js";
7
8
  import { resolveOutput, subdir, stamp, rand } from "../utils/paths.js";
8
9
  const inputSchema = {
9
- inputA: z.string().min(1).describe("Path to the first (outgoing) video."),
10
- inputB: z.string().min(1).describe("Path to the second (incoming) video."),
10
+ inputA: z.string().min(1).describe("Outgoing video."),
11
+ inputB: z.string().min(1).describe("Incoming video."),
11
12
  transition: z
12
13
  .string()
13
14
  .optional()
14
- .describe("xfade transition name (default fade): fade, wipeleft, slideup, circleopen, dissolve, ..."),
15
+ .describe("xfade name (default fade): fade, wipeleft, slideup, circleopen, dissolve, ..."),
15
16
  duration: z
16
17
  .number()
17
18
  .positive()
@@ -21,10 +22,14 @@ 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("xfade_transition", "Crossfade two videos into one with an xfade transition. Both clips are " +
25
- "auto-normalized to a common resolution, fps, and audio rate first, so " +
26
- "they need not match. Offsets follow each clip's video length; audio is " +
27
- "crossfaded, with silence standing in for a clip that has no track.", inputSchema, async (args, extra) => {
25
+ server.registerTool("xfade_transition", {
26
+ title: "Crossfade Transition",
27
+ description: "Join two videos with an xfade transition (audio crossfaded); they need not match in size, " +
28
+ "fps, or audio. For more clips use assemble_highlights.",
29
+ inputSchema,
30
+ outputSchema: OUTPUT_PATH,
31
+ annotations: WRITES_FILE,
32
+ }, async (args, extra) => {
28
33
  try {
29
34
  requireFfmpeg();
30
35
  for (const f of [args.inputA, args.inputB]) {
@@ -49,4 +54,3 @@ export function register(server) {
49
54
  }
50
55
  });
51
56
  }
52
- //# sourceMappingURL=xfadeTransition.js.map