@useago/sdk 1.4.1 → 1.4.3
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-CMDVqNaH.cjs +8 -0
- package/dist/{AgoClient-BdtuHX7k.js → AgoClient-S8oeNnAE.js} +273 -157
- package/dist/angular.cjs +1 -1
- package/dist/angular.d.cts +121 -4
- package/dist/angular.d.ts +121 -4
- package/dist/angular.js +1 -1
- package/dist/{createConversationSession-B8zfTL78.cjs → createConversationSession-CmBq7uGi.cjs} +1 -1
- package/dist/{createConversationSession-CWpf4u6I.js → createConversationSession-DoUHdVNR.js} +1 -1
- package/dist/{createFormCollector-BB_l0Sia.cjs → createFormCollector-Bz_0IJ0Q.cjs} +1 -1
- package/dist/{createFormCollector-B4n0_diV.js → createFormCollector-vy-QvFja.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 +120 -3
- package/dist/devtools.d.ts +120 -3
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +132 -3
- package/dist/index.d.ts +132 -3
- package/dist/index.js +4 -4
- package/dist/react.cjs +3 -3
- package/dist/react.d.cts +134 -9
- package/dist/react.d.ts +134 -9
- package/dist/react.js +419 -401
- package/dist/testing.cjs +1 -1
- package/dist/testing.d.cts +120 -3
- package/dist/testing.d.ts +120 -3
- package/dist/testing.js +1 -1
- package/dist/vue.cjs +1 -1
- package/dist/vue.d.cts +127 -4
- package/dist/vue.d.ts +127 -4
- package/dist/vue.js +1 -1
- package/dist/widget.cjs +3 -3
- package/dist/widget.d.cts +120 -3
- package/dist/widget.d.ts +120 -3
- package/dist/widget.js +120 -120
- package/package.json +1 -1
- package/dist/AgoClient-CRAnT4qE.cjs +0 -8
- package/dist/createMockClient-ucPENDzz.cjs +0 -1
package/dist/react.d.ts
CHANGED
|
@@ -58,12 +58,45 @@ declare class AgoClient {
|
|
|
58
58
|
private config;
|
|
59
59
|
/** Conversations already warned about an empty reply (one warning each). */
|
|
60
60
|
private warnedEmptyConversations;
|
|
61
|
+
/** Paused turns awaiting auto-resume, keyed by assistant message id. */
|
|
62
|
+
private pendingResumes;
|
|
63
|
+
/** App-provided gate deciding WHEN a paused turn resumes (see {@link registerResumeGate}). */
|
|
64
|
+
private resumeGate;
|
|
61
65
|
constructor(config: AgoConfig);
|
|
62
66
|
/**
|
|
63
67
|
* Send a message and receive a streaming response
|
|
64
68
|
*/
|
|
65
69
|
sendMessage(content: string, options?: SendMessageOptions): Promise<AgoMessage>;
|
|
66
70
|
private processSSEResponse;
|
|
71
|
+
private resolveClientFunctionsMode;
|
|
72
|
+
/**
|
|
73
|
+
* Register a gate deciding WHEN a paused turn resumes. The SDK still decides
|
|
74
|
+
* *whether* (it resumes once every waiting result is submitted); the gate only
|
|
75
|
+
* delays the continue call — e.g. `useAgoAutoContinueAfterNavigation` waits for
|
|
76
|
+
* the destination page to register its page state. One gate at a time (last
|
|
77
|
+
* registration wins). Returns an unregister function.
|
|
78
|
+
*/
|
|
79
|
+
registerResumeGate(gate: ResumeGate): () => void;
|
|
80
|
+
/**
|
|
81
|
+
* Resume a turn paused on client function results (`WAITING_CLIENT`).
|
|
82
|
+
*
|
|
83
|
+
* Sends the CURRENT page's registered functions and context — the page may
|
|
84
|
+
* have changed since the pause (that's the point of pausing on a navigation) —
|
|
85
|
+
* and streams the continuation through the same event pipeline as
|
|
86
|
+
* `sendMessage`, so `message:chunk` / `message:complete` (or another
|
|
87
|
+
* `message:waiting-client` for chained pauses) fire as usual.
|
|
88
|
+
*
|
|
89
|
+
* The SDK calls this automatically after submitting the waiting results; call
|
|
90
|
+
* it manually only for custom flows (e.g. after restoring a reloaded page via
|
|
91
|
+
* {@link resumePendingClientFunctions}).
|
|
92
|
+
*/
|
|
93
|
+
continueMessage(messageId: string): Promise<AgoMessage>;
|
|
94
|
+
/**
|
|
95
|
+
* Record one of the two auto-resume preconditions for a paused turn and fire
|
|
96
|
+
* the resume when both are in (see {@link PendingResume}).
|
|
97
|
+
*/
|
|
98
|
+
private markResumeSignal;
|
|
99
|
+
private runAutoResume;
|
|
67
100
|
/**
|
|
68
101
|
* Detect a reply that completed as DONE with no content and no activity —
|
|
69
102
|
* today's backend answers an unknown `agent` slug with an empty 200, which
|
|
@@ -96,9 +129,25 @@ declare class AgoClient {
|
|
|
96
129
|
*/
|
|
97
130
|
getMessages(conversationId: string): Promise<AgoMessage[]>;
|
|
98
131
|
/**
|
|
99
|
-
*
|
|
132
|
+
* Resume a turn left paused on client function results by a page reload.
|
|
133
|
+
*
|
|
134
|
+
* A paused turn (pause mode) survives a full reload: the backend keeps the
|
|
135
|
+
* assistant message in `WAITING_CLIENT` with its waiting tool calls. After
|
|
136
|
+
* restoring the conversation (`getConversation`) and re-registering the page's
|
|
137
|
+
* functions, call this: it re-executes each waiting client function through the
|
|
138
|
+
* registry, submits the results, and continues the turn.
|
|
139
|
+
*
|
|
140
|
+
* Opt-in on purpose — re-running functions on reload can be surprising (e.g. a
|
|
141
|
+
* navigation function would navigate again), so the app decides. Returns the
|
|
142
|
+
* resumed turn's final message, or `null` when there was nothing to resume or
|
|
143
|
+
* some waiting function is not registered on this page.
|
|
144
|
+
*/
|
|
145
|
+
resumePendingClientFunctions(conversation: Conversation): Promise<AgoMessage | null>;
|
|
146
|
+
/**
|
|
147
|
+
* Submit form data for a tool call. The response's `resume` field (pause mode
|
|
148
|
+
* only) tells whether the paused turn is ready to be resumed.
|
|
100
149
|
*/
|
|
101
|
-
submitToolCallForm(toolCallId: string, formData: Record<string, unknown>): Promise<
|
|
150
|
+
submitToolCallForm(toolCallId: string, formData: Record<string, unknown>): Promise<SubmitToolCallResult>;
|
|
102
151
|
/**
|
|
103
152
|
* Confirm a tool call
|
|
104
153
|
*/
|
|
@@ -171,6 +220,12 @@ declare class AgoClient {
|
|
|
171
220
|
* the agent know *where* it is after it navigates (e.g. so auto-continuation
|
|
172
221
|
* can apply page state on the destination), not just how to navigate away.
|
|
173
222
|
*
|
|
223
|
+
* Routes may contain `:param` placeholders (`/users/:id`). Each distinct
|
|
224
|
+
* placeholder becomes a top-level string argument of `navigateToPage`
|
|
225
|
+
* (`{ page: "userDetail", id: "42" }`), so one route covers every detail
|
|
226
|
+
* page of an entity. Flat arguments only: nested object parameters are not
|
|
227
|
+
* reliably rendered to the model, so placeholders must not be named `page`.
|
|
228
|
+
*
|
|
174
229
|
* @param navigate - A callback that performs the navigation (e.g. react-router's navigate)
|
|
175
230
|
* @param routes - Map of route names to paths, with descriptions for the LLM
|
|
176
231
|
*/
|
|
@@ -338,6 +393,19 @@ declare interface AgoClientEvents {
|
|
|
338
393
|
*/
|
|
339
394
|
"message:answer-complete": AgoMessage;
|
|
340
395
|
"message:complete": AgoMessage;
|
|
396
|
+
/**
|
|
397
|
+
* The turn paused on client function call(s) (pause mode): the stream closed
|
|
398
|
+
* with status `WAITING_CLIENT` instead of `DONE`. `message:complete` does NOT
|
|
399
|
+
* fire for this stream — it fires when the resumed turn concludes, so one
|
|
400
|
+
* logical turn still emits exactly one `message:complete`. The SDK submits the
|
|
401
|
+
* function results and resumes automatically; listen to this to know the agent
|
|
402
|
+
* is waiting on the page (e.g. to keep a "working…" indicator up).
|
|
403
|
+
*/
|
|
404
|
+
"message:waiting-client": {
|
|
405
|
+
conversationId: string;
|
|
406
|
+
messageId: string;
|
|
407
|
+
waitingToolCallIds: string[];
|
|
408
|
+
};
|
|
341
409
|
/**
|
|
342
410
|
* A reply finished as `DONE` with empty content and no tool calls, client
|
|
343
411
|
* functions, or follow-up replies — usually an unknown `agent` slug (the
|
|
@@ -425,6 +493,16 @@ export declare interface AgoConfig {
|
|
|
425
493
|
* event fires regardless of this setting.
|
|
426
494
|
*/
|
|
427
495
|
warnOnEmptyReply?: boolean;
|
|
496
|
+
/**
|
|
497
|
+
* How the agent loop treats client function calls (requires backend support):
|
|
498
|
+
* - `"placeholder"` (default): the turn continues immediately on a placeholder
|
|
499
|
+
* result; the real result is only visible to the agent on later turns.
|
|
500
|
+
* - `"pause"`: the turn stops on client function call(s) with status
|
|
501
|
+
* `WAITING_CLIENT`; once every result is submitted, the SDK resumes the SAME
|
|
502
|
+
* turn via `POST /messages/{id}/continue`, so the agent sees the real results.
|
|
503
|
+
* Older backends ignore the flag, so `"pause"` degrades to legacy behavior.
|
|
504
|
+
*/
|
|
505
|
+
clientFunctionsMode?: ClientFunctionsMode;
|
|
428
506
|
}
|
|
429
507
|
|
|
430
508
|
/**
|
|
@@ -675,6 +753,9 @@ declare interface ClientFunctionSchema {
|
|
|
675
753
|
};
|
|
676
754
|
}
|
|
677
755
|
|
|
756
|
+
/** See {@link AgoConfig.clientFunctionsMode}. */
|
|
757
|
+
declare type ClientFunctionsMode = "placeholder" | "pause";
|
|
758
|
+
|
|
678
759
|
/**
|
|
679
760
|
* A single piece of context the client wants the LLM to know about.
|
|
680
761
|
*/
|
|
@@ -995,7 +1076,13 @@ export declare interface MessageProps {
|
|
|
995
1076
|
onFollowUpClick?: (reply: string) => void;
|
|
996
1077
|
}
|
|
997
1078
|
|
|
998
|
-
declare type MessageStatus = "IN_PROGRESS" | "DONE" | "ERROR" | "TODO" | "CANCELED"
|
|
1079
|
+
declare type MessageStatus = "IN_PROGRESS" | "DONE" | "ERROR" | "TODO" | "CANCELED"
|
|
1080
|
+
/**
|
|
1081
|
+
* The turn paused on client function call(s) (pause mode): the agent waits for
|
|
1082
|
+
* every waiting call to be submitted, then the turn resumes via
|
|
1083
|
+
* `continueMessage`. Not a final state.
|
|
1084
|
+
*/
|
|
1085
|
+
| "WAITING_CLIENT";
|
|
999
1086
|
|
|
1000
1087
|
declare interface MockAgoClient extends AgoClient {
|
|
1001
1088
|
/**
|
|
@@ -1027,6 +1114,17 @@ declare interface MockAgoClientOptions {
|
|
|
1027
1114
|
|
|
1028
1115
|
declare type MockFn = (...args: any[]) => any;
|
|
1029
1116
|
|
|
1117
|
+
/**
|
|
1118
|
+
* Hook run before a paused turn is resumed, so the app controls WHEN the
|
|
1119
|
+
* continuation fires (e.g. wait for the destination page to mount after a
|
|
1120
|
+
* navigation). It must resolve — throwing or hanging blocks the resume; on
|
|
1121
|
+
* timeout-style situations resolve anyway and let the agent conclude.
|
|
1122
|
+
*/
|
|
1123
|
+
declare type ResumeGate = (info: {
|
|
1124
|
+
conversationId: string;
|
|
1125
|
+
messageId: string;
|
|
1126
|
+
}) => Promise<void> | void;
|
|
1127
|
+
|
|
1030
1128
|
/**
|
|
1031
1129
|
* Options for sending a message
|
|
1032
1130
|
*/
|
|
@@ -1044,6 +1142,8 @@ declare interface SendMessageOptions {
|
|
|
1044
1142
|
* Requires backend support for the `hidden` flag; older backends ignore it.
|
|
1045
1143
|
*/
|
|
1046
1144
|
hidden?: boolean;
|
|
1145
|
+
/** Per-message override of {@link AgoConfig.clientFunctionsMode}. */
|
|
1146
|
+
clientFunctionsMode?: ClientFunctionsMode;
|
|
1047
1147
|
}
|
|
1048
1148
|
|
|
1049
1149
|
/**
|
|
@@ -1085,6 +1185,8 @@ declare interface SSEChunkData {
|
|
|
1085
1185
|
follow_up_replies?: string[];
|
|
1086
1186
|
satisfaction_feedback?: unknown;
|
|
1087
1187
|
ask_to_talk_to_human?: boolean;
|
|
1188
|
+
/** Tool call ids still awaiting a client result, sent with the final `WAITING_CLIENT` event. */
|
|
1189
|
+
waiting_tool_call_ids?: string[];
|
|
1088
1190
|
}
|
|
1089
1191
|
|
|
1090
1192
|
/**
|
|
@@ -1130,6 +1232,21 @@ export declare type SubmitConfig<V = Record<string, unknown>> = string | {
|
|
|
1130
1232
|
destination?: string;
|
|
1131
1233
|
} | false;
|
|
1132
1234
|
|
|
1235
|
+
/**
|
|
1236
|
+
* Response of `POST /tool-calls/{id}/submit`. `resume` is only present when the
|
|
1237
|
+
* tool call belongs to a turn paused on client functions (pause mode): `ready`
|
|
1238
|
+
* flips to `true` once ALL waiting calls of that message are submitted, meaning
|
|
1239
|
+
* the turn can be resumed via `continueMessage(resume.message_id)`.
|
|
1240
|
+
*/
|
|
1241
|
+
declare interface SubmitToolCallResult {
|
|
1242
|
+
status: string;
|
|
1243
|
+
result?: unknown;
|
|
1244
|
+
resume?: {
|
|
1245
|
+
message_id: string;
|
|
1246
|
+
ready: boolean;
|
|
1247
|
+
};
|
|
1248
|
+
}
|
|
1249
|
+
|
|
1133
1250
|
/**
|
|
1134
1251
|
* Tool call data from SSE stream
|
|
1135
1252
|
*/
|
|
@@ -1166,12 +1283,20 @@ export declare function useAgo(config: UseAgoOptions | null): {
|
|
|
1166
1283
|
* Auto-continue the agent after it navigates, so a "go to page B and change X"
|
|
1167
1284
|
* request completes in one user gesture. Mount this once inside `AgoProvider`.
|
|
1168
1285
|
*
|
|
1169
|
-
*
|
|
1170
|
-
*
|
|
1171
|
-
*
|
|
1172
|
-
*
|
|
1173
|
-
*
|
|
1174
|
-
*
|
|
1286
|
+
* Two mechanisms, picked by the turn's client-functions mode:
|
|
1287
|
+
*
|
|
1288
|
+
* - **Pause mode** (`clientFunctionsMode: "pause"`): the backend pauses the turn
|
|
1289
|
+
* on the navigation call (`message:waiting-client`) and the SDK resumes it once
|
|
1290
|
+
* the result is submitted. This hook only registers a *resume gate* that delays
|
|
1291
|
+
* the resume until the destination page's `useAgoPageState` registered (plus a
|
|
1292
|
+
* settle delay), so the continued turn ships the new page's `setPageState` and
|
|
1293
|
+
* current state. Same turn, no extra prompt, backend budget as the guardrail —
|
|
1294
|
+
* `continuationPrompt` and `maxDepth` are unused here.
|
|
1295
|
+
*
|
|
1296
|
+
* - **Placeholder mode** (legacy default): when the agent calls the navigation
|
|
1297
|
+
* function and that turn ends, this waits for the destination page's state to
|
|
1298
|
+
* register, then sends a hidden continuation message; the agent applies the
|
|
1299
|
+
* state in a second turn (requires backend support for the `hidden` flag).
|
|
1175
1300
|
*
|
|
1176
1301
|
* ```tsx
|
|
1177
1302
|
* function AppShell() {
|