@useago/sdk 1.0.7 → 1.0.9

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
@@ -176,6 +176,7 @@ declare class AgoClient {
176
176
  * call it when their store updates so observers like the dev panel stay live.
177
177
  */
178
178
  notifyContextChanged(): void;
179
+ /* Excluded from this release type: emitFormEvent */
179
180
  /**
180
181
  * Enable automatic capture of the current browser page (URL + title).
181
182
  * Injected as a dynamic context entry named `browser-page`.
@@ -290,6 +291,27 @@ declare interface AgoClientEvents {
290
291
  result: unknown;
291
292
  error?: string;
292
293
  };
294
+ /**
295
+ * A form collector submitted successfully. `result` is the raw submit response
296
+ * (POST body / handler return value / backend relay result) — the third-party
297
+ * API's answer. `values` is the submitted field set, `name` the collector name.
298
+ */
299
+ "form:submitted": {
300
+ name: string;
301
+ values: Record<string, unknown>;
302
+ result: unknown;
303
+ };
304
+ /**
305
+ * A form collector submit was attempted and failed at the network/server level
306
+ * (HTTP non-2xx, or a thrown handler/fetch). `error` is the message. Validation
307
+ * pre-checks (missing required fields, no submit target) are NOT errors and do
308
+ * not fire this — they are returned to the caller as `{ ok: false }`.
309
+ */
310
+ "form:error": {
311
+ name: string;
312
+ values: Record<string, unknown>;
313
+ error: string;
314
+ };
293
315
  "connection:status": {
294
316
  connected: boolean;
295
317
  };
@@ -611,7 +633,7 @@ declare interface FormCollectorDefinition<V = Record<string, unknown>> {
611
633
 
612
634
  /**
613
635
  * Shape of a form's fields. Mirrors a client function's `parameters` (so the same
614
- * 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.
636
+ * object feeds the store, the update function, and the dynamic context). Additionally allows the SDK-only per-field `requiredWhen`, which {@link toWireParameters} removes from the LLM tool's `parameters` (the full schema still reaches the agent via dynamic context).
615
637
  */
616
638
  declare interface FormCollectorSchema {
617
639
  type: "object";
@@ -628,17 +650,32 @@ declare interface FormField {
628
650
  }
629
651
 
630
652
  /**
631
- * A field's conditional-requiredness rule. The field becomes required exactly
632
- * when the controlling `property` matches `value` against the answers collected
633
- * so far:
653
+ * A field's conditional-requiredness rule: either a single {@link FormFieldLeafCondition}
654
+ * or a boolean combination of rules. `anyOf` is OR (true when any nested rule
655
+ * holds); `allOf` is AND (true when every nested rule holds). Both nest
656
+ * arbitrarily, so you can mix them, e.g.
657
+ * `{ anyOf: [{ property: "a", op: ">=", value: 1 }, { property: "b", value: "1" }] }`.
658
+ * An empty `anyOf` is never required; an empty `allOf` is always required.
659
+ *
660
+ * Stripped from the LLM tool's `parameters` (see {@link toWireParameters}), but the
661
+ * full schema, `requiredWhen` included, still reaches the agent via the dynamic
662
+ * context so it knows when each field becomes required.
663
+ */
664
+ declare type FormFieldCondition = FormFieldLeafCondition | {
665
+ anyOf: FormFieldCondition[];
666
+ } | {
667
+ allOf: FormFieldCondition[];
668
+ };
669
+
670
+ /**
671
+ * A single leaf comparison. The field it guards becomes required exactly when the
672
+ * controlling `property` matches `value` against the answers collected so far:
634
673
  * - a single `value`, no `op` — equality (compared as strings);
635
674
  * - a single `value` with `op` — numeric comparison (both sides coerced to numbers);
636
675
  * - an array `value`, no `op` — "one of": matches when the property equals any
637
676
  * listed value.
638
- *
639
- * SDK-only — it is stripped from the schema before it reaches the LLM tool
640
677
  */
641
- declare interface FormFieldCondition {
678
+ declare interface FormFieldLeafCondition {
642
679
  /** The controlling field whose value the rule tests. */
643
680
  property: string;
644
681
  /** Comparison operator; omitted means equality. Ignored when `value` is an array. */
@@ -659,7 +696,8 @@ declare interface FormFieldSchema {
659
696
  default?: unknown;
660
697
  /**
661
698
  * Makes the field required only while this condition holds. Drives the dynamic
662
- * `missing` list; stripped before the LLM tool — see {@link toWireParameters}.
699
+ * `missing` list; stripped from the LLM tool's `parameters` (still sent to the
700
+ * agent via dynamic context). See {@link toWireParameters}.
663
701
  */
664
702
  requiredWhen?: FormFieldCondition;
665
703
  }
@@ -779,6 +817,16 @@ export declare interface MountChatWidgetOptions {
779
817
  logoUrl?: string;
780
818
  /** Show the agent name above assistant messages. Defaults to `false`. */
781
819
  showAgentName?: boolean;
820
+ /** Render assistant messages inside a filled bubble (themed via `agentBubbleBg`). Defaults to `false`. */
821
+ agentBubble?: boolean;
822
+ /**
823
+ * Show the header bar (title, logo, and the side-panel close "×"). Set `false`
824
+ * to drop it, e.g. when the host page already frames the widget. Defaults to
825
+ * `true`. Note: with the built-in launcher in side placement, the close "×"
826
+ * lives in the header, so hiding it leaves the launcher (and `widget.close()`)
827
+ * as the way to dismiss the panel.
828
+ */
829
+ showHeader?: boolean;
782
830
  /**
783
831
  * Theme overrides so the panel blends into the host page.
784
832
  */
@@ -822,6 +870,25 @@ export declare interface MountChatWidgetOptions {
822
870
  id: string;
823
871
  content: string;
824
872
  }) => void;
873
+ /**
874
+ * Called when a form collector submits successfully. `result` is the raw submit
875
+ * response (the third-party API's answer); `values` are the submitted fields.
876
+ * Forwards the client's `form:submitted` event.
877
+ */
878
+ onFormSubmitted?: (data: {
879
+ name: string;
880
+ values: Record<string, unknown>;
881
+ result: unknown;
882
+ }) => void;
883
+ /**
884
+ * Called when a form collector submit fails at the network/server level.
885
+ * Forwards the client's `form:error` event. No notice is shown in the chat.
886
+ */
887
+ onFormError?: (data: {
888
+ name: string;
889
+ values: Record<string, unknown>;
890
+ error: string;
891
+ }) => void;
825
892
  }
826
893
 
827
894
  /**
@@ -979,6 +1046,8 @@ export declare interface WidgetTheme {
979
1046
  border?: string;
980
1047
  /** Secondary accent: source badges and suggested-reply hover outline. (`--ago-accent-color`) */
981
1048
  accent?: string;
1049
+ /** Background of assistant message bubbles when `agentBubble` is on. Defaults to a light gray. (`--ago-agent-bubble-background`) */
1050
+ agentBubbleBg?: string;
982
1051
  }
983
1052
 
984
1053
  export { }
package/dist/widget.d.ts CHANGED
@@ -176,6 +176,7 @@ declare class AgoClient {
176
176
  * call it when their store updates so observers like the dev panel stay live.
177
177
  */
178
178
  notifyContextChanged(): void;
179
+ /* Excluded from this release type: emitFormEvent */
179
180
  /**
180
181
  * Enable automatic capture of the current browser page (URL + title).
181
182
  * Injected as a dynamic context entry named `browser-page`.
@@ -290,6 +291,27 @@ declare interface AgoClientEvents {
290
291
  result: unknown;
291
292
  error?: string;
292
293
  };
294
+ /**
295
+ * A form collector submitted successfully. `result` is the raw submit response
296
+ * (POST body / handler return value / backend relay result) — the third-party
297
+ * API's answer. `values` is the submitted field set, `name` the collector name.
298
+ */
299
+ "form:submitted": {
300
+ name: string;
301
+ values: Record<string, unknown>;
302
+ result: unknown;
303
+ };
304
+ /**
305
+ * A form collector submit was attempted and failed at the network/server level
306
+ * (HTTP non-2xx, or a thrown handler/fetch). `error` is the message. Validation
307
+ * pre-checks (missing required fields, no submit target) are NOT errors and do
308
+ * not fire this — they are returned to the caller as `{ ok: false }`.
309
+ */
310
+ "form:error": {
311
+ name: string;
312
+ values: Record<string, unknown>;
313
+ error: string;
314
+ };
293
315
  "connection:status": {
294
316
  connected: boolean;
295
317
  };
@@ -611,7 +633,7 @@ declare interface FormCollectorDefinition<V = Record<string, unknown>> {
611
633
 
612
634
  /**
613
635
  * Shape of a form's fields. Mirrors a client function's `parameters` (so the same
614
- * 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.
636
+ * object feeds the store, the update function, and the dynamic context). Additionally allows the SDK-only per-field `requiredWhen`, which {@link toWireParameters} removes from the LLM tool's `parameters` (the full schema still reaches the agent via dynamic context).
615
637
  */
616
638
  declare interface FormCollectorSchema {
617
639
  type: "object";
@@ -628,17 +650,32 @@ declare interface FormField {
628
650
  }
629
651
 
630
652
  /**
631
- * A field's conditional-requiredness rule. The field becomes required exactly
632
- * when the controlling `property` matches `value` against the answers collected
633
- * so far:
653
+ * A field's conditional-requiredness rule: either a single {@link FormFieldLeafCondition}
654
+ * or a boolean combination of rules. `anyOf` is OR (true when any nested rule
655
+ * holds); `allOf` is AND (true when every nested rule holds). Both nest
656
+ * arbitrarily, so you can mix them, e.g.
657
+ * `{ anyOf: [{ property: "a", op: ">=", value: 1 }, { property: "b", value: "1" }] }`.
658
+ * An empty `anyOf` is never required; an empty `allOf` is always required.
659
+ *
660
+ * Stripped from the LLM tool's `parameters` (see {@link toWireParameters}), but the
661
+ * full schema, `requiredWhen` included, still reaches the agent via the dynamic
662
+ * context so it knows when each field becomes required.
663
+ */
664
+ declare type FormFieldCondition = FormFieldLeafCondition | {
665
+ anyOf: FormFieldCondition[];
666
+ } | {
667
+ allOf: FormFieldCondition[];
668
+ };
669
+
670
+ /**
671
+ * A single leaf comparison. The field it guards becomes required exactly when the
672
+ * controlling `property` matches `value` against the answers collected so far:
634
673
  * - a single `value`, no `op` — equality (compared as strings);
635
674
  * - a single `value` with `op` — numeric comparison (both sides coerced to numbers);
636
675
  * - an array `value`, no `op` — "one of": matches when the property equals any
637
676
  * listed value.
638
- *
639
- * SDK-only — it is stripped from the schema before it reaches the LLM tool
640
677
  */
641
- declare interface FormFieldCondition {
678
+ declare interface FormFieldLeafCondition {
642
679
  /** The controlling field whose value the rule tests. */
643
680
  property: string;
644
681
  /** Comparison operator; omitted means equality. Ignored when `value` is an array. */
@@ -659,7 +696,8 @@ declare interface FormFieldSchema {
659
696
  default?: unknown;
660
697
  /**
661
698
  * Makes the field required only while this condition holds. Drives the dynamic
662
- * `missing` list; stripped before the LLM tool — see {@link toWireParameters}.
699
+ * `missing` list; stripped from the LLM tool's `parameters` (still sent to the
700
+ * agent via dynamic context). See {@link toWireParameters}.
663
701
  */
664
702
  requiredWhen?: FormFieldCondition;
665
703
  }
@@ -779,6 +817,16 @@ export declare interface MountChatWidgetOptions {
779
817
  logoUrl?: string;
780
818
  /** Show the agent name above assistant messages. Defaults to `false`. */
781
819
  showAgentName?: boolean;
820
+ /** Render assistant messages inside a filled bubble (themed via `agentBubbleBg`). Defaults to `false`. */
821
+ agentBubble?: boolean;
822
+ /**
823
+ * Show the header bar (title, logo, and the side-panel close "×"). Set `false`
824
+ * to drop it, e.g. when the host page already frames the widget. Defaults to
825
+ * `true`. Note: with the built-in launcher in side placement, the close "×"
826
+ * lives in the header, so hiding it leaves the launcher (and `widget.close()`)
827
+ * as the way to dismiss the panel.
828
+ */
829
+ showHeader?: boolean;
782
830
  /**
783
831
  * Theme overrides so the panel blends into the host page.
784
832
  */
@@ -822,6 +870,25 @@ export declare interface MountChatWidgetOptions {
822
870
  id: string;
823
871
  content: string;
824
872
  }) => void;
873
+ /**
874
+ * Called when a form collector submits successfully. `result` is the raw submit
875
+ * response (the third-party API's answer); `values` are the submitted fields.
876
+ * Forwards the client's `form:submitted` event.
877
+ */
878
+ onFormSubmitted?: (data: {
879
+ name: string;
880
+ values: Record<string, unknown>;
881
+ result: unknown;
882
+ }) => void;
883
+ /**
884
+ * Called when a form collector submit fails at the network/server level.
885
+ * Forwards the client's `form:error` event. No notice is shown in the chat.
886
+ */
887
+ onFormError?: (data: {
888
+ name: string;
889
+ values: Record<string, unknown>;
890
+ error: string;
891
+ }) => void;
825
892
  }
826
893
 
827
894
  /**
@@ -979,6 +1046,8 @@ export declare interface WidgetTheme {
979
1046
  border?: string;
980
1047
  /** Secondary accent: source badges and suggested-reply hover outline. (`--ago-accent-color`) */
981
1048
  accent?: string;
1049
+ /** Background of assistant message bubbles when `agentBubble` is on. Defaults to a light gray. (`--ago-agent-bubble-background`) */
1050
+ agentBubbleBg?: string;
982
1051
  }
983
1052
 
984
1053
  export { }