@cappa/protocol 0.10.0 → 0.11.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/dist/index.cjs CHANGED
@@ -31,7 +31,7 @@ const diffMetadataSchema = zod.z.object({
31
31
  interpretation: zod.z.unknown().optional()
32
32
  });
33
33
  /**
34
- * The verdict `cappa agent check` reached for a changed screenshot.
34
+ * A judge's verdict on a changed screenshot, as `cappa agent check` applied it.
35
35
  *
36
36
  * Unlike the interpretation this is cappa's own shape, so it is described
37
37
  * rather than carried opaquely. `label` and `action` stay plain strings on the
@@ -66,6 +66,13 @@ const screenshotBase = {
66
66
  /** Plugin that owns `taskId`. Absent whenever `taskId` is. */
67
67
  plugin: zod.z.string().optional(),
68
68
  /**
69
+ * Image pixels per CSS pixel of the actual / expected PNG. Absent means 1.
70
+ * A client shows an image at its size divided by this, and two different
71
+ * ratios on one screenshot mean the baseline predates a scale change.
72
+ */
73
+ actualPixelRatio: zod.z.number().positive().optional(),
74
+ expectedPixelRatio: zod.z.number().positive().optional(),
75
+ /**
69
76
  * Neighbours in the full, unfiltered list, so the UI can walk every
70
77
  * screenshot with the arrow keys regardless of the current filter.
71
78
  *
@@ -1 +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\n/**\n * The verdict `cappa agent check` reached for a changed screenshot.\n *\n * Unlike the interpretation this is cappa's own shape, so it is described\n * rather than carried opaquely. `label` and `action` stay plain strings on the\n * wire so a newer engine adding a label does not make an older client reject\n * the whole screenshot list.\n */\nexport const agentReviewSchema = z.object({\n label: z.string(),\n headline: z.string(),\n rationale: z.array(z.string()),\n action: z.string(),\n source: z.enum([\"heuristic\", \"agent\"]),\n confidence: z.number().optional(),\n pending: z.boolean(),\n reviewedAt: z.string(),\n});\n\nexport type AgentReview = z.infer<typeof agentReviewSchema>;\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 review: agentReviewSchema.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;;;;;;;;;AAYD,MAAa,oBAAoBA,IAAAA,EAAE,OAAO;CACxC,OAAOA,IAAAA,EAAE,OAAO;CAChB,UAAUA,IAAAA,EAAE,OAAO;CACnB,WAAWA,IAAAA,EAAE,MAAMA,IAAAA,EAAE,OAAO,CAAC;CAC7B,QAAQA,IAAAA,EAAE,OAAO;CACjB,QAAQA,IAAAA,EAAE,KAAK,CAAC,aAAa,OAAO,CAAC;CACrC,YAAYA,IAAAA,EAAE,OAAO,CAAC,CAAC,SAAS;CAChC,SAASA,IAAAA,EAAE,QAAQ;CACnB,YAAYA,IAAAA,EAAE,OAAO;AACvB,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,SAAS;;;;;;;;CAQ5B,MAAMA,IAAAA,EAAE,OAAO,CAAC,CAAC,SAAS;CAC1B,MAAMA,IAAAA,EAAE,OAAO,CAAC,CAAC,SAAS;AAC5B;AAEA,MAAa,sBAAsBA,IAAAA,EAAE,OAAO;CAC1C,GAAG;CACH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;CACvB,CAAC;CACDA,IAAAA,EAAE,OAAO;EACP,GAAG;EACH,MAAMA,IAAAA,EAAE,QAAQ,cAAc;EAC9B,OAAOA,IAAAA,EAAE,MAAMA,IAAAA,EAAE,OAAO,CAAC;EACzB,OAAO;EACP,SAASA,IAAAA,EAAE,MAAMA,IAAAA,EAAE,OAAO,CAAC,CAAC,CAAC,SAAS;EACtC,OAAOA,IAAAA,EAAE,OAAO,CAAC,CAAC,SAAS;EAC3B,OAAOA,IAAAA,EAAE,OAAO,CAAC,CAAC,SAAS;CAC7B,CAAC;CACDA,IAAAA,EAAE,OAAO;EACP,GAAG;EACH,MAAMA,IAAAA,EAAE,QAAQ,YAAY;EAC5B,QAAQA,IAAAA,EAAE,KAAK,CAAC,aAAa,eAAe,CAAC;CAC/C,CAAC;AACH,CAAC;AAMD,MAAa,oBAAoBA,IAAAA,EAAE,OAAO;CACxC,QAAQA,IAAAA,EAAE,QAAQ;CAClB,OAAOA,IAAAA,EAAE,MAAMA,IAAAA,EAAE,OAAO,CAAC;CACzB,QAAQA,IAAAA,EAAE,OAAO,CAAC,CAAC,SAAS;CAC5B,YAAYA,IAAAA,EAAE,OAAO;CACrB,WAAWA,IAAAA,EAAE,OAAO,CAAC,CAAC,SAAS;CAC/B,YAAY,kBAAkB,SAAS;AACzC,CAAC;AAID,MAAa,0BAA0BA,IAAAA,EAAE,OAAO;CAC9C,OAAOA,IAAAA,EAAE,MAAMA,IAAAA,EAAE,OAAO,CAAC,CAAC,CAAC,SAAS;CACpC,QAAQA,IAAAA,EAAE,OAAO,CAAC,CAAC,SAAS;CAC5B,YAAYA,IAAAA,EAAE,OAAO,CAAC,CAAC,SAAS;CAChC,UAAUA,IAAAA,EAAE,OAAO,CAAC,CAAC,SAAS;AAChC,CAAC"}
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\n/**\n * A judge's verdict on a changed screenshot, as `cappa agent check` applied it.\n *\n * Unlike the interpretation this is cappa's own shape, so it is described\n * rather than carried opaquely. `label` and `action` stay plain strings on the\n * wire so a newer engine adding a label does not make an older client reject\n * the whole screenshot list.\n */\nexport const agentReviewSchema = z.object({\n label: z.string(),\n headline: z.string(),\n rationale: z.array(z.string()),\n action: z.string(),\n // Engines since 0.18 only send `agent`; older ones also sent `heuristic`\n // labels guessed from diff signals, so the wire format still accepts it.\n source: z.enum([\"heuristic\", \"agent\"]),\n confidence: z.number().optional(),\n pending: z.boolean(),\n reviewedAt: z.string(),\n});\n\nexport type AgentReview = z.infer<typeof agentReviewSchema>;\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 * Image pixels per CSS pixel of the actual / expected PNG. Absent means 1.\n * A client shows an image at its size divided by this, and two different\n * ratios on one screenshot mean the baseline predates a scale change.\n */\n actualPixelRatio: z.number().positive().optional(),\n expectedPixelRatio: z.number().positive().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 review: agentReviewSchema.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;;;;;;;;;AAYD,MAAa,oBAAoBA,IAAAA,EAAE,OAAO;CACxC,OAAOA,IAAAA,EAAE,OAAO;CAChB,UAAUA,IAAAA,EAAE,OAAO;CACnB,WAAWA,IAAAA,EAAE,MAAMA,IAAAA,EAAE,OAAO,CAAC;CAC7B,QAAQA,IAAAA,EAAE,OAAO;CAGjB,QAAQA,IAAAA,EAAE,KAAK,CAAC,aAAa,O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,oBAAoBA,IAAAA,EAAE,OAAO;CACxC,QAAQA,IAAAA,EAAE,QAAQ;CAClB,OAAOA,IAAAA,EAAE,MAAMA,IAAAA,EAAE,OAAO,CAAC;CACzB,QAAQA,IAAAA,EAAE,OAAO,CAAC,CAAC,SAAS;CAC5B,YAAYA,IAAAA,EAAE,OAAO;CACrB,WAAWA,IAAAA,EAAE,OAAO,CAAC,CAAC,SAAS;CAC/B,YAAY,kBAAkB,SAAS;AACzC,CAAC;AAID,MAAa,0BAA0BA,IAAAA,EAAE,OAAO;CAC9C,OAAOA,IAAAA,EAAE,MAAMA,IAAAA,EAAE,OAAO,CAAC,CAAC,CAAC,SAAS;CACpC,QAAQA,IAAAA,EAAE,OAAO,CAAC,CAAC,SAAS;CAC5B,YAAYA,IAAAA,EAAE,OAAO,CAAC,CAAC,SAAS;CAChC,UAAUA,IAAAA,EAAE,OAAO,CAAC,CAAC,SAAS;AAChC,CAAC"}
package/dist/index.d.cts CHANGED
@@ -23,7 +23,7 @@ export declare const diffMetadataSchema: z.ZodObject<{
23
23
  }, z.core.$strip>;
24
24
  type DiffMetadata = z.infer<typeof diffMetadataSchema>;
25
25
  /**
26
- * The verdict `cappa agent check` reached for a changed screenshot.
26
+ * A judge's verdict on a changed screenshot, as `cappa agent check` applied it.
27
27
  *
28
28
  * Unlike the interpretation this is cappa's own shape, so it is described
29
29
  * rather than carried opaquely. `label` and `action` stay plain strings on the
@@ -50,6 +50,8 @@ export declare const newScreenshotSchema: z.ZodObject<{
50
50
  approved: z.ZodOptional<z.ZodBoolean>;
51
51
  taskId: z.ZodOptional<z.ZodString>;
52
52
  plugin: z.ZodOptional<z.ZodString>;
53
+ actualPixelRatio: z.ZodOptional<z.ZodNumber>;
54
+ expectedPixelRatio: z.ZodOptional<z.ZodNumber>;
53
55
  next: z.ZodOptional<z.ZodString>;
54
56
  prev: z.ZodOptional<z.ZodString>;
55
57
  category: z.ZodLiteral<"new">;
@@ -61,6 +63,8 @@ export declare const deletedScreenshotSchema: z.ZodObject<{
61
63
  approved: z.ZodOptional<z.ZodBoolean>;
62
64
  taskId: z.ZodOptional<z.ZodString>;
63
65
  plugin: z.ZodOptional<z.ZodString>;
66
+ actualPixelRatio: z.ZodOptional<z.ZodNumber>;
67
+ expectedPixelRatio: z.ZodOptional<z.ZodNumber>;
64
68
  next: z.ZodOptional<z.ZodString>;
65
69
  prev: z.ZodOptional<z.ZodString>;
66
70
  category: z.ZodLiteral<"deleted">;
@@ -72,6 +76,8 @@ export declare const changedScreenshotSchema: z.ZodObject<{
72
76
  approved: z.ZodOptional<z.ZodBoolean>;
73
77
  taskId: z.ZodOptional<z.ZodString>;
74
78
  plugin: z.ZodOptional<z.ZodString>;
79
+ actualPixelRatio: z.ZodOptional<z.ZodNumber>;
80
+ expectedPixelRatio: z.ZodOptional<z.ZodNumber>;
75
81
  next: z.ZodOptional<z.ZodString>;
76
82
  prev: z.ZodOptional<z.ZodString>;
77
83
  category: z.ZodLiteral<"changed">;
@@ -103,6 +109,8 @@ export declare const passedScreenshotSchema: z.ZodObject<{
103
109
  approved: z.ZodOptional<z.ZodBoolean>;
104
110
  taskId: z.ZodOptional<z.ZodString>;
105
111
  plugin: z.ZodOptional<z.ZodString>;
112
+ actualPixelRatio: z.ZodOptional<z.ZodNumber>;
113
+ expectedPixelRatio: z.ZodOptional<z.ZodNumber>;
106
114
  next: z.ZodOptional<z.ZodString>;
107
115
  prev: z.ZodOptional<z.ZodString>;
108
116
  category: z.ZodLiteral<"passed">;
@@ -123,6 +131,8 @@ export declare const screenshotSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
123
131
  approved: z.ZodOptional<z.ZodBoolean>;
124
132
  taskId: z.ZodOptional<z.ZodString>;
125
133
  plugin: z.ZodOptional<z.ZodString>;
134
+ actualPixelRatio: z.ZodOptional<z.ZodNumber>;
135
+ expectedPixelRatio: z.ZodOptional<z.ZodNumber>;
126
136
  next: z.ZodOptional<z.ZodString>;
127
137
  prev: z.ZodOptional<z.ZodString>;
128
138
  category: z.ZodLiteral<"new">;
@@ -133,6 +143,8 @@ export declare const screenshotSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
133
143
  approved: z.ZodOptional<z.ZodBoolean>;
134
144
  taskId: z.ZodOptional<z.ZodString>;
135
145
  plugin: z.ZodOptional<z.ZodString>;
146
+ actualPixelRatio: z.ZodOptional<z.ZodNumber>;
147
+ expectedPixelRatio: z.ZodOptional<z.ZodNumber>;
136
148
  next: z.ZodOptional<z.ZodString>;
137
149
  prev: z.ZodOptional<z.ZodString>;
138
150
  category: z.ZodLiteral<"deleted">;
@@ -143,6 +155,8 @@ export declare const screenshotSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
143
155
  approved: z.ZodOptional<z.ZodBoolean>;
144
156
  taskId: z.ZodOptional<z.ZodString>;
145
157
  plugin: z.ZodOptional<z.ZodString>;
158
+ actualPixelRatio: z.ZodOptional<z.ZodNumber>;
159
+ expectedPixelRatio: z.ZodOptional<z.ZodNumber>;
146
160
  next: z.ZodOptional<z.ZodString>;
147
161
  prev: z.ZodOptional<z.ZodString>;
148
162
  category: z.ZodLiteral<"changed">;
@@ -173,6 +187,8 @@ export declare const screenshotSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
173
187
  approved: z.ZodOptional<z.ZodBoolean>;
174
188
  taskId: z.ZodOptional<z.ZodString>;
175
189
  plugin: z.ZodOptional<z.ZodString>;
190
+ actualPixelRatio: z.ZodOptional<z.ZodNumber>;
191
+ expectedPixelRatio: z.ZodOptional<z.ZodNumber>;
176
192
  next: z.ZodOptional<z.ZodString>;
177
193
  prev: z.ZodOptional<z.ZodString>;
178
194
  category: z.ZodLiteral<"passed">;
package/dist/index.d.ts CHANGED
@@ -23,7 +23,7 @@ export declare const diffMetadataSchema: z.ZodObject<{
23
23
  }, z.core.$strip>;
24
24
  type DiffMetadata = z.infer<typeof diffMetadataSchema>;
25
25
  /**
26
- * The verdict `cappa agent check` reached for a changed screenshot.
26
+ * A judge's verdict on a changed screenshot, as `cappa agent check` applied it.
27
27
  *
28
28
  * Unlike the interpretation this is cappa's own shape, so it is described
29
29
  * rather than carried opaquely. `label` and `action` stay plain strings on the
@@ -50,6 +50,8 @@ export declare const newScreenshotSchema: z.ZodObject<{
50
50
  approved: z.ZodOptional<z.ZodBoolean>;
51
51
  taskId: z.ZodOptional<z.ZodString>;
52
52
  plugin: z.ZodOptional<z.ZodString>;
53
+ actualPixelRatio: z.ZodOptional<z.ZodNumber>;
54
+ expectedPixelRatio: z.ZodOptional<z.ZodNumber>;
53
55
  next: z.ZodOptional<z.ZodString>;
54
56
  prev: z.ZodOptional<z.ZodString>;
55
57
  category: z.ZodLiteral<"new">;
@@ -61,6 +63,8 @@ export declare const deletedScreenshotSchema: z.ZodObject<{
61
63
  approved: z.ZodOptional<z.ZodBoolean>;
62
64
  taskId: z.ZodOptional<z.ZodString>;
63
65
  plugin: z.ZodOptional<z.ZodString>;
66
+ actualPixelRatio: z.ZodOptional<z.ZodNumber>;
67
+ expectedPixelRatio: z.ZodOptional<z.ZodNumber>;
64
68
  next: z.ZodOptional<z.ZodString>;
65
69
  prev: z.ZodOptional<z.ZodString>;
66
70
  category: z.ZodLiteral<"deleted">;
@@ -72,6 +76,8 @@ export declare const changedScreenshotSchema: z.ZodObject<{
72
76
  approved: z.ZodOptional<z.ZodBoolean>;
73
77
  taskId: z.ZodOptional<z.ZodString>;
74
78
  plugin: z.ZodOptional<z.ZodString>;
79
+ actualPixelRatio: z.ZodOptional<z.ZodNumber>;
80
+ expectedPixelRatio: z.ZodOptional<z.ZodNumber>;
75
81
  next: z.ZodOptional<z.ZodString>;
76
82
  prev: z.ZodOptional<z.ZodString>;
77
83
  category: z.ZodLiteral<"changed">;
@@ -103,6 +109,8 @@ export declare const passedScreenshotSchema: z.ZodObject<{
103
109
  approved: z.ZodOptional<z.ZodBoolean>;
104
110
  taskId: z.ZodOptional<z.ZodString>;
105
111
  plugin: z.ZodOptional<z.ZodString>;
112
+ actualPixelRatio: z.ZodOptional<z.ZodNumber>;
113
+ expectedPixelRatio: z.ZodOptional<z.ZodNumber>;
106
114
  next: z.ZodOptional<z.ZodString>;
107
115
  prev: z.ZodOptional<z.ZodString>;
108
116
  category: z.ZodLiteral<"passed">;
@@ -123,6 +131,8 @@ export declare const screenshotSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
123
131
  approved: z.ZodOptional<z.ZodBoolean>;
124
132
  taskId: z.ZodOptional<z.ZodString>;
125
133
  plugin: z.ZodOptional<z.ZodString>;
134
+ actualPixelRatio: z.ZodOptional<z.ZodNumber>;
135
+ expectedPixelRatio: z.ZodOptional<z.ZodNumber>;
126
136
  next: z.ZodOptional<z.ZodString>;
127
137
  prev: z.ZodOptional<z.ZodString>;
128
138
  category: z.ZodLiteral<"new">;
@@ -133,6 +143,8 @@ export declare const screenshotSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
133
143
  approved: z.ZodOptional<z.ZodBoolean>;
134
144
  taskId: z.ZodOptional<z.ZodString>;
135
145
  plugin: z.ZodOptional<z.ZodString>;
146
+ actualPixelRatio: z.ZodOptional<z.ZodNumber>;
147
+ expectedPixelRatio: z.ZodOptional<z.ZodNumber>;
136
148
  next: z.ZodOptional<z.ZodString>;
137
149
  prev: z.ZodOptional<z.ZodString>;
138
150
  category: z.ZodLiteral<"deleted">;
@@ -143,6 +155,8 @@ export declare const screenshotSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
143
155
  approved: z.ZodOptional<z.ZodBoolean>;
144
156
  taskId: z.ZodOptional<z.ZodString>;
145
157
  plugin: z.ZodOptional<z.ZodString>;
158
+ actualPixelRatio: z.ZodOptional<z.ZodNumber>;
159
+ expectedPixelRatio: z.ZodOptional<z.ZodNumber>;
146
160
  next: z.ZodOptional<z.ZodString>;
147
161
  prev: z.ZodOptional<z.ZodString>;
148
162
  category: z.ZodLiteral<"changed">;
@@ -173,6 +187,8 @@ export declare const screenshotSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
173
187
  approved: z.ZodOptional<z.ZodBoolean>;
174
188
  taskId: z.ZodOptional<z.ZodString>;
175
189
  plugin: z.ZodOptional<z.ZodString>;
190
+ actualPixelRatio: z.ZodOptional<z.ZodNumber>;
191
+ expectedPixelRatio: z.ZodOptional<z.ZodNumber>;
176
192
  next: z.ZodOptional<z.ZodString>;
177
193
  prev: z.ZodOptional<z.ZodString>;
178
194
  category: z.ZodLiteral<"passed">;
package/dist/index.js CHANGED
@@ -30,7 +30,7 @@ const diffMetadataSchema = z.object({
30
30
  interpretation: z.unknown().optional()
31
31
  });
32
32
  /**
33
- * The verdict `cappa agent check` reached for a changed screenshot.
33
+ * A judge's verdict on a changed screenshot, as `cappa agent check` applied it.
34
34
  *
35
35
  * Unlike the interpretation this is cappa's own shape, so it is described
36
36
  * rather than carried opaquely. `label` and `action` stay plain strings on the
@@ -65,6 +65,13 @@ const screenshotBase = {
65
65
  /** Plugin that owns `taskId`. Absent whenever `taskId` is. */
66
66
  plugin: z.string().optional(),
67
67
  /**
68
+ * Image pixels per CSS pixel of the actual / expected PNG. Absent means 1.
69
+ * A client shows an image at its size divided by this, and two different
70
+ * ratios on one screenshot mean the baseline predates a scale change.
71
+ */
72
+ actualPixelRatio: z.number().positive().optional(),
73
+ expectedPixelRatio: z.number().positive().optional(),
74
+ /**
68
75
  * Neighbours in the full, unfiltered list, so the UI can walk every
69
76
  * screenshot with the arrow keys regardless of the current filter.
70
77
  *
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":[],"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\n/**\n * The verdict `cappa agent check` reached for a changed screenshot.\n *\n * Unlike the interpretation this is cappa's own shape, so it is described\n * rather than carried opaquely. `label` and `action` stay plain strings on the\n * wire so a newer engine adding a label does not make an older client reject\n * the whole screenshot list.\n */\nexport const agentReviewSchema = z.object({\n label: z.string(),\n headline: z.string(),\n rationale: z.array(z.string()),\n action: z.string(),\n source: z.enum([\"heuristic\", \"agent\"]),\n confidence: z.number().optional(),\n pending: z.boolean(),\n reviewedAt: z.string(),\n});\n\nexport type AgentReview = z.infer<typeof agentReviewSchema>;\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 review: agentReviewSchema.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,2BAA2B,EAAE,KAAK;CAC7C;CACA;CACA;CACA;AACF,CAAC;AAID,MAAa,qBAAqB,EAAE,OAAO;CACzC,eAAe,EAAE,OAAO;CACxB,mBAAmB,EAAE,OAAO;;;;;;;;;;CAU5B,gBAAgB,EAAE,QAAQ,CAAC,CAAC,SAAS;AACvC,CAAC;;;;;;;;;AAYD,MAAa,oBAAoB,EAAE,OAAO;CACxC,OAAO,EAAE,OAAO;CAChB,UAAU,EAAE,OAAO;CACnB,WAAW,EAAE,MAAM,EAAE,OAAO,CAAC;CAC7B,QAAQ,EAAE,OAAO;CACjB,QAAQ,EAAE,KAAK,CAAC,aAAa,OAAO,CAAC;CACrC,YAAY,EAAE,OAAO,CAAC,CAAC,SAAS;CAChC,SAAS,EAAE,QAAQ;CACnB,YAAY,EAAE,OAAO;AACvB,CAAC;AAID,MAAM,iBAAiB;CACrB,IAAI,EAAE,OAAO;CACb,MAAM,EAAE,OAAO;CACf,UAAU,EAAE,QAAQ,CAAC,CAAC,SAAS;;;;;;;;;;;CAW/B,QAAQ,EAAE,OAAO,CAAC,CAAC,SAAS;;CAE5B,QAAQ,EAAE,OAAO,CAAC,CAAC,SAAS;;;;;;;;CAQ5B,MAAM,EAAE,OAAO,CAAC,CAAC,SAAS;CAC1B,MAAM,EAAE,OAAO,CAAC,CAAC,SAAS;AAC5B;AAEA,MAAa,sBAAsB,EAAE,OAAO;CAC1C,GAAG;CACH,UAAU,EAAE,QAAQ,KAAK;CACzB,YAAY,EAAE,OAAO;AACvB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5B,QAAQ,EAAE,KAAK,CAAC,aAAa,eAAe,CAAC;CAC/C,CAAC;AACH,CAAC;AAMD,MAAa,oBAAoB,EAAE,OAAO;CACxC,QAAQ,EAAE,QAAQ;CAClB,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC;CACzB,QAAQ,EAAE,OAAO,CAAC,CAAC,SAAS;CAC5B,YAAY,EAAE,OAAO;CACrB,WAAW,EAAE,OAAO,CAAC,CAAC,SAAS;CAC/B,YAAY,kBAAkB,SAAS;AACzC,CAAC;AAID,MAAa,0BAA0B,EAAE,OAAO;CAC9C,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC,SAAS;CACpC,QAAQ,EAAE,OAAO,CAAC,CAAC,SAAS;CAC5B,YAAY,EAAE,OAAO,CAAC,CAAC,SAAS;CAChC,UAAU,EAAE,OAAO,CAAC,CAAC,SAAS;AAChC,CAAC"}
1
+ {"version":3,"file":"index.js","names":[],"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\n/**\n * A judge's verdict on a changed screenshot, as `cappa agent check` applied it.\n *\n * Unlike the interpretation this is cappa's own shape, so it is described\n * rather than carried opaquely. `label` and `action` stay plain strings on the\n * wire so a newer engine adding a label does not make an older client reject\n * the whole screenshot list.\n */\nexport const agentReviewSchema = z.object({\n label: z.string(),\n headline: z.string(),\n rationale: z.array(z.string()),\n action: z.string(),\n // Engines since 0.18 only send `agent`; older ones also sent `heuristic`\n // labels guessed from diff signals, so the wire format still accepts it.\n source: z.enum([\"heuristic\", \"agent\"]),\n confidence: z.number().optional(),\n pending: z.boolean(),\n reviewedAt: z.string(),\n});\n\nexport type AgentReview = z.infer<typeof agentReviewSchema>;\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 * Image pixels per CSS pixel of the actual / expected PNG. Absent means 1.\n * A client shows an image at its size divided by this, and two different\n * ratios on one screenshot mean the baseline predates a scale change.\n */\n actualPixelRatio: z.number().positive().optional(),\n expectedPixelRatio: z.number().positive().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 review: agentReviewSchema.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,2BAA2B,EAAE,KAAK;CAC7C;CACA;CACA;CACA;AACF,CAAC;AAID,MAAa,qBAAqB,EAAE,OAAO;CACzC,eAAe,EAAE,OAAO;CACxB,mBAAmB,EAAE,OAAO;;;;;;;;;;CAU5B,gBAAgB,EAAE,QAAQ,CAAC,CAAC,SAAS;AACvC,CAAC;;;;;;;;;AAYD,MAAa,oBAAoB,EAAE,OAAO;CACxC,OAAO,EAAE,OAAO;CAChB,UAAU,EAAE,OAAO;CACnB,WAAW,EAAE,MAAM,EAAE,OAAO,CAAC;CAC7B,QAAQ,EAAE,OAAO;CAGjB,QAAQ,EAAE,KAAK,CAAC,aAAa,OAAO,CAAC;CACrC,YAAY,EAAE,OAAO,CAAC,CAAC,SAAS;CAChC,SAAS,EAAE,QAAQ;CACnB,YAAY,EAAE,OAAO;AACvB,CAAC;AAID,MAAM,iBAAiB;CACrB,IAAI,EAAE,OAAO;CACb,MAAM,EAAE,OAAO;CACf,UAAU,EAAE,QAAQ,CAAC,CAAC,SAAS;;;;;;;;;;;CAW/B,QAAQ,EAAE,OAAO,CAAC,CAAC,SAAS;;CAE5B,QAAQ,EAAE,OAAO,CAAC,CAAC,SAAS;;;;;;CAM5B,kBAAkB,EAAE,OAAO,CAAC,CAAC,SAAS,CAAC,CAAC,SAAS;CACjD,oBAAoB,EAAE,OAAO,CAAC,CAAC,SAAS,CAAC,CAAC,SAAS;;;;;;;;CAQnD,MAAM,EAAE,OAAO,CAAC,CAAC,SAAS;CAC1B,MAAM,EAAE,OAAO,CAAC,CAAC,SAAS;AAC5B;AAEA,MAAa,sBAAsB,EAAE,OAAO;CAC1C,GAAG;CACH,UAAU,EAAE,QAAQ,KAAK;CACzB,YAAY,EAA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Q,YAAY;EAC5B,QAAQ,EAAE,KAAK,CAAC,aAAa,eAAe,CAAC;CAC/C,CAAC;AACH,CAAC;AAMD,MAAa,oBAAoB,EAAE,OAAO;CACxC,QAAQ,EAAE,QAAQ;CAClB,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC;CACzB,QAAQ,EAAE,OAAO,CAAC,CAAC,SAAS;CAC5B,YAAY,EAAE,OAAO;CACrB,WAAW,EAAE,OAAO,CAAC,CAAC,SAAS;CAC/B,YAAY,kBAAkB,SAAS;AACzC,CAAC;AAID,MAAa,0BAA0B,EAAE,OAAO;CAC9C,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC,SAAS;CACpC,QAAQ,EAAE,OAAO,CAAC,CAAC,SAAS;CAC5B,YAAY,EAAE,OAAO,CAAC,CAAC,SAAS;CAChC,UAAU,EAAE,OAAO,CAAC,CAAC,SAAS;AAChC,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cappa/protocol",
3
- "version": "0.10.0",
3
+ "version": "0.11.0",
4
4
  "description": "Wire contract shared by the Cappa server, clients and review UI",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -31,11 +31,11 @@
31
31
  "./package.json": "./package.json"
32
32
  },
33
33
  "dependencies": {
34
- "zod": "4.5.4"
34
+ "zod": "4.6.6"
35
35
  },
36
36
  "devDependencies": {
37
37
  "@arethetypeswrong/cli": "0.18.5",
38
- "@cappa/core": "0.15.0",
38
+ "@cappa/core": "0.20.0",
39
39
  "tsdown": "0.23.0",
40
40
  "typescript": "7.0.2",
41
41
  "vitest": "5.0.0"