@genesislcap/ai-assistant 15.52.0 → 15.53.0-GENC-1662.1

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 (36) hide show
  1. package/dist/ai-assistant.api.json +251 -0
  2. package/dist/ai-assistant.d.ts +68 -0
  3. package/dist/chat-driver.cjs +26 -0
  4. package/dist/chat-driver.cjs.map +2 -2
  5. package/dist/chat-driver.mjs +26 -0
  6. package/dist/chat-driver.mjs.map +2 -2
  7. package/dist/custom-elements.json +639 -514
  8. package/dist/dts/components/ai-driver/ai-driver.d.ts +22 -0
  9. package/dist/dts/components/ai-driver/ai-driver.d.ts.map +1 -1
  10. package/dist/dts/components/chat-bubble/chat-bubble.d.ts +2 -0
  11. package/dist/dts/components/chat-bubble/chat-bubble.d.ts.map +1 -1
  12. package/dist/dts/components/orchestrating-driver/orchestrating-driver.d.ts +11 -0
  13. package/dist/dts/components/orchestrating-driver/orchestrating-driver.d.ts.map +1 -1
  14. package/dist/dts/config/config.d.ts +18 -0
  15. package/dist/dts/config/config.d.ts.map +1 -1
  16. package/dist/dts/config/define-stateful-agent.d.ts +5 -0
  17. package/dist/dts/config/define-stateful-agent.d.ts.map +1 -1
  18. package/dist/dts/main/main.d.ts +12 -0
  19. package/dist/dts/main/main.d.ts.map +1 -1
  20. package/dist/dts/state/debug-event-log.d.ts +1 -1
  21. package/dist/dts/state/debug-event-log.d.ts.map +1 -1
  22. package/dist/dts/state/persistence/session-persister.d.ts +24 -1
  23. package/dist/dts/state/persistence/session-persister.d.ts.map +1 -1
  24. package/dist/dts/state/persistence/session-snapshot.d.ts +13 -0
  25. package/dist/dts/state/persistence/session-snapshot.d.ts.map +1 -1
  26. package/dist/dts/utils/message-partition.d.ts +9 -1
  27. package/dist/dts/utils/message-partition.d.ts.map +1 -1
  28. package/dist/esm/components/chat-bubble/chat-bubble.js +31 -15
  29. package/dist/esm/components/orchestrating-driver/orchestrating-driver.js +26 -0
  30. package/dist/esm/config/define-stateful-agent.js +1 -0
  31. package/dist/esm/main/main.js +73 -22
  32. package/dist/esm/state/debug-event-log.js +2 -0
  33. package/dist/esm/state/persistence/session-persister.js +37 -15
  34. package/dist/esm/state/persistence/session-snapshot.js +41 -0
  35. package/dist/esm/utils/message-partition.js +11 -2
  36. package/package.json +17 -17
@@ -3174,6 +3174,51 @@
3174
3174
  ],
3175
3175
  "name": "canCompact"
3176
3176
  },
3177
+ {
3178
+ "kind": "MethodSignature",
3179
+ "canonicalReference": "@genesislcap/ai-assistant!AiDriver#canResumeRestoredFlow:member(1)",
3180
+ "docComment": "/**\n * Whether a restore should resume the flow `agentName` owns (GENC-1662): the agent is configured here and has not opted out with `resumeOnRestore: false`. Pure — no activation. Lets the restore pick its divider wording before it hands the transcript over.\n *\n * Optional: a driver without it never resumes.\n *\n * @beta\n */\n",
3181
+ "excerptTokens": [
3182
+ {
3183
+ "kind": "Content",
3184
+ "text": "canResumeRestoredFlow?(agentName: "
3185
+ },
3186
+ {
3187
+ "kind": "Content",
3188
+ "text": "string"
3189
+ },
3190
+ {
3191
+ "kind": "Content",
3192
+ "text": "): "
3193
+ },
3194
+ {
3195
+ "kind": "Content",
3196
+ "text": "boolean"
3197
+ },
3198
+ {
3199
+ "kind": "Content",
3200
+ "text": ";"
3201
+ }
3202
+ ],
3203
+ "isOptional": true,
3204
+ "returnTypeTokenRange": {
3205
+ "startIndex": 3,
3206
+ "endIndex": 4
3207
+ },
3208
+ "releaseTag": "Beta",
3209
+ "overloadIndex": 1,
3210
+ "parameters": [
3211
+ {
3212
+ "parameterName": "agentName",
3213
+ "parameterTypeTokenRange": {
3214
+ "startIndex": 1,
3215
+ "endIndex": 2
3216
+ },
3217
+ "isOptional": false
3218
+ }
3219
+ ],
3220
+ "name": "canResumeRestoredFlow"
3221
+ },
3177
3222
  {
3178
3223
  "kind": "MethodSignature",
3179
3224
  "canonicalReference": "@genesislcap/ai-assistant!AiDriver#compact:member(1)",
@@ -4174,6 +4219,70 @@
4174
4219
  ],
4175
4220
  "name": "restoreCondensePolicies"
4176
4221
  },
4222
+ {
4223
+ "kind": "MethodSignature",
4224
+ "canonicalReference": "@genesislcap/ai-assistant!AiDriver#resumeRestoredFlow:member(1)",
4225
+ "docComment": "/**\n * Bring a restored session's flow back to life (GENC-1662). Activates the locked agent — the flow owner or the user's pin — so its `init({ restored })` runs now rather than on the next message, then, when `transientPrimer` is given and the agent has not opted out, runs one turn from the restored history with that primer, exactly like a continuation.\n *\n * Returns the turn's result when one ran, `undefined` otherwise (nothing locked, the locked agent is not configured, or no primer). Never throws for those cases.\n *\n * @beta\n */\n",
4226
+ "excerptTokens": [
4227
+ {
4228
+ "kind": "Content",
4229
+ "text": "resumeRestoredFlow?(transientPrimer?: "
4230
+ },
4231
+ {
4232
+ "kind": "Reference",
4233
+ "text": "ChatMessage",
4234
+ "canonicalReference": "@genesislcap/foundation-ai!ChatMessage:interface"
4235
+ },
4236
+ {
4237
+ "kind": "Content",
4238
+ "text": "[]"
4239
+ },
4240
+ {
4241
+ "kind": "Content",
4242
+ "text": "): "
4243
+ },
4244
+ {
4245
+ "kind": "Reference",
4246
+ "text": "Promise",
4247
+ "canonicalReference": "!Promise:interface"
4248
+ },
4249
+ {
4250
+ "kind": "Content",
4251
+ "text": "<"
4252
+ },
4253
+ {
4254
+ "kind": "Reference",
4255
+ "text": "ChatDriverResult",
4256
+ "canonicalReference": "@genesislcap/foundation-ai!ChatDriverResult:type"
4257
+ },
4258
+ {
4259
+ "kind": "Content",
4260
+ "text": " | undefined>"
4261
+ },
4262
+ {
4263
+ "kind": "Content",
4264
+ "text": ";"
4265
+ }
4266
+ ],
4267
+ "isOptional": true,
4268
+ "returnTypeTokenRange": {
4269
+ "startIndex": 4,
4270
+ "endIndex": 8
4271
+ },
4272
+ "releaseTag": "Beta",
4273
+ "overloadIndex": 1,
4274
+ "parameters": [
4275
+ {
4276
+ "parameterName": "transientPrimer",
4277
+ "parameterTypeTokenRange": {
4278
+ "startIndex": 1,
4279
+ "endIndex": 3
4280
+ },
4281
+ "isOptional": true
4282
+ }
4283
+ ],
4284
+ "name": "resumeRestoredFlow"
4285
+ },
4177
4286
  {
4178
4287
  "kind": "MethodSignature",
4179
4288
  "canonicalReference": "@genesislcap/ai-assistant!AiDriver#sendMessage:member(1)",
@@ -18324,6 +18433,54 @@
18324
18433
  "isAbstract": false,
18325
18434
  "name": "canCompact"
18326
18435
  },
18436
+ {
18437
+ "kind": "Method",
18438
+ "canonicalReference": "@genesislcap/ai-assistant!OrchestratingDriver#canResumeRestoredFlow:member(1)",
18439
+ "docComment": "/**\n * Whether a restore should resume the flow `agentName` owns (GENC-1662): the agent is configured here and has not opted out with `resumeOnRestore: false`. Pure — no activation. Lets the restore pick its divider wording before it hands the transcript over.\n *\n * Optional: a driver without it never resumes.\n */\n",
18440
+ "excerptTokens": [
18441
+ {
18442
+ "kind": "Content",
18443
+ "text": "canResumeRestoredFlow(agentName: "
18444
+ },
18445
+ {
18446
+ "kind": "Content",
18447
+ "text": "string"
18448
+ },
18449
+ {
18450
+ "kind": "Content",
18451
+ "text": "): "
18452
+ },
18453
+ {
18454
+ "kind": "Content",
18455
+ "text": "boolean"
18456
+ },
18457
+ {
18458
+ "kind": "Content",
18459
+ "text": ";"
18460
+ }
18461
+ ],
18462
+ "isStatic": false,
18463
+ "returnTypeTokenRange": {
18464
+ "startIndex": 3,
18465
+ "endIndex": 4
18466
+ },
18467
+ "releaseTag": "Beta",
18468
+ "isProtected": false,
18469
+ "overloadIndex": 1,
18470
+ "parameters": [
18471
+ {
18472
+ "parameterName": "agentName",
18473
+ "parameterTypeTokenRange": {
18474
+ "startIndex": 1,
18475
+ "endIndex": 2
18476
+ },
18477
+ "isOptional": false
18478
+ }
18479
+ ],
18480
+ "isOptional": false,
18481
+ "isAbstract": false,
18482
+ "name": "canResumeRestoredFlow"
18483
+ },
18327
18484
  {
18328
18485
  "kind": "Method",
18329
18486
  "canonicalReference": "@genesislcap/ai-assistant!OrchestratingDriver#compact:member(1)",
@@ -19383,6 +19540,73 @@
19383
19540
  "isAbstract": false,
19384
19541
  "name": "restoreCondensePolicies"
19385
19542
  },
19543
+ {
19544
+ "kind": "Method",
19545
+ "canonicalReference": "@genesislcap/ai-assistant!OrchestratingDriver#resumeRestoredFlow:member(1)",
19546
+ "docComment": "/**\n * Bring a restored session's flow back to life (GENC-1662). Activates the locked agent — the flow owner or the user's pin — so its `init({ restored })` runs now rather than on the next message, then, when `transientPrimer` is given and the agent has not opted out, runs one turn from the restored history with that primer, exactly like a continuation.\n *\n * Returns the turn's result when one ran, `undefined` otherwise (nothing locked, the locked agent is not configured, or no primer). Never throws for those cases.\n */\n",
19547
+ "excerptTokens": [
19548
+ {
19549
+ "kind": "Content",
19550
+ "text": "resumeRestoredFlow(transientPrimer?: "
19551
+ },
19552
+ {
19553
+ "kind": "Reference",
19554
+ "text": "ChatMessage",
19555
+ "canonicalReference": "@genesislcap/foundation-ai!ChatMessage:interface"
19556
+ },
19557
+ {
19558
+ "kind": "Content",
19559
+ "text": "[]"
19560
+ },
19561
+ {
19562
+ "kind": "Content",
19563
+ "text": "): "
19564
+ },
19565
+ {
19566
+ "kind": "Reference",
19567
+ "text": "Promise",
19568
+ "canonicalReference": "!Promise:interface"
19569
+ },
19570
+ {
19571
+ "kind": "Content",
19572
+ "text": "<"
19573
+ },
19574
+ {
19575
+ "kind": "Reference",
19576
+ "text": "ChatDriverResult",
19577
+ "canonicalReference": "@genesislcap/foundation-ai!ChatDriverResult:type"
19578
+ },
19579
+ {
19580
+ "kind": "Content",
19581
+ "text": " | undefined>"
19582
+ },
19583
+ {
19584
+ "kind": "Content",
19585
+ "text": ";"
19586
+ }
19587
+ ],
19588
+ "isStatic": false,
19589
+ "returnTypeTokenRange": {
19590
+ "startIndex": 4,
19591
+ "endIndex": 8
19592
+ },
19593
+ "releaseTag": "Beta",
19594
+ "isProtected": false,
19595
+ "overloadIndex": 1,
19596
+ "parameters": [
19597
+ {
19598
+ "parameterName": "transientPrimer",
19599
+ "parameterTypeTokenRange": {
19600
+ "startIndex": 1,
19601
+ "endIndex": 3
19602
+ },
19603
+ "isOptional": true
19604
+ }
19605
+ ],
19606
+ "isOptional": false,
19607
+ "isAbstract": false,
19608
+ "name": "resumeRestoredFlow"
19609
+ },
19386
19610
  {
19387
19611
  "kind": "Method",
19388
19612
  "canonicalReference": "@genesislcap/ai-assistant!OrchestratingDriver#sendMessage:member(1)",
@@ -22990,6 +23214,33 @@
22990
23214
  "endIndex": 6
22991
23215
  }
22992
23216
  },
23217
+ {
23218
+ "kind": "PropertySignature",
23219
+ "canonicalReference": "@genesislcap/ai-assistant!StatefulAgentInit#resumeOnRestore:member",
23220
+ "docComment": "/**\n * Whether a restored session this agent owns continues on its own after a reload — see `AgentConfig.resumeOnRestore`, which this is passed straight through to. Defaults to `true`.\n */\n",
23221
+ "excerptTokens": [
23222
+ {
23223
+ "kind": "Content",
23224
+ "text": "resumeOnRestore?: "
23225
+ },
23226
+ {
23227
+ "kind": "Content",
23228
+ "text": "boolean"
23229
+ },
23230
+ {
23231
+ "kind": "Content",
23232
+ "text": ";"
23233
+ }
23234
+ ],
23235
+ "isReadonly": false,
23236
+ "isOptional": true,
23237
+ "releaseTag": "Beta",
23238
+ "name": "resumeOnRestore",
23239
+ "propertyTypeTokenRange": {
23240
+ "startIndex": 1,
23241
+ "endIndex": 2
23242
+ }
23243
+ },
22993
23244
  {
22994
23245
  "kind": "PropertySignature",
22995
23246
  "canonicalReference": "@genesislcap/ai-assistant!StatefulAgentInit#serialize:member",
@@ -803,6 +803,28 @@ export declare interface AiDriver extends EventTarget {
803
803
  * shipped drivers implement it and a host no longer has to feature-detect before restoring.
804
804
  */
805
805
  primeRestoredAgentState(snapshots: Record<string, unknown>): void;
806
+ /**
807
+ * Whether a restore should resume the flow `agentName` owns (GENC-1662): the agent is configured
808
+ * here and has not opted out with `resumeOnRestore: false`. Pure — no activation. Lets the restore
809
+ * pick its divider wording before it hands the transcript over.
810
+ *
811
+ * Optional: a driver without it never resumes.
812
+ *
813
+ * @beta
814
+ */
815
+ canResumeRestoredFlow?(agentName: string): boolean;
816
+ /**
817
+ * Bring a restored session's flow back to life (GENC-1662). Activates the locked agent — the
818
+ * flow owner or the user's pin — so its `init({ restored })` runs now rather than on the next
819
+ * message, then, when `transientPrimer` is given and the agent has not opted out, runs one turn
820
+ * from the restored history with that primer, exactly like a continuation.
821
+ *
822
+ * Returns the turn's result when one ran, `undefined` otherwise (nothing locked, the locked agent
823
+ * is not configured, or no primer). Never throws for those cases.
824
+ *
825
+ * @beta
826
+ */
827
+ resumeRestoredFlow?(transientPrimer?: ChatMessage[]): Promise<ChatDriverResult | undefined>;
806
828
  /**
807
829
  * Return the full, unredacted conversation history.
808
830
  */
@@ -1434,6 +1456,24 @@ declare interface BaseAgentConfig {
1434
1456
  * @beta
1435
1457
  */
1436
1458
  notResumableMessage?: string;
1459
+ /**
1460
+ * Whether a restored session that this agent owns continues on its own after a page reload
1461
+ * (GENC-1662). Defaults to `true`; set `false` to keep the old behaviour of waiting for the user.
1462
+ *
1463
+ * Applies when the reload interrupted a turn: the restore trims an unanswered tool call, a pending
1464
+ * interaction or a half-streamed reply off the transcript, because a live widget is a promise inside
1465
+ * a running tool handler and cannot be persisted. With this on, the restore re-activates the agent
1466
+ * and runs one turn from the restored history, with a transient note naming the call that never
1467
+ * completed. That turn is a fresh model decision — it usually re-asks the same question, but may
1468
+ * word it differently or pick another valid action.
1469
+ *
1470
+ * The agent is re-activated on restore either way, so a stateful agent's `init({ restored })` runs
1471
+ * straight after the reload rather than on the next message. Never consulted for a session restored
1472
+ * as interrupted ({@link BaseAgentConfig.resumable} returned `false`).
1473
+ *
1474
+ * @beta
1475
+ */
1476
+ resumeOnRestore?: boolean;
1437
1477
  /**
1438
1478
  * Tokens this agent wants kept free for one of its turns (GENC-1567).
1439
1479
  * Overrides `chatConfig.context.reserveTokens` while this agent is active;
@@ -4945,6 +4985,13 @@ export declare class FoundationAiAssistant extends GenesisElement {
4945
4985
  * persistence is (now) on.
4946
4986
  */
4947
4987
  private initPersistenceForNewStore;
4988
+ /**
4989
+ * Bring a restored flow back to life (GENC-1662). Always re-activates the flow owner, so a
4990
+ * stateful agent's `init({ restored })` — and anything the host hangs off it, like a progress
4991
+ * stepper — runs straight after the reload instead of on the next message. When the reload cut a
4992
+ * turn short, also runs one turn from the restored history, shown as busy exactly as a send is.
4993
+ */
4994
+ private resumeRestoredFlow;
4948
4995
  triggerFileInput(): void;
4949
4996
  handleFileSelect(e: Event): void;
4950
4997
  removeAttachment(attachment: ChatAttachment): void;
@@ -4991,6 +5038,11 @@ export declare class FoundationAiAssistant extends GenesisElement {
4991
5038
  */
4992
5039
  private _pendingSendPrompt?;
4993
5040
  private send;
5041
+ /**
5042
+ * The post-turn settle shared by `send()` and a resumed restore turn: back to idle through
5043
+ * the session ref captured at turn start, then the cleanup the state setter would have done.
5044
+ */
5045
+ private settleAfterTurn;
4994
5046
  onChatHeaderMouseDown(e: MouseEvent): void;
4995
5047
  handleInteractionCompleted(e: Event): void;
4996
5048
  /**
@@ -5493,6 +5545,17 @@ export declare class OrchestratingDriver extends EventTarget implements AiDriver
5493
5545
  continueFromHistory(transientPrimer?: ChatMessage[]): Promise<ChatDriverResult>;
5494
5546
  /** {@inheritDoc AiDriver.primeRestoredAgentState} */
5495
5547
  primeRestoredAgentState(snapshots: Record<string, unknown>): void;
5548
+ /** {@inheritDoc AiDriver.canResumeRestoredFlow} */
5549
+ canResumeRestoredFlow(agentName: string): boolean;
5550
+ /**
5551
+ * {@inheritDoc AiDriver.resumeRestoredFlow}
5552
+ *
5553
+ * Installs the locked agent directly rather than through `handleTurn`: there is no user message
5554
+ * to classify, and a restored lock already says which agent owns the flow. `continueFromHistory`
5555
+ * on its own would not do — it neither routes nor installs, so it would run on whatever agent
5556
+ * happened to be installed (none, straight after a reload).
5557
+ */
5558
+ resumeRestoredFlow(transientPrimer?: ChatMessage[]): Promise<ChatDriverResult | undefined>;
5496
5559
  /**
5497
5560
  * {@inheritDoc AiDriver.getContextReserve}
5498
5561
  *
@@ -6400,6 +6463,11 @@ export declare interface StatefulAgentInit<S> {
6400
6463
  * `false`. Falls back to a built-in default when omitted.
6401
6464
  */
6402
6465
  notResumableMessage?: string;
6466
+ /**
6467
+ * Whether a restored session this agent owns continues on its own after a reload — see
6468
+ * `AgentConfig.resumeOnRestore`, which this is passed straight through to. Defaults to `true`.
6469
+ */
6470
+ resumeOnRestore?: boolean;
6403
6471
  }
6404
6472
 
6405
6473
  /**
@@ -4114,6 +4114,8 @@ var META_EVENT_IMPORTANCE = {
4114
4114
  "session.switched": "low",
4115
4115
  "session.switch-deferred": "low",
4116
4116
  "persistence.restored": "normal",
4117
+ // Whether a restored flow will be re-activated and resumed (GENC-1662), and how much the trim cut.
4118
+ "persistence.resume-planned": "normal",
4117
4119
  "persistence.suppressed": "normal",
4118
4120
  "persistence.not-resumable": "normal",
4119
4121
  "driver.wired": "low",
@@ -8705,6 +8707,29 @@ var OrchestratingDriver = class extends EventTarget {
8705
8707
  primeRestoredAgentState(snapshots) {
8706
8708
  this.agentSession.primeRestoredStates(snapshots);
8707
8709
  }
8710
+ /** {@inheritDoc AiDriver.canResumeRestoredFlow} */
8711
+ canResumeRestoredFlow(agentName) {
8712
+ const agent = this.agents.find((a) => a.name === agentName);
8713
+ return !!agent && agent.resumeOnRestore !== false;
8714
+ }
8715
+ /**
8716
+ * {@inheritDoc AiDriver.resumeRestoredFlow}
8717
+ *
8718
+ * Installs the locked agent directly rather than through `handleTurn`: there is no user message
8719
+ * to classify, and a restored lock already says which agent owns the flow. `continueFromHistory`
8720
+ * on its own would not do — it neither routes nor installs, so it would run on whatever agent
8721
+ * happened to be installed (none, straight after a reload).
8722
+ */
8723
+ async resumeRestoredFlow(transientPrimer) {
8724
+ const agent = this.resolvePinnedAgent();
8725
+ if (!agent) return void 0;
8726
+ this.cancelled = false;
8727
+ await this.installAgent(agent);
8728
+ if (!transientPrimer?.length || agent.resumeOnRestore === false || this.cancelled) {
8729
+ return void 0;
8730
+ }
8731
+ return this.chatDriver.continueFromHistory(transientPrimer);
8732
+ }
8708
8733
  /**
8709
8734
  * {@inheritDoc AiDriver.getContextReserve}
8710
8735
  *
@@ -9179,6 +9204,7 @@ function defineStatefulAgent(opts) {
9179
9204
  onUnresolvedTool: wrappedOnUnresolvedTool,
9180
9205
  resumable: wrappedResumable,
9181
9206
  notResumableMessage: opts.notResumableMessage,
9207
+ resumeOnRestore: opts.resumeOnRestore,
9182
9208
  contextReserve: opts.contextReserve,
9183
9209
  onActivate: async (ctx) => {
9184
9210
  state = await opts.init(ctx);