@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
@@ -28,6 +28,23 @@ declare interface AgoAttachment {
28
28
  isSafeImage: boolean;
29
29
  }
30
30
 
31
+ export declare interface AgoAutoContinueOptions {
32
+ /** Function names whose invocation counts as "navigated". Default `["navigateToPage"]`. */
33
+ navigationFunctions?: string[];
34
+ /** Registered function that signals the destination has editable state. Default `"setPageState"`. */
35
+ pageStateFunctionName?: string;
36
+ /** The hidden continuation prompt. Override for i18n / tone. */
37
+ continuationPrompt?: string;
38
+ /** Max continuations per user gesture (guards navigate→continue→navigate loops). Default `1`. */
39
+ maxDepth?: number;
40
+ /** How long to wait for the destination page to register page-state before giving up. Default `4000`ms. */
41
+ readinessTimeoutMs?: number;
42
+ /** Extra settle delay after page-state appears, to let sibling state mount. Default `150`ms. */
43
+ settleMs?: number;
44
+ /** Opt-out escape hatch. Default `true`. */
45
+ enabled?: boolean;
46
+ }
47
+
31
48
  /**
32
49
  * Main SDK client for AGO Chat integration
33
50
  */
@@ -175,7 +192,7 @@ declare class AgoClient {
175
192
  * ```
176
193
  */
177
194
  registerFunction(definition: ClientFunctionDefinition): void;
178
- registerFunction(name: string, handler: ClientFunctionHandler, schema: Omit<ClientFunctionSchema, "name">): void;
195
+ registerFunction(name: string, handler: ClientFunctionHandler, schema: ClientFunctionRegisterOptions): void;
179
196
  /**
180
197
  * Short alias for `registerFunction`. Also accepts an array of definitions.
181
198
  *
@@ -476,14 +493,22 @@ export declare interface AgoConfig {
476
493
  warnOnEmptyReply?: boolean;
477
494
  /**
478
495
  * 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
496
+ * - `"pause"` (default): the turn stops on client function call(s) with status
482
497
  * `WAITING_CLIENT`; once every result is submitted, the SDK resumes the SAME
483
498
  * turn via `POST /messages/{id}/continue`, so the agent sees the real results.
499
+ * - `"placeholder"` (legacy): the turn continues immediately on a placeholder
500
+ * result; the real result is only visible to the agent on later turns.
484
501
  * Older backends ignore the flag, so `"pause"` degrades to legacy behavior.
485
502
  */
486
503
  clientFunctionsMode?: ClientFunctionsMode;
504
+ /**
505
+ * Max serialized size (bytes) of a client function result before the SDK
506
+ * replaces it with a flagged, truncated preview. Everything a handler
507
+ * returns is sent into the LLM context, so this caps runaway payloads
508
+ * (raw API responses, full tables). Default `50000`. Override per function
509
+ * with `maxResultBytes` on its definition; `Infinity` disables the guard.
510
+ */
511
+ maxFunctionResultBytes?: number;
487
512
  }
488
513
 
489
514
  declare type AgoEventHandler<K extends AgoEventName> = (data: AgoClientEvents[K]) => void;
@@ -590,7 +615,7 @@ export declare class AgoService {
590
615
  submitFeedback(messageId: string, rating: "positive" | "negative"): Promise<void>;
591
616
  /** Register a client-side function */
592
617
  registerFunction(definition: ClientFunctionDefinition): void;
593
- registerFunction(name: string, handler: ClientFunctionHandler, schema: Omit<ClientFunctionSchema, "name">): void;
618
+ registerFunction(name: string, handler: ClientFunctionHandler, schema: ClientFunctionRegisterOptions): void;
594
619
  /** Unregister a client-side function */
595
620
  unregisterFunction(name: string): boolean;
596
621
  /** Register navigation routes */
@@ -601,6 +626,31 @@ export declare class AgoService {
601
626
  }>): void;
602
627
  /** Unregister navigation (function + current-page context) */
603
628
  unregisterNavigationFunction(): void;
629
+ /**
630
+ * Auto-continue the agent after it navigates, so a "go to page B and change X"
631
+ * request completes in one user gesture. Enable once (e.g. in your root
632
+ * component) and call the returned function on teardown:
633
+ *
634
+ * ```ts
635
+ * export class AppComponent implements OnDestroy {
636
+ * private ago = inject(AgoService);
637
+ * private router = inject(Router);
638
+ * private stopAutoContinue = this.ago.enableAutoContinueAfterNavigation();
639
+ *
640
+ * constructor() {
641
+ * this.ago.registerNavigationFunction((path) => this.router.navigateByUrl(path), routes);
642
+ * }
643
+ *
644
+ * ngOnDestroy() {
645
+ * this.stopAutoContinue();
646
+ * }
647
+ * }
648
+ * ```
649
+ *
650
+ * See {@link attachAutoContinueAfterNavigation} for the pause-mode /
651
+ * placeholder-mode mechanics and the available options.
652
+ */
653
+ enableAutoContinueAfterNavigation(options?: AgoAutoContinueOptions): () => void;
604
654
  /** Register editable page-state controls (filters, sort, view mode…) */
605
655
  registerPageStateFunction(controls: AgoStateControl[], opts?: AgoPageStateOptions): void;
606
656
  /** Unregister a page-state function and its dynamic context */
@@ -670,6 +720,12 @@ declare interface ClientFunctionDefinition {
670
720
  description: string;
671
721
  parameters: ClientFunctionSchema["parameters"];
672
722
  handler: ClientFunctionHandler;
723
+ /**
724
+ * Max serialized result size in bytes before the SDK truncates it to a
725
+ * flagged preview (default: `AgoConfig.maxFunctionResultBytes`, 50 000).
726
+ * `Infinity` disables the guard for this function.
727
+ */
728
+ maxResultBytes?: number;
673
729
  }
674
730
 
675
731
  /**
@@ -684,6 +740,20 @@ declare interface ClientFunctionInvocation {
684
740
  conversationId: string;
685
741
  }
686
742
 
743
+ /**
744
+ * Schema-plus-settings object accepted when registering a function: the schema
745
+ * (minus `name`) and SDK-side options that are NOT sent to the backend.
746
+ */
747
+ declare type ClientFunctionRegisterOptions = Omit<ClientFunctionSchema, "name"> & {
748
+ /**
749
+ * Max serialized result size in bytes before the SDK truncates it to a
750
+ * flagged preview. Overrides the client-level default
751
+ * (`AgoConfig.maxFunctionResultBytes`, 50 000 by default). `Infinity`
752
+ * disables the guard for this function.
753
+ */
754
+ maxResultBytes?: number;
755
+ };
756
+
687
757
  /**
688
758
  * Schema for a client-side function that AGO can call
689
759
  */
package/dist/angular.d.ts CHANGED
@@ -28,6 +28,23 @@ declare interface AgoAttachment {
28
28
  isSafeImage: boolean;
29
29
  }
30
30
 
31
+ export declare interface AgoAutoContinueOptions {
32
+ /** Function names whose invocation counts as "navigated". Default `["navigateToPage"]`. */
33
+ navigationFunctions?: string[];
34
+ /** Registered function that signals the destination has editable state. Default `"setPageState"`. */
35
+ pageStateFunctionName?: string;
36
+ /** The hidden continuation prompt. Override for i18n / tone. */
37
+ continuationPrompt?: string;
38
+ /** Max continuations per user gesture (guards navigate→continue→navigate loops). Default `1`. */
39
+ maxDepth?: number;
40
+ /** How long to wait for the destination page to register page-state before giving up. Default `4000`ms. */
41
+ readinessTimeoutMs?: number;
42
+ /** Extra settle delay after page-state appears, to let sibling state mount. Default `150`ms. */
43
+ settleMs?: number;
44
+ /** Opt-out escape hatch. Default `true`. */
45
+ enabled?: boolean;
46
+ }
47
+
31
48
  /**
32
49
  * Main SDK client for AGO Chat integration
33
50
  */
@@ -175,7 +192,7 @@ declare class AgoClient {
175
192
  * ```
176
193
  */
177
194
  registerFunction(definition: ClientFunctionDefinition): void;
178
- registerFunction(name: string, handler: ClientFunctionHandler, schema: Omit<ClientFunctionSchema, "name">): void;
195
+ registerFunction(name: string, handler: ClientFunctionHandler, schema: ClientFunctionRegisterOptions): void;
179
196
  /**
180
197
  * Short alias for `registerFunction`. Also accepts an array of definitions.
181
198
  *
@@ -476,14 +493,22 @@ export declare interface AgoConfig {
476
493
  warnOnEmptyReply?: boolean;
477
494
  /**
478
495
  * 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
496
+ * - `"pause"` (default): the turn stops on client function call(s) with status
482
497
  * `WAITING_CLIENT`; once every result is submitted, the SDK resumes the SAME
483
498
  * turn via `POST /messages/{id}/continue`, so the agent sees the real results.
499
+ * - `"placeholder"` (legacy): the turn continues immediately on a placeholder
500
+ * result; the real result is only visible to the agent on later turns.
484
501
  * Older backends ignore the flag, so `"pause"` degrades to legacy behavior.
485
502
  */
486
503
  clientFunctionsMode?: ClientFunctionsMode;
504
+ /**
505
+ * Max serialized size (bytes) of a client function result before the SDK
506
+ * replaces it with a flagged, truncated preview. Everything a handler
507
+ * returns is sent into the LLM context, so this caps runaway payloads
508
+ * (raw API responses, full tables). Default `50000`. Override per function
509
+ * with `maxResultBytes` on its definition; `Infinity` disables the guard.
510
+ */
511
+ maxFunctionResultBytes?: number;
487
512
  }
488
513
 
489
514
  declare type AgoEventHandler<K extends AgoEventName> = (data: AgoClientEvents[K]) => void;
@@ -590,7 +615,7 @@ export declare class AgoService {
590
615
  submitFeedback(messageId: string, rating: "positive" | "negative"): Promise<void>;
591
616
  /** Register a client-side function */
592
617
  registerFunction(definition: ClientFunctionDefinition): void;
593
- registerFunction(name: string, handler: ClientFunctionHandler, schema: Omit<ClientFunctionSchema, "name">): void;
618
+ registerFunction(name: string, handler: ClientFunctionHandler, schema: ClientFunctionRegisterOptions): void;
594
619
  /** Unregister a client-side function */
595
620
  unregisterFunction(name: string): boolean;
596
621
  /** Register navigation routes */
@@ -601,6 +626,31 @@ export declare class AgoService {
601
626
  }>): void;
602
627
  /** Unregister navigation (function + current-page context) */
603
628
  unregisterNavigationFunction(): void;
629
+ /**
630
+ * Auto-continue the agent after it navigates, so a "go to page B and change X"
631
+ * request completes in one user gesture. Enable once (e.g. in your root
632
+ * component) and call the returned function on teardown:
633
+ *
634
+ * ```ts
635
+ * export class AppComponent implements OnDestroy {
636
+ * private ago = inject(AgoService);
637
+ * private router = inject(Router);
638
+ * private stopAutoContinue = this.ago.enableAutoContinueAfterNavigation();
639
+ *
640
+ * constructor() {
641
+ * this.ago.registerNavigationFunction((path) => this.router.navigateByUrl(path), routes);
642
+ * }
643
+ *
644
+ * ngOnDestroy() {
645
+ * this.stopAutoContinue();
646
+ * }
647
+ * }
648
+ * ```
649
+ *
650
+ * See {@link attachAutoContinueAfterNavigation} for the pause-mode /
651
+ * placeholder-mode mechanics and the available options.
652
+ */
653
+ enableAutoContinueAfterNavigation(options?: AgoAutoContinueOptions): () => void;
604
654
  /** Register editable page-state controls (filters, sort, view mode…) */
605
655
  registerPageStateFunction(controls: AgoStateControl[], opts?: AgoPageStateOptions): void;
606
656
  /** Unregister a page-state function and its dynamic context */
@@ -670,6 +720,12 @@ declare interface ClientFunctionDefinition {
670
720
  description: string;
671
721
  parameters: ClientFunctionSchema["parameters"];
672
722
  handler: ClientFunctionHandler;
723
+ /**
724
+ * Max serialized result size in bytes before the SDK truncates it to a
725
+ * flagged preview (default: `AgoConfig.maxFunctionResultBytes`, 50 000).
726
+ * `Infinity` disables the guard for this function.
727
+ */
728
+ maxResultBytes?: number;
673
729
  }
674
730
 
675
731
  /**
@@ -684,6 +740,20 @@ declare interface ClientFunctionInvocation {
684
740
  conversationId: string;
685
741
  }
686
742
 
743
+ /**
744
+ * Schema-plus-settings object accepted when registering a function: the schema
745
+ * (minus `name`) and SDK-side options that are NOT sent to the backend.
746
+ */
747
+ declare type ClientFunctionRegisterOptions = Omit<ClientFunctionSchema, "name"> & {
748
+ /**
749
+ * Max serialized result size in bytes before the SDK truncates it to a
750
+ * flagged preview. Overrides the client-level default
751
+ * (`AgoConfig.maxFunctionResultBytes`, 50 000 by default). `Infinity`
752
+ * disables the guard for this function.
753
+ */
754
+ maxResultBytes?: number;
755
+ };
756
+
687
757
  /**
688
758
  * Schema for a client-side function that AGO can call
689
759
  */
package/dist/angular.js CHANGED
@@ -1,4 +1,5 @@
1
- import { t as o } from "./AgoClient-S8oeNnAE.js";
1
+ import { t as o } from "./AgoClient-q39FIjSC.js";
2
+ import { t as c } from "./autoContinue-D3Mmaaca.js";
2
3
  var s = class {
3
4
  constructor(t) {
4
5
  this.client = new o(t), this.messages$ = this.fromEvent("message:complete"), this.chunks$ = this.fromEvent("message:chunk"), this.errors$ = this.fromEvent("message:error"), this.messageStart$ = this.fromEvent("message:start");
@@ -48,6 +49,9 @@ var s = class {
48
49
  unregisterNavigationFunction() {
49
50
  this.client.unregisterNavigationFunction();
50
51
  }
52
+ enableAutoContinueAfterNavigation(t) {
53
+ return c(this.client, t);
54
+ }
51
55
  registerPageStateFunction(t, e) {
52
56
  this.client.registerPageStateFunction(t, e);
53
57
  }
@@ -0,0 +1 @@
1
+ var I="You have navigated the user to a new page. That page now exposes its editable state through the available setPageState function, and its current values in the page context. If the user's latest request also asked to change something on this page, call setPageState now to apply exactly those changes and nothing else. Otherwise, reply with a short confirmation only.";function p(e){return{navigationFunctions:e?.navigationFunctions??["navigateToPage"],pageStateFunctionName:e?.pageStateFunctionName??"setPageState",continuationPrompt:e?.continuationPrompt??I,maxDepth:e?.maxDepth??1,readinessTimeoutMs:e?.readinessTimeoutMs??4e3,settleMs:e?.settleMs??150,enabled:e?.enabled??!0}}function w(e,s){const a=typeof s=="function"?()=>p(s()):()=>p(s),t={navigated:!1,pausedTurnNavigated:!1,depth:0,runId:0,ourSendPending:!1},i=()=>e.getRegisteredFunctions().some(n=>n.name===a().pageStateFunctionName),g=n=>new Promise(o=>{let l=!1;const r=N=>{l||(l=!0,clearTimeout(S),e.off("context:changed",u),o(N))},v=()=>setTimeout(()=>r(n===t.runId&&i()),a().settleMs),u=()=>{if(n!==t.runId)return r(!1);i()&&(e.off("context:changed",u),v())},S=setTimeout(()=>r(!1),a().readinessTimeoutMs);i()?v():e.on("context:changed",u)}),P=async n=>{const o=++t.runId;if(!(!await g(o)||o!==t.runId)){t.depth+=1,t.ourSendPending=!0;try{await e.sendMessage(a().continuationPrompt,{conversationId:n,hidden:!0})}catch{t.ourSendPending=!1}}},d=n=>{a().navigationFunctions.includes(n.functionName)&&(t.navigated=!0)},T=e.registerResumeGate(async()=>{a().enabled&&t.pausedTurnNavigated&&(t.pausedTurnNavigated=!1,await g(++t.runId))}),f=()=>{t.pausedTurnNavigated=t.navigated,t.navigated=!1},c=()=>{t.ourSendPending||(t.depth=0,t.runId+=1)},h=n=>{t.ourSendPending=!1;const o=t.navigated;t.navigated=!1,a().enabled&&o&&(t.depth>=a().maxDepth||P(n.conversationId))},m=()=>{t.ourSendPending=!1};return e.on("function:invoke",d),e.on("message:start",c),e.on("message:waiting-client",f),e.on("message:complete",h),e.on("message:error",m),()=>{t.runId+=1,T(),e.off("function:invoke",d),e.off("message:start",c),e.off("message:waiting-client",f),e.off("message:complete",h),e.off("message:error",m)}}Object.defineProperty(exports,"attachAutoContinueAfterNavigation",{enumerable:!0,get:function(){return w}});
@@ -0,0 +1,63 @@
1
+ var N = "You have navigated the user to a new page. That page now exposes its editable state through the available setPageState function, and its current values in the page context. If the user's latest request also asked to change something on this page, call setPageState now to apply exactly those changes and nothing else. Otherwise, reply with a short confirmation only.";
2
+ function p(e) {
3
+ return {
4
+ navigationFunctions: e?.navigationFunctions ?? ["navigateToPage"],
5
+ pageStateFunctionName: e?.pageStateFunctionName ?? "setPageState",
6
+ continuationPrompt: e?.continuationPrompt ?? N,
7
+ maxDepth: e?.maxDepth ?? 1,
8
+ readinessTimeoutMs: e?.readinessTimeoutMs ?? 4e3,
9
+ settleMs: e?.settleMs ?? 150,
10
+ enabled: e?.enabled ?? !0
11
+ };
12
+ }
13
+ function w(e, o) {
14
+ const a = typeof o == "function" ? () => p(o()) : () => p(o), t = {
15
+ navigated: !1,
16
+ pausedTurnNavigated: !1,
17
+ depth: 0,
18
+ runId: 0,
19
+ ourSendPending: !1
20
+ }, i = () => e.getRegisteredFunctions().some((n) => n.name === a().pageStateFunctionName), g = (n) => new Promise((s) => {
21
+ let l = !1;
22
+ const r = (I) => {
23
+ l || (l = !0, clearTimeout(S), e.off("context:changed", u), s(I));
24
+ }, v = () => setTimeout(() => r(n === t.runId && i()), a().settleMs), u = () => {
25
+ if (n !== t.runId) return r(!1);
26
+ i() && (e.off("context:changed", u), v());
27
+ }, S = setTimeout(() => r(!1), a().readinessTimeoutMs);
28
+ i() ? v() : e.on("context:changed", u);
29
+ }), P = async (n) => {
30
+ const s = ++t.runId;
31
+ if (!(!await g(s) || s !== t.runId)) {
32
+ t.depth += 1, t.ourSendPending = !0;
33
+ try {
34
+ await e.sendMessage(a().continuationPrompt, {
35
+ conversationId: n,
36
+ hidden: !0
37
+ });
38
+ } catch {
39
+ t.ourSendPending = !1;
40
+ }
41
+ }
42
+ }, d = (n) => {
43
+ a().navigationFunctions.includes(n.functionName) && (t.navigated = !0);
44
+ }, T = e.registerResumeGate(async () => {
45
+ a().enabled && t.pausedTurnNavigated && (t.pausedTurnNavigated = !1, await g(++t.runId));
46
+ }), f = () => {
47
+ t.pausedTurnNavigated = t.navigated, t.navigated = !1;
48
+ }, c = () => {
49
+ t.ourSendPending || (t.depth = 0, t.runId += 1);
50
+ }, h = (n) => {
51
+ t.ourSendPending = !1;
52
+ const s = t.navigated;
53
+ t.navigated = !1, a().enabled && s && (t.depth >= a().maxDepth || P(n.conversationId));
54
+ }, m = () => {
55
+ t.ourSendPending = !1;
56
+ };
57
+ return e.on("function:invoke", d), e.on("message:start", c), e.on("message:waiting-client", f), e.on("message:complete", h), e.on("message:error", m), () => {
58
+ t.runId += 1, T(), e.off("function:invoke", d), e.off("message:start", c), e.off("message:waiting-client", f), e.off("message:complete", h), e.off("message:error", m);
59
+ };
60
+ }
61
+ export {
62
+ w as t
63
+ };
@@ -1 +1 @@
1
- const d=require("./createFormCollector-Bz_0IJ0Q.cjs");var f="ago_widget_id",g="ago_last_thread",y=7200*1e3;function v(){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,e=>{const r=Math.floor(Math.random()*16);return(e==="x"?r:r&3|8).toString(16)})}function _(e={}){const r=e.key??f,i=e.threadKey??g,u=e.ttlMs??y,l=e.storage??(typeof localStorage<"u"?localStorage:void 0);let n=e.widgetId??"";if(!n&&l)try{n=l.getItem(r)??""}catch{}if(n||(n=v()),l)try{l.setItem(r,n)}catch{}const o=d.createStore({value:null,lastMessageAt:null},{key:i,storage:l}),c=o.get();c.value!==null&&s(c.lastMessageAt)&&o.set({value:null,lastMessageAt:null});function s(t){return t===null?!0:Number.isFinite(u)?Date.now()-t>u:!1}return{widgetId:n,key:r,getLastActiveThread(){const{value:t,lastMessageAt:a}=o.get();return t===null||s(a)?null:t},setActiveThread(t,a){const x=a==null?null:a instanceof Date?a.getTime():a;o.set({value:t,lastMessageAt:x})},clear(){o.set({value:null,lastMessageAt:null})}}}Object.defineProperty(exports,"createConversationSession",{enumerable:!0,get:function(){return _}});
1
+ const d=require("./createFormCollector-eimwwWEi.cjs");var f="ago_widget_id",g="ago_last_thread",y=7200*1e3;function v(){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,e=>{const r=Math.floor(Math.random()*16);return(e==="x"?r:r&3|8).toString(16)})}function _(e={}){const r=e.key??f,i=e.threadKey??g,u=e.ttlMs??y,l=e.storage??(typeof localStorage<"u"?localStorage:void 0);let n=e.widgetId??"";if(!n&&l)try{n=l.getItem(r)??""}catch{}if(n||(n=v()),l)try{l.setItem(r,n)}catch{}const o=d.createStore({value:null,lastMessageAt:null},{key:i,storage:l}),c=o.get();c.value!==null&&s(c.lastMessageAt)&&o.set({value:null,lastMessageAt:null});function s(t){return t===null?!0:Number.isFinite(u)?Date.now()-t>u:!1}return{widgetId:n,key:r,getLastActiveThread(){const{value:t,lastMessageAt:a}=o.get();return t===null||s(a)?null:t},setActiveThread(t,a){const x=a==null?null:a instanceof Date?a.getTime():a;o.set({value:t,lastMessageAt:x})},clear(){o.set({value:null,lastMessageAt:null})}}}Object.defineProperty(exports,"createConversationSession",{enumerable:!0,get:function(){return _}});
@@ -1,4 +1,4 @@
1
- import { i as d } from "./createFormCollector-vy-QvFja.js";
1
+ import { i as d } from "./createFormCollector-sB6rMccD.js";
2
2
  var f = "ago_widget_id", g = "ago_last_thread", y = 7200 * 1e3;
3
3
  function v() {
4
4
  return typeof crypto < "u" && typeof crypto.randomUUID == "function" ? crypto.randomUUID() : "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, (e) => {
@@ -1 +1 @@
1
- const C=require("./AgoClient-CMDVqNaH.cjs");function W(n,e){const a=e?e.storage??(typeof localStorage<"u"?localStorage:void 0):void 0;let s=n;if(e&&a)try{const m=a.getItem(e.key);m!=null&&(s=JSON.parse(m))}catch{}const i=new Set,c=()=>i.forEach(m=>m(s));function b(){if(e&&a)try{a.setItem(e.key,JSON.stringify(s))}catch{}}return{get:()=>s,set:m=>{s=m,b(),c()},subscribe:m=>(i.add(m),()=>{i.delete(m)})}}var T=/^[a-zA-Z0-9_-]{1,40}$/,x=n=>n==null||n==="";function v(n,e){if("anyOf"in n)return n.anyOf.some(c=>v(c,e));if("allOf"in n)return n.allOf.every(c=>v(c,e));const a=e[n.property];if(x(a))return!1;if(Array.isArray(n.value))return n.value.some(c=>String(a)===String(c));if(!n.op)return String(a)===String(n.value);const s=Number(a),i=Number(n.value);if(Number.isNaN(s)||Number.isNaN(i))return!1;switch(n.op){case">=":return s>=i;case"<=":return s<=i;case">":return s>i;case"<":return s<i;default:return C.logger.warn(`Unknown requiredWhen op "${n.op}"; treating as not required.`),!1}}function h(n,e){const a=n.properties??{},s=new Set;for(const c of n.required??[]){const b=a[c]?.requiredWhen;(!b||v(b,e))&&s.add(c)}for(const[c,b]of Object.entries(a))b.requiredWhen&&v(b.requiredWhen,e)&&s.add(c);const i=[...s].filter(c=>x(e[c]));return{missing:i,complete:i.length===0}}function R(n){const e={};for(const[a,s]of Object.entries(n.properties??{}))e[a]={type:s.type,...s.description!=null&&{description:s.description},...s.enum&&{enum:s.enum},...s.default!==void 0&&{default:s.default}};return{type:"object",properties:e,required:[]}}function A(n){const{name:e,description:a,schema:s}=n;if(!T.test(e))throw new Error(`Invalid form collector name "${e}": must match ${T} (it becomes the update_/submit_ function names).`);const i=typeof n.submit=="string"?n.submit?{via:"client",url:n.submit}:!1:n.submit??!1;n.autoSubmit===!0&&!i&&C.logger.warn(`FormCollector "${e}": autoSubmit is ignored because no submit target is configured.`);const c=(n.autoSubmit??!0)&&!!i,b=s.properties??{},m=t=>{const r={};for(const[u,o]of Object.entries(t)){const l=b[u];if(l)if(o==null)r[u]=o;else if(l.type==="number"||l.type==="integer"){const d=typeof o=="number"?o:Number(o);r[u]=Number.isNaN(d)?o:d}else l.type==="boolean"?r[u]=typeof o=="boolean"?o:o==="true"?!0:o==="false"?!1:!!o:r[u]=o}return r},S=n.initialValues??{},f=W({values:S,submitted:!1}),$=t=>{const r=f.get(),u={...r,values:{...r.values,...t}};return f.set(u),u};let g=null;const F=(t,r)=>{g?.emitFormEvent("form:error",{name:e,values:t,error:r})};let y=null;const I=async()=>{const{values:t}=f.get(),{complete:r,missing:u}=h(s,t);if(!r)return{ok:!1,missing:u};if(!i)return{ok:!1,error:"No submit target configured for this form collector."};const o=t;try{let l;if(i.via==="client")if("handler"in i)l=await i.handler(o);else{const d=await fetch(i.url,{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify(o)});if(!d.ok){const j=`Submit failed: HTTP ${d.status}`;return F(o,j),{ok:!1,error:j}}l=await d.json().catch(()=>{})}else{if(!g)return{ok:!1,error:"Backend submit requires install(client) (or useFormCollector) first."};l=await g.submitFormCollector(e,o)}return f.set({...f.get(),submitted:!0,submitResult:l}),g?.emitFormEvent("form:submitted",{name:e,values:o,result:l}),{ok:!0,result:l}}catch(l){const d=l instanceof Error?l.message:"Submit failed";return C.logger.error(`FormCollector "${e}" submit failed:`,l),F(o,d),{ok:!1,error:d}}},N=()=>y||(y=(async()=>{try{return await I()}finally{y=null}})(),y),k=async()=>{if(!c||!i)return null;const{values:t,submitted:r}=f.get();return r||!h(s,t).complete?null:N()},O={name:`update_${e}`,description:`Fill or update fields of the "${e}" form. ${a} Pass any subset of fields; call it repeatedly to fill the form as the user provides information. Returns the current values and which required fields are still missing.`,parameters:R(s),handler:async t=>{const r=$(m(t)),{missing:u}=h(s,r.values),o=await k();return o?o.ok?{ok:!0,values:r.values,missing:u,submitted:!0}:{ok:!0,values:r.values,missing:u,submitted:!1,submitError:o.error}:{ok:!0,values:r.values,missing:u}}},p=[O];i&&!c&&p.push({name:`submit_${e}`,description:`Submit the completed "${e}" form. Only call this once every required field is collected and the user has confirmed. If fields are missing it returns them instead of submitting.`,parameters:{type:"object",properties:{}},handler:()=>N()});const V="client__",q=i?`submit_${e}`:null,J=t=>{const r=t.functionName??t.toolName;if(r)return r.startsWith(V)?r.slice(8):r},_=t=>{let r={...S},u=!1;for(const o of t){const l=J(o);l===O.name?o.arguments&&(r={...r,...m(o.arguments)}):q&&l===q&&o.status?.toLowerCase()==="done"&&(u=!0)}f.set({values:r,submitted:u})},w=`form:${e}`,E=()=>{const{values:t,submitted:r}=f.get(),{missing:u,complete:o}=h(s,t),l=i?c?" The form is submitted automatically as soon as every required field is filled, so there is no submit function to call.":` When nothing is missing and the user confirms, call submit_${e}.`:"",d=r?`The "${e}" form has been submitted.`:`You are currently collecting information from the user to fill the "${e}" form.`;return{name:`Form: ${e}`,description:`${d} ${a} Some fields are conditionally required; the requiredWhen field in the schema tells you when each becomes required. The form schema is the following: ${JSON.stringify(s)}. Data collected so far: ${JSON.stringify(t)}. Call update_${e} with any fields the user provides; ask only for what is still missing.${l}`,data:{values:t,missing:u,complete:o,submitted:r}}},P=t=>{_((t.messages??[]).flatMap(r=>r.toolCalls??[]))};return{name:e,store:f,functions:p,contextKey:w,contextProvider:E,install:t=>{g=t;for(const u of p)t.register(u);t.addDynamicContext(w,E);const r=f.subscribe(()=>t.notifyContextChanged());return t.on("conversation:loaded",P),()=>{r();for(const u of p)t.unregisterFunction(u.name);t.removeDynamicContext(w),t.off("conversation:loaded",P),g===t&&(g=null)}},hydrate:_,submit:N,getValues:()=>f.get().values,setValues:t=>{$(m(t)),k()},reset:()=>{f.set({values:S,submitted:!1})},getStatus:()=>h(s,f.get().values)}}async function B(n,e){const a=await n.getFormCollector(e.name);return A({name:a.name,description:e.description??a.description,schema:e.schema??a.schema,submit:e.submit??a.submit,initialValues:e.initialValues,autoSubmit:e.autoSubmit??a.autoSubmit})}Object.defineProperty(exports,"createFormCollector",{enumerable:!0,get:function(){return A}});Object.defineProperty(exports,"createStore",{enumerable:!0,get:function(){return W}});Object.defineProperty(exports,"deriveFormStatus",{enumerable:!0,get:function(){return h}});Object.defineProperty(exports,"loadFormCollector",{enumerable:!0,get:function(){return B}});
1
+ const C=require("./AgoClient-wcPRaIMs.cjs");function W(n,e){const a=e?e.storage??(typeof localStorage<"u"?localStorage:void 0):void 0;let s=n;if(e&&a)try{const m=a.getItem(e.key);m!=null&&(s=JSON.parse(m))}catch{}const i=new Set,c=()=>i.forEach(m=>m(s));function b(){if(e&&a)try{a.setItem(e.key,JSON.stringify(s))}catch{}}return{get:()=>s,set:m=>{s=m,b(),c()},subscribe:m=>(i.add(m),()=>{i.delete(m)})}}var T=/^[a-zA-Z0-9_-]{1,40}$/,x=n=>n==null||n==="";function v(n,e){if("anyOf"in n)return n.anyOf.some(c=>v(c,e));if("allOf"in n)return n.allOf.every(c=>v(c,e));const a=e[n.property];if(x(a))return!1;if(Array.isArray(n.value))return n.value.some(c=>String(a)===String(c));if(!n.op)return String(a)===String(n.value);const s=Number(a),i=Number(n.value);if(Number.isNaN(s)||Number.isNaN(i))return!1;switch(n.op){case">=":return s>=i;case"<=":return s<=i;case">":return s>i;case"<":return s<i;default:return C.logger.warn(`Unknown requiredWhen op "${n.op}"; treating as not required.`),!1}}function h(n,e){const a=n.properties??{},s=new Set;for(const c of n.required??[]){const b=a[c]?.requiredWhen;(!b||v(b,e))&&s.add(c)}for(const[c,b]of Object.entries(a))b.requiredWhen&&v(b.requiredWhen,e)&&s.add(c);const i=[...s].filter(c=>x(e[c]));return{missing:i,complete:i.length===0}}function R(n){const e={};for(const[a,s]of Object.entries(n.properties??{}))e[a]={type:s.type,...s.description!=null&&{description:s.description},...s.enum&&{enum:s.enum},...s.default!==void 0&&{default:s.default}};return{type:"object",properties:e,required:[]}}function A(n){const{name:e,description:a,schema:s}=n;if(!T.test(e))throw new Error(`Invalid form collector name "${e}": must match ${T} (it becomes the update_/submit_ function names).`);const i=typeof n.submit=="string"?n.submit?{via:"client",url:n.submit}:!1:n.submit??!1;n.autoSubmit===!0&&!i&&C.logger.warn(`FormCollector "${e}": autoSubmit is ignored because no submit target is configured.`);const c=(n.autoSubmit??!0)&&!!i,b=s.properties??{},m=t=>{const r={};for(const[u,o]of Object.entries(t)){const l=b[u];if(l)if(o==null)r[u]=o;else if(l.type==="number"||l.type==="integer"){const d=typeof o=="number"?o:Number(o);r[u]=Number.isNaN(d)?o:d}else l.type==="boolean"?r[u]=typeof o=="boolean"?o:o==="true"?!0:o==="false"?!1:!!o:r[u]=o}return r},S=n.initialValues??{},f=W({values:S,submitted:!1}),$=t=>{const r=f.get(),u={...r,values:{...r.values,...t}};return f.set(u),u};let g=null;const F=(t,r)=>{g?.emitFormEvent("form:error",{name:e,values:t,error:r})};let y=null;const I=async()=>{const{values:t}=f.get(),{complete:r,missing:u}=h(s,t);if(!r)return{ok:!1,missing:u};if(!i)return{ok:!1,error:"No submit target configured for this form collector."};const o=t;try{let l;if(i.via==="client")if("handler"in i)l=await i.handler(o);else{const d=await fetch(i.url,{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify(o)});if(!d.ok){const j=`Submit failed: HTTP ${d.status}`;return F(o,j),{ok:!1,error:j}}l=await d.json().catch(()=>{})}else{if(!g)return{ok:!1,error:"Backend submit requires install(client) (or useFormCollector) first."};l=await g.submitFormCollector(e,o)}return f.set({...f.get(),submitted:!0,submitResult:l}),g?.emitFormEvent("form:submitted",{name:e,values:o,result:l}),{ok:!0,result:l}}catch(l){const d=l instanceof Error?l.message:"Submit failed";return C.logger.error(`FormCollector "${e}" submit failed:`,l),F(o,d),{ok:!1,error:d}}},N=()=>y||(y=(async()=>{try{return await I()}finally{y=null}})(),y),k=async()=>{if(!c||!i)return null;const{values:t,submitted:r}=f.get();return r||!h(s,t).complete?null:N()},O={name:`update_${e}`,description:`Fill or update fields of the "${e}" form. ${a} Pass any subset of fields; call it repeatedly to fill the form as the user provides information. Returns the current values and which required fields are still missing.`,parameters:R(s),handler:async t=>{const r=$(m(t)),{missing:u}=h(s,r.values),o=await k();return o?o.ok?{ok:!0,values:r.values,missing:u,submitted:!0}:{ok:!0,values:r.values,missing:u,submitted:!1,submitError:o.error}:{ok:!0,values:r.values,missing:u}}},p=[O];i&&!c&&p.push({name:`submit_${e}`,description:`Submit the completed "${e}" form. Only call this once every required field is collected and the user has confirmed. If fields are missing it returns them instead of submitting.`,parameters:{type:"object",properties:{}},handler:()=>N()});const V="client__",q=i?`submit_${e}`:null,J=t=>{const r=t.functionName??t.toolName;if(r)return r.startsWith(V)?r.slice(8):r},_=t=>{let r={...S},u=!1;for(const o of t){const l=J(o);l===O.name?o.arguments&&(r={...r,...m(o.arguments)}):q&&l===q&&o.status?.toLowerCase()==="done"&&(u=!0)}f.set({values:r,submitted:u})},w=`form:${e}`,E=()=>{const{values:t,submitted:r}=f.get(),{missing:u,complete:o}=h(s,t),l=i?c?" The form is submitted automatically as soon as every required field is filled, so there is no submit function to call.":` When nothing is missing and the user confirms, call submit_${e}.`:"",d=r?`The "${e}" form has been submitted.`:`You are currently collecting information from the user to fill the "${e}" form.`;return{name:`Form: ${e}`,description:`${d} ${a} Some fields are conditionally required; the requiredWhen field in the schema tells you when each becomes required. The form schema is the following: ${JSON.stringify(s)}. Data collected so far: ${JSON.stringify(t)}. Call update_${e} with any fields the user provides; ask only for what is still missing.${l}`,data:{values:t,missing:u,complete:o,submitted:r}}},P=t=>{_((t.messages??[]).flatMap(r=>r.toolCalls??[]))};return{name:e,store:f,functions:p,contextKey:w,contextProvider:E,install:t=>{g=t;for(const u of p)t.register(u);t.addDynamicContext(w,E);const r=f.subscribe(()=>t.notifyContextChanged());return t.on("conversation:loaded",P),()=>{r();for(const u of p)t.unregisterFunction(u.name);t.removeDynamicContext(w),t.off("conversation:loaded",P),g===t&&(g=null)}},hydrate:_,submit:N,getValues:()=>f.get().values,setValues:t=>{$(m(t)),k()},reset:()=>{f.set({values:S,submitted:!1})},getStatus:()=>h(s,f.get().values)}}async function B(n,e){const a=await n.getFormCollector(e.name);return A({name:a.name,description:e.description??a.description,schema:e.schema??a.schema,submit:e.submit??a.submit,initialValues:e.initialValues,autoSubmit:e.autoSubmit??a.autoSubmit})}Object.defineProperty(exports,"createFormCollector",{enumerable:!0,get:function(){return A}});Object.defineProperty(exports,"createStore",{enumerable:!0,get:function(){return W}});Object.defineProperty(exports,"deriveFormStatus",{enumerable:!0,get:function(){return h}});Object.defineProperty(exports,"loadFormCollector",{enumerable:!0,get:function(){return B}});
@@ -1,4 +1,4 @@
1
- import { f as $ } from "./AgoClient-S8oeNnAE.js";
1
+ import { f as $ } from "./AgoClient-q39FIjSC.js";
2
2
  function A(s, e) {
3
3
  const a = e ? e.storage ?? (typeof localStorage < "u" ? localStorage : void 0) : void 0;
4
4
  let n = s;
@@ -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
  */
@@ -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/helpers.cjs CHANGED
@@ -1 +1 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("./functions-Djnq-JAo.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;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("./functions-IGSjjvF4.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;
@@ -16,6 +16,12 @@ declare interface ClientFunctionDefinition {
16
16
  description: string;
17
17
  parameters: ClientFunctionSchema["parameters"];
18
18
  handler: ClientFunctionHandler;
19
+ /**
20
+ * Max serialized result size in bytes before the SDK truncates it to a
21
+ * flagged preview (default: `AgoConfig.maxFunctionResultBytes`, 50 000).
22
+ * `Infinity` disables the guard for this function.
23
+ */
24
+ maxResultBytes?: number;
19
25
  }
20
26
 
21
27
  /**
package/dist/helpers.d.ts CHANGED
@@ -16,6 +16,12 @@ declare interface ClientFunctionDefinition {
16
16
  description: string;
17
17
  parameters: ClientFunctionSchema["parameters"];
18
18
  handler: ClientFunctionHandler;
19
+ /**
20
+ * Max serialized result size in bytes before the SDK truncates it to a
21
+ * flagged preview (default: `AgoConfig.maxFunctionResultBytes`, 50 000).
22
+ * `Infinity` disables the guard for this function.
23
+ */
24
+ maxResultBytes?: number;
19
25
  }
20
26
 
21
27
  /**
package/dist/index.cjs CHANGED
@@ -1 +1 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("./AgoClient-CMDVqNaH.cjs"),f=require("./createFormCollector-Bz_0IJ0Q.cjs"),h=require("./createConversationSession-CmBq7uGi.cjs"),p=require("./createMockClient-BSr-UV8R.cjs");require("./testing.cjs");const g=require("./functions-Djnq-JAo.cjs");function w(e){return e}function S(e,o){return e.on("message:complete",o),()=>e.off("message:complete",o)}function E(e,o){return e.on("message:chunk",o),()=>e.off("message:chunk",o)}function y(e,o){return e.on("message:start",o),()=>e.off("message:start",o)}function 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 v(e,o){return e.on("form:submitted",o),()=>e.off("form:submitted",o)}function M(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*k(e,o,l){const a=[];let n=null,i=!1;const m=s=>{a.push(s),n?.()},c=s=>m({type:"start",data:s}),t=s=>m({type:"chunk",data:s}),u=s=>{m({type:"complete",data:s}),i=!0,n?.()},d=s=>{m({type:"error",data:s}),i=!0,n?.()},C=s=>m({type:"toolCall",data:s});e.on("message:start",c),e.on("message:chunk",t),e.on("message:complete",u),e.on("message:error",d),e.on("toolCall:received",C),e.sendMessage(o,l).catch(()=>{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",c),e.off("message:chunk",t),e.off("message:complete",u),e.off("message:error",d),e.off("toolCall:received",C)}}function A(e){let o,l,a,n,i,m;if(typeof window<"u"&&window.AGO){const t=window.AGO;o=t.basepath,l=t.widgetId,a=t.agent||t.defaultAgent,n=t.permission,i=t.email,m=t.jwt}if(typeof document<"u"){const t=u=>document.querySelector(`meta[name="${u}"]`)?.getAttribute("content")||void 0;o=o||t("ago-base-url"),l=l||t("ago-widget-id"),a=a||t("ago-agent")||t("ago-agent-id"),n=n||t("ago-permission"),i=i||t("ago-user-email")}if(typeof document<"u"){const t=[document.body,...Array.from(document.querySelectorAll("script[data-ago-base-url]"))].filter(Boolean);for(const u of t)u&&(o=o||u.getAttribute("data-ago-base-url")||void 0,l=l||u.getAttribute("data-ago-widget-id")||void 0,a=a||u.getAttribute("data-ago-agent")||u.getAttribute("data-ago-agent-id")||void 0,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,m=e?.userJwt||m;const c=e?.debug;return o?{baseUrl:o,widgetId:l,agent:a,permission:n,userEmail:i,userJwt:m,debug:c}:null}function T(e){const o=A(e);if(!o)throw new r.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 r.AgoClient(o)}function I(e,o){return{...e,handler:o}}exports.AgoApiError=r.AgoApiError;exports.AgoClient=r.AgoClient;exports.AgoError=r.AgoError;exports.AgoFunctionError=r.AgoFunctionError;exports.AgoNetworkError=r.AgoNetworkError;exports.AgoStreamError=r.AgoStreamError;exports.ClientContextRegistry=r.ClientContextRegistry;exports.EventEmitter=r.EventEmitter;exports.FunctionRegistry=r.FunctionRegistry;exports.SSEHandler=r.SSEHandler;exports.autoDetectConfig=A;exports.canInlineImage=r.canInlineImage;exports.copyToClipboard=g.copyToClipboard;exports.createAgo=T;exports.createConversationSession=h.createConversationSession;exports.createFormCollector=f.createFormCollector;exports.createMessageStream=k;exports.createMockClient=p.createMockClient;exports.createStore=f.createStore;exports.defineFunction=w;exports.deriveFormStatus=f.deriveFormStatus;exports.formatFileSize=r.formatFileSize;exports.getLocalStorage=g.getLocalStorage;exports.getUserLocation=g.getUserLocation;exports.highlightElement=g.highlightElement;exports.isStreamNetworkError=r.isStreamNetworkError;exports.loadFormCollector=f.loadFormCollector;exports.logger=r.logger;exports.onFormError=M;exports.onFormSubmitted=v;exports.onFunctionInvoke=q;exports.onMessage=S;exports.onMessageChunk=E;exports.onMessageError=F;exports.onMessageStart=y;exports.onToolCall=b;exports.openUrl=g.openUrl;exports.safeAttachmentUrl=r.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=r.validateConfig;exports.withHandler=I;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("./AgoClient-wcPRaIMs.cjs"),h=require("./autoContinue-CcCTva-D.cjs"),f=require("./createFormCollector-eimwwWEi.cjs"),p=require("./createConversationSession-BBYfQLLS.cjs"),w=require("./createMockClient-CjdCqixj.cjs");require("./testing.cjs");const g=require("./functions-IGSjjvF4.cjs");function S(e){return e}function E(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 F(e,o){return e.on("message:start",o),()=>e.off("message:start",o)}function v(e,o){return e.on("message:error",o),()=>e.off("message:error",o)}function b(e,o){return e.on("toolCall:received",o),()=>e.off("toolCall:received",o)}function q(e,o){return e.on("form:submitted",o),()=>e.off("form:submitted",o)}function M(e,o){return e.on("form:error",o),()=>e.off("form:error",o)}function k(e,o){return e.on("function:invoke",o),()=>e.off("function:invoke",o)}async function*T(e,o,l){const a=[];let n=null,i=!1;const c=s=>{a.push(s),n?.()},m=s=>c({type:"start",data:s}),t=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",t),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",t),e.off("message:complete",u),e.off("message:error",d),e.off("toolCall:received",A)}}function C(e){let o,l,a,n,i,c;if(typeof window<"u"&&window.AGO){const t=window.AGO;o=t.basepath,l=t.widgetId,a=t.agent||t.defaultAgent,n=t.permission,i=t.email,c=t.jwt}if(typeof document<"u"){const t=u=>document.querySelector(`meta[name="${u}"]`)?.getAttribute("content")||void 0;o=o||t("ago-base-url"),l=l||t("ago-widget-id"),a=a||t("ago-agent")||t("ago-agent-id"),n=n||t("ago-permission"),i=i||t("ago-user-email")}if(typeof document<"u"){const t=[document.body,...Array.from(document.querySelectorAll("script[data-ago-base-url]"))].filter(Boolean);for(const u of t)u&&(o=o||u.getAttribute("data-ago-base-url")||void 0,l=l||u.getAttribute("data-ago-widget-id")||void 0,a=a||u.getAttribute("data-ago-agent")||u.getAttribute("data-ago-agent-id")||void 0,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 I(e){const o=C(e);if(!o)throw new r.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 r.AgoClient(o)}function U(e,o){return{...e,handler:o}}exports.AgoApiError=r.AgoApiError;exports.AgoClient=r.AgoClient;exports.AgoError=r.AgoError;exports.AgoFunctionError=r.AgoFunctionError;exports.AgoNetworkError=r.AgoNetworkError;exports.AgoStreamError=r.AgoStreamError;exports.ClientContextRegistry=r.ClientContextRegistry;exports.EventEmitter=r.EventEmitter;exports.FunctionRegistry=r.FunctionRegistry;exports.SSEHandler=r.SSEHandler;exports.attachAutoContinueAfterNavigation=h.attachAutoContinueAfterNavigation;exports.autoDetectConfig=C;exports.canInlineImage=r.canInlineImage;exports.copyToClipboard=g.copyToClipboard;exports.createAgo=I;exports.createConversationSession=p.createConversationSession;exports.createFormCollector=f.createFormCollector;exports.createMessageStream=T;exports.createMockClient=w.createMockClient;exports.createStore=f.createStore;exports.defineFunction=S;exports.deriveFormStatus=f.deriveFormStatus;exports.formatFileSize=r.formatFileSize;exports.getLocalStorage=g.getLocalStorage;exports.getUserLocation=g.getUserLocation;exports.highlightElement=g.highlightElement;exports.isStreamNetworkError=r.isStreamNetworkError;exports.loadFormCollector=f.loadFormCollector;exports.logger=r.logger;exports.onFormError=M;exports.onFormSubmitted=q;exports.onFunctionInvoke=k;exports.onMessage=E;exports.onMessageChunk=y;exports.onMessageError=v;exports.onMessageStart=F;exports.onToolCall=b;exports.openUrl=g.openUrl;exports.safeAttachmentUrl=r.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=r.validateConfig;exports.withHandler=U;