@useago/sdk 1.4.2 → 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 +440 -429
- 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/widget.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.
|
|
125
|
+
*/
|
|
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.
|
|
81
130
|
*/
|
|
82
|
-
submitToolCallForm(toolCallId: string, formData: Record<string, unknown>): Promise<
|
|
131
|
+
submitToolCallForm(toolCallId: string, formData: Record<string, unknown>): Promise<SubmitToolCallResult>;
|
|
83
132
|
/**
|
|
84
133
|
* Confirm a tool call
|
|
85
134
|
*/
|
|
@@ -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,16 @@ 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;
|
|
409
487
|
}
|
|
410
488
|
|
|
411
489
|
declare type AgoEventHandler<K extends AgoEventName> = (data: AgoClientEvents[K]) => void;
|
|
@@ -599,6 +677,9 @@ declare interface ClientFunctionSchema {
|
|
|
599
677
|
};
|
|
600
678
|
}
|
|
601
679
|
|
|
680
|
+
/** See {@link AgoConfig.clientFunctionsMode}. */
|
|
681
|
+
declare type ClientFunctionsMode = "placeholder" | "pause";
|
|
682
|
+
|
|
602
683
|
/**
|
|
603
684
|
* A single piece of context the client wants the LLM to know about.
|
|
604
685
|
*/
|
|
@@ -819,7 +900,13 @@ declare interface LoadFormCollectorOptions<V = Record<string, unknown>> extends
|
|
|
819
900
|
name: string;
|
|
820
901
|
}
|
|
821
902
|
|
|
822
|
-
declare type MessageStatus = "IN_PROGRESS" | "DONE" | "ERROR" | "TODO" | "CANCELED"
|
|
903
|
+
declare type MessageStatus = "IN_PROGRESS" | "DONE" | "ERROR" | "TODO" | "CANCELED"
|
|
904
|
+
/**
|
|
905
|
+
* The turn paused on client function call(s) (pause mode): the agent waits for
|
|
906
|
+
* every waiting call to be submitted, then the turn resumes via
|
|
907
|
+
* `continueMessage`. Not a final state.
|
|
908
|
+
*/
|
|
909
|
+
| "WAITING_CLIENT";
|
|
823
910
|
|
|
824
911
|
/**
|
|
825
912
|
* Mount a complete, dependency-free chat widget into any DOM element — no React,
|
|
@@ -1067,6 +1154,17 @@ export declare interface MountChatWidgetOptions {
|
|
|
1067
1154
|
*/
|
|
1068
1155
|
export declare function renderMarkdown(source: string): DocumentFragment;
|
|
1069
1156
|
|
|
1157
|
+
/**
|
|
1158
|
+
* Hook run before a paused turn is resumed, so the app controls WHEN the
|
|
1159
|
+
* continuation fires (e.g. wait for the destination page to mount after a
|
|
1160
|
+
* navigation). It must resolve — throwing or hanging blocks the resume; on
|
|
1161
|
+
* timeout-style situations resolve anyway and let the agent conclude.
|
|
1162
|
+
*/
|
|
1163
|
+
declare type ResumeGate = (info: {
|
|
1164
|
+
conversationId: string;
|
|
1165
|
+
messageId: string;
|
|
1166
|
+
}) => Promise<void> | void;
|
|
1167
|
+
|
|
1070
1168
|
/**
|
|
1071
1169
|
* Options for sending a message
|
|
1072
1170
|
*/
|
|
@@ -1084,6 +1182,8 @@ declare interface SendMessageOptions {
|
|
|
1084
1182
|
* Requires backend support for the `hidden` flag; older backends ignore it.
|
|
1085
1183
|
*/
|
|
1086
1184
|
hidden?: boolean;
|
|
1185
|
+
/** Per-message override of {@link AgoConfig.clientFunctionsMode}. */
|
|
1186
|
+
clientFunctionsMode?: ClientFunctionsMode;
|
|
1087
1187
|
}
|
|
1088
1188
|
|
|
1089
1189
|
/**
|
|
@@ -1125,6 +1225,8 @@ declare interface SSEChunkData {
|
|
|
1125
1225
|
follow_up_replies?: string[];
|
|
1126
1226
|
satisfaction_feedback?: unknown;
|
|
1127
1227
|
ask_to_talk_to_human?: boolean;
|
|
1228
|
+
/** Tool call ids still awaiting a client result, sent with the final `WAITING_CLIENT` event. */
|
|
1229
|
+
waiting_tool_call_ids?: string[];
|
|
1128
1230
|
}
|
|
1129
1231
|
|
|
1130
1232
|
/** The slice of the Web Storage API that {@link createStore} relies on. */
|
|
@@ -1152,6 +1254,21 @@ declare type SubmitConfig<V = Record<string, unknown>> = string | {
|
|
|
1152
1254
|
destination?: string;
|
|
1153
1255
|
} | false;
|
|
1154
1256
|
|
|
1257
|
+
/**
|
|
1258
|
+
* Response of `POST /tool-calls/{id}/submit`. `resume` is only present when the
|
|
1259
|
+
* tool call belongs to a turn paused on client functions (pause mode): `ready`
|
|
1260
|
+
* flips to `true` once ALL waiting calls of that message are submitted, meaning
|
|
1261
|
+
* the turn can be resumed via `continueMessage(resume.message_id)`.
|
|
1262
|
+
*/
|
|
1263
|
+
declare interface SubmitToolCallResult {
|
|
1264
|
+
status: string;
|
|
1265
|
+
result?: unknown;
|
|
1266
|
+
resume?: {
|
|
1267
|
+
message_id: string;
|
|
1268
|
+
ready: boolean;
|
|
1269
|
+
};
|
|
1270
|
+
}
|
|
1271
|
+
|
|
1155
1272
|
/**
|
|
1156
1273
|
* Tool call data from SSE stream
|
|
1157
1274
|
*/
|