@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.cjs
CHANGED
|
@@ -1,26 +1,30 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const te=require("./errors-o1IB5fEu.cjs");function Q(n,e,i){if(!n)return;const r=document.createElement("div");r.className=`dev-log-line dev-log-${i}`,r.textContent=`${new Date().toLocaleTimeString()} ${e}`,n.appendChild(r),n.scrollTop=n.scrollHeight}function ne(n){let e;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)}`}var oe="ago_dev_panel_collapsed",ae="ago_dev_events_collapsed";function _(n,e,i,r){n.classList.toggle("collapsed",e);const v=n.querySelector(".dev-toggle");v&&(v.textContent=e?"▢":"—",v.title=e?`Expand ${r}`:`Collapse ${r}`,v.setAttribute("aria-expanded",String(!e)));try{localStorage.setItem(i,e?"1":"0")}catch{}}function W(n,e,i){n.querySelector(".dev-toggle")?.addEventListener("click",v=>{v.stopPropagation(),_(n,!n.classList.contains("collapsed"),e,i)}),n.addEventListener("click",()=>{n.classList.contains("collapsed")&&_(n,!1,e,i)});let r=!1;try{r=localStorage.getItem(e)==="1"}catch{}_(n,r,e,i)}var re=0;function de(n){const{client:e,target:i,label:r,side:v="right",enableFunctionRunner:P=!1}=n;if(P&&typeof e.executeClientFunction!="function")throw new te.AgoError("initDevPanel: enableFunctionRunner requires client.executeClientFunction. Pass a real AgoClient, not a mock that omits it.","dev_panel_missing_capability");let u=!1;const F=re++,R=F===0?"":`-${F+1}`,q=document.querySelectorAll(`#ago-dev-panel[data-ago-dev-side="${v}"]`).length,N=q>0?`${16+q*376}px`:"";let w=null,A=null,J=null;const Z=()=>{const t=e.getContextSnapshot()?.entries??{};return Object.fromEntries(Object.entries(t).map(([o,{name:d,data:a}])=>[o,{name:d,data:a}]))},h=()=>{u||w&&(w.textContent=JSON.stringify(Z(),null,2))},k=(t,o)=>{u||Q(A,t,o)};se();const D=typeof i=="string"?document.querySelector(i):i instanceof Element?i:document.body,M=t=>{t.dataset.agoDevSide=v,v==="left"?(t.style.right="auto",t.style.left=N||"16px"):N&&(t.style.right=N)},p=document.createElement("aside");p.id="ago-dev-panel",p.className="ago-dev-card",M(p),(D??document.body).appendChild(p),p.innerHTML=`
|
|
2
2
|
<div class="dev-head">
|
|
3
3
|
<span class="dev-badge">DEV</span>
|
|
4
|
-
<span class="dev-title">${
|
|
4
|
+
<span class="dev-title">${r?`DEV TOOLS · ${r}`:"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
|
|
9
|
-
<
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
8
|
+
<div class="dev-fns">Registered functions: <code></code></div>
|
|
9
|
+
<details class="dev-details" open>
|
|
10
|
+
<summary class="dev-section-label">JSON object (built by the agent)</summary>
|
|
11
|
+
<pre class="dev-state" id="ago-dev-state"></pre>
|
|
12
|
+
</details>
|
|
13
|
+
<details class="dev-details" open>
|
|
14
|
+
<summary class="dev-section-label">Function calls</summary>
|
|
15
|
+
<div class="dev-log" id="ago-dev-log"></div>
|
|
16
|
+
</details>
|
|
13
17
|
</div>
|
|
14
|
-
`,
|
|
18
|
+
`,w=p.querySelector(".dev-state"),A=p.querySelector(".dev-log");const j=p.querySelector(".dev-fns code");let b=null,L=null,O="";const m=()=>{if(u)return;const t=e.getRegisteredFunctions?.()??[],o=t.map(a=>a.name);if(j&&(j.textContent=o.join(", ")||"—"),!b)return;let d=O;if(o.includes(d)||(d=o.includes("setPageState")?"setPageState":o[0]??""),O=d,b.innerHTML="",o.length===0){const a=document.createElement("option");a.textContent="(no functions registered)",a.disabled=!0,b.appendChild(a)}for(const a of o){const s=document.createElement("option");s.value=a,s.textContent=a,s.selected=a===d,b.appendChild(s)}if(L){const a=t.find(s=>s.name===d);L.textContent=a?JSON.stringify(a.parameters??{},null,2):""}};W(p,oe+R,"dev tools");const g=document.createElement("aside");g.id="ago-dev-events",g.className="ago-dev-card",M(g),(D??document.body).appendChild(g),g.innerHTML=`
|
|
15
19
|
<div class="dev-head">
|
|
16
20
|
<span class="dev-badge">SSE</span>
|
|
17
|
-
<span class="dev-title">${
|
|
21
|
+
<span class="dev-title">${r?`SSE EVENT LOG · ${r}`:"SSE EVENT LOG · raw stream messages"}</span>
|
|
18
22
|
<button type="button" class="dev-toggle" aria-label="Toggle SSE event log">—</button>
|
|
19
23
|
</div>
|
|
20
24
|
<div class="dev-body">
|
|
21
25
|
<div class="dev-log" id="ago-dev-event-log"></div>
|
|
22
26
|
</div>
|
|
23
|
-
`,
|
|
27
|
+
`,J=g.querySelector(".dev-log"),W(g,ae+R,"SSE event log");function I(t){u||Q(J,ne(t),"event")}function V({functionName:t,arguments:o}){u||(k(`→ ${t}(${JSON.stringify(o??{})})`,"invoke"),m())}function H({result:t,error:o}){u||(k(o?`✗ error: ${o}`:`← ${JSON.stringify(t)}`,o?"error":"result"),h(),m())}function U(){u||(h(),m())}function B(t){if(u)return;const o=(t.messages??[]).flatMap(d=>d.toolCalls??[]);k(`⟳ hydrated "${t.title||t.id}" — replayed ${o.length} tool call${o.length===1?"":"s"}`,"hydrate"),h()}if(e.on("stream:message",I),e.on("function:invoke",V),e.on("function:result",H),e.on("context:changed",U),e.on("conversation:loaded",B),P){const t=document.createElement("div");t.className="dev-runner";const o=document.createElement("div");o.className="dev-section-label",o.textContent="LOCAL FUNCTION RUNNER",t.appendChild(o);const d=document.createElement("div");d.className="dev-runner-warning",d.textContent="Executes locally. Does not contact the agent backend.",t.appendChild(d);const a=document.createElement("div");a.className="dev-runner-row";const s=document.createElement("select");s.className="dev-runner-select",a.appendChild(s);const y=document.createElement("button");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;const $=document.createElement("div");$.className="dev-section-label",$.textContent="SCHEMA",t.appendChild($);const T=document.createElement("pre");T.className="dev-runner-schema",t.appendChild(T),L=T,s.addEventListener("change",()=>{O=s.value,m()});const z=document.createElement("div");z.className="dev-section-label",z.textContent="ARGUMENTS (JSON)",t.appendChild(z);const C=document.createElement("textarea");C.className="dev-runner-args",C.value="{}",C.spellcheck=!1,t.appendChild(C);const f=document.createElement("button");f.type="button",f.className="dev-runner-btn",f.textContent="Run",t.appendChild(f);const l=document.createElement("div");l.className="dev-runner-status",t.appendChild(l);const x=document.createElement("pre");x.className="dev-runner-result",t.appendChild(x);const E=document.createElement("div");E.className="dev-runner-bytes",t.appendChild(E);const ee=e.executeClientFunction.bind(e);f.addEventListener("click",async()=>{l.textContent="",x.textContent="",E.textContent="";let G;try{const c=JSON.parse(C.value);if(c===null||Array.isArray(c)||typeof c!="object"){l.textContent="Error: arguments must be a JSON object.",l.className="dev-runner-status dev-runner-error";return}G=c}catch(c){l.textContent=`Parse error: ${c instanceof Error?c.message:String(c)}`,l.className="dev-runner-status dev-runner-error";return}const Y=s.value;if(!Y)return;f.disabled=!0,l.textContent="Running…",l.className="dev-runner-status";let S,K=!1;try{S=await ee(Y,G),K=!0}catch(c){if(u)return;l.textContent="Execution error",l.className="dev-runner-status dev-runner-error",x.textContent=c instanceof Error?`${c.constructor.name}: ${c.message}`:String(c)}if(!u){if(K)if(l.textContent="OK",l.className="dev-runner-status dev-runner-ok",S===void 0)x.textContent="(undefined)";else try{x.textContent=JSON.stringify(S,null,2),E.textContent=`${new TextEncoder().encode(JSON.stringify(S)).length} bytes (UTF-8)`}catch{x.textContent="(result not serializable)"}f.disabled=!1,h(),m()}}),p.querySelector(".dev-body").appendChild(t)}return m(),h(),()=>{u||(u=!0,e.off("stream:message",I),e.off("function:invoke",V),e.off("function:result",H),e.off("context:changed",U),e.off("conversation:loaded",B),p.remove(),g.remove())}}var X="ago-dev-panel-styles";function se(){if(document.getElementById(X))return;const n=document.createElement("style");n.id=X,n.textContent=le,document.head.appendChild(n)}var le=`
|
|
24
28
|
.ago-dev-card {
|
|
25
29
|
position: fixed;
|
|
26
30
|
right: 16px;
|
|
@@ -62,7 +66,7 @@ Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function E(e,
|
|
|
62
66
|
cursor: pointer;
|
|
63
67
|
}
|
|
64
68
|
.ago-dev-card .dev-toggle:hover { color: #d7e0e8; border-color: #3a4655; }
|
|
65
|
-
.ago-dev-card .dev-body { display: flex; flex-direction: column; gap: 8px; }
|
|
69
|
+
.ago-dev-card .dev-body { display: flex; flex-direction: column; gap: 8px; min-height: 0; overflow-y: auto; }
|
|
66
70
|
|
|
67
71
|
/* Collapsed: shrink to a small clickable widget showing only the badge. */
|
|
68
72
|
.ago-dev-card.collapsed {
|
|
@@ -85,6 +89,11 @@ Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function E(e,
|
|
|
85
89
|
.ago-dev-card .dev-title { color: #f59e0b; font-size: 11px; line-height: 1.3; }
|
|
86
90
|
.ago-dev-card .dev-fns { color: #7c8a99; font-size: 11px; }
|
|
87
91
|
.ago-dev-card .dev-fns code { color: #9ecbff; }
|
|
92
|
+
.ago-dev-card .dev-details { margin: 0; }
|
|
93
|
+
.ago-dev-card .dev-details > summary { list-style: none; cursor: pointer; }
|
|
94
|
+
.ago-dev-card .dev-details > summary::-webkit-details-marker { display: none; }
|
|
95
|
+
.ago-dev-card .dev-details > summary::before { content: "▸ "; }
|
|
96
|
+
.ago-dev-card .dev-details[open] > summary::before { content: "▾ "; }
|
|
88
97
|
.ago-dev-card .dev-section-label {
|
|
89
98
|
color: #7c8a99;
|
|
90
99
|
text-transform: uppercase;
|
|
@@ -120,4 +129,44 @@ Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function E(e,
|
|
|
120
129
|
.ago-dev-card .dev-log-error { color: #fca5a5; }
|
|
121
130
|
.ago-dev-card .dev-log-hydrate { color: #d8b4fe; }
|
|
122
131
|
.ago-dev-card .dev-log-event { color: #7c8a99; }
|
|
123
|
-
|
|
132
|
+
/* Function runner */
|
|
133
|
+
.ago-dev-card .dev-runner { border-top: 1px solid #2a3441; padding-top: 8px; margin-top: 4px; }
|
|
134
|
+
.ago-dev-card .dev-runner-warning { color: #f59e0b; font-size: 10px; margin-bottom: 4px; }
|
|
135
|
+
.ago-dev-card .dev-runner-row { display: flex; gap: 6px; align-items: center; }
|
|
136
|
+
.ago-dev-card .dev-runner-select {
|
|
137
|
+
flex: 1;
|
|
138
|
+
background: #060a0e; color: #d7e0e8; border: 1px solid #2a3441;
|
|
139
|
+
border-radius: 6px; padding: 4px 6px; font: inherit; font-size: 11px;
|
|
140
|
+
}
|
|
141
|
+
.ago-dev-card .dev-runner-btn {
|
|
142
|
+
background: #1a2633; color: #9ecbff; border: 1px solid #2a3441;
|
|
143
|
+
border-radius: 6px; padding: 4px 10px; font: inherit; font-size: 11px;
|
|
144
|
+
cursor: pointer;
|
|
145
|
+
}
|
|
146
|
+
.ago-dev-card .dev-runner-btn:hover { background: #243040; }
|
|
147
|
+
.ago-dev-card .dev-runner-btn:disabled { opacity: .5; cursor: default; }
|
|
148
|
+
.ago-dev-card .dev-runner-btn-sm { padding: 4px 8px; }
|
|
149
|
+
.ago-dev-card .dev-runner-schema {
|
|
150
|
+
margin: 0; padding: 6px 8px; background: #060a0e;
|
|
151
|
+
border-radius: 6px; overflow: auto; max-height: 16vh;
|
|
152
|
+
white-space: pre; color: #7c8a99; font-size: 11px;
|
|
153
|
+
}
|
|
154
|
+
.ago-dev-card .dev-runner-args {
|
|
155
|
+
width: 100%; box-sizing: border-box; min-height: 48px; max-height: 20vh;
|
|
156
|
+
resize: vertical; background: #060a0e; color: #d7e0e8;
|
|
157
|
+
border: 1px solid #2a3441; border-radius: 6px; padding: 6px 8px;
|
|
158
|
+
font: inherit; font-size: 11px;
|
|
159
|
+
}
|
|
160
|
+
.ago-dev-card .dev-runner-status { font-size: 11px; margin-top: 4px; }
|
|
161
|
+
.ago-dev-card .dev-runner-ok { color: #86efac; }
|
|
162
|
+
.ago-dev-card .dev-runner-error { color: #fca5a5; }
|
|
163
|
+
.ago-dev-card .dev-runner-result {
|
|
164
|
+
margin: 0; padding: 6px 8px; background: #060a0e;
|
|
165
|
+
border-radius: 6px; overflow: auto; max-height: 24vh;
|
|
166
|
+
white-space: pre-wrap; word-break: break-word;
|
|
167
|
+
color: #c8e6c9; font-size: 11px;
|
|
168
|
+
}
|
|
169
|
+
.ago-dev-card .dev-runner-result:empty { display: none; }
|
|
170
|
+
.ago-dev-card .dev-runner-bytes { color: #7c8a99; font-size: 10px; margin-top: 2px; }
|
|
171
|
+
.ago-dev-card .dev-runner-bytes:empty { display: none; }
|
|
172
|
+
`;exports.initDevPanel=de;
|
package/dist/devtools.d.cts
CHANGED
|
@@ -273,9 +273,40 @@ declare class AgoClient {
|
|
|
273
273
|
*/
|
|
274
274
|
submitFormCollector(name: string, values: Record<string, unknown>): Promise<unknown>;
|
|
275
275
|
/**
|
|
276
|
-
*
|
|
276
|
+
* Report an answer: thumbs up/down, optionally with what went wrong.
|
|
277
|
+
*
|
|
278
|
+
* ```ts
|
|
279
|
+
* await client.submitFeedback(message.id, "negative", {
|
|
280
|
+
* reasons: ["inaccurate"],
|
|
281
|
+
* comment: "The price it quoted is from last year.",
|
|
282
|
+
* });
|
|
283
|
+
* ```
|
|
284
|
+
*
|
|
285
|
+
* A bare rating is a reaction (the thumbs counted in the dashboard). Adding a
|
|
286
|
+
* reason or a comment also files it in the feedback list, the analytics and
|
|
287
|
+
* the CSV export, so someone can act on it.
|
|
288
|
+
*/
|
|
289
|
+
submitFeedback(messageId: string, rating: FeedbackRating, details?: FeedbackDetails): Promise<void>;
|
|
290
|
+
/**
|
|
291
|
+
* Report a whole conversation ("this chat is not working").
|
|
292
|
+
*
|
|
293
|
+
* ```ts
|
|
294
|
+
* await client.submitConversationFeedback(conversationId, "negative", {
|
|
295
|
+
* reasons: ["information_not_found"],
|
|
296
|
+
* comment: "It never answered my question.",
|
|
297
|
+
* });
|
|
298
|
+
* ```
|
|
299
|
+
*
|
|
300
|
+
* Feedback is stored per message, so this attaches the report to the last
|
|
301
|
+
* answer of the conversation, which is the one the user is reacting to.
|
|
302
|
+
* Returns the message id it landed on.
|
|
303
|
+
*
|
|
304
|
+
* Pass `lastMessageId` when you already have it (the widget does) to skip the
|
|
305
|
+
* lookup round-trip.
|
|
277
306
|
*/
|
|
278
|
-
|
|
307
|
+
submitConversationFeedback(conversationId: string, rating: FeedbackRating, details?: FeedbackDetails & {
|
|
308
|
+
lastMessageId?: string;
|
|
309
|
+
}): Promise<string>;
|
|
279
310
|
/**
|
|
280
311
|
* Register a client-side function that AGO can call.
|
|
281
312
|
* Accepts either a definition object or (name, handler, schema) args.
|
|
@@ -907,12 +938,27 @@ declare interface AgoStateControl<T = unknown> {
|
|
|
907
938
|
enum?: (string | number)[];
|
|
908
939
|
};
|
|
909
940
|
};
|
|
941
|
+
/** String-only: `""` means "clear" instead of being dropped as filler. */
|
|
942
|
+
clearable?: boolean;
|
|
910
943
|
/** Current value → pushed as dynamic context so the agent knows what to change. */
|
|
911
944
|
get?: () => T;
|
|
912
945
|
/** Apply the state change on the page. May be async. */
|
|
913
|
-
set: (value: T) => void | Promise<void>;
|
|
946
|
+
set: (value: T) => void | AgoStateSetResult | Promise<void | AgoStateSetResult>;
|
|
914
947
|
}
|
|
915
948
|
|
|
949
|
+
/**
|
|
950
|
+
* Tagged outcome a page setter may return to reject or mark unchanged.
|
|
951
|
+
*
|
|
952
|
+
* Returning nothing (void) means APPLY. Returning an unrecognized JS value
|
|
953
|
+
* (e.g. a string from an assignment expression) is also treated as APPLY.
|
|
954
|
+
*/
|
|
955
|
+
declare type AgoStateSetResult = {
|
|
956
|
+
result: "rejected";
|
|
957
|
+
reason: string;
|
|
958
|
+
} | {
|
|
959
|
+
result: "unchanged";
|
|
960
|
+
};
|
|
961
|
+
|
|
916
962
|
/**
|
|
917
963
|
* Single-object function definition — combines name, schema, and handler.
|
|
918
964
|
*
|
|
@@ -1053,7 +1099,9 @@ export declare interface DevPanelOptions {
|
|
|
1053
1099
|
* function events, and renders the name + data of each entry in its live context
|
|
1054
1100
|
* snapshot (`client.getContextSnapshot()`)
|
|
1055
1101
|
*/
|
|
1056
|
-
client: Pick<AgoClient, "on" | "getRegisteredFunctions" | "getContextSnapshot"
|
|
1102
|
+
client: Pick<AgoClient, "on" | "off" | "getRegisteredFunctions" | "getContextSnapshot"> & {
|
|
1103
|
+
executeClientFunction?: AgoClient["executeClientFunction"];
|
|
1104
|
+
};
|
|
1057
1105
|
/** Where to mount: a CSS selector, an Element, or `document.body` (default). */
|
|
1058
1106
|
target?: string | Element;
|
|
1059
1107
|
/**
|
|
@@ -1067,6 +1115,12 @@ export declare interface DevPanelOptions {
|
|
|
1067
1115
|
* page (one per widget): pass e.g. the agent or widget name to tell them apart.
|
|
1068
1116
|
*/
|
|
1069
1117
|
label?: string;
|
|
1118
|
+
/**
|
|
1119
|
+
* Mount a local function runner in the panel. The runner executes registered
|
|
1120
|
+
* client functions locally via `client.executeClientFunction` and displays
|
|
1121
|
+
* the result. It never submits to the backend. Developer-only.
|
|
1122
|
+
*/
|
|
1123
|
+
enableFunctionRunner?: boolean;
|
|
1070
1124
|
}
|
|
1071
1125
|
|
|
1072
1126
|
/**
|
|
@@ -1076,6 +1130,37 @@ export declare interface DevPanelOptions {
|
|
|
1076
1130
|
*/
|
|
1077
1131
|
declare type DynamicContextProvider = () => ContextEntry | null | undefined;
|
|
1078
1132
|
|
|
1133
|
+
/**
|
|
1134
|
+
* Why the user is reporting a message (see `AgoClient.submitFeedback`).
|
|
1135
|
+
*
|
|
1136
|
+
* A rating on its own is a reaction (the thumbs count). Add a reason or a
|
|
1137
|
+
* comment and the report also lands in the feedback dashboard, the analytics
|
|
1138
|
+
* and the CSV export, where someone can act on it.
|
|
1139
|
+
*/
|
|
1140
|
+
declare interface FeedbackDetails {
|
|
1141
|
+
/** What went wrong. Several can apply at once. */
|
|
1142
|
+
reasons?: FeedbackReason[];
|
|
1143
|
+
/** The user's own words. Trimmed server-side; 5000 characters max. */
|
|
1144
|
+
comment?: string;
|
|
1145
|
+
}
|
|
1146
|
+
|
|
1147
|
+
/** Thumbs up / thumbs down on an answer. */
|
|
1148
|
+
declare type FeedbackRating = "positive" | "negative";
|
|
1149
|
+
|
|
1150
|
+
/**
|
|
1151
|
+
* What went wrong with an answer. These are the four buckets the AGO feedback
|
|
1152
|
+
* dashboard filters and charts on.
|
|
1153
|
+
*/
|
|
1154
|
+
declare type FeedbackReason =
|
|
1155
|
+
/** The answer states something false. */
|
|
1156
|
+
"inaccurate"
|
|
1157
|
+
/** The answer is right but stops short. */
|
|
1158
|
+
| "incomplete"
|
|
1159
|
+
/** The agent could not find the information. */
|
|
1160
|
+
| "information_not_found"
|
|
1161
|
+
/** Something broke: the widget, a tool call, the stream. */
|
|
1162
|
+
| "technical_issue";
|
|
1163
|
+
|
|
1079
1164
|
/**
|
|
1080
1165
|
* The backend-stored shape returned by `GET /api/sdk/v1/forms/{name}` (see
|
|
1081
1166
|
* {@link AgoClient.getFormCollector}). Mirrors the persistable subset of
|
|
@@ -1217,7 +1302,7 @@ declare class HttpClient {
|
|
|
1217
1302
|
private handleErrorResponse;
|
|
1218
1303
|
}
|
|
1219
1304
|
|
|
1220
|
-
export declare function initDevPanel(options: DevPanelOptions): void;
|
|
1305
|
+
export declare function initDevPanel(options: DevPanelOptions): () => void;
|
|
1221
1306
|
|
|
1222
1307
|
declare type MessageStatus = "IN_PROGRESS" | "DONE" | "ERROR" | "TODO" | "CANCELED"
|
|
1223
1308
|
/**
|
package/dist/devtools.d.ts
CHANGED
|
@@ -273,9 +273,40 @@ declare class AgoClient {
|
|
|
273
273
|
*/
|
|
274
274
|
submitFormCollector(name: string, values: Record<string, unknown>): Promise<unknown>;
|
|
275
275
|
/**
|
|
276
|
-
*
|
|
276
|
+
* Report an answer: thumbs up/down, optionally with what went wrong.
|
|
277
|
+
*
|
|
278
|
+
* ```ts
|
|
279
|
+
* await client.submitFeedback(message.id, "negative", {
|
|
280
|
+
* reasons: ["inaccurate"],
|
|
281
|
+
* comment: "The price it quoted is from last year.",
|
|
282
|
+
* });
|
|
283
|
+
* ```
|
|
284
|
+
*
|
|
285
|
+
* A bare rating is a reaction (the thumbs counted in the dashboard). Adding a
|
|
286
|
+
* reason or a comment also files it in the feedback list, the analytics and
|
|
287
|
+
* the CSV export, so someone can act on it.
|
|
288
|
+
*/
|
|
289
|
+
submitFeedback(messageId: string, rating: FeedbackRating, details?: FeedbackDetails): Promise<void>;
|
|
290
|
+
/**
|
|
291
|
+
* Report a whole conversation ("this chat is not working").
|
|
292
|
+
*
|
|
293
|
+
* ```ts
|
|
294
|
+
* await client.submitConversationFeedback(conversationId, "negative", {
|
|
295
|
+
* reasons: ["information_not_found"],
|
|
296
|
+
* comment: "It never answered my question.",
|
|
297
|
+
* });
|
|
298
|
+
* ```
|
|
299
|
+
*
|
|
300
|
+
* Feedback is stored per message, so this attaches the report to the last
|
|
301
|
+
* answer of the conversation, which is the one the user is reacting to.
|
|
302
|
+
* Returns the message id it landed on.
|
|
303
|
+
*
|
|
304
|
+
* Pass `lastMessageId` when you already have it (the widget does) to skip the
|
|
305
|
+
* lookup round-trip.
|
|
277
306
|
*/
|
|
278
|
-
|
|
307
|
+
submitConversationFeedback(conversationId: string, rating: FeedbackRating, details?: FeedbackDetails & {
|
|
308
|
+
lastMessageId?: string;
|
|
309
|
+
}): Promise<string>;
|
|
279
310
|
/**
|
|
280
311
|
* Register a client-side function that AGO can call.
|
|
281
312
|
* Accepts either a definition object or (name, handler, schema) args.
|
|
@@ -907,12 +938,27 @@ declare interface AgoStateControl<T = unknown> {
|
|
|
907
938
|
enum?: (string | number)[];
|
|
908
939
|
};
|
|
909
940
|
};
|
|
941
|
+
/** String-only: `""` means "clear" instead of being dropped as filler. */
|
|
942
|
+
clearable?: boolean;
|
|
910
943
|
/** Current value → pushed as dynamic context so the agent knows what to change. */
|
|
911
944
|
get?: () => T;
|
|
912
945
|
/** Apply the state change on the page. May be async. */
|
|
913
|
-
set: (value: T) => void | Promise<void>;
|
|
946
|
+
set: (value: T) => void | AgoStateSetResult | Promise<void | AgoStateSetResult>;
|
|
914
947
|
}
|
|
915
948
|
|
|
949
|
+
/**
|
|
950
|
+
* Tagged outcome a page setter may return to reject or mark unchanged.
|
|
951
|
+
*
|
|
952
|
+
* Returning nothing (void) means APPLY. Returning an unrecognized JS value
|
|
953
|
+
* (e.g. a string from an assignment expression) is also treated as APPLY.
|
|
954
|
+
*/
|
|
955
|
+
declare type AgoStateSetResult = {
|
|
956
|
+
result: "rejected";
|
|
957
|
+
reason: string;
|
|
958
|
+
} | {
|
|
959
|
+
result: "unchanged";
|
|
960
|
+
};
|
|
961
|
+
|
|
916
962
|
/**
|
|
917
963
|
* Single-object function definition — combines name, schema, and handler.
|
|
918
964
|
*
|
|
@@ -1053,7 +1099,9 @@ export declare interface DevPanelOptions {
|
|
|
1053
1099
|
* function events, and renders the name + data of each entry in its live context
|
|
1054
1100
|
* snapshot (`client.getContextSnapshot()`)
|
|
1055
1101
|
*/
|
|
1056
|
-
client: Pick<AgoClient, "on" | "getRegisteredFunctions" | "getContextSnapshot"
|
|
1102
|
+
client: Pick<AgoClient, "on" | "off" | "getRegisteredFunctions" | "getContextSnapshot"> & {
|
|
1103
|
+
executeClientFunction?: AgoClient["executeClientFunction"];
|
|
1104
|
+
};
|
|
1057
1105
|
/** Where to mount: a CSS selector, an Element, or `document.body` (default). */
|
|
1058
1106
|
target?: string | Element;
|
|
1059
1107
|
/**
|
|
@@ -1067,6 +1115,12 @@ export declare interface DevPanelOptions {
|
|
|
1067
1115
|
* page (one per widget): pass e.g. the agent or widget name to tell them apart.
|
|
1068
1116
|
*/
|
|
1069
1117
|
label?: string;
|
|
1118
|
+
/**
|
|
1119
|
+
* Mount a local function runner in the panel. The runner executes registered
|
|
1120
|
+
* client functions locally via `client.executeClientFunction` and displays
|
|
1121
|
+
* the result. It never submits to the backend. Developer-only.
|
|
1122
|
+
*/
|
|
1123
|
+
enableFunctionRunner?: boolean;
|
|
1070
1124
|
}
|
|
1071
1125
|
|
|
1072
1126
|
/**
|
|
@@ -1076,6 +1130,37 @@ export declare interface DevPanelOptions {
|
|
|
1076
1130
|
*/
|
|
1077
1131
|
declare type DynamicContextProvider = () => ContextEntry | null | undefined;
|
|
1078
1132
|
|
|
1133
|
+
/**
|
|
1134
|
+
* Why the user is reporting a message (see `AgoClient.submitFeedback`).
|
|
1135
|
+
*
|
|
1136
|
+
* A rating on its own is a reaction (the thumbs count). Add a reason or a
|
|
1137
|
+
* comment and the report also lands in the feedback dashboard, the analytics
|
|
1138
|
+
* and the CSV export, where someone can act on it.
|
|
1139
|
+
*/
|
|
1140
|
+
declare interface FeedbackDetails {
|
|
1141
|
+
/** What went wrong. Several can apply at once. */
|
|
1142
|
+
reasons?: FeedbackReason[];
|
|
1143
|
+
/** The user's own words. Trimmed server-side; 5000 characters max. */
|
|
1144
|
+
comment?: string;
|
|
1145
|
+
}
|
|
1146
|
+
|
|
1147
|
+
/** Thumbs up / thumbs down on an answer. */
|
|
1148
|
+
declare type FeedbackRating = "positive" | "negative";
|
|
1149
|
+
|
|
1150
|
+
/**
|
|
1151
|
+
* What went wrong with an answer. These are the four buckets the AGO feedback
|
|
1152
|
+
* dashboard filters and charts on.
|
|
1153
|
+
*/
|
|
1154
|
+
declare type FeedbackReason =
|
|
1155
|
+
/** The answer states something false. */
|
|
1156
|
+
"inaccurate"
|
|
1157
|
+
/** The answer is right but stops short. */
|
|
1158
|
+
| "incomplete"
|
|
1159
|
+
/** The agent could not find the information. */
|
|
1160
|
+
| "information_not_found"
|
|
1161
|
+
/** Something broke: the widget, a tool call, the stream. */
|
|
1162
|
+
| "technical_issue";
|
|
1163
|
+
|
|
1079
1164
|
/**
|
|
1080
1165
|
* The backend-stored shape returned by `GET /api/sdk/v1/forms/{name}` (see
|
|
1081
1166
|
* {@link AgoClient.getFormCollector}). Mirrors the persistable subset of
|
|
@@ -1217,7 +1302,7 @@ declare class HttpClient {
|
|
|
1217
1302
|
private handleErrorResponse;
|
|
1218
1303
|
}
|
|
1219
1304
|
|
|
1220
|
-
export declare function initDevPanel(options: DevPanelOptions): void;
|
|
1305
|
+
export declare function initDevPanel(options: DevPanelOptions): () => void;
|
|
1221
1306
|
|
|
1222
1307
|
declare type MessageStatus = "IN_PROGRESS" | "DONE" | "ERROR" | "TODO" | "CANCELED"
|
|
1223
1308
|
/**
|