@syntrologie/adapt-chatbot 2.10.0 → 2.12.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/SyntroChatbot.d.ts +14 -0
- package/dist/SyntroChatbot.d.ts.map +1 -0
- package/dist/SyntroChatbot.js +56 -0
- package/dist/tools/bridge.d.ts +26 -0
- package/dist/tools/bridge.d.ts.map +1 -0
- package/dist/tools/bridge.js +25 -0
- package/dist/tools/expanders.d.ts +17 -0
- package/dist/tools/expanders.d.ts.map +1 -0
- package/dist/tools/expanders.js +41 -0
- package/dist/tools/index.d.ts +14 -0
- package/dist/tools/index.d.ts.map +1 -0
- package/dist/tools/index.js +11 -0
- package/dist/tools/registrations/GetContextTool.d.ts +7 -0
- package/dist/tools/registrations/GetContextTool.d.ts.map +1 -0
- package/dist/tools/registrations/GetContextTool.js +18 -0
- package/dist/tools/registrations/ScrollToTool.d.ts +7 -0
- package/dist/tools/registrations/ScrollToTool.d.ts.map +1 -0
- package/dist/tools/registrations/ScrollToTool.js +38 -0
- package/dist/tools/registrations/ShowOverlayTool.d.ts +7 -0
- package/dist/tools/registrations/ShowOverlayTool.d.ts.map +1 -0
- package/dist/tools/registrations/ShowOverlayTool.js +47 -0
- package/dist/tools/registrations/index.d.ts +19 -0
- package/dist/tools/registrations/index.d.ts.map +1 -0
- package/dist/tools/registrations/index.js +7 -0
- package/dist/types.d.ts +9 -0
- package/dist/types.d.ts.map +1 -1
- package/package.json +22 -11
|
@@ -0,0 +1,14 @@
|
|
|
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
|
|
@@ -0,0 +1 @@
|
|
|
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"}
|
|
@@ -0,0 +1,56 @@
|
|
|
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;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tool Bridge — Dispatch
|
|
3
|
+
*
|
|
4
|
+
* executeTool: translates an AI tool call to an ActionStep and fires applyBatch().
|
|
5
|
+
* getContext: reads session state from the runtime (no page effect).
|
|
6
|
+
*/
|
|
7
|
+
import type { ChatbotWidgetRuntime } from '../types';
|
|
8
|
+
export interface ToolCall {
|
|
9
|
+
name: string;
|
|
10
|
+
args: Record<string, unknown>;
|
|
11
|
+
}
|
|
12
|
+
export interface ContextResult {
|
|
13
|
+
page: string;
|
|
14
|
+
signals: ReturnType<ChatbotWidgetRuntime['getActiveSignals']>;
|
|
15
|
+
config: ReturnType<ChatbotWidgetRuntime['getContextConfig']>;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Execute a tool call. For action tools (show_overlay, scroll_to):
|
|
19
|
+
* expands args to ActionStep and calls applyBatch(). Throws for unknown tools.
|
|
20
|
+
*/
|
|
21
|
+
export declare function executeTool(call: ToolCall, runtime: ChatbotWidgetRuntime): Promise<void>;
|
|
22
|
+
/**
|
|
23
|
+
* Read current session context. Never calls applyBatch.
|
|
24
|
+
*/
|
|
25
|
+
export declare function getContext(runtime: ChatbotWidgetRuntime): ContextResult;
|
|
26
|
+
//# sourceMappingURL=bridge.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bridge.d.ts","sourceRoot":"","sources":["../../src/tools/bridge.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,UAAU,CAAC;AAGrD,MAAM,WAAW,QAAQ;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAC/B;AAED,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,UAAU,CAAC,oBAAoB,CAAC,kBAAkB,CAAC,CAAC,CAAC;IAC9D,MAAM,EAAE,UAAU,CAAC,oBAAoB,CAAC,kBAAkB,CAAC,CAAC,CAAC;CAC9D;AAED;;;GAGG;AACH,wBAAsB,WAAW,CAAC,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,oBAAoB,GAAG,OAAO,CAAC,IAAI,CAAC,CAG9F;AAED;;GAEG;AACH,wBAAgB,UAAU,CAAC,OAAO,EAAE,oBAAoB,GAAG,aAAa,CAMvE"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tool Bridge — Dispatch
|
|
3
|
+
*
|
|
4
|
+
* executeTool: translates an AI tool call to an ActionStep and fires applyBatch().
|
|
5
|
+
* getContext: reads session state from the runtime (no page effect).
|
|
6
|
+
*/
|
|
7
|
+
import { expand } from './expanders';
|
|
8
|
+
/**
|
|
9
|
+
* Execute a tool call. For action tools (show_overlay, scroll_to):
|
|
10
|
+
* expands args to ActionStep and calls applyBatch(). Throws for unknown tools.
|
|
11
|
+
*/
|
|
12
|
+
export async function executeTool(call, runtime) {
|
|
13
|
+
const step = expand(call.name, call.args);
|
|
14
|
+
await runtime.actions.applyBatch([step]);
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Read current session context. Never calls applyBatch.
|
|
18
|
+
*/
|
|
19
|
+
export function getContext(runtime) {
|
|
20
|
+
return {
|
|
21
|
+
page: window.location.pathname,
|
|
22
|
+
signals: runtime.getActiveSignals(),
|
|
23
|
+
config: runtime.getContextConfig(),
|
|
24
|
+
};
|
|
25
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tool Bridge — Expanders
|
|
3
|
+
*
|
|
4
|
+
* Translates simplified AI tool arguments into full ActionStep objects.
|
|
5
|
+
* The AI sees small, constrained arg schemas. Expanders fill in all
|
|
6
|
+
* schema defaults the AI doesn't need to reason about.
|
|
7
|
+
*/
|
|
8
|
+
export interface ActionStep {
|
|
9
|
+
kind: string;
|
|
10
|
+
config: Record<string, unknown>;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Expand a tool call into a full ActionStep.
|
|
14
|
+
* Throws for unknown tool names — do not silently ignore.
|
|
15
|
+
*/
|
|
16
|
+
export declare function expand(toolName: string, args: Record<string, unknown>): ActionStep;
|
|
17
|
+
//# sourceMappingURL=expanders.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"expanders.d.ts","sourceRoot":"","sources":["../../src/tools/expanders.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,MAAM,WAAW,UAAU;IACzB,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACjC;AA6BD;;;GAGG;AACH,wBAAgB,MAAM,CAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,UAAU,CAMlF"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tool Bridge — Expanders
|
|
3
|
+
*
|
|
4
|
+
* Translates simplified AI tool arguments into full ActionStep objects.
|
|
5
|
+
* The AI sees small, constrained arg schemas. Expanders fill in all
|
|
6
|
+
* schema defaults the AI doesn't need to reason about.
|
|
7
|
+
*/
|
|
8
|
+
const expanders = {
|
|
9
|
+
show_overlay: (args) => ({
|
|
10
|
+
kind: 'show_overlay',
|
|
11
|
+
config: {
|
|
12
|
+
headline: args['headline'],
|
|
13
|
+
body: args['body'],
|
|
14
|
+
cta_label: args['cta'] ?? null,
|
|
15
|
+
// Schema defaults — AI does not control these
|
|
16
|
+
position: 'center',
|
|
17
|
+
dismissible: true,
|
|
18
|
+
},
|
|
19
|
+
}),
|
|
20
|
+
scroll_to: (args) => ({
|
|
21
|
+
kind: 'scroll_to',
|
|
22
|
+
config: {
|
|
23
|
+
// Passed through as-is. The runtime SDK's scroll_to executor resolves
|
|
24
|
+
// the target string: first as a CSS selector / anchor ID, then by
|
|
25
|
+
// case-insensitive heading text match. The expander does no DOM lookup.
|
|
26
|
+
target: args['section'],
|
|
27
|
+
behavior: 'smooth',
|
|
28
|
+
},
|
|
29
|
+
}),
|
|
30
|
+
};
|
|
31
|
+
/**
|
|
32
|
+
* Expand a tool call into a full ActionStep.
|
|
33
|
+
* Throws for unknown tool names — do not silently ignore.
|
|
34
|
+
*/
|
|
35
|
+
export function expand(toolName, args) {
|
|
36
|
+
const expander = expanders[toolName];
|
|
37
|
+
if (!expander) {
|
|
38
|
+
throw new Error(`Unknown tool: ${toolName}`);
|
|
39
|
+
}
|
|
40
|
+
return expander(args);
|
|
41
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tool Bridge — public API
|
|
3
|
+
*
|
|
4
|
+
* Integration mode (client owns the chat shell):
|
|
5
|
+
* import { SyntroTools } from '@syntrologie/adapt-chatbot/tools'
|
|
6
|
+
* // Render <SyntroTools runtime={syntroRuntime} /> inside AssistantRuntimeProvider
|
|
7
|
+
*
|
|
8
|
+
* Supply mode: use <SyntroChatbot /> from '@syntrologie/adapt-chatbot' instead.
|
|
9
|
+
*/
|
|
10
|
+
export type { ContextResult, ToolCall } from './bridge';
|
|
11
|
+
export { executeTool, getContext } from './bridge';
|
|
12
|
+
export type { ActionStep } from './expanders';
|
|
13
|
+
export { SyntroTools } from './registrations';
|
|
14
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/tools/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,YAAY,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AACxD,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AACnD,YAAY,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tool Bridge — public API
|
|
3
|
+
*
|
|
4
|
+
* Integration mode (client owns the chat shell):
|
|
5
|
+
* import { SyntroTools } from '@syntrologie/adapt-chatbot/tools'
|
|
6
|
+
* // Render <SyntroTools runtime={syntroRuntime} /> inside AssistantRuntimeProvider
|
|
7
|
+
*
|
|
8
|
+
* Supply mode: use <SyntroChatbot /> from '@syntrologie/adapt-chatbot' instead.
|
|
9
|
+
*/
|
|
10
|
+
export { executeTool, getContext } from './bridge';
|
|
11
|
+
export { SyntroTools } from './registrations';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"GetContextTool.d.ts","sourceRoot":"","sources":["../../../src/tools/registrations/GetContextTool.tsx"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAGxD,UAAU,KAAK;IACb,OAAO,EAAE,oBAAoB,CAAC;CAC/B;AAED,wBAAgB,cAAc,CAAC,EAAE,OAAO,EAAE,EAAE,KAAK,QAUhD"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* GetContextTool — registers the get_context tool with assistant-ui.
|
|
3
|
+
*
|
|
4
|
+
* This is a silent tool: it has no render output. When the AI calls it,
|
|
5
|
+
* execute() reads session state and returns the context. No applyBatch call.
|
|
6
|
+
*/
|
|
7
|
+
import { useAssistantTool } from '@assistant-ui/react';
|
|
8
|
+
import { getContext } from '../bridge';
|
|
9
|
+
export function GetContextTool({ runtime }) {
|
|
10
|
+
useAssistantTool({
|
|
11
|
+
toolName: 'get_context',
|
|
12
|
+
type: 'frontend',
|
|
13
|
+
description: "Get current context about the user: what page they're on and what behavioral signals have fired in this session.",
|
|
14
|
+
parameters: { type: 'object', properties: {}, required: [] },
|
|
15
|
+
execute: async () => getContext(runtime),
|
|
16
|
+
});
|
|
17
|
+
return null;
|
|
18
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ScrollToTool.d.ts","sourceRoot":"","sources":["../../../src/tools/registrations/ScrollToTool.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAOxD,UAAU,KAAK;IACb,OAAO,EAAE,oBAAoB,CAAC;CAC/B;AAED,wBAAgB,YAAY,CAAC,EAAE,OAAO,EAAE,EAAE,KAAK,QAuC9C"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
/**
|
|
3
|
+
* ScrollToTool — registers the scroll_to tool with assistant-ui.
|
|
4
|
+
*/
|
|
5
|
+
import { useAssistantTool } from '@assistant-ui/react';
|
|
6
|
+
import { executeTool } from '../bridge';
|
|
7
|
+
export function ScrollToTool({ runtime }) {
|
|
8
|
+
useAssistantTool({
|
|
9
|
+
toolName: 'scroll_to',
|
|
10
|
+
type: 'frontend',
|
|
11
|
+
description: "Scroll the page to a named section. Use the section's visible heading text or a known anchor ID.",
|
|
12
|
+
parameters: {
|
|
13
|
+
type: 'object',
|
|
14
|
+
properties: {
|
|
15
|
+
section: {
|
|
16
|
+
type: 'string',
|
|
17
|
+
description: "The section to scroll to. Use the section's visible heading text or a known anchor ID.",
|
|
18
|
+
},
|
|
19
|
+
},
|
|
20
|
+
required: ['section'],
|
|
21
|
+
},
|
|
22
|
+
execute: async (args) => {
|
|
23
|
+
await executeTool({ name: 'scroll_to', args }, runtime);
|
|
24
|
+
},
|
|
25
|
+
render: ({ args, status }) => {
|
|
26
|
+
if (status.type !== 'complete')
|
|
27
|
+
return null;
|
|
28
|
+
return (_jsxs("div", { style: {
|
|
29
|
+
padding: '8px 12px',
|
|
30
|
+
borderRadius: '6px',
|
|
31
|
+
background: 'rgba(99, 179, 237, 0.08)',
|
|
32
|
+
border: '1px solid rgba(99, 179, 237, 0.2)',
|
|
33
|
+
fontSize: '12px',
|
|
34
|
+
}, children: [_jsx("span", { style: { color: '#63b3ed', fontWeight: 600 }, children: "Scrolled to \u2014 " }), _jsx("span", { style: { color: '#90cdf4' }, children: args.section })] }));
|
|
35
|
+
},
|
|
36
|
+
});
|
|
37
|
+
return null;
|
|
38
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ShowOverlayTool.d.ts","sourceRoot":"","sources":["../../../src/tools/registrations/ShowOverlayTool.tsx"],"names":[],"mappings":"AAWA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AASxD,UAAU,KAAK;IACb,OAAO,EAAE,oBAAoB,CAAC;CAC/B;AAED,wBAAgB,eAAe,CAAC,EAAE,OAAO,EAAE,EAAE,KAAK,QAwCjD"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
/**
|
|
3
|
+
* ShowOverlayTool — registers the show_overlay tool with assistant-ui.
|
|
4
|
+
*
|
|
5
|
+
* execute() fires immediately (type: 'frontend'), dispatching the overlay
|
|
6
|
+
* action via applyBatch(). The render prop shows a compact confirmation card
|
|
7
|
+
* inline in the chat thread after the tool completes.
|
|
8
|
+
*
|
|
9
|
+
* React 18+ strict mode double-fires useEffect in dev. applyBatch is
|
|
10
|
+
* idempotent for the same action within a session, so this is benign.
|
|
11
|
+
*/
|
|
12
|
+
import { useAssistantTool } from '@assistant-ui/react';
|
|
13
|
+
import { executeTool } from '../bridge';
|
|
14
|
+
export function ShowOverlayTool({ runtime }) {
|
|
15
|
+
useAssistantTool({
|
|
16
|
+
toolName: 'show_overlay',
|
|
17
|
+
type: 'frontend',
|
|
18
|
+
description: 'Show a modal overlay on the page with a headline, body message, and optional call-to-action button.',
|
|
19
|
+
parameters: {
|
|
20
|
+
type: 'object',
|
|
21
|
+
properties: {
|
|
22
|
+
headline: { type: 'string', description: 'Short headline for the overlay.' },
|
|
23
|
+
body: { type: 'string', description: 'Main message body.' },
|
|
24
|
+
cta: {
|
|
25
|
+
type: 'string',
|
|
26
|
+
description: 'Button label. Omit if no action needed.',
|
|
27
|
+
},
|
|
28
|
+
},
|
|
29
|
+
required: ['headline', 'body'],
|
|
30
|
+
},
|
|
31
|
+
execute: async (args) => {
|
|
32
|
+
await executeTool({ name: 'show_overlay', args }, runtime);
|
|
33
|
+
},
|
|
34
|
+
render: ({ args, status }) => {
|
|
35
|
+
if (status.type !== 'complete')
|
|
36
|
+
return null;
|
|
37
|
+
return (_jsxs("div", { style: {
|
|
38
|
+
padding: '8px 12px',
|
|
39
|
+
borderRadius: '6px',
|
|
40
|
+
background: 'rgba(104, 211, 145, 0.08)',
|
|
41
|
+
border: '1px solid rgba(104, 211, 145, 0.2)',
|
|
42
|
+
fontSize: '12px',
|
|
43
|
+
}, children: [_jsx("span", { style: { color: '#68d391', fontWeight: 600 }, children: "Overlay shown \u2014 " }), _jsx("span", { style: { color: '#9ae6b4' }, children: args.headline })] }));
|
|
44
|
+
},
|
|
45
|
+
});
|
|
46
|
+
return null;
|
|
47
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SyntroTools — renders all tool registration components.
|
|
3
|
+
*
|
|
4
|
+
* Render this inside an AssistantRuntimeProvider. Each child registers
|
|
5
|
+
* one tool with assistant-ui via useAssistantTool.
|
|
6
|
+
*
|
|
7
|
+
* Integration mode:
|
|
8
|
+
* <AssistantRuntimeProvider runtime={myRuntime}>
|
|
9
|
+
* <SyntroTools runtime={syntroRuntime} />
|
|
10
|
+
* <Thread />
|
|
11
|
+
* </AssistantRuntimeProvider>
|
|
12
|
+
*/
|
|
13
|
+
import type { ChatbotWidgetRuntime } from '../../types';
|
|
14
|
+
interface Props {
|
|
15
|
+
runtime: ChatbotWidgetRuntime;
|
|
16
|
+
}
|
|
17
|
+
export declare function SyntroTools({ runtime }: Props): import("react/jsx-runtime").JSX.Element;
|
|
18
|
+
export {};
|
|
19
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/tools/registrations/index.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAKxD,UAAU,KAAK;IACb,OAAO,EAAE,oBAAoB,CAAC;CAC/B;AAED,wBAAgB,WAAW,CAAC,EAAE,OAAO,EAAE,EAAE,KAAK,2CAQ7C"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { GetContextTool } from './GetContextTool';
|
|
3
|
+
import { ScrollToTool } from './ScrollToTool';
|
|
4
|
+
import { ShowOverlayTool } from './ShowOverlayTool';
|
|
5
|
+
export function SyntroTools({ runtime }) {
|
|
6
|
+
return (_jsxs(_Fragment, { children: [_jsx(GetContextTool, { runtime: runtime }), _jsx(ShowOverlayTool, { runtime: runtime }), _jsx(ScrollToTool, { runtime: runtime })] }));
|
|
7
|
+
}
|
package/dist/types.d.ts
CHANGED
|
@@ -57,6 +57,15 @@ export interface ChatbotWidgetRuntime {
|
|
|
57
57
|
events: {
|
|
58
58
|
publish: (name: string, props?: Record<string, unknown>) => void;
|
|
59
59
|
};
|
|
60
|
+
getActiveSignals: () => ActiveSignal[];
|
|
61
|
+
getContextConfig: () => ContextConfig;
|
|
60
62
|
}
|
|
63
|
+
/** A behavioral signal that has fired in the current browser session */
|
|
64
|
+
export interface ActiveSignal {
|
|
65
|
+
name: string;
|
|
66
|
+
firedAt: number;
|
|
67
|
+
}
|
|
68
|
+
/** Workspace-configured key/value pairs injected into get_context responses */
|
|
69
|
+
export type ContextConfig = Record<string, unknown>;
|
|
61
70
|
export type { EditorPanelProps } from '@syntrologie/sdk-contracts';
|
|
62
71
|
//# sourceMappingURL=types.d.ts.map
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAMH,MAAM,MAAM,WAAW,GAAG,MAAM,GAAG,WAAW,CAAC;AAE/C,MAAM,WAAW,WAAW;IAC1B,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,WAAW,CAAC;IAClB,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,CAAC;CACnB;AAMD,MAAM,WAAW,cAAc;IAC7B,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,WAAW,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IACvD,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB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AED,MAAM,WAAW,iBAAiB;IAChC,EAAE,EAAE,MAAM,CAAC;IACX,OAAO,EAAE,YAAY,EAAE,CAAC;IACxB,SAAS,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;IAC/B,SAAS,EAAE,MAAM,OAAO,CAAC;CAC1B;AAED,MAAM,WAAW,YAAY;IAC3B,KAAK,EAAE,CAAC,MAAM,EAAE,OAAO,KAAK,OAAO,CAAC,YAAY,CAAC,CAAC;IAClD,UAAU,EAAE,CAAC,OAAO,EAAE,OAAO,EAAE,KAAK,OAAO,CAAC,iBAAiB,CAAC,CAAC;CAChE;AAED,MAAM,WAAW,oBAAoB;IACnC,OAAO,EAAE,YAAY,CAAC;IACtB,MAAM,EAAE;QACN,OAAO,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,IAAI,CAAC;KAClE,CAAC;IAEF,gBAAgB,EAAE,MAAM,YAAY,EAAE,CAAC;IACvC,gBAAgB,EAAE,MAAM,aAAa,CAAC;CACvC;AAMD,wEAAwE;AACxE,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,+EAA+E;AAC/E,MAAM,MAAM,aAAa,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAMpD,YAAY,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@syntrologie/adapt-chatbot",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.12.0",
|
|
4
4
|
"description": "Adaptive Chatbot - AI chat assistant widget with action execution",
|
|
5
5
|
"license": "Proprietary",
|
|
6
6
|
"private": false,
|
|
@@ -15,6 +15,14 @@
|
|
|
15
15
|
},
|
|
16
16
|
"type": "module",
|
|
17
17
|
"exports": {
|
|
18
|
+
".": {
|
|
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"
|
|
25
|
+
},
|
|
18
26
|
"./runtime": {
|
|
19
27
|
"types": "./dist/runtime.d.ts",
|
|
20
28
|
"import": "./dist/runtime.js"
|
|
@@ -44,6 +52,8 @@
|
|
|
44
52
|
"test:watch": "vitest"
|
|
45
53
|
},
|
|
46
54
|
"dependencies": {
|
|
55
|
+
"@assistant-ui/react": "0.12.22",
|
|
56
|
+
"@assistant-ui/react-ai-sdk": "1.3.17",
|
|
47
57
|
"@syntrologie/shared-editor-ui": "*",
|
|
48
58
|
"@syntro/design-system": "*"
|
|
49
59
|
},
|
|
@@ -53,16 +63,17 @@
|
|
|
53
63
|
"zod": "^3.0.0"
|
|
54
64
|
},
|
|
55
65
|
"devDependencies": {
|
|
56
|
-
"@
|
|
66
|
+
"@assistant-ui/react": "0.12.22",
|
|
67
|
+
"@syntro/design-system": "1.0.0",
|
|
57
68
|
"@syntrologie/shared-editor-ui": "*",
|
|
58
|
-
"@testing-library/react": "
|
|
59
|
-
"@types/react": "
|
|
60
|
-
"@types/react-dom": "
|
|
61
|
-
"jsdom": "
|
|
62
|
-
"react": "
|
|
63
|
-
"react-dom": "
|
|
64
|
-
"typescript": "
|
|
65
|
-
"vitest": "
|
|
66
|
-
"zod": "
|
|
69
|
+
"@testing-library/react": "16.3.2",
|
|
70
|
+
"@types/react": "19.2.14",
|
|
71
|
+
"@types/react-dom": "19.2.3",
|
|
72
|
+
"jsdom": "26.1.0",
|
|
73
|
+
"react": "19.2.1",
|
|
74
|
+
"react-dom": "19.2.1",
|
|
75
|
+
"typescript": "5.9.3",
|
|
76
|
+
"vitest": "4.0.18",
|
|
77
|
+
"zod": "3.25.76"
|
|
67
78
|
}
|
|
68
79
|
}
|