@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,89 +0,0 @@
1
- import { z } from "zod";
2
- import { existsSync } from "node:fs";
3
- import { extname } from "node:path";
4
- import { errorResponse, okResponse, ScreencastError } from "../utils/errors.js";
5
- import { WRITES_FILE, looseOutput } from "../utils/toolSpec.js";
6
- import { requireFfmpeg, probeMedia } from "../utils/ffmpeg.js";
7
- import { runEditJob } from "../utils/jobs.js";
8
- import { buildBackdropArgs, BACKDROP_PRESET_NAMES, MAX_BACKDROP_COLORS } from "../utils/backdrop.js";
9
- import { editOutputExt, assertEditContainer } from "../utils/media.js";
10
- import { resolveOutput, subdir, stamp, rand } from "../utils/paths.js";
11
- const STILL = /\.(png|jpe?g|bmp|tiff?|webp)$/i;
12
- export const backdropOptionsSchema = {
13
- preset: z.enum(BACKDROP_PRESET_NAMES).optional(),
14
- colors: z.array(z.string()).min(1).max(MAX_BACKDROP_COLORS).optional(),
15
- image: z.string().min(1).optional(),
16
- padding: z.number().int().nonnegative().max(2000).optional(),
17
- radius: z.number().int().nonnegative().max(1000).optional(),
18
- shadow: z.number().int().nonnegative().max(200).optional(),
19
- shadowOpacity: z.number().min(0).max(1).optional(),
20
- aspect: z.enum(["16:9", "9:16", "1:1", "4:5"]).optional(),
21
- };
22
- const o = backdropOptionsSchema;
23
- const inputSchema = {
24
- input: z.string().min(1).describe("Path to the source video or image (png/jpg)."),
25
- preset: o.preset.describe("Gradient: desktop (default, dark slate), rec (red), amber, light."),
26
- colors: o.colors.describe("Instead: 1 color = solid, 2-4 = diagonal gradient."),
27
- image: o.image.describe("Instead: a wallpaper image, scaled to cover."),
28
- padding: o.padding.describe("px around the content (default 6% of the longer side)."),
29
- radius: o.radius.describe("Corner radius px (default ~1.2% of the longer side; 0 = square)."),
30
- shadow: o.shadow.describe("Shadow blur px (default ~2.5%; 0 = none)."),
31
- shadowOpacity: o.shadowOpacity.describe("Default 0.5."),
32
- aspect: o.aspect.describe("Output on this aspect's canvas (1920x1080, ...), content scaled to fit."),
33
- output: z.string().optional().describe("Optional output path. Defaults under SCREENCAST_HOME/edits (screenshots for an image)."),
34
- overwrite: z.boolean().optional().describe("Allow replacing an existing file at the output path (default false)."),
35
- };
36
- export function register(server) {
37
- server.registerTool("backdrop", {
38
- title: "Add Backdrop",
39
- description: "Frame a video or screenshot on a gradient, color, or wallpaper with padding, rounded corners, " +
40
- "and a drop shadow, optionally on a 16:9/1:1/9:16/4:5 canvas.",
41
- inputSchema,
42
- outputSchema: looseOutput({ outputPath: z.string(), width: z.number().int(), height: z.number().int() }),
43
- annotations: WRITES_FILE,
44
- }, async (args, extra) => {
45
- try {
46
- requireFfmpeg();
47
- if (!existsSync(args.input))
48
- throw new ScreencastError(`Input file not found: ${args.input}`);
49
- if (args.image && !existsSync(args.image))
50
- throw new ScreencastError(`Background image not found: ${args.image}`);
51
- const still = STILL.test(args.input);
52
- if (still && args.output && !STILL.test(args.output)) {
53
- throw new ScreencastError("An image input writes an image: give the output a .png or .jpg extension.");
54
- }
55
- if (!still)
56
- assertEditContainer(args.output);
57
- const info = await probeMedia(args.input);
58
- if (!info.width || !info.height)
59
- throw new ScreencastError(`Could not read the size of ${args.input}.`);
60
- const ext = still ? (/\.jpe?g$/i.test(args.input) ? extname(args.input).toLowerCase() : ".png") : editOutputExt(args.input);
61
- const output = resolveOutput(args.output, subdir(still ? "screenshots" : "edits"), `backdrop-${stamp()}-${rand()}${ext}`, args.overwrite);
62
- const opts = {
63
- preset: args.preset,
64
- colors: args.colors,
65
- image: args.image,
66
- padding: args.padding,
67
- radius: args.radius,
68
- shadow: args.shadow,
69
- shadowOpacity: args.shadowOpacity,
70
- aspect: args.aspect,
71
- };
72
- const { args: ffArgs, layout } = buildBackdropArgs(args.input, output, opts, { width: info.width, height: info.height }, still);
73
- await runEditJob(ffArgs, { output, durationSec: still ? null : info.durationSec, extra });
74
- return okResponse({
75
- outputPath: output,
76
- width: layout.canvasW,
77
- height: layout.canvasH,
78
- content: { x: layout.x, y: layout.y, width: layout.contentW, height: layout.contentH },
79
- padding: layout.padding,
80
- radius: layout.radius,
81
- shadow: layout.shadow,
82
- background: args.image ? "image" : args.colors ? "colors" : (args.preset ?? "desktop"),
83
- });
84
- }
85
- catch (error) {
86
- return errorResponse(error);
87
- }
88
- });
89
- }
@@ -1,266 +0,0 @@
1
- import { z } from "zod";
2
- import { createRequire } from "node:module";
3
- import { existsSync, mkdirSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from "node:fs";
4
- import { tmpdir, release, version as osVersion } from "node:os";
5
- import { join } from "node:path";
6
- import { errorResponse, okResponse, ScreencastError } from "../utils/errors.js";
7
- import { WRITES_FILE, looseOutput } from "../utils/toolSpec.js";
8
- import { requireFfmpeg, probeMedia } from "../utils/ffmpeg.js";
9
- import { runEditJob } from "../utils/jobs.js";
10
- import { planPipeline } from "../utils/pipeline.js";
11
- import { exportAnimation } from "../utils/animExport.js";
12
- import { DEFAULT_MAX_BYTES } from "../utils/anim.js";
13
- import { evenTimes, DEFAULT_SHEET_COUNT, DEFAULT_TILE_WIDTH } from "../utils/sheet.js";
14
- import { scanVideoFrames, scanMatches } from "../utils/ocrScan.js";
15
- import { eventPaths, parseEventsJsonl, whenFinalized } from "../utils/events.js";
16
- import { ocrStatus, parseFfmpegVersion, versionText } from "../utils/capabilities.js";
17
- import { getMonitors } from "../utils/monitors.js";
18
- import { resolveOutputDir, subdir, stamp, rand } from "../utils/paths.js";
19
- import { encodeInlineImages, DEFAULT_MAX_IMAGE_WIDTH } from "../utils/images.js";
20
- import { getStore } from "../context.js";
21
- import { redactRegionSchema } from "./redactRegion.js";
22
- import { renderContactSheet } from "./contactSheet.js";
23
- import { DEFAULT_SCAN_FRAMES, MAX_SCAN_FRAMES } from "./findText.js";
24
- import { DEFAULT_CLIP_SEC, DEFAULT_ERROR_PATTERN, DEFAULT_SCAN_EVERY_SEC, DEFAULT_SECRET_PATTERN, MAX_CLIP_SEC, MAX_STEPS, REPORT_FILES, buildReportMarkdown, clipWindow, errorFindings, maskSecrets, mergeRedactions, reconstructSteps, } from "../utils/bugReport.js";
25
- const { version: serverVersion } = createRequire(import.meta.url)("../../package.json");
26
- const inputSchema = {
27
- input: z.string().min(1).optional().describe("Recording path (uses its .events.jsonl)."),
28
- sessionId: z.string().min(1).optional().describe("Or a stopped session's id."),
29
- title: z.string().max(200).optional().describe("Issue title."),
30
- actual: z.string().max(4000).optional().describe("What happened."),
31
- expected: z.string().max(4000).optional().describe("What should happen."),
32
- start: z.number().nonnegative().optional().describe("Clip start s (default: end - clipSec)."),
33
- end: z.number().positive().optional().describe("Clip end s (default: recording end)."),
34
- clipSec: z.number().positive().max(MAX_CLIP_SEC).optional().describe(`Clip length without start (default ${DEFAULT_CLIP_SEC}).`),
35
- redact: z.boolean().optional().describe("Box out OCR-found secrets in every output (default true; needs Windows OCR)."),
36
- secretPattern: z.string().optional().describe("Secret regex (default: API keys, tokens, password: values)."),
37
- regions: z.array(redactRegionSchema).optional().describe("Extra boxes (video px; start/end on the clip clock)."),
38
- errorPattern: z.string().optional().describe("Error-line regex."),
39
- scanEverySec: z.number().positive().optional().describe(`OCR every N s (default ${DEFAULT_SCAN_EVERY_SEC}).`),
40
- maxFrames: z.number().int().min(1).max(MAX_SCAN_FRAMES).optional().describe(`Scan frame cap (default ${DEFAULT_SCAN_FRAMES}).`),
41
- gif: z.boolean().optional().describe("Also export a GIF (default true)."),
42
- maxBytes: z.number().int().min(10_000).optional().describe(`GIF size budget (default ${DEFAULT_MAX_BYTES}).`),
43
- outputDir: z.string().optional().describe("Package folder (default: a new one in SCREENCAST_HOME/edits)."),
44
- overwrite: z.boolean().optional().describe("Replace a report already in outputDir."),
45
- };
46
- const r3 = (n) => Math.round(n * 1000) / 1000;
47
- export async function resolveSource(args) {
48
- if (args.sessionId !== undefined) {
49
- const record = getStore().get(args.sessionId);
50
- if (!record)
51
- throw new ScreencastError(`No session with id "${args.sessionId}".`);
52
- if (record.status === "recording" || record.status === "paused") {
53
- throw new ScreencastError("The recording is still running; stop_recording it first.");
54
- }
55
- await whenFinalized(record.id);
56
- if (!existsSync(record.outputPath))
57
- throw new ScreencastError(`The session's recording is missing: ${record.outputPath}`);
58
- const events = record.events?.path;
59
- return { path: record.outputPath, eventsPath: events && existsSync(events) ? events : null, record };
60
- }
61
- const path = args.input;
62
- if (!existsSync(path))
63
- throw new ScreencastError(`Input file not found: ${path}`);
64
- const { jsonl } = eventPaths(path);
65
- return { path, eventsPath: existsSync(jsonl) ? jsonl : null };
66
- }
67
- async function displayRows() {
68
- if (process.platform !== "win32")
69
- return null;
70
- try {
71
- const monitors = await getMonitors();
72
- return monitors
73
- .map((m) => `${m.width}x${m.height}${m.dpi ? ` @${Math.round((m.dpi / 96) * 100)}%` : ""}${m.primary ? " (primary)" : ""}`)
74
- .join(", ");
75
- }
76
- catch {
77
- return null;
78
- }
79
- }
80
- export function register(server) {
81
- server.registerTool("bug_report", {
82
- title: "Bug Report Package",
83
- description: "Package a recording as a paste-ready repro folder: secret-scanned, redacted clip and GIF, contact " +
84
- "sheet, steps from the event log, OCR'd errors, environment, report.md for gh issue create --body-file.",
85
- inputSchema,
86
- outputSchema: looseOutput({
87
- outputDir: z.string(),
88
- reportPath: z.string(),
89
- jsonPath: z.string(),
90
- clipPath: z.string(),
91
- }),
92
- annotations: WRITES_FILE,
93
- }, async (args, extra) => {
94
- let createdDir = null;
95
- const written = [];
96
- try {
97
- if ((args.input === undefined) === (args.sessionId === undefined)) {
98
- throw new ScreencastError("Provide exactly one of: input (a recording path) or sessionId.");
99
- }
100
- const { ffmpeg } = requireFfmpeg();
101
- const source = await resolveSource(args);
102
- const info = await probeMedia(source.path);
103
- if (!info.width || !info.height)
104
- throw new ScreencastError(`Could not read the size of ${source.path}.`);
105
- const duration = info.videoDurationSec ?? info.durationSec;
106
- if (duration === null)
107
- throw new ScreencastError(`Could not read the duration of ${source.path}.`);
108
- const window = clipWindow(duration, args);
109
- const clipLen = r3(window.end - window.start);
110
- const redact = args.redact !== false;
111
- const secretPattern = args.secretPattern ?? DEFAULT_SECRET_PATTERN;
112
- maskSecrets(["x"], secretPattern);
113
- if (args.errorPattern !== undefined)
114
- maskSecrets(["x"], args.errorPattern);
115
- const format = "gif";
116
- const dir = resolveOutputDir(args.outputDir, subdir("edits")) ?? join(subdir("edits"), `bug-report-${stamp()}-${rand()}`);
117
- const paths = {
118
- markdown: join(dir, REPORT_FILES.markdown),
119
- json: join(dir, REPORT_FILES.json),
120
- clip: join(dir, REPORT_FILES.clip),
121
- gif: join(dir, REPORT_FILES.gif(format)),
122
- sheet: join(dir, REPORT_FILES.contactSheet),
123
- };
124
- const clash = Object.values(paths).filter((p) => existsSync(p));
125
- if (clash.length > 0 && !args.overwrite) {
126
- throw new ScreencastError(`The folder already holds a report: ${clash.join(", ")}. Pass overwrite: true to replace it, or choose another outputDir.`);
127
- }
128
- if (!existsSync(dir)) {
129
- mkdirSync(dir, { recursive: true });
130
- createdDir = dir;
131
- }
132
- const warnings = [];
133
- const work = mkdtempSync(join(tmpdir(), "screencast-bug-"));
134
- try {
135
- let ocr = "unavailable";
136
- let scan = null;
137
- const status = await ocrStatus();
138
- if (status.available) {
139
- scan = await scanVideoFrames(source.path, {
140
- everySec: args.scanEverySec ?? DEFAULT_SCAN_EVERY_SEC,
141
- maxFrames: args.maxFrames ?? DEFAULT_SCAN_FRAMES,
142
- range: { start: window.start, duration: clipLen },
143
- }, work, extra.signal);
144
- ocr = "read";
145
- }
146
- else if (redact) {
147
- throw new ScreencastError(`The secret scan needs Windows OCR, which is unavailable here${status.error ? ` (${status.error})` : ""}.`, "Pass redact: false to package without it (then check the clip yourself before sharing), or run doctor.");
148
- }
149
- else {
150
- warnings.push("Windows OCR is unavailable, so no error text was read.");
151
- }
152
- const found = scan && redact ? mergeRedactions(scanMatches(scan, secretPattern, true, "line").redactRegions) : [];
153
- const regions = [...found, ...(args.regions ?? [])];
154
- const errors = scan ? errorFindings(scan.frames, args.errorPattern ?? DEFAULT_ERROR_PATTERN, redact ? secretPattern : null) : [];
155
- extra.signal.throwIfAborted();
156
- const steps = [
157
- { op: "trim", start: window.start, end: window.end },
158
- ...(regions.length > 0 ? [{ op: "redact", regions, style: "box" }] : []),
159
- ];
160
- const plan = planPipeline(source.path, paths.clip, steps, {
161
- width: info.width,
162
- height: info.height,
163
- fps: info.fps ?? 30,
164
- durationSec: info.durationSec,
165
- hasAudio: info.audioCodec !== null,
166
- });
167
- await runEditJob(plan.args, { output: paths.clip, durationSec: plan.durationSec, inputDurationSec: clipLen, extra });
168
- written.push(paths.clip);
169
- let anim = null;
170
- if (args.gif !== false) {
171
- anim = await exportAnimation(paths.clip, paths.gif, { format, maxBytes: args.maxBytes ?? DEFAULT_MAX_BYTES }, extra);
172
- written.push(paths.gif);
173
- if (anim.note)
174
- warnings.push(anim.note);
175
- }
176
- await renderContactSheet(paths.clip, evenTimes(clipLen, DEFAULT_SHEET_COUNT), paths.sheet, { tileWidth: DEFAULT_TILE_WIDTH }, extra.signal);
177
- written.push(paths.sheet);
178
- const allSteps = source.eventsPath ? reconstructSteps(parseEventsJsonl(readFileSync(source.eventsPath, "utf8"))) : [];
179
- const stepsNote = source.eventsPath
180
- ? allSteps.length === 0
181
- ? "The event log has no clicks, shortcuts, typing, or scrolls."
182
- : undefined
183
- : "The recording has no input event log (record with start_recording events: true).";
184
- const ff = parseFfmpegVersion(versionText(ffmpeg) ?? "");
185
- const displays = await displayRows();
186
- const record = source.record;
187
- const mask = (s) => (redact ? (maskSecrets([s], secretPattern)[0] ?? s) : s);
188
- const environment = [
189
- ["OS", `${osVersion()} (${release()}), ${process.arch}`],
190
- ...(displays ? [["Displays", displays]] : []),
191
- ...(record ? [["Recorded target", mask(record.target)]] : []),
192
- ...(record?.matchedWindow ? [["Window", mask(record.matchedWindow)]] : []),
193
- ...(record?.backend ? [["Capture backend", record.backend]] : []),
194
- [
195
- "Recording",
196
- `${info.width}x${info.height}${info.fps ? ` @ ${Math.round(info.fps * 100) / 100} fps` : ""}, ` +
197
- `${r3(duration)} s${info.videoCodec ? `, ${info.videoCodec}` : ""}`,
198
- ],
199
- ["ffmpeg", ff.version ?? "unknown"],
200
- ["screencast-mcp", `${serverVersion} (Node ${process.version})`],
201
- ];
202
- const data = {
203
- title: args.title?.trim() || "Bug report",
204
- ...(args.expected ? { expected: args.expected } : {}),
205
- ...(args.actual ? { actual: args.actual } : {}),
206
- createdAt: new Date().toISOString(),
207
- clip: { start: window.start, end: window.end, recordingDurationSec: r3(duration), width: info.width, height: info.height },
208
- files: {
209
- clip: REPORT_FILES.clip,
210
- ...(anim ? { gif: REPORT_FILES.gif(format) } : {}),
211
- contactSheet: REPORT_FILES.contactSheet,
212
- },
213
- ...(anim ? { gif: { format, sizeBytes: anim.sizeBytes, withinBudget: anim.withinBudget } } : {}),
214
- steps: allSteps.slice(0, MAX_STEPS),
215
- ...(allSteps.length > MAX_STEPS ? { stepsOmitted: allSteps.length - MAX_STEPS } : {}),
216
- ...(stepsNote ? { stepsNote } : {}),
217
- errors,
218
- ocr,
219
- redaction: {
220
- scanned: scan !== null && redact,
221
- ...(scan && redact ? { everySec: r3(scan.step), framesScanned: scan.frames.length } : {}),
222
- found: found.length,
223
- manual: args.regions?.length ?? 0,
224
- },
225
- environment,
226
- };
227
- writeFileSync(paths.markdown, buildReportMarkdown(data));
228
- written.push(paths.markdown);
229
- writeFileSync(paths.json, JSON.stringify({ ...data, steps: allSteps, redaction: { ...data.redaction, regions } }, null, 2) + "\n");
230
- written.push(paths.json);
231
- if (scan?.clamped) {
232
- warnings.push(`The scan interval was widened to ${r3(scan.step)} s to fit maxFrames.`);
233
- }
234
- const { images } = await encodeInlineImages([paths.sheet], DEFAULT_MAX_IMAGE_WIDTH, 1);
235
- return okResponse({
236
- outputDir: dir,
237
- reportPath: paths.markdown,
238
- jsonPath: paths.json,
239
- clipPath: paths.clip,
240
- ...(anim ? { gifPath: paths.gif, gifSizeBytes: anim.sizeBytes, gifWithinBudget: anim.withinBudget } : {}),
241
- contactSheetPath: paths.sheet,
242
- clip: { start: window.start, end: window.end },
243
- steps: allSteps.length,
244
- errors: errors.map((e) => e.text),
245
- ocr,
246
- redaction: data.redaction,
247
- ...(warnings.length > 0 ? { warnings } : {}),
248
- next: `Review the clip and report.md, then: gh issue create --title ${JSON.stringify(data.title)} ` +
249
- `--body-file ${JSON.stringify(paths.markdown)} and drag the GIF into the issue.`,
250
- note: "Redaction is OCR-based and best-effort: look at the clip before posting it anywhere public.",
251
- }, images);
252
- }
253
- finally {
254
- rmSync(work, { recursive: true, force: true });
255
- }
256
- }
257
- catch (error) {
258
- if (createdDir)
259
- rmSync(createdDir, { recursive: true, force: true });
260
- else
261
- for (const p of written)
262
- rmSync(p, { force: true });
263
- return errorResponse(error);
264
- }
265
- });
266
- }
@@ -1,56 +0,0 @@
1
- import { z } from "zod";
2
- import { dirname } from "node:path";
3
- import { existsSync } from "node:fs";
4
- import { errorResponse, okResponse, ScreencastError } from "../utils/errors.js";
5
- import { OUTPUT_PATH, WRITES_FILE } from "../utils/toolSpec.js";
6
- import { requireFfmpeg, probeMedia, hasFilter } from "../utils/ffmpeg.js";
7
- import { runEditJob } from "../utils/jobs.js";
8
- import { buildBurnSubtitlesArgs } from "../utils/captions.js";
9
- import { bundledFontPath } from "../utils/fonts.js";
10
- import { editOutputExt, assertEditContainer } from "../utils/media.js";
11
- import { resolveOutput, subdir, stamp, rand } from "../utils/paths.js";
12
- const inputSchema = {
13
- input: z.string().min(1).describe("Path to the source video."),
14
- subtitles: z.string().min(1).describe("Path to an .srt (e.g. from transcribe) or .ass subtitle file."),
15
- style: z
16
- .enum(["clean", "social"])
17
- .optional()
18
- .describe("clean (default for .srt): outlined line. social: big bold text on a dark box. .ass keeps its own " +
19
- "styling unless set."),
20
- output: z.string().optional().describe("Optional output path. Defaults under SCREENCAST_HOME/edits."),
21
- overwrite: z.boolean().optional().describe("Allow replacing an existing file at the output path (default false)."),
22
- };
23
- export function register(server) {
24
- server.registerTool("burn_subtitles", {
25
- title: "Burn In Subtitles",
26
- description: "Burn SRT/ASS subtitles (e.g. from transcribe) into a video in the bundled font.",
27
- inputSchema,
28
- outputSchema: OUTPUT_PATH,
29
- annotations: WRITES_FILE,
30
- }, async (args, extra) => {
31
- try {
32
- requireFfmpeg();
33
- for (const f of [args.input, args.subtitles]) {
34
- if (!existsSync(f))
35
- throw new ScreencastError(`File not found: ${f}`);
36
- }
37
- if (!hasFilter("subtitles")) {
38
- throw new ScreencastError("This ffmpeg has no subtitles filter (it needs libass).", "Install a full ffmpeg build, e.g. `winget install Gyan.FFmpeg`.");
39
- }
40
- assertEditContainer(args.output);
41
- const ext = editOutputExt(args.input);
42
- const output = resolveOutput(args.output, subdir("edits"), `subtitled-${stamp()}-${rand()}${ext}`, args.overwrite);
43
- const fontsDir = dirname(bundledFontPath("regular"));
44
- const style = args.style ?? (/\.(ass|ssa)$/i.test(args.subtitles) ? null : "clean");
45
- await runEditJob(buildBurnSubtitlesArgs(args.input, args.subtitles, output, fontsDir, style), {
46
- output,
47
- durationSec: (await probeMedia(args.input)).durationSec,
48
- extra,
49
- });
50
- return okResponse({ outputPath: output, style: style ?? "file" });
51
- }
52
- catch (error) {
53
- return errorResponse(error);
54
- }
55
- });
56
- }
@@ -1,103 +0,0 @@
1
- import { z } from "zod";
2
- import { join } from "node:path";
3
- import { existsSync, mkdtempSync, rmSync } from "node:fs";
4
- import { tmpdir } from "node:os";
5
- import { errorResponse, okResponse, ScreencastError } from "../utils/errors.js";
6
- import { OUTPUT_PATH, WRITES_FILE } from "../utils/toolSpec.js";
7
- import { requireFfmpeg } from "../utils/ffmpeg.js";
8
- import { runEditJob, probeDuration } from "../utils/jobs.js";
9
- import { buildCalloutArgs } from "../utils/callout.js";
10
- import { prepareCalloutAssets } from "../utils/calloutAssets.js";
11
- import { stillEdit } from "../utils/media.js";
12
- import { resolveOutput, subdir, stamp, rand } from "../utils/paths.js";
13
- const timing = {
14
- from: z.number().nonnegative().optional(),
15
- to: z.number().positive().optional(),
16
- color: z.string().optional(),
17
- };
18
- export const fontFileSchema = z
19
- .string()
20
- .min(1)
21
- .optional()
22
- .describe("Font: a .ttf/.otf/.ttc path or a C:\\Windows\\Fonts file name. Default: bundled Inter, with a " +
23
- "covering system font for scripts it lacks (CJK, emoji, Arabic, ...).");
24
- export const calloutItemSchema = z.discriminatedUnion("type", [
25
- z.object({
26
- type: z.literal("box"),
27
- x: z.number(),
28
- y: z.number(),
29
- width: z.number().positive(),
30
- height: z.number().positive(),
31
- thickness: z.number().positive().optional().describe("Outline px (default 4)."),
32
- fill: z.boolean().optional().describe("Fill instead of outline."),
33
- ...timing,
34
- }),
35
- z.object({
36
- type: z.literal("text"),
37
- x: z.number(),
38
- y: z.number(),
39
- text: z.string().min(1),
40
- size: z.number().positive().optional().describe("Font size px (default 32)."),
41
- background: z.boolean().optional().describe("Dark panel behind the text (default true)."),
42
- ...timing,
43
- }),
44
- z.object({
45
- type: z.literal("arrow"),
46
- x1: z.number(),
47
- y1: z.number(),
48
- x2: z.number().describe("Head (x2,y2) is the point the arrow points at."),
49
- y2: z.number(),
50
- thickness: z.number().positive().optional().describe("Shaft px (default 8)."),
51
- ...timing,
52
- }),
53
- ]);
54
- const inputSchema = {
55
- input: z.string().min(1).describe("Path to the source video or image (png/jpg; from/to are ignored for an image)."),
56
- items: z
57
- .array(calloutItemSchema)
58
- .min(1)
59
- .max(50)
60
- .describe("Boxes, text labels, and arrows, drawn in order (later on top), in video pixels. Each shows " +
61
- "from..to seconds (default: whole video); color is a name, #RRGGBB, or name@alpha."),
62
- fontFile: fontFileSchema,
63
- output: z.string().optional().describe("Optional output path. Defaults under SCREENCAST_HOME/edits."),
64
- overwrite: z.boolean().optional().describe("Allow replacing an existing file at the output path (default false)."),
65
- };
66
- export function register(server) {
67
- server.registerTool("callout", {
68
- title: "Add Callouts",
69
- description: "Annotate a video or screenshot with timed boxes, text labels, and arrows. Fallback fonts used are listed in " +
70
- "fallbackFonts; characters no font covers are reported in warnings.",
71
- inputSchema,
72
- outputSchema: OUTPUT_PATH,
73
- annotations: WRITES_FILE,
74
- }, async (args, extra) => {
75
- try {
76
- requireFfmpeg();
77
- if (!existsSync(args.input)) {
78
- throw new ScreencastError(`Input file not found: ${args.input}`);
79
- }
80
- const items = args.items;
81
- const { still, ext } = stillEdit(args.input, args.output);
82
- const output = resolveOutput(args.output, subdir("edits"), `callout-${stamp()}-${rand()}${ext}`, args.overwrite);
83
- const work = mkdtempSync(join(tmpdir(), "screencast-callout-"));
84
- try {
85
- const assets = await prepareCalloutAssets(items, work, "", args.fontFile);
86
- const ffArgs = buildCalloutArgs(args.input, output, items, assets, undefined, still);
87
- await runEditJob(ffArgs, { output, durationSec: still ? null : await probeDuration(args.input), extra });
88
- return okResponse({
89
- outputPath: output,
90
- callouts: items.length,
91
- ...(assets.fallbackFonts.length > 0 && { fallbackFonts: assets.fallbackFonts }),
92
- ...(assets.warnings.length > 0 && { warnings: assets.warnings }),
93
- });
94
- }
95
- finally {
96
- rmSync(work, { recursive: true, force: true });
97
- }
98
- }
99
- catch (error) {
100
- return errorResponse(error);
101
- }
102
- });
103
- }