@syntrologie/adapt-chatbot 2.16.0 → 2.25.1

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 (69) hide show
  1. package/dist/ChatAssistantLit.d.ts +8 -56
  2. package/dist/ChatAssistantLit.d.ts.map +1 -1
  3. package/dist/ChatAssistantLit.js +8 -389
  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-FI7F22ED.js +3331 -0
  8. package/dist/chunk-FI7F22ED.js.map +7 -0
  9. package/dist/chunk-V6TY7KAL.js +8 -0
  10. package/dist/chunk-V6TY7KAL.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/runtime-lit.d.ts +3 -24
  16. package/dist/runtime-lit.d.ts.map +1 -1
  17. package/dist/runtime.d.ts +1 -3
  18. package/dist/runtime.d.ts.map +1 -1
  19. package/dist/runtime.js +29 -40
  20. package/dist/runtime.js.map +7 -0
  21. package/dist/schema.d.ts +13 -3
  22. package/dist/schema.d.ts.map +1 -1
  23. package/dist/schema.js +29 -31
  24. package/dist/schema.js.map +7 -0
  25. package/dist/types.d.ts +1 -39
  26. package/dist/types.d.ts.map +1 -1
  27. package/package.json +22 -23
  28. package/dist/ChatAssistant.d.ts +0 -18
  29. package/dist/ChatAssistant.d.ts.map +0 -1
  30. package/dist/ChatAssistant.js +0 -178
  31. package/dist/SyntroChatbot.d.ts +0 -14
  32. package/dist/SyntroChatbot.d.ts.map +0 -1
  33. package/dist/SyntroChatbot.js +0 -56
  34. package/dist/actionParser.d.ts +0 -15
  35. package/dist/actionParser.d.ts.map +0 -1
  36. package/dist/actionParser.js +0 -52
  37. package/dist/apiClient.d.ts +0 -23
  38. package/dist/apiClient.d.ts.map +0 -1
  39. package/dist/apiClient.js +0 -51
  40. package/dist/cdn.js +0 -37
  41. package/dist/editor.d.ts +0 -17
  42. package/dist/editor.d.ts.map +0 -1
  43. package/dist/editor.js +0 -36
  44. package/dist/runtime-lit.js +0 -32
  45. package/dist/tools/bridge.d.ts +0 -26
  46. package/dist/tools/bridge.d.ts.map +0 -1
  47. package/dist/tools/bridge.js +0 -25
  48. package/dist/tools/expanders.d.ts +0 -17
  49. package/dist/tools/expanders.d.ts.map +0 -1
  50. package/dist/tools/expanders.js +0 -41
  51. package/dist/tools/index.d.ts +0 -14
  52. package/dist/tools/index.d.ts.map +0 -1
  53. package/dist/tools/index.js +0 -11
  54. package/dist/tools/registrations/GetContextTool.d.ts +0 -7
  55. package/dist/tools/registrations/GetContextTool.d.ts.map +0 -1
  56. package/dist/tools/registrations/GetContextTool.js +0 -18
  57. package/dist/tools/registrations/ScrollToTool.d.ts +0 -7
  58. package/dist/tools/registrations/ScrollToTool.d.ts.map +0 -1
  59. package/dist/tools/registrations/ScrollToTool.js +0 -38
  60. package/dist/tools/registrations/ShowOverlayTool.d.ts +0 -7
  61. package/dist/tools/registrations/ShowOverlayTool.d.ts.map +0 -1
  62. package/dist/tools/registrations/ShowOverlayTool.js +0 -47
  63. package/dist/tools/registrations/index.d.ts +0 -19
  64. package/dist/tools/registrations/index.d.ts.map +0 -1
  65. package/dist/tools/registrations/index.js +0 -7
  66. package/dist/types.js +0 -6
  67. package/dist/useChat.d.ts +0 -25
  68. package/dist/useChat.d.ts.map +0 -1
  69. package/dist/useChat.js +0 -106
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@syntrologie/adapt-chatbot",
3
- "version": "2.16.0",
3
+ "version": "2.25.1",
4
4
  "description": "Adaptive Chatbot - AI chat assistant widget with action execution",
5
5
  "license": "Proprietary",
6
6
  "private": false,
@@ -13,15 +13,14 @@
13
13
  "publishConfig": {
14
14
  "access": "public"
15
15
  },
16
+ "syntrologie": {
17
+ "bundlingMode": "cdn-only"
18
+ },
16
19
  "type": "module",
17
20
  "exports": {
18
21
  ".": {
19
- "types": "./dist/SyntroChatbot.d.ts",
20
- "import": "./dist/SyntroChatbot.js"
21
- },
22
- "./tools": {
23
- "types": "./dist/tools/index.d.ts",
24
- "import": "./dist/tools/index.js"
22
+ "types": "./dist/ChatAssistantLit.d.ts",
23
+ "import": "./dist/ChatAssistantLit.js"
25
24
  },
26
25
  "./runtime": {
27
26
  "types": "./dist/runtime.d.ts",
@@ -36,8 +35,12 @@
36
35
  "import": "./dist/schema.js"
37
36
  },
38
37
  "./editor": {
39
- "types": "./dist/editor.d.ts",
40
- "import": "./dist/editor.js"
38
+ "types": "./dist/editor-lit.d.ts",
39
+ "import": "./dist/editor-lit.js"
40
+ },
41
+ "./editor-lit": {
42
+ "types": "./src/editor-lit.ts",
43
+ "import": "./src/editor-lit.ts"
41
44
  }
42
45
  },
43
46
  "files": [
@@ -49,38 +52,34 @@
49
52
  ],
50
53
  "scripts": {
51
54
  "prepack": "node ../../../scripts/prepare-bundled-deps.mjs",
52
- "build": "tsc",
55
+ "build": "tsc --emitDeclarationOnly && node ../scripts/build-lib.mjs",
53
56
  "typecheck": "tsc --noEmit",
54
57
  "clean": "rm -rf dist",
55
58
  "test": "vitest run",
56
59
  "test:watch": "vitest"
57
60
  },
58
61
  "dependencies": {
59
- "@assistant-ui/react": "0.12.22",
60
- "@assistant-ui/react-ai-sdk": "1.3.17",
61
- "@syntrologie/shared-editor-ui": "*",
62
- "@syntro/design-system": "*"
62
+ "@a2ui/lit": "^0.10.0",
63
+ "@a2ui/web_core": "^0.10.0",
64
+ "@syntrologie/chat": "*"
63
65
  },
64
66
  "peerDependencies": {
65
- "react": ">=18.0.0",
66
- "react-dom": ">=18.0.0",
67
+ "lit": "^3.0.0",
67
68
  "zod": "^3.0.0"
68
69
  },
69
70
  "devDependencies": {
70
- "@assistant-ui/react": "0.12.22",
71
71
  "@open-wc/testing": "4.0.0",
72
72
  "@open-wc/testing-helpers": "3.0.1",
73
73
  "@syntro/design-system": "1.0.0",
74
74
  "@syntrologie/shared-editor-ui": "*",
75
- "@testing-library/react": "16.3.2",
76
- "@types/react": "19.2.14",
77
- "@types/react-dom": "19.2.3",
78
75
  "jsdom": "26.1.0",
79
76
  "lit": "3.3.2",
80
- "react": "19.2.1",
81
- "react-dom": "19.2.1",
82
77
  "typescript": "5.9.3",
83
78
  "vitest": "4.0.18",
84
79
  "zod": "3.25.76"
85
- }
80
+ },
81
+ "bundleDependencies": [
82
+ "@syntro/design-system",
83
+ "@syntrologie/shared-editor-ui"
84
+ ]
86
85
  }
@@ -1,18 +0,0 @@
1
- /**
2
- * Adaptive Chatbot - ChatAssistant Component
3
- *
4
- * Main React component for the AI chat assistant widget.
5
- * Renders a message list with auto-scroll, loading indicator, and input form.
6
- */
7
- import type { ChatbotConfig, ChatbotWidgetRuntime } from './types';
8
- export interface ChatAssistantProps {
9
- config: ChatbotConfig;
10
- runtime: ChatbotWidgetRuntime;
11
- tileId: string;
12
- }
13
- export declare function ChatAssistant({ config, runtime, tileId }: ChatAssistantProps): import("react/jsx-runtime").JSX.Element;
14
- export declare const ChatAssistantMountableWidget: {
15
- mount(container: HTMLElement, mountConfig?: Record<string, unknown>): () => void;
16
- };
17
- export default ChatAssistant;
18
- //# sourceMappingURL=ChatAssistant.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ChatAssistant.d.ts","sourceRoot":"","sources":["../src/ChatAssistant.tsx"],"names":[],"mappings":"AAAA;;;;;GAKG;AAMH,OAAO,KAAK,EAAE,aAAa,EAAE,oBAAoB,EAAe,MAAM,SAAS,CAAC;AA+GhF,MAAM,WAAW,kBAAkB;IACjC,MAAM,EAAE,aAAa,CAAC;IACtB,OAAO,EAAE,oBAAoB,CAAC;IAC9B,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,wBAAgB,aAAa,CAAC,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,EAAE,kBAAkB,2CAwE5E;AAMD,eAAO,MAAM,4BAA4B;qBACtB,WAAW,gBAAgB,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;CA6CpE,CAAC;AAEF,eAAe,aAAa,CAAC"}
@@ -1,178 +0,0 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- /**
3
- * Adaptive Chatbot - ChatAssistant Component
4
- *
5
- * Main React component for the AI chat assistant widget.
6
- * Renders a message list with auto-scroll, loading indicator, and input form.
7
- */
8
- import { base, purple, red, slateGrey } from '@syntro/design-system/tokens';
9
- import React, { useEffect, useRef } from 'react';
10
- import { createRoot } from 'react-dom/client';
11
- import { useChat } from './useChat';
12
- // ============================================================================
13
- // Styles
14
- // ============================================================================
15
- const styles = {
16
- container: {
17
- display: 'flex',
18
- flexDirection: 'column',
19
- height: '100%',
20
- fontFamily: 'system-ui, -apple-system, sans-serif',
21
- fontSize: '14px',
22
- touchAction: 'none',
23
- },
24
- messageList: {
25
- flex: 1,
26
- overflowY: 'auto',
27
- padding: '12px',
28
- display: 'flex',
29
- flexDirection: 'column',
30
- gap: '8px',
31
- },
32
- messageBubble: {
33
- maxWidth: '85%',
34
- padding: '8px 12px',
35
- borderRadius: '12px',
36
- lineHeight: 1.5,
37
- wordBreak: 'break-word',
38
- },
39
- userMessage: {
40
- alignSelf: 'flex-end',
41
- backgroundColor: purple[4],
42
- color: base.white,
43
- borderBottomRightRadius: '4px',
44
- },
45
- assistantMessage: {
46
- alignSelf: 'flex-start',
47
- backgroundColor: 'rgba(255, 255, 255, 0.08)',
48
- color: slateGrey[10],
49
- borderBottomLeftRadius: '4px',
50
- },
51
- loadingDots: {
52
- alignSelf: 'flex-start',
53
- padding: '8px 16px',
54
- backgroundColor: 'rgba(255, 255, 255, 0.05)',
55
- borderRadius: '12px',
56
- color: slateGrey[8],
57
- fontSize: '13px',
58
- },
59
- errorBanner: {
60
- padding: '8px 12px',
61
- backgroundColor: 'rgba(239, 68, 68, 0.1)',
62
- color: red[4],
63
- fontSize: '13px',
64
- borderRadius: '8px',
65
- margin: '0 12px',
66
- },
67
- inputForm: {
68
- display: 'flex',
69
- gap: '8px',
70
- padding: '12px',
71
- borderTop: '1px solid rgba(255, 255, 255, 0.06)',
72
- },
73
- input: {
74
- flex: 1,
75
- padding: '8px 12px',
76
- borderRadius: '8px',
77
- border: '1px solid rgba(255, 255, 255, 0.1)',
78
- backgroundColor: 'rgba(0, 0, 0, 0.2)',
79
- color: slateGrey[12],
80
- fontSize: '14px',
81
- outline: 'none',
82
- fontFamily: 'inherit',
83
- },
84
- sendButton: {
85
- padding: '8px 16px',
86
- borderRadius: '8px',
87
- border: 'none',
88
- backgroundColor: purple[4],
89
- color: base.white,
90
- fontWeight: 600,
91
- fontSize: '13px',
92
- cursor: 'pointer',
93
- whiteSpace: 'nowrap',
94
- },
95
- sendButtonDisabled: {
96
- opacity: 0.5,
97
- cursor: 'not-allowed',
98
- },
99
- };
100
- // ============================================================================
101
- // MessageBubble Component
102
- // ============================================================================
103
- function MessageBubble({ message }) {
104
- const isUser = message.role === 'user';
105
- const bubbleStyle = {
106
- ...styles.messageBubble,
107
- ...(isUser ? styles.userMessage : styles.assistantMessage),
108
- };
109
- return _jsx("div", { style: bubbleStyle, children: message.text });
110
- }
111
- export function ChatAssistant({ config, runtime, tileId }) {
112
- const { messages, isLoading, error, sendMessage, clearMessages: _clearMessages, } = useChat({
113
- backendUrl: config.backendUrl,
114
- tileId,
115
- runtime,
116
- greeting: config.greeting,
117
- maxHistory: config.maxHistory,
118
- mlflowRunId: config.mlflowRunId,
119
- });
120
- const messageListRef = useRef(null);
121
- const inputRef = useRef(null);
122
- // Auto-scroll to bottom on new messages
123
- useEffect(() => {
124
- if (messageListRef.current) {
125
- messageListRef.current.scrollTop = messageListRef.current.scrollHeight;
126
- }
127
- }, []);
128
- const handleSubmit = (e) => {
129
- e.preventDefault();
130
- const input = inputRef.current;
131
- if (!input || !input.value.trim() || isLoading)
132
- return;
133
- const text = input.value;
134
- input.value = '';
135
- sendMessage(text);
136
- };
137
- return (_jsxs("div", { style: styles.container, "data-testid": "chat-assistant", children: [_jsxs("div", { ref: messageListRef, style: styles.messageList, children: [messages.map((msg) => (_jsx(MessageBubble, { message: msg }, msg.id))), isLoading && _jsx("div", { style: styles.loadingDots, children: "Thinking..." })] }), error && _jsx("div", { style: styles.errorBanner, children: error }), _jsxs("form", { onSubmit: handleSubmit, style: styles.inputForm, children: [_jsx("input", { ref: inputRef, style: styles.input, placeholder: "Ask anything...", disabled: isLoading, "data-testid": "chat-input" }), _jsx("button", { type: "submit", disabled: isLoading, style: {
138
- ...styles.sendButton,
139
- ...(isLoading ? styles.sendButtonDisabled : {}),
140
- }, "data-testid": "chat-send", children: "Send" })] })] }));
141
- }
142
- // ============================================================================
143
- // Mountable Widget Interface
144
- // ============================================================================
145
- export const ChatAssistantMountableWidget = {
146
- mount(container, mountConfig) {
147
- const { config, runtime, tileId = 'chatbot-widget', } = (mountConfig || {});
148
- // React rendering when config + runtime + ReactDOM are available
149
- if (config && runtime && typeof createRoot === 'function') {
150
- const root = createRoot(container);
151
- root.render(React.createElement(ChatAssistant, {
152
- config,
153
- runtime,
154
- tileId,
155
- }));
156
- return () => {
157
- root.unmount();
158
- };
159
- }
160
- if (!config || !runtime) {
161
- container.innerHTML = `<div style="padding: 16px; color: ${slateGrey[8]};">Chat widget requires config and runtime.</div>`;
162
- return () => {
163
- container.innerHTML = '';
164
- };
165
- }
166
- // HTML fallback
167
- container.innerHTML = `
168
- <div style="padding: 16px; font-family: system-ui; color: ${slateGrey[10]};">
169
- <p style="margin: 0 0 8px; color: ${slateGrey[8]};">${config.greeting || 'Hi! How can I help?'}</p>
170
- <p style="margin: 0; font-size: 12px; color: ${slateGrey[7]};">Chat widget mounted. Awaiting React renderer.</p>
171
- </div>
172
- `;
173
- return () => {
174
- container.innerHTML = '';
175
- };
176
- },
177
- };
178
- export default ChatAssistant;
@@ -1,14 +0,0 @@
1
- import type { ChatbotWidgetRuntime } from './types';
2
- export interface SyntroChatbotConfig {
3
- /** Backend URL that returns Vercel AI SDK streaming response format */
4
- backendUrl: string;
5
- /** Greeting shown in the empty thread state */
6
- greeting?: string;
7
- }
8
- export interface SyntroChatbotProps {
9
- runtime: ChatbotWidgetRuntime;
10
- config: SyntroChatbotConfig;
11
- }
12
- export declare function SyntroChatbot({ runtime, config }: SyntroChatbotProps): import("react/jsx-runtime").JSX.Element;
13
- export default SyntroChatbot;
14
- //# sourceMappingURL=SyntroChatbot.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"SyntroChatbot.d.ts","sourceRoot":"","sources":["../src/SyntroChatbot.tsx"],"names":[],"mappings":"AAqBA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAC;AAEpD,MAAM,WAAW,mBAAmB;IAClC,uEAAuE;IACvE,UAAU,EAAE,MAAM,CAAC;IACnB,+CAA+C;IAC/C,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,kBAAkB;IACjC,OAAO,EAAE,oBAAoB,CAAC;IAC9B,MAAM,EAAE,mBAAmB,CAAC;CAC7B;AA6BD,wBAAgB,aAAa,CAAC,EAAE,OAAO,EAAE,MAAM,EAAE,EAAE,kBAAkB,2CAgEpE;AAED,eAAe,aAAa,CAAC"}
@@ -1,56 +0,0 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- /**
3
- * SyntroChatbot — Supply Mode
4
- *
5
- * Convenience component for clients who want Syntro to provide the chat shell.
6
- * Uses AssistantChatTransport (from @assistant-ui/react-ai-sdk) pointing at
7
- * backendUrl. The backend must return Vercel AI SDK streaming format
8
- * (toDataStreamResponse() from the `ai` package).
9
- *
10
- * For integration mode (client owns the shell), use SyntroTools instead:
11
- * import { SyntroTools } from '@syntrologie/adapt-chatbot/tools'
12
- */
13
- import { AssistantRuntimeProvider, ComposerPrimitive, MessagePrimitive, ThreadPrimitive, useMessage, } from '@assistant-ui/react';
14
- import { AssistantChatTransport, useChatRuntime } from '@assistant-ui/react-ai-sdk';
15
- import { useMemo } from 'react';
16
- import { SyntroTools } from './tools/registrations';
17
- function ChatBubble() {
18
- const message = useMessage();
19
- const textParts = message.content?.filter((part) => part.type === 'text');
20
- return (_jsx(MessagePrimitive.Root, { children: _jsx("div", { style: {
21
- padding: '8px 12px',
22
- borderRadius: '8px',
23
- background: message.role === 'user' ? 'rgba(107, 70, 193, 0.15)' : 'rgba(255,255,255,0.05)',
24
- alignSelf: message.role === 'user' ? 'flex-end' : 'flex-start',
25
- maxWidth: '80%',
26
- fontSize: '14px',
27
- }, children: textParts?.map((part, i) => (_jsx("span", { children: part.text }, i))) }) }));
28
- }
29
- export function SyntroChatbot({ runtime, config }) {
30
- const transport = useMemo(() => new AssistantChatTransport({ api: config.backendUrl }), [config.backendUrl]);
31
- const chatRuntime = useChatRuntime({ transport });
32
- return (_jsxs(AssistantRuntimeProvider, { runtime: chatRuntime, children: [_jsx(SyntroTools, { runtime: runtime }), _jsxs("div", { style: { display: 'flex', flexDirection: 'column', height: '100%' }, children: [_jsx(ThreadPrimitive.Root, { style: { flex: 1, overflowY: 'auto' }, children: _jsxs(ThreadPrimitive.Viewport, { style: { padding: '12px', display: 'flex', flexDirection: 'column', gap: '8px' }, children: [_jsx(ThreadPrimitive.Empty, { children: _jsx("div", { style: { padding: '24px', textAlign: 'center', fontSize: '14px', opacity: 0.7 }, children: config.greeting ?? 'Hi! How can I help?' }) }), _jsx(ThreadPrimitive.Messages, { components: {
33
- UserMessage: ChatBubble,
34
- AssistantMessage: ChatBubble,
35
- } })] }) }), _jsx("div", { style: { borderTop: '1px solid rgba(255,255,255,0.1)', padding: '12px' }, children: _jsxs(ComposerPrimitive.Root, { style: { display: 'flex', gap: '8px' }, children: [_jsx(ComposerPrimitive.Input, { placeholder: "Ask me anything...", style: {
36
- flex: 1,
37
- padding: '8px 12px',
38
- borderRadius: '8px',
39
- border: '1px solid rgba(255,255,255,0.15)',
40
- background: 'rgba(255,255,255,0.05)',
41
- color: 'inherit',
42
- fontSize: '14px',
43
- fontFamily: 'inherit',
44
- resize: 'none',
45
- }, rows: 1 }), _jsx(ComposerPrimitive.Send, { style: {
46
- padding: '8px 16px',
47
- borderRadius: '8px',
48
- border: 'none',
49
- background: 'var(--syntro-purple-4, #6b46c1)',
50
- color: 'white',
51
- fontSize: '14px',
52
- fontWeight: 600,
53
- cursor: 'pointer',
54
- }, children: "Send" })] }) })] })] }));
55
- }
56
- export default SyntroChatbot;
@@ -1,15 +0,0 @@
1
- /**
2
- * Adaptive Chatbot - Action Parser
3
- *
4
- * Extracts JSON action blocks from LLM markdown responses.
5
- * Actions are identified by having a `kind` field in a ```json code fence.
6
- */
7
- import type { ParsedResponse } from './types';
8
- /**
9
- * Parse an LLM response, extracting action blocks from JSON code fences.
10
- *
11
- * - Blocks with a `kind` field are treated as actions and removed from display text.
12
- * - Blocks without `kind` or with invalid JSON are left in the display text.
13
- */
14
- export declare function parseActions(input: string): ParsedResponse;
15
- //# sourceMappingURL=actionParser.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"actionParser.d.ts","sourceRoot":"","sources":["../src/actionParser.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAe,cAAc,EAAE,MAAM,SAAS,CAAC;AAI3D;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,cAAc,CA8C1D"}
@@ -1,52 +0,0 @@
1
- /**
2
- * Adaptive Chatbot - Action Parser
3
- *
4
- * Extracts JSON action blocks from LLM markdown responses.
5
- * Actions are identified by having a `kind` field in a ```json code fence.
6
- */
7
- const JSON_FENCE_RE = /```json\s*\n([\s\S]*?)```/g;
8
- /**
9
- * Parse an LLM response, extracting action blocks from JSON code fences.
10
- *
11
- * - Blocks with a `kind` field are treated as actions and removed from display text.
12
- * - Blocks without `kind` or with invalid JSON are left in the display text.
13
- */
14
- export function parseActions(input) {
15
- const actions = [];
16
- let displayText = input;
17
- // Collect matches in reverse order so we can splice display text without index shifting
18
- const matches = [];
19
- let match;
20
- // Reset regex state
21
- JSON_FENCE_RE.lastIndex = 0;
22
- while ((match = JSON_FENCE_RE.exec(input)) !== null) {
23
- matches.push({
24
- fullMatch: match[0],
25
- json: match[1],
26
- index: match.index,
27
- });
28
- }
29
- // Process in reverse to preserve indices when removing from displayText
30
- for (let i = matches.length - 1; i >= 0; i--) {
31
- const { fullMatch, json } = matches[i];
32
- let parsed;
33
- try {
34
- parsed = JSON.parse(json);
35
- }
36
- catch {
37
- // Malformed JSON — leave in display text
38
- continue;
39
- }
40
- if (typeof parsed === 'object' &&
41
- parsed !== null &&
42
- 'kind' in parsed &&
43
- typeof parsed.kind === 'string') {
44
- actions.unshift(parsed);
45
- // Remove the action block from display text
46
- displayText = displayText.replace(fullMatch, '');
47
- }
48
- }
49
- // Clean up extra blank lines left from removed blocks
50
- displayText = displayText.replace(/\n{3,}/g, '\n\n').trim();
51
- return { displayText, actions };
52
- }
@@ -1,23 +0,0 @@
1
- /**
2
- * Adaptive Chatbot - API Client
3
- *
4
- * Auth-aware fetch client that reads Stytch JWT from cookies
5
- * and workspace ID from localStorage.
6
- */
7
- import type { ChatApiRequest, ChatApiResponse } from './types';
8
- export declare class AuthError extends Error {
9
- constructor(message: string);
10
- }
11
- /**
12
- * Read auth credentials from browser cookie and localStorage.
13
- * Throws AuthError if credentials are missing.
14
- */
15
- export declare function getAuthHeaders(): {
16
- Authorization: string;
17
- 'X-Workspace-Id': string;
18
- };
19
- /**
20
- * Send a chat message to the backend.
21
- */
22
- export declare function sendMessage(url: string, request: ChatApiRequest): Promise<ChatApiResponse>;
23
- //# sourceMappingURL=apiClient.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"apiClient.d.ts","sourceRoot":"","sources":["../src/apiClient.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAE/D,qBAAa,SAAU,SAAQ,KAAK;gBACtB,OAAO,EAAE,MAAM;CAI5B;AAED;;;GAGG;AACH,wBAAgB,cAAc,IAAI;IAAE,aAAa,EAAE,MAAM,CAAC;IAAC,gBAAgB,EAAE,MAAM,CAAA;CAAE,CAepF;AAED;;GAEG;AACH,wBAAsB,WAAW,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,cAAc,GAAG,OAAO,CAAC,eAAe,CAAC,CAoBhG"}
package/dist/apiClient.js DELETED
@@ -1,51 +0,0 @@
1
- /**
2
- * Adaptive Chatbot - API Client
3
- *
4
- * Auth-aware fetch client that reads Stytch JWT from cookies
5
- * and workspace ID from localStorage.
6
- */
7
- export class AuthError extends Error {
8
- constructor(message) {
9
- super(message);
10
- this.name = 'AuthError';
11
- }
12
- }
13
- /**
14
- * Read auth credentials from browser cookie and localStorage.
15
- * Throws AuthError if credentials are missing.
16
- */
17
- export function getAuthHeaders() {
18
- const cookieMatch = document.cookie.match(/stytch_session_jwt=([^;]*)/);
19
- if (!cookieMatch || !cookieMatch[1]) {
20
- throw new AuthError('No authentication token found');
21
- }
22
- const workspaceId = localStorage.getItem('syntrologie_workspace_id');
23
- if (!workspaceId) {
24
- throw new AuthError('No workspace ID found');
25
- }
26
- return {
27
- Authorization: `Bearer ${cookieMatch[1]}`,
28
- 'X-Workspace-Id': workspaceId,
29
- };
30
- }
31
- /**
32
- * Send a chat message to the backend.
33
- */
34
- export async function sendMessage(url, request) {
35
- const authHeaders = getAuthHeaders();
36
- const response = await fetch(url, {
37
- method: 'POST',
38
- headers: {
39
- 'Content-Type': 'application/json',
40
- ...authHeaders,
41
- },
42
- body: JSON.stringify(request),
43
- });
44
- if (!response.ok) {
45
- if (response.status === 401) {
46
- throw new AuthError('Session expired or unauthorized');
47
- }
48
- throw new Error(`Chat request failed: ${response.status} ${response.statusText}`);
49
- }
50
- return response.json();
51
- }
package/dist/cdn.js DELETED
@@ -1,37 +0,0 @@
1
- /**
2
- * CDN Entry Point for Adaptive Chatbot
3
- *
4
- * This module is bundled for CDN delivery and self-registers with the global
5
- * SynOS app registry when loaded dynamically via the AppLoader.
6
- */
7
- import ChatbotEditor, { editorPanel } from './editor';
8
- import { runtime } from './runtime';
9
- /**
10
- * App manifest for registry registration.
11
- * Follows the AppManifest interface expected by AppLoader/AppRegistry.
12
- */
13
- export const manifest = {
14
- id: 'adaptive-chatbot',
15
- version: runtime.version,
16
- name: runtime.name,
17
- description: runtime.description,
18
- runtime: {
19
- actions: [],
20
- widgets: runtime.widgets,
21
- },
22
- editor: { component: ChatbotEditor, panel: editorPanel },
23
- metadata: {
24
- isBuiltIn: false,
25
- },
26
- };
27
- /**
28
- * Self-register with global registry if available.
29
- * This happens when loaded via script tag (UMD).
30
- */
31
- if (typeof window !== 'undefined') {
32
- const registry = window.SynOS?.appRegistry;
33
- if (registry && typeof registry.register === 'function') {
34
- registry.register(manifest);
35
- }
36
- }
37
- export default manifest;
package/dist/editor.d.ts DELETED
@@ -1,17 +0,0 @@
1
- /**
2
- * Adaptive Chatbot - Editor Component
3
- *
4
- * Visual editor panel for configuring chatbot tile props.
5
- */
6
- import type { EditorPanelProps } from './types';
7
- export declare function ChatbotEditor({ config, onChange, editor }: EditorPanelProps): import("react/jsx-runtime").JSX.Element;
8
- /**
9
- * Editor panel configuration for the app registry.
10
- */
11
- export declare const editorPanel: {
12
- title: string;
13
- icon: string;
14
- description: string;
15
- };
16
- export default ChatbotEditor;
17
- //# sourceMappingURL=editor.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"editor.d.ts","sourceRoot":"","sources":["../src/editor.tsx"],"names":[],"mappings":"AAAA;;;;GAIG;AAYH,OAAO,KAAK,EAAiB,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAM/D,wBAAgB,aAAa,CAAC,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,gBAAgB,2CAkF3E;AAED;;GAEG;AACH,eAAO,MAAM,WAAW;;;;CAIvB,CAAC;AAEF,eAAe,aAAa,CAAC"}
package/dist/editor.js DELETED
@@ -1,36 +0,0 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- /**
3
- * Adaptive Chatbot - Editor Component
4
- *
5
- * Visual editor panel for configuring chatbot tile props.
6
- */
7
- import { EditorBody, EditorHeader, EditorInput, EditorLayout, EditorTextarea, } from '@syntrologie/shared-editor-ui';
8
- import { useEffect, useRef } from 'react';
9
- // ============================================================================
10
- // ChatbotEditor Component
11
- // ============================================================================
12
- export function ChatbotEditor({ config, onChange, editor }) {
13
- const typedConfig = config;
14
- // Consume initial navigation payload on mount (chatbot is form-based, no sub-items)
15
- const initialConsumed = useRef(false);
16
- useEffect(() => {
17
- if (!initialConsumed.current && (editor.initialEditKey != null || editor.initialCreate)) {
18
- initialConsumed.current = true;
19
- editor.clearInitialState?.();
20
- }
21
- }, [editor]);
22
- const handleChange = (field, value) => {
23
- onChange({ ...config, [field]: value });
24
- editor.setDirty(true);
25
- };
26
- return (_jsxs(EditorLayout, { children: [_jsx(EditorHeader, { title: "Chat Assistant", subtitle: "Configure AI chat assistant", onBack: () => editor.navigateHome() }), _jsxs(EditorBody, { children: [_jsxs("div", { className: "se-mb-6", children: [_jsx("div", { className: "se-text-xs se-font-semibold se-text-slate-grey-8 se-uppercase se-tracking-wide se-mb-3", children: "API Configuration" }), _jsx(EditorInput, { label: "Backend URL", type: "text", value: typedConfig.backendUrl || '', onChange: (e) => handleChange('backendUrl', e.target.value), placeholder: "/api/chat/message" }), _jsx(EditorInput, { label: "MLflow Run ID (optional)", type: "text", value: typedConfig.mlflowRunId || '', onChange: (e) => handleChange('mlflowRunId', e.target.value), placeholder: "e.g., abc123" })] }), _jsxs("div", { className: "se-mb-6", children: [_jsx("div", { className: "se-text-xs se-font-semibold se-text-slate-grey-8 se-uppercase se-tracking-wide se-mb-3", children: "Chat Settings" }), _jsx(EditorTextarea, { label: "Greeting Message", value: typedConfig.greeting || '', onChange: (e) => handleChange('greeting', e.target.value), placeholder: "Hi! How can I help?" }), _jsx(EditorInput, { label: "Max History (messages sent to backend)", type: "number", value: typedConfig.maxHistory || 20, onChange: (e) => handleChange('maxHistory', parseInt(e.target.value, 10)), min: 1, max: 100 })] })] })] }));
27
- }
28
- /**
29
- * Editor panel configuration for the app registry.
30
- */
31
- export const editorPanel = {
32
- title: 'Chat Assistant',
33
- icon: '\u{1F4AC}',
34
- description: 'AI chat assistant with action execution',
35
- };
36
- export default ChatbotEditor;
@@ -1,32 +0,0 @@
1
- /**
2
- * Adaptive Chatbot - Runtime Module (Lit)
3
- *
4
- * Runtime manifest for the AI chat assistant adaptive.
5
- * Uses the Lit web component mountable instead of the React one.
6
- * This is a widget-based adaptive with no action executors.
7
- */
8
- import { ChatAssistantLitMountable } from './ChatAssistantLit';
9
- // ============================================================================
10
- // App Runtime Manifest
11
- // ============================================================================
12
- export const runtime = {
13
- id: 'adaptive-chatbot',
14
- version: '1.0.0',
15
- name: 'Chat Assistant',
16
- description: 'AI chat assistant with action execution capabilities',
17
- /** No action executors — chatbot uses existing action kinds via applyBatch */
18
- executors: [],
19
- /** Widget definitions for the runtime's WidgetRegistry */
20
- widgets: [
21
- {
22
- id: 'adaptive-chatbot:assistant',
23
- component: ChatAssistantLitMountable,
24
- metadata: {
25
- name: 'Chat Assistant',
26
- description: 'AI-powered chat assistant that can execute DOM actions',
27
- icon: '💬',
28
- },
29
- },
30
- ],
31
- };
32
- export default runtime;