@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/angular.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("./AgoClient-
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("./AgoClient-CMDVqNaH.cjs");var n=class{constructor(e){this.client=new o.AgoClient(e),this.messages$=this.fromEvent("message:complete"),this.chunks$=this.fromEvent("message:chunk"),this.errors$=this.fromEvent("message:error"),this.messageStart$=this.fromEvent("message:start")}fromEvent(e){const t=this.client;return{subscribe(i){const s=r=>{i.next?.(r)};return t.on(e,s),{unsubscribe:()=>t.off(e,s)}}}}sendMessage(e,t){return this.client.sendMessage(e,t)}getConversations(){return this.client.getConversations()}getConversation(e){return this.client.getConversation(e)}getMessages(e){return this.client.getMessages(e)}submitToolCallForm(e,t){return this.client.submitToolCallForm(e,t)}confirmToolCall(e){return this.client.confirmToolCall(e)}rejectToolCall(e){return this.client.rejectToolCall(e)}submitFeedback(e,t){return this.client.submitFeedback(e,t)}registerFunction(e,t,i){typeof e=="object"?this.client.registerFunction(e):this.client.registerFunction(e,t,i)}unregisterFunction(e){return this.client.unregisterFunction(e)}registerNavigationFunction(e,t){this.client.registerNavigationFunction(e,t)}unregisterNavigationFunction(){this.client.unregisterNavigationFunction()}registerPageStateFunction(e,t){this.client.registerPageStateFunction(e,t)}unregisterPageStateFunction(e){this.client.unregisterPageStateFunction(e)}on(e,t){this.client.on(e,t)}off(e,t){this.client.off(e,t)}updateConfig(e){this.client.updateConfig(e)}getClient(){return this.client}destroy(){this.client.destroy()}};function c(e){return{provide:n,useValue:new n(e)}}exports.AgoService=n;exports.provideAgo=c;
|
package/dist/angular.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.
|
|
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 @@ export 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 @@ export 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;
|
|
@@ -503,7 +581,7 @@ export declare class AgoService {
|
|
|
503
581
|
/** Get messages for a conversation */
|
|
504
582
|
getMessages(conversationId: string): Promise<AgoMessage[]>;
|
|
505
583
|
/** Submit form data for a tool call */
|
|
506
|
-
submitToolCallForm(toolCallId: string, formData: Record<string, unknown>): Promise<
|
|
584
|
+
submitToolCallForm(toolCallId: string, formData: Record<string, unknown>): Promise<SubmitToolCallResult>;
|
|
507
585
|
/** Confirm a tool call */
|
|
508
586
|
confirmToolCall(toolCallId: string): Promise<void>;
|
|
509
587
|
/** Reject a tool call */
|
|
@@ -631,6 +709,9 @@ declare interface ClientFunctionSchema {
|
|
|
631
709
|
};
|
|
632
710
|
}
|
|
633
711
|
|
|
712
|
+
/** See {@link AgoConfig.clientFunctionsMode}. */
|
|
713
|
+
declare type ClientFunctionsMode = "placeholder" | "pause";
|
|
714
|
+
|
|
634
715
|
/**
|
|
635
716
|
* A single piece of context the client wants the LLM to know about.
|
|
636
717
|
*/
|
|
@@ -764,7 +845,13 @@ declare interface FormSchema {
|
|
|
764
845
|
required?: string[];
|
|
765
846
|
}
|
|
766
847
|
|
|
767
|
-
declare type MessageStatus = "IN_PROGRESS" | "DONE" | "ERROR" | "TODO" | "CANCELED"
|
|
848
|
+
declare type MessageStatus = "IN_PROGRESS" | "DONE" | "ERROR" | "TODO" | "CANCELED"
|
|
849
|
+
/**
|
|
850
|
+
* The turn paused on client function call(s) (pause mode): the agent waits for
|
|
851
|
+
* every waiting call to be submitted, then the turn resumes via
|
|
852
|
+
* `continueMessage`. Not a final state.
|
|
853
|
+
*/
|
|
854
|
+
| "WAITING_CLIENT";
|
|
768
855
|
|
|
769
856
|
declare interface Observable<T> {
|
|
770
857
|
subscribe(observer: {
|
|
@@ -799,6 +886,17 @@ export declare function provideAgo(options: AgoProvideOptions): {
|
|
|
799
886
|
useValue: AgoService;
|
|
800
887
|
};
|
|
801
888
|
|
|
889
|
+
/**
|
|
890
|
+
* Hook run before a paused turn is resumed, so the app controls WHEN the
|
|
891
|
+
* continuation fires (e.g. wait for the destination page to mount after a
|
|
892
|
+
* navigation). It must resolve — throwing or hanging blocks the resume; on
|
|
893
|
+
* timeout-style situations resolve anyway and let the agent conclude.
|
|
894
|
+
*/
|
|
895
|
+
declare type ResumeGate = (info: {
|
|
896
|
+
conversationId: string;
|
|
897
|
+
messageId: string;
|
|
898
|
+
}) => Promise<void> | void;
|
|
899
|
+
|
|
802
900
|
/**
|
|
803
901
|
* Options for sending a message
|
|
804
902
|
*/
|
|
@@ -816,6 +914,8 @@ declare interface SendMessageOptions {
|
|
|
816
914
|
* Requires backend support for the `hidden` flag; older backends ignore it.
|
|
817
915
|
*/
|
|
818
916
|
hidden?: boolean;
|
|
917
|
+
/** Per-message override of {@link AgoConfig.clientFunctionsMode}. */
|
|
918
|
+
clientFunctionsMode?: ClientFunctionsMode;
|
|
819
919
|
}
|
|
820
920
|
|
|
821
921
|
/**
|
|
@@ -857,6 +957,8 @@ declare interface SSEChunkData {
|
|
|
857
957
|
follow_up_replies?: string[];
|
|
858
958
|
satisfaction_feedback?: unknown;
|
|
859
959
|
ask_to_talk_to_human?: boolean;
|
|
960
|
+
/** Tool call ids still awaiting a client result, sent with the final `WAITING_CLIENT` event. */
|
|
961
|
+
waiting_tool_call_ids?: string[];
|
|
860
962
|
}
|
|
861
963
|
|
|
862
964
|
/**
|
|
@@ -881,6 +983,21 @@ declare type SubmitConfig<V = Record<string, unknown>> = string | {
|
|
|
881
983
|
destination?: string;
|
|
882
984
|
} | false;
|
|
883
985
|
|
|
986
|
+
/**
|
|
987
|
+
* Response of `POST /tool-calls/{id}/submit`. `resume` is only present when the
|
|
988
|
+
* tool call belongs to a turn paused on client functions (pause mode): `ready`
|
|
989
|
+
* flips to `true` once ALL waiting calls of that message are submitted, meaning
|
|
990
|
+
* the turn can be resumed via `continueMessage(resume.message_id)`.
|
|
991
|
+
*/
|
|
992
|
+
declare interface SubmitToolCallResult {
|
|
993
|
+
status: string;
|
|
994
|
+
result?: unknown;
|
|
995
|
+
resume?: {
|
|
996
|
+
message_id: string;
|
|
997
|
+
ready: boolean;
|
|
998
|
+
};
|
|
999
|
+
}
|
|
1000
|
+
|
|
884
1001
|
/**
|
|
885
1002
|
* Tool call data from SSE stream
|
|
886
1003
|
*/
|
package/dist/angular.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 @@ export 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 @@ export 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;
|
|
@@ -503,7 +581,7 @@ export declare class AgoService {
|
|
|
503
581
|
/** Get messages for a conversation */
|
|
504
582
|
getMessages(conversationId: string): Promise<AgoMessage[]>;
|
|
505
583
|
/** Submit form data for a tool call */
|
|
506
|
-
submitToolCallForm(toolCallId: string, formData: Record<string, unknown>): Promise<
|
|
584
|
+
submitToolCallForm(toolCallId: string, formData: Record<string, unknown>): Promise<SubmitToolCallResult>;
|
|
507
585
|
/** Confirm a tool call */
|
|
508
586
|
confirmToolCall(toolCallId: string): Promise<void>;
|
|
509
587
|
/** Reject a tool call */
|
|
@@ -631,6 +709,9 @@ declare interface ClientFunctionSchema {
|
|
|
631
709
|
};
|
|
632
710
|
}
|
|
633
711
|
|
|
712
|
+
/** See {@link AgoConfig.clientFunctionsMode}. */
|
|
713
|
+
declare type ClientFunctionsMode = "placeholder" | "pause";
|
|
714
|
+
|
|
634
715
|
/**
|
|
635
716
|
* A single piece of context the client wants the LLM to know about.
|
|
636
717
|
*/
|
|
@@ -764,7 +845,13 @@ declare interface FormSchema {
|
|
|
764
845
|
required?: string[];
|
|
765
846
|
}
|
|
766
847
|
|
|
767
|
-
declare type MessageStatus = "IN_PROGRESS" | "DONE" | "ERROR" | "TODO" | "CANCELED"
|
|
848
|
+
declare type MessageStatus = "IN_PROGRESS" | "DONE" | "ERROR" | "TODO" | "CANCELED"
|
|
849
|
+
/**
|
|
850
|
+
* The turn paused on client function call(s) (pause mode): the agent waits for
|
|
851
|
+
* every waiting call to be submitted, then the turn resumes via
|
|
852
|
+
* `continueMessage`. Not a final state.
|
|
853
|
+
*/
|
|
854
|
+
| "WAITING_CLIENT";
|
|
768
855
|
|
|
769
856
|
declare interface Observable<T> {
|
|
770
857
|
subscribe(observer: {
|
|
@@ -799,6 +886,17 @@ export declare function provideAgo(options: AgoProvideOptions): {
|
|
|
799
886
|
useValue: AgoService;
|
|
800
887
|
};
|
|
801
888
|
|
|
889
|
+
/**
|
|
890
|
+
* Hook run before a paused turn is resumed, so the app controls WHEN the
|
|
891
|
+
* continuation fires (e.g. wait for the destination page to mount after a
|
|
892
|
+
* navigation). It must resolve — throwing or hanging blocks the resume; on
|
|
893
|
+
* timeout-style situations resolve anyway and let the agent conclude.
|
|
894
|
+
*/
|
|
895
|
+
declare type ResumeGate = (info: {
|
|
896
|
+
conversationId: string;
|
|
897
|
+
messageId: string;
|
|
898
|
+
}) => Promise<void> | void;
|
|
899
|
+
|
|
802
900
|
/**
|
|
803
901
|
* Options for sending a message
|
|
804
902
|
*/
|
|
@@ -816,6 +914,8 @@ declare interface SendMessageOptions {
|
|
|
816
914
|
* Requires backend support for the `hidden` flag; older backends ignore it.
|
|
817
915
|
*/
|
|
818
916
|
hidden?: boolean;
|
|
917
|
+
/** Per-message override of {@link AgoConfig.clientFunctionsMode}. */
|
|
918
|
+
clientFunctionsMode?: ClientFunctionsMode;
|
|
819
919
|
}
|
|
820
920
|
|
|
821
921
|
/**
|
|
@@ -857,6 +957,8 @@ declare interface SSEChunkData {
|
|
|
857
957
|
follow_up_replies?: string[];
|
|
858
958
|
satisfaction_feedback?: unknown;
|
|
859
959
|
ask_to_talk_to_human?: boolean;
|
|
960
|
+
/** Tool call ids still awaiting a client result, sent with the final `WAITING_CLIENT` event. */
|
|
961
|
+
waiting_tool_call_ids?: string[];
|
|
860
962
|
}
|
|
861
963
|
|
|
862
964
|
/**
|
|
@@ -881,6 +983,21 @@ declare type SubmitConfig<V = Record<string, unknown>> = string | {
|
|
|
881
983
|
destination?: string;
|
|
882
984
|
} | false;
|
|
883
985
|
|
|
986
|
+
/**
|
|
987
|
+
* Response of `POST /tool-calls/{id}/submit`. `resume` is only present when the
|
|
988
|
+
* tool call belongs to a turn paused on client functions (pause mode): `ready`
|
|
989
|
+
* flips to `true` once ALL waiting calls of that message are submitted, meaning
|
|
990
|
+
* the turn can be resumed via `continueMessage(resume.message_id)`.
|
|
991
|
+
*/
|
|
992
|
+
declare interface SubmitToolCallResult {
|
|
993
|
+
status: string;
|
|
994
|
+
result?: unknown;
|
|
995
|
+
resume?: {
|
|
996
|
+
message_id: string;
|
|
997
|
+
ready: boolean;
|
|
998
|
+
};
|
|
999
|
+
}
|
|
1000
|
+
|
|
884
1001
|
/**
|
|
885
1002
|
* Tool call data from SSE stream
|
|
886
1003
|
*/
|
package/dist/angular.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as o } from "./AgoClient-
|
|
1
|
+
import { t as o } from "./AgoClient-S8oeNnAE.js";
|
|
2
2
|
var s = class {
|
|
3
3
|
constructor(t) {
|
|
4
4
|
this.client = new o(t), this.messages$ = this.fromEvent("message:complete"), this.chunks$ = this.fromEvent("message:chunk"), this.errors$ = this.fromEvent("message:error"), this.messageStart$ = this.fromEvent("message:start");
|
package/dist/{createConversationSession-B8zfTL78.cjs → createConversationSession-CmBq7uGi.cjs}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
const d=require("./createFormCollector-
|
|
1
|
+
const d=require("./createFormCollector-Bz_0IJ0Q.cjs");var f="ago_widget_id",g="ago_last_thread",y=7200*1e3;function v(){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,e=>{const r=Math.floor(Math.random()*16);return(e==="x"?r:r&3|8).toString(16)})}function _(e={}){const r=e.key??f,i=e.threadKey??g,u=e.ttlMs??y,l=e.storage??(typeof localStorage<"u"?localStorage:void 0);let n=e.widgetId??"";if(!n&&l)try{n=l.getItem(r)??""}catch{}if(n||(n=v()),l)try{l.setItem(r,n)}catch{}const o=d.createStore({value:null,lastMessageAt:null},{key:i,storage:l}),c=o.get();c.value!==null&&s(c.lastMessageAt)&&o.set({value:null,lastMessageAt:null});function s(t){return t===null?!0:Number.isFinite(u)?Date.now()-t>u:!1}return{widgetId:n,key:r,getLastActiveThread(){const{value:t,lastMessageAt:a}=o.get();return t===null||s(a)?null:t},setActiveThread(t,a){const x=a==null?null:a instanceof Date?a.getTime():a;o.set({value:t,lastMessageAt:x})},clear(){o.set({value:null,lastMessageAt:null})}}}Object.defineProperty(exports,"createConversationSession",{enumerable:!0,get:function(){return _}});
|
package/dist/{createConversationSession-CWpf4u6I.js → createConversationSession-DoUHdVNR.js}
RENAMED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { i as d } from "./createFormCollector-
|
|
1
|
+
import { i as d } from "./createFormCollector-vy-QvFja.js";
|
|
2
2
|
var f = "ago_widget_id", g = "ago_last_thread", y = 7200 * 1e3;
|
|
3
3
|
function v() {
|
|
4
4
|
return typeof crypto < "u" && typeof crypto.randomUUID == "function" ? crypto.randomUUID() : "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, (e) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const C=require("./AgoClient-
|
|
1
|
+
const C=require("./AgoClient-CMDVqNaH.cjs");function W(n,e){const a=e?e.storage??(typeof localStorage<"u"?localStorage:void 0):void 0;let s=n;if(e&&a)try{const m=a.getItem(e.key);m!=null&&(s=JSON.parse(m))}catch{}const i=new Set,c=()=>i.forEach(m=>m(s));function b(){if(e&&a)try{a.setItem(e.key,JSON.stringify(s))}catch{}}return{get:()=>s,set:m=>{s=m,b(),c()},subscribe:m=>(i.add(m),()=>{i.delete(m)})}}var T=/^[a-zA-Z0-9_-]{1,40}$/,x=n=>n==null||n==="";function v(n,e){if("anyOf"in n)return n.anyOf.some(c=>v(c,e));if("allOf"in n)return n.allOf.every(c=>v(c,e));const a=e[n.property];if(x(a))return!1;if(Array.isArray(n.value))return n.value.some(c=>String(a)===String(c));if(!n.op)return String(a)===String(n.value);const s=Number(a),i=Number(n.value);if(Number.isNaN(s)||Number.isNaN(i))return!1;switch(n.op){case">=":return s>=i;case"<=":return s<=i;case">":return s>i;case"<":return s<i;default:return C.logger.warn(`Unknown requiredWhen op "${n.op}"; treating as not required.`),!1}}function h(n,e){const a=n.properties??{},s=new Set;for(const c of n.required??[]){const b=a[c]?.requiredWhen;(!b||v(b,e))&&s.add(c)}for(const[c,b]of Object.entries(a))b.requiredWhen&&v(b.requiredWhen,e)&&s.add(c);const i=[...s].filter(c=>x(e[c]));return{missing:i,complete:i.length===0}}function R(n){const e={};for(const[a,s]of Object.entries(n.properties??{}))e[a]={type:s.type,...s.description!=null&&{description:s.description},...s.enum&&{enum:s.enum},...s.default!==void 0&&{default:s.default}};return{type:"object",properties:e,required:[]}}function A(n){const{name:e,description:a,schema:s}=n;if(!T.test(e))throw new Error(`Invalid form collector name "${e}": must match ${T} (it becomes the update_/submit_ function names).`);const i=typeof n.submit=="string"?n.submit?{via:"client",url:n.submit}:!1:n.submit??!1;n.autoSubmit===!0&&!i&&C.logger.warn(`FormCollector "${e}": autoSubmit is ignored because no submit target is configured.`);const c=(n.autoSubmit??!0)&&!!i,b=s.properties??{},m=t=>{const r={};for(const[u,o]of Object.entries(t)){const l=b[u];if(l)if(o==null)r[u]=o;else if(l.type==="number"||l.type==="integer"){const d=typeof o=="number"?o:Number(o);r[u]=Number.isNaN(d)?o:d}else l.type==="boolean"?r[u]=typeof o=="boolean"?o:o==="true"?!0:o==="false"?!1:!!o:r[u]=o}return r},S=n.initialValues??{},f=W({values:S,submitted:!1}),$=t=>{const r=f.get(),u={...r,values:{...r.values,...t}};return f.set(u),u};let g=null;const F=(t,r)=>{g?.emitFormEvent("form:error",{name:e,values:t,error:r})};let y=null;const I=async()=>{const{values:t}=f.get(),{complete:r,missing:u}=h(s,t);if(!r)return{ok:!1,missing:u};if(!i)return{ok:!1,error:"No submit target configured for this form collector."};const o=t;try{let l;if(i.via==="client")if("handler"in i)l=await i.handler(o);else{const d=await fetch(i.url,{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify(o)});if(!d.ok){const j=`Submit failed: HTTP ${d.status}`;return F(o,j),{ok:!1,error:j}}l=await d.json().catch(()=>{})}else{if(!g)return{ok:!1,error:"Backend submit requires install(client) (or useFormCollector) first."};l=await g.submitFormCollector(e,o)}return f.set({...f.get(),submitted:!0,submitResult:l}),g?.emitFormEvent("form:submitted",{name:e,values:o,result:l}),{ok:!0,result:l}}catch(l){const d=l instanceof Error?l.message:"Submit failed";return C.logger.error(`FormCollector "${e}" submit failed:`,l),F(o,d),{ok:!1,error:d}}},N=()=>y||(y=(async()=>{try{return await I()}finally{y=null}})(),y),k=async()=>{if(!c||!i)return null;const{values:t,submitted:r}=f.get();return r||!h(s,t).complete?null:N()},O={name:`update_${e}`,description:`Fill or update fields of the "${e}" form. ${a} Pass any subset of fields; call it repeatedly to fill the form as the user provides information. Returns the current values and which required fields are still missing.`,parameters:R(s),handler:async t=>{const r=$(m(t)),{missing:u}=h(s,r.values),o=await k();return o?o.ok?{ok:!0,values:r.values,missing:u,submitted:!0}:{ok:!0,values:r.values,missing:u,submitted:!1,submitError:o.error}:{ok:!0,values:r.values,missing:u}}},p=[O];i&&!c&&p.push({name:`submit_${e}`,description:`Submit the completed "${e}" form. Only call this once every required field is collected and the user has confirmed. If fields are missing it returns them instead of submitting.`,parameters:{type:"object",properties:{}},handler:()=>N()});const V="client__",q=i?`submit_${e}`:null,J=t=>{const r=t.functionName??t.toolName;if(r)return r.startsWith(V)?r.slice(8):r},_=t=>{let r={...S},u=!1;for(const o of t){const l=J(o);l===O.name?o.arguments&&(r={...r,...m(o.arguments)}):q&&l===q&&o.status?.toLowerCase()==="done"&&(u=!0)}f.set({values:r,submitted:u})},w=`form:${e}`,E=()=>{const{values:t,submitted:r}=f.get(),{missing:u,complete:o}=h(s,t),l=i?c?" The form is submitted automatically as soon as every required field is filled, so there is no submit function to call.":` When nothing is missing and the user confirms, call submit_${e}.`:"",d=r?`The "${e}" form has been submitted.`:`You are currently collecting information from the user to fill the "${e}" form.`;return{name:`Form: ${e}`,description:`${d} ${a} Some fields are conditionally required; the requiredWhen field in the schema tells you when each becomes required. The form schema is the following: ${JSON.stringify(s)}. Data collected so far: ${JSON.stringify(t)}. Call update_${e} with any fields the user provides; ask only for what is still missing.${l}`,data:{values:t,missing:u,complete:o,submitted:r}}},P=t=>{_((t.messages??[]).flatMap(r=>r.toolCalls??[]))};return{name:e,store:f,functions:p,contextKey:w,contextProvider:E,install:t=>{g=t;for(const u of p)t.register(u);t.addDynamicContext(w,E);const r=f.subscribe(()=>t.notifyContextChanged());return t.on("conversation:loaded",P),()=>{r();for(const u of p)t.unregisterFunction(u.name);t.removeDynamicContext(w),t.off("conversation:loaded",P),g===t&&(g=null)}},hydrate:_,submit:N,getValues:()=>f.get().values,setValues:t=>{$(m(t)),k()},reset:()=>{f.set({values:S,submitted:!1})},getStatus:()=>h(s,f.get().values)}}async function B(n,e){const a=await n.getFormCollector(e.name);return A({name:a.name,description:e.description??a.description,schema:e.schema??a.schema,submit:e.submit??a.submit,initialValues:e.initialValues,autoSubmit:e.autoSubmit??a.autoSubmit})}Object.defineProperty(exports,"createFormCollector",{enumerable:!0,get:function(){return A}});Object.defineProperty(exports,"createStore",{enumerable:!0,get:function(){return W}});Object.defineProperty(exports,"deriveFormStatus",{enumerable:!0,get:function(){return h}});Object.defineProperty(exports,"loadFormCollector",{enumerable:!0,get:function(){return B}});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
function y(u={}){const{overrides:g={}}=u,a={id:"mock-msg-1",conversationId:"mock-conv-1",content:"Mock response",role:"assistant",status:"DONE",createdAt:new Date},l={id:"mock-conv-1",title:"Mock Conversation",lastMessageDate:new Date},t=new Map,r=[],m={sendMessage:async()=>a,continueMessage:async()=>a,resumePendingClientFunctions:async()=>null,registerResumeGate:()=>()=>{},getConversations:async()=>[l],getConversation:async()=>l,getMessages:async()=>[a],submitToolCallForm:async()=>({status:"completed"}),confirmToolCall:async()=>{},rejectToolCall:async()=>{},submitFeedback:async()=>{},registerFunction:()=>{},unregisterFunction:()=>!0,getRegisteredFunctions:()=>[],getContextSnapshot:()=>null,notifyContextChanged:()=>{},registerNavigationFunction:()=>{},unregisterNavigationFunction:()=>{},on:(e,o)=>{t.has(e)||t.set(e,new Set),t.get(e).add(o)},off:(e,o)=>{t.get(e)?.delete(o)},once:(e,o)=>{const n=(...i)=>{t.get(e)?.delete(n),o(...i)};t.has(e)||t.set(e,new Set),t.get(e).add(n)},waitFor:(e,o)=>new Promise((n,i)=>{let c;const d=f=>{c&&clearTimeout(c),t.get(e)?.delete(d),n(f)};t.has(e)||t.set(e,new Set),t.get(e).add(d),o?.timeout&&(c=setTimeout(()=>{t.get(e)?.delete(d),i(new Error(`waitFor("${e}") timed out after ${o.timeout}ms`))},o.timeout))}),updateConfig:()=>{},destroy:()=>{t.clear()},...g},s={};for(const[e,o]of Object.entries(m))s[e]=(...n)=>(r.push({method:e,args:n}),o(...n));return s.__calls=r,s.__callsFor=e=>r.filter(o=>o.method===e),s.__emitEvent=(e,o)=>{const n=t.get(e);n&&[...n].forEach(i=>i(o))},s}Object.defineProperty(exports,"createMockClient",{enumerable:!0,get:function(){return y}});
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
function
|
|
2
|
-
const { overrides: u = {} } = g,
|
|
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(),
|
|
14
|
-
sendMessage: async () =>
|
|
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 () => [
|
|
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
|
|
51
|
-
const
|
|
52
|
-
|
|
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(
|
|
55
|
-
t.get(e)?.delete(
|
|
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) => (
|
|
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 =
|
|
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
|
-
|
|
78
|
+
y as t
|
|
76
79
|
};
|