@40rty/ams-cli 0.5.0 → 0.5.1

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.
@@ -219,7 +219,9 @@ async function askCheck(config, check) {
219
219
  // The preview credential `forty dev` wrote opens a locked space, and its draft.
220
220
  const token = typeof env.FORTY_DEV_TOKEN === 'string' && env.FORTY_DEV_TOKEN !== '' ? env.FORTY_DEV_TOKEN : undefined;
221
221
  console.log(`\n- asking "${question}"${token === undefined ? '' : ' (with FORTY_DEV_TOKEN)'}…`);
222
- const turn = await askSpace({ apiUrl: config.apiUrl, slug: config.spaceSlug, token, question });
222
+ // The organization key fetches the socket ticket a deployment asks a script for.
223
+ const credential = await findCredential(config.apiUrl);
224
+ const turn = await askSpace({ apiUrl: config.apiUrl, slug: config.spaceSlug, token, apiKey: credential === null ? undefined : credential.key, question });
223
225
  if (turn.error !== undefined) {
224
226
  check(false, `the agent answered "${question}"`, turn.error);
225
227
  return;
@@ -5,6 +5,7 @@ import { buildBundle, loadBrandDefinition, loadCatalog, loadManifests, loadMark
5
5
  import { cwd, flag, option, readConfig } from '../lib/context.mjs';
6
6
  import { call } from '../lib/credentials.mjs';
7
7
  import { registerOrigin } from './origin.mjs';
8
+ import { resolvedSdkVersion } from '../lib/sdk-version.mjs';
8
9
 
9
10
  /** Everything a release carries, built from the repo as it is right now. */
10
11
  export async function buildRelease(config) {
@@ -23,6 +24,11 @@ export async function buildRelease(config) {
23
24
  manifests: await loadManifests(config.manifests),
24
25
  };
25
26
  if (config.bundle !== undefined) release.bundle = await buildBundle(config.bundle);
27
+ // The sdk this was built against: the platform picks the bundle's compat
28
+ // shims by it, and refuses one it cannot host.
29
+ const sdk = await resolvedSdkVersion(cwd);
30
+ if (sdk === undefined) console.warn('no @40rty/ams-sdk installed — the release records no sdk version and is hosted as legacy');
31
+ else release.builtWithSdk = sdk;
26
32
  // Optional, for a package the platform hosts: the class its stylesheet styles
27
33
  // under, and the canvas a fresh session opens on. A brand in the platform's
28
34
  // repository names its `brand.ts` instead, which also carries its prompt
@@ -0,0 +1,42 @@
1
+ // `forty publish` stamps a release with the sdk the brand project RESOLVES —
2
+ // found as Node finds a bare specifier, not read off the range in package.json.
3
+ import { mkdtemp, mkdir, rm, writeFile } from 'node:fs/promises';
4
+ import { tmpdir } from 'node:os';
5
+ import path from 'node:path';
6
+ import { afterEach, beforeEach, describe, expect, it } from 'vitest';
7
+ import { resolvedSdkVersion } from '../sdk-version.mjs';
8
+
9
+ let dir;
10
+ beforeEach(async () => {
11
+ dir = await mkdtemp(path.join(tmpdir(), 'forty-sdk-version-'));
12
+ });
13
+ afterEach(async () => {
14
+ await rm(dir, { recursive: true, force: true });
15
+ });
16
+
17
+ async function install(at, name, version) {
18
+ const pkg = path.join(at, 'node_modules', ...name.split('/'));
19
+ await mkdir(pkg, { recursive: true });
20
+ await writeFile(path.join(pkg, 'package.json'), JSON.stringify({ name, version }));
21
+ }
22
+
23
+ describe('resolvedSdkVersion', () => {
24
+ it('reads the installed @40rty/ams-sdk, walking up from a nested project', async () => {
25
+ await install(dir, '@40rty/ams-sdk', '0.4.2');
26
+ const project = path.join(dir, 'apps', 'brand');
27
+ await mkdir(project, { recursive: true });
28
+ await writeFile(path.join(project, 'package.json'), JSON.stringify({ dependencies: { '@40rty/ams-sdk': '^0.4.0' } }));
29
+ expect(await resolvedSdkVersion(project)).toBe('0.4.2');
30
+ });
31
+
32
+ it('prefers the nearest install', async () => {
33
+ await install(dir, '@40rty/ams-sdk', '0.3.0');
34
+ const project = path.join(dir, 'brand');
35
+ await install(project, '@40rty/ams-sdk', '0.5.0');
36
+ expect(await resolvedSdkVersion(project)).toBe('0.5.0');
37
+ });
38
+
39
+ it('is undefined when no sdk is installed', async () => {
40
+ expect(await resolvedSdkVersion(dir)).toBeUndefined();
41
+ });
42
+ });
package/bin/lib/ask.mjs CHANGED
@@ -1,11 +1,13 @@
1
1
  // One real visitor turn on the space — what `forty doctor --ask` runs.
2
2
  //
3
3
  // The same wire the spacefront uses: `POST /s/:slug/sessions` mints a session,
4
- // `GET /sessions/:id/init` (WebSocket, unlock bearer as `?token=`) carries a
4
+ // `GET /sessions/:id/init` (WebSocket, unlock bearer as `?token=`, socket
5
+ // ticket as `?ticket=` — minted for the organization key, since a deployment
6
+ // refuses a script's upgrade without one) carries a
5
7
  // `prompt` signal in and the turn's TraceEvents out. The turn is ours from the
6
8
  // `agent_ack` that echoes our `messageId`, and over at its `done` or `error`.
7
9
  import { randomUUID } from 'node:crypto';
8
- import { applySinglePatch, EMPTY_SPEC } from '../../dist/wire.js';
10
+ import { applySinglePatch, EMPTY_SPEC, WIRE_PROTOCOL_PARAM, WIRE_PROTOCOL_VERSION } from '../../dist/wire.js';
9
11
 
10
12
  /** A wire props-schema node, past the wrappers that do not change what it holds. */
11
13
  function unwrap(node) {
@@ -62,7 +64,20 @@ function isSpec(value) {
62
64
  * the turn produced: `{ before, layout, text, error }` — `error` is the
63
65
  * session's own words when it refused or failed.
64
66
  */
65
- export async function askSpace({ apiUrl, slug, token, question, timeoutMs = 60_000 }) {
67
+ /**
68
+ * A socket ticket for `slug`, fetched with the organization key. `null` when the
69
+ * deployment issues none (a local api) or there is no key to ask with — the dial
70
+ * then goes without, and a deployment says why in its refusal.
71
+ */
72
+ async function fetchSocketTicket(apiUrl, slug, apiKey) {
73
+ if (apiKey === undefined) return null;
74
+ const res = await fetch(`${apiUrl}/s/${encodeURIComponent(slug)}/socket-ticket`, { headers: { 'x-api-key': apiKey } });
75
+ if (!res.ok) throw new Error(`the socket ticket was refused (${res.status})`);
76
+ const body = await res.json();
77
+ return typeof body.ticket === 'string' && body.ticket !== '' ? body.ticket : null;
78
+ }
79
+
80
+ export async function askSpace({ apiUrl, slug, token, apiKey, question, timeoutMs = 60_000 }) {
66
81
  const headers = { 'content-type': 'application/json' };
67
82
  if (token !== undefined) headers['x-api-key'] = token;
68
83
  let res;
@@ -77,6 +92,13 @@ export async function askSpace({ apiUrl, slug, token, question, timeoutMs = 60_0
77
92
  const start = isSpec(session.layout) ? session.layout : isSpec(session.seedLayout) ? session.seedLayout : EMPTY_SPEC;
78
93
  const url = new URL(`${apiUrl.replace(/^http/, 'ws')}/sessions/${encodeURIComponent(session.sessionId)}/init`);
79
94
  if (token !== undefined) url.searchParams.set('token', token);
95
+ url.searchParams.set(WIRE_PROTOCOL_PARAM, String(WIRE_PROTOCOL_VERSION));
96
+ try {
97
+ const ticket = await fetchSocketTicket(apiUrl, slug, apiKey);
98
+ if (ticket !== null) url.searchParams.set('ticket', ticket);
99
+ } catch (err) {
100
+ return { error: `cannot open the session socket: ${err.message}` };
101
+ }
80
102
  const messageId = `msg-doctor-${randomUUID()}`;
81
103
 
82
104
  return new Promise((resolve) => {
@@ -0,0 +1,37 @@
1
+ // The sdk a release is built against — stamped on it as `builtWithSdk`, so the
2
+ // platform can tell which compat shims the bundle needs and whether it can host
3
+ // it at all (`sdk-compat.ts` in the wire contract).
4
+ import { readFile } from 'node:fs/promises';
5
+ import path from 'node:path';
6
+
7
+ /** The public name first; a brand inside the platform's repository imports the workspace one. */
8
+ const SDK_PACKAGES = ['@40rty/ams-sdk', '@fourty/sdk'];
9
+
10
+ async function versionAt(manifestPath) {
11
+ let raw;
12
+ try {
13
+ raw = await readFile(manifestPath, 'utf8');
14
+ } catch (err) {
15
+ if (err.code === 'ENOENT' || err.code === 'ENOTDIR') return undefined;
16
+ throw err;
17
+ }
18
+ const { version } = JSON.parse(raw);
19
+ return typeof version === 'string' && version !== '' ? version : undefined;
20
+ }
21
+
22
+ /**
23
+ * The version of the sdk the project at `from` RESOLVES — what its bundle was
24
+ * built and type-checked against — found the way Node resolves a bare
25
+ * specifier: the nearest `node_modules/<name>` walking up. Not the range in
26
+ * `package.json`, which names what it would accept, not what it got.
27
+ * `undefined` when the project has no sdk installed.
28
+ */
29
+ export async function resolvedSdkVersion(from) {
30
+ for (let dir = path.resolve(from); ; dir = path.dirname(dir)) {
31
+ for (const name of SDK_PACKAGES) {
32
+ const version = await versionAt(path.join(dir, 'node_modules', name, 'package.json'));
33
+ if (version !== undefined) return version;
34
+ }
35
+ if (path.dirname(dir) === dir) return undefined;
36
+ }
37
+ }
package/dist/wire.js CHANGED
@@ -840,7 +840,7 @@ function catalogToWire(catalog) {
840
840
  }
841
841
 
842
842
  // ../spacestation/src/catalog/wire/package-release.ts
843
- import { z as z23 } from "zod";
843
+ import { z as z24 } from "zod";
844
844
 
845
845
  // ../spacestation/src/catalog/wire/brand-mark.ts
846
846
  import { z as z22 } from "zod";
@@ -860,20 +860,33 @@ var BrandMarkSchema = z22.object({ square: BrandMarkFileSchema.optional(), wordm
860
860
  var BrandMarkImageSchema = z22.object({ src: z22.string().min(1), type: z22.enum(BRAND_MARK_TYPES) }).strict();
861
861
  var SpaceBrandMarkSchema = z22.object({ square: BrandMarkImageSchema.nullable(), wordmark: BrandMarkImageSchema.nullable() }).strict();
862
862
 
863
+ // ../spacestation/src/catalog/wire/sdk-compat.ts
864
+ import { z as z23 } from "zod";
865
+ var SDK_VERSION_PATTERN = /^\d{1,4}\.\d{1,4}\.\d{1,4}(-[0-9A-Za-z.]{1,32})?$/;
866
+ var SdkVersionSchema = z23.string().regex(SDK_VERSION_PATTERN, "an sdk version is major.minor.patch");
867
+
863
868
  // ../spacestation/src/catalog/wire/package-release.ts
864
869
  var RESERVED_SCOPES = ["@fourty/", "@40rty/"];
865
870
  var BUNDLE_ASSET_PATH = /^assets\/[A-Za-z0-9_-]+\.(woff2?|ttf|otf|png|jpe?g|svg|gif|webp)$/;
866
- var PackageReleaseSchema = z23.object({
871
+ var PackageReleaseSchema = z24.object({
867
872
  /** The id spaces name in `componentSources` — an npm-style package name. */
868
- sourceId: z23.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`),
869
- label: z23.string().min(1).max(120),
873
+ sourceId: z24.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`),
874
+ label: z24.string().min(1).max(120),
870
875
  /** The package's own version, as its repository states it — shown in the console. */
871
- version: z23.string().min(1).max(40),
876
+ version: z24.string().min(1).max(40),
872
877
  /** What this release changed, in the publisher's words (`forty publish --message`) — shown in the console's version list. */
873
- description: z23.string().min(1).max(500).optional(),
878
+ description: z24.string().min(1).max(500).optional(),
879
+ /**
880
+ * The `@40rty/ams-sdk` version the brand project resolved when `forty
881
+ * publish` built this release. A bundle takes the sdk from the page at
882
+ * runtime, so this is what tells the platform which compat shims it needs
883
+ * and whether it can host it at all (`sdk-compat.ts`). Absent on releases
884
+ * published before the stamp existed — those are legacy.
885
+ */
886
+ builtWithSdk: SdkVersionSchema.optional(),
874
887
  catalog: WireCatalogSchema,
875
888
  /** Component manifests by path under `catalogs/`, e.g. `catalogs/product/productGrid.md`. */
876
- manifests: z23.record(z23.string().regex(/^catalogs\/.+\.md$/, "a manifest path is catalogs/<\u2026>.md"), z23.string()),
889
+ manifests: z24.record(z24.string().regex(/^catalogs\/.+\.md$/, "a manifest path is catalogs/<\u2026>.md"), z24.string()),
877
890
  /**
878
891
  * The brand's components, built — present when the PLATFORM hosts this
879
892
  * brand's spacefront, absent when the brand hosts it in its own app. One
@@ -882,17 +895,17 @@ var PackageReleaseSchema = z23.object({
882
895
  * images — base64, keyed by the path the stylesheet's `url()` names, beside
883
896
  * it). It is served to browsers; the platform's servers never run it.
884
897
  */
885
- bundle: z23.object({
886
- js: z23.string().min(1),
887
- css: z23.string(),
888
- assets: z23.record(z23.string().regex(BUNDLE_ASSET_PATH, "an asset is assets/<name>.<font or image extension>"), z23.string().base64()).optional()
898
+ bundle: z24.object({
899
+ js: z24.string().min(1),
900
+ css: z24.string(),
901
+ assets: z24.record(z24.string().regex(BUNDLE_ASSET_PATH, "an asset is assets/<name>.<font or image extension>"), z24.string().base64()).optional()
889
902
  }).strict().optional(),
890
903
  /**
891
904
  * The class the spacefront root carries while this package is the space's.
892
905
  * The package's own stylesheet styles under it. Absent = the platform's
893
906
  * default theme class.
894
907
  */
895
- theme: z23.object({ themeClass: z23.string().regex(/^[a-z][a-z0-9-]*$/, "a theme class is lowercase letters, digits and hyphens") }).strict().optional(),
908
+ theme: z24.object({ themeClass: z24.string().regex(/^[a-z][a-z0-9-]*$/, "a theme class is lowercase letters, digits and hyphens") }).strict().optional(),
896
909
  /**
897
910
  * The brand's mark (`brand-mark.ts`). Sent as the files themselves; the
898
911
  * platform stores them content-addressed at ingest and keeps only their
@@ -905,63 +918,76 @@ var PackageReleaseSchema = z23.object({
905
918
  * The package's own composition guidance for its own components — prompt
906
919
  * markdown the agent reads, gated on the capabilities it names (`requires`).
907
920
  */
908
- promptSections: z23.array(z23.object({ id: z23.string().regex(/^[a-z0-9-]+$/), order: z23.number().int(), content: z23.string().min(1).max(2e4), requires: z23.array(z23.string()) }).strict()).max(10).optional(),
921
+ promptSections: z24.array(z24.object({ id: z24.string().regex(/^[a-z0-9-]+$/), order: z24.number().int(), content: z24.string().min(1).max(2e4), requires: z24.array(z24.string()) }).strict()).max(10).optional(),
909
922
  /**
910
923
  * Opaque per-vertical extension data (`BrandDefinition.config`): the
911
924
  * platform stays vertical-agnostic and the vertical's own code reads its keys.
912
925
  */
913
- config: z23.record(z23.string(), z23.unknown()).optional(),
926
+ config: z24.record(z24.string(), z24.unknown()).optional(),
914
927
  /**
915
928
  * Set by the platform, never by a publisher: this release is a DRAFT of the
916
929
  * package `of`, previewed on the space `space`. See `draftSourceId`.
917
930
  */
918
- draft: z23.object({ of: z23.string().min(1), space: z23.string().min(1) }).strict().optional()
931
+ draft: z24.object({ of: z24.string().min(1), space: z24.string().min(1) }).strict().optional()
919
932
  }).strict();
920
933
 
934
+ // ../spacestation/src/catalog/wire/package-bundle-ref.ts
935
+ import { z as z25 } from "zod";
936
+ var PackageBundleRefSchema = z25.object({
937
+ sourceId: z25.string(),
938
+ js: z25.string(),
939
+ css: z25.string(),
940
+ /** The brand's name for itself, and its package's version. */
941
+ label: z25.string(),
942
+ version: z25.string(),
943
+ /** The sdk the bundle was built against (`PackageRelease.builtWithSdk`) — absent for a legacy release. Picks its compat shims. */
944
+ builtWithSdk: SdkVersionSchema.optional()
945
+ });
946
+
921
947
  // ../spacestation/src/projection/projection.ts
922
- import { z as z24 } from "zod";
923
- var LateBoundValueSchema = z24.object({ fact: z24.literal(true) });
924
- var DirectiveValueSchema = z24.union([
925
- z24.string(),
926
- z24.number(),
927
- z24.boolean(),
948
+ import { z as z26 } from "zod";
949
+ var LateBoundValueSchema = z26.object({ fact: z26.literal(true) });
950
+ var DirectiveValueSchema = z26.union([
951
+ z26.string(),
952
+ z26.number(),
953
+ z26.boolean(),
928
954
  LateBoundValueSchema
929
955
  ]);
930
- var ProjectionDirectiveSchema = z24.object({
956
+ var ProjectionDirectiveSchema = z26.object({
931
957
  /** Keep only items whose axis values all match. Keyed by axis name
932
958
  * (e.g. `Size`); value is a literal or the `{fact:true}` marker. */
933
- isolateTo: z24.record(DirectiveValueSchema).optional(),
959
+ isolateTo: z26.record(DirectiveValueSchema).optional(),
934
960
  /** Isolate to EVERY axis the visitor has a stored fact for. The agent
935
961
  * emits this (it is vertical-agnostic — it cannot name axes); the
936
962
  * entity binding expands it against the entity's own axes + facts. */
937
- isolateToFacts: z24.boolean().optional(),
963
+ isolateToFacts: z26.boolean().optional(),
938
964
  /** Keep only items the entity binding reports as available. */
939
- availableOnly: z24.boolean().optional(),
965
+ availableOnly: z26.boolean().optional(),
940
966
  /** Cap the rendered count after filtering. */
941
- limit: z24.number().int().positive().optional()
967
+ limit: z26.number().int().positive().optional()
942
968
  });
943
- var ProjectionPreferencesSchema = z24.record(
944
- z24.union([ProjectionDirectiveSchema, z24.null()])
969
+ var ProjectionPreferencesSchema = z26.record(
970
+ z26.union([ProjectionDirectiveSchema, z26.null()])
945
971
  );
946
- var ProjectionSetPayloadSchema = z24.object({
947
- setAll: z24.union([ProjectionDirectiveSchema, z24.null()]).optional(),
972
+ var ProjectionSetPayloadSchema = z26.object({
973
+ setAll: z26.union([ProjectionDirectiveSchema, z26.null()]).optional(),
948
974
  set: ProjectionPreferencesSchema.optional()
949
975
  });
950
976
 
951
977
  // ../spacestation/src/focus/focus.ts
952
- import { z as z25 } from "zod";
953
- var FocusElementPayloadSchema = z25.object({
954
- elementId: z25.string().min(1)
978
+ import { z as z27 } from "zod";
979
+ var FocusElementPayloadSchema = z27.object({
980
+ elementId: z27.string().min(1)
955
981
  });
956
982
 
957
983
  // ../spacestation/src/view/continuation.ts
958
- import { z as z26 } from "zod";
959
- var ViewExtendPayloadSchema = z26.object({
960
- reason: z26.enum(["scroll_near_bottom"])
984
+ import { z as z28 } from "zod";
985
+ var ViewExtendPayloadSchema = z28.object({
986
+ reason: z28.enum(["scroll_near_bottom"])
961
987
  });
962
988
 
963
989
  // ../spacestation/src/attachment/attachment.ts
964
- import { z as z27 } from "zod";
990
+ import { z as z29 } from "zod";
965
991
  var ALLOWED_ATTACHMENT_TYPES = [
966
992
  "image/jpeg",
967
993
  "image/png",
@@ -973,34 +999,36 @@ var MAX_ATTACHMENT_BYTES = 10 * 1024 * 1024;
973
999
  function isAllowedAttachmentType(mime) {
974
1000
  return ALLOWED_ATTACHMENT_TYPES.includes(mime);
975
1001
  }
976
- var AttachmentRefSchema = z27.object({
977
- id: z27.string().min(1),
978
- mimeType: z27.string().refine(isAllowedAttachmentType, {
1002
+ var AttachmentRefSchema = z29.object({
1003
+ // A UUID, as `storeAttachment` mints it: the id becomes a storage path segment,
1004
+ // so nothing else — no `/`, no `..` — may reach that lookup.
1005
+ id: z29.string().uuid(),
1006
+ mimeType: z29.string().refine(isAllowedAttachmentType, {
979
1007
  message: "mimeType not on the attachment allow-list"
980
1008
  }),
981
- name: z27.string().min(1),
982
- size: z27.number().int().positive().max(MAX_ATTACHMENT_BYTES),
983
- url: z27.string().min(1)
1009
+ name: z29.string().min(1),
1010
+ size: z29.number().int().positive().max(MAX_ATTACHMENT_BYTES),
1011
+ url: z29.string().min(1)
984
1012
  });
985
- var AttachmentRefsSchema = z27.array(AttachmentRefSchema);
1013
+ var AttachmentRefsSchema = z29.array(AttachmentRefSchema);
986
1014
 
987
1015
  // ../spacestation/src/contracts/entry-context.ts
988
- import { z as z28 } from "zod";
1016
+ import { z as z30 } from "zod";
989
1017
  var ENTRY_CONTEXT_MAX_VALUE_CHARS = 200;
990
1018
  var ENTRY_CONTEXT_MAX_KEYS = 12;
991
1019
  var ENTRY_CONTEXT_MAX_NAMESPACES = 8;
992
1020
  var ENTRY_CONTEXT_MAX_NAME_CHARS = 64;
993
- var EntryContextValueSchema = z28.string().trim().min(1).max(ENTRY_CONTEXT_MAX_VALUE_CHARS);
994
- var EntryContextNameSchema = z28.string().trim().min(1).max(ENTRY_CONTEXT_MAX_NAME_CHARS);
995
- var EntryContextNamespaceSchema = z28.record(EntryContextNameSchema, EntryContextValueSchema).refine((entries) => Object.keys(entries).length <= ENTRY_CONTEXT_MAX_KEYS, {
1021
+ var EntryContextValueSchema = z30.string().trim().min(1).max(ENTRY_CONTEXT_MAX_VALUE_CHARS);
1022
+ var EntryContextNameSchema = z30.string().trim().min(1).max(ENTRY_CONTEXT_MAX_NAME_CHARS);
1023
+ var EntryContextNamespaceSchema = z30.record(EntryContextNameSchema, EntryContextValueSchema).refine((entries) => Object.keys(entries).length <= ENTRY_CONTEXT_MAX_KEYS, {
996
1024
  message: `at most ${ENTRY_CONTEXT_MAX_KEYS} entries per namespace`
997
1025
  });
998
- var EntryContextSchema = z28.record(EntryContextNameSchema, EntryContextNamespaceSchema).refine((namespaces) => Object.keys(namespaces).length <= ENTRY_CONTEXT_MAX_NAMESPACES, {
1026
+ var EntryContextSchema = z30.record(EntryContextNameSchema, EntryContextNamespaceSchema).refine((namespaces) => Object.keys(namespaces).length <= ENTRY_CONTEXT_MAX_NAMESPACES, {
999
1027
  message: `at most ${ENTRY_CONTEXT_MAX_NAMESPACES} entry-context namespaces`
1000
1028
  });
1001
1029
 
1002
1030
  // ../spacestation/src/contracts/session-arrival.ts
1003
- import { z as z29 } from "zod";
1031
+ import { z as z31 } from "zod";
1004
1032
  var SURFACES = [
1005
1033
  "spacefront",
1006
1034
  "embed",
@@ -1010,11 +1038,11 @@ var SURFACES = [
1010
1038
  "playground",
1011
1039
  "automation"
1012
1040
  ];
1013
- var SurfaceSchema = z29.enum(SURFACES);
1041
+ var SurfaceSchema = z31.enum(SURFACES);
1014
1042
  var CLICK_ID_KINDS = ["gclid", "fbclid", "msclkid", "wbraid", "gbraid"];
1015
- var ClickIdKindSchema = z29.enum(CLICK_ID_KINDS);
1043
+ var ClickIdKindSchema = z31.enum(CLICK_ID_KINDS);
1016
1044
  var VISITOR_ID_DURABILITIES = ["persisted", "ephemeral", "host_supplied"];
1017
- var VisitorIdDurabilitySchema = z29.enum(VISITOR_ID_DURABILITIES);
1045
+ var VisitorIdDurabilitySchema = z31.enum(VISITOR_ID_DURABILITIES);
1018
1046
  var TRAFFIC_BUCKETS = [
1019
1047
  "paid_google",
1020
1048
  "paid_meta",
@@ -1026,10 +1054,10 @@ var TRAFFIC_BUCKETS = [
1026
1054
  "direct",
1027
1055
  "unknown"
1028
1056
  ];
1029
- var TrafficBucketSchema = z29.enum(TRAFFIC_BUCKETS);
1057
+ var TrafficBucketSchema = z31.enum(TRAFFIC_BUCKETS);
1030
1058
  var ARRIVAL_MAX_VALUE_CHARS = 200;
1031
- var ArrivalValueSchema = z29.string().trim().min(1).max(ARRIVAL_MAX_VALUE_CHARS);
1032
- var SessionArrivalSchema = z29.object({
1059
+ var ArrivalValueSchema = z31.string().trim().min(1).max(ARRIVAL_MAX_VALUE_CHARS);
1060
+ var SessionArrivalSchema = z31.object({
1033
1061
  utmSource: ArrivalValueSchema.optional(),
1034
1062
  utmMedium: ArrivalValueSchema.optional(),
1035
1063
  utmCampaign: ArrivalValueSchema.optional(),
@@ -1062,37 +1090,41 @@ var ARRIVAL_PARAMS = [
1062
1090
  ...CLICK_ID_KINDS
1063
1091
  ];
1064
1092
 
1093
+ // ../spacestation/src/contracts/wire-protocol.ts
1094
+ var WIRE_PROTOCOL_VERSION = 1;
1095
+ var WIRE_PROTOCOL_PARAM = "protocol";
1096
+
1065
1097
  // ../spacestation/src/catalog/attribute-registry.ts
1066
- import { z as z30 } from "zod";
1067
- var AttributeScopeBucketSchema = z30.object({
1068
- scope: z30.string(),
1069
- needles: z30.array(z30.string()).readonly(),
1070
- label: z30.string().optional()
1098
+ import { z as z32 } from "zod";
1099
+ var AttributeScopeBucketSchema = z32.object({
1100
+ scope: z32.string(),
1101
+ needles: z32.array(z32.string()).readonly(),
1102
+ label: z32.string().optional()
1071
1103
  });
1072
- var AttributeScopeConfigSchema = z30.object({
1073
- facet: z30.string(),
1074
- buckets: z30.array(AttributeScopeBucketSchema).readonly(),
1075
- emptyScope: z30.string(),
1076
- noMatchScope: z30.string(),
1077
- ignoreValues: z30.array(z30.string()).readonly(),
1078
- emptyScopeLabel: z30.string().optional(),
1079
- noMatchScopeLabel: z30.string().optional()
1104
+ var AttributeScopeConfigSchema = z32.object({
1105
+ facet: z32.string(),
1106
+ buckets: z32.array(AttributeScopeBucketSchema).readonly(),
1107
+ emptyScope: z32.string(),
1108
+ noMatchScope: z32.string(),
1109
+ ignoreValues: z32.array(z32.string()).readonly(),
1110
+ emptyScopeLabel: z32.string().optional(),
1111
+ noMatchScopeLabel: z32.string().optional()
1080
1112
  });
1081
- var AttributeDefBaseSchema = z30.object({
1082
- description: z30.string().optional(),
1083
- durable: z30.boolean().optional(),
1084
- label: z30.string().optional()
1113
+ var AttributeDefBaseSchema = z32.object({
1114
+ description: z32.string().optional(),
1115
+ durable: z32.boolean().optional(),
1116
+ label: z32.string().optional()
1085
1117
  });
1086
- var AttributeDefSchema = z30.discriminatedUnion("kind", [
1087
- AttributeDefBaseSchema.extend({ kind: z30.literal("enum"), values: z30.array(z30.string()) }),
1088
- AttributeDefBaseSchema.extend({ kind: z30.literal("free_text") }),
1089
- AttributeDefBaseSchema.extend({ kind: z30.literal("date_or_season") }),
1090
- AttributeDefBaseSchema.extend({ kind: z30.literal("money_or_band") }),
1118
+ var AttributeDefSchema = z32.discriminatedUnion("kind", [
1119
+ AttributeDefBaseSchema.extend({ kind: z32.literal("enum"), values: z32.array(z32.string()) }),
1120
+ AttributeDefBaseSchema.extend({ kind: z32.literal("free_text") }),
1121
+ AttributeDefBaseSchema.extend({ kind: z32.literal("date_or_season") }),
1122
+ AttributeDefBaseSchema.extend({ kind: z32.literal("money_or_band") }),
1091
1123
  AttributeDefBaseSchema.extend({
1092
- kind: z30.literal("number"),
1093
- min: z30.number().optional(),
1094
- max: z30.number().optional(),
1095
- unit: z30.string().optional()
1124
+ kind: z32.literal("number"),
1125
+ min: z32.number().optional(),
1126
+ max: z32.number().optional(),
1127
+ unit: z32.string().optional()
1096
1128
  })
1097
1129
  ]);
1098
1130
 
@@ -1124,30 +1156,30 @@ var DEFAULT_SPACE_CONFIG = {
1124
1156
  };
1125
1157
 
1126
1158
  // ../spacestation/src/space/trace.ts
1127
- import { z as z31 } from "zod";
1128
- var RunTokenUsageSchema = z31.object({
1129
- input_tokens: z31.number().optional(),
1130
- output_tokens: z31.number().optional(),
1131
- cache_read_tokens: z31.number().optional()
1159
+ import { z as z33 } from "zod";
1160
+ var RunTokenUsageSchema = z33.object({
1161
+ input_tokens: z33.number().optional(),
1162
+ output_tokens: z33.number().optional(),
1163
+ cache_read_tokens: z33.number().optional()
1132
1164
  });
1133
- var TraceRecordSchema = z31.object({
1134
- id: z31.string().uuid(),
1135
- spaceId: z31.string().uuid().nullable(),
1136
- sessionId: z31.string(),
1165
+ var TraceRecordSchema = z33.object({
1166
+ id: z33.string().uuid(),
1167
+ spaceId: z33.string().uuid().nullable(),
1168
+ sessionId: z33.string(),
1137
1169
  /** OTP-verified visitor email the session was unlocked with, or `null`
1138
1170
  * for an unlocked space / anonymous unlock. */
1139
- visitorEmail: z31.string().nullable(),
1140
- userPrompt: z31.string(),
1141
- branch: z31.string().nullable(),
1142
- responseText: z31.string().nullable(),
1143
- layout: z31.unknown().nullable(),
1144
- phaseTimings: z31.record(z31.number()).nullable(),
1145
- tokensByModel: z31.record(RunTokenUsageSchema).nullable(),
1146
- toolCalls: z31.array(z31.unknown()).nullable(),
1147
- diagnostics: z31.array(z31.unknown()).nullable(),
1148
- latencyFirstText: z31.number().int().nullable(),
1149
- latencyFirstPatch: z31.number().int().nullable(),
1150
- latencyTotal: z31.number().int().nullable(),
1171
+ visitorEmail: z33.string().nullable(),
1172
+ userPrompt: z33.string(),
1173
+ branch: z33.string().nullable(),
1174
+ responseText: z33.string().nullable(),
1175
+ layout: z33.unknown().nullable(),
1176
+ phaseTimings: z33.record(z33.number()).nullable(),
1177
+ tokensByModel: z33.record(RunTokenUsageSchema).nullable(),
1178
+ toolCalls: z33.array(z33.unknown()).nullable(),
1179
+ diagnostics: z33.array(z33.unknown()).nullable(),
1180
+ latencyFirstText: z33.number().int().nullable(),
1181
+ latencyFirstPatch: z33.number().int().nullable(),
1182
+ latencyTotal: z33.number().int().nullable(),
1151
1183
  /**
1152
1184
  * The CLIENT's turn id for this run, or `null`.
1153
1185
  *
@@ -1163,29 +1195,29 @@ var TraceRecordSchema = z31.object({
1163
1195
  * a turn whose ack the client never saw — none of which is evidence that a
1164
1196
  * visitor asked something and got nothing.
1165
1197
  */
1166
- turnId: z31.string().nullable(),
1198
+ turnId: z33.string().nullable(),
1167
1199
  /** Serialized `TraceTracker.exportState()` payload (parsed object) —
1168
1200
  * lets the inspector rehydrate this run verbatim after a reload. */
1169
- trackerState: z31.unknown().nullable(),
1170
- createdAt: z31.string()
1201
+ trackerState: z33.unknown().nullable(),
1202
+ createdAt: z33.string()
1171
1203
  });
1172
- var MillisecondsSchema = z31.number().nullable().transform((v) => v === null ? null : Math.round(v));
1173
- var CreateTraceInputSchema = z31.object({
1174
- spaceId: z31.string().uuid().nullable(),
1175
- sessionId: z31.string(),
1176
- visitorEmail: z31.string().nullable(),
1177
- userPrompt: z31.string(),
1178
- branch: z31.string().nullable(),
1179
- responseText: z31.string().nullable(),
1180
- layout: z31.unknown().nullable(),
1181
- phaseTimings: z31.record(z31.number()).nullable(),
1182
- tokensByModel: z31.record(RunTokenUsageSchema).nullable(),
1183
- toolCalls: z31.array(z31.unknown()).nullable(),
1184
- diagnostics: z31.array(z31.unknown()).nullable(),
1204
+ var MillisecondsSchema = z33.number().nullable().transform((v) => v === null ? null : Math.round(v));
1205
+ var CreateTraceInputSchema = z33.object({
1206
+ spaceId: z33.string().uuid().nullable(),
1207
+ sessionId: z33.string(),
1208
+ visitorEmail: z33.string().nullable(),
1209
+ userPrompt: z33.string(),
1210
+ branch: z33.string().nullable(),
1211
+ responseText: z33.string().nullable(),
1212
+ layout: z33.unknown().nullable(),
1213
+ phaseTimings: z33.record(z33.number()).nullable(),
1214
+ tokensByModel: z33.record(RunTokenUsageSchema).nullable(),
1215
+ toolCalls: z33.array(z33.unknown()).nullable(),
1216
+ diagnostics: z33.array(z33.unknown()).nullable(),
1185
1217
  latencyFirstText: MillisecondsSchema,
1186
1218
  latencyFirstPatch: MillisecondsSchema,
1187
1219
  latencyTotal: MillisecondsSchema,
1188
- trackerState: z31.unknown().nullable(),
1220
+ trackerState: z33.unknown().nullable(),
1189
1221
  /**
1190
1222
  * The CLIENT's turn id for this run, or `null`.
1191
1223
  *
@@ -1201,37 +1233,37 @@ var CreateTraceInputSchema = z31.object({
1201
1233
  * a turn whose ack the client never saw — none of which is evidence that a
1202
1234
  * visitor asked something and got nothing.
1203
1235
  */
1204
- turnId: z31.string().nullable()
1236
+ turnId: z33.string().nullable()
1205
1237
  });
1206
- var AgentSessionSummarySchema = z31.object({
1207
- sessionId: z31.string(),
1238
+ var AgentSessionSummarySchema = z33.object({
1239
+ sessionId: z33.string(),
1208
1240
  /** Turn rows only; background/secondary runs are excluded by the aggregate. */
1209
- turnCount: z31.number().int(),
1241
+ turnCount: z33.number().int(),
1210
1242
  /** The session's opening prompt — titles the row in the UI. */
1211
- firstPrompt: z31.string(),
1212
- startedAt: z31.string(),
1213
- lastRunAt: z31.string(),
1243
+ firstPrompt: z33.string(),
1244
+ startedAt: z33.string(),
1245
+ lastRunAt: z33.string(),
1214
1246
  /** Summed `latency_total` across the session's turns. */
1215
- totalLatencyMs: z31.number().int()
1247
+ totalLatencyMs: z33.number().int()
1216
1248
  });
1217
- var SessionTurnSchema = z31.object({
1218
- id: z31.string().uuid(),
1219
- userPrompt: z31.string(),
1220
- responseText: z31.string().nullable(),
1249
+ var SessionTurnSchema = z33.object({
1250
+ id: z33.string().uuid(),
1251
+ userPrompt: z33.string(),
1252
+ responseText: z33.string().nullable(),
1221
1253
  /** Full cumulative Spec committed by this turn — never a patch delta. */
1222
- layout: z31.unknown().nullable(),
1223
- createdAt: z31.string(),
1224
- latencyTotal: z31.number().int().nullable(),
1225
- phaseTimings: z31.record(z31.number()).nullable(),
1226
- tokensByModel: z31.record(z31.object({
1227
- input_tokens: z31.number().optional(),
1228
- output_tokens: z31.number().optional()
1254
+ layout: z33.unknown().nullable(),
1255
+ createdAt: z33.string(),
1256
+ latencyTotal: z33.number().int().nullable(),
1257
+ phaseTimings: z33.record(z33.number()).nullable(),
1258
+ tokensByModel: z33.record(z33.object({
1259
+ input_tokens: z33.number().optional(),
1260
+ output_tokens: z33.number().optional()
1229
1261
  })).nullable(),
1230
- toolCalls: z31.array(z31.unknown()).nullable(),
1231
- diagnostics: z31.array(z31.unknown()).nullable()
1262
+ toolCalls: z33.array(z33.unknown()).nullable(),
1263
+ diagnostics: z33.array(z33.unknown()).nullable()
1232
1264
  });
1233
- var SessionReplaySchema = z31.object({
1234
- turns: z31.array(SessionTurnSchema),
1265
+ var SessionReplaySchema = z33.object({
1266
+ turns: z33.array(SessionTurnSchema),
1235
1267
  /**
1236
1268
  * The session's own last-committed layout, read straight off the durable
1237
1269
  * session record (`sessions.blob.layout`) rather than derived from `turns`.
@@ -1242,20 +1274,20 @@ var SessionReplaySchema = z31.object({
1242
1274
  * a perfectly real layout; only this field can show it. Null exclusively
1243
1275
  * when the durable session row itself could not be read.
1244
1276
  */
1245
- sessionLayout: z31.record(z31.string(), z31.unknown()).nullable()
1277
+ sessionLayout: z33.record(z33.string(), z33.unknown()).nullable()
1246
1278
  });
1247
- var SessionTraceSchema = z31.object({
1248
- trackerState: z31.string().nullable()
1279
+ var SessionTraceSchema = z33.object({
1280
+ trackerState: z33.string().nullable()
1249
1281
  });
1250
- var LlmUsageDailySchema = z31.object({
1251
- day: z31.string(),
1282
+ var LlmUsageDailySchema = z33.object({
1283
+ day: z33.string(),
1252
1284
  /** Deployment that made the call — 'production', 'staging', 'pr-123', 'development'. */
1253
- environment: z31.string(),
1254
- feature: z31.string(),
1255
- model: z31.string(),
1256
- provider: z31.string(),
1285
+ environment: z33.string(),
1286
+ feature: z33.string(),
1287
+ model: z33.string(),
1288
+ provider: z33.string(),
1257
1289
  /** Masked tail of the key actually billed, or null when unknown/non-Google. */
1258
- keyFingerprint: z31.string().nullable(),
1290
+ keyFingerprint: z33.string().nullable(),
1259
1291
  /**
1260
1292
  * The space the call served, or null when it served none.
1261
1293
  *
@@ -1264,91 +1296,91 @@ var LlmUsageDailySchema = z31.object({
1264
1296
  * report that share rather than dropping it, or a per-space total reads as
1265
1297
  * the platform total.
1266
1298
  */
1267
- spaceId: z31.string().nullable(),
1299
+ spaceId: z33.string().nullable(),
1268
1300
  /**
1269
1301
  * The surface of the session the call served (`sessions.surface`), or null
1270
1302
  * when it served no session or the session predates surface recording.
1271
1303
  * `automation` is the eval harness — the signal that files an ordinary
1272
1304
  * `agent-turn` as testing spend rather than as a visitor's.
1273
1305
  */
1274
- surface: z31.string().nullable(),
1275
- inputTokens: z31.number(),
1276
- outputTokens: z31.number(),
1306
+ surface: z33.string().nullable(),
1307
+ inputTokens: z33.number(),
1308
+ outputTokens: z33.number(),
1277
1309
  /** Subset of inputTokens, never additional to it. */
1278
- cachedInputTokens: z31.number(),
1279
- reasoningTokens: z31.number(),
1280
- callCount: z31.number(),
1281
- errorCount: z31.number(),
1282
- estimatedCostUsd: z31.number().nullable()
1310
+ cachedInputTokens: z33.number(),
1311
+ reasoningTokens: z33.number(),
1312
+ callCount: z33.number(),
1313
+ errorCount: z33.number(),
1314
+ estimatedCostUsd: z33.number().nullable()
1283
1315
  });
1284
- var LlmUsageBySessionSchema = z31.object({
1285
- sessionId: z31.string(),
1286
- environment: z31.string(),
1287
- model: z31.string(),
1316
+ var LlmUsageBySessionSchema = z33.object({
1317
+ sessionId: z33.string(),
1318
+ environment: z33.string(),
1319
+ model: z33.string(),
1288
1320
  /** The space this session belongs to, or null for a session with no space. */
1289
- spaceId: z31.string().nullable(),
1321
+ spaceId: z33.string().nullable(),
1290
1322
  /** The session's surface — see `LlmUsageDailySchema.surface`. */
1291
- surface: z31.string().nullable(),
1323
+ surface: z33.string().nullable(),
1292
1324
  /** Label only — the first feature seen in the session. */
1293
- firstFeature: z31.string(),
1294
- startedAt: z31.string(),
1295
- endedAt: z31.string(),
1296
- inputTokens: z31.number(),
1297
- outputTokens: z31.number(),
1298
- cachedInputTokens: z31.number(),
1299
- reasoningTokens: z31.number(),
1300
- callCount: z31.number(),
1301
- errorCount: z31.number(),
1325
+ firstFeature: z33.string(),
1326
+ startedAt: z33.string(),
1327
+ endedAt: z33.string(),
1328
+ inputTokens: z33.number(),
1329
+ outputTokens: z33.number(),
1330
+ cachedInputTokens: z33.number(),
1331
+ reasoningTokens: z33.number(),
1332
+ callCount: z33.number(),
1333
+ errorCount: z33.number(),
1302
1334
  /** Priced server-side, like the daily rollup — the browser never carries a
1303
1335
  * rate table, so there is exactly one place a price can be wrong. Null when
1304
1336
  * the model is unpriced; never 0, which would read as free. */
1305
- estimatedCostUsd: z31.number().nullable()
1337
+ estimatedCostUsd: z33.number().nullable()
1306
1338
  });
1307
- var LlmSessionsDailySchema = z31.object({
1308
- day: z31.string(),
1309
- environment: z31.string(),
1310
- sessionCount: z31.number()
1339
+ var LlmSessionsDailySchema = z33.object({
1340
+ day: z33.string(),
1341
+ environment: z33.string(),
1342
+ sessionCount: z33.number()
1311
1343
  });
1312
1344
 
1313
1345
  // ../spacestation/src/space/session-queue.ts
1314
- import { z as z33 } from "zod";
1346
+ import { z as z35 } from "zod";
1315
1347
 
1316
1348
  // ../spacestation/src/space/session-activity.ts
1317
- import { z as z32 } from "zod";
1318
- var SessionActivityEventSchema = z32.object({
1319
- id: z32.string(),
1320
- kind: z32.string(),
1321
- occurredAt: z32.string(),
1322
- source: z32.string(),
1323
- surface: z32.string(),
1324
- payload: z32.record(z32.unknown())
1349
+ import { z as z34 } from "zod";
1350
+ var SessionActivityEventSchema = z34.object({
1351
+ id: z34.string(),
1352
+ kind: z34.string(),
1353
+ occurredAt: z34.string(),
1354
+ source: z34.string(),
1355
+ surface: z34.string(),
1356
+ payload: z34.record(z34.unknown())
1325
1357
  });
1326
- var SessionActivitySchema = z32.object({
1327
- events: z32.array(SessionActivityEventSchema),
1328
- hasMore: z32.boolean()
1358
+ var SessionActivitySchema = z34.object({
1359
+ events: z34.array(SessionActivityEventSchema),
1360
+ hasMore: z34.boolean()
1329
1361
  });
1330
1362
 
1331
1363
  // ../spacestation/src/space/session-queue.ts
1332
- var SessionVerdictSchema = z33.enum(["unreviewed", "viewed", "bug"]);
1333
- var RecordableVerdictSchema = z33.enum(["viewed", "bug"]);
1334
- var SessionReviewEventSchema = z33.object({
1335
- id: z33.string().uuid(),
1364
+ var SessionVerdictSchema = z35.enum(["unreviewed", "viewed", "bug"]);
1365
+ var RecordableVerdictSchema = z35.enum(["viewed", "bug"]);
1366
+ var SessionReviewEventSchema = z35.object({
1367
+ id: z35.string().uuid(),
1336
1368
  verdict: RecordableVerdictSchema,
1337
1369
  /** Account email of the operator who judged it. Attribution is the reason the
1338
1370
  * log is append-only rather than a mutable current-state row. */
1339
- reviewer: z33.string(),
1340
- note: z33.string().nullable(),
1341
- createdAt: z33.string()
1371
+ reviewer: z35.string(),
1372
+ note: z35.string().nullable(),
1373
+ createdAt: z35.string()
1342
1374
  });
1343
- var BugSeveritySchema = z33.enum(["high", "medium", "low"]);
1344
- var BugLocationSchema = z33.object({
1345
- elementId: z33.string().nullable(),
1375
+ var BugSeveritySchema = z35.enum(["high", "medium", "low"]);
1376
+ var BugLocationSchema = z35.object({
1377
+ elementId: z35.string().nullable(),
1346
1378
  /** Display only — the catalog component type, e.g. "productGrid". Null
1347
1379
  * alongside a null `elementId`. */
1348
- elementType: z33.string().nullable(),
1380
+ elementType: z35.string().nullable(),
1349
1381
  /** Fraction of the ELEMENT's own box. Null for a page anchor. */
1350
- offsetXPct: z33.number().min(0).max(100).nullable(),
1351
- offsetYPct: z33.number().min(0).max(100).nullable(),
1382
+ offsetXPct: z35.number().min(0).max(100).nullable(),
1383
+ offsetYPct: z35.number().min(0).max(100).nullable(),
1352
1384
  /**
1353
1385
  * ABSOLUTE document pixels, for a pin with no element under it. Null for an
1354
1386
  * element anchor.
@@ -1359,8 +1391,8 @@ var BugLocationSchema = z33.object({
1359
1391
  * on the page with it. Measured before this was fixed: growing the page 9%
1360
1392
  * slid a pin 32px, so a pin ran away from the cursor reaching for it.
1361
1393
  */
1362
- pageX: z33.number().nullable(),
1363
- pageY: z33.number().nullable()
1394
+ pageX: z35.number().nullable(),
1395
+ pageY: z35.number().nullable()
1364
1396
  }).refine(
1365
1397
  (loc) => {
1366
1398
  const hasOffsets = loc.offsetXPct !== null && loc.offsetYPct !== null;
@@ -1374,24 +1406,24 @@ var BugLocationSchema = z33.object({
1374
1406
  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)"
1375
1407
  }
1376
1408
  );
1377
- var SessionBugSchema = z33.object({
1378
- id: z33.string().uuid(),
1409
+ var SessionBugSchema = z35.object({
1410
+ id: z35.string().uuid(),
1379
1411
  /** 1-based turn the fault was observed on; null when the fault is session-wide. */
1380
- turnIndex: z33.number().int().nullable(),
1412
+ turnIndex: z35.number().int().nullable(),
1381
1413
  /** Where on that turn's canvas the pin was dropped; null for a bug filed
1382
1414
  * without pinning a spot. */
1383
1415
  location: BugLocationSchema.nullable(),
1384
- provider: z33.string(),
1385
- issueKey: z33.string().nullable(),
1386
- issueUrl: z33.string().nullable(),
1416
+ provider: z35.string(),
1417
+ issueKey: z35.string().nullable(),
1418
+ issueUrl: z35.string().nullable(),
1387
1419
  /** The tracker's own state word ('Todo', 'Done', …) — their vocabulary, so
1388
1420
  * open text. Null until first synced. */
1389
- issueState: z33.string().nullable(),
1390
- title: z33.string(),
1391
- body: z33.string(),
1421
+ issueState: z35.string().nullable(),
1422
+ title: z35.string(),
1423
+ body: z35.string(),
1392
1424
  severity: BugSeveritySchema,
1393
- createdBy: z33.string(),
1394
- createdAt: z33.string(),
1425
+ createdBy: z35.string(),
1426
+ createdAt: z35.string(),
1395
1427
  /**
1396
1428
  * When this bug was resolved from the console; null means still OPEN.
1397
1429
  *
@@ -1400,55 +1432,55 @@ var SessionBugSchema = z33.object({
1400
1432
  * whether a particular fault is still live. The timestamp IS the state, so
1401
1433
  * no boolean can contradict it.
1402
1434
  */
1403
- resolvedAt: z33.string().nullable(),
1404
- resolvedBy: z33.string().nullable()
1435
+ resolvedAt: z35.string().nullable(),
1436
+ resolvedBy: z35.string().nullable()
1405
1437
  });
1406
- var SpaceBugSchema = SessionBugSchema.extend({ sessionId: z33.string() });
1407
- var SessionCommentSchema = z33.object({
1408
- id: z33.string().uuid(),
1438
+ var SpaceBugSchema = SessionBugSchema.extend({ sessionId: z35.string() });
1439
+ var SessionCommentSchema = z35.object({
1440
+ id: z35.string().uuid(),
1409
1441
  /** Set = a reply in that bug's thread. Null = a standalone comment pin. */
1410
- bugId: z33.string().uuid().nullable(),
1442
+ bugId: z35.string().uuid().nullable(),
1411
1443
  /** 1-based turn the comment was left on; null for a reply (it reads its
1412
1444
  * parent bug's turn). */
1413
- turnIndex: z33.number().int().nullable(),
1445
+ turnIndex: z35.number().int().nullable(),
1414
1446
  /** The canvas anchor for a STANDALONE comment's own pin; null for a reply. */
1415
1447
  location: BugLocationSchema.nullable(),
1416
- body: z33.string(),
1417
- createdBy: z33.string(),
1418
- createdAt: z33.string()
1448
+ body: z35.string(),
1449
+ createdBy: z35.string(),
1450
+ createdAt: z35.string()
1419
1451
  });
1420
- var CreateCommentInputSchema = z33.object({
1421
- bugId: z33.string().uuid().nullable(),
1422
- turnIndex: z33.number().int().positive().nullable(),
1452
+ var CreateCommentInputSchema = z35.object({
1453
+ bugId: z35.string().uuid().nullable(),
1454
+ turnIndex: z35.number().int().positive().nullable(),
1423
1455
  location: BugLocationSchema.nullable(),
1424
1456
  // Trimmed, so whitespace is not content: `.min(1)` alone accepted a comment
1425
1457
  // of three spaces, which renders as an empty bubble nobody can interpret.
1426
- body: z33.string().trim().min(1)
1458
+ body: z35.string().trim().min(1)
1427
1459
  }).refine((input) => input.bugId === null !== (input.location === null), {
1428
1460
  message: "a comment is either a reply (bugId, no location) or a standalone pin (location, no bugId)"
1429
1461
  });
1430
- var UpdateCommentInputSchema = z33.object({
1431
- body: z33.string().trim().min(1).optional(),
1432
- bugId: z33.string().uuid().nullable().optional(),
1462
+ var UpdateCommentInputSchema = z35.object({
1463
+ body: z35.string().trim().min(1).optional(),
1464
+ bugId: z35.string().uuid().nullable().optional(),
1433
1465
  location: BugLocationSchema.nullable().optional()
1434
1466
  });
1435
- var SessionFormFactorSchema = z33.enum(["mobile", "desktop"]).nullable();
1436
- var SessionSummarySchema = z33.object({
1437
- sessionId: z33.string(),
1467
+ var SessionFormFactorSchema = z35.enum(["mobile", "desktop"]).nullable();
1468
+ var SessionSummarySchema = z35.object({
1469
+ sessionId: z35.string(),
1438
1470
  /** Stable per-browser id — the join key across a visitor's sessions. Null when
1439
1471
  * the session row is gone (pruned) or predates the `sessions` table. */
1440
- visitorId: z33.string().nullable(),
1472
+ visitorId: z35.string().nullable(),
1441
1473
  /** Provider-qualified identity anchor, present only once the visitor
1442
1474
  * identified themselves. Both null together means "not identified yet". */
1443
- identityProvider: z33.string().nullable(),
1444
- identityKey: z33.string().nullable(),
1475
+ identityProvider: z35.string().nullable(),
1476
+ identityKey: z35.string().nullable(),
1445
1477
  /** Team/test traffic. The queue hides these by default. */
1446
- isInternal: z33.boolean(),
1478
+ isInternal: z35.boolean(),
1447
1479
  /** Build that served the session. Null = not captured; a version filter must
1448
1480
  * therefore EXCLUDE it rather than let it match an arbitrary bucket. */
1449
- clientVersion: z33.string().nullable(),
1481
+ clientVersion: z35.string().nullable(),
1450
1482
  /** Commit-shaped interaction signals, counted, keyed by open `SignalType`. */
1451
- signalCounts: z33.record(z33.number()),
1483
+ signalCounts: z35.record(z35.number()),
1452
1484
  /**
1453
1485
  * Did this conversation ACQUIRE anything, and how many times?
1454
1486
  *
@@ -1465,7 +1497,7 @@ var SessionSummarySchema = z33.object({
1465
1497
  * predates the column — and renders as no mark at all. It never means zero:
1466
1498
  * zero is a real, recorded answer and the rail reports it as one.
1467
1499
  */
1468
- conversionAttempts: z33.number().int().nullable(),
1500
+ conversionAttempts: z35.number().int().nullable(),
1469
1501
  /**
1470
1502
  * The same attempts split by EVENT KIND, keyed by the kind's own name
1471
1503
  * (`commerce.cart_line_added`, `commerce.registry_clicked`), counted distinct
@@ -1481,7 +1513,7 @@ var SessionSummarySchema = z33.object({
1481
1513
  * kinds together, and one attempt id appearing under both would be counted
1482
1514
  * once there and twice here.
1483
1515
  */
1484
- conversionKinds: z33.record(z33.number()),
1516
+ conversionKinds: z35.record(z35.number()),
1485
1517
  /**
1486
1518
  * Every analytics funnel step this session reached, in funnel order — the
1487
1519
  * dashboard's own step ids, read by the same per-step predicates, so a queue
@@ -1489,20 +1521,20 @@ var SessionSummarySchema = z33.object({
1489
1521
  * set of strings for the reason `conversionKinds` is: the contract does not
1490
1522
  * learn what a step means. Empty only when read from a pre-column database.
1491
1523
  */
1492
- funnelSteps: z33.array(z33.string()),
1524
+ funnelSteps: z35.array(z35.string()),
1493
1525
  /**
1494
1526
  * The connector's opaque handle for what this session produced in its back
1495
1527
  * office — present only once a checkout actually reached the platform. The
1496
1528
  * console hands it to the back-office link registry; nothing else reads it.
1497
1529
  */
1498
- backOfficeRef: z33.string().nullable(),
1530
+ backOfficeRef: z35.string().nullable(),
1499
1531
  /**
1500
1532
  * The order this session produced, when the connector's back office reported
1501
1533
  * it (`session_orders`): its opaque id and the back office's own name for it.
1502
1534
  * Both null when no order is known — the cart handle above is then the door.
1503
1535
  */
1504
- orderRef: z33.string().nullable(),
1505
- orderLabel: z33.string().nullable(),
1536
+ orderRef: z35.string().nullable(),
1537
+ orderLabel: z35.string().nullable(),
1506
1538
  /**
1507
1539
  * Which shell this session rendered — the one thing about the CAPTURE a list
1508
1540
  * needs.
@@ -1515,12 +1547,12 @@ var SessionSummarySchema = z33.object({
1515
1547
  * on a desktop are not the same session.
1516
1548
  */
1517
1549
  formFactor: SessionFormFactorSchema,
1518
- turnCount: z33.number().int(),
1550
+ turnCount: z35.number().int(),
1519
1551
  /** The visitor's opening message — the single most informative field for
1520
1552
  * deciding whether a session is worth opening, hence the widest column. */
1521
- firstPrompt: z33.string(),
1522
- startedAt: z33.string(),
1523
- lastRunAt: z33.string(),
1553
+ firstPrompt: z35.string(),
1554
+ startedAt: z35.string(),
1555
+ lastRunAt: z35.string(),
1524
1556
  /**
1525
1557
  * The VISITOR's own IANA zone (`America/New_York`), read from their browser
1526
1558
  * at session create — what the two timestamps above should be read in.
@@ -1548,7 +1580,7 @@ var SessionSummarySchema = z33.object({
1548
1580
  * Client-asserted and never validated against a zone table, so every consumer
1549
1581
  * must tolerate an unknown name: `Intl` throws a RangeError on one.
1550
1582
  */
1551
- visitorTimeZone: z33.string().nullable(),
1583
+ visitorTimeZone: z35.string().nullable(),
1552
1584
  /**
1553
1585
  * Mean TIME TO FIRST PATCH, over the turns that recorded one — the first
1554
1586
  * layout op reaching the visitor, and THE latency the project is managed on.
@@ -1556,31 +1588,31 @@ var SessionSummarySchema = z33.object({
1556
1588
  * `totalLatencyMs` carries the chip-gen tail that runs after the visitor is
1557
1589
  * already reading. Null when no turn in the session recorded a patch.
1558
1590
  */
1559
- avgTtftMs: z33.number().int().nullable(),
1591
+ avgTtftMs: z35.number().int().nullable(),
1560
1592
  /** Mean `main_done_ms` — layout + prose complete. Context for the TTFT, not
1561
1593
  * a budget: null on sessions older than the mark's recording. */
1562
- avgMainDoneMs: z33.number().int().nullable(),
1594
+ avgMainDoneMs: z35.number().int().nullable(),
1563
1595
  /** Mean `chip_gen_ms` — the pass that runs AFTER mainDone and is out of the
1564
1596
  * budget. On the row only to explain the gap to `totalLatencyMs`. */
1565
- avgChipGenMs: z33.number().int().nullable(),
1566
- totalLatencyMs: z33.number().int(),
1567
- durationMs: z33.number().int(),
1597
+ avgChipGenMs: z35.number().int().nullable(),
1598
+ totalLatencyMs: z35.number().int(),
1599
+ durationMs: z35.number().int(),
1568
1600
  /** Inferred from recent activity — nothing writes a session-end marker. A
1569
1601
  * live session streams and cannot be given a verdict until it ends. */
1570
- isLive: z33.boolean(),
1602
+ isLive: z35.boolean(),
1571
1603
  verdict: SessionVerdictSchema,
1572
- reviewedBy: z33.string().nullable(),
1573
- reviewedAt: z33.string().nullable(),
1604
+ reviewedBy: z35.string().nullable(),
1605
+ reviewedAt: z35.string().nullable(),
1574
1606
  /** Latest filed bug, flattened onto the row so the queue can show its live
1575
1607
  * state without a second request. */
1576
- bugIssueKey: z33.string().nullable(),
1577
- bugIssueUrl: z33.string().nullable(),
1578
- bugIssueState: z33.string().nullable()
1608
+ bugIssueKey: z35.string().nullable(),
1609
+ bugIssueUrl: z35.string().nullable(),
1610
+ bugIssueState: z35.string().nullable()
1579
1611
  });
1580
- var SessionQueuePageSchema = z33.object({
1581
- sessions: z33.array(SessionSummarySchema),
1582
- totalCount: z33.number().int(),
1583
- hiddenInternalCount: z33.number().int(),
1612
+ var SessionQueuePageSchema = z35.object({
1613
+ sessions: z35.array(SessionSummarySchema),
1614
+ totalCount: z35.number().int(),
1615
+ hiddenInternalCount: z35.number().int(),
1584
1616
  /**
1585
1617
  * Bounced sessions the queue left out — no turn and no add, the default.
1586
1618
  *
@@ -1590,65 +1622,67 @@ var SessionQueuePageSchema = z33.object({
1590
1622
  * `totalCount + hiddenBouncedCount` is that population, and this count is the
1591
1623
  * analytics dashboard's bounce over the same window.
1592
1624
  */
1593
- hiddenBouncedCount: z33.number().int()
1625
+ hiddenBouncedCount: z35.number().int()
1594
1626
  });
1595
- var SessionQueueFacetsSchema = z33.object({
1596
- review: z33.record(z33.number()),
1597
- version: z33.record(z33.number()),
1598
- turns: z33.record(z33.number()),
1599
- durationS: z33.record(z33.number()),
1627
+ var SessionQueueFacetsSchema = z35.object({
1628
+ review: z35.record(z35.number()),
1629
+ version: z35.record(z35.number()),
1630
+ turns: z35.record(z35.number()),
1631
+ durationS: z35.record(z35.number()),
1600
1632
  /** Sessions per funnel step reached — a session counts under every step it reached. */
1601
- funnel: z33.record(z33.number())
1633
+ funnel: z35.record(z35.number())
1602
1634
  });
1603
- var SessionCaptureSchema = z33.object({
1604
- viewportWidth: z33.number().int().nullable(),
1605
- viewportHeight: z33.number().int().nullable(),
1606
- userAgent: z33.string().nullable(),
1607
- locale: z33.string().nullable(),
1635
+ var SessionCaptureSchema = z35.object({
1636
+ viewportWidth: z35.number().int().nullable(),
1637
+ viewportHeight: z35.number().int().nullable(),
1638
+ userAgent: z35.string().nullable(),
1639
+ locale: z35.string().nullable(),
1608
1640
  /** Referrer at session create — separates agentic traffic from organic. */
1609
- referrer: z33.string().nullable()
1641
+ referrer: z35.string().nullable()
1610
1642
  });
1611
- var SessionCaptureInputSchema = z33.object({
1612
- viewportWidth: z33.number().int().positive().max(2e4).optional(),
1613
- viewportHeight: z33.number().int().positive().max(2e4).optional(),
1614
- userAgent: z33.string().max(1e3).optional(),
1615
- locale: z33.string().max(35).optional(),
1643
+ var SessionCaptureInputSchema = z35.object({
1644
+ viewportWidth: z35.number().int().positive().max(2e4).optional(),
1645
+ viewportHeight: z35.number().int().positive().max(2e4).optional(),
1646
+ userAgent: z35.string().max(1e3).optional(),
1647
+ locale: z35.string().max(35).optional(),
1616
1648
  /** IANA zone name from the visitor's browser. Bounded rather than validated:
1617
1649
  * the zone database grows, and refusing a name this build has not heard of
1618
1650
  * would drop a real session's capture over a table that is out of date. */
1619
- timeZone: z33.string().max(64).optional(),
1620
- referrer: z33.string().max(2048).optional(),
1621
- clientVersion: z33.string().max(100).optional(),
1622
- isInternal: z33.boolean().optional()
1651
+ timeZone: z35.string().max(64).optional(),
1652
+ referrer: z35.string().max(2048).optional(),
1653
+ clientVersion: z35.string().max(100).optional(),
1654
+ isInternal: z35.boolean().optional()
1623
1655
  });
1624
- var SessionDetailSchema = z33.object({
1656
+ var SessionDetailSchema = z35.object({
1625
1657
  session: SessionSummarySchema,
1626
1658
  capture: SessionCaptureSchema,
1627
1659
  /** Full verdict history, newest first. Verdicts are revisable, and a session
1628
1660
  * re-judged after a fix is the evidence the fix worked. */
1629
- reviews: z33.array(SessionReviewEventSchema),
1630
- bugs: z33.array(SessionBugSchema),
1631
- comments: z33.array(SessionCommentSchema),
1661
+ reviews: z35.array(SessionReviewEventSchema),
1662
+ bugs: z35.array(SessionBugSchema),
1663
+ comments: z35.array(SessionCommentSchema),
1632
1664
  /** Optional during API/console rolling deployment. Absent is unavailable,
1633
1665
  * not evidence of zero visitor activity. */
1634
1666
  activity: SessionActivitySchema.optional()
1635
1667
  });
1636
- var RecordVerdictInputSchema = z33.object({
1668
+ var RecordVerdictInputSchema = z35.object({
1637
1669
  verdict: RecordableVerdictSchema,
1638
- note: z33.string().max(2e3).optional()
1670
+ note: z35.string().max(2e3).optional()
1639
1671
  });
1640
- var FileBugInputSchema = z33.object({
1641
- turnIndex: z33.number().int().positive().nullable(),
1672
+ var FileBugInputSchema = z35.object({
1673
+ turnIndex: z35.number().int().positive().nullable(),
1642
1674
  /** Optional — a bug filed without dropping a pin has no location. */
1643
1675
  location: BugLocationSchema.nullable().optional(),
1644
- title: z33.string().min(1).max(300),
1645
- body: z33.string().min(1),
1676
+ title: z35.string().min(1).max(300),
1677
+ body: z35.string().min(1),
1646
1678
  severity: BugSeveritySchema,
1647
- payload: z33.record(z33.unknown())
1679
+ payload: z35.record(z35.unknown())
1648
1680
  });
1649
1681
  export {
1650
1682
  EMPTY_SPEC,
1651
1683
  PackageReleaseSchema,
1684
+ WIRE_PROTOCOL_PARAM,
1685
+ WIRE_PROTOCOL_VERSION,
1652
1686
  applySinglePatch,
1653
1687
  carriesShapeToken,
1654
1688
  catalogToWire
package/package.json CHANGED
@@ -15,7 +15,7 @@
15
15
  "peerDependencies": {
16
16
  "zod": "^3.25.0"
17
17
  },
18
- "version": "0.5.0",
18
+ "version": "0.5.1",
19
19
  "homepage": "https://docs.40rty.ai",
20
20
  "license": "UNLICENSED",
21
21
  "engines": {