omo-ai 5.1.46 → 5.1.47

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (39) hide show
  1. package/bin/lib/service-auth.generated.js +2 -2
  2. package/package.json +1 -1
  3. package/plugin/CHANGELOG.md +44 -0
  4. package/plugin/extensions/gateway-store-worker.mjs +2 -2
  5. package/plugin/extensions/memory-run-supervisor.mjs +3 -3
  6. package/plugin/extensions/omo-claim-receipt.js +1 -1
  7. package/plugin/extensions/omo-computer-use.js +1 -1
  8. package/plugin/extensions/omo-device-account.js +2 -2
  9. package/plugin/extensions/omo-feedback.js +1 -1
  10. package/plugin/extensions/omo-init-deep-advisor.js +1 -1
  11. package/plugin/extensions/omo-member.js +2 -2
  12. package/plugin/extensions/omo-memory-commands.js +3 -3
  13. package/plugin/extensions/omo-memory-doctor.js +3 -3
  14. package/plugin/extensions/omo-memory-memfs.js +3 -3
  15. package/plugin/extensions/omo-memory-palace.js +3 -3
  16. package/plugin/extensions/omo-memory-sync.js +1 -1
  17. package/plugin/extensions/omo-onboarding-scan.js +3 -3
  18. package/plugin/extensions/omo-recall-store.js +1 -1
  19. package/plugin/extensions/omo-session-history.js +1 -1
  20. package/plugin/extensions/omo-side-panel.js +2 -2
  21. package/plugin/extensions/omo-task.js +2 -2
  22. package/plugin/extensions/omo-telemetry-posthog.js +1 -1
  23. package/plugin/extensions/omo-telemetry-recovery.js +2 -2
  24. package/plugin/extensions/omo-thread-client.js +2 -2
  25. package/plugin/extensions/omo.js +3 -3
  26. package/plugin/package.json +1 -1
  27. package/plugin/runtime/agent-toolkit-sdk/sdk.js +2 -2
  28. package/plugin/runtime/ast-grep-mcp/manifest.json +1 -1
  29. package/plugin/runtime/category-coverage/index.js +1 -1
  30. package/plugin/runtime/rollback-migrate.js +2 -2
  31. package/plugin/runtime/thread-sdk/sdk.js +2 -2
  32. package/plugin/skills/browser/runtime/omowright/manifest.json +1 -1
  33. package/plugin/skills/ulw-research/SKILL.md +1 -1
  34. package/plugin/skills/ulw-research/references/deliverable-phase.md +9 -2
  35. package/plugin/skills/ulw-research/scripts/fact-commands-meaning.mjs +7 -22
  36. package/plugin/skills/ulw-research/scripts/fact-commands-polish.mjs +127 -0
  37. package/plugin/skills/ulw-research/scripts/fact-commands-verify.mjs +19 -0
  38. package/plugin/skills/ulw-research/scripts/fact-commands.mjs +4 -2
  39. package/plugin/skills/ulw-research/scripts/fact-pairs.mjs +7 -9
@@ -112,8 +112,8 @@ ${content.join(`
112
112
  }
113
113
  `)}return doc.write("payload.value = newResult;"),doc.write("return payload;"),doc.compile()},fastpass,isObject2=isObject,jit=!globalConfig.jitless,fastEnabled=jit&&allowsEval.value,catchall=def.catchall,value;inst._zod.parse=(payload,ctx)=>{value??(value=_normalized.value);let input=payload.value;if(!isObject2(input))return payload.issues.push({expected:"object",code:"invalid_type",input,inst}),payload;if(jit&&fastEnabled&&ctx?.async===!1&&ctx.jitless!==!0){if(!fastpass)fastpass=generateFastpass(def.shape);if(payload=fastpass(payload,ctx),!catchall)return payload;return handleCatchall([],input,payload,ctx,value,inst,ctx?.abortEarly===!0)}return superParse(payload,ctx)}});function handleUnionResults(results,final,inst,ctx){for(let result of results)if(result.issues.length===0)return final.value=result.value,final;let nonaborted=results.filter((r)=>!aborted(r));if(nonaborted.length===1)return final.value=nonaborted[0].value,nonaborted[0];return final.issues.push({code:"invalid_union",input:final.value,inst,errors:results.map((result)=>result.issues.map((iss)=>finalizeIssue(iss,ctx,config())))}),final}var $ZodUnion=$constructor("$ZodUnion",(inst,def)=>{$ZodType.init(inst,def),defineLazyInternal(inst,"optin",(zod)=>zod.def.options.some((o)=>o._zod.optin==="defaulted")?"defaulted":zod.def.options.some((o)=>o._zod.optin!==void 0)?"optional":void 0),defineLazyInternal(inst,"optout",(zod)=>zod.def.options.some((o)=>o._zod.optout==="optional")?"optional":void 0),defineLazyInternal(inst,"values",(zod)=>{if(zod.def.options.every((o)=>o._zod.values))return new Set(zod.def.options.flatMap((option)=>Array.from(option._zod.values)));return}),defineLazyInternal(inst,"pattern",(zod)=>{if(zod.def.options.every((o)=>o._zod.pattern)){let patterns=zod.def.options.map((o)=>o._zod.pattern);return new RegExp(`^(${patterns.map((p)=>cleanRegex(p.source)).join("|")})$`)}return});let first=def.options.length===1?def.options[0]._zod.run:null;inst._zod.parse=(payload,ctx)=>{if(first)return first(payload,ctx);let async=!1,results=[];for(let option of def.options){let result=option._zod.run({value:payload.value,issues:[]},ctx);if(result instanceof Promise)results.push(result),async=!0;else{if(result.issues.length===0)return result;results.push(result)}}if(!async)return handleUnionResults(results,payload,inst,ctx);return Promise.all(results).then((results)=>handleUnionResults(results,payload,inst,ctx))}});var $ZodIntersection=$constructor("$ZodIntersection",(inst,def)=>{$ZodType.init(inst,def),inst._zod.parse=(payload,ctx)=>{let input=payload.value,left=def.left._zod.run({value:input,issues:[]},ctx),right=def.right._zod.run({value:input,issues:[]},ctx);if(left instanceof Promise||right instanceof Promise)return Promise.all([left,right]).then(([left,right])=>handleIntersectionResults(payload,left,right));return handleIntersectionResults(payload,left,right)}});function mergeValues(a,b){if(a===b)return{valid:!0,data:a};if(a instanceof Date&&b instanceof Date&&+a===+b)return{valid:!0,data:a};if(isPlainObject(a)&&isPlainObject(b)){let bKeys=Object.keys(b),sharedKeys=Object.keys(a).filter((key)=>bKeys.indexOf(key)!==-1),newObj={...a,...b};if(Object.prototype.hasOwnProperty.call(newObj,"__proto__"))delete newObj.__proto__;for(let key of sharedKeys){if(key==="__proto__")continue;let sharedValue=mergeValues(a[key],b[key]);if(!sharedValue.valid)return{valid:!1,mergeErrorPath:[key,...sharedValue.mergeErrorPath]};newObj[key]=sharedValue.data}return{valid:!0,data:newObj}}if(Array.isArray(a)&&Array.isArray(b)){if(a.length!==b.length)return{valid:!1,mergeErrorPath:[]};let newArray=[];for(let index=0;index<a.length;index++){let itemA=a[index],itemB=b[index],sharedValue=mergeValues(itemA,itemB);if(!sharedValue.valid)return{valid:!1,mergeErrorPath:[index,...sharedValue.mergeErrorPath]};newArray.push(sharedValue.data)}return{valid:!0,data:newArray}}return{valid:!1,mergeErrorPath:[]}}function handleIntersectionResults(result,left,right){let unrecKeys=new Map,unrecIssue,keyIssues=new Map,collect=(iss,side)=>{let keys;if(iss.code==="unrecognized_keys"&&!iss.path?.length)unrecIssue??(unrecIssue=iss),keys=iss.keys;else if(iss.code==="invalid_key"&&iss.origin==="record"&&iss.path?.length===1){let k=String(iss.path[0]);if(!keyIssues.has(k))keyIssues.set(k,iss);keys=[k]}else return!1;for(let k of keys){if(!unrecKeys.has(k))unrecKeys.set(k,{});unrecKeys.get(k)[side]=!0}return!0};for(let iss of left.issues)if(!collect(iss,"l"))result.issues.push(iss);for(let iss of right.issues)if(!collect(iss,"r"))result.issues.push(iss);let bothKeys=[...unrecKeys].filter(([,f])=>f.l&&f.r).map(([k])=>k);if(bothKeys.length){let aggregated=unrecIssue?bothKeys.filter((k)=>unrecIssue.keys.includes(k)):[];if(aggregated.length)result.issues.push({...unrecIssue,keys:aggregated});for(let k of bothKeys)if(!aggregated.includes(k)&&keyIssues.has(k))result.issues.push(keyIssues.get(k))}let merged=mergeValues(left.value,right.value);if(!merged.valid){if(aborted(result))return result;throw Error(`Unmergable intersection. Error path: ${JSON.stringify(merged.mergeErrorPath)}`)}return result.value=merged.data,result}var $ZodEnum=$constructor("$ZodEnum",(inst,def)=>{$ZodType.init(inst,def);let values=getEnumValues(def.entries),valuesSet=new Set(values);inst._zod.values=valuesSet,defineLazyInternal(inst,"pattern",(zod)=>{let patternValues=getEnumValues(zod.def.entries).filter((k)=>propertyKeyTypes.has(typeof k));return new RegExp(patternValues.length?`^(${patternValues.map((o)=>escapeRegex(o.toString())).join("|")})$`:"^[^\\s\\S]$")}),inst._zod.parse=(payload,_ctx)=>{let input=payload.value;if(valuesSet.has(input))return payload;return payload.issues.push({code:"invalid_value",values,input,inst}),payload}}),$ZodLiteral=$constructor("$ZodLiteral",(inst,def)=>{$ZodType.init(inst,def);let values=new Set(def.values);inst._zod.values=values,defineLazyInternal(inst,"pattern",(zod)=>{let vals=zod.def.values;return new RegExp(vals.length?`^(${vals.map((o)=>typeof o==="string"?escapeRegex(o):o?escapeRegex(o.toString()):String(o)).join("|")})$`:"^[^\\s\\S]$")}),inst._zod.parse=(payload,_ctx)=>{let input=payload.value;if(values.has(input))return payload;return payload.issues.push({code:"invalid_value",values:def.values,input,inst}),payload}});var $ZodTransform=$constructor("$ZodTransform",(inst,def)=>{$ZodType.init(inst,def),inst._zod.optin="optional",globalConfig.memoizer?.guard(inst),inst._zod.parse=(payload,ctx)=>{if(ctx.direction==="backward")throw new $ZodEncodeError(inst.constructor.name);let _out=def.transform(payload.value,payload);if(ctx.async)return(_out instanceof Promise?_out:Promise.resolve(_out)).then((output)=>(payload.value=output,payload));if(_out instanceof Promise)throw new $ZodAsyncError;return payload.value=_out,payload}});function handleOptionalResult(payload,result){return payload.value=result.issues.length?void 0:result.value,payload}var $ZodOptional=$constructor("$ZodOptional",(inst,def)=>{$ZodType.init(inst,def),defineLazyInternal(inst,"optin",(zod)=>zod.def.innerType._zod.optin==="defaulted"?"defaulted":"optional"),inst._zod.optout="optional",defineLazyInternal(inst,"values",(zod)=>{let values=zod.def.innerType._zod.values;return values?new Set([...values,void 0]):void 0}),defineLazyInternal(inst,"pattern",(zod)=>{let pattern=zod.def.innerType._zod.pattern;return pattern?new RegExp(`^(${cleanRegex(pattern.source)})?$`):void 0}),inst._zod.parse=(payload,ctx)=>{if(payload.value===void 0){if(def.innerType._zod.optin!=="defaulted")return payload;let result=def.innerType._zod.run({value:payload.value,issues:[]},ctx);if(result instanceof Promise)return result.then((result)=>handleOptionalResult(payload,result));return handleOptionalResult(payload,result)}return def.innerType._zod.run(payload,ctx)}}),$ZodExactOptional=$constructor("$ZodExactOptional",(inst,def)=>{$ZodOptional.init(inst,def),defineLazyInternal(inst,"values",(zod)=>zod.def.innerType._zod.values),defineLazyInternal(inst,"pattern",(zod)=>zod.def.innerType._zod.pattern),inst._zod.parse=(payload,ctx)=>def.innerType._zod.run(payload,ctx)}),$ZodNullable=$constructor("$ZodNullable",(inst,def)=>{$ZodType.init(inst,def),defineLazyInternal(inst,"optin",(zod)=>zod.def.innerType._zod.optin),defineLazyInternal(inst,"optout",(zod)=>zod.def.innerType._zod.optout),defineLazyInternal(inst,"pattern",(zod)=>{let pattern=zod.def.innerType._zod.pattern;return pattern?new RegExp(`^(${cleanRegex(pattern.source)}|null)$`):void 0}),defineLazyInternal(inst,"values",(zod)=>zod.def.innerType._zod.values?new Set([...zod.def.innerType._zod.values,null]):void 0),inst._zod.parse=(payload,ctx)=>{if(payload.value===null)return payload;return def.innerType._zod.run(payload,ctx)}}),$ZodDefault=$constructor("$ZodDefault",(inst,def)=>{$ZodType.init(inst,def),inst._zod.optin="defaulted",defineLazyInternal(inst,"values",(zod)=>zod.def.innerType._zod.values),inst._zod.parse=(payload,ctx)=>{if(ctx.direction==="backward")return def.innerType._zod.run(payload,ctx);if(payload.value===void 0)return payload.value=def.defaultValue,payload;let result=def.innerType._zod.run(payload,ctx);if(result instanceof Promise)return result.then((result)=>handleDefaultResult(result,def));return handleDefaultResult(result,def)}});function handleDefaultResult(payload,def){if(payload.value===void 0)payload.value=def.defaultValue;return payload}var $ZodPrefault=$constructor("$ZodPrefault",(inst,def)=>{$ZodType.init(inst,def),inst._zod.optin="defaulted",defineLazyInternal(inst,"values",(zod)=>zod.def.innerType._zod.values),inst._zod.parse=(payload,ctx)=>{if(ctx.direction==="backward")return def.innerType._zod.run(payload,ctx);if(payload.value===void 0)payload.value=def.defaultValue;return def.innerType._zod.run(payload,ctx)}}),$ZodNonOptional=$constructor("$ZodNonOptional",(inst,def)=>{$ZodType.init(inst,def),defineLazyInternal(inst,"values",(zod)=>{let v=zod.def.innerType._zod.values;return v?new Set([...v].filter((x)=>x!==void 0)):void 0}),inst._zod.parse=(payload,ctx)=>{let result=def.innerType._zod.run(payload,ctx);if(result instanceof Promise)return result.then((result)=>handleNonOptionalResult(result,inst));return handleNonOptionalResult(result,inst)}});function handleNonOptionalResult(payload,inst){if(!payload.issues.length&&payload.value===void 0)payload.issues.push({code:"invalid_type",expected:"nonoptional",input:payload.value,inst});return payload}function handleCatchResult(payload,result,def,ctx){if(!result.issues.length){if(payload.value=result.value,result.memo)payload.memo=!0;return payload}return payload.value=def.catchValue({...result,value:payload.value,error:{issues:result.issues.map((iss)=>finalizeIssue(iss,ctx,config()))},input:payload.value}),payload}var $ZodCatch=$constructor("$ZodCatch",(inst,def)=>{$ZodType.init(inst,def),defineLazyInternal(inst,"optin",(zod)=>zod.def.innerType._zod.optin==="defaulted"?"defaulted":"optional"),defineLazyInternal(inst,"optout",(zod)=>zod.def.innerType._zod.optout),defineLazyInternal(inst,"values",(zod)=>zod.def.innerType._zod.values),inst._zod.parse=(payload,ctx)=>{if(ctx.direction==="backward")return def.innerType._zod.run(payload,ctx);let result=def.innerType._zod.run({value:payload.value,issues:[]},ctx);if(result instanceof Promise)return result.then((result)=>handleCatchResult(payload,result,def,ctx));return handleCatchResult(payload,result,def,ctx)}});var $ZodPipe=$constructor("$ZodPipe",(inst,def)=>{$ZodType.init(inst,def),defineLazyInternal(inst,"values",(zod)=>zod.def.in._zod.values),defineLazyInternal(inst,"optin",(zod)=>zod.def.in._zod.optin),defineLazyInternal(inst,"optout",(zod)=>zod.def.out._zod.optout),defineLazyInternal(inst,"propValues",(zod)=>zod.def.in._zod.propValues),inst._zod.parse=(payload,ctx)=>{if(ctx.direction==="backward"){let right=def.out._zod.run(payload,ctx);if(right instanceof Promise)return right.then((right)=>handlePipeResult(right,def.in,ctx));return handlePipeResult(right,def.in,ctx)}let left=def.in._zod.run(payload,ctx);if(left instanceof Promise)return left.then((left)=>handlePipeResult(left,def.out,ctx));return handlePipeResult(left,def.out,ctx)}});function handlePipeResult(left,next,ctx){if(left.issues.some((iss)=>iss.code!=="unrecognized_keys"))return left.aborted=!0,left;return next._zod.run({value:left.value,issues:left.issues},ctx)}var $ZodReadonly=$constructor("$ZodReadonly",(inst,def)=>{$ZodType.init(inst,def),defineLazyInternal(inst,"propValues",(zod)=>zod.def.innerType._zod.propValues),defineLazyInternal(inst,"values",(zod)=>zod.def.innerType._zod.values),defineLazyInternal(inst,"optin",(zod)=>zod.def.innerType?._zod?.optin),defineLazyInternal(inst,"optout",(zod)=>zod.def.innerType?._zod?.optout),inst._zod.parse=(payload,ctx)=>{if(ctx.direction==="backward")return def.innerType._zod.run(payload,ctx);let result=def.innerType._zod.run(payload,ctx);if(result instanceof Promise)return result.then(handleReadonlyResult);return handleReadonlyResult(result)}});function handleReadonlyResult(payload){if(!payload.memo)payload.value=Object.freeze(payload.value);return payload}var $ZodCustom=$constructor("$ZodCustom",(inst,def)=>{$ZodCheck.init(inst,def),$ZodType.init(inst,def),inst._zod.parse=(payload,_)=>payload,inst._zod.check=(payload)=>{let input=payload.value,r=def.fn(input);if(r instanceof Promise)return r.then((r)=>handleRefineResult(r,payload,input,inst));handleRefineResult(r,payload,input,inst);return}});function handleRefineResult(result,payload,input,inst){if(!result){let _iss={code:"custom",input,inst,path:[...inst._zod.def.path??[]],continue:!inst._zod.def.abort};if(inst._zod.def.params)_iss.params=inst._zod.def.params;payload.issues.push(issue(_iss))}}class $ZodCyclicError extends Error{constructor(){super("Cannot parse a reference cycle that closes through a transform");this.name="ZodCyclicError"}}var STATE="~memo",NO_ISSUES=[];function isRef(value){return value!==null&&typeof value==="object"}function cloneIssues(issues){return issues.map((iss)=>iss.path?{...iss,path:iss.path.slice()}:{...iss})}var recursive=new WeakMap,NONE=0,ASSUMED=1,PROVEN=2;function isRecursive(inst,stack,resolve){let cached=recursive.get(inst);if(cached!==void 0)return cached?PROVEN:NONE;if(stack.has(inst))return PROVEN;stack.add(inst);let result=NONE,check=(child)=>{if(result!==PROVEN&&child?._zod){let answer=isRecursive(child,stack,resolve);if(answer>result)result=answer}},shape=(sh,spread)=>{let answer=NONE;for(let key of Reflect.ownKeys(sh)){let desc=Object.getOwnPropertyDescriptor(sh,key);if(spread&&!desc.enumerable)continue;let child=desc.get?ASSUMED:desc.value?._zod?isRecursive(desc.value,stack,resolve):NONE;if(child>answer)answer=child}return answer},merge=(answer)=>{if(answer>result)result=answer},def=inst._zod.def,kind=def.type;switch(kind){case"object":{let raw=rawShape(def);merge(raw?shape(raw,!0):ASSUMED),check(def.catchall);break}case"array":check(def.element);break;case"tuple":for(let el of def.items)check(el);check(def.rest);break;case"record":case"map":check(def.keyType),check(def.valueType);break;case"set":check(def.valueType);break;case"union":for(let el of def.options)check(el);break;case"intersection":check(def.left),check(def.right);break;case"optional":case"nullable":case"default":case"prefault":case"catch":case"readonly":case"nonoptional":case"promise":case"success":check(def.innerType);break;case"pipe":check(def.in),check(def.out);break;case"function":check(def.input),check(def.output);break;case"lazy":{let inner=def._cachedInner??(resolve?inst._zod.innerType:void 0);merge(inner?isRecursive(inner,stack,!1):ASSUMED);break}case"template_literal":case"string":case"number":case"int":case"boolean":case"bigint":case"symbol":case"undefined":case"null":case"void":case"never":case"any":case"unknown":case"date":case"nan":case"enum":case"literal":case"file":case"transform":case"custom":break;default:for(let key in def){let desc=Object.getOwnPropertyDescriptor(def,key);if(!desc||desc.get)continue;let value=desc.value;if(!value||typeof value!=="object")continue;if(value._zod)check(value);else if(Array.isArray(value))for(let el of value)check(el)}}return stack.delete(inst),settle(inst,result)}function settle(inst,answer){if(answer!==ASSUMED)recursive.set(inst,answer===PROVEN);return answer}function bucketFor(state,inst){let bucket=state.buckets.get(inst);if(!bucket)bucket=new WeakMap,state.buckets.set(inst,bucket);return bucket}var handoff,open=[],memo={alloc(_inst,payload,empty){let bucket=handoff;if(!bucket)return empty;handoff=void 0;let entry={value:empty,issues:null};return bucket.set(payload.value,entry),open.push(entry),empty},guard(inst){var _a;(_a=inst._zod).deferred??(_a.deferred=[]),inst._zod.deferred.push(()=>{let base=inst._zod.parse,wrapped=(payload,ctx)=>{if(ctx.direction!=="backward"&&isBackEdge(ctx,payload.value))throw new $ZodCyclicError;return base(payload,ctx)};if(inst._zod.parse=wrapped,inst._zod.run===base)inst._zod.run=wrapped})},attach(inst){var _a;let isRecursiveInst,rechecked=!1,lastCtx,lastBucket;(_a=inst._zod).deferred??(_a.deferred=[]),inst._zod.deferred.push(()=>{let base=inst._zod.parse,wrapped=(payload,ctx)=>{if(isRecursiveInst===void 0){let walked=isRecursive(inst,new Set,!1);if(walked===NONE){if(inst._zod.parse=base,inst._zod.run===wrapped)inst._zod.run=base;return base(payload,ctx)}if(walked===PROVEN||rechecked)isRecursiveInst=!0;else rechecked=!0}let input=payload.value;if(!isRef(input))return base(payload,ctx);let state=ctx[STATE];if(!state)state={buckets:new WeakMap,backEdges:void 0},ctx[STATE]=state;let bucket;if(lastCtx===ctx)bucket=lastBucket;else bucket=bucketFor(state,inst),lastCtx=ctx,lastBucket=bucket;let hit=bucket.get(input);if(hit){if(payload.value=hit.value,hit.issues){if(hit.issues.length)payload.issues.push(...cloneIssues(hit.issues))}else payload.memo=!0,state.backEdges??(state.backEdges=new WeakSet),state.backEdges.add(hit.value);return payload}handoff=bucket;let depth=open.length,result=base(payload,ctx);handoff=void 0;let entry=open.length>depth?open.pop():void 0;if(result instanceof Promise)return result.then((r)=>{if(entry)entry.issues=r.issues.length?cloneIssues(r.issues):NO_ISSUES;return r});if(entry)entry.issues=result.issues.length?cloneIssues(result.issues):NO_ISSUES;return result};if(inst._zod.parse=wrapped,inst._zod.run===base)inst._zod.run=wrapped})}};function memoizer(){return memo}function isBackEdge(ctx,value){let backEdges=ctx[STATE]?.backEdges;return backEdges!==void 0&&isRef(value)&&backEdges.has(value)}var error=()=>{let Sizable={string:{unit:"characters",verb:"to have"},file:{unit:"bytes",verb:"to have"},array:{unit:"items",verb:"to have"},set:{unit:"items",verb:"to have"},map:{unit:"entries",verb:"to have"}};function getSizing(origin){return Sizable[origin]??null}let FormatDictionary={regex:"input",email:"email address",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO datetime",date:"ISO date",time:"ISO time",duration:"ISO duration",ipv4:"IPv4 address",ipv6:"IPv6 address",mac:"MAC address",cidrv4:"IPv4 range",cidrv6:"IPv6 range",base64:"base64-encoded string",base64url:"base64url-encoded string",json_string:"JSON string",e164:"E.164 number",currency_code:"currency code",credit_card:"credit card number",iban:"IBAN",jwt:"JWT",template_literal:"input"},TypeDictionary={nan:"NaN"};function getTypeName(type,input){if(type==="number"&&typeof input==="number"&&!Number.isFinite(input))return String(input);return TypeDictionary[type]??type}return(issue)=>{switch(issue.code){case"invalid_type":{let expected=getTypeName(issue.expected),receivedType=parsedType(issue.input),received=getTypeName(receivedType,issue.input);return`Invalid input: expected ${expected}, received ${received}`}case"invalid_value":if(issue.values.length===1)return`Invalid input: expected ${stringifyPrimitive(issue.values[0])}`;return`Invalid option: expected one of ${joinValues(issue.values,"|")}`;case"too_big":{let adj=issue.exact?"exactly ":issue.inclusive?"<=":"<",sizing=getSizing(issue.origin);if(sizing)return`Too big: expected ${issue.origin??"value"} to have ${adj}${issue.maximum.toString()} ${sizing.unit??"elements"}`;return`Too big: expected ${issue.origin??"value"} to be ${adj}${issue.maximum.toString()}`}case"too_small":{let adj=issue.exact?"exactly ":issue.inclusive?">=":">",sizing=getSizing(issue.origin);if(sizing)return`Too small: expected ${issue.origin} to have ${adj}${issue.minimum.toString()} ${sizing.unit}`;return`Too small: expected ${issue.origin} to be ${adj}${issue.minimum.toString()}`}case"invalid_format":{let _issue=issue;if(_issue.format==="starts_with")return`Invalid string: must start with "${_issue.prefix}"`;if(_issue.format==="ends_with")return`Invalid string: must end with "${_issue.suffix}"`;if(_issue.format==="includes")return`Invalid string: must include "${_issue.includes}"`;if(_issue.format==="regex")return`Invalid string: must match pattern ${_issue.pattern}`;return`Invalid ${FormatDictionary[_issue.format]??issue.format}`}case"not_multiple_of":return`Invalid number: must be a multiple of ${issue.divisor}`;case"unrecognized_keys":return`Unrecognized key${issue.keys.length>1?"s":""}: ${joinValues(issue.keys,", ")}`;case"invalid_key":return`Invalid key in ${issue.origin}`;case"invalid_union":if(issue.options&&Array.isArray(issue.options)&&issue.options.length>0)return`Invalid discriminator value. Expected ${issue.options.map((o)=>`'${o}'`).join(" | ")}`;if(issue.inclusive===!1)return"Invalid input: more than one option matched";return"Invalid input";case"invalid_element":return`Invalid value in ${issue.origin}`;default:return"Invalid input"}}};function en_default(){return{localeError:error()}}var _a2;class $ZodRegistry{constructor(){this._map=new WeakMap,this._idmap=new Map}add(schema,..._meta){let meta=_meta[0];if(this._map.set(schema,meta),meta&&typeof meta==="object"&&"id"in meta)this._idmap.set(meta.id,schema);return this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(schema){let meta=this._map.get(schema);if(meta&&typeof meta==="object"&&"id"in meta)this._idmap.delete(meta.id);return this._map.delete(schema),this}get(schema){let p=schema._zod.parent;if(p){let pm={...this.get(p)??{}};delete pm.id;let f={...pm,...this._map.get(schema)};return Object.keys(f).length?f:void 0}return this._map.get(schema)}has(schema){return this._map.has(schema)}}function registry(){return new $ZodRegistry}(_a2=globalThis).__zod_globalRegistry??(_a2.__zod_globalRegistry=registry());var globalRegistry=globalThis.__zod_globalRegistry;function snapshotChecks(def){if(def.checks)def.checks=[...def.checks];return def}function _string(Class,params){return new Class(snapshotChecks({type:"string",...normalizeParams(params)}))}function _email(Class,params){return new Class({type:"string",format:"email",check:"string_format",abort:!1,...normalizeParams(params)})}function _guid(Class,params){return new Class({type:"string",format:"guid",check:"string_format",abort:!1,...normalizeParams(params)})}function _uuid(Class,params){return new Class({type:"string",format:"uuid",check:"string_format",abort:!1,...normalizeParams(params)})}function _uuidv4(Class,params){return new Class({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...normalizeParams(params)})}function _uuidv6(Class,params){return new Class({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...normalizeParams(params)})}function _uuidv7(Class,params){return new Class({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...normalizeParams(params)})}function _url(Class,params){return new Class({type:"string",format:"url",check:"string_format",abort:!1,...normalizeParams(params)})}function _emoji2(Class,params){return new Class({type:"string",format:"emoji",check:"string_format",abort:!1,...normalizeParams(params)})}function _nanoid(Class,params){return new Class({type:"string",format:"nanoid",check:"string_format",abort:!1,...normalizeParams(params)})}function _cuid(Class,params){return new Class({type:"string",format:"cuid",check:"string_format",abort:!1,...normalizeParams(params)})}function _cuid2(Class,params){return new Class({type:"string",format:"cuid2",check:"string_format",abort:!1,...normalizeParams(params)})}function _ulid(Class,params){return new Class({type:"string",format:"ulid",check:"string_format",abort:!1,...normalizeParams(params)})}function _xid(Class,params){return new Class({type:"string",format:"xid",check:"string_format",abort:!1,...normalizeParams(params)})}function _ksuid(Class,params){return new Class({type:"string",format:"ksuid",check:"string_format",abort:!1,...normalizeParams(params)})}function _ipv4(Class,params){return new Class({type:"string",format:"ipv4",check:"string_format",abort:!1,...normalizeParams(params)})}function _ipv6(Class,params){return new Class({type:"string",format:"ipv6",check:"string_format",abort:!1,...normalizeParams(params)})}function _cidrv4(Class,params){return new Class({type:"string",format:"cidrv4",check:"string_format",abort:!1,...normalizeParams(params)})}function _cidrv6(Class,params){return new Class({type:"string",format:"cidrv6",check:"string_format",abort:!1,...normalizeParams(params)})}function _base64(Class,params){return new Class({type:"string",format:"base64",check:"string_format",abort:!1,...normalizeParams(params)})}function _base64url(Class,params){return new Class({type:"string",format:"base64url",check:"string_format",abort:!1,...normalizeParams(params)})}function _e164(Class,params){return new Class({type:"string",format:"e164",check:"string_format",abort:!1,...normalizeParams(params)})}function _jwt(Class,params){return new Class({type:"string",format:"jwt",check:"string_format",abort:!1,...normalizeParams(params)})}function _isoDateTime(Class,params){return new Class({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...normalizeParams(params)})}function _isoDate(Class,params){return new Class({type:"string",format:"date",check:"string_format",...normalizeParams(params)})}function _isoTime(Class,params){return new Class({type:"string",format:"time",check:"string_format",precision:null,...normalizeParams(params)})}function _isoDuration(Class,params){return new Class({type:"string",format:"duration",check:"string_format",...normalizeParams(params)})}function _number(Class,params){return new Class(snapshotChecks({type:"number",checks:[],...normalizeParams(params)}))}function _int(Class,params){return new Class({type:"number",check:"number_format",abort:!1,format:"safeint",...normalizeParams(params)})}function _boolean(Class,params){return new Class({type:"boolean",...normalizeParams(params)})}function _unknown(Class){return new Class({type:"unknown"})}function _never(Class,params){return new Class({type:"never",...normalizeParams(params)})}function _lt(value,params){return new $ZodCheckLessThan({check:"less_than",...normalizeParams(params),value,inclusive:!1})}function _lte(value,params){return new $ZodCheckLessThan({check:"less_than",...normalizeParams(params),value,inclusive:!0})}function _gt(value,params){return new $ZodCheckGreaterThan({check:"greater_than",...normalizeParams(params),value,inclusive:!1})}function _gte(value,params){return new $ZodCheckGreaterThan({check:"greater_than",...normalizeParams(params),value,inclusive:!0})}function _multipleOf(value,params){return new $ZodCheckMultipleOf({check:"multiple_of",...normalizeParams(params),value})}function _maxLength(maximum,params){return new $ZodCheckMaxLength({check:"max_length",...normalizeParams(params),maximum})}function _minLength(minimum,params){return new $ZodCheckMinLength({check:"min_length",...normalizeParams(params),minimum})}function _length(length,params){return new $ZodCheckLengthEquals({check:"length_equals",...normalizeParams(params),length})}function _regex(pattern,params){return new $ZodCheckRegex({check:"string_format",format:"regex",...normalizeParams(params),pattern})}function _lowercase(params){return new $ZodCheckLowerCase({check:"string_format",format:"lowercase",...normalizeParams(params)})}function _uppercase(params){return new $ZodCheckUpperCase({check:"string_format",format:"uppercase",...normalizeParams(params)})}function _includes(includes,params){return new $ZodCheckIncludes({check:"string_format",format:"includes",...normalizeParams(params),includes})}function _startsWith(prefix,params){return new $ZodCheckStartsWith({check:"string_format",format:"starts_with",...normalizeParams(params),prefix})}function _endsWith(suffix,params){return new $ZodCheckEndsWith({check:"string_format",format:"ends_with",...normalizeParams(params),suffix})}function _overwrite(tx){return new $ZodCheckOverwrite({check:"overwrite",tx})}function _normalize(form){return _overwrite((input)=>input.normalize(form))}function _trim(){return _overwrite((input)=>input.trim())}function _toLowerCase(){return _overwrite((input)=>input.toLowerCase())}function _toUpperCase(){return _overwrite((input)=>input.toUpperCase())}function _slugify(){return _overwrite((input)=>slugify(input))}function _array(Class,element,params){return new Class({type:"array",element,...normalizeParams(params)})}function _refine(Class,fn,_params){return new Class({type:"custom",check:"custom",fn,...normalizeParams(_params)})}function _superRefine(fn,params){let ch=_check((payload)=>(payload.addIssue=(issue2)=>{if(typeof issue2==="string")payload.issues.push(issue(issue2,payload.value,ch._zod.def));else{let _issue=issue2;if(_issue.fatal)_issue.continue=!1;if(_issue.code??(_issue.code="custom"),!("input"in _issue))_issue.input=payload.value;_issue.inst??(_issue.inst=ch),_issue.continue??(_issue.continue=!ch._zod.def.abort),payload.issues.push(issue(_issue))}},fn(payload.value,payload)),params);return ch}function _check(fn,params){let ch=new $ZodCheck({check:"custom",...normalizeParams(params)});return ch._zod.check=fn,ch}function assignProps(target,...sources){for(let source of sources)for(let key of Reflect.ownKeys(source))if(Object.prototype.propertyIsEnumerable.call(source,key))assignProp(target,key,source[key]);return target}function initializeContext(params){let target=params?.target??"draft-2020-12";if(target==="draft-4")target="draft-04";if(target==="draft-7")target="draft-07";return{processors:params.processors??{},metadataRegistry:params?.metadata??globalRegistry,target,unrepresentable:params?.unrepresentable??"throw",override:params?.override??(()=>{}),io:params?.io??"output",counter:0,seen:new Map,sharedDefsExtractedFor:void 0,sharedEmitDoneFor:void 0,cycles:params?.cycles??"ref",reused:params?.reused??"inline",intersections:[],deferred:[],external:params?.external??void 0}}function handleUnrepresentable(schema,ctx,json,params,message){let result=typeof ctx.unrepresentable==="function"?ctx.unrepresentable({zodSchema:schema,path:params.path,message}):ctx.unrepresentable;if(result==="any")return!1;if(result===void 0||result==="throw")throw Error(message);return Object.assign(json,result),!0}function processSchema(schema,ctx,_params={path:[],schemaPath:[]}){var _a;let def=schema._zod.def,seen=ctx.seen.get(schema);if(seen){if(seen.count++,_params.schemaPath.includes(schema))seen.cycle=_params.path;return seen.schema}let result={schema:{},count:1,cycle:void 0,path:_params.path};ctx.seen.set(schema,result),ctx.sharedDefsExtractedFor=void 0,ctx.sharedEmitDoneFor=void 0;let overrideSchema=schema._zod.toJSONSchema?.();if(overrideSchema)result.schema=overrideSchema;else{let params={..._params,schemaPath:[..._params.schemaPath,schema],path:_params.path};if(schema._zod.processJSONSchema)schema._zod.processJSONSchema(ctx,result.schema,params);else{let _json=result.schema,processor=ctx.processors[def.type];if(!processor)throw Error(`[toJSONSchema]: Non-representable type encountered: ${def.type}`);processor(schema,ctx,_json,params)}let parent=schema._zod.parent;if(parent){if(!result.ref)result.ref=parent;processSchema(parent,ctx,params),ctx.seen.get(parent).isParent=!0}}let meta=ctx.metadataRegistry.get(schema);if(meta)assignProps(result.schema,meta);if(ctx.io==="input"&&isTransforming(schema))delete result.schema.examples,delete result.schema.default;if(ctx.io==="input"&&"_prefault"in result.schema)(_a=result.schema).default??(_a.default=result.schema._prefault);return delete result.schema._prefault,ctx.seen.get(schema).schema}function encodeJSONPointerSegment(segment){return segment.replace(/~/g,"~0").replace(/\//g,"~1")}function extractDefs(ctx,schema){let root=ctx.seen.get(schema);if(!root)throw Error("Unprocessed schema. This is a bug in Zod.");if(ctx.external&&ctx.sharedDefsExtractedFor===ctx.external)return;let idToSchema=new Map;for(let entry of ctx.seen.entries()){let id=ctx.metadataRegistry.get(entry[0])?.id;if(id){let existing=idToSchema.get(id);if(existing&&existing!==entry[0])throw Error(`Duplicate schema id "${id}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);idToSchema.set(id,entry[0])}}let makeURI=(entry)=>{let defsSegment=ctx.target==="draft-2020-12"?"$defs":"definitions";if(ctx.external){let externalId=ctx.external.registry.get(entry[0])?.id,uriGenerator=ctx.external.uri??((id)=>id);if(externalId)return{ref:uriGenerator(externalId)};let id=entry[1].defId??entry[1].schema.id??`schema${ctx.counter++}`;return entry[1].defId=id,{defId:id,ref:`${uriGenerator("__shared")}#/${defsSegment}/${encodeJSONPointerSegment(id)}`}}let uriPrefix="#",defUriPrefix=`${uriPrefix}/${defsSegment}/`;if(entry[1]===root&&!entry[1].schema.id)return{ref:uriPrefix};let defId=entry[1].schema.id??`__schema${ctx.counter++}`;return{defId,ref:defUriPrefix+encodeJSONPointerSegment(defId)}},extractToDef=(entry)=>{if(entry[1].schema.$ref)return;let seen=entry[1],{ref,defId}=makeURI(entry);if(seen.def={...seen.schema},defId)seen.defId=defId;let schema=seen.schema;for(let key in schema)delete schema[key];schema.$ref=ref};if(ctx.cycles==="throw")for(let entry of ctx.seen.entries()){let seen=entry[1];if(seen.cycle)throw Error(`Cycle detected: #/${seen.cycle?.join("/")}/<root>
114
114
 
115
- Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let entry of ctx.seen.entries()){let seen=entry[1];if(schema===entry[0]){extractToDef(entry);continue}if(ctx.external){let ext=ctx.external.registry.get(entry[0])?.id;if(schema!==entry[0]&&ext){extractToDef(entry);continue}}if(ctx.metadataRegistry.get(entry[0])?.id){extractToDef(entry);continue}if(seen.cycle){extractToDef(entry);continue}if(seen.count>1){if(ctx.reused==="ref")extractToDef(entry)}}if(ctx.external)ctx.sharedDefsExtractedFor=ctx.external}function compactTypeUnion(schema){let options=schema.anyOf;if(!Array.isArray(options)||options.length===0||schema.type!==void 0)return;let types=[];for(let option of options){if(!option||typeof option!=="object")return;compactTypeUnion(option);let keys=Object.keys(option);if(keys.length!==1||keys[0]!=="type")return;let type=option.type;for(let member of Array.isArray(type)?type:[type]){if(typeof member!=="string")return;if(!types.includes(member))types.push(member)}}delete schema.anyOf,schema.type=types.length===1?types[0]:types}var FOLDABLE_KEYS=new Set(["type","properties","required","additionalProperties"]),UNION_KEYS=["oneOf","anyOf"];function undeclaredConstraint(member){let extra=member.additionalProperties;if(extra===void 0||extra===!1||typeof extra!=="object"||extra===null)return null;return Object.keys(extra).length?extra:null}function foldObjects(members){let objects=[];for(let member of members){if(typeof member!=="object"||member.type!=="object")return null;for(let key in member)if(!FOLDABLE_KEYS.has(key))return null;objects.push(member)}let properties={},required=new Set;for(let object of objects){for(let key in object.properties){if(Object.prototype.hasOwnProperty.call(properties,key))continue;let parts=[];for(let other of objects){let part=other.properties?.[key]??undeclaredConstraint(other);if(part===null||part===void 0)continue;if(!parts.some((seen)=>JSON.stringify(seen)===JSON.stringify(part)))parts.push(part)}let merged=parts.length===1?parts[0]:foldObjects(parts)??{allOf:parts};assignProp(properties,key,merged)}for(let key of object.required??[])required.add(key)}let folded={type:"object",properties};if(required.size)folded.required=[...required];if(objects.every((object)=>object.additionalProperties===!1))folded.additionalProperties=!1;else{let constraints=[];for(let object of objects){let constraint=undeclaredConstraint(object);if(constraint&&!constraints.some((seen)=>JSON.stringify(seen)===JSON.stringify(constraint)))constraints.push(constraint)}if(constraints.length===1)folded.additionalProperties=constraints[0];else if(constraints.length>1)folded.additionalProperties={allOf:constraints}}return folded}function foldIntersection(json){let allOf=json.allOf;if(!Array.isArray(allOf)||allOf.length<2)return;for(let key of FOLDABLE_KEYS)if(key in json)return;let unions=allOf.filter((m)=>UNION_KEYS.some((k)=>Array.isArray(m[k]))),folded=null;if(!unions.length)folded=foldObjects(allOf);else{let union=unions[0],keyword=UNION_KEYS.find((k)=>Array.isArray(union[k]));if(Object.keys(union).length!==1)return;let rest=allOf.filter((m)=>m!==union),branches=union[keyword].map((branch)=>foldObjects([...rest,branch]));if(branches.some((b)=>!b))return;folded={[keyword]:branches}}if(!folded)return;delete json.allOf,assignProps(json,folded)}function finalize(ctx,schema){let root=ctx.seen.get(schema);if(!root)throw Error("Unprocessed schema. This is a bug in Zod.");let flattenRef=(zodSchema)=>{let seen=ctx.seen.get(zodSchema);if(seen.ref===null)return;let schema=seen.def??seen.schema,_cached={...schema},ref=seen.ref;if(seen.ref=null,ref){flattenRef(ref);let refSeen=ctx.seen.get(ref),refSchema=refSeen.schema;if(refSchema.$ref&&(ctx.target==="draft-07"||ctx.target==="draft-04"||ctx.target==="openapi-3.0"))schema.allOf=schema.allOf??[],schema.allOf.push(refSchema);else assignProps(schema,refSchema);if(assignProps(schema,_cached),zodSchema._zod.parent===ref)for(let key in schema){if(key==="$ref"||key==="allOf")continue;if(!(key in _cached))delete schema[key]}if(refSchema.$ref&&refSeen.def)for(let key in schema){if(key==="$ref"||key==="allOf")continue;if(key in refSeen.def&&JSON.stringify(schema[key])===JSON.stringify(refSeen.def[key]))delete schema[key]}}let parent=zodSchema._zod.parent;if(parent&&parent!==ref){flattenRef(parent);let parentSeen=ctx.seen.get(parent);if(parentSeen?.schema.$ref){if(schema.$ref=parentSeen.schema.$ref,parentSeen.def)for(let key in schema){if(key==="$ref"||key==="allOf")continue;if(key in parentSeen.def&&JSON.stringify(schema[key])===JSON.stringify(parentSeen.def[key]))delete schema[key]}}}ctx.override({zodSchema,jsonSchema:schema,path:seen.path??[]})};if(!ctx.external||ctx.sharedEmitDoneFor!==ctx.external){for(let entry of[...ctx.seen.entries()].reverse())flattenRef(entry[0]);if(ctx.target!=="openapi-3.0")for(let entry of ctx.seen.entries())compactTypeUnion(entry[1].def??entry[1].schema);for(let rewrite of ctx.deferred)rewrite();if(ctx.intersections.length){let carriers=new Map;for(let seen of ctx.seen.values())for(let json of[seen.schema,seen.def]){let allOf=json?.allOf;if(!Array.isArray(allOf))continue;let existing=carriers.get(allOf);if(existing)existing.push(json);else carriers.set(allOf,[json])}for(let allOf of ctx.intersections)for(let json of carriers.get(allOf)??[])foldIntersection(json)}}let result={};if(ctx.target==="draft-2020-12")result.$schema="https://json-schema.org/draft/2020-12/schema";else if(ctx.target==="draft-07")result.$schema="http://json-schema.org/draft-07/schema#";else if(ctx.target==="draft-04")result.$schema="http://json-schema.org/draft-04/schema#";else if(ctx.target==="openapi-3.0");if(ctx.external?.uri){let id=ctx.external.registry.get(schema)?.id;if(!id)throw Error("Schema is missing an `id` property");result.$id=ctx.external.uri(id)}assignProps(result,root.defId?root.schema:root.def??root.schema);let rootMetaId=ctx.metadataRegistry.get(schema)?.id;if(rootMetaId!==void 0&&result.id===rootMetaId)delete result.id;let defs=ctx.external?.defs??{};if(!ctx.external||ctx.sharedEmitDoneFor!==ctx.external)for(let entry of ctx.seen.entries()){let seen=entry[1];if(seen.def&&seen.defId){if(seen.def.id===seen.defId)delete seen.def.id;assignProp(defs,seen.defId,seen.def)}}if(ctx.external)ctx.sharedEmitDoneFor=ctx.external;if(ctx.external);else if(Object.keys(defs).length>0)if(ctx.target==="draft-2020-12")result.$defs=defs;else result.definitions=defs;try{let finalized=JSON.parse(JSON.stringify(result));return Object.defineProperty(finalized,"~standard",{value:{...schema["~standard"],jsonSchema:{input:createStandardJSONSchemaMethod(schema,"input",ctx.processors),output:createStandardJSONSchemaMethod(schema,"output",ctx.processors)}},enumerable:!1,writable:!1}),finalized}catch(_err){throw Error("Error converting schema to JSON.")}}function isTransforming(_schema,_ctx){let ctx=_ctx??{seen:new Set};if(ctx.seen.has(_schema))return!1;ctx.seen.add(_schema);let def=_schema._zod.def;if(def.type==="transform")return!0;if(def.type==="array")return isTransforming(def.element,ctx);if(def.type==="set")return isTransforming(def.valueType,ctx);if(def.type==="lazy")return isTransforming(def.getter(),ctx);if(def.type==="promise"||def.type==="optional"||def.type==="nonoptional"||def.type==="nullable"||def.type==="readonly"||def.type==="default"||def.type==="prefault"||def.type==="catch")return isTransforming(def.innerType,ctx);if(def.type==="intersection")return isTransforming(def.left,ctx)||isTransforming(def.right,ctx);if(def.type==="record"||def.type==="map")return isTransforming(def.keyType,ctx)||isTransforming(def.valueType,ctx);if(def.type==="pipe"){if(_schema._zod.traits.has("$ZodCodec"))return!0;return isTransforming(def.in,ctx)||isTransforming(def.out,ctx)}if(def.type==="object"){for(let key in def.shape)if(isTransforming(def.shape[key],ctx))return!0;return!1}if(def.type==="union"){for(let option of def.options)if(isTransforming(option,ctx))return!0;return!1}if(def.type==="tuple"){for(let item of def.items)if(isTransforming(item,ctx))return!0;if(def.rest&&isTransforming(def.rest,ctx))return!0;return!1}return!1}var createToJSONSchemaMethod=(schema,processors={})=>(params)=>{let ctx=initializeContext({...params,processors});return processSchema(schema,ctx),extractDefs(ctx,schema),finalize(ctx,schema)},createStandardJSONSchemaMethod=(schema,io,processors={})=>(params)=>{let{libraryOptions,target}=params??{},ctx=initializeContext({...libraryOptions??{},target,io,processors});return processSchema(schema,ctx),extractDefs(ctx,schema),finalize(ctx,schema)};var narrowMin=(agg,key,value)=>{if(agg[key]===void 0||value>agg[key])agg[key]=value},narrowMax=(agg,key,value)=>{if(agg[key]===void 0||value<agg[key])agg[key]=value},narrowBoth=(agg,value)=>{narrowMin(agg,"minimum",value),narrowMax(agg,"maximum",value)},addDivisor=(agg,value)=>{if(agg.multipleOf??(agg.multipleOf=[]),!agg.multipleOf.includes(value))agg.multipleOf.push(value)},addPattern=(agg,pattern)=>{agg.patterns??(agg.patterns=new Set),agg.patterns.add(pattern)},intersectMime=(agg,mime)=>{agg.mime=agg.mime?agg.mime.filter((m)=>mime.includes(m)):[...mime]},setFormat=(agg,format)=>{if(agg.format=format,format.includes("int"))agg.isInt=!0},minContributor=(agg,def)=>narrowMin(agg,"minimum",def.minimum),maxContributor=(agg,def)=>narrowMax(agg,"maximum",def.maximum),formatContributor=(ranges)=>(agg,def)=>{setFormat(agg,def.format);let[minimum,maximum]=ranges[def.format];narrowMin(agg,"minimum",minimum),narrowMax(agg,"maximum",maximum)},contributors={greater_than:(agg,def)=>narrowMin(agg,def.inclusive?"minimum":"exclusiveMinimum",def.value),less_than:(agg,def)=>narrowMax(agg,def.inclusive?"maximum":"exclusiveMaximum",def.value),multiple_of:(agg,def)=>addDivisor(agg,def.value),number_format:formatContributor(NUMBER_FORMAT_RANGES),bigint_format:formatContributor(BIGINT_FORMAT_RANGES),min_length:minContributor,max_length:maxContributor,length_equals:(agg,def)=>narrowBoth(agg,def.length),min_size:minContributor,max_size:maxContributor,size_equals:(agg,def)=>narrowBoth(agg,def.size),string_format:(agg,def)=>{if(setFormat(agg,def.format),def.pattern)addPattern(agg,def.pattern);if(def.format==="base64"||def.format==="base64url")agg.contentEncoding=def.format;if(def.local||def.precision===-1)agg.laxFormat=!0},mime_type:(agg,def)=>intersectMime(agg,def.mime)};function aggregateChecks(schema){let agg={},def=schema._zod.def,list=schema._zod.traits.has("$ZodCheck")?[schema,...def.checks??[]]:def.checks??[];for(let ch of list)contributors[ch._zod.def.check]?.(agg,ch._zod.def);let bag=schema._zod.bag;if(bag.minimum!==void 0)narrowMin(agg,"minimum",bag.minimum);if(bag.exclusiveMinimum!==void 0)narrowMin(agg,"exclusiveMinimum",bag.exclusiveMinimum);if(bag.maximum!==void 0)narrowMax(agg,"maximum",bag.maximum);if(bag.exclusiveMaximum!==void 0)narrowMax(agg,"exclusiveMaximum",bag.exclusiveMaximum);if(bag.multipleOf!==void 0)addDivisor(agg,bag.multipleOf);if(bag.format!==void 0){if(agg.format??(agg.format=bag.format),bag.format.includes("int"))agg.isInt=!0}if(bag.mime)intersectMime(agg,bag.mime);for(let pattern of bag.patterns??[])addPattern(agg,pattern);return agg}var formatMap={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},exactPatterns=new Map([[base64Charset,base64],[base64urlCharset,base64url]]),exactPattern=(p)=>exactPatterns.get(p)??p,stringProcessor=(schema,ctx,_json,_params)=>{let json=_json;json.type="string";let{minimum,maximum,format,patterns,contentEncoding,laxFormat}=aggregateChecks(schema);if(typeof minimum==="number")json.minLength=minimum;if(typeof maximum==="number")json.maxLength=maximum;if(format){if(json.format=formatMap[format]??format,json.format==="")delete json.format;if(format==="time"||laxFormat)delete json.format}if(contentEncoding)json.contentEncoding=contentEncoding;if(patterns&&patterns.size>0){let patternList=[...patterns].map(exactPattern);if(patternList.length===1)json.pattern=patternList[0].source;else if(patternList.length>1)json.allOf=[...patternList.map((regex)=>({...ctx.target==="draft-07"||ctx.target==="draft-04"||ctx.target==="openapi-3.0"?{type:"string"}:{},pattern:regex.source}))]}},numberProcessor=(schema,ctx,_json,params)=>{let json=_json,{minimum,maximum,multipleOf,exclusiveMaximum,exclusiveMinimum,isInt}=aggregateChecks(schema);json.type=isInt?"integer":"number";let exMin=typeof exclusiveMinimum==="number"&&exclusiveMinimum>=(minimum??Number.NEGATIVE_INFINITY),exMax=typeof exclusiveMaximum==="number"&&exclusiveMaximum<=(maximum??Number.POSITIVE_INFINITY),legacy=ctx.target==="draft-04"||ctx.target==="openapi-3.0";if(exMin)if(legacy)json.minimum=exclusiveMinimum,json.exclusiveMinimum=!0;else json.exclusiveMinimum=exclusiveMinimum;else if(typeof minimum==="number")json.minimum=minimum;if(exMax)if(legacy)json.maximum=exclusiveMaximum,json.exclusiveMaximum=!0;else json.exclusiveMaximum=exclusiveMaximum;else if(typeof maximum==="number")json.maximum=maximum;if(multipleOf){let divisors=new Set;for(let divisor of multipleOf)if(Number.isFinite(divisor)&&divisor!==0)divisors.add(Math.abs(divisor));else handleUnrepresentable(schema,ctx,json,params,`A multipleOf divisor of ${divisor} cannot be represented in JSON Schema`);let[first,...rest]=divisors;if(first!==void 0)json.multipleOf=first;if(rest.length)json.allOf=[...json.allOf??[],...rest.map((m)=>({multipleOf:m}))]}},booleanProcessor=(_schema,_ctx,json,_params)=>{json.type="boolean"};var neverProcessor=(_schema,_ctx,json,_params)=>{json.not={}};var unknownProcessor=(_schema,_ctx,_json,_params)=>{};var enumProcessor=(schema,_ctx,json,_params)=>{let def=schema._zod.def,values=getEnumValues(def.entries);if(values.length===0){json.not={};return}if(values.every((v)=>typeof v==="number"))json.type="number";if(values.every((v)=>typeof v==="string"))json.type="string";json.enum=values},literalProcessor=(schema,ctx,json,params)=>{let def=schema._zod.def;if(def.values.length===0){json.not={};return}let vals=[];for(let val of def.values)if(val===void 0){if(handleUnrepresentable(schema,ctx,json,params,"Literal `undefined` cannot be represented in JSON Schema"))return}else if(typeof val==="bigint"){if(handleUnrepresentable(schema,ctx,json,params,"BigInt literals cannot be represented in JSON Schema"))return;vals.push(Number(val))}else vals.push(val);if(vals.length===0);else if(vals.length===1){let val=vals[0];if(json.type=val===null?"null":typeof val,ctx.target==="draft-04"||ctx.target==="openapi-3.0")json.enum=[val];else json.const=val}else{if(vals.every((v)=>typeof v==="number"))json.type="number";if(vals.every((v)=>typeof v==="string"))json.type="string";if(vals.every((v)=>typeof v==="boolean"))json.type="boolean";if(vals.every((v)=>v===null))json.type="null";json.enum=vals}};var customProcessor=(schema,ctx,json,params)=>{handleUnrepresentable(schema,ctx,json,params,"Custom types cannot be represented in JSON Schema")};var transformProcessor=(schema,ctx,json,params)=>{handleUnrepresentable(schema,ctx,json,params,"Transforms cannot be represented in JSON Schema")};var arrayProcessor=(schema,ctx,_json,params)=>{let json=_json,def=schema._zod.def,{minimum,maximum}=aggregateChecks(schema);if(typeof minimum==="number")json.minItems=minimum;if(typeof maximum==="number")json.maxItems=maximum;json.type="array",json.items=processSchema(def.element,ctx,{...params,path:[...params.path,"items"]})};function inputOptin(schema){let def=schema._zod.def;if(def.type==="pipe"&&def.in._zod.traits.has("$ZodTransform"))return inputOptin(def.out);if(def.type==="catch")return inputOptin(def.innerType);return schema._zod.optin}var objectProcessor=(schema,ctx,_json,params)=>{let json=_json,def=schema._zod.def,shape=def.shape;if(Object.getOwnPropertySymbols(shape).length&&handleUnrepresentable(schema,ctx,json,params,"Symbol keys cannot be represented in JSON Schema"))return;json.type="object",json.properties={};for(let key in shape)assignProp(json.properties,key,processSchema(shape[key],ctx,{...params,path:[...params.path,"properties",key]}));let requiredKeys=[];for(let key of Object.keys(shape)){let field=def.shape[key];if(ctx.io==="input"?inputOptin(field)===void 0:field._zod.optout===void 0)requiredKeys.push(key)}if(requiredKeys.length>0)json.required=requiredKeys;if(def.catchall?._zod.def.type==="never")json.additionalProperties=!1;else if(!def.catchall){if(ctx.io==="output")json.additionalProperties=!1}else if(def.catchall)json.additionalProperties=processSchema(def.catchall,ctx,{...params,path:[...params.path,"additionalProperties"]})},unionProcessor=(schema,ctx,json,params)=>{let def=schema._zod.def,isExclusive=def.inclusive===!1,options=def.options.map((x,i)=>processSchema(x,ctx,{...params,path:[...params.path,isExclusive?"oneOf":"anyOf",i]}));if(isExclusive)json.oneOf=options;else json.anyOf=options},intersectionProcessor=(schema,ctx,json,params)=>{let def=schema._zod.def,a=processSchema(def.left,ctx,{...params,path:[...params.path,"allOf",0]}),b=processSchema(def.right,ctx,{...params,path:[...params.path,"allOf",1]}),isSimpleIntersection=(val)=>("allOf"in val)&&Object.keys(val).length===1,allOf=[...isSimpleIntersection(a)?a.allOf:[a],...isSimpleIntersection(b)?b.allOf:[b]];json.allOf=allOf,ctx.intersections.push(allOf)};var nullableProcessor=(schema,ctx,json,params)=>{let def=schema._zod.def,inner=processSchema(def.innerType,ctx,params),seen=ctx.seen.get(schema);if(ctx.target==="openapi-3.0")seen.ref=def.innerType,json.nullable=!0;else json.anyOf=[inner,{type:"null"}]},nonoptionalProcessor=(schema,ctx,_json,params)=>{let def=schema._zod.def;processSchema(def.innerType,ctx,params);let seen=ctx.seen.get(schema);seen.ref=def.innerType},UNREPRESENTABLE_DEFAULT=Symbol();function serializeDefaultValue(value,schema,ctx,json,params){let unrepresentable=!1,serialized=JSON.stringify(value,(_,val)=>{if(typeof val!=="bigint")return val;return unrepresentable=!0,null});if(!unrepresentable)return JSON.parse(serialized);return handleUnrepresentable(schema,ctx,json,params,"BigInt defaults cannot be represented in JSON Schema"),UNREPRESENTABLE_DEFAULT}var defaultProcessor=(schema,ctx,json,params)=>{let def=schema._zod.def;processSchema(def.innerType,ctx,params);let seen=ctx.seen.get(schema);seen.ref=def.innerType;let value=serializeDefaultValue(def.defaultValue,schema,ctx,json,params);if(value!==UNREPRESENTABLE_DEFAULT)json.default=value},prefaultProcessor=(schema,ctx,json,params)=>{let def=schema._zod.def;processSchema(def.innerType,ctx,params);let seen=ctx.seen.get(schema);if(seen.ref=def.innerType,ctx.io!=="input")return;let value=serializeDefaultValue(def.defaultValue,schema,ctx,json,params);if(value!==UNREPRESENTABLE_DEFAULT)json._prefault=value},catchProcessor=(schema,ctx,json,params)=>{let def=schema._zod.def;processSchema(def.innerType,ctx,params);let seen=ctx.seen.get(schema);seen.ref=def.innerType;let catchValue;try{catchValue=def.catchValue(void 0)}catch{handleUnrepresentable(schema,ctx,json,params,"Dynamic catch values are not supported in JSON Schema");return}json.default=catchValue},pipeProcessor=(schema,ctx,_json,params)=>{let def=schema._zod.def,inIsTransform=def.in._zod.traits.has("$ZodTransform"),innerType=ctx.io==="input"?inIsTransform?def.out:def.in:def.out;processSchema(innerType,ctx,params);let seen=ctx.seen.get(schema);seen.ref=innerType},readonlyProcessor=(schema,ctx,json,params)=>{let def=schema._zod.def;processSchema(def.innerType,ctx,params);let seen=ctx.seen.get(schema);seen.ref=def.innerType,json.readOnly=!0};var optionalProcessor=(schema,ctx,_json,params)=>{let def=schema._zod.def;processSchema(def.innerType,ctx,params);let seen=ctx.seen.get(schema);seen.ref=def.innerType};var _installedErrorProtos=new WeakSet([Object.prototype,Error.prototype]);function _lazyMethod(proto,key,make){Object.defineProperty(proto,key,{configurable:!0,enumerable:!1,get(){let value=make(this);return Object.defineProperty(this,key,{value,configurable:!0,writable:!0}),value},set(value){Object.defineProperty(this,key,{value,configurable:!0,writable:!0})}})}var initializer2=(inst,issues)=>{$ZodError.init(inst,issues),inst.name="ZodError";let proto=Object.getPrototypeOf(inst);if(_installedErrorProtos.has(proto))return;_installedErrorProtos.add(proto),_lazyMethod(proto,"format",(self)=>(mapper)=>formatError(self,mapper)),_lazyMethod(proto,"flatten",(self)=>(mapper)=>flattenError(self,mapper)),_lazyMethod(proto,"addIssue",(self)=>(issue)=>{self.issues.push(issue),self.message=JSON.stringify(self.issues,jsonStringifyReplacer,2)}),_lazyMethod(proto,"addIssues",(self)=>(issues)=>{self.issues.push(...issues),self.message=JSON.stringify(self.issues,jsonStringifyReplacer,2)}),Object.defineProperty(proto,"isEmpty",{configurable:!0,enumerable:!1,get(){return this.issues.length===0}})};var ZodRealError=$constructor("ZodError",initializer2,void 0,{Parent:Error});var parse2=_parse(ZodRealError),parseAsync=_parseAsync(ZodRealError),safeParse=_safeParse(ZodRealError),safeParseAsync=_safeParseAsync(ZodRealError),encode=_encode(ZodRealError),decode=_decode(ZodRealError),encodeAsync=_encodeAsync(ZodRealError),decodeAsync=_decodeAsync(ZodRealError),safeEncode=_safeEncode(ZodRealError),safeDecode=_safeDecode(ZodRealError),safeEncodeAsync=_safeEncodeAsync(ZodRealError),safeDecodeAsync=_safeDecodeAsync(ZodRealError);function _ensureDefaultLocale(){if(!globalConfig.localeError)config(en_default())}function _ensureDefaultMemoizer(){if(!globalConfig.memoizer)config({memoizer:memoizer()})}var ZodType=$constructor("ZodType",(inst,def)=>(_ensureDefaultLocale(),$ZodType.init(inst,def),inst.def=def,inst.type=def.type,inst),{check(...chks){let def=this.def;return this.clone(mergeDefs(def,{checks:[...def.checks??[],...chks.map((ch)=>typeof ch==="function"?{_zod:{check:ch,def:{check:"custom"},onattach:[]}}:ch)]}),{parent:!0})},with(...chks){return this.check(...chks)},clone(def,params){return clone(this,def,params)},brand(){return this},register(reg,meta){return reg.add(this,meta),this},refine(check,params){return this.check(refine(check,params))},superRefine(refinement,params){return this.check(superRefine(refinement,params))},overwrite(fn){return this.check(_overwrite(fn))},optional(){return optional(this)},exactOptional(){return exactOptional(this)},nullable(){return nullable(this)},nullish(){return optional(nullable(this))},nonoptional(params){return nonoptional(this,params)},array(){return array(this)},or(arg){return union([this,arg])},and(arg){return intersection(this,arg)},transform(tx){return pipe(this,transform(tx))},default(d){return _default(this,d)},prefault(d){return prefault(this,d)},catch(params){return _catch(this,params)},pipe(target){return pipe(this,target)},readonly(){return readonly(this)},describe(description){let cl=this.clone();return globalRegistry.add(cl,{description}),cl},meta(...args){if(args.length===0)return globalRegistry.get(this);let cl=this.clone();return globalRegistry.add(cl,args[0]),cl},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(fn,...args){return args.length===0?fn(this):fn(this,...args)},get "~standard"(){return hide(this,"~standard",{...standardProps(this),jsonSchema:{input:createStandardJSONSchemaMethod(this,"input"),output:createStandardJSONSchemaMethod(this,"output")}})},set "~standard"(value){own(this,"~standard",value)},parse:function _parse(data,params){return parse2(this,data,params,{callee:_parse})},parseAsync:async function _parseAsync(data,params){return await parseAsync(this,data,params,{callee:_parseAsync})},safeParse(data,params){return safeParse(this,data,params)},async safeParseAsync(data,params){return safeParseAsync(this,data,params)},get spa(){return this?.safeParseAsync},set spa(value){own(this,"spa",value)},validate(data,params){return validate(this,data,params)},validateAsync(data,params){return validateAsync(this,data,params)},encode:function _encode(data,params){return encode(this,data,params,{callee:_encode})},decode:function _decode(data,params){return decode(this,data,params,{callee:_decode})},encodeAsync:async function _encodeAsync(data,params){return await encodeAsync(this,data,params,{callee:_encodeAsync})},decodeAsync:async function _decodeAsync(data,params){return await decodeAsync(this,data,params,{callee:_decodeAsync})},safeEncode(data,params){return safeEncode(this,data,params)},safeDecode(data,params){return safeDecode(this,data,params)},async safeEncodeAsync(data,params){return safeEncodeAsync(this,data,params)},async safeDecodeAsync(data,params){return safeDecodeAsync(this,data,params)},toJSONSchema(params){return createToJSONSchemaMethod(this,{})(params)},get description(){return globalRegistry.get(this)?.description},get _def(){return this._zod.def}}),_ZodString=$constructor("_ZodString",(inst,def)=>{$ZodString.init(inst,def),ZodType.init(inst,def),inst._zod.processJSONSchema=(ctx,json,params)=>stringProcessor(inst,ctx,json,params)},derived({format:(inst)=>aggregateChecks(inst).format??null,minLength:(inst)=>aggregateChecks(inst).minimum??null,maxLength:(inst)=>aggregateChecks(inst).maximum??null},{regex(...args){return this.check(_regex(...args))},includes(...args){return this.check(_includes(...args))},startsWith(...args){return this.check(_startsWith(...args))},endsWith(...args){return this.check(_endsWith(...args))},min(...args){return this.check(_minLength(...args))},max(...args){return this.check(_maxLength(...args))},length(...args){return this.check(_length(...args))},nonempty(...args){return this.check(_minLength(1,...args))},lowercase(params){return this.check(_lowercase(params))},uppercase(params){return this.check(_uppercase(params))},trim(){return this.check(_trim())},normalize(...args){return this.check(_normalize(...args))},toLowerCase(){return this.check(_toLowerCase())},toUpperCase(){return this.check(_toUpperCase())},slugify(){return this.check(_slugify())}})),ZodString=$constructor("ZodString",(inst,def)=>{$ZodString.init(inst,def),_ZodString.init(inst,def)},{email(params){return this.check(_email(ZodEmail,params))},url(params){return this.check(_url(ZodURL,params))},jwt(params){return this.check(_jwt(ZodJWT,params))},emoji(params){return this.check(_emoji2(ZodEmoji,params))},guid(params){return this.check(_guid(ZodGUID,params))},uuid(params){return this.check(_uuid(ZodUUID,params))},uuidv4(params){return this.check(_uuidv4(ZodUUID,params))},uuidv6(params){return this.check(_uuidv6(ZodUUID,params))},uuidv7(params){return this.check(_uuidv7(ZodUUID,params))},nanoid(params){return this.check(_nanoid(ZodNanoID,params))},cuid(params){return this.check(_cuid(ZodCUID,params))},cuid2(params){return this.check(_cuid2(ZodCUID2,params))},ulid(params){return this.check(_ulid(ZodULID,params))},base64(params){return this.check(_base64(ZodBase64,params))},base64url(params){return this.check(_base64url(ZodBase64URL,params))},xid(params){return this.check(_xid(ZodXID,params))},ksuid(params){return this.check(_ksuid(ZodKSUID,params))},ipv4(params){return this.check(_ipv4(ZodIPv4,params))},ipv6(params){return this.check(_ipv6(ZodIPv6,params))},cidrv4(params){return this.check(_cidrv4(ZodCIDRv4,params))},cidrv6(params){return this.check(_cidrv6(ZodCIDRv6,params))},e164(params){return this.check(_e164(ZodE164,params))},datetime(params){return this.check(_isoDateTime(ZodISODateTime,params))},date(params){return this.check(_isoDate(ZodISODate,params))},time(params){return this.check(_isoTime(ZodISOTime,params))},duration(params){return this.check(_isoDuration(ZodISODuration,params))}});function string2(params){return _string(ZodString,params)}var ZodStringFormat=$constructor("ZodStringFormat",(inst,def)=>{$ZodStringFormat.init(inst,def),_ZodString.init(inst,def)}),ZodISODateTime=$constructor("ZodISODateTime",(inst,def)=>{$ZodISODateTime.init(inst,def),ZodStringFormat.init(inst,def)}),ZodISODate=$constructor("ZodISODate",(inst,def)=>{$ZodISODate.init(inst,def),ZodStringFormat.init(inst,def)}),ZodISOTime=$constructor("ZodISOTime",(inst,def)=>{$ZodISOTime.init(inst,def),ZodStringFormat.init(inst,def)}),ZodISODuration=$constructor("ZodISODuration",(inst,def)=>{$ZodISODuration.init(inst,def),ZodStringFormat.init(inst,def)}),ZodEmail=$constructor("ZodEmail",(inst,def)=>{$ZodEmail.init(inst,def),ZodStringFormat.init(inst,def)});var ZodGUID=$constructor("ZodGUID",(inst,def)=>{$ZodGUID.init(inst,def),ZodStringFormat.init(inst,def)});var ZodUUID=$constructor("ZodUUID",(inst,def)=>{$ZodUUID.init(inst,def),ZodStringFormat.init(inst,def)});var ZodURL=$constructor("ZodURL",(inst,def)=>{$ZodURL.init(inst,def),ZodStringFormat.init(inst,def)});var ZodEmoji=$constructor("ZodEmoji",(inst,def)=>{$ZodEmoji.init(inst,def),ZodStringFormat.init(inst,def)});var ZodNanoID=$constructor("ZodNanoID",(inst,def)=>{$ZodNanoID.init(inst,def),ZodStringFormat.init(inst,def)});var ZodCUID=$constructor("ZodCUID",(inst,def)=>{$ZodCUID.init(inst,def),ZodStringFormat.init(inst,def)});var ZodCUID2=$constructor("ZodCUID2",(inst,def)=>{$ZodCUID2.init(inst,def),ZodStringFormat.init(inst,def)});var ZodULID=$constructor("ZodULID",(inst,def)=>{$ZodULID.init(inst,def),ZodStringFormat.init(inst,def)});var ZodXID=$constructor("ZodXID",(inst,def)=>{$ZodXID.init(inst,def),ZodStringFormat.init(inst,def)});var ZodKSUID=$constructor("ZodKSUID",(inst,def)=>{$ZodKSUID.init(inst,def),ZodStringFormat.init(inst,def)});var ZodIPv4=$constructor("ZodIPv4",(inst,def)=>{$ZodIPv4.init(inst,def),ZodStringFormat.init(inst,def)});var ZodIPv6=$constructor("ZodIPv6",(inst,def)=>{$ZodIPv6.init(inst,def),ZodStringFormat.init(inst,def)});var ZodCIDRv4=$constructor("ZodCIDRv4",(inst,def)=>{$ZodCIDRv4.init(inst,def),ZodStringFormat.init(inst,def)});var ZodCIDRv6=$constructor("ZodCIDRv6",(inst,def)=>{$ZodCIDRv6.init(inst,def),ZodStringFormat.init(inst,def)});var ZodBase64=$constructor("ZodBase64",(inst,def)=>{$ZodBase64.init(inst,def),ZodStringFormat.init(inst,def)});var ZodBase64URL=$constructor("ZodBase64URL",(inst,def)=>{$ZodBase64URL.init(inst,def),ZodStringFormat.init(inst,def)});var ZodE164=$constructor("ZodE164",(inst,def)=>{$ZodE164.init(inst,def),ZodStringFormat.init(inst,def)});var ZodJWT=$constructor("ZodJWT",(inst,def)=>{$ZodJWT.init(inst,def),ZodStringFormat.init(inst,def)});var ZodNumber=$constructor("ZodNumber",(inst,def)=>{$ZodNumber.init(inst,def),ZodType.init(inst,def),inst._zod.processJSONSchema=(ctx,json,params)=>numberProcessor(inst,ctx,json,params),inst.isFinite=!0},derived({minValue:(inst)=>{let{minimum,exclusiveMinimum}=aggregateChecks(inst);return Math.max(minimum??Number.NEGATIVE_INFINITY,exclusiveMinimum??Number.NEGATIVE_INFINITY)},maxValue:(inst)=>{let{maximum,exclusiveMaximum}=aggregateChecks(inst);return Math.min(maximum??Number.POSITIVE_INFINITY,exclusiveMaximum??Number.POSITIVE_INFINITY)},isInt:(inst)=>{let{isInt,multipleOf}=aggregateChecks(inst);return!!isInt||!!multipleOf?.some(Number.isSafeInteger)},format:(inst)=>aggregateChecks(inst).format??null},{gt(value,params){return this.check(_gt(value,params))},gte(value,params){return this.check(_gte(value,params))},min(value,params){return this.check(_gte(value,params))},lt(value,params){return this.check(_lt(value,params))},lte(value,params){return this.check(_lte(value,params))},max(value,params){return this.check(_lte(value,params))},int(params){return this.check(int(params))},safe(params){return this.check(int(params))},positive(params){return this.check(_gt(0,params))},nonnegative(params){return this.check(_gte(0,params))},negative(params){return this.check(_lt(0,params))},nonpositive(params){return this.check(_lte(0,params))},multipleOf(value,params){return this.check(_multipleOf(value,params))},step(value,params){return this.check(_multipleOf(value,params))},finite(){return this}}));function number2(params){return _number(ZodNumber,params)}var ZodNumberFormat=$constructor("ZodNumberFormat",(inst,def)=>{$ZodNumberFormat.init(inst,def),ZodNumber.init(inst,def)});function int(params){return _int(ZodNumberFormat,params)}var ZodBoolean=$constructor("ZodBoolean",(inst,def)=>{$ZodBoolean.init(inst,def),ZodType.init(inst,def),inst._zod.processJSONSchema=(ctx,json,params)=>booleanProcessor(inst,ctx,json,params)});function boolean2(params){return _boolean(ZodBoolean,params)}var ZodUnknown=$constructor("ZodUnknown",(inst,def)=>{$ZodUnknown.init(inst,def),ZodType.init(inst,def),inst._zod.processJSONSchema=(ctx,json,params)=>unknownProcessor(inst,ctx,json,params)});function unknown(){return _unknown(ZodUnknown)}var ZodNever=$constructor("ZodNever",(inst,def)=>{$ZodNever.init(inst,def),ZodType.init(inst,def),inst._zod.processJSONSchema=(ctx,json,params)=>neverProcessor(inst,ctx,json,params)});function never(params){return _never(ZodNever,params)}var ZodArray=$constructor("ZodArray",(inst,def)=>{_ensureDefaultMemoizer(),$ZodArray.init(inst,def),ZodType.init(inst,def),inst._zod.processJSONSchema=(ctx,json,params)=>arrayProcessor(inst,ctx,json,params),inst.element=def.element},{min(n,params){return this.check(_minLength(n,params))},nonempty(params){return this.check(_minLength(1,params))},max(n,params){return this.check(_maxLength(n,params))},length(n,params){return this.check(_length(n,params))},unwrap(){return this.element}});function array(element,params){return _array(ZodArray,element,params)}var ZodObject=$constructor("ZodObject",(inst,def)=>{_ensureDefaultMemoizer(),$ZodObjectJIT.init(inst,def),ZodType.init(inst,def),inst._zod.processJSONSchema=(ctx,json,params)=>objectProcessor(inst,ctx,json,params),installLazyProp(inst,"shape",(self)=>self._zod.def.shape,!1)},{keyof(){return _enum(Object.keys(this._zod.def.shape))},catchall(catchall){return this.clone(mergeDefs(this._zod.def,{catchall}))},passthrough(){return this.clone(mergeDefs(this._zod.def,{catchall:unknown()}))},loose(){return this.clone(mergeDefs(this._zod.def,{catchall:unknown()}))},strict(){return this.clone(mergeDefs(this._zod.def,{catchall:never()}))},strip(){return this.clone(mergeDefs(this._zod.def,{catchall:void 0}))},extend(incoming){return extend(this,incoming)},safeExtend(incoming){return safeExtend(this,incoming)},merge(other){return merge(this,other)},pick(mask){return pick(this,mask)},omit(mask){return omit(this,mask)},partial(...args){return partial(ZodOptional,this,args[0])},exactPartial(...args){return partial(ZodExactOptional,this,args[0],"exactPartial")},required(...args){return required(ZodNonOptional,this,args[0])}});function object(shape,params){let def={type:"object",shape:shape??{},...normalizeParams(params)};return new ZodObject(def)}var ZodUnion=$constructor("ZodUnion",(inst,def)=>{$ZodUnion.init(inst,def),ZodType.init(inst,def),inst._zod.processJSONSchema=(ctx,json,params)=>unionProcessor(inst,ctx,json,params),inst.options=def.options});function union(options,params){return new ZodUnion({type:"union",options,...normalizeParams(params)})}var ZodIntersection=$constructor("ZodIntersection",(inst,def)=>{$ZodIntersection.init(inst,def),ZodType.init(inst,def),inst._zod.processJSONSchema=(ctx,json,params)=>intersectionProcessor(inst,ctx,json,params)});function intersection(left,right){return new ZodIntersection({type:"intersection",left,right})}var ZodEnum=$constructor("ZodEnum",(inst,def)=>{$ZodEnum.init(inst,def),ZodType.init(inst,def),inst._zod.processJSONSchema=(ctx,json,params)=>enumProcessor(inst,ctx,json,params),inst.enum=def.entries,inst.options=[...inst._zod.values];let keys=new Set(Object.keys(def.entries));inst.extract=(values,params)=>{let newEntries={};for(let value of values)if(keys.has(value))newEntries[value]=def.entries[value];else throw Error(`Key ${value} not found in enum`);return new ZodEnum({...def,checks:[],...normalizeParams(params),entries:newEntries})},inst.exclude=(values,params)=>{let newEntries={...def.entries};for(let value of values)if(keys.has(value))delete newEntries[value];else throw Error(`Key ${value} not found in enum`);return new ZodEnum({...def,checks:[],...normalizeParams(params),entries:newEntries})}});function _enum(values,params){let entries=Array.isArray(values)?Object.fromEntries(values.map((v)=>[v,v])):values;return new ZodEnum({type:"enum",entries,...normalizeParams(params)})}var ZodLiteral=$constructor("ZodLiteral",(inst,def)=>{$ZodLiteral.init(inst,def),ZodType.init(inst,def),inst._zod.processJSONSchema=(ctx,json,params)=>literalProcessor(inst,ctx,json,params),inst.values=new Set(def.values),Object.defineProperty(inst,"value",{get(){if(def.values.length>1)throw Error("This schema contains multiple valid literal values. Use `.values` instead.");return def.values[0]}})});function literal(value,params){return new ZodLiteral({type:"literal",values:Array.isArray(value)?value:[value],...normalizeParams(params)})}var ZodTransform=$constructor("ZodTransform",(inst,def)=>{_ensureDefaultMemoizer(),$ZodTransform.init(inst,def),ZodType.init(inst,def),inst._zod.processJSONSchema=(ctx,json,params)=>transformProcessor(inst,ctx,json,params),inst._zod.parse=(payload,_ctx)=>{if(_ctx.direction==="backward")throw new $ZodEncodeError(inst.constructor.name);payload.addIssue=(issue2)=>{if(typeof issue2==="string")payload.issues.push(issue(issue2,payload.value,def));else{let _issue=issue2;if(_issue.fatal)_issue.continue=!1;if(_issue.code??(_issue.code="custom"),!("input"in _issue))_issue.input=payload.value;_issue.inst??(_issue.inst=inst),payload.issues.push(issue(_issue))}};let output=def.transform(payload.value,payload);if(output instanceof Promise)return output.then((output)=>(payload.value=output,payload));return payload.value=output,payload}});function transform(fn){return new ZodTransform({type:"transform",transform:fn})}var ZodOptional=$constructor("ZodOptional",(inst,def)=>{$ZodOptional.init(inst,def),ZodType.init(inst,def),inst._zod.processJSONSchema=(ctx,json,params)=>optionalProcessor(inst,ctx,json,params),inst.unwrap=()=>inst._zod.def.innerType});function optional(innerType){return new ZodOptional({type:"optional",innerType})}var ZodExactOptional=$constructor("ZodExactOptional",(inst,def)=>{$ZodExactOptional.init(inst,def),ZodType.init(inst,def),inst._zod.processJSONSchema=(ctx,json,params)=>optionalProcessor(inst,ctx,json,params),inst.unwrap=()=>inst._zod.def.innerType});function exactOptional(innerType){return new ZodExactOptional({type:"optional",innerType})}var ZodNullable=$constructor("ZodNullable",(inst,def)=>{$ZodNullable.init(inst,def),ZodType.init(inst,def),inst._zod.processJSONSchema=(ctx,json,params)=>nullableProcessor(inst,ctx,json,params),inst.unwrap=()=>inst._zod.def.innerType});function nullable(innerType){return new ZodNullable({type:"nullable",innerType})}var ZodDefault=$constructor("ZodDefault",(inst,def)=>{$ZodDefault.init(inst,def),ZodType.init(inst,def),inst._zod.processJSONSchema=(ctx,json,params)=>defaultProcessor(inst,ctx,json,params),inst.unwrap=()=>inst._zod.def.innerType,inst.removeDefault=inst.unwrap});function _default(innerType,defaultValue){return new ZodDefault({type:"default",innerType,get defaultValue(){return typeof defaultValue==="function"?defaultValue():shallowClone(defaultValue)}})}var ZodPrefault=$constructor("ZodPrefault",(inst,def)=>{$ZodPrefault.init(inst,def),ZodType.init(inst,def),inst._zod.processJSONSchema=(ctx,json,params)=>prefaultProcessor(inst,ctx,json,params),inst.unwrap=()=>inst._zod.def.innerType});function prefault(innerType,defaultValue){return new ZodPrefault({type:"prefault",innerType,get defaultValue(){return typeof defaultValue==="function"?defaultValue():shallowClone(defaultValue)}})}var ZodNonOptional=$constructor("ZodNonOptional",(inst,def)=>{$ZodNonOptional.init(inst,def),ZodType.init(inst,def),inst._zod.processJSONSchema=(ctx,json,params)=>nonoptionalProcessor(inst,ctx,json,params),inst.unwrap=()=>inst._zod.def.innerType});function nonoptional(innerType,params){return new ZodNonOptional({type:"nonoptional",innerType,...normalizeParams(params)})}var ZodCatch=$constructor("ZodCatch",(inst,def)=>{$ZodCatch.init(inst,def),ZodType.init(inst,def),inst._zod.processJSONSchema=(ctx,json,params)=>catchProcessor(inst,ctx,json,params),inst.unwrap=()=>inst._zod.def.innerType,inst.removeCatch=inst.unwrap});function _catch(innerType,catchValue){return new ZodCatch({type:"catch",innerType,catchValue:typeof catchValue==="function"?catchValue:constantCatch(catchValue)})}var ZodPipe=$constructor("ZodPipe",(inst,def)=>{$ZodPipe.init(inst,def),ZodType.init(inst,def),inst._zod.processJSONSchema=(ctx,json,params)=>pipeProcessor(inst,ctx,json,params),inst.in=def.in,inst.out=def.out});function pipe(in_,out){return new ZodPipe({type:"pipe",in:in_,out})}var ZodReadonly=$constructor("ZodReadonly",(inst,def)=>{$ZodReadonly.init(inst,def),ZodType.init(inst,def),inst._zod.processJSONSchema=(ctx,json,params)=>readonlyProcessor(inst,ctx,json,params),inst.unwrap=()=>inst._zod.def.innerType});function readonly(innerType){return new ZodReadonly({type:"readonly",innerType})}var ZodCustom=$constructor("ZodCustom",(inst,def)=>{$ZodCustom.init(inst,def),ZodType.init(inst,def),inst._zod.processJSONSchema=(ctx,json,params)=>customProcessor(inst,ctx,json,params)});function refine(fn,_params={}){return _refine(ZodCustom,fn,_params)}function superRefine(fn,params){return _superRefine(fn,params)}import{stripVTControlCharacters as stripVTControlCharacters4}from"node:util";function terminalText(value){return stripVTControlCharacters4(value).replace(/[\p{C}\p{Zl}\p{Zp}]/gu,"")}class SignInError extends Error{retryable;name="SignInError";constructor(message,retryable=!1){super(message);this.retryable=retryable}}class RequestFailure extends SignInError{notSent;constructor(notSent){super("Unable to complete the service request. Check the connection and retry.",!0);this.notSent=notSent}}var platformSchema=_enum(["macos","linux","windows"]),nonempty=string2().min(1),timestamp=string2().datetime({offset:!0}),tokenSchema=object({accessToken:nonempty,accessTokenExpiresAt:timestamp,refreshToken:nonempty}),grantSchema=tokenSchema.extend({device:object({id:nonempty,name:nonempty}),offlineGrant:nonempty.optional()}),credentialSchema=grantSchema.extend({signingPrivateKey:nonempty,sealingPrivateKey:nonempty,refreshState:literal("uncertain").optional()}),deviceCodeSchema=object({deviceCode:string2().regex(/^dc\.[A-Za-z0-9_-]{43}$/),userCode:string2().regex(/^[BCDFGHJKLMNPQRSTVWXZ]{4}-[BCDFGHJKLMNPQRSTVWXZ]{4}$/),matchingCode:string2().regex(/^\d{3} \d{3}$/),verificationUri:string2().transform(terminalText).pipe(string2().url()),expiresAt:timestamp,intervalSeconds:number2().int().min(1).max(60)}),envelopeSchema=object({error:object({code:nonempty,message:string2(),retryable:boolean2(),requestId:string2(),detail:unknown().optional()})}),limitSchema=object({reason:literal("device_limit"),managementToken:nonempty,used:number2().int().nonnegative(),limit:number2().int().nonnegative()}),deviceListSchema=object({devices:array(object({id:nonempty,name:nonempty,revokedAt:timestamp.nullable()}))});class ApiRefusal extends SignInError{status;code;#detail;#retryAfter;constructor(code,status,detail,retryAfter=null){super("The service refused this request. Sign in again or check your account.",status===429||status>=500);this.status=status;this.code=["unauthorized","account_deleted","reauth_required","invalid_grant","device_revoked","entitlement_required","authorization_pending","slow_down","access_denied","expired_token","rate_limited","internal","unavailable","forbidden","invalid_request","not_found"].includes(code)?code:"unknown",this.#detail=detail,this.#retryAfter=retryAfter}get detail(){return this.#detail}retryDelay(now,fallback){let raw=this.#retryAfter,delay=raw===null?Number.NaN:/^\d+$/.test(raw)?Number(raw)*1000:Date.parse(raw)-now;return Math.min(60000,Math.max(fallback,Number.isFinite(delay)?delay:fallback))}}function parseReply(schema,value){let result=schema.safeParse(value);if(!result.success)throw new SignInError("The service returned an invalid response.");return result.data}function serviceOrigin(value){let url;try{url=new URL(value)}catch{throw new SignInError("Invalid service URL.")}let loopback=url.protocol==="http:"&&url.hostname==="127.0.0.1"&&url.port!=="";if(url.protocol!=="https:"&&!loopback||url.username||url.password||url.search||url.hash||url.pathname!=="/")throw new SignInError("Service URLs must be HTTPS origins, or http://127.0.0.1:<port> for local testing.");return url.origin}async function requestApi(api,path,init,signal){let response,body;try{response=await fetch(`${api}${path}`,{...init,redirect:"error",signal:signal?AbortSignal.any([signal,AbortSignal.timeout(30000)]):AbortSignal.timeout(30000)})}catch(error){let cause=error instanceof Error&&error.cause instanceof Error?error.cause:error,code=cause instanceof Error?Reflect.get(cause,"code"):void 0;throw new RequestFailure(typeof code==="string"&&["ENOTFOUND","ECONNREFUSED","ENETUNREACH","EHOSTUNREACH","EAI_AGAIN","ConnectionRefused","EADDRNOTAVAIL","ENETDOWN","EHOSTDOWN","UND_ERR_CONNECT_TIMEOUT","ERR_TLS_HANDSHAKE_TIMEOUT","DEPTH_ZERO_SELF_SIGNED_CERT","CERT_HAS_EXPIRED","ERR_TLS_CERT_ALTNAME_INVALID","UNABLE_TO_VERIFY_LEAF_SIGNATURE","SELF_SIGNED_CERT_IN_CHAIN","CERT_NOT_YET_VALID","UNABLE_TO_GET_ISSUER_CERT","UNABLE_TO_GET_ISSUER_CERT_LOCALLY","CERT_SIGNATURE_FAILURE","CERT_UNTRUSTED","CERT_REJECTED"].includes(code))}if(response.status===204)return null;try{body=await response.json()}catch{throw new RequestFailure(!1)}if(response.ok)return body;let envelope=envelopeSchema.safeParse(body);if(!envelope.success)throw new SignInError("The service returned an invalid error response.");let error=envelope.data.error,detail=limitSchema.safeParse(error.detail);throw new ApiRefusal(error.code,response.status,error.code==="entitlement_required"&&detail.success?detail.data:void 0,response.headers.get("retry-after"))}var jsonRequest=(body)=>({method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(body)});function deviceName(host=hostname()){return[...`omo CLI on ${host}`.replace(/[\p{Cc}\p{Zl}\p{Zp}\p{Cf}\u3164\u115F\u1160\uFFA0]/gu,"").trim()].slice(0,64).join("").trim()}function devicePlatform(){switch(process.platform){case"darwin":return"macos";case"linux":return"linux";case"win32":return"windows";default:throw new SignInError("This platform is not supported for OmO sign-in.")}}import{setTimeout as setTimeout2}from"node:timers/promises";import{generateKeyPairSync}from"node:crypto";function generateDeviceKeys(){let signing=generateKeyPairSync("ed25519"),sealing=generateKeyPairSync("x25519"),signingKey=signing.publicKey.export({format:"jwk"}).x,sealingKey=sealing.publicKey.export({format:"jwk"}).x;if(!signingKey||!sealingKey)throw new SignInError("Unable to generate device keys.");return{public:{signingKey,sealingKey},private:{signingPrivateKey:signing.privateKey.export({format:"der",type:"pkcs8"}).toString("base64"),sealingPrivateKey:sealing.privateKey.export({format:"der",type:"pkcs8"}).toString("base64")}}}async function loginDevice(session,options){await session.ready();let keys=generateDeviceKeys(),minted=parseReply(deviceCodeSchema,await session.request("/v1/device/code",jsonRequest({client:{name:options.name,platform:options.platform}}))),uri=new URL(minted.verificationUri);if(uri.protocol!=="https:"&&!(uri.protocol==="http:"&&uri.hostname==="127.0.0.1"&&uri.port!==""))throw new SignInError("The service returned an unsafe verification URL.");options.show({verificationUri:minted.verificationUri,userCode:minted.userCode,matchingCode:minted.matchingCode});let now=options.now??Date.now,sleep=options.sleep??((ms)=>setTimeout2(ms,void 0,{signal:session.signal})),expiresAt=Date.parse(minted.expiresAt),interval=minted.intervalSeconds*1000;while(now()<expiresAt){if(await sleep(Math.min(interval,expiresAt-now())),session.signal?.throwIfAborted(),now()>=expiresAt)break;try{let grant=parseReply(grantSchema,await session.request("/v1/device/token",jsonRequest({deviceCode:minted.deviceCode,...keys.public})));await session.save({...grant,...keys.private});return}catch(error){if(!(error instanceof ApiRefusal))throw error;if(error.status===400&&error.code==="authorization_pending")continue;if(error.status===400&&error.code==="slow_down"){interval+=5000;continue}if(error.status===429){interval=error.retryDelay(now(),Math.min(60000,interval+5000));continue}if(error.detail!==void 0){if(await session.removeForLimit(error,options.chooseDevice))continue;throw new SignInError("Sign-in cancelled. No device was removed.")}if(["access_denied","expired_token","invalid_grant"].includes(error.code))throw new SignInError("Device sign-in was denied or expired. Run omo login again for a new code.");throw error}}throw new SignInError("Device sign-in expired. Run omo login again for a new code.")}import{createHash}from"node:crypto";import{spawn}from"node:child_process";var DEFAULT_COLLECTION="/org/freedesktop/secrets/aliases/default",PROBE_TIMEOUT_MS=1e4,parseLockedReply=(stdout)=>{let match=/<\s*(true|false)\s*>/.exec(stdout);if(match===null)return null;return match[1]==="true"?"locked":"unlocked"},probeSecretServiceLock=()=>new Promise((resolve)=>{let child=spawn("gdbus",["call","--session","--dest","org.freedesktop.secrets","--object-path",DEFAULT_COLLECTION,"--method","org.freedesktop.DBus.Properties.Get","org.freedesktop.Secret.Collection","Locked"],{stdio:["ignore","pipe","ignore"]}),stdout="",timer=setTimeout(()=>{child.kill(),resolve("unknown")},PROBE_TIMEOUT_MS);child.stdout.on("data",(chunk)=>{stdout+=chunk.toString()}),child.on("error",()=>{clearTimeout(timer),resolve("unknown")}),child.on("close",(code)=>{clearTimeout(timer),resolve(code===0?parseLockedReply(stdout)??"absent":"absent")})});class CredentialStoreError extends SignInError{}class KeychainLockedError extends CredentialStoreError{}class SecretServiceUnavailableError extends CredentialStoreError{}var LOCKED=/-25308|errSecInteractionNotAllowed|interaction is not allowed|locked collection/i,UNLOCKED_REUSE_MS=30000,fallbackNoticed=!1,stderrNoticeOncePerProcess=(message)=>{if(fallbackNoticed)return;fallbackNoticed=!0,process.stderr.write(`${message}
116
- `)};var isLocked=(error)=>error instanceof Error&&(LOCKED.test(error.message)||LOCKED.test(String(error.code??"")));function credentialId(api){return createHash("sha256").update(serviceOrigin(api)).digest("hex")}function createCredentialStore(api,secrets=typeof Bun>"u"?null:Bun.secrets,platform=process.platform,lockProbe=probeSecretServiceLock,notice=stderrNoticeOncePerProcess){if(!secrets)throw new SignInError("OmO sign-in needs Bun 1.4 or newer with OS credential storage. No file fallback is available.");let platformName=platform==="darwin"?"macOS Keychain":platform==="linux"?"Linux Secret Service (libsecret and an unlocked keyring)":platform==="win32"?"Windows Credential Manager":null;if(platformName===null)throw new SignInError("This platform has no supported OS credential store.");let key={service:"omo-cli",name:credentialId(api)},unavailable=(error)=>isLocked(error)?new KeychainLockedError(`${platformName} is locked. Unlock it, then try again. Credentials are never saved to a file.`):new CredentialStoreError(`Cannot access ${platformName}. Unlock or enable the OS credential store and try again. Credentials are never saved to a file.`),unlockedUntil=0,noticed=!1,assertUsable=async()=>{if(platform!=="linux"||Date.now()<unlockedUntil)return;let lock=await lockProbe();if(lock==="locked")throw new KeychainLockedError(`${platformName} is locked. Unlock it, then try again. Credentials are never saved to a file.`);if(lock==="unlocked"){unlockedUntil=Date.now()+UNLOCKED_REUSE_MS;return}if(!noticed)noticed=!0,notice("omo: could not check whether the keyring is locked (gdbus or the Secret Service did not answer); using libsecret directly.")};return{async read(){await assertUsable();let value;try{value=await secrets.get(key)}catch(error){throw unavailable(error)}if(value===null)return null;try{return credentialSchema.parse(JSON.parse(value))}catch{throw new SignInError("Stored sign-in data is invalid. Run omo logout, then omo login.")}},async write(value){await assertUsable();try{await secrets.set({...key,value:JSON.stringify(credentialSchema.parse(value))})}catch(error){throw unavailable(error)}},async clear(){await assertUsable();try{await secrets.delete(key)}catch(error){throw unavailable(error)}}}}import{createHash as createHash2,randomBytes,timingSafeEqual}from"node:crypto";import{createServer}from"node:http";class BrowserUnavailable extends SignInError{}async function authorize(options){let verifier=randomBytes(32).toString("base64url"),state=randomBytes(32).toString("base64url"),answer=Promise.withResolvers(),abort=()=>answer.reject(new SignInError("Browser sign-in cancelled or timed out.")),accepted=!1,origin="",server=createServer((request,response)=>{response.setHeader("cache-control","no-store"),response.setHeader("referrer-policy","no-referrer"),response.setHeader("content-type","text/plain; charset=utf-8");let url=new URL(request.url??"/",origin);if(request.method!=="GET"||request.headers.host!==new URL(origin).host||url.origin!==origin||url.pathname!=="/callback"||request.headers.forwarded||request.headers["x-forwarded-for"]){response.writeHead(404).end("Not found");return}let code=url.searchParams.get("code"),suppliedState=Buffer.from(url.searchParams.get("state")??""),expectedState=Buffer.from(state);if(accepted||url.searchParams.getAll("state").length!==1||suppliedState.length!==expectedState.length||!timingSafeEqual(suppliedState,expectedState)||url.searchParams.getAll("code").length!==1||!code){response.writeHead(400).end("Invalid sign-in response");return}accepted=!0,response.writeHead(200).end("Return to the terminal to finish signing in."),answer.resolve(code)});try{await new Promise((resolve,reject)=>{server.once("error",reject),server.listen(0,"127.0.0.1",()=>{server.off("error",reject),resolve()})});let address=server.address();if(!address||typeof address==="string")throw new SignInError("Unable to start the sign-in callback.");origin=`http://127.0.0.1:${address.port}`;let url=new URL(serviceOrigin(options.accounts));url.search=new URLSearchParams({redirect_uri:`${origin}/callback`,code_challenge:createHash2("sha256").update(verifier).digest("base64url"),code_challenge_method:"S256",state}).toString();let timer=setTimeout(abort,300000);options.signal?.addEventListener("abort",abort,{once:!0});try{options.signal?.throwIfAborted();let openerFailed=()=>{if(!accepted)throw new BrowserUnavailable("No browser is available; use device sign-in.")},[code]=await Promise.all([answer.promise,options.open(url.href).then((opened)=>{if(!opened)openerFailed()},openerFailed)]);return{code,codeVerifier:verifier}}finally{clearTimeout(timer),options.signal?.removeEventListener("abort",abort)}}finally{server.closeAllConnections(),await new Promise((resolve)=>server.close(()=>resolve()))}}async function loginLoopback(session,options){await session.ready();let keys=generateDeviceKeys();for(;;){let authorization=await authorize({accounts:options.accounts,open:options.open,signal:session.signal});try{let grant=parseReply(grantSchema,await session.request("/v1/session/exchange",jsonRequest({...authorization,kind:"cli",deviceName:options.name,platform:options.platform,...keys.public})));await session.save({...grant,...keys.private});return}catch(error){if(await session.removeForLimit(error,options.chooseDevice))continue;throw new SignInError("Sign-in cancelled. No device was removed.")}}}import{mkdir}from"node:fs/promises";import{homedir}from"node:os";import{join}from"node:path";import{access,open as open2,unlink}from"node:fs/promises";import{dirname}from"node:path";import{randomUUID}from"node:crypto";import{readFile,stat}from"node:fs/promises";var lockOwnerInstanceId=randomUUID(),heldLockRecords=new Set;function buildLockRecord(ownerTag){return`${ownerTag} ${randomUUID()}
115
+ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let entry of ctx.seen.entries()){let seen=entry[1];if(schema===entry[0]){extractToDef(entry);continue}if(ctx.external){let ext=ctx.external.registry.get(entry[0])?.id;if(schema!==entry[0]&&ext){extractToDef(entry);continue}}if(ctx.metadataRegistry.get(entry[0])?.id){extractToDef(entry);continue}if(seen.cycle){extractToDef(entry);continue}if(seen.count>1){if(ctx.reused==="ref")extractToDef(entry)}}if(ctx.external)ctx.sharedDefsExtractedFor=ctx.external}function compactTypeUnion(schema){let options=schema.anyOf;if(!Array.isArray(options)||options.length===0||schema.type!==void 0)return;let types=[];for(let option of options){if(!option||typeof option!=="object")return;compactTypeUnion(option);let keys=Object.keys(option);if(keys.length!==1||keys[0]!=="type")return;let type=option.type;for(let member of Array.isArray(type)?type:[type]){if(typeof member!=="string")return;if(!types.includes(member))types.push(member)}}delete schema.anyOf,schema.type=types.length===1?types[0]:types}var FOLDABLE_KEYS=new Set(["type","properties","required","additionalProperties"]),UNION_KEYS=["oneOf","anyOf"];function undeclaredConstraint(member){let extra=member.additionalProperties;if(extra===void 0||extra===!1||typeof extra!=="object"||extra===null)return null;return Object.keys(extra).length?extra:null}function foldObjects(members){let objects=[];for(let member of members){if(typeof member!=="object"||member.type!=="object")return null;for(let key in member)if(!FOLDABLE_KEYS.has(key))return null;objects.push(member)}let properties={},required=new Set;for(let object of objects){for(let key in object.properties){if(Object.prototype.hasOwnProperty.call(properties,key))continue;let parts=[];for(let other of objects){let part=other.properties?.[key]??undeclaredConstraint(other);if(part===null||part===void 0)continue;if(!parts.some((seen)=>JSON.stringify(seen)===JSON.stringify(part)))parts.push(part)}let merged=parts.length===1?parts[0]:foldObjects(parts)??{allOf:parts};assignProp(properties,key,merged)}for(let key of object.required??[])required.add(key)}let folded={type:"object",properties};if(required.size)folded.required=[...required];if(objects.every((object)=>object.additionalProperties===!1))folded.additionalProperties=!1;else{let constraints=[];for(let object of objects){let constraint=undeclaredConstraint(object);if(constraint&&!constraints.some((seen)=>JSON.stringify(seen)===JSON.stringify(constraint)))constraints.push(constraint)}if(constraints.length===1)folded.additionalProperties=constraints[0];else if(constraints.length>1)folded.additionalProperties={allOf:constraints}}return folded}function foldIntersection(json){let allOf=json.allOf;if(!Array.isArray(allOf)||allOf.length<2)return;for(let key of FOLDABLE_KEYS)if(key in json)return;let unions=allOf.filter((m)=>UNION_KEYS.some((k)=>Array.isArray(m[k]))),folded=null;if(!unions.length)folded=foldObjects(allOf);else{let union=unions[0],keyword=UNION_KEYS.find((k)=>Array.isArray(union[k]));if(Object.keys(union).length!==1)return;let rest=allOf.filter((m)=>m!==union),branches=union[keyword].map((branch)=>foldObjects([...rest,branch]));if(branches.some((b)=>!b))return;folded={[keyword]:branches}}if(!folded)return;delete json.allOf,assignProps(json,folded)}function finalize(ctx,schema){let root=ctx.seen.get(schema);if(!root)throw Error("Unprocessed schema. This is a bug in Zod.");let flattenRef=(zodSchema)=>{let seen=ctx.seen.get(zodSchema);if(seen.ref===null)return;let schema=seen.def??seen.schema,_cached={...schema},ref=seen.ref;if(seen.ref=null,ref){flattenRef(ref);let refSeen=ctx.seen.get(ref),refSchema=refSeen.schema;if(refSchema.$ref&&(ctx.target==="draft-07"||ctx.target==="draft-04"||ctx.target==="openapi-3.0"))schema.allOf=schema.allOf??[],schema.allOf.push(refSchema);else assignProps(schema,refSchema);if(assignProps(schema,_cached),zodSchema._zod.parent===ref)for(let key in schema){if(key==="$ref"||key==="allOf")continue;if(!(key in _cached))delete schema[key]}if(refSchema.$ref&&refSeen.def)for(let key in schema){if(key==="$ref"||key==="allOf")continue;if(key in refSeen.def&&JSON.stringify(schema[key])===JSON.stringify(refSeen.def[key]))delete schema[key]}}let parent=zodSchema._zod.parent;if(parent&&parent!==ref){flattenRef(parent);let parentSeen=ctx.seen.get(parent);if(parentSeen?.schema.$ref){if(schema.$ref=parentSeen.schema.$ref,parentSeen.def)for(let key in schema){if(key==="$ref"||key==="allOf")continue;if(key in parentSeen.def&&JSON.stringify(schema[key])===JSON.stringify(parentSeen.def[key]))delete schema[key]}}}ctx.override({zodSchema,jsonSchema:schema,path:seen.path??[]})};if(!ctx.external||ctx.sharedEmitDoneFor!==ctx.external){for(let entry of[...ctx.seen.entries()].reverse())flattenRef(entry[0]);if(ctx.target!=="openapi-3.0")for(let entry of ctx.seen.entries())compactTypeUnion(entry[1].def??entry[1].schema);for(let rewrite of ctx.deferred)rewrite();if(ctx.intersections.length){let carriers=new Map;for(let seen of ctx.seen.values())for(let json of[seen.schema,seen.def]){let allOf=json?.allOf;if(!Array.isArray(allOf))continue;let existing=carriers.get(allOf);if(existing)existing.push(json);else carriers.set(allOf,[json])}for(let allOf of ctx.intersections)for(let json of carriers.get(allOf)??[])foldIntersection(json)}}let result={};if(ctx.target==="draft-2020-12")result.$schema="https://json-schema.org/draft/2020-12/schema";else if(ctx.target==="draft-07")result.$schema="http://json-schema.org/draft-07/schema#";else if(ctx.target==="draft-04")result.$schema="http://json-schema.org/draft-04/schema#";else if(ctx.target==="openapi-3.0");if(ctx.external?.uri){let id=ctx.external.registry.get(schema)?.id;if(!id)throw Error("Schema is missing an `id` property");result.$id=ctx.external.uri(id)}assignProps(result,root.defId?root.schema:root.def??root.schema);let rootMetaId=ctx.metadataRegistry.get(schema)?.id;if(rootMetaId!==void 0&&result.id===rootMetaId)delete result.id;let defs=ctx.external?.defs??{};if(!ctx.external||ctx.sharedEmitDoneFor!==ctx.external)for(let entry of ctx.seen.entries()){let seen=entry[1];if(seen.def&&seen.defId){if(seen.def.id===seen.defId)delete seen.def.id;assignProp(defs,seen.defId,seen.def)}}if(ctx.external)ctx.sharedEmitDoneFor=ctx.external;if(ctx.external);else if(Object.keys(defs).length>0)if(ctx.target==="draft-2020-12")result.$defs=defs;else result.definitions=defs;try{let finalized=JSON.parse(JSON.stringify(result));return Object.defineProperty(finalized,"~standard",{value:{...schema["~standard"],jsonSchema:{input:createStandardJSONSchemaMethod(schema,"input",ctx.processors),output:createStandardJSONSchemaMethod(schema,"output",ctx.processors)}},enumerable:!1,writable:!1}),finalized}catch(_err){throw Error("Error converting schema to JSON.")}}function isTransforming(_schema,_ctx){let ctx=_ctx??{seen:new Set};if(ctx.seen.has(_schema))return!1;ctx.seen.add(_schema);let def=_schema._zod.def;if(def.type==="transform")return!0;if(def.type==="array")return isTransforming(def.element,ctx);if(def.type==="set")return isTransforming(def.valueType,ctx);if(def.type==="lazy")return isTransforming(def.getter(),ctx);if(def.type==="promise"||def.type==="optional"||def.type==="nonoptional"||def.type==="nullable"||def.type==="readonly"||def.type==="default"||def.type==="prefault"||def.type==="catch")return isTransforming(def.innerType,ctx);if(def.type==="intersection")return isTransforming(def.left,ctx)||isTransforming(def.right,ctx);if(def.type==="record"||def.type==="map")return isTransforming(def.keyType,ctx)||isTransforming(def.valueType,ctx);if(def.type==="pipe"){if(_schema._zod.traits.has("$ZodCodec"))return!0;return isTransforming(def.in,ctx)||isTransforming(def.out,ctx)}if(def.type==="object"){for(let key in def.shape)if(isTransforming(def.shape[key],ctx))return!0;return!1}if(def.type==="union"){for(let option of def.options)if(isTransforming(option,ctx))return!0;return!1}if(def.type==="tuple"){for(let item of def.items)if(isTransforming(item,ctx))return!0;if(def.rest&&isTransforming(def.rest,ctx))return!0;return!1}return!1}var createToJSONSchemaMethod=(schema,processors={})=>(params)=>{let ctx=initializeContext({...params,processors});return processSchema(schema,ctx),extractDefs(ctx,schema),finalize(ctx,schema)},createStandardJSONSchemaMethod=(schema,io,processors={})=>(params)=>{let{libraryOptions,target}=params??{},ctx=initializeContext({...libraryOptions??{},target,io,processors});return processSchema(schema,ctx),extractDefs(ctx,schema),finalize(ctx,schema)};var narrowMin=(agg,key,value)=>{if(agg[key]===void 0||value>agg[key])agg[key]=value},narrowMax=(agg,key,value)=>{if(agg[key]===void 0||value<agg[key])agg[key]=value},narrowBoth=(agg,value)=>{narrowMin(agg,"minimum",value),narrowMax(agg,"maximum",value)},addDivisor=(agg,value)=>{if(agg.multipleOf??(agg.multipleOf=[]),!agg.multipleOf.includes(value))agg.multipleOf.push(value)},addPattern=(agg,pattern)=>{agg.patterns??(agg.patterns=new Set),agg.patterns.add(pattern)},intersectMime=(agg,mime)=>{agg.mime=agg.mime?agg.mime.filter((m)=>mime.includes(m)):[...mime]},setFormat=(agg,format)=>{if(agg.format=format,format.includes("int"))agg.isInt=!0},minContributor=(agg,def)=>narrowMin(agg,"minimum",def.minimum),maxContributor=(agg,def)=>narrowMax(agg,"maximum",def.maximum),formatContributor=(ranges)=>(agg,def)=>{setFormat(agg,def.format);let[minimum,maximum]=ranges[def.format];narrowMin(agg,"minimum",minimum),narrowMax(agg,"maximum",maximum)},contributors={greater_than:(agg,def)=>narrowMin(agg,def.inclusive?"minimum":"exclusiveMinimum",def.value),less_than:(agg,def)=>narrowMax(agg,def.inclusive?"maximum":"exclusiveMaximum",def.value),multiple_of:(agg,def)=>addDivisor(agg,def.value),number_format:formatContributor(NUMBER_FORMAT_RANGES),bigint_format:formatContributor(BIGINT_FORMAT_RANGES),min_length:minContributor,max_length:maxContributor,length_equals:(agg,def)=>narrowBoth(agg,def.length),min_size:minContributor,max_size:maxContributor,size_equals:(agg,def)=>narrowBoth(agg,def.size),string_format:(agg,def)=>{if(setFormat(agg,def.format),def.pattern)addPattern(agg,def.pattern);if(def.format==="base64"||def.format==="base64url")agg.contentEncoding=def.format;if(def.local||def.precision===-1)agg.laxFormat=!0},mime_type:(agg,def)=>intersectMime(agg,def.mime)};function aggregateChecks(schema){let agg={},def=schema._zod.def,list=schema._zod.traits.has("$ZodCheck")?[schema,...def.checks??[]]:def.checks??[];for(let ch of list)contributors[ch._zod.def.check]?.(agg,ch._zod.def);let bag=schema._zod.bag;if(bag.minimum!==void 0)narrowMin(agg,"minimum",bag.minimum);if(bag.exclusiveMinimum!==void 0)narrowMin(agg,"exclusiveMinimum",bag.exclusiveMinimum);if(bag.maximum!==void 0)narrowMax(agg,"maximum",bag.maximum);if(bag.exclusiveMaximum!==void 0)narrowMax(agg,"exclusiveMaximum",bag.exclusiveMaximum);if(bag.multipleOf!==void 0)addDivisor(agg,bag.multipleOf);if(bag.format!==void 0){if(agg.format??(agg.format=bag.format),bag.format.includes("int"))agg.isInt=!0}if(bag.mime)intersectMime(agg,bag.mime);for(let pattern of bag.patterns??[])addPattern(agg,pattern);return agg}var formatMap={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},exactPatterns=new Map([[base64Charset,base64],[base64urlCharset,base64url]]),exactPattern=(p)=>exactPatterns.get(p)??p,stringProcessor=(schema,ctx,_json,_params)=>{let json=_json;json.type="string";let{minimum,maximum,format,patterns,contentEncoding,laxFormat}=aggregateChecks(schema);if(typeof minimum==="number")json.minLength=minimum;if(typeof maximum==="number")json.maxLength=maximum;if(format){if(json.format=formatMap[format]??format,json.format==="")delete json.format;if(format==="time"||laxFormat)delete json.format}if(contentEncoding)json.contentEncoding=contentEncoding;if(patterns&&patterns.size>0){let patternList=[...patterns].map(exactPattern);if(patternList.length===1)json.pattern=patternList[0].source;else if(patternList.length>1)json.allOf=[...patternList.map((regex)=>({...ctx.target==="draft-07"||ctx.target==="draft-04"||ctx.target==="openapi-3.0"?{type:"string"}:{},pattern:regex.source}))]}},numberProcessor=(schema,ctx,_json,params)=>{let json=_json,{minimum,maximum,multipleOf,exclusiveMaximum,exclusiveMinimum,isInt}=aggregateChecks(schema);json.type=isInt?"integer":"number";let exMin=typeof exclusiveMinimum==="number"&&exclusiveMinimum>=(minimum??Number.NEGATIVE_INFINITY),exMax=typeof exclusiveMaximum==="number"&&exclusiveMaximum<=(maximum??Number.POSITIVE_INFINITY),legacy=ctx.target==="draft-04"||ctx.target==="openapi-3.0";if(exMin)if(legacy)json.minimum=exclusiveMinimum,json.exclusiveMinimum=!0;else json.exclusiveMinimum=exclusiveMinimum;else if(typeof minimum==="number")json.minimum=minimum;if(exMax)if(legacy)json.maximum=exclusiveMaximum,json.exclusiveMaximum=!0;else json.exclusiveMaximum=exclusiveMaximum;else if(typeof maximum==="number")json.maximum=maximum;if(multipleOf){let divisors=new Set;for(let divisor of multipleOf)if(Number.isFinite(divisor)&&divisor!==0)divisors.add(Math.abs(divisor));else handleUnrepresentable(schema,ctx,json,params,`A multipleOf divisor of ${divisor} cannot be represented in JSON Schema`);let[first,...rest]=divisors;if(first!==void 0)json.multipleOf=first;if(rest.length)json.allOf=[...json.allOf??[],...rest.map((m)=>({multipleOf:m}))]}},booleanProcessor=(_schema,_ctx,json,_params)=>{json.type="boolean"};var neverProcessor=(_schema,_ctx,json,_params)=>{json.not={}};var unknownProcessor=(_schema,_ctx,_json,_params)=>{};var enumProcessor=(schema,_ctx,json,_params)=>{let def=schema._zod.def,values=getEnumValues(def.entries);if(values.length===0){json.not={};return}if(values.every((v)=>typeof v==="number"))json.type="number";if(values.every((v)=>typeof v==="string"))json.type="string";json.enum=values},literalProcessor=(schema,ctx,json,params)=>{let def=schema._zod.def;if(def.values.length===0){json.not={};return}let vals=[];for(let val of def.values)if(val===void 0){if(handleUnrepresentable(schema,ctx,json,params,"Literal `undefined` cannot be represented in JSON Schema"))return}else if(typeof val==="bigint"){if(handleUnrepresentable(schema,ctx,json,params,"BigInt literals cannot be represented in JSON Schema"))return;vals.push(Number(val))}else vals.push(val);if(vals.length===0);else if(vals.length===1){let val=vals[0];if(json.type=val===null?"null":typeof val,ctx.target==="draft-04"||ctx.target==="openapi-3.0")json.enum=[val];else json.const=val}else{if(vals.every((v)=>typeof v==="number"))json.type="number";if(vals.every((v)=>typeof v==="string"))json.type="string";if(vals.every((v)=>typeof v==="boolean"))json.type="boolean";if(vals.every((v)=>v===null))json.type="null";json.enum=vals}};var customProcessor=(schema,ctx,json,params)=>{handleUnrepresentable(schema,ctx,json,params,"Custom types cannot be represented in JSON Schema")};var transformProcessor=(schema,ctx,json,params)=>{handleUnrepresentable(schema,ctx,json,params,"Transforms cannot be represented in JSON Schema")};var arrayProcessor=(schema,ctx,_json,params)=>{let json=_json,def=schema._zod.def,{minimum,maximum}=aggregateChecks(schema);if(typeof minimum==="number")json.minItems=minimum;if(typeof maximum==="number")json.maxItems=maximum;json.type="array",json.items=processSchema(def.element,ctx,{...params,path:[...params.path,"items"]})};function inputOptin(schema){let def=schema._zod.def;if(def.type==="pipe"&&def.in._zod.traits.has("$ZodTransform"))return inputOptin(def.out);if(def.type==="catch")return inputOptin(def.innerType);return schema._zod.optin}var objectProcessor=(schema,ctx,_json,params)=>{let json=_json,def=schema._zod.def,shape=def.shape;if(Object.getOwnPropertySymbols(shape).length&&handleUnrepresentable(schema,ctx,json,params,"Symbol keys cannot be represented in JSON Schema"))return;json.type="object",json.properties={};for(let key in shape)assignProp(json.properties,key,processSchema(shape[key],ctx,{...params,path:[...params.path,"properties",key]}));let requiredKeys=[];for(let key of Object.keys(shape)){let field=def.shape[key];if(ctx.io==="input"?inputOptin(field)===void 0:field._zod.optout===void 0)requiredKeys.push(key)}if(requiredKeys.length>0)json.required=requiredKeys;if(def.catchall?._zod.def.type==="never")json.additionalProperties=!1;else if(!def.catchall){if(ctx.io==="output")json.additionalProperties=!1}else if(def.catchall)json.additionalProperties=processSchema(def.catchall,ctx,{...params,path:[...params.path,"additionalProperties"]})},unionProcessor=(schema,ctx,json,params)=>{let def=schema._zod.def,isExclusive=def.inclusive===!1,options=def.options.map((x,i)=>processSchema(x,ctx,{...params,path:[...params.path,isExclusive?"oneOf":"anyOf",i]}));if(isExclusive)json.oneOf=options;else json.anyOf=options},intersectionProcessor=(schema,ctx,json,params)=>{let def=schema._zod.def,a=processSchema(def.left,ctx,{...params,path:[...params.path,"allOf",0]}),b=processSchema(def.right,ctx,{...params,path:[...params.path,"allOf",1]}),isSimpleIntersection=(val)=>("allOf"in val)&&Object.keys(val).length===1,allOf=[...isSimpleIntersection(a)?a.allOf:[a],...isSimpleIntersection(b)?b.allOf:[b]];json.allOf=allOf,ctx.intersections.push(allOf)};var nullableProcessor=(schema,ctx,json,params)=>{let def=schema._zod.def,inner=processSchema(def.innerType,ctx,params),seen=ctx.seen.get(schema);if(ctx.target==="openapi-3.0")seen.ref=def.innerType,json.nullable=!0;else json.anyOf=[inner,{type:"null"}]},nonoptionalProcessor=(schema,ctx,_json,params)=>{let def=schema._zod.def;processSchema(def.innerType,ctx,params);let seen=ctx.seen.get(schema);seen.ref=def.innerType},UNREPRESENTABLE_DEFAULT=Symbol();function serializeDefaultValue(value,schema,ctx,json,params){let unrepresentable=!1,serialized=JSON.stringify(value,(_,val)=>{if(typeof val!=="bigint")return val;return unrepresentable=!0,null});if(!unrepresentable)return JSON.parse(serialized);return handleUnrepresentable(schema,ctx,json,params,"BigInt defaults cannot be represented in JSON Schema"),UNREPRESENTABLE_DEFAULT}var defaultProcessor=(schema,ctx,json,params)=>{let def=schema._zod.def;processSchema(def.innerType,ctx,params);let seen=ctx.seen.get(schema);seen.ref=def.innerType;let value=serializeDefaultValue(def.defaultValue,schema,ctx,json,params);if(value!==UNREPRESENTABLE_DEFAULT)json.default=value},prefaultProcessor=(schema,ctx,json,params)=>{let def=schema._zod.def;processSchema(def.innerType,ctx,params);let seen=ctx.seen.get(schema);if(seen.ref=def.innerType,ctx.io!=="input")return;let value=serializeDefaultValue(def.defaultValue,schema,ctx,json,params);if(value!==UNREPRESENTABLE_DEFAULT)json._prefault=value},catchProcessor=(schema,ctx,json,params)=>{let def=schema._zod.def;processSchema(def.innerType,ctx,params);let seen=ctx.seen.get(schema);seen.ref=def.innerType;let catchValue;try{catchValue=def.catchValue(void 0)}catch{handleUnrepresentable(schema,ctx,json,params,"Dynamic catch values are not supported in JSON Schema");return}json.default=catchValue},pipeProcessor=(schema,ctx,_json,params)=>{let def=schema._zod.def,inIsTransform=def.in._zod.traits.has("$ZodTransform"),innerType=ctx.io==="input"?inIsTransform?def.out:def.in:def.out;processSchema(innerType,ctx,params);let seen=ctx.seen.get(schema);seen.ref=innerType},readonlyProcessor=(schema,ctx,json,params)=>{let def=schema._zod.def;processSchema(def.innerType,ctx,params);let seen=ctx.seen.get(schema);seen.ref=def.innerType,json.readOnly=!0};var optionalProcessor=(schema,ctx,_json,params)=>{let def=schema._zod.def;processSchema(def.innerType,ctx,params);let seen=ctx.seen.get(schema);seen.ref=def.innerType};var _installedErrorProtos=new WeakSet([Object.prototype,Error.prototype]);function _lazyMethod(proto,key,make){Object.defineProperty(proto,key,{configurable:!0,enumerable:!1,get(){let value=make(this);return Object.defineProperty(this,key,{value,configurable:!0,writable:!0}),value},set(value){Object.defineProperty(this,key,{value,configurable:!0,writable:!0})}})}var initializer2=(inst,issues)=>{$ZodError.init(inst,issues),inst.name="ZodError";let proto=Object.getPrototypeOf(inst);if(_installedErrorProtos.has(proto))return;_installedErrorProtos.add(proto),_lazyMethod(proto,"format",(self)=>(mapper)=>formatError(self,mapper)),_lazyMethod(proto,"flatten",(self)=>(mapper)=>flattenError(self,mapper)),_lazyMethod(proto,"addIssue",(self)=>(issue)=>{self.issues.push(issue),self.message=JSON.stringify(self.issues,jsonStringifyReplacer,2)}),_lazyMethod(proto,"addIssues",(self)=>(issues)=>{self.issues.push(...issues),self.message=JSON.stringify(self.issues,jsonStringifyReplacer,2)}),Object.defineProperty(proto,"isEmpty",{configurable:!0,enumerable:!1,get(){return this.issues.length===0}})};var ZodRealError=$constructor("ZodError",initializer2,void 0,{Parent:Error});var parse2=_parse(ZodRealError),parseAsync=_parseAsync(ZodRealError),safeParse=_safeParse(ZodRealError),safeParseAsync=_safeParseAsync(ZodRealError),encode=_encode(ZodRealError),decode=_decode(ZodRealError),encodeAsync=_encodeAsync(ZodRealError),decodeAsync=_decodeAsync(ZodRealError),safeEncode=_safeEncode(ZodRealError),safeDecode=_safeDecode(ZodRealError),safeEncodeAsync=_safeEncodeAsync(ZodRealError),safeDecodeAsync=_safeDecodeAsync(ZodRealError);function _ensureDefaultLocale(){if(!globalConfig.localeError)config(en_default())}function _ensureDefaultMemoizer(){if(!globalConfig.memoizer)config({memoizer:memoizer()})}var ZodType=$constructor("ZodType",(inst,def)=>(_ensureDefaultLocale(),$ZodType.init(inst,def),inst.def=def,inst.type=def.type,inst),{check(...chks){let def=this.def;return this.clone(mergeDefs(def,{checks:[...def.checks??[],...chks.map((ch)=>typeof ch==="function"?{_zod:{check:ch,def:{check:"custom"},onattach:[]}}:ch)]}),{parent:!0})},with(...chks){return this.check(...chks)},clone(def,params){return clone(this,def,params)},brand(){return this},register(reg,meta){return reg.add(this,meta),this},refine(check,params){return this.check(refine(check,params))},superRefine(refinement,params){return this.check(superRefine(refinement,params))},overwrite(fn){return this.check(_overwrite(fn))},optional(){return optional(this)},exactOptional(){return exactOptional(this)},nullable(){return nullable(this)},nullish(){return optional(nullable(this))},nonoptional(params){return nonoptional(this,params)},array(){return array(this)},or(arg){return union([this,arg])},and(arg){return intersection(this,arg)},transform(tx){return pipe(this,transform(tx))},default(d){return _default(this,d)},prefault(d){return prefault(this,d)},catch(params){return _catch(this,params)},pipe(target){return pipe(this,target)},readonly(){return readonly(this)},describe(description){let cl=this.clone();return globalRegistry.add(cl,{description}),cl},meta(...args){if(args.length===0)return globalRegistry.get(this);let cl=this.clone();return globalRegistry.add(cl,args[0]),cl},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(fn,...args){return args.length===0?fn(this):fn(this,...args)},get "~standard"(){return hide(this,"~standard",{...standardProps(this),jsonSchema:{input:createStandardJSONSchemaMethod(this,"input"),output:createStandardJSONSchemaMethod(this,"output")}})},set "~standard"(value){own(this,"~standard",value)},parse:function _parse(data,params){return parse2(this,data,params,{callee:_parse})},parseAsync:async function _parseAsync(data,params){return await parseAsync(this,data,params,{callee:_parseAsync})},safeParse(data,params){return safeParse(this,data,params)},async safeParseAsync(data,params){return safeParseAsync(this,data,params)},get spa(){return this?.safeParseAsync},set spa(value){own(this,"spa",value)},validate(data,params){return validate(this,data,params)},validateAsync(data,params){return validateAsync(this,data,params)},encode:function _encode(data,params){return encode(this,data,params,{callee:_encode})},decode:function _decode(data,params){return decode(this,data,params,{callee:_decode})},encodeAsync:async function _encodeAsync(data,params){return await encodeAsync(this,data,params,{callee:_encodeAsync})},decodeAsync:async function _decodeAsync(data,params){return await decodeAsync(this,data,params,{callee:_decodeAsync})},safeEncode(data,params){return safeEncode(this,data,params)},safeDecode(data,params){return safeDecode(this,data,params)},async safeEncodeAsync(data,params){return safeEncodeAsync(this,data,params)},async safeDecodeAsync(data,params){return safeDecodeAsync(this,data,params)},toJSONSchema(params){return createToJSONSchemaMethod(this,{})(params)},get description(){return globalRegistry.get(this)?.description},get _def(){return this._zod.def}}),_ZodString=$constructor("_ZodString",(inst,def)=>{$ZodString.init(inst,def),ZodType.init(inst,def),inst._zod.processJSONSchema=(ctx,json,params)=>stringProcessor(inst,ctx,json,params)},derived({format:(inst)=>aggregateChecks(inst).format??null,minLength:(inst)=>aggregateChecks(inst).minimum??null,maxLength:(inst)=>aggregateChecks(inst).maximum??null},{regex(...args){return this.check(_regex(...args))},includes(...args){return this.check(_includes(...args))},startsWith(...args){return this.check(_startsWith(...args))},endsWith(...args){return this.check(_endsWith(...args))},min(...args){return this.check(_minLength(...args))},max(...args){return this.check(_maxLength(...args))},length(...args){return this.check(_length(...args))},nonempty(...args){return this.check(_minLength(1,...args))},lowercase(params){return this.check(_lowercase(params))},uppercase(params){return this.check(_uppercase(params))},trim(){return this.check(_trim())},normalize(...args){return this.check(_normalize(...args))},toLowerCase(){return this.check(_toLowerCase())},toUpperCase(){return this.check(_toUpperCase())},slugify(){return this.check(_slugify())}})),ZodString=$constructor("ZodString",(inst,def)=>{$ZodString.init(inst,def),_ZodString.init(inst,def)},{email(params){return this.check(_email(ZodEmail,params))},url(params){return this.check(_url(ZodURL,params))},jwt(params){return this.check(_jwt(ZodJWT,params))},emoji(params){return this.check(_emoji2(ZodEmoji,params))},guid(params){return this.check(_guid(ZodGUID,params))},uuid(params){return this.check(_uuid(ZodUUID,params))},uuidv4(params){return this.check(_uuidv4(ZodUUID,params))},uuidv6(params){return this.check(_uuidv6(ZodUUID,params))},uuidv7(params){return this.check(_uuidv7(ZodUUID,params))},nanoid(params){return this.check(_nanoid(ZodNanoID,params))},cuid(params){return this.check(_cuid(ZodCUID,params))},cuid2(params){return this.check(_cuid2(ZodCUID2,params))},ulid(params){return this.check(_ulid(ZodULID,params))},base64(params){return this.check(_base64(ZodBase64,params))},base64url(params){return this.check(_base64url(ZodBase64URL,params))},xid(params){return this.check(_xid(ZodXID,params))},ksuid(params){return this.check(_ksuid(ZodKSUID,params))},ipv4(params){return this.check(_ipv4(ZodIPv4,params))},ipv6(params){return this.check(_ipv6(ZodIPv6,params))},cidrv4(params){return this.check(_cidrv4(ZodCIDRv4,params))},cidrv6(params){return this.check(_cidrv6(ZodCIDRv6,params))},e164(params){return this.check(_e164(ZodE164,params))},datetime(params){return this.check(_isoDateTime(ZodISODateTime,params))},date(params){return this.check(_isoDate(ZodISODate,params))},time(params){return this.check(_isoTime(ZodISOTime,params))},duration(params){return this.check(_isoDuration(ZodISODuration,params))}});function string2(params){return _string(ZodString,params)}var ZodStringFormat=$constructor("ZodStringFormat",(inst,def)=>{$ZodStringFormat.init(inst,def),_ZodString.init(inst,def)}),ZodISODateTime=$constructor("ZodISODateTime",(inst,def)=>{$ZodISODateTime.init(inst,def),ZodStringFormat.init(inst,def)}),ZodISODate=$constructor("ZodISODate",(inst,def)=>{$ZodISODate.init(inst,def),ZodStringFormat.init(inst,def)}),ZodISOTime=$constructor("ZodISOTime",(inst,def)=>{$ZodISOTime.init(inst,def),ZodStringFormat.init(inst,def)}),ZodISODuration=$constructor("ZodISODuration",(inst,def)=>{$ZodISODuration.init(inst,def),ZodStringFormat.init(inst,def)}),ZodEmail=$constructor("ZodEmail",(inst,def)=>{$ZodEmail.init(inst,def),ZodStringFormat.init(inst,def)});var ZodGUID=$constructor("ZodGUID",(inst,def)=>{$ZodGUID.init(inst,def),ZodStringFormat.init(inst,def)});var ZodUUID=$constructor("ZodUUID",(inst,def)=>{$ZodUUID.init(inst,def),ZodStringFormat.init(inst,def)});var ZodURL=$constructor("ZodURL",(inst,def)=>{$ZodURL.init(inst,def),ZodStringFormat.init(inst,def)});var ZodEmoji=$constructor("ZodEmoji",(inst,def)=>{$ZodEmoji.init(inst,def),ZodStringFormat.init(inst,def)});var ZodNanoID=$constructor("ZodNanoID",(inst,def)=>{$ZodNanoID.init(inst,def),ZodStringFormat.init(inst,def)});var ZodCUID=$constructor("ZodCUID",(inst,def)=>{$ZodCUID.init(inst,def),ZodStringFormat.init(inst,def)});var ZodCUID2=$constructor("ZodCUID2",(inst,def)=>{$ZodCUID2.init(inst,def),ZodStringFormat.init(inst,def)});var ZodULID=$constructor("ZodULID",(inst,def)=>{$ZodULID.init(inst,def),ZodStringFormat.init(inst,def)});var ZodXID=$constructor("ZodXID",(inst,def)=>{$ZodXID.init(inst,def),ZodStringFormat.init(inst,def)});var ZodKSUID=$constructor("ZodKSUID",(inst,def)=>{$ZodKSUID.init(inst,def),ZodStringFormat.init(inst,def)});var ZodIPv4=$constructor("ZodIPv4",(inst,def)=>{$ZodIPv4.init(inst,def),ZodStringFormat.init(inst,def)});var ZodIPv6=$constructor("ZodIPv6",(inst,def)=>{$ZodIPv6.init(inst,def),ZodStringFormat.init(inst,def)});var ZodCIDRv4=$constructor("ZodCIDRv4",(inst,def)=>{$ZodCIDRv4.init(inst,def),ZodStringFormat.init(inst,def)});var ZodCIDRv6=$constructor("ZodCIDRv6",(inst,def)=>{$ZodCIDRv6.init(inst,def),ZodStringFormat.init(inst,def)});var ZodBase64=$constructor("ZodBase64",(inst,def)=>{$ZodBase64.init(inst,def),ZodStringFormat.init(inst,def)});var ZodBase64URL=$constructor("ZodBase64URL",(inst,def)=>{$ZodBase64URL.init(inst,def),ZodStringFormat.init(inst,def)});var ZodE164=$constructor("ZodE164",(inst,def)=>{$ZodE164.init(inst,def),ZodStringFormat.init(inst,def)});var ZodJWT=$constructor("ZodJWT",(inst,def)=>{$ZodJWT.init(inst,def),ZodStringFormat.init(inst,def)});var ZodNumber=$constructor("ZodNumber",(inst,def)=>{$ZodNumber.init(inst,def),ZodType.init(inst,def),inst._zod.processJSONSchema=(ctx,json,params)=>numberProcessor(inst,ctx,json,params),inst.isFinite=!0},derived({minValue:(inst)=>{let{minimum,exclusiveMinimum}=aggregateChecks(inst);return Math.max(minimum??Number.NEGATIVE_INFINITY,exclusiveMinimum??Number.NEGATIVE_INFINITY)},maxValue:(inst)=>{let{maximum,exclusiveMaximum}=aggregateChecks(inst);return Math.min(maximum??Number.POSITIVE_INFINITY,exclusiveMaximum??Number.POSITIVE_INFINITY)},isInt:(inst)=>{let{isInt,multipleOf}=aggregateChecks(inst);return!!isInt||!!multipleOf?.some(Number.isSafeInteger)},format:(inst)=>aggregateChecks(inst).format??null},{gt(value,params){return this.check(_gt(value,params))},gte(value,params){return this.check(_gte(value,params))},min(value,params){return this.check(_gte(value,params))},lt(value,params){return this.check(_lt(value,params))},lte(value,params){return this.check(_lte(value,params))},max(value,params){return this.check(_lte(value,params))},int(params){return this.check(int(params))},safe(params){return this.check(int(params))},positive(params){return this.check(_gt(0,params))},nonnegative(params){return this.check(_gte(0,params))},negative(params){return this.check(_lt(0,params))},nonpositive(params){return this.check(_lte(0,params))},multipleOf(value,params){return this.check(_multipleOf(value,params))},step(value,params){return this.check(_multipleOf(value,params))},finite(){return this}}));function number2(params){return _number(ZodNumber,params)}var ZodNumberFormat=$constructor("ZodNumberFormat",(inst,def)=>{$ZodNumberFormat.init(inst,def),ZodNumber.init(inst,def)});function int(params){return _int(ZodNumberFormat,params)}var ZodBoolean=$constructor("ZodBoolean",(inst,def)=>{$ZodBoolean.init(inst,def),ZodType.init(inst,def),inst._zod.processJSONSchema=(ctx,json,params)=>booleanProcessor(inst,ctx,json,params)});function boolean2(params){return _boolean(ZodBoolean,params)}var ZodUnknown=$constructor("ZodUnknown",(inst,def)=>{$ZodUnknown.init(inst,def),ZodType.init(inst,def),inst._zod.processJSONSchema=(ctx,json,params)=>unknownProcessor(inst,ctx,json,params)});function unknown(){return _unknown(ZodUnknown)}var ZodNever=$constructor("ZodNever",(inst,def)=>{$ZodNever.init(inst,def),ZodType.init(inst,def),inst._zod.processJSONSchema=(ctx,json,params)=>neverProcessor(inst,ctx,json,params)});function never(params){return _never(ZodNever,params)}var ZodArray=$constructor("ZodArray",(inst,def)=>{_ensureDefaultMemoizer(),$ZodArray.init(inst,def),ZodType.init(inst,def),inst._zod.processJSONSchema=(ctx,json,params)=>arrayProcessor(inst,ctx,json,params),inst.element=def.element},{min(n,params){return this.check(_minLength(n,params))},nonempty(params){return this.check(_minLength(1,params))},max(n,params){return this.check(_maxLength(n,params))},length(n,params){return this.check(_length(n,params))},unwrap(){return this.element}});function array(element,params){return _array(ZodArray,element,params)}var ZodObject=$constructor("ZodObject",(inst,def)=>{_ensureDefaultMemoizer(),$ZodObjectJIT.init(inst,def),ZodType.init(inst,def),inst._zod.processJSONSchema=(ctx,json,params)=>objectProcessor(inst,ctx,json,params),installLazyProp(inst,"shape",(self)=>self._zod.def.shape,!1)},{keyof(){return _enum(Object.keys(this._zod.def.shape))},catchall(catchall){return this.clone(mergeDefs(this._zod.def,{catchall}))},passthrough(){return this.clone(mergeDefs(this._zod.def,{catchall:unknown()}))},loose(){return this.clone(mergeDefs(this._zod.def,{catchall:unknown()}))},strict(){return this.clone(mergeDefs(this._zod.def,{catchall:never()}))},strip(){return this.clone(mergeDefs(this._zod.def,{catchall:void 0}))},extend(incoming){return extend(this,incoming)},safeExtend(incoming){return safeExtend(this,incoming)},merge(other){return merge(this,other)},pick(mask){return pick(this,mask)},omit(mask){return omit(this,mask)},partial(...args){return partial(ZodOptional,this,args[0])},exactPartial(...args){return partial(ZodExactOptional,this,args[0],"exactPartial")},required(...args){return required(ZodNonOptional,this,args[0])}});function object(shape,params){let def={type:"object",shape:shape??{},...normalizeParams(params)};return new ZodObject(def)}var ZodUnion=$constructor("ZodUnion",(inst,def)=>{$ZodUnion.init(inst,def),ZodType.init(inst,def),inst._zod.processJSONSchema=(ctx,json,params)=>unionProcessor(inst,ctx,json,params),inst.options=def.options});function union(options,params){return new ZodUnion({type:"union",options,...normalizeParams(params)})}var ZodIntersection=$constructor("ZodIntersection",(inst,def)=>{$ZodIntersection.init(inst,def),ZodType.init(inst,def),inst._zod.processJSONSchema=(ctx,json,params)=>intersectionProcessor(inst,ctx,json,params)});function intersection(left,right){return new ZodIntersection({type:"intersection",left,right})}var ZodEnum=$constructor("ZodEnum",(inst,def)=>{$ZodEnum.init(inst,def),ZodType.init(inst,def),inst._zod.processJSONSchema=(ctx,json,params)=>enumProcessor(inst,ctx,json,params),inst.enum=def.entries,inst.options=[...inst._zod.values];let keys=new Set(Object.keys(def.entries));inst.extract=(values,params)=>{let newEntries={};for(let value of values)if(keys.has(value))newEntries[value]=def.entries[value];else throw Error(`Key ${value} not found in enum`);return new ZodEnum({...def,checks:[],...normalizeParams(params),entries:newEntries})},inst.exclude=(values,params)=>{let newEntries={...def.entries};for(let value of values)if(keys.has(value))delete newEntries[value];else throw Error(`Key ${value} not found in enum`);return new ZodEnum({...def,checks:[],...normalizeParams(params),entries:newEntries})}});function _enum(values,params){let entries=Array.isArray(values)?Object.fromEntries(values.map((v)=>[v,v])):values;return new ZodEnum({type:"enum",entries,...normalizeParams(params)})}var ZodLiteral=$constructor("ZodLiteral",(inst,def)=>{$ZodLiteral.init(inst,def),ZodType.init(inst,def),inst._zod.processJSONSchema=(ctx,json,params)=>literalProcessor(inst,ctx,json,params),inst.values=new Set(def.values),Object.defineProperty(inst,"value",{get(){if(def.values.length>1)throw Error("This schema contains multiple valid literal values. Use `.values` instead.");return def.values[0]}})});function literal(value,params){return new ZodLiteral({type:"literal",values:Array.isArray(value)?value:[value],...normalizeParams(params)})}var ZodTransform=$constructor("ZodTransform",(inst,def)=>{_ensureDefaultMemoizer(),$ZodTransform.init(inst,def),ZodType.init(inst,def),inst._zod.processJSONSchema=(ctx,json,params)=>transformProcessor(inst,ctx,json,params),inst._zod.parse=(payload,_ctx)=>{if(_ctx.direction==="backward")throw new $ZodEncodeError(inst.constructor.name);payload.addIssue=(issue2)=>{if(typeof issue2==="string")payload.issues.push(issue(issue2,payload.value,def));else{let _issue=issue2;if(_issue.fatal)_issue.continue=!1;if(_issue.code??(_issue.code="custom"),!("input"in _issue))_issue.input=payload.value;_issue.inst??(_issue.inst=inst),payload.issues.push(issue(_issue))}};let output=def.transform(payload.value,payload);if(output instanceof Promise)return output.then((output)=>(payload.value=output,payload));return payload.value=output,payload}});function transform(fn){return new ZodTransform({type:"transform",transform:fn})}var ZodOptional=$constructor("ZodOptional",(inst,def)=>{$ZodOptional.init(inst,def),ZodType.init(inst,def),inst._zod.processJSONSchema=(ctx,json,params)=>optionalProcessor(inst,ctx,json,params),inst.unwrap=()=>inst._zod.def.innerType});function optional(innerType){return new ZodOptional({type:"optional",innerType})}var ZodExactOptional=$constructor("ZodExactOptional",(inst,def)=>{$ZodExactOptional.init(inst,def),ZodType.init(inst,def),inst._zod.processJSONSchema=(ctx,json,params)=>optionalProcessor(inst,ctx,json,params),inst.unwrap=()=>inst._zod.def.innerType});function exactOptional(innerType){return new ZodExactOptional({type:"optional",innerType})}var ZodNullable=$constructor("ZodNullable",(inst,def)=>{$ZodNullable.init(inst,def),ZodType.init(inst,def),inst._zod.processJSONSchema=(ctx,json,params)=>nullableProcessor(inst,ctx,json,params),inst.unwrap=()=>inst._zod.def.innerType});function nullable(innerType){return new ZodNullable({type:"nullable",innerType})}var ZodDefault=$constructor("ZodDefault",(inst,def)=>{$ZodDefault.init(inst,def),ZodType.init(inst,def),inst._zod.processJSONSchema=(ctx,json,params)=>defaultProcessor(inst,ctx,json,params),inst.unwrap=()=>inst._zod.def.innerType,inst.removeDefault=inst.unwrap});function _default(innerType,defaultValue){return new ZodDefault({type:"default",innerType,get defaultValue(){return typeof defaultValue==="function"?defaultValue():shallowClone(defaultValue)}})}var ZodPrefault=$constructor("ZodPrefault",(inst,def)=>{$ZodPrefault.init(inst,def),ZodType.init(inst,def),inst._zod.processJSONSchema=(ctx,json,params)=>prefaultProcessor(inst,ctx,json,params),inst.unwrap=()=>inst._zod.def.innerType});function prefault(innerType,defaultValue){return new ZodPrefault({type:"prefault",innerType,get defaultValue(){return typeof defaultValue==="function"?defaultValue():shallowClone(defaultValue)}})}var ZodNonOptional=$constructor("ZodNonOptional",(inst,def)=>{$ZodNonOptional.init(inst,def),ZodType.init(inst,def),inst._zod.processJSONSchema=(ctx,json,params)=>nonoptionalProcessor(inst,ctx,json,params),inst.unwrap=()=>inst._zod.def.innerType});function nonoptional(innerType,params){return new ZodNonOptional({type:"nonoptional",innerType,...normalizeParams(params)})}var ZodCatch=$constructor("ZodCatch",(inst,def)=>{$ZodCatch.init(inst,def),ZodType.init(inst,def),inst._zod.processJSONSchema=(ctx,json,params)=>catchProcessor(inst,ctx,json,params),inst.unwrap=()=>inst._zod.def.innerType,inst.removeCatch=inst.unwrap});function _catch(innerType,catchValue){return new ZodCatch({type:"catch",innerType,catchValue:typeof catchValue==="function"?catchValue:constantCatch(catchValue)})}var ZodPipe=$constructor("ZodPipe",(inst,def)=>{$ZodPipe.init(inst,def),ZodType.init(inst,def),inst._zod.processJSONSchema=(ctx,json,params)=>pipeProcessor(inst,ctx,json,params),inst.in=def.in,inst.out=def.out});function pipe(in_,out){return new ZodPipe({type:"pipe",in:in_,out})}var ZodReadonly=$constructor("ZodReadonly",(inst,def)=>{$ZodReadonly.init(inst,def),ZodType.init(inst,def),inst._zod.processJSONSchema=(ctx,json,params)=>readonlyProcessor(inst,ctx,json,params),inst.unwrap=()=>inst._zod.def.innerType});function readonly(innerType){return new ZodReadonly({type:"readonly",innerType})}var ZodCustom=$constructor("ZodCustom",(inst,def)=>{$ZodCustom.init(inst,def),ZodType.init(inst,def),inst._zod.processJSONSchema=(ctx,json,params)=>customProcessor(inst,ctx,json,params)});function refine(fn,_params={}){return _refine(ZodCustom,fn,_params)}function superRefine(fn,params){return _superRefine(fn,params)}import{stripVTControlCharacters as stripVTControlCharacters4}from"node:util";function terminalText(value){return stripVTControlCharacters4(value).replace(/[\p{C}\p{Zl}\p{Zp}]/gu,"")}class SignInError extends Error{retryable;name="SignInError";constructor(message,retryable=!1){super(message);this.retryable=retryable}}class RequestFailure extends SignInError{notSent;constructor(notSent){super("Unable to complete the service request. Check the connection and retry.",!0);this.notSent=notSent}}var platformSchema=_enum(["macos","linux","windows"]),nonempty=string2().min(1),timestamp=string2().datetime({offset:!0}),tokenSchema=object({accessToken:nonempty,accessTokenExpiresAt:timestamp,refreshToken:nonempty}),grantSchema=tokenSchema.extend({device:object({id:nonempty,name:nonempty}),offlineGrant:nonempty.optional()}),credentialSchema=grantSchema.extend({signingPrivateKey:nonempty,sealingPrivateKey:nonempty,refreshState:literal("uncertain").optional()}),deviceCodeSchema=object({deviceCode:string2().regex(/^dc\.[A-Za-z0-9_-]{43}$/),userCode:string2().regex(/^[BCDFGHJKLMNPQRSTVWXZ]{4}-[BCDFGHJKLMNPQRSTVWXZ]{4}$/),matchingCode:string2().regex(/^\d{3} \d{3}$/),verificationUri:string2().transform(terminalText).pipe(string2().url()),expiresAt:timestamp,intervalSeconds:number2().int().min(1).max(60)}),envelopeSchema=object({error:object({code:nonempty,message:string2(),retryable:boolean2(),requestId:string2(),detail:unknown().optional()})}),limitSchema=object({reason:literal("device_limit"),managementToken:nonempty,used:number2().int().nonnegative(),limit:number2().int().nonnegative()}),deviceListSchema=object({devices:array(object({id:nonempty,name:nonempty,revokedAt:timestamp.nullable()}))});class ApiRefusal extends SignInError{status;code;#detail;#retryAfter;constructor(code,status,detail,retryAfter=null){super("The service refused this request. Sign in again or check your account.",status===429||status>=500);this.status=status;this.code=["unauthorized","account_deleted","reauth_required","invalid_grant","device_revoked","entitlement_required","authorization_pending","slow_down","access_denied","expired_token","rate_limited","internal","unavailable","forbidden","invalid_request","not_found"].includes(code)?code:"unknown",this.#detail=detail,this.#retryAfter=retryAfter}get detail(){return this.#detail}retryDelay(now,fallback){let raw=this.#retryAfter,delay=raw===null?Number.NaN:/^\d+$/.test(raw)?Number(raw)*1000:Date.parse(raw)-now;return Math.min(60000,Math.max(fallback,Number.isFinite(delay)?delay:fallback))}}function parseReply(schema,value){let result=schema.safeParse(value);if(!result.success)throw new SignInError("The service returned an invalid response.");return result.data}function serviceOrigin(value){let url;try{url=new URL(value)}catch{throw new SignInError("Invalid service URL.")}let loopback=url.protocol==="http:"&&url.hostname==="127.0.0.1"&&url.port!=="";if(url.protocol!=="https:"&&!loopback||url.username||url.password||url.search||url.hash||url.pathname!=="/")throw new SignInError("Service URLs must be HTTPS origins, or http://127.0.0.1:<port> for local testing.");return url.origin}async function requestApi(api,path,init,signal){let response,body;try{response=await fetch(`${api}${path}`,{...init,redirect:"error",signal:signal?AbortSignal.any([signal,AbortSignal.timeout(30000)]):AbortSignal.timeout(30000)})}catch(error){let cause=error instanceof Error&&error.cause instanceof Error?error.cause:error,code=cause instanceof Error?Reflect.get(cause,"code"):void 0;throw new RequestFailure(typeof code==="string"&&["ENOTFOUND","ECONNREFUSED","ENETUNREACH","EHOSTUNREACH","EAI_AGAIN","ConnectionRefused","EADDRNOTAVAIL","ENETDOWN","EHOSTDOWN","UND_ERR_CONNECT_TIMEOUT","ERR_TLS_HANDSHAKE_TIMEOUT","DEPTH_ZERO_SELF_SIGNED_CERT","CERT_HAS_EXPIRED","ERR_TLS_CERT_ALTNAME_INVALID","UNABLE_TO_VERIFY_LEAF_SIGNATURE","SELF_SIGNED_CERT_IN_CHAIN","CERT_NOT_YET_VALID","UNABLE_TO_GET_ISSUER_CERT","UNABLE_TO_GET_ISSUER_CERT_LOCALLY","CERT_SIGNATURE_FAILURE","CERT_UNTRUSTED","CERT_REJECTED"].includes(code))}if(response.status===204)return null;try{body=await response.json()}catch{throw new RequestFailure(!1)}if(response.ok)return body;let envelope=envelopeSchema.safeParse(body);if(!envelope.success)throw new SignInError("The service returned an invalid error response.");let error=envelope.data.error,detail=limitSchema.safeParse(error.detail);throw new ApiRefusal(error.code,response.status,error.code==="entitlement_required"&&detail.success?detail.data:void 0,response.headers.get("retry-after"))}var jsonRequest=(body)=>({method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(body)});function deviceName(host=hostname()){return[...`omo CLI on ${host}`.replace(/[\p{Cc}\p{Zl}\p{Zp}\p{Cf}\u3164\u115F\u1160\uFFA0]/gu,"").trim()].slice(0,64).join("").trim()}function devicePlatform(){switch(process.platform){case"darwin":return"macos";case"linux":return"linux";case"win32":return"windows";default:throw new SignInError("This platform is not supported for OmO sign-in.")}}import{setTimeout as setTimeout2}from"node:timers/promises";import{generateKeyPairSync}from"node:crypto";function generateDeviceKeys(){let signing=generateKeyPairSync("ed25519"),sealing=generateKeyPairSync("x25519"),signingKey=signing.publicKey.export({format:"jwk"}).x,sealingKey=sealing.publicKey.export({format:"jwk"}).x;if(!signingKey||!sealingKey)throw new SignInError("Unable to generate device keys.");return{public:{signingKey,sealingKey},private:{signingPrivateKey:signing.privateKey.export({format:"der",type:"pkcs8"}).toString("base64"),sealingPrivateKey:sealing.privateKey.export({format:"der",type:"pkcs8"}).toString("base64")}}}async function loginDevice(session,options){await session.ready();let keys=generateDeviceKeys(),minted=parseReply(deviceCodeSchema,await session.request("/v1/device/code",jsonRequest({client:{name:options.name,platform:options.platform}}))),uri=new URL(minted.verificationUri);if(uri.protocol!=="https:"&&!(uri.protocol==="http:"&&uri.hostname==="127.0.0.1"&&uri.port!==""))throw new SignInError("The service returned an unsafe verification URL.");options.show({verificationUri:minted.verificationUri,userCode:minted.userCode,matchingCode:minted.matchingCode});let now=options.now??Date.now,sleep=options.sleep??((ms)=>setTimeout2(ms,void 0,{signal:session.signal})),expiresAt=Date.parse(minted.expiresAt),interval=minted.intervalSeconds*1000;while(now()<expiresAt){if(await sleep(Math.min(interval,expiresAt-now())),session.signal?.throwIfAborted(),now()>=expiresAt)break;try{let grant=parseReply(grantSchema,await session.request("/v1/device/token",jsonRequest({deviceCode:minted.deviceCode,...keys.public})));await session.save({...grant,...keys.private});return}catch(error){if(!(error instanceof ApiRefusal))throw error;if(error.status===400&&error.code==="authorization_pending")continue;if(error.status===400&&error.code==="slow_down"){interval+=5000;continue}if(error.status===429){interval=error.retryDelay(now(),Math.min(60000,interval+5000));continue}if(error.detail!==void 0){if(await session.removeForLimit(error,options.chooseDevice))continue;throw new SignInError("Sign-in cancelled. No device was removed.")}if(["access_denied","expired_token","invalid_grant"].includes(error.code))throw new SignInError("Device sign-in was denied or expired. Run omo login again for a new code.");throw error}}throw new SignInError("Device sign-in expired. Run omo login again for a new code.")}import{createHash}from"node:crypto";import{spawn}from"node:child_process";var DEFAULT_COLLECTION="/org/freedesktop/secrets/aliases/default",PROBE_TIMEOUT_MS=1e4,parseLockedReply=(stdout)=>{let match=/<\s*(true|false)\s*>/.exec(stdout);if(match===null)return null;return match[1]==="true"?"locked":"unlocked"},probeSecretServiceLock=()=>new Promise((resolve)=>{let child=spawn("gdbus",["call","--session","--dest","org.freedesktop.secrets","--object-path",DEFAULT_COLLECTION,"--method","org.freedesktop.DBus.Properties.Get","org.freedesktop.Secret.Collection","Locked"],{stdio:["ignore","pipe","ignore"]}),stdout="",timer=setTimeout(()=>{child.kill(),resolve("unknown")},PROBE_TIMEOUT_MS);child.stdout.on("data",(chunk)=>{stdout+=chunk.toString()}),child.on("error",()=>{clearTimeout(timer),resolve("unknown")}),child.on("close",(code)=>{clearTimeout(timer),resolve(code===0?parseLockedReply(stdout)??"absent":"absent")})});class CredentialStoreError extends SignInError{}class KeychainLockedError extends CredentialStoreError{}class SecretServiceUnavailableError extends CredentialStoreError{}class InvalidCredentialState extends SignInError{}var LOCKED=/-25308|errSecInteractionNotAllowed|interaction is not allowed|locked collection/i,UNLOCKED_REUSE_MS=30000,fallbackNoticed=!1,stderrNoticeOncePerProcess=(message)=>{if(fallbackNoticed)return;fallbackNoticed=!0,process.stderr.write(`${message}
116
+ `)};var isLocked=(error)=>error instanceof Error&&(LOCKED.test(error.message)||LOCKED.test(String(error.code??"")));function credentialId(api){return createHash("sha256").update(serviceOrigin(api)).digest("hex")}function createCredentialStore(api,secrets=typeof Bun>"u"?null:Bun.secrets,platform=process.platform,lockProbe=probeSecretServiceLock,notice=stderrNoticeOncePerProcess){return createSealedStore(api,"omo-cli",credentialSchema,secrets,platform,lockProbe,notice)}function createSealedStore(api,namespace,schema,secrets=typeof Bun>"u"?null:Bun.secrets,platform=process.platform,lockProbe=probeSecretServiceLock,notice=stderrNoticeOncePerProcess){if(!secrets)throw new SignInError("OmO sign-in needs Bun 1.4 or newer with OS credential storage. No file fallback is available.");let platformName=platform==="darwin"?"macOS Keychain":platform==="linux"?"Linux Secret Service (libsecret and an unlocked keyring)":platform==="win32"?"Windows Credential Manager":null;if(platformName===null)throw new SignInError("This platform has no supported OS credential store.");let key={service:namespace,name:credentialId(api)},unavailable=(error)=>isLocked(error)?new KeychainLockedError(`${platformName} is locked. Unlock it, then try again. Credentials are never saved to a file.`):new CredentialStoreError(`Cannot access ${platformName}. Unlock or enable the OS credential store and try again. Credentials are never saved to a file.`),unlockedUntil=0,noticed=!1,assertUsable=async()=>{if(platform!=="linux"||Date.now()<unlockedUntil)return;let lock=await lockProbe();if(lock==="locked")throw new KeychainLockedError(`${platformName} is locked. Unlock it, then try again. Credentials are never saved to a file.`);if(lock==="unlocked"){unlockedUntil=Date.now()+UNLOCKED_REUSE_MS;return}if(!noticed)noticed=!0,notice("omo: could not check whether the keyring is locked (gdbus or the Secret Service did not answer); using libsecret directly.")};return{async read(){await assertUsable();let value;try{value=await secrets.get(key)}catch(error){throw unavailable(error)}if(value===null)return null;try{return schema.parse(JSON.parse(value))}catch{throw new InvalidCredentialState("Stored sign-in data is invalid. Run omo logout, then omo login.")}},async write(value){await assertUsable();try{await secrets.set({...key,value:JSON.stringify(schema.parse(value))})}catch(error){throw unavailable(error)}},async clear(){await assertUsable();try{await secrets.delete(key)}catch(error){throw unavailable(error)}}}}import{createHash as createHash2,randomBytes,timingSafeEqual}from"node:crypto";import{createServer}from"node:http";class BrowserUnavailable extends SignInError{}async function authorize(options){let verifier=randomBytes(32).toString("base64url"),state=randomBytes(32).toString("base64url"),answer=Promise.withResolvers(),abort=()=>answer.reject(new SignInError("Browser sign-in cancelled or timed out.")),accepted=!1,origin="",server=createServer((request,response)=>{response.setHeader("cache-control","no-store"),response.setHeader("referrer-policy","no-referrer"),response.setHeader("content-type","text/plain; charset=utf-8");let url=new URL(request.url??"/",origin);if(request.method!=="GET"||request.headers.host!==new URL(origin).host||url.origin!==origin||url.pathname!=="/callback"||request.headers.forwarded||request.headers["x-forwarded-for"]){response.writeHead(404).end("Not found");return}let code=url.searchParams.get("code"),suppliedState=Buffer.from(url.searchParams.get("state")??""),expectedState=Buffer.from(state);if(accepted||url.searchParams.getAll("state").length!==1||suppliedState.length!==expectedState.length||!timingSafeEqual(suppliedState,expectedState)||url.searchParams.getAll("code").length!==1||!code){response.writeHead(400).end("Invalid sign-in response");return}accepted=!0,response.writeHead(200).end("Return to the terminal to finish signing in."),answer.resolve(code)});try{await new Promise((resolve,reject)=>{server.once("error",reject),server.listen(0,"127.0.0.1",()=>{server.off("error",reject),resolve()})});let address=server.address();if(!address||typeof address==="string")throw new SignInError("Unable to start the sign-in callback.");origin=`http://127.0.0.1:${address.port}`;let url=new URL(serviceOrigin(options.accounts));url.search=new URLSearchParams({redirect_uri:`${origin}/callback`,code_challenge:createHash2("sha256").update(verifier).digest("base64url"),code_challenge_method:"S256",state}).toString();let timer=setTimeout(abort,300000);options.signal?.addEventListener("abort",abort,{once:!0});try{options.signal?.throwIfAborted();let openerFailed=()=>{if(!accepted)throw new BrowserUnavailable("No browser is available; use device sign-in.")},[code]=await Promise.all([answer.promise,options.open(url.href).then((opened)=>{if(!opened)openerFailed()},openerFailed)]);return{code,codeVerifier:verifier}}finally{clearTimeout(timer),options.signal?.removeEventListener("abort",abort)}}finally{server.closeAllConnections(),await new Promise((resolve)=>server.close(()=>resolve()))}}async function loginLoopback(session,options){await session.ready();let keys=generateDeviceKeys();for(;;){let authorization=await authorize({accounts:options.accounts,open:options.open,signal:session.signal});try{let grant=parseReply(grantSchema,await session.request("/v1/session/exchange",jsonRequest({...authorization,kind:"cli",deviceName:options.name,platform:options.platform,...keys.public})));await session.save({...grant,...keys.private});return}catch(error){if(await session.removeForLimit(error,options.chooseDevice))continue;throw new SignInError("Sign-in cancelled. No device was removed.")}}}import{mkdir}from"node:fs/promises";import{homedir}from"node:os";import{join}from"node:path";import{access,open as open2,unlink}from"node:fs/promises";import{dirname}from"node:path";import{randomUUID}from"node:crypto";import{readFile,stat}from"node:fs/promises";var lockOwnerInstanceId=randomUUID(),heldLockRecords=new Set;function buildLockRecord(ownerTag){return`${ownerTag} ${randomUUID()}
117
117
  ${process.pid}
118
118
  ${Date.now()}
119
119
  ${lockOwnerInstanceId}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "omo-ai",
3
- "version": "5.1.46",
3
+ "version": "5.1.47",
4
4
  "type": "module",
5
5
  "description": "OmO Native - the standalone omo command with the OMO extension built in: bun add -g omo-ai",
6
6
  "bin": {
@@ -7,6 +7,50 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [5.1.47] - 2026-10-25
11
+
12
+ - Memory path-state recovery and commit hooks now keep literal Git lookups working when global glob or case-insensitive pathspec modes are enabled ([#11130](https://github.com/code-yeongyu/oh-my-openagent/issues/11130), [#11167](https://github.com/code-yeongyu/oh-my-openagent/pull/11167)). (batch [#11187](https://github.com/code-yeongyu/oh-my-openagent/pull/11187))
13
+
14
+ **A user Stop pauses the workflow run it started instead of cancelling it.** DAG nodes, workpool workers and task children hold where they are; a message to the paused run or Resume continues it from where it stopped. ([#10808](https://github.com/code-yeongyu/oh-my-openagent/pull/10808), fixes [#6752](https://github.com/code-yeongyu/oh-my-openagent/issues/6752)) (batch [#11187](https://github.com/code-yeongyu/oh-my-openagent/pull/11187))
15
+
16
+ **Concurrent file touches show each project memory nudge once.** Project memory reads reserve the nudge before asynchronous loading, retry failed reads, and discard stale results after compaction or session changes. ([#11165](https://github.com/code-yeongyu/oh-my-openagent/pull/11165), addresses item 1 of [#10927](https://github.com/code-yeongyu/oh-my-openagent/issues/10927)) (batch [#11187](https://github.com/code-yeongyu/oh-my-openagent/pull/11187))
17
+
18
+ **A finished workflow run now shows as a finished run.** When a workflow (DAG) run started from a session completes, including one that completes after recovery, the engine records the session's completion as a finished run instead of a plain reply ([#11155](https://github.com/code-yeongyu/oh-my-openagent/pull/11155)). (batch [#11187](https://github.com/code-yeongyu/oh-my-openagent/pull/11187))
19
+
20
+ **A finished ulw-execute plan now shows as a finished run.** When this session's own ulw-execute work is marked completed, the engine records the session's completion as a finished run instead of a plain reply. Work finished by an earlier run, abandoned work, and another session's work are not counted ([#11174](https://github.com/code-yeongyu/oh-my-openagent/pull/11174)). (batch [#11187](https://github.com/code-yeongyu/oh-my-openagent/pull/11187))
21
+
22
+ **A completed ulw-loop plan now shows as a finished run.** When this session's ulw-loop plan reaches its aggregate completion, the engine records the session's completion as a finished run instead of a plain reply. A plan that was already complete when the session started is not counted ([#11175](https://github.com/code-yeongyu/oh-my-openagent/pull/11175)). (batch [#11187](https://github.com/code-yeongyu/oh-my-openagent/pull/11187))
23
+
24
+ **CI exposes the lint ratchet as its own required-free status check.** Pull requests, pushes and merge groups run `Lint ratchet` independently of the heavy-validation typecheck path. ([#11128](https://github.com/code-yeongyu/oh-my-openagent/pull/11128), thanks @Dante-dan) (batch [#11187](https://github.com/code-yeongyu/oh-my-openagent/pull/11187))
25
+
26
+ **The 10k parked-backlog memory test now fails if it observed no entry reads.** ([#11164](https://github.com/code-yeongyu/oh-my-openagent/pull/11164), part of [#11091](https://github.com/code-yeongyu/oh-my-openagent/issues/11091), thanks @Dante-dan) (batch [#11187](https://github.com/code-yeongyu/oh-my-openagent/pull/11187))
27
+
28
+ **omo.dev/download no longer answers 404.** Desktop builds link it from the reinstall screen and the .deb update pill; while the site's own download page is off, `/download` and `/<locale>/download` now redirect to the public beta download page at https://get.omo.dev/desktop/beta/. ([#11270](https://github.com/code-yeongyu/oh-my-openagent/pull/11270))
29
+
30
+ **Gateway wakes, UI answers and releases reach a host session known only by its durable id.** A multi-session host refuses any command that names no session, so a wake for a session read from disk or found by `thread locate` was lost with `missing_session_id`. The client now looks the session up on its host by durable id and routes the command; when no live session holds it, the delivery stays queued for the session's next start and `omo thread report` says the completion's wake did not reach it. ([#11188](https://github.com/code-yeongyu/oh-my-openagent/pull/11188), fixes [#11185](https://github.com/code-yeongyu/oh-my-openagent/issues/11185), part of [#10995](https://github.com/code-yeongyu/oh-my-openagent/issues/10995)) ([#11252](https://github.com/code-yeongyu/oh-my-openagent/pull/11252))
31
+
32
+ **Turning telemetry off through an environment variable no longer deletes summaries another session queued under a profile.** A session whose `OMO_PROFILE` turns telemetry on could lose its queued usage summary when another session started with `DO_NOT_TRACK` and the base `omo.json` setting was off. Each summary queued from now on remembers the config it was recorded under and is judged by it when it is sent, resumed or cleaned up; summaries queued before the upgrade keep the old reading until they expire. ([#11198](https://github.com/code-yeongyu/oh-my-openagent/issues/11198)) ([#11202](https://github.com/code-yeongyu/oh-my-openagent/pull/11202)) ([#11252](https://github.com/code-yeongyu/oh-my-openagent/pull/11252))
33
+
34
+ **The telemetry reference now states exactly which queued summaries an opt-out deletes and what the legacy `rollups` cleanup can and cannot remove.** ([#11181](https://github.com/code-yeongyu/oh-my-openagent/pull/11181)) ([#11252](https://github.com/code-yeongyu/oh-my-openagent/pull/11252))
35
+
36
+ **senpi's on-demand memory report now shows OmO's task children and memory recall.** With `SENPI_MEMORY_REPORT=1`, a report gains an `omoTask` section (resident task children, cached task records and their bytes, open event logs) and an `omoRecall` section (loaded memory corpora, their text bytes, the recall index's term arrays and dictionary size), so a large session's memory can be traced to these layers. Nothing is measured unless a report is taken. ([#11178](https://github.com/code-yeongyu/oh-my-openagent/pull/11178), part of [#9442](https://github.com/code-yeongyu/oh-my-openagent/issues/9442)) ([#11252](https://github.com/code-yeongyu/oh-my-openagent/pull/11252))
37
+
38
+ **Kimi K3.1 gets its own Sisyphus, Sisyphus-Junior and Atlas prompts.** Kimi K3.1 Pro ids (`k3.1-pro`, `kimi-k3.1-pro` and their Highspeed versions) now route to separate copies of the K3 prompts instead of sharing K3's, and the Kimi Code id `k3.1-pro` gets a Kimi prompt at all. `kimi-k3.1-pro` maps to Kimi Code's `k3.1-pro` id. ([#11197](https://github.com/code-yeongyu/oh-my-openagent/pull/11197)) ([#11252](https://github.com/code-yeongyu/oh-my-openagent/pull/11252))
39
+
40
+ **Protocol-2 account storage has separate credential and pending-revocation namespaces.** Legacy credential writes and deletes cannot overwrite either namespace; the origin key and native storage-error mappings stay shared. This is storage support for the protocol-2 rollout, not enrollment activation. ([#11177](https://github.com/code-yeongyu/oh-my-openagent/pull/11177), refs [omo-service#628](https://github.com/sisyphuslabs/omo-service/issues/628)) ([#11252](https://github.com/code-yeongyu/oh-my-openagent/pull/11252))
41
+
42
+ **A background task whose task host stays unreachable no longer comes back as a leftover session after recovery gives up.** When a task child's reconnect timed out and its host answered only later, the stalled reconnect could retry after the session had already been closed and reopen it on the host, leaving a live session and its processes behind. The abandoned reconnect now stops retrying, while the parked child keeps its respawn and its single notice. ([#11246](https://github.com/code-yeongyu/oh-my-openagent/pull/11246), fixes [#10925](https://github.com/code-yeongyu/oh-my-openagent/issues/10925)) ([#11252](https://github.com/code-yeongyu/oh-my-openagent/pull/11252))
43
+
44
+ **Windows Codex commands no longer stop at a command syntax error.** Generated command shims accept a quoted `NODE_REPL_NODE_PATH` in `config.toml` and also run when that setting or the config file is absent. Thanks to @fvegiard for the report and @LilMGenius for the fix. ([#11222](https://github.com/code-yeongyu/oh-my-openagent/pull/11222), fixes [#7473](https://github.com/code-yeongyu/oh-my-openagent/issues/7473)) ([#11252](https://github.com/code-yeongyu/oh-my-openagent/pull/11252))
45
+
46
+ **The ulw-research proofread lane returns edits that are checked before they land.** The writing lane hands back `polish-edits.json`; `fact polish-apply` applies each edit only when it changes text nodes alone and keeps every number, hedge, qualifier, link, and claim id, `fact polish-diff` backstops hand edits, and `fact pairs --changed-since` sends every sentence polish rewrote back to the meaning readers. ([#11160](https://github.com/code-yeongyu/oh-my-openagent/pull/11160), part of [#11009](https://github.com/code-yeongyu/oh-my-openagent/issues/11009))
47
+
48
+ **Changelog entries live in per-PR fragments, so pull requests stop conflicting on the changelogs.** A pull request that changes what ships adds exactly one file, `changes/unreleased/<pr-number>.md`: the paragraph that used to go under `## [Unreleased]` (or `### Fixed`-style bullets), plus a `<!-- changes-log: <path> -->` block for each entry it used to prepend to `changes.md` or `packages/<name>/changes.md`. Only the release pull request edits those files: the release workflow writes every fragment into the release section and the logs, and deletes the fragments. What counts as shipped is unchanged, and `bun script/changelog-fragments-cli.ts from-diff --base origin/dev --pr <n>` converts a branch that still edits the changelogs. ([#10477](https://github.com/code-yeongyu/oh-my-openagent/pull/10477))
49
+
50
+ ### Fixed
51
+
52
+ - Commands OmO starts under Bun now see environment changes made while it runs, as they already did under Node. Before, a child started without an explicit environment got the values the process started with, so it could run with an out-of-date temp or home directory. ([#11260](https://github.com/code-yeongyu/oh-my-openagent/pull/11260)) ([#11252](https://github.com/code-yeongyu/oh-my-openagent/pull/11252))
53
+
10
54
  ## [5.1.46] - 2026-10-24
11
55
 
12
56
  **OmO Native init-deep committed mode no longer dead-ends.** Committed mode now finishes through its own pull-request handoff instead of pointing at a skill that does not ship with OmO Native, and it reports how to finish by hand when no PR can be opened. Thanks to @HolisticDeveloper for the report and @surlymochan for the fix. ([#11228](https://github.com/code-yeongyu/oh-my-openagent/pull/11228), fixes [#9686](https://github.com/code-yeongyu/oh-my-openagent/issues/9686))