@useago/sdk 1.4.2 → 1.4.4

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 (41) hide show
  1. package/README.md +4 -1
  2. package/dist/AgoClient-CLmtYTJx.cjs +8 -0
  3. package/dist/{AgoClient-BdtuHX7k.js → AgoClient-Ozz2b1dQ.js} +301 -161
  4. package/dist/angular.cjs +1 -1
  5. package/dist/angular.d.cts +151 -6
  6. package/dist/angular.d.ts +151 -6
  7. package/dist/angular.js +1 -1
  8. package/dist/{createConversationSession-B8zfTL78.cjs → createConversationSession-CUkNp6mZ.cjs} +1 -1
  9. package/dist/{createConversationSession-CWpf4u6I.js → createConversationSession-QIBN0gLx.js} +1 -1
  10. package/dist/{createFormCollector-BB_l0Sia.cjs → createFormCollector-DHT1ObOb.cjs} +1 -1
  11. package/dist/{createFormCollector-B4n0_diV.js → createFormCollector-F3YJfsbg.js} +1 -1
  12. package/dist/createMockClient-BSr-UV8R.cjs +1 -0
  13. package/dist/{createMockClient-d-arlmCq.js → createMockClient-bAZ9KBHC.js} +18 -15
  14. package/dist/devtools.d.cts +149 -4
  15. package/dist/devtools.d.ts +149 -4
  16. package/dist/helpers.d.cts +6 -0
  17. package/dist/helpers.d.ts +6 -0
  18. package/dist/index.cjs +1 -1
  19. package/dist/index.d.cts +181 -5
  20. package/dist/index.d.ts +181 -5
  21. package/dist/index.js +4 -4
  22. package/dist/react.cjs +3 -3
  23. package/dist/react.d.cts +169 -10
  24. package/dist/react.d.ts +169 -10
  25. package/dist/react.js +441 -428
  26. package/dist/testing.cjs +1 -1
  27. package/dist/testing.d.cts +149 -4
  28. package/dist/testing.d.ts +149 -4
  29. package/dist/testing.js +1 -1
  30. package/dist/vue.cjs +1 -1
  31. package/dist/vue.d.cts +162 -5
  32. package/dist/vue.d.ts +162 -5
  33. package/dist/vue.js +22 -21
  34. package/dist/widget.cjs +3 -3
  35. package/dist/widget.d.cts +149 -4
  36. package/dist/widget.d.ts +149 -4
  37. package/dist/widget.js +120 -120
  38. package/llms-full.txt +1910 -0
  39. package/package.json +5 -3
  40. package/dist/AgoClient-CRAnT4qE.cjs +0 -8
  41. package/dist/createMockClient-ucPENDzz.cjs +0 -1
@@ -1,5 +1,5 @@
1
- function C(g = {}) {
2
- const { overrides: u = {} } = g, d = {
1
+ function y(g = {}) {
2
+ const { overrides: u = {} } = g, a = {
3
3
  id: "mock-msg-1",
4
4
  conversationId: "mock-conv-1",
5
5
  content: "Mock response",
@@ -10,13 +10,16 @@ function C(g = {}) {
10
10
  id: "mock-conv-1",
11
11
  title: "Mock Conversation",
12
12
  lastMessageDate: /* @__PURE__ */ new Date()
13
- }, t = /* @__PURE__ */ new Map(), a = [], m = {
14
- sendMessage: async () => d,
13
+ }, t = /* @__PURE__ */ new Map(), r = [], m = {
14
+ sendMessage: async () => a,
15
+ continueMessage: async () => a,
16
+ resumePendingClientFunctions: async () => null,
17
+ registerResumeGate: () => () => {
18
+ },
15
19
  getConversations: async () => [l],
16
20
  getConversation: async () => l,
17
- getMessages: async () => [d],
18
- submitToolCallForm: async () => {
19
- },
21
+ getMessages: async () => [a],
22
+ submitToolCallForm: async () => ({ status: "completed" }),
20
23
  confirmToolCall: async () => {
21
24
  },
22
25
  rejectToolCall: async () => {
@@ -47,12 +50,12 @@ function C(g = {}) {
47
50
  t.has(e) || t.set(e, /* @__PURE__ */ new Set()), t.get(e).add(n);
48
51
  },
49
52
  waitFor: (e, o) => new Promise((n, i) => {
50
- let r;
51
- const c = (f) => {
52
- r && clearTimeout(r), t.get(e)?.delete(c), n(f);
53
+ let c;
54
+ const d = (f) => {
55
+ c && clearTimeout(c), t.get(e)?.delete(d), n(f);
53
56
  };
54
- t.has(e) || t.set(e, /* @__PURE__ */ new Set()), t.get(e).add(c), o?.timeout && (r = setTimeout(() => {
55
- t.get(e)?.delete(c), i(/* @__PURE__ */ new Error(`waitFor("${e}") timed out after ${o.timeout}ms`));
57
+ t.has(e) || t.set(e, /* @__PURE__ */ new Set()), t.get(e).add(d), o?.timeout && (c = setTimeout(() => {
58
+ t.get(e)?.delete(d), i(/* @__PURE__ */ new Error(`waitFor("${e}") timed out after ${o.timeout}ms`));
56
59
  }, o.timeout));
57
60
  }),
58
61
  updateConfig: () => {
@@ -62,15 +65,15 @@ function C(g = {}) {
62
65
  },
63
66
  ...u
64
67
  }, s = {};
65
- for (const [e, o] of Object.entries(m)) s[e] = (...n) => (a.push({
68
+ for (const [e, o] of Object.entries(m)) s[e] = (...n) => (r.push({
66
69
  method: e,
67
70
  args: n
68
71
  }), o(...n));
69
- return s.__calls = a, s.__callsFor = (e) => a.filter((o) => o.method === e), s.__emitEvent = (e, o) => {
72
+ return s.__calls = r, s.__callsFor = (e) => r.filter((o) => o.method === e), s.__emitEvent = (e, o) => {
70
73
  const n = t.get(e);
71
74
  n && [...n].forEach((i) => i(o));
72
75
  }, s;
73
76
  }
74
77
  export {
75
- C as t
78
+ y as t
76
79
  };
@@ -39,12 +39,45 @@ declare class AgoClient {
39
39
  private config;
40
40
  /** Conversations already warned about an empty reply (one warning each). */
41
41
  private warnedEmptyConversations;
42
+ /** Paused turns awaiting auto-resume, keyed by assistant message id. */
43
+ private pendingResumes;
44
+ /** App-provided gate deciding WHEN a paused turn resumes (see {@link registerResumeGate}). */
45
+ private resumeGate;
42
46
  constructor(config: AgoConfig);
43
47
  /**
44
48
  * Send a message and receive a streaming response
45
49
  */
46
50
  sendMessage(content: string, options?: SendMessageOptions): Promise<AgoMessage>;
47
51
  private processSSEResponse;
52
+ private resolveClientFunctionsMode;
53
+ /**
54
+ * Register a gate deciding WHEN a paused turn resumes. The SDK still decides
55
+ * *whether* (it resumes once every waiting result is submitted); the gate only
56
+ * delays the continue call — e.g. `useAgoAutoContinueAfterNavigation` waits for
57
+ * the destination page to register its page state. One gate at a time (last
58
+ * registration wins). Returns an unregister function.
59
+ */
60
+ registerResumeGate(gate: ResumeGate): () => void;
61
+ /**
62
+ * Resume a turn paused on client function results (`WAITING_CLIENT`).
63
+ *
64
+ * Sends the CURRENT page's registered functions and context — the page may
65
+ * have changed since the pause (that's the point of pausing on a navigation) —
66
+ * and streams the continuation through the same event pipeline as
67
+ * `sendMessage`, so `message:chunk` / `message:complete` (or another
68
+ * `message:waiting-client` for chained pauses) fire as usual.
69
+ *
70
+ * The SDK calls this automatically after submitting the waiting results; call
71
+ * it manually only for custom flows (e.g. after restoring a reloaded page via
72
+ * {@link resumePendingClientFunctions}).
73
+ */
74
+ continueMessage(messageId: string): Promise<AgoMessage>;
75
+ /**
76
+ * Record one of the two auto-resume preconditions for a paused turn and fire
77
+ * the resume when both are in (see {@link PendingResume}).
78
+ */
79
+ private markResumeSignal;
80
+ private runAutoResume;
48
81
  /**
49
82
  * Detect a reply that completed as DONE with no content and no activity —
50
83
  * today's backend answers an unknown `agent` slug with an empty 200, which
@@ -77,9 +110,25 @@ declare class AgoClient {
77
110
  */
78
111
  getMessages(conversationId: string): Promise<AgoMessage[]>;
79
112
  /**
80
- * Submit form data for a tool call
113
+ * Resume a turn left paused on client function results by a page reload.
114
+ *
115
+ * A paused turn (pause mode) survives a full reload: the backend keeps the
116
+ * assistant message in `WAITING_CLIENT` with its waiting tool calls. After
117
+ * restoring the conversation (`getConversation`) and re-registering the page's
118
+ * functions, call this: it re-executes each waiting client function through the
119
+ * registry, submits the results, and continues the turn.
120
+ *
121
+ * Opt-in on purpose — re-running functions on reload can be surprising (e.g. a
122
+ * navigation function would navigate again), so the app decides. Returns the
123
+ * resumed turn's final message, or `null` when there was nothing to resume or
124
+ * some waiting function is not registered on this page.
81
125
  */
82
- submitToolCallForm(toolCallId: string, formData: Record<string, unknown>): Promise<void>;
126
+ resumePendingClientFunctions(conversation: Conversation): Promise<AgoMessage | null>;
127
+ /**
128
+ * Submit form data for a tool call. The response's `resume` field (pause mode
129
+ * only) tells whether the paused turn is ready to be resumed.
130
+ */
131
+ submitToolCallForm(toolCallId: string, formData: Record<string, unknown>): Promise<SubmitToolCallResult>;
83
132
  /**
84
133
  * Confirm a tool call
85
134
  */
@@ -126,7 +175,7 @@ declare class AgoClient {
126
175
  * ```
127
176
  */
128
177
  registerFunction(definition: ClientFunctionDefinition): void;
129
- registerFunction(name: string, handler: ClientFunctionHandler, schema: Omit<ClientFunctionSchema, "name">): void;
178
+ registerFunction(name: string, handler: ClientFunctionHandler, schema: ClientFunctionRegisterOptions): void;
130
179
  /**
131
180
  * Short alias for `registerFunction`. Also accepts an array of definitions.
132
181
  *
@@ -152,6 +201,12 @@ declare class AgoClient {
152
201
  * the agent know *where* it is after it navigates (e.g. so auto-continuation
153
202
  * can apply page state on the destination), not just how to navigate away.
154
203
  *
204
+ * Routes may contain `:param` placeholders (`/users/:id`). Each distinct
205
+ * placeholder becomes a top-level string argument of `navigateToPage`
206
+ * (`{ page: "userDetail", id: "42" }`), so one route covers every detail
207
+ * page of an entity. Flat arguments only: nested object parameters are not
208
+ * reliably rendered to the model, so placeholders must not be named `page`.
209
+ *
155
210
  * @param navigate - A callback that performs the navigation (e.g. react-router's navigate)
156
211
  * @param routes - Map of route names to paths, with descriptions for the LLM
157
212
  */
@@ -319,6 +374,19 @@ declare interface AgoClientEvents {
319
374
  */
320
375
  "message:answer-complete": AgoMessage;
321
376
  "message:complete": AgoMessage;
377
+ /**
378
+ * The turn paused on client function call(s) (pause mode): the stream closed
379
+ * with status `WAITING_CLIENT` instead of `DONE`. `message:complete` does NOT
380
+ * fire for this stream — it fires when the resumed turn concludes, so one
381
+ * logical turn still emits exactly one `message:complete`. The SDK submits the
382
+ * function results and resumes automatically; listen to this to know the agent
383
+ * is waiting on the page (e.g. to keep a "working…" indicator up).
384
+ */
385
+ "message:waiting-client": {
386
+ conversationId: string;
387
+ messageId: string;
388
+ waitingToolCallIds: string[];
389
+ };
322
390
  /**
323
391
  * A reply finished as `DONE` with empty content and no tool calls, client
324
392
  * functions, or follow-up replies — usually an unknown `agent` slug (the
@@ -406,6 +474,24 @@ declare interface AgoConfig {
406
474
  * event fires regardless of this setting.
407
475
  */
408
476
  warnOnEmptyReply?: boolean;
477
+ /**
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
482
+ * `WAITING_CLIENT`; once every result is submitted, the SDK resumes the SAME
483
+ * turn via `POST /messages/{id}/continue`, so the agent sees the real results.
484
+ * Older backends ignore the flag, so `"pause"` degrades to legacy behavior.
485
+ */
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;
409
495
  }
410
496
 
411
497
  declare type AgoEventHandler<K extends AgoEventName> = (data: AgoClientEvents[K]) => void;
@@ -497,6 +583,12 @@ declare interface ClientFunctionDefinition {
497
583
  description: string;
498
584
  parameters: ClientFunctionSchema["parameters"];
499
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;
500
592
  }
501
593
 
502
594
  /**
@@ -511,6 +603,20 @@ declare interface ClientFunctionInvocation {
511
603
  conversationId: string;
512
604
  }
513
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
+
514
620
  /**
515
621
  * Schema for a client-side function that AGO can call
516
622
  */
@@ -536,6 +642,9 @@ declare interface ClientFunctionSchema {
536
642
  };
537
643
  }
538
644
 
645
+ /** See {@link AgoConfig.clientFunctionsMode}. */
646
+ declare type ClientFunctionsMode = "placeholder" | "pause";
647
+
539
648
  /**
540
649
  * A single piece of context the client wants the LLM to know about.
541
650
  */
@@ -694,7 +803,24 @@ declare interface FormSchema {
694
803
 
695
804
  export declare function initDevPanel(options: DevPanelOptions): void;
696
805
 
697
- declare type MessageStatus = "IN_PROGRESS" | "DONE" | "ERROR" | "TODO" | "CANCELED";
806
+ declare type MessageStatus = "IN_PROGRESS" | "DONE" | "ERROR" | "TODO" | "CANCELED"
807
+ /**
808
+ * The turn paused on client function call(s) (pause mode): the agent waits for
809
+ * every waiting call to be submitted, then the turn resumes via
810
+ * `continueMessage`. Not a final state.
811
+ */
812
+ | "WAITING_CLIENT";
813
+
814
+ /**
815
+ * Hook run before a paused turn is resumed, so the app controls WHEN the
816
+ * continuation fires (e.g. wait for the destination page to mount after a
817
+ * navigation). It must resolve — throwing or hanging blocks the resume; on
818
+ * timeout-style situations resolve anyway and let the agent conclude.
819
+ */
820
+ declare type ResumeGate = (info: {
821
+ conversationId: string;
822
+ messageId: string;
823
+ }) => Promise<void> | void;
698
824
 
699
825
  /**
700
826
  * Options for sending a message
@@ -713,6 +839,8 @@ declare interface SendMessageOptions {
713
839
  * Requires backend support for the `hidden` flag; older backends ignore it.
714
840
  */
715
841
  hidden?: boolean;
842
+ /** Per-message override of {@link AgoConfig.clientFunctionsMode}. */
843
+ clientFunctionsMode?: ClientFunctionsMode;
716
844
  }
717
845
 
718
846
  /**
@@ -754,6 +882,8 @@ declare interface SSEChunkData {
754
882
  follow_up_replies?: string[];
755
883
  satisfaction_feedback?: unknown;
756
884
  ask_to_talk_to_human?: boolean;
885
+ /** Tool call ids still awaiting a client result, sent with the final `WAITING_CLIENT` event. */
886
+ waiting_tool_call_ids?: string[];
757
887
  }
758
888
 
759
889
  /**
@@ -778,6 +908,21 @@ declare type SubmitConfig<V = Record<string, unknown>> = string | {
778
908
  destination?: string;
779
909
  } | false;
780
910
 
911
+ /**
912
+ * Response of `POST /tool-calls/{id}/submit`. `resume` is only present when the
913
+ * tool call belongs to a turn paused on client functions (pause mode): `ready`
914
+ * flips to `true` once ALL waiting calls of that message are submitted, meaning
915
+ * the turn can be resumed via `continueMessage(resume.message_id)`.
916
+ */
917
+ declare interface SubmitToolCallResult {
918
+ status: string;
919
+ result?: unknown;
920
+ resume?: {
921
+ message_id: string;
922
+ ready: boolean;
923
+ };
924
+ }
925
+
781
926
  /**
782
927
  * Tool call data from SSE stream
783
928
  */
@@ -39,12 +39,45 @@ declare class AgoClient {
39
39
  private config;
40
40
  /** Conversations already warned about an empty reply (one warning each). */
41
41
  private warnedEmptyConversations;
42
+ /** Paused turns awaiting auto-resume, keyed by assistant message id. */
43
+ private pendingResumes;
44
+ /** App-provided gate deciding WHEN a paused turn resumes (see {@link registerResumeGate}). */
45
+ private resumeGate;
42
46
  constructor(config: AgoConfig);
43
47
  /**
44
48
  * Send a message and receive a streaming response
45
49
  */
46
50
  sendMessage(content: string, options?: SendMessageOptions): Promise<AgoMessage>;
47
51
  private processSSEResponse;
52
+ private resolveClientFunctionsMode;
53
+ /**
54
+ * Register a gate deciding WHEN a paused turn resumes. The SDK still decides
55
+ * *whether* (it resumes once every waiting result is submitted); the gate only
56
+ * delays the continue call — e.g. `useAgoAutoContinueAfterNavigation` waits for
57
+ * the destination page to register its page state. One gate at a time (last
58
+ * registration wins). Returns an unregister function.
59
+ */
60
+ registerResumeGate(gate: ResumeGate): () => void;
61
+ /**
62
+ * Resume a turn paused on client function results (`WAITING_CLIENT`).
63
+ *
64
+ * Sends the CURRENT page's registered functions and context — the page may
65
+ * have changed since the pause (that's the point of pausing on a navigation) —
66
+ * and streams the continuation through the same event pipeline as
67
+ * `sendMessage`, so `message:chunk` / `message:complete` (or another
68
+ * `message:waiting-client` for chained pauses) fire as usual.
69
+ *
70
+ * The SDK calls this automatically after submitting the waiting results; call
71
+ * it manually only for custom flows (e.g. after restoring a reloaded page via
72
+ * {@link resumePendingClientFunctions}).
73
+ */
74
+ continueMessage(messageId: string): Promise<AgoMessage>;
75
+ /**
76
+ * Record one of the two auto-resume preconditions for a paused turn and fire
77
+ * the resume when both are in (see {@link PendingResume}).
78
+ */
79
+ private markResumeSignal;
80
+ private runAutoResume;
48
81
  /**
49
82
  * Detect a reply that completed as DONE with no content and no activity —
50
83
  * today's backend answers an unknown `agent` slug with an empty 200, which
@@ -77,9 +110,25 @@ declare class AgoClient {
77
110
  */
78
111
  getMessages(conversationId: string): Promise<AgoMessage[]>;
79
112
  /**
80
- * Submit form data for a tool call
113
+ * Resume a turn left paused on client function results by a page reload.
114
+ *
115
+ * A paused turn (pause mode) survives a full reload: the backend keeps the
116
+ * assistant message in `WAITING_CLIENT` with its waiting tool calls. After
117
+ * restoring the conversation (`getConversation`) and re-registering the page's
118
+ * functions, call this: it re-executes each waiting client function through the
119
+ * registry, submits the results, and continues the turn.
120
+ *
121
+ * Opt-in on purpose — re-running functions on reload can be surprising (e.g. a
122
+ * navigation function would navigate again), so the app decides. Returns the
123
+ * resumed turn's final message, or `null` when there was nothing to resume or
124
+ * some waiting function is not registered on this page.
81
125
  */
82
- submitToolCallForm(toolCallId: string, formData: Record<string, unknown>): Promise<void>;
126
+ resumePendingClientFunctions(conversation: Conversation): Promise<AgoMessage | null>;
127
+ /**
128
+ * Submit form data for a tool call. The response's `resume` field (pause mode
129
+ * only) tells whether the paused turn is ready to be resumed.
130
+ */
131
+ submitToolCallForm(toolCallId: string, formData: Record<string, unknown>): Promise<SubmitToolCallResult>;
83
132
  /**
84
133
  * Confirm a tool call
85
134
  */
@@ -126,7 +175,7 @@ declare class AgoClient {
126
175
  * ```
127
176
  */
128
177
  registerFunction(definition: ClientFunctionDefinition): void;
129
- registerFunction(name: string, handler: ClientFunctionHandler, schema: Omit<ClientFunctionSchema, "name">): void;
178
+ registerFunction(name: string, handler: ClientFunctionHandler, schema: ClientFunctionRegisterOptions): void;
130
179
  /**
131
180
  * Short alias for `registerFunction`. Also accepts an array of definitions.
132
181
  *
@@ -152,6 +201,12 @@ declare class AgoClient {
152
201
  * the agent know *where* it is after it navigates (e.g. so auto-continuation
153
202
  * can apply page state on the destination), not just how to navigate away.
154
203
  *
204
+ * Routes may contain `:param` placeholders (`/users/:id`). Each distinct
205
+ * placeholder becomes a top-level string argument of `navigateToPage`
206
+ * (`{ page: "userDetail", id: "42" }`), so one route covers every detail
207
+ * page of an entity. Flat arguments only: nested object parameters are not
208
+ * reliably rendered to the model, so placeholders must not be named `page`.
209
+ *
155
210
  * @param navigate - A callback that performs the navigation (e.g. react-router's navigate)
156
211
  * @param routes - Map of route names to paths, with descriptions for the LLM
157
212
  */
@@ -319,6 +374,19 @@ declare interface AgoClientEvents {
319
374
  */
320
375
  "message:answer-complete": AgoMessage;
321
376
  "message:complete": AgoMessage;
377
+ /**
378
+ * The turn paused on client function call(s) (pause mode): the stream closed
379
+ * with status `WAITING_CLIENT` instead of `DONE`. `message:complete` does NOT
380
+ * fire for this stream — it fires when the resumed turn concludes, so one
381
+ * logical turn still emits exactly one `message:complete`. The SDK submits the
382
+ * function results and resumes automatically; listen to this to know the agent
383
+ * is waiting on the page (e.g. to keep a "working…" indicator up).
384
+ */
385
+ "message:waiting-client": {
386
+ conversationId: string;
387
+ messageId: string;
388
+ waitingToolCallIds: string[];
389
+ };
322
390
  /**
323
391
  * A reply finished as `DONE` with empty content and no tool calls, client
324
392
  * functions, or follow-up replies — usually an unknown `agent` slug (the
@@ -406,6 +474,24 @@ declare interface AgoConfig {
406
474
  * event fires regardless of this setting.
407
475
  */
408
476
  warnOnEmptyReply?: boolean;
477
+ /**
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
482
+ * `WAITING_CLIENT`; once every result is submitted, the SDK resumes the SAME
483
+ * turn via `POST /messages/{id}/continue`, so the agent sees the real results.
484
+ * Older backends ignore the flag, so `"pause"` degrades to legacy behavior.
485
+ */
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;
409
495
  }
410
496
 
411
497
  declare type AgoEventHandler<K extends AgoEventName> = (data: AgoClientEvents[K]) => void;
@@ -497,6 +583,12 @@ declare interface ClientFunctionDefinition {
497
583
  description: string;
498
584
  parameters: ClientFunctionSchema["parameters"];
499
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;
500
592
  }
501
593
 
502
594
  /**
@@ -511,6 +603,20 @@ declare interface ClientFunctionInvocation {
511
603
  conversationId: string;
512
604
  }
513
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
+
514
620
  /**
515
621
  * Schema for a client-side function that AGO can call
516
622
  */
@@ -536,6 +642,9 @@ declare interface ClientFunctionSchema {
536
642
  };
537
643
  }
538
644
 
645
+ /** See {@link AgoConfig.clientFunctionsMode}. */
646
+ declare type ClientFunctionsMode = "placeholder" | "pause";
647
+
539
648
  /**
540
649
  * A single piece of context the client wants the LLM to know about.
541
650
  */
@@ -694,7 +803,24 @@ declare interface FormSchema {
694
803
 
695
804
  export declare function initDevPanel(options: DevPanelOptions): void;
696
805
 
697
- declare type MessageStatus = "IN_PROGRESS" | "DONE" | "ERROR" | "TODO" | "CANCELED";
806
+ declare type MessageStatus = "IN_PROGRESS" | "DONE" | "ERROR" | "TODO" | "CANCELED"
807
+ /**
808
+ * The turn paused on client function call(s) (pause mode): the agent waits for
809
+ * every waiting call to be submitted, then the turn resumes via
810
+ * `continueMessage`. Not a final state.
811
+ */
812
+ | "WAITING_CLIENT";
813
+
814
+ /**
815
+ * Hook run before a paused turn is resumed, so the app controls WHEN the
816
+ * continuation fires (e.g. wait for the destination page to mount after a
817
+ * navigation). It must resolve — throwing or hanging blocks the resume; on
818
+ * timeout-style situations resolve anyway and let the agent conclude.
819
+ */
820
+ declare type ResumeGate = (info: {
821
+ conversationId: string;
822
+ messageId: string;
823
+ }) => Promise<void> | void;
698
824
 
699
825
  /**
700
826
  * Options for sending a message
@@ -713,6 +839,8 @@ declare interface SendMessageOptions {
713
839
  * Requires backend support for the `hidden` flag; older backends ignore it.
714
840
  */
715
841
  hidden?: boolean;
842
+ /** Per-message override of {@link AgoConfig.clientFunctionsMode}. */
843
+ clientFunctionsMode?: ClientFunctionsMode;
716
844
  }
717
845
 
718
846
  /**
@@ -754,6 +882,8 @@ declare interface SSEChunkData {
754
882
  follow_up_replies?: string[];
755
883
  satisfaction_feedback?: unknown;
756
884
  ask_to_talk_to_human?: boolean;
885
+ /** Tool call ids still awaiting a client result, sent with the final `WAITING_CLIENT` event. */
886
+ waiting_tool_call_ids?: string[];
757
887
  }
758
888
 
759
889
  /**
@@ -778,6 +908,21 @@ declare type SubmitConfig<V = Record<string, unknown>> = string | {
778
908
  destination?: string;
779
909
  } | false;
780
910
 
911
+ /**
912
+ * Response of `POST /tool-calls/{id}/submit`. `resume` is only present when the
913
+ * tool call belongs to a turn paused on client functions (pause mode): `ready`
914
+ * flips to `true` once ALL waiting calls of that message are submitted, meaning
915
+ * the turn can be resumed via `continueMessage(resume.message_id)`.
916
+ */
917
+ declare interface SubmitToolCallResult {
918
+ status: string;
919
+ result?: unknown;
920
+ resume?: {
921
+ message_id: string;
922
+ ready: boolean;
923
+ };
924
+ }
925
+
781
926
  /**
782
927
  * Tool call data from SSE stream
783
928
  */
@@ -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-CRAnT4qE.cjs"),f=require("./createFormCollector-BB_l0Sia.cjs"),h=require("./createConversationSession-B8zfTL78.cjs"),p=require("./createMockClient-ucPENDzz.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-CLmtYTJx.cjs"),f=require("./createFormCollector-DHT1ObOb.cjs"),h=require("./createConversationSession-CUkNp6mZ.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;