@tmhs/screencast-mcp 0.46.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.
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/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";
@@ -29,6 +32,7 @@ import { register as registerSpeed } from "./tools/speed.js";
29
32
  import { register as registerOverlay } from "./tools/overlay.js";
30
33
  import { register as registerCallout } from "./tools/callout.js";
31
34
  import { register as registerKeystrokeOverlay } from "./tools/keystrokeOverlay.js";
35
+ import { register as registerCursor } from "./tools/cursor.js";
32
36
  import { register as registerBackdrop } from "./tools/backdrop.js";
33
37
  import { register as registerCompress } from "./tools/compress.js";
34
38
  import { register as registerExtractAudio } from "./tools/extractAudio.js";
@@ -47,6 +51,7 @@ import { register as registerXfadeTransition } from "./tools/xfadeTransition.js"
47
51
  import { register as registerAssembleHighlights } from "./tools/assembleHighlights.js";
48
52
  import { register as registerTitleCard } from "./tools/titleCard.js";
49
53
  import { register as registerMusicBed } from "./tools/musicBed.js";
54
+ import { register as registerNarrate } from "./tools/narrate.js";
50
55
  import { register as registerReframe } from "./tools/reframe.js";
51
56
  import { register as registerZoom } from "./tools/zoom.js";
52
57
  import { register as registerPipeline } from "./tools/pipeline.js";
@@ -72,6 +77,8 @@ export function createServer(options = {}) {
72
77
  const tools = captureRegisteredTools(server);
73
78
  registerStartRecording(server);
74
79
  registerStopRecording(server);
80
+ registerPauseRecording(server);
81
+ registerResumeRecording(server);
75
82
  registerSaveReplay(server);
76
83
  registerListSessions(server);
77
84
  registerGetSession(server);
@@ -97,6 +104,7 @@ export function createServer(options = {}) {
97
104
  registerOverlay(server);
98
105
  registerCallout(server);
99
106
  registerKeystrokeOverlay(server);
107
+ registerCursor(server);
100
108
  registerBackdrop(server);
101
109
  registerCompress(server);
102
110
  registerExtractAudio(server);
@@ -110,12 +118,14 @@ export function createServer(options = {}) {
110
118
  registerCutByTranscript(server);
111
119
  registerRedactRegion(server);
112
120
  registerListAudioDevices(server);
121
+ registerListVideoDevices(server);
113
122
  registerListTargets(server);
114
123
  registerDoctor(server);
115
124
  registerXfadeTransition(server);
116
125
  registerAssembleHighlights(server);
117
126
  registerTitleCard(server);
118
127
  registerMusicBed(server);
128
+ registerNarrate(server);
119
129
  registerReframe(server);
120
130
  registerZoom(server);
121
131
  registerPipeline(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
  }
@@ -49,7 +49,7 @@ export async function resolveSource(args) {
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
+ }
@@ -8,6 +8,8 @@ import { detectFfmpeg, hasFilter, wgcAvailable } from "../utils/ffmpeg.js";
8
8
  import { allowedOutputDirs, envAllowedDirs, homeRoot } from "../utils/paths.js";
9
9
  import { FFMPEG_FEATURE_MAJOR, KEY_FILTERS, devicesText, envSettings, locate, ocrStatus, parseDevices, parseFfmpegVersion, versionText, } from "../utils/capabilities.js";
10
10
  import { parseToolsets, SELECTABLE_TOOLSETS } from "../utils/toolsets.js";
11
+ import { ttsStatus } from "../utils/narrate.js";
12
+ import { probeHwEncoders } from "../utils/gpu.js";
11
13
  const { version: serverVersion } = createRequire(import.meta.url)("../../package.json");
12
14
  const binary = z.looseObject({
13
15
  found: z.boolean(),
@@ -87,10 +89,19 @@ export function register(server) {
87
89
  if (process.platform !== "win32") {
88
90
  problems.push("Not Windows: capture (screenshot, start_recording, list_targets) and OCR are unavailable; the watch and edit tools work.");
89
91
  }
90
- const ocr = await ocrStatus();
92
+ const gpu = tools
93
+ ? {
94
+ ddagrab: process.platform === "win32" && hasFilter("ddagrab"),
95
+ encoders: await probeHwEncoders(tools.ffmpeg),
96
+ }
97
+ : null;
98
+ const [ocr, tts] = await Promise.all([ocrStatus(), ttsStatus()]);
91
99
  if (process.platform === "win32" && !ocr.available) {
92
100
  problems.push(`Windows OCR unavailable: find_text cannot read the screen. ${ocr.error ?? "Install an OCR language (Settings > Time & language > Language)."}`);
93
101
  }
102
+ if (process.platform === "win32" && !tts.available) {
103
+ problems.push(`Windows speech unavailable: narrate cannot speak. ${tts.error ?? ""} Install a voice (Settings > Time & language > Speech).`.replace(/\s+/g, " "));
104
+ }
94
105
  const env = envSettings();
95
106
  const model = env.SCREENCAST_WHISPER_MODEL;
96
107
  if (model && !existsSync(model))
@@ -113,7 +124,9 @@ export function register(server) {
113
124
  filters,
114
125
  devices,
115
126
  wgc: { available: filters.gfxcapture === true },
127
+ ...(gpu ? { gpu } : {}),
116
128
  ocr,
129
+ tts,
117
130
  storage: {
118
131
  home,
119
132
  homeExists: existsSync(home),
@@ -0,0 +1,26 @@
1
+ import { z } from "zod";
2
+ import { errorResponse, okResponse } from "../utils/errors.js";
3
+ import { READ_ONLY, looseOutput } from "../utils/toolSpec.js";
4
+ import { requireFfmpeg } from "../utils/ffmpeg.js";
5
+ import { listDshowVideoDevices } from "../utils/audioDevices.js";
6
+ export function register(server) {
7
+ server.registerTool("list_video_devices", {
8
+ title: "List Video Devices",
9
+ description: "List DirectShow cameras for start_recording's webcam.device.",
10
+ inputSchema: {},
11
+ outputSchema: looseOutput({ devices: z.array(z.string()) }),
12
+ annotations: READ_ONLY,
13
+ }, async () => {
14
+ try {
15
+ requireFfmpeg();
16
+ const devices = await listDshowVideoDevices(true);
17
+ return okResponse({
18
+ devices,
19
+ note: devices.length ? `start_recording { webcam: { device: "${devices[0]}" } } records it.` : "No camera found.",
20
+ });
21
+ }
22
+ catch (error) {
23
+ return errorResponse(error);
24
+ }
25
+ });
26
+ }