@tmhs/screencast-mcp 0.49.0 → 0.50.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 (133) hide show
  1. package/README.md +13 -8
  2. package/dist/index.js +550 -106
  3. package/dist/wgcRecorder.js +15 -139
  4. package/package.json +8 -4
  5. package/assets/.gitkeep +0 -0
  6. package/assets/icon.png +0 -0
  7. package/dist/cli.js +0 -516
  8. package/dist/context.js +0 -50
  9. package/dist/prompts.js +0 -95
  10. package/dist/resources.js +0 -93
  11. package/dist/server.js +0 -174
  12. package/dist/setup.js +0 -438
  13. package/dist/tools/addMarker.js +0 -93
  14. package/dist/tools/assembleHighlights.js +0 -69
  15. package/dist/tools/backdrop.js +0 -89
  16. package/dist/tools/bugReport.js +0 -266
  17. package/dist/tools/burnSubtitles.js +0 -56
  18. package/dist/tools/callout.js +0 -103
  19. package/dist/tools/chapters.js +0 -156
  20. package/dist/tools/clip.js +0 -52
  21. package/dist/tools/compress.js +0 -51
  22. package/dist/tools/concat.js +0 -67
  23. package/dist/tools/contactSheet.js +0 -135
  24. package/dist/tools/convert.js +0 -46
  25. package/dist/tools/crop.js +0 -43
  26. package/dist/tools/cursor.js +0 -87
  27. package/dist/tools/cutByTranscript.js +0 -86
  28. package/dist/tools/cutIdle.js +0 -84
  29. package/dist/tools/deleteRecording.js +0 -119
  30. package/dist/tools/denoise.js +0 -60
  31. package/dist/tools/doctor.js +0 -146
  32. package/dist/tools/exportGif.js +0 -57
  33. package/dist/tools/exportPreset.js +0 -48
  34. package/dist/tools/extractAudio.js +0 -65
  35. package/dist/tools/findText.js +0 -196
  36. package/dist/tools/getMediaInfo.js +0 -36
  37. package/dist/tools/getSession.js +0 -40
  38. package/dist/tools/indexRecording.js +0 -195
  39. package/dist/tools/keystrokeOverlay.js +0 -131
  40. package/dist/tools/listAudioDevices.js +0 -35
  41. package/dist/tools/listSessions.js +0 -28
  42. package/dist/tools/listTargets.js +0 -76
  43. package/dist/tools/listVideoDevices.js +0 -26
  44. package/dist/tools/musicBed.js +0 -55
  45. package/dist/tools/narrate.js +0 -86
  46. package/dist/tools/normalizeAudio.js +0 -60
  47. package/dist/tools/overlay.js +0 -62
  48. package/dist/tools/pauseRecording.js +0 -44
  49. package/dist/tools/pipeline.js +0 -400
  50. package/dist/tools/readEvents.js +0 -98
  51. package/dist/tools/redactRegion.js +0 -70
  52. package/dist/tools/reframe.js +0 -46
  53. package/dist/tools/resumeRecording.js +0 -46
  54. package/dist/tools/reviewRecording.js +0 -163
  55. package/dist/tools/sampleFrames.js +0 -200
  56. package/dist/tools/saveReplay.js +0 -90
  57. package/dist/tools/scale.js +0 -44
  58. package/dist/tools/screenDiff.js +0 -86
  59. package/dist/tools/screenshot.js +0 -76
  60. package/dist/tools/searchRecording.js +0 -79
  61. package/dist/tools/speed.js +0 -46
  62. package/dist/tools/startRecording.js +0 -398
  63. package/dist/tools/stepGuide.js +0 -250
  64. package/dist/tools/stopRecording.js +0 -132
  65. package/dist/tools/titleCard.js +0 -67
  66. package/dist/tools/transcribe.js +0 -66
  67. package/dist/tools/trim.js +0 -57
  68. package/dist/tools/waitForChange.js +0 -128
  69. package/dist/tools/xfadeTransition.js +0 -58
  70. package/dist/tools/zoom.js +0 -149
  71. package/dist/utils/anim.js +0 -54
  72. package/dist/utils/animExport.js +0 -56
  73. package/dist/utils/argPaths.js +0 -39
  74. package/dist/utils/audio.js +0 -113
  75. package/dist/utils/audioDevices.js +0 -107
  76. package/dist/utils/backdrop.js +0 -151
  77. package/dist/utils/bugReport.js +0 -172
  78. package/dist/utils/callout.js +0 -90
  79. package/dist/utils/calloutAssets.js +0 -42
  80. package/dist/utils/capabilities.js +0 -96
  81. package/dist/utils/captions.js +0 -103
  82. package/dist/utils/chapters.js +0 -227
  83. package/dist/utils/consent.js +0 -29
  84. package/dist/utils/cursor.js +0 -317
  85. package/dist/utils/diff.js +0 -184
  86. package/dist/utils/errors.js +0 -29
  87. package/dist/utils/events.js +0 -403
  88. package/dist/utils/expr.js +0 -11
  89. package/dist/utils/ffmpeg.js +0 -285
  90. package/dist/utils/fontCoverage.js +0 -177
  91. package/dist/utils/fonts.js +0 -154
  92. package/dist/utils/gpu.js +0 -219
  93. package/dist/utils/idle.js +0 -91
  94. package/dist/utils/images.js +0 -38
  95. package/dist/utils/jobs.js +0 -129
  96. package/dist/utils/keystrokes.js +0 -155
  97. package/dist/utils/lifecycle.js +0 -233
  98. package/dist/utils/logging.js +0 -75
  99. package/dist/utils/media.js +0 -574
  100. package/dist/utils/monitors.js +0 -124
  101. package/dist/utils/narrate.js +0 -233
  102. package/dist/utils/ocr.js +0 -222
  103. package/dist/utils/ocrScan.js +0 -91
  104. package/dist/utils/paths.js +0 -155
  105. package/dist/utils/pause.js +0 -190
  106. package/dist/utils/pipeline.js +0 -361
  107. package/dist/utils/player.js +0 -85
  108. package/dist/utils/pool.js +0 -29
  109. package/dist/utils/produce.js +0 -298
  110. package/dist/utils/recipes.js +0 -71
  111. package/dist/utils/recorder.js +0 -173
  112. package/dist/utils/recordingFiles.js +0 -32
  113. package/dist/utils/recordingIndex.js +0 -312
  114. package/dist/utils/replay.js +0 -283
  115. package/dist/utils/resolveTarget.js +0 -25
  116. package/dist/utils/retention.js +0 -48
  117. package/dist/utils/roots.js +0 -43
  118. package/dist/utils/sessions.js +0 -499
  119. package/dist/utils/sheet.js +0 -59
  120. package/dist/utils/stepGuide.js +0 -231
  121. package/dist/utils/steps.js +0 -88
  122. package/dist/utils/still.js +0 -38
  123. package/dist/utils/targetList.js +0 -64
  124. package/dist/utils/targets.js +0 -265
  125. package/dist/utils/timeline.js +0 -85
  126. package/dist/utils/toolSpec.js +0 -31
  127. package/dist/utils/toolsets.js +0 -134
  128. package/dist/utils/transcriptCut.js +0 -149
  129. package/dist/utils/validate.js +0 -23
  130. package/dist/utils/waitLoop.js +0 -50
  131. package/dist/utils/wgc.js +0 -84
  132. package/dist/utils/windows.js +0 -192
  133. package/dist/utils/zoom.js +0 -234
@@ -1,265 +0,0 @@
1
- import { ScreencastError } from "./errors.js";
2
- import { stillOutput } from "./paths.js";
3
- export const QUALITY_PRESETS = {
4
- draft: { preset: "ultrafast", crf: 28 },
5
- standard: { preset: "veryfast", crf: 23 },
6
- high: { preset: "medium", crf: 18 },
7
- };
8
- export const DEFAULT_FPS = 30;
9
- export const DEFAULT_QUALITY = "standard";
10
- export function buildAudioInputArgs(audio) {
11
- if (!audio || audio.device.trim().length === 0)
12
- return [];
13
- return ["-f", "dshow", "-i", `audio=${audio.device}`];
14
- }
15
- function parseIntStrict(value, label) {
16
- if (!/^-?\d+$/.test(value.trim())) {
17
- throw new ScreencastError(`${label} must be an integer, got "${value}".`);
18
- }
19
- return parseInt(value, 10);
20
- }
21
- export function parseTarget(spec) {
22
- const raw = spec.trim();
23
- if (raw === "" || raw.toLowerCase() === "full")
24
- return { kind: "full" };
25
- const colon = raw.indexOf(":");
26
- if (colon === -1) {
27
- throw new ScreencastError(`Unrecognized target "${spec}". Use full | monitor:<index> | ` +
28
- `window:<title> | region:<x>,<y>,<w>,<h>.`);
29
- }
30
- const kind = raw.slice(0, colon).toLowerCase();
31
- const rest = raw.slice(colon + 1);
32
- if (kind === "monitor") {
33
- const index = parseIntStrict(rest, "monitor index");
34
- if (index < 0)
35
- throw new ScreencastError("monitor index must be >= 0.");
36
- return { kind: "monitor", index };
37
- }
38
- if (kind === "window") {
39
- const title = rest.trim();
40
- if (title === "")
41
- throw new ScreencastError("window title must not be empty.");
42
- return { kind: "window", title };
43
- }
44
- if (kind === "region") {
45
- const parts = rest.split(",").map((p) => p.trim());
46
- if (parts.length !== 4) {
47
- throw new ScreencastError(`region must be x,y,w,h (4 integers), got "${rest}".`);
48
- }
49
- const [px = "", py = "", pw = "", ph = ""] = parts;
50
- const [x, y, w, h] = [
51
- parseIntStrict(px, "region x"),
52
- parseIntStrict(py, "region y"),
53
- parseIntStrict(pw, "region w"),
54
- parseIntStrict(ph, "region h"),
55
- ];
56
- if (w <= 0 || h <= 0) {
57
- throw new ScreencastError("region width and height must be positive.");
58
- }
59
- return { kind: "region", x, y, w, h };
60
- }
61
- throw new ScreencastError(`Unknown target kind "${kind}". Use full | monitor | window | region.`);
62
- }
63
- export function resolveMonitor(index, monitors) {
64
- const m = monitors.find((mon) => mon.index === index);
65
- if (!m) {
66
- const available = monitors.map((mon) => mon.index).join(", ") || "none";
67
- throw new ScreencastError(`monitor:${index} not found. Available monitor indexes: ${available}.`);
68
- }
69
- return m;
70
- }
71
- export function virtualDesktopBounds(monitors) {
72
- if (monitors.length === 0)
73
- return { x: 0, y: 0, w: 0, h: 0 };
74
- const minX = Math.min(...monitors.map((m) => m.x));
75
- const minY = Math.min(...monitors.map((m) => m.y));
76
- const maxX = Math.max(...monitors.map((m) => m.x + m.width));
77
- const maxY = Math.max(...monitors.map((m) => m.y + m.height));
78
- return { x: minX, y: minY, w: maxX - minX, h: maxY - minY };
79
- }
80
- export function validateRegionOnDesktop(region, monitors) {
81
- if (monitors.length === 0)
82
- return;
83
- const v = virtualDesktopBounds(monitors);
84
- const within = region.x >= v.x &&
85
- region.y >= v.y &&
86
- region.x + region.w <= v.x + v.w &&
87
- region.y + region.h <= v.y + v.h;
88
- if (!within) {
89
- throw new ScreencastError(`region ${region.x},${region.y},${region.w},${region.h} is outside the ` +
90
- `virtual desktop (origin ${v.x},${v.y}, size ${v.w}x${v.h}). gdigrab ` +
91
- `captures the desktop, so the rectangle must fit inside it. Adjust the ` +
92
- `offset/size, or use monitor:<index> to capture a whole display.`);
93
- }
94
- }
95
- export function resolveQuality(quality) {
96
- const q = QUALITY_PRESETS[quality];
97
- if (!q)
98
- throw new ScreencastError(`Unknown quality preset "${quality}".`);
99
- return ["-c:v", "libx264", "-preset", q.preset, "-crf", String(q.crf),
100
- "-pix_fmt", "yuv420p"];
101
- }
102
- function evenDown(n) {
103
- return n - (n % 2);
104
- }
105
- export function targetInputArgs(target, monitors, opts = {}) {
106
- switch (target.kind) {
107
- case "full": {
108
- const v = virtualDesktopBounds(monitors);
109
- if (opts.evenSize && monitors.length > 0 && (v.w % 2 !== 0 || v.h % 2 !== 0)) {
110
- return [
111
- "-offset_x", String(v.x),
112
- "-offset_y", String(v.y),
113
- "-video_size", `${evenDown(v.w)}x${evenDown(v.h)}`,
114
- "-i", "desktop",
115
- ];
116
- }
117
- return ["-i", "desktop"];
118
- }
119
- case "window":
120
- throw new ScreencastError("Internal: a window target must be resolved to a region before " +
121
- "building capture args. Call resolveCaptureTarget().");
122
- case "region": {
123
- let { w, h } = target;
124
- if (opts.evenSize) {
125
- w = evenDown(w);
126
- h = evenDown(h);
127
- if (w <= 0 || h <= 0) {
128
- throw new ScreencastError(`region ${target.w}x${target.h} is too small to record: width and ` +
129
- `height must each be at least 2px (the video encoder needs even ` +
130
- `dimensions). Use a larger region, or take a screenshot instead.`);
131
- }
132
- }
133
- return [
134
- "-offset_x", String(target.x),
135
- "-offset_y", String(target.y),
136
- "-video_size", `${w}x${h}`,
137
- "-i", "desktop",
138
- ];
139
- }
140
- case "monitor": {
141
- const m = resolveMonitor(target.index, monitors);
142
- const w = opts.evenSize ? evenDown(m.width) : m.width;
143
- const h = opts.evenSize ? evenDown(m.height) : m.height;
144
- return [
145
- "-offset_x", String(m.x),
146
- "-offset_y", String(m.y),
147
- "-video_size", `${w}x${h}`,
148
- "-i", "desktop",
149
- ];
150
- }
151
- }
152
- }
153
- export function buildWebcamInputArgs(device) {
154
- if (device.trim().length === 0)
155
- throw new ScreencastError("webcam device must not be empty.");
156
- return ["-f", "dshow", "-use_wallclock_as_timestamps", "1", "-rtbufsize", "256M", "-i", `video=${device}`];
157
- }
158
- export const DEFAULT_MAX_RECORDING_SEC = 3600;
159
- export function resolveMaxDuration(explicit, env = process.env) {
160
- if (explicit !== undefined)
161
- return validateMaxDuration(explicit);
162
- const raw = env.SCREENCAST_MAX_RECORDING_SEC;
163
- if (raw !== undefined && raw.trim() !== "") {
164
- const n = Number(raw);
165
- if (!Number.isInteger(n) || n < 0 || n > MAX_RECORDING_CAP_SEC) {
166
- throw new ScreencastError(`SCREENCAST_MAX_RECORDING_SEC must be an integer from 0 (no cap) to ${MAX_RECORDING_CAP_SEC} (7 days), got "${raw}".`);
167
- }
168
- return n;
169
- }
170
- return DEFAULT_MAX_RECORDING_SEC;
171
- }
172
- export const MAX_RECORDING_CAP_SEC = 7 * 24 * 3600;
173
- function validateMaxDuration(n) {
174
- if (!Number.isInteger(n) || n < 0 || n > MAX_RECORDING_CAP_SEC) {
175
- throw new ScreencastError(`maxDurationSec must be an integer from 0 (no cap) to ${MAX_RECORDING_CAP_SEC} (7 days).`);
176
- }
177
- return n;
178
- }
179
- function validateFps(fps) {
180
- if (!Number.isInteger(fps) || fps < 1 || fps > 120) {
181
- throw new ScreencastError("fps must be an integer between 1 and 120.");
182
- }
183
- return fps;
184
- }
185
- export function captureKeyframeArgs(fps) {
186
- return ["-g", String(Math.max(1, Math.round(fps * 2)))];
187
- }
188
- const FRAGMENTED_MP4 = ["-movflags", "+frag_keyframe+empty_moov+default_base_moof"];
189
- export function buildCaptureArgs(target, opts) {
190
- const fps = validateFps(opts.fps ?? DEFAULT_FPS);
191
- const quality = opts.quality ?? DEFAULT_QUALITY;
192
- const monitors = opts.monitors ?? [];
193
- const cap = validateMaxDuration(opts.maxDurationSec ?? 0);
194
- const capArgs = cap > 0 ? ["-t", String(cap)] : [];
195
- const cam = opts.webcam;
196
- const camInput = opts.audio ? 2 : 1;
197
- return [
198
- "-y",
199
- ...(opts.videoInput ?? [
200
- "-f", "gdigrab",
201
- "-framerate", String(fps),
202
- ...(opts.drawMouse === false ? ["-draw_mouse", "0"] : []),
203
- ...targetInputArgs(target, monitors, { evenSize: true }),
204
- ]),
205
- ...buildAudioInputArgs(opts.audio),
206
- ...(cam ? buildWebcamInputArgs(cam.device) : []),
207
- ...(cam ? ["-map", "0:v", ...(opts.audio ? ["-map", "1:a"] : [])] : []),
208
- ...(!opts.videoInput && target.kind === "full" && monitors.length === 0
209
- ? ["-vf", "crop=trunc(iw/2)*2:trunc(ih/2)*2"]
210
- : []),
211
- ...(opts.videoCodec ?? resolveQuality(quality)),
212
- ...captureKeyframeArgs(fps),
213
- ...(opts.audio ? ["-c:a", "aac", "-b:a", "160k"] : []),
214
- ...FRAGMENTED_MP4,
215
- ...capArgs,
216
- opts.output,
217
- ...(cam
218
- ? [
219
- "-map", `${camInput}:v`,
220
- ...(cam.codec ?? resolveQuality(quality)),
221
- ...captureKeyframeArgs(fps),
222
- ...FRAGMENTED_MP4,
223
- ...capArgs,
224
- cam.output,
225
- ]
226
- : []),
227
- ];
228
- }
229
- export const SCREENSHOT_GRAB_FPS = 30;
230
- export function buildWgcScreenshotArgs(hwnd, output) {
231
- if (!Number.isSafeInteger(hwnd) || hwnd <= 0)
232
- throw new ScreencastError("Invalid window handle.");
233
- return [
234
- "-y", "-v", "error",
235
- "-filter_complex", `gfxcapture=hwnd=${hwnd}:max_framerate=30,hwdownload,format=bgra`,
236
- "-frames:v", "1",
237
- ...stillOutput(output),
238
- ];
239
- }
240
- export function buildScreenshotArgs(target, output, monitors = []) {
241
- return [
242
- "-y",
243
- "-f", "gdigrab",
244
- "-framerate", String(SCREENSHOT_GRAB_FPS),
245
- ...targetInputArgs(target, monitors),
246
- "-frames:v", "1",
247
- ...stillOutput(output),
248
- ];
249
- }
250
- export function captureFrame(target, monitors) {
251
- switch (target.kind) {
252
- case "region":
253
- return { x: target.x, y: target.y, w: evenDown(target.w), h: evenDown(target.h) };
254
- case "monitor": {
255
- const m = resolveMonitor(target.index, monitors);
256
- return { x: m.x, y: m.y, w: evenDown(m.width), h: evenDown(m.height) };
257
- }
258
- case "full": {
259
- const v = virtualDesktopBounds(monitors);
260
- return { x: v.x, y: v.y, w: evenDown(v.w), h: evenDown(v.h) };
261
- }
262
- case "window":
263
- throw new ScreencastError("Internal: resolve a window target to a region first.");
264
- }
265
- }
@@ -1,85 +0,0 @@
1
- const r3 = (v) => Math.round(v * 1000) / 1000;
2
- export function cutShift(t, spans) {
3
- let removed = 0;
4
- for (const s of spans) {
5
- if (t <= s.start)
6
- break;
7
- removed += Math.min(t, s.end) - s.start;
8
- }
9
- return removed;
10
- }
11
- export function mapTime(t, ops) {
12
- let v = t;
13
- for (const op of ops) {
14
- if (op.op === "trim") {
15
- if (v < op.start || v >= op.end)
16
- return null;
17
- v -= op.start;
18
- }
19
- else if (op.op === "speed")
20
- v /= op.factor;
21
- else
22
- v -= cutShift(v, op.spans);
23
- }
24
- return v;
25
- }
26
- export function mapWindow(from, to, ops) {
27
- let a = from;
28
- let b = to;
29
- for (const op of ops) {
30
- if (op.op === "trim") {
31
- a = Math.max(a, op.start) - op.start;
32
- b = Math.min(b, op.end) - op.start;
33
- }
34
- else if (op.op === "speed") {
35
- a /= op.factor;
36
- b /= op.factor;
37
- }
38
- else {
39
- a -= cutShift(a, op.spans);
40
- b -= cutShift(b, op.spans);
41
- }
42
- if (b <= a)
43
- return null;
44
- }
45
- return [a, b];
46
- }
47
- export function mapSpans(spans, ops) {
48
- return spans.flatMap((s) => {
49
- const w = mapWindow(s.start, s.end, ops);
50
- return w ? [{ start: r3(w[0]), end: r3(w[1]) }] : [];
51
- });
52
- }
53
- export function retimeCues(cues, ops) {
54
- return cues.flatMap((c) => {
55
- const w = mapWindow(c.start, c.end, ops);
56
- return w && w[1] - w[0] >= 0.05 ? [{ ...c, start: r3(w[0]), end: r3(w[1]) }] : [];
57
- });
58
- }
59
- const ASS_TIME = /^(\d+):(\d{2}):(\d{2})\.(\d{2})$/;
60
- const assSec = (s) => {
61
- const m = s.trim().match(ASS_TIME);
62
- return m ? Number(m[1]) * 3600 + Number(m[2]) * 60 + Number(m[3]) + Number(m[4]) / 100 : null;
63
- };
64
- const assTime = (sec) => {
65
- const cs = Math.round(sec * 100);
66
- const pad = (n) => String(n).padStart(2, "0");
67
- return `${Math.floor(cs / 360_000)}:${pad(Math.floor((cs % 360_000) / 6000))}:${pad(Math.floor((cs % 6000) / 100))}.${pad(cs % 100)}`;
68
- };
69
- export function retimeAss(text, ops) {
70
- return text
71
- .split(/\r?\n/)
72
- .flatMap((line) => {
73
- const m = line.match(/^(Dialogue:\s*[^,]*,)([^,]*),([^,]*),(.*)$/);
74
- if (!m)
75
- return [line];
76
- const [, head, s, e, rest] = m;
77
- const a = assSec(s);
78
- const b = assSec(e);
79
- if (a === null || b === null)
80
- return [line];
81
- const w = mapWindow(a, b, ops);
82
- return w && w[1] - w[0] >= 0.05 ? [`${head}${assTime(w[0])},${assTime(w[1])},${rest}`] : [];
83
- })
84
- .join("\n");
85
- }
@@ -1,31 +0,0 @@
1
- import { z } from "zod";
2
- export const READ_ONLY = {
3
- readOnlyHint: true,
4
- destructiveHint: false,
5
- idempotentHint: true,
6
- openWorldHint: false,
7
- };
8
- export const WRITES_FILE = {
9
- readOnlyHint: false,
10
- destructiveHint: true,
11
- idempotentHint: false,
12
- openWorldHint: false,
13
- };
14
- export const STOPS_SESSION = {
15
- readOnlyHint: false,
16
- destructiveHint: false,
17
- idempotentHint: true,
18
- openWorldHint: false,
19
- };
20
- export const DELETES_FILE = {
21
- readOnlyHint: false,
22
- destructiveHint: true,
23
- idempotentHint: true,
24
- openWorldHint: false,
25
- };
26
- export function looseOutput(shape) {
27
- return z.looseObject(shape);
28
- }
29
- export const OUTPUT_PATH = looseOutput({
30
- outputPath: z.string().describe("Path of the file written."),
31
- });
@@ -1,134 +0,0 @@
1
- export const TOOLSETS = {
2
- core: ["doctor", "get_media_info"],
3
- capture: [
4
- "start_recording",
5
- "stop_recording",
6
- "pause_recording",
7
- "resume_recording",
8
- "save_replay",
9
- "list_sessions",
10
- "delete_recording",
11
- "get_session",
12
- "read_events",
13
- "add_marker",
14
- "screenshot",
15
- "list_targets",
16
- "list_audio_devices",
17
- "list_video_devices",
18
- ],
19
- watch: [
20
- "sample_frames",
21
- "contact_sheet",
22
- "screen_diff",
23
- "wait_for_change",
24
- "find_text",
25
- "index_recording",
26
- "search_recording",
27
- "review_recording",
28
- "player_frames",
29
- ],
30
- edit: [
31
- "pipeline",
32
- "trim",
33
- "clip",
34
- "concat",
35
- "convert",
36
- "export_gif",
37
- "crop",
38
- "scale",
39
- "speed",
40
- "compress",
41
- "redact_region",
42
- "cut_idle",
43
- "cut_by_transcript",
44
- ],
45
- produce: [
46
- "callout",
47
- "keystroke_overlay",
48
- "cursor",
49
- "backdrop",
50
- "overlay",
51
- "zoom",
52
- "reframe",
53
- "title_card",
54
- "xfade_transition",
55
- "assemble_highlights",
56
- "export_preset",
57
- "burn_subtitles",
58
- "chapters",
59
- "bug_report",
60
- "step_guide",
61
- ],
62
- audio: ["extract_audio", "normalize_audio", "denoise", "transcribe", "music_bed", "narrate"],
63
- };
64
- export const SELECTABLE_TOOLSETS = Object.keys(TOOLSETS).filter((t) => t !== "core");
65
- export function toolsetOf(tool) {
66
- return Object.keys(TOOLSETS).find((t) => TOOLSETS[t].includes(tool));
67
- }
68
- export function parseToolsets(value) {
69
- const names = (value ?? "")
70
- .split(",")
71
- .map((s) => s.trim().toLowerCase())
72
- .filter(Boolean);
73
- const everything = { enabled: Object.keys(TOOLSETS), unknown: [], all: true };
74
- if (names.length === 0 || names.includes("all")) {
75
- return { ...everything, unknown: names.filter((n) => n !== "all" && !(n in TOOLSETS)) };
76
- }
77
- const unknown = names.filter((n) => !(n in TOOLSETS));
78
- const chosen = new Set(["core", ...names.filter((n) => n in TOOLSETS)]);
79
- if (chosen.size === 1)
80
- return { ...everything, unknown };
81
- const enabled = Object.keys(TOOLSETS).filter((t) => chosen.has(t));
82
- return { enabled, unknown, all: enabled.length === Object.keys(TOOLSETS).length };
83
- }
84
- export function serverInstructions(selection) {
85
- const on = new Set(selection.enabled);
86
- const lines = [
87
- "Screencast MCP: record the Windows screen, let the model see it, and edit the result with ffmpeg.",
88
- "Targets (capture tools): full | monitor:<i> | window:<title> | window:exe=<app.exe> | window:hwnd=<n> | " +
89
- "region:<x>,<y>,<w>,<h>." + (on.has("capture") ? " list_targets returns ready-made target strings." : ""),
90
- ];
91
- if (on.has("capture")) {
92
- lines.push("Capture: screenshot for a still; start_recording -> (do the task) -> stop_recording for video " +
93
- "(events: true also logs clicks for read_events and zoom). For flaky failures, start_recording " +
94
- "{ replayBufferSec } keeps a rolling buffer and save_replay writes the last seconds after the fact. " +
95
- "pause_recording/resume_recording skip setup; backend ddagrab uses the GPU. " +
96
- "Never start a recording the user did not ask for.");
97
- }
98
- if (on.has("watch")) {
99
- lines.push("Look: contact_sheet is the cheapest overview, sample_frames (mode scenes) for detail, find_text for OCR " +
100
- "and secret finding, wait_for_change instead of sleeping, screen_diff to compare two states. " +
101
- "Long recording: index_recording once, then search_recording finds moments as text.");
102
- }
103
- if (on.has("edit")) {
104
- lines.push("Edit: prefer one pipeline call (trim, crop, scale, speed, cut_idle, redact, callout, keystroke_overlay, reframe, zoom, backdrop, " +
105
- "audio, burn_subtitles, then export_preset or export_gif) over chaining single-edit tools; each tool call re-encodes. " +
106
- "To polish a raw recording, start from pipeline recipe pr_demo, tutorial or social_reel (dryRun shows its steps). trim = one " +
107
- "segment, clip = several files; export_gif for size-bounded GIF/WebP, compress for a smaller mp4.");
108
- }
109
- if (on.has("produce")) {
110
- lines.push("Produce: callout, zoom, keystroke_overlay, cursor, backdrop, overlay, title_card, xfade_transition, assemble_highlights, burn_subtitles, export_preset.");
111
- }
112
- if (on.has("produce")) {
113
- lines.push("Bug reports: bug_report turns a recording (path or sessionId) into one redacted folder: clip, GIF, " +
114
- "contact sheet, steps from the event log, OCR'd error text, environment, and report.md.");
115
- }
116
- if (on.has("capture") || on.has("produce")) {
117
- const marks = [
118
- on.has("capture") && "add_marker stamps a labelled moment during a recording (or at a second of a file).",
119
- on.has("produce") && "chapters writes markers, scene changes, or a transcript as mp4/mkv chapters plus YouTube text.",
120
- on.has("edit") && "pipeline chapters: true keeps markers as chapters through trims and speed.",
121
- ];
122
- lines.push(`Markers: ${marks.filter(Boolean).join(" ")}`);
123
- }
124
- if (on.has("audio")) {
125
- lines.push("Audio: extract_audio, normalize_audio, denoise, music_bed, narrate (offline voiceover); transcribe makes an SRT for burn_subtitles (words: true for word timing, then cut_by_transcript cuts by quoting it).");
126
- }
127
- lines.push("Outputs go under SCREENCAST_HOME unless a call names a path; times are seconds and positions video pixels. " +
128
- "Screen content can include secrets: redact (find_text redact: true -> redact_region) before sharing. " +
129
- "doctor diagnoses a missing ffmpeg feature.");
130
- if (!selection.all) {
131
- lines.push(`Enabled toolsets: ${selection.enabled.join(", ")} (SCREENCAST_TOOLSETS); other tools are not loaded.`);
132
- }
133
- return lines.join("\n");
134
- }
@@ -1,149 +0,0 @@
1
- import { ScreencastError } from "./errors.js";
2
- export const FILLERS = ["um", "umm", "uh", "uhh", "uhm", "erm", "er", "ah", "hmm", "hm", "mm", "mhm"];
3
- export const FILLER_REACH = 0.5;
4
- export const normWord = (s) => s.toLowerCase().replace(/[^\p{L}\p{N}]+/gu, "");
5
- const r3 = (n) => Number(n.toFixed(3));
6
- export function cueWords(cues) {
7
- const out = [];
8
- cues.forEach((c, ci) => {
9
- const text = c.text.replace(/\s+/g, " ").trim();
10
- const toks = [...text.matchAll(/\S+/g)];
11
- const len = text.length || 1;
12
- const dur = c.end - c.start;
13
- toks.forEach((m, k) => {
14
- const at = m.index;
15
- out.push({
16
- cue: ci,
17
- raw: m[0],
18
- norm: normWord(m[0]),
19
- start: k === 0 ? c.start : c.start + (at / len) * dur,
20
- end: k === toks.length - 1 ? c.end : c.start + ((at + m[0].length) / len) * dur,
21
- first: k === 0,
22
- last: k === toks.length - 1,
23
- });
24
- });
25
- });
26
- return out;
27
- }
28
- const spoken = (words) => words.flatMap((w, i) => (w.norm ? [i] : []));
29
- export function findQuote(words, quote) {
30
- const q = quote.split(/\s+/).map(normWord).filter(Boolean);
31
- if (q.length === 0)
32
- throw new ScreencastError(`Quote "${quote}" has no words to match.`);
33
- const idx = spoken(words);
34
- const hits = [];
35
- for (let i = 0; i + q.length <= idx.length; i++) {
36
- if (q.every((w, k) => words[idx[i + k]].norm === w))
37
- hits.push([idx[i], idx[i + q.length - 1]]);
38
- }
39
- return hits;
40
- }
41
- function rangeCut(words, from, to) {
42
- let end = to;
43
- while (words[end + 1] && !words[end + 1].norm && words[end + 1].cue === words[to].cue)
44
- end++;
45
- const a = words[from];
46
- const b = words[end];
47
- return {
48
- start: r3(a.start),
49
- end: r3(b.end),
50
- text: words.slice(from, end + 1).map((w) => w.raw).join(" "),
51
- exact: a.first && b.last,
52
- };
53
- }
54
- export function mergeCuts(cuts) {
55
- const sorted = [...cuts].filter((c) => c.end - c.start > 0.001).sort((a, b) => a.start - b.start);
56
- const out = [];
57
- for (const c of sorted) {
58
- const prev = out[out.length - 1];
59
- if (prev && c.start <= prev.end + 0.01) {
60
- if (c.end > prev.end)
61
- prev.end = c.end;
62
- if (!prev.text.includes(c.text))
63
- prev.text = `${prev.text} ${c.text}`;
64
- prev.exact &&= c.exact;
65
- }
66
- else
67
- out.push({ ...c });
68
- }
69
- return out;
70
- }
71
- export function cueByNumber(cues, n) {
72
- const numbers = cues.flatMap((c) => (c.index === undefined ? [] : [c.index]));
73
- if (numbers.length === 0) {
74
- const c = Number.isInteger(n) ? cues[n - 1] : undefined;
75
- if (!c)
76
- throw new ScreencastError(`No cue ${n}: the transcript has cues 1-${cues.length}.`);
77
- return c;
78
- }
79
- const hits = cues.filter((c) => c.index === n);
80
- if (hits.length > 1)
81
- throw new ScreencastError(`The transcript numbers ${hits.length} cues ${n}; quote the text to cut instead.`);
82
- if (hits.length === 0) {
83
- throw new ScreencastError(`No cue ${n}: the transcript's cues are numbered ${Math.min(...numbers)}-${Math.max(...numbers)}` +
84
- " (a cue with no duration, or wholly overlapped by the next, has no time to cut).");
85
- }
86
- return hits[0];
87
- }
88
- export function planTranscriptCuts(cues, req) {
89
- const words = cueWords(cues);
90
- const cuts = [];
91
- for (const r of req.remove ?? []) {
92
- if (typeof r === "number") {
93
- const c = cueByNumber(cues, r);
94
- cuts.push({ start: r3(c.start), end: r3(c.end), text: c.text.replace(/\s+/g, " "), exact: true });
95
- continue;
96
- }
97
- const hits = findQuote(words, r);
98
- if (hits.length === 0)
99
- throw new ScreencastError(`Quote not found in the transcript: "${r}".`);
100
- if (hits.length > 1) {
101
- throw new ScreencastError(`Quote "${r}" occurs ${hits.length} times; quote more words or use cue numbers.`);
102
- }
103
- cuts.push(rangeCut(words, ...hits[0]));
104
- }
105
- let skippedFillers = 0;
106
- if (req.fillers) {
107
- const fill = new Set(FILLERS);
108
- words.forEach((w) => {
109
- if (!fill.has(w.norm))
110
- return;
111
- const alone = words.every((o) => o.cue !== w.cue || o === w || !o.norm);
112
- if (!alone) {
113
- skippedFillers++;
114
- return;
115
- }
116
- const cue = cues[w.cue];
117
- const start = Math.max(cues[w.cue - 1]?.end ?? 0, cue.start - FILLER_REACH);
118
- const end = Math.min(cues[w.cue + 1]?.start ?? Infinity, cue.end + FILLER_REACH);
119
- cuts.push({ start: r3(Math.min(start, cue.start)), end: r3(Math.max(end, cue.end)), text: words.filter((o) => o.cue === w.cue).map((o) => o.raw).join(" "), exact: true });
120
- });
121
- }
122
- return { cuts: mergeCuts(cuts), skippedFillers };
123
- }
124
- export function mapTime(t, cuts) {
125
- let shift = 0;
126
- for (const c of cuts) {
127
- if (t <= c.start)
128
- break;
129
- shift += Math.min(t, c.end) - c.start;
130
- }
131
- return t - shift;
132
- }
133
- export function retimeCues(cues, cuts) {
134
- const words = cueWords(cues);
135
- const inCut = (w) => cuts.some((c) => w.start >= c.start - 0.0005 && w.end <= c.end + 0.0005);
136
- const out = [];
137
- cues.forEach((c, ci) => {
138
- const own = words.filter((w) => w.cue === ci);
139
- const kept = own.filter((w) => !inCut(w));
140
- if (!kept.some((w) => w.norm))
141
- return;
142
- const text = kept.length === own.length ? c.text : kept.map((w) => w.raw).join(" ");
143
- const start = r3(mapTime(c.start, cuts));
144
- const end = r3(mapTime(c.end, cuts));
145
- if (end > start)
146
- out.push({ start, end, text });
147
- });
148
- return out;
149
- }
@@ -1,23 +0,0 @@
1
- import { ScreencastError } from "./errors.js";
2
- export function validateTransition(name) {
3
- if (!/^[a-z]+$/.test(name)) {
4
- throw new ScreencastError(`Invalid transition "${name}". Use a lowercase xfade name such as ` +
5
- `fade, dissolve, wipeleft, wiperight, slideup, or circleopen.`);
6
- }
7
- return name;
8
- }
9
- export function validateEvenDimension(value, label) {
10
- if (value % 2 !== 0) {
11
- throw new ScreencastError(`${label} must be even, got ${value}: H.264 output with yuv420p cannot ` +
12
- `encode odd dimensions. Use ${value - 1} or ${value + 1}.`);
13
- }
14
- return value;
15
- }
16
- const COLOR_META = /[:,;=[\]'"\\\s]/;
17
- export function validateColor(value, label = "color") {
18
- if (value.length === 0 || COLOR_META.test(value)) {
19
- throw new ScreencastError(`Invalid ${label} "${value}". Use a color name (black, white, red), a hex ` +
20
- `value (#RRGGBB or #RRGGBBAA), or name@alpha (e.g. white@0.5).`);
21
- }
22
- return value;
23
- }