cbrowser 18.69.3 → 18.71.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 (67) hide show
  1. package/dist/browser.d.ts +32 -0
  2. package/dist/browser.d.ts.map +1 -1
  3. package/dist/browser.js +46 -2
  4. package/dist/browser.js.map +1 -1
  5. package/dist/cli.js +1465 -24
  6. package/dist/cli.js.map +1 -1
  7. package/dist/cognitive/index.d.ts +10 -0
  8. package/dist/cognitive/index.d.ts.map +1 -1
  9. package/dist/cognitive/index.js +8 -0
  10. package/dist/cognitive/index.js.map +1 -1
  11. package/dist/daemon.d.ts.map +1 -1
  12. package/dist/daemon.js +151 -3
  13. package/dist/daemon.js.map +1 -1
  14. package/dist/mcp-server.d.ts.map +1 -1
  15. package/dist/mcp-server.js +67 -0
  16. package/dist/mcp-server.js.map +1 -1
  17. package/dist/mcp-tools/base/capture-tools.d.ts +189 -0
  18. package/dist/mcp-tools/base/capture-tools.d.ts.map +1 -0
  19. package/dist/mcp-tools/base/capture-tools.js +667 -0
  20. package/dist/mcp-tools/base/capture-tools.js.map +1 -0
  21. package/dist/mcp-tools/base/gif-tools.d.ts +19 -0
  22. package/dist/mcp-tools/base/gif-tools.d.ts.map +1 -1
  23. package/dist/mcp-tools/base/gif-tools.js +45 -27
  24. package/dist/mcp-tools/base/gif-tools.js.map +1 -1
  25. package/dist/mcp-tools/base/index.d.ts +2 -1
  26. package/dist/mcp-tools/base/index.d.ts.map +1 -1
  27. package/dist/mcp-tools/base/index.js +5 -1
  28. package/dist/mcp-tools/base/index.js.map +1 -1
  29. package/dist/mcp-tools/tool-categories.d.ts.map +1 -1
  30. package/dist/mcp-tools/tool-categories.js +11 -0
  31. package/dist/mcp-tools/tool-categories.js.map +1 -1
  32. package/dist/recording/auto-capture.d.ts +72 -0
  33. package/dist/recording/auto-capture.d.ts.map +1 -0
  34. package/dist/recording/auto-capture.js +155 -0
  35. package/dist/recording/auto-capture.js.map +1 -0
  36. package/dist/recording/contact-sheet.d.ts +65 -0
  37. package/dist/recording/contact-sheet.d.ts.map +1 -0
  38. package/dist/recording/contact-sheet.js +204 -0
  39. package/dist/recording/contact-sheet.js.map +1 -0
  40. package/dist/recording/encoders.d.ts +101 -0
  41. package/dist/recording/encoders.d.ts.map +1 -0
  42. package/dist/recording/encoders.js +304 -0
  43. package/dist/recording/encoders.js.map +1 -0
  44. package/dist/recording/engine.d.ts +263 -0
  45. package/dist/recording/engine.d.ts.map +1 -0
  46. package/dist/recording/engine.js +890 -0
  47. package/dist/recording/engine.js.map +1 -0
  48. package/dist/recording/ssim.d.ts +35 -0
  49. package/dist/recording/ssim.d.ts.map +1 -0
  50. package/dist/recording/ssim.js +113 -0
  51. package/dist/recording/ssim.js.map +1 -0
  52. package/dist/recording/timing.d.ts +124 -0
  53. package/dist/recording/timing.d.ts.map +1 -0
  54. package/dist/recording/timing.js +251 -0
  55. package/dist/recording/timing.js.map +1 -0
  56. package/dist/recording/types.d.ts +213 -0
  57. package/dist/recording/types.d.ts.map +1 -0
  58. package/dist/recording/types.js +171 -0
  59. package/dist/recording/types.js.map +1 -0
  60. package/dist/testing/nl-test-suite.d.ts +13 -1
  61. package/dist/testing/nl-test-suite.d.ts.map +1 -1
  62. package/dist/testing/nl-test-suite.js +91 -6
  63. package/dist/testing/nl-test-suite.js.map +1 -1
  64. package/dist/types.d.ts +25 -1
  65. package/dist/types.d.ts.map +1 -1
  66. package/dist/types.js.map +1 -1
  67. package/package.json +1 -1
@@ -0,0 +1,189 @@
1
+ /**
2
+ * CBrowser MCP Tools - Screen Capture Tools
3
+ *
4
+ * Screen capture (pixels -> GIF/WebP/video), exposed as `capture_start`,
5
+ * `capture_stop`, `capture_status`.
6
+ *
7
+ * Distinct from the `record` feature, which records user ACTIONS for test
8
+ * generation. Nothing here touches that.
9
+ *
10
+ * The response discipline is the point of this module: a recording is hundreds
11
+ * of frames and tens of megabytes of video, none of which can cross an MCP
12
+ * boundary. Frames and artifacts are returned as PATHS; the only inlined pixels
13
+ * are a contact sheet sized to whatever is left of the response budget after
14
+ * the JSON payload is measured.
15
+ *
16
+ * @copyright 2026 Alexandria Eden alexandria.shai.eden@gmail.com https://cbrowser.ai
17
+ * @license MIT
18
+ */
19
+ import { z } from "zod";
20
+ import { type CaptureFormat } from "../../recording/engine.js";
21
+ import type { RecordingManifest } from "../../recording/types.js";
22
+ import type { CBrowser, McpServer, ToolRegistrationContext } from "../types.js";
23
+ /** Exposed for tests and for `reset_browser`-style teardown. */
24
+ export declare function clearCaptureSessions(): void;
25
+ /** Parse "5s", "2m", "1500ms" or a bare millisecond count. */
26
+ export declare function parseDurationMs(input: string): number;
27
+ /** Parse "gif,webp,mp4" into validated formats. */
28
+ export declare function parseFormats(input: string): CaptureFormat[];
29
+ /**
30
+ * Resolve a viewport argument: either `WxH` or the name of a built-in preset
31
+ * (`mobile`, `tablet`, `desktop-lg`, ...).
32
+ */
33
+ export declare function parseViewport(input: string): {
34
+ width: number;
35
+ height: number;
36
+ };
37
+ /** Parse "x,y,width,height" into a rect. */
38
+ export declare function parseRegion(input: string): {
39
+ x: number;
40
+ y: number;
41
+ width: number;
42
+ height: number;
43
+ };
44
+ export interface CaptureStopPayload {
45
+ success: true;
46
+ slug: string;
47
+ manifest_path: string;
48
+ out_dir: string;
49
+ frames: number;
50
+ target_fps: number;
51
+ actual_fps: number;
52
+ duration_ms: number;
53
+ capture_method: string;
54
+ engine: string;
55
+ output_dims: {
56
+ width: number;
57
+ height: number;
58
+ };
59
+ target: RecordingManifest["target"];
60
+ region_clamped?: boolean;
61
+ artifacts: Record<string, string>;
62
+ encode_errors?: Record<string, string>;
63
+ change_points: number[];
64
+ change_points_total: number;
65
+ frame_gaps: {
66
+ after_index: number;
67
+ gap_ms: number;
68
+ }[];
69
+ frame_gaps_total: number;
70
+ console_errors: string[];
71
+ console_errors_total: number;
72
+ network_requests_total: number;
73
+ frames_dir: string;
74
+ contact_sheet?: string;
75
+ contact_sheet_note?: string;
76
+ note: string;
77
+ }
78
+ /**
79
+ * Build the `capture_stop` JSON payload from a manifest.
80
+ *
81
+ * Deliberately excludes the frame array: 500 frames of paths, crops, SSIM
82
+ * scores and per-frame console/network records is megabytes of JSON that would
83
+ * blow the response budget and tell the model nothing it can act on. The frames
84
+ * live on disk and the directory is named instead. Unbounded lists
85
+ * (change points, gaps, console errors) are truncated with their true totals
86
+ * reported alongside, so the model can tell "3 change points" from
87
+ * "200 shown of 4,812".
88
+ *
89
+ * Pure and exported so the budget can be tested without running a browser.
90
+ */
91
+ export declare function buildCaptureStopPayload(manifest: RecordingManifest, extra: {
92
+ manifestPath: string;
93
+ outDir: string;
94
+ encodeErrors?: Record<string, string>;
95
+ contactSheet?: string;
96
+ contactSheetNote?: string;
97
+ }): CaptureStopPayload;
98
+ /**
99
+ * Last line of defence on the response budget.
100
+ *
101
+ * The payload builder and the contact-sheet budget already keep the response
102
+ * small, but "small by construction" is a claim about code that can drift. This
103
+ * measures the actual serialized content blocks and sheds until they fit:
104
+ * image blocks first (the sheet is a convenience, the paths are the payload),
105
+ * then the text block itself, replaced by a minimal pointer to the manifest.
106
+ *
107
+ * An over-budget response is therefore not merely unlikely, it cannot be
108
+ * returned — the tool would have to skip this function to emit one.
109
+ */
110
+ export declare function enforceResponseBudget<T extends {
111
+ type: string;
112
+ text?: string;
113
+ data?: string;
114
+ }>(content: T[], maxBytes?: number, fallbackText?: string): T[];
115
+ /**
116
+ * Byte budget left for an inlined contact sheet once the JSON payload is
117
+ * accounted for. Returns 0 when there is no room worth using.
118
+ */
119
+ export declare function contactSheetBudget(payloadBytes: number, totalBudget?: number): number;
120
+ export interface CaptureStartArgs {
121
+ url?: string;
122
+ fps?: number;
123
+ duration?: string;
124
+ viewport?: string;
125
+ region?: string;
126
+ element?: string;
127
+ padding?: number;
128
+ format?: string;
129
+ quality?: number;
130
+ max_frames?: number;
131
+ name?: string;
132
+ out_dir?: string;
133
+ }
134
+ /** Start a capture on the given browser. Returns the payload object. */
135
+ export declare function startCapture(browser: CBrowser, args: CaptureStartArgs, token?: string): Promise<Record<string, unknown>>;
136
+ /**
137
+ * Stop the capture and build the response payload plus a budget-fitted contact
138
+ * sheet. Returns the payload and the sheet path (if one was produced).
139
+ */
140
+ export declare function stopCapture(token?: string): Promise<{
141
+ payload: CaptureStopPayload;
142
+ contactSheet?: string;
143
+ }>;
144
+ /**
145
+ * Report the running or most recent capture for this browser session.
146
+ *
147
+ * Two rules, in tension, both honoured:
148
+ * - A running capture is never invisible. If one is live on another token or
149
+ * in another process, it is always surfaced.
150
+ * - The caller's own capture is never masked by someone else's. A session
151
+ * that just finished a recording is told about its own run first, with the
152
+ * other capture attached alongside rather than in place of it.
153
+ *
154
+ * The failure this replaces: after `capture_stop`, status reported
155
+ * "No capture has been started on this browser session" — the completed run
156
+ * vanished with the session object, reading as though it never happened.
157
+ */
158
+ export declare function captureStatus(token?: string): Record<string, unknown>;
159
+ /** Input schema shared by both servers, so the two cannot drift. */
160
+ export declare const captureStartSchema: {
161
+ url: z.ZodOptional<z.ZodString>;
162
+ fps: z.ZodOptional<z.ZodNumber>;
163
+ duration: z.ZodOptional<z.ZodString>;
164
+ viewport: z.ZodOptional<z.ZodString>;
165
+ region: z.ZodOptional<z.ZodString>;
166
+ element: z.ZodOptional<z.ZodString>;
167
+ padding: z.ZodOptional<z.ZodNumber>;
168
+ format: z.ZodOptional<z.ZodString>;
169
+ quality: z.ZodOptional<z.ZodNumber>;
170
+ max_frames: z.ZodOptional<z.ZodNumber>;
171
+ name: z.ZodOptional<z.ZodString>;
172
+ out_dir: z.ZodOptional<z.ZodString>;
173
+ _browserToken: z.ZodOptional<z.ZodString>;
174
+ };
175
+ export declare const captureStopSchema: {
176
+ _browserToken: z.ZodOptional<z.ZodString>;
177
+ };
178
+ export declare const captureStatusSchema: {
179
+ _browserToken: z.ZodOptional<z.ZodString>;
180
+ };
181
+ declare const CAPTURE_START_DESCRIPTION: string;
182
+ declare const CAPTURE_STOP_DESCRIPTION: string;
183
+ declare const CAPTURE_STATUS_DESCRIPTION: string;
184
+ /**
185
+ * Register capture tools (3 tools: capture_start, capture_stop, capture_status)
186
+ */
187
+ export declare function registerCaptureTools(server: McpServer, { getBrowser, getBrowserByToken }: ToolRegistrationContext): void;
188
+ export { CAPTURE_START_DESCRIPTION, CAPTURE_STOP_DESCRIPTION, CAPTURE_STATUS_DESCRIPTION };
189
+ //# sourceMappingURL=capture-tools.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"capture-tools.d.ts","sourceRoot":"","sources":["../../../src/mcp-tools/base/capture-tools.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAIH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAKxB,OAAO,EAAuB,KAAK,aAAa,EAA4B,MAAM,2BAA2B,CAAC;AAC9G,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAGlE,OAAO,KAAK,EAAE,QAAQ,EAAE,SAAS,EAAE,uBAAuB,EAAE,MAAM,aAAa,CAAC;AA6DhF,gEAAgE;AAChE,wBAAgB,oBAAoB,IAAI,IAAI,CAG3C;AAgCD,8DAA8D;AAC9D,wBAAgB,eAAe,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAUrD;AAED,mDAAmD;AACnD,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,aAAa,EAAE,CAQ3D;AAED;;;GAGG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,MAAM,GAAG;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAmB9E;AAED,4CAA4C;AAC5C,wBAAgB,WAAW,CAAC,KAAK,EAAE,MAAM,GAAG;IAAE,CAAC,EAAE,MAAM,CAAC;IAAC,CAAC,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAUlG;AAMD,MAAM,WAAW,k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