@useago/sdk 1.0.0 → 1.0.1

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
@@ -53,6 +53,13 @@ declare class AgoClient {
53
53
  * Reject a tool call
54
54
  */
55
55
  rejectToolCall(toolCallId: string): Promise<void>;
56
+ /**
57
+ * Fetch a backend-stored form collector definition by name (the single source
58
+ * of truth for the form's description, schema, and submit target). Used by
59
+ * `loadFormCollector` / the name-only form of `useFormCollector` so the schema
60
+ * lives in the backend instead of being hardcoded in client code.
61
+ */
62
+ getFormCollector(name: string): Promise<FormCollectorDefinition>;
56
63
  /**
57
64
  * Relay a completed form collector's values to a server-configured destination.
58
65
  *
@@ -345,6 +352,13 @@ export declare interface ChatWidgetHandle {
345
352
  element: HTMLElement;
346
353
  /** Programmatically send a message (same path as the input). */
347
354
  sendMessage: (content: string, files?: File[]) => Promise<void>;
355
+ /**
356
+ * Open / close / toggle the side panel. Present only for
357
+ * `placement: "left" | "right"` (an inline panel is always visible).
358
+ */
359
+ open?: () => void;
360
+ close?: () => void;
361
+ toggle?: () => void;
348
362
  /**
349
363
  * The conversation-persistence session, present only when `persistConversation`
350
364
  * is set — exposes the stable `widgetId` and `session.clear()` to start a new thread.
@@ -520,6 +534,20 @@ export declare interface CreateFormCollectorOptions<V = Record<string, unknown>>
520
534
  */
521
535
  declare type DynamicContextProvider = () => ContextEntry | null | undefined;
522
536
 
537
+ /**
538
+ * The backend-stored shape returned by `GET /api/sdk/v1/forms/{name}` (see
539
+ * {@link AgoClient.getFormCollector}). Mirrors the persistable subset of
540
+ * {@link CreateFormCollectorOptions}: the `submit` here is never the client-only
541
+ * `handler` variant (a function can't be stored server-side).
542
+ */
543
+ declare interface FormCollectorDefinition<V = Record<string, unknown>> {
544
+ name: string;
545
+ description: string;
546
+ schema: FormCollectorSchema;
547
+ /** Server-stored submit target, if any. Absent means collect-only. */
548
+ submit?: SubmitConfig<V>;
549
+ }
550
+
523
551
  /**
524
552
  * Shape of a form's fields. Mirrors a client function's `parameters` (so the same
525
553
  * object feeds the store, the update function, and the dynamic context). Additionally allows the SDK-only per-field `requiredWhen`, which {@link toWireParameters} removes before the schema reaches the LLM.
@@ -584,6 +612,16 @@ declare interface FormSchema {
584
612
  required?: string[];
585
613
  }
586
614
 
615
+ /**
616
+ * Options for {@link loadFormCollector} / the name-only form of `useFormCollector`:
617
+ * the `name` is required and the definition is fetched from the backend, while any
618
+ * field here overrides the fetched one — notably a client-only `submit` handler,
619
+ * which can't be stored server-side.
620
+ */
621
+ declare interface LoadFormCollectorOptions<V = Record<string, unknown>> extends Partial<Omit<CreateFormCollectorOptions<V>, "name">> {
622
+ name: string;
623
+ }
624
+
587
625
  declare type MessageStatus = "IN_PROGRESS" | "DONE" | "ERROR" | "TODO" | "CANCELED";
588
626
 
589
627
  /**
@@ -646,9 +684,37 @@ export declare interface MountChatWidgetOptions {
646
684
  placeholder?: string;
647
685
  /** Enable file attachments. */
648
686
  allowFiles?: boolean;
649
- /** Widget height (number → px). */
687
+ /** Widget height (number → px). Ignored when `placement` is `"left"`/`"right"`
688
+ * (a side panel is always full-height). */
650
689
  height?: string | number;
651
- /** URL of a logo shown in the header. */
690
+ /**
691
+ * Where the panel renders. `"inline"` (default) mounts it directly into the
692
+ * target element, filling it. `"left"` / `"right"` instead pin a **fixed,
693
+ * full-height side panel** to that edge of the viewport that slides open and
694
+ * closed; the target is only used as the DOM parent (pass `document.body` for
695
+ * a true page overlay). In side mode `height` is ignored and the width comes
696
+ * from {@link MountChatWidgetOptions.width}.
697
+ */
698
+ placement?: "inline" | "left" | "right";
699
+ /**
700
+ * Width of the side panel for `placement: "left" | "right"` (number → px).
701
+ * Capped at the viewport width so it never overflows on mobile. Ignored when
702
+ * `placement` is `"inline"`. Defaults to `400`.
703
+ */
704
+ width?: string | number;
705
+ /**
706
+ * For side placements, render the built-in floating launcher button that opens
707
+ * the panel (plus a close "×" in the header). Set `false` to drive open/close
708
+ * yourself via the handle's `open()`/`close()`/`toggle()`. Ignored when
709
+ * `placement` is `"inline"`. Defaults to `true`.
710
+ */
711
+ launcher?: boolean;
712
+ /**
713
+ * For side placements, whether the panel starts open. Ignored when `placement`
714
+ * is `"inline"` (an inline panel is always visible). Defaults to `false`.
715
+ */
716
+ defaultOpen?: boolean;
717
+ /** URL of a logo shown in the header (and on the launcher button, if shown). */
652
718
  logoUrl?: string;
653
719
  /** Show the agent name above assistant messages. Defaults to `false`. */
654
720
  showAgentName?: boolean;
@@ -665,10 +731,13 @@ export declare interface MountChatWidgetOptions {
665
731
  loadThreads?: boolean;
666
732
  /**
667
733
  * Conversational forms the agent can fill and submit during the chat. Each
668
- * config is installed as a {@link createFormCollector} for the lifetime of the
734
+ * entry is installed as a {@link createFormCollector} for the lifetime of the
669
735
  * widget (removed on `destroy()`).
736
+ *
737
+ * Pass a full config (with `schema`) to define it inline, or just `{ name }` to
738
+ * fetch the definition from the backend ({@link loadFormCollector}).
670
739
  */
671
- forms?: CreateFormCollectorOptions[];
740
+ forms?: Array<CreateFormCollectorOptions | LoadFormCollectorOptions>;
672
741
  /**
673
742
  * How clicking a suggested follow-up reply behaves. Defaults to sending the
674
743
  * reply as a new user message. Pass a handler to override, or `false` to
package/dist/widget.d.ts CHANGED
@@ -53,6 +53,13 @@ declare class AgoClient {
53
53
  * Reject a tool call
54
54
  */
55
55
  rejectToolCall(toolCallId: string): Promise<void>;
56
+ /**
57
+ * Fetch a backend-stored form collector definition by name (the single source
58
+ * of truth for the form's description, schema, and submit target). Used by
59
+ * `loadFormCollector` / the name-only form of `useFormCollector` so the schema
60
+ * lives in the backend instead of being hardcoded in client code.
61
+ */
62
+ getFormCollector(name: string): Promise<FormCollectorDefinition>;
56
63
  /**
57
64
  * Relay a completed form collector's values to a server-configured destination.
58
65
  *
@@ -345,6 +352,13 @@ export declare interface ChatWidgetHandle {
345
352
  element: HTMLElement;
346
353
  /** Programmatically send a message (same path as the input). */
347
354
  sendMessage: (content: string, files?: File[]) => Promise<void>;
355
+ /**
356
+ * Open / close / toggle the side panel. Present only for
357
+ * `placement: "left" | "right"` (an inline panel is always visible).
358
+ */
359
+ open?: () => void;
360
+ close?: () => void;
361
+ toggle?: () => void;
348
362
  /**
349
363
  * The conversation-persistence session, present only when `persistConversation`
350
364
  * is set — exposes the stable `widgetId` and `session.clear()` to start a new thread.
@@ -520,6 +534,20 @@ export declare interface CreateFormCollectorOptions<V = Record<string, unknown>>
520
534
  */
521
535
  declare type DynamicContextProvider = () => ContextEntry | null | undefined;
522
536
 
537
+ /**
538
+ * The backend-stored shape returned by `GET /api/sdk/v1/forms/{name}` (see
539
+ * {@link AgoClient.getFormCollector}). Mirrors the persistable subset of
540
+ * {@link CreateFormCollectorOptions}: the `submit` here is never the client-only
541
+ * `handler` variant (a function can't be stored server-side).
542
+ */
543
+ declare interface FormCollectorDefinition<V = Record<string, unknown>> {
544
+ name: string;
545
+ description: string;
546
+ schema: FormCollectorSchema;
547
+ /** Server-stored submit target, if any. Absent means collect-only. */
548
+ submit?: SubmitConfig<V>;
549
+ }
550
+
523
551
  /**
524
552
  * Shape of a form's fields. Mirrors a client function's `parameters` (so the same
525
553
  * object feeds the store, the update function, and the dynamic context). Additionally allows the SDK-only per-field `requiredWhen`, which {@link toWireParameters} removes before the schema reaches the LLM.
@@ -584,6 +612,16 @@ declare interface FormSchema {
584
612
  required?: string[];
585
613
  }
586
614
 
615
+ /**
616
+ * Options for {@link loadFormCollector} / the name-only form of `useFormCollector`:
617
+ * the `name` is required and the definition is fetched from the backend, while any
618
+ * field here overrides the fetched one — notably a client-only `submit` handler,
619
+ * which can't be stored server-side.
620
+ */
621
+ declare interface LoadFormCollectorOptions<V = Record<string, unknown>> extends Partial<Omit<CreateFormCollectorOptions<V>, "name">> {
622
+ name: string;
623
+ }
624
+
587
625
  declare type MessageStatus = "IN_PROGRESS" | "DONE" | "ERROR" | "TODO" | "CANCELED";
588
626
 
589
627
  /**
@@ -646,9 +684,37 @@ export declare interface MountChatWidgetOptions {
646
684
  placeholder?: string;
647
685
  /** Enable file attachments. */
648
686
  allowFiles?: boolean;
649
- /** Widget height (number → px). */
687
+ /** Widget height (number → px). Ignored when `placement` is `"left"`/`"right"`
688
+ * (a side panel is always full-height). */
650
689
  height?: string | number;
651
- /** URL of a logo shown in the header. */
690
+ /**
691
+ * Where the panel renders. `"inline"` (default) mounts it directly into the
692
+ * target element, filling it. `"left"` / `"right"` instead pin a **fixed,
693
+ * full-height side panel** to that edge of the viewport that slides open and
694
+ * closed; the target is only used as the DOM parent (pass `document.body` for
695
+ * a true page overlay). In side mode `height` is ignored and the width comes
696
+ * from {@link MountChatWidgetOptions.width}.
697
+ */
698
+ placement?: "inline" | "left" | "right";
699
+ /**
700
+ * Width of the side panel for `placement: "left" | "right"` (number → px).
701
+ * Capped at the viewport width so it never overflows on mobile. Ignored when
702
+ * `placement` is `"inline"`. Defaults to `400`.
703
+ */
704
+ width?: string | number;
705
+ /**
706
+ * For side placements, render the built-in floating launcher button that opens
707
+ * the panel (plus a close "×" in the header). Set `false` to drive open/close
708
+ * yourself via the handle's `open()`/`close()`/`toggle()`. Ignored when
709
+ * `placement` is `"inline"`. Defaults to `true`.
710
+ */
711
+ launcher?: boolean;
712
+ /**
713
+ * For side placements, whether the panel starts open. Ignored when `placement`
714
+ * is `"inline"` (an inline panel is always visible). Defaults to `false`.
715
+ */
716
+ defaultOpen?: boolean;
717
+ /** URL of a logo shown in the header (and on the launcher button, if shown). */
652
718
  logoUrl?: string;
653
719
  /** Show the agent name above assistant messages. Defaults to `false`. */
654
720
  showAgentName?: boolean;
@@ -665,10 +731,13 @@ export declare interface MountChatWidgetOptions {
665
731
  loadThreads?: boolean;
666
732
  /**
667
733
  * Conversational forms the agent can fill and submit during the chat. Each
668
- * config is installed as a {@link createFormCollector} for the lifetime of the
734
+ * entry is installed as a {@link createFormCollector} for the lifetime of the
669
735
  * widget (removed on `destroy()`).
736
+ *
737
+ * Pass a full config (with `schema`) to define it inline, or just `{ name }` to
738
+ * fetch the definition from the backend ({@link loadFormCollector}).
670
739
  */
671
- forms?: CreateFormCollectorOptions[];
740
+ forms?: Array<CreateFormCollectorOptions | LoadFormCollectorOptions>;
672
741
  /**
673
742
  * How clicking a suggested follow-up reply behaves. Defaults to sending the
674
743
  * reply as a new user message. Pass a handler to override, or `false` to