@40rty/ams-cli 0.5.0 → 0.5.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/commands/doctor.mjs +3 -1
- package/bin/commands/publish.mjs +10 -1
- package/bin/lib/__tests__/sdk-version.test.mjs +42 -0
- package/bin/lib/ask.mjs +25 -3
- package/bin/lib/build.mjs +16 -0
- package/bin/lib/sdk-version.mjs +37 -0
- package/dist/wire.js +391 -305
- package/package.json +1 -1
package/bin/commands/doctor.mjs
CHANGED
|
@@ -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
|
-
|
|
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;
|
package/bin/commands/publish.mjs
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
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';
|
|
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
|
|
@@ -30,6 +36,9 @@ export async function buildRelease(config) {
|
|
|
30
36
|
if (typeof config.brand === 'string') Object.assign(release, await loadBrandDefinition(config.brand, config.prompts));
|
|
31
37
|
if (typeof config.theme === 'string') release.theme = { themeClass: config.theme };
|
|
32
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;
|
|
33
42
|
// The brand's mark — the files themselves; the platform stores and serves them.
|
|
34
43
|
if (config.mark !== undefined) release.mark = await loadMark(config.mark);
|
|
35
44
|
warnShapeTokenExamples(release.catalog);
|
|
@@ -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
|
|
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
|
-
|
|
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) => {
|
package/bin/lib/build.mjs
CHANGED
|
@@ -232,6 +232,22 @@ export async function loadBrandDefinition(file, promptsDir) {
|
|
|
232
232
|
return out;
|
|
233
233
|
}
|
|
234
234
|
|
|
235
|
+
/**
|
|
236
|
+
* The brand's SPACE prompt — `<prompts>/space.md`, sent verbatim. It is the
|
|
237
|
+
* prompt file every space bound to this package reads: how the brand speaks,
|
|
238
|
+
* what it sells, what it never claims. Absent when the package declares no
|
|
239
|
+
* `prompts` directory or ships no file there.
|
|
240
|
+
*/
|
|
241
|
+
export async function loadSpacePrompt(promptsDir) {
|
|
242
|
+
if (typeof promptsDir !== 'string') return undefined;
|
|
243
|
+
try {
|
|
244
|
+
return await readFile(path.join(cwd, promptsDir, 'space.md'), 'utf8');
|
|
245
|
+
} catch (err) {
|
|
246
|
+
if (err instanceof Error && 'code' in err && err.code === 'ENOENT') return undefined;
|
|
247
|
+
throw err;
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
|
|
235
251
|
/**
|
|
236
252
|
* The brand's mark — forty.config.json `"mark": { "square": "brand/mark.svg",
|
|
237
253
|
* "wordmark": "brand/wordmark.svg" }`, either or both. The files are sent
|
|
@@ -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
|
|
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 =
|
|
871
|
+
var PackageReleaseSchema = z24.object({
|
|
867
872
|
/** The id spaces name in `componentSources` — an npm-style package name. */
|
|
868
|
-
sourceId:
|
|
869
|
-
label:
|
|
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:
|
|
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:
|
|
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:
|
|
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:
|
|
886
|
-
js:
|
|
887
|
-
css:
|
|
888
|
-
assets:
|
|
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:
|
|
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,84 @@ 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:
|
|
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(),
|
|
922
|
+
/**
|
|
923
|
+
* The brand's SPACE prompt — its `prompts/space.md`, verbatim: sections split
|
|
924
|
+
* by `<!-- section:<id> -->` markers, the same format as the platform's
|
|
925
|
+
* `prompts/spaces/<slug>.md`, which it replaces for any space bound to this
|
|
926
|
+
* package. How the brand speaks, what it sells and what it never claims ship
|
|
927
|
+
* with the brand, and a release changes them with no platform deploy.
|
|
928
|
+
*/
|
|
929
|
+
spacePrompt: z24.string().min(1).max(2e5).optional(),
|
|
909
930
|
/**
|
|
910
931
|
* Opaque per-vertical extension data (`BrandDefinition.config`): the
|
|
911
932
|
* platform stays vertical-agnostic and the vertical's own code reads its keys.
|
|
912
933
|
*/
|
|
913
|
-
config:
|
|
934
|
+
config: z24.record(z24.string(), z24.unknown()).optional(),
|
|
914
935
|
/**
|
|
915
936
|
* Set by the platform, never by a publisher: this release is a DRAFT of the
|
|
916
937
|
* package `of`, previewed on the space `space`. See `draftSourceId`.
|
|
917
938
|
*/
|
|
918
|
-
draft:
|
|
939
|
+
draft: z24.object({ of: z24.string().min(1), space: z24.string().min(1) }).strict().optional()
|
|
919
940
|
}).strict();
|
|
920
941
|
|
|
942
|
+
// ../spacestation/src/catalog/wire/package-bundle-ref.ts
|
|
943
|
+
import { z as z25 } from "zod";
|
|
944
|
+
var PackageBundleRefSchema = z25.object({
|
|
945
|
+
sourceId: z25.string(),
|
|
946
|
+
js: z25.string(),
|
|
947
|
+
css: z25.string(),
|
|
948
|
+
/** The brand's name for itself, and its package's version. */
|
|
949
|
+
label: z25.string(),
|
|
950
|
+
version: z25.string(),
|
|
951
|
+
/** The sdk the bundle was built against (`PackageRelease.builtWithSdk`) — absent for a legacy release. Picks its compat shims. */
|
|
952
|
+
builtWithSdk: SdkVersionSchema.optional()
|
|
953
|
+
});
|
|
954
|
+
|
|
921
955
|
// ../spacestation/src/projection/projection.ts
|
|
922
|
-
import { z as
|
|
923
|
-
var LateBoundValueSchema =
|
|
924
|
-
var DirectiveValueSchema =
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
956
|
+
import { z as z26 } from "zod";
|
|
957
|
+
var LateBoundValueSchema = z26.object({ fact: z26.literal(true) });
|
|
958
|
+
var DirectiveValueSchema = z26.union([
|
|
959
|
+
z26.string(),
|
|
960
|
+
z26.number(),
|
|
961
|
+
z26.boolean(),
|
|
928
962
|
LateBoundValueSchema
|
|
929
963
|
]);
|
|
930
|
-
var ProjectionDirectiveSchema =
|
|
964
|
+
var ProjectionDirectiveSchema = z26.object({
|
|
931
965
|
/** Keep only items whose axis values all match. Keyed by axis name
|
|
932
966
|
* (e.g. `Size`); value is a literal or the `{fact:true}` marker. */
|
|
933
|
-
isolateTo:
|
|
967
|
+
isolateTo: z26.record(DirectiveValueSchema).optional(),
|
|
934
968
|
/** Isolate to EVERY axis the visitor has a stored fact for. The agent
|
|
935
969
|
* emits this (it is vertical-agnostic — it cannot name axes); the
|
|
936
970
|
* entity binding expands it against the entity's own axes + facts. */
|
|
937
|
-
isolateToFacts:
|
|
971
|
+
isolateToFacts: z26.boolean().optional(),
|
|
938
972
|
/** Keep only items the entity binding reports as available. */
|
|
939
|
-
availableOnly:
|
|
973
|
+
availableOnly: z26.boolean().optional(),
|
|
940
974
|
/** Cap the rendered count after filtering. */
|
|
941
|
-
limit:
|
|
975
|
+
limit: z26.number().int().positive().optional()
|
|
942
976
|
});
|
|
943
|
-
var ProjectionPreferencesSchema =
|
|
944
|
-
|
|
977
|
+
var ProjectionPreferencesSchema = z26.record(
|
|
978
|
+
z26.union([ProjectionDirectiveSchema, z26.null()])
|
|
945
979
|
);
|
|
946
|
-
var ProjectionSetPayloadSchema =
|
|
947
|
-
setAll:
|
|
980
|
+
var ProjectionSetPayloadSchema = z26.object({
|
|
981
|
+
setAll: z26.union([ProjectionDirectiveSchema, z26.null()]).optional(),
|
|
948
982
|
set: ProjectionPreferencesSchema.optional()
|
|
949
983
|
});
|
|
950
984
|
|
|
951
985
|
// ../spacestation/src/focus/focus.ts
|
|
952
|
-
import { z as
|
|
953
|
-
var FocusElementPayloadSchema =
|
|
954
|
-
elementId:
|
|
986
|
+
import { z as z27 } from "zod";
|
|
987
|
+
var FocusElementPayloadSchema = z27.object({
|
|
988
|
+
elementId: z27.string().min(1)
|
|
955
989
|
});
|
|
956
990
|
|
|
957
991
|
// ../spacestation/src/view/continuation.ts
|
|
958
|
-
import { z as
|
|
959
|
-
var ViewExtendPayloadSchema =
|
|
960
|
-
reason:
|
|
992
|
+
import { z as z28 } from "zod";
|
|
993
|
+
var ViewExtendPayloadSchema = z28.object({
|
|
994
|
+
reason: z28.enum(["scroll_near_bottom"])
|
|
961
995
|
});
|
|
962
996
|
|
|
963
997
|
// ../spacestation/src/attachment/attachment.ts
|
|
964
|
-
import { z as
|
|
998
|
+
import { z as z29 } from "zod";
|
|
965
999
|
var ALLOWED_ATTACHMENT_TYPES = [
|
|
966
1000
|
"image/jpeg",
|
|
967
1001
|
"image/png",
|
|
@@ -973,34 +1007,36 @@ var MAX_ATTACHMENT_BYTES = 10 * 1024 * 1024;
|
|
|
973
1007
|
function isAllowedAttachmentType(mime) {
|
|
974
1008
|
return ALLOWED_ATTACHMENT_TYPES.includes(mime);
|
|
975
1009
|
}
|
|
976
|
-
var AttachmentRefSchema =
|
|
977
|
-
|
|
978
|
-
|
|
1010
|
+
var AttachmentRefSchema = z29.object({
|
|
1011
|
+
// A UUID, as `storeAttachment` mints it: the id becomes a storage path segment,
|
|
1012
|
+
// so nothing else — no `/`, no `..` — may reach that lookup.
|
|
1013
|
+
id: z29.string().uuid(),
|
|
1014
|
+
mimeType: z29.string().refine(isAllowedAttachmentType, {
|
|
979
1015
|
message: "mimeType not on the attachment allow-list"
|
|
980
1016
|
}),
|
|
981
|
-
name:
|
|
982
|
-
size:
|
|
983
|
-
url:
|
|
1017
|
+
name: z29.string().min(1),
|
|
1018
|
+
size: z29.number().int().positive().max(MAX_ATTACHMENT_BYTES),
|
|
1019
|
+
url: z29.string().min(1)
|
|
984
1020
|
});
|
|
985
|
-
var AttachmentRefsSchema =
|
|
1021
|
+
var AttachmentRefsSchema = z29.array(AttachmentRefSchema);
|
|
986
1022
|
|
|
987
1023
|
// ../spacestation/src/contracts/entry-context.ts
|
|
988
|
-
import { z as
|
|
1024
|
+
import { z as z30 } from "zod";
|
|
989
1025
|
var ENTRY_CONTEXT_MAX_VALUE_CHARS = 200;
|
|
990
1026
|
var ENTRY_CONTEXT_MAX_KEYS = 12;
|
|
991
1027
|
var ENTRY_CONTEXT_MAX_NAMESPACES = 8;
|
|
992
1028
|
var ENTRY_CONTEXT_MAX_NAME_CHARS = 64;
|
|
993
|
-
var EntryContextValueSchema =
|
|
994
|
-
var EntryContextNameSchema =
|
|
995
|
-
var EntryContextNamespaceSchema =
|
|
1029
|
+
var EntryContextValueSchema = z30.string().trim().min(1).max(ENTRY_CONTEXT_MAX_VALUE_CHARS);
|
|
1030
|
+
var EntryContextNameSchema = z30.string().trim().min(1).max(ENTRY_CONTEXT_MAX_NAME_CHARS);
|
|
1031
|
+
var EntryContextNamespaceSchema = z30.record(EntryContextNameSchema, EntryContextValueSchema).refine((entries) => Object.keys(entries).length <= ENTRY_CONTEXT_MAX_KEYS, {
|
|
996
1032
|
message: `at most ${ENTRY_CONTEXT_MAX_KEYS} entries per namespace`
|
|
997
1033
|
});
|
|
998
|
-
var EntryContextSchema =
|
|
1034
|
+
var EntryContextSchema = z30.record(EntryContextNameSchema, EntryContextNamespaceSchema).refine((namespaces) => Object.keys(namespaces).length <= ENTRY_CONTEXT_MAX_NAMESPACES, {
|
|
999
1035
|
message: `at most ${ENTRY_CONTEXT_MAX_NAMESPACES} entry-context namespaces`
|
|
1000
1036
|
});
|
|
1001
1037
|
|
|
1002
1038
|
// ../spacestation/src/contracts/session-arrival.ts
|
|
1003
|
-
import { z as
|
|
1039
|
+
import { z as z31 } from "zod";
|
|
1004
1040
|
var SURFACES = [
|
|
1005
1041
|
"spacefront",
|
|
1006
1042
|
"embed",
|
|
@@ -1010,11 +1046,11 @@ var SURFACES = [
|
|
|
1010
1046
|
"playground",
|
|
1011
1047
|
"automation"
|
|
1012
1048
|
];
|
|
1013
|
-
var SurfaceSchema =
|
|
1049
|
+
var SurfaceSchema = z31.enum(SURFACES);
|
|
1014
1050
|
var CLICK_ID_KINDS = ["gclid", "fbclid", "msclkid", "wbraid", "gbraid"];
|
|
1015
|
-
var ClickIdKindSchema =
|
|
1051
|
+
var ClickIdKindSchema = z31.enum(CLICK_ID_KINDS);
|
|
1016
1052
|
var VISITOR_ID_DURABILITIES = ["persisted", "ephemeral", "host_supplied"];
|
|
1017
|
-
var VisitorIdDurabilitySchema =
|
|
1053
|
+
var VisitorIdDurabilitySchema = z31.enum(VISITOR_ID_DURABILITIES);
|
|
1018
1054
|
var TRAFFIC_BUCKETS = [
|
|
1019
1055
|
"paid_google",
|
|
1020
1056
|
"paid_meta",
|
|
@@ -1026,10 +1062,10 @@ var TRAFFIC_BUCKETS = [
|
|
|
1026
1062
|
"direct",
|
|
1027
1063
|
"unknown"
|
|
1028
1064
|
];
|
|
1029
|
-
var TrafficBucketSchema =
|
|
1065
|
+
var TrafficBucketSchema = z31.enum(TRAFFIC_BUCKETS);
|
|
1030
1066
|
var ARRIVAL_MAX_VALUE_CHARS = 200;
|
|
1031
|
-
var ArrivalValueSchema =
|
|
1032
|
-
var SessionArrivalSchema =
|
|
1067
|
+
var ArrivalValueSchema = z31.string().trim().min(1).max(ARRIVAL_MAX_VALUE_CHARS);
|
|
1068
|
+
var SessionArrivalSchema = z31.object({
|
|
1033
1069
|
utmSource: ArrivalValueSchema.optional(),
|
|
1034
1070
|
utmMedium: ArrivalValueSchema.optional(),
|
|
1035
1071
|
utmCampaign: ArrivalValueSchema.optional(),
|
|
@@ -1062,40 +1098,88 @@ var ARRIVAL_PARAMS = [
|
|
|
1062
1098
|
...CLICK_ID_KINDS
|
|
1063
1099
|
];
|
|
1064
1100
|
|
|
1101
|
+
// ../spacestation/src/contracts/wire-protocol.ts
|
|
1102
|
+
var WIRE_PROTOCOL_VERSION = 1;
|
|
1103
|
+
var WIRE_PROTOCOL_PARAM = "protocol";
|
|
1104
|
+
|
|
1065
1105
|
// ../spacestation/src/catalog/attribute-registry.ts
|
|
1066
|
-
import { z as
|
|
1067
|
-
var AttributeScopeBucketSchema =
|
|
1068
|
-
scope:
|
|
1069
|
-
needles:
|
|
1070
|
-
label:
|
|
1106
|
+
import { z as z32 } from "zod";
|
|
1107
|
+
var AttributeScopeBucketSchema = z32.object({
|
|
1108
|
+
scope: z32.string(),
|
|
1109
|
+
needles: z32.array(z32.string()).readonly(),
|
|
1110
|
+
label: z32.string().optional()
|
|
1071
1111
|
});
|
|
1072
|
-
var AttributeScopeConfigSchema =
|
|
1073
|
-
facet:
|
|
1074
|
-
buckets:
|
|
1075
|
-
emptyScope:
|
|
1076
|
-
noMatchScope:
|
|
1077
|
-
ignoreValues:
|
|
1078
|
-
emptyScopeLabel:
|
|
1079
|
-
noMatchScopeLabel:
|
|
1112
|
+
var AttributeScopeConfigSchema = z32.object({
|
|
1113
|
+
facet: z32.string(),
|
|
1114
|
+
buckets: z32.array(AttributeScopeBucketSchema).readonly(),
|
|
1115
|
+
emptyScope: z32.string(),
|
|
1116
|
+
noMatchScope: z32.string(),
|
|
1117
|
+
ignoreValues: z32.array(z32.string()).readonly(),
|
|
1118
|
+
emptyScopeLabel: z32.string().optional(),
|
|
1119
|
+
noMatchScopeLabel: z32.string().optional()
|
|
1080
1120
|
});
|
|
1081
|
-
var AttributeDefBaseSchema =
|
|
1082
|
-
description:
|
|
1083
|
-
durable:
|
|
1084
|
-
label:
|
|
1121
|
+
var AttributeDefBaseSchema = z32.object({
|
|
1122
|
+
description: z32.string().optional(),
|
|
1123
|
+
durable: z32.boolean().optional(),
|
|
1124
|
+
label: z32.string().optional()
|
|
1085
1125
|
});
|
|
1086
|
-
var AttributeDefSchema =
|
|
1087
|
-
AttributeDefBaseSchema.extend({ kind:
|
|
1088
|
-
AttributeDefBaseSchema.extend({ kind:
|
|
1089
|
-
AttributeDefBaseSchema.extend({ kind:
|
|
1090
|
-
AttributeDefBaseSchema.extend({ kind:
|
|
1126
|
+
var AttributeDefSchema = z32.discriminatedUnion("kind", [
|
|
1127
|
+
AttributeDefBaseSchema.extend({ kind: z32.literal("enum"), values: z32.array(z32.string()) }),
|
|
1128
|
+
AttributeDefBaseSchema.extend({ kind: z32.literal("free_text") }),
|
|
1129
|
+
AttributeDefBaseSchema.extend({ kind: z32.literal("date_or_season") }),
|
|
1130
|
+
AttributeDefBaseSchema.extend({ kind: z32.literal("money_or_band") }),
|
|
1091
1131
|
AttributeDefBaseSchema.extend({
|
|
1092
|
-
kind:
|
|
1093
|
-
min:
|
|
1094
|
-
max:
|
|
1095
|
-
unit:
|
|
1132
|
+
kind: z32.literal("number"),
|
|
1133
|
+
min: z32.number().optional(),
|
|
1134
|
+
max: z32.number().optional(),
|
|
1135
|
+
unit: z32.string().optional()
|
|
1096
1136
|
})
|
|
1097
1137
|
]);
|
|
1098
1138
|
|
|
1139
|
+
// ../spacestation/src/space/agent-directive.ts
|
|
1140
|
+
import { z as z33 } from "zod";
|
|
1141
|
+
var AGENT_DIRECTIVE_KINDS = ["preference", "pairing", "order of things", "promise", "threshold"];
|
|
1142
|
+
var AGENT_DIRECTIVE_SEVERITIES = ["a missed opportunity", "a problem", "unacceptable"];
|
|
1143
|
+
var AGENT_DIRECTIVE_SOURCES = ["owner", "operator", "session-lesson"];
|
|
1144
|
+
var AGENT_DIRECTIVE_STATUSES = ["proposed", "active", "rejected", "retired"];
|
|
1145
|
+
var AgentDirectiveSchema = z33.object({
|
|
1146
|
+
name: z33.string().trim().min(1).max(80),
|
|
1147
|
+
kind: z33.enum(AGENT_DIRECTIVE_KINDS),
|
|
1148
|
+
severity: z33.enum(AGENT_DIRECTIVE_SEVERITIES),
|
|
1149
|
+
/** No bare URL: a URL is a hallucination surface, and a handle is not a
|
|
1150
|
+
* product name. */
|
|
1151
|
+
text: z33.string().trim().min(1).max(1e3).refine((t) => !/https?:\/\//.test(t), "a directive names things by name, never by URL")
|
|
1152
|
+
}).strict();
|
|
1153
|
+
var SpaceAgentDirectiveSchema = z33.object({
|
|
1154
|
+
id: z33.string(),
|
|
1155
|
+
position: z33.number().int(),
|
|
1156
|
+
name: z33.string(),
|
|
1157
|
+
kind: z33.enum(AGENT_DIRECTIVE_KINDS),
|
|
1158
|
+
severity: z33.enum(AGENT_DIRECTIVE_SEVERITIES),
|
|
1159
|
+
text: z33.string(),
|
|
1160
|
+
source: z33.enum(AGENT_DIRECTIVE_SOURCES),
|
|
1161
|
+
status: z33.enum(AGENT_DIRECTIVE_STATUSES),
|
|
1162
|
+
/** Who wrote it; null for a lesson the system proposed. */
|
|
1163
|
+
createdBy: z33.string().nullable(),
|
|
1164
|
+
/** Why a mined lesson was proposed; null for a directive a person wrote. */
|
|
1165
|
+
evidence: z33.record(z33.unknown()).nullable(),
|
|
1166
|
+
decidedBy: z33.string().nullable(),
|
|
1167
|
+
decidedAt: z33.string().nullable(),
|
|
1168
|
+
createdAt: z33.string()
|
|
1169
|
+
});
|
|
1170
|
+
var OutcomeTallySchema = z33.object({ turns: z33.number().int(), acted: z33.number().int() });
|
|
1171
|
+
var SpaceAgentDirectiveListItemSchema = SpaceAgentDirectiveSchema.extend({
|
|
1172
|
+
impact: z33.object({ before: OutcomeTallySchema, after: OutcomeTallySchema }).nullable()
|
|
1173
|
+
});
|
|
1174
|
+
var UpdateAgentDirectiveInputSchema = z33.object({
|
|
1175
|
+
name: AgentDirectiveSchema.shape.name.optional(),
|
|
1176
|
+
kind: AgentDirectiveSchema.shape.kind.optional(),
|
|
1177
|
+
severity: AgentDirectiveSchema.shape.severity.optional(),
|
|
1178
|
+
text: AgentDirectiveSchema.shape.text.optional(),
|
|
1179
|
+
status: z33.enum(AGENT_DIRECTIVE_STATUSES).optional()
|
|
1180
|
+
}).strict();
|
|
1181
|
+
var ReorderAgentDirectivesInputSchema = z33.object({ ids: z33.array(z33.string()).min(1) }).strict();
|
|
1182
|
+
|
|
1099
1183
|
// ../spacestation/src/space/workspace-catalog.ts
|
|
1100
1184
|
var COMPONENT_SOURCE = {
|
|
1101
1185
|
ui: "@fourty/ui"
|
|
@@ -1124,30 +1208,30 @@ var DEFAULT_SPACE_CONFIG = {
|
|
|
1124
1208
|
};
|
|
1125
1209
|
|
|
1126
1210
|
// ../spacestation/src/space/trace.ts
|
|
1127
|
-
import { z as
|
|
1128
|
-
var RunTokenUsageSchema =
|
|
1129
|
-
input_tokens:
|
|
1130
|
-
output_tokens:
|
|
1131
|
-
cache_read_tokens:
|
|
1211
|
+
import { z as z34 } from "zod";
|
|
1212
|
+
var RunTokenUsageSchema = z34.object({
|
|
1213
|
+
input_tokens: z34.number().optional(),
|
|
1214
|
+
output_tokens: z34.number().optional(),
|
|
1215
|
+
cache_read_tokens: z34.number().optional()
|
|
1132
1216
|
});
|
|
1133
|
-
var TraceRecordSchema =
|
|
1134
|
-
id:
|
|
1135
|
-
spaceId:
|
|
1136
|
-
sessionId:
|
|
1217
|
+
var TraceRecordSchema = z34.object({
|
|
1218
|
+
id: z34.string().uuid(),
|
|
1219
|
+
spaceId: z34.string().uuid().nullable(),
|
|
1220
|
+
sessionId: z34.string(),
|
|
1137
1221
|
/** OTP-verified visitor email the session was unlocked with, or `null`
|
|
1138
1222
|
* for an unlocked space / anonymous unlock. */
|
|
1139
|
-
visitorEmail:
|
|
1140
|
-
userPrompt:
|
|
1141
|
-
branch:
|
|
1142
|
-
responseText:
|
|
1143
|
-
layout:
|
|
1144
|
-
phaseTimings:
|
|
1145
|
-
tokensByModel:
|
|
1146
|
-
toolCalls:
|
|
1147
|
-
diagnostics:
|
|
1148
|
-
latencyFirstText:
|
|
1149
|
-
latencyFirstPatch:
|
|
1150
|
-
latencyTotal:
|
|
1223
|
+
visitorEmail: z34.string().nullable(),
|
|
1224
|
+
userPrompt: z34.string(),
|
|
1225
|
+
branch: z34.string().nullable(),
|
|
1226
|
+
responseText: z34.string().nullable(),
|
|
1227
|
+
layout: z34.unknown().nullable(),
|
|
1228
|
+
phaseTimings: z34.record(z34.number()).nullable(),
|
|
1229
|
+
tokensByModel: z34.record(RunTokenUsageSchema).nullable(),
|
|
1230
|
+
toolCalls: z34.array(z34.unknown()).nullable(),
|
|
1231
|
+
diagnostics: z34.array(z34.unknown()).nullable(),
|
|
1232
|
+
latencyFirstText: z34.number().int().nullable(),
|
|
1233
|
+
latencyFirstPatch: z34.number().int().nullable(),
|
|
1234
|
+
latencyTotal: z34.number().int().nullable(),
|
|
1151
1235
|
/**
|
|
1152
1236
|
* The CLIENT's turn id for this run, or `null`.
|
|
1153
1237
|
*
|
|
@@ -1163,29 +1247,29 @@ var TraceRecordSchema = z31.object({
|
|
|
1163
1247
|
* a turn whose ack the client never saw — none of which is evidence that a
|
|
1164
1248
|
* visitor asked something and got nothing.
|
|
1165
1249
|
*/
|
|
1166
|
-
turnId:
|
|
1250
|
+
turnId: z34.string().nullable(),
|
|
1167
1251
|
/** Serialized `TraceTracker.exportState()` payload (parsed object) —
|
|
1168
1252
|
* lets the inspector rehydrate this run verbatim after a reload. */
|
|
1169
|
-
trackerState:
|
|
1170
|
-
createdAt:
|
|
1253
|
+
trackerState: z34.unknown().nullable(),
|
|
1254
|
+
createdAt: z34.string()
|
|
1171
1255
|
});
|
|
1172
|
-
var MillisecondsSchema =
|
|
1173
|
-
var CreateTraceInputSchema =
|
|
1174
|
-
spaceId:
|
|
1175
|
-
sessionId:
|
|
1176
|
-
visitorEmail:
|
|
1177
|
-
userPrompt:
|
|
1178
|
-
branch:
|
|
1179
|
-
responseText:
|
|
1180
|
-
layout:
|
|
1181
|
-
phaseTimings:
|
|
1182
|
-
tokensByModel:
|
|
1183
|
-
toolCalls:
|
|
1184
|
-
diagnostics:
|
|
1256
|
+
var MillisecondsSchema = z34.number().nullable().transform((v) => v === null ? null : Math.round(v));
|
|
1257
|
+
var CreateTraceInputSchema = z34.object({
|
|
1258
|
+
spaceId: z34.string().uuid().nullable(),
|
|
1259
|
+
sessionId: z34.string(),
|
|
1260
|
+
visitorEmail: z34.string().nullable(),
|
|
1261
|
+
userPrompt: z34.string(),
|
|
1262
|
+
branch: z34.string().nullable(),
|
|
1263
|
+
responseText: z34.string().nullable(),
|
|
1264
|
+
layout: z34.unknown().nullable(),
|
|
1265
|
+
phaseTimings: z34.record(z34.number()).nullable(),
|
|
1266
|
+
tokensByModel: z34.record(RunTokenUsageSchema).nullable(),
|
|
1267
|
+
toolCalls: z34.array(z34.unknown()).nullable(),
|
|
1268
|
+
diagnostics: z34.array(z34.unknown()).nullable(),
|
|
1185
1269
|
latencyFirstText: MillisecondsSchema,
|
|
1186
1270
|
latencyFirstPatch: MillisecondsSchema,
|
|
1187
1271
|
latencyTotal: MillisecondsSchema,
|
|
1188
|
-
trackerState:
|
|
1272
|
+
trackerState: z34.unknown().nullable(),
|
|
1189
1273
|
/**
|
|
1190
1274
|
* The CLIENT's turn id for this run, or `null`.
|
|
1191
1275
|
*
|
|
@@ -1201,37 +1285,37 @@ var CreateTraceInputSchema = z31.object({
|
|
|
1201
1285
|
* a turn whose ack the client never saw — none of which is evidence that a
|
|
1202
1286
|
* visitor asked something and got nothing.
|
|
1203
1287
|
*/
|
|
1204
|
-
turnId:
|
|
1288
|
+
turnId: z34.string().nullable()
|
|
1205
1289
|
});
|
|
1206
|
-
var AgentSessionSummarySchema =
|
|
1207
|
-
sessionId:
|
|
1290
|
+
var AgentSessionSummarySchema = z34.object({
|
|
1291
|
+
sessionId: z34.string(),
|
|
1208
1292
|
/** Turn rows only; background/secondary runs are excluded by the aggregate. */
|
|
1209
|
-
turnCount:
|
|
1293
|
+
turnCount: z34.number().int(),
|
|
1210
1294
|
/** The session's opening prompt — titles the row in the UI. */
|
|
1211
|
-
firstPrompt:
|
|
1212
|
-
startedAt:
|
|
1213
|
-
lastRunAt:
|
|
1295
|
+
firstPrompt: z34.string(),
|
|
1296
|
+
startedAt: z34.string(),
|
|
1297
|
+
lastRunAt: z34.string(),
|
|
1214
1298
|
/** Summed `latency_total` across the session's turns. */
|
|
1215
|
-
totalLatencyMs:
|
|
1299
|
+
totalLatencyMs: z34.number().int()
|
|
1216
1300
|
});
|
|
1217
|
-
var SessionTurnSchema =
|
|
1218
|
-
id:
|
|
1219
|
-
userPrompt:
|
|
1220
|
-
responseText:
|
|
1301
|
+
var SessionTurnSchema = z34.object({
|
|
1302
|
+
id: z34.string().uuid(),
|
|
1303
|
+
userPrompt: z34.string(),
|
|
1304
|
+
responseText: z34.string().nullable(),
|
|
1221
1305
|
/** Full cumulative Spec committed by this turn — never a patch delta. */
|
|
1222
|
-
layout:
|
|
1223
|
-
createdAt:
|
|
1224
|
-
latencyTotal:
|
|
1225
|
-
phaseTimings:
|
|
1226
|
-
tokensByModel:
|
|
1227
|
-
input_tokens:
|
|
1228
|
-
output_tokens:
|
|
1306
|
+
layout: z34.unknown().nullable(),
|
|
1307
|
+
createdAt: z34.string(),
|
|
1308
|
+
latencyTotal: z34.number().int().nullable(),
|
|
1309
|
+
phaseTimings: z34.record(z34.number()).nullable(),
|
|
1310
|
+
tokensByModel: z34.record(z34.object({
|
|
1311
|
+
input_tokens: z34.number().optional(),
|
|
1312
|
+
output_tokens: z34.number().optional()
|
|
1229
1313
|
})).nullable(),
|
|
1230
|
-
toolCalls:
|
|
1231
|
-
diagnostics:
|
|
1314
|
+
toolCalls: z34.array(z34.unknown()).nullable(),
|
|
1315
|
+
diagnostics: z34.array(z34.unknown()).nullable()
|
|
1232
1316
|
});
|
|
1233
|
-
var SessionReplaySchema =
|
|
1234
|
-
turns:
|
|
1317
|
+
var SessionReplaySchema = z34.object({
|
|
1318
|
+
turns: z34.array(SessionTurnSchema),
|
|
1235
1319
|
/**
|
|
1236
1320
|
* The session's own last-committed layout, read straight off the durable
|
|
1237
1321
|
* session record (`sessions.blob.layout`) rather than derived from `turns`.
|
|
@@ -1242,20 +1326,20 @@ var SessionReplaySchema = z31.object({
|
|
|
1242
1326
|
* a perfectly real layout; only this field can show it. Null exclusively
|
|
1243
1327
|
* when the durable session row itself could not be read.
|
|
1244
1328
|
*/
|
|
1245
|
-
sessionLayout:
|
|
1329
|
+
sessionLayout: z34.record(z34.string(), z34.unknown()).nullable()
|
|
1246
1330
|
});
|
|
1247
|
-
var SessionTraceSchema =
|
|
1248
|
-
trackerState:
|
|
1331
|
+
var SessionTraceSchema = z34.object({
|
|
1332
|
+
trackerState: z34.string().nullable()
|
|
1249
1333
|
});
|
|
1250
|
-
var LlmUsageDailySchema =
|
|
1251
|
-
day:
|
|
1334
|
+
var LlmUsageDailySchema = z34.object({
|
|
1335
|
+
day: z34.string(),
|
|
1252
1336
|
/** Deployment that made the call — 'production', 'staging', 'pr-123', 'development'. */
|
|
1253
|
-
environment:
|
|
1254
|
-
feature:
|
|
1255
|
-
model:
|
|
1256
|
-
provider:
|
|
1337
|
+
environment: z34.string(),
|
|
1338
|
+
feature: z34.string(),
|
|
1339
|
+
model: z34.string(),
|
|
1340
|
+
provider: z34.string(),
|
|
1257
1341
|
/** Masked tail of the key actually billed, or null when unknown/non-Google. */
|
|
1258
|
-
keyFingerprint:
|
|
1342
|
+
keyFingerprint: z34.string().nullable(),
|
|
1259
1343
|
/**
|
|
1260
1344
|
* The space the call served, or null when it served none.
|
|
1261
1345
|
*
|
|
@@ -1264,91 +1348,91 @@ var LlmUsageDailySchema = z31.object({
|
|
|
1264
1348
|
* report that share rather than dropping it, or a per-space total reads as
|
|
1265
1349
|
* the platform total.
|
|
1266
1350
|
*/
|
|
1267
|
-
spaceId:
|
|
1351
|
+
spaceId: z34.string().nullable(),
|
|
1268
1352
|
/**
|
|
1269
1353
|
* The surface of the session the call served (`sessions.surface`), or null
|
|
1270
1354
|
* when it served no session or the session predates surface recording.
|
|
1271
1355
|
* `automation` is the eval harness — the signal that files an ordinary
|
|
1272
1356
|
* `agent-turn` as testing spend rather than as a visitor's.
|
|
1273
1357
|
*/
|
|
1274
|
-
surface:
|
|
1275
|
-
inputTokens:
|
|
1276
|
-
outputTokens:
|
|
1358
|
+
surface: z34.string().nullable(),
|
|
1359
|
+
inputTokens: z34.number(),
|
|
1360
|
+
outputTokens: z34.number(),
|
|
1277
1361
|
/** Subset of inputTokens, never additional to it. */
|
|
1278
|
-
cachedInputTokens:
|
|
1279
|
-
reasoningTokens:
|
|
1280
|
-
callCount:
|
|
1281
|
-
errorCount:
|
|
1282
|
-
estimatedCostUsd:
|
|
1362
|
+
cachedInputTokens: z34.number(),
|
|
1363
|
+
reasoningTokens: z34.number(),
|
|
1364
|
+
callCount: z34.number(),
|
|
1365
|
+
errorCount: z34.number(),
|
|
1366
|
+
estimatedCostUsd: z34.number().nullable()
|
|
1283
1367
|
});
|
|
1284
|
-
var LlmUsageBySessionSchema =
|
|
1285
|
-
sessionId:
|
|
1286
|
-
environment:
|
|
1287
|
-
model:
|
|
1368
|
+
var LlmUsageBySessionSchema = z34.object({
|
|
1369
|
+
sessionId: z34.string(),
|
|
1370
|
+
environment: z34.string(),
|
|
1371
|
+
model: z34.string(),
|
|
1288
1372
|
/** The space this session belongs to, or null for a session with no space. */
|
|
1289
|
-
spaceId:
|
|
1373
|
+
spaceId: z34.string().nullable(),
|
|
1290
1374
|
/** The session's surface — see `LlmUsageDailySchema.surface`. */
|
|
1291
|
-
surface:
|
|
1375
|
+
surface: z34.string().nullable(),
|
|
1292
1376
|
/** Label only — the first feature seen in the session. */
|
|
1293
|
-
firstFeature:
|
|
1294
|
-
startedAt:
|
|
1295
|
-
endedAt:
|
|
1296
|
-
inputTokens:
|
|
1297
|
-
outputTokens:
|
|
1298
|
-
cachedInputTokens:
|
|
1299
|
-
reasoningTokens:
|
|
1300
|
-
callCount:
|
|
1301
|
-
errorCount:
|
|
1377
|
+
firstFeature: z34.string(),
|
|
1378
|
+
startedAt: z34.string(),
|
|
1379
|
+
endedAt: z34.string(),
|
|
1380
|
+
inputTokens: z34.number(),
|
|
1381
|
+
outputTokens: z34.number(),
|
|
1382
|
+
cachedInputTokens: z34.number(),
|
|
1383
|
+
reasoningTokens: z34.number(),
|
|
1384
|
+
callCount: z34.number(),
|
|
1385
|
+
errorCount: z34.number(),
|
|
1302
1386
|
/** Priced server-side, like the daily rollup — the browser never carries a
|
|
1303
1387
|
* rate table, so there is exactly one place a price can be wrong. Null when
|
|
1304
1388
|
* the model is unpriced; never 0, which would read as free. */
|
|
1305
|
-
estimatedCostUsd:
|
|
1389
|
+
estimatedCostUsd: z34.number().nullable()
|
|
1306
1390
|
});
|
|
1307
|
-
var LlmSessionsDailySchema =
|
|
1308
|
-
day:
|
|
1309
|
-
environment:
|
|
1310
|
-
sessionCount:
|
|
1391
|
+
var LlmSessionsDailySchema = z34.object({
|
|
1392
|
+
day: z34.string(),
|
|
1393
|
+
environment: z34.string(),
|
|
1394
|
+
sessionCount: z34.number()
|
|
1311
1395
|
});
|
|
1312
1396
|
|
|
1313
1397
|
// ../spacestation/src/space/session-queue.ts
|
|
1314
|
-
import { z as
|
|
1398
|
+
import { z as z36 } from "zod";
|
|
1315
1399
|
|
|
1316
1400
|
// ../spacestation/src/space/session-activity.ts
|
|
1317
|
-
import { z as
|
|
1318
|
-
var SessionActivityEventSchema =
|
|
1319
|
-
id:
|
|
1320
|
-
kind:
|
|
1321
|
-
occurredAt:
|
|
1322
|
-
source:
|
|
1323
|
-
surface:
|
|
1324
|
-
payload:
|
|
1401
|
+
import { z as z35 } from "zod";
|
|
1402
|
+
var SessionActivityEventSchema = z35.object({
|
|
1403
|
+
id: z35.string(),
|
|
1404
|
+
kind: z35.string(),
|
|
1405
|
+
occurredAt: z35.string(),
|
|
1406
|
+
source: z35.string(),
|
|
1407
|
+
surface: z35.string(),
|
|
1408
|
+
payload: z35.record(z35.unknown())
|
|
1325
1409
|
});
|
|
1326
|
-
var SessionActivitySchema =
|
|
1327
|
-
events:
|
|
1328
|
-
hasMore:
|
|
1410
|
+
var SessionActivitySchema = z35.object({
|
|
1411
|
+
events: z35.array(SessionActivityEventSchema),
|
|
1412
|
+
hasMore: z35.boolean()
|
|
1329
1413
|
});
|
|
1330
1414
|
|
|
1331
1415
|
// ../spacestation/src/space/session-queue.ts
|
|
1332
|
-
var SessionVerdictSchema =
|
|
1333
|
-
var RecordableVerdictSchema =
|
|
1334
|
-
var SessionReviewEventSchema =
|
|
1335
|
-
id:
|
|
1416
|
+
var SessionVerdictSchema = z36.enum(["unreviewed", "viewed", "bug"]);
|
|
1417
|
+
var RecordableVerdictSchema = z36.enum(["viewed", "bug"]);
|
|
1418
|
+
var SessionReviewEventSchema = z36.object({
|
|
1419
|
+
id: z36.string().uuid(),
|
|
1336
1420
|
verdict: RecordableVerdictSchema,
|
|
1337
1421
|
/** Account email of the operator who judged it. Attribution is the reason the
|
|
1338
1422
|
* log is append-only rather than a mutable current-state row. */
|
|
1339
|
-
reviewer:
|
|
1340
|
-
note:
|
|
1341
|
-
createdAt:
|
|
1423
|
+
reviewer: z36.string(),
|
|
1424
|
+
note: z36.string().nullable(),
|
|
1425
|
+
createdAt: z36.string()
|
|
1342
1426
|
});
|
|
1343
|
-
var BugSeveritySchema =
|
|
1344
|
-
var BugLocationSchema =
|
|
1345
|
-
elementId:
|
|
1427
|
+
var BugSeveritySchema = z36.enum(["high", "medium", "low"]);
|
|
1428
|
+
var BugLocationSchema = z36.object({
|
|
1429
|
+
elementId: z36.string().nullable(),
|
|
1346
1430
|
/** Display only — the catalog component type, e.g. "productGrid". Null
|
|
1347
1431
|
* alongside a null `elementId`. */
|
|
1348
|
-
elementType:
|
|
1432
|
+
elementType: z36.string().nullable(),
|
|
1349
1433
|
/** Fraction of the ELEMENT's own box. Null for a page anchor. */
|
|
1350
|
-
offsetXPct:
|
|
1351
|
-
offsetYPct:
|
|
1434
|
+
offsetXPct: z36.number().min(0).max(100).nullable(),
|
|
1435
|
+
offsetYPct: z36.number().min(0).max(100).nullable(),
|
|
1352
1436
|
/**
|
|
1353
1437
|
* ABSOLUTE document pixels, for a pin with no element under it. Null for an
|
|
1354
1438
|
* element anchor.
|
|
@@ -1359,8 +1443,8 @@ var BugLocationSchema = z33.object({
|
|
|
1359
1443
|
* on the page with it. Measured before this was fixed: growing the page 9%
|
|
1360
1444
|
* slid a pin 32px, so a pin ran away from the cursor reaching for it.
|
|
1361
1445
|
*/
|
|
1362
|
-
pageX:
|
|
1363
|
-
pageY:
|
|
1446
|
+
pageX: z36.number().nullable(),
|
|
1447
|
+
pageY: z36.number().nullable()
|
|
1364
1448
|
}).refine(
|
|
1365
1449
|
(loc) => {
|
|
1366
1450
|
const hasOffsets = loc.offsetXPct !== null && loc.offsetYPct !== null;
|
|
@@ -1374,24 +1458,24 @@ var BugLocationSchema = z33.object({
|
|
|
1374
1458
|
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
1459
|
}
|
|
1376
1460
|
);
|
|
1377
|
-
var SessionBugSchema =
|
|
1378
|
-
id:
|
|
1461
|
+
var SessionBugSchema = z36.object({
|
|
1462
|
+
id: z36.string().uuid(),
|
|
1379
1463
|
/** 1-based turn the fault was observed on; null when the fault is session-wide. */
|
|
1380
|
-
turnIndex:
|
|
1464
|
+
turnIndex: z36.number().int().nullable(),
|
|
1381
1465
|
/** Where on that turn's canvas the pin was dropped; null for a bug filed
|
|
1382
1466
|
* without pinning a spot. */
|
|
1383
1467
|
location: BugLocationSchema.nullable(),
|
|
1384
|
-
provider:
|
|
1385
|
-
issueKey:
|
|
1386
|
-
issueUrl:
|
|
1468
|
+
provider: z36.string(),
|
|
1469
|
+
issueKey: z36.string().nullable(),
|
|
1470
|
+
issueUrl: z36.string().nullable(),
|
|
1387
1471
|
/** The tracker's own state word ('Todo', 'Done', …) — their vocabulary, so
|
|
1388
1472
|
* open text. Null until first synced. */
|
|
1389
|
-
issueState:
|
|
1390
|
-
title:
|
|
1391
|
-
body:
|
|
1473
|
+
issueState: z36.string().nullable(),
|
|
1474
|
+
title: z36.string(),
|
|
1475
|
+
body: z36.string(),
|
|
1392
1476
|
severity: BugSeveritySchema,
|
|
1393
|
-
createdBy:
|
|
1394
|
-
createdAt:
|
|
1477
|
+
createdBy: z36.string(),
|
|
1478
|
+
createdAt: z36.string(),
|
|
1395
1479
|
/**
|
|
1396
1480
|
* When this bug was resolved from the console; null means still OPEN.
|
|
1397
1481
|
*
|
|
@@ -1400,55 +1484,55 @@ var SessionBugSchema = z33.object({
|
|
|
1400
1484
|
* whether a particular fault is still live. The timestamp IS the state, so
|
|
1401
1485
|
* no boolean can contradict it.
|
|
1402
1486
|
*/
|
|
1403
|
-
resolvedAt:
|
|
1404
|
-
resolvedBy:
|
|
1487
|
+
resolvedAt: z36.string().nullable(),
|
|
1488
|
+
resolvedBy: z36.string().nullable()
|
|
1405
1489
|
});
|
|
1406
|
-
var SpaceBugSchema = SessionBugSchema.extend({ sessionId:
|
|
1407
|
-
var SessionCommentSchema =
|
|
1408
|
-
id:
|
|
1490
|
+
var SpaceBugSchema = SessionBugSchema.extend({ sessionId: z36.string() });
|
|
1491
|
+
var SessionCommentSchema = z36.object({
|
|
1492
|
+
id: z36.string().uuid(),
|
|
1409
1493
|
/** Set = a reply in that bug's thread. Null = a standalone comment pin. */
|
|
1410
|
-
bugId:
|
|
1494
|
+
bugId: z36.string().uuid().nullable(),
|
|
1411
1495
|
/** 1-based turn the comment was left on; null for a reply (it reads its
|
|
1412
1496
|
* parent bug's turn). */
|
|
1413
|
-
turnIndex:
|
|
1497
|
+
turnIndex: z36.number().int().nullable(),
|
|
1414
1498
|
/** The canvas anchor for a STANDALONE comment's own pin; null for a reply. */
|
|
1415
1499
|
location: BugLocationSchema.nullable(),
|
|
1416
|
-
body:
|
|
1417
|
-
createdBy:
|
|
1418
|
-
createdAt:
|
|
1500
|
+
body: z36.string(),
|
|
1501
|
+
createdBy: z36.string(),
|
|
1502
|
+
createdAt: z36.string()
|
|
1419
1503
|
});
|
|
1420
|
-
var CreateCommentInputSchema =
|
|
1421
|
-
bugId:
|
|
1422
|
-
turnIndex:
|
|
1504
|
+
var CreateCommentInputSchema = z36.object({
|
|
1505
|
+
bugId: z36.string().uuid().nullable(),
|
|
1506
|
+
turnIndex: z36.number().int().positive().nullable(),
|
|
1423
1507
|
location: BugLocationSchema.nullable(),
|
|
1424
1508
|
// Trimmed, so whitespace is not content: `.min(1)` alone accepted a comment
|
|
1425
1509
|
// of three spaces, which renders as an empty bubble nobody can interpret.
|
|
1426
|
-
body:
|
|
1510
|
+
body: z36.string().trim().min(1)
|
|
1427
1511
|
}).refine((input) => input.bugId === null !== (input.location === null), {
|
|
1428
1512
|
message: "a comment is either a reply (bugId, no location) or a standalone pin (location, no bugId)"
|
|
1429
1513
|
});
|
|
1430
|
-
var UpdateCommentInputSchema =
|
|
1431
|
-
body:
|
|
1432
|
-
bugId:
|
|
1514
|
+
var UpdateCommentInputSchema = z36.object({
|
|
1515
|
+
body: z36.string().trim().min(1).optional(),
|
|
1516
|
+
bugId: z36.string().uuid().nullable().optional(),
|
|
1433
1517
|
location: BugLocationSchema.nullable().optional()
|
|
1434
1518
|
});
|
|
1435
|
-
var SessionFormFactorSchema =
|
|
1436
|
-
var SessionSummarySchema =
|
|
1437
|
-
sessionId:
|
|
1519
|
+
var SessionFormFactorSchema = z36.enum(["mobile", "desktop"]).nullable();
|
|
1520
|
+
var SessionSummarySchema = z36.object({
|
|
1521
|
+
sessionId: z36.string(),
|
|
1438
1522
|
/** Stable per-browser id — the join key across a visitor's sessions. Null when
|
|
1439
1523
|
* the session row is gone (pruned) or predates the `sessions` table. */
|
|
1440
|
-
visitorId:
|
|
1524
|
+
visitorId: z36.string().nullable(),
|
|
1441
1525
|
/** Provider-qualified identity anchor, present only once the visitor
|
|
1442
1526
|
* identified themselves. Both null together means "not identified yet". */
|
|
1443
|
-
identityProvider:
|
|
1444
|
-
identityKey:
|
|
1527
|
+
identityProvider: z36.string().nullable(),
|
|
1528
|
+
identityKey: z36.string().nullable(),
|
|
1445
1529
|
/** Team/test traffic. The queue hides these by default. */
|
|
1446
|
-
isInternal:
|
|
1530
|
+
isInternal: z36.boolean(),
|
|
1447
1531
|
/** Build that served the session. Null = not captured; a version filter must
|
|
1448
1532
|
* therefore EXCLUDE it rather than let it match an arbitrary bucket. */
|
|
1449
|
-
clientVersion:
|
|
1533
|
+
clientVersion: z36.string().nullable(),
|
|
1450
1534
|
/** Commit-shaped interaction signals, counted, keyed by open `SignalType`. */
|
|
1451
|
-
signalCounts:
|
|
1535
|
+
signalCounts: z36.record(z36.number()),
|
|
1452
1536
|
/**
|
|
1453
1537
|
* Did this conversation ACQUIRE anything, and how many times?
|
|
1454
1538
|
*
|
|
@@ -1465,7 +1549,7 @@ var SessionSummarySchema = z33.object({
|
|
|
1465
1549
|
* predates the column — and renders as no mark at all. It never means zero:
|
|
1466
1550
|
* zero is a real, recorded answer and the rail reports it as one.
|
|
1467
1551
|
*/
|
|
1468
|
-
conversionAttempts:
|
|
1552
|
+
conversionAttempts: z36.number().int().nullable(),
|
|
1469
1553
|
/**
|
|
1470
1554
|
* The same attempts split by EVENT KIND, keyed by the kind's own name
|
|
1471
1555
|
* (`commerce.cart_line_added`, `commerce.registry_clicked`), counted distinct
|
|
@@ -1481,7 +1565,7 @@ var SessionSummarySchema = z33.object({
|
|
|
1481
1565
|
* kinds together, and one attempt id appearing under both would be counted
|
|
1482
1566
|
* once there and twice here.
|
|
1483
1567
|
*/
|
|
1484
|
-
conversionKinds:
|
|
1568
|
+
conversionKinds: z36.record(z36.number()),
|
|
1485
1569
|
/**
|
|
1486
1570
|
* Every analytics funnel step this session reached, in funnel order — the
|
|
1487
1571
|
* dashboard's own step ids, read by the same per-step predicates, so a queue
|
|
@@ -1489,20 +1573,20 @@ var SessionSummarySchema = z33.object({
|
|
|
1489
1573
|
* set of strings for the reason `conversionKinds` is: the contract does not
|
|
1490
1574
|
* learn what a step means. Empty only when read from a pre-column database.
|
|
1491
1575
|
*/
|
|
1492
|
-
funnelSteps:
|
|
1576
|
+
funnelSteps: z36.array(z36.string()),
|
|
1493
1577
|
/**
|
|
1494
1578
|
* The connector's opaque handle for what this session produced in its back
|
|
1495
1579
|
* office — present only once a checkout actually reached the platform. The
|
|
1496
1580
|
* console hands it to the back-office link registry; nothing else reads it.
|
|
1497
1581
|
*/
|
|
1498
|
-
backOfficeRef:
|
|
1582
|
+
backOfficeRef: z36.string().nullable(),
|
|
1499
1583
|
/**
|
|
1500
1584
|
* The order this session produced, when the connector's back office reported
|
|
1501
1585
|
* it (`session_orders`): its opaque id and the back office's own name for it.
|
|
1502
1586
|
* Both null when no order is known — the cart handle above is then the door.
|
|
1503
1587
|
*/
|
|
1504
|
-
orderRef:
|
|
1505
|
-
orderLabel:
|
|
1588
|
+
orderRef: z36.string().nullable(),
|
|
1589
|
+
orderLabel: z36.string().nullable(),
|
|
1506
1590
|
/**
|
|
1507
1591
|
* Which shell this session rendered — the one thing about the CAPTURE a list
|
|
1508
1592
|
* needs.
|
|
@@ -1515,12 +1599,12 @@ var SessionSummarySchema = z33.object({
|
|
|
1515
1599
|
* on a desktop are not the same session.
|
|
1516
1600
|
*/
|
|
1517
1601
|
formFactor: SessionFormFactorSchema,
|
|
1518
|
-
turnCount:
|
|
1602
|
+
turnCount: z36.number().int(),
|
|
1519
1603
|
/** The visitor's opening message — the single most informative field for
|
|
1520
1604
|
* deciding whether a session is worth opening, hence the widest column. */
|
|
1521
|
-
firstPrompt:
|
|
1522
|
-
startedAt:
|
|
1523
|
-
lastRunAt:
|
|
1605
|
+
firstPrompt: z36.string(),
|
|
1606
|
+
startedAt: z36.string(),
|
|
1607
|
+
lastRunAt: z36.string(),
|
|
1524
1608
|
/**
|
|
1525
1609
|
* The VISITOR's own IANA zone (`America/New_York`), read from their browser
|
|
1526
1610
|
* at session create — what the two timestamps above should be read in.
|
|
@@ -1548,7 +1632,7 @@ var SessionSummarySchema = z33.object({
|
|
|
1548
1632
|
* Client-asserted and never validated against a zone table, so every consumer
|
|
1549
1633
|
* must tolerate an unknown name: `Intl` throws a RangeError on one.
|
|
1550
1634
|
*/
|
|
1551
|
-
visitorTimeZone:
|
|
1635
|
+
visitorTimeZone: z36.string().nullable(),
|
|
1552
1636
|
/**
|
|
1553
1637
|
* Mean TIME TO FIRST PATCH, over the turns that recorded one — the first
|
|
1554
1638
|
* layout op reaching the visitor, and THE latency the project is managed on.
|
|
@@ -1556,31 +1640,31 @@ var SessionSummarySchema = z33.object({
|
|
|
1556
1640
|
* `totalLatencyMs` carries the chip-gen tail that runs after the visitor is
|
|
1557
1641
|
* already reading. Null when no turn in the session recorded a patch.
|
|
1558
1642
|
*/
|
|
1559
|
-
avgTtftMs:
|
|
1643
|
+
avgTtftMs: z36.number().int().nullable(),
|
|
1560
1644
|
/** Mean `main_done_ms` — layout + prose complete. Context for the TTFT, not
|
|
1561
1645
|
* a budget: null on sessions older than the mark's recording. */
|
|
1562
|
-
avgMainDoneMs:
|
|
1646
|
+
avgMainDoneMs: z36.number().int().nullable(),
|
|
1563
1647
|
/** Mean `chip_gen_ms` — the pass that runs AFTER mainDone and is out of the
|
|
1564
1648
|
* budget. On the row only to explain the gap to `totalLatencyMs`. */
|
|
1565
|
-
avgChipGenMs:
|
|
1566
|
-
totalLatencyMs:
|
|
1567
|
-
durationMs:
|
|
1649
|
+
avgChipGenMs: z36.number().int().nullable(),
|
|
1650
|
+
totalLatencyMs: z36.number().int(),
|
|
1651
|
+
durationMs: z36.number().int(),
|
|
1568
1652
|
/** Inferred from recent activity — nothing writes a session-end marker. A
|
|
1569
1653
|
* live session streams and cannot be given a verdict until it ends. */
|
|
1570
|
-
isLive:
|
|
1654
|
+
isLive: z36.boolean(),
|
|
1571
1655
|
verdict: SessionVerdictSchema,
|
|
1572
|
-
reviewedBy:
|
|
1573
|
-
reviewedAt:
|
|
1656
|
+
reviewedBy: z36.string().nullable(),
|
|
1657
|
+
reviewedAt: z36.string().nullable(),
|
|
1574
1658
|
/** Latest filed bug, flattened onto the row so the queue can show its live
|
|
1575
1659
|
* state without a second request. */
|
|
1576
|
-
bugIssueKey:
|
|
1577
|
-
bugIssueUrl:
|
|
1578
|
-
bugIssueState:
|
|
1660
|
+
bugIssueKey: z36.string().nullable(),
|
|
1661
|
+
bugIssueUrl: z36.string().nullable(),
|
|
1662
|
+
bugIssueState: z36.string().nullable()
|
|
1579
1663
|
});
|
|
1580
|
-
var SessionQueuePageSchema =
|
|
1581
|
-
sessions:
|
|
1582
|
-
totalCount:
|
|
1583
|
-
hiddenInternalCount:
|
|
1664
|
+
var SessionQueuePageSchema = z36.object({
|
|
1665
|
+
sessions: z36.array(SessionSummarySchema),
|
|
1666
|
+
totalCount: z36.number().int(),
|
|
1667
|
+
hiddenInternalCount: z36.number().int(),
|
|
1584
1668
|
/**
|
|
1585
1669
|
* Bounced sessions the queue left out — no turn and no add, the default.
|
|
1586
1670
|
*
|
|
@@ -1590,65 +1674,67 @@ var SessionQueuePageSchema = z33.object({
|
|
|
1590
1674
|
* `totalCount + hiddenBouncedCount` is that population, and this count is the
|
|
1591
1675
|
* analytics dashboard's bounce over the same window.
|
|
1592
1676
|
*/
|
|
1593
|
-
hiddenBouncedCount:
|
|
1677
|
+
hiddenBouncedCount: z36.number().int()
|
|
1594
1678
|
});
|
|
1595
|
-
var SessionQueueFacetsSchema =
|
|
1596
|
-
review:
|
|
1597
|
-
version:
|
|
1598
|
-
turns:
|
|
1599
|
-
durationS:
|
|
1679
|
+
var SessionQueueFacetsSchema = z36.object({
|
|
1680
|
+
review: z36.record(z36.number()),
|
|
1681
|
+
version: z36.record(z36.number()),
|
|
1682
|
+
turns: z36.record(z36.number()),
|
|
1683
|
+
durationS: z36.record(z36.number()),
|
|
1600
1684
|
/** Sessions per funnel step reached — a session counts under every step it reached. */
|
|
1601
|
-
funnel:
|
|
1685
|
+
funnel: z36.record(z36.number())
|
|
1602
1686
|
});
|
|
1603
|
-
var SessionCaptureSchema =
|
|
1604
|
-
viewportWidth:
|
|
1605
|
-
viewportHeight:
|
|
1606
|
-
userAgent:
|
|
1607
|
-
locale:
|
|
1687
|
+
var SessionCaptureSchema = z36.object({
|
|
1688
|
+
viewportWidth: z36.number().int().nullable(),
|
|
1689
|
+
viewportHeight: z36.number().int().nullable(),
|
|
1690
|
+
userAgent: z36.string().nullable(),
|
|
1691
|
+
locale: z36.string().nullable(),
|
|
1608
1692
|
/** Referrer at session create — separates agentic traffic from organic. */
|
|
1609
|
-
referrer:
|
|
1693
|
+
referrer: z36.string().nullable()
|
|
1610
1694
|
});
|
|
1611
|
-
var SessionCaptureInputSchema =
|
|
1612
|
-
viewportWidth:
|
|
1613
|
-
viewportHeight:
|
|
1614
|
-
userAgent:
|
|
1615
|
-
locale:
|
|
1695
|
+
var SessionCaptureInputSchema = z36.object({
|
|
1696
|
+
viewportWidth: z36.number().int().positive().max(2e4).optional(),
|
|
1697
|
+
viewportHeight: z36.number().int().positive().max(2e4).optional(),
|
|
1698
|
+
userAgent: z36.string().max(1e3).optional(),
|
|
1699
|
+
locale: z36.string().max(35).optional(),
|
|
1616
1700
|
/** IANA zone name from the visitor's browser. Bounded rather than validated:
|
|
1617
1701
|
* the zone database grows, and refusing a name this build has not heard of
|
|
1618
1702
|
* would drop a real session's capture over a table that is out of date. */
|
|
1619
|
-
timeZone:
|
|
1620
|
-
referrer:
|
|
1621
|
-
clientVersion:
|
|
1622
|
-
isInternal:
|
|
1703
|
+
timeZone: z36.string().max(64).optional(),
|
|
1704
|
+
referrer: z36.string().max(2048).optional(),
|
|
1705
|
+
clientVersion: z36.string().max(100).optional(),
|
|
1706
|
+
isInternal: z36.boolean().optional()
|
|
1623
1707
|
});
|
|
1624
|
-
var SessionDetailSchema =
|
|
1708
|
+
var SessionDetailSchema = z36.object({
|
|
1625
1709
|
session: SessionSummarySchema,
|
|
1626
1710
|
capture: SessionCaptureSchema,
|
|
1627
1711
|
/** Full verdict history, newest first. Verdicts are revisable, and a session
|
|
1628
1712
|
* re-judged after a fix is the evidence the fix worked. */
|
|
1629
|
-
reviews:
|
|
1630
|
-
bugs:
|
|
1631
|
-
comments:
|
|
1713
|
+
reviews: z36.array(SessionReviewEventSchema),
|
|
1714
|
+
bugs: z36.array(SessionBugSchema),
|
|
1715
|
+
comments: z36.array(SessionCommentSchema),
|
|
1632
1716
|
/** Optional during API/console rolling deployment. Absent is unavailable,
|
|
1633
1717
|
* not evidence of zero visitor activity. */
|
|
1634
1718
|
activity: SessionActivitySchema.optional()
|
|
1635
1719
|
});
|
|
1636
|
-
var RecordVerdictInputSchema =
|
|
1720
|
+
var RecordVerdictInputSchema = z36.object({
|
|
1637
1721
|
verdict: RecordableVerdictSchema,
|
|
1638
|
-
note:
|
|
1722
|
+
note: z36.string().max(2e3).optional()
|
|
1639
1723
|
});
|
|
1640
|
-
var FileBugInputSchema =
|
|
1641
|
-
turnIndex:
|
|
1724
|
+
var FileBugInputSchema = z36.object({
|
|
1725
|
+
turnIndex: z36.number().int().positive().nullable(),
|
|
1642
1726
|
/** Optional — a bug filed without dropping a pin has no location. */
|
|
1643
1727
|
location: BugLocationSchema.nullable().optional(),
|
|
1644
|
-
title:
|
|
1645
|
-
body:
|
|
1728
|
+
title: z36.string().min(1).max(300),
|
|
1729
|
+
body: z36.string().min(1),
|
|
1646
1730
|
severity: BugSeveritySchema,
|
|
1647
|
-
payload:
|
|
1731
|
+
payload: z36.record(z36.unknown())
|
|
1648
1732
|
});
|
|
1649
1733
|
export {
|
|
1650
1734
|
EMPTY_SPEC,
|
|
1651
1735
|
PackageReleaseSchema,
|
|
1736
|
+
WIRE_PROTOCOL_PARAM,
|
|
1737
|
+
WIRE_PROTOCOL_VERSION,
|
|
1652
1738
|
applySinglePatch,
|
|
1653
1739
|
carriesShapeToken,
|
|
1654
1740
|
catalogToWire
|