@syntrologie/adapt-chatbot 2.55.1 → 2.56.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 (73) hide show
  1. package/dist/AdaptiveChatBar.d.ts +18 -0
  2. package/dist/AdaptiveChatBar.d.ts.map +1 -1
  3. package/dist/AdaptiveChatBar.interleave.test.d.ts +9 -0
  4. package/dist/AdaptiveChatBar.interleave.test.d.ts.map +1 -0
  5. package/dist/AdaptiveChatBar.js +4 -4
  6. package/dist/AdaptiveChatBarMountable.d.ts +28 -17
  7. package/dist/AdaptiveChatBarMountable.d.ts.map +1 -1
  8. package/dist/AdaptiveChatTrail.js +3 -3
  9. package/dist/AdaptiveChipsStrip.d.ts +20 -20
  10. package/dist/AdaptiveChipsStrip.js +3 -3
  11. package/dist/ChatAssistantLit.d.ts.map +1 -1
  12. package/dist/ChatAssistantLit.js +5 -4
  13. package/dist/ChatTransport.d.ts +6 -1
  14. package/dist/ChatTransport.d.ts.map +1 -1
  15. package/dist/cdn.d.ts +1 -0
  16. package/dist/cdn.d.ts.map +1 -1
  17. package/dist/chunk-23E6WZOO.js +882 -0
  18. package/dist/chunk-23E6WZOO.js.map +7 -0
  19. package/dist/{chunk-EXDL3OKE.js → chunk-7QXC475Y.js} +314 -908
  20. package/dist/{chunk-EXDL3OKE.js.map → chunk-7QXC475Y.js.map} +4 -4
  21. package/dist/{chunk-TZA7572J.js → chunk-GN7Z5IVP.js} +2 -2
  22. package/dist/chunk-LY5AGXVD.js +21 -0
  23. package/dist/{chunk-ETDHHQS3.js → chunk-NMYFYMJI.js} +12 -12
  24. package/dist/{chunk-ETDHHQS3.js.map → chunk-NMYFYMJI.js.map} +1 -1
  25. package/dist/{chunk-LJEPZI6Y.js → chunk-WQIDXGGS.js} +2 -2
  26. package/dist/{chunk-VFWA5W56.js → chunk-XPUHW2YO.js} +44 -7
  27. package/dist/chunk-XPUHW2YO.js.map +7 -0
  28. package/dist/chunk-Z3YR4JFE.js +4702 -0
  29. package/dist/chunk-Z3YR4JFE.js.map +7 -0
  30. package/dist/editor-lit.js +1 -1
  31. package/dist/element-session.d.ts +3 -0
  32. package/dist/element-session.d.ts.map +1 -0
  33. package/dist/element-session.js +9 -0
  34. package/dist/element-session.js.map +7 -0
  35. package/dist/elements/ElementInstanceStore.d.ts +15 -1
  36. package/dist/elements/ElementInstanceStore.d.ts.map +1 -1
  37. package/dist/elements/ElementSessionController.d.ts +37 -0
  38. package/dist/elements/ElementSessionController.d.ts.map +1 -0
  39. package/dist/elements/ElementSessionController.test.d.ts +2 -0
  40. package/dist/elements/ElementSessionController.test.d.ts.map +1 -0
  41. package/dist/elements/TileHandler.d.ts.map +1 -1
  42. package/dist/elements/createElementStore.d.ts +11 -0
  43. package/dist/elements/createElementStore.d.ts.map +1 -0
  44. package/dist/elements/tileLifecycleProps.d.ts +13 -0
  45. package/dist/elements/tileLifecycleProps.d.ts.map +1 -0
  46. package/dist/elements/types.d.ts +7 -0
  47. package/dist/elements/types.d.ts.map +1 -1
  48. package/dist/hostAgentController.d.ts +65 -0
  49. package/dist/hostAgentController.d.ts.map +1 -0
  50. package/dist/hostAgentController.test.d.ts +2 -0
  51. package/dist/hostAgentController.test.d.ts.map +1 -0
  52. package/dist/observer/wire.d.ts +54 -0
  53. package/dist/observer/wire.d.ts.map +1 -0
  54. package/dist/observer/wire.test.d.ts +2 -0
  55. package/dist/observer/wire.test.d.ts.map +1 -0
  56. package/dist/runtime.d.ts +3 -0
  57. package/dist/runtime.d.ts.map +1 -1
  58. package/dist/runtime.js +824 -163
  59. package/dist/runtime.js.map +4 -4
  60. package/dist/schema.d.ts +66 -66
  61. package/dist/schema.d.ts.map +1 -1
  62. package/dist/schema.js +75 -76
  63. package/dist/schema.js.map +3 -3
  64. package/dist/types.d.ts +17 -0
  65. package/dist/types.d.ts.map +1 -1
  66. package/package.json +9 -7
  67. package/dist/chunk-NGV35N4T.js +0 -474
  68. package/dist/chunk-NGV35N4T.js.map +0 -7
  69. package/dist/chunk-UVKRO5ER.js +0 -13
  70. package/dist/chunk-VFWA5W56.js.map +0 -7
  71. /package/dist/{chunk-TZA7572J.js.map → chunk-GN7Z5IVP.js.map} +0 -0
  72. /package/dist/{chunk-UVKRO5ER.js.map → chunk-LY5AGXVD.js.map} +0 -0
  73. /package/dist/{chunk-LJEPZI6Y.js.map → chunk-WQIDXGGS.js.map} +0 -0
@@ -1,4 +1,4 @@
1
- import "./chunk-UVKRO5ER.js";
1
+ import "./chunk-LY5AGXVD.js";
2
2
 
3
3
  // src/editor-lit.ts
4
4
  import { html, LitElement } from "lit";
@@ -0,0 +1,3 @@
1
+ export type { ApplyOutcome, ElementSessionController, ElementSessionOptions, } from './elements/ElementSessionController';
2
+ export { createElementSessionController } from './elements/ElementSessionController';
3
+ //# sourceMappingURL=element-session.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"element-session.d.ts","sourceRoot":"","sources":["../src/element-session.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,YAAY,EACZ,wBAAwB,EACxB,qBAAqB,GACtB,MAAM,qCAAqC,CAAC;AAC7C,OAAO,EAAE,8BAA8B,EAAE,MAAM,qCAAqC,CAAC"}
@@ -0,0 +1,9 @@
1
+ import {
2
+ createElementSessionController
3
+ } from "./chunk-23E6WZOO.js";
4
+ import "./chunk-Z3YR4JFE.js";
5
+ import "./chunk-LY5AGXVD.js";
6
+ export {
7
+ createElementSessionController
8
+ };
9
+ //# sourceMappingURL=element-session.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": [],
4
+ "sourcesContent": [],
5
+ "mappings": "",
6
+ "names": []
7
+ }
@@ -116,6 +116,10 @@ export interface ElementInstanceStoreOptions {
116
116
  */
117
117
  resolveTileWidget?: (templateId: string) => string | undefined;
118
118
  }
119
+ export interface ApplyReport {
120
+ ok: boolean;
121
+ rejectedInstanceIds: string[];
122
+ }
119
123
  export declare class ElementInstanceStore {
120
124
  private readonly _actions;
121
125
  private readonly _events;
@@ -125,6 +129,9 @@ export declare class ElementInstanceStore {
125
129
  private readonly _resolveTileWidget?;
126
130
  /** Active TTL timeout — replaced on each call to `scheduleClientTtl`. */
127
131
  private _ttlTimer;
132
+ private _unsubscribeReplay?;
133
+ private _disposed;
134
+ private _disposing;
128
135
  /** Instance IDs the client has dismissed. Persists across canvas remounts
129
136
  * so a dismissed tile never silently reappears on replay/broadcast. */
130
137
  private readonly _dismissedIds;
@@ -180,6 +187,7 @@ export declare class ElementInstanceStore {
180
187
  * stateful instances; callers should not.
181
188
  */
182
189
  hydrate(snapshot: MountedElement[]): Promise<void>;
190
+ private _hydrateWithReport;
183
191
  /**
184
192
  * Re-publish `element.tile_mounted` / `element.compositional_append`
185
193
  * for every active LLM-authored instance in the store. Idempotent —
@@ -193,16 +201,22 @@ export declare class ElementInstanceStore {
193
201
  * patch: resulting_version must be > current; unmount: idempotent).
194
202
  */
195
203
  apply(mutations: ElementMutation[]): Promise<void>;
204
+ applyWithReport(mutations: ElementMutation[]): Promise<ApplyReport>;
205
+ private _applyWithReport;
196
206
  /** Read-only snapshot of currently-known instances. */
197
207
  getInstances(): MountedElement[];
198
208
  getInstance(instance_id: string): MountedElement | undefined;
209
+ /** Replace a host-provided complete UI snapshot; never replay imperative actions. */
210
+ reconcileSnapshot(snapshot: MountedElement[]): Promise<ApplyReport>;
211
+ /** Release page-lifetime listeners and timers; queued work becomes inert. */
212
+ dispose(unmount?: boolean): void;
199
213
  /**
200
214
  * Schedule a client-side TTL that unmounts every active stateful
201
215
  * instance when the server-side session expires. Replaces any
202
216
  * previously-scheduled TTL.
203
217
  *
204
218
  * Avoids the orphan-window where session-expired tiles linger on the
205
- * page until manual refresh — the server forgets at the 4h mark and
219
+ * page until manual refresh — the server forgets at the 24h mark and
206
220
  * the SDK tears down concurrently. Re-schedule on each boot fetch /
207
221
  * mutation event that carries a refreshed `session_expires_at`.
208
222
  *
@@ -1 +1 @@
1
- {"version":3,"file":"ElementInstanceStore.d.ts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,CAAC;QACpB,QAAQ,CAAC,EAAE,MAAM,CAAC;KACnB,GACD;QAAE,IAAI,EAAE,OAAO,CAAC;QAAC,UAAU,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAC;QAAC,MAAM,CAAC,EAAE,MAAM,CAAC;QAAC,UAAU,CAAC,EAAE,MAAM,CAAA;KAAE,CAC7F;IA6ED;;;;;;OAMG;IACH,iBAAiB,IAAI,YAAY,EAAE;IAkBnC,sFAAsF;IACtF,QAAQ,CAAC,UAAU,EAAE,MAAM,GAAG,IAAI;IAoBlC;;;;;;;;OAQG;IACG,OAAO,CAAC,QAAQ,EAAE,cAAc,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;YAI1C,kBAAkB;IAkEhC;;;;;OAKG;IACH,OAAO,CAAC,gBAAgB;IAkBxB;;;;OAIG;IACG,KAAK,CAAC,SAAS,EAAE,eAAe,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAIlD,eAAe,CAAC,SAAS,EAAE,eAAe,EAAE,GAAG,OAAO,CAAC,WAAW,CAAC;YAI3D,gBAAgB;IAsB9B,uDAAuD;IACvD,YAAY,IAAI,cAAc,EAAE;IAIhC,WAAW,CAAC,WAAW,EAAE,MAAM,GAAG,cAAc,GAAG,SAAS;IAI5D,qFAAqF;IAC/E,iBAAiB,CAAC,QAAQ,EAAE,cAAc,EAAE,GAAG,OAAO,CAAC,WAAW,CAAC;IAuDzE,6EAA6E;IAC7E,OAAO,CAAC,OAAO,UAAQ,GAAG,IAAI;IAqB9B;;;;;;;;;;;;OAYG;IACH,iBAAiB,CAAC,kBAAkB,EAAE,MAAM,GAAG,IAAI,GAAG,IAAI;YAwB5C,oBAAoB;YAkBpB,SAAS;YA6IT,MAAM;IAyBpB,OAAO,CAAC,IAAI;CAUb"}
@@ -0,0 +1,37 @@
1
+ import type { ChatbotWidgetRuntime } from '../types';
2
+ import type { ElementInstanceStore } from './ElementInstanceStore';
3
+ import type { MountedElement, MountedElementsResponse, MutationEnvelope } from './types';
4
+ export type ApplyOutcome = {
5
+ status: 'applied' | 'duplicate';
6
+ resultId: string;
7
+ } | {
8
+ status: 'rejected';
9
+ reason: 'invalid' | 'wrong_scope' | 'disposed' | 'projection_failed';
10
+ };
11
+ export interface ElementSessionController {
12
+ configureTemplates(templates: Record<string, unknown> | undefined): void;
13
+ acceptHostFrame(payload: unknown): Promise<ApplyOutcome>;
14
+ applyLegacyEnvelope(envelope: MutationEnvelope): Promise<void>;
15
+ hydrateLegacy(instances: MountedElement[], expiresAt: string | null): Promise<void>;
16
+ dispose(): Promise<void>;
17
+ }
18
+ export interface ElementSessionOptions extends Pick<ChatbotWidgetRuntime, 'actions' | 'events'> {
19
+ templates?: Record<string, unknown>;
20
+ /** The older standalone assistant accepted template IDs as widget IDs. */
21
+ legacyTemplateFallback?: boolean;
22
+ /** The one conversation this owner renders. A frame for any other is refused. */
23
+ hostScope?: {
24
+ sessionRef: string;
25
+ };
26
+ }
27
+ /** Compatibility accessors belong to this owner, never a module-wide store. */
28
+ export interface OwnedElementSession extends ElementSessionController {
29
+ readonly store: ElementInstanceStore;
30
+ resolveTileWidget(templateId: string): string | undefined;
31
+ whenIdle(): Promise<void>;
32
+ hydrateOnce(load: () => Promise<MountedElementsResponse | null>): void;
33
+ listen(target: EventTarget, name: string, listener: EventListener): () => void;
34
+ }
35
+ /** The UI-independent owner for ordered projection, replay and teardown. */
36
+ export declare function createElementSessionController(options: ElementSessionOptions): OwnedElementSession;
37
+ //# sourceMappingURL=ElementSessionController.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ElementSessionController.d.ts","sourceRoot":"","sources":["../../src/elements/ElementSessionController.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,UAAU,CAAC;AAErD,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AACnE,OAAO,KAAK,EAAE,cAAc,EAAE,uBAAuB,EAAE,gBAAgB,EAAE,MA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AE,MAAM,OAAO,CAAC,uBAAuB,GAAG,IAAI,CAAC,GAAG,IAAI,CAAC;IACvE,MAAM,CAAC,MAAM,EAAE,WAAW,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,aAAa,GAAG,MAAM,IAAI,CAAC;CAChF;AAoFD,4EAA4E;AAC5E,wBAAgB,8BAA8B,CAC5C,OAAO,EAAE,qBAAqB,GAC7B,mBAAmB,CA8GrB"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=ElementSessionController.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ElementSessionController.test.d.ts","sourceRoot":"","sources":["../../src/elements/ElementSessionController.test.ts"],"names":[],"mappings":""}
@@ -1 +1 @@
1
- {"version":3,"file":"TileHandler.d.ts","sourceRoot":"","sources":["../../src/elements/TileHandler.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAUH,OAAO,KAAK,EACV,qBAAqB,EACrB,kBAAkB,EAClB,cAAc,EACf,MAAM,sBAAsB,CAAC;AAC9B,OAAO,KAAK,EAAE,cAAc,EAAiB,MAAM,SAAS,CAAC;AAE7D,OAAO,EACL,kBAAkB,EAClB,kBAAkB,EAClB,oBAAoB,GACrB,MAAM,4BAA4B,CAAC;AAEpC;;;;;;;;GAQG;AACH,MAAM,MAAM,0BAA0B,GAAG,CAAC,UAAU,EAAE,MAAM,KAAK,MAAM,GAAG,SAAS,CAAC;AAEpF,qBAAa,WAAY,YAAW,kBAAkB;IAIxC,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAC;IAH3C,QAAQ,CAAC,QAAQ,EAAG,MAAM,CAAU;IACpC,QAAQ,CAAC,SAAS,EAAG,UAAU,CAAU;gBAEZ,aAAa,CAAC,EAAE,0BAA0B,YAAA;IAEvE,OAAO,CAAC,UAAU;IAIlB,QAAQ,CAAC,QAAQ,EAAE,cAAc,EAAE,IAAI,EAAE,qBAAqB,GAAG,cAAc;IA2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,IAAI,CAAC;IAO1E,OAAO,CAAC,QAAQ,EAAE,cAAc,EAAE,GAAG,EAAE,qBAAqB,GAAG,OAAO,CAAC,IAAI,CAAC;CASnF"}
@@ -0,0 +1,11 @@
1
+ import type { ChatbotWidgetRuntime } from '../types';
2
+ import { ElementInstanceStore } from './ElementInstanceStore';
3
+ import { type TileTemplateWidgetResolver } from './TileHandler';
4
+ /** Independent template state shared by live mounts and replay in one surface. */
5
+ export declare function createTemplateWidgetResolver(): {
6
+ resolve: (templateId: string) => string | undefined;
7
+ refresh(uiTemplates: Record<string, unknown> | undefined): void;
8
+ };
9
+ /** UI-free store construction; the owning surface controls its lifetime. */
10
+ export declare function createElementStore(runtime: Pick<ChatbotWidgetRuntime, 'actions' | 'events'>, resolveTileWidget: TileTemplateWidgetResolver): ElementInstanceStore;
11
+ //# sourceMappingURL=createElementStore.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"createElementStore.d.ts","sourceRoot":"","sources":["../../src/elements/createElementStore.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,UAAU,CAAC;AAErD,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAE9D,OAAO,EAAe,KAAK,0BAA0B,EAAE,MAAM,eAAe,CAAC;AAE7E,kFAAkF;AAClF,wBAAgB,4BAA4B;0BAGlB,MAAM,KAAG,MAAM,GAAG,SAAS;yBAC5B,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,GAAG,IAAI;EAkBlE;AAED,4EAA4E;AAC5E,wBAAgB,kBAAkB,CAChC,OAAO,EAAE,IAAI,CAAC,oBAAoB,EAAE,SAAS,GAAG,QAAQ,CAAC,EACzD,iBAAiB,EAAE,0BAA0B,GAC5C,oBAAoB,CAUtB"}
@@ -0,0 +1,13 @@
1
+ import { type TileLifecycleMountProps } from '@syntrologie/sdk-contracts';
2
+ import type { MountedElement, SlotPlacement } from './types';
3
+ /**
4
+ * The one builder for an `element.tile_mounted` / `element.tile_patched`
5
+ * payload. The runtime rebuilds a tile from the LATEST event for its id, so
6
+ * every site that publishes one (the handler's mount and patch, the store's
7
+ * replays) must send the same fields: a replay built by hand dropped the
8
+ * agent's placement plan and ungrouped the tiles it had just placed.
9
+ */
10
+ export declare function tileMountProps(instance: MountedElement & {
11
+ placement: SlotPlacement;
12
+ }, widget: string): TileLifecycleMountProps;
13
+ //# sourceMappingURL=tileLifecycleProps.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tileLifecycleProps.d.ts","sourceRoot":"","sources":["../../src/elements/tileLifecycleProps.ts"],"names":[],"mappings":"AAAA,OAAO,EAAmB,KAAK,uBAAuB,EAAE,MAAM,4BAA4B,CAAC;AAC3F,OAAO,KAAK,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAE7D;;;;;;GAMG;AACH,wBAAgB,cAAc,CAC5B,QAAQ,EAAE,cAAc,GAAG;IAAE,SAAS,EAAE,aAAa,CAAA;CAAE,EACvD,MAAM,EAAE,MAAM,GACb,uBAAuB,CASzB"}
@@ -55,6 +55,13 @@ export interface MountedElement {
55
55
  element_type: 'tile' | 'action' | 'item';
56
56
  template_id: string;
57
57
  placement: Placement;
58
+ /** The agent's placement plan for a tile: its group heading and whether it
59
+ * leads the group. Absent when the agent gave none, and on elements mounted
60
+ * before the plan existed. */
61
+ layout?: {
62
+ group?: string | null;
63
+ lead: boolean;
64
+ } | null;
58
65
  content: Record<string, unknown>;
59
66
  state: ElementState;
60
67
  mounted_by: AgentProvenance;
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/elements/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,MAAM,MAAM,YAAY,GAAG,QAAQ,GAAG,SAAS,GAAG,UAAU,GAAG,SAAS,CAAC;AAEzE,MAAM,WAAW,eAAe;IAC9B,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EA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I,CAAC;IAC7B,OAAO,EAAE,MAAM,CAAC;IAChB,YAAY,CAAC,EAAE,QAAQ,EAAE,CAAC;CAC3B;AAED;;;GAGG;AACH,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,yBAAyB,CAAC;IAChC,cAAc,EAAE,IAAI,CAAC;IACrB,SAAS,EAAE,eAAe,EAAE,CAAC;CAC9B;AAED,MAAM,MAAM,eAAe,GAAG,aAAa,GAAG,aAAa,GAAG,eAAe,CAAC;AAE9E,MAAM,WAAW,aAAa;IAC5B,EAAE,EAAE,OAAO,CAAC;IACZ,QAAQ,EAAE,cAAc,CAAC;CAC1B;AAED,MAAM,WAAW,aAAa;IAC5B,EAAE,EAAE,OAAO,CAAC;IACZ,WAAW,EAAE,MAAM,CAAC;IACpB,OAAO,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,OAAO,CAAA;KAAE,EAAE,CAAC;IAC5C,gBAAgB,EAAE,MAAM,CAAC;IACzB,6EAA6E;IAC7E,iBAAiB,EAAE,MAAM,CAAC;IAC1B;qCACiC;IACjC,iBAAiB,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAC5C;AAED,MAAM,WAAW,eAAe;IAC9B,EAAE,EAAE,SAAS,CAAC;IACd,WAAW,EAAE,MAAM,CAAC;CACrB;AAED;;;GAGG;AACH,MAAM,WAAW,uBAAuB;IACtC,gBAAgB,EAAE,cAAc,EAAE,CAAC;IACnC,kBAAkB,EAAE,MAAM,GAAG,IAAI,CAAC;IAClC,cAAc,EAAE,IAAI,CAAC;CACtB"}
@@ -0,0 +1,65 @@
1
+ import type { ChatbotWidgetRuntime } from './types';
2
+ /** Generic host transport. Agent metadata belongs to this adaptive, not the bridge. */
3
+ export interface HostToolResults {
4
+ subscribeToolResults(listener: (result: unknown) => void, options?: {
5
+ metadataKey?: string;
6
+ }): () => void;
7
+ /**
8
+ * The card's own way to ask the server a question, through the host.
9
+ *
10
+ * A reloaded card has nothing on screen and no live turn to wait for, so it
11
+ * calls the app-only read tool and applies what comes back. The host
12
+ * attaches the shopper's credential, which is why the card needs none.
13
+ */
14
+ callServerTool?(params: {
15
+ name: string;
16
+ arguments?: Record<string, unknown>;
17
+ }): Promise<unknown>;
18
+ /**
19
+ * Called whenever the host says anything about a tool call (input, a
20
+ * result of any shape, a cancellation), and at once on subscribe if it
21
+ * already has. What the missing-result check stands down on.
22
+ */
23
+ subscribeToolActivity?(listener: () => void): () => void;
24
+ /**
25
+ * Where the tool call this card was drawn for stands, the latest replayed
26
+ * on subscribe. Its input names the session the conversation is in.
27
+ */
28
+ subscribeToolCall?(listener: (call: {
29
+ phase: 'input';
30
+ arguments: Record<string, unknown>;
31
+ } | {
32
+ phase: 'result';
33
+ } | {
34
+ phase: 'cancelled';
35
+ }) => void): () => void;
36
+ }
37
+ /**
38
+ * How long a card says its answer is on its way when neither the answer nor a
39
+ * cancellation ever comes (a host that stops a turn without saying so).
40
+ */
41
+ export declare const PENDING_MAX_MS = 120000;
42
+ export interface HostAgentControllerOptions {
43
+ /** How long a card that has heard nothing waits before reporting it. */
44
+ missingResultMs?: number;
45
+ }
46
+ interface HostUiInitialization {
47
+ setInteractive?(interactive: boolean): void;
48
+ }
49
+ /** One host conversation owns one store; host delivery may synchronously replay. */
50
+ export declare function activateHostAgentController(runtime: ChatbotWidgetRuntime, bridge: HostToolResults, hostUi?: HostUiInitialization, options?: HostAgentControllerOptions): {
51
+ acceptHostUi: (payload: unknown) => void;
52
+ consumeToolResult: (result: unknown, { earlyRead }?: {
53
+ earlyRead?: boolean;
54
+ }) => Promise<void>;
55
+ whenIdle: () => Promise<void>;
56
+ dispose(): void;
57
+ };
58
+ /** App activation runs without mounting a chat widget on MCP host surfaces. */
59
+ export declare function activateHostAgent(runtime: unknown): (() => void) | undefined;
60
+ /** Narrow manifest entry point; runtime owns queueing before adaptive activation. */
61
+ export declare function acceptHostUi(runtime: {
62
+ acceptHostUi?: (payload: unknown) => void;
63
+ }, payload: unknown): void;
64
+ export {};
65
+ //# sourceMappingURL=hostAgentController.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hostAgentController.d.ts","sourceRoot":"","sources":["../src/hostAgentController.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAC;AAEpD,uFAAuF;AACvF,MAAM,WAAW,eAAe;IAC9B,oBAAoB,CAClB,QAAQ,EAAE,CAAC,MAAM,EAAE,OAAO,KAAK,IAAI,EACnC,OAAO,CAAC,EAAE;QAAE,WAAW,CAAC,EAAE,MAAM,CAAA;KAAE,GACjC,MAAM,IAAI,CAAC;IACd;;;;;;OAMG;IACH,cAAc,CAAC,CAAC,MAAM,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;KAAE,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;IACjG;;;;OAIG;IACH,qBAAqB,CAAC,CAAC,QAAQ,EAAE,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC;IACzD;;;OAGG;IACH,iBAAiB,CAAC,CAChB,QAAQ,EAAE,CACR,IAAI,EACA;QAAE,KAAK,EAAE,OAAO,CAAC;QAAC,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;KAAE,GACtD;QAAE,KAAK,EAAE,QAAQ,CAAA;KAAE,GACnB;QAAE,KAAK,EAAE,WAAW,CAAA;KAAE,KACvB,IAAI,GACR,MAAM,IAAI,CAAC;CACf;AAYD;;;GAGG;AACH,eAAO,MAAM,cAAc,SAAU,CAAC;AAKtC,MAAM,WAAW,0BAA0B;IACzC,wEAAwE;IACxE,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B;AAwJD,UAAU,oBAAoB;IAC5B,cAAc,CAAC,CAAC,WAAW,EAAE,OAAO,GAAG,IAAI,CAAC;CAC7C;AAsJD,oFAAoF;AACpF,wBAAgB,2BAA2B,CACzC,OAAO,EAAE,oBAAoB,EAC7B,MAAM,EAAE,eAAe,EACvB,MAAM,CAAC,EAAE,oBAAoB,EAC7B,OAAO,GAAE,0BAA+B;4BAwaT,OAAO,KAAG,IAAI;gCAiGnC,OAAO,kBACQ;QAAE,SAAS,CAAC,EAAE,OAAO,CAAA;KAAE,KAC7C,OAAO,CAAC,IAAI,CAAC;;;EAkKjB;AA0BD,+EAA+E;AAC/E,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,OAAO,GAAG,CAAC,MAAM,IAAI,CAAC,GAAG,SAAS,CA4D5E;AAED,qFAAqF;AACrF,wBAAgB,YAAY,CAC1B,OAAO,EAAE;IAAE,YAAY,CAAC,EAAE,CAAC,OAAO,EAAE,OAAO,KAAK,IAAI,CAAA;CAAE,EACtD,OAAO,EAAE,OAAO,GACf,IAAI,CAEN"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=hostAgentController.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hostAgentController.test.d.ts","sourceRoot":"","sources":["../src/hostAgentController.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,54 @@
1
+ /**
2
+ * One place that connects a Syntro runtime to the observer.
3
+ *
4
+ * What the shopper does is the same signal wherever they are: on a storefront
5
+ * page the chat bar wires this, and inside a chat app's card the host agent
6
+ * controller wires the very same thing. Both post to
7
+ * `/api/adaptive/observation` with the runtime's own distinct id, so the
8
+ * backend drains one visitor's timeline whichever surface produced it.
9
+ *
10
+ * Extracted from `AdaptiveChatBarMountable` so there is exactly one copy of
11
+ * the transport options, the identity accessors and the bus translation.
12
+ * `startObserver` is reference-counted, so several owners share one queue and
13
+ * the observer tears down when the last one stops.
14
+ */
15
+ import type { ProductIdentityExtractor } from '@syntrologie/sdk-contracts';
16
+ import type { ObservationEvent, RawEvent } from './allowlist';
17
+ /** What the observer needs from a runtime. Everything else is none of its business. */
18
+ export interface ObserverRuntime {
19
+ events?: {
20
+ subscribe?: (filter: unknown, cb: (e: unknown) => void) => () => void;
21
+ };
22
+ backendUrl?: string;
23
+ token?: string;
24
+ telemetry?: {
25
+ getDistinctId?: () => string | undefined | null;
26
+ getSessionId?: () => string | undefined | null;
27
+ };
28
+ /** Active platform adapter's product-identity extractor (undefined off-platform). */
29
+ getProductIdentity?: ProductIdentityExtractor;
30
+ }
31
+ /**
32
+ * Observation enrichment (exported for direct testing).
33
+ *
34
+ * Two passes through the SAME platform-adapter extractor:
35
+ * 1. clicks — resolve product identity from the clicked element chain
36
+ * (original behavior, unchanged);
37
+ * 2. page-level signals (view/scroll/idle/hesitation/hover/nav) with no
38
+ * product — resolve the CURRENT page's product by feeding the extractor
39
+ * a synthetic chain element carrying `location.pathname`. Live-verified
40
+ * gap (FEAT-1783640628): a visitor ON a PDP produces section views with
41
+ * no product identity, which starved every product-shaped downstream
42
+ * (nudge ping-pong detection, the agent's "viewed <product>" context).
43
+ */
44
+ export declare function buildObserverEnrich(runtimeRef: {
45
+ getProductIdentity?: ProductIdentityExtractor;
46
+ }): (ev: ObservationEvent, raw: RawEvent) => ObservationEvent;
47
+ /**
48
+ * Start observing this runtime's bus and return the owner's stop.
49
+ *
50
+ * The stop is idempotent and releases only this owner's reference; the shared
51
+ * observer keeps running while any other owner holds one.
52
+ */
53
+ export declare function wireObserver(runtime: ObserverRuntime | undefined): () => void;
54
+ //# sourceMappingURL=wire.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"wire.d.ts","sourceRoot":"","sources":["../../src/observer/wire.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,KAAK,EAAuB,wBAAwB,EAAE,MAAM,4BAA4B,CAAC;AAChG,OAAO,KAAK,EAAE,gBAAgB,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAI9D,uFAAuF;AACvF,MAAM,WAAW,eAAe;IAC9B,MAAM,CAAC,EAAE;QAAE,SAAS,CAAC,EAAE,CAAC,MAAM,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC,CAAC,EAAE,OAAO,KAAK,IAAI,KAAK,MAAM,IAAI,CAAA;KAAE,CAAC;IACnF,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,SAAS,CAAC,EAAE;QACV,aAAa,CAAC,EAAE,MAAM,MAAM,GAAG,SAAS,GAAG,IAAI,CAAC;QAChD,YAAY,CAAC,EAAE,MAAM,MAAM,GAAG,SAAS,GAAG,IAAI,CAAC;KAChD,CAAC;IACF,qFAAqF;IACrF,kBAAkB,CAAC,EAAE,wBAAwB,CAAC;CAC/C;AAOD;;;;;;;;;;;;GAYG;AACH,wBAAgB,mBAAmB,CAAC,UAAU,EAAE;IAC9C,kBAAkB,CAAC,EAAE,wBAAwB,CAAC;CAC/C,GAAG,CAAC,EAAE,EAAE,gBAAgB,EAAE,GAAG,EAAE,QAAQ,KAAK,gBAAgB,CAkC5D;AAED;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,OAAO,EAAE,eAAe,GAAG,SAAS,GAAG,MAAM,IAAI,CAqE7E"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=wire.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"wire.test.d.ts","sourceRoot":"","sources":["../../src/observer/wire.test.ts"],"names":[],"mappings":""}
package/dist/runtime.d.ts CHANGED
@@ -12,6 +12,7 @@
12
12
  import { type MountPlumbing } from '@syntrologie/sdk-contracts';
13
13
  import './AdaptiveChatBar';
14
14
  import './AdaptiveChatTrail';
15
+ import { acceptHostUi, activateHostAgent } from './hostAgentController';
15
16
  /**
16
17
  * LeaveAMessageMountable — mounts `<syntro-leave-a-message>`
17
18
  * (adaptive-chatbot:leave-a-message). Escalation-only async human handoff:
@@ -45,6 +46,8 @@ export declare const runtime: {
45
46
  name: string;
46
47
  description: string;
47
48
  executors: never[];
49
+ onActivate: typeof activateHostAgent;
50
+ acceptHostUi: typeof acceptHostUi;
48
51
  widgets: ({
49
52
  id: string;
50
53
  component: {
@@ -1 +1 @@
1
- {"version":3,"file":"runtime.d.ts","sourceRoot":"","sources":["../src/runtime.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,KAAK,aAAa,EAAsB,MAAM,4BAA4B,CAAC;AAGpF,OAAO,mBAAmB,CAAC;AAC3B,OAAO,qBAAqB,CAAC;AAwC7B;;;;;;;;;GASG;AACH,eAAO,MAAM,sBAAsB;qBAChB,WAAW,WAAW,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,aAAa,CAAC,GAAG,IAAI;IA6BvF;;;;;;;;;;OAUG;sBACe,WAAW,WAAW,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,aAAa,CAAC,GAAG,IAAI;CASzF,CAAC;AAMF,OAAO,EAAE,oBAAoB,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAC/D,OAAO,EAAE,uBAAuB,EAAE,uBAAuB,EAAE,MAAM,4BAA4B,CAAC;AAE9F,eAAO,MAAM,OAAO;;;;;;;;;;;;;;;;;;;6BA1DD,WAAW,WAAW,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,aAAa,CAAC,GAAG,IAAI;YA6BvF;;;;;;;;;;eAUG;8BACe,WAAW,WAAW,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,aAAa,CAAC,GAAG,IAAI;;;;;;;;CA2GzF,CAAC;AAEF,eAAe,OAAO,CAAC"}
1
+ {"version":3,"file":"runtime.d.ts","sourceRoot":"","sources":["../src/runtime.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,KAAK,aAAa,EAAsB,MAAM,4BAA4B,CAAC;AAGpF,OAAO,mBAAmB,CAAC;AAC3B,OAAO,qBAAqB,CAAC;AAI7B,OAAO,EAAE,YAAY,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAqCx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