@useago/sdk 0.1.7 → 0.2.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.
Files changed (62) hide show
  1. package/dist/AgoClient-CNT-8sh_.js +905 -0
  2. package/dist/AgoClient-CNT-8sh_.js.map +1 -0
  3. package/dist/AgoClient-D0l1GTRs.cjs +976 -0
  4. package/dist/AgoClient-D0l1GTRs.cjs.map +1 -0
  5. package/dist/angular.cjs +138 -100
  6. package/dist/angular.cjs.map +1 -1
  7. package/dist/angular.d.ts +1 -0
  8. package/dist/angular.js +139 -103
  9. package/dist/angular.js.map +1 -1
  10. package/dist/client/types.d.ts +5 -1
  11. package/dist/createMockClient-Ci_N2tH8.cjs +104 -0
  12. package/dist/createMockClient-Ci_N2tH8.cjs.map +1 -0
  13. package/dist/createMockClient-U0ae_AYy.js +99 -0
  14. package/dist/createMockClient-U0ae_AYy.js.map +1 -0
  15. package/dist/functions--c6lx3ic.cjs +480 -0
  16. package/dist/functions--c6lx3ic.cjs.map +1 -0
  17. package/dist/functions-C9F1dnmh.js +398 -0
  18. package/dist/functions-C9F1dnmh.js.map +1 -0
  19. package/dist/helpers.cjs +14 -16
  20. package/dist/helpers.d.ts +1 -0
  21. package/dist/helpers.js +2 -17
  22. package/dist/index.cjs +281 -153
  23. package/dist/index.cjs.map +1 -1
  24. package/dist/index.js +256 -166
  25. package/dist/index.js.map +1 -1
  26. package/dist/react/components/ChatWidget.d.ts +2 -0
  27. package/dist/react/components/Markdown.d.ts +12 -0
  28. package/dist/react/components/Message.d.ts +2 -0
  29. package/dist/react/components/index.d.ts +2 -0
  30. package/dist/react/index.d.ts +2 -0
  31. package/dist/react.cjs +22099 -10333
  32. package/dist/react.cjs.map +1 -1
  33. package/dist/react.d.ts +1 -0
  34. package/dist/react.js +22099 -10349
  35. package/dist/react.js.map +1 -1
  36. package/dist/rolldown-runtime-BqCkTl7Q.cjs +50 -0
  37. package/dist/rolldown-runtime-CNZpIYwj.js +33 -0
  38. package/dist/vue.cjs +287 -208
  39. package/dist/vue.cjs.map +1 -1
  40. package/dist/vue.d.ts +1 -0
  41. package/dist/vue.js +287 -218
  42. package/dist/vue.js.map +1 -1
  43. package/dist/widget.cjs +0 -2
  44. package/dist/widget.d.ts +1 -0
  45. package/dist/widget.js +0 -2
  46. package/package.json +8 -6
  47. package/dist/AgoClient-BDO4avLq.cjs +0 -1036
  48. package/dist/AgoClient-BDO4avLq.cjs.map +0 -1
  49. package/dist/AgoClient-D-c91tx5.js +0 -1037
  50. package/dist/AgoClient-D-c91tx5.js.map +0 -1
  51. package/dist/createMockClient-B1DcBiIK.js +0 -94
  52. package/dist/createMockClient-B1DcBiIK.js.map +0 -1
  53. package/dist/createMockClient-BqNSJUu4.cjs +0 -93
  54. package/dist/createMockClient-BqNSJUu4.cjs.map +0 -1
  55. package/dist/functions-B0Z0rNQW.cjs +0 -306
  56. package/dist/functions-B0Z0rNQW.cjs.map +0 -1
  57. package/dist/functions-C-wLEc8b.js +0 -306
  58. package/dist/functions-C-wLEc8b.js.map +0 -1
  59. package/dist/helpers.cjs.map +0 -1
  60. package/dist/helpers.js.map +0 -1
  61. package/dist/widget.cjs.map +0 -1
  62. package/dist/widget.js.map +0 -1
@@ -1,306 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const showToast = {
4
- name: "showToast",
5
- description: "Show a toast notification to the user. Use this to confirm actions or display brief messages.",
6
- parameters: {
7
- type: "object",
8
- properties: {
9
- message: { type: "string", description: "The message to display" },
10
- type: {
11
- type: "string",
12
- description: "Toast type",
13
- enum: ["success", "error", "warning", "info"]
14
- },
15
- duration: {
16
- type: "number",
17
- description: "Duration in milliseconds (default 3000)"
18
- }
19
- },
20
- required: ["message"]
21
- },
22
- handler: async () => ({ shown: false, error: "No toast handler configured" })
23
- };
24
- const showNotification = {
25
- name: "showNotification",
26
- description: "Show a browser notification to the user. Useful for important alerts even when the tab is not focused.",
27
- parameters: {
28
- type: "object",
29
- properties: {
30
- title: { type: "string", description: "Notification title" },
31
- body: { type: "string", description: "Notification body text" }
32
- },
33
- required: ["title"]
34
- },
35
- handler: async (args) => {
36
- if (typeof Notification === "undefined") {
37
- return { shown: false, error: "Notifications not supported" };
38
- }
39
- if (Notification.permission === "denied") {
40
- return { shown: false, error: "Notification permission denied" };
41
- }
42
- if (Notification.permission !== "granted") {
43
- await Notification.requestPermission();
44
- }
45
- if (Notification.permission === "granted") {
46
- new Notification(args.title, { body: args.body });
47
- return { shown: true };
48
- }
49
- return { shown: false, error: "Permission not granted" };
50
- }
51
- };
52
- const openUrl = {
53
- name: "openUrl",
54
- description: "Open a URL in a new browser tab.",
55
- parameters: {
56
- type: "object",
57
- properties: {
58
- url: { type: "string", description: "The URL to open" }
59
- },
60
- required: ["url"]
61
- },
62
- handler: async (args) => {
63
- window.open(args.url, "_blank", "noopener,noreferrer");
64
- return { opened: true };
65
- }
66
- };
67
- const copyToClipboard = {
68
- name: "copyToClipboard",
69
- description: "Copy text to the user's clipboard.",
70
- parameters: {
71
- type: "object",
72
- properties: {
73
- text: { type: "string", description: "The text to copy" }
74
- },
75
- required: ["text"]
76
- },
77
- handler: async (args) => {
78
- await navigator.clipboard.writeText(args.text);
79
- return { copied: true };
80
- }
81
- };
82
- const setTheme = {
83
- name: "setTheme",
84
- description: "Change the application's color theme. Sets a data-theme attribute on the document element.",
85
- parameters: {
86
- type: "object",
87
- properties: {
88
- theme: {
89
- type: "string",
90
- description: "Theme to apply",
91
- enum: ["light", "dark", "system"]
92
- }
93
- },
94
- required: ["theme"]
95
- },
96
- handler: async (args) => {
97
- const theme = args.theme;
98
- document.documentElement.setAttribute("data-theme", theme);
99
- if (theme === "dark") {
100
- document.documentElement.classList.add("dark");
101
- } else {
102
- document.documentElement.classList.remove("dark");
103
- }
104
- return { theme, applied: true };
105
- }
106
- };
107
- const showConfirmDialog = {
108
- name: "showConfirmDialog",
109
- description: "Show a confirmation dialog to the user and return their choice (true/false).",
110
- parameters: {
111
- type: "object",
112
- properties: {
113
- message: {
114
- type: "string",
115
- description: "The confirmation message to display"
116
- }
117
- },
118
- required: ["message"]
119
- },
120
- handler: async (args) => {
121
- const confirmed = window.confirm(args.message);
122
- return { confirmed };
123
- }
124
- };
125
- const getUserLocation = {
126
- name: "getUserLocation",
127
- description: "Get the user's current geographic location (requires permission).",
128
- parameters: {
129
- type: "object",
130
- properties: {}
131
- },
132
- handler: async () => {
133
- if (!navigator.geolocation) {
134
- return { error: "Geolocation not supported" };
135
- }
136
- return new Promise((resolve) => {
137
- navigator.geolocation.getCurrentPosition(
138
- (pos) => resolve({
139
- latitude: pos.coords.latitude,
140
- longitude: pos.coords.longitude,
141
- accuracy: pos.coords.accuracy
142
- }),
143
- (err) => resolve({ error: err.message })
144
- );
145
- });
146
- }
147
- };
148
- const scrollToElement = {
149
- name: "scrollToElement",
150
- description: "Scroll the page to a specific element identified by CSS selector.",
151
- parameters: {
152
- type: "object",
153
- properties: {
154
- selector: {
155
- type: "string",
156
- description: "CSS selector of the element to scroll to (e.g. '#section-pricing')"
157
- },
158
- behavior: {
159
- type: "string",
160
- description: "Scroll behavior",
161
- enum: ["smooth", "instant"]
162
- }
163
- },
164
- required: ["selector"]
165
- },
166
- handler: async (args) => {
167
- const el = document.querySelector(args.selector);
168
- if (!el) {
169
- return { scrolled: false, error: `Element not found: ${args.selector}` };
170
- }
171
- el.scrollIntoView({ behavior: args.behavior || "smooth" });
172
- return { scrolled: true };
173
- }
174
- };
175
- const setLocalStorage = {
176
- name: "setLocalStorage",
177
- description: "Store a value in the browser's localStorage.",
178
- parameters: {
179
- type: "object",
180
- properties: {
181
- key: { type: "string", description: "Storage key" },
182
- value: { type: "string", description: "Value to store" }
183
- },
184
- required: ["key", "value"]
185
- },
186
- handler: async (args) => {
187
- localStorage.setItem(args.key, args.value);
188
- return { stored: true };
189
- }
190
- };
191
- const getLocalStorage = {
192
- name: "getLocalStorage",
193
- description: "Retrieve a value from the browser's localStorage.",
194
- parameters: {
195
- type: "object",
196
- properties: {
197
- key: { type: "string", description: "Storage key" }
198
- },
199
- required: ["key"]
200
- },
201
- handler: async (args) => {
202
- const value = localStorage.getItem(args.key);
203
- return { key: args.key, value, found: value !== null };
204
- }
205
- };
206
- const highlightElement = {
207
- name: "highlightElement",
208
- description: "Highlight a DOM element to draw the user's attention (e.g. for onboarding).",
209
- parameters: {
210
- type: "object",
211
- properties: {
212
- selector: {
213
- type: "string",
214
- description: "CSS selector of the element to highlight"
215
- },
216
- color: {
217
- type: "string",
218
- description: "Highlight border color (default: #3b82f6)"
219
- }
220
- },
221
- required: ["selector"]
222
- },
223
- handler: async (args) => {
224
- const el = document.querySelector(args.selector);
225
- if (!el) {
226
- return { highlighted: false, error: `Element not found: ${args.selector}` };
227
- }
228
- const prev = el.style.outline;
229
- const color = args.color || "#3b82f6";
230
- el.style.outline = `3px solid ${color}`;
231
- el.style.outlineOffset = "2px";
232
- el.scrollIntoView({ behavior: "smooth", block: "center" });
233
- setTimeout(() => {
234
- el.style.outline = prev;
235
- el.style.outlineOffset = "";
236
- }, 3e3);
237
- return { highlighted: true };
238
- }
239
- };
240
- const submitForm = {
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 (args) => {
258
- const form = document.querySelector(args.selector);
259
- if (!form) {
260
- return { submitted: false, error: `Form not found: ${args.selector}` };
261
- }
262
- if (args.values) {
263
- const values = JSON.parse(args.values);
264
- for (const [name, value] of Object.entries(values)) {
265
- const input = form.elements.namedItem(name);
266
- if (input) input.value = value;
267
- }
268
- }
269
- form.requestSubmit();
270
- return { submitted: true };
271
- }
272
- };
273
- const trackEvent = {
274
- name: "trackEvent",
275
- description: "Track a custom analytics event. Override the handler to wire up your analytics provider.",
276
- parameters: {
277
- type: "object",
278
- properties: {
279
- event: { type: "string", description: "Event name" },
280
- properties: {
281
- type: "string",
282
- description: "JSON string of event properties"
283
- }
284
- },
285
- required: ["event"]
286
- },
287
- handler: async (args) => {
288
- const props = args.properties ? JSON.parse(args.properties) : {};
289
- console.log(`[AGO Analytics] ${args.event}`, props);
290
- return { tracked: true, event: args.event };
291
- }
292
- };
293
- exports.copyToClipboard = copyToClipboard;
294
- exports.getLocalStorage = getLocalStorage;
295
- exports.getUserLocation = getUserLocation;
296
- exports.highlightElement = highlightElement;
297
- exports.openUrl = openUrl;
298
- exports.scrollToElement = scrollToElement;
299
- exports.setLocalStorage = setLocalStorage;
300
- exports.setTheme = setTheme;
301
- exports.showConfirmDialog = showConfirmDialog;
302
- exports.showNotification = showNotification;
303
- exports.showToast = showToast;
304
- exports.submitForm = submitForm;
305
- exports.trackEvent = trackEvent;
306
- //# sourceMappingURL=functions-B0Z0rNQW.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"functions-B0Z0rNQW.cjs","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,aAAa;AAAA,QACb,MAAM,CAAC,WAAW,SAAS,WAAW,MAAM;AAAA,MAAA;AAAA,MAE9C,UAAU;AAAA,QACR,MAAM;AAAA,QACN,aAAa;AAAA,MAAA;AAAA,IACf;AAAA,IAEF,UAAU,CAAC,SAAS;AAAA,EAAA;AAAA,EAEtB,SAAS,aAAa,EAAE,OAAO,OAAO,OAAO,8BAAA;AAC/C;AAKO,MAAM,mBAA6C;AAAA,EACxD,MAAM;AAAA,EACN,aACE;AAAA,EACF,YAAY;AAAA,IACV,MAAM;AAAA,IACN,YA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ACN,aAAa;AAAA,MAAA;AAAA,MAEf,QAAQ;AAAA,QACN,MAAM;AAAA,QACN,aAAa;AAAA,MAAA;AAAA,IACf;AAAA,IAEF,UAAU,CAAC,UAAU;AAAA,EAAA;AAAA,EAEvB,SAAS,OAAO,SAAS;AACvB,UAAM,OAAO,SAAS,cAAc,KAAK,QAAkB;AAC3D,QAAI,CAAC,MAAM;AACT,aAAO,EAAE,WAAW,OAAO,OAAO,mBAAmB,KAAK,QAAQ,GAAA;AAAA,IACpE;AACA,QAAI,KAAK,QAAQ;AACf,YAAM,SAAS,KAAK,MAAM,KAAK,MAAgB;AAC/C,iBAAW,CAAC,MAAM,KAAK,KAAK,OAAO,QAAQ,MAAM,GAAG;AAClD,cAAM,QAAQ,KAAK,SAAS,UAAU,IAAI;AAC1C,YAAI,aAAa,QAAQ;AAAA,MAC3B;AAAA,IACF;AACA,SAAK,cAAA;AACL,WAAO,EAAE,WAAW,KAAA;AAAA,EACtB;AACF;AAMO,MAAM,aAAuC;AAAA,EAClD,MAAM;AAAA,EACN,aACE;AAAA,EACF,YAAY;AAAA,IACV,MAAM;AAAA,IACN,YAAY;AAAA,MACV,OAAO,EAAE,MAAM,UAAU,aAAa,aAAA;AAAA,MACtC,YAAY;AAAA,QACV,MAAM;AAAA,QACN,aAAa;AAAA,MAAA;AAAA,IACf;AAAA,IAEF,UAAU,CAAC,OAAO;AAAA,EAAA;AAAA,EAEpB,SAAS,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;;;;;;;;;;;;;;"}
@@ -1,306 +0,0 @@
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