@genesislcap/ai-assistant 15.103.2-GENC-2024.1 → 15.104.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/ai-assistant.api.json +56 -2
- package/dist/ai-assistant.d.ts +14 -6
- package/dist/chat-driver.cjs +29 -47
- package/dist/chat-driver.cjs.map +2 -2
- package/dist/chat-driver.mjs +29 -47
- package/dist/chat-driver.mjs.map +2 -2
- package/dist/custom-elements.json +2 -26
- package/dist/dts/autopilot/decision-message.d.ts.map +1 -1
- package/dist/dts/components/chat-driver/chat-driver.d.ts.map +1 -1
- package/dist/dts/components/chat-driver/turn-recorder.d.ts +11 -37
- package/dist/dts/components/chat-driver/turn-recorder.d.ts.map +1 -1
- package/dist/dts/headless/describe-interaction.d.ts.map +1 -1
- package/dist/dts/headless/headless.types.d.ts +2 -0
- package/dist/dts/headless/headless.types.d.ts.map +1 -1
- package/dist/dts/headless-server/types.d.ts +1 -0
- package/dist/dts/headless-server/types.d.ts.map +1 -1
- package/dist/dts/state/decision-surface.d.ts.map +1 -1
- package/dist/dts/state/persistence/diagnostics-cursors.d.ts +1 -4
- package/dist/dts/state/persistence/diagnostics-cursors.d.ts.map +1 -1
- package/dist/dts/state/persistence/diagnostics.d.ts +0 -24
- package/dist/dts/state/persistence/diagnostics.d.ts.map +1 -1
- package/dist/dts/state/persistence/session-persister.d.ts.map +1 -1
- package/dist/dts/types/interaction-surface.d.ts +8 -0
- package/dist/dts/types/interaction-surface.d.ts.map +1 -1
- package/dist/esm/autopilot/decision-message.js +3 -2
- package/dist/esm/components/chat-driver/chat-driver.js +9 -20
- package/dist/esm/components/chat-driver/turn-recorder.js +13 -36
- package/dist/esm/headless/describe-interaction.js +1 -1
- package/dist/esm/headless-server/compact.js +1 -1
- package/dist/esm/state/debug-event-log.js +3 -3
- package/dist/esm/state/decision-surface.js +7 -2
- package/dist/esm/state/persistence/diagnostics.js +4 -9
- package/dist/esm/state/persistence/session-persister.js +3 -4
- package/dist/headless-server.cjs +1 -1
- package/dist/headless-server.cjs.map +2 -2
- package/dist/headless-server.mjs +1 -1
- package/dist/headless-server.mjs.map +2 -2
- package/docs/sub_agent.md +16 -26
- package/package.json +17 -17
|
@@ -18917,7 +18917,7 @@
|
|
|
18917
18917
|
},
|
|
18918
18918
|
{
|
|
18919
18919
|
"kind": "Content",
|
|
18920
|
-
"text": "string | {\n readonly id?: string;\n readonly label: string;\n readonly unavailable?: () => string | undefined;\n}"
|
|
18920
|
+
"text": "string | {\n readonly id?: string;\n readonly label: string;\n readonly hint?: string;\n readonly unavailable?: () => string | undefined;\n}"
|
|
18921
18921
|
},
|
|
18922
18922
|
{
|
|
18923
18923
|
"kind": "Content",
|
|
@@ -19948,6 +19948,33 @@
|
|
|
19948
19948
|
"endIndex": 2
|
|
19949
19949
|
}
|
|
19950
19950
|
},
|
|
19951
|
+
{
|
|
19952
|
+
"kind": "PropertySignature",
|
|
19953
|
+
"canonicalReference": "@genesislcap/ai-assistant!DescribedAction#hint:member",
|
|
19954
|
+
"docComment": "/**\n * A sentence worth knowing before picking it. Only on a numbered option, when its widget gave one.\n */\n",
|
|
19955
|
+
"excerptTokens": [
|
|
19956
|
+
{
|
|
19957
|
+
"kind": "Content",
|
|
19958
|
+
"text": "readonly hint?: "
|
|
19959
|
+
},
|
|
19960
|
+
{
|
|
19961
|
+
"kind": "Content",
|
|
19962
|
+
"text": "string"
|
|
19963
|
+
},
|
|
19964
|
+
{
|
|
19965
|
+
"kind": "Content",
|
|
19966
|
+
"text": ";"
|
|
19967
|
+
}
|
|
19968
|
+
],
|
|
19969
|
+
"isReadonly": true,
|
|
19970
|
+
"isOptional": true,
|
|
19971
|
+
"releaseTag": "Beta",
|
|
19972
|
+
"name": "hint",
|
|
19973
|
+
"propertyTypeTokenRange": {
|
|
19974
|
+
"startIndex": 1,
|
|
19975
|
+
"endIndex": 2
|
|
19976
|
+
}
|
|
19977
|
+
},
|
|
19951
19978
|
{
|
|
19952
19979
|
"kind": "PropertySignature",
|
|
19953
19980
|
"canonicalReference": "@genesislcap/ai-assistant!DescribedAction#label:member",
|
|
@@ -43218,6 +43245,33 @@
|
|
|
43218
43245
|
"endIndex": 2
|
|
43219
43246
|
}
|
|
43220
43247
|
},
|
|
43248
|
+
{
|
|
43249
|
+
"kind": "PropertySignature",
|
|
43250
|
+
"canonicalReference": "@genesislcap/ai-assistant!SurfaceAction#hint:member",
|
|
43251
|
+
"docComment": "/**\n * A short-form option's hint, when its widget gave one: a sentence worth knowing before picking it.\n */\n",
|
|
43252
|
+
"excerptTokens": [
|
|
43253
|
+
{
|
|
43254
|
+
"kind": "Content",
|
|
43255
|
+
"text": "readonly hint?: "
|
|
43256
|
+
},
|
|
43257
|
+
{
|
|
43258
|
+
"kind": "Content",
|
|
43259
|
+
"text": "string"
|
|
43260
|
+
},
|
|
43261
|
+
{
|
|
43262
|
+
"kind": "Content",
|
|
43263
|
+
"text": ";"
|
|
43264
|
+
}
|
|
43265
|
+
],
|
|
43266
|
+
"isReadonly": true,
|
|
43267
|
+
"isOptional": true,
|
|
43268
|
+
"releaseTag": "Beta",
|
|
43269
|
+
"name": "hint",
|
|
43270
|
+
"propertyTypeTokenRange": {
|
|
43271
|
+
"startIndex": 1,
|
|
43272
|
+
"endIndex": 2
|
|
43273
|
+
}
|
|
43274
|
+
},
|
|
43221
43275
|
{
|
|
43222
43276
|
"kind": "PropertySignature",
|
|
43223
43277
|
"canonicalReference": "@genesislcap/ai-assistant!SurfaceAction#label:member",
|
|
@@ -45873,7 +45927,7 @@
|
|
|
45873
45927
|
{
|
|
45874
45928
|
"kind": "PropertySignature",
|
|
45875
45929
|
"canonicalReference": "@genesislcap/ai-assistant!TurnSnapshot#turnIndex:member",
|
|
45876
|
-
"docComment": "/**\n * Turn identifier, always a string. A driver's own turns are the bare counter (`\"0\"`, `\"1\"`, … — monotonic, does not reset on agent swap). Turns forwarded up from a sub-agent are re-labelled
|
|
45930
|
+
"docComment": "/**\n * Turn identifier, always a string. A driver's own turns are the bare counter (`\"0\"`, `\"1\"`, … — monotonic, does not reset on agent swap). Turns forwarded up from a sub-agent are re-labelled under the parent turn that activated them — a sub-agent invoked on parent turn 5 contributes `\"5-1\"`, `\"5-2\"`, …, and a nested sub-agent on `\"5-2\"` contributes `\"5-2-1\"`, …. See `forwardSubAgent`.\n */\n",
|
|
45877
45931
|
"excerptTokens": [
|
|
45878
45932
|
{
|
|
45879
45933
|
"kind": "Content",
|
package/dist/ai-assistant.d.ts
CHANGED
|
@@ -4707,6 +4707,12 @@ export declare type DecisionOption = string | {
|
|
|
4707
4707
|
readonly id?: string;
|
|
4708
4708
|
/** The option's text, as the person sees it. */
|
|
4709
4709
|
readonly label: string;
|
|
4710
|
+
/**
|
|
4711
|
+
* A sentence worth knowing before picking the option, as the person reads it (e.g. a
|
|
4712
|
+
* tooltip). Shown with the option to whoever decides it, so the autopilot and the headless CLI
|
|
4713
|
+
* choose from more than the bare label. Plain text, static like the label.
|
|
4714
|
+
*/
|
|
4715
|
+
readonly hint?: string;
|
|
4710
4716
|
/**
|
|
4711
4717
|
* Why it cannot be chosen right now, or `undefined` when it can — the button's own guard (e.g.
|
|
4712
4718
|
* "2 validation errors" for a Continue that needs a validated handler). Read fresh every time.
|
|
@@ -4979,6 +4985,8 @@ export declare interface DescribedAction {
|
|
|
4979
4985
|
readonly name: string;
|
|
4980
4986
|
/** What the person would read on the button, when it differs from the name. */
|
|
4981
4987
|
readonly label?: string;
|
|
4988
|
+
/** A sentence worth knowing before picking it. Only on a numbered option, when its widget gave one. */
|
|
4989
|
+
readonly hint?: string;
|
|
4982
4990
|
/** What a full-form action does, as its widget wrote it. */
|
|
4983
4991
|
readonly description?: string;
|
|
4984
4992
|
/** Whether it can be taken now. */
|
|
@@ -10480,6 +10488,8 @@ export declare interface SurfaceAction {
|
|
|
10480
10488
|
readonly name: string;
|
|
10481
10489
|
/** The text the person sees for it, where it has one. */
|
|
10482
10490
|
readonly label?: string;
|
|
10491
|
+
/** A short-form option's hint, when its widget gave one: a sentence worth knowing before picking it. */
|
|
10492
|
+
readonly hint?: string;
|
|
10483
10493
|
/** Whether running it settles the interaction. Every short-form action does. */
|
|
10484
10494
|
readonly finishes: boolean;
|
|
10485
10495
|
/** Whether it can be run right now. */
|
|
@@ -10995,12 +11005,10 @@ export declare interface TurnSnapshot {
|
|
|
10995
11005
|
/**
|
|
10996
11006
|
* Turn identifier, always a string. A driver's own turns are the bare counter
|
|
10997
11007
|
* (`"0"`, `"1"`, … — monotonic, does not reset on agent swap). Turns forwarded
|
|
10998
|
-
* up from a sub-agent are re-labelled
|
|
10999
|
-
*
|
|
11000
|
-
*
|
|
11001
|
-
*
|
|
11002
|
-
* a nested sub-agent started on its turn `"5-2.2"` contributes `"5-2.2-1.1"`, ….
|
|
11003
|
-
* `.` joins the parts of one level, `-` separates levels. See `forwardSubAgent`.
|
|
11008
|
+
* up from a sub-agent are re-labelled under the parent turn that activated them
|
|
11009
|
+
* — a sub-agent invoked on parent turn 5 contributes `"5-1"`, `"5-2"`, …, and a
|
|
11010
|
+
* nested sub-agent on `"5-2"` contributes `"5-2-1"`, …. See
|
|
11011
|
+
* `forwardSubAgent`.
|
|
11004
11012
|
*/
|
|
11005
11013
|
turnIndex: string;
|
|
11006
11014
|
/** ISO timestamp captured just before the LLM call. */
|
package/dist/chat-driver.cjs
CHANGED
|
@@ -5300,14 +5300,14 @@ var DEBUG_LOG_README = [
|
|
|
5300
5300
|
"kind:'message' \u2014 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 \u2014 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 \u2014 cache reads a fraction of uncached input, cache writes a premium, output highest \u2014 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 \u2014 and any tool calls it carries \u2014 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` \u2014 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 \u2014 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.",
|
|
5301
5301
|
"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 \u203A 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 \u2014 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.",
|
|
5302
5302
|
"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.",
|
|
5303
|
-
"Sub-agent messages appear inline. When a tool delegates to a sub-agent (via `requestSubAgent`), the sub-agent's whole conversation \u2014 its own assistant/tool messages, each with their own `content`/`thinking`/`toolCalls`/`toolResult` and per-message `model`/`providerName`/`inputTokens`/`outputTokens`/`cacheReadTokens`/`cacheWriteTokens`/`cost` \u2014 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, \u2026), `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> \u203A <sub-agent>\"` breadcrumb (composing when nested, e.g. `\"UI Builder \u203A Planner \u203A Grounding\"`). The sub-agent's per-LLM-call snapshots also surface as kind:'turn' entries with
|
|
5304
|
-
"kind:'turn' \u2014 one LLM call. `turnIndex` is a string: a top-level turn is the bare counter ('0', '1', \u2026); a sub-agent's turns are
|
|
5303
|
+
"Sub-agent messages appear inline. When a tool delegates to a sub-agent (via `requestSubAgent`), the sub-agent's whole conversation \u2014 its own assistant/tool messages, each with their own `content`/`thinking`/`toolCalls`/`toolResult` and per-message `model`/`providerName`/`inputTokens`/`outputTokens`/`cacheReadTokens`/`cacheWriteTokens`/`cost` \u2014 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, \u2026), `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> \u203A <sub-agent>\"` breadcrumb (composing when nested, e.g. `\"UI Builder \u203A Planner \u203A 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.",
|
|
5304
|
+
"kind:'turn' \u2014 one LLM call. `turnIndex` is a string: a top-level turn is the bare counter ('0', '1', \u2026); a sub-agent's turns are numbered under the parent turn that activated them ('3-1', '3-2', \u2026, and a nested sub-agent contributes '3-2-1', \u2026), and `agentName` names the agent that ran the turn. `systemPrompt` and `toolNames` are what the model saw. A systemPrompt of '<repeated \u2014 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.",
|
|
5305
5305
|
"kind:'turn'.`model`/`providerName`/`provider` \u2014 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 \u2014 a flow that plans on a high tier and executes on a low one \u2014 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.",
|
|
5306
5306
|
"kind:'turn'.`usage` \u2014 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 \u2014 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.",
|
|
5307
5307
|
"kind:'turn'.`agentSnapshot` \u2014 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.",
|
|
5308
5308
|
"kind:'event' \u2014 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'.",
|
|
5309
5309
|
"Each 'event' also has an `importance`: 'high' (failures/limits \u2014 turn.error, tool.failed, subagent.failed, file.read-failed, suggestions.failed, context.threshold-crossed), 'normal' (session flow \u2014 connects, turns, retries, handoffs, agent/provider changes, interactions, sub-agent start/complete), or 'low' (skippable UI/bookkeeping noise \u2014 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 \u2014 read them together to see how many attempts were made before bailing. 'message' and 'turn' entries carry no importance \u2014 they are the substance, always read them.",
|
|
5310
|
-
"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\u2194loading), turn.start/turn.end (turn boundary; turn.end carries durationMs), turn.retry (a recoverable in-turn retry \u2014 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 \u2014 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 \u2014 detail.nudge of detail.maxNudges, the note stored with driverNote completion-nudge \u2014 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 \u2014 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 \u2014 real earlier this activation but retired by the current state or hidden behind an open exclusive fold \u2014 and hallucinatedTools \u2014 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 \u2014 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 \u2014 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 \u2014 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 \u2014 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 \u2014 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; 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 \u2014 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 \u2014 see its own paragraph below), provider.selected (the resolved provider for the upcoming turns \u2014 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 \u2014 explain quiet gaps; note that when a sub-agent opens a widget, detail.agent \u2014 and the agentName on the interaction message \u2014 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 \u2014 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) \u2014 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 \u2014 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) \u2014 which then carries detail.resolvedItself: true instead, as the interaction message does \u2014 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 \u2014 the framing and those choice texts \u2014 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 \u2014 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 \u2014 detail.claimant + reason), autopilot.* (the autopilot, a decorator that answers interactions on behalf of the user \u2014 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 \u2014 a gate whose controller said it was asking, such as a failed build the autopilot may not cancel \u2014 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 \u2014 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 \u2014 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 \u2014 stale when a pause, a resume, a new turn or the end of its flow came before the answer landed, which then went nowhere \u2014 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 \u2014 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 \u2014 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 \u2014 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 \u2014 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 \u2014 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.",
|
|
5310
|
+
"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\u2194loading), turn.start/turn.end (turn boundary; turn.end carries durationMs), turn.retry (a recoverable in-turn retry \u2014 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 \u2014 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 \u2014 detail.nudge of detail.maxNudges, the note stored with driverNote completion-nudge \u2014 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 \u2014 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 \u2014 real earlier this activation but retired by the current state or hidden behind an open exclusive fold \u2014 and hallucinatedTools \u2014 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 \u2014 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 \u2014 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 \u2014 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 \u2014 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 \u2014 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 \u2014 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 \u2014 see its own paragraph below), provider.selected (the resolved provider for the upcoming turns \u2014 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 \u2014 explain quiet gaps; note that when a sub-agent opens a widget, detail.agent \u2014 and the agentName on the interaction message \u2014 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 \u2014 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) \u2014 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 \u2014 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) \u2014 which then carries detail.resolvedItself: true instead, as the interaction message does \u2014 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 \u2014 the framing and those choice texts \u2014 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 \u2014 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 \u2014 detail.claimant + reason), autopilot.* (the autopilot, a decorator that answers interactions on behalf of the user \u2014 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 \u2014 a gate whose controller said it was asking, such as a failed build the autopilot may not cancel \u2014 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 \u2014 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 \u2014 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 \u2014 stale when a pause, a resume, a new turn or the end of its flow came before the answer landed, which then went nowhere \u2014 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 \u2014 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 \u2014 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 \u2014 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 \u2014 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 \u2014 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.",
|
|
5311
5311
|
"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` \u2014 a `\"<parent> \u203A <sub-agent>\"` breadcrumb that composes when nested (e.g. `\"UI Builder \u203A Planner \u203A Grounding\"`) \u2014 and interleaved by their original timestamps within the subagent.started\u2192completed/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 \u2014 read its hoisted messages for model/tokens/cost and turn-by-turn activity, and the bracketing subagent.* events for the run's span.",
|
|
5312
5312
|
"`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 \u2014 sessionCostUsd, sessionTokensConsumed, and the four-bucket sessionUsage lifted to the top of this log), activeDebugSnapshot (the active agent's `getDebugSnapshot()` taken fresh at export \u2014 reflects state NOW, which may have advanced beyond the last turn's agentSnapshot), debug (optional host-supplied debug state), host, and the export timestamp.",
|
|
5313
5313
|
"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\u2019s prompt again in the next turn\u2019s and is expected to dwarf the context size \u2014 that is not double-counting.",
|
|
@@ -6649,7 +6649,12 @@ var IdleClock = class {
|
|
|
6649
6649
|
// src/state/decision-surface.ts
|
|
6650
6650
|
var SELECT_ACTION = "select";
|
|
6651
6651
|
var REPLY_ACTION = "reply";
|
|
6652
|
-
var normalise = (option) => typeof option === "string" ? { id: option, label: option } : {
|
|
6652
|
+
var normalise = (option) => typeof option === "string" ? { id: option, label: option } : {
|
|
6653
|
+
id: option.id ?? option.label,
|
|
6654
|
+
label: option.label,
|
|
6655
|
+
hint: option.hint,
|
|
6656
|
+
unavailable: option.unavailable
|
|
6657
|
+
};
|
|
6653
6658
|
var GENERIC_UNAVAILABLE = "not available in this state";
|
|
6654
6659
|
function unavailableReason(guard, ...args) {
|
|
6655
6660
|
if (!guard) return void 0;
|
|
@@ -6691,6 +6696,7 @@ function buildDecisionSurface(spec) {
|
|
|
6691
6696
|
return {
|
|
6692
6697
|
name: o.id,
|
|
6693
6698
|
label: o.label,
|
|
6699
|
+
...o.hint !== void 0 ? { hint: o.hint } : {},
|
|
6694
6700
|
finishes: true,
|
|
6695
6701
|
enabled: unavailable === void 0,
|
|
6696
6702
|
...unavailable !== void 0 ? { unavailable } : {}
|
|
@@ -8059,14 +8065,6 @@ var TurnRecorder = class {
|
|
|
8059
8065
|
this.buffer = [];
|
|
8060
8066
|
/** Monotonic counter that survives agent swaps — useful for cross-referencing with history. */
|
|
8061
8067
|
this.turnIndex = 0;
|
|
8062
|
-
/**
|
|
8063
|
-
* Sub-agents started so far per parent turn — the source of each sub-agent's number in its
|
|
8064
|
-
* forwarded labels. Left unbounded on purpose: it holds one small entry per parent turn that
|
|
8065
|
-
* started a sub-agent, for the driver's lifetime, which is far cheaper than the snapshots
|
|
8066
|
-
* themselves. Pruning to the current turn would risk reusing a number if a late sub-agent
|
|
8067
|
-
* began after the parent had moved on.
|
|
8068
|
-
*/
|
|
8069
|
-
this.subAgentsByTurn = /* @__PURE__ */ new Map();
|
|
8070
8068
|
/**
|
|
8071
8069
|
* `turn` + `message` diagnostic entries harvested from an out-of-band source. `event` entries
|
|
8072
8070
|
* are NOT kept here — they are folded into the session's meta-event registry so they inherit
|
|
@@ -8130,48 +8128,32 @@ var TurnRecorder = class {
|
|
|
8130
8128
|
this.trim();
|
|
8131
8129
|
return snapshot;
|
|
8132
8130
|
}
|
|
8133
|
-
/**
|
|
8134
|
-
* Claim the next sub-agent slot under the parent turn that is activating it. Call this
|
|
8135
|
-
* synchronously when the sub-agent *starts* (not when it finishes): parallel sub-agents finish
|
|
8136
|
-
* in any order, so numbering at start keeps the numbers in the order of the `subagent.started`
|
|
8137
|
-
* events. Pass the slot to `forwardSubAgent` once the child has run.
|
|
8138
|
-
*
|
|
8139
|
-
* The activating parent turn = the most recent snapshot this driver recorded before entering
|
|
8140
|
-
* the tool handler that invoked the sub-agent.
|
|
8141
|
-
*/
|
|
8142
|
-
beginSubAgent() {
|
|
8143
|
-
const parentTurn = Math.max(0, this.turnIndex - 1);
|
|
8144
|
-
const subAgentNo = (this.subAgentsByTurn.get(parentTurn) ?? 0) + 1;
|
|
8145
|
-
this.subAgentsByTurn.set(parentTurn, subAgentNo);
|
|
8146
|
-
return { parentTurn, subAgentNo };
|
|
8147
|
-
}
|
|
8148
8131
|
/**
|
|
8149
8132
|
* Merge a sub-agent's turn snapshots into this driver's buffer so they surface
|
|
8150
8133
|
* as `kind:'turn'` entries in the exported debug log. The child runs as a
|
|
8151
8134
|
* separate, discarded driver, so its snapshots would otherwise be lost. Each is
|
|
8152
|
-
* re-labelled under the
|
|
8153
|
-
* (numeric) turns become `"<parentTurn
|
|
8154
|
-
*
|
|
8155
|
-
*
|
|
8135
|
+
* re-labelled under the parent turn that activated the sub-agent: the child's
|
|
8136
|
+
* own (numeric) turns become `"<parentTurn>-1"`, `"-2"`, … (1-based, in order);
|
|
8137
|
+
* any already-forwarded grand-child labels (strings) have their leading segment
|
|
8138
|
+
* remapped the same way, so nesting composes (`"5-2"` → `"5-2-1"`).
|
|
8156
8139
|
*
|
|
8157
|
-
*
|
|
8158
|
-
* their labels
|
|
8140
|
+
* Note: two sub-agents invoked in the *same* parent turn share the prefix, so
|
|
8141
|
+
* their labels can repeat — `agentName` on each snapshot disambiguates them.
|
|
8159
8142
|
*/
|
|
8160
|
-
forwardSubAgent(childSnapshots
|
|
8143
|
+
forwardSubAgent(childSnapshots) {
|
|
8161
8144
|
if (childSnapshots.length === 0) return;
|
|
8162
|
-
const
|
|
8163
|
-
const prefix = `${parentTurn}-${subAgentNo}`;
|
|
8145
|
+
const parentTurn = Math.max(0, this.turnIndex - 1);
|
|
8164
8146
|
const ownTurnLabel = /* @__PURE__ */ new Map();
|
|
8165
8147
|
let ownPos = 0;
|
|
8166
8148
|
for (const snap of childSnapshots) {
|
|
8167
8149
|
let turnIndex;
|
|
8168
8150
|
if (!snap.turnIndex.includes("-")) {
|
|
8169
8151
|
ownPos += 1;
|
|
8170
|
-
turnIndex = `${
|
|
8152
|
+
turnIndex = `${parentTurn}-${ownPos}`;
|
|
8171
8153
|
ownTurnLabel.set(snap.turnIndex, turnIndex);
|
|
8172
8154
|
} else {
|
|
8173
8155
|
const [lead, ...rest] = snap.turnIndex.split("-");
|
|
8174
|
-
const leadLabel = ownTurnLabel.get(lead) ?? `${
|
|
8156
|
+
const leadLabel = ownTurnLabel.get(lead) ?? `${parentTurn}-${lead}`;
|
|
8175
8157
|
turnIndex = [leadLabel, ...rest].join("-");
|
|
8176
8158
|
}
|
|
8177
8159
|
this.buffer.push({ ...snap, turnIndex });
|
|
@@ -10265,14 +10247,11 @@ var ChatDriver = class _ChatDriver extends EventTarget {
|
|
|
10265
10247
|
`Sub-agent "${name}" not found on agent "${this.activeAgentName}". Available: ${available}`
|
|
10266
10248
|
);
|
|
10267
10249
|
}
|
|
10268
|
-
const { task, historyCap,
|
|
10250
|
+
const { task, historyCap, context, timeoutMs, idleTimeoutMs } = options ?? {};
|
|
10269
10251
|
const idle = isIdleLimit(idleTimeoutMs) ? new IdleClock(idleTimeoutMs) : void 0;
|
|
10270
10252
|
const noteIdle = () => idle?.touch();
|
|
10271
|
-
|
|
10272
|
-
|
|
10273
|
-
const baseHistory = this.history.slice(0, inFlightToolCallsAt(this.history));
|
|
10274
|
-
snapshotHistory = historyCap != null ? applyHistoryCap(baseHistory, historyCap) : [...baseHistory];
|
|
10275
|
-
}
|
|
10253
|
+
const baseHistory = this.history.slice(0, inFlightToolCallsAt(this.history));
|
|
10254
|
+
const snapshotHistory = historyCap != null ? applyHistoryCap(baseHistory, historyCap) : [...baseHistory];
|
|
10276
10255
|
const contextMessages = context ? [{ role: "user", content: `[Sub-agent context]: ${JSON.stringify(context)}` }] : [];
|
|
10277
10256
|
const effectivePrimer = [
|
|
10278
10257
|
...snapshotHistory,
|
|
@@ -10280,7 +10259,6 @@ var ChatDriver = class _ChatDriver extends EventTarget {
|
|
|
10280
10259
|
...subConfig.primerHistory ?? []
|
|
10281
10260
|
];
|
|
10282
10261
|
const invocationId = crypto.randomUUID();
|
|
10283
|
-
const subAgentSlot = this.turnRecorder.beginSubAgent();
|
|
10284
10262
|
const childSessionKey = `${this.sessionKey}::sub:${invocationId}`;
|
|
10285
10263
|
const child = new _ChatDriver(this.providerRegistry, {
|
|
10286
10264
|
sessionKey: childSessionKey,
|
|
@@ -10374,7 +10352,7 @@ var ChatDriver = class _ChatDriver extends EventTarget {
|
|
|
10374
10352
|
child.removeEventListener("sub-agent-history-updated", noteIdle);
|
|
10375
10353
|
child.dispose();
|
|
10376
10354
|
this.dispatchEvent(new CustomEvent("sub-agent-stop", { detail: lifecycleDetail }));
|
|
10377
|
-
this.turnRecorder.forwardSubAgent(child.getTurnSnapshots()
|
|
10355
|
+
this.turnRecorder.forwardSubAgent(child.getTurnSnapshots());
|
|
10378
10356
|
const parentName = this.activeAgentName ?? "?";
|
|
10379
10357
|
const harvested = getMetaEvents(childSessionKey).filter((e) => HARVESTED_SUBAGENT_EVENTS.has(e.type)).map((e) => {
|
|
10380
10358
|
const existing = e.detail?.subAgent;
|
|
@@ -12914,7 +12892,10 @@ function renderActions(actions, options = {}) {
|
|
|
12914
12892
|
lines.push(` reply({text}) \u2014 answer in your own words${unavailable}`);
|
|
12915
12893
|
} else {
|
|
12916
12894
|
numbering.push(action.name);
|
|
12917
|
-
|
|
12895
|
+
const hint = action.hint?.trim();
|
|
12896
|
+
lines.push(
|
|
12897
|
+
` [${numbering.length}] "${action.label ?? action.name}"${hint ? ` \u2014 ${hint}` : ""}${unavailable}`
|
|
12898
|
+
);
|
|
12918
12899
|
}
|
|
12919
12900
|
}
|
|
12920
12901
|
const allSettle = actions.every((a) => a.description === void 0);
|
|
@@ -13049,6 +13030,7 @@ var describeAction = (action, n) => ({
|
|
|
13049
13030
|
...n !== void 0 ? { n } : {},
|
|
13050
13031
|
name: action.name,
|
|
13051
13032
|
...action.label !== void 0 ? { label: action.label } : {},
|
|
13033
|
+
...action.hint !== void 0 ? { hint: action.hint } : {},
|
|
13052
13034
|
...action.description !== void 0 ? { description: action.description } : {},
|
|
13053
13035
|
enabled: action.enabled,
|
|
13054
13036
|
...action.unavailable !== void 0 ? { unavailable: action.unavailable } : {},
|