@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.
- package/README.md +4 -1
- package/dist/AgoClient-CLmtYTJx.cjs +8 -0
- package/dist/{AgoClient-BdtuHX7k.js → AgoClient-Ozz2b1dQ.js} +301 -161
- package/dist/angular.cjs +1 -1
- package/dist/angular.d.cts +151 -6
- package/dist/angular.d.ts +151 -6
- package/dist/angular.js +1 -1
- package/dist/{createConversationSession-B8zfTL78.cjs → createConversationSession-CUkNp6mZ.cjs} +1 -1
- package/dist/{createConversationSession-CWpf4u6I.js → createConversationSession-QIBN0gLx.js} +1 -1
- package/dist/{createFormCollector-BB_l0Sia.cjs → createFormCollector-DHT1ObOb.cjs} +1 -1
- package/dist/{createFormCollector-B4n0_diV.js → createFormCollector-F3YJfsbg.js} +1 -1
- package/dist/createMockClient-BSr-UV8R.cjs +1 -0
- package/dist/{createMockClient-d-arlmCq.js → createMockClient-bAZ9KBHC.js} +18 -15
- package/dist/devtools.d.cts +149 -4
- package/dist/devtools.d.ts +149 -4
- package/dist/helpers.d.cts +6 -0
- package/dist/helpers.d.ts +6 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +181 -5
- package/dist/index.d.ts +181 -5
- package/dist/index.js +4 -4
- package/dist/react.cjs +3 -3
- package/dist/react.d.cts +169 -10
- package/dist/react.d.ts +169 -10
- package/dist/react.js +441 -428
- package/dist/testing.cjs +1 -1
- package/dist/testing.d.cts +149 -4
- package/dist/testing.d.ts +149 -4
- package/dist/testing.js +1 -1
- package/dist/vue.cjs +1 -1
- package/dist/vue.d.cts +162 -5
- package/dist/vue.d.ts +162 -5
- package/dist/vue.js +22 -21
- package/dist/widget.cjs +3 -3
- package/dist/widget.d.cts +149 -4
- package/dist/widget.d.ts +149 -4
- package/dist/widget.js +120 -120
- package/llms-full.txt +1910 -0
- package/package.json +5 -3
- package/dist/AgoClient-CRAnT4qE.cjs +0 -8
- package/dist/createMockClient-ucPENDzz.cjs +0 -1
package/dist/testing.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./createMockClient-
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./createMockClient-BSr-UV8R.cjs");exports.createMockClient=e.createMockClient;
|
package/dist/testing.d.cts
CHANGED
|
@@ -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
|
-
*
|
|
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
|
-
|
|
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:
|
|
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
|
*/
|
|
@@ -682,7 +791,13 @@ declare interface FormSchema {
|
|
|
682
791
|
required?: string[];
|
|
683
792
|
}
|
|
684
793
|
|
|
685
|
-
declare type MessageStatus = "IN_PROGRESS" | "DONE" | "ERROR" | "TODO" | "CANCELED"
|
|
794
|
+
declare type MessageStatus = "IN_PROGRESS" | "DONE" | "ERROR" | "TODO" | "CANCELED"
|
|
795
|
+
/**
|
|
796
|
+
* The turn paused on client function call(s) (pause mode): the agent waits for
|
|
797
|
+
* every waiting call to be submitted, then the turn resumes via
|
|
798
|
+
* `continueMessage`. Not a final state.
|
|
799
|
+
*/
|
|
800
|
+
| "WAITING_CLIENT";
|
|
686
801
|
|
|
687
802
|
export declare interface MockAgoClient extends AgoClient {
|
|
688
803
|
/**
|
|
@@ -714,6 +829,17 @@ export declare interface MockAgoClientOptions {
|
|
|
714
829
|
|
|
715
830
|
declare type MockFn = (...args: any[]) => any;
|
|
716
831
|
|
|
832
|
+
/**
|
|
833
|
+
* Hook run before a paused turn is resumed, so the app controls WHEN the
|
|
834
|
+
* continuation fires (e.g. wait for the destination page to mount after a
|
|
835
|
+
* navigation). It must resolve — throwing or hanging blocks the resume; on
|
|
836
|
+
* timeout-style situations resolve anyway and let the agent conclude.
|
|
837
|
+
*/
|
|
838
|
+
declare type ResumeGate = (info: {
|
|
839
|
+
conversationId: string;
|
|
840
|
+
messageId: string;
|
|
841
|
+
}) => Promise<void> | void;
|
|
842
|
+
|
|
717
843
|
/**
|
|
718
844
|
* Options for sending a message
|
|
719
845
|
*/
|
|
@@ -731,6 +857,8 @@ declare interface SendMessageOptions {
|
|
|
731
857
|
* Requires backend support for the `hidden` flag; older backends ignore it.
|
|
732
858
|
*/
|
|
733
859
|
hidden?: boolean;
|
|
860
|
+
/** Per-message override of {@link AgoConfig.clientFunctionsMode}. */
|
|
861
|
+
clientFunctionsMode?: ClientFunctionsMode;
|
|
734
862
|
}
|
|
735
863
|
|
|
736
864
|
/**
|
|
@@ -772,6 +900,8 @@ declare interface SSEChunkData {
|
|
|
772
900
|
follow_up_replies?: string[];
|
|
773
901
|
satisfaction_feedback?: unknown;
|
|
774
902
|
ask_to_talk_to_human?: boolean;
|
|
903
|
+
/** Tool call ids still awaiting a client result, sent with the final `WAITING_CLIENT` event. */
|
|
904
|
+
waiting_tool_call_ids?: string[];
|
|
775
905
|
}
|
|
776
906
|
|
|
777
907
|
/**
|
|
@@ -796,6 +926,21 @@ declare type SubmitConfig<V = Record<string, unknown>> = string | {
|
|
|
796
926
|
destination?: string;
|
|
797
927
|
} | false;
|
|
798
928
|
|
|
929
|
+
/**
|
|
930
|
+
* Response of `POST /tool-calls/{id}/submit`. `resume` is only present when the
|
|
931
|
+
* tool call belongs to a turn paused on client functions (pause mode): `ready`
|
|
932
|
+
* flips to `true` once ALL waiting calls of that message are submitted, meaning
|
|
933
|
+
* the turn can be resumed via `continueMessage(resume.message_id)`.
|
|
934
|
+
*/
|
|
935
|
+
declare interface SubmitToolCallResult {
|
|
936
|
+
status: string;
|
|
937
|
+
result?: unknown;
|
|
938
|
+
resume?: {
|
|
939
|
+
message_id: string;
|
|
940
|
+
ready: boolean;
|
|
941
|
+
};
|
|
942
|
+
}
|
|
943
|
+
|
|
799
944
|
/**
|
|
800
945
|
* Tool call data from SSE stream
|
|
801
946
|
*/
|
package/dist/testing.d.ts
CHANGED
|
@@ -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
|
-
*
|
|
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
|
-
|
|
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:
|
|
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
|
*/
|
|
@@ -682,7 +791,13 @@ declare interface FormSchema {
|
|
|
682
791
|
required?: string[];
|
|
683
792
|
}
|
|
684
793
|
|
|
685
|
-
declare type MessageStatus = "IN_PROGRESS" | "DONE" | "ERROR" | "TODO" | "CANCELED"
|
|
794
|
+
declare type MessageStatus = "IN_PROGRESS" | "DONE" | "ERROR" | "TODO" | "CANCELED"
|
|
795
|
+
/**
|
|
796
|
+
* The turn paused on client function call(s) (pause mode): the agent waits for
|
|
797
|
+
* every waiting call to be submitted, then the turn resumes via
|
|
798
|
+
* `continueMessage`. Not a final state.
|
|
799
|
+
*/
|
|
800
|
+
| "WAITING_CLIENT";
|
|
686
801
|
|
|
687
802
|
export declare interface MockAgoClient extends AgoClient {
|
|
688
803
|
/**
|
|
@@ -714,6 +829,17 @@ export declare interface MockAgoClientOptions {
|
|
|
714
829
|
|
|
715
830
|
declare type MockFn = (...args: any[]) => any;
|
|
716
831
|
|
|
832
|
+
/**
|
|
833
|
+
* Hook run before a paused turn is resumed, so the app controls WHEN the
|
|
834
|
+
* continuation fires (e.g. wait for the destination page to mount after a
|
|
835
|
+
* navigation). It must resolve — throwing or hanging blocks the resume; on
|
|
836
|
+
* timeout-style situations resolve anyway and let the agent conclude.
|
|
837
|
+
*/
|
|
838
|
+
declare type ResumeGate = (info: {
|
|
839
|
+
conversationId: string;
|
|
840
|
+
messageId: string;
|
|
841
|
+
}) => Promise<void> | void;
|
|
842
|
+
|
|
717
843
|
/**
|
|
718
844
|
* Options for sending a message
|
|
719
845
|
*/
|
|
@@ -731,6 +857,8 @@ declare interface SendMessageOptions {
|
|
|
731
857
|
* Requires backend support for the `hidden` flag; older backends ignore it.
|
|
732
858
|
*/
|
|
733
859
|
hidden?: boolean;
|
|
860
|
+
/** Per-message override of {@link AgoConfig.clientFunctionsMode}. */
|
|
861
|
+
clientFunctionsMode?: ClientFunctionsMode;
|
|
734
862
|
}
|
|
735
863
|
|
|
736
864
|
/**
|
|
@@ -772,6 +900,8 @@ declare interface SSEChunkData {
|
|
|
772
900
|
follow_up_replies?: string[];
|
|
773
901
|
satisfaction_feedback?: unknown;
|
|
774
902
|
ask_to_talk_to_human?: boolean;
|
|
903
|
+
/** Tool call ids still awaiting a client result, sent with the final `WAITING_CLIENT` event. */
|
|
904
|
+
waiting_tool_call_ids?: string[];
|
|
775
905
|
}
|
|
776
906
|
|
|
777
907
|
/**
|
|
@@ -796,6 +926,21 @@ declare type SubmitConfig<V = Record<string, unknown>> = string | {
|
|
|
796
926
|
destination?: string;
|
|
797
927
|
} | false;
|
|
798
928
|
|
|
929
|
+
/**
|
|
930
|
+
* Response of `POST /tool-calls/{id}/submit`. `resume` is only present when the
|
|
931
|
+
* tool call belongs to a turn paused on client functions (pause mode): `ready`
|
|
932
|
+
* flips to `true` once ALL waiting calls of that message are submitted, meaning
|
|
933
|
+
* the turn can be resumed via `continueMessage(resume.message_id)`.
|
|
934
|
+
*/
|
|
935
|
+
declare interface SubmitToolCallResult {
|
|
936
|
+
status: string;
|
|
937
|
+
result?: unknown;
|
|
938
|
+
resume?: {
|
|
939
|
+
message_id: string;
|
|
940
|
+
ready: boolean;
|
|
941
|
+
};
|
|
942
|
+
}
|
|
943
|
+
|
|
799
944
|
/**
|
|
800
945
|
* Tool call data from SSE stream
|
|
801
946
|
*/
|
package/dist/testing.js
CHANGED
package/dist/vue.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const x=require("./rolldown-runtime-16Nf8qvH.cjs"),E=require("./AgoClient-CLmtYTJx.cjs");let o=require("vue");var I=Symbol("ago-client"),S={install(t,n){const e=new E.AgoClient(n);t.provide(I,e)}};function d(t){if(t)return new E.AgoClient(t);const n=(0,o.inject)(I);if(!n)throw new Error("useAgo(): no AgoClient found. Either pass config or install AgoPlugin.");return n}function M(t={}){const n=t.client??d(),e=(0,o.ref)([]),s=(0,o.ref)(t.conversationId),u=(0,o.ref)(!1),r=(0,o.ref)(null),c=a=>{s.value||(s.value=a.conversationId)},f=a=>{const i=e.value.findIndex(v=>v.id===a.messageId);i>=0&&(e.value[i]={...e.value[i],content:e.value[i].content+a.content})},m=a=>{const i=e.value.findIndex(v=>v.id===a.id);i>=0?e.value[i]=a:e.value.push(a),u.value=!1},C=a=>{r.value=new Error(a.error),u.value=!1};(0,o.onMounted)(()=>{n.on("message:start",c),n.on("message:chunk",f),n.on("message:complete",m),n.on("message:error",C)}),(0,o.onUnmounted)(()=>{n.off("message:start",c),n.off("message:chunk",f),n.off("message:complete",m),n.off("message:error",C)});async function g(a,i){u.value=!0,r.value=null;const v={id:`temp-${Date.now()}`,conversationId:s.value||"",content:a,role:"user",status:"DONE",createdAt:new Date},N={id:`temp-assistant-${Date.now()}`,conversationId:s.value||"",content:"",role:"assistant",status:"IN_PROGRESS",createdAt:new Date};e.value.push(v,N);try{const l=await n.sendMessage(a,{conversationId:s.value,files:i});l.conversationId&&!s.value&&(s.value=l.conversationId),e.value=e.value.filter(w=>!w.id.startsWith("temp-"));const A={...v,id:v.id.replace("temp-","user-"),conversationId:l.conversationId};return e.value.some(w=>w.id===l.id)?e.value.push(A):e.value.push(A,l),l}catch(l){return r.value=l instanceof Error?l:new Error("Failed to send"),u.value=!1,e.value=e.value.filter(A=>!A.id.startsWith("temp-")),null}}function h(){e.value=[],s.value=void 0,r.value=null}return{messages:e,isLoading:u,error:r,conversationId:s,sendMessage:g,clearMessages:h}}function p(t={}){const n=t.client??d(),e=t.autoLoad??!0,s=(0,o.ref)([]),u=(0,o.ref)(null),r=(0,o.ref)(!1),c=(0,o.ref)(null);async function f(){r.value=!0,c.value=null;try{s.value=await n.getConversations()}catch(g){c.value=g instanceof Error?g:new Error("Failed to load conversations")}finally{r.value=!1}}async function m(g){r.value=!0,c.value=null;try{u.value=await n.getConversation(g)}catch(h){c.value=h instanceof Error?h:new Error("Failed to load conversation")}finally{r.value=!1}}function C(){u.value=null}return(0,o.onMounted)(()=>{e&&f()}),{conversations:s,currentConversation:u,isLoading:r,error:c,selectConversation:m,startNewConversation:C,refreshConversations:f}}function y(t={}){const n=M({client:t.client,conversationId:t.conversationId}),e=p({client:t.client,autoLoad:t.autoLoad}),s=(0,o.computed)(()=>n.error.value||e.error.value);return{messages:n.messages,isLoading:n.isLoading,error:s,sendMessage:n.sendMessage,clearMessages:n.clearMessages,conversationId:n.conversationId,conversations:e.conversations,currentConversation:e.currentConversation,isConversationsLoading:e.isLoading,selectConversation:e.selectConversation,startNewConversation:e.startNewConversation,refreshConversations:e.refreshConversations}}function L(t,n){const e=d();(0,o.onMounted)(()=>{e.registerFunction(t,n.handler,{description:n.description,parameters:n.parameters,maxResultBytes:n.maxResultBytes})}),(0,o.onUnmounted)(()=>{e.unregisterFunction(t)})}function F(t,n){const e=d();(0,o.onMounted)(()=>{e.registerNavigationFunction(t,n)}),(0,o.onUnmounted)(()=>{e.unregisterNavigationFunction()})}function P(t,n){const e=d(),s=n?.functionName??"setPageState";(0,o.onMounted)(()=>{e.registerPageStateFunction(t,{functionName:s})}),(0,o.onUnmounted)(()=>{e.unregisterPageStateFunction(s)})}function _(t,n){const e=d();(0,o.onMounted)(()=>{e.on(t,n)}),(0,o.onUnmounted)(()=>{e.off(t,n)})}function R(t){const n=(0,o.shallowRef)(t.get());return(0,o.onScopeDispose)(t.subscribe(e=>{n.value=e})),n}exports.AGO_CLIENT_KEY=I;exports.AgoPlugin=S;exports.useAgo=d;exports.useAgoEvents=_;exports.useAgoFunction=L;exports.useAgoNavigation=F;exports.useAgoPageState=P;exports.useAgoStore=R;exports.useChat=y;exports.useConversation=p;exports.useMessages=M;
|