@useago/sdk 1.0.8 → 1.0.10

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
@@ -705,7 +705,7 @@ export declare interface FormCollectorDefinition<V = Record<string, unknown>> {
705
705
 
706
706
  /**
707
707
  * Shape of a form's fields. Mirrors a client function's `parameters` (so the same
708
- * 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.
708
+ * 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).
709
709
  */
710
710
  export declare interface FormCollectorSchema {
711
711
  type: "object";
@@ -745,17 +745,32 @@ declare interface FormField {
745
745
  }
746
746
 
747
747
  /**
748
- * A field's conditional-requiredness rule. The field becomes required exactly
749
- * when the controlling `property` matches `value` against the answers collected
750
- * so far:
748
+ * A field's conditional-requiredness rule: either a single {@link FormFieldLeafCondition}
749
+ * or a boolean combination of rules. `anyOf` is OR (true when any nested rule
750
+ * holds); `allOf` is AND (true when every nested rule holds). Both nest
751
+ * arbitrarily, so you can mix them, e.g.
752
+ * `{ anyOf: [{ property: "a", op: ">=", value: 1 }, { property: "b", value: "1" }] }`.
753
+ * An empty `anyOf` is never required; an empty `allOf` is always required.
754
+ *
755
+ * Stripped from the LLM tool's `parameters` (see {@link toWireParameters}), but the
756
+ * full schema, `requiredWhen` included, still reaches the agent via the dynamic
757
+ * context so it knows when each field becomes required.
758
+ */
759
+ export declare type FormFieldCondition = FormFieldLeafCondition | {
760
+ anyOf: FormFieldCondition[];
761
+ } | {
762
+ allOf: FormFieldCondition[];
763
+ };
764
+
765
+ /**
766
+ * A single leaf comparison. The field it guards becomes required exactly when the
767
+ * controlling `property` matches `value` against the answers collected so far:
751
768
  * - a single `value`, no `op` — equality (compared as strings);
752
769
  * - a single `value` with `op` — numeric comparison (both sides coerced to numbers);
753
770
  * - an array `value`, no `op` — "one of": matches when the property equals any
754
771
  * listed value.
755
- *
756
- * SDK-only — it is stripped from the schema before it reaches the LLM tool
757
772
  */
758
- declare interface FormFieldCondition {
773
+ export declare interface FormFieldLeafCondition {
759
774
  /** The controlling field whose value the rule tests. */
760
775
  property: string;
761
776
  /** Comparison operator; omitted means equality. Ignored when `value` is an array. */
@@ -769,14 +784,15 @@ declare interface FormFieldCondition {
769
784
  }
770
785
 
771
786
  /** A single field's schema: the wire-legal keys plus the SDK-only `requiredWhen`. */
772
- declare interface FormFieldSchema {
787
+ export declare interface FormFieldSchema {
773
788
  type: string;
774
789
  description?: string;
775
790
  enum?: string[];
776
791
  default?: unknown;
777
792
  /**
778
793
  * Makes the field required only while this condition holds. Drives the dynamic
779
- * `missing` list; stripped before the LLM tool — see {@link toWireParameters}.
794
+ * `missing` list; stripped from the LLM tool's `parameters` (still sent to the
795
+ * agent via dynamic context). See {@link toWireParameters}.
780
796
  */
781
797
  requiredWhen?: FormFieldCondition;
782
798
  }
package/dist/react.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { t as J } from "./AgoClient-QcTtrN7u.js";
2
- import { i as q, n as Me, r as z, t as H } from "./createFormCollector-QyojCH_-.js";
2
+ import { i as q, n as Me, r as z, t as H } from "./createFormCollector-CFt1_QSL.js";
3
3
  import { t as Ee } from "./createMockClient-DwdxNwEn.js";
4
4
  import G, { createContext as V, useCallback as E, useContext as O, useEffect as S, useId as j, useMemo as F, useRef as T, useState as M, useSyncExternalStore as X } from "react";
5
5
  import { Fragment as Y, jsx as s, jsxs as I } from "react/jsx-runtime";
@@ -496,7 +496,7 @@ declare interface FormCollectorDefinition<V = Record<string, unknown>> {
496
496
 
497
497
  /**
498
498
  * Shape of a form's fields. Mirrors a client function's `parameters` (so the same
499
- * 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.
499
+ * 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).
500
500
  */
501
501
  declare interface FormCollectorSchema {
502
502
  type: "object";
@@ -513,17 +513,32 @@ declare interface FormField {
513
513
  }
514
514
 
515
515
  /**
516
- * A field's conditional-requiredness rule. The field becomes required exactly
517
- * when the controlling `property` matches `value` against the answers collected
518
- * so far:
516
+ * A field's conditional-requiredness rule: either a single {@link FormFieldLeafCondition}
517
+ * or a boolean combination of rules. `anyOf` is OR (true when any nested rule
518
+ * holds); `allOf` is AND (true when every nested rule holds). Both nest
519
+ * arbitrarily, so you can mix them, e.g.
520
+ * `{ anyOf: [{ property: "a", op: ">=", value: 1 }, { property: "b", value: "1" }] }`.
521
+ * An empty `anyOf` is never required; an empty `allOf` is always required.
522
+ *
523
+ * Stripped from the LLM tool's `parameters` (see {@link toWireParameters}), but the
524
+ * full schema, `requiredWhen` included, still reaches the agent via the dynamic
525
+ * context so it knows when each field becomes required.
526
+ */
527
+ declare type FormFieldCondition = FormFieldLeafCondition | {
528
+ anyOf: FormFieldCondition[];
529
+ } | {
530
+ allOf: FormFieldCondition[];
531
+ };
532
+
533
+ /**
534
+ * A single leaf comparison. The field it guards becomes required exactly when the
535
+ * controlling `property` matches `value` against the answers collected so far:
519
536
  * - a single `value`, no `op` — equality (compared as strings);
520
537
  * - a single `value` with `op` — numeric comparison (both sides coerced to numbers);
521
538
  * - an array `value`, no `op` — "one of": matches when the property equals any
522
539
  * listed value.
523
- *
524
- * SDK-only — it is stripped from the schema before it reaches the LLM tool
525
540
  */
526
- declare interface FormFieldCondition {
541
+ declare interface FormFieldLeafCondition {
527
542
  /** The controlling field whose value the rule tests. */
528
543
  property: string;
529
544
  /** Comparison operator; omitted means equality. Ignored when `value` is an array. */
@@ -544,7 +559,8 @@ declare interface FormFieldSchema {
544
559
  default?: unknown;
545
560
  /**
546
561
  * Makes the field required only while this condition holds. Drives the dynamic
547
- * `missing` list; stripped before the LLM tool — see {@link toWireParameters}.
562
+ * `missing` list; stripped from the LLM tool's `parameters` (still sent to the
563
+ * agent via dynamic context). See {@link toWireParameters}.
548
564
  */
549
565
  requiredWhen?: FormFieldCondition;
550
566
  }
package/dist/testing.d.ts CHANGED
@@ -496,7 +496,7 @@ declare interface FormCollectorDefinition<V = Record<string, unknown>> {
496
496
 
497
497
  /**
498
498
  * Shape of a form's fields. Mirrors a client function's `parameters` (so the same
499
- * 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.
499
+ * 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).
500
500
  */
501
501
  declare interface FormCollectorSchema {
502
502
  type: "object";
@@ -513,17 +513,32 @@ declare interface FormField {
513
513
  }
514
514
 
515
515
  /**
516
- * A field's conditional-requiredness rule. The field becomes required exactly
517
- * when the controlling `property` matches `value` against the answers collected
518
- * so far:
516
+ * A field's conditional-requiredness rule: either a single {@link FormFieldLeafCondition}
517
+ * or a boolean combination of rules. `anyOf` is OR (true when any nested rule
518
+ * holds); `allOf` is AND (true when every nested rule holds). Both nest
519
+ * arbitrarily, so you can mix them, e.g.
520
+ * `{ anyOf: [{ property: "a", op: ">=", value: 1 }, { property: "b", value: "1" }] }`.
521
+ * An empty `anyOf` is never required; an empty `allOf` is always required.
522
+ *
523
+ * Stripped from the LLM tool's `parameters` (see {@link toWireParameters}), but the
524
+ * full schema, `requiredWhen` included, still reaches the agent via the dynamic
525
+ * context so it knows when each field becomes required.
526
+ */
527
+ declare type FormFieldCondition = FormFieldLeafCondition | {
528
+ anyOf: FormFieldCondition[];
529
+ } | {
530
+ allOf: FormFieldCondition[];
531
+ };
532
+
533
+ /**
534
+ * A single leaf comparison. The field it guards becomes required exactly when the
535
+ * controlling `property` matches `value` against the answers collected so far:
519
536
  * - a single `value`, no `op` — equality (compared as strings);
520
537
  * - a single `value` with `op` — numeric comparison (both sides coerced to numbers);
521
538
  * - an array `value`, no `op` — "one of": matches when the property equals any
522
539
  * listed value.
523
- *
524
- * SDK-only — it is stripped from the schema before it reaches the LLM tool
525
540
  */
526
- declare interface FormFieldCondition {
541
+ declare interface FormFieldLeafCondition {
527
542
  /** The controlling field whose value the rule tests. */
528
543
  property: string;
529
544
  /** Comparison operator; omitted means equality. Ignored when `value` is an array. */
@@ -544,7 +559,8 @@ declare interface FormFieldSchema {
544
559
  default?: unknown;
545
560
  /**
546
561
  * Makes the field required only while this condition holds. Drives the dynamic
547
- * `missing` list; stripped before the LLM tool — see {@link toWireParameters}.
562
+ * `missing` list; stripped from the LLM tool's `parameters` (still sent to the
563
+ * agent via dynamic context). See {@link toWireParameters}.
548
564
  */
549
565
  requiredWhen?: FormFieldCondition;
550
566
  }
package/dist/vue.d.cts CHANGED
@@ -512,7 +512,7 @@ declare interface FormCollectorDefinition<V = Record<string, unknown>> {
512
512
 
513
513
  /**
514
514
  * Shape of a form's fields. Mirrors a client function's `parameters` (so the same
515
- * 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.
515
+ * 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).
516
516
  */
517
517
  declare interface FormCollectorSchema {
518
518
  type: "object";
@@ -537,17 +537,32 @@ declare interface FormField_2 {
537
537
  }
538
538
 
539
539
  /**
540
- * A field's conditional-requiredness rule. The field becomes required exactly
541
- * when the controlling `property` matches `value` against the answers collected
542
- * so far:
540
+ * A field's conditional-requiredness rule: either a single {@link FormFieldLeafCondition}
541
+ * or a boolean combination of rules. `anyOf` is OR (true when any nested rule
542
+ * holds); `allOf` is AND (true when every nested rule holds). Both nest
543
+ * arbitrarily, so you can mix them, e.g.
544
+ * `{ anyOf: [{ property: "a", op: ">=", value: 1 }, { property: "b", value: "1" }] }`.
545
+ * An empty `anyOf` is never required; an empty `allOf` is always required.
546
+ *
547
+ * Stripped from the LLM tool's `parameters` (see {@link toWireParameters}), but the
548
+ * full schema, `requiredWhen` included, still reaches the agent via the dynamic
549
+ * context so it knows when each field becomes required.
550
+ */
551
+ declare type FormFieldCondition = FormFieldLeafCondition | {
552
+ anyOf: FormFieldCondition[];
553
+ } | {
554
+ allOf: FormFieldCondition[];
555
+ };
556
+
557
+ /**
558
+ * A single leaf comparison. The field it guards becomes required exactly when the
559
+ * controlling `property` matches `value` against the answers collected so far:
543
560
  * - a single `value`, no `op` — equality (compared as strings);
544
561
  * - a single `value` with `op` — numeric comparison (both sides coerced to numbers);
545
562
  * - an array `value`, no `op` — "one of": matches when the property equals any
546
563
  * listed value.
547
- *
548
- * SDK-only — it is stripped from the schema before it reaches the LLM tool
549
564
  */
550
- declare interface FormFieldCondition {
565
+ declare interface FormFieldLeafCondition {
551
566
  /** The controlling field whose value the rule tests. */
552
567
  property: string;
553
568
  /** Comparison operator; omitted means equality. Ignored when `value` is an array. */
@@ -568,7 +583,8 @@ declare interface FormFieldSchema {
568
583
  default?: unknown;
569
584
  /**
570
585
  * Makes the field required only while this condition holds. Drives the dynamic
571
- * `missing` list; stripped before the LLM tool — see {@link toWireParameters}.
586
+ * `missing` list; stripped from the LLM tool's `parameters` (still sent to the
587
+ * agent via dynamic context). See {@link toWireParameters}.
572
588
  */
573
589
  requiredWhen?: FormFieldCondition;
574
590
  }
package/dist/vue.d.ts CHANGED
@@ -512,7 +512,7 @@ declare interface FormCollectorDefinition<V = Record<string, unknown>> {
512
512
 
513
513
  /**
514
514
  * Shape of a form's fields. Mirrors a client function's `parameters` (so the same
515
- * 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.
515
+ * 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).
516
516
  */
517
517
  declare interface FormCollectorSchema {
518
518
  type: "object";
@@ -537,17 +537,32 @@ declare interface FormField_2 {
537
537
  }
538
538
 
539
539
  /**
540
- * A field's conditional-requiredness rule. The field becomes required exactly
541
- * when the controlling `property` matches `value` against the answers collected
542
- * so far:
540
+ * A field's conditional-requiredness rule: either a single {@link FormFieldLeafCondition}
541
+ * or a boolean combination of rules. `anyOf` is OR (true when any nested rule
542
+ * holds); `allOf` is AND (true when every nested rule holds). Both nest
543
+ * arbitrarily, so you can mix them, e.g.
544
+ * `{ anyOf: [{ property: "a", op: ">=", value: 1 }, { property: "b", value: "1" }] }`.
545
+ * An empty `anyOf` is never required; an empty `allOf` is always required.
546
+ *
547
+ * Stripped from the LLM tool's `parameters` (see {@link toWireParameters}), but the
548
+ * full schema, `requiredWhen` included, still reaches the agent via the dynamic
549
+ * context so it knows when each field becomes required.
550
+ */
551
+ declare type FormFieldCondition = FormFieldLeafCondition | {
552
+ anyOf: FormFieldCondition[];
553
+ } | {
554
+ allOf: FormFieldCondition[];
555
+ };
556
+
557
+ /**
558
+ * A single leaf comparison. The field it guards becomes required exactly when the
559
+ * controlling `property` matches `value` against the answers collected so far:
543
560
  * - a single `value`, no `op` — equality (compared as strings);
544
561
  * - a single `value` with `op` — numeric comparison (both sides coerced to numbers);
545
562
  * - an array `value`, no `op` — "one of": matches when the property equals any
546
563
  * listed value.
547
- *
548
- * SDK-only — it is stripped from the schema before it reaches the LLM tool
549
564
  */
550
- declare interface FormFieldCondition {
565
+ declare interface FormFieldLeafCondition {
551
566
  /** The controlling field whose value the rule tests. */
552
567
  property: string;
553
568
  /** Comparison operator; omitted means equality. Ignored when `value` is an array. */
@@ -568,7 +583,8 @@ declare interface FormFieldSchema {
568
583
  default?: unknown;
569
584
  /**
570
585
  * Makes the field required only while this condition holds. Drives the dynamic
571
- * `missing` list; stripped before the LLM tool — see {@link toWireParameters}.
586
+ * `missing` list; stripped from the LLM tool's `parameters` (still sent to the
587
+ * agent via dynamic context). See {@link toWireParameters}.
572
588
  */
573
589
  requiredWhen?: FormFieldCondition;
574
590
  }
package/dist/widget.cjs CHANGED
@@ -1,5 +1,5 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const De=require("./AgoClient-B3-WGVne.cjs"),Me=require("./createFormCollector-BHHEW6uX.cjs"),rt=require("./createConversationSession-BwYNMZWq.cjs");var at={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"};function U(o){return o.replace(/[&<>"']/g,n=>at[n])}function Fe(o){const n=o.trim();return/^(https?:|mailto:|tel:|#|\/|\.\/|\.\.\/)/i.test(n)||!/^[a-z][a-z0-9+.-]*:/i.test(n)?n:null}var We='"IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, monospace',Q="";function F(o){const n=[],a=u=>(n.push(u),`${Q}${n.length-1}${Q}`);let t=o;return t=t.replace(/`([^`]+)`/g,(u,s)=>a(`<code style="background:#f0f2f5;padding:2px 5px;border-radius:4px;font-size:13px;font-family:${We}">${U(s)}</code>`)),t=t.replace(/!\[([^\]]*)\]\(([^)\s]+)\)/g,(u,s,f)=>{const l=Fe(f);return l?a(`<img alt="${U(s)}" src="${U(l)}" style="max-width:100%;border-radius:8px;margin:4px 0" />`):u}),t=t.replace(/\[([^\]]+)\]\(([^)\s]+)\)/g,(u,s,f)=>{const l=Fe(f);return l?a(`<a href="${U(l)}" target="_blank" rel="noopener noreferrer" style="color:#1b5fc4;text-decoration:underline">${F(s)}</a>`):u}),t=U(t),t=t.replace(/\*\*([^*]+?)\*\*/g,"<strong>$1</strong>").replace(/__([^_]+?)__/g,"<strong>$1</strong>").replace(/~~([^~]+?)~~/g,"<del>$1</del>").replace(/(^|[^*])\*(?!\s)([^*]+?)\*/g,"$1<em>$2</em>").replace(/(^|[^\w_])_(?!\s)([^_]+?)_/g,"$1<em>$2</em>"),t=t.replace(new RegExp(`${Q}(\\d+)${Q}`,"g"),(u,s)=>n[Number(s)]),t}function R(o,n,a){const t=document.createElement(o);return Object.assign(t.style,n),a!==void 0&&(t.innerHTML=a),t}var Pe=/^ {0,3}([-*_])( *\1){2,} *$/,Ge=/^ {0,3}(#{1,6})\s+(.*?)\s*#*\s*$/,je=/^ {0,3}(```+|~~~+)/,Z=/^ {0,3}>\s?/,W=/^(\s*)([-*+]|\d+[.)])\s+(.*)$/,it=["20px","18px","16px","15px","14px","13px"],he=o=>o.match(/^\s*/)?.[0].length??0;function st(o){return o.trim()===""||Pe.test(o)||Ge.test(o)||je.test(o)||Z.test(o)||W.test(o)}function qe(o){const n=o[0].match(W),a=n[1].length,t=/\d/.test(n[2]),u=R(t?"ol":"ul",{margin:"0 0 8px 0",paddingLeft:"20px",listStyleType:t?"decimal":"disc",listStylePosition:"outside"});let s=0;for(;s<o.length;){const f=o[s].match(W),l=[];for(s++;s<o.length&&he(o[s])>a;)l.push(o[s]),s++;const p=R("li",{display:"list-item",margin:"2px 0",lineHeight:"1.6"}),c=f[3].match(/^\[([ xX])\]\s+(.*)$/);c?(p.style.listStyleType="none",p.style.marginLeft="-20px",p.innerHTML=`<span style="margin-right:6px">${c[1].toLowerCase()==="x"?"☑":"☐"}</span>${F(c[2])}`):p.innerHTML=F(f[3]),l.filter(m=>W.test(m)).length>0&&p.appendChild(qe(l.filter(m=>m.trim()!==""))),u.appendChild(p)}return u}function lt(o){const n=l=>l.replace(/^\s*\|?/,"").replace(/\|?\s*$/,"").split("|").map(p=>p.trim()),a=R("div",{overflowX:"auto",margin:"0 0 8px 0"}),t=R("table",{borderCollapse:"collapse",width:"100%",fontSize:"13px"}),u=document.createElement("thead"),s=document.createElement("tr");for(const l of n(o[0]))s.appendChild(R("th",{border:"1px solid #dee3e8",padding:"6px 10px",textAlign:"left",backgroundColor:"#f5f7fa",fontWeight:"600"},F(l)));u.appendChild(s),t.appendChild(u);const f=document.createElement("tbody");for(const l of o.slice(2)){const p=document.createElement("tr");for(const c of n(l))p.appendChild(R("td",{border:"1px solid #dee3e8",padding:"6px 10px"},F(c)));f.appendChild(p)}return t.appendChild(f),a.appendChild(t),a}var dt=o=>!!o&&/^\s*\|?\s*:?-{1,}:?\s*(\|\s*:?-{1,}:?\s*)*\|?\s*$/.test(o);function J(o){const n=document.createDocumentFragment(),a=o.replace(/\r\n?/g,`
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const Fe=require("./AgoClient-B3-WGVne.cjs"),ze=require("./createFormCollector-BI3DXaew.cjs"),pt=require("./createConversationSession-C0diFTUk.cjs");var ft={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"};function j(r){return r.replace(/[&<>"']/g,o=>ft[o])}function He(r){const o=r.trim();return/^(https?:|mailto:|tel:|#|\/|\.\/|\.\.\/)/i.test(o)||!/^[a-z][a-z0-9+.-]*:/i.test(o)?o:null}var Xe='"IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, monospace',ee="";function H(r){const o=[],a=g=>(o.push(g),`${ee}${o.length-1}${ee}`);let t=r;return t=t.replace(/`([^`]+)`/g,(g,s)=>a(`<code style="background:#f0f2f5;padding:2px 5px;border-radius:4px;font-size:13px;font-family:${Xe}">${j(s)}</code>`)),t=t.replace(/!\[([^\]]*)\]\(([^)\s]+)\)/g,(g,s,u)=>{const l=He(u);return l?a(`<img alt="${j(s)}" src="${j(l)}" style="max-width:100%;border-radius:8px;margin:4px 0" />`):g}),t=t.replace(/\[([^\]]+)\]\(([^)\s]+)\)/g,(g,s,u)=>{const l=He(u);return l?a(`<a href="${j(l)}" target="_blank" rel="noopener noreferrer" style="color:#1b5fc4;text-decoration:underline">${H(s)}</a>`):g}),t=j(t),t=t.replace(/\*\*([^*]+?)\*\*/g,"<strong>$1</strong>").replace(/__([^_]+?)__/g,"<strong>$1</strong>").replace(/~~([^~]+?)~~/g,"<del>$1</del>").replace(/(^|[^*])\*(?!\s)([^*]+?)\*/g,"$1<em>$2</em>").replace(/(^|[^\w_])_(?!\s)([^_]+?)_/g,"$1<em>$2</em>"),t=t.replace(new RegExp(`${ee}(\\d+)${ee}`,"g"),(g,s)=>o[Number(s)]),t}function k(r,o,a){const t=document.createElement(r);return Object.assign(t.style,o),a!==void 0&&(t.innerHTML=a),t}var Ke=/^ {0,3}([-*_])( *\1){2,} *$/,Ve=/^ {0,3}(#{1,6})\s+(.*?)\s*#*\s*$/,Qe=/^ {0,3}(```+|~~~+)/,ne=/^ {0,3}>\s?/,q=/^(\s*)([-*+]|\d+[.)])\s+(.*)$/,ut=["20px","18px","16px","15px","14px","13px"],ye=r=>r.match(/^\s*/)?.[0].length??0;function gt(r){return r.trim()===""||Ke.test(r)||Ve.test(r)||Qe.test(r)||ne.test(r)||q.test(r)}function Ye(r){const o=r[0].match(q),a=o[1].length,t=/\d/.test(o[2]),g=k(t?"ol":"ul",{margin:"0 0 8px 0",paddingLeft:"20px",listStyleType:t?"decimal":"disc",listStylePosition:"outside"});let s=0;for(;s<r.length;){const u=r[s].match(q),l=[];for(s++;s<r.length&&ye(r[s])>a;)l.push(r[s]),s++;const p=k("li",{display:"list-item",margin:"2px 0",lineHeight:"1.6"}),c=u[3].match(/^\[([ xX])\]\s+(.*)$/);c?(p.style.listStyleType="none",p.style.marginLeft="-20px",p.innerHTML=`<span style="margin-right:6px">${c[1].toLowerCase()==="x"?"☑":"☐"}</span>${H(c[2])}`):p.innerHTML=H(u[3]),l.filter(x=>q.test(x)).length>0&&p.appendChild(Ye(l.filter(x=>x.trim()!==""))),g.appendChild(p)}return g}function mt(r){const o=l=>l.replace(/^\s*\|?/,"").replace(/\|?\s*$/,"").split("|").map(p=>p.trim()),a=k("div",{overflowX:"auto",margin:"0 0 8px 0"}),t=k("table",{borderCollapse:"collapse",width:"100%",fontSize:"13px"}),g=document.createElement("thead"),s=document.createElement("tr");for(const l of o(r[0]))s.appendChild(k("th",{border:"1px solid #dee3e8",padding:"6px 10px",textAlign:"left",backgroundColor:"#f5f7fa",fontWeight:"600"},H(l)));g.appendChild(s),t.appendChild(g);const u=document.createElement("tbody");for(const l of r.slice(2)){const p=document.createElement("tr");for(const c of o(l))p.appendChild(k("td",{border:"1px solid #dee3e8",padding:"6px 10px"},H(c)));u.appendChild(p)}return t.appendChild(u),a.appendChild(t),a}var ht=r=>!!r&&/^\s*\|?\s*:?-{1,}:?\s*(\|\s*:?-{1,}:?\s*)*\|?\s*$/.test(r);function re(r){const o=document.createDocumentFragment(),a=r.replace(/\r\n?/g,`
2
2
  `).split(`
3
- `);let t=0;for(;t<a.length;){const s=a[t];if(s.trim()===""){t++;continue}const f=s.match(je);if(f){const c=f[1][0],m=[];for(t++;t<a.length&&!new RegExp(`^ {0,3}${c==="`"?"`{3,}":"~{3,}"}\\s*$`).test(a[t]);)m.push(a[t]),t++;t++;const N=R("pre",{margin:"0 0 8px 0"});N.appendChild(R("code",{display:"block",background:"#f5f5f5",padding:"8px 12px",borderRadius:"6px",fontSize:"13px",overflowX:"auto",fontFamily:We,whiteSpace:"pre"},U(m.join(`
4
- `)))),n.appendChild(N);continue}if(Pe.test(s)){n.appendChild(R("hr",{border:"none",borderTop:"1px solid #dee3e8",margin:"12px 0"})),t++;continue}const l=s.match(Ge);if(l){const c=l[1].length;n.appendChild(R(`h${c}`,{margin:"16px 0 8px 0",fontSize:it[c-1],fontWeight:"600",lineHeight:"1.3"},F(l[2]))),t++;continue}if(Z.test(s)){const c=[];for(;t<a.length&&Z.test(a[t]);)c.push(a[t].replace(Z,"")),t++;const m=R("blockquote",{borderLeft:"4px solid #dee3e8",paddingLeft:"12px",margin:"0 0 8px 0",fontStyle:"italic",color:"#6b6d6f"});m.appendChild(J(c.join(`
5
- `))),n.appendChild(m);continue}if(s.includes("|")&&dt(a[t+1])){const c=[s,a[t+1]];for(t+=2;t<a.length&&a[t].includes("|")&&a[t].trim();)c.push(a[t]),t++;n.appendChild(lt(c));continue}if(W.test(s)){const c=[],m=he(s);for(;t<a.length&&a[t].trim()!=="";)if(W.test(a[t])||he(a[t])>m)c.push(a[t]),t++;else break;n.appendChild(qe(c));continue}const p=[s];for(t++;t<a.length&&!st(a[t]);)p.push(a[t]),t++;n.appendChild(R("p",{margin:"0 0 8px 0",lineHeight:"1.6"},p.map(c=>F(c)).join("<br>")))}const u=n.lastElementChild;return u&&(u.style.marginBottom="0"),n}var xe='var(--ago-font, "IBM Plex Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif)',Be={font:"--ago-font",radius:"--ago-radius",messageRadius:"--ago-message-radius",brand:"--ago-brand-color",brandText:"--ago-brand-text-color",headerBg:"--ago-header-background",headerText:"--ago-header-text-color",panelBg:"--ago-panel-background",messagesBg:"--ago-messages-background",text:"--ago-text-color",mutedText:"--ago-muted-text-color",border:"--ago-border-color",accent:"--ago-accent-color"},be="var(--ago-brand-color, #03182f)",Ce="var(--ago-brand-text-color, #fff)",ct="var(--ago-header-background, var(--ago-brand-color, #03182f))",ze="var(--ago-header-text-color, #e8f0fe)",j="var(--ago-panel-background, #fff)",pt="var(--ago-messages-background, #fbfbfb)",Y="var(--ago-text-color, #30373e)",ft="var(--ago-muted-text-color, #6b6d6f)",I="var(--ago-border-color, #dee3e8)",ge="var(--ago-accent-color, #1b5fc4)",ut="var(--ago-radius, 16px)",me="var(--ago-message-radius, 16px)";function gt(o,n){if(n)for(const a of Object.keys(Be)){const t=n[a];t!=null&&o.style.setProperty(Be[a],t)}}function E(o,n){Object.assign(o.style,n)}function b(o={}){const n=document.createElement("div");return E(n,o),n}var He="Form submitted.";function mt(o){if(typeof o=="string")return o||null;if(!o||typeof o!="object")return null;const n=o;if(typeof n.message=="string"&&n.message)return n.message;const a=n.result;if(typeof a=="string"&&a)return a;if(a&&typeof a=="object"){const t=a.message;if(typeof t=="string"&&t)return t}return null}var Ue="ago-chat-widget-keyframes";function ht(){if(typeof document>"u"||document.getElementById(Ue))return;const o=document.createElement("style");o.id=Ue,o.textContent="@keyframes ago-pulse { 0%, 80%, 100% { opacity: 0.3; transform: scale(0.8); } 40% { opacity: 1; transform: scale(1); } }",document.head.appendChild(o)}function xt(o){const n=typeof o=="string"?document.querySelector(o):o;if(!n)throw new Error(`mountChatWidget: target "${String(o)}" not found.`);return n}function bt(o,n){const{title:a="Chat",welcomeMessage:t="Hello! How can I help you today?",placeholder:u="Type a message...",allowFiles:s=!1,height:f=500,placement:l="inline",width:p=400,defaultOpen:c=!1,logoUrl:m,showAgentName:N=!1,theme:h,loadThreads:_=!1,forms:q,formSubmittedMessage:L=He,onFollowUpClick:$,onMessageSent:ye,onMessageReceived:ee,onFormSubmitted:te,onFormError:ne}=n;if(!n.client&&!n.config?.baseUrl)throw new De.AgoError("mountChatWidget requires either `client` or `config` (with a baseUrl).","config_missing_base_url");const g=n.client??new De.AgoClient(n.config),ve=xt(o),B=l==="left"||l==="right",Xe=B&&(n.launcher??!0);let z=B?c:!0;const oe=n.persistConversation,X=oe?rt.createConversationSession(oe===!0?{}:oe):void 0;let k=n.conversationId??X?.getLastActiveThread()??void 0,d=[],O=!1,P=null;const Ee=[];function Ke(e){if(typeof L=="function"){const i=L(e);if(typeof i=="string"&&i)return i}const r=mt(e);return r||(typeof L=="string"?L:He)}const K=[],H=b({display:"flex",flexDirection:"column",height:B?"100%":typeof f=="number"?`${f}px`:f,border:`1px solid ${I}`,borderRadius:ut,overflow:"hidden",backgroundColor:j,fontFamily:xe,textAlign:"left",boxShadow:"rgba(15, 15, 15, 0.08) 0px 2px 16px 0px"});H.className="ago-chat-widget",gt(H,h);const G=b({padding:"14px 16px",borderBottom:`1px solid ${I}`,backgroundColor:ct,color:ze,display:"flex",alignItems:"center",gap:"10px"});if(G.className="ago-chat-widget__header",m){const e=document.createElement("img");e.src=m,e.alt="Logo",E(e,{height:"24px",width:"auto"}),G.appendChild(e)}const re=document.createElement("h3");if(re.textContent=a,E(re,{margin:"0",fontSize:"15px",fontWeight:"600"}),G.appendChild(re),B){const e=document.createElement("button");e.type="button",e.className="ago-chat-widget__close",e.setAttribute("aria-label","Close"),e.textContent="×",E(e,{marginLeft:"auto",background:"transparent",border:"none",color:ze,fontSize:"22px",lineHeight:"1",cursor:"pointer",padding:"0 2px"}),e.addEventListener("click",()=>fe()),G.appendChild(e)}const T=b({flex:"1",overflow:"auto",padding:"16px",backgroundColor:pt});T.className="ago-chat-widget__messages";const{inputRow:Ve,setDisabled:Qe,focus:ae}=Ct({placeholder:u,allowFiles:s,onSend:(e,r)=>{le(e,r)}});ht(),H.append(G,T,Ve);let V=H,D,S;const ie=l==="left"?"left":"right";if(B&&(D=b({position:"fixed",top:"0",bottom:"0",[ie]:"0",width:typeof p=="number"?`${p}px`:p,maxWidth:"100vw",display:"flex",zIndex:"2147483000",transition:"transform 0.3s ease",boxShadow:"rgba(15, 15, 15, 0.18) 0px 0px 24px 0px"}),D.className="ago-chat-widget-panel",E(H,{height:"100%",width:"100%",borderRadius:"0",border:"none",boxShadow:"none",[ie==="left"?"borderRight":"borderLeft"]:`1px solid ${I}`}),D.appendChild(H),V=D),Xe){if(S=document.createElement("button"),S.type="button",S.className="ago-chat-widget-launcher",S.setAttribute("aria-label",`Open ${a}`),E(S,{position:"fixed",bottom:"20px",[ie]:"20px",width:"56px",height:"56px",borderRadius:"50%",border:"none",backgroundColor:be,color:Ce,cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",zIndex:"2147483000",boxShadow:"rgba(15, 15, 15, 0.2) 0px 4px 14px 0px",fontFamily:xe}),m){const e=document.createElement("img");e.src=m,e.alt="",E(e,{width:"26px",height:"26px",objectFit:"contain"}),S.appendChild(e)}else S.appendChild(nt());S.addEventListener("click",()=>pe())}ve.appendChild(V),S&&ve.appendChild(S),ce();const we=$!==!1,Se=$===!1?void 0:$??(e=>{le(e)});function Ye(e,r){const i=e.role==="user",x=b({display:"flex",flexDirection:"column",alignItems:i?"flex-end":"flex-start",marginBottom:"16px"});if(x.className=`ago-message ago-message--${e.role}`,!i&&N&&e.agent){const C=b({fontSize:"13px",fontWeight:"500",color:Y,marginBottom:"6px",padding:"0 4px"});C.className="ago-message__agent",C.textContent=e.agent.displayName||e.agent.name,x.appendChild(C)}if(!i&&e.sources&&e.sources.length>0){const C=b({display:"grid",gridTemplateColumns:"1fr 1fr",gap:"6px",marginBottom:"10px",width:"100%",maxWidth:"85%"});C.className="ago-message__sources",e.sources.forEach((y,w)=>{const M=y.url?document.createElement("a"):document.createElement("div");y.url&&M instanceof HTMLAnchorElement&&(M.href=y.url,M.target="_blank",M.rel="noopener noreferrer"),E(M,{display:"flex",alignItems:"center",gap:"8px",padding:"8px 10px",border:`1px solid ${I}`,borderRadius:"8px",backgroundColor:j,textDecoration:"none",color:Y,fontSize:"12px",overflow:"hidden"});const Oe=b({flexShrink:"0",width:"18px",height:"18px",borderRadius:"3px",border:`1px solid ${ge}`,color:ge,fontSize:"11px",fontWeight:"500",display:"flex",alignItems:"center",justifyContent:"center",backgroundColor:"#f0f4ff"});Oe.textContent=String(w+1);const ue=b({overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"});ue.textContent=y.title,ue.title=y.title,M.append(Oe,ue),C.appendChild(M)}),x.appendChild(C)}const v=b({maxWidth:i?"75%":"100%",padding:i?"10px 14px":"2px 8px",borderRadius:i?me:"0",backgroundColor:i?be:"transparent",color:i?Ce:Y,wordBreak:"break-word",fontSize:"16px",lineHeight:"1.6"});if(v.className="ago-message__content",e.content?v.appendChild(J(e.content)):e.status==="IN_PROGRESS"&&v.appendChild(ot()),x.appendChild(v),r&&e.followUpReplies&&e.followUpReplies.length>0){const C=b({display:"flex",flexWrap:"wrap",gap:"8px",marginTop:"10px"});C.className="ago-message__followups";for(const y of e.followUpReplies){const w=document.createElement("button");w.type="button",w.className="ago-message__followup-btn",w.textContent=y,w.disabled=!we,E(w,{padding:"6px 14px",fontSize:"14px",borderRadius:me,border:`1px solid ${I}`,backgroundColor:j,color:Y,cursor:we?"pointer":"default",transition:"border-color 0.15s"}),Se&&w.addEventListener("click",()=>Se(y)),w.addEventListener("mouseenter",()=>{w.style.borderColor=ge}),w.addEventListener("mouseleave",()=>{w.style.borderColor=I}),C.appendChild(w)}x.appendChild(C)}return x}function Ze(e){const r=b({display:"flex",alignItems:"center",gap:"8px",padding:"10px 14px",backgroundColor:"#f0fdf4",color:"#15803d",borderRadius:me,marginTop:"8px",fontSize:"13px",border:"1px solid #bbf7d0"});r.className="ago-form-notice",r.setAttribute("role","status");const i=document.createElement("span");i.textContent="✓",i.setAttribute("aria-hidden","true"),E(i,{fontWeight:"700"});const x=document.createElement("span");return x.textContent=e,r.append(i,x),r}function A(){if(T.replaceChildren(),d.length===0){const r=b({textAlign:"center",color:ft,padding:"24px 16px",fontSize:"16px",lineHeight:"1.5"});r.appendChild(J(t)),T.appendChild(r)}else d.forEach((r,i)=>{T.appendChild(Ye(r,i===d.length-1))});for(const r of Ee)T.appendChild(Ze(r));if(P){const r=b({padding:"10px 14px",backgroundColor:"#fef2f2",color:"#dc2626",borderRadius:"12px",marginTop:"8px",fontSize:"13px",border:"1px solid #fecaca"});r.textContent=P,T.appendChild(r)}T.scrollTop=T.scrollHeight;const e=d[d.length-1];Qe(O&&e?.role==="assistant"&&e.status==="IN_PROGRESS")}function Je(){for(let e=d.length-1;e>=0;e--){const r=d[e];if(r.role==="assistant"&&r.status==="IN_PROGRESS")return r}}const Re=e=>{k||(k=e.conversationId)},_e=e=>{const r=Je();r&&(r.content+=e.content,A())},ke=e=>{const r=d.findIndex(i=>i.id===e.id||i.role==="assistant"&&i.status==="IN_PROGRESS");r>=0?d[r]=e:d.push(e),A(),ae()},Ae=e=>{const r=d.findIndex(i=>i.id===e.id||i.role==="assistant"&&i.status==="IN_PROGRESS");r>=0?d[r]=e:d.push(e),O=!1,A(),e.status==="DONE"&&ee?.({id:e.id,content:e.content})},Ie=e=>{P=e.error,O=!1,d=d.filter(r=>!r.id.startsWith("temp-")),A()};g.on("message:start",Re),g.on("message:chunk",_e),g.on("message:answer-complete",ke),g.on("message:complete",Ae),g.on("message:error",Ie);const $e=e=>te?.(e),Te=e=>ne?.(e);te&&g.on("form:submitted",$e),ne&&g.on("form:error",Te);const se=[];let Ne=!1;const Le=e=>{if(Ne)return;se.push(e.install(g));let r=e.store.get().submitted;const i=e.store.subscribe(x=>{x.submitted&&!r&&(Ee.push(Ke(x.submitResult)),A()),r=x.submitted});se.push(i)};for(const e of q??[])e.schema!=null?Le(Me.createFormCollector(e)):Me.loadFormCollector(g,e).then(r=>Le(r)).catch(()=>{});async function le(e,r){const i=e.trim();if(!i&&!r?.length||O)return;ye?.(i),O=!0,P=null;const x=Date.now();d.push({id:`temp-user-${x}`,conversationId:k||"",content:i,role:"user",status:"DONE",createdAt:new Date}),d.push({id:`temp-assistant-${x}`,conversationId:k||"",content:"",role:"assistant",status:"IN_PROGRESS",createdAt:new Date}),A();try{const v=await g.sendMessage(i,{conversationId:k,files:r});v.conversationId&&(k||(k=v.conversationId),X?.setActiveThread(v.conversationId,v.createdAt));const C=d.find(y=>y.id===`temp-user-${x}`);if(C&&(C.id=`user-${x}`,C.conversationId=v.conversationId),!d.some(y=>y.id===v.id)){const y=d.findIndex(w=>w.id===`temp-assistant-${x}`);y>=0?d[y]=v:d.push(v)}d=d.filter(y=>!y.id.startsWith("temp-")),O=!1,A(),_&&de()}catch(v){P=v instanceof Error?v.message:"Failed to send message",O=!1,d=d.filter(C=>!C.id.startsWith("temp-")),A()}}async function de(){try{const e=await g.getConversations();K.splice(0,K.length,...e)}catch{}return K}async function et(e){try{const r=(await g.getConversation(e))?.messages??[];r.length>0&&d.length===0&&(d=r,A())}catch{d.length===0&&(X?.clear(),k=void 0)}}return A(),ae(),k&&et(k),_&&de(),{client:g,element:V,sendMessage:le,...B?{open:pe,close:fe,toggle:tt}:{},session:X,threads:K,refreshThreads:de,destroy(){g.off("message:start",Re),g.off("message:chunk",_e),g.off("message:answer-complete",ke),g.off("message:complete",Ae),g.off("message:error",Ie),te&&g.off("form:submitted",$e),ne&&g.off("form:error",Te),Ne=!0,se.forEach(e=>e()),V.remove(),S?.remove(),n.client||g.destroy()}};function ce(){if(!D)return;const e=l==="left"?"translateX(-100%)":"translateX(100%)";D.style.transform=z?"translateX(0)":e,D.setAttribute("aria-hidden",z?"false":"true"),S&&(S.style.display=z?"none":"flex")}function pe(){z=!0,ce(),ae()}function fe(){z=!1,ce()}function tt(){z?fe():pe()}function nt(){const e="http://www.w3.org/2000/svg",r=document.createElementNS(e,"svg");r.setAttribute("width","26"),r.setAttribute("height","26"),r.setAttribute("viewBox","0 0 24 24"),r.setAttribute("fill","none");const i=document.createElementNS(e,"path");return i.setAttribute("d","M21 11.5a8.38 8.38 0 0 1-8.5 8.5 8.5 8.5 0 0 1-3.8-.9L3 21l1.9-5.7a8.5 8.5 0 0 1-.9-3.8 8.38 8.38 0 0 1 8.5-8.5 8.38 8.38 0 0 1 8.5 8.5z"),i.setAttribute("stroke","currentColor"),i.setAttribute("stroke-width","2"),i.setAttribute("stroke-linecap","round"),i.setAttribute("stroke-linejoin","round"),r.appendChild(i),r}function ot(){const e=b({display:"flex",gap:"4px",padding:"4px 0"});for(let r=0;r<3;r++){const i=b({width:"6px",height:"6px",borderRadius:"50%",backgroundColor:"#b5bfc8",animation:"ago-pulse 1.2s ease-in-out infinite",animationDelay:`${r*.2}s`});e.appendChild(i)}return e}}function Ct(o){let n=[];const a=document.createElement("form");E(a,{display:"flex",flexDirection:"column",gap:"8px",padding:"12px",borderTop:`1px solid ${I}`,backgroundColor:j}),a.className="ago-chat-input";const t=b({display:"flex",flexWrap:"wrap",gap:"6px"}),u=b({display:"flex",gap:"8px",alignItems:"flex-end"}),s=document.createElement("textarea");s.placeholder=o.placeholder,s.rows=1,E(s,{flex:"1",resize:"none",padding:"10px 12px",border:`1px solid ${I}`,borderRadius:"12px",fontSize:"16px",fontFamily:xe,lineHeight:"1.4",maxHeight:"120px",outline:"none"});const f=document.createElement("button");f.type="submit",f.textContent="Send",E(f,{padding:"10px 16px",border:"none",borderRadius:"12px",backgroundColor:be,color:Ce,fontSize:"16px",fontWeight:"500",cursor:"pointer"});let l=null,p=null;o.allowFiles&&(l=document.createElement("input"),l.type="file",l.multiple=!0,E(l,{display:"none"}),p=document.createElement("button"),p.type="button",p.textContent="📎",E(p,{padding:"10px 12px",border:`1px solid ${I}`,borderRadius:"12px",backgroundColor:j,cursor:"pointer",fontSize:"14px"}),p.addEventListener("click",()=>l?.click()),l.addEventListener("change",()=>{n=[...n,...Array.from(l?.files??[])],c()}));function c(){t.replaceChildren(),n.forEach((h,_)=>{const q=b({display:"flex",alignItems:"center",gap:"4px",padding:"4px 8px",backgroundColor:"#f0f4ff",border:`1px solid ${I}`,borderRadius:"8px",fontSize:"12px"}),L=document.createElement("span");L.textContent=h.name;const $=document.createElement("button");$.type="button",$.textContent="×",E($,{border:"none",background:"transparent",cursor:"pointer",fontSize:"14px",lineHeight:"1"}),$.addEventListener("click",()=>{n=n.filter((ye,ee)=>ee!==_),c()}),q.append(L,$),t.appendChild(q)})}const m=()=>{const h=s.value,_=n;return s.value="",n=[],c(),{content:h,files:_}},N=()=>{const{content:h,files:_}=m();(h.trim()||_.length>0)&&o.onSend(h.trim(),_.length>0?_:void 0)};return a.addEventListener("submit",h=>{h.preventDefault(),N()}),s.addEventListener("keydown",h=>{h.key==="Enter"&&!h.shiftKey&&(h.preventDefault(),N())}),p&&u.appendChild(p),u.append(s,f),l&&a.appendChild(l),a.append(t,u),{inputRow:a,getValueAndClear:m,setDisabled:h=>{s.disabled=h,f.disabled=h,f.style.opacity=h?"0.6":"1",f.style.cursor=h?"not-allowed":"pointer"},focus:()=>s.focus()}}exports.mountChatWidget=bt;exports.renderMarkdown=J;
3
+ `);let t=0;for(;t<a.length;){const s=a[t];if(s.trim()===""){t++;continue}const u=s.match(Qe);if(u){const c=u[1][0],x=[];for(t++;t<a.length&&!new RegExp(`^ {0,3}${c==="`"?"`{3,}":"~{3,}"}\\s*$`).test(a[t]);)x.push(a[t]),t++;t++;const B=k("pre",{margin:"0 0 8px 0"});B.appendChild(k("code",{display:"block",background:"#f5f5f5",padding:"8px 12px",borderRadius:"6px",fontSize:"13px",overflowX:"auto",fontFamily:Xe,whiteSpace:"pre"},j(x.join(`
4
+ `)))),o.appendChild(B);continue}if(Ke.test(s)){o.appendChild(k("hr",{border:"none",borderTop:"1px solid #dee3e8",margin:"12px 0"})),t++;continue}const l=s.match(Ve);if(l){const c=l[1].length;o.appendChild(k(`h${c}`,{margin:"16px 0 8px 0",fontSize:ut[c-1],fontWeight:"600",lineHeight:"1.3"},H(l[2]))),t++;continue}if(ne.test(s)){const c=[];for(;t<a.length&&ne.test(a[t]);)c.push(a[t].replace(ne,"")),t++;const x=k("blockquote",{borderLeft:"4px solid #dee3e8",paddingLeft:"12px",margin:"0 0 8px 0",fontStyle:"italic",color:"#6b6d6f"});x.appendChild(re(c.join(`
5
+ `))),o.appendChild(x);continue}if(s.includes("|")&&ht(a[t+1])){const c=[s,a[t+1]];for(t+=2;t<a.length&&a[t].includes("|")&&a[t].trim();)c.push(a[t]),t++;o.appendChild(mt(c));continue}if(q.test(s)){const c=[],x=ye(s);for(;t<a.length&&a[t].trim()!=="";)if(q.test(a[t])||ye(a[t])>x)c.push(a[t]),t++;else break;o.appendChild(Ye(c));continue}const p=[s];for(t++;t<a.length&&!gt(a[t]);)p.push(a[t]),t++;o.appendChild(k("p",{margin:"0 0 8px 0",lineHeight:"1.6"},p.map(c=>H(c)).join("<br>")))}const g=o.lastElementChild;return g&&(g.style.marginBottom="0"),o}var ve='var(--ago-font, "IBM Plex Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif)',Ue={font:"--ago-font",radius:"--ago-radius",messageRadius:"--ago-message-radius",brand:"--ago-brand-color",brandText:"--ago-brand-text-color",headerBg:"--ago-header-background",headerText:"--ago-header-text-color",panelBg:"--ago-panel-background",messagesBg:"--ago-messages-background",text:"--ago-text-color",mutedText:"--ago-muted-text-color",border:"--ago-border-color",accent:"--ago-accent-color",agentBubbleBg:"--ago-agent-bubble-background"},oe="var(--ago-brand-color, #03182f)",Ee="var(--ago-brand-text-color, #fff)",xt="var(--ago-header-background, var(--ago-brand-color, #03182f))",We="var(--ago-header-text-color, #e8f0fe)",K="var(--ago-panel-background, #fff)",Pe="var(--ago-messages-background, #fbfbfb)",te="var(--ago-text-color, #30373e)",bt="var(--ago-muted-text-color, #6b6d6f)",N="var(--ago-border-color, #dee3e8)",be="var(--ago-accent-color, #1b5fc4)",Ge="var(--ago-agent-bubble-background, #f1f3f5)",Ct="var(--ago-radius, 16px)",Ce="var(--ago-message-radius, 16px)";function yt(r,o){if(o)for(const a of Object.keys(Ue)){const t=o[a];t!=null&&r.style.setProperty(Ue[a],t)}}function v(r,o){Object.assign(r.style,o)}function h(r={}){const o=document.createElement("div");return v(o,r),o}var je="Form submitted.";function vt(r){if(typeof r=="string")return r||null;if(!r||typeof r!="object")return null;const o=r;if(typeof o.message=="string"&&o.message)return o.message;const a=o.result;if(typeof a=="string"&&a)return a;if(a&&typeof a=="object"){const t=a.message;if(typeof t=="string"&&t)return t}return null}var qe="ago-chat-widget-keyframes";function Et(){if(typeof document>"u"||document.getElementById(qe))return;const r=document.createElement("style");r.id=qe,r.textContent="@keyframes ago-pulse { 0%, 80%, 100% { opacity: 0.3; transform: scale(0.8); } 40% { opacity: 1; transform: scale(1); } }",document.head.appendChild(r)}function wt(r){const o=typeof r=="string"?document.querySelector(r):r;if(!o)throw new Error(`mountChatWidget: target "${String(r)}" not found.`);return o}function St(r,o){const{title:a="Chat",welcomeMessage:t="Hello! How can I help you today?",placeholder:g="Type a message...",allowFiles:s=!1,height:u=500,placement:l="inline",width:p=400,defaultOpen:c=!1,logoUrl:x,showAgentName:B=!1,agentBubble:b=!1,bubbleStyle:L="default",showHeader:V=!0,theme:Q,loadThreads:O=!1,forms:we,formSubmittedMessage:U=je,onFollowUpClick:ae,onMessageSent:Ze,onMessageReceived:Je,onFormSubmitted:se,onFormError:ie}=o;if(!o.client&&!o.config?.baseUrl)throw new Fe.AgoError("mountChatWidget requires either `client` or `config` (with a baseUrl).","config_missing_base_url");const m=o.client??new Fe.AgoClient(o.config),Se=wt(r),W=l==="left"||l==="right",et=W&&(o.launcher??!0);let P=W?c:!0;const le=o.persistConversation,Y=le?pt.createConversationSession(le===!0?{}:le):void 0;let A=o.conversationId??Y?.getLastActiveThread()??void 0,d=[],D=!1,X=null;const Re=[];function tt(e){if(typeof U=="function"){const i=U(e);if(typeof i=="string"&&i)return i}const n=vt(e);return n||(typeof U=="string"?U:je)}const Z=[],G=h({display:"flex",flexDirection:"column",height:W?"100%":typeof u=="number"?`${u}px`:u,border:`1px solid ${N}`,borderRadius:Ct,overflow:"hidden",backgroundColor:K,fontFamily:ve,textAlign:"left",boxShadow:"rgba(15, 15, 15, 0.08) 0px 2px 16px 0px"});G.className="ago-chat-widget",yt(G,Q);let M;if(V){if(M=h({padding:"14px 16px",borderBottom:`1px solid ${N}`,backgroundColor:xt,color:We,display:"flex",alignItems:"center",gap:"10px"}),M.className="ago-chat-widget__header",x){const n=document.createElement("img");n.src=x,n.alt="Logo",v(n,{height:"24px",width:"auto"}),M.appendChild(n)}const e=document.createElement("h3");if(e.textContent=a,v(e,{margin:"0",fontSize:"15px",fontWeight:"600"}),M.appendChild(e),W){const n=document.createElement("button");n.type="button",n.className="ago-chat-widget__close",n.setAttribute("aria-label","Close"),n.textContent="×",v(n,{marginLeft:"auto",background:"transparent",border:"none",color:We,fontSize:"22px",lineHeight:"1",cursor:"pointer",padding:"0 2px"}),n.addEventListener("click",()=>he()),M.appendChild(n)}}const T=h({flex:"1",overflow:"auto",padding:"16px",backgroundColor:Pe});T.className="ago-chat-widget__messages";const{inputRow:nt,setDisabled:ot,focus:de}=Rt({placeholder:g,allowFiles:s,onSend:(e,n)=>{fe(e,n)}});Et(),G.append(...M?[M]:[],T,nt);let J=G,F,w;const ce=l==="left"?"left":"right";if(W&&(F=h({position:"fixed",top:"0",bottom:"0",[ce]:"0",width:typeof p=="number"?`${p}px`:p,maxWidth:"100vw",display:"flex",zIndex:"2147483000",transition:"transform 0.3s ease",boxShadow:"rgba(15, 15, 15, 0.18) 0px 0px 24px 0px"}),F.className="ago-chat-widget-panel",v(G,{height:"100%",width:"100%",borderRadius:"0",border:"none",boxShadow:"none",[ce==="left"?"borderRight":"borderLeft"]:`1px solid ${N}`}),F.appendChild(G),J=F),et){if(w=document.createElement("button"),w.type="button",w.className="ago-chat-widget-launcher",w.setAttribute("aria-label",`Open ${a}`),v(w,{position:"fixed",bottom:"20px",[ce]:"20px",width:"56px",height:"56px",borderRadius:"50%",border:"none",backgroundColor:oe,color:Ee,cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",zIndex:"2147483000",boxShadow:"rgba(15, 15, 15, 0.2) 0px 4px 14px 0px",fontFamily:ve}),x){const e=document.createElement("img");e.src=x,e.alt="",v(e,{width:"26px",height:"26px",objectFit:"contain"}),w.appendChild(e)}else w.appendChild(dt());w.addEventListener("click",()=>me())}Se.appendChild(J),w&&Se.appendChild(w),ge();const _e=ae!==!1,ke=ae===!1?void 0:ae??(e=>{fe(e)});function rt(e,n,i=!0){const f=e.role==="user",y=L==="imessage",_=h({display:"flex",flexDirection:"column",alignItems:f?"flex-end":"flex-start",marginBottom:y&&!i?"2px":"16px"});if(_.className=`ago-message ago-message--${e.role}`,!f&&B&&e.agent){const C=h({fontSize:"13px",fontWeight:"500",color:te,marginBottom:"6px",padding:"0 4px"});C.className="ago-message__agent",C.textContent=e.agent.displayName||e.agent.name,_.appendChild(C)}if(!f&&e.sources&&e.sources.length>0){const C=h({display:"grid",gridTemplateColumns:"1fr 1fr",gap:"6px",marginBottom:"10px",width:"100%",maxWidth:"85%"});C.className="ago-message__sources",e.sources.forEach((E,R)=>{const z=E.url?document.createElement("a"):document.createElement("div");E.url&&z instanceof HTMLAnchorElement&&(z.href=E.url,z.target="_blank",z.rel="noopener noreferrer"),v(z,{display:"flex",alignItems:"center",gap:"8px",padding:"8px 10px",border:`1px solid ${N}`,borderRadius:"8px",backgroundColor:K,textDecoration:"none",color:te,fontSize:"12px",overflow:"hidden"});const Me=h({flexShrink:"0",width:"18px",height:"18px",borderRadius:"3px",border:`1px solid ${be}`,color:be,fontSize:"11px",fontWeight:"500",display:"flex",alignItems:"center",justifyContent:"center",backgroundColor:"#f0f4ff"});Me.textContent=String(R+1);const xe=h({overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"});xe.textContent=E.title,xe.title=E.title,z.append(Me,xe),C.appendChild(z)}),_.appendChild(C)}const S=f||b||y,$=h({maxWidth:y||f?"75%":S?"85%":"100%",padding:S?"10px 14px":"2px 8px",borderRadius:S?Ce:"0",backgroundColor:f?oe:S?Ge:"transparent",color:f?Ee:te,wordBreak:"break-word",fontSize:"16px",lineHeight:"1.6"});if($.className="ago-message__content",y&&i){$.style.position="relative",f?$.style.borderBottomRightRadius="4px":$.style.borderBottomLeftRadius="4px";const C=h({position:"absolute",zIndex:"0",bottom:"0",width:"20px",height:"20px",background:f?oe:Ge});C.className="ago-message__tail";const E=h({position:"absolute",zIndex:"1",bottom:"0",width:"10px",height:"20px",background:Pe});E.className="ago-message__tail-mask",f?(C.style.right="-8px",C.style.borderBottomLeftRadius="15px",E.style.right="-10px",E.style.borderBottomLeftRadius="10px"):(C.style.left="-7px",C.style.borderBottomRightRadius="15px",E.style.left="-10px",E.style.borderBottomRightRadius="10px"),$.append(C,E)}if(e.content?$.appendChild(re(e.content)):e.status==="IN_PROGRESS"&&$.appendChild(ct()),_.appendChild($),n&&e.followUpReplies&&e.followUpReplies.length>0){const C=h({display:"flex",flexWrap:"wrap",gap:"8px",marginTop:"10px"});C.className="ago-message__followups";for(const E of e.followUpReplies){const R=document.createElement("button");R.type="button",R.className="ago-message__followup-btn",R.textContent=E,R.disabled=!_e,v(R,{padding:"6px 14px",fontSize:"14px",borderRadius:Ce,border:`1px solid ${N}`,backgroundColor:K,color:te,cursor:_e?"pointer":"default",transition:"border-color 0.15s"}),ke&&R.addEventListener("click",()=>ke(E)),R.addEventListener("mouseenter",()=>{R.style.borderColor=be}),R.addEventListener("mouseleave",()=>{R.style.borderColor=N}),C.appendChild(R)}_.appendChild(C)}return _}function at(e){const n=h({display:"flex",alignItems:"center",gap:"8px",padding:"10px 14px",backgroundColor:"#f0fdf4",color:"#15803d",borderRadius:Ce,marginTop:"8px",fontSize:"13px",border:"1px solid #bbf7d0"});n.className="ago-form-notice",n.setAttribute("role","status");const i=document.createElement("span");i.textContent="✓",i.setAttribute("aria-hidden","true"),v(i,{fontWeight:"700"});const f=document.createElement("span");return f.textContent=e,n.append(i,f),n}function I(){if(T.replaceChildren(),d.length===0){const n=h({textAlign:"center",color:bt,padding:"24px 16px",fontSize:"16px",lineHeight:"1.5"});n.appendChild(re(t)),T.appendChild(n)}else d.forEach((n,i)=>{const f=i===d.length-1||d[i+1].role!==n.role;T.appendChild(rt(n,i===d.length-1,f))});for(const n of Re)T.appendChild(at(n));if(X){const n=h({padding:"10px 14px",backgroundColor:"#fef2f2",color:"#dc2626",borderRadius:"12px",marginTop:"8px",fontSize:"13px",border:"1px solid #fecaca"});n.textContent=X,T.appendChild(n)}T.scrollTop=T.scrollHeight;const e=d[d.length-1];ot(D&&e?.role==="assistant"&&e.status==="IN_PROGRESS")}function st(){for(let e=d.length-1;e>=0;e--){const n=d[e];if(n.role==="assistant"&&n.status==="IN_PROGRESS")return n}}const Ae=e=>{A||(A=e.conversationId)},Ie=e=>{const n=st();n&&(n.content+=e.content,I())},$e=e=>{const n=d.findIndex(i=>i.id===e.id||i.role==="assistant"&&i.status==="IN_PROGRESS");n>=0?d[n]=e:d.push(e),I(),de()},Ne=e=>{const n=d.findIndex(i=>i.id===e.id||i.role==="assistant"&&i.status==="IN_PROGRESS");n>=0?d[n]=e:d.push(e),D=!1,I(),e.status==="DONE"&&Je?.({id:e.id,content:e.content})},Le=e=>{X=e.error,D=!1,d=d.filter(n=>!n.id.startsWith("temp-")),I()};m.on("message:start",Ae),m.on("message:chunk",Ie),m.on("message:answer-complete",$e),m.on("message:complete",Ne),m.on("message:error",Le);const Te=e=>se?.(e),Oe=e=>ie?.(e);se&&m.on("form:submitted",Te),ie&&m.on("form:error",Oe);const pe=[];let Be=!1;const De=e=>{if(Be)return;pe.push(e.install(m));let n=e.store.get().submitted;const i=e.store.subscribe(f=>{f.submitted&&!n&&(Re.push(tt(f.submitResult)),I()),n=f.submitted});pe.push(i)};for(const e of we??[])e.schema!=null?De(ze.createFormCollector(e)):ze.loadFormCollector(m,e).then(n=>De(n)).catch(()=>{});async function fe(e,n){const i=e.trim();if(!i&&!n?.length||D)return;Ze?.(i),D=!0,X=null;const f=Date.now();d.push({id:`temp-user-${f}`,conversationId:A||"",content:i,role:"user",status:"DONE",createdAt:new Date}),d.push({id:`temp-assistant-${f}`,conversationId:A||"",content:"",role:"assistant",status:"IN_PROGRESS",createdAt:new Date}),I();try{const y=await m.sendMessage(i,{conversationId:A,files:n});y.conversationId&&(A||(A=y.conversationId),Y?.setActiveThread(y.conversationId,y.createdAt));const _=d.find(S=>S.id===`temp-user-${f}`);if(_&&(_.id=`user-${f}`,_.conversationId=y.conversationId),!d.some(S=>S.id===y.id)){const S=d.findIndex($=>$.id===`temp-assistant-${f}`);S>=0?d[S]=y:d.push(y)}d=d.filter(S=>!S.id.startsWith("temp-")),D=!1,I(),O&&ue()}catch(y){X=y instanceof Error?y.message:"Failed to send message",D=!1,d=d.filter(_=>!_.id.startsWith("temp-")),I()}}async function ue(){try{const e=await m.getConversations();Z.splice(0,Z.length,...e)}catch{}return Z}async function it(e){try{const n=(await m.getConversation(e))?.messages??[];n.length>0&&d.length===0&&(d=n,I())}catch{d.length===0&&(Y?.clear(),A=void 0)}}return I(),de(),A&&it(A),O&&ue(),{client:m,element:J,sendMessage:fe,...W?{open:me,close:he,toggle:lt}:{},session:Y,threads:Z,refreshThreads:ue,destroy(){m.off("message:start",Ae),m.off("message:chunk",Ie),m.off("message:answer-complete",$e),m.off("message:complete",Ne),m.off("message:error",Le),se&&m.off("form:submitted",Te),ie&&m.off("form:error",Oe),Be=!0,pe.forEach(e=>e()),J.remove(),w?.remove(),o.client||m.destroy()}};function ge(){if(!F)return;const e=l==="left"?"translateX(-100%)":"translateX(100%)";F.style.transform=P?"translateX(0)":e,F.setAttribute("aria-hidden",P?"false":"true"),w&&(w.style.display=P?"none":"flex")}function me(){P=!0,ge(),de()}function he(){P=!1,ge()}function lt(){P?he():me()}function dt(){const e="http://www.w3.org/2000/svg",n=document.createElementNS(e,"svg");n.setAttribute("width","26"),n.setAttribute("height","26"),n.setAttribute("viewBox","0 0 24 24"),n.setAttribute("fill","none");const i=document.createElementNS(e,"path");return i.setAttribute("d","M21 11.5a8.38 8.38 0 0 1-8.5 8.5 8.5 8.5 0 0 1-3.8-.9L3 21l1.9-5.7a8.5 8.5 0 0 1-.9-3.8 8.38 8.38 0 0 1 8.5-8.5 8.38 8.38 0 0 1 8.5 8.5z"),i.setAttribute("stroke","currentColor"),i.setAttribute("stroke-width","2"),i.setAttribute("stroke-linecap","round"),i.setAttribute("stroke-linejoin","round"),n.appendChild(i),n}function ct(){const e=h({display:"flex",gap:"4px",padding:"4px 0"});for(let n=0;n<3;n++){const i=h({width:"6px",height:"6px",borderRadius:"50%",backgroundColor:"#b5bfc8",animation:"ago-pulse 1.2s ease-in-out infinite",animationDelay:`${n*.2}s`});e.appendChild(i)}return e}}function Rt(r){let o=[];const a=document.createElement("form");v(a,{display:"flex",flexDirection:"column",gap:"8px",padding:"12px",borderTop:`1px solid ${N}`,backgroundColor:K}),a.className="ago-chat-input";const t=h({display:"flex",flexWrap:"wrap",gap:"6px"}),g=h({display:"flex",gap:"8px",alignItems:"flex-end"}),s=document.createElement("textarea");s.placeholder=r.placeholder,s.rows=1,v(s,{flex:"1",resize:"none",padding:"10px 12px",border:`1px solid ${N}`,borderRadius:"12px",fontSize:"16px",fontFamily:ve,lineHeight:"1.4",maxHeight:"120px",outline:"none"});const u=document.createElement("button");u.type="submit",u.textContent="Send",v(u,{padding:"10px 16px",border:"none",borderRadius:"12px",backgroundColor:oe,color:Ee,fontSize:"16px",fontWeight:"500",cursor:"pointer"});let l=null,p=null;r.allowFiles&&(l=document.createElement("input"),l.type="file",l.multiple=!0,v(l,{display:"none"}),p=document.createElement("button"),p.type="button",p.textContent="📎",v(p,{padding:"10px 12px",border:`1px solid ${N}`,borderRadius:"12px",backgroundColor:K,cursor:"pointer",fontSize:"14px"}),p.addEventListener("click",()=>l?.click()),l.addEventListener("change",()=>{o=[...o,...Array.from(l?.files??[])],c()}));function c(){t.replaceChildren(),o.forEach((b,L)=>{const V=h({display:"flex",alignItems:"center",gap:"4px",padding:"4px 8px",backgroundColor:"#f0f4ff",border:`1px solid ${N}`,borderRadius:"8px",fontSize:"12px"}),Q=document.createElement("span");Q.textContent=b.name;const O=document.createElement("button");O.type="button",O.textContent="×",v(O,{border:"none",background:"transparent",cursor:"pointer",fontSize:"14px",lineHeight:"1"}),O.addEventListener("click",()=>{o=o.filter((we,U)=>U!==L),c()}),V.append(Q,O),t.appendChild(V)})}const x=()=>{const b=s.value,L=o;return s.value="",o=[],c(),{content:b,files:L}},B=()=>{const{content:b,files:L}=x();(b.trim()||L.length>0)&&r.onSend(b.trim(),L.length>0?L:void 0)};return a.addEventListener("submit",b=>{b.preventDefault(),B()}),s.addEventListener("keydown",b=>{b.key==="Enter"&&!b.shiftKey&&(b.preventDefault(),B())}),p&&g.appendChild(p),g.append(s,u),l&&a.appendChild(l),a.append(t,g),{inputRow:a,getValueAndClear:x,setDisabled:b=>{s.disabled=b,u.disabled=b,u.style.opacity=b?"0.6":"1",u.style.cursor=b?"not-allowed":"pointer"},focus:()=>s.focus()}}exports.mountChatWidget=St;exports.renderMarkdown=re;
package/dist/widget.d.cts CHANGED
@@ -633,7 +633,7 @@ declare interface FormCollectorDefinition<V = Record<string, unknown>> {
633
633
 
634
634
  /**
635
635
  * Shape of a form's fields. Mirrors a client function's `parameters` (so the same
636
- * 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).
637
637
  */
638
638
  declare interface FormCollectorSchema {
639
639
  type: "object";
@@ -650,17 +650,32 @@ declare interface FormField {
650
650
  }
651
651
 
652
652
  /**
653
- * A field's conditional-requiredness rule. The field becomes required exactly
654
- * when the controlling `property` matches `value` against the answers collected
655
- * 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:
656
673
  * - a single `value`, no `op` — equality (compared as strings);
657
674
  * - a single `value` with `op` — numeric comparison (both sides coerced to numbers);
658
675
  * - an array `value`, no `op` — "one of": matches when the property equals any
659
676
  * listed value.
660
- *
661
- * SDK-only — it is stripped from the schema before it reaches the LLM tool
662
677
  */
663
- declare interface FormFieldCondition {
678
+ declare interface FormFieldLeafCondition {
664
679
  /** The controlling field whose value the rule tests. */
665
680
  property: string;
666
681
  /** Comparison operator; omitted means equality. Ignored when `value` is an array. */
@@ -681,7 +696,8 @@ declare interface FormFieldSchema {
681
696
  default?: unknown;
682
697
  /**
683
698
  * Makes the field required only while this condition holds. Drives the dynamic
684
- * `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}.
685
701
  */
686
702
  requiredWhen?: FormFieldCondition;
687
703
  }
@@ -801,6 +817,24 @@ export declare interface MountChatWidgetOptions {
801
817
  logoUrl?: string;
802
818
  /** Show the agent name above assistant messages. Defaults to `false`. */
803
819
  showAgentName?: boolean;
820
+ /** Render assistant messages inside a filled bubble (themed via `agentBubbleBg`). Defaults to `false`. */
821
+ agentBubble?: boolean;
822
+ /**
823
+ * Bubble shape preset. `"imessage"` bubbles both sides (assistant messages get
824
+ * the filled `agentBubbleBg` bubble too) and draws the iMessage "tail" curl on
825
+ * the last bubble of each same-sender run. Defaults to `"default"` (current
826
+ * look). Colors stay themed: user bubble `brand`, assistant bubble
827
+ * `agentBubbleBg`, and the tail mask follows `messagesBg`.
828
+ */
829
+ bubbleStyle?: "default" | "imessage";
830
+ /**
831
+ * Show the header bar (title, logo, and the side-panel close "×"). Set `false`
832
+ * to drop it, e.g. when the host page already frames the widget. Defaults to
833
+ * `true`. Note: with the built-in launcher in side placement, the close "×"
834
+ * lives in the header, so hiding it leaves the launcher (and `widget.close()`)
835
+ * as the way to dismiss the panel.
836
+ */
837
+ showHeader?: boolean;
804
838
  /**
805
839
  * Theme overrides so the panel blends into the host page.
806
840
  */
@@ -1020,6 +1054,8 @@ export declare interface WidgetTheme {
1020
1054
  border?: string;
1021
1055
  /** Secondary accent: source badges and suggested-reply hover outline. (`--ago-accent-color`) */
1022
1056
  accent?: string;
1057
+ /** Background of assistant message bubbles when `agentBubble` is on. Defaults to a light gray. (`--ago-agent-bubble-background`) */
1058
+ agentBubbleBg?: string;
1023
1059
  }
1024
1060
 
1025
1061
  export { }
package/dist/widget.d.ts CHANGED
@@ -633,7 +633,7 @@ declare interface FormCollectorDefinition<V = Record<string, unknown>> {
633
633
 
634
634
  /**
635
635
  * Shape of a form's fields. Mirrors a client function's `parameters` (so the same
636
- * 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).
637
637
  */
638
638
  declare interface FormCollectorSchema {
639
639
  type: "object";
@@ -650,17 +650,32 @@ declare interface FormField {
650
650
  }
651
651
 
652
652
  /**
653
- * A field's conditional-requiredness rule. The field becomes required exactly
654
- * when the controlling `property` matches `value` against the answers collected
655
- * 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:
656
673
  * - a single `value`, no `op` — equality (compared as strings);
657
674
  * - a single `value` with `op` — numeric comparison (both sides coerced to numbers);
658
675
  * - an array `value`, no `op` — "one of": matches when the property equals any
659
676
  * listed value.
660
- *
661
- * SDK-only — it is stripped from the schema before it reaches the LLM tool
662
677
  */
663
- declare interface FormFieldCondition {
678
+ declare interface FormFieldLeafCondition {
664
679
  /** The controlling field whose value the rule tests. */
665
680
  property: string;
666
681
  /** Comparison operator; omitted means equality. Ignored when `value` is an array. */
@@ -681,7 +696,8 @@ declare interface FormFieldSchema {
681
696
  default?: unknown;
682
697
  /**
683
698
  * Makes the field required only while this condition holds. Drives the dynamic
684
- * `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}.
685
701
  */
686
702
  requiredWhen?: FormFieldCondition;
687
703
  }
@@ -801,6 +817,24 @@ export declare interface MountChatWidgetOptions {
801
817
  logoUrl?: string;
802
818
  /** Show the agent name above assistant messages. Defaults to `false`. */
803
819
  showAgentName?: boolean;
820
+ /** Render assistant messages inside a filled bubble (themed via `agentBubbleBg`). Defaults to `false`. */
821
+ agentBubble?: boolean;
822
+ /**
823
+ * Bubble shape preset. `"imessage"` bubbles both sides (assistant messages get
824
+ * the filled `agentBubbleBg` bubble too) and draws the iMessage "tail" curl on
825
+ * the last bubble of each same-sender run. Defaults to `"default"` (current
826
+ * look). Colors stay themed: user bubble `brand`, assistant bubble
827
+ * `agentBubbleBg`, and the tail mask follows `messagesBg`.
828
+ */
829
+ bubbleStyle?: "default" | "imessage";
830
+ /**
831
+ * Show the header bar (title, logo, and the side-panel close "×"). Set `false`
832
+ * to drop it, e.g. when the host page already frames the widget. Defaults to
833
+ * `true`. Note: with the built-in launcher in side placement, the close "×"
834
+ * lives in the header, so hiding it leaves the launcher (and `widget.close()`)
835
+ * as the way to dismiss the panel.
836
+ */
837
+ showHeader?: boolean;
804
838
  /**
805
839
  * Theme overrides so the panel blends into the host page.
806
840
  */
@@ -1020,6 +1054,8 @@ export declare interface WidgetTheme {
1020
1054
  border?: string;
1021
1055
  /** Secondary accent: source badges and suggested-reply hover outline. (`--ago-accent-color`) */
1022
1056
  accent?: string;
1057
+ /** Background of assistant message bubbles when `agentBubble` is on. Defaults to a light gray. (`--ago-agent-bubble-background`) */
1058
+ agentBubbleBg?: string;
1023
1059
  }
1024
1060
 
1025
1061
  export { }