@tmhs/screencast-mcp 0.44.2 → 0.46.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +58 -11
- package/assets/ui/player.html +9 -0
- package/assets/ui/player.js +20 -0
- package/dist/index.js +12 -0
- package/dist/prompts.js +34 -4
- package/dist/server.js +20 -0
- package/dist/tools/addMarker.js +89 -0
- package/dist/tools/backdrop.js +89 -0
- package/dist/tools/bugReport.js +266 -0
- package/dist/tools/chapters.js +156 -0
- package/dist/tools/contactSheet.js +19 -17
- package/dist/tools/cutByTranscript.js +86 -0
- package/dist/tools/findText.js +14 -64
- package/dist/tools/indexRecording.js +173 -0
- package/dist/tools/keystrokeOverlay.js +131 -0
- package/dist/tools/pipeline.js +251 -18
- package/dist/tools/reviewRecording.js +12 -0
- package/dist/tools/saveReplay.js +90 -0
- package/dist/tools/searchRecording.js +73 -0
- package/dist/tools/startRecording.js +51 -10
- package/dist/tools/stepGuide.js +193 -0
- package/dist/tools/stopRecording.js +25 -1
- package/dist/tools/transcribe.js +4 -3
- package/dist/tools/zoom.js +1 -1
- package/dist/utils/audio.js +12 -4
- package/dist/utils/backdrop.js +151 -0
- package/dist/utils/bugReport.js +172 -0
- package/dist/utils/captions.js +19 -6
- package/dist/utils/chapters.js +227 -0
- package/dist/utils/idle.js +10 -3
- package/dist/utils/keystrokes.js +155 -0
- package/dist/utils/lifecycle.js +11 -2
- package/dist/utils/media.js +5 -2
- package/dist/utils/ocrScan.js +77 -0
- package/dist/utils/pipeline.js +169 -15
- package/dist/utils/recipes.js +67 -0
- package/dist/utils/recordingIndex.js +266 -0
- package/dist/utils/replay.js +278 -0
- package/dist/utils/stepGuide.js +205 -0
- package/dist/utils/steps.js +88 -0
- package/dist/utils/timeline.js +85 -0
- package/dist/utils/toolsets.js +32 -6
- package/dist/utils/transcriptCut.js +134 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
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
|
|
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 53 typed tools.
|
|
8
8
|
|
|
9
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)
|
|
10
10
|
|
|
@@ -79,7 +79,7 @@ What it can do beyond record-and-look:
|
|
|
79
79
|
- **Zoom toward clicks.** Record with `events: true` and `zoom` glides in on each click and rings it, Screen Studio style.
|
|
80
80
|
- **Review before sharing.** In clients with MCP Apps, `review_recording` opens an inline player where a person trims and draws redaction boxes.
|
|
81
81
|
- **Find and cover secrets.** `find_text` reads the screen with Windows OCR and returns rectangles for `redact_region`.
|
|
82
|
-
- **One call, one encode.** `pipeline` runs trim, crop, redact, callouts, and an export as a single ffmpeg pass.
|
|
82
|
+
- **One call, one encode.** `pipeline` runs trim, crop, redact, callouts, and an export as a single ffmpeg pass; `recipe: "tutorial"` turns a raw recording into a cut, zoomed, normalized, captioned mp4.
|
|
83
83
|
- **Record a covered window.** `backend: "wgc"` records a window's own surface through Windows Graphics Capture.
|
|
84
84
|
|
|
85
85
|
### Why not just...
|
|
@@ -92,19 +92,21 @@ What it can do beyond record-and-look:
|
|
|
92
92
|
|
|
93
93
|
## Tools
|
|
94
94
|
|
|
95
|
-
|
|
95
|
+
53 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/`.
|
|
96
96
|
|
|
97
97
|
### Capture
|
|
98
98
|
|
|
99
99
|
| Tool | Purpose |
|
|
100
100
|
| --- | --- |
|
|
101
|
-
| `start_recording` | Start a background recording. `target` = `full` \| `monitor:<index>` \| `window:<title>` \| `region:<x>,<y>,<w>,<h>`; optional `fps`, `quality`, `audio` (set `audio.source` = `system` to also capture loopback audio), `maxDurationSec` (auto-stop cap, default 3600; `0` = none), and `events` (log clicks, scroll, cursor, and key presses to `<recording>.events.jsonl`; `keys` = `masked` by default or `shortcuts`). Returns a session id and output path. |
|
|
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. |
|
|
101
|
+
| `start_recording` | Start a background recording. `target` = `full` \| `monitor:<index>` \| `window:<title>` \| `region:<x>,<y>,<w>,<h>`; optional `fps`, `quality`, `audio` (set `audio.source` = `system` to also capture loopback audio), `maxDurationSec` (auto-stop cap, default 3600; `0` = none), and `events` (log clicks, scroll, cursor, and key presses to `<recording>.events.jsonl`; `keys` = `masked` by default or `shortcuts`), and `replayBufferSec` (instant replay: keep only the last N seconds, see `save_replay`). Returns a session id and output path. |
|
|
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. On a replay buffer, `save: true` writes the whole buffer to the output path; otherwise the buffer is discarded. |
|
|
103
|
+
| `save_replay` | Instant replay: write the last `lastSec` seconds of a buffer started with `start_recording { "replayBufferSec": 60 }` to an mp4, without stopping it. A stream copy, so it returns in about a second; `reencode: true` for a frame-exact file. With `events: true` the event log is sliced to match. |
|
|
103
104
|
| `list_sessions` | List active and finished sessions. |
|
|
104
105
|
| `get_session` | Inspect a single session by id. |
|
|
105
106
|
| `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
107
|
| `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. |
|
|
107
108
|
| `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`. |
|
|
109
|
+
| `add_marker` | Stamp a labelled moment ("bug appears", "step 3") on a running recording's video clock, or at a given second of a stopped one or any file. Markers are kept in the session (survive `stop_recording`, shown by `get_session`) and in a `<video>.markers.json` sidecar; the review player shows them as ticks, and `chapters` / `pipeline` turn them into chapters. |
|
|
108
110
|
| `screenshot` | Capture a single PNG of a `target`, and return it inline as an image the model can view. |
|
|
109
111
|
| `list_audio_devices` | List the DirectShow audio devices ffmpeg can see and flag a likely system-audio loopback device for `start_recording`. |
|
|
110
112
|
| `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`. |
|
|
@@ -119,6 +121,8 @@ What it can do beyond record-and-look:
|
|
|
119
121
|
| `screen_diff` | Compare two screenshots/frames: SSIM score, share changed, and **bounding boxes of what changed**, with the changes outlined in an inline image. Verify a UI change happened, and only where expected. |
|
|
120
122
|
| `wait_for_change` | Watch a target and return when it **changes** (a dialog opened) or **settles** (a build or page finished), instead of guessing a sleep. Reports elapsed time, changed regions, and the final state inline. |
|
|
121
123
|
| `find_text` | **Read text** on screen or in a frame with the OCR engine built into Windows (no install): every line and match with its bounding box. Locate a button by its label, check what the screen says, or find secrets (`regex: "sk-|ghp_"`) and get `redact_region` rectangles with `redact: true`; `scanEverySec` checks a whole video, with a time window per match. Best-effort; review before relying on it. |
|
|
124
|
+
| `index_recording` | **Text timeline** of a recording (path or `sessionId`): cuts it at scene changes (with fill keyframes so no stretch over 10 s goes unread), OCRs one keyframe per segment, and attaches input events, markers, and transcript cues (an `.srt`, the `<video>.srt` sidecar, or `transcript: "whisper"`). Writes `<video>.index.json` next to the video (or under `SCREENCAST_HOME/edits/indexes` when that folder is outside the allowed output dirs); a re-run on an unchanged file reuses the OCR. The index holds the raw screen text, so treat it like the video. |
|
|
125
|
+
| `search_recording` | **Find a moment as text** in an indexed recording: "when did Save failed appear?" returns timecoded hits (segment `start`/`end` plus the exact time of a matching cue, marker, or event), best first, with secrets masked in the snippets. Plain queries tolerate OCR misreads; `regex: true` for patterns. No images unless `images: N` asks for small thumbnails of the top hits. |
|
|
122
126
|
| `get_media_info` | ffprobe wrapper: duration, resolution, fps, codecs, container format, and size. |
|
|
123
127
|
|
|
124
128
|
### Minimal edit
|
|
@@ -145,10 +149,12 @@ These tools re-encode (a filter rewrites pixels, so stream copy does not apply).
|
|
|
145
149
|
| `extract_audio` | Write the audio track to its own file (`mp3`, `aac`, `wav`, or `copy`). |
|
|
146
150
|
| `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. |
|
|
147
151
|
| `denoise` | Reduce **steady** background noise (fan, hum, hiss) with `afftdn`, tuned to the file's measured noise floor. Video is copied. |
|
|
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
|
|
152
|
+
| `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; `words: true` gives one word per cue (whisper `max_len=1`) for `cut_by_transcript`. |
|
|
149
153
|
| `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). |
|
|
154
|
+
| `chapters` | **Chapters without a re-encode**: from markers (the default), the strongest scene changes, transcript sections (an SRT split at pauses), or an explicit list, written into an mp4/mkv/mov copy as real chapters (FFMETADATA, stream copy; they show in VLC and MPC) and returned as YouTube chapter text, with any YouTube rule it breaks (first at 0:00, three or more, 10 s each). `subtitles` muxes an SRT as a soft, toggleable track (`mov_text` in mp4) instead of burning it in; `textOnly` writes nothing. |
|
|
150
155
|
| `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. |
|
|
151
156
|
| `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`. |
|
|
157
|
+
| `cut_by_transcript` | **Edit by the transcript**: cut the lines you quote (`remove: ["exact words"]`, or cue numbers) and, with `fillers: true`, um/uh/erm, in one select/aselect pass that keeps audio and video in sync. Writes a re-timed `.srt` next to the video so `burn_subtitles` still lines up. Timing is as fine as the SRT: `transcribe { words: true }` gives one word per cue; with sentence cues a partial quote is placed by estimate (`exact: false`) and fillers inside a sentence are left in. `dryRun` returns the edited text first. |
|
|
152
158
|
|
|
153
159
|
### Redact
|
|
154
160
|
|
|
@@ -171,8 +177,12 @@ The production layer turns raw clips into a finished piece. Tools that combine c
|
|
|
171
177
|
| `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). |
|
|
172
178
|
| `reframe` | Re-aspect to `16:9`, `9:16`, `1:1`, or `4:5` with `pad` (letterbox, no content lost) or `crop` (fill, trims overflow). |
|
|
173
179
|
| `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. |
|
|
180
|
+
| `keystroke_overlay` | **Keycast-style badges** ("Ctrl + Shift + P", "Double click", "Typing…") burned in from the input event log, one at a time, each lingering `lingerSec` (default 1.2). Repeats merge (`Ctrl + Z ×3`); `position`, `size`, `clicks`, `typing`. It can only show what the log holds: never typed text, and shortcuts only from `keys: "shortcuts"` recordings; `keys: "masked"` here shows a chord's modifiers only. |
|
|
181
|
+
| `backdrop` | **Frame a clip or screenshot** (Screen Studio / CleanShot style): padding, a gradient, solid, or wallpaper `image` background, rounded corners, and a soft drop shadow, optionally on a `16:9`/`9:16`/`1:1`/`4:5` canvas. Presets in the project palette: `desktop` (default, dark slate), `rec` (record red), `amber` (amber to red), `light`. A PNG/JPG input writes a framed still. |
|
|
174
182
|
| `export_preset` | Encode a platform-ready file (`youtube`, `instagram_reel`, `tiktok`, `x`, `square`, `steam_trailer`, `vertical_reel`): reframes, caps fps, and encodes H.264 at the platform bitrate with faststart. `steam_trailer` is 1080p H.264 High at a padded 5.5 Mbps CBR (above Steam's 5 Mbps floor) with 48 kHz audio at -14 LUFS; `vertical_reel` centres the footage over a blurred copy of itself with audio at -14 LUFS. |
|
|
175
|
-
| `pipeline` | **Several edits in one ffmpeg process**: `steps` of `trim`, `crop`, `scale`, `speed`, `redact`, `callout`, `reframe`, `zoom` (keyframes), ending optionally in `export_preset` or `export_gif`, each with its tool's options. One re-encode, no intermediate files, and a recipe you can save and re-run on the next recording; `dryRun` returns the planned command. |
|
|
183
|
+
| `pipeline` | **Several edits in one ffmpeg process**: `steps` of `trim`, `crop`, `scale`, `speed`, `cut_idle`, `redact`, `callout`, `keystroke_overlay`, `reframe`, `zoom` (keyframes, or `follow: "clicks"` from the event log), `backdrop`, `audio` (`normalize`, `denoise`), `burn_subtitles` (a file, or `transcribe: true`), ending optionally in `export_preset` or `export_gif`, each with its tool's options. Or name a `recipe`: `pr_demo` (cut idle, click zoom, GIF under 10 MB), `tutorial` (plus denoise/normalize and captions, 1080p mp4) or `social_reel` (9:16, big captions); it expands to steps that `dryRun` shows and your own `steps` override. One re-encode, no intermediate files, and a recipe you can save and re-run on the next recording; `dryRun` returns the planned command; `chapters: true` keeps the input's markers as chapters, re-timed through trims and speed changes. |
|
|
184
|
+
| `bug_report` | **A paste-ready repro package in one call**: from a recording path or `sessionId`, writes a folder with a trimmed clip (the last 30 s by default) and a GIF under 10 MB, a timecoded contact sheet, numbered steps rebuilt from the input event log, OCR'd error and dialog text, environment details (OS, displays and DPI, window, ffmpeg), and a `report.md` for `gh issue create --body-file` (plus `report.json`). Before anything is encoded, a whole-clip OCR secret scan boxes out API keys, tokens, and `password:` values in every output and masks them in the quoted text; it needs Windows OCR (`redact: false` skips it). |
|
|
185
|
+
| `step_guide` | **A step-by-step how-to from a recording** (Steps Recorder for the agent era): from a path or `sessionId` with an input event log, writes `guide.md` with an `images/` folder and/or one self-contained `guide.html`. Each click, shortcut, typing burst, and scroll becomes a numbered step with the frame just before it, the click ringed, and a caption ("Click **Save**") from OCR of the text under the click; markers become section headings. OCR also boxes secrets out of the screenshots and masks them in captions (`ocr: false` skips both; it needs Windows OCR). Typed text is never logged, so it never appears. Returns the steps so the agent can rewrite captions. |
|
|
176
186
|
|
|
177
187
|
### Targets
|
|
178
188
|
|
|
@@ -216,10 +226,10 @@ Edit and produce tools write to a `<name>.partial.<ext>` file next to the output
|
|
|
216
226
|
|
|
217
227
|
| Toolset | Tools |
|
|
218
228
|
| --- | --- |
|
|
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` |
|
|
229
|
+
| `capture` | `start_recording`, `stop_recording`, `save_replay`, `list_sessions`, `get_session`, `read_events`, `add_marker`, `screenshot`, `list_targets`, `list_audio_devices` |
|
|
230
|
+
| `watch` | `sample_frames`, `contact_sheet`, `screen_diff`, `wait_for_change`, `find_text`, `index_recording`, `search_recording`, `review_recording`, `player_frames` |
|
|
231
|
+
| `edit` | `pipeline`, `trim`, `clip`, `concat`, `convert`, `export_gif`, `crop`, `scale`, `speed`, `compress`, `redact_region`, `cut_idle`, `cut_by_transcript` |
|
|
232
|
+
| `produce` | `callout`, `keystroke_overlay`, `backdrop`, `overlay`, `zoom`, `reframe`, `title_card`, `xfade_transition`, `assemble_highlights`, `export_preset`, `burn_subtitles`, `chapters`, `bug_report`, `step_guide` |
|
|
223
233
|
| `audio` | `extract_audio`, `normalize_audio`, `denoise`, `transcribe`, `music_bed` |
|
|
224
234
|
| `core` (always) | `doctor`, `get_media_info` |
|
|
225
235
|
|
|
@@ -254,6 +264,41 @@ Don't know where to look? `sample_frames { "input": "…", "mode": "scenes" }` r
|
|
|
254
264
|
|
|
255
265
|
`screenshot { "target": "window:My App" }` is the one-shot equivalent for a still, and also returns the image inline.
|
|
256
266
|
|
|
267
|
+
Catching a flaky failure: the useful footage is the half minute before the test failed, and by then it is too late to start recording. Run an instant-replay buffer instead and save it when something goes wrong:
|
|
268
|
+
|
|
269
|
+
```jsonc
|
|
270
|
+
// 1. keep a rolling 60 s buffer for the whole test loop (maxDurationSec 0 = no cap)
|
|
271
|
+
start_recording { "target": "window:My App", "replayBufferSec": 60, "maxDurationSec": 0, "events": true }
|
|
272
|
+
// -> { "sessionId": "rec-…", "replay": { "bufferSec": 60, "segmentSec": 2 } }
|
|
273
|
+
|
|
274
|
+
// 2. a run fails: keep the last 30 s; the buffer keeps running for the next failure
|
|
275
|
+
save_replay { "sessionId": "rec-…", "lastSec": 30 }
|
|
276
|
+
// -> { "outputPath": "…/recordings/replay-….mp4", "durationSec": 30, "eventsPath": "…/replay-….events.jsonl" }
|
|
277
|
+
|
|
278
|
+
// 3. done: stop and discard the buffer (save: true would write the whole buffer)
|
|
279
|
+
stop_recording { "sessionId": "rec-…" }
|
|
280
|
+
```
|
|
281
|
+
|
|
282
|
+
The buffer is a ring of 2 s MPEG-TS segments under `SCREENCAST_HOME/replay`, so disk use stays at about the buffer length plus 6 s however long it runs (the same bitrate as an ordinary recording of that target). Encoding costs the same CPU as an ordinary recording. A save snapshots the segments it needs, joins them and cuts with a stream copy, so it returns in about a second; the clip can hold up to 2 s of earlier frames behind an edit list (pass `reencode: true` for a frame-exact file). Buffers no live recording owns are deleted when the server starts.
|
|
283
|
+
|
|
284
|
+
Filing the bug an agent just reproduced (record with `events: true` so the clicks become steps):
|
|
285
|
+
|
|
286
|
+
```jsonc
|
|
287
|
+
bug_report { "sessionId": "rec-…", "title": "Save fails on a read-only folder", "expected": "The file saves or a clear error" }
|
|
288
|
+
// -> { "outputDir": "…/edits/bug-report-…", "reportPath": "…/report.md", "steps": 6,
|
|
289
|
+
// "errors": ["Error: Access to the path is denied."], "redaction": { "found": 1, … } }
|
|
290
|
+
// review report.md and the returned contact sheet, then:
|
|
291
|
+
gh issue create --title "Save fails on a read-only folder" --body-file …/report.md
|
|
292
|
+
```
|
|
293
|
+
|
|
294
|
+
Documenting a task as a how-to (record with `events: true`; `add_marker` between phases gives section headings):
|
|
295
|
+
|
|
296
|
+
```jsonc
|
|
297
|
+
step_guide { "sessionId": "rec-…", "title": "Export a report as PDF" }
|
|
298
|
+
// -> { "outputDir": "…/edits/step-guide-…", "markdownPath": "…/guide.md", "htmlPath": "…/guide.html",
|
|
299
|
+
// "steps": [{ "n": 1, "caption": "Click File", "section": "Open the report", "image": "step-01.png" }, …] }
|
|
300
|
+
```
|
|
301
|
+
|
|
257
302
|
Inline images are downscaled JPEGs (`maxImageWidth`, default 1280) and capped per call (`maxInlineImages`, default 8, max 20); the full-resolution PNGs stay on disk. Pass `returnImage: false` / `returnImages: false` to get paths only.
|
|
258
303
|
|
|
259
304
|
`sample_frames` writes at most `maxFrames` frames per call (default 100, max 1000). In `fps` mode it probes the video first; if the rate would exceed the cap, it samples at a lower rate so the frames still span the whole video, and the result's `capNote` says what it did.
|
|
@@ -265,6 +310,8 @@ Beyond tools, the server offers **prompts**: ready-made workflows that clients s
|
|
|
265
310
|
| Prompt | What it does |
|
|
266
311
|
| --- | --- |
|
|
267
312
|
| `bug-repro-clip` | Record, find the bug moment, check for secrets, trim, annotate, and export a GIF for an issue. |
|
|
313
|
+
| `file-bug-report` | Record a repro with input events, package it with `bug_report` (redacted clip, GIF, steps, error text, `report.md`), review it, and file it with `gh issue create` once you confirm. |
|
|
314
|
+
| `document-steps` | Record a task with input events and markers, turn it into a step-by-step guide with `step_guide`, and tidy the captions. |
|
|
268
315
|
| `demo-gif` | Record a feature walkthrough and export a GIF small enough for a README or PR. |
|
|
269
316
|
| `verify-ui-change` | Screenshot before, make the change, wait for the screen to settle, diff, and confirm the text. |
|
|
270
317
|
| `review-recording` | Summarize what happens in a recording, with timestamps. |
|
package/assets/ui/player.html
CHANGED
|
@@ -63,6 +63,13 @@
|
|
|
63
63
|
.timeline { position: relative; height: 56px; border: 1px solid var(--line); border-radius: 6px; background: var(--panel); cursor: pointer; touch-action: none; }
|
|
64
64
|
.seek { position: absolute; inset: 0; border-radius: 5px; }
|
|
65
65
|
#ticks i { position: absolute; bottom: 0; width: 2px; height: 9px; margin-left: -1px; background: var(--amber); opacity: .8; pointer-events: none; }
|
|
66
|
+
/* Markers (#174): full-height ink ticks, a REC-red cap, and a list below. */
|
|
67
|
+
#marks b { position: absolute; top: 0; bottom: 0; width: 2px; margin-left: -1px; background: var(--ink); opacity: .85; pointer-events: none; }
|
|
68
|
+
#marks b::before { content: ""; position: absolute; top: 0; left: -3px; width: 8px; height: 6px; background: var(--rec); border-radius: 0 0 2px 2px; }
|
|
69
|
+
#markList { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: .4rem; }
|
|
70
|
+
#markList button { font: 12px var(--mono); background: var(--panel); border: 1px solid var(--line); border-radius: 6px; padding: .15rem .55rem; cursor: pointer; color: var(--ink); }
|
|
71
|
+
#markList button:hover { border-color: var(--rec); }
|
|
72
|
+
#markList button span { color: var(--rec); margin-right: .4rem; font-variant-numeric: tabular-nums; }
|
|
66
73
|
#strip { position: absolute; inset: 0; display: flex; overflow: hidden; border-radius: 5px; opacity: .55; }
|
|
67
74
|
#strip img { height: 100%; flex: 1 1 0; min-width: 0; object-fit: cover; pointer-events: none; }
|
|
68
75
|
.shade { position: absolute; top: 0; bottom: 0; background: color-mix(in srgb, var(--bg) 70%, transparent); pointer-events: none; }
|
|
@@ -114,6 +121,7 @@
|
|
|
114
121
|
<div id="strip"></div>
|
|
115
122
|
<div class="shade" id="shadeIn"></div><div class="shade" id="shadeOut"></div>
|
|
116
123
|
<div id="ticks"></div>
|
|
124
|
+
<div id="marks"></div>
|
|
117
125
|
<div id="head"></div>
|
|
118
126
|
<!-- Sliders (#243): arrows move a frame, Page Up/Down a tenth, Home/End the ends. -->
|
|
119
127
|
<div class="seek" id="seek" role="slider" tabindex="0" aria-label="Playhead" aria-disabled="true"
|
|
@@ -124,6 +132,7 @@
|
|
|
124
132
|
aria-valuemin="0" aria-valuemax="0" aria-valuenow="0"></div>
|
|
125
133
|
</div>
|
|
126
134
|
<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>
|
|
135
|
+
<ul id="markList" aria-label="Markers" hidden></ul>
|
|
127
136
|
<ul id="boxList" aria-label="Redaction boxes"></ul>
|
|
128
137
|
<form id="boxForm" novalidate>
|
|
129
138
|
<fieldset id="boxFields" disabled>
|
package/assets/ui/player.js
CHANGED
|
@@ -121,6 +121,26 @@
|
|
|
121
121
|
t.style.left = `${pct(S.times[i])}%`;
|
|
122
122
|
return t;
|
|
123
123
|
}));
|
|
124
|
+
// Markers (#174): a tick on the timeline and a button that seeks to it.
|
|
125
|
+
const marks = Array.isArray(meta.markers) ? meta.markers.filter((m) => m && typeof m.t === "number" && m.t <= S.duration) : [];
|
|
126
|
+
$("marks").replaceChildren(...marks.map((m) => {
|
|
127
|
+
const b = document.createElement("b");
|
|
128
|
+
b.style.left = `${pct(m.t)}%`;
|
|
129
|
+
return b;
|
|
130
|
+
}));
|
|
131
|
+
$("markList").replaceChildren(...marks.map((m) => {
|
|
132
|
+
const li = document.createElement("li");
|
|
133
|
+
const btn = document.createElement("button");
|
|
134
|
+
btn.type = "button";
|
|
135
|
+
const tc = document.createElement("span");
|
|
136
|
+
tc.textContent = fmt(m.t);
|
|
137
|
+
btn.append(tc, String(m.label || "Marker"));
|
|
138
|
+
btn.setAttribute("aria-label", `Go to marker ${m.label || ""} at ${fmt(m.t)}`);
|
|
139
|
+
btn.addEventListener("click", () => { stop(); show(frameAt(m.t)); render(); });
|
|
140
|
+
li.appendChild(btn);
|
|
141
|
+
return li;
|
|
142
|
+
}));
|
|
143
|
+
$("markList").hidden = marks.length === 0;
|
|
124
144
|
const every = meta.intervalSec ?? S.duration / S.frames.length;
|
|
125
145
|
$("sampling").textContent = `1 frame / ${every.toFixed(1)}s` + (S.scene.size ? `, +${S.scene.size} at scene changes` : "");
|
|
126
146
|
["play", "draw"].forEach((id) => ($(id).disabled = false));
|
package/dist/index.js
CHANGED
|
@@ -6,6 +6,7 @@ import { abortEditJobs } from "./utils/jobs.js";
|
|
|
6
6
|
import { probeDuration, stopAll } from "./utils/lifecycle.js";
|
|
7
7
|
import { createServer } from "./server.js";
|
|
8
8
|
import { pruneCaptures, retentionDays, RETENTION_ENV } from "./utils/retention.js";
|
|
9
|
+
import { cleanupReplayDirs } from "./utils/replay.js";
|
|
9
10
|
const server = createServer();
|
|
10
11
|
async function main() {
|
|
11
12
|
try {
|
|
@@ -17,6 +18,17 @@ async function main() {
|
|
|
17
18
|
catch (err) {
|
|
18
19
|
process.stderr.write(`Orphan reaping skipped: ${err instanceof Error ? err.message : String(err)}\n`);
|
|
19
20
|
}
|
|
21
|
+
try {
|
|
22
|
+
const live = getStore()
|
|
23
|
+
.list()
|
|
24
|
+
.flatMap((r) => (r.status === "recording" && r.replay ? [r.replay.dir] : []));
|
|
25
|
+
const removed = cleanupReplayDirs(live);
|
|
26
|
+
if (removed > 0)
|
|
27
|
+
process.stderr.write(`Removed ${removed} leftover replay buffer(s).\n`);
|
|
28
|
+
}
|
|
29
|
+
catch (err) {
|
|
30
|
+
process.stderr.write(`Replay buffer cleanup skipped: ${err instanceof Error ? err.message : String(err)}\n`);
|
|
31
|
+
}
|
|
20
32
|
const days = retentionDays();
|
|
21
33
|
if (days !== null) {
|
|
22
34
|
const pruned = pruneCaptures(days);
|
package/dist/prompts.js
CHANGED
|
@@ -8,13 +8,20 @@ export const PROMPT_TEXT = {
|
|
|
8
8
|
3. find_text { input: <recording>, scanEverySec: 1, query: "sk-|ghp_|api.?key|token|password", regex: true, redact: true } to check the whole clip, not one frame. If anything sensitive shows up, redact_region its redactRegions (each has its own start/end) with style "box" before sharing. OCR can miss text, so also look at the frames yourself.
|
|
9
9
|
4. trim (or clip) to the few seconds around the bug, and callout to box or point at it.
|
|
10
10
|
5. export_gif { input: <clip>, maxBytes: 10000000 } so it can be pasted into an issue or PR.
|
|
11
|
-
Report the final file path, what the clip shows, and anything you redacted
|
|
11
|
+
Report the final file path, what the clip shows, and anything you redacted. (To file it as an issue, bug_report does steps 3-5 in one call and writes report.md.)`,
|
|
12
|
+
fileBugReport: (target, notes, expected) => `File a bug report for ${target}, with a redacted repro package.${notes ? ` The bug: ${notes}.` : ""}${expected ? ` Expected: ${expected}.` : ""}
|
|
13
|
+
|
|
14
|
+
1. start_recording { target: "${target}", events: true } so clicks and shortcuts are logged as repro steps, then reproduce the bug (or ask me to), and stop_recording right after it shows.
|
|
15
|
+
2. contact_sheet { input: <recording> } and find the moment it goes wrong; note its time.
|
|
16
|
+
3. bug_report { sessionId: <session id>, title: <one-line summary>, actual: <what happened>, expected: <what should happen>, clipSec: 30 } (or start/end around that moment). It scans the clip for secrets with OCR and boxes them out before writing the clip, GIF, contact sheet, steps, error text, and report.md.
|
|
17
|
+
4. Read report.md and look at the contact sheet it returns: check the steps make sense and that nothing sensitive is left (OCR can miss text; add regions and rerun with overwrite: true if so).
|
|
18
|
+
5. Only if I confirm, run gh issue create --title <title> --body-file <reportPath>, then attach the GIF to the issue.
|
|
19
|
+
Report the folder path, the steps, the error text found, and what was redacted.`,
|
|
12
20
|
demoGif: (target, maxMB) => `Make a demo GIF of ${target} for a README or PR, under ${maxMB} MB.
|
|
13
21
|
|
|
14
|
-
1. start_recording { target: "${target}" }, walk through the feature (or ask me to), then stop_recording.
|
|
22
|
+
1. start_recording { target: "${target}", events: true }, walk through the feature (or ask me to), then stop_recording.
|
|
15
23
|
2. contact_sheet { input: <recording>, mode: "scenes" } to see the whole run at a glance and pick the best stretch.
|
|
16
|
-
3. trim
|
|
17
|
-
4. export_gif { input: <clip>, maxBytes: ${Math.round(Number(maxMB) * 1_000_000) || 10_000_000} }. If it does not fit, try format: "webp" or a shorter clip.
|
|
24
|
+
3. pipeline { input: <recording>, recipe: "pr_demo", steps: [{ op: "trim", ... that stretch }, { op: "export_gif", maxBytes: ${Math.round(Number(maxMB) * 1_000_000) || 10_000_000} }] }: one pass that cuts idle time, zooms toward the clicks, and writes the GIF (dryRun first to see the steps). If it does not fit, try format: "webp" or a shorter stretch.
|
|
18
25
|
Report the file path, its size, and the settings export_gif chose.`,
|
|
19
26
|
verifyUiChange: (target, expectation) => `Verify a UI change in ${target}. Expected: ${expectation || "(describe what should change)"}.
|
|
20
27
|
|
|
@@ -31,6 +38,12 @@ Say whether the change happened, whether anything changed that should not have,
|
|
|
31
38
|
3. sample_frames { input: "${path}", mode: "scenes" } to look closely at each change.
|
|
32
39
|
4. If there is on-screen text worth quoting, find_text on the relevant frame.
|
|
33
40
|
Give a timestamped summary of the main steps and anything that looks wrong.`,
|
|
41
|
+
documentSteps: (target, task) => `Document ${task ? `how to ${task}` : "what I do next"} as a step-by-step guide.
|
|
42
|
+
|
|
43
|
+
1. start_recording { target: "${target}", events: true } so every click and shortcut is logged, then do the task (or ask me to). Between phases, add_marker { sessionId: <id>, label: <phase name> } so the guide gets section headings. Then stop_recording.
|
|
44
|
+
2. step_guide { sessionId: <session id>, title: <what the guide teaches> }. It writes guide.md (with an images folder) and a self-contained guide.html: one screenshot per step, the click ringed, captioned from the text under it, secrets boxed out. Typed text is never logged; say what to type in the captions yourself.
|
|
45
|
+
3. Read the returned steps and rewrite any vague caption ("Click the marked spot") in guide.md, using the screenshot to name the control.
|
|
46
|
+
Report the guide paths, the steps, and anything you would check before sharing it.`,
|
|
34
47
|
};
|
|
35
48
|
export function registerPrompts(server) {
|
|
36
49
|
server.registerPrompt("bug-repro-clip", {
|
|
@@ -41,6 +54,15 @@ export function registerPrompts(server) {
|
|
|
41
54
|
notes: z.string().optional().describe("What the bug is."),
|
|
42
55
|
},
|
|
43
56
|
}, ({ target, notes }) => message(PROMPT_TEXT.bugReproClip(target || "full", notes ?? "")));
|
|
57
|
+
server.registerPrompt("file-bug-report", {
|
|
58
|
+
title: "File a bug report",
|
|
59
|
+
description: "Record a repro with input events, then package it with bug_report: redacted clip, GIF, steps, error text, and report.md.",
|
|
60
|
+
argsSchema: {
|
|
61
|
+
target: z.string().optional().describe("What to record, e.g. window:My App (default: full)."),
|
|
62
|
+
notes: z.string().optional().describe("What the bug is."),
|
|
63
|
+
expected: z.string().optional().describe("What should happen instead."),
|
|
64
|
+
},
|
|
65
|
+
}, ({ target, notes, expected }) => message(PROMPT_TEXT.fileBugReport(target || "full", notes ?? "", expected ?? "")));
|
|
44
66
|
server.registerPrompt("demo-gif", {
|
|
45
67
|
title: "Make a demo GIF",
|
|
46
68
|
description: "Record a feature walkthrough and export a GIF small enough for a README or PR.",
|
|
@@ -62,4 +84,12 @@ export function registerPrompts(server) {
|
|
|
62
84
|
description: "Summarize what happens in a recording, with timestamps, using a contact sheet and scene frames.",
|
|
63
85
|
argsSchema: { path: z.string().describe("Path to the recording.") },
|
|
64
86
|
}, ({ path }) => message(PROMPT_TEXT.reviewRecording(path)));
|
|
87
|
+
server.registerPrompt("document-steps", {
|
|
88
|
+
title: "Document what I just did",
|
|
89
|
+
description: "Record a task with input events and markers, then turn it into a step-by-step guide with step_guide.",
|
|
90
|
+
argsSchema: {
|
|
91
|
+
target: z.string().optional().describe("What to record (default: full)."),
|
|
92
|
+
task: z.string().optional().describe("The task the guide teaches."),
|
|
93
|
+
},
|
|
94
|
+
}, ({ target, task }) => message(PROMPT_TEXT.documentSteps(target || "full", task ?? "")));
|
|
65
95
|
}
|
package/dist/server.js
CHANGED
|
@@ -3,9 +3,12 @@ import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
|
3
3
|
import { parseToolsets, serverInstructions, SELECTABLE_TOOLSETS, toolsetOf, } from "./utils/toolsets.js";
|
|
4
4
|
import { register as registerStartRecording } from "./tools/startRecording.js";
|
|
5
5
|
import { register as registerStopRecording } from "./tools/stopRecording.js";
|
|
6
|
+
import { register as registerSaveReplay } from "./tools/saveReplay.js";
|
|
6
7
|
import { register as registerListSessions } from "./tools/listSessions.js";
|
|
7
8
|
import { register as registerGetSession } from "./tools/getSession.js";
|
|
8
9
|
import { register as registerReadEvents } from "./tools/readEvents.js";
|
|
10
|
+
import { register as registerAddMarker } from "./tools/addMarker.js";
|
|
11
|
+
import { register as registerChapters } from "./tools/chapters.js";
|
|
9
12
|
import { register as registerReviewRecording } from "./tools/reviewRecording.js";
|
|
10
13
|
import { register as registerScreenshot } from "./tools/screenshot.js";
|
|
11
14
|
import { register as registerSampleFrames } from "./tools/sampleFrames.js";
|
|
@@ -13,6 +16,8 @@ import { register as registerContactSheet } from "./tools/contactSheet.js";
|
|
|
13
16
|
import { register as registerScreenDiff } from "./tools/screenDiff.js";
|
|
14
17
|
import { register as registerWaitForChange } from "./tools/waitForChange.js";
|
|
15
18
|
import { register as registerFindText } from "./tools/findText.js";
|
|
19
|
+
import { register as registerIndexRecording } from "./tools/indexRecording.js";
|
|
20
|
+
import { register as registerSearchRecording } from "./tools/searchRecording.js";
|
|
16
21
|
import { register as registerGetMediaInfo } from "./tools/getMediaInfo.js";
|
|
17
22
|
import { register as registerTrim } from "./tools/trim.js";
|
|
18
23
|
import { register as registerConcat } from "./tools/concat.js";
|
|
@@ -23,6 +28,8 @@ import { register as registerScale } from "./tools/scale.js";
|
|
|
23
28
|
import { register as registerSpeed } from "./tools/speed.js";
|
|
24
29
|
import { register as registerOverlay } from "./tools/overlay.js";
|
|
25
30
|
import { register as registerCallout } from "./tools/callout.js";
|
|
31
|
+
import { register as registerKeystrokeOverlay } from "./tools/keystrokeOverlay.js";
|
|
32
|
+
import { register as registerBackdrop } from "./tools/backdrop.js";
|
|
26
33
|
import { register as registerCompress } from "./tools/compress.js";
|
|
27
34
|
import { register as registerExtractAudio } from "./tools/extractAudio.js";
|
|
28
35
|
import { register as registerNormalizeAudio } from "./tools/normalizeAudio.js";
|
|
@@ -31,6 +38,7 @@ import { register as registerTranscribe } from "./tools/transcribe.js";
|
|
|
31
38
|
import { register as registerBurnSubtitles } from "./tools/burnSubtitles.js";
|
|
32
39
|
import { register as registerClip } from "./tools/clip.js";
|
|
33
40
|
import { register as registerCutIdle } from "./tools/cutIdle.js";
|
|
41
|
+
import { register as registerCutByTranscript } from "./tools/cutByTranscript.js";
|
|
34
42
|
import { register as registerRedactRegion } from "./tools/redactRegion.js";
|
|
35
43
|
import { register as registerListAudioDevices } from "./tools/listAudioDevices.js";
|
|
36
44
|
import { register as registerListTargets } from "./tools/listTargets.js";
|
|
@@ -43,6 +51,8 @@ import { register as registerReframe } from "./tools/reframe.js";
|
|
|
43
51
|
import { register as registerZoom } from "./tools/zoom.js";
|
|
44
52
|
import { register as registerPipeline } from "./tools/pipeline.js";
|
|
45
53
|
import { register as registerExportPreset } from "./tools/exportPreset.js";
|
|
54
|
+
import { register as registerBugReport } from "./tools/bugReport.js";
|
|
55
|
+
import { register as registerStepGuide } from "./tools/stepGuide.js";
|
|
46
56
|
import { registerResources } from "./resources.js";
|
|
47
57
|
import { registerPrompts } from "./prompts.js";
|
|
48
58
|
import { attachLogging } from "./utils/logging.js";
|
|
@@ -62,9 +72,11 @@ export function createServer(options = {}) {
|
|
|
62
72
|
const tools = captureRegisteredTools(server);
|
|
63
73
|
registerStartRecording(server);
|
|
64
74
|
registerStopRecording(server);
|
|
75
|
+
registerSaveReplay(server);
|
|
65
76
|
registerListSessions(server);
|
|
66
77
|
registerGetSession(server);
|
|
67
78
|
registerReadEvents(server);
|
|
79
|
+
registerAddMarker(server);
|
|
68
80
|
registerReviewRecording(server);
|
|
69
81
|
registerScreenshot(server);
|
|
70
82
|
registerSampleFrames(server);
|
|
@@ -72,6 +84,8 @@ export function createServer(options = {}) {
|
|
|
72
84
|
registerScreenDiff(server);
|
|
73
85
|
registerWaitForChange(server);
|
|
74
86
|
registerFindText(server);
|
|
87
|
+
registerIndexRecording(server);
|
|
88
|
+
registerSearchRecording(server);
|
|
75
89
|
registerGetMediaInfo(server);
|
|
76
90
|
registerTrim(server);
|
|
77
91
|
registerConcat(server);
|
|
@@ -82,14 +96,18 @@ export function createServer(options = {}) {
|
|
|
82
96
|
registerSpeed(server);
|
|
83
97
|
registerOverlay(server);
|
|
84
98
|
registerCallout(server);
|
|
99
|
+
registerKeystrokeOverlay(server);
|
|
100
|
+
registerBackdrop(server);
|
|
85
101
|
registerCompress(server);
|
|
86
102
|
registerExtractAudio(server);
|
|
87
103
|
registerNormalizeAudio(server);
|
|
88
104
|
registerDenoise(server);
|
|
89
105
|
registerTranscribe(server);
|
|
90
106
|
registerBurnSubtitles(server);
|
|
107
|
+
registerChapters(server);
|
|
91
108
|
registerClip(server);
|
|
92
109
|
registerCutIdle(server);
|
|
110
|
+
registerCutByTranscript(server);
|
|
93
111
|
registerRedactRegion(server);
|
|
94
112
|
registerListAudioDevices(server);
|
|
95
113
|
registerListTargets(server);
|
|
@@ -102,6 +120,8 @@ export function createServer(options = {}) {
|
|
|
102
120
|
registerZoom(server);
|
|
103
121
|
registerPipeline(server);
|
|
104
122
|
registerExportPreset(server);
|
|
123
|
+
registerBugReport(server);
|
|
124
|
+
registerStepGuide(server);
|
|
105
125
|
applyToolsets(tools, selection);
|
|
106
126
|
registerResources(server);
|
|
107
127
|
registerPrompts(server);
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { existsSync } from "node:fs";
|
|
3
|
+
import { errorResponse, okResponse, ScreencastError } from "../utils/errors.js";
|
|
4
|
+
import { looseOutput } from "../utils/toolSpec.js";
|
|
5
|
+
import { assertOutputAllowed } from "../utils/paths.js";
|
|
6
|
+
import { cleanLabel, insertMarker, markerTimeSec, markersPath, readMarkers, writeMarkers, MAX_LABEL, } from "../utils/chapters.js";
|
|
7
|
+
import { getStore } from "../context.js";
|
|
8
|
+
const ADDS_MARKER = {
|
|
9
|
+
readOnlyHint: false,
|
|
10
|
+
destructiveHint: false,
|
|
11
|
+
idempotentHint: false,
|
|
12
|
+
openWorldHint: false,
|
|
13
|
+
};
|
|
14
|
+
const inputSchema = {
|
|
15
|
+
label: z.string().min(1).max(MAX_LABEL).describe('e.g. "bug appears".'),
|
|
16
|
+
sessionId: z.string().min(1).optional().describe("Recording to mark (a stopped one needs at)."),
|
|
17
|
+
input: z.string().min(1).optional().describe("Or a video path (needs at)."),
|
|
18
|
+
at: z
|
|
19
|
+
.number()
|
|
20
|
+
.min(0)
|
|
21
|
+
.optional()
|
|
22
|
+
.describe("Video second (default: now, while recording)."),
|
|
23
|
+
};
|
|
24
|
+
export function register(server) {
|
|
25
|
+
server.registerTool("add_marker", {
|
|
26
|
+
title: "Add Marker",
|
|
27
|
+
description: "Mark a labelled moment on a recording, live or at a second. Kept in the session and a sidecar; " +
|
|
28
|
+
"chapters and pipeline turn markers into chapters.",
|
|
29
|
+
inputSchema,
|
|
30
|
+
outputSchema: looseOutput({ count: z.number().int(), markersPath: z.string() }),
|
|
31
|
+
annotations: ADDS_MARKER,
|
|
32
|
+
}, async (args) => {
|
|
33
|
+
try {
|
|
34
|
+
if (!args.sessionId && !args.input)
|
|
35
|
+
throw new ScreencastError("Pass sessionId or input.");
|
|
36
|
+
if (args.sessionId) {
|
|
37
|
+
const store = getStore();
|
|
38
|
+
const record = store.get(args.sessionId);
|
|
39
|
+
if (!record)
|
|
40
|
+
throw new ScreencastError(`No session with id "${args.sessionId}".`);
|
|
41
|
+
let t = args.at;
|
|
42
|
+
if (t === undefined) {
|
|
43
|
+
if (record.status !== "recording") {
|
|
44
|
+
throw new ScreencastError(`Session "${args.sessionId}" is ${record.status}, so there is no "now" to mark.`, "Pass at (video seconds) to mark a stopped recording.");
|
|
45
|
+
}
|
|
46
|
+
t = markerTimeSec(record.videoStartMs ?? Date.parse(record.startedAt), Date.now());
|
|
47
|
+
}
|
|
48
|
+
else if (record.durationSec != null && t > record.durationSec) {
|
|
49
|
+
throw new ScreencastError(`at ${t}s is past the end of the recording (${record.durationSec}s).`);
|
|
50
|
+
}
|
|
51
|
+
const marker = { t, label: args.label, at: new Date().toISOString() };
|
|
52
|
+
const markers = insertMarker(record.markers ?? [], marker);
|
|
53
|
+
store.update(args.sessionId, { markers });
|
|
54
|
+
let sidecar = markersPath(record.outputPath);
|
|
55
|
+
let warning;
|
|
56
|
+
try {
|
|
57
|
+
sidecar = writeMarkers(record.outputPath, markers, args.sessionId);
|
|
58
|
+
}
|
|
59
|
+
catch (err) {
|
|
60
|
+
warning = `Saved in the session, but the sidecar ${sidecar} could not be written: ${err.message}`;
|
|
61
|
+
}
|
|
62
|
+
return okResponse({
|
|
63
|
+
sessionId: args.sessionId,
|
|
64
|
+
marker: { t: Math.round(t * 1000) / 1000, label: cleanLabel(args.label) },
|
|
65
|
+
count: markers.length,
|
|
66
|
+
markersPath: sidecar,
|
|
67
|
+
...(record.status === "recording" ? { live: true } : {}),
|
|
68
|
+
...(warning ? { warning } : {}),
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
const input = args.input;
|
|
72
|
+
if (args.at === undefined)
|
|
73
|
+
throw new ScreencastError("Pass at (video seconds) to mark a file.");
|
|
74
|
+
if (!existsSync(input))
|
|
75
|
+
throw new ScreencastError(`Input file not found: ${input}`);
|
|
76
|
+
assertOutputAllowed(markersPath(input));
|
|
77
|
+
const markers = insertMarker(readMarkers(input), { t: args.at, label: args.label, at: new Date().toISOString() });
|
|
78
|
+
const path = writeMarkers(input, markers);
|
|
79
|
+
return okResponse({
|
|
80
|
+
marker: { t: Math.round(args.at * 1000) / 1000, label: cleanLabel(args.label) },
|
|
81
|
+
count: markers.length,
|
|
82
|
+
markersPath: path,
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
catch (error) {
|
|
86
|
+
return errorResponse(error);
|
|
87
|
+
}
|
|
88
|
+
});
|
|
89
|
+
}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { existsSync } from "node:fs";
|
|
3
|
+
import { extname } from "node:path";
|
|
4
|
+
import { errorResponse, okResponse, ScreencastError } from "../utils/errors.js";
|
|
5
|
+
import { WRITES_FILE, looseOutput } from "../utils/toolSpec.js";
|
|
6
|
+
import { requireFfmpeg, probeMedia } from "../utils/ffmpeg.js";
|
|
7
|
+
import { runEditJob } from "../utils/jobs.js";
|
|
8
|
+
import { buildBackdropArgs, BACKDROP_PRESET_NAMES, MAX_BACKDROP_COLORS } from "../utils/backdrop.js";
|
|
9
|
+
import { editOutputExt, assertEditContainer } from "../utils/media.js";
|
|
10
|
+
import { resolveOutput, subdir, stamp, rand } from "../utils/paths.js";
|
|
11
|
+
const STILL = /\.(png|jpe?g|bmp|tiff?|webp)$/i;
|
|
12
|
+
export const backdropOptionsSchema = {
|
|
13
|
+
preset: z.enum(BACKDROP_PRESET_NAMES).optional(),
|
|
14
|
+
colors: z.array(z.string()).min(1).max(MAX_BACKDROP_COLORS).optional(),
|
|
15
|
+
image: z.string().min(1).optional(),
|
|
16
|
+
padding: z.number().int().nonnegative().max(2000).optional(),
|
|
17
|
+
radius: z.number().int().nonnegative().max(1000).optional(),
|
|
18
|
+
shadow: z.number().int().nonnegative().max(200).optional(),
|
|
19
|
+
shadowOpacity: z.number().min(0).max(1).optional(),
|
|
20
|
+
aspect: z.enum(["16:9", "9:16", "1:1", "4:5"]).optional(),
|
|
21
|
+
};
|
|
22
|
+
const o = backdropOptionsSchema;
|
|
23
|
+
const inputSchema = {
|
|
24
|
+
input: z.string().min(1).describe("Path to the source video or image (png/jpg)."),
|
|
25
|
+
preset: o.preset.describe("Gradient: desktop (default, dark slate), rec (red), amber, light."),
|
|
26
|
+
colors: o.colors.describe("Instead: 1 color = solid, 2-4 = diagonal gradient."),
|
|
27
|
+
image: o.image.describe("Instead: a wallpaper image, scaled to cover."),
|
|
28
|
+
padding: o.padding.describe("px around the content (default 6% of the longer side)."),
|
|
29
|
+
radius: o.radius.describe("Corner radius px (default ~1.2% of the longer side; 0 = square)."),
|
|
30
|
+
shadow: o.shadow.describe("Shadow blur px (default ~2.5%; 0 = none)."),
|
|
31
|
+
shadowOpacity: o.shadowOpacity.describe("Default 0.5."),
|
|
32
|
+
aspect: o.aspect.describe("Output on this aspect's canvas (1920x1080, ...), content scaled to fit."),
|
|
33
|
+
output: z.string().optional().describe("Optional output path. Defaults under SCREENCAST_HOME/edits (screenshots for an image)."),
|
|
34
|
+
overwrite: z.boolean().optional().describe("Allow replacing an existing file at the output path (default false)."),
|
|
35
|
+
};
|
|
36
|
+
export function register(server) {
|
|
37
|
+
server.registerTool("backdrop", {
|
|
38
|
+
title: "Add Backdrop",
|
|
39
|
+
description: "Frame a video or screenshot on a gradient, color, or wallpaper with padding, rounded corners, " +
|
|
40
|
+
"and a drop shadow, optionally on a 16:9/1:1/9:16/4:5 canvas.",
|
|
41
|
+
inputSchema,
|
|
42
|
+
outputSchema: looseOutput({ outputPath: z.string(), width: z.number().int(), height: z.number().int() }),
|
|
43
|
+
annotations: WRITES_FILE,
|
|
44
|
+
}, async (args, extra) => {
|
|
45
|
+
try {
|
|
46
|
+
requireFfmpeg();
|
|
47
|
+
if (!existsSync(args.input))
|
|
48
|
+
throw new ScreencastError(`Input file not found: ${args.input}`);
|
|
49
|
+
if (args.image && !existsSync(args.image))
|
|
50
|
+
throw new ScreencastError(`Background image not found: ${args.image}`);
|
|
51
|
+
const still = STILL.test(args.input);
|
|
52
|
+
if (still && args.output && !STILL.test(args.output)) {
|
|
53
|
+
throw new ScreencastError("An image input writes an image: give the output a .png or .jpg extension.");
|
|
54
|
+
}
|
|
55
|
+
if (!still)
|
|
56
|
+
assertEditContainer(args.output);
|
|
57
|
+
const info = await probeMedia(args.input);
|
|
58
|
+
if (!info.width || !info.height)
|
|
59
|
+
throw new ScreencastError(`Could not read the size of ${args.input}.`);
|
|
60
|
+
const ext = still ? (/\.jpe?g$/i.test(args.input) ? extname(args.input).toLowerCase() : ".png") : editOutputExt(args.input);
|
|
61
|
+
const output = resolveOutput(args.output, subdir(still ? "screenshots" : "edits"), `backdrop-${stamp()}-${rand()}${ext}`, args.overwrite);
|
|
62
|
+
const opts = {
|
|
63
|
+
preset: args.preset,
|
|
64
|
+
colors: args.colors,
|
|
65
|
+
image: args.image,
|
|
66
|
+
padding: args.padding,
|
|
67
|
+
radius: args.radius,
|
|
68
|
+
shadow: args.shadow,
|
|
69
|
+
shadowOpacity: args.shadowOpacity,
|
|
70
|
+
aspect: args.aspect,
|
|
71
|
+
};
|
|
72
|
+
const { args: ffArgs, layout } = buildBackdropArgs(args.input, output, opts, { width: info.width, height: info.height }, still);
|
|
73
|
+
await runEditJob(ffArgs, { output, durationSec: still ? null : info.durationSec, extra });
|
|
74
|
+
return okResponse({
|
|
75
|
+
outputPath: output,
|
|
76
|
+
width: layout.canvasW,
|
|
77
|
+
height: layout.canvasH,
|
|
78
|
+
content: { x: layout.x, y: layout.y, width: layout.contentW, height: layout.contentH },
|
|
79
|
+
padding: layout.padding,
|
|
80
|
+
radius: layout.radius,
|
|
81
|
+
shadow: layout.shadow,
|
|
82
|
+
background: args.image ? "image" : args.colors ? "colors" : (args.preset ?? "desktop"),
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
catch (error) {
|
|
86
|
+
return errorResponse(error);
|
|
87
|
+
}
|
|
88
|
+
});
|
|
89
|
+
}
|