@syntrologie/adapt-chatbot 2.8.0-canary.27 → 2.8.0-canary.271

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 (84) hide show
  1. package/dist/ChatAssistantLit.d.ts +109 -0
  2. package/dist/ChatAssistantLit.d.ts.map +1 -0
  3. package/dist/ChatAssistantLit.js +10 -0
  4. package/dist/ChatAssistantLit.js.map +7 -0
  5. package/dist/cdn.d.ts +2 -6
  6. package/dist/cdn.d.ts.map +1 -1
  7. package/dist/chunk-SRGELVHV.js +11675 -0
  8. package/dist/chunk-SRGELVHV.js.map +7 -0
  9. package/dist/chunk-UVKRO5ER.js +13 -0
  10. package/dist/chunk-UVKRO5ER.js.map +7 -0
  11. package/dist/editor-lit.d.ts +37 -0
  12. package/dist/editor-lit.d.ts.map +1 -0
  13. package/dist/editor-lit.js +134 -0
  14. package/dist/editor-lit.js.map +7 -0
  15. package/dist/elements/ActionHandler.d.ts +34 -0
  16. package/dist/elements/ActionHandler.d.ts.map +1 -0
  17. package/dist/elements/ElementInstanceStore.d.ts +84 -0
  18. package/dist/elements/ElementInstanceStore.d.ts.map +1 -0
  19. package/dist/elements/ElementInstanceStore.test.d.ts +2 -0
  20. package/dist/elements/ElementInstanceStore.test.d.ts.map +1 -0
  21. package/dist/elements/ElementTypeHandler.d.ts +67 -0
  22. package/dist/elements/ElementTypeHandler.d.ts.map +1 -0
  23. package/dist/elements/TileHandler.d.ts +20 -0
  24. package/dist/elements/TileHandler.d.ts.map +1 -0
  25. package/dist/elements/blockRenderer.d.ts +46 -0
  26. package/dist/elements/blockRenderer.d.ts.map +1 -0
  27. package/dist/elements/blockRenderer.test.d.ts +13 -0
  28. package/dist/elements/blockRenderer.test.d.ts.map +1 -0
  29. package/dist/elements/blocks.d.ts +58 -0
  30. package/dist/elements/blocks.d.ts.map +1 -0
  31. package/dist/elements/envelope.d.ts +24 -0
  32. package/dist/elements/envelope.d.ts.map +1 -0
  33. package/dist/elements/fetcher.d.ts +40 -0
  34. package/dist/elements/fetcher.d.ts.map +1 -0
  35. package/dist/elements/index.d.ts +30 -0
  36. package/dist/elements/index.d.ts.map +1 -0
  37. package/dist/elements/types.d.ts +91 -0
  38. package/dist/elements/types.d.ts.map +1 -0
  39. package/dist/observer/__tests__/allowlist.test.d.ts +9 -0
  40. package/dist/observer/__tests__/allowlist.test.d.ts.map +1 -0
  41. package/dist/observer/__tests__/observer-isolation.test.d.ts +13 -0
  42. package/dist/observer/__tests__/observer-isolation.test.d.ts.map +1 -0
  43. package/dist/observer/__tests__/queue.test.d.ts +2 -0
  44. package/dist/observer/__tests__/queue.test.d.ts.map +1 -0
  45. package/dist/observer/__tests__/transport.test.d.ts +2 -0
  46. package/dist/observer/__tests__/transport.test.d.ts.map +1 -0
  47. package/dist/observer/allowlist.d.ts +32 -0
  48. package/dist/observer/allowlist.d.ts.map +1 -0
  49. package/dist/observer/index.d.ts +35 -0
  50. package/dist/observer/index.d.ts.map +1 -0
  51. package/dist/observer/queue.d.ts +57 -0
  52. package/dist/observer/queue.d.ts.map +1 -0
  53. package/dist/observer/transport.d.ts +26 -0
  54. package/dist/observer/transport.d.ts.map +1 -0
  55. package/dist/runtime-lit.d.ts +8 -0
  56. package/dist/runtime-lit.d.ts.map +1 -0
  57. package/dist/runtime.d.ts +6 -3
  58. package/dist/runtime.d.ts.map +1 -1
  59. package/dist/runtime.js +395 -29
  60. package/dist/runtime.js.map +7 -0
  61. package/dist/schema.d.ts +105 -7
  62. package/dist/schema.d.ts.map +1 -1
  63. package/dist/schema.js +68 -31
  64. package/dist/schema.js.map +7 -0
  65. package/dist/types.d.ts +27 -31
  66. package/dist/types.d.ts.map +1 -1
  67. package/package.json +37 -19
  68. package/dist/ChatAssistant.d.ts +0 -18
  69. package/dist/ChatAssistant.d.ts.map +0 -1
  70. package/dist/ChatAssistant.js +0 -178
  71. package/dist/actionParser.d.ts +0 -15
  72. package/dist/actionParser.d.ts.map +0 -1
  73. package/dist/actionParser.js +0 -52
  74. package/dist/apiClient.d.ts +0 -23
  75. package/dist/apiClient.d.ts.map +0 -1
  76. package/dist/apiClient.js +0 -51
  77. package/dist/cdn.js +0 -37
  78. package/dist/editor.d.ts +0 -17
  79. package/dist/editor.d.ts.map +0 -1
  80. package/dist/editor.js +0 -36
  81. package/dist/types.js +0 -6
  82. package/dist/useChat.d.ts +0 -25
  83. package/dist/useChat.d.ts.map +0 -1
  84. package/dist/useChat.js +0 -106
@@ -0,0 +1,109 @@
1
+ /**
2
+ * Adaptive Chatbot — Lit Mountable
3
+ *
4
+ * Thin wrapper that mounts <syntro-chat> from @syntrologie/chat with an
5
+ * AgUiTransport pointed at the adaptive AG-UI streaming endpoint.
6
+ *
7
+ * Four pieces this mountable owns:
8
+ *
9
+ * 1. SDK token plumbing. The chat backend (`/api/adaptive/*`) is identified
10
+ * by the workspace's `syn_*` SDK token. The token lives on
11
+ * `window.__SYNTRO_CONFIG__.token` (set by runtime-config.js) — we read
12
+ * it at mount time and forward it via `Authorization: Bearer` header.
13
+ *
14
+ * 2. Cloudflare Turnstile bot-check token. When `TURNSTILE_SITEKEY` is
15
+ * set, render a single `size: 'flexible'` widget with
16
+ * `appearance: 'interaction-only'` against a `managed`-mode sitekey:
17
+ * • Clean traffic: CF passive-grades silently, token resolves in
18
+ * ~100ms, no UI is ever shown.
19
+ * • Flagged traffic (datacenter IP, automation, strict-privacy):
20
+ * CF renders an "I am human" checkbox inside the in-chat verify
21
+ * panel; on solve, swap to the chat UI.
22
+ * • Total failure (CSP blocks CF, network error, user dismisses):
23
+ * fall through with no token; backend enforcement 403s and the
24
+ * existing fallback card renders.
25
+ * The widget mode MUST be `managed` on the CF side — see
26
+ * cloudflare/turnstile/main.tf in syntro-infra. (`mode = 'invisible'`
27
+ * rejects any `size` other than `invisible`, and `size: 'invisible'`
28
+ * against `mode = 'managed'` fails with a synchronous TurnstileError —
29
+ * don't mix.)
30
+ * If sitekey is empty, this step is skipped entirely.
31
+ *
32
+ * 3. Fallback card. If the first agent run fails (Cloudflare Turnstile
33
+ * bot-check failure, CORS / network error, or a server-side rejection),
34
+ * swap the chat UI for a per-customer fallback card built from
35
+ * `props.fallback`. The end-user is redirected to the customer's normal
36
+ * support path instead of seeing a raw error.
37
+ *
38
+ * 4. A2UI passthrough. AG-UI CUSTOM events carrying A2UI payloads
39
+ * (createSurface, updateDataModel, …) get forwarded to
40
+ * `runtime.actions.applyBatch` so tiles can render server-driven UI
41
+ * inside the chat surface.
42
+ */
43
+ import '@syntrologie/chat';
44
+ import type { ChatbotConfig, ChatbotWidgetRuntime } from './types.js';
45
+ export interface ChatAssistantLitProps {
46
+ config: ChatbotConfig;
47
+ runtime: ChatbotWidgetRuntime;
48
+ tileId?: string;
49
+ }
50
+ export interface AcquireTurnstileOptions {
51
+ /**
52
+ * Widget size. `flexible` (default for managed-mode sitekeys) lets CF
53
+ * render a responsive checkbox when interaction is needed. `invisible`
54
+ * is only valid against an `invisible`-mode sitekey — pairing
55
+ * `invisible` with our `managed` sitekey produces a synchronous
56
+ * TurnstileError.
57
+ */
58
+ size?: 'flexible' | 'normal' | 'compact' | 'invisible';
59
+ /**
60
+ * `interaction-only` keeps the widget fully invisible during passive
61
+ * grading and only reveals UI if CF needs an interactive challenge.
62
+ * `always` (CF default) shows a small "verifying" indicator during
63
+ * grading. We default to `interaction-only` so clean traffic sees no
64
+ * flash before the chat appears.
65
+ */
66
+ appearance?: 'always' | 'execute' | 'interaction-only';
67
+ /**
68
+ * Where to mount the widget. For visible sizes (the default), this
69
+ * must be a host that's actually in the layout so CF has somewhere to
70
+ * draw the challenge UI if it needs to. When omitted, an off-screen
71
+ * div is created and removed automatically — only suitable for
72
+ * `size: 'invisible'` (which is only valid against an `invisible`-mode
73
+ * sitekey, which we don't ship).
74
+ */
75
+ host?: HTMLElement;
76
+ /**
77
+ * Fires when CF decides a challenge is needed and is about to reveal
78
+ * the checkbox. Caller uses it to surface accompanying copy
79
+ * ("Quick check before we start chatting") only when the challenge
80
+ * actually appears.
81
+ */
82
+ onBeforeInteractive?: () => void;
83
+ /**
84
+ * Cancels an in-flight acquisition. On abort, the promise resolves to
85
+ * `null`, the CF widget is removed from the registry, and any owned
86
+ * host is torn down. Required for cleanup-during-challenge — without
87
+ * it, a user dismissing the tile mid-checkbox leaks the widget.
88
+ */
89
+ signal?: AbortSignal;
90
+ }
91
+ /**
92
+ * Acquire a Cloudflare Turnstile token. Returns null when:
93
+ * • TURNSTILE_SITEKEY is empty (Turnstile disabled at build time)
94
+ * • the script fails to load (customer CSP blocks Cloudflare, etc.)
95
+ * • the render callback doesn't fire within TURNSTILE_ACQUIRE_TIMEOUT_MS
96
+ * • Cloudflare returns an error-callback (e.g., rate-limited, bad sitekey)
97
+ *
98
+ * Calls `turnstile.remove(widgetId)` on settle so CF's internal widget
99
+ * registry doesn't leak across re-mounts (CF will otherwise log
100
+ * `Cannot find Widget ...` when subsequent renders look up the old
101
+ * widget by id and find the host gone).
102
+ *
103
+ * Exported for tests; the production code path goes through `mount()`.
104
+ */
105
+ export declare function acquireTurnstileToken(opts?: AcquireTurnstileOptions): Promise<string | null>;
106
+ export declare const ChatAssistantLitMountable: {
107
+ mount(container: HTMLElement, mountConfig?: Record<string, unknown>): () => void;
108
+ };
109
+ //# sourceMappingURL=ChatAssistantLit.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ChatAssistantLit.d.ts","sourceRoot":"","sources":["../src/ChatAssistantLit.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyCG;AAGH,OAAO,mBAAmB,CAAC;AAY3B,OAAO,KAAK,EAAE,aAAa,EAAmB,oBAAoB,EAAE,MAAM,YAAY,CAAC;AAEvF,MAAM,WAAW,qBAAqB;IACpC,MAAM,EAAE,aAAa,CAAC;IACtB,OAAO,EAAE,oBAAoB,CAAC;IAC9B,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAuGD,MAAM,WAAW,uBAAuB;IACtC;;;;;;OAMG;IACH,IAAI,CAAC,EAAE,UAAU,GAAG,QAAQ,GAAG,SAAS,GAAG,WAAW,CAAC;IACvD;;;;;;OAMG;IACH,UAAU,CAAC,EAAE,QAAQ,GAAG,SAAS,GAAG,kBAAkB,CAAC;IACvD;;;;;;;OAOG;IACH,IAAI,CAAC,EAAE,WAAW,CAAC;IACnB;;;;;OAKG;IACH,mBAAmB,CAAC,EAAE,MAAM,IAAI,CAAC;IACjC;;;;;OAKG;IACH,MAAM,CAAC,EAAE,WAAW,CAAC;CACtB;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAsB,qBAAqB,CACzC,IAAI,GAAE,uBAA4B,GACjC,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAgHxB;AAqGD,eAAO,MAAM,yBAAyB;qBACnB,WAAW,gBAAgB,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;CA0cpE,CAAC"}
@@ -0,0 +1,10 @@
1
+ import {
2
+ ChatAssistantLitMountable,
3
+ acquireTurnstileToken
4
+ } from "./chunk-SRGELVHV.js";
5
+ import "./chunk-UVKRO5ER.js";
6
+ export {
7
+ ChatAssistantLitMountable,
8
+ acquireTurnstileToken
9
+ };
10
+ //# sourceMappingURL=ChatAssistantLit.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": [],
4
+ "sourcesContent": [],
5
+ "mappings": "",
6
+ "names": []
7
+ }
package/dist/cdn.d.ts CHANGED
@@ -4,11 +4,7 @@
4
4
  * This module is bundled for CDN delivery and self-registers with the global
5
5
  * SynOS app registry when loaded dynamically via the AppLoader.
6
6
  */
7
- import ChatbotEditor from './editor';
8
- /**
9
- * App manifest for registry registration.
10
- * Follows the AppManifest interface expected by AppLoader/AppRegistry.
11
- */
7
+ import { ChatbotEditorLit } from './editor-lit';
12
8
  export declare const manifest: {
13
9
  id: string;
14
10
  version: string;
@@ -29,7 +25,7 @@ export declare const manifest: {
29
25
  }[];
30
26
  };
31
27
  editor: {
32
- component: typeof ChatbotEditor;
28
+ component: typeof ChatbotEditorLit;
33
29
  panel: {
34
30
  title: string;
35
31
  icon: string;
package/dist/cdn.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"cdn.d.ts","sourceRoot":"","sources":["../src/cdn.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,aAA8B,MAAM,UAAU,CAAC;AAGtD;;;GAGG;AACH,eAAO,MAAM,QAAQ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAapB,CAAC;AAaF,eAAe,QAAQ,CAAC"}
1
+ {"version":3,"file":"cdn.d.ts","sourceRoot":"","sources":["../src/cdn.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAGhD,eAAO,MAAM,QAAQ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAoBpB,CAAC;AAaF,eAAe,QAAQ,CAAC"}