@tmhs/screencast-mcp 0.39.0 → 0.45.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 +95 -17
- package/assets/icon.png +0 -0
- package/assets/ui/player.html +47 -302
- package/assets/ui/player.js +402 -0
- package/dist/context.js +0 -5
- package/dist/index.js +17 -21
- package/dist/prompts.js +18 -8
- package/dist/resources.js +2 -14
- package/dist/server.js +49 -11
- package/dist/tools/addMarker.js +89 -0
- package/dist/tools/assembleHighlights.js +12 -7
- package/dist/tools/backdrop.js +89 -0
- package/dist/tools/bugReport.js +266 -0
- package/dist/tools/burnSubtitles.js +12 -6
- package/dist/tools/callout.js +32 -16
- package/dist/tools/chapters.js +156 -0
- 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 +39 -33
- 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 +52 -98
- package/dist/tools/getMediaInfo.js +17 -3
- package/dist/tools/getSession.js +15 -3
- package/dist/tools/keystrokeOverlay.js +131 -0
- 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 +86 -25
- 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 +75 -22
- package/dist/tools/sampleFrames.js +33 -40
- package/dist/tools/saveReplay.js +90 -0
- 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 +96 -59
- package/dist/tools/stopRecording.js +35 -10
- 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/backdrop.js +151 -0
- package/dist/utils/bugReport.js +246 -0
- 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/chapters.js +222 -0
- 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/keystrokes.js +170 -0
- package/dist/utils/lifecycle.js +11 -31
- package/dist/utils/logging.js +75 -0
- package/dist/utils/media.js +16 -124
- package/dist/utils/monitors.js +7 -43
- package/dist/utils/ocr.js +53 -71
- package/dist/utils/ocrScan.js +77 -0
- package/dist/utils/paths.js +68 -31
- package/dist/utils/pipeline.js +39 -25
- package/dist/utils/player.js +50 -27
- package/dist/utils/produce.js +6 -66
- package/dist/utils/replay.js +278 -0
- 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 +122 -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
package/dist/tools/findText.js
CHANGED
|
@@ -1,103 +1,78 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
import { extname, join } from "node:path";
|
|
3
|
-
import { existsSync, mkdtempSync,
|
|
3
|
+
import { existsSync, mkdtempSync, rmSync } from "node:fs";
|
|
4
4
|
import { tmpdir } from "node:os";
|
|
5
5
|
import { errorResponse, okResponse, ScreencastError } from "../utils/errors.js";
|
|
6
|
-
import {
|
|
6
|
+
import { READ_ONLY, looseOutput } from "../utils/toolSpec.js";
|
|
7
|
+
import { requireFfmpeg, runFfmpeg } from "../utils/ffmpeg.js";
|
|
7
8
|
import { resolveCaptureTarget } from "../utils/resolveTarget.js";
|
|
8
9
|
import { captureStill } from "../utils/still.js";
|
|
9
10
|
import { buildHighlightArgs, targetSize } from "../utils/diff.js";
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
11
|
+
import { findMatches, redactionRects } from "../utils/ocr.js";
|
|
12
|
+
import { readFrames, scanVideoFrames, scanMatches } from "../utils/ocrScan.js";
|
|
12
13
|
import { windowMatchReport } from "../utils/windows.js";
|
|
14
|
+
import { confirmCapture, describeTarget } from "../utils/consent.js";
|
|
13
15
|
import { subdir, stamp, rand, stillOutput } from "../utils/paths.js";
|
|
14
16
|
import { encodeInlineImages, DEFAULT_MAX_IMAGE_WIDTH } from "../utils/images.js";
|
|
15
17
|
const IMAGE_EXTENSIONS = new Set([".png", ".jpg", ".jpeg", ".bmp", ".gif", ".webp", ".tif", ".tiff"]);
|
|
16
18
|
const MAX_LINES = 300;
|
|
17
|
-
/** Default and largest frame count for a whole-clip scan (#204). */
|
|
18
19
|
export const DEFAULT_SCAN_FRAMES = 30;
|
|
19
20
|
export const MAX_SCAN_FRAMES = 120;
|
|
20
21
|
const inputSchema = {
|
|
21
22
|
target: z
|
|
22
23
|
.string()
|
|
23
24
|
.optional()
|
|
24
|
-
.describe("
|
|
25
|
-
input: z.string().optional().describe("
|
|
26
|
-
timestamp: z.number().nonnegative().optional().describe("
|
|
25
|
+
.describe("Live screen target (full | monitor:<i> | window:... | region:...), or pass input."),
|
|
26
|
+
input: z.string().optional().describe("Image or video file to read instead of a live target."),
|
|
27
|
+
timestamp: z.number().nonnegative().optional().describe("Video input: second to read (default 0)."),
|
|
27
28
|
scanEverySec: z
|
|
28
29
|
.number()
|
|
29
30
|
.positive()
|
|
30
31
|
.optional()
|
|
31
|
-
.describe("
|
|
32
|
-
"
|
|
33
|
-
"gets its time, and redactRegions get start/end. The interval widens to stay within maxFrames."),
|
|
32
|
+
.describe("Video input: scan a frame every N s across the clip (e.g. for secrets before sharing); matches " +
|
|
33
|
+
"and redactRegions get times. Widens to stay within maxFrames."),
|
|
34
34
|
maxFrames: z
|
|
35
35
|
.number()
|
|
36
36
|
.int()
|
|
37
37
|
.min(1)
|
|
38
38
|
.max(MAX_SCAN_FRAMES)
|
|
39
39
|
.optional()
|
|
40
|
-
.describe(`
|
|
41
|
-
exactTitle: z.boolean().optional().describe("
|
|
40
|
+
.describe(`scanEverySec frame cap (default ${DEFAULT_SCAN_FRAMES}; ~1 s each).`),
|
|
41
|
+
exactTitle: z.boolean().optional().describe("window: targets match the whole title only (default false)."),
|
|
42
42
|
backend: z
|
|
43
43
|
.enum(["gdigrab", "wgc"])
|
|
44
44
|
.optional()
|
|
45
|
-
.describe("
|
|
46
|
-
"reads the window's own surface even when other windows cover it."),
|
|
45
|
+
.describe("Live target: gdigrab (default) = what is visible; wgc (window:, FFmpeg 8+) = the window even if covered."),
|
|
47
46
|
query: z
|
|
48
47
|
.string()
|
|
49
48
|
.optional()
|
|
50
|
-
.describe("Text to
|
|
51
|
-
"O vs 0; regexes get the _ vs - tolerance). Without a query, all recognised text is returned."),
|
|
49
|
+
.describe("Text to find (case-insensitive, tolerates OCR misreads like I/l, O/0, _/-). Omit to return all text."),
|
|
52
50
|
regex: z.boolean().optional().describe("Treat query as a regular expression (case-insensitive)."),
|
|
53
51
|
redact: z
|
|
54
52
|
.boolean()
|
|
55
53
|
.optional()
|
|
56
|
-
.describe("Also return padded rectangles
|
|
57
|
-
"(regions) to cover them. Detection is best-effort: review the result."),
|
|
54
|
+
.describe("Also return padded match rectangles ready for redact_region's regions."),
|
|
58
55
|
keep: z
|
|
59
56
|
.boolean()
|
|
60
57
|
.optional()
|
|
61
|
-
.describe("
|
|
62
|
-
"deleted after reading, since it may show the secrets being looked for)."),
|
|
58
|
+
.describe("Live target: keep the capture and return its path (default false: deleted after reading)."),
|
|
63
59
|
returnImage: z
|
|
64
60
|
.boolean()
|
|
65
61
|
.optional()
|
|
66
|
-
.describe("Return the image
|
|
62
|
+
.describe("Return the image with matches outlined (default: true with a query)."),
|
|
67
63
|
};
|
|
68
|
-
/** OCR several frames in one PowerShell run: each frame is upscaled for every
|
|
69
|
-
* pass (passScales), and the passes are merged back per frame. */
|
|
70
|
-
async function readFrames(sources, work) {
|
|
71
|
-
const sized = await Promise.all(sources.map((s) => probeMedia(s)));
|
|
72
|
-
const passes = [];
|
|
73
|
-
const passScaleList = [];
|
|
74
|
-
const owner = [];
|
|
75
|
-
for (let f = 0; f < sources.length; f++) {
|
|
76
|
-
const { width, height } = sized[f];
|
|
77
|
-
if (!width || !height)
|
|
78
|
-
throw new ScreencastError("Could not read the image size.");
|
|
79
|
-
for (const [i, scale] of passScales(width, height).entries()) {
|
|
80
|
-
const out = join(work, `pass${f}-${i}.png`);
|
|
81
|
-
await runFfmpeg(["-y", "-v", "error", "-i", sources[f], "-vf", `scale=iw*${scale}:ih*${scale}:flags=lanczos`, out], 60_000);
|
|
82
|
-
passes.push(out);
|
|
83
|
-
passScaleList.push(scale);
|
|
84
|
-
owner.push(f);
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
const results = await recognize(passes, passScaleList);
|
|
88
|
-
return sources.map((_, f) => ({
|
|
89
|
-
lines: mergePasses(results.filter((_r, i) => owner[i] === f)),
|
|
90
|
-
width: sized[f].width,
|
|
91
|
-
height: sized[f].height,
|
|
92
|
-
}));
|
|
93
|
-
}
|
|
94
64
|
export function register(server) {
|
|
95
|
-
server.
|
|
96
|
-
"
|
|
97
|
-
"
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
65
|
+
server.registerTool("find_text", {
|
|
66
|
+
title: "Find Text (OCR)",
|
|
67
|
+
description: "OCR (built into Windows) on the screen, an image, or video frames, with line and match boxes " +
|
|
68
|
+
"in image pixels (add `origin` for desktop coordinates). Locate UI text or secrets (e.g. regex " +
|
|
69
|
+
"'sk-|ghp_|api.?key') to redact. Best-effort: review results.",
|
|
70
|
+
inputSchema,
|
|
71
|
+
outputSchema: looseOutput({
|
|
72
|
+
imageSize: looseOutput({ width: z.number(), height: z.number() }),
|
|
73
|
+
}),
|
|
74
|
+
annotations: READ_ONLY,
|
|
75
|
+
}, async (args, extra) => {
|
|
101
76
|
try {
|
|
102
77
|
requireFfmpeg();
|
|
103
78
|
if ((args.target === undefined) === (args.input === undefined)) {
|
|
@@ -106,21 +81,18 @@ export function register(server) {
|
|
|
106
81
|
const work = mkdtempSync(join(tmpdir(), "screencast-ocr-"));
|
|
107
82
|
try {
|
|
108
83
|
if (args.scanEverySec !== undefined)
|
|
109
|
-
return await scanClip(args, work);
|
|
110
|
-
// 1. Get the source as one PNG frame.
|
|
84
|
+
return await scanClip(args, work, extra.signal);
|
|
111
85
|
let source;
|
|
112
86
|
let windowReport = {};
|
|
113
87
|
let origin;
|
|
114
88
|
if (args.target !== undefined) {
|
|
115
89
|
const resolved = await resolveCaptureTarget(args.target, { exactTitle: args.exactTitle, backend: args.backend });
|
|
116
|
-
// Captures go to the work dir and vanish with it unless kept (#209).
|
|
117
90
|
source = args.keep ? join(subdir("screenshots"), `ocr-${stamp()}-${rand()}.png`) : join(work, "capture.png");
|
|
118
91
|
const backend = args.backend ?? "gdigrab";
|
|
92
|
+
await confirmCapture(server, `Capture ${describeTarget(args.target, resolved.window)} once to read the text on it?`, extra.signal);
|
|
119
93
|
await captureStill(resolved, source, backend);
|
|
120
94
|
if (resolved.window)
|
|
121
95
|
windowReport = windowMatchReport(resolved.window);
|
|
122
|
-
// Where the image sits on the desktop: boxes are image pixels (#233).
|
|
123
|
-
// A WGC still is the window's client area.
|
|
124
96
|
const area = targetSize(resolved.target, resolved.monitors);
|
|
125
97
|
origin = backend === "wgc" && resolved.window?.client ? resolved.window.client : { x: area.x, y: area.y };
|
|
126
98
|
}
|
|
@@ -129,17 +101,18 @@ export function register(server) {
|
|
|
129
101
|
throw new ScreencastError(`Input file not found: ${args.input}`);
|
|
130
102
|
const isImage = IMAGE_EXTENSIONS.has(extname(args.input).toLowerCase());
|
|
131
103
|
source = join(work, "frame.png");
|
|
132
|
-
await runFfmpeg(["-y", "-v", "error", ...(isImage ? [] : ["-ss", String(args.timestamp ?? 0)]), "-i", args.input, "-frames:v", "1", ...stillOutput(source)], 60_000);
|
|
104
|
+
await runFfmpeg(["-y", "-v", "error", ...(isImage ? [] : ["-ss", String(args.timestamp ?? 0)]), "-i", args.input, "-frames:v", "1", ...stillOutput(source)], 60_000, { signal: extra.signal });
|
|
133
105
|
}
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
106
|
+
const [frame] = await readFrames([source], work, extra.signal);
|
|
107
|
+
if (!frame)
|
|
108
|
+
throw new ScreencastError("Could not read the frame.");
|
|
109
|
+
const { lines, width, height } = frame;
|
|
137
110
|
const matches = args.query ? findMatches(lines, args.query, args.regex === true) : [];
|
|
138
111
|
const images = [];
|
|
139
112
|
const wantImage = args.returnImage ?? Boolean(args.query);
|
|
140
113
|
if (wantImage) {
|
|
141
114
|
const shown = join(work, "shown.png");
|
|
142
|
-
await runFfmpeg(buildHighlightArgs(source, matches, shown), 30_000);
|
|
115
|
+
await runFfmpeg(buildHighlightArgs(source, matches, shown), 30_000, { signal: extra.signal });
|
|
143
116
|
images.push(...(await encodeInlineImages([shown], DEFAULT_MAX_IMAGE_WIDTH, 1)).images);
|
|
144
117
|
}
|
|
145
118
|
return okResponse({
|
|
@@ -170,11 +143,7 @@ export function register(server) {
|
|
|
170
143
|
}
|
|
171
144
|
});
|
|
172
145
|
}
|
|
173
|
-
|
|
174
|
-
* fit maxFrames) and report each match with its time. A redaction window runs
|
|
175
|
-
* from the previous sample to the next, since the text may be on screen for
|
|
176
|
-
* any part of the time between two samples. */
|
|
177
|
-
async function scanClip(args, work) {
|
|
146
|
+
async function scanClip(args, work, signal) {
|
|
178
147
|
if (args.input === undefined)
|
|
179
148
|
throw new ScreencastError("scanEverySec reads a video file: pass input, not target.");
|
|
180
149
|
if (!existsSync(args.input))
|
|
@@ -182,49 +151,35 @@ async function scanClip(args, work) {
|
|
|
182
151
|
if (IMAGE_EXTENSIONS.has(extname(args.input).toLowerCase())) {
|
|
183
152
|
throw new ScreencastError("scanEverySec is for a video input; an image has one frame, so drop scanEverySec.");
|
|
184
153
|
}
|
|
185
|
-
const info = await probeMedia(args.input);
|
|
186
154
|
const maxFrames = args.maxFrames ?? DEFAULT_SCAN_FRAMES;
|
|
187
|
-
const
|
|
188
|
-
|
|
189
|
-
const
|
|
190
|
-
if (
|
|
155
|
+
const scan = await scanVideoFrames(args.input, { everySec: args.scanEverySec, maxFrames }, work, signal);
|
|
156
|
+
const { step } = scan;
|
|
157
|
+
const [size] = scan.frames;
|
|
158
|
+
if (!size)
|
|
191
159
|
throw new ScreencastError("Could not read any frames from the video.");
|
|
192
|
-
const step = 1 / plan.fps;
|
|
193
|
-
const times = frames.map((_, i) => Math.round(i * step * 1000) / 1000);
|
|
194
|
-
const end = info.videoDurationSec ?? info.durationSec ?? times[times.length - 1] + step;
|
|
195
|
-
const read = await readFrames(frames, work);
|
|
196
|
-
const matches = [];
|
|
197
|
-
const redactRegions = [];
|
|
198
160
|
const seenLines = new Set();
|
|
199
|
-
|
|
161
|
+
for (const frame of scan.frames)
|
|
200
162
|
for (const l of frame.lines)
|
|
201
163
|
seenLines.add(l.text);
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
const start = Math.max(0, Math.round((times[i] - step) * 1000) / 1000);
|
|
206
|
-
const stop = Math.min(end, Math.round((times[i] + step) * 1000) / 1000);
|
|
207
|
-
for (const [k, rect] of redactionRects(hits, frame).entries()) {
|
|
208
|
-
matches.push({ t: times[i], ...hits[k] });
|
|
209
|
-
redactRegions.push({ ...rect, start, end: stop });
|
|
210
|
-
}
|
|
211
|
-
});
|
|
164
|
+
const { matches, redactRegions } = args.query
|
|
165
|
+
? scanMatches(scan, args.query, args.regex === true)
|
|
166
|
+
: { matches: [], redactRegions: [] };
|
|
212
167
|
const images = [];
|
|
213
168
|
const first = matches[0];
|
|
214
|
-
|
|
215
|
-
|
|
169
|
+
const firstFrame = first && scan.frames.find((f) => f.t === first.t)?.path;
|
|
170
|
+
if ((args.returnImage ?? Boolean(args.query)) && first && firstFrame) {
|
|
216
171
|
const shown = join(work, "shown.png");
|
|
217
|
-
await runFfmpeg(buildHighlightArgs(
|
|
172
|
+
await runFfmpeg(buildHighlightArgs(firstFrame, matches.filter((m) => m.t === first.t), shown), 30_000, { signal });
|
|
218
173
|
images.push(...(await encodeInlineImages([shown], DEFAULT_MAX_IMAGE_WIDTH, 1)).images);
|
|
219
174
|
}
|
|
220
175
|
const text = [...seenLines].join("\n");
|
|
221
176
|
return okResponse({
|
|
222
177
|
input: args.input,
|
|
223
|
-
imageSize: { width:
|
|
178
|
+
imageSize: { width: size.width, height: size.height },
|
|
224
179
|
scan: {
|
|
225
180
|
everySec: Math.round(step * 1000) / 1000,
|
|
226
|
-
framesScanned: frames.length,
|
|
227
|
-
...(
|
|
181
|
+
framesScanned: scan.frames.length,
|
|
182
|
+
...(scan.clamped ? { note: `Widened from ${args.scanEverySec} s to fit maxFrames ${maxFrames}.` } : {}),
|
|
228
183
|
},
|
|
229
184
|
...(args.query
|
|
230
185
|
? {
|
|
@@ -239,4 +194,3 @@ async function scanClip(args, work) {
|
|
|
239
194
|
"or stylised text, can be missed. Review before sharing, especially for redaction.",
|
|
240
195
|
}, images);
|
|
241
196
|
}
|
|
242
|
-
//# sourceMappingURL=findText.js.map
|
|
@@ -1,13 +1,28 @@
|
|
|
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 { READ_ONLY, looseOutput } from "../utils/toolSpec.js";
|
|
4
5
|
import { probeMedia } from "../utils/ffmpeg.js";
|
|
5
6
|
const inputSchema = {
|
|
6
7
|
input: z.string().min(1).describe("Path to the media file to probe."),
|
|
7
8
|
};
|
|
8
9
|
export function register(server) {
|
|
9
|
-
server.
|
|
10
|
-
"
|
|
10
|
+
server.registerTool("get_media_info", {
|
|
11
|
+
title: "Get Media Info",
|
|
12
|
+
description: "Probe a media file with ffprobe and return duration, resolution, frame " +
|
|
13
|
+
"rate, codecs, container format, and size.",
|
|
14
|
+
inputSchema,
|
|
15
|
+
outputSchema: looseOutput({
|
|
16
|
+
input: z.string(),
|
|
17
|
+
durationSec: z.number().nullable(),
|
|
18
|
+
width: z.number().nullable(),
|
|
19
|
+
height: z.number().nullable(),
|
|
20
|
+
fps: z.number().nullable(),
|
|
21
|
+
videoCodec: z.string().nullable(),
|
|
22
|
+
audioCodec: z.string().nullable(),
|
|
23
|
+
}),
|
|
24
|
+
annotations: READ_ONLY,
|
|
25
|
+
}, async (args) => {
|
|
11
26
|
try {
|
|
12
27
|
if (!existsSync(args.input)) {
|
|
13
28
|
throw new ScreencastError(`Input file not found: ${args.input}`);
|
|
@@ -19,4 +34,3 @@ export function register(server) {
|
|
|
19
34
|
}
|
|
20
35
|
});
|
|
21
36
|
}
|
|
22
|
-
//# sourceMappingURL=getMediaInfo.js.map
|
package/dist/tools/getSession.js
CHANGED
|
@@ -1,14 +1,27 @@
|
|
|
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 { READ_ONLY, looseOutput } from "../utils/toolSpec.js";
|
|
4
5
|
import { isAlive } from "../utils/sessions.js";
|
|
5
6
|
import { getStore } from "../context.js";
|
|
6
7
|
const inputSchema = {
|
|
7
8
|
sessionId: z.string().min(1).describe("Session id returned by start_recording."),
|
|
8
9
|
};
|
|
9
10
|
export function register(server) {
|
|
10
|
-
server.
|
|
11
|
-
"
|
|
11
|
+
server.registerTool("get_session", {
|
|
12
|
+
title: "Get Session",
|
|
13
|
+
description: "Inspect a single recording session by id, including live status and " +
|
|
14
|
+
"whether its output file exists on disk.",
|
|
15
|
+
inputSchema,
|
|
16
|
+
outputSchema: looseOutput({
|
|
17
|
+
id: z.string(),
|
|
18
|
+
status: z.string(),
|
|
19
|
+
outputPath: z.string(),
|
|
20
|
+
alive: z.boolean(),
|
|
21
|
+
fileExists: z.boolean(),
|
|
22
|
+
}),
|
|
23
|
+
annotations: READ_ONLY,
|
|
24
|
+
}, async (args) => {
|
|
12
25
|
try {
|
|
13
26
|
const record = getStore().get(args.sessionId);
|
|
14
27
|
if (!record) {
|
|
@@ -25,4 +38,3 @@ export function register(server) {
|
|
|
25
38
|
}
|
|
26
39
|
});
|
|
27
40
|
}
|
|
28
|
-
//# sourceMappingURL=getSession.js.map
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { join } from "node:path";
|
|
3
|
+
import { existsSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from "node:fs";
|
|
4
|
+
import { tmpdir } from "node:os";
|
|
5
|
+
import { errorResponse, okResponse, ScreencastError } from "../utils/errors.js";
|
|
6
|
+
import { WRITES_FILE, looseOutput } from "../utils/toolSpec.js";
|
|
7
|
+
import { requireFfmpeg, probeMedia } from "../utils/ffmpeg.js";
|
|
8
|
+
import { runEditJob } from "../utils/jobs.js";
|
|
9
|
+
import { eventPaths, parseEventsJsonl } from "../utils/events.js";
|
|
10
|
+
import { resolveTextFont } from "../utils/fonts.js";
|
|
11
|
+
import { planBadges, groupBadges, buildKeystrokeArgs, BADGE_POSITIONS, DEFAULT_LINGER_SEC, } from "../utils/keystrokes.js";
|
|
12
|
+
import { editOutputExt, assertEditContainer } from "../utils/media.js";
|
|
13
|
+
import { resolveOutput, subdir, stamp, rand } from "../utils/paths.js";
|
|
14
|
+
import { fontFileSchema } from "./callout.js";
|
|
15
|
+
export const keystrokeOptionsSchema = {
|
|
16
|
+
events: z.string().optional(),
|
|
17
|
+
clicks: z.boolean().optional(),
|
|
18
|
+
typing: z.boolean().optional(),
|
|
19
|
+
keys: z.enum(["shortcuts", "masked"]).optional(),
|
|
20
|
+
lingerSec: z.number().positive().max(10).optional(),
|
|
21
|
+
position: z.enum(BADGE_POSITIONS).optional(),
|
|
22
|
+
size: z.number().min(8).max(400).optional(),
|
|
23
|
+
color: z.string().optional(),
|
|
24
|
+
fontFile: z.string().min(1).optional(),
|
|
25
|
+
};
|
|
26
|
+
const o = keystrokeOptionsSchema;
|
|
27
|
+
export function loadBadges(input, events, opts) {
|
|
28
|
+
const path = events ?? eventPaths(input).jsonl;
|
|
29
|
+
if (!existsSync(path)) {
|
|
30
|
+
throw new ScreencastError(`No event log for ${input} (looked for ${path}). Record with start_recording events: true ` +
|
|
31
|
+
'(keys: "shortcuts" to name shortcuts), or pass events: <path to .events.jsonl>.');
|
|
32
|
+
}
|
|
33
|
+
const log = parseEventsJsonl(readFileSync(path, "utf8"));
|
|
34
|
+
return { badges: planBadges(log, opts), shortcutsLogged: log.filter((e) => e.type === "key").length, path };
|
|
35
|
+
}
|
|
36
|
+
export function prepareKeystrokeAssets(labels, workDir, tag = "", fontFile) {
|
|
37
|
+
const font = resolveTextFont(labels.join(" "), { weight: "bold", fontFile });
|
|
38
|
+
const textFiles = {};
|
|
39
|
+
labels.forEach((label, i) => {
|
|
40
|
+
if (workDir === null) {
|
|
41
|
+
textFiles[label] = `<badge ${i}>`;
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
const f = join(workDir, `${tag}badge_${i}.txt`);
|
|
45
|
+
writeFileSync(f, label);
|
|
46
|
+
textFiles[label] = f;
|
|
47
|
+
});
|
|
48
|
+
return {
|
|
49
|
+
fontFile: font.fontFile,
|
|
50
|
+
textFiles,
|
|
51
|
+
...(font.fallback && { fallbackFont: font.fontFile }),
|
|
52
|
+
warnings: font.warning ? [font.warning] : [],
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
const inputSchema = {
|
|
56
|
+
input: z.string().min(1).describe("Path to the recording."),
|
|
57
|
+
events: o.events.describe("Event log (default: the input's .events.jsonl)."),
|
|
58
|
+
clicks: o.clicks.describe("Show clicks (default true)."),
|
|
59
|
+
typing: o.typing.describe('Show typing as "Typing…" (default true).'),
|
|
60
|
+
keys: o.keys.describe("shortcuts (default): the chord (Ctrl + S); masked: modifiers only (Ctrl + …)."),
|
|
61
|
+
lingerSec: o.lingerSec.describe(`Seconds a badge stays up (default ${DEFAULT_LINGER_SEC}).`),
|
|
62
|
+
position: o.position.describe("Default bottom (centred)."),
|
|
63
|
+
size: o.size.describe("Font px (default 4.5% of the frame height)."),
|
|
64
|
+
color: o.color.describe("Text color (default white)."),
|
|
65
|
+
fontFile: fontFileSchema,
|
|
66
|
+
dryRun: z.boolean().optional().describe("Return the planned badges; write nothing."),
|
|
67
|
+
output: z.string().optional().describe("Optional output path. Defaults under SCREENCAST_HOME/edits."),
|
|
68
|
+
overwrite: z.boolean().optional().describe("Allow replacing an existing file at the output path (default false)."),
|
|
69
|
+
};
|
|
70
|
+
export function register(server) {
|
|
71
|
+
server.registerTool("keystroke_overlay", {
|
|
72
|
+
title: "Keystroke Overlay",
|
|
73
|
+
description: "Burn keycast-style badges for shortcuts, clicks, and typing from the recording's input event log " +
|
|
74
|
+
"(start_recording events: true). Never shows typed text: the log has none.",
|
|
75
|
+
inputSchema,
|
|
76
|
+
outputSchema: looseOutput({ badges: z.number().int() }),
|
|
77
|
+
annotations: WRITES_FILE,
|
|
78
|
+
}, async (args, extra) => {
|
|
79
|
+
try {
|
|
80
|
+
requireFfmpeg();
|
|
81
|
+
if (!existsSync(args.input))
|
|
82
|
+
throw new ScreencastError(`Input file not found: ${args.input}`);
|
|
83
|
+
const plan = { clicks: args.clicks, typing: args.typing, keys: args.keys, lingerSec: args.lingerSec };
|
|
84
|
+
const { badges, shortcutsLogged } = loadBadges(args.input, args.events, plan);
|
|
85
|
+
const note = shortcutsLogged === 0
|
|
86
|
+
? 'The log names no shortcuts (recorded with keys: "masked"), so only clicks and typing can show.'
|
|
87
|
+
: undefined;
|
|
88
|
+
if (badges.length === 0) {
|
|
89
|
+
return okResponse({ badges: 0, note: "Nothing to show: the log has no clicks, shortcuts, or typing; nothing written." });
|
|
90
|
+
}
|
|
91
|
+
const groups = groupBadges(badges);
|
|
92
|
+
if (args.dryRun) {
|
|
93
|
+
const assets = prepareKeystrokeAssets(groups.map((g) => g.label), null, "", args.fontFile);
|
|
94
|
+
return okResponse({
|
|
95
|
+
dryRun: true,
|
|
96
|
+
badges: badges.length,
|
|
97
|
+
plan: badges,
|
|
98
|
+
...(assets.fallbackFont && { fallbackFont: assets.fallbackFont }),
|
|
99
|
+
...(assets.warnings.length > 0 && { warnings: assets.warnings }),
|
|
100
|
+
...(note && { note }),
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
assertEditContainer(args.output);
|
|
104
|
+
const info = await probeMedia(args.input);
|
|
105
|
+
if (!info.height)
|
|
106
|
+
throw new ScreencastError(`Could not read the size of ${args.input}.`);
|
|
107
|
+
const output = resolveOutput(args.output, subdir("edits"), `keys-${stamp()}-${rand()}${editOutputExt(args.input)}`, args.overwrite);
|
|
108
|
+
const work = mkdtempSync(join(tmpdir(), "screencast-keys-"));
|
|
109
|
+
try {
|
|
110
|
+
const assets = prepareKeystrokeAssets(groups.map((g) => g.label), work, "", args.fontFile);
|
|
111
|
+
const style = { position: args.position, size: args.size, color: args.color };
|
|
112
|
+
const ffArgs = buildKeystrokeArgs(args.input, output, groups, assets, style, { height: info.height });
|
|
113
|
+
await runEditJob(ffArgs, { output, durationSec: info.durationSec, extra });
|
|
114
|
+
return okResponse({
|
|
115
|
+
outputPath: output,
|
|
116
|
+
badges: badges.length,
|
|
117
|
+
labels: groups.map((g) => g.label),
|
|
118
|
+
...(assets.fallbackFont && { fallbackFont: assets.fallbackFont }),
|
|
119
|
+
...(assets.warnings.length > 0 && { warnings: assets.warnings }),
|
|
120
|
+
...(note && { note }),
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
finally {
|
|
124
|
+
rmSync(work, { recursive: true, force: true });
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
catch (error) {
|
|
128
|
+
return errorResponse(error);
|
|
129
|
+
}
|
|
130
|
+
});
|
|
131
|
+
}
|
|
@@ -1,15 +1,23 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
1
2
|
import { errorResponse, okResponse } from "../utils/errors.js";
|
|
3
|
+
import { READ_ONLY, looseOutput } from "../utils/toolSpec.js";
|
|
2
4
|
import { requireFfmpeg } from "../utils/ffmpeg.js";
|
|
3
5
|
import { listDshowAudioDevices, pickLoopbackDevice, NO_LOOPBACK_HINT, } from "../utils/audioDevices.js";
|
|
4
6
|
export function register(server) {
|
|
5
|
-
server.
|
|
6
|
-
"
|
|
7
|
-
"
|
|
8
|
-
|
|
7
|
+
server.registerTool("list_audio_devices", {
|
|
8
|
+
title: "List Audio Devices",
|
|
9
|
+
description: "List DirectShow audio devices and flag a likely loopback (Stereo Mix or a virtual-audio " +
|
|
10
|
+
"driver), for start_recording's audio.device.",
|
|
11
|
+
inputSchema: {},
|
|
12
|
+
outputSchema: looseOutput({
|
|
13
|
+
devices: z.array(z.unknown()),
|
|
14
|
+
loopbackDevice: z.string().nullable(),
|
|
15
|
+
note: z.string(),
|
|
16
|
+
}),
|
|
17
|
+
annotations: READ_ONLY,
|
|
18
|
+
}, async () => {
|
|
9
19
|
try {
|
|
10
20
|
requireFfmpeg();
|
|
11
|
-
// Always re-probe: this is the explicit "show me what's available" call,
|
|
12
|
-
// so a device enabled since the last recording must show up.
|
|
13
21
|
const devices = await listDshowAudioDevices(true);
|
|
14
22
|
const loopback = pickLoopbackDevice(devices);
|
|
15
23
|
return okResponse({
|
|
@@ -25,4 +33,3 @@ export function register(server) {
|
|
|
25
33
|
}
|
|
26
34
|
});
|
|
27
35
|
}
|
|
28
|
-
//# sourceMappingURL=listAudioDevices.js.map
|
|
@@ -1,9 +1,20 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
1
2
|
import { errorResponse, okResponse } from "../utils/errors.js";
|
|
3
|
+
import { READ_ONLY, looseOutput } from "../utils/toolSpec.js";
|
|
2
4
|
import { isAlive } from "../utils/sessions.js";
|
|
3
5
|
import { getStore } from "../context.js";
|
|
4
6
|
export function register(server) {
|
|
5
|
-
server.
|
|
6
|
-
"
|
|
7
|
+
server.registerTool("list_sessions", {
|
|
8
|
+
title: "List Sessions",
|
|
9
|
+
description: "List all recording sessions (active and finished) with their status, " +
|
|
10
|
+
"target, output path, and whether the process is still alive.",
|
|
11
|
+
inputSchema: {},
|
|
12
|
+
outputSchema: looseOutput({
|
|
13
|
+
count: z.number().int(),
|
|
14
|
+
sessions: z.array(looseOutput({ id: z.string(), status: z.string(), outputPath: z.string(), alive: z.boolean() })),
|
|
15
|
+
}),
|
|
16
|
+
annotations: READ_ONLY,
|
|
17
|
+
}, async () => {
|
|
7
18
|
try {
|
|
8
19
|
const sessions = getStore()
|
|
9
20
|
.list()
|
|
@@ -15,4 +26,3 @@ export function register(server) {
|
|
|
15
26
|
}
|
|
16
27
|
});
|
|
17
28
|
}
|
|
18
|
-
//# sourceMappingURL=listSessions.js.map
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { errorResponse, okResponse } from "../utils/errors.js";
|
|
3
|
+
import { READ_ONLY, looseOutput } from "../utils/toolSpec.js";
|
|
4
|
+
import { getMonitors } from "../utils/monitors.js";
|
|
5
|
+
import { getRawWindows } from "../utils/windows.js";
|
|
6
|
+
import { wgcAvailable } from "../utils/ffmpeg.js";
|
|
7
|
+
import { buildTargetList } from "../utils/targetList.js";
|
|
8
|
+
const inputSchema = {
|
|
9
|
+
exe: z
|
|
10
|
+
.string()
|
|
11
|
+
.min(1)
|
|
12
|
+
.optional()
|
|
13
|
+
.describe("Only list windows of this executable, e.g. 'Code.exe' or 'code'."),
|
|
14
|
+
titleContains: z
|
|
15
|
+
.string()
|
|
16
|
+
.min(1)
|
|
17
|
+
.optional()
|
|
18
|
+
.describe("Only list windows whose title contains this text (case-insensitive)."),
|
|
19
|
+
capturableOnly: z
|
|
20
|
+
.boolean()
|
|
21
|
+
.optional()
|
|
22
|
+
.describe("Leave out windows neither backend can capture (minimized, off screen). Default false."),
|
|
23
|
+
};
|
|
24
|
+
const bounds = z.object({ x: z.number(), y: z.number(), width: z.number(), height: z.number() });
|
|
25
|
+
const outputSchema = looseOutput({
|
|
26
|
+
full: z.looseObject({ target: z.literal("full"), bounds }),
|
|
27
|
+
monitors: z.array(z.looseObject({
|
|
28
|
+
target: z.string(),
|
|
29
|
+
index: z.number(),
|
|
30
|
+
primary: z.boolean(),
|
|
31
|
+
bounds,
|
|
32
|
+
dpi: z.number().nullable(),
|
|
33
|
+
scale: z.number().nullable(),
|
|
34
|
+
})),
|
|
35
|
+
windows: z.array(z.looseObject({
|
|
36
|
+
target: z.string(),
|
|
37
|
+
title: z.string(),
|
|
38
|
+
exe: z.string().nullable(),
|
|
39
|
+
pid: z.number().nullable(),
|
|
40
|
+
hwnd: z.number().nullable(),
|
|
41
|
+
bounds,
|
|
42
|
+
minimized: z.boolean(),
|
|
43
|
+
cloaked: z.boolean(),
|
|
44
|
+
capturable: z.boolean(),
|
|
45
|
+
wgcCapturable: z.boolean(),
|
|
46
|
+
})),
|
|
47
|
+
wgcAvailable: z.boolean(),
|
|
48
|
+
note: z.string(),
|
|
49
|
+
});
|
|
50
|
+
export function register(server) {
|
|
51
|
+
server.registerTool("list_targets", {
|
|
52
|
+
title: "List Capture Targets",
|
|
53
|
+
description: "List the desktop, monitors, and visible windows (topmost first, with capturability per backend). " +
|
|
54
|
+
"Each entry has a `target` string to pass as-is to capture tools; use it instead of guessing a title.",
|
|
55
|
+
inputSchema,
|
|
56
|
+
outputSchema,
|
|
57
|
+
annotations: READ_ONLY,
|
|
58
|
+
}, async (args) => {
|
|
59
|
+
try {
|
|
60
|
+
const [monitors, windows] = await Promise.all([getMonitors(), getRawWindows()]);
|
|
61
|
+
const list = buildTargetList(monitors, windows, {
|
|
62
|
+
wgcAvailable: wgcAvailable(),
|
|
63
|
+
filter: { exe: args.exe, titleContains: args.titleContains, capturableOnly: args.capturableOnly },
|
|
64
|
+
});
|
|
65
|
+
return okResponse({
|
|
66
|
+
...list,
|
|
67
|
+
note: "Pass a target string unchanged. A window handle lasts until the app closes the window; " +
|
|
68
|
+
"list again after an app restarts, or target it by window:exe=<app.exe>. " +
|
|
69
|
+
'A window with capturable false but wgcCapturable true needs backend: "wgc".',
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
catch (error) {
|
|
73
|
+
return errorResponse(error);
|
|
74
|
+
}
|
|
75
|
+
});
|
|
76
|
+
}
|