@tmhs/screencast-mcp 0.39.0 → 0.44.2
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 +58 -14
- package/assets/icon.png +0 -0
- package/assets/ui/player.html +38 -302
- package/assets/ui/player.js +382 -0
- package/dist/context.js +0 -5
- package/dist/index.js +5 -21
- package/dist/prompts.js +0 -7
- package/dist/resources.js +2 -14
- package/dist/server.js +37 -11
- package/dist/tools/assembleHighlights.js +12 -7
- package/dist/tools/burnSubtitles.js +12 -6
- package/dist/tools/callout.js +32 -16
- package/dist/tools/clip.js +12 -9
- package/dist/tools/compress.js +10 -5
- package/dist/tools/concat.js +16 -15
- package/dist/tools/contactSheet.js +26 -22
- package/dist/tools/convert.js +12 -6
- package/dist/tools/crop.js +12 -7
- package/dist/tools/cutIdle.js +15 -9
- package/dist/tools/denoise.js +12 -6
- package/dist/tools/doctor.js +133 -0
- package/dist/tools/exportGif.js +14 -10
- package/dist/tools/exportPreset.js +11 -8
- package/dist/tools/extractAudio.js +10 -8
- package/dist/tools/findText.js +69 -65
- package/dist/tools/getMediaInfo.js +17 -3
- package/dist/tools/getSession.js +15 -3
- package/dist/tools/listAudioDevices.js +14 -7
- package/dist/tools/listSessions.js +13 -3
- package/dist/tools/listTargets.js +76 -0
- package/dist/tools/musicBed.js +14 -10
- package/dist/tools/normalizeAudio.js +12 -8
- package/dist/tools/overlay.js +16 -12
- package/dist/tools/pipeline.js +31 -22
- package/dist/tools/readEvents.js +21 -12
- package/dist/tools/redactRegion.js +19 -17
- package/dist/tools/reframe.js +9 -5
- package/dist/tools/reviewRecording.js +63 -22
- package/dist/tools/sampleFrames.js +33 -40
- package/dist/tools/scale.js +9 -3
- package/dist/tools/screenDiff.js +23 -17
- package/dist/tools/screenshot.js +21 -17
- package/dist/tools/speed.js +15 -4
- package/dist/tools/startRecording.js +48 -52
- package/dist/tools/stopRecording.js +10 -9
- package/dist/tools/titleCard.js +19 -11
- package/dist/tools/transcribe.js +13 -7
- package/dist/tools/trim.js +11 -10
- package/dist/tools/waitForChange.js +37 -22
- package/dist/tools/xfadeTransition.js +12 -8
- package/dist/tools/zoom.js +26 -29
- package/dist/utils/anim.js +1 -21
- package/dist/utils/animExport.js +5 -10
- package/dist/utils/audio.js +4 -33
- package/dist/utils/audioDevices.js +1 -48
- package/dist/utils/callout.js +1 -19
- package/dist/utils/calloutAssets.js +21 -11
- package/dist/utils/capabilities.js +95 -0
- package/dist/utils/captions.js +9 -26
- package/dist/utils/consent.js +29 -0
- package/dist/utils/diff.js +0 -46
- package/dist/utils/errors.js +5 -13
- package/dist/utils/events.js +21 -77
- package/dist/utils/expr.js +11 -0
- package/dist/utils/ffmpeg.js +119 -48
- package/dist/utils/fontCoverage.js +177 -0
- package/dist/utils/fonts.js +139 -23
- package/dist/utils/idle.js +12 -24
- package/dist/utils/images.js +0 -17
- package/dist/utils/jobs.js +42 -41
- package/dist/utils/lifecycle.js +0 -29
- package/dist/utils/logging.js +75 -0
- package/dist/utils/media.js +11 -122
- package/dist/utils/monitors.js +7 -43
- package/dist/utils/ocr.js +53 -71
- package/dist/utils/paths.js +68 -31
- package/dist/utils/pipeline.js +0 -23
- package/dist/utils/player.js +50 -27
- package/dist/utils/produce.js +6 -66
- package/dist/utils/resolveTarget.js +0 -19
- package/dist/utils/retention.js +1 -15
- package/dist/utils/roots.js +42 -0
- package/dist/utils/sessions.js +195 -160
- package/dist/utils/sheet.js +0 -19
- package/dist/utils/still.js +0 -15
- package/dist/utils/targetList.js +63 -0
- package/dist/utils/targets.js +5 -70
- package/dist/utils/toolSpec.js +25 -0
- package/dist/utils/toolsets.js +102 -0
- package/dist/utils/validate.js +0 -22
- package/dist/utils/wgc.js +0 -46
- package/dist/utils/windows.js +5 -50
- package/dist/utils/zoom.js +55 -85
- package/dist/wgcRecorder.js +1 -30
- package/package.json +7 -3
- package/dist/context.d.ts +0 -9
- package/dist/context.d.ts.map +0 -1
- package/dist/context.js.map +0 -1
- package/dist/index.d.ts +0 -3
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/prompts.d.ts +0 -10
- package/dist/prompts.d.ts.map +0 -1
- package/dist/prompts.js.map +0 -1
- package/dist/resources.d.ts +0 -3
- package/dist/resources.d.ts.map +0 -1
- package/dist/resources.js.map +0 -1
- package/dist/server.d.ts +0 -3
- package/dist/server.d.ts.map +0 -1
- package/dist/server.js.map +0 -1
- package/dist/tools/assembleHighlights.d.ts +0 -3
- package/dist/tools/assembleHighlights.d.ts.map +0 -1
- package/dist/tools/assembleHighlights.js.map +0 -1
- package/dist/tools/burnSubtitles.d.ts +0 -3
- package/dist/tools/burnSubtitles.d.ts.map +0 -1
- package/dist/tools/burnSubtitles.js.map +0 -1
- package/dist/tools/callout.d.ts +0 -37
- package/dist/tools/callout.d.ts.map +0 -1
- package/dist/tools/callout.js.map +0 -1
- package/dist/tools/clip.d.ts +0 -3
- package/dist/tools/clip.d.ts.map +0 -1
- package/dist/tools/clip.js.map +0 -1
- package/dist/tools/compress.d.ts +0 -3
- package/dist/tools/compress.d.ts.map +0 -1
- package/dist/tools/compress.js.map +0 -1
- package/dist/tools/concat.d.ts +0 -3
- package/dist/tools/concat.d.ts.map +0 -1
- package/dist/tools/concat.js.map +0 -1
- package/dist/tools/contactSheet.d.ts +0 -3
- package/dist/tools/contactSheet.d.ts.map +0 -1
- package/dist/tools/contactSheet.js.map +0 -1
- package/dist/tools/convert.d.ts +0 -3
- package/dist/tools/convert.d.ts.map +0 -1
- package/dist/tools/convert.js.map +0 -1
- package/dist/tools/crop.d.ts +0 -3
- package/dist/tools/crop.d.ts.map +0 -1
- package/dist/tools/crop.js.map +0 -1
- package/dist/tools/cutIdle.d.ts +0 -3
- package/dist/tools/cutIdle.d.ts.map +0 -1
- package/dist/tools/cutIdle.js.map +0 -1
- package/dist/tools/denoise.d.ts +0 -3
- package/dist/tools/denoise.d.ts.map +0 -1
- package/dist/tools/denoise.js.map +0 -1
- package/dist/tools/exportGif.d.ts +0 -3
- package/dist/tools/exportGif.d.ts.map +0 -1
- package/dist/tools/exportGif.js.map +0 -1
- package/dist/tools/exportPreset.d.ts +0 -3
- package/dist/tools/exportPreset.d.ts.map +0 -1
- package/dist/tools/exportPreset.js.map +0 -1
- package/dist/tools/extractAudio.d.ts +0 -3
- package/dist/tools/extractAudio.d.ts.map +0 -1
- package/dist/tools/extractAudio.js.map +0 -1
- package/dist/tools/findText.d.ts +0 -6
- package/dist/tools/findText.d.ts.map +0 -1
- package/dist/tools/findText.js.map +0 -1
- package/dist/tools/getMediaInfo.d.ts +0 -3
- package/dist/tools/getMediaInfo.d.ts.map +0 -1
- package/dist/tools/getMediaInfo.js.map +0 -1
- package/dist/tools/getSession.d.ts +0 -3
- package/dist/tools/getSession.d.ts.map +0 -1
- package/dist/tools/getSession.js.map +0 -1
- package/dist/tools/listAudioDevices.d.ts +0 -3
- package/dist/tools/listAudioDevices.d.ts.map +0 -1
- package/dist/tools/listAudioDevices.js.map +0 -1
- package/dist/tools/listSessions.d.ts +0 -3
- package/dist/tools/listSessions.d.ts.map +0 -1
- package/dist/tools/listSessions.js.map +0 -1
- package/dist/tools/musicBed.d.ts +0 -3
- package/dist/tools/musicBed.d.ts.map +0 -1
- package/dist/tools/musicBed.js.map +0 -1
- package/dist/tools/normalizeAudio.d.ts +0 -3
- package/dist/tools/normalizeAudio.d.ts.map +0 -1
- package/dist/tools/normalizeAudio.js.map +0 -1
- package/dist/tools/overlay.d.ts +0 -3
- package/dist/tools/overlay.d.ts.map +0 -1
- package/dist/tools/overlay.js.map +0 -1
- package/dist/tools/pipeline.d.ts +0 -3
- package/dist/tools/pipeline.d.ts.map +0 -1
- package/dist/tools/pipeline.js.map +0 -1
- package/dist/tools/readEvents.d.ts +0 -6
- package/dist/tools/readEvents.d.ts.map +0 -1
- package/dist/tools/readEvents.js.map +0 -1
- package/dist/tools/redactRegion.d.ts +0 -13
- package/dist/tools/redactRegion.d.ts.map +0 -1
- package/dist/tools/redactRegion.js.map +0 -1
- package/dist/tools/reframe.d.ts +0 -3
- package/dist/tools/reframe.d.ts.map +0 -1
- package/dist/tools/reframe.js.map +0 -1
- package/dist/tools/reviewRecording.d.ts +0 -5
- package/dist/tools/reviewRecording.d.ts.map +0 -1
- package/dist/tools/reviewRecording.js.map +0 -1
- package/dist/tools/sampleFrames.d.ts +0 -3
- package/dist/tools/sampleFrames.d.ts.map +0 -1
- package/dist/tools/sampleFrames.js.map +0 -1
- package/dist/tools/scale.d.ts +0 -3
- package/dist/tools/scale.d.ts.map +0 -1
- package/dist/tools/scale.js.map +0 -1
- package/dist/tools/screenDiff.d.ts +0 -3
- package/dist/tools/screenDiff.d.ts.map +0 -1
- package/dist/tools/screenDiff.js.map +0 -1
- package/dist/tools/screenshot.d.ts +0 -3
- package/dist/tools/screenshot.d.ts.map +0 -1
- package/dist/tools/screenshot.js.map +0 -1
- package/dist/tools/speed.d.ts +0 -3
- package/dist/tools/speed.d.ts.map +0 -1
- package/dist/tools/speed.js.map +0 -1
- package/dist/tools/startRecording.d.ts +0 -3
- package/dist/tools/startRecording.d.ts.map +0 -1
- package/dist/tools/startRecording.js.map +0 -1
- package/dist/tools/stopRecording.d.ts +0 -3
- package/dist/tools/stopRecording.d.ts.map +0 -1
- package/dist/tools/stopRecording.js.map +0 -1
- package/dist/tools/titleCard.d.ts +0 -3
- package/dist/tools/titleCard.d.ts.map +0 -1
- package/dist/tools/titleCard.js.map +0 -1
- package/dist/tools/transcribe.d.ts +0 -3
- package/dist/tools/transcribe.d.ts.map +0 -1
- package/dist/tools/transcribe.js.map +0 -1
- package/dist/tools/trim.d.ts +0 -3
- package/dist/tools/trim.d.ts.map +0 -1
- package/dist/tools/trim.js.map +0 -1
- package/dist/tools/waitForChange.d.ts +0 -3
- package/dist/tools/waitForChange.d.ts.map +0 -1
- package/dist/tools/waitForChange.js.map +0 -1
- package/dist/tools/xfadeTransition.d.ts +0 -3
- package/dist/tools/xfadeTransition.d.ts.map +0 -1
- package/dist/tools/xfadeTransition.js.map +0 -1
- package/dist/tools/zoom.d.ts +0 -15
- package/dist/tools/zoom.d.ts.map +0 -1
- package/dist/tools/zoom.js.map +0 -1
- package/dist/utils/anim.d.ts +0 -33
- package/dist/utils/anim.d.ts.map +0 -1
- package/dist/utils/anim.js.map +0 -1
- package/dist/utils/animExport.d.ts +0 -27
- package/dist/utils/animExport.d.ts.map +0 -1
- package/dist/utils/animExport.js.map +0 -1
- package/dist/utils/audio.d.ts +0 -49
- package/dist/utils/audio.d.ts.map +0 -1
- package/dist/utils/audio.js.map +0 -1
- package/dist/utils/audioDevices.d.ts +0 -33
- package/dist/utils/audioDevices.d.ts.map +0 -1
- package/dist/utils/audioDevices.js.map +0 -1
- package/dist/utils/callout.d.ts +0 -72
- package/dist/utils/callout.d.ts.map +0 -1
- package/dist/utils/callout.js.map +0 -1
- package/dist/utils/calloutAssets.d.ts +0 -3
- package/dist/utils/calloutAssets.d.ts.map +0 -1
- package/dist/utils/calloutAssets.js.map +0 -1
- package/dist/utils/captions.d.ts +0 -26
- package/dist/utils/captions.d.ts.map +0 -1
- package/dist/utils/captions.js.map +0 -1
- package/dist/utils/diff.d.ts +0 -112
- package/dist/utils/diff.d.ts.map +0 -1
- package/dist/utils/diff.js.map +0 -1
- package/dist/utils/errors.d.ts +0 -33
- package/dist/utils/errors.d.ts.map +0 -1
- package/dist/utils/errors.js.map +0 -1
- package/dist/utils/events.d.ts +0 -143
- package/dist/utils/events.d.ts.map +0 -1
- package/dist/utils/events.js.map +0 -1
- package/dist/utils/ffmpeg.d.ts +0 -50
- package/dist/utils/ffmpeg.d.ts.map +0 -1
- package/dist/utils/ffmpeg.js.map +0 -1
- package/dist/utils/fonts.d.ts +0 -17
- package/dist/utils/fonts.d.ts.map +0 -1
- package/dist/utils/fonts.js.map +0 -1
- package/dist/utils/idle.d.ts +0 -23
- package/dist/utils/idle.d.ts.map +0 -1
- package/dist/utils/idle.js.map +0 -1
- package/dist/utils/images.d.ts +0 -21
- package/dist/utils/images.d.ts.map +0 -1
- package/dist/utils/images.js.map +0 -1
- package/dist/utils/jobs.d.ts +0 -44
- package/dist/utils/jobs.d.ts.map +0 -1
- package/dist/utils/jobs.js.map +0 -1
- package/dist/utils/lifecycle.d.ts +0 -29
- package/dist/utils/lifecycle.d.ts.map +0 -1
- package/dist/utils/lifecycle.js.map +0 -1
- package/dist/utils/media.d.ts +0 -272
- package/dist/utils/media.d.ts.map +0 -1
- package/dist/utils/media.js.map +0 -1
- package/dist/utils/monitors.d.ts +0 -47
- package/dist/utils/monitors.d.ts.map +0 -1
- package/dist/utils/monitors.js.map +0 -1
- package/dist/utils/ocr.d.ts +0 -50
- package/dist/utils/ocr.d.ts.map +0 -1
- package/dist/utils/ocr.js.map +0 -1
- package/dist/utils/paths.d.ts +0 -28
- package/dist/utils/paths.d.ts.map +0 -1
- package/dist/utils/paths.js.map +0 -1
- package/dist/utils/pipeline.d.ts +0 -69
- package/dist/utils/pipeline.d.ts.map +0 -1
- package/dist/utils/pipeline.js.map +0 -1
- package/dist/utils/player.d.ts +0 -30
- package/dist/utils/player.d.ts.map +0 -1
- package/dist/utils/player.js.map +0 -1
- package/dist/utils/produce.d.ts +0 -126
- package/dist/utils/produce.d.ts.map +0 -1
- package/dist/utils/produce.js.map +0 -1
- package/dist/utils/resolveTarget.d.ts +0 -32
- package/dist/utils/resolveTarget.d.ts.map +0 -1
- package/dist/utils/resolveTarget.js.map +0 -1
- package/dist/utils/retention.d.ts +0 -10
- package/dist/utils/retention.d.ts.map +0 -1
- package/dist/utils/retention.js.map +0 -1
- package/dist/utils/sessions.d.ts +0 -154
- package/dist/utils/sessions.d.ts.map +0 -1
- package/dist/utils/sessions.js.map +0 -1
- package/dist/utils/sheet.d.ts +0 -26
- package/dist/utils/sheet.d.ts.map +0 -1
- package/dist/utils/sheet.js.map +0 -1
- package/dist/utils/still.d.ts +0 -7
- package/dist/utils/still.d.ts.map +0 -1
- package/dist/utils/still.js.map +0 -1
- package/dist/utils/targets.d.ts +0 -113
- package/dist/utils/targets.d.ts.map +0 -1
- package/dist/utils/targets.js.map +0 -1
- package/dist/utils/validate.d.ts +0 -15
- package/dist/utils/validate.d.ts.map +0 -1
- package/dist/utils/validate.js.map +0 -1
- package/dist/utils/wgc.d.ts +0 -46
- package/dist/utils/wgc.d.ts.map +0 -1
- package/dist/utils/wgc.js.map +0 -1
- package/dist/utils/windows.d.ts +0 -94
- package/dist/utils/windows.d.ts.map +0 -1
- package/dist/utils/windows.js.map +0 -1
- package/dist/utils/zoom.d.ts +0 -95
- package/dist/utils/zoom.d.ts.map +0 -1
- package/dist/utils/zoom.js.map +0 -1
- package/dist/wgcRecorder.d.ts +0 -2
- package/dist/wgcRecorder.d.ts.map +0 -1
- package/dist/wgcRecorder.js.map +0 -1
|
@@ -1,14 +1,19 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
-
import { existsSync, readFileSync } from "node:fs";
|
|
2
|
+
import { existsSync, readFileSync, rmSync } from "node:fs";
|
|
3
3
|
import { fileURLToPath } from "node:url";
|
|
4
4
|
import { errorResponse, okResponse, ScreencastError } from "../utils/errors.js";
|
|
5
|
+
import { READ_ONLY, looseOutput } from "../utils/toolSpec.js";
|
|
5
6
|
import { requireFfmpeg, probeMedia, runFfmpegBuffer } from "../utils/ffmpeg.js";
|
|
6
7
|
import { jobTimeoutMs } from "../utils/jobs.js";
|
|
7
|
-
import {
|
|
8
|
+
import { tempPath } from "../utils/paths.js";
|
|
9
|
+
import { buildPlayerFramesArgs, clientSupportsApps, parsePlayerFrameLog, pickPlayerFrames, playerFramePlan, splitJpegs, DEFAULT_PLAYER_FRAMES, DEFAULT_PLAYER_WIDTH, MAX_PLAYER_FRAMES, MCP_APP_MIME, PLAYER_TOOL_META, PLAYER_URI, } from "../utils/player.js";
|
|
8
10
|
import { getStore } from "../context.js";
|
|
9
|
-
|
|
11
|
+
const uiAsset = (name) => readFileSync(fileURLToPath(new URL(`../../assets/ui/${name}`, import.meta.url)), "utf8");
|
|
10
12
|
export function playerHtml() {
|
|
11
|
-
|
|
13
|
+
const js = uiAsset("player.js");
|
|
14
|
+
if (/<\/script/i.test(js))
|
|
15
|
+
throw new ScreencastError("player.js must not contain a closing script tag.");
|
|
16
|
+
return uiAsset("player.html").replace('<script src="player.js"></script>', () => `<script>\n${js}</script>`);
|
|
12
17
|
}
|
|
13
18
|
function resolveInput(args) {
|
|
14
19
|
if (args.sessionId) {
|
|
@@ -24,7 +29,6 @@ function resolveInput(args) {
|
|
|
24
29
|
throw new ScreencastError("Pass input or sessionId.");
|
|
25
30
|
}
|
|
26
31
|
export function register(server) {
|
|
27
|
-
// The player page itself, for hosts that support MCP Apps.
|
|
28
32
|
server.registerResource("review-player", PLAYER_URI, {
|
|
29
33
|
title: "Recording review player",
|
|
30
34
|
description: "Interactive player: scrub, trim, and draw redaction boxes on a recording.",
|
|
@@ -33,14 +37,22 @@ export function register(server) {
|
|
|
33
37
|
contents: [{ uri: PLAYER_URI, mimeType: MCP_APP_MIME, text: playerHtml(), _meta: { ui: { prefersBorder: true } } }],
|
|
34
38
|
}));
|
|
35
39
|
server.registerTool("review_recording", {
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
"
|
|
39
|
-
"video's details; use contact_sheet or sample_frames to look at it.",
|
|
40
|
+
title: "Review Recording",
|
|
41
|
+
description: "Open a recording for a person to review: in MCP Apps clients an inline player to scrub, trim, " +
|
|
42
|
+
"and redact, then export; elsewhere just the video's details.",
|
|
40
43
|
inputSchema: {
|
|
41
44
|
input: z.string().optional().describe("Path to the video."),
|
|
42
45
|
sessionId: z.string().optional().describe("Or the session id of a stopped recording."),
|
|
43
46
|
},
|
|
47
|
+
outputSchema: looseOutput({
|
|
48
|
+
input: z.string(),
|
|
49
|
+
durationSec: z.number().nullable(),
|
|
50
|
+
width: z.number().nullable(),
|
|
51
|
+
height: z.number().nullable(),
|
|
52
|
+
fps: z.number().nullable(),
|
|
53
|
+
hasAudio: z.boolean(),
|
|
54
|
+
}),
|
|
55
|
+
annotations: READ_ONLY,
|
|
44
56
|
_meta: PLAYER_TOOL_META,
|
|
45
57
|
}, async (args) => {
|
|
46
58
|
try {
|
|
@@ -64,27 +76,48 @@ export function register(server) {
|
|
|
64
76
|
return errorResponse(error);
|
|
65
77
|
}
|
|
66
78
|
});
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
description: "Preview frames for the review player: JPEGs
|
|
70
|
-
"Used by the inline player; agents should use
|
|
79
|
+
const playerFrames = server.registerTool("player_frames", {
|
|
80
|
+
title: "Player Frames",
|
|
81
|
+
description: "Preview frames for the review player: JPEGs on an even grid over the video plus frames at " +
|
|
82
|
+
"scene changes, with their real times. Used by the inline player; agents should use " +
|
|
83
|
+
"sample_frames or contact_sheet instead.",
|
|
71
84
|
inputSchema: {
|
|
72
85
|
input: z.string().min(1).describe("Path to the video."),
|
|
73
|
-
maxFrames: z.number().int().min(1).max(MAX_PLAYER_FRAMES).optional().describe(`
|
|
86
|
+
maxFrames: z.number().int().min(1).max(MAX_PLAYER_FRAMES).optional().describe(`Frames on the even grid (default ${DEFAULT_PLAYER_FRAMES}); scene-change frames come on top, up to as many again.`),
|
|
74
87
|
width: z.number().int().min(64).max(1280).optional().describe(`Frame width (default ${DEFAULT_PLAYER_WIDTH}).`),
|
|
75
88
|
},
|
|
89
|
+
annotations: READ_ONLY,
|
|
76
90
|
_meta: { ui: { visibility: ["app"] } },
|
|
77
|
-
}, async (args) => {
|
|
91
|
+
}, async (args, extra) => {
|
|
78
92
|
try {
|
|
79
93
|
requireFfmpeg();
|
|
80
94
|
if (!existsSync(args.input))
|
|
81
95
|
throw new ScreencastError(`Input file not found: ${args.input}`);
|
|
82
96
|
const info = await probeMedia(args.input);
|
|
83
97
|
const durationSec = info.durationSec ?? 0;
|
|
84
|
-
const
|
|
85
|
-
const
|
|
86
|
-
|
|
87
|
-
|
|
98
|
+
const plan = playerFramePlan(durationSec, args.maxFrames ?? DEFAULT_PLAYER_FRAMES);
|
|
99
|
+
const log = tempPath(".txt");
|
|
100
|
+
let jpegs;
|
|
101
|
+
let frames;
|
|
102
|
+
try {
|
|
103
|
+
const raw = await runFfmpegBuffer(buildPlayerFramesArgs(args.input, plan, args.width ?? DEFAULT_PLAYER_WIDTH, log), jobTimeoutMs(durationSec), { signal: extra.signal });
|
|
104
|
+
jpegs = splitJpegs(raw);
|
|
105
|
+
frames = parsePlayerFrameLog(existsSync(log) ? readFileSync(log, "utf8") : "").slice(0, jpegs.length);
|
|
106
|
+
}
|
|
107
|
+
finally {
|
|
108
|
+
rmSync(log, { force: true });
|
|
109
|
+
}
|
|
110
|
+
const [firstFrame] = frames;
|
|
111
|
+
if (!firstFrame)
|
|
112
|
+
throw new ScreencastError("ffmpeg returned no preview frames.");
|
|
113
|
+
const keep = pickPlayerFrames(frames, plan.count).flatMap((i) => {
|
|
114
|
+
const frame = frames[i];
|
|
115
|
+
const jpeg = jpegs[i];
|
|
116
|
+
return frame && jpeg ? [{ frame, jpeg }] : [];
|
|
117
|
+
});
|
|
118
|
+
const t0 = firstFrame.timeSec;
|
|
119
|
+
const frameTimes = keep.map(({ frame }) => Math.round((frame.timeSec - t0) * 1000) / 1000);
|
|
120
|
+
const sceneFrames = keep.flatMap(({ frame }, k) => (frame.scene ? [k] : []));
|
|
88
121
|
return {
|
|
89
122
|
content: [
|
|
90
123
|
{
|
|
@@ -95,10 +128,12 @@ export function register(server) {
|
|
|
95
128
|
width: info.width,
|
|
96
129
|
height: info.height,
|
|
97
130
|
hasAudio: info.audioCodec !== null,
|
|
98
|
-
frameTimes
|
|
131
|
+
frameTimes,
|
|
132
|
+
intervalSec: plan.intervalSec,
|
|
133
|
+
sceneFrames,
|
|
99
134
|
}),
|
|
100
135
|
},
|
|
101
|
-
...
|
|
136
|
+
...keep.map(({ jpeg }) => ({ type: "image", data: jpeg.toString("base64"), mimeType: "image/jpeg" })),
|
|
102
137
|
],
|
|
103
138
|
};
|
|
104
139
|
}
|
|
@@ -106,5 +141,11 @@ export function register(server) {
|
|
|
106
141
|
return errorResponse(error);
|
|
107
142
|
}
|
|
108
143
|
});
|
|
144
|
+
playerFrames.disable();
|
|
145
|
+
const previous = server.server.oninitialized;
|
|
146
|
+
server.server.oninitialized = () => {
|
|
147
|
+
previous?.();
|
|
148
|
+
if (clientSupportsApps(server.server.getClientCapabilities()))
|
|
149
|
+
playerFrames.enable();
|
|
150
|
+
};
|
|
109
151
|
}
|
|
110
|
-
//# sourceMappingURL=reviewRecording.js.map
|
|
@@ -2,77 +2,81 @@ import { z } from "zod";
|
|
|
2
2
|
import { join } from "node:path";
|
|
3
3
|
import { mkdirSync, readdirSync, existsSync, rmSync } from "node:fs";
|
|
4
4
|
import { errorResponse, okResponse, ScreencastError } from "../utils/errors.js";
|
|
5
|
+
import { READ_ONLY, looseOutput } from "../utils/toolSpec.js";
|
|
5
6
|
import { requireFfmpeg, runFfmpeg, runCapture, probeMedia } from "../utils/ffmpeg.js";
|
|
6
7
|
import { jobTimeoutMs } from "../utils/jobs.js";
|
|
7
8
|
import { buildSampleByFpsArgs, buildSampleAtTimestampArgs, planFpsSampling, buildSceneScanArgs, parseSceneScan, pickSceneFrames, DEFAULT_SCENE_THRESHOLD, DEFAULT_MAX_FRAMES, MAX_FRAMES_CEILING, } from "../utils/media.js";
|
|
8
|
-
import { subdir, stamp, rand, sequencePattern } from "../utils/paths.js";
|
|
9
|
+
import { subdir, stamp, rand, sequencePattern, resolveOutputDir } from "../utils/paths.js";
|
|
9
10
|
import { encodeInlineImages, clampInlineCount, DEFAULT_MAX_IMAGE_WIDTH, DEFAULT_MAX_INLINE_IMAGES, MAX_INLINE_IMAGES, } from "../utils/images.js";
|
|
10
11
|
const inputSchema = {
|
|
11
12
|
input: z.string().min(1).describe("Path to the source video file."),
|
|
12
13
|
mode: z
|
|
13
14
|
.enum(["fps", "timestamps", "scenes"])
|
|
14
15
|
.optional()
|
|
15
|
-
.describe("
|
|
16
|
-
"
|
|
17
|
-
"usually the cheapest way to review a recording. Defaults to 'fps' or " +
|
|
18
|
-
"'timestamps' depending on which of those is given."),
|
|
16
|
+
.describe("scenes: only frames where the screen changed (strongest first), usually the cheapest review. " +
|
|
17
|
+
"Default: fps or timestamps, whichever is given."),
|
|
19
18
|
fps: z
|
|
20
19
|
.number()
|
|
21
20
|
.positive()
|
|
22
21
|
.optional()
|
|
23
|
-
.describe("
|
|
22
|
+
.describe("Frames per second (mode fps)."),
|
|
24
23
|
timestamps: z
|
|
25
24
|
.array(z.number().nonnegative())
|
|
26
25
|
.optional()
|
|
27
|
-
.describe("
|
|
26
|
+
.describe("Seconds to grab a frame at (mode timestamps)."),
|
|
28
27
|
sceneThreshold: z
|
|
29
28
|
.number()
|
|
30
29
|
.gt(0)
|
|
31
30
|
.lt(1)
|
|
32
31
|
.optional()
|
|
33
|
-
.describe(`Mode
|
|
34
|
-
"raise it to keep only big changes)."),
|
|
32
|
+
.describe(`Mode scenes: change needed to count, 0-1 (default ${DEFAULT_SCENE_THRESHOLD}).`),
|
|
35
33
|
dedupe: z
|
|
36
34
|
.boolean()
|
|
37
35
|
.optional()
|
|
38
|
-
.describe("Mode
|
|
36
|
+
.describe("Mode fps: drop near-duplicate frames (default false)."),
|
|
39
37
|
outputDir: z
|
|
40
38
|
.string()
|
|
41
39
|
.optional()
|
|
42
|
-
.describe("Optional folder for the frames. Defaults to SCREENCAST_HOME/frames/<id>."),
|
|
40
|
+
.describe("Optional folder for the frames (a relative path resolves under SCREENCAST_HOME/frames). Defaults to SCREENCAST_HOME/frames/<id>."),
|
|
43
41
|
maxFrames: z
|
|
44
42
|
.number()
|
|
45
43
|
.int()
|
|
46
44
|
.min(1)
|
|
47
45
|
.max(MAX_FRAMES_CEILING)
|
|
48
46
|
.optional()
|
|
49
|
-
.describe(`
|
|
50
|
-
"In fps mode a rate that would exceed it is lowered so the frames still span the whole video."),
|
|
47
|
+
.describe(`Frame cap (default ${DEFAULT_MAX_FRAMES}); fps is lowered to fit while still spanning the video.`),
|
|
51
48
|
returnImages: z
|
|
52
49
|
.boolean()
|
|
53
50
|
.optional()
|
|
54
|
-
.describe("
|
|
55
|
-
"(default true). Only the first maxInlineImages frames are embedded."),
|
|
51
|
+
.describe("Return the first maxInlineImages frames inline (default true)."),
|
|
56
52
|
maxInlineImages: z
|
|
57
53
|
.number()
|
|
58
54
|
.int()
|
|
59
55
|
.min(0)
|
|
60
56
|
.max(MAX_INLINE_IMAGES)
|
|
61
57
|
.optional()
|
|
62
|
-
.describe(`
|
|
63
|
-
"Every frame is still written to disk and listed by path."),
|
|
58
|
+
.describe(`Frames to embed inline (default ${DEFAULT_MAX_INLINE_IMAGES}); all are listed by path.`),
|
|
64
59
|
maxImageWidth: z
|
|
65
60
|
.number()
|
|
66
61
|
.int()
|
|
67
62
|
.min(16)
|
|
68
63
|
.optional()
|
|
69
|
-
.describe(`
|
|
64
|
+
.describe(`Max inline image width (default ${DEFAULT_MAX_IMAGE_WIDTH}).`),
|
|
70
65
|
};
|
|
71
66
|
export function register(server) {
|
|
72
|
-
server.
|
|
73
|
-
"
|
|
74
|
-
"
|
|
75
|
-
|
|
67
|
+
server.registerTool("sample_frames", {
|
|
68
|
+
title: "Sample Frames",
|
|
69
|
+
description: "Sample PNG frames from a video (by fps, timestamps, or scene changes) and return the first " +
|
|
70
|
+
"few inline so the model can see what happened.",
|
|
71
|
+
inputSchema,
|
|
72
|
+
outputSchema: looseOutput({
|
|
73
|
+
frameDir: z.string(),
|
|
74
|
+
frameCount: z.number().int(),
|
|
75
|
+
frames: z.array(z.string()),
|
|
76
|
+
mode: z.string(),
|
|
77
|
+
}),
|
|
78
|
+
annotations: READ_ONLY,
|
|
79
|
+
}, async (args, extra) => {
|
|
76
80
|
try {
|
|
77
81
|
requireFfmpeg();
|
|
78
82
|
if (!existsSync(args.input)) {
|
|
@@ -93,34 +97,28 @@ export function register(server) {
|
|
|
93
97
|
throw new ScreencastError(`${args.timestamps.length} timestamps exceeds maxFrames (${maxFrames}). ` +
|
|
94
98
|
`Pass fewer timestamps, or raise maxFrames (up to ${MAX_FRAMES_CEILING}).`);
|
|
95
99
|
}
|
|
96
|
-
// Size an fps request against the video's length before writing
|
|
97
|
-
// anything, so a high rate on a long recording cannot fill the disk (#80).
|
|
98
100
|
const durationSec = mode === "timestamps" ? null : (await probeMedia(args.input)).durationSec;
|
|
99
101
|
const plan = mode === "fps" ? planFpsSampling(durationSec, args.fps, maxFrames) : null;
|
|
100
|
-
// Scenes (#114): a cheap low-res pass finds where the screen changed;
|
|
101
|
-
// the chosen moments are then grabbed at full size like timestamps.
|
|
102
102
|
let scenes = null;
|
|
103
103
|
let sceneTimes = [];
|
|
104
104
|
if (mode === "scenes") {
|
|
105
105
|
const { ffmpeg } = requireFfmpeg();
|
|
106
|
-
const scan = await runCapture(ffmpeg, buildSceneScanArgs(args.input, args.sceneThreshold ?? DEFAULT_SCENE_THRESHOLD), jobTimeoutMs(durationSec));
|
|
106
|
+
const scan = await runCapture(ffmpeg, buildSceneScanArgs(args.input, args.sceneThreshold ?? DEFAULT_SCENE_THRESHOLD), jobTimeoutMs(durationSec), { signal: extra.signal });
|
|
107
107
|
if (scan.code !== 0) {
|
|
108
108
|
throw new ScreencastError(`Scene scan failed (exit ${scan.code}): ${scan.stderr.trim().slice(-400)}`);
|
|
109
109
|
}
|
|
110
110
|
scenes = parseSceneScan(scan.stdout);
|
|
111
111
|
sceneTimes = pickSceneFrames(scenes, maxFrames);
|
|
112
112
|
}
|
|
113
|
-
const dir = args.outputDir ?? join(subdir("frames"), `sample-${stamp()}-${rand()}`);
|
|
113
|
+
const dir = resolveOutputDir(args.outputDir, subdir("frames")) ?? join(subdir("frames"), `sample-${stamp()}-${rand()}`);
|
|
114
114
|
mkdirSync(dir, { recursive: true });
|
|
115
115
|
let frames = [];
|
|
116
116
|
const skipped = [];
|
|
117
117
|
if (plan) {
|
|
118
118
|
const isPng = (f) => f.endsWith(".png");
|
|
119
|
-
// Snapshot any pre-existing PNGs so a reused outputDir does not
|
|
120
|
-
// contaminate the result; return only the frames this run wrote.
|
|
121
119
|
const before = new Set(readdirSync(dir).filter(isPng));
|
|
122
120
|
const pattern = sequencePattern(dir, "frame_%05d.png");
|
|
123
|
-
await runFfmpeg(buildSampleByFpsArgs(args.input, plan.fps, pattern, maxFrames, args.dedupe === true),
|
|
121
|
+
await runFfmpeg(buildSampleByFpsArgs(args.input, plan.fps, pattern, maxFrames, args.dedupe === true), jobTimeoutMs(durationSec), { signal: extra.signal });
|
|
124
122
|
frames = readdirSync(dir)
|
|
125
123
|
.filter(isPng)
|
|
126
124
|
.filter((f) => !before.has(f))
|
|
@@ -129,18 +127,14 @@ export function register(server) {
|
|
|
129
127
|
}
|
|
130
128
|
else {
|
|
131
129
|
const ts = mode === "scenes" ? sceneTimes : args.timestamps;
|
|
132
|
-
for (
|
|
133
|
-
const out = join(dir, `frame_${String(i).padStart(3, "0")}_${
|
|
134
|
-
// Clear any stale file at this path (reused outputDir) so existence
|
|
135
|
-
// after the run reflects only what this invocation wrote.
|
|
130
|
+
for (const [i, t] of ts.entries()) {
|
|
131
|
+
const out = join(dir, `frame_${String(i).padStart(3, "0")}_${t}s.png`);
|
|
136
132
|
rmSync(out, { force: true });
|
|
137
|
-
await runFfmpeg(buildSampleAtTimestampArgs(args.input,
|
|
138
|
-
// A timestamp past the end of the video makes ffmpeg exit 0 without
|
|
139
|
-
// writing a file. Report only frames that actually exist (#35).
|
|
133
|
+
await runFfmpeg(buildSampleAtTimestampArgs(args.input, t, out), 60_000, { signal: extra.signal });
|
|
140
134
|
if (existsSync(out))
|
|
141
135
|
frames.push(out);
|
|
142
136
|
else
|
|
143
|
-
skipped.push(
|
|
137
|
+
skipped.push(t);
|
|
144
138
|
}
|
|
145
139
|
}
|
|
146
140
|
const inline = args.returnImages === false
|
|
@@ -200,4 +194,3 @@ export function register(server) {
|
|
|
200
194
|
}
|
|
201
195
|
});
|
|
202
196
|
}
|
|
203
|
-
//# sourceMappingURL=sampleFrames.js.map
|
package/dist/tools/scale.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
import { existsSync } from "node:fs";
|
|
3
3
|
import { errorResponse, okResponse, ScreencastError } from "../utils/errors.js";
|
|
4
|
+
import { OUTPUT_PATH, WRITES_FILE } from "../utils/toolSpec.js";
|
|
4
5
|
import { requireFfmpeg } from "../utils/ffmpeg.js";
|
|
5
6
|
import { runEditJob, probeDuration } from "../utils/jobs.js";
|
|
6
7
|
import { buildScaleArgs, editOutputExt, assertEditContainer } from "../utils/media.js";
|
|
@@ -13,8 +14,14 @@ const inputSchema = {
|
|
|
13
14
|
overwrite: z.boolean().optional().describe("Allow replacing an existing file at the output path (default false)."),
|
|
14
15
|
};
|
|
15
16
|
export function register(server) {
|
|
16
|
-
server.
|
|
17
|
-
"
|
|
17
|
+
server.registerTool("scale", {
|
|
18
|
+
title: "Scale Video",
|
|
19
|
+
description: "Resize a video to a target width and/or height and re-encode. Provide one " +
|
|
20
|
+
"side to keep the aspect ratio, or both to set an exact size.",
|
|
21
|
+
inputSchema,
|
|
22
|
+
outputSchema: OUTPUT_PATH,
|
|
23
|
+
annotations: WRITES_FILE,
|
|
24
|
+
}, async (args, extra) => {
|
|
18
25
|
try {
|
|
19
26
|
requireFfmpeg();
|
|
20
27
|
if (!existsSync(args.input)) {
|
|
@@ -35,4 +42,3 @@ export function register(server) {
|
|
|
35
42
|
}
|
|
36
43
|
});
|
|
37
44
|
}
|
|
38
|
-
//# sourceMappingURL=scale.js.map
|
package/dist/tools/screenDiff.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
import { existsSync, rmSync } from "node:fs";
|
|
3
3
|
import { errorResponse, okResponse, ScreencastError } from "../utils/errors.js";
|
|
4
|
+
import { READ_ONLY, looseOutput } from "../utils/toolSpec.js";
|
|
4
5
|
import { requireFfmpeg, runCapture, runFfmpeg, runFfmpegBuffer, probeMedia } from "../utils/ffmpeg.js";
|
|
5
6
|
import { detectionSize, diffFrames, buildRawFrameArgs, buildSsimArgs, buildHighlightArgs, parseSsim, DEFAULT_PIXEL_THRESHOLD, } from "../utils/diff.js";
|
|
6
7
|
import { stamp, rand } from "../utils/paths.js";
|
|
@@ -8,25 +9,34 @@ import { tmpdir } from "node:os";
|
|
|
8
9
|
import { join } from "node:path";
|
|
9
10
|
import { encodeInlineImages, DEFAULT_MAX_IMAGE_WIDTH } from "../utils/images.js";
|
|
10
11
|
const inputSchema = {
|
|
11
|
-
a: z.string().min(1).describe("
|
|
12
|
-
b: z.string().min(1).describe("
|
|
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."),
|
|
13
14
|
pixelThreshold: z
|
|
14
15
|
.number()
|
|
15
16
|
.min(0)
|
|
16
17
|
.max(255)
|
|
17
18
|
.optional()
|
|
18
|
-
.describe(`
|
|
19
|
-
`(default ${DEFAULT_PIXEL_THRESHOLD}: catches a changed label or a toast).`),
|
|
19
|
+
.describe(`Mean 0-255 difference for a ~32x32 cell to count as changed (default ${DEFAULT_PIXEL_THRESHOLD}).`),
|
|
20
20
|
returnImage: z
|
|
21
21
|
.boolean()
|
|
22
22
|
.optional()
|
|
23
|
-
.describe("
|
|
23
|
+
.describe("Return b inline with changes outlined (default true)."),
|
|
24
24
|
};
|
|
25
25
|
export function register(server) {
|
|
26
|
-
server.
|
|
27
|
-
"
|
|
28
|
-
"
|
|
29
|
-
|
|
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) => {
|
|
30
40
|
try {
|
|
31
41
|
requireFfmpeg();
|
|
32
42
|
for (const f of [args.a, args.b]) {
|
|
@@ -38,12 +48,10 @@ export function register(server) {
|
|
|
38
48
|
throw new ScreencastError(`Could not read the size of ${args.a}.`);
|
|
39
49
|
const size = detectionSize(ia.width, ia.height);
|
|
40
50
|
const [ra, rb, ssimRun] = await Promise.all([
|
|
41
|
-
runFfmpegBuffer(buildRawFrameArgs(args.a, size)),
|
|
42
|
-
runFfmpegBuffer(buildRawFrameArgs(args.b, size)),
|
|
43
|
-
runCapture(requireFfmpeg().ffmpeg, buildSsimArgs(args.a, args.b, size), 30_000),
|
|
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 }),
|
|
44
54
|
]);
|
|
45
|
-
// Map boxes onto b's own pixels so they can be drawn on (and clicked in)
|
|
46
|
-
// b, per axis: b was stretched to a's aspect ratio (#211).
|
|
47
55
|
const diff = diffFrames(ra, rb, size.width, size.height, {
|
|
48
56
|
scaleX: (ib.width ?? ia.width) / size.width,
|
|
49
57
|
scaleY: (ib.height ?? ia.height) / size.height,
|
|
@@ -51,10 +59,9 @@ export function register(server) {
|
|
|
51
59
|
});
|
|
52
60
|
const images = [];
|
|
53
61
|
if (args.returnImage !== false) {
|
|
54
|
-
// Only returned inline, so it is not left on disk (#209).
|
|
55
62
|
const highlighted = join(tmpdir(), `screencast-diff-${stamp()}-${rand()}.png`);
|
|
56
63
|
try {
|
|
57
|
-
await runFfmpeg(buildHighlightArgs(args.b, diff.regions, highlighted), 30_000);
|
|
64
|
+
await runFfmpeg(buildHighlightArgs(args.b, diff.regions, highlighted), 30_000, { signal: extra.signal });
|
|
58
65
|
images.push(...(await encodeInlineImages([highlighted], DEFAULT_MAX_IMAGE_WIDTH, 1)).images);
|
|
59
66
|
}
|
|
60
67
|
finally {
|
|
@@ -77,4 +84,3 @@ export function register(server) {
|
|
|
77
84
|
}
|
|
78
85
|
});
|
|
79
86
|
}
|
|
80
|
-
//# sourceMappingURL=screenDiff.js.map
|
package/dist/tools/screenshot.js
CHANGED
|
@@ -1,30 +1,26 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
import { errorResponse, okResponse } from "../utils/errors.js";
|
|
3
|
+
import { WRITES_FILE, looseOutput } from "../utils/toolSpec.js";
|
|
3
4
|
import { requireFfmpeg } from "../utils/ffmpeg.js";
|
|
4
5
|
import { captureStill } from "../utils/still.js";
|
|
5
6
|
import { resolveCaptureTarget } from "../utils/resolveTarget.js";
|
|
6
7
|
import { resolveOutput, subdir, stamp, rand } from "../utils/paths.js";
|
|
7
8
|
import { encodeInlineImages, DEFAULT_MAX_IMAGE_WIDTH } from "../utils/images.js";
|
|
8
9
|
import { windowMatchReport } from "../utils/windows.js";
|
|
10
|
+
import { confirmCapture, describeTarget } from "../utils/consent.js";
|
|
9
11
|
const inputSchema = {
|
|
10
12
|
target: z
|
|
11
13
|
.string()
|
|
12
|
-
.describe("
|
|
13
|
-
"
|
|
14
|
-
"window occupies as currently displayed - it must be visible, on top, " +
|
|
15
|
-
"and not minimized (case-insensitive exact title, else substring; " +
|
|
16
|
-
"topmost match wins)."),
|
|
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."),
|
|
17
16
|
exactTitle: z
|
|
18
17
|
.boolean()
|
|
19
18
|
.optional()
|
|
20
|
-
.describe("
|
|
21
|
-
"title (case-insensitive); never fall back to a substring match. Default false."),
|
|
19
|
+
.describe("window: targets match the whole title only, never a substring (default false)."),
|
|
22
20
|
backend: z
|
|
23
21
|
.enum(["gdigrab", "wgc"])
|
|
24
22
|
.optional()
|
|
25
|
-
.describe("gdigrab (default, ~0.2 s)
|
|
26
|
-
"only, FFmpeg 8+) captures the window's own surface through Windows Graphics Capture, " +
|
|
27
|
-
"even when other windows cover it; slower (~1-2 s)."),
|
|
23
|
+
.describe("gdigrab (default, ~0.2 s): what is visible. wgc (window:, FFmpeg 8+, ~1-2 s): the window even if covered."),
|
|
28
24
|
output: z
|
|
29
25
|
.string()
|
|
30
26
|
.optional()
|
|
@@ -33,25 +29,34 @@ const inputSchema = {
|
|
|
33
29
|
returnImage: z
|
|
34
30
|
.boolean()
|
|
35
31
|
.optional()
|
|
36
|
-
.describe("
|
|
37
|
-
"(default true). The PNG on disk is always full resolution."),
|
|
32
|
+
.describe("Return the image inline (default true; the PNG on disk stays full size)."),
|
|
38
33
|
maxImageWidth: z
|
|
39
34
|
.number()
|
|
40
35
|
.int()
|
|
41
36
|
.min(16)
|
|
42
37
|
.optional()
|
|
43
|
-
.describe(`
|
|
38
|
+
.describe(`Max inline image width (default ${DEFAULT_MAX_IMAGE_WIDTH}).`),
|
|
44
39
|
};
|
|
45
40
|
export function register(server) {
|
|
46
|
-
server.
|
|
47
|
-
|
|
48
|
-
"
|
|
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) => {
|
|
49
53
|
try {
|
|
50
54
|
requireFfmpeg();
|
|
51
55
|
const resolved = await resolveCaptureTarget(args.target, { exactTitle: args.exactTitle, backend: args.backend });
|
|
52
56
|
const { window } = resolved;
|
|
53
57
|
const output = resolveOutput(args.output, subdir("screenshots"), `shot-${stamp()}-${rand()}.png`, args.overwrite);
|
|
54
58
|
const backend = args.backend ?? "gdigrab";
|
|
59
|
+
await confirmCapture(server, `Take a screenshot of ${describeTarget(args.target, window)}, saved to ${output}?`, extra.signal);
|
|
55
60
|
await captureStill(resolved, output, backend);
|
|
56
61
|
const images = args.returnImage === false
|
|
57
62
|
? []
|
|
@@ -69,4 +74,3 @@ export function register(server) {
|
|
|
69
74
|
}
|
|
70
75
|
});
|
|
71
76
|
}
|
|
72
|
-
//# sourceMappingURL=screenshot.js.map
|
package/dist/tools/speed.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
import { existsSync } from "node:fs";
|
|
3
3
|
import { errorResponse, okResponse, ScreencastError } from "../utils/errors.js";
|
|
4
|
+
import { OUTPUT_PATH, WRITES_FILE } from "../utils/toolSpec.js";
|
|
4
5
|
import { requireFfmpeg, probeMedia } from "../utils/ffmpeg.js";
|
|
5
6
|
import { runEditJob } from "../utils/jobs.js";
|
|
6
7
|
import { buildSpeedArgs, editOutputExt, assertEditContainer } from "../utils/media.js";
|
|
@@ -12,8 +13,14 @@ const inputSchema = {
|
|
|
12
13
|
overwrite: z.boolean().optional().describe("Allow replacing an existing file at the output path (default false)."),
|
|
13
14
|
};
|
|
14
15
|
export function register(server) {
|
|
15
|
-
server.
|
|
16
|
-
"
|
|
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) => {
|
|
17
24
|
try {
|
|
18
25
|
requireFfmpeg();
|
|
19
26
|
if (!existsSync(args.input)) {
|
|
@@ -24,7 +31,12 @@ export function register(server) {
|
|
|
24
31
|
const ext = editOutputExt(args.input);
|
|
25
32
|
const output = resolveOutput(args.output, subdir("edits"), `speed-${stamp()}-${rand()}${ext}`, args.overwrite);
|
|
26
33
|
const ffArgs = buildSpeedArgs(args.input, output, args.factor, audioCodec !== null);
|
|
27
|
-
await runEditJob(ffArgs, {
|
|
34
|
+
await runEditJob(ffArgs, {
|
|
35
|
+
output,
|
|
36
|
+
durationSec: durationSec !== null ? durationSec / args.factor : null,
|
|
37
|
+
inputDurationSec: durationSec,
|
|
38
|
+
extra,
|
|
39
|
+
});
|
|
28
40
|
return okResponse({ outputPath: output, factor: args.factor, audio: audioCodec !== null });
|
|
29
41
|
}
|
|
30
42
|
catch (error) {
|
|
@@ -32,4 +44,3 @@ export function register(server) {
|
|
|
32
44
|
}
|
|
33
45
|
});
|
|
34
46
|
}
|
|
35
|
-
//# sourceMappingURL=speed.js.map
|