@useago/sdk 0.4.6 → 0.4.7
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/dist/{AgoClient-rvTz2thR.js → AgoClient-BrYhSO5M.js} +32 -26
- package/dist/AgoClient-CPqPT5s6.cjs +6 -0
- package/dist/angular.cjs +1 -1
- package/dist/angular.d.cts +5 -0
- package/dist/angular.d.ts +5 -0
- package/dist/angular.js +1 -1
- package/dist/{createConversationSession-DGcM_Z3f.cjs → createConversationSession-CGRO0bs2.cjs} +1 -1
- package/dist/{createConversationSession-D-eq8VIo.js → createConversationSession-Dmqd80DX.js} +1 -1
- package/dist/{createFormCollector-DON4vdJV.js → createFormCollector-CPS2phYq.js} +51 -50
- package/dist/createFormCollector-DaWZsBsI.cjs +1 -0
- package/dist/devtools.cjs +3 -3
- package/dist/devtools.d.cts +7 -2
- package/dist/devtools.d.ts +7 -2
- package/dist/devtools.js +41 -35
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +14 -0
- package/dist/index.d.ts +14 -0
- package/dist/index.js +3 -3
- package/dist/react.cjs +19 -19
- package/dist/react.d.cts +16 -0
- package/dist/react.d.ts +16 -0
- package/dist/react.js +1516 -1490
- package/dist/vue.cjs +1 -1
- package/dist/vue.d.cts +5 -0
- package/dist/vue.d.ts +5 -0
- package/dist/vue.js +1 -1
- package/dist/widget.cjs +4 -4
- package/dist/widget.d.cts +5 -0
- package/dist/widget.d.ts +5 -0
- package/dist/widget.js +300 -286
- package/package.json +1 -1
- package/dist/AgoClient-D4EL6nva.cjs +0 -6
- package/dist/createFormCollector-IO6bfPQx.cjs +0 -1
package/dist/devtools.js
CHANGED
|
@@ -1,65 +1,71 @@
|
|
|
1
|
-
var
|
|
1
|
+
var p, d, x = () => ({});
|
|
2
2
|
function i() {
|
|
3
|
-
|
|
3
|
+
p && (p.textContent = JSON.stringify(x(), null, 2));
|
|
4
4
|
}
|
|
5
|
-
function
|
|
5
|
+
function r(n, e) {
|
|
6
6
|
if (!d) return;
|
|
7
7
|
const o = document.createElement("div");
|
|
8
|
-
o.className = `dev-log-line dev-log-${e}`, o.textContent = `${(/* @__PURE__ */ new Date()).toLocaleTimeString()} ${
|
|
8
|
+
o.className = `dev-log-line dev-log-${e}`, o.textContent = `${(/* @__PURE__ */ new Date()).toLocaleTimeString()} ${n}`, d.appendChild(o), d.scrollTop = d.scrollHeight;
|
|
9
9
|
}
|
|
10
|
-
var
|
|
11
|
-
function
|
|
12
|
-
|
|
13
|
-
const o =
|
|
10
|
+
var f = "ago_dev_panel_collapsed";
|
|
11
|
+
function c(n, e) {
|
|
12
|
+
n.classList.toggle("collapsed", e);
|
|
13
|
+
const o = n.querySelector(".dev-toggle");
|
|
14
14
|
o && (o.textContent = e ? "▢" : "—", o.title = e ? "Expand dev tools" : "Collapse dev tools", o.setAttribute("aria-expanded", String(!e)));
|
|
15
15
|
try {
|
|
16
|
-
localStorage.setItem(
|
|
16
|
+
localStorage.setItem(f, e ? "1" : "0");
|
|
17
17
|
} catch {
|
|
18
18
|
}
|
|
19
19
|
}
|
|
20
|
-
function
|
|
21
|
-
const { client: e, target: o } =
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
20
|
+
function y(n) {
|
|
21
|
+
const { client: e, target: o } = n;
|
|
22
|
+
x = () => {
|
|
23
|
+
const t = e.getContextSnapshot()?.entries ?? {};
|
|
24
|
+
return Object.fromEntries(Object.entries(t).map(([l, { name: s, data: h }]) => [l, {
|
|
25
|
+
name: s,
|
|
26
|
+
data: h
|
|
27
|
+
}]));
|
|
28
|
+
}, b();
|
|
29
|
+
const u = typeof o == "string" ? document.querySelector(o) : o instanceof Element ? o : document.body, a = document.createElement("aside");
|
|
30
|
+
a.id = "ago-dev-panel", (u ?? document.body).appendChild(a), a.innerHTML = `
|
|
25
31
|
<div class="dev-head">
|
|
26
32
|
<span class="dev-badge">DEV</span>
|
|
27
33
|
<span class="dev-title">DEV TOOLS · client-side function state — not for production</span>
|
|
28
34
|
<button type="button" class="dev-toggle" aria-label="Toggle dev tools">—</button>
|
|
29
35
|
</div>
|
|
30
36
|
<div class="dev-body">
|
|
31
|
-
<div class="dev-fns">Registered functions: <code>${(e.getRegisteredFunctions?.() ?? []).map((
|
|
37
|
+
<div class="dev-fns">Registered functions: <code>${(e.getRegisteredFunctions?.() ?? []).map((t) => t.name).join(", ") || "—"}</code></div>
|
|
32
38
|
<div class="dev-section-label">JSON object (built by the agent)</div>
|
|
33
39
|
<pre class="dev-state" id="ago-dev-state"></pre>
|
|
34
40
|
<div class="dev-section-label">Function calls</div>
|
|
35
41
|
<div class="dev-log" id="ago-dev-log"></div>
|
|
36
42
|
</div>
|
|
37
|
-
`,
|
|
38
|
-
|
|
39
|
-
}),
|
|
40
|
-
|
|
43
|
+
`, p = a.querySelector("#ago-dev-state"), d = a.querySelector("#ago-dev-log"), a.querySelector(".dev-toggle")?.addEventListener("click", (t) => {
|
|
44
|
+
t.stopPropagation(), c(a, !a.classList.contains("collapsed"));
|
|
45
|
+
}), a.addEventListener("click", () => {
|
|
46
|
+
a.classList.contains("collapsed") && c(a, !1);
|
|
41
47
|
});
|
|
42
|
-
let
|
|
48
|
+
let g = !1;
|
|
43
49
|
try {
|
|
44
|
-
|
|
50
|
+
g = localStorage.getItem(f) === "1";
|
|
45
51
|
} catch {
|
|
46
52
|
}
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
}), e.on("function:result", ({ result:
|
|
50
|
-
|
|
51
|
-
}), e.on("context:changed", i), e.on("conversation:loaded", (
|
|
52
|
-
const
|
|
53
|
-
|
|
53
|
+
c(a, g), e.on("function:invoke", ({ functionName: t, arguments: l }) => {
|
|
54
|
+
r(`→ ${t}(${JSON.stringify(l ?? {})})`, "invoke");
|
|
55
|
+
}), e.on("function:result", ({ result: t, error: l }) => {
|
|
56
|
+
r(l ? `✗ error: ${l}` : `← ${JSON.stringify(t)}`, l ? "error" : "result"), i();
|
|
57
|
+
}), e.on("context:changed", i), e.on("conversation:loaded", (t) => {
|
|
58
|
+
const l = (t.messages ?? []).flatMap((s) => s.toolCalls ?? []);
|
|
59
|
+
r(`⟳ hydrated "${t.title || t.id}" — replayed ${l.length} tool call${l.length === 1 ? "" : "s"}`, "hydrate"), i();
|
|
54
60
|
}), i();
|
|
55
61
|
}
|
|
56
|
-
var
|
|
57
|
-
function
|
|
58
|
-
if (document.getElementById(
|
|
59
|
-
const
|
|
60
|
-
|
|
62
|
+
var v = "ago-dev-panel-styles";
|
|
63
|
+
function b() {
|
|
64
|
+
if (document.getElementById(v)) return;
|
|
65
|
+
const n = document.createElement("style");
|
|
66
|
+
n.id = v, n.textContent = m, document.head.appendChild(n);
|
|
61
67
|
}
|
|
62
|
-
var
|
|
68
|
+
var m = `
|
|
63
69
|
#ago-dev-panel {
|
|
64
70
|
position: fixed;
|
|
65
71
|
top: 16px;
|
|
@@ -156,5 +162,5 @@ var b = `
|
|
|
156
162
|
#ago-dev-panel .dev-log-hydrate { color: #d8b4fe; }
|
|
157
163
|
`;
|
|
158
164
|
export {
|
|
159
|
-
|
|
165
|
+
y as initDevPanel
|
|
160
166
|
};
|
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("./AgoClient-
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("./AgoClient-CPqPT5s6.cjs"),m=require("./createFormCollector-DaWZsBsI.cjs"),A=require("./createConversationSession-CGRO0bs2.cjs"),C=require("./createMockClient-zHQ0cjUH.cjs"),g=require("./functions-DsmzgHjC.cjs");function h(e){return e}function E(e,o){return e.on("message:complete",o),()=>e.off("message:complete",o)}function S(e,o){return e.on("message:chunk",o),()=>e.off("message:chunk",o)}function y(e,o){return e.on("message:start",o),()=>e.off("message:start",o)}function b(e,o){return e.on("message:error",o),()=>e.off("message:error",o)}function v(e,o){return e.on("toolCall:received",o),()=>e.off("toolCall:received",o)}function M(e,o){return e.on("function:invoke",o),()=>e.off("function:invoke",o)}async function*k(e,o,l){const n=[];let r=null,a=!1;const c=s=>{n.push(s),r?.()},f=s=>c({type:"start",data:s}),t=s=>c({type:"chunk",data:s}),u=s=>{c({type:"complete",data:s}),a=!0,r?.()},d=s=>{c({type:"error",data:s}),a=!0,r?.()},p=s=>c({type:"toolCall",data:s});e.on("message:start",f),e.on("message:chunk",t),e.on("message:complete",u),e.on("message:error",d),e.on("toolCall:received",p),e.sendMessage(o,l).catch(()=>{a=!0,r?.()});try{for(;!a||n.length>0;)n.length>0?yield n.shift():(await new Promise(s=>{r=s}),r=null)}finally{e.off("message:start",f),e.off("message:chunk",t),e.off("message:complete",u),e.off("message:error",d),e.off("toolCall:received",p)}}function w(e){let o,l,n,r,a,c;if(typeof window<"u"&&window.AGO){const t=window.AGO;o=t.basepath,l=t.widgetId,n=t.agent||t.defaultAgent,r=t.permission,a=t.email,c=t.jwt}if(typeof document<"u"){const t=u=>document.querySelector(`meta[name="${u}"]`)?.getAttribute("content")||void 0;o=o||t("ago-base-url"),l=l||t("ago-widget-id"),n=n||t("ago-agent")||t("ago-agent-id"),r=r||t("ago-permission"),a=a||t("ago-user-email")}if(typeof document<"u"){const t=[document.body,...Array.from(document.querySelectorAll("script[data-ago-base-url]"))].filter(Boolean);for(const u of t)u&&(o=o||u.getAttribute("data-ago-base-url")||void 0,l=l||u.getAttribute("data-ago-widget-id")||void 0,n=n||u.getAttribute("data-ago-agent")||u.getAttribute("data-ago-agent-id")||void 0,r=r||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,n=e?.agent||e?.defaultAgentId||n,r=e?.permission||r,a=e?.userEmail||a,c=e?.userJwt||c;const f=e?.debug;return o?{baseUrl:o,widgetId:l,agent:n,permission:r,userEmail:a,userJwt:c,debug:f}:null}function F(e){const o=w(e);if(!o)throw new Error('createAgo(): could not detect AGO configuration. Set window.AGO, add <meta name="ago-base-url">, or pass { baseUrl } explicitly.');return new i.AgoClient(o)}function q(e,o){return{...e,handler:o}}exports.AgoApiError=i.AgoApiError;exports.AgoClient=i.AgoClient;exports.AgoError=i.AgoError;exports.AgoFunctionError=i.AgoFunctionError;exports.AgoNetworkError=i.AgoNetworkError;exports.AgoStreamError=i.AgoStreamError;exports.ClientContextRegistry=i.ClientContextRegistry;exports.EventEmitter=i.EventEmitter;exports.FunctionRegistry=i.FunctionRegistry;exports.SSEHandler=i.SSEHandler;exports.autoDetectConfig=w;exports.copyToClipboard=g.copyToClipboard;exports.createAgo=F;exports.createConversationSession=A.createConversationSession;exports.createFormCollector=m.createFormCollector;exports.createMessageStream=k;exports.createMockClient=C.createMockClient;exports.createStore=m.createStore;exports.defineFunction=h;exports.deriveFormStatus=m.deriveFormStatus;exports.getLocalStorage=g.getLocalStorage;exports.getUserLocation=g.getUserLocation;exports.highlightElement=g.highlightElement;exports.isStreamNetworkError=i.isStreamNetworkError;exports.logger=i.logger;exports.onFunctionInvoke=M;exports.onMessage=E;exports.onMessageChunk=S;exports.onMessageError=b;exports.onMessageStart=y;exports.onToolCall=v;exports.openUrl=g.openUrl;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.withHandler=q;
|
package/dist/index.d.cts
CHANGED
|
@@ -227,6 +227,11 @@ export declare interface AgoClientEvents {
|
|
|
227
227
|
conversationId: string;
|
|
228
228
|
messageId: string;
|
|
229
229
|
};
|
|
230
|
+
/**
|
|
231
|
+
* The main answer text is done (backend emitted `status: "DONE"`), but follow-up
|
|
232
|
+
* replies may still be pending. Fires once, before `message:complete`.
|
|
233
|
+
*/
|
|
234
|
+
"message:answer-complete": AgoMessage;
|
|
230
235
|
"message:complete": AgoMessage;
|
|
231
236
|
"message:error": {
|
|
232
237
|
error: string;
|
|
@@ -1194,6 +1199,7 @@ export declare class SSEHandler {
|
|
|
1194
1199
|
private sources;
|
|
1195
1200
|
private followUpReplies;
|
|
1196
1201
|
private isFirstChunk;
|
|
1202
|
+
private answerCompleteEmitted;
|
|
1197
1203
|
constructor(callbacks: SSEHandlerCallbacks);
|
|
1198
1204
|
/**
|
|
1199
1205
|
* Process a streaming response
|
|
@@ -1202,6 +1208,8 @@ export declare class SSEHandler {
|
|
|
1202
1208
|
private processBuffer;
|
|
1203
1209
|
private handleChunk;
|
|
1204
1210
|
private parseToolCall;
|
|
1211
|
+
/** Snapshot the accumulated message. Shared by the answer-complete and final builds. */
|
|
1212
|
+
private buildMessage;
|
|
1205
1213
|
private buildFinalMessage;
|
|
1206
1214
|
}
|
|
1207
1215
|
|
|
@@ -1222,6 +1230,12 @@ declare interface SSEHandlerCallbacks {
|
|
|
1222
1230
|
arguments: Record<string, unknown>;
|
|
1223
1231
|
conversationId: string;
|
|
1224
1232
|
}) => void;
|
|
1233
|
+
/**
|
|
1234
|
+
* The main answer text is finished (the backend emitted `status: "DONE"`) but
|
|
1235
|
+
* follow-up replies may still be streaming. Fires once, before {@link onComplete},
|
|
1236
|
+
* with the message as it stands at that moment (no `followUpReplies` yet).
|
|
1237
|
+
*/
|
|
1238
|
+
onAnswerComplete?: (message: AgoMessage) => void;
|
|
1225
1239
|
onComplete?: (message: AgoMessage) => void;
|
|
1226
1240
|
onError?: (error: Error) => void;
|
|
1227
1241
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -227,6 +227,11 @@ export declare interface AgoClientEvents {
|
|
|
227
227
|
conversationId: string;
|
|
228
228
|
messageId: string;
|
|
229
229
|
};
|
|
230
|
+
/**
|
|
231
|
+
* The main answer text is done (backend emitted `status: "DONE"`), but follow-up
|
|
232
|
+
* replies may still be pending. Fires once, before `message:complete`.
|
|
233
|
+
*/
|
|
234
|
+
"message:answer-complete": AgoMessage;
|
|
230
235
|
"message:complete": AgoMessage;
|
|
231
236
|
"message:error": {
|
|
232
237
|
error: string;
|
|
@@ -1194,6 +1199,7 @@ export declare class SSEHandler {
|
|
|
1194
1199
|
private sources;
|
|
1195
1200
|
private followUpReplies;
|
|
1196
1201
|
private isFirstChunk;
|
|
1202
|
+
private answerCompleteEmitted;
|
|
1197
1203
|
constructor(callbacks: SSEHandlerCallbacks);
|
|
1198
1204
|
/**
|
|
1199
1205
|
* Process a streaming response
|
|
@@ -1202,6 +1208,8 @@ export declare class SSEHandler {
|
|
|
1202
1208
|
private processBuffer;
|
|
1203
1209
|
private handleChunk;
|
|
1204
1210
|
private parseToolCall;
|
|
1211
|
+
/** Snapshot the accumulated message. Shared by the answer-complete and final builds. */
|
|
1212
|
+
private buildMessage;
|
|
1205
1213
|
private buildFinalMessage;
|
|
1206
1214
|
}
|
|
1207
1215
|
|
|
@@ -1222,6 +1230,12 @@ declare interface SSEHandlerCallbacks {
|
|
|
1222
1230
|
arguments: Record<string, unknown>;
|
|
1223
1231
|
conversationId: string;
|
|
1224
1232
|
}) => void;
|
|
1233
|
+
/**
|
|
1234
|
+
* The main answer text is finished (the backend emitted `status: "DONE"`) but
|
|
1235
|
+
* follow-up replies may still be streaming. Fires once, before {@link onComplete},
|
|
1236
|
+
* with the message as it stands at that moment (no `followUpReplies` yet).
|
|
1237
|
+
*/
|
|
1238
|
+
onAnswerComplete?: (message: AgoMessage) => void;
|
|
1225
1239
|
onComplete?: (message: AgoMessage) => void;
|
|
1226
1240
|
onError?: (error: Error) => void;
|
|
1227
1241
|
}
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { a as w, c as h, d as A, f as y, i as C, l as E, n as S, o as b, r as v, s as k, t as d, u as M } from "./AgoClient-
|
|
2
|
-
import { n as T, r as I, t as U } from "./createFormCollector-
|
|
3
|
-
import { t as O } from "./createConversationSession-
|
|
1
|
+
import { a as w, c as h, d as A, f as y, i as C, l as E, n as S, o as b, r as v, s as k, t as d, u as M } from "./AgoClient-BrYhSO5M.js";
|
|
2
|
+
import { n as T, r as I, t as U } from "./createFormCollector-CPS2phYq.js";
|
|
3
|
+
import { t as O } from "./createConversationSession-Dmqd80DX.js";
|
|
4
4
|
import { t as x } from "./createMockClient-DwdxNwEn.js";
|
|
5
5
|
import { a as N, c as D, d as H, f as J, i as R, l as j, m as B, o as P, p as $, r as z, s as K, t as Q, u as V } from "./functions-C1-5vadY.js";
|
|
6
6
|
function W(e) {
|