@tmhs/screencast-mcp 0.2.1

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 (87) hide show
  1. package/LICENSE +34 -0
  2. package/README.md +212 -0
  3. package/dist/context.d.ts +5 -0
  4. package/dist/context.d.ts.map +1 -0
  5. package/dist/context.js +13 -0
  6. package/dist/context.js.map +1 -0
  7. package/dist/index.d.ts +3 -0
  8. package/dist/index.d.ts.map +1 -0
  9. package/dist/index.js +57 -0
  10. package/dist/index.js.map +1 -0
  11. package/dist/tools/concat.d.ts +3 -0
  12. package/dist/tools/concat.d.ts.map +1 -0
  13. package/dist/tools/concat.js +42 -0
  14. package/dist/tools/concat.js.map +1 -0
  15. package/dist/tools/convert.d.ts +3 -0
  16. package/dist/tools/convert.d.ts.map +1 -0
  17. package/dist/tools/convert.js +38 -0
  18. package/dist/tools/convert.js.map +1 -0
  19. package/dist/tools/getMediaInfo.d.ts +3 -0
  20. package/dist/tools/getMediaInfo.d.ts.map +1 -0
  21. package/dist/tools/getMediaInfo.js +28 -0
  22. package/dist/tools/getMediaInfo.js.map +1 -0
  23. package/dist/tools/getSession.d.ts +3 -0
  24. package/dist/tools/getSession.d.ts.map +1 -0
  25. package/dist/tools/getSession.js +28 -0
  26. package/dist/tools/getSession.js.map +1 -0
  27. package/dist/tools/listSessions.d.ts +3 -0
  28. package/dist/tools/listSessions.d.ts.map +1 -0
  29. package/dist/tools/listSessions.js +18 -0
  30. package/dist/tools/listSessions.js.map +1 -0
  31. package/dist/tools/sampleFrames.d.ts +3 -0
  32. package/dist/tools/sampleFrames.d.ts.map +1 -0
  33. package/dist/tools/sampleFrames.js +69 -0
  34. package/dist/tools/sampleFrames.js.map +1 -0
  35. package/dist/tools/screenshot.d.ts +3 -0
  36. package/dist/tools/screenshot.d.ts.map +1 -0
  37. package/dist/tools/screenshot.js +39 -0
  38. package/dist/tools/screenshot.js.map +1 -0
  39. package/dist/tools/startRecording.d.ts +3 -0
  40. package/dist/tools/startRecording.d.ts.map +1 -0
  41. package/dist/tools/startRecording.js +107 -0
  42. package/dist/tools/startRecording.js.map +1 -0
  43. package/dist/tools/stopRecording.d.ts +3 -0
  44. package/dist/tools/stopRecording.d.ts.map +1 -0
  45. package/dist/tools/stopRecording.js +100 -0
  46. package/dist/tools/stopRecording.js.map +1 -0
  47. package/dist/tools/trim.d.ts +3 -0
  48. package/dist/tools/trim.d.ts.map +1 -0
  49. package/dist/tools/trim.js +38 -0
  50. package/dist/tools/trim.js.map +1 -0
  51. package/dist/utils/errors.d.ts +25 -0
  52. package/dist/utils/errors.d.ts.map +1 -0
  53. package/dist/utils/errors.js +36 -0
  54. package/dist/utils/errors.js.map +1 -0
  55. package/dist/utils/ffmpeg.d.ts +24 -0
  56. package/dist/utils/ffmpeg.d.ts.map +1 -0
  57. package/dist/utils/ffmpeg.js +88 -0
  58. package/dist/utils/ffmpeg.js.map +1 -0
  59. package/dist/utils/media.d.ts +53 -0
  60. package/dist/utils/media.d.ts.map +1 -0
  61. package/dist/utils/media.js +133 -0
  62. package/dist/utils/media.js.map +1 -0
  63. package/dist/utils/monitors.d.ts +14 -0
  64. package/dist/utils/monitors.d.ts.map +1 -0
  65. package/dist/utils/monitors.js +55 -0
  66. package/dist/utils/monitors.js.map +1 -0
  67. package/dist/utils/paths.d.ts +11 -0
  68. package/dist/utils/paths.d.ts.map +1 -0
  69. package/dist/utils/paths.js +47 -0
  70. package/dist/utils/paths.js.map +1 -0
  71. package/dist/utils/resolveTarget.d.ts +24 -0
  72. package/dist/utils/resolveTarget.d.ts.map +1 -0
  73. package/dist/utils/resolveTarget.js +32 -0
  74. package/dist/utils/resolveTarget.js.map +1 -0
  75. package/dist/utils/sessions.d.ts +51 -0
  76. package/dist/utils/sessions.d.ts.map +1 -0
  77. package/dist/utils/sessions.js +144 -0
  78. package/dist/utils/sessions.js.map +1 -0
  79. package/dist/utils/targets.d.ts +43 -0
  80. package/dist/utils/targets.d.ts.map +1 -0
  81. package/dist/utils/targets.js +156 -0
  82. package/dist/utils/targets.js.map +1 -0
  83. package/dist/utils/windows.d.ts +43 -0
  84. package/dist/utils/windows.d.ts.map +1 -0
  85. package/dist/utils/windows.js +127 -0
  86. package/dist/utils/windows.js.map +1 -0
  87. package/package.json +59 -0
@@ -0,0 +1,53 @@
1
+ export interface MediaInfo {
2
+ durationSec: number | null;
3
+ width: number | null;
4
+ height: number | null;
5
+ fps: number | null;
6
+ videoCodec: string | null;
7
+ audioCodec: string | null;
8
+ format: string | null;
9
+ sizeBytes: number | null;
10
+ }
11
+ interface FfprobeStream {
12
+ codec_type?: string;
13
+ codec_name?: string;
14
+ width?: number;
15
+ height?: number;
16
+ avg_frame_rate?: string;
17
+ r_frame_rate?: string;
18
+ }
19
+ interface FfprobeJson {
20
+ streams?: FfprobeStream[];
21
+ format?: {
22
+ duration?: string;
23
+ format_name?: string;
24
+ size?: string;
25
+ };
26
+ }
27
+ /** Parse an `avg_frame_rate` / `r_frame_rate` rational ("30000/1001") to fps. */
28
+ export declare function parseFrameRate(value: string | undefined): number | null;
29
+ /** Reduce a parsed ffprobe JSON document to a flat MediaInfo. */
30
+ export declare function parseMediaInfo(probe: FfprobeJson): MediaInfo;
31
+ export declare function buildProbeArgs(input: string): string[];
32
+ /** Sample frames at a fixed rate: ffmpeg -i in -vf fps=N outdir/frame_%05d.png */
33
+ export declare function buildSampleByFpsArgs(input: string, fps: number, outputPattern: string): string[];
34
+ /** Build one ffmpeg invocation per timestamp (accurate single-frame seek). */
35
+ export declare function buildSampleAtTimestampArgs(input: string, timestampSec: number, output: string): string[];
36
+ /** Trim by start + (end | duration). Stream-copy for speed. */
37
+ export declare function buildTrimArgs(input: string, output: string, opts: {
38
+ start: number;
39
+ end?: number;
40
+ duration?: number;
41
+ }): string[];
42
+ /** Build the concat-demuxer list file content for a set of inputs. */
43
+ export declare function buildConcatListContent(inputs: string[]): string;
44
+ export declare function buildConcatArgs(listFile: string, output: string): string[];
45
+ export type ConvertFormat = "mp4" | "gif" | "webm";
46
+ /** Build conversion args for mp4 <-> gif/webm. gif uses a single-pass
47
+ * palette-quality filter; webm uses VP9; mp4 uses H.264. */
48
+ export declare function buildConvertArgs(input: string, output: string, format: ConvertFormat, opts?: {
49
+ fps?: number;
50
+ width?: number;
51
+ }): string[];
52
+ export {};
53
+ //# sourceMappingURL=media.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"media.d.ts","sourceRoot":"","sources":["../../src/utils/media.ts"],"names":[],"mappings":"AAQA,MAAM,WAAW,SAAS;IACxB,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,GAAG,EAAE,MAAM,GAAG,IAAI,CAAC;IACnB,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;CAC1B;AAED,UAAU,aAAa;IACrB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED,UAAU,WAAW;IACnB,OAAO,CAAC,EAAE,aAAa,EAAE,CAAC;IAC1B,MAAM,CAAC,EAAE;QAAE,QAAQ,CAAC,EAAE,MAAM,CAAC;QAAC,WAAW,CAAC,EAAE,MAAM,CAAC;QAAC,IAAI,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;CACrE;AAED,iFAAiF;AACjF,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,GAAG,IAAI,CAQvE;AAED,iEAAiE;AACjE,wBAAgB,cAAc,CAAC,KAAK,EAAE,WAAW,GAAG,SAAS,CAgB5D;AAED,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,CAQtD;AASD,kFAAkF;AAClF,wBAAgB,oBAAoB,CAClC,KAAK,EAAE,MAAM,EACb,GAAG,EAAE,MAAM,EACX,aAAa,EAAE,MAAM,GACpB,MAAM,EAAE,CAGV;AAED,8EAA8E;AAC9E,wBAAgB,0BAA0B,CACxC,KAAK,EAAE,MAAM,EACb,YAAY,EAAE,MAAM,EACpB,MAAM,EAAE,MAAM,GACb,MAAM,EAAE,CAKV;AAED,+DAA+D;AAC/D,wBAAgB,aAAa,CAC3B,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,MAAM,EACd,IAAI,EAAE;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,GAAG,CAAC,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,EAAE,MAAM,CAAA;CAAE,GACvD,MAAM,EAAE,CAsBV;AAED,sEAAsE;AACtE,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,MAAM,CAS/D;AAED,wBAAgB,eAAe,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,CAE1E;AAED,MAAM,MAAM,aAAa,GAAG,KAAK,GAAG,KAAK,GAAG,MAAM,CAAC;AAEnD;4DAC4D;AAC5D,wBAAgB,gBAAgB,CAC9B,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,aAAa,EACrB,IAAI,GAAE;IAAE,GAAG,CAAC,EAAE,MAAM,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAA;CAAO,GAC1C,MAAM,EAAE,CA4BV"}
@@ -0,0 +1,133 @@
1
+ /**
2
+ * ffprobe parsing and the Phase 1 edit/watch argument builders.
3
+ *
4
+ * All functions here are pure (string in, args/strings out) so the edit and
5
+ * watch surfaces are unit-tested without ffmpeg present.
6
+ */
7
+ import { ScreencastError } from "./errors.js";
8
+ /** Parse an `avg_frame_rate` / `r_frame_rate` rational ("30000/1001") to fps. */
9
+ export function parseFrameRate(value) {
10
+ if (!value)
11
+ return null;
12
+ const [num, den] = value.split("/");
13
+ const n = Number(num);
14
+ const d = den === undefined ? 1 : Number(den);
15
+ if (!Number.isFinite(n) || !Number.isFinite(d) || d === 0)
16
+ return null;
17
+ if (n === 0)
18
+ return null;
19
+ return Math.round((n / d) * 1000) / 1000;
20
+ }
21
+ /** Reduce a parsed ffprobe JSON document to a flat MediaInfo. */
22
+ export function parseMediaInfo(probe) {
23
+ const streams = probe.streams ?? [];
24
+ const video = streams.find((s) => s.codec_type === "video");
25
+ const audio = streams.find((s) => s.codec_type === "audio");
26
+ const duration = probe.format?.duration;
27
+ const size = probe.format?.size;
28
+ return {
29
+ durationSec: duration !== undefined ? Number(duration) : null,
30
+ width: video?.width ?? null,
31
+ height: video?.height ?? null,
32
+ fps: parseFrameRate(video?.avg_frame_rate) ?? parseFrameRate(video?.r_frame_rate),
33
+ videoCodec: video?.codec_name ?? null,
34
+ audioCodec: audio?.codec_name ?? null,
35
+ format: probe.format?.format_name ?? null,
36
+ sizeBytes: size !== undefined ? Number(size) : null,
37
+ };
38
+ }
39
+ export function buildProbeArgs(input) {
40
+ return [
41
+ "-v", "quiet",
42
+ "-print_format", "json",
43
+ "-show_format",
44
+ "-show_streams",
45
+ input,
46
+ ];
47
+ }
48
+ function validatePositive(value, label) {
49
+ if (!Number.isFinite(value) || value <= 0) {
50
+ throw new ScreencastError(`${label} must be a positive number.`);
51
+ }
52
+ return value;
53
+ }
54
+ /** Sample frames at a fixed rate: ffmpeg -i in -vf fps=N outdir/frame_%05d.png */
55
+ export function buildSampleByFpsArgs(input, fps, outputPattern) {
56
+ validatePositive(fps, "fps");
57
+ return ["-y", "-i", input, "-vf", `fps=${fps}`, outputPattern];
58
+ }
59
+ /** Build one ffmpeg invocation per timestamp (accurate single-frame seek). */
60
+ export function buildSampleAtTimestampArgs(input, timestampSec, output) {
61
+ if (!Number.isFinite(timestampSec) || timestampSec < 0) {
62
+ throw new ScreencastError("timestamp must be a non-negative number.");
63
+ }
64
+ return ["-y", "-ss", String(timestampSec), "-i", input, "-frames:v", "1", output];
65
+ }
66
+ /** Trim by start + (end | duration). Stream-copy for speed. */
67
+ export function buildTrimArgs(input, output, opts) {
68
+ const start = opts.start;
69
+ if (!Number.isFinite(start) || start < 0) {
70
+ throw new ScreencastError("start must be a non-negative number.");
71
+ }
72
+ if (opts.end === undefined && opts.duration === undefined) {
73
+ throw new ScreencastError("trim requires either end or duration.");
74
+ }
75
+ if (opts.end !== undefined && opts.duration !== undefined) {
76
+ throw new ScreencastError("trim takes end OR duration, not both.");
77
+ }
78
+ const args = ["-y", "-ss", String(start), "-i", input];
79
+ if (opts.end !== undefined) {
80
+ if (opts.end <= start) {
81
+ throw new ScreencastError("end must be greater than start.");
82
+ }
83
+ args.push("-to", String(opts.end));
84
+ }
85
+ else {
86
+ args.push("-t", String(validatePositive(opts.duration, "duration")));
87
+ }
88
+ args.push("-c", "copy", output);
89
+ return args;
90
+ }
91
+ /** Build the concat-demuxer list file content for a set of inputs. */
92
+ export function buildConcatListContent(inputs) {
93
+ if (inputs.length < 2) {
94
+ throw new ScreencastError("concat requires at least two input files.");
95
+ }
96
+ return (inputs
97
+ .map((p) => `file '${p.replace(/'/g, "'\\''")}'`)
98
+ .join("\n") + "\n");
99
+ }
100
+ export function buildConcatArgs(listFile, output) {
101
+ return ["-y", "-f", "concat", "-safe", "0", "-i", listFile, "-c", "copy", output];
102
+ }
103
+ /** Build conversion args for mp4 <-> gif/webm. gif uses a single-pass
104
+ * palette-quality filter; webm uses VP9; mp4 uses H.264. */
105
+ export function buildConvertArgs(input, output, format, opts = {}) {
106
+ switch (format) {
107
+ case "gif": {
108
+ const fps = opts.fps ?? 12;
109
+ const width = opts.width ?? 720;
110
+ const filter = `fps=${fps},scale=${width}:-1:flags=lanczos,split[s0][s1];` +
111
+ `[s0]palettegen[p];[s1][p]paletteuse`;
112
+ return ["-y", "-i", input, "-vf", filter, output];
113
+ }
114
+ case "webm":
115
+ return [
116
+ "-y", "-i", input,
117
+ "-c:v", "libvpx-vp9", "-b:v", "0", "-crf", "30",
118
+ "-row-mt", "1",
119
+ output,
120
+ ];
121
+ case "mp4":
122
+ return [
123
+ "-y", "-i", input,
124
+ "-c:v", "libx264", "-preset", "veryfast", "-crf", "23",
125
+ "-pix_fmt", "yuv420p",
126
+ "-movflags", "+faststart",
127
+ output,
128
+ ];
129
+ default:
130
+ throw new ScreencastError(`Unsupported convert format "${format}".`);
131
+ }
132
+ }
133
+ //# sourceMappingURL=media.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"media.js","sourceRoot":"","sources":["../../src/utils/media.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AA2B9C,iFAAiF;AACjF,MAAM,UAAU,cAAc,CAAC,KAAyB;IACtD,IAAI,CAAC,KAAK;QAAE,OAAO,IAAI,CAAC;IACxB,MAAM,CAAC,GAAG,EAAE,GAAG,CAAC,GAAG,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IACpC,MAAM,CAAC,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC;IACtB,MAAM,CAAC,GAAG,GAAG,KAAK,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;IAC9C,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC;QAAE,OAAO,IAAI,CAAC;IACvE,IAAI,CAAC,KAAK,CAAC;QAAE,OAAO,IAAI,CAAC;IACzB,OAAO,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC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14 @@
1
+ export interface Monitor {
2
+ index: number;
3
+ x: number;
4
+ y: number;
5
+ width: number;
6
+ height: number;
7
+ primary: boolean;
8
+ }
9
+ /** Normalize raw PowerShell screen objects into ordered Monitor records.
10
+ * Primary monitor is sorted first so monitor:0 is the primary display. */
11
+ export declare function parseMonitors(raw: unknown): Monitor[];
12
+ /** Query live monitor geometry on Windows. Throws on non-Windows or failure. */
13
+ export declare function getMonitors(): Monitor[];
14
+ //# sourceMappingURL=monitors.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"monitors.d.ts","sourceRoot":"","sources":["../../src/utils/monitors.ts"],"names":[],"mappings":"AAeA,MAAM,WAAW,OAAO;IACtB,KAAK,EAAE,MAAM,CAAC;IACd,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,OAAO,CAAC;CAClB;AAUD;0EAC0E;AAC1E,wBAAgB,aAAa,CAAC,GAAG,EAAE,OAAO,GAAG,OAAO,EAAE,CAerD;AAQD,gFAAgF;AAChF,wBAAgB,WAAW,IAAI,OAAO,EAAE,CAuBvC"}
@@ -0,0 +1,55 @@
1
+ /**
2
+ * Monitor geometry discovery.
3
+ *
4
+ * gdigrab has no native "capture monitor N" selector: you capture the whole
5
+ * virtual desktop and crop to a monitor's bounds with -offset_x / -offset_y /
6
+ * -video_size. To do that correctly on a multi-monitor setup (for example a
7
+ * 4480x1440 dual-monitor desktop where the second display starts at x=2560),
8
+ * we need each monitor's pixel bounds. On Windows those come from
9
+ * System.Windows.Forms.Screen.AllScreens via PowerShell.
10
+ *
11
+ * `parseMonitors` is pure so the offset math is unit-tested without Windows.
12
+ */
13
+ import { spawnSync } from "node:child_process";
14
+ import { ScreencastError } from "./errors.js";
15
+ /** Normalize raw PowerShell screen objects into ordered Monitor records.
16
+ * Primary monitor is sorted first so monitor:0 is the primary display. */
17
+ export function parseMonitors(raw) {
18
+ const arr = Array.isArray(raw) ? raw : raw ? [raw] : [];
19
+ const screens = arr.map((s) => ({
20
+ x: Number(s.X ?? 0),
21
+ y: Number(s.Y ?? 0),
22
+ width: Number(s.Width ?? 0),
23
+ height: Number(s.Height ?? 0),
24
+ primary: Boolean(s.Primary),
25
+ }));
26
+ screens.sort((a, b) => {
27
+ if (a.primary !== b.primary)
28
+ return a.primary ? -1 : 1;
29
+ if (a.x !== b.x)
30
+ return a.x - b.x;
31
+ return a.y - b.y;
32
+ });
33
+ return screens.map((s, index) => ({ index, ...s }));
34
+ }
35
+ const PS_SCRIPT = "Add-Type -AssemblyName System.Windows.Forms; " +
36
+ "[System.Windows.Forms.Screen]::AllScreens | ForEach-Object { " +
37
+ "[pscustomobject]@{ X=$_.Bounds.X; Y=$_.Bounds.Y; Width=$_.Bounds.Width; " +
38
+ "Height=$_.Bounds.Height; Primary=$_.Primary } } | ConvertTo-Json -Compress";
39
+ /** Query live monitor geometry on Windows. Throws on non-Windows or failure. */
40
+ export function getMonitors() {
41
+ if (process.platform !== "win32") {
42
+ throw new ScreencastError("Monitor enumeration is implemented for Windows (gdigrab) only.");
43
+ }
44
+ const res = spawnSync("powershell", ["-NoProfile", "-NonInteractive", "-Command", PS_SCRIPT], { encoding: "utf8", windowsHide: true });
45
+ if (res.status !== 0 || !res.stdout) {
46
+ throw new ScreencastError(`Could not enumerate monitors: ${res.stderr || "powershell failed"}`);
47
+ }
48
+ try {
49
+ return parseMonitors(JSON.parse(res.stdout));
50
+ }
51
+ catch (err) {
52
+ throw new ScreencastError(`Could not parse monitor geometry: ${err.message}`);
53
+ }
54
+ }
55
+ //# sourceMappingURL=monitors.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"monitors.js","sourceRoot":"","sources":["../../src/utils/monitors.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAC/C,OAAO,EAAE,eAAe,EA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ACtD,CAAC;AAED,MAAM,SAAS,GACb,+CAA+C;IAC/C,+DAA+D;IAC/D,0EAA0E;IAC1E,4EAA4E,CAAC;AAE/E,gFAAgF;AAChF,MAAM,UAAU,WAAW;IACzB,IAAI,OAAO,CAAC,QAAQ,KAAK,OAAO,EAAE,CAAC;QACjC,MAAM,IAAI,eAAe,CACvB,gEAAgE,CACjE,CAAC;IACJ,CAAC;IACD,MAAM,GAAG,GAAG,SAAS,CACnB,YAAY,EACZ,CAAC,YAAY,EAAE,iBAAiB,EAAE,UAAU,EAAE,SAAS,CAAC,EACxD,EAAE,QAAQ,EAAE,MAAM,EAAE,WAAW,EAAE,IAAI,EAAE,CACxC,CAAC;IACF,IAAI,GAAG,CAAC,MAAM,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,MAAM,EAAE,CAAC;QACpC,MAAM,IAAI,eAAe,CACvB,iCAAiC,GAAG,CAAC,MAAM,IAAI,mBAAmB,EAAE,CACrE,CAAC;IACJ,CAAC;IACD,IAAI,CAAC;QACH,OAAO,aAAa,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC;IAC/C,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,MAAM,IAAI,eAAe,CACvB,qCAAsC,GAAa,CAAC,OAAO,EAAE,CAC9D,CAAC;IACJ,CAAC;AACH,CAAC"}
@@ -0,0 +1,11 @@
1
+ export declare function homeRoot(): string;
2
+ export declare function subdir(name: "recordings" | "frames" | "screenshots" | "edits"): string;
3
+ /** The on-disk session registry path. */
4
+ export declare function registryPath(): string;
5
+ /** A compact UTC timestamp like 20260615-192430-880. */
6
+ export declare function stamp(date?: Date): string;
7
+ /** Short random suffix to make ids/filenames unique within the same ms. */
8
+ export declare function rand(n?: number): string;
9
+ /** Resolve a caller-supplied output path, or build a default under a subdir. */
10
+ export declare function resolveOutput(provided: string | undefined, defaultDir: string, defaultName: string): string;
11
+ //# sourceMappingURL=paths.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"paths.d.ts","sourceRoot":"","sources":["../../src/utils/paths.ts"],"names":[],"mappings":"AAaA,wBAAgB,QAAQ,IAAI,MAAM,CAIjC;AAED,wBAAgB,MAAM,CAAC,IAAI,EAAE,YAAY,GAAG,QAAQ,GAAG,aAAa,GAAG,OAAO,GAAG,MAAM,CAItF;AAED,yCAAyC;AACzC,wBAAgB,YAAY,IAAI,MAAM,CAIrC;AAED,wDAAwD;AACxD,wBAAgB,KAAK,CAAC,IAAI,OAAa,GAAG,MAAM,CAI/C;AAED,2EAA2E;AAC3E,wBAAgB,IAAI,CAAC,CAAC,SAAI,GAAG,MAAM,CAElC;AAED,gFAAgF;AAChF,wBAAgB,aAAa,CAC3B,QAAQ,EAAE,MAAM,GAAG,SAAS,EAC5B,UAAU,EAAE,MAAM,EAClB,WAAW,EAAE,MAAM,GAClB,MAAM,CAKR"}
@@ -0,0 +1,47 @@
1
+ /**
2
+ * Output location and filename helpers.
3
+ *
4
+ * By default everything the server writes lands under SCREENCAST_HOME
5
+ * (default: <homedir>/.screencast-mcp), NOT the current working directory, so
6
+ * captures never accidentally land inside a checked-out repo. Callers may still
7
+ * pass an absolute `output` path per call. The repo .gitignore is a second line
8
+ * of defence for the case where output is pointed back into the project.
9
+ */
10
+ import { homedir } from "node:os";
11
+ import { join, isAbsolute, resolve } from "node:path";
12
+ import { mkdirSync } from "node:fs";
13
+ export function homeRoot() {
14
+ const override = process.env.SCREENCAST_HOME;
15
+ if (override && override.trim().length > 0)
16
+ return override;
17
+ return join(homedir(), ".screencast-mcp");
18
+ }
19
+ export function subdir(name) {
20
+ const dir = join(homeRoot(), name);
21
+ mkdirSync(dir, { recursive: true });
22
+ return dir;
23
+ }
24
+ /** The on-disk session registry path. */
25
+ export function registryPath() {
26
+ const dir = homeRoot();
27
+ mkdirSync(dir, { recursive: true });
28
+ return join(dir, "sessions.json");
29
+ }
30
+ /** A compact UTC timestamp like 20260615-192430-880. */
31
+ export function stamp(date = new Date()) {
32
+ const iso = date.toISOString().replace(/[-:T]/g, "").replace(/\..+/, "");
33
+ const ms = String(date.getMilliseconds()).padStart(3, "0");
34
+ return `${iso.slice(0, 8)}-${iso.slice(8, 14)}-${ms}`;
35
+ }
36
+ /** Short random suffix to make ids/filenames unique within the same ms. */
37
+ export function rand(n = 4) {
38
+ return Math.random().toString(36).slice(2, 2 + n);
39
+ }
40
+ /** Resolve a caller-supplied output path, or build a default under a subdir. */
41
+ export function resolveOutput(provided, defaultDir, defaultName) {
42
+ if (provided && provided.trim().length > 0) {
43
+ return isAbsolute(provided) ? provided : resolve(provided);
44
+ }
45
+ return join(defaultDir, defaultName);
46
+ }
47
+ //# sourceMappingURL=paths.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"paths.js","sourceRoot":"","sources":["../../src/utils/paths.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAClC,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACtD,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAEpC,MAAM,UAAU,QAAQ;IACtB,MAAM,QAAQ,GAAG,OAAO,CAAC,GAAG,CAAC,eAAe,CAAC;IAC7C,IAAI,QAAQ,IAAI,QAAQ,CAAC,IAAI,EAAE,CAAC,MAAM,GAAG,CAAC;QAAE,OAAO,QAAQ,CAAC;IAC5D,OAAO,IAAI,CAAC,OAAO,EAAE,EAAE,iBAAiB,CAAC,CAAC;AAC5C,CAAC;AAED,MAAM,UAAU,MAAM,CAAC,IAAuD;IAC5E,MAAM,GAAG,GAAG,IAAI,CAAC,QAAQ,EAAE,EAAE,IAAI,CAAC,CAAC;IACnC,SAAS,CAAC,GAAG,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;IACpC,OAAO,GAAG,CAAC;AACb,CAAC;AAED,yCAAyC;AACzC,MAAM,UAAU,YA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"}
@@ -0,0 +1,24 @@
1
+ /**
2
+ * Shared capture-target resolution for screenshot and start_recording.
3
+ *
4
+ * This is the one place that turns a raw target spec into the concrete
5
+ * (target, monitors) pair the gdigrab argument builders consume, so both the
6
+ * still and the recording paths get identical behaviour:
7
+ * - monitor:<i> -> its pixel bounds (queried live)
8
+ * - window:<title> -> the on-screen RECTANGLE the window occupies, captured
9
+ * via the proven region path (NOT gdigrab title=, which grabs a blank
10
+ * surface for GPU-composited windows). The rect is resolved once, here.
11
+ * - full / region -> passed through unchanged.
12
+ */
13
+ import { type Target } from "./targets.js";
14
+ import { type Monitor } from "./monitors.js";
15
+ import { type WindowBounds } from "./windows.js";
16
+ export interface ResolvedTarget {
17
+ target: Target;
18
+ monitors: Monitor[];
19
+ /** Present only when the raw spec was a window: surfaced for the result. */
20
+ window?: WindowBounds;
21
+ }
22
+ /** Resolve a raw target spec into builder-ready (target, monitors). */
23
+ export declare function resolveCaptureTarget(spec: string): ResolvedTarget;
24
+ //# sourceMappingURL=resolveTarget.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resolveTarget.d.ts","sourceRoot":"","sources":["../../src/utils/resolveTarget.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,OAAO,EAAe,KAAK,MAAM,EAAE,MAAM,cAAc,CAAC;AACxD,OAAO,EAAe,KAAK,OAAO,EAAE,MAAM,eAAe,CAAC;AAC1D,OAAO,EAAuB,KAAK,YAAY,EAAE,MAAM,cAAc,CAAC;AAEtE,MAAM,WAAW,cAAc;IAC7B,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,OAAO,EAAE,CAAC;IACpB,4EAA4E;IAC5E,MAAM,CAAC,EAAE,YAAY,CAAC;CACvB;AAED,uEAAuE;AACvE,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,MAAM,GAAG,cAAc,CAcjE"}
@@ -0,0 +1,32 @@
1
+ /**
2
+ * Shared capture-target resolution for screenshot and start_recording.
3
+ *
4
+ * This is the one place that turns a raw target spec into the concrete
5
+ * (target, monitors) pair the gdigrab argument builders consume, so both the
6
+ * still and the recording paths get identical behaviour:
7
+ * - monitor:<i> -> its pixel bounds (queried live)
8
+ * - window:<title> -> the on-screen RECTANGLE the window occupies, captured
9
+ * via the proven region path (NOT gdigrab title=, which grabs a blank
10
+ * surface for GPU-composited windows). The rect is resolved once, here.
11
+ * - full / region -> passed through unchanged.
12
+ */
13
+ import { parseTarget } from "./targets.js";
14
+ import { getMonitors } from "./monitors.js";
15
+ import { resolveWindowBounds } from "./windows.js";
16
+ /** Resolve a raw target spec into builder-ready (target, monitors). */
17
+ export function resolveCaptureTarget(spec) {
18
+ const parsed = parseTarget(spec);
19
+ if (parsed.kind === "window") {
20
+ const w = resolveWindowBounds(parsed.title);
21
+ return {
22
+ target: { kind: "region", x: w.x, y: w.y, w: w.width, h: w.height },
23
+ monitors: [],
24
+ window: w,
25
+ };
26
+ }
27
+ if (parsed.kind === "monitor") {
28
+ return { target: parsed, monitors: getMonitors() };
29
+ }
30
+ return { target: parsed, monitors: [] };
31
+ }
32
+ //# sourceMappingURL=resolveTarget.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resolveTarget.js","sourceRoot":"","sources":["../../src/utils/resolveTarget.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,OAAO,EAAE,WAAW,EAAe,MAAM,cAAc,CAAC;AACxD,OAAO,EAAE,WAAW,EAAgB,MAAM,eAAe,CAAC;AAC1D,OAAO,EAAE,mBAAmB,EAAqB,MAAM,cAAc,CAAC;AAStE,uEAAuE;AACvE,MAAM,UAAU,oBAAoB,CAAC,IAAY;IAC/C,MAAM,MAAM,GAAG,WAAW,CAAC,IAAI,CAAC,CAAC;IACjC,IAAI,MAAM,CAAC,IAAI,KAAK,QAAQ,EAAE,CAAC;QAC7B,MAAM,CAAC,GAAG,mBAAmB,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;QAC5C,OAAO;YACL,MAAM,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,KAAK,EAAE,CAAC,EAAE,CAAC,CAAC,MAAM,EAAE;YACnE,QAAQ,EAAE,EAAE;YACZ,MAAM,EAAE,CAAC;SACV,CAAC;IACJ,CAAC;IACD,IAAI,MAAM,CAAC,IAAI,KAAK,SAAS,EAAE,CAAC;QAC9B,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,WAAW,EAAE,EAAE,CAAC;IACrD,CAAC;IACD,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,EAAE,EAAE,CAAC;AAC1C,CAAC"}
@@ -0,0 +1,51 @@
1
+ import type { ChildProcess } from "node:child_process";
2
+ import type { Quality } from "./targets.js";
3
+ export type SessionStatus = "recording" | "stopped" | "failed" | "orphaned";
4
+ export interface SessionRecord {
5
+ id: string;
6
+ target: string;
7
+ outputPath: string;
8
+ fps: number;
9
+ quality: Quality;
10
+ pid: number | null;
11
+ status: SessionStatus;
12
+ startedAt: string;
13
+ stoppedAt?: string;
14
+ durationSec?: number;
15
+ error?: string;
16
+ }
17
+ /** Decide what an in-progress session becomes at boot, given liveness.
18
+ * Pure: a still-alive pid is an orphan to be reaped; a dead one simply ended. */
19
+ export declare function classifyOrphan(record: SessionRecord, alive: boolean): {
20
+ status: SessionStatus;
21
+ reaped: boolean;
22
+ };
23
+ /** True if a pid exists. `process.kill(pid, 0)` throws ESRCH when it does not. */
24
+ export declare function isAlive(pid: number | null): boolean;
25
+ /** On Windows, confirm a pid is actually an ffmpeg.exe before killing it, so a
26
+ * recycled pid belonging to an unrelated process is never terminated. */
27
+ export declare function isFfmpegProcess(pid: number | null): boolean;
28
+ /** Forcefully terminate a pid tree (used only for orphan reaping). */
29
+ export declare function killPid(pid: number): void;
30
+ export declare class SessionStore {
31
+ private readonly path;
32
+ private records;
33
+ private children;
34
+ constructor(path: string);
35
+ load(): void;
36
+ persist(): void;
37
+ create(record: SessionRecord): void;
38
+ get(id: string): SessionRecord | undefined;
39
+ list(): SessionRecord[];
40
+ update(id: string, patch: Partial<SessionRecord>): SessionRecord | undefined;
41
+ attachChild(id: string, child: ChildProcess): void;
42
+ getChild(id: string): ChildProcess | undefined;
43
+ detachChild(id: string): void;
44
+ /**
45
+ * Reconcile persisted "recording" sessions at boot: kill any ffmpeg child
46
+ * that outlived the previous server, and mark records accordingly. Returns
47
+ * the ids that were reaped.
48
+ */
49
+ reapOrphans(): string[];
50
+ }
51
+ //# sourceMappingURL=sessions.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sessions.d.ts","sourceRoot":"","sources":["../../src/utils/sessions.ts"],"names":[],"mappings":"AAcA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AACvD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAE5C,MAAM,MAAM,aAAa,GAAG,WAAW,GAAG,SAAS,GAAG,QAAQ,GAAG,UAAU,CAAC;AAE5E,MAAM,WAAW,aAAa;IAC5B,EAAE,EAAE,MAAM,CAAC;IACX,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,MAAM,CAAC;IACnB,GAAG,EAAE,MAAM,CAAC;IACZ,OAAO,EAAE,OAAO,CAAC;IACjB,GAAG,EAAE,MAAM,GAAG,IAAI,CAAC;IACnB,MAAM,EAAE,aAAa,CAAC;IACtB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED;iFACiF;AACjF,wBAAgB,cAAc,CAC5B,MAAM,EAAE,aAAa,EACrB,KAAK,EAAE,OAAO,GACb;IAAE,MAAM,EAAE,aAAa,CAAC;IAAC,MAAM,EAAE,OAAO,CAAA;CAAE,CAO5C;AAED,kFAAkF;AAClF,wBAAgB,OAAO,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,GAAG,OAAO,CAQnD;AAED;yEACyE;AACzE,wBAAgB,eAAe,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,GAAG,OAAO,CAS3D;AAED,sEAAsE;AACtE,wBAAgB,OAAO,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAazC;AAED,qBAAa,YAAY;IAIX,OAAO,CAAC,QAAQ,CAAC,IAAI;IAHjC,OAAO,CAAC,OAAO,CAAoC;IACnD,OAAO,CAAC,QAAQ,CAAmC;gBAEtB,IAAI,EAAE,MAAM;IAEzC,IAAI,IAAI,IAAI;IAUZ,OAAO,IAAI,IAAI;IAIf,MAAM,CAAC,MAAM,EAAE,aAAa,GAAG,IAAI;IAKnC,GAAG,CAAC,EAAE,EAAE,MAAM,GAAG,aAAa,GAAG,SAAS;IAI1C,IAAI,IAAI,aAAa,EAAE;IAMvB,MAAM,CAAC,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,CAAC,aAAa,CAAC,GAAG,aAAa,GAAG,SAAS;IAS5E,WAAW,CAAC,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,YAAY,GAAG,IAAI;IAIlD,QAAQ,CAAC,EAAE,EAAE,MAAM,GAAG,YAAY,GAAG,SAAS;IAI9C,WAAW,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI;IAI7B;;;;OAIG;IACH,WAAW,IAAI,MAAM,EAAE;CAuBxB"}
@@ -0,0 +1,144 @@
1
+ /**
2
+ * Recording session registry.
3
+ *
4
+ * Sessions are tracked both in memory (with a live child-process handle for
5
+ * graceful stop) and on disk (sessions.json) so that:
6
+ * - stop/list/get survive within a server run, and
7
+ * - a crash leaves a durable record the next boot can reconcile (orphan
8
+ * reaping), ensuring no ffmpeg child silently outlives the server.
9
+ *
10
+ * The child handle is intentionally NOT persisted; only the pid is. Reaping
11
+ * logic (classifyOrphan) is pure so it is unit-tested without real processes.
12
+ */
13
+ import { spawnSync } from "node:child_process";
14
+ import { readFileSync, writeFileSync, existsSync } from "node:fs";
15
+ /** Decide what an in-progress session becomes at boot, given liveness.
16
+ * Pure: a still-alive pid is an orphan to be reaped; a dead one simply ended. */
17
+ export function classifyOrphan(record, alive) {
18
+ if (record.status !== "recording") {
19
+ return { status: record.status, reaped: false };
20
+ }
21
+ return alive
22
+ ? { status: "orphaned", reaped: true }
23
+ : { status: "stopped", reaped: false };
24
+ }
25
+ /** True if a pid exists. `process.kill(pid, 0)` throws ESRCH when it does not. */
26
+ export function isAlive(pid) {
27
+ if (pid === null || !Number.isInteger(pid) || pid <= 0)
28
+ return false;
29
+ try {
30
+ process.kill(pid, 0);
31
+ return true;
32
+ }
33
+ catch (err) {
34
+ return err.code === "EPERM";
35
+ }
36
+ }
37
+ /** On Windows, confirm a pid is actually an ffmpeg.exe before killing it, so a
38
+ * recycled pid belonging to an unrelated process is never terminated. */
39
+ export function isFfmpegProcess(pid) {
40
+ if (pid === null || process.platform !== "win32")
41
+ return false;
42
+ const res = spawnSync("tasklist", ["/FI", `PID eq ${pid}`, "/FO", "CSV", "/NH"], { encoding: "utf8", windowsHide: true });
43
+ if (res.status !== 0 || !res.stdout)
44
+ return false;
45
+ return /"ffmpeg\.exe"/i.test(res.stdout);
46
+ }
47
+ /** Forcefully terminate a pid tree (used only for orphan reaping). */
48
+ export function killPid(pid) {
49
+ if (process.platform === "win32") {
50
+ spawnSync("taskkill", ["/PID", String(pid), "/T", "/F"], {
51
+ stdio: "ignore",
52
+ windowsHide: true,
53
+ });
54
+ }
55
+ else {
56
+ try {
57
+ process.kill(pid, "SIGKILL");
58
+ }
59
+ catch {
60
+ /* already gone */
61
+ }
62
+ }
63
+ }
64
+ export class SessionStore {
65
+ path;
66
+ records = new Map();
67
+ children = new Map();
68
+ constructor(path) {
69
+ this.path = path;
70
+ }
71
+ load() {
72
+ if (!existsSync(this.path))
73
+ return;
74
+ try {
75
+ const data = JSON.parse(readFileSync(this.path, "utf8"));
76
+ this.records = new Map(data.map((r) => [r.id, r]));
77
+ }
78
+ catch {
79
+ this.records = new Map();
80
+ }
81
+ }
82
+ persist() {
83
+ writeFileSync(this.path, JSON.stringify([...this.records.values()], null, 2));
84
+ }
85
+ create(record) {
86
+ this.records.set(record.id, record);
87
+ this.persist();
88
+ }
89
+ get(id) {
90
+ return this.records.get(id);
91
+ }
92
+ list() {
93
+ return [...this.records.values()].sort((a, b) => a.startedAt < b.startedAt ? 1 : -1);
94
+ }
95
+ update(id, patch) {
96
+ const cur = this.records.get(id);
97
+ if (!cur)
98
+ return undefined;
99
+ const next = { ...cur, ...patch };
100
+ this.records.set(id, next);
101
+ this.persist();
102
+ return next;
103
+ }
104
+ attachChild(id, child) {
105
+ this.children.set(id, child);
106
+ }
107
+ getChild(id) {
108
+ return this.children.get(id);
109
+ }
110
+ detachChild(id) {
111
+ this.children.delete(id);
112
+ }
113
+ /**
114
+ * Reconcile persisted "recording" sessions at boot: kill any ffmpeg child
115
+ * that outlived the previous server, and mark records accordingly. Returns
116
+ * the ids that were reaped.
117
+ */
118
+ reapOrphans() {
119
+ const reaped = [];
120
+ for (const record of this.records.values()) {
121
+ if (record.status !== "recording")
122
+ continue;
123
+ const alive = isAlive(record.pid);
124
+ const verdict = classifyOrphan(record, alive);
125
+ if (verdict.reaped && record.pid !== null) {
126
+ if (isFfmpegProcess(record.pid))
127
+ killPid(record.pid);
128
+ reaped.push(record.id);
129
+ }
130
+ this.records.set(record.id, {
131
+ ...record,
132
+ status: verdict.status,
133
+ stoppedAt: record.stoppedAt ?? new Date().toISOString(),
134
+ error: verdict.status === "orphaned"
135
+ ? "Reaped on server restart (recording was interrupted)."
136
+ : record.error,
137
+ });
138
+ }
139
+ if (this.records.size > 0)
140
+ this.persist();
141
+ return reaped;
142
+ }
143
+ }
144
+ //# sourceMappingURL=sessions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sessions.js","sourceRoot":"","sources":["../../src/utils/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