@genesislcap/ai-assistant 15.84.2-GENC-1737.1 → 15.84.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (49) hide show
  1. package/dist/ai-assistant.api.json +138 -2144
  2. package/dist/ai-assistant.d.ts +43 -396
  3. package/dist/chat-driver.cjs +210 -724
  4. package/dist/chat-driver.cjs.map +4 -4
  5. package/dist/chat-driver.mjs +209 -724
  6. package/dist/chat-driver.mjs.map +4 -4
  7. package/dist/custom-elements.json +662 -1661
  8. package/dist/dts/components/agent-session/agent-session.d.ts +2 -45
  9. package/dist/dts/components/agent-session/agent-session.d.ts.map +1 -1
  10. package/dist/dts/components/ai-driver/ai-driver.d.ts +1 -57
  11. package/dist/dts/components/ai-driver/ai-driver.d.ts.map +1 -1
  12. package/dist/dts/components/ai-driver/base-driver-decorator.d.ts +1 -12
  13. package/dist/dts/components/ai-driver/base-driver-decorator.d.ts.map +1 -1
  14. package/dist/dts/components/chat-driver/chat-driver.constants.d.ts +8 -0
  15. package/dist/dts/components/chat-driver/chat-driver.constants.d.ts.map +1 -1
  16. package/dist/dts/components/chat-driver/chat-driver.d.ts +15 -67
  17. package/dist/dts/components/chat-driver/chat-driver.d.ts.map +1 -1
  18. package/dist/dts/components/orchestrating-driver/orchestrating-driver.d.ts +22 -112
  19. package/dist/dts/components/orchestrating-driver/orchestrating-driver.d.ts.map +1 -1
  20. package/dist/dts/config/config.d.ts +0 -66
  21. package/dist/dts/config/config.d.ts.map +1 -1
  22. package/dist/dts/main/main.d.ts +0 -3
  23. package/dist/dts/main/main.d.ts.map +1 -1
  24. package/dist/dts/main/main.types.d.ts +0 -6
  25. package/dist/dts/main/main.types.d.ts.map +1 -1
  26. package/dist/dts/react.d.ts +1 -4
  27. package/dist/dts/state/persistence/session-persister.d.ts.map +1 -1
  28. package/dist/dts/state/persistence/session-snapshot.d.ts +1 -33
  29. package/dist/dts/state/persistence/session-snapshot.d.ts.map +1 -1
  30. package/dist/dts/utils/condense-history.d.ts +3 -10
  31. package/dist/dts/utils/condense-history.d.ts.map +1 -1
  32. package/dist/esm/components/agent-session/agent-session.js +7 -114
  33. package/dist/esm/components/ai-driver/ai-driver.js +0 -3
  34. package/dist/esm/components/ai-driver/base-driver-decorator.js +0 -24
  35. package/dist/esm/components/chat-driver/chat-driver.constants.js +8 -0
  36. package/dist/esm/components/chat-driver/chat-driver.js +73 -232
  37. package/dist/esm/components/orchestrating-driver/orchestrating-driver.js +299 -447
  38. package/dist/esm/main/main.js +6 -32
  39. package/dist/esm/main/main.types.js +0 -6
  40. package/dist/esm/state/persistence/session-persister.js +12 -55
  41. package/dist/esm/state/persistence/session-snapshot.js +6 -12
  42. package/dist/esm/utils/condense-history.js +4 -13
  43. package/dist/react.cjs +1 -16
  44. package/dist/react.mjs +1 -16
  45. package/docs/sub_agent.md +1 -1
  46. package/package.json +17 -17
  47. package/dist/dts/components/orchestrating-driver/hand-off.d.ts +0 -14
  48. package/dist/dts/components/orchestrating-driver/hand-off.d.ts.map +0 -1
  49. package/dist/esm/components/orchestrating-driver/hand-off.js +0 -53
@@ -25,9 +25,6 @@ import type { CondensePolicy } from '@genesislcap/foundation-ai';
25
25
  import { Container } from '@genesislcap/web-core';
26
26
  import { ElementStyles } from '@genesislcap/web-core';
27
27
  import { GenesisElement } from '@genesislcap/web-core';
28
- import type { HandOffCompletion } from '@genesislcap/foundation-ai';
29
- import type { HandOffRequest } from '@genesislcap/foundation-ai';
30
- import type { HandOffResult } from '@genesislcap/foundation-ai';
31
28
  import { InteractionEdit } from '@genesislcap/foundation-ai';
32
29
  import type { InteractionRequestOptions } from '@genesislcap/foundation-ai';
33
30
  import type { InteractionResult } from '@genesislcap/foundation-ai';
@@ -534,8 +531,8 @@ export { AgentPickerMode }
534
531
  * and the `onActivate` / `onDeactivate` lifecycle around a swap. Either driver can own one.
535
532
  *
536
533
  * Knows nothing about routing, tool surfaces or transcripts — whether an agent is terminal, the
537
- * hand-off stack, the divider in history all stay with the orchestrator, which is the only thing
538
- * with agents to route between.
534
+ * continuation tool, the handoff marker in history all stay with the orchestrator, which is the
535
+ * only thing with agents to route between.
539
536
  *
540
537
  * @beta
541
538
  */
@@ -567,17 +564,6 @@ export declare class AgentSession {
567
564
  private restoredStates;
568
565
  /** The tail of the activation queue — see {@link AgentSession.activate}. */
569
566
  private activation;
570
- /**
571
- * Callers waiting in a hand-off (GENC-1737), oldest first: still live, so never deactivated by
572
- * the hand-off, and resumed without `onActivate`. Empty after a reload, when a caller has no live
573
- * state and is activated again from its saved state instead.
574
- */
575
- private suspended;
576
- /**
577
- * The `data` of the hand-off that activated each agent (GENC-1737), for its tool handlers: kept
578
- * while it is active or waits as a caller, and dropped when its activation ends.
579
- */
580
- private handOffData;
581
567
  constructor(deps: AgentSessionDeps);
582
568
  /** The active agent, or `undefined` before the first activation and after a release. */
583
569
  getActive(): AgentConfig | undefined;
@@ -603,34 +589,6 @@ export declare class AgentSession {
603
589
  primeRestoredStates(snapshots: Record<string, unknown>): void;
604
590
  /** Whether a restored snapshot is waiting for this agent's next activation. */
605
591
  hasRestoredState(agentName: string): boolean;
606
- /** The `data` of the hand-off that activated `agentName`, if one did and carried any. */
607
- getHandOffData(agentName: string): unknown;
608
- /** Record the `data` a hand-off activated `agentName` with, or restore it; `undefined` drops it. */
609
- setHandOffData(agentName: string, data: unknown): void;
610
- /** The callers waiting in a hand-off whose state is live, oldest first. */
611
- getSuspended(): readonly AgentConfig[];
612
- /**
613
- * Make `target` active for a hand-off (GENC-1737), holding the flow lock whatever kind of agent
614
- * it is, since a waiting caller depends on it. With `suspendCaller` the active agent waits:
615
- * it is not deactivated and keeps its state. Without it the active agent is deactivated as on
616
- * any swap: a one-way hand-off from a target, whose waiting caller then waits for the new
617
- * target. Queued with {@link AgentSession.activate}.
618
- */
619
- handOff(target: AgentConfig, options: {
620
- suspendCaller: boolean;
621
- }): Promise<AgentTransition>;
622
- /**
623
- * Make a waiting caller active again when its hand-off ends (GENC-1737). One whose state is live
624
- * resumes without `onActivate`, since it was never deactivated; after a reload it is activated
625
- * from its saved state like any other agent. `lock` keeps the flow lock on it: it held it before,
626
- * or another caller is still waiting further down.
627
- */
628
- resume(caller: AgentConfig, lock: boolean): Promise<AgentTransition>;
629
- /**
630
- * Deactivate the callers left waiting by hand-offs that ended without a hand-back, newest first,
631
- * when no teardown follows to do it (GENC-1737).
632
- */
633
- endSuspended(): Promise<void>;
634
592
  /**
635
593
  * Make `agent` active, firing the lifecycle hooks around the swap: outgoing `onDeactivate`
636
594
  * first, then incoming `onActivate`. Both are awaited so heavy activation work (a machine
@@ -647,10 +605,6 @@ export declare class AgentSession {
647
605
  * the flow owner outside a turn, where a send can land mid-activation.
648
606
  */
649
607
  activate(agent: AgentConfig): Promise<AgentTransition>;
650
- /**
651
- * `lock` takes the flow lock whatever kind of agent it is, and `suspendPrevious` leaves the
652
- * outgoing agent waiting instead of deactivating it, as a hand-off does (GENC-1737).
653
- */
654
608
  private activateNow;
655
609
  /**
656
610
  * Release the active agent: fire `onDeactivate` and drop the flow lock.
@@ -788,12 +742,6 @@ export declare const AiAssistantEvent: {
788
742
  readonly SessionCleared: "session-cleared";
789
743
  /** Header pressed in `popout-mode="expand"` (drag-to-popout hosts). `detail`: `ChatHeaderMouseDownDetail`. */
790
744
  readonly ChatHeaderMouseDown: "chat-header-mousedown";
791
- /** An agent's hand-off started (GENC-1737). `detail`: `HandOffFrame`. */
792
- readonly HandOffStarted: "handoff-started";
793
- /** A hand-off ended and its caller is active again. `detail`: `HandOffFrame`, with `outcome`. */
794
- readonly HandOffReturned: "handoff-returned";
795
- /** A hand-off ended with no hand-back. `detail`: `HandOffFrame`, with `outcome`. */
796
- readonly HandOffUnwound: "handoff-unwound";
797
745
  };
798
746
 
799
747
  /**
@@ -1085,56 +1033,6 @@ export declare interface AiDriver extends EventTarget {
1085
1033
  restored: number;
1086
1034
  awaitingReactivation: number;
1087
1035
  };
1088
- /**
1089
- * The hand-offs in progress, oldest first, to save with the session (GENC-1737). Copies: changing
1090
- * them changes nothing.
1091
- *
1092
- * @beta
1093
- */
1094
- getHandOffStack?(): HandOffFrame[];
1095
- /**
1096
- * Restore saved hand-offs, before the condense policies, against the agents configured now and
1097
- * the saved agent states. A frame whose caller has gone, or whose stateful caller has no saved
1098
- * state (`interrupted` drops them all), is unwound with `handoff-unwound`. When the top frame's
1099
- * target had finished, or has gone, its caller is due to resume: `resume` names it and the note
1100
- * its resumed turn needs, and {@link AiDriver.resumeRestoredFlow} hands back.
1101
- *
1102
- * @beta
1103
- */
1104
- restoreHandOffStack?(saved: unknown, savedStates: Record<string, unknown>, interrupted: boolean): {
1105
- resume?: {
1106
- agent: string;
1107
- note: string;
1108
- };
1109
- };
1110
- /**
1111
- * End every hand-off without a hand-back, newest first: the chat was cleared, or the agents
1112
- * changed. Each raises `handoff-unwound`; on Clear a waiting caller's `onHandOffReturn` is told.
1113
- *
1114
- * @beta
1115
- */
1116
- unwindHandOffs?(kind: Extract<HandOffOutcomeKind, 'cleared' | 'state-lost'>): Promise<void>;
1117
- /**
1118
- * The saved state of each caller waiting in a hand-off whose state is live, by name, from its
1119
- * `serialize`. Saved with the active agent's, so a reload can resume the caller.
1120
- *
1121
- * @beta
1122
- */
1123
- serializeWaitingCallers?(): Record<string, unknown>;
1124
- /**
1125
- * The `data` each hand-off target was activated with, by name, for the agents a reload resumes:
1126
- * the flow owner and the callers waiting in a hand-off. See the tool context's `handOffData`.
1127
- *
1128
- * @beta
1129
- */
1130
- getHandOffData?(): Record<string, unknown>;
1131
- /**
1132
- * Restore what {@link AiDriver.getHandOffData} saved, before the hand-off stack. Nothing comes
1133
- * back from a frozen (`interrupted`) session, whose flow does not resume.
1134
- *
1135
- * @beta
1136
- */
1137
- restoreHandOffData?(saved: unknown, interrupted: boolean): void;
1138
1036
  /**
1139
1037
  * The live `AgentConfig` currently active in the driver — the instance whose
1140
1038
  * `onActivate` ran, so its `serialize`/`getDebugSnapshot` closures hold live
@@ -1425,12 +1323,6 @@ export declare interface AiDriverEventMap {
1425
1323
  'agent-released': CustomEvent<AgentConfig>;
1426
1324
  /** The flow-owner lock changed. Detail: the new owner's name, or `null` when cleared. */
1427
1325
  'flow-owner-changed': CustomEvent<string | null>;
1428
- /** A hand-off started: its target is now active (GENC-1737). */
1429
- 'handoff-started': CustomEvent<HandOffFrame>;
1430
- /** A hand-off ended and its caller is active again; `detail.outcome` says how. */
1431
- 'handoff-returned': CustomEvent<HandOffFrame>;
1432
- /** A hand-off ended with no hand-back: cleared, or found unresumable. */
1433
- 'handoff-unwound': CustomEvent<HandOffFrame>;
1434
1326
  /** Routing started (the classifier is about to run). Orchestrator only. */
1435
1327
  'orchestrating-start': CustomEvent<undefined>;
1436
1328
  /** Routing finished and an agent is installed. Orchestrator only. */
@@ -2480,28 +2372,6 @@ declare interface BaseAgentConfig {
2480
2372
  * @beta
2481
2373
  */
2482
2374
  onDeactivate?: (ctx: AgentLifecycleContext) => void | Promise<void>;
2483
- /**
2484
- * Fires on the caller when its `handOff` takes effect, after its turn: it now waits, still active
2485
- * in spirit, for `frame.target` to finish. Awaited before the target runs. GENC-1737.
2486
- *
2487
- * @beta
2488
- */
2489
- onHandOffStart?: (frame: HandOffFrame) => void | Promise<void>;
2490
- /**
2491
- * Fires on the caller when a hand-off it made ends, before its next model call, so its own state
2492
- * can move on. `outcome.kind` says how it ended. Not fired for `state-lost`, whose caller cannot
2493
- * resume. GENC-1737.
2494
- *
2495
- * @beta
2496
- */
2497
- onHandOffReturn?: (outcome: HandOffOutcome, frame: HandOffFrame) => void | Promise<void>;
2498
- /**
2499
- * The agents this one may hand off to. Left out, any other agent. A `handOff` to one not listed
2500
- * is refused with `not-allowed`. GENC-1737.
2501
- *
2502
- * @beta
2503
- */
2504
- handOffTargets?: string[];
2505
2375
  /**
2506
2376
  * Returns an agent-supplied debug payload for the export log. Called once per
2507
2377
  * LLM call by the driver (alongside the resolved prompt and tool list) and
@@ -2664,17 +2534,6 @@ export declare abstract class BaseDriverDecorator<TInner extends AiDriver = AiDr
2664
2534
  restored: number;
2665
2535
  awaitingReactivation: number;
2666
2536
  };
2667
- getHandOffStack(): HandOffFrame[];
2668
- restoreHandOffStack(saved: unknown, savedStates: Record<string, unknown>, interrupted: boolean): {
2669
- resume?: {
2670
- agent: string;
2671
- note: string;
2672
- };
2673
- };
2674
- unwindHandOffs(kind: Extract<HandOffOutcomeKind, 'cleared' | 'state-lost'>): Promise<void>;
2675
- serializeWaitingCallers(): Record<string, unknown>;
2676
- getHandOffData(): Record<string, unknown>;
2677
- restoreHandOffData(saved: unknown, interrupted: boolean): void;
2678
2537
  getActiveAgent(): AgentConfig | undefined;
2679
2538
  setPinnedAgent(name: string | null): void;
2680
2539
  setFlowOwner(name: string | null): void;
@@ -2942,8 +2801,9 @@ export declare class ChatDriver extends EventTarget implements AiDriver {
2942
2801
  /** Sub-agents declared on the active agent config, keyed by name. */
2943
2802
  private subAgentsMap;
2944
2803
  /**
2945
- * Set by `completeSubAgent` inside a sub-agent tool handler. Checked after tool
2946
- * results are appended, so the turn ends without another model call.
2804
+ * Set by `completeSubAgent` inside a sub-agent tool handler. Checked at the
2805
+ * same point in the loop as `REQUEST_CONTINUATION_TOOL` — after tool results
2806
+ * are appended — so the exit path mirrors the system-call pattern.
2947
2807
  * `undefined` means the loop has not been stopped early.
2948
2808
  */
2949
2809
  private subAgentCompletion;
@@ -2975,23 +2835,6 @@ export declare class ChatDriver extends EventTarget implements AiDriver {
2975
2835
  * doesn't leak forward.
2976
2836
  */
2977
2837
  private agentReleaseRequested;
2978
- /** A `handOff` this call accepted, for the orchestrator to act on after it (GENC-1737). */
2979
- private handOffRequested?;
2980
- /** What `completeHandOff` handed back this call, beside the release it also requests. */
2981
- private handOffCompletion?;
2982
- /** See {@link ChatDriver.setHandOffCheck}. */
2983
- private checkHandOff?;
2984
- /**
2985
- * The `agentEnd` activation of each caller waiting in a hand-off, by agent name, with the phase
2986
- * epoch it was suspended at (GENC-1737). A waiting caller is suspended, not ended, so neither its
2987
- * `agentEnd` payloads nor its `phaseEnd` ones (to another agent's `endPhase()`) collapse while the
2988
- * target runs; when it is installed again its entries move to the new activation and, while
2989
- * their phase had not ended, to the current epoch. A caller restored from a saved session gets
2990
- * an activation placeholder below zero, which no live activation uses.
2991
- */
2992
- private readonly suspendedActivations;
2993
- /** The last placeholder handed out for a restored caller; see `suspendedActivations`. */
2994
- private restoredSuspensionSeq;
2995
2838
  /**
2996
2839
  * Per-turn snapshots, forwarded sub-agent snapshots, and harvested external diagnostics —
2997
2840
  * everything the exported debug log draws from this driver.
@@ -3137,8 +2980,8 @@ export declare class ChatDriver extends EventTarget implements AiDriver {
3137
2980
  * The stateful-agent contract for this driver: active agent, user pin, flow lock, restored
3138
2981
  * state, and the `onActivate` / `onDeactivate` hooks (§7.1).
3139
2982
  *
3140
- * **Public because `OrchestratingDriver` reaches through to it.** The orchestrator builds a
3141
- * config before installing it (the fallback's prompt), so it cannot route through
2983
+ * **Public because `OrchestratingDriver` reaches through to it.** The orchestrator decorates a
2984
+ * config before installing it (the cross-agent continuation tool), so it cannot route through
3142
2985
  * {@link ChatDriver.activateAgent} and must drive the session itself — and one shared session is
3143
2986
  * the point: two would let `getActiveAgent()` disagree between the outer and inner driver.
3144
2987
  * `@internal` rather than private so that reach is legal without six delegating one-liners.
@@ -3380,13 +3223,17 @@ export declare class ChatDriver extends EventTarget implements AiDriver {
3380
3223
  * does not show it twice. Marks it shown otherwise. Only the driver the user sees keeps count.
3381
3224
  */
3382
3225
  private aiServiceSentenceShown;
3383
- /** Whether a sub-agent hit a wall this turn that stops this driver too. */
3226
+ /**
3227
+ * Whether a sub-agent hit a wall this turn that stops this driver too. A handoff goes on past an
3228
+ * AI-service wall: the next agent may use another vendor, and if it uses this one its own call
3229
+ * meets the wall and says so.
3230
+ */
3384
3231
  private subAgentWallThisTurn;
3385
3232
  /**
3386
3233
  * Ends the turn when a sub-agent hit a wall this turn that stops this driver too: the provider
3387
3234
  * refusing the account, the AI service (GENC-1611), or the budget. Checked before each model call,
3388
- * and again right after a tool batch, before the iteration cap can report the turn as something
3389
- * else.
3235
+ * and again right after a tool batch, before a handoff or the iteration cap can report the turn as
3236
+ * something else.
3390
3237
  */
3391
3238
  private endTurnOnSubAgentWall;
3392
3239
  /** The typed failure reason on a loop result, or `undefined` for a clean turn / handoff. */
@@ -3559,46 +3406,6 @@ export declare class ChatDriver extends EventTarget implements AiDriver {
3559
3406
  * Consumed by the orchestrator to trigger the auto-pin release path.
3560
3407
  */
3561
3408
  getAgentReleaseRequested(): boolean;
3562
- /**
3563
- * Offer `handOff` and `completeHandOff` to tool handlers, checking each `handOff` with `check`
3564
- * (GENC-1737). Set by `OrchestratingDriver`, which knows the agents and the hand-off stack and acts
3565
- * on the request after the call; a bare `ChatDriver` has no other agent to hand to.
3566
- *
3567
- * @internal
3568
- */
3569
- setHandOffCheck(check: (request: HandOffRequest, caller: string | undefined) => HandOffResult): void;
3570
- /** The `handOff` the most recent call accepted, if any (GENC-1737). */
3571
- getHandOffRequest(): HandOffRequest | undefined;
3572
- /** What `completeHandOff` handed back in the most recent call, if it was called. */
3573
- getHandOffCompletion(): HandOffCompletion | undefined;
3574
- /**
3575
- * A handler's `handOff`: refused once this call has handed off or released, or when `data` is
3576
- * not JSON, and otherwise checked by the orchestrator. `data` is kept as a JSON copy, since it is
3577
- * saved with the session and the handler may change its own object afterwards.
3578
- */
3579
- private requestHandOff;
3580
- /**
3581
- * Suspend the active agent's activation for a hand-off it made (GENC-1737): installing the target
3582
- * advances the `agentEnd` clock as any swap does, but this caller's payloads stay live.
3583
- */
3584
- suspendActivation(agentName: string): void;
3585
- /**
3586
- * Suspend restored callers before their condense policies are restored, so entries still live
3587
- * at save time stay live instead of waiting for "the next activation", which is the target's.
3588
- */
3589
- suspendRestoredActivations(agentNames: readonly string[]): void;
3590
- /** End every suspension: the hand-offs were unwound, so their callers' activations are over. */
3591
- endSuspendedActivations(): void;
3592
- /**
3593
- * A caller installed again takes its suspended entries into the activation it resumes in, and
3594
- * the ones whose phase had not ended into the current phase epoch.
3595
- */
3596
- private resumeSuspendedActivation;
3597
- /**
3598
- * The suspended activations, each with the phase epoch it was suspended at, for the `agentEnd`
3599
- * and `phaseEnd` checks and for persistence.
3600
- */
3601
- private suspendedClocks;
3602
3409
  /**
3603
3410
  * Act on a `releaseAgent` call from a tool handler: fire `onDeactivate` and drop the flow lock,
3604
3411
  * so the next turn starts clean and the persister does not serialize a flow that is over.
@@ -4049,7 +3856,7 @@ export declare interface ChatDriverConfig {
4049
3856
  * Leave acting on `releaseAgent` to the owner of this driver.
4050
3857
  *
4051
3858
  * Set by `OrchestratingDriver` for its inner driver, which performs the release itself after the
4052
- * call, because a release may hand back to a waiting caller and it reads the flag to know. Both drivers share
3859
+ * turn, because a release ends its handoff loop and it reads the flag to know. Both drivers share
4053
3860
  * one `AgentSession`, and releasing here first would clear the flag before the orchestrator saw
4054
3861
  * it. The host-facing `agent-released` / `agent-changed` / `flow-owner-changed` events fire from
4055
3862
  * the session's transition either way (GENC-1485).
@@ -4889,9 +4696,6 @@ export declare function formatBlockedReason(budget?: Partial<Extract<ChatDriverR
4889
4696
  *
4890
4697
  * @fires chat-header-mousedown - Fired when the user presses the chat header in `popout-mode="expand"` (for drag-to-popout hosts). Bubbles and composed. detail: `ChatHeaderMouseDownDetail`
4891
4698
  * @fires session-cleared - Fired after the session is wiped (the lifecycle menu's Clear). The payload is captured before teardown so the host can clean up any external state the active agent was working on. Bubbles and composed. detail: `SessionClearedDetail`
4892
- * @fires handoff-started - Fired when an agent's `handOff` takes effect and its target becomes active. Bubbles and composed. detail: `HandOffFrame`
4893
- * @fires handoff-returned - Fired when a hand-off ends and its caller is active again; `detail.outcome` says how it ended. Bubbles and composed. detail: `HandOffFrame`
4894
- * @fires handoff-unwound - Fired when a hand-off ends with no hand-back: the chat was cleared, the agents changed, or a restore found it could not resume. Bubbles and composed. detail: `HandOffFrame`
4895
4699
  *
4896
4700
  * @beta
4897
4701
  */
@@ -7214,53 +7018,6 @@ export declare interface HandlerCapabilityScope {
7214
7018
  readonly flowOwner: string | null;
7215
7019
  }
7216
7020
 
7217
- /**
7218
- * One hand-off on the stack, saved with the session: who waits, for whom, and why. `outcome` is set
7219
- * when the target finishes, until the caller has resumed, so a reload in between still hands back.
7220
- * Also the `detail` of the `handoff-started`, `handoff-returned` and `handoff-unwound` events.
7221
- *
7222
- * @beta
7223
- */
7224
- export declare interface HandOffFrame {
7225
- id: string;
7226
- /** The agent waiting for the hand-back. */
7227
- caller: string;
7228
- target: string;
7229
- returnTo: boolean;
7230
- /** The brief. */
7231
- message: string;
7232
- /** JSON only. */
7233
- data?: unknown;
7234
- /** ISO time the hand-off started. */
7235
- startedAt: string;
7236
- outcome?: HandOffOutcome;
7237
- }
7238
-
7239
- /**
7240
- * What a hand-off's caller gets back. `message` is the target's `completeHandOff` summary, or for
7241
- * `released` its final reply since the brief; `data` is what `completeHandOff` passed.
7242
- *
7243
- * @beta
7244
- */
7245
- export declare interface HandOffOutcome {
7246
- kind: HandOffOutcomeKind;
7247
- message?: string;
7248
- data?: unknown;
7249
- }
7250
-
7251
- /**
7252
- * How a hand-off ended (GENC-1737):
7253
- * - `completed`: the target called `completeHandOff`;
7254
- * - `released`: the target called `releaseAgent`, or, a plain one, ended its turn;
7255
- * - `cleared`: the user cleared the chat;
7256
- * - `agent-removed`: the caller or the target is no longer in the agent list, found on restore;
7257
- * - `state-lost`: the caller's saved state is gone, so it cannot resume: a session saved while its
7258
- * flow could not be resumed, or a change to the agents, which disposes them.
7259
- *
7260
- * @beta
7261
- */
7262
- export declare type HandOffOutcomeKind = 'completed' | 'released' | 'cleared' | 'agent-removed' | 'state-lost';
7263
-
7264
7021
  /**
7265
7022
  * A single in-flight per-call chat-input override pushed by a `requestSubAgent`
7266
7023
  * or `requestInteraction` call. Tracked as an array (not a counter) so the
@@ -8015,37 +7772,22 @@ export declare class OrchestratingDriver extends BaseDriverDecorator<ChatDriver>
8015
7772
  */
8016
7773
  private get agentSession();
8017
7774
  /**
8018
- * Set by `cancel()` for the duration of a run. Stops it before the next agent
8019
- * runs — a hand-off's target or a hand-back's caller — so nothing more is asked
8020
- * of a provider after the user stops. Reset at the start of each run.
7775
+ * Set by `cancel()` for the duration of a `sendMessage` run. Breaks the
7776
+ * handoff loop so we don't classify or start another agent turn after the
7777
+ * user stops. Reset at the start of each `sendMessage`.
8021
7778
  */
8022
7779
  private cancelled;
8023
7780
  /**
8024
7781
  * Whether the CURRENT turn's user message has reached the inner driver's
8025
7782
  * history. False through the pre-first-turn classify (where the only echo of
8026
7783
  * the message is an optimistic `history-updated` dispatch), true from the
8027
- * moment `chatDriver.sendMessage` is entered. Read by the budget-wall catch in
8028
- * `sendMessage` to decide
7784
+ * moment `chatDriver.sendMessage` is entered — including through every later
7785
+ * handoff classify. Read by the budget-wall catch in `sendMessage` to decide
8029
7786
  * whether `reportBudgetExhausted` must append the message itself: appending
8030
7787
  * it when already appended duplicated it; not appending it when unappended
8031
7788
  * made it vanish. Reset at the top of each `runOrchestratedTurn`.
8032
7789
  */
8033
7790
  private userMessageAppended;
8034
- /** How many callers may wait in hand-offs at once (GENC-1737). */
8035
- private readonly maxHandOffDepth;
8036
- /**
8037
- * The hand-offs in progress, oldest first (GENC-1737). The top frame's target is the active agent
8038
- * and holds the flow lock; each caller waits, suspended, for the target above it. Saved with the
8039
- * session through {@link OrchestratingDriver.getHandOffStack}.
8040
- */
8041
- private handOffStack;
8042
- /** Hand-offs and hand-backs this user turn, against `maxHandoffs`. */
8043
- private handOffsThisTurn;
8044
- /**
8045
- * A hand-back a restore found due — the top frame's target had finished, or has gone — which
8046
- * {@link OrchestratingDriver.resumeRestoredFlow} carries out.
8047
- */
8048
- private pendingHandBack?;
8049
7791
  /**
8050
7792
  * The active agent, or `undefined` before the first activation and after a release.
8051
7793
  *
@@ -8056,8 +7798,6 @@ export declare class OrchestratingDriver extends BaseDriverDecorator<ChatDriver>
8056
7798
  constructor(providerRegistry: AIProviderRegistry, agents: AgentConfig[], options?: {
8057
7799
  sessionKey?: string;
8058
7800
  maxHandoffs?: number;
8059
- /** How many callers may wait in hand-offs at once. Default 1. */
8060
- maxHandOffDepth?: number;
8061
7801
  classifierHistoryLength?: number;
8062
7802
  classifierRetries?: number;
8063
7803
  maxToolIterations?: number;
@@ -8078,25 +7818,6 @@ export declare class OrchestratingDriver extends BaseDriverDecorator<ChatDriver>
8078
7818
  getSuggestions(history: ChatMessage[], prompt: string, count: number, allAgentInfo?: AllAgentSummary[]): Promise<string[]>;
8079
7819
  sendMessage(input: string, attachments?: ChatAttachment[], options?: SendMessageOptions): Promise<ChatDriverResult>;
8080
7820
  private runOrchestratedTurn;
8081
- /**
8082
- * Act on what the agent call that just ended asked for, and run the next agent in the same user
8083
- * turn while there is one (GENC-1737): a `handOff` runs its target with the brief, and a target
8084
- * that releases hands back to its caller. Returns the last call's result.
8085
- *
8086
- * A failed call ends the turn there, as a Stop does: what it asked for still happens, and the
8087
- * next agent runs on the next message. Running it now would meet the same wall (a budget, a
8088
- * refused account, a full context window), or build on a reply that never came.
8089
- */
8090
- private carryOn;
8091
- /**
8092
- * After one agent call: start the hand-off it asked for, or release it and, when it was a
8093
- * hand-off's target, hand back. Returns the tail note for the agent to run next, or `undefined`
8094
- * when the turn ends here.
8095
- *
8096
- * A plain target hands back when its call ends, released or not, as a plain agent is done once
8097
- * it has answered. A stateful one holds the hand-off until it releases, as it holds its flow.
8098
- */
8099
- private afterAgentCall;
8100
7821
  /** {@inheritDoc AiDriver.canRestoreFlowOwner} */
8101
7822
  canRestoreFlowOwner(agentName: string): boolean;
8102
7823
  /** {@inheritDoc AiDriver.canResumeRestoredFlow} */
@@ -8114,31 +7835,25 @@ export declare class OrchestratingDriver extends BaseDriverDecorator<ChatDriver>
8114
7835
  * undecorated.
8115
7836
  */
8116
7837
  resumeRestoredFlow(resumeNote?: string): Promise<ChatDriverResult | undefined>;
8117
- /**
8118
- * The hand-back a restore found due (GENC-1737). The first call, inside the host's restore gate,
8119
- * makes the caller active again and tells it the outcome; the call with the note runs its turn.
8120
- */
8121
- private resumeHandBack;
8122
7838
  /**
8123
7839
  * A continuation outside a routed turn — a decorator carrying the agent on, say — can finish the
8124
7840
  * flow as surely as a turn can, so a release it requests is acted on here too. Before
8125
7841
  * (GENC-1660), only `sendMessage` checked, and a flow finished by a continuation stayed locked.
8126
7842
  */
8127
7843
  continueFromHistory(transientPrimer?: ChatMessage[], options?: ContinueFromHistoryOptions): Promise<ChatDriverResult>;
7844
+ /** Release the flow if the turn that just ended asked to, and an agent is still active to release. */
7845
+ private releaseIfRequested;
8128
7846
  /**
8129
7847
  * {@inheritDoc AiDriver.getContextReserve}
8130
7848
  *
8131
7849
  * Two cases, because routing has two modes and they need opposite answers.
8132
7850
  */
8133
7851
  getContextReserve(): ContextReserveResolution | undefined;
8134
- /** Make `agent` active through the session, firing its hooks, and install it. */
8135
- private installAgent;
8136
7852
  /**
8137
- * Install an agent the session has already made active on the inner driver: the transcript's
8138
- * divider when another agent spoke before it, and its own view of the history. What is left here
8139
- * is this driver's own job, the transcript; the session owns the lifecycle.
7853
+ * `pin` stands in for the user-pin when given, as for
7854
+ * {@link OrchestratingDriver.resolvePinnedAgent}.
8140
7855
  */
8141
- private applyAgent;
7856
+ private installAgent;
8142
7857
  /**
8143
7858
  * Release the current stateful agent: fire `onDeactivate` and clear the flow-owner lock. The
8144
7859
  * inner driver raises the events from the session's transition, so the host (and Redux) reflect
@@ -8151,65 +7866,10 @@ export declare class OrchestratingDriver extends BaseDriverDecorator<ChatDriver>
8151
7866
  * routing through the classifier.
8152
7867
  */
8153
7868
  private releaseActiveAgent;
8154
- /** The agent named `name` as this driver installs it: the fallback with its prompt built. */
8155
- private agentNamed;
8156
- /**
8157
- * End the hand-offs when a turn runs an agent other than the top target (GENC-1737): the lock
8158
- * that kept turns on the target was taken away, by a host clearing `flowOwnerAgentName` say,
8159
- * and its caller would otherwise wait for good.
8160
- */
8161
- private endOrphanedHandOffs;
8162
- /**
8163
- * Check a handler's `handOff` when it is made (GENC-1737), so a refusal reaches its model. Checked
8164
- * against the agents and the stack as they are now; the hand-off itself starts after the call.
8165
- */
8166
- private checkHandOff;
8167
- /**
8168
- * Start the hand-off the agent call just made, and return the target's tail note (GENC-1737).
8169
- *
8170
- * - `returnTo` (the default): push a frame. The caller waits without being deactivated, its
8171
- * `agentEnd` payloads suspended, and the target takes the flow lock.
8172
- * - One-way from a hand-off's target: that frame's caller now waits for the new target instead.
8173
- * - One-way with nobody waiting: a plain switch, the caller deactivated as on any swap.
8174
- *
8175
- * Either way the brief is recorded as a message the caller sent on the user's behalf.
8176
- */
8177
- private startHandOff;
8178
- /**
8179
- * Hand back to `frame`'s caller with `outcome`, and return its tail note (GENC-1737). The outcome
8180
- * is kept on the frame until the caller is active again and its `onHandOffReturn` has run, so a
8181
- * reload in between still hands back; the frame then goes, before the caller's model call.
8182
- */
8183
- private handBack;
8184
- /** The top frame, when `agent` is its target. */
8185
- private topFrameFor;
8186
- /** The target's last reply since its brief, for a target that released without a summary. */
8187
- private lastReply;
8188
- /** The brief, in the transcript as a message the caller sent on the user's behalf. */
8189
- private recordBrief;
8190
- /** End `frame` with `kind` and no hand-back, for the host. */
8191
- private unwound;
8192
- /** {@inheritDoc AiDriver.getHandOffStack} */
8193
- getHandOffStack(): HandOffFrame[];
8194
- /** {@inheritDoc AiDriver.restoreHandOffStack} */
8195
- restoreHandOffStack(saved: unknown, savedStates: Record<string, unknown>, interrupted: boolean): {
8196
- resume?: {
8197
- agent: string;
8198
- note: string;
8199
- };
8200
- };
8201
- /** {@inheritDoc AiDriver.unwindHandOffs} */
8202
- unwindHandOffs(kind: 'cleared' | 'state-lost'): Promise<void>;
8203
- /** {@inheritDoc AiDriver.getHandOffData} */
8204
- getHandOffData(): Record<string, unknown>;
8205
- /** {@inheritDoc AiDriver.restoreHandOffData} */
8206
- restoreHandOffData(saved: unknown, interrupted: boolean): void;
8207
- /** {@inheritDoc AiDriver.serializeWaitingCallers} */
8208
- serializeWaitingCallers(): Record<string, unknown>;
8209
7869
  /**
8210
7870
  * Stop the current turn (user "stop" button). Cancels the inner chat driver's
8211
- * in-flight request, and no further agent runs this turn, not even a hand-off's
8212
- * target or a hand-back. The driver stays usable for the next message.
7871
+ * in-flight request and breaks the handoff loop so no further agent turn or
7872
+ * classify runs. The driver stays usable for the next message.
8213
7873
  */
8214
7874
  cancel(): void;
8215
7875
  /**
@@ -8251,7 +7911,7 @@ export declare class OrchestratingDriver extends BaseDriverDecorator<ChatDriver>
8251
7911
  */
8252
7912
  private resolvePinnedAgent;
8253
7913
  /**
8254
- * Append prose the ORCHESTRATOR wrote — the no-specialist apology. Flagged
7914
+ * Append prose the ORCHESTRATOR wrote — the handoff cap, the no-specialist apology. Flagged
8255
7915
  * `excludeFromProvider` for the same reason the driver's own notices are: it is not something a
8256
7916
  * model said, and feeding it back invites the model to echo it. See
8257
7917
  * `ChatMessage.excludeFromProvider`.
@@ -8416,33 +8076,6 @@ export declare interface PersistedSession {
8416
8076
  componentName: string;
8417
8077
  value: unknown;
8418
8078
  };
8419
- /**
8420
- * The hand-offs in progress, oldest first (GENC-1737): who waits for whom, and why. A frame with
8421
- * an `outcome` was finished by its target but its caller had not resumed yet, so a restore hands
8422
- * back. Each agent's own state is in `agentSnapshots`, the waiting callers' included. Optional
8423
- * and additive, like `condensePolicies`; omitted when there are none. The frame's shape, written
8424
- * out here as for `checkpoints`.
8425
- */
8426
- handoffStack?: Array<{
8427
- id: string;
8428
- caller: string;
8429
- target: string;
8430
- returnTo: boolean;
8431
- message: string;
8432
- data?: unknown;
8433
- startedAt: string;
8434
- outcome?: {
8435
- kind: string;
8436
- message?: string;
8437
- data?: unknown;
8438
- };
8439
- }>;
8440
- /**
8441
- * The `data` each hand-off target was activated with, by agent name (GENC-1737), for the agents
8442
- * a restore resumes: the flow owner and the waiting callers. Not written for a frozen session.
8443
- * Optional and additive, like `handoffStack`; omitted when there is none.
8444
- */
8445
- handOffData?: Record<string, unknown>;
8446
8079
  /**
8447
8080
  * Interrupted-flow marker (GENC-1351 §5.9). Present when the session was saved
8448
8081
  * while an agent declared its current state non-resumable (`resumable === false`).
@@ -8530,6 +8163,13 @@ export declare function registerInteraction<TController = unknown>(name: string,
8530
8163
  */
8531
8164
  export declare function registerTieredAIProviders(container: Container, options: Omit<TieredAIProviderSwitcherOptions, 'container'>): TieredAIProviderSwitcher;
8532
8165
 
8166
+ /**
8167
+ * Name reserved for the cross-agent handoff tool — injected by OrchestratingDriver.
8168
+ *
8169
+ * @beta
8170
+ */
8171
+ export declare const REQUEST_CONTINUATION_TOOL = "request_continuation";
8172
+
8533
8173
  /**
8534
8174
  * Ask the person for permission to show notifications, and resolve to the result. Call it from a
8535
8175
  * click or key handler: browsers ignore or refuse a request that does not come from the person.
@@ -8696,6 +8336,13 @@ export declare type RoutingDecision =
8696
8336
  'classified'
8697
8337
  /** The classifier ran and answered -1: nothing listed covers the request. */
8698
8338
  | 'no-match'
8339
+ /**
8340
+ * Every classifier-eligible specialist had already handled part of this turn and handed on, so
8341
+ * the ballot was empty and no call was made. Distinct from `'no-match'`, which means a
8342
+ * classifier RAN and declined — conflating the two re-creates exactly the "did anything actually
8343
+ * get asked?" ambiguity this event exists to remove.
8344
+ */
8345
+ | 'ballot-exhausted'
8699
8346
  /** One viable specialist and no fallback — no point asking. */
8700
8347
  | 'single-candidate'
8701
8348
  /** Nothing classifier-eligible was configured. */
@@ -10037,7 +9684,7 @@ export declare type UnresolvedToolInput = (ctx: UnresolvedToolContext) => string
10037
9684
  * A fallback prompt written by a consumer reliably covers two cases — small talk, and a request
10038
9685
  * that belongs to a specialist — because those are the ones you think of when you write it. The
10039
9686
  * case it exists FOR is the third: a substantive request that no specialist covers, and no way to
10040
- * act on it, because a fallback holds no tools.
9687
+ * act on it, because a fallback holds no tools and is denied the continuation tool as a leaf.
10041
9688
  *
10042
9689
  * Create's fallback prompt is the worked example (GENC-1573). It covered chit-chat and
10043
9690
  * "out of scope, here are the specialists", said nothing about a request nothing can serve, and