@tmhs/screencast-mcp 0.49.1 → 0.51.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 (134) hide show
  1. package/README.md +15 -9
  2. package/dist/index.js +551 -106
  3. package/dist/wgcRecorder.js +15 -139
  4. package/package.json +9 -5
  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 -79
  16. package/dist/tools/bugReport.js +0 -243
  17. package/dist/tools/burnSubtitles.js +0 -56
  18. package/dist/tools/callout.js +0 -62
  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 -113
  24. package/dist/tools/convert.js +0 -46
  25. package/dist/tools/crop.js +0 -43
  26. package/dist/tools/cursor.js +0 -67
  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 -194
  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 -90
  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 -59
  47. package/dist/tools/overlay.js +0 -62
  48. package/dist/tools/pauseRecording.js +0 -44
  49. package/dist/tools/pipeline.js +0 -397
  50. package/dist/tools/readEvents.js +0 -98
  51. package/dist/tools/redactRegion.js +0 -62
  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 -249
  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 -142
  69. package/dist/tools/xfadeTransition.js +0 -58
  70. package/dist/tools/zoom.js +0 -134
  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 -117
  75. package/dist/utils/audioDevices.js +0 -107
  76. package/dist/utils/backdrop.js +0 -162
  77. package/dist/utils/bugReport.js +0 -195
  78. package/dist/utils/callout.js +0 -132
  79. package/dist/utils/calloutAssets.js +0 -42
  80. package/dist/utils/capabilities.js +0 -96
  81. package/dist/utils/captions.js +0 -104
  82. package/dist/utils/chapters.js +0 -227
  83. package/dist/utils/consent.js +0 -29
  84. package/dist/utils/cursor.js +0 -338
  85. package/dist/utils/diff.js +0 -186
  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/frameQueue.js +0 -50
  93. package/dist/utils/gpu.js +0 -219
  94. package/dist/utils/idle.js +0 -91
  95. package/dist/utils/images.js +0 -38
  96. package/dist/utils/jobs.js +0 -129
  97. package/dist/utils/keystrokes.js +0 -198
  98. package/dist/utils/lifecycle.js +0 -233
  99. package/dist/utils/logging.js +0 -75
  100. package/dist/utils/media.js +0 -584
  101. package/dist/utils/monitors.js +0 -124
  102. package/dist/utils/narrate.js +0 -233
  103. package/dist/utils/ocr.js +0 -222
  104. package/dist/utils/ocrScan.js +0 -93
  105. package/dist/utils/paths.js +0 -155
  106. package/dist/utils/pause.js +0 -190
  107. package/dist/utils/pipeline.js +0 -361
  108. package/dist/utils/player.js +0 -85
  109. package/dist/utils/pool.js +0 -29
  110. package/dist/utils/produce.js +0 -300
  111. package/dist/utils/recipes.js +0 -71
  112. package/dist/utils/recorder.js +0 -173
  113. package/dist/utils/recordingFiles.js +0 -32
  114. package/dist/utils/recordingIndex.js +0 -312
  115. package/dist/utils/replay.js +0 -283
  116. package/dist/utils/resolveTarget.js +0 -25
  117. package/dist/utils/retention.js +0 -48
  118. package/dist/utils/roots.js +0 -43
  119. package/dist/utils/sessions.js +0 -499
  120. package/dist/utils/sheet.js +0 -82
  121. package/dist/utils/stepGuide.js +0 -231
  122. package/dist/utils/steps.js +0 -88
  123. package/dist/utils/still.js +0 -38
  124. package/dist/utils/targetList.js +0 -64
  125. package/dist/utils/targets.js +0 -265
  126. package/dist/utils/timeline.js +0 -85
  127. package/dist/utils/toolSpec.js +0 -31
  128. package/dist/utils/toolsets.js +0 -134
  129. package/dist/utils/transcriptCut.js +0 -149
  130. package/dist/utils/validate.js +0 -23
  131. package/dist/utils/waitLoop.js +0 -50
  132. package/dist/utils/wgc.js +0 -84
  133. package/dist/utils/windows.js +0 -192
  134. package/dist/utils/zoom.js +0 -252
@@ -1,233 +0,0 @@
1
- import { rmSync, writeFileSync } from "node:fs";
2
- import { probeDuration, requireFfmpeg } from "./ffmpeg.js";
3
- import { finishReplay } from "./replay.js";
4
- import { whenFinalized } from "./events.js";
5
- import { errorMessage, ScreencastError } from "./errors.js";
6
- import { wgcStopFile } from "./wgc.js";
7
- import { encoderArgs } from "./gpu.js";
8
- import { clearPausing, endSession, finishSegments, markPausing, pauseBlocker, recordedSec, segmentDurationSec, webcamOutputPath, } from "./pause.js";
9
- import { isAlive, isOwnRecorder, killPid, } from "./sessions.js";
10
- async function waitForPidExit(pid, ms) {
11
- const deadline = Date.now() + ms;
12
- while (Date.now() < deadline && isAlive(pid)) {
13
- await new Promise((r) => setTimeout(r, 100));
14
- }
15
- }
16
- export function waitForExit(child, ms) {
17
- return new Promise((resolve) => {
18
- if (child.exitCode !== null || child.signalCode !== null)
19
- return resolve(true);
20
- const timer = setTimeout(() => resolve(false), ms);
21
- child.once("exit", () => {
22
- clearTimeout(timer);
23
- resolve(true);
24
- });
25
- });
26
- }
27
- async function quitChild(child, pid, gracefulMs) {
28
- if (!child.stdin || !child.stdin.writable)
29
- return false;
30
- child.stdin.write("q\n");
31
- child.stdin.end();
32
- const graceful = await waitForExit(child, gracefulMs);
33
- if (!graceful && pid !== null) {
34
- killPid(pid);
35
- await waitForPidExit(pid, 2000);
36
- await waitForExit(child, 2000);
37
- }
38
- return graceful;
39
- }
40
- export async function finalParts(record, ffprobe) {
41
- const seg = record.segments;
42
- if (!seg)
43
- return [];
44
- const parts = [...seg.parts];
45
- if (seg.current) {
46
- const probed = await probeDuration(seg.current.path, { ffprobe });
47
- const endMs = record.stoppedAt ? Date.parse(record.stoppedAt) : Date.now();
48
- const durationSec = segmentDurationSec(seg.current.path, probed, seg.current.startMs, endMs) ?? 0;
49
- parts.push({ ...seg.current, durationSec });
50
- }
51
- return parts;
52
- }
53
- export function needsJoin(record) {
54
- const seg = record.segments;
55
- return !!seg && (seg.parts.length > 0 || !!record.webcam);
56
- }
57
- export async function joinSegments(record, tools) {
58
- const parts = await finalParts(record, tools.ffprobe);
59
- const res = await finishSegments(record.outputPath, parts, {
60
- ffmpeg: tools.ffmpeg,
61
- webcamOutput: record.webcam ? webcamOutputPath(record.outputPath) : undefined,
62
- webcamCodec: encoderArgs(record.encoder ?? "x264", record.quality, { gpuFrames: false }),
63
- });
64
- return {
65
- patch: {
66
- segments: { parts },
67
- ...(record.webcam ? { webcam: { ...record.webcam, error: res.webcamError } } : {}),
68
- },
69
- count: parts.length,
70
- error: res.error,
71
- };
72
- }
73
- const sessionOps = new WeakMap();
74
- export function sessionOpInFlight(store, id) {
75
- return sessionOps.get(store)?.get(id)?.kind ?? null;
76
- }
77
- export function withSessionOp(store, id, kind, fn, opts = {}) {
78
- let ops = sessionOps.get(store);
79
- if (!ops)
80
- sessionOps.set(store, (ops = new Map()));
81
- const running = ops.get(id);
82
- if (running?.kind === kind)
83
- return running.promise;
84
- if (running && !opts.queue) {
85
- return Promise.reject(new ScreencastError(`Cannot ${kind} ${id}: a ${running.kind} of it is in progress.`, "Retry once it finishes (get_recording shows the session's status)."));
86
- }
87
- let start;
88
- if (running) {
89
- start = running.promise.then(() => fn(true), () => fn(true));
90
- }
91
- else {
92
- try {
93
- start = fn(false);
94
- }
95
- catch (err) {
96
- start = Promise.reject(err);
97
- }
98
- }
99
- const map = ops;
100
- const op = start.finally(() => {
101
- if (map.get(id)?.promise === op)
102
- map.delete(id);
103
- });
104
- map.set(id, { kind, promise: op });
105
- return op;
106
- }
107
- export function pauseSession(store, record, opts) {
108
- return withSessionOp(store, record.id, "pause", () => runPause(store, store.get(record.id) ?? record, opts));
109
- }
110
- async function runPause(store, record, opts) {
111
- const child = store.getChild(record.id);
112
- const blocker = pauseBlocker(record, !!child);
113
- if (blocker)
114
- throw new ScreencastError(`Cannot pause ${record.id}: ${blocker}.`);
115
- markPausing(record.id);
116
- store.markStopping(record.id);
117
- try {
118
- const pausedAt = Date.now();
119
- const graceful = await quitChild(child, record.pid, opts.gracefulMs ?? 8000);
120
- store.detachChild(record.id, child);
121
- const cur = record.segments.current;
122
- const probed = await opts.probe(cur.path);
123
- const segmentSec = segmentDurationSec(cur.path, probed, cur.startMs, pausedAt) ?? 0;
124
- const parts = record.segments.parts;
125
- const next = segmentSec > 0 ? [...parts, { ...cur, durationSec: segmentSec }] : parts;
126
- if (segmentSec <= 0 && cur.path !== record.outputPath)
127
- rmSync(cur.path, { force: true });
128
- store.markPaused(record.id);
129
- const updated = store.update(record.id, { status: "paused", pid: null, segments: { parts: next } });
130
- return { record: updated, recordedSec: recordedSec(next), segmentSec, graceful };
131
- }
132
- finally {
133
- clearPausing(record.id);
134
- store.clearStopping(record.id);
135
- }
136
- }
137
- export async function stopAll(store, probe, capMs = 10_000) {
138
- const ids = store.activeIds();
139
- const stops = ids.map(async (id) => {
140
- const record = store.get(id);
141
- if (!record)
142
- return;
143
- try {
144
- await stopSession(store, record, { reason: "shutdown", probe, gracefulMs: Math.min(8000, capMs) });
145
- }
146
- catch (err) {
147
- process.stderr.write(`Stopping ${id} on shutdown failed: ${errorMessage(err)}\n`);
148
- }
149
- });
150
- let timer;
151
- const cap = new Promise((resolve) => {
152
- timer = setTimeout(resolve, capMs);
153
- });
154
- await Promise.race([Promise.allSettled(stops), cap]);
155
- clearTimeout(timer);
156
- return ids;
157
- }
158
- export function stopSession(store, record, opts) {
159
- return withSessionOp(store, record.id, "stop", async (waited) => {
160
- if (!waited)
161
- return runStop(store, record, opts);
162
- const cur = store.get(record.id) ?? record;
163
- if (cur.status !== "recording" && cur.status !== "paused") {
164
- return { record: cur, graceful: true, durationSec: cur.durationSec ?? null };
165
- }
166
- return runStop(store, cur, opts);
167
- }, { queue: true });
168
- }
169
- async function runStop(store, record, opts) {
170
- store.markStopping(record.id);
171
- const stopFile = record.backend === "wgc" ? wgcStopFile(record.outputPath) : null;
172
- try {
173
- let graceful = false;
174
- const child = store.getChild(record.id);
175
- const stillRunning = (pid) => new ScreencastError(`Could not stop recording ${record.id}: its process (pid ${pid}) is still running.`);
176
- if (child && child.stdin && child.stdin.writable) {
177
- graceful = await quitChild(child, record.pid, opts.gracefulMs ?? 8000);
178
- if (!graceful && record.pid !== null && isAlive(record.pid))
179
- throw stillRunning(record.pid);
180
- }
181
- else if (record.pid !== null && isAlive(record.pid)) {
182
- if (isOwnRecorder(record)) {
183
- if (stopFile) {
184
- writeFileSync(stopFile, "");
185
- await waitForPidExit(record.pid, opts.gracefulMs ?? 8000);
186
- graceful = !isAlive(record.pid);
187
- }
188
- if (isAlive(record.pid)) {
189
- killPid(record.pid);
190
- await waitForPidExit(record.pid, 2000);
191
- }
192
- if (isAlive(record.pid))
193
- throw stillRunning(record.pid);
194
- }
195
- }
196
- store.detachChild(record.id, child);
197
- if (record.status === "paused")
198
- graceful = true;
199
- endSession(record.id);
200
- store.clearPaused(record.id);
201
- await whenFinalized(record.id);
202
- let segments;
203
- let segmentPatch = {};
204
- if (needsJoin(record)) {
205
- const join = await joinSegments(record, requireFfmpeg());
206
- segmentPatch = join.patch;
207
- segments = { count: join.count, ...(join.error ? { error: join.error } : {}) };
208
- }
209
- const replay = record.replay
210
- ? await finishReplay(record.replay, {
211
- save: opts.saveReplay ?? false,
212
- output: record.outputPath,
213
- quality: record.quality,
214
- tools: requireFfmpeg,
215
- })
216
- : undefined;
217
- const durationSec = await opts.probe(record.outputPath);
218
- const updated = store.update(record.id, {
219
- ...segmentPatch,
220
- status: "stopped",
221
- stoppedAt: new Date().toISOString(),
222
- durationSec: durationSec ?? undefined,
223
- endReason: opts.reason,
224
- error: segments?.error,
225
- });
226
- return { record: updated, graceful, durationSec, ...(replay ? { replay } : {}), ...(segments ? { segments } : {}) };
227
- }
228
- finally {
229
- if (stopFile)
230
- rmSync(stopFile, { force: true });
231
- store.clearStopping(record.id);
232
- }
233
- }
@@ -1,75 +0,0 @@
1
- export const LOGGER_NAME = "screencast-mcp";
2
- const servers = new Set();
3
- export function attachLogging(server) {
4
- servers.add(server);
5
- }
6
- export function logMessage(level, message, data = {}) {
7
- for (const server of servers) {
8
- if (!server.isConnected())
9
- continue;
10
- server
11
- .sendLoggingMessage({ level, logger: LOGGER_NAME, data: { message, ...data } })
12
- .catch(() => { });
13
- }
14
- }
15
- const PROGRESS = /^\s*(?:frame|size)=/;
16
- const WARNING = /\b(?:warning|deprecated|dropp(?:ed|ing)|too full|discard\w*|non[- ]?monoton\w*|past duration|could not|cannot|failed|invalid|corrupt\w*|missing|error)\b/i;
17
- const BENIGN = /^\s*configuration:|deprecated pixel format used/i;
18
- export const MAX_WARNINGS = 20;
19
- function isWarning(line) {
20
- return !PROGRESS.test(line) && WARNING.test(line) && !BENIGN.test(line);
21
- }
22
- export function ffmpegWarnings(stderr) {
23
- const out = new Set();
24
- for (const raw of stderr.split(/[\r\n]+/)) {
25
- const line = raw.trim();
26
- if (line && isWarning(line))
27
- out.add(line);
28
- if (out.size >= MAX_WARNINGS)
29
- break;
30
- }
31
- return [...out];
32
- }
33
- export function logFfmpegWarnings(stderr, data = {}) {
34
- const warnings = ffmpegWarnings(stderr);
35
- if (warnings.length > 0)
36
- logMessage("warning", "ffmpeg reported warnings.", { ...data, warnings });
37
- }
38
- export const DROP_REPORT_INTERVAL_MS = 10_000;
39
- export class StderrWatch {
40
- data;
41
- send;
42
- now;
43
- partial = "";
44
- seen = new Set();
45
- dropped = 0;
46
- lastDropReport = -Infinity;
47
- constructor(data, send = logMessage, now = Date.now) {
48
- this.data = data;
49
- this.send = send;
50
- this.now = now;
51
- }
52
- feed(chunk) {
53
- const parts = (this.partial + chunk).split(/[\r\n]/);
54
- this.partial = parts.pop() ?? "";
55
- for (const raw of parts)
56
- this.line(raw.trim());
57
- }
58
- line(line) {
59
- if (!line)
60
- return;
61
- if (PROGRESS.test(line)) {
62
- const drop = Number(/\bdrop=\s*(\d+)/.exec(line)?.[1] ?? 0);
63
- if (drop > this.dropped && this.now() - this.lastDropReport >= DROP_REPORT_INTERVAL_MS) {
64
- this.lastDropReport = this.now();
65
- this.dropped = drop;
66
- this.send("warning", `The recording has dropped ${drop} frame(s) so far.`, { ...this.data(), dropped: drop });
67
- }
68
- return;
69
- }
70
- if (!isWarning(line) || this.seen.has(line) || this.seen.size >= MAX_WARNINGS)
71
- return;
72
- this.seen.add(line);
73
- this.send("warning", line, { ...this.data(), source: "ffmpeg" });
74
- }
75
- }