@useago/sdk 1.5.3 → 1.5.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/CHANGELOG.md +33 -0
- package/README.md +10 -0
- package/dist/AgoClient-BI5esqbd.js +1694 -0
- package/dist/AgoClient-CQh8YovA.cjs +8 -0
- package/dist/angular.cjs +1 -1
- package/dist/angular.d.cts +70 -3
- package/dist/angular.d.ts +70 -3
- package/dist/angular.js +3 -3
- package/dist/{createConversationSession-BCb0D6bt.cjs → createConversationSession-0zVkMdYj.cjs} +1 -1
- package/dist/{createConversationSession-C7cnnWKW.js → createConversationSession-BlYTpxwz.js} +1 -1
- package/dist/{createFormCollector-iCDwAwYJ.js → createFormCollector-Bgs94NyR.js} +1 -1
- package/dist/{createFormCollector-t_fGyuTD.cjs → createFormCollector-DiCe_8ik.cjs} +1 -1
- package/dist/devtools.d.cts +69 -2
- package/dist/devtools.d.ts +69 -2
- package/dist/functions-CPs7omgM.cjs +1 -0
- package/dist/helpers.cjs +1 -1
- package/dist/helpers.js +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +90 -2
- package/dist/index.d.ts +90 -2
- package/dist/index.js +64 -62
- package/dist/react.cjs +3 -3
- package/dist/react.d.cts +83 -2
- package/dist/react.d.ts +83 -2
- package/dist/react.js +240 -219
- package/dist/testing.cjs +1 -1
- package/dist/testing.d.cts +69 -2
- package/dist/testing.d.ts +69 -2
- package/dist/testing.js +1 -1
- package/dist/vue.cjs +1 -1
- package/dist/vue.d.cts +69 -2
- package/dist/vue.d.ts +69 -2
- package/dist/vue.js +2 -2
- package/dist/widget.cjs +2 -2
- package/dist/widget.d.cts +69 -2
- package/dist/widget.d.ts +69 -2
- package/dist/widget.js +4 -4
- package/llms-full.txt +29 -0
- package/package.json +1 -1
- package/dist/AgoClient-BGkFSNZF.cjs +0 -8
- package/dist/AgoClient-CW-BLT1_.js +0 -1542
- package/dist/functions-IGSjjvF4.cjs +0 -1
- package/dist/rolldown-runtime-16Nf8qvH.cjs +0 -1
- /package/dist/{autoContinue-D3Mmaaca.js → autoContinue-CC8K9mBU.js} +0 -0
- /package/dist/{autoContinue-CcCTva-D.cjs → autoContinue-CP9pJR-V.cjs} +0 -0
- /package/dist/{createMockClient-Br0TWgLO.js → createMockClient-DcuNlufr.js} +0 -0
- /package/dist/{createMockClient-BwNLPjeT.cjs → createMockClient-Dw-cyISN.cjs} +0 -0
- /package/dist/{functions-CApuQZ2b.js → functions-tzyOZNp6.js} +0 -0
package/dist/devtools.d.ts
CHANGED
|
@@ -1,3 +1,19 @@
|
|
|
1
|
+
declare interface ActivityEntry {
|
|
2
|
+
ts: number;
|
|
3
|
+
actor: "user" | "agent";
|
|
4
|
+
name: string;
|
|
5
|
+
summary: string;
|
|
6
|
+
data?: Record<string, unknown>;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
declare interface ActivityInput {
|
|
10
|
+
actor?: "user" | "agent";
|
|
11
|
+
name: string;
|
|
12
|
+
summary: string;
|
|
13
|
+
data?: Record<string, unknown>;
|
|
14
|
+
ts?: number;
|
|
15
|
+
}
|
|
16
|
+
|
|
1
17
|
/**
|
|
2
18
|
* Agent information
|
|
3
19
|
*/
|
|
@@ -36,6 +52,8 @@ declare class AgoClient {
|
|
|
36
52
|
private functionRegistry;
|
|
37
53
|
private contextRegistry;
|
|
38
54
|
private eventEmitter;
|
|
55
|
+
private activityLedger;
|
|
56
|
+
private lastSentPageState;
|
|
39
57
|
private config;
|
|
40
58
|
/** Conversations already warned about an empty reply (one warning each). */
|
|
41
59
|
private warnedEmptyConversations;
|
|
@@ -122,9 +140,14 @@ declare class AgoClient {
|
|
|
122
140
|
*/
|
|
123
141
|
rejectFunction(invocationId: string): Promise<void>;
|
|
124
142
|
/**
|
|
125
|
-
* Get
|
|
143
|
+
* Get a page of conversations, newest-first. `pageSize` is capped at 100 by
|
|
144
|
+
* the backend (default 50). Returns the `{ data, has_more, total }` envelope
|
|
145
|
+
* so callers can page; `total` counts across all pages.
|
|
126
146
|
*/
|
|
127
|
-
getConversations(
|
|
147
|
+
getConversations(options?: {
|
|
148
|
+
page?: number;
|
|
149
|
+
pageSize?: number;
|
|
150
|
+
}): Promise<PaginatedResult<Conversation>>;
|
|
128
151
|
/**
|
|
129
152
|
* Get a specific conversation with messages
|
|
130
153
|
*/
|
|
@@ -346,6 +369,19 @@ declare class AgoClient {
|
|
|
346
369
|
* Get the current context snapshot.
|
|
347
370
|
*/
|
|
348
371
|
getContextSnapshot(): ContextSnapshot | null;
|
|
372
|
+
private buildSendContext;
|
|
373
|
+
/**
|
|
374
|
+
* Record something the user just did so the agent is aware of it on the next
|
|
375
|
+
* message. `actor` defaults to `"user"`. Keep `summary` short and high-signal
|
|
376
|
+
* (no raw payloads, secrets, or PII).
|
|
377
|
+
*/
|
|
378
|
+
recordActivity(entry: ActivityInput): void;
|
|
379
|
+
/** Recent user + agent actions, oldest first (a copy). */
|
|
380
|
+
getRecentActivity(): ActivityEntry[];
|
|
381
|
+
clearActivity(): void;
|
|
382
|
+
private addActivity;
|
|
383
|
+
private recordAgentAction;
|
|
384
|
+
private registerActivityContext;
|
|
349
385
|
/**
|
|
350
386
|
* Subscribe to an event
|
|
351
387
|
*/
|
|
@@ -457,6 +493,15 @@ declare interface AgoClientEvents {
|
|
|
457
493
|
* notably `createFormCollector` — can replay them to restore their state.
|
|
458
494
|
*/
|
|
459
495
|
"conversation:loaded": Conversation;
|
|
496
|
+
/**
|
|
497
|
+
* The conversation's title was generated and streamed during a live turn
|
|
498
|
+
* (the backend emits it once, at the end of the first turn). Lets the UI
|
|
499
|
+
* update a header without a refetch.
|
|
500
|
+
*/
|
|
501
|
+
"conversation:title": {
|
|
502
|
+
conversationId: string;
|
|
503
|
+
title: string;
|
|
504
|
+
};
|
|
460
505
|
"toolCall:received": ToolCallData;
|
|
461
506
|
"toolCall:form": ToolCallData;
|
|
462
507
|
"function:invoke": ClientFunctionInvocation;
|
|
@@ -517,6 +562,8 @@ declare interface AgoClientEvents {
|
|
|
517
562
|
"nudge:accepted": {
|
|
518
563
|
nudge: ProactiveNudgeInstance;
|
|
519
564
|
};
|
|
565
|
+
/** A user- or agent-action was recorded into the activity ledger. */
|
|
566
|
+
"activity:recorded": ActivityEntry;
|
|
520
567
|
}
|
|
521
568
|
|
|
522
569
|
/**
|
|
@@ -578,6 +625,14 @@ declare interface AgoConfig {
|
|
|
578
625
|
* with `maxResultBytes` on its definition; `Infinity` disables the guard.
|
|
579
626
|
*/
|
|
580
627
|
maxFunctionResultBytes?: number;
|
|
628
|
+
/**
|
|
629
|
+
* Max number of recent actions kept in the in-memory activity ledger that
|
|
630
|
+
* rides along as the `activity:recent` context entry. Older entries drop
|
|
631
|
+
* first. Default `10`. Larger values give the agent more history at the cost
|
|
632
|
+
* of tokens on every message. Each entry's `data` is also size-clamped (long
|
|
633
|
+
* strings truncated, large arrays capped) so one event can't bloat the context.
|
|
634
|
+
*/
|
|
635
|
+
maxActivityEntries?: number;
|
|
581
636
|
/**
|
|
582
637
|
* Enable the proactive mode: declarative triggers evaluated client-side
|
|
583
638
|
* against friction signals (dwell/idle time, rage clicks, route bounces…)
|
|
@@ -987,6 +1042,16 @@ declare type NudgeAction = {
|
|
|
987
1042
|
setPageState: Record<string, unknown>;
|
|
988
1043
|
};
|
|
989
1044
|
|
|
1045
|
+
/**
|
|
1046
|
+
* A page of list results, mirroring the API's `{ data, has_more, total }`
|
|
1047
|
+
* envelope. `total` is the count across all pages, not just this page.
|
|
1048
|
+
*/
|
|
1049
|
+
declare interface PaginatedResult<T> {
|
|
1050
|
+
data: T[];
|
|
1051
|
+
hasMore: boolean;
|
|
1052
|
+
total: number;
|
|
1053
|
+
}
|
|
1054
|
+
|
|
990
1055
|
/**
|
|
991
1056
|
* Controller returned by {@link createAgoProactive} (also available as
|
|
992
1057
|
* `client.proactive`).
|
|
@@ -1239,6 +1304,8 @@ declare interface SSEChunkData {
|
|
|
1239
1304
|
thread?: {
|
|
1240
1305
|
id: string;
|
|
1241
1306
|
};
|
|
1307
|
+
/** Generated conversation title, streamed once at the end of the first turn. */
|
|
1308
|
+
title?: string;
|
|
1242
1309
|
agent?: {
|
|
1243
1310
|
id: string;
|
|
1244
1311
|
name: string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const v=require("./react.cjs");var w=v.__exportAll({copyToClipboard:()=>c,getLocalStorage:()=>f,getUserLocation:()=>p,highlightElement:()=>h,openUrl:()=>a,scrollToElement:()=>d,setLocalStorage:()=>m,setTheme:()=>l,showConfirmDialog:()=>u,showNotification:()=>s,showToast:()=>i,submitForm:()=>y,trackEvent:()=>g}),i={name:"showToast",description:"Show a toast notification to the user. Use this to confirm actions or display brief messages.",parameters:{type:"object",properties:{message:{type:"string",description:"The message to display"},type:{type:"string",description:"Toast type",enum:["success","error","warning","info"]},duration:{type:"number",description:"Duration in milliseconds (default 3000)"}},required:["message"]},handler:async()=>({shown:!1,error:"No toast handler configured"})},s={name:"showNotification",description:"Show a browser notification to the user. Useful for important alerts even when the tab is not focused.",parameters:{type:"object",properties:{title:{type:"string",description:"Notification title"},body:{type:"string",description:"Notification body text"}},required:["title"]},handler:async e=>typeof Notification>"u"?{shown:!1,error:"Notifications not supported"}:Notification.permission==="denied"?{shown:!1,error:"Notification permission denied"}:(Notification.permission!=="granted"&&await Notification.requestPermission(),Notification.permission==="granted"?(new Notification(e.title,{body:e.body}),{shown:!0}):{shown:!1,error:"Permission not granted"})},a={name:"openUrl",description:"Open a URL in a new browser tab.",parameters:{type:"object",properties:{url:{type:"string",description:"The URL to open"}},required:["url"]},handler:async e=>(window.open(e.url,"_blank","noopener,noreferrer"),{opened:!0})},c={name:"copyToClipboard",description:"Copy text to the user's clipboard.",parameters:{type:"object",properties:{text:{type:"string",description:"The text to copy"}},required:["text"]},handler:async e=>(await navigator.clipboard.writeText(e.text),{copied:!0})},l={name:"setTheme",description:"Change the application's color theme. Sets a data-theme attribute on the document element.",parameters:{type:"object",properties:{theme:{type:"string",description:"Theme to apply",enum:["light","dark","system"]}},required:["theme"]},handler:async e=>{const t=e.theme;return document.documentElement.setAttribute("data-theme",t),t==="dark"?document.documentElement.classList.add("dark"):document.documentElement.classList.remove("dark"),{theme:t,applied:!0}}},u={name:"showConfirmDialog",description:"Show a confirmation dialog to the user and return their choice (true/false).",parameters:{type:"object",properties:{message:{type:"string",description:"The confirmation message to display"}},required:["message"]},handler:async e=>({confirmed:window.confirm(e.message)})},p={name:"getUserLocation",description:"Get the user's current geographic location (requires permission).",parameters:{type:"object",properties:{}},handler:async()=>navigator.geolocation?new Promise(e=>{navigator.geolocation.getCurrentPosition(t=>e({latitude:t.coords.latitude,longitude:t.coords.longitude,accuracy:t.coords.accuracy}),t=>e({error:t.message}))}):{error:"Geolocation not supported"}},d={name:"scrollToElement",description:"Scroll the page to a specific element identified by CSS selector.",parameters:{type:"object",properties:{selector:{type:"string",description:"CSS selector of the element to scroll to (e.g. '#section-pricing')"},behavior:{type:"string",description:"Scroll behavior",enum:["smooth","instant"]}},required:["selector"]},handler:async e=>{const t=document.querySelector(e.selector);return t?(t.scrollIntoView({behavior:e.behavior||"smooth"}),{scrolled:!0}):{scrolled:!1,error:`Element not found: ${e.selector}`}}},m={name:"setLocalStorage",description:"Store a value in the browser's localStorage.",parameters:{type:"object",properties:{key:{type:"string",description:"Storage key"},value:{type:"string",description:"Value to store"}},required:["key","value"]},handler:async e=>(localStorage.setItem(e.key,e.value),{stored:!0})},f={name:"getLocalStorage",description:"Retrieve a value from the browser's localStorage.",parameters:{type:"object",properties:{key:{type:"string",description:"Storage key"}},required:["key"]},handler:async e=>{const t=localStorage.getItem(e.key);return{key:e.key,value:t,found:t!==null}}},h={name:"highlightElement",description:"Highlight a DOM element to draw the user's attention (e.g. for onboarding).",parameters:{type:"object",properties:{selector:{type:"string",description:"CSS selector of the element to highlight"},color:{type:"string",description:"Highlight border color (default: #3b82f6)"}},required:["selector"]},handler:async e=>{const t=document.querySelector(e.selector);if(!t)return{highlighted:!1,error:`Element not found: ${e.selector}`};const r=t.style.outline,o=e.color||"#3b82f6";return t.style.outline=`3px solid ${o}`,t.style.outlineOffset="2px",t.scrollIntoView({behavior:"smooth",block:"center"}),setTimeout(()=>{t.style.outline=r,t.style.outlineOffset=""},3e3),{highlighted:!0}}},y={name:"submitForm",description:"Fill and submit an HTML form on the page. Pass field values as key-value pairs.",parameters:{type:"object",properties:{selector:{type:"string",description:"CSS selector of the form element"},values:{type:"string",description:"JSON string of field name → value pairs"}},required:["selector"]},handler:async e=>{const t=document.querySelector(e.selector);if(!t)return{submitted:!1,error:`Form not found: ${e.selector}`};if(e.values){const r=JSON.parse(e.values);for(const[o,b]of Object.entries(r)){const n=t.elements.namedItem(o);n&&(n.value=b)}}return t.requestSubmit(),{submitted:!0}}},g={name:"trackEvent",description:"Track a custom analytics event. Override the handler to wire up your analytics provider.",parameters:{type:"object",properties:{event:{type:"string",description:"Event name"},properties:{type:"string",description:"JSON string of event properties"}},required:["event"]},handler:async e=>{const t=e.properties?JSON.parse(e.properties):{};return console.log(`[AGO Analytics] ${e.event}`,t),{tracked:!0,event:e.event}}};Object.defineProperty(exports,"copyToClipboard",{enumerable:!0,get:function(){return c}});Object.defineProperty(exports,"functions_exports",{enumerable:!0,get:function(){return w}});Object.defineProperty(exports,"getLocalStorage",{enumerable:!0,get:function(){return f}});Object.defineProperty(exports,"getUserLocation",{enumerable:!0,get:function(){return p}});Object.defineProperty(exports,"highlightElement",{enumerable:!0,get:function(){return h}});Object.defineProperty(exports,"openUrl",{enumerable:!0,get:function(){return a}});Object.defineProperty(exports,"scrollToElement",{enumerable:!0,get:function(){return d}});Object.defineProperty(exports,"setLocalStorage",{enumerable:!0,get:function(){return m}});Object.defineProperty(exports,"setTheme",{enumerable:!0,get:function(){return l}});Object.defineProperty(exports,"showConfirmDialog",{enumerable:!0,get:function(){return u}});Object.defineProperty(exports,"showNotification",{enumerable:!0,get:function(){return s}});Object.defineProperty(exports,"showToast",{enumerable:!0,get:function(){return i}});Object.defineProperty(exports,"submitForm",{enumerable:!0,get:function(){return y}});Object.defineProperty(exports,"trackEvent",{enumerable:!0,get:function(){return g}});
|
package/dist/helpers.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("./functions-
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("./functions-CPs7omgM.cjs");exports.copyToClipboard=o.copyToClipboard;exports.getLocalStorage=o.getLocalStorage;exports.getUserLocation=o.getUserLocation;exports.highlightElement=o.highlightElement;exports.openUrl=o.openUrl;exports.scrollToElement=o.scrollToElement;exports.setLocalStorage=o.setLocalStorage;exports.setTheme=o.setTheme;exports.showConfirmDialog=o.showConfirmDialog;exports.showNotification=o.showNotification;exports.showToast=o.showToast;exports.submitForm=o.submitForm;exports.trackEvent=o.trackEvent;
|
package/dist/helpers.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a, c as s, d as t, f as e, i as r, l as i, m as l, o as m, p as c, r as g, s as h, t as n, u as p } from "./functions-
|
|
1
|
+
import { a, c as s, d as t, f as e, i as r, l as i, m as l, o as m, p as c, r as g, s as h, t as n, u as p } from "./functions-tzyOZNp6.js";
|
|
2
2
|
export {
|
|
3
3
|
n as copyToClipboard,
|
|
4
4
|
g as getLocalStorage,
|
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("./AgoClient-
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("./AgoClient-CQh8YovA.cjs"),C=require("./autoContinue-CP9pJR-V.cjs"),p=require("./createConversationSession-0zVkMdYj.cjs"),f=require("./createFormCollector-DiCe_8ik.cjs"),E=require("./createMockClient-Dw-cyISN.cjs");require("./testing.cjs");const g=require("./functions-CPs7omgM.cjs");function S(e){return e}function w(e,o){return e.on("message:complete",o),()=>e.off("message:complete",o)}function y(e,o){return e.on("message:chunk",o),()=>e.off("message:chunk",o)}function v(e,o){return e.on("message:start",o),()=>e.off("message:start",o)}function F(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 M(e,o){return e.on("form:submitted",o),()=>e.off("form:submitted",o)}function T(e,o){return e.on("form:error",o),()=>e.off("form:error",o)}function q(e,o){return e.on("function:invoke",o),()=>e.off("function:invoke",o)}async function*I(e,o,l){const a=[];let n=null,i=!1;const c=s=>{a.push(s),n?.()},m=s=>c({type:"start",data:s}),r=s=>c({type:"chunk",data:s}),u=s=>{c({type:"complete",data:s}),i=!0,n?.()},d=s=>{c({type:"error",data:s}),i=!0,n?.()},A=s=>c({type:"toolCall",data:s});e.on("message:start",m),e.on("message:chunk",r),e.on("message:complete",u),e.on("message:error",d),e.on("toolCall:received",A),e.sendMessage(o,l).catch(()=>{i=!0,n?.()});try{for(;!i||a.length>0;)a.length>0?yield a.shift():(await new Promise(s=>{n=s}),n=null)}finally{e.off("message:start",m),e.off("message:chunk",r),e.off("message:complete",u),e.off("message:error",d),e.off("toolCall:received",A)}}function h(e){let o,l,a,n,i,c;if(typeof window<"u"&&window.AGO){const r=window.AGO;o=r.basepath,l=r.widgetId,a=r.agent||r.defaultAgent,n=r.permission,i=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"),a=a||r("ago-agent")||r("ago-agent-id"),n=n||r("ago-permission"),i=i||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,a=a||u.getAttribute("data-ago-agent")||u.getAttribute("data-ago-agent-id")||void 0,n=n||u.getAttribute("data-ago-permission")||void 0,i=i||u.getAttribute("data-ago-user-email")||void 0)}o=e?.baseUrl||o,l=e?.widgetId||l,a=e?.agent||e?.defaultAgentId||a,n=e?.permission||n,i=e?.userEmail||i,c=e?.userJwt||c;const m=e?.debug;return o?{baseUrl:o,widgetId:l,agent:a,permission:n,userEmail:i,userJwt:c,debug:m}:null}function _(e){const o=h(e);if(!o)throw new t.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 k(e,o){return{...e,handler:o}}exports.ActivityLedger=t.ActivityLedger;exports.AgoApiError=t.AgoApiError;exports.AgoClient=t.AgoClient;exports.AgoError=t.AgoError;exports.AgoFunctionError=t.AgoFunctionError;exports.AgoNetworkError=t.AgoNetworkError;exports.AgoStreamError=t.AgoStreamError;exports.ClientContextRegistry=t.ClientContextRegistry;exports.DEFAULT_MAX_ACTIVITY_ENTRIES=t.DEFAULT_MAX_ACTIVITY_ENTRIES;exports.EventEmitter=t.EventEmitter;exports.FunctionRegistry=t.FunctionRegistry;exports.SSEHandler=t.SSEHandler;exports.SignalCollector=t.SignalCollector;exports.attachAutoContinueAfterNavigation=C.attachAutoContinueAfterNavigation;exports.autoDetectConfig=h;exports.canInlineImage=t.canInlineImage;exports.copyToClipboard=g.copyToClipboard;exports.createAgo=_;exports.createAgoProactive=t.createAgoProactive;exports.createConversationSession=p.createConversationSession;exports.createFormCollector=f.createFormCollector;exports.createMessageStream=I;exports.createMockClient=E.createMockClient;exports.createStore=t.createStore;exports.defineFunction=S;exports.deriveFormStatus=f.deriveFormStatus;exports.formatFileSize=t.formatFileSize;exports.getLocalStorage=g.getLocalStorage;exports.getUserLocation=g.getUserLocation;exports.highlightElement=g.highlightElement;exports.isStreamNetworkError=t.isStreamNetworkError;exports.loadFormCollector=f.loadFormCollector;exports.logger=t.logger;exports.matchesRoutePattern=t.matchesRoutePattern;exports.matchesWhen=t.matchesWhen;exports.onFormError=T;exports.onFormSubmitted=M;exports.onFunctionInvoke=q;exports.onMessage=w;exports.onMessageChunk=y;exports.onMessageError=F;exports.onMessageStart=v;exports.onToolCall=b;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=k;
|
package/dist/index.d.cts
CHANGED
|
@@ -1,3 +1,30 @@
|
|
|
1
|
+
export declare interface ActivityEntry {
|
|
2
|
+
ts: number;
|
|
3
|
+
actor: "user" | "agent";
|
|
4
|
+
name: string;
|
|
5
|
+
summary: string;
|
|
6
|
+
data?: Record<string, unknown>;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export declare interface ActivityInput {
|
|
10
|
+
actor?: "user" | "agent";
|
|
11
|
+
name: string;
|
|
12
|
+
summary: string;
|
|
13
|
+
data?: Record<string, unknown>;
|
|
14
|
+
ts?: number;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/** Capped, in-memory log of recent user and agent actions (oldest dropped first). */
|
|
18
|
+
export declare class ActivityLedger {
|
|
19
|
+
private entries;
|
|
20
|
+
private readonly maxEntries;
|
|
21
|
+
constructor(maxEntries?: number);
|
|
22
|
+
add(input: ActivityInput): ActivityEntry;
|
|
23
|
+
getRecent(): ActivityEntry[];
|
|
24
|
+
get size(): number;
|
|
25
|
+
clear(): void;
|
|
26
|
+
}
|
|
27
|
+
|
|
1
28
|
/**
|
|
2
29
|
* Agent information
|
|
3
30
|
*/
|
|
@@ -64,6 +91,8 @@ export declare class AgoClient {
|
|
|
64
91
|
private functionRegistry;
|
|
65
92
|
private contextRegistry;
|
|
66
93
|
private eventEmitter;
|
|
94
|
+
private activityLedger;
|
|
95
|
+
private lastSentPageState;
|
|
67
96
|
private config;
|
|
68
97
|
/** Conversations already warned about an empty reply (one warning each). */
|
|
69
98
|
private warnedEmptyConversations;
|
|
@@ -150,9 +179,14 @@ export declare class AgoClient {
|
|
|
150
179
|
*/
|
|
151
180
|
rejectFunction(invocationId: string): Promise<void>;
|
|
152
181
|
/**
|
|
153
|
-
* Get
|
|
182
|
+
* Get a page of conversations, newest-first. `pageSize` is capped at 100 by
|
|
183
|
+
* the backend (default 50). Returns the `{ data, has_more, total }` envelope
|
|
184
|
+
* so callers can page; `total` counts across all pages.
|
|
154
185
|
*/
|
|
155
|
-
getConversations(
|
|
186
|
+
getConversations(options?: {
|
|
187
|
+
page?: number;
|
|
188
|
+
pageSize?: number;
|
|
189
|
+
}): Promise<PaginatedResult<Conversation>>;
|
|
156
190
|
/**
|
|
157
191
|
* Get a specific conversation with messages
|
|
158
192
|
*/
|
|
@@ -374,6 +408,19 @@ export declare class AgoClient {
|
|
|
374
408
|
* Get the current context snapshot.
|
|
375
409
|
*/
|
|
376
410
|
getContextSnapshot(): ContextSnapshot | null;
|
|
411
|
+
private buildSendContext;
|
|
412
|
+
/**
|
|
413
|
+
* Record something the user just did so the agent is aware of it on the next
|
|
414
|
+
* message. `actor` defaults to `"user"`. Keep `summary` short and high-signal
|
|
415
|
+
* (no raw payloads, secrets, or PII).
|
|
416
|
+
*/
|
|
417
|
+
recordActivity(entry: ActivityInput): void;
|
|
418
|
+
/** Recent user + agent actions, oldest first (a copy). */
|
|
419
|
+
getRecentActivity(): ActivityEntry[];
|
|
420
|
+
clearActivity(): void;
|
|
421
|
+
private addActivity;
|
|
422
|
+
private recordAgentAction;
|
|
423
|
+
private registerActivityContext;
|
|
377
424
|
/**
|
|
378
425
|
* Subscribe to an event
|
|
379
426
|
*/
|
|
@@ -485,6 +532,15 @@ export declare interface AgoClientEvents {
|
|
|
485
532
|
* notably `createFormCollector` — can replay them to restore their state.
|
|
486
533
|
*/
|
|
487
534
|
"conversation:loaded": Conversation;
|
|
535
|
+
/**
|
|
536
|
+
* The conversation's title was generated and streamed during a live turn
|
|
537
|
+
* (the backend emits it once, at the end of the first turn). Lets the UI
|
|
538
|
+
* update a header without a refetch.
|
|
539
|
+
*/
|
|
540
|
+
"conversation:title": {
|
|
541
|
+
conversationId: string;
|
|
542
|
+
title: string;
|
|
543
|
+
};
|
|
488
544
|
"toolCall:received": ToolCallData;
|
|
489
545
|
"toolCall:form": ToolCallData;
|
|
490
546
|
"function:invoke": ClientFunctionInvocation;
|
|
@@ -545,6 +601,8 @@ export declare interface AgoClientEvents {
|
|
|
545
601
|
"nudge:accepted": {
|
|
546
602
|
nudge: ProactiveNudgeInstance;
|
|
547
603
|
};
|
|
604
|
+
/** A user- or agent-action was recorded into the activity ledger. */
|
|
605
|
+
"activity:recorded": ActivityEntry;
|
|
548
606
|
}
|
|
549
607
|
|
|
550
608
|
/**
|
|
@@ -606,6 +664,14 @@ export declare interface AgoConfig {
|
|
|
606
664
|
* with `maxResultBytes` on its definition; `Infinity` disables the guard.
|
|
607
665
|
*/
|
|
608
666
|
maxFunctionResultBytes?: number;
|
|
667
|
+
/**
|
|
668
|
+
* Max number of recent actions kept in the in-memory activity ledger that
|
|
669
|
+
* rides along as the `activity:recent` context entry. Older entries drop
|
|
670
|
+
* first. Default `10`. Larger values give the agent more history at the cost
|
|
671
|
+
* of tokens on every message. Each entry's `data` is also size-clamped (long
|
|
672
|
+
* strings truncated, large arrays capped) so one event can't bloat the context.
|
|
673
|
+
*/
|
|
674
|
+
maxActivityEntries?: number;
|
|
609
675
|
/**
|
|
610
676
|
* Enable the proactive mode: declarative triggers evaluated client-side
|
|
611
677
|
* against friction signals (dwell/idle time, rage clicks, route bounces…)
|
|
@@ -1238,6 +1304,8 @@ export declare function createMockClient(options?: MockAgoClientOptions): MockAg
|
|
|
1238
1304
|
|
|
1239
1305
|
export declare function createStore<T>(initial: T, persist?: PersistOptions): Store<T>;
|
|
1240
1306
|
|
|
1307
|
+
export declare const DEFAULT_MAX_ACTIVITY_ENTRIES = 10;
|
|
1308
|
+
|
|
1241
1309
|
/**
|
|
1242
1310
|
* Create a reusable function definition.
|
|
1243
1311
|
* Returns the same object — this is an identity function for discoverability and type-checking.
|
|
@@ -1792,6 +1860,16 @@ export declare function onToolCall(client: AgoClient, callback: (toolCall: ToolC
|
|
|
1792
1860
|
*/
|
|
1793
1861
|
export declare const openUrl: ClientFunctionDefinition;
|
|
1794
1862
|
|
|
1863
|
+
/**
|
|
1864
|
+
* A page of list results, mirroring the API's `{ data, has_more, total }`
|
|
1865
|
+
* envelope. `total` is the count across all pages, not just this page.
|
|
1866
|
+
*/
|
|
1867
|
+
export declare interface PaginatedResult<T> {
|
|
1868
|
+
data: T[];
|
|
1869
|
+
hasMore: boolean;
|
|
1870
|
+
total: number;
|
|
1871
|
+
}
|
|
1872
|
+
|
|
1795
1873
|
/**
|
|
1796
1874
|
* Partial deep match: every key/value present in `expected` must match the
|
|
1797
1875
|
* corresponding value in `actual`. Nested objects recurse (partially); arrays
|
|
@@ -2260,6 +2338,8 @@ export declare interface SSEChunkData {
|
|
|
2260
2338
|
thread?: {
|
|
2261
2339
|
id: string;
|
|
2262
2340
|
};
|
|
2341
|
+
/** Generated conversation title, streamed once at the end of the first turn. */
|
|
2342
|
+
title?: string;
|
|
2263
2343
|
agent?: {
|
|
2264
2344
|
id: string;
|
|
2265
2345
|
name: string;
|
|
@@ -2341,6 +2421,14 @@ declare interface SSEHandlerCallbacks {
|
|
|
2341
2421
|
arguments: Record<string, unknown>;
|
|
2342
2422
|
conversationId: string;
|
|
2343
2423
|
}) => void;
|
|
2424
|
+
/**
|
|
2425
|
+
* The conversation's title was generated and streamed (the backend emits it
|
|
2426
|
+
* once, near the end of the first turn).
|
|
2427
|
+
*/
|
|
2428
|
+
onTitle?: (data: {
|
|
2429
|
+
conversationId: string;
|
|
2430
|
+
title: string;
|
|
2431
|
+
}) => void;
|
|
2344
2432
|
/**
|
|
2345
2433
|
* The main answer text is finished (the backend emitted `status: "DONE"`) but
|
|
2346
2434
|
* follow-up replies may still be streaming. Fires once, before {@link onComplete},
|
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,30 @@
|
|
|
1
|
+
export declare interface ActivityEntry {
|
|
2
|
+
ts: number;
|
|
3
|
+
actor: "user" | "agent";
|
|
4
|
+
name: string;
|
|
5
|
+
summary: string;
|
|
6
|
+
data?: Record<string, unknown>;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export declare interface ActivityInput {
|
|
10
|
+
actor?: "user" | "agent";
|
|
11
|
+
name: string;
|
|
12
|
+
summary: string;
|
|
13
|
+
data?: Record<string, unknown>;
|
|
14
|
+
ts?: number;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/** Capped, in-memory log of recent user and agent actions (oldest dropped first). */
|
|
18
|
+
export declare class ActivityLedger {
|
|
19
|
+
private entries;
|
|
20
|
+
private readonly maxEntries;
|
|
21
|
+
constructor(maxEntries?: number);
|
|
22
|
+
add(input: ActivityInput): ActivityEntry;
|
|
23
|
+
getRecent(): ActivityEntry[];
|
|
24
|
+
get size(): number;
|
|
25
|
+
clear(): void;
|
|
26
|
+
}
|
|
27
|
+
|
|
1
28
|
/**
|
|
2
29
|
* Agent information
|
|
3
30
|
*/
|
|
@@ -64,6 +91,8 @@ export declare class AgoClient {
|
|
|
64
91
|
private functionRegistry;
|
|
65
92
|
private contextRegistry;
|
|
66
93
|
private eventEmitter;
|
|
94
|
+
private activityLedger;
|
|
95
|
+
private lastSentPageState;
|
|
67
96
|
private config;
|
|
68
97
|
/** Conversations already warned about an empty reply (one warning each). */
|
|
69
98
|
private warnedEmptyConversations;
|
|
@@ -150,9 +179,14 @@ export declare class AgoClient {
|
|
|
150
179
|
*/
|
|
151
180
|
rejectFunction(invocationId: string): Promise<void>;
|
|
152
181
|
/**
|
|
153
|
-
* Get
|
|
182
|
+
* Get a page of conversations, newest-first. `pageSize` is capped at 100 by
|
|
183
|
+
* the backend (default 50). Returns the `{ data, has_more, total }` envelope
|
|
184
|
+
* so callers can page; `total` counts across all pages.
|
|
154
185
|
*/
|
|
155
|
-
getConversations(
|
|
186
|
+
getConversations(options?: {
|
|
187
|
+
page?: number;
|
|
188
|
+
pageSize?: number;
|
|
189
|
+
}): Promise<PaginatedResult<Conversation>>;
|
|
156
190
|
/**
|
|
157
191
|
* Get a specific conversation with messages
|
|
158
192
|
*/
|
|
@@ -374,6 +408,19 @@ export declare class AgoClient {
|
|
|
374
408
|
* Get the current context snapshot.
|
|
375
409
|
*/
|
|
376
410
|
getContextSnapshot(): ContextSnapshot | null;
|
|
411
|
+
private buildSendContext;
|
|
412
|
+
/**
|
|
413
|
+
* Record something the user just did so the agent is aware of it on the next
|
|
414
|
+
* message. `actor` defaults to `"user"`. Keep `summary` short and high-signal
|
|
415
|
+
* (no raw payloads, secrets, or PII).
|
|
416
|
+
*/
|
|
417
|
+
recordActivity(entry: ActivityInput): void;
|
|
418
|
+
/** Recent user + agent actions, oldest first (a copy). */
|
|
419
|
+
getRecentActivity(): ActivityEntry[];
|
|
420
|
+
clearActivity(): void;
|
|
421
|
+
private addActivity;
|
|
422
|
+
private recordAgentAction;
|
|
423
|
+
private registerActivityContext;
|
|
377
424
|
/**
|
|
378
425
|
* Subscribe to an event
|
|
379
426
|
*/
|
|
@@ -485,6 +532,15 @@ export declare interface AgoClientEvents {
|
|
|
485
532
|
* notably `createFormCollector` — can replay them to restore their state.
|
|
486
533
|
*/
|
|
487
534
|
"conversation:loaded": Conversation;
|
|
535
|
+
/**
|
|
536
|
+
* The conversation's title was generated and streamed during a live turn
|
|
537
|
+
* (the backend emits it once, at the end of the first turn). Lets the UI
|
|
538
|
+
* update a header without a refetch.
|
|
539
|
+
*/
|
|
540
|
+
"conversation:title": {
|
|
541
|
+
conversationId: string;
|
|
542
|
+
title: string;
|
|
543
|
+
};
|
|
488
544
|
"toolCall:received": ToolCallData;
|
|
489
545
|
"toolCall:form": ToolCallData;
|
|
490
546
|
"function:invoke": ClientFunctionInvocation;
|
|
@@ -545,6 +601,8 @@ export declare interface AgoClientEvents {
|
|
|
545
601
|
"nudge:accepted": {
|
|
546
602
|
nudge: ProactiveNudgeInstance;
|
|
547
603
|
};
|
|
604
|
+
/** A user- or agent-action was recorded into the activity ledger. */
|
|
605
|
+
"activity:recorded": ActivityEntry;
|
|
548
606
|
}
|
|
549
607
|
|
|
550
608
|
/**
|
|
@@ -606,6 +664,14 @@ export declare interface AgoConfig {
|
|
|
606
664
|
* with `maxResultBytes` on its definition; `Infinity` disables the guard.
|
|
607
665
|
*/
|
|
608
666
|
maxFunctionResultBytes?: number;
|
|
667
|
+
/**
|
|
668
|
+
* Max number of recent actions kept in the in-memory activity ledger that
|
|
669
|
+
* rides along as the `activity:recent` context entry. Older entries drop
|
|
670
|
+
* first. Default `10`. Larger values give the agent more history at the cost
|
|
671
|
+
* of tokens on every message. Each entry's `data` is also size-clamped (long
|
|
672
|
+
* strings truncated, large arrays capped) so one event can't bloat the context.
|
|
673
|
+
*/
|
|
674
|
+
maxActivityEntries?: number;
|
|
609
675
|
/**
|
|
610
676
|
* Enable the proactive mode: declarative triggers evaluated client-side
|
|
611
677
|
* against friction signals (dwell/idle time, rage clicks, route bounces…)
|
|
@@ -1238,6 +1304,8 @@ export declare function createMockClient(options?: MockAgoClientOptions): MockAg
|
|
|
1238
1304
|
|
|
1239
1305
|
export declare function createStore<T>(initial: T, persist?: PersistOptions): Store<T>;
|
|
1240
1306
|
|
|
1307
|
+
export declare const DEFAULT_MAX_ACTIVITY_ENTRIES = 10;
|
|
1308
|
+
|
|
1241
1309
|
/**
|
|
1242
1310
|
* Create a reusable function definition.
|
|
1243
1311
|
* Returns the same object — this is an identity function for discoverability and type-checking.
|
|
@@ -1792,6 +1860,16 @@ export declare function onToolCall(client: AgoClient, callback: (toolCall: ToolC
|
|
|
1792
1860
|
*/
|
|
1793
1861
|
export declare const openUrl: ClientFunctionDefinition;
|
|
1794
1862
|
|
|
1863
|
+
/**
|
|
1864
|
+
* A page of list results, mirroring the API's `{ data, has_more, total }`
|
|
1865
|
+
* envelope. `total` is the count across all pages, not just this page.
|
|
1866
|
+
*/
|
|
1867
|
+
export declare interface PaginatedResult<T> {
|
|
1868
|
+
data: T[];
|
|
1869
|
+
hasMore: boolean;
|
|
1870
|
+
total: number;
|
|
1871
|
+
}
|
|
1872
|
+
|
|
1795
1873
|
/**
|
|
1796
1874
|
* Partial deep match: every key/value present in `expected` must match the
|
|
1797
1875
|
* corresponding value in `actual`. Nested objects recurse (partially); arrays
|
|
@@ -2260,6 +2338,8 @@ export declare interface SSEChunkData {
|
|
|
2260
2338
|
thread?: {
|
|
2261
2339
|
id: string;
|
|
2262
2340
|
};
|
|
2341
|
+
/** Generated conversation title, streamed once at the end of the first turn. */
|
|
2342
|
+
title?: string;
|
|
2263
2343
|
agent?: {
|
|
2264
2344
|
id: string;
|
|
2265
2345
|
name: string;
|
|
@@ -2341,6 +2421,14 @@ declare interface SSEHandlerCallbacks {
|
|
|
2341
2421
|
arguments: Record<string, unknown>;
|
|
2342
2422
|
conversationId: string;
|
|
2343
2423
|
}) => void;
|
|
2424
|
+
/**
|
|
2425
|
+
* The conversation's title was generated and streamed (the backend emits it
|
|
2426
|
+
* once, near the end of the first turn).
|
|
2427
|
+
*/
|
|
2428
|
+
onTitle?: (data: {
|
|
2429
|
+
conversationId: string;
|
|
2430
|
+
title: string;
|
|
2431
|
+
}) => void;
|
|
2344
2432
|
/**
|
|
2345
2433
|
* The main answer text is finished (the backend emitted `status: "DONE"`) but
|
|
2346
2434
|
* follow-up replies may still be streaming. Fires once, before {@link onComplete},
|