@paikko/contract 0.1.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.
@@ -0,0 +1,1590 @@
1
+ /**
2
+ * paikko ticket bundle contract.
3
+ *
4
+ * This is THE shared interface. Every module imports from here: the
5
+ * `<ReportButton>` that produces a bundle, the API that persists it, the ticket
6
+ * UI that renders it, and the agent runner that consumes it. Change a shape here
7
+ * and you change it for everyone, so it lives in one file with types and zod
8
+ * schemas side by side.
9
+ *
10
+ * ## Two tiers
11
+ *
12
+ * A ticket is split so the agent's context stays cheap:
13
+ *
14
+ * - TIER 1 - the HEAD ({@link TicketHead}). Small, always loaded into agent
15
+ * context. Carries the user's message, where it happened (route + clicked
16
+ * element provenance), the conversation thread, and an INDEX of artifacts.
17
+ * The index lists each artifact by name with a `ref` (how to fetch it) and a
18
+ * `summary` (one line) plus a few cheap stats, so the agent can decide from
19
+ * the head alone whether it even needs the heavy payload. Most tickets are
20
+ * solved from the head with zero fetches.
21
+ *
22
+ * - TIER 2 - the ARTIFACT PAYLOADS. Heavy, immutable, captured once at report
23
+ * time (a photograph, not a live window). Fetched by ref only when a fix
24
+ * needs them: console, network, client state, storage, DOM snapshot, backend
25
+ * trace. Stored as JSONB rows keyed by ticket+name, served at
26
+ * `GET /tickets/:id/artifacts/:name`.
27
+ *
28
+ * ## The spine: traceId
29
+ *
30
+ * `traceId` stitches the two halves of a single request together. A frontend
31
+ * {@link NetworkEntry} and the backend {@link TraceRequest} it triggered share
32
+ * the same `traceId`. That is how the agent walks from "this fetch on the page"
33
+ * to "this handler + these queries on the server" without guessing.
34
+ *
35
+ * ## Provenance: src
36
+ *
37
+ * `src` ("file:line:col") appears on every layer the user or agent can point at -
38
+ * the clicked element, the API handler, each DB query - so provenance runs end to
39
+ * end. It is injected at build time (see PROVENANCE.md).
40
+ */
41
+ import { z } from "zod";
42
+ /**
43
+ * Ticket lifecycle. `status` is persisted as a free `String` in
44
+ * prisma/schema.prisma; this enum is the app-side validator for it.
45
+ *
46
+ * Terminal states are `closed` (accepted: the ticket's branch was merged to main
47
+ * and the live app redeployed) and `rejected` (discarded: the ticket's branch +
48
+ * worktree were dropped, the live app untouched). `reviewing` is the parked state
49
+ * where the fix lives on its own branch with an isolated preview; a user reply on
50
+ * a `reviewing` ticket re-engages the agent (no separate reject needed to request
51
+ * changes).
52
+ */
53
+ export declare const TicketStatusSchema: z.ZodEnum<["open", "reproducing", "needs_info", "reviewing", "closed", "rejected"]>;
54
+ export type TicketStatus = z.infer<typeof TicketStatusSchema>;
55
+ /**
56
+ * The canonical names an artifact can have. The artifact index is keyed by these,
57
+ * and `GET /tickets/:id/artifacts/:name` expects one of them.
58
+ */
59
+ export declare const ArtifactNameSchema: z.ZodEnum<["console", "network", "clientState", "storage", "dom", "trace", "screenshot"]>;
60
+ export type ArtifactName = z.infer<typeof ArtifactNameSchema>;
61
+ /**
62
+ * Source provenance, "file:line:col" (e.g. "src/components/Cart.tsx:42:7").
63
+ * Injected at build time onto JSX, attached to handlers and queries.
64
+ */
65
+ export declare const SrcSchema: z.ZodString;
66
+ export type Src = z.infer<typeof SrcSchema>;
67
+ /** ISO-8601 timestamp string. Used everywhere a time is recorded. */
68
+ export declare const IsoTimeSchema: z.ZodString;
69
+ export type IsoTime = z.infer<typeof IsoTimeSchema>;
70
+ /**
71
+ * The id that stitches a frontend network entry to its backend request.
72
+ * Generated client-side per request, echoed by the server.
73
+ */
74
+ export declare const TraceIdSchema: z.ZodString;
75
+ export type TraceId = z.infer<typeof TraceIdSchema>;
76
+ /**
77
+ * What the user pointed at when they hit report: the clicked DOM element resolved
78
+ * to a CSS selector, its source location, and the owning component. All optional
79
+ * because a report can be fired without a specific target (e.g. a global "this
80
+ * page is wrong").
81
+ */
82
+ export declare const ReportTargetSchema: z.ZodObject<{
83
+ /** CSS selector identifying the clicked element in the live DOM. */
84
+ selector: z.ZodNullable<z.ZodString>;
85
+ /** Build-time source provenance of the element ("file:line:col"). */
86
+ src: z.ZodNullable<z.ZodString>;
87
+ /** Display name of the React component that owns the element. */
88
+ component: z.ZodNullable<z.ZodString>;
89
+ }, "strip", z.ZodTypeAny, {
90
+ selector: string | null;
91
+ src: string | null;
92
+ component: string | null;
93
+ }, {
94
+ selector: string | null;
95
+ src: string | null;
96
+ component: string | null;
97
+ }>;
98
+ export type ReportTarget = z.infer<typeof ReportTargetSchema>;
99
+ /** The user-authored core of a report: what's wrong and where. */
100
+ export declare const ReportSchema: z.ZodObject<{
101
+ /** Free-text description from the reporter. Capped so a single report can't be
102
+ * an unbounded blob (intake has no other size gate on this field). */
103
+ message: z.ZodString;
104
+ /** Report category (e.g. "bug", "visual", "crash"). Free-form in v0. */
105
+ kind: z.ZodString;
106
+ /** App route the report was fired from (e.g. "/cart"). */
107
+ route: z.ZodString;
108
+ /** The clicked element, resolved to selector + provenance + component. */
109
+ target: z.ZodObject<{
110
+ /** CSS selector identifying the clicked element in the live DOM. */
111
+ selector: z.ZodNullable<z.ZodString>;
112
+ /** Build-time source provenance of the element ("file:line:col"). */
113
+ src: z.ZodNullable<z.ZodString>;
114
+ /** Display name of the React component that owns the element. */
115
+ component: z.ZodNullable<z.ZodString>;
116
+ }, "strip", z.ZodTypeAny, {
117
+ selector: string | null;
118
+ src: string | null;
119
+ component: string | null;
120
+ }, {
121
+ selector: string | null;
122
+ src: string | null;
123
+ component: string | null;
124
+ }>;
125
+ }, "strip", z.ZodTypeAny, {
126
+ message: string;
127
+ kind: string;
128
+ route: string;
129
+ target: {
130
+ selector: string | null;
131
+ src: string | null;
132
+ component: string | null;
133
+ };
134
+ }, {
135
+ message: string;
136
+ kind: string;
137
+ route: string;
138
+ target: {
139
+ selector: string | null;
140
+ src: string | null;
141
+ component: string | null;
142
+ };
143
+ }>;
144
+ export type Report = z.infer<typeof ReportSchema>;
145
+ /** One message in the ticket's conversation (reporter, agent, or reviewer). */
146
+ export declare const ThreadMessageSchema: z.ZodObject<{
147
+ id: z.ZodString;
148
+ /** Author handle: reporter id, "agent", reviewer id, etc. */
149
+ by: z.ZodString;
150
+ text: z.ZodString;
151
+ at: z.ZodString;
152
+ }, "strip", z.ZodTypeAny, {
153
+ at: string;
154
+ id: string;
155
+ by: string;
156
+ text: string;
157
+ }, {
158
+ at: string;
159
+ id: string;
160
+ by: string;
161
+ text: string;
162
+ }>;
163
+ export type ThreadMessage = z.infer<typeof ThreadMessageSchema>;
164
+ /**
165
+ * One entry in the artifact index. Lives in the head so the agent can read the
166
+ * `summary` and stats and decide whether to fetch the heavy payload via `ref`.
167
+ *
168
+ * `count` and `size` are cheap, type-agnostic stats:
169
+ * - `count`: number of records in the payload (console lines, network calls,
170
+ * backend requests, ...). Null for single-object artifacts (clientState).
171
+ * - `size`: serialized payload size in bytes.
172
+ */
173
+ export declare const ArtifactIndexEntrySchema: z.ZodObject<{
174
+ /** Fetch handle: `GET /tickets/:id/artifacts/:name`. */
175
+ ref: z.ZodString;
176
+ /** One-line human/agent summary so the head is decision-complete. */
177
+ summary: z.ZodString;
178
+ /** Record count for collection artifacts; null for singletons. */
179
+ count: z.ZodNullable<z.ZodNumber>;
180
+ /** Serialized payload size in bytes. */
181
+ size: z.ZodNumber;
182
+ }, "strip", z.ZodTypeAny, {
183
+ ref: string;
184
+ summary: string;
185
+ count: number | null;
186
+ size: number;
187
+ }, {
188
+ ref: string;
189
+ summary: string;
190
+ count: number | null;
191
+ size: number;
192
+ }>;
193
+ export type ArtifactIndexEntry = z.infer<typeof ArtifactIndexEntrySchema>;
194
+ /**
195
+ * The artifacts index: a map from artifact name to its index entry. Partial -
196
+ * a ticket only indexes the artifacts that were actually captured.
197
+ */
198
+ export declare const ArtifactIndexSchema: z.ZodRecord<z.ZodEnum<["console", "network", "clientState", "storage", "dom", "trace", "screenshot"]>, z.ZodObject<{
199
+ /** Fetch handle: `GET /tickets/:id/artifacts/:name`. */
200
+ ref: z.ZodString;
201
+ /** One-line human/agent summary so the head is decision-complete. */
202
+ summary: z.ZodString;
203
+ /** Record count for collection artifacts; null for singletons. */
204
+ count: z.ZodNullable<z.ZodNumber>;
205
+ /** Serialized payload size in bytes. */
206
+ size: z.ZodNumber;
207
+ }, "strip", z.ZodTypeAny, {
208
+ ref: string;
209
+ summary: string;
210
+ count: number | null;
211
+ size: number;
212
+ }, {
213
+ ref: string;
214
+ summary: string;
215
+ count: number | null;
216
+ size: number;
217
+ }>>;
218
+ export type ArtifactIndex = Partial<Record<ArtifactName, ArtifactIndexEntry>>;
219
+ /**
220
+ * TIER 1. The ticket head - always loaded into agent context. Small and
221
+ * self-sufficient: message, where it happened, the thread, and the index of
222
+ * heavy artifacts behind refs.
223
+ */
224
+ export declare const TicketHeadSchema: z.ZodObject<{
225
+ id: z.ZodString;
226
+ status: z.ZodEnum<["open", "reproducing", "needs_info", "reviewing", "closed", "rejected"]>;
227
+ createdAt: z.ZodString;
228
+ /** Who filed it (user id / handle). */
229
+ reporter: z.ZodString;
230
+ report: z.ZodObject<{
231
+ /** Free-text description from the reporter. Capped so a single report can't be
232
+ * an unbounded blob (intake has no other size gate on this field). */
233
+ message: z.ZodString;
234
+ /** Report category (e.g. "bug", "visual", "crash"). Free-form in v0. */
235
+ kind: z.ZodString;
236
+ /** App route the report was fired from (e.g. "/cart"). */
237
+ route: z.ZodString;
238
+ /** The clicked element, resolved to selector + provenance + component. */
239
+ target: z.ZodObject<{
240
+ /** CSS selector identifying the clicked element in the live DOM. */
241
+ selector: z.ZodNullable<z.ZodString>;
242
+ /** Build-time source provenance of the element ("file:line:col"). */
243
+ src: z.ZodNullable<z.ZodString>;
244
+ /** Display name of the React component that owns the element. */
245
+ component: z.ZodNullable<z.ZodString>;
246
+ }, "strip", z.ZodTypeAny, {
247
+ selector: string | null;
248
+ src: string | null;
249
+ component: string | null;
250
+ }, {
251
+ selector: string | null;
252
+ src: string | null;
253
+ component: string | null;
254
+ }>;
255
+ }, "strip", z.ZodTypeAny, {
256
+ message: string;
257
+ kind: string;
258
+ route: string;
259
+ target: {
260
+ selector: string | null;
261
+ src: string | null;
262
+ component: string | null;
263
+ };
264
+ }, {
265
+ message: string;
266
+ kind: string;
267
+ route: string;
268
+ target: {
269
+ selector: string | null;
270
+ src: string | null;
271
+ component: string | null;
272
+ };
273
+ }>;
274
+ thread: z.ZodArray<z.ZodObject<{
275
+ id: z.ZodString;
276
+ /** Author handle: reporter id, "agent", reviewer id, etc. */
277
+ by: z.ZodString;
278
+ text: z.ZodString;
279
+ at: z.ZodString;
280
+ }, "strip", z.ZodTypeAny, {
281
+ at: string;
282
+ id: string;
283
+ by: string;
284
+ text: string;
285
+ }, {
286
+ at: string;
287
+ id: string;
288
+ by: string;
289
+ text: string;
290
+ }>, "many">;
291
+ artifacts: z.ZodRecord<z.ZodEnum<["console", "network", "clientState", "storage", "dom", "trace", "screenshot"]>, z.ZodObject<{
292
+ /** Fetch handle: `GET /tickets/:id/artifacts/:name`. */
293
+ ref: z.ZodString;
294
+ /** One-line human/agent summary so the head is decision-complete. */
295
+ summary: z.ZodString;
296
+ /** Record count for collection artifacts; null for singletons. */
297
+ count: z.ZodNullable<z.ZodNumber>;
298
+ /** Serialized payload size in bytes. */
299
+ size: z.ZodNumber;
300
+ }, "strip", z.ZodTypeAny, {
301
+ ref: string;
302
+ summary: string;
303
+ count: number | null;
304
+ size: number;
305
+ }, {
306
+ ref: string;
307
+ summary: string;
308
+ count: number | null;
309
+ size: number;
310
+ }>>;
311
+ /**
312
+ * Which project/tenant this ticket belongs to (the SaaS seam). Persisted from
313
+ * the `projectKey` the widget sent on the {@link ReportBundle}. Null in the
314
+ * current single-tenant deployment; making multi-tenancy real is a later flip of
315
+ * this value, not a schema rewrite.
316
+ */
317
+ projectKey: z.ZodNullable<z.ZodString>;
318
+ /**
319
+ * The git branch the fix lives on (e.g. "ticket/{id}"). Branch-isolated review:
320
+ * each ticket is fixed in its own worktree + branch off main, so main stays
321
+ * pristine until Accept. Null until the agent has cut the branch.
322
+ */
323
+ branch: z.ZodNullable<z.ZodString>;
324
+ /**
325
+ * The isolated preview URL where ONLY this ticket's fix is viewable
326
+ * (e.g. "http://localhost:8788"), distinct from the pristine main app. "View
327
+ * fix" links here, not to the live app. Null until the isolated preview is up.
328
+ */
329
+ previewUrl: z.ZodNullable<z.ZodString>;
330
+ }, "strip", z.ZodTypeAny, {
331
+ status: "open" | "reproducing" | "needs_info" | "reviewing" | "closed" | "rejected";
332
+ id: string;
333
+ createdAt: string;
334
+ reporter: string;
335
+ report: {
336
+ message: string;
337
+ kind: string;
338
+ route: string;
339
+ target: {
340
+ selector: string | null;
341
+ src: string | null;
342
+ component: string | null;
343
+ };
344
+ };
345
+ thread: {
346
+ at: string;
347
+ id: string;
348
+ by: string;
349
+ text: string;
350
+ }[];
351
+ artifacts: Partial<Record<"console" | "network" | "clientState" | "storage" | "dom" | "trace" | "screenshot", {
352
+ ref: string;
353
+ summary: string;
354
+ count: number | null;
355
+ size: number;
356
+ }>>;
357
+ projectKey: string | null;
358
+ branch: string | null;
359
+ previewUrl: string | null;
360
+ }, {
361
+ status: "open" | "reproducing" | "needs_info" | "reviewing" | "closed" | "rejected";
362
+ id: string;
363
+ createdAt: string;
364
+ reporter: string;
365
+ report: {
366
+ message: string;
367
+ kind: string;
368
+ route: string;
369
+ target: {
370
+ selector: string | null;
371
+ src: string | null;
372
+ component: string | null;
373
+ };
374
+ };
375
+ thread: {
376
+ at: string;
377
+ id: string;
378
+ by: string;
379
+ text: string;
380
+ }[];
381
+ artifacts: Partial<Record<"console" | "network" | "clientState" | "storage" | "dom" | "trace" | "screenshot", {
382
+ ref: string;
383
+ summary: string;
384
+ count: number | null;
385
+ size: number;
386
+ }>>;
387
+ projectKey: string | null;
388
+ branch: string | null;
389
+ previewUrl: string | null;
390
+ }>;
391
+ export type TicketHead = z.infer<typeof TicketHeadSchema>;
392
+ /** One captured console line from the ring buffer. */
393
+ export declare const ConsoleEntrySchema: z.ZodObject<{
394
+ level: z.ZodEnum<["log", "info", "warn", "error", "debug"]>;
395
+ /** Already-formatted message text. */
396
+ message: z.ZodString;
397
+ /** Structured args as captured (best-effort serialized). */
398
+ args: z.ZodOptional<z.ZodArray<z.ZodUnknown, "many">>;
399
+ at: z.ZodString;
400
+ }, "strip", z.ZodTypeAny, {
401
+ message: string;
402
+ at: string;
403
+ level: "log" | "info" | "warn" | "error" | "debug";
404
+ args?: unknown[] | undefined;
405
+ }, {
406
+ message: string;
407
+ at: string;
408
+ level: "log" | "info" | "warn" | "error" | "debug";
409
+ args?: unknown[] | undefined;
410
+ }>;
411
+ export type ConsoleEntry = z.infer<typeof ConsoleEntrySchema>;
412
+ /** Payload for the `console` artifact: the console ring buffer, oldest first.
413
+ * Length-capped so a forged bundle can't ship an unbounded array. */
414
+ export declare const ConsoleArtifactSchema: z.ZodArray<z.ZodObject<{
415
+ level: z.ZodEnum<["log", "info", "warn", "error", "debug"]>;
416
+ /** Already-formatted message text. */
417
+ message: z.ZodString;
418
+ /** Structured args as captured (best-effort serialized). */
419
+ args: z.ZodOptional<z.ZodArray<z.ZodUnknown, "many">>;
420
+ at: z.ZodString;
421
+ }, "strip", z.ZodTypeAny, {
422
+ message: string;
423
+ at: string;
424
+ level: "log" | "info" | "warn" | "error" | "debug";
425
+ args?: unknown[] | undefined;
426
+ }, {
427
+ message: string;
428
+ at: string;
429
+ level: "log" | "info" | "warn" | "error" | "debug";
430
+ args?: unknown[] | undefined;
431
+ }>, "many">;
432
+ export type ConsoleArtifact = z.infer<typeof ConsoleArtifactSchema>;
433
+ /**
434
+ * One captured frontend network call. `traceId` is the spine: it matches the
435
+ * `traceId` on the {@link TraceRequest} the call hit on the backend.
436
+ */
437
+ export declare const NetworkEntrySchema: z.ZodObject<{
438
+ /** Spine id linking this call to its backend request. */
439
+ traceId: z.ZodString;
440
+ method: z.ZodString;
441
+ url: z.ZodString;
442
+ /** HTTP status; null if the request never completed. */
443
+ status: z.ZodNullable<z.ZodNumber>;
444
+ /** Request body as captured (serialized; null if none). */
445
+ reqBody: z.ZodNullable<z.ZodUnknown>;
446
+ /** Response body as captured (serialized; null if none). */
447
+ resBody: z.ZodNullable<z.ZodUnknown>;
448
+ startedAt: z.ZodString;
449
+ /** Round-trip duration in milliseconds; null if unknown. */
450
+ durationMs: z.ZodNullable<z.ZodNumber>;
451
+ }, "strip", z.ZodTypeAny, {
452
+ status: number | null;
453
+ traceId: string;
454
+ method: string;
455
+ url: string;
456
+ startedAt: string;
457
+ durationMs: number | null;
458
+ reqBody?: unknown;
459
+ resBody?: unknown;
460
+ }, {
461
+ status: number | null;
462
+ traceId: string;
463
+ method: string;
464
+ url: string;
465
+ startedAt: string;
466
+ durationMs: number | null;
467
+ reqBody?: unknown;
468
+ resBody?: unknown;
469
+ }>;
470
+ export type NetworkEntry = z.infer<typeof NetworkEntrySchema>;
471
+ /** Payload for the `network` artifact: last N network calls, oldest first.
472
+ * Length-capped so a forged bundle can't ship an unbounded array. */
473
+ export declare const NetworkArtifactSchema: z.ZodArray<z.ZodObject<{
474
+ /** Spine id linking this call to its backend request. */
475
+ traceId: z.ZodString;
476
+ method: z.ZodString;
477
+ url: z.ZodString;
478
+ /** HTTP status; null if the request never completed. */
479
+ status: z.ZodNullable<z.ZodNumber>;
480
+ /** Request body as captured (serialized; null if none). */
481
+ reqBody: z.ZodNullable<z.ZodUnknown>;
482
+ /** Response body as captured (serialized; null if none). */
483
+ resBody: z.ZodNullable<z.ZodUnknown>;
484
+ startedAt: z.ZodString;
485
+ /** Round-trip duration in milliseconds; null if unknown. */
486
+ durationMs: z.ZodNullable<z.ZodNumber>;
487
+ }, "strip", z.ZodTypeAny, {
488
+ status: number | null;
489
+ traceId: string;
490
+ method: string;
491
+ url: string;
492
+ startedAt: string;
493
+ durationMs: number | null;
494
+ reqBody?: unknown;
495
+ resBody?: unknown;
496
+ }, {
497
+ status: number | null;
498
+ traceId: string;
499
+ method: string;
500
+ url: string;
501
+ startedAt: string;
502
+ durationMs: number | null;
503
+ reqBody?: unknown;
504
+ resBody?: unknown;
505
+ }>, "many">;
506
+ export type NetworkArtifact = z.infer<typeof NetworkArtifactSchema>;
507
+ /**
508
+ * Payload for the `clientState` artifact: a snapshot of the mandated state store
509
+ * at report time. Shape is app-defined, so it's an opaque record.
510
+ */
511
+ export declare const ClientStateArtifactSchema: z.ZodRecord<z.ZodString, z.ZodUnknown>;
512
+ export type ClientStateArtifact = z.infer<typeof ClientStateArtifactSchema>;
513
+ /**
514
+ * Payload for the `storage` artifact: localStorage / sessionStorage / cookies
515
+ * captured at report time. Each is a flat string->string map.
516
+ */
517
+ export declare const StorageArtifactSchema: z.ZodObject<{
518
+ local: z.ZodRecord<z.ZodString, z.ZodString>;
519
+ session: z.ZodRecord<z.ZodString, z.ZodString>;
520
+ cookies: z.ZodRecord<z.ZodString, z.ZodString>;
521
+ }, "strip", z.ZodTypeAny, {
522
+ local: Record<string, string>;
523
+ session: Record<string, string>;
524
+ cookies: Record<string, string>;
525
+ }, {
526
+ local: Record<string, string>;
527
+ session: Record<string, string>;
528
+ cookies: Record<string, string>;
529
+ }>;
530
+ export type StorageArtifact = z.infer<typeof StorageArtifactSchema>;
531
+ /**
532
+ * Payload for the `dom` artifact: a snapshot of the DOM at report time. `html` is
533
+ * the serialized document/subtree; `targetSelector` points back at the clicked
534
+ * element within it.
535
+ */
536
+ export declare const DomArtifactSchema: z.ZodObject<{
537
+ /** Serialized DOM (full document or relevant subtree). Capped (~8MB) so a
538
+ * crafted bundle can't bloat a D1 row / OOM the worker on intake. */
539
+ html: z.ZodString;
540
+ /** Selector of the reported element within `html`. */
541
+ targetSelector: z.ZodNullable<z.ZodString>;
542
+ /** Viewport size at capture time. */
543
+ viewport: z.ZodObject<{
544
+ width: z.ZodNumber;
545
+ height: z.ZodNumber;
546
+ }, "strip", z.ZodTypeAny, {
547
+ width: number;
548
+ height: number;
549
+ }, {
550
+ width: number;
551
+ height: number;
552
+ }>;
553
+ }, "strip", z.ZodTypeAny, {
554
+ html: string;
555
+ targetSelector: string | null;
556
+ viewport: {
557
+ width: number;
558
+ height: number;
559
+ };
560
+ }, {
561
+ html: string;
562
+ targetSelector: string | null;
563
+ viewport: {
564
+ width: number;
565
+ height: number;
566
+ };
567
+ }>;
568
+ export type DomArtifact = z.infer<typeof DomArtifactSchema>;
569
+ /** One database query recorded inside a backend request. */
570
+ export declare const TraceQuerySchema: z.ZodObject<{
571
+ /** SQL or query string as executed. */
572
+ sql: z.ZodString;
573
+ /** Bound parameters, serialized. */
574
+ params: z.ZodOptional<z.ZodArray<z.ZodUnknown, "many">>;
575
+ /** Execution time in milliseconds. */
576
+ durationMs: z.ZodNullable<z.ZodNumber>;
577
+ /** Provenance of the call site issuing the query ("file:line:col"). */
578
+ src: z.ZodNullable<z.ZodString>;
579
+ }, "strip", z.ZodTypeAny, {
580
+ src: string | null;
581
+ durationMs: number | null;
582
+ sql: string;
583
+ params?: unknown[] | undefined;
584
+ }, {
585
+ src: string | null;
586
+ durationMs: number | null;
587
+ sql: string;
588
+ params?: unknown[] | undefined;
589
+ }>;
590
+ export type TraceQuery = z.infer<typeof TraceQuerySchema>;
591
+ /**
592
+ * One backend request captured by the `withCapture()` handler wrapper. Joined to
593
+ * a frontend {@link NetworkEntry} by `traceId`.
594
+ */
595
+ export declare const TraceRequestSchema: z.ZodObject<{
596
+ /** Spine id - matches the frontend NetworkEntry that triggered this request. */
597
+ traceId: z.ZodString;
598
+ /** Name/identity of the handler that ran. */
599
+ handler: z.ZodString;
600
+ /** Provenance of the handler ("file:line:col"). */
601
+ src: z.ZodNullable<z.ZodString>;
602
+ method: z.ZodString;
603
+ url: z.ZodString;
604
+ status: z.ZodNullable<z.ZodNumber>;
605
+ /** Queries issued during this request, in order. */
606
+ queries: z.ZodArray<z.ZodObject<{
607
+ /** SQL or query string as executed. */
608
+ sql: z.ZodString;
609
+ /** Bound parameters, serialized. */
610
+ params: z.ZodOptional<z.ZodArray<z.ZodUnknown, "many">>;
611
+ /** Execution time in milliseconds. */
612
+ durationMs: z.ZodNullable<z.ZodNumber>;
613
+ /** Provenance of the call site issuing the query ("file:line:col"). */
614
+ src: z.ZodNullable<z.ZodString>;
615
+ }, "strip", z.ZodTypeAny, {
616
+ src: string | null;
617
+ durationMs: number | null;
618
+ sql: string;
619
+ params?: unknown[] | undefined;
620
+ }, {
621
+ src: string | null;
622
+ durationMs: number | null;
623
+ sql: string;
624
+ params?: unknown[] | undefined;
625
+ }>, "many">;
626
+ /** Serialized error if the handler threw; null on success. */
627
+ threw: z.ZodNullable<z.ZodUnknown>;
628
+ durationMs: z.ZodNullable<z.ZodNumber>;
629
+ }, "strip", z.ZodTypeAny, {
630
+ src: string | null;
631
+ status: number | null;
632
+ traceId: string;
633
+ method: string;
634
+ url: string;
635
+ durationMs: number | null;
636
+ handler: string;
637
+ queries: {
638
+ src: string | null;
639
+ durationMs: number | null;
640
+ sql: string;
641
+ params?: unknown[] | undefined;
642
+ }[];
643
+ threw?: unknown;
644
+ }, {
645
+ src: string | null;
646
+ status: number | null;
647
+ traceId: string;
648
+ method: string;
649
+ url: string;
650
+ durationMs: number | null;
651
+ handler: string;
652
+ queries: {
653
+ src: string | null;
654
+ durationMs: number | null;
655
+ sql: string;
656
+ params?: unknown[] | undefined;
657
+ }[];
658
+ threw?: unknown;
659
+ }>;
660
+ export type TraceRequest = z.infer<typeof TraceRequestSchema>;
661
+ /**
662
+ * Payload for the `trace` artifact: the backend side of the report. One capture
663
+ * session containing every backend request that ran during the reported
664
+ * interaction, each stitched to its frontend call by `traceId`.
665
+ */
666
+ export declare const TraceArtifactSchema: z.ZodObject<{
667
+ /** Backend capture session id for the reported interaction. */
668
+ sessionId: z.ZodString;
669
+ requests: z.ZodArray<z.ZodObject<{
670
+ /** Spine id - matches the frontend NetworkEntry that triggered this request. */
671
+ traceId: z.ZodString;
672
+ /** Name/identity of the handler that ran. */
673
+ handler: z.ZodString;
674
+ /** Provenance of the handler ("file:line:col"). */
675
+ src: z.ZodNullable<z.ZodString>;
676
+ method: z.ZodString;
677
+ url: z.ZodString;
678
+ status: z.ZodNullable<z.ZodNumber>;
679
+ /** Queries issued during this request, in order. */
680
+ queries: z.ZodArray<z.ZodObject<{
681
+ /** SQL or query string as executed. */
682
+ sql: z.ZodString;
683
+ /** Bound parameters, serialized. */
684
+ params: z.ZodOptional<z.ZodArray<z.ZodUnknown, "many">>;
685
+ /** Execution time in milliseconds. */
686
+ durationMs: z.ZodNullable<z.ZodNumber>;
687
+ /** Provenance of the call site issuing the query ("file:line:col"). */
688
+ src: z.ZodNullable<z.ZodString>;
689
+ }, "strip", z.ZodTypeAny, {
690
+ src: string | null;
691
+ durationMs: number | null;
692
+ sql: string;
693
+ params?: unknown[] | undefined;
694
+ }, {
695
+ src: string | null;
696
+ durationMs: number | null;
697
+ sql: string;
698
+ params?: unknown[] | undefined;
699
+ }>, "many">;
700
+ /** Serialized error if the handler threw; null on success. */
701
+ threw: z.ZodNullable<z.ZodUnknown>;
702
+ durationMs: z.ZodNullable<z.ZodNumber>;
703
+ }, "strip", z.ZodTypeAny, {
704
+ src: string | null;
705
+ status: number | null;
706
+ traceId: string;
707
+ method: string;
708
+ url: string;
709
+ durationMs: number | null;
710
+ handler: string;
711
+ queries: {
712
+ src: string | null;
713
+ durationMs: number | null;
714
+ sql: string;
715
+ params?: unknown[] | undefined;
716
+ }[];
717
+ threw?: unknown;
718
+ }, {
719
+ src: string | null;
720
+ status: number | null;
721
+ traceId: string;
722
+ method: string;
723
+ url: string;
724
+ durationMs: number | null;
725
+ handler: string;
726
+ queries: {
727
+ src: string | null;
728
+ durationMs: number | null;
729
+ sql: string;
730
+ params?: unknown[] | undefined;
731
+ }[];
732
+ threw?: unknown;
733
+ }>, "many">;
734
+ }, "strip", z.ZodTypeAny, {
735
+ sessionId: string;
736
+ requests: {
737
+ src: string | null;
738
+ status: number | null;
739
+ traceId: string;
740
+ method: string;
741
+ url: string;
742
+ durationMs: number | null;
743
+ handler: string;
744
+ queries: {
745
+ src: string | null;
746
+ durationMs: number | null;
747
+ sql: string;
748
+ params?: unknown[] | undefined;
749
+ }[];
750
+ threw?: unknown;
751
+ }[];
752
+ }, {
753
+ sessionId: string;
754
+ requests: {
755
+ src: string | null;
756
+ status: number | null;
757
+ traceId: string;
758
+ method: string;
759
+ url: string;
760
+ durationMs: number | null;
761
+ handler: string;
762
+ queries: {
763
+ src: string | null;
764
+ durationMs: number | null;
765
+ sql: string;
766
+ params?: unknown[] | undefined;
767
+ }[];
768
+ threw?: unknown;
769
+ }[];
770
+ }>;
771
+ export type TraceArtifact = z.infer<typeof TraceArtifactSchema>;
772
+ /**
773
+ * Payload for the `screenshot` artifact: an actual rendered image of the page at
774
+ * report time, so the agent (which can see images) and the human reviewer can
775
+ * directly judge "this looks off" / visual reports that a DOM/CSS snapshot can't
776
+ * convey. The widget's own report UI is excluded from the shot.
777
+ *
778
+ * Kept small on purpose: the longest side is capped (~1280px) and the image is
779
+ * JPEG-compressed, so the base64 `dataUrl` typically lands well under ~1MB. `png`
780
+ * is allowed as a fallback but is larger; prefer `jpeg`.
781
+ */
782
+ export declare const ScreenshotArtifactSchema: z.ZodObject<{
783
+ /** A `data:` URL holding the base64-encoded image (e.g. `data:image/jpeg;base64,...`).
784
+ * Scheme-locked to an inline image (a remote http(s) src would turn opening
785
+ * the artifact into an outbound request to an attacker host) and size-capped
786
+ * (~12MB) so it can't be used as a DoS payload. */
787
+ dataUrl: z.ZodString;
788
+ /** Pixel width of the rendered image. */
789
+ width: z.ZodNumber;
790
+ /** Pixel height of the rendered image. */
791
+ height: z.ZodNumber;
792
+ /** Encoding of the image embedded in `dataUrl`. */
793
+ format: z.ZodEnum<["jpeg", "png"]>;
794
+ }, "strip", z.ZodTypeAny, {
795
+ width: number;
796
+ height: number;
797
+ dataUrl: string;
798
+ format: "jpeg" | "png";
799
+ }, {
800
+ width: number;
801
+ height: number;
802
+ dataUrl: string;
803
+ format: "jpeg" | "png";
804
+ }>;
805
+ export type ScreenshotArtifact = z.infer<typeof ScreenshotArtifactSchema>;
806
+ /**
807
+ * Maps each artifact name to the zod schema for its payload. Use this to validate
808
+ * a payload before persisting it or after fetching it by ref:
809
+ *
810
+ * ArtifactPayloadSchemas[name].parse(payload)
811
+ */
812
+ export declare const ArtifactPayloadSchemas: {
813
+ readonly console: z.ZodArray<z.ZodObject<{
814
+ level: z.ZodEnum<["log", "info", "warn", "error", "debug"]>;
815
+ /** Already-formatted message text. */
816
+ message: z.ZodString;
817
+ /** Structured args as captured (best-effort serialized). */
818
+ args: z.ZodOptional<z.ZodArray<z.ZodUnknown, "many">>;
819
+ at: z.ZodString;
820
+ }, "strip", z.ZodTypeAny, {
821
+ message: string;
822
+ at: string;
823
+ level: "log" | "info" | "warn" | "error" | "debug";
824
+ args?: unknown[] | undefined;
825
+ }, {
826
+ message: string;
827
+ at: string;
828
+ level: "log" | "info" | "warn" | "error" | "debug";
829
+ args?: unknown[] | undefined;
830
+ }>, "many">;
831
+ readonly network: z.ZodArray<z.ZodObject<{
832
+ /** Spine id linking this call to its backend request. */
833
+ traceId: z.ZodString;
834
+ method: z.ZodString;
835
+ url: z.ZodString;
836
+ /** HTTP status; null if the request never completed. */
837
+ status: z.ZodNullable<z.ZodNumber>;
838
+ /** Request body as captured (serialized; null if none). */
839
+ reqBody: z.ZodNullable<z.ZodUnknown>;
840
+ /** Response body as captured (serialized; null if none). */
841
+ resBody: z.ZodNullable<z.ZodUnknown>;
842
+ startedAt: z.ZodString;
843
+ /** Round-trip duration in milliseconds; null if unknown. */
844
+ durationMs: z.ZodNullable<z.ZodNumber>;
845
+ }, "strip", z.ZodTypeAny, {
846
+ status: number | null;
847
+ traceId: string;
848
+ method: string;
849
+ url: string;
850
+ startedAt: string;
851
+ durationMs: number | null;
852
+ reqBody?: unknown;
853
+ resBody?: unknown;
854
+ }, {
855
+ status: number | null;
856
+ traceId: string;
857
+ method: string;
858
+ url: string;
859
+ startedAt: string;
860
+ durationMs: number | null;
861
+ reqBody?: unknown;
862
+ resBody?: unknown;
863
+ }>, "many">;
864
+ readonly clientState: z.ZodRecord<z.ZodString, z.ZodUnknown>;
865
+ readonly storage: z.ZodObject<{
866
+ local: z.ZodRecord<z.ZodString, z.ZodString>;
867
+ session: z.ZodRecord<z.ZodString, z.ZodString>;
868
+ cookies: z.ZodRecord<z.ZodString, z.ZodString>;
869
+ }, "strip", z.ZodTypeAny, {
870
+ local: Record<string, string>;
871
+ session: Record<string, string>;
872
+ cookies: Record<string, string>;
873
+ }, {
874
+ local: Record<string, string>;
875
+ session: Record<string, string>;
876
+ cookies: Record<string, string>;
877
+ }>;
878
+ readonly dom: z.ZodObject<{
879
+ /** Serialized DOM (full document or relevant subtree). Capped (~8MB) so a
880
+ * crafted bundle can't bloat a D1 row / OOM the worker on intake. */
881
+ html: z.ZodString;
882
+ /** Selector of the reported element within `html`. */
883
+ targetSelector: z.ZodNullable<z.ZodString>;
884
+ /** Viewport size at capture time. */
885
+ viewport: z.ZodObject<{
886
+ width: z.ZodNumber;
887
+ height: z.ZodNumber;
888
+ }, "strip", z.ZodTypeAny, {
889
+ width: number;
890
+ height: number;
891
+ }, {
892
+ width: number;
893
+ height: number;
894
+ }>;
895
+ }, "strip", z.ZodTypeAny, {
896
+ html: string;
897
+ targetSelector: string | null;
898
+ viewport: {
899
+ width: number;
900
+ height: number;
901
+ };
902
+ }, {
903
+ html: string;
904
+ targetSelector: string | null;
905
+ viewport: {
906
+ width: number;
907
+ height: number;
908
+ };
909
+ }>;
910
+ readonly trace: z.ZodObject<{
911
+ /** Backend capture session id for the reported interaction. */
912
+ sessionId: z.ZodString;
913
+ requests: z.ZodArray<z.ZodObject<{
914
+ /** Spine id - matches the frontend NetworkEntry that triggered this request. */
915
+ traceId: z.ZodString;
916
+ /** Name/identity of the handler that ran. */
917
+ handler: z.ZodString;
918
+ /** Provenance of the handler ("file:line:col"). */
919
+ src: z.ZodNullable<z.ZodString>;
920
+ method: z.ZodString;
921
+ url: z.ZodString;
922
+ status: z.ZodNullable<z.ZodNumber>;
923
+ /** Queries issued during this request, in order. */
924
+ queries: z.ZodArray<z.ZodObject<{
925
+ /** SQL or query string as executed. */
926
+ sql: z.ZodString;
927
+ /** Bound parameters, serialized. */
928
+ params: z.ZodOptional<z.ZodArray<z.ZodUnknown, "many">>;
929
+ /** Execution time in milliseconds. */
930
+ durationMs: z.ZodNullable<z.ZodNumber>;
931
+ /** Provenance of the call site issuing the query ("file:line:col"). */
932
+ src: z.ZodNullable<z.ZodString>;
933
+ }, "strip", z.ZodTypeAny, {
934
+ src: string | null;
935
+ durationMs: number | null;
936
+ sql: string;
937
+ params?: unknown[] | undefined;
938
+ }, {
939
+ src: string | null;
940
+ durationMs: number | null;
941
+ sql: string;
942
+ params?: unknown[] | undefined;
943
+ }>, "many">;
944
+ /** Serialized error if the handler threw; null on success. */
945
+ threw: z.ZodNullable<z.ZodUnknown>;
946
+ durationMs: z.ZodNullable<z.ZodNumber>;
947
+ }, "strip", z.ZodTypeAny, {
948
+ src: string | null;
949
+ status: number | null;
950
+ traceId: string;
951
+ method: string;
952
+ url: string;
953
+ durationMs: number | null;
954
+ handler: string;
955
+ queries: {
956
+ src: string | null;
957
+ durationMs: number | null;
958
+ sql: string;
959
+ params?: unknown[] | undefined;
960
+ }[];
961
+ threw?: unknown;
962
+ }, {
963
+ src: string | null;
964
+ status: number | null;
965
+ traceId: string;
966
+ method: string;
967
+ url: string;
968
+ durationMs: number | null;
969
+ handler: string;
970
+ queries: {
971
+ src: string | null;
972
+ durationMs: number | null;
973
+ sql: string;
974
+ params?: unknown[] | undefined;
975
+ }[];
976
+ threw?: unknown;
977
+ }>, "many">;
978
+ }, "strip", z.ZodTypeAny, {
979
+ sessionId: string;
980
+ requests: {
981
+ src: string | null;
982
+ status: number | null;
983
+ traceId: string;
984
+ method: string;
985
+ url: string;
986
+ durationMs: number | null;
987
+ handler: string;
988
+ queries: {
989
+ src: string | null;
990
+ durationMs: number | null;
991
+ sql: string;
992
+ params?: unknown[] | undefined;
993
+ }[];
994
+ threw?: unknown;
995
+ }[];
996
+ }, {
997
+ sessionId: string;
998
+ requests: {
999
+ src: string | null;
1000
+ status: number | null;
1001
+ traceId: string;
1002
+ method: string;
1003
+ url: string;
1004
+ durationMs: number | null;
1005
+ handler: string;
1006
+ queries: {
1007
+ src: string | null;
1008
+ durationMs: number | null;
1009
+ sql: string;
1010
+ params?: unknown[] | undefined;
1011
+ }[];
1012
+ threw?: unknown;
1013
+ }[];
1014
+ }>;
1015
+ readonly screenshot: z.ZodObject<{
1016
+ /** A `data:` URL holding the base64-encoded image (e.g. `data:image/jpeg;base64,...`).
1017
+ * Scheme-locked to an inline image (a remote http(s) src would turn opening
1018
+ * the artifact into an outbound request to an attacker host) and size-capped
1019
+ * (~12MB) so it can't be used as a DoS payload. */
1020
+ dataUrl: z.ZodString;
1021
+ /** Pixel width of the rendered image. */
1022
+ width: z.ZodNumber;
1023
+ /** Pixel height of the rendered image. */
1024
+ height: z.ZodNumber;
1025
+ /** Encoding of the image embedded in `dataUrl`. */
1026
+ format: z.ZodEnum<["jpeg", "png"]>;
1027
+ }, "strip", z.ZodTypeAny, {
1028
+ width: number;
1029
+ height: number;
1030
+ dataUrl: string;
1031
+ format: "jpeg" | "png";
1032
+ }, {
1033
+ width: number;
1034
+ height: number;
1035
+ dataUrl: string;
1036
+ format: "jpeg" | "png";
1037
+ }>;
1038
+ };
1039
+ /** Type-level map from artifact name to its decoded payload type. */
1040
+ export interface ArtifactPayloadMap {
1041
+ console: ConsoleArtifact;
1042
+ network: NetworkArtifact;
1043
+ clientState: ClientStateArtifact;
1044
+ storage: StorageArtifact;
1045
+ dom: DomArtifact;
1046
+ trace: TraceArtifact;
1047
+ screenshot: ScreenshotArtifact;
1048
+ }
1049
+ /** Union of all artifact payloads (the body served behind any ref). */
1050
+ export type ArtifactPayload = ArtifactPayloadMap[ArtifactName];
1051
+ /**
1052
+ * What the `<ReportButton>` produces and POSTs to create a ticket: the head's
1053
+ * report core plus every captured artifact payload inline. The server splits this
1054
+ * into the persisted head (with a built index) and the artifact rows.
1055
+ */
1056
+ export declare const ReportBundleSchema: z.ZodObject<{
1057
+ reporter: z.ZodString;
1058
+ /**
1059
+ * Which project/tenant this report belongs to (the SaaS seam). The widget is
1060
+ * configured with a `projectKey` and stamps it here; the server persists it onto
1061
+ * the {@link TicketHead}. Null when the widget is unkeyed (single-tenant); making
1062
+ * multi-tenancy real is a later flip, not a schema rewrite.
1063
+ */
1064
+ projectKey: z.ZodNullable<z.ZodString>;
1065
+ report: z.ZodObject<{
1066
+ /** Free-text description from the reporter. Capped so a single report can't be
1067
+ * an unbounded blob (intake has no other size gate on this field). */
1068
+ message: z.ZodString;
1069
+ /** Report category (e.g. "bug", "visual", "crash"). Free-form in v0. */
1070
+ kind: z.ZodString;
1071
+ /** App route the report was fired from (e.g. "/cart"). */
1072
+ route: z.ZodString;
1073
+ /** The clicked element, resolved to selector + provenance + component. */
1074
+ target: z.ZodObject<{
1075
+ /** CSS selector identifying the clicked element in the live DOM. */
1076
+ selector: z.ZodNullable<z.ZodString>;
1077
+ /** Build-time source provenance of the element ("file:line:col"). */
1078
+ src: z.ZodNullable<z.ZodString>;
1079
+ /** Display name of the React component that owns the element. */
1080
+ component: z.ZodNullable<z.ZodString>;
1081
+ }, "strip", z.ZodTypeAny, {
1082
+ selector: string | null;
1083
+ src: string | null;
1084
+ component: string | null;
1085
+ }, {
1086
+ selector: string | null;
1087
+ src: string | null;
1088
+ component: string | null;
1089
+ }>;
1090
+ }, "strip", z.ZodTypeAny, {
1091
+ message: string;
1092
+ kind: string;
1093
+ route: string;
1094
+ target: {
1095
+ selector: string | null;
1096
+ src: string | null;
1097
+ component: string | null;
1098
+ };
1099
+ }, {
1100
+ message: string;
1101
+ kind: string;
1102
+ route: string;
1103
+ target: {
1104
+ selector: string | null;
1105
+ src: string | null;
1106
+ component: string | null;
1107
+ };
1108
+ }>;
1109
+ artifacts: z.ZodObject<{
1110
+ console: z.ZodOptional<z.ZodOptional<z.ZodArray<z.ZodObject<{
1111
+ level: z.ZodEnum<["log", "info", "warn", "error", "debug"]>;
1112
+ /** Already-formatted message text. */
1113
+ message: z.ZodString;
1114
+ /** Structured args as captured (best-effort serialized). */
1115
+ args: z.ZodOptional<z.ZodArray<z.ZodUnknown, "many">>;
1116
+ at: z.ZodString;
1117
+ }, "strip", z.ZodTypeAny, {
1118
+ message: string;
1119
+ at: string;
1120
+ level: "log" | "info" | "warn" | "error" | "debug";
1121
+ args?: unknown[] | undefined;
1122
+ }, {
1123
+ message: string;
1124
+ at: string;
1125
+ level: "log" | "info" | "warn" | "error" | "debug";
1126
+ args?: unknown[] | undefined;
1127
+ }>, "many">>>;
1128
+ network: z.ZodOptional<z.ZodOptional<z.ZodArray<z.ZodObject<{
1129
+ /** Spine id linking this call to its backend request. */
1130
+ traceId: z.ZodString;
1131
+ method: z.ZodString;
1132
+ url: z.ZodString;
1133
+ /** HTTP status; null if the request never completed. */
1134
+ status: z.ZodNullable<z.ZodNumber>;
1135
+ /** Request body as captured (serialized; null if none). */
1136
+ reqBody: z.ZodNullable<z.ZodUnknown>;
1137
+ /** Response body as captured (serialized; null if none). */
1138
+ resBody: z.ZodNullable<z.ZodUnknown>;
1139
+ startedAt: z.ZodString;
1140
+ /** Round-trip duration in milliseconds; null if unknown. */
1141
+ durationMs: z.ZodNullable<z.ZodNumber>;
1142
+ }, "strip", z.ZodTypeAny, {
1143
+ status: number | null;
1144
+ traceId: string;
1145
+ method: string;
1146
+ url: string;
1147
+ startedAt: string;
1148
+ durationMs: number | null;
1149
+ reqBody?: unknown;
1150
+ resBody?: unknown;
1151
+ }, {
1152
+ status: number | null;
1153
+ traceId: string;
1154
+ method: string;
1155
+ url: string;
1156
+ startedAt: string;
1157
+ durationMs: number | null;
1158
+ reqBody?: unknown;
1159
+ resBody?: unknown;
1160
+ }>, "many">>>;
1161
+ clientState: z.ZodOptional<z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
1162
+ storage: z.ZodOptional<z.ZodOptional<z.ZodObject<{
1163
+ local: z.ZodRecord<z.ZodString, z.ZodString>;
1164
+ session: z.ZodRecord<z.ZodString, z.ZodString>;
1165
+ cookies: z.ZodRecord<z.ZodString, z.ZodString>;
1166
+ }, "strip", z.ZodTypeAny, {
1167
+ local: Record<string, string>;
1168
+ session: Record<string, string>;
1169
+ cookies: Record<string, string>;
1170
+ }, {
1171
+ local: Record<string, string>;
1172
+ session: Record<string, string>;
1173
+ cookies: Record<string, string>;
1174
+ }>>>;
1175
+ dom: z.ZodOptional<z.ZodOptional<z.ZodObject<{
1176
+ /** Serialized DOM (full document or relevant subtree). Capped (~8MB) so a
1177
+ * crafted bundle can't bloat a D1 row / OOM the worker on intake. */
1178
+ html: z.ZodString;
1179
+ /** Selector of the reported element within `html`. */
1180
+ targetSelector: z.ZodNullable<z.ZodString>;
1181
+ /** Viewport size at capture time. */
1182
+ viewport: z.ZodObject<{
1183
+ width: z.ZodNumber;
1184
+ height: z.ZodNumber;
1185
+ }, "strip", z.ZodTypeAny, {
1186
+ width: number;
1187
+ height: number;
1188
+ }, {
1189
+ width: number;
1190
+ height: number;
1191
+ }>;
1192
+ }, "strip", z.ZodTypeAny, {
1193
+ html: string;
1194
+ targetSelector: string | null;
1195
+ viewport: {
1196
+ width: number;
1197
+ height: number;
1198
+ };
1199
+ }, {
1200
+ html: string;
1201
+ targetSelector: string | null;
1202
+ viewport: {
1203
+ width: number;
1204
+ height: number;
1205
+ };
1206
+ }>>>;
1207
+ trace: z.ZodOptional<z.ZodOptional<z.ZodObject<{
1208
+ /** Backend capture session id for the reported interaction. */
1209
+ sessionId: z.ZodString;
1210
+ requests: z.ZodArray<z.ZodObject<{
1211
+ /** Spine id - matches the frontend NetworkEntry that triggered this request. */
1212
+ traceId: z.ZodString;
1213
+ /** Name/identity of the handler that ran. */
1214
+ handler: z.ZodString;
1215
+ /** Provenance of the handler ("file:line:col"). */
1216
+ src: z.ZodNullable<z.ZodString>;
1217
+ method: z.ZodString;
1218
+ url: z.ZodString;
1219
+ status: z.ZodNullable<z.ZodNumber>;
1220
+ /** Queries issued during this request, in order. */
1221
+ queries: z.ZodArray<z.ZodObject<{
1222
+ /** SQL or query string as executed. */
1223
+ sql: z.ZodString;
1224
+ /** Bound parameters, serialized. */
1225
+ params: z.ZodOptional<z.ZodArray<z.ZodUnknown, "many">>;
1226
+ /** Execution time in milliseconds. */
1227
+ durationMs: z.ZodNullable<z.ZodNumber>;
1228
+ /** Provenance of the call site issuing the query ("file:line:col"). */
1229
+ src: z.ZodNullable<z.ZodString>;
1230
+ }, "strip", z.ZodTypeAny, {
1231
+ src: string | null;
1232
+ durationMs: number | null;
1233
+ sql: string;
1234
+ params?: unknown[] | undefined;
1235
+ }, {
1236
+ src: string | null;
1237
+ durationMs: number | null;
1238
+ sql: string;
1239
+ params?: unknown[] | undefined;
1240
+ }>, "many">;
1241
+ /** Serialized error if the handler threw; null on success. */
1242
+ threw: z.ZodNullable<z.ZodUnknown>;
1243
+ durationMs: z.ZodNullable<z.ZodNumber>;
1244
+ }, "strip", z.ZodTypeAny, {
1245
+ src: string | null;
1246
+ status: number | null;
1247
+ traceId: string;
1248
+ method: string;
1249
+ url: string;
1250
+ durationMs: number | null;
1251
+ handler: string;
1252
+ queries: {
1253
+ src: string | null;
1254
+ durationMs: number | null;
1255
+ sql: string;
1256
+ params?: unknown[] | undefined;
1257
+ }[];
1258
+ threw?: unknown;
1259
+ }, {
1260
+ src: string | null;
1261
+ status: number | null;
1262
+ traceId: string;
1263
+ method: string;
1264
+ url: string;
1265
+ durationMs: number | null;
1266
+ handler: string;
1267
+ queries: {
1268
+ src: string | null;
1269
+ durationMs: number | null;
1270
+ sql: string;
1271
+ params?: unknown[] | undefined;
1272
+ }[];
1273
+ threw?: unknown;
1274
+ }>, "many">;
1275
+ }, "strip", z.ZodTypeAny, {
1276
+ sessionId: string;
1277
+ requests: {
1278
+ src: string | null;
1279
+ status: number | null;
1280
+ traceId: string;
1281
+ method: string;
1282
+ url: string;
1283
+ durationMs: number | null;
1284
+ handler: string;
1285
+ queries: {
1286
+ src: string | null;
1287
+ durationMs: number | null;
1288
+ sql: string;
1289
+ params?: unknown[] | undefined;
1290
+ }[];
1291
+ threw?: unknown;
1292
+ }[];
1293
+ }, {
1294
+ sessionId: string;
1295
+ requests: {
1296
+ src: string | null;
1297
+ status: number | null;
1298
+ traceId: string;
1299
+ method: string;
1300
+ url: string;
1301
+ durationMs: number | null;
1302
+ handler: string;
1303
+ queries: {
1304
+ src: string | null;
1305
+ durationMs: number | null;
1306
+ sql: string;
1307
+ params?: unknown[] | undefined;
1308
+ }[];
1309
+ threw?: unknown;
1310
+ }[];
1311
+ }>>>;
1312
+ screenshot: z.ZodOptional<z.ZodOptional<z.ZodObject<{
1313
+ /** A `data:` URL holding the base64-encoded image (e.g. `data:image/jpeg;base64,...`).
1314
+ * Scheme-locked to an inline image (a remote http(s) src would turn opening
1315
+ * the artifact into an outbound request to an attacker host) and size-capped
1316
+ * (~12MB) so it can't be used as a DoS payload. */
1317
+ dataUrl: z.ZodString;
1318
+ /** Pixel width of the rendered image. */
1319
+ width: z.ZodNumber;
1320
+ /** Pixel height of the rendered image. */
1321
+ height: z.ZodNumber;
1322
+ /** Encoding of the image embedded in `dataUrl`. */
1323
+ format: z.ZodEnum<["jpeg", "png"]>;
1324
+ }, "strip", z.ZodTypeAny, {
1325
+ width: number;
1326
+ height: number;
1327
+ dataUrl: string;
1328
+ format: "jpeg" | "png";
1329
+ }, {
1330
+ width: number;
1331
+ height: number;
1332
+ dataUrl: string;
1333
+ format: "jpeg" | "png";
1334
+ }>>>;
1335
+ }, "strip", z.ZodTypeAny, {
1336
+ console?: {
1337
+ message: string;
1338
+ at: string;
1339
+ level: "log" | "info" | "warn" | "error" | "debug";
1340
+ args?: unknown[] | undefined;
1341
+ }[] | undefined;
1342
+ network?: {
1343
+ status: number | null;
1344
+ traceId: string;
1345
+ method: string;
1346
+ url: string;
1347
+ startedAt: string;
1348
+ durationMs: number | null;
1349
+ reqBody?: unknown;
1350
+ resBody?: unknown;
1351
+ }[] | undefined;
1352
+ clientState?: Record<string, unknown> | undefined;
1353
+ storage?: {
1354
+ local: Record<string, string>;
1355
+ session: Record<string, string>;
1356
+ cookies: Record<string, string>;
1357
+ } | undefined;
1358
+ dom?: {
1359
+ html: string;
1360
+ targetSelector: string | null;
1361
+ viewport: {
1362
+ width: number;
1363
+ height: number;
1364
+ };
1365
+ } | undefined;
1366
+ trace?: {
1367
+ sessionId: string;
1368
+ requests: {
1369
+ src: string | null;
1370
+ status: number | null;
1371
+ traceId: string;
1372
+ method: string;
1373
+ url: string;
1374
+ durationMs: number | null;
1375
+ handler: string;
1376
+ queries: {
1377
+ src: string | null;
1378
+ durationMs: number | null;
1379
+ sql: string;
1380
+ params?: unknown[] | undefined;
1381
+ }[];
1382
+ threw?: unknown;
1383
+ }[];
1384
+ } | undefined;
1385
+ screenshot?: {
1386
+ width: number;
1387
+ height: number;
1388
+ dataUrl: string;
1389
+ format: "jpeg" | "png";
1390
+ } | undefined;
1391
+ }, {
1392
+ console?: {
1393
+ message: string;
1394
+ at: string;
1395
+ level: "log" | "info" | "warn" | "error" | "debug";
1396
+ args?: unknown[] | undefined;
1397
+ }[] | undefined;
1398
+ network?: {
1399
+ status: number | null;
1400
+ traceId: string;
1401
+ method: string;
1402
+ url: string;
1403
+ startedAt: string;
1404
+ durationMs: number | null;
1405
+ reqBody?: unknown;
1406
+ resBody?: unknown;
1407
+ }[] | undefined;
1408
+ clientState?: Record<string, unknown> | undefined;
1409
+ storage?: {
1410
+ local: Record<string, string>;
1411
+ session: Record<string, string>;
1412
+ cookies: Record<string, string>;
1413
+ } | undefined;
1414
+ dom?: {
1415
+ html: string;
1416
+ targetSelector: string | null;
1417
+ viewport: {
1418
+ width: number;
1419
+ height: number;
1420
+ };
1421
+ } | undefined;
1422
+ trace?: {
1423
+ sessionId: string;
1424
+ requests: {
1425
+ src: string | null;
1426
+ status: number | null;
1427
+ traceId: string;
1428
+ method: string;
1429
+ url: string;
1430
+ durationMs: number | null;
1431
+ handler: string;
1432
+ queries: {
1433
+ src: string | null;
1434
+ durationMs: number | null;
1435
+ sql: string;
1436
+ params?: unknown[] | undefined;
1437
+ }[];
1438
+ threw?: unknown;
1439
+ }[];
1440
+ } | undefined;
1441
+ screenshot?: {
1442
+ width: number;
1443
+ height: number;
1444
+ dataUrl: string;
1445
+ format: "jpeg" | "png";
1446
+ } | undefined;
1447
+ }>;
1448
+ }, "strip", z.ZodTypeAny, {
1449
+ reporter: string;
1450
+ report: {
1451
+ message: string;
1452
+ kind: string;
1453
+ route: string;
1454
+ target: {
1455
+ selector: string | null;
1456
+ src: string | null;
1457
+ component: string | null;
1458
+ };
1459
+ };
1460
+ artifacts: {
1461
+ console?: {
1462
+ message: string;
1463
+ at: string;
1464
+ level: "log" | "info" | "warn" | "error" | "debug";
1465
+ args?: unknown[] | undefined;
1466
+ }[] | undefined;
1467
+ network?: {
1468
+ status: number | null;
1469
+ traceId: string;
1470
+ method: string;
1471
+ url: string;
1472
+ startedAt: string;
1473
+ durationMs: number | null;
1474
+ reqBody?: unknown;
1475
+ resBody?: unknown;
1476
+ }[] | undefined;
1477
+ clientState?: Record<string, unknown> | undefined;
1478
+ storage?: {
1479
+ local: Record<string, string>;
1480
+ session: Record<string, string>;
1481
+ cookies: Record<string, string>;
1482
+ } | undefined;
1483
+ dom?: {
1484
+ html: string;
1485
+ targetSelector: string | null;
1486
+ viewport: {
1487
+ width: number;
1488
+ height: number;
1489
+ };
1490
+ } | undefined;
1491
+ trace?: {
1492
+ sessionId: string;
1493
+ requests: {
1494
+ src: string | null;
1495
+ status: number | null;
1496
+ traceId: string;
1497
+ method: string;
1498
+ url: string;
1499
+ durationMs: number | null;
1500
+ handler: string;
1501
+ queries: {
1502
+ src: string | null;
1503
+ durationMs: number | null;
1504
+ sql: string;
1505
+ params?: unknown[] | undefined;
1506
+ }[];
1507
+ threw?: unknown;
1508
+ }[];
1509
+ } | undefined;
1510
+ screenshot?: {
1511
+ width: number;
1512
+ height: number;
1513
+ dataUrl: string;
1514
+ format: "jpeg" | "png";
1515
+ } | undefined;
1516
+ };
1517
+ projectKey: string | null;
1518
+ }, {
1519
+ reporter: string;
1520
+ report: {
1521
+ message: string;
1522
+ kind: string;
1523
+ route: string;
1524
+ target: {
1525
+ selector: string | null;
1526
+ src: string | null;
1527
+ component: string | null;
1528
+ };
1529
+ };
1530
+ artifacts: {
1531
+ console?: {
1532
+ message: string;
1533
+ at: string;
1534
+ level: "log" | "info" | "warn" | "error" | "debug";
1535
+ args?: unknown[] | undefined;
1536
+ }[] | undefined;
1537
+ network?: {
1538
+ status: number | null;
1539
+ traceId: string;
1540
+ method: string;
1541
+ url: string;
1542
+ startedAt: string;
1543
+ durationMs: number | null;
1544
+ reqBody?: unknown;
1545
+ resBody?: unknown;
1546
+ }[] | undefined;
1547
+ clientState?: Record<string, unknown> | undefined;
1548
+ storage?: {
1549
+ local: Record<string, string>;
1550
+ session: Record<string, string>;
1551
+ cookies: Record<string, string>;
1552
+ } | undefined;
1553
+ dom?: {
1554
+ html: string;
1555
+ targetSelector: string | null;
1556
+ viewport: {
1557
+ width: number;
1558
+ height: number;
1559
+ };
1560
+ } | undefined;
1561
+ trace?: {
1562
+ sessionId: string;
1563
+ requests: {
1564
+ src: string | null;
1565
+ status: number | null;
1566
+ traceId: string;
1567
+ method: string;
1568
+ url: string;
1569
+ durationMs: number | null;
1570
+ handler: string;
1571
+ queries: {
1572
+ src: string | null;
1573
+ durationMs: number | null;
1574
+ sql: string;
1575
+ params?: unknown[] | undefined;
1576
+ }[];
1577
+ threw?: unknown;
1578
+ }[];
1579
+ } | undefined;
1580
+ screenshot?: {
1581
+ width: number;
1582
+ height: number;
1583
+ dataUrl: string;
1584
+ format: "jpeg" | "png";
1585
+ } | undefined;
1586
+ };
1587
+ projectKey: string | null;
1588
+ }>;
1589
+ export type ReportBundle = z.infer<typeof ReportBundleSchema>;
1590
+ //# sourceMappingURL=index.d.ts.map