diff --git a/plugins/genie/orca-entrypoint.min.js b/plugins/genie/orca-entrypoint.min.js index d55bbfcc2..e97ab5406 100644 --- a/plugins/genie/orca-entrypoint.min.js +++ b/plugins/genie/orca-entrypoint.min.js @@ -1,2 +1,2 @@ -var Zt=Object.defineProperty;var zt=(t,e)=>{for(var r in e)Zt(t,r,{get:e[r],enumerable:!0})};import{spawn as Yr}from"node:child_process";var d={};zt(d,{BRAND:()=>lr,DIRTY:()=>ne,EMPTY_PATH:()=>Ut,INVALID:()=>g,NEVER:()=>Gr,OK:()=>E,ParseStatus:()=>C,Schema:()=>x,ZodAny:()=>X,ZodArray:()=>G,ZodBigInt:()=>ae,ZodBoolean:()=>ie,ZodBranded:()=>je,ZodCatch:()=>ye,ZodDate:()=>oe,ZodDefault:()=>ge,ZodDiscriminatedUnion:()=>$e,ZodEffects:()=>z,ZodEnum:()=>me,ZodError:()=>j,ZodFirstPartyTypeKind:()=>_,ZodFunction:()=>ze,ZodIntersection:()=>le,ZodIssueCode:()=>l,ZodLazy:()=>fe,ZodLiteral:()=>pe,ZodMap:()=>Se,ZodNaN:()=>Re,ZodNativeEnum:()=>he,ZodNever:()=>L,ZodNull:()=>ue,ZodNullable:()=>q,ZodNumber:()=>se,ZodObject:()=>N,ZodOptional:()=>$,ZodParsedType:()=>p,ZodPipeline:()=>Ne,ZodPromise:()=>Q,ZodReadonly:()=>_e,ZodRecord:()=>Ze,ZodSchema:()=>x,ZodSet:()=>Ie,ZodString:()=>K,ZodSymbol:()=>Oe,ZodTransformer:()=>z,ZodTuple:()=>U,ZodType:()=>x,ZodUndefined:()=>ce,ZodUnion:()=>de,ZodUnknown:()=>H,ZodVoid:()=>Te,addIssueToContext:()=>f,any:()=>xr,array:()=>Or,bigint:()=>hr,boolean:()=>ht,coerce:()=>Hr,custom:()=>ft,date:()=>gr,datetimeRegex:()=>dt,defaultErrorMap:()=>F,discriminatedUnion:()=>Rr,effect:()=>Lr,enum:()=>$r,function:()=>Mr,getErrorMap:()=>ke,getParsedType:()=>B,instanceof:()=>pr,intersection:()=>Ar,isAborted:()=>Ve,isAsync:()=>be,isDirty:()=>Pe,isValid:()=>Y,late:()=>fr,lazy:()=>Vr,literal:()=>Pr,makeIssue:()=>Ee,map:()=>jr,nan:()=>mr,nativeEnum:()=>Zr,never:()=>br,null:()=>vr,nullable:()=>Br,number:()=>mt,object:()=>Tr,objectUtil:()=>We,oboolean:()=>Wr,onumber:()=>Fr,optional:()=>Dr,ostring:()=>Jr,pipeline:()=>qr,preprocess:()=>Ur,promise:()=>zr,quotelessJson:()=>Lt,record:()=>Er,set:()=>Nr,setErrorMap:()=>Bt,strictObject:()=>Sr,string:()=>pt,symbol:()=>yr,transformer:()=>Lr,tuple:()=>Cr,undefined:()=>_r,union:()=>Ir,unknown:()=>kr,util:()=>k,void:()=>wr});var k;(function(t){t.assertEqual=s=>{};function e(s){}t.assertIs=e;function r(s){throw new Error}t.assertNever=r,t.arrayToEnum=s=>{let a={};for(let i of s)a[i]=i;return a},t.getValidEnumValues=s=>{let a=t.objectKeys(s).filter(o=>typeof s[s[o]]!="number"),i={};for(let o of a)i[o]=s[o];return t.objectValues(i)},t.objectValues=s=>t.objectKeys(s).map(function(a){return s[a]}),t.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},t.find=(s,a)=>{for(let i of s)if(a(i))return i},t.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)}t.joinValues=n,t.jsonStringifyReplacer=(s,a)=>typeof a=="bigint"?a.toString():a})(k||(k={}));var We;(function(t){t.mergeShapes=(e,r)=>({...e,...r})})(We||(We={}));var p=k.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),B=t=>{switch(typeof t){case"undefined":return p.undefined;case"string":return p.string;case"number":return Number.isNaN(t)?p.nan:p.number;case"boolean":return p.boolean;case"function":return p.function;case"bigint":return p.bigint;case"symbol":return p.symbol;case"object":return Array.isArray(t)?p.array:t===null?p.null:t.then&&typeof t.then=="function"&&t.catch&&typeof t.catch=="function"?p.promise:typeof Map<"u"&&t instanceof Map?p.map:typeof Set<"u"&&t instanceof Set?p.set:typeof Date<"u"&&t instanceof Date?p.date:p.object;default:return p.unknown}};var l=k.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"]),Lt=t=>JSON.stringify(t,null,2).replace(/"([^"]+)":/g,"$1:"),j=class t 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 r=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,r):this.__proto__=r,this.name="ZodError",this.issues=e}format(e){let r=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(r(i));else{let o=n,c=0;for(;cr.message){let r={},n=[];for(let s of this.issues)if(s.path.length>0){let a=s.path[0];r[a]=r[a]||[],r[a].push(e(s))}else n.push(e(s));return{formErrors:n,fieldErrors:r}}get formErrors(){return this.flatten()}};j.create=t=>new j(t);var Dt=(t,e)=>{let r;switch(t.code){case l.invalid_type:t.received===p.undefined?r="Required":r=`Expected ${t.expected}, received ${t.received}`;break;case l.invalid_literal:r=`Invalid literal value, expected ${JSON.stringify(t.expected,k.jsonStringifyReplacer)}`;break;case l.unrecognized_keys:r=`Unrecognized key(s) in object: ${k.joinValues(t.keys,", ")}`;break;case l.invalid_union:r="Invalid input";break;case l.invalid_union_discriminator:r=`Invalid discriminator value. Expected ${k.joinValues(t.options)}`;break;case l.invalid_enum_value:r=`Invalid enum value. Expected ${k.joinValues(t.options)}, received '${t.received}'`;break;case l.invalid_arguments:r="Invalid function arguments";break;case l.invalid_return_type:r="Invalid function return type";break;case l.invalid_date:r="Invalid date";break;case l.invalid_string:typeof t.validation=="object"?"includes"in t.validation?(r=`Invalid input: must include "${t.validation.includes}"`,typeof t.validation.position=="number"&&(r=`${r} at one or more positions greater than or equal to ${t.validation.position}`)):"startsWith"in t.validation?r=`Invalid input: must start with "${t.validation.startsWith}"`:"endsWith"in t.validation?r=`Invalid input: must end with "${t.validation.endsWith}"`:k.assertNever(t.validation):t.validation!=="regex"?r=`Invalid ${t.validation}`:r="Invalid";break;case l.too_small:t.type==="array"?r=`Array must contain ${t.exact?"exactly":t.inclusive?"at least":"more than"} ${t.minimum} element(s)`:t.type==="string"?r=`String must contain ${t.exact?"exactly":t.inclusive?"at least":"over"} ${t.minimum} character(s)`:t.type==="number"?r=`Number must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${t.minimum}`:t.type==="bigint"?r=`Number must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${t.minimum}`:t.type==="date"?r=`Date must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(t.minimum))}`:r="Invalid input";break;case l.too_big:t.type==="array"?r=`Array must contain ${t.exact?"exactly":t.inclusive?"at most":"less than"} ${t.maximum} element(s)`:t.type==="string"?r=`String must contain ${t.exact?"exactly":t.inclusive?"at most":"under"} ${t.maximum} character(s)`:t.type==="number"?r=`Number must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:t.type==="bigint"?r=`BigInt must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:t.type==="date"?r=`Date must be ${t.exact?"exactly":t.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(t.maximum))}`:r="Invalid input";break;case l.custom:r="Invalid input";break;case l.invalid_intersection_types:r="Intersection results could not be merged";break;case l.not_multiple_of:r=`Number must be a multiple of ${t.multipleOf}`;break;case l.not_finite:r="Number must be finite";break;default:r=e.defaultError,k.assertNever(t)}return{message:r}},F=Dt;var at=F;function Bt(t){at=t}function ke(){return at}var Ee=t=>{let{data:e,path:r,errorMaps:n,issueData:s}=t,a=[...r,...s.path||[]],i={...s,path:a};if(s.message!==void 0)return{...s,path:a,message:s.message};let o="",c=n.filter(u=>!!u).slice().reverse();for(let u of c)o=u(i,{data:e,defaultError:o}).message;return{...s,path:a,message:o}},Ut=[];function f(t,e){let r=ke(),n=Ee({issueData:e,data:t.data,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,r,r===F?void 0:F].filter(s=>!!s)});t.common.issues.push(n)}var C=class t{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,r){let n=[];for(let s of r){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,r){let n=[];for(let s of r){let a=await s.key,i=await s.value;n.push({key:a,value:i})}return t.mergeObjectSync(e,n)}static mergeObjectSync(e,r){let n={};for(let s of r){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"}),ne=t=>({status:"dirty",value:t}),E=t=>({status:"valid",value:t}),Ve=t=>t.status==="aborted",Pe=t=>t.status==="dirty",Y=t=>t.status==="valid",be=t=>typeof Promise<"u"&&t instanceof Promise;var m;(function(t){t.errToObj=e=>typeof e=="string"?{message:e}:e||{},t.toString=e=>typeof e=="string"?e:e?.message})(m||(m={}));var Z=class{constructor(e,r,n,s){this._cachedPath=[],this.parent=e,this.data=r,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}},it=(t,e)=>{if(Y(e))return{success:!0,data:e.value};if(!t.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;let r=new j(t.common.issues);return this._error=r,this._error}}};function v(t){if(!t)return{};let{errorMap:e,invalid_type_error:r,required_error:n,description:s}=t;if(e&&(r||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}=t;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??r??o.defaultError}},description:s}}var x=class{get description(){return this._def.description}_getType(e){return B(e.data)}_getOrReturnCtx(e,r){return r||{common:e.parent.common,data:e.data,parsedType:B(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new C,ctx:{common:e.parent.common,data:e.data,parsedType:B(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){let r=this._parse(e);if(be(r))throw new Error("Synchronous parse encountered promise.");return r}_parseAsync(e){let r=this._parse(e);return Promise.resolve(r)}parse(e,r){let n=this.safeParse(e,r);if(n.success)return n.data;throw n.error}safeParse(e,r){let n={common:{issues:[],async:r?.async??!1,contextualErrorMap:r?.errorMap},path:r?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:B(e)},s=this._parseSync({data:e,path:n.path,parent:n});return it(n,s)}"~validate"(e){let r={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:B(e)};if(!this["~standard"].async)try{let n=this._parseSync({data:e,path:[],parent:r});return Y(n)?{value:n.value}:{issues:r.common.issues}}catch(n){n?.message?.toLowerCase()?.includes("encountered")&&(this["~standard"].async=!0),r.common={issues:[],async:!0}}return this._parseAsync({data:e,path:[],parent:r}).then(n=>Y(n)?{value:n.value}:{issues:r.common.issues})}async parseAsync(e,r){let n=await this.safeParseAsync(e,r);if(n.success)return n.data;throw n.error}async safeParseAsync(e,r){let n={common:{issues:[],contextualErrorMap:r?.errorMap,async:!0},path:r?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:B(e)},s=this._parse({data:e,path:n.path,parent:n}),a=await(be(s)?s:Promise.resolve(s));return it(n,a)}refine(e,r){let n=s=>typeof r=="string"||typeof r>"u"?{message:r}:typeof r=="function"?r(s):r;return this._refinement((s,a)=>{let i=e(s),o=()=>a.addIssue({code:l.custom,...n(s)});return typeof Promise<"u"&&i instanceof Promise?i.then(c=>c?!0:(o(),!1)):i?!0:(o(),!1)})}refinement(e,r){return this._refinement((n,s)=>e(n)?!0:(s.addIssue(typeof r=="function"?r(n,s):r),!1))}_refinement(e){return new z({schema:this,typeName:_.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:r=>this["~validate"](r)}}optional(){return $.create(this,this._def)}nullable(){return q.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return G.create(this)}promise(){return Q.create(this,this._def)}or(e){return de.create([this,e],this._def)}and(e){return le.create(this,e,this._def)}transform(e){return new z({...v(this._def),schema:this,typeName:_.ZodEffects,effect:{type:"transform",transform:e}})}default(e){let r=typeof e=="function"?e:()=>e;return new ge({...v(this._def),innerType:this,defaultValue:r,typeName:_.ZodDefault})}brand(){return new je({typeName:_.ZodBranded,type:this,...v(this._def)})}catch(e){let r=typeof e=="function"?e:()=>e;return new ye({...v(this._def),innerType:this,catchValue:r,typeName:_.ZodCatch})}describe(e){let r=this.constructor;return new r({...this._def,description:e})}pipe(e){return Ne.create(this,e)}readonly(){return _e.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}},qt=/^c[^\s-]{8,}$/i,Jt=/^[0-9a-z]+$/,Ft=/^[0-9A-HJKMNP-TV-Z]{26}$/i,Wt=/^[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,Ht=/^[a-z0-9_-]{21}$/i,Gt=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,Yt=/^[-+]?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)?)??$/,Kt=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,Xt="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",He,Qt=/^(?:(?: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])$/,er=/^(?:(?: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])$/,tr=/^(([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]))$/,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]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,nr=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,sr=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,ct="((\\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])))",ar=new RegExp(`^${ct}$`);function ut(t){let e="[0-5]\\d";t.precision?e=`${e}\\.\\d{${t.precision}}`:t.precision==null&&(e=`${e}(\\.\\d+)?`);let r=t.precision?"+":"?";return`([01]\\d|2[0-3]):[0-5]\\d(:${e})${r}`}function ir(t){return new RegExp(`^${ut(t)}$`)}function dt(t){let e=`${ct}T${ut(t)}`,r=[];return r.push(t.local?"Z?":"Z"),t.offset&&r.push("([+-]\\d{2}:?\\d{2})"),e=`${e}(${r.join("|")})`,new RegExp(`^${e}$`)}function or(t,e){return!!((e==="v4"||!e)&&Qt.test(t)||(e==="v6"||!e)&&tr.test(t))}function cr(t,e){if(!Gt.test(t))return!1;try{let[r]=t.split(".");if(!r)return!1;let n=r.replace(/-/g,"+").replace(/_/g,"/").padEnd(r.length+(4-r.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(t,e){return!!((e==="v4"||!e)&&er.test(t)||(e==="v6"||!e)&&rr.test(t))}var K=class t extends x{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==p.string){let a=this._getOrReturnCtx(e);return f(a,{code:l.invalid_type,expected:p.string,received:a.parsedType}),g}let n=new C,s;for(let a of this._def.checks)if(a.kind==="min")e.data.lengtha.value&&(s=this._getOrReturnCtx(e,s),f(s,{code:l.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.lengthe.test(s),{validation:r,code:l.invalid_string,...m.errToObj(n)})}_addCheck(e){return new t({...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,r){return this._addCheck({kind:"regex",regex:e,...m.errToObj(r)})}includes(e,r){return this._addCheck({kind:"includes",value:e,position:r?.position,...m.errToObj(r?.message)})}startsWith(e,r){return this._addCheck({kind:"startsWith",value:e,...m.errToObj(r)})}endsWith(e,r){return this._addCheck({kind:"endsWith",value:e,...m.errToObj(r)})}min(e,r){return this._addCheck({kind:"min",value:e,...m.errToObj(r)})}max(e,r){return this._addCheck({kind:"max",value:e,...m.errToObj(r)})}length(e,r){return this._addCheck({kind:"length",value:e,...m.errToObj(r)})}nonempty(e){return this.min(1,m.errToObj(e))}trim(){return new t({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new t({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new t({...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 r of this._def.checks)r.kind==="min"&&(e===null||r.value>e)&&(e=r.value);return e}get maxLength(){let e=null;for(let r of this._def.checks)r.kind==="max"&&(e===null||r.valuenew K({checks:[],typeName:_.ZodString,coerce:t?.coerce??!1,...v(t)});function dr(t,e){let r=(t.toString().split(".")[1]||"").length,n=(e.toString().split(".")[1]||"").length,s=r>n?r:n,a=Number.parseInt(t.toFixed(s).replace(".","")),i=Number.parseInt(e.toFixed(s).replace(".",""));return a%i/10**s}var se=class t extends x{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)!==p.number){let a=this._getOrReturnCtx(e);return f(a,{code:l.invalid_type,expected:p.number,received:a.parsedType}),g}let n,s=new C;for(let a of this._def.checks)a.kind==="int"?k.isInteger(e.data)||(n=this._getOrReturnCtx(e,n),f(n,{code:l.invalid_type,expected:"integer",received:"float",message:a.message}),s.dirty()):a.kind==="min"?(a.inclusive?e.dataa.value:e.data>=a.value)&&(n=this._getOrReturnCtx(e,n),f(n,{code:l.too_big,maximum:a.value,type:"number",inclusive:a.inclusive,exact:!1,message:a.message}),s.dirty()):a.kind==="multipleOf"?dr(e.data,a.value)!==0&&(n=this._getOrReturnCtx(e,n),f(n,{code:l.not_multiple_of,multipleOf:a.value,message:a.message}),s.dirty()):a.kind==="finite"?Number.isFinite(e.data)||(n=this._getOrReturnCtx(e,n),f(n,{code:l.not_finite,message:a.message}),s.dirty()):k.assertNever(a);return{status:s.value,value:e.data}}gte(e,r){return this.setLimit("min",e,!0,m.toString(r))}gt(e,r){return this.setLimit("min",e,!1,m.toString(r))}lte(e,r){return this.setLimit("max",e,!0,m.toString(r))}lt(e,r){return this.setLimit("max",e,!1,m.toString(r))}setLimit(e,r,n,s){return new t({...this._def,checks:[...this._def.checks,{kind:e,value:r,inclusive:n,message:m.toString(s)}]})}_addCheck(e){return new t({...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,r){return this._addCheck({kind:"multipleOf",value:e,message:m.toString(r)})}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 r of this._def.checks)r.kind==="min"&&(e===null||r.value>e)&&(e=r.value);return e}get maxValue(){let e=null;for(let r of this._def.checks)r.kind==="max"&&(e===null||r.valuee.kind==="int"||e.kind==="multipleOf"&&k.isInteger(e.value))}get isFinite(){let e=null,r=null;for(let n of this._def.checks){if(n.kind==="finite"||n.kind==="int"||n.kind==="multipleOf")return!0;n.kind==="min"?(r===null||n.value>r)&&(r=n.value):n.kind==="max"&&(e===null||n.valuenew se({checks:[],typeName:_.ZodNumber,coerce:t?.coerce||!1,...v(t)});var ae=class t extends x{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)!==p.bigint)return this._getInvalidInput(e);let n,s=new C;for(let a of this._def.checks)a.kind==="min"?(a.inclusive?e.dataa.value:e.data>=a.value)&&(n=this._getOrReturnCtx(e,n),f(n,{code:l.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),f(n,{code:l.not_multiple_of,multipleOf:a.value,message:a.message}),s.dirty()):k.assertNever(a);return{status:s.value,value:e.data}}_getInvalidInput(e){let r=this._getOrReturnCtx(e);return f(r,{code:l.invalid_type,expected:p.bigint,received:r.parsedType}),g}gte(e,r){return this.setLimit("min",e,!0,m.toString(r))}gt(e,r){return this.setLimit("min",e,!1,m.toString(r))}lte(e,r){return this.setLimit("max",e,!0,m.toString(r))}lt(e,r){return this.setLimit("max",e,!1,m.toString(r))}setLimit(e,r,n,s){return new t({...this._def,checks:[...this._def.checks,{kind:e,value:r,inclusive:n,message:m.toString(s)}]})}_addCheck(e){return new t({...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,r){return this._addCheck({kind:"multipleOf",value:e,message:m.toString(r)})}get minValue(){let e=null;for(let r of this._def.checks)r.kind==="min"&&(e===null||r.value>e)&&(e=r.value);return e}get maxValue(){let e=null;for(let r of this._def.checks)r.kind==="max"&&(e===null||r.valuenew ae({checks:[],typeName:_.ZodBigInt,coerce:t?.coerce??!1,...v(t)});var ie=class extends x{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==p.boolean){let n=this._getOrReturnCtx(e);return f(n,{code:l.invalid_type,expected:p.boolean,received:n.parsedType}),g}return E(e.data)}};ie.create=t=>new ie({typeName:_.ZodBoolean,coerce:t?.coerce||!1,...v(t)});var oe=class t extends x{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==p.date){let a=this._getOrReturnCtx(e);return f(a,{code:l.invalid_type,expected:p.date,received:a.parsedType}),g}if(Number.isNaN(e.data.getTime())){let a=this._getOrReturnCtx(e);return f(a,{code:l.invalid_date}),g}let n=new C,s;for(let a of this._def.checks)a.kind==="min"?e.data.getTime()a.value&&(s=this._getOrReturnCtx(e,s),f(s,{code:l.too_big,message:a.message,inclusive:!0,exact:!1,maximum:a.value,type:"date"}),n.dirty()):k.assertNever(a);return{status:n.value,value:new Date(e.data.getTime())}}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}min(e,r){return this._addCheck({kind:"min",value:e.getTime(),message:m.toString(r)})}max(e,r){return this._addCheck({kind:"max",value:e.getTime(),message:m.toString(r)})}get minDate(){let e=null;for(let r of this._def.checks)r.kind==="min"&&(e===null||r.value>e)&&(e=r.value);return e!=null?new Date(e):null}get maxDate(){let e=null;for(let r of this._def.checks)r.kind==="max"&&(e===null||r.valuenew oe({checks:[],coerce:t?.coerce||!1,typeName:_.ZodDate,...v(t)});var Oe=class extends x{_parse(e){if(this._getType(e)!==p.symbol){let n=this._getOrReturnCtx(e);return f(n,{code:l.invalid_type,expected:p.symbol,received:n.parsedType}),g}return E(e.data)}};Oe.create=t=>new Oe({typeName:_.ZodSymbol,...v(t)});var ce=class extends x{_parse(e){if(this._getType(e)!==p.undefined){let n=this._getOrReturnCtx(e);return f(n,{code:l.invalid_type,expected:p.undefined,received:n.parsedType}),g}return E(e.data)}};ce.create=t=>new ce({typeName:_.ZodUndefined,...v(t)});var ue=class extends x{_parse(e){if(this._getType(e)!==p.null){let n=this._getOrReturnCtx(e);return f(n,{code:l.invalid_type,expected:p.null,received:n.parsedType}),g}return E(e.data)}};ue.create=t=>new ue({typeName:_.ZodNull,...v(t)});var X=class extends x{constructor(){super(...arguments),this._any=!0}_parse(e){return E(e.data)}};X.create=t=>new X({typeName:_.ZodAny,...v(t)});var H=class extends x{constructor(){super(...arguments),this._unknown=!0}_parse(e){return E(e.data)}};H.create=t=>new H({typeName:_.ZodUnknown,...v(t)});var L=class extends x{_parse(e){let r=this._getOrReturnCtx(e);return f(r,{code:l.invalid_type,expected:p.never,received:r.parsedType}),g}};L.create=t=>new L({typeName:_.ZodNever,...v(t)});var Te=class extends x{_parse(e){if(this._getType(e)!==p.undefined){let n=this._getOrReturnCtx(e);return f(n,{code:l.invalid_type,expected:p.void,received:n.parsedType}),g}return E(e.data)}};Te.create=t=>new Te({typeName:_.ZodVoid,...v(t)});var G=class t extends x{_parse(e){let{ctx:r,status:n}=this._processInputParams(e),s=this._def;if(r.parsedType!==p.array)return f(r,{code:l.invalid_type,expected:p.array,received:r.parsedType}),g;if(s.exactLength!==null){let i=r.data.length>s.exactLength.value,o=r.data.lengths.maxLength.value&&(f(r,{code:l.too_big,maximum:s.maxLength.value,type:"array",inclusive:!0,exact:!1,message:s.maxLength.message}),n.dirty()),r.common.async)return Promise.all([...r.data].map((i,o)=>s.type._parseAsync(new Z(r,i,r.path,o)))).then(i=>C.mergeArray(n,i));let a=[...r.data].map((i,o)=>s.type._parseSync(new Z(r,i,r.path,o)));return C.mergeArray(n,a)}get element(){return this._def.type}min(e,r){return new t({...this._def,minLength:{value:e,message:m.toString(r)}})}max(e,r){return new t({...this._def,maxLength:{value:e,message:m.toString(r)}})}length(e,r){return new t({...this._def,exactLength:{value:e,message:m.toString(r)}})}nonempty(e){return this.min(1,e)}};G.create=(t,e)=>new G({type:t,minLength:null,maxLength:null,exactLength:null,typeName:_.ZodArray,...v(e)});function we(t){if(t instanceof N){let e={};for(let r in t.shape){let n=t.shape[r];e[r]=$.create(we(n))}return new N({...t._def,shape:()=>e})}else return t instanceof G?new G({...t._def,type:we(t.element)}):t instanceof $?$.create(we(t.unwrap())):t instanceof q?q.create(we(t.unwrap())):t instanceof U?U.create(t.items.map(e=>we(e))):t}var N=class t extends x{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(),r=k.objectKeys(e);return this._cached={shape:e,keys:r},this._cached}_parse(e){if(this._getType(e)!==p.object){let u=this._getOrReturnCtx(e);return f(u,{code:l.invalid_type,expected:p.object,received:u.parsedType}),g}let{status:n,ctx:s}=this._processInputParams(e),{shape:a,keys:i}=this._getCached(),o=[];if(!(this._def.catchall instanceof L&&this._def.unknownKeys==="strip"))for(let u in s.data)i.includes(u)||o.push(u);let c=[];for(let u of i){let h=a[u],w=s.data[u];c.push({key:{status:"valid",value:u},value:h._parse(new Z(s,w,s.path,u)),alwaysSet:u in s.data})}if(this._def.catchall instanceof L){let u=this._def.unknownKeys;if(u==="passthrough")for(let h of o)c.push({key:{status:"valid",value:h},value:{status:"valid",value:s.data[h]}});else if(u==="strict")o.length>0&&(f(s,{code:l.unrecognized_keys,keys:o}),n.dirty());else if(u!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{let u=this._def.catchall;for(let h of o){let w=s.data[h];c.push({key:{status:"valid",value:h},value:u._parse(new Z(s,w,s.path,h)),alwaysSet:h in s.data})}}return s.common.async?Promise.resolve().then(async()=>{let u=[];for(let h of c){let w=await h.key,V=await h.value;u.push({key:w,value:V,alwaysSet:h.alwaysSet})}return u}).then(u=>C.mergeObjectSync(n,u)):C.mergeObjectSync(n,c)}get shape(){return this._def.shape()}strict(e){return m.errToObj,new t({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(r,n)=>{let s=this._def.errorMap?.(r,n).message??n.defaultError;return r.code==="unrecognized_keys"?{message:m.errToObj(e).message??s}:{message:s}}}:{}})}strip(){return new t({...this._def,unknownKeys:"strip"})}passthrough(){return new t({...this._def,unknownKeys:"passthrough"})}extend(e){return new t({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new t({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:_.ZodObject})}setKey(e,r){return this.augment({[e]:r})}catchall(e){return new t({...this._def,catchall:e})}pick(e){let r={};for(let n of k.objectKeys(e))e[n]&&this.shape[n]&&(r[n]=this.shape[n]);return new t({...this._def,shape:()=>r})}omit(e){let r={};for(let n of k.objectKeys(this.shape))e[n]||(r[n]=this.shape[n]);return new t({...this._def,shape:()=>r})}deepPartial(){return we(this)}partial(e){let r={};for(let n of k.objectKeys(this.shape)){let s=this.shape[n];e&&!e[n]?r[n]=s:r[n]=s.optional()}return new t({...this._def,shape:()=>r})}required(e){let r={};for(let n of k.objectKeys(this.shape))if(e&&!e[n])r[n]=this.shape[n];else{let a=this.shape[n];for(;a instanceof $;)a=a._def.innerType;r[n]=a}return new t({...this._def,shape:()=>r})}keyof(){return lt(k.objectKeys(this.shape))}};N.create=(t,e)=>new N({shape:()=>t,unknownKeys:"strip",catchall:L.create(),typeName:_.ZodObject,...v(e)});N.strictCreate=(t,e)=>new N({shape:()=>t,unknownKeys:"strict",catchall:L.create(),typeName:_.ZodObject,...v(e)});N.lazycreate=(t,e)=>new N({shape:t,unknownKeys:"strip",catchall:L.create(),typeName:_.ZodObject,...v(e)});var de=class extends x{_parse(e){let{ctx:r}=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 r.common.issues.push(...o.ctx.common.issues),o.result;let i=a.map(o=>new j(o.ctx.common.issues));return f(r,{code:l.invalid_union,unionErrors:i}),g}if(r.common.async)return Promise.all(n.map(async a=>{let i={...r,common:{...r.common,issues:[]},parent:null};return{result:await a._parseAsync({data:r.data,path:r.path,parent:i}),ctx:i}})).then(s);{let a,i=[];for(let c of n){let u={...r,common:{...r.common,issues:[]},parent:null},h=c._parseSync({data:r.data,path:r.path,parent:u});if(h.status==="valid")return h;h.status==="dirty"&&!a&&(a={result:h,ctx:u}),u.common.issues.length&&i.push(u.common.issues)}if(a)return r.common.issues.push(...a.ctx.common.issues),a.result;let o=i.map(c=>new j(c));return f(r,{code:l.invalid_union,unionErrors:o}),g}}get options(){return this._def.options}};de.create=(t,e)=>new de({options:t,typeName:_.ZodUnion,...v(e)});var W=t=>t instanceof fe?W(t.schema):t instanceof z?W(t.innerType()):t instanceof pe?[t.value]:t instanceof me?t.options:t instanceof he?k.objectValues(t.enum):t instanceof ge?W(t._def.innerType):t instanceof ce?[void 0]:t instanceof ue?[null]:t instanceof $?[void 0,...W(t.unwrap())]:t instanceof q?[null,...W(t.unwrap())]:t instanceof je||t instanceof _e?W(t.unwrap()):t instanceof ye?W(t._def.innerType):[],$e=class t extends x{_parse(e){let{ctx:r}=this._processInputParams(e);if(r.parsedType!==p.object)return f(r,{code:l.invalid_type,expected:p.object,received:r.parsedType}),g;let n=this.discriminator,s=r.data[n],a=this.optionsMap.get(s);return a?r.common.async?a._parseAsync({data:r.data,path:r.path,parent:r}):a._parseSync({data:r.data,path:r.path,parent:r}):(f(r,{code:l.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,r,n){let s=new Map;for(let a of r){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 t({typeName:_.ZodDiscriminatedUnion,discriminator:e,options:r,optionsMap:s,...v(n)})}};function Ge(t,e){let r=B(t),n=B(e);if(t===e)return{valid:!0,data:t};if(r===p.object&&n===p.object){let s=k.objectKeys(e),a=k.objectKeys(t).filter(o=>s.indexOf(o)!==-1),i={...t,...e};for(let o of a){let c=Ge(t[o],e[o]);if(!c.valid)return{valid:!1};i[o]=c.data}return{valid:!0,data:i}}else if(r===p.array&&n===p.array){if(t.length!==e.length)return{valid:!1};let s=[];for(let a=0;a{if(Ve(a)||Ve(i))return g;let o=Ge(a.value,i.value);return o.valid?((Pe(a)||Pe(i))&&r.dirty(),{status:r.value,value:o.data}):(f(n,{code:l.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}))}};le.create=(t,e,r)=>new le({left:t,right:e,typeName:_.ZodIntersection,...v(r)});var U=class t extends x{_parse(e){let{status:r,ctx:n}=this._processInputParams(e);if(n.parsedType!==p.array)return f(n,{code:l.invalid_type,expected:p.array,received:n.parsedType}),g;if(n.data.lengththis._def.items.length&&(f(n,{code:l.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),r.dirty());let a=[...n.data].map((i,o)=>{let c=this._def.items[o]||this._def.rest;return c?c._parse(new Z(n,i,n.path,o)):null}).filter(i=>!!i);return n.common.async?Promise.all(a).then(i=>C.mergeArray(r,i)):C.mergeArray(r,a)}get items(){return this._def.items}rest(e){return new t({...this._def,rest:e})}};U.create=(t,e)=>{if(!Array.isArray(t))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new U({items:t,typeName:_.ZodTuple,rest:null,...v(e)})};var Ze=class t extends x{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:r,ctx:n}=this._processInputParams(e);if(n.parsedType!==p.object)return f(n,{code:l.invalid_type,expected:p.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 Z(n,o,n.path,o)),value:i._parse(new Z(n,n.data[o],n.path,o)),alwaysSet:o in n.data});return n.common.async?C.mergeObjectAsync(r,s):C.mergeObjectSync(r,s)}get element(){return this._def.valueType}static create(e,r,n){return r instanceof x?new t({keyType:e,valueType:r,typeName:_.ZodRecord,...v(n)}):new t({keyType:K.create(),valueType:e,typeName:_.ZodRecord,...v(r)})}},Se=class extends x{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:r,ctx:n}=this._processInputParams(e);if(n.parsedType!==p.map)return f(n,{code:l.invalid_type,expected:p.map,received:n.parsedType}),g;let s=this._def.keyType,a=this._def.valueType,i=[...n.data.entries()].map(([o,c],u)=>({key:s._parse(new Z(n,o,n.path,[u,"key"])),value:a._parse(new Z(n,c,n.path,[u,"value"]))}));if(n.common.async){let o=new Map;return Promise.resolve().then(async()=>{for(let c of i){let u=await c.key,h=await c.value;if(u.status==="aborted"||h.status==="aborted")return g;(u.status==="dirty"||h.status==="dirty")&&r.dirty(),o.set(u.value,h.value)}return{status:r.value,value:o}})}else{let o=new Map;for(let c of i){let u=c.key,h=c.value;if(u.status==="aborted"||h.status==="aborted")return g;(u.status==="dirty"||h.status==="dirty")&&r.dirty(),o.set(u.value,h.value)}return{status:r.value,value:o}}}};Se.create=(t,e,r)=>new Se({valueType:e,keyType:t,typeName:_.ZodMap,...v(r)});var Ie=class t extends x{_parse(e){let{status:r,ctx:n}=this._processInputParams(e);if(n.parsedType!==p.set)return f(n,{code:l.invalid_type,expected:p.set,received:n.parsedType}),g;let s=this._def;s.minSize!==null&&n.data.sizes.maxSize.value&&(f(n,{code:l.too_big,maximum:s.maxSize.value,type:"set",inclusive:!0,exact:!1,message:s.maxSize.message}),r.dirty());let a=this._def.valueType;function i(c){let u=new Set;for(let h of c){if(h.status==="aborted")return g;h.status==="dirty"&&r.dirty(),u.add(h.value)}return{status:r.value,value:u}}let o=[...n.data.values()].map((c,u)=>a._parse(new Z(n,c,n.path,u)));return n.common.async?Promise.all(o).then(c=>i(c)):i(o)}min(e,r){return new t({...this._def,minSize:{value:e,message:m.toString(r)}})}max(e,r){return new t({...this._def,maxSize:{value:e,message:m.toString(r)}})}size(e,r){return this.min(e,r).max(e,r)}nonempty(e){return this.min(1,e)}};Ie.create=(t,e)=>new Ie({valueType:t,minSize:null,maxSize:null,typeName:_.ZodSet,...v(e)});var ze=class t extends x{constructor(){super(...arguments),this.validate=this.implement}_parse(e){let{ctx:r}=this._processInputParams(e);if(r.parsedType!==p.function)return f(r,{code:l.invalid_type,expected:p.function,received:r.parsedType}),g;function n(o,c){return Ee({data:o,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,ke(),F].filter(u=>!!u),issueData:{code:l.invalid_arguments,argumentsError:c}})}function s(o,c){return Ee({data:o,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,ke(),F].filter(u=>!!u),issueData:{code:l.invalid_return_type,returnTypeError:c}})}let a={errorMap:r.common.contextualErrorMap},i=r.data;if(this._def.returns instanceof Q){let o=this;return E(async function(...c){let u=new j([]),h=await o._def.args.parseAsync(c,a).catch(P=>{throw u.addIssue(n(c,P)),u}),w=await Reflect.apply(i,this,h);return await o._def.returns._def.type.parseAsync(w,a).catch(P=>{throw u.addIssue(s(w,P)),u})})}else{let o=this;return E(function(...c){let u=o._def.args.safeParse(c,a);if(!u.success)throw new j([n(c,u.error)]);let h=Reflect.apply(i,this,u.data),w=o._def.returns.safeParse(h,a);if(!w.success)throw new j([s(h,w.error)]);return w.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new t({...this._def,args:U.create(e).rest(H.create())})}returns(e){return new t({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,r,n){return new t({args:e||U.create([]).rest(H.create()),returns:r||H.create(),typeName:_.ZodFunction,...v(n)})}},fe=class extends x{get schema(){return this._def.getter()}_parse(e){let{ctx:r}=this._processInputParams(e);return this._def.getter()._parse({data:r.data,path:r.path,parent:r})}};fe.create=(t,e)=>new fe({getter:t,typeName:_.ZodLazy,...v(e)});var pe=class extends x{_parse(e){if(e.data!==this._def.value){let r=this._getOrReturnCtx(e);return f(r,{received:r.data,code:l.invalid_literal,expected:this._def.value}),g}return{status:"valid",value:e.data}}get value(){return this._def.value}};pe.create=(t,e)=>new pe({value:t,typeName:_.ZodLiteral,...v(e)});function lt(t,e){return new me({values:t,typeName:_.ZodEnum,...v(e)})}var me=class t extends x{_parse(e){if(typeof e.data!="string"){let r=this._getOrReturnCtx(e),n=this._def.values;return f(r,{expected:k.joinValues(n),received:r.parsedType,code:l.invalid_type}),g}if(this._cache||(this._cache=new Set(this._def.values)),!this._cache.has(e.data)){let r=this._getOrReturnCtx(e),n=this._def.values;return f(r,{received:r.data,code:l.invalid_enum_value,options:n}),g}return E(e.data)}get options(){return this._def.values}get enum(){let e={};for(let r of this._def.values)e[r]=r;return e}get Values(){let e={};for(let r of this._def.values)e[r]=r;return e}get Enum(){let e={};for(let r of this._def.values)e[r]=r;return e}extract(e,r=this._def){return t.create(e,{...this._def,...r})}exclude(e,r=this._def){return t.create(this.options.filter(n=>!e.includes(n)),{...this._def,...r})}};me.create=lt;var he=class extends x{_parse(e){let r=k.getValidEnumValues(this._def.values),n=this._getOrReturnCtx(e);if(n.parsedType!==p.string&&n.parsedType!==p.number){let s=k.objectValues(r);return f(n,{expected:k.joinValues(s),received:n.parsedType,code:l.invalid_type}),g}if(this._cache||(this._cache=new Set(k.getValidEnumValues(this._def.values))),!this._cache.has(e.data)){let s=k.objectValues(r);return f(n,{received:n.data,code:l.invalid_enum_value,options:s}),g}return E(e.data)}get enum(){return this._def.values}};he.create=(t,e)=>new he({values:t,typeName:_.ZodNativeEnum,...v(e)});var Q=class extends x{unwrap(){return this._def.type}_parse(e){let{ctx:r}=this._processInputParams(e);if(r.parsedType!==p.promise&&r.common.async===!1)return f(r,{code:l.invalid_type,expected:p.promise,received:r.parsedType}),g;let n=r.parsedType===p.promise?r.data:Promise.resolve(r.data);return E(n.then(s=>this._def.type.parseAsync(s,{path:r.path,errorMap:r.common.contextualErrorMap})))}};Q.create=(t,e)=>new Q({type:t,typeName:_.ZodPromise,...v(e)});var z=class extends x{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===_.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){let{status:r,ctx:n}=this._processInputParams(e),s=this._def.effect||null,a={addIssue:i=>{f(n,i),i.fatal?r.abort():r.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(r.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"?ne(c.value):r.value==="dirty"?ne(c.value):c});{if(r.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"?ne(o.value):r.value==="dirty"?ne(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"&&r.dirty(),i(o.value),{status:r.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"&&r.dirty(),i(o.value).then(()=>({status:r.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(!Y(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:r.value,value:o}}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(i=>Y(i)?Promise.resolve(s.transform(i.value,a)).then(o=>({status:r.value,value:o})):g);k.assertNever(s)}};z.create=(t,e,r)=>new z({schema:t,typeName:_.ZodEffects,effect:e,...v(r)});z.createWithPreprocess=(t,e,r)=>new z({schema:e,effect:{type:"preprocess",transform:t},typeName:_.ZodEffects,...v(r)});var $=class extends x{_parse(e){return this._getType(e)===p.undefined?E(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};$.create=(t,e)=>new $({innerType:t,typeName:_.ZodOptional,...v(e)});var q=class extends x{_parse(e){return this._getType(e)===p.null?E(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};q.create=(t,e)=>new q({innerType:t,typeName:_.ZodNullable,...v(e)});var ge=class extends x{_parse(e){let{ctx:r}=this._processInputParams(e),n=r.data;return r.parsedType===p.undefined&&(n=this._def.defaultValue()),this._def.innerType._parse({data:n,path:r.path,parent:r})}removeDefault(){return this._def.innerType}};ge.create=(t,e)=>new ge({innerType:t,typeName:_.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...v(e)});var ye=class extends x{_parse(e){let{ctx:r}=this._processInputParams(e),n={...r,common:{...r.common,issues:[]}},s=this._def.innerType._parse({data:n.data,path:n.path,parent:{...n}});return be(s)?s.then(a=>({status:"valid",value:a.status==="valid"?a.value:this._def.catchValue({get error(){return new j(n.common.issues)},input:n.data})})):{status:"valid",value:s.status==="valid"?s.value:this._def.catchValue({get error(){return new j(n.common.issues)},input:n.data})}}removeCatch(){return this._def.innerType}};ye.create=(t,e)=>new ye({innerType:t,typeName:_.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...v(e)});var Re=class extends x{_parse(e){if(this._getType(e)!==p.nan){let n=this._getOrReturnCtx(e);return f(n,{code:l.invalid_type,expected:p.nan,received:n.parsedType}),g}return{status:"valid",value:e.data}}};Re.create=t=>new Re({typeName:_.ZodNaN,...v(t)});var lr=Symbol("zod_brand"),je=class extends x{_parse(e){let{ctx:r}=this._processInputParams(e),n=r.data;return this._def.type._parse({data:n,path:r.path,parent:r})}unwrap(){return this._def.type}},Ne=class t extends x{_parse(e){let{status:r,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"?(r.dirty(),ne(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"?(r.dirty(),{status:"dirty",value:s.value}):this._def.out._parseSync({data:s.value,path:n.path,parent:n})}}static create(e,r){return new t({in:e,out:r,typeName:_.ZodPipeline})}},_e=class extends x{_parse(e){let r=this._def.innerType._parse(e),n=s=>(Y(s)&&(s.value=Object.freeze(s.value)),s);return be(r)?r.then(s=>n(s)):n(r)}unwrap(){return this._def.innerType}};_e.create=(t,e)=>new _e({innerType:t,typeName:_.ZodReadonly,...v(e)});function ot(t,e){let r=typeof t=="function"?t(e):typeof t=="string"?{message:t}:t;return typeof r=="string"?{message:r}:r}function ft(t,e={},r){return t?X.create().superRefine((n,s)=>{let a=t(n);if(a instanceof Promise)return a.then(i=>{if(!i){let o=ot(e,n),c=o.fatal??r??!0;s.addIssue({code:"custom",...o,fatal:c})}});if(!a){let i=ot(e,n),o=i.fatal??r??!0;s.addIssue({code:"custom",...i,fatal:o})}}):X.create()}var fr={object:N.lazycreate},_;(function(t){t.ZodString="ZodString",t.ZodNumber="ZodNumber",t.ZodNaN="ZodNaN",t.ZodBigInt="ZodBigInt",t.ZodBoolean="ZodBoolean",t.ZodDate="ZodDate",t.ZodSymbol="ZodSymbol",t.ZodUndefined="ZodUndefined",t.ZodNull="ZodNull",t.ZodAny="ZodAny",t.ZodUnknown="ZodUnknown",t.ZodNever="ZodNever",t.ZodVoid="ZodVoid",t.ZodArray="ZodArray",t.ZodObject="ZodObject",t.ZodUnion="ZodUnion",t.ZodDiscriminatedUnion="ZodDiscriminatedUnion",t.ZodIntersection="ZodIntersection",t.ZodTuple="ZodTuple",t.ZodRecord="ZodRecord",t.ZodMap="ZodMap",t.ZodSet="ZodSet",t.ZodFunction="ZodFunction",t.ZodLazy="ZodLazy",t.ZodLiteral="ZodLiteral",t.ZodEnum="ZodEnum",t.ZodEffects="ZodEffects",t.ZodNativeEnum="ZodNativeEnum",t.ZodOptional="ZodOptional",t.ZodNullable="ZodNullable",t.ZodDefault="ZodDefault",t.ZodCatch="ZodCatch",t.ZodPromise="ZodPromise",t.ZodBranded="ZodBranded",t.ZodPipeline="ZodPipeline",t.ZodReadonly="ZodReadonly"})(_||(_={}));var pr=(t,e={message:`Input not instance of ${t.name}`})=>ft(r=>r instanceof t,e),pt=K.create,mt=se.create,mr=Re.create,hr=ae.create,ht=ie.create,gr=oe.create,yr=Oe.create,_r=ce.create,vr=ue.create,xr=X.create,kr=H.create,br=L.create,wr=Te.create,Or=G.create,Tr=N.create,Sr=N.strictCreate,Ir=de.create,Rr=$e.create,Ar=le.create,Cr=U.create,Er=Ze.create,jr=Se.create,Nr=Ie.create,Mr=ze.create,Vr=fe.create,Pr=pe.create,$r=me.create,Zr=he.create,zr=Q.create,Lr=z.create,Dr=$.create,Br=q.create,Ur=z.createWithPreprocess,qr=Ne.create,Jr=()=>pt().optional(),Fr=()=>mt().optional(),Wr=()=>ht().optional(),Hr={string:(t=>K.create({...t,coerce:!0})),number:(t=>se.create({...t,coerce:!0})),boolean:(t=>ie.create({...t,coerce:!0})),bigint:(t=>ae.create({...t,coerce:!0})),date:(t=>oe.create({...t,coerce:!0}))};var Gr=g;var Kr=["run-create","run-list","run-show","run-current","run-use","task-create","task-list","task-update","worker-start","worker-show","worker-read","worker-release","send","check","reply","ask","gate-create","gate-list","gate-resolve"],T=class extends Error{constructor(r,n,s,a,i,o,c){super(o);this.code=r;this.operation=n;this.phase=s;this.retrySafety=a;this.recovery=i;this.stderr=c}code;operation;phase;retrySafety;recovery;stderr;name="OrcaAdapterError"},y=d.string().regex(/^[A-Za-z][A-Za-z0-9_-]{0,127}$/),rt=t=>d.string().refine(e=>e===e.normalize("NFC"),"must be NFC-normalized").refine(e=>!e.includes("\0")&&!/[\uD800-\uDFFF]/u.test(e),"contains an invalid code point").refine(e=>Buffer.byteLength(e,"utf8")>=1&&Buffer.byteLength(e,"utf8")<=t),M=rt(16384),D=rt(512),te=rt(256),Me=d.string().min(1).max(512).regex(/^[\x21-\x7E]+$/).refine(t=>!t.startsWith("-")&&!/[;&|`$<>\\(){}\[\]*?!'\"]/.test(t)),kt=Me.refine(t=>Buffer.byteLength(t,"utf8")<=128),gt=d.number().int().min(1).max(100),Ye=d.number().int().min(250).max(6e5),Ue=d.enum(["pending","ready","dispatched","completed","failed","blocked"]),bt=d.enum(["pending","resolved"]),Be=d.enum(["status","dispatch","worker_done","merge_ready","escalation","handoff","question","decision_gate","heartbeat"]),Xr=d.enum(["low","normal","high","urgent"]),wt=d.enum(["auto","transcript","terminal"]),Ot=d.enum(["claude","codex","cursor","droid","gemini","grok","opencode"]),Tt=d.enum(["low","medium","high","xhigh"]),ee=(t,e,r=0)=>d.array(t).min(r).max(e).refine(n=>new Set(n).size===n.length,"items must be unique"),St=d.object({summary:M,artifacts:ee(te,32).optional()}).strict().refine(t=>Buffer.byteLength(JSON.stringify(t))<=32768),Qr=d.object({taskId:y.optional(),dispatchId:y.optional(),phase:te.optional(),outcome:d.enum(["succeeded","failed"]).optional(),filesModified:ee(te,128).optional(),reportPath:te.optional()}).strict().refine(t=>Object.keys(t).length>0,"payload must not be empty").refine(t=>Buffer.byteLength(JSON.stringify(t))<=32768),R=(t,e)=>d.object({operation:d.literal(t),...e}).strict(),It=d.union([R("run-create",{objective:M}),R("run-list",{limit:gt.optional(),cursor:Me.optional()}),R("run-show",{id:y}),R("run-current",{}),R("run-use",{id:y}),R("task-create",{spec:M,title:D.optional(),deps:ee(y,64).optional(),parent:y.optional()}),R("task-list",{status:Ue.optional(),ready:d.boolean().optional(),brief:d.boolean().optional()}),R("task-update",{id:y,status:Ue,result:St.optional()}),R("worker-start",{task:y,agent:Ot,model:kt.optional(),effort:Tt.optional(),timeoutMs:Ye.optional()}).refine(t=>t.effort===void 0||t.model!==void 0,{message:"effort requires model"}),R("worker-show",{dispatch:y}),R("worker-read",{dispatch:y,source:wt.optional(),cursor:Me.optional(),limit:gt.optional()}),R("worker-release",{dispatch:y}),R("send",{subject:D,body:M.optional(),type:Be.optional(),priority:Xr.optional(),threadId:y.optional(),payload:Qr.optional()}),R("check",{ack:y.optional(),unread:d.boolean().optional(),peek:d.boolean().optional(),all:d.boolean().optional(),types:ee(Be,Be.options.length,1).optional(),wait:d.boolean().optional(),timeoutMs:Ye.optional()}).refine(t=>[t.unread,t.peek,t.all].filter(e=>e===!0).length<=1,{message:"unread, peek, and all are mutually exclusive"}).refine(t=>t.timeoutMs===void 0||t.wait===!0,{message:"timeoutMs requires wait"}),R("reply",{id:y,body:M}),R("ask",{question:D.optional(),resume:y.optional(),options:ee(te,10,1).optional(),timeoutMs:Ye.optional()}).refine(t=>t.question===void 0!=(t.resume===void 0),{message:"exactly one of question or resume is required"}).refine(t=>t.options===void 0||t.question!==void 0,{message:"options require question"}).refine(t=>t.options?.every(e=>!/[,\r\n]/.test(e))??!0,{message:"ask options cannot contain comma, CR, or LF"}),R("gate-create",{task:y,question:D,options:ee(te,10,1).optional()}),R("gate-list",{task:y.optional(),status:bt.optional()}),R("gate-resolve",{id:y,resolution:M,task:y})]);function S(t,e){if(e.length>0&&e[0]==="-")throw new T("invalid_argument","runtime","validate","safe","Correct the rejected semantic value and retry.",`${t} has a flag-shaped value`);return[t,e]}function I(t,e){return e===void 0?[]:S(t,String(e))}function Ae(t,e){return e===!0?[t]:[]}function yt(t){let e=It.safeParse(t);if(!e.success){let s=en(t);throw new T(s===void 0?"invalid_operation":"invalid_argument",s??"runtime","validate","safe","Correct the semantic input and retry.",e.error.issues.map(a=>a.message).join("; "))}let r=e.data,n=tn(r);return Object.freeze(["orchestration",r.operation,...n,"--json"])}function en(t){if(typeof t!="object"||t===null||!("operation"in t))return;let e=t.operation;return Kr.find(r=>r===e)}function tn(t){switch(t.operation){case"run-create":return S("--objective",t.objective);case"run-list":return[...I("--limit",t.limit),...I("--cursor",t.cursor)];case"run-show":case"run-use":return S("--id",t.id);case"run-current":return[];case"task-create":return[...S("--spec",t.spec),...I("--task-title",t.title),...t.deps===void 0?[]:S("--deps",JSON.stringify(t.deps)),...I("--parent",t.parent)];case"task-list":return[...I("--status",t.status),...Ae("--ready",t.ready),...Ae("--brief",t.brief)];case"task-update":return[...S("--id",t.id),...S("--status",t.status),...t.result===void 0?[]:S("--result",JSON.stringify(t.result))];case"worker-start":return[...S("--task",t.task),"--worktree","current",...S("--agent",t.agent),...I("--model",t.model),...I("--effort",t.effort),...I("--timeout-ms",t.timeoutMs)];case"worker-show":case"worker-release":return S("--dispatch",t.dispatch);case"worker-read":return[...S("--dispatch",t.dispatch),...I("--source",t.source),...I("--cursor",t.cursor),...I("--limit",t.limit)];case"send":return[...S("--subject",t.subject),...I("--body",t.body),...I("--type",t.type),...I("--priority",t.priority),...I("--thread-id",t.threadId),...t.payload===void 0?[]:S("--payload",JSON.stringify(t.payload))];case"check":return[...I("--ack",t.ack),...Ae("--unread",t.unread),...Ae("--peek",t.peek),...Ae("--all",t.all),...t.types===void 0?[]:S("--types",t.types.join(",")),...Ae("--wait",t.wait),...I("--timeout-ms",t.timeoutMs)];case"reply":return[...S("--id",t.id),...S("--body",t.body)];case"ask":return[...t.question===void 0?S("--resume",t.resume):S("--question",t.question),...t.options===void 0?[]:S("--options",t.options.join(",")),...I("--timeout-ms",t.timeoutMs)];case"gate-create":return[...S("--task",t.task),...S("--question",t.question),...t.options===void 0?[]:S("--options",JSON.stringify(t.options))];case"gate-list":return[...I("--task",t.task),...I("--status",t.status)];case"gate-resolve":return[...S("--id",t.id),...S("--resolution",t.resolution)]}}function rn(t={}){let e=t.platform??process.platform;if(e==="win32")return"orca.exe";if(e==="darwin")return"orca";if(e==="linux")return t.managedTerminal===!0?"orca":"orca-ide";throw new T("unsupported_platform","runtime","resolve","safe","Run the adapter on a supported Orca host.",`unsupported platform: ${e}`)}var nn=3e4,sn=5e3,an=605e3,on=1048576,cn=65536,un=1e3,dn=1e3;function Rt(t=Yr){return e=>new Promise((r,n)=>{let s=t(e.executable,[...e.argv],{shell:e.shell,env:e.env,stdio:["ignore","pipe","pipe"],windowsHide:!0}),a=[],i=[],o=0,c=0,u=!1,h=!1,w=!1,V=!1,P,J,xe=A=>{u||(u=!0,clearTimeout(st),P!==void 0&&clearTimeout(P),J!==void 0&&clearTimeout(J),r(A))},Je=()=>{s.kill("SIGTERM"),P??=setTimeout(()=>{s.kill("SIGKILL"),J??=setTimeout(()=>xe({exitCode:null,signal:"SIGKILL",stdout:Buffer.concat(a).toString("utf8"),stderr:Buffer.concat(i).toString("utf8"),timedOut:h,outputLimited:w,transportLost:!0}),dn)},un)},st=setTimeout(()=>{h=!0,Je()},e.timeoutMs),Fe=A=>{u||xe({exitCode:null,stdout:Buffer.concat(a).toString("utf8"),stderr:`${Buffer.concat(i).toString("utf8")} -${A}`,timedOut:h,outputLimited:w,transportLost:!0})};s.stdout.on("error",A=>{Fe(`stdout stream error: ${A.message}`)}),s.stderr.on("error",A=>{Fe(`stderr stream error: ${A.message}`)}),s.stdout.on("data",A=>{o+=A.length,o>e.maxStdoutBytes?(w=!0,Je()):a.push(A)}),s.stderr.on("data",A=>{c+=A.length,c>e.maxStderrBytes?(w=!0,Je()):i.push(A)}),s.once("spawn",()=>{V=!0}),s.once("error",A=>{if(!u){if(V){Fe(`process transport error: ${A.message}`);return}u=!0,clearTimeout(st),P!==void 0&&clearTimeout(P),J!==void 0&&clearTimeout(J),n(A)}}),s.once("close",(A,$t)=>{u||xe({exitCode:A,signal:$t,stdout:Buffer.concat(a).toString("utf8"),stderr:Buffer.concat(i).toString("utf8"),timedOut:h,outputLimited:w})})})}var At=Rt(),Ce=y,b=t=>d.object(t).strict(),Ke=b({id:y,objective:M.optional(),coordinatorTerminalHandle:Ce.optional()}),Le=b({id:y,objective:M,home_database:d.string().min(1).max(128),coordinator_handle:Ce,coordinator_pane_key:d.string().min(1).max(256),consumer_generation:d.number().int().positive(),legacy:d.number().int().min(0).max(1),created_at:d.string().min(1).max(64),updated_at:d.string().min(1).max(64)}),ln=b({id:y,spec:M,title:D.optional(),deps:ee(y,64).optional(),parent:y.optional(),status:Ue,result:St.optional()}),Xe=b({id:y,run_id:y,parent_id:y.nullable(),created_by_terminal_handle:Ce,created_by_pane_key:d.string().min(1).max(256),created_by_process_incarnation:d.string().min(1).max(512),created_by_run_generation:d.number().int().positive(),task_title:D,display_name:D,spec:M,status:Ue,deps:d.string().max(16384),result:d.string().max(32768).nullable(),created_at:d.string().min(1).max(64),completed_at:d.string().min(1).max(64).nullable()}),De=b({requestId:d.string().uuid(),replayed:d.boolean()}),_t=b({consumerGeneration:d.number().int().positive()}),fn=b({id:y,taskId:y,agent:Ot.optional(),model:kt.optional(),effort:Tt.optional(),state:te.optional(),terminalDisposition:d.enum(["released","retained"]).optional()}),pn=b({id:y,taskId:y,question:D,options:ee(te,10,1).optional(),status:bt,resolution:M.optional()}),vt=b({messageId:y}),mn=d.union([b({messageId:y,state:d.literal("answered"),answer:M}),b({messageId:y,state:d.literal("pending")})]),hn=b({deliveryId:y.optional(),acknowledged:d.boolean().optional(),messages:d.array(b({id:y,type:Be,subject:D})).max(50).optional(),count:d.number().int().min(0).max(50).optional()}),gn={"run-create":d.union([b({runId:y}),b({run:Le,binding:_t,mutation:De})]),"run-list":b({runs:d.array(Ke).max(100),cursor:Me.optional()}),"run-show":b({run:d.union([Ke,Le])}),"run-current":d.union([b({run:Ke,coordinatorTerminalHandle:Ce}),b({run:Le.nullable()})]),"run-use":d.union([b({runId:y,coordinatorTerminalHandle:Ce}),b({run:Le,binding:_t,mutation:De})]),"task-create":d.union([b({taskId:y}),b({task:Xe,mutation:De})]),"task-list":d.union([b({tasks:d.array(ln).max(100)}),b({runId:y,legacyReadOnly:d.boolean(),tasks:d.array(Xe).max(100),count:d.number().int().min(0).max(100)})]),"task-update":d.union([b({taskId:y}),b({task:Xe,mutation:De})]),"worker-start":b({dispatchId:y,taskId:y}),"worker-show":b({dispatch:fn}),"worker-read":b({dispatchId:y,source:wt,output:M,cursor:Me.optional()}),"worker-release":b({dispatchId:y}),send:vt,check:hn,reply:vt,ask:mn,"gate-create":b({gateId:y,taskId:y}),"gate-list":b({gates:d.array(pn).max(100)}),"gate-resolve":b({gateId:y,taskId:y})},yn=d.object({id:d.string().min(1).max(256),ok:d.boolean(),result:d.unknown().optional(),error:d.object({code:d.string().min(1).max(128),message:d.string().min(1).max(4096)}).strict().optional(),_meta:d.object({runtimeId:y,runtimeVersion:D.optional(),version:D.optional(),invokingTerminal:Ce.optional()}).strict().optional()}).strict().refine(t=>t.ok?t.result!==void 0&&t.error===void 0:t.result===void 0&&t.error!==void 0),_n=d.object({id:d.string().min(1).max(256),ok:d.literal(!0),result:d.object({target:d.object({kind:d.literal("local")}).strict(),app:d.object({running:d.literal(!0),pid:d.number().int().positive(),desktopWindowStatus:d.enum(["available","unavailable"])}).strict(),runtime:d.object({state:d.literal("ready"),reachable:d.literal(!0),runtimeId:d.string().min(1).max(256),appVersion:d.string().regex(/^\d+\.\d+\.\d+(?:[-+].*)?$/),remoteUpdateSupport:d.object({installMode:d.string().min(1).max(128),automatic:d.boolean(),reason:d.string().min(1).max(256)}).strict(),capabilities:d.array(d.string().min(1).max(256)).max(256)}).strict(),graph:d.object({state:d.literal("ready")}).strict()}).strict(),_meta:d.object({runtimeId:d.string().min(1).max(256)}).strict()}).strict().refine(t=>t.result.runtime.runtimeId===t._meta.runtimeId,"runtime identity mismatch");function re(t,e,r){return new T("ambiguous_after_possible_commit",t,e,"unrecoverably-ambiguous","Do not retry automatically; inspect the documented public read operation before choosing another mutation.",r)}function vn(t,e,r){let n;try{n=Ct(e)}catch{throw r?re(t,"decode","stdout was not one JSON document"):new T("malformed_json",t,"decode","safe","Inspect Orca health and retry this read-only operation when safe.","stdout was not one JSON document")}let s=yn.safeParse(n);if(!s.success)throw r?re(t,"decode","stdout did not match the Orca envelope contract"):new T("unexpected_response",t,"decode","safe","Use a compatible Orca CLI version.","stdout did not match the Orca envelope contract");if(s.data.ok&&!gn[t].safeParse(s.data.result).success)throw r?re(t,"receipt",`success result did not match the finite ${t} response contract`):new T("unexpected_response",t,"decode","safe","Use a compatible Orca CLI version and inspect the public operation result.",`success result did not match the finite ${t} response contract`);return s.data}function Ct(t){let e=[],r=!1,n=0;for(;n=t.length)throw new Error("unterminated JSON string");if(r){let i=JSON.parse(t.slice(a,n+1)),o=e.at(-1);if(o==null||o.has(i))throw new Error("duplicate JSON key");o.add(i),r=!1}}else s==="{"?(e.push(new Set),r=!0):s==="["?e.push(null):s==="}"||s==="]"?e.pop():s===","&&e.at(-1)instanceof Set&&(r=!0);n+=1}return JSON.parse(t)}var Qe=new Set(["run-create","run-use","task-create","task-update","worker-start","worker-release","send","reply","ask","gate-create","gate-resolve"]);function et(t,e){return t==="check"&&typeof e=="object"&&e!==null&&"ack"in e}function O(t){return typeof t!="object"||t===null||Array.isArray(t)?{}:t}function ve(t,e){let r=O(t)[e];return typeof r=="object"&&r!==null?O(r).id:void 0}function xn(t,e){let r=O(e);if(t==="run-create"||t==="run-use"){let s=r.runId??ve(r,"run");return Object.freeze(typeof s=="string"?{runId:s}:{})}if(t==="task-create"||t==="task-update"){let s=r.taskId??ve(r,"task");return Object.freeze(typeof s=="string"?{taskId:s}:{})}return Object.freeze(Object.fromEntries(({"run-create":["runId"],"run-use":["runId"],"task-create":["taskId"],"task-update":["taskId"],"worker-start":["dispatchId","taskId"],"worker-release":["dispatchId"],send:["messageId"],reply:["messageId"],ask:["messageId"],check:["deliveryId"],"gate-create":["gateId","taskId"],"gate-resolve":["gateId","taskId"]}[t]??[]).flatMap(s=>typeof r[s]=="string"?[[s,r[s]]]:[])))}function kn(t,e){if(t.operation==="run-use"){let r=O(e),n=r.runId??ve(r,"run");return{operation:{operation:"run-current"},matches:s=>{let a=O(s);if(a.run===null||a.run===void 0)return!1;let i=O(a.run);return n===t.id&&i.id===t.id}}}if(t.operation==="gate-resolve"){let r=O(e);return{operation:{operation:"gate-list",task:t.task},matches:n=>{if(r.gateId!==t.id||r.taskId!==t.task)return!1;let s=O(n).gates;if(!Array.isArray(s))return!1;let a=s.map(O).filter(i=>i.id===t.id);return a.length===1&&a[0].taskId===t.task&&a[0].status==="resolved"&&a[0].resolution===t.resolution}}}if(t.operation==="worker-release"){let r=O(e);return{operation:{operation:"worker-show",dispatch:t.dispatch},matches:n=>{let s=O(O(n).dispatch);return r.dispatchId===t.dispatch&&s.id===t.dispatch&&["released","retained"].includes(String(s.terminalDisposition))}}}if(t.operation==="run-create"){let r=O(e),n=r.runId??ve(r,"run");return{operation:{operation:"run-show",id:String(n)},matches:s=>{let a=O(O(s).run);return a.id===n&&a.objective===t.objective}}}if(t.operation==="task-create"||t.operation==="task-update"){let r=O(e),n=r.taskId??ve(r,"task"),s=t.operation==="task-create"?n:t.id;return{operation:{operation:"task-list"},matches:a=>{if(n!==s)return!1;let i=O(a).tasks;if(!Array.isArray(i))return!1;let o=i.map(O).filter(u=>u.id===s);if(o.length!==1)return!1;let c=o[0];return t.operation==="task-create"&&"run_id"in c?c.spec===t.spec&&c.task_title===(t.title??t.spec)&&c.deps===JSON.stringify(t.deps??[])&&c.parent_id===(t.parent??null):t.operation==="task-create"?c.spec===t.spec&&c.title===t.title&&JSON.stringify(c.deps??[])===JSON.stringify(t.deps??[])&&c.parent===t.parent:c.status===t.status&&bn(c.result,t.result)}}}if(t.operation==="worker-start"){let r=O(e),n=r.dispatchId;return{operation:{operation:"worker-show",dispatch:String(n)},matches:s=>{let a=O(O(s).dispatch);return r.taskId===t.task&&a.id===n&&a.taskId===t.task&&a.agent===t.agent&&a.model===t.model&&a.effort===t.effort}}}if(t.operation==="gate-create"){let r=O(e),n=r.gateId;return{operation:{operation:"gate-list",task:t.task},matches:s=>{let a=O(s).gates;if(!Array.isArray(a)||r.taskId!==t.task)return!1;let i=a.map(O).filter(c=>c.id===n);if(i.length!==1)return!1;let o=i[0];return o?.taskId===t.task&&o.question===t.question&&JSON.stringify(o.options)===JSON.stringify(t.options)}}}}function bn(t,e){return e===void 0?!0:JSON.stringify(t)===JSON.stringify(e)||t===JSON.stringify(e)}function wn(t,e,r){let n=et(t,e),s=Qe.has(t)||n;if(r.outputLimited||r.transportLost)return s?re(t,"execute",r.outputLimited?"Orca output exceeded the adapter limit":"Orca transport closed before a valid response"):xt(t,r.outputLimited?"output_limit":"process_exit",r.outputLimited?"Orca output exceeded the adapter limit":"Orca transport closed before a valid response");if(r.timedOut)return s?re(t,"execute","Orca did not finish before the deadline"):xt(t,"timeout","Orca did not finish before the deadline");if(r.exitCode!==0)return s?new T("ambiguous_after_possible_commit",t,"execute","unrecoverably-ambiguous","Do not retry automatically; inspect the documented public read operation before choosing another mutation.",`Orca exited with status ${r.exitCode??"signal"}`,r.stderr):new T("process_exit",t,"execute",s?"readback-required":"safe","Inspect Orca state and use the documented recovery operation.",`Orca exited with status ${r.exitCode??"signal"}`,r.stderr.slice(-4096))}function xt(t,e,r){return new T(e,t,"execute","safe","Retry the read-only operation when Orca is healthy.",r)}function On(t,e){return t===void 0?e:Math.min(an,Math.max(e,t+sn))}function Et(t={}){let e=Object.freeze({...t.env??process.env}),r=rn({platform:t.platform,managedTerminal:t.managedTerminal??e.TERM_PROGRAM==="Orca"}),n=t.executor??At,s=t.timeoutMs??nn,a=t.now??(()=>new Date),i=async(c,u,h=s)=>{try{return await n({executable:r,argv:c,shell:!1,timeoutMs:h,maxStdoutBytes:on,maxStderrBytes:cn,env:e})}catch(w){throw new T("executable_unavailable",u,"resolve","safe","Verify that the deterministic Orca executable is installed and available, then retry.",w instanceof Error&&"code"in w?`Orca execution failed (${String(w.code)})`:"Orca execution failed")}},o=async c=>{let u=yt(c),h="timeoutMs"in c?c.timeoutMs:void 0,w=await i(u,c.operation,On(h,s));w={...w,stderr:An(w.stderr,c,e)};let V=Qe.has(c.operation)||et(c.operation,c),P=wn(c.operation,c,w);if(P!==void 0)throw P;let J=vn(c.operation,w.stdout,V);if(!J.ok){let xe=nt(J.error?.message??"Orca returned an error envelope",c,e);throw V?re(c.operation,"decode",xe):new T("unexpected_response",c.operation,"decode",V?"readback-required":"safe","Follow the public Orca diagnostic and inspect state before retrying.",xe)}return J};return Object.freeze({executable:r,async status(){let c=await i(["status","--json"],"runtime");if(c.outputLimited||c.transportLost||c.timedOut||c.exitCode!==0)throw new T(c.outputLimited?"output_limit":c.timedOut?"timeout":"process_exit","runtime","execute","safe","Restore the public Orca runtime and retry the compatibility probe.","Orca status did not complete successfully");let u;try{u=Ct(c.stdout)}catch{throw new T("malformed_json","runtime","decode","safe","Use a compatible Orca CLI version.","Orca status was not one JSON document")}let h=_n.safeParse(u);if(!h.success)throw new T("unexpected_response","runtime","decode","safe","Use a compatible Orca CLI version.","Orca status did not match the strict runtime compatibility contract");return h.data},async execute(c){let u=It.safeParse(c);if(!u.success)throw yt(c),new Error("unreachable");let h=u.data,w=a().toISOString(),V=await o(h);return!Qe.has(h.operation)&&!et(h.operation,h)?V:Tn(h,V,w,o,a,e)}})}async function Tn(t,e,r,n,s,a){In(t,e);let i=kn(t,e.result);if(i!==void 0){let u;try{u=await n(i.operation)}catch(h){throw Sn(t,i.operation.operation,h,a)}if(!i.matches(u.result))throw new T("readback_mismatch",t.operation,"readback","unsafe",`Inspect state with orchestration ${i.operation.operation}; do not retry the mutation automatically.`,`${i.operation.operation} disagreed with the mutation receipt`)}let o=e._meta,c=Object.freeze({verb:t.operation,ids:xn(t.operation,e.result),runtimeId:o.runtimeId,runtimeVersion:o.runtimeVersion??null,startedAt:r,completedAt:s().toISOString(),readbackVerb:i?.operation.operation??null});return Object.freeze({...e,receipt:c})}function Sn(t,e,r,n){return r instanceof T?new T(r.code,t.operation,"readback","readback-required",`Repeat or inspect orchestration ${e}; do not retry the mutation automatically.`,nt(`${e} failed after Orca returned a valid mutation receipt: ${r.message}`,t,n),r.stderr):new T("unexpected_response",t.operation,"readback","unrecoverably-ambiguous",`Inspect state with orchestration ${e}; do not retry the mutation automatically.`,`${e} failed after Orca returned a valid mutation receipt`)}function In(t,e){if(e._meta?.runtimeId===void 0)throw re(t.operation,"receipt","mutation receipt omitted bounded runtime identity metadata");if(!Rn(t,e.result))throw new T("readback_mismatch",t.operation,"receipt","unsafe","Inspect the requested entity with its documented public read operation; do not retry automatically.","mutation receipt identity disagreed with the requested entity");if(t.operation==="check"&&t.ack!==void 0&&O(e.result).acknowledged!==!0)throw re(t.operation,"receipt","check --ack success did not contain its matching delivery identifier");if(t.operation==="run-use"&&"coordinatorTerminalHandle"in O(e.result)&&O(e.result).coordinatorTerminalHandle!==e._meta.invokingTerminal)throw new T("readback_mismatch",t.operation,"readback","unsafe","Inspect orchestration run-current; do not retry run-use automatically.","run-use terminal binding was not runtime-attested")}function Rn(t,e){let r=O(e);switch(t.operation){case"run-use":return(r.runId??ve(r,"run"))===t.id;case"task-update":return(r.taskId??ve(r,"task"))===t.id;case"worker-start":return r.taskId===t.task;case"worker-release":return r.dispatchId===t.dispatch;case"reply":return r.messageId===t.id;case"ask":return t.resume===void 0||r.messageId===t.resume;case"check":return t.ack===void 0||r.deliveryId===t.ack;case"gate-create":return r.taskId===t.task;case"gate-resolve":return r.gateId===t.id&&r.taskId===t.task;default:return!0}}function An(t,e,r){return nt(t,e,r)}function nt(t,e,r){let n=[...t].filter(c=>{let u=c.charCodeAt(0);return u===9||u===10||u===13||u>=32&&u!==127&&u<128||u>159}).join(""),s=tt(e),a=Object.entries(r).filter(([c,u])=>u!==void 0&&/(?:TOKEN|SECRET|PASSWORD|PASS|KEY|CREDENTIAL|AUTH|COOKIE)/i.test(c)).map(([,c])=>c),i=Object.values(r).flatMap(c=>c===void 0?[]:Cn(c));for(let c of[...s,...a,...i].filter(u=>u.length>=3).sort((u,h)=>h.length-u.length))n=n.split(c).join("[REDACTED]");let o=Buffer.from(n,"utf8");return o.length<=4096?n:Buffer.concat([Buffer.from("[truncated] "),o.subarray(o.length-4084)]).toString("utf8")}function Cn(t){try{let e=new URL(t);if(e.password.length===0)return[];try{return[e.password,decodeURIComponent(e.password)]}catch{return[e.password]}}catch{return[]}}function tt(t){return typeof t=="string"?[t]:Array.isArray(t)?t.flatMap(tt):typeof t=="object"&&t!==null?Object.values(t).flatMap(tt):[]}function qe(){return Et()}var ls=Object.freeze({createAdapter:Et,createOrcaProcessExecutor:Rt,spawnOrcaProcess:At});var En="1.4.192",jt="orchestration.contract.v1";function Nt(t){return new T("unsupported_environment","runtime","resolve","safe","Run this plugin in a supported Orca host with the public orchestration contract and child-process access.",t)}function Mt(t){let e=/^(\d+)\.(\d+)\.(\d+)(?:-([0-9A-Za-z.-]+))?(?:\+[0-9A-Za-z.-]+)?$/.exec(t);if(e!==null)return{release:[Number(e[1]),Number(e[2]),Number(e[3])],prerelease:e[4]===void 0?[]:e[4].split(".")}}function jn(t,e){if(t.length===0||e.length===0)return e.length-t.length;for(let r=0;rn.release[s];return jn(r.prerelease,n.prerelease)>=0}async function Vt(t){try{let e=await t.status(),r=e.result.runtime.runtimeId,n=e.result.runtime.appVersion;if(!Nn(n,En)||!e.result.runtime.capabilities.includes(jt))throw Nt("Orca runtime version or orchestration contract is outside the supported range.");return Object.freeze({runtimeId:r,runtimeVersion:n,contract:jt})}catch(e){throw e instanceof T&&e.code==="unsupported_environment"?e:Nt("The Orca compatibility probe could not complete through the public adapter.")}}function Pt(t=qe()){return Object.freeze({probe:()=>Vt(t),async execute(e){return await Vt(t),t.execute(e)}})}var Mn="genie.orca.run-list";function Vn(t=qe()){let e=Pt(t);return async r=>{r.commands.register(Mn,()=>e.execute({operation:"run-list",limit:100}))}}var ys=Vn();export{Mn as ORCA_RUN_LIST_COMMAND,Vn as createOrcaPluginEntrypoint,ys as default}; +var Zt=Object.defineProperty;var zt=(t,e)=>{for(var r in e)Zt(t,r,{get:e[r],enumerable:!0})};import{spawn as Yr}from"node:child_process";var d={};zt(d,{BRAND:()=>lr,DIRTY:()=>ne,EMPTY_PATH:()=>Ut,INVALID:()=>g,NEVER:()=>Gr,OK:()=>E,ParseStatus:()=>C,Schema:()=>x,ZodAny:()=>X,ZodArray:()=>G,ZodBigInt:()=>ae,ZodBoolean:()=>ie,ZodBranded:()=>Ne,ZodCatch:()=>ye,ZodDate:()=>oe,ZodDefault:()=>ge,ZodDiscriminatedUnion:()=>Ze,ZodEffects:()=>z,ZodEnum:()=>me,ZodError:()=>j,ZodFirstPartyTypeKind:()=>_,ZodFunction:()=>Le,ZodIntersection:()=>le,ZodIssueCode:()=>l,ZodLazy:()=>fe,ZodLiteral:()=>pe,ZodMap:()=>Se,ZodNaN:()=>Re,ZodNativeEnum:()=>he,ZodNever:()=>L,ZodNull:()=>ue,ZodNullable:()=>q,ZodNumber:()=>se,ZodObject:()=>N,ZodOptional:()=>$,ZodParsedType:()=>p,ZodPipeline:()=>Me,ZodPromise:()=>Q,ZodReadonly:()=>_e,ZodRecord:()=>ze,ZodSchema:()=>x,ZodSet:()=>Ie,ZodString:()=>K,ZodSymbol:()=>Oe,ZodTransformer:()=>z,ZodTuple:()=>U,ZodType:()=>x,ZodUndefined:()=>ce,ZodUnion:()=>de,ZodUnknown:()=>H,ZodVoid:()=>Te,addIssueToContext:()=>f,any:()=>xr,array:()=>Or,bigint:()=>hr,boolean:()=>ht,coerce:()=>Hr,custom:()=>ft,date:()=>gr,datetimeRegex:()=>dt,defaultErrorMap:()=>F,discriminatedUnion:()=>Rr,effect:()=>Lr,enum:()=>$r,function:()=>Mr,getErrorMap:()=>ke,getParsedType:()=>B,instanceof:()=>pr,intersection:()=>Ar,isAborted:()=>Pe,isAsync:()=>be,isDirty:()=>$e,isValid:()=>Y,late:()=>fr,lazy:()=>Vr,literal:()=>Pr,makeIssue:()=>je,map:()=>jr,nan:()=>mr,nativeEnum:()=>Zr,never:()=>br,null:()=>vr,nullable:()=>Br,number:()=>mt,object:()=>Tr,objectUtil:()=>We,oboolean:()=>Wr,onumber:()=>Fr,optional:()=>Dr,ostring:()=>Jr,pipeline:()=>qr,preprocess:()=>Ur,promise:()=>zr,quotelessJson:()=>Lt,record:()=>Er,set:()=>Nr,setErrorMap:()=>Bt,strictObject:()=>Sr,string:()=>pt,symbol:()=>yr,transformer:()=>Lr,tuple:()=>Cr,undefined:()=>_r,union:()=>Ir,unknown:()=>kr,util:()=>k,void:()=>wr});var k;(function(t){t.assertEqual=s=>{};function e(s){}t.assertIs=e;function r(s){throw new Error}t.assertNever=r,t.arrayToEnum=s=>{let a={};for(let i of s)a[i]=i;return a},t.getValidEnumValues=s=>{let a=t.objectKeys(s).filter(o=>typeof s[s[o]]!="number"),i={};for(let o of a)i[o]=s[o];return t.objectValues(i)},t.objectValues=s=>t.objectKeys(s).map(function(a){return s[a]}),t.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},t.find=(s,a)=>{for(let i of s)if(a(i))return i},t.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)}t.joinValues=n,t.jsonStringifyReplacer=(s,a)=>typeof a=="bigint"?a.toString():a})(k||(k={}));var We;(function(t){t.mergeShapes=(e,r)=>({...e,...r})})(We||(We={}));var p=k.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),B=t=>{switch(typeof t){case"undefined":return p.undefined;case"string":return p.string;case"number":return Number.isNaN(t)?p.nan:p.number;case"boolean":return p.boolean;case"function":return p.function;case"bigint":return p.bigint;case"symbol":return p.symbol;case"object":return Array.isArray(t)?p.array:t===null?p.null:t.then&&typeof t.then=="function"&&t.catch&&typeof t.catch=="function"?p.promise:typeof Map<"u"&&t instanceof Map?p.map:typeof Set<"u"&&t instanceof Set?p.set:typeof Date<"u"&&t instanceof Date?p.date:p.object;default:return p.unknown}};var l=k.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"]),Lt=t=>JSON.stringify(t,null,2).replace(/"([^"]+)":/g,"$1:"),j=class t 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 r=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,r):this.__proto__=r,this.name="ZodError",this.issues=e}format(e){let r=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(r(i));else{let o=n,c=0;for(;cr.message){let r={},n=[];for(let s of this.issues)if(s.path.length>0){let a=s.path[0];r[a]=r[a]||[],r[a].push(e(s))}else n.push(e(s));return{formErrors:n,fieldErrors:r}}get formErrors(){return this.flatten()}};j.create=t=>new j(t);var Dt=(t,e)=>{let r;switch(t.code){case l.invalid_type:t.received===p.undefined?r="Required":r=`Expected ${t.expected}, received ${t.received}`;break;case l.invalid_literal:r=`Invalid literal value, expected ${JSON.stringify(t.expected,k.jsonStringifyReplacer)}`;break;case l.unrecognized_keys:r=`Unrecognized key(s) in object: ${k.joinValues(t.keys,", ")}`;break;case l.invalid_union:r="Invalid input";break;case l.invalid_union_discriminator:r=`Invalid discriminator value. Expected ${k.joinValues(t.options)}`;break;case l.invalid_enum_value:r=`Invalid enum value. Expected ${k.joinValues(t.options)}, received '${t.received}'`;break;case l.invalid_arguments:r="Invalid function arguments";break;case l.invalid_return_type:r="Invalid function return type";break;case l.invalid_date:r="Invalid date";break;case l.invalid_string:typeof t.validation=="object"?"includes"in t.validation?(r=`Invalid input: must include "${t.validation.includes}"`,typeof t.validation.position=="number"&&(r=`${r} at one or more positions greater than or equal to ${t.validation.position}`)):"startsWith"in t.validation?r=`Invalid input: must start with "${t.validation.startsWith}"`:"endsWith"in t.validation?r=`Invalid input: must end with "${t.validation.endsWith}"`:k.assertNever(t.validation):t.validation!=="regex"?r=`Invalid ${t.validation}`:r="Invalid";break;case l.too_small:t.type==="array"?r=`Array must contain ${t.exact?"exactly":t.inclusive?"at least":"more than"} ${t.minimum} element(s)`:t.type==="string"?r=`String must contain ${t.exact?"exactly":t.inclusive?"at least":"over"} ${t.minimum} character(s)`:t.type==="number"?r=`Number must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${t.minimum}`:t.type==="bigint"?r=`Number must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${t.minimum}`:t.type==="date"?r=`Date must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(t.minimum))}`:r="Invalid input";break;case l.too_big:t.type==="array"?r=`Array must contain ${t.exact?"exactly":t.inclusive?"at most":"less than"} ${t.maximum} element(s)`:t.type==="string"?r=`String must contain ${t.exact?"exactly":t.inclusive?"at most":"under"} ${t.maximum} character(s)`:t.type==="number"?r=`Number must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:t.type==="bigint"?r=`BigInt must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:t.type==="date"?r=`Date must be ${t.exact?"exactly":t.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(t.maximum))}`:r="Invalid input";break;case l.custom:r="Invalid input";break;case l.invalid_intersection_types:r="Intersection results could not be merged";break;case l.not_multiple_of:r=`Number must be a multiple of ${t.multipleOf}`;break;case l.not_finite:r="Number must be finite";break;default:r=e.defaultError,k.assertNever(t)}return{message:r}},F=Dt;var at=F;function Bt(t){at=t}function ke(){return at}var je=t=>{let{data:e,path:r,errorMaps:n,issueData:s}=t,a=[...r,...s.path||[]],i={...s,path:a};if(s.message!==void 0)return{...s,path:a,message:s.message};let o="",c=n.filter(u=>!!u).slice().reverse();for(let u of c)o=u(i,{data:e,defaultError:o}).message;return{...s,path:a,message:o}},Ut=[];function f(t,e){let r=ke(),n=je({issueData:e,data:t.data,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,r,r===F?void 0:F].filter(s=>!!s)});t.common.issues.push(n)}var C=class t{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,r){let n=[];for(let s of r){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,r){let n=[];for(let s of r){let a=await s.key,i=await s.value;n.push({key:a,value:i})}return t.mergeObjectSync(e,n)}static mergeObjectSync(e,r){let n={};for(let s of r){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"}),ne=t=>({status:"dirty",value:t}),E=t=>({status:"valid",value:t}),Pe=t=>t.status==="aborted",$e=t=>t.status==="dirty",Y=t=>t.status==="valid",be=t=>typeof Promise<"u"&&t instanceof Promise;var m;(function(t){t.errToObj=e=>typeof e=="string"?{message:e}:e||{},t.toString=e=>typeof e=="string"?e:e?.message})(m||(m={}));var Z=class{constructor(e,r,n,s){this._cachedPath=[],this.parent=e,this.data=r,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}},it=(t,e)=>{if(Y(e))return{success:!0,data:e.value};if(!t.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;let r=new j(t.common.issues);return this._error=r,this._error}}};function v(t){if(!t)return{};let{errorMap:e,invalid_type_error:r,required_error:n,description:s}=t;if(e&&(r||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}=t;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??r??o.defaultError}},description:s}}var x=class{get description(){return this._def.description}_getType(e){return B(e.data)}_getOrReturnCtx(e,r){return r||{common:e.parent.common,data:e.data,parsedType:B(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new C,ctx:{common:e.parent.common,data:e.data,parsedType:B(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){let r=this._parse(e);if(be(r))throw new Error("Synchronous parse encountered promise.");return r}_parseAsync(e){let r=this._parse(e);return Promise.resolve(r)}parse(e,r){let n=this.safeParse(e,r);if(n.success)return n.data;throw n.error}safeParse(e,r){let n={common:{issues:[],async:r?.async??!1,contextualErrorMap:r?.errorMap},path:r?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:B(e)},s=this._parseSync({data:e,path:n.path,parent:n});return it(n,s)}"~validate"(e){let r={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:B(e)};if(!this["~standard"].async)try{let n=this._parseSync({data:e,path:[],parent:r});return Y(n)?{value:n.value}:{issues:r.common.issues}}catch(n){n?.message?.toLowerCase()?.includes("encountered")&&(this["~standard"].async=!0),r.common={issues:[],async:!0}}return this._parseAsync({data:e,path:[],parent:r}).then(n=>Y(n)?{value:n.value}:{issues:r.common.issues})}async parseAsync(e,r){let n=await this.safeParseAsync(e,r);if(n.success)return n.data;throw n.error}async safeParseAsync(e,r){let n={common:{issues:[],contextualErrorMap:r?.errorMap,async:!0},path:r?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:B(e)},s=this._parse({data:e,path:n.path,parent:n}),a=await(be(s)?s:Promise.resolve(s));return it(n,a)}refine(e,r){let n=s=>typeof r=="string"||typeof r>"u"?{message:r}:typeof r=="function"?r(s):r;return this._refinement((s,a)=>{let i=e(s),o=()=>a.addIssue({code:l.custom,...n(s)});return typeof Promise<"u"&&i instanceof Promise?i.then(c=>c?!0:(o(),!1)):i?!0:(o(),!1)})}refinement(e,r){return this._refinement((n,s)=>e(n)?!0:(s.addIssue(typeof r=="function"?r(n,s):r),!1))}_refinement(e){return new z({schema:this,typeName:_.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:r=>this["~validate"](r)}}optional(){return $.create(this,this._def)}nullable(){return q.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return G.create(this)}promise(){return Q.create(this,this._def)}or(e){return de.create([this,e],this._def)}and(e){return le.create(this,e,this._def)}transform(e){return new z({...v(this._def),schema:this,typeName:_.ZodEffects,effect:{type:"transform",transform:e}})}default(e){let r=typeof e=="function"?e:()=>e;return new ge({...v(this._def),innerType:this,defaultValue:r,typeName:_.ZodDefault})}brand(){return new Ne({typeName:_.ZodBranded,type:this,...v(this._def)})}catch(e){let r=typeof e=="function"?e:()=>e;return new ye({...v(this._def),innerType:this,catchValue:r,typeName:_.ZodCatch})}describe(e){let r=this.constructor;return new r({...this._def,description:e})}pipe(e){return Me.create(this,e)}readonly(){return _e.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}},qt=/^c[^\s-]{8,}$/i,Jt=/^[0-9a-z]+$/,Ft=/^[0-9A-HJKMNP-TV-Z]{26}$/i,Wt=/^[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,Ht=/^[a-z0-9_-]{21}$/i,Gt=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,Yt=/^[-+]?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)?)??$/,Kt=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,Xt="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",He,Qt=/^(?:(?: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])$/,er=/^(?:(?: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])$/,tr=/^(([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]))$/,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]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,nr=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,sr=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,ct="((\\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])))",ar=new RegExp(`^${ct}$`);function ut(t){let e="[0-5]\\d";t.precision?e=`${e}\\.\\d{${t.precision}}`:t.precision==null&&(e=`${e}(\\.\\d+)?`);let r=t.precision?"+":"?";return`([01]\\d|2[0-3]):[0-5]\\d(:${e})${r}`}function ir(t){return new RegExp(`^${ut(t)}$`)}function dt(t){let e=`${ct}T${ut(t)}`,r=[];return r.push(t.local?"Z?":"Z"),t.offset&&r.push("([+-]\\d{2}:?\\d{2})"),e=`${e}(${r.join("|")})`,new RegExp(`^${e}$`)}function or(t,e){return!!((e==="v4"||!e)&&Qt.test(t)||(e==="v6"||!e)&&tr.test(t))}function cr(t,e){if(!Gt.test(t))return!1;try{let[r]=t.split(".");if(!r)return!1;let n=r.replace(/-/g,"+").replace(/_/g,"/").padEnd(r.length+(4-r.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(t,e){return!!((e==="v4"||!e)&&er.test(t)||(e==="v6"||!e)&&rr.test(t))}var K=class t extends x{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==p.string){let a=this._getOrReturnCtx(e);return f(a,{code:l.invalid_type,expected:p.string,received:a.parsedType}),g}let n=new C,s;for(let a of this._def.checks)if(a.kind==="min")e.data.lengtha.value&&(s=this._getOrReturnCtx(e,s),f(s,{code:l.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.lengthe.test(s),{validation:r,code:l.invalid_string,...m.errToObj(n)})}_addCheck(e){return new t({...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,r){return this._addCheck({kind:"regex",regex:e,...m.errToObj(r)})}includes(e,r){return this._addCheck({kind:"includes",value:e,position:r?.position,...m.errToObj(r?.message)})}startsWith(e,r){return this._addCheck({kind:"startsWith",value:e,...m.errToObj(r)})}endsWith(e,r){return this._addCheck({kind:"endsWith",value:e,...m.errToObj(r)})}min(e,r){return this._addCheck({kind:"min",value:e,...m.errToObj(r)})}max(e,r){return this._addCheck({kind:"max",value:e,...m.errToObj(r)})}length(e,r){return this._addCheck({kind:"length",value:e,...m.errToObj(r)})}nonempty(e){return this.min(1,m.errToObj(e))}trim(){return new t({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new t({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new t({...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 r of this._def.checks)r.kind==="min"&&(e===null||r.value>e)&&(e=r.value);return e}get maxLength(){let e=null;for(let r of this._def.checks)r.kind==="max"&&(e===null||r.valuenew K({checks:[],typeName:_.ZodString,coerce:t?.coerce??!1,...v(t)});function dr(t,e){let r=(t.toString().split(".")[1]||"").length,n=(e.toString().split(".")[1]||"").length,s=r>n?r:n,a=Number.parseInt(t.toFixed(s).replace(".","")),i=Number.parseInt(e.toFixed(s).replace(".",""));return a%i/10**s}var se=class t extends x{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)!==p.number){let a=this._getOrReturnCtx(e);return f(a,{code:l.invalid_type,expected:p.number,received:a.parsedType}),g}let n,s=new C;for(let a of this._def.checks)a.kind==="int"?k.isInteger(e.data)||(n=this._getOrReturnCtx(e,n),f(n,{code:l.invalid_type,expected:"integer",received:"float",message:a.message}),s.dirty()):a.kind==="min"?(a.inclusive?e.dataa.value:e.data>=a.value)&&(n=this._getOrReturnCtx(e,n),f(n,{code:l.too_big,maximum:a.value,type:"number",inclusive:a.inclusive,exact:!1,message:a.message}),s.dirty()):a.kind==="multipleOf"?dr(e.data,a.value)!==0&&(n=this._getOrReturnCtx(e,n),f(n,{code:l.not_multiple_of,multipleOf:a.value,message:a.message}),s.dirty()):a.kind==="finite"?Number.isFinite(e.data)||(n=this._getOrReturnCtx(e,n),f(n,{code:l.not_finite,message:a.message}),s.dirty()):k.assertNever(a);return{status:s.value,value:e.data}}gte(e,r){return this.setLimit("min",e,!0,m.toString(r))}gt(e,r){return this.setLimit("min",e,!1,m.toString(r))}lte(e,r){return this.setLimit("max",e,!0,m.toString(r))}lt(e,r){return this.setLimit("max",e,!1,m.toString(r))}setLimit(e,r,n,s){return new t({...this._def,checks:[...this._def.checks,{kind:e,value:r,inclusive:n,message:m.toString(s)}]})}_addCheck(e){return new t({...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,r){return this._addCheck({kind:"multipleOf",value:e,message:m.toString(r)})}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 r of this._def.checks)r.kind==="min"&&(e===null||r.value>e)&&(e=r.value);return e}get maxValue(){let e=null;for(let r of this._def.checks)r.kind==="max"&&(e===null||r.valuee.kind==="int"||e.kind==="multipleOf"&&k.isInteger(e.value))}get isFinite(){let e=null,r=null;for(let n of this._def.checks){if(n.kind==="finite"||n.kind==="int"||n.kind==="multipleOf")return!0;n.kind==="min"?(r===null||n.value>r)&&(r=n.value):n.kind==="max"&&(e===null||n.valuenew se({checks:[],typeName:_.ZodNumber,coerce:t?.coerce||!1,...v(t)});var ae=class t extends x{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)!==p.bigint)return this._getInvalidInput(e);let n,s=new C;for(let a of this._def.checks)a.kind==="min"?(a.inclusive?e.dataa.value:e.data>=a.value)&&(n=this._getOrReturnCtx(e,n),f(n,{code:l.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),f(n,{code:l.not_multiple_of,multipleOf:a.value,message:a.message}),s.dirty()):k.assertNever(a);return{status:s.value,value:e.data}}_getInvalidInput(e){let r=this._getOrReturnCtx(e);return f(r,{code:l.invalid_type,expected:p.bigint,received:r.parsedType}),g}gte(e,r){return this.setLimit("min",e,!0,m.toString(r))}gt(e,r){return this.setLimit("min",e,!1,m.toString(r))}lte(e,r){return this.setLimit("max",e,!0,m.toString(r))}lt(e,r){return this.setLimit("max",e,!1,m.toString(r))}setLimit(e,r,n,s){return new t({...this._def,checks:[...this._def.checks,{kind:e,value:r,inclusive:n,message:m.toString(s)}]})}_addCheck(e){return new t({...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,r){return this._addCheck({kind:"multipleOf",value:e,message:m.toString(r)})}get minValue(){let e=null;for(let r of this._def.checks)r.kind==="min"&&(e===null||r.value>e)&&(e=r.value);return e}get maxValue(){let e=null;for(let r of this._def.checks)r.kind==="max"&&(e===null||r.valuenew ae({checks:[],typeName:_.ZodBigInt,coerce:t?.coerce??!1,...v(t)});var ie=class extends x{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==p.boolean){let n=this._getOrReturnCtx(e);return f(n,{code:l.invalid_type,expected:p.boolean,received:n.parsedType}),g}return E(e.data)}};ie.create=t=>new ie({typeName:_.ZodBoolean,coerce:t?.coerce||!1,...v(t)});var oe=class t extends x{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==p.date){let a=this._getOrReturnCtx(e);return f(a,{code:l.invalid_type,expected:p.date,received:a.parsedType}),g}if(Number.isNaN(e.data.getTime())){let a=this._getOrReturnCtx(e);return f(a,{code:l.invalid_date}),g}let n=new C,s;for(let a of this._def.checks)a.kind==="min"?e.data.getTime()a.value&&(s=this._getOrReturnCtx(e,s),f(s,{code:l.too_big,message:a.message,inclusive:!0,exact:!1,maximum:a.value,type:"date"}),n.dirty()):k.assertNever(a);return{status:n.value,value:new Date(e.data.getTime())}}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}min(e,r){return this._addCheck({kind:"min",value:e.getTime(),message:m.toString(r)})}max(e,r){return this._addCheck({kind:"max",value:e.getTime(),message:m.toString(r)})}get minDate(){let e=null;for(let r of this._def.checks)r.kind==="min"&&(e===null||r.value>e)&&(e=r.value);return e!=null?new Date(e):null}get maxDate(){let e=null;for(let r of this._def.checks)r.kind==="max"&&(e===null||r.valuenew oe({checks:[],coerce:t?.coerce||!1,typeName:_.ZodDate,...v(t)});var Oe=class extends x{_parse(e){if(this._getType(e)!==p.symbol){let n=this._getOrReturnCtx(e);return f(n,{code:l.invalid_type,expected:p.symbol,received:n.parsedType}),g}return E(e.data)}};Oe.create=t=>new Oe({typeName:_.ZodSymbol,...v(t)});var ce=class extends x{_parse(e){if(this._getType(e)!==p.undefined){let n=this._getOrReturnCtx(e);return f(n,{code:l.invalid_type,expected:p.undefined,received:n.parsedType}),g}return E(e.data)}};ce.create=t=>new ce({typeName:_.ZodUndefined,...v(t)});var ue=class extends x{_parse(e){if(this._getType(e)!==p.null){let n=this._getOrReturnCtx(e);return f(n,{code:l.invalid_type,expected:p.null,received:n.parsedType}),g}return E(e.data)}};ue.create=t=>new ue({typeName:_.ZodNull,...v(t)});var X=class extends x{constructor(){super(...arguments),this._any=!0}_parse(e){return E(e.data)}};X.create=t=>new X({typeName:_.ZodAny,...v(t)});var H=class extends x{constructor(){super(...arguments),this._unknown=!0}_parse(e){return E(e.data)}};H.create=t=>new H({typeName:_.ZodUnknown,...v(t)});var L=class extends x{_parse(e){let r=this._getOrReturnCtx(e);return f(r,{code:l.invalid_type,expected:p.never,received:r.parsedType}),g}};L.create=t=>new L({typeName:_.ZodNever,...v(t)});var Te=class extends x{_parse(e){if(this._getType(e)!==p.undefined){let n=this._getOrReturnCtx(e);return f(n,{code:l.invalid_type,expected:p.void,received:n.parsedType}),g}return E(e.data)}};Te.create=t=>new Te({typeName:_.ZodVoid,...v(t)});var G=class t extends x{_parse(e){let{ctx:r,status:n}=this._processInputParams(e),s=this._def;if(r.parsedType!==p.array)return f(r,{code:l.invalid_type,expected:p.array,received:r.parsedType}),g;if(s.exactLength!==null){let i=r.data.length>s.exactLength.value,o=r.data.lengths.maxLength.value&&(f(r,{code:l.too_big,maximum:s.maxLength.value,type:"array",inclusive:!0,exact:!1,message:s.maxLength.message}),n.dirty()),r.common.async)return Promise.all([...r.data].map((i,o)=>s.type._parseAsync(new Z(r,i,r.path,o)))).then(i=>C.mergeArray(n,i));let a=[...r.data].map((i,o)=>s.type._parseSync(new Z(r,i,r.path,o)));return C.mergeArray(n,a)}get element(){return this._def.type}min(e,r){return new t({...this._def,minLength:{value:e,message:m.toString(r)}})}max(e,r){return new t({...this._def,maxLength:{value:e,message:m.toString(r)}})}length(e,r){return new t({...this._def,exactLength:{value:e,message:m.toString(r)}})}nonempty(e){return this.min(1,e)}};G.create=(t,e)=>new G({type:t,minLength:null,maxLength:null,exactLength:null,typeName:_.ZodArray,...v(e)});function we(t){if(t instanceof N){let e={};for(let r in t.shape){let n=t.shape[r];e[r]=$.create(we(n))}return new N({...t._def,shape:()=>e})}else return t instanceof G?new G({...t._def,type:we(t.element)}):t instanceof $?$.create(we(t.unwrap())):t instanceof q?q.create(we(t.unwrap())):t instanceof U?U.create(t.items.map(e=>we(e))):t}var N=class t extends x{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(),r=k.objectKeys(e);return this._cached={shape:e,keys:r},this._cached}_parse(e){if(this._getType(e)!==p.object){let u=this._getOrReturnCtx(e);return f(u,{code:l.invalid_type,expected:p.object,received:u.parsedType}),g}let{status:n,ctx:s}=this._processInputParams(e),{shape:a,keys:i}=this._getCached(),o=[];if(!(this._def.catchall instanceof L&&this._def.unknownKeys==="strip"))for(let u in s.data)i.includes(u)||o.push(u);let c=[];for(let u of i){let h=a[u],w=s.data[u];c.push({key:{status:"valid",value:u},value:h._parse(new Z(s,w,s.path,u)),alwaysSet:u in s.data})}if(this._def.catchall instanceof L){let u=this._def.unknownKeys;if(u==="passthrough")for(let h of o)c.push({key:{status:"valid",value:h},value:{status:"valid",value:s.data[h]}});else if(u==="strict")o.length>0&&(f(s,{code:l.unrecognized_keys,keys:o}),n.dirty());else if(u!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{let u=this._def.catchall;for(let h of o){let w=s.data[h];c.push({key:{status:"valid",value:h},value:u._parse(new Z(s,w,s.path,h)),alwaysSet:h in s.data})}}return s.common.async?Promise.resolve().then(async()=>{let u=[];for(let h of c){let w=await h.key,V=await h.value;u.push({key:w,value:V,alwaysSet:h.alwaysSet})}return u}).then(u=>C.mergeObjectSync(n,u)):C.mergeObjectSync(n,c)}get shape(){return this._def.shape()}strict(e){return m.errToObj,new t({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(r,n)=>{let s=this._def.errorMap?.(r,n).message??n.defaultError;return r.code==="unrecognized_keys"?{message:m.errToObj(e).message??s}:{message:s}}}:{}})}strip(){return new t({...this._def,unknownKeys:"strip"})}passthrough(){return new t({...this._def,unknownKeys:"passthrough"})}extend(e){return new t({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new t({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:_.ZodObject})}setKey(e,r){return this.augment({[e]:r})}catchall(e){return new t({...this._def,catchall:e})}pick(e){let r={};for(let n of k.objectKeys(e))e[n]&&this.shape[n]&&(r[n]=this.shape[n]);return new t({...this._def,shape:()=>r})}omit(e){let r={};for(let n of k.objectKeys(this.shape))e[n]||(r[n]=this.shape[n]);return new t({...this._def,shape:()=>r})}deepPartial(){return we(this)}partial(e){let r={};for(let n of k.objectKeys(this.shape)){let s=this.shape[n];e&&!e[n]?r[n]=s:r[n]=s.optional()}return new t({...this._def,shape:()=>r})}required(e){let r={};for(let n of k.objectKeys(this.shape))if(e&&!e[n])r[n]=this.shape[n];else{let a=this.shape[n];for(;a instanceof $;)a=a._def.innerType;r[n]=a}return new t({...this._def,shape:()=>r})}keyof(){return lt(k.objectKeys(this.shape))}};N.create=(t,e)=>new N({shape:()=>t,unknownKeys:"strip",catchall:L.create(),typeName:_.ZodObject,...v(e)});N.strictCreate=(t,e)=>new N({shape:()=>t,unknownKeys:"strict",catchall:L.create(),typeName:_.ZodObject,...v(e)});N.lazycreate=(t,e)=>new N({shape:t,unknownKeys:"strip",catchall:L.create(),typeName:_.ZodObject,...v(e)});var de=class extends x{_parse(e){let{ctx:r}=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 r.common.issues.push(...o.ctx.common.issues),o.result;let i=a.map(o=>new j(o.ctx.common.issues));return f(r,{code:l.invalid_union,unionErrors:i}),g}if(r.common.async)return Promise.all(n.map(async a=>{let i={...r,common:{...r.common,issues:[]},parent:null};return{result:await a._parseAsync({data:r.data,path:r.path,parent:i}),ctx:i}})).then(s);{let a,i=[];for(let c of n){let u={...r,common:{...r.common,issues:[]},parent:null},h=c._parseSync({data:r.data,path:r.path,parent:u});if(h.status==="valid")return h;h.status==="dirty"&&!a&&(a={result:h,ctx:u}),u.common.issues.length&&i.push(u.common.issues)}if(a)return r.common.issues.push(...a.ctx.common.issues),a.result;let o=i.map(c=>new j(c));return f(r,{code:l.invalid_union,unionErrors:o}),g}}get options(){return this._def.options}};de.create=(t,e)=>new de({options:t,typeName:_.ZodUnion,...v(e)});var W=t=>t instanceof fe?W(t.schema):t instanceof z?W(t.innerType()):t instanceof pe?[t.value]:t instanceof me?t.options:t instanceof he?k.objectValues(t.enum):t instanceof ge?W(t._def.innerType):t instanceof ce?[void 0]:t instanceof ue?[null]:t instanceof $?[void 0,...W(t.unwrap())]:t instanceof q?[null,...W(t.unwrap())]:t instanceof Ne||t instanceof _e?W(t.unwrap()):t instanceof ye?W(t._def.innerType):[],Ze=class t extends x{_parse(e){let{ctx:r}=this._processInputParams(e);if(r.parsedType!==p.object)return f(r,{code:l.invalid_type,expected:p.object,received:r.parsedType}),g;let n=this.discriminator,s=r.data[n],a=this.optionsMap.get(s);return a?r.common.async?a._parseAsync({data:r.data,path:r.path,parent:r}):a._parseSync({data:r.data,path:r.path,parent:r}):(f(r,{code:l.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,r,n){let s=new Map;for(let a of r){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 t({typeName:_.ZodDiscriminatedUnion,discriminator:e,options:r,optionsMap:s,...v(n)})}};function Ge(t,e){let r=B(t),n=B(e);if(t===e)return{valid:!0,data:t};if(r===p.object&&n===p.object){let s=k.objectKeys(e),a=k.objectKeys(t).filter(o=>s.indexOf(o)!==-1),i={...t,...e};for(let o of a){let c=Ge(t[o],e[o]);if(!c.valid)return{valid:!1};i[o]=c.data}return{valid:!0,data:i}}else if(r===p.array&&n===p.array){if(t.length!==e.length)return{valid:!1};let s=[];for(let a=0;a{if(Pe(a)||Pe(i))return g;let o=Ge(a.value,i.value);return o.valid?(($e(a)||$e(i))&&r.dirty(),{status:r.value,value:o.data}):(f(n,{code:l.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}))}};le.create=(t,e,r)=>new le({left:t,right:e,typeName:_.ZodIntersection,...v(r)});var U=class t extends x{_parse(e){let{status:r,ctx:n}=this._processInputParams(e);if(n.parsedType!==p.array)return f(n,{code:l.invalid_type,expected:p.array,received:n.parsedType}),g;if(n.data.lengththis._def.items.length&&(f(n,{code:l.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),r.dirty());let a=[...n.data].map((i,o)=>{let c=this._def.items[o]||this._def.rest;return c?c._parse(new Z(n,i,n.path,o)):null}).filter(i=>!!i);return n.common.async?Promise.all(a).then(i=>C.mergeArray(r,i)):C.mergeArray(r,a)}get items(){return this._def.items}rest(e){return new t({...this._def,rest:e})}};U.create=(t,e)=>{if(!Array.isArray(t))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new U({items:t,typeName:_.ZodTuple,rest:null,...v(e)})};var ze=class t extends x{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:r,ctx:n}=this._processInputParams(e);if(n.parsedType!==p.object)return f(n,{code:l.invalid_type,expected:p.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 Z(n,o,n.path,o)),value:i._parse(new Z(n,n.data[o],n.path,o)),alwaysSet:o in n.data});return n.common.async?C.mergeObjectAsync(r,s):C.mergeObjectSync(r,s)}get element(){return this._def.valueType}static create(e,r,n){return r instanceof x?new t({keyType:e,valueType:r,typeName:_.ZodRecord,...v(n)}):new t({keyType:K.create(),valueType:e,typeName:_.ZodRecord,...v(r)})}},Se=class extends x{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:r,ctx:n}=this._processInputParams(e);if(n.parsedType!==p.map)return f(n,{code:l.invalid_type,expected:p.map,received:n.parsedType}),g;let s=this._def.keyType,a=this._def.valueType,i=[...n.data.entries()].map(([o,c],u)=>({key:s._parse(new Z(n,o,n.path,[u,"key"])),value:a._parse(new Z(n,c,n.path,[u,"value"]))}));if(n.common.async){let o=new Map;return Promise.resolve().then(async()=>{for(let c of i){let u=await c.key,h=await c.value;if(u.status==="aborted"||h.status==="aborted")return g;(u.status==="dirty"||h.status==="dirty")&&r.dirty(),o.set(u.value,h.value)}return{status:r.value,value:o}})}else{let o=new Map;for(let c of i){let u=c.key,h=c.value;if(u.status==="aborted"||h.status==="aborted")return g;(u.status==="dirty"||h.status==="dirty")&&r.dirty(),o.set(u.value,h.value)}return{status:r.value,value:o}}}};Se.create=(t,e,r)=>new Se({valueType:e,keyType:t,typeName:_.ZodMap,...v(r)});var Ie=class t extends x{_parse(e){let{status:r,ctx:n}=this._processInputParams(e);if(n.parsedType!==p.set)return f(n,{code:l.invalid_type,expected:p.set,received:n.parsedType}),g;let s=this._def;s.minSize!==null&&n.data.sizes.maxSize.value&&(f(n,{code:l.too_big,maximum:s.maxSize.value,type:"set",inclusive:!0,exact:!1,message:s.maxSize.message}),r.dirty());let a=this._def.valueType;function i(c){let u=new Set;for(let h of c){if(h.status==="aborted")return g;h.status==="dirty"&&r.dirty(),u.add(h.value)}return{status:r.value,value:u}}let o=[...n.data.values()].map((c,u)=>a._parse(new Z(n,c,n.path,u)));return n.common.async?Promise.all(o).then(c=>i(c)):i(o)}min(e,r){return new t({...this._def,minSize:{value:e,message:m.toString(r)}})}max(e,r){return new t({...this._def,maxSize:{value:e,message:m.toString(r)}})}size(e,r){return this.min(e,r).max(e,r)}nonempty(e){return this.min(1,e)}};Ie.create=(t,e)=>new Ie({valueType:t,minSize:null,maxSize:null,typeName:_.ZodSet,...v(e)});var Le=class t extends x{constructor(){super(...arguments),this.validate=this.implement}_parse(e){let{ctx:r}=this._processInputParams(e);if(r.parsedType!==p.function)return f(r,{code:l.invalid_type,expected:p.function,received:r.parsedType}),g;function n(o,c){return je({data:o,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,ke(),F].filter(u=>!!u),issueData:{code:l.invalid_arguments,argumentsError:c}})}function s(o,c){return je({data:o,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,ke(),F].filter(u=>!!u),issueData:{code:l.invalid_return_type,returnTypeError:c}})}let a={errorMap:r.common.contextualErrorMap},i=r.data;if(this._def.returns instanceof Q){let o=this;return E(async function(...c){let u=new j([]),h=await o._def.args.parseAsync(c,a).catch(P=>{throw u.addIssue(n(c,P)),u}),w=await Reflect.apply(i,this,h);return await o._def.returns._def.type.parseAsync(w,a).catch(P=>{throw u.addIssue(s(w,P)),u})})}else{let o=this;return E(function(...c){let u=o._def.args.safeParse(c,a);if(!u.success)throw new j([n(c,u.error)]);let h=Reflect.apply(i,this,u.data),w=o._def.returns.safeParse(h,a);if(!w.success)throw new j([s(h,w.error)]);return w.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new t({...this._def,args:U.create(e).rest(H.create())})}returns(e){return new t({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,r,n){return new t({args:e||U.create([]).rest(H.create()),returns:r||H.create(),typeName:_.ZodFunction,...v(n)})}},fe=class extends x{get schema(){return this._def.getter()}_parse(e){let{ctx:r}=this._processInputParams(e);return this._def.getter()._parse({data:r.data,path:r.path,parent:r})}};fe.create=(t,e)=>new fe({getter:t,typeName:_.ZodLazy,...v(e)});var pe=class extends x{_parse(e){if(e.data!==this._def.value){let r=this._getOrReturnCtx(e);return f(r,{received:r.data,code:l.invalid_literal,expected:this._def.value}),g}return{status:"valid",value:e.data}}get value(){return this._def.value}};pe.create=(t,e)=>new pe({value:t,typeName:_.ZodLiteral,...v(e)});function lt(t,e){return new me({values:t,typeName:_.ZodEnum,...v(e)})}var me=class t extends x{_parse(e){if(typeof e.data!="string"){let r=this._getOrReturnCtx(e),n=this._def.values;return f(r,{expected:k.joinValues(n),received:r.parsedType,code:l.invalid_type}),g}if(this._cache||(this._cache=new Set(this._def.values)),!this._cache.has(e.data)){let r=this._getOrReturnCtx(e),n=this._def.values;return f(r,{received:r.data,code:l.invalid_enum_value,options:n}),g}return E(e.data)}get options(){return this._def.values}get enum(){let e={};for(let r of this._def.values)e[r]=r;return e}get Values(){let e={};for(let r of this._def.values)e[r]=r;return e}get Enum(){let e={};for(let r of this._def.values)e[r]=r;return e}extract(e,r=this._def){return t.create(e,{...this._def,...r})}exclude(e,r=this._def){return t.create(this.options.filter(n=>!e.includes(n)),{...this._def,...r})}};me.create=lt;var he=class extends x{_parse(e){let r=k.getValidEnumValues(this._def.values),n=this._getOrReturnCtx(e);if(n.parsedType!==p.string&&n.parsedType!==p.number){let s=k.objectValues(r);return f(n,{expected:k.joinValues(s),received:n.parsedType,code:l.invalid_type}),g}if(this._cache||(this._cache=new Set(k.getValidEnumValues(this._def.values))),!this._cache.has(e.data)){let s=k.objectValues(r);return f(n,{received:n.data,code:l.invalid_enum_value,options:s}),g}return E(e.data)}get enum(){return this._def.values}};he.create=(t,e)=>new he({values:t,typeName:_.ZodNativeEnum,...v(e)});var Q=class extends x{unwrap(){return this._def.type}_parse(e){let{ctx:r}=this._processInputParams(e);if(r.parsedType!==p.promise&&r.common.async===!1)return f(r,{code:l.invalid_type,expected:p.promise,received:r.parsedType}),g;let n=r.parsedType===p.promise?r.data:Promise.resolve(r.data);return E(n.then(s=>this._def.type.parseAsync(s,{path:r.path,errorMap:r.common.contextualErrorMap})))}};Q.create=(t,e)=>new Q({type:t,typeName:_.ZodPromise,...v(e)});var z=class extends x{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===_.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){let{status:r,ctx:n}=this._processInputParams(e),s=this._def.effect||null,a={addIssue:i=>{f(n,i),i.fatal?r.abort():r.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(r.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"?ne(c.value):r.value==="dirty"?ne(c.value):c});{if(r.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"?ne(o.value):r.value==="dirty"?ne(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"&&r.dirty(),i(o.value),{status:r.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"&&r.dirty(),i(o.value).then(()=>({status:r.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(!Y(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:r.value,value:o}}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(i=>Y(i)?Promise.resolve(s.transform(i.value,a)).then(o=>({status:r.value,value:o})):g);k.assertNever(s)}};z.create=(t,e,r)=>new z({schema:t,typeName:_.ZodEffects,effect:e,...v(r)});z.createWithPreprocess=(t,e,r)=>new z({schema:e,effect:{type:"preprocess",transform:t},typeName:_.ZodEffects,...v(r)});var $=class extends x{_parse(e){return this._getType(e)===p.undefined?E(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};$.create=(t,e)=>new $({innerType:t,typeName:_.ZodOptional,...v(e)});var q=class extends x{_parse(e){return this._getType(e)===p.null?E(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};q.create=(t,e)=>new q({innerType:t,typeName:_.ZodNullable,...v(e)});var ge=class extends x{_parse(e){let{ctx:r}=this._processInputParams(e),n=r.data;return r.parsedType===p.undefined&&(n=this._def.defaultValue()),this._def.innerType._parse({data:n,path:r.path,parent:r})}removeDefault(){return this._def.innerType}};ge.create=(t,e)=>new ge({innerType:t,typeName:_.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...v(e)});var ye=class extends x{_parse(e){let{ctx:r}=this._processInputParams(e),n={...r,common:{...r.common,issues:[]}},s=this._def.innerType._parse({data:n.data,path:n.path,parent:{...n}});return be(s)?s.then(a=>({status:"valid",value:a.status==="valid"?a.value:this._def.catchValue({get error(){return new j(n.common.issues)},input:n.data})})):{status:"valid",value:s.status==="valid"?s.value:this._def.catchValue({get error(){return new j(n.common.issues)},input:n.data})}}removeCatch(){return this._def.innerType}};ye.create=(t,e)=>new ye({innerType:t,typeName:_.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...v(e)});var Re=class extends x{_parse(e){if(this._getType(e)!==p.nan){let n=this._getOrReturnCtx(e);return f(n,{code:l.invalid_type,expected:p.nan,received:n.parsedType}),g}return{status:"valid",value:e.data}}};Re.create=t=>new Re({typeName:_.ZodNaN,...v(t)});var lr=Symbol("zod_brand"),Ne=class extends x{_parse(e){let{ctx:r}=this._processInputParams(e),n=r.data;return this._def.type._parse({data:n,path:r.path,parent:r})}unwrap(){return this._def.type}},Me=class t extends x{_parse(e){let{status:r,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"?(r.dirty(),ne(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"?(r.dirty(),{status:"dirty",value:s.value}):this._def.out._parseSync({data:s.value,path:n.path,parent:n})}}static create(e,r){return new t({in:e,out:r,typeName:_.ZodPipeline})}},_e=class extends x{_parse(e){let r=this._def.innerType._parse(e),n=s=>(Y(s)&&(s.value=Object.freeze(s.value)),s);return be(r)?r.then(s=>n(s)):n(r)}unwrap(){return this._def.innerType}};_e.create=(t,e)=>new _e({innerType:t,typeName:_.ZodReadonly,...v(e)});function ot(t,e){let r=typeof t=="function"?t(e):typeof t=="string"?{message:t}:t;return typeof r=="string"?{message:r}:r}function ft(t,e={},r){return t?X.create().superRefine((n,s)=>{let a=t(n);if(a instanceof Promise)return a.then(i=>{if(!i){let o=ot(e,n),c=o.fatal??r??!0;s.addIssue({code:"custom",...o,fatal:c})}});if(!a){let i=ot(e,n),o=i.fatal??r??!0;s.addIssue({code:"custom",...i,fatal:o})}}):X.create()}var fr={object:N.lazycreate},_;(function(t){t.ZodString="ZodString",t.ZodNumber="ZodNumber",t.ZodNaN="ZodNaN",t.ZodBigInt="ZodBigInt",t.ZodBoolean="ZodBoolean",t.ZodDate="ZodDate",t.ZodSymbol="ZodSymbol",t.ZodUndefined="ZodUndefined",t.ZodNull="ZodNull",t.ZodAny="ZodAny",t.ZodUnknown="ZodUnknown",t.ZodNever="ZodNever",t.ZodVoid="ZodVoid",t.ZodArray="ZodArray",t.ZodObject="ZodObject",t.ZodUnion="ZodUnion",t.ZodDiscriminatedUnion="ZodDiscriminatedUnion",t.ZodIntersection="ZodIntersection",t.ZodTuple="ZodTuple",t.ZodRecord="ZodRecord",t.ZodMap="ZodMap",t.ZodSet="ZodSet",t.ZodFunction="ZodFunction",t.ZodLazy="ZodLazy",t.ZodLiteral="ZodLiteral",t.ZodEnum="ZodEnum",t.ZodEffects="ZodEffects",t.ZodNativeEnum="ZodNativeEnum",t.ZodOptional="ZodOptional",t.ZodNullable="ZodNullable",t.ZodDefault="ZodDefault",t.ZodCatch="ZodCatch",t.ZodPromise="ZodPromise",t.ZodBranded="ZodBranded",t.ZodPipeline="ZodPipeline",t.ZodReadonly="ZodReadonly"})(_||(_={}));var pr=(t,e={message:`Input not instance of ${t.name}`})=>ft(r=>r instanceof t,e),pt=K.create,mt=se.create,mr=Re.create,hr=ae.create,ht=ie.create,gr=oe.create,yr=Oe.create,_r=ce.create,vr=ue.create,xr=X.create,kr=H.create,br=L.create,wr=Te.create,Or=G.create,Tr=N.create,Sr=N.strictCreate,Ir=de.create,Rr=Ze.create,Ar=le.create,Cr=U.create,Er=ze.create,jr=Se.create,Nr=Ie.create,Mr=Le.create,Vr=fe.create,Pr=pe.create,$r=me.create,Zr=he.create,zr=Q.create,Lr=z.create,Dr=$.create,Br=q.create,Ur=z.createWithPreprocess,qr=Me.create,Jr=()=>pt().optional(),Fr=()=>mt().optional(),Wr=()=>ht().optional(),Hr={string:(t=>K.create({...t,coerce:!0})),number:(t=>se.create({...t,coerce:!0})),boolean:(t=>ie.create({...t,coerce:!0})),bigint:(t=>ae.create({...t,coerce:!0})),date:(t=>oe.create({...t,coerce:!0}))};var Gr=g;var Kr=["run-create","run-list","run-show","run-current","run-use","task-create","task-list","task-update","worker-start","worker-show","worker-read","worker-release","send","check","reply","ask","gate-create","gate-list","gate-resolve"],T=class extends Error{constructor(r,n,s,a,i,o,c){super(o);this.code=r;this.operation=n;this.phase=s;this.retrySafety=a;this.recovery=i;this.stderr=c}code;operation;phase;retrySafety;recovery;stderr;name="OrcaAdapterError"},y=d.string().regex(/^[A-Za-z][A-Za-z0-9_-]{0,127}$/),rt=t=>d.string().refine(e=>e===e.normalize("NFC"),"must be NFC-normalized").refine(e=>!e.includes("\0")&&!/[\uD800-\uDFFF]/u.test(e),"contains an invalid code point").refine(e=>Buffer.byteLength(e,"utf8")>=1&&Buffer.byteLength(e,"utf8")<=t),M=rt(16384),D=rt(512),te=rt(256),Ce=d.string().min(1).max(512).regex(/^[\x21-\x7E]+$/).refine(t=>!t.startsWith("-")&&!/[;&|`$<>\\(){}\[\]*?!'\"]/.test(t)),kt=Ce.refine(t=>Buffer.byteLength(t,"utf8")<=128),gt=d.number().int().min(1).max(100),Ye=d.number().int().min(250).max(6e5),Ue=d.enum(["pending","ready","dispatched","completed","failed","blocked"]),bt=d.enum(["pending","resolved"]),Be=d.enum(["status","dispatch","worker_done","merge_ready","escalation","handoff","question","decision_gate","heartbeat"]),Xr=d.enum(["low","normal","high","urgent"]),wt=d.enum(["auto","transcript","terminal"]),Ot=d.enum(["claude","codex","cursor","droid","gemini","grok","opencode"]),Tt=d.enum(["low","medium","high","xhigh"]),ee=(t,e,r=0)=>d.array(t).min(r).max(e).refine(n=>new Set(n).size===n.length,"items must be unique"),St=d.object({summary:M,artifacts:ee(te,32).optional()}).strict().refine(t=>Buffer.byteLength(JSON.stringify(t))<=32768),Qr=d.object({taskId:y.optional(),dispatchId:y.optional(),phase:te.optional(),outcome:d.enum(["succeeded","failed"]).optional(),filesModified:ee(te,128).optional(),reportPath:te.optional()}).strict().refine(t=>Object.keys(t).length>0,"payload must not be empty").refine(t=>Buffer.byteLength(JSON.stringify(t))<=32768),R=(t,e)=>d.object({operation:d.literal(t),...e}).strict(),It=d.union([R("run-create",{objective:M}),R("run-list",{limit:gt.optional(),cursor:Ce.optional()}),R("run-show",{id:y}),R("run-current",{}),R("run-use",{id:y}),R("task-create",{spec:M,title:D.optional(),deps:ee(y,64).optional(),parent:y.optional()}),R("task-list",{status:Ue.optional(),ready:d.boolean().optional(),brief:d.boolean().optional()}),R("task-update",{id:y,status:Ue,result:St.optional()}),R("worker-start",{task:y,agent:Ot,model:kt.optional(),effort:Tt.optional(),timeoutMs:Ye.optional()}).refine(t=>t.effort===void 0||t.model!==void 0,{message:"effort requires model"}),R("worker-show",{dispatch:y}),R("worker-read",{dispatch:y,source:wt.optional(),cursor:Ce.optional(),limit:gt.optional()}),R("worker-release",{dispatch:y}),R("send",{subject:D,body:M.optional(),type:Be.optional(),priority:Xr.optional(),threadId:y.optional(),payload:Qr.optional()}),R("check",{ack:y.optional(),unread:d.boolean().optional(),peek:d.boolean().optional(),all:d.boolean().optional(),types:ee(Be,Be.options.length,1).optional(),wait:d.boolean().optional(),timeoutMs:Ye.optional()}).refine(t=>[t.unread,t.peek,t.all].filter(e=>e===!0).length<=1,{message:"unread, peek, and all are mutually exclusive"}).refine(t=>t.timeoutMs===void 0||t.wait===!0,{message:"timeoutMs requires wait"}),R("reply",{id:y,body:M}),R("ask",{question:D.optional(),resume:y.optional(),options:ee(te,10,1).optional(),timeoutMs:Ye.optional()}).refine(t=>t.question===void 0!=(t.resume===void 0),{message:"exactly one of question or resume is required"}).refine(t=>t.options===void 0||t.question!==void 0,{message:"options require question"}).refine(t=>t.options?.every(e=>!/[,\r\n]/.test(e))??!0,{message:"ask options cannot contain comma, CR, or LF"}),R("gate-create",{task:y,question:D,options:ee(te,10,1).optional()}),R("gate-list",{task:y.optional(),status:bt.optional()}),R("gate-resolve",{id:y,resolution:M,task:y})]);function S(t,e){if(e.length>0&&e[0]==="-")throw new T("invalid_argument","runtime","validate","safe","Correct the rejected semantic value and retry.",`${t} has a flag-shaped value`);return[t,e]}function I(t,e){return e===void 0?[]:S(t,String(e))}function Ae(t,e){return e===!0?[t]:[]}function yt(t){let e=It.safeParse(t);if(!e.success){let s=en(t);throw new T(s===void 0?"invalid_operation":"invalid_argument",s??"runtime","validate","safe","Correct the semantic input and retry.",e.error.issues.map(a=>a.message).join("; "))}let r=e.data,n=tn(r);return Object.freeze(["orchestration",r.operation,...n,"--json"])}function en(t){if(typeof t!="object"||t===null||!("operation"in t))return;let e=t.operation;return Kr.find(r=>r===e)}function tn(t){switch(t.operation){case"run-create":return S("--objective",t.objective);case"run-list":return[...I("--limit",t.limit),...I("--cursor",t.cursor)];case"run-show":case"run-use":return S("--id",t.id);case"run-current":return[];case"task-create":return[...S("--spec",t.spec),...I("--task-title",t.title),...t.deps===void 0?[]:S("--deps",JSON.stringify(t.deps)),...I("--parent",t.parent)];case"task-list":return[...I("--status",t.status),...Ae("--ready",t.ready),...Ae("--brief",t.brief)];case"task-update":return[...S("--id",t.id),...S("--status",t.status),...t.result===void 0?[]:S("--result",JSON.stringify(t.result))];case"worker-start":return[...S("--task",t.task),"--worktree","current",...S("--agent",t.agent),...I("--model",t.model),...I("--effort",t.effort),...I("--timeout-ms",t.timeoutMs)];case"worker-show":case"worker-release":return S("--dispatch",t.dispatch);case"worker-read":return[...S("--dispatch",t.dispatch),...I("--source",t.source),...I("--cursor",t.cursor),...I("--limit",t.limit)];case"send":return[...S("--subject",t.subject),...I("--body",t.body),...I("--type",t.type),...I("--priority",t.priority),...I("--thread-id",t.threadId),...t.payload===void 0?[]:S("--payload",JSON.stringify(t.payload))];case"check":return[...I("--ack",t.ack),...Ae("--unread",t.unread),...Ae("--peek",t.peek),...Ae("--all",t.all),...t.types===void 0?[]:S("--types",t.types.join(",")),...Ae("--wait",t.wait),...I("--timeout-ms",t.timeoutMs)];case"reply":return[...S("--id",t.id),...S("--body",t.body)];case"ask":return[...t.question===void 0?S("--resume",t.resume):S("--question",t.question),...t.options===void 0?[]:S("--options",t.options.join(",")),...I("--timeout-ms",t.timeoutMs)];case"gate-create":return[...S("--task",t.task),...S("--question",t.question),...t.options===void 0?[]:S("--options",JSON.stringify(t.options))];case"gate-list":return[...I("--task",t.task),...I("--status",t.status)];case"gate-resolve":return[...S("--id",t.id),...S("--resolution",t.resolution)]}}function rn(t={}){let e=t.platform??process.platform;if(e==="win32")return"orca.exe";if(e==="darwin")return"orca";if(e==="linux")return t.managedTerminal===!0?"orca":"orca-ide";throw new T("unsupported_platform","runtime","resolve","safe","Run the adapter on a supported Orca host.",`unsupported platform: ${e}`)}var nn=3e4,sn=5e3,an=605e3,on=1048576,cn=65536,un=1e3,dn=1e3;function Rt(t=Yr){return e=>new Promise((r,n)=>{let s=t(e.executable,[...e.argv],{shell:e.shell,env:e.env,stdio:["ignore","pipe","pipe"],windowsHide:!0}),a=[],i=[],o=0,c=0,u=!1,h=!1,w=!1,V=!1,P,J,xe=A=>{u||(u=!0,clearTimeout(st),P!==void 0&&clearTimeout(P),J!==void 0&&clearTimeout(J),r(A))},Je=()=>{s.kill("SIGTERM"),P??=setTimeout(()=>{s.kill("SIGKILL"),J??=setTimeout(()=>xe({exitCode:null,signal:"SIGKILL",stdout:Buffer.concat(a).toString("utf8"),stderr:Buffer.concat(i).toString("utf8"),timedOut:h,outputLimited:w,transportLost:!0}),dn)},un)},st=setTimeout(()=>{h=!0,Je()},e.timeoutMs),Fe=A=>{u||xe({exitCode:null,stdout:Buffer.concat(a).toString("utf8"),stderr:`${Buffer.concat(i).toString("utf8")} +${A}`,timedOut:h,outputLimited:w,transportLost:!0})};s.stdout.on("error",A=>{Fe(`stdout stream error: ${A.message}`)}),s.stderr.on("error",A=>{Fe(`stderr stream error: ${A.message}`)}),s.stdout.on("data",A=>{o+=A.length,o>e.maxStdoutBytes?(w=!0,Je()):a.push(A)}),s.stderr.on("data",A=>{c+=A.length,c>e.maxStderrBytes?(w=!0,Je()):i.push(A)}),s.once("spawn",()=>{V=!0}),s.once("error",A=>{if(!u){if(V){Fe(`process transport error: ${A.message}`);return}u=!0,clearTimeout(st),P!==void 0&&clearTimeout(P),J!==void 0&&clearTimeout(J),n(A)}}),s.once("close",(A,$t)=>{u||xe({exitCode:A,signal:$t,stdout:Buffer.concat(a).toString("utf8"),stderr:Buffer.concat(i).toString("utf8"),timedOut:h,outputLimited:w})})})}var At=Rt(),Ee=y,b=t=>d.object(t).strict(),Ke=b({id:y,objective:M.optional(),coordinatorTerminalHandle:Ee.optional()}),Ve=b({id:y,objective:M,home_database:d.string().min(1).max(128),coordinator_handle:Ee.nullable(),coordinator_pane_key:d.string().min(1).max(256).nullable(),consumer_generation:d.number().int().positive(),legacy:d.number().int().min(0).max(1),created_at:d.string().min(1).max(64),updated_at:d.string().min(1).max(64)}),ln=b({id:y,spec:M,title:D.optional(),deps:ee(y,64).optional(),parent:y.optional(),status:Ue,result:St.optional()}),Xe=b({id:y,run_id:y,parent_id:y.nullable(),created_by_terminal_handle:Ee,created_by_pane_key:d.string().min(1).max(256),created_by_process_incarnation:d.string().min(1).max(512),created_by_run_generation:d.number().int().positive(),task_title:D,display_name:D,spec:M,status:Ue,deps:d.string().max(16384),result:d.string().max(32768).nullable(),created_at:d.string().min(1).max(64),completed_at:d.string().min(1).max(64).nullable()}),De=b({requestId:d.string().uuid(),replayed:d.boolean()}),_t=b({consumerGeneration:d.number().int().positive()}),fn=b({id:y,taskId:y,agent:Ot.optional(),model:kt.optional(),effort:Tt.optional(),state:te.optional(),terminalDisposition:d.enum(["released","retained"]).optional()}),pn=b({id:y,taskId:y,question:D,options:ee(te,10,1).optional(),status:bt,resolution:M.optional()}),vt=b({messageId:y}),mn=d.union([b({messageId:y,state:d.literal("answered"),answer:M}),b({messageId:y,state:d.literal("pending")})]),hn=b({deliveryId:y.optional(),acknowledged:d.boolean().optional(),messages:d.array(b({id:y,type:Be,subject:D})).max(50).optional(),count:d.number().int().min(0).max(50).optional()}),gn={"run-create":d.union([b({runId:y}),b({run:Ve,binding:_t,mutation:De})]),"run-list":b({runs:d.array(d.union([Ke,Ve])).max(100),cursor:Ce.optional(),nextCursor:Ce.nullable().optional()}),"run-show":b({run:d.union([Ke,Ve])}),"run-current":d.union([b({run:Ke,coordinatorTerminalHandle:Ee}),b({run:Ve.nullable()})]),"run-use":d.union([b({runId:y,coordinatorTerminalHandle:Ee}),b({run:Ve,binding:_t,mutation:De})]),"task-create":d.union([b({taskId:y}),b({task:Xe,mutation:De})]),"task-list":d.union([b({tasks:d.array(ln).max(100)}),b({runId:y,legacyReadOnly:d.boolean(),tasks:d.array(Xe).max(100),count:d.number().int().min(0).max(100)})]),"task-update":d.union([b({taskId:y}),b({task:Xe,mutation:De})]),"worker-start":b({dispatchId:y,taskId:y}),"worker-show":b({dispatch:fn}),"worker-read":b({dispatchId:y,source:wt,output:M,cursor:Ce.optional()}),"worker-release":b({dispatchId:y}),send:vt,check:hn,reply:vt,ask:mn,"gate-create":b({gateId:y,taskId:y}),"gate-list":b({gates:d.array(pn).max(100)}),"gate-resolve":b({gateId:y,taskId:y})},yn=d.object({id:d.string().min(1).max(256),ok:d.boolean(),result:d.unknown().optional(),error:d.object({code:d.string().min(1).max(128),message:d.string().min(1).max(4096)}).strict().optional(),_meta:d.object({runtimeId:y,runtimeVersion:D.optional(),version:D.optional(),invokingTerminal:Ee.optional()}).strict().optional()}).strict().refine(t=>t.ok?t.result!==void 0&&t.error===void 0:t.result===void 0&&t.error!==void 0),_n=d.object({id:d.string().min(1).max(256),ok:d.literal(!0),result:d.object({target:d.object({kind:d.literal("local")}).strict(),app:d.object({running:d.literal(!0),pid:d.number().int().positive(),desktopWindowStatus:d.enum(["available","unavailable"])}).strict(),runtime:d.object({state:d.literal("ready"),reachable:d.literal(!0),runtimeId:d.string().min(1).max(256),appVersion:d.string().regex(/^\d+\.\d+\.\d+(?:[-+].*)?$/),remoteUpdateSupport:d.object({installMode:d.string().min(1).max(128),automatic:d.boolean(),reason:d.string().min(1).max(256)}).strict(),capabilities:d.array(d.string().min(1).max(256)).max(256)}).strict(),graph:d.object({state:d.literal("ready")}).strict()}).strict(),_meta:d.object({runtimeId:d.string().min(1).max(256)}).strict()}).strict().refine(t=>t.result.runtime.runtimeId===t._meta.runtimeId,"runtime identity mismatch");function re(t,e,r){return new T("ambiguous_after_possible_commit",t,e,"unrecoverably-ambiguous","Do not retry automatically; inspect the documented public read operation before choosing another mutation.",r)}function vn(t,e,r){let n;try{n=Ct(e)}catch{throw r?re(t,"decode","stdout was not one JSON document"):new T("malformed_json",t,"decode","safe","Inspect Orca health and retry this read-only operation when safe.","stdout was not one JSON document")}let s=yn.safeParse(n);if(!s.success)throw r?re(t,"decode","stdout did not match the Orca envelope contract"):new T("unexpected_response",t,"decode","safe","Use a compatible Orca CLI version.","stdout did not match the Orca envelope contract");if(s.data.ok&&!gn[t].safeParse(s.data.result).success)throw r?re(t,"receipt",`success result did not match the finite ${t} response contract`):new T("unexpected_response",t,"decode","safe","Use a compatible Orca CLI version and inspect the public operation result.",`success result did not match the finite ${t} response contract`);return s.data}function Ct(t){let e=[],r=!1,n=0;for(;n=t.length)throw new Error("unterminated JSON string");if(r){let i=JSON.parse(t.slice(a,n+1)),o=e.at(-1);if(o==null||o.has(i))throw new Error("duplicate JSON key");o.add(i),r=!1}}else s==="{"?(e.push(new Set),r=!0):s==="["?e.push(null):s==="}"||s==="]"?e.pop():s===","&&e.at(-1)instanceof Set&&(r=!0);n+=1}return JSON.parse(t)}var Qe=new Set(["run-create","run-use","task-create","task-update","worker-start","worker-release","send","reply","ask","gate-create","gate-resolve"]);function et(t,e){return t==="check"&&typeof e=="object"&&e!==null&&"ack"in e}function O(t){return typeof t!="object"||t===null||Array.isArray(t)?{}:t}function ve(t,e){let r=O(t)[e];return typeof r=="object"&&r!==null?O(r).id:void 0}function xn(t,e){let r=O(e);if(t==="run-create"||t==="run-use"){let s=r.runId??ve(r,"run");return Object.freeze(typeof s=="string"?{runId:s}:{})}if(t==="task-create"||t==="task-update"){let s=r.taskId??ve(r,"task");return Object.freeze(typeof s=="string"?{taskId:s}:{})}return Object.freeze(Object.fromEntries(({"run-create":["runId"],"run-use":["runId"],"task-create":["taskId"],"task-update":["taskId"],"worker-start":["dispatchId","taskId"],"worker-release":["dispatchId"],send:["messageId"],reply:["messageId"],ask:["messageId"],check:["deliveryId"],"gate-create":["gateId","taskId"],"gate-resolve":["gateId","taskId"]}[t]??[]).flatMap(s=>typeof r[s]=="string"?[[s,r[s]]]:[])))}function kn(t,e){if(t.operation==="run-use"){let r=O(e),n=r.runId??ve(r,"run");return{operation:{operation:"run-current"},matches:s=>{let a=O(s);if(a.run===null||a.run===void 0)return!1;let i=O(a.run);return n===t.id&&i.id===t.id}}}if(t.operation==="gate-resolve"){let r=O(e);return{operation:{operation:"gate-list",task:t.task},matches:n=>{if(r.gateId!==t.id||r.taskId!==t.task)return!1;let s=O(n).gates;if(!Array.isArray(s))return!1;let a=s.map(O).filter(i=>i.id===t.id);return a.length===1&&a[0].taskId===t.task&&a[0].status==="resolved"&&a[0].resolution===t.resolution}}}if(t.operation==="worker-release"){let r=O(e);return{operation:{operation:"worker-show",dispatch:t.dispatch},matches:n=>{let s=O(O(n).dispatch);return r.dispatchId===t.dispatch&&s.id===t.dispatch&&["released","retained"].includes(String(s.terminalDisposition))}}}if(t.operation==="run-create"){let r=O(e),n=r.runId??ve(r,"run");return{operation:{operation:"run-show",id:String(n)},matches:s=>{let a=O(O(s).run);return a.id===n&&a.objective===t.objective}}}if(t.operation==="task-create"||t.operation==="task-update"){let r=O(e),n=r.taskId??ve(r,"task"),s=t.operation==="task-create"?n:t.id;return{operation:{operation:"task-list"},matches:a=>{if(n!==s)return!1;let i=O(a).tasks;if(!Array.isArray(i))return!1;let o=i.map(O).filter(u=>u.id===s);if(o.length!==1)return!1;let c=o[0];return t.operation==="task-create"&&"run_id"in c?c.spec===t.spec&&c.task_title===(t.title??t.spec)&&c.deps===JSON.stringify(t.deps??[])&&c.parent_id===(t.parent??null):t.operation==="task-create"?c.spec===t.spec&&c.title===t.title&&JSON.stringify(c.deps??[])===JSON.stringify(t.deps??[])&&c.parent===t.parent:c.status===t.status&&bn(c.result,t.result)}}}if(t.operation==="worker-start"){let r=O(e),n=r.dispatchId;return{operation:{operation:"worker-show",dispatch:String(n)},matches:s=>{let a=O(O(s).dispatch);return r.taskId===t.task&&a.id===n&&a.taskId===t.task&&a.agent===t.agent&&a.model===t.model&&a.effort===t.effort}}}if(t.operation==="gate-create"){let r=O(e),n=r.gateId;return{operation:{operation:"gate-list",task:t.task},matches:s=>{let a=O(s).gates;if(!Array.isArray(a)||r.taskId!==t.task)return!1;let i=a.map(O).filter(c=>c.id===n);if(i.length!==1)return!1;let o=i[0];return o?.taskId===t.task&&o.question===t.question&&JSON.stringify(o.options)===JSON.stringify(t.options)}}}}function bn(t,e){return e===void 0?!0:JSON.stringify(t)===JSON.stringify(e)||t===JSON.stringify(e)}function wn(t,e,r){let n=et(t,e),s=Qe.has(t)||n;if(r.outputLimited||r.transportLost)return s?re(t,"execute",r.outputLimited?"Orca output exceeded the adapter limit":"Orca transport closed before a valid response"):xt(t,r.outputLimited?"output_limit":"process_exit",r.outputLimited?"Orca output exceeded the adapter limit":"Orca transport closed before a valid response");if(r.timedOut)return s?re(t,"execute","Orca did not finish before the deadline"):xt(t,"timeout","Orca did not finish before the deadline");if(r.exitCode!==0)return s?new T("ambiguous_after_possible_commit",t,"execute","unrecoverably-ambiguous","Do not retry automatically; inspect the documented public read operation before choosing another mutation.",`Orca exited with status ${r.exitCode??"signal"}`,r.stderr):new T("process_exit",t,"execute",s?"readback-required":"safe","Inspect Orca state and use the documented recovery operation.",`Orca exited with status ${r.exitCode??"signal"}`,r.stderr.slice(-4096))}function xt(t,e,r){return new T(e,t,"execute","safe","Retry the read-only operation when Orca is healthy.",r)}function On(t,e){return t===void 0?e:Math.min(an,Math.max(e,t+sn))}function Et(t={}){let e=Object.freeze({...t.env??process.env}),r=rn({platform:t.platform,managedTerminal:t.managedTerminal??e.TERM_PROGRAM==="Orca"}),n=t.executor??At,s=t.timeoutMs??nn,a=t.now??(()=>new Date),i=async(c,u,h=s)=>{try{return await n({executable:r,argv:c,shell:!1,timeoutMs:h,maxStdoutBytes:on,maxStderrBytes:cn,env:e})}catch(w){throw new T("executable_unavailable",u,"resolve","safe","Verify that the deterministic Orca executable is installed and available, then retry.",w instanceof Error&&"code"in w?`Orca execution failed (${String(w.code)})`:"Orca execution failed")}},o=async c=>{let u=yt(c),h="timeoutMs"in c?c.timeoutMs:void 0,w=await i(u,c.operation,On(h,s));w={...w,stderr:An(w.stderr,c,e)};let V=Qe.has(c.operation)||et(c.operation,c),P=wn(c.operation,c,w);if(P!==void 0)throw P;let J=vn(c.operation,w.stdout,V);if(!J.ok){let xe=nt(J.error?.message??"Orca returned an error envelope",c,e);throw V?re(c.operation,"decode",xe):new T("unexpected_response",c.operation,"decode",V?"readback-required":"safe","Follow the public Orca diagnostic and inspect state before retrying.",xe)}return J};return Object.freeze({executable:r,async status(){let c=await i(["status","--json"],"runtime");if(c.outputLimited||c.transportLost||c.timedOut||c.exitCode!==0)throw new T(c.outputLimited?"output_limit":c.timedOut?"timeout":"process_exit","runtime","execute","safe","Restore the public Orca runtime and retry the compatibility probe.","Orca status did not complete successfully");let u;try{u=Ct(c.stdout)}catch{throw new T("malformed_json","runtime","decode","safe","Use a compatible Orca CLI version.","Orca status was not one JSON document")}let h=_n.safeParse(u);if(!h.success)throw new T("unexpected_response","runtime","decode","safe","Use a compatible Orca CLI version.","Orca status did not match the strict runtime compatibility contract");return h.data},async execute(c){let u=It.safeParse(c);if(!u.success)throw yt(c),new Error("unreachable");let h=u.data,w=a().toISOString(),V=await o(h);return!Qe.has(h.operation)&&!et(h.operation,h)?V:Tn(h,V,w,o,a,e)}})}async function Tn(t,e,r,n,s,a){In(t,e);let i=kn(t,e.result);if(i!==void 0){let u;try{u=await n(i.operation)}catch(h){throw Sn(t,i.operation.operation,h,a)}if(!i.matches(u.result))throw new T("readback_mismatch",t.operation,"readback","unsafe",`Inspect state with orchestration ${i.operation.operation}; do not retry the mutation automatically.`,`${i.operation.operation} disagreed with the mutation receipt`)}let o=e._meta,c=Object.freeze({verb:t.operation,ids:xn(t.operation,e.result),runtimeId:o.runtimeId,runtimeVersion:o.runtimeVersion??null,startedAt:r,completedAt:s().toISOString(),readbackVerb:i?.operation.operation??null});return Object.freeze({...e,receipt:c})}function Sn(t,e,r,n){return r instanceof T?new T(r.code,t.operation,"readback","readback-required",`Repeat or inspect orchestration ${e}; do not retry the mutation automatically.`,nt(`${e} failed after Orca returned a valid mutation receipt: ${r.message}`,t,n),r.stderr):new T("unexpected_response",t.operation,"readback","unrecoverably-ambiguous",`Inspect state with orchestration ${e}; do not retry the mutation automatically.`,`${e} failed after Orca returned a valid mutation receipt`)}function In(t,e){if(e._meta?.runtimeId===void 0)throw re(t.operation,"receipt","mutation receipt omitted bounded runtime identity metadata");if(!Rn(t,e.result))throw new T("readback_mismatch",t.operation,"receipt","unsafe","Inspect the requested entity with its documented public read operation; do not retry automatically.","mutation receipt identity disagreed with the requested entity");if(t.operation==="check"&&t.ack!==void 0&&O(e.result).acknowledged!==!0)throw re(t.operation,"receipt","check --ack success did not contain its matching delivery identifier");if(t.operation==="run-use"&&"coordinatorTerminalHandle"in O(e.result)&&O(e.result).coordinatorTerminalHandle!==e._meta.invokingTerminal)throw new T("readback_mismatch",t.operation,"readback","unsafe","Inspect orchestration run-current; do not retry run-use automatically.","run-use terminal binding was not runtime-attested")}function Rn(t,e){let r=O(e);switch(t.operation){case"run-use":return(r.runId??ve(r,"run"))===t.id;case"task-update":return(r.taskId??ve(r,"task"))===t.id;case"worker-start":return r.taskId===t.task;case"worker-release":return r.dispatchId===t.dispatch;case"reply":return r.messageId===t.id;case"ask":return t.resume===void 0||r.messageId===t.resume;case"check":return t.ack===void 0||r.deliveryId===t.ack;case"gate-create":return r.taskId===t.task;case"gate-resolve":return r.gateId===t.id&&r.taskId===t.task;default:return!0}}function An(t,e,r){return nt(t,e,r)}function nt(t,e,r){let n=[...t].filter(c=>{let u=c.charCodeAt(0);return u===9||u===10||u===13||u>=32&&u!==127&&u<128||u>159}).join(""),s=tt(e),a=Object.entries(r).filter(([c,u])=>u!==void 0&&/(?:TOKEN|SECRET|PASSWORD|PASS|KEY|CREDENTIAL|AUTH|COOKIE)/i.test(c)).map(([,c])=>c),i=Object.values(r).flatMap(c=>c===void 0?[]:Cn(c));for(let c of[...s,...a,...i].filter(u=>u.length>=3).sort((u,h)=>h.length-u.length))n=n.split(c).join("[REDACTED]");let o=Buffer.from(n,"utf8");return o.length<=4096?n:Buffer.concat([Buffer.from("[truncated] "),o.subarray(o.length-4084)]).toString("utf8")}function Cn(t){try{let e=new URL(t);if(e.password.length===0)return[];try{return[e.password,decodeURIComponent(e.password)]}catch{return[e.password]}}catch{return[]}}function tt(t){return typeof t=="string"?[t]:Array.isArray(t)?t.flatMap(tt):typeof t=="object"&&t!==null?Object.values(t).flatMap(tt):[]}function qe(){return Et()}var ls=Object.freeze({createAdapter:Et,createOrcaProcessExecutor:Rt,spawnOrcaProcess:At});var En="1.4.192",jt="orchestration.contract.v1";function Nt(t){return new T("unsupported_environment","runtime","resolve","safe","Run this plugin in a supported Orca host with the public orchestration contract and child-process access.",t)}function Mt(t){let e=/^(\d+)\.(\d+)\.(\d+)(?:-([0-9A-Za-z.-]+))?(?:\+[0-9A-Za-z.-]+)?$/.exec(t);if(e!==null)return{release:[Number(e[1]),Number(e[2]),Number(e[3])],prerelease:e[4]===void 0?[]:e[4].split(".")}}function jn(t,e){if(t.length===0||e.length===0)return e.length-t.length;for(let r=0;rn.release[s];return jn(r.prerelease,n.prerelease)>=0}async function Vt(t){try{let e=await t.status(),r=e.result.runtime.runtimeId,n=e.result.runtime.appVersion;if(!Nn(n,En)||!e.result.runtime.capabilities.includes(jt))throw Nt("Orca runtime version or orchestration contract is outside the supported range.");return Object.freeze({runtimeId:r,runtimeVersion:n,contract:jt})}catch(e){throw e instanceof T&&e.code==="unsupported_environment"?e:Nt("The Orca compatibility probe could not complete through the public adapter.")}}function Pt(t=qe()){return Object.freeze({probe:()=>Vt(t),async execute(e){return await Vt(t),t.execute(e)}})}var Mn="genie.orca.run-list";function Vn(t=qe()){let e=Pt(t);return async r=>{r.commands.register(Mn,()=>e.execute({operation:"run-list",limit:100}))}}var ys=Vn();export{Mn as ORCA_RUN_LIST_COMMAND,Vn as createOrcaPluginEntrypoint,ys as default}; diff --git a/plugins/genie/orca-real-runtime-smoke.test.ts b/plugins/genie/orca-real-runtime-smoke.test.ts index c8f471c9b..3585d09aa 100644 --- a/plugins/genie/orca-real-runtime-smoke.test.ts +++ b/plugins/genie/orca-real-runtime-smoke.test.ts @@ -66,8 +66,11 @@ runRealSmoke( return; } + // A terminal that is not bound to a Run reads back `run: null`; the smoke + // must not dereference it — there is simply nothing to restore afterwards. const prior = await runtime.execute({ operation: 'run-current' }); - const priorRunId = String(object(object(prior.result).run).id); + const priorRun = object(prior.result).run; + const priorRunId = priorRun === null || priorRun === undefined ? null : String(object(priorRun).id); const suffix = randomUUID().replaceAll('-', '').slice(0, 12); let disposableTaskId: string | undefined; @@ -94,12 +97,14 @@ runRealSmoke( tasks.some((task) => object(task).id === disposableTaskId && object(task).status === 'completed'), ).toBe(true); } finally { - await runtime.execute({ operation: 'run-use', id: priorRunId }); + if (priorRunId !== null) await runtime.execute({ operation: 'run-use', id: priorRunId }); } expect(disposableTaskId).toBeDefined(); - const restored = await runtime.execute({ operation: 'run-current' }); - expect(object(object(restored.result).run).id).toBe(priorRunId); + if (priorRunId !== null) { + const restored = await runtime.execute({ operation: 'run-current' }); + expect(object(object(restored.result).run).id).toBe(priorRunId); + } expect(await snapshotLocalLifecycle()).toEqual(before); }, 30_000, diff --git a/src/lib/orca-orchestration-adapter.test.ts b/src/lib/orca-orchestration-adapter.test.ts index 71d3695ff..b33c5ad70 100644 --- a/src/lib/orca-orchestration-adapter.test.ts +++ b/src/lib/orca-orchestration-adapter.test.ts @@ -279,6 +279,45 @@ describe('runtime and executor boundary', () => { ]); }); + test('decodes the real Orca 1.4.192 run-list page (unbound coordinators, nextCursor null)', async () => { + // Captured from `orca orchestration run-list --json --limit 5` against a live + // 1.4.192 runtime on 2026-08-30: runs whose coordinator terminal is gone list + // with null coordinator fields, and the page carries `nextCursor`, not `cursor`. + const realRun = (id: string, bound: boolean) => ({ + id, + objective: 'Genie A3 disposable smoke 6b2dacf88b03', + home_database: 'this_database', + coordinator_handle: bound ? 'term_9479beab-e0e3-4ccd-8f4e-3a6374c293c1' : null, + coordinator_pane_key: bound ? 'e1dd5d83-902f-4170-a054-360834ff6bc2:b7b71158-894b-4235-a996-775f998c12d6' : null, + consumer_generation: 2, + legacy: 0, + created_at: '2026-08-29T20:38:02Z', + updated_at: '2026-08-29T20:38:07Z', + }); + const page = { runs: [realRun('run_ca7f3f1c6a2d', false), realRun('run_4f9c0796c24a', true)], nextCursor: null }; + const adapter = __orcaAdapterTestOnly.createAdapter({ + executor: async () => ({ + exitCode: 0, + stdout: JSON.stringify({ id: 'req_1', ok: true, result: page, _meta: { runtimeId: 'rt_1' } }), + stderr: '', + }), + }); + const response = await adapter.execute({ operation: 'run-list', limit: 5 }); + expect((response.result as { runs: unknown[] }).runs).toHaveLength(2); + }); + + test('decodes an unbound terminal run-current (run: null) as a valid empty binding', async () => { + const adapter = __orcaAdapterTestOnly.createAdapter({ + executor: async () => ({ + exitCode: 0, + stdout: JSON.stringify({ id: 'req_2', ok: true, result: { run: null }, _meta: { runtimeId: 'rt_1' } }), + stderr: '', + }), + }); + const response = await adapter.execute({ operation: 'run-current' }); + expect((response.result as { run: unknown }).run).toBeNull(); + }); + test('requires one strict success envelope', async () => { for (const stdout of ['', '{}', '{"id":"x","ok":true}', '{"id":"x","ok":true,"result":{},"extra":1}', '{}\n{}']) { const adapter = __orcaAdapterTestOnly.createAdapter({ diff --git a/src/lib/orca-orchestration-adapter.ts b/src/lib/orca-orchestration-adapter.ts index f4ee5229a..9779bc70c 100644 --- a/src/lib/orca-orchestration-adapter.ts +++ b/src/lib/orca-orchestration-adapter.ts @@ -529,8 +529,10 @@ const publicRunEntity = receipt({ id, objective: longText, home_database: z.string().min(1).max(128), - coordinator_handle: terminalId, - coordinator_pane_key: z.string().min(1).max(256), + // A Run whose coordinator terminal has gone away (or that was never bound + // from a terminal) lists with null coordinator fields on real Orca 1.4.192. + coordinator_handle: terminalId.nullable(), + coordinator_pane_key: z.string().min(1).max(256).nullable(), consumer_generation: z.number().int().positive(), legacy: z.number().int().min(0).max(1), created_at: z.string().min(1).max(64), @@ -600,7 +602,13 @@ const responseSchemas: Readonly> = { receipt({ runId: id }), receipt({ run: publicRunEntity, binding: bindingMetadata, mutation: mutationMetadata }), ]), - 'run-list': receipt({ runs: z.array(runEntity).max(100), cursor: cursor.optional() }), + // Real Orca 1.4.192 pages with `nextCursor` (null on the last page); the + // legacy shape used `cursor`. Both are accepted, neither is required. + 'run-list': receipt({ + runs: z.array(z.union([runEntity, publicRunEntity])).max(100), + cursor: cursor.optional(), + nextCursor: cursor.nullable().optional(), + }), 'run-show': receipt({ run: z.union([runEntity, publicRunEntity]) }), 'run-current': z.union([ receipt({ run: runEntity, coordinatorTerminalHandle: terminalId }),