@40rty/ams-cli 0.0.0-stage → 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.
package/dist/wire.js ADDED
@@ -0,0 +1,1485 @@
1
+ // ../spacestation/src/layout/layout.ts
2
+ import { z } from "zod";
3
+ var JSON_PATCH_OPS = ["add", "remove", "replace", "move"];
4
+ var UIElementSchema = z.object({
5
+ type: z.string(),
6
+ props: z.record(z.unknown()).default({}),
7
+ children: z.array(z.string()).optional(),
8
+ experience: z.string().optional(),
9
+ __turnId: z.string().optional()
10
+ });
11
+ var SpecSchema = z.object({
12
+ root: z.string(),
13
+ aliases: z.record(z.string()).optional(),
14
+ elements: z.record(UIElementSchema),
15
+ state: z.record(z.unknown()).optional()
16
+ });
17
+ var JsonPatchOpSchema = z.object({
18
+ op: z.enum(JSON_PATCH_OPS),
19
+ path: z.string(),
20
+ value: z.unknown().optional(),
21
+ from: z.string().optional()
22
+ });
23
+ var AgentOutputSchema = z.object({
24
+ layout: SpecSchema.optional(),
25
+ patches: z.array(JsonPatchOpSchema).optional()
26
+ });
27
+
28
+ // ../spacestation/src/layout/patch.ts
29
+ import { z as z2 } from "zod";
30
+ var PatchSchema = z2.union([
31
+ z2.object({
32
+ id: z2.string().min(1),
33
+ op: z2.literal("set"),
34
+ element: UIElementSchema
35
+ }),
36
+ z2.object({
37
+ id: z2.string().min(1),
38
+ op: z2.literal("append"),
39
+ field: z2.string().min(1),
40
+ value: z2.union([z2.string(), z2.array(z2.unknown())])
41
+ }),
42
+ z2.object({
43
+ id: z2.string().min(1),
44
+ op: z2.literal("remove")
45
+ })
46
+ ]);
47
+
48
+ // ../spacestation/src/layout/reserved-ids.ts
49
+ var RESERVED_IDS = {
50
+ prose: "prose",
51
+ followups: "followups"
52
+ };
53
+ var RESERVED_ID_SET = new Set(
54
+ Object.values(RESERVED_IDS)
55
+ );
56
+
57
+ // ../spacestation/src/layout/page.ts
58
+ import { z as z5 } from "zod";
59
+
60
+ // ../spacestation/src/shell/shell.ts
61
+ import { z as z4 } from "zod";
62
+
63
+ // ../spacestation/src/signal/agent-signals.ts
64
+ import { z as z3 } from "zod";
65
+ var ToolCallHintSchema = z3.object({
66
+ name: z3.string().min(1),
67
+ args: z3.record(z3.unknown())
68
+ });
69
+ var AgentSignalSchema = z3.object({
70
+ id: z3.string().optional(),
71
+ label: z3.string().optional(),
72
+ type: z3.string(),
73
+ payload: z3.record(z3.unknown()).optional(),
74
+ icon: z3.string().optional(),
75
+ expectedTool: ToolCallHintSchema.optional()
76
+ });
77
+ var MAX_VISITOR_PROMPT_CHARS = 2e3;
78
+ var InteractionSignalSchema = z3.object({
79
+ type: z3.string().min(1).max(64),
80
+ timestamp: z3.number().optional(),
81
+ payload: z3.object({ text: z3.string().max(MAX_VISITOR_PROMPT_CHARS).optional() }).catchall(z3.unknown()).optional(),
82
+ causedBy: z3.string().max(200).optional()
83
+ });
84
+ var SuggestionActionStrictSchema = z3.object({
85
+ id: z3.string(),
86
+ label: z3.string(),
87
+ type: z3.string(),
88
+ payload: z3.record(z3.unknown()),
89
+ icon: z3.string().optional(),
90
+ expectedTool: ToolCallHintSchema.optional()
91
+ });
92
+ var SuggestionActionsSchema = z3.object({
93
+ type: z3.literal("suggestion_cards"),
94
+ actions: z3.array(SuggestionActionStrictSchema),
95
+ heading: z3.string().optional()
96
+ });
97
+
98
+ // ../spacestation/src/shell/shell.ts
99
+ var ShellMenuItemSchema = z4.object({
100
+ label: z4.string(),
101
+ action: AgentSignalSchema,
102
+ /** Optional secondary label shown beside the main label (e.g. "→"). */
103
+ hint: z4.string().optional(),
104
+ /** Optional icon hint for renderers that show menu icons. */
105
+ icon: z4.string().optional()
106
+ });
107
+ var ShellConfigSchema = z4.record(z4.unknown());
108
+
109
+ // ../spacestation/src/layout/page.ts
110
+ var pageKindSchemas = /* @__PURE__ */ new Map();
111
+ function registerPageKindSchema(kind, schema) {
112
+ pageKindSchemas.set(kind, schema);
113
+ }
114
+ registerPageKindSchema("home", z5.object({ kind: z5.literal("home") }));
115
+ registerPageKindSchema(
116
+ "message",
117
+ z5.object({
118
+ kind: z5.literal("message"),
119
+ messageIndex: z5.number().int().nonnegative(),
120
+ messageId: z5.string().min(1).optional()
121
+ })
122
+ );
123
+ registerPageKindSchema(
124
+ "answer",
125
+ z5.object({
126
+ kind: z5.literal("answer"),
127
+ messageIndex: z5.number().int().nonnegative(),
128
+ messageId: z5.string().min(1).optional()
129
+ })
130
+ );
131
+ function lookupPageKindSchema(val) {
132
+ if (typeof val !== "object" || val === null || Array.isArray(val)) return null;
133
+ const kind = Reflect.get(val, "kind");
134
+ if (typeof kind !== "string" || kind.length === 0) return null;
135
+ const schema = pageKindSchemas.get(kind);
136
+ return schema === void 0 ? null : schema;
137
+ }
138
+ var PageSchema = z5.custom((val) => {
139
+ const schema = lookupPageKindSchema(val);
140
+ if (schema === null) return false;
141
+ return schema.safeParse(val).success;
142
+ }, { message: "Not a valid Page for any registered page kind" }).transform((val) => {
143
+ const schema = lookupPageKindSchema(val);
144
+ if (schema === null) return val;
145
+ const parsed = schema.safeParse(val);
146
+ return parsed.success ? parsed.data : val;
147
+ });
148
+ var NavigatePayloadSchema = z5.object({
149
+ page: PageSchema
150
+ });
151
+ var ViewportFocusSchema = z5.object({
152
+ visibleElementIds: z5.array(z5.string()),
153
+ topElementId: z5.string().min(1).optional(),
154
+ nearBottom: z5.boolean().optional()
155
+ });
156
+ var ViewSchema = z5.object({
157
+ page: PageSchema,
158
+ layout: SpecSchema,
159
+ shell: ShellConfigSchema
160
+ });
161
+
162
+ // ../spacestation/src/commerce/page-kinds.ts
163
+ import { z as z6 } from "zod";
164
+ registerPageKindSchema(
165
+ "product",
166
+ z6.object({
167
+ kind: z6.literal("product"),
168
+ id: z6.string().min(1),
169
+ morph: z6.boolean().optional()
170
+ })
171
+ );
172
+ registerPageKindSchema(
173
+ "collection",
174
+ z6.object({
175
+ kind: z6.literal("collection"),
176
+ handle: z6.string().min(1),
177
+ products: z6.array(z6.string()).optional(),
178
+ title: z6.string().optional()
179
+ })
180
+ );
181
+ registerPageKindSchema(
182
+ "search",
183
+ z6.object({
184
+ kind: z6.literal("search"),
185
+ query: z6.string(),
186
+ products: z6.array(z6.string()).optional()
187
+ })
188
+ );
189
+ registerPageKindSchema("article", z6.object({ kind: z6.literal("article"), id: z6.string().min(1) }));
190
+ registerPageKindSchema("cms", z6.object({ kind: z6.literal("cms"), handle: z6.string().min(1) }));
191
+
192
+ // ../spacestation/src/commerce/cart-state.ts
193
+ import { z as z7 } from "zod";
194
+ var CartSnapshotLineSchema = z7.object({
195
+ productId: z7.string().min(1),
196
+ title: z7.string(),
197
+ selection: z7.string().min(1).optional(),
198
+ quantity: z7.number().int().positive()
199
+ });
200
+ var CartSnapshotSchema = z7.object({
201
+ lines: z7.array(CartSnapshotLineSchema)
202
+ });
203
+ var WishlistSnapshotSchema = z7.object({
204
+ productIds: z7.array(z7.string().min(1))
205
+ });
206
+
207
+ // ../spacestation/src/commerce/cart-add-signal.ts
208
+ import { z as z10 } from "zod";
209
+
210
+ // ../spacestation/src/analytics/ecommerce/events.ts
211
+ import { z as z8 } from "zod";
212
+
213
+ // ../spacestation/src/analytics/kind.ts
214
+ function defineEventKind(name, trust, schema, ...guard) {
215
+ void guard;
216
+ return { name, trust, schema };
217
+ }
218
+
219
+ // ../spacestation/src/analytics/ecommerce/events.ts
220
+ var CART_ORIGINS = ["visitor", "agent", "webmcp"];
221
+ var CHECKOUT_ORIGINS = ["visitor", "agent"];
222
+ var CHECKOUT_OUTCOMES = [
223
+ /** The agent committed an exit that fires when the turn lands. */
224
+ "armed",
225
+ /** Refused before arming, or disarmed. See `refusal` for which. */
226
+ "unavailable",
227
+ /** This tab is leaving for the store's checkout page. */
228
+ "redirected",
229
+ /** Checkout opened in a new tab (embedded contexts). */
230
+ "new-tab",
231
+ /** The browser refused the tab — they did NOT reach checkout. */
232
+ "blocked",
233
+ /** No checkout url on the cart by the time it fired. */
234
+ "no-url"
235
+ ];
236
+ var CHECKOUT_REFUSALS = [
237
+ /** The agent refused: nothing in the cart. */
238
+ "empty-cart",
239
+ /** The agent refused: the cart carries no checkout link. */
240
+ "no-link",
241
+ /** The visitor cancelled the turn before the armed exit fired. */
242
+ "cancelled-turn"
243
+ ];
244
+ var CART_SETTLE_TRIGGERS = [
245
+ /** The cart settled after a line or discount mutation. */
246
+ "mutation",
247
+ /**
248
+ * A cart that already existed was restored into a NEW session and never
249
+ * touched. Without this edge, "cart subtotal at end of session" silently
250
+ * meant "among sessions that MODIFIED the cart" — blind to exactly the
251
+ * returning visitors it should count, because a cart id survives in
252
+ * localStorage across sessions.
253
+ */
254
+ "restore"
255
+ ];
256
+ var CART_LINE_ADDED = defineEventKind(
257
+ "commerce.cart_line_added",
258
+ "client",
259
+ z8.object({
260
+ /**
261
+ * ONE visitor/agent INTENT, minted once per intent and shared by every
262
+ * `addLine` call that intent produces. This is why metric #5a is
263
+ * `count(distinct (session_id, attempt_id))` and never `count(*)`:
264
+ * `cart-line-handlers.ts:63` is a fast path inside a `try` whose catch at
265
+ * `:76` falls through to a SECOND `addLine` at `:96`, so one `cart.add`
266
+ * signal can produce two rows — and two rows for zero landed lines when
267
+ * both throw. That fallback recovers a stale explicit variant id through
268
+ * product resolution; it is load-bearing and is not being deleted to make
269
+ * a count easier.
270
+ */
271
+ attemptId: z8.string().min(1).max(128),
272
+ /**
273
+ * NULLABLE AND REQUIRED. A quick-add from a batch CTA knows the variant
274
+ * and not always the product, so writing `null` is a decision the call
275
+ * site has to make. `productId?: string` would let it be forgotten, and a
276
+ * forgotten field and a deliberate null are indistinguishable afterwards.
277
+ */
278
+ productId: z8.string().min(1).max(256).nullable(),
279
+ variantId: z8.string().min(1).max(256),
280
+ quantity: z8.number().int().positive(),
281
+ origin: z8.enum(CART_ORIGINS)
282
+ }).strict()
283
+ );
284
+ var CART_LINE_REMOVED = defineEventKind(
285
+ "commerce.cart_line_removed",
286
+ "client",
287
+ z8.object({
288
+ lineId: z8.string().min(1).max(256),
289
+ /** Nullable and required, for the same reason as the add's: the line's
290
+ * product is read off the settled cart, and the settled cart is not
291
+ * always in hand at the facade. */
292
+ productId: z8.string().min(1).max(256).nullable(),
293
+ origin: z8.enum(CART_ORIGINS)
294
+ }).strict()
295
+ );
296
+ var CART_SETTLED = defineEventKind(
297
+ "commerce.cart_settled",
298
+ "client",
299
+ z8.object({
300
+ trigger: z8.enum(CART_SETTLE_TRIGGERS),
301
+ lineCount: z8.number().int().nonnegative(),
302
+ totalQuantity: z8.number().int().nonnegative(),
303
+ subtotalAmount: z8.number().nonnegative().finite(),
304
+ /** ISO-4217 alpha-3, as the storefront reports it. */
305
+ currencyCode: z8.string().regex(/^[A-Z]{3}$/),
306
+ /**
307
+ * True when the cart still carries a pending line, so its totals are
308
+ * mid-flight. Reported rather than suppressed: a subtotal that is honest
309
+ * about being provisional is usable, and a row that never arrives is not.
310
+ */
311
+ totalsPending: z8.boolean(),
312
+ /**
313
+ * The cart's OPAQUE back-office handle — what the connector's own back
314
+ * office knows this cart by, so a reviewer can open the order it became.
315
+ *
316
+ * It rides HERE rather than on `commerce.checkout_clicked`, and that is
317
+ * deliberate. The handle is a property of the cart, and this kind already
318
+ * fires on both cart edges (mutation and restore) from one payload
319
+ * builder; the checkout kind's two reached outcomes are recorded by
320
+ * `settleArmedCheckoutHandoff` / `recordVisitorCheckoutExit`, which pass
321
+ * `url: null` and hold no cart at all. Reading the pair together — a
322
+ * `checkout_clicked` and this session's latest handle — is one join in
323
+ * the reader and no threading through five call sites in three packages.
324
+ *
325
+ * Nullable and required: a platform with no back office writes `null`
326
+ * explicitly, so "no handle" is an assertion rather than an omission.
327
+ */
328
+ backOfficeRef: z8.string().nullable()
329
+ }).strict()
330
+ );
331
+ var CHECKOUT_CLICKED = defineEventKind(
332
+ "commerce.checkout_clicked",
333
+ "client",
334
+ z8.object({
335
+ origin: z8.enum(CHECKOUT_ORIGINS),
336
+ outcome: z8.enum(CHECKOUT_OUTCOMES),
337
+ /** Nullable and required: every non-`unavailable` outcome writes `null`
338
+ * explicitly, so "no refusal" is an assertion rather than an omission. */
339
+ refusal: z8.enum(CHECKOUT_REFUSALS).nullable(),
340
+ /** The store's monotone per-session counter, starting at 1. */
341
+ attempt: z8.number().int().positive()
342
+ }).strict()
343
+ );
344
+ var REGISTRY_CLICKED = defineEventKind(
345
+ "commerce.registry_clicked",
346
+ "client",
347
+ z8.object({
348
+ /** One visitor intent. Minted per click so a double-click is two
349
+ * attempts, exactly as two taps on Add to cart are two attempts. */
350
+ attemptId: z8.string().min(1).max(128),
351
+ /**
352
+ * WHICH registry. Free-form and bounded rather than an enum, because
353
+ * `RegistryProvider.id` is a `string` the brand supplies and the
354
+ * component already falls back to label text for a partner without a
355
+ * bundled logo. An enum here would refuse a new partner at INGEST — the
356
+ * row would land in `client_event_exceptions` and the click would be lost
357
+ * — for the sake of a validation that buys the read layer nothing it
358
+ * cannot do with a `GROUP BY`.
359
+ */
360
+ partnerId: z8.string().min(1).max(64),
361
+ /** Nullable and required, for the same reason the cart add's is: a
362
+ * registry action rendered outside a product detail has no product in
363
+ * scope, and writing `null` is a decision the call site has to make
364
+ * rather than a field it can forget. */
365
+ productId: z8.string().min(1).max(256).nullable(),
366
+ origin: z8.enum(CART_ORIGINS)
367
+ }).strict()
368
+ );
369
+
370
+ // ../spacestation/src/commerce/cart-verb-signals.ts
371
+ import { z as z9 } from "zod";
372
+ var CartRemoveSignalPayloadSchema = z9.object({
373
+ origin: z9.enum(CART_ORIGINS),
374
+ productId: z9.string().min(1),
375
+ selections: z9.record(z9.string()).optional()
376
+ });
377
+
378
+ // ../spacestation/src/commerce/cart-add-signal.ts
379
+ var CartAddSignalPayloadSchema = z10.object({
380
+ origin: z10.enum(CART_ORIGINS),
381
+ productId: z10.string().optional(),
382
+ variantId: z10.string().optional(),
383
+ quantity: z10.number().optional(),
384
+ selections: z10.record(z10.string()).optional(),
385
+ optimisticLine: z10.unknown().optional(),
386
+ /**
387
+ * Whether a LANDED add announces itself by opening the cart drawer on the
388
+ * changed line. Absent means yes, which is every existing producer's
389
+ * behaviour and the right default: for an agent-driven write the visitor
390
+ * never clicked, the drawer is the only visible confirmation there is.
391
+ *
392
+ * `false` is for an add whose acknowledgement is something else entirely —
393
+ * buy-now, which adds and then navigates to checkout. Opening a drawer there
394
+ * covers the page for a beat and then throws it away as the tab leaves, which
395
+ * is worse than no feedback: it reads as "your cart" at the exact moment the
396
+ * visitor asked NOT to look at their cart.
397
+ *
398
+ * A field on the signal rather than a flag on a store, because this is a
399
+ * property of the INTENT — the producer is the only frame that knows why the
400
+ * add is happening — and the handler is several frames away from it.
401
+ */
402
+ acknowledgeInDrawer: z10.boolean().optional()
403
+ });
404
+
405
+ // ../spacestation/src/types.ts
406
+ import { z as z11 } from "zod";
407
+ var StateSnapshotFrameSchema = z11.object({
408
+ rev: z11.number(),
409
+ state: z11.record(z11.unknown())
410
+ });
411
+
412
+ // ../spacestation/src/catalog/canvas-arrangement.ts
413
+ var CANVAS_BLOCK_SIZES = ["full", "wide", "half", "narrow"];
414
+
415
+ // ../spacestation/src/catalog/structural-baseline.ts
416
+ import { z as z12 } from "zod";
417
+ var agentTextProps = z12.object({
418
+ text: z12.string().optional().describe("Plain prose. Used by the streaming text.delta slot binding so the agent can flow words in without choosing emphasis spans up front."),
419
+ parts: z12.array(z12.object({
420
+ type: z12.enum(["text", "em"]).describe("text = sans body; em = italic emphasis."),
421
+ value: z12.string()
422
+ })).optional().describe("Pre-segmented prose with mixed sans + italic spans. When present, takes precedence over `text`. Use sparingly \u2014 italic carries weight, save it for the human moment in the answer."),
423
+ size: z12.enum(["sm", "md", "lg"]).optional().describe("Visual scale. lg for hero prose at the top of a turn; md (default) for body; sm for trailing footnote prose.")
424
+ });
425
+ var turnProps = z12.object({
426
+ prompt: z12.string().describe("The user's prompt for this turn, rendered as a quoted lede above the agent's response. Required so the conversation reads."),
427
+ index: z12.number().optional().describe("Turn index (0-based). When omitted the runtime infers from sibling turns."),
428
+ timestamp: z12.string().optional().describe("ISO timestamp for the small turn header. Omit to skip the header."),
429
+ thinking: z12.string().optional().describe("Short status line shown while the response streams in. Hidden once the first block lands.")
430
+ });
431
+ var backdropProps = z12.object({
432
+ variant: z12.enum(["ridges", "sky", "video", "none"]).optional().describe(
433
+ "Background variant. `ridges` = parallax silhouettes + sky gradient. `sky` = gradient + grain + vignette only. `video` = full-bleed autoplay-loop-muted video sourced from `videoUrl`. `none` = nothing rendered."
434
+ ),
435
+ ridgeColor: z12.string().optional().describe("Hex color of the ridge silhouettes. Defaults to surface fg1."),
436
+ videoUrl: z12.string().optional().describe(
437
+ 'Direct mp4/webm URL for the `video` variant. Loaded with preload="metadata", muted, looped, playsInline.'
438
+ ),
439
+ posterUrl: z12.string().optional().describe("Optional poster frame shown while video buffers.")
440
+ });
441
+ var STRUCTURAL_BASELINE_CATALOG = {
442
+ page: {
443
+ type: "page",
444
+ alwaysInclude: true,
445
+ propsSchema: z12.object({}),
446
+ layout: "fullbleed",
447
+ progressLabel: "Composing the page"
448
+ },
449
+ agentText: {
450
+ type: "agentText",
451
+ propsSchema: agentTextProps,
452
+ examples: [
453
+ {
454
+ parts: [
455
+ { type: "text", value: "Here are the three I'd shortlist. The order is " },
456
+ { type: "em", value: "what I'd pick first" },
457
+ { type: "text", value: "." }
458
+ ]
459
+ }
460
+ ],
461
+ layout: "fullbleed",
462
+ bindings: [
463
+ // Streaming agent prose flows into `text`. The model emits an empty
464
+ // agentText; this binding accumulates deltas as they arrive.
465
+ { source: "signal:text.delta", prop: "text", accumulate: "concat-text" },
466
+ // Final non-streamed text replaces the streamed accumulator.
467
+ { source: "signal:text.done", prop: "text", accumulate: "replace" }
468
+ ]
469
+ },
470
+ turn: {
471
+ type: "turn",
472
+ propsSchema: turnProps,
473
+ examples: [
474
+ {
475
+ prompt: "<the user prompt for this turn>",
476
+ thinking: "Short status line shown while the response streams in."
477
+ }
478
+ ],
479
+ layout: "fullbleed",
480
+ defaultLayoutWeight: 0,
481
+ bindings: [
482
+ // The user's prompt is part of session state; the SDK injects it into the
483
+ // turn wrapper. The model never repeats it in its output.
484
+ { source: "session.lastUserMessage", prop: "prompt", accumulate: "replace" }
485
+ ]
486
+ },
487
+ backdrop: {
488
+ type: "backdrop",
489
+ propsSchema: backdropProps,
490
+ examples: [{ variant: "ridges" }, { variant: "video", videoUrl: "https://cdn.example.com/hero.mp4" }],
491
+ layout: "fullbleed",
492
+ alwaysInclude: false
493
+ }
494
+ };
495
+ var STRUCTURAL_BASELINE_TYPES = Object.keys(STRUCTURAL_BASELINE_CATALOG);
496
+
497
+ // ../spacestation/src/catalog/resolved.ts
498
+ import { z as z13 } from "zod";
499
+ function readResolvedMeta(schema) {
500
+ const def = schema._def;
501
+ if (!("_resolved" in def)) return void 0;
502
+ const raw = def._resolved;
503
+ if (raw === null || typeof raw !== "object") return void 0;
504
+ if (!("resolverKey" in raw) || typeof raw.resolverKey !== "string") return void 0;
505
+ const meta = { resolverKey: raw.resolverKey };
506
+ if ("min" in raw && typeof raw.min === "number") meta.min = raw.min;
507
+ if ("max" in raw && typeof raw.max === "number") meta.max = raw.max;
508
+ if ("renderFloor" in raw && typeof raw.renderFloor === "number") meta.renderFloor = raw.renderFloor;
509
+ if ("derivedFrom" in raw && typeof raw.derivedFrom === "string") meta.derivedFrom = raw.derivedFrom;
510
+ return meta;
511
+ }
512
+
513
+ // ../spacestation/src/catalog/prose.ts
514
+ import { z as z14 } from "zod";
515
+ function readProseMeta(schema) {
516
+ const def = schema._def;
517
+ return "_prose" in def && def._prose === true;
518
+ }
519
+
520
+ // ../spacestation/src/catalog/required-props.ts
521
+ import { z as z15 } from "zod";
522
+
523
+ // ../spacestation/src/catalog/function-props.ts
524
+ import { z as z16 } from "zod";
525
+
526
+ // ../spacestation/src/catalog/wire/wire-schema.ts
527
+ import { z as z17 } from "zod";
528
+ var common = {
529
+ description: z17.string().optional(),
530
+ resolved: z17.object({
531
+ resolverKey: z17.string(),
532
+ min: z17.number().optional(),
533
+ max: z17.number().optional(),
534
+ renderFloor: z17.number().optional(),
535
+ derivedFrom: z17.string().optional()
536
+ }).strict().optional(),
537
+ prose: z17.literal(true).optional()
538
+ };
539
+ var WireSchemaSchema = z17.lazy(
540
+ () => z17.discriminatedUnion("t", [
541
+ z17.object({ ...common, t: z17.literal("string"), min: z17.number().optional(), max: z17.number().optional() }).strict(),
542
+ z17.object({
543
+ ...common,
544
+ t: z17.literal("number"),
545
+ int: z17.literal(true).optional(),
546
+ min: z17.number().optional(),
547
+ minExclusive: z17.literal(true).optional(),
548
+ max: z17.number().optional(),
549
+ maxExclusive: z17.literal(true).optional()
550
+ }).strict(),
551
+ z17.object({ ...common, t: z17.literal("boolean") }).strict(),
552
+ z17.object({ ...common, t: z17.literal("unknown") }).strict(),
553
+ z17.object({ ...common, t: z17.literal("literal"), value: z17.union([z17.string(), z17.number(), z17.boolean()]) }).strict(),
554
+ z17.object({ ...common, t: z17.literal("enum"), values: z17.array(z17.string()).min(1) }).strict(),
555
+ z17.object({ ...common, t: z17.literal("array"), element: WireSchemaSchema, min: z17.number().optional(), max: z17.number().optional() }).strict(),
556
+ z17.object({ ...common, t: z17.literal("object"), shape: z17.record(WireSchemaSchema), unknownKeys: z17.enum(["strip", "passthrough", "strict"]) }).strict(),
557
+ z17.object({ ...common, t: z17.literal("union"), options: z17.array(WireSchemaSchema).min(2) }).strict(),
558
+ z17.object({ ...common, t: z17.literal("discriminatedUnion"), discriminator: z17.string(), options: z17.array(WireSchemaSchema).min(2) }).strict(),
559
+ z17.object({ ...common, t: z17.literal("record"), value: WireSchemaSchema }).strict(),
560
+ z17.object({ ...common, t: z17.literal("optional"), inner: WireSchemaSchema }).strict(),
561
+ z17.object({ ...common, t: z17.literal("nullable"), inner: WireSchemaSchema }).strict(),
562
+ z17.object({ ...common, t: z17.literal("default"), inner: WireSchemaSchema, value: z17.unknown() }).strict()
563
+ ])
564
+ );
565
+
566
+ // ../spacestation/src/catalog/wire/schema-to-wire.ts
567
+ import { z as z18 } from "zod";
568
+ var UnsupportedSchemaError = class extends Error {
569
+ constructor(path, what) {
570
+ super(`Cannot publish the schema at ${path === "" ? "<root>" : path}: ${what}.`);
571
+ this.name = "UnsupportedSchemaError";
572
+ }
573
+ };
574
+ function stringNode(schema, path) {
575
+ const node = { t: "string" };
576
+ for (const check of schema._def.checks) {
577
+ if (check.kind === "min") node.min = check.value;
578
+ else if (check.kind === "max") node.max = check.value;
579
+ else throw new UnsupportedSchemaError(path, `string check "${check.kind}" is not supported`);
580
+ }
581
+ return node;
582
+ }
583
+ function numberNode(schema, path) {
584
+ const node = { t: "number" };
585
+ for (const check of schema._def.checks) {
586
+ if (check.kind === "int") node.int = true;
587
+ else if (check.kind === "min") {
588
+ node.min = check.value;
589
+ if (!check.inclusive) node.minExclusive = true;
590
+ } else if (check.kind === "max") {
591
+ node.max = check.value;
592
+ if (!check.inclusive) node.maxExclusive = true;
593
+ } else throw new UnsupportedSchemaError(path, `number check "${check.kind}" is not supported`);
594
+ }
595
+ return node;
596
+ }
597
+ function arrayNode(schema, path) {
598
+ if (schema._def.exactLength !== null) throw new UnsupportedSchemaError(path, "array .length() is not supported");
599
+ const node = { t: "array", element: toNode(schema.element, `${path}[]`) };
600
+ if (schema._def.minLength !== null) node.min = schema._def.minLength.value;
601
+ if (schema._def.maxLength !== null) node.max = schema._def.maxLength.value;
602
+ return node;
603
+ }
604
+ function objectNode(schema, path) {
605
+ if (!(schema._def.catchall instanceof z18.ZodNever)) throw new UnsupportedSchemaError(path, "object .catchall() is not supported");
606
+ const shape = {};
607
+ for (const [key, child] of Object.entries(schema.shape)) shape[key] = toNode(child, path === "" ? key : `${path}.${key}`);
608
+ return { t: "object", shape, unknownKeys: schema._def.unknownKeys };
609
+ }
610
+ function literalNode(schema, path) {
611
+ const value = schema.value;
612
+ if (typeof value === "string" || typeof value === "number" || typeof value === "boolean") return { t: "literal", value };
613
+ throw new UnsupportedSchemaError(path, "only string, number and boolean literals are supported");
614
+ }
615
+ function bare(schema, path) {
616
+ if (schema instanceof z18.ZodString) return stringNode(schema, path);
617
+ if (schema instanceof z18.ZodNumber) return numberNode(schema, path);
618
+ if (schema instanceof z18.ZodBoolean) return { t: "boolean" };
619
+ if (schema instanceof z18.ZodUnknown || schema instanceof z18.ZodAny) return { t: "unknown" };
620
+ if (schema instanceof z18.ZodLiteral) return literalNode(schema, path);
621
+ if (schema instanceof z18.ZodEnum) return { t: "enum", values: [...schema.options] };
622
+ if (schema instanceof z18.ZodArray) return arrayNode(schema, path);
623
+ if (schema instanceof z18.ZodObject) return objectNode(schema, path);
624
+ if (schema instanceof z18.ZodUnion) {
625
+ const options = schema.options;
626
+ return { t: "union", options: options.map((option, i) => toNode(option, `${path}|${i}`)) };
627
+ }
628
+ if (schema instanceof z18.ZodDiscriminatedUnion) {
629
+ const options = schema.options;
630
+ return {
631
+ t: "discriminatedUnion",
632
+ discriminator: schema.discriminator,
633
+ options: options.map((option, i) => toNode(option, `${path}|${i}`))
634
+ };
635
+ }
636
+ if (schema instanceof z18.ZodRecord) {
637
+ if (!(schema.keySchema instanceof z18.ZodString)) throw new UnsupportedSchemaError(path, "only string-keyed records are supported");
638
+ return { t: "record", value: toNode(schema.valueSchema, `${path}{}`) };
639
+ }
640
+ if (schema instanceof z18.ZodOptional) return { t: "optional", inner: toNode(schema.unwrap(), path) };
641
+ if (schema instanceof z18.ZodNullable) return { t: "nullable", inner: toNode(schema.unwrap(), path) };
642
+ if (schema instanceof z18.ZodDefault) {
643
+ return { t: "default", inner: toNode(schema._def.innerType, path), value: schema._def.defaultValue() };
644
+ }
645
+ throw new UnsupportedSchemaError(path, `${schema.constructor.name} is not supported`);
646
+ }
647
+ function toNode(schema, path) {
648
+ const node = bare(schema, path);
649
+ if (schema.description !== void 0) node.description = schema.description;
650
+ const resolvedMeta = readResolvedMeta(schema);
651
+ if (resolvedMeta !== void 0) node.resolved = resolvedMeta;
652
+ if (readProseMeta(schema)) node.prose = true;
653
+ return node;
654
+ }
655
+ function schemaToWire(schema) {
656
+ return toNode(schema, "");
657
+ }
658
+
659
+ // ../spacestation/src/catalog/wire/schema-from-wire.ts
660
+ import { z as z19 } from "zod";
661
+
662
+ // ../spacestation/src/catalog/wire/catalog-wire.ts
663
+ import { z as z20 } from "zod";
664
+ var WireCatalogEntrySchema = z20.object({
665
+ type: z20.string().min(1),
666
+ propsSchema: WireSchemaSchema.optional(),
667
+ examples: z20.array(z20.record(z20.unknown())).optional(),
668
+ renderedBy: z20.string().optional(),
669
+ alwaysInclude: z20.boolean().optional(),
670
+ whenToUse: z20.string().optional(),
671
+ dontUseWhen: z20.string().optional(),
672
+ variants: z20.string().optional(),
673
+ dependencies: z20.string().optional(),
674
+ layout: z20.enum(["section", "fullbleed"]).optional(),
675
+ size: z20.enum(CANVAS_BLOCK_SIZES).optional(),
676
+ extendsPage: z20.boolean().optional(),
677
+ bindings: z20.array(
678
+ z20.object({
679
+ source: z20.string(),
680
+ prop: z20.string(),
681
+ accumulate: z20.enum(["replace", "append", "concat-text"]).optional(),
682
+ mountAt: z20.string().optional()
683
+ })
684
+ ).optional(),
685
+ defaultLayoutWeight: z20.number().optional(),
686
+ defaultMaxHeight: z20.enum(["sm", "md", "lg", "full"]).optional(),
687
+ category: z20.string().optional(),
688
+ progressLabel: z20.string().optional(),
689
+ isExperience: z20.boolean().optional(),
690
+ requires: z20.array(z20.string()).optional(),
691
+ provides: z20.array(z20.string()).optional()
692
+ }).strict();
693
+ var WireCatalogSchema = z20.record(WireCatalogEntrySchema);
694
+ function propsToWire(type, schema) {
695
+ try {
696
+ return schemaToWire(schema);
697
+ } catch (err) {
698
+ throw new Error(`Catalog type "${type}": ${err instanceof Error ? err.message : String(err)}`);
699
+ }
700
+ }
701
+ function catalogToWire(catalog) {
702
+ const out = {};
703
+ for (const [type, entry] of Object.entries(catalog)) {
704
+ const { propsSchema, source: _source, ...data } = entry;
705
+ out[type] = propsSchema === void 0 ? data : { ...data, propsSchema: propsToWire(type, propsSchema) };
706
+ }
707
+ return out;
708
+ }
709
+
710
+ // ../spacestation/src/catalog/wire/package-release.ts
711
+ import { z as z21 } from "zod";
712
+ var RESERVED_SCOPES = ["@fourty/", "@40rty/"];
713
+ var PackageReleaseSchema = z21.object({
714
+ /** The id spaces name in `componentSources` — an npm-style package name. */
715
+ sourceId: z21.string().regex(/^(@[a-z0-9][a-z0-9-]*\/)?[a-z0-9][a-z0-9-]*$/, "sourceId must be an npm-style package name").refine((id) => !RESERVED_SCOPES.some((scope) => id.startsWith(scope)), `the ${RESERVED_SCOPES.join(" and ")} scopes are reserved`),
716
+ label: z21.string().min(1).max(120),
717
+ /** The package's own version, as its repository states it — shown in the console. */
718
+ version: z21.string().min(1).max(40),
719
+ catalog: WireCatalogSchema,
720
+ /** Component manifests by path under `catalogs/`, e.g. `catalogs/product/productGrid.md`. */
721
+ manifests: z21.record(z21.string().regex(/^catalogs\/.+\.md$/, "a manifest path is catalogs/<\u2026>.md"), z21.string()),
722
+ /**
723
+ * The brand's components, built — present when the PLATFORM hosts this
724
+ * brand's spacefront, absent when the brand hosts it in its own app. One
725
+ * ES module (exporting `renderers`, and optionally `shells`) and its
726
+ * stylesheet. It is served to browsers; the platform's servers never run it.
727
+ */
728
+ bundle: z21.object({ js: z21.string().min(1), css: z21.string() }).strict().optional(),
729
+ /**
730
+ * The class the spacefront root carries while this package is the space's.
731
+ * The package's own stylesheet styles under it. Absent = the platform's
732
+ * default theme class.
733
+ */
734
+ theme: z21.object({ themeClass: z21.string().regex(/^[a-z][a-z0-9-]*$/, "a theme class is lowercase letters, digits and hyphens") }).strict().optional(),
735
+ /** The canvas a fresh session opens on, before the visitor has asked anything. */
736
+ seedLayout: SpecSchema.optional(),
737
+ /**
738
+ * The package's own composition guidance for its own components — prompt
739
+ * markdown the agent reads, gated on the capabilities it names (`requires`).
740
+ */
741
+ promptSections: z21.array(z21.object({ id: z21.string().regex(/^[a-z0-9-]+$/), order: z21.number().int(), content: z21.string().min(1).max(2e4), requires: z21.array(z21.string()) }).strict()).max(10).optional(),
742
+ /**
743
+ * Opaque per-vertical extension data (`BrandDefinition.config`): the
744
+ * platform stays vertical-agnostic and the vertical's own code reads its keys.
745
+ */
746
+ config: z21.record(z21.string(), z21.unknown()).optional(),
747
+ /**
748
+ * Set by the platform, never by a publisher: this release is a DRAFT of the
749
+ * package `of`, previewed on the space `space`. See `draftSourceId`.
750
+ */
751
+ draft: z21.object({ of: z21.string().min(1), space: z21.string().min(1) }).strict().optional()
752
+ }).strict();
753
+
754
+ // ../spacestation/src/projection/projection.ts
755
+ import { z as z22 } from "zod";
756
+ var LateBoundValueSchema = z22.object({ fact: z22.literal(true) });
757
+ var DirectiveValueSchema = z22.union([
758
+ z22.string(),
759
+ z22.number(),
760
+ z22.boolean(),
761
+ LateBoundValueSchema
762
+ ]);
763
+ var ProjectionDirectiveSchema = z22.object({
764
+ /** Keep only items whose axis values all match. Keyed by axis name
765
+ * (e.g. `Size`); value is a literal or the `{fact:true}` marker. */
766
+ isolateTo: z22.record(DirectiveValueSchema).optional(),
767
+ /** Isolate to EVERY axis the visitor has a stored fact for. The agent
768
+ * emits this (it is vertical-agnostic — it cannot name axes); the
769
+ * entity binding expands it against the entity's own axes + facts. */
770
+ isolateToFacts: z22.boolean().optional(),
771
+ /** Keep only items the entity binding reports as available. */
772
+ availableOnly: z22.boolean().optional(),
773
+ /** Cap the rendered count after filtering. */
774
+ limit: z22.number().int().positive().optional()
775
+ });
776
+ var ProjectionPreferencesSchema = z22.record(
777
+ z22.union([ProjectionDirectiveSchema, z22.null()])
778
+ );
779
+ var ProjectionSetPayloadSchema = z22.object({
780
+ setAll: z22.union([ProjectionDirectiveSchema, z22.null()]).optional(),
781
+ set: ProjectionPreferencesSchema.optional()
782
+ });
783
+
784
+ // ../spacestation/src/focus/focus.ts
785
+ import { z as z23 } from "zod";
786
+ var FocusElementPayloadSchema = z23.object({
787
+ elementId: z23.string().min(1)
788
+ });
789
+
790
+ // ../spacestation/src/view/continuation.ts
791
+ import { z as z24 } from "zod";
792
+ var ViewExtendPayloadSchema = z24.object({
793
+ reason: z24.enum(["scroll_near_bottom"])
794
+ });
795
+
796
+ // ../spacestation/src/attachment/attachment.ts
797
+ import { z as z25 } from "zod";
798
+ var ALLOWED_ATTACHMENT_TYPES = [
799
+ "image/jpeg",
800
+ "image/png",
801
+ "image/webp",
802
+ "image/gif",
803
+ "image/heic"
804
+ ];
805
+ var MAX_ATTACHMENT_BYTES = 10 * 1024 * 1024;
806
+ function isAllowedAttachmentType(mime) {
807
+ return ALLOWED_ATTACHMENT_TYPES.includes(mime);
808
+ }
809
+ var AttachmentRefSchema = z25.object({
810
+ id: z25.string().min(1),
811
+ mimeType: z25.string().refine(isAllowedAttachmentType, {
812
+ message: "mimeType not on the attachment allow-list"
813
+ }),
814
+ name: z25.string().min(1),
815
+ size: z25.number().int().positive().max(MAX_ATTACHMENT_BYTES),
816
+ url: z25.string().min(1)
817
+ });
818
+ var AttachmentRefsSchema = z25.array(AttachmentRefSchema);
819
+
820
+ // ../spacestation/src/contracts/entry-context.ts
821
+ import { z as z26 } from "zod";
822
+ var ENTRY_CONTEXT_MAX_VALUE_CHARS = 200;
823
+ var ENTRY_CONTEXT_MAX_KEYS = 12;
824
+ var ENTRY_CONTEXT_MAX_NAMESPACES = 8;
825
+ var ENTRY_CONTEXT_MAX_NAME_CHARS = 64;
826
+ var EntryContextValueSchema = z26.string().trim().min(1).max(ENTRY_CONTEXT_MAX_VALUE_CHARS);
827
+ var EntryContextNameSchema = z26.string().trim().min(1).max(ENTRY_CONTEXT_MAX_NAME_CHARS);
828
+ var EntryContextNamespaceSchema = z26.record(EntryContextNameSchema, EntryContextValueSchema).refine((entries) => Object.keys(entries).length <= ENTRY_CONTEXT_MAX_KEYS, {
829
+ message: `at most ${ENTRY_CONTEXT_MAX_KEYS} entries per namespace`
830
+ });
831
+ var EntryContextSchema = z26.record(EntryContextNameSchema, EntryContextNamespaceSchema).refine((namespaces) => Object.keys(namespaces).length <= ENTRY_CONTEXT_MAX_NAMESPACES, {
832
+ message: `at most ${ENTRY_CONTEXT_MAX_NAMESPACES} entry-context namespaces`
833
+ });
834
+
835
+ // ../spacestation/src/contracts/session-arrival.ts
836
+ import { z as z27 } from "zod";
837
+ var SURFACES = [
838
+ "spacefront",
839
+ "embed",
840
+ "headless",
841
+ "internal",
842
+ /** @deprecated Renamed to `internal`. Accepted for rollback safety, never emitted. */
843
+ "playground",
844
+ "automation"
845
+ ];
846
+ var SurfaceSchema = z27.enum(SURFACES);
847
+ var CLICK_ID_KINDS = ["gclid", "fbclid", "msclkid", "wbraid", "gbraid"];
848
+ var ClickIdKindSchema = z27.enum(CLICK_ID_KINDS);
849
+ var VISITOR_ID_DURABILITIES = ["persisted", "ephemeral", "host_supplied"];
850
+ var VisitorIdDurabilitySchema = z27.enum(VISITOR_ID_DURABILITIES);
851
+ var TRAFFIC_BUCKETS = [
852
+ "paid_google",
853
+ "paid_meta",
854
+ "paid_other",
855
+ "organic",
856
+ "social",
857
+ "referral",
858
+ "own_site",
859
+ "direct",
860
+ "unknown"
861
+ ];
862
+ var TrafficBucketSchema = z27.enum(TRAFFIC_BUCKETS);
863
+ var ARRIVAL_MAX_VALUE_CHARS = 200;
864
+ var ArrivalValueSchema = z27.string().trim().min(1).max(ARRIVAL_MAX_VALUE_CHARS);
865
+ var SessionArrivalSchema = z27.object({
866
+ utmSource: ArrivalValueSchema.optional(),
867
+ utmMedium: ArrivalValueSchema.optional(),
868
+ utmCampaign: ArrivalValueSchema.optional(),
869
+ utmContent: ArrivalValueSchema.optional(),
870
+ utmTerm: ArrivalValueSchema.optional(),
871
+ /** Set as a pair or not at all — a kind with no value classifies nothing, and
872
+ * a value with no kind cannot be attributed to a network. Enforced below. */
873
+ clickIdKind: ClickIdKindSchema.optional(),
874
+ clickId: ArrivalValueSchema.optional(),
875
+ /** Host only — never a full URL. A path carries query strings, and query
876
+ * strings carry emails and order ids. Normalised server-side. */
877
+ referrerHost: ArrivalValueSchema.optional(),
878
+ surface: SurfaceSchema.optional(),
879
+ visitorIdDurability: VisitorIdDurabilitySchema.optional()
880
+ }).strict().refine(
881
+ (arrival) => arrival.clickIdKind === void 0 === (arrival.clickId === void 0),
882
+ { message: "clickIdKind and clickId must be supplied together" }
883
+ );
884
+
885
+ // ../spacestation/src/contracts/session-arrival-params.ts
886
+ var UTM_PARAMS = [
887
+ ["utm_source", "utmSource"],
888
+ ["utm_medium", "utmMedium"],
889
+ ["utm_campaign", "utmCampaign"],
890
+ ["utm_content", "utmContent"],
891
+ ["utm_term", "utmTerm"]
892
+ ];
893
+ var ARRIVAL_PARAMS = [
894
+ ...UTM_PARAMS.map(([param]) => param),
895
+ ...CLICK_ID_KINDS
896
+ ];
897
+
898
+ // ../spacestation/src/catalog/attribute-registry.ts
899
+ import { z as z28 } from "zod";
900
+ var AttributeScopeBucketSchema = z28.object({
901
+ scope: z28.string(),
902
+ needles: z28.array(z28.string()).readonly(),
903
+ label: z28.string().optional()
904
+ });
905
+ var AttributeScopeConfigSchema = z28.object({
906
+ facet: z28.string(),
907
+ buckets: z28.array(AttributeScopeBucketSchema).readonly(),
908
+ emptyScope: z28.string(),
909
+ noMatchScope: z28.string(),
910
+ ignoreValues: z28.array(z28.string()).readonly(),
911
+ emptyScopeLabel: z28.string().optional(),
912
+ noMatchScopeLabel: z28.string().optional()
913
+ });
914
+ var AttributeDefBaseSchema = z28.object({
915
+ description: z28.string().optional(),
916
+ durable: z28.boolean().optional(),
917
+ label: z28.string().optional()
918
+ });
919
+ var AttributeDefSchema = z28.discriminatedUnion("kind", [
920
+ AttributeDefBaseSchema.extend({ kind: z28.literal("enum"), values: z28.array(z28.string()) }),
921
+ AttributeDefBaseSchema.extend({ kind: z28.literal("free_text") }),
922
+ AttributeDefBaseSchema.extend({ kind: z28.literal("date_or_season") }),
923
+ AttributeDefBaseSchema.extend({ kind: z28.literal("money_or_band") }),
924
+ AttributeDefBaseSchema.extend({
925
+ kind: z28.literal("number"),
926
+ min: z28.number().optional(),
927
+ max: z28.number().optional(),
928
+ unit: z28.string().optional()
929
+ })
930
+ ]);
931
+
932
+ // ../spacestation/src/space/workspace-catalog.ts
933
+ var COMPONENT_SOURCE = {
934
+ ui: "@fourty/ui"
935
+ };
936
+ var THEME_PACKAGE = {
937
+ ui: "@fourty/ui-theme"
938
+ };
939
+ var COMPONENT_SOURCE_DEFAULT_THEME = {
940
+ [COMPONENT_SOURCE.ui]: THEME_PACKAGE.ui
941
+ };
942
+ var WORKSPACE_THEME_PACKAGES = [
943
+ { id: THEME_PACKAGE.ui, label: "40rty" }
944
+ ];
945
+
946
+ // ../spacestation/src/space/space-config.ts
947
+ var DEFAULT_SPACE_CONFIG = {
948
+ vertical: "ecommerce",
949
+ // The base catalog. A new space renders the 16 baseline components out of the
950
+ // box; brands layer their own source on top (or replace the base) in settings.
951
+ // An empty list would resolve to an empty catalog — a space that renders
952
+ // nothing — so the default must carry the base.
953
+ componentSources: [COMPONENT_SOURCE.ui],
954
+ // The theme resolves from the winning component source's `defaultTheme`
955
+ // (base `@fourty/ui` → `@fourty/ui-theme`); there is no per-space override.
956
+ soulSlug: "ecommerce"
957
+ };
958
+
959
+ // ../spacestation/src/space/trace.ts
960
+ import { z as z29 } from "zod";
961
+ var RunTokenUsageSchema = z29.object({
962
+ input_tokens: z29.number().optional(),
963
+ output_tokens: z29.number().optional(),
964
+ cache_read_tokens: z29.number().optional()
965
+ });
966
+ var TraceRecordSchema = z29.object({
967
+ id: z29.string().uuid(),
968
+ spaceId: z29.string().uuid().nullable(),
969
+ sessionId: z29.string(),
970
+ /** OTP-verified visitor email the session was unlocked with, or `null`
971
+ * for an unlocked space / anonymous unlock. */
972
+ visitorEmail: z29.string().nullable(),
973
+ userPrompt: z29.string(),
974
+ branch: z29.string().nullable(),
975
+ responseText: z29.string().nullable(),
976
+ layout: z29.unknown().nullable(),
977
+ phaseTimings: z29.record(z29.number()).nullable(),
978
+ tokensByModel: z29.record(RunTokenUsageSchema).nullable(),
979
+ toolCalls: z29.array(z29.unknown()).nullable(),
980
+ diagnostics: z29.array(z29.unknown()).nullable(),
981
+ latencyFirstText: z29.number().int().nullable(),
982
+ latencyFirstPatch: z29.number().int().nullable(),
983
+ latencyTotal: z29.number().int().nullable(),
984
+ /**
985
+ * The CLIENT's turn id for this run, or `null`.
986
+ *
987
+ * Written so a browser-emitted event can be lined up against the turn that
988
+ * produced it. `commerce.products_surfaced` carries the same id, and the
989
+ * dead-end classifier's whole question — "did this turn run a catalog search
990
+ * and still surface nothing?" — needs both halves of that join. Before this
991
+ * column the id was known at persist time and simply thrown away: it reached
992
+ * `trace_saved` and went no further.
993
+ *
994
+ * NULLABLE, and the classifier treats null as UNMEASURED rather than as a
995
+ * dead end. A run with no turn id is a background pass, a pre-column row, or
996
+ * a turn whose ack the client never saw — none of which is evidence that a
997
+ * visitor asked something and got nothing.
998
+ */
999
+ turnId: z29.string().nullable(),
1000
+ /** Serialized `TraceTracker.exportState()` payload (parsed object) —
1001
+ * lets the inspector rehydrate this run verbatim after a reload. */
1002
+ trackerState: z29.unknown().nullable(),
1003
+ createdAt: z29.string()
1004
+ });
1005
+ var MillisecondsSchema = z29.number().nullable().transform((v) => v === null ? null : Math.round(v));
1006
+ var CreateTraceInputSchema = z29.object({
1007
+ spaceId: z29.string().uuid().nullable(),
1008
+ sessionId: z29.string(),
1009
+ visitorEmail: z29.string().nullable(),
1010
+ userPrompt: z29.string(),
1011
+ branch: z29.string().nullable(),
1012
+ responseText: z29.string().nullable(),
1013
+ layout: z29.unknown().nullable(),
1014
+ phaseTimings: z29.record(z29.number()).nullable(),
1015
+ tokensByModel: z29.record(RunTokenUsageSchema).nullable(),
1016
+ toolCalls: z29.array(z29.unknown()).nullable(),
1017
+ diagnostics: z29.array(z29.unknown()).nullable(),
1018
+ latencyFirstText: MillisecondsSchema,
1019
+ latencyFirstPatch: MillisecondsSchema,
1020
+ latencyTotal: MillisecondsSchema,
1021
+ trackerState: z29.unknown().nullable(),
1022
+ /**
1023
+ * The CLIENT's turn id for this run, or `null`.
1024
+ *
1025
+ * Written so a browser-emitted event can be lined up against the turn that
1026
+ * produced it. `commerce.products_surfaced` carries the same id, and the
1027
+ * dead-end classifier's whole question — "did this turn run a catalog search
1028
+ * and still surface nothing?" — needs both halves of that join. Before this
1029
+ * column the id was known at persist time and simply thrown away: it reached
1030
+ * `trace_saved` and went no further.
1031
+ *
1032
+ * NULLABLE, and the classifier treats null as UNMEASURED rather than as a
1033
+ * dead end. A run with no turn id is a background pass, a pre-column row, or
1034
+ * a turn whose ack the client never saw — none of which is evidence that a
1035
+ * visitor asked something and got nothing.
1036
+ */
1037
+ turnId: z29.string().nullable()
1038
+ });
1039
+ var AgentSessionSummarySchema = z29.object({
1040
+ sessionId: z29.string(),
1041
+ /** Turn rows only; background/secondary runs are excluded by the aggregate. */
1042
+ turnCount: z29.number().int(),
1043
+ /** The session's opening prompt — titles the row in the UI. */
1044
+ firstPrompt: z29.string(),
1045
+ startedAt: z29.string(),
1046
+ lastRunAt: z29.string(),
1047
+ /** Summed `latency_total` across the session's turns. */
1048
+ totalLatencyMs: z29.number().int()
1049
+ });
1050
+ var SessionTurnSchema = z29.object({
1051
+ id: z29.string().uuid(),
1052
+ userPrompt: z29.string(),
1053
+ responseText: z29.string().nullable(),
1054
+ /** Full cumulative Spec committed by this turn — never a patch delta. */
1055
+ layout: z29.unknown().nullable(),
1056
+ createdAt: z29.string(),
1057
+ latencyTotal: z29.number().int().nullable(),
1058
+ phaseTimings: z29.record(z29.number()).nullable(),
1059
+ tokensByModel: z29.record(z29.object({
1060
+ input_tokens: z29.number().optional(),
1061
+ output_tokens: z29.number().optional()
1062
+ })).nullable(),
1063
+ toolCalls: z29.array(z29.unknown()).nullable(),
1064
+ diagnostics: z29.array(z29.unknown()).nullable()
1065
+ });
1066
+ var SessionReplaySchema = z29.object({
1067
+ turns: z29.array(SessionTurnSchema),
1068
+ /**
1069
+ * The session's own last-committed layout, read straight off the durable
1070
+ * session record (`sessions.blob.layout`) rather than derived from `turns`.
1071
+ *
1072
+ * A session always has a layout — the client seeds one on arrival, agent
1073
+ * turn or not — but `turns` only exists once the agent has SPOKEN. A visitor
1074
+ * who deep-links into a product and leaves without a word has zero turns and
1075
+ * a perfectly real layout; only this field can show it. Null exclusively
1076
+ * when the durable session row itself could not be read.
1077
+ */
1078
+ sessionLayout: z29.record(z29.string(), z29.unknown()).nullable()
1079
+ });
1080
+ var SessionTraceSchema = z29.object({
1081
+ trackerState: z29.string().nullable()
1082
+ });
1083
+ var LlmUsageDailySchema = z29.object({
1084
+ day: z29.string(),
1085
+ /** Deployment that made the call — 'production', 'staging', 'pr-123', 'development'. */
1086
+ environment: z29.string(),
1087
+ feature: z29.string(),
1088
+ model: z29.string(),
1089
+ provider: z29.string(),
1090
+ /** Masked tail of the key actually billed, or null when unknown/non-Google. */
1091
+ keyFingerprint: z29.string().nullable(),
1092
+ /**
1093
+ * The space the call served, or null when it served none.
1094
+ *
1095
+ * Null is a REAL answer, not missing data: evals, BIC scans, layout edits and
1096
+ * embeddings are platform work with no one space behind them. Consumers must
1097
+ * report that share rather than dropping it, or a per-space total reads as
1098
+ * the platform total.
1099
+ */
1100
+ spaceId: z29.string().nullable(),
1101
+ /**
1102
+ * The surface of the session the call served (`sessions.surface`), or null
1103
+ * when it served no session or the session predates surface recording.
1104
+ * `automation` is the eval harness — the signal that files an ordinary
1105
+ * `agent-turn` as testing spend rather than as a visitor's.
1106
+ */
1107
+ surface: z29.string().nullable(),
1108
+ inputTokens: z29.number(),
1109
+ outputTokens: z29.number(),
1110
+ /** Subset of inputTokens, never additional to it. */
1111
+ cachedInputTokens: z29.number(),
1112
+ reasoningTokens: z29.number(),
1113
+ callCount: z29.number(),
1114
+ errorCount: z29.number(),
1115
+ estimatedCostUsd: z29.number().nullable()
1116
+ });
1117
+ var LlmUsageBySessionSchema = z29.object({
1118
+ sessionId: z29.string(),
1119
+ environment: z29.string(),
1120
+ model: z29.string(),
1121
+ /** The space this session belongs to, or null for a session with no space. */
1122
+ spaceId: z29.string().nullable(),
1123
+ /** The session's surface — see `LlmUsageDailySchema.surface`. */
1124
+ surface: z29.string().nullable(),
1125
+ /** Label only — the first feature seen in the session. */
1126
+ firstFeature: z29.string(),
1127
+ startedAt: z29.string(),
1128
+ endedAt: z29.string(),
1129
+ inputTokens: z29.number(),
1130
+ outputTokens: z29.number(),
1131
+ cachedInputTokens: z29.number(),
1132
+ reasoningTokens: z29.number(),
1133
+ callCount: z29.number(),
1134
+ errorCount: z29.number(),
1135
+ /** Priced server-side, like the daily rollup — the browser never carries a
1136
+ * rate table, so there is exactly one place a price can be wrong. Null when
1137
+ * the model is unpriced; never 0, which would read as free. */
1138
+ estimatedCostUsd: z29.number().nullable()
1139
+ });
1140
+ var LlmSessionsDailySchema = z29.object({
1141
+ day: z29.string(),
1142
+ environment: z29.string(),
1143
+ sessionCount: z29.number()
1144
+ });
1145
+
1146
+ // ../spacestation/src/space/session-queue.ts
1147
+ import { z as z31 } from "zod";
1148
+
1149
+ // ../spacestation/src/space/session-activity.ts
1150
+ import { z as z30 } from "zod";
1151
+ var SessionActivityEventSchema = z30.object({
1152
+ id: z30.string(),
1153
+ kind: z30.string(),
1154
+ occurredAt: z30.string(),
1155
+ source: z30.string(),
1156
+ surface: z30.string(),
1157
+ payload: z30.record(z30.unknown())
1158
+ });
1159
+ var SessionActivitySchema = z30.object({
1160
+ events: z30.array(SessionActivityEventSchema),
1161
+ hasMore: z30.boolean()
1162
+ });
1163
+
1164
+ // ../spacestation/src/space/session-queue.ts
1165
+ var SessionVerdictSchema = z31.enum(["unreviewed", "viewed", "bug"]);
1166
+ var RecordableVerdictSchema = z31.enum(["viewed", "bug"]);
1167
+ var SessionReviewEventSchema = z31.object({
1168
+ id: z31.string().uuid(),
1169
+ verdict: RecordableVerdictSchema,
1170
+ /** Account email of the operator who judged it. Attribution is the reason the
1171
+ * log is append-only rather than a mutable current-state row. */
1172
+ reviewer: z31.string(),
1173
+ note: z31.string().nullable(),
1174
+ createdAt: z31.string()
1175
+ });
1176
+ var BugSeveritySchema = z31.enum(["high", "medium", "low"]);
1177
+ var BugLocationSchema = z31.object({
1178
+ elementId: z31.string().nullable(),
1179
+ /** Display only — the catalog component type, e.g. "productGrid". Null
1180
+ * alongside a null `elementId`. */
1181
+ elementType: z31.string().nullable(),
1182
+ /** Fraction of the ELEMENT's own box. Null for a page anchor. */
1183
+ offsetXPct: z31.number().min(0).max(100).nullable(),
1184
+ offsetYPct: z31.number().min(0).max(100).nullable(),
1185
+ /**
1186
+ * ABSOLUTE document pixels, for a pin with no element under it. Null for an
1187
+ * element anchor.
1188
+ *
1189
+ * Absolute, and NOT a fraction of the page, because the page's total size is
1190
+ * not stable: a hover scale, a late-loading image, an expanding card or a
1191
+ * scrollbar all change it, and a fraction of a moving total drags every pin
1192
+ * on the page with it. Measured before this was fixed: growing the page 9%
1193
+ * slid a pin 32px, so a pin ran away from the cursor reaching for it.
1194
+ */
1195
+ pageX: z31.number().nullable(),
1196
+ pageY: z31.number().nullable()
1197
+ }).refine(
1198
+ (loc) => {
1199
+ const hasOffsets = loc.offsetXPct !== null && loc.offsetYPct !== null;
1200
+ if (loc.elementId !== null || loc.elementType !== null) {
1201
+ return loc.elementId !== null && loc.elementType !== null && hasOffsets && loc.pageX === null && loc.pageY === null;
1202
+ }
1203
+ if (loc.pageX !== null || loc.pageY !== null) return loc.pageX !== null && loc.pageY !== null;
1204
+ return hasOffsets;
1205
+ },
1206
+ {
1207
+ message: "location must be one complete anchor: an element (elementId + elementType + both offsets), a page position (pageX + pageY), or a legacy page fraction (both offsets)"
1208
+ }
1209
+ );
1210
+ var SessionBugSchema = z31.object({
1211
+ id: z31.string().uuid(),
1212
+ /** 1-based turn the fault was observed on; null when the fault is session-wide. */
1213
+ turnIndex: z31.number().int().nullable(),
1214
+ /** Where on that turn's canvas the pin was dropped; null for a bug filed
1215
+ * without pinning a spot. */
1216
+ location: BugLocationSchema.nullable(),
1217
+ provider: z31.string(),
1218
+ issueKey: z31.string().nullable(),
1219
+ issueUrl: z31.string().nullable(),
1220
+ /** The tracker's own state word ('Todo', 'Done', …) — their vocabulary, so
1221
+ * open text. Null until first synced. */
1222
+ issueState: z31.string().nullable(),
1223
+ title: z31.string(),
1224
+ body: z31.string(),
1225
+ severity: BugSeveritySchema,
1226
+ createdBy: z31.string(),
1227
+ createdAt: z31.string(),
1228
+ /**
1229
+ * When this bug was resolved from the console; null means still OPEN.
1230
+ *
1231
+ * Resolution belongs to the bug, not to the session: the session verdict
1232
+ * answers "did anyone look at this conversation", which says nothing about
1233
+ * whether a particular fault is still live. The timestamp IS the state, so
1234
+ * no boolean can contradict it.
1235
+ */
1236
+ resolvedAt: z31.string().nullable(),
1237
+ resolvedBy: z31.string().nullable()
1238
+ });
1239
+ var SpaceBugSchema = SessionBugSchema.extend({ sessionId: z31.string() });
1240
+ var SessionCommentSchema = z31.object({
1241
+ id: z31.string().uuid(),
1242
+ /** Set = a reply in that bug's thread. Null = a standalone comment pin. */
1243
+ bugId: z31.string().uuid().nullable(),
1244
+ /** 1-based turn the comment was left on; null for a reply (it reads its
1245
+ * parent bug's turn). */
1246
+ turnIndex: z31.number().int().nullable(),
1247
+ /** The canvas anchor for a STANDALONE comment's own pin; null for a reply. */
1248
+ location: BugLocationSchema.nullable(),
1249
+ body: z31.string(),
1250
+ createdBy: z31.string(),
1251
+ createdAt: z31.string()
1252
+ });
1253
+ var CreateCommentInputSchema = z31.object({
1254
+ bugId: z31.string().uuid().nullable(),
1255
+ turnIndex: z31.number().int().positive().nullable(),
1256
+ location: BugLocationSchema.nullable(),
1257
+ // Trimmed, so whitespace is not content: `.min(1)` alone accepted a comment
1258
+ // of three spaces, which renders as an empty bubble nobody can interpret.
1259
+ body: z31.string().trim().min(1)
1260
+ }).refine((input) => input.bugId === null !== (input.location === null), {
1261
+ message: "a comment is either a reply (bugId, no location) or a standalone pin (location, no bugId)"
1262
+ });
1263
+ var UpdateCommentInputSchema = z31.object({
1264
+ body: z31.string().trim().min(1).optional(),
1265
+ bugId: z31.string().uuid().nullable().optional(),
1266
+ location: BugLocationSchema.nullable().optional()
1267
+ });
1268
+ var SessionFormFactorSchema = z31.enum(["mobile", "desktop"]).nullable();
1269
+ var SessionSummarySchema = z31.object({
1270
+ sessionId: z31.string(),
1271
+ /** Stable per-browser id — the join key across a visitor's sessions. Null when
1272
+ * the session row is gone (pruned) or predates the `sessions` table. */
1273
+ visitorId: z31.string().nullable(),
1274
+ /** Provider-qualified identity anchor, present only once the visitor
1275
+ * identified themselves. Both null together means "not identified yet". */
1276
+ identityProvider: z31.string().nullable(),
1277
+ identityKey: z31.string().nullable(),
1278
+ /** Team/test traffic. The queue hides these by default. */
1279
+ isInternal: z31.boolean(),
1280
+ /** Build that served the session. Null = not captured; a version filter must
1281
+ * therefore EXCLUDE it rather than let it match an arbitrary bucket. */
1282
+ clientVersion: z31.string().nullable(),
1283
+ /** Commit-shaped interaction signals, counted, keyed by open `SignalType`. */
1284
+ signalCounts: z31.record(z31.number()),
1285
+ /**
1286
+ * Did this conversation ACQUIRE anything, and how many times?
1287
+ *
1288
+ * The count of DISTINCT acquisition attempts on the session's client-event
1289
+ * rail — the same population, at the same grain, that the analytics funnel's
1290
+ * `cart` step counts (`client_sessions_scoped`, and the migration that made a
1291
+ * registry hand-off count alongside an on-site add). Reading both surfaces
1292
+ * from one definition is the point: `signalCounts` above is the AGENT'S
1293
+ * announcement, and a registry hand-off announces nothing, so this is the
1294
+ * only field on the row that can answer the question for a space whose
1295
+ * visitors convert off-site.
1296
+ *
1297
+ * NULL means NOT MEASURED — a console talking to a queue function that
1298
+ * predates the column — and renders as no mark at all. It never means zero:
1299
+ * zero is a real, recorded answer and the rail reports it as one.
1300
+ */
1301
+ conversionAttempts: z31.number().int().nullable(),
1302
+ /**
1303
+ * The same attempts split by EVENT KIND, keyed by the kind's own name
1304
+ * (`commerce.cart_line_added`, `commerce.registry_clicked`), counted distinct
1305
+ * WITHIN each kind.
1306
+ *
1307
+ * The kinds stay distinct even though the metric merges: an outbound click to
1308
+ * a partner and an on-site write are not the same act. The console renders
1309
+ * each key VERBATIM rather than translating it — the same discipline
1310
+ * `outcomeLabel` follows for signals, and what keeps the platform from
1311
+ * learning what either kind means (§XIII.4).
1312
+ *
1313
+ * Does NOT sum to `conversionAttempts`: that total is distinct over both
1314
+ * kinds together, and one attempt id appearing under both would be counted
1315
+ * once there and twice here.
1316
+ */
1317
+ conversionKinds: z31.record(z31.number()),
1318
+ /**
1319
+ * Every analytics funnel step this session reached, in funnel order — the
1320
+ * dashboard's own step ids, read by the same per-step predicates, so a queue
1321
+ * filtered to a step lists the sessions the dashboard counts there. An open
1322
+ * set of strings for the reason `conversionKinds` is: the contract does not
1323
+ * learn what a step means. Empty only when read from a pre-column database.
1324
+ */
1325
+ funnelSteps: z31.array(z31.string()),
1326
+ /**
1327
+ * The connector's opaque handle for what this session produced in its back
1328
+ * office — present only once a checkout actually reached the platform. The
1329
+ * console hands it to the back-office link registry; nothing else reads it.
1330
+ */
1331
+ backOfficeRef: z31.string().nullable(),
1332
+ /**
1333
+ * The order this session produced, when the connector's back office reported
1334
+ * it (`session_orders`): its opaque id and the back office's own name for it.
1335
+ * Both null when no order is known — the cart handle above is then the door.
1336
+ */
1337
+ orderRef: z31.string().nullable(),
1338
+ orderLabel: z31.string().nullable(),
1339
+ /**
1340
+ * Which shell this session rendered — the one thing about the CAPTURE a list
1341
+ * needs.
1342
+ *
1343
+ * The rest of the capture stays off the queue on purpose (§XIII.6: a list
1344
+ * representation carrying a detail representation's fields is how the two
1345
+ * stop being distinguishable). This is not that: it is a derived
1346
+ * classification, one word wide, and it changes how a reviewer reads every
1347
+ * other field in the row — a 3-turn session on a phone and a 3-turn session
1348
+ * on a desktop are not the same session.
1349
+ */
1350
+ formFactor: SessionFormFactorSchema,
1351
+ turnCount: z31.number().int(),
1352
+ /** The visitor's opening message — the single most informative field for
1353
+ * deciding whether a session is worth opening, hence the widest column. */
1354
+ firstPrompt: z31.string(),
1355
+ startedAt: z31.string(),
1356
+ lastRunAt: z31.string(),
1357
+ /**
1358
+ * The VISITOR's own IANA zone (`America/New_York`), read from their browser
1359
+ * at session create — what the two timestamps above should be read in.
1360
+ *
1361
+ * ── WHY THIS IS ON THE SUMMARY AND NOT THE CAPTURE (§XIII.6) ────────────
1362
+ *
1363
+ * It is not a detail about how the session was captured; it is the UNIT of a
1364
+ * field the summary already carries. A timestamp without its zone is money
1365
+ * without its currency, and this contract is emphatic about that everywhere
1366
+ * else — `cartValueMinor` never travels without `currency` and its exponent.
1367
+ * The queue renders `lastRunAt` in its own column, so a zone reachable only
1368
+ * from the detail would leave the list rendering an instant it cannot label.
1369
+ * `clientVersion` and `isInternal` are already read from the queue row for
1370
+ * the same kind of reason.
1371
+ *
1372
+ * Named `visitorTimeZone` and not `timeZone` because the console already has
1373
+ * another one: the analytics screen reports in the SPACE's reporting zone.
1374
+ * Two clocks with one name is how a screen ends up quietly mixing them.
1375
+ *
1376
+ * NULL means not captured, and every session recorded before 2026-09-06 is
1377
+ * null forever — `locale` spans three US hours and the ingest path keeps only
1378
+ * a keyed hash of the address, so it cannot be backfilled. The console
1379
+ * renders those in the READER's zone and says so.
1380
+ *
1381
+ * Client-asserted and never validated against a zone table, so every consumer
1382
+ * must tolerate an unknown name: `Intl` throws a RangeError on one.
1383
+ */
1384
+ visitorTimeZone: z31.string().nullable(),
1385
+ /**
1386
+ * Mean TIME TO FIRST PATCH, over the turns that recorded one — the first
1387
+ * layout op reaching the visitor, and THE latency the project is managed on.
1388
+ * mainDone is free to run long (a richer page costs mainDone, not this), and
1389
+ * `totalLatencyMs` carries the chip-gen tail that runs after the visitor is
1390
+ * already reading. Null when no turn in the session recorded a patch.
1391
+ */
1392
+ avgTtftMs: z31.number().int().nullable(),
1393
+ /** Mean `main_done_ms` — layout + prose complete. Context for the TTFT, not
1394
+ * a budget: null on sessions older than the mark's recording. */
1395
+ avgMainDoneMs: z31.number().int().nullable(),
1396
+ /** Mean `chip_gen_ms` — the pass that runs AFTER mainDone and is out of the
1397
+ * budget. On the row only to explain the gap to `totalLatencyMs`. */
1398
+ avgChipGenMs: z31.number().int().nullable(),
1399
+ totalLatencyMs: z31.number().int(),
1400
+ durationMs: z31.number().int(),
1401
+ /** Inferred from recent activity — nothing writes a session-end marker. A
1402
+ * live session streams and cannot be given a verdict until it ends. */
1403
+ isLive: z31.boolean(),
1404
+ verdict: SessionVerdictSchema,
1405
+ reviewedBy: z31.string().nullable(),
1406
+ reviewedAt: z31.string().nullable(),
1407
+ /** Latest filed bug, flattened onto the row so the queue can show its live
1408
+ * state without a second request. */
1409
+ bugIssueKey: z31.string().nullable(),
1410
+ bugIssueUrl: z31.string().nullable(),
1411
+ bugIssueState: z31.string().nullable()
1412
+ });
1413
+ var SessionQueuePageSchema = z31.object({
1414
+ sessions: z31.array(SessionSummarySchema),
1415
+ totalCount: z31.number().int(),
1416
+ hiddenInternalCount: z31.number().int(),
1417
+ /**
1418
+ * Bounced sessions the queue left out — no turn and no add, the default.
1419
+ *
1420
+ * This one IS rendered, because unlike the internal switch the omission is on
1421
+ * by default and a total that silently excluded most of a space's arrivals
1422
+ * would be the definitional gap the log's population was fixed to close.
1423
+ * `totalCount + hiddenBouncedCount` is that population, and this count is the
1424
+ * analytics dashboard's bounce over the same window.
1425
+ */
1426
+ hiddenBouncedCount: z31.number().int()
1427
+ });
1428
+ var SessionQueueFacetsSchema = z31.object({
1429
+ review: z31.record(z31.number()),
1430
+ version: z31.record(z31.number()),
1431
+ turns: z31.record(z31.number()),
1432
+ durationS: z31.record(z31.number()),
1433
+ /** Sessions per funnel step reached — a session counts under every step it reached. */
1434
+ funnel: z31.record(z31.number())
1435
+ });
1436
+ var SessionCaptureSchema = z31.object({
1437
+ viewportWidth: z31.number().int().nullable(),
1438
+ viewportHeight: z31.number().int().nullable(),
1439
+ userAgent: z31.string().nullable(),
1440
+ locale: z31.string().nullable(),
1441
+ /** Referrer at session create — separates agentic traffic from organic. */
1442
+ referrer: z31.string().nullable()
1443
+ });
1444
+ var SessionCaptureInputSchema = z31.object({
1445
+ viewportWidth: z31.number().int().positive().max(2e4).optional(),
1446
+ viewportHeight: z31.number().int().positive().max(2e4).optional(),
1447
+ userAgent: z31.string().max(1e3).optional(),
1448
+ locale: z31.string().max(35).optional(),
1449
+ /** IANA zone name from the visitor's browser. Bounded rather than validated:
1450
+ * the zone database grows, and refusing a name this build has not heard of
1451
+ * would drop a real session's capture over a table that is out of date. */
1452
+ timeZone: z31.string().max(64).optional(),
1453
+ referrer: z31.string().max(2048).optional(),
1454
+ clientVersion: z31.string().max(100).optional(),
1455
+ isInternal: z31.boolean().optional()
1456
+ });
1457
+ var SessionDetailSchema = z31.object({
1458
+ session: SessionSummarySchema,
1459
+ capture: SessionCaptureSchema,
1460
+ /** Full verdict history, newest first. Verdicts are revisable, and a session
1461
+ * re-judged after a fix is the evidence the fix worked. */
1462
+ reviews: z31.array(SessionReviewEventSchema),
1463
+ bugs: z31.array(SessionBugSchema),
1464
+ comments: z31.array(SessionCommentSchema),
1465
+ /** Optional during API/console rolling deployment. Absent is unavailable,
1466
+ * not evidence of zero visitor activity. */
1467
+ activity: SessionActivitySchema.optional()
1468
+ });
1469
+ var RecordVerdictInputSchema = z31.object({
1470
+ verdict: RecordableVerdictSchema,
1471
+ note: z31.string().max(2e3).optional()
1472
+ });
1473
+ var FileBugInputSchema = z31.object({
1474
+ turnIndex: z31.number().int().positive().nullable(),
1475
+ /** Optional — a bug filed without dropping a pin has no location. */
1476
+ location: BugLocationSchema.nullable().optional(),
1477
+ title: z31.string().min(1).max(300),
1478
+ body: z31.string().min(1),
1479
+ severity: BugSeveritySchema,
1480
+ payload: z31.record(z31.unknown())
1481
+ });
1482
+ export {
1483
+ PackageReleaseSchema,
1484
+ catalogToWire
1485
+ };