@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
|
@@ -0,0 +1,402 @@
|
|
|
1
|
+
// screencast-mcp review player script (#128). Kept out of player.html so ESLint
|
|
2
|
+
// sees it (#243); reviewRecording.ts inlines it into the page when served, as
|
|
3
|
+
// the host's CSP allows no separate fetch.
|
|
4
|
+
(() => {
|
|
5
|
+
"use strict";
|
|
6
|
+
const $ = (id) => document.getElementById(id);
|
|
7
|
+
const PROTOCOL = "2026-01-26";
|
|
8
|
+
|
|
9
|
+
// --- JSON-RPC over postMessage with the host ---------------------------
|
|
10
|
+
let nextId = 1;
|
|
11
|
+
const pending = new Map();
|
|
12
|
+
const send = (msg) => window.parent.postMessage({ jsonrpc: "2.0", ...msg }, "*");
|
|
13
|
+
const request = (method, params) =>
|
|
14
|
+
new Promise((resolve, reject) => {
|
|
15
|
+
const id = nextId++;
|
|
16
|
+
pending.set(id, { resolve, reject });
|
|
17
|
+
send({ id, method, params });
|
|
18
|
+
});
|
|
19
|
+
const notify = (method, params) => send({ method, params });
|
|
20
|
+
|
|
21
|
+
window.addEventListener("message", (e) => {
|
|
22
|
+
if (e.source !== window.parent) return;
|
|
23
|
+
const m = e.data;
|
|
24
|
+
if (!m || m.jsonrpc !== "2.0") return;
|
|
25
|
+
if (m.id !== undefined && !m.method) {
|
|
26
|
+
const p = pending.get(m.id);
|
|
27
|
+
if (!p) return;
|
|
28
|
+
pending.delete(m.id);
|
|
29
|
+
if (m.error) p.reject(new Error(m.error.message || "request failed"));
|
|
30
|
+
else p.resolve(m.result);
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
if (m.id !== undefined) {
|
|
34
|
+
// A request from the host.
|
|
35
|
+
if (m.method === "ui/resource-teardown" || m.method === "ping") send({ id: m.id, result: {} });
|
|
36
|
+
else send({ id: m.id, error: { code: -32601, message: `Unsupported: ${m.method}` } });
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
if (m.method === "ui/notifications/tool-input") onToolInput(m.params?.arguments || {});
|
|
40
|
+
else if (m.method === "ui/notifications/tool-result") onToolResult(m.params || {});
|
|
41
|
+
else if (m.method === "ui/notifications/host-context-changed") applyHostContext(m.params || {});
|
|
42
|
+
else if (m.method === "ui/notifications/tool-cancelled") setEmpty("The tool call was cancelled.");
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
const applyHostContext = (ctx) => {
|
|
46
|
+
if (ctx && (ctx.theme === "light" || ctx.theme === "dark")) document.documentElement.dataset.theme = ctx.theme;
|
|
47
|
+
};
|
|
48
|
+
const callTool = async (name, args) => {
|
|
49
|
+
const r = await request("tools/call", { name, arguments: args });
|
|
50
|
+
if (r && r.isError) throw new Error((r.content || []).map((c) => c.text).filter(Boolean).join(" ") || `${name} failed`);
|
|
51
|
+
return r;
|
|
52
|
+
};
|
|
53
|
+
const resultJson = (r) => {
|
|
54
|
+
const t = (r?.content || []).find((c) => c.type === "text");
|
|
55
|
+
try { return t ? JSON.parse(t.text) : null; } catch { return null; }
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
// --- state ---------------------------------------------------------------
|
|
59
|
+
// Frames sit at their real times (#232): an even grid plus scene changes,
|
|
60
|
+
// so frame i shows [times[i], end(i)) and the timeline maps by time.
|
|
61
|
+
const S = { input: null, duration: 0, W: 0, H: 0, frames: [], times: [], scene: new Set(), i: 0, inI: 0, outI: 0, boxes: [], drawing: false, playing: null, result: null };
|
|
62
|
+
const fmt = (t) => { const m = Math.floor(t / 60), s = t - m * 60; return `${String(m).padStart(2, "0")}:${s.toFixed(1).padStart(4, "0")}`; };
|
|
63
|
+
const end = (i) => (i + 1 < S.times.length ? S.times[i + 1] : S.duration);
|
|
64
|
+
const pct = (t) => (S.duration > 0 ? Math.max(0, Math.min(100, (t / S.duration) * 100)) : 0);
|
|
65
|
+
/** The frame showing time t: the last one starting at or before it. */
|
|
66
|
+
const frameAt = (t) => {
|
|
67
|
+
let i = 0;
|
|
68
|
+
while (i + 1 < S.times.length && S.times[i + 1] <= t) i++;
|
|
69
|
+
return i;
|
|
70
|
+
};
|
|
71
|
+
const setEmpty = (text) => { $("empty").textContent = text; $("empty").hidden = false; };
|
|
72
|
+
const status = (text, kind) => { const s = $("status"); s.textContent = text; s.className = kind || ""; };
|
|
73
|
+
|
|
74
|
+
function onToolInput(args) {
|
|
75
|
+
if (args.input) $("file").textContent = args.input;
|
|
76
|
+
}
|
|
77
|
+
function onToolResult(result) {
|
|
78
|
+
if (result.isError) return setEmpty((result.content || []).map((c) => c.text).join(" ") || "The tool failed.");
|
|
79
|
+
const j = resultJson(result);
|
|
80
|
+
const input = j && (j.outputPath || j.input);
|
|
81
|
+
if (!input) return setEmpty("No video in this result.");
|
|
82
|
+
load(input);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
async function load(input) {
|
|
86
|
+
stop();
|
|
87
|
+
S.input = input;
|
|
88
|
+
S.boxes = [];
|
|
89
|
+
$("file").textContent = input.split(/[\\/]/).pop();
|
|
90
|
+
$("file").title = input;
|
|
91
|
+
setEmpty("Loading frames...");
|
|
92
|
+
status("");
|
|
93
|
+
let meta;
|
|
94
|
+
try {
|
|
95
|
+
const r = await callTool("player_frames", { input });
|
|
96
|
+
meta = resultJson(r);
|
|
97
|
+
S.frames = (r.content || []).filter((c) => c.type === "image").map((c) => `data:${c.mimeType};base64,${c.data}`);
|
|
98
|
+
if (!meta || S.frames.length === 0) throw new Error("No frames came back.");
|
|
99
|
+
Object.assign(S, {
|
|
100
|
+
duration: meta.durationSec, W: meta.width, H: meta.height, times: meta.frameTimes,
|
|
101
|
+
scene: new Set(meta.sceneFrames || []), i: 0, inI: 0, outI: S.frames.length - 1,
|
|
102
|
+
});
|
|
103
|
+
} catch (err) {
|
|
104
|
+
return setEmpty(`Could not load the recording: ${err.message}`);
|
|
105
|
+
}
|
|
106
|
+
$("empty").hidden = true;
|
|
107
|
+
$("frame").hidden = false;
|
|
108
|
+
// A strip of up to 40 thumbnails, evenly spaced in time.
|
|
109
|
+
const strip = $("strip");
|
|
110
|
+
strip.replaceChildren();
|
|
111
|
+
const n = Math.min(40, S.frames.length);
|
|
112
|
+
for (let k = 0; k < n; k++) {
|
|
113
|
+
const img = document.createElement("img");
|
|
114
|
+
img.alt = "";
|
|
115
|
+
img.src = S.frames[frameAt(((k + 0.5) * S.duration) / n)];
|
|
116
|
+
strip.appendChild(img);
|
|
117
|
+
}
|
|
118
|
+
// Scene-change frames get a tick, so a person sees where the extras are.
|
|
119
|
+
$("ticks").replaceChildren(...[...S.scene].map((i) => {
|
|
120
|
+
const t = document.createElement("i");
|
|
121
|
+
t.style.left = `${pct(S.times[i])}%`;
|
|
122
|
+
return t;
|
|
123
|
+
}));
|
|
124
|
+
// Markers (#174): a tick on the timeline and a button that seeks to it.
|
|
125
|
+
const marks = Array.isArray(meta.markers) ? meta.markers.filter((m) => m && typeof m.t === "number" && m.t <= S.duration) : [];
|
|
126
|
+
$("marks").replaceChildren(...marks.map((m) => {
|
|
127
|
+
const b = document.createElement("b");
|
|
128
|
+
b.style.left = `${pct(m.t)}%`;
|
|
129
|
+
return b;
|
|
130
|
+
}));
|
|
131
|
+
$("markList").replaceChildren(...marks.map((m) => {
|
|
132
|
+
const li = document.createElement("li");
|
|
133
|
+
const btn = document.createElement("button");
|
|
134
|
+
btn.type = "button";
|
|
135
|
+
const tc = document.createElement("span");
|
|
136
|
+
tc.textContent = fmt(m.t);
|
|
137
|
+
btn.append(tc, String(m.label || "Marker"));
|
|
138
|
+
btn.setAttribute("aria-label", `Go to marker ${m.label || ""} at ${fmt(m.t)}`);
|
|
139
|
+
btn.addEventListener("click", () => { stop(); show(frameAt(m.t)); render(); });
|
|
140
|
+
li.appendChild(btn);
|
|
141
|
+
return li;
|
|
142
|
+
}));
|
|
143
|
+
$("markList").hidden = marks.length === 0;
|
|
144
|
+
const every = meta.intervalSec ?? S.duration / S.frames.length;
|
|
145
|
+
$("sampling").textContent = `1 frame / ${every.toFixed(1)}s` + (S.scene.size ? `, +${S.scene.size} at scene changes` : "");
|
|
146
|
+
["play", "draw"].forEach((id) => ($(id).disabled = false));
|
|
147
|
+
$("boxFields").disabled = false;
|
|
148
|
+
for (const id of ["seek", "hIn", "hOut"]) $(id).removeAttribute("aria-disabled");
|
|
149
|
+
show(0);
|
|
150
|
+
render();
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
function show(i) {
|
|
154
|
+
S.i = Math.max(0, Math.min(S.frames.length - 1, i));
|
|
155
|
+
const t = S.times[S.i] || 0;
|
|
156
|
+
$("frame").src = S.frames[S.i];
|
|
157
|
+
$("frame").alt = `Frame at ${fmt(t)}`;
|
|
158
|
+
$("tc").textContent = `${fmt(t)} / ${fmt(S.duration)}`;
|
|
159
|
+
$("head").style.left = `${pct(t)}%`;
|
|
160
|
+
setSlider($("seek"), t, `${fmt(t)} of ${fmt(S.duration)}`);
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
function setSlider(el, t, text) {
|
|
164
|
+
el.setAttribute("aria-valuemax", String(Math.round(S.duration * 10) / 10));
|
|
165
|
+
el.setAttribute("aria-valuenow", String(Math.round(t * 10) / 10));
|
|
166
|
+
el.setAttribute("aria-valuetext", text);
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
function render() {
|
|
170
|
+
const tin = S.times[S.inI] || 0, tout = end(S.outI);
|
|
171
|
+
const a = pct(tin), b = pct(tout);
|
|
172
|
+
$("hIn").style.left = `${a}%`;
|
|
173
|
+
$("hOut").style.left = `${b}%`;
|
|
174
|
+
$("shadeIn").style.cssText = `left:0;width:${a}%`;
|
|
175
|
+
$("shadeOut").style.cssText = `left:${b}%;right:0`;
|
|
176
|
+
$("inT").textContent = `${tin.toFixed(1)}s`;
|
|
177
|
+
$("outT").textContent = `${tout.toFixed(1)}s`;
|
|
178
|
+
$("lenT").textContent = `${(tout - tin).toFixed(1)}s kept`;
|
|
179
|
+
setSlider($("hIn"), tin, `Trim start ${fmt(tin)}`);
|
|
180
|
+
setSlider($("hOut"), tout, `Trim end ${fmt(tout)}`);
|
|
181
|
+
renderBoxes();
|
|
182
|
+
$("apply").disabled = !S.input || (!trimmed() && S.boxes.length === 0);
|
|
183
|
+
}
|
|
184
|
+
const trimmed = () => S.inI > 0 || S.outI < S.frames.length - 1;
|
|
185
|
+
|
|
186
|
+
// --- timeline: seek and trim handles ----------------------------------
|
|
187
|
+
const tl = $("timeline");
|
|
188
|
+
const indexAt = (clientX) => {
|
|
189
|
+
const r = tl.getBoundingClientRect();
|
|
190
|
+
return frameAt(((clientX - r.left) / r.width) * S.duration);
|
|
191
|
+
};
|
|
192
|
+
let dragging = null;
|
|
193
|
+
tl.addEventListener("pointerdown", (e) => {
|
|
194
|
+
if (!S.frames.length) return;
|
|
195
|
+
dragging = e.target === $("hIn") ? "in" : e.target === $("hOut") ? "out" : "seek";
|
|
196
|
+
tl.setPointerCapture(e.pointerId);
|
|
197
|
+
move(e);
|
|
198
|
+
});
|
|
199
|
+
tl.addEventListener("pointermove", (e) => {
|
|
200
|
+
if (dragging) move(e);
|
|
201
|
+
});
|
|
202
|
+
// An interrupted drag (touch scroll, alt-tab) ends like a release (#243).
|
|
203
|
+
for (const type of ["pointerup", "pointercancel", "lostpointercapture"]) tl.addEventListener(type, () => (dragging = null));
|
|
204
|
+
function move(e) {
|
|
205
|
+
const i = indexAt(e.clientX);
|
|
206
|
+
if (dragging === "in") S.inI = Math.min(i, S.outI);
|
|
207
|
+
else if (dragging === "out") S.outI = Math.max(i, S.inI);
|
|
208
|
+
show(dragging === "in" ? S.inI : dragging === "out" ? S.outI : i);
|
|
209
|
+
render();
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
/** Where a slider key moves frame index i: arrows one frame, Page keys a
|
|
213
|
+
* tenth of the recording, Home/End the ends. null for other keys. */
|
|
214
|
+
function keyTarget(key, i) {
|
|
215
|
+
const n = S.frames.length;
|
|
216
|
+
if (key === "ArrowLeft" || key === "ArrowDown") return i - 1;
|
|
217
|
+
if (key === "ArrowRight" || key === "ArrowUp") return i + 1;
|
|
218
|
+
if (key === "PageDown") return Math.min(i - 1, frameAt(S.times[i] - S.duration / 10));
|
|
219
|
+
if (key === "PageUp") return Math.max(i + 1, frameAt(S.times[i] + S.duration / 10));
|
|
220
|
+
if (key === "Home") return 0;
|
|
221
|
+
if (key === "End") return n - 1;
|
|
222
|
+
return null;
|
|
223
|
+
}
|
|
224
|
+
$("seek").addEventListener("keydown", (e) => {
|
|
225
|
+
const to = S.frames.length ? keyTarget(e.key, S.i) : null;
|
|
226
|
+
if (to === null) return;
|
|
227
|
+
e.preventDefault();
|
|
228
|
+
show(to);
|
|
229
|
+
});
|
|
230
|
+
for (const [id, key] of [["hIn", "inI"], ["hOut", "outI"]]) {
|
|
231
|
+
$(id).addEventListener("keydown", (e) => {
|
|
232
|
+
const to = S.frames.length ? keyTarget(e.key, S[key]) : null;
|
|
233
|
+
if (to === null) return;
|
|
234
|
+
e.preventDefault();
|
|
235
|
+
if (key === "inI") S.inI = Math.max(0, Math.min(to, S.outI));
|
|
236
|
+
else S.outI = Math.min(S.frames.length - 1, Math.max(to, S.inI));
|
|
237
|
+
show(S[key]);
|
|
238
|
+
render();
|
|
239
|
+
});
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
// --- playback: a flipbook over the kept range, at the frames' real times ---
|
|
243
|
+
$("play").addEventListener("click", () => {
|
|
244
|
+
if (S.playing) return stop();
|
|
245
|
+
$("play").textContent = "Pause";
|
|
246
|
+
let i = S.i < S.inI || S.i >= S.outI ? S.inI : S.i;
|
|
247
|
+
const tick = () => {
|
|
248
|
+
show(i);
|
|
249
|
+
const ms = Math.max(40, (end(i) - S.times[i]) * 1000);
|
|
250
|
+
i = i >= S.outI ? S.inI : i + 1;
|
|
251
|
+
S.playing = setTimeout(tick, ms);
|
|
252
|
+
};
|
|
253
|
+
tick();
|
|
254
|
+
});
|
|
255
|
+
function stop() {
|
|
256
|
+
clearTimeout(S.playing);
|
|
257
|
+
S.playing = null;
|
|
258
|
+
$("play").textContent = "Play";
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
// --- redaction boxes, in video pixels -----------------------------------
|
|
262
|
+
const stage = $("stage"), img = $("frame");
|
|
263
|
+
$("draw").addEventListener("click", () => {
|
|
264
|
+
S.drawing = !S.drawing;
|
|
265
|
+
$("draw").setAttribute("aria-pressed", String(S.drawing));
|
|
266
|
+
stage.classList.toggle("drawing", S.drawing);
|
|
267
|
+
});
|
|
268
|
+
const toVideo = (clientX, clientY) => {
|
|
269
|
+
const r = img.getBoundingClientRect();
|
|
270
|
+
return {
|
|
271
|
+
x: Math.max(0, Math.min(S.W, ((clientX - r.left) / r.width) * S.W)),
|
|
272
|
+
y: Math.max(0, Math.min(S.H, ((clientY - r.top) / r.height) * S.H)),
|
|
273
|
+
};
|
|
274
|
+
};
|
|
275
|
+
let start = null, draft = null;
|
|
276
|
+
stage.addEventListener("pointerdown", (e) => {
|
|
277
|
+
if (!S.drawing || !S.frames.length) return;
|
|
278
|
+
start = toVideo(e.clientX, e.clientY);
|
|
279
|
+
stage.setPointerCapture(e.pointerId);
|
|
280
|
+
draft = document.createElement("div");
|
|
281
|
+
draft.className = "box draft";
|
|
282
|
+
stage.appendChild(draft);
|
|
283
|
+
});
|
|
284
|
+
stage.addEventListener("pointermove", (e) => {
|
|
285
|
+
if (!start) return;
|
|
286
|
+
placeBox(draft, rectOf(start, toVideo(e.clientX, e.clientY)));
|
|
287
|
+
});
|
|
288
|
+
stage.addEventListener("pointerup", (e) => {
|
|
289
|
+
if (!start) return;
|
|
290
|
+
const r = rectOf(start, toVideo(e.clientX, e.clientY));
|
|
291
|
+
dropDraft();
|
|
292
|
+
if (r.width >= 4 && r.height >= 4) S.boxes.push(r);
|
|
293
|
+
render();
|
|
294
|
+
});
|
|
295
|
+
// A cancelled drag adds nothing and leaves no dashed box behind (#243).
|
|
296
|
+
for (const type of ["pointercancel", "lostpointercapture"]) stage.addEventListener(type, dropDraft);
|
|
297
|
+
function dropDraft() {
|
|
298
|
+
start = null;
|
|
299
|
+
draft?.remove();
|
|
300
|
+
draft = null;
|
|
301
|
+
}
|
|
302
|
+
const rectOf = (a, b) => {
|
|
303
|
+
const x = Math.floor(Math.min(a.x, b.x)), y = Math.floor(Math.min(a.y, b.y));
|
|
304
|
+
return { x, y, width: Math.ceil(Math.max(a.x, b.x)) - x, height: Math.ceil(Math.max(a.y, b.y)) - y };
|
|
305
|
+
};
|
|
306
|
+
|
|
307
|
+
// The keyboard path: type a box in video pixels (#243).
|
|
308
|
+
$("boxForm").addEventListener("submit", (e) => {
|
|
309
|
+
e.preventDefault();
|
|
310
|
+
const [x, y, w, h] = ["bx", "by", "bw", "bh"].map((id) => Math.round(Number($(id).value)));
|
|
311
|
+
if (![x, y, w, h].every(Number.isFinite) || x < 0 || y < 0 || x >= S.W || y >= S.H) {
|
|
312
|
+
return status(`A box needs x 0-${S.W - 1} and y 0-${S.H - 1}.`, "err");
|
|
313
|
+
}
|
|
314
|
+
const r = { x, y, width: Math.min(w, S.W - x), height: Math.min(h, S.H - y) };
|
|
315
|
+
if (r.width < 4 || r.height < 4) return status("A box needs to be at least 4 px wide and tall inside the video.", "err");
|
|
316
|
+
S.boxes.push(r);
|
|
317
|
+
render();
|
|
318
|
+
status(`Added box ${S.boxes.length}: ${r.width}\u00d7${r.height} at ${r.x},${r.y}.`);
|
|
319
|
+
});
|
|
320
|
+
|
|
321
|
+
function placeBox(el, r) {
|
|
322
|
+
const ir = img.getBoundingClientRect(), sr = stage.getBoundingClientRect();
|
|
323
|
+
const k = ir.width / S.W;
|
|
324
|
+
el.style.left = `${ir.left - sr.left + r.x * k}px`;
|
|
325
|
+
el.style.top = `${ir.top - sr.top + r.y * k}px`;
|
|
326
|
+
el.style.width = `${r.width * k}px`;
|
|
327
|
+
el.style.height = `${r.height * k}px`;
|
|
328
|
+
}
|
|
329
|
+
function renderBoxes() {
|
|
330
|
+
stage.querySelectorAll(".box:not(.draft)").forEach((b) => b.remove());
|
|
331
|
+
const list = $("boxList");
|
|
332
|
+
list.replaceChildren();
|
|
333
|
+
S.boxes.forEach((r, n) => {
|
|
334
|
+
const el = document.createElement("div");
|
|
335
|
+
el.className = "box";
|
|
336
|
+
const tag = document.createElement("span");
|
|
337
|
+
tag.textContent = String(n + 1);
|
|
338
|
+
el.appendChild(tag);
|
|
339
|
+
stage.appendChild(el);
|
|
340
|
+
placeBox(el, r);
|
|
341
|
+
const li = document.createElement("li");
|
|
342
|
+
li.textContent = `#${n + 1} ${r.width}\u00d7${r.height} at ${r.x},${r.y}`;
|
|
343
|
+
const rm = document.createElement("button");
|
|
344
|
+
rm.type = "button";
|
|
345
|
+
rm.textContent = "\u2715";
|
|
346
|
+
rm.setAttribute("aria-label", `Remove box ${n + 1}`);
|
|
347
|
+
rm.addEventListener("click", () => {
|
|
348
|
+
S.boxes.splice(n, 1);
|
|
349
|
+
render();
|
|
350
|
+
status(`Removed box ${n + 1}.`);
|
|
351
|
+
// Keep keyboard focus in the list (or on the form when it empties).
|
|
352
|
+
const next = list.querySelectorAll("button")[Math.min(n, S.boxes.length - 1)];
|
|
353
|
+
(next || $("bx")).focus();
|
|
354
|
+
});
|
|
355
|
+
li.appendChild(rm);
|
|
356
|
+
list.appendChild(li);
|
|
357
|
+
});
|
|
358
|
+
}
|
|
359
|
+
img.addEventListener("load", renderBoxes);
|
|
360
|
+
new ResizeObserver(renderBoxes).observe(stage);
|
|
361
|
+
|
|
362
|
+
// --- export: one pipeline call -----------------------------------------
|
|
363
|
+
$("apply").addEventListener("click", async () => {
|
|
364
|
+
stop();
|
|
365
|
+
const steps = [];
|
|
366
|
+
// Redact first, so a box covers every frame of the kept range.
|
|
367
|
+
if (S.boxes.length) steps.push({ op: "redact", regions: S.boxes.map((b) => ({ ...b })) });
|
|
368
|
+
const tin = Math.round((S.times[S.inI] || 0) * 1000) / 1000, tout = Math.round(end(S.outI) * 1000) / 1000;
|
|
369
|
+
if (trimmed()) steps.push({ op: "trim", start: tin, end: Math.min(tout, S.duration) });
|
|
370
|
+
$("apply").disabled = true;
|
|
371
|
+
status("Exporting...");
|
|
372
|
+
try {
|
|
373
|
+
const out = resultJson(await callTool("pipeline", { input: S.input, steps }));
|
|
374
|
+
S.result = out.outputPath;
|
|
375
|
+
status(`Saved ${S.result}`, "ok");
|
|
376
|
+
$("openResult").hidden = false;
|
|
377
|
+
const what = [steps.some((s) => s.op === "trim") ? `trimmed to ${tin}-${tout}s` : "", S.boxes.length ? `${S.boxes.length} region(s) redacted` : ""].filter(Boolean).join(", ");
|
|
378
|
+
// Tell the agent what the person did; the host includes it on the next turn.
|
|
379
|
+
request("ui/update-model-context", {
|
|
380
|
+
content: [{ type: "text", text: `In the review player the user exported ${S.input}, ${what}, to ${S.result}.` }],
|
|
381
|
+
structuredContent: { input: S.input, output: S.result, steps },
|
|
382
|
+
}).catch(() => {});
|
|
383
|
+
} catch (err) {
|
|
384
|
+
status(`Export failed: ${err.message}`, "err");
|
|
385
|
+
} finally {
|
|
386
|
+
render();
|
|
387
|
+
}
|
|
388
|
+
});
|
|
389
|
+
$("openResult").addEventListener("click", () => {
|
|
390
|
+
$("openResult").hidden = true;
|
|
391
|
+
load(S.result);
|
|
392
|
+
});
|
|
393
|
+
|
|
394
|
+
// --- start ---------------------------------------------------------------
|
|
395
|
+
new ResizeObserver(() => notify("ui/notifications/size-changed", { height: Math.ceil(document.documentElement.scrollHeight) })).observe(document.body);
|
|
396
|
+
request("ui/initialize", { appInfo: { name: "screencast-review-player", version: "1.0.0" }, appCapabilities: {}, protocolVersion: PROTOCOL })
|
|
397
|
+
.then((r) => {
|
|
398
|
+
applyHostContext(r && r.hostContext);
|
|
399
|
+
notify("ui/notifications/initialized", {});
|
|
400
|
+
})
|
|
401
|
+
.catch((err) => setEmpty(`The host did not start the player: ${err.message}`));
|
|
402
|
+
})();
|
package/dist/context.js
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
/** Process-wide singletons shared by every tool. */
|
|
2
1
|
import { SessionStore } from "./utils/sessions.js";
|
|
3
2
|
import { registryPath } from "./utils/paths.js";
|
|
4
3
|
let store = null;
|
|
5
|
-
/** Lazily construct and load the on-disk session registry. */
|
|
6
4
|
export function getStore() {
|
|
7
5
|
if (!store) {
|
|
8
6
|
store = new SessionStore(registryPath());
|
|
@@ -11,12 +9,9 @@ export function getStore() {
|
|
|
11
9
|
return store;
|
|
12
10
|
}
|
|
13
11
|
let shuttingDown = false;
|
|
14
|
-
/** Set once shutdown begins: from then on nothing writes to the client, whose
|
|
15
|
-
* pipe may already be closed (#229). */
|
|
16
12
|
export function markShuttingDown() {
|
|
17
13
|
shuttingDown = true;
|
|
18
14
|
}
|
|
19
15
|
export function isShuttingDown() {
|
|
20
16
|
return shuttingDown;
|
|
21
17
|
}
|
|
22
|
-
//# sourceMappingURL=context.js.map
|
package/dist/index.js
CHANGED
|
@@ -1,23 +1,14 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
/**
|
|
3
|
-
* screencast-mcp - a Windows-first MCP server for screen recording, frame
|
|
4
|
-
* sampling ("watching" footage), and minimal ffmpeg edits.
|
|
5
|
-
*
|
|
6
|
-
* Transport: stdio. ffmpeg/ffprobe are external dependencies detected per call.
|
|
7
|
-
* Capture is always explicit (a tool call) and never auto-fires - a recording
|
|
8
|
-
* can contain anything on screen, including secrets. See the README threat
|
|
9
|
-
* model.
|
|
10
|
-
*/
|
|
11
2
|
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
12
3
|
import { getStore, isShuttingDown, markShuttingDown } from "./context.js";
|
|
13
4
|
import { requireFfmpeg } from "./utils/ffmpeg.js";
|
|
5
|
+
import { abortEditJobs } from "./utils/jobs.js";
|
|
14
6
|
import { probeDuration, stopAll } from "./utils/lifecycle.js";
|
|
15
7
|
import { createServer } from "./server.js";
|
|
16
8
|
import { pruneCaptures, retentionDays, RETENTION_ENV } from "./utils/retention.js";
|
|
9
|
+
import { cleanupReplayDirs } from "./utils/replay.js";
|
|
17
10
|
const server = createServer();
|
|
18
11
|
async function main() {
|
|
19
|
-
// Reconcile any sessions interrupted by a previous crash and kill ffmpeg
|
|
20
|
-
// children that outlived the last run, so no zombie capture survives.
|
|
21
12
|
try {
|
|
22
13
|
const reaped = getStore().reapOrphans();
|
|
23
14
|
if (reaped.length > 0) {
|
|
@@ -27,6 +18,17 @@ async function main() {
|
|
|
27
18
|
catch (err) {
|
|
28
19
|
process.stderr.write(`Orphan reaping skipped: ${err instanceof Error ? err.message : String(err)}\n`);
|
|
29
20
|
}
|
|
21
|
+
try {
|
|
22
|
+
const live = getStore()
|
|
23
|
+
.list()
|
|
24
|
+
.flatMap((r) => (r.status === "recording" && r.replay ? [r.replay.dir] : []));
|
|
25
|
+
const removed = cleanupReplayDirs(live);
|
|
26
|
+
if (removed > 0)
|
|
27
|
+
process.stderr.write(`Removed ${removed} leftover replay buffer(s).\n`);
|
|
28
|
+
}
|
|
29
|
+
catch (err) {
|
|
30
|
+
process.stderr.write(`Replay buffer cleanup skipped: ${err instanceof Error ? err.message : String(err)}\n`);
|
|
31
|
+
}
|
|
30
32
|
const days = retentionDays();
|
|
31
33
|
if (days !== null) {
|
|
32
34
|
const pruned = pruneCaptures(days);
|
|
@@ -36,10 +38,6 @@ async function main() {
|
|
|
36
38
|
}
|
|
37
39
|
const transport = new StdioServerTransport();
|
|
38
40
|
await server.connect(transport);
|
|
39
|
-
// Without this, a client that disconnects mid-recording leaves the server
|
|
40
|
-
// and its ffmpeg child running (the child's pipes keep the event loop
|
|
41
|
-
// alive), so the screen keeps being recorded (#76). stdin EOF is the stdio
|
|
42
|
-
// transport's disconnect signal; signals cover a client that kills us.
|
|
43
41
|
process.stdin.on("end", () => void shutdown("client disconnected"));
|
|
44
42
|
process.stdin.on("close", () => void shutdown("client disconnected"));
|
|
45
43
|
server.server.onclose = () => void shutdown("transport closed");
|
|
@@ -47,14 +45,11 @@ async function main() {
|
|
|
47
45
|
process.on(sig, () => void shutdown(sig));
|
|
48
46
|
}
|
|
49
47
|
}
|
|
50
|
-
// A write to a client that has gone away fails with EPIPE; without a handler
|
|
51
|
-
// that error is uncaught and kills the server mid-cleanup (#229).
|
|
52
48
|
process.stdout.on("error", (err) => {
|
|
53
49
|
if (err.code !== "EPIPE")
|
|
54
50
|
process.stderr.write(`stdout error: ${err.message}\n`);
|
|
55
51
|
void shutdown("client pipe closed");
|
|
56
52
|
});
|
|
57
|
-
// A crash must never leave captures running: stop them, then exit (#207).
|
|
58
53
|
process.on("uncaughtException", (err) => {
|
|
59
54
|
process.stderr.write(`Uncaught exception: ${err.stack ?? err.message}\n`);
|
|
60
55
|
void shutdown("uncaught exception", 1);
|
|
@@ -62,11 +57,11 @@ process.on("uncaughtException", (err) => {
|
|
|
62
57
|
process.on("unhandledRejection", (reason) => {
|
|
63
58
|
process.stderr.write(`Unhandled rejection: ${reason instanceof Error ? (reason.stack ?? reason.message) : String(reason)}\n`);
|
|
64
59
|
});
|
|
65
|
-
/** Finalize every active recording, then exit. Idempotent and never throws. */
|
|
66
60
|
async function shutdown(reason, exitCode = 0) {
|
|
67
61
|
if (isShuttingDown())
|
|
68
62
|
return;
|
|
69
63
|
markShuttingDown();
|
|
64
|
+
const edits = abortEditJobs();
|
|
70
65
|
try {
|
|
71
66
|
const store = getStore();
|
|
72
67
|
if (store.activeIds().length > 0) {
|
|
@@ -75,7 +70,6 @@ async function shutdown(reason, exitCode = 0) {
|
|
|
75
70
|
ffprobe = requireFfmpeg().ffprobe;
|
|
76
71
|
}
|
|
77
72
|
catch {
|
|
78
|
-
/* duration stays unknown */
|
|
79
73
|
}
|
|
80
74
|
const stopped = await stopAll(store, (path) => ffprobe ? probeDuration(ffprobe, path) : Promise.resolve(null));
|
|
81
75
|
process.stderr.write(`Shutdown (${reason}): stopped ${stopped.length} recording(s).\n`);
|
|
@@ -84,10 +78,12 @@ async function shutdown(reason, exitCode = 0) {
|
|
|
84
78
|
catch (err) {
|
|
85
79
|
process.stderr.write(`Shutdown cleanup failed: ${err instanceof Error ? err.message : String(err)}\n`);
|
|
86
80
|
}
|
|
81
|
+
const cancelled = await edits;
|
|
82
|
+
if (cancelled > 0)
|
|
83
|
+
process.stderr.write(`Shutdown (${reason}): cancelled ${cancelled} edit job(s).\n`);
|
|
87
84
|
process.exit(exitCode);
|
|
88
85
|
}
|
|
89
86
|
main().catch((error) => {
|
|
90
87
|
process.stderr.write(`Fatal error: ${error instanceof Error ? error.message : String(error)}\n`);
|
|
91
88
|
process.exit(1);
|
|
92
89
|
});
|
|
93
|
-
//# sourceMappingURL=index.js.map
|
package/dist/prompts.js
CHANGED
|
@@ -1,11 +1,5 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* MCP prompts (#126): ready-made workflows that clients surface as slash
|
|
3
|
-
* commands, so a user can run a whole job without knowing the tools. Each
|
|
4
|
-
* prompt returns one user message spelling out the tool sequence.
|
|
5
|
-
*/
|
|
6
1
|
import { z } from "zod";
|
|
7
2
|
const message = (text) => ({ messages: [{ role: "user", content: { type: "text", text } }] });
|
|
8
|
-
/** The workflow texts, exported so tests can check they name real tools. */
|
|
9
3
|
export const PROMPT_TEXT = {
|
|
10
4
|
bugReproClip: (target, notes) => `Record a short bug-reproduction clip of ${target}.${notes ? ` The bug: ${notes}.` : ""}
|
|
11
5
|
|
|
@@ -14,7 +8,15 @@ export const PROMPT_TEXT = {
|
|
|
14
8
|
3. find_text { input: <recording>, scanEverySec: 1, query: "sk-|ghp_|api.?key|token|password", regex: true, redact: true } to check the whole clip, not one frame. If anything sensitive shows up, redact_region its redactRegions (each has its own start/end) with style "box" before sharing. OCR can miss text, so also look at the frames yourself.
|
|
15
9
|
4. trim (or clip) to the few seconds around the bug, and callout to box or point at it.
|
|
16
10
|
5. export_gif { input: <clip>, maxBytes: 10000000 } so it can be pasted into an issue or PR.
|
|
17
|
-
Report the final file path, what the clip shows, and anything you redacted
|
|
11
|
+
Report the final file path, what the clip shows, and anything you redacted. (To file it as an issue, bug_report does steps 3-5 in one call and writes report.md.)`,
|
|
12
|
+
fileBugReport: (target, notes, expected) => `File a bug report for ${target}, with a redacted repro package.${notes ? ` The bug: ${notes}.` : ""}${expected ? ` Expected: ${expected}.` : ""}
|
|
13
|
+
|
|
14
|
+
1. start_recording { target: "${target}", events: true } so clicks and shortcuts are logged as repro steps, then reproduce the bug (or ask me to), and stop_recording right after it shows.
|
|
15
|
+
2. contact_sheet { input: <recording> } and find the moment it goes wrong; note its time.
|
|
16
|
+
3. bug_report { sessionId: <session id>, title: <one-line summary>, actual: <what happened>, expected: <what should happen>, clipSec: 30 } (or start/end around that moment). It scans the clip for secrets with OCR and boxes them out before writing the clip, GIF, contact sheet, steps, error text, and report.md.
|
|
17
|
+
4. Read report.md and look at the contact sheet it returns: check the steps make sense and that nothing sensitive is left (OCR can miss text; add regions and rerun with overwrite: true if so).
|
|
18
|
+
5. Only if I confirm, run gh issue create --title <title> --body-file <reportPath>, then attach the GIF to the issue.
|
|
19
|
+
Report the folder path, the steps, the error text found, and what was redacted.`,
|
|
18
20
|
demoGif: (target, maxMB) => `Make a demo GIF of ${target} for a README or PR, under ${maxMB} MB.
|
|
19
21
|
|
|
20
22
|
1. start_recording { target: "${target}" }, walk through the feature (or ask me to), then stop_recording.
|
|
@@ -47,6 +49,15 @@ export function registerPrompts(server) {
|
|
|
47
49
|
notes: z.string().optional().describe("What the bug is."),
|
|
48
50
|
},
|
|
49
51
|
}, ({ target, notes }) => message(PROMPT_TEXT.bugReproClip(target || "full", notes ?? "")));
|
|
52
|
+
server.registerPrompt("file-bug-report", {
|
|
53
|
+
title: "File a bug report",
|
|
54
|
+
description: "Record a repro with input events, then package it with bug_report: redacted clip, GIF, steps, error text, and report.md.",
|
|
55
|
+
argsSchema: {
|
|
56
|
+
target: z.string().optional().describe("What to record, e.g. window:My App (default: full)."),
|
|
57
|
+
notes: z.string().optional().describe("What the bug is."),
|
|
58
|
+
expected: z.string().optional().describe("What should happen instead."),
|
|
59
|
+
},
|
|
60
|
+
}, ({ target, notes, expected }) => message(PROMPT_TEXT.fileBugReport(target || "full", notes ?? "", expected ?? "")));
|
|
50
61
|
server.registerPrompt("demo-gif", {
|
|
51
62
|
title: "Make a demo GIF",
|
|
52
63
|
description: "Record a feature walkthrough and export a GIF small enough for a README or PR.",
|
|
@@ -69,4 +80,3 @@ export function registerPrompts(server) {
|
|
|
69
80
|
argsSchema: { path: z.string().describe("Path to the recording.") },
|
|
70
81
|
}, ({ path }) => message(PROMPT_TEXT.reviewRecording(path)));
|
|
71
82
|
}
|
|
72
|
-
//# sourceMappingURL=prompts.js.map
|
package/dist/resources.js
CHANGED
|
@@ -1,13 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* MCP resources (#126): recording sessions as resources a client can list,
|
|
3
|
-
* read, and attach, without a filesystem tool.
|
|
4
|
-
*
|
|
5
|
-
* screencast://sessions every session (JSON)
|
|
6
|
-
* screencast://sessions/{id} one session's record (JSON)
|
|
7
|
-
* screencast://sessions/{id}/poster a JPEG preview frame of its recording
|
|
8
|
-
*
|
|
9
|
-
* Clients are told when the list changes (a recording starts or stops).
|
|
10
|
-
*/
|
|
11
1
|
import { existsSync, rmSync } from "node:fs";
|
|
12
2
|
import { ResourceTemplate } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
13
3
|
import { getStore, isShuttingDown } from "./context.js";
|
|
@@ -57,14 +47,14 @@ export function registerResources(server) {
|
|
|
57
47
|
try {
|
|
58
48
|
await runFfmpeg(["-y", "-v", "error", "-ss", String((durationSec ?? 0) / 2), "-i", s.outputPath, "-frames:v", "1", frame], 30_000);
|
|
59
49
|
const [image] = (await encodeInlineImages([frame], 960, 1)).images;
|
|
50
|
+
if (!image)
|
|
51
|
+
throw new ScreencastError(`Could not extract a thumbnail frame from ${s.outputPath}`);
|
|
60
52
|
return { contents: [{ uri: uri.href, mimeType: image.mimeType, blob: image.data }] };
|
|
61
53
|
}
|
|
62
54
|
finally {
|
|
63
55
|
rmSync(frame, { force: true });
|
|
64
56
|
}
|
|
65
57
|
});
|
|
66
|
-
// Skipped once shutdown starts (the client's pipe may be gone), and never
|
|
67
|
-
// allowed to throw into a registry write (#229).
|
|
68
58
|
getStore().onChange(() => {
|
|
69
59
|
if (isShuttingDown() || !server.isConnected())
|
|
70
60
|
return;
|
|
@@ -72,8 +62,6 @@ export function registerResources(server) {
|
|
|
72
62
|
server.sendResourceListChanged();
|
|
73
63
|
}
|
|
74
64
|
catch {
|
|
75
|
-
/* the client went away */
|
|
76
65
|
}
|
|
77
66
|
});
|
|
78
67
|
}
|
|
79
|
-
//# sourceMappingURL=resources.js.map
|