@useago/sdk 1.0.3 → 1.0.5
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/README.md +51 -3
- package/dist/AgoClient--y10UXUV.cjs +6 -0
- package/dist/{AgoClient-CBLJfu90.js → AgoClient-DYdIe_R4.js} +55 -44
- package/dist/angular.cjs +1 -1
- package/dist/angular.d.cts +49 -2
- package/dist/angular.d.ts +49 -2
- package/dist/angular.js +1 -1
- package/dist/{createConversationSession-D3aHSSir.js → createConversationSession-Boi0PjDU.js} +1 -1
- package/dist/{createConversationSession-CnIchjFa.cjs → createConversationSession-lJWANT6T.cjs} +1 -1
- package/dist/{createFormCollector-CyD7KnjG.js → createFormCollector-BUqSA2Qw.js} +1 -1
- package/dist/{createFormCollector-CQKfRjfj.cjs → createFormCollector-CSG5ioym.cjs} +1 -1
- package/dist/devtools.cjs +41 -27
- package/dist/devtools.d.cts +48 -0
- package/dist/devtools.d.ts +48 -0
- package/dist/devtools.js +98 -70
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +13 -0
- package/dist/index.d.ts +13 -0
- package/dist/index.js +3 -3
- package/dist/react.cjs +1 -1
- package/dist/react.d.cts +49 -2
- package/dist/react.d.ts +49 -2
- package/dist/react.js +2 -2
- package/dist/testing.d.cts +48 -0
- package/dist/testing.d.ts +48 -0
- package/dist/vue.cjs +1 -1
- package/dist/vue.d.cts +49 -2
- package/dist/vue.d.ts +49 -2
- package/dist/vue.js +1 -1
- package/dist/widget.cjs +1 -1
- package/dist/widget.d.cts +48 -0
- package/dist/widget.d.ts +48 -0
- package/dist/widget.js +3 -3
- package/package.json +4 -4
- package/dist/AgoClient-nYVPdI5x.cjs +0 -6
package/dist/devtools.cjs
CHANGED
|
@@ -1,20 +1,28 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});var p,
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});var v,x,p,h=()=>({});function s(){v&&(v.textContent=JSON.stringify(h(),null,2))}function m(e,t,d){if(!e)return;const n=document.createElement("div");n.className=`dev-log-line dev-log-${d}`,n.textContent=`${new Date().toLocaleTimeString()} ${t}`,e.appendChild(n),e.scrollTop=e.scrollHeight}function c(e,t){m(x,e,t)}function y(e){let t;return e.type?t=e.type:e.content!==void 0?t="content":e.full_content!==void 0?t="full_content":e.status?t=`status:${e.status}`:t="event",`${t} ${JSON.stringify(e)}`}var S="ago_dev_panel_collapsed",E="ago_dev_events_collapsed";function g(e,t,d,n){e.classList.toggle("collapsed",t);const o=e.querySelector(".dev-toggle");o&&(o.textContent=t?"▢":"—",o.title=t?`Expand ${n}`:`Collapse ${n}`,o.setAttribute("aria-expanded",String(!t)));try{localStorage.setItem(d,t?"1":"0")}catch{}}function u(e,t,d){e.querySelector(".dev-toggle")?.addEventListener("click",o=>{o.stopPropagation(),g(e,!e.classList.contains("collapsed"),t,d)}),e.addEventListener("click",()=>{e.classList.contains("collapsed")&&g(e,!1,t,d)});let n=!1;try{n=localStorage.getItem(t)==="1"}catch{}g(e,n,t,d)}function C(e){const{client:t,target:d}=e;h=()=>{const a=t.getContextSnapshot()?.entries??{};return Object.fromEntries(Object.entries(a).map(([l,{name:r,data:b}])=>[l,{name:r,data:b}]))},w();const n=typeof d=="string"?document.querySelector(d):d instanceof Element?d:document.body,o=document.createElement("aside");o.id="ago-dev-panel",o.className="ago-dev-card",(n??document.body).appendChild(o),o.innerHTML=`
|
|
2
2
|
<div class="dev-head">
|
|
3
3
|
<span class="dev-badge">DEV</span>
|
|
4
4
|
<span class="dev-title">DEV TOOLS · client-side function state — not for production</span>
|
|
5
5
|
<button type="button" class="dev-toggle" aria-label="Toggle dev tools">—</button>
|
|
6
6
|
</div>
|
|
7
7
|
<div class="dev-body">
|
|
8
|
-
<div class="dev-fns">Registered functions: <code>${(
|
|
8
|
+
<div class="dev-fns">Registered functions: <code>${(t.getRegisteredFunctions?.()??[]).map(a=>a.name).join(", ")||"—"}</code></div>
|
|
9
9
|
<div class="dev-section-label">JSON object (built by the agent)</div>
|
|
10
10
|
<pre class="dev-state" id="ago-dev-state"></pre>
|
|
11
11
|
<div class="dev-section-label">Function calls</div>
|
|
12
12
|
<div class="dev-log" id="ago-dev-log"></div>
|
|
13
13
|
</div>
|
|
14
|
-
`,
|
|
15
|
-
|
|
14
|
+
`,v=o.querySelector("#ago-dev-state"),x=o.querySelector("#ago-dev-log"),u(o,S,"dev tools");const i=document.createElement("aside");i.id="ago-dev-events",i.className="ago-dev-card",(n??document.body).appendChild(i),i.innerHTML=`
|
|
15
|
+
<div class="dev-head">
|
|
16
|
+
<span class="dev-badge">SSE</span>
|
|
17
|
+
<span class="dev-title">SSE EVENT LOG · raw stream messages</span>
|
|
18
|
+
<button type="button" class="dev-toggle" aria-label="Toggle SSE event log">—</button>
|
|
19
|
+
</div>
|
|
20
|
+
<div class="dev-body">
|
|
21
|
+
<div class="dev-log" id="ago-dev-event-log"></div>
|
|
22
|
+
</div>
|
|
23
|
+
`,p=i.querySelector("#ago-dev-event-log"),u(i,E,"SSE event log"),t.on("stream:message",a=>{m(p,y(a),"event")}),t.on("function:invoke",({functionName:a,arguments:l})=>{c(`→ ${a}(${JSON.stringify(l??{})})`,"invoke")}),t.on("function:result",({result:a,error:l})=>{c(l?`✗ error: ${l}`:`← ${JSON.stringify(a)}`,l?"error":"result"),s()}),t.on("context:changed",s),t.on("conversation:loaded",a=>{const l=(a.messages??[]).flatMap(r=>r.toolCalls??[]);c(`⟳ hydrated "${a.title||a.id}" — replayed ${l.length} tool call${l.length===1?"":"s"}`,"hydrate"),s()}),s()}var f="ago-dev-panel-styles";function w(){if(document.getElementById(f))return;const e=document.createElement("style");e.id=f,e.textContent=L,document.head.appendChild(e)}var L=`
|
|
24
|
+
.ago-dev-card {
|
|
16
25
|
position: fixed;
|
|
17
|
-
top: 16px;
|
|
18
26
|
right: 16px;
|
|
19
27
|
width: min(360px, calc(100vw - 32px));
|
|
20
28
|
max-width: calc(100vw - 32px);
|
|
@@ -33,8 +41,11 @@ Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});var p,d,x=()=
|
|
|
33
41
|
font-size: 12px;
|
|
34
42
|
z-index: 1000;
|
|
35
43
|
}
|
|
36
|
-
|
|
37
|
-
#ago-dev-panel
|
|
44
|
+
/* The main panel pins to the top, the SSE log to the bottom, so they don't overlap. */
|
|
45
|
+
#ago-dev-panel { top: 16px; }
|
|
46
|
+
#ago-dev-events { bottom: 16px; }
|
|
47
|
+
.ago-dev-card .dev-head { display: flex; align-items: center; gap: 8px; }
|
|
48
|
+
.ago-dev-card .dev-toggle {
|
|
38
49
|
margin-left: auto;
|
|
39
50
|
flex: none;
|
|
40
51
|
width: 22px;
|
|
@@ -50,19 +61,19 @@ Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});var p,d,x=()=
|
|
|
50
61
|
line-height: 1;
|
|
51
62
|
cursor: pointer;
|
|
52
63
|
}
|
|
53
|
-
|
|
54
|
-
|
|
64
|
+
.ago-dev-card .dev-toggle:hover { color: #d7e0e8; border-color: #3a4655; }
|
|
65
|
+
.ago-dev-card .dev-body { display: flex; flex-direction: column; gap: 8px; }
|
|
55
66
|
|
|
56
|
-
/* Collapsed: shrink to a small clickable widget showing only the
|
|
57
|
-
|
|
67
|
+
/* Collapsed: shrink to a small clickable widget showing only the badge. */
|
|
68
|
+
.ago-dev-card.collapsed {
|
|
58
69
|
width: auto;
|
|
59
70
|
cursor: pointer;
|
|
60
71
|
padding: 8px 10px;
|
|
61
72
|
}
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
73
|
+
.ago-dev-card.collapsed .dev-title,
|
|
74
|
+
.ago-dev-card.collapsed .dev-body { display: none; }
|
|
75
|
+
.ago-dev-card.collapsed .dev-toggle { margin-left: 6px; }
|
|
76
|
+
.ago-dev-card .dev-badge {
|
|
66
77
|
background: #f59e0b;
|
|
67
78
|
color: #1c1206;
|
|
68
79
|
font-weight: 700;
|
|
@@ -71,17 +82,17 @@ Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});var p,d,x=()=
|
|
|
71
82
|
padding: 2px 6px;
|
|
72
83
|
border-radius: 5px;
|
|
73
84
|
}
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
85
|
+
.ago-dev-card .dev-title { color: #f59e0b; font-size: 11px; line-height: 1.3; }
|
|
86
|
+
.ago-dev-card .dev-fns { color: #7c8a99; font-size: 11px; }
|
|
87
|
+
.ago-dev-card .dev-fns code { color: #9ecbff; }
|
|
88
|
+
.ago-dev-card .dev-section-label {
|
|
78
89
|
color: #7c8a99;
|
|
79
90
|
text-transform: uppercase;
|
|
80
91
|
letter-spacing: .08em;
|
|
81
92
|
font-size: 10px;
|
|
82
93
|
margin-top: 4px;
|
|
83
94
|
}
|
|
84
|
-
|
|
95
|
+
.ago-dev-card .dev-state {
|
|
85
96
|
margin: 0;
|
|
86
97
|
padding: 8px;
|
|
87
98
|
background: #060a0e;
|
|
@@ -91,7 +102,7 @@ Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});var p,d,x=()=
|
|
|
91
102
|
white-space: pre;
|
|
92
103
|
color: #c8e6c9;
|
|
93
104
|
}
|
|
94
|
-
|
|
105
|
+
.ago-dev-card .dev-log {
|
|
95
106
|
display: flex;
|
|
96
107
|
flex-direction: column;
|
|
97
108
|
gap: 2px;
|
|
@@ -101,9 +112,12 @@ Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});var p,d,x=()=
|
|
|
101
112
|
border-radius: 8px;
|
|
102
113
|
padding: 6px 8px;
|
|
103
114
|
}
|
|
104
|
-
|
|
105
|
-
#ago-dev-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
115
|
+
/* The SSE log is the events panel's only content, so give it more room. */
|
|
116
|
+
#ago-dev-events .dev-log { max-height: 60vh; }
|
|
117
|
+
.ago-dev-card .dev-log-line { white-space: pre-wrap; word-break: break-word; line-height: 1.4; }
|
|
118
|
+
.ago-dev-card .dev-log-invoke { color: #9ecbff; }
|
|
119
|
+
.ago-dev-card .dev-log-result { color: #86efac; }
|
|
120
|
+
.ago-dev-card .dev-log-error { color: #fca5a5; }
|
|
121
|
+
.ago-dev-card .dev-log-hydrate { color: #d8b4fe; }
|
|
122
|
+
.ago-dev-card .dev-log-event { color: #7c8a99; }
|
|
123
|
+
`;exports.initDevPanel=C;
|
package/dist/devtools.d.cts
CHANGED
|
@@ -243,6 +243,13 @@ declare interface AgoClientEvents {
|
|
|
243
243
|
conversationId: string;
|
|
244
244
|
messageId: string;
|
|
245
245
|
};
|
|
246
|
+
/**
|
|
247
|
+
* Every raw SSE message parsed off the stream, before the handler interprets it
|
|
248
|
+
* into the higher-level `message:*` / `toolCall:*` / `function:*` events. Carries
|
|
249
|
+
* the chunk verbatim so debugging tools (notably the dev panel) can log the exact
|
|
250
|
+
* wire payload. Heartbeat comments are not messages and don't fire this.
|
|
251
|
+
*/
|
|
252
|
+
"stream:message": SSEChunkData;
|
|
246
253
|
/**
|
|
247
254
|
* The main answer text is done (backend emitted `status: "DONE"`), but follow-up
|
|
248
255
|
* replies may still be pending. Fires once, before `message:complete`.
|
|
@@ -542,6 +549,47 @@ declare interface SendMessageOptions {
|
|
|
542
549
|
files?: File[];
|
|
543
550
|
}
|
|
544
551
|
|
|
552
|
+
/**
|
|
553
|
+
* SSE stream chunk data
|
|
554
|
+
*/
|
|
555
|
+
declare interface SSEChunkData {
|
|
556
|
+
content?: string;
|
|
557
|
+
full_content?: string;
|
|
558
|
+
message_id?: string;
|
|
559
|
+
status?: MessageStatus;
|
|
560
|
+
thread?: {
|
|
561
|
+
id: string;
|
|
562
|
+
};
|
|
563
|
+
agent?: {
|
|
564
|
+
id: string;
|
|
565
|
+
name: string;
|
|
566
|
+
display_name?: string;
|
|
567
|
+
};
|
|
568
|
+
knowledge_sources?: Array<{
|
|
569
|
+
knowledge_document: {
|
|
570
|
+
id: string;
|
|
571
|
+
title: string;
|
|
572
|
+
use_external_link: boolean;
|
|
573
|
+
external_link_url?: string;
|
|
574
|
+
internal_link_url?: string;
|
|
575
|
+
};
|
|
576
|
+
position: number;
|
|
577
|
+
}>;
|
|
578
|
+
tool_call_data?: boolean;
|
|
579
|
+
type?: string;
|
|
580
|
+
id?: string;
|
|
581
|
+
tool_name?: string;
|
|
582
|
+
tool_display_name?: string;
|
|
583
|
+
function_name?: string;
|
|
584
|
+
arguments?: Record<string, unknown>;
|
|
585
|
+
form_schema?: FormSchema;
|
|
586
|
+
message?: string;
|
|
587
|
+
data?: Record<string, unknown>;
|
|
588
|
+
follow_up_replies?: string[];
|
|
589
|
+
satisfaction_feedback?: unknown;
|
|
590
|
+
ask_to_talk_to_human?: boolean;
|
|
591
|
+
}
|
|
592
|
+
|
|
545
593
|
/**
|
|
546
594
|
* Where a completed form is sent.
|
|
547
595
|
* - `"https://..."` (a bare string) — shorthand for `{ via: "client", url }`: the browser
|
package/dist/devtools.d.ts
CHANGED
|
@@ -243,6 +243,13 @@ declare interface AgoClientEvents {
|
|
|
243
243
|
conversationId: string;
|
|
244
244
|
messageId: string;
|
|
245
245
|
};
|
|
246
|
+
/**
|
|
247
|
+
* Every raw SSE message parsed off the stream, before the handler interprets it
|
|
248
|
+
* into the higher-level `message:*` / `toolCall:*` / `function:*` events. Carries
|
|
249
|
+
* the chunk verbatim so debugging tools (notably the dev panel) can log the exact
|
|
250
|
+
* wire payload. Heartbeat comments are not messages and don't fire this.
|
|
251
|
+
*/
|
|
252
|
+
"stream:message": SSEChunkData;
|
|
246
253
|
/**
|
|
247
254
|
* The main answer text is done (backend emitted `status: "DONE"`), but follow-up
|
|
248
255
|
* replies may still be pending. Fires once, before `message:complete`.
|
|
@@ -542,6 +549,47 @@ declare interface SendMessageOptions {
|
|
|
542
549
|
files?: File[];
|
|
543
550
|
}
|
|
544
551
|
|
|
552
|
+
/**
|
|
553
|
+
* SSE stream chunk data
|
|
554
|
+
*/
|
|
555
|
+
declare interface SSEChunkData {
|
|
556
|
+
content?: string;
|
|
557
|
+
full_content?: string;
|
|
558
|
+
message_id?: string;
|
|
559
|
+
status?: MessageStatus;
|
|
560
|
+
thread?: {
|
|
561
|
+
id: string;
|
|
562
|
+
};
|
|
563
|
+
agent?: {
|
|
564
|
+
id: string;
|
|
565
|
+
name: string;
|
|
566
|
+
display_name?: string;
|
|
567
|
+
};
|
|
568
|
+
knowledge_sources?: Array<{
|
|
569
|
+
knowledge_document: {
|
|
570
|
+
id: string;
|
|
571
|
+
title: string;
|
|
572
|
+
use_external_link: boolean;
|
|
573
|
+
external_link_url?: string;
|
|
574
|
+
internal_link_url?: string;
|
|
575
|
+
};
|
|
576
|
+
position: number;
|
|
577
|
+
}>;
|
|
578
|
+
tool_call_data?: boolean;
|
|
579
|
+
type?: string;
|
|
580
|
+
id?: string;
|
|
581
|
+
tool_name?: string;
|
|
582
|
+
tool_display_name?: string;
|
|
583
|
+
function_name?: string;
|
|
584
|
+
arguments?: Record<string, unknown>;
|
|
585
|
+
form_schema?: FormSchema;
|
|
586
|
+
message?: string;
|
|
587
|
+
data?: Record<string, unknown>;
|
|
588
|
+
follow_up_replies?: string[];
|
|
589
|
+
satisfaction_feedback?: unknown;
|
|
590
|
+
ask_to_talk_to_human?: boolean;
|
|
591
|
+
}
|
|
592
|
+
|
|
545
593
|
/**
|
|
546
594
|
* Where a completed form is sent.
|
|
547
595
|
* - `"https://..."` (a bare string) — shorthand for `{ via: "client", url }`: the browser
|
package/dist/devtools.js
CHANGED
|
@@ -1,74 +1,96 @@
|
|
|
1
|
-
var
|
|
1
|
+
var v, x, p, h = () => ({});
|
|
2
2
|
function i() {
|
|
3
|
-
|
|
3
|
+
v && (v.textContent = JSON.stringify(h(), null, 2));
|
|
4
4
|
}
|
|
5
|
-
function
|
|
6
|
-
if (!
|
|
7
|
-
const
|
|
8
|
-
|
|
5
|
+
function m(e, t, d) {
|
|
6
|
+
if (!e) return;
|
|
7
|
+
const n = document.createElement("div");
|
|
8
|
+
n.className = `dev-log-line dev-log-${d}`, n.textContent = `${(/* @__PURE__ */ new Date()).toLocaleTimeString()} ${t}`, e.appendChild(n), e.scrollTop = e.scrollHeight;
|
|
9
9
|
}
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
10
|
+
function c(e, t) {
|
|
11
|
+
m(x, e, t);
|
|
12
|
+
}
|
|
13
|
+
function y(e) {
|
|
14
|
+
let t;
|
|
15
|
+
return e.type ? t = e.type : e.content !== void 0 ? t = "content" : e.full_content !== void 0 ? t = "full_content" : e.status ? t = `status:${e.status}` : t = "event", `${t} ${JSON.stringify(e)}`;
|
|
16
|
+
}
|
|
17
|
+
var S = "ago_dev_panel_collapsed", E = "ago_dev_events_collapsed";
|
|
18
|
+
function g(e, t, d, n) {
|
|
19
|
+
e.classList.toggle("collapsed", t);
|
|
20
|
+
const o = e.querySelector(".dev-toggle");
|
|
21
|
+
o && (o.textContent = t ? "▢" : "—", o.title = t ? `Expand ${n}` : `Collapse ${n}`, o.setAttribute("aria-expanded", String(!t)));
|
|
22
|
+
try {
|
|
23
|
+
localStorage.setItem(d, t ? "1" : "0");
|
|
24
|
+
} catch {
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
function u(e, t, d) {
|
|
28
|
+
e.querySelector(".dev-toggle")?.addEventListener("click", (o) => {
|
|
29
|
+
o.stopPropagation(), g(e, !e.classList.contains("collapsed"), t, d);
|
|
30
|
+
}), e.addEventListener("click", () => {
|
|
31
|
+
e.classList.contains("collapsed") && g(e, !1, t, d);
|
|
32
|
+
});
|
|
33
|
+
let n = !1;
|
|
15
34
|
try {
|
|
16
|
-
localStorage.
|
|
35
|
+
n = localStorage.getItem(t) === "1";
|
|
17
36
|
} catch {
|
|
18
37
|
}
|
|
38
|
+
g(e, n, t, d);
|
|
19
39
|
}
|
|
20
|
-
function
|
|
21
|
-
const { client:
|
|
22
|
-
|
|
23
|
-
const
|
|
24
|
-
return Object.fromEntries(Object.entries(
|
|
25
|
-
name:
|
|
26
|
-
data:
|
|
40
|
+
function L(e) {
|
|
41
|
+
const { client: t, target: d } = e;
|
|
42
|
+
h = () => {
|
|
43
|
+
const a = t.getContextSnapshot()?.entries ?? {};
|
|
44
|
+
return Object.fromEntries(Object.entries(a).map(([l, { name: r, data: b }]) => [l, {
|
|
45
|
+
name: r,
|
|
46
|
+
data: b
|
|
27
47
|
}]));
|
|
28
|
-
},
|
|
29
|
-
const
|
|
30
|
-
|
|
48
|
+
}, C();
|
|
49
|
+
const n = typeof d == "string" ? document.querySelector(d) : d instanceof Element ? d : document.body, o = document.createElement("aside");
|
|
50
|
+
o.id = "ago-dev-panel", o.className = "ago-dev-card", (n ?? document.body).appendChild(o), o.innerHTML = `
|
|
31
51
|
<div class="dev-head">
|
|
32
52
|
<span class="dev-badge">DEV</span>
|
|
33
53
|
<span class="dev-title">DEV TOOLS · client-side function state — not for production</span>
|
|
34
54
|
<button type="button" class="dev-toggle" aria-label="Toggle dev tools">—</button>
|
|
35
55
|
</div>
|
|
36
56
|
<div class="dev-body">
|
|
37
|
-
<div class="dev-fns">Registered functions: <code>${(
|
|
57
|
+
<div class="dev-fns">Registered functions: <code>${(t.getRegisteredFunctions?.() ?? []).map((a) => a.name).join(", ") || "—"}</code></div>
|
|
38
58
|
<div class="dev-section-label">JSON object (built by the agent)</div>
|
|
39
59
|
<pre class="dev-state" id="ago-dev-state"></pre>
|
|
40
60
|
<div class="dev-section-label">Function calls</div>
|
|
41
61
|
<div class="dev-log" id="ago-dev-log"></div>
|
|
42
62
|
</div>
|
|
43
|
-
`,
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
63
|
+
`, v = o.querySelector("#ago-dev-state"), x = o.querySelector("#ago-dev-log"), u(o, S, "dev tools");
|
|
64
|
+
const s = document.createElement("aside");
|
|
65
|
+
s.id = "ago-dev-events", s.className = "ago-dev-card", (n ?? document.body).appendChild(s), s.innerHTML = `
|
|
66
|
+
<div class="dev-head">
|
|
67
|
+
<span class="dev-badge">SSE</span>
|
|
68
|
+
<span class="dev-title">SSE EVENT LOG · raw stream messages</span>
|
|
69
|
+
<button type="button" class="dev-toggle" aria-label="Toggle SSE event log">—</button>
|
|
70
|
+
</div>
|
|
71
|
+
<div class="dev-body">
|
|
72
|
+
<div class="dev-log" id="ago-dev-event-log"></div>
|
|
73
|
+
</div>
|
|
74
|
+
`, p = s.querySelector("#ago-dev-event-log"), u(s, E, "SSE event log"), t.on("stream:message", (a) => {
|
|
75
|
+
m(p, y(a), "event");
|
|
76
|
+
}), t.on("function:invoke", ({ functionName: a, arguments: l }) => {
|
|
77
|
+
c(`→ ${a}(${JSON.stringify(l ?? {})})`, "invoke");
|
|
78
|
+
}), t.on("function:result", ({ result: a, error: l }) => {
|
|
79
|
+
c(l ? `✗ error: ${l}` : `← ${JSON.stringify(a)}`, l ? "error" : "result"), i();
|
|
80
|
+
}), t.on("context:changed", i), t.on("conversation:loaded", (a) => {
|
|
81
|
+
const l = (a.messages ?? []).flatMap((r) => r.toolCalls ?? []);
|
|
82
|
+
c(`⟳ hydrated "${a.title || a.id}" — replayed ${l.length} tool call${l.length === 1 ? "" : "s"}`, "hydrate"), i();
|
|
60
83
|
}), i();
|
|
61
84
|
}
|
|
62
|
-
var
|
|
63
|
-
function
|
|
64
|
-
if (document.getElementById(
|
|
65
|
-
const
|
|
66
|
-
|
|
85
|
+
var f = "ago-dev-panel-styles";
|
|
86
|
+
function C() {
|
|
87
|
+
if (document.getElementById(f)) return;
|
|
88
|
+
const e = document.createElement("style");
|
|
89
|
+
e.id = f, e.textContent = w, document.head.appendChild(e);
|
|
67
90
|
}
|
|
68
|
-
var
|
|
69
|
-
|
|
91
|
+
var w = `
|
|
92
|
+
.ago-dev-card {
|
|
70
93
|
position: fixed;
|
|
71
|
-
top: 16px;
|
|
72
94
|
right: 16px;
|
|
73
95
|
width: min(360px, calc(100vw - 32px));
|
|
74
96
|
max-width: calc(100vw - 32px);
|
|
@@ -87,8 +109,11 @@ var m = `
|
|
|
87
109
|
font-size: 12px;
|
|
88
110
|
z-index: 1000;
|
|
89
111
|
}
|
|
90
|
-
|
|
91
|
-
#ago-dev-panel
|
|
112
|
+
/* The main panel pins to the top, the SSE log to the bottom, so they don't overlap. */
|
|
113
|
+
#ago-dev-panel { top: 16px; }
|
|
114
|
+
#ago-dev-events { bottom: 16px; }
|
|
115
|
+
.ago-dev-card .dev-head { display: flex; align-items: center; gap: 8px; }
|
|
116
|
+
.ago-dev-card .dev-toggle {
|
|
92
117
|
margin-left: auto;
|
|
93
118
|
flex: none;
|
|
94
119
|
width: 22px;
|
|
@@ -104,19 +129,19 @@ var m = `
|
|
|
104
129
|
line-height: 1;
|
|
105
130
|
cursor: pointer;
|
|
106
131
|
}
|
|
107
|
-
|
|
108
|
-
|
|
132
|
+
.ago-dev-card .dev-toggle:hover { color: #d7e0e8; border-color: #3a4655; }
|
|
133
|
+
.ago-dev-card .dev-body { display: flex; flex-direction: column; gap: 8px; }
|
|
109
134
|
|
|
110
|
-
/* Collapsed: shrink to a small clickable widget showing only the
|
|
111
|
-
|
|
135
|
+
/* Collapsed: shrink to a small clickable widget showing only the badge. */
|
|
136
|
+
.ago-dev-card.collapsed {
|
|
112
137
|
width: auto;
|
|
113
138
|
cursor: pointer;
|
|
114
139
|
padding: 8px 10px;
|
|
115
140
|
}
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
141
|
+
.ago-dev-card.collapsed .dev-title,
|
|
142
|
+
.ago-dev-card.collapsed .dev-body { display: none; }
|
|
143
|
+
.ago-dev-card.collapsed .dev-toggle { margin-left: 6px; }
|
|
144
|
+
.ago-dev-card .dev-badge {
|
|
120
145
|
background: #f59e0b;
|
|
121
146
|
color: #1c1206;
|
|
122
147
|
font-weight: 700;
|
|
@@ -125,17 +150,17 @@ var m = `
|
|
|
125
150
|
padding: 2px 6px;
|
|
126
151
|
border-radius: 5px;
|
|
127
152
|
}
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
153
|
+
.ago-dev-card .dev-title { color: #f59e0b; font-size: 11px; line-height: 1.3; }
|
|
154
|
+
.ago-dev-card .dev-fns { color: #7c8a99; font-size: 11px; }
|
|
155
|
+
.ago-dev-card .dev-fns code { color: #9ecbff; }
|
|
156
|
+
.ago-dev-card .dev-section-label {
|
|
132
157
|
color: #7c8a99;
|
|
133
158
|
text-transform: uppercase;
|
|
134
159
|
letter-spacing: .08em;
|
|
135
160
|
font-size: 10px;
|
|
136
161
|
margin-top: 4px;
|
|
137
162
|
}
|
|
138
|
-
|
|
163
|
+
.ago-dev-card .dev-state {
|
|
139
164
|
margin: 0;
|
|
140
165
|
padding: 8px;
|
|
141
166
|
background: #060a0e;
|
|
@@ -145,7 +170,7 @@ var m = `
|
|
|
145
170
|
white-space: pre;
|
|
146
171
|
color: #c8e6c9;
|
|
147
172
|
}
|
|
148
|
-
|
|
173
|
+
.ago-dev-card .dev-log {
|
|
149
174
|
display: flex;
|
|
150
175
|
flex-direction: column;
|
|
151
176
|
gap: 2px;
|
|
@@ -155,12 +180,15 @@ var m = `
|
|
|
155
180
|
border-radius: 8px;
|
|
156
181
|
padding: 6px 8px;
|
|
157
182
|
}
|
|
158
|
-
|
|
159
|
-
#ago-dev-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
183
|
+
/* The SSE log is the events panel's only content, so give it more room. */
|
|
184
|
+
#ago-dev-events .dev-log { max-height: 60vh; }
|
|
185
|
+
.ago-dev-card .dev-log-line { white-space: pre-wrap; word-break: break-word; line-height: 1.4; }
|
|
186
|
+
.ago-dev-card .dev-log-invoke { color: #9ecbff; }
|
|
187
|
+
.ago-dev-card .dev-log-result { color: #86efac; }
|
|
188
|
+
.ago-dev-card .dev-log-error { color: #fca5a5; }
|
|
189
|
+
.ago-dev-card .dev-log-hydrate { color: #d8b4fe; }
|
|
190
|
+
.ago-dev-card .dev-log-event { color: #7c8a99; }
|
|
163
191
|
`;
|
|
164
192
|
export {
|
|
165
|
-
|
|
193
|
+
L as initDevPanel
|
|
166
194
|
};
|
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("./AgoClient
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("./AgoClient--y10UXUV.cjs"),m=require("./createFormCollector-CSG5ioym.cjs"),p=require("./createConversationSession-lJWANT6T.cjs"),w=require("./createMockClient-zHQ0cjUH.cjs");require("./testing.cjs");const 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 v(e,o){return e.on("message:error",o),()=>e.off("message:error",o)}function b(e,o){return e.on("toolCall:received",o),()=>e.off("toolCall:received",o)}function F(e,o){return e.on("function:invoke",o),()=>e.off("function:invoke",o)}async function*M(e,o,l){const a=[];let r=null,s=!1;const c=i=>{a.push(i),r?.()},f=i=>c({type:"start",data:i}),t=i=>c({type:"chunk",data:i}),u=i=>{c({type:"complete",data:i}),s=!0,r?.()},d=i=>{c({type:"error",data:i}),s=!0,r?.()},C=i=>c({type:"toolCall",data:i});e.on("message:start",f),e.on("message:chunk",t),e.on("message:complete",u),e.on("message:error",d),e.on("toolCall:received",C),e.sendMessage(o,l).catch(()=>{s=!0,r?.()});try{for(;!s||a.length>0;)a.length>0?yield a.shift():(await new Promise(i=>{r=i}),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",C)}}function A(e){let o,l,a,r,s,c;if(typeof window<"u"&&window.AGO){const t=window.AGO;o=t.basepath,l=t.widgetId,a=t.agent||t.defaultAgent,r=t.permission,s=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"),a=a||t("ago-agent")||t("ago-agent-id"),r=r||t("ago-permission"),s=s||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,a=a||u.getAttribute("data-ago-agent")||u.getAttribute("data-ago-agent-id")||void 0,r=r||u.getAttribute("data-ago-permission")||void 0,s=s||u.getAttribute("data-ago-user-email")||void 0)}o=e?.baseUrl||o,l=e?.widgetId||l,a=e?.agent||e?.defaultAgentId||a,r=e?.permission||r,s=e?.userEmail||s,c=e?.userJwt||c;const f=e?.debug;return o?{baseUrl:o,widgetId:l,agent:a,permission:r,userEmail:s,userJwt:c,debug:f}:null}function k(e){const o=A(e);if(!o)throw new n.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 n.AgoClient(o)}function q(e,o){return{...e,handler:o}}exports.AgoApiError=n.AgoApiError;exports.AgoClient=n.AgoClient;exports.AgoError=n.AgoError;exports.AgoFunctionError=n.AgoFunctionError;exports.AgoNetworkError=n.AgoNetworkError;exports.AgoStreamError=n.AgoStreamError;exports.ClientContextRegistry=n.ClientContextRegistry;exports.EventEmitter=n.EventEmitter;exports.FunctionRegistry=n.FunctionRegistry;exports.SSEHandler=n.SSEHandler;exports.autoDetectConfig=A;exports.copyToClipboard=g.copyToClipboard;exports.createAgo=k;exports.createConversationSession=p.createConversationSession;exports.createFormCollector=m.createFormCollector;exports.createMessageStream=M;exports.createMockClient=w.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=n.isStreamNetworkError;exports.loadFormCollector=m.loadFormCollector;exports.logger=n.logger;exports.onFunctionInvoke=F;exports.onMessage=E;exports.onMessageChunk=S;exports.onMessageError=v;exports.onMessageStart=y;exports.onToolCall=b;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.validateConfig=n.validateConfig;exports.withHandler=q;
|
package/dist/index.d.cts
CHANGED
|
@@ -254,6 +254,13 @@ export declare interface AgoClientEvents {
|
|
|
254
254
|
conversationId: string;
|
|
255
255
|
messageId: string;
|
|
256
256
|
};
|
|
257
|
+
/**
|
|
258
|
+
* Every raw SSE message parsed off the stream, before the handler interprets it
|
|
259
|
+
* into the higher-level `message:*` / `toolCall:*` / `function:*` events. Carries
|
|
260
|
+
* the chunk verbatim so debugging tools (notably the dev panel) can log the exact
|
|
261
|
+
* wire payload. Heartbeat comments are not messages and don't fire this.
|
|
262
|
+
*/
|
|
263
|
+
"stream:message": SSEChunkData;
|
|
257
264
|
/**
|
|
258
265
|
* The main answer text is done (backend emitted `status: "DONE"`), but follow-up
|
|
259
266
|
* replies may still be pending. Fires once, before `message:complete`.
|
|
@@ -1300,6 +1307,7 @@ export declare class SSEHandler {
|
|
|
1300
1307
|
private followUpReplies;
|
|
1301
1308
|
private isFirstChunk;
|
|
1302
1309
|
private answerCompleteEmitted;
|
|
1310
|
+
private firedClientFunctions;
|
|
1303
1311
|
constructor(callbacks: SSEHandlerCallbacks);
|
|
1304
1312
|
/**
|
|
1305
1313
|
* Process a streaming response
|
|
@@ -1314,6 +1322,11 @@ export declare class SSEHandler {
|
|
|
1314
1322
|
}
|
|
1315
1323
|
|
|
1316
1324
|
declare interface SSEHandlerCallbacks {
|
|
1325
|
+
/**
|
|
1326
|
+
* Every raw SSE chunk parsed off the stream, fired before it's interpreted into
|
|
1327
|
+
* the higher-level callbacks below. The verbatim payload, for debugging/logging.
|
|
1328
|
+
*/
|
|
1329
|
+
onRawChunk?: (data: SSEChunkData) => void;
|
|
1317
1330
|
onStart?: (data: {
|
|
1318
1331
|
conversationId: string;
|
|
1319
1332
|
messageId: string;
|
package/dist/index.d.ts
CHANGED
|
@@ -254,6 +254,13 @@ export declare interface AgoClientEvents {
|
|
|
254
254
|
conversationId: string;
|
|
255
255
|
messageId: string;
|
|
256
256
|
};
|
|
257
|
+
/**
|
|
258
|
+
* Every raw SSE message parsed off the stream, before the handler interprets it
|
|
259
|
+
* into the higher-level `message:*` / `toolCall:*` / `function:*` events. Carries
|
|
260
|
+
* the chunk verbatim so debugging tools (notably the dev panel) can log the exact
|
|
261
|
+
* wire payload. Heartbeat comments are not messages and don't fire this.
|
|
262
|
+
*/
|
|
263
|
+
"stream:message": SSEChunkData;
|
|
257
264
|
/**
|
|
258
265
|
* The main answer text is done (backend emitted `status: "DONE"`), but follow-up
|
|
259
266
|
* replies may still be pending. Fires once, before `message:complete`.
|
|
@@ -1300,6 +1307,7 @@ export declare class SSEHandler {
|
|
|
1300
1307
|
private followUpReplies;
|
|
1301
1308
|
private isFirstChunk;
|
|
1302
1309
|
private answerCompleteEmitted;
|
|
1310
|
+
private firedClientFunctions;
|
|
1303
1311
|
constructor(callbacks: SSEHandlerCallbacks);
|
|
1304
1312
|
/**
|
|
1305
1313
|
* Process a streaming response
|
|
@@ -1314,6 +1322,11 @@ export declare class SSEHandler {
|
|
|
1314
1322
|
}
|
|
1315
1323
|
|
|
1316
1324
|
declare interface SSEHandlerCallbacks {
|
|
1325
|
+
/**
|
|
1326
|
+
* Every raw SSE chunk parsed off the stream, fired before it's interpreted into
|
|
1327
|
+
* the higher-level callbacks below. The verbatim payload, for debugging/logging.
|
|
1328
|
+
*/
|
|
1329
|
+
onRawChunk?: (data: SSEChunkData) => void;
|
|
1317
1330
|
onStart?: (data: {
|
|
1318
1331
|
conversationId: string;
|
|
1319
1332
|
messageId: string;
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { a as h, c as A, d as y, f as C, i as E, l as b, n as S, o as v, p as k, r as F, s as M, t as d, u as c } from "./AgoClient-
|
|
2
|
-
import { i as I, n as U, r as G, t as O } from "./createFormCollector-
|
|
3
|
-
import { t as x } from "./createConversationSession-
|
|
1
|
+
import { a as h, c as A, d as y, f as C, i as E, l as b, n as S, o as v, p as k, r as F, s as M, t as d, u as c } from "./AgoClient-DYdIe_R4.js";
|
|
2
|
+
import { i as I, n as U, r as G, t as O } from "./createFormCollector-BUqSA2Qw.js";
|
|
3
|
+
import { t as x } from "./createConversationSession-Boi0PjDU.js";
|
|
4
4
|
import { t as N } from "./createMockClient-DwdxNwEn.js";
|
|
5
5
|
import "./testing.js";
|
|
6
6
|
import { a as H, c as J, d as R, f as j, i as B, l as P, m as $, o as z, p as K, r as Q, s as V, t as W, u as X } from "./functions-C1-5vadY.js";
|