@useago/sdk 1.0.8 → 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.
@@ -495,7 +495,7 @@ declare interface FormCollectorDefinition<V = Record<string, unknown>> {
495
495
 
496
496
  /**
497
497
  * Shape of a form's fields. Mirrors a client function's `parameters` (so the same
498
- * 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.
498
+ * 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).
499
499
  */
500
500
  declare interface FormCollectorSchema {
501
501
  type: "object";
@@ -512,17 +512,32 @@ declare interface FormField {
512
512
  }
513
513
 
514
514
  /**
515
- * A field's conditional-requiredness rule. The field becomes required exactly
516
- * when the controlling `property` matches `value` against the answers collected
517
- * so far:
515
+ * A field's conditional-requiredness rule: either a single {@link FormFieldLeafCondition}
516
+ * or a boolean combination of rules. `anyOf` is OR (true when any nested rule
517
+ * holds); `allOf` is AND (true when every nested rule holds). Both nest
518
+ * arbitrarily, so you can mix them, e.g.
519
+ * `{ anyOf: [{ property: "a", op: ">=", value: 1 }, { property: "b", value: "1" }] }`.
520
+ * An empty `anyOf` is never required; an empty `allOf` is always required.
521
+ *
522
+ * Stripped from the LLM tool's `parameters` (see {@link toWireParameters}), but the
523
+ * full schema, `requiredWhen` included, still reaches the agent via the dynamic
524
+ * context so it knows when each field becomes required.
525
+ */
526
+ declare type FormFieldCondition = FormFieldLeafCondition | {
527
+ anyOf: FormFieldCondition[];
528
+ } | {
529
+ allOf: FormFieldCondition[];
530
+ };
531
+
532
+ /**
533
+ * A single leaf comparison. The field it guards becomes required exactly when the
534
+ * controlling `property` matches `value` against the answers collected so far:
518
535
  * - a single `value`, no `op` — equality (compared as strings);
519
536
  * - a single `value` with `op` — numeric comparison (both sides coerced to numbers);
520
537
  * - an array `value`, no `op` — "one of": matches when the property equals any
521
538
  * listed value.
522
- *
523
- * SDK-only — it is stripped from the schema before it reaches the LLM tool
524
539
  */
525
- declare interface FormFieldCondition {
540
+ declare interface FormFieldLeafCondition {
526
541
  /** The controlling field whose value the rule tests. */
527
542
  property: string;
528
543
  /** Comparison operator; omitted means equality. Ignored when `value` is an array. */
@@ -543,7 +558,8 @@ declare interface FormFieldSchema {
543
558
  default?: unknown;
544
559
  /**
545
560
  * Makes the field required only while this condition holds. Drives the dynamic
546
- * `missing` list; stripped before the LLM tool — see {@link toWireParameters}.
561
+ * `missing` list; stripped from the LLM tool's `parameters` (still sent to the
562
+ * agent via dynamic context). See {@link toWireParameters}.
547
563
  */
548
564
  requiredWhen?: FormFieldCondition;
549
565
  }
package/dist/index.cjs CHANGED
@@ -1 +1 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("./AgoClient-B3-WGVne.cjs"),f=require("./createFormCollector-BHHEW6uX.cjs"),p=require("./createConversationSession-BwYNMZWq.cjs"),w=require("./createMockClient-zHQ0cjUH.cjs");require("./testing.cjs");const g=require("./functions-Djnq-JAo.cjs");function h(e){return e}function E(e,o){return e.on("message:complete",o),()=>e.off("message:complete",o)}function S(e,o){return e.on("message:chunk",o),()=>e.off("message:chunk",o)}function y(e,o){return e.on("message:start",o),()=>e.off("message:start",o)}function b(e,o){return e.on("message:error",o),()=>e.off("message:error",o)}function F(e,o){return e.on("toolCall:received",o),()=>e.off("toolCall:received",o)}function v(e,o){return e.on("form:submitted",o),()=>e.off("form:submitted",o)}function M(e,o){return e.on("form:error",o),()=>e.off("form:error",o)}function q(e,o){return e.on("function:invoke",o),()=>e.off("function:invoke",o)}async function*k(e,o,l){const a=[];let r=null,s=!1;const m=i=>{a.push(i),r?.()},c=i=>m({type:"start",data:i}),t=i=>m({type:"chunk",data:i}),u=i=>{m({type:"complete",data:i}),s=!0,r?.()},d=i=>{m({type:"error",data:i}),s=!0,r?.()},C=i=>m({type:"toolCall",data:i});e.on("message:start",c),e.on("message:chunk",t),e.on("message:complete",u),e.on("message:error",d),e.on("toolCall:received",C),e.sendMessage(o,l).catch(()=>{s=!0,r?.()});try{for(;!s||a.length>0;)a.length>0?yield a.shift():(await new Promise(i=>{r=i}),r=null)}finally{e.off("message:start",c),e.off("message:chunk",t),e.off("message:complete",u),e.off("message:error",d),e.off("toolCall:received",C)}}function A(e){let o,l,a,r,s,m;if(typeof window<"u"&&window.AGO){const t=window.AGO;o=t.basepath,l=t.widgetId,a=t.agent||t.defaultAgent,r=t.permission,s=t.email,m=t.jwt}if(typeof document<"u"){const t=u=>document.querySelector(`meta[name="${u}"]`)?.getAttribute("content")||void 0;o=o||t("ago-base-url"),l=l||t("ago-widget-id"),a=a||t("ago-agent")||t("ago-agent-id"),r=r||t("ago-permission"),s=s||t("ago-user-email")}if(typeof document<"u"){const t=[document.body,...Array.from(document.querySelectorAll("script[data-ago-base-url]"))].filter(Boolean);for(const u of t)u&&(o=o||u.getAttribute("data-ago-base-url")||void 0,l=l||u.getAttribute("data-ago-widget-id")||void 0,a=a||u.getAttribute("data-ago-agent")||u.getAttribute("data-ago-agent-id")||void 0,r=r||u.getAttribute("data-ago-permission")||void 0,s=s||u.getAttribute("data-ago-user-email")||void 0)}o=e?.baseUrl||o,l=e?.widgetId||l,a=e?.agent||e?.defaultAgentId||a,r=e?.permission||r,s=e?.userEmail||s,m=e?.userJwt||m;const c=e?.debug;return o?{baseUrl:o,widgetId:l,agent:a,permission:r,userEmail:s,userJwt:m,debug:c}:null}function T(e){const o=A(e);if(!o)throw new n.AgoError('createAgo(): could not detect AGO configuration. Set window.AGO, add <meta name="ago-base-url">, or pass { baseUrl } explicitly.',"config_missing_base_url");return new n.AgoClient(o)}function _(e,o){return{...e,handler:o}}exports.AgoApiError=n.AgoApiError;exports.AgoClient=n.AgoClient;exports.AgoError=n.AgoError;exports.AgoFunctionError=n.AgoFunctionError;exports.AgoNetworkError=n.AgoNetworkError;exports.AgoStreamError=n.AgoStreamError;exports.ClientContextRegistry=n.ClientContextRegistry;exports.EventEmitter=n.EventEmitter;exports.FunctionRegistry=n.FunctionRegistry;exports.SSEHandler=n.SSEHandler;exports.autoDetectConfig=A;exports.copyToClipboard=g.copyToClipboard;exports.createAgo=T;exports.createConversationSession=p.createConversationSession;exports.createFormCollector=f.createFormCollector;exports.createMessageStream=k;exports.createMockClient=w.createMockClient;exports.createStore=f.createStore;exports.defineFunction=h;exports.deriveFormStatus=f.deriveFormStatus;exports.getLocalStorage=g.getLocalStorage;exports.getUserLocation=g.getUserLocation;exports.highlightElement=g.highlightElement;exports.isStreamNetworkError=n.isStreamNetworkError;exports.loadFormCollector=f.loadFormCollector;exports.logger=n.logger;exports.onFormError=M;exports.onFormSubmitted=v;exports.onFunctionInvoke=q;exports.onMessage=E;exports.onMessageChunk=S;exports.onMessageError=b;exports.onMessageStart=y;exports.onToolCall=F;exports.openUrl=g.openUrl;exports.scrollToElement=g.scrollToElement;exports.setLocalStorage=g.setLocalStorage;exports.setTheme=g.setTheme;exports.showConfirmDialog=g.showConfirmDialog;exports.showNotification=g.showNotification;exports.showToast=g.showToast;exports.submitForm=g.submitForm;exports.trackEvent=g.trackEvent;exports.validateConfig=n.validateConfig;exports.withHandler=_;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("./AgoClient-B3-WGVne.cjs"),f=require("./createFormCollector-BI3DXaew.cjs"),p=require("./createConversationSession-C0diFTUk.cjs"),w=require("./createMockClient-zHQ0cjUH.cjs");require("./testing.cjs");const g=require("./functions-Djnq-JAo.cjs");function h(e){return e}function E(e,o){return e.on("message:complete",o),()=>e.off("message:complete",o)}function S(e,o){return e.on("message:chunk",o),()=>e.off("message:chunk",o)}function y(e,o){return e.on("message:start",o),()=>e.off("message:start",o)}function b(e,o){return e.on("message:error",o),()=>e.off("message:error",o)}function F(e,o){return e.on("toolCall:received",o),()=>e.off("toolCall:received",o)}function v(e,o){return e.on("form:submitted",o),()=>e.off("form:submitted",o)}function M(e,o){return e.on("form:error",o),()=>e.off("form:error",o)}function q(e,o){return e.on("function:invoke",o),()=>e.off("function:invoke",o)}async function*k(e,o,l){const a=[];let r=null,s=!1;const m=i=>{a.push(i),r?.()},c=i=>m({type:"start",data:i}),t=i=>m({type:"chunk",data:i}),u=i=>{m({type:"complete",data:i}),s=!0,r?.()},d=i=>{m({type:"error",data:i}),s=!0,r?.()},C=i=>m({type:"toolCall",data:i});e.on("message:start",c),e.on("message:chunk",t),e.on("message:complete",u),e.on("message:error",d),e.on("toolCall:received",C),e.sendMessage(o,l).catch(()=>{s=!0,r?.()});try{for(;!s||a.length>0;)a.length>0?yield a.shift():(await new Promise(i=>{r=i}),r=null)}finally{e.off("message:start",c),e.off("message:chunk",t),e.off("message:complete",u),e.off("message:error",d),e.off("toolCall:received",C)}}function A(e){let o,l,a,r,s,m;if(typeof window<"u"&&window.AGO){const t=window.AGO;o=t.basepath,l=t.widgetId,a=t.agent||t.defaultAgent,r=t.permission,s=t.email,m=t.jwt}if(typeof document<"u"){const t=u=>document.querySelector(`meta[name="${u}"]`)?.getAttribute("content")||void 0;o=o||t("ago-base-url"),l=l||t("ago-widget-id"),a=a||t("ago-agent")||t("ago-agent-id"),r=r||t("ago-permission"),s=s||t("ago-user-email")}if(typeof document<"u"){const t=[document.body,...Array.from(document.querySelectorAll("script[data-ago-base-url]"))].filter(Boolean);for(const u of t)u&&(o=o||u.getAttribute("data-ago-base-url")||void 0,l=l||u.getAttribute("data-ago-widget-id")||void 0,a=a||u.getAttribute("data-ago-agent")||u.getAttribute("data-ago-agent-id")||void 0,r=r||u.getAttribute("data-ago-permission")||void 0,s=s||u.getAttribute("data-ago-user-email")||void 0)}o=e?.baseUrl||o,l=e?.widgetId||l,a=e?.agent||e?.defaultAgentId||a,r=e?.permission||r,s=e?.userEmail||s,m=e?.userJwt||m;const c=e?.debug;return o?{baseUrl:o,widgetId:l,agent:a,permission:r,userEmail:s,userJwt:m,debug:c}:null}function T(e){const o=A(e);if(!o)throw new n.AgoError('createAgo(): could not detect AGO configuration. Set window.AGO, add <meta name="ago-base-url">, or pass { baseUrl } explicitly.',"config_missing_base_url");return new n.AgoClient(o)}function _(e,o){return{...e,handler:o}}exports.AgoApiError=n.AgoApiError;exports.AgoClient=n.AgoClient;exports.AgoError=n.AgoError;exports.AgoFunctionError=n.AgoFunctionError;exports.AgoNetworkError=n.AgoNetworkError;exports.AgoStreamError=n.AgoStreamError;exports.ClientContextRegistry=n.ClientContextRegistry;exports.EventEmitter=n.EventEmitter;exports.FunctionRegistry=n.FunctionRegistry;exports.SSEHandler=n.SSEHandler;exports.autoDetectConfig=A;exports.copyToClipboard=g.copyToClipboard;exports.createAgo=T;exports.createConversationSession=p.createConversationSession;exports.createFormCollector=f.createFormCollector;exports.createMessageStream=k;exports.createMockClient=w.createMockClient;exports.createStore=f.createStore;exports.defineFunction=h;exports.deriveFormStatus=f.deriveFormStatus;exports.getLocalStorage=g.getLocalStorage;exports.getUserLocation=g.getUserLocation;exports.highlightElement=g.highlightElement;exports.isStreamNetworkError=n.isStreamNetworkError;exports.loadFormCollector=f.loadFormCollector;exports.logger=n.logger;exports.onFormError=M;exports.onFormSubmitted=v;exports.onFunctionInvoke=q;exports.onMessage=E;exports.onMessageChunk=S;exports.onMessageError=b;exports.onMessageStart=y;exports.onToolCall=F;exports.openUrl=g.openUrl;exports.scrollToElement=g.scrollToElement;exports.setLocalStorage=g.setLocalStorage;exports.setTheme=g.setTheme;exports.showConfirmDialog=g.showConfirmDialog;exports.showNotification=g.showNotification;exports.showToast=g.showToast;exports.submitForm=g.submitForm;exports.trackEvent=g.trackEvent;exports.validateConfig=n.validateConfig;exports.withHandler=_;
package/dist/index.d.cts CHANGED
@@ -935,7 +935,7 @@ export declare interface FormCollectorDefinition<V = Record<string, unknown>> {
935
935
 
936
936
  /**
937
937
  * Shape of a form's fields. Mirrors a client function's `parameters` (so the same
938
- * 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.
938
+ * 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).
939
939
  */
940
940
  export declare interface FormCollectorSchema {
941
941
  type: "object";
@@ -975,17 +975,32 @@ export declare interface FormField {
975
975
  }
976
976
 
977
977
  /**
978
- * A field's conditional-requiredness rule. The field becomes required exactly
979
- * when the controlling `property` matches `value` against the answers collected
980
- * so far:
978
+ * A field's conditional-requiredness rule: either a single {@link FormFieldLeafCondition}
979
+ * or a boolean combination of rules. `anyOf` is OR (true when any nested rule
980
+ * holds); `allOf` is AND (true when every nested rule holds). Both nest
981
+ * arbitrarily, so you can mix them, e.g.
982
+ * `{ anyOf: [{ property: "a", op: ">=", value: 1 }, { property: "b", value: "1" }] }`.
983
+ * An empty `anyOf` is never required; an empty `allOf` is always required.
984
+ *
985
+ * Stripped from the LLM tool's `parameters` (see {@link toWireParameters}), but the
986
+ * full schema, `requiredWhen` included, still reaches the agent via the dynamic
987
+ * context so it knows when each field becomes required.
988
+ */
989
+ export declare type FormFieldCondition = FormFieldLeafCondition | {
990
+ anyOf: FormFieldCondition[];
991
+ } | {
992
+ allOf: FormFieldCondition[];
993
+ };
994
+
995
+ /**
996
+ * A single leaf comparison. The field it guards becomes required exactly when the
997
+ * controlling `property` matches `value` against the answers collected so far:
981
998
  * - a single `value`, no `op` — equality (compared as strings);
982
999
  * - a single `value` with `op` — numeric comparison (both sides coerced to numbers);
983
1000
  * - an array `value`, no `op` — "one of": matches when the property equals any
984
1001
  * listed value.
985
- *
986
- * SDK-only — it is stripped from the schema before it reaches the LLM tool
987
1002
  */
988
- declare interface FormFieldCondition {
1003
+ export declare interface FormFieldLeafCondition {
989
1004
  /** The controlling field whose value the rule tests. */
990
1005
  property: string;
991
1006
  /** Comparison operator; omitted means equality. Ignored when `value` is an array. */
@@ -999,14 +1014,15 @@ declare interface FormFieldCondition {
999
1014
  }
1000
1015
 
1001
1016
  /** A single field's schema: the wire-legal keys plus the SDK-only `requiredWhen`. */
1002
- declare interface FormFieldSchema {
1017
+ export declare interface FormFieldSchema {
1003
1018
  type: string;
1004
1019
  description?: string;
1005
1020
  enum?: string[];
1006
1021
  default?: unknown;
1007
1022
  /**
1008
1023
  * Makes the field required only while this condition holds. Drives the dynamic
1009
- * `missing` list; stripped before the LLM tool — see {@link toWireParameters}.
1024
+ * `missing` list; stripped from the LLM tool's `parameters` (still sent to the
1025
+ * agent via dynamic context). See {@link toWireParameters}.
1010
1026
  */
1011
1027
  requiredWhen?: FormFieldCondition;
1012
1028
  }
package/dist/index.d.ts CHANGED
@@ -935,7 +935,7 @@ export declare interface FormCollectorDefinition<V = Record<string, unknown>> {
935
935
 
936
936
  /**
937
937
  * Shape of a form's fields. Mirrors a client function's `parameters` (so the same
938
- * 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.
938
+ * 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).
939
939
  */
940
940
  export declare interface FormCollectorSchema {
941
941
  type: "object";
@@ -975,17 +975,32 @@ export declare interface FormField {
975
975
  }
976
976
 
977
977
  /**
978
- * A field's conditional-requiredness rule. The field becomes required exactly
979
- * when the controlling `property` matches `value` against the answers collected
980
- * so far:
978
+ * A field's conditional-requiredness rule: either a single {@link FormFieldLeafCondition}
979
+ * or a boolean combination of rules. `anyOf` is OR (true when any nested rule
980
+ * holds); `allOf` is AND (true when every nested rule holds). Both nest
981
+ * arbitrarily, so you can mix them, e.g.
982
+ * `{ anyOf: [{ property: "a", op: ">=", value: 1 }, { property: "b", value: "1" }] }`.
983
+ * An empty `anyOf` is never required; an empty `allOf` is always required.
984
+ *
985
+ * Stripped from the LLM tool's `parameters` (see {@link toWireParameters}), but the
986
+ * full schema, `requiredWhen` included, still reaches the agent via the dynamic
987
+ * context so it knows when each field becomes required.
988
+ */
989
+ export declare type FormFieldCondition = FormFieldLeafCondition | {
990
+ anyOf: FormFieldCondition[];
991
+ } | {
992
+ allOf: FormFieldCondition[];
993
+ };
994
+
995
+ /**
996
+ * A single leaf comparison. The field it guards becomes required exactly when the
997
+ * controlling `property` matches `value` against the answers collected so far:
981
998
  * - a single `value`, no `op` — equality (compared as strings);
982
999
  * - a single `value` with `op` — numeric comparison (both sides coerced to numbers);
983
1000
  * - an array `value`, no `op` — "one of": matches when the property equals any
984
1001
  * listed value.
985
- *
986
- * SDK-only — it is stripped from the schema before it reaches the LLM tool
987
1002
  */
988
- declare interface FormFieldCondition {
1003
+ export declare interface FormFieldLeafCondition {
989
1004
  /** The controlling field whose value the rule tests. */
990
1005
  property: string;
991
1006
  /** Comparison operator; omitted means equality. Ignored when `value` is an array. */
@@ -999,14 +1014,15 @@ declare interface FormFieldCondition {
999
1014
  }
1000
1015
 
1001
1016
  /** A single field's schema: the wire-legal keys plus the SDK-only `requiredWhen`. */
1002
- declare interface FormFieldSchema {
1017
+ export declare interface FormFieldSchema {
1003
1018
  type: string;
1004
1019
  description?: string;
1005
1020
  enum?: string[];
1006
1021
  default?: unknown;
1007
1022
  /**
1008
1023
  * Makes the field required only while this condition holds. Drives the dynamic
1009
- * `missing` list; stripped before the LLM tool — see {@link toWireParameters}.
1024
+ * `missing` list; stripped from the LLM tool's `parameters` (still sent to the
1025
+ * agent via dynamic context). See {@link toWireParameters}.
1010
1026
  */
1011
1027
  requiredWhen?: FormFieldCondition;
1012
1028
  }
package/dist/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import { a as h, c as A, d as y, f as C, i as E, l as b, m as S, o as v, p as F, r as M, s as k, t as T, u as I } from "./functions-CApuQZ2b.js";
2
2
  import { a as G, c as O, d as q, f as x, i as L, l as N, n as _, o as D, p as H, r as J, s as R, t as d, u as c } from "./AgoClient-QcTtrN7u.js";
3
- import { i as B, n as P, r as $, t as z } from "./createFormCollector-QyojCH_-.js";
4
- import { t as Q } from "./createConversationSession-DrCMdwkV.js";
3
+ import { i as B, n as P, r as $, t as z } from "./createFormCollector-CFt1_QSL.js";
4
+ import { t as Q } from "./createConversationSession-CR-71aLR.js";
5
5
  import { t as W } from "./createMockClient-DwdxNwEn.js";
6
6
  import "./testing.js";
7
7
  function Y(e) {
package/dist/react.cjs CHANGED
@@ -1,4 +1,4 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const P=require("./rolldown-runtime-16Nf8qvH.cjs"),J=require("./AgoClient-B3-WGVne.cjs"),M=require("./createFormCollector-BHHEW6uX.cjs"),V=require("./createMockClient-zHQ0cjUH.cjs");let n=require("react");n=P.__toESM(n,1);let o=require("react/jsx-runtime"),F=require("react-markdown");F=P.__toESM(F,1);let N=require("remark-gfm");N=P.__toESM(N,1);function q(e){const[t,s]=(0,n.useState)(!1),r=(0,n.useRef)(null),a=(0,n.useMemo)(()=>{if(r.current&&(r.current.destroy(),r.current=null),!e)return null;const l=new J.AgoClient(e);return r.current=l,l},[e?.baseUrl,e?.widgetId]);return(0,n.useEffect)(()=>(s(!0),()=>{r.current?.destroy(),r.current=null}),[a]),(0,n.useEffect)(()=>{r.current&&e&&r.current.updateConfig({agent:e.agent,defaultAgentId:e.defaultAgentId,permission:e.permission,userEmail:e.userEmail,userJwt:e.userJwt,debug:e.debug,warnOnEmptyReply:e.warnOnEmptyReply})},[e?.agent,e?.defaultAgentId,e?.permission,e?.userEmail,e?.userJwt,e?.debug,e?.warnOnEmptyReply]),{client:a,isReady:t}}var T=(0,n.createContext)(null),G=({children:e,client:t,tools:s,helpers:r,pageContext:a,...l})=>{const{client:u}=q(t?null:l),i=t||u;return(0,n.useEffect)(()=>{if(!(!s||s.length===0)){for(const p of s)i.register(p);return()=>{for(const p of s)i.unregisterFunction(p.name)}}},[i,s]),(0,n.useEffect)(()=>{if(!r)return;const p=[];return Promise.resolve().then(()=>require("./functions-Djnq-JAo.cjs")).then(d=>d.functions_exports).then(d=>{for(const[h,C]of Object.entries(r)){const k=d[h];if(!k){console.warn(`[AGO] Unknown helper: "${h}"`);continue}const m=C===!0?k:{...k,handler:C};i.register(m),p.push(m.name)}}),()=>{for(const d of p)i.unregisterFunction(d)}},[i,r]),(0,n.useEffect)(()=>{a==="auto"&&i.enableAutoPageContext()},[i,a]),(0,o.jsx)(T.Provider,{value:i,children:e})};function A(){const e=(0,n.useContext)(T);if(!e)throw new Error('useAgoClient must be used within an <AgoProvider>. Wrap your component tree with <AgoProvider baseUrl="...">.');return e}function R(){return(0,n.useContext)(T)}function L({client:e,conversationId:t}={}){const s=R(),r=e||s;if(!r)throw new Error("useMessages requires an AgoClient. Either pass it as options.client or wrap your app in <AgoProvider>.");const[a,l]=(0,n.useState)([]),[u,i]=(0,n.useState)(t),[p,d]=(0,n.useState)(!1),[h,C]=(0,n.useState)(null);(0,n.useEffect)(()=>{t&&t!==u&&(i(t),k(t))},[t]);const k=async m=>{try{l(await r.getMessages(m))}catch(v){C(v instanceof Error?v:new Error("Failed to load messages"))}};return(0,n.useEffect)(()=>{const m=x=>{u||i(x.conversationId)},v=x=>{l(f=>{const w=f[f.length-1];return w&&w.id===x.messageId?[...f.slice(0,-1),{...w,content:w.content+x.content}]:f})},c=x=>{l(f=>{let w=-1;for(let S=f.length-1;S>=0;S--)if(f[S].role==="assistant"&&f[S].status==="IN_PROGRESS"){w=S;break}return w<0?f:[...f.slice(0,w),{...f[w],...x},...f.slice(w+1)]})},y=x=>{l(f=>{const w=f.findIndex(S=>S.id===x.id);return w>=0?[...f.slice(0,w),x,...f.slice(w+1)]:[...f,x]}),d(!1)},g=x=>{C(new Error(x.error)),d(!1)};return r.on("message:start",m),r.on("message:chunk",v),r.on("message:answer-complete",c),r.on("message:complete",y),r.on("message:error",g),()=>{r.off("message:start",m),r.off("message:chunk",v),r.off("message:answer-complete",c),r.off("message:complete",y),r.off("message:error",g)}},[r,u]),{messages:a,isLoading:p,error:h,sendMessage:(0,n.useCallback)(async(m,v)=>{d(!0),C(null);const c={id:`temp-${Date.now()}`,conversationId:u||"",content:m,role:"user",status:"DONE",createdAt:new Date},y={id:`temp-assistant-${Date.now()}`,conversationId:u||"",content:"",role:"assistant",status:"IN_PROGRESS",createdAt:new Date};l(g=>[...g,c,y]);try{const g=await r.sendMessage(m,{conversationId:u,files:v});return g.conversationId&&!u&&i(g.conversationId),l(x=>{const f=x.filter(S=>!S.id.startsWith("temp-")),w={...c,id:c.id.replace("temp-","user-"),conversationId:g.conversationId};return f.some(S=>S.id===g.id)?[...f,w].sort((S,_)=>new Date(S.createdAt).getTime()-new Date(_.createdAt).getTime()):[...f,w,g]}),g}catch(g){return C(g instanceof Error?g:new Error("Failed to send message")),d(!1),l(x=>x.filter(f=>!f.id.startsWith("temp-"))),null}},[r,u]),clearMessages:(0,n.useCallback)(()=>{l([]),i(void 0),C(null)},[]),conversationId:u}}var W=({onSend:e,disabled:t=!1,placeholder:s="Type a message...",allowFiles:r=!1,className:a=""})=>{const[l,u]=(0,n.useState)(""),[i,p]=(0,n.useState)([]),d=(0,n.useRef)(null),h=(0,n.useCallback)(c=>{c.preventDefault(),(l.trim()||i.length>0)&&(e(l.trim(),i.length>0?i:void 0),u(""),p([]))},[l,i,e]),C=(0,n.useCallback)(c=>{c.key==="Enter"&&!c.shiftKey&&(c.preventDefault(),h(c))},[h]),k=(0,n.useCallback)(c=>{const y=Array.from(c.target.files||[]);p(g=>[...g,...y])},[]),m=(0,n.useCallback)(c=>{p(y=>y.filter((g,x)=>x!==c))},[]),v=l.trim()||i.length>0;return(0,o.jsxs)("form",{onSubmit:h,className:`ago-chat-input ${a}`,style:{display:"flex",flexDirection:"column",gap:"8px",padding:"12px 16px",borderTop:"1px solid #dee3e8",backgroundColor:"#fff"},children:[i.length>0&&(0,o.jsx)("div",{className:"ago-chat-input__files",style:{display:"flex",flexWrap:"wrap",gap:"6px"},children:i.map((c,y)=>(0,o.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:"6px",padding:"4px 10px",backgroundColor:"#f0f2f5",borderRadius:"6px",fontSize:"12px",color:"#30373e"},children:[(0,o.jsx)("span",{style:{maxWidth:"120px",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:c.name}),(0,o.jsx)("button",{type:"button",onClick:()=>m(y),style:{border:"none",background:"none",cursor:"pointer",padding:"0",color:"#6b6d6f",fontSize:"14px",lineHeight:1},children:"×"})]},y))}),(0,o.jsxs)("div",{style:{display:"flex",gap:"8px",alignItems:"flex-end"},children:[r&&(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)("button",{type:"button",onClick:()=>d.current?.click(),disabled:t,style:{padding:"8px",border:"1px solid #dee3e8",borderRadius:"8px",backgroundColor:"#fff",cursor:t?"not-allowed":"pointer",color:"#6b6d6f",fontSize:"16px",lineHeight:1},children:"+"}),(0,o.jsx)("input",{ref:d,type:"file",multiple:!0,onChange:k,style:{display:"none"}})]}),(0,o.jsx)("textarea",{value:l,onChange:c=>u(c.target.value),onKeyDown:C,placeholder:s,disabled:t,rows:1,style:{flex:1,padding:"10px 14px",border:"1px solid #dee3e8",borderRadius:"20px",resize:"none",outline:"none",fontFamily:"inherit",fontSize:"16px",color:"#30373e",backgroundColor:"#f8f8f8",transition:"border-color 0.15s"},onFocus:c=>{c.currentTarget.style.borderColor="#1b5fc4"},onBlur:c=>{c.currentTarget.style.borderColor="#dee3e8"}}),(0,o.jsx)("button",{type:"submit",disabled:t||!v,style:{padding:"10px 18px",border:"none",borderRadius:"20px",backgroundColor:t||!v?"#b5bfc8":"#03182f",color:"#fff",cursor:t||!v?"not-allowed":"pointer",fontWeight:500,fontSize:"16px",transition:"background-color 0.15s"},children:"Send"})]})]})},X=({href:e,children:t,...s})=>(0,o.jsx)("a",{href:e,target:"_blank",rel:"noopener noreferrer",style:{color:"#1b5fc4",textDecoration:"underline"},...s,children:t}),Y=({children:e,...t})=>(0,o.jsx)("p",{style:{margin:"0 0 8px 0",lineHeight:"1.6"},...t,children:e}),I=(e,t)=>{const s=({children:r,...a})=>n.default.createElement(`h${e}`,{style:{margin:"16px 0 8px 0",fontSize:t,fontWeight:600,lineHeight:"1.3"},...a},r);return s.displayName=`MarkdownHeading${e}`,s},Q=({children:e,...t})=>(0,o.jsx)("ul",{style:{margin:"0 0 8px 0",paddingLeft:"20px",listStyleType:"disc",listStylePosition:"outside"},...t,children:e}),Z=({children:e,...t})=>(0,o.jsx)("ol",{style:{margin:"0 0 8px 0",paddingLeft:"20px",listStyleType:"decimal",listStylePosition:"outside"},...t,children:e}),ee=({children:e,...t})=>(0,o.jsx)("li",{style:{display:"list-item",margin:"2px 0",lineHeight:"1.6"},...t,children:e}),te=({className:e,children:t,...s})=>e!==void 0||String(t).includes(`
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const P=require("./rolldown-runtime-16Nf8qvH.cjs"),J=require("./AgoClient-B3-WGVne.cjs"),M=require("./createFormCollector-BI3DXaew.cjs"),V=require("./createMockClient-zHQ0cjUH.cjs");let n=require("react");n=P.__toESM(n,1);let o=require("react/jsx-runtime"),F=require("react-markdown");F=P.__toESM(F,1);let N=require("remark-gfm");N=P.__toESM(N,1);function q(e){const[t,s]=(0,n.useState)(!1),r=(0,n.useRef)(null),a=(0,n.useMemo)(()=>{if(r.current&&(r.current.destroy(),r.current=null),!e)return null;const l=new J.AgoClient(e);return r.current=l,l},[e?.baseUrl,e?.widgetId]);return(0,n.useEffect)(()=>(s(!0),()=>{r.current?.destroy(),r.current=null}),[a]),(0,n.useEffect)(()=>{r.current&&e&&r.current.updateConfig({agent:e.agent,defaultAgentId:e.defaultAgentId,permission:e.permission,userEmail:e.userEmail,userJwt:e.userJwt,debug:e.debug,warnOnEmptyReply:e.warnOnEmptyReply})},[e?.agent,e?.defaultAgentId,e?.permission,e?.userEmail,e?.userJwt,e?.debug,e?.warnOnEmptyReply]),{client:a,isReady:t}}var T=(0,n.createContext)(null),G=({children:e,client:t,tools:s,helpers:r,pageContext:a,...l})=>{const{client:u}=q(t?null:l),i=t||u;return(0,n.useEffect)(()=>{if(!(!s||s.length===0)){for(const p of s)i.register(p);return()=>{for(const p of s)i.unregisterFunction(p.name)}}},[i,s]),(0,n.useEffect)(()=>{if(!r)return;const p=[];return Promise.resolve().then(()=>require("./functions-Djnq-JAo.cjs")).then(d=>d.functions_exports).then(d=>{for(const[h,C]of Object.entries(r)){const k=d[h];if(!k){console.warn(`[AGO] Unknown helper: "${h}"`);continue}const m=C===!0?k:{...k,handler:C};i.register(m),p.push(m.name)}}),()=>{for(const d of p)i.unregisterFunction(d)}},[i,r]),(0,n.useEffect)(()=>{a==="auto"&&i.enableAutoPageContext()},[i,a]),(0,o.jsx)(T.Provider,{value:i,children:e})};function A(){const e=(0,n.useContext)(T);if(!e)throw new Error('useAgoClient must be used within an <AgoProvider>. Wrap your component tree with <AgoProvider baseUrl="...">.');return e}function R(){return(0,n.useContext)(T)}function L({client:e,conversationId:t}={}){const s=R(),r=e||s;if(!r)throw new Error("useMessages requires an AgoClient. Either pass it as options.client or wrap your app in <AgoProvider>.");const[a,l]=(0,n.useState)([]),[u,i]=(0,n.useState)(t),[p,d]=(0,n.useState)(!1),[h,C]=(0,n.useState)(null);(0,n.useEffect)(()=>{t&&t!==u&&(i(t),k(t))},[t]);const k=async m=>{try{l(await r.getMessages(m))}catch(v){C(v instanceof Error?v:new Error("Failed to load messages"))}};return(0,n.useEffect)(()=>{const m=x=>{u||i(x.conversationId)},v=x=>{l(f=>{const w=f[f.length-1];return w&&w.id===x.messageId?[...f.slice(0,-1),{...w,content:w.content+x.content}]:f})},c=x=>{l(f=>{let w=-1;for(let S=f.length-1;S>=0;S--)if(f[S].role==="assistant"&&f[S].status==="IN_PROGRESS"){w=S;break}return w<0?f:[...f.slice(0,w),{...f[w],...x},...f.slice(w+1)]})},y=x=>{l(f=>{const w=f.findIndex(S=>S.id===x.id);return w>=0?[...f.slice(0,w),x,...f.slice(w+1)]:[...f,x]}),d(!1)},g=x=>{C(new Error(x.error)),d(!1)};return r.on("message:start",m),r.on("message:chunk",v),r.on("message:answer-complete",c),r.on("message:complete",y),r.on("message:error",g),()=>{r.off("message:start",m),r.off("message:chunk",v),r.off("message:answer-complete",c),r.off("message:complete",y),r.off("message:error",g)}},[r,u]),{messages:a,isLoading:p,error:h,sendMessage:(0,n.useCallback)(async(m,v)=>{d(!0),C(null);const c={id:`temp-${Date.now()}`,conversationId:u||"",content:m,role:"user",status:"DONE",createdAt:new Date},y={id:`temp-assistant-${Date.now()}`,conversationId:u||"",content:"",role:"assistant",status:"IN_PROGRESS",createdAt:new Date};l(g=>[...g,c,y]);try{const g=await r.sendMessage(m,{conversationId:u,files:v});return g.conversationId&&!u&&i(g.conversationId),l(x=>{const f=x.filter(S=>!S.id.startsWith("temp-")),w={...c,id:c.id.replace("temp-","user-"),conversationId:g.conversationId};return f.some(S=>S.id===g.id)?[...f,w].sort((S,_)=>new Date(S.createdAt).getTime()-new Date(_.createdAt).getTime()):[...f,w,g]}),g}catch(g){return C(g instanceof Error?g:new Error("Failed to send message")),d(!1),l(x=>x.filter(f=>!f.id.startsWith("temp-"))),null}},[r,u]),clearMessages:(0,n.useCallback)(()=>{l([]),i(void 0),C(null)},[]),conversationId:u}}var W=({onSend:e,disabled:t=!1,placeholder:s="Type a message...",allowFiles:r=!1,className:a=""})=>{const[l,u]=(0,n.useState)(""),[i,p]=(0,n.useState)([]),d=(0,n.useRef)(null),h=(0,n.useCallback)(c=>{c.preventDefault(),(l.trim()||i.length>0)&&(e(l.trim(),i.length>0?i:void 0),u(""),p([]))},[l,i,e]),C=(0,n.useCallback)(c=>{c.key==="Enter"&&!c.shiftKey&&(c.preventDefault(),h(c))},[h]),k=(0,n.useCallback)(c=>{const y=Array.from(c.target.files||[]);p(g=>[...g,...y])},[]),m=(0,n.useCallback)(c=>{p(y=>y.filter((g,x)=>x!==c))},[]),v=l.trim()||i.length>0;return(0,o.jsxs)("form",{onSubmit:h,className:`ago-chat-input ${a}`,style:{display:"flex",flexDirection:"column",gap:"8px",padding:"12px 16px",borderTop:"1px solid #dee3e8",backgroundColor:"#fff"},children:[i.length>0&&(0,o.jsx)("div",{className:"ago-chat-input__files",style:{display:"flex",flexWrap:"wrap",gap:"6px"},children:i.map((c,y)=>(0,o.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:"6px",padding:"4px 10px",backgroundColor:"#f0f2f5",borderRadius:"6px",fontSize:"12px",color:"#30373e"},children:[(0,o.jsx)("span",{style:{maxWidth:"120px",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:c.name}),(0,o.jsx)("button",{type:"button",onClick:()=>m(y),style:{border:"none",background:"none",cursor:"pointer",padding:"0",color:"#6b6d6f",fontSize:"14px",lineHeight:1},children:"×"})]},y))}),(0,o.jsxs)("div",{style:{display:"flex",gap:"8px",alignItems:"flex-end"},children:[r&&(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)("button",{type:"button",onClick:()=>d.current?.click(),disabled:t,style:{padding:"8px",border:"1px solid #dee3e8",borderRadius:"8px",backgroundColor:"#fff",cursor:t?"not-allowed":"pointer",color:"#6b6d6f",fontSize:"16px",lineHeight:1},children:"+"}),(0,o.jsx)("input",{ref:d,type:"file",multiple:!0,onChange:k,style:{display:"none"}})]}),(0,o.jsx)("textarea",{value:l,onChange:c=>u(c.target.value),onKeyDown:C,placeholder:s,disabled:t,rows:1,style:{flex:1,padding:"10px 14px",border:"1px solid #dee3e8",borderRadius:"20px",resize:"none",outline:"none",fontFamily:"inherit",fontSize:"16px",color:"#30373e",backgroundColor:"#f8f8f8",transition:"border-color 0.15s"},onFocus:c=>{c.currentTarget.style.borderColor="#1b5fc4"},onBlur:c=>{c.currentTarget.style.borderColor="#dee3e8"}}),(0,o.jsx)("button",{type:"submit",disabled:t||!v,style:{padding:"10px 18px",border:"none",borderRadius:"20px",backgroundColor:t||!v?"#b5bfc8":"#03182f",color:"#fff",cursor:t||!v?"not-allowed":"pointer",fontWeight:500,fontSize:"16px",transition:"background-color 0.15s"},children:"Send"})]})]})},X=({href:e,children:t,...s})=>(0,o.jsx)("a",{href:e,target:"_blank",rel:"noopener noreferrer",style:{color:"#1b5fc4",textDecoration:"underline"},...s,children:t}),Y=({children:e,...t})=>(0,o.jsx)("p",{style:{margin:"0 0 8px 0",lineHeight:"1.6"},...t,children:e}),I=(e,t)=>{const s=({children:r,...a})=>n.default.createElement(`h${e}`,{style:{margin:"16px 0 8px 0",fontSize:t,fontWeight:600,lineHeight:"1.3"},...a},r);return s.displayName=`MarkdownHeading${e}`,s},Q=({children:e,...t})=>(0,o.jsx)("ul",{style:{margin:"0 0 8px 0",paddingLeft:"20px",listStyleType:"disc",listStylePosition:"outside"},...t,children:e}),Z=({children:e,...t})=>(0,o.jsx)("ol",{style:{margin:"0 0 8px 0",paddingLeft:"20px",listStyleType:"decimal",listStylePosition:"outside"},...t,children:e}),ee=({children:e,...t})=>(0,o.jsx)("li",{style:{display:"list-item",margin:"2px 0",lineHeight:"1.6"},...t,children:e}),te=({className:e,children:t,...s})=>e!==void 0||String(t).includes(`
2
2
  `)?(0,o.jsx)("code",{style:{display:"block",background:"#f5f5f5",padding:"8px 12px",borderRadius:"6px",fontSize:"13px",overflowX:"auto",fontFamily:'"IBM Plex Mono", monospace'},...s,children:t}):(0,o.jsx)("code",{style:{background:"#f0f2f5",padding:"2px 5px",borderRadius:"4px",fontSize:"13px",fontFamily:'"IBM Plex Mono", monospace'},...s,children:t}),re=({children:e,...t})=>(0,o.jsx)("pre",{style:{margin:"0 0 8px 0"},...t,children:e}),ne=({children:e,...t})=>(0,o.jsx)("blockquote",{style:{borderLeft:"4px solid #dee3e8",paddingLeft:"12px",margin:"0 0 8px 0",fontStyle:"italic",color:"#6b6d6f"},...t,children:e}),oe=({children:e,...t})=>(0,o.jsx)("div",{style:{overflowX:"auto",margin:"0 0 8px 0"},children:(0,o.jsx)("table",{style:{borderCollapse:"collapse",width:"100%",fontSize:"13px"},...t,children:e})}),se=({children:e,...t})=>(0,o.jsx)("th",{style:{border:"1px solid #dee3e8",padding:"6px 10px",textAlign:"left",backgroundColor:"#f5f7fa",fontWeight:600},...t,children:e}),ae=({children:e,...t})=>(0,o.jsx)("td",{style:{border:"1px solid #dee3e8",padding:"6px 10px"},...t,children:e}),le=({alt:e,...t})=>(0,o.jsx)("img",{alt:e??"",style:{maxWidth:"100%",borderRadius:"8px",margin:"4px 0"},...t}),ie=e=>(0,o.jsx)("hr",{style:{border:"none",borderTop:"1px solid #dee3e8",margin:"12px 0"},...e}),ce={a:X,p:Y,h1:I(1,"20px"),h2:I(2,"18px"),h3:I(3,"16px"),h4:I(4,"15px"),h5:I(5,"14px"),h6:I(6,"13px"),ul:Q,ol:Z,li:ee,code:te,pre:re,blockquote:ne,table:oe,th:se,td:ae,img:le,hr:ie},de=[N.default],z=({content:e})=>(0,o.jsx)(F.default,{remarkPlugins:de,components:ce,children:e}),ue=({source:e,index:t})=>{const s=(0,o.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:"8px",width:"100%",minWidth:0},children:[(0,o.jsx)("div",{style:{flexShrink:0,width:"18px",height:"18px",borderRadius:"3px",border:"1px solid #1b5fc4",color:"#1b5fc4",fontSize:"11px",fontWeight:500,display:"flex",alignItems:"center",justifyContent:"center",backgroundColor:"#f0f4ff"},children:t+1}),(0,o.jsx)("div",{style:{fontSize:"12px",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",color:"#30373e"},title:e.title,children:e.title})]}),r={display:"flex",alignItems:"center",padding:"8px 10px",border:"1px solid #dee3e8",borderRadius:"8px",backgroundColor:"#fff",cursor:e.url?"pointer":"default",textDecoration:"none",color:"inherit",minWidth:0,transition:"border-color 0.15s"};return e.url?(0,o.jsx)("a",{href:e.url,target:"_blank",rel:"noopener noreferrer",style:r,onMouseEnter:a=>{a.currentTarget.style.borderColor="#1b5fc4"},onMouseLeave:a=>{a.currentTarget.style.borderColor="#dee3e8"},children:s}):(0,o.jsx)("div",{style:r,children:s})},fe=()=>(0,o.jsxs)("div",{style:{display:"flex",gap:"4px",padding:"4px 0"},children:[[0,1,2].map(e=>(0,o.jsx)("div",{style:{width:"6px",height:"6px",borderRadius:"50%",backgroundColor:"#b5bfc8",animation:"ago-pulse 1.2s ease-in-out infinite",animationDelay:`${e*.2}s`}},e)),(0,o.jsx)("style",{children:`
3
3
  @keyframes ago-pulse {
4
4
  0%, 80%, 100% { opacity: 0.3; transform: scale(0.8); }
package/dist/react.d.cts 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.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
  }