@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.
- package/README.md +13 -8
- package/dist/index.js +550 -106
- package/dist/wgcRecorder.js +15 -139
- package/package.json +8 -4
- package/assets/.gitkeep +0 -0
- package/assets/icon.png +0 -0
- package/dist/cli.js +0 -516
- package/dist/context.js +0 -50
- package/dist/prompts.js +0 -95
- package/dist/resources.js +0 -93
- package/dist/server.js +0 -174
- package/dist/setup.js +0 -438
- package/dist/tools/addMarker.js +0 -93
- package/dist/tools/assembleHighlights.js +0 -69
- package/dist/tools/backdrop.js +0 -79
- package/dist/tools/bugReport.js +0 -243
- package/dist/tools/burnSubtitles.js +0 -56
- package/dist/tools/callout.js +0 -62
- package/dist/tools/chapters.js +0 -156
- package/dist/tools/clip.js +0 -52
- package/dist/tools/compress.js +0 -51
- package/dist/tools/concat.js +0 -67
- package/dist/tools/contactSheet.js +0 -113
- package/dist/tools/convert.js +0 -46
- package/dist/tools/crop.js +0 -43
- package/dist/tools/cursor.js +0 -67
- package/dist/tools/cutByTranscript.js +0 -86
- package/dist/tools/cutIdle.js +0 -84
- package/dist/tools/deleteRecording.js +0 -119
- package/dist/tools/denoise.js +0 -60
- package/dist/tools/doctor.js +0 -146
- package/dist/tools/exportGif.js +0 -57
- package/dist/tools/exportPreset.js +0 -48
- package/dist/tools/extractAudio.js +0 -65
- package/dist/tools/findText.js +0 -194
- package/dist/tools/getMediaInfo.js +0 -36
- package/dist/tools/getSession.js +0 -40
- package/dist/tools/indexRecording.js +0 -195
- package/dist/tools/keystrokeOverlay.js +0 -90
- package/dist/tools/listAudioDevices.js +0 -35
- package/dist/tools/listSessions.js +0 -28
- package/dist/tools/listTargets.js +0 -76
- package/dist/tools/listVideoDevices.js +0 -26
- package/dist/tools/musicBed.js +0 -55
- package/dist/tools/narrate.js +0 -86
- package/dist/tools/normalizeAudio.js +0 -59
- package/dist/tools/overlay.js +0 -62
- package/dist/tools/pauseRecording.js +0 -44
- package/dist/tools/pipeline.js +0 -397
- package/dist/tools/readEvents.js +0 -98
- package/dist/tools/redactRegion.js +0 -62
- package/dist/tools/reframe.js +0 -46
- package/dist/tools/resumeRecording.js +0 -46
- package/dist/tools/reviewRecording.js +0 -163
- package/dist/tools/sampleFrames.js +0 -200
- package/dist/tools/saveReplay.js +0 -90
- package/dist/tools/scale.js +0 -44
- package/dist/tools/screenDiff.js +0 -86
- package/dist/tools/screenshot.js +0 -76
- package/dist/tools/searchRecording.js +0 -79
- package/dist/tools/speed.js +0 -46
- package/dist/tools/startRecording.js +0 -398
- package/dist/tools/stepGuide.js +0 -249
- package/dist/tools/stopRecording.js +0 -132
- package/dist/tools/titleCard.js +0 -67
- package/dist/tools/transcribe.js +0 -66
- package/dist/tools/trim.js +0 -57
- package/dist/tools/waitForChange.js +0 -142
- package/dist/tools/xfadeTransition.js +0 -58
- package/dist/tools/zoom.js +0 -134
- package/dist/utils/anim.js +0 -54
- package/dist/utils/animExport.js +0 -56
- package/dist/utils/argPaths.js +0 -39
- package/dist/utils/audio.js +0 -117
- package/dist/utils/audioDevices.js +0 -107
- package/dist/utils/backdrop.js +0 -162
- package/dist/utils/bugReport.js +0 -195
- package/dist/utils/callout.js +0 -132
- package/dist/utils/calloutAssets.js +0 -42
- package/dist/utils/capabilities.js +0 -96
- package/dist/utils/captions.js +0 -104
- package/dist/utils/chapters.js +0 -227
- package/dist/utils/consent.js +0 -29
- package/dist/utils/cursor.js +0 -338
- package/dist/utils/diff.js +0 -186
- package/dist/utils/errors.js +0 -29
- package/dist/utils/events.js +0 -403
- package/dist/utils/expr.js +0 -11
- package/dist/utils/ffmpeg.js +0 -285
- package/dist/utils/fontCoverage.js +0 -177
- package/dist/utils/fonts.js +0 -154
- package/dist/utils/frameQueue.js +0 -50
- package/dist/utils/gpu.js +0 -219
- package/dist/utils/idle.js +0 -91
- package/dist/utils/images.js +0 -38
- package/dist/utils/jobs.js +0 -129
- package/dist/utils/keystrokes.js +0 -198
- package/dist/utils/lifecycle.js +0 -233
- package/dist/utils/logging.js +0 -75
- package/dist/utils/media.js +0 -584
- package/dist/utils/monitors.js +0 -124
- package/dist/utils/narrate.js +0 -233
- package/dist/utils/ocr.js +0 -222
- package/dist/utils/ocrScan.js +0 -93
- package/dist/utils/paths.js +0 -155
- package/dist/utils/pause.js +0 -190
- package/dist/utils/pipeline.js +0 -361
- package/dist/utils/player.js +0 -85
- package/dist/utils/pool.js +0 -29
- package/dist/utils/produce.js +0 -300
- package/dist/utils/recipes.js +0 -71
- package/dist/utils/recorder.js +0 -173
- package/dist/utils/recordingFiles.js +0 -32
- package/dist/utils/recordingIndex.js +0 -312
- package/dist/utils/replay.js +0 -283
- package/dist/utils/resolveTarget.js +0 -25
- package/dist/utils/retention.js +0 -48
- package/dist/utils/roots.js +0 -43
- package/dist/utils/sessions.js +0 -499
- package/dist/utils/sheet.js +0 -82
- package/dist/utils/stepGuide.js +0 -231
- package/dist/utils/steps.js +0 -88
- package/dist/utils/still.js +0 -38
- package/dist/utils/targetList.js +0 -64
- package/dist/utils/targets.js +0 -265
- package/dist/utils/timeline.js +0 -85
- package/dist/utils/toolSpec.js +0 -31
- package/dist/utils/toolsets.js +0 -134
- package/dist/utils/transcriptCut.js +0 -149
- package/dist/utils/validate.js +0 -23
- package/dist/utils/waitLoop.js +0 -50
- package/dist/utils/wgc.js +0 -84
- package/dist/utils/windows.js +0 -192
- package/dist/utils/zoom.js +0 -252
package/dist/tools/denoise.js
DELETED
|
@@ -1,60 +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, runCapture, probeMedia } from "../utils/ffmpeg.js";
|
|
6
|
-
import { runEditJob, jobTimeoutMs } from "../utils/jobs.js";
|
|
7
|
-
import { buildDenoiseArgs, buildNoiseFloorArgs, parseNoiseFloor, DENOISE_STRENGTHS } from "../utils/audio.js";
|
|
8
|
-
import { editOutputExt, assertEditContainer } from "../utils/media.js";
|
|
9
|
-
import { resolveOutput, subdir, stamp, rand } from "../utils/paths.js";
|
|
10
|
-
const inputSchema = {
|
|
11
|
-
input: z.string().min(1).describe("Path to the source video or audio file."),
|
|
12
|
-
strength: z
|
|
13
|
-
.enum(DENOISE_STRENGTHS)
|
|
14
|
-
.optional()
|
|
15
|
-
.describe("How hard to reduce noise: light (6 dB), medium (12 dB, default), strong (20 dB)."),
|
|
16
|
-
output: z.string().optional().describe("Optional output path. Defaults under SCREENCAST_HOME/edits."),
|
|
17
|
-
overwrite: z.boolean().optional().describe("Allow replacing an existing file at the output path (default false)."),
|
|
18
|
-
};
|
|
19
|
-
export function register(server) {
|
|
20
|
-
server.registerTool("denoise", {
|
|
21
|
-
title: "Denoise Audio",
|
|
22
|
-
description: "Reduce steady background noise (fan, hum, hiss) in a recording's audio with an " +
|
|
23
|
-
"adaptive FFT denoiser. Video is copied untouched. Returns the output path.",
|
|
24
|
-
inputSchema,
|
|
25
|
-
outputSchema: OUTPUT_PATH,
|
|
26
|
-
annotations: WRITES_FILE,
|
|
27
|
-
}, async (args, extra) => {
|
|
28
|
-
try {
|
|
29
|
-
requireFfmpeg();
|
|
30
|
-
if (!existsSync(args.input)) {
|
|
31
|
-
throw new ScreencastError(`Input file not found: ${args.input}`);
|
|
32
|
-
}
|
|
33
|
-
const info = await probeMedia(args.input);
|
|
34
|
-
if (!info.audioCodec)
|
|
35
|
-
throw new ScreencastError(`Input has no audio stream: ${args.input}`);
|
|
36
|
-
const strength = args.strength ?? "medium";
|
|
37
|
-
assertEditContainer(args.output);
|
|
38
|
-
const ext = editOutputExt(args.input, { audio: true });
|
|
39
|
-
const output = resolveOutput(args.output, subdir("edits"), `denoise-${stamp()}-${rand()}${ext}`, args.overwrite);
|
|
40
|
-
const scan = await runCapture(requireFfmpeg().ffmpeg, buildNoiseFloorArgs(args.input), jobTimeoutMs(info.durationSec), {
|
|
41
|
-
signal: extra.signal,
|
|
42
|
-
});
|
|
43
|
-
const floor = parseNoiseFloor(scan.stdout);
|
|
44
|
-
await runEditJob(buildDenoiseArgs(args.input, output, strength, floor), {
|
|
45
|
-
output,
|
|
46
|
-
durationSec: info.durationSec,
|
|
47
|
-
extra,
|
|
48
|
-
});
|
|
49
|
-
return okResponse({
|
|
50
|
-
outputPath: output,
|
|
51
|
-
strength,
|
|
52
|
-
noiseFloorDb: floor === null ? null : Number(floor.toFixed(1)),
|
|
53
|
-
note: "Works best on steady noise (fans, hum, hiss); it does little for intermittent sounds.",
|
|
54
|
-
});
|
|
55
|
-
}
|
|
56
|
-
catch (error) {
|
|
57
|
-
return errorResponse(error);
|
|
58
|
-
}
|
|
59
|
-
});
|
|
60
|
-
}
|
package/dist/tools/doctor.js
DELETED
|
@@ -1,146 +0,0 @@
|
|
|
1
|
-
import { createRequire } from "node:module";
|
|
2
|
-
import { existsSync } from "node:fs";
|
|
3
|
-
import { join } from "node:path";
|
|
4
|
-
import { z } from "zod";
|
|
5
|
-
import { errorResponse, okResponse } from "../utils/errors.js";
|
|
6
|
-
import { READ_ONLY, looseOutput } from "../utils/toolSpec.js";
|
|
7
|
-
import { detectFfmpeg, hasFilter, wgcAvailable } from "../utils/ffmpeg.js";
|
|
8
|
-
import { allowedOutputDirs, envAllowedDirs, homeRoot } from "../utils/paths.js";
|
|
9
|
-
import { FFMPEG_FEATURE_MAJOR, KEY_FILTERS, devicesText, envSettings, locate, ocrStatus, parseDevices, parseFfmpegVersion, versionText, } from "../utils/capabilities.js";
|
|
10
|
-
import { parseToolsets, SELECTABLE_TOOLSETS } from "../utils/toolsets.js";
|
|
11
|
-
import { ttsStatus } from "../utils/narrate.js";
|
|
12
|
-
import { probeHwEncoders } from "../utils/gpu.js";
|
|
13
|
-
const { version: serverVersion } = createRequire(import.meta.url)("../../package.json");
|
|
14
|
-
const binary = z.looseObject({
|
|
15
|
-
found: z.boolean(),
|
|
16
|
-
path: z.string().nullable(),
|
|
17
|
-
version: z.string().nullable(),
|
|
18
|
-
major: z.number().nullable(),
|
|
19
|
-
});
|
|
20
|
-
const outputSchema = looseOutput({
|
|
21
|
-
ok: z.boolean(),
|
|
22
|
-
problems: z.array(z.string()),
|
|
23
|
-
server: z.looseObject({ version: z.string(), node: z.string(), platform: z.string(), arch: z.string() }),
|
|
24
|
-
ffmpeg: binary.extend({ meetsFfmpeg8: z.boolean().nullable() }),
|
|
25
|
-
ffprobe: binary,
|
|
26
|
-
filters: z.record(z.string(), z.boolean()),
|
|
27
|
-
devices: z.looseObject({ gdigrab: z.boolean(), dshow: z.boolean() }),
|
|
28
|
-
wgc: z.looseObject({ available: z.boolean() }),
|
|
29
|
-
ocr: z.looseObject({ available: z.boolean(), language: z.string().nullable(), languages: z.array(z.string()) }),
|
|
30
|
-
storage: z.looseObject({ home: z.string(), homeExists: z.boolean() }),
|
|
31
|
-
env: z.record(z.string(), z.string().nullable()),
|
|
32
|
-
});
|
|
33
|
-
function errorText(err) {
|
|
34
|
-
const first = errorResponse(err).content[0];
|
|
35
|
-
return first?.type === "text" ? first.text.replace(/\s*\n+\s*/g, " ") : String(err);
|
|
36
|
-
}
|
|
37
|
-
function describeBinary(bin) {
|
|
38
|
-
const text = versionText(bin);
|
|
39
|
-
const parsed = parseFfmpegVersion(text ?? "");
|
|
40
|
-
return {
|
|
41
|
-
found: text !== null,
|
|
42
|
-
path: text !== null ? locate(bin) : null,
|
|
43
|
-
version: parsed.version,
|
|
44
|
-
major: parsed.major,
|
|
45
|
-
...(parsed.inferred ? { majorInferred: true } : {}),
|
|
46
|
-
};
|
|
47
|
-
}
|
|
48
|
-
export function register(server) {
|
|
49
|
-
server.registerTool("doctor", {
|
|
50
|
-
title: "Check Setup",
|
|
51
|
-
description: `Check the setup: ffmpeg/ffprobe (FFmpeg ${FFMPEG_FEATURE_MAJOR}+?), optional filters, capture ` +
|
|
52
|
-
"devices, Windows OCR, settings, and enabled toolsets; `problems` says what is missing and how to " +
|
|
53
|
-
"fix it. Call on first use or when a tool reports a missing feature.",
|
|
54
|
-
inputSchema: {},
|
|
55
|
-
outputSchema,
|
|
56
|
-
annotations: READ_ONLY,
|
|
57
|
-
}, async () => {
|
|
58
|
-
try {
|
|
59
|
-
const problems = [];
|
|
60
|
-
let tools = null;
|
|
61
|
-
try {
|
|
62
|
-
tools = detectFfmpeg();
|
|
63
|
-
}
|
|
64
|
-
catch (err) {
|
|
65
|
-
problems.push(errorText(err));
|
|
66
|
-
}
|
|
67
|
-
const ffmpeg = describeBinary(tools?.ffmpeg ?? (process.env.FFMPEG_PATH?.trim() || "ffmpeg"));
|
|
68
|
-
const ffprobe = describeBinary(tools?.ffprobe ?? (process.env.FFPROBE_PATH?.trim() || "ffprobe"));
|
|
69
|
-
const meetsFfmpeg8 = ffmpeg.major === null ? null : ffmpeg.major >= FFMPEG_FEATURE_MAJOR;
|
|
70
|
-
if (tools && meetsFfmpeg8 === false) {
|
|
71
|
-
problems.push(`FFmpeg ${ffmpeg.version} is older than ${FFMPEG_FEATURE_MAJOR}: transcribe and backend "wgc" need FFmpeg ${FFMPEG_FEATURE_MAJOR}+. ` +
|
|
72
|
-
"Windows: `winget install Gyan.FFmpeg`.");
|
|
73
|
-
}
|
|
74
|
-
const filters = {};
|
|
75
|
-
let devices = { gdigrab: false, dshow: false };
|
|
76
|
-
if (tools) {
|
|
77
|
-
for (const f of KEY_FILTERS) {
|
|
78
|
-
filters[f.filter] = f.filter === "gfxcapture" ? wgcAvailable() : hasFilter(f.filter);
|
|
79
|
-
if (!filters[f.filter] && !(f.filter === "gfxcapture" && process.platform !== "win32")) {
|
|
80
|
-
problems.push(`No ${f.filter} filter: ${f.tools} unavailable (needs ${f.why}).`);
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
const names = parseDevices(devicesText(tools.ffmpeg) ?? "");
|
|
84
|
-
devices = { gdigrab: names.includes("gdigrab"), dshow: names.includes("dshow") };
|
|
85
|
-
if (process.platform === "win32" && !devices.gdigrab) {
|
|
86
|
-
problems.push("This ffmpeg has no gdigrab device: screenshot and start_recording cannot capture the screen.");
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
if (process.platform !== "win32") {
|
|
90
|
-
problems.push("Not Windows: capture (screenshot, start_recording, list_targets) and OCR are unavailable; the watch and edit tools work.");
|
|
91
|
-
}
|
|
92
|
-
const gpu = tools
|
|
93
|
-
? {
|
|
94
|
-
ddagrab: process.platform === "win32" && hasFilter("ddagrab"),
|
|
95
|
-
encoders: await probeHwEncoders(tools.ffmpeg),
|
|
96
|
-
}
|
|
97
|
-
: null;
|
|
98
|
-
const [ocr, tts] = await Promise.all([ocrStatus(), ttsStatus()]);
|
|
99
|
-
if (process.platform === "win32" && !ocr.available) {
|
|
100
|
-
problems.push(`Windows OCR unavailable: find_text cannot read the screen. ${ocr.error ?? "Install an OCR language (Settings > Time & language > Language)."}`);
|
|
101
|
-
}
|
|
102
|
-
if (process.platform === "win32" && !tts.available) {
|
|
103
|
-
problems.push(`Windows speech unavailable: narrate cannot speak. ${tts.error ?? ""} Install a voice (Settings > Time & language > Speech).`.replace(/\s+/g, " "));
|
|
104
|
-
}
|
|
105
|
-
const env = envSettings();
|
|
106
|
-
const model = env.SCREENCAST_WHISPER_MODEL;
|
|
107
|
-
if (model && !existsSync(model))
|
|
108
|
-
problems.push(`SCREENCAST_WHISPER_MODEL points at a missing file: ${model}`);
|
|
109
|
-
const home = homeRoot();
|
|
110
|
-
for (const dir of envAllowedDirs()) {
|
|
111
|
-
if (!existsSync(dir))
|
|
112
|
-
problems.push(`SCREENCAST_ALLOWED_DIRS names a missing folder: ${dir}`);
|
|
113
|
-
}
|
|
114
|
-
const toolsets = parseToolsets(env.SCREENCAST_TOOLSETS ?? undefined);
|
|
115
|
-
if (toolsets.unknown.length > 0) {
|
|
116
|
-
problems.push(`SCREENCAST_TOOLSETS names unknown toolsets (ignored): ${toolsets.unknown.join(", ")}.`);
|
|
117
|
-
}
|
|
118
|
-
return okResponse({
|
|
119
|
-
ok: problems.length === 0,
|
|
120
|
-
problems,
|
|
121
|
-
server: { version: serverVersion, node: process.version, platform: process.platform, arch: process.arch },
|
|
122
|
-
ffmpeg: { ...ffmpeg, meetsFfmpeg8 },
|
|
123
|
-
ffprobe,
|
|
124
|
-
filters,
|
|
125
|
-
devices,
|
|
126
|
-
wgc: { available: filters.gfxcapture === true },
|
|
127
|
-
...(gpu ? { gpu } : {}),
|
|
128
|
-
ocr,
|
|
129
|
-
tts,
|
|
130
|
-
storage: {
|
|
131
|
-
home,
|
|
132
|
-
homeExists: existsSync(home),
|
|
133
|
-
recordings: join(home, "recordings"),
|
|
134
|
-
screenshots: join(home, "screenshots"),
|
|
135
|
-
edits: join(home, "edits"),
|
|
136
|
-
allowedOutputDirs: allowedOutputDirs(),
|
|
137
|
-
},
|
|
138
|
-
env,
|
|
139
|
-
toolsets: { enabled: toolsets.enabled, available: ["all", ...SELECTABLE_TOOLSETS] },
|
|
140
|
-
});
|
|
141
|
-
}
|
|
142
|
-
catch (error) {
|
|
143
|
-
return errorResponse(error);
|
|
144
|
-
}
|
|
145
|
-
});
|
|
146
|
-
}
|
package/dist/tools/exportGif.js
DELETED
|
@@ -1,57 +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 } from "../utils/ffmpeg.js";
|
|
6
|
-
import { DEFAULT_ANIM_FPS, DEFAULT_ANIM_WIDTH, DEFAULT_MAX_BYTES } from "../utils/anim.js";
|
|
7
|
-
import { exportAnimation } from "../utils/animExport.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
|
-
format: z
|
|
12
|
-
.enum(["gif", "webp"])
|
|
13
|
-
.optional()
|
|
14
|
-
.describe("gif (default) or webp (usually much smaller)."),
|
|
15
|
-
maxBytes: z
|
|
16
|
-
.number()
|
|
17
|
-
.int()
|
|
18
|
-
.min(10_000)
|
|
19
|
-
.optional()
|
|
20
|
-
.describe(`Size budget in bytes (default ${DEFAULT_MAX_BYTES}, under GitHub's 10 MB image limit).`),
|
|
21
|
-
fps: z.number().positive().max(30).optional().describe(`Starting frame rate (default ${DEFAULT_ANIM_FPS}).`),
|
|
22
|
-
width: z
|
|
23
|
-
.number()
|
|
24
|
-
.int()
|
|
25
|
-
.min(64)
|
|
26
|
-
.max(1920)
|
|
27
|
-
.optional()
|
|
28
|
-
.describe(`Starting width in px (default ${DEFAULT_ANIM_WIDTH}).`),
|
|
29
|
-
start: z.number().nonnegative().optional().describe("Start second."),
|
|
30
|
-
duration: z.number().positive().optional().describe("Seconds to export (default: to the end)."),
|
|
31
|
-
output: z.string().optional().describe("Optional output path. Defaults under SCREENCAST_HOME/edits."),
|
|
32
|
-
overwrite: z.boolean().optional().describe("Allow replacing an existing file at the output path (default false)."),
|
|
33
|
-
};
|
|
34
|
-
export function register(server) {
|
|
35
|
-
server.registerTool("export_gif", {
|
|
36
|
-
title: "Export GIF or WebP",
|
|
37
|
-
description: "Export an animated GIF or WebP that fits a size budget (for PRs, issues, READMEs), stepping " +
|
|
38
|
-
"fps, width, and quality down until it fits.",
|
|
39
|
-
inputSchema,
|
|
40
|
-
outputSchema: OUTPUT_PATH,
|
|
41
|
-
annotations: WRITES_FILE,
|
|
42
|
-
}, async (args, extra) => {
|
|
43
|
-
try {
|
|
44
|
-
requireFfmpeg();
|
|
45
|
-
if (!existsSync(args.input)) {
|
|
46
|
-
throw new ScreencastError(`Input file not found: ${args.input}`);
|
|
47
|
-
}
|
|
48
|
-
const format = args.format ?? "gif";
|
|
49
|
-
const maxBytes = args.maxBytes ?? DEFAULT_MAX_BYTES;
|
|
50
|
-
const output = resolveOutput(args.output, subdir("edits"), `anim-${stamp()}-${rand()}.${format}`, args.overwrite);
|
|
51
|
-
return okResponse(await exportAnimation(args.input, output, { format, maxBytes, fps: args.fps, width: args.width, start: args.start, duration: args.duration }, extra));
|
|
52
|
-
}
|
|
53
|
-
catch (error) {
|
|
54
|
-
return errorResponse(error);
|
|
55
|
-
}
|
|
56
|
-
});
|
|
57
|
-
}
|
|
@@ -1,48 +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 } from "../utils/ffmpeg.js";
|
|
6
|
-
import { runEditJob, probeDuration } from "../utils/jobs.js";
|
|
7
|
-
import { buildExportPresetArgs, PLATFORM_PRESETS, PLATFORMS, } from "../utils/produce.js";
|
|
8
|
-
import { resolveOutput, subdir, stamp, rand } from "../utils/paths.js";
|
|
9
|
-
import { assertEditContainer } from "../utils/media.js";
|
|
10
|
-
const inputSchema = {
|
|
11
|
-
input: z.string().min(1).describe("Path to the source video."),
|
|
12
|
-
platform: z
|
|
13
|
-
.enum(PLATFORMS)
|
|
14
|
-
.describe("Sets aspect, size, fps, bitrate. steam_trailer: 1080p 5.5 Mbps CBR, -14 LUFS. vertical_reel: " +
|
|
15
|
-
"1080x1920 over a blurred copy of itself, -14 LUFS (ignores fit)."),
|
|
16
|
-
fit: z
|
|
17
|
-
.enum(["pad", "crop"])
|
|
18
|
-
.optional()
|
|
19
|
-
.describe("Fit to the platform aspect: pad (default) or crop."),
|
|
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("export_preset", {
|
|
25
|
-
title: "Export for Platform",
|
|
26
|
-
description: "Encode a platform-ready H.264 file (aspect, fps, bitrate, faststart) for a named platform.",
|
|
27
|
-
inputSchema,
|
|
28
|
-
outputSchema: OUTPUT_PATH,
|
|
29
|
-
annotations: WRITES_FILE,
|
|
30
|
-
}, async (args, extra) => {
|
|
31
|
-
try {
|
|
32
|
-
requireFfmpeg();
|
|
33
|
-
if (!existsSync(args.input)) {
|
|
34
|
-
throw new ScreencastError(`Input file not found: ${args.input}`);
|
|
35
|
-
}
|
|
36
|
-
assertEditContainer(args.output);
|
|
37
|
-
const platform = args.platform;
|
|
38
|
-
const output = resolveOutput(args.output, subdir("edits"), `${platform}-${stamp()}-${rand()}.mp4`, args.overwrite);
|
|
39
|
-
const ffArgs = buildExportPresetArgs(args.input, output, platform, args.fit ?? "pad");
|
|
40
|
-
await runEditJob(ffArgs, { output, durationSec: await probeDuration(args.input), extra });
|
|
41
|
-
const spec = PLATFORM_PRESETS[platform];
|
|
42
|
-
return okResponse({ outputPath: output, platform, aspect: spec.aspect, fps: spec.fps });
|
|
43
|
-
}
|
|
44
|
-
catch (error) {
|
|
45
|
-
return errorResponse(error);
|
|
46
|
-
}
|
|
47
|
-
});
|
|
48
|
-
}
|
|
@@ -1,65 +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, runCapture } from "../utils/ffmpeg.js";
|
|
6
|
-
import { runEditJob, probeDuration } from "../utils/jobs.js";
|
|
7
|
-
import { buildExtractAudioArgs, buildProbeArgs, parseMediaInfo, copyAudioExtension, } from "../utils/media.js";
|
|
8
|
-
import { resolveOutput, subdir, stamp, rand } from "../utils/paths.js";
|
|
9
|
-
const EXTENSION = {
|
|
10
|
-
mp3: "mp3",
|
|
11
|
-
aac: "m4a",
|
|
12
|
-
wav: "wav",
|
|
13
|
-
};
|
|
14
|
-
const inputSchema = {
|
|
15
|
-
input: z.string().min(1).describe("Path to the source media."),
|
|
16
|
-
format: z
|
|
17
|
-
.enum(["mp3", "aac", "wav", "copy"])
|
|
18
|
-
.describe("Audio output codec. copy keeps the source codec without re-encoding."),
|
|
19
|
-
output: z.string().optional().describe("Optional output path. Defaults under SCREENCAST_HOME/edits."),
|
|
20
|
-
overwrite: z.boolean().optional().describe("Allow replacing an existing file at the output path (default false)."),
|
|
21
|
-
};
|
|
22
|
-
export function register(server) {
|
|
23
|
-
server.registerTool("extract_audio", {
|
|
24
|
-
title: "Extract Audio",
|
|
25
|
-
description: "Extract the audio track of a media file to its own file (mp3, aac, wav, " +
|
|
26
|
-
"or copy). Returns the output path.",
|
|
27
|
-
inputSchema,
|
|
28
|
-
outputSchema: OUTPUT_PATH,
|
|
29
|
-
annotations: WRITES_FILE,
|
|
30
|
-
}, async (args, extra) => {
|
|
31
|
-
try {
|
|
32
|
-
const { ffprobe } = requireFfmpeg();
|
|
33
|
-
if (!existsSync(args.input)) {
|
|
34
|
-
throw new ScreencastError(`Input file not found: ${args.input}`);
|
|
35
|
-
}
|
|
36
|
-
const format = args.format;
|
|
37
|
-
let audioCodec = null;
|
|
38
|
-
let ext;
|
|
39
|
-
if (format === "copy") {
|
|
40
|
-
const res = await runCapture(ffprobe, buildProbeArgs(args.input), 30_000, { signal: extra.signal });
|
|
41
|
-
if (res.code !== 0) {
|
|
42
|
-
throw new ScreencastError(`ffprobe failed (exit ${res.code}): ${res.stderr.trim().slice(-400)}`);
|
|
43
|
-
}
|
|
44
|
-
audioCodec = parseMediaInfo(JSON.parse(res.stdout)).audioCodec;
|
|
45
|
-
if (!audioCodec) {
|
|
46
|
-
throw new ScreencastError(`Input has no audio stream to extract: ${args.input}`);
|
|
47
|
-
}
|
|
48
|
-
ext = copyAudioExtension(audioCodec);
|
|
49
|
-
}
|
|
50
|
-
else {
|
|
51
|
-
ext = EXTENSION[format];
|
|
52
|
-
}
|
|
53
|
-
const output = resolveOutput(args.output, subdir("edits"), `audio-${stamp()}-${rand()}.${ext}`, args.overwrite);
|
|
54
|
-
await runEditJob(buildExtractAudioArgs(args.input, output, format), { output, durationSec: await probeDuration(args.input), extra });
|
|
55
|
-
return okResponse({
|
|
56
|
-
outputPath: output,
|
|
57
|
-
format,
|
|
58
|
-
...(audioCodec ? { sourceAudioCodec: audioCodec } : {}),
|
|
59
|
-
});
|
|
60
|
-
}
|
|
61
|
-
catch (error) {
|
|
62
|
-
return errorResponse(error);
|
|
63
|
-
}
|
|
64
|
-
});
|
|
65
|
-
}
|
package/dist/tools/findText.js
DELETED
|
@@ -1,194 +0,0 @@
|
|
|
1
|
-
import { z } from "zod";
|
|
2
|
-
import { extname, 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 { resolveCaptureTarget } from "../utils/resolveTarget.js";
|
|
9
|
-
import { captureStill } from "../utils/still.js";
|
|
10
|
-
import { buildHighlightArgs, targetSize } from "../utils/diff.js";
|
|
11
|
-
import { findMatches, redactionRects } from "../utils/ocr.js";
|
|
12
|
-
import { readFrames, scanVideoFrames, scanMatches, DEFAULT_SCAN_FRAMES, MAX_SCAN_FRAMES } from "../utils/ocrScan.js";
|
|
13
|
-
import { windowMatchReport } from "../utils/windows.js";
|
|
14
|
-
import { confirmCapture, describeTarget } from "../utils/consent.js";
|
|
15
|
-
import { subdir, stamp, rand, stillOutput } from "../utils/paths.js";
|
|
16
|
-
import { encodeInlineImages, DEFAULT_MAX_IMAGE_WIDTH } from "../utils/images.js";
|
|
17
|
-
const IMAGE_EXTENSIONS = new Set([".png", ".jpg", ".jpeg", ".bmp", ".gif", ".webp", ".tif", ".tiff"]);
|
|
18
|
-
const MAX_LINES = 300;
|
|
19
|
-
const inputSchema = {
|
|
20
|
-
target: z
|
|
21
|
-
.string()
|
|
22
|
-
.optional()
|
|
23
|
-
.describe("Live screen target (full | monitor:<i> | window:... | region:...), or pass input."),
|
|
24
|
-
input: z.string().optional().describe("Image or video file to read instead of a live target."),
|
|
25
|
-
timestamp: z.number().nonnegative().optional().describe("Video input: second to read (default 0)."),
|
|
26
|
-
scanEverySec: z
|
|
27
|
-
.number()
|
|
28
|
-
.positive()
|
|
29
|
-
.optional()
|
|
30
|
-
.describe("Video input: scan a frame every N s across the clip (e.g. for secrets before sharing); matches " +
|
|
31
|
-
"and redactRegions get times. Widens to stay within maxFrames."),
|
|
32
|
-
maxFrames: z
|
|
33
|
-
.number()
|
|
34
|
-
.int()
|
|
35
|
-
.min(1)
|
|
36
|
-
.max(MAX_SCAN_FRAMES)
|
|
37
|
-
.optional()
|
|
38
|
-
.describe(`scanEverySec frame cap (default ${DEFAULT_SCAN_FRAMES}; ~1 s each).`),
|
|
39
|
-
exactTitle: z.boolean().optional().describe("window: targets match the whole title only (default false)."),
|
|
40
|
-
backend: z
|
|
41
|
-
.enum(["gdigrab", "wgc"])
|
|
42
|
-
.optional()
|
|
43
|
-
.describe("Live target: gdigrab (default) = what is visible; wgc (window:, FFmpeg 8+) = the window even if covered."),
|
|
44
|
-
query: z
|
|
45
|
-
.string()
|
|
46
|
-
.optional()
|
|
47
|
-
.describe("Text to find (case-insensitive, tolerates OCR misreads like I/l, O/0, _/-). Omit to return all text."),
|
|
48
|
-
regex: z.boolean().optional().describe("Treat query as a regular expression (case-insensitive)."),
|
|
49
|
-
redact: z
|
|
50
|
-
.boolean()
|
|
51
|
-
.optional()
|
|
52
|
-
.describe("Also return padded match rectangles ready for redact_region's regions."),
|
|
53
|
-
keep: z
|
|
54
|
-
.boolean()
|
|
55
|
-
.optional()
|
|
56
|
-
.describe("Live target: keep the capture and return its path (default false: deleted after reading)."),
|
|
57
|
-
returnImage: z
|
|
58
|
-
.boolean()
|
|
59
|
-
.optional()
|
|
60
|
-
.describe("Return the image with matches outlined (default: true with a query)."),
|
|
61
|
-
};
|
|
62
|
-
export function register(server) {
|
|
63
|
-
server.registerTool("find_text", {
|
|
64
|
-
title: "Find Text (OCR)",
|
|
65
|
-
description: "OCR (built into Windows) on the screen, an image, or video frames, with line and match boxes " +
|
|
66
|
-
"in image pixels (add `origin` for desktop coordinates). Locate UI text or secrets (e.g. regex " +
|
|
67
|
-
"'sk-|ghp_|api.?key') to redact. Best-effort: review results.",
|
|
68
|
-
inputSchema,
|
|
69
|
-
outputSchema: looseOutput({
|
|
70
|
-
imageSize: looseOutput({ width: z.number(), height: z.number() }),
|
|
71
|
-
}),
|
|
72
|
-
annotations: READ_ONLY,
|
|
73
|
-
}, async (args, extra) => {
|
|
74
|
-
try {
|
|
75
|
-
requireFfmpeg();
|
|
76
|
-
if ((args.target === undefined) === (args.input === undefined)) {
|
|
77
|
-
throw new ScreencastError("Provide exactly one of: target (live screen) or input (a file).");
|
|
78
|
-
}
|
|
79
|
-
const work = mkdtempSync(join(tmpdir(), "screencast-ocr-"));
|
|
80
|
-
try {
|
|
81
|
-
if (args.scanEverySec !== undefined)
|
|
82
|
-
return await scanClip(args, work, extra.signal);
|
|
83
|
-
let source;
|
|
84
|
-
let windowReport = {};
|
|
85
|
-
let origin;
|
|
86
|
-
if (args.target !== undefined) {
|
|
87
|
-
const resolved = await resolveCaptureTarget(args.target, { exactTitle: args.exactTitle, backend: args.backend });
|
|
88
|
-
source = args.keep ? join(subdir("screenshots"), `ocr-${stamp()}-${rand()}.png`) : join(work, "capture.png");
|
|
89
|
-
const backend = args.backend ?? "gdigrab";
|
|
90
|
-
await confirmCapture(server, `Capture ${describeTarget(args.target, resolved.window)} once to read the text on it?`, extra.signal);
|
|
91
|
-
await captureStill(resolved, source, backend);
|
|
92
|
-
if (resolved.window)
|
|
93
|
-
windowReport = windowMatchReport(resolved.window);
|
|
94
|
-
const area = targetSize(resolved.target, resolved.monitors);
|
|
95
|
-
origin = backend === "wgc" && resolved.window?.client ? resolved.window.client : { x: area.x, y: area.y };
|
|
96
|
-
}
|
|
97
|
-
else {
|
|
98
|
-
if (!existsSync(args.input))
|
|
99
|
-
throw new ScreencastError(`Input file not found: ${args.input}`);
|
|
100
|
-
const isImage = IMAGE_EXTENSIONS.has(extname(args.input).toLowerCase());
|
|
101
|
-
source = join(work, "frame.png");
|
|
102
|
-
await runFfmpeg(["-y", "-v", "error", ...(isImage ? [] : ["-ss", String(args.timestamp ?? 0)]), "-i", args.input, "-frames:v", "1", ...stillOutput(source)], 60_000, { signal: extra.signal });
|
|
103
|
-
}
|
|
104
|
-
const [frame] = await readFrames([source], work, extra.signal);
|
|
105
|
-
if (!frame)
|
|
106
|
-
throw new ScreencastError("Could not read the frame.");
|
|
107
|
-
const { lines, width, height } = frame;
|
|
108
|
-
const matches = args.query ? findMatches(lines, args.query, args.regex === true) : [];
|
|
109
|
-
const images = [];
|
|
110
|
-
const wantImage = args.returnImage ?? Boolean(args.query);
|
|
111
|
-
if (wantImage) {
|
|
112
|
-
const shown = join(work, "shown.png");
|
|
113
|
-
await runFfmpeg(buildHighlightArgs(source, matches, shown), 30_000, { signal: extra.signal });
|
|
114
|
-
images.push(...(await encodeInlineImages([shown], DEFAULT_MAX_IMAGE_WIDTH, 1)).images);
|
|
115
|
-
}
|
|
116
|
-
return okResponse({
|
|
117
|
-
...(args.target !== undefined ? (args.keep ? { screenshotPath: source } : {}) : { input: args.input }),
|
|
118
|
-
imageSize: { width, height },
|
|
119
|
-
...(origin ? { origin } : {}),
|
|
120
|
-
...(args.query
|
|
121
|
-
? {
|
|
122
|
-
query: args.query,
|
|
123
|
-
matchCount: matches.length,
|
|
124
|
-
matches,
|
|
125
|
-
...(args.redact ? { redactRegions: redactionRects(matches, { width, height }) } : {}),
|
|
126
|
-
}
|
|
127
|
-
: {}),
|
|
128
|
-
text: lines.map((l) => l.text).join("\n"),
|
|
129
|
-
lines: lines.slice(0, MAX_LINES).map(({ words: _w, ...l }) => l),
|
|
130
|
-
...(lines.length > MAX_LINES ? { linesTruncated: lines.length - MAX_LINES } : {}),
|
|
131
|
-
...windowReport,
|
|
132
|
-
note: "OCR is best-effort: small or stylised text can be missed. Review before relying on it, especially for redaction.",
|
|
133
|
-
}, images);
|
|
134
|
-
}
|
|
135
|
-
finally {
|
|
136
|
-
rmSync(work, { recursive: true, force: true });
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
|
-
catch (error) {
|
|
140
|
-
return errorResponse(error);
|
|
141
|
-
}
|
|
142
|
-
});
|
|
143
|
-
}
|
|
144
|
-
async function scanClip(args, work, signal) {
|
|
145
|
-
if (args.input === undefined)
|
|
146
|
-
throw new ScreencastError("scanEverySec reads a video file: pass input, not target.");
|
|
147
|
-
if (!existsSync(args.input))
|
|
148
|
-
throw new ScreencastError(`Input file not found: ${args.input}`);
|
|
149
|
-
if (IMAGE_EXTENSIONS.has(extname(args.input).toLowerCase())) {
|
|
150
|
-
throw new ScreencastError("scanEverySec is for a video input; an image has one frame, so drop scanEverySec.");
|
|
151
|
-
}
|
|
152
|
-
const maxFrames = args.maxFrames ?? DEFAULT_SCAN_FRAMES;
|
|
153
|
-
const scan = await scanVideoFrames(args.input, { everySec: args.scanEverySec, maxFrames }, work, signal);
|
|
154
|
-
const { step } = scan;
|
|
155
|
-
const [size] = scan.frames;
|
|
156
|
-
if (!size)
|
|
157
|
-
throw new ScreencastError("Could not read any frames from the video.");
|
|
158
|
-
const seenLines = new Set();
|
|
159
|
-
for (const frame of scan.frames)
|
|
160
|
-
for (const l of frame.lines)
|
|
161
|
-
seenLines.add(l.text);
|
|
162
|
-
const { matches, redactRegions } = args.query
|
|
163
|
-
? scanMatches(scan, args.query, args.regex === true)
|
|
164
|
-
: { matches: [], redactRegions: [] };
|
|
165
|
-
const images = [];
|
|
166
|
-
const first = matches[0];
|
|
167
|
-
const firstFrame = first && scan.frames.find((f) => f.t === first.t)?.path;
|
|
168
|
-
if ((args.returnImage ?? Boolean(args.query)) && first && firstFrame) {
|
|
169
|
-
const shown = join(work, "shown.png");
|
|
170
|
-
await runFfmpeg(buildHighlightArgs(firstFrame, matches.filter((m) => m.t === first.t), shown), 30_000, { signal });
|
|
171
|
-
images.push(...(await encodeInlineImages([shown], DEFAULT_MAX_IMAGE_WIDTH, 1)).images);
|
|
172
|
-
}
|
|
173
|
-
const text = [...seenLines].join("\n");
|
|
174
|
-
return okResponse({
|
|
175
|
-
input: args.input,
|
|
176
|
-
imageSize: { width: size.width, height: size.height },
|
|
177
|
-
scan: {
|
|
178
|
-
everySec: Math.round(step * 1000) / 1000,
|
|
179
|
-
framesScanned: scan.frames.length,
|
|
180
|
-
...(scan.clamped ? { note: `Widened from ${args.scanEverySec} s to fit maxFrames ${maxFrames}.` } : {}),
|
|
181
|
-
},
|
|
182
|
-
...(args.query
|
|
183
|
-
? {
|
|
184
|
-
query: args.query,
|
|
185
|
-
matchCount: matches.length,
|
|
186
|
-
matches: matches.slice(0, MAX_LINES),
|
|
187
|
-
...(args.redact ? { redactRegions } : {}),
|
|
188
|
-
}
|
|
189
|
-
: {}),
|
|
190
|
-
text: text.length > 20_000 ? `${text.slice(0, 20_000)}...` : text,
|
|
191
|
-
note: "OCR is best-effort and reads only the sampled frames: text shown briefly between samples, or small " +
|
|
192
|
-
"or stylised text, can be missed. Review before sharing, especially for redaction.",
|
|
193
|
-
}, images);
|
|
194
|
-
}
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import { z } from "zod";
|
|
2
|
-
import { existsSync } from "node:fs";
|
|
3
|
-
import { errorResponse, okResponse, ScreencastError } from "../utils/errors.js";
|
|
4
|
-
import { READ_ONLY, looseOutput } from "../utils/toolSpec.js";
|
|
5
|
-
import { probeMedia } from "../utils/ffmpeg.js";
|
|
6
|
-
const inputSchema = {
|
|
7
|
-
input: z.string().min(1).describe("Path to the media file to probe."),
|
|
8
|
-
};
|
|
9
|
-
export function register(server) {
|
|
10
|
-
server.registerTool("get_media_info", {
|
|
11
|
-
title: "Get Media Info",
|
|
12
|
-
description: "Probe a media file with ffprobe and return duration, resolution, frame " +
|
|
13
|
-
"rate, codecs, container format, and size.",
|
|
14
|
-
inputSchema,
|
|
15
|
-
outputSchema: looseOutput({
|
|
16
|
-
input: z.string(),
|
|
17
|
-
durationSec: z.number().nullable(),
|
|
18
|
-
width: z.number().nullable(),
|
|
19
|
-
height: z.number().nullable(),
|
|
20
|
-
fps: z.number().nullable(),
|
|
21
|
-
videoCodec: z.string().nullable(),
|
|
22
|
-
audioCodec: z.string().nullable(),
|
|
23
|
-
}),
|
|
24
|
-
annotations: READ_ONLY,
|
|
25
|
-
}, async (args) => {
|
|
26
|
-
try {
|
|
27
|
-
if (!existsSync(args.input)) {
|
|
28
|
-
throw new ScreencastError(`Input file not found: ${args.input}`);
|
|
29
|
-
}
|
|
30
|
-
return okResponse({ input: args.input, ...(await probeMedia(args.input)) });
|
|
31
|
-
}
|
|
32
|
-
catch (error) {
|
|
33
|
-
return errorResponse(error);
|
|
34
|
-
}
|
|
35
|
-
});
|
|
36
|
-
}
|
package/dist/tools/getSession.js
DELETED
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import { z } from "zod";
|
|
2
|
-
import { existsSync } from "node:fs";
|
|
3
|
-
import { errorResponse, okResponse, ScreencastError } from "../utils/errors.js";
|
|
4
|
-
import { READ_ONLY, looseOutput } from "../utils/toolSpec.js";
|
|
5
|
-
import { isAlive } from "../utils/sessions.js";
|
|
6
|
-
import { getStore } from "../context.js";
|
|
7
|
-
const inputSchema = {
|
|
8
|
-
sessionId: z.string().min(1).describe("Session id returned by start_recording."),
|
|
9
|
-
};
|
|
10
|
-
export function register(server) {
|
|
11
|
-
server.registerTool("get_session", {
|
|
12
|
-
title: "Get Session",
|
|
13
|
-
description: "Inspect a single recording session by id, including live status and " +
|
|
14
|
-
"whether its output file exists on disk.",
|
|
15
|
-
inputSchema,
|
|
16
|
-
outputSchema: looseOutput({
|
|
17
|
-
id: z.string(),
|
|
18
|
-
status: z.string(),
|
|
19
|
-
outputPath: z.string(),
|
|
20
|
-
alive: z.boolean(),
|
|
21
|
-
fileExists: z.boolean(),
|
|
22
|
-
}),
|
|
23
|
-
annotations: READ_ONLY,
|
|
24
|
-
}, async (args) => {
|
|
25
|
-
try {
|
|
26
|
-
const record = getStore().get(args.sessionId);
|
|
27
|
-
if (!record) {
|
|
28
|
-
throw new ScreencastError(`No session with id "${args.sessionId}".`);
|
|
29
|
-
}
|
|
30
|
-
return okResponse({
|
|
31
|
-
...record,
|
|
32
|
-
alive: record.status === "recording" && isAlive(record.pid),
|
|
33
|
-
fileExists: existsSync(record.outputPath),
|
|
34
|
-
});
|
|
35
|
-
}
|
|
36
|
-
catch (error) {
|
|
37
|
-
return errorResponse(error);
|
|
38
|
-
}
|
|
39
|
-
});
|
|
40
|
-
}
|