@genesislcap/ai-assistant 15.92.1 → 15.93.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.
@@ -4961,7 +4961,7 @@ var DEBUG_LOG_README = [
4961
4961
  "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.",
4962
4962
  "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'.",
4963
4963
  "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.",
4964
- "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.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; 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; 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.",
4964
+ "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.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; 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.",
4965
4965
  "Sub-agent meta events: a sub-agent's own turn.retry/turn.error/tool.failed/tool.unresolved 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.",
4966
4966
  "`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.",
4967
4967
  "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.",
@@ -6227,6 +6227,53 @@ var FoldController = class {
6227
6227
  }
6228
6228
  };
6229
6229
 
6230
+ // src/components/chat-driver/idle-clock.ts
6231
+ var MAX_TIMER_MS = 2147483647;
6232
+ var isIdleLimit = (ms) => typeof ms === "number" && Number.isFinite(ms) && ms > 0 && ms <= MAX_TIMER_MS;
6233
+ var IdleClock = class {
6234
+ constructor(ms) {
6235
+ this.ms = ms;
6236
+ /** True once the clock ran out (as opposed to being stopped). */
6237
+ this.expired = false;
6238
+ this.stopped = false;
6239
+ this.parked = 0;
6240
+ }
6241
+ /** Starts the clock; `onExpire` runs once if it ever runs out. */
6242
+ start(onExpire) {
6243
+ this.onExpire = onExpire;
6244
+ this.touch();
6245
+ }
6246
+ /** Progress was made: restart the clock in full (a no-op before `start`, after `stop`, or parked). */
6247
+ touch() {
6248
+ if (this.handle) clearTimeout(this.handle);
6249
+ this.handle = void 0;
6250
+ if (!this.onExpire || this.stopped || this.parked > 0) return;
6251
+ this.handle = setTimeout(() => {
6252
+ this.expired = true;
6253
+ this.stop();
6254
+ this.onExpire?.();
6255
+ }, this.ms);
6256
+ }
6257
+ /**
6258
+ * Pauses the clock until `waiting` settles, then restarts it in full. Returns a promise that
6259
+ * settles the same way `waiting` does.
6260
+ */
6261
+ parkWhile(waiting) {
6262
+ this.parked += 1;
6263
+ this.touch();
6264
+ return waiting.finally(() => {
6265
+ this.parked -= 1;
6266
+ this.touch();
6267
+ });
6268
+ }
6269
+ /** Clears the timer for good, so a late `touch` (an aborted run settling) cannot re-arm it. */
6270
+ stop() {
6271
+ this.stopped = true;
6272
+ if (this.handle) clearTimeout(this.handle);
6273
+ this.handle = void 0;
6274
+ }
6275
+ };
6276
+
6230
6277
  // src/state/decision-surface.ts
6231
6278
  var SELECT_ACTION = "select";
6232
6279
  var REPLY_ACTION = "reply";
@@ -9773,7 +9820,9 @@ var ChatDriver = class _ChatDriver extends EventTarget {
9773
9820
  `Sub-agent "${name}" not found on agent "${this.activeAgentName}". Available: ${available}`
9774
9821
  );
9775
9822
  }
9776
- const { task, historyCap, context, timeoutMs } = options ?? {};
9823
+ const { task, historyCap, context, timeoutMs, idleTimeoutMs } = options ?? {};
9824
+ const idle = isIdleLimit(idleTimeoutMs) ? new IdleClock(idleTimeoutMs) : void 0;
9825
+ const noteIdle = () => idle?.touch();
9777
9826
  const baseHistory = this.history.slice(0, inFlightToolCallsAt(this.history));
9778
9827
  const snapshotHistory = historyCap != null ? applyHistoryCap(baseHistory, historyCap) : [...baseHistory];
9779
9828
  const contextMessages = context ? [{ role: "user", content: `[Sub-agent context]: ${JSON.stringify(context)}` }] : [];
@@ -9801,13 +9850,24 @@ var ChatDriver = class _ChatDriver extends EventTarget {
9801
9850
  }
9802
9851
  child.installAgent({ ...subConfig, primerHistory: effectivePrimer });
9803
9852
  child.setHostInteractionRequester(
9804
- (componentName, data, opts, onOpened, ownerPath, onSettled) => this.requestInteraction(componentName, data, opts, onOpened, ownerPath, onSettled),
9853
+ (componentName, data, opts, onOpened, ownerPath, onSettled) => {
9854
+ const settled = this.requestInteraction(
9855
+ componentName,
9856
+ data,
9857
+ opts,
9858
+ onOpened,
9859
+ ownerPath,
9860
+ onSettled
9861
+ );
9862
+ return idle ? idle.parkWhile(settled) : settled;
9863
+ },
9805
9864
  // An outcome goes where its interaction went.
9806
9865
  (interactionId, outcome) => this.recordInteractionOutcome(interactionId, outcome)
9807
9866
  );
9808
9867
  child.hostAIServiceNotice = (code) => this.noticeAIServiceRefusal(code);
9809
9868
  child.capabilityParent = this;
9810
9869
  const forwardTrace = (e) => {
9870
+ noteIdle();
9811
9871
  this.dispatchEvent(
9812
9872
  new CustomEvent("sub-agent-history-updated", {
9813
9873
  detail: { agentName: subConfig.name, history: e.detail }
@@ -9821,6 +9881,7 @@ var ChatDriver = class _ChatDriver extends EventTarget {
9821
9881
  };
9822
9882
  child.addEventListener("history-updated", forwardTrace);
9823
9883
  child.addEventListener("provider-changed", forwardProviderChanged);
9884
+ child.addEventListener("sub-agent-history-updated", noteIdle);
9824
9885
  const chatInputDuringExecution = options?.chatInputDuringExecution;
9825
9886
  const lifecycleDetail = { name, invocationId, chatInputDuringExecution };
9826
9887
  this.dispatchEvent(new CustomEvent("sub-agent-start", { detail: lifecycleDetail }));
@@ -9828,13 +9889,16 @@ var ChatDriver = class _ChatDriver extends EventTarget {
9828
9889
  let timedOut = false;
9829
9890
  const runPromise = child.sendMessage(task ?? "");
9830
9891
  try {
9831
- if (timeoutMs == null) {
9892
+ if (timeoutMs == null && !idle) {
9832
9893
  await runPromise;
9833
9894
  } else {
9834
9895
  let timeoutHandle;
9835
9896
  try {
9836
9897
  const timeoutSignal = new Promise((resolveTimeout) => {
9837
- timeoutHandle = setTimeout(() => resolveTimeout("timeout"), timeoutMs);
9898
+ if (timeoutMs != null) {
9899
+ timeoutHandle = setTimeout(() => resolveTimeout("timeout"), timeoutMs);
9900
+ }
9901
+ idle?.start(() => resolveTimeout("timeout"));
9838
9902
  });
9839
9903
  const winner = await Promise.race([
9840
9904
  runPromise.then(() => "done"),
@@ -9842,11 +9906,15 @@ var ChatDriver = class _ChatDriver extends EventTarget {
9842
9906
  ]);
9843
9907
  if (winner === "timeout") {
9844
9908
  timedOut = true;
9909
+ idle?.stop();
9845
9910
  child.dispose();
9846
- this.interactions.cancelAll(`Sub-agent "${name}" timed out after ${timeoutMs}ms.`);
9911
+ this.interactions.cancelAll(
9912
+ idle?.expired ? `Sub-agent "${name}" made no progress for ${idleTimeoutMs}ms.` : `Sub-agent "${name}" timed out after ${timeoutMs}ms.`
9913
+ );
9847
9914
  await runPromise.catch(() => void 0);
9848
9915
  }
9849
9916
  } finally {
9917
+ idle?.stop();
9850
9918
  if (timeoutHandle) clearTimeout(timeoutHandle);
9851
9919
  }
9852
9920
  }
@@ -9854,6 +9922,7 @@ var ChatDriver = class _ChatDriver extends EventTarget {
9854
9922
  this.lifecycleController.signal.removeEventListener("abort", disposeChild);
9855
9923
  child.removeEventListener("history-updated", forwardTrace);
9856
9924
  child.removeEventListener("provider-changed", forwardProviderChanged);
9925
+ child.removeEventListener("sub-agent-history-updated", noteIdle);
9857
9926
  child.dispose();
9858
9927
  this.dispatchEvent(new CustomEvent("sub-agent-stop", { detail: lifecycleDetail }));
9859
9928
  this.turnRecorder.forwardSubAgent(child.getTurnSnapshots());
@@ -9867,7 +9936,12 @@ var ChatDriver = class _ChatDriver extends EventTarget {
9867
9936
  }
9868
9937
  const trace = child.getHistory();
9869
9938
  if (timedOut) {
9870
- recordMetaEvent(this.sessionKey, "subagent.failed", { agent: name, reason: "timeout" });
9939
+ recordMetaEvent(this.sessionKey, "subagent.failed", {
9940
+ agent: name,
9941
+ reason: "timeout",
9942
+ // Only added for an idle expiry, so the timeline can tell it from the overall cap.
9943
+ ...idle?.expired && { cause: "idle" }
9944
+ });
9871
9945
  return { outcome: { ok: false, reason: "timeout" }, trace };
9872
9946
  }
9873
9947
  const completion = child.getSubAgentCompletion();
@@ -12744,9 +12818,9 @@ var NOT_A_CLAIMANT = HEADLESS_INTERCEPTOR_ID;
12744
12818
  var LINE_CAP_CHARS = 4e3;
12745
12819
  var MAX_EVENTS = 5e3;
12746
12820
  var TURN_POLL_MS = 50;
12747
- var MAX_TIMER_MS = 2147483647;
12821
+ var MAX_TIMER_MS2 = 2147483647;
12748
12822
  var capped = (text) => text.length > LINE_CAP_CHARS ? { text: `${text.slice(0, LINE_CAP_CHARS)}\u2026`, chars: text.length } : { text };
12749
- var timerMs = (ms) => Number.isNaN(Number(ms)) ? 0 : Math.min(Math.max(0, Number(ms)), MAX_TIMER_MS);
12823
+ var timerMs = (ms) => Number.isNaN(Number(ms)) ? 0 : Math.min(Math.max(0, Number(ms)), MAX_TIMER_MS2);
12750
12824
  var messageOf = (e) => e instanceof Error ? e.message : String(e);
12751
12825
  var isAutopilotLike = (value) => {
12752
12826
  const v = value;