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