@tmhs/screencast-mcp 0.32.0 → 0.33.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 +4 -2
- package/assets/ui/player.html +410 -0
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/tools/reviewRecording.d.ts +5 -0
- package/dist/tools/reviewRecording.d.ts.map +1 -0
- package/dist/tools/reviewRecording.js +110 -0
- package/dist/tools/reviewRecording.js.map +1 -0
- package/dist/tools/stopRecording.d.ts.map +1 -1
- package/dist/tools/stopRecording.js +11 -4
- package/dist/tools/stopRecording.js.map +1 -1
- package/dist/utils/player.d.ts +30 -0
- package/dist/utils/player.d.ts.map +1 -0
- package/dist/utils/player.js +62 -0
- package/dist/utils/player.js.map +1 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
**An MCP server that lets an agent record the screen, _watch_ the footage, and make minimal ffmpeg edits — over stdio, on Windows.**
|
|
6
6
|
|
|
7
|
-
Capture the desktop, a monitor, a window, or a region; sample a recording into frames the agent can actually look at; trim, crop, scale, redact, annotate, zoom, and export. No cloud, no streaming — ffmpeg and ffprobe wrapped behind
|
|
7
|
+
Capture the desktop, a monitor, a window, or a region; sample a recording into frames the agent can actually look at; trim, crop, scale, redact, annotate, zoom, and export. No cloud, no streaming — ffmpeg and ffprobe wrapped behind forty-one typed tools.
|
|
8
8
|
|
|
9
9
|
<br />
|
|
10
10
|
|
|
@@ -59,6 +59,8 @@ Thirty-seven tools across four concerns. The manifest in [`mcp-tools.json`](mcp-
|
|
|
59
59
|
| `stop_recording` | Stop a session by id. Sends ffmpeg a graceful quit so the file is **finalized, not truncated**. Returns the final path and duration. |
|
|
60
60
|
| `list_sessions` | List active and finished sessions. |
|
|
61
61
|
| `get_session` | Inspect a single session by id. |
|
|
62
|
+
| `review_recording` | **Review player** in clients that support MCP Apps: an inline player where a person scrubs the recording, drags trim handles, and draws redaction boxes, then exports a trimmed, redacted copy (one `pipeline` call). `stop_recording` results open it too. Elsewhere it returns the video's details. |
|
|
63
|
+
| `player_frames` | Preview JPEG frames for the review player; called by the player (app-only), not by agents. |
|
|
62
64
|
| `read_events` | Read a recording's input event log (clicks, scroll, cursor, key presses) on the video's clock. Opt in with `start_recording` `events: true`. |
|
|
63
65
|
| `screenshot` | Capture a single PNG of a `target`, and return it inline as an image the model can view. |
|
|
64
66
|
| `list_audio_devices` | List the DirectShow audio devices ffmpeg can see and flag a likely system-audio loopback device for `start_recording`. |
|
|
@@ -248,7 +250,7 @@ It also offers **resources**, so a client can list and attach recordings without
|
|
|
248
250
|
- **Capture is always explicit.** Nothing auto-fires; capture is gated behind an explicit tool call.
|
|
249
251
|
- **Output stays local.** Files are written to the local filesystem only — never uploaded, streamed, or transmitted anywhere.
|
|
250
252
|
- **Public repo, private captures.** The `.gitignore` blocks recordings, frames, screenshots, and common video/image output so test media cannot be committed by accident.
|
|
251
|
-
- **Review before sharing.** Sample frames or inspect a recording before handing a file to another tool or person, so you know what it contains.
|
|
253
|
+
- **Review before sharing.** Sample frames or inspect a recording before handing a file to another tool or person, so you know what it contains. In clients that support MCP Apps, `stop_recording` and `review_recording` open an inline player where a person can scrub the whole recording and draw redaction boxes before anything leaves the machine. The player gets frames through the MCP connection; no local web server is started.
|
|
252
254
|
- **Redaction covers what you declare.** `redact_region` covers only the rectangles you specify. `find_text` can help find them: OCR with a query such as `regex: "sk-|ghp_|api.?key"` and `redact: true` returns ready-made rectangles. But OCR is best-effort; it can miss small or stylised text, so treat it as an aid, not a guarantee. Use the default `box` style for a solid irreversible fill, and still review the output before sharing.
|
|
253
255
|
- **The input event log never records what you type.** `start_recording` `events: true` hooks mouse and keyboard input for that recording only, in a helper that exits with it (or with the server). Keys are `masked` by default: the log says a key went down, not which. `keys: "shortcuts"` also names chords held with Ctrl, Alt, or Win (`Ctrl+S`); plain typing, Shift+letter, and AltGr characters stay masked, and no mode records text. Cursor positions and clicks still reveal what you pointed at, so treat `.events.jsonl` like the recording beside it.
|
|
254
256
|
- **System audio is sensitive too.** When `audio.source` = `system`, the recording captures everything playing on the machine (call audio, notifications, media). Treat audio-bearing recordings with the same care as the video.
|
|
@@ -0,0 +1,410 @@
|
|
|
1
|
+
<!doctype html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="utf-8">
|
|
5
|
+
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
6
|
+
<title>Review player</title>
|
|
7
|
+
<!--
|
|
8
|
+
screencast-mcp review player (#128): an MCP Apps view. The host renders it in
|
|
9
|
+
a sandboxed iframe for stop_recording / review_recording results. It talks to
|
|
10
|
+
the host with JSON-RPC over postMessage (ui/initialize, tool notifications,
|
|
11
|
+
tools/call), shows the recording as JPEG frames from player_frames, and sends
|
|
12
|
+
the person's trim and redaction back as one pipeline call. Self-contained: the
|
|
13
|
+
host's CSP allows no outside origins.
|
|
14
|
+
-->
|
|
15
|
+
<style>
|
|
16
|
+
:root {
|
|
17
|
+
color-scheme: dark;
|
|
18
|
+
--bg: #0A0D12; --panel: #11161E; --line: #232B36; --ink: #EAF0F6; --dim: #93A0AE;
|
|
19
|
+
--amber: #FFB454; --rec: #FF4545; --ok: #3FB950;
|
|
20
|
+
--mono: ui-monospace, "Cascadia Mono", "SF Mono", Menlo, Consolas, monospace;
|
|
21
|
+
--sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
|
|
22
|
+
}
|
|
23
|
+
:root[data-theme="light"] {
|
|
24
|
+
color-scheme: light;
|
|
25
|
+
--bg: #FFFFFF; --panel: #F4F6F9; --line: #D5DBE3; --ink: #0F141A; --dim: #5B6673;
|
|
26
|
+
--amber: #B4690E; --rec: #D92D2D; --ok: #1A7F37;
|
|
27
|
+
}
|
|
28
|
+
* { box-sizing: border-box; }
|
|
29
|
+
html, body { margin: 0; background: var(--bg); color: var(--ink); font: 14px/1.5 var(--sans); }
|
|
30
|
+
button { font: inherit; color: inherit; }
|
|
31
|
+
:focus-visible { outline: 2px solid var(--amber); outline-offset: 2px; }
|
|
32
|
+
.hud {
|
|
33
|
+
display: flex; align-items: center; gap: .6rem; flex-wrap: wrap;
|
|
34
|
+
padding: .55rem .9rem; border-bottom: 1px solid var(--line);
|
|
35
|
+
font: 12px/1.4 var(--mono); letter-spacing: .04em; color: var(--dim);
|
|
36
|
+
}
|
|
37
|
+
.dot { width: .6rem; height: .6rem; border-radius: 50%; background: var(--rec); }
|
|
38
|
+
.rec { color: var(--rec); font-weight: 600; }
|
|
39
|
+
#file { color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; min-width: 6rem; }
|
|
40
|
+
#tc { color: var(--ink); font-variant-numeric: tabular-nums; }
|
|
41
|
+
main { padding: .8rem .9rem 1rem; display: grid; gap: .7rem; }
|
|
42
|
+
.stage {
|
|
43
|
+
position: relative; background: #000; border: 1px solid var(--line); border-radius: 6px;
|
|
44
|
+
min-height: 120px; display: grid; place-items: center; overflow: hidden; touch-action: none;
|
|
45
|
+
}
|
|
46
|
+
.stage img { display: block; max-width: 100%; max-height: 60vh; user-select: none; -webkit-user-drag: none; }
|
|
47
|
+
.stage.drawing { cursor: crosshair; }
|
|
48
|
+
#empty { color: var(--dim); font: 12px var(--mono); padding: 2rem; text-align: center; }
|
|
49
|
+
.box { position: absolute; border: 2px solid var(--rec); background: color-mix(in srgb, var(--rec) 28%, transparent); pointer-events: none; }
|
|
50
|
+
.box.draft { border-style: dashed; }
|
|
51
|
+
.box span { position: absolute; top: -1.3rem; left: -2px; font: 11px var(--mono); background: var(--rec); color: #fff; padding: 0 .3rem; border-radius: 3px 3px 0 0; }
|
|
52
|
+
.controls, .row { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
|
|
53
|
+
.btn {
|
|
54
|
+
background: var(--panel); border: 1px solid var(--line); border-radius: 6px;
|
|
55
|
+
padding: .35rem .75rem; cursor: pointer; font: 12px var(--mono);
|
|
56
|
+
}
|
|
57
|
+
.btn:hover:not(:disabled) { border-color: var(--amber); }
|
|
58
|
+
.btn[aria-pressed="true"] { border-color: var(--rec); color: var(--rec); }
|
|
59
|
+
.btn.primary { background: var(--amber); color: #111; border-color: var(--amber); font-weight: 600; }
|
|
60
|
+
.btn:disabled { opacity: .45; cursor: default; }
|
|
61
|
+
#hint { color: var(--dim); font-size: 12px; }
|
|
62
|
+
.timeline { position: relative; height: 56px; border: 1px solid var(--line); border-radius: 6px; background: var(--panel); cursor: pointer; touch-action: none; }
|
|
63
|
+
#strip { position: absolute; inset: 0; display: flex; overflow: hidden; border-radius: 5px; opacity: .55; }
|
|
64
|
+
#strip img { height: 100%; flex: 1 1 0; min-width: 0; object-fit: cover; pointer-events: none; }
|
|
65
|
+
.shade { position: absolute; top: 0; bottom: 0; background: color-mix(in srgb, var(--bg) 70%, transparent); pointer-events: none; }
|
|
66
|
+
#head { position: absolute; top: -4px; bottom: -4px; width: 2px; background: var(--ink); pointer-events: none; }
|
|
67
|
+
.handle {
|
|
68
|
+
position: absolute; top: -6px; bottom: -6px; width: 14px; margin-left: -7px; padding: 0;
|
|
69
|
+
background: var(--amber); border: 0; border-radius: 4px; cursor: ew-resize;
|
|
70
|
+
}
|
|
71
|
+
.handle::after { content: ""; position: absolute; inset: 40% 5px; border-left: 2px solid #111; border-right: 2px solid #111; }
|
|
72
|
+
.times { font: 12px var(--mono); color: var(--dim); gap: 1.2rem; }
|
|
73
|
+
.times b { color: var(--amber); font-weight: 500; }
|
|
74
|
+
#boxList { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: .4rem; }
|
|
75
|
+
#boxList li { font: 12px var(--mono); border: 1px solid var(--line); border-radius: 6px; padding: .15rem .2rem .15rem .55rem; display: flex; gap: .4rem; align-items: center; }
|
|
76
|
+
#boxList button { border: 0; background: none; color: var(--dim); cursor: pointer; padding: 0 .3rem; }
|
|
77
|
+
#boxList button:hover { color: var(--rec); }
|
|
78
|
+
#status { font: 12px var(--mono); color: var(--dim); overflow-wrap: anywhere; }
|
|
79
|
+
#status.ok { color: var(--ok); }
|
|
80
|
+
#status.err { color: var(--rec); }
|
|
81
|
+
@media (prefers-reduced-motion: reduce) { .dot { animation: none; } }
|
|
82
|
+
</style>
|
|
83
|
+
</head>
|
|
84
|
+
<body>
|
|
85
|
+
<header class="hud" aria-label="Recording">
|
|
86
|
+
<span class="dot" aria-hidden="true"></span><span class="rec">REVIEW</span>
|
|
87
|
+
<span id="file">waiting for a recording</span>
|
|
88
|
+
<span id="tc">00:00.0 / 00:00.0</span>
|
|
89
|
+
</header>
|
|
90
|
+
<main>
|
|
91
|
+
<div class="stage" id="stage">
|
|
92
|
+
<div id="empty">Loading the recording...</div>
|
|
93
|
+
<img id="frame" alt="" hidden>
|
|
94
|
+
</div>
|
|
95
|
+
<div class="controls">
|
|
96
|
+
<button class="btn" id="play" type="button" disabled>Play</button>
|
|
97
|
+
<button class="btn" id="draw" type="button" aria-pressed="false" disabled>Draw redaction box</button>
|
|
98
|
+
<span id="hint">Drag the amber handles to trim. Draw boxes over anything secret.</span>
|
|
99
|
+
</div>
|
|
100
|
+
<div class="timeline" id="timeline" role="group" aria-label="Timeline: click to seek">
|
|
101
|
+
<div id="strip"></div>
|
|
102
|
+
<div class="shade" id="shadeIn"></div><div class="shade" id="shadeOut"></div>
|
|
103
|
+
<div id="head"></div>
|
|
104
|
+
<button class="handle" id="hIn" type="button" aria-label="Trim start (arrow keys move one frame)"></button>
|
|
105
|
+
<button class="handle" id="hOut" type="button" aria-label="Trim end (arrow keys move one frame)"></button>
|
|
106
|
+
</div>
|
|
107
|
+
<div class="row times"><span>IN <b id="inT">0.0s</b></span><span>OUT <b id="outT">0.0s</b></span><span id="lenT"></span></div>
|
|
108
|
+
<ul id="boxList" aria-label="Redaction boxes"></ul>
|
|
109
|
+
<div class="row">
|
|
110
|
+
<button class="btn primary" id="apply" type="button" disabled>Export trimmed + redacted copy</button>
|
|
111
|
+
<button class="btn" id="openResult" type="button" hidden>Review the result</button>
|
|
112
|
+
<span id="status" role="status"></span>
|
|
113
|
+
</div>
|
|
114
|
+
</main>
|
|
115
|
+
<script>
|
|
116
|
+
(() => {
|
|
117
|
+
"use strict";
|
|
118
|
+
const $ = (id) => document.getElementById(id);
|
|
119
|
+
const PROTOCOL = "2026-01-26";
|
|
120
|
+
|
|
121
|
+
// --- JSON-RPC over postMessage with the host ---------------------------
|
|
122
|
+
let nextId = 1;
|
|
123
|
+
const pending = new Map();
|
|
124
|
+
const send = (msg) => window.parent.postMessage({ jsonrpc: "2.0", ...msg }, "*");
|
|
125
|
+
const request = (method, params) =>
|
|
126
|
+
new Promise((resolve, reject) => {
|
|
127
|
+
const id = nextId++;
|
|
128
|
+
pending.set(id, { resolve, reject });
|
|
129
|
+
send({ id, method, params });
|
|
130
|
+
});
|
|
131
|
+
const notify = (method, params) => send({ method, params });
|
|
132
|
+
|
|
133
|
+
window.addEventListener("message", (e) => {
|
|
134
|
+
if (e.source !== window.parent) return;
|
|
135
|
+
const m = e.data;
|
|
136
|
+
if (!m || m.jsonrpc !== "2.0") return;
|
|
137
|
+
if (m.id !== undefined && !m.method) {
|
|
138
|
+
const p = pending.get(m.id);
|
|
139
|
+
if (!p) return;
|
|
140
|
+
pending.delete(m.id);
|
|
141
|
+
m.error ? p.reject(new Error(m.error.message || "request failed")) : p.resolve(m.result);
|
|
142
|
+
return;
|
|
143
|
+
}
|
|
144
|
+
if (m.id !== undefined) {
|
|
145
|
+
// A request from the host.
|
|
146
|
+
if (m.method === "ui/resource-teardown" || m.method === "ping") send({ id: m.id, result: {} });
|
|
147
|
+
else send({ id: m.id, error: { code: -32601, message: `Unsupported: ${m.method}` } });
|
|
148
|
+
return;
|
|
149
|
+
}
|
|
150
|
+
if (m.method === "ui/notifications/tool-input") onToolInput(m.params?.arguments || {});
|
|
151
|
+
else if (m.method === "ui/notifications/tool-result") onToolResult(m.params || {});
|
|
152
|
+
else if (m.method === "ui/notifications/host-context-changed") applyHostContext(m.params || {});
|
|
153
|
+
else if (m.method === "ui/notifications/tool-cancelled") setEmpty("The tool call was cancelled.");
|
|
154
|
+
});
|
|
155
|
+
|
|
156
|
+
const applyHostContext = (ctx) => {
|
|
157
|
+
if (ctx && (ctx.theme === "light" || ctx.theme === "dark")) document.documentElement.dataset.theme = ctx.theme;
|
|
158
|
+
};
|
|
159
|
+
const callTool = async (name, args) => {
|
|
160
|
+
const r = await request("tools/call", { name, arguments: args });
|
|
161
|
+
if (r && r.isError) throw new Error((r.content || []).map((c) => c.text).filter(Boolean).join(" ") || `${name} failed`);
|
|
162
|
+
return r;
|
|
163
|
+
};
|
|
164
|
+
const resultJson = (r) => {
|
|
165
|
+
const t = (r?.content || []).find((c) => c.type === "text");
|
|
166
|
+
try { return t ? JSON.parse(t.text) : null; } catch { return null; }
|
|
167
|
+
};
|
|
168
|
+
|
|
169
|
+
// --- state ---------------------------------------------------------------
|
|
170
|
+
const S = { input: null, duration: 0, W: 0, H: 0, frames: [], times: [], i: 0, inI: 0, outI: 0, boxes: [], drawing: false, playing: null };
|
|
171
|
+
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")}`; };
|
|
172
|
+
const sliceStart = (i) => (i * S.duration) / S.frames.length;
|
|
173
|
+
const sliceEnd = (i) => ((i + 1) * S.duration) / S.frames.length;
|
|
174
|
+
const setEmpty = (text) => { $("empty").textContent = text; $("empty").hidden = false; };
|
|
175
|
+
const status = (text, kind) => { const s = $("status"); s.textContent = text; s.className = kind || ""; };
|
|
176
|
+
|
|
177
|
+
function onToolInput(args) {
|
|
178
|
+
if (args.input) $("file").textContent = args.input;
|
|
179
|
+
}
|
|
180
|
+
function onToolResult(result) {
|
|
181
|
+
if (result.isError) return setEmpty((result.content || []).map((c) => c.text).join(" ") || "The tool failed.");
|
|
182
|
+
const j = resultJson(result);
|
|
183
|
+
const input = j && (j.outputPath || j.input);
|
|
184
|
+
if (!input) return setEmpty("No video in this result.");
|
|
185
|
+
load(input);
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
async function load(input) {
|
|
189
|
+
S.input = input;
|
|
190
|
+
S.boxes = [];
|
|
191
|
+
$("file").textContent = input.split(/[\\/]/).pop();
|
|
192
|
+
$("file").title = input;
|
|
193
|
+
setEmpty("Loading frames...");
|
|
194
|
+
status("");
|
|
195
|
+
try {
|
|
196
|
+
const r = await callTool("player_frames", { input });
|
|
197
|
+
const meta = resultJson(r);
|
|
198
|
+
S.frames = (r.content || []).filter((c) => c.type === "image").map((c) => `data:${c.mimeType};base64,${c.data}`);
|
|
199
|
+
if (!meta || S.frames.length === 0) throw new Error("No frames came back.");
|
|
200
|
+
Object.assign(S, { duration: meta.durationSec, W: meta.width, H: meta.height, times: meta.frameTimes, i: 0, inI: 0, outI: S.frames.length - 1 });
|
|
201
|
+
} catch (err) {
|
|
202
|
+
return setEmpty(`Could not load the recording: ${err.message}`);
|
|
203
|
+
}
|
|
204
|
+
$("empty").hidden = true;
|
|
205
|
+
$("frame").hidden = false;
|
|
206
|
+
// A strip of up to 40 evenly chosen thumbnails.
|
|
207
|
+
const strip = $("strip");
|
|
208
|
+
strip.replaceChildren();
|
|
209
|
+
const n = Math.min(40, S.frames.length);
|
|
210
|
+
for (let k = 0; k < n; k++) {
|
|
211
|
+
const img = document.createElement("img");
|
|
212
|
+
img.alt = "";
|
|
213
|
+
img.src = S.frames[Math.floor((k * S.frames.length) / n)];
|
|
214
|
+
strip.appendChild(img);
|
|
215
|
+
}
|
|
216
|
+
["play", "draw"].forEach((id) => ($(id).disabled = false));
|
|
217
|
+
show(0);
|
|
218
|
+
render();
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
function show(i) {
|
|
222
|
+
S.i = Math.max(0, Math.min(S.frames.length - 1, i));
|
|
223
|
+
$("frame").src = S.frames[S.i];
|
|
224
|
+
$("tc").textContent = `${fmt(S.times[S.i] || 0)} / ${fmt(S.duration)}`;
|
|
225
|
+
$("head").style.left = `${((S.i + 0.5) / S.frames.length) * 100}%`;
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
function render() {
|
|
229
|
+
const n = S.frames.length || 1;
|
|
230
|
+
const a = (S.inI / n) * 100, b = ((S.outI + 1) / n) * 100;
|
|
231
|
+
$("hIn").style.left = `${a}%`;
|
|
232
|
+
$("hOut").style.left = `${b}%`;
|
|
233
|
+
$("shadeIn").style.cssText = `left:0;width:${a}%`;
|
|
234
|
+
$("shadeOut").style.cssText = `left:${b}%;right:0`;
|
|
235
|
+
const tin = sliceStart(S.inI), tout = sliceEnd(S.outI);
|
|
236
|
+
$("inT").textContent = `${tin.toFixed(1)}s`;
|
|
237
|
+
$("outT").textContent = `${tout.toFixed(1)}s`;
|
|
238
|
+
$("lenT").textContent = `${(tout - tin).toFixed(1)}s kept`;
|
|
239
|
+
renderBoxes();
|
|
240
|
+
const trimmed = S.inI > 0 || S.outI < S.frames.length - 1;
|
|
241
|
+
$("apply").disabled = !S.input || (!trimmed && S.boxes.length === 0);
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
// --- timeline: seek and trim handles ----------------------------------
|
|
245
|
+
const tl = $("timeline");
|
|
246
|
+
const indexAt = (clientX) => {
|
|
247
|
+
const r = tl.getBoundingClientRect();
|
|
248
|
+
return Math.floor(((clientX - r.left) / r.width) * S.frames.length);
|
|
249
|
+
};
|
|
250
|
+
let dragging = null;
|
|
251
|
+
tl.addEventListener("pointerdown", (e) => {
|
|
252
|
+
if (!S.frames.length) return;
|
|
253
|
+
dragging = e.target === $("hIn") ? "in" : e.target === $("hOut") ? "out" : "seek";
|
|
254
|
+
tl.setPointerCapture(e.pointerId);
|
|
255
|
+
move(e);
|
|
256
|
+
});
|
|
257
|
+
tl.addEventListener("pointermove", (e) => dragging && move(e));
|
|
258
|
+
tl.addEventListener("pointerup", () => (dragging = null));
|
|
259
|
+
function move(e) {
|
|
260
|
+
const i = Math.max(0, Math.min(S.frames.length - 1, indexAt(e.clientX)));
|
|
261
|
+
if (dragging === "in") S.inI = Math.min(i, S.outI);
|
|
262
|
+
else if (dragging === "out") S.outI = Math.max(i, S.inI);
|
|
263
|
+
show(i);
|
|
264
|
+
render();
|
|
265
|
+
}
|
|
266
|
+
for (const [id, key] of [["hIn", "inI"], ["hOut", "outI"]]) {
|
|
267
|
+
$(id).addEventListener("keydown", (e) => {
|
|
268
|
+
const d = e.key === "ArrowLeft" ? -1 : e.key === "ArrowRight" ? 1 : 0;
|
|
269
|
+
if (!d) return;
|
|
270
|
+
e.preventDefault();
|
|
271
|
+
const v = S[key] + d;
|
|
272
|
+
if (key === "inI") S.inI = Math.max(0, Math.min(v, S.outI));
|
|
273
|
+
else S.outI = Math.min(S.frames.length - 1, Math.max(v, S.inI));
|
|
274
|
+
show(S[key]);
|
|
275
|
+
render();
|
|
276
|
+
});
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
// --- playback: a flipbook over the kept range ---------------------------
|
|
280
|
+
$("play").addEventListener("click", () => {
|
|
281
|
+
if (S.playing) return stop();
|
|
282
|
+
$("play").textContent = "Pause";
|
|
283
|
+
let i = S.i < S.inI || S.i >= S.outI ? S.inI : S.i;
|
|
284
|
+
const ms = (S.duration / S.frames.length) * 1000;
|
|
285
|
+
S.playing = setInterval(() => {
|
|
286
|
+
show(i);
|
|
287
|
+
i = i >= S.outI ? S.inI : i + 1;
|
|
288
|
+
}, ms);
|
|
289
|
+
});
|
|
290
|
+
function stop() {
|
|
291
|
+
clearInterval(S.playing);
|
|
292
|
+
S.playing = null;
|
|
293
|
+
$("play").textContent = "Play";
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
// --- redaction boxes, in video pixels -----------------------------------
|
|
297
|
+
const stage = $("stage"), img = $("frame");
|
|
298
|
+
$("draw").addEventListener("click", () => {
|
|
299
|
+
S.drawing = !S.drawing;
|
|
300
|
+
$("draw").setAttribute("aria-pressed", String(S.drawing));
|
|
301
|
+
stage.classList.toggle("drawing", S.drawing);
|
|
302
|
+
});
|
|
303
|
+
const toVideo = (clientX, clientY) => {
|
|
304
|
+
const r = img.getBoundingClientRect();
|
|
305
|
+
return {
|
|
306
|
+
x: Math.max(0, Math.min(S.W, ((clientX - r.left) / r.width) * S.W)),
|
|
307
|
+
y: Math.max(0, Math.min(S.H, ((clientY - r.top) / r.height) * S.H)),
|
|
308
|
+
};
|
|
309
|
+
};
|
|
310
|
+
let start = null, draft = null;
|
|
311
|
+
stage.addEventListener("pointerdown", (e) => {
|
|
312
|
+
if (!S.drawing || !S.frames.length) return;
|
|
313
|
+
start = toVideo(e.clientX, e.clientY);
|
|
314
|
+
stage.setPointerCapture(e.pointerId);
|
|
315
|
+
draft = document.createElement("div");
|
|
316
|
+
draft.className = "box draft";
|
|
317
|
+
stage.appendChild(draft);
|
|
318
|
+
});
|
|
319
|
+
stage.addEventListener("pointermove", (e) => {
|
|
320
|
+
if (!start) return;
|
|
321
|
+
placeBox(draft, rectOf(start, toVideo(e.clientX, e.clientY)));
|
|
322
|
+
});
|
|
323
|
+
stage.addEventListener("pointerup", (e) => {
|
|
324
|
+
if (!start) return;
|
|
325
|
+
const r = rectOf(start, toVideo(e.clientX, e.clientY));
|
|
326
|
+
start = null;
|
|
327
|
+
draft.remove();
|
|
328
|
+
if (r.width >= 4 && r.height >= 4) S.boxes.push(r);
|
|
329
|
+
render();
|
|
330
|
+
});
|
|
331
|
+
const rectOf = (a, b) => {
|
|
332
|
+
const x = Math.floor(Math.min(a.x, b.x)), y = Math.floor(Math.min(a.y, b.y));
|
|
333
|
+
return { x, y, width: Math.ceil(Math.max(a.x, b.x)) - x, height: Math.ceil(Math.max(a.y, b.y)) - y };
|
|
334
|
+
};
|
|
335
|
+
function placeBox(el, r) {
|
|
336
|
+
const ir = img.getBoundingClientRect(), sr = stage.getBoundingClientRect();
|
|
337
|
+
const k = ir.width / S.W;
|
|
338
|
+
el.style.left = `${ir.left - sr.left + r.x * k}px`;
|
|
339
|
+
el.style.top = `${ir.top - sr.top + r.y * k}px`;
|
|
340
|
+
el.style.width = `${r.width * k}px`;
|
|
341
|
+
el.style.height = `${r.height * k}px`;
|
|
342
|
+
}
|
|
343
|
+
function renderBoxes() {
|
|
344
|
+
stage.querySelectorAll(".box:not(.draft)").forEach((b) => b.remove());
|
|
345
|
+
const list = $("boxList");
|
|
346
|
+
list.replaceChildren();
|
|
347
|
+
S.boxes.forEach((r, n) => {
|
|
348
|
+
const el = document.createElement("div");
|
|
349
|
+
el.className = "box";
|
|
350
|
+
el.innerHTML = `<span>${n + 1}</span>`;
|
|
351
|
+
stage.appendChild(el);
|
|
352
|
+
placeBox(el, r);
|
|
353
|
+
const li = document.createElement("li");
|
|
354
|
+
li.textContent = `#${n + 1} ${r.width}\u00d7${r.height} at ${r.x},${r.y}`;
|
|
355
|
+
const rm = document.createElement("button");
|
|
356
|
+
rm.type = "button";
|
|
357
|
+
rm.textContent = "\u2715";
|
|
358
|
+
rm.setAttribute("aria-label", `Remove box ${n + 1}`);
|
|
359
|
+
rm.addEventListener("click", () => { S.boxes.splice(n, 1); render(); });
|
|
360
|
+
li.appendChild(rm);
|
|
361
|
+
list.appendChild(li);
|
|
362
|
+
});
|
|
363
|
+
}
|
|
364
|
+
img.addEventListener("load", renderBoxes);
|
|
365
|
+
new ResizeObserver(renderBoxes).observe(stage);
|
|
366
|
+
|
|
367
|
+
// --- export: one pipeline call -----------------------------------------
|
|
368
|
+
$("apply").addEventListener("click", async () => {
|
|
369
|
+
stop();
|
|
370
|
+
const steps = [];
|
|
371
|
+
// Redact first, so a box covers every frame of the kept range.
|
|
372
|
+
if (S.boxes.length) steps.push({ op: "redact", regions: S.boxes.map((b) => ({ ...b })) });
|
|
373
|
+
const tin = Math.round(sliceStart(S.inI) * 1000) / 1000, tout = Math.round(sliceEnd(S.outI) * 1000) / 1000;
|
|
374
|
+
if (S.inI > 0 || S.outI < S.frames.length - 1) steps.push({ op: "trim", start: tin, end: Math.min(tout, S.duration) });
|
|
375
|
+
$("apply").disabled = true;
|
|
376
|
+
status("Exporting...");
|
|
377
|
+
try {
|
|
378
|
+
const out = resultJson(await callTool("pipeline", { input: S.input, steps }));
|
|
379
|
+
S.result = out.outputPath;
|
|
380
|
+
status(`Saved ${S.result}`, "ok");
|
|
381
|
+
$("openResult").hidden = false;
|
|
382
|
+
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(", ");
|
|
383
|
+
// Tell the agent what the person did; the host includes it on the next turn.
|
|
384
|
+
request("ui/update-model-context", {
|
|
385
|
+
content: [{ type: "text", text: `In the review player the user exported ${S.input}, ${what}, to ${S.result}.` }],
|
|
386
|
+
structuredContent: { input: S.input, output: S.result, steps },
|
|
387
|
+
}).catch(() => {});
|
|
388
|
+
} catch (err) {
|
|
389
|
+
status(`Export failed: ${err.message}`, "err");
|
|
390
|
+
} finally {
|
|
391
|
+
render();
|
|
392
|
+
}
|
|
393
|
+
});
|
|
394
|
+
$("openResult").addEventListener("click", () => {
|
|
395
|
+
$("openResult").hidden = true;
|
|
396
|
+
load(S.result);
|
|
397
|
+
});
|
|
398
|
+
|
|
399
|
+
// --- start ---------------------------------------------------------------
|
|
400
|
+
new ResizeObserver(() => notify("ui/notifications/size-changed", { height: Math.ceil(document.documentElement.scrollHeight) })).observe(document.body);
|
|
401
|
+
request("ui/initialize", { appInfo: { name: "screencast-review-player", version: "1.0.0" }, appCapabilities: {}, protocolVersion: PROTOCOL })
|
|
402
|
+
.then((r) => {
|
|
403
|
+
applyHostContext(r && r.hostContext);
|
|
404
|
+
notify("ui/notifications/initialized", {});
|
|
405
|
+
})
|
|
406
|
+
.catch((err) => setEmpty(`The host did not start the player: ${err.message}`));
|
|
407
|
+
})();
|
|
408
|
+
</script>
|
|
409
|
+
</body>
|
|
410
|
+
</html>
|
package/dist/index.js
CHANGED
|
@@ -19,6 +19,7 @@ import { register as registerStopRecording } from "./tools/stopRecording.js";
|
|
|
19
19
|
import { register as registerListSessions } from "./tools/listSessions.js";
|
|
20
20
|
import { register as registerGetSession } from "./tools/getSession.js";
|
|
21
21
|
import { register as registerReadEvents } from "./tools/readEvents.js";
|
|
22
|
+
import { register as registerReviewRecording } from "./tools/reviewRecording.js";
|
|
22
23
|
import { register as registerScreenshot } from "./tools/screenshot.js";
|
|
23
24
|
import { register as registerSampleFrames } from "./tools/sampleFrames.js";
|
|
24
25
|
import { register as registerContactSheet } from "./tools/contactSheet.js";
|
|
@@ -68,6 +69,7 @@ registerStopRecording(server);
|
|
|
68
69
|
registerListSessions(server);
|
|
69
70
|
registerGetSession(server);
|
|
70
71
|
registerReadEvents(server);
|
|
72
|
+
registerReviewRecording(server);
|
|
71
73
|
registerScreenshot(server);
|
|
72
74
|
registerSampleFrames(server);
|
|
73
75
|
registerContactSheet(server);
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AACA;;;;;;;;GAQG;AACH,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AACpE,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAC;AAEjF,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AACxC,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAClD,OAAO,EAAE,aAAa,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAC9D,OAAO,EAAE,QAAQ,IAAI,sBAAsB,EAAE,MAAM,2BAA2B,CAAC;AAC/E,OAAO,EAAE,QAAQ,IAAI,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;AAC7E,OAAO,EAAE,QAAQ,IAAI,oBAAoB,EAAE,MAAM,yBAAyB,CAAC;AAC3E,OAAO,EAAE,QAAQ,IAAI,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AACvE,OAAO,EAAE,QAAQ,IAAI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EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,CAC/D,CAAC;YACF,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,aAAa,MAAM,cAAc,OAAO,CAAC,MAAM,kBAAkB,CAAC,CAAC;QAC1F,CAAC;IACH,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,OAAO,CAAC,MAAM,CAAC,KAAK,CAClB,4BAA4B,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,IAAI,CACjF,CAAC;IACJ,CAAC;IACD,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC;AAED,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC,KAAc,EAAE,EAAE;IAC9B,OAAO,CAAC,MAAM,CAAC,KAAK,CAClB,gBAAgB,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAC3E,CAAC;IACF,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
2
|
+
/** The player page, shipped in assets/ui (dist/tools -> ../../assets). */
|
|
3
|
+
export declare function playerHtml(): string;
|
|
4
|
+
export declare function register(server: McpServer): void;
|
|
5
|
+
//# sourceMappingURL=reviewRecording.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reviewRecording.d.ts","sourceRoot":"","sources":["../../src/tools/reviewRecording.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAkBzE,0EAA0E;AAC1E,wBAAgB,UAAU,IAAI,MAAM,CAEnC;AAaD,wBAAgB,QAAQ,CAAC,MAAM,EAAE,SAAS,GAAG,IAAI,CAoGhD"}
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { existsSync, readFileSync } from "node:fs";
|
|
3
|
+
import { fileURLToPath } from "node:url";
|
|
4
|
+
import { errorResponse, okResponse, ScreencastError } from "../utils/errors.js";
|
|
5
|
+
import { requireFfmpeg, probeMedia, runFfmpegBuffer } from "../utils/ffmpeg.js";
|
|
6
|
+
import { jobTimeoutMs } from "../utils/jobs.js";
|
|
7
|
+
import { buildPlayerFramesArgs, playerFramePlan, playerFrameTimes, splitJpegs, DEFAULT_PLAYER_FRAMES, DEFAULT_PLAYER_WIDTH, MAX_PLAYER_FRAMES, MCP_APP_MIME, PLAYER_TOOL_META, PLAYER_URI, } from "../utils/player.js";
|
|
8
|
+
import { getStore } from "../context.js";
|
|
9
|
+
/** The player page, shipped in assets/ui (dist/tools -> ../../assets). */
|
|
10
|
+
export function playerHtml() {
|
|
11
|
+
return readFileSync(fileURLToPath(new URL("../../assets/ui/player.html", import.meta.url)), "utf8");
|
|
12
|
+
}
|
|
13
|
+
function resolveInput(args) {
|
|
14
|
+
if (args.sessionId) {
|
|
15
|
+
const record = getStore().get(args.sessionId);
|
|
16
|
+
if (!record)
|
|
17
|
+
throw new ScreencastError(`No session with id "${args.sessionId}".`);
|
|
18
|
+
if (record.status === "recording")
|
|
19
|
+
throw new ScreencastError("The recording is still running; stop it first.");
|
|
20
|
+
return record.outputPath;
|
|
21
|
+
}
|
|
22
|
+
if (args.input)
|
|
23
|
+
return args.input;
|
|
24
|
+
throw new ScreencastError("Pass input or sessionId.");
|
|
25
|
+
}
|
|
26
|
+
export function register(server) {
|
|
27
|
+
// The player page itself, for hosts that support MCP Apps.
|
|
28
|
+
server.registerResource("review-player", PLAYER_URI, {
|
|
29
|
+
title: "Recording review player",
|
|
30
|
+
description: "Interactive player: scrub, trim, and draw redaction boxes on a recording.",
|
|
31
|
+
mimeType: MCP_APP_MIME,
|
|
32
|
+
}, async () => ({
|
|
33
|
+
contents: [{ uri: PLAYER_URI, mimeType: MCP_APP_MIME, text: playerHtml(), _meta: { ui: { prefersBorder: true } } }],
|
|
34
|
+
}));
|
|
35
|
+
server.registerTool("review_recording", {
|
|
36
|
+
description: "Open a recording for a person to review. In clients that support MCP Apps it shows an " +
|
|
37
|
+
"inline player: scrub the timeline, drag trim handles, and draw redaction boxes, then export " +
|
|
38
|
+
"a trimmed, redacted copy (their choices run as a pipeline call). Elsewhere it returns the " +
|
|
39
|
+
"video's details; use contact_sheet or sample_frames to look at it.",
|
|
40
|
+
inputSchema: {
|
|
41
|
+
input: z.string().optional().describe("Path to the video."),
|
|
42
|
+
sessionId: z.string().optional().describe("Or the session id of a stopped recording."),
|
|
43
|
+
},
|
|
44
|
+
_meta: PLAYER_TOOL_META,
|
|
45
|
+
}, async (args) => {
|
|
46
|
+
try {
|
|
47
|
+
requireFfmpeg();
|
|
48
|
+
const input = resolveInput(args);
|
|
49
|
+
if (!existsSync(input))
|
|
50
|
+
throw new ScreencastError(`Input file not found: ${input}`);
|
|
51
|
+
const info = await probeMedia(input);
|
|
52
|
+
return okResponse({
|
|
53
|
+
input,
|
|
54
|
+
durationSec: info.durationSec,
|
|
55
|
+
width: info.width,
|
|
56
|
+
height: info.height,
|
|
57
|
+
fps: info.fps,
|
|
58
|
+
hasAudio: info.audioCodec !== null,
|
|
59
|
+
note: "Clients with MCP Apps show an inline review player for this result. Without it, " +
|
|
60
|
+
"look with contact_sheet or sample_frames, then trim and redact with pipeline.",
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
catch (error) {
|
|
64
|
+
return errorResponse(error);
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
// Called by the player (app visibility only), not by the model.
|
|
68
|
+
server.registerTool("player_frames", {
|
|
69
|
+
description: "Preview frames for the review player: JPEGs spread evenly over the video, with their times. " +
|
|
70
|
+
"Used by the inline player; agents should use sample_frames or contact_sheet instead.",
|
|
71
|
+
inputSchema: {
|
|
72
|
+
input: z.string().min(1).describe("Path to the video."),
|
|
73
|
+
maxFrames: z.number().int().min(1).max(MAX_PLAYER_FRAMES).optional().describe(`Most frames (default ${DEFAULT_PLAYER_FRAMES}).`),
|
|
74
|
+
width: z.number().int().min(64).max(1280).optional().describe(`Frame width (default ${DEFAULT_PLAYER_WIDTH}).`),
|
|
75
|
+
},
|
|
76
|
+
_meta: { ui: { visibility: ["app"] } },
|
|
77
|
+
}, async (args) => {
|
|
78
|
+
try {
|
|
79
|
+
requireFfmpeg();
|
|
80
|
+
if (!existsSync(args.input))
|
|
81
|
+
throw new ScreencastError(`Input file not found: ${args.input}`);
|
|
82
|
+
const info = await probeMedia(args.input);
|
|
83
|
+
const durationSec = info.durationSec ?? 0;
|
|
84
|
+
const { count, fps } = playerFramePlan(durationSec, args.maxFrames ?? DEFAULT_PLAYER_FRAMES);
|
|
85
|
+
const raw = await runFfmpegBuffer(buildPlayerFramesArgs(args.input, fps, args.width ?? DEFAULT_PLAYER_WIDTH, count), jobTimeoutMs(durationSec));
|
|
86
|
+
const jpegs = splitJpegs(raw);
|
|
87
|
+
const times = playerFrameTimes(durationSec, jpegs.length);
|
|
88
|
+
return {
|
|
89
|
+
content: [
|
|
90
|
+
{
|
|
91
|
+
type: "text",
|
|
92
|
+
text: JSON.stringify({
|
|
93
|
+
input: args.input,
|
|
94
|
+
durationSec,
|
|
95
|
+
width: info.width,
|
|
96
|
+
height: info.height,
|
|
97
|
+
hasAudio: info.audioCodec !== null,
|
|
98
|
+
frameTimes: times,
|
|
99
|
+
}),
|
|
100
|
+
},
|
|
101
|
+
...jpegs.map((j) => ({ type: "image", data: j.toString("base64"), mimeType: "image/jpeg" })),
|
|
102
|
+
],
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
catch (error) {
|
|
106
|
+
return errorResponse(error);
|
|
107
|
+
}
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
//# sourceMapping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AC;QACJ,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,OAAO,aAAa,CAAC,KAAK,CAAC,CAAC;QAC9B,CAAC;IACH,CAAC,CACF,CAAC;AACJ,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stopRecording.d.ts","sourceRoot":"","sources":["../../src/tools/stopRecording.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;
|
|
1
|
+
{"version":3,"file":"stopRecording.d.ts","sourceRoot":"","sources":["../../src/tools/stopRecording.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAWzE,wBAAgB,QAAQ,CAAC,MAAM,EAAE,SAAS,GAAG,IAAI,CA6DhD"}
|
|
@@ -4,14 +4,21 @@ import { errorResponse, okResponse, ScreencastError } from "../utils/errors.js";
|
|
|
4
4
|
import { requireFfmpeg } from "../utils/ffmpeg.js";
|
|
5
5
|
import { probeDuration, stopSession } from "../utils/lifecycle.js";
|
|
6
6
|
import { getStore } from "../context.js";
|
|
7
|
+
import { PLAYER_TOOL_META } from "../utils/player.js";
|
|
7
8
|
const inputSchema = {
|
|
8
9
|
sessionId: z.string().min(1).describe("Session id returned by start_recording."),
|
|
9
10
|
};
|
|
10
11
|
export function register(server) {
|
|
11
|
-
server.
|
|
12
|
-
"
|
|
13
|
-
|
|
14
|
-
|
|
12
|
+
server.registerTool("stop_recording", {
|
|
13
|
+
description: "Stop a recording by session id. Sends ffmpeg a graceful quit so the file " +
|
|
14
|
+
"is finalized rather than truncated, then returns the final path and " +
|
|
15
|
+
"duration. Falls back to terminating the process by pid if the live " +
|
|
16
|
+
"handle was lost (for example after a server restart). Clients with MCP " +
|
|
17
|
+
"Apps show the review player for the result.",
|
|
18
|
+
inputSchema,
|
|
19
|
+
// The review player (#128) renders for this result in Apps-capable hosts.
|
|
20
|
+
_meta: PLAYER_TOOL_META,
|
|
21
|
+
}, async (args) => {
|
|
15
22
|
try {
|
|
16
23
|
const store = getStore();
|
|
17
24
|
const record = store.get(args.sessionId);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stopRecording.js","sourceRoot":"","sources":["../../src/tools/stopRecording.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAErC,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAChF,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACnE,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"stopRecording.js","sourceRoot":"","sources":["../../src/tools/stopRecording.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAErC,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAChF,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACnE,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAEtD,MAAM,WAAW,GAAG;IAClB,SAAS,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,yCAAyC,CAAC;CACjF,CAAC;AAEF,MAAM,UAAU,QAAQ,CAAC,MAAiB;IACxC,MAAM,CAAC,YAAY,CACjB,gBAAgB,EAChB;QACE,WAA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EAAE;gBACpB,MAAM,EAAE,SAAS;gBACjB,UAAU,EAAE,MAAM,CAAC,UAAU;gBAC7B,WAAW,EAAE,WAAW,IAAI,IAAI;gBAChC,mBAAmB,EAAE,QAAQ;gBAC7B,GAAG,CAAC,OAAO,EAAE,MAAM;oBACjB,CAAC,CAAC,EAAE,UAAU,EAAE,OAAO,CAAC,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,MAAM,CAAC,OAAO,IAAI,EAAE,EAAE,GAAG,CAAC,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,WAAW,EAAE,OAAO,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE;oBACnJ,CAAC,CAAC,EAAE,CAAC;gBACP,UAAU,EAAE,UAAU,CAAC,MAAM,CAAC,UAAU,CAAC;gBACzC,IAAI,EAAE,QAAQ;oBACZ,CAAC,CAAC,sCAAsC;oBACxC,CAAC,CAAC,oEAAoE;gBACxE,MAAM,EAAE,OAAO;aAChB,CAAC,CAAC;QACL,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,OAAO,aAAa,CAAC,KAAK,CAAC,CAAC;QAC9B,CAAC;IACH,CAAC,CACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/** The MCP Apps resource the player is served as, and its MIME type. */
|
|
2
|
+
export declare const PLAYER_URI = "ui://screencast/player";
|
|
3
|
+
export declare const MCP_APP_MIME = "text/html;profile=mcp-app";
|
|
4
|
+
/** Tool _meta that tells an Apps host to render the player for a tool's
|
|
5
|
+
* result. Both the current and the legacy key, as the spec asks hosts to read. */
|
|
6
|
+
export declare const PLAYER_TOOL_META: {
|
|
7
|
+
readonly ui: {
|
|
8
|
+
readonly resourceUri: "ui://screencast/player";
|
|
9
|
+
};
|
|
10
|
+
readonly "ui/resourceUri": "ui://screencast/player";
|
|
11
|
+
};
|
|
12
|
+
export declare const DEFAULT_PLAYER_FRAMES = 120;
|
|
13
|
+
export declare const MAX_PLAYER_FRAMES = 300;
|
|
14
|
+
export declare const PLAYER_FPS = 4;
|
|
15
|
+
export declare const DEFAULT_PLAYER_WIDTH = 640;
|
|
16
|
+
/** How many preview frames, and at what rate, to cover `durationSec`: up to
|
|
17
|
+
* PLAYER_FPS per second, at most `maxFrames`, spread evenly. */
|
|
18
|
+
export declare function playerFramePlan(durationSec: number, maxFrames?: number): {
|
|
19
|
+
count: number;
|
|
20
|
+
fps: number;
|
|
21
|
+
};
|
|
22
|
+
/** Each frame's time: the middle of its slice of the video. */
|
|
23
|
+
export declare function playerFrameTimes(durationSec: number, count: number): number[];
|
|
24
|
+
/** Decode `input` to JPEG frames on stdout at `fps`, `width` wide. */
|
|
25
|
+
export declare function buildPlayerFramesArgs(input: string, fps: number, width: number, count: number): string[];
|
|
26
|
+
/** Split concatenated JPEGs (ffmpeg's mjpeg image2pipe) at their start/end
|
|
27
|
+
* markers. In entropy-coded data 0xFF is always followed by 0x00 or a restart
|
|
28
|
+
* marker, so 0xFFD9 only ever ends an image. */
|
|
29
|
+
export declare function splitJpegs(buf: Buffer): Buffer[];
|
|
30
|
+
//# sourceMappingURL=player.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"player.d.ts","sourceRoot":"","sources":["../../src/utils/player.ts"],"names":[],"mappings":"AAWA,wEAAwE;AACxE,eAAO,MAAM,UAAU,2BAA2B,CAAC;AACnD,eAAO,MAAM,YAAY,8BAA8B,CAAC;AAExD;kFACkF;AAClF,eAAO,MAAM,gBAAgB;;;;;CAA6E,CAAC;AAE3G,eAAO,MAAM,qBAAqB,MAAM,CAAC;AACzC,eAAO,MAAM,iBAAiB,MAAM,CAAC;AACrC,eAAO,MAAM,UAAU,IAAI,CAAC;AAC5B,eAAO,MAAM,oBAAoB,MAAM,CAAC;AAExC;gEACgE;AAChE,wBAAgB,eAAe,CAAC,WAAW,EAAE,MAAM,EAAE,SAAS,SAAwB,GAAG;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAA;CAAE,CAItH;AAED,+DAA+D;AAC/D,wBAAgB,gBAAgB,CAAC,WAAW,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,CAE7E;AAED,sEAAsE;AACtE,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,CAOxG;AAED;;gDAEgD;AAChD,wBAAgB,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,EAAE,CAchD"}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The review player (#128): an MCP Apps view (a sandboxed HTML page the host
|
|
3
|
+
* shows inline) where a person scrubs a recording, sets trim handles, and
|
|
4
|
+
* draws redaction boxes; their choices come back as a pipeline call.
|
|
5
|
+
*
|
|
6
|
+
* The page gets the video as JPEG frames (data: images work under the strict
|
|
7
|
+
* CSP hosts apply to apps, unlike a local file or HTTP server, and keep
|
|
8
|
+
* "output stays local"). These helpers plan and split those frames. Pure.
|
|
9
|
+
*/
|
|
10
|
+
import { ScreencastError } from "./errors.js";
|
|
11
|
+
/** The MCP Apps resource the player is served as, and its MIME type. */
|
|
12
|
+
export const PLAYER_URI = "ui://screencast/player";
|
|
13
|
+
export const MCP_APP_MIME = "text/html;profile=mcp-app";
|
|
14
|
+
/** Tool _meta that tells an Apps host to render the player for a tool's
|
|
15
|
+
* result. Both the current and the legacy key, as the spec asks hosts to read. */
|
|
16
|
+
export const PLAYER_TOOL_META = { ui: { resourceUri: PLAYER_URI }, "ui/resourceUri": PLAYER_URI };
|
|
17
|
+
export const DEFAULT_PLAYER_FRAMES = 120;
|
|
18
|
+
export const MAX_PLAYER_FRAMES = 300;
|
|
19
|
+
export const PLAYER_FPS = 4;
|
|
20
|
+
export const DEFAULT_PLAYER_WIDTH = 640;
|
|
21
|
+
/** How many preview frames, and at what rate, to cover `durationSec`: up to
|
|
22
|
+
* PLAYER_FPS per second, at most `maxFrames`, spread evenly. */
|
|
23
|
+
export function playerFramePlan(durationSec, maxFrames = DEFAULT_PLAYER_FRAMES) {
|
|
24
|
+
if (!(durationSec > 0))
|
|
25
|
+
throw new ScreencastError("The video has no duration to review.");
|
|
26
|
+
const count = Math.max(1, Math.min(maxFrames, Math.ceil(durationSec * PLAYER_FPS)));
|
|
27
|
+
return { count, fps: count / durationSec };
|
|
28
|
+
}
|
|
29
|
+
/** Each frame's time: the middle of its slice of the video. */
|
|
30
|
+
export function playerFrameTimes(durationSec, count) {
|
|
31
|
+
return Array.from({ length: count }, (_, i) => Math.round(((i + 0.5) * durationSec * 1000) / count) / 1000);
|
|
32
|
+
}
|
|
33
|
+
/** Decode `input` to JPEG frames on stdout at `fps`, `width` wide. */
|
|
34
|
+
export function buildPlayerFramesArgs(input, fps, width, count) {
|
|
35
|
+
return [
|
|
36
|
+
"-v", "error", "-i", input, "-an",
|
|
37
|
+
"-vf", `fps=${Number(fps.toFixed(6))},scale='min(${width},iw)':-2`,
|
|
38
|
+
"-frames:v", String(count),
|
|
39
|
+
"-q:v", "6", "-f", "image2pipe", "-c:v", "mjpeg", "-",
|
|
40
|
+
];
|
|
41
|
+
}
|
|
42
|
+
/** Split concatenated JPEGs (ffmpeg's mjpeg image2pipe) at their start/end
|
|
43
|
+
* markers. In entropy-coded data 0xFF is always followed by 0x00 or a restart
|
|
44
|
+
* marker, so 0xFFD9 only ever ends an image. */
|
|
45
|
+
export function splitJpegs(buf) {
|
|
46
|
+
const out = [];
|
|
47
|
+
let start = -1;
|
|
48
|
+
for (let i = 0; i + 1 < buf.length; i++) {
|
|
49
|
+
if (buf[i] !== 0xff)
|
|
50
|
+
continue;
|
|
51
|
+
const m = buf[i + 1];
|
|
52
|
+
if (m === 0xd8 && start < 0)
|
|
53
|
+
start = i;
|
|
54
|
+
else if (m === 0xd9 && start >= 0) {
|
|
55
|
+
out.push(buf.subarray(start, i + 2));
|
|
56
|
+
start = -1;
|
|
57
|
+
i++;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
return out;
|
|
61
|
+
}
|
|
62
|
+
//# sourceMappingURL=player.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"player.js","sourceRoot":"","sources":["../../src/utils/player.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAE9C,wEAAwE;AACxE,MAAM,CAAC,MAAM,UAAU,GAAG,wBAAwB,CAAC;AACnD,MAAM,CAAC,MAAM,YAAY,GAAG,2BAA2B,CAAC;AAExD;kFACkF;AAClF,MAAM,CAAC,MAAM,gBAAgB,GAAG,EAAE,EAAE,EAAE,EAAE,WAAW,EAAE,UAAU,EAAE,EAAE,gBAAgB,EAAE,UAAU,EAAW,CAAC;AAE3G,MAAM,CAAC,MAAM,qBAAqB,GAAG,GAAG,CAAC;AACzC,MAAM,CAAC,MAAM,iBAAiB,GAAG,GAAG,CAAC;AACrC,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,CAAC;AAC5B,MAAM,CAAC,MAAM,oBAAoB,GAAG,GAAG,CAAC;AAExC;gEACgE;AAChE,MAAM,UAAU,eAAe,CAAC,WAAmB,EAAE,SAAS,GAAG,qBAAqB;IACpF,IAAI,CAAC,CAAC,WAAW,GAAG,CAAC,CAAC;QAAE,MAAM,IAAI,eAAe,CAAC,sCAAsC,CAAC,CAAC;IAC1F,MAAM,KAAK,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,GAAG,CAAC,SAAS,EAAE,IAAI,CAAC,IAAI,CAAC,WAAW,GAAG,UAAU,CAAC,CAAC,CAAC,CAAC;IACpF,OAAO,EAAE,KAAK,EAAE,GAAG,EAAE,KAAK,GAAG,WAAW,EAAE,CAAC;AAC7C,CA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