@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,155 +0,0 @@
1
- import { homedir, tmpdir } from "node:os";
2
- import { basename, delimiter, dirname, join, isAbsolute, relative, resolve, sep } from "node:path";
3
- import { mkdirSync, existsSync, realpathSync } from "node:fs";
4
- import { ScreencastError } from "./errors.js";
5
- export function homeRoot() {
6
- const override = process.env.SCREENCAST_HOME;
7
- if (override && override.trim().length > 0)
8
- return override;
9
- return join(homedir(), ".screencast-mcp");
10
- }
11
- export function subdir(name) {
12
- const dir = join(homeRoot(), name);
13
- mkdirSync(dir, { recursive: true });
14
- return dir;
15
- }
16
- export function registryPath() {
17
- const dir = homeRoot();
18
- mkdirSync(dir, { recursive: true });
19
- return join(dir, "sessions.json");
20
- }
21
- export function stamp(date = new Date()) {
22
- const iso = date.toISOString().replace(/[-:T]/g, "").replace(/\..+/, "");
23
- const ms = String(date.getMilliseconds()).padStart(3, "0");
24
- return `${iso.slice(0, 8)}-${iso.slice(8, 14)}-${ms}`;
25
- }
26
- export function rand(n = 4) {
27
- return Math.random().toString(36).slice(2, 2 + n);
28
- }
29
- export function sequencePattern(dir, name) {
30
- return join(dir.replace(/%/g, "%%"), name);
31
- }
32
- const STILL_IMAGE = /\.(png|jpe?g|bmp|tiff?)$/i;
33
- export function isStillImage(path) {
34
- return STILL_IMAGE.test(path);
35
- }
36
- export function stillOutput(output) {
37
- return STILL_IMAGE.test(output) ? ["-update", "1", output] : [output];
38
- }
39
- export function tempPath(suffix = "") {
40
- return join(tmpdir(), `screencast-${stamp()}-${rand()}${suffix}`);
41
- }
42
- export const ALLOWED_DIRS_ENV = "SCREENCAST_ALLOWED_DIRS";
43
- export function envAllowedDirs(env = process.env) {
44
- const raw = env[ALLOWED_DIRS_ENV];
45
- if (!raw)
46
- return [];
47
- return raw
48
- .split(delimiter)
49
- .map((d) => d.trim())
50
- .filter((d) => d.length > 0)
51
- .map((d) => resolve(d));
52
- }
53
- let clientRoots = null;
54
- export function setClientRoots(dirs) {
55
- clientRoots = dirs === null || dirs === "pending" ? dirs : dirs.map((d) => resolve(d));
56
- }
57
- export function getClientRoots() {
58
- return Array.isArray(clientRoots) ? clientRoots : null;
59
- }
60
- export function allowedOutputDirs(env = process.env) {
61
- const fromEnv = envAllowedDirs(env);
62
- if (clientRoots === null && fromEnv.length === 0)
63
- return null;
64
- const roots = Array.isArray(clientRoots) ? clientRoots : [];
65
- return [resolve(homeRoot()), ...fromEnv, ...roots];
66
- }
67
- function realish(path) {
68
- const tail = [];
69
- let cur = resolve(path);
70
- for (;;) {
71
- try {
72
- return join(realpathSync.native(cur), ...tail.reverse());
73
- }
74
- catch {
75
- const parent = dirname(cur);
76
- if (parent === cur)
77
- return resolve(path);
78
- tail.push(basename(cur));
79
- cur = parent;
80
- }
81
- }
82
- }
83
- export function isWithin(path, dir) {
84
- const rel = relative(realish(dir), realish(path));
85
- return rel === "" || (rel !== ".." && !rel.startsWith(`..${sep}`) && !isAbsolute(rel));
86
- }
87
- export function isNetworkPath(path) {
88
- const p = path.trim();
89
- if (!/^[\\/]{2}/.test(p))
90
- return false;
91
- return !/^[\\/]{2}\?[\\/][A-Za-z]:[\\/]/.test(p);
92
- }
93
- export function assertLocalPath(path, label = "Path") {
94
- if (isNetworkPath(path)) {
95
- throw new ScreencastError(`${label} ${path} is a network or device path; only local files are allowed. ` +
96
- "Copy the file to a local folder first.");
97
- }
98
- }
99
- export function assertInputAllowed(path, label = "Input") {
100
- assertLocalPath(path, label);
101
- const full = resolve(path);
102
- if (clientRoots === "pending" && envAllowedDirs().length === 0 && !isWithin(full, homeRoot())) {
103
- throw new ScreencastError(`${label} ${full} is outside SCREENCAST_HOME and the client's workspace roots have not loaded yet. ` +
104
- "Retry the call in a moment.");
105
- }
106
- const allowed = allowedOutputDirs();
107
- if (allowed === null || allowed.some((dir) => isWithin(full, dir)))
108
- return;
109
- throw new ScreencastError(`${label} ${full} is outside the allowed directories: ${allowed.join(", ")}. ` +
110
- `Move it under one of them, or add its folder to ${ALLOWED_DIRS_ENV} or the client's workspace roots.`);
111
- }
112
- export function assertOutputAllowed(path) {
113
- assertLocalPath(path, "Output");
114
- if (clientRoots === "pending" && envAllowedDirs().length === 0 && !isWithin(path, homeRoot())) {
115
- throw new ScreencastError(`Output ${path} is outside SCREENCAST_HOME and the client's workspace roots have not loaded yet. ` +
116
- "Retry the call in a moment, or omit the path to write under SCREENCAST_HOME.");
117
- }
118
- const allowed = allowedOutputDirs();
119
- if (allowed === null || allowed.some((dir) => isWithin(path, dir)))
120
- return;
121
- throw new ScreencastError(`Output ${path} is outside the allowed directories: ${allowed.join(", ")}. ` +
122
- `Write under one of them (a relative path lands in SCREENCAST_HOME), or add the folder to ` +
123
- `${ALLOWED_DIRS_ENV} or the client's workspace roots.`);
124
- }
125
- export function assertOverwriteAllowed(path) {
126
- if (allowedOutputDirs() !== null || isWithin(path, homeRoot()))
127
- return;
128
- throw new ScreencastError(`Refusing to replace ${path}: it is outside SCREENCAST_HOME and no allowed directories are set. ` +
129
- `Add its folder to ${ALLOWED_DIRS_ENV} (or the client's workspace roots) to allow overwriting there, ` +
130
- "or write to a new path.");
131
- }
132
- export function resolveOutput(provided, defaultDir, defaultName, overwrite = false) {
133
- if (provided && provided.trim().length > 0) {
134
- assertLocalPath(provided, "Output");
135
- const path = resolve(defaultDir, provided);
136
- assertOutputAllowed(path);
137
- if (existsSync(path)) {
138
- if (!overwrite) {
139
- throw new ScreencastError(`Output already exists: ${path}. Pass overwrite: true to replace it, ` +
140
- `or choose a different path.`);
141
- }
142
- assertOverwriteAllowed(path);
143
- }
144
- return path;
145
- }
146
- return join(defaultDir, defaultName);
147
- }
148
- export function resolveOutputDir(provided, defaultParent) {
149
- if (!provided || provided.trim().length === 0)
150
- return undefined;
151
- assertLocalPath(provided, "Output directory");
152
- const dir = resolve(defaultParent, provided);
153
- assertOutputAllowed(dir);
154
- return dir;
155
- }
@@ -1,190 +0,0 @@
1
- import { existsSync, mkdirSync, renameSync, rmSync, statSync, writeFileSync } from "node:fs";
2
- import { basename, dirname, extname, join } from "node:path";
3
- import { ScreencastError } from "./errors.js";
4
- import { runCapture } from "./ffmpeg.js";
5
- import { jobTimeoutMs } from "./jobs.js";
6
- import { buildConcatArgs, concatListContent } from "./media.js";
7
- export const DEFAULT_WEBCAM_SIZE = 0.25;
8
- export function partsDir(output) {
9
- return `${output}.parts`;
10
- }
11
- export function partPath(output, index) {
12
- return index === 0 ? output : join(partsDir(output), `part-${String(index).padStart(3, "0")}.mp4`);
13
- }
14
- export function webcamPartPath(output, index) {
15
- return join(partsDir(output), `webcam-${String(index).padStart(3, "0")}.mp4`);
16
- }
17
- export function webcamOutputPath(output) {
18
- const ext = extname(output);
19
- return join(dirname(output), `${basename(output, ext)}.webcam.mp4`);
20
- }
21
- export function segmentDurationSec(path, probed, startMs, endMs) {
22
- if (probed !== null && probed > 0)
23
- return probed;
24
- let size;
25
- try {
26
- size = statSync(path).size;
27
- }
28
- catch {
29
- return null;
30
- }
31
- if (size <= 0)
32
- return null;
33
- return Math.max(0.001, Math.round(endMs - startMs) / 1000);
34
- }
35
- export function recordedSec(parts) {
36
- return parts.reduce((s, p) => s + p.durationSec, 0);
37
- }
38
- export function clockSpans(state) {
39
- const spans = [];
40
- let offset = 0;
41
- for (const p of state.parts) {
42
- spans.push({ startMs: p.startMs, offsetSec: offset, durationSec: p.durationSec });
43
- offset += p.durationSec;
44
- }
45
- if (state.current)
46
- spans.push({ startMs: state.current.startMs, offsetSec: offset });
47
- return spans;
48
- }
49
- export function eventClock(state, fallbackStartMs, nowMs) {
50
- if (!state || (state.parts.length === 0 && !state.current)) {
51
- return { startMs: fallbackStartMs, endSec: (nowMs - fallbackStartMs) / 1000 };
52
- }
53
- const spans = clockSpans(state);
54
- const live = state.current ? Math.max(0, (nowMs - state.current.startMs) / 1000) : 0;
55
- return { startMs: spans[0].startMs, endSec: recordedSec(state.parts) + live, spans };
56
- }
57
- export function remainingCapSec(maxDurationSec, recorded) {
58
- if (!maxDurationSec)
59
- return 0;
60
- const left = Math.floor(maxDurationSec - recorded);
61
- if (left < 1) {
62
- throw new ScreencastError(`The recording already used its maxDurationSec cap (${maxDurationSec}s); nothing is left to resume.`, "Call stop_recording to finalize it.");
63
- }
64
- return left;
65
- }
66
- export function pauseBlocker(record, ownsChild) {
67
- if (record.status === "paused")
68
- return "it is already paused";
69
- if (record.status !== "recording")
70
- return `it is ${record.status}`;
71
- if (record.backend === "wgc")
72
- return 'backend "wgc" cannot pause yet';
73
- if (record.replay)
74
- return "a replay buffer cannot pause";
75
- if (!record.capture || !record.segments?.current)
76
- return "it was started before pause was supported";
77
- if (!ownsChild)
78
- return "another server instance owns it";
79
- return null;
80
- }
81
- export function resumeBlocker(record, owns) {
82
- if (record.status === "recording")
83
- return "it is already recording";
84
- if (record.status !== "paused")
85
- return `it is ${record.status}`;
86
- if (!record.capture || !record.segments)
87
- return "its capture settings are missing";
88
- if (!owns)
89
- return "it was paused by another server instance";
90
- return null;
91
- }
92
- const pausing = new Set();
93
- export function markPausing(id) {
94
- pausing.add(id);
95
- }
96
- export function isPausing(id) {
97
- return pausing.has(id);
98
- }
99
- export function clearPausing(id) {
100
- pausing.delete(id);
101
- }
102
- const ends = new Map();
103
- function endEntry(id) {
104
- let e = ends.get(id);
105
- if (!e) {
106
- let resolve;
107
- const promise = new Promise((r) => (resolve = r));
108
- e = { promise, resolve };
109
- ends.set(id, e);
110
- }
111
- return e;
112
- }
113
- export function sessionEnded(id) {
114
- return endEntry(id).promise;
115
- }
116
- export function endSession(id) {
117
- endEntry(id).resolve();
118
- setTimeout(() => ends.delete(id), 60_000).unref?.();
119
- }
120
- const r3 = (n) => Math.round(n * 1000) / 1000;
121
- export function buildWebcamAlignArgs(parts, output, codec) {
122
- if (parts.length === 0)
123
- throw new ScreencastError("No webcam parts to join.");
124
- const chains = parts.map((p, i) => {
125
- const d = r3(Math.max(0.001, p.durationSec));
126
- const lead = r3(p.leadSec);
127
- const head = lead > 0 ? `tpad=start_duration=${lead}:start_mode=clone,` : lead < 0 ? `trim=start=${-lead},setpts=PTS-STARTPTS,` : "";
128
- return `[${i}:v]${head}tpad=stop_duration=${d}:stop_mode=clone,trim=duration=${d},setpts=PTS-STARTPTS,format=yuv420p,setsar=1[w${i}]`;
129
- });
130
- const join = `${parts.map((_, i) => `[w${i}]`).join("")}concat=n=${parts.length}:v=1:a=0[v]`;
131
- return [
132
- "-y", "-v", "error",
133
- ...parts.flatMap((p) => ["-i", p.path]),
134
- "-filter_complex", `${chains.join(";")};${join}`,
135
- "-map", "[v]",
136
- ...codec,
137
- "-movflags", "+faststart",
138
- output,
139
- ];
140
- }
141
- export async function finishSegments(output, parts, opts) {
142
- const dir = partsDir(output);
143
- const result = { joined: false };
144
- const video = parts.filter((p) => existsSync(p.path) && p.durationSec > 0);
145
- const total = recordedSec(video);
146
- let keepDir = false;
147
- if (video.length > 1 || (video.length === 1 && video[0].path !== output)) {
148
- mkdirSync(dir, { recursive: true });
149
- const list = join(dir, "segments.txt");
150
- const tmp = join(dir, `joined${extname(output) || ".mp4"}`);
151
- writeFileSync(list, concatListContent(video.map((p) => p.path)));
152
- const res = await runCapture(opts.ffmpeg, buildConcatArgs(list, tmp, { quiet: true }), jobTimeoutMs(total));
153
- if (res.code === 0 && existsSync(tmp)) {
154
- renameSync(tmp, output);
155
- result.joined = true;
156
- }
157
- else {
158
- keepDir = true;
159
- result.error = `Joining the ${video.length} segments failed; they are kept in ${dir}: ${res.stderr.trim().split("\n").slice(-3).join(" ")}`;
160
- }
161
- }
162
- const cams = video.filter((p) => p.webcamPath && existsSync(p.webcamPath));
163
- if (opts.webcamOutput && cams.length > 0) {
164
- const args = buildWebcamAlignArgs(cams.map((p) => ({
165
- path: p.webcamPath,
166
- leadSec: p.webcamStartMs !== undefined ? (p.webcamStartMs - p.startMs) / 1000 : 0,
167
- durationSec: p.durationSec,
168
- })), opts.webcamOutput, opts.webcamCodec);
169
- const res = await runCapture(opts.ffmpeg, args, jobTimeoutMs(total));
170
- if (res.code === 0 && existsSync(opts.webcamOutput)) {
171
- result.webcamPath = opts.webcamOutput;
172
- }
173
- else {
174
- keepDir = true;
175
- result.webcamError = `Aligning the webcam failed; its raw parts are kept in ${dir}: ${res.stderr.trim().split("\n").slice(-3).join(" ")}`;
176
- }
177
- }
178
- if (!keepDir)
179
- rmSync(dir, { recursive: true, force: true });
180
- return result;
181
- }
182
- export function webcamPlacement(screen, cam, corner, size) {
183
- const even = (n) => Math.max(2, Math.round(n / 2) * 2);
184
- const width = even(screen.width * size);
185
- const height = even((width * cam.height) / Math.max(1, cam.width));
186
- const m = Math.round(screen.width * 0.02);
187
- const x = corner.endsWith("left") ? m : Math.max(0, screen.width - width - m);
188
- const y = corner.startsWith("top") ? m : Math.max(0, screen.height - height - m);
189
- return { x, y, width, height };
190
- }