@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/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
|
*/
|
|
@@ -145,7 +194,7 @@ declare class AgoClient {
|
|
|
145
194
|
* ```
|
|
146
195
|
*/
|
|
147
196
|
registerFunction(definition: ClientFunctionDefinition): void;
|
|
148
|
-
registerFunction(name: string, handler: ClientFunctionHandler, schema:
|
|
197
|
+
registerFunction(name: string, handler: ClientFunctionHandler, schema: ClientFunctionRegisterOptions): void;
|
|
149
198
|
/**
|
|
150
199
|
* Short alias for `registerFunction`. Also accepts an array of definitions.
|
|
151
200
|
*
|
|
@@ -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,24 @@ 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;
|
|
506
|
+
/**
|
|
507
|
+
* Max serialized size (bytes) of a client function result before the SDK
|
|
508
|
+
* replaces it with a flagged, truncated preview. Everything a handler
|
|
509
|
+
* returns is sent into the LLM context, so this caps runaway payloads
|
|
510
|
+
* (raw API responses, full tables). Default `50000`. Override per function
|
|
511
|
+
* with `maxResultBytes` on its definition; `Infinity` disables the guard.
|
|
512
|
+
*/
|
|
513
|
+
maxFunctionResultBytes?: number;
|
|
428
514
|
}
|
|
429
515
|
|
|
430
516
|
/**
|
|
@@ -636,6 +722,12 @@ declare interface ClientFunctionDefinition {
|
|
|
636
722
|
description: string;
|
|
637
723
|
parameters: ClientFunctionSchema["parameters"];
|
|
638
724
|
handler: ClientFunctionHandler;
|
|
725
|
+
/**
|
|
726
|
+
* Max serialized result size in bytes before the SDK truncates it to a
|
|
727
|
+
* flagged preview (default: `AgoConfig.maxFunctionResultBytes`, 50 000).
|
|
728
|
+
* `Infinity` disables the guard for this function.
|
|
729
|
+
*/
|
|
730
|
+
maxResultBytes?: number;
|
|
639
731
|
}
|
|
640
732
|
|
|
641
733
|
/**
|
|
@@ -650,6 +742,20 @@ declare interface ClientFunctionInvocation {
|
|
|
650
742
|
conversationId: string;
|
|
651
743
|
}
|
|
652
744
|
|
|
745
|
+
/**
|
|
746
|
+
* Schema-plus-settings object accepted when registering a function: the schema
|
|
747
|
+
* (minus `name`) and SDK-side options that are NOT sent to the backend.
|
|
748
|
+
*/
|
|
749
|
+
declare type ClientFunctionRegisterOptions = Omit<ClientFunctionSchema, "name"> & {
|
|
750
|
+
/**
|
|
751
|
+
* Max serialized result size in bytes before the SDK truncates it to a
|
|
752
|
+
* flagged preview. Overrides the client-level default
|
|
753
|
+
* (`AgoConfig.maxFunctionResultBytes`, 50 000 by default). `Infinity`
|
|
754
|
+
* disables the guard for this function.
|
|
755
|
+
*/
|
|
756
|
+
maxResultBytes?: number;
|
|
757
|
+
};
|
|
758
|
+
|
|
653
759
|
/**
|
|
654
760
|
* Schema for a client-side function that AGO can call
|
|
655
761
|
*/
|
|
@@ -675,6 +781,9 @@ declare interface ClientFunctionSchema {
|
|
|
675
781
|
};
|
|
676
782
|
}
|
|
677
783
|
|
|
784
|
+
/** See {@link AgoConfig.clientFunctionsMode}. */
|
|
785
|
+
declare type ClientFunctionsMode = "placeholder" | "pause";
|
|
786
|
+
|
|
678
787
|
/**
|
|
679
788
|
* A single piece of context the client wants the LLM to know about.
|
|
680
789
|
*/
|
|
@@ -995,7 +1104,13 @@ export declare interface MessageProps {
|
|
|
995
1104
|
onFollowUpClick?: (reply: string) => void;
|
|
996
1105
|
}
|
|
997
1106
|
|
|
998
|
-
declare type MessageStatus = "IN_PROGRESS" | "DONE" | "ERROR" | "TODO" | "CANCELED"
|
|
1107
|
+
declare type MessageStatus = "IN_PROGRESS" | "DONE" | "ERROR" | "TODO" | "CANCELED"
|
|
1108
|
+
/**
|
|
1109
|
+
* The turn paused on client function call(s) (pause mode): the agent waits for
|
|
1110
|
+
* every waiting call to be submitted, then the turn resumes via
|
|
1111
|
+
* `continueMessage`. Not a final state.
|
|
1112
|
+
*/
|
|
1113
|
+
| "WAITING_CLIENT";
|
|
999
1114
|
|
|
1000
1115
|
declare interface MockAgoClient extends AgoClient {
|
|
1001
1116
|
/**
|
|
@@ -1027,6 +1142,17 @@ declare interface MockAgoClientOptions {
|
|
|
1027
1142
|
|
|
1028
1143
|
declare type MockFn = (...args: any[]) => any;
|
|
1029
1144
|
|
|
1145
|
+
/**
|
|
1146
|
+
* Hook run before a paused turn is resumed, so the app controls WHEN the
|
|
1147
|
+
* continuation fires (e.g. wait for the destination page to mount after a
|
|
1148
|
+
* navigation). It must resolve — throwing or hanging blocks the resume; on
|
|
1149
|
+
* timeout-style situations resolve anyway and let the agent conclude.
|
|
1150
|
+
*/
|
|
1151
|
+
declare type ResumeGate = (info: {
|
|
1152
|
+
conversationId: string;
|
|
1153
|
+
messageId: string;
|
|
1154
|
+
}) => Promise<void> | void;
|
|
1155
|
+
|
|
1030
1156
|
/**
|
|
1031
1157
|
* Options for sending a message
|
|
1032
1158
|
*/
|
|
@@ -1044,6 +1170,8 @@ declare interface SendMessageOptions {
|
|
|
1044
1170
|
* Requires backend support for the `hidden` flag; older backends ignore it.
|
|
1045
1171
|
*/
|
|
1046
1172
|
hidden?: boolean;
|
|
1173
|
+
/** Per-message override of {@link AgoConfig.clientFunctionsMode}. */
|
|
1174
|
+
clientFunctionsMode?: ClientFunctionsMode;
|
|
1047
1175
|
}
|
|
1048
1176
|
|
|
1049
1177
|
/**
|
|
@@ -1085,6 +1213,8 @@ declare interface SSEChunkData {
|
|
|
1085
1213
|
follow_up_replies?: string[];
|
|
1086
1214
|
satisfaction_feedback?: unknown;
|
|
1087
1215
|
ask_to_talk_to_human?: boolean;
|
|
1216
|
+
/** Tool call ids still awaiting a client result, sent with the final `WAITING_CLIENT` event. */
|
|
1217
|
+
waiting_tool_call_ids?: string[];
|
|
1088
1218
|
}
|
|
1089
1219
|
|
|
1090
1220
|
/**
|
|
@@ -1130,6 +1260,21 @@ export declare type SubmitConfig<V = Record<string, unknown>> = string | {
|
|
|
1130
1260
|
destination?: string;
|
|
1131
1261
|
} | false;
|
|
1132
1262
|
|
|
1263
|
+
/**
|
|
1264
|
+
* Response of `POST /tool-calls/{id}/submit`. `resume` is only present when the
|
|
1265
|
+
* tool call belongs to a turn paused on client functions (pause mode): `ready`
|
|
1266
|
+
* flips to `true` once ALL waiting calls of that message are submitted, meaning
|
|
1267
|
+
* the turn can be resumed via `continueMessage(resume.message_id)`.
|
|
1268
|
+
*/
|
|
1269
|
+
declare interface SubmitToolCallResult {
|
|
1270
|
+
status: string;
|
|
1271
|
+
result?: unknown;
|
|
1272
|
+
resume?: {
|
|
1273
|
+
message_id: string;
|
|
1274
|
+
ready: boolean;
|
|
1275
|
+
};
|
|
1276
|
+
}
|
|
1277
|
+
|
|
1133
1278
|
/**
|
|
1134
1279
|
* Tool call data from SSE stream
|
|
1135
1280
|
*/
|
|
@@ -1166,12 +1311,20 @@ export declare function useAgo(config: UseAgoOptions | null): {
|
|
|
1166
1311
|
* Auto-continue the agent after it navigates, so a "go to page B and change X"
|
|
1167
1312
|
* request completes in one user gesture. Mount this once inside `AgoProvider`.
|
|
1168
1313
|
*
|
|
1169
|
-
*
|
|
1170
|
-
*
|
|
1171
|
-
*
|
|
1172
|
-
*
|
|
1173
|
-
*
|
|
1174
|
-
*
|
|
1314
|
+
* Two mechanisms, picked by the turn's client-functions mode:
|
|
1315
|
+
*
|
|
1316
|
+
* - **Pause mode** (`clientFunctionsMode: "pause"`): the backend pauses the turn
|
|
1317
|
+
* on the navigation call (`message:waiting-client`) and the SDK resumes it once
|
|
1318
|
+
* the result is submitted. This hook only registers a *resume gate* that delays
|
|
1319
|
+
* the resume until the destination page's `useAgoPageState` registered (plus a
|
|
1320
|
+
* settle delay), so the continued turn ships the new page's `setPageState` and
|
|
1321
|
+
* current state. Same turn, no extra prompt, backend budget as the guardrail —
|
|
1322
|
+
* `continuationPrompt` and `maxDepth` are unused here.
|
|
1323
|
+
*
|
|
1324
|
+
* - **Placeholder mode** (legacy default): when the agent calls the navigation
|
|
1325
|
+
* function and that turn ends, this waits for the destination page's state to
|
|
1326
|
+
* register, then sends a hidden continuation message; the agent applies the
|
|
1327
|
+
* state in a second turn (requires backend support for the `hidden` flag).
|
|
1175
1328
|
*
|
|
1176
1329
|
* ```tsx
|
|
1177
1330
|
* function AppShell() {
|
|
@@ -1274,6 +1427,12 @@ export declare interface UseAgoFunctionOptions {
|
|
|
1274
1427
|
required?: string[];
|
|
1275
1428
|
};
|
|
1276
1429
|
handler: ClientFunctionHandler;
|
|
1430
|
+
/**
|
|
1431
|
+
* Max serialized result size in bytes before the SDK truncates it to a
|
|
1432
|
+
* flagged preview (default: `AgoConfig.maxFunctionResultBytes`, 50 000).
|
|
1433
|
+
* `Infinity` disables the guard for this function.
|
|
1434
|
+
*/
|
|
1435
|
+
maxResultBytes?: number;
|
|
1277
1436
|
}
|
|
1278
1437
|
|
|
1279
1438
|
/**
|