@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
package/README.md CHANGED
@@ -4,7 +4,9 @@
4
4
 
5
5
  **An MCP server that lets an agent record the screen, _watch_ the footage, and make minimal ffmpeg edits — over stdio, on Windows.**
6
6
 
7
- Capture the desktop, a monitor, a window, or a region; sample a recording into frames the agent can actually look at; trim, crop, redact, annotate, zoom toward clicks, and export for GitHub or social. No cloud service, no telemetry: ffmpeg and ffprobe behind 41 typed tools.
7
+ Capture the desktop, a monitor, a window, or a region; sample a recording into frames the agent can actually look at; trim, crop, redact, annotate, zoom toward clicks, and export for GitHub or social. No cloud service, no telemetry: ffmpeg and ffprobe behind 43 typed tools.
8
+
9
+ **For developers who want their coding agent to see and prove UI changes on Windows**: bug repros, UI verification, and demo clips the agent records, checks, and edits itself. Capture is Windows-only; the watch and edit tools work on any OS with ffmpeg. Free for non-commercial use ([CC BY-NC-ND 4.0](#license)); [why not OBS, Playwright, or a screenshot MCP?](#why-not-just)
8
10
 
9
11
  <br />
10
12
 
@@ -36,14 +38,14 @@ Capture the desktop, a monitor, a window, or a region; sample a recording into f
36
38
 
37
39
  ## Quick start
38
40
 
39
- **You need** Windows 10 or 11, [Node.js](https://nodejs.org) 22+, and ffmpeg on `PATH` (`winget install Gyan.FFmpeg`). Capture is Windows-only; the watch, edit, and produce tools work anywhere ffmpeg runs.
41
+ **You need** Windows 10 or 11, [Node.js](https://nodejs.org) 22+, and **FFmpeg 8 or newer** on `PATH` (`winget install Gyan.FFmpeg`, the full build). Older builds run most tools, but `transcribe` (the `whisper` filter) and `backend: "wgc"` (`gfxcapture`) need FFmpeg 8, and essentials or distro builds can lack them (Ubuntu LTS `apt install ffmpeg` gives 6.x). Capture is Windows-only; the watch, edit, and produce tools work anywhere ffmpeg runs. After connecting, ask the agent to run `doctor`: it reports the ffmpeg version, the filters and devices it has, OCR, and anything missing.
40
42
 
41
43
  **Add it to your client:**
42
44
 
43
45
  | Client | How |
44
46
  | --- | --- |
45
47
  | Claude Code | `claude mcp add screencast -- cmd /c npx -y @tmhs/screencast-mcp` |
46
- | Claude Desktop | Download the `.mcpb` from the [latest release](https://github.com/TMHSDigital/screencast-mcp/releases/latest) and open it (one click) |
48
+ | Claude Desktop | Download [`screencast-mcp.mcpb`](https://github.com/TMHSDigital/screencast-mcp/releases/latest/download/screencast-mcp.mcpb) from the latest release and open it (one click) |
47
49
  | Cursor, VS Code, others | The JSON config below, or step-by-step on [Connect your client](https://tmhsdigital.github.io/screencast-mcp/connect.html) |
48
50
 
49
51
  ```json
@@ -75,14 +77,22 @@ The design choices are deliberate rather than incidental:
75
77
  What it can do beyond record-and-look:
76
78
 
77
79
  - **Zoom toward clicks.** Record with `events: true` and `zoom` glides in on each click and rings it, Screen Studio style.
78
- - **Review before sharing.** In clients with MCP Apps, `stop_recording` opens an inline player where a person trims and draws redaction boxes.
80
+ - **Review before sharing.** In clients with MCP Apps, `review_recording` opens an inline player where a person trims and draws redaction boxes.
79
81
  - **Find and cover secrets.** `find_text` reads the screen with Windows OCR and returns rectangles for `redact_region`.
80
82
  - **One call, one encode.** `pipeline` runs trim, crop, redact, callouts, and an export as a single ffmpeg pass.
81
83
  - **Record a covered window.** `backend: "wgc"` records a window's own surface through Windows Graphics Capture.
82
84
 
85
+ ### Why not just...
86
+
87
+ | Instead of | The difference |
88
+ | --- | --- |
89
+ | OBS, ShareX, Game Bar | Built for a person at the controls. Here the agent starts and stops the recording, looks at the frames, and makes the edits through typed tools, with no GUI step. |
90
+ | Playwright or Puppeteer video | Browser pages only, and the video is a file the model never sees. Here: any window or monitor, frames returned to the model, plus `wait_for_change`, `find_text`, and `screen_diff` for checking what happened. |
91
+ | A screenshot-only MCP server | Single stills. Here: video over time, an input event log, scene-change sampling, redaction, and export, so the agent can show a sequence, not one moment. |
92
+
83
93
  ## Tools
84
94
 
85
- 41 tools in six groups. The manifest in [`mcp-tools.json`](mcp-tools.json) is the canonical surface; tests keep it, this README, and the docs site in sync with `src/tools/`.
95
+ 43 tools in six groups. The manifest in [`mcp-tools.json`](mcp-tools.json) is the canonical surface; tests keep it, this README, and the docs site in sync with `src/tools/`.
86
96
 
87
97
  ### Capture
88
98
 
@@ -92,11 +102,13 @@ What it can do beyond record-and-look:
92
102
  | `stop_recording` | Stop a session by id. Sends ffmpeg a graceful quit so the file is **finalized, not truncated**. Returns the final path and duration. |
93
103
  | `list_sessions` | List active and finished sessions. |
94
104
  | `get_session` | Inspect a single session by id. |
95
- | `review_recording` | **Review player** in clients that support MCP Apps: an inline player where a person scrubs the recording, drags trim handles, and draws redaction boxes, then exports a trimmed, redacted copy (one `pipeline` call). `stop_recording` results open it too. Elsewhere it returns the video's details. |
96
- | `player_frames` | Preview JPEG frames for the review player; called by the player (app-only), not by agents. |
105
+ | `review_recording` | **Review player** in clients that support MCP Apps: an inline player where a person scrubs the recording, drags trim handles, and draws redaction boxes, then exports a trimmed, redacted copy (one `pipeline` call). Pass it a stopped recording's `sessionId`. Elsewhere it returns the video's details. |
106
+ | `player_frames` | Preview JPEG frames for the review player (an even grid plus scene changes, labelled with their real times); called by the player (app-only), not by agents. |
97
107
  | `read_events` | Read a recording's input event log (clicks, scroll, cursor, shortcuts, typing bursts) on the video's clock. Opt in with `start_recording` `events: true`. |
98
108
  | `screenshot` | Capture a single PNG of a `target`, and return it inline as an image the model can view. |
99
109
  | `list_audio_devices` | List the DirectShow audio devices ffmpeg can see and flag a likely system-audio loopback device for `start_recording`. |
110
+ | `list_targets` | List what can be captured: the desktop, each monitor (bounds, DPI scale), and each window (title, exe, pid, hwnd, bounds, minimized, cloaked, and whether gdigrab and `wgc` can capture it). Every entry carries a `target` string (`window:hwnd=<handle>` for windows) to pass as-is to `screenshot` or `start_recording`; filter with `exe` / `titleContains`. |
111
+ | `doctor` | Check the setup: ffmpeg/ffprobe path and version (FFmpeg 8+?), key filters (`whisper`, `gfxcapture`, `subtitles`, `drawtext`, ...), `gdigrab`/`dshow` devices, Windows OCR, `SCREENCAST_HOME`, and the env settings in effect, with a `problems` list naming each fix. |
100
112
 
101
113
  ### Watch
102
114
 
@@ -128,14 +140,14 @@ These tools re-encode (a filter rewrites pixels, so stream copy does not apply).
128
140
  | `scale` | Resize to a `width` and/or `height`. One side keeps the aspect ratio; both set an exact size. |
129
141
  | `speed` | Change playback speed by a `factor` (>1 faster, <1 slower). Audio is retempo'd when present. |
130
142
  | `overlay` | Composite a logo, watermark, or picture-in-picture onto a base video at a position, optionally scaled and time-limited. |
131
- | `callout` | **Timed annotations**: boxes, text labels, and arrows at any angle, each shown between two timestamps. Mark the bug, point at the button, caption a step. |
143
+ | `callout` | **Timed annotations**: boxes, text labels, and arrows at any angle, each shown between two timestamps. Mark the bug, point at the button, caption a step. Text Inter can't draw (CJK, emoji, Arabic, Indic, ...) falls back to a Windows system font that covers it; `fontFile` picks one explicitly, and anything no font covers comes back in `warnings` instead of as silent boxes. |
132
144
  | `compress` | Re-encode smaller with a `light`/`medium`/`heavy` CRF ladder and an optional `maxWidth` that only downscales. |
133
145
  | `extract_audio` | Write the audio track to its own file (`mp3`, `aac`, `wav`, or `copy`). |
134
146
  | `normalize_audio` | **Loudness to a delivery target** (two-pass EBU R128 `loudnorm`): `youtube` −14 LUFS, `podcast` −16, `broadcast` −23, or any LUFS value. Video is copied; reports loudness before and after. |
135
147
  | `denoise` | Reduce **steady** background noise (fan, hum, hiss) with `afftdn`, tuned to the file's measured noise floor. Video is copied. |
136
148
  | `transcribe` | **Speech to an SRT file, locally**, with FFmpeg 8's `whisper` filter (needs a whisper.cpp model: pass `model` or set `SCREENCAST_WHISPER_MODEL`). Cues are renumbered and de-overlapped. |
137
149
  | `burn_subtitles` | Burn an SRT/ASS into the video in the bundled font: `clean` (outlined line) or `social` (big bold text on a dark box, for muted autoplay). |
138
- | `clip` | Extract one or more frame-accurate sub-segments to separate files. Unlike `trim`, it re-encodes so cuts land exactly on the given times. |
150
+ | `clip` | Extract one or more frame-accurate sub-segments, each to its own file. For a single segment, `trim` (default `exact: true`) does the same. |
139
151
  | `cut_idle` | **Remove dead air**: cut stretches where the screen is frozen and (when there is audio) silent, keeping a short pad at each edge. `dryRun` reports first; speech over a still screen is kept unless `useAudio: false`. |
140
152
 
141
153
  ### Redact
@@ -155,7 +167,7 @@ The production layer turns raw clips into a finished piece. Tools that combine c
155
167
  | --- | --- |
156
168
  | `xfade_transition` | Crossfade two videos into one with an `xfade` transition (`fade`, `wipeleft`, `slideup`, ...). Audio is crossfaded when both clips have a track. |
157
169
  | `assemble_highlights` | Stitch two or more clips into one, with hard cuts (`transition: "cut"`) or an xfade transition between each. |
158
- | `title_card` | Generate a standalone title card (centered text on a solid background, with a silent track so it composes). Text uses a bundled font, so no system font is needed. |
170
+ | `title_card` | Generate a standalone title card (centered text on a solid background, with a silent track so it composes). Text uses the bundled Inter, so Latin, Greek and Cyrillic need no system font; other scripts and emoji fall back to a Windows system font (or pass `fontFile`), with `warnings` for anything no font covers. |
159
171
  | `music_bed` | Lay a music track under a video: looped/trimmed to length, faded in and out, leveled, and mixed with any existing audio (optionally ducked). |
160
172
  | `reframe` | Re-aspect to `16:9`, `9:16`, `1:1`, or `4:5` with `pad` (letterbox, no content lost) or `crop` (fill, trims overflow). |
161
173
  | `zoom` | **Smooth zoom-and-pan** (Screen Studio style) into where the action is and back out. Give keyframes (rectangles by time), or let it plan them from the clicks in the input event log (`start_recording` `events: true`; `highlightClicks` rings each click) or from where the screen changes; `dryRun` returns the plan to adjust. |
@@ -177,24 +189,46 @@ Every capture tool takes a single `target` string, so an agent never has to jugg
177
189
 
178
190
  For `window:` targets, `screenshot` and `start_recording` both report `matchedWindow`, `matchCount`, `matchKind` (`exact`, `substring`, `exe`, or `hwnd`), and the captured `region`. When the title matched only as a substring, or several windows matched, the result carries a `windowWarning` listing the candidate titles, so a generic title like `window:Code` cannot quietly record a different window. Pass `exactTitle: true` to refuse the substring fallback entirely.
179
191
 
180
- Output is written under `SCREENCAST_HOME` (default `<homedir>/.screencast-mcp`) into `recordings/`, `frames/`, `screenshots/`, and `edits/`. Any tool also accepts an explicit output path.
192
+ Output is written under `SCREENCAST_HOME` (default `<homedir>/.screencast-mcp`) into `recordings/`, `frames/`, `screenshots/`, and `edits/`. Any tool also accepts an explicit output path; a relative one resolves under that tool's `SCREENCAST_HOME` subfolder, never the server's working directory.
193
+
194
+ **Output confinement.** When the client sends workspace roots (the MCP `roots` capability), or `SCREENCAST_ALLOWED_DIRS` is set, an explicit output path (or `sample_frames` `outputDir`) must sit inside `SCREENCAST_HOME`, one of those roots, or one of those folders; anything else is refused with an error naming the allowed folders. The roots are re-read when the client reports they changed. With neither, any path you can write to is accepted, as before. `doctor` reports the folders in effect as `storage.allowedOutputDirs`.
181
195
 
182
196
  Edit and produce tools write to a `<name>.partial.<ext>` file next to the output and rename it into place only when ffmpeg succeeds, so a failed, timed-out, or cancelled job never leaves a truncated file at `output`. The job timeout scales with the media's length (at least 10 minutes, or 4x the duration); set `SCREENCAST_JOB_TIMEOUT_MS` to override it. Clients that send a progress token get `notifications/progress` updates while a job runs, and cancelling the request stops ffmpeg.
183
197
 
184
198
  ## Configuration
185
199
 
186
- `ffmpeg` and `ffprobe` must be on `PATH`, or pointed at with `FFMPEG_PATH` / `FFPROBE_PATH`; the server checks per call and returns an install hint if either is missing (macOS: `brew install ffmpeg`; Linux: `apt install ffmpeg`, for the non-capture tools).
200
+ `ffmpeg` and `ffprobe` must be on `PATH`, or pointed at with `FFMPEG_PATH` / `FFPROBE_PATH`; the server checks per call and returns an install hint if either is missing (macOS: `brew install ffmpeg`; Linux: `apt install ffmpeg`, for the non-capture tools; distro packages may predate FFmpeg 8, so `transcribe` needs a newer static build). `doctor` shows what the ffmpeg in use supports.
187
201
 
188
202
  | Variable | Default | Purpose |
189
203
  | --- | --- | --- |
190
204
  | `SCREENCAST_HOME` | `<homedir>/.screencast-mcp` | Where recordings, frames, screenshots, and edits are written |
205
+ | `SCREENCAST_ALLOWED_DIRS` | none | `;`-separated folders explicit outputs may also go to; when set, or when the client sends roots, outputs outside `SCREENCAST_HOME`, the roots, and these folders are refused |
191
206
  | `SCREENCAST_MAX_RECORDING_SEC` | `3600` | Default recording cap (`0` disables it) |
192
207
  | `SCREENCAST_JOB_TIMEOUT_MS` | scales with length | Override the edit job timeout |
193
208
  | `SCREENCAST_WHISPER_MODEL` | none | whisper.cpp model for `transcribe` |
194
209
  | `SCREENCAST_RETENTION_DAYS` | off | Delete screenshots, frames, and leftover raw event logs older than this many days at startup (never recordings or edits) |
195
210
  | `SCREENCAST_PS_TIMEOUT_MS` | 20000 (OCR 60000) | Limit for the PowerShell helpers that list monitors and windows and run OCR |
211
+ | `SCREENCAST_CONFIRM_CAPTURE` | off | Set to `1` to ask the user to confirm every live capture (`start_recording`, `screenshot`, `find_text` on a target, `wait_for_change`) through MCP elicitation; clients without elicitation are refused |
212
+ | `SCREENCAST_TOOLSETS` | `all` | Comma-separated toolsets to expose (`capture`, `watch`, `edit`, `produce`, `audio`); the rest are not loaded, which shrinks the tool list the agent pays for on every turn |
196
213
  | `FFMPEG_PATH` / `FFPROBE_PATH` | `PATH` lookup | Explicit ffmpeg / ffprobe binaries |
197
214
 
215
+ **Toolsets.** The full tool list (`tools/list`) is about 70 KB, roughly 17k tokens of context; `capture` alone is about 16 KB. Set `SCREENCAST_TOOLSETS` to load only the groups an agent needs, for example `capture,watch` for a QA agent that records and looks but never edits. `core` (`doctor`, `get_media_info`) is always on; unset, empty, `all`, or a value naming no known toolset loads everything, and unknown names are ignored with a warning (and listed by `doctor`).
216
+
217
+ | Toolset | Tools |
218
+ | --- | --- |
219
+ | `capture` | `start_recording`, `stop_recording`, `list_sessions`, `get_session`, `read_events`, `screenshot`, `list_targets`, `list_audio_devices` |
220
+ | `watch` | `sample_frames`, `contact_sheet`, `screen_diff`, `wait_for_change`, `find_text`, `review_recording`, `player_frames` |
221
+ | `edit` | `pipeline`, `trim`, `clip`, `concat`, `convert`, `export_gif`, `crop`, `scale`, `speed`, `compress`, `redact_region`, `cut_idle` |
222
+ | `produce` | `callout`, `overlay`, `zoom`, `reframe`, `title_card`, `xfade_transition`, `assemble_highlights`, `export_preset`, `burn_subtitles` |
223
+ | `audio` | `extract_audio`, `normalize_audio`, `denoise`, `transcribe`, `music_bed` |
224
+ | `core` (always) | `doctor`, `get_media_info` |
225
+
226
+ The server also sends MCP `instructions` at initialize: the record, look, edit workflow, which tool to reach for when, and the toolsets in effect, so each tool's own description stays short.
227
+
228
+ **Capture consent.** With `SCREENCAST_CONFIRM_CAPTURE=1`, each live capture first asks the user through the client (MCP elicitation), showing what will be captured: the matched window, the duration, the audio source, and the output path. Only the user can answer, not the model, so a prompt injection cannot approve its own capture. Declining, cancelling, or not answering within 5 minutes captures nothing. A client that does not support elicitation fails closed: the tool returns an error and nothing is captured.
229
+
230
+ **Log messages.** The server declares the MCP `logging` capability: ffmpeg warnings (dropped frames, a full audio buffer, a warning from an edit job that still succeeded) and a recording that ends on its own (cap reached, window closed, recorder crash) are sent as `notifications/message`, filtered by the level the client sets with `logging/setLevel`.
231
+
198
232
  ## Usage
199
233
 
200
234
  **Workflows:** copy-paste recipes with the tool calls and real outputs are on the docs site: [bug-repro clip for a PR](https://tmhsdigital.github.io/screencast-mcp/workflows/bug-repro.html), [README demo GIF](https://tmhsdigital.github.io/screencast-mcp/workflows/demo-gif.html), [agent UI verification loop](https://tmhsdigital.github.io/screencast-mcp/workflows/verify-ui.html), [social clip](https://tmhsdigital.github.io/screencast-mcp/workflows/social-clip.html), [reviewing a long recording](https://tmhsdigital.github.io/screencast-mcp/workflows/review-recording.html), [zoom toward every click](https://tmhsdigital.github.io/screencast-mcp/workflows/zoom-clicks.html), and [the whole edit in one call](https://tmhsdigital.github.io/screencast-mcp/workflows/pipeline.html).
@@ -244,6 +278,7 @@ It also offers **resources**, so a client can list and attach recordings without
244
278
  - **Windows Graphics Capture (`backend: "wgc"`, FFmpeg 8+).** Captures a window's **own surface** by handle, even when other windows cover it. On `screenshot` and `find_text` it takes 1-2 s instead of ~0.2 s, so it is opt-in. On `start_recording` it records the window's client area while it is covered, moved, or in the background. `gfxcapture` only emits a frame when the window presents, so a small recorder process repaints one pixel of the window every 200 ms and repeats the latest frame at the requested fps; it stops on `q` like ffmpeg, so `stop_recording` and `maxDurationSec` work the same. The first frame takes a second or two, and `start_recording` returns once it is captured. No audio with `wgc` yet.
245
279
  - **Fullscreen-exclusive apps** often produce black frames under `gdigrab`; run the source in borderless-windowed mode for reliable capture.
246
280
  - **System audio needs a loopback device.** `gdigrab` is video-only, so `start_recording` with `audio.source` = `system` captures from a separate dshow input. Windows has no native loopback, so this needs a virtual-audio device (enable Stereo Mix, or install a driver such as screen-capture-recorder's `virtual-audio-capturer` or VB-CABLE). Run `list_audio_devices` to find it. Microphone capture is intentionally not supported.
281
+ - **Windows on ARM64.** CI runs the unit, ffmpeg-integration and gdigrab capture-smoke suites on a native `windows-11-arm` runner with arm64 Node. gyan.dev has no arm64 build; CI uses [BtbN's](https://github.com/BtbN/FFmpeg-Builds/releases) FFmpeg 8.1 `winarm64-gpl-shared` build (from a month-end `autobuild-*` release, which are kept), which has `gdigrab`, `gfxcapture` (WGC) and `drawtext` but is built without whisper and libvpx: `transcribe` and `.webm` output need another build. Run `node scripts/platform-probe.mjs` after `npm run build` to see what your machine supports (`doctor` now reports `arch`).
247
282
 
248
283
  ## Privacy
249
284
 
@@ -266,10 +301,10 @@ It also offers **resources**, so a client can list and attach recordings without
266
301
  > [!WARNING]
267
302
  > Screen capture can record **anything** on screen at the moment of capture — passwords, tokens, private messages, and other secrets. `window:` captures the screen rectangle a window occupies, so overlays, notifications, or another window drawn over it are captured too. Treat recordings, screenshots, and sampled frames as sensitive by default.
268
303
 
269
- - **Capture is always explicit.** Nothing auto-fires; capture is gated behind an explicit tool call.
304
+ - **Capture is always explicit.** Nothing auto-fires; capture is gated behind an explicit tool call. Set `SCREENCAST_CONFIRM_CAPTURE=1` to also require the user's confirmation, through the client, before each live capture (see [Configuration](#configuration)).
270
305
  - **The server makes no network requests.** Files are written to the local filesystem only. What a tool returns to your agent (frames, OCR text, event summaries) is sent to your model provider like any other tool result; see [Privacy](#privacy).
271
306
  - **Public repo, private captures.** The `.gitignore` blocks recordings, frames, screenshots, and common video/image output so test media cannot be committed by accident.
272
- - **Review before sharing.** Sample frames or inspect a recording before handing a file to another tool or person, so you know what it contains. In clients that support MCP Apps, `stop_recording` and `review_recording` open an inline player where a person can scrub the whole recording and draw redaction boxes before anything leaves the machine. The player gets frames through the MCP connection; no local web server is started.
307
+ - **Review before sharing.** Sample frames or inspect a recording before handing a file to another tool or person, so you know what it contains. In clients that support MCP Apps, `review_recording` opens an inline player where a person can scrub the whole recording and draw redaction boxes before anything leaves the machine. The player gets frames through the MCP connection; no local web server is started.
273
308
  - **Redaction covers what you declare.** `redact_region` covers only the rectangles you specify. `find_text` can help find them: OCR with a query such as `regex: "sk-|ghp_|api.?key"` and `redact: true` returns ready-made rectangles, and `scanEverySec` checks a whole video rather than one frame. But OCR is best-effort; it can miss small or stylised text, so treat it as an aid, not a guarantee. Use the default `box` style for a solid irreversible fill, and still review the output before sharing.
274
309
  - **The input event log never records what you type.** `start_recording` `events: true` hooks mouse and keyboard input system-wide for that recording only, in a helper that exits with it (or with the server). Typing is logged only as bursts on a 0.5 s grid, never key by key, so the log does not reveal which keys were pressed, how many, or their timing. `keys: "shortcuts"` also names chords held with Ctrl, Alt, or Win (`Ctrl+S`). Cursor positions and clicks still reveal what you pointed at, so treat `.events.jsonl` like the recording beside it. See [Privacy](#privacy) for exactly what each mode records.
275
310
  - **System audio is sensitive too.** When `audio.source` = `system`, the recording captures everything playing on the machine (call audio, notifications, media). Treat audio-bearing recordings with the same care as the video.
@@ -317,6 +352,13 @@ The capture path can't be exercised on CI's headless Linux runners, so an end-to
317
352
  RUN_LOCAL_CAPTURE_TESTS=1 npm test # Windows + ffmpeg + a real display
318
353
  ```
319
354
 
355
+ Agent evals (`evals/`) score tool selection, argument validity and outcomes on scripted tasks against lavfi-generated fixtures, through the built server over MCP. The default oracle mode replays known-good calls and needs no model or network; `--agent anthropic` runs a real model (install the SDK ad hoc with `npm install --no-save @anthropic-ai/sdk`; `EVAL_MODEL` defaults to `claude-sonnet-5-5`). Live-capture tools are always blocked.
356
+
357
+ ```bash
358
+ npm run build && npm run eval # oracle mode
359
+ npm run eval -- --agent anthropic --json evals/results/baseline.json
360
+ ```
361
+
320
362
  ## Contributing
321
363
 
322
364
  Issues and pull requests are welcome — see [CONTRIBUTING.md](CONTRIBUTING.md) and the [Code of Conduct](CODE_OF_CONDUCT.md). Security reports go through [SECURITY.md](SECURITY.md).
@@ -325,6 +367,8 @@ Issues and pull requests are welcome — see [CONTRIBUTING.md](CONTRIBUTING.md)
325
367
 
326
368
  Released under the [CC-BY-NC-ND-4.0](LICENSE) license: free to use and share for non-commercial purposes, with attribution and without modification. For other uses, [open an issue](https://github.com/TMHSDigital/screencast-mcp/issues).
327
369
 
370
+ **Can I use it at work?** Only for non-commercial purposes under this license. If your use is commercial (inside a paid product or service, or work done mainly for commercial advantage), or you are not sure, [open an issue](https://github.com/TMHSDigital/screencast-mcp/issues) to ask about a commercial license. The licensing model is described in the [TMHSDigital licensing standard](https://github.com/TMHSDigital/Developer-Tools-Directory/blob/main/standards/licensing.md).
371
+
328
372
  <div align="center">
329
373
  <br />
330
374
 
Binary file
@@ -6,11 +6,12 @@
6
6
  <title>Review player</title>
7
7
  <!--
8
8
  screencast-mcp review player (#128): an MCP Apps view. The host renders it in
9
- a sandboxed iframe for stop_recording / review_recording results. It talks to
9
+ a sandboxed iframe for review_recording results. It talks to
10
10
  the host with JSON-RPC over postMessage (ui/initialize, tool notifications,
11
11
  tools/call), shows the recording as JPEG frames from player_frames, and sends
12
- the person's trim and redaction back as one pipeline call. Self-contained: the
13
- host's CSP allows no outside origins.
12
+ the person's trim and redaction back as one pipeline call. Self-contained when
13
+ served: the host's CSP allows no outside origins, so the server inlines
14
+ player.js in place of its script tag (#243).
14
15
  -->
15
16
  <style>
16
17
  :root {
@@ -60,6 +61,8 @@
60
61
  .btn:disabled { opacity: .45; cursor: default; }
61
62
  #hint { color: var(--dim); font-size: 12px; }
62
63
  .timeline { position: relative; height: 56px; border: 1px solid var(--line); border-radius: 6px; background: var(--panel); cursor: pointer; touch-action: none; }
64
+ .seek { position: absolute; inset: 0; border-radius: 5px; }
65
+ #ticks i { position: absolute; bottom: 0; width: 2px; height: 9px; margin-left: -1px; background: var(--amber); opacity: .8; pointer-events: none; }
63
66
  #strip { position: absolute; inset: 0; display: flex; overflow: hidden; border-radius: 5px; opacity: .55; }
64
67
  #strip img { height: 100%; flex: 1 1 0; min-width: 0; object-fit: cover; pointer-events: none; }
65
68
  .shade { position: absolute; top: 0; bottom: 0; background: color-mix(in srgb, var(--bg) 70%, transparent); pointer-events: none; }
@@ -68,6 +71,7 @@
68
71
  position: absolute; top: -6px; bottom: -6px; width: 14px; margin-left: -7px; padding: 0;
69
72
  background: var(--amber); border: 0; border-radius: 4px; cursor: ew-resize;
70
73
  }
74
+ .handle:focus-visible { outline-color: var(--ink); }
71
75
  .handle::after { content: ""; position: absolute; inset: 40% 5px; border-left: 2px solid #111; border-right: 2px solid #111; }
72
76
  .times { font: 12px var(--mono); color: var(--dim); gap: 1.2rem; }
73
77
  .times b { color: var(--amber); font-weight: 500; }
@@ -75,6 +79,15 @@
75
79
  #boxList li { font: 12px var(--mono); border: 1px solid var(--line); border-radius: 6px; padding: .15rem .2rem .15rem .55rem; display: flex; gap: .4rem; align-items: center; }
76
80
  #boxList button { border: 0; background: none; color: var(--dim); cursor: pointer; padding: 0 .3rem; }
77
81
  #boxList button:hover { color: var(--rec); }
82
+ #boxFields { border: 0; margin: 0; padding: 0; display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; font: 12px var(--mono); color: var(--dim); }
83
+ #boxFields legend { float: left; padding: 0; margin-right: .2rem; }
84
+ #boxFields label { display: flex; align-items: center; gap: .3rem; }
85
+ #boxFields input {
86
+ width: 5.2rem; padding: .3rem .45rem; font: 12px var(--mono); color: var(--ink);
87
+ background: var(--panel); border: 1px solid var(--line); border-radius: 6px;
88
+ }
89
+ #boxFields:disabled { opacity: .45; }
90
+ #sampling { margin-left: auto; }
78
91
  #status { font: 12px var(--mono); color: var(--dim); overflow-wrap: anywhere; }
79
92
  #status.ok { color: var(--ok); }
80
93
  #status.err { color: var(--rec); }
@@ -95,316 +108,39 @@
95
108
  <div class="controls">
96
109
  <button class="btn" id="play" type="button" disabled>Play</button>
97
110
  <button class="btn" id="draw" type="button" aria-pressed="false" disabled>Draw redaction box</button>
98
- <span id="hint">Drag the amber handles to trim. Draw boxes over anything secret.</span>
111
+ <span id="hint">Drag the amber handles to trim (or focus one and use the arrow keys). Draw or type boxes over anything secret.</span>
99
112
  </div>
100
- <div class="timeline" id="timeline" role="group" aria-label="Timeline: click to seek">
113
+ <div class="timeline" id="timeline" role="group" aria-label="Timeline">
101
114
  <div id="strip"></div>
102
115
  <div class="shade" id="shadeIn"></div><div class="shade" id="shadeOut"></div>
116
+ <div id="ticks"></div>
103
117
  <div id="head"></div>
104
- <button class="handle" id="hIn" type="button" aria-label="Trim start (arrow keys move one frame)"></button>
105
- <button class="handle" id="hOut" type="button" aria-label="Trim end (arrow keys move one frame)"></button>
118
+ <!-- Sliders (#243): arrows move a frame, Page Up/Down a tenth, Home/End the ends. -->
119
+ <div class="seek" id="seek" role="slider" tabindex="0" aria-label="Playhead" aria-disabled="true"
120
+ aria-valuemin="0" aria-valuemax="0" aria-valuenow="0" aria-valuetext="00:00.0"></div>
121
+ <div class="handle" id="hIn" role="slider" tabindex="0" aria-label="Trim start" aria-disabled="true"
122
+ aria-valuemin="0" aria-valuemax="0" aria-valuenow="0"></div>
123
+ <div class="handle" id="hOut" role="slider" tabindex="0" aria-label="Trim end" aria-disabled="true"
124
+ aria-valuemin="0" aria-valuemax="0" aria-valuenow="0"></div>
106
125
  </div>
107
- <div class="row times"><span>IN <b id="inT">0.0s</b></span><span>OUT <b id="outT">0.0s</b></span><span id="lenT"></span></div>
126
+ <div class="row times"><span>IN <b id="inT">0.0s</b></span><span>OUT <b id="outT">0.0s</b></span><span id="lenT"></span><span id="sampling"></span></div>
108
127
  <ul id="boxList" aria-label="Redaction boxes"></ul>
128
+ <form id="boxForm" novalidate>
129
+ <fieldset id="boxFields" disabled>
130
+ <legend>ADD BOX (video px)</legend>
131
+ <label>X <input id="bx" type="number" min="0" step="1" inputmode="numeric"></label>
132
+ <label>Y <input id="by" type="number" min="0" step="1" inputmode="numeric"></label>
133
+ <label>W <input id="bw" type="number" min="4" step="1" inputmode="numeric"></label>
134
+ <label>H <input id="bh" type="number" min="4" step="1" inputmode="numeric"></label>
135
+ <button class="btn" type="submit">Add box</button>
136
+ </fieldset>
137
+ </form>
109
138
  <div class="row">
110
139
  <button class="btn primary" id="apply" type="button" disabled>Export trimmed + redacted copy</button>
111
140
  <button class="btn" id="openResult" type="button" hidden>Review the result</button>
112
141
  <span id="status" role="status"></span>
113
142
  </div>
114
143
  </main>
115
- <script>
116
- (() => {
117
- "use strict";
118
- const $ = (id) => document.getElementById(id);
119
- const PROTOCOL = "2026-01-26";
120
-
121
- // --- JSON-RPC over postMessage with the host ---------------------------
122
- let nextId = 1;
123
- const pending = new Map();
124
- const send = (msg) => window.parent.postMessage({ jsonrpc: "2.0", ...msg }, "*");
125
- const request = (method, params) =>
126
- new Promise((resolve, reject) => {
127
- const id = nextId++;
128
- pending.set(id, { resolve, reject });
129
- send({ id, method, params });
130
- });
131
- const notify = (method, params) => send({ method, params });
132
-
133
- window.addEventListener("message", (e) => {
134
- if (e.source !== window.parent) return;
135
- const m = e.data;
136
- if (!m || m.jsonrpc !== "2.0") return;
137
- if (m.id !== undefined && !m.method) {
138
- const p = pending.get(m.id);
139
- if (!p) return;
140
- pending.delete(m.id);
141
- m.error ? p.reject(new Error(m.error.message || "request failed")) : p.resolve(m.result);
142
- return;
143
- }
144
- if (m.id !== undefined) {
145
- // A request from the host.
146
- if (m.method === "ui/resource-teardown" || m.method === "ping") send({ id: m.id, result: {} });
147
- else send({ id: m.id, error: { code: -32601, message: `Unsupported: ${m.method}` } });
148
- return;
149
- }
150
- if (m.method === "ui/notifications/tool-input") onToolInput(m.params?.arguments || {});
151
- else if (m.method === "ui/notifications/tool-result") onToolResult(m.params || {});
152
- else if (m.method === "ui/notifications/host-context-changed") applyHostContext(m.params || {});
153
- else if (m.method === "ui/notifications/tool-cancelled") setEmpty("The tool call was cancelled.");
154
- });
155
-
156
- const applyHostContext = (ctx) => {
157
- if (ctx && (ctx.theme === "light" || ctx.theme === "dark")) document.documentElement.dataset.theme = ctx.theme;
158
- };
159
- const callTool = async (name, args) => {
160
- const r = await request("tools/call", { name, arguments: args });
161
- if (r && r.isError) throw new Error((r.content || []).map((c) => c.text).filter(Boolean).join(" ") || `${name} failed`);
162
- return r;
163
- };
164
- const resultJson = (r) => {
165
- const t = (r?.content || []).find((c) => c.type === "text");
166
- try { return t ? JSON.parse(t.text) : null; } catch { return null; }
167
- };
168
-
169
- // --- state ---------------------------------------------------------------
170
- const S = { input: null, duration: 0, W: 0, H: 0, frames: [], times: [], i: 0, inI: 0, outI: 0, boxes: [], drawing: false, playing: null };
171
- const fmt = (t) => { const m = Math.floor(t / 60), s = t - m * 60; return `${String(m).padStart(2, "0")}:${s.toFixed(1).padStart(4, "0")}`; };
172
- const sliceStart = (i) => (i * S.duration) / S.frames.length;
173
- const sliceEnd = (i) => ((i + 1) * S.duration) / S.frames.length;
174
- const setEmpty = (text) => { $("empty").textContent = text; $("empty").hidden = false; };
175
- const status = (text, kind) => { const s = $("status"); s.textContent = text; s.className = kind || ""; };
176
-
177
- function onToolInput(args) {
178
- if (args.input) $("file").textContent = args.input;
179
- }
180
- function onToolResult(result) {
181
- if (result.isError) return setEmpty((result.content || []).map((c) => c.text).join(" ") || "The tool failed.");
182
- const j = resultJson(result);
183
- const input = j && (j.outputPath || j.input);
184
- if (!input) return setEmpty("No video in this result.");
185
- load(input);
186
- }
187
-
188
- async function load(input) {
189
- S.input = input;
190
- S.boxes = [];
191
- $("file").textContent = input.split(/[\\/]/).pop();
192
- $("file").title = input;
193
- setEmpty("Loading frames...");
194
- status("");
195
- try {
196
- const r = await callTool("player_frames", { input });
197
- const meta = resultJson(r);
198
- S.frames = (r.content || []).filter((c) => c.type === "image").map((c) => `data:${c.mimeType};base64,${c.data}`);
199
- if (!meta || S.frames.length === 0) throw new Error("No frames came back.");
200
- Object.assign(S, { duration: meta.durationSec, W: meta.width, H: meta.height, times: meta.frameTimes, i: 0, inI: 0, outI: S.frames.length - 1 });
201
- } catch (err) {
202
- return setEmpty(`Could not load the recording: ${err.message}`);
203
- }
204
- $("empty").hidden = true;
205
- $("frame").hidden = false;
206
- // A strip of up to 40 evenly chosen thumbnails.
207
- const strip = $("strip");
208
- strip.replaceChildren();
209
- const n = Math.min(40, S.frames.length);
210
- for (let k = 0; k < n; k++) {
211
- const img = document.createElement("img");
212
- img.alt = "";
213
- img.src = S.frames[Math.floor((k * S.frames.length) / n)];
214
- strip.appendChild(img);
215
- }
216
- ["play", "draw"].forEach((id) => ($(id).disabled = false));
217
- show(0);
218
- render();
219
- }
220
-
221
- function show(i) {
222
- S.i = Math.max(0, Math.min(S.frames.length - 1, i));
223
- $("frame").src = S.frames[S.i];
224
- $("tc").textContent = `${fmt(S.times[S.i] || 0)} / ${fmt(S.duration)}`;
225
- $("head").style.left = `${((S.i + 0.5) / S.frames.length) * 100}%`;
226
- }
227
-
228
- function render() {
229
- const n = S.frames.length || 1;
230
- const a = (S.inI / n) * 100, b = ((S.outI + 1) / n) * 100;
231
- $("hIn").style.left = `${a}%`;
232
- $("hOut").style.left = `${b}%`;
233
- $("shadeIn").style.cssText = `left:0;width:${a}%`;
234
- $("shadeOut").style.cssText = `left:${b}%;right:0`;
235
- const tin = sliceStart(S.inI), tout = sliceEnd(S.outI);
236
- $("inT").textContent = `${tin.toFixed(1)}s`;
237
- $("outT").textContent = `${tout.toFixed(1)}s`;
238
- $("lenT").textContent = `${(tout - tin).toFixed(1)}s kept`;
239
- renderBoxes();
240
- const trimmed = S.inI > 0 || S.outI < S.frames.length - 1;
241
- $("apply").disabled = !S.input || (!trimmed && S.boxes.length === 0);
242
- }
243
-
244
- // --- timeline: seek and trim handles ----------------------------------
245
- const tl = $("timeline");
246
- const indexAt = (clientX) => {
247
- const r = tl.getBoundingClientRect();
248
- return Math.floor(((clientX - r.left) / r.width) * S.frames.length);
249
- };
250
- let dragging = null;
251
- tl.addEventListener("pointerdown", (e) => {
252
- if (!S.frames.length) return;
253
- dragging = e.target === $("hIn") ? "in" : e.target === $("hOut") ? "out" : "seek";
254
- tl.setPointerCapture(e.pointerId);
255
- move(e);
256
- });
257
- tl.addEventListener("pointermove", (e) => dragging && move(e));
258
- tl.addEventListener("pointerup", () => (dragging = null));
259
- function move(e) {
260
- const i = Math.max(0, Math.min(S.frames.length - 1, indexAt(e.clientX)));
261
- if (dragging === "in") S.inI = Math.min(i, S.outI);
262
- else if (dragging === "out") S.outI = Math.max(i, S.inI);
263
- show(i);
264
- render();
265
- }
266
- for (const [id, key] of [["hIn", "inI"], ["hOut", "outI"]]) {
267
- $(id).addEventListener("keydown", (e) => {
268
- const d = e.key === "ArrowLeft" ? -1 : e.key === "ArrowRight" ? 1 : 0;
269
- if (!d) return;
270
- e.preventDefault();
271
- const v = S[key] + d;
272
- if (key === "inI") S.inI = Math.max(0, Math.min(v, S.outI));
273
- else S.outI = Math.min(S.frames.length - 1, Math.max(v, S.inI));
274
- show(S[key]);
275
- render();
276
- });
277
- }
278
-
279
- // --- playback: a flipbook over the kept range ---------------------------
280
- $("play").addEventListener("click", () => {
281
- if (S.playing) return stop();
282
- $("play").textContent = "Pause";
283
- let i = S.i < S.inI || S.i >= S.outI ? S.inI : S.i;
284
- const ms = (S.duration / S.frames.length) * 1000;
285
- S.playing = setInterval(() => {
286
- show(i);
287
- i = i >= S.outI ? S.inI : i + 1;
288
- }, ms);
289
- });
290
- function stop() {
291
- clearInterval(S.playing);
292
- S.playing = null;
293
- $("play").textContent = "Play";
294
- }
295
-
296
- // --- redaction boxes, in video pixels -----------------------------------
297
- const stage = $("stage"), img = $("frame");
298
- $("draw").addEventListener("click", () => {
299
- S.drawing = !S.drawing;
300
- $("draw").setAttribute("aria-pressed", String(S.drawing));
301
- stage.classList.toggle("drawing", S.drawing);
302
- });
303
- const toVideo = (clientX, clientY) => {
304
- const r = img.getBoundingClientRect();
305
- return {
306
- x: Math.max(0, Math.min(S.W, ((clientX - r.left) / r.width) * S.W)),
307
- y: Math.max(0, Math.min(S.H, ((clientY - r.top) / r.height) * S.H)),
308
- };
309
- };
310
- let start = null, draft = null;
311
- stage.addEventListener("pointerdown", (e) => {
312
- if (!S.drawing || !S.frames.length) return;
313
- start = toVideo(e.clientX, e.clientY);
314
- stage.setPointerCapture(e.pointerId);
315
- draft = document.createElement("div");
316
- draft.className = "box draft";
317
- stage.appendChild(draft);
318
- });
319
- stage.addEventListener("pointermove", (e) => {
320
- if (!start) return;
321
- placeBox(draft, rectOf(start, toVideo(e.clientX, e.clientY)));
322
- });
323
- stage.addEventListener("pointerup", (e) => {
324
- if (!start) return;
325
- const r = rectOf(start, toVideo(e.clientX, e.clientY));
326
- start = null;
327
- draft.remove();
328
- if (r.width >= 4 && r.height >= 4) S.boxes.push(r);
329
- render();
330
- });
331
- const rectOf = (a, b) => {
332
- const x = Math.floor(Math.min(a.x, b.x)), y = Math.floor(Math.min(a.y, b.y));
333
- return { x, y, width: Math.ceil(Math.max(a.x, b.x)) - x, height: Math.ceil(Math.max(a.y, b.y)) - y };
334
- };
335
- function placeBox(el, r) {
336
- const ir = img.getBoundingClientRect(), sr = stage.getBoundingClientRect();
337
- const k = ir.width / S.W;
338
- el.style.left = `${ir.left - sr.left + r.x * k}px`;
339
- el.style.top = `${ir.top - sr.top + r.y * k}px`;
340
- el.style.width = `${r.width * k}px`;
341
- el.style.height = `${r.height * k}px`;
342
- }
343
- function renderBoxes() {
344
- stage.querySelectorAll(".box:not(.draft)").forEach((b) => b.remove());
345
- const list = $("boxList");
346
- list.replaceChildren();
347
- S.boxes.forEach((r, n) => {
348
- const el = document.createElement("div");
349
- el.className = "box";
350
- el.innerHTML = `<span>${n + 1}</span>`;
351
- stage.appendChild(el);
352
- placeBox(el, r);
353
- const li = document.createElement("li");
354
- li.textContent = `#${n + 1} ${r.width}\u00d7${r.height} at ${r.x},${r.y}`;
355
- const rm = document.createElement("button");
356
- rm.type = "button";
357
- rm.textContent = "\u2715";
358
- rm.setAttribute("aria-label", `Remove box ${n + 1}`);
359
- rm.addEventListener("click", () => { S.boxes.splice(n, 1); render(); });
360
- li.appendChild(rm);
361
- list.appendChild(li);
362
- });
363
- }
364
- img.addEventListener("load", renderBoxes);
365
- new ResizeObserver(renderBoxes).observe(stage);
366
-
367
- // --- export: one pipeline call -----------------------------------------
368
- $("apply").addEventListener("click", async () => {
369
- stop();
370
- const steps = [];
371
- // Redact first, so a box covers every frame of the kept range.
372
- if (S.boxes.length) steps.push({ op: "redact", regions: S.boxes.map((b) => ({ ...b })) });
373
- const tin = Math.round(sliceStart(S.inI) * 1000) / 1000, tout = Math.round(sliceEnd(S.outI) * 1000) / 1000;
374
- if (S.inI > 0 || S.outI < S.frames.length - 1) steps.push({ op: "trim", start: tin, end: Math.min(tout, S.duration) });
375
- $("apply").disabled = true;
376
- status("Exporting...");
377
- try {
378
- const out = resultJson(await callTool("pipeline", { input: S.input, steps }));
379
- S.result = out.outputPath;
380
- status(`Saved ${S.result}`, "ok");
381
- $("openResult").hidden = false;
382
- const what = [steps.some((s) => s.op === "trim") ? `trimmed to ${tin}-${tout}s` : "", S.boxes.length ? `${S.boxes.length} region(s) redacted` : ""].filter(Boolean).join(", ");
383
- // Tell the agent what the person did; the host includes it on the next turn.
384
- request("ui/update-model-context", {
385
- content: [{ type: "text", text: `In the review player the user exported ${S.input}, ${what}, to ${S.result}.` }],
386
- structuredContent: { input: S.input, output: S.result, steps },
387
- }).catch(() => {});
388
- } catch (err) {
389
- status(`Export failed: ${err.message}`, "err");
390
- } finally {
391
- render();
392
- }
393
- });
394
- $("openResult").addEventListener("click", () => {
395
- $("openResult").hidden = true;
396
- load(S.result);
397
- });
398
-
399
- // --- start ---------------------------------------------------------------
400
- new ResizeObserver(() => notify("ui/notifications/size-changed", { height: Math.ceil(document.documentElement.scrollHeight) })).observe(document.body);
401
- request("ui/initialize", { appInfo: { name: "screencast-review-player", version: "1.0.0" }, appCapabilities: {}, protocolVersion: PROTOCOL })
402
- .then((r) => {
403
- applyHostContext(r && r.hostContext);
404
- notify("ui/notifications/initialized", {});
405
- })
406
- .catch((err) => setEmpty(`The host did not start the player: ${err.message}`));
407
- })();
408
- </script>
144
+ <script src="player.js"></script>
409
145
  </body>
410
146
  </html>