@useago/sdk 0.3.2 → 0.3.3

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 (116) 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/createMockClient-D6uVh-B9.js +254 -0
  8. package/dist/createMockClient-DecMEUcK.cjs +1 -0
  9. package/dist/devtools.cjs +4 -78
  10. package/dist/devtools.d.cts +443 -0
  11. package/dist/devtools.d.ts +443 -2
  12. package/dist/devtools.js +46 -71
  13. package/dist/functions-Bz-1Bs3I.cjs +1 -0
  14. package/dist/functions-DdROP6Ui.js +312 -0
  15. package/dist/helpers.cjs +1 -15
  16. package/dist/{helpers/functions.d.ts → helpers.d.cts} +121 -62
  17. package/dist/helpers.d.ts +121 -2
  18. package/dist/helpers.js +16 -2
  19. package/dist/index.cjs +1 -347
  20. package/dist/index.d.cts +1150 -0
  21. package/dist/index.d.ts +1150 -20
  22. package/dist/index.js +128 -298
  23. package/dist/react.cjs +31 -22438
  24. package/dist/react.d.cts +960 -0
  25. package/dist/react.d.ts +960 -2
  26. package/dist/react.js +8401 -22376
  27. package/dist/rolldown-runtime-CaekUdDJ.cjs +1 -0
  28. package/dist/rolldown-runtime-DxmricAu.js +25 -0
  29. package/dist/vue.cjs +1 -336
  30. package/dist/vue.d.cts +1063 -0
  31. package/dist/vue.d.ts +1063 -2
  32. package/dist/vue.js +174 -316
  33. package/dist/{widget/types.d.ts → widget.d.cts} +41 -43
  34. package/dist/widget.d.ts +41 -2
  35. package/package.json +35 -24
  36. package/dist/AgoClient-DPZdN5n2.js +0 -905
  37. package/dist/AgoClient-DPZdN5n2.js.map +0 -1
  38. package/dist/AgoClient-wMVUQqCD.cjs +0 -976
  39. package/dist/AgoClient-wMVUQqCD.cjs.map +0 -1
  40. package/dist/angular/ago.service.d.ts +0 -98
  41. package/dist/angular/index.d.ts +0 -4
  42. package/dist/angular/provide.d.ts +0 -27
  43. package/dist/angular.cjs.map +0 -1
  44. package/dist/angular.js.map +0 -1
  45. package/dist/api/HttpClient.d.ts +0 -31
  46. package/dist/api/index.d.ts +0 -1
  47. package/dist/auto/createAgo.d.ts +0 -39
  48. package/dist/auto/index.d.ts +0 -1
  49. package/dist/client/AgoClient.d.ts +0 -169
  50. package/dist/client/errors.d.ts +0 -48
  51. package/dist/client/index.d.ts +0 -3
  52. package/dist/client/types.d.ts +0 -205
  53. package/dist/createMockClient-Ci_N2tH8.cjs +0 -104
  54. package/dist/createMockClient-Ci_N2tH8.cjs.map +0 -1
  55. package/dist/createMockClient-U0ae_AYy.js +0 -99
  56. package/dist/createMockClient-U0ae_AYy.js.map +0 -1
  57. package/dist/devtools/index.d.ts +0 -2
  58. package/dist/devtools/initDevPanel.d.ts +0 -15
  59. package/dist/devtools.cjs.map +0 -1
  60. package/dist/devtools.js.map +0 -1
  61. package/dist/functions/FunctionRegistry.d.ts +0 -41
  62. package/dist/functions/defineFunction.d.ts +0 -22
  63. package/dist/functions/index.d.ts +0 -2
  64. package/dist/functions/types.d.ts +0 -50
  65. package/dist/functions--c6lx3ic.cjs +0 -480
  66. package/dist/functions--c6lx3ic.cjs.map +0 -1
  67. package/dist/functions-C9F1dnmh.js +0 -398
  68. package/dist/functions-C9F1dnmh.js.map +0 -1
  69. package/dist/helpers/factory.d.ts +0 -20
  70. package/dist/helpers/index.d.ts +0 -1
  71. package/dist/index.cjs.map +0 -1
  72. package/dist/index.js.map +0 -1
  73. package/dist/react/components/ChatInput.d.ts +0 -12
  74. package/dist/react/components/ChatWidget.d.ts +0 -35
  75. package/dist/react/components/Markdown.d.ts +0 -12
  76. package/dist/react/components/Message.d.ts +0 -9
  77. package/dist/react/components/index.d.ts +0 -8
  78. package/dist/react/context/AgoContext.d.ts +0 -62
  79. package/dist/react/context/index.d.ts +0 -2
  80. package/dist/react/hooks/index.d.ts +0 -7
  81. package/dist/react/hooks/useAgo.d.ts +0 -14
  82. package/dist/react/hooks/useAgoContext.d.ts +0 -40
  83. package/dist/react/hooks/useAgoFunction.d.ts +0 -58
  84. package/dist/react/hooks/useAgoStore.d.ts +0 -17
  85. package/dist/react/hooks/useChat.d.ts +0 -45
  86. package/dist/react/hooks/useConversation.d.ts +0 -28
  87. package/dist/react/hooks/useMessages.d.ts +0 -26
  88. package/dist/react/index.d.ts +0 -24
  89. package/dist/react/testing.d.ts +0 -2
  90. package/dist/react.cjs.map +0 -1
  91. package/dist/react.js.map +0 -1
  92. package/dist/rolldown-runtime-BqCkTl7Q.cjs +0 -50
  93. package/dist/rolldown-runtime-CNZpIYwj.js +0 -33
  94. package/dist/state/ClientContextRegistry.d.ts +0 -64
  95. package/dist/state/createStore.d.ts +0 -30
  96. package/dist/streaming/SSEHandler.d.ts +0 -46
  97. package/dist/streaming/helpers.d.ts +0 -67
  98. package/dist/streaming/index.d.ts +0 -2
  99. package/dist/testing/createMockClient.d.ts +0 -42
  100. package/dist/testing/index.d.ts +0 -2
  101. package/dist/utils/eventEmitter.d.ts +0 -23
  102. package/dist/utils/index.d.ts +0 -2
  103. package/dist/utils/logger.d.ts +0 -14
  104. package/dist/vue/composables/useAgo.d.ts +0 -17
  105. package/dist/vue/composables/useAgoEvents.d.ts +0 -11
  106. package/dist/vue/composables/useAgoFunction.d.ts +0 -34
  107. package/dist/vue/composables/useAgoStore.d.ts +0 -18
  108. package/dist/vue/composables/useChat.d.ts +0 -251
  109. package/dist/vue/composables/useConversation.d.ts +0 -178
  110. package/dist/vue/composables/useMessages.d.ts +0 -89
  111. package/dist/vue/index.d.ts +0 -11
  112. package/dist/vue/plugin.d.ts +0 -16
  113. package/dist/vue/symbols.d.ts +0 -3
  114. package/dist/vue.cjs.map +0 -1
  115. package/dist/vue.js.map +0 -1
  116. package/dist/widget/index.d.ts +0 -1
@@ -1,251 +0,0 @@
1
- import type { AgoClient } from "../../client/AgoClient";
2
- export interface UseChatOptions {
3
- client?: AgoClient;
4
- conversationId?: string;
5
- autoLoad?: boolean;
6
- }
7
- /**
8
- * All-in-one composable combining messages + conversations.
9
- *
10
- * ```ts
11
- * const { messages, sendMessage, conversations, selectConversation } = useChat();
12
- * ```
13
- */
14
- export declare function useChat(options?: UseChatOptions): {
15
- messages: import("vue").Ref<{
16
- id: string;
17
- conversationId: string;
18
- content: string;
19
- role: "user" | "assistant";
20
- status: import("../..").MessageStatus;
21
- agent?: {
22
- id: string;
23
- name: string;
24
- displayName?: string | undefined;
25
- } | undefined;
26
- sources?: {
27
- id: string;
28
- title: string;
29
- url?: string | undefined;
30
- }[] | undefined;
31
- toolCalls?: {
32
- id: string;
33
- type: import("../..").ToolCallType;
34
- status: string;
35
- toolName: string;
36
- toolDisplayName?: string | undefined;
37
- message?: string | undefined;
38
- formSchema?: {
39
- type: "object";
40
- properties: Record<string, import("../..").FormField>;
41
- required?: string[] | undefined;
42
- } | undefined;
43
- data?: Record<string, unknown> | undefined;
44
- functionName?: string | undefined;
45
- arguments?: Record<string, unknown> | undefined;
46
- }[] | undefined;
47
- followUpReplies?: string[] | undefined;
48
- createdAt: Date;
49
- }[], import("..").AgoMessage[] | {
50
- id: string;
51
- conversationId: string;
52
- content: string;
53
- role: "user" | "assistant";
54
- status: import("../..").MessageStatus;
55
- agent?: {
56
- id: string;
57
- name: string;
58
- displayName?: string | undefined;
59
- } | undefined;
60
- sources?: {
61
- id: string;
62
- title: string;
63
- url?: string | undefined;
64
- }[] | undefined;
65
- toolCalls?: {
66
- id: string;
67
- type: import("../..").ToolCallType;
68
- status: string;
69
- toolName: string;
70
- toolDisplayName?: string | undefined;
71
- message?: string | undefined;
72
- formSchema?: {
73
- type: "object";
74
- properties: Record<string, import("../..").FormField>;
75
- required?: string[] | undefined;
76
- } | undefined;
77
- data?: Record<string, unknown> | undefined;
78
- functionName?: string | undefined;
79
- arguments?: Record<string, unknown> | undefined;
80
- }[] | undefined;
81
- followUpReplies?: string[] | undefined;
82
- createdAt: Date;
83
- }[]>;
84
- isLoading: import("vue").Ref<boolean, boolean>;
85
- error: import("vue").ComputedRef<Error | null>;
86
- sendMessage: (content: string, files?: File[]) => Promise<import("..").AgoMessage | null>;
87
- clearMessages: () => void;
88
- conversationId: import("vue").Ref<string | undefined, string | undefined>;
89
- conversations: import("vue").Ref<{
90
- id: string;
91
- title: string;
92
- lastMessageDate: Date;
93
- messages?: {
94
- id: string;
95
- conversationId: string;
96
- content: string;
97
- role: "user" | "assistant";
98
- status: import("../..").MessageStatus;
99
- agent?: {
100
- id: string;
101
- name: string;
102
- displayName?: string | undefined;
103
- } | undefined;
104
- sources?: {
105
- id: string;
106
- title: string;
107
- url?: string | undefined;
108
- }[] | undefined;
109
- toolCalls?: {
110
- id: string;
111
- type: import("../..").ToolCallType;
112
- status: string;
113
- toolName: string;
114
- toolDisplayName?: string | undefined;
115
- message?: string | undefined;
116
- formSchema?: {
117
- type: "object";
118
- properties: Record<string, import("../..").FormField>;
119
- required?: string[] | undefined;
120
- } | undefined;
121
- data?: Record<string, unknown> | undefined;
122
- functionName?: string | undefined;
123
- arguments?: Record<string, unknown> | undefined;
124
- }[] | undefined;
125
- followUpReplies?: string[] | undefined;
126
- createdAt: Date;
127
- }[] | undefined;
128
- }[], import("..").Conversation[] | {
129
- id: string;
130
- title: string;
131
- lastMessageDate: Date;
132
- messages?: {
133
- id: string;
134
- conversationId: string;
135
- content: string;
136
- role: "user" | "assistant";
137
- status: import("../..").MessageStatus;
138
- agent?: {
139
- id: string;
140
- name: string;
141
- displayName?: string | undefined;
142
- } | undefined;
143
- sources?: {
144
- id: string;
145
- title: string;
146
- url?: string | undefined;
147
- }[] | undefined;
148
- toolCalls?: {
149
- id: string;
150
- type: import("../..").ToolCallType;
151
- status: string;
152
- toolName: string;
153
- toolDisplayName?: string | undefined;
154
- message?: string | undefined;
155
- formSchema?: {
156
- type: "object";
157
- properties: Record<string, import("../..").FormField>;
158
- required?: string[] | undefined;
159
- } | undefined;
160
- data?: Record<string, unknown> | undefined;
161
- functionName?: string | undefined;
162
- arguments?: Record<string, unknown> | undefined;
163
- }[] | undefined;
164
- followUpReplies?: string[] | undefined;
165
- createdAt: Date;
166
- }[] | undefined;
167
- }[]>;
168
- currentConversation: import("vue").Ref<{
169
- id: string;
170
- title: string;
171
- lastMessageDate: Date;
172
- messages?: {
173
- id: string;
174
- conversationId: string;
175
- content: string;
176
- role: "user" | "assistant";
177
- status: import("../..").MessageStatus;
178
- agent?: {
179
- id: string;
180
- name: string;
181
- displayName?: string | undefined;
182
- } | undefined;
183
- sources?: {
184
- id: string;
185
- title: string;
186
- url?: string | undefined;
187
- }[] | undefined;
188
- toolCalls?: {
189
- id: string;
190
- type: import("../..").ToolCallType;
191
- status: string;
192
- toolName: string;
193
- toolDisplayName?: string | undefined;
194
- message?: string | undefined;
195
- formSchema?: {
196
- type: "object";
197
- properties: Record<string, import("../..").FormField>;
198
- required?: string[] | undefined;
199
- } | undefined;
200
- data?: Record<string, unknown> | undefined;
201
- functionName?: string | undefined;
202
- arguments?: Record<string, unknown> | undefined;
203
- }[] | undefined;
204
- followUpReplies?: string[] | undefined;
205
- createdAt: Date;
206
- }[] | undefined;
207
- } | null, import("..").Conversation | {
208
- id: string;
209
- title: string;
210
- lastMessageDate: Date;
211
- messages?: {
212
- id: string;
213
- conversationId: string;
214
- content: string;
215
- role: "user" | "assistant";
216
- status: import("../..").MessageStatus;
217
- agent?: {
218
- id: string;
219
- name: string;
220
- displayName?: string | undefined;
221
- } | undefined;
222
- sources?: {
223
- id: string;
224
- title: string;
225
- url?: string | undefined;
226
- }[] | undefined;
227
- toolCalls?: {
228
- id: string;
229
- type: import("../..").ToolCallType;
230
- status: string;
231
- toolName: string;
232
- toolDisplayName?: string | undefined;
233
- message?: string | undefined;
234
- formSchema?: {
235
- type: "object";
236
- properties: Record<string, import("../..").FormField>;
237
- required?: string[] | undefined;
238
- } | undefined;
239
- data?: Record<string, unknown> | undefined;
240
- functionName?: string | undefined;
241
- arguments?: Record<string, unknown> | undefined;
242
- }[] | undefined;
243
- followUpReplies?: string[] | undefined;
244
- createdAt: Date;
245
- }[] | undefined;
246
- } | null>;
247
- isConversationsLoading: import("vue").Ref<boolean, boolean>;
248
- selectConversation: (id: string) => Promise<void>;
249
- startNewConversation: () => void;
250
- refreshConversations: () => Promise<void>;
251
- };
@@ -1,178 +0,0 @@
1
- import type { AgoClient } from "../../client/AgoClient";
2
- import type { Conversation } from "../../client/types";
3
- export interface UseConversationOptions {
4
- client?: AgoClient;
5
- autoLoad?: boolean;
6
- }
7
- /**
8
- * Composable to manage conversations.
9
- *
10
- * ```ts
11
- * const { conversations, selectConversation } = useConversation();
12
- * ```
13
- */
14
- export declare function useConversation(options?: UseConversationOptions): {
15
- conversations: import("vue").Ref<{
16
- id: string;
17
- title: string;
18
- lastMessageDate: Date;
19
- messages?: {
20
- id: string;
21
- conversationId: string;
22
- content: string;
23
- role: "user" | "assistant";
24
- status: import("../..").MessageStatus;
25
- agent?: {
26
- id: string;
27
- name: string;
28
- displayName?: string | undefined;
29
- } | undefined;
30
- sources?: {
31
- id: string;
32
- title: string;
33
- url?: string | undefined;
34
- }[] | undefined;
35
- toolCalls?: {
36
- id: string;
37
- type: import("../..").ToolCallType;
38
- status: string;
39
- toolName: string;
40
- toolDisplayName?: string | undefined;
41
- message?: string | undefined;
42
- formSchema?: {
43
- type: "object";
44
- properties: Record<string, import("../..").FormField>;
45
- required?: string[] | undefined;
46
- } | undefined;
47
- data?: Record<string, unknown> | undefined;
48
- functionName?: string | undefined;
49
- arguments?: Record<string, unknown> | undefined;
50
- }[] | undefined;
51
- followUpReplies?: string[] | undefined;
52
- createdAt: Date;
53
- }[] | undefined;
54
- }[], Conversation[] | {
55
- id: string;
56
- title: string;
57
- lastMessageDate: Date;
58
- messages?: {
59
- id: string;
60
- conversationId: string;
61
- content: string;
62
- role: "user" | "assistant";
63
- status: import("../..").MessageStatus;
64
- agent?: {
65
- id: string;
66
- name: string;
67
- displayName?: string | undefined;
68
- } | undefined;
69
- sources?: {
70
- id: string;
71
- title: string;
72
- url?: string | undefined;
73
- }[] | undefined;
74
- toolCalls?: {
75
- id: string;
76
- type: import("../..").ToolCallType;
77
- status: string;
78
- toolName: string;
79
- toolDisplayName?: string | undefined;
80
- message?: string | undefined;
81
- formSchema?: {
82
- type: "object";
83
- properties: Record<string, import("../..").FormField>;
84
- required?: string[] | undefined;
85
- } | undefined;
86
- data?: Record<string, unknown> | undefined;
87
- functionName?: string | undefined;
88
- arguments?: Record<string, unknown> | undefined;
89
- }[] | undefined;
90
- followUpReplies?: string[] | undefined;
91
- createdAt: Date;
92
- }[] | undefined;
93
- }[]>;
94
- currentConversation: import("vue").Ref<{
95
- id: string;
96
- title: string;
97
- lastMessageDate: Date;
98
- messages?: {
99
- id: string;
100
- conversationId: string;
101
- content: string;
102
- role: "user" | "assistant";
103
- status: import("../..").MessageStatus;
104
- agent?: {
105
- id: string;
106
- name: string;
107
- displayName?: string | undefined;
108
- } | undefined;
109
- sources?: {
110
- id: string;
111
- title: string;
112
- url?: string | undefined;
113
- }[] | undefined;
114
- toolCalls?: {
115
- id: string;
116
- type: import("../..").ToolCallType;
117
- status: string;
118
- toolName: string;
119
- toolDisplayName?: string | undefined;
120
- message?: string | undefined;
121
- formSchema?: {
122
- type: "object";
123
- properties: Record<string, import("../..").FormField>;
124
- required?: string[] | undefined;
125
- } | undefined;
126
- data?: Record<string, unknown> | undefined;
127
- functionName?: string | undefined;
128
- arguments?: Record<string, unknown> | undefined;
129
- }[] | undefined;
130
- followUpReplies?: string[] | undefined;
131
- createdAt: Date;
132
- }[] | undefined;
133
- } | null, Conversation | {
134
- id: string;
135
- title: string;
136
- lastMessageDate: Date;
137
- messages?: {
138
- id: string;
139
- conversationId: string;
140
- content: string;
141
- role: "user" | "assistant";
142
- status: import("../..").MessageStatus;
143
- agent?: {
144
- id: string;
145
- name: string;
146
- displayName?: string | undefined;
147
- } | undefined;
148
- sources?: {
149
- id: string;
150
- title: string;
151
- url?: string | undefined;
152
- }[] | undefined;
153
- toolCalls?: {
154
- id: string;
155
- type: import("../..").ToolCallType;
156
- status: string;
157
- toolName: string;
158
- toolDisplayName?: string | undefined;
159
- message?: string | undefined;
160
- formSchema?: {
161
- type: "object";
162
- properties: Record<string, import("../..").FormField>;
163
- required?: string[] | undefined;
164
- } | undefined;
165
- data?: Record<string, unknown> | undefined;
166
- functionName?: string | undefined;
167
- arguments?: Record<string, unknown> | undefined;
168
- }[] | undefined;
169
- followUpReplies?: string[] | undefined;
170
- createdAt: Date;
171
- }[] | undefined;
172
- } | null>;
173
- isLoading: import("vue").Ref<boolean, boolean>;
174
- error: import("vue").Ref<Error | null, Error | null>;
175
- selectConversation: (id: string) => Promise<void>;
176
- startNewConversation: () => void;
177
- refreshConversations: () => Promise<void>;
178
- };
@@ -1,89 +0,0 @@
1
- import type { AgoClient } from "../../client/AgoClient";
2
- import type { AgoMessage } from "../../client/types";
3
- export interface UseMessagesOptions {
4
- client?: AgoClient;
5
- conversationId?: string;
6
- }
7
- /**
8
- * Composable to manage messages in a conversation.
9
- *
10
- * ```ts
11
- * const { messages, sendMessage, isLoading } = useMessages();
12
- * ```
13
- */
14
- export declare function useMessages(options?: UseMessagesOptions): {
15
- messages: import("vue").Ref<{
16
- id: string;
17
- conversationId: string;
18
- content: string;
19
- role: "user" | "assistant";
20
- status: import("../..").MessageStatus;
21
- agent?: {
22
- id: string;
23
- name: string;
24
- displayName?: string | undefined;
25
- } | undefined;
26
- sources?: {
27
- id: string;
28
- title: string;
29
- url?: string | undefined;
30
- }[] | undefined;
31
- toolCalls?: {
32
- id: string;
33
- type: import("../..").ToolCallType;
34
- status: string;
35
- toolName: string;
36
- toolDisplayName?: string | undefined;
37
- message?: string | undefined;
38
- formSchema?: {
39
- type: "object";
40
- properties: Record<string, import("../..").FormField>;
41
- required?: string[] | undefined;
42
- } | undefined;
43
- data?: Record<string, unknown> | undefined;
44
- functionName?: string | undefined;
45
- arguments?: Record<string, unknown> | undefined;
46
- }[] | undefined;
47
- followUpReplies?: string[] | undefined;
48
- createdAt: Date;
49
- }[], AgoMessage[] | {
50
- id: string;
51
- conversationId: string;
52
- content: string;
53
- role: "user" | "assistant";
54
- status: import("../..").MessageStatus;
55
- agent?: {
56
- id: string;
57
- name: string;
58
- displayName?: string | undefined;
59
- } | undefined;
60
- sources?: {
61
- id: string;
62
- title: string;
63
- url?: string | undefined;
64
- }[] | undefined;
65
- toolCalls?: {
66
- id: string;
67
- type: import("../..").ToolCallType;
68
- status: string;
69
- toolName: string;
70
- toolDisplayName?: string | undefined;
71
- message?: string | undefined;
72
- formSchema?: {
73
- type: "object";
74
- properties: Record<string, import("../..").FormField>;
75
- required?: string[] | undefined;
76
- } | undefined;
77
- data?: Record<string, unknown> | undefined;
78
- functionName?: string | undefined;
79
- arguments?: Record<string, unknown> | undefined;
80
- }[] | undefined;
81
- followUpReplies?: string[] | undefined;
82
- createdAt: Date;
83
- }[]>;
84
- isLoading: import("vue").Ref<boolean, boolean>;
85
- error: import("vue").Ref<Error | null, Error | null>;
86
- conversationId: import("vue").Ref<string | undefined, string | undefined>;
87
- sendMessage: (content: string, files?: File[]) => Promise<AgoMessage | null>;
88
- clearMessages: () => void;
89
- };
@@ -1,11 +0,0 @@
1
- export { AgoPlugin } from "./plugin";
2
- export type { AgoPluginOptions } from "./plugin";
3
- export { useAgo } from "./composables/useAgo";
4
- export { useChat } from "./composables/useChat";
5
- export { useMessages } from "./composables/useMessages";
6
- export { useConversation } from "./composables/useConversation";
7
- export { useAgoFunction, useAgoNavigation } from "./composables/useAgoFunction";
8
- export { useAgoEvents } from "./composables/useAgoEvents";
9
- export { useAgoStore } from "./composables/useAgoStore";
10
- export { AGO_CLIENT_KEY } from "./symbols";
11
- export type { AgoConfig, AgoMessage, Conversation, AgoAgent, AgoSource, ToolCallData, } from "../client/types";
@@ -1,16 +0,0 @@
1
- import type { App } from "vue";
2
- import type { AgoConfig } from "../client/types";
3
- export interface AgoPluginOptions extends AgoConfig {
4
- }
5
- /**
6
- * Vue plugin that provides an AgoClient to the entire app via inject/provide.
7
- *
8
- * ```ts
9
- * import { AgoPlugin } from "@useago/sdk/vue";
10
- *
11
- * app.use(AgoPlugin, { baseUrl: "https://YOUR-DOMAIN.useago.com" });
12
- * ```
13
- */
14
- export declare const AgoPlugin: {
15
- install(app: App, options: AgoPluginOptions): void;
16
- };
@@ -1,3 +0,0 @@
1
- import type { InjectionKey } from "vue";
2
- import type { AgoClient } from "../client/AgoClient";
3
- export declare const AGO_CLIENT_KEY: InjectionKey<AgoClient>;
package/dist/vue.cjs.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"vue.cjs","names":[],"sources":["../src/vue/symbols.ts","../src/vue/plugin.ts","../src/vue/composables/useAgo.ts","../src/vue/composables/useMessages.ts","../src/vue/composables/useConversation.ts","../src/vue/composables/useChat.ts","../src/vue/composables/useAgoFunction.ts","../src/vue/composables/useAgoEvents.ts","../src/vue/composables/useAgoStore.ts"],"sourcesContent":["import type { InjectionKey } from \"vue\";\nimport type { AgoClient } from \"../client/AgoClient\";\n\nexport const AGO_CLIENT_KEY: InjectionKey<AgoClient> = Symbol(\"ago-client\");\n","import type { App } from \"vue\";\nimport { AgoClient } from \"../client/AgoClient\";\nimport type { AgoConfig } from \"../client/types\";\nimport { AGO_CLIENT_KEY } from \"./symbols\";\n\nexport interface AgoPluginOptions extends AgoConfig {}\n\n/**\n * Vue plugin that provides an AgoClient to the entire app via inject/provide.\n *\n * ```ts\n * import { AgoPlugin } from \"@useago/sdk/vue\";\n *\n * app.use(AgoPlugin, { baseUrl: \"https://YOUR-DOMAIN.useago.com\" });\n * ```\n */\nexport const AgoPlugin = {\n install(app: App, options: AgoPluginOptions) {\n const client = new AgoClient(options);\n app.provide(AGO_CLIENT_KEY, client);\n },\n};\n","import { inject } from \"vue\";\nimport { AgoClient } from \"../../client/AgoClient\";\nimport type { AgoConfig } from \"../../client/types\";\nimport { AGO_CLIENT_KEY } from \"../symbols\";\n\n/**\n * Get or create an AgoClient.\n *\n * - Without args: returns the client from `AgoPlugin` (throws if none).\n * - With config: creates a new client instance.\n *\n * ```ts\n * // From plugin\n * const client = useAgo();\n *\n * // Standalone\n * const client = useAgo({ baseUrl: \"https://YOUR-DOMAIN.useago.com\" });\n * ```\n */\nexport function useAgo(config?: AgoConfig): AgoClient {\n if (config) {\n return new AgoClient(config);\n }\n\n const client = inject(AGO_CLIENT_KEY);\n if (!client) {\n throw new Error(\n \"useAgo(): no AgoClient found. Either pass config or install AgoPlugin.\"\n );\n }\n return client;\n}\n","import { ref, onMounted, onUnmounted } from \"vue\";\nimport type { AgoClient } from \"../../client/AgoClient\";\nimport type { AgoMessage } from \"../../client/types\";\nimport { useAgo } from \"./useAgo\";\n\nexport interface UseMessagesOptions {\n client?: AgoClient;\n conversationId?: string;\n}\n\n/**\n * Composable to manage messages in a conversation.\n *\n * ```ts\n * const { messages, sendMessage, isLoading } = useMessages();\n * ```\n */\nexport function useMessages(options: UseMessagesOptions = {}) {\n const client = options.client ?? useAgo();\n\n const messages = ref<AgoMessage[]>([]);\n const conversationId = ref<string | undefined>(options.conversationId);\n const isLoading = ref(false);\n const error = ref<Error | null>(null);\n\n const handleStart = (data: { conversationId: string; messageId: string }) => {\n if (!conversationId.value) {\n conversationId.value = data.conversationId;\n }\n };\n\n const handleChunk = (data: { content: string; messageId: string }) => {\n const idx = messages.value.findIndex((m: AgoMessage) => m.id === data.messageId);\n if (idx >= 0) {\n messages.value[idx] = {\n ...messages.value[idx],\n content: messages.value[idx].content + data.content,\n };\n }\n };\n\n const handleComplete = (message: AgoMessage) => {\n const idx = messages.value.findIndex((m: AgoMessage) => m.id === message.id);\n if (idx >= 0) {\n messages.value[idx] = message;\n } else {\n messages.value.push(message);\n }\n isLoading.value = false;\n };\n\n const handleError = (data: { error: string }) => {\n error.value = new Error(data.error);\n isLoading.value = false;\n };\n\n onMounted(() => {\n client.on(\"message:start\", handleStart);\n client.on(\"message:chunk\", handleChunk);\n client.on(\"message:complete\", handleComplete);\n client.on(\"message:error\", handleError);\n });\n\n onUnmounted(() => {\n client.off(\"message:start\", handleStart);\n client.off(\"message:chunk\", handleChunk);\n client.off(\"message:complete\", handleComplete);\n client.off(\"message:error\", handleError);\n });\n\n async function sendMessage(content: string, files?: File[]): Promise<AgoMessage | null> {\n isLoading.value = true;\n error.value = null;\n\n // Optimistic user message\n const userMsg: AgoMessage = {\n id: `temp-${Date.now()}`,\n conversationId: conversationId.value || \"\",\n content,\n role: \"user\",\n status: \"DONE\",\n createdAt: new Date(),\n };\n const assistantMsg: AgoMessage = {\n id: `temp-assistant-${Date.now()}`,\n conversationId: conversationId.value || \"\",\n content: \"\",\n role: \"assistant\",\n status: \"IN_PROGRESS\",\n createdAt: new Date(),\n };\n messages.value.push(userMsg, assistantMsg);\n\n try {\n const response = await client.sendMessage(content, {\n conversationId: conversationId.value,\n files,\n });\n if (response.conversationId && !conversationId.value) {\n conversationId.value = response.conversationId;\n }\n // Replace temp messages\n messages.value = messages.value.filter((m: AgoMessage) => !m.id.startsWith(\"temp-\"));\n const updatedUser = { ...userMsg, id: userMsg.id.replace(\"temp-\", \"user-\"), conversationId: response.conversationId };\n if (!messages.value.some((m: AgoMessage) => m.id === response.id)) {\n messages.value.push(updatedUser, response);\n } else {\n messages.value.push(updatedUser);\n }\n return response;\n } catch (err) {\n error.value = err instanceof Error ? err : new Error(\"Failed to send\");\n isLoading.value = false;\n messages.value = messages.value.filter((m: AgoMessage) => !m.id.startsWith(\"temp-\"));\n return null;\n }\n }\n\n function clearMessages() {\n messages.value = [];\n conversationId.value = undefined;\n error.value = null;\n }\n\n return { messages, isLoading, error, conversationId, sendMessage, clearMessages };\n}\n","import { ref, onMounted } from \"vue\";\nimport type { AgoClient } from \"../../client/AgoClient\";\nimport type { Conversation } from \"../../client/types\";\nimport { useAgo } from \"./useAgo\";\n\nexport interface UseConversationOptions {\n client?: AgoClient;\n autoLoad?: boolean;\n}\n\n/**\n * Composable to manage conversations.\n *\n * ```ts\n * const { conversations, selectConversation } = useConversation();\n * ```\n */\nexport function useConversation(options: UseConversationOptions = {}) {\n const client = options.client ?? useAgo();\n const autoLoad = options.autoLoad ?? true;\n\n const conversations = ref<Conversation[]>([]);\n const currentConversation = ref<Conversation | null>(null);\n const isLoading = ref(false);\n const error = ref<Error | null>(null);\n\n async function refreshConversations() {\n isLoading.value = true;\n error.value = null;\n try {\n conversations.value = await client.getConversations();\n } catch (err) {\n error.value = err instanceof Error ? err : new Error(\"Failed to load conversations\");\n } finally {\n isLoading.value = false;\n }\n }\n\n async function selectConversation(id: string) {\n isLoading.value = true;\n error.value = null;\n try {\n currentConversation.value = await client.getConversation(id);\n } catch (err) {\n error.value = err instanceof Error ? err : new Error(\"Failed to load conversation\");\n } finally {\n isLoading.value = false;\n }\n }\n\n function startNewConversation() {\n currentConversation.value = null;\n }\n\n onMounted(() => {\n if (autoLoad) refreshConversations();\n });\n\n return {\n conversations,\n currentConversation,\n isLoading,\n error,\n selectConversation,\n startNewConversation,\n refreshConversations,\n };\n}\n","import { computed } from \"vue\";\nimport type { AgoClient } from \"../../client/AgoClient\";\nimport { useMessages } from \"./useMessages\";\nimport { useConversation } from \"./useConversation\";\n\nexport interface UseChatOptions {\n client?: AgoClient;\n conversationId?: string;\n autoLoad?: boolean;\n}\n\n/**\n * All-in-one composable combining messages + conversations.\n *\n * ```ts\n * const { messages, sendMessage, conversations, selectConversation } = useChat();\n * ```\n */\nexport function useChat(options: UseChatOptions = {}) {\n const msgResult = useMessages({\n client: options.client,\n conversationId: options.conversationId,\n });\n\n const convResult = useConversation({\n client: options.client,\n autoLoad: options.autoLoad,\n });\n\n const error = computed(\n () => msgResult.error.value || convResult.error.value\n );\n\n return {\n // Messages\n messages: msgResult.messages,\n isLoading: msgResult.isLoading,\n error,\n sendMessage: msgResult.sendMessage,\n clearMessages: msgResult.clearMessages,\n conversationId: msgResult.conversationId,\n // Conversations\n conversations: convResult.conversations,\n currentConversation: convResult.currentConversation,\n isConversationsLoading: convResult.isLoading,\n selectConversation: convResult.selectConversation,\n startNewConversation: convResult.startNewConversation,\n refreshConversations: convResult.refreshConversations,\n };\n}\n","import { onMounted, onUnmounted } from \"vue\";\nimport type { ClientFunctionHandler, ClientFunctionSchema } from \"../../functions/types\";\nimport { useAgo } from \"./useAgo\";\n\n/**\n * Register a client-side function with auto-cleanup on unmount.\n *\n * ```ts\n * useAgoFunction(\"showToast\", {\n * description: \"Show a toast\",\n * parameters: { type: \"object\", properties: { message: { type: \"string\" } } },\n * handler: async (args) => { toast(args.message); return { shown: true }; },\n * });\n * ```\n */\nexport function useAgoFunction(\n name: string,\n options: {\n description: string;\n parameters: ClientFunctionSchema[\"parameters\"];\n handler: ClientFunctionHandler;\n }\n): void {\n const client = useAgo();\n\n onMounted(() => {\n client.registerFunction(name, options.handler, {\n description: options.description,\n parameters: options.parameters,\n });\n });\n\n onUnmounted(() => {\n client.unregisterFunction(name);\n });\n}\n\nexport interface AgoRoute {\n name: string;\n path: string;\n description: string;\n}\n\n/**\n * Register navigation routes with auto-cleanup on unmount.\n * Works with vue-router's `useRouter().push`.\n *\n * ```ts\n * const router = useRouter();\n * useAgoNavigation((path) => router.push(path), [\n * { name: \"dashboard\", path: \"/dashboard\", description: \"Main dashboard\" },\n * ]);\n * ```\n */\nexport function useAgoNavigation(\n navigate: (path: string) => void,\n routes: AgoRoute[]\n): void {\n const client = useAgo();\n\n onMounted(() => {\n client.registerNavigationFunction(navigate, routes);\n });\n\n onUnmounted(() => {\n client.unregisterFunction(\"navigateToPage\");\n });\n}\n","import { onMounted, onUnmounted } from \"vue\";\nimport type { AgoClientEvents, AgoEventName } from \"../../client/types\";\nimport { useAgo } from \"./useAgo\";\n\n/**\n * Subscribe to AGO client events with auto-cleanup on unmount.\n *\n * ```ts\n * useAgoEvents(\"message:complete\", (msg) => {\n * console.log(\"Got message:\", msg.content);\n * });\n * ```\n */\nexport function useAgoEvents<K extends AgoEventName>(\n event: K,\n handler: (data: AgoClientEvents[K]) => void\n): void {\n const client = useAgo();\n\n onMounted(() => {\n client.on(event, handler);\n });\n\n onUnmounted(() => {\n client.off(event, handler);\n });\n}\n","import { shallowRef, onScopeDispose, type ShallowRef } from \"vue\";\nimport type { Store } from \"../../state/createStore\";\n\n/**\n * Read a framework-agnostic AGO store (`createStore`) as a reactive Vue ref.\n *\n * The ref's `.value` updates on every `store.set(...)`. Mutate through the store,\n * not the ref. A `shallowRef` is used because the store replaces its value\n * wholesale, so deep reactivity would be wasted work.\n *\n * ```ts\n * const cart = createStore({ items: [] as string[] });\n *\n * // in setup():\n * const state = useAgoStore(cart);\n * // template: {{ state.items.length }}\n * ```\n */\nexport function useAgoStore<T>(store: Store<T>): ShallowRef<T> {\n const state = shallowRef(store.get()) as ShallowRef<T>;\n // Subscribe during setup so no updates are missed before mount; clean up when\n // the surrounding effect scope (the component) is disposed.\n const unsubscribe = store.subscribe((next) => {\n state.value = next;\n });\n onScopeDispose(unsubscribe);\n return state;\n}\n"],"mappings":";;;;;AAGA,IAAa,iBAA0C,OAAO,aAAa;;;;;;;;;;;;ACa3E,IAAa,YAAY,EACvB,QAAQ,KAAU,SAA2B;CAC3C,MAAM,SAAS,IAAI,kBAAA,UAAU,QAAQ;AACrC,KAAI,QAAQ,gBAAgB,OAAO;GAEtC;;;;;;;;;;;;;;;;;ACFD,SAAgB,OAAO,QAA+B;AACpD,KAAI,OACF,QAAO,IAAI,kBAAA,UAAU,OAAO;CAG9B,MAAM,UAAA,GAAA,IAAA,QAAgB,eAAe;AACrC,KAAI,CAAC,OACH,OAAM,IAAI,MACR,yEACD;AAEH,QAAO;;;;;;;;;;;ACbT,SAAgB,YAAY,UAA8B,EAAE,EAAE;CAC5D,MAAM,SAAS,QAAQ,UAAU,QAAQ;CAEzC,MAAM,YAAA,GAAA,IAAA,KAA6B,EAAE,CAAC;CACtC,MAAM,kBAAA,GAAA,IAAA,KAAyC,QAAQ,eAAe;CACtE,MAAM,a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;AAEvB,EAAA,GAAA,IAAA,iBAAgB;AACd,SAAO,iBAAiB,MAAM,QAAQ,SAAS;GAC7C,aAAa,QAAQ;GACrB,YAAY,QAAQ;GACrB,CAAC;GACF;AAEF,EAAA,GAAA,IAAA,mBAAkB;AAChB,SAAO,mBAAmB,KAAK;GAC/B;;;;;;;;;;;;;AAoBJ,SAAgB,iBACd,UACA,QACM;CACN,MAAM,SAAS,QAAQ;AAEvB,EAAA,GAAA,IAAA,iBAAgB;AACd,SAAO,2BAA2B,UAAU,OAAO;GACnD;AAEF,EAAA,GAAA,IAAA,mBAAkB;AAChB,SAAO,mBAAmB,iBAAiB;GAC3C;;;;;;;;;;;;;ACrDJ,SAAgB,aACd,OACA,SACM;CACN,MAAM,SAAS,QAAQ;AAEvB,EAAA,GAAA,IAAA,iBAAgB;AACd,SAAO,GAAG,OAAO,QAAQ;GACzB;AAEF,EAAA,GAAA,IAAA,mBAAkB;AAChB,SAAO,IAAI,OAAO,QAAQ;GAC1B;;;;;;;;;;;;;;;;;;;ACPJ,SAAgB,YAAe,OAAgC;CAC7D,MAAM,SAAA,GAAA,IAAA,YAAmB,MAAM,KAAK,CAAC;AAMrC,EAAA,GAAA,IAAA,gBAHoB,MAAM,WAAW,SAAS;AAC5C,QAAM,QAAQ;GAED,CAAY;AAC3B,QAAO"}
package/dist/vue.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"vue.js","names":[],"sources":["../src/vue/symbols.ts","../src/vue/plugin.ts","../src/vue/composables/useAgo.ts","../src/vue/composables/useMessages.ts","../src/vue/composables/useConversation.ts","../src/vue/composables/useChat.ts","../src/vue/composables/useAgoFunction.ts","../src/vue/composables/useAgoEvents.ts","../src/vue/composables/useAgoStore.ts"],"sourcesContent":["import type { InjectionKey } from \"vue\";\nimport type { AgoClient } from \"../client/AgoClient\";\n\nexport const AGO_CLIENT_KEY: InjectionKey<AgoClient> = Symbol(\"ago-client\");\n","import type { App } from \"vue\";\nimport { AgoClient } from \"../client/AgoClient\";\nimport type { AgoConfig } from \"../client/types\";\nimport { AGO_CLIENT_KEY } from \"./symbols\";\n\nexport interface AgoPluginOptions extends AgoConfig {}\n\n/**\n * Vue plugin that provides an AgoClient to the entire app via inject/provide.\n *\n * ```ts\n * import { AgoPlugin } from \"@useago/sdk/vue\";\n *\n * app.use(AgoPlugin, { baseUrl: \"https://YOUR-DOMAIN.useago.com\" });\n * ```\n */\nexport const AgoPlugin = {\n install(app: App, options: AgoPluginOptions) {\n const client = new AgoClient(options);\n app.provide(AGO_CLIENT_KEY, client);\n },\n};\n","import { inject } from \"vue\";\nimport { AgoClient } from \"../../client/AgoClient\";\nimport type { AgoConfig } from \"../../client/types\";\nimport { AGO_CLIENT_KEY } from \"../symbols\";\n\n/**\n * Get or create an AgoClient.\n *\n * - Without args: returns the client from `AgoPlugin` (throws if none).\n * - With config: creates a new client instance.\n *\n * ```ts\n * // From plugin\n * const client = useAgo();\n *\n * // Standalone\n * const client = useAgo({ baseUrl: \"https://YOUR-DOMAIN.useago.com\" });\n * ```\n */\nexport function useAgo(config?: AgoConfig): AgoClient {\n if (config) {\n return new AgoClient(config);\n }\n\n const client = inject(AGO_CLIENT_KEY);\n if (!client) {\n throw new Error(\n \"useAgo(): no AgoClient found. Either pass config or install AgoPlugin.\"\n );\n }\n return client;\n}\n","import { ref, onMounted, onUnmounted } from \"vue\";\nimport type { AgoClient } from \"../../client/AgoClient\";\nimport type { AgoMessage } from \"../../client/types\";\nimport { useAgo } from \"./useAgo\";\n\nexport interface UseMessagesOptions {\n client?: AgoClient;\n conversationId?: string;\n}\n\n/**\n * Composable to manage messages in a conversation.\n *\n * ```ts\n * const { messages, sendMessage, isLoading } = useMessages();\n * ```\n */\nexport function useMessages(options: UseMessagesOptions = {}) {\n const client = options.client ?? useAgo();\n\n const messages = ref<AgoMessage[]>([]);\n const conversationId = ref<string | undefined>(options.conversationId);\n const isLoading = ref(false);\n const error = ref<Error | null>(null);\n\n const handleStart = (data: { conversationId: string; messageId: string }) => {\n if (!conversationId.value) {\n conversationId.value = data.conversationId;\n }\n };\n\n const handleChunk = (data: { content: string; messageId: string }) => {\n const idx = messages.value.findIndex((m: AgoMessage) => m.id === data.messageId);\n if (idx >= 0) {\n messages.value[idx] = {\n ...messages.value[idx],\n content: messages.value[idx].content + data.content,\n };\n }\n };\n\n const handleComplete = (message: AgoMessage) => {\n const idx = messages.value.findIndex((m: AgoMessage) => m.id === message.id);\n if (idx >= 0) {\n messages.value[idx] = message;\n } else {\n messages.value.push(message);\n }\n isLoading.value = false;\n };\n\n const handleError = (data: { error: string }) => {\n error.value = new Error(data.error);\n isLoading.value = false;\n };\n\n onMounted(() => {\n client.on(\"message:start\", handleStart);\n client.on(\"message:chunk\", handleChunk);\n client.on(\"message:complete\", handleComplete);\n client.on(\"message:error\", handleError);\n });\n\n onUnmounted(() => {\n client.off(\"message:start\", handleStart);\n client.off(\"message:chunk\", handleChunk);\n client.off(\"message:complete\", handleComplete);\n client.off(\"message:error\", handleError);\n });\n\n async function sendMessage(content: string, files?: File[]): Promise<AgoMessage | null> {\n isLoading.value = true;\n error.value = null;\n\n // Optimistic user message\n const userMsg: AgoMessage = {\n id: `temp-${Date.now()}`,\n conversationId: conversationId.value || \"\",\n content,\n role: \"user\",\n status: \"DONE\",\n createdAt: new Date(),\n };\n const assistantMsg: AgoMessage = {\n id: `temp-assistant-${Date.now()}`,\n conversationId: conversationId.value || \"\",\n content: \"\",\n role: \"assistant\",\n status: \"IN_PROGRESS\",\n createdAt: new Date(),\n };\n messages.value.push(userMsg, assistantMsg);\n\n try {\n const response = await client.sendMessage(content, {\n conversationId: conversationId.value,\n files,\n });\n if (response.conversationId && !conversationId.value) {\n conversationId.value = response.conversationId;\n }\n // Replace temp messages\n messages.value = messages.value.filter((m: AgoMessage) => !m.id.startsWith(\"temp-\"));\n const updatedUser = { ...userMsg, id: userMsg.id.replace(\"temp-\", \"user-\"), conversationId: response.conversationId };\n if (!messages.value.some((m: AgoMessage) => m.id === response.id)) {\n messages.value.push(updatedUser, response);\n } else {\n messages.value.push(updatedUser);\n }\n return response;\n } catch (err) {\n error.value = err instanceof Error ? err : new Error(\"Failed to send\");\n isLoading.value = false;\n messages.value = messages.value.filter((m: AgoMessage) => !m.id.startsWith(\"temp-\"));\n return null;\n }\n }\n\n function clearMessages() {\n messages.value = [];\n conversationId.value = undefined;\n error.value = null;\n }\n\n return { messages, isLoading, error, conversationId, sendMessage, clearMessages };\n}\n","import { ref, onMounted } from \"vue\";\nimport type { AgoClient } from \"../../client/AgoClient\";\nimport type { Conversation } from \"../../client/types\";\nimport { useAgo } from \"./useAgo\";\n\nexport interface UseConversationOptions {\n client?: AgoClient;\n autoLoad?: boolean;\n}\n\n/**\n * Composable to manage conversations.\n *\n * ```ts\n * const { conversations, selectConversation } = useConversation();\n * ```\n */\nexport function useConversation(options: UseConversationOptions = {}) {\n const client = options.client ?? useAgo();\n const autoLoad = options.autoLoad ?? true;\n\n const conversations = ref<Conversation[]>([]);\n const currentConversation = ref<Conversation | null>(null);\n const isLoading = ref(false);\n const error = ref<Error | null>(null);\n\n async function refreshConversations() {\n isLoading.value = true;\n error.value = null;\n try {\n conversations.value = await client.getConversations();\n } catch (err) {\n error.value = err instanceof Error ? err : new Error(\"Failed to load conversations\");\n } finally {\n isLoading.value = false;\n }\n }\n\n async function selectConversation(id: string) {\n isLoading.value = true;\n error.value = null;\n try {\n currentConversation.value = await client.getConversation(id);\n } catch (err) {\n error.value = err instanceof Error ? err : new Error(\"Failed to load conversation\");\n } finally {\n isLoading.value = false;\n }\n }\n\n function startNewConversation() {\n currentConversation.value = null;\n }\n\n onMounted(() => {\n if (autoLoad) refreshConversations();\n });\n\n return {\n conversations,\n currentConversation,\n isLoading,\n error,\n selectConversation,\n startNewConversation,\n refreshConversations,\n };\n}\n","import { computed } from \"vue\";\nimport type { AgoClient } from \"../../client/AgoClient\";\nimport { useMessages } from \"./useMessages\";\nimport { useConversation } from \"./useConversation\";\n\nexport interface UseChatOptions {\n client?: AgoClient;\n conversationId?: string;\n autoLoad?: boolean;\n}\n\n/**\n * All-in-one composable combining messages + conversations.\n *\n * ```ts\n * const { messages, sendMessage, conversations, selectConversation } = useChat();\n * ```\n */\nexport function useChat(options: UseChatOptions = {}) {\n const msgResult = useMessages({\n client: options.client,\n conversationId: options.conversationId,\n });\n\n const convResult = useConversation({\n client: options.client,\n autoLoad: options.autoLoad,\n });\n\n const error = computed(\n () => msgResult.error.value || convResult.error.value\n );\n\n return {\n // Messages\n messages: msgResult.messages,\n isLoading: msgResult.isLoading,\n error,\n sendMessage: msgResult.sendMessage,\n clearMessages: msgResult.clearMessages,\n conversationId: msgResult.conversationId,\n // Conversations\n conversations: convResult.conversations,\n currentConversation: convResult.currentConversation,\n isConversationsLoading: convResult.isLoading,\n selectConversation: convResult.selectConversation,\n startNewConversation: convResult.startNewConversation,\n refreshConversations: convResult.refreshConversations,\n };\n}\n","import { onMounted, onUnmounted } from \"vue\";\nimport type { ClientFunctionHandler, ClientFunctionSchema } from \"../../functions/types\";\nimport { useAgo } from \"./useAgo\";\n\n/**\n * Register a client-side function with auto-cleanup on unmount.\n *\n * ```ts\n * useAgoFunction(\"showToast\", {\n * description: \"Show a toast\",\n * parameters: { type: \"object\", properties: { message: { type: \"string\" } } },\n * handler: async (args) => { toast(args.message); return { shown: true }; },\n * });\n * ```\n */\nexport function useAgoFunction(\n name: string,\n options: {\n description: string;\n parameters: ClientFunctionSchema[\"parameters\"];\n handler: ClientFunctionHandler;\n }\n): void {\n const client = useAgo();\n\n onMounted(() => {\n client.registerFunction(name, options.handler, {\n description: options.description,\n parameters: options.parameters,\n });\n });\n\n onUnmounted(() => {\n client.unregisterFunction(name);\n });\n}\n\nexport interface AgoRoute {\n name: string;\n path: string;\n description: string;\n}\n\n/**\n * Register navigation routes with auto-cleanup on unmount.\n * Works with vue-router's `useRouter().push`.\n *\n * ```ts\n * const router = useRouter();\n * useAgoNavigation((path) => router.push(path), [\n * { name: \"dashboard\", path: \"/dashboard\", description: \"Main dashboard\" },\n * ]);\n * ```\n */\nexport function useAgoNavigation(\n navigate: (path: string) => void,\n routes: AgoRoute[]\n): void {\n const client = useAgo();\n\n onMounted(() => {\n client.registerNavigationFunction(navigate, routes);\n });\n\n onUnmounted(() => {\n client.unregisterFunction(\"navigateToPage\");\n });\n}\n","import { onMounted, onUnmounted } from \"vue\";\nimport type { AgoClientEvents, AgoEventName } from \"../../client/types\";\nimport { useAgo } from \"./useAgo\";\n\n/**\n * Subscribe to AGO client events with auto-cleanup on unmount.\n *\n * ```ts\n * useAgoEvents(\"message:complete\", (msg) => {\n * console.log(\"Got message:\", msg.content);\n * });\n * ```\n */\nexport function useAgoEvents<K extends AgoEventName>(\n event: K,\n handler: (data: AgoClientEvents[K]) => void\n): void {\n const client = useAgo();\n\n onMounted(() => {\n client.on(event, handler);\n });\n\n onUnmounted(() => {\n client.off(event, handler);\n });\n}\n","import { shallowRef, onScopeDispose, type ShallowRef } from \"vue\";\nimport type { Store } from \"../../state/createStore\";\n\n/**\n * Read a framework-agnostic AGO store (`createStore`) as a reactive Vue ref.\n *\n * The ref's `.value` updates on every `store.set(...)`. Mutate through the store,\n * not the ref. A `shallowRef` is used because the store replaces its value\n * wholesale, so deep reactivity would be wasted work.\n *\n * ```ts\n * const cart = createStore({ items: [] as string[] });\n *\n * // in setup():\n * const state = useAgoStore(cart);\n * // template: {{ state.items.length }}\n * ```\n */\nexport function useAgoStore<T>(store: Store<T>): ShallowRef<T> {\n const state = shallowRef(store.get()) as ShallowRef<T>;\n // Subscribe during setup so no updates are missed before mount; clean up when\n // the surrounding effect scope (the component) is disposed.\n const unsubscribe = store.subscribe((next) => {\n state.value = next;\n });\n onScopeDispose(unsubscribe);\n return state;\n}\n"],"mappings":";;;AAGA,IAAa,iBAA0C,OAAO,aAAa;;;;;;;;;;;;ACa3E,IAAa,YAAY,EACvB,QAAQ,KAAU,SAA2B;CAC3C,MAAM,SAAS,IAAI,UAAU,QAAQ;AACrC,KAAI,QAAQ,gBAAgB,O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