@tmhs/screencast-mcp 0.49.1 → 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 (134) 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 -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,86 +0,0 @@
1
- import { z } from "zod";
2
- import { existsSync, rmSync } from "node:fs";
3
- import { errorResponse, okResponse, ScreencastError } from "../utils/errors.js";
4
- import { READ_ONLY, looseOutput } from "../utils/toolSpec.js";
5
- import { requireFfmpeg, runCapture, runFfmpeg, runFfmpegBuffer, probeMedia } from "../utils/ffmpeg.js";
6
- import { detectionSize, diffFrames, buildRawFrameArgs, buildSsimArgs, buildHighlightArgs, parseSsim, DEFAULT_PIXEL_THRESHOLD, } from "../utils/diff.js";
7
- import { stamp, rand } from "../utils/paths.js";
8
- import { tmpdir } from "node:os";
9
- import { join } from "node:path";
10
- import { encodeInlineImages, DEFAULT_MAX_IMAGE_WIDTH } from "../utils/images.js";
11
- const inputSchema = {
12
- a: z.string().min(1).describe("Before image (or video: first frame)."),
13
- b: z.string().min(1).describe("After image (or video); scaled to a's size."),
14
- pixelThreshold: z
15
- .number()
16
- .min(0)
17
- .max(255)
18
- .optional()
19
- .describe(`Mean 0-255 difference for a ~32x32 cell to count as changed (default ${DEFAULT_PIXEL_THRESHOLD}).`),
20
- returnImage: z
21
- .boolean()
22
- .optional()
23
- .describe("Return b inline with changes outlined (default true)."),
24
- };
25
- export function register(server) {
26
- server.registerTool("screen_diff", {
27
- title: "Screen Diff",
28
- description: "Compare two screenshots or frames: SSIM score, changed share, and changed boxes in b's " +
29
- "pixels, to check a UI change happened only where expected.",
30
- inputSchema,
31
- outputSchema: looseOutput({
32
- identical: z.boolean(),
33
- ssim: z.number().nullable(),
34
- meanDiff: z.number(),
35
- changedFraction: z.number(),
36
- regions: z.array(z.unknown()),
37
- }),
38
- annotations: READ_ONLY,
39
- }, async (args, extra) => {
40
- try {
41
- requireFfmpeg();
42
- for (const f of [args.a, args.b]) {
43
- if (!existsSync(f))
44
- throw new ScreencastError(`Input file not found: ${f}`);
45
- }
46
- const [ia, ib] = await Promise.all([probeMedia(args.a), probeMedia(args.b)]);
47
- if (!ia.width || !ia.height)
48
- throw new ScreencastError(`Could not read the size of ${args.a}.`);
49
- const size = detectionSize(ia.width, ia.height);
50
- const [ra, rb, ssimRun] = await Promise.all([
51
- runFfmpegBuffer(buildRawFrameArgs(args.a, size), 30_000, { signal: extra.signal }),
52
- runFfmpegBuffer(buildRawFrameArgs(args.b, size), 30_000, { signal: extra.signal }),
53
- runCapture(requireFfmpeg().ffmpeg, buildSsimArgs(args.a, args.b, size), 30_000, { signal: extra.signal }),
54
- ]);
55
- const diff = diffFrames(ra, rb, size.width, size.height, {
56
- scaleX: (ib.width ?? ia.width) / size.width,
57
- scaleY: (ib.height ?? ia.height) / size.height,
58
- pixelThreshold: args.pixelThreshold,
59
- });
60
- const images = [];
61
- if (args.returnImage !== false) {
62
- const highlighted = join(tmpdir(), `screencast-diff-${stamp()}-${rand()}.png`);
63
- try {
64
- await runFfmpeg(buildHighlightArgs(args.b, diff.regions, highlighted), 30_000, { signal: extra.signal });
65
- images.push(...(await encodeInlineImages([highlighted], DEFAULT_MAX_IMAGE_WIDTH, 1)).images);
66
- }
67
- finally {
68
- rmSync(highlighted, { force: true });
69
- }
70
- }
71
- return okResponse({
72
- identical: diff.regions.length === 0,
73
- ssim: parseSsim(ssimRun.stderr),
74
- meanDiff: Number(diff.meanDiff.toFixed(4)),
75
- changedFraction: Number(diff.changedFraction.toFixed(4)),
76
- regions: diff.regions,
77
- ...(ib.width !== ia.width || ib.height !== ia.height
78
- ? { note: `b (${ib.width}x${ib.height}) was compared at a's size (${ia.width}x${ia.height}).` }
79
- : {}),
80
- }, images);
81
- }
82
- catch (error) {
83
- return errorResponse(error);
84
- }
85
- });
86
- }
@@ -1,76 +0,0 @@
1
- import { z } from "zod";
2
- import { errorResponse, okResponse } from "../utils/errors.js";
3
- import { WRITES_FILE, looseOutput } from "../utils/toolSpec.js";
4
- import { requireFfmpeg } from "../utils/ffmpeg.js";
5
- import { captureStill } from "../utils/still.js";
6
- import { resolveCaptureTarget } from "../utils/resolveTarget.js";
7
- import { resolveOutput, subdir, stamp, rand } from "../utils/paths.js";
8
- import { encodeInlineImages, DEFAULT_MAX_IMAGE_WIDTH } from "../utils/images.js";
9
- import { windowMatchReport } from "../utils/windows.js";
10
- import { confirmCapture, describeTarget } from "../utils/consent.js";
11
- const inputSchema = {
12
- target: z
13
- .string()
14
- .describe("full | monitor:<i> (0 = primary) | window:<title> (or window:exe=<app.exe> / window:hwnd=<n>) | " +
15
- "region:<x>,<y>,<w>,<h>. Titles match exactly, else as a substring; topmost wins."),
16
- exactTitle: z
17
- .boolean()
18
- .optional()
19
- .describe("window: targets match the whole title only, never a substring (default false)."),
20
- backend: z
21
- .enum(["gdigrab", "wgc"])
22
- .optional()
23
- .describe("gdigrab (default, ~0.2 s): what is visible. wgc (window:, FFmpeg 8+, ~1-2 s): the window even if covered."),
24
- output: z
25
- .string()
26
- .optional()
27
- .describe("Optional output .png path. Defaults to a file under SCREENCAST_HOME/screenshots."),
28
- overwrite: z.boolean().optional().describe("Allow replacing an existing file at the output path (default false)."),
29
- returnImage: z
30
- .boolean()
31
- .optional()
32
- .describe("Return the image inline (default true; the PNG on disk stays full size)."),
33
- maxImageWidth: z
34
- .number()
35
- .int()
36
- .min(16)
37
- .optional()
38
- .describe(`Max inline image width (default ${DEFAULT_MAX_IMAGE_WIDTH}).`),
39
- };
40
- export function register(server) {
41
- server.registerTool("screenshot", {
42
- title: "Take Screenshot",
43
- description: "Capture one PNG of the screen, a monitor, a window, or a region, returned inline and by path.",
44
- inputSchema,
45
- outputSchema: looseOutput({
46
- outputPath: z.string(),
47
- target: z.string(),
48
- backend: z.string(),
49
- inlineImages: z.number().int(),
50
- }),
51
- annotations: WRITES_FILE,
52
- }, async (args, extra) => {
53
- try {
54
- requireFfmpeg();
55
- const resolved = await resolveCaptureTarget(args.target, { exactTitle: args.exactTitle, backend: args.backend });
56
- const { window } = resolved;
57
- const output = resolveOutput(args.output, subdir("screenshots"), `shot-${stamp()}-${rand()}.png`, args.overwrite);
58
- const backend = args.backend ?? "gdigrab";
59
- await confirmCapture(server, `Take a screenshot of ${describeTarget(args.target, window)}, saved to ${output}?`, extra.signal);
60
- await captureStill(resolved, output, backend);
61
- const images = args.returnImage === false
62
- ? []
63
- : (await encodeInlineImages([output], args.maxImageWidth ?? DEFAULT_MAX_IMAGE_WIDTH, 1)).images;
64
- return okResponse({
65
- outputPath: output,
66
- target: args.target,
67
- backend,
68
- ...(window ? windowMatchReport(window) : {}),
69
- inlineImages: images.length,
70
- }, images);
71
- }
72
- catch (error) {
73
- return errorResponse(error);
74
- }
75
- });
76
- }
@@ -1,79 +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 { READ_ONLY, looseOutput } from "../utils/toolSpec.js";
7
- import { requireFfmpeg, runFfmpeg } from "../utils/ffmpeg.js";
8
- import { buildSampleAtTimestampArgs } from "../utils/media.js";
9
- import { subdir } from "../utils/paths.js";
10
- import { encodeInlineImages, clampInlineCount, MAX_INLINE_IMAGES } from "../utils/images.js";
11
- import { DEFAULT_SEARCH_LIMIT, MAX_SEARCH_LIMIT, fingerprintFile, findIndex, keyframeTime, readIndex, resolveRecording, sameFingerprint, searchIndex, } from "../utils/recordingIndex.js";
12
- const THUMB_WIDTH = 480;
13
- const inputSchema = {
14
- input: z.string().optional().describe("Recording path."),
15
- sessionId: z.string().optional().describe("Or a stopped session id."),
16
- query: z.string().min(1).describe("Text; tolerates OCR misreads."),
17
- regex: z.boolean().optional().describe("query is a regex."),
18
- limit: z.number().int().min(1).max(MAX_SEARCH_LIMIT).optional().describe(`Max hits (default ${DEFAULT_SEARCH_LIMIT}).`),
19
- images: z.number().int().min(0).max(MAX_INLINE_IMAGES).optional().describe("Thumbnails of the top N hits (default 0)."),
20
- };
21
- export function register(server) {
22
- server.registerTool("search_recording", {
23
- title: "Search Recording",
24
- description: "Search an index_recording timeline (screen text, events, markers, transcript): timecoded hits, " +
25
- "best first, secrets masked. No frames unless asked.",
26
- inputSchema,
27
- outputSchema: looseOutput({ total: z.number(), hits: z.array(z.unknown()) }),
28
- annotations: READ_ONLY,
29
- }, async (args, extra) => {
30
- try {
31
- const source = await resolveRecording(args);
32
- const fingerprint = fingerprintFile(source.path);
33
- const indexPath = findIndex(source.path, subdir("edits"), fingerprint);
34
- const index = indexPath ? readIndex(indexPath) : null;
35
- if (!indexPath || !index) {
36
- throw new ScreencastError(`No index for ${source.path}.`, "Run index_recording on it first.");
37
- }
38
- const stale = !sameFingerprint(index.fingerprint, fingerprint);
39
- const { hits, total } = searchIndex(index, args.query, {
40
- regex: args.regex === true,
41
- limit: args.limit,
42
- video: source.path,
43
- fingerprint,
44
- });
45
- const want = Math.min(clampInlineCount(args.images ?? 0), hits.length);
46
- let images = [];
47
- if (want > 0) {
48
- requireFfmpeg();
49
- const work = mkdtempSync(join(tmpdir(), "screencast-search-"));
50
- try {
51
- const shots = [];
52
- for (const [i, hit] of hits.slice(0, want).entries()) {
53
- const at = hit.t === hit.start ? keyframeTime(hit) : hit.t;
54
- const out = join(work, `hit_${i}.png`);
55
- await runFfmpeg(buildSampleAtTimestampArgs(source.path, at, out), 60_000, { signal: extra.signal });
56
- if (existsSync(out))
57
- shots.push(out);
58
- }
59
- images = (await encodeInlineImages(shots, THUMB_WIDTH, want)).images;
60
- }
61
- finally {
62
- rmSync(work, { recursive: true, force: true });
63
- }
64
- }
65
- return okResponse({
66
- indexPath,
67
- query: args.query,
68
- total,
69
- hits,
70
- ...(total > hits.length ? { more: total - hits.length } : {}),
71
- ...(index.ocr ? {} : { note: "The index has no screen text (OCR was unavailable when it was built)." }),
72
- ...(stale ? { stale: true, warning: "The recording changed since it was indexed; run index_recording again." } : {}),
73
- }, images);
74
- }
75
- catch (error) {
76
- return errorResponse(error);
77
- }
78
- });
79
- }
@@ -1,46 +0,0 @@
1
- import { z } from "zod";
2
- import { existsSync } from "node:fs";
3
- import { errorResponse, okResponse, ScreencastError } from "../utils/errors.js";
4
- import { OUTPUT_PATH, WRITES_FILE } from "../utils/toolSpec.js";
5
- import { requireFfmpeg, probeMedia } from "../utils/ffmpeg.js";
6
- import { runEditJob } from "../utils/jobs.js";
7
- import { buildSpeedArgs, editOutputExt, assertEditContainer } from "../utils/media.js";
8
- import { resolveOutput, subdir, stamp, rand } from "../utils/paths.js";
9
- const inputSchema = {
10
- input: z.string().min(1).describe("Path to the source video."),
11
- factor: z.number().positive().describe("Speed multiplier: >1 is faster, <1 is slower (e.g. 2 = double speed)."),
12
- output: z.string().optional().describe("Optional output path. Defaults under SCREENCAST_HOME/edits."),
13
- overwrite: z.boolean().optional().describe("Allow replacing an existing file at the output path (default false)."),
14
- };
15
- export function register(server) {
16
- server.registerTool("speed", {
17
- title: "Change Speed",
18
- description: "Change playback speed by a factor (>1 faster, <1 slower) and re-encode. " +
19
- "Audio is retempo'd to match when the source has an audio track.",
20
- inputSchema,
21
- outputSchema: OUTPUT_PATH,
22
- annotations: WRITES_FILE,
23
- }, async (args, extra) => {
24
- try {
25
- requireFfmpeg();
26
- if (!existsSync(args.input)) {
27
- throw new ScreencastError(`Input file not found: ${args.input}`);
28
- }
29
- const { audioCodec, durationSec } = await probeMedia(args.input);
30
- assertEditContainer(args.output);
31
- const ext = editOutputExt(args.input);
32
- const output = resolveOutput(args.output, subdir("edits"), `speed-${stamp()}-${rand()}${ext}`, args.overwrite);
33
- const ffArgs = buildSpeedArgs(args.input, output, args.factor, audioCodec !== null);
34
- await runEditJob(ffArgs, {
35
- output,
36
- durationSec: durationSec !== null ? durationSec / args.factor : null,
37
- inputDurationSec: durationSec,
38
- extra,
39
- });
40
- return okResponse({ outputPath: output, factor: args.factor, audio: audioCodec !== null });
41
- }
42
- catch (error) {
43
- return errorResponse(error);
44
- }
45
- });
46
- }