@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,31 +1,31 @@
|
|
|
1
1
|
import { spawn } from "node:child_process";
|
|
2
2
|
import { z } from "zod";
|
|
3
3
|
import { errorResponse, okResponse, ScreencastError } from "../utils/errors.js";
|
|
4
|
+
import { WRITES_FILE, looseOutput } from "../utils/toolSpec.js";
|
|
4
5
|
import { requireFfmpeg, wgcAvailable } from "../utils/ffmpeg.js";
|
|
5
6
|
import { fileURLToPath } from "node:url";
|
|
6
7
|
import { buildCaptureArgs, captureFrame, resolveQuality, DEFAULT_FPS, DEFAULT_QUALITY, DEFAULT_MAX_RECORDING_SEC, MAX_RECORDING_CAP_SEC, resolveMaxDuration, captureKeyframeArgs, } from "../utils/targets.js";
|
|
7
8
|
import { resolveCaptureTarget } from "../utils/resolveTarget.js";
|
|
8
9
|
import { windowMatchReport } from "../utils/windows.js";
|
|
9
10
|
import { resolveLoopbackDevice } from "../utils/audioDevices.js";
|
|
11
|
+
import { confirmCapture, describeTarget } from "../utils/consent.js";
|
|
12
|
+
import { logMessage, StderrWatch } from "../utils/logging.js";
|
|
10
13
|
import { resolveOutput, subdir, stamp, rand } from "../utils/paths.js";
|
|
11
14
|
import { getStore } from "../context.js";
|
|
12
|
-
import { classifyUnrequestedExit, killPid } from "../utils/sessions.js";
|
|
15
|
+
import { classifyUnrequestedExit, killPid, serverIdentity } from "../utils/sessions.js";
|
|
13
16
|
import { rmSync } from "node:fs";
|
|
14
17
|
import { basename } from "node:path";
|
|
15
|
-
import { DEFAULT_KEY_MODE, eventPaths, parseCaptureStart, startEventLogger, stopEventLogger, summarizeEvents, trackFinalizer, writeEventsFile, } from "../utils/events.js";
|
|
18
|
+
import { DEFAULT_KEY_MODE, eventPaths, parseCaptureStart, prepareEventPaths, startEventLogger, stopEventLogger, summarizeEvents, trackFinalizer, writeEventsFile, } from "../utils/events.js";
|
|
16
19
|
const inputSchema = {
|
|
17
20
|
target: z
|
|
18
21
|
.string()
|
|
19
|
-
.describe("
|
|
20
|
-
"
|
|
21
|
-
"
|
|
22
|
-
"ONCE at start (it must be visible, on top, not minimized); it does not " +
|
|
23
|
-
"follow a window moved or resized mid-recording."),
|
|
22
|
+
.describe("full | monitor:<i> (0 = primary) | window:<title> (or window:exe=<app.exe> / window:hwnd=<n>) | " +
|
|
23
|
+
"region:<x>,<y>,<w>,<h>. With gdigrab a window's rectangle is resolved once at start (visible, " +
|
|
24
|
+
"on top); it does not follow the window."),
|
|
24
25
|
exactTitle: z
|
|
25
26
|
.boolean()
|
|
26
27
|
.optional()
|
|
27
|
-
.describe("
|
|
28
|
-
"title (case-insensitive); never fall back to a substring match. Default false."),
|
|
28
|
+
.describe("window: targets match the whole title only, never a substring (default false)."),
|
|
29
29
|
fps: z
|
|
30
30
|
.number()
|
|
31
31
|
.int()
|
|
@@ -41,20 +41,18 @@ const inputSchema = {
|
|
|
41
41
|
.object({
|
|
42
42
|
source: z
|
|
43
43
|
.enum(["system", "none"])
|
|
44
|
-
.describe("system
|
|
44
|
+
.describe("system = what the machine plays (needs a loopback device); none = video only."),
|
|
45
45
|
device: z
|
|
46
46
|
.string()
|
|
47
47
|
.optional()
|
|
48
|
-
.describe("
|
|
49
|
-
"omitted, a loopback device is auto-detected."),
|
|
48
|
+
.describe("dshow loopback device (from list_audio_devices); auto-detected if omitted."),
|
|
50
49
|
})
|
|
51
50
|
.optional()
|
|
52
|
-
.describe("Audio
|
|
53
|
-
"loopback device; microphone capture is not supported."),
|
|
51
|
+
.describe("Audio (default none). No microphone capture."),
|
|
54
52
|
output: z
|
|
55
53
|
.string()
|
|
56
54
|
.optional()
|
|
57
|
-
.describe("
|
|
55
|
+
.describe("Output .mp4 path (default under SCREENCAST_HOME/recordings)."),
|
|
58
56
|
overwrite: z.boolean().optional().describe("Allow replacing an existing file at the output path (default false)."),
|
|
59
57
|
maxDurationSec: z
|
|
60
58
|
.number()
|
|
@@ -62,34 +60,38 @@ const inputSchema = {
|
|
|
62
60
|
.min(0)
|
|
63
61
|
.max(MAX_RECORDING_CAP_SEC)
|
|
64
62
|
.optional()
|
|
65
|
-
.describe(`
|
|
66
|
-
|
|
67
|
-
"A safety net against a recording that is never stopped."),
|
|
63
|
+
.describe(`Auto-stop after this many seconds (default ${DEFAULT_MAX_RECORDING_SEC} or ` +
|
|
64
|
+
"SCREENCAST_MAX_RECORDING_SEC; max 7 days; 0 = no cap)."),
|
|
68
65
|
events: z
|
|
69
66
|
.boolean()
|
|
70
67
|
.optional()
|
|
71
|
-
.describe("Also log
|
|
72
|
-
"
|
|
73
|
-
"false). Read it with read_events. Adds about a second to start."),
|
|
68
|
+
.describe("Also log clicks, scroll, cursor, and typing (video-timed, video pixels) for read_events " +
|
|
69
|
+
"(default false; ~1 s slower start)."),
|
|
74
70
|
keys: z
|
|
75
71
|
.enum(["masked", "shortcuts"])
|
|
76
72
|
.optional()
|
|
77
|
-
.describe("With events: masked (default) logs typing only as
|
|
78
|
-
"
|
|
79
|
-
"or Win (e.g. Ctrl+S), with their times; typed text is never logged."),
|
|
73
|
+
.describe("With events: masked (default) logs typing only as 0.5 s-grid bursts, never keys; shortcuts " +
|
|
74
|
+
"also names Ctrl/Alt/Win chords. Typed text is never logged."),
|
|
80
75
|
backend: z
|
|
81
76
|
.enum(["gdigrab", "wgc"])
|
|
82
77
|
.optional()
|
|
83
|
-
.describe("gdigrab (default)
|
|
84
|
-
"
|
|
85
|
-
"it is covered, moved, or in the background, and frames only its client area. No audio with wgc."),
|
|
78
|
+
.describe("gdigrab (default): the screen rectangle. wgc (window: targets, FFmpeg 8+): the window's own " +
|
|
79
|
+
"surface, even when covered or moved; client area only, no audio."),
|
|
86
80
|
};
|
|
87
81
|
export function register(server) {
|
|
88
|
-
server.
|
|
89
|
-
"
|
|
90
|
-
"
|
|
91
|
-
|
|
92
|
-
|
|
82
|
+
server.registerTool("start_recording", {
|
|
83
|
+
title: "Start Recording",
|
|
84
|
+
description: "Start a background screen recording. Returns a session id; finalize it with stop_recording. " +
|
|
85
|
+
"Never auto-starts.",
|
|
86
|
+
inputSchema,
|
|
87
|
+
outputSchema: looseOutput({
|
|
88
|
+
sessionId: z.string(),
|
|
89
|
+
status: z.string(),
|
|
90
|
+
backend: z.string(),
|
|
91
|
+
outputPath: z.string(),
|
|
92
|
+
}),
|
|
93
|
+
annotations: WRITES_FILE,
|
|
94
|
+
}, async (args, extra) => {
|
|
93
95
|
try {
|
|
94
96
|
const { ffmpeg } = requireFfmpeg();
|
|
95
97
|
const { target, monitors, window } = await resolveCaptureTarget(args.target, {
|
|
@@ -110,11 +112,14 @@ export function register(server) {
|
|
|
110
112
|
const quality = args.quality ?? DEFAULT_QUALITY;
|
|
111
113
|
const maxDurationSec = resolveMaxDuration(args.maxDurationSec);
|
|
112
114
|
const output = resolveOutput(args.output, subdir("recordings"), `rec-${stamp()}-${rand()}.mp4`, args.overwrite);
|
|
113
|
-
// Resolve a loopback device up front so a missing one fails before the
|
|
114
|
-
// ffmpeg child is spawned, with a clear install hint.
|
|
115
115
|
const audio = args.audio?.source === "system"
|
|
116
116
|
? { device: await resolveLoopbackDevice(args.audio.device) }
|
|
117
117
|
: undefined;
|
|
118
|
+
await confirmCapture(server, `Record ${describeTarget(args.target, window)} ` +
|
|
119
|
+
(maxDurationSec > 0 ? `for up to ${maxDurationSec} s` : "with no time limit") +
|
|
120
|
+
(audio ? `, with system audio (${audio.device})` : ", without audio") +
|
|
121
|
+
(args.events ? ", logging mouse clicks and typing" : "") +
|
|
122
|
+
`, saved to ${output}?`, extra.signal);
|
|
118
123
|
const ffArgs = buildCaptureArgs(target, {
|
|
119
124
|
fps,
|
|
120
125
|
quality,
|
|
@@ -123,10 +128,10 @@ export function register(server) {
|
|
|
123
128
|
audio,
|
|
124
129
|
maxDurationSec,
|
|
125
130
|
});
|
|
126
|
-
// The event logger starts first so the first frames have events (#118).
|
|
127
131
|
const keyMode = args.keys ?? DEFAULT_KEY_MODE;
|
|
128
132
|
const evPaths = args.events ? eventPaths(output) : null;
|
|
129
|
-
|
|
133
|
+
if (evPaths)
|
|
134
|
+
prepareEventPaths(evPaths, args.overwrite);
|
|
130
135
|
let frame = args.events
|
|
131
136
|
? captureFrame(target, monitors)
|
|
132
137
|
: null;
|
|
@@ -141,18 +146,17 @@ export function register(server) {
|
|
|
141
146
|
stdio: ["pipe", "ignore", "pipe"],
|
|
142
147
|
windowsHide: true,
|
|
143
148
|
});
|
|
144
|
-
// Detect an immediate failure (bad window title, busy device, etc.).
|
|
145
|
-
// The head keeps the input banner, whose start: time aligns events.
|
|
146
149
|
let stderrTail = "";
|
|
147
150
|
let stderrHead = "";
|
|
151
|
+
const id = `rec-${stamp()}-${rand(6)}`;
|
|
152
|
+
const watch = new StderrWatch(() => ({ sessionId: id }));
|
|
148
153
|
child.stderr?.on("data", (d) => {
|
|
149
154
|
const text = d.toString();
|
|
150
155
|
stderrTail = (stderrTail + text).slice(-2000);
|
|
151
156
|
if (stderrHead.length < 8000)
|
|
152
157
|
stderrHead += text;
|
|
158
|
+
watch.feed(text);
|
|
153
159
|
});
|
|
154
|
-
// gdigrab is running once it survives a moment; the wgc recorder says
|
|
155
|
-
// so when its first frame is written (a repaint can take a second).
|
|
156
160
|
const settled = await new Promise((resolve) => {
|
|
157
161
|
const timer = setTimeout(() => resolve("running"), backend === "wgc" ? 15_000 : 1200);
|
|
158
162
|
if (backend === "wgc") {
|
|
@@ -173,7 +177,6 @@ export function register(server) {
|
|
|
173
177
|
resolve("exited");
|
|
174
178
|
});
|
|
175
179
|
});
|
|
176
|
-
const id = `rec-${stamp()}-${rand(6)}`;
|
|
177
180
|
if (settled === "exited") {
|
|
178
181
|
if (logger)
|
|
179
182
|
await stopEventLogger(logger);
|
|
@@ -193,7 +196,7 @@ export function register(server) {
|
|
|
193
196
|
fps,
|
|
194
197
|
quality,
|
|
195
198
|
pid: child.pid ?? null,
|
|
196
|
-
|
|
199
|
+
...serverIdentity(),
|
|
197
200
|
status: "recording",
|
|
198
201
|
startedAt: new Date().toISOString(),
|
|
199
202
|
...(maxDurationSec > 0 ? { maxDurationSec } : {}),
|
|
@@ -203,8 +206,6 @@ export function register(server) {
|
|
|
203
206
|
processImage: backend === "wgc" ? basename(process.execPath).toLowerCase() : "ffmpeg.exe",
|
|
204
207
|
};
|
|
205
208
|
const store = getStore();
|
|
206
|
-
// Register the child for shutdown first; if the registry write fails,
|
|
207
|
-
// stop the capture rather than leave one nothing can reach (#207).
|
|
208
209
|
store.attachChild(id, child);
|
|
209
210
|
try {
|
|
210
211
|
store.create(record);
|
|
@@ -239,19 +240,15 @@ export function register(server) {
|
|
|
239
240
|
process.stderr.write(`Event log for ${id} failed: ${err instanceof Error ? err.message : String(err)}\n`);
|
|
240
241
|
}));
|
|
241
242
|
}
|
|
242
|
-
// Keep the on-disk record consistent if the child dies on its own. A
|
|
243
|
-
// non-zero exit is a crash (disk full, encoder failure), not a clean
|
|
244
|
-
// stop - record it as "failed" with the stderr tail so the caller can
|
|
245
|
-
// tell the two apart. A clean exit nobody requested is the
|
|
246
|
-
// maxDurationSec cap, or the recorded window closing (#240).
|
|
247
243
|
child.on("exit", (code) => {
|
|
248
244
|
store.detachChild(id);
|
|
249
245
|
const cur = store.get(id);
|
|
250
|
-
// A deliberate stop (stop_recording / shutdown) records its own final
|
|
251
|
-
// state; only an exit nobody asked for is classified here.
|
|
252
246
|
if (!cur || cur.status !== "recording" || store.isStopping(id))
|
|
253
247
|
return;
|
|
254
248
|
const verdict = classifyUnrequestedExit({ code, backend, maxDurationSec, elapsedMs: Date.now() - spawnedAt });
|
|
249
|
+
logMessage(verdict.status === "failed" ? "error" : "notice", verdict.status === "failed"
|
|
250
|
+
? `Recording ${id} failed: the recorder exited with code ${code}.`
|
|
251
|
+
: `Recording ${id} ended on its own (${verdict.endReason}).`, { sessionId: id, ...verdict });
|
|
255
252
|
store.tryUpdate(id, {
|
|
256
253
|
...verdict,
|
|
257
254
|
stoppedAt: new Date().toISOString(),
|
|
@@ -283,4 +280,3 @@ export function register(server) {
|
|
|
283
280
|
}
|
|
284
281
|
});
|
|
285
282
|
}
|
|
286
|
-
//# sourceMappingURL=startRecording.js.map
|
|
@@ -1,23 +1,25 @@
|
|
|
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 { STOPS_SESSION, looseOutput } from "../utils/toolSpec.js";
|
|
4
5
|
import { requireFfmpeg } from "../utils/ffmpeg.js";
|
|
5
6
|
import { probeDuration, stopSession } from "../utils/lifecycle.js";
|
|
6
7
|
import { getStore } from "../context.js";
|
|
7
|
-
import { PLAYER_TOOL_META } from "../utils/player.js";
|
|
8
8
|
const inputSchema = {
|
|
9
9
|
sessionId: z.string().min(1).describe("Session id returned by start_recording."),
|
|
10
10
|
};
|
|
11
11
|
export function register(server) {
|
|
12
12
|
server.registerTool("stop_recording", {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
"duration. Falls back to terminating the process by pid if the live " +
|
|
16
|
-
"handle was lost (for example after a server restart). Clients with MCP " +
|
|
17
|
-
"Apps show the review player for the result.",
|
|
13
|
+
title: "Stop Recording",
|
|
14
|
+
description: "Stop a recording gracefully so the file is finalized; returns the path and duration.",
|
|
18
15
|
inputSchema,
|
|
19
|
-
|
|
20
|
-
|
|
16
|
+
outputSchema: looseOutput({
|
|
17
|
+
sessionId: z.string(),
|
|
18
|
+
status: z.string(),
|
|
19
|
+
outputPath: z.string(),
|
|
20
|
+
durationSec: z.number().nullable(),
|
|
21
|
+
}),
|
|
22
|
+
annotations: STOPS_SESSION,
|
|
21
23
|
}, async (args) => {
|
|
22
24
|
try {
|
|
23
25
|
const store = getStore();
|
|
@@ -65,4 +67,3 @@ export function register(server) {
|
|
|
65
67
|
}
|
|
66
68
|
});
|
|
67
69
|
}
|
|
68
|
-
//# sourceMappingURL=stopRecording.js.map
|
package/dist/tools/titleCard.js
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
import { writeFileSync, rmSync } from "node:fs";
|
|
3
3
|
import { errorResponse, okResponse } 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 } from "../utils/jobs.js";
|
|
6
7
|
import { buildTitleCardArgs, DEFAULT_TITLE_DURATION } from "../utils/produce.js";
|
|
7
|
-
import {
|
|
8
|
+
import { resolveTextFont } from "../utils/fonts.js";
|
|
9
|
+
import { fontFileSchema } from "./callout.js";
|
|
8
10
|
import { resolveOutput, subdir, stamp, rand, tempPath } from "../utils/paths.js";
|
|
9
11
|
const inputSchema = {
|
|
10
12
|
text: z.string().min(1).describe("Title text. Multiple lines are allowed (use \\n)."),
|
|
@@ -16,24 +18,27 @@ const inputSchema = {
|
|
|
16
18
|
fontColor: z.string().optional().describe("Text color (default white)."),
|
|
17
19
|
fontSize: z.number().int().positive().optional().describe("Text size in px (default 96)."),
|
|
18
20
|
bold: z.boolean().optional().describe("Use the bold weight (default true)."),
|
|
21
|
+
fontFile: fontFileSchema,
|
|
19
22
|
output: z.string().optional().describe("Optional output path. Defaults under SCREENCAST_HOME/edits."),
|
|
20
23
|
overwrite: z.boolean().optional().describe("Allow replacing an existing file at the output path (default false)."),
|
|
21
24
|
};
|
|
22
25
|
export function register(server) {
|
|
23
|
-
server.
|
|
24
|
-
"
|
|
25
|
-
"
|
|
26
|
-
|
|
26
|
+
server.registerTool("title_card", {
|
|
27
|
+
title: "Title Card",
|
|
28
|
+
description: "Generate a title card clip (centered text on a solid background, silent audio track) to stitch " +
|
|
29
|
+
"in with assemble_highlights. Uncoverable characters are reported in warnings.",
|
|
30
|
+
inputSchema,
|
|
31
|
+
outputSchema: OUTPUT_PATH,
|
|
32
|
+
annotations: WRITES_FILE,
|
|
33
|
+
}, async (args, extra) => {
|
|
27
34
|
try {
|
|
28
35
|
requireFfmpeg();
|
|
29
36
|
const output = resolveOutput(args.output, subdir("edits"), `title-${stamp()}-${rand()}.mp4`, args.overwrite);
|
|
30
|
-
const
|
|
31
|
-
// Write the text to a temp file so arbitrary content (quotes, colons,
|
|
32
|
-
// percent signs) needs no inline filtergraph escaping.
|
|
37
|
+
const font = resolveTextFont(args.text, { weight: args.bold === false ? "regular" : "bold", fontFile: args.fontFile });
|
|
33
38
|
const textFile = tempPath(".txt");
|
|
34
39
|
writeFileSync(textFile, args.text);
|
|
35
40
|
try {
|
|
36
|
-
const ffArgs = buildTitleCardArgs(textFile, fontFile, output, {
|
|
41
|
+
const ffArgs = buildTitleCardArgs(textFile, font.fontFile, output, {
|
|
37
42
|
duration: args.duration,
|
|
38
43
|
width: args.width,
|
|
39
44
|
height: args.height,
|
|
@@ -47,11 +52,14 @@ export function register(server) {
|
|
|
47
52
|
finally {
|
|
48
53
|
rmSync(textFile, { force: true });
|
|
49
54
|
}
|
|
50
|
-
return okResponse({
|
|
55
|
+
return okResponse({
|
|
56
|
+
outputPath: output,
|
|
57
|
+
...((font.fallback || args.fontFile) && { fontFile: font.fontFile }),
|
|
58
|
+
...(font.warning && { warnings: [font.warning] }),
|
|
59
|
+
});
|
|
51
60
|
}
|
|
52
61
|
catch (error) {
|
|
53
62
|
return errorResponse(error);
|
|
54
63
|
}
|
|
55
64
|
});
|
|
56
65
|
}
|
|
57
|
-
//# sourceMappingURL=titleCard.js.map
|
package/dist/tools/transcribe.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
import { existsSync, readFileSync, rmSync, writeFileSync } from "node:fs";
|
|
3
3
|
import { errorResponse, okResponse, ScreencastError } from "../utils/errors.js";
|
|
4
|
+
import { WRITES_FILE, looseOutput } from "../utils/toolSpec.js";
|
|
4
5
|
import { requireFfmpeg, runFfmpeg, probeMedia, hasFilter } from "../utils/ffmpeg.js";
|
|
5
6
|
import { jobTimeoutMs } from "../utils/jobs.js";
|
|
6
7
|
import { resolveWhisperModel, buildTranscribeArgs, parseSrt, normalizeCues, formatSrt, WHISPER_MODEL_ENV, } from "../utils/captions.js";
|
|
@@ -16,9 +17,15 @@ const inputSchema = {
|
|
|
16
17
|
overwrite: z.boolean().optional().describe("Allow replacing an existing file at the output path (default false)."),
|
|
17
18
|
};
|
|
18
19
|
export function register(server) {
|
|
19
|
-
server.
|
|
20
|
-
"
|
|
21
|
-
"
|
|
20
|
+
server.registerTool("transcribe", {
|
|
21
|
+
title: "Transcribe Speech",
|
|
22
|
+
description: "Transcribe a recording's speech to an SRT subtitle file, locally, with FFmpeg 8's " +
|
|
23
|
+
"whisper filter (needs a whisper.cpp model file). Returns the SRT path and the text. " +
|
|
24
|
+
"Pair with burn_subtitles to caption the video.",
|
|
25
|
+
inputSchema,
|
|
26
|
+
outputSchema: looseOutput({ srtPath: z.string(), cues: z.number().int(), text: z.string() }),
|
|
27
|
+
annotations: WRITES_FILE,
|
|
28
|
+
}, async (args, extra) => {
|
|
22
29
|
try {
|
|
23
30
|
requireFfmpeg();
|
|
24
31
|
if (!existsSync(args.input))
|
|
@@ -32,11 +39,11 @@ export function register(server) {
|
|
|
32
39
|
if (!info.audioCodec)
|
|
33
40
|
throw new ScreencastError(`Input has no audio to transcribe: ${args.input}`);
|
|
34
41
|
const output = resolveOutput(args.output, subdir("edits"), `captions-${stamp()}-${rand()}.srt`, args.overwrite);
|
|
35
|
-
// whisper writes (appends) to its destination; use a fresh temp file,
|
|
36
|
-
// then tidy it into the output.
|
|
37
42
|
const raw = tempPath(".srt");
|
|
38
43
|
try {
|
|
39
|
-
await runFfmpeg(buildTranscribeArgs(args.input, model, raw, args.language ?? "auto"), jobTimeoutMs(info.durationSec)
|
|
44
|
+
await runFfmpeg(buildTranscribeArgs(args.input, model, raw, args.language ?? "auto"), jobTimeoutMs(info.durationSec), {
|
|
45
|
+
signal: extra.signal,
|
|
46
|
+
});
|
|
40
47
|
const cues = existsSync(raw) ? normalizeCues(parseSrt(readFileSync(raw, "utf8"))) : [];
|
|
41
48
|
writeFileSync(output, formatSrt(cues));
|
|
42
49
|
const text = cues.map((c) => c.text.replace(/\n/g, " ")).join(" ");
|
|
@@ -56,4 +63,3 @@ export function register(server) {
|
|
|
56
63
|
}
|
|
57
64
|
});
|
|
58
65
|
}
|
|
59
|
-
//# sourceMappingURL=transcribe.js.map
|
package/dist/tools/trim.js
CHANGED
|
@@ -2,6 +2,7 @@ import { z } from "zod";
|
|
|
2
2
|
import { extname } from "node:path";
|
|
3
3
|
import { existsSync } from "node:fs";
|
|
4
4
|
import { errorResponse, okResponse, ScreencastError } from "../utils/errors.js";
|
|
5
|
+
import { OUTPUT_PATH, WRITES_FILE } from "../utils/toolSpec.js";
|
|
5
6
|
import { requireFfmpeg } from "../utils/ffmpeg.js";
|
|
6
7
|
import { runEditJob, probeDuration } from "../utils/jobs.js";
|
|
7
8
|
import { buildTrimArgs, editOutputExt, assertEditContainer } from "../utils/media.js";
|
|
@@ -14,23 +15,25 @@ const inputSchema = {
|
|
|
14
15
|
exact: z
|
|
15
16
|
.boolean()
|
|
16
17
|
.optional()
|
|
17
|
-
.describe("Re-encode
|
|
18
|
-
"
|
|
19
|
-
"still ship in the file, hidden only by an edit list. Never use false to remove sensitive content."),
|
|
18
|
+
.describe("Re-encode for a frame-exact cut with the removed content really gone (default true). false = fast " +
|
|
19
|
+
"stream copy that snaps to a keyframe and keeps hidden earlier frames; never use it to remove secrets."),
|
|
20
20
|
output: z.string().optional().describe("Optional output path. Defaults under SCREENCAST_HOME/edits."),
|
|
21
21
|
overwrite: z.boolean().optional().describe("Allow replacing an existing file at the output path (default false)."),
|
|
22
22
|
};
|
|
23
23
|
export function register(server) {
|
|
24
|
-
server.
|
|
25
|
-
|
|
26
|
-
"
|
|
24
|
+
server.registerTool("trim", {
|
|
25
|
+
title: "Trim Video",
|
|
26
|
+
description: "Cut a video down to one sub-clip by start + (end or duration). For several segments use clip; " +
|
|
27
|
+
"to combine with other edits use pipeline.",
|
|
28
|
+
inputSchema,
|
|
29
|
+
outputSchema: OUTPUT_PATH,
|
|
30
|
+
annotations: WRITES_FILE,
|
|
31
|
+
}, async (args, extra) => {
|
|
27
32
|
try {
|
|
28
33
|
requireFfmpeg();
|
|
29
34
|
if (!existsSync(args.input)) {
|
|
30
35
|
throw new ScreencastError(`Input file not found: ${args.input}`);
|
|
31
36
|
}
|
|
32
|
-
// A stream copy keeps the input's container; a re-encode needs one that
|
|
33
|
-
// holds libx264/AAC.
|
|
34
37
|
if (args.exact !== false)
|
|
35
38
|
assertEditContainer(args.output);
|
|
36
39
|
const ext = args.exact === false ? extname(args.input) || ".mp4" : editOutputExt(args.input);
|
|
@@ -41,7 +44,6 @@ export function register(server) {
|
|
|
41
44
|
duration: args.duration,
|
|
42
45
|
exact: args.exact,
|
|
43
46
|
});
|
|
44
|
-
// Length of the trimmed clip, which sizes the job's timeout and progress.
|
|
45
47
|
const start = args.start ?? 0;
|
|
46
48
|
const end = args.end ?? (await probeDuration(args.input));
|
|
47
49
|
const durationSec = args.duration ?? (end !== null ? end - start : null);
|
|
@@ -53,4 +55,3 @@ export function register(server) {
|
|
|
53
55
|
}
|
|
54
56
|
});
|
|
55
57
|
}
|
|
56
|
-
//# sourceMappingURL=trim.js.map
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
import { errorResponse, okResponse } from "../utils/errors.js";
|
|
3
|
+
import { READ_ONLY, looseOutput } from "../utils/toolSpec.js";
|
|
3
4
|
import { requireFfmpeg, runFfmpeg, runFfmpegBuffer } from "../utils/ffmpeg.js";
|
|
4
5
|
import { resolveCaptureTarget } from "../utils/resolveTarget.js";
|
|
5
6
|
import { buildScreenshotArgs } from "../utils/targets.js";
|
|
6
7
|
import { detectionSize, targetSize, diffFrames, buildRawGrabArgs, SettleTracker, targetDiffOptions, DEFAULT_PIXEL_THRESHOLD, } from "../utils/diff.js";
|
|
7
8
|
import { windowMatchReport } from "../utils/windows.js";
|
|
9
|
+
import { confirmCapture, describeTarget } from "../utils/consent.js";
|
|
8
10
|
import { subdir, stamp, rand } from "../utils/paths.js";
|
|
9
11
|
import { join } from "node:path";
|
|
10
12
|
import { rmSync } from "node:fs";
|
|
@@ -13,66 +15,73 @@ import { encodeInlineImages, DEFAULT_MAX_IMAGE_WIDTH } from "../utils/images.js"
|
|
|
13
15
|
const inputSchema = {
|
|
14
16
|
target: z
|
|
15
17
|
.string()
|
|
16
|
-
.describe("What to watch:
|
|
17
|
-
exactTitle: z.boolean().optional().describe("
|
|
18
|
+
.describe("What to watch: full | monitor:<i> | window:<title> (or exe=/hwnd=) | region:<x>,<y>,<w>,<h>."),
|
|
19
|
+
exactTitle: z.boolean().optional().describe("window: targets match the whole title only (default false)."),
|
|
18
20
|
mode: z
|
|
19
21
|
.enum(["change", "settle"])
|
|
20
22
|
.optional()
|
|
21
|
-
.describe("
|
|
22
|
-
"(a dialog opened, a page responded). 'settle' returns once the target has stopped " +
|
|
23
|
-
"changing for settleSec (a build finished, a page finished loading)."),
|
|
23
|
+
.describe("change (default): return once it differs from the start. settle: once it has been still for settleSec."),
|
|
24
24
|
timeoutSec: z
|
|
25
25
|
.number()
|
|
26
26
|
.positive()
|
|
27
27
|
.max(600)
|
|
28
28
|
.optional()
|
|
29
|
-
.describe("Give up after this many seconds (default 30
|
|
29
|
+
.describe("Give up after this many seconds (default 30; a timeout is a result, not an error)."),
|
|
30
30
|
settleSec: z
|
|
31
31
|
.number()
|
|
32
32
|
.positive()
|
|
33
33
|
.max(60)
|
|
34
34
|
.optional()
|
|
35
|
-
.describe("Mode
|
|
35
|
+
.describe("Mode settle: seconds of stillness (default 1)."),
|
|
36
36
|
intervalMs: z
|
|
37
37
|
.number()
|
|
38
38
|
.int()
|
|
39
39
|
.min(100)
|
|
40
40
|
.max(5000)
|
|
41
41
|
.optional()
|
|
42
|
-
.describe("Pause between checks in ms (default 250)
|
|
42
|
+
.describe("Pause between checks in ms (default 250)."),
|
|
43
43
|
pixelThreshold: z
|
|
44
44
|
.number()
|
|
45
45
|
.min(0)
|
|
46
46
|
.max(255)
|
|
47
47
|
.optional()
|
|
48
|
-
.describe(`
|
|
49
|
-
`(default ${DEFAULT_PIXEL_THRESHOLD}: catches a changed label or a toast).`),
|
|
48
|
+
.describe(`Mean 0-255 difference for a ~32x32 cell to count as changed (default ${DEFAULT_PIXEL_THRESHOLD}).`),
|
|
50
49
|
returnImage: z
|
|
51
50
|
.boolean()
|
|
52
51
|
.optional()
|
|
53
|
-
.describe("
|
|
52
|
+
.describe("Return the final state inline (default true)."),
|
|
54
53
|
keep: z
|
|
55
54
|
.boolean()
|
|
56
55
|
.optional()
|
|
57
|
-
.describe("Keep the final screenshot on disk and return its path (default false
|
|
56
|
+
.describe("Keep the final screenshot on disk and return its path (default false)."),
|
|
58
57
|
};
|
|
59
58
|
const sleep = (ms) => new Promise((r) => setTimeout(r, ms));
|
|
60
59
|
export function register(server) {
|
|
61
|
-
server.
|
|
62
|
-
"
|
|
63
|
-
"
|
|
64
|
-
|
|
60
|
+
server.registerTool("wait_for_change", {
|
|
61
|
+
title: "Wait for Screen Change",
|
|
62
|
+
description: "Wait until part of the screen changes or settles, instead of guessing a sleep. Returns the " +
|
|
63
|
+
"elapsed time, changed regions (screenshot pixels; add `origin` for desktop), and the final state.",
|
|
64
|
+
inputSchema,
|
|
65
|
+
outputSchema: looseOutput({
|
|
66
|
+
outcome: z.string(),
|
|
67
|
+
mode: z.string(),
|
|
68
|
+
elapsedSec: z.number(),
|
|
69
|
+
regions: z.array(z.unknown()),
|
|
70
|
+
origin: looseOutput({ x: z.number(), y: z.number() }),
|
|
71
|
+
}),
|
|
72
|
+
annotations: READ_ONLY,
|
|
73
|
+
}, async (args, extra) => {
|
|
65
74
|
try {
|
|
66
75
|
requireFfmpeg();
|
|
67
76
|
const mode = args.mode ?? "change";
|
|
68
77
|
const timeoutMs = (args.timeoutSec ?? 30) * 1000;
|
|
69
78
|
const settleMs = (args.settleSec ?? 1) * 1000;
|
|
70
79
|
const interval = args.intervalMs ?? 250;
|
|
71
|
-
// The target (and a window's rectangle) is resolved once, up front.
|
|
72
80
|
const { target, monitors, window } = await resolveCaptureTarget(args.target, { exactTitle: args.exactTitle });
|
|
81
|
+
await confirmCapture(server, `Watch ${describeTarget(args.target, window)} for up to ${timeoutMs / 1000} s, until it ${mode === "settle" ? "stops changing" : "changes"}?`, extra.signal);
|
|
73
82
|
const area = targetSize(target, monitors);
|
|
74
83
|
const size = detectionSize(area.width, area.height);
|
|
75
|
-
const grab = () => runFfmpegBuffer(buildRawGrabArgs(target, monitors, size), 15_000);
|
|
84
|
+
const grab = () => runFfmpegBuffer(buildRawGrabArgs(target, monitors, size), 15_000, { signal: extra.signal });
|
|
76
85
|
const opts = targetDiffOptions(area, size, args.pixelThreshold);
|
|
77
86
|
const started = Date.now();
|
|
78
87
|
const baseline = await grab();
|
|
@@ -87,7 +96,15 @@ export function register(server) {
|
|
|
87
96
|
break;
|
|
88
97
|
}
|
|
89
98
|
await sleep(interval);
|
|
90
|
-
const current = await grab()
|
|
99
|
+
const current = await grab().catch((error) => {
|
|
100
|
+
if (extra.signal.aborted)
|
|
101
|
+
return null;
|
|
102
|
+
throw error;
|
|
103
|
+
});
|
|
104
|
+
if (!current) {
|
|
105
|
+
outcome = "cancelled";
|
|
106
|
+
break;
|
|
107
|
+
}
|
|
91
108
|
if (mode === "change") {
|
|
92
109
|
const d = diffFrames(baseline, current, size.width, size.height, opts);
|
|
93
110
|
if (d.regions.length > 0) {
|
|
@@ -120,12 +137,11 @@ export function register(server) {
|
|
|
120
137
|
};
|
|
121
138
|
const images = [];
|
|
122
139
|
if (args.returnImage !== false && outcome !== "cancelled") {
|
|
123
|
-
// Not kept by default, so screenshots do not pile up on disk (#209).
|
|
124
140
|
const shot = args.keep
|
|
125
141
|
? join(subdir("screenshots"), `wait-${stamp()}-${rand()}.png`)
|
|
126
142
|
: join(tmpdir(), `screencast-wait-${stamp()}-${rand()}.png`);
|
|
127
143
|
try {
|
|
128
|
-
await runFfmpeg(buildScreenshotArgs(target, shot, monitors), 60_000);
|
|
144
|
+
await runFfmpeg(buildScreenshotArgs(target, shot, monitors), 60_000, { signal: extra.signal });
|
|
129
145
|
if (args.keep)
|
|
130
146
|
result.screenshotPath = shot;
|
|
131
147
|
images.push(...(await encodeInlineImages([shot], DEFAULT_MAX_IMAGE_WIDTH, 1)).images);
|
|
@@ -142,4 +158,3 @@ export function register(server) {
|
|
|
142
158
|
}
|
|
143
159
|
});
|
|
144
160
|
}
|
|
145
|
-
//# sourceMappingURL=waitForChange.js.map
|
|
@@ -1,17 +1,18 @@
|
|
|
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 { buildXfadeArgs, clipLength, DEFAULT_TRANSITION_DUR } from "../utils/produce.js";
|
|
7
8
|
import { resolveOutput, subdir, stamp, rand } from "../utils/paths.js";
|
|
8
9
|
const inputSchema = {
|
|
9
|
-
inputA: z.string().min(1).describe("
|
|
10
|
-
inputB: z.string().min(1).describe("
|
|
10
|
+
inputA: z.string().min(1).describe("Outgoing video."),
|
|
11
|
+
inputB: z.string().min(1).describe("Incoming video."),
|
|
11
12
|
transition: z
|
|
12
13
|
.string()
|
|
13
14
|
.optional()
|
|
14
|
-
.describe("xfade
|
|
15
|
+
.describe("xfade name (default fade): fade, wipeleft, slideup, circleopen, dissolve, ..."),
|
|
15
16
|
duration: z
|
|
16
17
|
.number()
|
|
17
18
|
.positive()
|
|
@@ -21,10 +22,14 @@ const inputSchema = {
|
|
|
21
22
|
overwrite: z.boolean().optional().describe("Allow replacing an existing file at the output path (default false)."),
|
|
22
23
|
};
|
|
23
24
|
export function register(server) {
|
|
24
|
-
server.
|
|
25
|
-
"
|
|
26
|
-
"
|
|
27
|
-
|
|
25
|
+
server.registerTool("xfade_transition", {
|
|
26
|
+
title: "Crossfade Transition",
|
|
27
|
+
description: "Join two videos with an xfade transition (audio crossfaded); they need not match in size, " +
|
|
28
|
+
"fps, or audio. For more clips use assemble_highlights.",
|
|
29
|
+
inputSchema,
|
|
30
|
+
outputSchema: OUTPUT_PATH,
|
|
31
|
+
annotations: WRITES_FILE,
|
|
32
|
+
}, async (args, extra) => {
|
|
28
33
|
try {
|
|
29
34
|
requireFfmpeg();
|
|
30
35
|
for (const f of [args.inputA, args.inputB]) {
|
|
@@ -49,4 +54,3 @@ export function register(server) {
|
|
|
49
54
|
}
|
|
50
55
|
});
|
|
51
56
|
}
|
|
52
|
-
//# sourceMappingURL=xfadeTransition.js.map
|