@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
|
@@ -0,0 +1,312 @@
|
|
|
1
|
+
import { n as s } from "./rolldown-runtime-DxmricAu.js";
|
|
2
|
+
var S = /* @__PURE__ */ s({
|
|
3
|
+
copyToClipboard: () => p,
|
|
4
|
+
getLocalStorage: () => f,
|
|
5
|
+
getUserLocation: () => m,
|
|
6
|
+
highlightElement: () => g,
|
|
7
|
+
openUrl: () => l,
|
|
8
|
+
scrollToElement: () => h,
|
|
9
|
+
setLocalStorage: () => y,
|
|
10
|
+
setTheme: () => d,
|
|
11
|
+
showConfirmDialog: () => u,
|
|
12
|
+
showNotification: () => c,
|
|
13
|
+
showToast: () => a,
|
|
14
|
+
submitForm: () => v,
|
|
15
|
+
trackEvent: () => b
|
|
16
|
+
}), a = {
|
|
17
|
+
name: "showToast",
|
|
18
|
+
description: "Show a toast notification to the user. Use this to confirm actions or display brief messages.",
|
|
19
|
+
parameters: {
|
|
20
|
+
type: "object",
|
|
21
|
+
properties: {
|
|
22
|
+
message: {
|
|
23
|
+
type: "string",
|
|
24
|
+
description: "The message to display"
|
|
25
|
+
},
|
|
26
|
+
type: {
|
|
27
|
+
type: "string",
|
|
28
|
+
description: "Toast type",
|
|
29
|
+
enum: [
|
|
30
|
+
"success",
|
|
31
|
+
"error",
|
|
32
|
+
"warning",
|
|
33
|
+
"info"
|
|
34
|
+
]
|
|
35
|
+
},
|
|
36
|
+
duration: {
|
|
37
|
+
type: "number",
|
|
38
|
+
description: "Duration in milliseconds (default 3000)"
|
|
39
|
+
}
|
|
40
|
+
},
|
|
41
|
+
required: ["message"]
|
|
42
|
+
},
|
|
43
|
+
handler: async () => ({
|
|
44
|
+
shown: !1,
|
|
45
|
+
error: "No toast handler configured"
|
|
46
|
+
})
|
|
47
|
+
}, c = {
|
|
48
|
+
name: "showNotification",
|
|
49
|
+
description: "Show a browser notification to the user. Useful for important alerts even when the tab is not focused.",
|
|
50
|
+
parameters: {
|
|
51
|
+
type: "object",
|
|
52
|
+
properties: {
|
|
53
|
+
title: {
|
|
54
|
+
type: "string",
|
|
55
|
+
description: "Notification title"
|
|
56
|
+
},
|
|
57
|
+
body: {
|
|
58
|
+
type: "string",
|
|
59
|
+
description: "Notification body text"
|
|
60
|
+
}
|
|
61
|
+
},
|
|
62
|
+
required: ["title"]
|
|
63
|
+
},
|
|
64
|
+
handler: async (e) => typeof Notification > "u" ? {
|
|
65
|
+
shown: !1,
|
|
66
|
+
error: "Notifications not supported"
|
|
67
|
+
} : Notification.permission === "denied" ? {
|
|
68
|
+
shown: !1,
|
|
69
|
+
error: "Notification permission denied"
|
|
70
|
+
} : (Notification.permission !== "granted" && await Notification.requestPermission(), Notification.permission === "granted" ? (new Notification(e.title, { body: e.body }), { shown: !0 }) : {
|
|
71
|
+
shown: !1,
|
|
72
|
+
error: "Permission not granted"
|
|
73
|
+
})
|
|
74
|
+
}, l = {
|
|
75
|
+
name: "openUrl",
|
|
76
|
+
description: "Open a URL in a new browser tab.",
|
|
77
|
+
parameters: {
|
|
78
|
+
type: "object",
|
|
79
|
+
properties: { url: {
|
|
80
|
+
type: "string",
|
|
81
|
+
description: "The URL to open"
|
|
82
|
+
} },
|
|
83
|
+
required: ["url"]
|
|
84
|
+
},
|
|
85
|
+
handler: async (e) => (window.open(e.url, "_blank", "noopener,noreferrer"), { opened: !0 })
|
|
86
|
+
}, p = {
|
|
87
|
+
name: "copyToClipboard",
|
|
88
|
+
description: "Copy text to the user's clipboard.",
|
|
89
|
+
parameters: {
|
|
90
|
+
type: "object",
|
|
91
|
+
properties: { text: {
|
|
92
|
+
type: "string",
|
|
93
|
+
description: "The text to copy"
|
|
94
|
+
} },
|
|
95
|
+
required: ["text"]
|
|
96
|
+
},
|
|
97
|
+
handler: async (e) => (await navigator.clipboard.writeText(e.text), { copied: !0 })
|
|
98
|
+
}, d = {
|
|
99
|
+
name: "setTheme",
|
|
100
|
+
description: "Change the application's color theme. Sets a data-theme attribute on the document element.",
|
|
101
|
+
parameters: {
|
|
102
|
+
type: "object",
|
|
103
|
+
properties: { theme: {
|
|
104
|
+
type: "string",
|
|
105
|
+
description: "Theme to apply",
|
|
106
|
+
enum: [
|
|
107
|
+
"light",
|
|
108
|
+
"dark",
|
|
109
|
+
"system"
|
|
110
|
+
]
|
|
111
|
+
} },
|
|
112
|
+
required: ["theme"]
|
|
113
|
+
},
|
|
114
|
+
handler: async (e) => {
|
|
115
|
+
const t = e.theme;
|
|
116
|
+
return document.documentElement.setAttribute("data-theme", t), t === "dark" ? document.documentElement.classList.add("dark") : document.documentElement.classList.remove("dark"), {
|
|
117
|
+
theme: t,
|
|
118
|
+
applied: !0
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
}, u = {
|
|
122
|
+
name: "showConfirmDialog",
|
|
123
|
+
description: "Show a confirmation dialog to the user and return their choice (true/false).",
|
|
124
|
+
parameters: {
|
|
125
|
+
type: "object",
|
|
126
|
+
properties: { message: {
|
|
127
|
+
type: "string",
|
|
128
|
+
description: "The confirmation message to display"
|
|
129
|
+
} },
|
|
130
|
+
required: ["message"]
|
|
131
|
+
},
|
|
132
|
+
handler: async (e) => ({ confirmed: window.confirm(e.message) })
|
|
133
|
+
}, m = {
|
|
134
|
+
name: "getUserLocation",
|
|
135
|
+
description: "Get the user's current geographic location (requires permission).",
|
|
136
|
+
parameters: {
|
|
137
|
+
type: "object",
|
|
138
|
+
properties: {}
|
|
139
|
+
},
|
|
140
|
+
handler: async () => navigator.geolocation ? new Promise((e) => {
|
|
141
|
+
navigator.geolocation.getCurrentPosition((t) => e({
|
|
142
|
+
latitude: t.coords.latitude,
|
|
143
|
+
longitude: t.coords.longitude,
|
|
144
|
+
accuracy: t.coords.accuracy
|
|
145
|
+
}), (t) => e({ error: t.message }));
|
|
146
|
+
}) : { error: "Geolocation not supported" }
|
|
147
|
+
}, h = {
|
|
148
|
+
name: "scrollToElement",
|
|
149
|
+
description: "Scroll the page to a specific element identified by CSS selector.",
|
|
150
|
+
parameters: {
|
|
151
|
+
type: "object",
|
|
152
|
+
properties: {
|
|
153
|
+
selector: {
|
|
154
|
+
type: "string",
|
|
155
|
+
description: "CSS selector of the element to scroll to (e.g. '#section-pricing')"
|
|
156
|
+
},
|
|
157
|
+
behavior: {
|
|
158
|
+
type: "string",
|
|
159
|
+
description: "Scroll behavior",
|
|
160
|
+
enum: ["smooth", "instant"]
|
|
161
|
+
}
|
|
162
|
+
},
|
|
163
|
+
required: ["selector"]
|
|
164
|
+
},
|
|
165
|
+
handler: async (e) => {
|
|
166
|
+
const t = document.querySelector(e.selector);
|
|
167
|
+
return t ? (t.scrollIntoView({ behavior: e.behavior || "smooth" }), { scrolled: !0 }) : {
|
|
168
|
+
scrolled: !1,
|
|
169
|
+
error: `Element not found: ${e.selector}`
|
|
170
|
+
};
|
|
171
|
+
}
|
|
172
|
+
}, y = {
|
|
173
|
+
name: "setLocalStorage",
|
|
174
|
+
description: "Store a value in the browser's localStorage.",
|
|
175
|
+
parameters: {
|
|
176
|
+
type: "object",
|
|
177
|
+
properties: {
|
|
178
|
+
key: {
|
|
179
|
+
type: "string",
|
|
180
|
+
description: "Storage key"
|
|
181
|
+
},
|
|
182
|
+
value: {
|
|
183
|
+
type: "string",
|
|
184
|
+
description: "Value to store"
|
|
185
|
+
}
|
|
186
|
+
},
|
|
187
|
+
required: ["key", "value"]
|
|
188
|
+
},
|
|
189
|
+
handler: async (e) => (localStorage.setItem(e.key, e.value), { stored: !0 })
|
|
190
|
+
}, f = {
|
|
191
|
+
name: "getLocalStorage",
|
|
192
|
+
description: "Retrieve a value from the browser's localStorage.",
|
|
193
|
+
parameters: {
|
|
194
|
+
type: "object",
|
|
195
|
+
properties: { key: {
|
|
196
|
+
type: "string",
|
|
197
|
+
description: "Storage key"
|
|
198
|
+
} },
|
|
199
|
+
required: ["key"]
|
|
200
|
+
},
|
|
201
|
+
handler: async (e) => {
|
|
202
|
+
const t = localStorage.getItem(e.key);
|
|
203
|
+
return {
|
|
204
|
+
key: e.key,
|
|
205
|
+
value: t,
|
|
206
|
+
found: t !== null
|
|
207
|
+
};
|
|
208
|
+
}
|
|
209
|
+
}, g = {
|
|
210
|
+
name: "highlightElement",
|
|
211
|
+
description: "Highlight a DOM element to draw the user's attention (e.g. for onboarding).",
|
|
212
|
+
parameters: {
|
|
213
|
+
type: "object",
|
|
214
|
+
properties: {
|
|
215
|
+
selector: {
|
|
216
|
+
type: "string",
|
|
217
|
+
description: "CSS selector of the element to highlight"
|
|
218
|
+
},
|
|
219
|
+
color: {
|
|
220
|
+
type: "string",
|
|
221
|
+
description: "Highlight border color (default: #3b82f6)"
|
|
222
|
+
}
|
|
223
|
+
},
|
|
224
|
+
required: ["selector"]
|
|
225
|
+
},
|
|
226
|
+
handler: async (e) => {
|
|
227
|
+
const t = document.querySelector(e.selector);
|
|
228
|
+
if (!t) return {
|
|
229
|
+
highlighted: !1,
|
|
230
|
+
error: `Element not found: ${e.selector}`
|
|
231
|
+
};
|
|
232
|
+
const r = t.style.outline, o = e.color || "#3b82f6";
|
|
233
|
+
return t.style.outline = `3px solid ${o}`, t.style.outlineOffset = "2px", t.scrollIntoView({
|
|
234
|
+
behavior: "smooth",
|
|
235
|
+
block: "center"
|
|
236
|
+
}), setTimeout(() => {
|
|
237
|
+
t.style.outline = r, t.style.outlineOffset = "";
|
|
238
|
+
}, 3e3), { highlighted: !0 };
|
|
239
|
+
}
|
|
240
|
+
}, v = {
|
|
241
|
+
name: "submitForm",
|
|
242
|
+
description: "Fill and submit an HTML form on the page. Pass field values as key-value pairs.",
|
|
243
|
+
parameters: {
|
|
244
|
+
type: "object",
|
|
245
|
+
properties: {
|
|
246
|
+
selector: {
|
|
247
|
+
type: "string",
|
|
248
|
+
description: "CSS selector of the form element"
|
|
249
|
+
},
|
|
250
|
+
values: {
|
|
251
|
+
type: "string",
|
|
252
|
+
description: "JSON string of field name → value pairs"
|
|
253
|
+
}
|
|
254
|
+
},
|
|
255
|
+
required: ["selector"]
|
|
256
|
+
},
|
|
257
|
+
handler: async (e) => {
|
|
258
|
+
const t = document.querySelector(e.selector);
|
|
259
|
+
if (!t) return {
|
|
260
|
+
submitted: !1,
|
|
261
|
+
error: `Form not found: ${e.selector}`
|
|
262
|
+
};
|
|
263
|
+
if (e.values) {
|
|
264
|
+
const r = JSON.parse(e.values);
|
|
265
|
+
for (const [o, n] of Object.entries(r)) {
|
|
266
|
+
const i = t.elements.namedItem(o);
|
|
267
|
+
i && (i.value = n);
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
return t.requestSubmit(), { submitted: !0 };
|
|
271
|
+
}
|
|
272
|
+
}, b = {
|
|
273
|
+
name: "trackEvent",
|
|
274
|
+
description: "Track a custom analytics event. Override the handler to wire up your analytics provider.",
|
|
275
|
+
parameters: {
|
|
276
|
+
type: "object",
|
|
277
|
+
properties: {
|
|
278
|
+
event: {
|
|
279
|
+
type: "string",
|
|
280
|
+
description: "Event name"
|
|
281
|
+
},
|
|
282
|
+
properties: {
|
|
283
|
+
type: "string",
|
|
284
|
+
description: "JSON string of event properties"
|
|
285
|
+
}
|
|
286
|
+
},
|
|
287
|
+
required: ["event"]
|
|
288
|
+
},
|
|
289
|
+
handler: async (e) => {
|
|
290
|
+
const t = e.properties ? JSON.parse(e.properties) : {};
|
|
291
|
+
return console.log(`[AGO Analytics] ${e.event}`, t), {
|
|
292
|
+
tracked: !0,
|
|
293
|
+
event: e.event
|
|
294
|
+
};
|
|
295
|
+
}
|
|
296
|
+
};
|
|
297
|
+
export {
|
|
298
|
+
g as a,
|
|
299
|
+
y as c,
|
|
300
|
+
c as d,
|
|
301
|
+
a as f,
|
|
302
|
+
m as i,
|
|
303
|
+
d as l,
|
|
304
|
+
b as m,
|
|
305
|
+
S as n,
|
|
306
|
+
l as o,
|
|
307
|
+
v as p,
|
|
308
|
+
f as r,
|
|
309
|
+
h as s,
|
|
310
|
+
p as t,
|
|
311
|
+
u
|
|
312
|
+
};
|
package/dist/helpers.cjs
CHANGED
|
@@ -1,15 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,
|
|
2
|
-
const require_functions = require("./functions--c6lx3ic.cjs");
|
|
3
|
-
exports.copyToClipboard = require_functions.copyToClipboard;
|
|
4
|
-
exports.getLocalStorage = require_functions.getLocalStorage;
|
|
5
|
-
exports.getUserLocation = require_functions.getUserLocation;
|
|
6
|
-
exports.highlightElement = require_functions.highlightElement;
|
|
7
|
-
exports.openUrl = require_functions.openUrl;
|
|
8
|
-
exports.scrollToElement = require_functions.scrollToElement;
|
|
9
|
-
exports.setLocalStorage = require_functions.setLocalStorage;
|
|
10
|
-
exports.setTheme = require_functions.setTheme;
|
|
11
|
-
exports.showConfirmDialog = require_functions.showConfirmDialog;
|
|
12
|
-
exports.showNotification = require_functions.showNotification;
|
|
13
|
-
exports.showToast = require_functions.showToast;
|
|
14
|
-
exports.submitForm = require_functions.submitForm;
|
|
15
|
-
exports.trackEvent = require_functions.trackEvent;
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("./functions-BH1X5kas.cjs");exports.copyToClipboard=o.copyToClipboard;exports.getLocalStorage=o.getLocalStorage;exports.getUserLocation=o.getUserLocation;exports.highlightElement=o.highlightElement;exports.openUrl=o.openUrl;exports.scrollToElement=o.scrollToElement;exports.setLocalStorage=o.setLocalStorage;exports.setTheme=o.setTheme;exports.showConfirmDialog=o.showConfirmDialog;exports.showNotification=o.showNotification;exports.showToast=o.showToast;exports.submitForm=o.submitForm;exports.trackEvent=o.trackEvent;
|
|
@@ -1,62 +1,121 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
*
|
|
23
|
-
*/
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
*
|
|
28
|
-
*/
|
|
29
|
-
|
|
30
|
-
/**
|
|
31
|
-
|
|
32
|
-
*/
|
|
33
|
-
|
|
34
|
-
/**
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Single-object function definition — combines name, schema, and handler.
|
|
3
|
+
*
|
|
4
|
+
* ```ts
|
|
5
|
+
* const fn = defineFunction({
|
|
6
|
+
* name: "lookupOrder",
|
|
7
|
+
* description: "Look up an order by ID",
|
|
8
|
+
* parameters: { type: "object", properties: { id: { type: "string" } }, required: ["id"] },
|
|
9
|
+
* handler: async (args) => fetchOrder(args.id as string),
|
|
10
|
+
* });
|
|
11
|
+
* client.registerFunction(fn);
|
|
12
|
+
* ```
|
|
13
|
+
*/
|
|
14
|
+
declare interface ClientFunctionDefinition {
|
|
15
|
+
name: string;
|
|
16
|
+
description: string;
|
|
17
|
+
parameters: ClientFunctionSchema["parameters"];
|
|
18
|
+
handler: ClientFunctionHandler;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Function handler type
|
|
23
|
+
*/
|
|
24
|
+
declare type ClientFunctionHandler = (args: Record<string, unknown>) => Promise<unknown> | unknown;
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Schema for a client-side function that AGO can call
|
|
28
|
+
*/
|
|
29
|
+
declare interface ClientFunctionSchema {
|
|
30
|
+
/** Function name (must be unique) */
|
|
31
|
+
name: string;
|
|
32
|
+
/** Description for the LLM to understand when to call this function */
|
|
33
|
+
description: string;
|
|
34
|
+
/** JSON Schema for function parameters */
|
|
35
|
+
parameters: {
|
|
36
|
+
type: "object";
|
|
37
|
+
properties: Record<string, {
|
|
38
|
+
type: string;
|
|
39
|
+
description?: string;
|
|
40
|
+
enum?: string[];
|
|
41
|
+
default?: unknown;
|
|
42
|
+
}>;
|
|
43
|
+
required?: string[];
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Copy text to clipboard.
|
|
49
|
+
*/
|
|
50
|
+
export declare const copyToClipboard: ClientFunctionDefinition;
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Get a value from localStorage.
|
|
54
|
+
*/
|
|
55
|
+
export declare const getLocalStorage: ClientFunctionDefinition;
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Get the user's geolocation.
|
|
59
|
+
*/
|
|
60
|
+
export declare const getUserLocation: ClientFunctionDefinition;
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Highlight an element on the page (useful for guided tours).
|
|
64
|
+
*/
|
|
65
|
+
export declare const highlightElement: ClientFunctionDefinition;
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Open a URL in a new tab.
|
|
69
|
+
*/
|
|
70
|
+
export declare const openUrl: ClientFunctionDefinition;
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* Scroll to an element on the page.
|
|
74
|
+
*/
|
|
75
|
+
export declare const scrollToElement: ClientFunctionDefinition;
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* Set a value in localStorage.
|
|
79
|
+
*/
|
|
80
|
+
export declare const setLocalStorage: ClientFunctionDefinition;
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* Set the application theme (light/dark/system).
|
|
84
|
+
* Default handler toggles a `data-theme` attribute on `<html>`.
|
|
85
|
+
*/
|
|
86
|
+
export declare const setTheme: ClientFunctionDefinition;
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* Show a confirm dialog and return the user's choice.
|
|
90
|
+
*/
|
|
91
|
+
export declare const showConfirmDialog: ClientFunctionDefinition;
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* Show a browser notification (requires permission).
|
|
95
|
+
*/
|
|
96
|
+
export declare const showNotification: ClientFunctionDefinition;
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* Show a toast/notification to the user.
|
|
100
|
+
* The handler is a no-op by default — wire it up to your toast library.
|
|
101
|
+
*
|
|
102
|
+
* ```ts
|
|
103
|
+
* import { showToast } from "@useago/sdk/helpers";
|
|
104
|
+
* showToast.handler = async (args) => { myToast(args.message); return { shown: true }; };
|
|
105
|
+
* client.registerFunction(showToast);
|
|
106
|
+
* ```
|
|
107
|
+
*/
|
|
108
|
+
export declare const showToast: ClientFunctionDefinition;
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* Submit a form on the page programmatically.
|
|
112
|
+
*/
|
|
113
|
+
export declare const submitForm: ClientFunctionDefinition;
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* Track a custom analytics event.
|
|
117
|
+
* Default handler logs to console — replace with your analytics provider.
|
|
118
|
+
*/
|
|
119
|
+
export declare const trackEvent: ClientFunctionDefinition;
|
|
120
|
+
|
|
121
|
+
export { }
|
package/dist/helpers.d.ts
CHANGED
|
@@ -1,2 +1,121 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Single-object function definition — combines name, schema, and handler.
|
|
3
|
+
*
|
|
4
|
+
* ```ts
|
|
5
|
+
* const fn = defineFunction({
|
|
6
|
+
* name: "lookupOrder",
|
|
7
|
+
* description: "Look up an order by ID",
|
|
8
|
+
* parameters: { type: "object", properties: { id: { type: "string" } }, required: ["id"] },
|
|
9
|
+
* handler: async (args) => fetchOrder(args.id as string),
|
|
10
|
+
* });
|
|
11
|
+
* client.registerFunction(fn);
|
|
12
|
+
* ```
|
|
13
|
+
*/
|
|
14
|
+
declare interface ClientFunctionDefinition {
|
|
15
|
+
name: string;
|
|
16
|
+
description: string;
|
|
17
|
+
parameters: ClientFunctionSchema["parameters"];
|
|
18
|
+
handler: ClientFunctionHandler;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Function handler type
|
|
23
|
+
*/
|
|
24
|
+
declare type ClientFunctionHandler = (args: Record<string, unknown>) => Promise<unknown> | unknown;
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Schema for a client-side function that AGO can call
|
|
28
|
+
*/
|
|
29
|
+
declare interface ClientFunctionSchema {
|
|
30
|
+
/** Function name (must be unique) */
|
|
31
|
+
name: string;
|
|
32
|
+
/** Description for the LLM to understand when to call this function */
|
|
33
|
+
description: string;
|
|
34
|
+
/** JSON Schema for function parameters */
|
|
35
|
+
parameters: {
|
|
36
|
+
type: "object";
|
|
37
|
+
properties: Record<string, {
|
|
38
|
+
type: string;
|
|
39
|
+
description?: string;
|
|
40
|
+
enum?: string[];
|
|
41
|
+
default?: unknown;
|
|
42
|
+
}>;
|
|
43
|
+
required?: string[];
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Copy text to clipboard.
|
|
49
|
+
*/
|
|
50
|
+
export declare const copyToClipboard: ClientFunctionDefinition;
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Get a value from localStorage.
|
|
54
|
+
*/
|
|
55
|
+
export declare const getLocalStorage: ClientFunctionDefinition;
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Get the user's geolocation.
|
|
59
|
+
*/
|
|
60
|
+
export declare const getUserLocation: ClientFunctionDefinition;
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Highlight an element on the page (useful for guided tours).
|
|
64
|
+
*/
|
|
65
|
+
export declare const highlightElement: ClientFunctionDefinition;
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Open a URL in a new tab.
|
|
69
|
+
*/
|
|
70
|
+
export declare const openUrl: ClientFunctionDefinition;
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* Scroll to an element on the page.
|
|
74
|
+
*/
|
|
75
|
+
export declare const scrollToElement: ClientFunctionDefinition;
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* Set a value in localStorage.
|
|
79
|
+
*/
|
|
80
|
+
export declare const setLocalStorage: ClientFunctionDefinition;
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* Set the application theme (light/dark/system).
|
|
84
|
+
* Default handler toggles a `data-theme` attribute on `<html>`.
|
|
85
|
+
*/
|
|
86
|
+
export declare const setTheme: ClientFunctionDefinition;
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* Show a confirm dialog and return the user's choice.
|
|
90
|
+
*/
|
|
91
|
+
export declare const showConfirmDialog: ClientFunctionDefinition;
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* Show a browser notification (requires permission).
|
|
95
|
+
*/
|
|
96
|
+
export declare const showNotification: ClientFunctionDefinition;
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* Show a toast/notification to the user.
|
|
100
|
+
* The handler is a no-op by default — wire it up to your toast library.
|
|
101
|
+
*
|
|
102
|
+
* ```ts
|
|
103
|
+
* import { showToast } from "@useago/sdk/helpers";
|
|
104
|
+
* showToast.handler = async (args) => { myToast(args.message); return { shown: true }; };
|
|
105
|
+
* client.registerFunction(showToast);
|
|
106
|
+
* ```
|
|
107
|
+
*/
|
|
108
|
+
export declare const showToast: ClientFunctionDefinition;
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* Submit a form on the page programmatically.
|
|
112
|
+
*/
|
|
113
|
+
export declare const submitForm: ClientFunctionDefinition;
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* Track a custom analytics event.
|
|
117
|
+
* Default handler logs to console — replace with your analytics provider.
|
|
118
|
+
*/
|
|
119
|
+
export declare const trackEvent: ClientFunctionDefinition;
|
|
120
|
+
|
|
121
|
+
export { }
|
package/dist/helpers.js
CHANGED
|
@@ -1,2 +1,16 @@
|
|
|
1
|
-
import { a
|
|
2
|
-
export {
|
|
1
|
+
import { a, c as s, d as t, f as e, i as r, l as i, m as l, o as m, p as c, r as g, s as h, t as n, u as p } from "./functions-CWSRi3xv.js";
|
|
2
|
+
export {
|
|
3
|
+
n as copyToClipboard,
|
|
4
|
+
g as getLocalStorage,
|
|
5
|
+
r as getUserLocation,
|
|
6
|
+
a as highlightElement,
|
|
7
|
+
m as openUrl,
|
|
8
|
+
h as scrollToElement,
|
|
9
|
+
s as setLocalStorage,
|
|
10
|
+
i as setTheme,
|
|
11
|
+
p as showConfirmDialog,
|
|
12
|
+
t as showNotification,
|
|
13
|
+
e as showToast,
|
|
14
|
+
c as submitForm,
|
|
15
|
+
l as trackEvent
|
|
16
|
+
};
|