@genesislcap/ai-assistant 15.106.0 → 15.108.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (34) hide show
  1. package/dist/ai-assistant.api.json +1 -1
  2. package/dist/ai-assistant.d.ts +6 -4
  3. package/dist/chat-driver.cjs +108 -42
  4. package/dist/chat-driver.cjs.map +2 -2
  5. package/dist/chat-driver.mjs +108 -42
  6. package/dist/chat-driver.mjs.map +2 -2
  7. package/dist/custom-elements.json +67 -3
  8. package/dist/dts/chat-driver-node.d.ts +1 -1
  9. package/dist/dts/chat-driver-node.d.ts.map +1 -1
  10. package/dist/dts/components/chat-driver/chat-driver.d.ts.map +1 -1
  11. package/dist/dts/components/chat-driver/turn-recorder.d.ts +48 -12
  12. package/dist/dts/components/chat-driver/turn-recorder.d.ts.map +1 -1
  13. package/dist/dts/genesis/config.d.ts.map +1 -1
  14. package/dist/dts/state/persistence/diagnostics-cursors.d.ts +4 -1
  15. package/dist/dts/state/persistence/diagnostics-cursors.d.ts.map +1 -1
  16. package/dist/dts/state/persistence/diagnostics.d.ts +24 -0
  17. package/dist/dts/state/persistence/diagnostics.d.ts.map +1 -1
  18. package/dist/dts/state/persistence/session-persister.d.ts +2 -2
  19. package/dist/dts/state/persistence/session-persister.d.ts.map +1 -1
  20. package/dist/esm/components/chat-driver/chat-driver.js +42 -19
  21. package/dist/esm/components/chat-driver/turn-recorder.js +57 -35
  22. package/dist/esm/genesis/config.js +1 -1
  23. package/dist/esm/genesis/consumes.js +1 -1
  24. package/dist/esm/state/debug-event-log.js +4 -4
  25. package/dist/esm/state/persistence/diagnostics.js +9 -4
  26. package/dist/esm/state/persistence/session-persister.js +6 -5
  27. package/dist/genesis-consumes.cjs +1 -1
  28. package/dist/genesis-consumes.cjs.map +2 -2
  29. package/dist/genesis-consumes.mjs +1 -1
  30. package/dist/genesis-consumes.mjs.map +2 -2
  31. package/docs/genesis.md +2 -2
  32. package/docs/sub_agent.md +28 -16
  33. package/package.json +17 -17
  34. package/scripts/smoke-genesis-consumes-node.mjs +1 -1
@@ -19,7 +19,7 @@ import { FoldController } from './fold-controller';
19
19
  import { IdleClock, isIdleLimit } from './idle-clock';
20
20
  import { InteractionController, } from './interaction-controller';
21
21
  import { TURN_FAILURE_EXITS, turnDone } from './turn-failures';
22
- import { TurnRecorder } from './turn-recorder';
22
+ import { nestUnderSubAgent, TurnRecorder } from './turn-recorder';
23
23
  /** Re-exported so `from './chat-driver'` keeps resolving these. */
24
24
  export { EMPTY_RESPONSE_NUDGE, MALFORMED_CALL_NUDGE } from './chat-driver.constants';
25
25
  /**
@@ -174,6 +174,19 @@ function inFlightToolCallsAt(history) {
174
174
  }
175
175
  return history.length;
176
176
  }
177
+ /**
178
+ * Re-badge a sub-agent's harvested meta event for the parent's timeline: the
179
+ * `"<parent> › <sub-agent>"` breadcrumb (composing for a nested sub-agent whose own breadcrumb the
180
+ * child already merged) and `detail.turnPrefix`. A nested sub-agent's events already carry a
181
+ * `turnPrefix` relative to the child, composed like the turn labels; events with none belong to
182
+ * this slot directly.
183
+ */
184
+ function stampSubAgentEvent(e, parentName, name, turnPrefix) {
185
+ var _a, _b;
186
+ const existing = (_a = e.detail) === null || _a === void 0 ? void 0 : _a.subAgent;
187
+ const childPrefix = (_b = e.detail) === null || _b === void 0 ? void 0 : _b.turnPrefix;
188
+ return Object.assign(Object.assign({}, e), { detail: Object.assign(Object.assign({}, e.detail), { subAgent: `${parentName} › ${existing !== null && existing !== void 0 ? existing : name}`, turnPrefix: childPrefix ? nestUnderSubAgent(turnPrefix, childPrefix) : turnPrefix }) });
189
+ }
177
190
  export class ChatDriver extends EventTarget {
178
191
  constructor(providerRegistry, config = {}) {
179
192
  super();
@@ -2308,18 +2321,25 @@ export class ChatDriver extends EventTarget {
2308
2321
  const available = [...this.subAgentsMap.keys()].join(', ') || '(none)';
2309
2322
  throw new Error(`Sub-agent "${name}" not found on agent "${this.activeAgentName}". Available: ${available}`);
2310
2323
  }
2311
- const { task, historyCap, context, timeoutMs, idleTimeoutMs } = options !== null && options !== void 0 ? options : {};
2324
+ const { task, historyCap, inheritHistory, context, timeoutMs, idleTimeoutMs } = options !== null && options !== void 0 ? options : {};
2312
2325
  // Fed by the interaction route and the progress listeners below; inert until the race starts it.
2313
2326
  // On only for a finite value in (0, MAX_TIMER_MS]: 0 would abort at once, and Infinity or
2314
2327
  // anything above a timer's range overflows to 1ms. Anything else means no idle limit.
2315
2328
  const idle = isIdleLimit(idleTimeoutMs) ? new IdleClock(idleTimeoutMs) : undefined;
2316
2329
  const noteIdle = () => idle === null || idle === void 0 ? void 0 : idle.touch();
2317
- // Exclude the current in-flight assistant message (the one with tool calls that
2318
- // triggered this invocation) — it has unresolved tool calls that would confuse
2319
- // the sub-agent into thinking it needs to handle tools it doesn't own. Found by its
2320
- // unanswered calls, not by being last: a widget the batch showed can come after it.
2321
- const baseHistory = this.history.slice(0, inFlightToolCallsAt(this.history));
2322
- const snapshotHistory = historyCap != null ? applyHistoryCap(baseHistory, historyCap) : [...baseHistory];
2330
+ // `inheritHistory: false` sends none of the parent's history, so skip building the snapshot
2331
+ // (and ignore `historyCap`): the primer is then only the context message and the sub-agent's
2332
+ // own `primerHistory`.
2333
+ let snapshotHistory = [];
2334
+ if (inheritHistory !== false) {
2335
+ // Exclude the current in-flight assistant message (the one with tool calls that
2336
+ // triggered this invocation) — it has unresolved tool calls that would confuse
2337
+ // the sub-agent into thinking it needs to handle tools it doesn't own. Found by its
2338
+ // unanswered calls, not by being last: a widget the batch showed can come after it.
2339
+ const baseHistory = this.history.slice(0, inFlightToolCallsAt(this.history));
2340
+ snapshotHistory =
2341
+ historyCap != null ? applyHistoryCap(baseHistory, historyCap) : [...baseHistory];
2342
+ }
2323
2343
  const contextMessages = context
2324
2344
  ? [{ role: 'user', content: `[Sub-agent context]: ${JSON.stringify(context)}` }]
2325
2345
  : [];
@@ -2333,6 +2353,13 @@ export class ChatDriver extends EventTarget {
2333
2353
  // under this own bucket (rather than the shared empty-key sink), so they can
2334
2354
  // be harvested into THIS session on completion and then discarded.
2335
2355
  const invocationId = crypto.randomUUID();
2356
+ // Claim this sub-agent's number under the parent turn NOW, synchronously and before any
2357
+ // await: parallel sub-agents finish in any order, so numbering at start keeps the forwarded
2358
+ // turn labels in the order of the `subagent.started` events.
2359
+ const subAgentSlot = this.turnRecorder.beginSubAgent();
2360
+ // The `<parentTurn>-<subAgentNo>` this sub-agent's forwarded turn labels begin with; stamped on
2361
+ // its events as `detail.turnPrefix` so events and turns match by value.
2362
+ const turnPrefix = `${subAgentSlot.parentTurn}-${subAgentSlot.subAgentNo}`;
2336
2363
  const childSessionKey = `${this.sessionKey}::sub:${invocationId}`;
2337
2364
  const child = new ChatDriver(this.providerRegistry, {
2338
2365
  sessionKey: childSessionKey,
@@ -2405,7 +2432,7 @@ export class ChatDriver extends EventTarget {
2405
2432
  // Bracket the run on the timeline (mirrors turn.start/turn.end). Recorded
2406
2433
  // under THIS (parent) session — like subagent.completed/failed below — so the
2407
2434
  // sub-agent's span is visible on the user-facing timeline, not the child's.
2408
- recordMetaEvent(this.sessionKey, 'subagent.started', { agent: name });
2435
+ recordMetaEvent(this.sessionKey, 'subagent.started', { agent: name, turnPrefix });
2409
2436
  let timedOut = false;
2410
2437
  const runPromise = child.sendMessage(task !== null && task !== void 0 ? task : '');
2411
2438
  try {
@@ -2473,8 +2500,8 @@ export class ChatDriver extends EventTarget {
2473
2500
  // rejection (which propagates out of this method) can't orphan the bucket in
2474
2501
  // the registry, and a crashed sub-agent still leaves its turns/events behind.
2475
2502
  // Forward the child's per-LLM-call snapshots so they show as `kind:'turn'`
2476
- // entries in the exported debug log, re-numbered under the activating parent turn.
2477
- this.turnRecorder.forwardSubAgent(child.getTurnSnapshots());
2503
+ // entries in the exported debug log, re-labelled under the activating parent turn and this sub-agent's slot.
2504
+ this.turnRecorder.forwardSubAgent(child.getTurnSnapshots(), subAgentSlot);
2478
2505
  // Fold the sub-agent's high-value meta events (retries/errors/tool failures —
2479
2506
  // see HARVESTED_SUBAGENT_EVENTS) into THIS session, preserving their original
2480
2507
  // timestamps so they interleave within the subagent.started→completed/failed
@@ -2483,11 +2510,7 @@ export class ChatDriver extends EventTarget {
2483
2510
  const parentName = (_c = this.activeAgentName) !== null && _c !== void 0 ? _c : '?';
2484
2511
  const harvested = getMetaEvents(childSessionKey)
2485
2512
  .filter((e) => HARVESTED_SUBAGENT_EVENTS.has(e.type))
2486
- .map((e) => {
2487
- var _a;
2488
- const existing = (_a = e.detail) === null || _a === void 0 ? void 0 : _a.subAgent;
2489
- return Object.assign(Object.assign({}, e), { detail: Object.assign(Object.assign({}, e.detail), { subAgent: `${parentName} › ${existing !== null && existing !== void 0 ? existing : name}` }) });
2490
- });
2513
+ .map((e) => stampSubAgentEvent(e, parentName, name, turnPrefix));
2491
2514
  mergeMetaEvents(this.sessionKey, harvested);
2492
2515
  clearSession(childSessionKey);
2493
2516
  }
@@ -2496,12 +2519,12 @@ export class ChatDriver extends EventTarget {
2496
2519
  // Same failure shape as any other non-completion — the parent handler
2497
2520
  // recovers on its existing `{ ok: false }` branch. Recorded under THIS
2498
2521
  // (parent) session so it lands on the user-visible debug-log timeline.
2499
- recordMetaEvent(this.sessionKey, 'subagent.failed', Object.assign({ agent: name, reason: 'timeout' }, ((idle === null || idle === void 0 ? void 0 : idle.expired) && { cause: 'idle' })));
2522
+ recordMetaEvent(this.sessionKey, 'subagent.failed', Object.assign({ agent: name, turnPrefix, reason: 'timeout' }, ((idle === null || idle === void 0 ? void 0 : idle.expired) && { cause: 'idle' })));
2500
2523
  return { outcome: { ok: false, reason: 'timeout' }, trace };
2501
2524
  }
2502
2525
  const completion = child.getSubAgentCompletion();
2503
2526
  if (completion) {
2504
- recordMetaEvent(this.sessionKey, 'subagent.completed', { agent: name });
2527
+ recordMetaEvent(this.sessionKey, 'subagent.completed', { agent: name, turnPrefix });
2505
2528
  return { outcome: { ok: true, result: completion.result }, trace };
2506
2529
  }
2507
2530
  // No completion → the sub-agent's loop ended without calling its completion
@@ -2516,7 +2539,7 @@ export class ChatDriver extends EventTarget {
2516
2539
  // user-visible debug-log timeline — the child ran under its own session key.
2517
2540
  // This is also the only telemetry for the defensive default above, where the
2518
2541
  // child's loop ended without recording an explicit failure reason.
2519
- recordMetaEvent(this.sessionKey, 'subagent.failed', { agent: name, reason });
2542
+ recordMetaEvent(this.sessionKey, 'subagent.failed', { agent: name, turnPrefix, reason });
2520
2543
  // A child that hit the budget wall walls this driver too — the cap is shared,
2521
2544
  // and the parent's very next model call would 402 as well. Flagged (not
2522
2545
  // thrown) because the handler's return value is still appended as a tool
@@ -1,5 +1,15 @@
1
1
  import { __rest } from "tslib";
2
2
  import { mergeMetaEvents, recordMetaEvent } from '../../state/debug-event-log';
3
+ /**
4
+ * Compose a sub-agent label: the lead segment of `key` is the child's own 0-based turn counter,
5
+ * which becomes its 1-based call number under `prefix` (`<parentTurn>-<subAgentNo>`); any
6
+ * remaining `-` segments (an already-forwarded grand-child label) are kept. Used for both turn
7
+ * labels and event `turnPrefix`es so they always match.
8
+ */
9
+ export function nestUnderSubAgent(prefix, key) {
10
+ const [lead, ...rest] = key.split('-');
11
+ return [`${prefix}.${Number(lead) + 1}`, ...rest].join('-');
12
+ }
3
13
  /**
4
14
  * Everything the exported debug log draws from one driver: its own per-LLM-call snapshots, the
5
15
  * ones forwarded up from sub-agents, and the diagnostics harvested from resolved interactions.
@@ -19,6 +29,14 @@ export class TurnRecorder {
19
29
  this.buffer = [];
20
30
  /** Monotonic counter that survives agent swaps — useful for cross-referencing with history. */
21
31
  this.turnIndex = 0;
32
+ /**
33
+ * Sub-agents started so far per parent turn — the source of each sub-agent's number in its
34
+ * forwarded labels. Left unbounded on purpose: it holds one small entry per parent turn that
35
+ * started a sub-agent, for the driver's lifetime, which is far cheaper than the snapshots
36
+ * themselves. Pruning to the current turn would risk reusing a number if a late sub-agent
37
+ * began after the parent had moved on.
38
+ */
39
+ this.subAgentsByTurn = new Map();
22
40
  /**
23
41
  * `turn` + `message` diagnostic entries harvested from an out-of-band source. `event` entries
24
42
  * are NOT kept here — they are folded into the session's meta-event registry so they inherit
@@ -30,7 +48,7 @@ export class TurnRecorder {
30
48
  /**
31
49
  * Monotonic count of external-diagnostics batches folded this driver-lifetime. Namespaces each
32
50
  * batch's re-keyed `turn` entries so distinct server generations in one chat session can't
33
- * collide on `turnIndex` in the forward-capture persister (which dedups turns by that key).
51
+ * collide on turn identity (`turnIndex` + timestamp + agentName) in the forward-capture persister.
34
52
  */
35
53
  this.externalBatches = 0;
36
54
  }
@@ -81,42 +99,43 @@ export class TurnRecorder {
81
99
  this.trim();
82
100
  return snapshot;
83
101
  }
102
+ /**
103
+ * Claim the next sub-agent slot under the parent turn that is activating it. Call this
104
+ * synchronously when the sub-agent *starts* (not when it finishes): parallel sub-agents finish
105
+ * in any order, so numbering at start keeps the numbers in the order of the `subagent.started`
106
+ * events. Pass the slot to `forwardSubAgent` once the child has run.
107
+ *
108
+ * The activating parent turn = the most recent snapshot this driver recorded before entering
109
+ * the tool handler that invoked the sub-agent.
110
+ */
111
+ beginSubAgent() {
112
+ var _a;
113
+ const parentTurn = Math.max(0, this.turnIndex - 1);
114
+ const subAgentNo = ((_a = this.subAgentsByTurn.get(parentTurn)) !== null && _a !== void 0 ? _a : 0) + 1;
115
+ this.subAgentsByTurn.set(parentTurn, subAgentNo);
116
+ return { parentTurn, subAgentNo };
117
+ }
84
118
  /**
85
119
  * Merge a sub-agent's turn snapshots into this driver's buffer so they surface
86
120
  * as `kind:'turn'` entries in the exported debug log. The child runs as a
87
121
  * separate, discarded driver, so its snapshots would otherwise be lost. Each is
88
- * re-labelled under the parent turn that activated the sub-agent: the child's
89
- * own (numeric) turns become `"<parentTurn>-1"`, `"-2"`, … (1-based, in order);
90
- * any already-forwarded grand-child labels (strings) have their leading segment
91
- * remapped the same way, so nesting composes (`"5-2"` → `"5-2-1"`).
122
+ * re-labelled under the slot claimed by `beginSubAgent`: the child's own
123
+ * (numeric) turns become `"<parentTurn>-<subAgentNo>.<childTurn>"`, where
124
+ * `childTurn` is the child's own call number (1-based, derived from its 0-based
125
+ * counter, which has no gaps). It therefore stays correct when the child's
126
+ * oldest snapshots were evicted from its ring buffer. Any already-forwarded
127
+ * grand-child labels (strings) have their leading segment remapped the same
128
+ * way, so nesting composes (`"5-2.2"` → `"5-2.2-1.3"`).
92
129
  *
93
- * Note: two sub-agents invoked in the *same* parent turn share the prefix, so
94
- * their labels can repeat — `agentName` on each snapshot disambiguates them.
130
+ * Sub-agents started in the same parent turn have distinct `subAgentNo`s, so
131
+ * their labels never collide.
95
132
  */
96
- forwardSubAgent(childSnapshots) {
97
- var _a;
133
+ forwardSubAgent(childSnapshots, slot) {
98
134
  if (childSnapshots.length === 0)
99
135
  return;
100
- // The activating parent turn = the most recent snapshot this driver recorded
101
- // before entering the tool handler that invoked the sub-agent.
102
- const parentTurn = Math.max(0, this.turnIndex - 1);
103
- const ownTurnLabel = new Map();
104
- let ownPos = 0;
136
+ const prefix = `${slot.parentTurn}-${slot.subAgentNo}`;
105
137
  for (const snap of childSnapshots) {
106
- let turnIndex;
107
- if (!snap.turnIndex.includes('-')) {
108
- // The child's own turn (a bare counter) → number it under the parent turn.
109
- ownPos += 1;
110
- turnIndex = `${parentTurn}-${ownPos}`;
111
- ownTurnLabel.set(snap.turnIndex, turnIndex);
112
- }
113
- else {
114
- // An already-forwarded grand-child label — remap its leading segment.
115
- const [lead, ...rest] = snap.turnIndex.split('-');
116
- const leadLabel = (_a = ownTurnLabel.get(lead)) !== null && _a !== void 0 ? _a : `${parentTurn}-${lead}`;
117
- turnIndex = [leadLabel, ...rest].join('-');
118
- }
119
- this.buffer.push(Object.assign(Object.assign({}, snap), { turnIndex }));
138
+ this.buffer.push(Object.assign(Object.assign({}, snap), { turnIndex: nestUnderSubAgent(prefix, snap.turnIndex) }));
120
139
  }
121
140
  this.trim();
122
141
  }
@@ -129,18 +148,21 @@ export class TurnRecorder {
129
148
  */
130
149
  foldDiagnostics(interactionId, harvested) {
131
150
  // The harvested entries carry the SOURCE engine's own index space (0-based turns/events), which
132
- // would collide with this host's cursors in the forward-capture persister — turns dedup by
133
- // `turnIndex`, events by an `index` high-water mark — so foreign entries get silently dropped
151
+ // would collide with this host's cursors in the forward-capture persister — turns are keyed by
152
+ // `turnIdentity` (`turnIndex` + timestamp + agentName), events by an `index` high-water mark —
153
+ // so foreign entries can get silently dropped
134
154
  // from the persisted stream. Route each kind through the host's own collision-safe machinery,
135
155
  // mirroring how a sub-agent's log is folded in (see `invokeSubAgent`):
136
156
  // • `event` → `mergeMetaEvents`, which re-indexes them onto this session's monotonic event
137
157
  // counter (clearing the high-water) while preserving their timestamps; they then
138
158
  // reach the log via `getMetaEvents` in `buildTimelineEntries`, not this buffer.
139
159
  // • `turn` → re-key `turnIndex` to the turn's local position within a per-batch namespace,
140
- // so turns stay unique even when one interaction folds in several independent
141
- // server runs that each number their own turns from 0 (a consolidator carries a
142
- // consolidator-code run AND a table-code run), and never collide with the host's
143
- // own bare-integer turn keys.
160
+ // so turns get distinct, readable labels even when one interaction folds in
161
+ // several independent server runs that each number their own turns from 0 (a
162
+ // consolidator carries a consolidator-code run AND a table-code run), and never
163
+ // share a label with the host's own bare-integer turns. Identity also includes
164
+ // timestamp + agentName, so this is not what keeps them apart on its own: a
165
+ // same-agent foreign turn with the same timestamp and label could still collide.
144
166
  // • `message` → kept as-is; the persister already keys messages by content, so they survive.
145
167
  // TODO(GENC-1461, option 2 / streaming): expose an imperative `appendDiagnostics(entries)` on
146
168
  // the handler context (see buildHandlerContext) that runs this same decomposition as SSE ticks
@@ -169,7 +191,7 @@ export class TurnRecorder {
169
191
  // interaction can carry several independent server runs (a consolidator folds in its
170
192
  // consolidator-code run and its table-code run), each numbering its turns from 0, so
171
193
  // keying by the source index would collide them. The local position keeps every turn key
172
- // distinct within the batch, so the persister's per-`turnIndex` dedup keeps them all.
194
+ // distinct within the batch (and across batches via the `batch` namespace).
173
195
  this.externalEntries.push(Object.assign(Object.assign({}, entry), { turnIndex: `server-generation.${batch}:${turnCount}` }));
174
196
  turnCount += 1;
175
197
  }
@@ -367,7 +367,7 @@ export function validateGenesisAiConfig(config) {
367
367
  if (c.enabled !== true)
368
368
  problems.push(`enabled must be true (got ${String(c.enabled)})`);
369
369
  if (c.vendor !== undefined && !AI_TIER_VENDORS.includes(c.vendor)) {
370
- problems.push(`unknown vendor '${String(c.vendor)}' (expected ${AI_TIER_VENDORS.join(' or ')})`);
370
+ problems.push(`unknown vendor '${String(c.vendor)}' (expected ${AI_TIER_VENDORS.join(', ')})`);
371
371
  }
372
372
  if (c.tier !== undefined && !AI_TIER_IDS.includes(c.tier)) {
373
373
  problems.push(`unknown tier '${String(c.tier)}' (expected ${AI_TIER_IDS.join(', ')})`);
@@ -38,7 +38,7 @@ export const GENESIS_AI_CONSUMES = Object.freeze({
38
38
  'inputs',
39
39
  'effects',
40
40
  ]),
41
- vendors: Object.freeze(['anthropic', 'gemini']),
41
+ vendors: Object.freeze(['anthropic', 'gemini', 'openai']),
42
42
  tiers: Object.freeze(['low', 'high', 'reasoning']),
43
43
  shapes: Object.freeze(['row', 'key-row']),
44
44
  });
@@ -263,15 +263,15 @@ export const DEBUG_LOG_README = [
263
263
  "kind:'message' — the conversation. `role` is user/assistant/tool/system-event/synthetic-user; `agentName` says which agent produced it; `toolCalls`/`toolResult`/`interaction` carry tool and widget activity; `inputTokens`/`outputTokens`/`cost` are per-message LLM usage, where `inputTokens` is the WHOLE prompt for that request and `cacheReadTokens`/`cacheWriteTokens` BREAK IT DOWN rather than add to it — uncached input is `inputTokens` minus those two, and adding the cache fields to `inputTokens` counts the prompt twice. The cache fields are absent on providers that report no cache split (Gemini reports reads only, since implicit caching bills no write) and on messages persisted before they existed, so read them as 0 when missing. Each bucket bills at a different rate — cache reads a fraction of uncached input, cache writes a premium, output highest — so a large token count at a small cost means the prompt was mostly cache hits. `externalCostUsd` is any non-LLM cost a widget reported for its own external service calls (folded into the session cost total alongside `cost`). On model-produced assistant messages, `model` is the concrete model id that generated it (e.g. 'gemini-2.5-flash-lite') and `providerName` is the registry slot it resolved under (e.g. a tier name like 'high'/'low', or the default); together they attribute the message — and any tool calls it carries — to an exact model even across a mid-session vendor/tier switch, where one slot name can map to different models before and after the switch. Both are undefined on any entry that is NOT an LLM response: non-assistant roles (user/tool/system-event) and 'synthetic-user' echoes; assistant interaction/widget entries (empty content carrying an `interaction` — a rendered widget, not a model turn); driver-authored assistant fallbacks (the timeout, repeated-malformed-call, and empty-response apology messages); and messages restored from a session persisted before these fields existed. One partial case: on a genuine model turn whose provider exposes no `getStatus` (or reports no model), `providerName` is still set but `model` alone is undefined. A 'synthetic-user' message is a display-only echo of an interaction outcome (e.g. the answer a widget reported): it renders on the user's side of the chat and `agentName` is the agent that created it, but it is never sent to the LLM — so it has no matching 'turn' and the model learns the outcome only from the corresponding tool result. An echo of an answer an interceptor (such as an autopilot) gave is NOT synthetic-user: see the delegated-messages paragraph.",
264
264
  'The autopilot (GENC-1660) runs on a driver of its own, and everything it did is harvested into this log: entries with delegate: autopilot and an agentName ending in › Autopilot are its turns (the decision message it was sent is the user message of its turn, so what it was shown is there verbatim; its systemPrompt is its grounding, such as the brief), its tool calls (widget_read, widget_act, hand_back, any read-only tools of its own, and its widget tools — reads with parameters that a widget type declares, routed to the interaction of that type being decided and refused with a reason when none is, offered on every decision so its tool list never changes; while one is open its tail starts with a line naming them) and their results (a read, view or widget tool, is capped at about 20,000 characters, cut with a note asking for less, and leaves its history at the end of the decision as a one-line note), and its own events. Its cost is already in the session total: it is booked as externalCostUsd on the interaction each decision answered, or, for a written question it answered, on the user message it sent on the user behalf (delegate: autopilot), so do not add its turns to that total. Spend that reached no message is recorded as autopilot.cost-dropped instead.',
265
265
  "Delegated messages (GENC-1660): a message with a `delegate` field was written or sent ON THE USER'S BEHALF by a driver decorator, and `delegate` names it (e.g. autopilot). The platform stamps it; nothing else can. It renders as the assistant whatever its role. A delegated `user` message was NOT typed by the user: it is an answer given on their behalf, and the model read it with `delegateFraming` in brackets in front of the content (the stored `content` is the bare text). A delegated `assistant` message is display-only (`excludeFromProvider`): the decorator's narration note, or, when its answer carried no note, the widget's own echo of the answer (its `userMessage`), shown as the assistant and never as the person. A widget answer a decorator gave with a note is not echoed at all: the note already says what was chosen. To tell what the person decided from what was decided for them, read `interaction.answeredBy` and these fields, never the role alone. Driver notes: a `user` message with a `driverNote` field was written by the driver for the model, never by the user, and is hidden from the transcript; `driverNote: 'finish-guard'` is the agent's finishGuard holding the turn open after a prose reply, its content the guard's note in a `<system-reminder>`, and it follows a turn.finish-guard event; `driverNote: 'completion-nudge'` is the driver asking a sub-agent that replied in prose to call its completion tool; `driverNote: 'forced-tool-nudge'` is the driver asking a parent agent for the tool call its forced turn required, after a model that rejects forcing (responseMeta.toolChoiceDowngraded) replied in prose.",
266
- "Sub-agent messages appear inline. When a tool delegates to a sub-agent (via `requestSubAgent`), the sub-agent's whole conversation — its own assistant/tool messages, each with their own `content`/`thinking`/`toolCalls`/`toolResult` and per-message `model`/`providerName`/`inputTokens`/`outputTokens`/`cacheReadTokens`/`cacheWriteTokens`/`cost` — is hoisted into the timeline as ordinary kind:'message' entries, interleaved by timestamp right after the tool call that spawned them (so you read the delegation top-to-bottom). A hoisted entry is marked: `subAgentDepth` is its delegation depth (1 for a sub-agent, 2 for a sub-agent's sub-agent, …), `subAgentOf` is the id of the parent tool call that spawned it (correlates it back even when two sub-agents run in one parent turn), `subAgentName` is the sub-agent's own name, and `agentName` is rewritten to a `\"<parent> › <sub-agent>\"` breadcrumb (composing when nested, e.g. `\"UI Builder › Planner › Grounding\"`). The sub-agent's per-LLM-call snapshots also surface as kind:'turn' entries with an N-M `turnIndex`, and subagent.started/completed (or subagent.failed) events bracket the run. Per-message `cost` on hoisted entries is already part of the session total (it is summed from the un-flattened history), so summing the top-level timeline does NOT double-count.",
267
- "kind:'turn' — one LLM call. `turnIndex` is a string: a top-level turn is the bare counter ('0', '1', …); a sub-agent's turns are numbered under the parent turn that activated them ('3-1', '3-2', …, and a nested sub-agent contributes '3-2-1', …), and `agentName` names the agent that ran the turn. `systemPrompt` and `toolNames` are what the model saw. A systemPrompt of '<repeated — identical to turn N>' was byte-identical to turn N and de-duplicated; the full prompt is shown whenever it changes (often because a stateful agent advanced), so prompt evolution is visible.",
266
+ "Sub-agent messages appear inline. When a tool delegates to a sub-agent (via `requestSubAgent`), the sub-agent's whole conversation — its own assistant/tool messages, each with their own `content`/`thinking`/`toolCalls`/`toolResult` and per-message `model`/`providerName`/`inputTokens`/`outputTokens`/`cacheReadTokens`/`cacheWriteTokens`/`cost` — is hoisted into the timeline as ordinary kind:'message' entries, interleaved by timestamp right after the tool call that spawned them (so you read the delegation top-to-bottom). A hoisted entry is marked: `subAgentDepth` is its delegation depth (1 for a sub-agent, 2 for a sub-agent's sub-agent, …), `subAgentOf` is the id of the parent tool call that spawned it (correlates it back even when two sub-agents run in one parent turn), `subAgentName` is the sub-agent's own name, and `agentName` is rewritten to a `\"<parent> › <sub-agent>\"` breadcrumb (composing when nested, e.g. `\"UI Builder › Planner › Grounding\"`). The sub-agent's per-LLM-call snapshots also surface as kind:'turn' entries with a `<parentTurn>-<subAgentNo>.<childTurn>` `turnIndex` (see the kind:'turn' paragraph), and subagent.started/completed (or subagent.failed) events bracket the run. Per-message `cost` on hoisted entries is already part of the session total (it is summed from the un-flattened history), so summing the top-level timeline does NOT double-count.",
267
+ "kind:'turn' — one LLM call. `turnIndex` is a string: a top-level turn is the bare counter ('0', '1', …); a sub-agent's turns are labelled '<parentTurn>-<subAgentNo>.<childTurn>': the parent turn that activated it, the sub-agent's number (1-based, in the order the sub-agents started within that parent turn, so it matches the order of the subagent.started events; two sub-agents in one parent turn never share a number, even when they run in parallel or share a name), and the sub-agent's own turn position (1-based) — e.g. '3-2.1', '3-2.2' are the first two turns of the second sub-agent started in parent turn 3, and a sub-agent nested under its turn '3-2.2' contributes '3-2.2-1.1', … ('.' joins the parts of one level, '-' separates levels). The `<parentTurn>-<subAgentNo>` part is the sub-agent's `turnPrefix`: the same value is stamped on its subagent.started/completed/failed events and on its harvested events as `detail.turnPrefix`, so match events to turns by value (a turn belongs to the sub-agent whose `turnPrefix` its `turnIndex` begins with) — and `agentName` names the agent that ran the turn. `systemPrompt` and `toolNames` are what the model saw. A systemPrompt of '<repeated — identical to turn N>' was byte-identical to turn N and de-duplicated; the full prompt is shown whenever it changes (often because a stateful agent advanced), so prompt evolution is visible.",
268
268
  "kind:'turn'.`model`/`providerName`/`provider` — which model ran that call: the concrete model id, the registry slot it resolved under (a tier name like 'high'/'low', or the default), and the vendor. Recorded per CALL, so an agent whose `provider` selector varies by state — a flow that plans on a high tier and executes on a low one — has every step attributed, including calls that produced no message. `model` is the SERVING model where the provider reports one, so a turn answered by a server-side fallback names the model that answered rather than the one requested; it always matches the `model` on the message that call produced. Absent when the provider exposes no `getStatus` and the transport stamped nothing.",
269
269
  "kind:'turn'.`usage` — what that ONE call cost, in the same four-bucket + `costUsd` shape as `sessionUsage`. Absent while a call is in flight and on providers that report no usage. This is the SAME money as the message the call produced, not extra money: never add turn usage to message usage, and read a turn plus its message as one charge. Its distinct value is the calls that produced NO message — a blank or refused response is billed and then discarded before the retry, so the turn entry is the only record of that spend, and a turn with `usage` but no message after it is exactly that. `costUsd: 0` alongside a nonzero token count means the provider reported no price, not that the call was free.",
270
270
  "kind:'turn'.`agentSnapshot` — the active agent's own view of its internal state, captured at that turn. An agent opts into this by exposing a `getDebugSnapshot()` that returns JSON-serializable per-state info; stateful/flow agents wire it automatically, so you can watch a flow advance turn-by-turn (e.g. current step, cursor, collected fields, pending changes). Absent for agents that don't expose one.",
271
271
  "kind:'event' — a meta/lifecycle event. `type` names it (see below); `detail` carries structured data. `detail.placement` is the emitting UI instance: 'bubble' (collapsed), 'panel' (popped-out), or 'standalone'.",
272
272
  "Each 'event' also has an `importance`: 'high' (failures/limits — turn.error, tool.failed, subagent.failed, file.read-failed, suggestions.failed, context.threshold-crossed), 'normal' (session flow — connects, turns, retries, handoffs, agent/provider changes, interactions, sub-agent start/complete), or 'low' (skippable UI/bookkeeping noise — panel.toggled, attachment.added, driver.wired/unwired, context.updated, context.condensed). To skim, ignore importance:'low'; to triage a failure, filter to importance:'high' then read the nearby messages and turns. A 'high' turn.error is often preceded by one or more 'normal' turn.retry events for the same reason — read them together to see how many attempts were made before bailing. 'message' and 'turn' entries carry no importance — they are the substance, always read them.",
273
- "Event types: assistant.connected/disconnected (mount + placement + whether the session was created or restored), assistant.popout/popin (window placement), driver.created/wired/unwired (which driver is live and why it stops/starts responding across a popout), state.changed (idle↔loading), turn.start/turn.end (turn boundary; turn.end carries durationMs), turn.retry (a recoverable in-turn retry — detail.reason plus attempt/maxAttempts; for malformed calls also finishMessage; for empty responses also the provider finishReason + thoughtsTokens + parts breakdown), turn.finish-guard (the model replied with no tool call and the agent's finishGuard hook answered — detail.action is continue (the turn was held open: detail.continuation counts the holds this turn and detail.note is the note stored as a hidden user message with driverNote finish-guard, the next message in the log; detail.source: 'completion-nudge' is instead the driver holding a SUB-AGENT's turn open because it replied in prose without calling its completion tool — detail.nudge of detail.maxNudges, the note stored with driverNote completion-nudge — and a sub-agent that still answers in prose after the last nudge fails as before; detail.source: 'forced-tool-nudge' is the driver holding a PARENT agent's forced turn open after a model that rejects forcing answered in prose, the note stored with driverNote forced-tool-nudge, naming the tool when the turn was pinned to one) or end with detail.release: true (the agent was released on a prose answer); a plain end records nothing), turn.error (a turn failed or hit a guardrail — detail.reason is one of exception/malformed-function-call/empty-response/unknown-tool-limit/max-iterations/response-truncated/refusal/budget-exhausted/provider-refused/context-exhausted/ai-service-error, plus reason-specific diagnostics: attempts (for empty-response also finishReason + thoughtsTokens + a parts breakdown, distinguishing a thinking-only STOP from a truly empty turn), finishMessage, for response-truncated the model + maxTokens + outputTokens + tools, unknownTools (split into staleTools — real earlier this activation but retired by the current state or hidden behind an open exclusive fold — and hallucinatedTools — never advertised) + availableTools, iterations + limit, for budget-exhausted the budgetUsd + spentUsd figures reported by the proxy plus the resolved vendor, for provider-refused the kind (spend|auth) plus the upstream status and error type — the vendor refusing the ACCOUNT rather than us refusing to spend, so the remedy is a top-up or a key rotation rather than a raised cap, and the kind is the only place that distinction survives because the user-facing copy is deliberately cause-free, for context-exhausted the estimated contextTokens against the guard that stopped the turn plus the iterations reached — the driver ending a runaway tool loop at the edge of the context window rather than issuing a request the provider would reject, so the transcript survives intact and can still be compacted, for ai-service-error the code (one of AI_SERVICE_ERROR_CODES, e.g. NO_API_KEY) and the status the AI service answered with — its own text goes to the browser console only, or name + message for exceptions), tool.failed (a tool threw), tool.unresolved (the model called a tool that could not be dispatched — detail.kind is folded/fold-hidden/stale/unknown, plus tool + agent and, for the counted kinds, the consecutive streak; or kind pinned-elsewhere, a turn pinned to detail.pinned (toolChoice { tool }) that went out unforced because the model rejects forcing, and whose reply called only detail.tools: none of them was run, each was answered with a refusal naming the pinned tool, detail.nudge of detail.maxNudges, counted against the forced-tool nudge on a parent agent and the completion nudge on a sub-agent; the recurring lead-up to an unknown-tool-limit turn.error), subagent.started/completed/failed (the lifecycle of a `requestSubAgent` delegation — detail.agent names the sub-agent; these bracket the sub-agent turns that appear as kind:turn entries with an N-M `turnIndex`; subagent.failed also carries detail.reason, one of max_iterations/malformed_tool_call/empty_response/unknown_tool_limit/timeout/response_truncated/refusal/budget_exhausted/provider_refused/context_exhausted/ai_service_error, and for timeout detail.cause: 'idle' when it was the sub-agent making no progress for `idleTimeoutMs` rather than the overall `timeoutMs` (absent for the latter); budget_exhausted and provider_refused are terminal for the PARENT turn too, and so is ai_service_error when the refusal is about the service rather than the request and came from the vendor the parent calls — the parent stops rather than calling the model again into the same wall; after context_exhausted the parent goes on, but its own next call is likely to stop on the same guard), agent.handoff (routing; from=null is the initial activation), agent.pinned/unpinned (forced routing), routing.decided (ONE PER ROUTING DECISION — see its own paragraph below), provider.selected (the resolved provider for the upcoming turns — detail.provider is the registry SLOT/tier name, detail.model the concrete model behind it and detail.vendor its vendor; emitted only when the slot CHANGES, so read the per-turn `model` for the model of any given call rather than assuming the nearest event still applies), interaction.requested/resolved (blocking user widgets — explain quiet gaps; note that when a sub-agent opens a widget, detail.agent — and the agentName on the interaction message — is the HOST agent that owns the widget, NOT the sub-agent that asked, because widgets render and resolve on the host driver; detail.ownerPath names the agents that actually asked, outermost first, the last being the one whose tool requested it, and detail.heldBy says who held it when it opened: user, or the id of the interceptor that claimed it, such as autopilot; on interaction.resolved, detail.answeredBy is who answered — the claimant id when it settled through its own hold, user for any other answer (a click counts as the person even on a widget a claimant held) — absent when it closed unanswered (a timeout or a stop), and absent too when it settled by itself other than through the hold of a claimant — a widget registered resolvesItself (one that does its work and settles on its own, asking the person nothing, such as a generation run), or one outcome its controller said settled itself (ctx.resolve with resolvedItself, such as a generation phase that failed outright before its review gate ever asked anything) — which then carries detail.resolvedItself: true instead, as the interaction message does — nobody answered it, and the platform cannot tell it finishing from the person interrupting it (a Skip), so only the result of the widget itself can say which; the same value is stamped on the interaction message as answeredBy and on the result the asking tool handler receives (absent there in the same cases), and when it is not user the tool result that interaction returned carries a decidedOnUsersBehalf record, so the model was told the choice was not made by the person; detail.edits, present only when non-zero, counts the editing actions a claimant ran on the widget before it was settled, whoever settled it, and those edits are stamped on the interaction message as edits, each with by, action, choice and args when it had some, in the order they ran, while a decidedOnUsersBehalf record carries their choice texts as edits, and when the person settled it after such edits the tool result carries an editedOnUsersBehalf record instead — the framing and those choice texts — so the model knows the widget was changed on the user behalf before the user answered, and that the user then confirmed it by finishing it), interaction.held (a claimant moved a pending interaction to the person or back to itself — detail.heldBy is the new holder, detail.claimant the interceptor; detail.late: true is an interceptor that declined it when it opened claiming it afterwards, such as the autopilot resumed while it was open; a widget held by anything but user was not answered by the person), interaction.claim-refused (a claim on a userOnly interaction, which stays with the person — detail.claimant + reason), autopilot.* (the autopilot, a decorator that answers interactions on behalf of the user — autopilot.claimed / autopilot.declined say whether it took each interaction and, for a decline, detail.reason: paused, other-flow, no-autopilot, unavailable, userOnly, policy or no-controller; one declined as paused that is still open when the person resumes the autopilot is looked at again, and the autopilot.claimed or autopilot.declined recorded for it then carries detail.onResume: true (a decline then can also be claimed-elsewhere, another interceptor having claimed it first); a restored mode looks at nothing; autopilot.decision-sent is what it was sent (detail.chars; detail.nothingEnabled: true when every action on the widget was unavailable — a gate whose controller said it was asking, such as a failed build the autopilot may not cancel — so it could only hand it back, which it may then do even after the person asked it to decide it itself; a widget whose controller says it is working (ctx.setWorking) is never sent a decision until it says it is asking, even when an action is enabled or the person resumes the autopilot); autopilot.acted is what it did (detail.action, detail.note, detail.finished); autopilot.handed-back is a decision it gave to the person (detail.reason and detail.trigger: model, no-decision or error); autopilot.paused / autopilot.resumed are mode changes (detail.scope, detail.trigger, detail.decideYourself when the person resumed during a hand-back; detail.trigger is restored when the mode came back with the session after a reload, applied once its flow re-activated, which starts nothing by itself); autopilot.carried is the mode, running or paused, going with the task to the agent that took it over, rather than ending with the flow as on any other change of flow owner: to the target of a hand-off, or back to its caller on the hand-back (detail.from, detail.to, detail.mode); a pause the person chose goes with it, and Stop and Clear still end it; a mode restored for the target of a hand-off applies to its caller when the reload hands back; autopilot.error is the wrapper itself failing; autopilot.refinement counts a refining action against its step — a written answer (reply) or a widget action declared refines, such as a regenerate with instructions, counted together (detail.action, detail.stepKey, detail.count, detail.limitReached, after which every refining action is withdrawn for that step: not listed, and refused; the decision and every relisting of its actions say how many are left at the step, as a line Refinements left at this step: N, wherever the widget has a refining action); autopilot.handback-presented is the turn-level hand-back, shown when a working turn ended needing the person with no widget to hand over (detail.why: max-iterations, context-exhausted, failure or question; detail.options; detail.choice once answered); autopilot.catch-up is the autopilot being given the whole visible transcript at once (detail.why: first, for its first decision in a flow or after a reload; size, when its own history passed its budget and was rebuilt short — detail.ownChars; or compacted, when a compaction removed the last message it had seen, so it reads the summary and everything since, short; in each, what it had sent on the user behalf is included and labelled as its own, since its own history does not hold it); autopilot.cost-dropped is autopilot spend that no message carries, so it is NOT in the session total (detail.costUsd and detail.why: handed-back, aborted or stale for a written question it answered that no reply was sent for — stale when a pause, a resume, a new turn or the end of its flow came before the answer landed, which then went nowhere — or no-recorder when the driver had no way to book a decision to its interaction); a hand-back trigger can also be budget (the decision passed its spend cap), watchdog (its work went quiet: no ready surface and no heartbeat, or its own decision stalled with no model call landing, which stops that decision) or detached (the autopilot was removed while it held the interaction, which went to the person with no reason shown). To debug one autopilot decision, follow its interactionId: interaction.requested (heldBy), autopilot.claimed, autopilot.decision-sent, autopilot.acted or autopilot.handed-back, interaction.invoked, interaction.resolved (answeredBy), then the next turn of the working agent), interaction.invoked (a claimant ran one of the actions the widget itself exposes, through its hold, the same code the button runs — detail.claimant, detail.action (an option id, select or reply) and detail.finished, whether that settled the interaction, and when it did not, the run is recorded as an edit; the choice and narration it recorded reach the result of the tool that asked as decidedOnUsersBehalf; the person's own programmatic action, from a host with no DOM to click, carries detail.by: user in place of detail.claimant, and is not recorded as an edit nor as a decision on their behalf, so what it settles is answered by user), interaction.step (a long action run as named steps through runSteps, which survive a reload — detail.step and detail.outcome: started, done, skipped when the step was already done before a reload, or resumed when it started before a reload and runs again with what it saved part-way, such as a job id it re-attaches to), interaction.checkpoint (the checkpoints a conversation keeps for its long actions: the one in flight, and each one a reload cut, held apart until a request of its own widget type takes it over, so a resumed flow that opens other long widgets first, which save their own, loses nothing — detail.action: resumed when a reload cut the work and a request of the same widget type that the registration sameWork agrees is the same work took it over, refused when sameWork said a new request is different work (detail.saved is the identity it kept; detail.kept: true, since it stays for a later request of that type, and is offered to every one until one agrees) or when runSteps found the handed-over checkpoint malformed and started fresh (detail.reason, detail.saved), or cleared when its flow ended, once per checkpoint, with detail.cut: true for one a reload cut that nothing took over), context.updated/threshold-crossed (token + cost), headless.attached (a HeadlessSession attached, for a host that drives the assistant with no screen — detail.label, what the host called itself, when it gave one) and headless.raw-resolved (that host settled an interaction raw, bypassing the widget's own actions: detail.interactionId and detail.component; the result went to the tool as given, so check what the widget would have enforced), context.condensed (a stale tool payload was collapsed out of the model-bound history by a `condenseWhen` declaration on the tool — detail.tool + toolCallId, target args|response, trigger (superseded:<key> or age:<n>), stubLen, and an estimated tokensSaved; stored history and this log keep the FULL payload, so the model-visible slice at any point is the full history minus the condensations recorded up to then), panel.toggled, attachment.added, file.read-failed, suggestions.failed.",
274
- 'Sub-agent meta events: a sub-agent\'s own turn.retry/turn.error/tool.failed/tool.unresolved/turn.finish-guard events are merged into this same timeline, tagged with `detail.subAgent` — a `"<parent> › <sub-agent>"` breadcrumb that composes when nested (e.g. `"UI Builder › Planner › Grounding"`) — and interleaved by their original timestamps within the subagent.started→completed/failed bracket. These are the per-attempt/per-failure signals that do NOT appear among the sub-agent\'s (hoisted) messages: a malformed/empty attempt that gets retried produces no message, and the stale-vs-hallucinated split and streak counts live only on the event. A sub-agent\'s high-volume, message-derivable events (turn.start/turn.end, provider.selected, context.updated) are intentionally NOT merged — read its hoisted messages for model/tokens/cost and turn-by-turn activity, and the bracketing subagent.* events for the run\'s span.',
273
+ "Event types: assistant.connected/disconnected (mount + placement + whether the session was created or restored), assistant.popout/popin (window placement), driver.created/wired/unwired (which driver is live and why it stops/starts responding across a popout), state.changed (idle↔loading), turn.start/turn.end (turn boundary; turn.end carries durationMs), turn.retry (a recoverable in-turn retry — detail.reason plus attempt/maxAttempts; for malformed calls also finishMessage; for empty responses also the provider finishReason + thoughtsTokens + parts breakdown), turn.finish-guard (the model replied with no tool call and the agent's finishGuard hook answered — detail.action is continue (the turn was held open: detail.continuation counts the holds this turn and detail.note is the note stored as a hidden user message with driverNote finish-guard, the next message in the log; detail.source: 'completion-nudge' is instead the driver holding a SUB-AGENT's turn open because it replied in prose without calling its completion tool — detail.nudge of detail.maxNudges, the note stored with driverNote completion-nudge — and a sub-agent that still answers in prose after the last nudge fails as before; detail.source: 'forced-tool-nudge' is the driver holding a PARENT agent's forced turn open after a model that rejects forcing answered in prose, the note stored with driverNote forced-tool-nudge, naming the tool when the turn was pinned to one) or end with detail.release: true (the agent was released on a prose answer); a plain end records nothing), turn.error (a turn failed or hit a guardrail — detail.reason is one of exception/malformed-function-call/empty-response/unknown-tool-limit/max-iterations/response-truncated/refusal/budget-exhausted/provider-refused/context-exhausted/ai-service-error, plus reason-specific diagnostics: attempts (for empty-response also finishReason + thoughtsTokens + a parts breakdown, distinguishing a thinking-only STOP from a truly empty turn), finishMessage, for response-truncated the model + maxTokens + outputTokens + tools, unknownTools (split into staleTools — real earlier this activation but retired by the current state or hidden behind an open exclusive fold — and hallucinatedTools — never advertised) + availableTools, iterations + limit, for budget-exhausted the budgetUsd + spentUsd figures reported by the proxy plus the resolved vendor, for provider-refused the kind (spend|auth) plus the upstream status and error type — the vendor refusing the ACCOUNT rather than us refusing to spend, so the remedy is a top-up or a key rotation rather than a raised cap, and the kind is the only place that distinction survives because the user-facing copy is deliberately cause-free, for context-exhausted the estimated contextTokens against the guard that stopped the turn plus the iterations reached — the driver ending a runaway tool loop at the edge of the context window rather than issuing a request the provider would reject, so the transcript survives intact and can still be compacted, for ai-service-error the code (one of AI_SERVICE_ERROR_CODES, e.g. NO_API_KEY) and the status the AI service answered with — its own text goes to the browser console only, or name + message for exceptions), tool.failed (a tool threw), tool.unresolved (the model called a tool that could not be dispatched — detail.kind is folded/fold-hidden/stale/unknown, plus tool + agent and, for the counted kinds, the consecutive streak; or kind pinned-elsewhere, a turn pinned to detail.pinned (toolChoice { tool }) that went out unforced because the model rejects forcing, and whose reply called only detail.tools: none of them was run, each was answered with a refusal naming the pinned tool, detail.nudge of detail.maxNudges, counted against the forced-tool nudge on a parent agent and the completion nudge on a sub-agent; the recurring lead-up to an unknown-tool-limit turn.error), subagent.started/completed/failed (the lifecycle of a `requestSubAgent` delegation — detail.agent names the sub-agent; these bracket the sub-agent turns that appear as kind:turn entries with a `<parentTurn>-<subAgentNo>.<childTurn>` `turnIndex`, where the sub-agent number is the order the sub-agent started in within its parent turn, so it matches the order of the subagent.started events; all three carry detail.turnPrefix, that `<parentTurn>-<subAgentNo>` which the sub-agent's turns' `turnIndex` begins with, so an event and its turns are matched by value; subagent.failed also carries detail.reason, one of max_iterations/malformed_tool_call/empty_response/unknown_tool_limit/timeout/response_truncated/refusal/budget_exhausted/provider_refused/context_exhausted/ai_service_error, and for timeout detail.cause: 'idle' when it was the sub-agent making no progress for `idleTimeoutMs` rather than the overall `timeoutMs` (absent for the latter); budget_exhausted and provider_refused are terminal for the PARENT turn too, and so is ai_service_error when the refusal is about the service rather than the request and came from the vendor the parent calls — the parent stops rather than calling the model again into the same wall; after context_exhausted the parent goes on, but its own next call is likely to stop on the same guard), agent.handoff (routing; from=null is the initial activation), agent.pinned/unpinned (forced routing), routing.decided (ONE PER ROUTING DECISION — see its own paragraph below), provider.selected (the resolved provider for the upcoming turns — detail.provider is the registry SLOT/tier name, detail.model the concrete model behind it and detail.vendor its vendor; emitted only when the slot CHANGES, so read the per-turn `model` for the model of any given call rather than assuming the nearest event still applies), interaction.requested/resolved (blocking user widgets — explain quiet gaps; note that when a sub-agent opens a widget, detail.agent — and the agentName on the interaction message — is the HOST agent that owns the widget, NOT the sub-agent that asked, because widgets render and resolve on the host driver; detail.ownerPath names the agents that actually asked, outermost first, the last being the one whose tool requested it, and detail.heldBy says who held it when it opened: user, or the id of the interceptor that claimed it, such as autopilot; on interaction.resolved, detail.answeredBy is who answered — the claimant id when it settled through its own hold, user for any other answer (a click counts as the person even on a widget a claimant held) — absent when it closed unanswered (a timeout or a stop), and absent too when it settled by itself other than through the hold of a claimant — a widget registered resolvesItself (one that does its work and settles on its own, asking the person nothing, such as a generation run), or one outcome its controller said settled itself (ctx.resolve with resolvedItself, such as a generation phase that failed outright before its review gate ever asked anything) — which then carries detail.resolvedItself: true instead, as the interaction message does — nobody answered it, and the platform cannot tell it finishing from the person interrupting it (a Skip), so only the result of the widget itself can say which; the same value is stamped on the interaction message as answeredBy and on the result the asking tool handler receives (absent there in the same cases), and when it is not user the tool result that interaction returned carries a decidedOnUsersBehalf record, so the model was told the choice was not made by the person; detail.edits, present only when non-zero, counts the editing actions a claimant ran on the widget before it was settled, whoever settled it, and those edits are stamped on the interaction message as edits, each with by, action, choice and args when it had some, in the order they ran, while a decidedOnUsersBehalf record carries their choice texts as edits, and when the person settled it after such edits the tool result carries an editedOnUsersBehalf record instead — the framing and those choice texts — so the model knows the widget was changed on the user behalf before the user answered, and that the user then confirmed it by finishing it), interaction.held (a claimant moved a pending interaction to the person or back to itself — detail.heldBy is the new holder, detail.claimant the interceptor; detail.late: true is an interceptor that declined it when it opened claiming it afterwards, such as the autopilot resumed while it was open; a widget held by anything but user was not answered by the person), interaction.claim-refused (a claim on a userOnly interaction, which stays with the person — detail.claimant + reason), autopilot.* (the autopilot, a decorator that answers interactions on behalf of the user — autopilot.claimed / autopilot.declined say whether it took each interaction and, for a decline, detail.reason: paused, other-flow, no-autopilot, unavailable, userOnly, policy or no-controller; one declined as paused that is still open when the person resumes the autopilot is looked at again, and the autopilot.claimed or autopilot.declined recorded for it then carries detail.onResume: true (a decline then can also be claimed-elsewhere, another interceptor having claimed it first); a restored mode looks at nothing; autopilot.decision-sent is what it was sent (detail.chars; detail.nothingEnabled: true when every action on the widget was unavailable — a gate whose controller said it was asking, such as a failed build the autopilot may not cancel — so it could only hand it back, which it may then do even after the person asked it to decide it itself; a widget whose controller says it is working (ctx.setWorking) is never sent a decision until it says it is asking, even when an action is enabled or the person resumes the autopilot); autopilot.acted is what it did (detail.action, detail.note, detail.finished); autopilot.handed-back is a decision it gave to the person (detail.reason and detail.trigger: model, no-decision or error); autopilot.paused / autopilot.resumed are mode changes (detail.scope, detail.trigger, detail.decideYourself when the person resumed during a hand-back; detail.trigger is restored when the mode came back with the session after a reload, applied once its flow re-activated, which starts nothing by itself); autopilot.carried is the mode, running or paused, going with the task to the agent that took it over, rather than ending with the flow as on any other change of flow owner: to the target of a hand-off, or back to its caller on the hand-back (detail.from, detail.to, detail.mode); a pause the person chose goes with it, and Stop and Clear still end it; a mode restored for the target of a hand-off applies to its caller when the reload hands back; autopilot.error is the wrapper itself failing; autopilot.refinement counts a refining action against its step — a written answer (reply) or a widget action declared refines, such as a regenerate with instructions, counted together (detail.action, detail.stepKey, detail.count, detail.limitReached, after which every refining action is withdrawn for that step: not listed, and refused; the decision and every relisting of its actions say how many are left at the step, as a line Refinements left at this step: N, wherever the widget has a refining action); autopilot.handback-presented is the turn-level hand-back, shown when a working turn ended needing the person with no widget to hand over (detail.why: max-iterations, context-exhausted, failure or question; detail.options; detail.choice once answered); autopilot.catch-up is the autopilot being given the whole visible transcript at once (detail.why: first, for its first decision in a flow or after a reload; size, when its own history passed its budget and was rebuilt short — detail.ownChars; or compacted, when a compaction removed the last message it had seen, so it reads the summary and everything since, short; in each, what it had sent on the user behalf is included and labelled as its own, since its own history does not hold it); autopilot.cost-dropped is autopilot spend that no message carries, so it is NOT in the session total (detail.costUsd and detail.why: handed-back, aborted or stale for a written question it answered that no reply was sent for — stale when a pause, a resume, a new turn or the end of its flow came before the answer landed, which then went nowhere — or no-recorder when the driver had no way to book a decision to its interaction); a hand-back trigger can also be budget (the decision passed its spend cap), watchdog (its work went quiet: no ready surface and no heartbeat, or its own decision stalled with no model call landing, which stops that decision) or detached (the autopilot was removed while it held the interaction, which went to the person with no reason shown). To debug one autopilot decision, follow its interactionId: interaction.requested (heldBy), autopilot.claimed, autopilot.decision-sent, autopilot.acted or autopilot.handed-back, interaction.invoked, interaction.resolved (answeredBy), then the next turn of the working agent), interaction.invoked (a claimant ran one of the actions the widget itself exposes, through its hold, the same code the button runs — detail.claimant, detail.action (an option id, select or reply) and detail.finished, whether that settled the interaction, and when it did not, the run is recorded as an edit; the choice and narration it recorded reach the result of the tool that asked as decidedOnUsersBehalf; the person's own programmatic action, from a host with no DOM to click, carries detail.by: user in place of detail.claimant, and is not recorded as an edit nor as a decision on their behalf, so what it settles is answered by user), interaction.step (a long action run as named steps through runSteps, which survive a reload — detail.step and detail.outcome: started, done, skipped when the step was already done before a reload, or resumed when it started before a reload and runs again with what it saved part-way, such as a job id it re-attaches to), interaction.checkpoint (the checkpoints a conversation keeps for its long actions: the one in flight, and each one a reload cut, held apart until a request of its own widget type takes it over, so a resumed flow that opens other long widgets first, which save their own, loses nothing — detail.action: resumed when a reload cut the work and a request of the same widget type that the registration sameWork agrees is the same work took it over, refused when sameWork said a new request is different work (detail.saved is the identity it kept; detail.kept: true, since it stays for a later request of that type, and is offered to every one until one agrees) or when runSteps found the handed-over checkpoint malformed and started fresh (detail.reason, detail.saved), or cleared when its flow ended, once per checkpoint, with detail.cut: true for one a reload cut that nothing took over), context.updated/threshold-crossed (token + cost), headless.attached (a HeadlessSession attached, for a host that drives the assistant with no screen — detail.label, what the host called itself, when it gave one) and headless.raw-resolved (that host settled an interaction raw, bypassing the widget's own actions: detail.interactionId and detail.component; the result went to the tool as given, so check what the widget would have enforced), context.condensed (a stale tool payload was collapsed out of the model-bound history by a `condenseWhen` declaration on the tool — detail.tool + toolCallId, target args|response, trigger (superseded:<key> or age:<n>), stubLen, and an estimated tokensSaved; stored history and this log keep the FULL payload, so the model-visible slice at any point is the full history minus the condensations recorded up to then), panel.toggled, attachment.added, file.read-failed, suggestions.failed.",
274
+ 'Sub-agent meta events: a sub-agent\'s own turn.retry/turn.error/tool.failed/tool.unresolved/turn.finish-guard events are merged into this same timeline, tagged with `detail.subAgent` — a `"<parent> › <sub-agent>"` breadcrumb that composes when nested (e.g. `"UI Builder › Planner › Grounding"`) — and interleaved by their original timestamps within the subagent.started→completed/failed bracket; each also carries `detail.turnPrefix`, the `<parentTurn>-<subAgentNo>` that the `turnIndex` of its own sub-agent turns begins with (an event of a nested sub-agent gets the composed prefix, e.g. 3-2.2-1), so a retry or failure is matched to the turns it happened in by value. These are the per-attempt/per-failure signals that do NOT appear among the sub-agent\'s (hoisted) messages: a malformed/empty attempt that gets retried produces no message, and the stale-vs-hallucinated split and streak counts live only on the event. A sub-agent\'s high-volume, message-derivable events (turn.start/turn.end, provider.selected, context.updated) are intentionally NOT merged — read its hoisted messages for model/tokens/cost and turn-by-turn activity, and the bracketing subagent.* events for the run\'s span.',
275
275
  "`meta` holds context captured at export time: agentSummary (full agent configs), context (active model, contextTokens/contextLimit/contextUsagePercent for the last call, and the session totals — sessionCostUsd, sessionTokensConsumed, and the four-bucket sessionUsage lifted to the top of this log), activeDebugSnapshot (the active agent's `getDebugSnapshot()` taken fresh at export — reflects state NOW, which may have advanced beyond the last turn's agentSnapshot), debug (optional host-supplied debug state), host, and the export timestamp.",
276
276
  'Note the two different scopes in `meta.context`: `contextTokens` is the prompt size of the LAST call (against `contextLimit`, the model context window), while `sessionUsage`/`sessionTokensConsumed` are cumulative BILLED throughput. Every turn resends the conversation, so the cumulative figure counts each turn’s prompt again in the next turn’s and is expected to dwarf the context size — that is not double-counting.',
277
277
  "kind:'event' type 'routing.decided' — how ONE user turn was routed, emitted by the orchestrating driver before the agent runs. Only a user turn is routed: a hand-off names its target, so the agents a hand-off runs show up as agent.handoff events, not as more routing.decided. `decision` is why that agent was chosen: 'classified' (the classifier ran and picked one), 'no-match' (it ran and answered -1 — nothing listed covers the request), 'pinned' (a user pin, an agent named for that one message by the send's `agent` option, or an active stateful flow owned the turn, so no call was made), 'single-candidate'/'no-specialists' (configuration left nothing to decide), 'provider-unavailable' (the registry default exposes no chat()), 'classifier-failed' (every attempt threw — `error` carries the last one). `to` names the agent and `fallback` says whether that agent is the fallback. `candidates` is what was ON THE BALLOT — every classifier-eligible specialist — in ballot order, so `index` — the classifier's own answer — indexes it directly. `candidates` is absent on the three decisions that put nothing to a vote — 'pinned', 'single-candidate', 'no-specialists'. It IS present on 'provider-unavailable', which is not an exception worth removing: the ballot was built there, it simply never got sent. `attempts` covers the retry ladder. `durationMs` is on EVERY routing.decided, and is the field to read when a decision looks wrong: the decisions that can reach the fallback ('no-match', 'no-specialists', 'provider-unavailable', 'classifier-failed') are told apart by the clock as much as by their name, because a fallback routing that resolved in tens of milliseconds made no network call at all whatever its `decision` says.",
@@ -137,11 +137,16 @@ function stringifyLeniently(value) {
137
137
  *
138
138
  * All three components are fixed when the snapshot is created and never re-derived.
139
139
  * `turnIndex` alone is not enough: it restarts at `'0'` on each page load, and a lifetime
140
- * log legitimately holds one turn `'0'` per load. `agentName` separates two sub-agents
141
- * invoked in the same parent turn, which share a `turnIndex` prefix by construction (see
142
- * `forwardSubAgentSnapshots`).
140
+ * log legitimately holds one turn `'0'` per load. `timestamp` and `agentName` are a backstop
141
+ * for any future label collision — forwarded sub-agent turns are already labelled uniquely
142
+ * (`<parentTurn>-<subAgentNo>.<childTurn>`, see `TurnRecorder.forwardSubAgent`).
143
+ *
144
+ * Shared with the forward-capture persister, which keys its per-turn cursor on the same
145
+ * identity so the two layers can never disagree about which turns are distinct.
146
+ *
147
+ * @internal
143
148
  */
144
- function turnIdentity(entry) {
149
+ export function turnIdentity(entry) {
145
150
  var _a, _b, _c;
146
151
  return `turn::${String((_a = entry.turnIndex) !== null && _a !== void 0 ? _a : '')}::${(_b = entry.timestamp) !== null && _b !== void 0 ? _b : ''}::${String((_c = entry.agentName) !== null && _c !== void 0 ? _c : '')}`;
147
152
  }
@@ -6,7 +6,7 @@ import { logger } from '../../utils/logger';
6
6
  import { isSessionNoticeMarker, SESSION_RESTORE_FAILED_LABEL, SESSION_RESTORED_LABEL, SESSION_RESUMED_LABEL, } from '../../utils/message-partition';
7
7
  import { withTimeout } from '../../utils/with-timeout';
8
8
  import { recordMetaEvent } from '../debug-event-log';
9
- import { diagnosticsMessageKey } from './diagnostics';
9
+ import { diagnosticsMessageKey, turnIdentity } from './diagnostics';
10
10
  import { getDiagnosticsCursors } from './diagnostics-cursors';
11
11
  import { buildResumeNote, createPersistedSession, interruptedPromptFiles, isRestorableSession, keepThroughLastUserMessage, lastUserMessageIndex, reconcileAgentSnapshots, resolveNonResumableNotice, toLoadSessionPayload, trimToRestorableBoundary, unknownAgentSnapshots, } from './session-snapshot';
12
12
  const autopilotOf = (driver) => driver && typeof driver.getPersistedMode === 'function'
@@ -1080,14 +1080,14 @@ export class SessionPersister {
1080
1080
  /**
1081
1081
  * The diagnostic entries not yet appended this load — the forward-capture delta
1082
1082
  * (§5.8). Skips messages present at restore or already appended; emits each meta-event
1083
- * (by index) once and each turn (by turn-index) once unpriced plus once more when its
1083
+ * (by index) once and each turn (by `turnIdentity`: turnIndex + timestamp + agentName) once unpriced plus once more when its
1084
1084
  * per-call `usage` lands; appends a `meta-snapshot` only when the block changed.
1085
1085
  * Advances the shared per-session cursors as it goes.
1086
1086
  *
1087
1087
  * TODO(GENC-1461, longer-term): this whole delta step exists only because the element *pulls* the
1088
1088
  * ENTIRE debug log on every throttled flush (`getDiagnosticEntries()` returns the full timeline),
1089
1089
  * so we must diff it against per-session cursors to append only the new tail — and messages, unlike
1090
- * events (monotonic `index`) and turns (`turnIndex`), have no stable positional cursor (compaction
1090
+ * events (monotonic `index`) and turns (`turnIdentity`: turnIndex + timestamp + agentName), have no stable positional cursor (compaction
1091
1091
  * rewrites ranges, tool-call messages are annotated in place, synthetic messages are spliced in,
1092
1092
  * restore reloads them), forcing a content-derived identity (`diagnosticsMessageKey`). That
1093
1093
  * identity is inherently fragile: it was too coarse for the reasoning/answer/tool-call split and
@@ -1097,7 +1097,6 @@ export class SessionPersister {
1097
1097
  * the message-identity key and this dedup entirely. Bigger change; deferred.
1098
1098
  */
1099
1099
  collectDiagnosticsDelta() {
1100
- var _a;
1101
1100
  const cursors = getDiagnosticsCursors(this.stateKey);
1102
1101
  const delta = [];
1103
1102
  for (const entry of this.deps.getDiagnosticEntries()) {
@@ -1113,9 +1112,11 @@ export class SessionPersister {
1113
1112
  // lands, so a flush that falls in between persists it unpriced. Emit it a second
1114
1113
  // time once `usage` is there — keyed separately so it happens at most once per
1115
1114
  // turn — and let `assembleDebugLog` collapse the pair onto the priced copy.
1115
+ // Keyed by the full turn identity (the same key `assembleDebugLog` collapses on), not
1116
+ // `turnIndex` alone, so two turns that ever share a label are both kept.
1116
1117
  // Without this the stitched lifetime log silently loses per-call cost for any
1117
1118
  // turn that outlived a flush, which is most of the slow ones.
1118
- const key = String((_a = entry.turnIndex) !== null && _a !== void 0 ? _a : '');
1119
+ const key = turnIdentity(entry);
1119
1120
  const emitKey = entry.usage ? `${key}::usage` : key;
1120
1121
  if (cursors.emittedTurnKeys.has(emitKey))
1121
1122
  continue;
@@ -38,7 +38,7 @@ var GENESIS_AI_CONSUMES = Object.freeze({
38
38
  "inputs",
39
39
  "effects"
40
40
  ]),
41
- vendors: Object.freeze(["anthropic", "gemini"]),
41
+ vendors: Object.freeze(["anthropic", "gemini", "openai"]),
42
42
  tiers: Object.freeze(["low", "high", "reasoning"]),
43
43
  shapes: Object.freeze(["row", "key-row"])
44
44
  });
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../src/genesis/consumes.ts"],
4
- "sourcesContent": ["/**\n * What this version of the assistant reads from a generated AI config\n * (`@genesislcap/ai-assistant/genesis/consumes`).\n *\n * @remarks\n * Its own entry point, loadable in bare Node, because the seed's CI reads it in a Node step and\n * `./genesis` cannot be: that entry is bundler-target ESM, and its closure registers custom\n * elements, which need a DOM. So this module imports nothing at run time. A type from `./types`\n * is all it may take, and a test holds it to that. The Node build bundles it to\n * `dist/genesis-consumes.mjs` and `.cjs`, and a smoke test loads both without a DOM.\n *\n * @packageDocumentation\n * @beta\n */\nimport type { GenesisAiConsumes } from './types';\n\nexport type { GenesisAiConsumes } from './types';\n\n/**\n * What this version of the assistant reads from a generated AI config: the resource kinds it\n * accepts, the resource fields its validator or a tool reads, the `vendor` and `tier` values it\n * accepts, and the row-action shapes it runs.\n *\n * @remarks\n * The generator must not emit what the installed assistant does not read, or a new kind is left out\n * and a new field ignored \u2014 and an older assistant used to block entirely on a kind it did not know.\n * Nothing in the generator can say which version will run its output. So the app's seed declares\n * what it expects, and the seed's CI checks that declaration against this constant, exported from\n * the version it installs. That makes this the single statement of what an assistant consumes, and\n * it carries no version number because it needs none.\n *\n * A test holds it to the code: its kinds are the ones validation accepts, and its fields are the\n * ones read. A change that teaches the validator a kind, or a tool a field, updates it in the same\n * commit.\n *\n * A resource this version does not read is only left out, but an unknown `vendor` or `tier` still\n * blocks the whole assistant, so those are here too. They are written out rather than imported\n * from foundation-ai, which this entry must not load; a test holds them equal to its\n * `AI_TIER_VENDORS` and `AI_TIER_IDS`, which the validator checks against.\n *\n * @beta\n */\nexport const GENESIS_AI_CONSUMES: GenesisAiConsumes = Object.freeze({\n kinds: Object.freeze(['request', 'event', 'query'] as const),\n resourceFields: Object.freeze([\n 'name',\n 'kind',\n 'op',\n 'context',\n 'maxRows',\n 'customCode',\n 'references',\n 'shape',\n 'entity',\n 'key',\n 'inputs',\n 'effects',\n ] as const),\n vendors: Object.freeze(['anthropic', 'gemini'] as const),\n tiers: Object.freeze(['low', 'high', 'reasoning'] as const),\n shapes: Object.freeze(['row', 'key-row'] as const),\n});\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AA0CO,IAAM,sBAAyC,OAAO,OAAO;AAAA,EAClE,OAAO,OAAO,OAAO,CAAC,WAAW,SAAS,OAAO,CAAU;AAAA,EAC3D,gBAAgB,OAAO,OAAO;AAAA,IAC5B;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF,CAAU;AAAA,EACV,SAAS,OAAO,OAAO,CAAC,aAAa,QAAQ,CAAU;AAAA,EACvD,OAAO,OAAO,OAAO,CAAC,OAAO,QAAQ,WAAW,CAAU;AAAA,EAC1D,QAAQ,OAAO,OAAO,CAAC,OAAO,SAAS,CAAU;AACnD,CAAC;",
4
+ "sourcesContent": ["/**\n * What this version of the assistant reads from a generated AI config\n * (`@genesislcap/ai-assistant/genesis/consumes`).\n *\n * @remarks\n * Its own entry point, loadable in bare Node, because the seed's CI reads it in a Node step and\n * `./genesis` cannot be: that entry is bundler-target ESM, and its closure registers custom\n * elements, which need a DOM. So this module imports nothing at run time. A type from `./types`\n * is all it may take, and a test holds it to that. The Node build bundles it to\n * `dist/genesis-consumes.mjs` and `.cjs`, and a smoke test loads both without a DOM.\n *\n * @packageDocumentation\n * @beta\n */\nimport type { GenesisAiConsumes } from './types';\n\nexport type { GenesisAiConsumes } from './types';\n\n/**\n * What this version of the assistant reads from a generated AI config: the resource kinds it\n * accepts, the resource fields its validator or a tool reads, the `vendor` and `tier` values it\n * accepts, and the row-action shapes it runs.\n *\n * @remarks\n * The generator must not emit what the installed assistant does not read, or a new kind is left out\n * and a new field ignored \u2014 and an older assistant used to block entirely on a kind it did not know.\n * Nothing in the generator can say which version will run its output. So the app's seed declares\n * what it expects, and the seed's CI checks that declaration against this constant, exported from\n * the version it installs. That makes this the single statement of what an assistant consumes, and\n * it carries no version number because it needs none.\n *\n * A test holds it to the code: its kinds are the ones validation accepts, and its fields are the\n * ones read. A change that teaches the validator a kind, or a tool a field, updates it in the same\n * commit.\n *\n * A resource this version does not read is only left out, but an unknown `vendor` or `tier` still\n * blocks the whole assistant, so those are here too. They are written out rather than imported\n * from foundation-ai, which this entry must not load; a test holds them equal to its\n * `AI_TIER_VENDORS` and `AI_TIER_IDS`, which the validator checks against.\n *\n * @beta\n */\nexport const GENESIS_AI_CONSUMES: GenesisAiConsumes = Object.freeze({\n kinds: Object.freeze(['request', 'event', 'query'] as const),\n resourceFields: Object.freeze([\n 'name',\n 'kind',\n 'op',\n 'context',\n 'maxRows',\n 'customCode',\n 'references',\n 'shape',\n 'entity',\n 'key',\n 'inputs',\n 'effects',\n ] as const),\n vendors: Object.freeze(['anthropic', 'gemini', 'openai'] as const),\n tiers: Object.freeze(['low', 'high', 'reasoning'] as const),\n shapes: Object.freeze(['row', 'key-row'] as const),\n});\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AA0CO,IAAM,sBAAyC,OAAO,OAAO;AAAA,EAClE,OAAO,OAAO,OAAO,CAAC,WAAW,SAAS,OAAO,CAAU;AAAA,EAC3D,gBAAgB,OAAO,OAAO;AAAA,IAC5B;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF,CAAU;AAAA,EACV,SAAS,OAAO,OAAO,CAAC,aAAa,UAAU,QAAQ,CAAU;AAAA,EACjE,OAAO,OAAO,OAAO,CAAC,OAAO,QAAQ,WAAW,CAAU;AAAA,EAC1D,QAAQ,OAAO,OAAO,CAAC,OAAO,SAAS,CAAU;AACnD,CAAC;",
6
6
  "names": []
7
7
  }
@@ -15,7 +15,7 @@ var GENESIS_AI_CONSUMES = Object.freeze({
15
15
  "inputs",
16
16
  "effects"
17
17
  ]),
18
- vendors: Object.freeze(["anthropic", "gemini"]),
18
+ vendors: Object.freeze(["anthropic", "gemini", "openai"]),
19
19
  tiers: Object.freeze(["low", "high", "reasoning"]),
20
20
  shapes: Object.freeze(["row", "key-row"])
21
21
  });
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../src/genesis/consumes.ts"],
4
- "sourcesContent": ["/**\n * What this version of the assistant reads from a generated AI config\n * (`@genesislcap/ai-assistant/genesis/consumes`).\n *\n * @remarks\n * Its own entry point, loadable in bare Node, because the seed's CI reads it in a Node step and\n * `./genesis` cannot be: that entry is bundler-target ESM, and its closure registers custom\n * elements, which need a DOM. So this module imports nothing at run time. A type from `./types`\n * is all it may take, and a test holds it to that. The Node build bundles it to\n * `dist/genesis-consumes.mjs` and `.cjs`, and a smoke test loads both without a DOM.\n *\n * @packageDocumentation\n * @beta\n */\nimport type { GenesisAiConsumes } from './types';\n\nexport type { GenesisAiConsumes } from './types';\n\n/**\n * What this version of the assistant reads from a generated AI config: the resource kinds it\n * accepts, the resource fields its validator or a tool reads, the `vendor` and `tier` values it\n * accepts, and the row-action shapes it runs.\n *\n * @remarks\n * The generator must not emit what the installed assistant does not read, or a new kind is left out\n * and a new field ignored \u2014 and an older assistant used to block entirely on a kind it did not know.\n * Nothing in the generator can say which version will run its output. So the app's seed declares\n * what it expects, and the seed's CI checks that declaration against this constant, exported from\n * the version it installs. That makes this the single statement of what an assistant consumes, and\n * it carries no version number because it needs none.\n *\n * A test holds it to the code: its kinds are the ones validation accepts, and its fields are the\n * ones read. A change that teaches the validator a kind, or a tool a field, updates it in the same\n * commit.\n *\n * A resource this version does not read is only left out, but an unknown `vendor` or `tier` still\n * blocks the whole assistant, so those are here too. They are written out rather than imported\n * from foundation-ai, which this entry must not load; a test holds them equal to its\n * `AI_TIER_VENDORS` and `AI_TIER_IDS`, which the validator checks against.\n *\n * @beta\n */\nexport const GENESIS_AI_CONSUMES: GenesisAiConsumes = Object.freeze({\n kinds: Object.freeze(['request', 'event', 'query'] as const),\n resourceFields: Object.freeze([\n 'name',\n 'kind',\n 'op',\n 'context',\n 'maxRows',\n 'customCode',\n 'references',\n 'shape',\n 'entity',\n 'key',\n 'inputs',\n 'effects',\n ] as const),\n vendors: Object.freeze(['anthropic', 'gemini'] as const),\n tiers: Object.freeze(['low', 'high', 'reasoning'] as const),\n shapes: Object.freeze(['row', 'key-row'] as const),\n});\n"],
5
- "mappings": ";AA0CO,IAAM,sBAAyC,OAAO,OAAO;AAAA,EAClE,OAAO,OAAO,OAAO,CAAC,WAAW,SAAS,OAAO,CAAU;AAAA,EAC3D,gBAAgB,OAAO,OAAO;AAAA,IAC5B;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF,CAAU;AAAA,EACV,SAAS,OAAO,OAAO,CAAC,aAAa,QAAQ,CAAU;AAAA,EACvD,OAAO,OAAO,OAAO,CAAC,OAAO,QAAQ,WAAW,CAAU;AAAA,EAC1D,QAAQ,OAAO,OAAO,CAAC,OAAO,SAAS,CAAU;AACnD,CAAC;",
4
+ "sourcesContent": ["/**\n * What this version of the assistant reads from a generated AI config\n * (`@genesislcap/ai-assistant/genesis/consumes`).\n *\n * @remarks\n * Its own entry point, loadable in bare Node, because the seed's CI reads it in a Node step and\n * `./genesis` cannot be: that entry is bundler-target ESM, and its closure registers custom\n * elements, which need a DOM. So this module imports nothing at run time. A type from `./types`\n * is all it may take, and a test holds it to that. The Node build bundles it to\n * `dist/genesis-consumes.mjs` and `.cjs`, and a smoke test loads both without a DOM.\n *\n * @packageDocumentation\n * @beta\n */\nimport type { GenesisAiConsumes } from './types';\n\nexport type { GenesisAiConsumes } from './types';\n\n/**\n * What this version of the assistant reads from a generated AI config: the resource kinds it\n * accepts, the resource fields its validator or a tool reads, the `vendor` and `tier` values it\n * accepts, and the row-action shapes it runs.\n *\n * @remarks\n * The generator must not emit what the installed assistant does not read, or a new kind is left out\n * and a new field ignored \u2014 and an older assistant used to block entirely on a kind it did not know.\n * Nothing in the generator can say which version will run its output. So the app's seed declares\n * what it expects, and the seed's CI checks that declaration against this constant, exported from\n * the version it installs. That makes this the single statement of what an assistant consumes, and\n * it carries no version number because it needs none.\n *\n * A test holds it to the code: its kinds are the ones validation accepts, and its fields are the\n * ones read. A change that teaches the validator a kind, or a tool a field, updates it in the same\n * commit.\n *\n * A resource this version does not read is only left out, but an unknown `vendor` or `tier` still\n * blocks the whole assistant, so those are here too. They are written out rather than imported\n * from foundation-ai, which this entry must not load; a test holds them equal to its\n * `AI_TIER_VENDORS` and `AI_TIER_IDS`, which the validator checks against.\n *\n * @beta\n */\nexport const GENESIS_AI_CONSUMES: GenesisAiConsumes = Object.freeze({\n kinds: Object.freeze(['request', 'event', 'query'] as const),\n resourceFields: Object.freeze([\n 'name',\n 'kind',\n 'op',\n 'context',\n 'maxRows',\n 'customCode',\n 'references',\n 'shape',\n 'entity',\n 'key',\n 'inputs',\n 'effects',\n ] as const),\n vendors: Object.freeze(['anthropic', 'gemini', 'openai'] as const),\n tiers: Object.freeze(['low', 'high', 'reasoning'] as const),\n shapes: Object.freeze(['row', 'key-row'] as const),\n});\n"],
5
+ "mappings": ";AA0CO,IAAM,sBAAyC,OAAO,OAAO;AAAA,EAClE,OAAO,OAAO,OAAO,CAAC,WAAW,SAAS,OAAO,CAAU;AAAA,EAC3D,gBAAgB,OAAO,OAAO;AAAA,IAC5B;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF,CAAU;AAAA,EACV,SAAS,OAAO,OAAO,CAAC,aAAa,UAAU,QAAQ,CAAU;AAAA,EACjE,OAAO,OAAO,OAAO,CAAC,OAAO,QAAQ,WAAW,CAAU;AAAA,EAC1D,QAAQ,OAAO,OAAO,CAAC,OAAO,SAAS,CAAU;AACnD,CAAC;",
6
6
  "names": []
7
7
  }
package/docs/genesis.md CHANGED
@@ -99,7 +99,7 @@ that table, unless asked), then the extensions' prompt.
99
99
 
100
100
  | Field | Rule |
101
101
  | -------------- | ------------------------------------------------------------------------------------------- |
102
- | `vendor` | A tier-table vendor. Defaults to `gemini`. |
102
+ | `vendor` | `anthropic`, `gemini` or `openai`. Defaults to `gemini`. |
103
103
  | `tier` | `low`, `high` or `reasoning`. Defaults to `high`. |
104
104
  | `name` | Unique; the tool name is the lowercased name (≤ 64 chars). `REQ_<NAME>` for a request, `EVENT_<NAME>` for an event, and for a query the dataserver query's own name in upper-case letters, digits and underscores. |
105
105
  | `kind` | `request`, `event` or `query`. The kind decides which name rule applies, never the name: a query named `REQ_…` is still a query. |
@@ -137,7 +137,7 @@ GENESIS_AI_CONSUMES;
137
137
  // kinds: ['request', 'event', 'query'],
138
138
  // resourceFields: ['name', 'kind', 'op', 'context', 'maxRows', 'customCode', 'references',
139
139
  // 'shape', 'entity', 'key', 'inputs', 'effects'],
140
- // vendors: ['anthropic', 'gemini'],
140
+ // vendors: ['anthropic', 'gemini', 'openai'],
141
141
  // tiers: ['low', 'high', 'reasoning'],
142
142
  // shapes: ['row', 'key-row'],
143
143
  // }