@useago/sdk 0.3.2 → 0.3.4
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/AgoClient-DF7M2WAz.js +575 -0
- package/dist/AgoClient-bjN-z2ZQ.cjs +6 -0
- package/dist/angular.cjs +1 -143
- package/dist/angular.d.cts +530 -0
- package/dist/angular.d.ts +530 -2
- package/dist/angular.js +71 -139
- package/dist/createFormCollector-ClzHfaBd.js +185 -0
- package/dist/createFormCollector-H4Me_2uj.cjs +1 -0
- package/dist/createMockClient-C50gjV0b.js +71 -0
- package/dist/createMockClient-DQvFFWnc.cjs +1 -0
- package/dist/devtools.cjs +26 -100
- package/dist/devtools.d.cts +443 -0
- package/dist/devtools.d.ts +443 -2
- package/dist/devtools.js +68 -93
- package/dist/functions-BH1X5kas.cjs +1 -0
- package/dist/functions-CWSRi3xv.js +312 -0
- package/dist/helpers.cjs +1 -15
- package/dist/{helpers/functions.d.ts → helpers.d.cts} +121 -62
- package/dist/helpers.d.ts +121 -2
- package/dist/helpers.js +16 -2
- package/dist/index.cjs +1 -347
- package/dist/index.d.cts +1150 -0
- package/dist/index.d.ts +1150 -20
- package/dist/index.js +129 -298
- package/dist/react.cjs +31 -22438
- package/dist/react.d.cts +999 -0
- package/dist/react.d.ts +999 -2
- package/dist/react.js +8416 -22376
- package/dist/rolldown-runtime-CaekUdDJ.cjs +1 -0
- package/dist/rolldown-runtime-DxmricAu.js +25 -0
- package/dist/vue.cjs +1 -336
- package/dist/vue.d.cts +1063 -0
- package/dist/vue.d.ts +1063 -2
- package/dist/vue.js +174 -316
- package/dist/widget.cjs +1 -0
- package/dist/widget.d.cts +577 -0
- package/dist/widget.d.ts +577 -2
- package/dist/widget.js +398 -0
- package/package.json +35 -24
- package/dist/AgoClient-DPZdN5n2.js +0 -905
- package/dist/AgoClient-DPZdN5n2.js.map +0 -1
- package/dist/AgoClient-wMVUQqCD.cjs +0 -976
- package/dist/AgoClient-wMVUQqCD.cjs.map +0 -1
- package/dist/angular/ago.service.d.ts +0 -98
- package/dist/angular/index.d.ts +0 -4
- package/dist/angular/provide.d.ts +0 -27
- package/dist/angular.cjs.map +0 -1
- package/dist/angular.js.map +0 -1
- package/dist/api/HttpClient.d.ts +0 -31
- package/dist/api/index.d.ts +0 -1
- package/dist/auto/createAgo.d.ts +0 -39
- package/dist/auto/index.d.ts +0 -1
- package/dist/client/AgoClient.d.ts +0 -169
- package/dist/client/errors.d.ts +0 -48
- package/dist/client/index.d.ts +0 -3
- package/dist/client/types.d.ts +0 -205
- package/dist/createMockClient-Ci_N2tH8.cjs +0 -104
- package/dist/createMockClient-Ci_N2tH8.cjs.map +0 -1
- package/dist/createMockClient-U0ae_AYy.js +0 -99
- package/dist/createMockClient-U0ae_AYy.js.map +0 -1
- package/dist/devtools/index.d.ts +0 -2
- package/dist/devtools/initDevPanel.d.ts +0 -15
- package/dist/devtools.cjs.map +0 -1
- package/dist/devtools.js.map +0 -1
- package/dist/functions/FunctionRegistry.d.ts +0 -41
- package/dist/functions/defineFunction.d.ts +0 -22
- package/dist/functions/index.d.ts +0 -2
- package/dist/functions/types.d.ts +0 -50
- package/dist/functions--c6lx3ic.cjs +0 -480
- package/dist/functions--c6lx3ic.cjs.map +0 -1
- package/dist/functions-C9F1dnmh.js +0 -398
- package/dist/functions-C9F1dnmh.js.map +0 -1
- package/dist/helpers/factory.d.ts +0 -20
- package/dist/helpers/index.d.ts +0 -1
- package/dist/index.cjs.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/react/components/ChatInput.d.ts +0 -12
- package/dist/react/components/ChatWidget.d.ts +0 -35
- package/dist/react/components/Markdown.d.ts +0 -12
- package/dist/react/components/Message.d.ts +0 -9
- package/dist/react/components/index.d.ts +0 -8
- package/dist/react/context/AgoContext.d.ts +0 -62
- package/dist/react/context/index.d.ts +0 -2
- package/dist/react/hooks/index.d.ts +0 -7
- package/dist/react/hooks/useAgo.d.ts +0 -14
- package/dist/react/hooks/useAgoContext.d.ts +0 -40
- package/dist/react/hooks/useAgoFunction.d.ts +0 -58
- package/dist/react/hooks/useAgoStore.d.ts +0 -17
- package/dist/react/hooks/useChat.d.ts +0 -45
- package/dist/react/hooks/useConversation.d.ts +0 -28
- package/dist/react/hooks/useMessages.d.ts +0 -26
- package/dist/react/index.d.ts +0 -24
- package/dist/react/testing.d.ts +0 -2
- package/dist/react.cjs.map +0 -1
- package/dist/react.js.map +0 -1
- package/dist/rolldown-runtime-BqCkTl7Q.cjs +0 -50
- package/dist/rolldown-runtime-CNZpIYwj.js +0 -33
- package/dist/state/ClientContextRegistry.d.ts +0 -64
- package/dist/state/createStore.d.ts +0 -30
- package/dist/streaming/SSEHandler.d.ts +0 -46
- package/dist/streaming/helpers.d.ts +0 -67
- package/dist/streaming/index.d.ts +0 -2
- package/dist/testing/createMockClient.d.ts +0 -42
- package/dist/testing/index.d.ts +0 -2
- package/dist/utils/eventEmitter.d.ts +0 -23
- package/dist/utils/index.d.ts +0 -2
- package/dist/utils/logger.d.ts +0 -14
- package/dist/vue/composables/useAgo.d.ts +0 -17
- package/dist/vue/composables/useAgoEvents.d.ts +0 -11
- package/dist/vue/composables/useAgoFunction.d.ts +0 -34
- package/dist/vue/composables/useAgoStore.d.ts +0 -18
- package/dist/vue/composables/useChat.d.ts +0 -251
- package/dist/vue/composables/useConversation.d.ts +0 -178
- package/dist/vue/composables/useMessages.d.ts +0 -89
- package/dist/vue/index.d.ts +0 -11
- package/dist/vue/plugin.d.ts +0 -16
- package/dist/vue/symbols.d.ts +0 -3
- package/dist/vue.cjs.map +0 -1
- package/dist/vue.js.map +0 -1
- package/dist/widget/index.d.ts +0 -1
- package/dist/widget/types.d.ts +0 -43
package/dist/index.cjs
CHANGED
|
@@ -1,347 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,
|
|
2
|
-
const require_AgoClient = require("./AgoClient-wMVUQqCD.cjs");
|
|
3
|
-
const require_createMockClient = require("./createMockClient-Ci_N2tH8.cjs");
|
|
4
|
-
const require_functions = require("./functions--c6lx3ic.cjs");
|
|
5
|
-
//#region src/state/createStore.ts
|
|
6
|
-
function createStore(initial, persist) {
|
|
7
|
-
const storage = persist ? persist.storage ?? (typeof localStorage !== "undefined" ? localStorage : void 0) : void 0;
|
|
8
|
-
let state = initial;
|
|
9
|
-
if (persist && storage) try {
|
|
10
|
-
const raw = storage.getItem(persist.key);
|
|
11
|
-
if (raw != null) state = JSON.parse(raw);
|
|
12
|
-
} catch {}
|
|
13
|
-
const subscribers = /* @__PURE__ */ new Set();
|
|
14
|
-
const notify = () => subscribers.forEach((fn) => fn(state));
|
|
15
|
-
function persistState() {
|
|
16
|
-
if (persist && storage) try {
|
|
17
|
-
storage.setItem(persist.key, JSON.stringify(state));
|
|
18
|
-
} catch {}
|
|
19
|
-
}
|
|
20
|
-
return {
|
|
21
|
-
get: () => state,
|
|
22
|
-
set: (next) => {
|
|
23
|
-
state = next;
|
|
24
|
-
persistState();
|
|
25
|
-
notify();
|
|
26
|
-
},
|
|
27
|
-
subscribe: (fn) => {
|
|
28
|
-
subscribers.add(fn);
|
|
29
|
-
return () => {
|
|
30
|
-
subscribers.delete(fn);
|
|
31
|
-
};
|
|
32
|
-
}
|
|
33
|
-
};
|
|
34
|
-
}
|
|
35
|
-
//#endregion
|
|
36
|
-
//#region src/functions/defineFunction.ts
|
|
37
|
-
/**
|
|
38
|
-
* Create a reusable function definition.
|
|
39
|
-
* Returns the same object — this is an identity function for discoverability and type-checking.
|
|
40
|
-
*
|
|
41
|
-
* ```ts
|
|
42
|
-
* // Define once, reuse anywhere
|
|
43
|
-
* export const lookupOrder = defineFunction({
|
|
44
|
-
* name: "lookupOrder",
|
|
45
|
-
* description: "Look up an order by ID",
|
|
46
|
-
* parameters: { type: "object", properties: { id: { type: "string" } }, required: ["id"] },
|
|
47
|
-
* handler: async (args) => fetchOrder(args.id as string),
|
|
48
|
-
* });
|
|
49
|
-
*
|
|
50
|
-
* // Register with client
|
|
51
|
-
* client.registerFunction(lookupOrder);
|
|
52
|
-
*
|
|
53
|
-
* // Or use in React
|
|
54
|
-
* useAgoFunction(lookupOrder.name, lookupOrder);
|
|
55
|
-
* ```
|
|
56
|
-
*/
|
|
57
|
-
function defineFunction(definition) {
|
|
58
|
-
return definition;
|
|
59
|
-
}
|
|
60
|
-
//#endregion
|
|
61
|
-
//#region src/streaming/helpers.ts
|
|
62
|
-
/**
|
|
63
|
-
* Subscribe to complete messages with a simple callback. Returns an unsubscribe function.
|
|
64
|
-
*
|
|
65
|
-
* ```ts
|
|
66
|
-
* const unsub = onMessage(client, (msg) => console.log(msg.content));
|
|
67
|
-
* // later: unsub();
|
|
68
|
-
* ```
|
|
69
|
-
*/
|
|
70
|
-
function onMessage(client, callback) {
|
|
71
|
-
client.on("message:complete", callback);
|
|
72
|
-
return () => client.off("message:complete", callback);
|
|
73
|
-
}
|
|
74
|
-
/**
|
|
75
|
-
* Subscribe to streaming text chunks.
|
|
76
|
-
*
|
|
77
|
-
* ```ts
|
|
78
|
-
* onMessageChunk(client, ({ content }) => {
|
|
79
|
-
* outputEl.textContent += content;
|
|
80
|
-
* });
|
|
81
|
-
* ```
|
|
82
|
-
*/
|
|
83
|
-
function onMessageChunk(client, callback) {
|
|
84
|
-
client.on("message:chunk", callback);
|
|
85
|
-
return () => client.off("message:chunk", callback);
|
|
86
|
-
}
|
|
87
|
-
/**
|
|
88
|
-
* Subscribe to message start events.
|
|
89
|
-
*/
|
|
90
|
-
function onMessageStart(client, callback) {
|
|
91
|
-
client.on("message:start", callback);
|
|
92
|
-
return () => client.off("message:start", callback);
|
|
93
|
-
}
|
|
94
|
-
/**
|
|
95
|
-
* Subscribe to message errors.
|
|
96
|
-
*/
|
|
97
|
-
function onMessageError(client, callback) {
|
|
98
|
-
client.on("message:error", callback);
|
|
99
|
-
return () => client.off("message:error", callback);
|
|
100
|
-
}
|
|
101
|
-
/**
|
|
102
|
-
* Subscribe to tool call events.
|
|
103
|
-
*/
|
|
104
|
-
function onToolCall(client, callback) {
|
|
105
|
-
client.on("toolCall:received", callback);
|
|
106
|
-
return () => client.off("toolCall:received", callback);
|
|
107
|
-
}
|
|
108
|
-
/**
|
|
109
|
-
* Subscribe to client function invocations.
|
|
110
|
-
*/
|
|
111
|
-
function onFunctionInvoke(client, callback) {
|
|
112
|
-
client.on("function:invoke", callback);
|
|
113
|
-
return () => client.off("function:invoke", callback);
|
|
114
|
-
}
|
|
115
|
-
/**
|
|
116
|
-
* Send a message and iterate over chunks as an async generator.
|
|
117
|
-
* Gives you full control over how you process the stream.
|
|
118
|
-
*
|
|
119
|
-
* ```ts
|
|
120
|
-
* for await (const chunk of createMessageStream(client, "Hello!")) {
|
|
121
|
-
* console.log(chunk.type, chunk.data);
|
|
122
|
-
* }
|
|
123
|
-
* ```
|
|
124
|
-
*/
|
|
125
|
-
async function* createMessageStream(client, content, options) {
|
|
126
|
-
const queue = [];
|
|
127
|
-
let resolve = null;
|
|
128
|
-
let done = false;
|
|
129
|
-
const push = (event) => {
|
|
130
|
-
queue.push(event);
|
|
131
|
-
resolve?.();
|
|
132
|
-
};
|
|
133
|
-
const onStart = (data) => push({
|
|
134
|
-
type: "start",
|
|
135
|
-
data
|
|
136
|
-
});
|
|
137
|
-
const onChunk = (data) => push({
|
|
138
|
-
type: "chunk",
|
|
139
|
-
data
|
|
140
|
-
});
|
|
141
|
-
const onComplete = (data) => {
|
|
142
|
-
push({
|
|
143
|
-
type: "complete",
|
|
144
|
-
data
|
|
145
|
-
});
|
|
146
|
-
done = true;
|
|
147
|
-
resolve?.();
|
|
148
|
-
};
|
|
149
|
-
const onError = (data) => {
|
|
150
|
-
push({
|
|
151
|
-
type: "error",
|
|
152
|
-
data
|
|
153
|
-
});
|
|
154
|
-
done = true;
|
|
155
|
-
resolve?.();
|
|
156
|
-
};
|
|
157
|
-
const onTool = (data) => push({
|
|
158
|
-
type: "toolCall",
|
|
159
|
-
data
|
|
160
|
-
});
|
|
161
|
-
client.on("message:start", onStart);
|
|
162
|
-
client.on("message:chunk", onChunk);
|
|
163
|
-
client.on("message:complete", onComplete);
|
|
164
|
-
client.on("message:error", onError);
|
|
165
|
-
client.on("toolCall:received", onTool);
|
|
166
|
-
client.sendMessage(content, options).catch(() => {
|
|
167
|
-
done = true;
|
|
168
|
-
resolve?.();
|
|
169
|
-
});
|
|
170
|
-
try {
|
|
171
|
-
while (!done || queue.length > 0) if (queue.length > 0) yield queue.shift();
|
|
172
|
-
else {
|
|
173
|
-
await new Promise((r) => {
|
|
174
|
-
resolve = r;
|
|
175
|
-
});
|
|
176
|
-
resolve = null;
|
|
177
|
-
}
|
|
178
|
-
} finally {
|
|
179
|
-
client.off("message:start", onStart);
|
|
180
|
-
client.off("message:chunk", onChunk);
|
|
181
|
-
client.off("message:complete", onComplete);
|
|
182
|
-
client.off("message:error", onError);
|
|
183
|
-
client.off("toolCall:received", onTool);
|
|
184
|
-
}
|
|
185
|
-
}
|
|
186
|
-
//#endregion
|
|
187
|
-
//#region src/auto/createAgo.ts
|
|
188
|
-
/**
|
|
189
|
-
* Auto-detect AGO configuration from the DOM environment.
|
|
190
|
-
*
|
|
191
|
-
* Checks (in order of priority):
|
|
192
|
-
* 1. `window.AGO` global object (widget config)
|
|
193
|
-
* 2. `<meta>` tags: `<meta name="ago-api-key" content="...">`
|
|
194
|
-
* 3. `data-ago-*` attributes on `<body>` or `<script data-ago-api-key="...">`
|
|
195
|
-
* 4. Explicit overrides passed as argument
|
|
196
|
-
*
|
|
197
|
-
* Returns null if no API key can be found.
|
|
198
|
-
*/
|
|
199
|
-
function autoDetectConfig(overrides) {
|
|
200
|
-
let baseUrl;
|
|
201
|
-
let widgetId;
|
|
202
|
-
let agent;
|
|
203
|
-
let permission;
|
|
204
|
-
let userEmail;
|
|
205
|
-
let userJwt;
|
|
206
|
-
if (typeof window !== "undefined" && window.AGO) {
|
|
207
|
-
const ago = window.AGO;
|
|
208
|
-
baseUrl = ago.basepath;
|
|
209
|
-
widgetId = ago.widgetId;
|
|
210
|
-
agent = ago.agent || ago.defaultAgent;
|
|
211
|
-
permission = ago.permission;
|
|
212
|
-
userEmail = ago.email;
|
|
213
|
-
userJwt = ago.jwt;
|
|
214
|
-
}
|
|
215
|
-
if (typeof document !== "undefined") {
|
|
216
|
-
const getMeta = (name) => document.querySelector(`meta[name="${name}"]`)?.getAttribute("content") || void 0;
|
|
217
|
-
baseUrl = baseUrl || getMeta("ago-base-url");
|
|
218
|
-
widgetId = widgetId || getMeta("ago-widget-id");
|
|
219
|
-
agent = agent || getMeta("ago-agent") || getMeta("ago-agent-id");
|
|
220
|
-
permission = permission || getMeta("ago-permission");
|
|
221
|
-
userEmail = userEmail || getMeta("ago-user-email");
|
|
222
|
-
}
|
|
223
|
-
if (typeof document !== "undefined") {
|
|
224
|
-
const sources = [document.body, ...Array.from(document.querySelectorAll("script[data-ago-base-url]"))].filter(Boolean);
|
|
225
|
-
for (const el of sources) {
|
|
226
|
-
if (!el) continue;
|
|
227
|
-
baseUrl = baseUrl || el.getAttribute("data-ago-base-url") || void 0;
|
|
228
|
-
widgetId = widgetId || el.getAttribute("data-ago-widget-id") || void 0;
|
|
229
|
-
agent = agent || el.getAttribute("data-ago-agent") || el.getAttribute("data-ago-agent-id") || void 0;
|
|
230
|
-
permission = permission || el.getAttribute("data-ago-permission") || void 0;
|
|
231
|
-
userEmail = userEmail || el.getAttribute("data-ago-user-email") || void 0;
|
|
232
|
-
}
|
|
233
|
-
}
|
|
234
|
-
baseUrl = overrides?.baseUrl || baseUrl;
|
|
235
|
-
widgetId = overrides?.widgetId || widgetId;
|
|
236
|
-
agent = overrides?.agent || overrides?.defaultAgentId || agent;
|
|
237
|
-
permission = overrides?.permission || permission;
|
|
238
|
-
userEmail = overrides?.userEmail || userEmail;
|
|
239
|
-
userJwt = overrides?.userJwt || userJwt;
|
|
240
|
-
const debug = overrides?.debug;
|
|
241
|
-
if (!baseUrl) return null;
|
|
242
|
-
return {
|
|
243
|
-
baseUrl,
|
|
244
|
-
widgetId,
|
|
245
|
-
agent,
|
|
246
|
-
permission,
|
|
247
|
-
userEmail,
|
|
248
|
-
userJwt,
|
|
249
|
-
debug
|
|
250
|
-
};
|
|
251
|
-
}
|
|
252
|
-
/**
|
|
253
|
-
* Create an AgoClient with zero configuration.
|
|
254
|
-
* Auto-detects config from window.AGO, meta tags, and data-ago-* attributes.
|
|
255
|
-
*
|
|
256
|
-
* ```html
|
|
257
|
-
* <!-- In your HTML -->
|
|
258
|
-
* <meta name="ago-base-url" content="https://YOUR-DOMAIN.useago.com">
|
|
259
|
-
*
|
|
260
|
-
* <!-- Or on a script tag -->
|
|
261
|
-
* <script src="app.js" data-ago-base-url="https://YOUR-DOMAIN.useago.com"><\/script>
|
|
262
|
-
* ```
|
|
263
|
-
*
|
|
264
|
-
* ```ts
|
|
265
|
-
* import { createAgo } from "@useago/sdk";
|
|
266
|
-
*
|
|
267
|
-
* // Zero config — picks up from DOM
|
|
268
|
-
* const client = createAgo();
|
|
269
|
-
*
|
|
270
|
-
* // Or with partial overrides
|
|
271
|
-
* const client = createAgo({ debug: true });
|
|
272
|
-
* ```
|
|
273
|
-
*
|
|
274
|
-
* Throws if no base URL can be detected.
|
|
275
|
-
*/
|
|
276
|
-
function createAgo(overrides) {
|
|
277
|
-
const config = autoDetectConfig(overrides);
|
|
278
|
-
if (!config) throw new Error("createAgo(): could not detect AGO configuration. Set window.AGO, add <meta name=\"ago-base-url\">, or pass { baseUrl } explicitly.");
|
|
279
|
-
return new require_AgoClient.AgoClient(config);
|
|
280
|
-
}
|
|
281
|
-
//#endregion
|
|
282
|
-
//#region src/helpers/factory.ts
|
|
283
|
-
/**
|
|
284
|
-
* Attach a handler to a pre-built function definition.
|
|
285
|
-
*
|
|
286
|
-
* Pre-built helpers (`showToast`, `trackEvent`, ...) ship with a no-op or
|
|
287
|
-
* console-logging default handler. Use `withHandler` to wire them up to
|
|
288
|
-
* your actual implementation without mutating the original definition.
|
|
289
|
-
*
|
|
290
|
-
* ```ts
|
|
291
|
-
* import { showToast, withHandler } from "@useago/sdk";
|
|
292
|
-
*
|
|
293
|
-
* client.register(
|
|
294
|
-
* withHandler(showToast, (args) => {
|
|
295
|
-
* myToast(args.message as string);
|
|
296
|
-
* return { shown: true };
|
|
297
|
-
* })
|
|
298
|
-
* );
|
|
299
|
-
* ```
|
|
300
|
-
*/
|
|
301
|
-
function withHandler(definition, handler) {
|
|
302
|
-
return {
|
|
303
|
-
...definition,
|
|
304
|
-
handler
|
|
305
|
-
};
|
|
306
|
-
}
|
|
307
|
-
//#endregion
|
|
308
|
-
exports.AgoApiError = require_AgoClient.AgoApiError;
|
|
309
|
-
exports.AgoClient = require_AgoClient.AgoClient;
|
|
310
|
-
exports.AgoError = require_AgoClient.AgoError;
|
|
311
|
-
exports.AgoFunctionError = require_AgoClient.AgoFunctionError;
|
|
312
|
-
exports.AgoNetworkError = require_AgoClient.AgoNetworkError;
|
|
313
|
-
exports.AgoStreamError = require_AgoClient.AgoStreamError;
|
|
314
|
-
exports.ClientContextRegistry = require_AgoClient.ClientContextRegistry;
|
|
315
|
-
exports.EventEmitter = require_AgoClient.EventEmitter;
|
|
316
|
-
exports.FunctionRegistry = require_AgoClient.FunctionRegistry;
|
|
317
|
-
exports.SSEHandler = require_AgoClient.SSEHandler;
|
|
318
|
-
exports.autoDetectConfig = autoDetectConfig;
|
|
319
|
-
exports.copyToClipboard = require_functions.copyToClipboard;
|
|
320
|
-
exports.createAgo = createAgo;
|
|
321
|
-
exports.createMessageStream = createMessageStream;
|
|
322
|
-
exports.createMockClient = require_createMockClient.createMockClient;
|
|
323
|
-
exports.createStore = createStore;
|
|
324
|
-
exports.defineFunction = defineFunction;
|
|
325
|
-
exports.getLocalStorage = require_functions.getLocalStorage;
|
|
326
|
-
exports.getUserLocation = require_functions.getUserLocation;
|
|
327
|
-
exports.highlightElement = require_functions.highlightElement;
|
|
328
|
-
exports.isStreamNetworkError = require_AgoClient.isStreamNetworkError;
|
|
329
|
-
exports.logger = require_AgoClient.logger;
|
|
330
|
-
exports.onFunctionInvoke = onFunctionInvoke;
|
|
331
|
-
exports.onMessage = onMessage;
|
|
332
|
-
exports.onMessageChunk = onMessageChunk;
|
|
333
|
-
exports.onMessageError = onMessageError;
|
|
334
|
-
exports.onMessageStart = onMessageStart;
|
|
335
|
-
exports.onToolCall = onToolCall;
|
|
336
|
-
exports.openUrl = require_functions.openUrl;
|
|
337
|
-
exports.scrollToElement = require_functions.scrollToElement;
|
|
338
|
-
exports.setLocalStorage = require_functions.setLocalStorage;
|
|
339
|
-
exports.setTheme = require_functions.setTheme;
|
|
340
|
-
exports.showConfirmDialog = require_functions.showConfirmDialog;
|
|
341
|
-
exports.showNotification = require_functions.showNotification;
|
|
342
|
-
exports.showToast = require_functions.showToast;
|
|
343
|
-
exports.submitForm = require_functions.submitForm;
|
|
344
|
-
exports.trackEvent = require_functions.trackEvent;
|
|
345
|
-
exports.withHandler = withHandler;
|
|
346
|
-
|
|
347
|
-
//# sourceMappingURL=index.cjs.map
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("./AgoClient-bjN-z2ZQ.cjs"),p=require("./createFormCollector-H4Me_2uj.cjs"),A=require("./createMockClient-DQvFFWnc.cjs"),g=require("./functions-BH1X5kas.cjs");function h(e){return e}function C(e,o){return e.on("message:complete",o),()=>e.off("message:complete",o)}function E(e,o){return e.on("message:chunk",o),()=>e.off("message:chunk",o)}function y(e,o){return e.on("message:start",o),()=>e.off("message:start",o)}function S(e,o){return e.on("message:error",o),()=>e.off("message:error",o)}function b(e,o){return e.on("toolCall:received",o),()=>e.off("toolCall:received",o)}function M(e,o){return e.on("function:invoke",o),()=>e.off("function:invoke",o)}async function*k(e,o,l){const n=[];let r=null,a=!1;const c=s=>{n.push(s),r?.()},f=s=>c({type:"start",data:s}),t=s=>c({type:"chunk",data:s}),u=s=>{c({type:"complete",data:s}),a=!0,r?.()},m=s=>{c({type:"error",data:s}),a=!0,r?.()},d=s=>c({type:"toolCall",data:s});e.on("message:start",f),e.on("message:chunk",t),e.on("message:complete",u),e.on("message:error",m),e.on("toolCall:received",d),e.sendMessage(o,l).catch(()=>{a=!0,r?.()});try{for(;!a||n.length>0;)n.length>0?yield n.shift():(await new Promise(s=>{r=s}),r=null)}finally{e.off("message:start",f),e.off("message:chunk",t),e.off("message:complete",u),e.off("message:error",m),e.off("toolCall:received",d)}}function w(e){let o,l,n,r,a,c;if(typeof window<"u"&&window.AGO){const t=window.AGO;o=t.basepath,l=t.widgetId,n=t.agent||t.defaultAgent,r=t.permission,a=t.email,c=t.jwt}if(typeof document<"u"){const t=u=>document.querySelector(`meta[name="${u}"]`)?.getAttribute("content")||void 0;o=o||t("ago-base-url"),l=l||t("ago-widget-id"),n=n||t("ago-agent")||t("ago-agent-id"),r=r||t("ago-permission"),a=a||t("ago-user-email")}if(typeof document<"u"){const t=[document.body,...Array.from(document.querySelectorAll("script[data-ago-base-url]"))].filter(Boolean);for(const u of t)u&&(o=o||u.getAttribute("data-ago-base-url")||void 0,l=l||u.getAttribute("data-ago-widget-id")||void 0,n=n||u.getAttribute("data-ago-agent")||u.getAttribute("data-ago-agent-id")||void 0,r=r||u.getAttribute("data-ago-permission")||void 0,a=a||u.getAttribute("data-ago-user-email")||void 0)}o=e?.baseUrl||o,l=e?.widgetId||l,n=e?.agent||e?.defaultAgentId||n,r=e?.permission||r,a=e?.userEmail||a,c=e?.userJwt||c;const f=e?.debug;return o?{baseUrl:o,widgetId:l,agent:n,permission:r,userEmail:a,userJwt:c,debug:f}:null}function v(e){const o=w(e);if(!o)throw new Error('createAgo(): could not detect AGO configuration. Set window.AGO, add <meta name="ago-base-url">, or pass { baseUrl } explicitly.');return new i.AgoClient(o)}function F(e,o){return{...e,handler:o}}exports.AgoApiError=i.AgoApiError;exports.AgoClient=i.AgoClient;exports.AgoError=i.AgoError;exports.AgoFunctionError=i.AgoFunctionError;exports.AgoNetworkError=i.AgoNetworkError;exports.AgoStreamError=i.AgoStreamError;exports.ClientContextRegistry=i.ClientContextRegistry;exports.EventEmitter=i.EventEmitter;exports.FunctionRegistry=i.FunctionRegistry;exports.SSEHandler=i.SSEHandler;exports.autoDetectConfig=w;exports.copyToClipboard=g.copyToClipboard;exports.createAgo=v;exports.createFormCollector=p.createFormCollector;exports.createMessageStream=k;exports.createMockClient=A.createMockClient;exports.createStore=p.createStore;exports.defineFunction=h;exports.getLocalStorage=g.getLocalStorage;exports.getUserLocation=g.getUserLocation;exports.highlightElement=g.highlightElement;exports.isStreamNetworkError=i.isStreamNetworkError;exports.logger=i.logger;exports.onFunctionInvoke=M;exports.onMessage=C;exports.onMessageChunk=E;exports.onMessageError=S;exports.onMessageStart=y;exports.onToolCall=b;exports.openUrl=g.openUrl;exports.scrollToElement=g.scrollToElement;exports.setLocalStorage=g.setLocalStorage;exports.setTheme=g.setTheme;exports.showConfirmDialog=g.showConfirmDialog;exports.showNotification=g.showNotification;exports.showToast=g.showToast;exports.submitForm=g.submitForm;exports.trackEvent=g.trackEvent;exports.withHandler=F;
|