@useago/sdk 1.7.1 → 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.
Files changed (46) hide show
  1. package/CHANGELOG.md +90 -0
  2. package/README.md +53 -6
  3. package/dist/angular.cjs +1 -1
  4. package/dist/angular.d.cts +89 -5
  5. package/dist/angular.d.ts +89 -5
  6. package/dist/angular.js +11 -7
  7. package/dist/{createConversationSession-Bgvx753t.js → createConversationSession-BaaXBQ5b.js} +3 -3
  8. package/dist/createConversationSession-CU0b-t1W.cjs +1 -0
  9. package/dist/{createFormCollector-CM3qjGcM.js → createFormCollector-Cf7kGhCB.js} +1 -1
  10. package/dist/createFormCollector-DfN1xZBy.cjs +1 -0
  11. package/dist/{createMockClient-BDLW6tVc.js → createMockClient-5YF-ZbVu.js} +22 -21
  12. package/dist/createMockClient-BZbOe-23.cjs +1 -0
  13. package/dist/devtools.cjs +61 -12
  14. package/dist/devtools.d.cts +90 -5
  15. package/dist/devtools.d.ts +90 -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 +100 -3
  21. package/dist/index.d.ts +100 -3
  22. package/dist/index.js +77 -75
  23. package/dist/react.cjs +4 -4
  24. package/dist/react.d.cts +197 -3
  25. package/dist/react.d.ts +197 -3
  26. package/dist/react.js +1034 -752
  27. package/dist/testing.cjs +1 -1
  28. package/dist/testing.d.cts +80 -3
  29. package/dist/testing.d.ts +80 -3
  30. package/dist/testing.js +1 -1
  31. package/dist/{AgoClient-BJjLTOw4.js → types-CPga11Of.js} +489 -386
  32. package/dist/types-D3YQl1jx.cjs +9 -0
  33. package/dist/vue.cjs +1 -1
  34. package/dist/vue.d.cts +110 -3
  35. package/dist/vue.d.ts +110 -3
  36. package/dist/vue.js +202 -154
  37. package/dist/widget.cjs +4 -4
  38. package/dist/widget.d.cts +148 -3
  39. package/dist/widget.d.ts +148 -3
  40. package/dist/widget.js +871 -651
  41. package/llms-full.txt +144 -30
  42. package/package.json +1 -1
  43. package/dist/AgoClient-B_u_d-XS.cjs +0 -9
  44. package/dist/createConversationSession-BCdwAhLF.cjs +0 -1
  45. package/dist/createFormCollector-ssBP8u0p.cjs +0 -1
  46. package/dist/createMockClient-BSNuN3ys.cjs +0 -1
package/dist/index.d.ts CHANGED
@@ -312,9 +312,40 @@ export declare class AgoClient {
312
312
  */
313
313
  submitFormCollector(name: string, values: Record<string, unknown>): Promise<unknown>;
314
314
  /**
315
- * Submit feedback for a message
315
+ * Report an answer: thumbs up/down, optionally with what went wrong.
316
+ *
317
+ * ```ts
318
+ * await client.submitFeedback(message.id, "negative", {
319
+ * reasons: ["inaccurate"],
320
+ * comment: "The price it quoted is from last year.",
321
+ * });
322
+ * ```
323
+ *
324
+ * A bare rating is a reaction (the thumbs counted in the dashboard). Adding a
325
+ * reason or a comment also files it in the feedback list, the analytics and
326
+ * the CSV export, so someone can act on it.
327
+ */
328
+ submitFeedback(messageId: string, rating: FeedbackRating, details?: FeedbackDetails): Promise<void>;
329
+ /**
330
+ * Report a whole conversation ("this chat is not working").
331
+ *
332
+ * ```ts
333
+ * await client.submitConversationFeedback(conversationId, "negative", {
334
+ * reasons: ["information_not_found"],
335
+ * comment: "It never answered my question.",
336
+ * });
337
+ * ```
338
+ *
339
+ * Feedback is stored per message, so this attaches the report to the last
340
+ * answer of the conversation, which is the one the user is reacting to.
341
+ * Returns the message id it landed on.
342
+ *
343
+ * Pass `lastMessageId` when you already have it (the widget does) to skip the
344
+ * lookup round-trip.
316
345
  */
317
- submitFeedback(messageId: string, rating: "positive" | "negative"): Promise<void>;
346
+ submitConversationFeedback(conversationId: string, rating: FeedbackRating, details?: FeedbackDetails & {
347
+ lastMessageId?: string;
348
+ }): Promise<string>;
318
349
  /**
319
350
  * Register a client-side function that AGO can call.
320
351
  * Accepts either a definition object or (name, handler, schema) args.
@@ -919,6 +950,14 @@ export declare interface AgoPageDataSource<T = unknown> {
919
950
  maxResultBytes?: number;
920
951
  }
921
952
 
953
+ /** The verdict part of a setPageState answer, without the page snapshot. */
954
+ export declare interface AgoPageStateEnvelope {
955
+ success: boolean;
956
+ applied: string[];
957
+ unchanged: string[];
958
+ rejected?: Record<string, string>;
959
+ }
960
+
922
961
  /**
923
962
  * Options for {@link AgoClient.registerPageStateFunction}.
924
963
  */
@@ -949,6 +988,15 @@ export declare interface AgoPageStateOptions {
949
988
  settleTimeoutMs?: number;
950
989
  }
951
990
 
991
+ /**
992
+ * What `setPageState` answers the agent. Every non-dropped field the agent sent
993
+ * is accounted for by name, so it can tell a change it made from one that was
994
+ * already true. Dropped placeholders are intentionally omitted.
995
+ */
996
+ export declare interface AgoPageStateResult<TData = unknown> extends AgoPageStateEnvelope {
997
+ data?: TData;
998
+ }
999
+
952
1000
  /**
953
1001
  * Knowledge source citation
954
1002
  */
@@ -978,12 +1026,27 @@ export declare interface AgoStateControl<T = unknown> {
978
1026
  enum?: (string | number)[];
979
1027
  };
980
1028
  };
1029
+ /** String-only: `""` means "clear" instead of being dropped as filler. */
1030
+ clearable?: boolean;
981
1031
  /** Current value → pushed as dynamic context so the agent knows what to change. */
982
1032
  get?: () => T;
983
1033
  /** Apply the state change on the page. May be async. */
984
- set: (value: T) => void | Promise<void>;
1034
+ set: (value: T) => void | AgoStateSetResult | Promise<void | AgoStateSetResult>;
985
1035
  }
986
1036
 
1037
+ /**
1038
+ * Tagged outcome a page setter may return to reject or mark unchanged.
1039
+ *
1040
+ * Returning nothing (void) means APPLY. Returning an unrecognized JS value
1041
+ * (e.g. a string from an assignment expression) is also treated as APPLY.
1042
+ */
1043
+ export declare type AgoStateSetResult = {
1044
+ result: "rejected";
1045
+ reason: string;
1046
+ } | {
1047
+ result: "unchanged";
1048
+ };
1049
+
987
1050
  /**
988
1051
  * SSE stream error
989
1052
  *
@@ -1564,6 +1627,40 @@ export declare class EventEmitter<Events extends Record<string, any> = Record<st
1564
1627
 
1565
1628
  declare type EventHandler<T = unknown> = (data: T) => void;
1566
1629
 
1630
+ /** The four values of {@link FeedbackReason}, in dashboard order. */
1631
+ export declare const FEEDBACK_REASONS: readonly FeedbackReason[];
1632
+
1633
+ /**
1634
+ * Why the user is reporting a message (see `AgoClient.submitFeedback`).
1635
+ *
1636
+ * A rating on its own is a reaction (the thumbs count). Add a reason or a
1637
+ * comment and the report also lands in the feedback dashboard, the analytics
1638
+ * and the CSV export, where someone can act on it.
1639
+ */
1640
+ export declare interface FeedbackDetails {
1641
+ /** What went wrong. Several can apply at once. */
1642
+ reasons?: FeedbackReason[];
1643
+ /** The user's own words. Trimmed server-side; 5000 characters max. */
1644
+ comment?: string;
1645
+ }
1646
+
1647
+ /** Thumbs up / thumbs down on an answer. */
1648
+ export declare type FeedbackRating = "positive" | "negative";
1649
+
1650
+ /**
1651
+ * What went wrong with an answer. These are the four buckets the AGO feedback
1652
+ * dashboard filters and charts on.
1653
+ */
1654
+ export declare type FeedbackReason =
1655
+ /** The answer states something false. */
1656
+ "inaccurate"
1657
+ /** The answer is right but stops short. */
1658
+ | "incomplete"
1659
+ /** The agent could not find the information. */
1660
+ | "information_not_found"
1661
+ /** Something broke: the widget, a tool call, the stream. */
1662
+ | "technical_issue";
1663
+
1567
1664
  /** Human-readable file size (e.g. "12.3 KB"). Empty string when size is unknown. */
1568
1665
  export declare function formatFileSize(bytes?: number): string;
1569
1666
 
package/dist/index.js CHANGED
@@ -1,43 +1,44 @@
1
- import { a as w, c as C, d as y, f as S, i as E, l as b, m as v, o as F, p as T, r as I, s as M, t as U, u as _ } from "./functions-tzyOZNp6.js";
2
- import { C as L, S as N, T as x, _ as D, a as G, b as c, c as O, d as R, f as q, g as P, h as H, l as J, m as j, n as z, o as B, p as V, r as W, s as X, t as p, u as Y, v as $, w as K, x as Q, y as Z } from "./AgoClient-BJjLTOw4.js";
3
- import { t as oe } from "./autoContinue-CC8K9mBU.js";
4
- import { t as re } from "./createConversationSession-Bgvx753t.js";
5
- import { n as ne, r as se, t as ie } from "./createFormCollector-CM3qjGcM.js";
6
- import { t as ge } from "./createMockClient-BDLW6tVc.js";
1
+ import { a as w, c as C, d as E, f as y, i as S, l as b, m as v, o as F, p as I, r as M, s as T, t as _, u as U } from "./functions-tzyOZNp6.js";
2
+ import { _ as N, b as D, c as L, d as O, f as R, g as x, h as G, i as q, l as P, m as B, n as c, o as H, p as J, r as j, s as z, t as K, u as V, v as W, x as X, y as Y } from "./types-CPga11Of.js";
3
+ import { a as Q, i as Z, n as p, r as ee, t as oe } from "./errors-BLfjXnLB.js";
4
+ import { t as re } from "./autoContinue-CC8K9mBU.js";
5
+ import { t as ne } from "./createConversationSession-BaaXBQ5b.js";
6
+ import { n as ie, r as ue, t as ge } from "./createFormCollector-Cf7kGhCB.js";
7
+ import { t as fe } from "./createMockClient-5YF-ZbVu.js";
7
8
  import "./testing.js";
8
- function me(e) {
9
+ function de(e) {
9
10
  return e;
10
11
  }
11
- function le(e, o) {
12
+ function ce(e, o) {
12
13
  return e.on("message:complete", o), () => e.off("message:complete", o);
13
14
  }
14
- function de(e, o) {
15
+ function pe(e, o) {
15
16
  return e.on("message:chunk", o), () => e.off("message:chunk", o);
16
17
  }
17
- function ce(e, o) {
18
+ function Ae(e, o) {
18
19
  return e.on("message:start", o), () => e.off("message:start", o);
19
20
  }
20
- function pe(e, o) {
21
+ function he(e, o) {
21
22
  return e.on("message:error", o), () => e.off("message:error", o);
22
23
  }
23
- function Ae(e, o) {
24
+ function we(e, o) {
24
25
  return e.on("toolCall:received", o), () => e.off("toolCall:received", o);
25
26
  }
26
- function he(e, o) {
27
+ function Ce(e, o) {
27
28
  return e.on("form:submitted", o), () => e.off("form:submitted", o);
28
29
  }
29
- function we(e, o) {
30
+ function Ee(e, o) {
30
31
  return e.on("form:error", o), () => e.off("form:error", o);
31
32
  }
32
- function Ce(e, o) {
33
+ function ye(e, o) {
33
34
  return e.on("function:invoke", o), () => e.off("function:invoke", o);
34
35
  }
35
- async function* ye(e, o, u) {
36
+ async function* Se(e, o, u) {
36
37
  const n = [];
37
38
  let r = null, a = !1;
38
39
  const g = (s) => {
39
40
  n.push(s), r?.();
40
- }, f = (s) => g({
41
+ }, m = (s) => g({
41
42
  type: "start",
42
43
  data: s
43
44
  }), t = (s) => g({
@@ -48,7 +49,7 @@ async function* ye(e, o, u) {
48
49
  type: "complete",
49
50
  data: s
50
51
  }), a = !0, r?.();
51
- }, m = (s) => {
52
+ }, f = (s) => {
52
53
  g({
53
54
  type: "error",
54
55
  data: s
@@ -59,7 +60,7 @@ async function* ye(e, o, u) {
59
60
  }), d = () => {
60
61
  a = !0, r?.();
61
62
  };
62
- e.on("message:start", f), e.on("message:chunk", t), e.on("message:complete", i), e.on("message:error", m), e.on("message:stopped", d), e.on("toolCall:received", l), e.sendMessage(o, u).catch(() => {
63
+ e.on("message:start", m), e.on("message:chunk", t), e.on("message:complete", i), e.on("message:error", f), e.on("message:stopped", d), e.on("toolCall:received", l), e.sendMessage(o, u).catch(() => {
63
64
  a = !0, r?.();
64
65
  });
65
66
  try {
@@ -67,7 +68,7 @@ async function* ye(e, o, u) {
67
68
  r = s;
68
69
  }), r = null);
69
70
  } finally {
70
- e.off("message:start", f), e.off("message:chunk", t), e.off("message:complete", i), e.off("message:error", m), e.off("message:stopped", d), e.off("toolCall:received", l);
71
+ e.off("message:start", m), e.off("message:chunk", t), e.off("message:complete", i), e.off("message:error", f), e.off("message:stopped", d), e.off("toolCall:received", l);
71
72
  }
72
73
  }
73
74
  function A(e) {
@@ -86,7 +87,7 @@ function A(e) {
86
87
  i && (o = o || i.getAttribute("data-ago-base-url") || void 0, u = u || i.getAttribute("data-ago-widget-id") || void 0, n = n || i.getAttribute("data-ago-agent") || i.getAttribute("data-ago-agent-id") || void 0, r = r || i.getAttribute("data-ago-permission") || void 0, a = a || i.getAttribute("data-ago-user-email") || void 0);
87
88
  }
88
89
  o = e?.baseUrl || o, u = e?.widgetId || u, n = e?.agent || e?.defaultAgentId || n, r = e?.permission || r, a = e?.userEmail || a, g = e?.userJwt || g;
89
- const f = e?.debug;
90
+ const m = e?.debug;
90
91
  return o ? {
91
92
  baseUrl: o,
92
93
  widgetId: u,
@@ -94,75 +95,76 @@ function A(e) {
94
95
  permission: r,
95
96
  userEmail: a,
96
97
  userJwt: g,
97
- debug: f
98
+ debug: m
98
99
  } : null;
99
100
  }
100
- function Se(e) {
101
+ function be(e) {
101
102
  const o = A(e);
102
- if (!o) throw new c('createAgo(): could not detect AGO configuration. Set window.AGO, add <meta name="ago-base-url">, or pass { baseUrl } explicitly.', "config_missing_base_url");
103
- return new p(o);
103
+ if (!o) throw new p('createAgo(): could not detect AGO configuration. Set window.AGO, add <meta name="ago-base-url">, or pass { baseUrl } explicitly.', "config_missing_base_url");
104
+ return new c(o);
104
105
  }
105
- function Ee(e, o) {
106
+ function ve(e, o) {
106
107
  return {
107
108
  ...e,
108
109
  handler: o
109
110
  };
110
111
  }
111
112
  export {
112
- K as ActivityLedger,
113
- Z as AgoApiError,
114
- p as AgoClient,
115
- c as AgoError,
116
- Q as AgoFunctionError,
117
- N as AgoNetworkError,
118
- L as AgoStreamError,
119
- Y as ClientContextRegistry,
120
- x as DEFAULT_MAX_ACTIVITY_ENTRIES,
121
- W as EventEmitter,
122
- D as FunctionRegistry,
123
- O as SSEHandler,
124
- P as SignalCollector,
125
- oe as attachAutoContinueAfterNavigation,
113
+ D as ActivityLedger,
114
+ oe as AgoApiError,
115
+ c as AgoClient,
116
+ p as AgoError,
117
+ ee as AgoFunctionError,
118
+ Z as AgoNetworkError,
119
+ Q as AgoStreamError,
120
+ O as ClientContextRegistry,
121
+ X as DEFAULT_MAX_ACTIVITY_ENTRIES,
122
+ q as EventEmitter,
123
+ K as FEEDBACK_REASONS,
124
+ W as FunctionRegistry,
125
+ P as SSEHandler,
126
+ N as SignalCollector,
127
+ re as attachAutoContinueAfterNavigation,
126
128
  A as autoDetectConfig,
127
- G as canInlineImage,
128
- U as copyToClipboard,
129
- Se as createAgo,
129
+ H as canInlineImage,
130
+ _ as copyToClipboard,
131
+ be as createAgo,
130
132
  R as createAgoProactive,
131
- re as createConversationSession,
132
- ie as createFormCollector,
133
- ye as createMessageStream,
134
- ge as createMockClient,
135
- H as createStore,
136
- me as defineFunction,
137
- ne as deriveFormStatus,
138
- B as formatFileSize,
139
- I as getLocalStorage,
140
- E as getUserLocation,
133
+ ne as createConversationSession,
134
+ ge as createFormCollector,
135
+ Se as createMessageStream,
136
+ fe as createMockClient,
137
+ x as createStore,
138
+ de as defineFunction,
139
+ ie as deriveFormStatus,
140
+ z as formatFileSize,
141
+ M as getLocalStorage,
142
+ S as getUserLocation,
141
143
  w as highlightElement,
142
- J as isStreamNetworkError,
143
- se as loadFormCollector,
144
- $ as logger,
145
- q as matchesRoutePattern,
146
- V as matchesWhen,
147
- we as onFormError,
148
- he as onFormSubmitted,
149
- Ce as onFunctionInvoke,
150
- le as onMessage,
151
- de as onMessageChunk,
152
- pe as onMessageError,
153
- ce as onMessageStart,
154
- Ae as onToolCall,
144
+ V as isStreamNetworkError,
145
+ ue as loadFormCollector,
146
+ Y as logger,
147
+ J as matchesRoutePattern,
148
+ B as matchesWhen,
149
+ Ee as onFormError,
150
+ Ce as onFormSubmitted,
151
+ ye as onFunctionInvoke,
152
+ ce as onMessage,
153
+ pe as onMessageChunk,
154
+ he as onMessageError,
155
+ Ae as onMessageStart,
156
+ we as onToolCall,
155
157
  F as openUrl,
156
- j as partialDeepMatch,
157
- X as safeAttachmentUrl,
158
- M as scrollToElement,
158
+ G as partialDeepMatch,
159
+ L as safeAttachmentUrl,
160
+ T as scrollToElement,
159
161
  C as setLocalStorage,
160
162
  b as setTheme,
161
- _ as showConfirmDialog,
162
- y as showNotification,
163
- S as showToast,
164
- T as submitForm,
163
+ U as showConfirmDialog,
164
+ E as showNotification,
165
+ y as showToast,
166
+ I as submitForm,
165
167
  v as trackEvent,
166
- z as validateConfig,
167
- Ee as withHandler
168
+ j as validateConfig,
169
+ ve as withHandler
168
170
  };