@useago/sdk 1.3.1 → 1.4.0

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.ts CHANGED
@@ -30,6 +30,23 @@ declare interface AgoAttachment {
30
30
  isSafeImage: boolean;
31
31
  }
32
32
 
33
+ export declare interface AgoAutoContinueOptions {
34
+ /** Function names whose invocation counts as "navigated". Default `["navigateToPage"]`. */
35
+ navigationFunctions?: string[];
36
+ /** Registered function that signals the destination has editable state. Default `"setPageState"`. */
37
+ pageStateFunctionName?: string;
38
+ /** The hidden continuation prompt. Override for i18n / tone. */
39
+ continuationPrompt?: string;
40
+ /** Max continuations per user gesture (guards navigate→continue→navigate loops). Default `1`. */
41
+ maxDepth?: number;
42
+ /** How long to wait for the destination page to register page-state before giving up. Default `4000`ms. */
43
+ readinessTimeoutMs?: number;
44
+ /** Extra settle delay after page-state appears, to let sibling state mount. Default `150`ms. */
45
+ settleMs?: number;
46
+ /** Opt-out escape hatch. Default `true`. */
47
+ enabled?: boolean;
48
+ }
49
+
33
50
  /**
34
51
  * Main SDK client for AGO Chat integration
35
52
  */
@@ -156,6 +173,37 @@ declare class AgoClient {
156
173
  path: string;
157
174
  description: string;
158
175
  }>): void;
176
+ /**
177
+ * Register a "page state" function that lets AGO change the current page's
178
+ * state (filters, sort, view mode, selection…) and reads the current state
179
+ * back as dynamic context. This is the state-mutation mirror of
180
+ * {@link registerNavigationFunction}.
181
+ *
182
+ * It does two things:
183
+ * - Synthesizes ONE client function (default name `setPageState`) whose
184
+ * properties are the controls — all optional, so the agent sets only the
185
+ * ones the user asked for.
186
+ * - Registers a dynamic context provider (keyed `page-state:<fnName>`) that
187
+ * reports each control's current `get()` value on every message.
188
+ *
189
+ * ```ts
190
+ * client.registerPageStateFunction([
191
+ * {
192
+ * name: "statusFilter",
193
+ * description: "Filter the list by review status",
194
+ * schema: { type: "string", enum: ["all", "pending", "approved"] },
195
+ * get: () => filters.status,
196
+ * set: (v) => setFilters({ ...filters, status: v }),
197
+ * },
198
+ * ]);
199
+ * ```
200
+ */
201
+ registerPageStateFunction(controls: AgoStateControl[], opts?: AgoPageStateOptions): void;
202
+ /**
203
+ * Unregister a page state function and its dynamic context provider.
204
+ * Mirror of unregistering `navigateToPage`.
205
+ */
206
+ unregisterPageStateFunction(functionName?: string): void;
159
207
  /**
160
208
  * Register or update a piece of client-side context.
161
209
  * This context is sent with every message so the AI understands the user's situation.
@@ -401,9 +449,23 @@ export declare interface AgoMessage {
401
449
  followUpReplies?: string[];
402
450
  /** Uploaded files on this message (usually the user's). */
403
451
  attachments?: AgoAttachment[];
452
+ /**
453
+ * True when the backend flagged this message as hidden (e.g. an
454
+ * auto-continuation nudge). Kept in the model's context but not displayed;
455
+ * UI helpers like `useMessages`/`ChatWidget` filter these out.
456
+ */
457
+ hidden?: boolean;
404
458
  createdAt: Date;
405
459
  }
406
460
 
461
+ /**
462
+ * Options for {@link AgoClient.registerPageStateFunction}.
463
+ */
464
+ export declare interface AgoPageStateOptions {
465
+ /** Name of the synthesized client function. Defaults to "setPageState". */
466
+ functionName?: string;
467
+ }
468
+
407
469
  /**
408
470
  * Provides an AgoClient to all descendant components via React context.
409
471
  *
@@ -457,6 +519,32 @@ export declare interface AgoSource {
457
519
  url?: string;
458
520
  }
459
521
 
522
+ /**
523
+ * A single editable control on the current page (a filter, a sort, a view mode,
524
+ * a selection…). It becomes one optional property of the synthesized
525
+ * `setPageState` function, and its current value is surfaced back to the agent
526
+ * as dynamic context. This is the state-mutation mirror of a navigation route.
527
+ */
528
+ export declare interface AgoStateControl<T = unknown> {
529
+ /** Machine name of the control, e.g. "statusFilter". Becomes a property of the tool. */
530
+ name: string;
531
+ /** Description for the LLM, e.g. "Filter the list by review status". */
532
+ description: string;
533
+ /** JSON schema for a SINGLE field (like one property of navigateToPage). */
534
+ schema: {
535
+ type: "string" | "number" | "boolean" | "array";
536
+ enum?: (string | number)[];
537
+ items?: {
538
+ type: string;
539
+ enum?: (string | number)[];
540
+ };
541
+ };
542
+ /** Current value → pushed as dynamic context so the agent knows what to change. */
543
+ get?: () => T;
544
+ /** Apply the state change on the page. May be async. */
545
+ set: (value: T) => void | Promise<void>;
546
+ }
547
+
460
548
  /**
461
549
  * Chat input component with send button
462
550
  */
@@ -566,7 +654,11 @@ declare interface ClientFunctionSchema {
566
654
  properties: Record<string, {
567
655
  type: string;
568
656
  description?: string;
569
- enum?: string[];
657
+ enum?: (string | number)[];
658
+ items?: {
659
+ type: string;
660
+ enum?: (string | number)[];
661
+ };
570
662
  default?: unknown;
571
663
  }>;
572
664
  required?: string[];
@@ -935,6 +1027,13 @@ declare interface SendMessageOptions {
935
1027
  agentId?: string;
936
1028
  /** File attachments */
937
1029
  files?: File[];
1030
+ /**
1031
+ * Mark this message as hidden. The backend keeps it in the model's context but
1032
+ * flags it so the UI never displays it. Used by auto-continuation to nudge the
1033
+ * agent after a navigation without polluting the visible transcript.
1034
+ * Requires backend support for the `hidden` flag; older backends ignore it.
1035
+ */
1036
+ hidden?: boolean;
938
1037
  }
939
1038
 
940
1039
  /**
@@ -1053,6 +1152,27 @@ export declare function useAgo(config: UseAgoOptions | null): {
1053
1152
  isReady: boolean;
1054
1153
  };
1055
1154
 
1155
+ /**
1156
+ * Auto-continue the agent after it navigates, so a "go to page B and change X"
1157
+ * request completes in one user gesture. Mount this once inside `AgoProvider`.
1158
+ *
1159
+ * How it works: when the agent calls the navigation function and that turn ends,
1160
+ * this waits for the destination page's `useAgoPageState` to register (so the
1161
+ * SDK will ship its `setPageState` + current state on the next send), then sends
1162
+ * a hidden continuation message. The agent then applies the state in a second
1163
+ * turn. The continuation is `hidden`, so it never shows in the transcript
1164
+ * (requires backend support for the `hidden` flag).
1165
+ *
1166
+ * ```tsx
1167
+ * function AppShell() {
1168
+ * useAgoNavigation(navigate, routes);
1169
+ * useAgoAutoContinueAfterNavigation();
1170
+ * return <Outlet />;
1171
+ * }
1172
+ * ```
1173
+ */
1174
+ export declare function useAgoAutoContinueAfterNavigation(options?: AgoAutoContinueOptions): void;
1175
+
1056
1176
  /**
1057
1177
  * Returns the AgoClient from the nearest AgoProvider.
1058
1178
  * Throws if used outside of an AgoProvider.
@@ -1134,7 +1254,11 @@ export declare interface UseAgoFunctionOptions {
1134
1254
  properties: Record<string, {
1135
1255
  type: string;
1136
1256
  description?: string;
1137
- enum?: string[];
1257
+ enum?: (string | number)[];
1258
+ items?: {
1259
+ type: string;
1260
+ enum?: (string | number)[];
1261
+ };
1138
1262
  default?: unknown;
1139
1263
  }>;
1140
1264
  required?: string[];
@@ -1158,6 +1282,28 @@ export declare function useAgoNavigation(navigate: (path: string) => void, route
1158
1282
 
1159
1283
  export declare type UseAgoOptions = AgoConfig;
1160
1284
 
1285
+ /**
1286
+ * Declaratively register editable page-state controls with the AGO agent.
1287
+ * The state-mutation mirror of `useAgoNavigation`: it wraps
1288
+ * `registerPageStateFunction` with React lifecycle management, so the agent can
1289
+ * change the current page's state (filters, sort, view mode…) and read the
1290
+ * current state back.
1291
+ *
1292
+ * ```tsx
1293
+ * const [status, setStatus] = useState("all");
1294
+ * useAgoPageState([
1295
+ * {
1296
+ * name: "statusFilter",
1297
+ * description: "Filter the list by review status",
1298
+ * schema: { type: "string", enum: ["all", "pending", "approved"] },
1299
+ * get: () => status,
1300
+ * set: setStatus,
1301
+ * },
1302
+ * ]);
1303
+ * ```
1304
+ */
1305
+ export declare function useAgoPageState(controls: AgoStateControl[], opts?: AgoPageStateOptions): void;
1306
+
1161
1307
  export declare interface UseAgoResult {
1162
1308
  /** The AGO client instance */
1163
1309
  client: AgoClient;