@genesislcap/ai-assistant 15.58.2 → 15.60.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.
Files changed (79) hide show
  1. package/dist/ai-assistant.api.json +10096 -6986
  2. package/dist/ai-assistant.d.ts +562 -101
  3. package/dist/chat-driver.cjs +624 -207
  4. package/dist/chat-driver.cjs.map +4 -4
  5. package/dist/chat-driver.mjs +624 -207
  6. package/dist/chat-driver.mjs.map +4 -4
  7. package/dist/custom-elements.json +5426 -3570
  8. package/dist/dts/components/agent-session/agent-session.d.ts +19 -3
  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 +120 -10
  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 +103 -0
  13. package/dist/dts/components/ai-driver/base-driver-decorator.d.ts.map +1 -0
  14. package/dist/dts/components/ai-driver/index.d.ts +3 -1
  15. package/dist/dts/components/ai-driver/index.d.ts.map +1 -1
  16. package/dist/dts/components/chat-driver/chat-driver.d.ts +84 -8
  17. package/dist/dts/components/chat-driver/chat-driver.d.ts.map +1 -1
  18. package/dist/dts/components/chat-driver/interaction-controller.d.ts +37 -3
  19. package/dist/dts/components/chat-driver/interaction-controller.d.ts.map +1 -1
  20. package/dist/dts/components/message-feedback/index.d.ts +2 -0
  21. package/dist/dts/components/message-feedback/index.d.ts.map +1 -0
  22. package/dist/dts/components/message-feedback/message-feedback.d.ts +61 -0
  23. package/dist/dts/components/message-feedback/message-feedback.d.ts.map +1 -0
  24. package/dist/dts/components/message-feedback/message-feedback.styles.d.ts +2 -0
  25. package/dist/dts/components/message-feedback/message-feedback.styles.d.ts.map +1 -0
  26. package/dist/dts/components/message-feedback/message-feedback.template.d.ts +4 -0
  27. package/dist/dts/components/message-feedback/message-feedback.template.d.ts.map +1 -0
  28. package/dist/dts/components/orchestrating-driver/orchestrating-driver.d.ts +30 -93
  29. package/dist/dts/components/orchestrating-driver/orchestrating-driver.d.ts.map +1 -1
  30. package/dist/dts/index.d.ts +4 -1
  31. package/dist/dts/index.d.ts.map +1 -1
  32. package/dist/dts/main/main.d.ts +21 -5
  33. package/dist/dts/main/main.d.ts.map +1 -1
  34. package/dist/dts/main/main.styles.d.ts.map +1 -1
  35. package/dist/dts/main/main.template.d.ts.map +1 -1
  36. package/dist/dts/react.d.ts +10 -0
  37. package/dist/dts/state/debug-event-log.d.ts +1 -1
  38. package/dist/dts/state/debug-event-log.d.ts.map +1 -1
  39. package/dist/dts/state/interaction-context.d.ts +7 -1
  40. package/dist/dts/state/interaction-context.d.ts.map +1 -1
  41. package/dist/dts/state/persistence/session-persister.d.ts.map +1 -1
  42. package/dist/dts/suggestions/generate-suggestions.d.ts.map +1 -1
  43. package/dist/dts/types/handler-capability.d.ts +28 -0
  44. package/dist/dts/types/handler-capability.d.ts.map +1 -0
  45. package/dist/dts/types/interaction-context.d.ts +16 -0
  46. package/dist/dts/types/interaction-context.d.ts.map +1 -1
  47. package/dist/dts/types/interaction-interceptor.d.ts +109 -0
  48. package/dist/dts/types/interaction-interceptor.d.ts.map +1 -0
  49. package/dist/dts/utils/delegated-message.d.ts +52 -0
  50. package/dist/dts/utils/delegated-message.d.ts.map +1 -0
  51. package/dist/dts/utils/history-transform.d.ts.map +1 -1
  52. package/dist/esm/components/agent-session/agent-session.js +17 -0
  53. package/dist/esm/components/ai-driver/ai-driver.js +21 -1
  54. package/dist/esm/components/ai-driver/base-driver-decorator.js +211 -0
  55. package/dist/esm/components/ai-driver/index.js +2 -1
  56. package/dist/esm/components/chat-driver/chat-driver.js +195 -14
  57. package/dist/esm/components/chat-driver/interaction-controller.js +168 -14
  58. package/dist/esm/components/message-feedback/index.js +1 -0
  59. package/dist/esm/components/message-feedback/message-feedback.js +241 -0
  60. package/dist/esm/components/message-feedback/message-feedback.styles.js +94 -0
  61. package/dist/esm/components/message-feedback/message-feedback.template.js +80 -0
  62. package/dist/esm/components/orchestrating-driver/orchestrating-driver.js +72 -196
  63. package/dist/esm/index.js +1 -0
  64. package/dist/esm/main/main.js +123 -78
  65. package/dist/esm/main/main.styles.js +27 -0
  66. package/dist/esm/main/main.template.js +13 -0
  67. package/dist/esm/state/debug-event-log.js +7 -2
  68. package/dist/esm/state/interaction-context.js +11 -0
  69. package/dist/esm/state/persistence/session-persister.js +5 -6
  70. package/dist/esm/suggestions/generate-suggestions.js +8 -1
  71. package/dist/esm/types/handler-capability.js +1 -0
  72. package/dist/esm/types/interaction-interceptor.js +1 -0
  73. package/dist/esm/utils/delegated-message.js +25 -0
  74. package/dist/esm/utils/history-transform.js +12 -1
  75. package/dist/react.cjs +7 -0
  76. package/dist/react.mjs +6 -0
  77. package/package.json +17 -17
  78. package/sandbox/README.md +1 -1
  79. package/sandbox/sandbox.ts +35 -0
@@ -1,4 +1,4 @@
1
- import type { InteractionContext } from '../types/interaction-context';
1
+ import type { InteractionContext, InteractionHolder } from '../types/interaction-context';
2
2
  /**
3
3
  * A created {@link InteractionContext} plus the host-only `dispose` handle. The
4
4
  * driver keeps the handle (so it can tear the context down on resolve/evict) and
@@ -14,6 +14,12 @@ export interface InteractionContextHandle {
14
14
  * and on driver teardown — never on element unmount.
15
15
  */
16
16
  dispose(): void;
17
+ /**
18
+ * Change {@link InteractionContext.heldBy} and notify subscribers (GENC-1660). Host-only, like
19
+ * `dispose`: the controller reaches it through the claimant's `InteractionHold`. A no-op that
20
+ * returns `false` once the context is disposed, or when the holder is unchanged.
21
+ */
22
+ setHeldBy(holder: InteractionHolder): boolean;
17
23
  }
18
24
  /**
19
25
  * Create a live, per-interaction context (GENC-1390). Framework-agnostic: the
@@ -1 +1 @@
1
- {"version":3,"file":"interaction-context.d.ts","sourceRoot":"","sources":["../../../src/state/interaction-context.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,8BAA8B,CAAC;AAGvE;;;;;;GAMG;AACH,MAAM,WAAW,wBAAwB;IACvC,QAAQ,CAAC,OAAO,EAAE,kBAAkB,CAAC;IACrC;;;;OAIG;IACH,OAAO,IAAI,IAAI,CAAC;CACjB;AAED;;;;;;GAMG;AACH,wBAAgB,wBAAwB,CAAC,aAAa,EAAE,MAAM,GAAG,wBAAwB,CAyExF"}
1
+ {"version":3,"file":"interaction-context.d.ts","sourceRoot":"","sources":["../../../src/state/interaction-context.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AAG1F;;;;;;GAMG;AACH,MAAM,WAAW,wBAAwB;IACvC,QAAQ,CAAC,OAAO,EAAE,kBAAkB,CAAC;IACrC;;;;OAIG;IACH,OAAO,IAAI,IAAI,CAAC;IAChB;;;;OAIG;IACH,SAAS,CAAC,MAAM,EAAE,iBAAiB,GAAG,OAAO,CAAC;CAC/C;AAED;;;;;;GAMG;AACH,wBAAgB,wBAAwB,CAAC,aAAa,EAAE,MAAM,GAAG,wBAAwB,CAmFxF"}
@@ -1 +1 @@
1
- {"version":3,"file":"session-persister.d.ts","sourceRoot":"","sources":["../../../../src/state/persistence/session-persister.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,sCAAsC,CAAC;AAarE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAC3D,OAAO,EAAyB,KAAK,eAAe,EAAE,MAAM,eAAe,CAAC;AAE5E,OAAO,KAAK,EAAE,wBAAwB,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAC;AA+CnG;;;;;GAKG;AACH,MAAM,WAAW,cAAc;IAC7B,2FAA2F;IAC3F,UAAU,EAAE,MAAM,CAAC;IACnB;;;OAGG;IACH,kBAAkB,EAAE,MAAM,GAAG,IAAI,CAAC;IAClC;;;;;OAKG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED;;;;;;;GAOG;AACH,MAAM,WAA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,CAAC;IAYvC;;;;;;;;;;;;;;;;;;OAkBG;IACH,OAAO,CAAC,uBAAuB;IA6C/B,sEAAsE;IACtE,OAAO,IAAI,IAAI;CAMhB"}
1
+ {"version":3,"file":"session-persister.d.ts","sourceRoot":"","sources":["../../../../src/state/persistence/session-persister.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,sCAAsC,CAAC;AAYrE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAC3D,OAAO,EAAyB,KAAK,eAAe,EAAE,MAAM,eAAe,CAAC;AAE5E,OAAO,KAAK,EAAE,wBAAwB,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAC;AA+CnG;;;;;GAKG;AACH,MAAM,WAAW,cAAc;IAC7B,2FAA2F;IAC3F,UAAU,EAAE,MAAM,CAAC;IACnB;;;OAGG;IACH,kBAAkB,EAAE,MAAM,GAAG,IAAI,CAAC;IAClC;;;;;OAKG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED;;;;;;;GAOG;AACH,MAAM,WAAW,oBAAoB;IACnC,8DAA8D;IAC9D,QAAQ,EAAE,MAAM,CAAC;IACjB,oFAAoF;IACpF,cAAc,EAAE,MAAM,wBAAwB,CAAC;IAC/C,+EAA+E;IAC/E,aAAa,EAAE,MAAM,MAAM,EAAE,CAAC;IAC9B,oEAAoE;IACpE,SAAS,EAAE,MAAM,QAAQ,GAAG,SAAS,CAAC;IACtC,mEAAmE;IACnE,QAAQ,EAAE,MAAM,kBAAkB,GAAG,SAAS,CAAC;IAC/C;;;;OAIG;IACH,oBAAoB,EAAE,MAAM,eAAe,EAAE,CAAC;IAC9C;;;;;OAKG;IACH,mBAAmB,CAAC,EAAE,CAAC,MAAM,EAAE;QAC7B,oEAAoE;QACpE,eAAe,EAAE,MAAM,CAAC;QACxB,mEAAmE;QACnE,WAAW,CAAC,EAAE,MAAM,CAAC;QACrB,+DAA+D;QAC/D,MAAM,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;;;;;;OASG;IACH,OAAO,CAAC,iBAAiB;IAUzB;;;;;;;;;OASG;YACW,gBAAgB;IAsB9B;;;;;;;;;;;;;;;;OAgBG;IACH,OAAO,CAAC,iBAAiB;IAQzB;;;;;;;;;;OAUG;IACH,OAAO,CAAC,yBAAyB;IAiBjC;;;;OAIG;YACW,cAAc;IAiO5B;;;;;;;;;;OAUG;IACG,OAAO,IAAI,OAAO,CAAC,cAAc,GAAG,SAAS,CAAC;IA2MpD;;;;;OAKG;IACH,cAAc,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI;IAkBpC;;;;;;;OAOG;IACH,OAAO,CAAC,uBAAuB;IAU/B;;;;OAIG;IACG,gBAAgB,IAAI,OAAO,CAAC,IAAI,CAAC;IAmBvC;;;;OAIG;IACG,eAAe,IAAI,OAAO,CAAC,IAAI,CAAC;IAatC;;;;;OAKG;IACH,eAAe,CAAC,KAAK,EAAE,kBAAkB,GAAG,IAAI;IAchD;;;;;;OAMG;IACH,mBAAmB,IAAI,IAAI;IAiB3B;;;;;;OAMG;IACG,gBAAgB,IAAI,OAAO,CAAC,IAAI,CAAC;IAYvC;;;;;;;;;;;;;;;;;;OAkBG;IACH,OAAO,CAAC,uBAAuB;IA6C/B,sEAAsE;IACtE,OAAO,IAAI,IAAI;CAMhB"}
@@ -1 +1 @@
1
- {"version":3,"file":"generate-suggestions.d.ts","sourceRoot":"","sources":["../../../src/suggestions/generate-suggestions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,kBAAkB,EAClB,WAAW,EACX,kBAAkB,EACnB,MAAM,4BAA4B,CAAC;AACpC,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mCAAmC,CAAC;AAOzE,wEAAwE;AACxE,MAAM,WAAW,kBAAkB;IACjC,mFAAmF;IACnF,QAAQ,EAAE,kBAAkB,CAAC;IAC7B,gFAAgF;IAChF,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,4BAA4B;IAC5B,eAAe,EAAE,kBAAkB,EAAE,CAAC;CACvC;AAiDD;;;;;;;GAOG;AACH,eAAO,MAAM,yBAAyB,QAE+B,CAAC;AAEtE,6FAA6F;AAC7F,wBAAgB,sBAAsB,CACpC,GAAG,EAAE,kBAAkB,EACvB,OAAO,EAAE,WAAW,EAAE,EACtB,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,MAAM,EACb,YAAY,CAAC,EAAE,eAAe,EAAE,GAC/B,MAAM,CAsCR;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,CAetE;AAED;;;;;GAKG;AACH,wBAAsB,mBAAmB,CACvC,GAAG,EAAE,kBAAkB,EACvB,OAAO,EAAE,WAAW,EAAE,EACtB,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,MAAM,EACb,YAAY,CAAC,EAAE,eAAe,EAAE,GAC/B,OAAO,CAAC,MAAM,EAAE,CAAC,CAWnB"}
1
+ {"version":3,"file":"generate-suggestions.d.ts","sourceRoot":"","sources":["../../../src/suggestions/generate-suggestions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,kBAAkB,EAClB,WAAW,EACX,kBAAkB,EACnB,MAAM,4BAA4B,CAAC;AACpC,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mCAAmC,CAAC;AAQzE,wEAAwE;AACxE,MAAM,WAAW,kBAAkB;IACjC,mFAAmF;IACnF,QAAQ,EAAE,kBAAkB,CAAC;IAC7B,gFAAgF;IAChF,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,4BAA4B;IAC5B,eAAe,EAAE,kBAAkB,EAAE,CAAC;CACvC;AAiDD;;;;;;;GAOG;AACH,eAAO,MAAM,yBAAyB,QAE+B,CAAC;AAEtE,6FAA6F;AAC7F,wBAAgB,sBAAsB,CACpC,GAAG,EAAE,kBAAkB,EACvB,OAAO,EAAE,WAAW,EAAE,EACtB,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,MAAM,EACb,YAAY,CAAC,EAAE,eAAe,EAAE,GAC/B,MAAM,CA2CR;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,CAetE;AAED;;;;;GAKG;AACH,wBAAsB,mBAAmB,CACvC,GAAG,EAAE,kBAAkB,EACvB,OAAO,EAAE,WAAW,EAAE,EACtB,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,MAAM,EACb,YAAY,CAAC,EAAE,eAAe,EAAE,GAC/B,OAAO,CAAC,MAAM,EAAE,CAAC,CAWnB"}
@@ -0,0 +1,28 @@
1
+ /**
2
+ * Who a handler capability is being built for (GENC-1660): the tool handler about to run.
3
+ *
4
+ * @beta
5
+ */
6
+ export interface HandlerCapabilityScope {
7
+ /**
8
+ * The agents from the root down to the one whose handler is running, outermost first — e.g.
9
+ * `['bootstrap', 'brief-critic']` for a sub-agent's handler. The same shape as
10
+ * `InteractionOpened.ownerPath`, so a decorator scopes the two the same way.
11
+ */
12
+ readonly ownerPath: readonly string[];
13
+ /**
14
+ * The root driver's flow owner when the handler runs, or `null`. A sub-agent has no flow of its
15
+ * own, so it sees its root's: a capability scoped to a flow applies to the flow's sub-agents.
16
+ */
17
+ readonly flowOwner: string | null;
18
+ }
19
+ /**
20
+ * Builds a capability's value for one tool-handler call (GENC-1660). Called per call, so it can
21
+ * reflect the moment; it should be cheap and must not throw (a throw is logged and the capability
22
+ * left out of that call). Returning `undefined` leaves the capability out, which is how a decorator
23
+ * says "not available here".
24
+ *
25
+ * @beta
26
+ */
27
+ export type HandlerCapabilityFactory = (scope: HandlerCapabilityScope) => unknown;
28
+ //# sourceMappingURL=handler-capability.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"handler-capability.d.ts","sourceRoot":"","sources":["../../../src/types/handler-capability.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,WAAW,sBAAsB;IACrC;;;;OAIG;IACH,QAAQ,CAAC,SAAS,EAAE,SAAS,MAAM,EAAE,CAAC;IACtC;;;OAGG;IACH,QAAQ,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;CACnC;AAED;;;;;;;GAOG;AACH,MAAM,MAAM,wBAAwB,GAAG,CAAC,KAAK,EAAE,sBAAsB,KAAK,OAAO,CAAC"}
@@ -1,3 +1,10 @@
1
+ /**
2
+ * Who holds a pending interaction: the person, or the id of the interceptor that claimed it
3
+ * (GENC-1660). See {@link InteractionContext.heldBy}.
4
+ *
5
+ * @beta
6
+ */
7
+ export type InteractionHolder = 'user' | (string & {});
1
8
  /**
2
9
  * A live, per-interaction scratch space owned by the chat host (keyed by
3
10
  * `interactionId`) and handed to a widget on every (re)mount.
@@ -30,6 +37,15 @@
30
37
  export interface InteractionContext<TState extends object = Record<string, unknown>> {
31
38
  /** Stable id of the interaction this context belongs to. */
32
39
  readonly interactionId: string;
40
+ /**
41
+ * Who holds this pending interaction right now: `'user'`, or the id of the interceptor that
42
+ * claimed it, e.g. `'autopilot'` (GENC-1660). `'user'` unless something claimed it.
43
+ *
44
+ * Reactive through {@link InteractionContext.subscribe}: a change calls `notify()`, so a view
45
+ * must re-read it on every notification rather than once on mount, or it would stay hidden after
46
+ * a hand-back. Only the claimant changes it, through its `InteractionHold`.
47
+ */
48
+ readonly heldBy: InteractionHolder;
33
49
  /**
34
50
  * Durable, remount-surviving source of truth for the interaction — a socket
35
51
  * handle, the current phase, a half-typed draft. A plain object, deliberately
@@ -1 +1 @@
1
- {"version":3,"file":"interaction-context.d.ts","sourceRoot":"","sources":["../../../src/types/interaction-context.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,MAAM,WAAW,kBAAkB,CAAC,MAAM,SAAS,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IACjF,4DAA4D;IAC5D,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;IAE/B;;;;;OAKG;IAC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C;CACjC"}
@@ -0,0 +1,109 @@
1
+ import type { InteractionContext } from './interaction-context';
2
+ /**
3
+ * The handle an interceptor uses to move a pending interaction between the person and itself
4
+ * (GENC-1660): to the person when it hands back or is paused, back to itself when resumed.
5
+ *
6
+ * Every interceptor is offered one, but only the claimant's works: on any other interceptor's
7
+ * handle, and after the interaction ends, its members do nothing and return `false`. A claim is
8
+ * granted only once `onInteractionOpened` has returned `'claim'` (it may yet be refused), so the
9
+ * claimant's own handle does nothing until then either: act on it afterwards. Views read the
10
+ * result as `ctx.heldBy`; they never change it.
11
+ *
12
+ * @beta
13
+ */
14
+ export interface InteractionHold {
15
+ /**
16
+ * Give the interaction to the person (`'user'`) or back to the claimant (`'claimant'`). Notifies
17
+ * the context's subscribers and records `interaction.held`. Returns whether it applied.
18
+ */
19
+ set(holder: 'user' | 'claimant'): boolean;
20
+ /**
21
+ * Say what the claimant decided, before it settles the interaction, so the tool that asked is
22
+ * told honestly (GENC-1660). When the interaction then resolves while the claimant holds it, the
23
+ * driver adds a {@link DelegatedDecision} built from this to that tool's result, so the working
24
+ * agent learns the choice was made on the user's behalf and what the user was shown about it.
25
+ *
26
+ * Optional to call: without it the record carries only the framing. Later calls replace earlier
27
+ * ones. Returns `false`, recording nothing, unless this interceptor holds the interaction.
28
+ */
29
+ recordDecision(decision: {
30
+ choice?: string;
31
+ shownToUser?: string;
32
+ }): boolean;
33
+ /**
34
+ * Settle the interaction AS the claimant (GENC-1660). The only route that stamps the claimant as
35
+ * `answeredBy`: an answer through the host's `resolveInteraction` — a click — is the person's,
36
+ * whoever held the interaction at the time, so attribution never depends on a view honouring
37
+ * `heldBy`. Returns `false`, settling nothing, unless this interceptor holds it right now.
38
+ */
39
+ resolve(result: unknown): boolean;
40
+ }
41
+ /**
42
+ * What the working agent is told about an interaction an interceptor answered (GENC-1660): added
43
+ * to the result of the tool call that requested it, as `decidedOnUsersBehalf` on an object result
44
+ * or as a line appended to a text one.
45
+ *
46
+ * Built only from what the platform already holds — the claimant's framing, and the choice and
47
+ * narration it recorded — so the text the person saw and the text the agent is told about are the
48
+ * same string. It never names the claimant, so the agent has nothing to repeat about one.
49
+ *
50
+ * @beta
51
+ */
52
+ export interface DelegatedDecision {
53
+ /** The claimant's {@link InteractionInterceptor.decisionFraming}, e.g. "Decided on the user's behalf". */
54
+ readonly framing: string;
55
+ /** What was chosen, as recorded by the claimant. */
56
+ readonly choice?: string;
57
+ /** What the person was shown about it, verbatim, as the assistant's own words. */
58
+ readonly shownToUser?: string;
59
+ }
60
+ /**
61
+ * A new interaction, as offered to each installed interceptor (GENC-1660).
62
+ *
63
+ * Offered once, at the root driver, after its context exists and before its message is appended,
64
+ * so the first render of its widget already knows who holds it.
65
+ *
66
+ * @beta
67
+ */
68
+ export interface InteractionOpened {
69
+ readonly interactionId: string;
70
+ readonly componentName: string;
71
+ /** The `data` the widget was requested with. */
72
+ readonly data: unknown;
73
+ /**
74
+ * The agents that asked for it, outermost first: the root's active agent, then each sub-agent
75
+ * the request travelled up through — e.g. `['bootstrap', 'brief-critic']`. The last entry is the
76
+ * agent whose tool handler called `requestInteraction`.
77
+ */
78
+ readonly ownerPath: readonly string[];
79
+ /** Set from `InteractionRequestOptions.userOnly`: nobody may claim it. */
80
+ readonly userOnly: boolean;
81
+ /** The interaction's live context, the same object its widget is handed. */
82
+ readonly ctx: InteractionContext;
83
+ /** See {@link InteractionHold}. Works only for the interceptor whose claim was granted. */
84
+ readonly hold: InteractionHold;
85
+ }
86
+ /**
87
+ * Something that is told about every interaction a driver opens, and may answer it instead of the
88
+ * person (GENC-1660). Installed with `AiDriver.addInteractionInterceptor`, typically by a driver
89
+ * decorator such as an autopilot or a test harness.
90
+ *
91
+ * Interceptors are asked outermost first. The first to claim an interaction holds it; the rest
92
+ * observe — they see the same context but their `hold` does nothing. Nobody can claim a `userOnly`
93
+ * interaction. A throwing interceptor is logged and treated as abstaining.
94
+ *
95
+ * @beta
96
+ */
97
+ export interface InteractionInterceptor {
98
+ /** The holder id this interceptor's claims are recorded under, e.g. `'autopilot'`. Not `'user'`. */
99
+ readonly id: string;
100
+ /**
101
+ * How a {@link DelegatedDecision} it settled opens, as the working agent reads it. Must not name
102
+ * the interceptor. Defaults to "Decided on the user's behalf"; an autopilot grounded in a brief
103
+ * would say "Decided on the user's behalf, from their brief".
104
+ */
105
+ readonly decisionFraming?: string;
106
+ /** Return `'claim'` to hold the interaction, or nothing to leave it with the person. */
107
+ onInteractionOpened(opened: InteractionOpened): 'claim' | undefined | void;
108
+ }
109
+ //# sourceMappingURL=interaction-interceptor.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"interaction-interceptor.d.ts","sourceRoot":"","sources":["../../../src/types/interaction-interceptor.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAEhE;;;;;;;;;;;GAWG;AACH,MAAM,WAAW,eAAe;IAC9B;;;OAGG;IACH,GAAG,CAAC,MAAM,EAAE,MAAM,GAAG,UAAU,GAAG,OAAO,CAAC;IAC1C;;;;;;;;OAQG;IACH,cAAc,CAAC,QAAQ,EAAE;QAAE,MAAM,CAAC,EAAE,MAAM,CAAC;QAAC,WAAW,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC;IAC7E;;;;;OAKG;IACH,OAAO,CAAC,MAAM,EAAE,OAAO,GAAG,OAAO,CAAC;CACnC;AAED;;;;;;;;;;GAUG;AACH,MAAM,WAAW,iBAAiB;IAChC,0GAA0G;IAC1G,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,oDAAoD;IACpD,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IACzB,kFAAkF;IAClF,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC;CAC/B;AAED;;;;;;;GAOG;AACH,MAAM,WAAW,iBAAiB;IAChC,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;IAC/B,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;IAC/B,gDAAgD;IAChD,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC;IACvB;;;;OAIG;IACH,QAAQ,CAAC,SAAS,EAAE,SAAS,MAAM,EAAE,CAAC;IACtC,0EAA0E;IAC1E,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC;IAC3B,4EAA4E;IAC5E,QAAQ,CAAC,GAAG,EAAE,kBAAkB,CAAC;IACjC,2FAA2F;IAC3F,QAAQ,CAAC,IAAI,EAAE,eAAe,CAAC;CAChC;AAED;;;;;;;;;;GAUG;AACH,MAAM,WAAW,sBAAsB;IACrC,oGAAoG;IACpG,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB;;;;OAIG;IACH,QAAQ,CAAC,eAAe,CAAC,EAAE,MAAM,CAAC;IAClC,wFAAwF;IACxF,mBAAmB,CAAC,MAAM,EAAE,iBAAiB,GAAG,OAAO,GAAG,SAAS,GAAG,IAAI,CAAC;CAC5E"}
@@ -0,0 +1,52 @@
1
+ import type { ChatMessage } from '@genesislcap/foundation-ai';
2
+ /**
3
+ * A message written or sent on the user's behalf by a driver decorator (GENC-1660). See
4
+ * `ChatMessage.delegate`.
5
+ *
6
+ * @beta
7
+ */
8
+ export type DelegatedMessage = ChatMessage & {
9
+ delegate: string;
10
+ };
11
+ /**
12
+ * Whether `message` was written or sent on the user's behalf. A delegated message renders as the
13
+ * assistant, whatever its role.
14
+ *
15
+ * @beta
16
+ */
17
+ export declare const isDelegated: (message: ChatMessage) => message is DelegatedMessage;
18
+ /**
19
+ * How a delegated `user` message is framed for the model when its sender gives no phrase. Names no
20
+ * decorator, so the model has none to repeat.
21
+ *
22
+ * @beta
23
+ */
24
+ export declare const DEFAULT_DELEGATE_FRAMING = "Sent on the user's behalf.";
25
+ /**
26
+ * Options for `AiDriver.sendMessage` (GENC-1660).
27
+ *
28
+ * @beta
29
+ */
30
+ export interface SendMessageOptions {
31
+ /**
32
+ * Send the message on the user's behalf, as this decorator (e.g. `'autopilot'`). The platform
33
+ * stamps it on the stored message as `delegate`, so it renders as the assistant and the model
34
+ * reads it framed.
35
+ */
36
+ delegate?: string;
37
+ /**
38
+ * The phrase the model reads in front of a delegated message. Defaults to
39
+ * {@link DEFAULT_DELEGATE_FRAMING}. Ignored unless `delegate` is set.
40
+ */
41
+ delegateFraming?: string;
42
+ }
43
+ /**
44
+ * A delegated `user` message's content as the model reads it: its framing in brackets, then the
45
+ * text. The one place this string is built, so the first model call (which takes the message as
46
+ * its input) and every later call (which reads it from history) send the same bytes and the cache
47
+ * prefix holds.
48
+ *
49
+ * @internal
50
+ */
51
+ export declare function frameDelegatedContent(content: string, framing: string | undefined): string;
52
+ //# sourceMappingURL=delegated-message.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"delegated-message.d.ts","sourceRoot":"","sources":["../../../src/utils/delegated-message.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AAE9D;;;;;GAKG;AACH,MAAM,MAAM,gBAAgB,GAAG,WAAW,GAAG;IAAE,QAAQ,EAAE,MAAM,CAAA;CAAE,CAAC;AAElE;;;;;GAKG;AACH,eAAO,MAAM,WAAW,GAAI,SAAS,WAAW,KAAG,OAAO,IAAI,gBAC1C,CAAC;AAErB;;;;;GAKG;AACH,eAAO,MAAM,wBAAwB,+BAA+B,CAAC;AAErE;;;;GAIG;AACH,MAAM,WAAW,kBAAkB;IACjC;;;;OAIG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB;;;OAGG;IACH,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B;AAED;;;;;;;GAOG;AACH,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,CAE1F"}
@@ -1 +1 @@
1
- {"version":3,"file":"history-transform.d.ts","sourceRoot":"","sources":["../../../src/utils/history-transform.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,E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AAgB,CAAC,EAAE,MAAM,CAAC;IAC1B;;;;OAIG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,cAAc,CAC5B,OAAO,EAAE,SAAS,WAAW,EAAE,EAC/B,OAAO,GAAE,qBAA0B,GAClC,oBAAoB,GAAG,IAAI,CAc7B;AAqCD;;;;;;GAMG;AACH,wBAAgB,4BAA4B,CAAC,SAAS,EAAE,SAAS,WAAW,EAAE,GAAG;IAC/E,YAAY,EAAE,MAAM,CAAC;IACrB,WAAW,EAAE,MAAM,CAAC;CACrB,CAkBA;AAED;;;;;;;;;GASG;AACH,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,SAAS,WAAW,EAAE,GAAG,WAAW,EAAE,CAkBnF;AAED,oEAAoE;AACpE,wBAAgB,sBAAsB,CAAC,CAAC,EAAE,WAAW,GAAG,MAAM,CAG7D"}
@@ -150,6 +150,8 @@ export class AgentSession {
150
150
  transition.flowOwnerChangedTo = agent.name;
151
151
  }
152
152
  this.active = agent;
153
+ if (switched)
154
+ this.reportTransition(transition);
153
155
  return transition;
154
156
  });
155
157
  }
@@ -174,9 +176,24 @@ export class AgentSession {
174
176
  this.flowOwner = null;
175
177
  transition.flowOwnerChangedTo = null;
176
178
  }
179
+ this.reportTransition(transition);
177
180
  return transition;
178
181
  });
179
182
  }
183
+ /**
184
+ * Hand a transition to the owner. A throwing listener is logged rather than propagated, for the
185
+ * same reason a throwing hook is: the transition has already happened, and failing the caller
186
+ * would leave it believing it had not.
187
+ */
188
+ reportTransition(transition) {
189
+ var _a, _b;
190
+ try {
191
+ (_b = (_a = this.deps).onTransition) === null || _b === void 0 ? void 0 : _b.call(_a, transition);
192
+ }
193
+ catch (e) {
194
+ logger.warn(`${WARN_PREFIX}: onTransition threw:`, e);
195
+ }
196
+ }
180
197
  /**
181
198
  * Fire `onDeactivate` on the active agent and abort pending lifecycle work, for session
182
199
  * teardown, so machines release resources cleanly. The session is not reusable afterwards: the
@@ -1 +1,21 @@
1
- export {};
1
+ /**
2
+ * The event types in {@link AiDriverEventMap}, as a runtime list. Built from a record keyed by the
3
+ * map, so adding an event to the map without adding it here is a compile error.
4
+ *
5
+ * @beta
6
+ */
7
+ export const AI_DRIVER_EVENT_TYPES = Object.keys({
8
+ 'history-updated': true,
9
+ 'sub-agent-history-updated': true,
10
+ 'sub-agent-start': true,
11
+ 'sub-agent-stop': true,
12
+ 'interaction-start': true,
13
+ 'interaction-stop': true,
14
+ 'provider-changed': true,
15
+ 'external-cost-recorded': true,
16
+ 'agent-changed': true,
17
+ 'agent-released': true,
18
+ 'flow-owner-changed': true,
19
+ 'orchestrating-start': true,
20
+ 'orchestrating-stop': true,
21
+ });
@@ -0,0 +1,211 @@
1
+ import { AI_DRIVER_EVENT_TYPES, } from './ai-driver';
2
+ /**
3
+ * The base of every driver decorator (GENC-1660): an {@link AiDriver} that wraps another and
4
+ * passes every member, and every event in {@link AiDriverEventMap}, through to it.
5
+ *
6
+ * A decorator extends this and overrides only what it changes, so decorators stack in any order
7
+ * and a member or event added to `AiDriver` reaches the host through every layer by default.
8
+ * `OrchestratingDriver` is one; it used to forward by hand, and twice a member it did not forward
9
+ * silently did nothing for every multi-agent host (`recordExternalCost`, then
10
+ * `getHistoryForPersistence`).
11
+ *
12
+ * Abstract with no abstract members, so it cannot be constructed on its own: a decorator that
13
+ * changes nothing is not one.
14
+ *
15
+ * Optional `AiDriver` members are implemented here unconditionally, as a forward that falls back
16
+ * to the "not supported" answer when the inner driver lacks them. A host that feature-detects with
17
+ * `?.` therefore always finds them, and gets the same answer it would from the inner driver.
18
+ *
19
+ * @beta
20
+ */
21
+ export class BaseDriverDecorator extends EventTarget {
22
+ constructor(inner) {
23
+ super();
24
+ this.inner = inner;
25
+ /** Undoes this layer's hold on its inner driver; see {@link BaseDriverDecorator.detach}. */
26
+ this.detachers = [];
27
+ // Re-dispatch, not re-target: an event belongs to one target, so each layer raises its own
28
+ // copy with the same detail, as the orchestrator always did.
29
+ for (const type of AI_DRIVER_EVENT_TYPES) {
30
+ const forward = (e) => {
31
+ this.dispatchEvent(new CustomEvent(type, { detail: e.detail }));
32
+ };
33
+ inner.addEventListener(type, forward);
34
+ this.onDetach(() => inner.removeEventListener(type, forward));
35
+ }
36
+ }
37
+ /**
38
+ * Let go of the inner driver WITHOUT disposing it: stop forwarding its events, and undo whatever
39
+ * a subclass registered through {@link BaseDriverDecorator.onDetach} (its interceptors, its
40
+ * capabilities, its own listeners). For dropping or replacing a decorator while the driver it
41
+ * wrapped lives on — otherwise the old layer keeps re-dispatching every event and is never
42
+ * collected. Idempotent. `dispose()` detaches too.
43
+ */
44
+ detach() {
45
+ for (const undo of this.detachers.splice(0)) {
46
+ try {
47
+ undo();
48
+ }
49
+ catch (_a) {
50
+ // One failed undo must not keep the rest attached.
51
+ }
52
+ }
53
+ }
54
+ /** Register something {@link BaseDriverDecorator.detach} must undo. */
55
+ onDetach(undo) {
56
+ this.detachers.push(undo);
57
+ }
58
+ sendMessage(input, attachments, options) {
59
+ return this.inner.sendMessage(input, attachments, options);
60
+ }
61
+ continueFromHistory(transientPrimer, options) {
62
+ return this.inner.continueFromHistory(transientPrimer, options);
63
+ }
64
+ resolveInteraction(interactionId, result) {
65
+ this.inner.resolveInteraction(interactionId, result);
66
+ }
67
+ recordExternalCost(interactionId, costUsd) {
68
+ var _a, _b, _c;
69
+ return (_c = (_b = (_a = this.inner).recordExternalCost) === null || _b === void 0 ? void 0 : _b.call(_a, interactionId, costUsd)) !== null && _c !== void 0 ? _c : false;
70
+ }
71
+ getInteractionContext(interactionId) {
72
+ var _a, _b;
73
+ return (_b = (_a = this.inner).getInteractionContext) === null || _b === void 0 ? void 0 : _b.call(_a, interactionId);
74
+ }
75
+ loadHistory(messages) {
76
+ this.inner.loadHistory(messages);
77
+ }
78
+ primeRestoredAgentState(snapshots) {
79
+ this.inner.primeRestoredAgentState(snapshots);
80
+ }
81
+ canRestoreFlowOwner(agentName) {
82
+ var _a, _b, _c;
83
+ return (_c = (_b = (_a = this.inner).canRestoreFlowOwner) === null || _b === void 0 ? void 0 : _b.call(_a, agentName)) !== null && _c !== void 0 ? _c : false;
84
+ }
85
+ canResumeRestoredFlow(agentName) {
86
+ var _a, _b, _c;
87
+ return (_c = (_b = (_a = this.inner).canResumeRestoredFlow) === null || _b === void 0 ? void 0 : _b.call(_a, agentName)) !== null && _c !== void 0 ? _c : false;
88
+ }
89
+ resumeRestoredFlow(resumeNote, agent) {
90
+ var _a, _b, _c;
91
+ return (_c = (_b = (_a = this.inner).resumeRestoredFlow) === null || _b === void 0 ? void 0 : _b.call(_a, resumeNote, agent)) !== null && _c !== void 0 ? _c : Promise.resolve(undefined);
92
+ }
93
+ getRawHistory() {
94
+ var _a, _b, _c;
95
+ return (_c = (_b = (_a = this.inner).getRawHistory) === null || _b === void 0 ? void 0 : _b.call(_a)) !== null && _c !== void 0 ? _c : [];
96
+ }
97
+ getHistoryForPersistence() {
98
+ var _a, _b, _c;
99
+ return (_c = (_b = (_a = this.inner).getHistoryForPersistence) === null || _b === void 0 ? void 0 : _b.call(_a)) !== null && _c !== void 0 ? _c : [...this.getRawHistory()];
100
+ }
101
+ getCondensePoliciesForPersistence(messages) {
102
+ var _a, _b, _c;
103
+ return (_c = (_b = (_a = this.inner).getCondensePoliciesForPersistence) === null || _b === void 0 ? void 0 : _b.call(_a, messages)) !== null && _c !== void 0 ? _c : [];
104
+ }
105
+ restoreCondensePolicies(entries) {
106
+ var _a, _b, _c;
107
+ return ((_c = (_b = (_a = this.inner).restoreCondensePolicies) === null || _b === void 0 ? void 0 : _b.call(_a, entries)) !== null && _c !== void 0 ? _c : { restored: 0, awaitingReactivation: 0 });
108
+ }
109
+ getActiveAgent() {
110
+ return this.inner.getActiveAgent();
111
+ }
112
+ setPinnedAgent(name) {
113
+ this.inner.setPinnedAgent(name);
114
+ }
115
+ setFlowOwner(name) {
116
+ this.inner.setFlowOwner(name);
117
+ }
118
+ getFlowOwner() {
119
+ var _a, _b, _c;
120
+ return (_c = (_b = (_a = this.inner).getFlowOwner) === null || _b === void 0 ? void 0 : _b.call(_a)) !== null && _c !== void 0 ? _c : null;
121
+ }
122
+ /**
123
+ * Forwarded, so an interceptor installed on any layer lands on the driver that opens the
124
+ * interactions. A decorator that answers interactions installs its own on `this.inner`.
125
+ */
126
+ addInteractionInterceptor(interceptor) {
127
+ var _a, _b, _c;
128
+ return (_c = (_b = (_a = this.inner).addInteractionInterceptor) === null || _b === void 0 ? void 0 : _b.call(_a, interceptor)) !== null && _c !== void 0 ? _c : (() => undefined);
129
+ }
130
+ presentInteraction(componentName, data, options) {
131
+ var _a, _b, _c;
132
+ return ((_c = (_b = (_a = this.inner).presentInteraction) === null || _b === void 0 ? void 0 : _b.call(_a, componentName, data, options)) !== null && _c !== void 0 ? _c : Promise.reject(new Error('presentInteraction: the inner driver cannot show interactions.')));
133
+ }
134
+ provideHandlerCapability(name, factory) {
135
+ var _a, _b, _c;
136
+ return (_c = (_b = (_a = this.inner).provideHandlerCapability) === null || _b === void 0 ? void 0 : _b.call(_a, name, factory)) !== null && _c !== void 0 ? _c : (() => undefined);
137
+ }
138
+ getContextReserve() {
139
+ var _a, _b;
140
+ return (_b = (_a = this.inner).getContextReserve) === null || _b === void 0 ? void 0 : _b.call(_a);
141
+ }
142
+ getPreambleTokens() {
143
+ var _a, _b;
144
+ return (_b = (_a = this.inner).getPreambleTokens) === null || _b === void 0 ? void 0 : _b.call(_a);
145
+ }
146
+ setContextGuard(policy) {
147
+ var _a, _b;
148
+ (_b = (_a = this.inner).setContextGuard) === null || _b === void 0 ? void 0 : _b.call(_a, policy);
149
+ }
150
+ compact(options) {
151
+ var _a, _b, _c;
152
+ return (_c = (_b = (_a = this.inner).compact) === null || _b === void 0 ? void 0 : _b.call(_a, options)) !== null && _c !== void 0 ? _c : Promise.resolve(null);
153
+ }
154
+ getCompactionPlan(options) {
155
+ var _a, _b, _c;
156
+ return (_c = (_b = (_a = this.inner).getCompactionPlan) === null || _b === void 0 ? void 0 : _b.call(_a, options)) !== null && _c !== void 0 ? _c : null;
157
+ }
158
+ canCompact(options) {
159
+ var _a, _b, _c;
160
+ return (_c = (_b = (_a = this.inner).canCompact) === null || _b === void 0 ? void 0 : _b.call(_a, options)) !== null && _c !== void 0 ? _c : false;
161
+ }
162
+ isBusy() {
163
+ return this.inner.isBusy();
164
+ }
165
+ getSuggestions(history, prompt, count, allAgentInfo) {
166
+ return this.inner.getSuggestions(history, prompt, count, allAgentInfo);
167
+ }
168
+ getTurnSnapshots() {
169
+ var _a, _b, _c;
170
+ return (_c = (_b = (_a = this.inner).getTurnSnapshots) === null || _b === void 0 ? void 0 : _b.call(_a)) !== null && _c !== void 0 ? _c : [];
171
+ }
172
+ /**
173
+ * The inner driver's entries. Diagnostics compose down the stack: a decorator with entries of
174
+ * its own overrides this and appends them to `super.getExternalDiagnostics()`.
175
+ */
176
+ getExternalDiagnostics() {
177
+ var _a, _b, _c;
178
+ return (_c = (_b = (_a = this.inner).getExternalDiagnostics) === null || _b === void 0 ? void 0 : _b.call(_a)) !== null && _c !== void 0 ? _c : [];
179
+ }
180
+ getActiveProviderName() {
181
+ return this.inner.getActiveProviderName();
182
+ }
183
+ dispose() {
184
+ var _a, _b;
185
+ const disposed = (_b = (_a = this.inner).dispose) === null || _b === void 0 ? void 0 : _b.call(_a);
186
+ this.detach();
187
+ return disposed;
188
+ }
189
+ cancel() {
190
+ var _a, _b;
191
+ (_b = (_a = this.inner).cancel) === null || _b === void 0 ? void 0 : _b.call(_a);
192
+ }
193
+ /**
194
+ * Every driver in the stack, outermost first: `driver`, then each inner driver down to the one
195
+ * that is not a decorator.
196
+ *
197
+ * For diagnostics and labelling only: behaviour must go through `AiDriver` members, which every
198
+ * layer forwards, never through a concrete class found here.
199
+ *
200
+ * @internal
201
+ */
202
+ static layers(driver) {
203
+ const layers = [driver];
204
+ let current = driver;
205
+ while (current instanceof BaseDriverDecorator) {
206
+ current = current.inner;
207
+ layers.push(current);
208
+ }
209
+ return layers;
210
+ }
211
+ }
@@ -1 +1,2 @@
1
- export {};
1
+ export { AI_DRIVER_EVENT_TYPES } from './ai-driver';
2
+ export { BaseDriverDecorator } from './base-driver-decorator';