@tmhs/screencast-mcp 0.45.0 → 0.47.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (56) hide show
  1. package/README.md +138 -82
  2. package/assets/cursor/arrow.png +0 -0
  3. package/dist/cli.js +360 -0
  4. package/dist/index.js +10 -2
  5. package/dist/prompts.js +16 -3
  6. package/dist/server.js +18 -0
  7. package/dist/tools/addMarker.js +6 -2
  8. package/dist/tools/bugReport.js +2 -2
  9. package/dist/tools/chapters.js +1 -1
  10. package/dist/tools/cursor.js +87 -0
  11. package/dist/tools/cutByTranscript.js +86 -0
  12. package/dist/tools/doctor.js +14 -1
  13. package/dist/tools/indexRecording.js +173 -0
  14. package/dist/tools/listVideoDevices.js +26 -0
  15. package/dist/tools/narrate.js +84 -0
  16. package/dist/tools/overlay.js +2 -0
  17. package/dist/tools/pauseRecording.js +44 -0
  18. package/dist/tools/pipeline.js +215 -19
  19. package/dist/tools/readEvents.js +1 -1
  20. package/dist/tools/resumeRecording.js +46 -0
  21. package/dist/tools/reviewRecording.js +1 -1
  22. package/dist/tools/searchRecording.js +73 -0
  23. package/dist/tools/startRecording.js +106 -67
  24. package/dist/tools/stepGuide.js +193 -0
  25. package/dist/tools/stopRecording.js +38 -3
  26. package/dist/tools/transcribe.js +4 -3
  27. package/dist/tools/zoom.js +1 -1
  28. package/dist/utils/audio.js +12 -4
  29. package/dist/utils/audioDevices.js +34 -4
  30. package/dist/utils/bugReport.js +1 -75
  31. package/dist/utils/captions.js +19 -6
  32. package/dist/utils/chapters.js +5 -0
  33. package/dist/utils/cursor.js +317 -0
  34. package/dist/utils/events.js +22 -4
  35. package/dist/utils/gpu.js +173 -0
  36. package/dist/utils/idle.js +10 -3
  37. package/dist/utils/keystrokes.js +2 -17
  38. package/dist/utils/lifecycle.js +85 -2
  39. package/dist/utils/media.js +4 -0
  40. package/dist/utils/monitors.js +5 -2
  41. package/dist/utils/narrate.js +224 -0
  42. package/dist/utils/pause.js +176 -0
  43. package/dist/utils/pipeline.js +154 -14
  44. package/dist/utils/recipes.js +67 -0
  45. package/dist/utils/recorder.js +163 -0
  46. package/dist/utils/recordingIndex.js +266 -0
  47. package/dist/utils/sessions.js +29 -5
  48. package/dist/utils/stepGuide.js +205 -0
  49. package/dist/utils/steps.js +88 -0
  50. package/dist/utils/targets.js +31 -7
  51. package/dist/utils/timeline.js +85 -0
  52. package/dist/utils/toolsets.js +17 -6
  53. package/dist/utils/transcriptCut.js +134 -0
  54. package/dist/utils/wgc.js +2 -2
  55. package/dist/wgcRecorder.js +1 -1
  56. package/package.json +3 -1
package/dist/cli.js ADDED
@@ -0,0 +1,360 @@
1
+ import { spawn } from "node:child_process";
2
+ import { createRequire } from "node:module";
3
+ import { mkdirSync, readFileSync, rmSync, writeFileSync } from "node:fs";
4
+ import { join, resolve } from "node:path";
5
+ import { Client } from "@modelcontextprotocol/sdk/client/index.js";
6
+ import { InMemoryTransport } from "@modelcontextprotocol/sdk/inMemory.js";
7
+ import { createServer } from "./server.js";
8
+ const VERSION = createRequire(import.meta.url)("../package.json").version;
9
+ export class CliUsageError extends Error {
10
+ }
11
+ const SUBCOMMANDS = new Set(["record", "call", "help", "--help", "-h", "--version", "-v"]);
12
+ export function isCliInvocation(argv) {
13
+ return argv.length > 0 && SUBCOMMANDS.has(argv[0] ?? "");
14
+ }
15
+ export const USAGE = `screencast-mcp: an MCP server for Windows screen recording.
16
+
17
+ Usage:
18
+ screencast-mcp run the MCP server over stdio (default)
19
+ screencast-mcp record [options] -- <command...>
20
+ record the screen while <command> runs
21
+ screencast-mcp call <tool> [json|@file] call one tool and print its result
22
+ screencast-mcp --version | --help
23
+
24
+ record options:
25
+ --target <target> full | monitor:<i> | window:<title> | region:x,y,w,h (default full)
26
+ --fps <n> capture frame rate, 1-120 (default 15)
27
+ --out <dir> output folder (default screencast-evidence)
28
+ --artifacts <when> make the GIF and contact sheet on: failure | always | never (default failure)
29
+ --last <sec> the GIF covers the last <sec> seconds; 0 = all (default 30)
30
+ --no-gif skip the GIF
31
+ --no-contact-sheet skip the contact sheet
32
+ --discard-on-success delete the recording when the command exits 0
33
+ --max-duration <sec> stop recording after <sec> seconds (default SCREENCAST_MAX_RECORDING_SEC)
34
+
35
+ record exits with the command's exit code and writes <out>/evidence.json.
36
+ `;
37
+ function takeValue(argv, i, flag) {
38
+ const value = argv[i + 1];
39
+ if (value === undefined || value === "--")
40
+ throw new CliUsageError(`${flag} needs a value.`);
41
+ return value;
42
+ }
43
+ function number(value, flag, min, max = Infinity, integer = false) {
44
+ const n = Number(value);
45
+ if (!Number.isFinite(n) || n < min || n > max || (integer && !Number.isInteger(n))) {
46
+ const range = max === Infinity ? `>= ${min}` : `${min}-${max}`;
47
+ throw new CliUsageError(`${flag} must be ${integer ? "an integer" : "a number"} ${range}, got "${value}".`);
48
+ }
49
+ return n;
50
+ }
51
+ function parseRecord(argv) {
52
+ const dash = argv.indexOf("--");
53
+ if (dash === -1 || dash === argv.length - 1) {
54
+ throw new CliUsageError("record needs a command after --, e.g. screencast-mcp record -- npm test");
55
+ }
56
+ const options = {
57
+ target: "full",
58
+ fps: 15,
59
+ outDir: "screencast-evidence",
60
+ artifacts: "failure",
61
+ lastSec: 30,
62
+ gif: true,
63
+ contactSheet: true,
64
+ discardOnSuccess: false,
65
+ command: argv.slice(dash + 1),
66
+ };
67
+ const flags = argv.slice(0, dash);
68
+ for (let i = 0; i < flags.length; i++) {
69
+ const raw = flags[i] ?? "";
70
+ const eq = raw.startsWith("--") ? raw.indexOf("=") : -1;
71
+ const flag = eq === -1 ? raw : raw.slice(0, eq);
72
+ const inline = eq === -1 ? undefined : raw.slice(eq + 1);
73
+ const value = () => {
74
+ if (inline !== undefined)
75
+ return inline;
76
+ const v = takeValue(flags, i, flag);
77
+ i++;
78
+ return v;
79
+ };
80
+ switch (flag) {
81
+ case "--target":
82
+ options.target = value();
83
+ break;
84
+ case "--fps":
85
+ options.fps = number(value(), flag, 1, 120, true);
86
+ break;
87
+ case "--out":
88
+ options.outDir = value();
89
+ break;
90
+ case "--artifacts": {
91
+ const v = value();
92
+ if (v !== "failure" && v !== "always" && v !== "never") {
93
+ throw new CliUsageError(`--artifacts must be failure, always, or never, got "${v}".`);
94
+ }
95
+ options.artifacts = v;
96
+ break;
97
+ }
98
+ case "--last":
99
+ options.lastSec = number(value(), flag, 0);
100
+ break;
101
+ case "--max-duration":
102
+ options.maxDurationSec = number(value(), flag, 0);
103
+ break;
104
+ case "--no-gif":
105
+ options.gif = false;
106
+ break;
107
+ case "--no-contact-sheet":
108
+ options.contactSheet = false;
109
+ break;
110
+ case "--discard-on-success":
111
+ options.discardOnSuccess = true;
112
+ break;
113
+ default:
114
+ throw new CliUsageError(`Unknown record option "${raw}". Run screencast-mcp --help.`);
115
+ }
116
+ }
117
+ return options;
118
+ }
119
+ export function parseCliArgs(argv) {
120
+ const [sub, ...rest] = argv;
121
+ switch (sub) {
122
+ case "help":
123
+ case "--help":
124
+ case "-h":
125
+ return { kind: "help" };
126
+ case "--version":
127
+ case "-v":
128
+ return { kind: "version" };
129
+ case "record":
130
+ if (rest[0] === "--help" || rest[0] === "-h")
131
+ return { kind: "help" };
132
+ return { kind: "record", options: parseRecord(rest) };
133
+ case "call": {
134
+ const [tool, args, extra] = rest;
135
+ if (!tool || tool.startsWith("-"))
136
+ throw new CliUsageError("call needs a tool name, e.g. screencast-mcp call doctor");
137
+ if (extra !== undefined)
138
+ throw new CliUsageError("call takes one JSON argument; quote it as a single string.");
139
+ return { kind: "call", tool, args };
140
+ }
141
+ default:
142
+ throw new CliUsageError(`Unknown command "${sub ?? ""}". Run screencast-mcp --help.`);
143
+ }
144
+ }
145
+ export function commandLine(command) {
146
+ if (command.length === 1)
147
+ return command[0] ?? "";
148
+ return command.map((a) => (/[\s"&|<>^()!;'`$*?]/.test(a) || a === "" ? `"${a.replace(/"/g, '\\"')}"` : a)).join(" ");
149
+ }
150
+ export function tailWindow(durationSec, lastSec) {
151
+ if (!lastSec || durationSec === null || durationSec <= lastSec)
152
+ return {};
153
+ return { start: Math.round((durationSec - lastSec) * 1000) / 1000, duration: lastSec };
154
+ }
155
+ export function parseToolArgs(raw, readFile = (p) => readFileSync(p, "utf8")) {
156
+ if (raw === undefined || raw.trim() === "")
157
+ return {};
158
+ const text = raw.startsWith("@") ? readFile(raw.slice(1)) : raw;
159
+ let value;
160
+ try {
161
+ value = JSON.parse(text);
162
+ }
163
+ catch (err) {
164
+ throw new CliUsageError(`Tool arguments are not valid JSON: ${err instanceof Error ? err.message : String(err)}`);
165
+ }
166
+ if (typeof value !== "object" || value === null || Array.isArray(value)) {
167
+ throw new CliUsageError("Tool arguments must be a JSON object.");
168
+ }
169
+ return value;
170
+ }
171
+ async function connect() {
172
+ const [clientSide, serverSide] = InMemoryTransport.createLinkedPair();
173
+ await createServer({ toolsets: "all" }).connect(serverSide);
174
+ const client = new Client({ name: "screencast-mcp-cli", version: VERSION });
175
+ await client.connect(clientSide);
176
+ return client;
177
+ }
178
+ async function callTool(client, name, args) {
179
+ const res = await client.callTool({ name, arguments: args });
180
+ const text = res.content
181
+ .map((c) => (c.type === "text" ? (c.text ?? "") : `[${c.type} omitted]`))
182
+ .join("\n");
183
+ return {
184
+ isError: res.isError === true,
185
+ text,
186
+ structured: res.structuredContent,
187
+ };
188
+ }
189
+ async function mustCall(client, name, args) {
190
+ const res = await callTool(client, name, args);
191
+ if (res.isError)
192
+ throw new Error(`${name}: ${res.text}`);
193
+ return res.structured ?? {};
194
+ }
195
+ const defaultIo = {
196
+ out: (s) => process.stdout.write(s),
197
+ err: (s) => process.stderr.write(s),
198
+ };
199
+ function runCommand(command) {
200
+ return new Promise((resolveExit) => {
201
+ const child = spawn(commandLine(command), { shell: true, stdio: "inherit" });
202
+ const forward = (sig) => () => child.kill(sig);
203
+ const onInt = forward("SIGINT");
204
+ const onTerm = forward("SIGTERM");
205
+ process.on("SIGINT", onInt);
206
+ process.on("SIGTERM", onTerm);
207
+ const done = (code) => {
208
+ process.off("SIGINT", onInt);
209
+ process.off("SIGTERM", onTerm);
210
+ resolveExit(code);
211
+ };
212
+ child.on("error", (err) => {
213
+ process.stderr.write(`screencast-mcp: could not run the command: ${err.message}\n`);
214
+ done(127);
215
+ });
216
+ child.on("exit", (code, signal) => done(code ?? (signal ? 1 : 0)));
217
+ });
218
+ }
219
+ async function record(opts, io) {
220
+ const outDir = resolve(opts.outDir);
221
+ mkdirSync(outDir, { recursive: true });
222
+ const evidence = {
223
+ command: commandLine(opts.command),
224
+ exitCode: 0,
225
+ target: opts.target,
226
+ recording: null,
227
+ durationSec: null,
228
+ gif: null,
229
+ contactSheet: null,
230
+ warnings: [],
231
+ };
232
+ const warn = (msg) => {
233
+ evidence.warnings.push(msg);
234
+ io.err(`screencast-mcp: ${msg}\n`);
235
+ };
236
+ const client = await connect();
237
+ try {
238
+ let sessionId = null;
239
+ try {
240
+ const started = await mustCall(client, "start_recording", {
241
+ target: opts.target,
242
+ fps: opts.fps,
243
+ output: join(outDir, "recording.mp4"),
244
+ overwrite: true,
245
+ ...(opts.maxDurationSec !== undefined ? { maxDurationSec: opts.maxDurationSec } : {}),
246
+ });
247
+ sessionId = String(started.sessionId);
248
+ io.err(`screencast-mcp: recording ${opts.target} to ${String(started.outputPath)}\n`);
249
+ }
250
+ catch (err) {
251
+ warn(`recording did not start, running the command without it: ${err instanceof Error ? err.message : String(err)}`);
252
+ }
253
+ evidence.exitCode = await runCommand(opts.command);
254
+ if (sessionId) {
255
+ try {
256
+ const stopped = await mustCall(client, "stop_recording", { sessionId });
257
+ evidence.recording = String(stopped.outputPath);
258
+ evidence.durationSec = typeof stopped.durationSec === "number" ? stopped.durationSec : null;
259
+ }
260
+ catch (err) {
261
+ warn(`stop_recording failed: ${err instanceof Error ? err.message : String(err)}`);
262
+ }
263
+ }
264
+ const failed = evidence.exitCode !== 0;
265
+ const wanted = opts.artifacts === "always" || (opts.artifacts === "failure" && failed);
266
+ if (evidence.recording && wanted) {
267
+ const input = evidence.recording;
268
+ if (opts.gif) {
269
+ try {
270
+ const gif = await mustCall(client, "export_gif", {
271
+ input,
272
+ ...tailWindow(evidence.durationSec, opts.lastSec),
273
+ output: join(outDir, "evidence.gif"),
274
+ overwrite: true,
275
+ });
276
+ evidence.gif = String(gif.outputPath);
277
+ }
278
+ catch (err) {
279
+ warn(`export_gif failed: ${err instanceof Error ? err.message : String(err)}`);
280
+ }
281
+ }
282
+ if (opts.contactSheet) {
283
+ try {
284
+ const sheet = await mustCall(client, "contact_sheet", {
285
+ input,
286
+ output: join(outDir, "contact-sheet.png"),
287
+ overwrite: true,
288
+ returnImage: false,
289
+ });
290
+ evidence.contactSheet = String(sheet.outputPath);
291
+ }
292
+ catch (err) {
293
+ warn(`contact_sheet failed: ${err instanceof Error ? err.message : String(err)}`);
294
+ }
295
+ }
296
+ }
297
+ if (!failed && opts.discardOnSuccess && evidence.recording) {
298
+ rmSync(evidence.recording, { force: true });
299
+ evidence.recording = null;
300
+ }
301
+ }
302
+ finally {
303
+ await client.close();
304
+ }
305
+ writeFileSync(join(outDir, "evidence.json"), JSON.stringify(evidence, null, 2) + "\n");
306
+ io.err(`screencast-mcp: command exited ${evidence.exitCode}; evidence in ${outDir}` +
307
+ (evidence.gif ? ` (gif: ${evidence.gif})` : "") +
308
+ "\n");
309
+ return evidence.exitCode;
310
+ }
311
+ async function call(tool, rawArgs, io) {
312
+ const args = parseToolArgs(rawArgs);
313
+ const client = await connect();
314
+ try {
315
+ const res = await callTool(client, tool, args);
316
+ if (res.isError) {
317
+ io.err(`${res.text}\n`);
318
+ return 1;
319
+ }
320
+ io.out((res.structured ? JSON.stringify(res.structured, null, 2) : res.text) + "\n");
321
+ return 0;
322
+ }
323
+ finally {
324
+ await client.close();
325
+ }
326
+ }
327
+ export async function runCli(argv, io = defaultIo) {
328
+ let command;
329
+ try {
330
+ command = parseCliArgs(argv);
331
+ }
332
+ catch (err) {
333
+ if (err instanceof CliUsageError) {
334
+ io.err(`screencast-mcp: ${err.message}\n`);
335
+ return 2;
336
+ }
337
+ throw err;
338
+ }
339
+ switch (command.kind) {
340
+ case "help":
341
+ io.out(USAGE);
342
+ return 0;
343
+ case "version":
344
+ io.out(`${VERSION}\n`);
345
+ return 0;
346
+ case "record":
347
+ return record(command.options, io);
348
+ case "call":
349
+ try {
350
+ return await call(command.tool, command.args, io);
351
+ }
352
+ catch (err) {
353
+ if (err instanceof CliUsageError) {
354
+ io.err(`screencast-mcp: ${err.message}\n`);
355
+ return 2;
356
+ }
357
+ throw err;
358
+ }
359
+ }
360
+ }
package/dist/index.js CHANGED
@@ -1,5 +1,6 @@
1
1
  #!/usr/bin/env node
2
2
  import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
3
+ import { isCliInvocation, runCli } from "./cli.js";
3
4
  import { getStore, isShuttingDown, markShuttingDown } from "./context.js";
4
5
  import { requireFfmpeg } from "./utils/ffmpeg.js";
5
6
  import { abortEditJobs } from "./utils/jobs.js";
@@ -83,7 +84,14 @@ async function shutdown(reason, exitCode = 0) {
83
84
  process.stderr.write(`Shutdown (${reason}): cancelled ${cancelled} edit job(s).\n`);
84
85
  process.exit(exitCode);
85
86
  }
86
- main().catch((error) => {
87
+ const fatal = (error) => {
87
88
  process.stderr.write(`Fatal error: ${error instanceof Error ? error.message : String(error)}\n`);
88
89
  process.exit(1);
89
- });
90
+ };
91
+ const argv = process.argv.slice(2);
92
+ if (isCliInvocation(argv)) {
93
+ runCli(argv).then((code) => process.exit(code), fatal);
94
+ }
95
+ else {
96
+ main().catch(fatal);
97
+ }
package/dist/prompts.js CHANGED
@@ -19,10 +19,9 @@ Report the final file path, what the clip shows, and anything you redacted. (To
19
19
  Report the folder path, the steps, the error text found, and what was redacted.`,
20
20
  demoGif: (target, maxMB) => `Make a demo GIF of ${target} for a README or PR, under ${maxMB} MB.
21
21
 
22
- 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.
23
23
  2. contact_sheet { input: <recording>, mode: "scenes" } to see the whole run at a glance and pick the best stretch.
24
- 3. trim to that stretch (skip any audio steps: a GIF has no sound).
25
- 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.
26
25
  Report the file path, its size, and the settings export_gif chose.`,
27
26
  verifyUiChange: (target, expectation) => `Verify a UI change in ${target}. Expected: ${expectation || "(describe what should change)"}.
28
27
 
@@ -39,6 +38,12 @@ Say whether the change happened, whether anything changed that should not have,
39
38
  3. sample_frames { input: "${path}", mode: "scenes" } to look closely at each change.
40
39
  4. If there is on-screen text worth quoting, find_text on the relevant frame.
41
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.`,
42
47
  };
43
48
  export function registerPrompts(server) {
44
49
  server.registerPrompt("bug-repro-clip", {
@@ -79,4 +84,12 @@ export function registerPrompts(server) {
79
84
  description: "Summarize what happens in a recording, with timestamps, using a contact sheet and scene frames.",
80
85
  argsSchema: { path: z.string().describe("Path to the recording.") },
81
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 ?? "")));
82
95
  }
package/dist/server.js CHANGED
@@ -4,6 +4,9 @@ import { parseToolsets, serverInstructions, SELECTABLE_TOOLSETS, toolsetOf, } fr
4
4
  import { register as registerStartRecording } from "./tools/startRecording.js";
5
5
  import { register as registerStopRecording } from "./tools/stopRecording.js";
6
6
  import { register as registerSaveReplay } from "./tools/saveReplay.js";
7
+ import { register as registerPauseRecording } from "./tools/pauseRecording.js";
8
+ import { register as registerResumeRecording } from "./tools/resumeRecording.js";
9
+ import { register as registerListVideoDevices } from "./tools/listVideoDevices.js";
7
10
  import { register as registerListSessions } from "./tools/listSessions.js";
8
11
  import { register as registerGetSession } from "./tools/getSession.js";
9
12
  import { register as registerReadEvents } from "./tools/readEvents.js";
@@ -16,6 +19,8 @@ import { register as registerContactSheet } from "./tools/contactSheet.js";
16
19
  import { register as registerScreenDiff } from "./tools/screenDiff.js";
17
20
  import { register as registerWaitForChange } from "./tools/waitForChange.js";
18
21
  import { register as registerFindText } from "./tools/findText.js";
22
+ import { register as registerIndexRecording } from "./tools/indexRecording.js";
23
+ import { register as registerSearchRecording } from "./tools/searchRecording.js";
19
24
  import { register as registerGetMediaInfo } from "./tools/getMediaInfo.js";
20
25
  import { register as registerTrim } from "./tools/trim.js";
21
26
  import { register as registerConcat } from "./tools/concat.js";
@@ -27,6 +32,7 @@ import { register as registerSpeed } from "./tools/speed.js";
27
32
  import { register as registerOverlay } from "./tools/overlay.js";
28
33
  import { register as registerCallout } from "./tools/callout.js";
29
34
  import { register as registerKeystrokeOverlay } from "./tools/keystrokeOverlay.js";
35
+ import { register as registerCursor } from "./tools/cursor.js";
30
36
  import { register as registerBackdrop } from "./tools/backdrop.js";
31
37
  import { register as registerCompress } from "./tools/compress.js";
32
38
  import { register as registerExtractAudio } from "./tools/extractAudio.js";
@@ -36,6 +42,7 @@ import { register as registerTranscribe } from "./tools/transcribe.js";
36
42
  import { register as registerBurnSubtitles } from "./tools/burnSubtitles.js";
37
43
  import { register as registerClip } from "./tools/clip.js";
38
44
  import { register as registerCutIdle } from "./tools/cutIdle.js";
45
+ import { register as registerCutByTranscript } from "./tools/cutByTranscript.js";
39
46
  import { register as registerRedactRegion } from "./tools/redactRegion.js";
40
47
  import { register as registerListAudioDevices } from "./tools/listAudioDevices.js";
41
48
  import { register as registerListTargets } from "./tools/listTargets.js";
@@ -44,11 +51,13 @@ import { register as registerXfadeTransition } from "./tools/xfadeTransition.js"
44
51
  import { register as registerAssembleHighlights } from "./tools/assembleHighlights.js";
45
52
  import { register as registerTitleCard } from "./tools/titleCard.js";
46
53
  import { register as registerMusicBed } from "./tools/musicBed.js";
54
+ import { register as registerNarrate } from "./tools/narrate.js";
47
55
  import { register as registerReframe } from "./tools/reframe.js";
48
56
  import { register as registerZoom } from "./tools/zoom.js";
49
57
  import { register as registerPipeline } from "./tools/pipeline.js";
50
58
  import { register as registerExportPreset } from "./tools/exportPreset.js";
51
59
  import { register as registerBugReport } from "./tools/bugReport.js";
60
+ import { register as registerStepGuide } from "./tools/stepGuide.js";
52
61
  import { registerResources } from "./resources.js";
53
62
  import { registerPrompts } from "./prompts.js";
54
63
  import { attachLogging } from "./utils/logging.js";
@@ -68,6 +77,8 @@ export function createServer(options = {}) {
68
77
  const tools = captureRegisteredTools(server);
69
78
  registerStartRecording(server);
70
79
  registerStopRecording(server);
80
+ registerPauseRecording(server);
81
+ registerResumeRecording(server);
71
82
  registerSaveReplay(server);
72
83
  registerListSessions(server);
73
84
  registerGetSession(server);
@@ -80,6 +91,8 @@ export function createServer(options = {}) {
80
91
  registerScreenDiff(server);
81
92
  registerWaitForChange(server);
82
93
  registerFindText(server);
94
+ registerIndexRecording(server);
95
+ registerSearchRecording(server);
83
96
  registerGetMediaInfo(server);
84
97
  registerTrim(server);
85
98
  registerConcat(server);
@@ -91,6 +104,7 @@ export function createServer(options = {}) {
91
104
  registerOverlay(server);
92
105
  registerCallout(server);
93
106
  registerKeystrokeOverlay(server);
107
+ registerCursor(server);
94
108
  registerBackdrop(server);
95
109
  registerCompress(server);
96
110
  registerExtractAudio(server);
@@ -101,19 +115,23 @@ export function createServer(options = {}) {
101
115
  registerChapters(server);
102
116
  registerClip(server);
103
117
  registerCutIdle(server);
118
+ registerCutByTranscript(server);
104
119
  registerRedactRegion(server);
105
120
  registerListAudioDevices(server);
121
+ registerListVideoDevices(server);
106
122
  registerListTargets(server);
107
123
  registerDoctor(server);
108
124
  registerXfadeTransition(server);
109
125
  registerAssembleHighlights(server);
110
126
  registerTitleCard(server);
111
127
  registerMusicBed(server);
128
+ registerNarrate(server);
112
129
  registerReframe(server);
113
130
  registerZoom(server);
114
131
  registerPipeline(server);
115
132
  registerExportPreset(server);
116
133
  registerBugReport(server);
134
+ registerStepGuide(server);
117
135
  applyToolsets(tools, selection);
118
136
  registerResources(server);
119
137
  registerPrompts(server);
@@ -5,6 +5,7 @@ import { looseOutput } from "../utils/toolSpec.js";
5
5
  import { assertOutputAllowed } from "../utils/paths.js";
6
6
  import { cleanLabel, insertMarker, markerTimeSec, markersPath, readMarkers, writeMarkers, MAX_LABEL, } from "../utils/chapters.js";
7
7
  import { getStore } from "../context.js";
8
+ import { recordedSec } from "../utils/pause.js";
8
9
  const ADDS_MARKER = {
9
10
  readOnlyHint: false,
10
11
  destructiveHint: false,
@@ -39,7 +40,10 @@ export function register(server) {
39
40
  if (!record)
40
41
  throw new ScreencastError(`No session with id "${args.sessionId}".`);
41
42
  let t = args.at;
42
- if (t === undefined) {
43
+ if (t === undefined && record.status === "paused") {
44
+ t = recordedSec(record.segments?.parts ?? []);
45
+ }
46
+ else if (t === undefined) {
43
47
  if (record.status !== "recording") {
44
48
  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
49
  }
@@ -64,7 +68,7 @@ export function register(server) {
64
68
  marker: { t: Math.round(t * 1000) / 1000, label: cleanLabel(args.label) },
65
69
  count: markers.length,
66
70
  markersPath: sidecar,
67
- ...(record.status === "recording" ? { live: true } : {}),
71
+ ...(record.status === "recording" || record.status === "paused" ? { live: true } : {}),
68
72
  ...(warning ? { warning } : {}),
69
73
  });
70
74
  }
@@ -44,12 +44,12 @@ const inputSchema = {
44
44
  overwrite: z.boolean().optional().describe("Replace a report already in outputDir."),
45
45
  };
46
46
  const r3 = (n) => Math.round(n * 1000) / 1000;
47
- async function resolveSource(args) {
47
+ export async function resolveSource(args) {
48
48
  if (args.sessionId !== undefined) {
49
49
  const record = getStore().get(args.sessionId);
50
50
  if (!record)
51
51
  throw new ScreencastError(`No session with id "${args.sessionId}".`);
52
- if (record.status === "recording") {
52
+ if (record.status === "recording" || record.status === "paused") {
53
53
  throw new ScreencastError("The recording is still running; stop_recording it first.");
54
54
  }
55
55
  await whenFinalized(record.id);
@@ -58,7 +58,7 @@ export function register(server) {
58
58
  const record = getStore().get(args.sessionId);
59
59
  if (!record)
60
60
  throw new ScreencastError(`No session with id "${args.sessionId}".`);
61
- if (record.status === "recording")
61
+ if (record.status === "recording" || record.status === "paused")
62
62
  throw new ScreencastError("The recording is still running; stop it first.");
63
63
  input ??= record.outputPath;
64
64
  sessionMarkers = record.markers;
@@ -0,0 +1,87 @@
1
+ import { z } from "zod";
2
+ import { join } from "node:path";
3
+ import { existsSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from "node:fs";
4
+ import { tmpdir } from "node:os";
5
+ import { errorResponse, okResponse, ScreencastError } from "../utils/errors.js";
6
+ import { WRITES_FILE, looseOutput } from "../utils/toolSpec.js";
7
+ import { requireFfmpeg, probeMedia } from "../utils/ffmpeg.js";
8
+ import { runEditJob } from "../utils/jobs.js";
9
+ import { eventPaths, parseEventsJsonl } from "../utils/events.js";
10
+ import { buildCursorArgs, cursorSpritePath, planCursor, transformCursor, DEFAULT_CURSOR_SIZE, DEFAULT_HIDE_AFTER_SEC, } from "../utils/cursor.js";
11
+ import { editOutputExt, assertEditContainer } from "../utils/media.js";
12
+ import { resolveOutput, subdir, stamp, rand } from "../utils/paths.js";
13
+ export const cursorOptionsSchema = {
14
+ events: z.string().optional(),
15
+ size: z.number().min(0.25).max(8).optional(),
16
+ smoothing: z.number().min(0).max(1).optional(),
17
+ hideAfterSec: z.number().min(0).max(600).optional(),
18
+ clicks: z.boolean().optional(),
19
+ spotlight: z.boolean().optional(),
20
+ };
21
+ const o = cursorOptionsSchema;
22
+ export function loadCursor(input, events, opts, endSec) {
23
+ const path = events ?? eventPaths(input).jsonl;
24
+ if (!existsSync(path)) {
25
+ throw new ScreencastError(`No event log for ${input} (looked for ${path}). Record with start_recording cursor: "events" ` +
26
+ "(no OS cursor in the video, events logged), or pass events: <path to .events.jsonl>.");
27
+ }
28
+ const plan = planCursor(parseEventsJsonl(readFileSync(path, "utf8")), opts, endSec);
29
+ if (plan.path.length === 0)
30
+ throw new ScreencastError(`The event log ${path} has no cursor positions to draw.`);
31
+ return plan;
32
+ }
33
+ const inputSchema = {
34
+ input: z.string().min(1).describe("Path to the recording."),
35
+ events: o.events.describe("Event log (default: the input's .events.jsonl)."),
36
+ size: o.size.describe(`Times a typical cursor's size (default ${DEFAULT_CURSOR_SIZE}).`),
37
+ smoothing: o.smoothing.describe("0 = as logged, 1 = floaty (default 0.5)."),
38
+ hideAfterSec: o.hideAfterSec.describe(`Hide when the mouse rests this long; 0 = never (default ${DEFAULT_HIDE_AFTER_SEC}).`),
39
+ clicks: o.clicks.describe("Ripple on clicks (default true)."),
40
+ spotlight: o.spotlight.describe("Dim all but the area around the cursor."),
41
+ dryRun: z.boolean().optional().describe("Return the plan; write nothing."),
42
+ output: z.string().optional().describe("Optional output path. Defaults under SCREENCAST_HOME/edits."),
43
+ overwrite: z.boolean().optional().describe("Allow replacing an existing file at the output path (default false)."),
44
+ };
45
+ export function register(server) {
46
+ server.registerTool("cursor", {
47
+ title: "Re-rendered Cursor",
48
+ description: 'Draw a smoothed, scaled cursor that hides when idle from the event log of a start_recording cursor: "events" ' +
49
+ "recording (no OS cursor in the video), with click ripples and an optional spotlight.",
50
+ inputSchema,
51
+ outputSchema: looseOutput({ segments: z.number().int() }),
52
+ annotations: WRITES_FILE,
53
+ }, async (args, extra) => {
54
+ try {
55
+ requireFfmpeg();
56
+ if (!existsSync(args.input))
57
+ throw new ScreencastError(`Input file not found: ${args.input}`);
58
+ const info = await probeMedia(args.input);
59
+ if (!info.width || !info.height)
60
+ throw new ScreencastError(`Could not read the size of ${args.input}.`);
61
+ const plan = transformCursor(loadCursor(args.input, args.events, args, info.durationSec));
62
+ const summary = {
63
+ segments: plan.path.length,
64
+ clicks: plan.clicks.length,
65
+ shownSec: Math.round(plan.visible.reduce((s, [a, b]) => s + (Math.min(b, info.durationSec ?? b) - a), 0) * 10) / 10,
66
+ };
67
+ if (args.dryRun)
68
+ return okResponse({ dryRun: true, ...summary, visible: plan.visible });
69
+ assertEditContainer(args.output);
70
+ const output = resolveOutput(args.output, subdir("edits"), `cursor-${stamp()}-${rand()}${editOutputExt(args.input)}`, args.overwrite);
71
+ const work = mkdtempSync(join(tmpdir(), "screencast-cursor-"));
72
+ try {
73
+ const cmdFile = join(work, "cursor.cmd");
74
+ const { args: ffArgs, commands } = buildCursorArgs(args.input, output, plan, { size: args.size, clicks: args.clicks, spotlight: args.spotlight }, { width: info.width, height: info.height }, cursorSpritePath(), cmdFile);
75
+ writeFileSync(cmdFile, commands);
76
+ await runEditJob(ffArgs, { output, durationSec: info.durationSec, extra });
77
+ return okResponse({ outputPath: output, ...summary });
78
+ }
79
+ finally {
80
+ rmSync(work, { recursive: true, force: true });
81
+ }
82
+ }
83
+ catch (error) {
84
+ return errorResponse(error);
85
+ }
86
+ });
87
+ }