@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/widget.d.cts CHANGED
@@ -154,6 +154,37 @@ declare class AgoClient {
154
154
  path: string;
155
155
  description: string;
156
156
  }>): void;
157
+ /**
158
+ * Register a "page state" function that lets AGO change the current page's
159
+ * state (filters, sort, view mode, selection…) and reads the current state
160
+ * back as dynamic context. This is the state-mutation mirror of
161
+ * {@link registerNavigationFunction}.
162
+ *
163
+ * It does two things:
164
+ * - Synthesizes ONE client function (default name `setPageState`) whose
165
+ * properties are the controls — all optional, so the agent sets only the
166
+ * ones the user asked for.
167
+ * - Registers a dynamic context provider (keyed `page-state:<fnName>`) that
168
+ * reports each control's current `get()` value on every message.
169
+ *
170
+ * ```ts
171
+ * client.registerPageStateFunction([
172
+ * {
173
+ * name: "statusFilter",
174
+ * description: "Filter the list by review status",
175
+ * schema: { type: "string", enum: ["all", "pending", "approved"] },
176
+ * get: () => filters.status,
177
+ * set: (v) => setFilters({ ...filters, status: v }),
178
+ * },
179
+ * ]);
180
+ * ```
181
+ */
182
+ registerPageStateFunction(controls: AgoStateControl[], opts?: AgoPageStateOptions): void;
183
+ /**
184
+ * Unregister a page state function and its dynamic context provider.
185
+ * Mirror of unregistering `navigateToPage`.
186
+ */
187
+ unregisterPageStateFunction(functionName?: string): void;
157
188
  /**
158
189
  * Register or update a piece of client-side context.
159
190
  * This context is sent with every message so the AI understands the user's situation.
@@ -386,9 +417,23 @@ declare interface AgoMessage {
386
417
  followUpReplies?: string[];
387
418
  /** Uploaded files on this message (usually the user's). */
388
419
  attachments?: AgoAttachment[];
420
+ /**
421
+ * True when the backend flagged this message as hidden (e.g. an
422
+ * auto-continuation nudge). Kept in the model's context but not displayed;
423
+ * UI helpers like `useMessages`/`ChatWidget` filter these out.
424
+ */
425
+ hidden?: boolean;
389
426
  createdAt: Date;
390
427
  }
391
428
 
429
+ /**
430
+ * Options for {@link AgoClient.registerPageStateFunction}.
431
+ */
432
+ declare interface AgoPageStateOptions {
433
+ /** Name of the synthesized client function. Defaults to "setPageState". */
434
+ functionName?: string;
435
+ }
436
+
392
437
  /**
393
438
  * Knowledge source citation
394
439
  */
@@ -398,6 +443,32 @@ declare interface AgoSource {
398
443
  url?: string;
399
444
  }
400
445
 
446
+ /**
447
+ * A single editable control on the current page (a filter, a sort, a view mode,
448
+ * a selection…). It becomes one optional property of the synthesized
449
+ * `setPageState` function, and its current value is surfaced back to the agent
450
+ * as dynamic context. This is the state-mutation mirror of a navigation route.
451
+ */
452
+ declare interface AgoStateControl<T = unknown> {
453
+ /** Machine name of the control, e.g. "statusFilter". Becomes a property of the tool. */
454
+ name: string;
455
+ /** Description for the LLM, e.g. "Filter the list by review status". */
456
+ description: string;
457
+ /** JSON schema for a SINGLE field (like one property of navigateToPage). */
458
+ schema: {
459
+ type: "string" | "number" | "boolean" | "array";
460
+ enum?: (string | number)[];
461
+ items?: {
462
+ type: string;
463
+ enum?: (string | number)[];
464
+ };
465
+ };
466
+ /** Current value → pushed as dynamic context so the agent knows what to change. */
467
+ get?: () => T;
468
+ /** Apply the state change on the page. May be async. */
469
+ set: (value: T) => void | Promise<void>;
470
+ }
471
+
401
472
  export declare interface AgoWidgetColors {
402
473
  button?: string;
403
474
  header?: string;
@@ -507,7 +578,11 @@ declare interface ClientFunctionSchema {
507
578
  properties: Record<string, {
508
579
  type: string;
509
580
  description?: string;
510
- enum?: string[];
581
+ enum?: (string | number)[];
582
+ items?: {
583
+ type: string;
584
+ enum?: (string | number)[];
585
+ };
511
586
  default?: unknown;
512
587
  }>;
513
588
  required?: string[];
@@ -876,11 +951,13 @@ export declare interface MountChatWidgetOptions {
876
951
  /** Max viewport width (px) treated as "mobile". Defaults to `768`. */
877
952
  breakpoint?: number;
878
953
  /**
879
- * Inline placement only: how the card enters full screen. `"focus"` (default)
880
- * expands when the input is tapped/focused; `"manual"` expands only via
881
- * `widget.open()`. Ignored for side placements (driven by the launcher).
954
+ * Inline placement only: how the card enters full screen.
955
+ * - `"tap"` (default): expands when anywhere on the compact card is tapped
956
+ * - `"focus"`: expands only when the input is tapped/focused.
957
+ * - `"manual"`: expands only via `widget.open()`.
958
+ * Ignored for side placements (driven by the launcher).
882
959
  */
883
- trigger?: "focus" | "manual";
960
+ trigger?: "tap" | "focus" | "manual";
884
961
  };
885
962
  /**
886
963
  * Load the visitor's conversation list into `widget.threads` on mount and refresh
@@ -990,6 +1067,13 @@ declare interface SendMessageOptions {
990
1067
  agentId?: string;
991
1068
  /** File attachments */
992
1069
  files?: File[];
1070
+ /**
1071
+ * Mark this message as hidden. The backend keeps it in the model's context but
1072
+ * flags it so the UI never displays it. Used by auto-continuation to nudge the
1073
+ * agent after a navigation without polluting the visible transcript.
1074
+ * Requires backend support for the `hidden` flag; older backends ignore it.
1075
+ */
1076
+ hidden?: boolean;
993
1077
  }
994
1078
 
995
1079
  /**
package/dist/widget.d.ts CHANGED
@@ -154,6 +154,37 @@ declare class AgoClient {
154
154
  path: string;
155
155
  description: string;
156
156
  }>): void;
157
+ /**
158
+ * Register a "page state" function that lets AGO change the current page's
159
+ * state (filters, sort, view mode, selection…) and reads the current state
160
+ * back as dynamic context. This is the state-mutation mirror of
161
+ * {@link registerNavigationFunction}.
162
+ *
163
+ * It does two things:
164
+ * - Synthesizes ONE client function (default name `setPageState`) whose
165
+ * properties are the controls — all optional, so the agent sets only the
166
+ * ones the user asked for.
167
+ * - Registers a dynamic context provider (keyed `page-state:<fnName>`) that
168
+ * reports each control's current `get()` value on every message.
169
+ *
170
+ * ```ts
171
+ * client.registerPageStateFunction([
172
+ * {
173
+ * name: "statusFilter",
174
+ * description: "Filter the list by review status",
175
+ * schema: { type: "string", enum: ["all", "pending", "approved"] },
176
+ * get: () => filters.status,
177
+ * set: (v) => setFilters({ ...filters, status: v }),
178
+ * },
179
+ * ]);
180
+ * ```
181
+ */
182
+ registerPageStateFunction(controls: AgoStateControl[], opts?: AgoPageStateOptions): void;
183
+ /**
184
+ * Unregister a page state function and its dynamic context provider.
185
+ * Mirror of unregistering `navigateToPage`.
186
+ */
187
+ unregisterPageStateFunction(functionName?: string): void;
157
188
  /**
158
189
  * Register or update a piece of client-side context.
159
190
  * This context is sent with every message so the AI understands the user's situation.
@@ -386,9 +417,23 @@ declare interface AgoMessage {
386
417
  followUpReplies?: string[];
387
418
  /** Uploaded files on this message (usually the user's). */
388
419
  attachments?: AgoAttachment[];
420
+ /**
421
+ * True when the backend flagged this message as hidden (e.g. an
422
+ * auto-continuation nudge). Kept in the model's context but not displayed;
423
+ * UI helpers like `useMessages`/`ChatWidget` filter these out.
424
+ */
425
+ hidden?: boolean;
389
426
  createdAt: Date;
390
427
  }
391
428
 
429
+ /**
430
+ * Options for {@link AgoClient.registerPageStateFunction}.
431
+ */
432
+ declare interface AgoPageStateOptions {
433
+ /** Name of the synthesized client function. Defaults to "setPageState". */
434
+ functionName?: string;
435
+ }
436
+
392
437
  /**
393
438
  * Knowledge source citation
394
439
  */
@@ -398,6 +443,32 @@ declare interface AgoSource {
398
443
  url?: string;
399
444
  }
400
445
 
446
+ /**
447
+ * A single editable control on the current page (a filter, a sort, a view mode,
448
+ * a selection…). It becomes one optional property of the synthesized
449
+ * `setPageState` function, and its current value is surfaced back to the agent
450
+ * as dynamic context. This is the state-mutation mirror of a navigation route.
451
+ */
452
+ declare interface AgoStateControl<T = unknown> {
453
+ /** Machine name of the control, e.g. "statusFilter". Becomes a property of the tool. */
454
+ name: string;
455
+ /** Description for the LLM, e.g. "Filter the list by review status". */
456
+ description: string;
457
+ /** JSON schema for a SINGLE field (like one property of navigateToPage). */
458
+ schema: {
459
+ type: "string" | "number" | "boolean" | "array";
460
+ enum?: (string | number)[];
461
+ items?: {
462
+ type: string;
463
+ enum?: (string | number)[];
464
+ };
465
+ };
466
+ /** Current value → pushed as dynamic context so the agent knows what to change. */
467
+ get?: () => T;
468
+ /** Apply the state change on the page. May be async. */
469
+ set: (value: T) => void | Promise<void>;
470
+ }
471
+
401
472
  export declare interface AgoWidgetColors {
402
473
  button?: string;
403
474
  header?: string;
@@ -507,7 +578,11 @@ declare interface ClientFunctionSchema {
507
578
  properties: Record<string, {
508
579
  type: string;
509
580
  description?: string;
510
- enum?: string[];
581
+ enum?: (string | number)[];
582
+ items?: {
583
+ type: string;
584
+ enum?: (string | number)[];
585
+ };
511
586
  default?: unknown;
512
587
  }>;
513
588
  required?: string[];
@@ -876,11 +951,13 @@ export declare interface MountChatWidgetOptions {
876
951
  /** Max viewport width (px) treated as "mobile". Defaults to `768`. */
877
952
  breakpoint?: number;
878
953
  /**
879
- * Inline placement only: how the card enters full screen. `"focus"` (default)
880
- * expands when the input is tapped/focused; `"manual"` expands only via
881
- * `widget.open()`. Ignored for side placements (driven by the launcher).
954
+ * Inline placement only: how the card enters full screen.
955
+ * - `"tap"` (default): expands when anywhere on the compact card is tapped
956
+ * - `"focus"`: expands only when the input is tapped/focused.
957
+ * - `"manual"`: expands only via `widget.open()`.
958
+ * Ignored for side placements (driven by the launcher).
882
959
  */
883
- trigger?: "focus" | "manual";
960
+ trigger?: "tap" | "focus" | "manual";
884
961
  };
885
962
  /**
886
963
  * Load the visitor's conversation list into `widget.threads` on mount and refresh
@@ -990,6 +1067,13 @@ declare interface SendMessageOptions {
990
1067
  agentId?: string;
991
1068
  /** File attachments */
992
1069
  files?: File[];
1070
+ /**
1071
+ * Mark this message as hidden. The backend keeps it in the model's context but
1072
+ * flags it so the UI never displays it. Used by auto-continuation to nudge the
1073
+ * agent after a navigation without polluting the visible transcript.
1074
+ * Requires backend support for the `hidden` flag; older backends ignore it.
1075
+ */
1076
+ hidden?: boolean;
993
1077
  }
994
1078
 
995
1079
  /**