@useago/sdk 0.1.6 → 0.1.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (67) hide show
  1. package/dist/{createMockClient-BZKh_1em.cjs → AgoClient-BDO4avLq.cjs} +219 -124
  2. package/dist/AgoClient-BDO4avLq.cjs.map +1 -0
  3. package/dist/{createMockClient-uGlVyjbL.js → AgoClient-D-c91tx5.js} +221 -126
  4. package/dist/AgoClient-D-c91tx5.js.map +1 -0
  5. package/dist/angular/ago.service.d.ts +98 -0
  6. package/dist/angular/index.d.ts +4 -0
  7. package/dist/angular/provide.d.ts +27 -0
  8. package/dist/angular.cjs +105 -0
  9. package/dist/angular.cjs.map +1 -0
  10. package/dist/angular.d.ts +1 -0
  11. package/dist/angular.js +105 -0
  12. package/dist/angular.js.map +1 -0
  13. package/dist/auto/createAgo.d.ts +39 -0
  14. package/dist/auto/index.d.ts +1 -0
  15. package/dist/client/AgoClient.d.ts +56 -0
  16. package/dist/client/types.d.ts +4 -6
  17. package/dist/createMockClient-B1DcBiIK.js +94 -0
  18. package/dist/createMockClient-B1DcBiIK.js.map +1 -0
  19. package/dist/createMockClient-BqNSJUu4.cjs +93 -0
  20. package/dist/createMockClient-BqNSJUu4.cjs.map +1 -0
  21. package/dist/functions-B0Z0rNQW.cjs +306 -0
  22. package/dist/functions-B0Z0rNQW.cjs.map +1 -0
  23. package/dist/functions-C-wLEc8b.js +306 -0
  24. package/dist/functions-C-wLEc8b.js.map +1 -0
  25. package/dist/helpers/factory.d.ts +20 -0
  26. package/dist/helpers/functions.d.ts +62 -0
  27. package/dist/helpers/index.d.ts +1 -0
  28. package/dist/helpers.cjs +17 -0
  29. package/dist/helpers.cjs.map +1 -0
  30. package/dist/helpers.d.ts +1 -0
  31. package/dist/helpers.js +17 -0
  32. package/dist/helpers.js.map +1 -0
  33. package/dist/index.cjs +179 -12
  34. package/dist/index.cjs.map +1 -1
  35. package/dist/index.d.ts +6 -0
  36. package/dist/index.js +173 -5
  37. package/dist/index.js.map +1 -1
  38. package/dist/react/context/AgoContext.d.ts +30 -4
  39. package/dist/react/context/index.d.ts +1 -1
  40. package/dist/react/hooks/index.d.ts +1 -0
  41. package/dist/react/hooks/useAgoContext.d.ts +40 -0
  42. package/dist/react/hooks/useAgoFunction.d.ts +14 -2
  43. package/dist/react/index.d.ts +2 -1
  44. package/dist/react.cjs +76 -11
  45. package/dist/react.cjs.map +1 -1
  46. package/dist/react.js +81 -17
  47. package/dist/react.js.map +1 -1
  48. package/dist/state/ClientContextRegistry.d.ts +64 -0
  49. package/dist/streaming/helpers.d.ts +67 -0
  50. package/dist/vue/composables/useAgo.d.ts +17 -0
  51. package/dist/vue/composables/useAgoEvents.d.ts +11 -0
  52. package/dist/vue/composables/useAgoFunction.d.ts +34 -0
  53. package/dist/vue/composables/useChat.d.ts +251 -0
  54. package/dist/vue/composables/useConversation.d.ts +178 -0
  55. package/dist/vue/composables/useMessages.d.ts +89 -0
  56. package/dist/vue/index.d.ts +10 -0
  57. package/dist/vue/plugin.d.ts +16 -0
  58. package/dist/vue/symbols.d.ts +3 -0
  59. package/dist/vue.cjs +232 -0
  60. package/dist/vue.cjs.map +1 -0
  61. package/dist/vue.d.ts +1 -0
  62. package/dist/vue.js +232 -0
  63. package/dist/vue.js.map +1 -0
  64. package/dist/widget/types.d.ts +1 -0
  65. package/package.json +23 -3
  66. package/dist/createMockClient-BZKh_1em.cjs.map +0 -1
  67. package/dist/createMockClient-uGlVyjbL.js.map +0 -1
@@ -0,0 +1,306 @@
1
+ const showToast = {
2
+ name: "showToast",
3
+ description: "Show a toast notification to the user. Use this to confirm actions or display brief messages.",
4
+ parameters: {
5
+ type: "object",
6
+ properties: {
7
+ message: { type: "string", description: "The message to display" },
8
+ type: {
9
+ type: "string",
10
+ description: "Toast type",
11
+ enum: ["success", "error", "warning", "info"]
12
+ },
13
+ duration: {
14
+ type: "number",
15
+ description: "Duration in milliseconds (default 3000)"
16
+ }
17
+ },
18
+ required: ["message"]
19
+ },
20
+ handler: async () => ({ shown: false, error: "No toast handler configured" })
21
+ };
22
+ const showNotification = {
23
+ name: "showNotification",
24
+ description: "Show a browser notification to the user. Useful for important alerts even when the tab is not focused.",
25
+ parameters: {
26
+ type: "object",
27
+ properties: {
28
+ title: { type: "string", description: "Notification title" },
29
+ body: { type: "string", description: "Notification body text" }
30
+ },
31
+ required: ["title"]
32
+ },
33
+ handler: async (args) => {
34
+ if (typeof Notification === "undefined") {
35
+ return { shown: false, error: "Notifications not supported" };
36
+ }
37
+ if (Notification.permission === "denied") {
38
+ return { shown: false, error: "Notification permission denied" };
39
+ }
40
+ if (Notification.permission !== "granted") {
41
+ await Notification.requestPermission();
42
+ }
43
+ if (Notification.permission === "granted") {
44
+ new Notification(args.title, { body: args.body });
45
+ return { shown: true };
46
+ }
47
+ return { shown: false, error: "Permission not granted" };
48
+ }
49
+ };
50
+ const openUrl = {
51
+ name: "openUrl",
52
+ description: "Open a URL in a new browser tab.",
53
+ parameters: {
54
+ type: "object",
55
+ properties: {
56
+ url: { type: "string", description: "The URL to open" }
57
+ },
58
+ required: ["url"]
59
+ },
60
+ handler: async (args) => {
61
+ window.open(args.url, "_blank", "noopener,noreferrer");
62
+ return { opened: true };
63
+ }
64
+ };
65
+ const copyToClipboard = {
66
+ name: "copyToClipboard",
67
+ description: "Copy text to the user's clipboard.",
68
+ parameters: {
69
+ type: "object",
70
+ properties: {
71
+ text: { type: "string", description: "The text to copy" }
72
+ },
73
+ required: ["text"]
74
+ },
75
+ handler: async (args) => {
76
+ await navigator.clipboard.writeText(args.text);
77
+ return { copied: true };
78
+ }
79
+ };
80
+ const setTheme = {
81
+ name: "setTheme",
82
+ description: "Change the application's color theme. Sets a data-theme attribute on the document element.",
83
+ parameters: {
84
+ type: "object",
85
+ properties: {
86
+ theme: {
87
+ type: "string",
88
+ description: "Theme to apply",
89
+ enum: ["light", "dark", "system"]
90
+ }
91
+ },
92
+ required: ["theme"]
93
+ },
94
+ handler: async (args) => {
95
+ const theme = args.theme;
96
+ document.documentElement.setAttribute("data-theme", theme);
97
+ if (theme === "dark") {
98
+ document.documentElement.classList.add("dark");
99
+ } else {
100
+ document.documentElement.classList.remove("dark");
101
+ }
102
+ return { theme, applied: true };
103
+ }
104
+ };
105
+ const showConfirmDialog = {
106
+ name: "showConfirmDialog",
107
+ description: "Show a confirmation dialog to the user and return their choice (true/false).",
108
+ parameters: {
109
+ type: "object",
110
+ properties: {
111
+ message: {
112
+ type: "string",
113
+ description: "The confirmation message to display"
114
+ }
115
+ },
116
+ required: ["message"]
117
+ },
118
+ handler: async (args) => {
119
+ const confirmed = window.confirm(args.message);
120
+ return { confirmed };
121
+ }
122
+ };
123
+ const getUserLocation = {
124
+ name: "getUserLocation",
125
+ description: "Get the user's current geographic location (requires permission).",
126
+ parameters: {
127
+ type: "object",
128
+ properties: {}
129
+ },
130
+ handler: async () => {
131
+ if (!navigator.geolocation) {
132
+ return { error: "Geolocation not supported" };
133
+ }
134
+ return new Promise((resolve) => {
135
+ navigator.geolocation.getCurrentPosition(
136
+ (pos) => resolve({
137
+ latitude: pos.coords.latitude,
138
+ longitude: pos.coords.longitude,
139
+ accuracy: pos.coords.accuracy
140
+ }),
141
+ (err) => resolve({ error: err.message })
142
+ );
143
+ });
144
+ }
145
+ };
146
+ const scrollToElement = {
147
+ name: "scrollToElement",
148
+ description: "Scroll the page to a specific element identified by CSS selector.",
149
+ parameters: {
150
+ type: "object",
151
+ properties: {
152
+ selector: {
153
+ type: "string",
154
+ description: "CSS selector of the element to scroll to (e.g. '#section-pricing')"
155
+ },
156
+ behavior: {
157
+ type: "string",
158
+ description: "Scroll behavior",
159
+ enum: ["smooth", "instant"]
160
+ }
161
+ },
162
+ required: ["selector"]
163
+ },
164
+ handler: async (args) => {
165
+ const el = document.querySelector(args.selector);
166
+ if (!el) {
167
+ return { scrolled: false, error: `Element not found: ${args.selector}` };
168
+ }
169
+ el.scrollIntoView({ behavior: args.behavior || "smooth" });
170
+ return { scrolled: true };
171
+ }
172
+ };
173
+ const setLocalStorage = {
174
+ name: "setLocalStorage",
175
+ description: "Store a value in the browser's localStorage.",
176
+ parameters: {
177
+ type: "object",
178
+ properties: {
179
+ key: { type: "string", description: "Storage key" },
180
+ value: { type: "string", description: "Value to store" }
181
+ },
182
+ required: ["key", "value"]
183
+ },
184
+ handler: async (args) => {
185
+ localStorage.setItem(args.key, args.value);
186
+ return { stored: true };
187
+ }
188
+ };
189
+ const getLocalStorage = {
190
+ name: "getLocalStorage",
191
+ description: "Retrieve a value from the browser's localStorage.",
192
+ parameters: {
193
+ type: "object",
194
+ properties: {
195
+ key: { type: "string", description: "Storage key" }
196
+ },
197
+ required: ["key"]
198
+ },
199
+ handler: async (args) => {
200
+ const value = localStorage.getItem(args.key);
201
+ return { key: args.key, value, found: value !== null };
202
+ }
203
+ };
204
+ const highlightElement = {
205
+ name: "highlightElement",
206
+ description: "Highlight a DOM element to draw the user's attention (e.g. for onboarding).",
207
+ parameters: {
208
+ type: "object",
209
+ properties: {
210
+ selector: {
211
+ type: "string",
212
+ description: "CSS selector of the element to highlight"
213
+ },
214
+ color: {
215
+ type: "string",
216
+ description: "Highlight border color (default: #3b82f6)"
217
+ }
218
+ },
219
+ required: ["selector"]
220
+ },
221
+ handler: async (args) => {
222
+ const el = document.querySelector(args.selector);
223
+ if (!el) {
224
+ return { highlighted: false, error: `Element not found: ${args.selector}` };
225
+ }
226
+ const prev = el.style.outline;
227
+ const color = args.color || "#3b82f6";
228
+ el.style.outline = `3px solid ${color}`;
229
+ el.style.outlineOffset = "2px";
230
+ el.scrollIntoView({ behavior: "smooth", block: "center" });
231
+ setTimeout(() => {
232
+ el.style.outline = prev;
233
+ el.style.outlineOffset = "";
234
+ }, 3e3);
235
+ return { highlighted: true };
236
+ }
237
+ };
238
+ const submitForm = {
239
+ name: "submitForm",
240
+ description: "Fill and submit an HTML form on the page. Pass field values as key-value pairs.",
241
+ parameters: {
242
+ type: "object",
243
+ properties: {
244
+ selector: {
245
+ type: "string",
246
+ description: "CSS selector of the form element"
247
+ },
248
+ values: {
249
+ type: "string",
250
+ description: "JSON string of field name → value pairs"
251
+ }
252
+ },
253
+ required: ["selector"]
254
+ },
255
+ handler: async (args) => {
256
+ const form = document.querySelector(args.selector);
257
+ if (!form) {
258
+ return { submitted: false, error: `Form not found: ${args.selector}` };
259
+ }
260
+ if (args.values) {
261
+ const values = JSON.parse(args.values);
262
+ for (const [name, value] of Object.entries(values)) {
263
+ const input = form.elements.namedItem(name);
264
+ if (input) input.value = value;
265
+ }
266
+ }
267
+ form.requestSubmit();
268
+ return { submitted: true };
269
+ }
270
+ };
271
+ const trackEvent = {
272
+ name: "trackEvent",
273
+ description: "Track a custom analytics event. Override the handler to wire up your analytics provider.",
274
+ parameters: {
275
+ type: "object",
276
+ properties: {
277
+ event: { type: "string", description: "Event name" },
278
+ properties: {
279
+ type: "string",
280
+ description: "JSON string of event properties"
281
+ }
282
+ },
283
+ required: ["event"]
284
+ },
285
+ handler: async (args) => {
286
+ const props = args.properties ? JSON.parse(args.properties) : {};
287
+ console.log(`[AGO Analytics] ${args.event}`, props);
288
+ return { tracked: true, event: args.event };
289
+ }
290
+ };
291
+ export {
292
+ copyToClipboard,
293
+ getLocalStorage,
294
+ getUserLocation,
295
+ highlightElement,
296
+ openUrl,
297
+ scrollToElement,
298
+ setLocalStorage,
299
+ setTheme,
300
+ showConfirmDialog,
301
+ showNotification,
302
+ showToast,
303
+ submitForm,
304
+ trackEvent
305
+ };
306
+ //# sourceMappingURL=functions-C-wLEc8b.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"functions-C-wLEc8b.js","sources":["../src/helpers/functions.ts"],"sourcesContent":["import type { ClientFunctionDefinition } from \"../functions/types\";\n\n/**\n * Show a toast/notification to the user.\n * The handler is a no-op by default — wire it up to your toast library.\n *\n * ```ts\n * import { showToast } from \"@useago/sdk/helpers\";\n * showToast.handler = async (args) => { myToast(args.message); return { shown: true }; };\n * client.registerFunction(showToast);\n * ```\n */\nexport const showToast: ClientFunctionDefinition = {\n name: \"showToast\",\n description:\n \"Show a toast notification to the user. Use this to confirm actions or display brief messages.\",\n parameters: {\n type: \"object\",\n properties: {\n message: { type: \"string\", description: \"The message to display\" },\n type: {\n type: \"string\",\n description: \"Toast type\",\n enum: [\"success\", \"error\", \"warning\", \"info\"],\n },\n duration: {\n type: \"number\",\n description: \"Duration in milliseconds (default 3000)\",\n },\n },\n required: [\"message\"],\n },\n handler: async () => ({ shown: false, error: \"No toast handler configured\" }),\n};\n\n/**\n * Show a browser notification (requires permission).\n */\nexport const showNotification: ClientFunctionDefinition = {\n name: \"showNotification\",\n description:\n \"Show a browser notification to the user. Useful for important alerts even when the tab is not focused.\",\n parameters: {\n type: \"object\",\n properties: {\n title: { type: \"string\", description: \"Notification title\" },\n body: { type: \"string\", description: \"Notification body text\" },\n },\n required: [\"title\"],\n },\n handler: async (args) => {\n if (typeof Notification === \"undefined\") {\n return { shown: false, error: \"Notifications not supported\" };\n }\n if (Notification.permission === \"denied\") {\n return { shown: false, error: \"Notification permission denied\" };\n }\n if (Notification.permission !== \"granted\") {\n await Notification.requestPermission();\n }\n if (Notification.permission === \"granted\") {\n new Notification(args.title as string, { body: args.body as string });\n return { shown: true };\n }\n return { shown: false, error: \"Permission not granted\" };\n },\n};\n\n/**\n * Open a URL in a new tab.\n */\nexport const openUrl: ClientFunctionDefinition = {\n name: \"openUrl\",\n description: \"Open a URL in a new browser tab.\",\n parameters: {\n type: \"object\",\n properties: {\n url: { type: \"string\", description: \"The URL to open\" },\n },\n required: [\"url\"],\n },\n handler: async (args) => {\n window.open(args.url as string, \"_blank\", \"noopener,noreferrer\");\n return { opened: true };\n },\n};\n\n/**\n * Copy text to clipboard.\n */\nexport const copyToClipboard: ClientFunctionDefinition = {\n name: \"copyToClipboard\",\n description: \"Copy text to the user's clipboard.\",\n parameters: {\n type: \"object\",\n properties: {\n text: { type: \"string\", description: \"The text to copy\" },\n },\n required: [\"text\"],\n },\n handler: async (args) => {\n await navigator.clipboard.writeText(args.text as string);\n return { copied: true };\n },\n};\n\n/**\n * Set the application theme (light/dark/system).\n * Default handler toggles a `data-theme` attribute on `<html>`.\n */\nexport const setTheme: ClientFunctionDefinition = {\n name: \"setTheme\",\n description:\n \"Change the application's color theme. Sets a data-theme attribute on the document element.\",\n parameters: {\n type: \"object\",\n properties: {\n theme: {\n type: \"string\",\n description: \"Theme to apply\",\n enum: [\"light\", \"dark\", \"system\"],\n },\n },\n required: [\"theme\"],\n },\n handler: async (args) => {\n const theme = args.theme as string;\n document.documentElement.setAttribute(\"data-theme\", theme);\n if (theme === \"dark\") {\n document.documentElement.classList.add(\"dark\");\n } else {\n document.documentElement.classList.remove(\"dark\");\n }\n return { theme, applied: true };\n },\n};\n\n/**\n * Show a confirm dialog and return the user's choice.\n */\nexport const showConfirmDialog: ClientFunctionDefinition = {\n name: \"showConfirmDialog\",\n description:\n \"Show a confirmation dialog to the user and return their choice (true/false).\",\n parameters: {\n type: \"object\",\n properties: {\n message: {\n type: \"string\",\n description: \"The confirmation message to display\",\n },\n },\n required: [\"message\"],\n },\n handler: async (args) => {\n const confirmed = window.confirm(args.message as string);\n return { confirmed };\n },\n};\n\n/**\n * Get the user's geolocation.\n */\nexport const getUserLocation: ClientFunctionDefinition = {\n name: \"getUserLocation\",\n description:\n \"Get the user's current geographic location (requires permission).\",\n parameters: {\n type: \"object\",\n properties: {},\n },\n handler: async () => {\n if (!navigator.geolocation) {\n return { error: \"Geolocation not supported\" };\n }\n return new Promise((resolve) => {\n navigator.geolocation.getCurrentPosition(\n (pos) =>\n resolve({\n latitude: pos.coords.latitude,\n longitude: pos.coords.longitude,\n accuracy: pos.coords.accuracy,\n }),\n (err) => resolve({ error: err.message })\n );\n });\n },\n};\n\n/**\n * Scroll to an element on the page.\n */\nexport const scrollToElement: ClientFunctionDefinition = {\n name: \"scrollToElement\",\n description: \"Scroll the page to a specific element identified by CSS selector.\",\n parameters: {\n type: \"object\",\n properties: {\n selector: {\n type: \"string\",\n description: \"CSS selector of the element to scroll to (e.g. '#section-pricing')\",\n },\n behavior: {\n type: \"string\",\n description: \"Scroll behavior\",\n enum: [\"smooth\", \"instant\"],\n },\n },\n required: [\"selector\"],\n },\n handler: async (args) => {\n const el = document.querySelector(args.selector as string);\n if (!el) {\n return { scrolled: false, error: `Element not found: ${args.selector}` };\n }\n el.scrollIntoView({ behavior: (args.behavior as ScrollBehavior) || \"smooth\" });\n return { scrolled: true };\n },\n};\n\n/**\n * Set a value in localStorage.\n */\nexport const setLocalStorage: ClientFunctionDefinition = {\n name: \"setLocalStorage\",\n description: \"Store a value in the browser's localStorage.\",\n parameters: {\n type: \"object\",\n properties: {\n key: { type: \"string\", description: \"Storage key\" },\n value: { type: \"string\", description: \"Value to store\" },\n },\n required: [\"key\", \"value\"],\n },\n handler: async (args) => {\n localStorage.setItem(args.key as string, args.value as string);\n return { stored: true };\n },\n};\n\n/**\n * Get a value from localStorage.\n */\nexport const getLocalStorage: ClientFunctionDefinition = {\n name: \"getLocalStorage\",\n description: \"Retrieve a value from the browser's localStorage.\",\n parameters: {\n type: \"object\",\n properties: {\n key: { type: \"string\", description: \"Storage key\" },\n },\n required: [\"key\"],\n },\n handler: async (args) => {\n const value = localStorage.getItem(args.key as string);\n return { key: args.key, value, found: value !== null };\n },\n};\n\n/**\n * Highlight an element on the page (useful for guided tours).\n */\nexport const highlightElement: ClientFunctionDefinition = {\n name: \"highlightElement\",\n description:\n \"Highlight a DOM element to draw the user's attention (e.g. for onboarding).\",\n parameters: {\n type: \"object\",\n properties: {\n selector: {\n type: \"string\",\n description: \"CSS selector of the element to highlight\",\n },\n color: {\n type: \"string\",\n description: \"Highlight border color (default: #3b82f6)\",\n },\n },\n required: [\"selector\"],\n },\n handler: async (args) => {\n const el = document.querySelector(args.selector as string) as HTMLElement | null;\n if (!el) {\n return { highlighted: false, error: `Element not found: ${args.selector}` };\n }\n const prev = el.style.outline;\n const color = (args.color as string) || \"#3b82f6\";\n el.style.outline = `3px solid ${color}`;\n el.style.outlineOffset = \"2px\";\n el.scrollIntoView({ behavior: \"smooth\", block: \"center\" });\n setTimeout(() => {\n el.style.outline = prev;\n el.style.outlineOffset = \"\";\n }, 3000);\n return { highlighted: true };\n },\n};\n\n/**\n * Submit a form on the page programmatically.\n */\nexport const submitForm: ClientFunctionDefinition = {\n name: \"submitForm\",\n description:\n \"Fill and submit an HTML form on the page. Pass field values as key-value pairs.\",\n parameters: {\n type: \"object\",\n properties: {\n selector: {\n type: \"string\",\n description: \"CSS selector of the form element\",\n },\n values: {\n type: \"string\",\n description: \"JSON string of field name → value pairs\",\n },\n },\n required: [\"selector\"],\n },\n handler: async (args) => {\n const form = document.querySelector(args.selector as string) as HTMLFormElement | null;\n if (!form) {\n return { submitted: false, error: `Form not found: ${args.selector}` };\n }\n if (args.values) {\n const values = JSON.parse(args.values as string) as Record<string, string>;\n for (const [name, value] of Object.entries(values)) {\n const input = form.elements.namedItem(name) as HTMLInputElement | null;\n if (input) input.value = value;\n }\n }\n form.requestSubmit();\n return { submitted: true };\n },\n};\n\n/**\n * Track a custom analytics event.\n * Default handler logs to console — replace with your analytics provider.\n */\nexport const trackEvent: ClientFunctionDefinition = {\n name: \"trackEvent\",\n description:\n \"Track a custom analytics event. Override the handler to wire up your analytics provider.\",\n parameters: {\n type: \"object\",\n properties: {\n event: { type: \"string\", description: \"Event name\" },\n properties: {\n type: \"string\",\n description: \"JSON string of event properties\",\n },\n },\n required: [\"event\"],\n },\n handler: async (args) => {\n const props = args.properties ? JSON.parse(args.properties as string) : {};\n console.log(`[AGO Analytics] ${args.event}`, props);\n return { tracked: true, event: args.event };\n },\n};\n"],"names":[],"mappings":"AAYO,MAAM,YAAsC;AAAA,EACjD,MAAM;AAAA,EACN,aACE;AAAA,EACF,YAAY;AAAA,IACV,MAAM;AAAA,IACN,YAAY;AAAA,MACV,SAAS,EAAE,MAAM,UAAU,aAAa,yBAAA;AAAA,MACxC,MAAM;AAAA,QACJ,MAAM;AAAA,QACN,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S,OAAO,SAAS;AACvB,UAAM,QAAQ,KAAK,aAAa,KAAK,MAAM,KAAK,UAAoB,IAAI,CAAA;AACxE,YAAQ,IAAI,mBAAmB,KAAK,KAAK,IAAI,KAAK;AAClD,WAAO,EAAE,SAAS,MAAM,OAAO,KAAK,MAAA;AAAA,EACtC;AACF;"}
@@ -0,0 +1,20 @@
1
+ import type { ClientFunctionDefinition, ClientFunctionHandler } from "../functions/types";
2
+ /**
3
+ * Attach a handler to a pre-built function definition.
4
+ *
5
+ * Pre-built helpers (`showToast`, `trackEvent`, ...) ship with a no-op or
6
+ * console-logging default handler. Use `withHandler` to wire them up to
7
+ * your actual implementation without mutating the original definition.
8
+ *
9
+ * ```ts
10
+ * import { showToast, withHandler } from "@useago/sdk";
11
+ *
12
+ * client.register(
13
+ * withHandler(showToast, (args) => {
14
+ * myToast(args.message as string);
15
+ * return { shown: true };
16
+ * })
17
+ * );
18
+ * ```
19
+ */
20
+ export declare function withHandler<T extends ClientFunctionDefinition>(definition: T, handler: ClientFunctionHandler): T;
@@ -0,0 +1,62 @@
1
+ import type { ClientFunctionDefinition } from "../functions/types";
2
+ /**
3
+ * Show a toast/notification to the user.
4
+ * The handler is a no-op by default — wire it up to your toast library.
5
+ *
6
+ * ```ts
7
+ * import { showToast } from "@useago/sdk/helpers";
8
+ * showToast.handler = async (args) => { myToast(args.message); return { shown: true }; };
9
+ * client.registerFunction(showToast);
10
+ * ```
11
+ */
12
+ export declare const showToast: ClientFunctionDefinition;
13
+ /**
14
+ * Show a browser notification (requires permission).
15
+ */
16
+ export declare const showNotification: ClientFunctionDefinition;
17
+ /**
18
+ * Open a URL in a new tab.
19
+ */
20
+ export declare const openUrl: ClientFunctionDefinition;
21
+ /**
22
+ * Copy text to clipboard.
23
+ */
24
+ export declare const copyToClipboard: ClientFunctionDefinition;
25
+ /**
26
+ * Set the application theme (light/dark/system).
27
+ * Default handler toggles a `data-theme` attribute on `<html>`.
28
+ */
29
+ export declare const setTheme: ClientFunctionDefinition;
30
+ /**
31
+ * Show a confirm dialog and return the user's choice.
32
+ */
33
+ export declare const showConfirmDialog: ClientFunctionDefinition;
34
+ /**
35
+ * Get the user's geolocation.
36
+ */
37
+ export declare const getUserLocation: ClientFunctionDefinition;
38
+ /**
39
+ * Scroll to an element on the page.
40
+ */
41
+ export declare const scrollToElement: ClientFunctionDefinition;
42
+ /**
43
+ * Set a value in localStorage.
44
+ */
45
+ export declare const setLocalStorage: ClientFunctionDefinition;
46
+ /**
47
+ * Get a value from localStorage.
48
+ */
49
+ export declare const getLocalStorage: ClientFunctionDefinition;
50
+ /**
51
+ * Highlight an element on the page (useful for guided tours).
52
+ */
53
+ export declare const highlightElement: ClientFunctionDefinition;
54
+ /**
55
+ * Submit a form on the page programmatically.
56
+ */
57
+ export declare const submitForm: ClientFunctionDefinition;
58
+ /**
59
+ * Track a custom analytics event.
60
+ * Default handler logs to console — replace with your analytics provider.
61
+ */
62
+ export declare const trackEvent: ClientFunctionDefinition;
@@ -0,0 +1 @@
1
+ export { showToast, showNotification, openUrl, copyToClipboard, setTheme, showConfirmDialog, getUserLocation, scrollToElement, setLocalStorage, getLocalStorage, highlightElement, submitForm, trackEvent, } from "./functions";
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const helpers = require("./functions-B0Z0rNQW.cjs");
4
+ exports.copyToClipboard = helpers.copyToClipboard;
5
+ exports.getLocalStorage = helpers.getLocalStorage;
6
+ exports.getUserLocation = helpers.getUserLocation;
7
+ exports.highlightElement = helpers.highlightElement;
8
+ exports.openUrl = helpers.openUrl;
9
+ exports.scrollToElement = helpers.scrollToElement;
10
+ exports.setLocalStorage = helpers.setLocalStorage;
11
+ exports.setTheme = helpers.setTheme;
12
+ exports.showConfirmDialog = helpers.showConfirmDialog;
13
+ exports.showNotification = helpers.showNotification;
14
+ exports.showToast = helpers.showToast;
15
+ exports.submitForm = helpers.submitForm;
16
+ exports.trackEvent = helpers.trackEvent;
17
+ //# sourceMappingURL=helpers.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"helpers.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;"}
@@ -0,0 +1 @@
1
+ export * from './helpers/index'
@@ -0,0 +1,17 @@
1
+ import { copyToClipboard, getLocalStorage, getUserLocation, highlightElement, openUrl, scrollToElement, setLocalStorage, setTheme, showConfirmDialog, showNotification, showToast, submitForm, trackEvent } from "./functions-C-wLEc8b.js";
2
+ export {
3
+ copyToClipboard,
4
+ getLocalStorage,
5
+ getUserLocation,
6
+ highlightElement,
7
+ openUrl,
8
+ scrollToElement,
9
+ setLocalStorage,
10
+ setTheme,
11
+ showConfirmDialog,
12
+ showNotification,
13
+ showToast,
14
+ submitForm,
15
+ trackEvent
16
+ };
17
+ //# sourceMappingURL=helpers.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"helpers.js","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
package/dist/index.cjs CHANGED
@@ -1,20 +1,187 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const createMockClient = require("./createMockClient-BZKh_1em.cjs");
3
+ const AgoClient = require("./AgoClient-BDO4avLq.cjs");
4
+ const createMockClient = require("./createMockClient-BqNSJUu4.cjs");
5
+ const helpers = require("./functions-B0Z0rNQW.cjs");
4
6
  function defineFunction(definition) {
5
7
  return definition;
6
8
  }
7
- exports.AgoApiError = createMockClient.AgoApiError;
8
- exports.AgoClient = createMockClient.AgoClient;
9
- exports.AgoError = createMockClient.AgoError;
10
- exports.AgoFunctionError = createMockClient.AgoFunctionError;
11
- exports.AgoNetworkError = createMockClient.AgoNetworkError;
12
- exports.AgoStreamError = createMockClient.AgoStreamError;
13
- exports.EventEmitter = createMockClient.EventEmitter;
14
- exports.FunctionRegistry = createMockClient.FunctionRegistry;
15
- exports.SSEHandler = createMockClient.SSEHandler;
9
+ function onMessage(client, callback) {
10
+ client.on("message:complete", callback);
11
+ return () => client.off("message:complete", callback);
12
+ }
13
+ function onMessageChunk(client, callback) {
14
+ client.on("message:chunk", callback);
15
+ return () => client.off("message:chunk", callback);
16
+ }
17
+ function onMessageStart(client, callback) {
18
+ client.on("message:start", callback);
19
+ return () => client.off("message:start", callback);
20
+ }
21
+ function onMessageError(client, callback) {
22
+ client.on("message:error", callback);
23
+ return () => client.off("message:error", callback);
24
+ }
25
+ function onToolCall(client, callback) {
26
+ client.on("toolCall:received", callback);
27
+ return () => client.off("toolCall:received", callback);
28
+ }
29
+ function onFunctionInvoke(client, callback) {
30
+ client.on("function:invoke", callback);
31
+ return () => client.off("function:invoke", callback);
32
+ }
33
+ async function* createMessageStream(client, content, options) {
34
+ const queue = [];
35
+ let resolve = null;
36
+ let done = false;
37
+ const push = (event) => {
38
+ queue.push(event);
39
+ resolve == null ? void 0 : resolve();
40
+ };
41
+ const onStart = (data) => push({ type: "start", data });
42
+ const onChunk = (data) => push({ type: "chunk", data });
43
+ const onComplete = (data) => {
44
+ push({ type: "complete", data });
45
+ done = true;
46
+ resolve == null ? void 0 : resolve();
47
+ };
48
+ const onError = (data) => {
49
+ push({ type: "error", data });
50
+ done = true;
51
+ resolve == null ? void 0 : resolve();
52
+ };
53
+ const onTool = (data) => push({ type: "toolCall", data });
54
+ client.on("message:start", onStart);
55
+ client.on("message:chunk", onChunk);
56
+ client.on("message:complete", onComplete);
57
+ client.on("message:error", onError);
58
+ client.on("toolCall:received", onTool);
59
+ client.sendMessage(content, options).catch(() => {
60
+ done = true;
61
+ resolve == null ? void 0 : resolve();
62
+ });
63
+ try {
64
+ while (!done || queue.length > 0) {
65
+ if (queue.length > 0) {
66
+ yield queue.shift();
67
+ } else {
68
+ await new Promise((r) => {
69
+ resolve = r;
70
+ });
71
+ resolve = null;
72
+ }
73
+ }
74
+ } finally {
75
+ client.off("message:start", onStart);
76
+ client.off("message:chunk", onChunk);
77
+ client.off("message:complete", onComplete);
78
+ client.off("message:error", onError);
79
+ client.off("toolCall:received", onTool);
80
+ }
81
+ }
82
+ function autoDetectConfig(overrides) {
83
+ let baseUrl;
84
+ let widgetId;
85
+ let defaultAgentId;
86
+ let userEmail;
87
+ let userJwt;
88
+ let debug;
89
+ if (typeof window !== "undefined" && window.AGO) {
90
+ const ago = window.AGO;
91
+ baseUrl = ago.basepath;
92
+ widgetId = ago.widgetId;
93
+ defaultAgentId = ago.defaultAgent;
94
+ userEmail = ago.email;
95
+ userJwt = ago.jwt;
96
+ }
97
+ if (typeof document !== "undefined") {
98
+ const getMeta = (name) => {
99
+ var _a;
100
+ return ((_a = document.querySelector(`meta[name="${name}"]`)) == null ? void 0 : _a.getAttribute("content")) || void 0;
101
+ };
102
+ baseUrl = baseUrl || getMeta("ago-base-url");
103
+ widgetId = widgetId || getMeta("ago-widget-id");
104
+ defaultAgentId = defaultAgentId || getMeta("ago-agent-id");
105
+ userEmail = userEmail || getMeta("ago-user-email");
106
+ }
107
+ if (typeof document !== "undefined") {
108
+ const sources = [
109
+ document.body,
110
+ ...Array.from(document.querySelectorAll("script[data-ago-base-url]"))
111
+ ].filter(Boolean);
112
+ for (const el of sources) {
113
+ if (!el) continue;
114
+ baseUrl = baseUrl || el.getAttribute("data-ago-base-url") || void 0;
115
+ widgetId = widgetId || el.getAttribute("data-ago-widget-id") || void 0;
116
+ defaultAgentId = defaultAgentId || el.getAttribute("data-ago-agent-id") || void 0;
117
+ userEmail = userEmail || el.getAttribute("data-ago-user-email") || void 0;
118
+ }
119
+ }
120
+ baseUrl = (overrides == null ? void 0 : overrides.baseUrl) || baseUrl;
121
+ widgetId = (overrides == null ? void 0 : overrides.widgetId) || widgetId;
122
+ defaultAgentId = (overrides == null ? void 0 : overrides.defaultAgentId) || defaultAgentId;
123
+ userEmail = (overrides == null ? void 0 : overrides.userEmail) || userEmail;
124
+ userJwt = (overrides == null ? void 0 : overrides.userJwt) || userJwt;
125
+ debug = (overrides == null ? void 0 : overrides.debug) ?? debug;
126
+ if (!baseUrl) {
127
+ return null;
128
+ }
129
+ return {
130
+ baseUrl,
131
+ widgetId,
132
+ defaultAgentId,
133
+ userEmail,
134
+ userJwt,
135
+ debug
136
+ };
137
+ }
138
+ function createAgo(overrides) {
139
+ const config = autoDetectConfig(overrides);
140
+ if (!config) {
141
+ throw new Error(
142
+ 'createAgo(): could not detect AGO configuration. Set window.AGO, add <meta name="ago-base-url">, or pass { baseUrl } explicitly.'
143
+ );
144
+ }
145
+ return new AgoClient.AgoClient(config);
146
+ }
147
+ function withHandler(definition, handler) {
148
+ return { ...definition, handler };
149
+ }
150
+ exports.AgoApiError = AgoClient.AgoApiError;
151
+ exports.AgoClient = AgoClient.AgoClient;
152
+ exports.AgoError = AgoClient.AgoError;
153
+ exports.AgoFunctionError = AgoClient.AgoFunctionError;
154
+ exports.AgoNetworkError = AgoClient.AgoNetworkError;
155
+ exports.AgoStreamError = AgoClient.AgoStreamError;
156
+ exports.ClientContextRegistry = AgoClient.ClientContextRegistry;
157
+ exports.EventEmitter = AgoClient.EventEmitter;
158
+ exports.FunctionRegistry = AgoClient.FunctionRegistry;
159
+ exports.SSEHandler = AgoClient.SSEHandler;
160
+ exports.isStreamNetworkError = AgoClient.isStreamNetworkError;
161
+ exports.logger = AgoClient.logger;
16
162
  exports.createMockClient = createMockClient.createMockClient;
17
- exports.isStreamNetworkError = createMockClient.isStreamNetworkError;
18
- exports.logger = createMockClient.logger;
163
+ exports.copyToClipboard = helpers.copyToClipboard;
164
+ exports.getLocalStorage = helpers.getLocalStorage;
165
+ exports.getUserLocation = helpers.getUserLocation;
166
+ exports.highlightElement = helpers.highlightElement;
167
+ exports.openUrl = helpers.openUrl;
168
+ exports.scrollToElement = helpers.scrollToElement;
169
+ exports.setLocalStorage = helpers.setLocalStorage;
170
+ exports.setTheme = helpers.setTheme;
171
+ exports.showConfirmDialog = helpers.showConfirmDialog;
172
+ exports.showNotification = helpers.showNotification;
173
+ exports.showToast = helpers.showToast;
174
+ exports.submitForm = helpers.submitForm;
175
+ exports.trackEvent = helpers.trackEvent;
176
+ exports.autoDetectConfig = autoDetectConfig;
177
+ exports.createAgo = createAgo;
178
+ exports.createMessageStream = createMessageStream;
19
179
  exports.defineFunction = defineFunction;
180
+ exports.onFunctionInvoke = onFunctionInvoke;
181
+ exports.onMessage = onMessage;
182
+ exports.onMessageChunk = onMessageChunk;
183
+ exports.onMessageError = onMessageError;
184
+ exports.onMessageStart = onMessageStart;
185
+ exports.onToolCall = onToolCall;
186
+ exports.withHandler = withHandler;
20
187
  //# sourceMappingURL=index.cjs.map