@genesislcap/ai-assistant 15.98.2 → 15.98.4

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.
@@ -5154,6 +5154,39 @@
5154
5154
  "parameters": [],
5155
5155
  "name": "getTurnSnapshots"
5156
5156
  },
5157
+ {
5158
+ "kind": "MethodSignature",
5159
+ "canonicalReference": "@genesislcap/ai-assistant!AiDriver#getWaitingCallers:member(1)",
5160
+ "docComment": "/**\n * The agent behind each hand-off frame's caller, oldest first, so a save can ask each whether it `resumable` (GENC-1640): the live instance when it waits live, else the configured one.\n *\n * @beta\n */\n",
5161
+ "excerptTokens": [
5162
+ {
5163
+ "kind": "Content",
5164
+ "text": "getWaitingCallers?(): "
5165
+ },
5166
+ {
5167
+ "kind": "Reference",
5168
+ "text": "AgentConfig",
5169
+ "canonicalReference": "@genesislcap/ai-assistant!AgentConfig:type"
5170
+ },
5171
+ {
5172
+ "kind": "Content",
5173
+ "text": "[]"
5174
+ },
5175
+ {
5176
+ "kind": "Content",
5177
+ "text": ";"
5178
+ }
5179
+ ],
5180
+ "isOptional": true,
5181
+ "returnTypeTokenRange": {
5182
+ "startIndex": 1,
5183
+ "endIndex": 3
5184
+ },
5185
+ "releaseTag": "Beta",
5186
+ "overloadIndex": 1,
5187
+ "parameters": [],
5188
+ "name": "getWaitingCallers"
5189
+ },
5157
5190
  {
5158
5191
  "kind": "MethodSignature",
5159
5192
  "canonicalReference": "@genesislcap/ai-assistant!AiDriver#invokeAsUser:member(1)",
@@ -5710,7 +5743,7 @@
5710
5743
  {
5711
5744
  "kind": "MethodSignature",
5712
5745
  "canonicalReference": "@genesislcap/ai-assistant!AiDriver#restoreHandOffData:member(1)",
5713
- "docComment": "/**\n * Restore what {@link AiDriver.getHandOffData} saved, before the hand-off stack. Nothing comes back from a frozen (`interrupted`) session, whose flow does not resume.\n *\n * @beta\n */\n",
5746
+ "docComment": "/**\n * Restore what {@link AiDriver.getHandOffData} saved, before the hand-off stack. With `interrupted` true nothing comes back. A frozen session saves only its waiting callers' data, which resume, so a host restoring one passes `false`.\n *\n * @beta\n */\n",
5714
5747
  "excerptTokens": [
5715
5748
  {
5716
5749
  "kind": "Content",
@@ -5771,7 +5804,7 @@
5771
5804
  {
5772
5805
  "kind": "MethodSignature",
5773
5806
  "canonicalReference": "@genesislcap/ai-assistant!AiDriver#restoreHandOffStack:member(1)",
5774
- "docComment": "/**\n * Restore saved hand-offs, before the condense policies, against the agents configured now and the saved agent states. A frame whose caller has gone, or whose stateful caller has no saved state (`interrupted` drops them all), is unwound with `handoff-unwound`. When the top frame's target had finished, or has gone, its caller is due to resume: `resume` names it and the note its resumed turn needs, and {@link AiDriver.resumeRestoredFlow} hands back. `droppedLocks` names plain targets of unwound hand-offs, whose saved lock was only that hand-off's.\n *\n * @beta\n */\n",
5807
+ "docComment": "/**\n * Restore saved hand-offs, before the condense policies, against the agents configured now and the saved agent states. A frame whose caller has gone, or whose stateful caller has no saved state, is unwound with `handoff-unwound`. `interrupted` says the save was frozen: the running target's state was dropped, but the waiting callers' were kept, so when the top frame's target had not finished its outcome is `target-interrupted`. When the top frame's target had finished, or has gone, or was interrupted, its caller is due to resume: `resume` names it and the note its resumed turn needs, and {@link AiDriver.resumeRestoredFlow} hands back. `droppedLocks` names plain targets of unwound hand-offs, whose saved lock was only that hand-off's.\n *\n * @beta\n */\n",
5775
5808
  "excerptTokens": [
5776
5809
  {
5777
5810
  "kind": "Content",
@@ -12576,6 +12609,42 @@
12576
12609
  "isAbstract": false,
12577
12610
  "name": "getTurnSnapshots"
12578
12611
  },
12612
+ {
12613
+ "kind": "Method",
12614
+ "canonicalReference": "@genesislcap/ai-assistant!BaseDriverDecorator#getWaitingCallers:member(1)",
12615
+ "docComment": "",
12616
+ "excerptTokens": [
12617
+ {
12618
+ "kind": "Content",
12619
+ "text": "getWaitingCallers(): "
12620
+ },
12621
+ {
12622
+ "kind": "Reference",
12623
+ "text": "AgentConfig",
12624
+ "canonicalReference": "@genesislcap/ai-assistant!AgentConfig:type"
12625
+ },
12626
+ {
12627
+ "kind": "Content",
12628
+ "text": "[]"
12629
+ },
12630
+ {
12631
+ "kind": "Content",
12632
+ "text": ";"
12633
+ }
12634
+ ],
12635
+ "isStatic": false,
12636
+ "returnTypeTokenRange": {
12637
+ "startIndex": 1,
12638
+ "endIndex": 3
12639
+ },
12640
+ "releaseTag": "Beta",
12641
+ "isProtected": false,
12642
+ "overloadIndex": 1,
12643
+ "parameters": [],
12644
+ "isOptional": false,
12645
+ "isAbstract": false,
12646
+ "name": "getWaitingCallers"
12647
+ },
12579
12648
  {
12580
12649
  "kind": "Property",
12581
12650
  "canonicalReference": "@genesislcap/ai-assistant!BaseDriverDecorator#inner:member",
@@ -30533,7 +30602,7 @@
30533
30602
  {
30534
30603
  "kind": "TypeAlias",
30535
30604
  "canonicalReference": "@genesislcap/ai-assistant!HandOffOutcomeKind:type",
30536
- "docComment": "/**\n * How a hand-off ended (GENC-1737): - `completed`: the target called `completeHandOff`; - `released`: the target called `releaseAgent`, or, a plain one, ended its turn; - `cleared`: the user cleared the chat; - `agent-removed`: the caller or the target is no longer in the agent list, found on restore; - `state-lost`: the caller's saved state is gone, so it cannot resume: a session saved while its flow could not be resumed, or a change to the agents, which disposes them.\n *\n * @beta\n */\n",
30605
+ "docComment": "/**\n * How a hand-off ended (GENC-1737): - `completed`: the target called `completeHandOff`; - `released`: the target called `releaseAgent`, or, a plain one, ended its turn; - `cleared`: the user cleared the chat; - `agent-removed`: the caller or the target is no longer in the agent list, found on restore; - `target-interrupted`: a reload cut the target's work short and it cannot resume (its `resumable` was `false`), so its unsaved work is lost; the caller's own state was saved, so the caller resumes and is told, and decides what to do next, such as handing off again; - `state-lost`: the caller's saved state is gone, so it cannot resume: a stateful caller whose state was not saved, or a change to the agents, which disposes them.\n *\n * @beta\n */\n",
30537
30606
  "excerptTokens": [
30538
30607
  {
30539
30608
  "kind": "Content",
@@ -30541,7 +30610,7 @@
30541
30610
  },
30542
30611
  {
30543
30612
  "kind": "Content",
30544
- "text": "'completed' | 'released' | 'cleared' | 'agent-removed' | 'state-lost'"
30613
+ "text": "'completed' | 'released' | 'cleared' | 'agent-removed' | 'target-interrupted' | 'state-lost'"
30545
30614
  },
30546
30615
  {
30547
30616
  "kind": "Content",
@@ -37342,10 +37411,46 @@
37342
37411
  "isAbstract": false,
37343
37412
  "name": "getSuggestions"
37344
37413
  },
37414
+ {
37415
+ "kind": "Method",
37416
+ "canonicalReference": "@genesislcap/ai-assistant!OrchestratingDriver#getWaitingCallers:member(1)",
37417
+ "docComment": "/**\n * The agent behind each hand-off frame's caller, oldest first, so a save can ask each whether it `resumable` (GENC-1640): the live instance when it waits live, else the configured one.\n */\n",
37418
+ "excerptTokens": [
37419
+ {
37420
+ "kind": "Content",
37421
+ "text": "getWaitingCallers(): "
37422
+ },
37423
+ {
37424
+ "kind": "Reference",
37425
+ "text": "AgentConfig",
37426
+ "canonicalReference": "@genesislcap/ai-assistant!AgentConfig:type"
37427
+ },
37428
+ {
37429
+ "kind": "Content",
37430
+ "text": "[]"
37431
+ },
37432
+ {
37433
+ "kind": "Content",
37434
+ "text": ";"
37435
+ }
37436
+ ],
37437
+ "isStatic": false,
37438
+ "returnTypeTokenRange": {
37439
+ "startIndex": 1,
37440
+ "endIndex": 3
37441
+ },
37442
+ "releaseTag": "Beta",
37443
+ "isProtected": false,
37444
+ "overloadIndex": 1,
37445
+ "parameters": [],
37446
+ "isOptional": false,
37447
+ "isAbstract": false,
37448
+ "name": "getWaitingCallers"
37449
+ },
37345
37450
  {
37346
37451
  "kind": "Method",
37347
37452
  "canonicalReference": "@genesislcap/ai-assistant!OrchestratingDriver#restoreHandOffData:member(1)",
37348
- "docComment": "/**\n * Restore what {@link AiDriver.getHandOffData} saved, before the hand-off stack. Nothing comes back from a frozen (`interrupted`) session, whose flow does not resume.\n */\n",
37453
+ "docComment": "/**\n * Restore what {@link AiDriver.getHandOffData} saved, before the hand-off stack. With `interrupted` true nothing comes back. A frozen session saves only its waiting callers' data, which resume, so a host restoring one passes `false`.\n */\n",
37349
37454
  "excerptTokens": [
37350
37455
  {
37351
37456
  "kind": "Content",
@@ -37409,7 +37514,7 @@
37409
37514
  {
37410
37515
  "kind": "Method",
37411
37516
  "canonicalReference": "@genesislcap/ai-assistant!OrchestratingDriver#restoreHandOffStack:member(1)",
37412
- "docComment": "/**\n * Restore saved hand-offs, before the condense policies, against the agents configured now and the saved agent states. A frame whose caller has gone, or whose stateful caller has no saved state (`interrupted` drops them all), is unwound with `handoff-unwound`. When the top frame's target had finished, or has gone, its caller is due to resume: `resume` names it and the note its resumed turn needs, and {@link AiDriver.resumeRestoredFlow} hands back. `droppedLocks` names plain targets of unwound hand-offs, whose saved lock was only that hand-off's.\n */\n",
37517
+ "docComment": "/**\n * Restore saved hand-offs, before the condense policies, against the agents configured now and the saved agent states. A frame whose caller has gone, or whose stateful caller has no saved state, is unwound with `handoff-unwound`. `interrupted` says the save was frozen: the running target's state was dropped, but the waiting callers' were kept, so when the top frame's target had not finished its outcome is `target-interrupted`. When the top frame's target had finished, or has gone, or was interrupted, its caller is due to resume: `resume` names it and the note its resumed turn needs, and {@link AiDriver.resumeRestoredFlow} hands back. `droppedLocks` names plain targets of unwound hand-offs, whose saved lock was only that hand-off's.\n */\n",
37413
37518
  "excerptTokens": [
37414
37519
  {
37415
37520
  "kind": "Content",
@@ -1102,9 +1102,11 @@ export declare interface AiDriver extends EventTarget {
1102
1102
  /**
1103
1103
  * Restore saved hand-offs, before the condense policies, against the agents configured now and
1104
1104
  * the saved agent states. A frame whose caller has gone, or whose stateful caller has no saved
1105
- * state (`interrupted` drops them all), is unwound with `handoff-unwound`. When the top frame's
1106
- * target had finished, or has gone, its caller is due to resume: `resume` names it and the note
1107
- * its resumed turn needs, and {@link AiDriver.resumeRestoredFlow} hands back. `droppedLocks`
1105
+ * state, is unwound with `handoff-unwound`. `interrupted` says the save was frozen: the running
1106
+ * target's state was dropped, but the waiting callers' were kept, so when the top frame's target
1107
+ * had not finished its outcome is `target-interrupted`. When the top frame's target had
1108
+ * finished, or has gone, or was interrupted, its caller is due to resume: `resume` names it and
1109
+ * the note its resumed turn needs, and {@link AiDriver.resumeRestoredFlow} hands back. `droppedLocks`
1108
1110
  * names plain targets of unwound hand-offs, whose saved lock was only that hand-off's.
1109
1111
  *
1110
1112
  * @beta
@@ -1130,6 +1132,13 @@ export declare interface AiDriver extends EventTarget {
1130
1132
  * @beta
1131
1133
  */
1132
1134
  serializeWaitingCallers?(): Record<string, unknown>;
1135
+ /**
1136
+ * The agent behind each hand-off frame's caller, oldest first, so a save can ask each whether it
1137
+ * `resumable` (GENC-1640): the live instance when it waits live, else the configured one.
1138
+ *
1139
+ * @beta
1140
+ */
1141
+ getWaitingCallers?(): AgentConfig[];
1133
1142
  /**
1134
1143
  * The `data` each hand-off target was activated with, by name, for the agents a reload resumes:
1135
1144
  * the flow owner and the callers waiting in a hand-off. See the tool context's `handOffData`.
@@ -1138,8 +1147,9 @@ export declare interface AiDriver extends EventTarget {
1138
1147
  */
1139
1148
  getHandOffData?(): Record<string, unknown>;
1140
1149
  /**
1141
- * Restore what {@link AiDriver.getHandOffData} saved, before the hand-off stack. Nothing comes
1142
- * back from a frozen (`interrupted`) session, whose flow does not resume.
1150
+ * Restore what {@link AiDriver.getHandOffData} saved, before the hand-off stack. With
1151
+ * `interrupted` true nothing comes back. A frozen session saves only its waiting callers' data,
1152
+ * which resume, so a host restoring one passes `false`.
1143
1153
  *
1144
1154
  * @beta
1145
1155
  */
@@ -2573,8 +2583,8 @@ declare interface BaseAgentConfig {
2573
2583
  onHandOffStart?: (frame: HandOffFrame) => void | Promise<void>;
2574
2584
  /**
2575
2585
  * Fires on the caller when a hand-off it made ends, before its next model call, so its own state
2576
- * can move on. `outcome.kind` says how it ended. Not fired for `state-lost`, whose caller cannot
2577
- * resume. GENC-1737.
2586
+ * can move on. `outcome.kind` says how it ended. Fired for `target-interrupted`, whose caller
2587
+ * resumes. Not fired for `state-lost`, whose caller cannot resume. GENC-1737.
2578
2588
  *
2579
2589
  * @beta
2580
2590
  */
@@ -2620,6 +2630,13 @@ declare interface BaseAgentConfig {
2620
2630
  * default) and pre-fills the composer with the user's last message so they can
2621
2631
  * re-run it.
2622
2632
  *
2633
+ * It is also consulted for an agent waiting in a hand-off (with `isFlowOwner: false` and its own
2634
+ * saved state) when the active agent cannot resume, and decides whether that agent is resumed.
2635
+ * The session goes back to the topmost waiting caller that says `true`, which resumes with the
2636
+ * `target-interrupted` outcome; agents above it lose their state, and a caller below it that
2637
+ * says `false` is unwound as `state-lost`. When a caller resumes, the composer is not pre-filled
2638
+ * and the user's last message is not re-added, since the caller carries on from its own state.
2639
+ *
2623
2640
  * Only consulted when the user has persistence enabled. Must be a **pure
2624
2641
  * function of `ctx.state`** — it may be re-evaluated on a restored snapshot, so
2625
2642
  * a resumable state must stay resumable. A thrown error is treated as `true`
@@ -2758,6 +2775,7 @@ export declare abstract class BaseDriverDecorator<TInner extends AiDriver = AiDr
2758
2775
  };
2759
2776
  unwindHandOffs(kind: Extract<HandOffOutcomeKind, 'cleared' | 'state-lost'>): Promise<void>;
2760
2777
  serializeWaitingCallers(): Record<string, unknown>;
2778
+ getWaitingCallers(): AgentConfig[];
2761
2779
  getHandOffData(): Record<string, unknown>;
2762
2780
  restoreHandOffData(saved: unknown, interrupted: boolean): void;
2763
2781
  getActiveAgent(): AgentConfig | undefined;
@@ -7573,12 +7591,15 @@ export declare interface HandOffOutcome {
7573
7591
  * - `released`: the target called `releaseAgent`, or, a plain one, ended its turn;
7574
7592
  * - `cleared`: the user cleared the chat;
7575
7593
  * - `agent-removed`: the caller or the target is no longer in the agent list, found on restore;
7576
- * - `state-lost`: the caller's saved state is gone, so it cannot resume: a session saved while its
7577
- * flow could not be resumed, or a change to the agents, which disposes them.
7594
+ * - `target-interrupted`: a reload cut the target's work short and it cannot resume (its
7595
+ * `resumable` was `false`), so its unsaved work is lost; the caller's own state was saved, so
7596
+ * the caller resumes and is told, and decides what to do next, such as handing off again;
7597
+ * - `state-lost`: the caller's saved state is gone, so it cannot resume: a stateful caller whose
7598
+ * state was not saved, or a change to the agents, which disposes them.
7578
7599
  *
7579
7600
  * @beta
7580
7601
  */
7581
- export declare type HandOffOutcomeKind = 'completed' | 'released' | 'cleared' | 'agent-removed' | 'state-lost';
7602
+ export declare type HandOffOutcomeKind = 'completed' | 'released' | 'cleared' | 'agent-removed' | 'target-interrupted' | 'state-lost';
7582
7603
 
7583
7604
  /**
7584
7605
  * What `act` is given besides the action: the arguments a person would fill in.
@@ -9220,6 +9241,8 @@ export declare class OrchestratingDriver extends BaseDriverDecorator<ChatDriver>
9220
9241
  getHandOffData(): Record<string, unknown>;
9221
9242
  /** {@inheritDoc AiDriver.restoreHandOffData} */
9222
9243
  restoreHandOffData(saved: unknown, interrupted: boolean): void;
9244
+ /** {@inheritDoc AiDriver.getWaitingCallers} */
9245
+ getWaitingCallers(): AgentConfig[];
9223
9246
  /** {@inheritDoc AiDriver.serializeWaitingCallers} */
9224
9247
  serializeWaitingCallers(): Record<string, unknown>;
9225
9248
  /**
@@ -11130,6 +11130,9 @@ var BaseDriverDecorator = class _BaseDriverDecorator extends EventTarget {
11130
11130
  serializeWaitingCallers() {
11131
11131
  return this.inner.serializeWaitingCallers?.() ?? {};
11132
11132
  }
11133
+ getWaitingCallers() {
11134
+ return this.inner.getWaitingCallers?.() ?? [];
11135
+ }
11133
11136
  getHandOffData() {
11134
11137
  return this.inner.getHandOffData?.() ?? {};
11135
11138
  }
@@ -11261,6 +11264,7 @@ var OUTCOME_KINDS = [
11261
11264
  "released",
11262
11265
  "cleared",
11263
11266
  "agent-removed",
11267
+ "target-interrupted",
11264
11268
  "state-lost"
11265
11269
  ];
11266
11270
  function handOffNote(caller) {
@@ -11272,6 +11276,7 @@ function handBackNote(frame, outcome) {
11272
11276
  released: `${frame.target} has finished the request you handed it, without a summary. Its last reply is above.`,
11273
11277
  cleared: "The hand-off was cleared.",
11274
11278
  "agent-removed": `${frame.target} is no longer available, so the request you handed it was not finished.`,
11279
+ "target-interrupted": `${frame.target} was cut short by a page reload and could not resume, so the request you handed it was not finished and its unsaved work is lost.`,
11275
11280
  "state-lost": `The hand-off to ${frame.target} could not be resumed.`
11276
11281
  };
11277
11282
  const summary = outcome.kind === "completed" && outcome.message ? " Its summary is the message above." : "";
@@ -11873,7 +11878,7 @@ var OrchestratingDriver = class _OrchestratingDriver extends BaseDriverDecorator
11873
11878
  const outcome = frame.outcome;
11874
11879
  if (!caller) {
11875
11880
  this.unwound(frame, "agent-removed");
11876
- } else if (interrupted || caller.serialize && savedStates?.[caller.name] === void 0) {
11881
+ } else if (caller.serialize && savedStates?.[caller.name] === void 0) {
11877
11882
  this.unwound(frame, "state-lost");
11878
11883
  } else {
11879
11884
  kept.push(frame);
@@ -11890,6 +11895,8 @@ var OrchestratingDriver = class _OrchestratingDriver extends BaseDriverDecorator
11890
11895
  const top = kept[kept.length - 1];
11891
11896
  if (top && !top.outcome && !this.agents.some((a) => a.name === top.target)) {
11892
11897
  top.outcome = { kind: "agent-removed" };
11898
+ } else if (top && !top.outcome && interrupted) {
11899
+ top.outcome = { kind: "target-interrupted" };
11893
11900
  }
11894
11901
  this.handOffStack = kept;
11895
11902
  this.chatDriver.suspendRestoredActivations(kept.map((f) => f.caller));
@@ -11935,6 +11942,16 @@ var OrchestratingDriver = class _OrchestratingDriver extends BaseDriverDecorator
11935
11942
  if (interrupted || !saved || typeof saved !== "object" || Array.isArray(saved)) return;
11936
11943
  for (const [name, data] of Object.entries(saved)) this.agentSession.setHandOffData(name, data);
11937
11944
  }
11945
+ /** {@inheritDoc AiDriver.getWaitingCallers} */
11946
+ getWaitingCallers() {
11947
+ const live2 = this.agentSession.getSuspended();
11948
+ const callers = [];
11949
+ for (const frame of this.handOffStack) {
11950
+ const agent = live2.find((a) => a.name === frame.caller) ?? this.agents.find((a) => a.name === frame.caller);
11951
+ if (agent) callers.push(agent);
11952
+ }
11953
+ return callers;
11954
+ }
11938
11955
  /** {@inheritDoc AiDriver.serializeWaitingCallers} */
11939
11956
  serializeWaitingCallers() {
11940
11957
  const states = {};