@syntrologie/adapt-chatbot 2.25.2 → 2.27.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/ChatAssistantLit.d.ts +71 -4
- package/dist/ChatAssistantLit.d.ts.map +1 -1
- package/dist/ChatAssistantLit.js +6 -4
- package/dist/{chunk-V6TY7KAL.js → chunk-UVKRO5ER.js} +6 -1
- package/dist/chunk-W457NMGD.js +11087 -0
- package/dist/chunk-W457NMGD.js.map +7 -0
- package/dist/editor-lit.js +1 -1
- package/dist/runtime.js +2 -2
- package/dist/schema.d.ts +98 -10
- package/dist/schema.d.ts.map +1 -1
- package/dist/schema.js +43 -4
- package/dist/schema.js.map +2 -2
- package/dist/types.d.ts +17 -0
- package/dist/types.d.ts.map +1 -1
- package/package.json +3 -2
- package/dist/chunk-FI7F22ED.js +0 -3331
- package/dist/chunk-FI7F22ED.js.map +0 -7
- /package/dist/{chunk-V6TY7KAL.js.map → chunk-UVKRO5ER.js.map} +0 -0
|
@@ -2,11 +2,41 @@
|
|
|
2
2
|
* Adaptive Chatbot — Lit Mountable
|
|
3
3
|
*
|
|
4
4
|
* Thin wrapper that mounts <syntro-chat> from @syntrologie/chat with an
|
|
5
|
-
*
|
|
5
|
+
* AgUiTransport pointed at the adaptive AG-UI streaming endpoint.
|
|
6
6
|
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
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 (two-phase). When
|
|
15
|
+
* `TURNSTILE_SITEKEY` is set:
|
|
16
|
+
* a. Try invisible first — passive fingerprints, no UI. Clean
|
|
17
|
+
* traffic resolves in milliseconds. Token forwarded via
|
|
18
|
+
* `CF-Turnstile-Token`.
|
|
19
|
+
* b. If CF declines to grant silently (datacenter IP, automation
|
|
20
|
+
* signals, strict-privacy browser), render a visible managed
|
|
21
|
+
* widget inside the chat container so CF can present the
|
|
22
|
+
* "I am human" checkbox. On solve, swap to the chat UI.
|
|
23
|
+
* c. If both phases fail, fall through with no token; backend
|
|
24
|
+
* enforcement returns 403 and the existing fallback card
|
|
25
|
+
* renders. The widget mode must be `managed` on the CF side
|
|
26
|
+
* for the visible escalation to work — see
|
|
27
|
+
* cloudflare/turnstile/main.tf in syntro-infra.
|
|
28
|
+
* If sitekey is empty, this step is skipped entirely.
|
|
29
|
+
*
|
|
30
|
+
* 3. Fallback card. If the first agent run fails (Cloudflare Turnstile
|
|
31
|
+
* bot-check failure, CORS / network error, or a server-side rejection),
|
|
32
|
+
* swap the chat UI for a per-customer fallback card built from
|
|
33
|
+
* `props.fallback`. The end-user is redirected to the customer's normal
|
|
34
|
+
* support path instead of seeing a raw error.
|
|
35
|
+
*
|
|
36
|
+
* 4. A2UI passthrough. AG-UI CUSTOM events carrying A2UI payloads
|
|
37
|
+
* (createSurface, updateDataModel, …) get forwarded to
|
|
38
|
+
* `runtime.actions.applyBatch` so tiles can render server-driven UI
|
|
39
|
+
* inside the chat surface.
|
|
10
40
|
*/
|
|
11
41
|
import '@syntrologie/chat';
|
|
12
42
|
import type { ChatbotConfig, ChatbotWidgetRuntime } from './types.js';
|
|
@@ -15,6 +45,43 @@ export interface ChatAssistantLitProps {
|
|
|
15
45
|
runtime: ChatbotWidgetRuntime;
|
|
16
46
|
tileId?: string;
|
|
17
47
|
}
|
|
48
|
+
export interface AcquireTurnstileOptions {
|
|
49
|
+
/**
|
|
50
|
+
* Widget size. `invisible` for the silent first attempt; `flexible`
|
|
51
|
+
* (or `normal`) for the visible managed checkbox after silent failure.
|
|
52
|
+
*/
|
|
53
|
+
size: 'invisible' | 'flexible' | 'normal' | 'compact';
|
|
54
|
+
/**
|
|
55
|
+
* Where to mount the widget. For `invisible` this is an off-screen
|
|
56
|
+
* host; for the visible sizes it must be a container that's actually
|
|
57
|
+
* in the layout so CF can render the challenge UI. When omitted, an
|
|
58
|
+
* off-screen div is created and removed automatically (suitable for
|
|
59
|
+
* `invisible` only — visible sizes need a real host).
|
|
60
|
+
*/
|
|
61
|
+
host?: HTMLElement;
|
|
62
|
+
/**
|
|
63
|
+
* Cancels an in-flight acquisition. On abort, the promise resolves to
|
|
64
|
+
* `null`, the CF widget is removed from the registry, and any owned
|
|
65
|
+
* host is torn down. Required for cleanup-during-challenge — without
|
|
66
|
+
* it, a user dismissing the tile mid-checkbox leaks the widget.
|
|
67
|
+
*/
|
|
68
|
+
signal?: AbortSignal;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Acquire a Cloudflare Turnstile token. Returns null when:
|
|
72
|
+
* • TURNSTILE_SITEKEY is empty (Turnstile disabled at build time)
|
|
73
|
+
* • the script fails to load (customer CSP blocks Cloudflare, etc.)
|
|
74
|
+
* • the render callback doesn't fire within TURNSTILE_ACQUIRE_TIMEOUT_MS
|
|
75
|
+
* • Cloudflare returns an error-callback (e.g., rate-limited, bad sitekey)
|
|
76
|
+
*
|
|
77
|
+
* Calls `turnstile.remove(widgetId)` on settle so CF's internal widget
|
|
78
|
+
* registry doesn't leak across re-mounts (CF will otherwise log
|
|
79
|
+
* `Cannot find Widget ...` when subsequent renders look up the old
|
|
80
|
+
* widget by id and find the host gone).
|
|
81
|
+
*
|
|
82
|
+
* Exported for tests; the production code path goes through `mount()`.
|
|
83
|
+
*/
|
|
84
|
+
export declare function acquireTurnstileToken(opts?: AcquireTurnstileOptions): Promise<string | null>;
|
|
18
85
|
export declare const ChatAssistantLitMountable: {
|
|
19
86
|
mount(container: HTMLElement, mountConfig?: Record<string, unknown>): () => void;
|
|
20
87
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ChatAssistantLit.d.ts","sourceRoot":"","sources":["../src/ChatAssistantLit.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"ChatAssistantLit.d.ts","sourceRoot":"","sources":["../src/ChatAssistantLit.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuCG;AAGH,OAAO,mBAAmB,CAAC;AAK3B,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;AAqGD,MAAM,WAAW,uBAAuB;IACtC;;;OAGG;IACH,IAAI,EAAE,WAAW,GAAG,UAAU,GAAG,QAAQ,GAAG,SAAS,CAAC;IACtD;;;;;;OAMG;IACH,IAAI,CAAC,EAAE,WAAW,CAAC;IACnB;;;;;OAKG;IACH,MAAM,CAAC,EAAE,WAAW,CAAC;CACtB;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAsB,qBAAqB,CACzC,IAAI,GAAE,uBAA+C,GACpD,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAkFxB;AAqGD,eAAO,MAAM,yBAAyB;qBACnB,WAAW,gBAAgB,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;CAwPpE,CAAC"}
|
package/dist/ChatAssistantLit.js
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import {
|
|
2
|
-
ChatAssistantLitMountable
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
ChatAssistantLitMountable,
|
|
3
|
+
acquireTurnstileToken
|
|
4
|
+
} from "./chunk-W457NMGD.js";
|
|
5
|
+
import "./chunk-UVKRO5ER.js";
|
|
5
6
|
export {
|
|
6
|
-
ChatAssistantLitMountable
|
|
7
|
+
ChatAssistantLitMountable,
|
|
8
|
+
acquireTurnstileToken
|
|
7
9
|
};
|
|
8
10
|
//# sourceMappingURL=ChatAssistantLit.js.map
|
|
@@ -1,8 +1,13 @@
|
|
|
1
1
|
var __defProp = Object.defineProperty;
|
|
2
2
|
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
3
|
+
var __export = (target, all) => {
|
|
4
|
+
for (var name in all)
|
|
5
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
6
|
+
};
|
|
3
7
|
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
4
8
|
|
|
5
9
|
export {
|
|
10
|
+
__export,
|
|
6
11
|
__publicField
|
|
7
12
|
};
|
|
8
|
-
//# sourceMappingURL=chunk-
|
|
13
|
+
//# sourceMappingURL=chunk-UVKRO5ER.js.map
|