@syntrologie/adapt-chatbot 2.27.0 → 2.28.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.
- package/dist/AdaptiveChatBar.d.ts +76 -0
- package/dist/AdaptiveChatBar.d.ts.map +1 -0
- package/dist/AdaptiveChatBar.js +10 -0
- package/dist/AdaptiveChatBar.js.map +7 -0
- package/dist/AdaptiveChatBarMountable.d.ts +35 -0
- package/dist/AdaptiveChatBarMountable.d.ts.map +1 -0
- package/dist/AdaptiveChatTrail.d.ts +77 -0
- package/dist/AdaptiveChatTrail.d.ts.map +1 -0
- package/dist/AdaptiveChatTrail.js +9 -0
- package/dist/AdaptiveChatTrail.js.map +7 -0
- package/dist/AdaptiveChipsStrip.d.ts +1150 -0
- package/dist/AdaptiveChipsStrip.d.ts.map +1 -0
- package/dist/AdaptiveChipsStrip.js +11 -0
- package/dist/AdaptiveChipsStrip.js.map +7 -0
- package/dist/AdaptiveChipsStripMountable.d.ts +24 -0
- package/dist/AdaptiveChipsStripMountable.d.ts.map +1 -0
- package/dist/ChatAssistantLit.d.ts +22 -50
- package/dist/ChatAssistantLit.d.ts.map +1 -1
- package/dist/ChatAssistantLit.js +5 -3
- package/dist/ChatSession.d.ts +178 -0
- package/dist/ChatSession.d.ts.map +1 -0
- package/dist/ChatTransport.d.ts +283 -0
- package/dist/ChatTransport.d.ts.map +1 -0
- package/dist/NavLinkMountable.d.ts +25 -0
- package/dist/NavLinkMountable.d.ts.map +1 -0
- package/dist/NavLinkMountable.test.d.ts +2 -0
- package/dist/NavLinkMountable.test.d.ts.map +1 -0
- package/dist/TextAnswerMountable.d.ts +17 -0
- package/dist/TextAnswerMountable.d.ts.map +1 -0
- package/dist/Turnstile.d.ts +83 -0
- package/dist/Turnstile.d.ts.map +1 -0
- package/dist/chunk-435KJD27.js +192 -0
- package/dist/chunk-435KJD27.js.map +7 -0
- package/dist/chunk-AUER7ZCK.js +634 -0
- package/dist/chunk-AUER7ZCK.js.map +7 -0
- package/dist/chunk-DOMEUJR7.js +382 -0
- package/dist/chunk-DOMEUJR7.js.map +7 -0
- package/dist/{chunk-W457NMGD.js → chunk-KUO67E2W.js} +1537 -4130
- package/dist/chunk-KUO67E2W.js.map +7 -0
- package/dist/chunk-QELVKBQV.js +214 -0
- package/dist/chunk-QELVKBQV.js.map +7 -0
- package/dist/chunk-UC4XU6GH.js +3306 -0
- package/dist/chunk-UC4XU6GH.js.map +7 -0
- package/dist/elements/ActionHandler.d.ts +34 -0
- package/dist/elements/ActionHandler.d.ts.map +1 -0
- package/dist/elements/ElementInstanceStore.d.ts +155 -0
- package/dist/elements/ElementInstanceStore.d.ts.map +1 -0
- package/dist/elements/ElementInstanceStore.test.d.ts +2 -0
- package/dist/elements/ElementInstanceStore.test.d.ts.map +1 -0
- package/dist/elements/ElementTypeHandler.d.ts +77 -0
- package/dist/elements/ElementTypeHandler.d.ts.map +1 -0
- package/dist/elements/ItemHandler.d.ts +60 -0
- package/dist/elements/ItemHandler.d.ts.map +1 -0
- package/dist/elements/ItemHandler.test.d.ts +2 -0
- package/dist/elements/ItemHandler.test.d.ts.map +1 -0
- package/dist/elements/TileHandler.d.ts +52 -0
- package/dist/elements/TileHandler.d.ts.map +1 -0
- package/dist/elements/blockRenderer.d.ts +46 -0
- package/dist/elements/blockRenderer.d.ts.map +1 -0
- package/dist/elements/blockRenderer.test.d.ts +13 -0
- package/dist/elements/blockRenderer.test.d.ts.map +1 -0
- package/dist/elements/blocks.d.ts +58 -0
- package/dist/elements/blocks.d.ts.map +1 -0
- package/dist/elements/envelope.d.ts +24 -0
- package/dist/elements/envelope.d.ts.map +1 -0
- package/dist/elements/fetcher.d.ts +40 -0
- package/dist/elements/fetcher.d.ts.map +1 -0
- package/dist/elements/index.d.ts +32 -0
- package/dist/elements/index.d.ts.map +1 -0
- package/dist/elements/types.d.ts +106 -0
- package/dist/elements/types.d.ts.map +1 -0
- package/dist/observer/__tests__/allowlist.test.d.ts +9 -0
- package/dist/observer/__tests__/allowlist.test.d.ts.map +1 -0
- package/dist/observer/__tests__/observer-isolation.test.d.ts +13 -0
- package/dist/observer/__tests__/observer-isolation.test.d.ts.map +1 -0
- package/dist/observer/__tests__/queue.test.d.ts +2 -0
- package/dist/observer/__tests__/queue.test.d.ts.map +1 -0
- package/dist/observer/__tests__/transport.test.d.ts +2 -0
- package/dist/observer/__tests__/transport.test.d.ts.map +1 -0
- package/dist/observer/allowlist.d.ts +32 -0
- package/dist/observer/allowlist.d.ts.map +1 -0
- package/dist/observer/index.d.ts +35 -0
- package/dist/observer/index.d.ts.map +1 -0
- package/dist/observer/queue.d.ts +57 -0
- package/dist/observer/queue.d.ts.map +1 -0
- package/dist/observer/transport.d.ts +26 -0
- package/dist/observer/transport.d.ts.map +1 -0
- package/dist/runtime.d.ts +7 -0
- package/dist/runtime.d.ts.map +1 -1
- package/dist/runtime.js +1617 -2
- package/dist/runtime.js.map +4 -4
- package/dist/schema.d.ts +3120 -7
- package/dist/schema.d.ts.map +1 -1
- package/dist/schema.js +40 -0
- package/dist/schema.js.map +2 -2
- package/dist/types.d.ts +30 -2
- package/dist/types.d.ts.map +1 -1
- package/package.json +13 -1
- package/dist/chunk-W457NMGD.js.map +0 -7
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Element-instantiation machinery for the adaptive chatbot.
|
|
3
|
+
*
|
|
4
|
+
* Originally added in runtime-sdk; moved here in two passes:
|
|
5
|
+
* - Phase 6c: store / handlers / fetcher / envelope / wire types
|
|
6
|
+
* (every consumer was the chat surface).
|
|
7
|
+
* - Phase 6c.1: Portable Text vocab + safe renderer (`renderBlocks`,
|
|
8
|
+
* `BlockNode`, etc.). Generic by shape but zero non-chat consumers
|
|
9
|
+
* in practice, so leaving it in the universal CDN bundle made every
|
|
10
|
+
* non-chat customer pay the bundle cost for nothing — the
|
|
11
|
+
* runtime-as-OS principle says don't ship interfaces with no
|
|
12
|
+
* consumers in the universal bundle.
|
|
13
|
+
*
|
|
14
|
+
* If a second adaptive ever needs Portable Text rendering, promote
|
|
15
|
+
* `blocks.ts` + `blockRenderer.ts` to a leaf shared package
|
|
16
|
+
* (`@syntrologie/portable-text`) and have both consumers depend on it.
|
|
17
|
+
* Do NOT push it back into runtime-sdk.
|
|
18
|
+
*/
|
|
19
|
+
export { ActionHandler } from './ActionHandler';
|
|
20
|
+
export type { RenderOptions } from './blockRenderer';
|
|
21
|
+
export { renderBlocks } from './blockRenderer';
|
|
22
|
+
export type { BlockNode, CodeBlock, HeadingBlock, HeadingLevel, LinkMark, ListBlock, ListItemBlock, ListStyle, MarkType, ParagraphBlock, TextSpan, } from './blocks';
|
|
23
|
+
export { ElementInstanceStore } from './ElementInstanceStore';
|
|
24
|
+
export type { ElementHandlerContext, ElementLifecycle, ElementMutationContext, ElementTypeHandler, ValidateResult, } from './ElementTypeHandler';
|
|
25
|
+
export { decodeMutationEnvelope } from './envelope';
|
|
26
|
+
export type { FetchMountedElementsOptions } from './fetcher';
|
|
27
|
+
export { fetchMountedElements } from './fetcher';
|
|
28
|
+
export type { CompositionalAppendEvent, CompositionalPatchEvent, CompositionalRemoveEvent, } from './ItemHandler';
|
|
29
|
+
export { COMPOSITIONAL_APPEND_EVENT, COMPOSITIONAL_PATCH_EVENT, COMPOSITIONAL_REMOVE_EVENT, ItemHandler, } from './ItemHandler';
|
|
30
|
+
export { TileHandler } from './TileHandler';
|
|
31
|
+
export type { AgentProvenance, ElementMutation, ElementState, MountedElement, MountedElementsResponse, MountMutation, Mutation, MutationEnvelope, NoPlacement, ParentTilePlacement, PatchMutation, Placement, SelectorPlacement, SlotPlacement, UnmountMutation, } from './types';
|
|
32
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/elements/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,YAAY,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AACrD,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,YAAY,EACV,SAAS,EACT,SAAS,EACT,YAAY,EACZ,YAAY,EACZ,QAAQ,EACR,SAAS,EACT,aAAa,EACb,SAAS,EACT,QAAQ,EACR,cAAc,EACd,QAAQ,GACT,MAAM,UAAU,CAAC;AAClB,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAC9D,YAAY,EACV,qBAAqB,EACrB,gBAAgB,EAChB,sBAAsB,EACtB,kBAAkB,EAClB,cAAc,GACf,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,sBAAsB,EAAE,MAAM,YAAY,CAAC;AACpD,YAAY,EAAE,2BAA2B,EAAE,MAAM,WAAW,CAAC;AAC7D,OAAO,EAAE,oBAAoB,EAAE,MAAM,WAAW,CAAC;AACjD,YAAY,EACV,wBAAwB,EACxB,uBAAuB,EACvB,wBAAwB,GACzB,MAAM,eAAe,CAAC;AACvB,OAAO,EACL,0BAA0B,EAC1B,yBAAyB,EACzB,0BAA0B,EAC1B,WAAW,GACZ,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,YAAY,EACV,eAAe,EACf,eAAe,EACf,YAAY,EACZ,cAAc,EACd,uBAAuB,EACvB,aAAa,EACb,QAAQ,EACR,gBAAgB,EAChB,WAAW,EACX,mBAAmB,EACnB,aAAa,EACb,SAAS,EACT,iBAAiB,EACjB,aAAa,EACb,eAAe,GAChB,MAAM,SAAS,CAAC"}
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Wire types for LLM-authored UI element instantiation — Phase 6.
|
|
3
|
+
*
|
|
4
|
+
* These mirror the backend Pydantic models in
|
|
5
|
+
* `platform/backend/app/services/agents/elements_models.py`. Kept as
|
|
6
|
+
* plain TypeScript types (no Zod validators) for v1 — the SDK trusts
|
|
7
|
+
* what it fetches from the workspace's own backend per the design doc's
|
|
8
|
+
* "backend is the sole enforcer" stance. Add Zod here if defence-in-depth
|
|
9
|
+
* ever becomes a real concern.
|
|
10
|
+
*
|
|
11
|
+
* Wire format documented in
|
|
12
|
+
* `docs/plans/current/2026-05-24-adaptive-chatbot-action-triggers-design.md`.
|
|
13
|
+
*/
|
|
14
|
+
export type ElementState = 'active' | 'applied' | 'reverted' | 'expired';
|
|
15
|
+
export interface AgentProvenance {
|
|
16
|
+
agent_id: string;
|
|
17
|
+
turn_id: string;
|
|
18
|
+
}
|
|
19
|
+
export interface Mutation {
|
|
20
|
+
op: 'mount' | 'patch' | 'unmount';
|
|
21
|
+
at: string;
|
|
22
|
+
by: AgentProvenance;
|
|
23
|
+
paths?: string[];
|
|
24
|
+
}
|
|
25
|
+
export interface SlotPlacement {
|
|
26
|
+
type: 'slot';
|
|
27
|
+
slot: string;
|
|
28
|
+
}
|
|
29
|
+
export interface SelectorPlacement {
|
|
30
|
+
type: 'selector';
|
|
31
|
+
selector: string;
|
|
32
|
+
position: 'beforebegin' | 'afterbegin' | 'beforeend' | 'afterend' | 'replace' | 'modify';
|
|
33
|
+
}
|
|
34
|
+
export interface NoPlacement {
|
|
35
|
+
type: 'none';
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Compositional-item placement — for chips, FAQ items, nav tips that
|
|
39
|
+
* mount INSIDE an existing tile's compositional-actions list rather
|
|
40
|
+
* than occupying their own slot. `tile_id` references a tile by its
|
|
41
|
+
* config-time id (e.g. `hero-chips`); `position` controls insertion
|
|
42
|
+
* order in the parent's items array.
|
|
43
|
+
*
|
|
44
|
+
* Backend mirror: `ParentTilePlacement` in
|
|
45
|
+
* `platform/backend/app/services/agents/elements_models.py`.
|
|
46
|
+
*/
|
|
47
|
+
export interface ParentTilePlacement {
|
|
48
|
+
type: 'parent_tile';
|
|
49
|
+
tile_id: string;
|
|
50
|
+
position: 'append' | 'prepend';
|
|
51
|
+
}
|
|
52
|
+
export type Placement = SlotPlacement | SelectorPlacement | NoPlacement | ParentTilePlacement;
|
|
53
|
+
export interface MountedElement {
|
|
54
|
+
instance_id: string;
|
|
55
|
+
element_type: 'tile' | 'action' | 'item';
|
|
56
|
+
template_id: string;
|
|
57
|
+
placement: Placement;
|
|
58
|
+
content: Record<string, unknown>;
|
|
59
|
+
state: ElementState;
|
|
60
|
+
mounted_by: AgentProvenance;
|
|
61
|
+
mounted_at: string;
|
|
62
|
+
version: number;
|
|
63
|
+
mutation_log?: Mutation[];
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Live-mutation envelope carried on the `syntro.element.mutation`
|
|
67
|
+
* AG-UI custom event.
|
|
68
|
+
*/
|
|
69
|
+
export interface MutationEnvelope {
|
|
70
|
+
type: 'syntro.element.mutation';
|
|
71
|
+
schema_version: 'v0';
|
|
72
|
+
mutations: ElementMutation[];
|
|
73
|
+
}
|
|
74
|
+
export type ElementMutation = MountMutation | PatchMutation | UnmountMutation;
|
|
75
|
+
export interface MountMutation {
|
|
76
|
+
op: 'mount';
|
|
77
|
+
instance: MountedElement;
|
|
78
|
+
}
|
|
79
|
+
export interface PatchMutation {
|
|
80
|
+
op: 'patch';
|
|
81
|
+
instance_id: string;
|
|
82
|
+
patches: {
|
|
83
|
+
path: string;
|
|
84
|
+
value: unknown;
|
|
85
|
+
}[];
|
|
86
|
+
expected_version: number;
|
|
87
|
+
/** New version after patch, sent by the backend. SDK uses this for dedup. */
|
|
88
|
+
resulting_version: number;
|
|
89
|
+
/** Full content snapshot after patch — saves the SDK from having to
|
|
90
|
+
* apply patches client-side. */
|
|
91
|
+
resulting_content: Record<string, unknown>;
|
|
92
|
+
}
|
|
93
|
+
export interface UnmountMutation {
|
|
94
|
+
op: 'unmount';
|
|
95
|
+
instance_id: string;
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Response shape from `GET /api/adaptive/mounted_elements`. Matches the
|
|
99
|
+
* backend `MountedElementsResponse` (Phase 4).
|
|
100
|
+
*/
|
|
101
|
+
export interface MountedElementsResponse {
|
|
102
|
+
mounted_elements: MountedElement[];
|
|
103
|
+
session_expires_at: string | null;
|
|
104
|
+
schema_version: 'v0';
|
|
105
|
+
}
|
|
106
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +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,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,QAAQ;IACvB,EAAE,EAAE,OAAO,GAAG,OAAO,GAAG,SAAS,CAAC;IAClC,EAAE,EAAE,MAAM,CAAC;IACX,EAAE,EAAE,eAAe,CAAC;IACpB,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;CAClB;AAED,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;CACd;AAED,MAAM,WAAW,iBAAiB;IAChC,IAAI,EAAE,UAAU,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,aAAa,GAAG,YAAY,GAAG,WAAW,GAAG,UAAU,GAAG,SAAS,GAAG,QAAQ,CAAC;CAC1F;AAED,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,MAAM,CAAC;CACd;AAED;;;;;;;;;GASG;AACH,MAAM,WAAW,mBAAmB;IAClC,IAAI,EAAE,aAAa,CAAC;IACpB,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,QAAQ,GAAG,SAAS,CAAC;CAChC;AAED,MAAM,MAAM,SAAS,GAAG,aAAa,GAAG,iBAAiB,GAAG,WAAW,GAAG,mBAAmB,CAAC;AAE9F,MAAM,WAAW,cAAc;IAC7B,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,EAAE,MAAM,GAAG,QAAQ,GAAG,MAAM,CAAC;IACzC,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,SAAS,CAAC;IACrB,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACjC,KAAK,EAAE,YAAY,CAAC;IACpB,UAAU,EAAE,eAAe,CAAC;IAC5B,UAAU,EAAE,MAAM,CAAC;IACnB,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,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tests for the pure event-allowlist module.
|
|
3
|
+
*
|
|
4
|
+
* Each PostHog autocapture event shape maps to either:
|
|
5
|
+
* - a templated ObservationEvent ready for transport, or
|
|
6
|
+
* - null (drop — not significant).
|
|
7
|
+
*/
|
|
8
|
+
export {};
|
|
9
|
+
//# sourceMappingURL=allowlist.test.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"allowlist.test.d.ts","sourceRoot":"","sources":["../../../src/observer/__tests__/allowlist.test.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Isolation tests for the observer.
|
|
3
|
+
*
|
|
4
|
+
* The observer must never include host-page PII in observation text.
|
|
5
|
+
* PostHog autocapture strips sensitive properties from $elements before
|
|
6
|
+
* delivery, but we add a belt-and-suspenders check here against text
|
|
7
|
+
* fields that look like emails, phones, or credit-card patterns.
|
|
8
|
+
*
|
|
9
|
+
* If this test ever fails, the templates in allowlist.ts have regressed
|
|
10
|
+
* — fix there, not by suppressing this test.
|
|
11
|
+
*/
|
|
12
|
+
export {};
|
|
13
|
+
//# sourceMappingURL=observer-isolation.test.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"observer-isolation.test.d.ts","sourceRoot":"","sources":["../../../src/observer/__tests__/observer-isolation.test.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"queue.test.d.ts","sourceRoot":"","sources":["../../../src/observer/__tests__/queue.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transport.test.d.ts","sourceRoot":"","sources":["../../../src/observer/__tests__/transport.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pure mapping from raw PostHog events to ObservationEvents.
|
|
3
|
+
*
|
|
4
|
+
* One function: matchEvent(raw, opts) → ObservationEvent | null. Null means
|
|
5
|
+
* "drop, not significant." This module is the single source of truth for what
|
|
6
|
+
* the chat agent sees on the in-session timeline; the SDK observer never
|
|
7
|
+
* forwards anything matchEvent returns null for.
|
|
8
|
+
*
|
|
9
|
+
* Kept dependency-free (no DOM access, no PostHog SDK imports) so the
|
|
10
|
+
* Vitest unit tests run without any browser shim.
|
|
11
|
+
*/
|
|
12
|
+
export type ObservationKind = 'nav' | 'click' | 'form' | 'rage' | 'dead' | 'scroll' | 'view' | 'idle' | 'hover' | 'hesitation' | 'custom';
|
|
13
|
+
export interface ObservationEvent {
|
|
14
|
+
ts: number;
|
|
15
|
+
kind: ObservationKind;
|
|
16
|
+
text: string;
|
|
17
|
+
ref?: string;
|
|
18
|
+
}
|
|
19
|
+
/** Shape of a raw event reaching matchEvent. Loose by design — PostHog's
|
|
20
|
+
* event shape evolves, and we want matchEvent to be resilient to extra
|
|
21
|
+
* properties. */
|
|
22
|
+
export interface RawEvent {
|
|
23
|
+
event: string;
|
|
24
|
+
timestamp: number;
|
|
25
|
+
properties: Record<string, unknown>;
|
|
26
|
+
}
|
|
27
|
+
export interface MatchOptions {
|
|
28
|
+
/** Workspace-configured custom event names to forward as kind="custom". */
|
|
29
|
+
observableEvents?: readonly string[];
|
|
30
|
+
}
|
|
31
|
+
export declare function matchEvent(raw: RawEvent, opts?: MatchOptions): ObservationEvent | null;
|
|
32
|
+
//# sourceMappingURL=allowlist.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"allowlist.d.ts","sourceRoot":"","sources":["../../src/observer/allowlist.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,MAAM,MAAM,eAAe,GACvB,KAAK,GACL,OAAO,GACP,MAAM,GACN,MAAM,GACN,MAAM,GACN,QAAQ,GACR,MAAM,GACN,MAAM,GACN,OAAO,GACP,YAAY,GACZ,QAAQ,CAAC;AAEb,MAAM,WAAW,gBAAgB;IAC/B,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,eAAe,CAAC;IACtB,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,CAAC,EAAE,MAAM,CAAC;CACd;AAED;;kBAEkB;AAClB,MAAM,WAAW,QAAQ;IACvB,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACrC;AAED,MAAM,WAAW,YAAY;IAC3B,2EAA2E;IAC3E,gBAAgB,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;CACtC;AA0ED,wBAAgB,UAAU,CAAC,GAAG,EAAE,QAAQ,EAAE,IAAI,GAAE,YAAiB,GAAG,gBAAgB,GAAG,IAAI,CA4I1F"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Observer entry point.
|
|
3
|
+
*
|
|
4
|
+
* startObserver wires the four pieces — allowlist filter + queue +
|
|
5
|
+
* transport + PostHog subscription — into a single lifecycle controlled
|
|
6
|
+
* via the returned handle. The handle is reference-counted: multiple
|
|
7
|
+
* call sites (e.g. multiple chatbot widgets on the same page) share
|
|
8
|
+
* one observer.
|
|
9
|
+
*
|
|
10
|
+
* Idempotent: calling startObserver twice with equivalent options
|
|
11
|
+
* returns the same instance. Calling stop() decrements the ref count;
|
|
12
|
+
* the observer tears down only when the count reaches zero.
|
|
13
|
+
*/
|
|
14
|
+
import { type RawEvent } from './allowlist';
|
|
15
|
+
import { type ObserverStats } from './queue';
|
|
16
|
+
import { type Transport } from './transport';
|
|
17
|
+
export interface StartObserverOptions {
|
|
18
|
+
url: string;
|
|
19
|
+
token: () => string;
|
|
20
|
+
getDistinctId: () => string | null;
|
|
21
|
+
observableEvents?: readonly string[];
|
|
22
|
+
/** Test seam: override fetch/timer behavior by injecting a custom transport. */
|
|
23
|
+
transport?: Transport;
|
|
24
|
+
}
|
|
25
|
+
export interface ObserverHandle {
|
|
26
|
+
stop(): void;
|
|
27
|
+
stats(): ObserverStats;
|
|
28
|
+
/** Test seam: ingest a raw event directly without depending on PostHog being loaded. */
|
|
29
|
+
ingest(raw: RawEvent): void;
|
|
30
|
+
flushNow(): Promise<void>;
|
|
31
|
+
}
|
|
32
|
+
export declare function startObserver(opts: StartObserverOptions): ObserverHandle;
|
|
33
|
+
/** Test-only: reset module singleton state. */
|
|
34
|
+
export declare function _resetObserverForTests(): void;
|
|
35
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/observer/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAc,KAAK,QAAQ,EAAE,MAAM,aAAa,CAAC;AACxD,OAAO,EAAiB,KAAK,aAAa,EAAE,MAAM,SAAS,CAAC;AAC5D,OAAO,EAAmB,KAAK,SAAS,EAAE,MAAM,aAAa,CAAC;AAE9D,MAAM,WAAW,oBAAoB;IACnC,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,MAAM,MAAM,CAAC;IACpB,aAAa,EAAE,MAAM,MAAM,GAAG,IAAI,CAAC;IACnC,gBAAgB,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IACrC,gFAAgF;IAChF,SAAS,CAAC,EAAE,SAAS,CAAC;CACvB;AAED,MAAM,WAAW,cAAc;IAC7B,IAAI,IAAI,IAAI,CAAC;IACb,KAAK,IAAI,aAAa,CAAC;IACvB,wFAAwF;IACxF,MAAM,CAAC,GAAG,EAAE,QAAQ,GAAG,IAAI,CAAC;IAC5B,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CAC3B;AAoDD,wBAAgB,aAAa,CAAC,IAAI,EAAE,oBAAoB,GAAG,cAAc,CAoCxE;AAoCD,+CAA+C;AAC/C,wBAAgB,sBAAsB,IAAI,IAAI,CAK7C"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* In-memory batching queue for ObservationEvents.
|
|
3
|
+
*
|
|
4
|
+
* Holds events until either a size threshold or a time interval triggers
|
|
5
|
+
* a flush. The flush function is injected so transport choice (fetch vs.
|
|
6
|
+
* sendBeacon) and auth wiring stay out of this module.
|
|
7
|
+
*
|
|
8
|
+
* Backoff strategy: pure exponential, starting at 1s and capping at 30s
|
|
9
|
+
* (1s → 2s → 4s → 8s → 16s → 30s). Reset on first successful flush.
|
|
10
|
+
* Jitter is intentionally omitted — the observer queue is per-client, so
|
|
11
|
+
* thundering-herd at recovery is not a meaningful risk, and deterministic
|
|
12
|
+
* timing keeps unit tests fast and stable. A "permanent" failure (4xx
|
|
13
|
+
* marked by the caller) disables the queue entirely — no further flushes
|
|
14
|
+
* are attempted; lastError is exposed via stats().
|
|
15
|
+
*/
|
|
16
|
+
import type { ObservationEvent } from './allowlist';
|
|
17
|
+
export interface FlushError extends Error {
|
|
18
|
+
/** When true, the queue stops trying forever. Set by transport for 4xx. */
|
|
19
|
+
permanent?: boolean;
|
|
20
|
+
}
|
|
21
|
+
export interface ObserverQueueOptions {
|
|
22
|
+
batchSize: number;
|
|
23
|
+
flushIntervalMs: number;
|
|
24
|
+
queueCap: number;
|
|
25
|
+
flush: (batch: ObservationEvent[]) => Promise<void>;
|
|
26
|
+
backoffStartMs?: number;
|
|
27
|
+
backoffCapMs?: number;
|
|
28
|
+
}
|
|
29
|
+
export interface ObserverStats {
|
|
30
|
+
queued: number;
|
|
31
|
+
sent: number;
|
|
32
|
+
dropped: number;
|
|
33
|
+
lastError: string | null;
|
|
34
|
+
disabled: boolean;
|
|
35
|
+
}
|
|
36
|
+
export declare class ObserverQueue {
|
|
37
|
+
private readonly _opts;
|
|
38
|
+
private readonly _buffer;
|
|
39
|
+
private _sent;
|
|
40
|
+
private _dropped;
|
|
41
|
+
private _lastError;
|
|
42
|
+
private _disabled;
|
|
43
|
+
private _intervalTimer;
|
|
44
|
+
private _backoffTimer;
|
|
45
|
+
private _currentBackoffMs;
|
|
46
|
+
private _inFlight;
|
|
47
|
+
constructor(opts: ObserverQueueOptions);
|
|
48
|
+
push(event: ObservationEvent): void;
|
|
49
|
+
flushNow(): Promise<void>;
|
|
50
|
+
stats(): ObserverStats;
|
|
51
|
+
private _scheduleImmediate;
|
|
52
|
+
private _scheduleInterval;
|
|
53
|
+
private _clearInterval;
|
|
54
|
+
private _flush;
|
|
55
|
+
private _scheduleBackoff;
|
|
56
|
+
}
|
|
57
|
+
//# sourceMappingURL=queue.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"queue.d.ts","sourceRoot":"","sources":["../../src/observer/queue.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAEpD,MAAM,WAAW,UAAW,SAAQ,KAAK;IACvC,2EAA2E;IAC3E,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB;AAED,MAAM,WAAW,oBAAoB;IACnC,SAAS,EAAE,MAAM,CAAC;IAClB,eAAe,EAAE,MAAM,CAAC;IACxB,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,CAAC,KAAK,EAAE,gBAAgB,EAAE,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IACpD,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED,MAAM,WAAW,aAAa;IAC5B,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,QAAQ,EAAE,OAAO,CAAC;CACnB;AAED,qBAAa,aAAa;IACxB,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAiC;IACvD,OAAO,CAAC,QAAQ,CAAC,OAAO,CAA0B;IAClD,OAAO,CAAC,KAAK,CAAK;IAClB,OAAO,CAAC,QAAQ,CAAK;IACrB,OAAO,CAAC,UAAU,CAAuB;IACzC,OAAO,CAAC,SAAS,CAAS;IAC1B,OAAO,CAAC,cAAc,CAA8C;IACpE,OAAO,CAAC,aAAa,CAA8C;IACnE,OAAO,CAAC,iBAAiB,CAAK;IAC9B,OAAO,CAAC,SAAS,CAAS;gBAEd,IAAI,EAAE,oBAAoB;IAQtC,IAAI,CAAC,KAAK,EAAE,gBAAgB,GAAG,IAAI;IAe7B,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC;IAK/B,KAAK,IAAI,aAAa;IAUtB,OAAO,CAAC,kBAAkB;IAM1B,OAAO,CAAC,iBAAiB;IAQzB,OAAO,CAAC,cAAc;YAOR,MAAM;IA0BpB,OAAO,CAAC,gBAAgB;CAazB"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* HTTP transport for the observer queue.
|
|
3
|
+
*
|
|
4
|
+
* Two send paths:
|
|
5
|
+
* - send(batch) — async fetch. Used for normal flushes. Throws on
|
|
6
|
+
* non-2xx; sets the FlushError.permanent flag for 4xx so the queue
|
|
7
|
+
* stops trying.
|
|
8
|
+
* - sendBeacon(batch) — fire-and-forget via navigator.sendBeacon.
|
|
9
|
+
* Used on `pagehide` so the last batch survives navigation. No
|
|
10
|
+
* error path — beacon failure is invisible by design.
|
|
11
|
+
*
|
|
12
|
+
* Auth: same syn_ Bearer token mechanism as /stream. The token is read
|
|
13
|
+
* via a getter so SDK tokens that rotate live get refreshed naturally.
|
|
14
|
+
*/
|
|
15
|
+
import type { ObservationEvent } from './allowlist';
|
|
16
|
+
export interface TransportOptions {
|
|
17
|
+
url: string;
|
|
18
|
+
token: () => string;
|
|
19
|
+
getDistinctId: () => string | null;
|
|
20
|
+
}
|
|
21
|
+
export interface Transport {
|
|
22
|
+
send(batch: ObservationEvent[]): Promise<void>;
|
|
23
|
+
sendBeacon(batch: ObservationEvent[]): boolean;
|
|
24
|
+
}
|
|
25
|
+
export declare function createTransport(opts: TransportOptions): Transport;
|
|
26
|
+
//# sourceMappingURL=transport.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transport.d.ts","sourceRoot":"","sources":["../../src/observer/transport.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAEpD,MAAM,WAAW,gBAAgB;IAC/B,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,MAAM,MAAM,CAAC;IACpB,aAAa,EAAE,MAAM,MAAM,GAAG,IAAI,CAAC;CACpC;AAED,MAAM,WAAW,SAAS;IACxB,IAAI,CAAC,KAAK,EAAE,gBAAgB,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC/C,UAAU,CAAC,KAAK,EAAE,gBAAgB,EAAE,GAAG,OAAO,CAAC;CAChD;AAYD,wBAAgB,eAAe,CAAC,IAAI,EAAE,gBAAgB,GAAG,SAAS,CAoCjE"}
|
package/dist/runtime.d.ts
CHANGED
|
@@ -3,7 +3,14 @@
|
|
|
3
3
|
*
|
|
4
4
|
* Runtime manifest for the AI chat assistant adaptive.
|
|
5
5
|
* Uses @syntrologie/chat for the UI — no React dependency.
|
|
6
|
+
*
|
|
7
|
+
* Chat surfaces are config-driven: customers reference the chat-bar
|
|
8
|
+
* widget id (`adaptive-chatbot:chat-bar`) from `slots.drawer.lid` (to
|
|
9
|
+
* replace the launcher FAB) or any other slot's `lid` / tile slot. The
|
|
10
|
+
* adaptive no longer auto-registers a canvas lid renderer.
|
|
6
11
|
*/
|
|
12
|
+
import './AdaptiveChatBar';
|
|
13
|
+
import './AdaptiveChatTrail';
|
|
7
14
|
export declare const runtime: {
|
|
8
15
|
id: string;
|
|
9
16
|
version: string;
|
package/dist/runtime.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runtime.d.ts","sourceRoot":"","sources":["../src/runtime.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"runtime.d.ts","sourceRoot":"","sources":["../src/runtime.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAIH,OAAO,mBAAmB,CAAC;AAC3B,OAAO,qBAAqB,CAAC;AAO7B,eAAO,MAAM,OAAO;;;;;;;;;;;;;;;;;CA4EnB,CAAC;AAEF,eAAe,OAAO,CAAC"}
|