@tmhs/screencast-mcp 0.48.0 → 0.48.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -2
- package/dist/cli.js +8 -7
- package/dist/context.js +33 -0
- package/dist/index.js +42 -27
- package/dist/setup.js +7 -6
- package/dist/tools/addMarker.js +2 -2
- package/dist/tools/assembleHighlights.js +2 -0
- package/dist/tools/exportPreset.js +2 -0
- package/dist/tools/pauseRecording.js +3 -3
- package/dist/tools/pipeline.js +3 -0
- package/dist/tools/sampleFrames.js +4 -4
- package/dist/tools/startRecording.js +11 -5
- package/dist/tools/stopRecording.js +7 -3
- package/dist/tools/titleCard.js +2 -0
- package/dist/tools/xfadeTransition.js +2 -0
- package/dist/utils/audioDevices.js +2 -6
- package/dist/utils/capabilities.js +2 -1
- package/dist/utils/consent.js +2 -2
- package/dist/utils/errors.js +4 -4
- package/dist/utils/ffmpeg.js +14 -1
- package/dist/utils/jobs.js +2 -9
- package/dist/utils/lifecycle.js +13 -31
- package/dist/utils/media.js +12 -5
- package/dist/utils/monitors.js +2 -2
- package/dist/utils/narrate.js +3 -3
- package/dist/utils/ocr.js +3 -3
- package/dist/utils/pause.js +3 -3
- package/dist/utils/recorder.js +7 -6
- package/dist/utils/replay.js +5 -11
- package/dist/utils/retention.js +14 -14
- package/dist/utils/roots.js +2 -1
- package/dist/utils/sessions.js +32 -16
- package/dist/utils/sheet.js +4 -4
- package/dist/utils/targetList.js +2 -1
- package/dist/utils/wgc.js +27 -0
- package/dist/utils/windows.js +2 -2
- package/dist/wgcRecorder.js +7 -10
- package/package.json +6 -6
package/README.md
CHANGED
|
@@ -42,6 +42,8 @@ The fastest path: `npx -y @tmhs/screencast-mcp setup` checks FFmpeg 8, OCR, and
|
|
|
42
42
|
|
|
43
43
|
**You need** Windows 10 or 11, [Node.js](https://nodejs.org) 22+, and **FFmpeg 8 or newer** on `PATH` (`winget install Gyan.FFmpeg`, the full build). Older builds run most tools, but `transcribe` (the `whisper` filter) and `backend: "wgc"` (`gfxcapture`) need FFmpeg 8, and essentials or distro builds can lack them (Ubuntu LTS `apt install ffmpeg` gives 6.x). Capture is Windows-only; the watch, edit, and produce tools work anywhere ffmpeg runs. After connecting, ask the agent to run `doctor`: it reports the ffmpeg version, the filters and devices it has, OCR, and anything missing.
|
|
44
44
|
|
|
45
|
+
**Windows on ARM64** is in progress (#246): CI runs a non-blocking `windows-11-arm` job. gyan.dev ships no arm64 FFmpeg, so use BtbN's `winarm64-gpl` FFmpeg 8 build; it has `gdigrab`, `gfxcapture` and `drawtext` but no `whisper` or libvpx, so `transcribe` and `.webm` output need another build. `doctor` reports `arch` and what is missing.
|
|
46
|
+
|
|
45
47
|
**Add it to your client:**
|
|
46
48
|
|
|
47
49
|
| Client | How |
|
|
@@ -192,7 +194,7 @@ Every capture tool takes one `target` string: `full`, `monitor:<index>`, `window
|
|
|
192
194
|
| `SCREENCAST_MAX_RECORDING_SEC` | `3600` | Default recording cap (`0` disables it) |
|
|
193
195
|
| `SCREENCAST_JOB_TIMEOUT_MS` | scales with length | Override the edit job timeout |
|
|
194
196
|
| `SCREENCAST_WHISPER_MODEL` | none | whisper.cpp model for `transcribe` |
|
|
195
|
-
| `SCREENCAST_RETENTION_DAYS` | off | Delete screenshots, frames,
|
|
197
|
+
| `SCREENCAST_RETENTION_DAYS` | off | Delete screenshots, frames, leftover raw event logs, and `index_recording` indexes older than this many days at startup (never recordings or edits; an index is rebuilt by running `index_recording` again) |
|
|
196
198
|
| `SCREENCAST_PS_TIMEOUT_MS` | 20000 (OCR 60000) | Limit for the PowerShell helpers that list monitors and windows and run OCR |
|
|
197
199
|
| `SCREENCAST_CONFIRM_CAPTURE` | off | Set to `1` to ask the user to confirm every live capture through MCP elicitation; clients without elicitation are refused |
|
|
198
200
|
| `SCREENCAST_TOOLSETS` | `all` | Comma-separated toolsets to expose; the rest are not loaded, which shrinks the tool list the agent pays for on every turn (`core` is always on) |
|
|
@@ -226,7 +228,7 @@ Every capture tool takes one `target` string: `full`, `monitor:<index>`, `window
|
|
|
226
228
|
|
|
227
229
|
- **No network requests, no telemetry.** The server runs ffmpeg, ffprobe, and PowerShell locally and talks to your client over stdio. OCR (`find_text`) and speech (`narrate`) use the engines built into Windows.
|
|
228
230
|
- **What a tool returns goes to your model provider.** Inline frames, OCR text, and event summaries reach your agent like any tool result; files on disk stay on disk unless a tool returns them or you share them.
|
|
229
|
-
- **Everything is stored under `SCREENCAST_HOME`** (`recordings/`, `screenshots/`, `frames/`, `edits/`, `sessions.json`) unless a call names another path. `find_text
|
|
231
|
+
- **Everything is stored under `SCREENCAST_HOME`** (`recordings/`, `screenshots/`, `frames/`, `edits/`, `sessions.json`) unless a call names another path. `find_text` and `wait_for_change` delete their captures after the call by default (`keep: true` keeps them); `screen_diff` compares existing images and captures nothing.
|
|
230
232
|
- **The event log never records typed text.** Only with `start_recording` `events: true` (or `cursor: "events"`), and only while that recording runs: clicks, scrolls, and cursor positions system-wide, and typing as bursts on a 0.5 s grid with no key names (`keys: "shortcuts"` also names Ctrl/Alt/Win chords). There is no microphone capture; system audio only with `audio.source` = `system`.
|
|
231
233
|
- **Deleting data.** Delete files under `SCREENCAST_HOME`, or set `SCREENCAST_RETENTION_DAYS`; recordings and edits are never deleted automatically.
|
|
232
234
|
|
package/dist/cli.js
CHANGED
|
@@ -8,6 +8,7 @@ import { createServer } from "./server.js";
|
|
|
8
8
|
import { MAX_RECORDING_CAP_SEC } from "./utils/targets.js";
|
|
9
9
|
import { DEFAULT_ERROR_PATTERN, DEFAULT_SECRET_PATTERN, MAX_ERROR_LINES, maskSecrets } from "./utils/bugReport.js";
|
|
10
10
|
import { defaultSetupDeps, parseSetupArgs, runSetup, SETUP_USAGE } from "./setup.js";
|
|
11
|
+
import { errorMessage } from "./utils/errors.js";
|
|
11
12
|
const VERSION = createRequire(import.meta.url)("../package.json").version;
|
|
12
13
|
export class CliUsageError extends Error {
|
|
13
14
|
}
|
|
@@ -174,7 +175,7 @@ export function parseCliArgs(argv, env = process.env) {
|
|
|
174
175
|
return { kind: "setup", options: parseSetupArgs(rest) };
|
|
175
176
|
}
|
|
176
177
|
catch (err) {
|
|
177
|
-
throw new CliUsageError(
|
|
178
|
+
throw new CliUsageError(errorMessage(err));
|
|
178
179
|
}
|
|
179
180
|
}
|
|
180
181
|
default:
|
|
@@ -241,7 +242,7 @@ export function parseToolArgs(raw, readFile = (p) => readFileSync(p, "utf8")) {
|
|
|
241
242
|
value = JSON.parse(text);
|
|
242
243
|
}
|
|
243
244
|
catch (err) {
|
|
244
|
-
throw new CliUsageError(`Tool arguments are not valid JSON: ${
|
|
245
|
+
throw new CliUsageError(`Tool arguments are not valid JSON: ${errorMessage(err)}`);
|
|
245
246
|
}
|
|
246
247
|
if (typeof value !== "object" || value === null || Array.isArray(value)) {
|
|
247
248
|
throw new CliUsageError("Tool arguments must be a JSON object.");
|
|
@@ -354,7 +355,7 @@ export async function runRecord(opts, io = defaultIo, deps = defaultRecordDeps)
|
|
|
354
355
|
io.err(`screencast-mcp: recording ${opts.target} to ${String(started.outputPath)}\n`);
|
|
355
356
|
}
|
|
356
357
|
catch (err) {
|
|
357
|
-
warn(`recording did not start, running the command without it: ${
|
|
358
|
+
warn(`recording did not start, running the command without it: ${errorMessage(err)}`);
|
|
358
359
|
}
|
|
359
360
|
const began = deps.now();
|
|
360
361
|
evidence.exitCode = await deps.run(opts.command);
|
|
@@ -372,7 +373,7 @@ export async function runRecord(opts, io = defaultIo, deps = defaultRecordDeps)
|
|
|
372
373
|
warn(early);
|
|
373
374
|
}
|
|
374
375
|
catch (err) {
|
|
375
|
-
warn(`stop_recording failed: ${
|
|
376
|
+
warn(`stop_recording failed: ${errorMessage(err)}`);
|
|
376
377
|
}
|
|
377
378
|
}
|
|
378
379
|
const failed = evidence.exitCode !== 0;
|
|
@@ -390,7 +391,7 @@ export async function runRecord(opts, io = defaultIo, deps = defaultRecordDeps)
|
|
|
390
391
|
evidence.gif = String(gif.outputPath);
|
|
391
392
|
}
|
|
392
393
|
catch (err) {
|
|
393
|
-
warn(`export_gif failed: ${
|
|
394
|
+
warn(`export_gif failed: ${errorMessage(err)}`);
|
|
394
395
|
}
|
|
395
396
|
}
|
|
396
397
|
if (opts.contactSheet) {
|
|
@@ -404,7 +405,7 @@ export async function runRecord(opts, io = defaultIo, deps = defaultRecordDeps)
|
|
|
404
405
|
evidence.contactSheet = String(sheet.outputPath);
|
|
405
406
|
}
|
|
406
407
|
catch (err) {
|
|
407
|
-
warn(`contact_sheet failed: ${
|
|
408
|
+
warn(`contact_sheet failed: ${errorMessage(err)}`);
|
|
408
409
|
}
|
|
409
410
|
}
|
|
410
411
|
}
|
|
@@ -453,7 +454,7 @@ async function ocrErrors(client, recording, durationSec, lastSec, outDir, warn)
|
|
|
453
454
|
return errorLines(matches);
|
|
454
455
|
}
|
|
455
456
|
catch (err) {
|
|
456
|
-
warn(`OCR of error lines failed: ${
|
|
457
|
+
warn(`OCR of error lines failed: ${errorMessage(err)}`);
|
|
457
458
|
return null;
|
|
458
459
|
}
|
|
459
460
|
finally {
|
package/dist/context.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { SessionStore } from "./utils/sessions.js";
|
|
2
2
|
import { registryPath } from "./utils/paths.js";
|
|
3
|
+
import { ScreencastError } from "./utils/errors.js";
|
|
3
4
|
let store = null;
|
|
4
5
|
export function getStore() {
|
|
5
6
|
if (!store) {
|
|
@@ -15,3 +16,35 @@ export function markShuttingDown() {
|
|
|
15
16
|
export function isShuttingDown() {
|
|
16
17
|
return shuttingDown;
|
|
17
18
|
}
|
|
19
|
+
let startsInFlight = 0;
|
|
20
|
+
let onStartsIdle = [];
|
|
21
|
+
export function beginStart() {
|
|
22
|
+
if (shuttingDown)
|
|
23
|
+
throw new ScreencastError("The server is shutting down; the recording was not started.");
|
|
24
|
+
startsInFlight++;
|
|
25
|
+
let released = false;
|
|
26
|
+
return () => {
|
|
27
|
+
if (released)
|
|
28
|
+
return;
|
|
29
|
+
released = true;
|
|
30
|
+
startsInFlight--;
|
|
31
|
+
if (startsInFlight === 0) {
|
|
32
|
+
const waiters = onStartsIdle;
|
|
33
|
+
onStartsIdle = [];
|
|
34
|
+
for (const w of waiters)
|
|
35
|
+
w();
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
export function startsSettled(timeoutMs) {
|
|
40
|
+
if (startsInFlight === 0)
|
|
41
|
+
return Promise.resolve(true);
|
|
42
|
+
return new Promise((resolve) => {
|
|
43
|
+
const timer = setTimeout(() => resolve(false), timeoutMs);
|
|
44
|
+
timer.unref?.();
|
|
45
|
+
onStartsIdle.push(() => {
|
|
46
|
+
clearTimeout(timer);
|
|
47
|
+
resolve(true);
|
|
48
|
+
});
|
|
49
|
+
});
|
|
50
|
+
}
|
package/dist/index.js
CHANGED
|
@@ -1,15 +1,18 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
3
3
|
import { isCliInvocation, runCli } from "./cli.js";
|
|
4
|
-
import { getStore, isShuttingDown, markShuttingDown } from "./context.js";
|
|
5
|
-
import { requireFfmpeg } from "./utils/ffmpeg.js";
|
|
4
|
+
import { getStore, isShuttingDown, markShuttingDown, startsSettled } from "./context.js";
|
|
5
|
+
import { probeDuration, requireFfmpeg } from "./utils/ffmpeg.js";
|
|
6
6
|
import { abortEditJobs } from "./utils/jobs.js";
|
|
7
|
-
import {
|
|
7
|
+
import { stopAll } from "./utils/lifecycle.js";
|
|
8
8
|
import { createServer } from "./server.js";
|
|
9
9
|
import { pruneCaptures, retentionDays, RETENTION_ENV } from "./utils/retention.js";
|
|
10
10
|
import { cleanupReplayDirs } from "./utils/replay.js";
|
|
11
|
-
|
|
11
|
+
import { errorMessage } from "./utils/errors.js";
|
|
12
|
+
const START_SETTLE_MS = 10_000;
|
|
12
13
|
async function main() {
|
|
14
|
+
const server = createServer();
|
|
15
|
+
installServerHandlers();
|
|
13
16
|
try {
|
|
14
17
|
const reaped = getStore().reapOrphans();
|
|
15
18
|
if (reaped.length > 0) {
|
|
@@ -17,7 +20,7 @@ async function main() {
|
|
|
17
20
|
}
|
|
18
21
|
}
|
|
19
22
|
catch (err) {
|
|
20
|
-
process.stderr.write(`Orphan reaping skipped: ${
|
|
23
|
+
process.stderr.write(`Orphan reaping skipped: ${errorMessage(err)}\n`);
|
|
21
24
|
}
|
|
22
25
|
try {
|
|
23
26
|
const live = getStore()
|
|
@@ -28,17 +31,20 @@ async function main() {
|
|
|
28
31
|
process.stderr.write(`Removed ${removed} leftover replay buffer(s).\n`);
|
|
29
32
|
}
|
|
30
33
|
catch (err) {
|
|
31
|
-
process.stderr.write(`Replay buffer cleanup skipped: ${
|
|
34
|
+
process.stderr.write(`Replay buffer cleanup skipped: ${errorMessage(err)}\n`);
|
|
32
35
|
}
|
|
36
|
+
const transport = new StdioServerTransport();
|
|
37
|
+
await server.connect(transport);
|
|
33
38
|
const days = retentionDays();
|
|
34
39
|
if (days !== null) {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
40
|
+
pruneCaptures(days).then((pruned) => {
|
|
41
|
+
if (pruned.removed > 0) {
|
|
42
|
+
process.stderr.write(`Deleted ${pruned.removed} capture file(s) older than ${days} day(s) (${RETENTION_ENV}).\n`);
|
|
43
|
+
}
|
|
44
|
+
}, (err) => {
|
|
45
|
+
process.stderr.write(`Retention prune failed: ${errorMessage(err)}\n`);
|
|
46
|
+
});
|
|
39
47
|
}
|
|
40
|
-
const transport = new StdioServerTransport();
|
|
41
|
-
await server.connect(transport);
|
|
42
48
|
process.stdin.on("end", () => void shutdown("client disconnected"));
|
|
43
49
|
process.stdin.on("close", () => void shutdown("client disconnected"));
|
|
44
50
|
server.server.onclose = () => void shutdown("transport closed");
|
|
@@ -46,24 +52,29 @@ async function main() {
|
|
|
46
52
|
process.on(sig, () => void shutdown(sig));
|
|
47
53
|
}
|
|
48
54
|
}
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
process.
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
process.
|
|
60
|
-
});
|
|
55
|
+
function installServerHandlers() {
|
|
56
|
+
process.stdout.on("error", (err) => {
|
|
57
|
+
if (err.code !== "EPIPE")
|
|
58
|
+
process.stderr.write(`stdout error: ${err.message}\n`);
|
|
59
|
+
void shutdown("client pipe closed");
|
|
60
|
+
});
|
|
61
|
+
process.on("uncaughtException", (err) => {
|
|
62
|
+
process.stderr.write(`Uncaught exception: ${err.stack ?? err.message}\n`);
|
|
63
|
+
void shutdown("uncaught exception", 1);
|
|
64
|
+
});
|
|
65
|
+
process.on("unhandledRejection", (reason) => {
|
|
66
|
+
process.stderr.write(`Unhandled rejection: ${reason instanceof Error ? (reason.stack ?? reason.message) : String(reason)}\n`);
|
|
67
|
+
});
|
|
68
|
+
}
|
|
61
69
|
async function shutdown(reason, exitCode = 0) {
|
|
62
70
|
if (isShuttingDown())
|
|
63
71
|
return;
|
|
64
72
|
markShuttingDown();
|
|
65
73
|
const edits = abortEditJobs();
|
|
66
74
|
try {
|
|
75
|
+
if (!(await startsSettled(START_SETTLE_MS))) {
|
|
76
|
+
process.stderr.write(`Shutdown (${reason}): a start_recording call did not finish within ${START_SETTLE_MS / 1000}s.\n`);
|
|
77
|
+
}
|
|
67
78
|
const store = getStore();
|
|
68
79
|
if (store.activeIds().length > 0) {
|
|
69
80
|
let ffprobe = null;
|
|
@@ -72,12 +83,12 @@ async function shutdown(reason, exitCode = 0) {
|
|
|
72
83
|
}
|
|
73
84
|
catch {
|
|
74
85
|
}
|
|
75
|
-
const stopped = await stopAll(store, (path) => ffprobe ? probeDuration(
|
|
86
|
+
const stopped = await stopAll(store, (path) => ffprobe ? probeDuration(path, { ffprobe }) : Promise.resolve(null));
|
|
76
87
|
process.stderr.write(`Shutdown (${reason}): stopped ${stopped.length} recording(s).\n`);
|
|
77
88
|
}
|
|
78
89
|
}
|
|
79
90
|
catch (err) {
|
|
80
|
-
process.stderr.write(`Shutdown cleanup failed: ${
|
|
91
|
+
process.stderr.write(`Shutdown cleanup failed: ${errorMessage(err)}\n`);
|
|
81
92
|
}
|
|
82
93
|
const cancelled = await edits;
|
|
83
94
|
if (cancelled > 0)
|
|
@@ -85,11 +96,15 @@ async function shutdown(reason, exitCode = 0) {
|
|
|
85
96
|
process.exit(exitCode);
|
|
86
97
|
}
|
|
87
98
|
const fatal = (error) => {
|
|
88
|
-
process.stderr.write(`Fatal error: ${
|
|
99
|
+
process.stderr.write(`Fatal error: ${errorMessage(error)}\n`);
|
|
89
100
|
process.exit(1);
|
|
90
101
|
};
|
|
91
102
|
const argv = process.argv.slice(2);
|
|
92
103
|
if (isCliInvocation(argv)) {
|
|
104
|
+
process.stdout.on("error", (err) => {
|
|
105
|
+
if (err.code !== "EPIPE")
|
|
106
|
+
process.stderr.write(`stdout error: ${err.message}\n`);
|
|
107
|
+
});
|
|
93
108
|
runCli(argv).then((code) => process.exit(code), fatal);
|
|
94
109
|
}
|
|
95
110
|
else {
|
package/dist/setup.js
CHANGED
|
@@ -3,6 +3,7 @@ import { copyFileSync, existsSync, mkdirSync, readFileSync, writeFileSync } from
|
|
|
3
3
|
import { homedir } from "node:os";
|
|
4
4
|
import { dirname, join } from "node:path";
|
|
5
5
|
import { createInterface } from "node:readline/promises";
|
|
6
|
+
import { errorMessage } from "./utils/errors.js";
|
|
6
7
|
export const CLIENT_IDS = ["claude-desktop", "claude-code", "cursor", "vscode"];
|
|
7
8
|
export const SETUP_USAGE = `setup options:
|
|
8
9
|
--yes answer yes: install FFmpeg and write client configs without asking
|
|
@@ -113,7 +114,7 @@ export function mergeServerConfig(existing, key, name, entry, force = false) {
|
|
|
113
114
|
parsed = JSON.parse(existing.charCodeAt(0) === 0xfeff ? existing.slice(1) : existing);
|
|
114
115
|
}
|
|
115
116
|
catch (err) {
|
|
116
|
-
return { status: "invalid", reason: `not plain JSON (${
|
|
117
|
+
return { status: "invalid", reason: `not plain JSON (${errorMessage(err)})` };
|
|
117
118
|
}
|
|
118
119
|
if (typeof parsed !== "object" || parsed === null || Array.isArray(parsed)) {
|
|
119
120
|
return { status: "invalid", reason: "the file is not a JSON object" };
|
|
@@ -209,7 +210,7 @@ async function configureJsonClient(client, opts, deps) {
|
|
|
209
210
|
text = fs.readFile(client.path);
|
|
210
211
|
}
|
|
211
212
|
catch (err) {
|
|
212
|
-
deps.out(` ${client.name}: could not read ${client.path}: ${
|
|
213
|
+
deps.out(` ${client.name}: could not read ${client.path}: ${errorMessage(err)}\n`);
|
|
213
214
|
return false;
|
|
214
215
|
}
|
|
215
216
|
}
|
|
@@ -248,7 +249,7 @@ async function configureJsonClient(client, opts, deps) {
|
|
|
248
249
|
return true;
|
|
249
250
|
}
|
|
250
251
|
catch (err) {
|
|
251
|
-
deps.out(` ${client.name}: could not write ${client.path}: ${
|
|
252
|
+
deps.out(` ${client.name}: could not write ${client.path}: ${errorMessage(err)}\n`);
|
|
252
253
|
return false;
|
|
253
254
|
}
|
|
254
255
|
}
|
|
@@ -293,7 +294,7 @@ export async function runSetup(opts, deps) {
|
|
|
293
294
|
report = await deps.doctor();
|
|
294
295
|
}
|
|
295
296
|
catch (err) {
|
|
296
|
-
deps.err(`screencast-mcp: the doctor checks failed to run: ${
|
|
297
|
+
deps.err(`screencast-mcp: the doctor checks failed to run: ${errorMessage(err)}\n`);
|
|
297
298
|
return 1;
|
|
298
299
|
}
|
|
299
300
|
for (const line of checklist(report, deps.env, deps.platform))
|
|
@@ -317,7 +318,7 @@ export async function runSetup(opts, deps) {
|
|
|
317
318
|
const res = await deps.exec("winget", WINGET_FFMPEG).catch((err) => ({
|
|
318
319
|
code: 1,
|
|
319
320
|
stdout: "",
|
|
320
|
-
stderr:
|
|
321
|
+
stderr: errorMessage(err),
|
|
321
322
|
}));
|
|
322
323
|
if (res.code === 0)
|
|
323
324
|
say(" FFmpeg installed. Open a new terminal so PATH picks it up, then run setup again.\n");
|
|
@@ -355,7 +356,7 @@ export async function runSetup(opts, deps) {
|
|
|
355
356
|
await deps.open(gif).catch(() => undefined);
|
|
356
357
|
}
|
|
357
358
|
catch (err) {
|
|
358
|
-
say(` the test clip failed: ${
|
|
359
|
+
say(` the test clip failed: ${errorMessage(err)}\n`);
|
|
359
360
|
return 1;
|
|
360
361
|
}
|
|
361
362
|
}
|
package/dist/tools/addMarker.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
import { existsSync } from "node:fs";
|
|
3
|
-
import { errorResponse, okResponse, ScreencastError } from "../utils/errors.js";
|
|
3
|
+
import { errorMessage, errorResponse, okResponse, ScreencastError } from "../utils/errors.js";
|
|
4
4
|
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";
|
|
@@ -61,7 +61,7 @@ export function register(server) {
|
|
|
61
61
|
sidecar = writeMarkers(record.outputPath, markers, args.sessionId);
|
|
62
62
|
}
|
|
63
63
|
catch (err) {
|
|
64
|
-
warning = `Saved in the session, but the sidecar ${sidecar} could not be written: ${err
|
|
64
|
+
warning = `Saved in the session, but the sidecar ${sidecar} could not be written: ${errorMessage(err)}`;
|
|
65
65
|
}
|
|
66
66
|
return okResponse({
|
|
67
67
|
sessionId: args.sessionId,
|
|
@@ -5,6 +5,7 @@ import { OUTPUT_PATH, WRITES_FILE } from "../utils/toolSpec.js";
|
|
|
5
5
|
import { requireFfmpeg, probeMedia } from "../utils/ffmpeg.js";
|
|
6
6
|
import { runEditJob } from "../utils/jobs.js";
|
|
7
7
|
import { buildAssembleArgs, clipLength, DEFAULT_TRANSITION_DUR } from "../utils/produce.js";
|
|
8
|
+
import { assertEditContainer } from "../utils/media.js";
|
|
8
9
|
import { resolveOutput, subdir, stamp, rand } from "../utils/paths.js";
|
|
9
10
|
const inputSchema = {
|
|
10
11
|
clips: z
|
|
@@ -41,6 +42,7 @@ export function register(server) {
|
|
|
41
42
|
if (!existsSync(f))
|
|
42
43
|
throw new ScreencastError(`Input file not found: ${f}`);
|
|
43
44
|
}
|
|
45
|
+
assertEditContainer(args.output);
|
|
44
46
|
const infos = await Promise.all(args.clips.map((c) => probeMedia(c)));
|
|
45
47
|
const durations = infos.map((i) => clipLength(i) ?? 0);
|
|
46
48
|
const clipHasAudio = infos.map((i) => i.audioCodec !== null);
|
|
@@ -6,6 +6,7 @@ import { requireFfmpeg } from "../utils/ffmpeg.js";
|
|
|
6
6
|
import { runEditJob, probeDuration } from "../utils/jobs.js";
|
|
7
7
|
import { buildExportPresetArgs, PLATFORM_PRESETS, PLATFORMS, } from "../utils/produce.js";
|
|
8
8
|
import { resolveOutput, subdir, stamp, rand } from "../utils/paths.js";
|
|
9
|
+
import { assertEditContainer } from "../utils/media.js";
|
|
9
10
|
const inputSchema = {
|
|
10
11
|
input: z.string().min(1).describe("Path to the source video."),
|
|
11
12
|
platform: z
|
|
@@ -32,6 +33,7 @@ export function register(server) {
|
|
|
32
33
|
if (!existsSync(args.input)) {
|
|
33
34
|
throw new ScreencastError(`Input file not found: ${args.input}`);
|
|
34
35
|
}
|
|
36
|
+
assertEditContainer(args.output);
|
|
35
37
|
const platform = args.platform;
|
|
36
38
|
const output = resolveOutput(args.output, subdir("edits"), `${platform}-${stamp()}-${rand()}.mp4`, args.overwrite);
|
|
37
39
|
const ffArgs = buildExportPresetArgs(args.input, output, platform, args.fit ?? "pad");
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
import { errorResponse, okResponse, ScreencastError } from "../utils/errors.js";
|
|
3
3
|
import { STOPS_SESSION, looseOutput } from "../utils/toolSpec.js";
|
|
4
|
-
import { requireFfmpeg } from "../utils/ffmpeg.js";
|
|
5
|
-
import { pauseSession
|
|
4
|
+
import { probeDuration, requireFfmpeg } from "../utils/ffmpeg.js";
|
|
5
|
+
import { pauseSession } from "../utils/lifecycle.js";
|
|
6
6
|
import { recordedSec } from "../utils/pause.js";
|
|
7
7
|
import { getStore } from "../context.js";
|
|
8
8
|
const r3 = (n) => Math.round(n * 1000) / 1000;
|
|
@@ -28,7 +28,7 @@ export function register(server) {
|
|
|
28
28
|
});
|
|
29
29
|
}
|
|
30
30
|
const { ffprobe } = requireFfmpeg();
|
|
31
|
-
const res = await pauseSession(store, record, { probe: (p) => probeDuration(
|
|
31
|
+
const res = await pauseSession(store, record, { probe: (p) => probeDuration(p, { ffprobe }) });
|
|
32
32
|
return okResponse({
|
|
33
33
|
sessionId: record.id,
|
|
34
34
|
status: "paused",
|
package/dist/tools/pipeline.js
CHANGED
|
@@ -10,6 +10,7 @@ import { planPipeline, probeArgs, sidecarCues, MAX_PIPELINE_STEPS } from "../uti
|
|
|
10
10
|
import { calloutFonts, prepareCalloutAssets } from "../utils/calloutAssets.js";
|
|
11
11
|
import { exportAnimation } from "../utils/animExport.js";
|
|
12
12
|
import { calloutItemSchema, fontFileSchema } from "./callout.js";
|
|
13
|
+
import { assertEditContainer } from "../utils/media.js";
|
|
13
14
|
import { readClicks, zoomKeyframeSchema } from "./zoom.js";
|
|
14
15
|
import { redactRegionSchema } from "./redactRegion.js";
|
|
15
16
|
import { resolveOutput, subdir, stamp, rand } from "../utils/paths.js";
|
|
@@ -166,6 +167,8 @@ export function register(server) {
|
|
|
166
167
|
const last = steps.at(-1);
|
|
167
168
|
if (!last)
|
|
168
169
|
throw new ScreencastError("Provide at least one step.");
|
|
170
|
+
if (last.op !== "export_gif")
|
|
171
|
+
assertEditContainer(args.output);
|
|
169
172
|
const ext = last.op === "export_gif" ? `.${last.format ?? "gif"}` : ".mp4";
|
|
170
173
|
const output = resolveOutput(args.output, subdir("edits"), `pipeline-${stamp()}-${rand()}${ext}`, args.overwrite);
|
|
171
174
|
const transcribes = last.op !== "export_gif" && steps.some((s) => s.op === "burn_subtitles" && s.transcribe);
|
|
@@ -5,7 +5,7 @@ import { errorResponse, okResponse, ScreencastError } from "../utils/errors.js";
|
|
|
5
5
|
import { READ_ONLY, looseOutput } from "../utils/toolSpec.js";
|
|
6
6
|
import { requireFfmpeg, runFfmpeg, runCapture, probeMedia } from "../utils/ffmpeg.js";
|
|
7
7
|
import { jobTimeoutMs } from "../utils/jobs.js";
|
|
8
|
-
import { buildSampleByFpsArgs, buildSampleAtTimestampArgs, planFpsSampling, buildSceneScanArgs, parseSceneScan, pickSceneFrames, DEFAULT_SCENE_THRESHOLD, DEFAULT_MAX_FRAMES, MAX_FRAMES_CEILING, } from "../utils/media.js";
|
|
8
|
+
import { buildSampleByFpsArgs, pickFramePrefix, buildSampleAtTimestampArgs, planFpsSampling, buildSceneScanArgs, parseSceneScan, pickSceneFrames, DEFAULT_SCENE_THRESHOLD, DEFAULT_MAX_FRAMES, MAX_FRAMES_CEILING, } from "../utils/media.js";
|
|
9
9
|
import { subdir, stamp, rand, sequencePattern, resolveOutputDir } from "../utils/paths.js";
|
|
10
10
|
import { encodeInlineImages, clampInlineCount, DEFAULT_MAX_IMAGE_WIDTH, DEFAULT_MAX_INLINE_IMAGES, MAX_INLINE_IMAGES, } from "../utils/images.js";
|
|
11
11
|
const inputSchema = {
|
|
@@ -117,11 +117,11 @@ export function register(server) {
|
|
|
117
117
|
if (plan) {
|
|
118
118
|
const isPng = (f) => f.endsWith(".png");
|
|
119
119
|
const before = new Set(readdirSync(dir).filter(isPng));
|
|
120
|
-
const
|
|
120
|
+
const prefix = pickFramePrefix(before, `${stamp()}-${rand()}`);
|
|
121
|
+
const pattern = sequencePattern(dir, `${prefix}%05d.png`);
|
|
121
122
|
await runFfmpeg(buildSampleByFpsArgs(args.input, plan.fps, pattern, maxFrames, args.dedupe === true), jobTimeoutMs(durationSec), { signal: extra.signal });
|
|
122
123
|
frames = readdirSync(dir)
|
|
123
|
-
.filter(isPng)
|
|
124
|
-
.filter((f) => !before.has(f))
|
|
124
|
+
.filter((f) => isPng(f) && f.startsWith(prefix) && !before.has(f))
|
|
125
125
|
.sort()
|
|
126
126
|
.map((f) => join(dir, f));
|
|
127
127
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { spawn } from "node:child_process";
|
|
2
2
|
import { z } from "zod";
|
|
3
|
-
import { errorResponse, okResponse, ScreencastError } from "../utils/errors.js";
|
|
3
|
+
import { errorMessage, errorResponse, okResponse, ScreencastError } from "../utils/errors.js";
|
|
4
4
|
import { WRITES_FILE, looseOutput } from "../utils/toolSpec.js";
|
|
5
5
|
import { requireFfmpeg, wgcAvailable } from "../utils/ffmpeg.js";
|
|
6
6
|
import { fileURLToPath } from "node:url";
|
|
@@ -10,7 +10,7 @@ import { windowMatchReport } from "../utils/windows.js";
|
|
|
10
10
|
import { resolveLoopbackDevice, resolveVideoDevice } from "../utils/audioDevices.js";
|
|
11
11
|
import { confirmCapture, describeTarget } from "../utils/consent.js";
|
|
12
12
|
import { resolveOutput, subdir, stamp, rand } from "../utils/paths.js";
|
|
13
|
-
import { getStore } from "../context.js";
|
|
13
|
+
import { beginStart, getStore } from "../context.js";
|
|
14
14
|
import { killPid, serverIdentity } from "../utils/sessions.js";
|
|
15
15
|
import { mkdirSync, rmSync } from "node:fs";
|
|
16
16
|
import { buildDdaInputArgs, ddagrabWorks, encoderArgs, getDxgiOutputs, planDdaSource, resolveEncoder, startWithEncoderFallback, } from "../utils/gpu.js";
|
|
@@ -132,7 +132,9 @@ export function register(server) {
|
|
|
132
132
|
}),
|
|
133
133
|
annotations: WRITES_FILE,
|
|
134
134
|
}, async (args, extra) => {
|
|
135
|
+
let release = () => { };
|
|
135
136
|
try {
|
|
137
|
+
release = beginStart();
|
|
136
138
|
const { ffmpeg } = requireFfmpeg();
|
|
137
139
|
const hideCursor = args.cursor === "events";
|
|
138
140
|
if (hideCursor)
|
|
@@ -268,6 +270,7 @@ export function register(server) {
|
|
|
268
270
|
fps,
|
|
269
271
|
quality,
|
|
270
272
|
pid: child.pid ?? null,
|
|
273
|
+
pidSpawnedAt: spawnedAt,
|
|
271
274
|
...serverIdentity(),
|
|
272
275
|
status: "recording",
|
|
273
276
|
startedAt: new Date().toISOString(),
|
|
@@ -330,7 +333,7 @@ export function register(server) {
|
|
|
330
333
|
discardReplay(replay);
|
|
331
334
|
if (webcamRaw)
|
|
332
335
|
rmSync(partsDir(output), { recursive: true, force: true });
|
|
333
|
-
throw new ScreencastError(`Recording stopped: the session registry could not be written (${err
|
|
336
|
+
throw new ScreencastError(`Recording stopped: the session registry could not be written (${errorMessage(err)}).`);
|
|
334
337
|
}
|
|
335
338
|
if (logger && replay) {
|
|
336
339
|
const exited = new Promise((resolve) => child.once("exit", () => resolve()));
|
|
@@ -348,11 +351,11 @@ export function register(server) {
|
|
|
348
351
|
}
|
|
349
352
|
catch (err) {
|
|
350
353
|
store.tryUpdate(id, {
|
|
351
|
-
events: { path: evPaths.jsonl, keys: keyMode, error: err
|
|
354
|
+
events: { path: evPaths.jsonl, keys: keyMode, error: errorMessage(err) },
|
|
352
355
|
});
|
|
353
356
|
}
|
|
354
357
|
}).catch((err) => {
|
|
355
|
-
process.stderr.write(`Event log for ${id} failed: ${
|
|
358
|
+
process.stderr.write(`Event log for ${id} failed: ${errorMessage(err)}\n`);
|
|
356
359
|
}));
|
|
357
360
|
}
|
|
358
361
|
attachExitHandler(store, id, child, { backend, maxDurationSec, spawnedAt, watch });
|
|
@@ -388,5 +391,8 @@ export function register(server) {
|
|
|
388
391
|
catch (error) {
|
|
389
392
|
return errorResponse(error);
|
|
390
393
|
}
|
|
394
|
+
finally {
|
|
395
|
+
release();
|
|
396
|
+
}
|
|
391
397
|
});
|
|
392
398
|
}
|
|
@@ -2,9 +2,10 @@ import { z } from "zod";
|
|
|
2
2
|
import { existsSync } from "node:fs";
|
|
3
3
|
import { errorResponse, okResponse, ScreencastError } from "../utils/errors.js";
|
|
4
4
|
import { STOPS_SESSION, looseOutput } from "../utils/toolSpec.js";
|
|
5
|
-
import { probeMedia, requireFfmpeg } from "../utils/ffmpeg.js";
|
|
6
|
-
import {
|
|
5
|
+
import { probeDuration, probeMedia, requireFfmpeg } from "../utils/ffmpeg.js";
|
|
6
|
+
import { stopSession } from "../utils/lifecycle.js";
|
|
7
7
|
import { getStore } from "../context.js";
|
|
8
|
+
import { foreignStopRefusal, ownerAlive } from "../utils/sessions.js";
|
|
8
9
|
import { finishReplay } from "../utils/replay.js";
|
|
9
10
|
import { webcamPlacement } from "../utils/pause.js";
|
|
10
11
|
function replayReport(r) {
|
|
@@ -95,10 +96,13 @@ export function register(server) {
|
|
|
95
96
|
: "Session was not active; returning its recorded final state.",
|
|
96
97
|
});
|
|
97
98
|
}
|
|
99
|
+
const refusal = foreignStopRefusal(record, process.pid, ownerAlive(record));
|
|
100
|
+
if (refusal)
|
|
101
|
+
throw new ScreencastError(refusal);
|
|
98
102
|
const { ffprobe } = requireFfmpeg();
|
|
99
103
|
const { record: updated, graceful, durationSec, replay, segments } = await stopSession(store, record, {
|
|
100
104
|
reason: "stopped",
|
|
101
|
-
probe: (path) => probeDuration(
|
|
105
|
+
probe: (path) => probeDuration(path, { ffprobe }),
|
|
102
106
|
saveReplay: args.save,
|
|
103
107
|
});
|
|
104
108
|
return okResponse({
|
package/dist/tools/titleCard.js
CHANGED
|
@@ -8,6 +8,7 @@ import { buildTitleCardArgs, DEFAULT_TITLE_DURATION } from "../utils/produce.js"
|
|
|
8
8
|
import { resolveTextFont } from "../utils/fonts.js";
|
|
9
9
|
import { fontFileSchema } from "./callout.js";
|
|
10
10
|
import { resolveOutput, subdir, stamp, rand, tempPath } from "../utils/paths.js";
|
|
11
|
+
import { assertEditContainer } from "../utils/media.js";
|
|
11
12
|
const inputSchema = {
|
|
12
13
|
text: z.string().min(1).describe("Title text. Multiple lines are allowed (use \\n)."),
|
|
13
14
|
duration: z.number().positive().optional().describe("Card length in seconds (default 3)."),
|
|
@@ -33,6 +34,7 @@ export function register(server) {
|
|
|
33
34
|
}, async (args, extra) => {
|
|
34
35
|
try {
|
|
35
36
|
requireFfmpeg();
|
|
37
|
+
assertEditContainer(args.output);
|
|
36
38
|
const output = resolveOutput(args.output, subdir("edits"), `title-${stamp()}-${rand()}.mp4`, args.overwrite);
|
|
37
39
|
const font = resolveTextFont(args.text, { weight: args.bold === false ? "regular" : "bold", fontFile: args.fontFile });
|
|
38
40
|
const textFile = tempPath(".txt");
|
|
@@ -5,6 +5,7 @@ import { OUTPUT_PATH, WRITES_FILE } from "../utils/toolSpec.js";
|
|
|
5
5
|
import { requireFfmpeg, probeMedia } from "../utils/ffmpeg.js";
|
|
6
6
|
import { runEditJob } from "../utils/jobs.js";
|
|
7
7
|
import { buildXfadeArgs, clipLength, DEFAULT_TRANSITION_DUR } from "../utils/produce.js";
|
|
8
|
+
import { assertEditContainer } from "../utils/media.js";
|
|
8
9
|
import { resolveOutput, subdir, stamp, rand } from "../utils/paths.js";
|
|
9
10
|
const inputSchema = {
|
|
10
11
|
inputA: z.string().min(1).describe("Outgoing video."),
|
|
@@ -36,6 +37,7 @@ export function register(server) {
|
|
|
36
37
|
if (!existsSync(f))
|
|
37
38
|
throw new ScreencastError(`Input file not found: ${f}`);
|
|
38
39
|
}
|
|
40
|
+
assertEditContainer(args.output);
|
|
39
41
|
const [a, b] = await Promise.all([probeMedia(args.inputA), probeMedia(args.inputB)]);
|
|
40
42
|
const durA = clipLength(a);
|
|
41
43
|
const durB = clipLength(b);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ScreencastError } from "./errors.js";
|
|
1
|
+
import { errorMessage, ScreencastError } from "./errors.js";
|
|
2
2
|
import { requireFfmpeg, runCapture } from "./ffmpeg.js";
|
|
3
3
|
export const LOOPBACK_HINTS = [
|
|
4
4
|
"virtual-audio-capturer",
|
|
@@ -89,15 +89,11 @@ async function enumerateDshow() {
|
|
|
89
89
|
res = await runCapture(ffmpeg, ["-hide_banner", "-list_devices", "true", "-f", "dshow", "-i", "dummy"], ENUM_TIMEOUT_MS, { closeStdin: true });
|
|
90
90
|
}
|
|
91
91
|
catch (err) {
|
|
92
|
-
throw new ScreencastError(`Could not enumerate audio devices (${err
|
|
92
|
+
throw new ScreencastError(`Could not enumerate audio devices (${errorMessage(err)}).`, ENUM_FAILED_HINT);
|
|
93
93
|
}
|
|
94
94
|
cachedDevices = parseDshowAudioDevices(res.stderr);
|
|
95
95
|
cachedVideo = parseDshowVideoDevices(res.stderr);
|
|
96
96
|
}
|
|
97
|
-
export function clearAudioDeviceCache() {
|
|
98
|
-
cachedDevices = null;
|
|
99
|
-
cachedVideo = null;
|
|
100
|
-
}
|
|
101
97
|
export async function resolveLoopbackDevice(explicit) {
|
|
102
98
|
const devices = await listDshowAudioDevices();
|
|
103
99
|
const picked = pickLoopbackDevice(devices, explicit);
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { spawnSync } from "node:child_process";
|
|
2
2
|
import { isAbsolute } from "node:path";
|
|
3
3
|
import { runPowerShell, psTimeoutMs } from "./monitors.js";
|
|
4
|
+
import { errorMessage } from "./errors.js";
|
|
4
5
|
export const FFMPEG_FEATURE_MAJOR = 8;
|
|
5
6
|
export function parseFfmpegVersion(text) {
|
|
6
7
|
const version = /^ff(?:mpeg|probe) version (\S+)/m.exec(text)?.[1] ?? null;
|
|
@@ -62,7 +63,7 @@ export async function ocrStatus() {
|
|
|
62
63
|
return { available: raw.available === true, language: raw.language ?? null, languages };
|
|
63
64
|
}
|
|
64
65
|
catch (err) {
|
|
65
|
-
return { available: false, language: null, languages: [], error: err
|
|
66
|
+
return { available: false, language: null, languages: [], error: errorMessage(err) };
|
|
66
67
|
}
|
|
67
68
|
}
|
|
68
69
|
export const ENV_SETTINGS = [
|
package/dist/utils/consent.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ScreencastError } from "./errors.js";
|
|
1
|
+
import { errorMessage, ScreencastError } from "./errors.js";
|
|
2
2
|
export const CONFIRM_CAPTURE_ENV = "SCREENCAST_CONFIRM_CAPTURE";
|
|
3
3
|
export const CONFIRM_TIMEOUT_MS = 5 * 60 * 1000;
|
|
4
4
|
export function confirmCaptureEnabled(env = process.env) {
|
|
@@ -21,7 +21,7 @@ export async function confirmCapture(server, request, signal) {
|
|
|
21
21
|
({ action } = await server.server.elicitInput({ message: request, requestedSchema: { type: "object", properties: {} } }, { signal, timeout: CONFIRM_TIMEOUT_MS }));
|
|
22
22
|
}
|
|
23
23
|
catch (err) {
|
|
24
|
-
throw new ScreencastError(`Capture blocked: the confirmation request failed (${
|
|
24
|
+
throw new ScreencastError(`Capture blocked: the confirmation request failed (${errorMessage(err)}). Nothing was captured.`);
|
|
25
25
|
}
|
|
26
26
|
if (action !== "accept") {
|
|
27
27
|
throw new ScreencastError(`Capture ${action === "decline" ? "declined" : "cancelled"} by the user. Nothing was captured.`);
|