@useago/sdk 1.7.2 → 1.12.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.
Files changed (51) hide show
  1. package/CHANGELOG.md +175 -0
  2. package/README.md +96 -1
  3. package/dist/angular.cjs +1 -1
  4. package/dist/angular.d.cts +402 -5
  5. package/dist/angular.d.ts +402 -5
  6. package/dist/angular.js +11 -7
  7. package/dist/{createConversationSession-DP90nY71.js → createConversationSession-B1Qn-y0I.js} +3 -3
  8. package/dist/createConversationSession-B3v_xOU7.cjs +1 -0
  9. package/dist/createFormCollector-FvwDOqnV.cjs +1 -0
  10. package/dist/{createFormCollector-BivHRIAe.js → createFormCollector-m79zk_NA.js} +1 -1
  11. package/dist/createMockClient-BEOXI8yW.cjs +1 -0
  12. package/dist/{createMockClient-BDLW6tVc.js → createMockClient-Beao82tu.js} +31 -18
  13. package/dist/devtools.cjs +61 -12
  14. package/dist/devtools.d.cts +403 -5
  15. package/dist/devtools.d.ts +403 -5
  16. package/dist/devtools.js +225 -73
  17. package/dist/errors-BLfjXnLB.js +32 -0
  18. package/dist/errors-o1IB5fEu.cjs +1 -0
  19. package/dist/index.cjs +1 -1
  20. package/dist/index.d.cts +489 -7
  21. package/dist/index.d.ts +489 -7
  22. package/dist/index.js +124 -118
  23. package/dist/react.cjs +4 -4
  24. package/dist/react.d.cts +510 -3
  25. package/dist/react.d.ts +510 -3
  26. package/dist/react.js +1036 -752
  27. package/dist/sheetController-BThJRtOu.cjs +1 -0
  28. package/dist/sheetController-aEKXIvjk.js +343 -0
  29. package/dist/testing.cjs +1 -1
  30. package/dist/testing.d.cts +393 -3
  31. package/dist/testing.d.ts +393 -3
  32. package/dist/testing.js +1 -1
  33. package/dist/types-Ct1hlKwg.js +2408 -0
  34. package/dist/types-mcW8vB1U.cjs +10 -0
  35. package/dist/vue.cjs +1 -1
  36. package/dist/vue.d.cts +615 -3
  37. package/dist/vue.d.ts +615 -3
  38. package/dist/vue.js +202 -154
  39. package/dist/widget.cjs +6 -4
  40. package/dist/widget.d.cts +733 -5
  41. package/dist/widget.d.ts +733 -5
  42. package/dist/widget.js +3996 -786
  43. package/llms-full.txt +264 -31
  44. package/package.json +1 -1
  45. package/dist/AgoClient-7yXQ6R3O.cjs +0 -9
  46. package/dist/AgoClient-DTkBRGFE.js +0 -1965
  47. package/dist/createConversationSession-Bv6a15E0.cjs +0 -1
  48. package/dist/createFormCollector-CwfiYn0V.cjs +0 -1
  49. package/dist/createMockClient-BSNuN3ys.cjs +0 -1
  50. package/dist/sheetController-CBUVOroo.js +0 -205
  51. package/dist/sheetController-DY-sC13T.cjs +0 -1
package/dist/vue.js CHANGED
@@ -1,237 +1,285 @@
1
- import { t as N } from "./AgoClient-DTkBRGFE.js";
2
- import { computed as R, inject as F, onMounted as f, onScopeDispose as P, onUnmounted as m, ref as v, shallowRef as y } from "vue";
3
- var A = /* @__PURE__ */ Symbol("ago-client"), k = { install(t, e) {
4
- const n = new N(e);
5
- t.provide(A, n);
1
+ import { n as A, t as D } from "./types-Ct1hlKwg.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 g(t) {
8
- if (t) return new N(t);
9
- const e = F(A);
10
- if (!e) throw new Error("useAgo(): no AgoClient found. Either pass config or install AgoPlugin.");
11
- return e;
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 x(t = {}) {
14
- const e = t.client ?? g(), n = v([]), s = v(t.conversationId), a = v(!1), i = v(null), c = (o) => {
15
- s.value || (s.value = o.conversationId);
16
- }, p = (o) => {
17
- const r = n.value.findIndex((u) => u.id === o.messageId);
18
- r >= 0 && (n.value[r] = {
19
- ...n.value[r],
20
- content: n.value[r].content + o.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 = (o) => {
23
- const r = n.value.findIndex((u) => u.id === o.id);
24
- r >= 0 ? n.value[r] = o : n.value.push(o), a.value = !1;
25
- }, C = (o) => {
26
- i.value = new Error(o.error), a.value = !1;
27
- }, d = () => {
28
- let o = -1;
29
- for (let r = n.value.length - 1; r >= 0; r--) {
30
- const u = n.value[r];
31
- if (u.role === "assistant" && (u.status === "IN_PROGRESS" || u.status === "WAITING_CLIENT")) {
32
- o = r;
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
- o >= 0 && (n.value[o].content ? n.value[o] = {
37
- ...n.value[o],
36
+ s >= 0 && (e.value[s].content ? e.value[s] = {
37
+ ...e.value[s],
38
38
  status: "CANCELED"
39
- } : n.value.splice(o, 1)), a.value = !1;
39
+ } : e.value.splice(s, 1)), o.value = !1;
40
40
  };
41
- f(() => {
42
- e.on("message:start", c), e.on("message:chunk", p), e.on("message:complete", h), e.on("message:error", C), e.on("message:stopped", d);
43
- }), m(() => {
44
- e.off("message:start", c), e.off("message:chunk", p), e.off("message:complete", h), e.off("message:error", C), e.off("message:stopped", d);
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 I(o, r) {
47
- a.value = !0, i.value = null;
48
- const u = {
46
+ async function l(s, u) {
47
+ o.value = !0, i.value = null;
48
+ const v = {
49
49
  id: `temp-${Date.now()}`,
50
- conversationId: s.value || "",
51
- content: o,
50
+ conversationId: a.value || "",
51
+ content: s,
52
52
  role: "user",
53
53
  status: "DONE",
54
54
  createdAt: /* @__PURE__ */ new Date()
55
- }, M = {
55
+ }, S = {
56
56
  id: `temp-assistant-${Date.now()}`,
57
- conversationId: s.value || "",
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
- n.value.push(u, M);
63
+ e.value.push(v, S);
64
64
  try {
65
- const l = await e.sendMessage(o, {
66
- conversationId: s.value,
67
- files: r
65
+ const f = await n.sendMessage(s, {
66
+ conversationId: a.value,
67
+ files: u
68
68
  });
69
- l.conversationId && !s.value && (s.value = l.conversationId), n.value = n.value.filter((E) => !E.id.startsWith("temp-"));
70
- const w = {
71
- ...u,
72
- id: u.id.replace("temp-", "user-"),
73
- conversationId: l.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 n.value.some((E) => E.id === l.id) ? n.value.push(w) : n.value.push(w, l), l;
76
- } catch (l) {
77
- return i.value = l instanceof Error ? l : /* @__PURE__ */ new Error("Failed to send"), a.value = !1, n.value = n.value.filter((w) => !w.id.startsWith("temp-")), null;
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 L() {
81
- await e.stop();
80
+ async function E() {
81
+ await n.stop();
82
82
  }
83
- function S() {
84
- n.value = [], s.value = void 0, i.value = null;
83
+ function y() {
84
+ e.value = [], a.value = void 0, i.value = null;
85
85
  }
86
86
  return {
87
- messages: n,
88
- isLoading: a,
87
+ messages: e,
88
+ isLoading: o,
89
89
  error: i,
90
- conversationId: s,
91
- sendMessage: I,
92
- stop: L,
93
- clearMessages: S
90
+ conversationId: a,
91
+ sendMessage: l,
92
+ stop: E,
93
+ clearMessages: y
94
94
  };
95
95
  }
96
- function D(t = {}) {
97
- const e = t.client ?? g(), n = t.autoLoad ?? !0, s = v([]), a = v(null), i = v(!1), c = v(null);
98
- async function p() {
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
- s.value = (await e.getConversations()).data;
102
- } catch (d) {
103
- c.value = d instanceof Error ? d : /* @__PURE__ */ new Error("Failed to load conversations");
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(d) {
108
+ async function h(r) {
109
109
  i.value = !0, c.value = null;
110
110
  try {
111
- a.value = await e.getConversation(d);
112
- } catch (I) {
113
- c.value = I instanceof Error ? I : /* @__PURE__ */ new Error("Failed to load conversation");
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 C() {
119
- a.value = null;
118
+ function w() {
119
+ o.value = null;
120
120
  }
121
- return f(() => {
122
- n && p();
121
+ return p(() => {
122
+ e && g();
123
123
  }), {
124
- conversations: s,
125
- currentConversation: a,
124
+ conversations: a,
125
+ currentConversation: o,
126
126
  isLoading: i,
127
127
  error: c,
128
128
  selectConversation: h,
129
- startNewConversation: C,
130
- refreshConversations: p
129
+ startNewConversation: w,
130
+ refreshConversations: g
131
131
  };
132
132
  }
133
- function G(t = {}) {
134
- const e = x({
133
+ function O(t = {}) {
134
+ const n = k({
135
135
  client: t.client,
136
136
  conversationId: t.conversationId
137
- }), n = D({
137
+ }), e = P({
138
138
  client: t.client,
139
139
  autoLoad: t.autoLoad
140
- }), s = R(() => e.error.value || n.error.value);
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
- messages: e.messages,
143
- isLoading: e.isLoading,
144
- error: s,
145
- sendMessage: e.sendMessage,
146
- stop: e.stop,
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 O(t, e) {
158
- const n = g();
159
- f(() => {
160
- n.registerFunction(t, e.handler, {
161
- description: e.description,
162
- parameters: e.parameters,
163
- maxResultBytes: e.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
- }), m(() => {
166
- n.unregisterFunction(t);
211
+ }), C(() => {
212
+ e.unregisterFunction(t);
167
213
  });
168
214
  }
169
- function T(t, e) {
170
- const n = g();
171
- f(() => {
172
- n.registerNavigationFunction(t, e);
173
- }), m(() => {
174
- n.unregisterNavigationFunction();
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, e) {
178
- const n = g(), s = e?.functionName ?? "setPageState";
179
- f(() => {
180
- n.registerPageStateFunction(t, {
181
- ...e,
182
- functionName: s
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
- }), m(() => {
185
- n.unregisterPageStateFunction(s);
230
+ }), C(() => {
231
+ e.unregisterPageStateFunction(a);
186
232
  });
187
233
  }
188
- function B(t, e) {
189
- const n = g();
190
- f(() => {
191
- n.on(t, e);
192
- }), m(() => {
193
- n.off(t, e);
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 e = y(t.get());
198
- return P(t.subscribe((n) => {
199
- e.value = n;
200
- })), e;
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 = g(), e = y(null), n = (a) => {
204
- e.value = a, t.proactive?.shown(a);
205
- }, s = ({ nudge: a }) => {
206
- e.value?.id === a.id && (e.value = null);
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 f(() => {
209
- t.on("nudge:ready", n), t.on("nudge:accepted", s), t.on("nudge:dismissed", s);
210
- }), m(() => {
211
- t.off("nudge:ready", n), t.off("nudge:accepted", s), t.off("nudge:dismissed", s);
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: e,
259
+ nudge: n,
214
260
  accept: async () => {
215
- const a = e.value;
216
- a && (e.value = null, await t.proactive?.accept(a));
261
+ const o = n.value;
262
+ o && (n.value = null, await t.proactive?.accept(o));
217
263
  },
218
264
  dismiss: () => {
219
- const a = e.value;
220
- a && (e.value = null, t.proactive?.dismiss(a));
265
+ const o = n.value;
266
+ o && (n.value = null, t.proactive?.dismiss(o));
221
267
  }
222
268
  };
223
269
  }
224
270
  export {
225
- A as AGO_CLIENT_KEY,
226
- k as AgoPlugin,
227
- g as useAgo,
228
- B as useAgoEvents,
229
- O as useAgoFunction,
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
- G as useChat,
234
- D as useConversation,
235
- x as useMessages,
280
+ O as useChat,
281
+ P as useConversation,
282
+ G as useFeedback,
283
+ k as useMessages,
236
284
  $ as useProactiveNudge
237
285
  };