@useago/sdk 1.12.0 → 1.13.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 (48) hide show
  1. package/CHANGELOG.md +71 -4
  2. package/README.md +73 -0
  3. package/dist/angular.cjs +1 -1
  4. package/dist/angular.d.cts +97 -28
  5. package/dist/angular.d.ts +97 -28
  6. package/dist/angular.js +4 -1
  7. package/dist/{createConversationSession-B1Qn-y0I.js → createConversationSession-BfJg0WyA.js} +1 -1
  8. package/dist/{createConversationSession-B3v_xOU7.cjs → createConversationSession-CiOXKWl0.cjs} +1 -1
  9. package/dist/{createFormCollector-m79zk_NA.js → createFormCollector-DN1xjAv5.js} +1 -1
  10. package/dist/{createFormCollector-FvwDOqnV.cjs → createFormCollector-DnQl77Ko.cjs} +1 -1
  11. package/dist/createMockClient-BPt1gSve.cjs +1 -0
  12. package/dist/{createMockClient-Beao82tu.js → createMockClient-YoYr3pQr.js} +1 -0
  13. package/dist/devtools.cjs +4 -4
  14. package/dist/devtools.d.cts +95 -28
  15. package/dist/devtools.d.ts +95 -28
  16. package/dist/devtools.js +87 -84
  17. package/dist/helpers.d.cts +42 -12
  18. package/dist/helpers.d.ts +42 -12
  19. package/dist/index.cjs +1 -1
  20. package/dist/index.d.cts +101 -35
  21. package/dist/index.d.ts +101 -35
  22. package/dist/index.js +44 -43
  23. package/dist/react.cjs +4 -4
  24. package/dist/react.d.cts +147 -28
  25. package/dist/react.d.ts +147 -28
  26. package/dist/react.js +814 -727
  27. package/dist/speechToText-BV7qxqPF.js +704 -0
  28. package/dist/speechToText-ZciRyyJE.cjs +1 -0
  29. package/dist/testing.cjs +1 -1
  30. package/dist/testing.d.cts +95 -28
  31. package/dist/testing.d.ts +95 -28
  32. package/dist/testing.js +1 -1
  33. package/dist/{types-Ct1hlKwg.js → types-Q7t1peH-.js} +595 -419
  34. package/dist/types-a7teDBnC.cjs +10 -0
  35. package/dist/vue.cjs +1 -1
  36. package/dist/vue.d.cts +105 -28
  37. package/dist/vue.d.ts +105 -28
  38. package/dist/vue.js +103 -101
  39. package/dist/widget.cjs +6 -6
  40. package/dist/widget.d.cts +127 -28
  41. package/dist/widget.d.ts +127 -28
  42. package/dist/widget.js +1717 -1772
  43. package/llms-full.txt +129 -1
  44. package/package.json +1 -1
  45. package/dist/createMockClient-BEOXI8yW.cjs +0 -1
  46. package/dist/sheetController-BThJRtOu.cjs +0 -1
  47. package/dist/sheetController-aEKXIvjk.js +0 -343
  48. package/dist/types-mcW8vB1U.cjs +0 -10
package/dist/devtools.js CHANGED
@@ -1,56 +1,56 @@
1
- import { n as te } from "./errors-BLfjXnLB.js";
2
- function Q(n, e, i) {
1
+ import { n as ne } from "./errors-BLfjXnLB.js";
2
+ function W(n, e, u) {
3
3
  if (!n) return;
4
4
  const r = document.createElement("div");
5
- r.className = `dev-log-line dev-log-${i}`, r.textContent = `${(/* @__PURE__ */ new Date()).toLocaleTimeString()} ${e}`, n.appendChild(r), n.scrollTop = n.scrollHeight;
5
+ r.className = `dev-log-line dev-log-${u}`, r.textContent = `${(/* @__PURE__ */ new Date()).toLocaleTimeString()} ${e}`, n.appendChild(r), n.scrollTop = n.scrollHeight;
6
6
  }
7
- function ne(n) {
7
+ function oe(n) {
8
8
  let e;
9
9
  return n.type ? e = n.type : n.content !== void 0 ? e = "content" : n.full_content !== void 0 ? e = "full_content" : n.status ? e = `status:${n.status}` : e = "event", `${e} ${JSON.stringify(n)}`;
10
10
  }
11
- var oe = "ago_dev_panel_collapsed", ae = "ago_dev_events_collapsed";
12
- function _(n, e, i, r) {
11
+ var ae = "ago_dev_panel_collapsed", re = "ago_dev_events_collapsed";
12
+ function F(n, e, u, r) {
13
13
  n.classList.toggle("collapsed", e);
14
14
  const v = n.querySelector(".dev-toggle");
15
15
  v && (v.textContent = e ? "▢" : "—", v.title = e ? `Expand ${r}` : `Collapse ${r}`, v.setAttribute("aria-expanded", String(!e)));
16
16
  try {
17
- localStorage.setItem(i, e ? "1" : "0");
17
+ localStorage.setItem(u, e ? "1" : "0");
18
18
  } catch {
19
19
  }
20
20
  }
21
- function W(n, e, i) {
21
+ function X(n, e, u) {
22
22
  n.querySelector(".dev-toggle")?.addEventListener("click", (v) => {
23
- v.stopPropagation(), _(n, !n.classList.contains("collapsed"), e, i);
23
+ v.stopPropagation(), F(n, !n.classList.contains("collapsed"), e, u);
24
24
  }), n.addEventListener("click", () => {
25
- n.classList.contains("collapsed") && _(n, !1, e, i);
25
+ n.classList.contains("collapsed") && F(n, !1, e, u);
26
26
  });
27
27
  let r = !1;
28
28
  try {
29
29
  r = localStorage.getItem(e) === "1";
30
30
  } catch {
31
31
  }
32
- _(n, r, e, i);
32
+ F(n, r, e, u);
33
33
  }
34
- var re = 0;
35
- function ce(n) {
36
- const { client: e, target: i, label: r, side: v = "right", enableFunctionRunner: F = !1 } = n;
37
- if (F && typeof e.executeClientFunction != "function") throw new te("initDevPanel: enableFunctionRunner requires client.executeClientFunction. Pass a real AgoClient, not a mock that omits it.", "dev_panel_missing_capability");
38
- let u = !1;
39
- const P = re++, R = P === 0 ? "" : `-${P + 1}`, A = document.querySelectorAll(`#ago-dev-panel[data-ago-dev-side="${v}"]`).length, N = A > 0 ? `${16 + A * 376}px` : "";
34
+ var de = 0;
35
+ function ie(n) {
36
+ const { client: e, target: u, label: r, side: v = "right", enableFunctionRunner: _ = !1 } = n;
37
+ if (_ && typeof e.executeClientFunction != "function") throw new ne("initDevPanel: enableFunctionRunner requires client.executeClientFunction. Pass a real AgoClient, not a mock that omits it.", "dev_panel_missing_capability");
38
+ let d = !1;
39
+ const P = de++, R = P === 0 ? "" : `-${P + 1}`, A = document.querySelectorAll(`#ago-dev-panel[data-ago-dev-side="${v}"]`).length, N = A > 0 ? `${16 + A * 376}px` : "";
40
40
  let w = null, J = null, q = null;
41
- const Z = () => {
41
+ const ee = () => {
42
42
  const t = e.getContextSnapshot()?.entries ?? {};
43
- return Object.fromEntries(Object.entries(t).map(([o, { name: d, data: a }]) => [o, {
44
- name: d,
43
+ return Object.fromEntries(Object.entries(t).map(([o, { name: s, data: a }]) => [o, {
44
+ name: s,
45
45
  data: a
46
46
  }]));
47
47
  }, h = () => {
48
- u || w && (w.textContent = JSON.stringify(Z(), null, 2));
48
+ d || w && (w.textContent = JSON.stringify(ee(), null, 2));
49
49
  }, k = (t, o) => {
50
- u || Q(J, t, o);
50
+ d || W(J, t, o);
51
51
  };
52
- de();
53
- const D = typeof i == "string" ? document.querySelector(i) : i instanceof Element ? i : document.body, I = (t) => {
52
+ se();
53
+ const D = typeof u == "string" ? document.querySelector(u) : u instanceof Element ? u : document.body, I = (t) => {
54
54
  t.dataset.agoDevSide = v, v === "left" ? (t.style.right = "auto", t.style.left = N || "16px") : N && (t.style.right = N);
55
55
  }, p = document.createElement("aside");
56
56
  p.id = "ago-dev-panel", p.className = "ago-dev-card", I(p), (D ?? document.body).appendChild(p), p.innerHTML = `
@@ -73,27 +73,27 @@ function ce(n) {
73
73
  `, w = p.querySelector(".dev-state"), J = p.querySelector(".dev-log");
74
74
  const M = p.querySelector(".dev-fns code");
75
75
  let b = null, L = null, $ = "";
76
- const m = () => {
77
- if (u) return;
76
+ const g = () => {
77
+ if (d) return;
78
78
  const t = e.getRegisteredFunctions?.() ?? [], o = t.map((a) => a.name);
79
79
  if (M && (M.textContent = o.join(", ") || "—"), !b) return;
80
- let d = $;
81
- if (o.includes(d) || (d = o.includes("setPageState") ? "setPageState" : o[0] ?? ""), $ = d, b.innerHTML = "", o.length === 0) {
80
+ let s = $;
81
+ if (o.includes(s) || (s = o.includes("setPageState") ? "setPageState" : o[0] ?? ""), $ = s, b.innerHTML = "", o.length === 0) {
82
82
  const a = document.createElement("option");
83
83
  a.textContent = "(no functions registered)", a.disabled = !0, b.appendChild(a);
84
84
  }
85
85
  for (const a of o) {
86
- const s = document.createElement("option");
87
- s.value = a, s.textContent = a, s.selected = a === d, b.appendChild(s);
86
+ const l = document.createElement("option");
87
+ l.value = a, l.textContent = a, l.selected = a === s, b.appendChild(l);
88
88
  }
89
89
  if (L) {
90
- const a = t.find((s) => s.name === d);
90
+ const a = t.find((l) => l.name === s);
91
91
  L.textContent = a ? JSON.stringify(a.parameters ?? {}, null, 2) : "";
92
92
  }
93
93
  };
94
- W(p, oe + R, "dev tools");
95
- const g = document.createElement("aside");
96
- g.id = "ago-dev-events", g.className = "ago-dev-card", I(g), (D ?? document.body).appendChild(g), g.innerHTML = `
94
+ X(p, ae + R, "dev tools");
95
+ const f = document.createElement("aside");
96
+ f.id = "ago-dev-events", f.className = "ago-dev-card", I(f), (D ?? document.body).appendChild(f), f.innerHTML = `
97
97
  <div class="dev-head">
98
98
  <span class="dev-badge">SSE</span>
99
99
  <span class="dev-title">${r ? `SSE EVENT LOG · ${r}` : "SSE EVENT LOG · raw stream messages"}</span>
@@ -102,103 +102,106 @@ function ce(n) {
102
102
  <div class="dev-body">
103
103
  <div class="dev-log" id="ago-dev-event-log"></div>
104
104
  </div>
105
- `, q = g.querySelector(".dev-log"), W(g, ae + R, "SSE event log");
105
+ `, q = f.querySelector(".dev-log"), X(f, re + R, "SSE event log");
106
106
  function j(t) {
107
- u || Q(q, ne(t), "event");
107
+ d || W(q, oe(t), "event");
108
108
  }
109
109
  function V({ functionName: t, arguments: o }) {
110
- u || (k(`→ ${t}(${JSON.stringify(o ?? {})})`, "invoke"), m());
110
+ d || (k(`→ ${t}(${JSON.stringify(o ?? {})})`, "invoke"), g());
111
111
  }
112
112
  function H({ result: t, error: o }) {
113
- u || (k(o ? `✗ error: ${o}` : `← ${JSON.stringify(t)}`, o ? "error" : "result"), h(), m());
113
+ d || (k(o ? `✗ error: ${o}` : `← ${JSON.stringify(t)}`, o ? "error" : "result"), h(), g());
114
114
  }
115
115
  function U() {
116
- u || (h(), m());
116
+ d || (h(), g());
117
117
  }
118
- function B(t) {
119
- if (u) return;
120
- const o = (t.messages ?? []).flatMap((d) => d.toolCalls ?? []);
118
+ function B() {
119
+ d || g();
120
+ }
121
+ function G(t) {
122
+ if (d) return;
123
+ const o = (t.messages ?? []).flatMap((s) => s.toolCalls ?? []);
121
124
  k(`⟳ hydrated "${t.title || t.id}" — replayed ${o.length} tool call${o.length === 1 ? "" : "s"}`, "hydrate"), h();
122
125
  }
123
- if (e.on("stream:message", j), e.on("function:invoke", V), e.on("function:result", H), e.on("context:changed", U), e.on("conversation:loaded", B), F) {
126
+ if (e.on("stream:message", j), e.on("function:invoke", V), e.on("function:result", H), e.on("context:changed", U), e.on("conversation:loaded", G), e.on("functions:changed", B), _) {
124
127
  const t = document.createElement("div");
125
128
  t.className = "dev-runner";
126
129
  const o = document.createElement("div");
127
130
  o.className = "dev-section-label", o.textContent = "LOCAL FUNCTION RUNNER", t.appendChild(o);
128
- const d = document.createElement("div");
129
- d.className = "dev-runner-warning", d.textContent = "Executes locally. Does not contact the agent backend.", t.appendChild(d);
131
+ const s = document.createElement("div");
132
+ s.className = "dev-runner-warning", s.textContent = "Executes locally. Does not contact the agent backend.", t.appendChild(s);
130
133
  const a = document.createElement("div");
131
134
  a.className = "dev-runner-row";
132
- const s = document.createElement("select");
133
- s.className = "dev-runner-select", a.appendChild(s);
135
+ const l = document.createElement("select");
136
+ l.className = "dev-runner-select", a.appendChild(l);
134
137
  const y = document.createElement("button");
135
- y.type = "button", y.className = "dev-runner-btn dev-runner-btn-sm", y.textContent = "Refresh", y.addEventListener("click", m), a.appendChild(y), t.appendChild(a), b = s;
138
+ y.type = "button", y.className = "dev-runner-btn dev-runner-btn-sm", y.textContent = "Refresh", y.addEventListener("click", g), a.appendChild(y), t.appendChild(a), b = l;
136
139
  const O = document.createElement("div");
137
140
  O.className = "dev-section-label", O.textContent = "SCHEMA", t.appendChild(O);
138
141
  const z = document.createElement("pre");
139
- z.className = "dev-runner-schema", t.appendChild(z), L = z, s.addEventListener("change", () => {
140
- $ = s.value, m();
142
+ z.className = "dev-runner-schema", t.appendChild(z), L = z, l.addEventListener("change", () => {
143
+ $ = l.value, g();
141
144
  });
142
145
  const T = document.createElement("div");
143
146
  T.className = "dev-section-label", T.textContent = "ARGUMENTS (JSON)", t.appendChild(T);
144
147
  const C = document.createElement("textarea");
145
148
  C.className = "dev-runner-args", C.value = "{}", C.spellcheck = !1, t.appendChild(C);
146
- const f = document.createElement("button");
147
- f.type = "button", f.className = "dev-runner-btn", f.textContent = "Run", t.appendChild(f);
148
- const l = document.createElement("div");
149
- l.className = "dev-runner-status", t.appendChild(l);
149
+ const m = document.createElement("button");
150
+ m.type = "button", m.className = "dev-runner-btn", m.textContent = "Run", t.appendChild(m);
151
+ const c = document.createElement("div");
152
+ c.className = "dev-runner-status", t.appendChild(c);
150
153
  const x = document.createElement("pre");
151
154
  x.className = "dev-runner-result", t.appendChild(x);
152
155
  const E = document.createElement("div");
153
156
  E.className = "dev-runner-bytes", t.appendChild(E);
154
- const ee = e.executeClientFunction.bind(e);
155
- f.addEventListener("click", async () => {
156
- l.textContent = "", x.textContent = "", E.textContent = "";
157
- let G;
157
+ const te = e.executeClientFunction.bind(e);
158
+ m.addEventListener("click", async () => {
159
+ c.textContent = "", x.textContent = "", E.textContent = "";
160
+ let Y;
158
161
  try {
159
- const c = JSON.parse(C.value);
160
- if (c === null || Array.isArray(c) || typeof c != "object") {
161
- l.textContent = "Error: arguments must be a JSON object.", l.className = "dev-runner-status dev-runner-error";
162
+ const i = JSON.parse(C.value);
163
+ if (i === null || Array.isArray(i) || typeof i != "object") {
164
+ c.textContent = "Error: arguments must be a JSON object.", c.className = "dev-runner-status dev-runner-error";
162
165
  return;
163
166
  }
164
- G = c;
165
- } catch (c) {
166
- l.textContent = `Parse error: ${c instanceof Error ? c.message : String(c)}`, l.className = "dev-runner-status dev-runner-error";
167
+ Y = i;
168
+ } catch (i) {
169
+ c.textContent = `Parse error: ${i instanceof Error ? i.message : String(i)}`, c.className = "dev-runner-status dev-runner-error";
167
170
  return;
168
171
  }
169
- const Y = s.value;
170
- if (!Y) return;
171
- f.disabled = !0, l.textContent = "Running…", l.className = "dev-runner-status";
172
- let S, K = !1;
172
+ const K = l.value;
173
+ if (!K) return;
174
+ m.disabled = !0, c.textContent = "Running…", c.className = "dev-runner-status";
175
+ let S, Q = !1;
173
176
  try {
174
- S = await ee(Y, G), K = !0;
175
- } catch (c) {
176
- if (u) return;
177
- l.textContent = "Execution error", l.className = "dev-runner-status dev-runner-error", x.textContent = c instanceof Error ? `${c.constructor.name}: ${c.message}` : String(c);
177
+ S = await te(K, Y), Q = !0;
178
+ } catch (i) {
179
+ if (d) return;
180
+ c.textContent = "Execution error", c.className = "dev-runner-status dev-runner-error", x.textContent = i instanceof Error ? `${i.constructor.name}: ${i.message}` : String(i);
178
181
  }
179
- if (!u) {
180
- if (K)
181
- if (l.textContent = "OK", l.className = "dev-runner-status dev-runner-ok", S === void 0) x.textContent = "(undefined)";
182
+ if (!d) {
183
+ if (Q)
184
+ if (c.textContent = "OK", c.className = "dev-runner-status dev-runner-ok", S === void 0) x.textContent = "(undefined)";
182
185
  else try {
183
186
  x.textContent = JSON.stringify(S, null, 2), E.textContent = `${new TextEncoder().encode(JSON.stringify(S)).length} bytes (UTF-8)`;
184
187
  } catch {
185
188
  x.textContent = "(result not serializable)";
186
189
  }
187
- f.disabled = !1, h(), m();
190
+ m.disabled = !1, h(), g();
188
191
  }
189
192
  }), p.querySelector(".dev-body").appendChild(t);
190
193
  }
191
- return m(), h(), () => {
192
- u || (u = !0, e.off("stream:message", j), e.off("function:invoke", V), e.off("function:result", H), e.off("context:changed", U), e.off("conversation:loaded", B), p.remove(), g.remove());
194
+ return g(), h(), () => {
195
+ d || (d = !0, e.off("stream:message", j), e.off("function:invoke", V), e.off("function:result", H), e.off("context:changed", U), e.off("conversation:loaded", G), e.off("functions:changed", B), p.remove(), f.remove());
193
196
  };
194
197
  }
195
- var X = "ago-dev-panel-styles";
196
- function de() {
197
- if (document.getElementById(X)) return;
198
+ var Z = "ago-dev-panel-styles";
199
+ function se() {
200
+ if (document.getElementById(Z)) return;
198
201
  const n = document.createElement("style");
199
- n.id = X, n.textContent = se, document.head.appendChild(n);
202
+ n.id = Z, n.textContent = le, document.head.appendChild(n);
200
203
  }
201
- var se = `
204
+ var le = `
202
205
  .ago-dev-card {
203
206
  position: fixed;
204
207
  right: 16px;
@@ -345,5 +348,5 @@ var se = `
345
348
  .ago-dev-card .dev-runner-bytes:empty { display: none; }
346
349
  `;
347
350
  export {
348
- ce as initDevPanel
351
+ ie as initDevPanel
349
352
  };
@@ -11,22 +11,11 @@
11
11
  * client.registerFunction(fn);
12
12
  * ```
13
13
  */
14
- declare interface ClientFunctionDefinition {
14
+ declare interface ClientFunctionDefinition extends ClientFunctionSettings {
15
15
  name: string;
16
16
  description: string;
17
17
  parameters: ClientFunctionSchema["parameters"];
18
18
  handler: ClientFunctionHandler;
19
- /**
20
- * Max serialized result size in bytes before the SDK truncates it to a
21
- * flagged preview (default: `AgoConfig.maxFunctionResultBytes`, 50 000).
22
- * `Infinity` disables the guard for this function.
23
- */
24
- maxResultBytes?: number;
25
- /**
26
- * Require explicit user approval before this function runs. See
27
- * {@link AgoConfig.approvalPolicy} — pause mode only. ORs with the policy.
28
- */
29
- requiresApproval?: boolean;
30
19
  }
31
20
 
32
21
  /**
@@ -59,6 +48,28 @@ declare interface ClientFunctionSchema {
59
48
  };
60
49
  }
61
50
 
51
+ /** SDK-side function settings that are never sent to the backend. */
52
+ declare interface ClientFunctionSettings {
53
+ /**
54
+ * Max serialized result size in bytes before the SDK truncates it to a
55
+ * flagged preview. Overrides the client-level default
56
+ * (`AgoConfig.maxFunctionResultBytes`, 50 000 by default). `Infinity`
57
+ * disables the guard for this function.
58
+ */
59
+ maxResultBytes?: number;
60
+ /**
61
+ * Require explicit user approval before this function runs. See
62
+ * {@link AgoConfig.approvalPolicy} — pause mode only. ORs with the policy.
63
+ */
64
+ requiresApproval?: boolean;
65
+ /**
66
+ * WebMCP metadata, read only when the bridge is on (`AgoConfig.webmcp`).
67
+ * `false` keeps this function out of WebMCP while leaving it available to the
68
+ * in-app agent.
69
+ */
70
+ webmcp?: WebMCPToolMeta | false;
71
+ }
72
+
62
73
  /**
63
74
  * Copy text to clipboard.
64
75
  */
@@ -133,4 +144,23 @@ export declare const submitForm: ClientFunctionDefinition;
133
144
  */
134
145
  export declare const trackEvent: ClientFunctionDefinition;
135
146
 
147
+ /** The MCP behavior hints AGO has no equivalent for. */
148
+ declare interface WebMCPToolMeta {
149
+ /**
150
+ * Both default to `false`, so only set what is true: `readOnlyHint` marks a
151
+ * function that changes nothing, `untrustedContentHint` one whose result may
152
+ * carry third-party text.
153
+ */
154
+ annotations?: {
155
+ readOnlyHint?: boolean;
156
+ untrustedContentHint?: boolean;
157
+ };
158
+ /**
159
+ * This function navigates. The WebMCP call is held open until the function
160
+ * registry goes quiet, so the caller sees the destination page's tools rather
161
+ * than the departing page's. Already set on the built-in `navigateToPage`.
162
+ */
163
+ navigates?: boolean;
164
+ }
165
+
136
166
  export { }
package/dist/helpers.d.ts CHANGED
@@ -11,22 +11,11 @@
11
11
  * client.registerFunction(fn);
12
12
  * ```
13
13
  */
14
- declare interface ClientFunctionDefinition {
14
+ declare interface ClientFunctionDefinition extends ClientFunctionSettings {
15
15
  name: string;
16
16
  description: string;
17
17
  parameters: ClientFunctionSchema["parameters"];
18
18
  handler: ClientFunctionHandler;
19
- /**
20
- * Max serialized result size in bytes before the SDK truncates it to a
21
- * flagged preview (default: `AgoConfig.maxFunctionResultBytes`, 50 000).
22
- * `Infinity` disables the guard for this function.
23
- */
24
- maxResultBytes?: number;
25
- /**
26
- * Require explicit user approval before this function runs. See
27
- * {@link AgoConfig.approvalPolicy} — pause mode only. ORs with the policy.
28
- */
29
- requiresApproval?: boolean;
30
19
  }
31
20
 
32
21
  /**
@@ -59,6 +48,28 @@ declare interface ClientFunctionSchema {
59
48
  };
60
49
  }
61
50
 
51
+ /** SDK-side function settings that are never sent to the backend. */
52
+ declare interface ClientFunctionSettings {
53
+ /**
54
+ * Max serialized result size in bytes before the SDK truncates it to a
55
+ * flagged preview. Overrides the client-level default
56
+ * (`AgoConfig.maxFunctionResultBytes`, 50 000 by default). `Infinity`
57
+ * disables the guard for this function.
58
+ */
59
+ maxResultBytes?: number;
60
+ /**
61
+ * Require explicit user approval before this function runs. See
62
+ * {@link AgoConfig.approvalPolicy} — pause mode only. ORs with the policy.
63
+ */
64
+ requiresApproval?: boolean;
65
+ /**
66
+ * WebMCP metadata, read only when the bridge is on (`AgoConfig.webmcp`).
67
+ * `false` keeps this function out of WebMCP while leaving it available to the
68
+ * in-app agent.
69
+ */
70
+ webmcp?: WebMCPToolMeta | false;
71
+ }
72
+
62
73
  /**
63
74
  * Copy text to clipboard.
64
75
  */
@@ -133,4 +144,23 @@ export declare const submitForm: ClientFunctionDefinition;
133
144
  */
134
145
  export declare const trackEvent: ClientFunctionDefinition;
135
146
 
147
+ /** The MCP behavior hints AGO has no equivalent for. */
148
+ declare interface WebMCPToolMeta {
149
+ /**
150
+ * Both default to `false`, so only set what is true: `readOnlyHint` marks a
151
+ * function that changes nothing, `untrustedContentHint` one whose result may
152
+ * carry third-party text.
153
+ */
154
+ annotations?: {
155
+ readOnlyHint?: boolean;
156
+ untrustedContentHint?: boolean;
157
+ };
158
+ /**
159
+ * This function navigates. The WebMCP call is held open until the function
160
+ * registry goes quiet, so the caller sees the destination page's tools rather
161
+ * than the departing page's. Already set on the built-in `navigateToPage`.
162
+ */
163
+ navigates?: boolean;
164
+ }
165
+
136
166
  export { }
package/dist/index.cjs CHANGED
@@ -1 +1 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("./types-mcW8vB1U.cjs"),f=require("./errors-o1IB5fEu.cjs"),S=require("./autoContinue-CP9pJR-V.cjs"),p=require("./createConversationSession-B3v_xOU7.cjs"),A=require("./createFormCollector-FvwDOqnV.cjs"),w=require("./createMockClient-BEOXI8yW.cjs");require("./testing.cjs");const g=require("./functions-CPs7omgM.cjs");function F(e){return e}function _(e,t){return e.on("message:complete",t),()=>e.off("message:complete",t)}function y(e,t){return e.on("message:chunk",t),()=>e.off("message:chunk",t)}function M(e,t){return e.on("message:start",t),()=>e.off("message:start",t)}function v(e,t){return e.on("message:error",t),()=>e.off("message:error",t)}function T(e,t){return e.on("toolCall:received",t),()=>e.off("toolCall:received",t)}function R(e,t){return e.on("form:submitted",t),()=>e.off("form:submitted",t)}function b(e,t){return e.on("form:error",t),()=>e.off("form:error",t)}function q(e,t){return e.on("function:invoke",t),()=>e.off("function:invoke",t)}async function*I(e,t,c){const i=[];let n=null,a=!1;const l=s=>{i.push(s),n?.()},m=s=>l({type:"start",data:s}),d=s=>l({type:"chunk",data:s}),r=s=>{l({type:"complete",data:s}),a=!0,n?.()},u=s=>{l({type:"error",data:s}),a=!0,n?.()},E=s=>l({type:"toolCall",data:s}),h=()=>{a=!0,n?.()};e.on("message:start",m),e.on("message:chunk",d),e.on("message:complete",r),e.on("message:error",u),e.on("message:stopped",h),e.on("toolCall:received",E),e.sendMessage(t,c).catch(()=>{a=!0,n?.()});try{for(;!a||i.length>0;)i.length>0?yield i.shift():(await new Promise(s=>{n=s}),n=null)}finally{e.off("message:start",m),e.off("message:chunk",d),e.off("message:complete",r),e.off("message:error",u),e.off("message:stopped",h),e.off("toolCall:received",E)}}function C(e){let t,c,i,n,a,l,m;if(typeof window<"u"&&window.AGO){const r=window.AGO;t=r.basepath,c=r.widgetId,i=r.agent||r.defaultAgent,n=r.permission,a=r.email,l=r.jwt,m=r.metadata}if(typeof document<"u"){const r=u=>document.querySelector(`meta[name="${u}"]`)?.getAttribute("content")||void 0;t=t||r("ago-base-url"),c=c||r("ago-widget-id"),i=i||r("ago-agent")||r("ago-agent-id"),n=n||r("ago-permission"),a=a||r("ago-user-email")}if(typeof document<"u"){const r=[document.body,...Array.from(document.querySelectorAll("script[data-ago-base-url]"))].filter(Boolean);for(const u of r)u&&(t=t||u.getAttribute("data-ago-base-url")||void 0,c=c||u.getAttribute("data-ago-widget-id")||void 0,i=i||u.getAttribute("data-ago-agent")||u.getAttribute("data-ago-agent-id")||void 0,n=n||u.getAttribute("data-ago-permission")||void 0,a=a||u.getAttribute("data-ago-user-email")||void 0)}t=e?.baseUrl||t,c=e?.widgetId||c,i=e?.agent||e?.defaultAgentId||i,n=e?.permission||n,a=e?.userEmail||a,l=e?.userJwt||l,e?.metadata!==void 0&&(m=e.metadata);const d=e?.debug;return t?{baseUrl:t,widgetId:c,agent:i,permission:n,userEmail:a,userJwt:l,metadata:m,debug:d}:null}function U(e){const t=C(e);if(!t)throw new f.AgoError('createAgo(): could not detect AGO configuration. Set window.AGO, add <meta name="ago-base-url">, or pass { baseUrl } explicitly.',"config_missing_base_url");return new o.AgoClient(t)}function D(e,t){return{...e,handler:t}}exports.ActivityLedger=o.ActivityLedger;exports.AgoApiError=f.AgoApiError;exports.AgoClient=o.AgoClient;exports.AgoError=f.AgoError;exports.AgoFunctionError=f.AgoFunctionError;exports.AgoNetworkError=f.AgoNetworkError;exports.AgoStreamError=f.AgoStreamError;exports.ClientContextRegistry=o.ClientContextRegistry;exports.DEFAULT_MAX_ACTIVITY_ENTRIES=o.DEFAULT_MAX_ACTIVITY_ENTRIES;exports.DEFAULT_MAX_ERRORS=o.DEFAULT_MAX_ERRORS;exports.DEFAULT_MAX_ERROR_AGE_MS=o.DEFAULT_MAX_ERROR_AGE_MS;exports.ErrorWatcher=o.ErrorWatcher;exports.EventEmitter=o.EventEmitter;exports.FEEDBACK_REASONS=o.FEEDBACK_REASONS;exports.FunctionRegistry=o.FunctionRegistry;exports.SSEHandler=o.SSEHandler;exports.SignalCollector=o.SignalCollector;exports.attachAutoContinueAfterNavigation=S.attachAutoContinueAfterNavigation;exports.autoDetectConfig=C;exports.canInlineImage=o.canInlineImage;exports.copyToClipboard=g.copyToClipboard;exports.createAgo=U;exports.createAgoProactive=o.createAgoProactive;exports.createConversationSession=p.createConversationSession;exports.createFormCollector=A.createFormCollector;exports.createMessageStream=I;exports.createMockClient=w.createMockClient;exports.createStore=o.createStore;exports.defineFunction=F;exports.deriveFormStatus=A.deriveFormStatus;exports.formatFileSize=o.formatFileSize;exports.getLocalStorage=g.getLocalStorage;exports.getUserLocation=g.getUserLocation;exports.highlightElement=g.highlightElement;exports.isStreamNetworkError=o.isStreamNetworkError;exports.loadFormCollector=A.loadFormCollector;exports.logger=o.logger;exports.matchesRoutePattern=o.matchesRoutePattern;exports.matchesWhen=o.matchesWhen;exports.onFormError=b;exports.onFormSubmitted=R;exports.onFunctionInvoke=q;exports.onMessage=_;exports.onMessageChunk=y;exports.onMessageError=v;exports.onMessageStart=M;exports.onToolCall=T;exports.openUrl=g.openUrl;exports.partialDeepMatch=o.partialDeepMatch;exports.safeAttachmentUrl=o.safeAttachmentUrl;exports.scrollToElement=g.scrollToElement;exports.setLocalStorage=g.setLocalStorage;exports.setTheme=g.setTheme;exports.showConfirmDialog=g.showConfirmDialog;exports.showNotification=g.showNotification;exports.showToast=g.showToast;exports.submitForm=g.submitForm;exports.trackEvent=g.trackEvent;exports.validateConfig=o.validateConfig;exports.withHandler=D;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("./types-a7teDBnC.cjs"),f=require("./errors-o1IB5fEu.cjs"),S=require("./autoContinue-CP9pJR-V.cjs"),p=require("./createConversationSession-CiOXKWl0.cjs"),A=require("./createFormCollector-DnQl77Ko.cjs"),w=require("./createMockClient-BPt1gSve.cjs");require("./testing.cjs");const g=require("./functions-CPs7omgM.cjs");function F(e){return e}function _(e,t){return e.on("message:complete",t),()=>e.off("message:complete",t)}function y(e,t){return e.on("message:chunk",t),()=>e.off("message:chunk",t)}function M(e,t){return e.on("message:start",t),()=>e.off("message:start",t)}function v(e,t){return e.on("message:error",t),()=>e.off("message:error",t)}function T(e,t){return e.on("toolCall:received",t),()=>e.off("toolCall:received",t)}function R(e,t){return e.on("form:submitted",t),()=>e.off("form:submitted",t)}function b(e,t){return e.on("form:error",t),()=>e.off("form:error",t)}function q(e,t){return e.on("function:invoke",t),()=>e.off("function:invoke",t)}async function*I(e,t,l){const i=[];let n=null,a=!1;const c=s=>{i.push(s),n?.()},m=s=>c({type:"start",data:s}),d=s=>c({type:"chunk",data:s}),r=s=>{c({type:"complete",data:s}),a=!0,n?.()},u=s=>{c({type:"error",data:s}),a=!0,n?.()},E=s=>c({type:"toolCall",data:s}),h=()=>{a=!0,n?.()};e.on("message:start",m),e.on("message:chunk",d),e.on("message:complete",r),e.on("message:error",u),e.on("message:stopped",h),e.on("toolCall:received",E),e.sendMessage(t,l).catch(()=>{a=!0,n?.()});try{for(;!a||i.length>0;)i.length>0?yield i.shift():(await new Promise(s=>{n=s}),n=null)}finally{e.off("message:start",m),e.off("message:chunk",d),e.off("message:complete",r),e.off("message:error",u),e.off("message:stopped",h),e.off("toolCall:received",E)}}function C(e){let t,l,i,n,a,c,m;if(typeof window<"u"&&window.AGO){const r=window.AGO;t=r.basepath,l=r.widgetId,i=r.agent||r.defaultAgent,n=r.permission,a=r.email,c=r.jwt,m=r.metadata}if(typeof document<"u"){const r=u=>document.querySelector(`meta[name="${u}"]`)?.getAttribute("content")||void 0;t=t||r("ago-base-url"),l=l||r("ago-widget-id"),i=i||r("ago-agent")||r("ago-agent-id"),n=n||r("ago-permission"),a=a||r("ago-user-email")}if(typeof document<"u"){const r=[document.body,...Array.from(document.querySelectorAll("script[data-ago-base-url]"))].filter(Boolean);for(const u of r)u&&(t=t||u.getAttribute("data-ago-base-url")||void 0,l=l||u.getAttribute("data-ago-widget-id")||void 0,i=i||u.getAttribute("data-ago-agent")||u.getAttribute("data-ago-agent-id")||void 0,n=n||u.getAttribute("data-ago-permission")||void 0,a=a||u.getAttribute("data-ago-user-email")||void 0)}t=e?.baseUrl||t,l=e?.widgetId||l,i=e?.agent||e?.defaultAgentId||i,n=e?.permission||n,a=e?.userEmail||a,c=e?.userJwt||c,e?.metadata!==void 0&&(m=e.metadata);const d=e?.debug;return t?{baseUrl:t,widgetId:l,agent:i,permission:n,language:e?.language,userEmail:a,userJwt:c,metadata:m,debug:d}:null}function U(e){const t=C(e);if(!t)throw new f.AgoError('createAgo(): could not detect AGO configuration. Set window.AGO, add <meta name="ago-base-url">, or pass { baseUrl } explicitly.',"config_missing_base_url");return new o.AgoClient(t)}function D(e,t){return{...e,handler:t}}exports.ActivityLedger=o.ActivityLedger;exports.AgoApiError=f.AgoApiError;exports.AgoClient=o.AgoClient;exports.AgoError=f.AgoError;exports.AgoFunctionError=f.AgoFunctionError;exports.AgoNetworkError=f.AgoNetworkError;exports.AgoStreamError=f.AgoStreamError;exports.ClientContextRegistry=o.ClientContextRegistry;exports.DEFAULT_MAX_ACTIVITY_ENTRIES=o.DEFAULT_MAX_ACTIVITY_ENTRIES;exports.DEFAULT_MAX_ERRORS=o.DEFAULT_MAX_ERRORS;exports.DEFAULT_MAX_ERROR_AGE_MS=o.DEFAULT_MAX_ERROR_AGE_MS;exports.ErrorWatcher=o.ErrorWatcher;exports.EventEmitter=o.EventEmitter;exports.FEEDBACK_REASONS=o.FEEDBACK_REASONS;exports.FunctionRegistry=o.FunctionRegistry;exports.SSEHandler=o.SSEHandler;exports.SignalCollector=o.SignalCollector;exports.attachAutoContinueAfterNavigation=S.attachAutoContinueAfterNavigation;exports.autoDetectConfig=C;exports.canInlineImage=o.canInlineImage;exports.copyToClipboard=g.copyToClipboard;exports.createAgo=U;exports.createAgoProactive=o.createAgoProactive;exports.createConversationSession=p.createConversationSession;exports.createFormCollector=A.createFormCollector;exports.createMessageStream=I;exports.createMockClient=w.createMockClient;exports.createStore=o.createStore;exports.defineFunction=F;exports.deriveFormStatus=A.deriveFormStatus;exports.formatFileSize=o.formatFileSize;exports.getLocalStorage=g.getLocalStorage;exports.getUserLocation=g.getUserLocation;exports.highlightElement=g.highlightElement;exports.isStreamNetworkError=o.isStreamNetworkError;exports.loadFormCollector=A.loadFormCollector;exports.logger=o.logger;exports.matchesRoutePattern=o.matchesRoutePattern;exports.matchesWhen=o.matchesWhen;exports.onFormError=b;exports.onFormSubmitted=R;exports.onFunctionInvoke=q;exports.onMessage=_;exports.onMessageChunk=y;exports.onMessageError=v;exports.onMessageStart=M;exports.onToolCall=T;exports.openUrl=g.openUrl;exports.partialDeepMatch=o.partialDeepMatch;exports.safeAttachmentUrl=o.safeAttachmentUrl;exports.scrollToElement=g.scrollToElement;exports.setLocalStorage=g.setLocalStorage;exports.setTheme=g.setTheme;exports.showConfirmDialog=g.showConfirmDialog;exports.showNotification=g.showNotification;exports.showToast=g.showToast;exports.submitForm=g.submitForm;exports.trackEvent=g.trackEvent;exports.validateConfig=o.validateConfig;exports.withHandler=D;