@tmhs/screencast-mcp 0.49.0 → 0.50.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.
Files changed (133) hide show
  1. package/README.md +13 -8
  2. package/dist/index.js +550 -106
  3. package/dist/wgcRecorder.js +15 -139
  4. package/package.json +8 -4
  5. package/assets/.gitkeep +0 -0
  6. package/assets/icon.png +0 -0
  7. package/dist/cli.js +0 -516
  8. package/dist/context.js +0 -50
  9. package/dist/prompts.js +0 -95
  10. package/dist/resources.js +0 -93
  11. package/dist/server.js +0 -174
  12. package/dist/setup.js +0 -438
  13. package/dist/tools/addMarker.js +0 -93
  14. package/dist/tools/assembleHighlights.js +0 -69
  15. package/dist/tools/backdrop.js +0 -89
  16. package/dist/tools/bugReport.js +0 -266
  17. package/dist/tools/burnSubtitles.js +0 -56
  18. package/dist/tools/callout.js +0 -103
  19. package/dist/tools/chapters.js +0 -156
  20. package/dist/tools/clip.js +0 -52
  21. package/dist/tools/compress.js +0 -51
  22. package/dist/tools/concat.js +0 -67
  23. package/dist/tools/contactSheet.js +0 -135
  24. package/dist/tools/convert.js +0 -46
  25. package/dist/tools/crop.js +0 -43
  26. package/dist/tools/cursor.js +0 -87
  27. package/dist/tools/cutByTranscript.js +0 -86
  28. package/dist/tools/cutIdle.js +0 -84
  29. package/dist/tools/deleteRecording.js +0 -119
  30. package/dist/tools/denoise.js +0 -60
  31. package/dist/tools/doctor.js +0 -146
  32. package/dist/tools/exportGif.js +0 -57
  33. package/dist/tools/exportPreset.js +0 -48
  34. package/dist/tools/extractAudio.js +0 -65
  35. package/dist/tools/findText.js +0 -196
  36. package/dist/tools/getMediaInfo.js +0 -36
  37. package/dist/tools/getSession.js +0 -40
  38. package/dist/tools/indexRecording.js +0 -195
  39. package/dist/tools/keystrokeOverlay.js +0 -131
  40. package/dist/tools/listAudioDevices.js +0 -35
  41. package/dist/tools/listSessions.js +0 -28
  42. package/dist/tools/listTargets.js +0 -76
  43. package/dist/tools/listVideoDevices.js +0 -26
  44. package/dist/tools/musicBed.js +0 -55
  45. package/dist/tools/narrate.js +0 -86
  46. package/dist/tools/normalizeAudio.js +0 -60
  47. package/dist/tools/overlay.js +0 -62
  48. package/dist/tools/pauseRecording.js +0 -44
  49. package/dist/tools/pipeline.js +0 -400
  50. package/dist/tools/readEvents.js +0 -98
  51. package/dist/tools/redactRegion.js +0 -70
  52. package/dist/tools/reframe.js +0 -46
  53. package/dist/tools/resumeRecording.js +0 -46
  54. package/dist/tools/reviewRecording.js +0 -163
  55. package/dist/tools/sampleFrames.js +0 -200
  56. package/dist/tools/saveReplay.js +0 -90
  57. package/dist/tools/scale.js +0 -44
  58. package/dist/tools/screenDiff.js +0 -86
  59. package/dist/tools/screenshot.js +0 -76
  60. package/dist/tools/searchRecording.js +0 -79
  61. package/dist/tools/speed.js +0 -46
  62. package/dist/tools/startRecording.js +0 -398
  63. package/dist/tools/stepGuide.js +0 -250
  64. package/dist/tools/stopRecording.js +0 -132
  65. package/dist/tools/titleCard.js +0 -67
  66. package/dist/tools/transcribe.js +0 -66
  67. package/dist/tools/trim.js +0 -57
  68. package/dist/tools/waitForChange.js +0 -128
  69. package/dist/tools/xfadeTransition.js +0 -58
  70. package/dist/tools/zoom.js +0 -149
  71. package/dist/utils/anim.js +0 -54
  72. package/dist/utils/animExport.js +0 -56
  73. package/dist/utils/argPaths.js +0 -39
  74. package/dist/utils/audio.js +0 -113
  75. package/dist/utils/audioDevices.js +0 -107
  76. package/dist/utils/backdrop.js +0 -151
  77. package/dist/utils/bugReport.js +0 -172
  78. package/dist/utils/callout.js +0 -90
  79. package/dist/utils/calloutAssets.js +0 -42
  80. package/dist/utils/capabilities.js +0 -96
  81. package/dist/utils/captions.js +0 -103
  82. package/dist/utils/chapters.js +0 -227
  83. package/dist/utils/consent.js +0 -29
  84. package/dist/utils/cursor.js +0 -317
  85. package/dist/utils/diff.js +0 -184
  86. package/dist/utils/errors.js +0 -29
  87. package/dist/utils/events.js +0 -403
  88. package/dist/utils/expr.js +0 -11
  89. package/dist/utils/ffmpeg.js +0 -285
  90. package/dist/utils/fontCoverage.js +0 -177
  91. package/dist/utils/fonts.js +0 -154
  92. package/dist/utils/gpu.js +0 -219
  93. package/dist/utils/idle.js +0 -91
  94. package/dist/utils/images.js +0 -38
  95. package/dist/utils/jobs.js +0 -129
  96. package/dist/utils/keystrokes.js +0 -155
  97. package/dist/utils/lifecycle.js +0 -233
  98. package/dist/utils/logging.js +0 -75
  99. package/dist/utils/media.js +0 -574
  100. package/dist/utils/monitors.js +0 -124
  101. package/dist/utils/narrate.js +0 -233
  102. package/dist/utils/ocr.js +0 -222
  103. package/dist/utils/ocrScan.js +0 -91
  104. package/dist/utils/paths.js +0 -155
  105. package/dist/utils/pause.js +0 -190
  106. package/dist/utils/pipeline.js +0 -361
  107. package/dist/utils/player.js +0 -85
  108. package/dist/utils/pool.js +0 -29
  109. package/dist/utils/produce.js +0 -298
  110. package/dist/utils/recipes.js +0 -71
  111. package/dist/utils/recorder.js +0 -173
  112. package/dist/utils/recordingFiles.js +0 -32
  113. package/dist/utils/recordingIndex.js +0 -312
  114. package/dist/utils/replay.js +0 -283
  115. package/dist/utils/resolveTarget.js +0 -25
  116. package/dist/utils/retention.js +0 -48
  117. package/dist/utils/roots.js +0 -43
  118. package/dist/utils/sessions.js +0 -499
  119. package/dist/utils/sheet.js +0 -59
  120. package/dist/utils/stepGuide.js +0 -231
  121. package/dist/utils/steps.js +0 -88
  122. package/dist/utils/still.js +0 -38
  123. package/dist/utils/targetList.js +0 -64
  124. package/dist/utils/targets.js +0 -265
  125. package/dist/utils/timeline.js +0 -85
  126. package/dist/utils/toolSpec.js +0 -31
  127. package/dist/utils/toolsets.js +0 -134
  128. package/dist/utils/transcriptCut.js +0 -149
  129. package/dist/utils/validate.js +0 -23
  130. package/dist/utils/waitLoop.js +0 -50
  131. package/dist/utils/wgc.js +0 -84
  132. package/dist/utils/windows.js +0 -192
  133. package/dist/utils/zoom.js +0 -234
@@ -1,140 +1,16 @@
1
- import { spawn } from "node:child_process";
2
- import { existsSync, rmSync } from "node:fs";
3
- import { buildWgcEncodeArgs, buildWgcGrabArgs, FrameAssembler, framesDue, parseRawSize, nudgeScript, startBanner, yuv420FrameBytes, wgcStopFile, WGC_WINDOW_CLOSED_EXIT, } from "./utils/wgc.js";
4
- const FIRST_FRAME_TIMEOUT_MS = 10_000;
5
- const MAX_QUEUED_FRAMES = 4;
6
- const cfg = JSON.parse(process.argv[2] ?? "{}");
7
- const log = (s) => process.stderr.write(s.endsWith("\n") ? s : `${s}\n`);
8
- const grab = spawn(cfg.ffmpeg, buildWgcGrabArgs(cfg.hwnd, cfg.fps, cfg.cursor !== false), { stdio: ["ignore", "pipe", "pipe"], windowsHide: true });
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 I}from"node:child_process";import{existsSync as H,rmSync as k}from"node:fs";var p=class extends Error{hint;constructor(e,n){super(e),this.name="ScreencastError",this.hint=n}};function C(t,e,n=!0){if(!Number.isSafeInteger(t)||t<=0)throw new p("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 T(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 E(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),a=n*e,L=w.subarray(a-e,a),R=this.length-a;return this.parts=R?[Buffer.from(w.subarray(a))]:[],this.length=R,L}};function _(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.encode,"-movflags","+frag_keyframe+empty_moov+default_base_moof",n.output]}function B(t,e){return Math.floor(t*e/1e3)+1}var W=3;function N(t){return`${t}.stop`}function A(t){return`Input #0, wgc, from 'window':
2
+ Duration: N/A, start: ${(t/1e3).toFixed(6)}, bitrate: N/A
3
+ `}function D(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
- function exitWith(code) {
35
- killChild(nudge);
36
- killChild(grab);
37
- killChild(encoder);
38
- rmSync(stopFile, { force: true });
39
- process.exit(code);
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 J=4,r=JSON.parse(process.argv[2]??"{}"),M=r.firstFrameTimeoutMs??1e4,s=t=>process.stderr.write(t.endsWith(`
14
+ `)?t:`${t}
15
+ `),l=I(r.ffmpeg,C(r.hwnd,r.fps,r.cursor!==!1),{stdio:["ignore","pipe","pipe"],windowsHide:!0}),F=I("powershell",["-NoProfile","-NonInteractive","-Command",D(r.hwnd,200,process.pid)],{stdio:"ignore",windowsHide:!0}),m="",o=null,y=0,$=new g,h=null,i=null,b=0,x=0,S=null,u=!1,O=!1,v=N(r.output);function f(t){if(t&&t.exitCode===null&&t.signalCode===null)try{t.kill()}catch{}}function c(t){f(F),f(l),f(i),k(v,{force:!0}),process.exit(t)}function P(){if(!o||u)return;let t=$.take();t&&(h=t),h&&!i&&j()}l.stderr.on("data",t=>{o||(m=(m+t.toString()).slice(-8e3),o=T(m),o&&(y=E(o.width,o.height),$.frameBytes=y,P()))});l.stdout.on("data",t=>{$.push(t),P()});function j(){i=I(r.ffmpeg,_(o.width,o.height,r),{stdio:["pipe","ignore","pipe"],windowsHide:!0}),i.stderr?.on("data",e=>s(e.toString())),i.on("exit",e=>c(e===0&&O?W:e??1)),i.stdin?.on("error",()=>{}),b=Date.now(),s(A(b)),s(`wgc: ${o.width}x${o.height} at ${r.fps} fps`);let t=()=>{let e=B(Date.now()-b,r.fps);for(;x<e&&h&&i?.stdin?.writable;){if((i.stdin.writableLength??0)>J*y){x=e;break}i.stdin.write(h),x++}};t(),S=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):d(),e)}function d(){u||(u=!0,S&&clearInterval(S),f(F),f(l),i||(s("wgc: no frame was captured from the window"),c(1)),i.stdin?.end())}l.on("exit",()=>{u||(i||(s(`wgc: capture failed: ${m.split(`
16
+ `).filter(t=>/error|fail|invalid/i.test(t)).slice(-3).join(" ")||"gfxcapture exited"}`),c(1)),s("wgc: the window closed; recording ended"),O=!0,d())});setTimeout(()=>{!i&&!u&&(s(`wgc: the window produced no frame in ${M/1e3}s`),u=!0,c(1))},M);k(v,{force:!0});setInterval(()=>{H(v)&&d()},250).unref();for(let t of["SIGINT","SIGTERM"])process.on(t,()=>c(1));process.stdin.on("data",t=>{t.toString().includes("q")&&d()});process.stdin.on("end",d);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tmhs/screencast-mcp",
3
- "version": "0.49.0",
3
+ "version": "0.50.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/**/*.js",
13
- "assets",
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,6 +75,7 @@
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",
package/assets/.gitkeep DELETED
File without changes
package/assets/icon.png DELETED
Binary file