@40rty/ams-cli 0.5.1 → 0.5.3

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.
@@ -23,7 +23,7 @@ export async function dev() {
23
23
  if ((await readConfigIfPresent()) === null) await init();
24
24
  const config = await readConfig();
25
25
 
26
- const files = [config.catalog, config.manifests];
26
+ const files = [config.catalog, ...(Array.isArray(config.manifests) ? config.manifests : [config.manifests])];
27
27
  if (config.bundle !== undefined) files.push(path.dirname(config.bundle.entry));
28
28
  if (config.bundle !== undefined && typeof config.bundle.css === 'string') files.push(config.bundle.css);
29
29
  if (typeof config.seedLayout === 'string') files.push(config.seedLayout);
@@ -1,7 +1,7 @@
1
1
  import { readFile } from 'node:fs/promises';
2
2
  import path from 'node:path';
3
3
  import { PackageReleaseSchema, carriesShapeToken, catalogToWire } from '../../dist/wire.js';
4
- import { buildBundle, loadBrandDefinition, loadCatalog, loadManifests, loadMark } from '../lib/build.mjs';
4
+ import { buildBundle, loadBrandDefinition, loadCatalog, loadManifests, loadMark, loadSpacePrompt } from '../lib/build.mjs';
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';
@@ -36,6 +36,9 @@ export async function buildRelease(config) {
36
36
  if (typeof config.brand === 'string') Object.assign(release, await loadBrandDefinition(config.brand, config.prompts));
37
37
  if (typeof config.theme === 'string') release.theme = { themeClass: config.theme };
38
38
  if (typeof config.seedLayout === 'string') release.seedLayout = JSON.parse(await readFile(path.join(cwd, config.seedLayout), 'utf8'));
39
+ // The brand's space prompt (`<prompts>/space.md`) — its spaces' prompt file.
40
+ const spacePrompt = await loadSpacePrompt(config.prompts);
41
+ if (spacePrompt !== undefined) release.spacePrompt = spacePrompt;
39
42
  // The brand's mark — the files themselves; the platform stores and serves them.
40
43
  if (config.mark !== undefined) release.mark = await loadMark(config.mark);
41
44
  warnShapeTokenExamples(release.catalog);
package/bin/lib/build.mjs CHANGED
@@ -182,14 +182,23 @@ function bundleAssets(outputs) {
182
182
  return assets;
183
183
  }
184
184
 
185
- export async function loadManifests(dir) {
186
- const root = path.resolve(cwd, dir);
185
+ /**
186
+ * The manifests a release carries, as `catalogs/<rel>.md`. `dirs` is one folder
187
+ * or several, in priority order: the brand's own first, then a kit it declares
188
+ * types from (`node_modules/@40rty/ams-ui/dist/conversation/manifests`). The
189
+ * first folder that has a file wins it — the same layering a brand in the
190
+ * platform's repository gets from `layerCatalogsFileAccess`.
191
+ */
192
+ export async function loadManifests(dirs) {
187
193
  const out = {};
188
- for (const entry of await readdir(root, { recursive: true, withFileTypes: true })) {
189
- if (!entry.isFile() || !entry.name.endsWith('.md')) continue;
190
- const abs = path.join(entry.parentPath, entry.name);
191
- const rel = path.relative(root, abs).split(path.sep).join('/');
192
- out[`catalogs/${rel}`] = await readFile(abs, 'utf8');
194
+ for (const dir of (Array.isArray(dirs) ? dirs : [dirs])) {
195
+ const root = path.resolve(cwd, dir);
196
+ for (const entry of await readdir(root, { recursive: true, withFileTypes: true })) {
197
+ if (!entry.isFile() || !entry.name.endsWith('.md')) continue;
198
+ const abs = path.join(entry.parentPath, entry.name);
199
+ const key = `catalogs/${path.relative(root, abs).split(path.sep).join('/')}`;
200
+ if (!(key in out)) out[key] = await readFile(abs, 'utf8');
201
+ }
193
202
  }
194
203
  return out;
195
204
  }
@@ -232,6 +241,22 @@ export async function loadBrandDefinition(file, promptsDir) {
232
241
  return out;
233
242
  }
234
243
 
244
+ /**
245
+ * The brand's SPACE prompt — `<prompts>/space.md`, sent verbatim. It is the
246
+ * prompt file every space bound to this package reads: how the brand speaks,
247
+ * what it sells, what it never claims. Absent when the package declares no
248
+ * `prompts` directory or ships no file there.
249
+ */
250
+ export async function loadSpacePrompt(promptsDir) {
251
+ if (typeof promptsDir !== 'string') return undefined;
252
+ try {
253
+ return await readFile(path.join(cwd, promptsDir, 'space.md'), 'utf8');
254
+ } catch (err) {
255
+ if (err instanceof Error && 'code' in err && err.code === 'ENOENT') return undefined;
256
+ throw err;
257
+ }
258
+ }
259
+
235
260
  /**
236
261
  * The brand's mark — forty.config.json `"mark": { "square": "brand/mark.svg",
237
262
  * "wordmark": "brand/wordmark.svg" }`, either or both. The files are sent
@@ -44,9 +44,12 @@ export async function readConfig() {
44
44
  // Slugs are per deployment too: `FORTY_SPACE` names this repo's space on the one `FORTY_API_URL` points at.
45
45
  const space = fromEnv('FORTY_SPACE');
46
46
  if (space !== undefined) config.spaceSlug = space;
47
- for (const key of ['apiUrl', 'spaceSlug', 'sourceId', 'label', 'catalog', 'manifests']) {
47
+ for (const key of ['apiUrl', 'spaceSlug', 'sourceId', 'label', 'catalog']) {
48
48
  if (typeof config[key] !== 'string' || config[key] === '') fail(`${CONFIG_FILE} is missing "${key}"`);
49
49
  }
50
+ // One manifests folder, or several in priority order (the brand's own first).
51
+ const manifests = Array.isArray(config.manifests) ? config.manifests : [config.manifests];
52
+ if (manifests.length === 0 || manifests.some((dir) => typeof dir !== 'string' || dir === '')) fail(`${CONFIG_FILE} is missing "manifests"`);
50
53
  return config;
51
54
  }
52
55
 
package/dist/wire.js CHANGED
@@ -387,6 +387,14 @@ var CartAddSignalPayloadSchema = z10.object({
387
387
  quantity: z10.number().optional(),
388
388
  selections: z10.record(z10.string()).optional(),
389
389
  optimisticLine: z10.unknown().optional(),
390
+ /**
391
+ * The agent turn whose canvas element the add came from — stamped by the sdk
392
+ * session hooks for a producer inside a turn (`turn-attributed-session.ts`),
393
+ * absent for one outside any (the agent's own add, the header cart, WebMCP).
394
+ * Carried for the same reason as `origin`: the handler that emits the outcome
395
+ * sees only this payload.
396
+ */
397
+ turnId: z10.string().min(1).optional(),
390
398
  /**
391
399
  * Whether a LANDED add announces itself by opening the cart drawer on the
392
400
  * changed line. Absent means yes, which is every existing producer's
@@ -919,6 +927,14 @@ var PackageReleaseSchema = z24.object({
919
927
  * markdown the agent reads, gated on the capabilities it names (`requires`).
920
928
  */
921
929
  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(),
930
+ /**
931
+ * The brand's SPACE prompt — its `prompts/space.md`, verbatim: sections split
932
+ * by `<!-- section:<id> -->` markers, the same format as the platform's
933
+ * `prompts/spaces/<slug>.md`, which it replaces for any space bound to this
934
+ * package. How the brand speaks, what it sells and what it never claims ship
935
+ * with the brand, and a release changes them with no platform deploy.
936
+ */
937
+ spacePrompt: z24.string().min(1).max(2e5).optional(),
922
938
  /**
923
939
  * Opaque per-vertical extension data (`BrandDefinition.config`): the
924
940
  * platform stays vertical-agnostic and the vertical's own code reads its keys.
@@ -1128,6 +1144,50 @@ var AttributeDefSchema = z32.discriminatedUnion("kind", [
1128
1144
  })
1129
1145
  ]);
1130
1146
 
1147
+ // ../spacestation/src/space/agent-directive.ts
1148
+ import { z as z33 } from "zod";
1149
+ var AGENT_DIRECTIVE_KINDS = ["preference", "pairing", "order of things", "promise", "threshold"];
1150
+ var AGENT_DIRECTIVE_SEVERITIES = ["a missed opportunity", "a problem", "unacceptable"];
1151
+ var AGENT_DIRECTIVE_SOURCES = ["owner", "operator", "session-lesson"];
1152
+ var AGENT_DIRECTIVE_STATUSES = ["proposed", "active", "rejected", "retired"];
1153
+ var AgentDirectiveSchema = z33.object({
1154
+ name: z33.string().trim().min(1).max(80),
1155
+ kind: z33.enum(AGENT_DIRECTIVE_KINDS),
1156
+ severity: z33.enum(AGENT_DIRECTIVE_SEVERITIES),
1157
+ /** No bare URL: a URL is a hallucination surface, and a handle is not a
1158
+ * product name. */
1159
+ text: z33.string().trim().min(1).max(1e3).refine((t) => !/https?:\/\//.test(t), "a directive names things by name, never by URL")
1160
+ }).strict();
1161
+ var SpaceAgentDirectiveSchema = z33.object({
1162
+ id: z33.string(),
1163
+ position: z33.number().int(),
1164
+ name: z33.string(),
1165
+ kind: z33.enum(AGENT_DIRECTIVE_KINDS),
1166
+ severity: z33.enum(AGENT_DIRECTIVE_SEVERITIES),
1167
+ text: z33.string(),
1168
+ source: z33.enum(AGENT_DIRECTIVE_SOURCES),
1169
+ status: z33.enum(AGENT_DIRECTIVE_STATUSES),
1170
+ /** Who wrote it; null for a lesson the system proposed. */
1171
+ createdBy: z33.string().nullable(),
1172
+ /** Why a mined lesson was proposed; null for a directive a person wrote. */
1173
+ evidence: z33.record(z33.unknown()).nullable(),
1174
+ decidedBy: z33.string().nullable(),
1175
+ decidedAt: z33.string().nullable(),
1176
+ createdAt: z33.string()
1177
+ });
1178
+ var OutcomeTallySchema = z33.object({ turns: z33.number().int(), acted: z33.number().int() });
1179
+ var SpaceAgentDirectiveListItemSchema = SpaceAgentDirectiveSchema.extend({
1180
+ impact: z33.object({ before: OutcomeTallySchema, after: OutcomeTallySchema }).nullable()
1181
+ });
1182
+ var UpdateAgentDirectiveInputSchema = z33.object({
1183
+ name: AgentDirectiveSchema.shape.name.optional(),
1184
+ kind: AgentDirectiveSchema.shape.kind.optional(),
1185
+ severity: AgentDirectiveSchema.shape.severity.optional(),
1186
+ text: AgentDirectiveSchema.shape.text.optional(),
1187
+ status: z33.enum(AGENT_DIRECTIVE_STATUSES).optional()
1188
+ }).strict();
1189
+ var ReorderAgentDirectivesInputSchema = z33.object({ ids: z33.array(z33.string()).min(1) }).strict();
1190
+
1131
1191
  // ../spacestation/src/space/workspace-catalog.ts
1132
1192
  var COMPONENT_SOURCE = {
1133
1193
  ui: "@fourty/ui"
@@ -1156,30 +1216,30 @@ var DEFAULT_SPACE_CONFIG = {
1156
1216
  };
1157
1217
 
1158
1218
  // ../spacestation/src/space/trace.ts
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()
1219
+ import { z as z34 } from "zod";
1220
+ var RunTokenUsageSchema = z34.object({
1221
+ input_tokens: z34.number().optional(),
1222
+ output_tokens: z34.number().optional(),
1223
+ cache_read_tokens: z34.number().optional()
1164
1224
  });
1165
- var TraceRecordSchema = z33.object({
1166
- id: z33.string().uuid(),
1167
- spaceId: z33.string().uuid().nullable(),
1168
- sessionId: z33.string(),
1225
+ var TraceRecordSchema = z34.object({
1226
+ id: z34.string().uuid(),
1227
+ spaceId: z34.string().uuid().nullable(),
1228
+ sessionId: z34.string(),
1169
1229
  /** OTP-verified visitor email the session was unlocked with, or `null`
1170
1230
  * for an unlocked space / anonymous unlock. */
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(),
1231
+ visitorEmail: z34.string().nullable(),
1232
+ userPrompt: z34.string(),
1233
+ branch: z34.string().nullable(),
1234
+ responseText: z34.string().nullable(),
1235
+ layout: z34.unknown().nullable(),
1236
+ phaseTimings: z34.record(z34.number()).nullable(),
1237
+ tokensByModel: z34.record(RunTokenUsageSchema).nullable(),
1238
+ toolCalls: z34.array(z34.unknown()).nullable(),
1239
+ diagnostics: z34.array(z34.unknown()).nullable(),
1240
+ latencyFirstText: z34.number().int().nullable(),
1241
+ latencyFirstPatch: z34.number().int().nullable(),
1242
+ latencyTotal: z34.number().int().nullable(),
1183
1243
  /**
1184
1244
  * The CLIENT's turn id for this run, or `null`.
1185
1245
  *
@@ -1195,29 +1255,29 @@ var TraceRecordSchema = z33.object({
1195
1255
  * a turn whose ack the client never saw — none of which is evidence that a
1196
1256
  * visitor asked something and got nothing.
1197
1257
  */
1198
- turnId: z33.string().nullable(),
1258
+ turnId: z34.string().nullable(),
1199
1259
  /** Serialized `TraceTracker.exportState()` payload (parsed object) —
1200
1260
  * lets the inspector rehydrate this run verbatim after a reload. */
1201
- trackerState: z33.unknown().nullable(),
1202
- createdAt: z33.string()
1261
+ trackerState: z34.unknown().nullable(),
1262
+ createdAt: z34.string()
1203
1263
  });
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(),
1264
+ var MillisecondsSchema = z34.number().nullable().transform((v) => v === null ? null : Math.round(v));
1265
+ var CreateTraceInputSchema = z34.object({
1266
+ spaceId: z34.string().uuid().nullable(),
1267
+ sessionId: z34.string(),
1268
+ visitorEmail: z34.string().nullable(),
1269
+ userPrompt: z34.string(),
1270
+ branch: z34.string().nullable(),
1271
+ responseText: z34.string().nullable(),
1272
+ layout: z34.unknown().nullable(),
1273
+ phaseTimings: z34.record(z34.number()).nullable(),
1274
+ tokensByModel: z34.record(RunTokenUsageSchema).nullable(),
1275
+ toolCalls: z34.array(z34.unknown()).nullable(),
1276
+ diagnostics: z34.array(z34.unknown()).nullable(),
1217
1277
  latencyFirstText: MillisecondsSchema,
1218
1278
  latencyFirstPatch: MillisecondsSchema,
1219
1279
  latencyTotal: MillisecondsSchema,
1220
- trackerState: z33.unknown().nullable(),
1280
+ trackerState: z34.unknown().nullable(),
1221
1281
  /**
1222
1282
  * The CLIENT's turn id for this run, or `null`.
1223
1283
  *
@@ -1233,37 +1293,37 @@ var CreateTraceInputSchema = z33.object({
1233
1293
  * a turn whose ack the client never saw — none of which is evidence that a
1234
1294
  * visitor asked something and got nothing.
1235
1295
  */
1236
- turnId: z33.string().nullable()
1296
+ turnId: z34.string().nullable()
1237
1297
  });
1238
- var AgentSessionSummarySchema = z33.object({
1239
- sessionId: z33.string(),
1298
+ var AgentSessionSummarySchema = z34.object({
1299
+ sessionId: z34.string(),
1240
1300
  /** Turn rows only; background/secondary runs are excluded by the aggregate. */
1241
- turnCount: z33.number().int(),
1301
+ turnCount: z34.number().int(),
1242
1302
  /** The session's opening prompt — titles the row in the UI. */
1243
- firstPrompt: z33.string(),
1244
- startedAt: z33.string(),
1245
- lastRunAt: z33.string(),
1303
+ firstPrompt: z34.string(),
1304
+ startedAt: z34.string(),
1305
+ lastRunAt: z34.string(),
1246
1306
  /** Summed `latency_total` across the session's turns. */
1247
- totalLatencyMs: z33.number().int()
1307
+ totalLatencyMs: z34.number().int()
1248
1308
  });
1249
- var SessionTurnSchema = z33.object({
1250
- id: z33.string().uuid(),
1251
- userPrompt: z33.string(),
1252
- responseText: z33.string().nullable(),
1309
+ var SessionTurnSchema = z34.object({
1310
+ id: z34.string().uuid(),
1311
+ userPrompt: z34.string(),
1312
+ responseText: z34.string().nullable(),
1253
1313
  /** Full cumulative Spec committed by this turn — never a patch delta. */
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()
1314
+ layout: z34.unknown().nullable(),
1315
+ createdAt: z34.string(),
1316
+ latencyTotal: z34.number().int().nullable(),
1317
+ phaseTimings: z34.record(z34.number()).nullable(),
1318
+ tokensByModel: z34.record(z34.object({
1319
+ input_tokens: z34.number().optional(),
1320
+ output_tokens: z34.number().optional()
1261
1321
  })).nullable(),
1262
- toolCalls: z33.array(z33.unknown()).nullable(),
1263
- diagnostics: z33.array(z33.unknown()).nullable()
1322
+ toolCalls: z34.array(z34.unknown()).nullable(),
1323
+ diagnostics: z34.array(z34.unknown()).nullable()
1264
1324
  });
1265
- var SessionReplaySchema = z33.object({
1266
- turns: z33.array(SessionTurnSchema),
1325
+ var SessionReplaySchema = z34.object({
1326
+ turns: z34.array(SessionTurnSchema),
1267
1327
  /**
1268
1328
  * The session's own last-committed layout, read straight off the durable
1269
1329
  * session record (`sessions.blob.layout`) rather than derived from `turns`.
@@ -1274,20 +1334,20 @@ var SessionReplaySchema = z33.object({
1274
1334
  * a perfectly real layout; only this field can show it. Null exclusively
1275
1335
  * when the durable session row itself could not be read.
1276
1336
  */
1277
- sessionLayout: z33.record(z33.string(), z33.unknown()).nullable()
1337
+ sessionLayout: z34.record(z34.string(), z34.unknown()).nullable()
1278
1338
  });
1279
- var SessionTraceSchema = z33.object({
1280
- trackerState: z33.string().nullable()
1339
+ var SessionTraceSchema = z34.object({
1340
+ trackerState: z34.string().nullable()
1281
1341
  });
1282
- var LlmUsageDailySchema = z33.object({
1283
- day: z33.string(),
1342
+ var LlmUsageDailySchema = z34.object({
1343
+ day: z34.string(),
1284
1344
  /** Deployment that made the call — 'production', 'staging', 'pr-123', 'development'. */
1285
- environment: z33.string(),
1286
- feature: z33.string(),
1287
- model: z33.string(),
1288
- provider: z33.string(),
1345
+ environment: z34.string(),
1346
+ feature: z34.string(),
1347
+ model: z34.string(),
1348
+ provider: z34.string(),
1289
1349
  /** Masked tail of the key actually billed, or null when unknown/non-Google. */
1290
- keyFingerprint: z33.string().nullable(),
1350
+ keyFingerprint: z34.string().nullable(),
1291
1351
  /**
1292
1352
  * The space the call served, or null when it served none.
1293
1353
  *
@@ -1296,91 +1356,91 @@ var LlmUsageDailySchema = z33.object({
1296
1356
  * report that share rather than dropping it, or a per-space total reads as
1297
1357
  * the platform total.
1298
1358
  */
1299
- spaceId: z33.string().nullable(),
1359
+ spaceId: z34.string().nullable(),
1300
1360
  /**
1301
1361
  * The surface of the session the call served (`sessions.surface`), or null
1302
1362
  * when it served no session or the session predates surface recording.
1303
1363
  * `automation` is the eval harness — the signal that files an ordinary
1304
1364
  * `agent-turn` as testing spend rather than as a visitor's.
1305
1365
  */
1306
- surface: z33.string().nullable(),
1307
- inputTokens: z33.number(),
1308
- outputTokens: z33.number(),
1366
+ surface: z34.string().nullable(),
1367
+ inputTokens: z34.number(),
1368
+ outputTokens: z34.number(),
1309
1369
  /** Subset of inputTokens, never additional to it. */
1310
- cachedInputTokens: z33.number(),
1311
- reasoningTokens: z33.number(),
1312
- callCount: z33.number(),
1313
- errorCount: z33.number(),
1314
- estimatedCostUsd: z33.number().nullable()
1370
+ cachedInputTokens: z34.number(),
1371
+ reasoningTokens: z34.number(),
1372
+ callCount: z34.number(),
1373
+ errorCount: z34.number(),
1374
+ estimatedCostUsd: z34.number().nullable()
1315
1375
  });
1316
- var LlmUsageBySessionSchema = z33.object({
1317
- sessionId: z33.string(),
1318
- environment: z33.string(),
1319
- model: z33.string(),
1376
+ var LlmUsageBySessionSchema = z34.object({
1377
+ sessionId: z34.string(),
1378
+ environment: z34.string(),
1379
+ model: z34.string(),
1320
1380
  /** The space this session belongs to, or null for a session with no space. */
1321
- spaceId: z33.string().nullable(),
1381
+ spaceId: z34.string().nullable(),
1322
1382
  /** The session's surface — see `LlmUsageDailySchema.surface`. */
1323
- surface: z33.string().nullable(),
1383
+ surface: z34.string().nullable(),
1324
1384
  /** Label only — the first feature seen in the session. */
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(),
1385
+ firstFeature: z34.string(),
1386
+ startedAt: z34.string(),
1387
+ endedAt: z34.string(),
1388
+ inputTokens: z34.number(),
1389
+ outputTokens: z34.number(),
1390
+ cachedInputTokens: z34.number(),
1391
+ reasoningTokens: z34.number(),
1392
+ callCount: z34.number(),
1393
+ errorCount: z34.number(),
1334
1394
  /** Priced server-side, like the daily rollup — the browser never carries a
1335
1395
  * rate table, so there is exactly one place a price can be wrong. Null when
1336
1396
  * the model is unpriced; never 0, which would read as free. */
1337
- estimatedCostUsd: z33.number().nullable()
1397
+ estimatedCostUsd: z34.number().nullable()
1338
1398
  });
1339
- var LlmSessionsDailySchema = z33.object({
1340
- day: z33.string(),
1341
- environment: z33.string(),
1342
- sessionCount: z33.number()
1399
+ var LlmSessionsDailySchema = z34.object({
1400
+ day: z34.string(),
1401
+ environment: z34.string(),
1402
+ sessionCount: z34.number()
1343
1403
  });
1344
1404
 
1345
1405
  // ../spacestation/src/space/session-queue.ts
1346
- import { z as z35 } from "zod";
1406
+ import { z as z36 } from "zod";
1347
1407
 
1348
1408
  // ../spacestation/src/space/session-activity.ts
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())
1409
+ import { z as z35 } from "zod";
1410
+ var SessionActivityEventSchema = z35.object({
1411
+ id: z35.string(),
1412
+ kind: z35.string(),
1413
+ occurredAt: z35.string(),
1414
+ source: z35.string(),
1415
+ surface: z35.string(),
1416
+ payload: z35.record(z35.unknown())
1357
1417
  });
1358
- var SessionActivitySchema = z34.object({
1359
- events: z34.array(SessionActivityEventSchema),
1360
- hasMore: z34.boolean()
1418
+ var SessionActivitySchema = z35.object({
1419
+ events: z35.array(SessionActivityEventSchema),
1420
+ hasMore: z35.boolean()
1361
1421
  });
1362
1422
 
1363
1423
  // ../spacestation/src/space/session-queue.ts
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(),
1424
+ var SessionVerdictSchema = z36.enum(["unreviewed", "viewed", "bug"]);
1425
+ var RecordableVerdictSchema = z36.enum(["viewed", "bug"]);
1426
+ var SessionReviewEventSchema = z36.object({
1427
+ id: z36.string().uuid(),
1368
1428
  verdict: RecordableVerdictSchema,
1369
1429
  /** Account email of the operator who judged it. Attribution is the reason the
1370
1430
  * log is append-only rather than a mutable current-state row. */
1371
- reviewer: z35.string(),
1372
- note: z35.string().nullable(),
1373
- createdAt: z35.string()
1431
+ reviewer: z36.string(),
1432
+ note: z36.string().nullable(),
1433
+ createdAt: z36.string()
1374
1434
  });
1375
- var BugSeveritySchema = z35.enum(["high", "medium", "low"]);
1376
- var BugLocationSchema = z35.object({
1377
- elementId: z35.string().nullable(),
1435
+ var BugSeveritySchema = z36.enum(["high", "medium", "low"]);
1436
+ var BugLocationSchema = z36.object({
1437
+ elementId: z36.string().nullable(),
1378
1438
  /** Display only — the catalog component type, e.g. "productGrid". Null
1379
1439
  * alongside a null `elementId`. */
1380
- elementType: z35.string().nullable(),
1440
+ elementType: z36.string().nullable(),
1381
1441
  /** Fraction of the ELEMENT's own box. Null for a page anchor. */
1382
- offsetXPct: z35.number().min(0).max(100).nullable(),
1383
- offsetYPct: z35.number().min(0).max(100).nullable(),
1442
+ offsetXPct: z36.number().min(0).max(100).nullable(),
1443
+ offsetYPct: z36.number().min(0).max(100).nullable(),
1384
1444
  /**
1385
1445
  * ABSOLUTE document pixels, for a pin with no element under it. Null for an
1386
1446
  * element anchor.
@@ -1391,8 +1451,8 @@ var BugLocationSchema = z35.object({
1391
1451
  * on the page with it. Measured before this was fixed: growing the page 9%
1392
1452
  * slid a pin 32px, so a pin ran away from the cursor reaching for it.
1393
1453
  */
1394
- pageX: z35.number().nullable(),
1395
- pageY: z35.number().nullable()
1454
+ pageX: z36.number().nullable(),
1455
+ pageY: z36.number().nullable()
1396
1456
  }).refine(
1397
1457
  (loc) => {
1398
1458
  const hasOffsets = loc.offsetXPct !== null && loc.offsetYPct !== null;
@@ -1406,24 +1466,24 @@ var BugLocationSchema = z35.object({
1406
1466
  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)"
1407
1467
  }
1408
1468
  );
1409
- var SessionBugSchema = z35.object({
1410
- id: z35.string().uuid(),
1469
+ var SessionBugSchema = z36.object({
1470
+ id: z36.string().uuid(),
1411
1471
  /** 1-based turn the fault was observed on; null when the fault is session-wide. */
1412
- turnIndex: z35.number().int().nullable(),
1472
+ turnIndex: z36.number().int().nullable(),
1413
1473
  /** Where on that turn's canvas the pin was dropped; null for a bug filed
1414
1474
  * without pinning a spot. */
1415
1475
  location: BugLocationSchema.nullable(),
1416
- provider: z35.string(),
1417
- issueKey: z35.string().nullable(),
1418
- issueUrl: z35.string().nullable(),
1476
+ provider: z36.string(),
1477
+ issueKey: z36.string().nullable(),
1478
+ issueUrl: z36.string().nullable(),
1419
1479
  /** The tracker's own state word ('Todo', 'Done', …) — their vocabulary, so
1420
1480
  * open text. Null until first synced. */
1421
- issueState: z35.string().nullable(),
1422
- title: z35.string(),
1423
- body: z35.string(),
1481
+ issueState: z36.string().nullable(),
1482
+ title: z36.string(),
1483
+ body: z36.string(),
1424
1484
  severity: BugSeveritySchema,
1425
- createdBy: z35.string(),
1426
- createdAt: z35.string(),
1485
+ createdBy: z36.string(),
1486
+ createdAt: z36.string(),
1427
1487
  /**
1428
1488
  * When this bug was resolved from the console; null means still OPEN.
1429
1489
  *
@@ -1432,55 +1492,55 @@ var SessionBugSchema = z35.object({
1432
1492
  * whether a particular fault is still live. The timestamp IS the state, so
1433
1493
  * no boolean can contradict it.
1434
1494
  */
1435
- resolvedAt: z35.string().nullable(),
1436
- resolvedBy: z35.string().nullable()
1495
+ resolvedAt: z36.string().nullable(),
1496
+ resolvedBy: z36.string().nullable()
1437
1497
  });
1438
- var SpaceBugSchema = SessionBugSchema.extend({ sessionId: z35.string() });
1439
- var SessionCommentSchema = z35.object({
1440
- id: z35.string().uuid(),
1498
+ var SpaceBugSchema = SessionBugSchema.extend({ sessionId: z36.string() });
1499
+ var SessionCommentSchema = z36.object({
1500
+ id: z36.string().uuid(),
1441
1501
  /** Set = a reply in that bug's thread. Null = a standalone comment pin. */
1442
- bugId: z35.string().uuid().nullable(),
1502
+ bugId: z36.string().uuid().nullable(),
1443
1503
  /** 1-based turn the comment was left on; null for a reply (it reads its
1444
1504
  * parent bug's turn). */
1445
- turnIndex: z35.number().int().nullable(),
1505
+ turnIndex: z36.number().int().nullable(),
1446
1506
  /** The canvas anchor for a STANDALONE comment's own pin; null for a reply. */
1447
1507
  location: BugLocationSchema.nullable(),
1448
- body: z35.string(),
1449
- createdBy: z35.string(),
1450
- createdAt: z35.string()
1508
+ body: z36.string(),
1509
+ createdBy: z36.string(),
1510
+ createdAt: z36.string()
1451
1511
  });
1452
- var CreateCommentInputSchema = z35.object({
1453
- bugId: z35.string().uuid().nullable(),
1454
- turnIndex: z35.number().int().positive().nullable(),
1512
+ var CreateCommentInputSchema = z36.object({
1513
+ bugId: z36.string().uuid().nullable(),
1514
+ turnIndex: z36.number().int().positive().nullable(),
1455
1515
  location: BugLocationSchema.nullable(),
1456
1516
  // Trimmed, so whitespace is not content: `.min(1)` alone accepted a comment
1457
1517
  // of three spaces, which renders as an empty bubble nobody can interpret.
1458
- body: z35.string().trim().min(1)
1518
+ body: z36.string().trim().min(1)
1459
1519
  }).refine((input) => input.bugId === null !== (input.location === null), {
1460
1520
  message: "a comment is either a reply (bugId, no location) or a standalone pin (location, no bugId)"
1461
1521
  });
1462
- var UpdateCommentInputSchema = z35.object({
1463
- body: z35.string().trim().min(1).optional(),
1464
- bugId: z35.string().uuid().nullable().optional(),
1522
+ var UpdateCommentInputSchema = z36.object({
1523
+ body: z36.string().trim().min(1).optional(),
1524
+ bugId: z36.string().uuid().nullable().optional(),
1465
1525
  location: BugLocationSchema.nullable().optional()
1466
1526
  });
1467
- var SessionFormFactorSchema = z35.enum(["mobile", "desktop"]).nullable();
1468
- var SessionSummarySchema = z35.object({
1469
- sessionId: z35.string(),
1527
+ var SessionFormFactorSchema = z36.enum(["mobile", "desktop"]).nullable();
1528
+ var SessionSummarySchema = z36.object({
1529
+ sessionId: z36.string(),
1470
1530
  /** Stable per-browser id — the join key across a visitor's sessions. Null when
1471
1531
  * the session row is gone (pruned) or predates the `sessions` table. */
1472
- visitorId: z35.string().nullable(),
1532
+ visitorId: z36.string().nullable(),
1473
1533
  /** Provider-qualified identity anchor, present only once the visitor
1474
1534
  * identified themselves. Both null together means "not identified yet". */
1475
- identityProvider: z35.string().nullable(),
1476
- identityKey: z35.string().nullable(),
1535
+ identityProvider: z36.string().nullable(),
1536
+ identityKey: z36.string().nullable(),
1477
1537
  /** Team/test traffic. The queue hides these by default. */
1478
- isInternal: z35.boolean(),
1538
+ isInternal: z36.boolean(),
1479
1539
  /** Build that served the session. Null = not captured; a version filter must
1480
1540
  * therefore EXCLUDE it rather than let it match an arbitrary bucket. */
1481
- clientVersion: z35.string().nullable(),
1541
+ clientVersion: z36.string().nullable(),
1482
1542
  /** Commit-shaped interaction signals, counted, keyed by open `SignalType`. */
1483
- signalCounts: z35.record(z35.number()),
1543
+ signalCounts: z36.record(z36.number()),
1484
1544
  /**
1485
1545
  * Did this conversation ACQUIRE anything, and how many times?
1486
1546
  *
@@ -1497,7 +1557,7 @@ var SessionSummarySchema = z35.object({
1497
1557
  * predates the column — and renders as no mark at all. It never means zero:
1498
1558
  * zero is a real, recorded answer and the rail reports it as one.
1499
1559
  */
1500
- conversionAttempts: z35.number().int().nullable(),
1560
+ conversionAttempts: z36.number().int().nullable(),
1501
1561
  /**
1502
1562
  * The same attempts split by EVENT KIND, keyed by the kind's own name
1503
1563
  * (`commerce.cart_line_added`, `commerce.registry_clicked`), counted distinct
@@ -1513,7 +1573,7 @@ var SessionSummarySchema = z35.object({
1513
1573
  * kinds together, and one attempt id appearing under both would be counted
1514
1574
  * once there and twice here.
1515
1575
  */
1516
- conversionKinds: z35.record(z35.number()),
1576
+ conversionKinds: z36.record(z36.number()),
1517
1577
  /**
1518
1578
  * Every analytics funnel step this session reached, in funnel order — the
1519
1579
  * dashboard's own step ids, read by the same per-step predicates, so a queue
@@ -1521,20 +1581,20 @@ var SessionSummarySchema = z35.object({
1521
1581
  * set of strings for the reason `conversionKinds` is: the contract does not
1522
1582
  * learn what a step means. Empty only when read from a pre-column database.
1523
1583
  */
1524
- funnelSteps: z35.array(z35.string()),
1584
+ funnelSteps: z36.array(z36.string()),
1525
1585
  /**
1526
1586
  * The connector's opaque handle for what this session produced in its back
1527
1587
  * office — present only once a checkout actually reached the platform. The
1528
1588
  * console hands it to the back-office link registry; nothing else reads it.
1529
1589
  */
1530
- backOfficeRef: z35.string().nullable(),
1590
+ backOfficeRef: z36.string().nullable(),
1531
1591
  /**
1532
1592
  * The order this session produced, when the connector's back office reported
1533
1593
  * it (`session_orders`): its opaque id and the back office's own name for it.
1534
1594
  * Both null when no order is known — the cart handle above is then the door.
1535
1595
  */
1536
- orderRef: z35.string().nullable(),
1537
- orderLabel: z35.string().nullable(),
1596
+ orderRef: z36.string().nullable(),
1597
+ orderLabel: z36.string().nullable(),
1538
1598
  /**
1539
1599
  * Which shell this session rendered — the one thing about the CAPTURE a list
1540
1600
  * needs.
@@ -1547,12 +1607,12 @@ var SessionSummarySchema = z35.object({
1547
1607
  * on a desktop are not the same session.
1548
1608
  */
1549
1609
  formFactor: SessionFormFactorSchema,
1550
- turnCount: z35.number().int(),
1610
+ turnCount: z36.number().int(),
1551
1611
  /** The visitor's opening message — the single most informative field for
1552
1612
  * deciding whether a session is worth opening, hence the widest column. */
1553
- firstPrompt: z35.string(),
1554
- startedAt: z35.string(),
1555
- lastRunAt: z35.string(),
1613
+ firstPrompt: z36.string(),
1614
+ startedAt: z36.string(),
1615
+ lastRunAt: z36.string(),
1556
1616
  /**
1557
1617
  * The VISITOR's own IANA zone (`America/New_York`), read from their browser
1558
1618
  * at session create — what the two timestamps above should be read in.
@@ -1580,7 +1640,7 @@ var SessionSummarySchema = z35.object({
1580
1640
  * Client-asserted and never validated against a zone table, so every consumer
1581
1641
  * must tolerate an unknown name: `Intl` throws a RangeError on one.
1582
1642
  */
1583
- visitorTimeZone: z35.string().nullable(),
1643
+ visitorTimeZone: z36.string().nullable(),
1584
1644
  /**
1585
1645
  * Mean TIME TO FIRST PATCH, over the turns that recorded one — the first
1586
1646
  * layout op reaching the visitor, and THE latency the project is managed on.
@@ -1588,31 +1648,31 @@ var SessionSummarySchema = z35.object({
1588
1648
  * `totalLatencyMs` carries the chip-gen tail that runs after the visitor is
1589
1649
  * already reading. Null when no turn in the session recorded a patch.
1590
1650
  */
1591
- avgTtftMs: z35.number().int().nullable(),
1651
+ avgTtftMs: z36.number().int().nullable(),
1592
1652
  /** Mean `main_done_ms` — layout + prose complete. Context for the TTFT, not
1593
1653
  * a budget: null on sessions older than the mark's recording. */
1594
- avgMainDoneMs: z35.number().int().nullable(),
1654
+ avgMainDoneMs: z36.number().int().nullable(),
1595
1655
  /** Mean `chip_gen_ms` — the pass that runs AFTER mainDone and is out of the
1596
1656
  * budget. On the row only to explain the gap to `totalLatencyMs`. */
1597
- avgChipGenMs: z35.number().int().nullable(),
1598
- totalLatencyMs: z35.number().int(),
1599
- durationMs: z35.number().int(),
1657
+ avgChipGenMs: z36.number().int().nullable(),
1658
+ totalLatencyMs: z36.number().int(),
1659
+ durationMs: z36.number().int(),
1600
1660
  /** Inferred from recent activity — nothing writes a session-end marker. A
1601
1661
  * live session streams and cannot be given a verdict until it ends. */
1602
- isLive: z35.boolean(),
1662
+ isLive: z36.boolean(),
1603
1663
  verdict: SessionVerdictSchema,
1604
- reviewedBy: z35.string().nullable(),
1605
- reviewedAt: z35.string().nullable(),
1664
+ reviewedBy: z36.string().nullable(),
1665
+ reviewedAt: z36.string().nullable(),
1606
1666
  /** Latest filed bug, flattened onto the row so the queue can show its live
1607
1667
  * state without a second request. */
1608
- bugIssueKey: z35.string().nullable(),
1609
- bugIssueUrl: z35.string().nullable(),
1610
- bugIssueState: z35.string().nullable()
1668
+ bugIssueKey: z36.string().nullable(),
1669
+ bugIssueUrl: z36.string().nullable(),
1670
+ bugIssueState: z36.string().nullable()
1611
1671
  });
1612
- var SessionQueuePageSchema = z35.object({
1613
- sessions: z35.array(SessionSummarySchema),
1614
- totalCount: z35.number().int(),
1615
- hiddenInternalCount: z35.number().int(),
1672
+ var SessionQueuePageSchema = z36.object({
1673
+ sessions: z36.array(SessionSummarySchema),
1674
+ totalCount: z36.number().int(),
1675
+ hiddenInternalCount: z36.number().int(),
1616
1676
  /**
1617
1677
  * Bounced sessions the queue left out — no turn and no add, the default.
1618
1678
  *
@@ -1622,61 +1682,61 @@ var SessionQueuePageSchema = z35.object({
1622
1682
  * `totalCount + hiddenBouncedCount` is that population, and this count is the
1623
1683
  * analytics dashboard's bounce over the same window.
1624
1684
  */
1625
- hiddenBouncedCount: z35.number().int()
1685
+ hiddenBouncedCount: z36.number().int()
1626
1686
  });
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()),
1687
+ var SessionQueueFacetsSchema = z36.object({
1688
+ review: z36.record(z36.number()),
1689
+ version: z36.record(z36.number()),
1690
+ turns: z36.record(z36.number()),
1691
+ durationS: z36.record(z36.number()),
1632
1692
  /** Sessions per funnel step reached — a session counts under every step it reached. */
1633
- funnel: z35.record(z35.number())
1693
+ funnel: z36.record(z36.number())
1634
1694
  });
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(),
1695
+ var SessionCaptureSchema = z36.object({
1696
+ viewportWidth: z36.number().int().nullable(),
1697
+ viewportHeight: z36.number().int().nullable(),
1698
+ userAgent: z36.string().nullable(),
1699
+ locale: z36.string().nullable(),
1640
1700
  /** Referrer at session create — separates agentic traffic from organic. */
1641
- referrer: z35.string().nullable()
1701
+ referrer: z36.string().nullable()
1642
1702
  });
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(),
1703
+ var SessionCaptureInputSchema = z36.object({
1704
+ viewportWidth: z36.number().int().positive().max(2e4).optional(),
1705
+ viewportHeight: z36.number().int().positive().max(2e4).optional(),
1706
+ userAgent: z36.string().max(1e3).optional(),
1707
+ locale: z36.string().max(35).optional(),
1648
1708
  /** IANA zone name from the visitor's browser. Bounded rather than validated:
1649
1709
  * the zone database grows, and refusing a name this build has not heard of
1650
1710
  * would drop a real session's capture over a table that is out of date. */
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()
1711
+ timeZone: z36.string().max(64).optional(),
1712
+ referrer: z36.string().max(2048).optional(),
1713
+ clientVersion: z36.string().max(100).optional(),
1714
+ isInternal: z36.boolean().optional()
1655
1715
  });
1656
- var SessionDetailSchema = z35.object({
1716
+ var SessionDetailSchema = z36.object({
1657
1717
  session: SessionSummarySchema,
1658
1718
  capture: SessionCaptureSchema,
1659
1719
  /** Full verdict history, newest first. Verdicts are revisable, and a session
1660
1720
  * re-judged after a fix is the evidence the fix worked. */
1661
- reviews: z35.array(SessionReviewEventSchema),
1662
- bugs: z35.array(SessionBugSchema),
1663
- comments: z35.array(SessionCommentSchema),
1721
+ reviews: z36.array(SessionReviewEventSchema),
1722
+ bugs: z36.array(SessionBugSchema),
1723
+ comments: z36.array(SessionCommentSchema),
1664
1724
  /** Optional during API/console rolling deployment. Absent is unavailable,
1665
1725
  * not evidence of zero visitor activity. */
1666
1726
  activity: SessionActivitySchema.optional()
1667
1727
  });
1668
- var RecordVerdictInputSchema = z35.object({
1728
+ var RecordVerdictInputSchema = z36.object({
1669
1729
  verdict: RecordableVerdictSchema,
1670
- note: z35.string().max(2e3).optional()
1730
+ note: z36.string().max(2e3).optional()
1671
1731
  });
1672
- var FileBugInputSchema = z35.object({
1673
- turnIndex: z35.number().int().positive().nullable(),
1732
+ var FileBugInputSchema = z36.object({
1733
+ turnIndex: z36.number().int().positive().nullable(),
1674
1734
  /** Optional — a bug filed without dropping a pin has no location. */
1675
1735
  location: BugLocationSchema.nullable().optional(),
1676
- title: z35.string().min(1).max(300),
1677
- body: z35.string().min(1),
1736
+ title: z36.string().min(1).max(300),
1737
+ body: z36.string().min(1),
1678
1738
  severity: BugSeveritySchema,
1679
- payload: z35.record(z35.unknown())
1739
+ payload: z36.record(z36.unknown())
1680
1740
  });
1681
1741
  export {
1682
1742
  EMPTY_SPEC,
package/package.json CHANGED
@@ -15,7 +15,7 @@
15
15
  "peerDependencies": {
16
16
  "zod": "^3.25.0"
17
17
  },
18
- "version": "0.5.1",
18
+ "version": "0.5.3",
19
19
  "homepage": "https://docs.40rty.ai",
20
20
  "license": "UNLICENSED",
21
21
  "engines": {