@useago/sdk 1.4.3 → 1.5.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.
Files changed (44) hide show
  1. package/CHANGELOG.md +15 -1
  2. package/dist/{AgoClient-S8oeNnAE.js → AgoClient-q39FIjSC.js} +105 -81
  3. package/dist/AgoClient-wcPRaIMs.cjs +8 -0
  4. package/dist/angular.cjs +1 -1
  5. package/dist/angular.d.cts +75 -5
  6. package/dist/angular.d.ts +75 -5
  7. package/dist/angular.js +5 -1
  8. package/dist/autoContinue-CcCTva-D.cjs +1 -0
  9. package/dist/autoContinue-D3Mmaaca.js +63 -0
  10. package/dist/{createConversationSession-CmBq7uGi.cjs → createConversationSession-BBYfQLLS.cjs} +1 -1
  11. package/dist/{createConversationSession-DoUHdVNR.js → createConversationSession-DCSWShaW.js} +1 -1
  12. package/dist/{createFormCollector-Bz_0IJ0Q.cjs → createFormCollector-eimwwWEi.cjs} +1 -1
  13. package/dist/{createFormCollector-vy-QvFja.js → createFormCollector-sB6rMccD.js} +1 -1
  14. package/dist/devtools.d.cts +32 -4
  15. package/dist/devtools.d.ts +32 -4
  16. package/dist/helpers.cjs +1 -1
  17. package/dist/helpers.d.cts +6 -0
  18. package/dist/helpers.d.ts +6 -0
  19. package/dist/index.cjs +1 -1
  20. package/dist/index.d.cts +101 -5
  21. package/dist/index.d.ts +101 -5
  22. package/dist/index.js +45 -43
  23. package/dist/react.cjs +3 -3
  24. package/dist/react.d.cts +40 -18
  25. package/dist/react.d.ts +40 -18
  26. package/dist/react.js +415 -471
  27. package/dist/testing.cjs +1 -1
  28. package/dist/testing.d.cts +32 -4
  29. package/dist/testing.d.ts +32 -4
  30. package/dist/testing.js +1 -1
  31. package/dist/vue.cjs +1 -1
  32. package/dist/vue.d.cts +38 -4
  33. package/dist/vue.d.ts +38 -4
  34. package/dist/vue.js +22 -21
  35. package/dist/widget.cjs +1 -1
  36. package/dist/widget.d.cts +32 -4
  37. package/dist/widget.d.ts +32 -4
  38. package/dist/widget.js +3 -3
  39. package/llms-full.txt +1932 -0
  40. package/package.json +5 -3
  41. package/dist/AgoClient-CMDVqNaH.cjs +0 -8
  42. /package/dist/{createMockClient-bAZ9KBHC.js → createMockClient-BUc9PSbo.js} +0 -0
  43. /package/dist/{createMockClient-BSr-UV8R.cjs → createMockClient-CjdCqixj.cjs} +0 -0
  44. /package/dist/{functions-Djnq-JAo.cjs → functions-IGSjjvF4.cjs} +0 -0
package/dist/testing.cjs CHANGED
@@ -1 +1 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./createMockClient-BSr-UV8R.cjs");exports.createMockClient=e.createMockClient;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./createMockClient-CjdCqixj.cjs");exports.createMockClient=e.createMockClient;
@@ -175,7 +175,7 @@ declare class AgoClient {
175
175
  * ```
176
176
  */
177
177
  registerFunction(definition: ClientFunctionDefinition): void;
178
- registerFunction(name: string, handler: ClientFunctionHandler, schema: Omit<ClientFunctionSchema, "name">): void;
178
+ registerFunction(name: string, handler: ClientFunctionHandler, schema: ClientFunctionRegisterOptions): void;
179
179
  /**
180
180
  * Short alias for `registerFunction`. Also accepts an array of definitions.
181
181
  *
@@ -476,14 +476,22 @@ declare interface AgoConfig {
476
476
  warnOnEmptyReply?: boolean;
477
477
  /**
478
478
  * How the agent loop treats client function calls (requires backend support):
479
- * - `"placeholder"` (default): the turn continues immediately on a placeholder
480
- * result; the real result is only visible to the agent on later turns.
481
- * - `"pause"`: the turn stops on client function call(s) with status
479
+ * - `"pause"` (default): the turn stops on client function call(s) with status
482
480
  * `WAITING_CLIENT`; once every result is submitted, the SDK resumes the SAME
483
481
  * turn via `POST /messages/{id}/continue`, so the agent sees the real results.
482
+ * - `"placeholder"` (legacy): the turn continues immediately on a placeholder
483
+ * result; the real result is only visible to the agent on later turns.
484
484
  * Older backends ignore the flag, so `"pause"` degrades to legacy behavior.
485
485
  */
486
486
  clientFunctionsMode?: ClientFunctionsMode;
487
+ /**
488
+ * Max serialized size (bytes) of a client function result before the SDK
489
+ * replaces it with a flagged, truncated preview. Everything a handler
490
+ * returns is sent into the LLM context, so this caps runaway payloads
491
+ * (raw API responses, full tables). Default `50000`. Override per function
492
+ * with `maxResultBytes` on its definition; `Infinity` disables the guard.
493
+ */
494
+ maxFunctionResultBytes?: number;
487
495
  }
488
496
 
489
497
  declare type AgoEventHandler<K extends AgoEventName> = (data: AgoClientEvents[K]) => void;
@@ -575,6 +583,12 @@ declare interface ClientFunctionDefinition {
575
583
  description: string;
576
584
  parameters: ClientFunctionSchema["parameters"];
577
585
  handler: ClientFunctionHandler;
586
+ /**
587
+ * Max serialized result size in bytes before the SDK truncates it to a
588
+ * flagged preview (default: `AgoConfig.maxFunctionResultBytes`, 50 000).
589
+ * `Infinity` disables the guard for this function.
590
+ */
591
+ maxResultBytes?: number;
578
592
  }
579
593
 
580
594
  /**
@@ -589,6 +603,20 @@ declare interface ClientFunctionInvocation {
589
603
  conversationId: string;
590
604
  }
591
605
 
606
+ /**
607
+ * Schema-plus-settings object accepted when registering a function: the schema
608
+ * (minus `name`) and SDK-side options that are NOT sent to the backend.
609
+ */
610
+ declare type ClientFunctionRegisterOptions = Omit<ClientFunctionSchema, "name"> & {
611
+ /**
612
+ * Max serialized result size in bytes before the SDK truncates it to a
613
+ * flagged preview. Overrides the client-level default
614
+ * (`AgoConfig.maxFunctionResultBytes`, 50 000 by default). `Infinity`
615
+ * disables the guard for this function.
616
+ */
617
+ maxResultBytes?: number;
618
+ };
619
+
592
620
  /**
593
621
  * Schema for a client-side function that AGO can call
594
622
  */
package/dist/testing.d.ts CHANGED
@@ -175,7 +175,7 @@ declare class AgoClient {
175
175
  * ```
176
176
  */
177
177
  registerFunction(definition: ClientFunctionDefinition): void;
178
- registerFunction(name: string, handler: ClientFunctionHandler, schema: Omit<ClientFunctionSchema, "name">): void;
178
+ registerFunction(name: string, handler: ClientFunctionHandler, schema: ClientFunctionRegisterOptions): void;
179
179
  /**
180
180
  * Short alias for `registerFunction`. Also accepts an array of definitions.
181
181
  *
@@ -476,14 +476,22 @@ declare interface AgoConfig {
476
476
  warnOnEmptyReply?: boolean;
477
477
  /**
478
478
  * How the agent loop treats client function calls (requires backend support):
479
- * - `"placeholder"` (default): the turn continues immediately on a placeholder
480
- * result; the real result is only visible to the agent on later turns.
481
- * - `"pause"`: the turn stops on client function call(s) with status
479
+ * - `"pause"` (default): the turn stops on client function call(s) with status
482
480
  * `WAITING_CLIENT`; once every result is submitted, the SDK resumes the SAME
483
481
  * turn via `POST /messages/{id}/continue`, so the agent sees the real results.
482
+ * - `"placeholder"` (legacy): the turn continues immediately on a placeholder
483
+ * result; the real result is only visible to the agent on later turns.
484
484
  * Older backends ignore the flag, so `"pause"` degrades to legacy behavior.
485
485
  */
486
486
  clientFunctionsMode?: ClientFunctionsMode;
487
+ /**
488
+ * Max serialized size (bytes) of a client function result before the SDK
489
+ * replaces it with a flagged, truncated preview. Everything a handler
490
+ * returns is sent into the LLM context, so this caps runaway payloads
491
+ * (raw API responses, full tables). Default `50000`. Override per function
492
+ * with `maxResultBytes` on its definition; `Infinity` disables the guard.
493
+ */
494
+ maxFunctionResultBytes?: number;
487
495
  }
488
496
 
489
497
  declare type AgoEventHandler<K extends AgoEventName> = (data: AgoClientEvents[K]) => void;
@@ -575,6 +583,12 @@ declare interface ClientFunctionDefinition {
575
583
  description: string;
576
584
  parameters: ClientFunctionSchema["parameters"];
577
585
  handler: ClientFunctionHandler;
586
+ /**
587
+ * Max serialized result size in bytes before the SDK truncates it to a
588
+ * flagged preview (default: `AgoConfig.maxFunctionResultBytes`, 50 000).
589
+ * `Infinity` disables the guard for this function.
590
+ */
591
+ maxResultBytes?: number;
578
592
  }
579
593
 
580
594
  /**
@@ -589,6 +603,20 @@ declare interface ClientFunctionInvocation {
589
603
  conversationId: string;
590
604
  }
591
605
 
606
+ /**
607
+ * Schema-plus-settings object accepted when registering a function: the schema
608
+ * (minus `name`) and SDK-side options that are NOT sent to the backend.
609
+ */
610
+ declare type ClientFunctionRegisterOptions = Omit<ClientFunctionSchema, "name"> & {
611
+ /**
612
+ * Max serialized result size in bytes before the SDK truncates it to a
613
+ * flagged preview. Overrides the client-level default
614
+ * (`AgoConfig.maxFunctionResultBytes`, 50 000 by default). `Infinity`
615
+ * disables the guard for this function.
616
+ */
617
+ maxResultBytes?: number;
618
+ };
619
+
592
620
  /**
593
621
  * Schema for a client-side function that AGO can call
594
622
  */
package/dist/testing.js CHANGED
@@ -1,4 +1,4 @@
1
- import { t as e } from "./createMockClient-bAZ9KBHC.js";
1
+ import { t as e } from "./createMockClient-BUc9PSbo.js";
2
2
  export {
3
3
  e as createMockClient
4
4
  };
package/dist/vue.cjs CHANGED
@@ -1 +1 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const U=require("./rolldown-runtime-16Nf8qvH.cjs"),p=require("./AgoClient-CMDVqNaH.cjs");let o=require("vue");var I=Symbol("ago-client"),S={install(t,n){const e=new p.AgoClient(n);t.provide(I,e)}};function d(t){if(t)return new p.AgoClient(t);const n=(0,o.inject)(I);if(!n)throw new Error("useAgo(): no AgoClient found. Either pass config or install AgoPlugin.");return n}function E(t={}){const n=t.client??d(),e=(0,o.ref)([]),s=(0,o.ref)(t.conversationId),i=(0,o.ref)(!1),r=(0,o.ref)(null),c=a=>{s.value||(s.value=a.conversationId)},f=a=>{const u=e.value.findIndex(v=>v.id===a.messageId);u>=0&&(e.value[u]={...e.value[u],content:e.value[u].content+a.content})},m=a=>{const u=e.value.findIndex(v=>v.id===a.id);u>=0?e.value[u]=a:e.value.push(a),i.value=!1},C=a=>{r.value=new Error(a.error),i.value=!1};(0,o.onMounted)(()=>{n.on("message:start",c),n.on("message:chunk",f),n.on("message:complete",m),n.on("message:error",C)}),(0,o.onUnmounted)(()=>{n.off("message:start",c),n.off("message:chunk",f),n.off("message:complete",m),n.off("message:error",C)});async function g(a,u){i.value=!0,r.value=null;const v={id:`temp-${Date.now()}`,conversationId:s.value||"",content:a,role:"user",status:"DONE",createdAt:new Date},N={id:`temp-assistant-${Date.now()}`,conversationId:s.value||"",content:"",role:"assistant",status:"IN_PROGRESS",createdAt:new Date};e.value.push(v,N);try{const l=await n.sendMessage(a,{conversationId:s.value,files:u});l.conversationId&&!s.value&&(s.value=l.conversationId),e.value=e.value.filter(w=>!w.id.startsWith("temp-"));const A={...v,id:v.id.replace("temp-","user-"),conversationId:l.conversationId};return e.value.some(w=>w.id===l.id)?e.value.push(A):e.value.push(A,l),l}catch(l){return r.value=l instanceof Error?l:new Error("Failed to send"),i.value=!1,e.value=e.value.filter(A=>!A.id.startsWith("temp-")),null}}function h(){e.value=[],s.value=void 0,r.value=null}return{messages:e,isLoading:i,error:r,conversationId:s,sendMessage:g,clearMessages:h}}function M(t={}){const n=t.client??d(),e=t.autoLoad??!0,s=(0,o.ref)([]),i=(0,o.ref)(null),r=(0,o.ref)(!1),c=(0,o.ref)(null);async function f(){r.value=!0,c.value=null;try{s.value=await n.getConversations()}catch(g){c.value=g instanceof Error?g:new Error("Failed to load conversations")}finally{r.value=!1}}async function m(g){r.value=!0,c.value=null;try{i.value=await n.getConversation(g)}catch(h){c.value=h instanceof Error?h:new Error("Failed to load conversation")}finally{r.value=!1}}function C(){i.value=null}return(0,o.onMounted)(()=>{e&&f()}),{conversations:s,currentConversation:i,isLoading:r,error:c,selectConversation:m,startNewConversation:C,refreshConversations:f}}function L(t={}){const n=E({client:t.client,conversationId:t.conversationId}),e=M({client:t.client,autoLoad:t.autoLoad}),s=(0,o.computed)(()=>n.error.value||e.error.value);return{messages:n.messages,isLoading:n.isLoading,error:s,sendMessage:n.sendMessage,clearMessages:n.clearMessages,conversationId:n.conversationId,conversations:e.conversations,currentConversation:e.currentConversation,isConversationsLoading:e.isLoading,selectConversation:e.selectConversation,startNewConversation:e.startNewConversation,refreshConversations:e.refreshConversations}}function y(t,n){const e=d();(0,o.onMounted)(()=>{e.registerFunction(t,n.handler,{description:n.description,parameters:n.parameters})}),(0,o.onUnmounted)(()=>{e.unregisterFunction(t)})}function F(t,n){const e=d();(0,o.onMounted)(()=>{e.registerNavigationFunction(t,n)}),(0,o.onUnmounted)(()=>{e.unregisterNavigationFunction()})}function P(t,n){const e=d(),s=n?.functionName??"setPageState";(0,o.onMounted)(()=>{e.registerPageStateFunction(t,{functionName:s})}),(0,o.onUnmounted)(()=>{e.unregisterPageStateFunction(s)})}function _(t,n){const e=d();(0,o.onMounted)(()=>{e.on(t,n)}),(0,o.onUnmounted)(()=>{e.off(t,n)})}function D(t){const n=(0,o.shallowRef)(t.get());return(0,o.onScopeDispose)(t.subscribe(e=>{n.value=e})),n}exports.AGO_CLIENT_KEY=I;exports.AgoPlugin=S;exports.useAgo=d;exports.useAgoEvents=_;exports.useAgoFunction=y;exports.useAgoNavigation=F;exports.useAgoPageState=P;exports.useAgoStore=D;exports.useChat=L;exports.useConversation=M;exports.useMessages=E;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const x=require("./rolldown-runtime-16Nf8qvH.cjs"),E=require("./AgoClient-wcPRaIMs.cjs");let o=require("vue");var I=Symbol("ago-client"),S={install(t,n){const e=new E.AgoClient(n);t.provide(I,e)}};function d(t){if(t)return new E.AgoClient(t);const n=(0,o.inject)(I);if(!n)throw new Error("useAgo(): no AgoClient found. Either pass config or install AgoPlugin.");return n}function M(t={}){const n=t.client??d(),e=(0,o.ref)([]),s=(0,o.ref)(t.conversationId),u=(0,o.ref)(!1),r=(0,o.ref)(null),c=a=>{s.value||(s.value=a.conversationId)},f=a=>{const i=e.value.findIndex(v=>v.id===a.messageId);i>=0&&(e.value[i]={...e.value[i],content:e.value[i].content+a.content})},m=a=>{const i=e.value.findIndex(v=>v.id===a.id);i>=0?e.value[i]=a:e.value.push(a),u.value=!1},C=a=>{r.value=new Error(a.error),u.value=!1};(0,o.onMounted)(()=>{n.on("message:start",c),n.on("message:chunk",f),n.on("message:complete",m),n.on("message:error",C)}),(0,o.onUnmounted)(()=>{n.off("message:start",c),n.off("message:chunk",f),n.off("message:complete",m),n.off("message:error",C)});async function g(a,i){u.value=!0,r.value=null;const v={id:`temp-${Date.now()}`,conversationId:s.value||"",content:a,role:"user",status:"DONE",createdAt:new Date},N={id:`temp-assistant-${Date.now()}`,conversationId:s.value||"",content:"",role:"assistant",status:"IN_PROGRESS",createdAt:new Date};e.value.push(v,N);try{const l=await n.sendMessage(a,{conversationId:s.value,files:i});l.conversationId&&!s.value&&(s.value=l.conversationId),e.value=e.value.filter(w=>!w.id.startsWith("temp-"));const A={...v,id:v.id.replace("temp-","user-"),conversationId:l.conversationId};return e.value.some(w=>w.id===l.id)?e.value.push(A):e.value.push(A,l),l}catch(l){return r.value=l instanceof Error?l:new Error("Failed to send"),u.value=!1,e.value=e.value.filter(A=>!A.id.startsWith("temp-")),null}}function h(){e.value=[],s.value=void 0,r.value=null}return{messages:e,isLoading:u,error:r,conversationId:s,sendMessage:g,clearMessages:h}}function p(t={}){const n=t.client??d(),e=t.autoLoad??!0,s=(0,o.ref)([]),u=(0,o.ref)(null),r=(0,o.ref)(!1),c=(0,o.ref)(null);async function f(){r.value=!0,c.value=null;try{s.value=await n.getConversations()}catch(g){c.value=g instanceof Error?g:new Error("Failed to load conversations")}finally{r.value=!1}}async function m(g){r.value=!0,c.value=null;try{u.value=await n.getConversation(g)}catch(h){c.value=h instanceof Error?h:new Error("Failed to load conversation")}finally{r.value=!1}}function C(){u.value=null}return(0,o.onMounted)(()=>{e&&f()}),{conversations:s,currentConversation:u,isLoading:r,error:c,selectConversation:m,startNewConversation:C,refreshConversations:f}}function y(t={}){const n=M({client:t.client,conversationId:t.conversationId}),e=p({client:t.client,autoLoad:t.autoLoad}),s=(0,o.computed)(()=>n.error.value||e.error.value);return{messages:n.messages,isLoading:n.isLoading,error:s,sendMessage:n.sendMessage,clearMessages:n.clearMessages,conversationId:n.conversationId,conversations:e.conversations,currentConversation:e.currentConversation,isConversationsLoading:e.isLoading,selectConversation:e.selectConversation,startNewConversation:e.startNewConversation,refreshConversations:e.refreshConversations}}function L(t,n){const e=d();(0,o.onMounted)(()=>{e.registerFunction(t,n.handler,{description:n.description,parameters:n.parameters,maxResultBytes:n.maxResultBytes})}),(0,o.onUnmounted)(()=>{e.unregisterFunction(t)})}function F(t,n){const e=d();(0,o.onMounted)(()=>{e.registerNavigationFunction(t,n)}),(0,o.onUnmounted)(()=>{e.unregisterNavigationFunction()})}function P(t,n){const e=d(),s=n?.functionName??"setPageState";(0,o.onMounted)(()=>{e.registerPageStateFunction(t,{functionName:s})}),(0,o.onUnmounted)(()=>{e.unregisterPageStateFunction(s)})}function _(t,n){const e=d();(0,o.onMounted)(()=>{e.on(t,n)}),(0,o.onUnmounted)(()=>{e.off(t,n)})}function R(t){const n=(0,o.shallowRef)(t.get());return(0,o.onScopeDispose)(t.subscribe(e=>{n.value=e})),n}exports.AGO_CLIENT_KEY=I;exports.AgoPlugin=S;exports.useAgo=d;exports.useAgoEvents=_;exports.useAgoFunction=L;exports.useAgoNavigation=F;exports.useAgoPageState=P;exports.useAgoStore=R;exports.useChat=y;exports.useConversation=p;exports.useMessages=M;
package/dist/vue.d.cts CHANGED
@@ -183,7 +183,7 @@ declare class AgoClient {
183
183
  * ```
184
184
  */
185
185
  registerFunction(definition: ClientFunctionDefinition): void;
186
- registerFunction(name: string, handler: ClientFunctionHandler, schema: Omit<ClientFunctionSchema, "name">): void;
186
+ registerFunction(name: string, handler: ClientFunctionHandler, schema: ClientFunctionRegisterOptions): void;
187
187
  /**
188
188
  * Short alias for `registerFunction`. Also accepts an array of definitions.
189
189
  *
@@ -484,14 +484,22 @@ export declare interface AgoConfig {
484
484
  warnOnEmptyReply?: boolean;
485
485
  /**
486
486
  * How the agent loop treats client function calls (requires backend support):
487
- * - `"placeholder"` (default): the turn continues immediately on a placeholder
488
- * result; the real result is only visible to the agent on later turns.
489
- * - `"pause"`: the turn stops on client function call(s) with status
487
+ * - `"pause"` (default): the turn stops on client function call(s) with status
490
488
  * `WAITING_CLIENT`; once every result is submitted, the SDK resumes the SAME
491
489
  * turn via `POST /messages/{id}/continue`, so the agent sees the real results.
490
+ * - `"placeholder"` (legacy): the turn continues immediately on a placeholder
491
+ * result; the real result is only visible to the agent on later turns.
492
492
  * Older backends ignore the flag, so `"pause"` degrades to legacy behavior.
493
493
  */
494
494
  clientFunctionsMode?: ClientFunctionsMode;
495
+ /**
496
+ * Max serialized size (bytes) of a client function result before the SDK
497
+ * replaces it with a flagged, truncated preview. Everything a handler
498
+ * returns is sent into the LLM context, so this caps runaway payloads
499
+ * (raw API responses, full tables). Default `50000`. Override per function
500
+ * with `maxResultBytes` on its definition; `Infinity` disables the guard.
501
+ */
502
+ maxFunctionResultBytes?: number;
495
503
  }
496
504
 
497
505
  declare type AgoEventHandler<K extends AgoEventName> = (data: AgoClientEvents[K]) => void;
@@ -604,6 +612,12 @@ declare interface ClientFunctionDefinition {
604
612
  description: string;
605
613
  parameters: ClientFunctionSchema["parameters"];
606
614
  handler: ClientFunctionHandler;
615
+ /**
616
+ * Max serialized result size in bytes before the SDK truncates it to a
617
+ * flagged preview (default: `AgoConfig.maxFunctionResultBytes`, 50 000).
618
+ * `Infinity` disables the guard for this function.
619
+ */
620
+ maxResultBytes?: number;
607
621
  }
608
622
 
609
623
  /**
@@ -618,6 +632,20 @@ declare interface ClientFunctionInvocation {
618
632
  conversationId: string;
619
633
  }
620
634
 
635
+ /**
636
+ * Schema-plus-settings object accepted when registering a function: the schema
637
+ * (minus `name`) and SDK-side options that are NOT sent to the backend.
638
+ */
639
+ declare type ClientFunctionRegisterOptions = Omit<ClientFunctionSchema, "name"> & {
640
+ /**
641
+ * Max serialized result size in bytes before the SDK truncates it to a
642
+ * flagged preview. Overrides the client-level default
643
+ * (`AgoConfig.maxFunctionResultBytes`, 50 000 by default). `Infinity`
644
+ * disables the guard for this function.
645
+ */
646
+ maxResultBytes?: number;
647
+ };
648
+
621
649
  /**
622
650
  * Schema for a client-side function that AGO can call
623
651
  */
@@ -998,6 +1026,12 @@ export declare function useAgoFunction(name: string, options: {
998
1026
  description: string;
999
1027
  parameters: ClientFunctionSchema["parameters"];
1000
1028
  handler: ClientFunctionHandler;
1029
+ /**
1030
+ * Max serialized result size in bytes before the SDK truncates it to a
1031
+ * flagged preview (default: `AgoConfig.maxFunctionResultBytes`, 50 000).
1032
+ * `Infinity` disables the guard for this function.
1033
+ */
1034
+ maxResultBytes?: number;
1001
1035
  }): void;
1002
1036
 
1003
1037
  /**
package/dist/vue.d.ts CHANGED
@@ -183,7 +183,7 @@ declare class AgoClient {
183
183
  * ```
184
184
  */
185
185
  registerFunction(definition: ClientFunctionDefinition): void;
186
- registerFunction(name: string, handler: ClientFunctionHandler, schema: Omit<ClientFunctionSchema, "name">): void;
186
+ registerFunction(name: string, handler: ClientFunctionHandler, schema: ClientFunctionRegisterOptions): void;
187
187
  /**
188
188
  * Short alias for `registerFunction`. Also accepts an array of definitions.
189
189
  *
@@ -484,14 +484,22 @@ export declare interface AgoConfig {
484
484
  warnOnEmptyReply?: boolean;
485
485
  /**
486
486
  * How the agent loop treats client function calls (requires backend support):
487
- * - `"placeholder"` (default): the turn continues immediately on a placeholder
488
- * result; the real result is only visible to the agent on later turns.
489
- * - `"pause"`: the turn stops on client function call(s) with status
487
+ * - `"pause"` (default): the turn stops on client function call(s) with status
490
488
  * `WAITING_CLIENT`; once every result is submitted, the SDK resumes the SAME
491
489
  * turn via `POST /messages/{id}/continue`, so the agent sees the real results.
490
+ * - `"placeholder"` (legacy): the turn continues immediately on a placeholder
491
+ * result; the real result is only visible to the agent on later turns.
492
492
  * Older backends ignore the flag, so `"pause"` degrades to legacy behavior.
493
493
  */
494
494
  clientFunctionsMode?: ClientFunctionsMode;
495
+ /**
496
+ * Max serialized size (bytes) of a client function result before the SDK
497
+ * replaces it with a flagged, truncated preview. Everything a handler
498
+ * returns is sent into the LLM context, so this caps runaway payloads
499
+ * (raw API responses, full tables). Default `50000`. Override per function
500
+ * with `maxResultBytes` on its definition; `Infinity` disables the guard.
501
+ */
502
+ maxFunctionResultBytes?: number;
495
503
  }
496
504
 
497
505
  declare type AgoEventHandler<K extends AgoEventName> = (data: AgoClientEvents[K]) => void;
@@ -604,6 +612,12 @@ declare interface ClientFunctionDefinition {
604
612
  description: string;
605
613
  parameters: ClientFunctionSchema["parameters"];
606
614
  handler: ClientFunctionHandler;
615
+ /**
616
+ * Max serialized result size in bytes before the SDK truncates it to a
617
+ * flagged preview (default: `AgoConfig.maxFunctionResultBytes`, 50 000).
618
+ * `Infinity` disables the guard for this function.
619
+ */
620
+ maxResultBytes?: number;
607
621
  }
608
622
 
609
623
  /**
@@ -618,6 +632,20 @@ declare interface ClientFunctionInvocation {
618
632
  conversationId: string;
619
633
  }
620
634
 
635
+ /**
636
+ * Schema-plus-settings object accepted when registering a function: the schema
637
+ * (minus `name`) and SDK-side options that are NOT sent to the backend.
638
+ */
639
+ declare type ClientFunctionRegisterOptions = Omit<ClientFunctionSchema, "name"> & {
640
+ /**
641
+ * Max serialized result size in bytes before the SDK truncates it to a
642
+ * flagged preview. Overrides the client-level default
643
+ * (`AgoConfig.maxFunctionResultBytes`, 50 000 by default). `Infinity`
644
+ * disables the guard for this function.
645
+ */
646
+ maxResultBytes?: number;
647
+ };
648
+
621
649
  /**
622
650
  * Schema for a client-side function that AGO can call
623
651
  */
@@ -998,6 +1026,12 @@ export declare function useAgoFunction(name: string, options: {
998
1026
  description: string;
999
1027
  parameters: ClientFunctionSchema["parameters"];
1000
1028
  handler: ClientFunctionHandler;
1029
+ /**
1030
+ * Max serialized result size in bytes before the SDK truncates it to a
1031
+ * flagged preview (default: `AgoConfig.maxFunctionResultBytes`, 50 000).
1032
+ * `Infinity` disables the guard for this function.
1033
+ */
1034
+ maxResultBytes?: number;
1001
1035
  }): void;
1002
1036
 
1003
1037
  /**
package/dist/vue.js CHANGED
@@ -1,16 +1,16 @@
1
- import { t as A } from "./AgoClient-S8oeNnAE.js";
2
- import { computed as M, inject as F, onMounted as f, onScopeDispose as S, onUnmounted as h, ref as c, shallowRef as y } from "vue";
1
+ import { t as A } from "./AgoClient-q39FIjSC.js";
2
+ import { computed as L, inject as M, onMounted as f, onScopeDispose as F, onUnmounted as h, ref as c, shallowRef as S } from "vue";
3
3
  var N = /* @__PURE__ */ Symbol("ago-client"), b = { install(t, n) {
4
4
  const e = new A(n);
5
5
  t.provide(N, e);
6
6
  } };
7
7
  function g(t) {
8
8
  if (t) return new A(t);
9
- const n = F(N);
9
+ const n = M(N);
10
10
  if (!n) throw new Error("useAgo(): no AgoClient found. Either pass config or install AgoPlugin.");
11
11
  return n;
12
12
  }
13
- function P(t = {}) {
13
+ function x(t = {}) {
14
14
  const n = t.client ?? g(), e = c([]), s = c(t.conversationId), r = c(!1), a = c(null), l = (o) => {
15
15
  s.value || (s.value = o.conversationId);
16
16
  }, m = (o) => {
@@ -39,7 +39,7 @@ function P(t = {}) {
39
39
  role: "user",
40
40
  status: "DONE",
41
41
  createdAt: /* @__PURE__ */ new Date()
42
- }, L = {
42
+ }, y = {
43
43
  id: `temp-assistant-${Date.now()}`,
44
44
  conversationId: s.value || "",
45
45
  content: "",
@@ -47,7 +47,7 @@ function P(t = {}) {
47
47
  status: "IN_PROGRESS",
48
48
  createdAt: /* @__PURE__ */ new Date()
49
49
  };
50
- e.value.push(v, L);
50
+ e.value.push(v, y);
51
51
  try {
52
52
  const u = await n.sendMessage(o, {
53
53
  conversationId: s.value,
@@ -76,7 +76,7 @@ function P(t = {}) {
76
76
  clearMessages: w
77
77
  };
78
78
  }
79
- function D(t = {}) {
79
+ function P(t = {}) {
80
80
  const n = t.client ?? g(), e = t.autoLoad ?? !0, s = c([]), r = c(null), a = c(!1), l = c(null);
81
81
  async function m() {
82
82
  a.value = !0, l.value = null;
@@ -114,13 +114,13 @@ function D(t = {}) {
114
114
  };
115
115
  }
116
116
  function k(t = {}) {
117
- const n = P({
117
+ const n = x({
118
118
  client: t.client,
119
119
  conversationId: t.conversationId
120
- }), e = D({
120
+ }), e = P({
121
121
  client: t.client,
122
122
  autoLoad: t.autoLoad
123
- }), s = M(() => n.error.value || e.error.value);
123
+ }), s = L(() => n.error.value || e.error.value);
124
124
  return {
125
125
  messages: n.messages,
126
126
  isLoading: n.isLoading,
@@ -141,7 +141,8 @@ function O(t, n) {
141
141
  f(() => {
142
142
  e.registerFunction(t, n.handler, {
143
143
  description: n.description,
144
- parameters: n.parameters
144
+ parameters: n.parameters,
145
+ maxResultBytes: n.maxResultBytes
145
146
  });
146
147
  }), h(() => {
147
148
  e.unregisterFunction(t);
@@ -155,7 +156,7 @@ function _(t, n) {
155
156
  e.unregisterNavigationFunction();
156
157
  });
157
158
  }
158
- function G(t, n) {
159
+ function B(t, n) {
159
160
  const e = g(), s = n?.functionName ?? "setPageState";
160
161
  f(() => {
161
162
  e.registerPageStateFunction(t, { functionName: s });
@@ -163,7 +164,7 @@ function G(t, n) {
163
164
  e.unregisterPageStateFunction(s);
164
165
  });
165
166
  }
166
- function U(t, n) {
167
+ function G(t, n) {
167
168
  const e = g();
168
169
  f(() => {
169
170
  e.on(t, n);
@@ -171,9 +172,9 @@ function U(t, n) {
171
172
  e.off(t, n);
172
173
  });
173
174
  }
174
- function W(t) {
175
- const n = y(t.get());
176
- return S(t.subscribe((e) => {
175
+ function U(t) {
176
+ const n = S(t.get());
177
+ return F(t.subscribe((e) => {
177
178
  n.value = e;
178
179
  })), n;
179
180
  }
@@ -181,12 +182,12 @@ export {
181
182
  N as AGO_CLIENT_KEY,
182
183
  b as AgoPlugin,
183
184
  g as useAgo,
184
- U as useAgoEvents,
185
+ G as useAgoEvents,
185
186
  O as useAgoFunction,
186
187
  _ as useAgoNavigation,
187
- G as useAgoPageState,
188
- W as useAgoStore,
188
+ B as useAgoPageState,
189
+ U as useAgoStore,
189
190
  k as useChat,
190
- D as useConversation,
191
- P as useMessages
191
+ P as useConversation,
192
+ x as useMessages
192
193
  };
package/dist/widget.cjs CHANGED
@@ -1,4 +1,4 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const se=require("./AgoClient-CMDVqNaH.cjs"),ct=require("./createFormCollector-Bz_0IJ0Q.cjs"),Gt=require("./createConversationSession-CmBq7uGi.cjs");var jt='"IBM Plex Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif',Re=`var(--ago-font, ${jt})`,pt={font:"--ago-font",radius:"--ago-radius",messageRadius:"--ago-message-radius",brand:"--ago-brand-color",brandText:"--ago-brand-text-color",headerBg:"--ago-header-background",headerText:"--ago-header-text-color",panelBg:"--ago-panel-background",messagesBg:"--ago-messages-background",text:"--ago-text-color",mutedText:"--ago-muted-text-color",border:"--ago-border-color",accent:"--ago-accent-color",agentBubbleBg:"--ago-agent-bubble-background"},Ae="var(--ago-brand-color, #03182f)",_e="var(--ago-brand-text-color, #fff)",Vt="var(--ago-header-background, var(--ago-brand-color, #03182f))",ft="var(--ago-header-text-color, #e8f0fe)",ee="var(--ago-panel-background, #fff)",xt="var(--ago-messages-background, #fbfbfb)",J="var(--ago-text-color, #30373e)",bt="var(--ago-muted-text-color, #6b6d6f)",L="var(--ago-border-color, #dee3e8)",De="var(--ago-accent-color, #1b5fc4)",ut="var(--ago-agent-bubble-background, #f1f3f5)",qt="var(--ago-radius, 16px)",ze="var(--ago-message-radius, 16px)",Kt="var(--ago-message-radius, 20px)";function Xt(n,o){if(o)for(const i of Object.keys(pt)){const r=o[i];r!=null&&n.style.setProperty(pt[i],r)}}function v(n,o){Object.assign(n.style,o)}function h(n={}){const o=document.createElement("div");return v(o,n),o}var mt="ago-chat-widget-keyframes";function Qt(){if(typeof document>"u"||document.getElementById(mt))return;const n=document.createElement("style");n.id=mt,n.textContent="@keyframes ago-pulse { 0%, 80%, 100% { opacity: 0.3; transform: scale(0.8); } 40% { opacity: 1; transform: scale(1); } }@keyframes ago-spin { to { transform: rotate(360deg); } }",document.head.appendChild(n)}function Yt(n){let o=[];const i=document.createElement("form");v(i,{display:"flex",flexDirection:"column",gap:"8px",padding:"12px",borderTop:`1px solid ${L}`,backgroundColor:ee}),i.className="ago-chat-input";const r=h({display:"flex",flexWrap:"wrap",gap:"6px"}),b=h({display:"flex",gap:"8px",alignItems:"flex-end"}),a=document.createElement("textarea");a.placeholder=n.placeholder,a.setAttribute("aria-label",n.placeholder),a.rows=1,v(a,{flex:"1",resize:"none",boxSizing:"border-box",padding:"10px 12px",border:`1px solid ${L}`,borderRadius:"12px",fontSize:"16px",fontFamily:Re,lineHeight:"1.4",maxHeight:"110px",overflowY:"hidden"});const C=()=>{a.style.height="auto";const c=Math.min(a.scrollHeight+2,110);a.style.height=`${c}px`,a.style.overflowY=a.scrollHeight+2>110?"auto":"hidden"};a.addEventListener("input",()=>{C(),A()});const m='<svg width="18" height="18" viewBox="0 -960 960 960" fill="currentColor" aria-hidden="true"><path d="M440-160v-487L216-423l-56-57 320-320 320 320-56 57-224-224v487h-80Z"/></svg>',x='<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" aria-hidden="true" style="animation: ago-spin 0.8s linear infinite"><path d="M21 12a9 9 0 1 1-6.219-8.56"/></svg>',p=document.createElement("button");p.type="submit",p.setAttribute("aria-label","Send"),p.innerHTML=m,v(p,{flexShrink:"0",width:"40px",height:"40px",padding:"0",border:"none",borderRadius:"50%",backgroundColor:Ae,color:_e,display:"flex",alignItems:"center",justifyContent:"center",cursor:"pointer"});let f=!1;const A=()=>{const s=a.value.trim()!==""||o.length>0,c=f||!s;p.disabled=c,p.innerHTML=f?x:m,p.style.opacity=c&&!f?"0.5":"1",p.style.cursor=c?"default":"pointer"};let R=null,_=null;n.allowFiles&&(R=document.createElement("input"),R.type="file",R.multiple=!0,v(R,{display:"none"}),_=document.createElement("button"),_.type="button",_.setAttribute("aria-label","Attach file"),_.textContent="📎",v(_,{padding:"10px 12px",border:`1px solid ${L}`,borderRadius:"12px",backgroundColor:ee,cursor:"pointer",fontSize:"14px"}),_.addEventListener("click",()=>R?.click()),R.addEventListener("change",()=>{o=[...o,...Array.from(R?.files??[])],Y()}));function Y(){r.replaceChildren(),o.forEach((s,c)=>{const w=h({display:"flex",alignItems:"center",gap:"4px",padding:"4px 8px",backgroundColor:"#f0f4ff",border:`1px solid ${L}`,borderRadius:"8px",fontSize:"12px"}),$=document.createElement("span");$.textContent=s.name;const I=document.createElement("button");I.type="button",I.setAttribute("aria-label",`Remove ${s.name}`),I.textContent="×",v(I,{border:"none",background:"transparent",cursor:"pointer",fontSize:"14px",lineHeight:"1"}),I.addEventListener("click",()=>{o=o.filter((j,V)=>V!==c),Y()}),w.append($,I),r.appendChild(w)}),A()}const D=()=>{const s=a.value,c=o;return a.value="",C(),o=[],Y(),{content:s,files:c}},g=()=>{const{content:s,files:c}=D();(s.trim()||c.length>0)&&n.onSend(s.trim(),c.length>0?c:void 0)};return i.addEventListener("submit",s=>{s.preventDefault(),g()}),a.addEventListener("keydown",s=>{s.key==="Enter"&&!s.shiftKey&&(s.preventDefault(),g())}),_&&b.appendChild(_),b.append(a,p),R&&i.appendChild(R),i.append(r,b),A(),{inputRow:i,getValueAndClear:D,setDisabled:s=>{a.disabled=s,f=s,A()},focus:()=>a.focus()}}var Zt={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"};function ae(n){return n.replace(/[&<>"']/g,o=>Zt[o])}function gt(n){const o=n.trim();return/^(https?:|mailto:|tel:|#|\/|\.\/|\.\.\/)/i.test(o)||!/^[a-z][a-z0-9+.-]*:/i.test(o)?o:null}var vt='"IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, monospace',Se="";function te(n){const o=[],i=b=>(o.push(b),`${Se}${o.length-1}${Se}`);let r=n;return r=r.replace(/`([^`]+)`/g,(b,a)=>i(`<code style="background:#f0f2f5;padding:2px 5px;border-radius:4px;font-size:13px;font-family:${vt}">${ae(a)}</code>`)),r=r.replace(/!\[([^\]]*)\]\(([^)\s]+)\)/g,(b,a,C)=>{const m=gt(C);return m?i(`<img alt="${ae(a)}" src="${ae(m)}" style="max-width:100%;border-radius:8px;margin:4px 0" />`):b}),r=r.replace(/\[([^\]]+)\]\(([^)\s]+)\)/g,(b,a,C)=>{const m=gt(C);return m?i(`<a href="${ae(m)}" target="_blank" rel="noopener noreferrer" style="color:#1b5fc4;text-decoration:underline">${te(a)}</a>`):b}),r=ae(r),r=r.replace(/\*\*([^*]+?)\*\*/g,"<strong>$1</strong>").replace(/__([^_]+?)__/g,"<strong>$1</strong>").replace(/~~([^~]+?)~~/g,"<del>$1</del>").replace(/(^|[^*])\*(?!\s)([^*]+?)\*/g,"$1<em>$2</em>").replace(/(^|[^\w_])_(?!\s)([^_]+?)_/g,"$1<em>$2</em>"),r=r.replace(new RegExp(`${Se}(\\d+)${Se}`,"g"),(b,a)=>o[Number(a)]),r}function B(n,o,i){const r=document.createElement(n);return Object.assign(r.style,o),i!==void 0&&(r.innerHTML=i),r}var yt=/^ {0,3}([-*_])( *\1){2,} *$/,wt=/^ {0,3}(#{1,6})\s+(.*?)\s*#*\s*$/,Ct=/^ {0,3}(```+|~~~+)/,Ie=/^ {0,3}>\s?/,le=/^(\s*)([-*+]|\d+[.)])\s+(.*)$/,Jt=["20px","18px","16px","15px","14px","13px"],Fe=n=>n.match(/^\s*/)?.[0].length??0;function en(n){return n.trim()===""||yt.test(n)||wt.test(n)||Ct.test(n)||Ie.test(n)||le.test(n)}function Et(n){const o=n[0].match(le),i=o[1].length,r=/\d/.test(o[2]),b=B(r?"ol":"ul",{margin:"0 0 8px 0",paddingLeft:"20px",listStyleType:r?"decimal":"disc",listStylePosition:"outside"});let a=0;for(;a<n.length;){const C=n[a].match(le),m=[];for(a++;a<n.length&&Fe(n[a])>i;)m.push(n[a]),a++;const x=B("li",{display:"list-item",margin:"2px 0",lineHeight:"1.6"}),p=C[3].match(/^\[([ xX])\]\s+(.*)$/);p?(x.style.listStyleType="none",x.style.marginLeft="-20px",x.innerHTML=`<span style="margin-right:6px">${p[1].toLowerCase()==="x"?"☑":"☐"}</span>${te(p[2])}`):x.innerHTML=te(C[3]),m.filter(f=>le.test(f)).length>0&&x.appendChild(Et(m.filter(f=>f.trim()!==""))),b.appendChild(x)}return b}function tn(n){const o=m=>m.replace(/^\s*\|?/,"").replace(/\|?\s*$/,"").split("|").map(x=>x.trim()),i=B("div",{overflowX:"auto",margin:"0 0 8px 0"}),r=B("table",{borderCollapse:"collapse",width:"100%",fontSize:"13px"}),b=document.createElement("thead"),a=document.createElement("tr");for(const m of o(n[0]))a.appendChild(B("th",{border:"1px solid #dee3e8",padding:"6px 10px",textAlign:"left",backgroundColor:"#f5f7fa",fontWeight:"600"},te(m)));b.appendChild(a),r.appendChild(b);const C=document.createElement("tbody");for(const m of n.slice(2)){const x=document.createElement("tr");for(const p of o(m))x.appendChild(B("td",{border:"1px solid #dee3e8",padding:"6px 10px"},te(p)));C.appendChild(x)}return r.appendChild(C),i.appendChild(r),i}var nn=n=>!!n&&/^\s*\|?\s*:?-{1,}:?\s*(\|\s*:?-{1,}:?\s*)*\|?\s*$/.test(n);function ke(n){const o=document.createDocumentFragment(),i=n.replace(/\r\n?/g,`
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const se=require("./AgoClient-wcPRaIMs.cjs"),ct=require("./createFormCollector-eimwwWEi.cjs"),Gt=require("./createConversationSession-BBYfQLLS.cjs");var jt='"IBM Plex Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif',Re=`var(--ago-font, ${jt})`,pt={font:"--ago-font",radius:"--ago-radius",messageRadius:"--ago-message-radius",brand:"--ago-brand-color",brandText:"--ago-brand-text-color",headerBg:"--ago-header-background",headerText:"--ago-header-text-color",panelBg:"--ago-panel-background",messagesBg:"--ago-messages-background",text:"--ago-text-color",mutedText:"--ago-muted-text-color",border:"--ago-border-color",accent:"--ago-accent-color",agentBubbleBg:"--ago-agent-bubble-background"},Ae="var(--ago-brand-color, #03182f)",_e="var(--ago-brand-text-color, #fff)",Vt="var(--ago-header-background, var(--ago-brand-color, #03182f))",ft="var(--ago-header-text-color, #e8f0fe)",ee="var(--ago-panel-background, #fff)",xt="var(--ago-messages-background, #fbfbfb)",J="var(--ago-text-color, #30373e)",bt="var(--ago-muted-text-color, #6b6d6f)",L="var(--ago-border-color, #dee3e8)",De="var(--ago-accent-color, #1b5fc4)",ut="var(--ago-agent-bubble-background, #f1f3f5)",qt="var(--ago-radius, 16px)",ze="var(--ago-message-radius, 16px)",Kt="var(--ago-message-radius, 20px)";function Xt(n,o){if(o)for(const i of Object.keys(pt)){const r=o[i];r!=null&&n.style.setProperty(pt[i],r)}}function v(n,o){Object.assign(n.style,o)}function h(n={}){const o=document.createElement("div");return v(o,n),o}var mt="ago-chat-widget-keyframes";function Qt(){if(typeof document>"u"||document.getElementById(mt))return;const n=document.createElement("style");n.id=mt,n.textContent="@keyframes ago-pulse { 0%, 80%, 100% { opacity: 0.3; transform: scale(0.8); } 40% { opacity: 1; transform: scale(1); } }@keyframes ago-spin { to { transform: rotate(360deg); } }",document.head.appendChild(n)}function Yt(n){let o=[];const i=document.createElement("form");v(i,{display:"flex",flexDirection:"column",gap:"8px",padding:"12px",borderTop:`1px solid ${L}`,backgroundColor:ee}),i.className="ago-chat-input";const r=h({display:"flex",flexWrap:"wrap",gap:"6px"}),b=h({display:"flex",gap:"8px",alignItems:"flex-end"}),a=document.createElement("textarea");a.placeholder=n.placeholder,a.setAttribute("aria-label",n.placeholder),a.rows=1,v(a,{flex:"1",resize:"none",boxSizing:"border-box",padding:"10px 12px",border:`1px solid ${L}`,borderRadius:"12px",fontSize:"16px",fontFamily:Re,lineHeight:"1.4",maxHeight:"110px",overflowY:"hidden"});const C=()=>{a.style.height="auto";const c=Math.min(a.scrollHeight+2,110);a.style.height=`${c}px`,a.style.overflowY=a.scrollHeight+2>110?"auto":"hidden"};a.addEventListener("input",()=>{C(),A()});const m='<svg width="18" height="18" viewBox="0 -960 960 960" fill="currentColor" aria-hidden="true"><path d="M440-160v-487L216-423l-56-57 320-320 320 320-56 57-224-224v487h-80Z"/></svg>',x='<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" aria-hidden="true" style="animation: ago-spin 0.8s linear infinite"><path d="M21 12a9 9 0 1 1-6.219-8.56"/></svg>',p=document.createElement("button");p.type="submit",p.setAttribute("aria-label","Send"),p.innerHTML=m,v(p,{flexShrink:"0",width:"40px",height:"40px",padding:"0",border:"none",borderRadius:"50%",backgroundColor:Ae,color:_e,display:"flex",alignItems:"center",justifyContent:"center",cursor:"pointer"});let f=!1;const A=()=>{const s=a.value.trim()!==""||o.length>0,c=f||!s;p.disabled=c,p.innerHTML=f?x:m,p.style.opacity=c&&!f?"0.5":"1",p.style.cursor=c?"default":"pointer"};let R=null,_=null;n.allowFiles&&(R=document.createElement("input"),R.type="file",R.multiple=!0,v(R,{display:"none"}),_=document.createElement("button"),_.type="button",_.setAttribute("aria-label","Attach file"),_.textContent="📎",v(_,{padding:"10px 12px",border:`1px solid ${L}`,borderRadius:"12px",backgroundColor:ee,cursor:"pointer",fontSize:"14px"}),_.addEventListener("click",()=>R?.click()),R.addEventListener("change",()=>{o=[...o,...Array.from(R?.files??[])],Y()}));function Y(){r.replaceChildren(),o.forEach((s,c)=>{const w=h({display:"flex",alignItems:"center",gap:"4px",padding:"4px 8px",backgroundColor:"#f0f4ff",border:`1px solid ${L}`,borderRadius:"8px",fontSize:"12px"}),$=document.createElement("span");$.textContent=s.name;const I=document.createElement("button");I.type="button",I.setAttribute("aria-label",`Remove ${s.name}`),I.textContent="×",v(I,{border:"none",background:"transparent",cursor:"pointer",fontSize:"14px",lineHeight:"1"}),I.addEventListener("click",()=>{o=o.filter((j,V)=>V!==c),Y()}),w.append($,I),r.appendChild(w)}),A()}const D=()=>{const s=a.value,c=o;return a.value="",C(),o=[],Y(),{content:s,files:c}},g=()=>{const{content:s,files:c}=D();(s.trim()||c.length>0)&&n.onSend(s.trim(),c.length>0?c:void 0)};return i.addEventListener("submit",s=>{s.preventDefault(),g()}),a.addEventListener("keydown",s=>{s.key==="Enter"&&!s.shiftKey&&(s.preventDefault(),g())}),_&&b.appendChild(_),b.append(a,p),R&&i.appendChild(R),i.append(r,b),A(),{inputRow:i,getValueAndClear:D,setDisabled:s=>{a.disabled=s,f=s,A()},focus:()=>a.focus()}}var Zt={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"};function ae(n){return n.replace(/[&<>"']/g,o=>Zt[o])}function gt(n){const o=n.trim();return/^(https?:|mailto:|tel:|#|\/|\.\/|\.\.\/)/i.test(o)||!/^[a-z][a-z0-9+.-]*:/i.test(o)?o:null}var vt='"IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, monospace',Se="";function te(n){const o=[],i=b=>(o.push(b),`${Se}${o.length-1}${Se}`);let r=n;return r=r.replace(/`([^`]+)`/g,(b,a)=>i(`<code style="background:#f0f2f5;padding:2px 5px;border-radius:4px;font-size:13px;font-family:${vt}">${ae(a)}</code>`)),r=r.replace(/!\[([^\]]*)\]\(([^)\s]+)\)/g,(b,a,C)=>{const m=gt(C);return m?i(`<img alt="${ae(a)}" src="${ae(m)}" style="max-width:100%;border-radius:8px;margin:4px 0" />`):b}),r=r.replace(/\[([^\]]+)\]\(([^)\s]+)\)/g,(b,a,C)=>{const m=gt(C);return m?i(`<a href="${ae(m)}" target="_blank" rel="noopener noreferrer" style="color:#1b5fc4;text-decoration:underline">${te(a)}</a>`):b}),r=ae(r),r=r.replace(/\*\*([^*]+?)\*\*/g,"<strong>$1</strong>").replace(/__([^_]+?)__/g,"<strong>$1</strong>").replace(/~~([^~]+?)~~/g,"<del>$1</del>").replace(/(^|[^*])\*(?!\s)([^*]+?)\*/g,"$1<em>$2</em>").replace(/(^|[^\w_])_(?!\s)([^_]+?)_/g,"$1<em>$2</em>"),r=r.replace(new RegExp(`${Se}(\\d+)${Se}`,"g"),(b,a)=>o[Number(a)]),r}function B(n,o,i){const r=document.createElement(n);return Object.assign(r.style,o),i!==void 0&&(r.innerHTML=i),r}var yt=/^ {0,3}([-*_])( *\1){2,} *$/,wt=/^ {0,3}(#{1,6})\s+(.*?)\s*#*\s*$/,Ct=/^ {0,3}(```+|~~~+)/,Ie=/^ {0,3}>\s?/,le=/^(\s*)([-*+]|\d+[.)])\s+(.*)$/,Jt=["20px","18px","16px","15px","14px","13px"],Fe=n=>n.match(/^\s*/)?.[0].length??0;function en(n){return n.trim()===""||yt.test(n)||wt.test(n)||Ct.test(n)||Ie.test(n)||le.test(n)}function Et(n){const o=n[0].match(le),i=o[1].length,r=/\d/.test(o[2]),b=B(r?"ol":"ul",{margin:"0 0 8px 0",paddingLeft:"20px",listStyleType:r?"decimal":"disc",listStylePosition:"outside"});let a=0;for(;a<n.length;){const C=n[a].match(le),m=[];for(a++;a<n.length&&Fe(n[a])>i;)m.push(n[a]),a++;const x=B("li",{display:"list-item",margin:"2px 0",lineHeight:"1.6"}),p=C[3].match(/^\[([ xX])\]\s+(.*)$/);p?(x.style.listStyleType="none",x.style.marginLeft="-20px",x.innerHTML=`<span style="margin-right:6px">${p[1].toLowerCase()==="x"?"☑":"☐"}</span>${te(p[2])}`):x.innerHTML=te(C[3]),m.filter(f=>le.test(f)).length>0&&x.appendChild(Et(m.filter(f=>f.trim()!==""))),b.appendChild(x)}return b}function tn(n){const o=m=>m.replace(/^\s*\|?/,"").replace(/\|?\s*$/,"").split("|").map(x=>x.trim()),i=B("div",{overflowX:"auto",margin:"0 0 8px 0"}),r=B("table",{borderCollapse:"collapse",width:"100%",fontSize:"13px"}),b=document.createElement("thead"),a=document.createElement("tr");for(const m of o(n[0]))a.appendChild(B("th",{border:"1px solid #dee3e8",padding:"6px 10px",textAlign:"left",backgroundColor:"#f5f7fa",fontWeight:"600"},te(m)));b.appendChild(a),r.appendChild(b);const C=document.createElement("tbody");for(const m of n.slice(2)){const x=document.createElement("tr");for(const p of o(m))x.appendChild(B("td",{border:"1px solid #dee3e8",padding:"6px 10px"},te(p)));C.appendChild(x)}return r.appendChild(C),i.appendChild(r),i}var nn=n=>!!n&&/^\s*\|?\s*:?-{1,}:?\s*(\|\s*:?-{1,}:?\s*)*\|?\s*$/.test(n);function ke(n){const o=document.createDocumentFragment(),i=n.replace(/\r\n?/g,`
2
2
  `).split(`
3
3
  `);let r=0;for(;r<i.length;){const a=i[r];if(a.trim()===""){r++;continue}const C=a.match(Ct);if(C){const p=C[1][0],f=[];for(r++;r<i.length&&!new RegExp(`^ {0,3}${p==="`"?"`{3,}":"~{3,}"}\\s*$`).test(i[r]);)f.push(i[r]),r++;r++;const A=B("pre",{margin:"0 0 8px 0"});A.appendChild(B("code",{display:"block",background:"#f5f5f5",padding:"8px 12px",borderRadius:"6px",fontSize:"13px",overflowX:"auto",fontFamily:vt,whiteSpace:"pre"},ae(f.join(`
4
4
  `)))),o.appendChild(A);continue}if(yt.test(a)){o.appendChild(B("hr",{border:"none",borderTop:"1px solid #dee3e8",margin:"12px 0"})),r++;continue}const m=a.match(wt);if(m){const p=m[1].length;o.appendChild(B(`h${p}`,{margin:"16px 0 8px 0",fontSize:Jt[p-1],fontWeight:"600",lineHeight:"1.3"},te(m[2]))),r++;continue}if(Ie.test(a)){const p=[];for(;r<i.length&&Ie.test(i[r]);)p.push(i[r].replace(Ie,"")),r++;const f=B("blockquote",{borderLeft:"4px solid #dee3e8",paddingLeft:"12px",margin:"0 0 8px 0",fontStyle:"italic",color:"#6b6d6f"});f.appendChild(ke(p.join(`
package/dist/widget.d.cts CHANGED
@@ -175,7 +175,7 @@ declare class AgoClient {
175
175
  * ```
176
176
  */
177
177
  registerFunction(definition: ClientFunctionDefinition): void;
178
- registerFunction(name: string, handler: ClientFunctionHandler, schema: Omit<ClientFunctionSchema, "name">): void;
178
+ registerFunction(name: string, handler: ClientFunctionHandler, schema: ClientFunctionRegisterOptions): void;
179
179
  /**
180
180
  * Short alias for `registerFunction`. Also accepts an array of definitions.
181
181
  *
@@ -476,14 +476,22 @@ declare interface AgoConfig {
476
476
  warnOnEmptyReply?: boolean;
477
477
  /**
478
478
  * How the agent loop treats client function calls (requires backend support):
479
- * - `"placeholder"` (default): the turn continues immediately on a placeholder
480
- * result; the real result is only visible to the agent on later turns.
481
- * - `"pause"`: the turn stops on client function call(s) with status
479
+ * - `"pause"` (default): the turn stops on client function call(s) with status
482
480
  * `WAITING_CLIENT`; once every result is submitted, the SDK resumes the SAME
483
481
  * turn via `POST /messages/{id}/continue`, so the agent sees the real results.
482
+ * - `"placeholder"` (legacy): the turn continues immediately on a placeholder
483
+ * result; the real result is only visible to the agent on later turns.
484
484
  * Older backends ignore the flag, so `"pause"` degrades to legacy behavior.
485
485
  */
486
486
  clientFunctionsMode?: ClientFunctionsMode;
487
+ /**
488
+ * Max serialized size (bytes) of a client function result before the SDK
489
+ * replaces it with a flagged, truncated preview. Everything a handler
490
+ * returns is sent into the LLM context, so this caps runaway payloads
491
+ * (raw API responses, full tables). Default `50000`. Override per function
492
+ * with `maxResultBytes` on its definition; `Infinity` disables the guard.
493
+ */
494
+ maxFunctionResultBytes?: number;
487
495
  }
488
496
 
489
497
  declare type AgoEventHandler<K extends AgoEventName> = (data: AgoClientEvents[K]) => void;
@@ -638,6 +646,12 @@ declare interface ClientFunctionDefinition {
638
646
  description: string;
639
647
  parameters: ClientFunctionSchema["parameters"];
640
648
  handler: ClientFunctionHandler;
649
+ /**
650
+ * Max serialized result size in bytes before the SDK truncates it to a
651
+ * flagged preview (default: `AgoConfig.maxFunctionResultBytes`, 50 000).
652
+ * `Infinity` disables the guard for this function.
653
+ */
654
+ maxResultBytes?: number;
641
655
  }
642
656
 
643
657
  /**
@@ -652,6 +666,20 @@ declare interface ClientFunctionInvocation {
652
666
  conversationId: string;
653
667
  }
654
668
 
669
+ /**
670
+ * Schema-plus-settings object accepted when registering a function: the schema
671
+ * (minus `name`) and SDK-side options that are NOT sent to the backend.
672
+ */
673
+ declare type ClientFunctionRegisterOptions = Omit<ClientFunctionSchema, "name"> & {
674
+ /**
675
+ * Max serialized result size in bytes before the SDK truncates it to a
676
+ * flagged preview. Overrides the client-level default
677
+ * (`AgoConfig.maxFunctionResultBytes`, 50 000 by default). `Infinity`
678
+ * disables the guard for this function.
679
+ */
680
+ maxResultBytes?: number;
681
+ };
682
+
655
683
  /**
656
684
  * Schema for a client-side function that AGO can call
657
685
  */
package/dist/widget.d.ts CHANGED
@@ -175,7 +175,7 @@ declare class AgoClient {
175
175
  * ```
176
176
  */
177
177
  registerFunction(definition: ClientFunctionDefinition): void;
178
- registerFunction(name: string, handler: ClientFunctionHandler, schema: Omit<ClientFunctionSchema, "name">): void;
178
+ registerFunction(name: string, handler: ClientFunctionHandler, schema: ClientFunctionRegisterOptions): void;
179
179
  /**
180
180
  * Short alias for `registerFunction`. Also accepts an array of definitions.
181
181
  *
@@ -476,14 +476,22 @@ declare interface AgoConfig {
476
476
  warnOnEmptyReply?: boolean;
477
477
  /**
478
478
  * How the agent loop treats client function calls (requires backend support):
479
- * - `"placeholder"` (default): the turn continues immediately on a placeholder
480
- * result; the real result is only visible to the agent on later turns.
481
- * - `"pause"`: the turn stops on client function call(s) with status
479
+ * - `"pause"` (default): the turn stops on client function call(s) with status
482
480
  * `WAITING_CLIENT`; once every result is submitted, the SDK resumes the SAME
483
481
  * turn via `POST /messages/{id}/continue`, so the agent sees the real results.
482
+ * - `"placeholder"` (legacy): the turn continues immediately on a placeholder
483
+ * result; the real result is only visible to the agent on later turns.
484
484
  * Older backends ignore the flag, so `"pause"` degrades to legacy behavior.
485
485
  */
486
486
  clientFunctionsMode?: ClientFunctionsMode;
487
+ /**
488
+ * Max serialized size (bytes) of a client function result before the SDK
489
+ * replaces it with a flagged, truncated preview. Everything a handler
490
+ * returns is sent into the LLM context, so this caps runaway payloads
491
+ * (raw API responses, full tables). Default `50000`. Override per function
492
+ * with `maxResultBytes` on its definition; `Infinity` disables the guard.
493
+ */
494
+ maxFunctionResultBytes?: number;
487
495
  }
488
496
 
489
497
  declare type AgoEventHandler<K extends AgoEventName> = (data: AgoClientEvents[K]) => void;
@@ -638,6 +646,12 @@ declare interface ClientFunctionDefinition {
638
646
  description: string;
639
647
  parameters: ClientFunctionSchema["parameters"];
640
648
  handler: ClientFunctionHandler;
649
+ /**
650
+ * Max serialized result size in bytes before the SDK truncates it to a
651
+ * flagged preview (default: `AgoConfig.maxFunctionResultBytes`, 50 000).
652
+ * `Infinity` disables the guard for this function.
653
+ */
654
+ maxResultBytes?: number;
641
655
  }
642
656
 
643
657
  /**
@@ -652,6 +666,20 @@ declare interface ClientFunctionInvocation {
652
666
  conversationId: string;
653
667
  }
654
668
 
669
+ /**
670
+ * Schema-plus-settings object accepted when registering a function: the schema
671
+ * (minus `name`) and SDK-side options that are NOT sent to the backend.
672
+ */
673
+ declare type ClientFunctionRegisterOptions = Omit<ClientFunctionSchema, "name"> & {
674
+ /**
675
+ * Max serialized result size in bytes before the SDK truncates it to a
676
+ * flagged preview. Overrides the client-level default
677
+ * (`AgoConfig.maxFunctionResultBytes`, 50 000 by default). `Infinity`
678
+ * disables the guard for this function.
679
+ */
680
+ maxResultBytes?: number;
681
+ };
682
+
655
683
  /**
656
684
  * Schema for a client-side function that AGO can call
657
685
  */