@tmhs/screencast-mcp 0.49.1 → 0.51.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 +15 -9
- package/dist/index.js +551 -106
- package/dist/wgcRecorder.js +15 -139
- package/package.json +9 -5
- package/assets/.gitkeep +0 -0
- package/assets/icon.png +0 -0
- package/dist/cli.js +0 -516
- package/dist/context.js +0 -50
- package/dist/prompts.js +0 -95
- package/dist/resources.js +0 -93
- package/dist/server.js +0 -174
- package/dist/setup.js +0 -438
- package/dist/tools/addMarker.js +0 -93
- package/dist/tools/assembleHighlights.js +0 -69
- package/dist/tools/backdrop.js +0 -79
- package/dist/tools/bugReport.js +0 -243
- package/dist/tools/burnSubtitles.js +0 -56
- package/dist/tools/callout.js +0 -62
- package/dist/tools/chapters.js +0 -156
- package/dist/tools/clip.js +0 -52
- package/dist/tools/compress.js +0 -51
- package/dist/tools/concat.js +0 -67
- package/dist/tools/contactSheet.js +0 -113
- package/dist/tools/convert.js +0 -46
- package/dist/tools/crop.js +0 -43
- package/dist/tools/cursor.js +0 -67
- package/dist/tools/cutByTranscript.js +0 -86
- package/dist/tools/cutIdle.js +0 -84
- package/dist/tools/deleteRecording.js +0 -119
- package/dist/tools/denoise.js +0 -60
- package/dist/tools/doctor.js +0 -146
- package/dist/tools/exportGif.js +0 -57
- package/dist/tools/exportPreset.js +0 -48
- package/dist/tools/extractAudio.js +0 -65
- package/dist/tools/findText.js +0 -194
- package/dist/tools/getMediaInfo.js +0 -36
- package/dist/tools/getSession.js +0 -40
- package/dist/tools/indexRecording.js +0 -195
- package/dist/tools/keystrokeOverlay.js +0 -90
- package/dist/tools/listAudioDevices.js +0 -35
- package/dist/tools/listSessions.js +0 -28
- package/dist/tools/listTargets.js +0 -76
- package/dist/tools/listVideoDevices.js +0 -26
- package/dist/tools/musicBed.js +0 -55
- package/dist/tools/narrate.js +0 -86
- package/dist/tools/normalizeAudio.js +0 -59
- package/dist/tools/overlay.js +0 -62
- package/dist/tools/pauseRecording.js +0 -44
- package/dist/tools/pipeline.js +0 -397
- package/dist/tools/readEvents.js +0 -98
- package/dist/tools/redactRegion.js +0 -62
- package/dist/tools/reframe.js +0 -46
- package/dist/tools/resumeRecording.js +0 -46
- package/dist/tools/reviewRecording.js +0 -163
- package/dist/tools/sampleFrames.js +0 -200
- package/dist/tools/saveReplay.js +0 -90
- package/dist/tools/scale.js +0 -44
- package/dist/tools/screenDiff.js +0 -86
- package/dist/tools/screenshot.js +0 -76
- package/dist/tools/searchRecording.js +0 -79
- package/dist/tools/speed.js +0 -46
- package/dist/tools/startRecording.js +0 -398
- package/dist/tools/stepGuide.js +0 -249
- package/dist/tools/stopRecording.js +0 -132
- package/dist/tools/titleCard.js +0 -67
- package/dist/tools/transcribe.js +0 -66
- package/dist/tools/trim.js +0 -57
- package/dist/tools/waitForChange.js +0 -142
- package/dist/tools/xfadeTransition.js +0 -58
- package/dist/tools/zoom.js +0 -134
- package/dist/utils/anim.js +0 -54
- package/dist/utils/animExport.js +0 -56
- package/dist/utils/argPaths.js +0 -39
- package/dist/utils/audio.js +0 -117
- package/dist/utils/audioDevices.js +0 -107
- package/dist/utils/backdrop.js +0 -162
- package/dist/utils/bugReport.js +0 -195
- package/dist/utils/callout.js +0 -132
- package/dist/utils/calloutAssets.js +0 -42
- package/dist/utils/capabilities.js +0 -96
- package/dist/utils/captions.js +0 -104
- package/dist/utils/chapters.js +0 -227
- package/dist/utils/consent.js +0 -29
- package/dist/utils/cursor.js +0 -338
- package/dist/utils/diff.js +0 -186
- package/dist/utils/errors.js +0 -29
- package/dist/utils/events.js +0 -403
- package/dist/utils/expr.js +0 -11
- package/dist/utils/ffmpeg.js +0 -285
- package/dist/utils/fontCoverage.js +0 -177
- package/dist/utils/fonts.js +0 -154
- package/dist/utils/frameQueue.js +0 -50
- package/dist/utils/gpu.js +0 -219
- package/dist/utils/idle.js +0 -91
- package/dist/utils/images.js +0 -38
- package/dist/utils/jobs.js +0 -129
- package/dist/utils/keystrokes.js +0 -198
- package/dist/utils/lifecycle.js +0 -233
- package/dist/utils/logging.js +0 -75
- package/dist/utils/media.js +0 -584
- package/dist/utils/monitors.js +0 -124
- package/dist/utils/narrate.js +0 -233
- package/dist/utils/ocr.js +0 -222
- package/dist/utils/ocrScan.js +0 -93
- package/dist/utils/paths.js +0 -155
- package/dist/utils/pause.js +0 -190
- package/dist/utils/pipeline.js +0 -361
- package/dist/utils/player.js +0 -85
- package/dist/utils/pool.js +0 -29
- package/dist/utils/produce.js +0 -300
- package/dist/utils/recipes.js +0 -71
- package/dist/utils/recorder.js +0 -173
- package/dist/utils/recordingFiles.js +0 -32
- package/dist/utils/recordingIndex.js +0 -312
- package/dist/utils/replay.js +0 -283
- package/dist/utils/resolveTarget.js +0 -25
- package/dist/utils/retention.js +0 -48
- package/dist/utils/roots.js +0 -43
- package/dist/utils/sessions.js +0 -499
- package/dist/utils/sheet.js +0 -82
- package/dist/utils/stepGuide.js +0 -231
- package/dist/utils/steps.js +0 -88
- package/dist/utils/still.js +0 -38
- package/dist/utils/targetList.js +0 -64
- package/dist/utils/targets.js +0 -265
- package/dist/utils/timeline.js +0 -85
- package/dist/utils/toolSpec.js +0 -31
- package/dist/utils/toolsets.js +0 -134
- package/dist/utils/transcriptCut.js +0 -149
- package/dist/utils/validate.js +0 -23
- package/dist/utils/waitLoop.js +0 -50
- package/dist/utils/wgc.js +0 -84
- package/dist/utils/windows.js +0 -192
- package/dist/utils/zoom.js +0 -252
package/dist/wgcRecorder.js
CHANGED
|
@@ -1,140 +1,16 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
const nudge = spawn("powershell", ["-NoProfile", "-NonInteractive", "-Command", nudgeScript(cfg.hwnd, 200, process.pid)], {
|
|
10
|
-
stdio: "ignore",
|
|
11
|
-
windowsHide: true,
|
|
12
|
-
});
|
|
13
|
-
let grabErr = "";
|
|
14
|
-
let size = null;
|
|
15
|
-
let frameBytes = 0;
|
|
16
|
-
const frames = new FrameAssembler();
|
|
17
|
-
let latest = null;
|
|
18
|
-
let encoder = null;
|
|
19
|
-
let startedAt = 0;
|
|
20
|
-
let written = 0;
|
|
21
|
-
let pacer = null;
|
|
22
|
-
let finishing = false;
|
|
23
|
-
let windowClosed = false;
|
|
24
|
-
const stopFile = wgcStopFile(cfg.output);
|
|
25
|
-
function killChild(c) {
|
|
26
|
-
if (c && c.exitCode === null && c.signalCode === null) {
|
|
27
|
-
try {
|
|
28
|
-
c.kill();
|
|
29
|
-
}
|
|
30
|
-
catch {
|
|
31
|
-
}
|
|
32
|
-
}
|
|
1
|
+
import{spawn as S}from"node:child_process";import{existsSync as H,rmSync as P}from"node:fs";var u=class extends Error{hint;constructor(e,n){super(e),this.name="ScreencastError",this.hint=n}};function _(t){return!t||t.device.trim().length===0?[]:["-f","dshow","-i",`audio=${t.device}`]}var j="160k";function C(t=j){return["-c:a","aac",...t?["-b:a",t]:[]]}var tt=168*3600;function I(t,e,n=!0){if(!Number.isSafeInteger(t)||t<=0)throw new u("Invalid window handle.");return["-hide_banner","-nostats","-loglevel","info","-f","lavfi","-i",`gfxcapture=hwnd=${t}:max_framerate=${e}${n?"":":capture_cursor=0"},hwdownload,format=bgra,crop=trunc(iw/2)*2:trunc(ih/2)*2,format=yuv420p`,"-flush_packets","1","-f","rawvideo","-"]}function R(t){let e=t.indexOf("Output #0");if(e<0)return null;let n=/Video: rawvideo[^\n]*?, (\d{2,5})x(\d{2,5})/.exec(t.slice(e));return n?{width:Number(n[1]),height:Number(n[2])}:null}function T(t,e){return t*e*3/2}var g=class{parts=[];length=0;frameBytes=0;push(e){e.length&&(this.parts.push(e),this.length+=e.length)}get buffered(){return this.length}take(){let e=this.frameBytes;if(e<=0||this.length<e)return null;let n=Math.floor(this.length/e),w=this.parts.length===1&&this.parts[0]?this.parts[0]:Buffer.concat(this.parts,this.length),c=n*e,U=w.subarray(c-e,c),E=this.length-c;return this.parts=E?[Buffer.from(w.subarray(c))]:[],this.length=E,U}};function M(t,e,n){return["-hide_banner","-nostats","-loglevel","error","-y","-f","rawvideo","-pix_fmt","yuv420p","-s",`${t}x${e}`,"-framerate",String(n.fps),"-i","pipe:0",...n.audioDevice?[..._({device:n.audioDevice}),"-map","0:v","-map","1:a"]:[],...n.encode,...n.audioDevice?[...C(),"-shortest"]:[],"-movflags","+frag_keyframe+empty_moov+default_base_moof",n.output]}function O(t,e){return Math.floor(t*e/1e3)+1}var k=3;function N(t){return`${t}.stop`}function D(t){return`Input #0, wgc, from 'window':
|
|
2
|
+
Duration: N/A, start: ${(t/1e3).toFixed(6)}, bitrate: N/A
|
|
3
|
+
`}function W(t,e,n){return`Add-Type @"
|
|
4
|
+
using System;using System.Runtime.InteropServices;
|
|
5
|
+
public class ScNudge{
|
|
6
|
+
[StructLayout(LayoutKind.Sequential)] public struct RECT{public int L,T,R,B;}
|
|
7
|
+
[DllImport("user32.dll")] public static extern bool RedrawWindow(IntPtr h,ref RECT r,IntPtr g,uint f);
|
|
8
|
+
[DllImport("user32.dll")] public static extern bool IsWindow(IntPtr h);
|
|
33
9
|
}
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
}
|
|
41
|
-
function drain() {
|
|
42
|
-
if (!size || finishing)
|
|
43
|
-
return;
|
|
44
|
-
const frame = frames.take();
|
|
45
|
-
if (frame)
|
|
46
|
-
latest = frame;
|
|
47
|
-
if (latest && !encoder)
|
|
48
|
-
begin();
|
|
49
|
-
}
|
|
50
|
-
grab.stderr.on("data", (d) => {
|
|
51
|
-
if (size)
|
|
52
|
-
return;
|
|
53
|
-
grabErr = (grabErr + d.toString()).slice(-8000);
|
|
54
|
-
size = parseRawSize(grabErr);
|
|
55
|
-
if (size) {
|
|
56
|
-
frameBytes = yuv420FrameBytes(size.width, size.height);
|
|
57
|
-
frames.frameBytes = frameBytes;
|
|
58
|
-
drain();
|
|
59
|
-
}
|
|
60
|
-
});
|
|
61
|
-
grab.stdout.on("data", (chunk) => {
|
|
62
|
-
frames.push(chunk);
|
|
63
|
-
drain();
|
|
64
|
-
});
|
|
65
|
-
function begin() {
|
|
66
|
-
encoder = spawn(cfg.ffmpeg, buildWgcEncodeArgs(size.width, size.height, cfg), {
|
|
67
|
-
stdio: ["pipe", "ignore", "pipe"],
|
|
68
|
-
windowsHide: true,
|
|
69
|
-
});
|
|
70
|
-
encoder.stderr?.on("data", (d) => log(d.toString()));
|
|
71
|
-
encoder.on("exit", (code) => exitWith(code === 0 && windowClosed ? WGC_WINDOW_CLOSED_EXIT : (code ?? 1)));
|
|
72
|
-
encoder.stdin?.on("error", () => {
|
|
73
|
-
});
|
|
74
|
-
startedAt = Date.now();
|
|
75
|
-
log(startBanner(startedAt));
|
|
76
|
-
log(`wgc: ${size.width}x${size.height} at ${cfg.fps} fps`);
|
|
77
|
-
const tick = () => {
|
|
78
|
-
const due = framesDue(Date.now() - startedAt, cfg.fps);
|
|
79
|
-
while (written < due && latest && encoder?.stdin?.writable) {
|
|
80
|
-
if ((encoder.stdin.writableLength ?? 0) > MAX_QUEUED_FRAMES * frameBytes) {
|
|
81
|
-
written = due;
|
|
82
|
-
break;
|
|
83
|
-
}
|
|
84
|
-
encoder.stdin.write(latest);
|
|
85
|
-
written++;
|
|
86
|
-
}
|
|
87
|
-
};
|
|
88
|
-
tick();
|
|
89
|
-
pacer = setInterval(tick, Math.max(5, Math.floor(1000 / cfg.fps / 2)));
|
|
90
|
-
if (cfg.maxDurationSec > 0)
|
|
91
|
-
finishAfter(cfg.maxDurationSec * 1000);
|
|
92
|
-
}
|
|
93
|
-
function finishAfter(ms) {
|
|
94
|
-
const step = Math.min(ms, 2 ** 31 - 1);
|
|
95
|
-
setTimeout(() => (ms > step ? finishAfter(ms - step) : finish()), step);
|
|
96
|
-
}
|
|
97
|
-
function finish() {
|
|
98
|
-
if (finishing)
|
|
99
|
-
return;
|
|
100
|
-
finishing = true;
|
|
101
|
-
if (pacer)
|
|
102
|
-
clearInterval(pacer);
|
|
103
|
-
killChild(nudge);
|
|
104
|
-
killChild(grab);
|
|
105
|
-
if (!encoder) {
|
|
106
|
-
log("wgc: no frame was captured from the window");
|
|
107
|
-
exitWith(1);
|
|
108
|
-
}
|
|
109
|
-
encoder.stdin?.end();
|
|
110
|
-
}
|
|
111
|
-
grab.on("exit", () => {
|
|
112
|
-
if (finishing)
|
|
113
|
-
return;
|
|
114
|
-
if (!encoder) {
|
|
115
|
-
log(`wgc: capture failed: ${grabErr.split("\n").filter((l) => /error|fail|invalid/i.test(l)).slice(-3).join(" ") || "gfxcapture exited"}`);
|
|
116
|
-
exitWith(1);
|
|
117
|
-
}
|
|
118
|
-
log("wgc: the window closed; recording ended");
|
|
119
|
-
windowClosed = true;
|
|
120
|
-
finish();
|
|
121
|
-
});
|
|
122
|
-
setTimeout(() => {
|
|
123
|
-
if (!encoder && !finishing) {
|
|
124
|
-
log(`wgc: the window produced no frame in ${FIRST_FRAME_TIMEOUT_MS / 1000}s`);
|
|
125
|
-
finishing = true;
|
|
126
|
-
exitWith(1);
|
|
127
|
-
}
|
|
128
|
-
}, FIRST_FRAME_TIMEOUT_MS);
|
|
129
|
-
rmSync(stopFile, { force: true });
|
|
130
|
-
setInterval(() => {
|
|
131
|
-
if (existsSync(stopFile))
|
|
132
|
-
finish();
|
|
133
|
-
}, 250).unref();
|
|
134
|
-
for (const sig of ["SIGINT", "SIGTERM"])
|
|
135
|
-
process.on(sig, () => exitWith(1));
|
|
136
|
-
process.stdin.on("data", (d) => {
|
|
137
|
-
if (d.toString().includes("q"))
|
|
138
|
-
finish();
|
|
139
|
-
});
|
|
140
|
-
process.stdin.on("end", finish);
|
|
10
|
+
"@
|
|
11
|
+
$r=New-Object ScNudge+RECT;$r.R=1;$r.B=1
|
|
12
|
+
${n?`$p=Get-Process -Id ${n} -ErrorAction SilentlyContinue
|
|
13
|
+
`:""}while([ScNudge]::IsWindow([IntPtr]${t})${n?" -and $p -and !$p.HasExited":""}){[void][ScNudge]::RedrawWindow([IntPtr]${t},[ref]$r,[IntPtr]::Zero,0x0105);Start-Sleep -Milliseconds ${e}}`}var Q=4,r=JSON.parse(process.argv[2]??"{}"),B=r.firstFrameTimeoutMs??1e4,s=t=>process.stderr.write(t.endsWith(`
|
|
14
|
+
`)?t:`${t}
|
|
15
|
+
`),d=S(r.ffmpeg,I(r.hwnd,r.fps,r.cursor!==!1),{stdio:["ignore","pipe","pipe"],windowsHide:!0}),F=S("powershell",["-NoProfile","-NonInteractive","-Command",W(r.hwnd,200,process.pid)],{stdio:"ignore",windowsHide:!0}),m="",o=null,y=0,$=new g,h=null,i=null,x=0,b=0,v=null,a=!1,L=!1,A=N(r.output);function l(t){if(t&&t.exitCode===null&&t.signalCode===null)try{t.kill()}catch{}}function f(t){l(F),l(d),l(i),P(A,{force:!0}),process.exit(t)}function z(){if(!o||a)return;let t=$.take();t&&(h=t),h&&!i&&q()}d.stderr.on("data",t=>{o||(m=(m+t.toString()).slice(-8e3),o=R(m),o&&(y=T(o.width,o.height),$.frameBytes=y,z()))});d.stdout.on("data",t=>{$.push(t),z()});function q(){i=S(r.ffmpeg,M(o.width,o.height,r),{stdio:["pipe","ignore","pipe"],windowsHide:!0}),i.stderr?.on("data",e=>s(e.toString())),i.on("exit",e=>f(e===0&&L?k:e??1)),i.stdin?.on("error",()=>{}),x=Date.now(),s(D(x)),s(`wgc: ${o.width}x${o.height} at ${r.fps} fps`);let t=()=>{let e=O(Date.now()-x,r.fps);for(;b<e&&h&&i?.stdin?.writable;){if((i.stdin.writableLength??0)>Q*y){b=e;break}i.stdin.write(h),b++}};t(),v=setInterval(t,Math.max(5,Math.floor(1e3/r.fps/2))),r.maxDurationSec>0&&G(r.maxDurationSec*1e3)}function G(t){let e=Math.min(t,2147483647);setTimeout(()=>t>e?G(t-e):p(),e)}function p(){a||(a=!0,v&&clearInterval(v),l(F),l(d),i||(s("wgc: no frame was captured from the window"),f(1)),i.stdin?.end())}d.on("exit",()=>{a||(i||(s(`wgc: capture failed: ${m.split(`
|
|
16
|
+
`).filter(t=>/error|fail|invalid/i.test(t)).slice(-3).join(" ")||"gfxcapture exited"}`),f(1)),s("wgc: the window closed; recording ended"),L=!0,p())});setTimeout(()=>{!i&&!a&&(s(`wgc: the window produced no frame in ${B/1e3}s`),a=!0,f(1))},B);P(A,{force:!0});setInterval(()=>{H(A)&&p()},250).unref();for(let t of["SIGINT","SIGTERM"])process.on(t,()=>f(1));process.stdin.on("data",t=>{t.toString().includes("q")&&p()});process.stdin.on("end",p);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tmhs/screencast-mcp",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.51.0",
|
|
4
4
|
"description": "Let AI agents record the Windows screen, watch it as frames, and edit it with ffmpeg",
|
|
5
5
|
"mcpName": "io.github.TMHSDigital/screencast-mcp",
|
|
6
6
|
"type": "module",
|
|
@@ -9,8 +9,11 @@
|
|
|
9
9
|
"screencast-mcp": "dist/index.js"
|
|
10
10
|
},
|
|
11
11
|
"files": [
|
|
12
|
-
"dist
|
|
13
|
-
"
|
|
12
|
+
"dist/index.js",
|
|
13
|
+
"dist/wgcRecorder.js",
|
|
14
|
+
"assets/cursor",
|
|
15
|
+
"assets/fonts",
|
|
16
|
+
"assets/ui",
|
|
14
17
|
"README.md",
|
|
15
18
|
"LICENSE"
|
|
16
19
|
],
|
|
@@ -18,7 +21,7 @@
|
|
|
18
21
|
"access": "public"
|
|
19
22
|
},
|
|
20
23
|
"scripts": {
|
|
21
|
-
"build": "tsc",
|
|
24
|
+
"build": "tsc && node scripts/bundle.mjs",
|
|
22
25
|
"typecheck": "tsc --noEmit && tsc -p src/__tests__ && tsc -p evals/tsconfig.json",
|
|
23
26
|
"lint": "eslint .",
|
|
24
27
|
"dev": "tsx watch src/index.ts",
|
|
@@ -72,10 +75,11 @@
|
|
|
72
75
|
"@types/jsdom": "^30.0.0",
|
|
73
76
|
"@types/node": "^22.15.3",
|
|
74
77
|
"@vitest/coverage-v8": "^5.0.5",
|
|
78
|
+
"esbuild": "0.28.2",
|
|
75
79
|
"eslint": "^10.14.0",
|
|
76
80
|
"jsdom": "^31.0.0",
|
|
77
81
|
"tsx": "^4.19.4",
|
|
78
|
-
"typescript": "
|
|
82
|
+
"typescript": "~6.0.3",
|
|
79
83
|
"typescript-eslint": "^8.72.1",
|
|
80
84
|
"vitest": "^5.1.0"
|
|
81
85
|
}
|
package/assets/.gitkeep
DELETED
|
File without changes
|
package/assets/icon.png
DELETED
|
Binary file
|