@useago/sdk 1.0.1 → 1.0.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/CHANGELOG.md +44 -0
- package/README.md +1 -1
- package/dist/{AgoClient-CZYNL25R.js → AgoClient-CBLJfu90.js} +173 -142
- package/dist/AgoClient-nYVPdI5x.cjs +6 -0
- package/dist/angular.cjs +1 -1
- package/dist/angular.d.cts +50 -7
- package/dist/angular.d.ts +50 -7
- package/dist/angular.js +1 -1
- package/dist/{createConversationSession-BLZvXMmM.cjs → createConversationSession-CnIchjFa.cjs} +1 -1
- package/dist/{createConversationSession-Bmqj2rSS.js → createConversationSession-D3aHSSir.js} +1 -1
- package/dist/createFormCollector-CQKfRjfj.cjs +1 -0
- package/dist/{createFormCollector-Bk0DRhUf.js → createFormCollector-CyD7KnjG.js} +2 -2
- package/dist/devtools.d.cts +50 -7
- package/dist/devtools.d.ts +50 -7
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +87 -10
- package/dist/index.d.ts +87 -10
- package/dist/index.js +60 -59
- package/dist/react.cjs +19 -19
- package/dist/react.d.cts +59 -13
- package/dist/react.d.ts +59 -13
- package/dist/react.js +1268 -1275
- package/dist/testing.d.cts +50 -7
- package/dist/testing.d.ts +50 -7
- package/dist/vue.cjs +1 -1
- package/dist/vue.d.cts +50 -7
- package/dist/vue.d.ts +50 -7
- package/dist/vue.js +1 -1
- package/dist/widget.cjs +4 -4
- package/dist/widget.d.cts +51 -8
- package/dist/widget.d.ts +51 -8
- package/dist/widget.js +194 -201
- package/package.json +2 -2
- package/dist/AgoClient-0x2Du_62.cjs +0 -6
- package/dist/createFormCollector-Ca8wRrxc.cjs +0 -1
package/dist/react.d.cts
CHANGED
|
@@ -18,12 +18,26 @@ declare class AgoClient {
|
|
|
18
18
|
private contextRegistry;
|
|
19
19
|
private eventEmitter;
|
|
20
20
|
private config;
|
|
21
|
+
/** Conversations already warned about an empty reply (one warning each). */
|
|
22
|
+
private warnedEmptyConversations;
|
|
21
23
|
constructor(config: AgoConfig);
|
|
22
24
|
/**
|
|
23
25
|
* Send a message and receive a streaming response
|
|
24
26
|
*/
|
|
25
27
|
sendMessage(content: string, options?: SendMessageOptions): Promise<AgoMessage>;
|
|
26
28
|
private processSSEResponse;
|
|
29
|
+
/**
|
|
30
|
+
* Detect a reply that completed as DONE with no content and no activity —
|
|
31
|
+
* today's backend answers an unknown `agent` slug with an empty 200, which
|
|
32
|
+
* otherwise fails silently. Emits `message:empty` (always) and warns on the
|
|
33
|
+
* console once per conversation (unless `warnOnEmptyReply: false`).
|
|
34
|
+
*
|
|
35
|
+
* Deferred with setTimeout(0) so both land AFTER `sendMessage` resolves:
|
|
36
|
+
* `await client.sendMessage(...)` followed by `client.waitFor("message:empty")`
|
|
37
|
+
* must not race. TEMPORARY heuristic: remove once the backend returns an
|
|
38
|
+
* explicit error for unknown agents (see TODOS.md, backend issue).
|
|
39
|
+
*/
|
|
40
|
+
private maybeFlagEmptyReply;
|
|
27
41
|
private handleClientFunctionInvocation;
|
|
28
42
|
/**
|
|
29
43
|
* Get list of conversations
|
|
@@ -66,10 +80,11 @@ declare class AgoClient {
|
|
|
66
80
|
* Relay a completed form collector's values to a server-configured destination.
|
|
67
81
|
*
|
|
68
82
|
* Used by `createFormCollector` / `useFormCollector` in `{ via: "backend" }` mode:
|
|
69
|
-
* the browser never holds the destination URL or its secret — the backend
|
|
70
|
-
*
|
|
83
|
+
* the browser never holds the destination name, URL, or its secret — the backend
|
|
84
|
+
* resolves the destination from the named form's stored definition and forwards
|
|
85
|
+
* the values from the server.
|
|
71
86
|
*/
|
|
72
|
-
submitFormCollector(
|
|
87
|
+
submitFormCollector(name: string, values: Record<string, unknown>): Promise<unknown>;
|
|
73
88
|
/**
|
|
74
89
|
* Submit feedback for a message
|
|
75
90
|
*/
|
|
@@ -196,6 +211,11 @@ declare class AgoClient {
|
|
|
196
211
|
}): Promise<AgoClientEvents[K]>;
|
|
197
212
|
/**
|
|
198
213
|
* Update client configuration
|
|
214
|
+
*
|
|
215
|
+
* Validates the MERGED config before committing: omitting a key (or passing
|
|
216
|
+
* it as `undefined`, common with spread-built partials) keeps the current
|
|
217
|
+
* value; an explicit empty/non-string `baseUrl` throws `config_missing_base_url`
|
|
218
|
+
* and leaves the client unchanged (no half-updated state).
|
|
199
219
|
*/
|
|
200
220
|
updateConfig(config: Partial<AgoConfig>): void;
|
|
201
221
|
/**
|
|
@@ -231,8 +251,23 @@ declare interface AgoClientEvents {
|
|
|
231
251
|
*/
|
|
232
252
|
"message:answer-complete": AgoMessage;
|
|
233
253
|
"message:complete": AgoMessage;
|
|
254
|
+
/**
|
|
255
|
+
* A reply finished as `DONE` with empty content and no tool calls, client
|
|
256
|
+
* functions, or follow-up replies — usually an unknown `agent` slug (the
|
|
257
|
+
* backend currently answers those with an empty 200). Fires after
|
|
258
|
+
* `message:complete` AND after `sendMessage` resolves, so subscribing right
|
|
259
|
+
* after `await sendMessage(...)` still catches it. `messageId` and
|
|
260
|
+
* `conversationId` are empty strings when the stream completed without any
|
|
261
|
+
* message data at all (e.g. a proxy stripped the SSE stream).
|
|
262
|
+
*/
|
|
263
|
+
"message:empty": {
|
|
264
|
+
conversationId: string;
|
|
265
|
+
messageId: string;
|
|
266
|
+
};
|
|
234
267
|
"message:error": {
|
|
235
268
|
error: string;
|
|
269
|
+
/** Stable error code (see configuration.md#error-codes) when the failure was an AgoError. */
|
|
270
|
+
code?: string;
|
|
236
271
|
conversationId?: string;
|
|
237
272
|
messageId?: string;
|
|
238
273
|
};
|
|
@@ -261,7 +296,7 @@ declare interface AgoClientEvents {
|
|
|
261
296
|
export declare interface AgoConfig {
|
|
262
297
|
/** API base URL (e.g., https://YOUR-DOMAIN.useago.com) */
|
|
263
298
|
baseUrl: string;
|
|
264
|
-
/**
|
|
299
|
+
/** Per-visitor anonymous ID (X-User-Anon-Id header). Auto-generated if not provided. */
|
|
265
300
|
widgetId?: string;
|
|
266
301
|
/** Default agent (id or slug) for new conversations. Shorthand for `defaultAgentId`. */
|
|
267
302
|
agent?: string;
|
|
@@ -275,6 +310,13 @@ export declare interface AgoConfig {
|
|
|
275
310
|
userJwt?: string;
|
|
276
311
|
/** Enable debug logging */
|
|
277
312
|
debug?: boolean;
|
|
313
|
+
/**
|
|
314
|
+
* Warn on the console when a reply completes with empty content and no tool
|
|
315
|
+
* calls (the usual cause is an unknown `agent` slug, which the backend
|
|
316
|
+
* currently answers with an empty 200). Default `true`. The `message:empty`
|
|
317
|
+
* event fires regardless of this setting.
|
|
318
|
+
*/
|
|
319
|
+
warnOnEmptyReply?: boolean;
|
|
278
320
|
}
|
|
279
321
|
|
|
280
322
|
/**
|
|
@@ -757,12 +799,6 @@ export declare interface MessageProps {
|
|
|
757
799
|
* render on the last message. Defaults to `false`.
|
|
758
800
|
*/
|
|
759
801
|
isLast?: boolean;
|
|
760
|
-
/**
|
|
761
|
-
* The main answer is done but its follow-up replies are still being generated.
|
|
762
|
-
* On the last message this renders the "..." indicator in the follow-up slot
|
|
763
|
-
* until the suggestions arrive. Defaults to `false`.
|
|
764
|
-
*/
|
|
765
|
-
isAwaitingFollowUps?: boolean;
|
|
766
802
|
/**
|
|
767
803
|
* Called when the user clicks a suggested follow-up reply. When omitted the
|
|
768
804
|
* follow-up buttons render but are not interactive (backwards-compatible).
|
|
@@ -841,8 +877,9 @@ declare interface Store<T> {
|
|
|
841
877
|
* POSTs the values to that URL.
|
|
842
878
|
* - `{ via: "client", url }` — same, written out.
|
|
843
879
|
* - `{ via: "client", handler }` — the browser runs your own submit logic.
|
|
844
|
-
* - `{ via: "backend"
|
|
845
|
-
*
|
|
880
|
+
* - `{ via: "backend" }` — the browser relays the values to the backend, which resolves
|
|
881
|
+
* the destination from the form's backend-stored definition (name, URL and secret all
|
|
882
|
+
* stay server-side). `destination` is deprecated and ignored.
|
|
846
883
|
* - `false` — collect only, no submit function.
|
|
847
884
|
*/
|
|
848
885
|
export declare type SubmitConfig<V = Record<string, unknown>> = string | {
|
|
@@ -853,7 +890,7 @@ export declare type SubmitConfig<V = Record<string, unknown>> = string | {
|
|
|
853
890
|
handler: (values: V) => Promise<unknown> | unknown;
|
|
854
891
|
} | {
|
|
855
892
|
via: "backend";
|
|
856
|
-
destination
|
|
893
|
+
destination?: string;
|
|
857
894
|
} | false;
|
|
858
895
|
|
|
859
896
|
/**
|
|
@@ -876,9 +913,18 @@ declare type ToolCallType = "form" | "confirmation_input" | "status_message" | "
|
|
|
876
913
|
|
|
877
914
|
/**
|
|
878
915
|
* Hook to create and manage an AgoClient instance
|
|
916
|
+
*
|
|
917
|
+
* Pass `null` to skip client creation entirely (used by `AgoProvider` when an
|
|
918
|
+
* external client is supplied — constructing a throwaway client would waste
|
|
919
|
+
* resources and fail `baseUrl` validation).
|
|
879
920
|
*/
|
|
880
921
|
export declare function useAgo(config: UseAgoOptions): UseAgoResult;
|
|
881
922
|
|
|
923
|
+
export declare function useAgo(config: UseAgoOptions | null): {
|
|
924
|
+
client: AgoClient | null;
|
|
925
|
+
isReady: boolean;
|
|
926
|
+
};
|
|
927
|
+
|
|
882
928
|
/**
|
|
883
929
|
* Returns the AgoClient from the nearest AgoProvider.
|
|
884
930
|
* Throws if used outside of an AgoProvider.
|
package/dist/react.d.ts
CHANGED
|
@@ -18,12 +18,26 @@ declare class AgoClient {
|
|
|
18
18
|
private contextRegistry;
|
|
19
19
|
private eventEmitter;
|
|
20
20
|
private config;
|
|
21
|
+
/** Conversations already warned about an empty reply (one warning each). */
|
|
22
|
+
private warnedEmptyConversations;
|
|
21
23
|
constructor(config: AgoConfig);
|
|
22
24
|
/**
|
|
23
25
|
* Send a message and receive a streaming response
|
|
24
26
|
*/
|
|
25
27
|
sendMessage(content: string, options?: SendMessageOptions): Promise<AgoMessage>;
|
|
26
28
|
private processSSEResponse;
|
|
29
|
+
/**
|
|
30
|
+
* Detect a reply that completed as DONE with no content and no activity —
|
|
31
|
+
* today's backend answers an unknown `agent` slug with an empty 200, which
|
|
32
|
+
* otherwise fails silently. Emits `message:empty` (always) and warns on the
|
|
33
|
+
* console once per conversation (unless `warnOnEmptyReply: false`).
|
|
34
|
+
*
|
|
35
|
+
* Deferred with setTimeout(0) so both land AFTER `sendMessage` resolves:
|
|
36
|
+
* `await client.sendMessage(...)` followed by `client.waitFor("message:empty")`
|
|
37
|
+
* must not race. TEMPORARY heuristic: remove once the backend returns an
|
|
38
|
+
* explicit error for unknown agents (see TODOS.md, backend issue).
|
|
39
|
+
*/
|
|
40
|
+
private maybeFlagEmptyReply;
|
|
27
41
|
private handleClientFunctionInvocation;
|
|
28
42
|
/**
|
|
29
43
|
* Get list of conversations
|
|
@@ -66,10 +80,11 @@ declare class AgoClient {
|
|
|
66
80
|
* Relay a completed form collector's values to a server-configured destination.
|
|
67
81
|
*
|
|
68
82
|
* Used by `createFormCollector` / `useFormCollector` in `{ via: "backend" }` mode:
|
|
69
|
-
* the browser never holds the destination URL or its secret — the backend
|
|
70
|
-
*
|
|
83
|
+
* the browser never holds the destination name, URL, or its secret — the backend
|
|
84
|
+
* resolves the destination from the named form's stored definition and forwards
|
|
85
|
+
* the values from the server.
|
|
71
86
|
*/
|
|
72
|
-
submitFormCollector(
|
|
87
|
+
submitFormCollector(name: string, values: Record<string, unknown>): Promise<unknown>;
|
|
73
88
|
/**
|
|
74
89
|
* Submit feedback for a message
|
|
75
90
|
*/
|
|
@@ -196,6 +211,11 @@ declare class AgoClient {
|
|
|
196
211
|
}): Promise<AgoClientEvents[K]>;
|
|
197
212
|
/**
|
|
198
213
|
* Update client configuration
|
|
214
|
+
*
|
|
215
|
+
* Validates the MERGED config before committing: omitting a key (or passing
|
|
216
|
+
* it as `undefined`, common with spread-built partials) keeps the current
|
|
217
|
+
* value; an explicit empty/non-string `baseUrl` throws `config_missing_base_url`
|
|
218
|
+
* and leaves the client unchanged (no half-updated state).
|
|
199
219
|
*/
|
|
200
220
|
updateConfig(config: Partial<AgoConfig>): void;
|
|
201
221
|
/**
|
|
@@ -231,8 +251,23 @@ declare interface AgoClientEvents {
|
|
|
231
251
|
*/
|
|
232
252
|
"message:answer-complete": AgoMessage;
|
|
233
253
|
"message:complete": AgoMessage;
|
|
254
|
+
/**
|
|
255
|
+
* A reply finished as `DONE` with empty content and no tool calls, client
|
|
256
|
+
* functions, or follow-up replies — usually an unknown `agent` slug (the
|
|
257
|
+
* backend currently answers those with an empty 200). Fires after
|
|
258
|
+
* `message:complete` AND after `sendMessage` resolves, so subscribing right
|
|
259
|
+
* after `await sendMessage(...)` still catches it. `messageId` and
|
|
260
|
+
* `conversationId` are empty strings when the stream completed without any
|
|
261
|
+
* message data at all (e.g. a proxy stripped the SSE stream).
|
|
262
|
+
*/
|
|
263
|
+
"message:empty": {
|
|
264
|
+
conversationId: string;
|
|
265
|
+
messageId: string;
|
|
266
|
+
};
|
|
234
267
|
"message:error": {
|
|
235
268
|
error: string;
|
|
269
|
+
/** Stable error code (see configuration.md#error-codes) when the failure was an AgoError. */
|
|
270
|
+
code?: string;
|
|
236
271
|
conversationId?: string;
|
|
237
272
|
messageId?: string;
|
|
238
273
|
};
|
|
@@ -261,7 +296,7 @@ declare interface AgoClientEvents {
|
|
|
261
296
|
export declare interface AgoConfig {
|
|
262
297
|
/** API base URL (e.g., https://YOUR-DOMAIN.useago.com) */
|
|
263
298
|
baseUrl: string;
|
|
264
|
-
/**
|
|
299
|
+
/** Per-visitor anonymous ID (X-User-Anon-Id header). Auto-generated if not provided. */
|
|
265
300
|
widgetId?: string;
|
|
266
301
|
/** Default agent (id or slug) for new conversations. Shorthand for `defaultAgentId`. */
|
|
267
302
|
agent?: string;
|
|
@@ -275,6 +310,13 @@ export declare interface AgoConfig {
|
|
|
275
310
|
userJwt?: string;
|
|
276
311
|
/** Enable debug logging */
|
|
277
312
|
debug?: boolean;
|
|
313
|
+
/**
|
|
314
|
+
* Warn on the console when a reply completes with empty content and no tool
|
|
315
|
+
* calls (the usual cause is an unknown `agent` slug, which the backend
|
|
316
|
+
* currently answers with an empty 200). Default `true`. The `message:empty`
|
|
317
|
+
* event fires regardless of this setting.
|
|
318
|
+
*/
|
|
319
|
+
warnOnEmptyReply?: boolean;
|
|
278
320
|
}
|
|
279
321
|
|
|
280
322
|
/**
|
|
@@ -757,12 +799,6 @@ export declare interface MessageProps {
|
|
|
757
799
|
* render on the last message. Defaults to `false`.
|
|
758
800
|
*/
|
|
759
801
|
isLast?: boolean;
|
|
760
|
-
/**
|
|
761
|
-
* The main answer is done but its follow-up replies are still being generated.
|
|
762
|
-
* On the last message this renders the "..." indicator in the follow-up slot
|
|
763
|
-
* until the suggestions arrive. Defaults to `false`.
|
|
764
|
-
*/
|
|
765
|
-
isAwaitingFollowUps?: boolean;
|
|
766
802
|
/**
|
|
767
803
|
* Called when the user clicks a suggested follow-up reply. When omitted the
|
|
768
804
|
* follow-up buttons render but are not interactive (backwards-compatible).
|
|
@@ -841,8 +877,9 @@ declare interface Store<T> {
|
|
|
841
877
|
* POSTs the values to that URL.
|
|
842
878
|
* - `{ via: "client", url }` — same, written out.
|
|
843
879
|
* - `{ via: "client", handler }` — the browser runs your own submit logic.
|
|
844
|
-
* - `{ via: "backend"
|
|
845
|
-
*
|
|
880
|
+
* - `{ via: "backend" }` — the browser relays the values to the backend, which resolves
|
|
881
|
+
* the destination from the form's backend-stored definition (name, URL and secret all
|
|
882
|
+
* stay server-side). `destination` is deprecated and ignored.
|
|
846
883
|
* - `false` — collect only, no submit function.
|
|
847
884
|
*/
|
|
848
885
|
export declare type SubmitConfig<V = Record<string, unknown>> = string | {
|
|
@@ -853,7 +890,7 @@ export declare type SubmitConfig<V = Record<string, unknown>> = string | {
|
|
|
853
890
|
handler: (values: V) => Promise<unknown> | unknown;
|
|
854
891
|
} | {
|
|
855
892
|
via: "backend";
|
|
856
|
-
destination
|
|
893
|
+
destination?: string;
|
|
857
894
|
} | false;
|
|
858
895
|
|
|
859
896
|
/**
|
|
@@ -876,9 +913,18 @@ declare type ToolCallType = "form" | "confirmation_input" | "status_message" | "
|
|
|
876
913
|
|
|
877
914
|
/**
|
|
878
915
|
* Hook to create and manage an AgoClient instance
|
|
916
|
+
*
|
|
917
|
+
* Pass `null` to skip client creation entirely (used by `AgoProvider` when an
|
|
918
|
+
* external client is supplied — constructing a throwaway client would waste
|
|
919
|
+
* resources and fail `baseUrl` validation).
|
|
879
920
|
*/
|
|
880
921
|
export declare function useAgo(config: UseAgoOptions): UseAgoResult;
|
|
881
922
|
|
|
923
|
+
export declare function useAgo(config: UseAgoOptions | null): {
|
|
924
|
+
client: AgoClient | null;
|
|
925
|
+
isReady: boolean;
|
|
926
|
+
};
|
|
927
|
+
|
|
882
928
|
/**
|
|
883
929
|
* Returns the AgoClient from the nearest AgoProvider.
|
|
884
930
|
* Throws if used outside of an AgoProvider.
|