@useago/sdk 1.7.2 → 1.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +71 -0
- package/README.md +43 -1
- package/dist/angular.cjs +1 -1
- package/dist/angular.d.cts +89 -5
- package/dist/angular.d.ts +89 -5
- package/dist/angular.js +11 -7
- package/dist/{createConversationSession-DP90nY71.js → createConversationSession-BaaXBQ5b.js} +3 -3
- package/dist/createConversationSession-CU0b-t1W.cjs +1 -0
- package/dist/{createFormCollector-BivHRIAe.js → createFormCollector-Cf7kGhCB.js} +1 -1
- package/dist/createFormCollector-DfN1xZBy.cjs +1 -0
- package/dist/{createMockClient-BDLW6tVc.js → createMockClient-5YF-ZbVu.js} +22 -21
- package/dist/createMockClient-BZbOe-23.cjs +1 -0
- package/dist/devtools.cjs +61 -12
- package/dist/devtools.d.cts +90 -5
- package/dist/devtools.d.ts +90 -5
- package/dist/devtools.js +225 -73
- package/dist/errors-BLfjXnLB.js +32 -0
- package/dist/errors-o1IB5fEu.cjs +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +100 -3
- package/dist/index.d.ts +100 -3
- package/dist/index.js +77 -75
- package/dist/react.cjs +4 -4
- package/dist/react.d.cts +197 -3
- package/dist/react.d.ts +197 -3
- package/dist/react.js +1034 -752
- package/dist/testing.cjs +1 -1
- package/dist/testing.d.cts +80 -3
- package/dist/testing.d.ts +80 -3
- package/dist/testing.js +1 -1
- package/dist/{AgoClient-DTkBRGFE.js → types-CPga11Of.js} +489 -386
- package/dist/types-D3YQl1jx.cjs +9 -0
- package/dist/vue.cjs +1 -1
- package/dist/vue.d.cts +110 -3
- package/dist/vue.d.ts +110 -3
- package/dist/vue.js +202 -154
- package/dist/widget.cjs +4 -4
- package/dist/widget.d.cts +148 -3
- package/dist/widget.d.ts +148 -3
- package/dist/widget.js +871 -651
- package/llms-full.txt +139 -25
- package/package.json +1 -1
- package/dist/AgoClient-7yXQ6R3O.cjs +0 -9
- package/dist/createConversationSession-Bv6a15E0.cjs +0 -1
- package/dist/createFormCollector-CwfiYn0V.cjs +0 -1
- package/dist/createMockClient-BSNuN3ys.cjs +0 -1
package/dist/vue.js
CHANGED
|
@@ -1,237 +1,285 @@
|
|
|
1
|
-
import { t as
|
|
2
|
-
import { computed as
|
|
3
|
-
var
|
|
4
|
-
const
|
|
5
|
-
t.provide(
|
|
1
|
+
import { n as A, t as D } from "./types-CPga11Of.js";
|
|
2
|
+
import { computed as L, inject as M, onMounted as p, onScopeDispose as R, onUnmounted as C, ref as d, shallowRef as F } from "vue";
|
|
3
|
+
var N = /* @__PURE__ */ Symbol("ago-client"), q = { install(t, n) {
|
|
4
|
+
const e = new A(n);
|
|
5
|
+
t.provide(N, e);
|
|
6
6
|
} };
|
|
7
|
-
function
|
|
8
|
-
if (t) return new
|
|
9
|
-
const
|
|
10
|
-
if (!
|
|
11
|
-
return
|
|
7
|
+
function m(t) {
|
|
8
|
+
if (t) return new A(t);
|
|
9
|
+
const n = M(N);
|
|
10
|
+
if (!n) throw new Error("useAgo(): no AgoClient found. Either pass config or install AgoPlugin.");
|
|
11
|
+
return n;
|
|
12
12
|
}
|
|
13
|
-
function
|
|
14
|
-
const
|
|
15
|
-
|
|
16
|
-
},
|
|
17
|
-
const
|
|
18
|
-
|
|
19
|
-
...
|
|
20
|
-
content:
|
|
13
|
+
function k(t = {}) {
|
|
14
|
+
const n = t.client ?? m(), e = d([]), a = d(t.conversationId), o = d(!1), i = d(null), c = (s) => {
|
|
15
|
+
a.value || (a.value = s.conversationId);
|
|
16
|
+
}, g = (s) => {
|
|
17
|
+
const u = e.value.findIndex((v) => v.id === s.messageId);
|
|
18
|
+
u >= 0 && (e.value[u] = {
|
|
19
|
+
...e.value[u],
|
|
20
|
+
content: e.value[u].content + s.content
|
|
21
21
|
});
|
|
22
|
-
}, h = (
|
|
23
|
-
const
|
|
24
|
-
|
|
25
|
-
},
|
|
26
|
-
i.value = new Error(
|
|
27
|
-
},
|
|
28
|
-
let
|
|
29
|
-
for (let
|
|
30
|
-
const
|
|
31
|
-
if (
|
|
32
|
-
|
|
22
|
+
}, h = (s) => {
|
|
23
|
+
const u = e.value.findIndex((v) => v.id === s.id);
|
|
24
|
+
u >= 0 ? e.value[u] = s : e.value.push(s), o.value = !1;
|
|
25
|
+
}, w = (s) => {
|
|
26
|
+
i.value = new Error(s.error), o.value = !1;
|
|
27
|
+
}, r = () => {
|
|
28
|
+
let s = -1;
|
|
29
|
+
for (let u = e.value.length - 1; u >= 0; u--) {
|
|
30
|
+
const v = e.value[u];
|
|
31
|
+
if (v.role === "assistant" && (v.status === "IN_PROGRESS" || v.status === "WAITING_CLIENT")) {
|
|
32
|
+
s = u;
|
|
33
33
|
break;
|
|
34
34
|
}
|
|
35
35
|
}
|
|
36
|
-
|
|
37
|
-
...
|
|
36
|
+
s >= 0 && (e.value[s].content ? e.value[s] = {
|
|
37
|
+
...e.value[s],
|
|
38
38
|
status: "CANCELED"
|
|
39
|
-
} :
|
|
39
|
+
} : e.value.splice(s, 1)), o.value = !1;
|
|
40
40
|
};
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
}),
|
|
44
|
-
|
|
41
|
+
p(() => {
|
|
42
|
+
n.on("message:start", c), n.on("message:chunk", g), n.on("message:complete", h), n.on("message:error", w), n.on("message:stopped", r);
|
|
43
|
+
}), C(() => {
|
|
44
|
+
n.off("message:start", c), n.off("message:chunk", g), n.off("message:complete", h), n.off("message:error", w), n.off("message:stopped", r);
|
|
45
45
|
});
|
|
46
|
-
async function
|
|
47
|
-
|
|
48
|
-
const
|
|
46
|
+
async function l(s, u) {
|
|
47
|
+
o.value = !0, i.value = null;
|
|
48
|
+
const v = {
|
|
49
49
|
id: `temp-${Date.now()}`,
|
|
50
|
-
conversationId:
|
|
51
|
-
content:
|
|
50
|
+
conversationId: a.value || "",
|
|
51
|
+
content: s,
|
|
52
52
|
role: "user",
|
|
53
53
|
status: "DONE",
|
|
54
54
|
createdAt: /* @__PURE__ */ new Date()
|
|
55
|
-
},
|
|
55
|
+
}, S = {
|
|
56
56
|
id: `temp-assistant-${Date.now()}`,
|
|
57
|
-
conversationId:
|
|
57
|
+
conversationId: a.value || "",
|
|
58
58
|
content: "",
|
|
59
59
|
role: "assistant",
|
|
60
60
|
status: "IN_PROGRESS",
|
|
61
61
|
createdAt: /* @__PURE__ */ new Date()
|
|
62
62
|
};
|
|
63
|
-
|
|
63
|
+
e.value.push(v, S);
|
|
64
64
|
try {
|
|
65
|
-
const
|
|
66
|
-
conversationId:
|
|
67
|
-
files:
|
|
65
|
+
const f = await n.sendMessage(s, {
|
|
66
|
+
conversationId: a.value,
|
|
67
|
+
files: u
|
|
68
68
|
});
|
|
69
|
-
|
|
70
|
-
const
|
|
71
|
-
...
|
|
72
|
-
id:
|
|
73
|
-
conversationId:
|
|
69
|
+
f.conversationId && !a.value && (a.value = f.conversationId), e.value = e.value.filter((b) => !b.id.startsWith("temp-"));
|
|
70
|
+
const I = {
|
|
71
|
+
...v,
|
|
72
|
+
id: v.id.replace("temp-", "user-"),
|
|
73
|
+
conversationId: f.conversationId
|
|
74
74
|
};
|
|
75
|
-
return
|
|
76
|
-
} catch (
|
|
77
|
-
return i.value =
|
|
75
|
+
return e.value.some((b) => b.id === f.id) ? e.value.push(I) : e.value.push(I, f), f;
|
|
76
|
+
} catch (f) {
|
|
77
|
+
return i.value = f instanceof Error ? f : /* @__PURE__ */ new Error("Failed to send"), o.value = !1, e.value = e.value.filter((I) => !I.id.startsWith("temp-")), null;
|
|
78
78
|
}
|
|
79
79
|
}
|
|
80
|
-
async function
|
|
81
|
-
await
|
|
80
|
+
async function E() {
|
|
81
|
+
await n.stop();
|
|
82
82
|
}
|
|
83
|
-
function
|
|
84
|
-
|
|
83
|
+
function y() {
|
|
84
|
+
e.value = [], a.value = void 0, i.value = null;
|
|
85
85
|
}
|
|
86
86
|
return {
|
|
87
|
-
messages:
|
|
88
|
-
isLoading:
|
|
87
|
+
messages: e,
|
|
88
|
+
isLoading: o,
|
|
89
89
|
error: i,
|
|
90
|
-
conversationId:
|
|
91
|
-
sendMessage:
|
|
92
|
-
stop:
|
|
93
|
-
clearMessages:
|
|
90
|
+
conversationId: a,
|
|
91
|
+
sendMessage: l,
|
|
92
|
+
stop: E,
|
|
93
|
+
clearMessages: y
|
|
94
94
|
};
|
|
95
95
|
}
|
|
96
|
-
function
|
|
97
|
-
const
|
|
98
|
-
async function
|
|
96
|
+
function P(t = {}) {
|
|
97
|
+
const n = t.client ?? m(), e = t.autoLoad ?? !0, a = d([]), o = d(null), i = d(!1), c = d(null);
|
|
98
|
+
async function g() {
|
|
99
99
|
i.value = !0, c.value = null;
|
|
100
100
|
try {
|
|
101
|
-
|
|
102
|
-
} catch (
|
|
103
|
-
c.value =
|
|
101
|
+
a.value = (await n.getConversations()).data;
|
|
102
|
+
} catch (r) {
|
|
103
|
+
c.value = r instanceof Error ? r : /* @__PURE__ */ new Error("Failed to load conversations");
|
|
104
104
|
} finally {
|
|
105
105
|
i.value = !1;
|
|
106
106
|
}
|
|
107
107
|
}
|
|
108
|
-
async function h(
|
|
108
|
+
async function h(r) {
|
|
109
109
|
i.value = !0, c.value = null;
|
|
110
110
|
try {
|
|
111
|
-
|
|
112
|
-
} catch (
|
|
113
|
-
c.value =
|
|
111
|
+
o.value = await n.getConversation(r);
|
|
112
|
+
} catch (l) {
|
|
113
|
+
c.value = l instanceof Error ? l : /* @__PURE__ */ new Error("Failed to load conversation");
|
|
114
114
|
} finally {
|
|
115
115
|
i.value = !1;
|
|
116
116
|
}
|
|
117
117
|
}
|
|
118
|
-
function
|
|
119
|
-
|
|
118
|
+
function w() {
|
|
119
|
+
o.value = null;
|
|
120
120
|
}
|
|
121
|
-
return
|
|
122
|
-
|
|
121
|
+
return p(() => {
|
|
122
|
+
e && g();
|
|
123
123
|
}), {
|
|
124
|
-
conversations:
|
|
125
|
-
currentConversation:
|
|
124
|
+
conversations: a,
|
|
125
|
+
currentConversation: o,
|
|
126
126
|
isLoading: i,
|
|
127
127
|
error: c,
|
|
128
128
|
selectConversation: h,
|
|
129
|
-
startNewConversation:
|
|
130
|
-
refreshConversations:
|
|
129
|
+
startNewConversation: w,
|
|
130
|
+
refreshConversations: g
|
|
131
131
|
};
|
|
132
132
|
}
|
|
133
|
-
function
|
|
134
|
-
const
|
|
133
|
+
function O(t = {}) {
|
|
134
|
+
const n = k({
|
|
135
135
|
client: t.client,
|
|
136
136
|
conversationId: t.conversationId
|
|
137
|
-
}),
|
|
137
|
+
}), e = P({
|
|
138
138
|
client: t.client,
|
|
139
139
|
autoLoad: t.autoLoad
|
|
140
|
-
}),
|
|
140
|
+
}), a = L(() => n.error.value || e.error.value);
|
|
141
|
+
return {
|
|
142
|
+
messages: n.messages,
|
|
143
|
+
isLoading: n.isLoading,
|
|
144
|
+
error: a,
|
|
145
|
+
sendMessage: n.sendMessage,
|
|
146
|
+
stop: n.stop,
|
|
147
|
+
clearMessages: n.clearMessages,
|
|
148
|
+
conversationId: n.conversationId,
|
|
149
|
+
conversations: e.conversations,
|
|
150
|
+
currentConversation: e.currentConversation,
|
|
151
|
+
isConversationsLoading: e.isLoading,
|
|
152
|
+
selectConversation: e.selectConversation,
|
|
153
|
+
startNewConversation: e.startNewConversation,
|
|
154
|
+
refreshConversations: e.refreshConversations
|
|
155
|
+
};
|
|
156
|
+
}
|
|
157
|
+
function G(t = {}) {
|
|
158
|
+
const n = t.client ?? m(), e = d({}), a = d(!1), o = d(null), i = /* @__PURE__ */ new Map();
|
|
159
|
+
function c(r) {
|
|
160
|
+
const l = (i.get(r) ?? 0) + 1;
|
|
161
|
+
return i.set(r, l), l;
|
|
162
|
+
}
|
|
163
|
+
const g = (r, l) => i.get(r) === l;
|
|
164
|
+
async function h(r, l, E) {
|
|
165
|
+
const y = c(r);
|
|
166
|
+
a.value = !0, o.value = null;
|
|
167
|
+
try {
|
|
168
|
+
await n.submitFeedback(r, l, E), g(r, y) && (e.value = {
|
|
169
|
+
...e.value,
|
|
170
|
+
[r]: l
|
|
171
|
+
});
|
|
172
|
+
} catch (s) {
|
|
173
|
+
const u = s instanceof Error ? s : /* @__PURE__ */ new Error("Failed to submit feedback");
|
|
174
|
+
throw o.value = u, u;
|
|
175
|
+
} finally {
|
|
176
|
+
a.value = !1;
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
async function w(r, l, E) {
|
|
180
|
+
const y = c(r);
|
|
181
|
+
a.value = !0, o.value = null;
|
|
182
|
+
try {
|
|
183
|
+
const s = await n.submitConversationFeedback(r, l, E);
|
|
184
|
+
return g(r, y) && (e.value = {
|
|
185
|
+
...e.value,
|
|
186
|
+
[s]: l
|
|
187
|
+
}), s;
|
|
188
|
+
} catch (s) {
|
|
189
|
+
const u = s instanceof Error ? s : /* @__PURE__ */ new Error("Failed to submit feedback");
|
|
190
|
+
throw o.value = u, u;
|
|
191
|
+
} finally {
|
|
192
|
+
a.value = !1;
|
|
193
|
+
}
|
|
194
|
+
}
|
|
141
195
|
return {
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
error:
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
clearMessages: e.clearMessages,
|
|
148
|
-
conversationId: e.conversationId,
|
|
149
|
-
conversations: n.conversations,
|
|
150
|
-
currentConversation: n.currentConversation,
|
|
151
|
-
isConversationsLoading: n.isLoading,
|
|
152
|
-
selectConversation: n.selectConversation,
|
|
153
|
-
startNewConversation: n.startNewConversation,
|
|
154
|
-
refreshConversations: n.refreshConversations
|
|
196
|
+
ratings: e,
|
|
197
|
+
isSubmitting: a,
|
|
198
|
+
error: o,
|
|
199
|
+
submitFeedback: h,
|
|
200
|
+
submitConversationFeedback: w
|
|
155
201
|
};
|
|
156
202
|
}
|
|
157
|
-
function
|
|
158
|
-
const
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
description:
|
|
162
|
-
parameters:
|
|
163
|
-
maxResultBytes:
|
|
203
|
+
function B(t, n) {
|
|
204
|
+
const e = m();
|
|
205
|
+
p(() => {
|
|
206
|
+
e.registerFunction(t, n.handler, {
|
|
207
|
+
description: n.description,
|
|
208
|
+
parameters: n.parameters,
|
|
209
|
+
maxResultBytes: n.maxResultBytes
|
|
164
210
|
});
|
|
165
|
-
}),
|
|
166
|
-
|
|
211
|
+
}), C(() => {
|
|
212
|
+
e.unregisterFunction(t);
|
|
167
213
|
});
|
|
168
214
|
}
|
|
169
|
-
function T(t,
|
|
170
|
-
const
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
}),
|
|
174
|
-
|
|
215
|
+
function T(t, n) {
|
|
216
|
+
const e = m();
|
|
217
|
+
p(() => {
|
|
218
|
+
e.registerNavigationFunction(t, n);
|
|
219
|
+
}), C(() => {
|
|
220
|
+
e.unregisterNavigationFunction();
|
|
175
221
|
});
|
|
176
222
|
}
|
|
177
|
-
function W(t,
|
|
178
|
-
const
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
...
|
|
182
|
-
functionName:
|
|
223
|
+
function W(t, n) {
|
|
224
|
+
const e = m(), a = n?.functionName ?? "setPageState";
|
|
225
|
+
p(() => {
|
|
226
|
+
e.registerPageStateFunction(t, {
|
|
227
|
+
...n,
|
|
228
|
+
functionName: a
|
|
183
229
|
});
|
|
184
|
-
}),
|
|
185
|
-
|
|
230
|
+
}), C(() => {
|
|
231
|
+
e.unregisterPageStateFunction(a);
|
|
186
232
|
});
|
|
187
233
|
}
|
|
188
|
-
function
|
|
189
|
-
const
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
}),
|
|
193
|
-
|
|
234
|
+
function K(t, n) {
|
|
235
|
+
const e = m();
|
|
236
|
+
p(() => {
|
|
237
|
+
e.on(t, n);
|
|
238
|
+
}), C(() => {
|
|
239
|
+
e.off(t, n);
|
|
194
240
|
});
|
|
195
241
|
}
|
|
196
242
|
function U(t) {
|
|
197
|
-
const
|
|
198
|
-
return
|
|
199
|
-
|
|
200
|
-
})),
|
|
243
|
+
const n = F(t.get());
|
|
244
|
+
return R(t.subscribe((e) => {
|
|
245
|
+
n.value = e;
|
|
246
|
+
})), n;
|
|
201
247
|
}
|
|
202
248
|
function $() {
|
|
203
|
-
const t =
|
|
204
|
-
|
|
205
|
-
},
|
|
206
|
-
|
|
249
|
+
const t = m(), n = F(null), e = (o) => {
|
|
250
|
+
n.value = o, t.proactive?.shown(o);
|
|
251
|
+
}, a = ({ nudge: o }) => {
|
|
252
|
+
n.value?.id === o.id && (n.value = null);
|
|
207
253
|
};
|
|
208
|
-
return
|
|
209
|
-
t.on("nudge:ready",
|
|
210
|
-
}),
|
|
211
|
-
t.off("nudge:ready",
|
|
254
|
+
return p(() => {
|
|
255
|
+
t.on("nudge:ready", e), t.on("nudge:accepted", a), t.on("nudge:dismissed", a);
|
|
256
|
+
}), C(() => {
|
|
257
|
+
t.off("nudge:ready", e), t.off("nudge:accepted", a), t.off("nudge:dismissed", a);
|
|
212
258
|
}), {
|
|
213
|
-
nudge:
|
|
259
|
+
nudge: n,
|
|
214
260
|
accept: async () => {
|
|
215
|
-
const
|
|
216
|
-
|
|
261
|
+
const o = n.value;
|
|
262
|
+
o && (n.value = null, await t.proactive?.accept(o));
|
|
217
263
|
},
|
|
218
264
|
dismiss: () => {
|
|
219
|
-
const
|
|
220
|
-
|
|
265
|
+
const o = n.value;
|
|
266
|
+
o && (n.value = null, t.proactive?.dismiss(o));
|
|
221
267
|
}
|
|
222
268
|
};
|
|
223
269
|
}
|
|
224
270
|
export {
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
271
|
+
N as AGO_CLIENT_KEY,
|
|
272
|
+
q as AgoPlugin,
|
|
273
|
+
D as FEEDBACK_REASONS,
|
|
274
|
+
m as useAgo,
|
|
275
|
+
K as useAgoEvents,
|
|
276
|
+
B as useAgoFunction,
|
|
230
277
|
T as useAgoNavigation,
|
|
231
278
|
W as useAgoPageState,
|
|
232
279
|
U as useAgoStore,
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
280
|
+
O as useChat,
|
|
281
|
+
P as useConversation,
|
|
282
|
+
G as useFeedback,
|
|
283
|
+
k as useMessages,
|
|
236
284
|
$ as useProactiveNudge
|
|
237
285
|
};
|