@cappa/protocol 0.9.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Tim Richter
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/dist/index.cjs ADDED
@@ -0,0 +1,498 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ let zod = require("zod");
3
+ //#region src/screenshot.ts
4
+ /**
5
+ * Screenshot shapes as they cross the wire.
6
+ *
7
+ * These mirror the types in `@cappa/core`, but are declared independently on
8
+ * purpose: this package must stay installable by a browser client that has no
9
+ * business pulling in `playwright-core` or native diff bindings. A type-level
10
+ * compatibility assertion in `screenshot.test.ts` fails the build if the two
11
+ * definitions drift apart.
12
+ */
13
+ const screenshotCategorySchema = zod.z.enum([
14
+ "new",
15
+ "deleted",
16
+ "changed",
17
+ "passed"
18
+ ]);
19
+ const diffMetadataSchema = zod.z.object({
20
+ numDiffPixels: zod.z.number(),
21
+ percentDifference: zod.z.number(),
22
+ /**
23
+ * Structured diff interpretation, carried opaquely.
24
+ *
25
+ * Its shape is owned by the diff engine (`@blazediff/core-native`'s
26
+ * `InterpretResult`) and changes with that dependency. Pinning it here would
27
+ * make every diff-engine upgrade a breaking protocol change for no benefit,
28
+ * so the protocol passes it through untouched and consumers that want to
29
+ * render the detail narrow it with `InterpretResult` from `@cappa/core`.
30
+ */
31
+ interpretation: zod.z.unknown().optional()
32
+ });
33
+ const screenshotBase = {
34
+ id: zod.z.string(),
35
+ name: zod.z.string(),
36
+ approved: zod.z.boolean().optional(),
37
+ /**
38
+ * The capture task that produced this screenshot.
39
+ *
40
+ * Described here because it is the only way a client can re-capture one
41
+ * screenshot: `startRun` accepts task ids, and a screenshot's `name` is not
42
+ * one — Storybook writes `example/button/primary` for the task
43
+ * `example-button--primary`. Optional because the engine can only know it for
44
+ * screenshots captured since the capture manifest existed, so a client must
45
+ * treat its absence as "not re-capturable" rather than substituting `name`.
46
+ */
47
+ taskId: zod.z.string().optional(),
48
+ /** Plugin that owns `taskId`. Absent whenever `taskId` is. */
49
+ plugin: zod.z.string().optional(),
50
+ /**
51
+ * Neighbours in the full, unfiltered list, so the UI can walk every
52
+ * screenshot with the arrow keys regardless of the current filter.
53
+ *
54
+ * Computed by the server rather than the engine — but they must be described
55
+ * here, or a client parsing a response would silently drop them.
56
+ */
57
+ next: zod.z.string().optional(),
58
+ prev: zod.z.string().optional()
59
+ };
60
+ const newScreenshotSchema = zod.z.object({
61
+ ...screenshotBase,
62
+ category: zod.z.literal("new"),
63
+ actualPath: zod.z.string()
64
+ });
65
+ const deletedScreenshotSchema = zod.z.object({
66
+ ...screenshotBase,
67
+ category: zod.z.literal("deleted"),
68
+ expectedPath: zod.z.string()
69
+ });
70
+ const changedScreenshotSchema = zod.z.object({
71
+ ...screenshotBase,
72
+ category: zod.z.literal("changed"),
73
+ actualPath: zod.z.string(),
74
+ expectedPath: zod.z.string(),
75
+ diffPath: zod.z.string(),
76
+ diffMeta: diffMetadataSchema.optional()
77
+ });
78
+ const passedScreenshotSchema = zod.z.object({
79
+ ...screenshotBase,
80
+ category: zod.z.literal("passed"),
81
+ actualPath: zod.z.string(),
82
+ expectedPath: zod.z.string()
83
+ });
84
+ const screenshotSchema = zod.z.discriminatedUnion("category", [
85
+ newScreenshotSchema,
86
+ deletedScreenshotSchema,
87
+ changedScreenshotSchema,
88
+ passedScreenshotSchema
89
+ ]);
90
+ const screenshotQuerySchema = zod.z.object({
91
+ search: zod.z.string().optional(),
92
+ category: screenshotCategorySchema.optional()
93
+ });
94
+ const approveRequestSchema = zod.z.object({ names: zod.z.array(zod.z.string()).min(1, "names must be a non-empty array") });
95
+ const approveResultSchema = zod.z.object({
96
+ approved: zod.z.array(zod.z.string()),
97
+ errors: zod.z.array(zod.z.object({
98
+ name: zod.z.string(),
99
+ error: zod.z.string()
100
+ }))
101
+ });
102
+ //#endregion
103
+ //#region src/routes.ts
104
+ /**
105
+ * Bumped whenever the wire contract changes incompatibly.
106
+ *
107
+ * Served on `GET /api/health` and checked by `@cappa/client` on its first call,
108
+ * so a client built against an older server fails with a clear message instead
109
+ * of mis-parsing responses.
110
+ */
111
+ const PROTOCOL_VERSION = 1;
112
+ /** Capabilities a server advertises, so a client can hide what is unavailable. */
113
+ const capabilitiesSchema = zod.z.object({
114
+ /** Capture routes are mounted (false when the server is read-only). */
115
+ capture: zod.z.boolean(),
116
+ /** Screenshots can be approved. */
117
+ approve: zod.z.boolean(),
118
+ /** The run event stream is available. */
119
+ events: zod.z.boolean(),
120
+ /**
121
+ * The server can watch its own filesystem and re-capture on change.
122
+ *
123
+ * Optional so a client built against this version still parses an older
124
+ * server's health response, which has no such field. Absent means no.
125
+ */
126
+ watch: zod.z.boolean().optional()
127
+ });
128
+ const healthResponseSchema = zod.z.object({
129
+ ok: zod.z.boolean(),
130
+ protocolVersion: zod.z.number(),
131
+ capabilities: capabilitiesSchema
132
+ });
133
+ const configResponseSchema = zod.z.object({
134
+ theme: zod.z.enum(["light", "dark"]),
135
+ readOnly: zod.z.boolean()
136
+ });
137
+ const startRunResponseSchema = zod.z.object({ runId: zod.z.string() });
138
+ /**
139
+ * Machine-readable codes on error responses.
140
+ *
141
+ * Kept here, in the wire contract, rather than derived from `@cappa/core`'s
142
+ * error classes: a client must be able to tell a conflict from a validation
143
+ * failure without installing the engine. `@cappa/core` mirrors these values and
144
+ * a compatibility assertion there fails the build if they drift.
145
+ */
146
+ const ERROR_CODES = {
147
+ runInProgress: "CAPPA_RUN_IN_PROGRESS",
148
+ unknownTargets: "CAPPA_UNKNOWN_TARGETS",
149
+ watchInProgress: "CAPPA_WATCH_IN_PROGRESS"
150
+ };
151
+ const errorResponseSchema = zod.z.object({
152
+ error: zod.z.unknown(),
153
+ code: zod.z.string().optional(),
154
+ activeRunId: zod.z.string().optional(),
155
+ taskIds: zod.z.array(zod.z.string()).optional()
156
+ });
157
+ /** Every route the server exposes, in one place. */
158
+ const routes = {
159
+ health: "/api/health",
160
+ config: "/api/config",
161
+ plugins: "/api/plugins",
162
+ targets: "/api/targets",
163
+ runs: "/api/runs",
164
+ run: (id) => `/api/runs/${encodeURIComponent(id)}`,
165
+ runCancel: (id) => `/api/runs/${encodeURIComponent(id)}/cancel`,
166
+ runEvents: (id) => `/api/runs/${encodeURIComponent(id)}/events`,
167
+ screenshots: "/api/screenshots",
168
+ screenshot: (id) => `/api/screenshots/${encodeURIComponent(id)}`,
169
+ approveBatch: "/api/screenshots/approve-batch",
170
+ watch: "/api/watch",
171
+ watchEvents: "/api/watch/events"
172
+ };
173
+ /** Prefix under which screenshot images are served. */
174
+ const ASSET_PREFIX = "/assets/screenshots";
175
+ /** Header carrying the access token when the server is not on loopback. */
176
+ const TOKEN_HEADER = "x-cappa-token";
177
+ const targetsQuerySchema = zod.z.object({ refresh: zod.z.union([
178
+ zod.z.literal("1"),
179
+ zod.z.literal("true"),
180
+ zod.z.literal("0"),
181
+ zod.z.literal("false")
182
+ ]).optional() });
183
+ //#endregion
184
+ //#region src/run.ts
185
+ const runStateSchema = zod.z.enum([
186
+ "idle",
187
+ "discovering",
188
+ "running",
189
+ "completed",
190
+ "failed",
191
+ "cancelled"
192
+ ]);
193
+ const taskStatusSchema = zod.z.enum([
194
+ "pending",
195
+ "running",
196
+ "passed",
197
+ "changed",
198
+ "new",
199
+ "failed",
200
+ "skipped"
201
+ ]);
202
+ const targetSchema = zod.z.object({
203
+ id: zod.z.string(),
204
+ url: zod.z.string(),
205
+ plugin: zod.z.string()
206
+ });
207
+ const pluginInfoSchema = zod.z.object({
208
+ name: zod.z.string(),
209
+ description: zod.z.string().optional()
210
+ });
211
+ /**
212
+ * Why a run started, when a person did not start it.
213
+ *
214
+ * Carried on the request rather than as a separate lookup, so a run list can
215
+ * say "this one came from saving Button.stories.tsx" from what it already has.
216
+ */
217
+ const runTriggerSchema = zod.z.object({
218
+ source: zod.z.literal("watch"),
219
+ files: zod.z.array(zod.z.string())
220
+ });
221
+ const startRunRequestSchema = zod.z.object({
222
+ plugins: zod.z.array(zod.z.string()).optional(),
223
+ filter: zod.z.string().optional(),
224
+ taskIds: zod.z.array(zod.z.string()).optional(),
225
+ clearActual: zod.z.boolean().optional(),
226
+ trigger: runTriggerSchema.optional()
227
+ });
228
+ const serializedErrorSchema = zod.z.object({
229
+ name: zod.z.string(),
230
+ message: zod.z.string(),
231
+ stack: zod.z.string().optional()
232
+ });
233
+ /**
234
+ * A plugin's `execute` return value.
235
+ *
236
+ * Only the keys the runner interprets are named; plugins are free to return
237
+ * more, so unknown keys pass through.
238
+ */
239
+ const pluginCaptureResultSchema = zod.z.looseObject({
240
+ success: zod.z.boolean().optional(),
241
+ skipped: zod.z.boolean().optional(),
242
+ isNew: zod.z.boolean().optional(),
243
+ error: zod.z.unknown().optional(),
244
+ filepath: zod.z.string().optional(),
245
+ storyId: zod.z.string().optional(),
246
+ storyName: zod.z.string().optional()
247
+ });
248
+ const taskFailureSchema = zod.z.object({
249
+ taskId: zod.z.string(),
250
+ taskUrl: zod.z.string(),
251
+ pluginName: zod.z.string(),
252
+ result: pluginCaptureResultSchema
253
+ });
254
+ const taskRecordSchema = zod.z.object({
255
+ id: zod.z.string(),
256
+ url: zod.z.string(),
257
+ plugin: zod.z.string(),
258
+ status: taskStatusSchema,
259
+ durationMs: zod.z.number().optional(),
260
+ result: pluginCaptureResultSchema.optional()
261
+ });
262
+ const runSummarySchema = zod.z.object({
263
+ id: zod.z.string(),
264
+ state: runStateSchema,
265
+ request: startRunRequestSchema,
266
+ startedAt: zod.z.number(),
267
+ finishedAt: zod.z.number().optional(),
268
+ durationMs: zod.z.number().optional(),
269
+ totalTasks: zod.z.number(),
270
+ completedTasks: zod.z.number(),
271
+ failedTasks: zod.z.number(),
272
+ deletedScreenshots: zod.z.array(zod.z.string()),
273
+ anyTasksRan: zod.z.boolean(),
274
+ error: serializedErrorSchema.optional()
275
+ });
276
+ const runDetailSchema = runSummarySchema.extend({
277
+ tasks: zod.z.array(taskRecordSchema),
278
+ failures: zod.z.array(taskFailureSchema)
279
+ });
280
+ const runLogLevelSchema = zod.z.enum([
281
+ "debug",
282
+ "info",
283
+ "warn",
284
+ "error",
285
+ "success"
286
+ ]);
287
+ const eventBase = {
288
+ seq: zod.z.number(),
289
+ runId: zod.z.string(),
290
+ at: zod.z.number()
291
+ };
292
+ /**
293
+ * The run event stream, exactly as `@cappa/core`'s `CaptureRunner` emits it.
294
+ *
295
+ * `seq` is monotonic and 1-based per run; the SSE endpoint uses it as the
296
+ * `Last-Event-ID` so a reconnecting client can replay what it missed.
297
+ */
298
+ const runEventSchema = zod.z.discriminatedUnion("type", [
299
+ zod.z.object({
300
+ ...eventBase,
301
+ type: zod.z.literal("run:start"),
302
+ request: startRunRequestSchema
303
+ }),
304
+ zod.z.object({
305
+ ...eventBase,
306
+ type: zod.z.literal("discover:start"),
307
+ plugins: zod.z.array(zod.z.string())
308
+ }),
309
+ zod.z.object({
310
+ ...eventBase,
311
+ type: zod.z.literal("discover:plugin"),
312
+ plugin: zod.z.string(),
313
+ taskCount: zod.z.number()
314
+ }),
315
+ zod.z.object({
316
+ ...eventBase,
317
+ type: zod.z.literal("discover:complete"),
318
+ targets: zod.z.array(targetSchema),
319
+ totalTasks: zod.z.number()
320
+ }),
321
+ zod.z.object({
322
+ ...eventBase,
323
+ type: zod.z.literal("filter:applied"),
324
+ filter: zod.z.string().optional(),
325
+ taskIds: zod.z.array(zod.z.string()).optional(),
326
+ plugins: zod.z.array(zod.z.object({
327
+ plugin: zod.z.string(),
328
+ before: zod.z.number(),
329
+ after: zod.z.number()
330
+ }))
331
+ }),
332
+ zod.z.object({
333
+ ...eventBase,
334
+ type: zod.z.literal("plugin:start"),
335
+ plugin: zod.z.string(),
336
+ taskCount: zod.z.number()
337
+ }),
338
+ zod.z.object({
339
+ ...eventBase,
340
+ type: zod.z.literal("task:start"),
341
+ plugin: zod.z.string(),
342
+ taskId: zod.z.string(),
343
+ url: zod.z.string()
344
+ }),
345
+ zod.z.object({
346
+ ...eventBase,
347
+ type: zod.z.literal("task:complete"),
348
+ plugin: zod.z.string(),
349
+ taskId: zod.z.string(),
350
+ url: zod.z.string(),
351
+ status: taskStatusSchema,
352
+ completed: zod.z.number(),
353
+ total: zod.z.number(),
354
+ durationMs: zod.z.number(),
355
+ result: pluginCaptureResultSchema.optional()
356
+ }),
357
+ zod.z.object({
358
+ ...eventBase,
359
+ type: zod.z.literal("plugin:complete"),
360
+ plugin: zod.z.string(),
361
+ resultCount: zod.z.number(),
362
+ failed: zod.z.boolean()
363
+ }),
364
+ zod.z.object({
365
+ ...eventBase,
366
+ type: zod.z.literal("log"),
367
+ level: runLogLevelSchema,
368
+ message: zod.z.string(),
369
+ args: zod.z.array(zod.z.unknown())
370
+ }),
371
+ zod.z.object({
372
+ ...eventBase,
373
+ type: zod.z.literal("run:complete"),
374
+ summary: runSummarySchema
375
+ }),
376
+ zod.z.object({
377
+ ...eventBase,
378
+ type: zod.z.literal("run:error"),
379
+ error: serializedErrorSchema
380
+ }),
381
+ zod.z.object({
382
+ ...eventBase,
383
+ type: zod.z.literal("run:cancelled")
384
+ })
385
+ ]);
386
+ /**
387
+ * How a watch iteration decided what to capture.
388
+ *
389
+ * `tasks` is the precise case; `plugins` means at least one plugin could not
390
+ * attribute the change; `all` means the resolved set was too large or discovery
391
+ * failed; `none` means there was nothing to capture.
392
+ */
393
+ const watchScopeSchema = zod.z.enum([
394
+ "tasks",
395
+ "plugins",
396
+ "all",
397
+ "none"
398
+ ]);
399
+ const watchChangeSchema = zod.z.object({
400
+ files: zod.z.array(zod.z.string()),
401
+ scope: watchScopeSchema,
402
+ taskIds: zod.z.array(zod.z.string()).optional(),
403
+ runId: zod.z.string().optional(),
404
+ error: zod.z.string().optional(),
405
+ at: zod.z.number()
406
+ });
407
+ const watchEventBase = {
408
+ /** Monotonic, 1-based, per server. Used for SSE `Last-Event-ID` replay. */
409
+ seq: zod.z.number(),
410
+ at: zod.z.number()
411
+ };
412
+ /**
413
+ * The watch event stream, exactly as `@cappa/core`'s engine emits it.
414
+ *
415
+ * Separate from `runEventSchema` because a watch session outlives any single
416
+ * run: the runs it starts report themselves on the ordinary run stream, and
417
+ * these events say why they started.
418
+ */
419
+ const watchEventSchema = zod.z.discriminatedUnion("type", [
420
+ zod.z.object({
421
+ ...watchEventBase,
422
+ type: zod.z.literal("watch:start"),
423
+ paths: zod.z.array(zod.z.string()),
424
+ filter: zod.z.string().optional(),
425
+ debounceMs: zod.z.number()
426
+ }),
427
+ zod.z.object({
428
+ ...watchEventBase,
429
+ type: zod.z.literal("watch:change"),
430
+ files: zod.z.array(zod.z.string()),
431
+ scope: watchScopeSchema,
432
+ taskIds: zod.z.array(zod.z.string()).optional(),
433
+ runId: zod.z.string().optional(),
434
+ error: zod.z.string().optional()
435
+ }),
436
+ zod.z.object({
437
+ ...watchEventBase,
438
+ type: zod.z.literal("watch:stop"),
439
+ reason: zod.z.enum(["requested", "engine-closed"])
440
+ })
441
+ ]);
442
+ const watchStatusSchema = zod.z.object({
443
+ active: zod.z.boolean(),
444
+ paths: zod.z.array(zod.z.string()),
445
+ filter: zod.z.string().optional(),
446
+ debounceMs: zod.z.number(),
447
+ startedAt: zod.z.number().optional(),
448
+ lastChange: watchChangeSchema.optional()
449
+ });
450
+ const startWatchRequestSchema = zod.z.object({
451
+ paths: zod.z.array(zod.z.string()).optional(),
452
+ filter: zod.z.string().optional(),
453
+ debounceMs: zod.z.number().optional(),
454
+ maxTasks: zod.z.number().optional()
455
+ });
456
+ //#endregion
457
+ exports.ASSET_PREFIX = ASSET_PREFIX;
458
+ exports.ERROR_CODES = ERROR_CODES;
459
+ exports.PROTOCOL_VERSION = PROTOCOL_VERSION;
460
+ exports.TOKEN_HEADER = TOKEN_HEADER;
461
+ exports.approveRequestSchema = approveRequestSchema;
462
+ exports.approveResultSchema = approveResultSchema;
463
+ exports.capabilitiesSchema = capabilitiesSchema;
464
+ exports.changedScreenshotSchema = changedScreenshotSchema;
465
+ exports.configResponseSchema = configResponseSchema;
466
+ exports.deletedScreenshotSchema = deletedScreenshotSchema;
467
+ exports.diffMetadataSchema = diffMetadataSchema;
468
+ exports.errorResponseSchema = errorResponseSchema;
469
+ exports.healthResponseSchema = healthResponseSchema;
470
+ exports.newScreenshotSchema = newScreenshotSchema;
471
+ exports.passedScreenshotSchema = passedScreenshotSchema;
472
+ exports.pluginCaptureResultSchema = pluginCaptureResultSchema;
473
+ exports.pluginInfoSchema = pluginInfoSchema;
474
+ exports.routes = routes;
475
+ exports.runDetailSchema = runDetailSchema;
476
+ exports.runEventSchema = runEventSchema;
477
+ exports.runLogLevelSchema = runLogLevelSchema;
478
+ exports.runStateSchema = runStateSchema;
479
+ exports.runSummarySchema = runSummarySchema;
480
+ exports.runTriggerSchema = runTriggerSchema;
481
+ exports.screenshotCategorySchema = screenshotCategorySchema;
482
+ exports.screenshotQuerySchema = screenshotQuerySchema;
483
+ exports.screenshotSchema = screenshotSchema;
484
+ exports.serializedErrorSchema = serializedErrorSchema;
485
+ exports.startRunRequestSchema = startRunRequestSchema;
486
+ exports.startRunResponseSchema = startRunResponseSchema;
487
+ exports.startWatchRequestSchema = startWatchRequestSchema;
488
+ exports.targetSchema = targetSchema;
489
+ exports.targetsQuerySchema = targetsQuerySchema;
490
+ exports.taskFailureSchema = taskFailureSchema;
491
+ exports.taskRecordSchema = taskRecordSchema;
492
+ exports.taskStatusSchema = taskStatusSchema;
493
+ exports.watchChangeSchema = watchChangeSchema;
494
+ exports.watchEventSchema = watchEventSchema;
495
+ exports.watchScopeSchema = watchScopeSchema;
496
+ exports.watchStatusSchema = watchStatusSchema;
497
+
498
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.cjs","names":["z","z","z"],"sources":["../src/screenshot.ts","../src/routes.ts","../src/run.ts"],"sourcesContent":["import { z } from \"zod\";\n\n/**\n * Screenshot shapes as they cross the wire.\n *\n * These mirror the types in `@cappa/core`, but are declared independently on\n * purpose: this package must stay installable by a browser client that has no\n * business pulling in `playwright-core` or native diff bindings. A type-level\n * compatibility assertion in `screenshot.test.ts` fails the build if the two\n * definitions drift apart.\n */\n\nexport const screenshotCategorySchema = z.enum([\n \"new\",\n \"deleted\",\n \"changed\",\n \"passed\",\n]);\n\nexport type ScreenshotCategory = z.infer<typeof screenshotCategorySchema>;\n\nexport const diffMetadataSchema = z.object({\n numDiffPixels: z.number(),\n percentDifference: z.number(),\n /**\n * Structured diff interpretation, carried opaquely.\n *\n * Its shape is owned by the diff engine (`@blazediff/core-native`'s\n * `InterpretResult`) and changes with that dependency. Pinning it here would\n * make every diff-engine upgrade a breaking protocol change for no benefit,\n * so the protocol passes it through untouched and consumers that want to\n * render the detail narrow it with `InterpretResult` from `@cappa/core`.\n */\n interpretation: z.unknown().optional(),\n});\n\nexport type DiffMetadata = z.infer<typeof diffMetadataSchema>;\n\nconst screenshotBase = {\n id: z.string(),\n name: z.string(),\n approved: z.boolean().optional(),\n /**\n * The capture task that produced this screenshot.\n *\n * Described here because it is the only way a client can re-capture one\n * screenshot: `startRun` accepts task ids, and a screenshot's `name` is not\n * one — Storybook writes `example/button/primary` for the task\n * `example-button--primary`. Optional because the engine can only know it for\n * screenshots captured since the capture manifest existed, so a client must\n * treat its absence as \"not re-capturable\" rather than substituting `name`.\n */\n taskId: z.string().optional(),\n /** Plugin that owns `taskId`. Absent whenever `taskId` is. */\n plugin: z.string().optional(),\n /**\n * Neighbours in the full, unfiltered list, so the UI can walk every\n * screenshot with the arrow keys regardless of the current filter.\n *\n * Computed by the server rather than the engine — but they must be described\n * here, or a client parsing a response would silently drop them.\n */\n next: z.string().optional(),\n prev: z.string().optional(),\n};\n\nexport const newScreenshotSchema = z.object({\n ...screenshotBase,\n category: z.literal(\"new\"),\n actualPath: z.string(),\n});\n\nexport const deletedScreenshotSchema = z.object({\n ...screenshotBase,\n category: z.literal(\"deleted\"),\n expectedPath: z.string(),\n});\n\nexport const changedScreenshotSchema = z.object({\n ...screenshotBase,\n category: z.literal(\"changed\"),\n actualPath: z.string(),\n expectedPath: z.string(),\n diffPath: z.string(),\n diffMeta: diffMetadataSchema.optional(),\n});\n\nexport const passedScreenshotSchema = z.object({\n ...screenshotBase,\n category: z.literal(\"passed\"),\n actualPath: z.string(),\n expectedPath: z.string(),\n});\n\n/**\n * The changed variant on its own.\n *\n * Exported because the review UI's comparison views only ever render a changed\n * screenshot, and typing them on the full union would force a narrow at every\n * call site.\n */\nexport type ChangedScreenshot = z.infer<typeof changedScreenshotSchema>;\n\nexport const screenshotSchema = z.discriminatedUnion(\"category\", [\n newScreenshotSchema,\n deletedScreenshotSchema,\n changedScreenshotSchema,\n passedScreenshotSchema,\n]);\n\nexport type Screenshot = z.infer<typeof screenshotSchema>;\n\nexport const screenshotQuerySchema = z.object({\n search: z.string().optional(),\n category: screenshotCategorySchema.optional(),\n});\n\nexport type ScreenshotQuery = z.infer<typeof screenshotQuerySchema>;\n\nexport const approveRequestSchema = z.object({\n names: z.array(z.string()).min(1, \"names must be a non-empty array\"),\n});\n\nexport type ApproveRequest = z.infer<typeof approveRequestSchema>;\n\nexport const approveResultSchema = z.object({\n approved: z.array(z.string()),\n errors: z.array(z.object({ name: z.string(), error: z.string() })),\n});\n\nexport type ApproveResult = z.infer<typeof approveResultSchema>;\n","import { z } from \"zod\";\nimport { screenshotCategorySchema } from \"./screenshot\";\n\n/**\n * Bumped whenever the wire contract changes incompatibly.\n *\n * Served on `GET /api/health` and checked by `@cappa/client` on its first call,\n * so a client built against an older server fails with a clear message instead\n * of mis-parsing responses.\n */\nexport const PROTOCOL_VERSION = 1;\n\n/** Capabilities a server advertises, so a client can hide what is unavailable. */\nexport const capabilitiesSchema = z.object({\n /** Capture routes are mounted (false when the server is read-only). */\n capture: z.boolean(),\n /** Screenshots can be approved. */\n approve: z.boolean(),\n /** The run event stream is available. */\n events: z.boolean(),\n /**\n * The server can watch its own filesystem and re-capture on change.\n *\n * Optional so a client built against this version still parses an older\n * server's health response, which has no such field. Absent means no.\n */\n watch: z.boolean().optional(),\n});\n\nexport type Capabilities = z.infer<typeof capabilitiesSchema>;\n\nexport const healthResponseSchema = z.object({\n ok: z.boolean(),\n protocolVersion: z.number(),\n capabilities: capabilitiesSchema,\n});\n\nexport type HealthResponse = z.infer<typeof healthResponseSchema>;\n\nexport const configResponseSchema = z.object({\n theme: z.enum([\"light\", \"dark\"]),\n readOnly: z.boolean(),\n});\n\nexport type ConfigResponse = z.infer<typeof configResponseSchema>;\n\nexport const startRunResponseSchema = z.object({\n runId: z.string(),\n});\n\nexport type StartRunResponse = z.infer<typeof startRunResponseSchema>;\n\n/**\n * Machine-readable codes on error responses.\n *\n * Kept here, in the wire contract, rather than derived from `@cappa/core`'s\n * error classes: a client must be able to tell a conflict from a validation\n * failure without installing the engine. `@cappa/core` mirrors these values and\n * a compatibility assertion there fails the build if they drift.\n */\nexport const ERROR_CODES = {\n runInProgress: \"CAPPA_RUN_IN_PROGRESS\",\n unknownTargets: \"CAPPA_UNKNOWN_TARGETS\",\n watchInProgress: \"CAPPA_WATCH_IN_PROGRESS\",\n} as const;\n\nexport type ErrorCode = (typeof ERROR_CODES)[keyof typeof ERROR_CODES];\n\nexport const errorResponseSchema = z.object({\n error: z.unknown(),\n code: z.string().optional(),\n activeRunId: z.string().optional(),\n taskIds: z.array(z.string()).optional(),\n});\n\nexport type ErrorResponse = z.infer<typeof errorResponseSchema>;\n\n/** Every route the server exposes, in one place. */\nexport const routes = {\n health: \"/api/health\",\n config: \"/api/config\",\n plugins: \"/api/plugins\",\n targets: \"/api/targets\",\n runs: \"/api/runs\",\n run: (id: string) => `/api/runs/${encodeURIComponent(id)}`,\n runCancel: (id: string) => `/api/runs/${encodeURIComponent(id)}/cancel`,\n runEvents: (id: string) => `/api/runs/${encodeURIComponent(id)}/events`,\n screenshots: \"/api/screenshots\",\n screenshot: (id: string) => `/api/screenshots/${encodeURIComponent(id)}`,\n approveBatch: \"/api/screenshots/approve-batch\",\n watch: \"/api/watch\",\n watchEvents: \"/api/watch/events\",\n} as const;\n\n/** Prefix under which screenshot images are served. */\nexport const ASSET_PREFIX = \"/assets/screenshots\";\n\n/** Header carrying the access token when the server is not on loopback. */\nexport const TOKEN_HEADER = \"x-cappa-token\";\n\nexport const targetsQuerySchema = z.object({\n refresh: z\n .union([\n z.literal(\"1\"),\n z.literal(\"true\"),\n z.literal(\"0\"),\n z.literal(\"false\"),\n ])\n .optional(),\n});\n\nexport { screenshotCategorySchema };\n","import { z } from \"zod\";\n\nexport const runStateSchema = z.enum([\n \"idle\",\n \"discovering\",\n \"running\",\n \"completed\",\n \"failed\",\n \"cancelled\",\n]);\n\nexport type RunState = z.infer<typeof runStateSchema>;\n\nexport const taskStatusSchema = z.enum([\n \"pending\",\n \"running\",\n \"passed\",\n \"changed\",\n \"new\",\n \"failed\",\n \"skipped\",\n]);\n\nexport type TaskStatus = z.infer<typeof taskStatusSchema>;\n\nexport const targetSchema = z.object({\n id: z.string(),\n url: z.string(),\n plugin: z.string(),\n});\n\nexport type Target = z.infer<typeof targetSchema>;\n\nexport const pluginInfoSchema = z.object({\n name: z.string(),\n description: z.string().optional(),\n});\n\nexport type PluginInfo = z.infer<typeof pluginInfoSchema>;\n\n/**\n * Why a run started, when a person did not start it.\n *\n * Carried on the request rather than as a separate lookup, so a run list can\n * say \"this one came from saving Button.stories.tsx\" from what it already has.\n */\nexport const runTriggerSchema = z.object({\n source: z.literal(\"watch\"),\n files: z.array(z.string()),\n});\n\nexport type RunTrigger = z.infer<typeof runTriggerSchema>;\n\nexport const startRunRequestSchema = z.object({\n plugins: z.array(z.string()).optional(),\n filter: z.string().optional(),\n taskIds: z.array(z.string()).optional(),\n clearActual: z.boolean().optional(),\n trigger: runTriggerSchema.optional(),\n});\n\nexport type StartRunRequest = z.infer<typeof startRunRequestSchema>;\n\nexport const serializedErrorSchema = z.object({\n name: z.string(),\n message: z.string(),\n stack: z.string().optional(),\n});\n\nexport type SerializedError = z.infer<typeof serializedErrorSchema>;\n\n/**\n * A plugin's `execute` return value.\n *\n * Only the keys the runner interprets are named; plugins are free to return\n * more, so unknown keys pass through.\n */\nexport const pluginCaptureResultSchema = z.looseObject({\n success: z.boolean().optional(),\n skipped: z.boolean().optional(),\n isNew: z.boolean().optional(),\n error: z.unknown().optional(),\n filepath: z.string().optional(),\n storyId: z.string().optional(),\n storyName: z.string().optional(),\n});\n\nexport type PluginCaptureResult = z.infer<typeof pluginCaptureResultSchema>;\n\nexport const taskFailureSchema = z.object({\n taskId: z.string(),\n taskUrl: z.string(),\n pluginName: z.string(),\n result: pluginCaptureResultSchema,\n});\n\nexport type TaskFailure = z.infer<typeof taskFailureSchema>;\n\nexport const taskRecordSchema = z.object({\n id: z.string(),\n url: z.string(),\n plugin: z.string(),\n status: taskStatusSchema,\n durationMs: z.number().optional(),\n result: pluginCaptureResultSchema.optional(),\n});\n\nexport type TaskRecord = z.infer<typeof taskRecordSchema>;\n\nexport const runSummarySchema = z.object({\n id: z.string(),\n state: runStateSchema,\n request: startRunRequestSchema,\n startedAt: z.number(),\n finishedAt: z.number().optional(),\n durationMs: z.number().optional(),\n totalTasks: z.number(),\n completedTasks: z.number(),\n failedTasks: z.number(),\n deletedScreenshots: z.array(z.string()),\n anyTasksRan: z.boolean(),\n error: serializedErrorSchema.optional(),\n});\n\nexport type RunSummary = z.infer<typeof runSummarySchema>;\n\nexport const runDetailSchema = runSummarySchema.extend({\n tasks: z.array(taskRecordSchema),\n failures: z.array(taskFailureSchema),\n});\n\nexport type RunDetail = z.infer<typeof runDetailSchema>;\n\nexport const runLogLevelSchema = z.enum([\n \"debug\",\n \"info\",\n \"warn\",\n \"error\",\n \"success\",\n]);\n\nexport type RunLogLevel = z.infer<typeof runLogLevelSchema>;\n\nconst eventBase = {\n seq: z.number(),\n runId: z.string(),\n at: z.number(),\n};\n\n/**\n * The run event stream, exactly as `@cappa/core`'s `CaptureRunner` emits it.\n *\n * `seq` is monotonic and 1-based per run; the SSE endpoint uses it as the\n * `Last-Event-ID` so a reconnecting client can replay what it missed.\n */\nexport const runEventSchema = z.discriminatedUnion(\"type\", [\n z.object({\n ...eventBase,\n type: z.literal(\"run:start\"),\n request: startRunRequestSchema,\n }),\n z.object({\n ...eventBase,\n type: z.literal(\"discover:start\"),\n plugins: z.array(z.string()),\n }),\n z.object({\n ...eventBase,\n type: z.literal(\"discover:plugin\"),\n plugin: z.string(),\n taskCount: z.number(),\n }),\n z.object({\n ...eventBase,\n type: z.literal(\"discover:complete\"),\n targets: z.array(targetSchema),\n totalTasks: z.number(),\n }),\n z.object({\n ...eventBase,\n type: z.literal(\"filter:applied\"),\n filter: z.string().optional(),\n taskIds: z.array(z.string()).optional(),\n plugins: z.array(\n z.object({\n plugin: z.string(),\n before: z.number(),\n after: z.number(),\n }),\n ),\n }),\n z.object({\n ...eventBase,\n type: z.literal(\"plugin:start\"),\n plugin: z.string(),\n taskCount: z.number(),\n }),\n z.object({\n ...eventBase,\n type: z.literal(\"task:start\"),\n plugin: z.string(),\n taskId: z.string(),\n url: z.string(),\n }),\n z.object({\n ...eventBase,\n type: z.literal(\"task:complete\"),\n plugin: z.string(),\n taskId: z.string(),\n url: z.string(),\n status: taskStatusSchema,\n completed: z.number(),\n total: z.number(),\n durationMs: z.number(),\n result: pluginCaptureResultSchema.optional(),\n }),\n z.object({\n ...eventBase,\n type: z.literal(\"plugin:complete\"),\n plugin: z.string(),\n resultCount: z.number(),\n failed: z.boolean(),\n }),\n z.object({\n ...eventBase,\n type: z.literal(\"log\"),\n level: runLogLevelSchema,\n message: z.string(),\n args: z.array(z.unknown()),\n }),\n z.object({\n ...eventBase,\n type: z.literal(\"run:complete\"),\n summary: runSummarySchema,\n }),\n z.object({\n ...eventBase,\n type: z.literal(\"run:error\"),\n error: serializedErrorSchema,\n }),\n z.object({ ...eventBase, type: z.literal(\"run:cancelled\") }),\n]);\n\nexport type RunEvent = z.infer<typeof runEventSchema>;\n\nexport type RunEventType = RunEvent[\"type\"];\n\n/**\n * How a watch iteration decided what to capture.\n *\n * `tasks` is the precise case; `plugins` means at least one plugin could not\n * attribute the change; `all` means the resolved set was too large or discovery\n * failed; `none` means there was nothing to capture.\n */\nexport const watchScopeSchema = z.enum([\"tasks\", \"plugins\", \"all\", \"none\"]);\n\nexport type WatchScope = z.infer<typeof watchScopeSchema>;\n\nexport const watchChangeSchema = z.object({\n files: z.array(z.string()),\n scope: watchScopeSchema,\n taskIds: z.array(z.string()).optional(),\n runId: z.string().optional(),\n error: z.string().optional(),\n at: z.number(),\n});\n\nexport type WatchChange = z.infer<typeof watchChangeSchema>;\n\nconst watchEventBase = {\n /** Monotonic, 1-based, per server. Used for SSE `Last-Event-ID` replay. */\n seq: z.number(),\n at: z.number(),\n};\n\n/**\n * The watch event stream, exactly as `@cappa/core`'s engine emits it.\n *\n * Separate from `runEventSchema` because a watch session outlives any single\n * run: the runs it starts report themselves on the ordinary run stream, and\n * these events say why they started.\n */\nexport const watchEventSchema = z.discriminatedUnion(\"type\", [\n z.object({\n ...watchEventBase,\n type: z.literal(\"watch:start\"),\n paths: z.array(z.string()),\n filter: z.string().optional(),\n debounceMs: z.number(),\n }),\n z.object({\n ...watchEventBase,\n type: z.literal(\"watch:change\"),\n files: z.array(z.string()),\n scope: watchScopeSchema,\n taskIds: z.array(z.string()).optional(),\n runId: z.string().optional(),\n error: z.string().optional(),\n }),\n z.object({\n ...watchEventBase,\n type: z.literal(\"watch:stop\"),\n reason: z.enum([\"requested\", \"engine-closed\"]),\n }),\n]);\n\nexport type WatchEvent = z.infer<typeof watchEventSchema>;\n\nexport type WatchEventType = WatchEvent[\"type\"];\n\nexport const watchStatusSchema = z.object({\n active: z.boolean(),\n paths: z.array(z.string()),\n filter: z.string().optional(),\n debounceMs: z.number(),\n startedAt: z.number().optional(),\n lastChange: watchChangeSchema.optional(),\n});\n\nexport type WatchStatus = z.infer<typeof watchStatusSchema>;\n\nexport const startWatchRequestSchema = z.object({\n paths: z.array(z.string()).optional(),\n filter: z.string().optional(),\n debounceMs: z.number().optional(),\n maxTasks: z.number().optional(),\n});\n\nexport type StartWatchRequest = z.infer<typeof startWatchRequestSchema>;\n"],"mappings":";;;;;;;;;;;;AAYA,MAAa,2BAA2BA,IAAAA,EAAE,KAAK;CAC7C;CACA;CACA;CACA;AACF,CAAC;AAID,MAAa,qBAAqBA,IAAAA,EAAE,OAAO;CACzC,eAAeA,IAAAA,EAAE,OAAO;CACxB,mBAAmBA,IAAAA,EAAE,OAAO;;;;;;;;;;CAU5B,gBAAgBA,IAAAA,EAAE,QAAQ,CAAC,CAAC,SAAS;AACvC,CAAC;AAID,MAAM,iBAAiB;CACrB,IAAIA,IAAAA,EAAE,OAAO;CACb,MAAMA,IAAAA,EAAE,OAAO;CACf,UAAUA,IAAAA,EAAE,QAAQ,CAAC,CAAC,SAAS;;;;;;;;;;;CAW/B,QAAQA,IAAAA,EAAE,OAAO,CAAC,CAAC,SAAS;;CAE5B,QAAQA,IAAAA,EAAE,OAAO,CAAC,CAAC,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