@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.
Files changed (121) hide show
  1. package/dist/AgoClient-DF7M2WAz.js +575 -0
  2. package/dist/AgoClient-bjN-z2ZQ.cjs +6 -0
  3. package/dist/angular.cjs +1 -143
  4. package/dist/angular.d.cts +530 -0
  5. package/dist/angular.d.ts +530 -2
  6. package/dist/angular.js +71 -139
  7. package/dist/createFormCollector-ClzHfaBd.js +185 -0
  8. package/dist/createFormCollector-H4Me_2uj.cjs +1 -0
  9. package/dist/createMockClient-C50gjV0b.js +71 -0
  10. package/dist/createMockClient-DQvFFWnc.cjs +1 -0
  11. package/dist/devtools.cjs +26 -100
  12. package/dist/devtools.d.cts +443 -0
  13. package/dist/devtools.d.ts +443 -2
  14. package/dist/devtools.js +68 -93
  15. package/dist/functions-BH1X5kas.cjs +1 -0
  16. package/dist/functions-CWSRi3xv.js +312 -0
  17. package/dist/helpers.cjs +1 -15
  18. package/dist/{helpers/functions.d.ts → helpers.d.cts} +121 -62
  19. package/dist/helpers.d.ts +121 -2
  20. package/dist/helpers.js +16 -2
  21. package/dist/index.cjs +1 -347
  22. package/dist/index.d.cts +1150 -0
  23. package/dist/index.d.ts +1150 -20
  24. package/dist/index.js +129 -298
  25. package/dist/react.cjs +31 -22438
  26. package/dist/react.d.cts +999 -0
  27. package/dist/react.d.ts +999 -2
  28. package/dist/react.js +8416 -22376
  29. package/dist/rolldown-runtime-CaekUdDJ.cjs +1 -0
  30. package/dist/rolldown-runtime-DxmricAu.js +25 -0
  31. package/dist/vue.cjs +1 -336
  32. package/dist/vue.d.cts +1063 -0
  33. package/dist/vue.d.ts +1063 -2
  34. package/dist/vue.js +174 -316
  35. package/dist/widget.cjs +1 -0
  36. package/dist/widget.d.cts +577 -0
  37. package/dist/widget.d.ts +577 -2
  38. package/dist/widget.js +398 -0
  39. package/package.json +35 -24
  40. package/dist/AgoClient-DPZdN5n2.js +0 -905
  41. package/dist/AgoClient-DPZdN5n2.js.map +0 -1
  42. package/dist/AgoClient-wMVUQqCD.cjs +0 -976
  43. package/dist/AgoClient-wMVUQqCD.cjs.map +0 -1
  44. package/dist/angular/ago.service.d.ts +0 -98
  45. package/dist/angular/index.d.ts +0 -4
  46. package/dist/angular/provide.d.ts +0 -27
  47. package/dist/angular.cjs.map +0 -1
  48. package/dist/angular.js.map +0 -1
  49. package/dist/api/HttpClient.d.ts +0 -31
  50. package/dist/api/index.d.ts +0 -1
  51. package/dist/auto/createAgo.d.ts +0 -39
  52. package/dist/auto/index.d.ts +0 -1
  53. package/dist/client/AgoClient.d.ts +0 -169
  54. package/dist/client/errors.d.ts +0 -48
  55. package/dist/client/index.d.ts +0 -3
  56. package/dist/client/types.d.ts +0 -205
  57. package/dist/createMockClient-Ci_N2tH8.cjs +0 -104
  58. package/dist/createMockClient-Ci_N2tH8.cjs.map +0 -1
  59. package/dist/createMockClient-U0ae_AYy.js +0 -99
  60. package/dist/createMockClient-U0ae_AYy.js.map +0 -1
  61. package/dist/devtools/index.d.ts +0 -2
  62. package/dist/devtools/initDevPanel.d.ts +0 -15
  63. package/dist/devtools.cjs.map +0 -1
  64. package/dist/devtools.js.map +0 -1
  65. package/dist/functions/FunctionRegistry.d.ts +0 -41
  66. package/dist/functions/defineFunction.d.ts +0 -22
  67. package/dist/functions/index.d.ts +0 -2
  68. package/dist/functions/types.d.ts +0 -50
  69. package/dist/functions--c6lx3ic.cjs +0 -480
  70. package/dist/functions--c6lx3ic.cjs.map +0 -1
  71. package/dist/functions-C9F1dnmh.js +0 -398
  72. package/dist/functions-C9F1dnmh.js.map +0 -1
  73. package/dist/helpers/factory.d.ts +0 -20
  74. package/dist/helpers/index.d.ts +0 -1
  75. package/dist/index.cjs.map +0 -1
  76. package/dist/index.js.map +0 -1
  77. package/dist/react/components/ChatInput.d.ts +0 -12
  78. package/dist/react/components/ChatWidget.d.ts +0 -35
  79. package/dist/react/components/Markdown.d.ts +0 -12
  80. package/dist/react/components/Message.d.ts +0 -9
  81. package/dist/react/components/index.d.ts +0 -8
  82. package/dist/react/context/AgoContext.d.ts +0 -62
  83. package/dist/react/context/index.d.ts +0 -2
  84. package/dist/react/hooks/index.d.ts +0 -7
  85. package/dist/react/hooks/useAgo.d.ts +0 -14
  86. package/dist/react/hooks/useAgoContext.d.ts +0 -40
  87. package/dist/react/hooks/useAgoFunction.d.ts +0 -58
  88. package/dist/react/hooks/useAgoStore.d.ts +0 -17
  89. package/dist/react/hooks/useChat.d.ts +0 -45
  90. package/dist/react/hooks/useConversation.d.ts +0 -28
  91. package/dist/react/hooks/useMessages.d.ts +0 -26
  92. package/dist/react/index.d.ts +0 -24
  93. package/dist/react/testing.d.ts +0 -2
  94. package/dist/react.cjs.map +0 -1
  95. package/dist/react.js.map +0 -1
  96. package/dist/rolldown-runtime-BqCkTl7Q.cjs +0 -50
  97. package/dist/rolldown-runtime-CNZpIYwj.js +0 -33
  98. package/dist/state/ClientContextRegistry.d.ts +0 -64
  99. package/dist/state/createStore.d.ts +0 -30
  100. package/dist/streaming/SSEHandler.d.ts +0 -46
  101. package/dist/streaming/helpers.d.ts +0 -67
  102. package/dist/streaming/index.d.ts +0 -2
  103. package/dist/testing/createMockClient.d.ts +0 -42
  104. package/dist/testing/index.d.ts +0 -2
  105. package/dist/utils/eventEmitter.d.ts +0 -23
  106. package/dist/utils/index.d.ts +0 -2
  107. package/dist/utils/logger.d.ts +0 -14
  108. package/dist/vue/composables/useAgo.d.ts +0 -17
  109. package/dist/vue/composables/useAgoEvents.d.ts +0 -11
  110. package/dist/vue/composables/useAgoFunction.d.ts +0 -34
  111. package/dist/vue/composables/useAgoStore.d.ts +0 -18
  112. package/dist/vue/composables/useChat.d.ts +0 -251
  113. package/dist/vue/composables/useConversation.d.ts +0 -178
  114. package/dist/vue/composables/useMessages.d.ts +0 -89
  115. package/dist/vue/index.d.ts +0 -11
  116. package/dist/vue/plugin.d.ts +0 -16
  117. package/dist/vue/symbols.d.ts +0 -3
  118. package/dist/vue.cjs.map +0 -1
  119. package/dist/vue.js.map +0 -1
  120. package/dist/widget/index.d.ts +0 -1
  121. package/dist/widget/types.d.ts +0 -43
@@ -0,0 +1 @@
1
+ var c=Object.create,u=Object.defineProperty,b=Object.getOwnPropertyDescriptor,O=Object.getOwnPropertyNames,i=Object.getPrototypeOf,f=Object.prototype.hasOwnProperty,v=(e,r)=>()=>(r||(e((r={exports:{}}).exports,r),e=null),r.exports),P=(e,r)=>{let t={};for(var o in e)u(t,o,{get:e[o],enumerable:!0});return r||u(t,Symbol.toStringTag,{value:"Module"}),t},g=(e,r,t,o)=>{if(r&&typeof r=="object"||typeof r=="function")for(var a=O(r),_=0,l=a.length,n;_<l;_++)n=a[_],!f.call(e,n)&&n!==t&&u(e,n,{get:(p=>r[p]).bind(null,n),enumerable:!(o=b(r,n))||o.enumerable});return e},j=(e,r,t)=>(t=e!=null?c(i(e)):{},g(r||!e||!e.__esModule?u(t,"default",{value:e,enumerable:!0}):t,e));Object.defineProperty(exports,"__commonJSMin",{enumerable:!0,get:function(){return v}});Object.defineProperty(exports,"__exportAll",{enumerable:!0,get:function(){return P}});Object.defineProperty(exports,"__toESM",{enumerable:!0,get:function(){return j}});
@@ -0,0 +1,25 @@
1
+ var v = Object.create, _ = Object.defineProperty, O = Object.getOwnPropertyDescriptor, c = Object.getOwnPropertyNames, b = Object.getPrototypeOf, s = Object.prototype.hasOwnProperty, g = (e, r) => () => (r || (e((r = { exports: {} }).exports, r), e = null), r.exports), f = (e, r) => {
2
+ let t = {};
3
+ for (var n in e)
4
+ _(t, n, {
5
+ get: e[n],
6
+ enumerable: !0
7
+ });
8
+ return r || _(t, Symbol.toStringTag, { value: "Module" }), t;
9
+ }, P = (e, r, t, n) => {
10
+ if (r && typeof r == "object" || typeof r == "function")
11
+ for (var l = c(r), p = 0, o = l.length, a; p < o; p++)
12
+ a = l[p], !s.call(e, a) && a !== t && _(e, a, {
13
+ get: ((u) => r[u]).bind(null, a),
14
+ enumerable: !(n = O(r, a)) || n.enumerable
15
+ });
16
+ return e;
17
+ }, i = (e, r, t) => (t = e != null ? v(b(e)) : {}, P(r || !e || !e.__esModule ? _(t, "default", {
18
+ value: e,
19
+ enumerable: !0
20
+ }) : t, e));
21
+ export {
22
+ f as n,
23
+ i as r,
24
+ g as t
25
+ };
package/dist/vue.cjs CHANGED
@@ -1,336 +1 @@
1
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- require("./rolldown-runtime-BqCkTl7Q.cjs");
3
- const require_AgoClient = require("./AgoClient-wMVUQqCD.cjs");
4
- let vue = require("vue");
5
- //#region src/vue/symbols.ts
6
- var AGO_CLIENT_KEY = Symbol("ago-client");
7
- //#endregion
8
- //#region src/vue/plugin.ts
9
- /**
10
- * Vue plugin that provides an AgoClient to the entire app via inject/provide.
11
- *
12
- * ```ts
13
- * import { AgoPlugin } from "@useago/sdk/vue";
14
- *
15
- * app.use(AgoPlugin, { baseUrl: "https://YOUR-DOMAIN.useago.com" });
16
- * ```
17
- */
18
- var AgoPlugin = { install(app, options) {
19
- const client = new require_AgoClient.AgoClient(options);
20
- app.provide(AGO_CLIENT_KEY, client);
21
- } };
22
- //#endregion
23
- //#region src/vue/composables/useAgo.ts
24
- /**
25
- * Get or create an AgoClient.
26
- *
27
- * - Without args: returns the client from `AgoPlugin` (throws if none).
28
- * - With config: creates a new client instance.
29
- *
30
- * ```ts
31
- * // From plugin
32
- * const client = useAgo();
33
- *
34
- * // Standalone
35
- * const client = useAgo({ baseUrl: "https://YOUR-DOMAIN.useago.com" });
36
- * ```
37
- */
38
- function useAgo(config) {
39
- if (config) return new require_AgoClient.AgoClient(config);
40
- const client = (0, vue.inject)(AGO_CLIENT_KEY);
41
- if (!client) throw new Error("useAgo(): no AgoClient found. Either pass config or install AgoPlugin.");
42
- return client;
43
- }
44
- //#endregion
45
- //#region src/vue/composables/useMessages.ts
46
- /**
47
- * Composable to manage messages in a conversation.
48
- *
49
- * ```ts
50
- * const { messages, sendMessage, isLoading } = useMessages();
51
- * ```
52
- */
53
- function useMessages(options = {}) {
54
- const client = options.client ?? useAgo();
55
- const messages = (0, vue.ref)([]);
56
- const conversationId = (0, vue.ref)(options.conversationId);
57
- const isLoading = (0, vue.ref)(false);
58
- const error = (0, vue.ref)(null);
59
- const handleStart = (data) => {
60
- if (!conversationId.value) conversationId.value = data.conversationId;
61
- };
62
- const handleChunk = (data) => {
63
- const idx = messages.value.findIndex((m) => m.id === data.messageId);
64
- if (idx >= 0) messages.value[idx] = {
65
- ...messages.value[idx],
66
- content: messages.value[idx].content + data.content
67
- };
68
- };
69
- const handleComplete = (message) => {
70
- const idx = messages.value.findIndex((m) => m.id === message.id);
71
- if (idx >= 0) messages.value[idx] = message;
72
- else messages.value.push(message);
73
- isLoading.value = false;
74
- };
75
- const handleError = (data) => {
76
- error.value = new Error(data.error);
77
- isLoading.value = false;
78
- };
79
- (0, vue.onMounted)(() => {
80
- client.on("message:start", handleStart);
81
- client.on("message:chunk", handleChunk);
82
- client.on("message:complete", handleComplete);
83
- client.on("message:error", handleError);
84
- });
85
- (0, vue.onUnmounted)(() => {
86
- client.off("message:start", handleStart);
87
- client.off("message:chunk", handleChunk);
88
- client.off("message:complete", handleComplete);
89
- client.off("message:error", handleError);
90
- });
91
- async function sendMessage(content, files) {
92
- isLoading.value = true;
93
- error.value = null;
94
- const userMsg = {
95
- id: `temp-${Date.now()}`,
96
- conversationId: conversationId.value || "",
97
- content,
98
- role: "user",
99
- status: "DONE",
100
- createdAt: /* @__PURE__ */ new Date()
101
- };
102
- const assistantMsg = {
103
- id: `temp-assistant-${Date.now()}`,
104
- conversationId: conversationId.value || "",
105
- content: "",
106
- role: "assistant",
107
- status: "IN_PROGRESS",
108
- createdAt: /* @__PURE__ */ new Date()
109
- };
110
- messages.value.push(userMsg, assistantMsg);
111
- try {
112
- const response = await client.sendMessage(content, {
113
- conversationId: conversationId.value,
114
- files
115
- });
116
- if (response.conversationId && !conversationId.value) conversationId.value = response.conversationId;
117
- messages.value = messages.value.filter((m) => !m.id.startsWith("temp-"));
118
- const updatedUser = {
119
- ...userMsg,
120
- id: userMsg.id.replace("temp-", "user-"),
121
- conversationId: response.conversationId
122
- };
123
- if (!messages.value.some((m) => m.id === response.id)) messages.value.push(updatedUser, response);
124
- else messages.value.push(updatedUser);
125
- return response;
126
- } catch (err) {
127
- error.value = err instanceof Error ? err : /* @__PURE__ */ new Error("Failed to send");
128
- isLoading.value = false;
129
- messages.value = messages.value.filter((m) => !m.id.startsWith("temp-"));
130
- return null;
131
- }
132
- }
133
- function clearMessages() {
134
- messages.value = [];
135
- conversationId.value = void 0;
136
- error.value = null;
137
- }
138
- return {
139
- messages,
140
- isLoading,
141
- error,
142
- conversationId,
143
- sendMessage,
144
- clearMessages
145
- };
146
- }
147
- //#endregion
148
- //#region src/vue/composables/useConversation.ts
149
- /**
150
- * Composable to manage conversations.
151
- *
152
- * ```ts
153
- * const { conversations, selectConversation } = useConversation();
154
- * ```
155
- */
156
- function useConversation(options = {}) {
157
- const client = options.client ?? useAgo();
158
- const autoLoad = options.autoLoad ?? true;
159
- const conversations = (0, vue.ref)([]);
160
- const currentConversation = (0, vue.ref)(null);
161
- const isLoading = (0, vue.ref)(false);
162
- const error = (0, vue.ref)(null);
163
- async function refreshConversations() {
164
- isLoading.value = true;
165
- error.value = null;
166
- try {
167
- conversations.value = await client.getConversations();
168
- } catch (err) {
169
- error.value = err instanceof Error ? err : /* @__PURE__ */ new Error("Failed to load conversations");
170
- } finally {
171
- isLoading.value = false;
172
- }
173
- }
174
- async function selectConversation(id) {
175
- isLoading.value = true;
176
- error.value = null;
177
- try {
178
- currentConversation.value = await client.getConversation(id);
179
- } catch (err) {
180
- error.value = err instanceof Error ? err : /* @__PURE__ */ new Error("Failed to load conversation");
181
- } finally {
182
- isLoading.value = false;
183
- }
184
- }
185
- function startNewConversation() {
186
- currentConversation.value = null;
187
- }
188
- (0, vue.onMounted)(() => {
189
- if (autoLoad) refreshConversations();
190
- });
191
- return {
192
- conversations,
193
- currentConversation,
194
- isLoading,
195
- error,
196
- selectConversation,
197
- startNewConversation,
198
- refreshConversations
199
- };
200
- }
201
- //#endregion
202
- //#region src/vue/composables/useChat.ts
203
- /**
204
- * All-in-one composable combining messages + conversations.
205
- *
206
- * ```ts
207
- * const { messages, sendMessage, conversations, selectConversation } = useChat();
208
- * ```
209
- */
210
- function useChat(options = {}) {
211
- const msgResult = useMessages({
212
- client: options.client,
213
- conversationId: options.conversationId
214
- });
215
- const convResult = useConversation({
216
- client: options.client,
217
- autoLoad: options.autoLoad
218
- });
219
- const error = (0, vue.computed)(() => msgResult.error.value || convResult.error.value);
220
- return {
221
- messages: msgResult.messages,
222
- isLoading: msgResult.isLoading,
223
- error,
224
- sendMessage: msgResult.sendMessage,
225
- clearMessages: msgResult.clearMessages,
226
- conversationId: msgResult.conversationId,
227
- conversations: convResult.conversations,
228
- currentConversation: convResult.currentConversation,
229
- isConversationsLoading: convResult.isLoading,
230
- selectConversation: convResult.selectConversation,
231
- startNewConversation: convResult.startNewConversation,
232
- refreshConversations: convResult.refreshConversations
233
- };
234
- }
235
- //#endregion
236
- //#region src/vue/composables/useAgoFunction.ts
237
- /**
238
- * Register a client-side function with auto-cleanup on unmount.
239
- *
240
- * ```ts
241
- * useAgoFunction("showToast", {
242
- * description: "Show a toast",
243
- * parameters: { type: "object", properties: { message: { type: "string" } } },
244
- * handler: async (args) => { toast(args.message); return { shown: true }; },
245
- * });
246
- * ```
247
- */
248
- function useAgoFunction(name, options) {
249
- const client = useAgo();
250
- (0, vue.onMounted)(() => {
251
- client.registerFunction(name, options.handler, {
252
- description: options.description,
253
- parameters: options.parameters
254
- });
255
- });
256
- (0, vue.onUnmounted)(() => {
257
- client.unregisterFunction(name);
258
- });
259
- }
260
- /**
261
- * Register navigation routes with auto-cleanup on unmount.
262
- * Works with vue-router's `useRouter().push`.
263
- *
264
- * ```ts
265
- * const router = useRouter();
266
- * useAgoNavigation((path) => router.push(path), [
267
- * { name: "dashboard", path: "/dashboard", description: "Main dashboard" },
268
- * ]);
269
- * ```
270
- */
271
- function useAgoNavigation(navigate, routes) {
272
- const client = useAgo();
273
- (0, vue.onMounted)(() => {
274
- client.registerNavigationFunction(navigate, routes);
275
- });
276
- (0, vue.onUnmounted)(() => {
277
- client.unregisterFunction("navigateToPage");
278
- });
279
- }
280
- //#endregion
281
- //#region src/vue/composables/useAgoEvents.ts
282
- /**
283
- * Subscribe to AGO client events with auto-cleanup on unmount.
284
- *
285
- * ```ts
286
- * useAgoEvents("message:complete", (msg) => {
287
- * console.log("Got message:", msg.content);
288
- * });
289
- * ```
290
- */
291
- function useAgoEvents(event, handler) {
292
- const client = useAgo();
293
- (0, vue.onMounted)(() => {
294
- client.on(event, handler);
295
- });
296
- (0, vue.onUnmounted)(() => {
297
- client.off(event, handler);
298
- });
299
- }
300
- //#endregion
301
- //#region src/vue/composables/useAgoStore.ts
302
- /**
303
- * Read a framework-agnostic AGO store (`createStore`) as a reactive Vue ref.
304
- *
305
- * The ref's `.value` updates on every `store.set(...)`. Mutate through the store,
306
- * not the ref. A `shallowRef` is used because the store replaces its value
307
- * wholesale, so deep reactivity would be wasted work.
308
- *
309
- * ```ts
310
- * const cart = createStore({ items: [] as string[] });
311
- *
312
- * // in setup():
313
- * const state = useAgoStore(cart);
314
- * // template: {{ state.items.length }}
315
- * ```
316
- */
317
- function useAgoStore(store) {
318
- const state = (0, vue.shallowRef)(store.get());
319
- (0, vue.onScopeDispose)(store.subscribe((next) => {
320
- state.value = next;
321
- }));
322
- return state;
323
- }
324
- //#endregion
325
- exports.AGO_CLIENT_KEY = AGO_CLIENT_KEY;
326
- exports.AgoPlugin = AgoPlugin;
327
- exports.useAgo = useAgo;
328
- exports.useAgoEvents = useAgoEvents;
329
- exports.useAgoFunction = useAgoFunction;
330
- exports.useAgoNavigation = useAgoNavigation;
331
- exports.useAgoStore = useAgoStore;
332
- exports.useChat = useChat;
333
- exports.useConversation = useConversation;
334
- exports.useMessages = useMessages;
335
-
336
- //# sourceMappingURL=vue.cjs.map
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const P=require("./rolldown-runtime-CaekUdDJ.cjs"),p=require("./AgoClient-bjN-z2ZQ.cjs");let t=require("vue");var I=Symbol("ago-client"),y={install(o,n){const e=new p.AgoClient(n);o.provide(I,e)}};function g(o){if(o)return new p.AgoClient(o);const n=(0,t.inject)(I);if(!n)throw new Error("useAgo(): no AgoClient found. Either pass config or install AgoPlugin.");return n}function E(o={}){const n=o.client??g(),e=(0,t.ref)([]),s=(0,t.ref)(o.conversationId),i=(0,t.ref)(!1),r=(0,t.ref)(null),c=a=>{s.value||(s.value=a.conversationId)},f=a=>{const u=e.value.findIndex(v=>v.id===a.messageId);u>=0&&(e.value[u]={...e.value[u],content:e.value[u].content+a.content})},m=a=>{const u=e.value.findIndex(v=>v.id===a.id);u>=0?e.value[u]=a:e.value.push(a),i.value=!1},C=a=>{r.value=new Error(a.error),i.value=!1};(0,t.onMounted)(()=>{n.on("message:start",c),n.on("message:chunk",f),n.on("message:complete",m),n.on("message:error",C)}),(0,t.onUnmounted)(()=>{n.off("message:start",c),n.off("message:chunk",f),n.off("message:complete",m),n.off("message:error",C)});async function d(a,u){i.value=!0,r.value=null;const v={id:`temp-${Date.now()}`,conversationId:s.value||"",content:a,role:"user",status:"DONE",createdAt:new Date},L={id:`temp-assistant-${Date.now()}`,conversationId:s.value||"",content:"",role:"assistant",status:"IN_PROGRESS",createdAt:new Date};e.value.push(v,L);try{const l=await n.sendMessage(a,{conversationId:s.value,files:u});l.conversationId&&!s.value&&(s.value=l.conversationId),e.value=e.value.filter(w=>!w.id.startsWith("temp-"));const A={...v,id:v.id.replace("temp-","user-"),conversationId:l.conversationId};return e.value.some(w=>w.id===l.id)?e.value.push(A):e.value.push(A,l),l}catch(l){return r.value=l instanceof Error?l:new Error("Failed to send"),i.value=!1,e.value=e.value.filter(A=>!A.id.startsWith("temp-")),null}}function h(){e.value=[],s.value=void 0,r.value=null}return{messages:e,isLoading:i,error:r,conversationId:s,sendMessage:d,clearMessages:h}}function M(o={}){const n=o.client??g(),e=o.autoLoad??!0,s=(0,t.ref)([]),i=(0,t.ref)(null),r=(0,t.ref)(!1),c=(0,t.ref)(null);async function f(){r.value=!0,c.value=null;try{s.value=await n.getConversations()}catch(d){c.value=d instanceof Error?d:new Error("Failed to load conversations")}finally{r.value=!1}}async function m(d){r.value=!0,c.value=null;try{i.value=await n.getConversation(d)}catch(h){c.value=h instanceof Error?h:new Error("Failed to load conversation")}finally{r.value=!1}}function C(){i.value=null}return(0,t.onMounted)(()=>{e&&f()}),{conversations:s,currentConversation:i,isLoading:r,error:c,selectConversation:m,startNewConversation:C,refreshConversations:f}}function N(o={}){const n=E({client:o.client,conversationId:o.conversationId}),e=M({client:o.client,autoLoad:o.autoLoad}),s=(0,t.computed)(()=>n.error.value||e.error.value);return{messages:n.messages,isLoading:n.isLoading,error:s,sendMessage:n.sendMessage,clearMessages:n.clearMessages,conversationId:n.conversationId,conversations:e.conversations,currentConversation:e.currentConversation,isConversationsLoading:e.isLoading,selectConversation:e.selectConversation,startNewConversation:e.startNewConversation,refreshConversations:e.refreshConversations}}function F(o,n){const e=g();(0,t.onMounted)(()=>{e.registerFunction(o,n.handler,{description:n.description,parameters:n.parameters})}),(0,t.onUnmounted)(()=>{e.unregisterFunction(o)})}function S(o,n){const e=g();(0,t.onMounted)(()=>{e.registerNavigationFunction(o,n)}),(0,t.onUnmounted)(()=>{e.unregisterFunction("navigateToPage")})}function _(o,n){const e=g();(0,t.onMounted)(()=>{e.on(o,n)}),(0,t.onUnmounted)(()=>{e.off(o,n)})}function D(o){const n=(0,t.shallowRef)(o.get());return(0,t.onScopeDispose)(o.subscribe(e=>{n.value=e})),n}exports.AGO_CLIENT_KEY=I;exports.AgoPlugin=y;exports.useAgo=g;exports.useAgoEvents=_;exports.useAgoFunction=F;exports.useAgoNavigation=S;exports.useAgoStore=D;exports.useChat=N;exports.useConversation=M;exports.useMessages=E;