@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.
- package/CHANGELOG.md +90 -0
- package/README.md +53 -6
- 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-Bgvx753t.js → createConversationSession-BaaXBQ5b.js} +3 -3
- package/dist/createConversationSession-CU0b-t1W.cjs +1 -0
- package/dist/{createFormCollector-CM3qjGcM.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-BJjLTOw4.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 +144 -30
- package/package.json +1 -1
- package/dist/AgoClient-B_u_d-XS.cjs +0 -9
- package/dist/createConversationSession-BCdwAhLF.cjs +0 -1
- package/dist/createFormCollector-ssBP8u0p.cjs +0 -1
- package/dist/createMockClient-BSNuN3ys.cjs +0 -1
package/dist/devtools.js
CHANGED
|
@@ -1,97 +1,204 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
1
|
+
import { n as te } from "./errors-BLfjXnLB.js";
|
|
2
|
+
function Q(n, e, i) {
|
|
3
|
+
if (!n) return;
|
|
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;
|
|
6
|
+
}
|
|
7
|
+
function ne(n) {
|
|
8
|
+
let e;
|
|
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
|
+
}
|
|
11
|
+
var oe = "ago_dev_panel_collapsed", ae = "ago_dev_events_collapsed";
|
|
12
|
+
function _(n, e, i, r) {
|
|
13
|
+
n.classList.toggle("collapsed", e);
|
|
14
|
+
const v = n.querySelector(".dev-toggle");
|
|
15
|
+
v && (v.textContent = e ? "▢" : "—", v.title = e ? `Expand ${r}` : `Collapse ${r}`, v.setAttribute("aria-expanded", String(!e)));
|
|
15
16
|
try {
|
|
16
|
-
localStorage.setItem(
|
|
17
|
+
localStorage.setItem(i, e ? "1" : "0");
|
|
17
18
|
} catch {
|
|
18
19
|
}
|
|
19
20
|
}
|
|
20
|
-
function
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
}),
|
|
24
|
-
|
|
21
|
+
function W(n, e, i) {
|
|
22
|
+
n.querySelector(".dev-toggle")?.addEventListener("click", (v) => {
|
|
23
|
+
v.stopPropagation(), _(n, !n.classList.contains("collapsed"), e, i);
|
|
24
|
+
}), n.addEventListener("click", () => {
|
|
25
|
+
n.classList.contains("collapsed") && _(n, !1, e, i);
|
|
25
26
|
});
|
|
26
|
-
let
|
|
27
|
+
let r = !1;
|
|
27
28
|
try {
|
|
28
|
-
|
|
29
|
+
r = localStorage.getItem(e) === "1";
|
|
29
30
|
} catch {
|
|
30
31
|
}
|
|
31
|
-
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
32
|
+
_(n, r, e, i);
|
|
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` : "";
|
|
40
|
+
let w = null, J = null, q = null;
|
|
41
|
+
const Z = () => {
|
|
42
|
+
const t = e.getContextSnapshot()?.entries ?? {};
|
|
43
|
+
return Object.fromEntries(Object.entries(t).map(([o, { name: d, data: a }]) => [o, {
|
|
44
|
+
name: d,
|
|
45
|
+
data: a
|
|
41
46
|
}]));
|
|
42
|
-
},
|
|
43
|
-
|
|
44
|
-
},
|
|
45
|
-
|
|
47
|
+
}, h = () => {
|
|
48
|
+
u || w && (w.textContent = JSON.stringify(Z(), null, 2));
|
|
49
|
+
}, k = (t, o) => {
|
|
50
|
+
u || Q(J, t, o);
|
|
46
51
|
};
|
|
47
|
-
|
|
48
|
-
const
|
|
49
|
-
|
|
50
|
-
},
|
|
51
|
-
|
|
52
|
-
const w = (t.getRegisteredFunctions?.() ?? []).map((o) => o.name).join(", ") || "—";
|
|
53
|
-
s.innerHTML = `
|
|
52
|
+
de();
|
|
53
|
+
const D = typeof i == "string" ? document.querySelector(i) : i instanceof Element ? i : document.body, I = (t) => {
|
|
54
|
+
t.dataset.agoDevSide = v, v === "left" ? (t.style.right = "auto", t.style.left = N || "16px") : N && (t.style.right = N);
|
|
55
|
+
}, p = document.createElement("aside");
|
|
56
|
+
p.id = "ago-dev-panel", p.className = "ago-dev-card", I(p), (D ?? document.body).appendChild(p), p.innerHTML = `
|
|
54
57
|
<div class="dev-head">
|
|
55
58
|
<span class="dev-badge">DEV</span>
|
|
56
|
-
<span class="dev-title">${
|
|
59
|
+
<span class="dev-title">${r ? `DEV TOOLS · ${r}` : "DEV TOOLS · client-side function state — not for production"}</span>
|
|
57
60
|
<button type="button" class="dev-toggle" aria-label="Toggle dev tools">—</button>
|
|
58
61
|
</div>
|
|
59
62
|
<div class="dev-body">
|
|
60
|
-
<div class="dev-fns">Registered functions: <code
|
|
61
|
-
<
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
63
|
+
<div class="dev-fns">Registered functions: <code></code></div>
|
|
64
|
+
<details class="dev-details" open>
|
|
65
|
+
<summary class="dev-section-label">JSON object (built by the agent)</summary>
|
|
66
|
+
<pre class="dev-state" id="ago-dev-state"></pre>
|
|
67
|
+
</details>
|
|
68
|
+
<details class="dev-details" open>
|
|
69
|
+
<summary class="dev-section-label">Function calls</summary>
|
|
70
|
+
<div class="dev-log" id="ago-dev-log"></div>
|
|
71
|
+
</details>
|
|
65
72
|
</div>
|
|
66
|
-
`,
|
|
67
|
-
const
|
|
68
|
-
|
|
73
|
+
`, w = p.querySelector(".dev-state"), J = p.querySelector(".dev-log");
|
|
74
|
+
const M = p.querySelector(".dev-fns code");
|
|
75
|
+
let b = null, L = null, $ = "";
|
|
76
|
+
const m = () => {
|
|
77
|
+
if (u) return;
|
|
78
|
+
const t = e.getRegisteredFunctions?.() ?? [], o = t.map((a) => a.name);
|
|
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) {
|
|
82
|
+
const a = document.createElement("option");
|
|
83
|
+
a.textContent = "(no functions registered)", a.disabled = !0, b.appendChild(a);
|
|
84
|
+
}
|
|
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);
|
|
88
|
+
}
|
|
89
|
+
if (L) {
|
|
90
|
+
const a = t.find((s) => s.name === d);
|
|
91
|
+
L.textContent = a ? JSON.stringify(a.parameters ?? {}, null, 2) : "";
|
|
92
|
+
}
|
|
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 = `
|
|
69
97
|
<div class="dev-head">
|
|
70
98
|
<span class="dev-badge">SSE</span>
|
|
71
|
-
<span class="dev-title">${
|
|
99
|
+
<span class="dev-title">${r ? `SSE EVENT LOG · ${r}` : "SSE EVENT LOG · raw stream messages"}</span>
|
|
72
100
|
<button type="button" class="dev-toggle" aria-label="Toggle SSE event log">—</button>
|
|
73
101
|
</div>
|
|
74
102
|
<div class="dev-body">
|
|
75
103
|
<div class="dev-log" id="ago-dev-event-log"></div>
|
|
76
104
|
</div>
|
|
77
|
-
`,
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
}
|
|
94
|
-
|
|
105
|
+
`, q = g.querySelector(".dev-log"), W(g, ae + R, "SSE event log");
|
|
106
|
+
function j(t) {
|
|
107
|
+
u || Q(q, ne(t), "event");
|
|
108
|
+
}
|
|
109
|
+
function V({ functionName: t, arguments: o }) {
|
|
110
|
+
u || (k(`→ ${t}(${JSON.stringify(o ?? {})})`, "invoke"), m());
|
|
111
|
+
}
|
|
112
|
+
function H({ result: t, error: o }) {
|
|
113
|
+
u || (k(o ? `✗ error: ${o}` : `← ${JSON.stringify(t)}`, o ? "error" : "result"), h(), m());
|
|
114
|
+
}
|
|
115
|
+
function U() {
|
|
116
|
+
u || (h(), m());
|
|
117
|
+
}
|
|
118
|
+
function B(t) {
|
|
119
|
+
if (u) return;
|
|
120
|
+
const o = (t.messages ?? []).flatMap((d) => d.toolCalls ?? []);
|
|
121
|
+
k(`⟳ hydrated "${t.title || t.id}" — replayed ${o.length} tool call${o.length === 1 ? "" : "s"}`, "hydrate"), h();
|
|
122
|
+
}
|
|
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) {
|
|
124
|
+
const t = document.createElement("div");
|
|
125
|
+
t.className = "dev-runner";
|
|
126
|
+
const o = document.createElement("div");
|
|
127
|
+
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);
|
|
130
|
+
const a = document.createElement("div");
|
|
131
|
+
a.className = "dev-runner-row";
|
|
132
|
+
const s = document.createElement("select");
|
|
133
|
+
s.className = "dev-runner-select", a.appendChild(s);
|
|
134
|
+
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;
|
|
136
|
+
const O = document.createElement("div");
|
|
137
|
+
O.className = "dev-section-label", O.textContent = "SCHEMA", t.appendChild(O);
|
|
138
|
+
const z = document.createElement("pre");
|
|
139
|
+
z.className = "dev-runner-schema", t.appendChild(z), L = z, s.addEventListener("change", () => {
|
|
140
|
+
$ = s.value, m();
|
|
141
|
+
});
|
|
142
|
+
const T = document.createElement("div");
|
|
143
|
+
T.className = "dev-section-label", T.textContent = "ARGUMENTS (JSON)", t.appendChild(T);
|
|
144
|
+
const C = document.createElement("textarea");
|
|
145
|
+
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);
|
|
150
|
+
const x = document.createElement("pre");
|
|
151
|
+
x.className = "dev-runner-result", t.appendChild(x);
|
|
152
|
+
const E = document.createElement("div");
|
|
153
|
+
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;
|
|
158
|
+
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
|
+
return;
|
|
163
|
+
}
|
|
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
|
+
return;
|
|
168
|
+
}
|
|
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;
|
|
173
|
+
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);
|
|
178
|
+
}
|
|
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
|
+
else try {
|
|
183
|
+
x.textContent = JSON.stringify(S, null, 2), E.textContent = `${new TextEncoder().encode(JSON.stringify(S)).length} bytes (UTF-8)`;
|
|
184
|
+
} catch {
|
|
185
|
+
x.textContent = "(result not serializable)";
|
|
186
|
+
}
|
|
187
|
+
f.disabled = !1, h(), m();
|
|
188
|
+
}
|
|
189
|
+
}), p.querySelector(".dev-body").appendChild(t);
|
|
190
|
+
}
|
|
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());
|
|
193
|
+
};
|
|
194
|
+
}
|
|
195
|
+
var X = "ago-dev-panel-styles";
|
|
196
|
+
function de() {
|
|
197
|
+
if (document.getElementById(X)) return;
|
|
198
|
+
const n = document.createElement("style");
|
|
199
|
+
n.id = X, n.textContent = se, document.head.appendChild(n);
|
|
200
|
+
}
|
|
201
|
+
var se = `
|
|
95
202
|
.ago-dev-card {
|
|
96
203
|
position: fixed;
|
|
97
204
|
right: 16px;
|
|
@@ -133,7 +240,7 @@ var q = `
|
|
|
133
240
|
cursor: pointer;
|
|
134
241
|
}
|
|
135
242
|
.ago-dev-card .dev-toggle:hover { color: #d7e0e8; border-color: #3a4655; }
|
|
136
|
-
.ago-dev-card .dev-body { display: flex; flex-direction: column; gap: 8px; }
|
|
243
|
+
.ago-dev-card .dev-body { display: flex; flex-direction: column; gap: 8px; min-height: 0; overflow-y: auto; }
|
|
137
244
|
|
|
138
245
|
/* Collapsed: shrink to a small clickable widget showing only the badge. */
|
|
139
246
|
.ago-dev-card.collapsed {
|
|
@@ -156,6 +263,11 @@ var q = `
|
|
|
156
263
|
.ago-dev-card .dev-title { color: #f59e0b; font-size: 11px; line-height: 1.3; }
|
|
157
264
|
.ago-dev-card .dev-fns { color: #7c8a99; font-size: 11px; }
|
|
158
265
|
.ago-dev-card .dev-fns code { color: #9ecbff; }
|
|
266
|
+
.ago-dev-card .dev-details { margin: 0; }
|
|
267
|
+
.ago-dev-card .dev-details > summary { list-style: none; cursor: pointer; }
|
|
268
|
+
.ago-dev-card .dev-details > summary::-webkit-details-marker { display: none; }
|
|
269
|
+
.ago-dev-card .dev-details > summary::before { content: "▸ "; }
|
|
270
|
+
.ago-dev-card .dev-details[open] > summary::before { content: "▾ "; }
|
|
159
271
|
.ago-dev-card .dev-section-label {
|
|
160
272
|
color: #7c8a99;
|
|
161
273
|
text-transform: uppercase;
|
|
@@ -191,7 +303,47 @@ var q = `
|
|
|
191
303
|
.ago-dev-card .dev-log-error { color: #fca5a5; }
|
|
192
304
|
.ago-dev-card .dev-log-hydrate { color: #d8b4fe; }
|
|
193
305
|
.ago-dev-card .dev-log-event { color: #7c8a99; }
|
|
306
|
+
/* Function runner */
|
|
307
|
+
.ago-dev-card .dev-runner { border-top: 1px solid #2a3441; padding-top: 8px; margin-top: 4px; }
|
|
308
|
+
.ago-dev-card .dev-runner-warning { color: #f59e0b; font-size: 10px; margin-bottom: 4px; }
|
|
309
|
+
.ago-dev-card .dev-runner-row { display: flex; gap: 6px; align-items: center; }
|
|
310
|
+
.ago-dev-card .dev-runner-select {
|
|
311
|
+
flex: 1;
|
|
312
|
+
background: #060a0e; color: #d7e0e8; border: 1px solid #2a3441;
|
|
313
|
+
border-radius: 6px; padding: 4px 6px; font: inherit; font-size: 11px;
|
|
314
|
+
}
|
|
315
|
+
.ago-dev-card .dev-runner-btn {
|
|
316
|
+
background: #1a2633; color: #9ecbff; border: 1px solid #2a3441;
|
|
317
|
+
border-radius: 6px; padding: 4px 10px; font: inherit; font-size: 11px;
|
|
318
|
+
cursor: pointer;
|
|
319
|
+
}
|
|
320
|
+
.ago-dev-card .dev-runner-btn:hover { background: #243040; }
|
|
321
|
+
.ago-dev-card .dev-runner-btn:disabled { opacity: .5; cursor: default; }
|
|
322
|
+
.ago-dev-card .dev-runner-btn-sm { padding: 4px 8px; }
|
|
323
|
+
.ago-dev-card .dev-runner-schema {
|
|
324
|
+
margin: 0; padding: 6px 8px; background: #060a0e;
|
|
325
|
+
border-radius: 6px; overflow: auto; max-height: 16vh;
|
|
326
|
+
white-space: pre; color: #7c8a99; font-size: 11px;
|
|
327
|
+
}
|
|
328
|
+
.ago-dev-card .dev-runner-args {
|
|
329
|
+
width: 100%; box-sizing: border-box; min-height: 48px; max-height: 20vh;
|
|
330
|
+
resize: vertical; background: #060a0e; color: #d7e0e8;
|
|
331
|
+
border: 1px solid #2a3441; border-radius: 6px; padding: 6px 8px;
|
|
332
|
+
font: inherit; font-size: 11px;
|
|
333
|
+
}
|
|
334
|
+
.ago-dev-card .dev-runner-status { font-size: 11px; margin-top: 4px; }
|
|
335
|
+
.ago-dev-card .dev-runner-ok { color: #86efac; }
|
|
336
|
+
.ago-dev-card .dev-runner-error { color: #fca5a5; }
|
|
337
|
+
.ago-dev-card .dev-runner-result {
|
|
338
|
+
margin: 0; padding: 6px 8px; background: #060a0e;
|
|
339
|
+
border-radius: 6px; overflow: auto; max-height: 24vh;
|
|
340
|
+
white-space: pre-wrap; word-break: break-word;
|
|
341
|
+
color: #c8e6c9; font-size: 11px;
|
|
342
|
+
}
|
|
343
|
+
.ago-dev-card .dev-runner-result:empty { display: none; }
|
|
344
|
+
.ago-dev-card .dev-runner-bytes { color: #7c8a99; font-size: 10px; margin-top: 2px; }
|
|
345
|
+
.ago-dev-card .dev-runner-bytes:empty { display: none; }
|
|
194
346
|
`;
|
|
195
347
|
export {
|
|
196
|
-
|
|
348
|
+
ce as initDevPanel
|
|
197
349
|
};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
var t = class extends Error {
|
|
2
|
+
constructor(s, r, e) {
|
|
3
|
+
super(s), this.code = r, this.statusCode = e, this.name = "AgoError";
|
|
4
|
+
}
|
|
5
|
+
}, u = class a extends t {
|
|
6
|
+
constructor(r, e, o, n, c, i) {
|
|
7
|
+
super(r, e, o), this.type = n, this.param = c, this.docUrl = i, this.name = "AgoApiError";
|
|
8
|
+
}
|
|
9
|
+
static fromResponse(r, e) {
|
|
10
|
+
const o = r.error;
|
|
11
|
+
return new a(o.doc_url ? `${o.message} See ${o.doc_url}` : o.message, o.code, e, o.type, o.param, o.doc_url);
|
|
12
|
+
}
|
|
13
|
+
}, g = class extends t {
|
|
14
|
+
constructor(s, r) {
|
|
15
|
+
super(s, "network_error"), this.originalError = r, this.name = "AgoNetworkError";
|
|
16
|
+
}
|
|
17
|
+
}, m = class extends t {
|
|
18
|
+
constructor(s, r = "stream_error") {
|
|
19
|
+
super(s, r), this.name = "AgoStreamError";
|
|
20
|
+
}
|
|
21
|
+
}, p = class extends t {
|
|
22
|
+
constructor(s, r, e) {
|
|
23
|
+
super(s, "function_error"), this.functionName = r, this.originalError = e, this.name = "AgoFunctionError";
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
export {
|
|
27
|
+
m as a,
|
|
28
|
+
g as i,
|
|
29
|
+
t as n,
|
|
30
|
+
p as r,
|
|
31
|
+
u as t
|
|
32
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var n=class extends Error{constructor(o,r,t){super(o),this.code=r,this.statusCode=t,this.name="AgoError"}},a=class s extends n{constructor(r,t,e,u,c,i){super(r,t,e),this.type=u,this.param=c,this.docUrl=i,this.name="AgoApiError"}static fromResponse(r,t){const e=r.error;return new s(e.doc_url?`${e.message} See ${e.doc_url}`:e.message,e.code,t,e.type,e.param,e.doc_url)}},g=class extends n{constructor(o,r){super(o,"network_error"),this.originalError=r,this.name="AgoNetworkError"}},m=class extends n{constructor(o,r="stream_error"){super(o,r),this.name="AgoStreamError"}},A=class extends n{constructor(o,r,t){super(o,"function_error"),this.functionName=r,this.originalError=t,this.name="AgoFunctionError"}};Object.defineProperty(exports,"AgoApiError",{enumerable:!0,get:function(){return a}});Object.defineProperty(exports,"AgoError",{enumerable:!0,get:function(){return n}});Object.defineProperty(exports,"AgoFunctionError",{enumerable:!0,get:function(){return A}});Object.defineProperty(exports,"AgoNetworkError",{enumerable:!0,get:function(){return g}});Object.defineProperty(exports,"AgoStreamError",{enumerable:!0,get:function(){return m}});
|
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("./
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("./types-D3YQl1jx.cjs"),m=require("./errors-o1IB5fEu.cjs"),E=require("./autoContinue-CP9pJR-V.cjs"),S=require("./createConversationSession-CU0b-t1W.cjs"),d=require("./createFormCollector-DfN1xZBy.cjs"),w=require("./createMockClient-BZbOe-23.cjs");require("./testing.cjs");const g=require("./functions-CPs7omgM.cjs");function y(e){return e}function F(e,o){return e.on("message:complete",o),()=>e.off("message:complete",o)}function v(e,o){return e.on("message:chunk",o),()=>e.off("message:chunk",o)}function b(e,o){return e.on("message:start",o),()=>e.off("message:start",o)}function M(e,o){return e.on("message:error",o),()=>e.off("message:error",o)}function T(e,o){return e.on("toolCall:received",o),()=>e.off("toolCall:received",o)}function q(e,o){return e.on("form:submitted",o),()=>e.off("form:submitted",o)}function _(e,o){return e.on("form:error",o),()=>e.off("form:error",o)}function I(e,o){return e.on("function:invoke",o),()=>e.off("function:invoke",o)}async function*k(e,o,l){const i=[];let n=null,a=!1;const c=s=>{i.push(s),n?.()},f=s=>c({type:"start",data:s}),r=s=>c({type:"chunk",data:s}),u=s=>{c({type:"complete",data:s}),a=!0,n?.()},A=s=>{c({type:"error",data:s}),a=!0,n?.()},C=s=>c({type:"toolCall",data:s}),h=()=>{a=!0,n?.()};e.on("message:start",f),e.on("message:chunk",r),e.on("message:complete",u),e.on("message:error",A),e.on("message:stopped",h),e.on("toolCall:received",C),e.sendMessage(o,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",f),e.off("message:chunk",r),e.off("message:complete",u),e.off("message:error",A),e.off("message:stopped",h),e.off("toolCall:received",C)}}function p(e){let o,l,i,n,a,c;if(typeof window<"u"&&window.AGO){const r=window.AGO;o=r.basepath,l=r.widgetId,i=r.agent||r.defaultAgent,n=r.permission,a=r.email,c=r.jwt}if(typeof document<"u"){const r=u=>document.querySelector(`meta[name="${u}"]`)?.getAttribute("content")||void 0;o=o||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&&(o=o||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)}o=e?.baseUrl||o,l=e?.widgetId||l,i=e?.agent||e?.defaultAgentId||i,n=e?.permission||n,a=e?.userEmail||a,c=e?.userJwt||c;const f=e?.debug;return o?{baseUrl:o,widgetId:l,agent:i,permission:n,userEmail:a,userJwt:c,debug:f}:null}function N(e){const o=p(e);if(!o)throw new m.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 t.AgoClient(o)}function U(e,o){return{...e,handler:o}}exports.ActivityLedger=t.ActivityLedger;exports.AgoApiError=m.AgoApiError;exports.AgoClient=t.AgoClient;exports.AgoError=m.AgoError;exports.AgoFunctionError=m.AgoFunctionError;exports.AgoNetworkError=m.AgoNetworkError;exports.AgoStreamError=m.AgoStreamError;exports.ClientContextRegistry=t.ClientContextRegistry;exports.DEFAULT_MAX_ACTIVITY_ENTRIES=t.DEFAULT_MAX_ACTIVITY_ENTRIES;exports.EventEmitter=t.EventEmitter;exports.FEEDBACK_REASONS=t.FEEDBACK_REASONS;exports.FunctionRegistry=t.FunctionRegistry;exports.SSEHandler=t.SSEHandler;exports.SignalCollector=t.SignalCollector;exports.attachAutoContinueAfterNavigation=E.attachAutoContinueAfterNavigation;exports.autoDetectConfig=p;exports.canInlineImage=t.canInlineImage;exports.copyToClipboard=g.copyToClipboard;exports.createAgo=N;exports.createAgoProactive=t.createAgoProactive;exports.createConversationSession=S.createConversationSession;exports.createFormCollector=d.createFormCollector;exports.createMessageStream=k;exports.createMockClient=w.createMockClient;exports.createStore=t.createStore;exports.defineFunction=y;exports.deriveFormStatus=d.deriveFormStatus;exports.formatFileSize=t.formatFileSize;exports.getLocalStorage=g.getLocalStorage;exports.getUserLocation=g.getUserLocation;exports.highlightElement=g.highlightElement;exports.isStreamNetworkError=t.isStreamNetworkError;exports.loadFormCollector=d.loadFormCollector;exports.logger=t.logger;exports.matchesRoutePattern=t.matchesRoutePattern;exports.matchesWhen=t.matchesWhen;exports.onFormError=_;exports.onFormSubmitted=q;exports.onFunctionInvoke=I;exports.onMessage=F;exports.onMessageChunk=v;exports.onMessageError=M;exports.onMessageStart=b;exports.onToolCall=T;exports.openUrl=g.openUrl;exports.partialDeepMatch=t.partialDeepMatch;exports.safeAttachmentUrl=t.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=t.validateConfig;exports.withHandler=U;
|
package/dist/index.d.cts
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
|
-
*
|
|
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
|
-
|
|
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
|
|