@syntrologie/adapt-chatbot 2.8.0-canary.43 → 2.8.0-canary.430
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 +175 -0
- package/dist/AdaptiveChatBar.d.ts.map +1 -0
- package/dist/AdaptiveChatBar.js +11 -0
- package/dist/AdaptiveChatBar.js.map +7 -0
- package/dist/AdaptiveChatBarMountable.d.ts +80 -0
- package/dist/AdaptiveChatBarMountable.d.ts.map +1 -0
- package/dist/AdaptiveChatTrail.anchor-scroll.test.d.ts +2 -0
- package/dist/AdaptiveChatTrail.anchor-scroll.test.d.ts.map +1 -0
- package/dist/AdaptiveChatTrail.d.ts +415 -0
- package/dist/AdaptiveChatTrail.d.ts.map +1 -0
- package/dist/AdaptiveChatTrail.js +11 -0
- package/dist/AdaptiveChatTrail.js.map +7 -0
- package/dist/AdaptiveChatTrail.test.d.ts +2 -0
- package/dist/AdaptiveChatTrail.test.d.ts.map +1 -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 +60 -0
- package/dist/ChatAssistantLit.d.ts.map +1 -0
- package/dist/ChatAssistantLit.js +13 -0
- package/dist/ChatAssistantLit.js.map +7 -0
- package/dist/ChatSession.d.ts +230 -0
- package/dist/ChatSession.d.ts.map +1 -0
- package/dist/ChatTransport.d.ts +360 -0
- package/dist/ChatTransport.d.ts.map +1 -0
- package/dist/InlineRegistryWidgetMount.test.d.ts +2 -0
- package/dist/InlineRegistryWidgetMount.test.d.ts.map +1 -0
- package/dist/InlineWidgetLiveMount.test.d.ts +2 -0
- package/dist/InlineWidgetLiveMount.test.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/TextAnswerMountable.test.d.ts +2 -0
- package/dist/TextAnswerMountable.test.d.ts.map +1 -0
- package/dist/Turnstile.d.ts +83 -0
- package/dist/Turnstile.d.ts.map +1 -0
- package/dist/cdn.d.ts +2 -6
- package/dist/cdn.d.ts.map +1 -1
- package/dist/chunk-5W75LR6M.js +460 -0
- package/dist/chunk-5W75LR6M.js.map +7 -0
- package/dist/chunk-7WSMNAKW.js +3824 -0
- package/dist/chunk-7WSMNAKW.js.map +7 -0
- package/dist/chunk-EWPPVPJ4.js +14 -0
- package/dist/chunk-EWPPVPJ4.js.map +7 -0
- package/dist/chunk-GP4OSTZT.js +641 -0
- package/dist/chunk-GP4OSTZT.js.map +7 -0
- package/dist/chunk-HELUC5JI.js +8971 -0
- package/dist/chunk-HELUC5JI.js.map +7 -0
- package/dist/chunk-HVGQJZMP.js +1520 -0
- package/dist/chunk-HVGQJZMP.js.map +7 -0
- package/dist/chunk-KPWW7N27.js +235 -0
- package/dist/chunk-KPWW7N27.js.map +7 -0
- package/dist/chunk-UVKRO5ER.js +13 -0
- package/dist/chunk-UVKRO5ER.js.map +7 -0
- package/dist/editor-lit.d.ts +37 -0
- package/dist/editor-lit.d.ts.map +1 -0
- package/dist/editor-lit.js +134 -0
- package/dist/editor-lit.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 +207 -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/TileHandler.test.d.ts +2 -0
- package/dist/elements/TileHandler.test.d.ts.map +1 -0
- package/dist/elements/__tests__/ElementInstanceStore.recall.test.d.ts +2 -0
- package/dist/elements/__tests__/ElementInstanceStore.recall.test.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 +33 -0
- package/dist/elements/index.d.ts.map +1 -0
- package/dist/elements/store-singleton.d.ts +4 -0
- package/dist/elements/store-singleton.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__/bus-translate.test.d.ts +16 -0
- package/dist/observer/__tests__/bus-translate.test.d.ts.map +1 -0
- package/dist/observer/__tests__/lifecycle.test.d.ts +2 -0
- package/dist/observer/__tests__/lifecycle.test.d.ts.map +1 -0
- package/dist/observer/__tests__/observer-enrich.test.d.ts +10 -0
- package/dist/observer/__tests__/observer-enrich.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 +30 -0
- package/dist/observer/allowlist.d.ts.map +1 -0
- package/dist/observer/bus-translate.d.ts +33 -0
- package/dist/observer/bus-translate.d.ts.map +1 -0
- package/dist/observer/index.d.ts +44 -0
- package/dist/observer/index.d.ts.map +1 -0
- package/dist/observer/queue.d.ts +63 -0
- package/dist/observer/queue.d.ts.map +1 -0
- package/dist/observer/transport.d.ts +27 -0
- package/dist/observer/transport.d.ts.map +1 -0
- package/dist/runtime-lit.d.ts +8 -0
- package/dist/runtime-lit.d.ts.map +1 -0
- package/dist/runtime.d.ts +10 -3
- package/dist/runtime.d.ts.map +1 -1
- package/dist/runtime.js +2232 -29
- package/dist/runtime.js.map +7 -0
- package/dist/schema.d.ts +3340 -11
- package/dist/schema.d.ts.map +1 -1
- package/dist/schema.js +220 -31
- package/dist/schema.js.map +7 -0
- package/dist/test/setup.d.ts +1 -0
- package/dist/test/setup.d.ts.map +1 -0
- package/dist/types.d.ts +61 -40
- package/dist/types.d.ts.map +1 -1
- package/package.json +44 -23
- package/dist/ChatAssistant.d.ts +0 -18
- package/dist/ChatAssistant.d.ts.map +0 -1
- package/dist/ChatAssistant.js +0 -178
- package/dist/SyntroChatbot.d.ts +0 -14
- package/dist/SyntroChatbot.d.ts.map +0 -1
- package/dist/SyntroChatbot.js +0 -56
- package/dist/actionParser.d.ts +0 -15
- package/dist/actionParser.d.ts.map +0 -1
- package/dist/actionParser.js +0 -52
- package/dist/apiClient.d.ts +0 -23
- package/dist/apiClient.d.ts.map +0 -1
- package/dist/apiClient.js +0 -51
- package/dist/cdn.js +0 -37
- package/dist/editor.d.ts +0 -17
- package/dist/editor.d.ts.map +0 -1
- package/dist/editor.js +0 -36
- package/dist/tools/bridge.d.ts +0 -26
- package/dist/tools/bridge.d.ts.map +0 -1
- package/dist/tools/bridge.js +0 -25
- package/dist/tools/expanders.d.ts +0 -17
- package/dist/tools/expanders.d.ts.map +0 -1
- package/dist/tools/expanders.js +0 -41
- package/dist/tools/index.d.ts +0 -14
- package/dist/tools/index.d.ts.map +0 -1
- package/dist/tools/index.js +0 -11
- package/dist/tools/registrations/GetContextTool.d.ts +0 -7
- package/dist/tools/registrations/GetContextTool.d.ts.map +0 -1
- package/dist/tools/registrations/GetContextTool.js +0 -18
- package/dist/tools/registrations/ScrollToTool.d.ts +0 -7
- package/dist/tools/registrations/ScrollToTool.d.ts.map +0 -1
- package/dist/tools/registrations/ScrollToTool.js +0 -38
- package/dist/tools/registrations/ShowOverlayTool.d.ts +0 -7
- package/dist/tools/registrations/ShowOverlayTool.d.ts.map +0 -1
- package/dist/tools/registrations/ShowOverlayTool.js +0 -47
- package/dist/tools/registrations/index.d.ts +0 -19
- package/dist/tools/registrations/index.d.ts.map +0 -1
- package/dist/tools/registrations/index.js +0 -7
- package/dist/types.js +0 -6
- package/dist/useChat.d.ts +0 -25
- package/dist/useChat.d.ts.map +0 -1
- package/dist/useChat.js +0 -106
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Per-type handler interface for `ElementInstanceStore`.
|
|
3
|
+
*
|
|
4
|
+
* Adding a future element type (overlay / tour / form) is one new
|
|
5
|
+
* `ElementTypeHandler` implementation registered in the store —
|
|
6
|
+
* `ElementInstanceStore` itself stays type-neutral.
|
|
7
|
+
*
|
|
8
|
+
* Handlers own their per-type lifecycle. They receive the current
|
|
9
|
+
* `MountedElement` snapshot and the runtime's `ActionEngine` and either
|
|
10
|
+
* call `applyBatch` to drive DOM changes or hold on to returned
|
|
11
|
+
* `ActionHandle`s for later cleanup.
|
|
12
|
+
*
|
|
13
|
+
* Design choices the handlers MUST honor:
|
|
14
|
+
*
|
|
15
|
+
* - **Imperative actions never re-fire on boot.** When the store
|
|
16
|
+
* hydrates an element with `lifecycle === 'imperative'` and `state ===
|
|
17
|
+
* 'applied'`, the handler's `mount()` is NOT called. The backend
|
|
18
|
+
* records the prior invocation for audit but the SDK does not replay
|
|
19
|
+
* it (would re-scroll, re-navigate, etc.).
|
|
20
|
+
* - **Defense-in-depth content validation.** `validate()` is called
|
|
21
|
+
* before every mount/patch. The backend already validated, but the
|
|
22
|
+
* handler should refuse malformed content so a buggy server can't
|
|
23
|
+
* crash the runtime.
|
|
24
|
+
*/
|
|
25
|
+
import type { ActionEngine } from '../types';
|
|
26
|
+
import type { ElementMutation, MountedElement } from './types';
|
|
27
|
+
/** Lifecycle classification used to decide whether to apply on boot rehydrate. */
|
|
28
|
+
export type ElementLifecycle = 'stateful' | 'imperative' | 'ephemeral';
|
|
29
|
+
export interface ElementHandlerContext {
|
|
30
|
+
/** Runtime's ActionEngine — handlers use `applyBatch` to drive DOM
|
|
31
|
+
* changes via existing executors (`core:mountWidget`, etc.). */
|
|
32
|
+
actions: ActionEngine;
|
|
33
|
+
/** Runtime's event bus — handlers publish typed events that container
|
|
34
|
+
* widgets subscribe to. Used by `ItemHandler` to broadcast
|
|
35
|
+
* `element.compositional_append` so chip-strip / FAQ / nav-tips
|
|
36
|
+
* containers can insert LLM-authored items.
|
|
37
|
+
* Optional so test fixtures that exercise only DOM action handlers
|
|
38
|
+
* don't need to stub the bus.
|
|
39
|
+
*/
|
|
40
|
+
events?: {
|
|
41
|
+
publish: (name: string, props?: Record<string, unknown>) => void;
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
export type ValidateResult = {
|
|
45
|
+
accepted: true;
|
|
46
|
+
} | {
|
|
47
|
+
accepted: false;
|
|
48
|
+
reason: string;
|
|
49
|
+
detail?: string;
|
|
50
|
+
};
|
|
51
|
+
export interface ElementTypeHandler {
|
|
52
|
+
readonly typeName: 'tile' | 'action' | 'item';
|
|
53
|
+
/** Whether the handler's elements survive a boot rehydrate. Imperative
|
|
54
|
+
* handlers (action handler in v1) DO NOT replay applied instances. */
|
|
55
|
+
readonly lifecycle: ElementLifecycle;
|
|
56
|
+
/** Defense-in-depth — refuse malformed content/placement before the
|
|
57
|
+
* handler touches the DOM. The store calls this before `mount` and
|
|
58
|
+
* `patch`; a rejection is logged but does not throw — the store
|
|
59
|
+
* records the rejection on the instance and skips the apply. */
|
|
60
|
+
validate(instance: MountedElement, ctx: ElementHandlerContext): ValidateResult;
|
|
61
|
+
/** Apply a new mount to the DOM. Called once per mount; the store
|
|
62
|
+
* passes the instance object so the handler can read `placement`,
|
|
63
|
+
* `content`, `template_id`, etc. */
|
|
64
|
+
mount(instance: MountedElement, ctx: ElementHandlerContext): Promise<void>;
|
|
65
|
+
/** Apply a patch — typically by re-mounting the widget with merged
|
|
66
|
+
* content. v1 has no fine-grained reactivity; full re-mount is
|
|
67
|
+
* expected. */
|
|
68
|
+
patch(instance: MountedElement, ctx: ElementHandlerContext): Promise<void>;
|
|
69
|
+
/** Remove the element from the DOM. Idempotent — called for both
|
|
70
|
+
* user-initiated unmounts and TTL-triggered cleanup. */
|
|
71
|
+
unmount(instance: MountedElement, ctx: ElementHandlerContext): Promise<void>;
|
|
72
|
+
}
|
|
73
|
+
export interface ElementMutationContext extends ElementHandlerContext {
|
|
74
|
+
/** Op being processed — handler-side telemetry / debug surface. */
|
|
75
|
+
mutation: ElementMutation;
|
|
76
|
+
}
|
|
77
|
+
//# sourceMappingURL=ElementTypeHandler.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ElementTypeHandler.d.ts","sourceRoot":"","sources":["../../src/elements/ElementTypeHandler.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAC7C,OAAO,KAAK,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAE/D,kFAAkF;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
|
|
1
|
+
/**
|
|
2
|
+
* Item element handler — translates `parent_tile`-placed mount/patch/
|
|
3
|
+
* unmount mutations into pub/sub events that container widgets subscribe
|
|
4
|
+
* to.
|
|
5
|
+
*
|
|
6
|
+
* Container widgets (chips strip, FAQ accordion, nav tips) declare
|
|
7
|
+
* themselves participants by implementing the `CompositionalContainer`
|
|
8
|
+
* contract and subscribing to `runtime.events` with
|
|
9
|
+
* `element.compositional_append` / `element.compositional_patch` /
|
|
10
|
+
* `element.compositional_remove`. Each container filters by
|
|
11
|
+
* `props.tile_id === this.tileId`.
|
|
12
|
+
*
|
|
13
|
+
* Why pub/sub rather than DOM lookup? The runtime's event bus is
|
|
14
|
+
* domain-agnostic and already exists. Container widgets that aren't
|
|
15
|
+
* mounted yet (slow inline-slot wrapper hydration) miss the event,
|
|
16
|
+
* but the next subscribe-then-replay pass at container mount time picks
|
|
17
|
+
* up the durable session state from the LLM's `mounted_elements`. No
|
|
18
|
+
* DOM crawling, no MutationObserver wiring, no ordering assumption.
|
|
19
|
+
*
|
|
20
|
+
* The handler is dumb: it forwards the wire `content` as the `item`
|
|
21
|
+
* payload. The backend wrote that content as a fully-formed
|
|
22
|
+
* compositional-item envelope (`{kind, config: {id, title, payload}}`)
|
|
23
|
+
* so the receiving container can append it verbatim.
|
|
24
|
+
*/
|
|
25
|
+
import type { ElementHandlerContext, ElementTypeHandler, ValidateResult } from './ElementTypeHandler';
|
|
26
|
+
import type { MountedElement } from './types';
|
|
27
|
+
/** Event names. Kept as module constants so subscribers can import them
|
|
28
|
+
* instead of memorizing strings. */
|
|
29
|
+
export declare const COMPOSITIONAL_APPEND_EVENT = "element.compositional_append";
|
|
30
|
+
export declare const COMPOSITIONAL_PATCH_EVENT = "element.compositional_patch";
|
|
31
|
+
export declare const COMPOSITIONAL_REMOVE_EVENT = "element.compositional_remove";
|
|
32
|
+
export interface CompositionalAppendEvent {
|
|
33
|
+
/** Parent tile id from the mount's placement. Receivers filter on this. */
|
|
34
|
+
tile_id: string;
|
|
35
|
+
/** Unique id of the mounted item — the receiving container should also
|
|
36
|
+
* set this on the item's DOM as `data-syntro-element-id`. */
|
|
37
|
+
instance_id: string;
|
|
38
|
+
/** Wire shape constructed by the backend — `{kind, config: {…}}`. */
|
|
39
|
+
item: Record<string, unknown>;
|
|
40
|
+
/** Insertion position — receivers honor this when appending. */
|
|
41
|
+
position: 'append' | 'prepend';
|
|
42
|
+
}
|
|
43
|
+
export interface CompositionalPatchEvent {
|
|
44
|
+
tile_id: string;
|
|
45
|
+
instance_id: string;
|
|
46
|
+
item: Record<string, unknown>;
|
|
47
|
+
}
|
|
48
|
+
export interface CompositionalRemoveEvent {
|
|
49
|
+
tile_id: string;
|
|
50
|
+
instance_id: string;
|
|
51
|
+
}
|
|
52
|
+
export declare class ItemHandler implements ElementTypeHandler {
|
|
53
|
+
readonly typeName: "item";
|
|
54
|
+
readonly lifecycle: "stateful";
|
|
55
|
+
validate(instance: MountedElement, _ctx: ElementHandlerContext): ValidateResult;
|
|
56
|
+
mount(instance: MountedElement, ctx: ElementHandlerContext): Promise<void>;
|
|
57
|
+
patch(instance: MountedElement, ctx: ElementHandlerContext): Promise<void>;
|
|
58
|
+
unmount(instance: MountedElement, ctx: ElementHandlerContext): Promise<void>;
|
|
59
|
+
}
|
|
60
|
+
//# sourceMappingURL=ItemHandler.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ItemHandler.d.ts","sourceRoot":"","sources":["../../src/elements/ItemHandler.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEH,OAAO,KAAK,EACV,qBAAqB,EACrB,kBAAkB,EAClB,cAAc,EACf,MAAM,sBAAsB,CAAC;AAC9B,OAAO,KAAK,EAAE,cAAc,EAAuB,MAAM,SAAS,CAAC;AAEnE;qCACqC;AACrC,eAAO,MAAM,0BAA0B,iCAAiC,CAAC;AACzE,eAAO,MAAM,yBAAyB,gCAAgC,CAAC;AACvE,eAAO,MAAM,0BAA0B,iCAAiC,CAAC;AAEzE,MAAM,WAAW,wBAAwB;IACvC,2EAA2E;IAC3E,OAAO,EAAE,MAAM,CAAC;IAChB;kEAC8D;IAC9D,WAAW,EAAE,MAAM,CAAC;IACpB,qEAAqE;IACrE,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC9B,gEAAgE;IAChE,QAAQ,EAAE,QAAQ,GAAG,SAAS,CAAC;CAChC;AAED,MAAM,WAAW,uBAAuB;IACtC,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,EAAE,MAAM,CAAC;IACpB,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAC/B;AAED,MAAM,WAAW,wBAAwB;IACvC,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,EAAE,MAAM,CAAC;CACrB;AAED,qBAAa,WAAY,YAAW,kBAAkB;IACpD,QAAQ,CAAC,QAAQ,EAAG,MAAM,CAAU;IACpC,QAAQ,CAAC,SAAS,EAAG,UAAU,CAAU;IAEzC,QAAQ,CAAC,QAAQ,EAAE,cAAc,EAAE,IAAI,EAAE,qBAAqB,GAAG,cAAc;IAqBzE,KAAK,CAAC,QAAQ,EAAE,cAAc,EAAE,GAAG,EAAE,qBAAqB,GAAG,OAAO,CAAC,IAAI,CAAC;IAW1E,KAAK,CAAC,QAAQ,EAAE,cAAc,EAAE,GAAG,EAAE,qBAAqB,GAAG,OAAO,CAAC,IAAI,CAAC;IAU1E,OAAO,CAAC,QAAQ,EAAE,cAAc,EAAE,GAAG,EAAE,qBAAqB,GAAG,OAAO,CAAC,IAAI,CAAC;CAQnF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ItemHandler.test.d.ts","sourceRoot":"","sources":["../../src/elements/ItemHandler.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tile element handler — translates `slot`-placed mount/patch/unmount
|
|
3
|
+
* mutations into pub/sub events that the runtime SDK subscribes to.
|
|
4
|
+
*
|
|
5
|
+
* The runtime SDK's `SmartCanvasElementLit` already routes config-driven
|
|
6
|
+
* tiles to inline slots via `tile.slot === slotName`. LLM-authored tiles
|
|
7
|
+
* use the same path: we publish a TileConfig-shaped envelope and the
|
|
8
|
+
* runtime merges it into its tile array, then existing routing renders
|
|
9
|
+
* it inside the slot's `<syntro-tile-stack>` alongside any config tiles.
|
|
10
|
+
*
|
|
11
|
+
* Why pub/sub instead of `core:mountWidget` via ActionEngine?
|
|
12
|
+
*
|
|
13
|
+
* - `Surfaces.mount` is exclusive per slot — a second LLM tile to the
|
|
14
|
+
* same slot would displace the first.
|
|
15
|
+
* - `Surfaces` only knows built-in slot names; inline slots resolve
|
|
16
|
+
* anchors via SyntroInlineSlot, not via Surfaces.
|
|
17
|
+
* - Tiles need the SyntroTileCard chrome (chromeless handling, theme
|
|
18
|
+
* overrides, dismiss control) that `core:mountWidget` skips.
|
|
19
|
+
*
|
|
20
|
+
* Container widgets stay dumb: the runtime owns one tile array per slot
|
|
21
|
+
* and renders it the same way regardless of provenance. Subscribers
|
|
22
|
+
* filter on `slot === this.name`.
|
|
23
|
+
*
|
|
24
|
+
* Event names + payload types live in `@syntrologie/sdk-contracts` so
|
|
25
|
+
* both packages share the contract. Renaming a field there is a TS
|
|
26
|
+
* error here and in the runtime subscriber — no silent drift.
|
|
27
|
+
*/
|
|
28
|
+
import type { ElementHandlerContext, ElementTypeHandler, ValidateResult } from './ElementTypeHandler';
|
|
29
|
+
import type { MountedElement } from './types';
|
|
30
|
+
export { TILE_MOUNTED_EVENT, TILE_PATCHED_EVENT, TILE_UNMOUNTED_EVENT, } from '@syntrologie/sdk-contracts';
|
|
31
|
+
/**
|
|
32
|
+
* Optional template→widget resolver. ``uiTemplates`` declares both
|
|
33
|
+
* the LLM-facing ``id`` (e.g. ``"product-card"``) and the runtime
|
|
34
|
+
* widget the chrome should render (e.g. ``"adaptive-product:card"``).
|
|
35
|
+
* Without this resolver, the handler falls back to ``template_id`` as
|
|
36
|
+
* the widget id — which only works when the admin chose ids matching
|
|
37
|
+
* the widget registry, and silently mounts to "Widget not available"
|
|
38
|
+
* when they don't.
|
|
39
|
+
*/
|
|
40
|
+
export type TileTemplateWidgetResolver = (templateId: string) => string | undefined;
|
|
41
|
+
export declare class TileHandler implements ElementTypeHandler {
|
|
42
|
+
private readonly resolveWidget?;
|
|
43
|
+
readonly typeName: "tile";
|
|
44
|
+
readonly lifecycle: "stateful";
|
|
45
|
+
constructor(resolveWidget?: TileTemplateWidgetResolver | undefined);
|
|
46
|
+
private _widgetFor;
|
|
47
|
+
validate(instance: MountedElement, _ctx: ElementHandlerContext): ValidateResult;
|
|
48
|
+
mount(instance: MountedElement, ctx: ElementHandlerContext): Promise<void>;
|
|
49
|
+
patch(instance: MountedElement, ctx: ElementHandlerContext): Promise<void>;
|
|
50
|
+
unmount(instance: MountedElement, ctx: ElementHandlerContext): Promise<void>;
|
|
51
|
+
}
|
|
52
|
+
//# sourceMappingURL=TileHandler.d.ts.map
|
|
@@ -0,0 +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;IA2BzE,KAAK,CAAC,QAAQ,EAAE,cAAc,EAAE,GAAG,EAAE,qBAAqB,GAAG,OAAO,CAAC,IAAI,CAAC;IAY1E,KAAK,CAAC,QAAQ,EAAE,cAAc,EAAE,GAAG,EAAE,qBAAqB,GAAG,OAAO,CAAC,IAAI,CAAC;IAY1E,OAAO,CAAC,QAAQ,EAAE,cAAc,EAAE,GAAG,EAAE,qBAAqB,GAAG,OAAO,CAAC,IAAI,CAAC;CASnF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TileHandler.test.d.ts","sourceRoot":"","sources":["../../src/elements/TileHandler.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ElementInstanceStore.recall.test.d.ts","sourceRoot":"","sources":["../../../src/elements/__tests__/ElementInstanceStore.recall.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Portable Text block renderer — Phase 7 of the LLM-authored UI element
|
|
3
|
+
* instantiation work.
|
|
4
|
+
*
|
|
5
|
+
* `renderBlocks(blocks)` walks a Portable Text tree and produces a
|
|
6
|
+
* `DocumentFragment` of known-safe DOM. Calling code attaches the
|
|
7
|
+
* fragment via `target.appendChild(fragment)` /
|
|
8
|
+
* `target.insertAdjacentElement(...)` — **never** via `innerHTML`.
|
|
9
|
+
*
|
|
10
|
+
* The safety story:
|
|
11
|
+
*
|
|
12
|
+
* 1. **No `innerHTML` from agent data, ever.** Every text reaches the
|
|
13
|
+
* DOM through `document.createTextNode` or `element.textContent`.
|
|
14
|
+
* Even if an agent slips a `<script>` tag into a span's text, it's
|
|
15
|
+
* rendered as the literal characters `<script>` inside a text node,
|
|
16
|
+
* never parsed as HTML.
|
|
17
|
+
* 2. **Closed mark vocabulary.** Only `bold` / `italic` / `code` / `link`
|
|
18
|
+
* are honored. Unknown marks are dropped at render time.
|
|
19
|
+
* 3. **Closed block vocabulary.** Only `paragraph` / `heading` / `list` /
|
|
20
|
+
* `list_item` / `code` are honored. Unknown block types are dropped.
|
|
21
|
+
* 4. **Link href validation.** Backend already rejects `javascript:` /
|
|
22
|
+
* `data:` / `vbscript:` etc., but the renderer re-checks for defense
|
|
23
|
+
* in depth. Rejected links render as plain text spans.
|
|
24
|
+
* 5. **No inline styles, no event handlers, no custom attributes.**
|
|
25
|
+
* Every attribute set on the output DOM is hard-coded in this file.
|
|
26
|
+
*
|
|
27
|
+
* Forward-compat: unknown block / mark types drop silently rather than
|
|
28
|
+
* throw — a future schema bump can add types without breaking today's
|
|
29
|
+
* renderer.
|
|
30
|
+
*/
|
|
31
|
+
import type { BlockNode } from './blocks';
|
|
32
|
+
export interface RenderOptions {
|
|
33
|
+
/** Override the document used for `createElement` / `createTextNode`.
|
|
34
|
+
* Tests inject jsdom's document; SSR contexts can pass a custom impl
|
|
35
|
+
* if needed. Defaults to `globalThis.document`. */
|
|
36
|
+
doc?: Document;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Render an array of blocks into a `DocumentFragment` of safe DOM.
|
|
40
|
+
*
|
|
41
|
+
* Unknown / malformed entries are silently dropped — the caller has
|
|
42
|
+
* already validated server-side; the renderer is the last line of
|
|
43
|
+
* defense and stays fault-tolerant.
|
|
44
|
+
*/
|
|
45
|
+
export declare function renderBlocks(blocks: BlockNode[], options?: RenderOptions): DocumentFragment;
|
|
46
|
+
//# sourceMappingURL=blockRenderer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"blockRenderer.d.ts","sourceRoot":"","sources":["../../src/elements/blockRenderer.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AAEH,OAAO,KAAK,EACV,SAAS,EAQV,MAAM,UAAU,CAAC;AAQlB,MAAM,WAAW,aAAa;IAC5B;;wDAEoD;IACpD,GAAG,CAAC,EAAE,QAAQ,CAAC;CAChB;AAED;;;;;;GAMG;AACH,wBAAgB,YAAY,CAAC,MAAM,EAAE,SAAS,EAAE,EAAE,OAAO,GAAE,aAAkB,GAAG,gBAAgB,CAiB/F"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tests for the Portable Text block renderer — Phase 7.
|
|
3
|
+
*
|
|
4
|
+
* The bulk of this file is a hostile-input corpus. The point of the
|
|
5
|
+
* renderer is that **agent-authored text cannot produce script execution
|
|
6
|
+
* or unsafe DOM**, by construction, regardless of what the agent
|
|
7
|
+
* sends. Each test below pumps a different attack shape through
|
|
8
|
+
* `renderBlocks` and asserts that the resulting DOM contains no
|
|
9
|
+
* dangerous nodes, no live script content, and no `javascript:` /
|
|
10
|
+
* `data:` URIs on anchor tags.
|
|
11
|
+
*/
|
|
12
|
+
export {};
|
|
13
|
+
//# sourceMappingURL=blockRenderer.test.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"blockRenderer.test.d.ts","sourceRoot":"","sources":["../../src/elements/blockRenderer.test.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Portable Text block + mark types — Phase 7 of the LLM-authored UI
|
|
3
|
+
* element instantiation work.
|
|
4
|
+
*
|
|
5
|
+
* Mirror of `platform/common/syntrologie_common/sdk/blocks.py`. Closed
|
|
6
|
+
* vocabulary (block types + mark types) the LLM may author in
|
|
7
|
+
* `rich_text_blocks` fields. The renderer walks this tree and produces
|
|
8
|
+
* DOM via `document.createElement` + `textContent` — **agent never
|
|
9
|
+
* writes HTML strings**. XSS-class attacks have no surface because
|
|
10
|
+
* there's no HTML on the wire.
|
|
11
|
+
*
|
|
12
|
+
* Forward-compat: unknown block types and unknown marks are dropped at
|
|
13
|
+
* render time (not thrown). A future protocol bump can add new types
|
|
14
|
+
* without breaking today's renderer.
|
|
15
|
+
*/
|
|
16
|
+
/**
|
|
17
|
+
* The closed inline-mark vocabulary. Adding a mark is a deliberate
|
|
18
|
+
* code change with review, never an allowlist tweak.
|
|
19
|
+
*/
|
|
20
|
+
export type MarkType = 'bold' | 'italic' | 'code' | 'link';
|
|
21
|
+
export type HeadingLevel = 1 | 2 | 3 | 4 | 5 | 6;
|
|
22
|
+
export type ListStyle = 'bullet' | 'numbered';
|
|
23
|
+
export interface LinkMark {
|
|
24
|
+
/** Validated server-side; renderer revalidates for defense in depth. */
|
|
25
|
+
href: string;
|
|
26
|
+
}
|
|
27
|
+
export interface TextSpan {
|
|
28
|
+
text: string;
|
|
29
|
+
marks?: MarkType[];
|
|
30
|
+
link?: LinkMark;
|
|
31
|
+
}
|
|
32
|
+
export interface ParagraphBlock {
|
|
33
|
+
type: 'paragraph';
|
|
34
|
+
spans: TextSpan[];
|
|
35
|
+
}
|
|
36
|
+
export interface HeadingBlock {
|
|
37
|
+
type: 'heading';
|
|
38
|
+
level: HeadingLevel;
|
|
39
|
+
spans: TextSpan[];
|
|
40
|
+
}
|
|
41
|
+
export interface ListItemBlock {
|
|
42
|
+
type: 'list_item';
|
|
43
|
+
spans: TextSpan[];
|
|
44
|
+
}
|
|
45
|
+
export interface ListBlock {
|
|
46
|
+
type: 'list';
|
|
47
|
+
style: ListStyle;
|
|
48
|
+
items: ListItemBlock[];
|
|
49
|
+
}
|
|
50
|
+
export interface CodeBlock {
|
|
51
|
+
type: 'code';
|
|
52
|
+
/** Raw code text. Rendered inside `<pre><code>` via `textContent` —
|
|
53
|
+
* no HTML interpretation, no syntax-highlight injection. */
|
|
54
|
+
text: string;
|
|
55
|
+
language?: string;
|
|
56
|
+
}
|
|
57
|
+
export type BlockNode = ParagraphBlock | HeadingBlock | ListBlock | CodeBlock;
|
|
58
|
+
//# sourceMappingURL=blocks.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"blocks.d.ts","sourceRoot":"","sources":["../../src/elements/blocks.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH;;;GAGG;AACH,MAAM,MAAM,QAAQ,GAAG,MAAM,GAAG,QAAQ,GAAG,MAAM,GAAG,MAAM,CAAC;AAE3D,MAAM,MAAM,YAAY,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;AAEjD,MAAM,MAAM,SAAS,GAAG,QAAQ,GAAG,UAAU,CAAC;AAE9C,MAAM,WAAW,QAAQ;IACvB,wEAAwE;IACxE,IAAI,EAAE,MAAM,CAAC;CACd;AAED,MAAM,WAAW,QAAQ;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,QAAQ,EAAE,CAAC;IACnB,IAAI,CAAC,EAAE,QAAQ,CAAC;CACjB;AAED,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,WAAW,CAAC;IAClB,KAAK,EAAE,QAAQ,EAAE,CAAC;CACnB;AAED,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,SAAS,CAAC;IAChB,KAAK,EAAE,YAAY,CAAC;IACpB,KAAK,EAAE,QAAQ,EAAE,CAAC;CACnB;AAED,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,WAAW,CAAC;IAClB,KAAK,EAAE,QAAQ,EAAE,CAAC;CACnB;AAED,MAAM,WAAW,SAAS;IACxB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,SAAS,CAAC;IACjB,KAAK,EAAE,aAAa,EAAE,CAAC;CACxB;AAED,MAAM,WAAW,SAAS;IACxB,IAAI,EAAE,MAAM,CAAC;IACb;iEAC6D;IAC7D,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,MAAM,SAAS,GAAG,cAAc,GAAG,YAAY,GAAG,SAAS,GAAG,SAAS,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Helpers for decoding AG-UI custom event payloads — Phase 6b.
|
|
3
|
+
*
|
|
4
|
+
* `AgUiTransport.onA2UIEvent` historically forwarded the raw `event.value`
|
|
5
|
+
* payload as an `ActionStep` directly to `runtime.actions.applyBatch`.
|
|
6
|
+
* Phase 5's backend now also emits `syntro.element.mutation` envelopes
|
|
7
|
+
* (mounts/patches/unmounts authored by the LLM via `mount_element` &c.),
|
|
8
|
+
* which the SDK routes to `ElementInstanceStore.apply` instead.
|
|
9
|
+
*
|
|
10
|
+
* Discrimination is by the envelope's `type` field. Non-element payloads
|
|
11
|
+
* (raw ActionStep, A2UI `createSurface` / `updateDataModel` envelopes
|
|
12
|
+
* from any A2UI integration) fall through to the legacy path.
|
|
13
|
+
*/
|
|
14
|
+
import type { ElementMutation } from './types';
|
|
15
|
+
/**
|
|
16
|
+
* Returns the mutations array if `payload` is a well-formed
|
|
17
|
+
* `syntro.element.mutation` envelope, otherwise `null`.
|
|
18
|
+
*
|
|
19
|
+
* Validates only the discriminator + the structural shape needed to
|
|
20
|
+
* route to the store. Per-mutation validation lives in the store / its
|
|
21
|
+
* type handlers (defense in depth), so this stays small.
|
|
22
|
+
*/
|
|
23
|
+
export declare function decodeMutationEnvelope(payload: unknown): ElementMutation[] | null;
|
|
24
|
+
//# sourceMappingURL=envelope.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"envelope.d.ts","sourceRoot":"","sources":["../../src/elements/envelope.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAoB,MAAM,SAAS,CAAC;AAEjE;;;;;;;GAOG;AACH,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,OAAO,GAAG,eAAe,EAAE,GAAG,IAAI,CAOjF"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Boot-time fetcher for `GET /api/adaptive/mounted_elements`.
|
|
3
|
+
*
|
|
4
|
+
* Follows the SDK's vanilla-fetch convention (see
|
|
5
|
+
* `packages/runtime-sdk/src/overlays/fetcher.ts` for the sibling pattern
|
|
6
|
+
* — no shared HTTP client, no axios, no fetch wrapper).
|
|
7
|
+
*
|
|
8
|
+
* Auth: forwards the SDK token from `window.__SYNTRO_CONFIG__.token`
|
|
9
|
+
* as a Bearer header, plus the runtime's visitor ids (`X-Distinct-Id` /
|
|
10
|
+
* `X-Syntro-Session`) so the backend rehydrates mounts under the same
|
|
11
|
+
* session-keyed Redis state the chat persisted to.
|
|
12
|
+
*
|
|
13
|
+
* 404 contract: the backend returns 404 only when the workspace's SDK
|
|
14
|
+
* token doesn't resolve to a workspace. The SDK treats 404 as
|
|
15
|
+
* "feature unavailable" — no error UI, no retries — per the design doc.
|
|
16
|
+
* Network errors are logged + swallowed so the SDK boot path stays
|
|
17
|
+
* resilient to backend hiccups.
|
|
18
|
+
*/
|
|
19
|
+
import type { MountedElementsResponse } from './types';
|
|
20
|
+
export interface FetchMountedElementsOptions {
|
|
21
|
+
/** Override the endpoint URL (defaults to same-origin
|
|
22
|
+
* `/api/adaptive/mounted_elements`). Tests + multi-environment
|
|
23
|
+
* deploys use this. */
|
|
24
|
+
endpoint?: string;
|
|
25
|
+
/** SDK token. Defaults to `window.__SYNTRO_CONFIG__.token`. */
|
|
26
|
+
token?: string;
|
|
27
|
+
/** Custom fetch implementation — used by tests to mock the network. */
|
|
28
|
+
fetchImpl?: typeof fetch;
|
|
29
|
+
/** Logger — used by tests to capture log output. */
|
|
30
|
+
logger?: Pick<Console, 'warn'>;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Fetch the visitor's currently-mounted elements + session expiry.
|
|
34
|
+
*
|
|
35
|
+
* Returns `null` on any failure (404, network error, malformed JSON,
|
|
36
|
+
* etc.). The caller treats `null` as "feature unavailable, no
|
|
37
|
+
* rehydrate" — boot continues normally with an empty element store.
|
|
38
|
+
*/
|
|
39
|
+
export declare function fetchMountedElements(options?: FetchMountedElementsOptions): Promise<MountedElementsResponse | null>;
|
|
40
|
+
//# sourceMappingURL=fetcher.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fetcher.d.ts","sourceRoot":"","sources":["../../src/elements/fetcher.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,SAAS,CAAC;AAIvD,MAAM,WAAW,2BAA2B;IAC1C;;4BAEwB;IACxB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,+DAA+D;IAC/D,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,uEAAuE;IACvE,SAAS,CAAC,EAAE,OAAO,KAAK,CAAC;IACzB,oDAAoD;IACpD,MAAM,CAAC,EAAE,IAAI,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;CAChC;AAED;;;;;;GAMG;AACH,wBAAsB,oBAAoB,CACxC,OAAO,GAAE,2BAAgC,GACxC,OAAO,CAAC,uBAAuB,GAAG,IAAI,CAAC,CA2DzC"}
|
|
@@ -0,0 +1,33 @@
|
|
|
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 { getElementInstanceStore, setElementInstanceStore } from './store-singleton';
|
|
31
|
+
export { TileHandler } from './TileHandler';
|
|
32
|
+
export type { AgentProvenance, ElementMutation, ElementState, MountedElement, MountedElementsResponse, MountMutation, Mutation, MutationEnvelope, NoPlacement, ParentTilePlacement, PatchMutation, Placement, SelectorPlacement, SlotPlacement, UnmountMutation, } from './types';
|
|
33
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":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 -0,0 +1,4 @@
|
|
|
1
|
+
import type { ElementInstanceStore } from './ElementInstanceStore';
|
|
2
|
+
export declare function setElementInstanceStore(store: ElementInstanceStore | null): void;
|
|
3
|
+
export declare function getElementInstanceStore(): ElementInstanceStore | null;
|
|
4
|
+
//# sourceMappingURL=store-singleton.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"store-singleton.d.ts","sourceRoot":"","sources":["../../src/elements/store-singleton.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAInE,wBAAgB,uBAAuB,CAAC,KAAK,EAAE,oBAAoB,GAAG,IAAI,GAAG,IAAI,CAEhF;AAED,wBAAgB,uBAAuB,IAAI,oBAAoB,GAAG,IAAI,CAErE"}
|
|
@@ -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,QA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AAI,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,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Real-seam tests for the bus-fed observer path.
|
|
3
|
+
*
|
|
4
|
+
* On hosts without a `window.posthog` global, click / rage / dead / form
|
|
5
|
+
* observations reach the chat agent only via the runtime bus, which carries
|
|
6
|
+
* NORMALIZED events (event-processor's PostHog normalizer). This drives the
|
|
7
|
+
* ACTUAL translator (`busEventToRawEvent`) into the ACTUAL matcher
|
|
8
|
+
* (`matchEvent`) with authentic bus-shaped inputs — the exact shape
|
|
9
|
+
* `packages/event-processor/src/normalizers/posthog.ts` emits.
|
|
10
|
+
*
|
|
11
|
+
* Pre-fix, the translator only re-prefixed pathname/url, so matchEvent's
|
|
12
|
+
* `$autocapture` branch read `$event_type: undefined` → returned null. These
|
|
13
|
+
* tests fail against that behavior and pass once the mapping is fixed.
|
|
14
|
+
*/
|
|
15
|
+
export {};
|
|
16
|
+
//# sourceMappingURL=bus-translate.test.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bus-translate.test.d.ts","sourceRoot":"","sources":["../../../src/observer/__tests__/bus-translate.test.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lifecycle.test.d.ts","sourceRoot":"","sources":["../../../src/observer/__tests__/lifecycle.test.ts"],"names":[],"mappings":""}
|