@aigentyc/chat-sdk 0.5.5 → 0.7.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/context7.json +1 -1
- package/dist/{ChatInterface-Bo0dU48x.d.cts → ChatInterface-CJwumV6Z.d.cts} +1 -1
- package/dist/{ChatInterface-D5tY6WT1.d.ts → ChatInterface-jIlVCXyV.d.ts} +1 -1
- package/dist/{SlotsContext-hUp2jze9.d.ts → SlotsContext-BFyBOPC2.d.ts} +1 -1
- package/dist/{SlotsContext-p_bTEjGT.d.cts → SlotsContext-CvGHgMRZ.d.cts} +1 -1
- package/dist/ai-elements.cjs +2 -2
- package/dist/ai-elements.cjs.map +1 -1
- package/dist/ai-elements.js +2 -2
- package/dist/ai-elements.js.map +1 -1
- package/dist/{chunk-G63CLUHC.js → chunk-2HJZDMY2.js} +134 -9
- package/dist/chunk-2HJZDMY2.js.map +1 -0
- package/dist/{chunk-ZPOCKCBF.js → chunk-4DC55YI3.js} +3 -3
- package/dist/{chunk-ZPOCKCBF.js.map → chunk-4DC55YI3.js.map} +1 -1
- package/dist/{chunk-7TMQBROA.js → chunk-7N5ELRVH.js} +4 -4
- package/dist/{chunk-7TMQBROA.js.map → chunk-7N5ELRVH.js.map} +1 -1
- package/dist/{chunk-AQTN4QLR.cjs → chunk-MN7RYGXK.cjs} +6 -6
- package/dist/{chunk-AQTN4QLR.cjs.map → chunk-MN7RYGXK.cjs.map} +1 -1
- package/dist/{chunk-7MHR4BSJ.cjs → chunk-SOU2OES4.cjs} +21 -21
- package/dist/{chunk-7MHR4BSJ.cjs.map → chunk-SOU2OES4.cjs.map} +1 -1
- package/dist/{chunk-JJRLHXHZ.cjs → chunk-XV7N7UXF.cjs} +133 -8
- package/dist/chunk-XV7N7UXF.cjs.map +1 -0
- package/dist/components.cjs +15 -15
- package/dist/components.d.cts +3 -3
- package/dist/components.d.ts +3 -3
- package/dist/components.js +4 -4
- package/dist/core.d.cts +2 -2
- package/dist/core.d.ts +2 -2
- package/dist/hooks.cjs +4 -4
- package/dist/hooks.d.cts +2 -2
- package/dist/hooks.d.ts +2 -2
- package/dist/hooks.js +1 -1
- package/dist/i18n.d.cts +1 -1
- package/dist/i18n.d.ts +1 -1
- package/dist/index.cjs +25 -23
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +5 -5
- package/dist/index.d.ts +5 -5
- package/dist/index.js +8 -6
- package/dist/index.js.map +1 -1
- package/dist/llms-full.txt +9 -9
- package/dist/styles.css +1 -1
- package/dist/theme.d.cts +1 -1
- package/dist/theme.d.ts +1 -1
- package/dist/tools.cjs +5 -5
- package/dist/tools.d.cts +2 -2
- package/dist/tools.d.ts +2 -2
- package/dist/tools.js +2 -2
- package/dist/{types-DRa1zFlN.d.ts → types-BxvFxOg1.d.cts} +9 -0
- package/dist/{types-DRa1zFlN.d.cts → types-BxvFxOg1.d.ts} +9 -0
- package/package.json +5 -5
- package/dist/chunk-G63CLUHC.js.map +0 -1
- package/dist/chunk-JJRLHXHZ.cjs.map +0 -1
|
@@ -27,7 +27,82 @@ function renderSlot(name, props, DefaultComponent, slots) {
|
|
|
27
27
|
const Default = DefaultComponent;
|
|
28
28
|
return /* @__PURE__ */ jsxRuntime.jsx(Default, { ...spreadProps });
|
|
29
29
|
}
|
|
30
|
+
|
|
31
|
+
// src/core/browser-fetch.ts
|
|
32
|
+
var FETCH_TIMEOUT_MS = 15e3;
|
|
33
|
+
function failure(toolName, detail) {
|
|
34
|
+
return {
|
|
35
|
+
kind: "error",
|
|
36
|
+
errorText: `${toolName} could NOT run (${detail}). This is a failed check, NOT an empty result \u2014 do not say the item is missing or not in the catalogue. Tell the user the lookup could not be completed right now and offer to try again or to open a request.`
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
async function runBrowserFetchTool(call) {
|
|
40
|
+
const endpoint = `${call.apiEndpoint || ""}/api/kb/tools/browser-fetch`;
|
|
41
|
+
const post = (payload) => fetch(endpoint, {
|
|
42
|
+
method: "POST",
|
|
43
|
+
headers: {
|
|
44
|
+
"Content-Type": "application/json",
|
|
45
|
+
...call.apiKey ? { Authorization: `Bearer ${call.apiKey}` } : {}
|
|
46
|
+
},
|
|
47
|
+
body: JSON.stringify({
|
|
48
|
+
projectId: call.projectId,
|
|
49
|
+
sessionId: call.sessionId,
|
|
50
|
+
toolName: call.toolName,
|
|
51
|
+
input: call.input ?? {},
|
|
52
|
+
...payload
|
|
53
|
+
})
|
|
54
|
+
});
|
|
55
|
+
try {
|
|
56
|
+
const resolved = await post({ phase: "resolve" });
|
|
57
|
+
if (resolved.status === 404) return { kind: "not-browser-fetch" };
|
|
58
|
+
if (!resolved.ok) {
|
|
59
|
+
return failure(call.toolName, `prepare step HTTP ${resolved.status}`);
|
|
60
|
+
}
|
|
61
|
+
const { request } = await resolved.json();
|
|
62
|
+
const startedAt = Date.now();
|
|
63
|
+
let response;
|
|
64
|
+
try {
|
|
65
|
+
const res = await fetch(request.url, {
|
|
66
|
+
method: request.method,
|
|
67
|
+
headers: request.headers,
|
|
68
|
+
body: request.body,
|
|
69
|
+
credentials: "include",
|
|
70
|
+
signal: AbortSignal.timeout(FETCH_TIMEOUT_MS)
|
|
71
|
+
});
|
|
72
|
+
if (!res.ok) {
|
|
73
|
+
return failure(call.toolName, `HTTP ${res.status}`);
|
|
74
|
+
}
|
|
75
|
+
response = await res.json();
|
|
76
|
+
} catch (err) {
|
|
77
|
+
return failure(call.toolName, err instanceof Error ? err.message : String(err));
|
|
78
|
+
}
|
|
79
|
+
const completed = await post({
|
|
80
|
+
phase: "complete",
|
|
81
|
+
response,
|
|
82
|
+
latencyMs: Date.now() - startedAt
|
|
83
|
+
});
|
|
84
|
+
if (!completed.ok) {
|
|
85
|
+
const detail = await completed.json().catch(() => null);
|
|
86
|
+
return failure(call.toolName, detail?.error || `HTTP ${completed.status}`);
|
|
87
|
+
}
|
|
88
|
+
const { output } = await completed.json();
|
|
89
|
+
return { kind: "output", output };
|
|
90
|
+
} catch (err) {
|
|
91
|
+
return failure(call.toolName, err instanceof Error ? err.message : String(err));
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
function pendingToolCalls(message) {
|
|
95
|
+
const out = [];
|
|
96
|
+
for (const raw of message.parts ?? []) {
|
|
97
|
+
const p = raw;
|
|
98
|
+
if (p.state !== "input-available" || !p.toolCallId) continue;
|
|
99
|
+
const toolName = p.type === "dynamic-tool" ? p.toolName : p.type.startsWith("tool-") ? p.type.slice(5) : void 0;
|
|
100
|
+
if (toolName) out.push({ toolName, toolCallId: p.toolCallId, input: p.input });
|
|
101
|
+
}
|
|
102
|
+
return out;
|
|
103
|
+
}
|
|
30
104
|
var SESSION_KEY_PREFIX = "aigentyc-session-";
|
|
105
|
+
var MAX_BROWSER_TOOL_CALLS_PER_TURN = 6;
|
|
31
106
|
var LEGACY_MESSAGE_KEY_PREFIX = "aigentyc-messages-";
|
|
32
107
|
function dropLegacyMessageStore(projectId) {
|
|
33
108
|
if (typeof window === "undefined") return;
|
|
@@ -78,12 +153,14 @@ function ChatContextProvider({
|
|
|
78
153
|
const pageRef = react.useRef({
|
|
79
154
|
pageUrl: config.pageUrl,
|
|
80
155
|
pageTitle: config.pageTitle,
|
|
81
|
-
pageContext: config.pageContext
|
|
156
|
+
pageContext: config.pageContext,
|
|
157
|
+
browserFetch: config.browserFetch === true
|
|
82
158
|
});
|
|
83
159
|
pageRef.current = {
|
|
84
160
|
pageUrl: config.pageUrl,
|
|
85
161
|
pageTitle: config.pageTitle,
|
|
86
|
-
pageContext: config.pageContext
|
|
162
|
+
pageContext: config.pageContext,
|
|
163
|
+
browserFetch: config.browserFetch === true
|
|
87
164
|
};
|
|
88
165
|
const transport = react.useMemo(
|
|
89
166
|
() => new ai.DefaultChatTransport({
|
|
@@ -91,18 +168,49 @@ function ChatContextProvider({
|
|
|
91
168
|
headers: config.apiKey ? { Authorization: `Bearer ${config.apiKey}` } : void 0,
|
|
92
169
|
// A function body is resolved per request by the AI SDK transport.
|
|
93
170
|
body: () => {
|
|
94
|
-
const { pageUrl, pageTitle, pageContext } = pageRef.current;
|
|
171
|
+
const { pageUrl, pageTitle, pageContext, browserFetch } = pageRef.current;
|
|
95
172
|
return {
|
|
96
173
|
projectId: config.projectId,
|
|
97
174
|
sessionId,
|
|
98
175
|
...pageUrl ? { pageUrl } : {},
|
|
99
176
|
...pageTitle ? { pageTitle } : {},
|
|
100
|
-
...pageContext !== void 0 ? { pageContext } : {}
|
|
177
|
+
...pageContext !== void 0 ? { pageContext } : {},
|
|
178
|
+
...browserFetch ? { clientCapabilities: ["browser_fetch"] } : {}
|
|
101
179
|
};
|
|
102
180
|
}
|
|
103
181
|
}),
|
|
104
182
|
[config.apiEndpoint, config.apiKey, config.projectId, sessionId]
|
|
105
183
|
);
|
|
184
|
+
const browserAnsweredRef = react.useRef(/* @__PURE__ */ new Set());
|
|
185
|
+
const browserRunRef = react.useRef(/* @__PURE__ */ new Set());
|
|
186
|
+
const addToolOutputRef = react.useRef(null);
|
|
187
|
+
const runPendingBrowserTools = react.useCallback(
|
|
188
|
+
async (message) => {
|
|
189
|
+
if (!pageRef.current.browserFetch) return;
|
|
190
|
+
for (const call of pendingToolCalls(message)) {
|
|
191
|
+
const result = await runBrowserFetchTool({
|
|
192
|
+
apiEndpoint: config.apiEndpoint,
|
|
193
|
+
apiKey: config.apiKey,
|
|
194
|
+
projectId: config.projectId,
|
|
195
|
+
sessionId,
|
|
196
|
+
toolName: call.toolName,
|
|
197
|
+
input: call.input
|
|
198
|
+
});
|
|
199
|
+
if (result.kind === "not-browser-fetch") continue;
|
|
200
|
+
browserAnsweredRef.current.add(call.toolCallId);
|
|
201
|
+
browserRunRef.current.add(call.toolCallId);
|
|
202
|
+
addToolOutputRef.current?.(
|
|
203
|
+
result.kind === "output" ? { tool: call.toolName, toolCallId: call.toolCallId, output: result.output } : {
|
|
204
|
+
tool: call.toolName,
|
|
205
|
+
toolCallId: call.toolCallId,
|
|
206
|
+
state: "output-error",
|
|
207
|
+
errorText: result.errorText
|
|
208
|
+
}
|
|
209
|
+
);
|
|
210
|
+
}
|
|
211
|
+
},
|
|
212
|
+
[config.apiEndpoint, config.apiKey, config.projectId, sessionId]
|
|
213
|
+
);
|
|
106
214
|
const {
|
|
107
215
|
messages,
|
|
108
216
|
sendMessage: sdkSendMessage,
|
|
@@ -111,18 +219,35 @@ function ChatContextProvider({
|
|
|
111
219
|
stop,
|
|
112
220
|
setMessages,
|
|
113
221
|
regenerate,
|
|
114
|
-
clearError
|
|
222
|
+
clearError,
|
|
223
|
+
addToolOutput
|
|
115
224
|
} = react$1.useChat({
|
|
116
225
|
id: sessionId,
|
|
117
226
|
messages: initialMessages,
|
|
118
227
|
transport,
|
|
119
|
-
|
|
228
|
+
// Resume only a turn whose last open calls were answered by this widget —
|
|
229
|
+
// never one merely ending on a server tool, which would loop.
|
|
230
|
+
sendAutomaticallyWhen: ({ messages: all }) => {
|
|
231
|
+
if (!ai.lastAssistantMessageIsCompleteWithToolCalls({ messages: all })) return false;
|
|
232
|
+
const last = all[all.length - 1];
|
|
233
|
+
const parts = last.parts ?? [];
|
|
234
|
+
const answered = parts.some(
|
|
235
|
+
(p) => p.toolCallId && browserAnsweredRef.current.delete(p.toolCallId)
|
|
236
|
+
);
|
|
237
|
+
const rounds = parts.filter(
|
|
238
|
+
(p) => p.toolCallId && browserRunRef.current.has(p.toolCallId)
|
|
239
|
+
).length;
|
|
240
|
+
return answered && rounds <= MAX_BROWSER_TOOL_CALLS_PER_TURN;
|
|
241
|
+
},
|
|
242
|
+
onFinish: ({ message, isAbort, isError }) => {
|
|
243
|
+
if (!isAbort && !isError) void runPendingBrowserTools(message);
|
|
120
244
|
callbacksRef.current?.onMessageReceived?.(message);
|
|
121
245
|
},
|
|
122
246
|
onError: (err) => {
|
|
123
247
|
callbacksRef.current?.onError?.(err);
|
|
124
248
|
}
|
|
125
249
|
});
|
|
250
|
+
addToolOutputRef.current = addToolOutput;
|
|
126
251
|
const status = error ? "error" : sdkStatus === "streaming" || sdkStatus === "submitted" ? "streaming" : "idle";
|
|
127
252
|
react.useEffect(() => {
|
|
128
253
|
persistMessages(projectId, sessionId, messages);
|
|
@@ -243,5 +368,5 @@ exports.renderSlot = renderSlot;
|
|
|
243
368
|
exports.useChatContext = useChatContext;
|
|
244
369
|
exports.useSlot = useSlot;
|
|
245
370
|
exports.useSlots = useSlots;
|
|
246
|
-
//# sourceMappingURL=chunk-
|
|
247
|
-
//# sourceMappingURL=chunk-
|
|
371
|
+
//# sourceMappingURL=chunk-XV7N7UXF.cjs.map
|
|
372
|
+
//# sourceMappingURL=chunk-XV7N7UXF.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/providers/SlotsContext.tsx","../src/core/browser-fetch.ts","../src/providers/ChatContext.tsx"],"names":["createContext","useContext","jsx","saveMessages","loadMessages","clearMessages","useState","useRef","useMemo","useEffect","DefaultChatTransport","useCallback","useChat","lastAssistantMessageIsCompleteWithToolCalls"],"mappings":";;;;;;;;AA4CA,IAAM,YAAA,GAAeA,mBAAA,CAAuB,EAAE,CAAA;AAcvC,SAAS,cAAc,EAAE,KAAA,GAAQ,EAAC,EAAG,UAAS,EAAuB;AAC1E,EAAA,sCACG,YAAA,CAAa,QAAA,EAAb,EAAsB,KAAA,EAAO,OAAQ,QAAA,EAAS,CAAA;AAEnD;AAKO,SAAS,QAAA,GAAoB;AAClC,EAAA,OAAOC,iBAAW,YAAY,CAAA;AAChC;AAKO,SAAS,QACd,IAAA,EAC8B;AAC9B,EAAA,MAAM,KAAA,GAAQA,iBAAW,YAAY,CAAA;AACrC,EAAA,OAAO,MAAM,IAAI,CAAA;AACnB;AAeO,SAAS,UAAA,CACd,IAAA,EACA,KAAA,EACA,gBAAA,EACA,KAAA,EACoB;AACpB,EAAA,MAAM,WAAA,GAAc,KAAA;AACpB,EAAA,MAAM,QAAA,GAAW,MAAM,IAAI,CAAA;AAG3B,EAAA,IAAI,QAAA,EAAU;AACZ,IAAA,uBAAOC,cAAA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AACT","file":"chunk-XV7N7UXF.cjs","sourcesContent":["\"use client\";\n\nimport * as React from \"react\";\nimport {\n createContext,\n useContext,\n type ReactNode,\n type ComponentType,\n} from \"react\";\n\n/**\n * All available slot names that can be overridden.\n */\nexport type SlotName =\n | \"header\"\n | \"footer\"\n | \"input\"\n | \"welcomePage\"\n | \"userMessage\"\n | \"assistantMessage\"\n | \"systemMessage\"\n | \"loader\"\n | \"feedback\"\n | \"tools\"\n | \"toolRenderers\"\n | \"liveChatPanel\"\n | \"satisfactionRating\"\n | \"visitorIdentityForm\"\n | \"floatingButton\"\n | \"emptyState\"\n | \"error\";\n\n/**\n * A slot component receives the default component as a prop alongside its own props.\n */\nexport type SlotComponent<P = Record<string, unknown>> = ComponentType<\n P & { DefaultComponent: ComponentType<P> }\n>;\n\n/**\n * Map of slot name to override component.\n */\nexport type SlotMap = Partial<Record<SlotName, SlotComponent<any>>>;\n\nconst SlotsContext = createContext<SlotMap>({});\n\n/** Props for the SlotsProvider component. */\nexport interface SlotsProviderProps {\n /** Slot overrides map */\n slots?: SlotMap;\n children: ReactNode;\n}\n\n/**\n * Provides slot overrides to descendant components.\n * Wrap your chat tree with this provider and pass a `slots` map\n * to replace built-in UI sections.\n */\nexport function SlotsProvider({ slots = {}, children }: SlotsProviderProps) {\n return (\n <SlotsContext.Provider value={slots}>{children}</SlotsContext.Provider>\n );\n}\n\n/**\n * Returns the full SlotMap from context.\n */\nexport function useSlots(): SlotMap {\n return useContext(SlotsContext);\n}\n\n/**\n * Returns the override component for the given slot name, or undefined if none is set.\n */\nexport function useSlot<P = Record<string, unknown>>(\n name: SlotName\n): SlotComponent<P> | undefined {\n const slots = useContext(SlotsContext);\n return slots[name] as SlotComponent<P> | undefined;\n}\n\n/**\n * Renders a slot: if an override exists, renders it with `{...props, DefaultComponent}`.\n * Otherwise renders the DefaultComponent with the given props.\n *\n * The generic `P` is NOT constrained to `Record<string, unknown>` so concrete\n * component prop types (e.g. `ChatHeaderProps`) flow through at call sites\n * without `as never` casts. Internal spreads are cast through\n * `Record<string, unknown>` — safe because JSX spread accepts any record.\n *\n * @param name - The slot name\n * @param props - Props to pass to the component\n * @param DefaultComponent - The built-in fallback component\n */\nexport function renderSlot<P>(\n name: SlotName,\n props: P,\n DefaultComponent: ComponentType<P>,\n slots: SlotMap\n): React.ReactElement {\n const spreadProps = props as unknown as Record<string, unknown>;\n const Override = slots[name] as\n | ComponentType<Record<string, unknown> & { DefaultComponent: ComponentType<P> }>\n | undefined;\n if (Override) {\n return <Override {...spreadProps} DefaultComponent={DefaultComponent} />;\n }\n const Default = DefaultComponent as ComponentType<Record<string, unknown>>;\n return <Default {...spreadProps} />;\n}\n","/**\n * Browser-fetch tools — tools whose HTTP call must run in the visitor's browser\n * (apiConfig.fetchFrom = \"browser\" on the platform), typically because the API\n * answers per visitor session: a signed-in customer's private catalogue is\n * invisible to any server-side call, which has no access to their cookies.\n *\n * When the chat is configured with `browserFetch`, the backend registers those\n * tools without a server `execute`, so the turn pauses on the call. This module\n * runs one such call:\n * 1. asks the platform for the request to make (`phase: \"resolve\"`);\n * 2. makes it here, with `credentials: \"include\"`;\n * 3. hands the raw response back for the tool's own transform (`phase:\n * \"complete\"`), which also records it in analytics;\n * and returns the tool output the chat resumes with.\n */\n\nexport interface BrowserFetchCall {\n apiEndpoint: string;\n apiKey?: string;\n projectId: string;\n sessionId: string;\n toolName: string;\n input: unknown;\n}\n\nexport type BrowserFetchResult =\n | { kind: \"output\"; output: unknown }\n | { kind: \"error\"; errorText: string }\n /** The platform says this is not a browser-fetch tool — leave the call alone. */\n | { kind: \"not-browser-fetch\" };\n\n/** Upper bound for the visitor-side request, so a dead API cannot hang the turn. */\nconst FETCH_TIMEOUT_MS = 15_000;\n\n/**\n * What the model reads when a browser-run call fails. It must not be mistaken\n * for an empty result: a lookup that never ran is not \"not found\", and saying\n * so to a signed-in customer about their own product is the worst outcome.\n */\nfunction failure(toolName: string, detail: string): BrowserFetchResult {\n return {\n kind: \"error\",\n errorText:\n `${toolName} could NOT run (${detail}). This is a failed check, NOT an empty result — ` +\n `do not say the item is missing or not in the catalogue. Tell the user the lookup ` +\n `could not be completed right now and offer to try again or to open a request.`,\n };\n}\n\nexport async function runBrowserFetchTool(\n call: BrowserFetchCall,\n): Promise<BrowserFetchResult> {\n const endpoint = `${call.apiEndpoint || \"\"}/api/kb/tools/browser-fetch`;\n const post = (payload: Record<string, unknown>) =>\n fetch(endpoint, {\n method: \"POST\",\n headers: {\n \"Content-Type\": \"application/json\",\n ...(call.apiKey ? { Authorization: `Bearer ${call.apiKey}` } : {}),\n },\n body: JSON.stringify({\n projectId: call.projectId,\n sessionId: call.sessionId,\n toolName: call.toolName,\n input: call.input ?? {},\n ...payload,\n }),\n });\n\n try {\n const resolved = await post({ phase: \"resolve\" });\n if (resolved.status === 404) return { kind: \"not-browser-fetch\" };\n if (!resolved.ok) {\n return failure(call.toolName, `prepare step HTTP ${resolved.status}`);\n }\n const { request } = (await resolved.json()) as {\n request: {\n url: string;\n method: \"GET\" | \"POST\";\n headers: Record<string, string>;\n body?: string;\n };\n };\n\n const startedAt = Date.now();\n let response: unknown;\n try {\n const res = await fetch(request.url, {\n method: request.method,\n headers: request.headers,\n body: request.body,\n credentials: \"include\",\n signal: AbortSignal.timeout(FETCH_TIMEOUT_MS),\n });\n if (!res.ok) {\n return failure(call.toolName, `HTTP ${res.status}`);\n }\n response = await res.json();\n } catch (err) {\n return failure(call.toolName, err instanceof Error ? err.message : String(err));\n }\n\n const completed = await post({\n phase: \"complete\",\n response,\n latencyMs: Date.now() - startedAt,\n });\n if (!completed.ok) {\n const detail = (await completed.json().catch(() => null)) as {\n error?: string;\n } | null;\n return failure(call.toolName, detail?.error || `HTTP ${completed.status}`);\n }\n const { output } = (await completed.json()) as { output: unknown };\n return { kind: \"output\", output };\n } catch (err) {\n return failure(call.toolName, err instanceof Error ? err.message : String(err));\n }\n}\n\ninterface PendingToolPart {\n type: string;\n toolName?: string;\n toolCallId?: string;\n state?: string;\n input?: unknown;\n}\n\n/**\n * Tool calls in a finished assistant message that are still waiting for an\n * output — the candidates for browser execution. The platform decides which\n * of them really are browser-fetch tools (others, e.g. an upload-driven image\n * analysis, answer `not-browser-fetch` and are left alone).\n */\nexport function pendingToolCalls(message: {\n parts?: unknown[];\n}): Array<{ toolName: string; toolCallId: string; input: unknown }> {\n const out: Array<{ toolName: string; toolCallId: string; input: unknown }> = [];\n for (const raw of message.parts ?? []) {\n const p = raw as PendingToolPart;\n if (p.state !== \"input-available\" || !p.toolCallId) continue;\n const toolName =\n p.type === \"dynamic-tool\"\n ? p.toolName\n : p.type.startsWith(\"tool-\")\n ? p.type.slice(5)\n : undefined;\n if (toolName) out.push({ toolName, toolCallId: p.toolCallId, input: p.input });\n }\n return out;\n}\n","\"use client\";\n\nimport {\n createContext,\n useContext,\n useState,\n useCallback,\n useRef,\n useEffect,\n useMemo,\n type ReactNode,\n} from \"react\";\nimport type {\n ChatConfig,\n ChatMessage,\n ChatEventCallbacks,\n ChatAttachmentInput,\n} from \"../core/types\";\nimport { useChat } from \"@ai-sdk/react\";\nimport { DefaultChatTransport, lastAssistantMessageIsCompleteWithToolCalls } from \"ai\";\nimport { pendingToolCalls, runBrowserFetchTool } from \"../core/browser-fetch\";\nimport {\n clearMessages as clearStoredMessages,\n loadMessages as loadStoredMessages,\n saveMessages as saveStoredMessages,\n type StoredMessage,\n} from \"../core/message-store\";\n\ntype ChatStatus = \"idle\" | \"streaming\" | \"error\";\n\ninterface ActiveTool {\n toolName: string;\n state: \"partial-call\" | \"call\" | \"output-available\";\n args: Record<string, unknown>;\n result?: unknown;\n renderMode: string;\n}\n\nconst SESSION_KEY_PREFIX = \"aigentyc-session-\";\n\n/** Browser-run tool calls one assistant turn may resume after (see browser-fetch). */\nconst MAX_BROWSER_TOOL_CALLS_PER_TURN = 6;\n\n/**\n * Where this provider used to keep history, before it moved to\n * `core/message-store`.\n *\n * Worth deleting rather than leaving behind. The old writer had no size cap and\n * no expiry, so an established visitor can be carrying a large dead blob under\n * this key — and `localStorage` is a ~5 MB budget shared by the whole origin.\n * Nothing reads the key any more, but the space it holds is space the new\n * store's writes need, and those writes fail SILENTLY when the quota is gone.\n * An orphan left in place would mean persistence quietly stopping for exactly\n * the visitors who had used the chat the most.\n */\nconst LEGACY_MESSAGE_KEY_PREFIX = \"aigentyc-messages-\";\n\nfunction dropLegacyMessageStore(projectId: string): void {\n if (typeof window === \"undefined\") return;\n try {\n localStorage.removeItem(LEGACY_MESSAGE_KEY_PREFIX + projectId);\n } catch {\n // Unavailable or blocked — the old key is harmless, just wasteful.\n }\n}\n\nfunction getOrCreateSessionId(projectId: string): string {\n if (typeof window === \"undefined\") return crypto.randomUUID();\n const key = SESSION_KEY_PREFIX + projectId;\n try {\n const stored = sessionStorage.getItem(key);\n if (stored) return stored;\n const id = crypto.randomUUID();\n sessionStorage.setItem(key, id);\n return id;\n } catch {\n return crypto.randomUUID();\n }\n}\n\n/**\n * History is stored per project AND per session, by `core/message-store`.\n *\n * This used to be three local helpers keyed on `projectId` alone, with no\n * expiry and no size bound, while `message-store` — written for exactly this\n * job, and exported from the package — went unused. The difference is not\n * cosmetic:\n *\n * - **A session could not escape a poisoned history.** The server refuses a\n * turn whose replayed history is too long or too large. Because every\n * session in the project read the same key, that history came back on the\n * next page load, in the next tab and in a new session — so a conversation\n * that broke once answered nothing ever again, which is exactly how this was\n * reported from the field.\n * - **Sessions leaked into each other.** A second tab adopted the first tab's\n * conversation while reporting a different `sessionId` upstream, so the\n * transcript the server logged did not match the one on screen.\n * - **Nothing ever expired.** `message-store` drops history after 24 hours and\n * trims it when it outgrows 200 KB.\n *\n * Persistence across navigation is unchanged: the session id lives in\n * `sessionStorage`, which survives a full page load in the same tab.\n */\nfunction persistMessages(\n projectId: string,\n sessionId: string,\n messages: unknown[]\n): void {\n saveStoredMessages(projectId, sessionId, messages as StoredMessage[]);\n}\n\nfunction loadPersistedMessages(\n projectId: string,\n sessionId: string\n): ChatMessage[] {\n return loadStoredMessages(projectId, sessionId) as unknown as ChatMessage[];\n}\n\nfunction clearPersistedMessages(projectId: string, sessionId: string): void {\n clearStoredMessages(projectId, sessionId);\n}\n\nexport interface ChatContextValue {\n messages: ChatMessage[];\n status: ChatStatus;\n error: Error | undefined;\n sessionId: string;\n config: ChatConfig;\n activeTools: ActiveTool[];\n /**\n * Sends a user turn. `files` travel with it as message parts; a turn carrying\n * files may have empty text — an image on its own is a question.\n */\n sendMessage: (content: string, files?: ChatAttachmentInput[]) => void;\n stopGeneration: () => void;\n /**\n * Re-run the last turn after a failure. No-op while a turn is in flight.\n *\n * Worth offering for a transient refusal — a rate limit, a dropped stream, a\n * momentary 503. It cannot clear a refusal caused by the history itself,\n * because the same history is what gets re-sent; that needs\n * {@link ChatContextValue.newConversation}.\n */\n retryLastTurn: () => void;\n /**\n * Replace a sent user message with new text and answer it again.\n *\n * Everything after that message is dropped, as in ChatGPT's edit: the\n * conversation continues from the corrected question, not alongside the old\n * one. A turn still streaming is stopped first.\n */\n editMessage: (messageId: string, content: string) => void;\n newConversation: () => void;\n clearMessages: () => void;\n callbacks?: ChatEventCallbacks;\n}\n\nexport const ChatContext = createContext<ChatContextValue | null>(null);\n\nexport interface ChatContextProviderProps {\n config: ChatConfig;\n callbacks?: ChatEventCallbacks;\n children: ReactNode;\n}\n\n/**\n * Internal provider that manages chat state via @ai-sdk/react `useChat`.\n * Handles message persistence and session management.\n */\nexport function ChatContextProvider({\n config,\n callbacks,\n children,\n}: ChatContextProviderProps) {\n const projectId = config.projectId || \"default\";\n const [sessionId, setSessionId] = useState(() => getOrCreateSessionId(projectId));\n const callbacksRef = useRef(callbacks);\n callbacksRef.current = callbacks;\n\n // Re-load persisted messages whenever the session changes (incl. after\n // newConversation()). Keying only on mount cached the original array, so\n // useChat would re-inject the OLD messages into the new sessionId — a real\n // \"new chat\" effectively kept the old conversation alive.\n const initialMessages = useMemo(\n () => loadPersistedMessages(projectId, sessionId),\n [projectId, sessionId]\n );\n\n useEffect(() => {\n dropLegacyMessageStore(projectId);\n }, [projectId]);\n\n // Page context is whatever the host page looks like *right now*, so it is read\n // through a ref at send time rather than captured when the transport is built.\n // Rebuilding the transport on every navigation would remount `useChat` and\n // drop an in-flight stream — in a single-page host that is one route change.\n const pageRef = useRef({\n pageUrl: config.pageUrl,\n pageTitle: config.pageTitle,\n pageContext: config.pageContext,\n browserFetch: config.browserFetch === true,\n });\n pageRef.current = {\n pageUrl: config.pageUrl,\n pageTitle: config.pageTitle,\n pageContext: config.pageContext,\n browserFetch: config.browserFetch === true,\n };\n\n const transport = useMemo(\n () =>\n new DefaultChatTransport({\n api: `${config.apiEndpoint || \"\"}/api/kb/chat`,\n headers: config.apiKey ? { Authorization: `Bearer ${config.apiKey}` } : undefined,\n // A function body is resolved per request by the AI SDK transport.\n body: () => {\n const { pageUrl, pageTitle, pageContext, browserFetch } = pageRef.current;\n return {\n projectId: config.projectId,\n sessionId,\n ...(pageUrl ? { pageUrl } : {}),\n ...(pageTitle ? { pageTitle } : {}),\n ...(pageContext !== undefined ? { pageContext } : {}),\n ...(browserFetch ? { clientCapabilities: [\"browser_fetch\"] } : {}),\n };\n },\n }),\n [config.apiEndpoint, config.apiKey, config.projectId, sessionId]\n );\n\n // Browser-fetch tools (see core/browser-fetch): a turn that ends on such a\n // call is paused until this widget runs it and hands the output back. Ids of\n // the calls answered here — only those resume the turn automatically.\n const browserAnsweredRef = useRef(new Set<string>());\n // Every call ever answered here, so a turn's browser rounds can be counted.\n const browserRunRef = useRef(new Set<string>());\n const addToolOutputRef = useRef<((args: never) => unknown) | null>(null);\n const runPendingBrowserTools = useCallback(\n async (message: { parts?: unknown[] }) => {\n if (!pageRef.current.browserFetch) return;\n for (const call of pendingToolCalls(message)) {\n const result = await runBrowserFetchTool({\n apiEndpoint: config.apiEndpoint,\n apiKey: config.apiKey,\n projectId: config.projectId,\n sessionId,\n toolName: call.toolName,\n input: call.input,\n });\n if (result.kind === \"not-browser-fetch\") continue;\n browserAnsweredRef.current.add(call.toolCallId);\n browserRunRef.current.add(call.toolCallId);\n addToolOutputRef.current?.(\n (result.kind === \"output\"\n ? { tool: call.toolName, toolCallId: call.toolCallId, output: result.output }\n : {\n tool: call.toolName,\n toolCallId: call.toolCallId,\n state: \"output-error\",\n errorText: result.errorText,\n }) as never\n );\n }\n },\n [config.apiEndpoint, config.apiKey, config.projectId, sessionId]\n );\n\n const {\n messages,\n sendMessage: sdkSendMessage,\n status: sdkStatus,\n error,\n stop,\n setMessages,\n regenerate,\n clearError,\n addToolOutput,\n } = useChat({\n id: sessionId,\n messages: initialMessages as never,\n transport,\n // Resume only a turn whose last open calls were answered by this widget —\n // never one merely ending on a server tool, which would loop.\n sendAutomaticallyWhen: ({ messages: all }) => {\n if (!lastAssistantMessageIsCompleteWithToolCalls({ messages: all })) return false;\n const last = all[all.length - 1] as { parts?: Array<{ toolCallId?: string }> };\n const parts = last.parts ?? [];\n const answered = parts.some(\n (p) => p.toolCallId && browserAnsweredRef.current.delete(p.toolCallId)\n );\n // A continuation keeps the same assistant message, so its browser-run\n // calls are this turn's rounds. Cap them: a model that keeps re-calling a\n // failing tool would otherwise resume forever, one request per error.\n const rounds = parts.filter(\n (p) => p.toolCallId && browserRunRef.current.has(p.toolCallId)\n ).length;\n return answered && rounds <= MAX_BROWSER_TOOL_CALLS_PER_TURN;\n },\n onFinish: ({ message, isAbort, isError }) => {\n if (!isAbort && !isError) void runPendingBrowserTools(message);\n callbacksRef.current?.onMessageReceived?.(message as unknown as ChatMessage);\n },\n onError: (err) => {\n callbacksRef.current?.onError?.(err);\n },\n });\n\n addToolOutputRef.current = addToolOutput as unknown as (args: never) => unknown;\n\n const status: ChatStatus = error\n ? \"error\"\n : sdkStatus === \"streaming\" || sdkStatus === \"submitted\"\n ? \"streaming\"\n : \"idle\";\n\n useEffect(() => {\n persistMessages(projectId, sessionId, messages);\n }, [messages, projectId, sessionId]);\n\n const activeTools = useMemo<ActiveTool[]>(() => {\n if (messages.length === 0) return [];\n const last = messages[messages.length - 1] as { role: string; parts?: unknown[] };\n if (last.role !== \"assistant\" || !Array.isArray(last.parts)) return [];\n return (last.parts as Array<Record<string, unknown>>)\n .filter((p) => typeof p.type === \"string\" && (p.type as string).startsWith(\"tool-\"))\n .map((p) => ({\n toolName: (p.toolName as string) || (p.type as string).replace(\"tool-\", \"\"),\n state: (p.state as ActiveTool[\"state\"]) || \"output-available\",\n args: (p.args as Record<string, unknown>) || {},\n result: p.result,\n renderMode: (p.renderMode as string) || \"inline\",\n }));\n }, [messages]);\n\n const sendMessage = useCallback(\n (content: string, files?: ChatAttachmentInput[]) => {\n // An attachment is a message on its own, so an empty string only blocks\n // the send when nothing else is going with it.\n if (!content.trim() && (!files || files.length === 0)) return;\n callbacksRef.current?.onMessageSent?.({\n id: crypto.randomUUID(),\n role: \"user\",\n content,\n } as ChatMessage);\n sdkSendMessage({\n text: content,\n ...(files && files.length > 0\n ? { files: files.map((f) => ({ ...f, type: \"file\" as const })) }\n : {}),\n });\n },\n [sdkSendMessage]\n );\n\n const stopGeneration = useCallback(() => stop(), [stop]);\n\n // `clearError` first: the error is what the UI is rendering, and leaving it\n // set would keep the failure card on screen next to the turn now streaming.\n //\n // The empty check is not defensive padding. `regenerate()` THROWS when there\n // is no message to re-run, and a host that calls `clearMessages()` while a\n // failure is on screen leaves exactly that state — no messages, error still\n // set, so the card is still rendered and still offering its button. Left\n // alone it would also be an unhandled rejection, since nothing awaits this.\n const retryLastTurn = useCallback(() => {\n clearError();\n if (messages.length === 0) return;\n regenerate().catch(() => {\n // Request failures already land in `error` via useChat's own handling;\n // this only stops a rejected promise escaping the click handler.\n });\n }, [clearError, regenerate, messages]);\n\n const editMessage = useCallback(\n (messageId: string, content: string) => {\n if (!content.trim()) return;\n const target = messages.find((m) => m.id === messageId);\n // useChat throws for an unknown id or a non-user message; refuse quietly\n // instead, since this is wired straight to a click.\n if (!target || target.role !== \"user\") return;\n clearError();\n if (sdkStatus === \"streaming\" || sdkStatus === \"submitted\") stop();\n callbacksRef.current?.onMessageSent?.({\n id: messageId,\n role: \"user\",\n content,\n } as ChatMessage);\n sdkSendMessage({ text: content, messageId }).catch(() => {\n // Request failures land in `error` via useChat's own handling.\n });\n },\n [clearError, messages, sdkSendMessage, sdkStatus, stop]\n );\n\n const newConversation = useCallback(() => {\n setMessages([]);\n clearPersistedMessages(projectId, sessionId);\n if (typeof window !== \"undefined\") {\n try {\n sessionStorage.removeItem(SESSION_KEY_PREFIX + projectId);\n } catch {\n // ignore\n }\n }\n setSessionId(getOrCreateSessionId(projectId));\n }, [projectId, sessionId, setMessages]);\n\n const clearMessages = useCallback(() => {\n setMessages([]);\n clearPersistedMessages(projectId, sessionId);\n }, [projectId, sessionId, setMessages]);\n\n const value = useMemo<ChatContextValue>(\n () => ({\n messages: messages as unknown as ChatMessage[],\n status,\n error: error as Error | undefined,\n sessionId,\n config,\n activeTools,\n sendMessage,\n stopGeneration,\n retryLastTurn,\n editMessage,\n newConversation,\n clearMessages,\n callbacks: callbacksRef.current,\n }),\n [\n messages,\n status,\n error,\n sessionId,\n config,\n activeTools,\n sendMessage,\n stopGeneration,\n retryLastTurn,\n editMessage,\n newConversation,\n clearMessages,\n ]\n );\n\n return <ChatContext.Provider value={value}>{children}</ChatContext.Provider>;\n}\n\n/**\n * Returns the chat context. Must be used within a `ChatContextProvider`.\n */\nexport function useChatContext(): ChatContextValue {\n const ctx = useContext(ChatContext);\n if (!ctx) {\n throw new Error(\n \"useChatContext must be used within a ChatProvider or ChatContextProvider\"\n );\n }\n return ctx;\n}\n"]}
|
package/dist/components.cjs
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
'use strict';
|
|
3
3
|
|
|
4
|
-
var
|
|
4
|
+
var chunkSOU2OES4_cjs = require('./chunk-SOU2OES4.cjs');
|
|
5
5
|
require('./chunk-DVWX2UGY.cjs');
|
|
6
6
|
require('./chunk-BYX6IOGX.cjs');
|
|
7
7
|
require('./chunk-7LJMBYHC.cjs');
|
|
8
8
|
require('./chunk-X7R334SB.cjs');
|
|
9
9
|
var chunk72QJ2ORD_cjs = require('./chunk-72QJ2ORD.cjs');
|
|
10
|
-
require('./chunk-
|
|
11
|
-
require('./chunk-
|
|
10
|
+
require('./chunk-MN7RYGXK.cjs');
|
|
11
|
+
require('./chunk-XV7N7UXF.cjs');
|
|
12
12
|
require('./chunk-VYBHYFG3.cjs');
|
|
13
13
|
require('./chunk-JOO6C3XT.cjs');
|
|
14
14
|
require('./chunk-EMVZ7HWM.cjs');
|
|
@@ -287,7 +287,7 @@ function ChatDrawer({
|
|
|
287
287
|
className: "w-full sm:w-[450px] sm:max-w-[450px] p-0 flex flex-col [&>button]:hidden",
|
|
288
288
|
children: [
|
|
289
289
|
/* @__PURE__ */ jsxRuntime.jsx(VisuallyHidden__namespace.Root, { children: /* @__PURE__ */ jsxRuntime.jsx(SheetTitle, { children: "Chat Assistant" }) }),
|
|
290
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
290
|
+
/* @__PURE__ */ jsxRuntime.jsx(chunkSOU2OES4_cjs.ChatInterface, {})
|
|
291
291
|
]
|
|
292
292
|
}
|
|
293
293
|
)
|
|
@@ -479,47 +479,47 @@ function SatisfactionRating({ onSubmit, onSkip }) {
|
|
|
479
479
|
|
|
480
480
|
Object.defineProperty(exports, "CartDrawer", {
|
|
481
481
|
enumerable: true,
|
|
482
|
-
get: function () { return
|
|
482
|
+
get: function () { return chunkSOU2OES4_cjs.CartDrawer; }
|
|
483
483
|
});
|
|
484
484
|
Object.defineProperty(exports, "ChatFooter", {
|
|
485
485
|
enumerable: true,
|
|
486
|
-
get: function () { return
|
|
486
|
+
get: function () { return chunkSOU2OES4_cjs.ChatFooter; }
|
|
487
487
|
});
|
|
488
488
|
Object.defineProperty(exports, "ChatHeader", {
|
|
489
489
|
enumerable: true,
|
|
490
|
-
get: function () { return
|
|
490
|
+
get: function () { return chunkSOU2OES4_cjs.ChatHeader; }
|
|
491
491
|
});
|
|
492
492
|
Object.defineProperty(exports, "ChatInput", {
|
|
493
493
|
enumerable: true,
|
|
494
|
-
get: function () { return
|
|
494
|
+
get: function () { return chunkSOU2OES4_cjs.ChatInput; }
|
|
495
495
|
});
|
|
496
496
|
Object.defineProperty(exports, "ChatInterface", {
|
|
497
497
|
enumerable: true,
|
|
498
|
-
get: function () { return
|
|
498
|
+
get: function () { return chunkSOU2OES4_cjs.ChatInterface; }
|
|
499
499
|
});
|
|
500
500
|
Object.defineProperty(exports, "FloatingButton", {
|
|
501
501
|
enumerable: true,
|
|
502
|
-
get: function () { return
|
|
502
|
+
get: function () { return chunkSOU2OES4_cjs.FloatingButton; }
|
|
503
503
|
});
|
|
504
504
|
Object.defineProperty(exports, "LiveChatPanel", {
|
|
505
505
|
enumerable: true,
|
|
506
|
-
get: function () { return
|
|
506
|
+
get: function () { return chunkSOU2OES4_cjs.LiveChatPanel; }
|
|
507
507
|
});
|
|
508
508
|
Object.defineProperty(exports, "PreviewEmbedPanel", {
|
|
509
509
|
enumerable: true,
|
|
510
|
-
get: function () { return
|
|
510
|
+
get: function () { return chunkSOU2OES4_cjs.PreviewEmbedPanel; }
|
|
511
511
|
});
|
|
512
512
|
Object.defineProperty(exports, "QuickQuestions", {
|
|
513
513
|
enumerable: true,
|
|
514
|
-
get: function () { return
|
|
514
|
+
get: function () { return chunkSOU2OES4_cjs.QuickQuestions; }
|
|
515
515
|
});
|
|
516
516
|
Object.defineProperty(exports, "SystemMessage", {
|
|
517
517
|
enumerable: true,
|
|
518
|
-
get: function () { return
|
|
518
|
+
get: function () { return chunkSOU2OES4_cjs.SystemMessage; }
|
|
519
519
|
});
|
|
520
520
|
Object.defineProperty(exports, "WelcomePage", {
|
|
521
521
|
enumerable: true,
|
|
522
|
-
get: function () { return
|
|
522
|
+
get: function () { return chunkSOU2OES4_cjs.WelcomePage; }
|
|
523
523
|
});
|
|
524
524
|
exports.ChatDrawer = ChatDrawer;
|
|
525
525
|
exports.ChatInputWithAttachments = ChatInputWithAttachments;
|
package/dist/components.d.cts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { P as PanelWidth } from './ChatInterface-
|
|
2
|
-
export { a as ChatInterface } from './ChatInterface-
|
|
1
|
+
import { P as PanelWidth } from './ChatInterface-CJwumV6Z.cjs';
|
|
2
|
+
export { a as ChatInterface } from './ChatInterface-CJwumV6Z.cjs';
|
|
3
3
|
import * as React$1 from 'react';
|
|
4
|
-
import { c as ChatAttachmentInput, Q as QuestionConfig } from './types-
|
|
4
|
+
import { c as ChatAttachmentInput, Q as QuestionConfig } from './types-BxvFxOg1.cjs';
|
|
5
5
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
6
6
|
import { FileUIPart } from 'ai';
|
|
7
7
|
|
package/dist/components.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { P as PanelWidth } from './ChatInterface-
|
|
2
|
-
export { a as ChatInterface } from './ChatInterface-
|
|
1
|
+
import { P as PanelWidth } from './ChatInterface-jIlVCXyV.js';
|
|
2
|
+
export { a as ChatInterface } from './ChatInterface-jIlVCXyV.js';
|
|
3
3
|
import * as React$1 from 'react';
|
|
4
|
-
import { c as ChatAttachmentInput, Q as QuestionConfig } from './types-
|
|
4
|
+
import { c as ChatAttachmentInput, Q as QuestionConfig } from './types-BxvFxOg1.js';
|
|
5
5
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
6
6
|
import { FileUIPart } from 'ai';
|
|
7
7
|
|
package/dist/components.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { ChatInterface } from './chunk-
|
|
3
|
-
export { CartDrawer, ChatFooter, ChatHeader, ChatInput, ChatInterface, FloatingButton, LiveChatPanel, PreviewEmbedPanel, QuickQuestions, SystemMessage, WelcomePage } from './chunk-
|
|
2
|
+
import { ChatInterface } from './chunk-7N5ELRVH.js';
|
|
3
|
+
export { CartDrawer, ChatFooter, ChatHeader, ChatInput, ChatInterface, FloatingButton, LiveChatPanel, PreviewEmbedPanel, QuickQuestions, SystemMessage, WelcomePage } from './chunk-7N5ELRVH.js';
|
|
4
4
|
import './chunk-P7UR37HP.js';
|
|
5
5
|
import './chunk-VQPOUMBC.js';
|
|
6
6
|
import './chunk-TXX2W7ZR.js';
|
|
7
7
|
import './chunk-MZQKGNWF.js';
|
|
8
8
|
import { useI18n } from './chunk-LDQVDUUJ.js';
|
|
9
|
-
import './chunk-
|
|
10
|
-
import './chunk-
|
|
9
|
+
import './chunk-4DC55YI3.js';
|
|
10
|
+
import './chunk-2HJZDMY2.js';
|
|
11
11
|
import './chunk-CNPYBLLT.js';
|
|
12
12
|
import './chunk-PS3U7T37.js';
|
|
13
13
|
import './chunk-JAOD6CNW.js';
|
package/dist/core.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { d as ChatConfig } from './types-
|
|
2
|
-
export { c as ChatAttachmentInput, e as ChatEventCallbacks, f as ChatMessage, b as ChatProviderProps, C as ComponentAction, L as Language, g as LiveChatMessage, h as LiveChatState, Q as QuestionConfig, S as SlotMap, j as SlotProps, i as ThemeConfig, T as ToolRendererProps, a as ToolResult } from './types-
|
|
1
|
+
import { d as ChatConfig } from './types-BxvFxOg1.cjs';
|
|
2
|
+
export { c as ChatAttachmentInput, e as ChatEventCallbacks, f as ChatMessage, b as ChatProviderProps, C as ComponentAction, L as Language, g as LiveChatMessage, h as LiveChatState, Q as QuestionConfig, S as SlotMap, j as SlotProps, i as ThemeConfig, T as ToolRendererProps, a as ToolResult } from './types-BxvFxOg1.cjs';
|
|
3
3
|
import { ClassValue } from 'clsx';
|
|
4
4
|
import * as ai from 'ai';
|
|
5
5
|
export { I as InteractionMetadata, a as InteractionType, T as TrackInteractionParams, U as UseInteractionTrackerOptions, g as generateSessionId, u as useInteractionTracker } from './interaction-tracker-D9P1Oq4j.cjs';
|
package/dist/core.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { d as ChatConfig } from './types-
|
|
2
|
-
export { c as ChatAttachmentInput, e as ChatEventCallbacks, f as ChatMessage, b as ChatProviderProps, C as ComponentAction, L as Language, g as LiveChatMessage, h as LiveChatState, Q as QuestionConfig, S as SlotMap, j as SlotProps, i as ThemeConfig, T as ToolRendererProps, a as ToolResult } from './types-
|
|
1
|
+
import { d as ChatConfig } from './types-BxvFxOg1.js';
|
|
2
|
+
export { c as ChatAttachmentInput, e as ChatEventCallbacks, f as ChatMessage, b as ChatProviderProps, C as ComponentAction, L as Language, g as LiveChatMessage, h as LiveChatState, Q as QuestionConfig, S as SlotMap, j as SlotProps, i as ThemeConfig, T as ToolRendererProps, a as ToolResult } from './types-BxvFxOg1.js';
|
|
3
3
|
import { ClassValue } from 'clsx';
|
|
4
4
|
import * as ai from 'ai';
|
|
5
5
|
export { I as InteractionMetadata, a as InteractionType, T as TrackInteractionParams, U as UseInteractionTrackerOptions, g as generateSessionId, u as useInteractionTracker } from './interaction-tracker-D9P1Oq4j.js';
|
package/dist/hooks.cjs
CHANGED
|
@@ -9,7 +9,7 @@ var chunkBYX6IOGX_cjs = require('./chunk-BYX6IOGX.cjs');
|
|
|
9
9
|
var chunkDDATCJ3O_cjs = require('./chunk-DDATCJ3O.cjs');
|
|
10
10
|
require('./chunk-X7R334SB.cjs');
|
|
11
11
|
var chunk72QJ2ORD_cjs = require('./chunk-72QJ2ORD.cjs');
|
|
12
|
-
var
|
|
12
|
+
var chunkXV7N7UXF_cjs = require('./chunk-XV7N7UXF.cjs');
|
|
13
13
|
require('./chunk-VYBHYFG3.cjs');
|
|
14
14
|
var react = require('react');
|
|
15
15
|
|
|
@@ -326,15 +326,15 @@ Object.defineProperty(exports, "useI18n", {
|
|
|
326
326
|
});
|
|
327
327
|
Object.defineProperty(exports, "useChatContext", {
|
|
328
328
|
enumerable: true,
|
|
329
|
-
get: function () { return
|
|
329
|
+
get: function () { return chunkXV7N7UXF_cjs.useChatContext; }
|
|
330
330
|
});
|
|
331
331
|
Object.defineProperty(exports, "useSlot", {
|
|
332
332
|
enumerable: true,
|
|
333
|
-
get: function () { return
|
|
333
|
+
get: function () { return chunkXV7N7UXF_cjs.useSlot; }
|
|
334
334
|
});
|
|
335
335
|
Object.defineProperty(exports, "useSlots", {
|
|
336
336
|
enumerable: true,
|
|
337
|
-
get: function () { return
|
|
337
|
+
get: function () { return chunkXV7N7UXF_cjs.useSlots; }
|
|
338
338
|
});
|
|
339
339
|
exports.useImageLoader = useImageLoader;
|
|
340
340
|
exports.useMultiImageLoader = useMultiImageLoader;
|
package/dist/hooks.d.cts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
export { A as AutoResizeOptions, K as KeyboardLanguageOptions, L as LATIN, a as LiveChatReturn, U as UseAigentycChatOptions, c as UseAigentycChatReturn, d as detectLanguage, s as scriptLanguageOf, u as useAigentycChat, e as useAutoResize, f as useChatContext, g as useKeyboardLanguage, h as useLiveChat, i as useSlot, j as useSlots } from './SlotsContext-
|
|
1
|
+
export { A as AutoResizeOptions, K as KeyboardLanguageOptions, L as LATIN, a as LiveChatReturn, U as UseAigentycChatOptions, c as UseAigentycChatReturn, d as detectLanguage, s as scriptLanguageOf, u as useAigentycChat, e as useAutoResize, f as useChatContext, g as useKeyboardLanguage, h as useLiveChat, i as useSlot, j as useSlots } from './SlotsContext-CvGHgMRZ.cjs';
|
|
2
2
|
export { useTheme } from './theme.cjs';
|
|
3
3
|
export { useI18n } from './i18n.cjs';
|
|
4
4
|
import { RefObject } from 'react';
|
|
5
5
|
export { u as useInteractionTracker } from './interaction-tracker-D9P1Oq4j.cjs';
|
|
6
|
-
import './types-
|
|
6
|
+
import './types-BxvFxOg1.cjs';
|
|
7
7
|
import 'react/jsx-runtime';
|
|
8
8
|
|
|
9
9
|
/** Information about a preview to display in an embedded panel. */
|
package/dist/hooks.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
export { A as AutoResizeOptions, K as KeyboardLanguageOptions, L as LATIN, a as LiveChatReturn, U as UseAigentycChatOptions, c as UseAigentycChatReturn, d as detectLanguage, s as scriptLanguageOf, u as useAigentycChat, e as useAutoResize, f as useChatContext, g as useKeyboardLanguage, h as useLiveChat, i as useSlot, j as useSlots } from './SlotsContext-
|
|
1
|
+
export { A as AutoResizeOptions, K as KeyboardLanguageOptions, L as LATIN, a as LiveChatReturn, U as UseAigentycChatOptions, c as UseAigentycChatReturn, d as detectLanguage, s as scriptLanguageOf, u as useAigentycChat, e as useAutoResize, f as useChatContext, g as useKeyboardLanguage, h as useLiveChat, i as useSlot, j as useSlots } from './SlotsContext-BFyBOPC2.js';
|
|
2
2
|
export { useTheme } from './theme.js';
|
|
3
3
|
export { useI18n } from './i18n.js';
|
|
4
4
|
import { RefObject } from 'react';
|
|
5
5
|
export { u as useInteractionTracker } from './interaction-tracker-D9P1Oq4j.js';
|
|
6
|
-
import './types-
|
|
6
|
+
import './types-BxvFxOg1.js';
|
|
7
7
|
import 'react/jsx-runtime';
|
|
8
8
|
|
|
9
9
|
/** Information about a preview to display in an embedded panel. */
|
package/dist/hooks.js
CHANGED
|
@@ -7,7 +7,7 @@ export { useTheme } from './chunk-VQPOUMBC.js';
|
|
|
7
7
|
export { LATIN, detectLanguage, scriptLanguageOf, useKeyboardLanguage } from './chunk-BYTPAQ7F.js';
|
|
8
8
|
import './chunk-MZQKGNWF.js';
|
|
9
9
|
export { useI18n } from './chunk-LDQVDUUJ.js';
|
|
10
|
-
export { useChatContext, useSlot, useSlots } from './chunk-
|
|
10
|
+
export { useChatContext, useSlot, useSlots } from './chunk-2HJZDMY2.js';
|
|
11
11
|
import './chunk-CNPYBLLT.js';
|
|
12
12
|
import { useState, useCallback, useMemo, useEffect } from 'react';
|
|
13
13
|
|
package/dist/i18n.d.cts
CHANGED
package/dist/i18n.d.ts
CHANGED