@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.
- 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 -89
- package/dist/tools/bugReport.js +0 -266
- package/dist/tools/burnSubtitles.js +0 -56
- package/dist/tools/callout.js +0 -103
- 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 -135
- package/dist/tools/convert.js +0 -46
- package/dist/tools/crop.js +0 -43
- package/dist/tools/cursor.js +0 -87
- 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 -196
- 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 -131
- 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 -60
- package/dist/tools/overlay.js +0 -62
- package/dist/tools/pauseRecording.js +0 -44
- package/dist/tools/pipeline.js +0 -400
- package/dist/tools/readEvents.js +0 -98
- package/dist/tools/redactRegion.js +0 -70
- 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 -250
- 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 -128
- package/dist/tools/xfadeTransition.js +0 -58
- package/dist/tools/zoom.js +0 -149
- 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 -113
- package/dist/utils/audioDevices.js +0 -107
- package/dist/utils/backdrop.js +0 -151
- package/dist/utils/bugReport.js +0 -172
- package/dist/utils/callout.js +0 -90
- package/dist/utils/calloutAssets.js +0 -42
- package/dist/utils/capabilities.js +0 -96
- package/dist/utils/captions.js +0 -103
- package/dist/utils/chapters.js +0 -227
- package/dist/utils/consent.js +0 -29
- package/dist/utils/cursor.js +0 -317
- package/dist/utils/diff.js +0 -184
- 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/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 -155
- package/dist/utils/lifecycle.js +0 -233
- package/dist/utils/logging.js +0 -75
- package/dist/utils/media.js +0 -574
- 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 -91
- 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 -298
- 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 -59
- 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 -234
|
@@ -1,86 +0,0 @@
|
|
|
1
|
-
import { z } from "zod";
|
|
2
|
-
import { existsSync, readFileSync, writeFileSync } from "node:fs";
|
|
3
|
-
import { errorResponse, okResponse, ScreencastError } from "../utils/errors.js";
|
|
4
|
-
import { WRITES_FILE, looseOutput } from "../utils/toolSpec.js";
|
|
5
|
-
import { requireFfmpeg, probeMedia } from "../utils/ffmpeg.js";
|
|
6
|
-
import { runEditJob } from "../utils/jobs.js";
|
|
7
|
-
import { parseSrt, normalizeCues, formatSrt } from "../utils/captions.js";
|
|
8
|
-
import { buildCutIdleArgs, MAX_CUTS } from "../utils/idle.js";
|
|
9
|
-
import { planTranscriptCuts, retimeCues } from "../utils/transcriptCut.js";
|
|
10
|
-
import { editOutputExt, assertEditContainer } from "../utils/media.js";
|
|
11
|
-
import { resolveOutput, subdir, stamp, rand } from "../utils/paths.js";
|
|
12
|
-
const inputSchema = {
|
|
13
|
-
input: z.string().min(1).describe("Path to the source video."),
|
|
14
|
-
srt: z.string().min(1).describe("Its .srt (transcribe; words: true for word timing)."),
|
|
15
|
-
remove: z
|
|
16
|
-
.array(z.union([z.number().int().min(0).max(99999), z.string().min(1)]))
|
|
17
|
-
.optional()
|
|
18
|
-
.describe("Cue numbers as the .srt numbers them, or transcript text quoted exactly (must occur once)."),
|
|
19
|
-
fillers: z.boolean().optional().describe("Also cut fillers (um, uh...) that have their own cue."),
|
|
20
|
-
dryRun: z.boolean().optional().describe("Only report the cuts."),
|
|
21
|
-
output: z.string().optional().describe("Optional output path. Defaults under SCREENCAST_HOME/edits."),
|
|
22
|
-
overwrite: z.boolean().optional().describe("Allow replacing an existing file at the output path (default false)."),
|
|
23
|
-
};
|
|
24
|
-
export function register(server) {
|
|
25
|
-
server.registerTool("cut_by_transcript", {
|
|
26
|
-
title: "Cut By Transcript",
|
|
27
|
-
description: "Edit a video by its transcript: cut quoted text, cue numbers, or fillers. Also writes the re-timed .srt.",
|
|
28
|
-
inputSchema,
|
|
29
|
-
outputSchema: looseOutput({ cuts: z.array(z.unknown()), removedSec: z.number() }),
|
|
30
|
-
annotations: WRITES_FILE,
|
|
31
|
-
}, async (args, extra) => {
|
|
32
|
-
try {
|
|
33
|
-
requireFfmpeg();
|
|
34
|
-
for (const f of [args.input, args.srt])
|
|
35
|
-
if (!existsSync(f))
|
|
36
|
-
throw new ScreencastError(`File not found: ${f}`);
|
|
37
|
-
if (!args.remove?.length && !args.fillers)
|
|
38
|
-
throw new ScreencastError("Nothing to cut: pass remove and/or fillers: true.");
|
|
39
|
-
const info = await probeMedia(args.input);
|
|
40
|
-
const duration = info.durationSec;
|
|
41
|
-
if (duration === null || !info.videoCodec)
|
|
42
|
-
throw new ScreencastError(`Not a readable video: ${args.input}`);
|
|
43
|
-
const cues = normalizeCues(parseSrt(readFileSync(args.srt, "utf8"), { index: true }));
|
|
44
|
-
if (cues.length === 0)
|
|
45
|
-
throw new ScreencastError(`No cues in ${args.srt}.`);
|
|
46
|
-
const { cuts, skippedFillers } = planTranscriptCuts(cues, { remove: args.remove, fillers: args.fillers });
|
|
47
|
-
if (cuts.length > MAX_CUTS)
|
|
48
|
-
throw new ScreencastError(`Too many cuts (${cuts.length}, max ${MAX_CUTS}); cut in batches.`);
|
|
49
|
-
const removedSec = Number(cuts.reduce((s, c) => s + Math.min(c.end, duration) - Math.min(c.start, duration), 0).toFixed(2));
|
|
50
|
-
const retimed = retimeCues(cues, cuts);
|
|
51
|
-
const notes = [
|
|
52
|
-
cuts.length === 0 && "Nothing matched; nothing to cut.",
|
|
53
|
-
skippedFillers > 0 && `${skippedFillers} filler(s) inside longer cues were kept; transcribe with words: true to cut them.`,
|
|
54
|
-
cuts.some((c) => !c.exact) && "Some edges were estimated inside a cue; transcribe with words: true for word timing.",
|
|
55
|
-
].filter(Boolean);
|
|
56
|
-
const summary = {
|
|
57
|
-
cuts,
|
|
58
|
-
removedSec,
|
|
59
|
-
originalSec: Number(duration.toFixed(2)),
|
|
60
|
-
newDurationSec: Number((duration - removedSec).toFixed(2)),
|
|
61
|
-
...(notes.length ? { note: notes.join(" ") } : {}),
|
|
62
|
-
};
|
|
63
|
-
if (args.dryRun || cuts.length === 0) {
|
|
64
|
-
const text = retimed.map((c) => c.text.replace(/\n/g, " ")).join(" ");
|
|
65
|
-
return okResponse({ ...summary, ...(cuts.length ? { dryRun: true } : {}), text: text.length > 4000 ? `${text.slice(0, 4000)}…` : text });
|
|
66
|
-
}
|
|
67
|
-
assertEditContainer(args.output);
|
|
68
|
-
const ext = editOutputExt(args.input);
|
|
69
|
-
const output = resolveOutput(args.output, subdir("edits"), `cut-transcript-${stamp()}-${rand()}${ext}`, args.overwrite);
|
|
70
|
-
const srtPath = output.replace(/\.[^.\\/]+$/, "") + ".srt";
|
|
71
|
-
if (!args.overwrite && existsSync(srtPath))
|
|
72
|
-
throw new ScreencastError(`Output already exists: ${srtPath}. Pass overwrite: true to replace it.`);
|
|
73
|
-
await runEditJob(buildCutIdleArgs(args.input, output, cuts, info.audioCodec !== null), {
|
|
74
|
-
output,
|
|
75
|
-
durationSec: duration - removedSec,
|
|
76
|
-
inputDurationSec: duration,
|
|
77
|
-
extra,
|
|
78
|
-
});
|
|
79
|
-
writeFileSync(srtPath, formatSrt(retimed));
|
|
80
|
-
return okResponse({ outputPath: output, srtPath, ...summary });
|
|
81
|
-
}
|
|
82
|
-
catch (error) {
|
|
83
|
-
return errorResponse(error);
|
|
84
|
-
}
|
|
85
|
-
});
|
|
86
|
-
}
|
package/dist/tools/cutIdle.js
DELETED
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
import { z } from "zod";
|
|
2
|
-
import { existsSync } from "node:fs";
|
|
3
|
-
import { errorResponse, okResponse, ScreencastError } from "../utils/errors.js";
|
|
4
|
-
import { 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 { buildIdleScanArgs, parseFreezes, parseSilences, intersect, cutsFor, buildCutIdleArgs, DEFAULT_MIN_IDLE_SEC, DEFAULT_KEEP_SEC, } from "../utils/idle.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."),
|
|
12
|
-
minIdleSec: z
|
|
13
|
-
.number()
|
|
14
|
-
.positive()
|
|
15
|
-
.optional()
|
|
16
|
-
.describe(`Only cut still stretches at least this long (default ${DEFAULT_MIN_IDLE_SEC}).`),
|
|
17
|
-
keepSec: z
|
|
18
|
-
.number()
|
|
19
|
-
.min(0)
|
|
20
|
-
.optional()
|
|
21
|
-
.describe(`Seconds kept at each edge of a cut (default ${DEFAULT_KEEP_SEC}).`),
|
|
22
|
-
useAudio: z
|
|
23
|
-
.boolean()
|
|
24
|
-
.optional()
|
|
25
|
-
.describe("Require silent audio too (default true when there is audio)."),
|
|
26
|
-
dryRun: z.boolean().optional().describe("Only report what would be cut."),
|
|
27
|
-
output: z.string().optional().describe("Optional output path. Defaults under SCREENCAST_HOME/edits."),
|
|
28
|
-
overwrite: z.boolean().optional().describe("Allow replacing an existing file at the output path (default false)."),
|
|
29
|
-
};
|
|
30
|
-
export function register(server) {
|
|
31
|
-
server.registerTool("cut_idle", {
|
|
32
|
-
title: "Cut Idle Stretches",
|
|
33
|
-
description: "Remove dead air: cut stretches where the screen is frozen (and silent), keeping a short pad. " +
|
|
34
|
-
"Returns the time saved.",
|
|
35
|
-
inputSchema,
|
|
36
|
-
annotations: WRITES_FILE,
|
|
37
|
-
}, async (args, extra) => {
|
|
38
|
-
try {
|
|
39
|
-
const { ffmpeg } = requireFfmpeg();
|
|
40
|
-
if (!existsSync(args.input))
|
|
41
|
-
throw new ScreencastError(`Input file not found: ${args.input}`);
|
|
42
|
-
const info = await probeMedia(args.input);
|
|
43
|
-
const duration = info.durationSec;
|
|
44
|
-
if (duration === null)
|
|
45
|
-
throw new ScreencastError(`Could not read duration of ${args.input}.`);
|
|
46
|
-
const minIdle = args.minIdleSec ?? DEFAULT_MIN_IDLE_SEC;
|
|
47
|
-
const keep = args.keepSec ?? DEFAULT_KEEP_SEC;
|
|
48
|
-
const hasAudio = info.audioCodec !== null;
|
|
49
|
-
const useAudio = (args.useAudio ?? true) && hasAudio;
|
|
50
|
-
const scan = await runCapture(ffmpeg, buildIdleScanArgs(args.input, minIdle, useAudio), jobTimeoutMs(duration), {
|
|
51
|
-
signal: extra.signal,
|
|
52
|
-
});
|
|
53
|
-
if (scan.code !== 0)
|
|
54
|
-
throw new ScreencastError(`Idle scan failed (exit ${scan.code}): ${scan.stderr.trim().slice(-400)}`);
|
|
55
|
-
const freezes = parseFreezes(scan.stderr, duration);
|
|
56
|
-
const idle = useAudio ? intersect(freezes, parseSilences(scan.stderr, duration)) : freezes;
|
|
57
|
-
const cuts = cutsFor(idle, minIdle, keep);
|
|
58
|
-
const removedSec = Number(cuts.reduce((s, c) => s + (c.end - c.start), 0).toFixed(2));
|
|
59
|
-
const summary = {
|
|
60
|
-
cuts,
|
|
61
|
-
removedSec,
|
|
62
|
-
originalSec: Number(duration.toFixed(2)),
|
|
63
|
-
newDurationSec: Number((duration - removedSec).toFixed(2)),
|
|
64
|
-
idleRule: useAudio ? "frozen video and silent audio" : "frozen video",
|
|
65
|
-
};
|
|
66
|
-
if (args.dryRun || cuts.length === 0) {
|
|
67
|
-
return okResponse({ ...summary, ...(cuts.length === 0 ? { note: "No idle stretches found; nothing to cut." } : { dryRun: true }) });
|
|
68
|
-
}
|
|
69
|
-
assertEditContainer(args.output);
|
|
70
|
-
const ext = editOutputExt(args.input);
|
|
71
|
-
const output = resolveOutput(args.output, subdir("edits"), `trimmed-idle-${stamp()}-${rand()}${ext}`, args.overwrite);
|
|
72
|
-
await runEditJob(buildCutIdleArgs(args.input, output, cuts, hasAudio), {
|
|
73
|
-
output,
|
|
74
|
-
durationSec: duration - removedSec,
|
|
75
|
-
inputDurationSec: duration,
|
|
76
|
-
extra,
|
|
77
|
-
});
|
|
78
|
-
return okResponse({ outputPath: output, ...summary });
|
|
79
|
-
}
|
|
80
|
-
catch (error) {
|
|
81
|
-
return errorResponse(error);
|
|
82
|
-
}
|
|
83
|
-
});
|
|
84
|
-
}
|
|
@@ -1,119 +0,0 @@
|
|
|
1
|
-
import { z } from "zod";
|
|
2
|
-
import { existsSync, readdirSync, rmSync, statSync } from "node:fs";
|
|
3
|
-
import { dirname, resolve } from "node:path";
|
|
4
|
-
import { errorMessage, errorResponse, okResponse, ScreencastError } from "../utils/errors.js";
|
|
5
|
-
import { DELETES_FILE, looseOutput } from "../utils/toolSpec.js";
|
|
6
|
-
import { getStore } from "../context.js";
|
|
7
|
-
import { isLive } from "../utils/sessions.js";
|
|
8
|
-
import { samePath } from "../utils/recordingIndex.js";
|
|
9
|
-
import { assertDeleteAllowed, recordingSidecars } from "../utils/recordingFiles.js";
|
|
10
|
-
import { subdir } from "../utils/paths.js";
|
|
11
|
-
import { CONFIRM_TIMEOUT_MS, confirmCaptureEnabled, CONFIRM_CAPTURE_ENV } from "../utils/consent.js";
|
|
12
|
-
const inputSchema = {
|
|
13
|
-
sessionId: z.string().min(1).optional().describe("Session id of the recording to delete."),
|
|
14
|
-
input: z.string().min(1).optional().describe("Or the recording's path."),
|
|
15
|
-
};
|
|
16
|
-
function sizeOf(path) {
|
|
17
|
-
try {
|
|
18
|
-
const st = statSync(path);
|
|
19
|
-
if (!st.isDirectory())
|
|
20
|
-
return st.size;
|
|
21
|
-
return readdirSync(path).reduce((n, name) => n + sizeOf(resolve(path, name)), 0);
|
|
22
|
-
}
|
|
23
|
-
catch {
|
|
24
|
-
return 0;
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
async function confirmDelete(server, message, signal) {
|
|
28
|
-
if (!server.server.getClientCapabilities()?.elicitation?.form) {
|
|
29
|
-
if (confirmCaptureEnabled()) {
|
|
30
|
-
throw new ScreencastError(`Not deleted: ${CONFIRM_CAPTURE_ENV} requires the user to confirm, but this client does not support MCP elicitation.`);
|
|
31
|
-
}
|
|
32
|
-
return false;
|
|
33
|
-
}
|
|
34
|
-
let action;
|
|
35
|
-
try {
|
|
36
|
-
({ action } = await server.server.elicitInput({ message, requestedSchema: { type: "object", properties: {} } }, { signal, timeout: CONFIRM_TIMEOUT_MS }));
|
|
37
|
-
}
|
|
38
|
-
catch (err) {
|
|
39
|
-
throw new ScreencastError(`Not deleted: the confirmation request failed (${errorMessage(err)}).`);
|
|
40
|
-
}
|
|
41
|
-
if (action !== "accept")
|
|
42
|
-
throw new ScreencastError(`Not deleted: ${action === "decline" ? "declined" : "cancelled"} by the user.`);
|
|
43
|
-
return true;
|
|
44
|
-
}
|
|
45
|
-
export function register(server) {
|
|
46
|
-
server.registerTool("delete_recording", {
|
|
47
|
-
title: "Delete Recording",
|
|
48
|
-
description: "Delete a finished recording with its sidecars (event log, webcam, transcript, index, markers, pause parts) " +
|
|
49
|
-
"and registry entries; reports bytes freed. Asks the user first when the client supports it. Edits made from it are kept.",
|
|
50
|
-
inputSchema,
|
|
51
|
-
outputSchema: looseOutput({
|
|
52
|
-
outputPath: z.string(),
|
|
53
|
-
deleted: z.array(z.string()),
|
|
54
|
-
bytesFreed: z.number(),
|
|
55
|
-
sessionsRemoved: z.array(z.string()),
|
|
56
|
-
}),
|
|
57
|
-
annotations: DELETES_FILE,
|
|
58
|
-
}, async (args, extra) => {
|
|
59
|
-
try {
|
|
60
|
-
if (!!args.sessionId === !!args.input)
|
|
61
|
-
throw new ScreencastError("Give exactly one of sessionId or input.");
|
|
62
|
-
const store = getStore();
|
|
63
|
-
let video;
|
|
64
|
-
if (args.sessionId) {
|
|
65
|
-
const record = store.get(args.sessionId);
|
|
66
|
-
if (!record)
|
|
67
|
-
throw new ScreencastError(`No session with id "${args.sessionId}".`);
|
|
68
|
-
video = record.outputPath;
|
|
69
|
-
}
|
|
70
|
-
else {
|
|
71
|
-
video = resolve(args.input);
|
|
72
|
-
}
|
|
73
|
-
assertDeleteAllowed(video);
|
|
74
|
-
const sessions = store.list().filter((r) => samePath(r.outputPath, video));
|
|
75
|
-
const live = sessions.find((r) => isLive(r.status));
|
|
76
|
-
if (live)
|
|
77
|
-
throw new ScreencastError(`Recording ${live.id} is still ${live.status}; stop it first.`);
|
|
78
|
-
let siblings = [];
|
|
79
|
-
try {
|
|
80
|
-
siblings = readdirSync(dirname(video));
|
|
81
|
-
}
|
|
82
|
-
catch {
|
|
83
|
-
}
|
|
84
|
-
const side = recordingSidecars(video, siblings, subdir("edits"));
|
|
85
|
-
const targets = [video, ...side.files, ...side.dirs].filter((p) => existsSync(p));
|
|
86
|
-
if (targets.length === 0 && sessions.length === 0)
|
|
87
|
-
throw new ScreencastError(`Nothing to delete: ${video} does not exist.`);
|
|
88
|
-
const asked = await confirmDelete(server, `Delete ${video} and ${targets.length - (existsSync(video) ? 1 : 0)} sidecar file(s)? This cannot be undone.`, extra.signal);
|
|
89
|
-
let bytesFreed = 0;
|
|
90
|
-
const deleted = [];
|
|
91
|
-
const failed = [];
|
|
92
|
-
for (const p of targets) {
|
|
93
|
-
const size = sizeOf(p);
|
|
94
|
-
try {
|
|
95
|
-
rmSync(p, { recursive: true, force: true });
|
|
96
|
-
deleted.push(p);
|
|
97
|
-
bytesFreed += size;
|
|
98
|
-
}
|
|
99
|
-
catch (err) {
|
|
100
|
-
failed.push(`${p}: ${errorMessage(err)}`);
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
const removedIds = existsSync(video) ? [] : sessions.map((r) => r.id);
|
|
104
|
-
if (removedIds.length > 0)
|
|
105
|
-
store.remove(removedIds);
|
|
106
|
-
return okResponse({
|
|
107
|
-
outputPath: video,
|
|
108
|
-
deleted,
|
|
109
|
-
bytesFreed,
|
|
110
|
-
sessionsRemoved: removedIds,
|
|
111
|
-
confirmedByUser: asked,
|
|
112
|
-
...(failed.length > 0 ? { failed, note: "Some files could not be deleted (in use?); the registry entry was kept if the recording remains." } : {}),
|
|
113
|
-
});
|
|
114
|
-
}
|
|
115
|
-
catch (error) {
|
|
116
|
-
return errorResponse(error);
|
|
117
|
-
}
|
|
118
|
-
});
|
|
119
|
-
}
|
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 } 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(["light", "medium", "strong"])
|
|
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
|
-
}
|