@genesislcap/ai-assistant 15.85.0 → 15.86.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.
@@ -9733,7 +9733,7 @@
9733
9733
  {
9734
9734
  "kind": "Method",
9735
9735
  "canonicalReference": "@genesislcap/ai-assistant!AutopilotDriver#getPersistedMode:member(1)",
9736
- "docComment": "/**\n * The mode to save with the session, while it is set for the current flow.\n */\n",
9736
+ "docComment": "/**\n * The mode to save with the session, while it is set for the current flow — or kept for a hand-off's caller while its target releases, saved for that target, as the stack saves it.\n */\n",
9737
9737
  "excerptTokens": [
9738
9738
  {
9739
9739
  "kind": "Content",
@@ -33076,7 +33076,7 @@
33076
33076
  {
33077
33077
  "kind": "Interface",
33078
33078
  "canonicalReference": "@genesislcap/ai-assistant!PersistedAutopilotMode:interface",
33079
- "docComment": "/**\n * The autopilot's mode as saved with the session (GENC-1660 §4.8): which flow it was set for, and whether it was running. Cleared when that flow ends, so a saved mode never outlives its flow.\n *\n * @beta\n */\n",
33079
+ "docComment": "/**\n * The autopilot's mode as saved with the session (GENC-1660 §4.8): which flow it was set for, and whether it was running. Cleared when that flow ends, so a saved mode never outlives its flow. A hand-off does not end it: the mode goes with the task to the target, and back (GENC-1751).\n *\n * @beta\n */\n",
33080
33080
  "excerptTokens": [
33081
33081
  {
33082
33082
  "kind": "Content",
@@ -1965,6 +1965,16 @@ export declare class AutopilotDriver extends BaseDriverDecorator implements Auto
1965
1965
  private turnHandBack?;
1966
1966
  /** A mode restored with the session, waiting for its flow to become the owner again. */
1967
1967
  private restored?;
1968
+ /**
1969
+ * The mode of a hand-off's target that has released, kept for its caller, which has not taken the
1970
+ * lock back yet (GENC-1751): the flow has no owner in between. See `carriedTo`.
1971
+ */
1972
+ private handingBack?;
1973
+ /**
1974
+ * The mode of the flow that just ended, should a one-way hand-off with nobody waiting turn out to
1975
+ * have ended it: that switch announces itself only after the owner has changed (GENC-1751).
1976
+ */
1977
+ private switchedFrom?;
1968
1978
  /**
1969
1979
  * Bumped on every pause and resume, and when its sessions end. A written answer is sent only if
1970
1980
  * none came between asking for it and its landing: one started before a pause is stale after it,
@@ -2005,7 +2015,10 @@ export declare class AutopilotDriver extends BaseDriverDecorator implements Auto
2005
2015
  pause(): void;
2006
2016
  resume(): void;
2007
2017
  stop(): void;
2008
- /** The mode to save with the session, while it is set for the current flow. */
2018
+ /**
2019
+ * The mode to save with the session, while it is set for the current flow — or kept for a
2020
+ * hand-off's caller while its target releases, saved for that target, as the stack saves it.
2021
+ */
2009
2022
  getPersistedMode(): PersistedAutopilotMode | undefined;
2010
2023
  /**
2011
2024
  * Bring back a saved mode. It applies once its flow is the owner again — at once if it already
@@ -2157,6 +2170,36 @@ export declare class AutopilotDriver extends BaseDriverDecorator implements Auto
2157
2170
  /** A claimed interaction settled, whoever settled it. */
2158
2171
  private onSettled;
2159
2172
  private onFlowOwnerChanged;
2173
+ /**
2174
+ * A one-way hand-off with nobody waiting is a plain switch, the caller deactivated, so nothing on
2175
+ * the stack says the owner it changed to took over the same task: its event, raised once the
2176
+ * target is active, does (GENC-1751).
2177
+ */
2178
+ private onHandOffStarted;
2179
+ /** The mode set for the current flow, or kept for the caller of a hand-back under way. */
2180
+ private current;
2181
+ /**
2182
+ * The mode that carries to `owner` because the owner changed for a hand-off or its hand-back, as
2183
+ * the hand-off stack shows it at that moment (GENC-1751):
2184
+ * - a hand-off: `owner` is the top frame's target, which has not finished. Its frame is on the
2185
+ * stack before the target is activated, and so is a waiting caller's passed on by a one-way
2186
+ * hand-off from a target;
2187
+ * - a hand-back: the top frame's target, which the mode is set for, has finished, and `owner` is
2188
+ * its caller, or no one while the target releases. Its frame leaves the stack only after the
2189
+ * caller is active again.
2190
+ *
2191
+ * Clear and an agents change empty the stack before the flow ends, so the mode ends with it, as
2192
+ * it ends with any flow. A turn routed away from the target ends the hand-offs the same way.
2193
+ */
2194
+ private carriedTo;
2195
+ /** Whether `owner` is the caller the top hand-off hands back to from `target`. */
2196
+ private handsBack;
2197
+ /**
2198
+ * Set `carried`'s mode for `owner`, which took the task over in a hand-off or its hand-back. A
2199
+ * pause the person chose carries with it; the autopilot's own hand-back of an interaction does
2200
+ * not, since that interaction settled before the hand-off could start.
2201
+ */
2202
+ private carry;
2160
2203
  private capabilityFor;
2161
2204
  private flowOwner;
2162
2205
  private bindingFor;
@@ -8100,7 +8143,8 @@ export declare class OrchestratingDriver extends BaseDriverDecorator<ChatDriver>
8100
8143
  *
8101
8144
  * A failed call ends the turn there, as a Stop does: what it asked for still happens, and the
8102
8145
  * next agent runs on the next message. Running it now would meet the same wall (a budget, a
8103
- * refused account, a full context window), or build on a reply that never came.
8146
+ * refused account, a full context window), or build on a reply that never came. The one thing a
8147
+ * Stop takes back is a hand-off that has not started (see `afterAgentCall`).
8104
8148
  */
8105
8149
  private carryOn;
8106
8150
  /**
@@ -8110,6 +8154,11 @@ export declare class OrchestratingDriver extends BaseDriverDecorator<ChatDriver>
8110
8154
  *
8111
8155
  * A plain target hands back when its call ends, released or not, as a plain agent is done once
8112
8156
  * it has answered. A stateful one holds the hand-off until it releases, as it holds its flow.
8157
+ *
8158
+ * A Stop cancels a hand-off that has not started: the user stopped the turn the caller asked for
8159
+ * it in, often during the caller's closing call, so the target is not activated, and the call
8160
+ * ends as if it had never asked (a plain caller's turn ends as usual below). A hand-back is not
8161
+ * taken back: the target finished the work it was given.
8113
8162
  */
8114
8163
  private afterAgentCall;
8115
8164
  /** How the target of `frame` finished: with `completeHandOff`, or a release and its last reply. */
@@ -8294,7 +8343,8 @@ export declare const PERSISTED_SESSION_VERSION = 1;
8294
8343
 
8295
8344
  /**
8296
8345
  * The autopilot's mode as saved with the session (GENC-1660 §4.8): which flow it was set for, and
8297
- * whether it was running. Cleared when that flow ends, so a saved mode never outlives its flow.
8346
+ * whether it was running. Cleared when that flow ends, so a saved mode never outlives its flow. A
8347
+ * hand-off does not end it: the mode goes with the task to the target, and back (GENC-1751).
8298
8348
  *
8299
8349
  * @beta
8300
8350
  */
@@ -4133,6 +4133,8 @@ var META_EVENT_IMPORTANCE = {
4133
4133
  "autopilot.handed-back": "normal",
4134
4134
  "autopilot.paused": "normal",
4135
4135
  "autopilot.resumed": "normal",
4136
+ // The mode went with the task across a hand-off or its hand-back, rather than ending with the flow.
4137
+ "autopilot.carried": "normal",
4136
4138
  // The wrapper itself failed: the journey stops being automatic without anyone choosing that.
4137
4139
  "autopilot.error": "high",
4138
4140
  // A written answer counted against the step's limit; reaching it withdraws `reply`.
@@ -10337,7 +10339,8 @@ var OrchestratingDriver = class _OrchestratingDriver extends BaseDriverDecorator
10337
10339
  *
10338
10340
  * A failed call ends the turn there, as a Stop does: what it asked for still happens, and the
10339
10341
  * next agent runs on the next message. Running it now would meet the same wall (a budget, a
10340
- * refused account, a full context window), or build on a reply that never came.
10342
+ * refused account, a full context window), or build on a reply that never came. The one thing a
10343
+ * Stop takes back is a hand-off that has not started (see `afterAgentCall`).
10341
10344
  */
10342
10345
  async carryOn(result) {
10343
10346
  let last = result;
@@ -10355,10 +10358,18 @@ var OrchestratingDriver = class _OrchestratingDriver extends BaseDriverDecorator
10355
10358
  *
10356
10359
  * A plain target hands back when its call ends, released or not, as a plain agent is done once
10357
10360
  * it has answered. A stateful one holds the hand-off until it releases, as it holds its flow.
10361
+ *
10362
+ * A Stop cancels a hand-off that has not started: the user stopped the turn the caller asked for
10363
+ * it in, often during the caller's closing call, so the target is not activated, and the call
10364
+ * ends as if it had never asked (a plain caller's turn ends as usual below). A hand-back is not
10365
+ * taken back: the target finished the work it was given.
10358
10366
  */
10359
10367
  async afterAgentCall() {
10360
10368
  const request = this.chatDriver.getHandOffRequest();
10361
- if (request) return this.startHandOff(request);
10369
+ if (request && !this.cancelled) return this.startHandOff(request);
10370
+ if (request) {
10371
+ logger2.debug(`OrchestratingDriver: stopped before the hand-off to "${request.to}" started`);
10372
+ }
10362
10373
  const active = this.agentSession.getActive();
10363
10374
  if (!active) return void 0;
10364
10375
  const frame = this.topFrameFor(active.name);