openclaw
Version:
Multi-channel AI gateway with extensible messaging integrations
2 lines • 36 kB
JavaScript
import{i as e}from"./transcript-record-coerce-CPLgmAk9.mjs";import{A as t,B as n,C as r,D as i,E as a,F as o,H as s,I as c,M as l,N as u,O as d,P as f,R as p,S as m,T as h,U as g,V as _,W as v,_ as y,a as b,b as x,c as S,d as C,f as w,h as T,i as E,j as D,k as O,w as k,x as A,z as j}from"./transcript-schemas-C_W5KYqZ.mjs";const M=Symbol.for(`zod.compile.invalid`),N=Symbol.for(`zod.compile.fallback`);var ZodCompileAsyncError=class extends Error{constructor(e=`z.compile does not support async refinements, transforms, or checks`){super(e),this.name=`ZodCompileAsyncError`}},ZodCompileUnsupportedError=class extends Error{constructor(e,t=!0){super(`z.compile does not support ${e}; this schema must use the runtime parser`),this.name=`ZodCompileUnsupportedError`,this.islandable=t}};function compileValidator(e,t){try{return compileFn(e,{assertOnly:!0})}catch{return t}}function compile(e,t){try{let t=compileFn(e),n=withParser(e,t);return n._zod.bag.validator=compileValidator(e,t),n}catch(n){if(t?.strict)throw n;return e}}function withParser(e,t){if(A(e))throw new ZodCompileUnsupportedError(`a schema whose subtree contains a reference cycle`);let n=p(e),r=e._zod.run,i=r.__originalRun??r,wrapped=(e,n)=>{if(n?.async||n?.direction===`backward`||n?.skipChecks||n?.[N]||n&&x(n,e.value))return i(e,n);let r=t(e.value);return r===M?(n&&(n[N]=!0),i(e,n)):(e.value=r,e)};return wrapped.__originalRun=i,n._zod.bag.fallbackRun=i,n._zod.bag.validator=t,n._zod.run=wrapped,r.__originalRun||installCompiledUserMethods(n,e,t),n}function installCompiledUserMethods(e,t,n){let r=e,i=t;if(typeof i.safeParse==`function`){let e=i.safeParse;r.safeParse=(t,r)=>{let i=n(t);return i===M?e(t,r):{success:!0,data:i}}}if(typeof i.parse==`function`){let e=i.parse;r.parse=(t,r)=>{let i=n(t);return i===M?e(t,r):i}}}function compileFn(e,t){let n=!0;try{n=A(e)}catch{}if(n)throw new ZodCompileUnsupportedError(`a schema whose subtree contains a reference cycle`);let r={constants:/* @__PURE__ */ new Map,constantCounter:0,varCounter:0,definite:!0},i=new f([`input`]),a=generateCheck(i,r,e,`input`,!t?.assertOnly);i.write(a===null?`return true;`:`return ${a};`);let o=[`INVALID`,...r.constants.keys()],s=[M,...r.constants.values()],c=i.content.join(`
`),l=t?.debug?o.length>0?`// Constants: ${o.join(`, `)}\n${c}`:c:``,u=Function,d=`return (input) => {\n${c}\n}`,p;try{p=new u(...o,d)(...s)}catch(e){throw new ZodCompileUnsupportedError(`this schema (generated code failed to evaluate: ${e.message})`)}return t?.debug&&(p.code=l),p.definite=r.definite,p}function addConstant(e,t){for(let[n,r]of e.constants)if(r===t)return n;let n=`c${e.constantCounter++}`;return e.constants.set(n,t),n}function addUserConstant(e,t){return e.definite=!1,addConstant(e,t)}function newVar(e){return`v${e.varCounter++}`}function runtimeRun(e,t){let n=e._zod.run({value:t,issues:[]},{});if(n&&typeof n.then==`function`)return M;let r=n;return r.issues.length===0?r.value:M}function compileChild(e,t,n,r,i=!0){let a=e.content.length,o=t.constants.size,s=t.constantCounter,c=t.varCounter;try{return generateCheck(e,t,n,r,i)}catch(i){if(!(i instanceof ZodCompileUnsupportedError)||!i.islandable)throw i;if(e.content.length=a,t.constants.size>o){let e=Array.from(t.constants.keys()).slice(o);for(let n of e)t.constants.delete(n)}return t.constantCounter=s,t.varCounter=c,emitRuntimeIsland(e,t,n,r)}}function emitRuntimeIsland(e,t,n,r){t.definite=!1;let i=addConstant(t,n),a=addConstant(t,runtimeRun),o=newVar(t);return e.write(`const ${o} = ${a}(${i}, ${r});`),e.write(`if (${o} === INVALID) return INVALID;`),o}const P=/* @__PURE__ */ new Set([`max_size`,`min_size`,`size_equals`,`max_length`,`min_length`,`length_equals`]);function generateChecks(e,t,n,r){let i=n._zod.def.checks;if(!i||i.length===0)return r;let a=r;for(let n of i){let r=n._zod.def;if(r.when&&!P.has(r.check))throw new ZodCompileUnsupportedError(`check with a custom "when" condition`);switch(r.check){case`greater_than`:generateGreaterThanCheck(e,t,r,a);break;case`less_than`:generateLessThanCheck(e,t,r,a);break;case`multiple_of`:generateMultipleOfCheck(e,t,r,a);break;case`number_format`:generateNumberFormatCheck(e,r,a);break;case`min_length`:{let n=numericOperand(r.minimum,`min_length`),i=codePointLengthVar(e,t,a,`${a}.length >= ${n} && ${a}.length < ${r.minimum*2}`);e.write(`if (${i} < ${n}) return INVALID;`);break}case`max_length`:{let n=numericOperand(r.maximum,`max_length`),i=codePointLengthVar(e,t,a,`${a}.length > ${n}`);e.write(`if (${i} > ${n}) return INVALID;`);break}case`length_equals`:{let n=numericOperand(r.length,`length_equals`),i=codePointLengthVar(e,t,a,`${a}.length >= ${n} && ${a}.length <= ${r.length*2}`);e.write(`if (${i} !== ${n}) return INVALID;`);break}case`min_size`:e.write(`if (${a}.size < ${numericOperand(r.minimum,`min_size`)}) return INVALID;`);break;case`max_size`:e.write(`if (${a}.size > ${numericOperand(r.maximum,`max_size`)}) return INVALID;`);break;case`size_equals`:e.write(`if (${a}.size !== ${numericOperand(r.size,`size_equals`)}) return INVALID;`);break;case`string_format`:a=generateStringFormatCheck(e,t,r,a);break;case`custom`:a=generateCustomRefineCheck(e,t,n,a);break;case`bigint_format`:generateBigIntFormatCheck(e,r,a);break;case`mime_type`:generateMimeTypeCheck(e,t,r,a);break;case`property`:generatePropertyCheck(e,t,r,a);break;case`properties`:generatePropertiesChecks(e,t,r,a);break;case`overwrite`:{let r=newVar(t);generateOverwriteCheck(e,t,n,a,r),a=r;break}default:throw new ZodCompileUnsupportedError(`check type ${r.check}`)}}return a}function codePointLengthVar(e,t,n,r){let i=addConstant(t,j),a=newVar(t);return e.write(`const ${a} = typeof ${n} === "string" && ${r} ? ${i}(${n}) : ${n}.length;`),a}function numericOperand(e,t){if(typeof e!=`number`||!Number.isFinite(e))throw new ZodCompileUnsupportedError(`${t} bound of type ${typeof e}`);return`${e}`}function comparisonOperand(e,t){if(typeof t==`bigint`)return`${t}n`;if(typeof t==`number`){if(Number.isNaN(t))throw new ZodCompileUnsupportedError(`comparison check with NaN bound`);return`${t}`}if(t instanceof Date){if(Number.isNaN(t.getTime()))throw new ZodCompileUnsupportedError(`comparison check with Invalid Date bound`);return addConstant(e,t)}throw new ZodCompileUnsupportedError(`comparison check bound of type ${typeof t}`)}function generateGreaterThanCheck(e,t,n,r){let i=n.inclusive?`<`:`<=`;e.write(`if (${r} ${i} ${comparisonOperand(t,n.value)}) return INVALID;`)}function generateLessThanCheck(e,t,n,r){let i=n.inclusive?`>`:`>=`;e.write(`if (${r} ${i} ${comparisonOperand(t,n.value)}) return INVALID;`)}function generateMultipleOfCheck(e,t,n,r){if(typeof n.value==`bigint`){if(n.value===BigInt(0))throw new ZodCompileUnsupportedError(`multiple_of check with a zero divisor`);e.write(`if (${r} % ${n.value}n !== 0n) return INVALID;`)}else{let i=addConstant(t,_);e.write(`if (${i}(${r}, ${numericOperand(n.value,`multiple_of`)}) !== 0) return INVALID;`)}}function generateNumberFormatCheck(e,t,n){let r=t.format;switch(r){case`safeint`:e.write(`if (!Number.isSafeInteger(${n})) return INVALID;`);break;case`int32`:e.write(`if (!Number.isInteger(${n}) || ${n} < -2147483648 || ${n} > 2147483647) return INVALID;`);break;case`uint32`:e.write(`if (!Number.isInteger(${n}) || ${n} < 0 || ${n} > 4294967295) return INVALID;`);break;case`float32`:e.write(`if (!Number.isFinite(${n}) || ${n} < -3.4028234663852886e38 || ${n} > 3.4028234663852886e38) return INVALID;`);break;case`float64`:e.write(`if (!Number.isFinite(${n})) return INVALID;`);break;default:throw new ZodCompileUnsupportedError(`number format ${r}`)}}function generateBigIntFormatCheck(e,t,n){let r=t.format;if(r)switch(r){case`int64`:e.write(`if (${n} < -9223372036854775808n || ${n} > 9223372036854775807n) return INVALID;`);break;case`uint64`:e.write(`if (${n} < 0n || ${n} > 18446744073709551615n) return INVALID;`);break;default:throw new ZodCompileUnsupportedError(`bigint format ${r}`)}}function generateMimeTypeCheck(e,t,n,r){let i=n.mime;if(i&&i.length>0){let n=addConstant(t,new Set(i));e.write(`if (!${n}.has(${r}.type)) return INVALID;`)}}function generatePropertiesChecks(e,t,r,i){if(r.when)throw new ZodCompileUnsupportedError(`check with a custom "when" condition`);e.write(`if (${i} == null) return INVALID;`);let a=r.shape;for(let r of Reflect.ownKeys(a)){let o=typeof r==`symbol`?addConstant(t,r):n(r),s=newVar(t);e.write(`const ${s} = ${i}[${o}];`),compileChild(e,t,a[r],s,!1)}}function generatePropertyCheck(e,t,n,r){let i=`${r}[${JSON.stringify(n.property)}]`;generateCheck(e,t,n.schema,i)}function generateOverwriteCheck(e,t,n,r,i){let a=n._zod.def.tx;if(!a)throw new ZodCompileUnsupportedError(`overwrite check without a transform function`);if(isAsyncFunction(a))throw new ZodCompileAsyncError(`z.compile: async overwrite transforms are not supported`);let o=addConstant(t,a);e.write(`const ${i} = ${o}(${r});`)}function throwAsync(){throw new c}function pushIssue(e){this.issues.push(e)}function generateCustomRefineCheck(e,t,n,r){let i=n._zod.def;if(i.fn){if(isAsyncFunction(i.fn))throw new ZodCompileAsyncError(`z.compile: async .refine() predicates are not supported`);let n=addUserConstant(t,i.fn),a=addConstant(t,throwAsync),o=newVar(t);return e.write(`const ${o} = ${n}(${r});`),e.write(`if (${o} instanceof Promise) ${a}();`),e.write(`if (!${o}) return INVALID;`),r}if(n._zod.check){if(isAsyncFunction(n._zod.check))throw new ZodCompileAsyncError(`z.compile: async .superRefine() / check functions are not supported`);let i=n._zod.check,a=addUserConstant(t,e=>{let t={value:e,issues:[],addIssue:pushIssue};return i(t)instanceof Promise&&throwAsync(),t.issues.length===0?t.value:M}),o=newVar(t);return e.write(`const ${o} = ${a}(${r});`),e.write(`if (${o} === INVALID) return INVALID;`),o}throw new ZodCompileUnsupportedError(`custom check without a predicate or check function`)}const F=/* @__PURE__ */ new Set([`cidrv4`,`cuid`,`cuid2`,`date`,`datetime`,`duration`,`e164`,`email`,`emoji`,`ends_with`,`guid`,`includes`,`ipv4`,`ksuid`,`lowercase`,`mac`,`nanoid`,`regex`,`starts_with`,`time`,`ulid`,`uppercase`,`uuid`,`xid`]);function generateStringFormatCheck(e,o,s,c,f=!0){let p=s.format;if(p===`base64`){let t=addConstant(o,m);return e.write(`if (!${t}(${c})) return INVALID;`),c}if(p===`base64url`){let t=addConstant(o,r);return e.write(`if (!${t}(${c})) return INVALID;`),c}if(p===`jwt`){let t=addConstant(o,d),n=addConstant(o,s.alg??null);return e.write(`if (!${t}(${c}, ${n})) return INVALID;`),c}if(p===`ipv6`){let t=addConstant(o,i);return e.write(`if (!${t}(${c})) return INVALID;`),c}if(p===`cidrv6`){let t=addConstant(o,k);return e.write(`if (!${t}(${c})) return INVALID;`),c}if(p===`credit_card`){let t=addConstant(o,h);return e.write(`if (!${t}(${c})) return INVALID;`),c}if(p===`iban`){let t=addConstant(o,a);return e.write(`if (!${t}(${c})) return INVALID;`),c}let g=s;if(p===`url`||p===`httpurl`||g.normalize||g.hostname!==void 0||g.protocol!==void 0){let n=addConstant(o,u),r=addConstant(o,s),i=newVar(o),a=newVar(o);if(e.write(`const ${i} = ${c}.trim();`),e.write(`const ${a} = ${n}(${i}, ${r});`),e.write(`if (typeof ${a} === "number") return INVALID;`),g.hostname!==void 0){let t=addConstant(o,D);e.write(`if (!${t}(${a}, ${r}.hostname)) return INVALID;`)}if(g.protocol!==void 0){let t=addConstant(o,l);e.write(`if (!${t}(${a}, ${r}.protocol)) return INVALID;`)}if(!f)return null;let d=newVar(o),p=g.normalize?`${a}.href`:`${addConstant(o,t)}(${i})`;return e.write(`const ${d} = ${p};`),d}let _=s.fn;if(_){if(isAsyncFunction(_))throw new ZodCompileUnsupportedError(`async string format ${p}`);let t=addConstant(o,_);return e.write(`if (!${t}(${c})) return INVALID;`),c}if(F.has(p)&&s.pattern){let t=addConstant(o,s.pattern);return e.write(`${t}.lastIndex = 0;`),e.write(`if (!${t}.test(${c})) return INVALID;`),c}let v=s.format;switch(v){case`regex`:throw new ZodCompileUnsupportedError(`regex format without a pattern`);case`lowercase`:e.write(`if (${c} !== ${c}.toLowerCase()) return INVALID;`);break;case`uppercase`:e.write(`if (${c} !== ${c}.toUpperCase()) return INVALID;`);break;case`includes`:e.write(`if (!${c}.includes(${n(s.includes)})) return INVALID;`);break;case`starts_with`:{let t=s.prefix;e.write(`if (${c}.slice(0, ${t.length}) !== ${n(t)}) return INVALID;`);break}case`ends_with`:{let t=s.suffix;e.write(`if (${c}.slice(-${t.length}) !== ${n(t)}) return INVALID;`);break}default:throw new ZodCompileUnsupportedError(`string format ${v}`)}return c}function generateCheck(e,t,n,r,i=!0){let a=n._zod.def,o=a.type;if(a.coerce)throw new ZodCompileUnsupportedError(`coercion (z.coerce.${o}())`);let s=i||!!a.checks?.length,c;switch(o){case`string`:c=generateStringCheck(e,t,n,r,s);break;case`number`:c=generateNumberCheck(e,n,r);break;case`boolean`:c=generateBooleanCheck(e,r);break;case`bigint`:c=generateBigIntCheck(e,n,r);break;case`symbol`:c=generateSymbolCheck(e,r);break;case`undefined`:c=generateUndefinedCheck(e,r);break;case`null`:c=generateNullCheck(e,r);break;case`any`:case`unknown`:c=r;break;case`never`:e.write(`return INVALID;`),c=r;break;case`void`:c=generateVoidCheck(e,r);break;case`nan`:c=generateNaNCheck(e,r);break;case`date`:c=generateDateCheck(e,r);break;case`object`:c=generateObjectCheck(e,t,n,r,s);break;case`optional`:c=generateOptionalCheck(e,t,n,r,s);break;case`nullable`:c=generateNullableCheck(e,t,n,r,s);break;case`array`:c=generateArrayCheck(e,t,n,r,s);break;case`literal`:c=generateLiteralCheck(e,t,n,r);break;case`enum`:c=generateEnumCheck(e,t,n,r);break;case`readonly`:{let i=generateWrapperCheck(e,t,n,r),a=newVar(t);e.write(`const ${a} = Object.freeze(${i});`),c=a;break}case`success`:generateWrapperCheck(e,t,n,r),c=`true`;break;case`default`:case`prefault`:c=generateDefaultCheck(e,t,n,r);break;case`nonoptional`:c=generateNonOptionalCheck(e,t,n,r);break;case`tuple`:c=generateTupleCheck(e,t,n,r);break;case`union`:c=generateUnionCheck(e,t,n,r);break;case`intersection`:c=generateIntersectionCheck(e,t,n,r);break;case`record`:c=generateRecordCheck(e,t,n,r);break;case`map`:c=generateMapCheck(e,t,n,r);break;case`set`:c=generateSetCheck(e,t,n,r);break;case`file`:c=generateFileCheck(e,r);break;case`template_literal`:c=generateTemplateLiteralCheck(e,t,n,r);break;case`lazy`:c=generateLazyCheck(e,t,n,r);break;case`pipe`:c=generatePipeCheck(e,t,n,r);break;case`custom`:c=generateCustomCheck(e,t,n,r);break;case`transform`:c=generateTransformCheck(e,t,n,r);break;case`catch`:c=generateCatchCheck(e,t,n,r);break;default:throw new ZodCompileUnsupportedError(`schema type ${o}`)}return c===null?null:generateChecks(e,t,n,c)}function generateStringCheck(e,t,n,r,i=!0){e.write(`if (typeof ${r} !== "string") return INVALID;`);let a=n._zod.def;return a.format===void 0?r:generateStringFormatCheck(e,t,a,r,i)}function generateNumberCheck(e,t,n){e.write(`if (typeof ${n} !== "number" || !Number.isFinite(${n})) return INVALID;`);let r=t._zod.def;return r.check===`number_format`&&r.format&&generateNumberFormatCheck(e,{format:r.format},n),n}function generateBooleanCheck(e,t){return e.write(`if (typeof ${t} !== "boolean") return INVALID;`),t}function generateBigIntCheck(e,t,n){e.write(`if (typeof ${n} !== "bigint") return INVALID;`);let r=t._zod.def;if(r.format)switch(r.format){case`int64`:e.write(`if (${n} < -9223372036854775808n || ${n} > 9223372036854775807n) return INVALID;`);break;case`uint64`:e.write(`if (${n} < 0n || ${n} > 18446744073709551615n) return INVALID;`)}return n}function generateSymbolCheck(e,t){return e.write(`if (typeof ${t} !== "symbol") return INVALID;`),t}function generateUndefinedCheck(e,t){return e.write(`if (${t} !== undefined) return INVALID;`),t}function generateNullCheck(e,t){return e.write(`if (${t} !== null) return INVALID;`),t}function generateVoidCheck(e,t){return e.write(`if (${t} !== undefined) return INVALID;`),t}function generateNaNCheck(e,t){return e.write(`if (typeof ${t} !== "number" || !Number.isNaN(${t})) return INVALID;`),t}function generateDateCheck(e,t){return e.write(`if (!(${t} instanceof Date) || Number.isNaN(${t}.getTime())) return INVALID;`),t}function generateObjectCheck(e,t,r,i,a=!0){let o=r._zod.def;e.write(`if (typeof ${i} !== "object" || ${i} === null || Array.isArray(${i})) return INVALID;`);let s=o.shape,c=Object.keys(s),l=Object.getOwnPropertySymbols(s),u=l.length?[...c,...l]:c,keyExpr=e=>typeof e==`symbol`?addConstant(t,e):n(e),propKey=e=>typeof e==`symbol`?`[${keyExpr(e)}]`:n(e),d=s;if(c.includes(`__proto__`))throw new ZodCompileUnsupportedError(`object shape key "__proto__"`);let f=/* @__PURE__ */ new Map;for(let n of u){let r=d[n],o=keyExpr(n),s=newVar(t);if(e.write(`const ${s} = ${i}[${o}];`),r._zod.optin!==void 0){let a=newVar(t);e.write(`let ${a} = (() => {`),e.indented(e=>{let n=compileChild(e,t,r,s);e.write(`return ${n};`)}),e.write(`})();`),r._zod.optout===`optional`?(e.write(`if (${a} === INVALID) {`),e.indented(e=>{e.write(`if (${o} in ${i}) return INVALID;`),e.write(`${a} = undefined;`)}),e.write(`}`)):e.write(`if (${a} === INVALID) return INVALID;`),f.set(n,a)}else{requiresPresenceCheck(r)&&e.write(`if (!(${o} in ${i})) return INVALID;`);let c=compileChild(e,t,r,s,a);c!==null&&f.set(n,c)}}let p=o.catchall,m=`none`;if(p){let t=p._zod.def.type;if(t===`never`){let t=c.map(e=>`k !== ${n(e)}`).join(` && `)||`true`;e.write(`for (const k in ${i}) {`),e.indented(e=>{e.write(`if (${t}) return INVALID;`)}),e.write(`}`)}else m=(t===`unknown`||t===`any`)&&!p._zod.def.checks?.length?`passthrough`:`schema`}let h=newVar(t),g=u.some(e=>mayOmitUndefined(d[e])||dropsWhenAbsent(d[e]));if(!a){if(m===`schema`){let n=c.length>0?addConstant(t,new Set(c)):null;e.write(`for (const k in ${i}) {`),e.indented(e=>{e.write(`if (k === "__proto__") continue;`),n&&e.write(`if (${n}.has(k)) continue;`);let r=newVar(t);e.write(`const ${r} = ${i}[k];`),compileChild(e,t,p,r,!1)}),e.write(`}`)}return null}if(g){e.write(`const ${h} = {};`);for(let t of u){let n=keyExpr(t),r=f.get(t);dropsWhenAbsent(d[t])?e.write(`if (${n} in ${i}) ${h}[${n}] = ${r};`):mayOmitUndefined(d[t])?e.write(`if (${r} !== undefined || ${n} in ${i}) ${h}[${n}] = ${r};`):e.write(`${h}[${n}] = ${r};`)}}else{let t=u.map(e=>`${propKey(e)}: ${f.get(e)}`).join(`, `);e.write(`const ${h} = { ${t} };`)}if(m!==`none`){let n=c.length>0?addConstant(t,new Set(c)):null;e.write(`for (const k in ${i}) {`),e.indented(e=>{if(e.write(`if (k === "__proto__") continue;`),n&&e.write(`if (${n}.has(k)) continue;`),m===`passthrough`)e.write(`${h}[k] = ${i}[k];`);else{let n=newVar(t);e.write(`const ${n} = ${i}[k];`);let r=compileChild(e,t,p,n);e.write(`${h}[k] = ${r};`)}}),e.write(`}`)}return h}function generateOptionalCheck(e,t,n,r,i=!0){let a=n._zod.def;if(isExactOptional(n))return generateCheck(e,t,a.innerType,r,i);if(a.innerType._zod.optin===`defaulted`){let n=newVar(t),i=newVar(t);return e.write(`let ${n};`),e.write(`if (${r} === undefined) {`),e.indented(e=>{e.write(`const ${i} = (() => {`),e.indented(e=>{let n=generateCheck(e,t,a.innerType,r);e.write(`return ${n};`)}),e.write(`})();`),e.write(`if (${i} !== INVALID) ${n} = ${i};`)}),e.write(`} else {`),e.indented(e=>{let i=generateCheck(e,t,a.innerType,r);e.write(`${n} = ${i};`)}),e.write(`}`),n}let o=i?newVar(t):null;return o&&e.write(`let ${o};`),e.write(`if (${r} !== undefined) {`),e.indented(e=>{let n=generateCheck(e,t,a.innerType,r,i);o&&n!==null&&e.write(`${o} = ${n};`)}),e.write(`}`),o}function isExactOptional(e){return e._zod.traits?.has(`$ZodExactOptional`)===!0}function requiresPresenceCheck(e){return e._zod.optin===void 0&&fastPathAcceptsAbsence(e)}function fastPathAcceptsAbsence(e){if(e._zod.def.coerce)return!0;let t=e._zod.def;switch(t.type){case`any`:case`unknown`:case`undefined`:case`void`:case`default`:case`prefault`:case`transform`:case`custom`:case`lazy`:return!0;case`string`:case`number`:case`boolean`:case`bigint`:case`symbol`:case`null`:case`never`:case`nan`:case`date`:case`object`:case`array`:case`tuple`:case`record`:case`map`:case`set`:case`file`:case`template_literal`:return!1;case`nonoptional`:return t.innerType?fastPathAcceptsAbsence(t.innerType):!1;case`literal`:return!!t.values?.includes(void 0);case`enum`:return!!e._zod.values?.has(void 0);case`optional`:case`nullable`:case`readonly`:case`success`:return!t.innerType||fastPathAcceptsAbsence(t.innerType);case`catch`:return!0;case`union`:return!t.options||t.options.some(fastPathAcceptsAbsence);case`intersection`:return!t.left||!t.right||fastPathAcceptsAbsence(t.left)&&fastPathAcceptsAbsence(t.right);case`pipe`:return!t.in||fastPathAcceptsAbsence(t.in);default:return!0}}function dropsWhenAbsent(e){return e._zod.optin===`optional`&&e._zod.optout===`optional`}function mayOmitUndefined(e){return(e._zod.optin!==`defaulted`||e._zod.optout===`optional`)&&mayOutputUndefined(e)}function mayOutputUndefined(e){let t=e._zod.def;switch(t.type){case`string`:case`number`:case`boolean`:case`bigint`:case`symbol`:case`null`:case`nan`:case`date`:case`object`:case`array`:case`tuple`:case`record`:case`map`:case`set`:case`file`:case`template_literal`:case`never`:case`success`:return!1;case`literal`:return!!t.values?.includes(void 0);case`enum`:return!!e._zod.values?.has(void 0);case`optional`:return!0;case`nullable`:case`readonly`:case`nonoptional`:return!t.innerType||mayOutputUndefined(t.innerType);case`union`:return!t.options||t.options.some(mayOutputUndefined);case`intersection`:return!t.left||!t.right||mayOutputUndefined(t.left)||mayOutputUndefined(t.right);case`pipe`:return!t.out||mayOutputUndefined(t.out);default:return!0}}function generateNullableCheck(e,t,n,r,i=!0){let a=n._zod.def,o=i?newVar(t):null;return o&&e.write(`let ${o} = null;`),e.write(`if (${r} !== null) {`),e.indented(e=>{let n=generateCheck(e,t,a.innerType,r,i);o&&n!==null&&e.write(`${o} = ${n};`)}),e.write(`}`),o}function generateSizeGate(e,t,n){for(let[r,i]of v(t._zod.def.checks))e.write(`if (${n} > ${numericOperand(r,i._zod.def.check)}) return INVALID;`)}function generateArrayCheck(e,t,n,r,i=!0){let a=n._zod.def;e.write(`if (!Array.isArray(${r})) return INVALID;`),generateSizeGate(e,n,`${r}.length`);let o=i?newVar(t):null,s=newVar(t),c=newVar(t);return o&&e.write(`const ${o} = new Array(${r}.length);`),e.write(`for (let ${s} = 0; ${s} < ${r}.length; ${s}++) {`),e.indented(e=>{e.write(`const ${c} = ${r}[${s}];`);let n=compileChild(e,t,a.element,c,i);o&&n!==null&&e.write(`${o}[${s}] = ${n};`)}),e.write(`}`),o}function generateLiteralCheck(e,t,r,i){let a=r._zod.def.values;if(a.length!==1){let n=addConstant(t,new Set(a));return e.write(`if (!${n}.has(${i})) return INVALID;`),i}let o=a[0];if(typeof o==`number`&&Number.isNaN(o)){let n=addConstant(t,new Set(a));return e.write(`if (!${n}.has(${i})) return INVALID;`),i}if(typeof o==`string`)e.write(`if (${i} !== ${n(o)}) return INVALID;`);else if(typeof o==`number`||typeof o==`boolean`)e.write(`if (${i} !== ${o}) return INVALID;`);else if(o===null)e.write(`if (${i} !== null) return INVALID;`);else if(o===void 0)e.write(`if (${i} !== undefined) return INVALID;`);else if(typeof o==`bigint`)e.write(`if (${i} !== ${o}n) return INVALID;`);else throw new ZodCompileUnsupportedError(`literal type ${typeof o}`);return i}function generateEnumCheck(e,t,n,r){let i=n._zod.values;if(!i)throw new ZodCompileUnsupportedError(`enum schema without enumerated values`);let a=addConstant(t,i);return e.write(`if (!${a}.has(${r})) return INVALID;`),r}function generateWrapperCheck(e,t,n,r){let i=n._zod.def;return generateCheck(e,t,i.innerType,r)}function generateDefaultCheck(e,t,n,r){let i=n._zod.def,a=Object.getOwnPropertyDescriptor(n._zod.def,`defaultValue`)?()=>n._zod.def.defaultValue:void 0;if(n._zod.def.type===`prefault`){if(!a)return generateCheck(e,t,i.innerType,r);let n=addConstant(t,a),o=newVar(t);return e.write(`let ${o} = ${r};`),e.write(`if (${r} === undefined) ${o} = ${n}();`),generateCheck(e,t,i.innerType,o)}let o=newVar(t);if(a){let n=addConstant(t,a),s=addConstant(t,g);e.write(`let ${o};`),e.write(`if (${r} === undefined) {`),e.indented(e=>{e.write(`${o} = ${s}(${n}());`)}),e.write(`} else {`),e.indented(e=>{let a=generateCheck(e,t,i.innerType,r);e.write(`${o} = ${a} === undefined ? ${s}(${n}()) : ${a};`)}),e.write(`}`)}else e.write(`let ${o};`),e.write(`if (${r} !== undefined) {`),e.indented(e=>{let n=generateCheck(e,t,i.innerType,r);e.write(`${o} = ${n};`)}),e.write(`}`);return o}function generateNonOptionalCheck(e,t,n,r){let i=n._zod.def,a=generateCheck(e,t,i.innerType,r),o=newVar(t);return e.write(`const ${o} = ${a};`),e.write(`if (${o} === undefined) return INVALID;`),o}function generateTupleCheck(e,t,n,r){let i=n._zod.def,a=i.items,o=i.rest;e.write(`if (!Array.isArray(${r})) return INVALID;`);let s=getTupleOptStart(a,`optin`),c=getTupleOptStart(a,`optout`);o?e.write(`if (${r}.length < ${s}) return INVALID;`):e.write(`if (${r}.length < ${s} || ${r}.length > ${a.length}) return INVALID;`);let l=newVar(t);e.write(`const ${l} = [];`);for(let n=0;n<a.length;n++){let i=a[n];if(n>=c)e.write(`if (${l}.length === ${n}) {`),e.indented(e=>{e.write(`if (${n} < ${r}.length) {`),e.indented(e=>{let a=newVar(t);e.write(`const ${a} = ${r}[${n}];`);let o=compileChild(e,t,i,a);e.write(`${l}[${n}] = ${o};`)}),e.write(`} else {`),e.indented(e=>{if(dropsWhenAbsent(i)){e.write(`${l}.length = ${n};`);return}let r=newVar(t),a=newVar(t);e.write(`const ${r} = undefined;`),e.write(`const ${a} = (() => {`),e.indented(e=>{let n=compileChild(e,t,i,r);e.write(`return ${n};`)}),e.write(`})();`),e.write(`if (${a} === INVALID || ${a} === undefined) ${l}.length = ${n};`),e.write(`else ${l}[${n}] = ${a};`)}),e.write(`}`)}),e.write(`}`);else{let a=newVar(t);e.write(`const ${a} = ${r}[${n}];`);let o=compileChild(e,t,i,a);e.write(`${l}[${n}] = ${o};`)}}if(o){let n=newVar(t),i=newVar(t);e.write(`for (let ${n} = ${a.length}; ${n} < ${r}.length; ${n}++) {`),e.indented(e=>{e.write(`const ${i} = ${r}[${n}];`);let a=compileChild(e,t,o,i);e.write(`${l}[${n}] = ${a};`)}),e.write(`}`)}return l}function getTupleOptStart(e,t){for(let n=e.length-1;n>=0;n--)if(!(t===`optin`?e[n]._zod.optin!==void 0:e[n]._zod.optout===`optional`))return n+1;return 0}function generateUnionCheck(e,t,n,r){let i=n._zod.def,a=i.options;if(i.discriminator)return generateDiscriminatedUnionCheck(e,t,i,r);if(i.inclusive===!1)throw new ZodCompileUnsupportedError(`exclusive unions (z.xor)`);if(a.length===0)return e.write(`return INVALID;`),r;if(a.length===1)return generateCheck(e,t,a[0],r);if(a.every(e=>e._zod.def.type===`literal`&&!e._zod.def.checks?.length)){let n=addConstant(t,new Set(a.flatMap(e=>e._zod.def.values)));return e.write(`if (!${n}.has(${r})) return INVALID;`),r}let o=newVar(t);e.write(`let ${o};`);for(let n=0;n<a.length;n++){let i=a[n];n===0?e.write(`${o} = (() => {`):e.write(`if (${o} === INVALID) ${o} = (() => {`),e.indented(e=>{let n=generateCheck(e,t,i,r);e.write(`return ${n};`)}),e.write(`})();`)}return e.write(`if (${o} === INVALID) return INVALID;`),o}function generateDiscriminatedUnionCheck(e,t,r,i){if(r.unionFallback)throw new ZodCompileUnsupportedError(`discriminated union with unionFallback`);if(r.options.length===0)return e.write(`return INVALID;`),i;let a=newVar(t),o=newVar(t);e.write(`const ${a} = ${i}?.[${n(r.discriminator)}];`),e.write(`let ${o};`);let s=!0,c=/* @__PURE__ */ new Set;for(let n of r.options){let l=n._zod.propValues?.[r.discriminator];if(!l||l.size===0)throw new ZodCompileUnsupportedError(`discriminated union option without static discriminator values`);for(let e of l){if(c.has(e))throw new ZodCompileUnsupportedError(`duplicate discriminator value ${String(e)}`);c.add(e)}let u=Array.from(l,e=>literalEquality(t,a,e)),d=s?`if`:`else if`;e.write(`${d} (${u.join(` || `)}) {`),e.indented(e=>{let r=generateCheck(e,t,n,i);e.write(`${o} = ${r};`)}),e.write(`}`),s=!1}return e.write(`else { return INVALID; }`),o}function literalEquality(e,t,r){if(typeof r==`string`)return`${t} === ${n(r)}`;if(typeof r==`number`)return Number.isNaN(r)?`Number.isNaN(${t})`:`${t} === ${r}`;if(typeof r==`boolean`)return`${t} === ${r}`;if(r===null)return`${t} === null`;if(r===void 0)return`${t} === undefined`;if(typeof r==`bigint`)return`${t} === ${r}n`;if(typeof r==`symbol`)return`${t} === ${addConstant(e,r)}`;throw new ZodCompileUnsupportedError(`literal discriminator value ${String(r)}`)}function generateIntersectionCheck(e,t,n,r){let i=n._zod.def;t.definite=!1;let a=compileChild(e,t,i.left,r),o=compileChild(e,t,i.right,r),s=addConstant(t,O),c=newVar(t);return e.write(`const ${c} = ${s}(${a}, ${o});`),e.write(`if (!${c}.valid) return INVALID;`),`${c}.data`}function generateRecordCheck(e,t,n,r){let i=n._zod.def,a=addConstant(t,s);e.write(`if (!${a}(${r})) return INVALID;`);let c=newVar(t),l=newVar(t),u=newVar(t);e.write(`const ${c} = {};`);let d=i,f=d.partial?void 0:i.keyType._zod.values;if(f){let n=[];for(let a of f){if(typeof a!=`string`&&typeof a!=`number`&&typeof a!=`symbol`)throw new ZodCompileUnsupportedError(`record key value ${String(a)}`);let o=typeof a==`number`?a.toString():a;if(o===`__proto__`)throw new ZodCompileUnsupportedError(`record key "__proto__"`);n.push(o);let s=addConstant(t,a),l=generateCheck(e,t,i.keyType,s),u=newVar(t);e.write(`const ${u} = ${r}[${literalPropertyKey(t,o)}];`);let d=compileChild(e,t,i.valueType,u);e.write(`${c}[${l}] = ${d};`)}let a=addConstant(t,new Set(n));return e.write(`for (const ${l} in ${r}) {`),e.indented(e=>{e.write(`if (${a}.has(${l})) continue;`),d.mode===`loose`?e.write(`if (${l} !== "__proto__") ${c}[${l}] = ${r}[${l}];`):e.write(`return INVALID;`)}),e.write(`}`),c}let p=i.keyType._zod.def;if(p.type!==`string`||p.format!==void 0||p.coerce||(p.checks?.length??0)!==0){let n=i.mode===`loose`,a=compileFn(i.keyType);a.definite===!1&&(t.definite=!1);let s=addConstant(t,a),u=addConstant(t,o),d=newVar(t);return emitOwnKeys(e,t,r,l,e=>{e.write(`let ${d} = ${s}(${l});`),e.write(`if (${d} === INVALID && typeof ${l} === "string" && ${u}.test(${l})) ${d} = ${s}(Number(${l}));`),n?e.write(`if (${d} === INVALID) { ${c}[${l}] = ${r}[${l}]; continue; }`):e.write(`if (${d} === INVALID) return INVALID;`),e.write(`if (${d} === "__proto__") continue;`);let a=newVar(t);e.write(`const ${a} = ${r}[${l}];`);let o=compileChild(e,t,i.valueType,a);e.write(`${c}[${d}] = ${o};`)}),c}return emitOwnKeys(e,t,r,l,e=>{e.write(`const ${u} = ${r}[${l}];`);let n=compileChild(e,t,i.valueType,u);e.write(`${c}[${l}] = ${n};`)},`return INVALID;`),c}function emitOwnKeys(e,t,n,r,i,a){let o=addConstant(t,Object.prototype.propertyIsEnumerable),s=newVar(t),c=newVar(t),l=newVar(t);e.write(`const ${s} = Object.getOwnPropertySymbols(${n});`),e.write(`const ${c} = Object.getOwnPropertyNames(${n});`),e.write(`for (let ${l} = 0; ${l} < ${c}.length; ${l}++) {`),e.indented(e=>{e.write(`const ${r} = ${c}[${l}];`),e.write(`if (${r} === "__proto__" || !${o}.call(${n}, ${r})) continue;`),i(e)}),e.write(`}`),e.write(`for (let ${l} = 0; ${l} < ${s}.length; ${l}++) {`),e.indented(e=>{e.write(`const ${r} = ${s}[${l}];`),e.write(`if (!${o}.call(${n}, ${r})) continue;`),a?e.write(a):i(e)}),e.write(`}`)}function literalPropertyKey(e,t){return typeof t==`string`?n(t):addConstant(e,t)}function generateMapCheck(e,t,n,r){let i=n._zod.def;e.write(`if (!(${r} instanceof Map)) return INVALID;`),generateSizeGate(e,n,`${r}.size`);let a=newVar(t),o=newVar(t),s=newVar(t);return e.write(`const ${a} = new Map();`),e.write(`for (const [${o}, ${s}] of ${r}) {`),e.indented(e=>{let n=generateCheck(e,t,i.keyType,o),r=generateCheck(e,t,i.valueType,s);e.write(`${a}.set(${n}, ${r});`)}),e.write(`}`),a}function generateSetCheck(e,t,n,r){let i=n._zod.def;e.write(`if (!(${r} instanceof Set)) return INVALID;`),generateSizeGate(e,n,`${r}.size`);let a=newVar(t),o=newVar(t);return e.write(`const ${a} = new Set();`),e.write(`for (const ${o} of ${r}) {`),e.indented(e=>{let n=generateCheck(e,t,i.valueType,o);e.write(`${a}.add(${n});`)}),e.write(`}`),a}function generateFileCheck(e,t){return e.write(`if (!(${t} instanceof File)) return INVALID;`),t}function generateTemplateLiteralCheck(e,t,n,r){e.write(`if (typeof ${r} !== "string") return INVALID;`);let i=n._zod.pattern;if(i){let n=addConstant(t,i);e.write(`${n}.lastIndex = 0;`),e.write(`if (!${n}.test(${r})) return INVALID;`)}return r}function generateLazyCheck(e,t,n,r){let i=n._zod.def,a=addUserConstant(t,i.getter),o=addConstant(t,{parser:null});e.write(`if (!${o}.parser) {`),e.indented(e=>{e.write(`const inner = ${a}();`),e.write(`${o}.parser = function(input) {`),e.indented(e=>{e.write(`const result = inner._zod.run({ value: input, issues: [] }, {});`),e.write(`return result.issues.length === 0 ? result.value : INVALID;`)}),e.write(`};`)}),e.write(`}`);let s=newVar(t);return e.write(`const ${s} = ${o}.parser(${r});`),e.write(`if (${s} === INVALID) return INVALID;`),s}function generatePipeCheck(e,t,n,r){let i=n._zod.def,a=generateCheck(e,t,i.in,r);if(i.transform){if(isAsyncFunction(i.transform))throw new ZodCompileAsyncError(`z.compile: async transforms in pipes are not supported`);let n=i.transform,r=addUserConstant(t,e=>{let t={value:e,issues:[],addIssue:pushIssue},r=n(e,t);return r instanceof Promise?M:t.issues.length===0?r:M}),o=newVar(t);return e.write(`const ${o} = ${r}(${a});`),e.write(`if (${o} === INVALID) return INVALID;`),generateCheck(e,t,i.out,o)}return generateCheck(e,t,i.out,a)}function isAsyncFunction(e){return typeof e==`function`&&(e.constructor.name===`AsyncFunction`||e[Symbol.toStringTag]===`AsyncFunction`)}function generateCustomCheck(e,t,n,r){let i=n._zod.def;if(i.fn){if(isAsyncFunction(i.fn))throw new ZodCompileAsyncError(`z.compile: async custom predicates are not supported`);let n=addUserConstant(t,i.fn),a=addConstant(t,throwAsync),o=newVar(t);e.write(`const ${o} = ${n}(${r});`),e.write(`if (${o} instanceof Promise) ${a}();`),e.write(`if (!${o}) return INVALID;`)}else throw new ZodCompileUnsupportedError(`custom schema without a predicate function`);return r}function runtimeCatch(e,t,n){let r=e._zod.run({value:n,issues:[]},{});if(r&&typeof r.then==`function`)return M;let i=r;return i.issues.length===0?i.value:t()}function generateCatchCheck(e,t,n,r){let i=n._zod.def;if(!i.catchValue[`~constantCatch`])throw new ZodCompileUnsupportedError(`catch with a callback (only a constant catch value compiles)`,!1);let a=newVar(t);e.write(`let ${a} = (() => {`),e.indented(e=>{let n=compileChild(e,t,i.innerType,r);e.write(`return ${n};`)}),e.write(`})();`);let o=addConstant(t,i.innerType),s=addUserConstant(t,i.catchValue),c=addConstant(t,runtimeCatch);return e.write(`if (${a} === INVALID) {`),e.indented(e=>{e.write(`${a} = ${c}(${o}, ${s}, ${r});`),e.write(`if (${a} === INVALID) return INVALID;`)}),e.write(`}`),a}function generateTransformCheck(e,t,n,r){let i=n._zod.def;if(i.transform){if(isAsyncFunction(i.transform))throw new ZodCompileAsyncError(`z.compile: async transforms are not supported`);let n=i.transform,a=addUserConstant(t,e=>{let t={value:e,issues:[],addIssue:pushIssue},r=n(e,t);return r instanceof Promise?M:t.issues.length===0?r:M}),o=newVar(t);return e.write(`const ${o} = ${a}(${r});`),e.write(`if (${o} === INVALID) return INVALID;`),o}return r}const I=`openclaw.nested-tool.v1`,L=T().min(1).max(1024),R=w({runId:L,scopeId:L,afterEntryId:L.nullable(),startOrder:C().int().nonnegative(),parentToolCallId:L.optional(),toolCallId:L,toolName:T().min(1).max(256),input:y(),result:w({content:E(y()),details:y().optional()}),isError:b(),startedAt:C().finite(),timestamp:C().finite()}).strict(),z=w({role:S(`custom`),customType:S(I),display:S(!0),excludeFromContext:S(!0),content:S(``),details:R,timestamp:C().finite()});let B;function getActivitySchema(){return B??=compile(z)}function readNestedToolActivity(t){if(e(t)?.customType!==`openclaw.nested-tool.v1`)return;let n=getActivitySchema().safeParse(t);return n.success?n.data:void 0}function nestedToolActivityContent({details:e}){let{input:t,result:n,...r}=e;return[{type:`toolCall`,id:r.toolCallId,runId:r.runId,name:r.toolName,arguments:t,parentToolCallId:r.parentToolCallId,timestamp:r.startedAt},{...r,...n,type:`toolResult`}]}export{nestedToolActivityContent as n,readNestedToolActivity as r,I as t};