@useago/sdk 0.1.7 → 0.2.1

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 (63) hide show
  1. package/README.md +101 -6
  2. package/dist/AgoClient-CNT-8sh_.js +905 -0
  3. package/dist/AgoClient-CNT-8sh_.js.map +1 -0
  4. package/dist/AgoClient-D0l1GTRs.cjs +976 -0
  5. package/dist/AgoClient-D0l1GTRs.cjs.map +1 -0
  6. package/dist/angular.cjs +138 -100
  7. package/dist/angular.cjs.map +1 -1
  8. package/dist/angular.d.ts +1 -0
  9. package/dist/angular.js +139 -103
  10. package/dist/angular.js.map +1 -1
  11. package/dist/client/types.d.ts +5 -1
  12. package/dist/createMockClient-Ci_N2tH8.cjs +104 -0
  13. package/dist/createMockClient-Ci_N2tH8.cjs.map +1 -0
  14. package/dist/createMockClient-U0ae_AYy.js +99 -0
  15. package/dist/createMockClient-U0ae_AYy.js.map +1 -0
  16. package/dist/functions--c6lx3ic.cjs +480 -0
  17. package/dist/functions--c6lx3ic.cjs.map +1 -0
  18. package/dist/functions-C9F1dnmh.js +398 -0
  19. package/dist/functions-C9F1dnmh.js.map +1 -0
  20. package/dist/helpers.cjs +14 -16
  21. package/dist/helpers.d.ts +1 -0
  22. package/dist/helpers.js +2 -17
  23. package/dist/index.cjs +281 -153
  24. package/dist/index.cjs.map +1 -1
  25. package/dist/index.js +256 -166
  26. package/dist/index.js.map +1 -1
  27. package/dist/react/components/ChatWidget.d.ts +2 -0
  28. package/dist/react/components/Markdown.d.ts +12 -0
  29. package/dist/react/components/Message.d.ts +2 -0
  30. package/dist/react/components/index.d.ts +2 -0
  31. package/dist/react/index.d.ts +2 -0
  32. package/dist/react.cjs +22099 -10333
  33. package/dist/react.cjs.map +1 -1
  34. package/dist/react.d.ts +1 -0
  35. package/dist/react.js +22099 -10349
  36. package/dist/react.js.map +1 -1
  37. package/dist/rolldown-runtime-BqCkTl7Q.cjs +50 -0
  38. package/dist/rolldown-runtime-CNZpIYwj.js +33 -0
  39. package/dist/vue.cjs +287 -208
  40. package/dist/vue.cjs.map +1 -1
  41. package/dist/vue.d.ts +1 -0
  42. package/dist/vue.js +287 -218
  43. package/dist/vue.js.map +1 -1
  44. package/dist/widget.cjs +0 -2
  45. package/dist/widget.d.ts +1 -0
  46. package/dist/widget.js +0 -2
  47. package/package.json +8 -6
  48. package/dist/AgoClient-BDO4avLq.cjs +0 -1036
  49. package/dist/AgoClient-BDO4avLq.cjs.map +0 -1
  50. package/dist/AgoClient-D-c91tx5.js +0 -1037
  51. package/dist/AgoClient-D-c91tx5.js.map +0 -1
  52. package/dist/createMockClient-B1DcBiIK.js +0 -94
  53. package/dist/createMockClient-B1DcBiIK.js.map +0 -1
  54. package/dist/createMockClient-BqNSJUu4.cjs +0 -93
  55. package/dist/createMockClient-BqNSJUu4.cjs.map +0 -1
  56. package/dist/functions-B0Z0rNQW.cjs +0 -306
  57. package/dist/functions-B0Z0rNQW.cjs.map +0 -1
  58. package/dist/functions-C-wLEc8b.js +0 -306
  59. package/dist/functions-C-wLEc8b.js.map +0 -1
  60. package/dist/helpers.cjs.map +0 -1
  61. package/dist/helpers.js.map +0 -1
  62. package/dist/widget.cjs.map +0 -1
  63. package/dist/widget.js.map +0 -1
@@ -0,0 +1,50 @@
1
+ //#region \0rolldown/runtime.js
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __commonJSMin = (cb, mod) => () => (mod || (cb((mod = { exports: {} }).exports, mod), cb = null), mod.exports);
9
+ var __exportAll = (all, no_symbols) => {
10
+ let target = {};
11
+ for (var name in all) __defProp(target, name, {
12
+ get: all[name],
13
+ enumerable: true
14
+ });
15
+ if (!no_symbols) __defProp(target, Symbol.toStringTag, { value: "Module" });
16
+ return target;
17
+ };
18
+ var __copyProps = (to, from, except, desc) => {
19
+ if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
20
+ key = keys[i];
21
+ if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
22
+ get: ((k) => from[k]).bind(null, key),
23
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
24
+ });
25
+ }
26
+ return to;
27
+ };
28
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
29
+ value: mod,
30
+ enumerable: true
31
+ }) : target, mod));
32
+ //#endregion
33
+ Object.defineProperty(exports, "__commonJSMin", {
34
+ enumerable: true,
35
+ get: function() {
36
+ return __commonJSMin;
37
+ }
38
+ });
39
+ Object.defineProperty(exports, "__exportAll", {
40
+ enumerable: true,
41
+ get: function() {
42
+ return __exportAll;
43
+ }
44
+ });
45
+ Object.defineProperty(exports, "__toESM", {
46
+ enumerable: true,
47
+ get: function() {
48
+ return __toESM;
49
+ }
50
+ });
@@ -0,0 +1,33 @@
1
+ //#region \0rolldown/runtime.js
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __commonJSMin = (cb, mod) => () => (mod || (cb((mod = { exports: {} }).exports, mod), cb = null), mod.exports);
9
+ var __exportAll = (all, no_symbols) => {
10
+ let target = {};
11
+ for (var name in all) __defProp(target, name, {
12
+ get: all[name],
13
+ enumerable: true
14
+ });
15
+ if (!no_symbols) __defProp(target, Symbol.toStringTag, { value: "Module" });
16
+ return target;
17
+ };
18
+ var __copyProps = (to, from, except, desc) => {
19
+ if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
20
+ key = keys[i];
21
+ if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
22
+ get: ((k) => from[k]).bind(null, key),
23
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
24
+ });
25
+ }
26
+ return to;
27
+ };
28
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
29
+ value: mod,
30
+ enumerable: true
31
+ }) : target, mod));
32
+ //#endregion
33
+ export { __exportAll as n, __toESM as r, __commonJSMin as t };
package/dist/vue.cjs CHANGED
@@ -1,225 +1,303 @@
1
- "use strict";
2
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const AgoClient = require("./AgoClient-BDO4avLq.cjs");
4
- const vue = require("vue");
5
- const AGO_CLIENT_KEY = Symbol("ago-client");
6
- const AgoPlugin = {
7
- install(app, options) {
8
- const client = new AgoClient.AgoClient(options);
9
- app.provide(AGO_CLIENT_KEY, client);
10
- }
11
- };
2
+ require("./rolldown-runtime-BqCkTl7Q.cjs");
3
+ const require_AgoClient = require("./AgoClient-D0l1GTRs.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
+ */
12
38
  function useAgo(config) {
13
- if (config) {
14
- return new AgoClient.AgoClient(config);
15
- }
16
- const client = vue.inject(AGO_CLIENT_KEY);
17
- if (!client) {
18
- throw new Error(
19
- "useAgo(): no AgoClient found. Either pass config or install AgoPlugin."
20
- );
21
- }
22
- return client;
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;
23
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
+ */
24
53
  function useMessages(options = {}) {
25
- const client = options.client ?? useAgo();
26
- const messages = vue.ref([]);
27
- const conversationId = vue.ref(options.conversationId);
28
- const isLoading = vue.ref(false);
29
- const error = vue.ref(null);
30
- const handleStart = (data) => {
31
- if (!conversationId.value) {
32
- conversationId.value = data.conversationId;
33
- }
34
- };
35
- const handleChunk = (data) => {
36
- const idx = messages.value.findIndex((m) => m.id === data.messageId);
37
- if (idx >= 0) {
38
- messages.value[idx] = {
39
- ...messages.value[idx],
40
- content: messages.value[idx].content + data.content
41
- };
42
- }
43
- };
44
- const handleComplete = (message) => {
45
- const idx = messages.value.findIndex((m) => m.id === message.id);
46
- if (idx >= 0) {
47
- messages.value[idx] = message;
48
- } else {
49
- messages.value.push(message);
50
- }
51
- isLoading.value = false;
52
- };
53
- const handleError = (data) => {
54
- error.value = new Error(data.error);
55
- isLoading.value = false;
56
- };
57
- vue.onMounted(() => {
58
- client.on("message:start", handleStart);
59
- client.on("message:chunk", handleChunk);
60
- client.on("message:complete", handleComplete);
61
- client.on("message:error", handleError);
62
- });
63
- vue.onUnmounted(() => {
64
- client.off("message:start", handleStart);
65
- client.off("message:chunk", handleChunk);
66
- client.off("message:complete", handleComplete);
67
- client.off("message:error", handleError);
68
- });
69
- async function sendMessage(content, files) {
70
- isLoading.value = true;
71
- error.value = null;
72
- const userMsg = {
73
- id: `temp-${Date.now()}`,
74
- conversationId: conversationId.value || "",
75
- content,
76
- role: "user",
77
- status: "DONE",
78
- createdAt: /* @__PURE__ */ new Date()
79
- };
80
- const assistantMsg = {
81
- id: `temp-assistant-${Date.now()}`,
82
- conversationId: conversationId.value || "",
83
- content: "",
84
- role: "assistant",
85
- status: "IN_PROGRESS",
86
- createdAt: /* @__PURE__ */ new Date()
87
- };
88
- messages.value.push(userMsg, assistantMsg);
89
- try {
90
- const response = await client.sendMessage(content, {
91
- conversationId: conversationId.value,
92
- files
93
- });
94
- if (response.conversationId && !conversationId.value) {
95
- conversationId.value = response.conversationId;
96
- }
97
- messages.value = messages.value.filter((m) => !m.id.startsWith("temp-"));
98
- const updatedUser = { ...userMsg, id: userMsg.id.replace("temp-", "user-"), conversationId: response.conversationId };
99
- if (!messages.value.some((m) => m.id === response.id)) {
100
- messages.value.push(updatedUser, response);
101
- } else {
102
- messages.value.push(updatedUser);
103
- }
104
- return response;
105
- } catch (err) {
106
- error.value = err instanceof Error ? err : new Error("Failed to send");
107
- isLoading.value = false;
108
- messages.value = messages.value.filter((m) => !m.id.startsWith("temp-"));
109
- return null;
110
- }
111
- }
112
- function clearMessages() {
113
- messages.value = [];
114
- conversationId.value = void 0;
115
- error.value = null;
116
- }
117
- return { messages, isLoading, error, conversationId, sendMessage, clearMessages };
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
+ };
118
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
+ */
119
156
  function useConversation(options = {}) {
120
- const client = options.client ?? useAgo();
121
- const autoLoad = options.autoLoad ?? true;
122
- const conversations = vue.ref([]);
123
- const currentConversation = vue.ref(null);
124
- const isLoading = vue.ref(false);
125
- const error = vue.ref(null);
126
- async function refreshConversations() {
127
- isLoading.value = true;
128
- error.value = null;
129
- try {
130
- conversations.value = await client.getConversations();
131
- } catch (err) {
132
- error.value = err instanceof Error ? err : new Error("Failed to load conversations");
133
- } finally {
134
- isLoading.value = false;
135
- }
136
- }
137
- async function selectConversation(id) {
138
- isLoading.value = true;
139
- error.value = null;
140
- try {
141
- currentConversation.value = await client.getConversation(id);
142
- } catch (err) {
143
- error.value = err instanceof Error ? err : new Error("Failed to load conversation");
144
- } finally {
145
- isLoading.value = false;
146
- }
147
- }
148
- function startNewConversation() {
149
- currentConversation.value = null;
150
- }
151
- vue.onMounted(() => {
152
- if (autoLoad) refreshConversations();
153
- });
154
- return {
155
- conversations,
156
- currentConversation,
157
- isLoading,
158
- error,
159
- selectConversation,
160
- startNewConversation,
161
- refreshConversations
162
- };
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
+ };
163
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
+ */
164
210
  function useChat(options = {}) {
165
- const msgResult = useMessages({
166
- client: options.client,
167
- conversationId: options.conversationId
168
- });
169
- const convResult = useConversation({
170
- client: options.client,
171
- autoLoad: options.autoLoad
172
- });
173
- const error = vue.computed(
174
- () => msgResult.error.value || convResult.error.value
175
- );
176
- return {
177
- // Messages
178
- messages: msgResult.messages,
179
- isLoading: msgResult.isLoading,
180
- error,
181
- sendMessage: msgResult.sendMessage,
182
- clearMessages: msgResult.clearMessages,
183
- conversationId: msgResult.conversationId,
184
- // Conversations
185
- conversations: convResult.conversations,
186
- currentConversation: convResult.currentConversation,
187
- isConversationsLoading: convResult.isLoading,
188
- selectConversation: convResult.selectConversation,
189
- startNewConversation: convResult.startNewConversation,
190
- refreshConversations: convResult.refreshConversations
191
- };
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
+ };
192
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
+ */
193
248
  function useAgoFunction(name, options) {
194
- const client = useAgo();
195
- vue.onMounted(() => {
196
- client.registerFunction(name, options.handler, {
197
- description: options.description,
198
- parameters: options.parameters
199
- });
200
- });
201
- vue.onUnmounted(() => {
202
- client.unregisterFunction(name);
203
- });
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
+ });
204
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
+ */
205
271
  function useAgoNavigation(navigate, routes) {
206
- const client = useAgo();
207
- vue.onMounted(() => {
208
- client.registerNavigationFunction(navigate, routes);
209
- });
210
- vue.onUnmounted(() => {
211
- client.unregisterFunction("navigateToPage");
212
- });
272
+ const client = useAgo();
273
+ (0, vue.onMounted)(() => {
274
+ client.registerNavigationFunction(navigate, routes);
275
+ });
276
+ (0, vue.onUnmounted)(() => {
277
+ client.unregisterFunction("navigateToPage");
278
+ });
213
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
+ */
214
291
  function useAgoEvents(event, handler) {
215
- const client = useAgo();
216
- vue.onMounted(() => {
217
- client.on(event, handler);
218
- });
219
- vue.onUnmounted(() => {
220
- client.off(event, handler);
221
- });
292
+ const client = useAgo();
293
+ (0, vue.onMounted)(() => {
294
+ client.on(event, handler);
295
+ });
296
+ (0, vue.onUnmounted)(() => {
297
+ client.off(event, handler);
298
+ });
222
299
  }
300
+ //#endregion
223
301
  exports.AGO_CLIENT_KEY = AGO_CLIENT_KEY;
224
302
  exports.AgoPlugin = AgoPlugin;
225
303
  exports.useAgo = useAgo;
@@ -229,4 +307,5 @@ exports.useAgoNavigation = useAgoNavigation;
229
307
  exports.useChat = useChat;
230
308
  exports.useConversation = useConversation;
231
309
  exports.useMessages = useMessages;
232
- //# sourceMappingURL=vue.cjs.map
310
+
311
+ //# sourceMappingURL=vue.cjs.map