@useago/sdk 1.0.1 → 1.0.2

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/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
@@ -196,6 +210,11 @@ declare class AgoClient {
196
210
  }): Promise<AgoClientEvents[K]>;
197
211
  /**
198
212
  * Update client configuration
213
+ *
214
+ * Validates the MERGED config before committing: omitting a key (or passing
215
+ * it as `undefined`, common with spread-built partials) keeps the current
216
+ * value; an explicit empty/non-string `baseUrl` throws `config_missing_base_url`
217
+ * and leaves the client unchanged (no half-updated state).
199
218
  */
200
219
  updateConfig(config: Partial<AgoConfig>): void;
201
220
  /**
@@ -231,8 +250,23 @@ declare interface AgoClientEvents {
231
250
  */
232
251
  "message:answer-complete": AgoMessage;
233
252
  "message:complete": AgoMessage;
253
+ /**
254
+ * A reply finished as `DONE` with empty content and no tool calls, client
255
+ * functions, or follow-up replies — usually an unknown `agent` slug (the
256
+ * backend currently answers those with an empty 200). Fires after
257
+ * `message:complete` AND after `sendMessage` resolves, so subscribing right
258
+ * after `await sendMessage(...)` still catches it. `messageId` and
259
+ * `conversationId` are empty strings when the stream completed without any
260
+ * message data at all (e.g. a proxy stripped the SSE stream).
261
+ */
262
+ "message:empty": {
263
+ conversationId: string;
264
+ messageId: string;
265
+ };
234
266
  "message:error": {
235
267
  error: string;
268
+ /** Stable error code (see configuration.md#error-codes) when the failure was an AgoError. */
269
+ code?: string;
236
270
  conversationId?: string;
237
271
  messageId?: string;
238
272
  };
@@ -261,7 +295,7 @@ declare interface AgoClientEvents {
261
295
  export declare interface AgoConfig {
262
296
  /** API base URL (e.g., https://YOUR-DOMAIN.useago.com) */
263
297
  baseUrl: string;
264
- /** Widget ID (X-Widget-Id header). Auto-generated if not provided. */
298
+ /** Per-visitor anonymous ID (X-User-Anon-Id header). Auto-generated if not provided. */
265
299
  widgetId?: string;
266
300
  /** Default agent (id or slug) for new conversations. Shorthand for `defaultAgentId`. */
267
301
  agent?: string;
@@ -275,6 +309,13 @@ export declare interface AgoConfig {
275
309
  userJwt?: string;
276
310
  /** Enable debug logging */
277
311
  debug?: boolean;
312
+ /**
313
+ * Warn on the console when a reply completes with empty content and no tool
314
+ * calls (the usual cause is an unknown `agent` slug, which the backend
315
+ * currently answers with an empty 200). Default `true`. The `message:empty`
316
+ * event fires regardless of this setting.
317
+ */
318
+ warnOnEmptyReply?: boolean;
278
319
  }
279
320
 
280
321
  /**
@@ -757,12 +798,6 @@ export declare interface MessageProps {
757
798
  * render on the last message. Defaults to `false`.
758
799
  */
759
800
  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
801
  /**
767
802
  * Called when the user clicks a suggested follow-up reply. When omitted the
768
803
  * follow-up buttons render but are not interactive (backwards-compatible).
@@ -876,9 +911,18 @@ declare type ToolCallType = "form" | "confirmation_input" | "status_message" | "
876
911
 
877
912
  /**
878
913
  * Hook to create and manage an AgoClient instance
914
+ *
915
+ * Pass `null` to skip client creation entirely (used by `AgoProvider` when an
916
+ * external client is supplied — constructing a throwaway client would waste
917
+ * resources and fail `baseUrl` validation).
879
918
  */
880
919
  export declare function useAgo(config: UseAgoOptions): UseAgoResult;
881
920
 
921
+ export declare function useAgo(config: UseAgoOptions | null): {
922
+ client: AgoClient | null;
923
+ isReady: boolean;
924
+ };
925
+
882
926
  /**
883
927
  * Returns the AgoClient from the nearest AgoProvider.
884
928
  * 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
@@ -196,6 +210,11 @@ declare class AgoClient {
196
210
  }): Promise<AgoClientEvents[K]>;
197
211
  /**
198
212
  * Update client configuration
213
+ *
214
+ * Validates the MERGED config before committing: omitting a key (or passing
215
+ * it as `undefined`, common with spread-built partials) keeps the current
216
+ * value; an explicit empty/non-string `baseUrl` throws `config_missing_base_url`
217
+ * and leaves the client unchanged (no half-updated state).
199
218
  */
200
219
  updateConfig(config: Partial<AgoConfig>): void;
201
220
  /**
@@ -231,8 +250,23 @@ declare interface AgoClientEvents {
231
250
  */
232
251
  "message:answer-complete": AgoMessage;
233
252
  "message:complete": AgoMessage;
253
+ /**
254
+ * A reply finished as `DONE` with empty content and no tool calls, client
255
+ * functions, or follow-up replies — usually an unknown `agent` slug (the
256
+ * backend currently answers those with an empty 200). Fires after
257
+ * `message:complete` AND after `sendMessage` resolves, so subscribing right
258
+ * after `await sendMessage(...)` still catches it. `messageId` and
259
+ * `conversationId` are empty strings when the stream completed without any
260
+ * message data at all (e.g. a proxy stripped the SSE stream).
261
+ */
262
+ "message:empty": {
263
+ conversationId: string;
264
+ messageId: string;
265
+ };
234
266
  "message:error": {
235
267
  error: string;
268
+ /** Stable error code (see configuration.md#error-codes) when the failure was an AgoError. */
269
+ code?: string;
236
270
  conversationId?: string;
237
271
  messageId?: string;
238
272
  };
@@ -261,7 +295,7 @@ declare interface AgoClientEvents {
261
295
  export declare interface AgoConfig {
262
296
  /** API base URL (e.g., https://YOUR-DOMAIN.useago.com) */
263
297
  baseUrl: string;
264
- /** Widget ID (X-Widget-Id header). Auto-generated if not provided. */
298
+ /** Per-visitor anonymous ID (X-User-Anon-Id header). Auto-generated if not provided. */
265
299
  widgetId?: string;
266
300
  /** Default agent (id or slug) for new conversations. Shorthand for `defaultAgentId`. */
267
301
  agent?: string;
@@ -275,6 +309,13 @@ export declare interface AgoConfig {
275
309
  userJwt?: string;
276
310
  /** Enable debug logging */
277
311
  debug?: boolean;
312
+ /**
313
+ * Warn on the console when a reply completes with empty content and no tool
314
+ * calls (the usual cause is an unknown `agent` slug, which the backend
315
+ * currently answers with an empty 200). Default `true`. The `message:empty`
316
+ * event fires regardless of this setting.
317
+ */
318
+ warnOnEmptyReply?: boolean;
278
319
  }
279
320
 
280
321
  /**
@@ -757,12 +798,6 @@ export declare interface MessageProps {
757
798
  * render on the last message. Defaults to `false`.
758
799
  */
759
800
  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
801
  /**
767
802
  * Called when the user clicks a suggested follow-up reply. When omitted the
768
803
  * follow-up buttons render but are not interactive (backwards-compatible).
@@ -876,9 +911,18 @@ declare type ToolCallType = "form" | "confirmation_input" | "status_message" | "
876
911
 
877
912
  /**
878
913
  * Hook to create and manage an AgoClient instance
914
+ *
915
+ * Pass `null` to skip client creation entirely (used by `AgoProvider` when an
916
+ * external client is supplied — constructing a throwaway client would waste
917
+ * resources and fail `baseUrl` validation).
879
918
  */
880
919
  export declare function useAgo(config: UseAgoOptions): UseAgoResult;
881
920
 
921
+ export declare function useAgo(config: UseAgoOptions | null): {
922
+ client: AgoClient | null;
923
+ isReady: boolean;
924
+ };
925
+
882
926
  /**
883
927
  * Returns the AgoClient from the nearest AgoProvider.
884
928
  * Throws if used outside of an AgoProvider.