@useago/sdk 0.3.3 → 0.3.4

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
@@ -359,8 +359,20 @@ export declare interface ChatWidgetProps {
359
359
  height?: string | number;
360
360
  /** URL of a logo to display in the header */
361
361
  logoUrl?: string;
362
- /** Show the agent name above assistant messages. Defaults to `true`. */
362
+ /** Show the agent name above assistant messages. Defaults to `false`. */
363
363
  showAgentName?: boolean;
364
+ /**
365
+ * Conversational forms the agent can fill and submit during the chat. Each
366
+ * config is installed as a {@link createFormCollector} (its `update_<name>` /
367
+ * `submit_<name>` functions + dynamic context) for the lifetime of the widget.
368
+ */
369
+ forms?: CreateFormCollectorOptions[];
370
+ /**
371
+ * How clicking a suggested follow-up reply behaves. Defaults to sending the
372
+ * reply as a new user message. Pass a handler to override, or `false` to
373
+ * render the suggestions as non-interactive.
374
+ */
375
+ onFollowUpClick?: ((reply: string) => void) | false;
364
376
  /** Additional CSS class */
365
377
  className?: string;
366
378
  /** Callback when a message is sent */
@@ -455,7 +467,29 @@ export declare interface Conversation {
455
467
  messages?: AgoMessage[];
456
468
  }
457
469
 
458
- declare interface CreateFormCollectorOptions<V = Record<string, unknown>> {
470
+ /**
471
+ * Wire one schema into a conversational form: an observable store, an
472
+ * `update_<name>` client function the agent calls to fill fields, a dynamic-context
473
+ * provider that tells the agent what's still missing, and an optional submit.
474
+ *
475
+ * ```ts
476
+ * const order = createFormCollector({
477
+ * name: "order",
478
+ * description: "The order the user wants to place",
479
+ * schema: {
480
+ * type: "object",
481
+ * properties: { product: { type: "string" }, quantity: { type: "number" } },
482
+ * required: ["product", "quantity"],
483
+ * },
484
+ * submit: { via: "client", url: "/api/orders" },
485
+ * });
486
+ * order.install(client);
487
+ * order.store.subscribe((s) => render(s));
488
+ * ```
489
+ */
490
+ export declare function createFormCollector<V = Record<string, unknown>>(options: CreateFormCollectorOptions<V>): FormCollector<V>;
491
+
492
+ export declare interface CreateFormCollectorOptions<V = Record<string, unknown>> {
459
493
  /** Short identifier; becomes the `update_<name>` / `submit_<name>` function names. */
460
494
  name: string;
461
495
  /** What the form is, for the LLM. */
@@ -488,7 +522,7 @@ export declare function createMockClient(options?: MockAgoClientOptions): MockAg
488
522
  */
489
523
  declare type DynamicContextProvider = () => ContextEntry | null | undefined;
490
524
 
491
- declare interface FormCollector<V = Record<string, unknown>> {
525
+ export declare interface FormCollector<V = Record<string, unknown>> {
492
526
  name: string;
493
527
  /** Observable store driving the form UI (read via `useAgoStore`). */
494
528
  store: Store<FormCollectorState<V>>;
@@ -512,10 +546,10 @@ declare interface FormCollector<V = Record<string, unknown>> {
512
546
  * `parameters`, so one schema feeds the store, the update function, and the
513
547
  * dynamic context with no second type.
514
548
  */
515
- declare type FormCollectorSchema = ClientFunctionSchema["parameters"];
549
+ export declare type FormCollectorSchema = ClientFunctionSchema["parameters"];
516
550
 
517
551
  /** Live state held in the collector's store. */
518
- declare interface FormCollectorState<V = Record<string, unknown>> {
552
+ export declare interface FormCollectorState<V = Record<string, unknown>> {
519
553
  /** Field values collected so far. */
520
554
  values: Partial<V>;
521
555
  /** Required field names still empty. */
@@ -544,7 +578,7 @@ declare interface FormSchema {
544
578
  }
545
579
 
546
580
  /** Result returned by `submit()` / the generated `submit_<name>` function. */
547
- declare interface FormSubmitResult {
581
+ export declare interface FormSubmitResult {
548
582
  ok: boolean;
549
583
  missing?: string[];
550
584
  result?: unknown;
@@ -569,8 +603,13 @@ export declare const Message: default_2.FC<MessageProps>;
569
603
  export declare interface MessageProps {
570
604
  message: AgoMessage;
571
605
  className?: string;
572
- /** Show the agent name above assistant messages. Defaults to `true`. */
606
+ /** Show the agent name above assistant messages. Defaults to `false`. */
573
607
  showAgentName?: boolean;
608
+ /**
609
+ * Called when the user clicks a suggested follow-up reply. When omitted the
610
+ * follow-up buttons render but are not interactive (backwards-compatible).
611
+ */
612
+ onFollowUpClick?: (reply: string) => void;
574
613
  }
575
614
 
576
615
  declare type MessageStatus = "IN_PROGRESS" | "DONE" | "ERROR" | "TODO" | "CANCELED";
@@ -648,7 +687,7 @@ declare interface Store<T> {
648
687
  * which forwards them to the server-configured destination (URL + secret stay server-side).
649
688
  * - `false` — collect only, no submit function.
650
689
  */
651
- declare type SubmitConfig<V = Record<string, unknown>> = string | {
690
+ export declare type SubmitConfig<V = Record<string, unknown>> = string | {
652
691
  via: "client";
653
692
  url: string;
654
693
  } | {
package/dist/react.d.ts CHANGED
@@ -359,8 +359,20 @@ export declare interface ChatWidgetProps {
359
359
  height?: string | number;
360
360
  /** URL of a logo to display in the header */
361
361
  logoUrl?: string;
362
- /** Show the agent name above assistant messages. Defaults to `true`. */
362
+ /** Show the agent name above assistant messages. Defaults to `false`. */
363
363
  showAgentName?: boolean;
364
+ /**
365
+ * Conversational forms the agent can fill and submit during the chat. Each
366
+ * config is installed as a {@link createFormCollector} (its `update_<name>` /
367
+ * `submit_<name>` functions + dynamic context) for the lifetime of the widget.
368
+ */
369
+ forms?: CreateFormCollectorOptions[];
370
+ /**
371
+ * How clicking a suggested follow-up reply behaves. Defaults to sending the
372
+ * reply as a new user message. Pass a handler to override, or `false` to
373
+ * render the suggestions as non-interactive.
374
+ */
375
+ onFollowUpClick?: ((reply: string) => void) | false;
364
376
  /** Additional CSS class */
365
377
  className?: string;
366
378
  /** Callback when a message is sent */
@@ -455,7 +467,29 @@ export declare interface Conversation {
455
467
  messages?: AgoMessage[];
456
468
  }
457
469
 
458
- declare interface CreateFormCollectorOptions<V = Record<string, unknown>> {
470
+ /**
471
+ * Wire one schema into a conversational form: an observable store, an
472
+ * `update_<name>` client function the agent calls to fill fields, a dynamic-context
473
+ * provider that tells the agent what's still missing, and an optional submit.
474
+ *
475
+ * ```ts
476
+ * const order = createFormCollector({
477
+ * name: "order",
478
+ * description: "The order the user wants to place",
479
+ * schema: {
480
+ * type: "object",
481
+ * properties: { product: { type: "string" }, quantity: { type: "number" } },
482
+ * required: ["product", "quantity"],
483
+ * },
484
+ * submit: { via: "client", url: "/api/orders" },
485
+ * });
486
+ * order.install(client);
487
+ * order.store.subscribe((s) => render(s));
488
+ * ```
489
+ */
490
+ export declare function createFormCollector<V = Record<string, unknown>>(options: CreateFormCollectorOptions<V>): FormCollector<V>;
491
+
492
+ export declare interface CreateFormCollectorOptions<V = Record<string, unknown>> {
459
493
  /** Short identifier; becomes the `update_<name>` / `submit_<name>` function names. */
460
494
  name: string;
461
495
  /** What the form is, for the LLM. */
@@ -488,7 +522,7 @@ export declare function createMockClient(options?: MockAgoClientOptions): MockAg
488
522
  */
489
523
  declare type DynamicContextProvider = () => ContextEntry | null | undefined;
490
524
 
491
- declare interface FormCollector<V = Record<string, unknown>> {
525
+ export declare interface FormCollector<V = Record<string, unknown>> {
492
526
  name: string;
493
527
  /** Observable store driving the form UI (read via `useAgoStore`). */
494
528
  store: Store<FormCollectorState<V>>;
@@ -512,10 +546,10 @@ declare interface FormCollector<V = Record<string, unknown>> {
512
546
  * `parameters`, so one schema feeds the store, the update function, and the
513
547
  * dynamic context with no second type.
514
548
  */
515
- declare type FormCollectorSchema = ClientFunctionSchema["parameters"];
549
+ export declare type FormCollectorSchema = ClientFunctionSchema["parameters"];
516
550
 
517
551
  /** Live state held in the collector's store. */
518
- declare interface FormCollectorState<V = Record<string, unknown>> {
552
+ export declare interface FormCollectorState<V = Record<string, unknown>> {
519
553
  /** Field values collected so far. */
520
554
  values: Partial<V>;
521
555
  /** Required field names still empty. */
@@ -544,7 +578,7 @@ declare interface FormSchema {
544
578
  }
545
579
 
546
580
  /** Result returned by `submit()` / the generated `submit_<name>` function. */
547
- declare interface FormSubmitResult {
581
+ export declare interface FormSubmitResult {
548
582
  ok: boolean;
549
583
  missing?: string[];
550
584
  result?: unknown;
@@ -569,8 +603,13 @@ export declare const Message: default_2.FC<MessageProps>;
569
603
  export declare interface MessageProps {
570
604
  message: AgoMessage;
571
605
  className?: string;
572
- /** Show the agent name above assistant messages. Defaults to `true`. */
606
+ /** Show the agent name above assistant messages. Defaults to `false`. */
573
607
  showAgentName?: boolean;
608
+ /**
609
+ * Called when the user clicks a suggested follow-up reply. When omitted the
610
+ * follow-up buttons render but are not interactive (backwards-compatible).
611
+ */
612
+ onFollowUpClick?: (reply: string) => void;
574
613
  }
575
614
 
576
615
  declare type MessageStatus = "IN_PROGRESS" | "DONE" | "ERROR" | "TODO" | "CANCELED";
@@ -648,7 +687,7 @@ declare interface Store<T> {
648
687
  * which forwards them to the server-configured destination (URL + secret stay server-side).
649
688
  * - `false` — collect only, no submit function.
650
689
  */
651
- declare type SubmitConfig<V = Record<string, unknown>> = string | {
690
+ export declare type SubmitConfig<V = Record<string, unknown>> = string | {
652
691
  via: "client";
653
692
  url: string;
654
693
  } | {