@zibby/core 0.1.37 → 0.1.40
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/agents/base.js +92 -230
- package/dist/framework/agents/assistant-strategy.js +9 -67
- package/dist/framework/agents/claude-strategy.js +16 -105
- package/dist/framework/agents/codex-strategy.js +12 -18
- package/dist/framework/agents/cursor-strategy.js +46 -81
- package/dist/framework/agents/gemini-strategy.js +13 -17
- package/dist/framework/agents/index.js +72 -210
- package/dist/framework/agents/utils/cursor-output-formatter.js +4 -8
- package/dist/framework/agents/utils/openai-proxy-formatter.js +5 -43
- package/dist/framework/agents/utils/structured-output-formatter.js +4 -8
- package/dist/framework/code-generator.js +85 -223
- package/dist/framework/function-bridge.js +1 -60
- package/dist/framework/graph-compiler.js +83 -221
- package/dist/framework/graph.js +80 -218
- package/dist/framework/index.js +96 -242
- package/dist/framework/mcp-client.js +2 -56
- package/dist/framework/node-registry.js +75 -213
- package/dist/framework/node.js +77 -215
- package/dist/framework/state-utils.js +1 -5
- package/dist/index.js +194 -332
- package/dist/package.json +35 -36
- package/dist/utils/ast-utils.js +1 -9
- package/dist/utils/node-schema-parser.js +1 -9
- package/package.json +5 -6
- package/templates/browser-test-automation/run-index.mjs +4 -4
- package/templates/code-analysis/nodes/analyze-ticket-node.js +3 -3
- package/templates/code-analysis/nodes/create-pr-node.js +1 -1
- package/templates/code-analysis/nodes/generate-code-node.js +1 -1
- package/templates/code-analysis/nodes/generate-test-cases-node.js +1 -1
- package/templates/code-analysis/nodes/services/prMetaService.js +1 -1
- package/templates/register-nodes.js +1 -1
- package/scripts/export-default-workflows.js +0 -51
- package/scripts/patch-cursor-mcp.js +0 -174
- package/scripts/setup-ci.sh +0 -115
- package/scripts/setup-official-playwright-mcp.sh +0 -173
- package/scripts/test-with-video.sh +0 -49
|
@@ -1,23 +1,17 @@
|
|
|
1
|
-
var
|
|
2
|
-
|
|
3
|
-
`),images:t}}function hn(r){let e=[];return pr(r,"",e),e}function pr(r,e,t){if(!mt(r))if(e){t.push(`${e}=${Ce(r,e)}`);return}else throw new Error("Codex config overrides must be a plain object");let n=Object.entries(r);if(!(!e&&n.length===0)){if(e&&n.length===0){t.push(`${e}={}`);return}for(let[s,a]of n){if(!s)throw new Error("Codex config override keys must be non-empty strings");if(a===void 0)continue;let i=e?`${e}.${s}`:s;mt(a)?pr(a,i,t):t.push(`${i}=${Ce(a,i)}`)}}}function Ce(r,e){if(typeof r=="string")return JSON.stringify(r);if(typeof r=="number"){if(!Number.isFinite(r))throw new Error(`Codex config override at ${e} must be a finite number`);return`${r}`}else{if(typeof r=="boolean")return r?"true":"false";if(Array.isArray(r))return`[${r.map((n,s)=>Ce(n,`${e}[${s}]`)).join(", ")}]`;if(mt(r)){let t=[];for(let[n,s]of Object.entries(r)){if(!n)throw new Error("Codex config override keys must be non-empty strings");s!==void 0&&t.push(`${yn(n)} = ${Ce(s,`${e}.${n}`)}`)}return`{${t.join(", ")}}`}else{if(r===null)throw new Error(`Codex config override at ${e} cannot be null`);{let t=typeof r;throw new Error(`Unsupported Codex config override value at ${e}: ${t}`)}}}}function yn(r){return gn.test(r)?r:JSON.stringify(r)}function mt(r){return typeof r=="object"&&r!==null&&!Array.isArray(r)}function _n(){let{platform:r,arch:e}=process,t=null;switch(r){case"linux":case"android":switch(e){case"x64":t="x86_64-unknown-linux-musl";break;case"arm64":t="aarch64-unknown-linux-musl";break;default:break}break;case"darwin":switch(e){case"x64":t="x86_64-apple-darwin";break;case"arm64":t="aarch64-apple-darwin";break;default:break}break;case"win32":switch(e){case"x64":t="x86_64-pc-windows-msvc";break;case"arm64":t="aarch64-pc-windows-msvc";break;default:break}break;default:break}if(!t)throw new Error(`Unsupported platform: ${r} (${e})`);let n=pn[t];if(!n)throw new Error(`Unsupported target triple: ${t}`);let s;try{let c=fn.resolve(`${dr}/package.json`),h=lr(c).resolve(`${n}/package.json`);s=Ve.join(Ve.dirname(h),"vendor")}catch{throw new Error(`Unable to locate Codex CLI binaries. Ensure ${dr} is installed with optional dependencies.`)}let a=Ve.join(s,t),i=process.platform==="win32"?"codex.exe":"codex";return Ve.join(a,"codex",i)}var ft,ur,ln,dr,pn,fn,mn,gn,vn,mr=xr(()=>{ft=class{_exec;_options;_id;_threadOptions;get id(){return this._id}constructor(r,e,t,n=null){this._exec=r,this._options=e,this._id=n,this._threadOptions=t}async runStreamed(r,e={}){return{events:this.runStreamedInternal(r,e)}}async*runStreamedInternal(r,e={}){let{schemaPath:t,cleanup:n}=await an(e.outputSchema),s=this._threadOptions,{prompt:a,images:i}=cn(r),o=this._exec.run({input:a,baseUrl:this._options.baseUrl,apiKey:this._options.apiKey,threadId:this._id,images:i,model:s?.model,sandboxMode:s?.sandboxMode,workingDirectory:s?.workingDirectory,skipGitRepoCheck:s?.skipGitRepoCheck,outputSchemaFile:t,modelReasoningEffort:s?.modelReasoningEffort,signal:e.signal,networkAccessEnabled:s?.networkAccessEnabled,webSearchMode:s?.webSearchMode,webSearchEnabled:s?.webSearchEnabled,approvalPolicy:s?.approvalPolicy,additionalDirectories:s?.additionalDirectories});try{for await(let c of o){let l;try{l=JSON.parse(c)}catch(h){throw new Error(`Failed to parse item: ${c}`,{cause:h})}l.type==="thread.started"&&(this._id=l.thread_id),yield l}}finally{await n()}}async run(r,e={}){let t=this.runStreamedInternal(r,e),n=[],s="",a=null,i=null;for await(let o of t)if(o.type==="item.completed")o.item.type==="agent_message"&&(s=o.item.text),n.push(o.item);else if(o.type==="turn.completed")a=o.usage;else if(o.type==="turn.failed"){i=o.error;break}if(i)throw new Error(i.message);return{items:n,finalResponse:s,usage:a}}};ur="CODEX_INTERNAL_ORIGINATOR_OVERRIDE",ln="codex_sdk_ts",dr="@openai/codex",pn={"x86_64-unknown-linux-musl":"@openai/codex-linux-x64","aarch64-unknown-linux-musl":"@openai/codex-linux-arm64","x86_64-apple-darwin":"@openai/codex-darwin-x64","aarch64-apple-darwin":"@openai/codex-darwin-arm64","x86_64-pc-windows-msvc":"@openai/codex-win32-x64","aarch64-pc-windows-msvc":"@openai/codex-win32-arm64"},fn=lr(import.meta.url),mn=class{executablePath;envOverride;configOverrides;constructor(r=null,e,t){this.executablePath=r||_n(),this.envOverride=e,this.configOverrides=t}async*run(r){let e=["exec","--experimental-json"];if(this.configOverrides)for(let c of hn(this.configOverrides))e.push("--config",c);if(r.baseUrl&&e.push("--config",`openai_base_url=${Ce(r.baseUrl,"openai_base_url")}`),r.model&&e.push("--model",r.model),r.sandboxMode&&e.push("--sandbox",r.sandboxMode),r.workingDirectory&&e.push("--cd",r.workingDirectory),r.additionalDirectories?.length)for(let c of r.additionalDirectories)e.push("--add-dir",c);if(r.skipGitRepoCheck&&e.push("--skip-git-repo-check"),r.outputSchemaFile&&e.push("--output-schema",r.outputSchemaFile),r.modelReasoningEffort&&e.push("--config",`model_reasoning_effort="${r.modelReasoningEffort}"`),r.networkAccessEnabled!==void 0&&e.push("--config",`sandbox_workspace_write.network_access=${r.networkAccessEnabled}`),r.webSearchMode?e.push("--config",`web_search="${r.webSearchMode}"`):r.webSearchEnabled===!0?e.push("--config",'web_search="live"'):r.webSearchEnabled===!1&&e.push("--config",'web_search="disabled"'),r.approvalPolicy&&e.push("--config",`approval_policy="${r.approvalPolicy}"`),r.threadId&&e.push("resume",r.threadId),r.images?.length)for(let c of r.images)e.push("--image",c);let t={};if(this.envOverride)Object.assign(t,this.envOverride);else for(let[c,l]of Object.entries(process.env))l!==void 0&&(t[c]=l);t[ur]||(t[ur]=ln),r.apiKey&&(t.CODEX_API_KEY=r.apiKey);let n=un(this.executablePath,e,{env:t,signal:r.signal}),s=null;if(n.once("error",c=>s=c),!n.stdin)throw n.kill(),new Error("Child process has no stdin");if(n.stdin.write(r.input),n.stdin.end(),!n.stdout)throw n.kill(),new Error("Child process has no stdout");let a=[];n.stderr&&n.stderr.on("data",c=>{a.push(c)});let i=new Promise(c=>{n.once("exit",(l,h)=>{c({code:l,signal:h})})}),o=dn.createInterface({input:n.stdout,crlfDelay:1/0});try{for await(let h of o)yield h;if(s)throw s;let{code:c,signal:l}=await i;if(c!==0||l){let h=Buffer.concat(a),A=l?`signal ${l}`:`code ${c??1}`;throw new Error(`Codex Exec exited with ${A}: ${h.toString("utf8")}`)}}finally{o.close(),n.removeAllListeners();try{n.killed||n.kill()}catch{}}}};gn=/^[A-Za-z0-9_-]+$/;vn=class{exec;options;constructor(r={}){let{codexPathOverride:e,env:t,config:n}=r;this.exec=new mn(e,t,n),this.options=r}startThread(r={}){return new ft(this.exec,this.options,r)}resumeThread(r,e={}){return new ft(this.exec,this.options,e,r)}}});var Ie=class{constructor(e,t,n=0){this.name=e,this.description=t,this.priority=n}async invoke(e,t={}){throw new Error("AgentStrategy.invoke() must be implemented by subclass")}canHandle(e){throw new Error("AgentStrategy.canHandle() must be implemented by subclass")}getName(){return this.name}getDescription(){return this.description}getPriority(){return this.priority}};import{execSync as xn}from"node:child_process";var _t=Symbol("Let zodToJsonSchema decide on which parser to use");var yt={name:void 0,$refStrategy:"root",basePath:["#"],effectStrategy:"input",pipeStrategy:"all",dateStrategy:"format:date-time",mapStrategy:"entries",removeAdditionalStrategy:"passthrough",allowedAdditionalProperties:!0,rejectedAdditionalProperties:!1,definitionPath:"definitions",target:"jsonSchema7",strictUnions:!1,definitions:{},errorMessages:!1,markdownDescription:!1,patternStrategy:"escape",applyRegexFlags:!1,emailStrategy:"format:email",base64Strategy:"contentEncoding:base64",nameStrategy:"ref",openAiAnyTypeName:"OpenAiAnyType"},vt=r=>typeof r=="string"?{...yt,name:r}:{...yt,...r};var xt=r=>{let e=vt(r),t=e.name!==void 0?[...e.basePath,e.definitionPath,e.name]:e.basePath;return{...e,flags:{hasReferencedOpenAiAnyType:!1},currentPath:t,propertyPath:void 0,seen:new Map(Object.entries(e.definitions).map(([n,s])=>[s._def,{def:s._def,path:[...e.basePath,e.definitionPath,n],jsonSchema:void 0}]))}};function Ke(r,e,t,n){n?.errorMessages&&t&&(r.errorMessage={...r.errorMessage,[e]:t})}function b(r,e,t,n,s){r[e]=t,Ke(r,e,n,s)}var Re=(r,e)=>{let t=0;for(;t<r.length&&t<e.length&&r[t]===e[t];t++);return[(r.length-t).toString(),...e.slice(t)].join("/")};var x;(function(r){r.assertEqual=s=>{};function e(s){}r.assertIs=e;function t(s){throw new Error}r.assertNever=t,r.arrayToEnum=s=>{let a={};for(let i of s)a[i]=i;return a},r.getValidEnumValues=s=>{let a=r.objectKeys(s).filter(o=>typeof s[s[o]]!="number"),i={};for(let o of a)i[o]=s[o];return r.objectValues(i)},r.objectValues=s=>r.objectKeys(s).map(function(a){return s[a]}),r.objectKeys=typeof Object.keys=="function"?s=>Object.keys(s):s=>{let a=[];for(let i in s)Object.prototype.hasOwnProperty.call(s,i)&&a.push(i);return a},r.find=(s,a)=>{for(let i of s)if(a(i))return i},r.isInteger=typeof Number.isInteger=="function"?s=>Number.isInteger(s):s=>typeof s=="number"&&Number.isFinite(s)&&Math.floor(s)===s;function n(s,a=" | "){return s.map(i=>typeof i=="string"?`'${i}'`:i).join(a)}r.joinValues=n,r.jsonStringifyReplacer=(s,a)=>typeof a=="bigint"?a.toString():a})(x||(x={}));var bt;(function(r){r.mergeShapes=(e,t)=>({...e,...t})})(bt||(bt={}));var f=x.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),V=r=>{switch(typeof r){case"undefined":return f.undefined;case"string":return f.string;case"number":return Number.isNaN(r)?f.nan:f.number;case"boolean":return f.boolean;case"function":return f.function;case"bigint":return f.bigint;case"symbol":return f.symbol;case"object":return Array.isArray(r)?f.array:r===null?f.null:r.then&&typeof r.then=="function"&&r.catch&&typeof r.catch=="function"?f.promise:typeof Map<"u"&&r instanceof Map?f.map:typeof Set<"u"&&r instanceof Set?f.set:typeof Date<"u"&&r instanceof Date?f.date:f.object;default:return f.unknown}};var u=x.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]);var P=class r extends Error{get errors(){return this.issues}constructor(e){super(),this.issues=[],this.addIssue=n=>{this.issues=[...this.issues,n]},this.addIssues=(n=[])=>{this.issues=[...this.issues,...n]};let t=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,t):this.__proto__=t,this.name="ZodError",this.issues=e}format(e){let t=e||function(a){return a.message},n={_errors:[]},s=a=>{for(let i of a.issues)if(i.code==="invalid_union")i.unionErrors.map(s);else if(i.code==="invalid_return_type")s(i.returnTypeError);else if(i.code==="invalid_arguments")s(i.argumentsError);else if(i.path.length===0)n._errors.push(t(i));else{let o=n,c=0;for(;c<i.path.length;){let l=i.path[c];c===i.path.length-1?(o[l]=o[l]||{_errors:[]},o[l]._errors.push(t(i))):o[l]=o[l]||{_errors:[]},o=o[l],c++}}};return s(this),n}static assert(e){if(!(e instanceof r))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,x.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=t=>t.message){let t=Object.create(null),n=[];for(let s of this.issues)if(s.path.length>0){let a=s.path[0];t[a]=t[a]||[],t[a].push(e(s))}else n.push(e(s));return{formErrors:n,fieldErrors:t}}get formErrors(){return this.flatten()}};P.create=r=>new P(r);var kr=(r,e)=>{let t;switch(r.code){case u.invalid_type:r.received===f.undefined?t="Required":t=`Expected ${r.expected}, received ${r.received}`;break;case u.invalid_literal:t=`Invalid literal value, expected ${JSON.stringify(r.expected,x.jsonStringifyReplacer)}`;break;case u.unrecognized_keys:t=`Unrecognized key(s) in object: ${x.joinValues(r.keys,", ")}`;break;case u.invalid_union:t="Invalid input";break;case u.invalid_union_discriminator:t=`Invalid discriminator value. Expected ${x.joinValues(r.options)}`;break;case u.invalid_enum_value:t=`Invalid enum value. Expected ${x.joinValues(r.options)}, received '${r.received}'`;break;case u.invalid_arguments:t="Invalid function arguments";break;case u.invalid_return_type:t="Invalid function return type";break;case u.invalid_date:t="Invalid date";break;case u.invalid_string:typeof r.validation=="object"?"includes"in r.validation?(t=`Invalid input: must include "${r.validation.includes}"`,typeof r.validation.position=="number"&&(t=`${t} at one or more positions greater than or equal to ${r.validation.position}`)):"startsWith"in r.validation?t=`Invalid input: must start with "${r.validation.startsWith}"`:"endsWith"in r.validation?t=`Invalid input: must end with "${r.validation.endsWith}"`:x.assertNever(r.validation):r.validation!=="regex"?t=`Invalid ${r.validation}`:t="Invalid";break;case u.too_small:r.type==="array"?t=`Array must contain ${r.exact?"exactly":r.inclusive?"at least":"more than"} ${r.minimum} element(s)`:r.type==="string"?t=`String must contain ${r.exact?"exactly":r.inclusive?"at least":"over"} ${r.minimum} character(s)`:r.type==="number"?t=`Number must be ${r.exact?"exactly equal to ":r.inclusive?"greater than or equal to ":"greater than "}${r.minimum}`:r.type==="bigint"?t=`Number must be ${r.exact?"exactly equal to ":r.inclusive?"greater than or equal to ":"greater than "}${r.minimum}`:r.type==="date"?t=`Date must be ${r.exact?"exactly equal to ":r.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(r.minimum))}`:t="Invalid input";break;case u.too_big:r.type==="array"?t=`Array must contain ${r.exact?"exactly":r.inclusive?"at most":"less than"} ${r.maximum} element(s)`:r.type==="string"?t=`String must contain ${r.exact?"exactly":r.inclusive?"at most":"under"} ${r.maximum} character(s)`:r.type==="number"?t=`Number must be ${r.exact?"exactly":r.inclusive?"less than or equal to":"less than"} ${r.maximum}`:r.type==="bigint"?t=`BigInt must be ${r.exact?"exactly":r.inclusive?"less than or equal to":"less than"} ${r.maximum}`:r.type==="date"?t=`Date must be ${r.exact?"exactly":r.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(r.maximum))}`:t="Invalid input";break;case u.custom:t="Invalid input";break;case u.invalid_intersection_types:t="Intersection results could not be merged";break;case u.not_multiple_of:t=`Number must be a multiple of ${r.multipleOf}`;break;case u.not_finite:t="Number must be finite";break;default:t=e.defaultError,x.assertNever(r)}return{message:t}},K=kr;var wr=K;function ge(){return wr}var je=r=>{let{data:e,path:t,errorMaps:n,issueData:s}=r,a=[...t,...s.path||[]],i={...s,path:a};if(s.message!==void 0)return{...s,path:a,message:s.message};let o="",c=n.filter(l=>!!l).slice().reverse();for(let l of c)o=l(i,{data:e,defaultError:o}).message;return{...s,path:a,message:o}};function p(r,e){let t=ge(),n=je({issueData:e,data:r.data,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,t,t===K?void 0:K].filter(s=>!!s)});r.common.issues.push(n)}var O=class r{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,t){let n=[];for(let s of t){if(s.status==="aborted")return g;s.status==="dirty"&&e.dirty(),n.push(s.value)}return{status:e.value,value:n}}static async mergeObjectAsync(e,t){let n=[];for(let s of t){let a=await s.key,i=await s.value;n.push({key:a,value:i})}return r.mergeObjectSync(e,n)}static mergeObjectSync(e,t){let n={};for(let s of t){let{key:a,value:i}=s;if(a.status==="aborted"||i.status==="aborted")return g;a.status==="dirty"&&e.dirty(),i.status==="dirty"&&e.dirty(),a.value!=="__proto__"&&(typeof i.value<"u"||s.alwaysSet)&&(n[a.value]=i.value)}return{status:e.value,value:n}}},g=Object.freeze({status:"aborted"}),Q=r=>({status:"dirty",value:r}),T=r=>({status:"valid",value:r}),Je=r=>r.status==="aborted",qe=r=>r.status==="dirty",X=r=>r.status==="valid",ye=r=>typeof Promise<"u"&&r instanceof Promise;var m;(function(r){r.errToObj=e=>typeof e=="string"?{message:e}:e||{},r.toString=e=>typeof e=="string"?e:e?.message})(m||(m={}));var N=class{constructor(e,t,n,s){this._cachedPath=[],this.parent=e,this.data=t,this._path=n,this._key=s}get path(){return this._cachedPath.length||(Array.isArray(this._key)?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}},kt=(r,e)=>{if(X(e))return{success:!0,data:e.value};if(!r.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;let t=new P(r.common.issues);return this._error=t,this._error}}};function _(r){if(!r)return{};let{errorMap:e,invalid_type_error:t,required_error:n,description:s}=r;if(e&&(t||n))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:s}:{errorMap:(i,o)=>{let{message:c}=r;return i.code==="invalid_enum_value"?{message:c??o.defaultError}:typeof o.data>"u"?{message:c??n??o.defaultError}:i.code!=="invalid_type"?{message:o.defaultError}:{message:c??t??o.defaultError}},description:s}}var v=class{get description(){return this._def.description}_getType(e){return V(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:V(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new O,ctx:{common:e.parent.common,data:e.data,parsedType:V(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){let t=this._parse(e);if(ye(t))throw new Error("Synchronous parse encountered promise.");return t}_parseAsync(e){let t=this._parse(e);return Promise.resolve(t)}parse(e,t){let n=this.safeParse(e,t);if(n.success)return n.data;throw n.error}safeParse(e,t){let n={common:{issues:[],async:t?.async??!1,contextualErrorMap:t?.errorMap},path:t?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:V(e)},s=this._parseSync({data:e,path:n.path,parent:n});return kt(n,s)}"~validate"(e){let t={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:V(e)};if(!this["~standard"].async)try{let n=this._parseSync({data:e,path:[],parent:t});return X(n)?{value:n.value}:{issues:t.common.issues}}catch(n){n?.message?.toLowerCase()?.includes("encountered")&&(this["~standard"].async=!0),t.common={issues:[],async:!0}}return this._parseAsync({data:e,path:[],parent:t}).then(n=>X(n)?{value:n.value}:{issues:t.common.issues})}async parseAsync(e,t){let n=await this.safeParseAsync(e,t);if(n.success)return n.data;throw n.error}async safeParseAsync(e,t){let n={common:{issues:[],contextualErrorMap:t?.errorMap,async:!0},path:t?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:V(e)},s=this._parse({data:e,path:n.path,parent:n}),a=await(ye(s)?s:Promise.resolve(s));return kt(n,a)}refine(e,t){let n=s=>typeof t=="string"||typeof t>"u"?{message:t}:typeof t=="function"?t(s):t;return this._refinement((s,a)=>{let i=e(s),o=()=>a.addIssue({code:u.custom,...n(s)});return typeof Promise<"u"&&i instanceof Promise?i.then(c=>c?!0:(o(),!1)):i?!0:(o(),!1)})}refinement(e,t){return this._refinement((n,s)=>e(n)?!0:(s.addIssue(typeof t=="function"?t(n,s):t),!1))}_refinement(e){return new R({schema:this,typeName:d.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}constructor(e){this.spa=this.safeParseAsync,this._def=e,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this["~standard"]={version:1,vendor:"zod",validate:t=>this["~validate"](t)}}optional(){return I.create(this,this._def)}nullable(){return B.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return q.create(this)}promise(){return H.create(this,this._def)}or(e){return se.create([this,e],this._def)}and(e){return ae.create(this,e,this._def)}transform(e){return new R({..._(this._def),schema:this,typeName:d.ZodEffects,effect:{type:"transform",transform:e}})}default(e){let t=typeof e=="function"?e:()=>e;return new de({..._(this._def),innerType:this,defaultValue:t,typeName:d.ZodDefault})}brand(){return new Me({typeName:d.ZodBranded,type:this,..._(this._def)})}catch(e){let t=typeof e=="function"?e:()=>e;return new le({..._(this._def),innerType:this,catchValue:t,typeName:d.ZodCatch})}describe(e){let t=this.constructor;return new t({...this._def,description:e})}pipe(e){return Ze.create(this,e)}readonly(){return pe.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}},Sr=/^c[^\s-]{8,}$/i,Ar=/^[0-9a-z]+$/,Or=/^[0-9A-HJKMNP-TV-Z]{26}$/i,Tr=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,Er=/^[a-z0-9_-]{21}$/i,Pr=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,$r=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,Cr=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,Nr="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",Ye,Dr=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,Ir=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/,Rr=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/,jr=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,Mr=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,Zr=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,wt="((\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\\d|3[01])|(0[469]|11)-(0[1-9]|[12]\\d|30)|(02)-(0[1-9]|1\\d|2[0-8])))",Lr=new RegExp(`^${wt}$`);function St(r){let e="[0-5]\\d";r.precision?e=`${e}\\.\\d{${r.precision}}`:r.precision==null&&(e=`${e}(\\.\\d+)?`);let t=r.precision?"+":"?";return`([01]\\d|2[0-3]):[0-5]\\d(:${e})${t}`}function zr(r){return new RegExp(`^${St(r)}$`)}function Fr(r){let e=`${wt}T${St(r)}`,t=[];return t.push(r.local?"Z?":"Z"),r.offset&&t.push("([+-]\\d{2}:?\\d{2})"),e=`${e}(${t.join("|")})`,new RegExp(`^${e}$`)}function Vr(r,e){return!!((e==="v4"||!e)&&Dr.test(r)||(e==="v6"||!e)&&Rr.test(r))}function Wr(r,e){if(!Pr.test(r))return!1;try{let[t]=r.split(".");if(!t)return!1;let n=t.replace(/-/g,"+").replace(/_/g,"/").padEnd(t.length+(4-t.length%4)%4,"="),s=JSON.parse(atob(n));return!(typeof s!="object"||s===null||"typ"in s&&s?.typ!=="JWT"||!s.alg||e&&s.alg!==e)}catch{return!1}}function Ur(r,e){return!!((e==="v4"||!e)&&Ir.test(r)||(e==="v6"||!e)&&jr.test(r))}var te=class r extends v{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==f.string){let a=this._getOrReturnCtx(e);return p(a,{code:u.invalid_type,expected:f.string,received:a.parsedType}),g}let n=new O,s;for(let a of this._def.checks)if(a.kind==="min")e.data.length<a.value&&(s=this._getOrReturnCtx(e,s),p(s,{code:u.too_small,minimum:a.value,type:"string",inclusive:!0,exact:!1,message:a.message}),n.dirty());else if(a.kind==="max")e.data.length>a.value&&(s=this._getOrReturnCtx(e,s),p(s,{code:u.too_big,maximum:a.value,type:"string",inclusive:!0,exact:!1,message:a.message}),n.dirty());else if(a.kind==="length"){let i=e.data.length>a.value,o=e.data.length<a.value;(i||o)&&(s=this._getOrReturnCtx(e,s),i?p(s,{code:u.too_big,maximum:a.value,type:"string",inclusive:!0,exact:!0,message:a.message}):o&&p(s,{code:u.too_small,minimum:a.value,type:"string",inclusive:!0,exact:!0,message:a.message}),n.dirty())}else if(a.kind==="email")Cr.test(e.data)||(s=this._getOrReturnCtx(e,s),p(s,{validation:"email",code:u.invalid_string,message:a.message}),n.dirty());else if(a.kind==="emoji")Ye||(Ye=new RegExp(Nr,"u")),Ye.test(e.data)||(s=this._getOrReturnCtx(e,s),p(s,{validation:"emoji",code:u.invalid_string,message:a.message}),n.dirty());else if(a.kind==="uuid")Tr.test(e.data)||(s=this._getOrReturnCtx(e,s),p(s,{validation:"uuid",code:u.invalid_string,message:a.message}),n.dirty());else if(a.kind==="nanoid")Er.test(e.data)||(s=this._getOrReturnCtx(e,s),p(s,{validation:"nanoid",code:u.invalid_string,message:a.message}),n.dirty());else if(a.kind==="cuid")Sr.test(e.data)||(s=this._getOrReturnCtx(e,s),p(s,{validation:"cuid",code:u.invalid_string,message:a.message}),n.dirty());else if(a.kind==="cuid2")Ar.test(e.data)||(s=this._getOrReturnCtx(e,s),p(s,{validation:"cuid2",code:u.invalid_string,message:a.message}),n.dirty());else if(a.kind==="ulid")Or.test(e.data)||(s=this._getOrReturnCtx(e,s),p(s,{validation:"ulid",code:u.invalid_string,message:a.message}),n.dirty());else if(a.kind==="url")try{new URL(e.data)}catch{s=this._getOrReturnCtx(e,s),p(s,{validation:"url",code:u.invalid_string,message:a.message}),n.dirty()}else a.kind==="regex"?(a.regex.lastIndex=0,a.regex.test(e.data)||(s=this._getOrReturnCtx(e,s),p(s,{validation:"regex",code:u.invalid_string,message:a.message}),n.dirty())):a.kind==="trim"?e.data=e.data.trim():a.kind==="includes"?e.data.includes(a.value,a.position)||(s=this._getOrReturnCtx(e,s),p(s,{code:u.invalid_string,validation:{includes:a.value,position:a.position},message:a.message}),n.dirty()):a.kind==="toLowerCase"?e.data=e.data.toLowerCase():a.kind==="toUpperCase"?e.data=e.data.toUpperCase():a.kind==="startsWith"?e.data.startsWith(a.value)||(s=this._getOrReturnCtx(e,s),p(s,{code:u.invalid_string,validation:{startsWith:a.value},message:a.message}),n.dirty()):a.kind==="endsWith"?e.data.endsWith(a.value)||(s=this._getOrReturnCtx(e,s),p(s,{code:u.invalid_string,validation:{endsWith:a.value},message:a.message}),n.dirty()):a.kind==="datetime"?Fr(a).test(e.data)||(s=this._getOrReturnCtx(e,s),p(s,{code:u.invalid_string,validation:"datetime",message:a.message}),n.dirty()):a.kind==="date"?Lr.test(e.data)||(s=this._getOrReturnCtx(e,s),p(s,{code:u.invalid_string,validation:"date",message:a.message}),n.dirty()):a.kind==="time"?zr(a).test(e.data)||(s=this._getOrReturnCtx(e,s),p(s,{code:u.invalid_string,validation:"time",message:a.message}),n.dirty()):a.kind==="duration"?$r.test(e.data)||(s=this._getOrReturnCtx(e,s),p(s,{validation:"duration",code:u.invalid_string,message:a.message}),n.dirty()):a.kind==="ip"?Vr(e.data,a.version)||(s=this._getOrReturnCtx(e,s),p(s,{validation:"ip",code:u.invalid_string,message:a.message}),n.dirty()):a.kind==="jwt"?Wr(e.data,a.alg)||(s=this._getOrReturnCtx(e,s),p(s,{validation:"jwt",code:u.invalid_string,message:a.message}),n.dirty()):a.kind==="cidr"?Ur(e.data,a.version)||(s=this._getOrReturnCtx(e,s),p(s,{validation:"cidr",code:u.invalid_string,message:a.message}),n.dirty()):a.kind==="base64"?Mr.test(e.data)||(s=this._getOrReturnCtx(e,s),p(s,{validation:"base64",code:u.invalid_string,message:a.message}),n.dirty()):a.kind==="base64url"?Zr.test(e.data)||(s=this._getOrReturnCtx(e,s),p(s,{validation:"base64url",code:u.invalid_string,message:a.message}),n.dirty()):x.assertNever(a);return{status:n.value,value:e.data}}_regex(e,t,n){return this.refinement(s=>e.test(s),{validation:t,code:u.invalid_string,...m.errToObj(n)})}_addCheck(e){return new r({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...m.errToObj(e)})}url(e){return this._addCheck({kind:"url",...m.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...m.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...m.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...m.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...m.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...m.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...m.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...m.errToObj(e)})}base64url(e){return this._addCheck({kind:"base64url",...m.errToObj(e)})}jwt(e){return this._addCheck({kind:"jwt",...m.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...m.errToObj(e)})}cidr(e){return this._addCheck({kind:"cidr",...m.errToObj(e)})}datetime(e){return typeof e=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:e}):this._addCheck({kind:"datetime",precision:typeof e?.precision>"u"?null:e?.precision,offset:e?.offset??!1,local:e?.local??!1,...m.errToObj(e?.message)})}date(e){return this._addCheck({kind:"date",message:e})}time(e){return typeof e=="string"?this._addCheck({kind:"time",precision:null,message:e}):this._addCheck({kind:"time",precision:typeof e?.precision>"u"?null:e?.precision,...m.errToObj(e?.message)})}duration(e){return this._addCheck({kind:"duration",...m.errToObj(e)})}regex(e,t){return this._addCheck({kind:"regex",regex:e,...m.errToObj(t)})}includes(e,t){return this._addCheck({kind:"includes",value:e,position:t?.position,...m.errToObj(t?.message)})}startsWith(e,t){return this._addCheck({kind:"startsWith",value:e,...m.errToObj(t)})}endsWith(e,t){return this._addCheck({kind:"endsWith",value:e,...m.errToObj(t)})}min(e,t){return this._addCheck({kind:"min",value:e,...m.errToObj(t)})}max(e,t){return this._addCheck({kind:"max",value:e,...m.errToObj(t)})}length(e,t){return this._addCheck({kind:"length",value:e,...m.errToObj(t)})}nonempty(e){return this.min(1,m.errToObj(e))}trim(){return new r({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new r({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new r({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(e=>e.kind==="datetime")}get isDate(){return!!this._def.checks.find(e=>e.kind==="date")}get isTime(){return!!this._def.checks.find(e=>e.kind==="time")}get isDuration(){return!!this._def.checks.find(e=>e.kind==="duration")}get isEmail(){return!!this._def.checks.find(e=>e.kind==="email")}get isURL(){return!!this._def.checks.find(e=>e.kind==="url")}get isEmoji(){return!!this._def.checks.find(e=>e.kind==="emoji")}get isUUID(){return!!this._def.checks.find(e=>e.kind==="uuid")}get isNANOID(){return!!this._def.checks.find(e=>e.kind==="nanoid")}get isCUID(){return!!this._def.checks.find(e=>e.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(e=>e.kind==="cuid2")}get isULID(){return!!this._def.checks.find(e=>e.kind==="ulid")}get isIP(){return!!this._def.checks.find(e=>e.kind==="ip")}get isCIDR(){return!!this._def.checks.find(e=>e.kind==="cidr")}get isBase64(){return!!this._def.checks.find(e=>e.kind==="base64")}get isBase64url(){return!!this._def.checks.find(e=>e.kind==="base64url")}get minLength(){let e=null;for(let t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxLength(){let e=null;for(let t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}};te.create=r=>new te({checks:[],typeName:d.ZodString,coerce:r?.coerce??!1,..._(r)});function Br(r,e){let t=(r.toString().split(".")[1]||"").length,n=(e.toString().split(".")[1]||"").length,s=t>n?t:n,a=Number.parseInt(r.toFixed(s).replace(".","")),i=Number.parseInt(e.toFixed(s).replace(".",""));return a%i/10**s}var _e=class r extends v{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(e){if(this._def.coerce&&(e.data=Number(e.data)),this._getType(e)!==f.number){let a=this._getOrReturnCtx(e);return p(a,{code:u.invalid_type,expected:f.number,received:a.parsedType}),g}let n,s=new O;for(let a of this._def.checks)a.kind==="int"?x.isInteger(e.data)||(n=this._getOrReturnCtx(e,n),p(n,{code:u.invalid_type,expected:"integer",received:"float",message:a.message}),s.dirty()):a.kind==="min"?(a.inclusive?e.data<a.value:e.data<=a.value)&&(n=this._getOrReturnCtx(e,n),p(n,{code:u.too_small,minimum:a.value,type:"number",inclusive:a.inclusive,exact:!1,message:a.message}),s.dirty()):a.kind==="max"?(a.inclusive?e.data>a.value:e.data>=a.value)&&(n=this._getOrReturnCtx(e,n),p(n,{code:u.too_big,maximum:a.value,type:"number",inclusive:a.inclusive,exact:!1,message:a.message}),s.dirty()):a.kind==="multipleOf"?Br(e.data,a.value)!==0&&(n=this._getOrReturnCtx(e,n),p(n,{code:u.not_multiple_of,multipleOf:a.value,message:a.message}),s.dirty()):a.kind==="finite"?Number.isFinite(e.data)||(n=this._getOrReturnCtx(e,n),p(n,{code:u.not_finite,message:a.message}),s.dirty()):x.assertNever(a);return{status:s.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,m.toString(t))}gt(e,t){return this.setLimit("min",e,!1,m.toString(t))}lte(e,t){return this.setLimit("max",e,!0,m.toString(t))}lt(e,t){return this.setLimit("max",e,!1,m.toString(t))}setLimit(e,t,n,s){return new r({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:n,message:m.toString(s)}]})}_addCheck(e){return new r({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:m.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:m.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:m.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:m.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:m.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:m.toString(t)})}finite(e){return this._addCheck({kind:"finite",message:m.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:m.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:m.toString(e)})}get minValue(){let e=null;for(let t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(let t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}get isInt(){return!!this._def.checks.find(e=>e.kind==="int"||e.kind==="multipleOf"&&x.isInteger(e.value))}get isFinite(){let e=null,t=null;for(let n of this._def.checks){if(n.kind==="finite"||n.kind==="int"||n.kind==="multipleOf")return!0;n.kind==="min"?(t===null||n.value>t)&&(t=n.value):n.kind==="max"&&(e===null||n.value<e)&&(e=n.value)}return Number.isFinite(t)&&Number.isFinite(e)}};_e.create=r=>new _e({checks:[],typeName:d.ZodNumber,coerce:r?.coerce||!1,..._(r)});var ve=class r extends v{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){if(this._def.coerce)try{e.data=BigInt(e.data)}catch{return this._getInvalidInput(e)}if(this._getType(e)!==f.bigint)return this._getInvalidInput(e);let n,s=new O;for(let a of this._def.checks)a.kind==="min"?(a.inclusive?e.data<a.value:e.data<=a.value)&&(n=this._getOrReturnCtx(e,n),p(n,{code:u.too_small,type:"bigint",minimum:a.value,inclusive:a.inclusive,message:a.message}),s.dirty()):a.kind==="max"?(a.inclusive?e.data>a.value:e.data>=a.value)&&(n=this._getOrReturnCtx(e,n),p(n,{code:u.too_big,type:"bigint",maximum:a.value,inclusive:a.inclusive,message:a.message}),s.dirty()):a.kind==="multipleOf"?e.data%a.value!==BigInt(0)&&(n=this._getOrReturnCtx(e,n),p(n,{code:u.not_multiple_of,multipleOf:a.value,message:a.message}),s.dirty()):x.assertNever(a);return{status:s.value,value:e.data}}_getInvalidInput(e){let t=this._getOrReturnCtx(e);return p(t,{code:u.invalid_type,expected:f.bigint,received:t.parsedType}),g}gte(e,t){return this.setLimit("min",e,!0,m.toString(t))}gt(e,t){return this.setLimit("min",e,!1,m.toString(t))}lte(e,t){return this.setLimit("max",e,!0,m.toString(t))}lt(e,t){return this.setLimit("max",e,!1,m.toString(t))}setLimit(e,t,n,s){return new r({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:n,message:m.toString(s)}]})}_addCheck(e){return new r({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:m.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:m.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:m.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:m.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:m.toString(t)})}get minValue(){let e=null;for(let t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(let t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}};ve.create=r=>new ve({checks:[],typeName:d.ZodBigInt,coerce:r?.coerce??!1,..._(r)});var xe=class extends v{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==f.boolean){let n=this._getOrReturnCtx(e);return p(n,{code:u.invalid_type,expected:f.boolean,received:n.parsedType}),g}return T(e.data)}};xe.create=r=>new xe({typeName:d.ZodBoolean,coerce:r?.coerce||!1,..._(r)});var be=class r extends v{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==f.date){let a=this._getOrReturnCtx(e);return p(a,{code:u.invalid_type,expected:f.date,received:a.parsedType}),g}if(Number.isNaN(e.data.getTime())){let a=this._getOrReturnCtx(e);return p(a,{code:u.invalid_date}),g}let n=new O,s;for(let a of this._def.checks)a.kind==="min"?e.data.getTime()<a.value&&(s=this._getOrReturnCtx(e,s),p(s,{code:u.too_small,message:a.message,inclusive:!0,exact:!1,minimum:a.value,type:"date"}),n.dirty()):a.kind==="max"?e.data.getTime()>a.value&&(s=this._getOrReturnCtx(e,s),p(s,{code:u.too_big,message:a.message,inclusive:!0,exact:!1,maximum:a.value,type:"date"}),n.dirty()):x.assertNever(a);return{status:n.value,value:new Date(e.data.getTime())}}_addCheck(e){return new r({...this._def,checks:[...this._def.checks,e]})}min(e,t){return this._addCheck({kind:"min",value:e.getTime(),message:m.toString(t)})}max(e,t){return this._addCheck({kind:"max",value:e.getTime(),message:m.toString(t)})}get minDate(){let e=null;for(let t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e!=null?new Date(e):null}get maxDate(){let e=null;for(let t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e!=null?new Date(e):null}};be.create=r=>new be({checks:[],coerce:r?.coerce||!1,typeName:d.ZodDate,..._(r)});var ke=class extends v{_parse(e){if(this._getType(e)!==f.symbol){let n=this._getOrReturnCtx(e);return p(n,{code:u.invalid_type,expected:f.symbol,received:n.parsedType}),g}return T(e.data)}};ke.create=r=>new ke({typeName:d.ZodSymbol,..._(r)});var re=class extends v{_parse(e){if(this._getType(e)!==f.undefined){let n=this._getOrReturnCtx(e);return p(n,{code:u.invalid_type,expected:f.undefined,received:n.parsedType}),g}return T(e.data)}};re.create=r=>new re({typeName:d.ZodUndefined,..._(r)});var ne=class extends v{_parse(e){if(this._getType(e)!==f.null){let n=this._getOrReturnCtx(e);return p(n,{code:u.invalid_type,expected:f.null,received:n.parsedType}),g}return T(e.data)}};ne.create=r=>new ne({typeName:d.ZodNull,..._(r)});var we=class extends v{constructor(){super(...arguments),this._any=!0}_parse(e){return T(e.data)}};we.create=r=>new we({typeName:d.ZodAny,..._(r)});var J=class extends v{constructor(){super(...arguments),this._unknown=!0}_parse(e){return T(e.data)}};J.create=r=>new J({typeName:d.ZodUnknown,..._(r)});var Z=class extends v{_parse(e){let t=this._getOrReturnCtx(e);return p(t,{code:u.invalid_type,expected:f.never,received:t.parsedType}),g}};Z.create=r=>new Z({typeName:d.ZodNever,..._(r)});var Se=class extends v{_parse(e){if(this._getType(e)!==f.undefined){let n=this._getOrReturnCtx(e);return p(n,{code:u.invalid_type,expected:f.void,received:n.parsedType}),g}return T(e.data)}};Se.create=r=>new Se({typeName:d.ZodVoid,..._(r)});var q=class r extends v{_parse(e){let{ctx:t,status:n}=this._processInputParams(e),s=this._def;if(t.parsedType!==f.array)return p(t,{code:u.invalid_type,expected:f.array,received:t.parsedType}),g;if(s.exactLength!==null){let i=t.data.length>s.exactLength.value,o=t.data.length<s.exactLength.value;(i||o)&&(p(t,{code:i?u.too_big:u.too_small,minimum:o?s.exactLength.value:void 0,maximum:i?s.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:s.exactLength.message}),n.dirty())}if(s.minLength!==null&&t.data.length<s.minLength.value&&(p(t,{code:u.too_small,minimum:s.minLength.value,type:"array",inclusive:!0,exact:!1,message:s.minLength.message}),n.dirty()),s.maxLength!==null&&t.data.length>s.maxLength.value&&(p(t,{code:u.too_big,maximum:s.maxLength.value,type:"array",inclusive:!0,exact:!1,message:s.maxLength.message}),n.dirty()),t.common.async)return Promise.all([...t.data].map((i,o)=>s.type._parseAsync(new N(t,i,t.path,o)))).then(i=>O.mergeArray(n,i));let a=[...t.data].map((i,o)=>s.type._parseSync(new N(t,i,t.path,o)));return O.mergeArray(n,a)}get element(){return this._def.type}min(e,t){return new r({...this._def,minLength:{value:e,message:m.toString(t)}})}max(e,t){return new r({...this._def,maxLength:{value:e,message:m.toString(t)}})}length(e,t){return new r({...this._def,exactLength:{value:e,message:m.toString(t)}})}nonempty(e){return this.min(1,e)}};q.create=(r,e)=>new q({type:r,minLength:null,maxLength:null,exactLength:null,typeName:d.ZodArray,..._(e)});function ee(r){if(r instanceof $){let e={};for(let t in r.shape){let n=r.shape[t];e[t]=I.create(ee(n))}return new $({...r._def,shape:()=>e})}else return r instanceof q?new q({...r._def,type:ee(r.element)}):r instanceof I?I.create(ee(r.unwrap())):r instanceof B?B.create(ee(r.unwrap())):r instanceof U?U.create(r.items.map(e=>ee(e))):r}var $=class r extends v{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;let e=this._def.shape(),t=x.objectKeys(e);return this._cached={shape:e,keys:t},this._cached}_parse(e){if(this._getType(e)!==f.object){let l=this._getOrReturnCtx(e);return p(l,{code:u.invalid_type,expected:f.object,received:l.parsedType}),g}let{status:n,ctx:s}=this._processInputParams(e),{shape:a,keys:i}=this._getCached(),o=[];if(!(this._def.catchall instanceof Z&&this._def.unknownKeys==="strip"))for(let l in s.data)i.includes(l)||o.push(l);let c=[];for(let l of i){let h=a[l],A=s.data[l];c.push({key:{status:"valid",value:l},value:h._parse(new N(s,A,s.path,l)),alwaysSet:l in s.data})}if(this._def.catchall instanceof Z){let l=this._def.unknownKeys;if(l==="passthrough")for(let h of o)c.push({key:{status:"valid",value:h},value:{status:"valid",value:s.data[h]}});else if(l==="strict")o.length>0&&(p(s,{code:u.unrecognized_keys,keys:o}),n.dirty());else if(l!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{let l=this._def.catchall;for(let h of o){let A=s.data[h];c.push({key:{status:"valid",value:h},value:l._parse(new N(s,A,s.path,h)),alwaysSet:h in s.data})}}return s.common.async?Promise.resolve().then(async()=>{let l=[];for(let h of c){let A=await h.key,C=await h.value;l.push({key:A,value:C,alwaysSet:h.alwaysSet})}return l}).then(l=>O.mergeObjectSync(n,l)):O.mergeObjectSync(n,c)}get shape(){return this._def.shape()}strict(e){return m.errToObj,new r({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(t,n)=>{let s=this._def.errorMap?.(t,n).message??n.defaultError;return t.code==="unrecognized_keys"?{message:m.errToObj(e).message??s}:{message:s}}}:{}})}strip(){return new r({...this._def,unknownKeys:"strip"})}passthrough(){return new r({...this._def,unknownKeys:"passthrough"})}extend(e){return new r({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new r({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:d.ZodObject})}setKey(e,t){return this.augment({[e]:t})}catchall(e){return new r({...this._def,catchall:e})}pick(e){let t={};for(let n of x.objectKeys(e))e[n]&&this.shape[n]&&(t[n]=this.shape[n]);return new r({...this._def,shape:()=>t})}omit(e){let t={};for(let n of x.objectKeys(this.shape))e[n]||(t[n]=this.shape[n]);return new r({...this._def,shape:()=>t})}deepPartial(){return ee(this)}partial(e){let t={};for(let n of x.objectKeys(this.shape)){let s=this.shape[n];e&&!e[n]?t[n]=s:t[n]=s.optional()}return new r({...this._def,shape:()=>t})}required(e){let t={};for(let n of x.objectKeys(this.shape))if(e&&!e[n])t[n]=this.shape[n];else{let a=this.shape[n];for(;a instanceof I;)a=a._def.innerType;t[n]=a}return new r({...this._def,shape:()=>t})}keyof(){return At(x.objectKeys(this.shape))}};$.create=(r,e)=>new $({shape:()=>r,unknownKeys:"strip",catchall:Z.create(),typeName:d.ZodObject,..._(e)});$.strictCreate=(r,e)=>new $({shape:()=>r,unknownKeys:"strict",catchall:Z.create(),typeName:d.ZodObject,..._(e)});$.lazycreate=(r,e)=>new $({shape:r,unknownKeys:"strip",catchall:Z.create(),typeName:d.ZodObject,..._(e)});var se=class extends v{_parse(e){let{ctx:t}=this._processInputParams(e),n=this._def.options;function s(a){for(let o of a)if(o.result.status==="valid")return o.result;for(let o of a)if(o.result.status==="dirty")return t.common.issues.push(...o.ctx.common.issues),o.result;let i=a.map(o=>new P(o.ctx.common.issues));return p(t,{code:u.invalid_union,unionErrors:i}),g}if(t.common.async)return Promise.all(n.map(async a=>{let i={...t,common:{...t.common,issues:[]},parent:null};return{result:await a._parseAsync({data:t.data,path:t.path,parent:i}),ctx:i}})).then(s);{let a,i=[];for(let c of n){let l={...t,common:{...t.common,issues:[]},parent:null},h=c._parseSync({data:t.data,path:t.path,parent:l});if(h.status==="valid")return h;h.status==="dirty"&&!a&&(a={result:h,ctx:l}),l.common.issues.length&&i.push(l.common.issues)}if(a)return t.common.issues.push(...a.ctx.common.issues),a.result;let o=i.map(c=>new P(c));return p(t,{code:u.invalid_union,unionErrors:o}),g}}get options(){return this._def.options}};se.create=(r,e)=>new se({options:r,typeName:d.ZodUnion,..._(e)});var W=r=>r instanceof ie?W(r.schema):r instanceof R?W(r.innerType()):r instanceof oe?[r.value]:r instanceof ce?r.options:r instanceof ue?x.objectValues(r.enum):r instanceof de?W(r._def.innerType):r instanceof re?[void 0]:r instanceof ne?[null]:r instanceof I?[void 0,...W(r.unwrap())]:r instanceof B?[null,...W(r.unwrap())]:r instanceof Me||r instanceof pe?W(r.unwrap()):r instanceof le?W(r._def.innerType):[],Xe=class r extends v{_parse(e){let{ctx:t}=this._processInputParams(e);if(t.parsedType!==f.object)return p(t,{code:u.invalid_type,expected:f.object,received:t.parsedType}),g;let n=this.discriminator,s=t.data[n],a=this.optionsMap.get(s);return a?t.common.async?a._parseAsync({data:t.data,path:t.path,parent:t}):a._parseSync({data:t.data,path:t.path,parent:t}):(p(t,{code:u.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[n]}),g)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,t,n){let s=new Map;for(let a of t){let i=W(a.shape[e]);if(!i.length)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(let o of i){if(s.has(o))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(o)}`);s.set(o,a)}}return new r({typeName:d.ZodDiscriminatedUnion,discriminator:e,options:t,optionsMap:s,..._(n)})}};function He(r,e){let t=V(r),n=V(e);if(r===e)return{valid:!0,data:r};if(t===f.object&&n===f.object){let s=x.objectKeys(e),a=x.objectKeys(r).filter(o=>s.indexOf(o)!==-1),i={...r,...e};for(let o of a){let c=He(r[o],e[o]);if(!c.valid)return{valid:!1};i[o]=c.data}return{valid:!0,data:i}}else if(t===f.array&&n===f.array){if(r.length!==e.length)return{valid:!1};let s=[];for(let a=0;a<r.length;a++){let i=r[a],o=e[a],c=He(i,o);if(!c.valid)return{valid:!1};s.push(c.data)}return{valid:!0,data:s}}else return t===f.date&&n===f.date&&+r==+e?{valid:!0,data:r}:{valid:!1}}var ae=class extends v{_parse(e){let{status:t,ctx:n}=this._processInputParams(e),s=(a,i)=>{if(Je(a)||Je(i))return g;let o=He(a.value,i.value);return o.valid?((qe(a)||qe(i))&&t.dirty(),{status:t.value,value:o.data}):(p(n,{code:u.invalid_intersection_types}),g)};return n.common.async?Promise.all([this._def.left._parseAsync({data:n.data,path:n.path,parent:n}),this._def.right._parseAsync({data:n.data,path:n.path,parent:n})]).then(([a,i])=>s(a,i)):s(this._def.left._parseSync({data:n.data,path:n.path,parent:n}),this._def.right._parseSync({data:n.data,path:n.path,parent:n}))}};ae.create=(r,e,t)=>new ae({left:r,right:e,typeName:d.ZodIntersection,..._(t)});var U=class r extends v{_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==f.array)return p(n,{code:u.invalid_type,expected:f.array,received:n.parsedType}),g;if(n.data.length<this._def.items.length)return p(n,{code:u.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),g;!this._def.rest&&n.data.length>this._def.items.length&&(p(n,{code:u.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),t.dirty());let a=[...n.data].map((i,o)=>{let c=this._def.items[o]||this._def.rest;return c?c._parse(new N(n,i,n.path,o)):null}).filter(i=>!!i);return n.common.async?Promise.all(a).then(i=>O.mergeArray(t,i)):O.mergeArray(t,a)}get items(){return this._def.items}rest(e){return new r({...this._def,rest:e})}};U.create=(r,e)=>{if(!Array.isArray(r))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new U({items:r,typeName:d.ZodTuple,rest:null,..._(e)})};var Qe=class r extends v{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==f.object)return p(n,{code:u.invalid_type,expected:f.object,received:n.parsedType}),g;let s=[],a=this._def.keyType,i=this._def.valueType;for(let o in n.data)s.push({key:a._parse(new N(n,o,n.path,o)),value:i._parse(new N(n,n.data[o],n.path,o)),alwaysSet:o in n.data});return n.common.async?O.mergeObjectAsync(t,s):O.mergeObjectSync(t,s)}get element(){return this._def.valueType}static create(e,t,n){return t instanceof v?new r({keyType:e,valueType:t,typeName:d.ZodRecord,..._(n)}):new r({keyType:te.create(),valueType:e,typeName:d.ZodRecord,..._(t)})}},Ae=class extends v{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==f.map)return p(n,{code:u.invalid_type,expected:f.map,received:n.parsedType}),g;let s=this._def.keyType,a=this._def.valueType,i=[...n.data.entries()].map(([o,c],l)=>({key:s._parse(new N(n,o,n.path,[l,"key"])),value:a._parse(new N(n,c,n.path,[l,"value"]))}));if(n.common.async){let o=new Map;return Promise.resolve().then(async()=>{for(let c of i){let l=await c.key,h=await c.value;if(l.status==="aborted"||h.status==="aborted")return g;(l.status==="dirty"||h.status==="dirty")&&t.dirty(),o.set(l.value,h.value)}return{status:t.value,value:o}})}else{let o=new Map;for(let c of i){let l=c.key,h=c.value;if(l.status==="aborted"||h.status==="aborted")return g;(l.status==="dirty"||h.status==="dirty")&&t.dirty(),o.set(l.value,h.value)}return{status:t.value,value:o}}}};Ae.create=(r,e,t)=>new Ae({valueType:e,keyType:r,typeName:d.ZodMap,..._(t)});var Oe=class r extends v{_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==f.set)return p(n,{code:u.invalid_type,expected:f.set,received:n.parsedType}),g;let s=this._def;s.minSize!==null&&n.data.size<s.minSize.value&&(p(n,{code:u.too_small,minimum:s.minSize.value,type:"set",inclusive:!0,exact:!1,message:s.minSize.message}),t.dirty()),s.maxSize!==null&&n.data.size>s.maxSize.value&&(p(n,{code:u.too_big,maximum:s.maxSize.value,type:"set",inclusive:!0,exact:!1,message:s.maxSize.message}),t.dirty());let a=this._def.valueType;function i(c){let l=new Set;for(let h of c){if(h.status==="aborted")return g;h.status==="dirty"&&t.dirty(),l.add(h.value)}return{status:t.value,value:l}}let o=[...n.data.values()].map((c,l)=>a._parse(new N(n,c,n.path,l)));return n.common.async?Promise.all(o).then(c=>i(c)):i(o)}min(e,t){return new r({...this._def,minSize:{value:e,message:m.toString(t)}})}max(e,t){return new r({...this._def,maxSize:{value:e,message:m.toString(t)}})}size(e,t){return this.min(e,t).max(e,t)}nonempty(e){return this.min(1,e)}};Oe.create=(r,e)=>new Oe({valueType:r,minSize:null,maxSize:null,typeName:d.ZodSet,..._(e)});var et=class r extends v{constructor(){super(...arguments),this.validate=this.implement}_parse(e){let{ctx:t}=this._processInputParams(e);if(t.parsedType!==f.function)return p(t,{code:u.invalid_type,expected:f.function,received:t.parsedType}),g;function n(o,c){return je({data:o,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,ge(),K].filter(l=>!!l),issueData:{code:u.invalid_arguments,argumentsError:c}})}function s(o,c){return je({data:o,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,ge(),K].filter(l=>!!l),issueData:{code:u.invalid_return_type,returnTypeError:c}})}let a={errorMap:t.common.contextualErrorMap},i=t.data;if(this._def.returns instanceof H){let o=this;return T(async function(...c){let l=new P([]),h=await o._def.args.parseAsync(c,a).catch(G=>{throw l.addIssue(n(c,G)),l}),A=await Reflect.apply(i,this,h);return await o._def.returns._def.type.parseAsync(A,a).catch(G=>{throw l.addIssue(s(A,G)),l})})}else{let o=this;return T(function(...c){let l=o._def.args.safeParse(c,a);if(!l.success)throw new P([n(c,l.error)]);let h=Reflect.apply(i,this,l.data),A=o._def.returns.safeParse(h,a);if(!A.success)throw new P([s(h,A.error)]);return A.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new r({...this._def,args:U.create(e).rest(J.create())})}returns(e){return new r({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,t,n){return new r({args:e||U.create([]).rest(J.create()),returns:t||J.create(),typeName:d.ZodFunction,..._(n)})}},ie=class extends v{get schema(){return this._def.getter()}_parse(e){let{ctx:t}=this._processInputParams(e);return this._def.getter()._parse({data:t.data,path:t.path,parent:t})}};ie.create=(r,e)=>new ie({getter:r,typeName:d.ZodLazy,..._(e)});var oe=class extends v{_parse(e){if(e.data!==this._def.value){let t=this._getOrReturnCtx(e);return p(t,{received:t.data,code:u.invalid_literal,expected:this._def.value}),g}return{status:"valid",value:e.data}}get value(){return this._def.value}};oe.create=(r,e)=>new oe({value:r,typeName:d.ZodLiteral,..._(e)});function At(r,e){return new ce({values:r,typeName:d.ZodEnum,..._(e)})}var ce=class r extends v{_parse(e){if(typeof e.data!="string"){let t=this._getOrReturnCtx(e),n=this._def.values;return p(t,{expected:x.joinValues(n),received:t.parsedType,code:u.invalid_type}),g}if(this._cache||(this._cache=new Set(this._def.values)),!this._cache.has(e.data)){let t=this._getOrReturnCtx(e),n=this._def.values;return p(t,{received:t.data,code:u.invalid_enum_value,options:n}),g}return T(e.data)}get options(){return this._def.values}get enum(){let e={};for(let t of this._def.values)e[t]=t;return e}get Values(){let e={};for(let t of this._def.values)e[t]=t;return e}get Enum(){let e={};for(let t of this._def.values)e[t]=t;return e}extract(e,t=this._def){return r.create(e,{...this._def,...t})}exclude(e,t=this._def){return r.create(this.options.filter(n=>!e.includes(n)),{...this._def,...t})}};ce.create=At;var ue=class extends v{_parse(e){let t=x.getValidEnumValues(this._def.values),n=this._getOrReturnCtx(e);if(n.parsedType!==f.string&&n.parsedType!==f.number){let s=x.objectValues(t);return p(n,{expected:x.joinValues(s),received:n.parsedType,code:u.invalid_type}),g}if(this._cache||(this._cache=new Set(x.getValidEnumValues(this._def.values))),!this._cache.has(e.data)){let s=x.objectValues(t);return p(n,{received:n.data,code:u.invalid_enum_value,options:s}),g}return T(e.data)}get enum(){return this._def.values}};ue.create=(r,e)=>new ue({values:r,typeName:d.ZodNativeEnum,..._(e)});var H=class extends v{unwrap(){return this._def.type}_parse(e){let{ctx:t}=this._processInputParams(e);if(t.parsedType!==f.promise&&t.common.async===!1)return p(t,{code:u.invalid_type,expected:f.promise,received:t.parsedType}),g;let n=t.parsedType===f.promise?t.data:Promise.resolve(t.data);return T(n.then(s=>this._def.type.parseAsync(s,{path:t.path,errorMap:t.common.contextualErrorMap})))}};H.create=(r,e)=>new H({type:r,typeName:d.ZodPromise,..._(e)});var R=class extends v{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===d.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){let{status:t,ctx:n}=this._processInputParams(e),s=this._def.effect||null,a={addIssue:i=>{p(n,i),i.fatal?t.abort():t.dirty()},get path(){return n.path}};if(a.addIssue=a.addIssue.bind(a),s.type==="preprocess"){let i=s.transform(n.data,a);if(n.common.async)return Promise.resolve(i).then(async o=>{if(t.value==="aborted")return g;let c=await this._def.schema._parseAsync({data:o,path:n.path,parent:n});return c.status==="aborted"?g:c.status==="dirty"?Q(c.value):t.value==="dirty"?Q(c.value):c});{if(t.value==="aborted")return g;let o=this._def.schema._parseSync({data:i,path:n.path,parent:n});return o.status==="aborted"?g:o.status==="dirty"?Q(o.value):t.value==="dirty"?Q(o.value):o}}if(s.type==="refinement"){let i=o=>{let c=s.refinement(o,a);if(n.common.async)return Promise.resolve(c);if(c instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return o};if(n.common.async===!1){let o=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});return o.status==="aborted"?g:(o.status==="dirty"&&t.dirty(),i(o.value),{status:t.value,value:o.value})}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(o=>o.status==="aborted"?g:(o.status==="dirty"&&t.dirty(),i(o.value).then(()=>({status:t.value,value:o.value}))))}if(s.type==="transform")if(n.common.async===!1){let i=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});if(!X(i))return g;let o=s.transform(i.value,a);if(o instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:t.value,value:o}}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(i=>X(i)?Promise.resolve(s.transform(i.value,a)).then(o=>({status:t.value,value:o})):g);x.assertNever(s)}};R.create=(r,e,t)=>new R({schema:r,typeName:d.ZodEffects,effect:e,..._(t)});R.createWithPreprocess=(r,e,t)=>new R({schema:e,effect:{type:"preprocess",transform:r},typeName:d.ZodEffects,..._(t)});var I=class extends v{_parse(e){return this._getType(e)===f.undefined?T(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};I.create=(r,e)=>new I({innerType:r,typeName:d.ZodOptional,..._(e)});var B=class extends v{_parse(e){return this._getType(e)===f.null?T(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};B.create=(r,e)=>new B({innerType:r,typeName:d.ZodNullable,..._(e)});var de=class extends v{_parse(e){let{ctx:t}=this._processInputParams(e),n=t.data;return t.parsedType===f.undefined&&(n=this._def.defaultValue()),this._def.innerType._parse({data:n,path:t.path,parent:t})}removeDefault(){return this._def.innerType}};de.create=(r,e)=>new de({innerType:r,typeName:d.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,..._(e)});var le=class extends v{_parse(e){let{ctx:t}=this._processInputParams(e),n={...t,common:{...t.common,issues:[]}},s=this._def.innerType._parse({data:n.data,path:n.path,parent:{...n}});return ye(s)?s.then(a=>({status:"valid",value:a.status==="valid"?a.value:this._def.catchValue({get error(){return new P(n.common.issues)},input:n.data})})):{status:"valid",value:s.status==="valid"?s.value:this._def.catchValue({get error(){return new P(n.common.issues)},input:n.data})}}removeCatch(){return this._def.innerType}};le.create=(r,e)=>new le({innerType:r,typeName:d.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,..._(e)});var Te=class extends v{_parse(e){if(this._getType(e)!==f.nan){let n=this._getOrReturnCtx(e);return p(n,{code:u.invalid_type,expected:f.nan,received:n.parsedType}),g}return{status:"valid",value:e.data}}};Te.create=r=>new Te({typeName:d.ZodNaN,..._(r)});var Me=class extends v{_parse(e){let{ctx:t}=this._processInputParams(e),n=t.data;return this._def.type._parse({data:n,path:t.path,parent:t})}unwrap(){return this._def.type}},Ze=class r extends v{_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.common.async)return(async()=>{let a=await this._def.in._parseAsync({data:n.data,path:n.path,parent:n});return a.status==="aborted"?g:a.status==="dirty"?(t.dirty(),Q(a.value)):this._def.out._parseAsync({data:a.value,path:n.path,parent:n})})();{let s=this._def.in._parseSync({data:n.data,path:n.path,parent:n});return s.status==="aborted"?g:s.status==="dirty"?(t.dirty(),{status:"dirty",value:s.value}):this._def.out._parseSync({data:s.value,path:n.path,parent:n})}}static create(e,t){return new r({in:e,out:t,typeName:d.ZodPipeline})}},pe=class extends v{_parse(e){let t=this._def.innerType._parse(e),n=s=>(X(s)&&(s.value=Object.freeze(s.value)),s);return ye(t)?t.then(s=>n(s)):n(t)}unwrap(){return this._def.innerType}};pe.create=(r,e)=>new pe({innerType:r,typeName:d.ZodReadonly,..._(e)});var Gn={object:$.lazycreate},d;(function(r){r.ZodString="ZodString",r.ZodNumber="ZodNumber",r.ZodNaN="ZodNaN",r.ZodBigInt="ZodBigInt",r.ZodBoolean="ZodBoolean",r.ZodDate="ZodDate",r.ZodSymbol="ZodSymbol",r.ZodUndefined="ZodUndefined",r.ZodNull="ZodNull",r.ZodAny="ZodAny",r.ZodUnknown="ZodUnknown",r.ZodNever="ZodNever",r.ZodVoid="ZodVoid",r.ZodArray="ZodArray",r.ZodObject="ZodObject",r.ZodUnion="ZodUnion",r.ZodDiscriminatedUnion="ZodDiscriminatedUnion",r.ZodIntersection="ZodIntersection",r.ZodTuple="ZodTuple",r.ZodRecord="ZodRecord",r.ZodMap="ZodMap",r.ZodSet="ZodSet",r.ZodFunction="ZodFunction",r.ZodLazy="ZodLazy",r.ZodLiteral="ZodLiteral",r.ZodEnum="ZodEnum",r.ZodEffects="ZodEffects",r.ZodNativeEnum="ZodNativeEnum",r.ZodOptional="ZodOptional",r.ZodNullable="ZodNullable",r.ZodDefault="ZodDefault",r.ZodCatch="ZodCatch",r.ZodPromise="ZodPromise",r.ZodBranded="ZodBranded",r.ZodPipeline="ZodPipeline",r.ZodReadonly="ZodReadonly"})(d||(d={}));var Kn=te.create,Jn=_e.create,qn=Te.create,Yn=ve.create,Xn=xe.create,Hn=be.create,Qn=ke.create,es=re.create,ts=ne.create,rs=we.create,ns=J.create,ss=Z.create,as=Se.create,is=q.create,os=$.create,cs=$.strictCreate,us=se.create,ds=Xe.create,ls=ae.create,ps=U.create,fs=Qe.create,ms=Ae.create,hs=Oe.create,gs=et.create,ys=ie.create,_s=oe.create,vs=ce.create,xs=ue.create,bs=H.create,ks=R.create,ws=I.create,Ss=B.create,As=R.createWithPreprocess,Os=Ze.create;function k(r){if(r.target!=="openAi")return{};let e=[...r.basePath,r.definitionPath,r.openAiAnyTypeName];return r.flags.hasReferencedOpenAiAnyType=!0,{$ref:r.$refStrategy==="relative"?Re(e,r.currentPath):e.join("/")}}function Ot(r,e){let t={type:"array"};return r.type?._def&&r.type?._def?.typeName!==d.ZodAny&&(t.items=y(r.type._def,{...e,currentPath:[...e.currentPath,"items"]})),r.minLength&&b(t,"minItems",r.minLength.value,r.minLength.message,e),r.maxLength&&b(t,"maxItems",r.maxLength.value,r.maxLength.message,e),r.exactLength&&(b(t,"minItems",r.exactLength.value,r.exactLength.message,e),b(t,"maxItems",r.exactLength.value,r.exactLength.message,e)),t}function Tt(r,e){let t={type:"integer",format:"int64"};if(!r.checks)return t;for(let n of r.checks)switch(n.kind){case"min":e.target==="jsonSchema7"?n.inclusive?b(t,"minimum",n.value,n.message,e):b(t,"exclusiveMinimum",n.value,n.message,e):(n.inclusive||(t.exclusiveMinimum=!0),b(t,"minimum",n.value,n.message,e));break;case"max":e.target==="jsonSchema7"?n.inclusive?b(t,"maximum",n.value,n.message,e):b(t,"exclusiveMaximum",n.value,n.message,e):(n.inclusive||(t.exclusiveMaximum=!0),b(t,"maximum",n.value,n.message,e));break;case"multipleOf":b(t,"multipleOf",n.value,n.message,e);break}return t}function Et(){return{type:"boolean"}}function Le(r,e){return y(r.type._def,e)}var Pt=(r,e)=>y(r.innerType._def,e);function tt(r,e,t){let n=t??e.dateStrategy;if(Array.isArray(n))return{anyOf:n.map((s,a)=>tt(r,e,s))};switch(n){case"string":case"format:date-time":return{type:"string",format:"date-time"};case"format:date":return{type:"string",format:"date"};case"integer":return Kr(r,e)}}var Kr=(r,e)=>{let t={type:"integer",format:"unix-time"};if(e.target==="openApi3")return t;for(let n of r.checks)switch(n.kind){case"min":b(t,"minimum",n.value,n.message,e);break;case"max":b(t,"maximum",n.value,n.message,e);break}return t};function $t(r,e){return{...y(r.innerType._def,e),default:r.defaultValue()}}function Ct(r,e){return e.effectStrategy==="input"?y(r.schema._def,e):k(e)}function Nt(r){return{type:"string",enum:Array.from(r.values)}}var Jr=r=>"type"in r&&r.type==="string"?!1:"allOf"in r;function Dt(r,e){let t=[y(r.left._def,{...e,currentPath:[...e.currentPath,"allOf","0"]}),y(r.right._def,{...e,currentPath:[...e.currentPath,"allOf","1"]})].filter(a=>!!a),n=e.target==="jsonSchema2019-09"?{unevaluatedProperties:!1}:void 0,s=[];return t.forEach(a=>{if(Jr(a))s.push(...a.allOf),a.unevaluatedProperties===void 0&&(n=void 0);else{let i=a;if("additionalProperties"in a&&a.additionalProperties===!1){let{additionalProperties:o,...c}=a;i=c}else n=void 0;s.push(i)}}),s.length?{allOf:s,...n}:void 0}function It(r,e){let t=typeof r.value;return t!=="bigint"&&t!=="number"&&t!=="boolean"&&t!=="string"?{type:Array.isArray(r.value)?"array":"object"}:e.target==="openApi3"?{type:t==="bigint"?"integer":t,enum:[r.value]}:{type:t==="bigint"?"integer":t,const:r.value}}var rt,j={cuid:/^[cC][^\s-]{8,}$/,cuid2:/^[0-9a-z]+$/,ulid:/^[0-9A-HJKMNP-TV-Z]{26}$/,email:/^(?!\.)(?!.*\.\.)([a-zA-Z0-9_'+\-\.]*)[a-zA-Z0-9_+-]@([a-zA-Z0-9][a-zA-Z0-9\-]*\.)+[a-zA-Z]{2,}$/,emoji:()=>(rt===void 0&&(rt=RegExp("^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$","u")),rt),uuid:/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/,ipv4:/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,ipv4Cidr:/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/,ipv6:/^(([a-f0-9]{1,4}:){7}|::([a-f0-9]{1,4}:){0,6}|([a-f0-9]{1,4}:){1}:([a-f0-9]{1,4}:){0,5}|([a-f0-9]{1,4}:){2}:([a-f0-9]{1,4}:){0,4}|([a-f0-9]{1,4}:){3}:([a-f0-9]{1,4}:){0,3}|([a-f0-9]{1,4}:){4}:([a-f0-9]{1,4}:){0,2}|([a-f0-9]{1,4}:){5}:([a-f0-9]{1,4}:){0,1})([a-f0-9]{1,4}|(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2})))$/,ipv6Cidr:/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,base64:/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,base64url:/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,nanoid:/^[a-zA-Z0-9_-]{21}$/,jwt:/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/};function ze(r,e){let t={type:"string"};if(r.checks)for(let n of r.checks)switch(n.kind){case"min":b(t,"minLength",typeof t.minLength=="number"?Math.max(t.minLength,n.value):n.value,n.message,e);break;case"max":b(t,"maxLength",typeof t.maxLength=="number"?Math.min(t.maxLength,n.value):n.value,n.message,e);break;case"email":switch(e.emailStrategy){case"format:email":M(t,"email",n.message,e);break;case"format:idn-email":M(t,"idn-email",n.message,e);break;case"pattern:zod":E(t,j.email,n.message,e);break}break;case"url":M(t,"uri",n.message,e);break;case"uuid":M(t,"uuid",n.message,e);break;case"regex":E(t,n.regex,n.message,e);break;case"cuid":E(t,j.cuid,n.message,e);break;case"cuid2":E(t,j.cuid2,n.message,e);break;case"startsWith":E(t,RegExp(`^${nt(n.value,e)}`),n.message,e);break;case"endsWith":E(t,RegExp(`${nt(n.value,e)}$`),n.message,e);break;case"datetime":M(t,"date-time",n.message,e);break;case"date":M(t,"date",n.message,e);break;case"time":M(t,"time",n.message,e);break;case"duration":M(t,"duration",n.message,e);break;case"length":b(t,"minLength",typeof t.minLength=="number"?Math.max(t.minLength,n.value):n.value,n.message,e),b(t,"maxLength",typeof t.maxLength=="number"?Math.min(t.maxLength,n.value):n.value,n.message,e);break;case"includes":{E(t,RegExp(nt(n.value,e)),n.message,e);break}case"ip":{n.version!=="v6"&&M(t,"ipv4",n.message,e),n.version!=="v4"&&M(t,"ipv6",n.message,e);break}case"base64url":E(t,j.base64url,n.message,e);break;case"jwt":E(t,j.jwt,n.message,e);break;case"cidr":{n.version!=="v6"&&E(t,j.ipv4Cidr,n.message,e),n.version!=="v4"&&E(t,j.ipv6Cidr,n.message,e);break}case"emoji":E(t,j.emoji(),n.message,e);break;case"ulid":{E(t,j.ulid,n.message,e);break}case"base64":{switch(e.base64Strategy){case"format:binary":{M(t,"binary",n.message,e);break}case"contentEncoding:base64":{b(t,"contentEncoding","base64",n.message,e);break}case"pattern:zod":{E(t,j.base64,n.message,e);break}}break}case"nanoid":E(t,j.nanoid,n.message,e);case"toLowerCase":case"toUpperCase":case"trim":break;default:}return t}function nt(r,e){return e.patternStrategy==="escape"?Yr(r):r}var qr=new Set("ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789");function Yr(r){let e="";for(let t=0;t<r.length;t++)qr.has(r[t])||(e+="\\"),e+=r[t];return e}function M(r,e,t,n){r.format||r.anyOf?.some(s=>s.format)?(r.anyOf||(r.anyOf=[]),r.format&&(r.anyOf.push({format:r.format,...r.errorMessage&&n.errorMessages&&{errorMessage:{format:r.errorMessage.format}}}),delete r.format,r.errorMessage&&(delete r.errorMessage.format,Object.keys(r.errorMessage).length===0&&delete r.errorMessage)),r.anyOf.push({format:e,...t&&n.errorMessages&&{errorMessage:{format:t}}})):b(r,"format",e,t,n)}function E(r,e,t,n){r.pattern||r.allOf?.some(s=>s.pattern)?(r.allOf||(r.allOf=[]),r.pattern&&(r.allOf.push({pattern:r.pattern,...r.errorMessage&&n.errorMessages&&{errorMessage:{pattern:r.errorMessage.pattern}}}),delete r.pattern,r.errorMessage&&(delete r.errorMessage.pattern,Object.keys(r.errorMessage).length===0&&delete r.errorMessage)),r.allOf.push({pattern:Rt(e,n),...t&&n.errorMessages&&{errorMessage:{pattern:t}}})):b(r,"pattern",Rt(e,n),t,n)}function Rt(r,e){if(!e.applyRegexFlags||!r.flags)return r.source;let t={i:r.flags.includes("i"),m:r.flags.includes("m"),s:r.flags.includes("s")},n=t.i?r.source.toLowerCase():r.source,s="",a=!1,i=!1,o=!1;for(let c=0;c<n.length;c++){if(a){s+=n[c],a=!1;continue}if(t.i){if(i){if(n[c].match(/[a-z]/)){o?(s+=n[c],s+=`${n[c-2]}-${n[c]}`.toUpperCase(),o=!1):n[c+1]==="-"&&n[c+2]?.match(/[a-z]/)?(s+=n[c],o=!0):s+=`${n[c]}${n[c].toUpperCase()}`;continue}}else if(n[c].match(/[a-z]/)){s+=`[${n[c]}${n[c].toUpperCase()}]`;continue}}if(t.m){if(n[c]==="^"){s+=`(^|(?<=[\r
|
|
4
|
-
]))`;continue}else if(n[c]==="$"){s+=`($|(?=[\r
|
|
5
|
-
]))`;continue}}if(t.s&&n[c]==="."){s+=i?`${n[c]}\r
|
|
6
|
-
`:`[${n[c]}\r
|
|
7
|
-
]`;continue}s+=n[c],n[c]==="\\"?a=!0:i&&n[c]==="]"?i=!1:!i&&n[c]==="["&&(i=!0)}try{new RegExp(s)}catch{return console.warn(`Could not convert regex pattern at ${e.currentPath.join("/")} to a flag-independent form! Falling back to the flag-ignorant source`),r.source}return s}function Fe(r,e){if(e.target==="openAi"&&console.warn("Warning: OpenAI may not support records in schemas! Try an array of key-value pairs instead."),e.target==="openApi3"&&r.keyType?._def.typeName===d.ZodEnum)return{type:"object",required:r.keyType._def.values,properties:r.keyType._def.values.reduce((n,s)=>({...n,[s]:y(r.valueType._def,{...e,currentPath:[...e.currentPath,"properties",s]})??k(e)}),{}),additionalProperties:e.rejectedAdditionalProperties};let t={type:"object",additionalProperties:y(r.valueType._def,{...e,currentPath:[...e.currentPath,"additionalProperties"]})??e.allowedAdditionalProperties};if(e.target==="openApi3")return t;if(r.keyType?._def.typeName===d.ZodString&&r.keyType._def.checks?.length){let{type:n,...s}=ze(r.keyType._def,e);return{...t,propertyNames:s}}else{if(r.keyType?._def.typeName===d.ZodEnum)return{...t,propertyNames:{enum:r.keyType._def.values}};if(r.keyType?._def.typeName===d.ZodBranded&&r.keyType._def.type._def.typeName===d.ZodString&&r.keyType._def.type._def.checks?.length){let{type:n,...s}=Le(r.keyType._def,e);return{...t,propertyNames:s}}}return t}function jt(r,e){if(e.mapStrategy==="record")return Fe(r,e);let t=y(r.keyType._def,{...e,currentPath:[...e.currentPath,"items","items","0"]})||k(e),n=y(r.valueType._def,{...e,currentPath:[...e.currentPath,"items","items","1"]})||k(e);return{type:"array",maxItems:125,items:{type:"array",items:[t,n],minItems:2,maxItems:2}}}function Mt(r){let e=r.values,n=Object.keys(r.values).filter(a=>typeof e[e[a]]!="number").map(a=>e[a]),s=Array.from(new Set(n.map(a=>typeof a)));return{type:s.length===1?s[0]==="string"?"string":"number":["string","number"],enum:n}}function Zt(r){return r.target==="openAi"?void 0:{not:k({...r,currentPath:[...r.currentPath,"not"]})}}function Lt(r){return r.target==="openApi3"?{enum:["null"],nullable:!0}:{type:"null"}}var Ee={ZodString:"string",ZodNumber:"number",ZodBigInt:"integer",ZodBoolean:"boolean",ZodNull:"null"};function Ft(r,e){if(e.target==="openApi3")return zt(r,e);let t=r.options instanceof Map?Array.from(r.options.values()):r.options;if(t.every(n=>n._def.typeName in Ee&&(!n._def.checks||!n._def.checks.length))){let n=t.reduce((s,a)=>{let i=Ee[a._def.typeName];return i&&!s.includes(i)?[...s,i]:s},[]);return{type:n.length>1?n:n[0]}}else if(t.every(n=>n._def.typeName==="ZodLiteral"&&!n.description)){let n=t.reduce((s,a)=>{let i=typeof a._def.value;switch(i){case"string":case"number":case"boolean":return[...s,i];case"bigint":return[...s,"integer"];case"object":if(a._def.value===null)return[...s,"null"];default:return s}},[]);if(n.length===t.length){let s=n.filter((a,i,o)=>o.indexOf(a)===i);return{type:s.length>1?s:s[0],enum:t.reduce((a,i)=>a.includes(i._def.value)?a:[...a,i._def.value],[])}}}else if(t.every(n=>n._def.typeName==="ZodEnum"))return{type:"string",enum:t.reduce((n,s)=>[...n,...s._def.values.filter(a=>!n.includes(a))],[])};return zt(r,e)}var zt=(r,e)=>{let t=(r.options instanceof Map?Array.from(r.options.values()):r.options).map((n,s)=>y(n._def,{...e,currentPath:[...e.currentPath,"anyOf",`${s}`]})).filter(n=>!!n&&(!e.strictUnions||typeof n=="object"&&Object.keys(n).length>0));return t.length?{anyOf:t}:void 0};function Vt(r,e){if(["ZodString","ZodNumber","ZodBigInt","ZodBoolean","ZodNull"].includes(r.innerType._def.typeName)&&(!r.innerType._def.checks||!r.innerType._def.checks.length))return e.target==="openApi3"?{type:Ee[r.innerType._def.typeName],nullable:!0}:{type:[Ee[r.innerType._def.typeName],"null"]};if(e.target==="openApi3"){let n=y(r.innerType._def,{...e,currentPath:[...e.currentPath]});return n&&"$ref"in n?{allOf:[n],nullable:!0}:n&&{...n,nullable:!0}}let t=y(r.innerType._def,{...e,currentPath:[...e.currentPath,"anyOf","0"]});return t&&{anyOf:[t,{type:"null"}]}}function Wt(r,e){let t={type:"number"};if(!r.checks)return t;for(let n of r.checks)switch(n.kind){case"int":t.type="integer",Ke(t,"type",n.message,e);break;case"min":e.target==="jsonSchema7"?n.inclusive?b(t,"minimum",n.value,n.message,e):b(t,"exclusiveMinimum",n.value,n.message,e):(n.inclusive||(t.exclusiveMinimum=!0),b(t,"minimum",n.value,n.message,e));break;case"max":e.target==="jsonSchema7"?n.inclusive?b(t,"maximum",n.value,n.message,e):b(t,"exclusiveMaximum",n.value,n.message,e):(n.inclusive||(t.exclusiveMaximum=!0),b(t,"maximum",n.value,n.message,e));break;case"multipleOf":b(t,"multipleOf",n.value,n.message,e);break}return t}function Ut(r,e){let t=e.target==="openAi",n={type:"object",properties:{}},s=[],a=r.shape();for(let o in a){let c=a[o];if(c===void 0||c._def===void 0)continue;let l=Hr(c);l&&t&&(c._def.typeName==="ZodOptional"&&(c=c._def.innerType),c.isNullable()||(c=c.nullable()),l=!1);let h=y(c._def,{...e,currentPath:[...e.currentPath,"properties",o],propertyPath:[...e.currentPath,"properties",o]});h!==void 0&&(n.properties[o]=h,l||s.push(o))}s.length&&(n.required=s);let i=Xr(r,e);return i!==void 0&&(n.additionalProperties=i),n}function Xr(r,e){if(r.catchall._def.typeName!=="ZodNever")return y(r.catchall._def,{...e,currentPath:[...e.currentPath,"additionalProperties"]});switch(r.unknownKeys){case"passthrough":return e.allowedAdditionalProperties;case"strict":return e.rejectedAdditionalProperties;case"strip":return e.removeAdditionalStrategy==="strict"?e.allowedAdditionalProperties:e.rejectedAdditionalProperties}}function Hr(r){try{return r.isOptional()}catch{return!0}}var Bt=(r,e)=>{if(e.currentPath.toString()===e.propertyPath?.toString())return y(r.innerType._def,e);let t=y(r.innerType._def,{...e,currentPath:[...e.currentPath,"anyOf","1"]});return t?{anyOf:[{not:k(e)},t]}:k(e)};var Gt=(r,e)=>{if(e.pipeStrategy==="input")return y(r.in._def,e);if(e.pipeStrategy==="output")return y(r.out._def,e);let t=y(r.in._def,{...e,currentPath:[...e.currentPath,"allOf","0"]}),n=y(r.out._def,{...e,currentPath:[...e.currentPath,"allOf",t?"1":"0"]});return{allOf:[t,n].filter(s=>s!==void 0)}};function Kt(r,e){return y(r.type._def,e)}function Jt(r,e){let n={type:"array",uniqueItems:!0,items:y(r.valueType._def,{...e,currentPath:[...e.currentPath,"items"]})};return r.minSize&&b(n,"minItems",r.minSize.value,r.minSize.message,e),r.maxSize&&b(n,"maxItems",r.maxSize.value,r.maxSize.message,e),n}function qt(r,e){return r.rest?{type:"array",minItems:r.items.length,items:r.items.map((t,n)=>y(t._def,{...e,currentPath:[...e.currentPath,"items",`${n}`]})).reduce((t,n)=>n===void 0?t:[...t,n],[]),additionalItems:y(r.rest._def,{...e,currentPath:[...e.currentPath,"additionalItems"]})}:{type:"array",minItems:r.items.length,maxItems:r.items.length,items:r.items.map((t,n)=>y(t._def,{...e,currentPath:[...e.currentPath,"items",`${n}`]})).reduce((t,n)=>n===void 0?t:[...t,n],[])}}function Yt(r){return{not:k(r)}}function Xt(r){return k(r)}var Ht=(r,e)=>y(r.innerType._def,e);var Qt=(r,e,t)=>{switch(e){case d.ZodString:return ze(r,t);case d.ZodNumber:return Wt(r,t);case d.ZodObject:return Ut(r,t);case d.ZodBigInt:return Tt(r,t);case d.ZodBoolean:return Et();case d.ZodDate:return tt(r,t);case d.ZodUndefined:return Yt(t);case d.ZodNull:return Lt(t);case d.ZodArray:return Ot(r,t);case d.ZodUnion:case d.ZodDiscriminatedUnion:return Ft(r,t);case d.ZodIntersection:return Dt(r,t);case d.ZodTuple:return qt(r,t);case d.ZodRecord:return Fe(r,t);case d.ZodLiteral:return It(r,t);case d.ZodEnum:return Nt(r);case d.ZodNativeEnum:return Mt(r);case d.ZodNullable:return Vt(r,t);case d.ZodOptional:return Bt(r,t);case d.ZodMap:return jt(r,t);case d.ZodSet:return Jt(r,t);case d.ZodLazy:return()=>r.getter()._def;case d.ZodPromise:return Kt(r,t);case d.ZodNaN:case d.ZodNever:return Zt(t);case d.ZodEffects:return Ct(r,t);case d.ZodAny:return k(t);case d.ZodUnknown:return Xt(t);case d.ZodDefault:return $t(r,t);case d.ZodBranded:return Le(r,t);case d.ZodReadonly:return Ht(r,t);case d.ZodCatch:return Pt(r,t);case d.ZodPipeline:return Gt(r,t);case d.ZodFunction:case d.ZodVoid:case d.ZodSymbol:return;default:return(n=>{})(e)}};function y(r,e,t=!1){let n=e.seen.get(r);if(e.override){let o=e.override?.(r,e,n,t);if(o!==_t)return o}if(n&&!t){let o=Qr(n,e);if(o!==void 0)return o}let s={def:r,path:e.currentPath,jsonSchema:void 0};e.seen.set(r,s);let a=Qt(r,r.typeName,e),i=typeof a=="function"?y(a(),e):a;if(i&&en(r,e,i),e.postProcess){let o=e.postProcess(i,r,e);return s.jsonSchema=i,o}return s.jsonSchema=i,i}var Qr=(r,e)=>{switch(e.$refStrategy){case"root":return{$ref:r.path.join("/")};case"relative":return{$ref:Re(e.currentPath,r.path)};case"none":case"seen":return r.path.length<e.currentPath.length&&r.path.every((t,n)=>e.currentPath[n]===t)?(console.warn(`Recursive reference detected at ${e.currentPath.join("/")}! Defaulting to any`),k(e)):e.$refStrategy==="seen"?k(e):void 0}},en=(r,e,t)=>(r.description&&(t.description=r.description,e.markdownDescription&&(t.markdownDescription=r.description)),t);var st=(r,e)=>{let t=xt(e),n=typeof e=="object"&&e.definitions?Object.entries(e.definitions).reduce((c,[l,h])=>({...c,[l]:y(h._def,{...t,currentPath:[...t.basePath,t.definitionPath,l]},!0)??k(t)}),{}):void 0,s=typeof e=="string"?e:e?.nameStrategy==="title"?void 0:e?.name,a=y(r._def,s===void 0?t:{...t,currentPath:[...t.basePath,t.definitionPath,s]},!1)??k(t),i=typeof e=="object"&&e.name!==void 0&&e.nameStrategy==="title"?e.name:void 0;i!==void 0&&(a.title=i),t.flags.hasReferencedOpenAiAnyType&&(n||(n={}),n[t.openAiAnyTypeName]||(n[t.openAiAnyTypeName]={type:["string","number","integer","boolean","array","null"],items:{$ref:t.$refStrategy==="relative"?"1":[...t.basePath,t.definitionPath,t.openAiAnyTypeName].join("/")}}));let o=s===void 0?n?{...a,[t.definitionPath]:n}:a:{$ref:[...t.$refStrategy==="relative"?[]:t.basePath,t.definitionPath,s].join("/"),[t.definitionPath]:{...n,[s]:a}};return t.target==="jsonSchema7"?o.$schema="http://json-schema.org/draft-07/schema#":(t.target==="jsonSchema2019-09"||t.target==="openAi")&&(o.$schema="https://json-schema.org/draft/2019-09/schema#"),t.target==="openAi"&&("anyOf"in o||"oneOf"in o||"allOf"in o||"type"in o&&Array.isArray(o.type))&&console.warn("Warning: OpenAI may not support schemas with unions as roots! Try wrapping it in an object property."),o};import Pe from"chalk";var L={debug:0,info:1,warn:2,error:3,silent:4},at=class{constructor(){this._level=this._getLogLevel()}_getLogLevel(){if(process.env.ZIBBY_DEBUG==="true")return L.debug;if(process.env.ZIBBY_VERBOSE==="true")return L.info;let e=process.env.LOG_LEVEL?.toLowerCase();return e&&e in L?L[e]:L.info}_shouldLog(e){return L[e]>=this._level}_formatMessage(e,t,n={}){let s=new Date().toISOString(),i=`${this._getPrefix(e)} ${t}`;return Object.keys(n).length>0&&(i+=Pe.dim(` ${JSON.stringify(n)}`)),i}_getPrefix(e){return{debug:Pe.gray("[DEBUG]"),info:Pe.cyan("[INFO]"),warn:Pe.yellow("[WARN]"),error:Pe.red("\u274C [ERROR]")}[e]||""}debug(e,t){this._shouldLog("debug")&&console.log(this._formatMessage("debug",e,t))}info(e,t){this._shouldLog("info")&&console.log(this._formatMessage("info",e,t))}warn(e,t){this._shouldLog("warn")&&console.warn(this._formatMessage("warn",e,t))}error(e,t){this._shouldLog("error")&&console.error(this._formatMessage("error",e,t))}setLevel(e){e in L&&(this._level=L[e])}getLevel(){return Object.keys(L).find(e=>L[e]===this._level)}},w=new at;import S from"chalk";var tn="__WORKFLOW_GRAPH_LOG__",$e=S.gray("\u2502"),rn=S.gray("\u250C"),er=S.gray("\u2514"),it=S.green("\u25C6"),tr=S.hex("#c084fc")("\u25C6"),rr=S.hex("#2dd4bf")("\u25C6"),ot=S.red("\u25C6"),nr=`${$e} `,sr=2;function ar(r){return r<1e3?`${r}ms`:`${(r/1e3).toFixed(1)}s`}function ir(r,e){return(t,n,s)=>{if(typeof t!="string")return r(t,n,s);let a=process.stdout.columns||120,i="";for(let o=0;o<t.length;o++){let c=t[o];e.lineStart&&(i+=nr,e.col=sr,e.lineStart=!1),c===`
|
|
8
|
-
`?(i+=c,e.lineStart=!0,e.col=0,e.inEsc=!1):c==="\x1B"?(e.inEsc=!0,i+=c):e.inEsc?(i+=c,(c>="A"&&c<="Z"||c>="a"&&c<="z")&&(e.inEsc=!1)):(e.col++,i+=c,e.col>=a&&(i+=`
|
|
9
|
-
${nr}`,e.col=sr))}return r(i,n,s)}}var ct=class{constructor(){this._currentNode=null,this._origStdoutWrite=null,this._origStderrWrite=null;let e=String(process.env.ZIBBY_RUN_SOURCE||"").trim().toLowerCase(),t=String(process.env.ZIBBY_WORKFLOW_GRAPH_LOG_MARKERS||"").trim()==="1";this._emitWorkflowGraphMarkers=t||e==="studio"}get isInsideNode(){return this._currentNode!==null}_startIntercepting(){this._origStdoutWrite=process.stdout.write.bind(process.stdout),this._origStderrWrite=process.stderr.write.bind(process.stderr);let e={lineStart:!0,col:0,inEsc:!1},t={lineStart:!0,col:0,inEsc:!1};this._outState=e,this._errState=t,process.stdout.write=ir(this._origStdoutWrite,e),process.stderr.write=ir(this._origStderrWrite,t)}_stopIntercepting(){this._origStdoutWrite&&(this._outState&&!this._outState.lineStart&&this._origStdoutWrite(`
|
|
1
|
+
var v=class{constructor(e,t,r=0){this.name=e,this.description=t,this.priority=r}async invoke(e,t={}){throw new Error("AgentStrategy.invoke() must be implemented by subclass")}canHandle(e){throw new Error("AgentStrategy.canHandle() must be implemented by subclass")}getName(){return this.name}getDescription(){return this.description}getPriority(){return this.priority}};import{execSync as te}from"node:child_process";import{zodToJsonSchema as oe}from"zod-to-json-schema";import E from"chalk";var u={debug:0,info:1,warn:2,error:3,silent:4},b=class{constructor(){this._level=this._getLogLevel()}_getLogLevel(){if(process.env.ZIBBY_DEBUG==="true")return u.debug;if(process.env.ZIBBY_VERBOSE==="true")return u.info;let e=process.env.LOG_LEVEL?.toLowerCase();return e&&e in u?u[e]:u.info}_shouldLog(e){return u[e]>=this._level}_formatMessage(e,t,r={}){let c=new Date().toISOString(),o=`${this._getPrefix(e)} ${t}`;return Object.keys(r).length>0&&(o+=E.dim(` ${JSON.stringify(r)}`)),o}_getPrefix(e){return{debug:E.gray("[DEBUG]"),info:E.cyan("[INFO]"),warn:E.yellow("[WARN]"),error:E.red("\u274C [ERROR]")}[e]||""}debug(e,t){this._shouldLog("debug")&&console.log(this._formatMessage("debug",e,t))}info(e,t){this._shouldLog("info")&&console.log(this._formatMessage("info",e,t))}warn(e,t){this._shouldLog("warn")&&console.warn(this._formatMessage("warn",e,t))}error(e,t){this._shouldLog("error")&&console.error(this._formatMessage("error",e,t))}setLevel(e){e in u&&(this._level=u[e])}getLevel(){return Object.keys(u).find(e=>u[e]===this._level)}},i=new b;import n from"chalk";var q="__WORKFLOW_GRAPH_LOG__",$=n.gray("\u2502"),Q=n.gray("\u250C"),G=n.gray("\u2514"),C=n.green("\u25C6"),K=n.hex("#c084fc")("\u25C6"),U=n.hex("#2dd4bf")("\u25C6"),M=n.red("\u25C6"),Y=`${$} `,F=2;function X(d){return d<1e3?`${d}ms`:`${(d/1e3).toFixed(1)}s`}function B(d,e){return(t,r,c)=>{if(typeof t!="string")return d(t,r,c);let s=process.stdout.columns||120,o="";for(let f=0;f<t.length;f++){let l=t[f];e.lineStart&&(o+=Y,e.col=F,e.lineStart=!1),l===`
|
|
2
|
+
`?(o+=l,e.lineStart=!0,e.col=0,e.inEsc=!1):l==="\x1B"?(e.inEsc=!0,o+=l):e.inEsc?(o+=l,(l>="A"&&l<="Z"||l>="a"&&l<="z")&&(e.inEsc=!1)):(e.col++,o+=l,e.col>=s&&(o+=`
|
|
3
|
+
${Y}`,e.col=F))}return d(o,r,c)}}var P=class{constructor(){this._currentNode=null,this._origStdoutWrite=null,this._origStderrWrite=null;let e=String(process.env.ZIBBY_RUN_SOURCE||"").trim().toLowerCase(),t=String(process.env.ZIBBY_WORKFLOW_GRAPH_LOG_MARKERS||"").trim()==="1";this._emitWorkflowGraphMarkers=t||e==="studio"}get isInsideNode(){return this._currentNode!==null}_startIntercepting(){this._origStdoutWrite=process.stdout.write.bind(process.stdout),this._origStderrWrite=process.stderr.write.bind(process.stderr);let e={lineStart:!0,col:0,inEsc:!1},t={lineStart:!0,col:0,inEsc:!1};this._outState=e,this._errState=t,process.stdout.write=B(this._origStdoutWrite,e),process.stderr.write=B(this._origStderrWrite,t)}_stopIntercepting(){this._origStdoutWrite&&(this._outState&&!this._outState.lineStart&&this._origStdoutWrite(`
|
|
10
4
|
`),process.stdout.write=this._origStdoutWrite),this._origStderrWrite&&(this._errState&&!this._errState.lineStart&&this._origStderrWrite(`
|
|
11
5
|
`),process.stderr.write=this._origStderrWrite),this._origStdoutWrite=null,this._origStderrWrite=null}_rawWrite(e){(this._origStdoutWrite||process.stdout.write.bind(process.stdout))(`${e}
|
|
12
|
-
`)}_emitGraphLogMarker(e){if(!this._emitWorkflowGraphMarkers)return;let t=`${
|
|
6
|
+
`)}_emitGraphLogMarker(e){if(!this._emitWorkflowGraphMarkers)return;let t=`${q}${JSON.stringify(e)}
|
|
13
7
|
`;this._origStdoutWrite?this._origStdoutWrite(t):process.stdout.write(t)}_writeDot(e,t){this._origStdoutWrite?(this._outState&&!this._outState.lineStart&&(this._origStdoutWrite(`
|
|
14
8
|
`),this._outState.lineStart=!0,this._outState.col=0),this._origStdoutWrite(`${e} ${t}
|
|
15
9
|
`)):process.stdout.write.bind(process.stdout)(`${e} ${t}
|
|
16
|
-
`)}step(e){this._origStdoutWrite?this._writeDot(
|
|
17
|
-
`)}stepTool(e){this._origStdoutWrite?this._writeDot(
|
|
18
|
-
`)}stepMemory(e){let t=
|
|
19
|
-
`)}stepFail(e){this._origStdoutWrite?this._writeDot(
|
|
20
|
-
`)}nodeStart(e){this._currentNode=e,this._emitGraphLogMarker({phase:"node_begin",node:e}),this._rawWrite(`${
|
|
21
|
-
\u25C6 Model: ${
|
|
22
|
-
`);let
|
|
23
|
-
${
|
|
10
|
+
`)}step(e){this._origStdoutWrite?this._writeDot(C,e):process.stdout.write.bind(process.stdout)(`${$} ${C} ${e}
|
|
11
|
+
`)}stepTool(e){this._origStdoutWrite?this._writeDot(K,e):process.stdout.write.bind(process.stdout)(`${$} ${K} ${e}
|
|
12
|
+
`)}stepMemory(e){let t=n.hex("#2dd4bf")(e);this._origStdoutWrite?this._writeDot(U,t):process.stdout.write.bind(process.stdout)(`${$} ${U} ${t}
|
|
13
|
+
`)}stepFail(e){this._origStdoutWrite?this._writeDot(M,n.red(e)):process.stdout.write.bind(process.stdout)(`${$} ${M} ${n.red(e)}
|
|
14
|
+
`)}nodeStart(e){this._currentNode=e,this._emitGraphLogMarker({phase:"node_begin",node:e}),this._rawWrite(`${Q} ${e}`),this._startIntercepting()}nodeComplete(e,t={}){this._stopIntercepting();let{duration:r,details:c}=t;if(c)for(let o of c)this._rawWrite(`${C} ${o}`);let s=r?n.dim(` ${X(r)}`):"";this._rawWrite(`${G} ${n.green("done")}${s}`),this._emitGraphLogMarker({phase:"node_end",node:e}),this._rawWrite("")}nodeFailed(e,t,r={}){this._stopIntercepting();let{duration:c}=r,s=c?n.dim(` ${X(c)}`):"";this._rawWrite(`${M} ${n.red(t)}`),this._rawWrite(`${G} ${n.red("failed")}${s}`),this._emitGraphLogMarker({phase:"node_end",node:e}),this._rawWrite("")}route(e,t){this._rawWrite(n.dim(` ${e} \u2192 ${t}`)),this._rawWrite("")}graphComplete(){this._rawWrite(n.green.bold("\u2713 Workflow completed"))}},D=new P;var k={ASSISTANT:"gpt-5.4-nano-2026-03-17",CLAUDE:"claude-sonnet-4-6",CURSOR:"auto",CODEX:"o4-mini",GEMINI:"gemini-2.5-pro",OPENAI_POSTPROCESSING:"gpt-4o-mini"};var N={auto:"o4-mini","o4-mini":"o4-mini",o3:"o3","o3-mini":"o3-mini","codex-mini":"codex-mini-latest","gpt-4o":"gpt-4o","gpt-4o-mini":"gpt-4o-mini","gpt-5.2-codex":"gpt-5.2-codex","gpt-5.2":"gpt-5.2","gpt-5.3":"gpt-5.3","gpt-5.4":"gpt-5.4"};var ue={CURSOR_AGENT_DEFAULT:1200*1e3,OPENAI_REQUEST:18e4};var ee=new Map;function j(d){return ee.get(d)||null}var J=class extends v{constructor(){super("codex","Codex (OpenAI)",75)}canHandle(e){if(!!!(process.env.OPENAI_API_KEY||process.env.CODEX_API_KEY))return i.debug("CodexAgentStrategy: OPENAI_API_KEY or CODEX_API_KEY not set"),!1;try{return te("codex --version",{encoding:"utf-8",timeout:5e3,stdio:"pipe"}),!0}catch{return i.warn("[Codex] codex CLI not found. Install: npm install -g @openai/codex"),!1}}async invoke(e,t={}){let{model:r,workspace:c=process.cwd(),schema:s=null,skills:o=null,sessionPath:f=null,nodeName:l=null,timeout:re,config:se={}}=t,{Codex:H}=await import("@openai/codex-sdk"),p=r;(!p||p==="auto")&&(i.debug(`Model is '${p||"undefined"}', using default: ${k.CODEX}`),p=k.CODEX);let x=N[p]||p;N[p]&&p!==x&&i.debug(`Mapped model: ${p} \u2192 ${x}`),i.debug(`Invoking Codex SDK with model: ${x}, skills: ${JSON.stringify(o)}`);let O=process.env.CODEX_API_KEY||process.env.OPENAI_API_KEY;O&&!process.env.CODEX_API_KEY&&(process.env.CODEX_API_KEY=O);let V=O?` | key: ***${O.slice(-4)}`:" | key: not set";console.log(`
|
|
15
|
+
\u25C6 Model: ${x}${V}
|
|
16
|
+
`);let I=(await import("chalk")).default;console.log(`
|
|
17
|
+
${I.bold("Prompt sent to LLM:")}`),console.log(I.dim("\u2500".repeat(60))),console.log(I.dim(e)),console.log(I.dim("\u2500".repeat(60)));let y=this._resolveSkillsToMcp(o,{sessionPath:f,workspace:c,nodeName:l}),A={};Object.keys(y).length>0&&(A.mcp_servers=y,i.debug(`[Codex] MCP servers: ${Object.keys(y).join(", ")}`));let Z=new H({...Object.keys(A).length>0&&{config:A}}).startThread({workingDirectory:c,skipGitRepoCheck:!0,approvalPolicy:"never",sandboxMode:"danger-full-access",networkAccessEnabled:!0}),R=s&&typeof s.parse=="function",T={};if(s)try{let g=R?oe(s,{target:"openAi"}):s;T.outputSchema=g,i.debug("Structured output via SDK outputSchema")}catch(g){i.warn(`[Codex] Schema conversion failed, will extract from text: ${g.message}`)}try{let{events:g}=await Z.runStreamed(e,T),m=0,a="";for await(let h of g){let S=h.type;if(S==="item.completed"){let _=h.item,w=_?.type;if(w==="mcp_tool_call"){m++;let L=`${_.server}/${_.tool}`;if(D.stepTool(`Tool: ${L}`),_.arguments){let W=JSON.stringify(_.arguments),z=W.length>100?`${W.substring(0,100)}...`:W;console.log(` Input: ${z}`)}}else if(w==="tool_call"||w==="function_call"||w==="command_execution"){m++;let L=_.name||_.tool||_.command||"unknown";D.stepTool(`Tool: ${L}`)}else w==="agent_message"&&(a=_.text||"",a.length<500?console.log(a):console.log(`${a.substring(0,200)}... (${a.length} chars)`))}else S==="turn.completed"?i.debug(`[Codex] Turn completed. Usage: ${JSON.stringify(h.usage||{})}`):i.debug(`[Codex] Event: ${S} ${JSON.stringify(h).slice(0,300)}`)}if(i.debug(`[Codex] Last agent message (${a.length} chars): ${a.slice(0,500)}`),s){if(!a)throw new Error("Codex agent returned no response");let h=JSON.parse(a),S=R?s.parse(h):h;return i.debug("\u2705 [Codex] Structured output validated"),{raw:a,structured:S}}return a||""}catch(g){let m=g.message||String(g);throw i.error(`\u274C [Codex] SDK call failed: ${m}`),m.includes("exited with code")&&(i.error("\u{1F4A1} [Codex] Verify: codex --version && echo $OPENAI_API_KEY"),i.error("\u{1F4A1} [Codex] If codex is missing: npm install -g @openai/codex")),g}}_resolveSkillsToMcp(e,t={}){if(!Array.isArray(e)||e.length===0)return{};let r={};for(let c of e){let s=j(c);if(!s){i.warn(`[Codex] Unknown skill "${c}" \u2014 skipping`);continue}if(typeof s.resolve!="function")continue;let o=s.resolve(t);if(!o)continue;let f=s.serverName||c,l={command:o.command};o.args?.length&&(l.args=o.args),o.env&&Object.keys(o.env).length>0&&(l.env=o.env),r[f]=l,i.debug(`[Codex] MCP: ${f} \u2192 ${o.command} ${(o.args||[]).join(" ")}`)}return r}};export{J as CodexAgentStrategy};
|