@abacus-ai/cli 2.4.5-canary.2 → 2.4.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.mjs +3 -3
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -47,7 +47,7 @@ import{createRequire as e}from"node:module";import*as t from"node:util";import n
|
|
|
47
47
|
|
|
48
48
|
`)}t.write(`payload.value = newResult;`),t.write(`return payload;`);let s=t.compile();return(t,n)=>s(e,t,n)},a,o=Tf,s=!uf.jitless,c=s&&Ef.value,l=t.catchall,u;e._zod.parse=(d,f)=>{u??=r.value;let p=d.value;return o(p)?s&&c&&f?.async===!1&&f.jitless!==!0?(a||=i(t.shape),d=a(d,f),l?Sm([],p,d,f,u,e):d):n(d,f):(d.issues.push({expected:`object`,code:`invalid_type`,input:p,inst:e}),d)}});function Tm(e,t,n,r){for(let n of e)if(n.issues.length===0)return t.value=n.value,t;let i=e.filter(e=>!Pf(e));return i.length===1?(t.value=i[0].value,i[0]):(t.issues.push({code:`invalid_union`,input:t.value,inst:n,errors:e.map(e=>e.issues.map(e=>Lf(e,r,df())))}),t)}const Em=G(`$ZodUnion`,(e,t)=>{zp.init(e,t),yf(e._zod,`optin`,()=>t.options.some(e=>e._zod.optin===`optional`)?`optional`:void 0),yf(e._zod,`optout`,()=>t.options.some(e=>e._zod.optout===`optional`)?`optional`:void 0),yf(e._zod,`values`,()=>{if(t.options.every(e=>e._zod.values))return new Set(t.options.flatMap(e=>Array.from(e._zod.values)))}),yf(e._zod,`pattern`,()=>{if(t.options.every(e=>e._zod.pattern)){let e=t.options.map(e=>e._zod.pattern);return RegExp(`^(${e.map(e=>gf(e.source)).join(`|`)})$`)}});let n=t.options.length===1,r=t.options[0]._zod.run;e._zod.parse=(i,a)=>{if(n)return r(i,a);let o=!1,s=[];for(let e of t.options){let t=e._zod.run({value:i.value,issues:[]},a);if(t instanceof Promise)s.push(t),o=!0;else{if(t.issues.length===0)return t;s.push(t)}}return o?Promise.all(s).then(t=>Tm(t,i,e,a)):Tm(s,i,e,a)}});function Dm(e,t,n,r){let i=e.filter(e=>e.issues.length===0);return i.length===1?(t.value=i[0].value,t):(i.length===0?t.issues.push({code:`invalid_union`,input:t.value,inst:n,errors:e.map(e=>e.issues.map(e=>Lf(e,r,df())))}):t.issues.push({code:`invalid_union`,input:t.value,inst:n,errors:[],inclusive:!1}),t)}const Om=G(`$ZodXor`,(e,t)=>{Em.init(e,t),t.inclusive=!1;let n=t.options.length===1,r=t.options[0]._zod.run;e._zod.parse=(i,a)=>{if(n)return r(i,a);let o=!1,s=[];for(let e of t.options){let t=e._zod.run({value:i.value,issues:[]},a);t instanceof Promise?(s.push(t),o=!0):s.push(t)}return o?Promise.all(s).then(t=>Dm(t,i,e,a)):Dm(s,i,e,a)}}),km=G(`$ZodDiscriminatedUnion`,(e,t)=>{t.inclusive=!1,Em.init(e,t);let n=e._zod.parse;yf(e._zod,`propValues`,()=>{let e={};for(let n of t.options){let r=n._zod.propValues;if(!r||Object.keys(r).length===0)throw Error(`Invalid discriminated union option at index "${t.options.indexOf(n)}"`);for(let[t,n]of Object.entries(r)){e[t]||(e[t]=new Set);for(let r of n)e[t].add(r)}}return e});let r=mf(()=>{let e=t.options,n=new Map;for(let r of e){let e=r._zod.propValues?.[t.discriminator];if(!e||e.size===0)throw Error(`Invalid discriminated union option at index "${t.options.indexOf(r)}"`);for(let t of e){if(n.has(t))throw Error(`Duplicate discriminator value "${String(t)}"`);n.set(t,r)}}return n});e._zod.parse=(i,a)=>{let o=i.value;if(!Tf(o))return i.issues.push({code:`invalid_type`,expected:`object`,input:o,inst:e}),i;let s=r.value.get(o?.[t.discriminator]);return s?s._zod.run(i,a):t.unionFallback?n(i,a):(i.issues.push({code:`invalid_union`,errors:[],note:`No matching discriminator`,discriminator:t.discriminator,input:o,path:[t.discriminator],inst:e}),i)}}),Am=G(`$ZodIntersection`,(e,t)=>{zp.init(e,t),e._zod.parse=(e,n)=>{let r=e.value,i=t.left._zod.run({value:r,issues:[]},n),a=t.right._zod.run({value:r,issues:[]},n);return i instanceof Promise||a instanceof Promise?Promise.all([i,a]).then(([t,n])=>Mm(e,t,n)):Mm(e,i,a)}});function jm(e,t){if(e===t||e instanceof Date&&t instanceof Date&&+e==+t)return{valid:!0,data:e};if(Df(e)&&Df(t)){let n=Object.keys(t),r=Object.keys(e).filter(e=>n.indexOf(e)!==-1),i={...e,...t};for(let n of r){let r=jm(e[n],t[n]);if(!r.valid)return{valid:!1,mergeErrorPath:[n,...r.mergeErrorPath]};i[n]=r.data}return{valid:!0,data:i}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};let n=[];for(let r=0;r<e.length;r++){let i=e[r],a=t[r],o=jm(i,a);if(!o.valid)return{valid:!1,mergeErrorPath:[r,...o.mergeErrorPath]};n.push(o.data)}return{valid:!0,data:n}}return{valid:!1,mergeErrorPath:[]}}function Mm(e,t,n){let r=new Map,i;for(let n of t.issues)if(n.code===`unrecognized_keys`){i??=n;for(let e of n.keys)r.has(e)||r.set(e,{}),r.get(e).l=!0}else e.issues.push(n);for(let t of n.issues)if(t.code===`unrecognized_keys`)for(let e of t.keys)r.has(e)||r.set(e,{}),r.get(e).r=!0;else e.issues.push(t);let a=[...r].filter(([,e])=>e.l&&e.r).map(([e])=>e);if(a.length&&i&&e.issues.push({...i,keys:a}),Pf(e))return e;let o=jm(t.value,n.value);if(!o.valid)throw Error(`Unmergable intersection. Error path: ${JSON.stringify(o.mergeErrorPath)}`);return e.value=o.data,e}const Nm=G(`$ZodTuple`,(e,t)=>{zp.init(e,t);let n=t.items;e._zod.parse=(r,i)=>{let a=r.value;if(!Array.isArray(a))return r.issues.push({input:a,inst:e,expected:`tuple`,code:`invalid_type`}),r;r.value=[];let o=[],s=[...n].reverse().findIndex(e=>e._zod.optin!==`optional`),c=s===-1?0:n.length-s;if(!t.rest){let t=a.length>n.length,i=a.length<c-1;if(t||i)return r.issues.push({...t?{code:`too_big`,maximum:n.length,inclusive:!0}:{code:`too_small`,minimum:n.length},input:a,inst:e,origin:`array`}),r}let l=-1;for(let e of n){if(l++,l>=a.length&&l>=c)continue;let t=e._zod.run({value:a[l],issues:[]},i);t instanceof Promise?o.push(t.then(e=>Pm(e,r,l))):Pm(t,r,l)}if(t.rest){let e=a.slice(n.length);for(let n of e){l++;let e=t.rest._zod.run({value:n,issues:[]},i);e instanceof Promise?o.push(e.then(e=>Pm(e,r,l))):Pm(e,r,l)}}return o.length?Promise.all(o).then(()=>r):r}});function Pm(e,t,n){e.issues.length&&t.issues.push(...Ff(n,e.issues)),t.value[n]=e.value}const Fm=G(`$ZodRecord`,(e,t)=>{zp.init(e,t),e._zod.parse=(n,r)=>{let i=n.value;if(!Df(i))return n.issues.push({expected:`record`,code:`invalid_type`,input:i,inst:e}),n;let a=[],o=t.keyType._zod.values;if(o){n.value={};let s=new Set;for(let e of o)if(typeof e==`string`||typeof e==`number`||typeof e==`symbol`){s.add(typeof e==`number`?e.toString():e);let o=t.valueType._zod.run({value:i[e],issues:[]},r);o instanceof Promise?a.push(o.then(t=>{t.issues.length&&n.issues.push(...Ff(e,t.issues)),n.value[e]=t.value})):(o.issues.length&&n.issues.push(...Ff(e,o.issues)),n.value[e]=o.value)}let c;for(let e in i)s.has(e)||(c??=[],c.push(e));c&&c.length>0&&n.issues.push({code:`unrecognized_keys`,input:i,inst:e,keys:c})}else{n.value={};for(let o of Reflect.ownKeys(i)){if(o===`__proto__`)continue;let s=t.keyType._zod.run({value:o,issues:[]},r);if(s instanceof Promise)throw Error(`Async schemas not supported in object keys currently`);if(typeof o==`string`&&xp.test(o)&&s.issues.length){let e=t.keyType._zod.run({value:Number(o),issues:[]},r);if(e instanceof Promise)throw Error(`Async schemas not supported in object keys currently`);e.issues.length===0&&(s=e)}if(s.issues.length){t.mode===`loose`?n.value[o]=i[o]:n.issues.push({code:`invalid_key`,origin:`record`,issues:s.issues.map(e=>Lf(e,r,df())),input:o,path:[o],inst:e});continue}let c=t.valueType._zod.run({value:i[o],issues:[]},r);c instanceof Promise?a.push(c.then(e=>{e.issues.length&&n.issues.push(...Ff(o,e.issues)),n.value[s.value]=e.value})):(c.issues.length&&n.issues.push(...Ff(o,c.issues)),n.value[s.value]=c.value)}}return a.length?Promise.all(a).then(()=>n):n}}),Im=G(`$ZodMap`,(e,t)=>{zp.init(e,t),e._zod.parse=(n,r)=>{let i=n.value;if(!(i instanceof Map))return n.issues.push({expected:`map`,code:`invalid_type`,input:i,inst:e}),n;let a=[];n.value=new Map;for(let[o,s]of i){let c=t.keyType._zod.run({value:o,issues:[]},r),l=t.valueType._zod.run({value:s,issues:[]},r);c instanceof Promise||l instanceof Promise?a.push(Promise.all([c,l]).then(([t,a])=>{Lm(t,a,n,o,i,e,r)})):Lm(c,l,n,o,i,e,r)}return a.length?Promise.all(a).then(()=>n):n}});function Lm(e,t,n,r,i,a,o){e.issues.length&&(kf.has(typeof r)?n.issues.push(...Ff(r,e.issues)):n.issues.push({code:`invalid_key`,origin:`map`,input:i,inst:a,issues:e.issues.map(e=>Lf(e,o,df()))})),t.issues.length&&(kf.has(typeof r)?n.issues.push(...Ff(r,t.issues)):n.issues.push({origin:`map`,code:`invalid_element`,input:i,inst:a,key:r,issues:t.issues.map(e=>Lf(e,o,df()))})),n.value.set(e.value,t.value)}const Rm=G(`$ZodSet`,(e,t)=>{zp.init(e,t),e._zod.parse=(n,r)=>{let i=n.value;if(!(i instanceof Set))return n.issues.push({input:i,inst:e,expected:`set`,code:`invalid_type`}),n;let a=[];n.value=new Set;for(let e of i){let i=t.valueType._zod.run({value:e,issues:[]},r);i instanceof Promise?a.push(i.then(e=>zm(e,n))):zm(i,n)}return a.length?Promise.all(a).then(()=>n):n}});function zm(e,t){e.issues.length&&t.issues.push(...e.issues),t.value.add(e.value)}const Bm=G(`$ZodEnum`,(e,t)=>{zp.init(e,t);let n=ff(t.entries),r=new Set(n);e._zod.values=r,e._zod.pattern=RegExp(`^(${n.filter(e=>kf.has(typeof e)).map(e=>typeof e==`string`?jf(e):e.toString()).join(`|`)})$`),e._zod.parse=(t,i)=>{let a=t.value;return r.has(a)||t.issues.push({code:`invalid_value`,values:n,input:a,inst:e}),t}}),Vm=G(`$ZodLiteral`,(e,t)=>{if(zp.init(e,t),t.values.length===0)throw Error(`Cannot create literal schema with no valid values`);let n=new Set(t.values);e._zod.values=n,e._zod.pattern=RegExp(`^(${t.values.map(e=>typeof e==`string`?jf(e):e?jf(e.toString()):String(e)).join(`|`)})$`),e._zod.parse=(r,i)=>{let a=r.value;return n.has(a)||r.issues.push({code:`invalid_value`,values:t.values,input:a,inst:e}),r}}),Hm=G(`$ZodFile`,(e,t)=>{zp.init(e,t),e._zod.parse=(t,n)=>{let r=t.value;return r instanceof File||t.issues.push({expected:`file`,code:`invalid_type`,input:r,inst:e}),t}}),Um=G(`$ZodTransform`,(e,t)=>{zp.init(e,t),e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new lf(e.constructor.name);let i=t.transform(n.value,n);if(r.async)return(i instanceof Promise?i:Promise.resolve(i)).then(e=>(n.value=e,n));if(i instanceof Promise)throw new cf;return n.value=i,n}});function Wm(e,t){return e.issues.length&&t===void 0?{issues:[],value:void 0}:e}const Gm=G(`$ZodOptional`,(e,t)=>{zp.init(e,t),e._zod.optin=`optional`,e._zod.optout=`optional`,yf(e._zod,`values`,()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),yf(e._zod,`pattern`,()=>{let e=t.innerType._zod.pattern;return e?RegExp(`^(${gf(e.source)})?$`):void 0}),e._zod.parse=(e,n)=>{if(t.innerType._zod.optin===`optional`){let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(t=>Wm(t,e.value)):Wm(r,e.value)}return e.value===void 0?e:t.innerType._zod.run(e,n)}}),Km=G(`$ZodExactOptional`,(e,t)=>{Gm.init(e,t),yf(e._zod,`values`,()=>t.innerType._zod.values),yf(e._zod,`pattern`,()=>t.innerType._zod.pattern),e._zod.parse=(e,n)=>t.innerType._zod.run(e,n)}),qm=G(`$ZodNullable`,(e,t)=>{zp.init(e,t),yf(e._zod,`optin`,()=>t.innerType._zod.optin),yf(e._zod,`optout`,()=>t.innerType._zod.optout),yf(e._zod,`pattern`,()=>{let e=t.innerType._zod.pattern;return e?RegExp(`^(${gf(e.source)}|null)$`):void 0}),yf(e._zod,`values`,()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,null]):void 0),e._zod.parse=(e,n)=>e.value===null?e:t.innerType._zod.run(e,n)}),Jm=G(`$ZodDefault`,(e,t)=>{zp.init(e,t),e._zod.optin=`optional`,yf(e._zod,`values`,()=>t.innerType._zod.values),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);if(e.value===void 0)return e.value=t.defaultValue,e;let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(e=>Ym(e,t)):Ym(r,t)}});function Ym(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}const Xm=G(`$ZodPrefault`,(e,t)=>{zp.init(e,t),e._zod.optin=`optional`,yf(e._zod,`values`,()=>t.innerType._zod.values),e._zod.parse=(e,n)=>(n.direction===`backward`||e.value===void 0&&(e.value=t.defaultValue),t.innerType._zod.run(e,n))}),Zm=G(`$ZodNonOptional`,(e,t)=>{zp.init(e,t),yf(e._zod,`values`,()=>{let e=t.innerType._zod.values;return e?new Set([...e].filter(e=>e!==void 0)):void 0}),e._zod.parse=(n,r)=>{let i=t.innerType._zod.run(n,r);return i instanceof Promise?i.then(t=>Qm(t,e)):Qm(i,e)}});function Qm(e,t){return!e.issues.length&&e.value===void 0&&e.issues.push({code:`invalid_type`,expected:`nonoptional`,input:e.value,inst:t}),e}const $m=G(`$ZodSuccess`,(e,t)=>{zp.init(e,t),e._zod.parse=(e,n)=>{if(n.direction===`backward`)throw new lf(`ZodSuccess`);let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(t=>(e.value=t.issues.length===0,e)):(e.value=r.issues.length===0,e)}}),eh=G(`$ZodCatch`,(e,t)=>{zp.init(e,t),yf(e._zod,`optin`,()=>t.innerType._zod.optin),yf(e._zod,`optout`,()=>t.innerType._zod.optout),yf(e._zod,`values`,()=>t.innerType._zod.values),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(r=>(e.value=r.value,r.issues.length&&(e.value=t.catchValue({...e,error:{issues:r.issues.map(e=>Lf(e,n,df()))},input:e.value}),e.issues=[]),e)):(e.value=r.value,r.issues.length&&(e.value=t.catchValue({...e,error:{issues:r.issues.map(e=>Lf(e,n,df()))},input:e.value}),e.issues=[]),e)}}),th=G(`$ZodNaN`,(e,t)=>{zp.init(e,t),e._zod.parse=(t,n)=>((typeof t.value!=`number`||!Number.isNaN(t.value))&&t.issues.push({input:t.value,inst:e,expected:`nan`,code:`invalid_type`}),t)}),nh=G(`$ZodPipe`,(e,t)=>{zp.init(e,t),yf(e._zod,`values`,()=>t.in._zod.values),yf(e._zod,`optin`,()=>t.in._zod.optin),yf(e._zod,`optout`,()=>t.out._zod.optout),yf(e._zod,`propValues`,()=>t.in._zod.propValues),e._zod.parse=(e,n)=>{if(n.direction===`backward`){let r=t.out._zod.run(e,n);return r instanceof Promise?r.then(e=>rh(e,t.in,n)):rh(r,t.in,n)}let r=t.in._zod.run(e,n);return r instanceof Promise?r.then(e=>rh(e,t.out,n)):rh(r,t.out,n)}});function rh(e,t,n){return e.issues.length?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues},n)}const ih=G(`$ZodCodec`,(e,t)=>{zp.init(e,t),yf(e._zod,`values`,()=>t.in._zod.values),yf(e._zod,`optin`,()=>t.in._zod.optin),yf(e._zod,`optout`,()=>t.out._zod.optout),yf(e._zod,`propValues`,()=>t.in._zod.propValues),e._zod.parse=(e,n)=>{if((n.direction||`forward`)===`forward`){let r=t.in._zod.run(e,n);return r instanceof Promise?r.then(e=>ah(e,t,n)):ah(r,t,n)}else{let r=t.out._zod.run(e,n);return r instanceof Promise?r.then(e=>ah(e,t,n)):ah(r,t,n)}}});function ah(e,t,n){if(e.issues.length)return e.aborted=!0,e;if((n.direction||`forward`)===`forward`){let r=t.transform(e.value,e);return r instanceof Promise?r.then(r=>oh(e,r,t.out,n)):oh(e,r,t.out,n)}else{let r=t.reverseTransform(e.value,e);return r instanceof Promise?r.then(r=>oh(e,r,t.in,n)):oh(e,r,t.in,n)}}function oh(e,t,n,r){return e.issues.length?(e.aborted=!0,e):n._zod.run({value:t,issues:e.issues},r)}const sh=G(`$ZodReadonly`,(e,t)=>{zp.init(e,t),yf(e._zod,`propValues`,()=>t.innerType._zod.propValues),yf(e._zod,`values`,()=>t.innerType._zod.values),yf(e._zod,`optin`,()=>t.innerType?._zod?.optin),yf(e._zod,`optout`,()=>t.innerType?._zod?.optout),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(ch):ch(r)}});function ch(e){return e.value=Object.freeze(e.value),e}const lh=G(`$ZodTemplateLiteral`,(e,t)=>{zp.init(e,t);let n=[];for(let e of t.parts)if(typeof e==`object`&&e){if(!e._zod.pattern)throw Error(`Invalid template literal part, no pattern found: ${[...e._zod.traits].shift()}`);let t=e._zod.pattern instanceof RegExp?e._zod.pattern.source:e._zod.pattern;if(!t)throw Error(`Invalid template literal part: ${e._zod.traits}`);let r=t.startsWith(`^`)?1:0,i=t.endsWith(`$`)?t.length-1:t.length;n.push(t.slice(r,i))}else if(e===null||Af.has(typeof e))n.push(jf(`${e}`));else throw Error(`Invalid template literal part: ${e}`);e._zod.pattern=RegExp(`^${n.join(``)}$`),e._zod.parse=(n,r)=>typeof n.value==`string`?(e._zod.pattern.lastIndex=0,e._zod.pattern.test(n.value)||n.issues.push({input:n.value,inst:e,code:`invalid_format`,format:t.format??`template_literal`,pattern:e._zod.pattern.source}),n):(n.issues.push({input:n.value,inst:e,expected:`string`,code:`invalid_type`}),n)}),uh=G(`$ZodFunction`,(e,t)=>(zp.init(e,t),e._def=t,e._zod.def=t,e.implement=t=>{if(typeof t!=`function`)throw Error(`implement() must be called with a function`);return function(...n){let r=e._def.input?Gf(e._def.input,n):n,i=Reflect.apply(t,this,r);return e._def.output?Gf(e._def.output,i):i}},e.implementAsync=t=>{if(typeof t!=`function`)throw Error(`implementAsync() must be called with a function`);return async function(...n){let r=e._def.input?await qf(e._def.input,n):n,i=await Reflect.apply(t,this,r);return e._def.output?await qf(e._def.output,i):i}},e._zod.parse=(t,n)=>typeof t.value==`function`?(e._def.output&&e._def.output._zod.def.type===`promise`?t.value=e.implementAsync(t.value):t.value=e.implement(t.value),t):(t.issues.push({code:`invalid_type`,expected:`function`,input:t.value,inst:e}),t),e.input=(...t)=>{let n=e.constructor;return Array.isArray(t[0])?new n({type:`function`,input:new Nm({type:`tuple`,items:t[0],rest:t[1]}),output:e._def.output}):new n({type:`function`,input:t[0],output:e._def.output})},e.output=t=>{let n=e.constructor;return new n({type:`function`,input:e._def.input,output:t})},e)),dh=G(`$ZodPromise`,(e,t)=>{zp.init(e,t),e._zod.parse=(e,n)=>Promise.resolve(e.value).then(e=>t.innerType._zod.run({value:e,issues:[]},n))}),fh=G(`$ZodLazy`,(e,t)=>{zp.init(e,t),yf(e._zod,`innerType`,()=>t.getter()),yf(e._zod,`pattern`,()=>e._zod.innerType?._zod?.pattern),yf(e._zod,`propValues`,()=>e._zod.innerType?._zod?.propValues),yf(e._zod,`optin`,()=>e._zod.innerType?._zod?.optin??void 0),yf(e._zod,`optout`,()=>e._zod.innerType?._zod?.optout??void 0),e._zod.parse=(t,n)=>e._zod.innerType._zod.run(t,n)}),ph=G(`$ZodCustom`,(e,t)=>{kp.init(e,t),zp.init(e,t),e._zod.parse=(e,t)=>e,e._zod.check=n=>{let r=n.value,i=t.fn(r);if(i instanceof Promise)return i.then(t=>mh(t,n,r,e));mh(i,n,r,e)}});function mh(e,t,n,r){if(!e){let e={code:`custom`,input:n,inst:r,path:[...r._zod.def.path??[]],continue:!r._zod.def.abort};r._zod.def.params&&(e.params=r._zod.def.params),t.issues.push(Bf(e))}}var hh,gh=class{constructor(){this._map=new WeakMap,this._idmap=new Map}add(e,...t){let n=t[0];return this._map.set(e,n),n&&typeof n==`object`&&`id`in n&&this._idmap.set(n.id,e),this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(e){let t=this._map.get(e);return t&&typeof t==`object`&&`id`in t&&this._idmap.delete(t.id),this._map.delete(e),this}get(e){let t=e._zod.parent;if(t){let n={...this.get(t)??{}};delete n.id;let r={...n,...this._map.get(e)};return Object.keys(r).length?r:void 0}return this._map.get(e)}has(e){return this._map.has(e)}};function _h(){return new gh}(hh=globalThis).__zod_globalRegistry??(hh.__zod_globalRegistry=_h());const vh=globalThis.__zod_globalRegistry;function yh(e,t){return new e({type:`string`,...Nf(t)})}function bh(e,t){return new e({type:`string`,coerce:!0,...Nf(t)})}function xh(e,t){return new e({type:`string`,format:`email`,check:`string_format`,abort:!1,...Nf(t)})}function Sh(e,t){return new e({type:`string`,format:`guid`,check:`string_format`,abort:!1,...Nf(t)})}function Ch(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,...Nf(t)})}function wh(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v4`,...Nf(t)})}function Th(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v6`,...Nf(t)})}function Eh(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v7`,...Nf(t)})}function Dh(e,t){return new e({type:`string`,format:`url`,check:`string_format`,abort:!1,...Nf(t)})}function Oh(e,t){return new e({type:`string`,format:`emoji`,check:`string_format`,abort:!1,...Nf(t)})}function kh(e,t){return new e({type:`string`,format:`nanoid`,check:`string_format`,abort:!1,...Nf(t)})}function Ah(e,t){return new e({type:`string`,format:`cuid`,check:`string_format`,abort:!1,...Nf(t)})}function jh(e,t){return new e({type:`string`,format:`cuid2`,check:`string_format`,abort:!1,...Nf(t)})}function Mh(e,t){return new e({type:`string`,format:`ulid`,check:`string_format`,abort:!1,...Nf(t)})}function Nh(e,t){return new e({type:`string`,format:`xid`,check:`string_format`,abort:!1,...Nf(t)})}function Ph(e,t){return new e({type:`string`,format:`ksuid`,check:`string_format`,abort:!1,...Nf(t)})}function Fh(e,t){return new e({type:`string`,format:`ipv4`,check:`string_format`,abort:!1,...Nf(t)})}function ete(e,t){return new e({type:`string`,format:`ipv6`,check:`string_format`,abort:!1,...Nf(t)})}function tte(e,t){return new e({type:`string`,format:`cidrv4`,check:`string_format`,abort:!1,...Nf(t)})}function nte(e,t){return new e({type:`string`,format:`cidrv6`,check:`string_format`,abort:!1,...Nf(t)})}function rte(e,t){return new e({type:`string`,format:`base64`,check:`string_format`,abort:!1,...Nf(t)})}function ite(e,t){return new e({type:`string`,format:`base64url`,check:`string_format`,abort:!1,...Nf(t)})}function ate(e,t){return new e({type:`string`,format:`e164`,check:`string_format`,abort:!1,...Nf(t)})}function ote(e,t){return new e({type:`string`,format:`jwt`,check:`string_format`,abort:!1,...Nf(t)})}function ste(e,t){return new e({type:`string`,format:`datetime`,check:`string_format`,offset:!1,local:!1,precision:null,...Nf(t)})}function cte(e,t){return new e({type:`string`,format:`date`,check:`string_format`,...Nf(t)})}function lte(e,t){return new e({type:`string`,format:`time`,check:`string_format`,precision:null,...Nf(t)})}function ute(e,t){return new e({type:`string`,format:`duration`,check:`string_format`,...Nf(t)})}function dte(e,t){return new e({type:`number`,checks:[],...Nf(t)})}function fte(e,t){return new e({type:`number`,coerce:!0,checks:[],...Nf(t)})}function pte(e,t){return new e({type:`number`,check:`number_format`,abort:!1,format:`safeint`,...Nf(t)})}function mte(e,t){return new e({type:`boolean`,...Nf(t)})}function hte(e,t){return new e({type:`null`,...Nf(t)})}function gte(e){return new e({type:`any`})}function _te(e){return new e({type:`unknown`})}function vte(e,t){return new e({type:`never`,...Nf(t)})}function Ih(e,t){return new jp({check:`less_than`,...Nf(t),value:e,inclusive:!1})}function Lh(e,t){return new jp({check:`less_than`,...Nf(t),value:e,inclusive:!0})}function Rh(e,t){return new Mp({check:`greater_than`,...Nf(t),value:e,inclusive:!1})}function zh(e,t){return new Mp({check:`greater_than`,...Nf(t),value:e,inclusive:!0})}function Bh(e,t){return new Np({check:`multiple_of`,...Nf(t),value:e})}function Vh(e,t){return new Ip({check:`max_size`,...Nf(t),maximum:e})}function Hh(e,t){return new Oee({check:`min_size`,...Nf(t),minimum:e})}function Uh(e,t){return new kee({check:`size_equals`,...Nf(t),size:e})}function Wh(e,t){return new Aee({check:`max_length`,...Nf(t),maximum:e})}function Gh(e,t){return new jee({check:`min_length`,...Nf(t),minimum:e})}function Kh(e,t){return new Mee({check:`length_equals`,...Nf(t),length:e})}function yte(e,t){return new Nee({check:`string_format`,format:`regex`,...Nf(t),pattern:e})}function bte(e){return new Pee({check:`string_format`,format:`lowercase`,...Nf(e)})}function xte(e){return new Fee({check:`string_format`,format:`uppercase`,...Nf(e)})}function Ste(e,t){return new Iee({check:`string_format`,format:`includes`,...Nf(t),includes:e})}function Cte(e,t){return new Lee({check:`string_format`,format:`starts_with`,...Nf(t),prefix:e})}function wte(e,t){return new Ree({check:`string_format`,format:`ends_with`,...Nf(t),suffix:e})}function Tte(e,t){return new zee({check:`mime_type`,mime:e,...Nf(t)})}function qh(e){return new Bee({check:`overwrite`,tx:e})}function Ete(e){return qh(t=>t.normalize(e))}function Dte(){return qh(e=>e.trim())}function Ote(){return qh(e=>e.toLowerCase())}function kte(){return qh(e=>e.toUpperCase())}function Ate(){return qh(e=>Cf(e))}function jte(e,t,n){return new e({type:`array`,element:t,...Nf(n)})}function Mte(e,t,n){let r=Nf(n);return r.abort??=!0,new e({type:`custom`,check:`custom`,fn:t,...r})}function Nte(e,t,n){return new e({type:`custom`,check:`custom`,fn:t,...Nf(n)})}function Pte(e){let t=Fte(n=>(n.addIssue=e=>{if(typeof e==`string`)n.issues.push(Bf(e,n.value,t._zod.def));else{let r=e;r.fatal&&(r.continue=!1),r.code??=`custom`,r.input??=n.value,r.inst??=t,r.continue??=!t._zod.def.abort,n.issues.push(Bf(r))}},e(n.value,n)));return t}function Fte(e,t){let n=new kp({check:`custom`,...Nf(t)});return n._zod.check=e,n}function Jh(e){let t=e?.target??`draft-2020-12`;return t===`draft-4`&&(t=`draft-04`),t===`draft-7`&&(t=`draft-07`),{processors:e.processors??{},metadataRegistry:e?.metadata??vh,target:t,unrepresentable:e?.unrepresentable??`throw`,override:e?.override??(()=>{}),io:e?.io??`output`,counter:0,seen:new Map,cycles:e?.cycles??`ref`,reused:e?.reused??`inline`,external:e?.external??void 0}}function Yh(e,t,n={path:[],schemaPath:[]}){var r;let i=e._zod.def,a=t.seen.get(e);if(a)return a.count++,n.schemaPath.includes(e)&&(a.cycle=n.path),a.schema;let o={schema:{},count:1,cycle:void 0,path:n.path};t.seen.set(e,o);let s=e._zod.toJSONSchema?.();if(s)o.schema=s;else{let r={...n,schemaPath:[...n.schemaPath,e],path:n.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,o.schema,r);else{let n=o.schema,a=t.processors[i.type];if(!a)throw Error(`[toJSONSchema]: Non-representable type encountered: ${i.type}`);a(e,t,n,r)}let a=e._zod.parent;a&&(o.ref||=a,Yh(a,t,r),t.seen.get(a).isParent=!0)}let c=t.metadataRegistry.get(e);return c&&Object.assign(o.schema,c),t.io===`input`&&Qh(e)&&(delete o.schema.examples,delete o.schema.default),t.io===`input`&&o.schema._prefault&&((r=o.schema).default??(r.default=o.schema._prefault)),delete o.schema._prefault,t.seen.get(e).schema}function Xh(e,t){let n=e.seen.get(t);if(!n)throw Error(`Unprocessed schema. This is a bug in Zod.`);let r=new Map;for(let t of e.seen.entries()){let n=e.metadataRegistry.get(t[0])?.id;if(n){let e=r.get(n);if(e&&e!==t[0])throw Error(`Duplicate schema id "${n}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);r.set(n,t[0])}}let i=t=>{let r=e.target===`draft-2020-12`?`$defs`:`definitions`;if(e.external){let n=e.external.registry.get(t[0])?.id,i=e.external.uri??(e=>e);if(n)return{ref:i(n)};let a=t[1].defId??t[1].schema.id??`schema${e.counter++}`;return t[1].defId=a,{defId:a,ref:`${i(`__shared`)}#/${r}/${a}`}}if(t[1]===n)return{ref:`#`};let i=`#/${r}/`,a=t[1].schema.id??`__schema${e.counter++}`;return{defId:a,ref:i+a}},a=e=>{if(e[1].schema.$ref)return;let t=e[1],{ref:n,defId:r}=i(e);t.def={...t.schema},r&&(t.defId=r);let a=t.schema;for(let e in a)delete a[e];a.$ref=n};if(e.cycles===`throw`)for(let t of e.seen.entries()){let e=t[1];if(e.cycle)throw Error(`Cycle detected: #/${e.cycle?.join(`/`)}/<root>
|
|
49
49
|
|
|
50
|
-
Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let n of e.seen.entries()){let r=n[1];if(t===n[0]){a(n);continue}if(e.external){let r=e.external.registry.get(n[0])?.id;if(t!==n[0]&&r){a(n);continue}}if(e.metadataRegistry.get(n[0])?.id){a(n);continue}if(r.cycle){a(n);continue}if(r.count>1&&e.reused===`ref`){a(n);continue}}}function Zh(e,t){let n=e.seen.get(t);if(!n)throw Error(`Unprocessed schema. This is a bug in Zod.`);let r=t=>{let n=e.seen.get(t);if(n.ref===null)return;let i=n.def??n.schema,a={...i},o=n.ref;if(n.ref=null,o){r(o);let n=e.seen.get(o),s=n.schema;if(s.$ref&&(e.target===`draft-07`||e.target===`draft-04`||e.target===`openapi-3.0`)?(i.allOf=i.allOf??[],i.allOf.push(s)):Object.assign(i,s),Object.assign(i,a),t._zod.parent===o)for(let e in i)e===`$ref`||e===`allOf`||e in a||delete i[e];if(s.$ref&&n.def)for(let e in i)e===`$ref`||e===`allOf`||e in n.def&&JSON.stringify(i[e])===JSON.stringify(n.def[e])&&delete i[e]}let s=t._zod.parent;if(s&&s!==o){r(s);let t=e.seen.get(s);if(t?.schema.$ref&&(i.$ref=t.schema.$ref,t.def))for(let e in i)e===`$ref`||e===`allOf`||e in t.def&&JSON.stringify(i[e])===JSON.stringify(t.def[e])&&delete i[e]}e.override({zodSchema:t,jsonSchema:i,path:n.path??[]})};for(let t of[...e.seen.entries()].reverse())r(t[0]);let i={};if(e.target===`draft-2020-12`?i.$schema=`https://json-schema.org/draft/2020-12/schema`:e.target===`draft-07`?i.$schema=`http://json-schema.org/draft-07/schema#`:e.target===`draft-04`?i.$schema=`http://json-schema.org/draft-04/schema#`:e.target,e.external?.uri){let n=e.external.registry.get(t)?.id;if(!n)throw Error("Schema is missing an `id` property");i.$id=e.external.uri(n)}Object.assign(i,n.def??n.schema);let a=e.external?.defs??{};for(let t of e.seen.entries()){let e=t[1];e.def&&e.defId&&(a[e.defId]=e.def)}e.external||Object.keys(a).length>0&&(e.target===`draft-2020-12`?i.$defs=a:i.definitions=a);try{let n=JSON.parse(JSON.stringify(i));return Object.defineProperty(n,`~standard`,{value:{...t[`~standard`],jsonSchema:{input:$h(t,`input`,e.processors),output:$h(t,`output`,e.processors)}},enumerable:!1,writable:!1}),n}catch{throw Error(`Error converting schema to JSON.`)}}function Qh(e,t){let n=t??{seen:new Set};if(n.seen.has(e))return!1;n.seen.add(e);let r=e._zod.def;if(r.type===`transform`)return!0;if(r.type===`array`)return Qh(r.element,n);if(r.type===`set`)return Qh(r.valueType,n);if(r.type===`lazy`)return Qh(r.getter(),n);if(r.type===`promise`||r.type===`optional`||r.type===`nonoptional`||r.type===`nullable`||r.type===`readonly`||r.type===`default`||r.type===`prefault`)return Qh(r.innerType,n);if(r.type===`intersection`)return Qh(r.left,n)||Qh(r.right,n);if(r.type===`record`||r.type===`map`)return Qh(r.keyType,n)||Qh(r.valueType,n);if(r.type===`pipe`)return Qh(r.in,n)||Qh(r.out,n);if(r.type===`object`){for(let e in r.shape)if(Qh(r.shape[e],n))return!0;return!1}if(r.type===`union`){for(let e of r.options)if(Qh(e,n))return!0;return!1}if(r.type===`tuple`){for(let e of r.items)if(Qh(e,n))return!0;return!!(r.rest&&Qh(r.rest,n))}return!1}const Ite=(e,t={})=>n=>{let r=Jh({...n,processors:t});return Yh(e,r),Xh(r,e),Zh(r,e)},$h=(e,t,n={})=>r=>{let{libraryOptions:i,target:a}=r??{},o=Jh({...i??{},target:a,io:t,processors:n});return Yh(e,o),Xh(o,e),Zh(o,e)},Lte={guid:`uuid`,url:`uri`,datetime:`date-time`,json_string:`json-string`,regex:``},Rte=(e,t,n,r)=>{let i=n;i.type=`string`;let{minimum:a,maximum:o,format:s,patterns:c,contentEncoding:l}=e._zod.bag;if(typeof a==`number`&&(i.minLength=a),typeof o==`number`&&(i.maxLength=o),s&&(i.format=Lte[s]??s,i.format===``&&delete i.format,s===`time`&&delete i.format),l&&(i.contentEncoding=l),c&&c.size>0){let e=[...c];e.length===1?i.pattern=e[0].source:e.length>1&&(i.allOf=[...e.map(e=>({...t.target===`draft-07`||t.target===`draft-04`||t.target===`openapi-3.0`?{type:`string`}:{},pattern:e.source}))])}},zte=(e,t,n,r)=>{let i=n,{minimum:a,maximum:o,format:s,multipleOf:c,exclusiveMaximum:l,exclusiveMinimum:u}=e._zod.bag;typeof s==`string`&&s.includes(`int`)?i.type=`integer`:i.type=`number`,typeof u==`number`&&(t.target===`draft-04`||t.target===`openapi-3.0`?(i.minimum=u,i.exclusiveMinimum=!0):i.exclusiveMinimum=u),typeof a==`number`&&(i.minimum=a,typeof u==`number`&&t.target!==`draft-04`&&(u>=a?delete i.minimum:delete i.exclusiveMinimum)),typeof l==`number`&&(t.target===`draft-04`||t.target===`openapi-3.0`?(i.maximum=l,i.exclusiveMaximum=!0):i.exclusiveMaximum=l),typeof o==`number`&&(i.maximum=o,typeof l==`number`&&t.target!==`draft-04`&&(l<=o?delete i.maximum:delete i.exclusiveMaximum)),typeof c==`number`&&(i.multipleOf=c)},Bte=(e,t,n,r)=>{n.type=`boolean`},Vte=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`BigInt cannot be represented in JSON Schema`)},Hte=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Symbols cannot be represented in JSON Schema`)},eg=(e,t,n,r)=>{t.target===`openapi-3.0`?(n.type=`string`,n.nullable=!0,n.enum=[null]):n.type=`null`},tg=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Undefined cannot be represented in JSON Schema`)},ng=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Void cannot be represented in JSON Schema`)},rg=(e,t,n,r)=>{n.not={}},ig=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Date cannot be represented in JSON Schema`)},ag=(e,t,n,r)=>{let i=e._zod.def,a=ff(i.entries);a.every(e=>typeof e==`number`)&&(n.type=`number`),a.every(e=>typeof e==`string`)&&(n.type=`string`),n.enum=a},og=(e,t,n,r)=>{let i=e._zod.def,a=[];for(let e of i.values)if(e===void 0){if(t.unrepresentable===`throw`)throw Error("Literal `undefined` cannot be represented in JSON Schema")}else if(typeof e==`bigint`){if(t.unrepresentable===`throw`)throw Error(`BigInt literals cannot be represented in JSON Schema`);a.push(Number(e))}else a.push(e);if(a.length!==0)if(a.length===1){let e=a[0];n.type=e===null?`null`:typeof e,t.target===`draft-04`||t.target===`openapi-3.0`?n.enum=[e]:n.const=e}else a.every(e=>typeof e==`number`)&&(n.type=`number`),a.every(e=>typeof e==`string`)&&(n.type=`string`),a.every(e=>typeof e==`boolean`)&&(n.type=`boolean`),a.every(e=>e===null)&&(n.type=`null`),n.enum=a},sg=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`NaN cannot be represented in JSON Schema`)},cg=(e,t,n,r)=>{let i=n,a=e._zod.pattern;if(!a)throw Error(`Pattern not found in template literal`);i.type=`string`,i.pattern=a.source},lg=(e,t,n,r)=>{let i=n,a={type:`string`,format:`binary`,contentEncoding:`binary`},{minimum:o,maximum:s,mime:c}=e._zod.bag;o!==void 0&&(a.minLength=o),s!==void 0&&(a.maxLength=s),c?c.length===1?(a.contentMediaType=c[0],Object.assign(i,a)):(Object.assign(i,a),i.anyOf=c.map(e=>({contentMediaType:e}))):Object.assign(i,a)},ug=(e,t,n,r)=>{n.type=`boolean`},dg=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Custom types cannot be represented in JSON Schema`)},fg=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Function types cannot be represented in JSON Schema`)},pg=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Transforms cannot be represented in JSON Schema`)},mg=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Map cannot be represented in JSON Schema`)},hg=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Set cannot be represented in JSON Schema`)},gg=(e,t,n,r)=>{let i=n,a=e._zod.def,{minimum:o,maximum:s}=e._zod.bag;typeof o==`number`&&(i.minItems=o),typeof s==`number`&&(i.maxItems=s),i.type=`array`,i.items=Yh(a.element,t,{...r,path:[...r.path,`items`]})},_g=(e,t,n,r)=>{let i=n,a=e._zod.def;i.type=`object`,i.properties={};let o=a.shape;for(let e in o)i.properties[e]=Yh(o[e],t,{...r,path:[...r.path,`properties`,e]});let s=new Set(Object.keys(o)),c=new Set([...s].filter(e=>{let n=a.shape[e]._zod;return t.io===`input`?n.optin===void 0:n.optout===void 0}));c.size>0&&(i.required=Array.from(c)),a.catchall?._zod.def.type===`never`?i.additionalProperties=!1:a.catchall?a.catchall&&(i.additionalProperties=Yh(a.catchall,t,{...r,path:[...r.path,`additionalProperties`]})):t.io===`output`&&(i.additionalProperties=!1)},vg=(e,t,n,r)=>{let i=e._zod.def,a=i.inclusive===!1,o=i.options.map((e,n)=>Yh(e,t,{...r,path:[...r.path,a?`oneOf`:`anyOf`,n]}));a?n.oneOf=o:n.anyOf=o},yg=(e,t,n,r)=>{let i=e._zod.def,a=Yh(i.left,t,{...r,path:[...r.path,`allOf`,0]}),o=Yh(i.right,t,{...r,path:[...r.path,`allOf`,1]}),s=e=>`allOf`in e&&Object.keys(e).length===1;n.allOf=[...s(a)?a.allOf:[a],...s(o)?o.allOf:[o]]},bg=(e,t,n,r)=>{let i=n,a=e._zod.def;i.type=`array`;let o=t.target===`draft-2020-12`?`prefixItems`:`items`,s=t.target===`draft-2020-12`||t.target===`openapi-3.0`?`items`:`additionalItems`,c=a.items.map((e,n)=>Yh(e,t,{...r,path:[...r.path,o,n]})),l=a.rest?Yh(a.rest,t,{...r,path:[...r.path,s,...t.target===`openapi-3.0`?[a.items.length]:[]]}):null;t.target===`draft-2020-12`?(i.prefixItems=c,l&&(i.items=l)):t.target===`openapi-3.0`?(i.items={anyOf:c},l&&i.items.anyOf.push(l),i.minItems=c.length,l||(i.maxItems=c.length)):(i.items=c,l&&(i.additionalItems=l));let{minimum:u,maximum:d}=e._zod.bag;typeof u==`number`&&(i.minItems=u),typeof d==`number`&&(i.maxItems=d)},xg=(e,t,n,r)=>{let i=n,a=e._zod.def;i.type=`object`;let o=a.keyType,s=o._zod.bag?.patterns;if(a.mode===`loose`&&s&&s.size>0){let e=Yh(a.valueType,t,{...r,path:[...r.path,`patternProperties`,`*`]});i.patternProperties={};for(let t of s)i.patternProperties[t.source]=e}else (t.target===`draft-07`||t.target===`draft-2020-12`)&&(i.propertyNames=Yh(a.keyType,t,{...r,path:[...r.path,`propertyNames`]})),i.additionalProperties=Yh(a.valueType,t,{...r,path:[...r.path,`additionalProperties`]});let c=o._zod.values;if(c){let e=[...c].filter(e=>typeof e==`string`||typeof e==`number`);e.length>0&&(i.required=e)}},Sg=(e,t,n,r)=>{let i=e._zod.def,a=Yh(i.innerType,t,r),o=t.seen.get(e);t.target===`openapi-3.0`?(o.ref=i.innerType,n.nullable=!0):n.anyOf=[a,{type:`null`}]},Cg=(e,t,n,r)=>{let i=e._zod.def;Yh(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},wg=(e,t,n,r)=>{let i=e._zod.def;Yh(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,n.default=JSON.parse(JSON.stringify(i.defaultValue))},Tg=(e,t,n,r)=>{let i=e._zod.def;Yh(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,t.io===`input`&&(n._prefault=JSON.parse(JSON.stringify(i.defaultValue)))},Eg=(e,t,n,r)=>{let i=e._zod.def;Yh(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType;let o;try{o=i.catchValue(void 0)}catch{throw Error(`Dynamic catch values are not supported in JSON Schema`)}n.default=o},Dg=(e,t,n,r)=>{let i=e._zod.def,a=t.io===`input`?i.in._zod.def.type===`transform`?i.out:i.in:i.out;Yh(a,t,r);let o=t.seen.get(e);o.ref=a},Og=(e,t,n,r)=>{let i=e._zod.def;Yh(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,n.readOnly=!0},kg=(e,t,n,r)=>{let i=e._zod.def;Yh(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},Ag=(e,t,n,r)=>{let i=e._zod.def;Yh(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},jg=(e,t,n,r)=>{let i=e._zod.innerType;Yh(i,t,r);let a=t.seen.get(e);a.ref=i},Mg=G(`ZodISODateTime`,(e,t)=>{Hp.init(e,t),r_.init(e,t)});function Ng(e){return ste(Mg,e)}const Pg=G(`ZodISODate`,(e,t)=>{Up.init(e,t),r_.init(e,t)});function Fg(e){return cte(Pg,e)}const Ig=G(`ZodISOTime`,(e,t)=>{Wp.init(e,t),r_.init(e,t)});function Lg(e){return lte(Ig,e)}const Rg=G(`ZodISODuration`,(e,t)=>{Gp.init(e,t),r_.init(e,t)});function zg(e){return ute(Rg,e)}const Bg=(e,t)=>{Hf.init(e,t),e.name=`ZodError`,Object.defineProperties(e,{format:{value:t=>hee(e,t)},flatten:{value:t=>mee(e,t)},addIssue:{value:t=>{e.issues.push(t),e.message=JSON.stringify(e.issues,pf,2)}},addIssues:{value:t=>{e.issues.push(...t),e.message=JSON.stringify(e.issues,pf,2)}},isEmpty:{get(){return e.issues.length===0}}})};G(`ZodError`,Bg);const Vg=G(`ZodError`,Bg,{Parent:Error}),Hg=Wf(Vg),Ug=Kf(Vg),Wg=Jf(Vg),Gg=Xf(Vg),Kg=_ee(Vg),qg=vee(Vg),Jg=yee(Vg),Yg=bee(Vg),Xg=xee(Vg),Zg=See(Vg),Qg=Cee(Vg),$g=Zf(Vg),e_=G(`ZodType`,(e,t)=>(zp.init(e,t),Object.assign(e[`~standard`],{jsonSchema:{input:$h(e,`input`),output:$h(e,`output`)}}),e.toJSONSchema=Ite(e,{}),e.def=t,e.type=t.type,Object.defineProperty(e,`_def`,{value:t}),e.check=(...n)=>e.clone(xf(t,{checks:[...t.checks??[],...n.map(e=>typeof e==`function`?{_zod:{check:e,def:{check:`custom`},onattach:[]}}:e)]}),{parent:!0}),e.with=e.check,e.clone=(t,n)=>Mf(e,t,n),e.brand=()=>e,e.register=((t,n)=>(t.add(e,n),e)),e.parse=(t,n)=>Hg(e,t,n,{callee:e.parse}),e.safeParse=(t,n)=>Wg(e,t,n),e.parseAsync=async(t,n)=>Ug(e,t,n,{callee:e.parseAsync}),e.safeParseAsync=async(t,n)=>Gg(e,t,n),e.spa=e.safeParseAsync,e.encode=(t,n)=>Kg(e,t,n),e.decode=(t,n)=>qg(e,t,n),e.encodeAsync=async(t,n)=>Jg(e,t,n),e.decodeAsync=async(t,n)=>Yg(e,t,n),e.safeEncode=(t,n)=>Xg(e,t,n),e.safeDecode=(t,n)=>Zg(e,t,n),e.safeEncodeAsync=async(t,n)=>Qg(e,t,n),e.safeDecodeAsync=async(t,n)=>$g(e,t,n),e.refine=(t,n)=>e.check(Tv(t,n)),e.superRefine=t=>e.check(Ev(t)),e.overwrite=t=>e.check(qh(t)),e.optional=()=>ov(e),e.exactOptional=()=>cv(e),e.nullable=()=>uv(e),e.nullish=()=>ov(uv(e)),e.nonoptional=t=>gv(e,t),e.array=()=>B_(e),e.or=t=>W_([e,t]),e.and=t=>J_(e,t),e.transform=t=>bv(e,iv(t)),e.default=t=>fv(e,t),e.prefault=t=>mv(e,t),e.catch=t=>vv(e,t),e.pipe=t=>bv(e,t),e.readonly=()=>Sv(e),e.describe=t=>{let n=e.clone();return vh.add(n,{description:t}),n},Object.defineProperty(e,`description`,{get(){return vh.get(e)?.description},configurable:!0}),e.meta=(...t)=>{if(t.length===0)return vh.get(e);let n=e.clone();return vh.add(n,t[0]),n},e.isOptional=()=>e.safeParse(void 0).success,e.isNullable=()=>e.safeParse(null).success,e.apply=t=>t(e),e)),t_=G(`_ZodString`,(e,t)=>{Bp.init(e,t),e_.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Rte(e,t,n,r);let n=e._zod.bag;e.format=n.format??null,e.minLength=n.minimum??null,e.maxLength=n.maximum??null,e.regex=(...t)=>e.check(yte(...t)),e.includes=(...t)=>e.check(Ste(...t)),e.startsWith=(...t)=>e.check(Cte(...t)),e.endsWith=(...t)=>e.check(wte(...t)),e.min=(...t)=>e.check(Gh(...t)),e.max=(...t)=>e.check(Wh(...t)),e.length=(...t)=>e.check(Kh(...t)),e.nonempty=(...t)=>e.check(Gh(1,...t)),e.lowercase=t=>e.check(bte(t)),e.uppercase=t=>e.check(xte(t)),e.trim=()=>e.check(Dte()),e.normalize=(...t)=>e.check(Ete(...t)),e.toLowerCase=()=>e.check(Ote()),e.toUpperCase=()=>e.check(kte()),e.slugify=()=>e.check(Ate())}),n_=G(`ZodString`,(e,t)=>{Bp.init(e,t),t_.init(e,t),e.email=t=>e.check(xh(i_,t)),e.url=t=>e.check(Dh(s_,t)),e.jwt=t=>e.check(ote(C_,t)),e.emoji=t=>e.check(Oh(l_,t)),e.guid=t=>e.check(Sh(a_,t)),e.uuid=t=>e.check(Ch(o_,t)),e.uuidv4=t=>e.check(wh(o_,t)),e.uuidv6=t=>e.check(Th(o_,t)),e.uuidv7=t=>e.check(Eh(o_,t)),e.nanoid=t=>e.check(kh(u_,t)),e.guid=t=>e.check(Sh(a_,t)),e.cuid=t=>e.check(Ah(d_,t)),e.cuid2=t=>e.check(jh(f_,t)),e.ulid=t=>e.check(Mh(p_,t)),e.base64=t=>e.check(rte(b_,t)),e.base64url=t=>e.check(ite(x_,t)),e.xid=t=>e.check(Nh(m_,t)),e.ksuid=t=>e.check(Ph(h_,t)),e.ipv4=t=>e.check(Fh(g_,t)),e.ipv6=t=>e.check(ete(__,t)),e.cidrv4=t=>e.check(tte(v_,t)),e.cidrv6=t=>e.check(nte(y_,t)),e.e164=t=>e.check(ate(S_,t)),e.datetime=t=>e.check(Ng(t)),e.date=t=>e.check(Fg(t)),e.time=t=>e.check(Lg(t)),e.duration=t=>e.check(zg(t))});function K(e){return yh(n_,e)}const r_=G(`ZodStringFormat`,(e,t)=>{Vp.init(e,t),t_.init(e,t)}),i_=G(`ZodEmail`,(e,t)=>{Gee.init(e,t),r_.init(e,t)}),a_=G(`ZodGUID`,(e,t)=>{Uee.init(e,t),r_.init(e,t)}),o_=G(`ZodUUID`,(e,t)=>{Wee.init(e,t),r_.init(e,t)}),s_=G(`ZodURL`,(e,t)=>{Kee.init(e,t),r_.init(e,t)});function c_(e){return Dh(s_,e)}const l_=G(`ZodEmoji`,(e,t)=>{qee.init(e,t),r_.init(e,t)}),u_=G(`ZodNanoID`,(e,t)=>{Jee.init(e,t),r_.init(e,t)}),d_=G(`ZodCUID`,(e,t)=>{Yee.init(e,t),r_.init(e,t)}),f_=G(`ZodCUID2`,(e,t)=>{Xee.init(e,t),r_.init(e,t)}),p_=G(`ZodULID`,(e,t)=>{Zee.init(e,t),r_.init(e,t)}),m_=G(`ZodXID`,(e,t)=>{Qee.init(e,t),r_.init(e,t)}),h_=G(`ZodKSUID`,(e,t)=>{$ee.init(e,t),r_.init(e,t)}),g_=G(`ZodIPv4`,(e,t)=>{Kp.init(e,t),r_.init(e,t)});G(`ZodMAC`,(e,t)=>{Jp.init(e,t),r_.init(e,t)});const __=G(`ZodIPv6`,(e,t)=>{qp.init(e,t),r_.init(e,t)}),v_=G(`ZodCIDRv4`,(e,t)=>{Yp.init(e,t),r_.init(e,t)}),y_=G(`ZodCIDRv6`,(e,t)=>{Xp.init(e,t),r_.init(e,t)}),b_=G(`ZodBase64`,(e,t)=>{Qp.init(e,t),r_.init(e,t)}),x_=G(`ZodBase64URL`,(e,t)=>{em.init(e,t),r_.init(e,t)}),S_=G(`ZodE164`,(e,t)=>{tm.init(e,t),r_.init(e,t)}),C_=G(`ZodJWT`,(e,t)=>{rm.init(e,t),r_.init(e,t)});G(`ZodCustomStringFormat`,(e,t)=>{im.init(e,t),r_.init(e,t)});const w_=G(`ZodNumber`,(e,t)=>{am.init(e,t),e_.init(e,t),e._zod.processJSONSchema=(t,n,r)=>zte(e,t,n,r),e.gt=(t,n)=>e.check(Rh(t,n)),e.gte=(t,n)=>e.check(zh(t,n)),e.min=(t,n)=>e.check(zh(t,n)),e.lt=(t,n)=>e.check(Ih(t,n)),e.lte=(t,n)=>e.check(Lh(t,n)),e.max=(t,n)=>e.check(Lh(t,n)),e.int=t=>e.check(D_(t)),e.safe=t=>e.check(D_(t)),e.positive=t=>e.check(Rh(0,t)),e.nonnegative=t=>e.check(zh(0,t)),e.negative=t=>e.check(Ih(0,t)),e.nonpositive=t=>e.check(Lh(0,t)),e.multipleOf=(t,n)=>e.check(Bh(t,n)),e.step=(t,n)=>e.check(Bh(t,n)),e.finite=()=>e;let n=e._zod.bag;e.minValue=Math.max(n.minimum??-1/0,n.exclusiveMinimum??-1/0)??null,e.maxValue=Math.min(n.maximum??1/0,n.exclusiveMaximum??1/0)??null,e.isInt=(n.format??``).includes(`int`)||Number.isSafeInteger(n.multipleOf??.5),e.isFinite=!0,e.format=n.format??null});function T_(e){return dte(w_,e)}const E_=G(`ZodNumberFormat`,(e,t)=>{om.init(e,t),w_.init(e,t)});function D_(e){return pte(E_,e)}const O_=G(`ZodBoolean`,(e,t)=>{sm.init(e,t),e_.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Bte(e,t,n,r)});function k_(e){return mte(O_,e)}const A_=G(`ZodBigInt`,(e,t)=>{cm.init(e,t),e_.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Vte(e,t,n,r),e.gte=(t,n)=>e.check(zh(t,n)),e.min=(t,n)=>e.check(zh(t,n)),e.gt=(t,n)=>e.check(Rh(t,n)),e.gte=(t,n)=>e.check(zh(t,n)),e.min=(t,n)=>e.check(zh(t,n)),e.lt=(t,n)=>e.check(Ih(t,n)),e.lte=(t,n)=>e.check(Lh(t,n)),e.max=(t,n)=>e.check(Lh(t,n)),e.positive=t=>e.check(Rh(BigInt(0),t)),e.negative=t=>e.check(Ih(BigInt(0),t)),e.nonpositive=t=>e.check(Lh(BigInt(0),t)),e.nonnegative=t=>e.check(zh(BigInt(0),t)),e.multipleOf=(t,n)=>e.check(Bh(t,n));let n=e._zod.bag;e.minValue=n.minimum??null,e.maxValue=n.maximum??null,e.format=n.format??null});G(`ZodBigIntFormat`,(e,t)=>{lm.init(e,t),A_.init(e,t)}),G(`ZodSymbol`,(e,t)=>{um.init(e,t),e_.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Hte(e,t,n,r)}),G(`ZodUndefined`,(e,t)=>{dm.init(e,t),e_.init(e,t),e._zod.processJSONSchema=(t,n,r)=>tg(e,t,n,r)});const j_=G(`ZodNull`,(e,t)=>{fm.init(e,t),e_.init(e,t),e._zod.processJSONSchema=(t,n,r)=>eg(e,t,n,r)});function M_(e){return hte(j_,e)}const N_=G(`ZodAny`,(e,t)=>{pm.init(e,t),e_.init(e,t),e._zod.processJSONSchema=(e,t,n)=>void 0});function P_(){return gte(N_)}const F_=G(`ZodUnknown`,(e,t)=>{mm.init(e,t),e_.init(e,t),e._zod.processJSONSchema=(e,t,n)=>void 0});function I_(){return _te(F_)}const L_=G(`ZodNever`,(e,t)=>{hm.init(e,t),e_.init(e,t),e._zod.processJSONSchema=(t,n,r)=>rg(e,t,n,r)});function R_(e){return vte(L_,e)}G(`ZodVoid`,(e,t)=>{gm.init(e,t),e_.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ng(e,t,n,r)}),G(`ZodDate`,(e,t)=>{_m.init(e,t),e_.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ig(e,t,n,r),e.min=(t,n)=>e.check(zh(t,n)),e.max=(t,n)=>e.check(Lh(t,n));let n=e._zod.bag;e.minDate=n.minimum?new Date(n.minimum):null,e.maxDate=n.maximum?new Date(n.maximum):null});const z_=G(`ZodArray`,(e,t)=>{ym.init(e,t),e_.init(e,t),e._zod.processJSONSchema=(t,n,r)=>gg(e,t,n,r),e.element=t.element,e.min=(t,n)=>e.check(Gh(t,n)),e.nonempty=t=>e.check(Gh(1,t)),e.max=(t,n)=>e.check(Wh(t,n)),e.length=(t,n)=>e.check(Kh(t,n)),e.unwrap=()=>e.element});function B_(e,t){return jte(z_,e,t)}const V_=G(`ZodObject`,(e,t)=>{wm.init(e,t),e_.init(e,t),e._zod.processJSONSchema=(t,n,r)=>_g(e,t,n,r),yf(e,`shape`,()=>t.shape),e.keyof=()=>ev(Object.keys(e._zod.def.shape)),e.catchall=t=>e.clone({...e._zod.def,catchall:t}),e.passthrough=()=>e.clone({...e._zod.def,catchall:I_()}),e.loose=()=>e.clone({...e._zod.def,catchall:I_()}),e.strict=()=>e.clone({...e._zod.def,catchall:R_()}),e.strip=()=>e.clone({...e._zod.def,catchall:void 0}),e.extend=t=>lee(e,t),e.safeExtend=t=>uee(e,t),e.merge=t=>dee(e,t),e.pick=t=>see(e,t),e.omit=t=>cee(e,t),e.partial=(...t)=>fee(av,e,t[0]),e.required=(...t)=>pee(hv,e,t[0])});function q(e,t){return new V_({type:`object`,shape:e??{},...Nf(t)})}function H_(e,t){return new V_({type:`object`,shape:e,catchall:I_(),...Nf(t)})}const U_=G(`ZodUnion`,(e,t)=>{Em.init(e,t),e_.init(e,t),e._zod.processJSONSchema=(t,n,r)=>vg(e,t,n,r),e.options=t.options});function W_(e,t){return new U_({type:`union`,options:e,...Nf(t)})}G(`ZodXor`,(e,t)=>{U_.init(e,t),Om.init(e,t),e._zod.processJSONSchema=(t,n,r)=>vg(e,t,n,r),e.options=t.options});const G_=G(`ZodDiscriminatedUnion`,(e,t)=>{U_.init(e,t),km.init(e,t)});function K_(e,t,n){return new G_({type:`union`,options:t,discriminator:e,...Nf(n)})}const q_=G(`ZodIntersection`,(e,t)=>{Am.init(e,t),e_.init(e,t),e._zod.processJSONSchema=(t,n,r)=>yg(e,t,n,r)});function J_(e,t){return new q_({type:`intersection`,left:e,right:t})}const Y_=G(`ZodTuple`,(e,t)=>{Nm.init(e,t),e_.init(e,t),e._zod.processJSONSchema=(t,n,r)=>bg(e,t,n,r),e.rest=t=>e.clone({...e._zod.def,rest:t})});function X_(e,t,n){let r=t instanceof zp;return new Y_({type:`tuple`,items:e,rest:r?t:null,...Nf(r?n:t)})}const Z_=G(`ZodRecord`,(e,t)=>{Fm.init(e,t),e_.init(e,t),e._zod.processJSONSchema=(t,n,r)=>xg(e,t,n,r),e.keyType=t.keyType,e.valueType=t.valueType});function Q_(e,t,n){return new Z_({type:`record`,keyType:e,valueType:t,...Nf(n)})}G(`ZodMap`,(e,t)=>{Im.init(e,t),e_.init(e,t),e._zod.processJSONSchema=(t,n,r)=>mg(e,t,n,r),e.keyType=t.keyType,e.valueType=t.valueType,e.min=(...t)=>e.check(Hh(...t)),e.nonempty=t=>e.check(Hh(1,t)),e.max=(...t)=>e.check(Vh(...t)),e.size=(...t)=>e.check(Uh(...t))}),G(`ZodSet`,(e,t)=>{Rm.init(e,t),e_.init(e,t),e._zod.processJSONSchema=(t,n,r)=>hg(e,t,n,r),e.min=(...t)=>e.check(Hh(...t)),e.nonempty=t=>e.check(Hh(1,t)),e.max=(...t)=>e.check(Vh(...t)),e.size=(...t)=>e.check(Uh(...t))});const $_=G(`ZodEnum`,(e,t)=>{Bm.init(e,t),e_.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ag(e,t,n,r),e.enum=t.entries,e.options=Object.values(t.entries);let n=new Set(Object.keys(t.entries));e.extract=(e,r)=>{let i={};for(let r of e)if(n.has(r))i[r]=t.entries[r];else throw Error(`Key ${r} not found in enum`);return new $_({...t,checks:[],...Nf(r),entries:i})},e.exclude=(e,r)=>{let i={...t.entries};for(let t of e)if(n.has(t))delete i[t];else throw Error(`Key ${t} not found in enum`);return new $_({...t,checks:[],...Nf(r),entries:i})}});function ev(e,t){return new $_({type:`enum`,entries:Array.isArray(e)?Object.fromEntries(e.map(e=>[e,e])):e,...Nf(t)})}const tv=G(`ZodLiteral`,(e,t)=>{Vm.init(e,t),e_.init(e,t),e._zod.processJSONSchema=(t,n,r)=>og(e,t,n,r),e.values=new Set(t.values),Object.defineProperty(e,`value`,{get(){if(t.values.length>1)throw Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})});function nv(e,t){return new tv({type:`literal`,values:Array.isArray(e)?e:[e],...Nf(t)})}G(`ZodFile`,(e,t)=>{Hm.init(e,t),e_.init(e,t),e._zod.processJSONSchema=(t,n,r)=>lg(e,t,n,r),e.min=(t,n)=>e.check(Hh(t,n)),e.max=(t,n)=>e.check(Vh(t,n)),e.mime=(t,n)=>e.check(Tte(Array.isArray(t)?t:[t],n))});const rv=G(`ZodTransform`,(e,t)=>{Um.init(e,t),e_.init(e,t),e._zod.processJSONSchema=(t,n,r)=>pg(e,t,n,r),e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new lf(e.constructor.name);n.addIssue=r=>{if(typeof r==`string`)n.issues.push(Bf(r,n.value,t));else{let t=r;t.fatal&&(t.continue=!1),t.code??=`custom`,t.input??=n.value,t.inst??=e,n.issues.push(Bf(t))}};let i=t.transform(n.value,n);return i instanceof Promise?i.then(e=>(n.value=e,n)):(n.value=i,n)}});function iv(e){return new rv({type:`transform`,transform:e})}const av=G(`ZodOptional`,(e,t)=>{Gm.init(e,t),e_.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ag(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function ov(e){return new av({type:`optional`,innerType:e})}const sv=G(`ZodExactOptional`,(e,t)=>{Km.init(e,t),e_.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ag(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function cv(e){return new sv({type:`optional`,innerType:e})}const lv=G(`ZodNullable`,(e,t)=>{qm.init(e,t),e_.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Sg(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function uv(e){return new lv({type:`nullable`,innerType:e})}const dv=G(`ZodDefault`,(e,t)=>{Jm.init(e,t),e_.init(e,t),e._zod.processJSONSchema=(t,n,r)=>wg(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function fv(e,t){return new dv({type:`default`,innerType:e,get defaultValue(){return typeof t==`function`?t():Of(t)}})}const pv=G(`ZodPrefault`,(e,t)=>{Xm.init(e,t),e_.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Tg(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function mv(e,t){return new pv({type:`prefault`,innerType:e,get defaultValue(){return typeof t==`function`?t():Of(t)}})}const hv=G(`ZodNonOptional`,(e,t)=>{Zm.init(e,t),e_.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Cg(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function gv(e,t){return new hv({type:`nonoptional`,innerType:e,...Nf(t)})}G(`ZodSuccess`,(e,t)=>{$m.init(e,t),e_.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ug(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});const _v=G(`ZodCatch`,(e,t)=>{eh.init(e,t),e_.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Eg(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function vv(e,t){return new _v({type:`catch`,innerType:e,catchValue:typeof t==`function`?t:()=>t})}G(`ZodNaN`,(e,t)=>{th.init(e,t),e_.init(e,t),e._zod.processJSONSchema=(t,n,r)=>sg(e,t,n,r)});const yv=G(`ZodPipe`,(e,t)=>{nh.init(e,t),e_.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Dg(e,t,n,r),e.in=t.in,e.out=t.out});function bv(e,t){return new yv({type:`pipe`,in:e,out:t})}G(`ZodCodec`,(e,t)=>{yv.init(e,t),ih.init(e,t)});const xv=G(`ZodReadonly`,(e,t)=>{sh.init(e,t),e_.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Og(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Sv(e){return new xv({type:`readonly`,innerType:e})}G(`ZodTemplateLiteral`,(e,t)=>{lh.init(e,t),e_.init(e,t),e._zod.processJSONSchema=(t,n,r)=>cg(e,t,n,r)}),G(`ZodLazy`,(e,t)=>{fh.init(e,t),e_.init(e,t),e._zod.processJSONSchema=(t,n,r)=>jg(e,t,n,r),e.unwrap=()=>e._zod.def.getter()}),G(`ZodPromise`,(e,t)=>{dh.init(e,t),e_.init(e,t),e._zod.processJSONSchema=(t,n,r)=>kg(e,t,n,r),e.unwrap=()=>e._zod.def.innerType}),G(`ZodFunction`,(e,t)=>{uh.init(e,t),e_.init(e,t),e._zod.processJSONSchema=(t,n,r)=>fg(e,t,n,r)});const Cv=G(`ZodCustom`,(e,t)=>{ph.init(e,t),e_.init(e,t),e._zod.processJSONSchema=(t,n,r)=>dg(e,t,n,r)});function wv(e,t){return Mte(Cv,e??(()=>!0),t)}function Tv(e,t={}){return Nte(Cv,e,t)}function Ev(e){return Pte(e)}function Dv(e,t){return bv(iv(e),t)}const Ov={invalid_type:`invalid_type`,too_big:`too_big`,too_small:`too_small`,invalid_format:`invalid_format`,not_multiple_of:`not_multiple_of`,unrecognized_keys:`unrecognized_keys`,invalid_union:`invalid_union`,invalid_key:`invalid_key`,invalid_element:`invalid_element`,invalid_value:`invalid_value`,custom:`custom`};var kv;(function(e){})(kv||={});function Av(e){return bh(n_,e)}function jv(e){return fte(w_,e)}const Mv={USER_MESSAGE:`user_message`,REJECTED:`rejected`,INTERRUPTED:`interrupted`},Nv={REJECTED:`rejected`};function Pv(e){if(e===`Tool was rejected by user`)return{rejected:!0};try{let t=JSON.parse(e);if(t.reason===Mv.USER_MESSAGE)return{rejected:!0,userNote:t.message};if(t.reason===Mv.REJECTED||t.reason===Mv.INTERRUPTED)return{rejected:!0};if(t.status===Nv.REJECTED)return{rejected:!0,userNote:t.userNote}}catch{}return{rejected:!1}}const Fv=`sibling_tool_failed`,Iv=JSON.stringify({type:Fv,message:`Not executed: a tool call in a preceding parallel batch failed`});function Lv(e){try{return JSON.parse(e)?.type===Fv}catch{return!1}}var Rv=class{concurrency(e,t){return!1}includeInApiDefinitions=!0;isEnabled(e){return!0}async prepare(e,t){return null}needsPermission(e,t,n){return!this.isReadonly}format(e,t){return typeof e==`string`?e:JSON.stringify(e)}formatForLLM(e,t){return this.format(e,t)}parse(e){let t=Pv(e);if(t.rejected)return{phase:`rejected`,toolType:this.name,data:{},summary:t.userNote?`Rejected \u00b7 "${t.userNote}"`:`Rejected`,...t.userNote!==void 0&&{userNote:t.userNote}};try{let t=JSON.parse(e),n=`success`;return t.status===`error`?n=`error`:t.status===`skipped`&&(n=`skipped`),{phase:n,toolType:t.type??this.name,data:t,summary:t.message??t.summary??`Completed`,...t.errorMessage!==void 0&&{errorMessage:t.errorMessage}}}catch{}return e.startsWith(`Error:`)?{phase:`error`,toolType:this.name,data:{},summary:e,errorMessage:e}:{phase:`success`,toolType:this.name,data:{},summary:`Completed`}}validateParams(e){return this.parameters.parse(e)}getToolDefinition(){let e=this.getParameterNames();return{name:this.name,description:this.description,arguments:e}}getParameterNames(){return Object.keys(this.parameters.shape)}};const zv=Symbol.for(`server-executed`);var Bv=class extends Rv{isReadonly=!0;async execute(e,t,n){return zv}format(e,t){return JSON.stringify({type:this.name,status:`server-executed`})}};rt([`codellm`,`agent`,`tools`,`subagent`]);var Vv=class e extends Bv{name=`subagent`;displayName=`Subagent`;description=`Switch to a different subagent for a task`;static parametersSchema=q({agent:K().describe(`The name of the subagent to switch to`),task:K().describe(`The task description for the subagent`)});parameters=e.parametersSchema;needsPermission(){return!1}format(e,t){return JSON.stringify({type:`subagent`,status:`success`,agent:t.agent,task:t.task})}parse(e){let t=Pv(e);if(t.rejected)return{phase:`rejected`,toolType:`subagent`,data:{},summary:t.userNote?`Rejected \u00b7 "${t.userNote}"`:`Rejected`,...t.userNote!==void 0&&{userNote:t.userNote}};try{let t=JSON.parse(e);return{phase:`success`,toolType:`subagent`,data:t,summary:`Delegated to ${t.agent??`explore`} agent`}}catch{}return{phase:`success`,toolType:`subagent`,data:{},summary:`Delegated`}}};rt([`codellm`,`agent`,`tools`,`todo-write`]);var Hv=class e extends Bv{name=`todo_write`;displayName=`TodoWrite`;description=`Create and manage a structured task list`;static parametersSchema=q({todos:Dv(e=>{if(e==null)return[];if(typeof e==`string`)try{let t=JSON.parse(e);return Array.isArray(t)?t:[]}catch{return[]}return Array.isArray(e)?e:[]},B_(q({content:K().describe(`The task content`),status:ev([`pending`,`in_progress`,`completed`,`cancelled`]).describe(`The status of the task`),id:K().optional().describe(`Optional task ID`)}))).describe(`Array of todo items`)});parameters=e.parametersSchema;needsPermission(){return!1}format(e,t){return`Updated`}parse(e){let t=Pv(e);if(t.rejected)return{phase:`rejected`,toolType:`todo_write`,data:{},summary:`Rejected`,...t.userNote!==void 0&&{userNote:t.userNote}};try{let t=JSON.parse(e);if(t.todos){let e=t.todos;return{phase:`success`,toolType:`todo_write`,data:t,summary:`${e.filter(e=>e.status===`pending`).length} pending, ${e.filter(e=>e.status===`in_progress`).length} in progress, ${e.filter(e=>e.status===`completed`).length} completed`}}}catch{}return{phase:`success`,toolType:`todo_write`,data:{},summary:`Updated`}}};function Uv(e){if(typeof e!=`string`)return e;let t=e.trim();return t?Number(t):NaN}function Wv(e){if(typeof e!=`string`)return e;let t=e.trim().toLowerCase();return[`true`,`1`,`yes`,`y`].includes(t)?!0:[`false`,`0`,`no`,`n`].includes(t)?!1:e}const Gv=Dv(Uv,T_()),Kv=Dv(Uv,T_().optional()),qv=Dv(Wv,k_()),Jv=Dv(Wv,k_().optional()),Yv=rt([`codellm`,`agent`,`tools`,`ask-user`]);var Xv=class e extends Rv{isReadonly=!0;name=`ask_user_question`;displayName=`AskUserQuestion`;description=`Ask the user questions during execution to gather preferences, clarify instructions, or get decisions on implementation choices`;static parametersSchema=q({questions:B_(q({question:K().describe(`The question to ask the user`),header:K().describe(`A header/title for the question`),options:B_(q({label:K().describe(`The option label`),description:K().describe(`A description of the option`)})).describe(`Array of options for the user to select from`),multiSelect:qv.describe(`Whether the user can select multiple options`)})).describe(`Array of questions to ask the user`),answers:Q_(K(),K()).optional().describe(`User-provided answers to the questions`)});parameters=e.parametersSchema;needsPermission(){return!0}async execute(e){return Yv.debug`Asking user ${e.questions.length} question(s)`,{answers:e.answers||{}}}format(e,t){return JSON.stringify({type:`ask_user_question`,status:`success`,answers:e.answers})}parse(e){let t=Pv(e);if(t.rejected)return{phase:`rejected`,toolType:`ask_user_question`,data:{},summary:`Cancelled`,...t.userNote!==void 0&&{userNote:t.userNote}};try{let t=JSON.parse(e),n=t.answers,r=n?Object.keys(n).length:0;return{phase:`success`,toolType:`ask_user_question`,data:t,summary:`Answered ${r} question${r===1?``:`s`}`}}catch{}return{phase:`success`,toolType:`ask_user_question`,data:{},summary:`Answered`}}};const Zv=rt([`codellm`,`agent`,`tools`,`plan-mode`]);var Qv=class e extends Rv{name=`enter_plan_mode`;displayName=`EnterPlanMode`;description=`Enter plan mode to create a plan before implementing changes`;static parametersSchema=q({});parameters=e.parametersSchema;isReadonly=!0;needsPermission(e,t,n){return!1}async execute(e,t){return Zv.info`Entering plan mode`,{success:!0}}format(e,t){return`Entered plan mode`}parse(e){let t=Pv(e);return t.rejected?{phase:`rejected`,toolType:`enter_plan_mode`,data:{},summary:`Rejected`,...t.userNote!==void 0&&{userNote:t.userNote}}:{phase:`success`,toolType:`enter_plan_mode`,data:{},summary:`Entered plan mode`}}};const $v=rt([`codellm`,`agent`,`tools`,`plan-mode`]);var ey=class e extends Rv{name=`exit_plan_mode`;displayName=`ExitPlanMode`;description=`Exit plan mode and return to normal agent operation`;static parametersSchema=q({planFilePath:K().describe(`Path to the plan file`)});parameters=e.parametersSchema;isReadonly=!0;async prepare(e,t){if(!e.planFilePath)return{error:`Plan not found`,skipPermission:!0};try{let n=await t.workspace.readRawFile(e.planFilePath);return n?{planContent:n}:{error:`Plan not found`,skipPermission:!0}}catch{return{error:`Plan not found`,skipPermission:!0}}}needsPermission(e,t,n){return!n?.skipPermission}async execute(e,t,n){if(n?.error)throw Error(n.error);return $v.info`Exiting plan mode with plan: ${e.planFilePath}`,{planFilePath:e.planFilePath}}format(e,t){return JSON.stringify({type:`exit_plan_mode`,status:`success`,...e.planFilePath&&{planFilePath:e.planFilePath}})}parse(e){let t=Pv(e);if(t.rejected)return{phase:`rejected`,toolType:`exit_plan_mode`,data:{},summary:`Rejected`,...t.userNote!==void 0&&{userNote:t.userNote}};try{return{phase:`success`,toolType:`exit_plan_mode`,data:JSON.parse(e),summary:`Plan approved`}}catch{}return e.includes(`implement the plan`),{phase:`success`,toolType:`exit_plan_mode`,data:{},summary:`Plan approved`}}},ty;(function(e){e.GeneralPurpose=`GENERAL_PURPOSE`,e.Explore=`EXPLORE`,e.Plan=`PLAN`})(ty||={});const ny={[ty.GeneralPurpose]:{name:ty.GeneralPurpose,displayName:`Agent`,description:`General-purpose agent for researching complex questions, searching for code, and executing multi-step tasks`,allowedTools:[`*`],defaultModel:`CLAUDE_V4_5_SONNET`},[ty.Explore]:{name:ty.Explore,displayName:`Explore`,description:`Fast agent specialized for exploring codebases. Use for finding files by patterns, searching code for keywords, or answering questions about the codebase.`,allowedTools:[`read`,`glob`,`grep`,`bash`,`web_fetch`,`web_search`],defaultModel:`CLAUDE_V4_5_HAIKU`},[ty.Plan]:{name:ty.Plan,displayName:`Plan`,description:`Fast agent for creating implementation plans. Explores codebase to understand architecture before planning.`,allowedTools:[`read`,`glob`,`grep`,`bash`,`web_fetch`,`web_search`],defaultModel:`CLAUDE_V4_5_HAIKU`}},ry=new Set(Object.values(ty));function iy(e){return ry.has(e)}function ay(e){if(iy(e))return e}function oy(e){return ny[e]}function sy(){return Object.values(ty)}function cy(e){let t=ay(e);return t?oy(t).displayName:e}function ly(e,t){let n=ay(e);if(!n)return!1;let r=oy(n);return r.allowedTools.includes(`*`)?!0:r.allowedTools.includes(t)}const uy=/[ \t()[\]{};|*?$`'"#&<>!~]/;function dy(e){return e.replace(RegExp(`\\\\([${uy.source.slice(1,-1)}])`,`g`),`$1`)}const fy=N.homedir();function py(e){return e===`~`?fy:e.startsWith(`~/`)?E.join(fy,e.slice(2)):e}function my(e,t){return E.isAbsolute(e)?(E.relative(t,e)||e).split(E.sep).join(`/`):e.startsWith(`./`)||e.startsWith(`.\\`)?e.slice(2):e}function hy(e){let t=E.resolve(e);try{return v(t)}catch{try{let e=E.dirname(t),n=E.basename(t);return E.join(v(e),n)}catch{return t}}}function gy(e){return!!e&&!e.startsWith(`..`)&&!E.isAbsolute(e)}function _y(e,t){let n=E.resolve(e),r=E.resolve(t);if(n===r||gy(E.relative(r,n)))return!0;let i=hy(n),a=hy(r);return i===a?!0:gy(E.relative(a,i))}function vy(e,t){let n=E.resolve(e),r=E.resolve(t),i=E.relative(r,n);if(gy(i))return{success:!0,relativePath:i};let a=hy(n),o=hy(r);return i=E.relative(o,a),gy(i)?{success:!0,relativePath:i}:{success:!1,reason:`outside_workspace`}}async function yy(e){return new Promise(t=>setTimeout(t,e))}const by=rt([`codellm`,`agent`,`loop`]);function xy(e){if(!e)return null;if(typeof e==`string`)return e;if(typeof e==`object`&&e){let t=e;if(t.text)return t.text;if(t.segment)return xy(t.segment)}return null}function Sy(e){return Math.min((e+1)*2e3,1e4)}function Cy(e){return 2**(e+1)*1e3}function*wy(e,t,n){if(e.error){let t=e.error,r=typeof t==`string`?t:JSON.stringify(t);r.includes(`Credit limit`)||r.includes(`no_usage_points`)||r.includes(`compute_point_budgeting`)||r.includes(`limit_exceeded`)||r.includes(`exhausted`)||r.includes(`purchase more credits`)?yield{__error:new nf({...n.pendingCreditLimitSegment??void 0,message:r})}:jl(r)?yield{__error:new Ol}:yield{__error:new tf(r)};return}if(e.type===`no_usage_points`||e.type===`compute_point_budgeting`||e.type===`limit_exceeded`){n.pendingCreditLimitSegment=e;return}if(e.type===`code_llm_credits`){yield{type:`credits`,creditsUsed:e.creditsUsed};return}if(e.type===`collapsible_component`&&e.isThoughts===!0){let t=e.title||`Thinking`,n=xy(e.segment)??``;n&&(yield{type:`thinking_delta`,content:n,title:t}),e.isSpinny===!1&&(yield{type:`thinking_complete`});return}if(e.type===`code_llm_notification`){let t=e.message||xy(e.segment)||`Notification`;yield{...e,type:`notification`,message:t,severity:e.severity??`info`};return}if(e.type===`code_llm_agent_tool_call_start`){yield{type:`tool_call_start`,toolCallId:e.toolCallId,toolName:e.toolName};return}if(e.type===`code_llm_agent_tool_call_delta`){yield{type:`tool_call_delta`,toolCallId:e.toolCallId,argumentsDelta:e.argumentsDelta};return}if(e.type===`code_llm_agent_tool_call_stop`){yield{type:`tool_call_stop`,toolCallId:e.toolCallId,toolName:e.toolName,arguments:e.arguments};let n=e.toolUseRequest;if(n){let e=n;if(e.name===`edit`){let t=e.input;(`startLineOneIndexed`in t||`endLineOneIndexed`in t)&&(e={...e,input:{...t,startLine:t.startLineOneIndexed??t.startLine,endLine:t.endLineOneIndexed??t.endLine}})}t.push(e),yield{type:`tool_requested`,tool:e}}return}if(e.toolUseRequest){let n=(Array.isArray(e.toolUseRequest)?e.toolUseRequest:[e.toolUseRequest]).map(e=>{if(e.name===`edit`){let t=e.input;if(`startLineOneIndexed`in t||`endLineOneIndexed`in t)return{...e,input:{...t,startLine:t.startLineOneIndexed??t.startLine,endLine:t.endLineOneIndexed??t.endLine}}}return e}),r=new Set(t.map(e=>e.id)),i=n.filter(e=>!r.has(e.id));t.push(...i);for(let e of i)yield{type:`tool_requested`,tool:e};return}if(e.segment){let t=xy(e.segment);t&&(yield{type:`text_delta`,content:t})}}async function*Ty(e){let t=crypto.randomUUID(),n=!1;by.debug(`Starting agent loop (conversationId={conversationId}, model={model})`,{conversationId:e.conversationId,model:e.model});for(let r=0;r<8;r++){xl(`turn started`,`agent`);let i=t,a=!1;if(r>0){by.debug(`Retry attempt {attempt}: checking for pending request ID`,{attempt:r});try{let t=await e.apiClient.getPendingRequestIdForConversation(e.conversationId);t?.success&&t.result?.requestId&&(i=t.result.requestId,a=!0)}catch{}}let o=[],s={pendingCreditLimitSegment:null},c=!1;try{let t=e.apiClient.streamAgentMessage({deploymentConversationId:e.conversationId,message:e.message,supportedTools:e.supportedTools,supportedSubAgents:e.supportedSubAgents,mcpTools:e.isPrintMode?[]:e.mcpTools??[],workspacePath:e.workspacePath,...e.swapFolder&&{swapFolder:e.swapFolder},llmName:e.model,requestId:i,docInfos:e.uploadedDocs?Array.from(e.uploadedDocs):[],toolUseResult:e.toolResult,supportsV2:!0,supportsThoughtStreaming:e.supportsThoughtStreaming??!0,supportsParallelToolUse:!0,isPrintMode:e.isPrintMode??!1,...e.subagent&&{subagent:e.subagent},agentMode:e.agentMode,currentFile:e.currentFile,selectionStartLine:e.selectionStartLine,selectionEndLine:e.selectionEndLine,gitBranch:e.gitBranch,gitMain:e.gitMain,gitStatus:e.gitStatus,gitCommits:e.gitCommits,diagnosticIssues:e.diagnosticIssues,availableSkills:e.availableSkills,activeSkills:e.activeSkills,client:e.client,setFolder:e.setFolder,reconnect:a,signal:e.signal});for await(let n of t){if(e.signal?.aborted)break;for(let e of wy(n,o,s)){if(`__error`in e)throw e.__error;yield e}c=!0}n&&=(yield{type:`network_status`,online:!0},!1),yield{type:`turn_complete_with_tools`,toolCalls:o},by.debug(`Agent loop completed with {count} tool calls`,{count:o.length});return}catch(t){let i=t instanceof Error?t:Error(String(t));if(i instanceof Ol){if(c&&r<4&&!e.signal?.aborted){let e=Cy(r);by.warn(`Auth error mid-stream (attempt={attempt}, delay={delayMs}ms) — retrying (server may have re-validated against a stale replica)`,{attempt:r+1,delayMs:e}),yl(`Mid-stream auth error, retrying`,`warning`,{context:`agent-loop`,attempt:r+1}),yield{type:`retry`,attempt:r+1,maxAttempts:5,delayMs:e,isNetworkError:!1},await yy(e);continue}throw by.warn(`Auth expired, aborting loop`),i}if(i instanceof nf)throw by.warn(`Credit limit reached, aborting loop`),yl(`Credit limit reached`,`warning`,{context:`agent-loop`}),i;let a=Ml(i),o=a?8:5;if(r<o-1&&!e.signal?.aborted){let e=a?Sy(r):Cy(r);by.warn(`Retrying after error (attempt={attempt}, network={isNetErr}, delay={delayMs}ms): {error}`,{attempt:r+1,isNetErr:a,delayMs:e,error:i.message}),a&&!n&&(n=!0,yield{type:`network_status`,online:!1}),yield{type:`retry`,attempt:r+1,maxAttempts:o,delayMs:e,isNetworkError:a},await yy(e);continue}throw by.error(`All retry attempts exhausted: {error}`,{error:i.message}),vl(i,{context:`agent-loop-retry-exhausted`}),Ml(i)?i instanceof kl?i:new kl(i.message,i):i}}}const Ey=rt([`codellm`,`agent`,`runner`]);var Dy=class{queue=[];resolvers=[];closed=!1;push(e){this.closed||(this.resolvers.length>0?this.resolvers.shift()(e):this.queue.push(e))}async next(){return this.queue.length>0?this.queue.shift():this.closed?null:new Promise(e=>{this.resolvers.push(e)})}close(){this.closed=!0;for(let e of this.resolvers)e(null);this.resolvers=[]}drain(){let e=[...this.queue];return this.queue=[],e}};function Oy(e){return e.toUpperCase().includes(`CLAUDE`)}async function*ky(e,t,n){let r=e.maxTurns??2**53-1,i=t,a,o=0,s=0,c=[],l=e.agentMode;Ey.info(`Starting agent conversation (model={model}, maxTurns={maxTurns})`,{model:e.model,maxTurns:r});try{for(;o<r;){if(n?.aborted)return Ey.info(`Conversation aborted after {numTurns} turns`,{numTurns:o}),{content:c.join(``),numTurns:o,toolCallsExecuted:s,success:!1,error:Error(`Execution cancelled`)};o++;let t={...e,swapFolder:a===void 0?e.swapFolder:void 0,setFolder:a===void 0?e.setFolder:void 0,agentMode:l,message:i,...a!==void 0&&{toolResult:a},...n!==void 0&&{signal:n}},r=[],u=new Map,d=new Map,f=new Map,p=[],m=new Dy,h=new AbortController,g=()=>h.abort(`interrupted`);n&&(n.aborted?h.abort(`interrupted`):n.addEventListener(`abort`,g,{once:!0}));let _=async(t,n,r)=>(await e.executeTools([t],n,r))[0],v=e.getConcurrency??(()=>!1),y=e=>{let t=_(e,h.signal,e=>m.push(e)).then(t=>{d.set(e.id,t);for(let[t,n]of f)if(n===e.id){f.delete(t);break}return t}).catch(e=>{throw h.abort(`sibling_tool_failed`),e});u.set(e.id,t)},b=e=>{let t=v(e);typeof t==`string`&&f.has(t)?p.push(e):(typeof t==`string`&&f.set(t,e.id),y(e))},x=!1;for await(let e of Ty(t)){for(let e of m.drain())e.type===`mode_changed`&&(l=e.mode),yield e;if(e.type===`turn_complete_with_tools`){r=e.toolCalls,x=!0;continue}if(e.type===`text_delta`&&c.push(e.content),e.type===`tool_requested`){yield e,b(e.tool);continue}yield e}for(let e of m.drain())e.type===`mode_changed`&&(l=e.mode),yield e;if(x||Ey.warn(`Agent loop exited without turn_complete_with_tools (collected {count} tool calls)`,{count:r.length}),r.length===0){Ey.debug(`Turn {numTurns} complete with no tool calls`,{numTurns:o}),n?.removeEventListener(`abort`,g),yield{type:`turn_complete`};break}for(let e of p){let t=v(e);if(typeof t==`string`&&f.has(t)){let e=f.get(t),n=u.get(e);if(n)try{await n}catch{}}h.signal.aborted||b(e)}let S=r.filter(e=>!u.has(e.id));if(S.length>0)if(u.size===0){let t,n=e.executeTools(r,h.signal,e=>m.push(e)).then(e=>{t=e;for(let t=0;t<e.length;t++){let n=r[t];n&&d.set(n.id,e[t])}return m.close(),e}),i=new Set;for(;t===void 0;){let e=await Promise.race([m.next(),n.then(()=>null)]);if(e!==null)e.type===`mode_changed`&&(l=e.mode),e.type===`tool_execution_complete`&&i.add(e.tool.id),yield e;else if(t!==void 0)break}t||=await n;for(let e of m.drain())e.type===`mode_changed`&&(l=e.mode),e.type===`tool_execution_complete`&&i.add(e.tool.id),yield e;for(let e=0;e<t.length;e++){let n=r[e],a=t[e];n&&a&&!i.has(n.id)&&(yield{type:`tool_execution_complete`,tool:n,result:a})}}else for(let e of S)h.signal.aborted||y(e);if(u.size>0){let e=Promise.allSettled(u.values()).then(()=>{m.close()}),t=new Set,n=await m.next();for(;n!==null;)n.type===`mode_changed`&&(l=n.mode),n.type===`tool_execution_complete`&&t.add(n.tool.id),yield n,n=await m.next();await e;for(let e of r){let n=d.get(e.id);n&&!t.has(e.id)&&(yield{type:`tool_execution_complete`,tool:e,result:n})}}s+=r.length;let C=r.map(e=>d.get(e.id)??{id:e.id,content:`Error: tool execution did not complete`});n?.removeEventListener(`abort`,g);for(let t of e.drainEvents?.()??[])t.type===`mode_changed`&&(l=t.mode),yield t;let w=new Set([`task`]),T=(e,t)=>!(!e.rejected||w.has(r[t]?.name??``)),E=C.some((e,t)=>{if(!T(e,t))return!1;try{return JSON.parse(e.content).reason===Mv.REJECTED}catch{return!1}}),D=C.some((e,t)=>{if(!T(e,t))return!1;try{return JSON.parse(e.content).reason===Mv.INTERRUPTED}catch{return!1}}),O=C.some(e=>{if(!e.rejected)return!1;try{return JSON.parse(e.content).reason===Mv.USER_MESSAGE}catch{return!1}});if((E||D)&&!O){yield{type:`turn_complete`};break}let k=C.map(({parsedResult:e,...t})=>t);a=k.length===1?k[0]:k;let A=r.some(e=>e.name===`exit_plan_mode`)&&C.some(e=>{if(e.rejected)return!1;try{return JSON.parse(e.content).type===`exit_plan_mode`}catch{return!1}}),j=`I want you to start implementing the plan now as you have outlined in your plan.`,M=e.getQueuedMessage?.();if(M)if(Oy(e.model))i=A?`${j} ${M}`:M,e.clearQueuedMessage?.(),e.isQueuedMessageHidden?.()||(yield{type:`user_message_dequeued`,content:M});else{yield{type:`turn_complete`};break}else i=A?j:``;yield{type:`turn_complete`}}if(o>=r){Ey.warn(`Maximum turns ({maxTurns}) exceeded`,{maxTurns:r});let e=Error(`Maximum turns (${r}) exceeded`);return yield{type:`error`,error:e},{content:c.join(``),numTurns:o,toolCallsExecuted:s,success:!1,error:e}}return Ey.info(`Conversation completed (turns={numTurns}, toolCalls={toolCallsExecuted})`,{numTurns:o,toolCallsExecuted:s}),{content:c.join(``),numTurns:o,toolCallsExecuted:s,success:!0}}catch(e){let t=e instanceof Error?e:Error(String(e));return vl(t,{context:`agent-runner`}),Ey.error(`Conversation failed after {numTurns} turns: {error}`,{numTurns:o,toolCallsExecuted:s,error:t}),yield{type:`error`,error:t},{content:c.join(``),numTurns:o,toolCallsExecuted:s,success:!1,error:t}}}const Ay=rt([`codellm`,`agent`,`subagent`]);function jy(e,t){let n=oy(t);return!n||n.allowedTools.includes(`*`)?e:e.filter(e=>ly(t,e.name))}function My(e,t,n,r,i){let a=n.get(e.name)?.displayName??e.name;if(!n.isBuiltinRequest(e))return{type:`generic`,tool:e,displayName:a,toolName:a,inputSummary:JSON.stringify(e.input??{}).slice(0,200)};switch(e.name){case`read`:{let n=t._prepareResult;if(n?.resolvedPath){let t=hy(n.resolvedPath);return{type:`read_outside_directory`,tool:e,displayName:a,filePath:t,resolvedPath:t,deducedDirectory:E.dirname(t)}}return{type:`generic`,tool:e,displayName:a,toolName:a,inputSummary:JSON.stringify(e.input??{}).slice(0,200)}}case`edit`:{let n=t._prepareResult;if(n?.outsideWorkspace){let t=hy(n.resolvedPath??e.input.filePath??``);return{type:`edit_outside_directory`,tool:e,displayName:a,filePath:t,resolvedPath:t,deducedDirectory:E.dirname(t)}}return{type:`edit_file`,tool:e,displayName:a,filePath:e.input.filePath??``,originalContent:n?.currentContent??``,newContent:n?.newContent??``}}case`write`:{let n=t._prepareResult;if(n?.outsideWorkspace){let t=hy(n.resolvedPath??e.input.filePath??``);return{type:`write_outside_directory`,tool:e,displayName:a,filePath:t,resolvedPath:t,deducedDirectory:E.dirname(t),isNewFile:!n?.fileExists}}return{type:`write_file`,tool:e,displayName:a,filePath:e.input.filePath??``,originalContent:n?.currentContent??``,content:e.input.content??``,isNewFile:!n?.fileExists}}case`bash`:return{type:`run_terminal`,tool:e,displayName:a,command:e.input.command??``,cwd:r,background:!!(e.input.runInBackground??!1),unmatchedPatterns:i?.getUnmatchedBashSegments(e.input.command??``)??[]};case`notebook_edit`:{let n=t._prepareResult;if(n?.outsideWorkspace){let t=hy(n.resolvedPath??e.input.notebookPath??``);return{type:`notebook_edit_outside_directory`,tool:e,displayName:a,filePath:t,resolvedPath:t,deducedDirectory:E.dirname(t)}}let r=n?.notebook,i=e.input.cellId,o=``;if(i&&r?.cells){let e=r.cells.find(e=>e.id===i||e.metadata?.id===i);e&&(o=Array.isArray(e.source)?e.source.join(``):String(e.source??``))}return{type:`notebook_edit`,tool:e,displayName:a,notebookPath:e.input.notebookPath??``,cellId:i,editMode:e.input.editMode??`replace`,cellType:e.input.cellType,originalContent:o,newContent:e.input.newSource??``}}case`ask_user_question`:return{type:`ask_user_question`,tool:e,displayName:a,questions:Array.isArray(e.input.questions)?e.input.questions:[]};case`exit_plan_mode`:{let n=t._prepareResult;return{type:`exit_plan_mode`,tool:e,displayName:a,planFilePath:e.input.planFilePath??``,planContent:n?.planContent??``}}default:return{type:`generic`,tool:e,displayName:a,toolName:a,inputSummary:JSON.stringify(e.input??{}).slice(0,200)}}}async function Ny(e){let{prompt:t,subagentType:n,model:r,resume:i,parentContext:a,onProgress:o,signal:s}=e;Ay.info(`Starting subagent (type={subagentType}, model={model})`,{subagentType:n,model:r??`default`});let c=oy(n);if(!c)return Ay.error(`Unknown subagent type: {subagentType}`,{subagentType:n}),{success:!1,output:``,toolsExecuted:[],toolCalls:[],numTurns:0,error:`Unknown subagent type: ${n}`};let l=Mw(),u=jy(l.getApiToolDefinitions(),n),d=r??c.defaultModel??`CLAUDE_V4_5_SONNET`,f;if(i&&c.supportsResume)f=i;else try{let e=await a.apiClient.createCodellmDeploymentConversation(`CODE_LLM_NON_INTERACTIVE`,a.clientType);if(!e?.result?.deploymentConversationId)return{success:!1,output:``,toolsExecuted:[],toolCalls:[],numTurns:0,error:`Failed to create subagent conversation: no conversation ID returned`};f=e.result.deploymentConversationId}catch(e){return{success:!1,output:``,toolsExecuted:[],toolCalls:[],numTurns:0,error:`Failed to create subagent conversation: ${e instanceof Error?e.message:String(e)}`}}let p=[],m=[],h=[],g=a.permissionProvider&&a.rulesEngine&&a.getAgentMode,_=()=>a.getAgentMode?.()??$d.Yolo,v=c?.name,y={apiClient:a.apiClient,conversationId:f,model:d,workspacePath:a.workspacePath,supportedTools:u,mcpTools:[],uploadedDocs:a.uploadedDocs,isPrintMode:!g,...v&&{subagent:v},supportsThoughtStreaming:!0,agentMode:_(),executeTools:async(e,t,n)=>{let r=[];for(let i of e){if(t?.aborted||s?.aborted)break;m.push(i.name);let e={name:i.name,input:i.input??{}};o?.({type:`tool_requested`,content:`${i.name}`,toolName:i.name,toolInput:e.input,toolId:i.id}),n?.({type:`tool_execution_start`,tool:i});let c=_(),u={...a,toolCallId:i.id,conversationId:f,agentMode:c,status:`executing`};try{let d=l.createToolInstance(i.name,i.input??{},u);await d.prepare();let f=c===$d.Yolo&&i.name!==`ask_user_question`;if(g&&!f&&d.needsPermission()){let c=l.get(i.name)?.displayName??i.name,f=Gw(i),p=a.rulesEngine.evaluate(c,f);if(p===`deny`){r.push({id:i.id,content:JSON.stringify({reason:Mv.REJECTED}),rejected:!0}),e.result=`denied by rule`,h.push(e),o?.({type:`tool_complete`,content:`${i.name}`,toolName:i.name,toolId:i.id});continue}if(p!==`allow`){let c=My(i,d,l,a.workspacePath,a.rulesEngine);if(a.permissionProvider.needsPermission(c)){n?.({type:`status_changed`,status:ef.WaitingForToolPermission}),a.emitEvent?.({type:`status_changed`,status:ef.WaitingForToolPermission});let l;try{let e=a.permissionProvider.requestPermission(c),n=t||s;if(n){let t,r=new Promise((e,r)=>{n.aborted?r(Error(`interrupted`)):(t=()=>r(Error(`interrupted`)),n.addEventListener(`abort`,t,{once:!0}))});try{l=await Promise.race([e,r])}finally{t&&n.removeEventListener(`abort`,t)}}else l=await e}catch{r.push({id:i.id,content:JSON.stringify({reason:Mv.INTERRUPTED}),rejected:!0}),e.result=`interrupted`,h.push(e),o?.({type:`tool_complete`,content:`${i.name}`,toolName:i.name,toolId:i.id});continue}if(n?.({type:`status_changed`,status:ef.ExecutingTool}),a.emitEvent?.({type:`status_changed`,status:ef.ExecutingTool}),l===`reject`){r.push({id:i.id,content:JSON.stringify({reason:Mv.REJECTED}),rejected:!0}),e.result=`rejected`,h.push(e),o?.({type:`tool_complete`,content:`${i.name}`,toolName:i.name,toolId:i.id});continue}if(typeof l==`object`&&l.type===`reject_with_message`){r.push({id:i.id,content:JSON.stringify({reason:Mv.USER_MESSAGE,message:l.message}),rejected:!0}),e.result=`rejected`,h.push(e),o?.({type:`tool_complete`,content:`${i.name}`,toolName:i.name,toolId:i.id});continue}if(l===`allowAlways`||l===`allowYolo`||l===`accept`){if(l===`allowAlways`&&(c.type===`read_outside_directory`||c.type===`write_outside_directory`||c.type===`edit_outside_directory`||c.type===`notebook_edit_outside_directory`)&&`deducedDirectory`in c){let e=a.allowEditingPaths??[],t=c.deducedDirectory;e.includes(t)||e.push(t)}else if(i.name===`exit_plan_mode`){let e=l===`allowYolo`?$d.Yolo:l===`allowAlways`?$d.AcceptEdits:$d.Normal;a.setAgentMode?.(e),u.agentMode=e,n?.({type:`mode_changed`,mode:e})}else if(l===`allowAlways`){let e=of(c.type);a.setAgentMode?.(e),u.agentMode=e,n?.({type:`mode_changed`,mode:e})}}if(typeof l==`object`&&l.type===`accept_with_message`){r.push({id:i.id,content:JSON.stringify({reason:Mv.USER_MESSAGE,message:l.message}),rejected:!0}),e.result=`accepted with message`,h.push(e),o?.({type:`tool_complete`,content:`${i.name}`,toolName:i.name,toolId:i.id});continue}if(typeof l==`object`&&l.type===`question_answers`&&d.mergeParams({answers:l.answers}),typeof l==`object`&&l.type===`allow_always_with_rule`&&a.rulesEngine.addAllowRule(l.rule),typeof l==`object`&&l.type===`allow_always_with_rules`)for(let e of l.rules)a.rulesEngine.addAllowRule(e)}}}i.name===`enter_plan_mode`&&(a.setAgentMode?.($d.PlanMode),u.agentMode=$d.PlanMode,n?.({type:`mode_changed`,mode:$d.PlanMode})),i.name===`exit_plan_mode`&&f&&(a.setAgentMode?.($d.Normal),u.agentMode=$d.Normal,n?.({type:`mode_changed`,mode:$d.Normal})),await d.execute();let p=d.formatResultForLLM(),m=d.formatResult(),_=typeof p==`string`?p:JSON.stringify(p),v=l.parse(i.name,m);r.push({id:i.id,content:_,parsedResult:v}),e.result=_}catch(t){let n=t instanceof Error?t.message:String(t);r.push({id:i.id,content:`Error: ${n}`}),e.result=`Error: ${n}`}h.push(e),o?.({type:`tool_complete`,content:`${i.name}`,toolName:i.name,toolId:i.id})}for(let t of e)r.some(e=>e.id===t.id)||r.push({id:t.id,content:JSON.stringify({reason:Mv.INTERRUPTED}),rejected:!0});return r}};try{o?.({type:`status`,content:`Starting ${n} agent...`});let e=ky(y,t,s),r=await e.next();for(;!r.done;){let t=r.value;switch(t.type){case`text_delta`:p.push(t.content),o?.({type:`text`,content:t.content});break;case`thinking_delta`:o?.({type:`thinking`,content:t.content});break;case`tool_requested`:case`turn_complete`:break;case`tool_execution_complete`:p.length=0;break;case`error`:return{success:!1,output:p.join(``),toolsExecuted:m,toolCalls:h,numTurns:0,error:t.error?.message??`Unknown error`};case`mode_changed`:a.emitEvent?.(t);break;case`status_changed`:case`notification`:break}r=await e.next()}let i=r.value;return Ay.info(`Subagent completed (type={subagentType}, turns={numTurns}, tools={toolCount})`,{subagentType:n,numTurns:i.numTurns,toolCount:m.length}),{success:i.success,output:p.join(``),toolsExecuted:m,toolCalls:h,numTurns:i.numTurns,...i.error&&{error:i.error.message}}}catch(e){let t=e instanceof Error?e.message:String(e);return vl(e instanceof Error?e:Error(t),{context:`subagent-runner`}),Ay.error(`Subagent failed (type={subagentType}): {error}`,{subagentType:n,error:t}),{success:!1,output:p.join(``),toolsExecuted:m,toolCalls:h,numTurns:0,error:t}}}const Py=rt([`codellm`,`agent`,`tools`,`task`]);var Fy=class e extends Rv{name=`task`;displayName=`Task`;description=`Launch a new agent to handle complex, multi-step tasks autonomously.
|
|
50
|
+
Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let n of e.seen.entries()){let r=n[1];if(t===n[0]){a(n);continue}if(e.external){let r=e.external.registry.get(n[0])?.id;if(t!==n[0]&&r){a(n);continue}}if(e.metadataRegistry.get(n[0])?.id){a(n);continue}if(r.cycle){a(n);continue}if(r.count>1&&e.reused===`ref`){a(n);continue}}}function Zh(e,t){let n=e.seen.get(t);if(!n)throw Error(`Unprocessed schema. This is a bug in Zod.`);let r=t=>{let n=e.seen.get(t);if(n.ref===null)return;let i=n.def??n.schema,a={...i},o=n.ref;if(n.ref=null,o){r(o);let n=e.seen.get(o),s=n.schema;if(s.$ref&&(e.target===`draft-07`||e.target===`draft-04`||e.target===`openapi-3.0`)?(i.allOf=i.allOf??[],i.allOf.push(s)):Object.assign(i,s),Object.assign(i,a),t._zod.parent===o)for(let e in i)e===`$ref`||e===`allOf`||e in a||delete i[e];if(s.$ref&&n.def)for(let e in i)e===`$ref`||e===`allOf`||e in n.def&&JSON.stringify(i[e])===JSON.stringify(n.def[e])&&delete i[e]}let s=t._zod.parent;if(s&&s!==o){r(s);let t=e.seen.get(s);if(t?.schema.$ref&&(i.$ref=t.schema.$ref,t.def))for(let e in i)e===`$ref`||e===`allOf`||e in t.def&&JSON.stringify(i[e])===JSON.stringify(t.def[e])&&delete i[e]}e.override({zodSchema:t,jsonSchema:i,path:n.path??[]})};for(let t of[...e.seen.entries()].reverse())r(t[0]);let i={};if(e.target===`draft-2020-12`?i.$schema=`https://json-schema.org/draft/2020-12/schema`:e.target===`draft-07`?i.$schema=`http://json-schema.org/draft-07/schema#`:e.target===`draft-04`?i.$schema=`http://json-schema.org/draft-04/schema#`:e.target,e.external?.uri){let n=e.external.registry.get(t)?.id;if(!n)throw Error("Schema is missing an `id` property");i.$id=e.external.uri(n)}Object.assign(i,n.def??n.schema);let a=e.external?.defs??{};for(let t of e.seen.entries()){let e=t[1];e.def&&e.defId&&(a[e.defId]=e.def)}e.external||Object.keys(a).length>0&&(e.target===`draft-2020-12`?i.$defs=a:i.definitions=a);try{let n=JSON.parse(JSON.stringify(i));return Object.defineProperty(n,`~standard`,{value:{...t[`~standard`],jsonSchema:{input:$h(t,`input`,e.processors),output:$h(t,`output`,e.processors)}},enumerable:!1,writable:!1}),n}catch{throw Error(`Error converting schema to JSON.`)}}function Qh(e,t){let n=t??{seen:new Set};if(n.seen.has(e))return!1;n.seen.add(e);let r=e._zod.def;if(r.type===`transform`)return!0;if(r.type===`array`)return Qh(r.element,n);if(r.type===`set`)return Qh(r.valueType,n);if(r.type===`lazy`)return Qh(r.getter(),n);if(r.type===`promise`||r.type===`optional`||r.type===`nonoptional`||r.type===`nullable`||r.type===`readonly`||r.type===`default`||r.type===`prefault`)return Qh(r.innerType,n);if(r.type===`intersection`)return Qh(r.left,n)||Qh(r.right,n);if(r.type===`record`||r.type===`map`)return Qh(r.keyType,n)||Qh(r.valueType,n);if(r.type===`pipe`)return Qh(r.in,n)||Qh(r.out,n);if(r.type===`object`){for(let e in r.shape)if(Qh(r.shape[e],n))return!0;return!1}if(r.type===`union`){for(let e of r.options)if(Qh(e,n))return!0;return!1}if(r.type===`tuple`){for(let e of r.items)if(Qh(e,n))return!0;return!!(r.rest&&Qh(r.rest,n))}return!1}const Ite=(e,t={})=>n=>{let r=Jh({...n,processors:t});return Yh(e,r),Xh(r,e),Zh(r,e)},$h=(e,t,n={})=>r=>{let{libraryOptions:i,target:a}=r??{},o=Jh({...i??{},target:a,io:t,processors:n});return Yh(e,o),Xh(o,e),Zh(o,e)},Lte={guid:`uuid`,url:`uri`,datetime:`date-time`,json_string:`json-string`,regex:``},Rte=(e,t,n,r)=>{let i=n;i.type=`string`;let{minimum:a,maximum:o,format:s,patterns:c,contentEncoding:l}=e._zod.bag;if(typeof a==`number`&&(i.minLength=a),typeof o==`number`&&(i.maxLength=o),s&&(i.format=Lte[s]??s,i.format===``&&delete i.format,s===`time`&&delete i.format),l&&(i.contentEncoding=l),c&&c.size>0){let e=[...c];e.length===1?i.pattern=e[0].source:e.length>1&&(i.allOf=[...e.map(e=>({...t.target===`draft-07`||t.target===`draft-04`||t.target===`openapi-3.0`?{type:`string`}:{},pattern:e.source}))])}},zte=(e,t,n,r)=>{let i=n,{minimum:a,maximum:o,format:s,multipleOf:c,exclusiveMaximum:l,exclusiveMinimum:u}=e._zod.bag;typeof s==`string`&&s.includes(`int`)?i.type=`integer`:i.type=`number`,typeof u==`number`&&(t.target===`draft-04`||t.target===`openapi-3.0`?(i.minimum=u,i.exclusiveMinimum=!0):i.exclusiveMinimum=u),typeof a==`number`&&(i.minimum=a,typeof u==`number`&&t.target!==`draft-04`&&(u>=a?delete i.minimum:delete i.exclusiveMinimum)),typeof l==`number`&&(t.target===`draft-04`||t.target===`openapi-3.0`?(i.maximum=l,i.exclusiveMaximum=!0):i.exclusiveMaximum=l),typeof o==`number`&&(i.maximum=o,typeof l==`number`&&t.target!==`draft-04`&&(l<=o?delete i.maximum:delete i.exclusiveMaximum)),typeof c==`number`&&(i.multipleOf=c)},Bte=(e,t,n,r)=>{n.type=`boolean`},Vte=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`BigInt cannot be represented in JSON Schema`)},Hte=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Symbols cannot be represented in JSON Schema`)},eg=(e,t,n,r)=>{t.target===`openapi-3.0`?(n.type=`string`,n.nullable=!0,n.enum=[null]):n.type=`null`},tg=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Undefined cannot be represented in JSON Schema`)},ng=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Void cannot be represented in JSON Schema`)},rg=(e,t,n,r)=>{n.not={}},ig=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Date cannot be represented in JSON Schema`)},ag=(e,t,n,r)=>{let i=e._zod.def,a=ff(i.entries);a.every(e=>typeof e==`number`)&&(n.type=`number`),a.every(e=>typeof e==`string`)&&(n.type=`string`),n.enum=a},og=(e,t,n,r)=>{let i=e._zod.def,a=[];for(let e of i.values)if(e===void 0){if(t.unrepresentable===`throw`)throw Error("Literal `undefined` cannot be represented in JSON Schema")}else if(typeof e==`bigint`){if(t.unrepresentable===`throw`)throw Error(`BigInt literals cannot be represented in JSON Schema`);a.push(Number(e))}else a.push(e);if(a.length!==0)if(a.length===1){let e=a[0];n.type=e===null?`null`:typeof e,t.target===`draft-04`||t.target===`openapi-3.0`?n.enum=[e]:n.const=e}else a.every(e=>typeof e==`number`)&&(n.type=`number`),a.every(e=>typeof e==`string`)&&(n.type=`string`),a.every(e=>typeof e==`boolean`)&&(n.type=`boolean`),a.every(e=>e===null)&&(n.type=`null`),n.enum=a},sg=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`NaN cannot be represented in JSON Schema`)},cg=(e,t,n,r)=>{let i=n,a=e._zod.pattern;if(!a)throw Error(`Pattern not found in template literal`);i.type=`string`,i.pattern=a.source},lg=(e,t,n,r)=>{let i=n,a={type:`string`,format:`binary`,contentEncoding:`binary`},{minimum:o,maximum:s,mime:c}=e._zod.bag;o!==void 0&&(a.minLength=o),s!==void 0&&(a.maxLength=s),c?c.length===1?(a.contentMediaType=c[0],Object.assign(i,a)):(Object.assign(i,a),i.anyOf=c.map(e=>({contentMediaType:e}))):Object.assign(i,a)},ug=(e,t,n,r)=>{n.type=`boolean`},dg=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Custom types cannot be represented in JSON Schema`)},fg=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Function types cannot be represented in JSON Schema`)},pg=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Transforms cannot be represented in JSON Schema`)},mg=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Map cannot be represented in JSON Schema`)},hg=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Set cannot be represented in JSON Schema`)},gg=(e,t,n,r)=>{let i=n,a=e._zod.def,{minimum:o,maximum:s}=e._zod.bag;typeof o==`number`&&(i.minItems=o),typeof s==`number`&&(i.maxItems=s),i.type=`array`,i.items=Yh(a.element,t,{...r,path:[...r.path,`items`]})},_g=(e,t,n,r)=>{let i=n,a=e._zod.def;i.type=`object`,i.properties={};let o=a.shape;for(let e in o)i.properties[e]=Yh(o[e],t,{...r,path:[...r.path,`properties`,e]});let s=new Set(Object.keys(o)),c=new Set([...s].filter(e=>{let n=a.shape[e]._zod;return t.io===`input`?n.optin===void 0:n.optout===void 0}));c.size>0&&(i.required=Array.from(c)),a.catchall?._zod.def.type===`never`?i.additionalProperties=!1:a.catchall?a.catchall&&(i.additionalProperties=Yh(a.catchall,t,{...r,path:[...r.path,`additionalProperties`]})):t.io===`output`&&(i.additionalProperties=!1)},vg=(e,t,n,r)=>{let i=e._zod.def,a=i.inclusive===!1,o=i.options.map((e,n)=>Yh(e,t,{...r,path:[...r.path,a?`oneOf`:`anyOf`,n]}));a?n.oneOf=o:n.anyOf=o},yg=(e,t,n,r)=>{let i=e._zod.def,a=Yh(i.left,t,{...r,path:[...r.path,`allOf`,0]}),o=Yh(i.right,t,{...r,path:[...r.path,`allOf`,1]}),s=e=>`allOf`in e&&Object.keys(e).length===1;n.allOf=[...s(a)?a.allOf:[a],...s(o)?o.allOf:[o]]},bg=(e,t,n,r)=>{let i=n,a=e._zod.def;i.type=`array`;let o=t.target===`draft-2020-12`?`prefixItems`:`items`,s=t.target===`draft-2020-12`||t.target===`openapi-3.0`?`items`:`additionalItems`,c=a.items.map((e,n)=>Yh(e,t,{...r,path:[...r.path,o,n]})),l=a.rest?Yh(a.rest,t,{...r,path:[...r.path,s,...t.target===`openapi-3.0`?[a.items.length]:[]]}):null;t.target===`draft-2020-12`?(i.prefixItems=c,l&&(i.items=l)):t.target===`openapi-3.0`?(i.items={anyOf:c},l&&i.items.anyOf.push(l),i.minItems=c.length,l||(i.maxItems=c.length)):(i.items=c,l&&(i.additionalItems=l));let{minimum:u,maximum:d}=e._zod.bag;typeof u==`number`&&(i.minItems=u),typeof d==`number`&&(i.maxItems=d)},xg=(e,t,n,r)=>{let i=n,a=e._zod.def;i.type=`object`;let o=a.keyType,s=o._zod.bag?.patterns;if(a.mode===`loose`&&s&&s.size>0){let e=Yh(a.valueType,t,{...r,path:[...r.path,`patternProperties`,`*`]});i.patternProperties={};for(let t of s)i.patternProperties[t.source]=e}else (t.target===`draft-07`||t.target===`draft-2020-12`)&&(i.propertyNames=Yh(a.keyType,t,{...r,path:[...r.path,`propertyNames`]})),i.additionalProperties=Yh(a.valueType,t,{...r,path:[...r.path,`additionalProperties`]});let c=o._zod.values;if(c){let e=[...c].filter(e=>typeof e==`string`||typeof e==`number`);e.length>0&&(i.required=e)}},Sg=(e,t,n,r)=>{let i=e._zod.def,a=Yh(i.innerType,t,r),o=t.seen.get(e);t.target===`openapi-3.0`?(o.ref=i.innerType,n.nullable=!0):n.anyOf=[a,{type:`null`}]},Cg=(e,t,n,r)=>{let i=e._zod.def;Yh(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},wg=(e,t,n,r)=>{let i=e._zod.def;Yh(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,n.default=JSON.parse(JSON.stringify(i.defaultValue))},Tg=(e,t,n,r)=>{let i=e._zod.def;Yh(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,t.io===`input`&&(n._prefault=JSON.parse(JSON.stringify(i.defaultValue)))},Eg=(e,t,n,r)=>{let i=e._zod.def;Yh(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType;let o;try{o=i.catchValue(void 0)}catch{throw Error(`Dynamic catch values are not supported in JSON Schema`)}n.default=o},Dg=(e,t,n,r)=>{let i=e._zod.def,a=t.io===`input`?i.in._zod.def.type===`transform`?i.out:i.in:i.out;Yh(a,t,r);let o=t.seen.get(e);o.ref=a},Og=(e,t,n,r)=>{let i=e._zod.def;Yh(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,n.readOnly=!0},kg=(e,t,n,r)=>{let i=e._zod.def;Yh(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},Ag=(e,t,n,r)=>{let i=e._zod.def;Yh(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},jg=(e,t,n,r)=>{let i=e._zod.innerType;Yh(i,t,r);let a=t.seen.get(e);a.ref=i},Mg=G(`ZodISODateTime`,(e,t)=>{Hp.init(e,t),r_.init(e,t)});function Ng(e){return ste(Mg,e)}const Pg=G(`ZodISODate`,(e,t)=>{Up.init(e,t),r_.init(e,t)});function Fg(e){return cte(Pg,e)}const Ig=G(`ZodISOTime`,(e,t)=>{Wp.init(e,t),r_.init(e,t)});function Lg(e){return lte(Ig,e)}const Rg=G(`ZodISODuration`,(e,t)=>{Gp.init(e,t),r_.init(e,t)});function zg(e){return ute(Rg,e)}const Bg=(e,t)=>{Hf.init(e,t),e.name=`ZodError`,Object.defineProperties(e,{format:{value:t=>hee(e,t)},flatten:{value:t=>mee(e,t)},addIssue:{value:t=>{e.issues.push(t),e.message=JSON.stringify(e.issues,pf,2)}},addIssues:{value:t=>{e.issues.push(...t),e.message=JSON.stringify(e.issues,pf,2)}},isEmpty:{get(){return e.issues.length===0}}})};G(`ZodError`,Bg);const Vg=G(`ZodError`,Bg,{Parent:Error}),Hg=Wf(Vg),Ug=Kf(Vg),Wg=Jf(Vg),Gg=Xf(Vg),Kg=_ee(Vg),qg=vee(Vg),Jg=yee(Vg),Yg=bee(Vg),Xg=xee(Vg),Zg=See(Vg),Qg=Cee(Vg),$g=Zf(Vg),e_=G(`ZodType`,(e,t)=>(zp.init(e,t),Object.assign(e[`~standard`],{jsonSchema:{input:$h(e,`input`),output:$h(e,`output`)}}),e.toJSONSchema=Ite(e,{}),e.def=t,e.type=t.type,Object.defineProperty(e,`_def`,{value:t}),e.check=(...n)=>e.clone(xf(t,{checks:[...t.checks??[],...n.map(e=>typeof e==`function`?{_zod:{check:e,def:{check:`custom`},onattach:[]}}:e)]}),{parent:!0}),e.with=e.check,e.clone=(t,n)=>Mf(e,t,n),e.brand=()=>e,e.register=((t,n)=>(t.add(e,n),e)),e.parse=(t,n)=>Hg(e,t,n,{callee:e.parse}),e.safeParse=(t,n)=>Wg(e,t,n),e.parseAsync=async(t,n)=>Ug(e,t,n,{callee:e.parseAsync}),e.safeParseAsync=async(t,n)=>Gg(e,t,n),e.spa=e.safeParseAsync,e.encode=(t,n)=>Kg(e,t,n),e.decode=(t,n)=>qg(e,t,n),e.encodeAsync=async(t,n)=>Jg(e,t,n),e.decodeAsync=async(t,n)=>Yg(e,t,n),e.safeEncode=(t,n)=>Xg(e,t,n),e.safeDecode=(t,n)=>Zg(e,t,n),e.safeEncodeAsync=async(t,n)=>Qg(e,t,n),e.safeDecodeAsync=async(t,n)=>$g(e,t,n),e.refine=(t,n)=>e.check(Tv(t,n)),e.superRefine=t=>e.check(Ev(t)),e.overwrite=t=>e.check(qh(t)),e.optional=()=>ov(e),e.exactOptional=()=>cv(e),e.nullable=()=>uv(e),e.nullish=()=>ov(uv(e)),e.nonoptional=t=>gv(e,t),e.array=()=>B_(e),e.or=t=>W_([e,t]),e.and=t=>J_(e,t),e.transform=t=>bv(e,iv(t)),e.default=t=>fv(e,t),e.prefault=t=>mv(e,t),e.catch=t=>vv(e,t),e.pipe=t=>bv(e,t),e.readonly=()=>Sv(e),e.describe=t=>{let n=e.clone();return vh.add(n,{description:t}),n},Object.defineProperty(e,`description`,{get(){return vh.get(e)?.description},configurable:!0}),e.meta=(...t)=>{if(t.length===0)return vh.get(e);let n=e.clone();return vh.add(n,t[0]),n},e.isOptional=()=>e.safeParse(void 0).success,e.isNullable=()=>e.safeParse(null).success,e.apply=t=>t(e),e)),t_=G(`_ZodString`,(e,t)=>{Bp.init(e,t),e_.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Rte(e,t,n,r);let n=e._zod.bag;e.format=n.format??null,e.minLength=n.minimum??null,e.maxLength=n.maximum??null,e.regex=(...t)=>e.check(yte(...t)),e.includes=(...t)=>e.check(Ste(...t)),e.startsWith=(...t)=>e.check(Cte(...t)),e.endsWith=(...t)=>e.check(wte(...t)),e.min=(...t)=>e.check(Gh(...t)),e.max=(...t)=>e.check(Wh(...t)),e.length=(...t)=>e.check(Kh(...t)),e.nonempty=(...t)=>e.check(Gh(1,...t)),e.lowercase=t=>e.check(bte(t)),e.uppercase=t=>e.check(xte(t)),e.trim=()=>e.check(Dte()),e.normalize=(...t)=>e.check(Ete(...t)),e.toLowerCase=()=>e.check(Ote()),e.toUpperCase=()=>e.check(kte()),e.slugify=()=>e.check(Ate())}),n_=G(`ZodString`,(e,t)=>{Bp.init(e,t),t_.init(e,t),e.email=t=>e.check(xh(i_,t)),e.url=t=>e.check(Dh(s_,t)),e.jwt=t=>e.check(ote(C_,t)),e.emoji=t=>e.check(Oh(l_,t)),e.guid=t=>e.check(Sh(a_,t)),e.uuid=t=>e.check(Ch(o_,t)),e.uuidv4=t=>e.check(wh(o_,t)),e.uuidv6=t=>e.check(Th(o_,t)),e.uuidv7=t=>e.check(Eh(o_,t)),e.nanoid=t=>e.check(kh(u_,t)),e.guid=t=>e.check(Sh(a_,t)),e.cuid=t=>e.check(Ah(d_,t)),e.cuid2=t=>e.check(jh(f_,t)),e.ulid=t=>e.check(Mh(p_,t)),e.base64=t=>e.check(rte(b_,t)),e.base64url=t=>e.check(ite(x_,t)),e.xid=t=>e.check(Nh(m_,t)),e.ksuid=t=>e.check(Ph(h_,t)),e.ipv4=t=>e.check(Fh(g_,t)),e.ipv6=t=>e.check(ete(__,t)),e.cidrv4=t=>e.check(tte(v_,t)),e.cidrv6=t=>e.check(nte(y_,t)),e.e164=t=>e.check(ate(S_,t)),e.datetime=t=>e.check(Ng(t)),e.date=t=>e.check(Fg(t)),e.time=t=>e.check(Lg(t)),e.duration=t=>e.check(zg(t))});function K(e){return yh(n_,e)}const r_=G(`ZodStringFormat`,(e,t)=>{Vp.init(e,t),t_.init(e,t)}),i_=G(`ZodEmail`,(e,t)=>{Gee.init(e,t),r_.init(e,t)}),a_=G(`ZodGUID`,(e,t)=>{Uee.init(e,t),r_.init(e,t)}),o_=G(`ZodUUID`,(e,t)=>{Wee.init(e,t),r_.init(e,t)}),s_=G(`ZodURL`,(e,t)=>{Kee.init(e,t),r_.init(e,t)});function c_(e){return Dh(s_,e)}const l_=G(`ZodEmoji`,(e,t)=>{qee.init(e,t),r_.init(e,t)}),u_=G(`ZodNanoID`,(e,t)=>{Jee.init(e,t),r_.init(e,t)}),d_=G(`ZodCUID`,(e,t)=>{Yee.init(e,t),r_.init(e,t)}),f_=G(`ZodCUID2`,(e,t)=>{Xee.init(e,t),r_.init(e,t)}),p_=G(`ZodULID`,(e,t)=>{Zee.init(e,t),r_.init(e,t)}),m_=G(`ZodXID`,(e,t)=>{Qee.init(e,t),r_.init(e,t)}),h_=G(`ZodKSUID`,(e,t)=>{$ee.init(e,t),r_.init(e,t)}),g_=G(`ZodIPv4`,(e,t)=>{Kp.init(e,t),r_.init(e,t)});G(`ZodMAC`,(e,t)=>{Jp.init(e,t),r_.init(e,t)});const __=G(`ZodIPv6`,(e,t)=>{qp.init(e,t),r_.init(e,t)}),v_=G(`ZodCIDRv4`,(e,t)=>{Yp.init(e,t),r_.init(e,t)}),y_=G(`ZodCIDRv6`,(e,t)=>{Xp.init(e,t),r_.init(e,t)}),b_=G(`ZodBase64`,(e,t)=>{Qp.init(e,t),r_.init(e,t)}),x_=G(`ZodBase64URL`,(e,t)=>{em.init(e,t),r_.init(e,t)}),S_=G(`ZodE164`,(e,t)=>{tm.init(e,t),r_.init(e,t)}),C_=G(`ZodJWT`,(e,t)=>{rm.init(e,t),r_.init(e,t)});G(`ZodCustomStringFormat`,(e,t)=>{im.init(e,t),r_.init(e,t)});const w_=G(`ZodNumber`,(e,t)=>{am.init(e,t),e_.init(e,t),e._zod.processJSONSchema=(t,n,r)=>zte(e,t,n,r),e.gt=(t,n)=>e.check(Rh(t,n)),e.gte=(t,n)=>e.check(zh(t,n)),e.min=(t,n)=>e.check(zh(t,n)),e.lt=(t,n)=>e.check(Ih(t,n)),e.lte=(t,n)=>e.check(Lh(t,n)),e.max=(t,n)=>e.check(Lh(t,n)),e.int=t=>e.check(D_(t)),e.safe=t=>e.check(D_(t)),e.positive=t=>e.check(Rh(0,t)),e.nonnegative=t=>e.check(zh(0,t)),e.negative=t=>e.check(Ih(0,t)),e.nonpositive=t=>e.check(Lh(0,t)),e.multipleOf=(t,n)=>e.check(Bh(t,n)),e.step=(t,n)=>e.check(Bh(t,n)),e.finite=()=>e;let n=e._zod.bag;e.minValue=Math.max(n.minimum??-1/0,n.exclusiveMinimum??-1/0)??null,e.maxValue=Math.min(n.maximum??1/0,n.exclusiveMaximum??1/0)??null,e.isInt=(n.format??``).includes(`int`)||Number.isSafeInteger(n.multipleOf??.5),e.isFinite=!0,e.format=n.format??null});function T_(e){return dte(w_,e)}const E_=G(`ZodNumberFormat`,(e,t)=>{om.init(e,t),w_.init(e,t)});function D_(e){return pte(E_,e)}const O_=G(`ZodBoolean`,(e,t)=>{sm.init(e,t),e_.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Bte(e,t,n,r)});function k_(e){return mte(O_,e)}const A_=G(`ZodBigInt`,(e,t)=>{cm.init(e,t),e_.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Vte(e,t,n,r),e.gte=(t,n)=>e.check(zh(t,n)),e.min=(t,n)=>e.check(zh(t,n)),e.gt=(t,n)=>e.check(Rh(t,n)),e.gte=(t,n)=>e.check(zh(t,n)),e.min=(t,n)=>e.check(zh(t,n)),e.lt=(t,n)=>e.check(Ih(t,n)),e.lte=(t,n)=>e.check(Lh(t,n)),e.max=(t,n)=>e.check(Lh(t,n)),e.positive=t=>e.check(Rh(BigInt(0),t)),e.negative=t=>e.check(Ih(BigInt(0),t)),e.nonpositive=t=>e.check(Lh(BigInt(0),t)),e.nonnegative=t=>e.check(zh(BigInt(0),t)),e.multipleOf=(t,n)=>e.check(Bh(t,n));let n=e._zod.bag;e.minValue=n.minimum??null,e.maxValue=n.maximum??null,e.format=n.format??null});G(`ZodBigIntFormat`,(e,t)=>{lm.init(e,t),A_.init(e,t)}),G(`ZodSymbol`,(e,t)=>{um.init(e,t),e_.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Hte(e,t,n,r)}),G(`ZodUndefined`,(e,t)=>{dm.init(e,t),e_.init(e,t),e._zod.processJSONSchema=(t,n,r)=>tg(e,t,n,r)});const j_=G(`ZodNull`,(e,t)=>{fm.init(e,t),e_.init(e,t),e._zod.processJSONSchema=(t,n,r)=>eg(e,t,n,r)});function M_(e){return hte(j_,e)}const N_=G(`ZodAny`,(e,t)=>{pm.init(e,t),e_.init(e,t),e._zod.processJSONSchema=(e,t,n)=>void 0});function P_(){return gte(N_)}const F_=G(`ZodUnknown`,(e,t)=>{mm.init(e,t),e_.init(e,t),e._zod.processJSONSchema=(e,t,n)=>void 0});function I_(){return _te(F_)}const L_=G(`ZodNever`,(e,t)=>{hm.init(e,t),e_.init(e,t),e._zod.processJSONSchema=(t,n,r)=>rg(e,t,n,r)});function R_(e){return vte(L_,e)}G(`ZodVoid`,(e,t)=>{gm.init(e,t),e_.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ng(e,t,n,r)}),G(`ZodDate`,(e,t)=>{_m.init(e,t),e_.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ig(e,t,n,r),e.min=(t,n)=>e.check(zh(t,n)),e.max=(t,n)=>e.check(Lh(t,n));let n=e._zod.bag;e.minDate=n.minimum?new Date(n.minimum):null,e.maxDate=n.maximum?new Date(n.maximum):null});const z_=G(`ZodArray`,(e,t)=>{ym.init(e,t),e_.init(e,t),e._zod.processJSONSchema=(t,n,r)=>gg(e,t,n,r),e.element=t.element,e.min=(t,n)=>e.check(Gh(t,n)),e.nonempty=t=>e.check(Gh(1,t)),e.max=(t,n)=>e.check(Wh(t,n)),e.length=(t,n)=>e.check(Kh(t,n)),e.unwrap=()=>e.element});function B_(e,t){return jte(z_,e,t)}const V_=G(`ZodObject`,(e,t)=>{wm.init(e,t),e_.init(e,t),e._zod.processJSONSchema=(t,n,r)=>_g(e,t,n,r),yf(e,`shape`,()=>t.shape),e.keyof=()=>ev(Object.keys(e._zod.def.shape)),e.catchall=t=>e.clone({...e._zod.def,catchall:t}),e.passthrough=()=>e.clone({...e._zod.def,catchall:I_()}),e.loose=()=>e.clone({...e._zod.def,catchall:I_()}),e.strict=()=>e.clone({...e._zod.def,catchall:R_()}),e.strip=()=>e.clone({...e._zod.def,catchall:void 0}),e.extend=t=>lee(e,t),e.safeExtend=t=>uee(e,t),e.merge=t=>dee(e,t),e.pick=t=>see(e,t),e.omit=t=>cee(e,t),e.partial=(...t)=>fee(av,e,t[0]),e.required=(...t)=>pee(hv,e,t[0])});function q(e,t){return new V_({type:`object`,shape:e??{},...Nf(t)})}function H_(e,t){return new V_({type:`object`,shape:e,catchall:I_(),...Nf(t)})}const U_=G(`ZodUnion`,(e,t)=>{Em.init(e,t),e_.init(e,t),e._zod.processJSONSchema=(t,n,r)=>vg(e,t,n,r),e.options=t.options});function W_(e,t){return new U_({type:`union`,options:e,...Nf(t)})}G(`ZodXor`,(e,t)=>{U_.init(e,t),Om.init(e,t),e._zod.processJSONSchema=(t,n,r)=>vg(e,t,n,r),e.options=t.options});const G_=G(`ZodDiscriminatedUnion`,(e,t)=>{U_.init(e,t),km.init(e,t)});function K_(e,t,n){return new G_({type:`union`,options:t,discriminator:e,...Nf(n)})}const q_=G(`ZodIntersection`,(e,t)=>{Am.init(e,t),e_.init(e,t),e._zod.processJSONSchema=(t,n,r)=>yg(e,t,n,r)});function J_(e,t){return new q_({type:`intersection`,left:e,right:t})}const Y_=G(`ZodTuple`,(e,t)=>{Nm.init(e,t),e_.init(e,t),e._zod.processJSONSchema=(t,n,r)=>bg(e,t,n,r),e.rest=t=>e.clone({...e._zod.def,rest:t})});function X_(e,t,n){let r=t instanceof zp;return new Y_({type:`tuple`,items:e,rest:r?t:null,...Nf(r?n:t)})}const Z_=G(`ZodRecord`,(e,t)=>{Fm.init(e,t),e_.init(e,t),e._zod.processJSONSchema=(t,n,r)=>xg(e,t,n,r),e.keyType=t.keyType,e.valueType=t.valueType});function Q_(e,t,n){return new Z_({type:`record`,keyType:e,valueType:t,...Nf(n)})}G(`ZodMap`,(e,t)=>{Im.init(e,t),e_.init(e,t),e._zod.processJSONSchema=(t,n,r)=>mg(e,t,n,r),e.keyType=t.keyType,e.valueType=t.valueType,e.min=(...t)=>e.check(Hh(...t)),e.nonempty=t=>e.check(Hh(1,t)),e.max=(...t)=>e.check(Vh(...t)),e.size=(...t)=>e.check(Uh(...t))}),G(`ZodSet`,(e,t)=>{Rm.init(e,t),e_.init(e,t),e._zod.processJSONSchema=(t,n,r)=>hg(e,t,n,r),e.min=(...t)=>e.check(Hh(...t)),e.nonempty=t=>e.check(Hh(1,t)),e.max=(...t)=>e.check(Vh(...t)),e.size=(...t)=>e.check(Uh(...t))});const $_=G(`ZodEnum`,(e,t)=>{Bm.init(e,t),e_.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ag(e,t,n,r),e.enum=t.entries,e.options=Object.values(t.entries);let n=new Set(Object.keys(t.entries));e.extract=(e,r)=>{let i={};for(let r of e)if(n.has(r))i[r]=t.entries[r];else throw Error(`Key ${r} not found in enum`);return new $_({...t,checks:[],...Nf(r),entries:i})},e.exclude=(e,r)=>{let i={...t.entries};for(let t of e)if(n.has(t))delete i[t];else throw Error(`Key ${t} not found in enum`);return new $_({...t,checks:[],...Nf(r),entries:i})}});function ev(e,t){return new $_({type:`enum`,entries:Array.isArray(e)?Object.fromEntries(e.map(e=>[e,e])):e,...Nf(t)})}const tv=G(`ZodLiteral`,(e,t)=>{Vm.init(e,t),e_.init(e,t),e._zod.processJSONSchema=(t,n,r)=>og(e,t,n,r),e.values=new Set(t.values),Object.defineProperty(e,`value`,{get(){if(t.values.length>1)throw Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})});function nv(e,t){return new tv({type:`literal`,values:Array.isArray(e)?e:[e],...Nf(t)})}G(`ZodFile`,(e,t)=>{Hm.init(e,t),e_.init(e,t),e._zod.processJSONSchema=(t,n,r)=>lg(e,t,n,r),e.min=(t,n)=>e.check(Hh(t,n)),e.max=(t,n)=>e.check(Vh(t,n)),e.mime=(t,n)=>e.check(Tte(Array.isArray(t)?t:[t],n))});const rv=G(`ZodTransform`,(e,t)=>{Um.init(e,t),e_.init(e,t),e._zod.processJSONSchema=(t,n,r)=>pg(e,t,n,r),e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new lf(e.constructor.name);n.addIssue=r=>{if(typeof r==`string`)n.issues.push(Bf(r,n.value,t));else{let t=r;t.fatal&&(t.continue=!1),t.code??=`custom`,t.input??=n.value,t.inst??=e,n.issues.push(Bf(t))}};let i=t.transform(n.value,n);return i instanceof Promise?i.then(e=>(n.value=e,n)):(n.value=i,n)}});function iv(e){return new rv({type:`transform`,transform:e})}const av=G(`ZodOptional`,(e,t)=>{Gm.init(e,t),e_.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ag(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function ov(e){return new av({type:`optional`,innerType:e})}const sv=G(`ZodExactOptional`,(e,t)=>{Km.init(e,t),e_.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ag(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function cv(e){return new sv({type:`optional`,innerType:e})}const lv=G(`ZodNullable`,(e,t)=>{qm.init(e,t),e_.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Sg(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function uv(e){return new lv({type:`nullable`,innerType:e})}const dv=G(`ZodDefault`,(e,t)=>{Jm.init(e,t),e_.init(e,t),e._zod.processJSONSchema=(t,n,r)=>wg(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function fv(e,t){return new dv({type:`default`,innerType:e,get defaultValue(){return typeof t==`function`?t():Of(t)}})}const pv=G(`ZodPrefault`,(e,t)=>{Xm.init(e,t),e_.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Tg(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function mv(e,t){return new pv({type:`prefault`,innerType:e,get defaultValue(){return typeof t==`function`?t():Of(t)}})}const hv=G(`ZodNonOptional`,(e,t)=>{Zm.init(e,t),e_.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Cg(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function gv(e,t){return new hv({type:`nonoptional`,innerType:e,...Nf(t)})}G(`ZodSuccess`,(e,t)=>{$m.init(e,t),e_.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ug(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});const _v=G(`ZodCatch`,(e,t)=>{eh.init(e,t),e_.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Eg(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function vv(e,t){return new _v({type:`catch`,innerType:e,catchValue:typeof t==`function`?t:()=>t})}G(`ZodNaN`,(e,t)=>{th.init(e,t),e_.init(e,t),e._zod.processJSONSchema=(t,n,r)=>sg(e,t,n,r)});const yv=G(`ZodPipe`,(e,t)=>{nh.init(e,t),e_.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Dg(e,t,n,r),e.in=t.in,e.out=t.out});function bv(e,t){return new yv({type:`pipe`,in:e,out:t})}G(`ZodCodec`,(e,t)=>{yv.init(e,t),ih.init(e,t)});const xv=G(`ZodReadonly`,(e,t)=>{sh.init(e,t),e_.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Og(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Sv(e){return new xv({type:`readonly`,innerType:e})}G(`ZodTemplateLiteral`,(e,t)=>{lh.init(e,t),e_.init(e,t),e._zod.processJSONSchema=(t,n,r)=>cg(e,t,n,r)}),G(`ZodLazy`,(e,t)=>{fh.init(e,t),e_.init(e,t),e._zod.processJSONSchema=(t,n,r)=>jg(e,t,n,r),e.unwrap=()=>e._zod.def.getter()}),G(`ZodPromise`,(e,t)=>{dh.init(e,t),e_.init(e,t),e._zod.processJSONSchema=(t,n,r)=>kg(e,t,n,r),e.unwrap=()=>e._zod.def.innerType}),G(`ZodFunction`,(e,t)=>{uh.init(e,t),e_.init(e,t),e._zod.processJSONSchema=(t,n,r)=>fg(e,t,n,r)});const Cv=G(`ZodCustom`,(e,t)=>{ph.init(e,t),e_.init(e,t),e._zod.processJSONSchema=(t,n,r)=>dg(e,t,n,r)});function wv(e,t){return Mte(Cv,e??(()=>!0),t)}function Tv(e,t={}){return Nte(Cv,e,t)}function Ev(e){return Pte(e)}function Dv(e,t){return bv(iv(e),t)}const Ov={invalid_type:`invalid_type`,too_big:`too_big`,too_small:`too_small`,invalid_format:`invalid_format`,not_multiple_of:`not_multiple_of`,unrecognized_keys:`unrecognized_keys`,invalid_union:`invalid_union`,invalid_key:`invalid_key`,invalid_element:`invalid_element`,invalid_value:`invalid_value`,custom:`custom`};var kv;(function(e){})(kv||={});function Av(e){return bh(n_,e)}function jv(e){return fte(w_,e)}const Mv={USER_MESSAGE:`user_message`,REJECTED:`rejected`,INTERRUPTED:`interrupted`},Nv={REJECTED:`rejected`};function Pv(e){if(e===`Tool was rejected by user`)return{rejected:!0};try{let t=JSON.parse(e);if(t.reason===Mv.USER_MESSAGE)return{rejected:!0,userNote:t.message};if(t.reason===Mv.REJECTED||t.reason===Mv.INTERRUPTED)return{rejected:!0};if(t.status===Nv.REJECTED)return{rejected:!0,userNote:t.userNote}}catch{}return{rejected:!1}}const Fv=`sibling_tool_failed`,Iv=JSON.stringify({type:Fv,message:`Not executed: a tool call in a preceding parallel batch failed`});function Lv(e){try{return JSON.parse(e)?.type===Fv}catch{return!1}}var Rv=class{concurrency(e,t){return!1}includeInApiDefinitions=!0;isEnabled(e){return!0}async prepare(e,t){return null}needsPermission(e,t,n){return!this.isReadonly}format(e,t){return typeof e==`string`?e:JSON.stringify(e)}formatForLLM(e,t){return this.format(e,t)}parse(e){let t=Pv(e);if(t.rejected)return{phase:`rejected`,toolType:this.name,data:{},summary:t.userNote?`Rejected \u00b7 "${t.userNote}"`:`Rejected`,...t.userNote!==void 0&&{userNote:t.userNote}};try{let t=JSON.parse(e),n=`success`;return t.status===`error`?n=`error`:t.status===`skipped`&&(n=`skipped`),{phase:n,toolType:t.type??this.name,data:t,summary:t.message??t.summary??`Completed`,...t.errorMessage!==void 0&&{errorMessage:t.errorMessage}}}catch{}return e.startsWith(`Error:`)?{phase:`error`,toolType:this.name,data:{},summary:e,errorMessage:e}:{phase:`success`,toolType:this.name,data:{},summary:`Completed`}}validateParams(e){return this.parameters.parse(e)}getToolDefinition(){let e=this.getParameterNames();return{name:this.name,description:this.description,arguments:e}}getParameterNames(){return Object.keys(this.parameters.shape)}};const zv=Symbol.for(`server-executed`);var Bv=class extends Rv{isReadonly=!0;async execute(e,t,n){return zv}format(e,t){return JSON.stringify({type:this.name,status:`server-executed`})}};rt([`codellm`,`agent`,`tools`,`subagent`]);var Vv=class e extends Bv{name=`subagent`;displayName=`Subagent`;description=`Switch to a different subagent for a task`;static parametersSchema=q({agent:K().describe(`The name of the subagent to switch to`),task:K().describe(`The task description for the subagent`)});parameters=e.parametersSchema;needsPermission(){return!1}format(e,t){return JSON.stringify({type:`subagent`,status:`success`,agent:t.agent,task:t.task})}parse(e){let t=Pv(e);if(t.rejected)return{phase:`rejected`,toolType:`subagent`,data:{},summary:t.userNote?`Rejected \u00b7 "${t.userNote}"`:`Rejected`,...t.userNote!==void 0&&{userNote:t.userNote}};try{let t=JSON.parse(e);return{phase:`success`,toolType:`subagent`,data:t,summary:`Delegated to ${t.agent??`explore`} agent`}}catch{}return{phase:`success`,toolType:`subagent`,data:{},summary:`Delegated`}}};rt([`codellm`,`agent`,`tools`,`todo-write`]);var Hv=class e extends Bv{name=`todo_write`;displayName=`TodoWrite`;description=`Create and manage a structured task list`;static parametersSchema=q({todos:Dv(e=>{if(e==null)return[];if(typeof e==`string`)try{let t=JSON.parse(e);return Array.isArray(t)?t:[]}catch{return[]}return Array.isArray(e)?e:[]},B_(q({content:K().describe(`The task content`),status:ev([`pending`,`in_progress`,`completed`,`cancelled`]).describe(`The status of the task`),id:K().optional().describe(`Optional task ID`)}))).describe(`Array of todo items`)});parameters=e.parametersSchema;needsPermission(){return!1}format(e,t){return`Updated`}parse(e){let t=Pv(e);if(t.rejected)return{phase:`rejected`,toolType:`todo_write`,data:{},summary:`Rejected`,...t.userNote!==void 0&&{userNote:t.userNote}};try{let t=JSON.parse(e);if(t.todos){let e=t.todos;return{phase:`success`,toolType:`todo_write`,data:t,summary:`${e.filter(e=>e.status===`pending`).length} pending, ${e.filter(e=>e.status===`in_progress`).length} in progress, ${e.filter(e=>e.status===`completed`).length} completed`}}}catch{}return{phase:`success`,toolType:`todo_write`,data:{},summary:`Updated`}}};function Uv(e){if(typeof e!=`string`)return e;let t=e.trim();return t?Number(t):NaN}function Wv(e){if(typeof e!=`string`)return e;let t=e.trim().toLowerCase();return[`true`,`1`,`yes`,`y`].includes(t)?!0:[`false`,`0`,`no`,`n`].includes(t)?!1:e}const Gv=Dv(Uv,T_()),Kv=Dv(Uv,T_().optional()),qv=Dv(Wv,k_()),Jv=Dv(Wv,k_().optional()),Yv=rt([`codellm`,`agent`,`tools`,`ask-user`]);var Xv=class e extends Rv{isReadonly=!0;name=`ask_user_question`;displayName=`AskUserQuestion`;description=`Ask the user questions during execution to gather preferences, clarify instructions, or get decisions on implementation choices`;static parametersSchema=q({questions:B_(q({question:K().describe(`The question to ask the user`),header:K().describe(`A header/title for the question`),options:B_(q({label:K().describe(`The option label`),description:K().describe(`A description of the option`)})).describe(`Array of options for the user to select from`),multiSelect:qv.describe(`Whether the user can select multiple options`)})).describe(`Array of questions to ask the user`),answers:Q_(K(),K()).optional().describe(`User-provided answers to the questions`)});parameters=e.parametersSchema;needsPermission(){return!0}async execute(e){return Yv.debug`Asking user ${e.questions.length} question(s)`,{answers:e.answers||{}}}format(e,t){return JSON.stringify({type:`ask_user_question`,status:`success`,answers:e.answers})}parse(e){let t=Pv(e);if(t.rejected)return{phase:`rejected`,toolType:`ask_user_question`,data:{},summary:`Cancelled`,...t.userNote!==void 0&&{userNote:t.userNote}};try{let t=JSON.parse(e),n=t.answers,r=n?Object.keys(n).length:0;return{phase:`success`,toolType:`ask_user_question`,data:t,summary:`Answered ${r} question${r===1?``:`s`}`}}catch{}return{phase:`success`,toolType:`ask_user_question`,data:{},summary:`Answered`}}};const Zv=rt([`codellm`,`agent`,`tools`,`plan-mode`]);var Qv=class e extends Rv{name=`enter_plan_mode`;displayName=`EnterPlanMode`;description=`Enter plan mode to create a plan before implementing changes`;static parametersSchema=q({});parameters=e.parametersSchema;isReadonly=!0;needsPermission(e,t,n){return!1}async execute(e,t){return Zv.info`Entering plan mode`,{success:!0}}format(e,t){return`Entered plan mode`}parse(e){let t=Pv(e);return t.rejected?{phase:`rejected`,toolType:`enter_plan_mode`,data:{},summary:`Rejected`,...t.userNote!==void 0&&{userNote:t.userNote}}:{phase:`success`,toolType:`enter_plan_mode`,data:{},summary:`Entered plan mode`}}};const $v=rt([`codellm`,`agent`,`tools`,`plan-mode`]);var ey=class e extends Rv{name=`exit_plan_mode`;displayName=`ExitPlanMode`;description=`Exit plan mode and return to normal agent operation`;static parametersSchema=q({planFilePath:K().describe(`Path to the plan file`)});parameters=e.parametersSchema;isReadonly=!0;async prepare(e,t){if(!e.planFilePath)return{error:`Plan not found`,skipPermission:!0};try{let n=await t.workspace.readRawFile(e.planFilePath);return n?{planContent:n}:{error:`Plan not found`,skipPermission:!0}}catch{return{error:`Plan not found`,skipPermission:!0}}}needsPermission(e,t,n){return!n?.skipPermission}async execute(e,t,n){if(n?.error)throw Error(n.error);return $v.info`Exiting plan mode with plan: ${e.planFilePath}`,{planFilePath:e.planFilePath}}format(e,t){return JSON.stringify({type:`exit_plan_mode`,status:`success`,...e.planFilePath&&{planFilePath:e.planFilePath}})}parse(e){let t=Pv(e);if(t.rejected)return{phase:`rejected`,toolType:`exit_plan_mode`,data:{},summary:`Rejected`,...t.userNote!==void 0&&{userNote:t.userNote}};try{return{phase:`success`,toolType:`exit_plan_mode`,data:JSON.parse(e),summary:`Plan approved`}}catch{}return e.includes(`implement the plan`),{phase:`success`,toolType:`exit_plan_mode`,data:{},summary:`Plan approved`}}},ty;(function(e){e.GeneralPurpose=`GENERAL_PURPOSE`,e.Explore=`EXPLORE`,e.Plan=`PLAN`})(ty||={});const ny={[ty.GeneralPurpose]:{name:ty.GeneralPurpose,displayName:`Agent`,description:`General-purpose agent for researching complex questions, searching for code, and executing multi-step tasks`,allowedTools:[`*`],defaultModel:`CLAUDE_V4_5_SONNET`},[ty.Explore]:{name:ty.Explore,displayName:`Explore`,description:`Fast agent specialized for exploring codebases. Use for finding files by patterns, searching code for keywords, or answering questions about the codebase.`,allowedTools:[`read`,`glob`,`grep`,`bash`,`web_fetch`,`web_search`],defaultModel:`CLAUDE_V4_5_HAIKU`},[ty.Plan]:{name:ty.Plan,displayName:`Plan`,description:`Fast agent for creating implementation plans. Explores codebase to understand architecture before planning.`,allowedTools:[`read`,`glob`,`grep`,`bash`,`web_fetch`,`web_search`],defaultModel:`CLAUDE_V4_5_HAIKU`}},ry=new Set(Object.values(ty));function iy(e){return ry.has(e)}function ay(e){if(iy(e))return e}function oy(e){return ny[e]}function sy(){return Object.values(ty)}function cy(e){let t=ay(e);return t?oy(t).displayName:e}function ly(e,t){let n=ay(e);if(!n)return!1;let r=oy(n);return r.allowedTools.includes(`*`)?!0:r.allowedTools.includes(t)}const uy=/[ \t()[\]{};|*?$`'"#&<>!~]/;function dy(e){return e.replace(RegExp(`\\\\([${uy.source.slice(1,-1)}])`,`g`),`$1`)}const fy=N.homedir();function py(e){return e===`~`?fy:e.startsWith(`~/`)?E.join(fy,e.slice(2)):e}function my(e,t){return E.isAbsolute(e)?(E.relative(t,e)||e).split(E.sep).join(`/`):e.startsWith(`./`)||e.startsWith(`.\\`)?e.slice(2):e}function hy(e){let t=E.resolve(e);try{return v(t)}catch{try{let e=E.dirname(t),n=E.basename(t);return E.join(v(e),n)}catch{return t}}}function gy(e){return!!e&&!e.startsWith(`..`)&&!E.isAbsolute(e)}function _y(e,t){let n=E.resolve(e),r=E.resolve(t);if(n===r||gy(E.relative(r,n)))return!0;let i=hy(n),a=hy(r);return i===a?!0:gy(E.relative(a,i))}function vy(e,t){let n=E.resolve(e),r=E.resolve(t),i=E.relative(r,n);if(gy(i))return{success:!0,relativePath:i};let a=hy(n),o=hy(r);return i=E.relative(o,a),gy(i)?{success:!0,relativePath:i}:{success:!1,reason:`outside_workspace`}}async function yy(e){return new Promise(t=>setTimeout(t,e))}const by=rt([`codellm`,`agent`,`loop`]);function xy(e){if(!e)return null;if(typeof e==`string`)return e;if(typeof e==`object`&&e){let t=e;if(t.text)return t.text;if(t.segment)return xy(t.segment)}return null}function Sy(e){return Math.min((e+1)*2e3,1e4)}function Cy(e){return 2**(e+1)*1e3}function*wy(e,t,n){if(e.error){let t=e.error,r=typeof t==`string`?t:JSON.stringify(t);r.includes(`Credit limit`)||r.includes(`no_usage_points`)||r.includes(`compute_point_budgeting`)||r.includes(`limit_exceeded`)||r.includes(`exhausted`)||r.includes(`purchase more credits`)?yield{__error:new nf({...n.pendingCreditLimitSegment??void 0,message:r})}:jl(r)?yield{__error:new Ol}:yield{__error:new tf(r)};return}if(e.type===`no_usage_points`||e.type===`compute_point_budgeting`||e.type===`limit_exceeded`){n.pendingCreditLimitSegment=e;return}if(e.type===`code_llm_credits`){yield{type:`credits`,creditsUsed:e.creditsUsed};return}if(e.type===`collapsible_component`&&e.isThoughts===!0){let t=e.title||`Thinking`,n=xy(e.segment)??``;n&&(yield{type:`thinking_delta`,content:n,title:t}),e.isSpinny===!1&&(yield{type:`thinking_complete`});return}if(e.type===`code_llm_notification`){let t=e.message||xy(e.segment)||`Notification`;yield{...e,type:`notification`,message:t,severity:e.severity??`info`};return}if(e.type===`code_llm_agent_tool_call_start`){yield{type:`tool_call_start`,toolCallId:e.toolCallId,toolName:e.toolName};return}if(e.type===`code_llm_agent_tool_call_delta`){yield{type:`tool_call_delta`,toolCallId:e.toolCallId,argumentsDelta:e.argumentsDelta};return}if(e.type===`code_llm_agent_tool_call_stop`){yield{type:`tool_call_stop`,toolCallId:e.toolCallId,toolName:e.toolName,arguments:e.arguments};let n=e.toolUseRequest;if(n){let e=n;if(e.name===`edit`){let t=e.input;(`startLineOneIndexed`in t||`endLineOneIndexed`in t)&&(e={...e,input:{...t,startLine:t.startLineOneIndexed??t.startLine,endLine:t.endLineOneIndexed??t.endLine}})}t.push(e),yield{type:`tool_requested`,tool:e}}return}if(e.toolUseRequest){let n=(Array.isArray(e.toolUseRequest)?e.toolUseRequest:[e.toolUseRequest]).map(e=>{if(e.name===`edit`){let t=e.input;if(`startLineOneIndexed`in t||`endLineOneIndexed`in t)return{...e,input:{...t,startLine:t.startLineOneIndexed??t.startLine,endLine:t.endLineOneIndexed??t.endLine}}}return e}),r=new Set(t.map(e=>e.id)),i=n.filter(e=>!r.has(e.id));t.push(...i);for(let e of i)yield{type:`tool_requested`,tool:e};return}if(e.segment){let t=xy(e.segment);t&&(yield{type:`text_delta`,content:t})}}async function*Ty(e,t){let n=t?.generateRequestId?.()??crypto.randomUUID(),r=!1;by.debug(`Starting agent loop (conversationId={conversationId}, model={model})`,{conversationId:e.conversationId,model:e.model});for(let t=0;t<8;t++){xl(`turn started`,`agent`);let i=n,a=!1;if(t>0){by.debug(`Retry attempt {attempt}: checking for pending request ID`,{attempt:t});try{let t=await e.apiClient.getPendingRequestIdForConversation(e.conversationId);t?.success&&t.result?.requestId&&(i=t.result.requestId,a=!0)}catch{}}let o=[],s={pendingCreditLimitSegment:null},c=!1;try{let t=e.apiClient.streamAgentMessage({deploymentConversationId:e.conversationId,message:e.message,supportedTools:e.supportedTools,supportedSubAgents:e.supportedSubAgents,mcpTools:e.isPrintMode?[]:e.mcpTools??[],workspacePath:e.workspacePath,...e.swapFolder&&{swapFolder:e.swapFolder},llmName:e.model,requestId:i,docInfos:e.uploadedDocs?Array.from(e.uploadedDocs):[],toolUseResult:e.toolResult,supportsV2:!0,supportsThoughtStreaming:e.supportsThoughtStreaming??!0,supportsParallelToolUse:!0,isPrintMode:e.isPrintMode??!1,...e.subagent&&{subagent:e.subagent},agentMode:e.agentMode,currentFile:e.currentFile,selectionStartLine:e.selectionStartLine,selectionEndLine:e.selectionEndLine,gitBranch:e.gitBranch,gitMain:e.gitMain,gitStatus:e.gitStatus,gitCommits:e.gitCommits,diagnosticIssues:e.diagnosticIssues,availableSkills:e.availableSkills,activeSkills:e.activeSkills,client:e.client,setFolder:e.setFolder,reconnect:a,signal:e.signal});for await(let n of t){if(e.signal?.aborted)break;for(let e of wy(n,o,s)){if(`__error`in e)throw e.__error;yield e}c=!0}if(e.signal?.aborted){e.apiClient.stopResponseSSE(i).catch(()=>{}),yield{type:`turn_complete_with_tools`,toolCalls:o};return}r&&=(yield{type:`network_status`,online:!0},!1),yield{type:`turn_complete_with_tools`,toolCalls:o},by.debug(`Agent loop completed with {count} tool calls`,{count:o.length});return}catch(n){let i=n instanceof Error?n:Error(String(n));if(i instanceof Ol){if(c&&t<4&&!e.signal?.aborted){let e=Cy(t);by.warn(`Auth error mid-stream (attempt={attempt}, delay={delayMs}ms) — retrying (server may have re-validated against a stale replica)`,{attempt:t+1,delayMs:e}),yl(`Mid-stream auth error, retrying`,`warning`,{context:`agent-loop`,attempt:t+1}),yield{type:`retry`,attempt:t+1,maxAttempts:5,delayMs:e,isNetworkError:!1},await yy(e);continue}throw by.warn(`Auth expired, aborting loop`),i}if(i instanceof nf)throw by.warn(`Credit limit reached, aborting loop`),yl(`Credit limit reached`,`warning`,{context:`agent-loop`}),i;let a=Ml(i),o=a?8:5;if(t<o-1&&!e.signal?.aborted){let e=a?Sy(t):Cy(t);by.warn(`Retrying after error (attempt={attempt}, network={isNetErr}, delay={delayMs}ms): {error}`,{attempt:t+1,isNetErr:a,delayMs:e,error:i.message}),a&&!r&&(r=!0,yield{type:`network_status`,online:!1}),yield{type:`retry`,attempt:t+1,maxAttempts:o,delayMs:e,isNetworkError:a},await yy(e);continue}throw by.error(`All retry attempts exhausted: {error}`,{error:i.message}),vl(i,{context:`agent-loop-retry-exhausted`}),Ml(i)?i instanceof kl?i:new kl(i.message,i):i}}}const Ey=rt([`codellm`,`agent`,`runner`]);var Dy=class{queue=[];resolvers=[];closed=!1;push(e){this.closed||(this.resolvers.length>0?this.resolvers.shift()(e):this.queue.push(e))}async next(){return this.queue.length>0?this.queue.shift():this.closed?null:new Promise(e=>{this.resolvers.push(e)})}close(){this.closed=!0;for(let e of this.resolvers)e(null);this.resolvers=[]}drain(){let e=[...this.queue];return this.queue=[],e}};function Oy(e){return e.toUpperCase().includes(`CLAUDE`)}async function*ky(e,t,n){let r=e.maxTurns??2**53-1,i=t,a,o=0,s=0,c=[],l=e.agentMode;Ey.info(`Starting agent conversation (model={model}, maxTurns={maxTurns})`,{model:e.model,maxTurns:r});try{for(;o<r;){if(n?.aborted)return Ey.info(`Conversation aborted after {numTurns} turns`,{numTurns:o}),{content:c.join(``),numTurns:o,toolCallsExecuted:s,success:!1,error:Error(`Execution cancelled`)};o++;let t={...e,swapFolder:a===void 0?e.swapFolder:void 0,setFolder:a===void 0?e.setFolder:void 0,agentMode:l,message:i,...a!==void 0&&{toolResult:a},...n!==void 0&&{signal:n}},r=[],u=new Map,d=new Map,f=new Map,p=[],m=new Dy,h=new AbortController,g=()=>h.abort(`interrupted`);n&&(n.aborted?h.abort(`interrupted`):n.addEventListener(`abort`,g,{once:!0}));let _=async(t,n,r)=>(await e.executeTools([t],n,r))[0],v=e.getConcurrency??(()=>!1),y=e=>{let t=_(e,h.signal,e=>m.push(e)).then(t=>{d.set(e.id,t);for(let[t,n]of f)if(n===e.id){f.delete(t);break}return t}).catch(e=>{throw h.abort(`sibling_tool_failed`),e});u.set(e.id,t)},b=e=>{let t=v(e);typeof t==`string`&&f.has(t)?p.push(e):(typeof t==`string`&&f.set(t,e.id),y(e))},x=!1;for await(let e of Ty(t)){for(let e of m.drain())e.type===`mode_changed`&&(l=e.mode),yield e;if(e.type===`turn_complete_with_tools`){r=e.toolCalls,x=!0;continue}if(e.type===`text_delta`&&c.push(e.content),e.type===`tool_requested`){yield e,b(e.tool);continue}yield e}for(let e of m.drain())e.type===`mode_changed`&&(l=e.mode),yield e;if(x||Ey.warn(`Agent loop exited without turn_complete_with_tools (collected {count} tool calls)`,{count:r.length}),r.length===0){Ey.debug(`Turn {numTurns} complete with no tool calls`,{numTurns:o}),n?.removeEventListener(`abort`,g),yield{type:`turn_complete`};break}for(let e of p){let t=v(e);if(typeof t==`string`&&f.has(t)){let e=f.get(t),n=u.get(e);if(n)try{await n}catch{}}h.signal.aborted||b(e)}let S=r.filter(e=>!u.has(e.id));if(S.length>0)if(u.size===0){let t,n=e.executeTools(r,h.signal,e=>m.push(e)).then(e=>{t=e;for(let t=0;t<e.length;t++){let n=r[t];n&&d.set(n.id,e[t])}return m.close(),e}),i=new Set;for(;t===void 0;){let e=await Promise.race([m.next(),n.then(()=>null)]);if(e!==null)e.type===`mode_changed`&&(l=e.mode),e.type===`tool_execution_complete`&&i.add(e.tool.id),yield e;else if(t!==void 0)break}t||=await n;for(let e of m.drain())e.type===`mode_changed`&&(l=e.mode),e.type===`tool_execution_complete`&&i.add(e.tool.id),yield e;for(let e=0;e<t.length;e++){let n=r[e],a=t[e];n&&a&&!i.has(n.id)&&(yield{type:`tool_execution_complete`,tool:n,result:a})}}else for(let e of S)h.signal.aborted||y(e);if(u.size>0){let e=Promise.allSettled(u.values()).then(()=>{m.close()}),t=new Set,n=await m.next();for(;n!==null;)n.type===`mode_changed`&&(l=n.mode),n.type===`tool_execution_complete`&&t.add(n.tool.id),yield n,n=await m.next();await e;for(let e of r){let n=d.get(e.id);n&&!t.has(e.id)&&(yield{type:`tool_execution_complete`,tool:e,result:n})}}s+=r.length;let C=r.map(e=>d.get(e.id)??{id:e.id,content:`Error: tool execution did not complete`});n?.removeEventListener(`abort`,g);for(let t of e.drainEvents?.()??[])t.type===`mode_changed`&&(l=t.mode),yield t;let w=new Set([`task`]),T=(e,t)=>!(!e.rejected||w.has(r[t]?.name??``)),E=C.some((e,t)=>{if(!T(e,t))return!1;try{return JSON.parse(e.content).reason===Mv.REJECTED}catch{return!1}}),D=C.some((e,t)=>{if(!T(e,t))return!1;try{return JSON.parse(e.content).reason===Mv.INTERRUPTED}catch{return!1}}),O=C.some(e=>{if(!e.rejected)return!1;try{return JSON.parse(e.content).reason===Mv.USER_MESSAGE}catch{return!1}});if((E||D)&&!O){yield{type:`turn_complete`};break}let k=C.map(({parsedResult:e,...t})=>t);a=k.length===1?k[0]:k;let A=r.some(e=>e.name===`exit_plan_mode`)&&C.some(e=>{if(e.rejected)return!1;try{return JSON.parse(e.content).type===`exit_plan_mode`}catch{return!1}}),j=`I want you to start implementing the plan now as you have outlined in your plan.`,M=e.getQueuedMessage?.();if(M)if(Oy(e.model))i=A?`${j} ${M}`:M,e.clearQueuedMessage?.(),e.isQueuedMessageHidden?.()||(yield{type:`user_message_dequeued`,content:M});else{yield{type:`turn_complete`};break}else i=A?j:``;yield{type:`turn_complete`}}if(o>=r){Ey.warn(`Maximum turns ({maxTurns}) exceeded`,{maxTurns:r});let e=Error(`Maximum turns (${r}) exceeded`);return yield{type:`error`,error:e},{content:c.join(``),numTurns:o,toolCallsExecuted:s,success:!1,error:e}}return Ey.info(`Conversation completed (turns={numTurns}, toolCalls={toolCallsExecuted})`,{numTurns:o,toolCallsExecuted:s}),{content:c.join(``),numTurns:o,toolCallsExecuted:s,success:!0}}catch(e){let t=e instanceof Error?e:Error(String(e));return vl(t,{context:`agent-runner`}),Ey.error(`Conversation failed after {numTurns} turns: {error}`,{numTurns:o,toolCallsExecuted:s,error:t}),yield{type:`error`,error:t},{content:c.join(``),numTurns:o,toolCallsExecuted:s,success:!1,error:t}}}const Ay=rt([`codellm`,`agent`,`subagent`]);function jy(e,t){let n=oy(t);return!n||n.allowedTools.includes(`*`)?e:e.filter(e=>ly(t,e.name))}function My(e,t,n,r,i){let a=n.get(e.name)?.displayName??e.name;if(!n.isBuiltinRequest(e))return{type:`generic`,tool:e,displayName:a,toolName:a,inputSummary:JSON.stringify(e.input??{}).slice(0,200)};switch(e.name){case`read`:{let n=t._prepareResult;if(n?.resolvedPath){let t=hy(n.resolvedPath);return{type:`read_outside_directory`,tool:e,displayName:a,filePath:t,resolvedPath:t,deducedDirectory:E.dirname(t)}}return{type:`generic`,tool:e,displayName:a,toolName:a,inputSummary:JSON.stringify(e.input??{}).slice(0,200)}}case`edit`:{let n=t._prepareResult;if(n?.outsideWorkspace){let t=hy(n.resolvedPath??e.input.filePath??``);return{type:`edit_outside_directory`,tool:e,displayName:a,filePath:t,resolvedPath:t,deducedDirectory:E.dirname(t)}}return{type:`edit_file`,tool:e,displayName:a,filePath:e.input.filePath??``,originalContent:n?.currentContent??``,newContent:n?.newContent??``}}case`write`:{let n=t._prepareResult;if(n?.outsideWorkspace){let t=hy(n.resolvedPath??e.input.filePath??``);return{type:`write_outside_directory`,tool:e,displayName:a,filePath:t,resolvedPath:t,deducedDirectory:E.dirname(t),isNewFile:!n?.fileExists}}return{type:`write_file`,tool:e,displayName:a,filePath:e.input.filePath??``,originalContent:n?.currentContent??``,content:e.input.content??``,isNewFile:!n?.fileExists}}case`bash`:return{type:`run_terminal`,tool:e,displayName:a,command:e.input.command??``,cwd:r,background:!!(e.input.runInBackground??!1),unmatchedPatterns:i?.getUnmatchedBashSegments(e.input.command??``)??[]};case`notebook_edit`:{let n=t._prepareResult;if(n?.outsideWorkspace){let t=hy(n.resolvedPath??e.input.notebookPath??``);return{type:`notebook_edit_outside_directory`,tool:e,displayName:a,filePath:t,resolvedPath:t,deducedDirectory:E.dirname(t)}}let r=n?.notebook,i=e.input.cellId,o=``;if(i&&r?.cells){let e=r.cells.find(e=>e.id===i||e.metadata?.id===i);e&&(o=Array.isArray(e.source)?e.source.join(``):String(e.source??``))}return{type:`notebook_edit`,tool:e,displayName:a,notebookPath:e.input.notebookPath??``,cellId:i,editMode:e.input.editMode??`replace`,cellType:e.input.cellType,originalContent:o,newContent:e.input.newSource??``}}case`ask_user_question`:return{type:`ask_user_question`,tool:e,displayName:a,questions:Array.isArray(e.input.questions)?e.input.questions:[]};case`exit_plan_mode`:{let n=t._prepareResult;return{type:`exit_plan_mode`,tool:e,displayName:a,planFilePath:e.input.planFilePath??``,planContent:n?.planContent??``}}default:return{type:`generic`,tool:e,displayName:a,toolName:a,inputSummary:JSON.stringify(e.input??{}).slice(0,200)}}}async function Ny(e){let{prompt:t,subagentType:n,model:r,resume:i,parentContext:a,onProgress:o,signal:s}=e;Ay.info(`Starting subagent (type={subagentType}, model={model})`,{subagentType:n,model:r??`default`});let c=oy(n);if(!c)return Ay.error(`Unknown subagent type: {subagentType}`,{subagentType:n}),{success:!1,output:``,toolsExecuted:[],toolCalls:[],numTurns:0,error:`Unknown subagent type: ${n}`};let l=Mw(),u=jy(l.getApiToolDefinitions(),n),d=r??c.defaultModel??`CLAUDE_V4_5_SONNET`,f;if(i&&c.supportsResume)f=i;else try{let e=await a.apiClient.createCodellmDeploymentConversation(`CODE_LLM_NON_INTERACTIVE`,a.clientType);if(!e?.result?.deploymentConversationId)return{success:!1,output:``,toolsExecuted:[],toolCalls:[],numTurns:0,error:`Failed to create subagent conversation: no conversation ID returned`};f=e.result.deploymentConversationId}catch(e){return{success:!1,output:``,toolsExecuted:[],toolCalls:[],numTurns:0,error:`Failed to create subagent conversation: ${e instanceof Error?e.message:String(e)}`}}let p=[],m=[],h=[],g=a.permissionProvider&&a.rulesEngine&&a.getAgentMode,_=()=>a.getAgentMode?.()??$d.Yolo,v=c?.name,y={apiClient:a.apiClient,conversationId:f,model:d,workspacePath:a.workspacePath,supportedTools:u,mcpTools:[],uploadedDocs:a.uploadedDocs,isPrintMode:!g,...v&&{subagent:v},supportsThoughtStreaming:!0,agentMode:_(),executeTools:async(e,t,n)=>{let r=[];for(let i of e){if(t?.aborted||s?.aborted)break;m.push(i.name);let e={name:i.name,input:i.input??{}};o?.({type:`tool_requested`,content:`${i.name}`,toolName:i.name,toolInput:e.input,toolId:i.id}),n?.({type:`tool_execution_start`,tool:i});let c=_(),u={...a,toolCallId:i.id,conversationId:f,agentMode:c,status:`executing`};try{let d=l.createToolInstance(i.name,i.input??{},u);await d.prepare();let f=c===$d.Yolo&&i.name!==`ask_user_question`;if(g&&!f&&d.needsPermission()){let c=l.get(i.name)?.displayName??i.name,f=Gw(i),p=a.rulesEngine.evaluate(c,f);if(p===`deny`){r.push({id:i.id,content:JSON.stringify({reason:Mv.REJECTED}),rejected:!0}),e.result=`denied by rule`,h.push(e),o?.({type:`tool_complete`,content:`${i.name}`,toolName:i.name,toolId:i.id});continue}if(p!==`allow`){let c=My(i,d,l,a.workspacePath,a.rulesEngine);if(a.permissionProvider.needsPermission(c)){n?.({type:`status_changed`,status:ef.WaitingForToolPermission}),a.emitEvent?.({type:`status_changed`,status:ef.WaitingForToolPermission});let l;try{let e=a.permissionProvider.requestPermission(c),n=t||s;if(n){let t,r=new Promise((e,r)=>{n.aborted?r(Error(`interrupted`)):(t=()=>r(Error(`interrupted`)),n.addEventListener(`abort`,t,{once:!0}))});try{l=await Promise.race([e,r])}finally{t&&n.removeEventListener(`abort`,t)}}else l=await e}catch{r.push({id:i.id,content:JSON.stringify({reason:Mv.INTERRUPTED}),rejected:!0}),e.result=`interrupted`,h.push(e),o?.({type:`tool_complete`,content:`${i.name}`,toolName:i.name,toolId:i.id});continue}if(n?.({type:`status_changed`,status:ef.ExecutingTool}),a.emitEvent?.({type:`status_changed`,status:ef.ExecutingTool}),l===`reject`){r.push({id:i.id,content:JSON.stringify({reason:Mv.REJECTED}),rejected:!0}),e.result=`rejected`,h.push(e),o?.({type:`tool_complete`,content:`${i.name}`,toolName:i.name,toolId:i.id});continue}if(typeof l==`object`&&l.type===`reject_with_message`){r.push({id:i.id,content:JSON.stringify({reason:Mv.USER_MESSAGE,message:l.message}),rejected:!0}),e.result=`rejected`,h.push(e),o?.({type:`tool_complete`,content:`${i.name}`,toolName:i.name,toolId:i.id});continue}if(l===`allowAlways`||l===`allowYolo`||l===`accept`){if(l===`allowAlways`&&(c.type===`read_outside_directory`||c.type===`write_outside_directory`||c.type===`edit_outside_directory`||c.type===`notebook_edit_outside_directory`)&&`deducedDirectory`in c){let e=a.allowEditingPaths??[],t=c.deducedDirectory;e.includes(t)||e.push(t)}else if(i.name===`exit_plan_mode`){let e=l===`allowYolo`?$d.Yolo:l===`allowAlways`?$d.AcceptEdits:$d.Normal;a.setAgentMode?.(e),u.agentMode=e,n?.({type:`mode_changed`,mode:e})}else if(l===`allowAlways`){let e=of(c.type);a.setAgentMode?.(e),u.agentMode=e,n?.({type:`mode_changed`,mode:e})}}if(typeof l==`object`&&l.type===`accept_with_message`){r.push({id:i.id,content:JSON.stringify({reason:Mv.USER_MESSAGE,message:l.message}),rejected:!0}),e.result=`accepted with message`,h.push(e),o?.({type:`tool_complete`,content:`${i.name}`,toolName:i.name,toolId:i.id});continue}if(typeof l==`object`&&l.type===`question_answers`&&d.mergeParams({answers:l.answers}),typeof l==`object`&&l.type===`allow_always_with_rule`&&a.rulesEngine.addAllowRule(l.rule),typeof l==`object`&&l.type===`allow_always_with_rules`)for(let e of l.rules)a.rulesEngine.addAllowRule(e)}}}i.name===`enter_plan_mode`&&(a.setAgentMode?.($d.PlanMode),u.agentMode=$d.PlanMode,n?.({type:`mode_changed`,mode:$d.PlanMode})),i.name===`exit_plan_mode`&&f&&(a.setAgentMode?.($d.Normal),u.agentMode=$d.Normal,n?.({type:`mode_changed`,mode:$d.Normal})),await d.execute();let p=d.formatResultForLLM(),m=d.formatResult(),_=typeof p==`string`?p:JSON.stringify(p),v=l.parse(i.name,m);r.push({id:i.id,content:_,parsedResult:v}),e.result=_}catch(t){let n=t instanceof Error?t.message:String(t);r.push({id:i.id,content:`Error: ${n}`}),e.result=`Error: ${n}`}h.push(e),o?.({type:`tool_complete`,content:`${i.name}`,toolName:i.name,toolId:i.id})}for(let t of e)r.some(e=>e.id===t.id)||r.push({id:t.id,content:JSON.stringify({reason:Mv.INTERRUPTED}),rejected:!0});return r}};try{o?.({type:`status`,content:`Starting ${n} agent...`});let e=ky(y,t,s),r=await e.next();for(;!r.done;){let t=r.value;switch(t.type){case`text_delta`:p.push(t.content),o?.({type:`text`,content:t.content});break;case`thinking_delta`:o?.({type:`thinking`,content:t.content});break;case`tool_requested`:case`turn_complete`:break;case`tool_execution_complete`:p.length=0;break;case`error`:return{success:!1,output:p.join(``),toolsExecuted:m,toolCalls:h,numTurns:0,error:t.error?.message??`Unknown error`};case`mode_changed`:a.emitEvent?.(t);break;case`status_changed`:case`notification`:break}r=await e.next()}let i=r.value;return Ay.info(`Subagent completed (type={subagentType}, turns={numTurns}, tools={toolCount})`,{subagentType:n,numTurns:i.numTurns,toolCount:m.length}),{success:i.success,output:p.join(``),toolsExecuted:m,toolCalls:h,numTurns:i.numTurns,...i.error&&{error:i.error.message}}}catch(e){let t=e instanceof Error?e.message:String(e);return vl(e instanceof Error?e:Error(t),{context:`subagent-runner`}),Ay.error(`Subagent failed (type={subagentType}): {error}`,{subagentType:n,error:t}),{success:!1,output:p.join(``),toolsExecuted:m,toolCalls:h,numTurns:0,error:t}}}const Py=rt([`codellm`,`agent`,`tools`,`task`]);var Fy=class e extends Rv{name=`task`;displayName=`Task`;description=`Launch a new agent to handle complex, multi-step tasks autonomously.
|
|
51
51
|
|
|
52
52
|
The Task tool launches specialized agents (subprocesses) that autonomously handle complex tasks. Each agent type has specific capabilities and tools available to it.
|
|
53
53
|
|
|
@@ -73324,7 +73324,7 @@ No matching component was found for:
|
|
|
73324
73324
|
`).map(e=>_z(e,i)).join(`
|
|
73325
73325
|
`):t===`truncate-start`&&(r=r.split(`
|
|
73326
73326
|
`).map(e=>gz(e,i)).join(`
|
|
73327
|
-
`))}}r=mB(e,r),e.renderCache={lines:[r],width:n,height:0,left:l,top:u},t.write(l,u,r,d)}else e.renderCache=void 0;e.renderDirty=!1;return}let f=!1;if(e.nodeName===`jar-view`){e.style.backgroundColor&&hB(l,u,e,t),e.style.borderStyle&&cB(l,u,e,t);let n=e.style.overflowX===`hidden`||e.style.overflow===`hidden`,r=e.style.overflowY===`hidden`||e.style.overflow===`hidden`;if(n||r){let i=n?l+fB(e.style,`Left`):void 0,a=n?l+c.getComputedWidth()-fB(e.style,`Right`):void 0,o=r?u+fB(e.style,`Top`):void 0,s=r?u+c.getComputedHeight()-fB(e.style,`Bottom`):void 0;t.clip({x1:i,x2:a,y1:o,y2:s}),f=!0}}if(e.nodeName===`jar-root`||e.nodeName===`jar-view`){let n=f?u+fB(e.style,`Top`):o,r=f?u+c.getComputedHeight()-fB(e.style,`Bottom`):s;for(let i of e.childNodes)gB(i,t,{offsetX:l,offsetY:u,transformers:d,clipY1:n,clipY2:r});f&&t.unclip()}e.renderDirty=!1};var _B=class{rootNode;lastWidth=0;cachedLines=null;output=new xz(0,0);constructor(e){this.rootNode=e}notifyCommit(){this.cachedLines=null}render(e){let t=e!==this.lastWidth;if(t&&(this.clearAllRenderCaches(this.rootNode),this.lastWidth=e),this.cachedLines&&!this.rootNode.renderDirty&&!t)return this.cachedLines;this.rootNode.yogaNode.setWidth(e),this.rootNode.yogaNode.calculateLayout(void 0,void 0,1);let n=Math.ceil(this.rootNode.yogaNode.getComputedHeight());if(n<=0)return this.cachedLines=[],this.cachedLines;this.output.reset(e,n),gB(this.rootNode,this.output,{});let r=this.output.get(),i=!1;for(let t of r)if(_I(t)>e){i=!0;break}return this.cachedLines=i?r.map(t=>_I(t)>e?TI(t,e):t):r,this.cachedLines}invalidate(){this.cachedLines=null,this.clearAllRenderCaches(this.rootNode)}clearAllRenderCaches(e){e.renderDirty=!0,e.renderCache=void 0;for(let t of e.childNodes)t.nodeName!==`#text`&&this.clearAllRenderCaches(t)}},vB;(function(e){e[e.BlinkingBlock=0]=`BlinkingBlock`,e[e.BlinkingBlockDefault=1]=`BlinkingBlockDefault`,e[e.SteadyBlock=2]=`SteadyBlock`,e[e.BlinkingUnderline=3]=`BlinkingUnderline`,e[e.SteadyUnderline=4]=`SteadyUnderline`,e[e.BlinkingBar=5]=`BlinkingBar`,e[e.SteadyBar=6]=`SteadyBar`})(vB||={});const yB=`\x1B[?25h`,bB=`\x1B[?25l`;function xB(e,t){let n=``;return t!==``&&(n=typeof Buffer<`u`?Buffer.from(t).toString(`base64`):btoa(t)),`\x1B]52;`+String.fromCharCode(e)+`;`+n+`\x07`}function SB(e){return xB(99,e)}function CB(e){let t=e??Jz(),n=t.TERM_PROGRAM.toLowerCase(),r=t.TERM.toLowerCase(),i=(t.LC_TERMINAL??``).toLowerCase();if(n===`iterm.app`)return`iterm2`;if(n===`wezterm`)return`wezterm`;if(n===`ghostty`)return`ghostty`;if(n===`vscode`)return`vscode`;if(n===`tmux`)return`tmux`;if(t.WT_SESSION)return`windows-terminal`;if(r.includes(`kitty`))return`kitty`;if(r.includes(`alacritty`))return`alacritty`;if(r.includes(`foot`))return`foot`;if(r.includes(`contour`))return`contour`;if(r.includes(`rio`))return`rio`;if(r.includes(`ghostty`))return`ghostty`;if(r.includes(`wezterm`))return`wezterm`;if(r.startsWith(`tmux`))return`tmux`;if(r.startsWith(`screen`))return`screen`;if(r===`xterm`||r.startsWith(`xterm-`))return`xterm`;if(r===`linux`)return`linux`;if(!n&&i){if(i===`iterm2`)return`iterm2`;if(i===`wezterm`)return`wezterm`}return`unknown`}function wB(e){return(e??Jz()).isTTY}function TB(e){let t=CB(e);return t===`windows-terminal`||t===`iterm2`||t===`wezterm`||t===`ghostty`}function EB(e){let t=CB(e);return t===`iterm2`||t===`kitty`||t===`wezterm`||t===`ghostty`||t===`alacritty`||t===`foot`||t===`xterm`||t===`tmux`||t===`windows-terminal`||t===`rio`||t===`contour`}function DB(e){let t=CB(e);return t===`iterm2`||t===`kitty`||t===`wezterm`||t===`ghostty`||t===`alacritty`||t===`foot`||t===`contour`||t===`rio`||t===`vscode`||t===`windows-terminal`}function OB(e,...t){return`\x1B]8;`+(t.length>0?t.join(`:`):``)+`;`+e+`\x07`}function kB(...e){return OB(``,...e)}function AB(e){return e.replace(/[\x07\x1b\x9c]/g,``)}function jB(e){return`\x1B]9;`+AB(e)+`\x07`}function MB(e,...t){return`\x1B]99;`+t.map(AB).join(`:`)+`;`+AB(e)+`\x07`}function NB(e){return`\x1B]777;notify;;`+AB(e)+`\x07`}const PB=`\x1B]9;4;0\x07`;function FB(e){return`\x1B]9;4;1;`+Math.min(Math.max(0,e),100)+`\x07`}function IB(e){return`\x1B]9;4;2;`+Math.min(Math.max(0,e),100)+`\x07`}function LB(e){return`\x1B]9;4;4;`+Math.min(Math.max(0,e),100)+`\x07`}var RB=class{env;profile;terminalType;_isDark;_writer;_progressHideTimer=null;constructor(e){this.env=e?.env??Jz(),this.profile=Xz(this.env),eB(this.profile),this.terminalType=CB(this.env),this._isDark=e?.isDark??Az(),this._writer=e?.writer??null,e?.isDark!==void 0&&jz(e.isDark)}get isDark(){return this._isDark}setDark(e){this._isDark=e,jz(e)}resolveAdaptiveColor(e){if(typeof e==`string`)return Kz.parse(e);let t=this._isDark?e.dark:e.light;return Kz.parse(t)}colorize(e,t,n){if(!t)return e;let r=this.resolveAdaptiveColor(t);if(!r)return e;let i=tB(r,this.profile);return i?`\x1B[`+(n===`foreground`?i.fgSequence():i.bgSequence())+`m`+e+`\x1B[0m`:e}styledText(){return aB(this.profile)}write(e){this._writer?this._writer(e):typeof process<`u`&&process.stdout?.isTTY&&process.stdout.write(e)}notify(e){if(!wB(this.env))return;let t=this.terminalType,{title:n,body:r}=e,i=n?`${n}:\n${r}`:r;t===`kitty`&&(n?this.write(MB(r,`d=0:p=title`,n)):this.write(MB(r))),this.write(NB(i)),this.write(jB(i))}showProgress(e){if(!TB(this.env))return;this.clearProgressTimer();let t=e.state??`normal`,n=Math.min(Math.max(0,e.percentage??0),100);switch(t){case`indeterminate`:this.write(`\x1B]9;4;3\x07`);break;case`error`:this.write(IB(n));break;case`warning`:this.write(LB(n));break;default:this.write(FB(n));break}(t===`error`||n>=100)&&this.scheduleProgressHide()}hideProgress(){this.clearProgressTimer(),TB(this.env)&&this.write(PB)}async trackProgress(e){this.showProgress({state:`indeterminate`});try{let t=await e;return this.showProgress({percentage:100}),this.scheduleProgressHide(),t}catch(e){throw this.showProgress({percentage:100,state:`error`}),this.scheduleProgressHide(),e}}copyToClipboard(e){EB(this.env)&&this.write(SB(e))}clearClipboard(){EB(this.env)&&this.write(`\x1B]52;c;\x07`)}hyperlink(e,t){return DB(this.env)?OB(e)+t+kB():t}clearProgressTimer(){this._progressHideTimer&&=(clearTimeout(this._progressHideTimer),null)}scheduleProgressHide(){this.clearProgressTimer(),this._progressHideTimer=setTimeout(()=>{this.write(PB),this._progressHideTimer=null},500)}},zB=class{tui;terminal;terminalOutput;rootNode;bridge;container;exitCallbacks=[];exitPromise;resolveExit;exitOnCtrlC;ownsTui;suspendable;onSuspended;cleanupSuspend;originalWarningListeners;warningInterceptor;constructor(e={}){this.exitOnCtrlC=e.exitOnCtrlC??!0,this.suspendable=e.suspendable??!1,this.onSuspended=e.onSuspended,e.tui?(this.tui=e.tui,this.terminal=e.tui.terminal,this.ownsTui=!1):e.terminal?(this.terminal=e.terminal,this.tui=new lL(this.terminal),this.ownsTui=!0):(this.terminal=new yL,this.tui=new lL(this.terminal),this.ownsTui=!0),this.terminalOutput=new RB({writer:e=>this.terminal.write(e)}),this.rootNode=qR(`jar-root`),this.rootNode.yogaNode.setFlexDirection(0),this.rootNode.yogaNode.setFlexGrow(1),this.rootNode.onRender=()=>{this.bridge.notifyCommit(),this.tui.requestRender(),performance.clearMeasures()},this.bridge=new _B(this.rootNode),this.tui.addChild(this.bridge),this.container=cz.createContainer(this.rootNode,0,null,!1,null,`jar`,()=>{},()=>{},()=>{},()=>{}),this.exitPromise=new Promise(e=>{this.resolveExit=e}),this.exitOnCtrlC&&this.tui.addInputListener(e=>{if(!UI(e)&&XI(e,`ctrl+c`))return this.exit(),{consume:!0}})}render(e){cz.updateContainerSync(e,this.container,null),cz.flushSyncWork()}start(){this.ownsTui&&this.tui.start(),this.setupWarningInterceptor(),this.suspendable&&(this.cleanupSuspend=this.setupSuspendHandler())}exit(e){for(let t of this.exitCallbacks)t(e);this.unmount()}onExit(e){this.exitCallbacks.push(e)}unmount(){if(this.warningInterceptor&&=(U.removeListener(`warning`,this.warningInterceptor),void 0),this.originalWarningListeners){let e=U.listeners(`warning`);for(let t of this.originalWarningListeners)e.includes(t)||U.on(`warning`,t);this.originalWarningListeners=void 0}this.cleanupSuspend?.(),this.ownsTui&&this.disableInputProtocols(),cz.updateContainerSync(null,this.container,null),cz.flushSyncWork(),this.tui.removeChild(this.bridge),this.ownsTui&&this.tui.stop(),this.rootNode.yogaNode?.unsetMeasureFunc(),this.rootNode.yogaNode?.free(),this.rootNode.yogaNode=void 0,this.resolveExit()}cleanupTerminal(){this.ownsTui&&(this.cleanupSuspend?.(),this.disableInputProtocols(),this.tui.stop(),U.stdout.write(yB))}disableInputProtocols(){this.terminal.write(xL),this.terminal.write(`\x1B[?2004l`),this.terminal.kittyProtocolActive&&this.terminal.write(`\x1B[<u`)}setupWarningInterceptor(){this.originalWarningListeners||(this.originalWarningListeners=U.rawListeners(`warning`),U.removeAllListeners(`warning`),this.warningInterceptor=()=>{},U.on(`warning`,this.warningInterceptor))}setupSuspendHandler(){if(U.platform===`win32`||!this.ownsTui)return()=>{};let e=!1,t=()=>{e=this.terminal.kittyProtocolActive,U.stdout.isTTY&&(this.disableInputProtocols(),U.stdout.write(yB)),U.stdin.isTTY&&U.stdin.isRaw&&U.stdin.setRawMode(!1),this.onSuspended?.(),U.removeListener(`SIGTSTP`,t),U.kill(U.pid,`SIGTSTP`)},n=()=>{U.stdin.isTTY&&U.stdin.setRawMode(!0),U.stdout.isTTY&&(U.stdout.write(bB),this.terminal.write(`\x1B[?2004h`),this.terminal.write(bL),e&&this.terminal.write(`\x1B[>7u`)),U.on(`SIGTSTP`,t),this.tui.requestRender(!0)};return U.on(`SIGTSTP`,t),U.on(`SIGCONT`,n),()=>{U.removeListener(`SIGTSTP`,t),U.removeListener(`SIGCONT`,n)}}waitUntilExit(){return this.exitPromise}getRootNode(){return this.rootNode}};function BB(e,t){let n=new zB(t),r=Y.createElement(mz,{tui:n.tui,terminal:n.terminal,terminalOutput:n.terminalOutput,exit:e=>n.exit(e),children:e});return n.render(r),n.start(),{rerender(e){let t=Y.createElement(mz,{tui:n.tui,terminal:n.terminal,terminalOutput:n.terminalOutput,exit:e=>n.exit(e),children:e});n.render(t)},unmount(){n.unmount()},waitUntilExit(){return n.waitUntilExit()},cleanupTerminal(){n.cleanupTerminal()}}}function X({children:e,...t}){return(0,J.jsx)(`jar-view`,{style:{flexWrap:`nowrap`,flexDirection:`row`,flexGrow:0,flexShrink:1,...t,overflowX:t.overflowX??t.overflow??`visible`,overflowY:t.overflowY??t.overflow??`visible`},children:e})}function Z({color:e,backgroundColor:t,dimColor:n=!1,bold:r=!1,italic:i=!1,underline:a=!1,strikethrough:o=!1,inverse:s=!1,wrap:c=`wrap`,transform:l,children:u}){if(u==null)return null;let d=(0,Y.useCallback)(c=>(n&&(c=aB().dim().render(c)),e&&(c=rB(c,e,`foreground`)),t&&(c=rB(c,t,`background`)),r&&(c=aB().bold().render(c)),i&&(c=aB().italic().render(c)),a&&(c=aB().underline().render(c)),o&&(c=aB().strikethrough().render(c)),s&&(c=aB().reverse().render(c)),l&&(c=l(c)),c),[e,t,n,r,i,a,o,s,l]);return(0,J.jsx)(`jar-text`,{style:{flexGrow:0,flexShrink:0,flexDirection:`row`,textWrap:c},internal_transform:d,children:u})}const VB=/\x1b\[[\d:]*;(\d+)/;function HB(e){let t=VB.exec(e);return t?(parseInt(t[1],10)-1&8)!=0:!1}const UB={upArrow:!1,downArrow:!1,leftArrow:!1,rightArrow:!1,pageDown:!1,pageUp:!1,home:!1,end:!1,return:!1,escape:!1,ctrl:!1,shift:!1,tab:!1,backspace:!1,delete:!1,meta:!1,super:!1,paste:!1,raw:``},WB=(e,t={})=>{let{addInputListener:n}=(0,Y.use)(dz),r=(0,Y.useRef)(e);r.current=e,(0,Y.useEffect)(()=>{if(t.isActive!==!1)return n(e=>{if(UI(e))return;if(e.startsWith(`\x1B[200~`)){let t=e.indexOf(`\x1B[201~`),n=t===-1?e.slice(6):e.slice(6,t);UB.upArrow=!1,UB.downArrow=!1,UB.leftArrow=!1,UB.rightArrow=!1,UB.pageDown=!1,UB.pageUp=!1,UB.home=!1,UB.end=!1,UB.return=!1,UB.escape=!1,UB.ctrl=!1,UB.shift=!1,UB.tab=!1,UB.backspace=!1,UB.delete=!1,UB.meta=!1,UB.super=!1,UB.paste=!0,UB.raw=e,r.current(n,{...UB});return}let t=ZI(e),n=t?t.split(`+`):[],i=n[n.length-1]??``,a=n.includes(`ctrl`),o=n.includes(`shift`),s=n.includes(`alt`);UB.upArrow=i===`up`,UB.downArrow=i===`down`,UB.leftArrow=i===`left`,UB.rightArrow=i===`right`,UB.pageDown=i===`pagedown`,UB.pageUp=i===`pageup`,UB.home=i===`home`,UB.end=i===`end`,UB.return=i===`return`||i===`enter`,UB.escape=i===`escape`,UB.ctrl=a,UB.shift=o,UB.tab=i===`tab`,UB.backspace=i===`backspace`,UB.delete=i===`delete`,UB.meta=s,UB.super=HB(e),UB.paste=!1,UB.raw=e;let c=UB,l=``;if(a&&i)l=i;else if(!c.upArrow&&!c.downArrow&&!c.leftArrow&&!c.rightArrow&&!c.pageDown&&!c.pageUp&&!c.home&&!c.end&&!c.return&&!c.escape&&!c.tab&&!c.backspace&&!c.delete){let t=eL(e);t===void 0?e.length===1?l=e:i.length===1&&(l=i):l=t}r.current(l,{...c})})},[t.isActive,n])},GB=({isActive:e=!0,autoFocus:t=!1,id:n}={})=>{let{activeId:r,add:i,remove:a,activate:o,deactivate:s,focus:c}=(0,Y.use)(lz),l=(0,Y.useMemo)(()=>n??Math.random().toString().slice(2,7),[n]);return(0,Y.useEffect)(()=>(i(l,{autoFocus:t}),()=>{a(l)}),[l,t]),(0,Y.useEffect)(()=>{e?o(l):s(l)},[e,l]),{isFocused:!!l&&r===l,focus:c}};function KB(){return(0,Y.use)(uz)}const qB=()=>{let e=(0,Y.use)(pz);if(!e)throw Error(`useTerminal must be used within a jar render context`);return e.output},JB=RegExp(`[\\x1b\\x9b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><~]|\\x1b\\][\\s\\S]*?(?:\\x07|\\x1b\\\\)`,`g`);function YB(){return new RegExp(JB.source,`g`)}function XB(e){return e.replace(JB,``)}function ZB(e){return e.replace(/[\x07\x1b\x9c]/g,``)}function QB(e){return`\x1B]2;`+ZB(e)+`\x07`}var $B=W(((e,t)=>{t.exports={name:`@codellm/cli`,version:`2.4.5-canary.2`,private:!0,bin:{abacusai:`dist/index.mjs`},files:[`dist`,`LICENSE.txt`],type:`module`,scripts:{"prepare-publish":`bun ./scripts/prepare-publish.ts`,build:`tsdown`,"check-types":`tsgo -b --noEmit`,test:`FORCE_COLOR=1 vitest run`,"test:watch":`FORCE_COLOR=1 vitest`,"test:ui":`FORCE_COLOR=1 vitest --ui`,"test:coverage":`FORCE_COLOR=1 vitest run --coverage`},dependencies:{"@clack/prompts":`^0.11.0`,"@codellm/agent":`workspace:*`,"@codellm/api":`workspace:*`,"@codellm/auth":`workspace:*`,"@codellm/comms":`workspace:*`,"@codellm/jar":`workspace:*`,"@codellm/logging":`workspace:*`,"@codellm/product":`workspace:*`,"@logtape/logtape":`^2.0.5`,"@orpc/client":`catalog:`,"@orpc/contract":`catalog:`,"@orpc/server":`catalog:`,"@sentry/node-core":`10.46.0`,"@slack/web-api":`^7.0.0`,"@tanstack/react-query":`^5.90.19`,"@vscode/ripgrep":`1.17.0`,"ansi-styles":`^6.2.3`,"beautiful-mermaid":`^1.1.3`,"cli-boxes":`^4.0.1`,"cli-highlight":`^2.1.11`,conf:`^15.0.2`,diff:`^8.0.3`,fzf:`^0.5.2`,"gradient-string":`^3.0.0`,immer:`^11.1.4`,"isomorphic-git":`^1.36.1`,marked:`^17.0.4`,"patchright-core":`^1.58.2`,react:`^19.2.3`,"react-compiler-runtime":`^1.0.0`,remend:`^1.2.2`,semver:`^7.7.4`,"shell-history":`^2.0.1`,"string-width":`^8.1.0`,"strip-ansi":`^7.2.0`,trash:`^9.0.0`,zod:`catalog:`},devDependencies:{"@codellm/configs":`workspace:*`,"@playwright/mcp":`^0.0.68`,"@types/diff":`^8.0.0`,"@types/node":`catalog:`,"@types/react":`^19.2.9`,"@types/semver":`^7.7.1`,"@typescript/native-preview":`catalog:`,"@vitejs/plugin-react":`^5.1.2`,"@vitest/coverage-v8":`^4.0.18`,"@vitest/ui":`^4.0.18`,"@xterm/addon-serialize":`^0.14.0`,"@xterm/headless":`^6.0.0`,"babel-plugin-react-compiler":`^1.0.0`,"cli-testing-library":`^3.0.1`,jsdom:`^27.4.0`,"node-pty":`^1.1.0`,"react-devtools-core":`^6.1.5`,"svg-term-cli":`^2.1.1`,tsdown:`^0.21.0`,vite:`catalog:`,vitest:`^4.0.18`},engines:{node:`>=18`}}})),eV=Ge($B(),1);let tV=null;function nV(e){let t=(0,bF.prerelease)(e);return t&&t.length>0&&typeof t[0]==`string`?t[0]:`latest`}function rV(){let e=process.env.npm_command;if(e===`exec`||e===`dlx`)return!0;let t=process.argv[1]??``;return!!/_npx[/\\]|[/\\]dlx[/\\]|\.cache[/\\]/.test(t)}function iV(){if(process.versions.bun===void 0)return!1;let e=process.argv[1]??process.argv[0]??``;return/[/\\]\.abacusai[/\\]bin[/\\]/.test(e)}function aV(){let e=`${sn.internalEnvPrefix}DEV`,t=process.env[e];if(t===`1`||t===`true`)return!0;let n=process.argv[1]??``;try{n=v(n)}catch{}if(/[/\\]\.abacusai[/\\]bin[/\\]/.test(n))return!1;let r=/[/\\]node_modules[/\\]/.test(n)||/[/\\]\.npm[/\\]/.test(n)||/[/\\]\.bun[/\\]/.test(n),i=!!process.env.npm_config_user_agent;return!r&&!i}function oV(){return`${process.platform===`win32`?`win32`:process.platform===`darwin`?`darwin`:`linux`}-${process.arch===`arm64`?`arm64`:`x64`}`}function sV(){let e=process.env.npm_config_user_agent;if(e){let t=e.split(`/`)[0];if(t===`yarn`||t===`pnpm`||t===`bun`||t===`npm`)return t}if(process.versions.bun!==void 0)return`bun`;let t=process.argv[1]??``;return/[/\\]\.?yarn[/\\]/.test(t)?`yarn`:/[/\\]\.?pnpm[/\\]/.test(t)?`pnpm`:/[/\\]\.bun[/\\]/.test(t)?`bun`:`npm`}async function cV(e){let t=Date.now();if(tV&&t-tV.timestamp<6e4)return tV.tags;let n=await fetch(`https://registry.npmjs.org/${e}`,{signal:AbortSignal.timeout(1e4),headers:{accept:`application/json`}});if(!n.ok)throw Error(`Registry returned ${n.status}`);let r=(await n.json())[`dist-tags`]??{};return tV={tags:r,timestamp:t},r}async function lV(e,t,n,r){let i=t??nV(e),a=(r??`https://apps.abacus.ai`).replace(/\/$/,``),o=new URL(`${a}/api/v0/_getCodellmCliVersion`);o.searchParams.set(`channel`,i),n&&o.searchParams.set(`platform`,n),o.searchParams.set(`cli_version`,e);let s=await fetch(o.toString(),{signal:AbortSignal.timeout(1e4)});if(s.status===204)return null;if(!s.ok)throw Error(`API returned ${s.status}`);let c=await s.json();return{currentVersion:e,latestVersion:c.result.version,tag:c.result.channel,packageManager:sV(),isEphemeral:rV(),downloadUrl:c.result.url}}async function uV(e){let t=nV(e),n=sV(),r=rV(),i=(await cV(cn.publishName))[t];return!i&&t!==`latest`||!i||i===e?null:{currentVersion:e,latestVersion:i,tag:t,packageManager:n,isEphemeral:r}}async function dV(e,t,n){if(iV())try{return await lV(e,t,oV(),n)}catch{return null}return await uV(e)}function fV(){return`${sn.binName} upgrade`}function pV(e){let t=`${cn.publishName}@${e.tag}`;switch(e.packageManager){case`yarn`:return`yarn global add ${t}`;case`pnpm`:return`pnpm add -g ${t}`;case`bun`:return`bun add -g ${t}`;default:return`npm install -g ${t}`}}function mV(e){try{return se(pV(e),{stdio:`pipe`}),!0}catch{return!1}}function hV(e){try{return{ok:!0,output:se(pV(e),{stdio:`pipe`,encoding:`utf-8`}).trim()}}catch(e){return{ok:!1,output:e instanceof Error&&`stderr`in e?String(e.stderr).trim():e instanceof Error?e.message:`Unknown error`}}}async function gV(e){if(!e.downloadUrl)return{ok:!1,output:`No download URL`};let t=T.join(M.tmpdir(),`abacusai-update-${Date.now()}`),n=T.join(M.homedir(),`.${sn.configDirName}`,`bin`),r=process.platform===`win32`,i=r?`${sn.binName}.exe`:sn.binName;try{await ye.mkdir(t,{recursive:!0});let a=T.join(t,r?`update.zip`:`update.tar.gz`),o=await fetch(e.downloadUrl);if(!o.ok)throw Error(`Download failed: ${o.status}`);let s=Buffer.from(await o.arrayBuffer());await ye.writeFile(a,s),se(r?`powershell -Command "Expand-Archive -Path '${a}' -DestinationPath '${t}' -Force"`:`tar -xzf "${a}" -C "${t}"`,{stdio:`pipe`});let c=T.join(t,i),l=T.join(n,i);return await ye.copyFile(c,l),r||await ye.chmod(l,493),{ok:!0,output:`Updated to ${e.latestVersion}`}}catch(e){return{ok:!1,output:e instanceof Error?e.message:`Unknown error`}}finally{await ye.rm(t,{recursive:!0,force:!0}).catch(()=>{})}}function _V(e,t){let n=e=>{let n=e.toLowerCase();if(n===t)return 1e3;if(n.startsWith(t))return 900;let r=0,i=-1;for(let e of t){let t=n.indexOf(e,i+1);if(t===-1)return 0;r+=100-(t-i),i=t}return r+=Math.max(0,50-n.length),r},r=null,i=0;for(let t of e){let e=Math.max(n(t.name??``),n(t.llmName));e>i&&(i=e,r=t.llmName)}return i>=100?r:null}async function vV(e,t){let n=(await e.listLLMModels())?.result??[];return n.length||(process.stderr.write(`Error: No models available.
|
|
73327
|
+
`))}}r=mB(e,r),e.renderCache={lines:[r],width:n,height:0,left:l,top:u},t.write(l,u,r,d)}else e.renderCache=void 0;e.renderDirty=!1;return}let f=!1;if(e.nodeName===`jar-view`){e.style.backgroundColor&&hB(l,u,e,t),e.style.borderStyle&&cB(l,u,e,t);let n=e.style.overflowX===`hidden`||e.style.overflow===`hidden`,r=e.style.overflowY===`hidden`||e.style.overflow===`hidden`;if(n||r){let i=n?l+fB(e.style,`Left`):void 0,a=n?l+c.getComputedWidth()-fB(e.style,`Right`):void 0,o=r?u+fB(e.style,`Top`):void 0,s=r?u+c.getComputedHeight()-fB(e.style,`Bottom`):void 0;t.clip({x1:i,x2:a,y1:o,y2:s}),f=!0}}if(e.nodeName===`jar-root`||e.nodeName===`jar-view`){let n=f?u+fB(e.style,`Top`):o,r=f?u+c.getComputedHeight()-fB(e.style,`Bottom`):s;for(let i of e.childNodes)gB(i,t,{offsetX:l,offsetY:u,transformers:d,clipY1:n,clipY2:r});f&&t.unclip()}e.renderDirty=!1};var _B=class{rootNode;lastWidth=0;cachedLines=null;output=new xz(0,0);constructor(e){this.rootNode=e}notifyCommit(){this.cachedLines=null}render(e){let t=e!==this.lastWidth;if(t&&(this.clearAllRenderCaches(this.rootNode),this.lastWidth=e),this.cachedLines&&!this.rootNode.renderDirty&&!t)return this.cachedLines;this.rootNode.yogaNode.setWidth(e),this.rootNode.yogaNode.calculateLayout(void 0,void 0,1);let n=Math.ceil(this.rootNode.yogaNode.getComputedHeight());if(n<=0)return this.cachedLines=[],this.cachedLines;this.output.reset(e,n),gB(this.rootNode,this.output,{});let r=this.output.get(),i=!1;for(let t of r)if(_I(t)>e){i=!0;break}return this.cachedLines=i?r.map(t=>_I(t)>e?TI(t,e):t):r,this.cachedLines}invalidate(){this.cachedLines=null,this.clearAllRenderCaches(this.rootNode)}clearAllRenderCaches(e){e.renderDirty=!0,e.renderCache=void 0;for(let t of e.childNodes)t.nodeName!==`#text`&&this.clearAllRenderCaches(t)}},vB;(function(e){e[e.BlinkingBlock=0]=`BlinkingBlock`,e[e.BlinkingBlockDefault=1]=`BlinkingBlockDefault`,e[e.SteadyBlock=2]=`SteadyBlock`,e[e.BlinkingUnderline=3]=`BlinkingUnderline`,e[e.SteadyUnderline=4]=`SteadyUnderline`,e[e.BlinkingBar=5]=`BlinkingBar`,e[e.SteadyBar=6]=`SteadyBar`})(vB||={});const yB=`\x1B[?25h`,bB=`\x1B[?25l`;function xB(e,t){let n=``;return t!==``&&(n=typeof Buffer<`u`?Buffer.from(t).toString(`base64`):btoa(t)),`\x1B]52;`+String.fromCharCode(e)+`;`+n+`\x07`}function SB(e){return xB(99,e)}function CB(e){let t=e??Jz(),n=t.TERM_PROGRAM.toLowerCase(),r=t.TERM.toLowerCase(),i=(t.LC_TERMINAL??``).toLowerCase();if(n===`iterm.app`)return`iterm2`;if(n===`wezterm`)return`wezterm`;if(n===`ghostty`)return`ghostty`;if(n===`vscode`)return`vscode`;if(n===`tmux`)return`tmux`;if(t.WT_SESSION)return`windows-terminal`;if(r.includes(`kitty`))return`kitty`;if(r.includes(`alacritty`))return`alacritty`;if(r.includes(`foot`))return`foot`;if(r.includes(`contour`))return`contour`;if(r.includes(`rio`))return`rio`;if(r.includes(`ghostty`))return`ghostty`;if(r.includes(`wezterm`))return`wezterm`;if(r.startsWith(`tmux`))return`tmux`;if(r.startsWith(`screen`))return`screen`;if(r===`xterm`||r.startsWith(`xterm-`))return`xterm`;if(r===`linux`)return`linux`;if(!n&&i){if(i===`iterm2`)return`iterm2`;if(i===`wezterm`)return`wezterm`}return`unknown`}function wB(e){return(e??Jz()).isTTY}function TB(e){let t=CB(e);return t===`windows-terminal`||t===`iterm2`||t===`wezterm`||t===`ghostty`}function EB(e){let t=CB(e);return t===`iterm2`||t===`kitty`||t===`wezterm`||t===`ghostty`||t===`alacritty`||t===`foot`||t===`xterm`||t===`tmux`||t===`windows-terminal`||t===`rio`||t===`contour`}function DB(e){let t=CB(e);return t===`iterm2`||t===`kitty`||t===`wezterm`||t===`ghostty`||t===`alacritty`||t===`foot`||t===`contour`||t===`rio`||t===`vscode`||t===`windows-terminal`}function OB(e,...t){return`\x1B]8;`+(t.length>0?t.join(`:`):``)+`;`+e+`\x07`}function kB(...e){return OB(``,...e)}function AB(e){return e.replace(/[\x07\x1b\x9c]/g,``)}function jB(e){return`\x1B]9;`+AB(e)+`\x07`}function MB(e,...t){return`\x1B]99;`+t.map(AB).join(`:`)+`;`+AB(e)+`\x07`}function NB(e){return`\x1B]777;notify;;`+AB(e)+`\x07`}const PB=`\x1B]9;4;0\x07`;function FB(e){return`\x1B]9;4;1;`+Math.min(Math.max(0,e),100)+`\x07`}function IB(e){return`\x1B]9;4;2;`+Math.min(Math.max(0,e),100)+`\x07`}function LB(e){return`\x1B]9;4;4;`+Math.min(Math.max(0,e),100)+`\x07`}var RB=class{env;profile;terminalType;_isDark;_writer;_progressHideTimer=null;constructor(e){this.env=e?.env??Jz(),this.profile=Xz(this.env),eB(this.profile),this.terminalType=CB(this.env),this._isDark=e?.isDark??Az(),this._writer=e?.writer??null,e?.isDark!==void 0&&jz(e.isDark)}get isDark(){return this._isDark}setDark(e){this._isDark=e,jz(e)}resolveAdaptiveColor(e){if(typeof e==`string`)return Kz.parse(e);let t=this._isDark?e.dark:e.light;return Kz.parse(t)}colorize(e,t,n){if(!t)return e;let r=this.resolveAdaptiveColor(t);if(!r)return e;let i=tB(r,this.profile);return i?`\x1B[`+(n===`foreground`?i.fgSequence():i.bgSequence())+`m`+e+`\x1B[0m`:e}styledText(){return aB(this.profile)}write(e){this._writer?this._writer(e):typeof process<`u`&&process.stdout?.isTTY&&process.stdout.write(e)}notify(e){if(!wB(this.env))return;let t=this.terminalType,{title:n,body:r}=e,i=n?`${n}:\n${r}`:r;t===`kitty`&&(n?this.write(MB(r,`d=0:p=title`,n)):this.write(MB(r))),this.write(NB(i)),this.write(jB(i))}showProgress(e){if(!TB(this.env))return;this.clearProgressTimer();let t=e.state??`normal`,n=Math.min(Math.max(0,e.percentage??0),100);switch(t){case`indeterminate`:this.write(`\x1B]9;4;3\x07`);break;case`error`:this.write(IB(n));break;case`warning`:this.write(LB(n));break;default:this.write(FB(n));break}(t===`error`||n>=100)&&this.scheduleProgressHide()}hideProgress(){this.clearProgressTimer(),TB(this.env)&&this.write(PB)}async trackProgress(e){this.showProgress({state:`indeterminate`});try{let t=await e;return this.showProgress({percentage:100}),this.scheduleProgressHide(),t}catch(e){throw this.showProgress({percentage:100,state:`error`}),this.scheduleProgressHide(),e}}copyToClipboard(e){EB(this.env)&&this.write(SB(e))}clearClipboard(){EB(this.env)&&this.write(`\x1B]52;c;\x07`)}hyperlink(e,t){return DB(this.env)?OB(e)+t+kB():t}clearProgressTimer(){this._progressHideTimer&&=(clearTimeout(this._progressHideTimer),null)}scheduleProgressHide(){this.clearProgressTimer(),this._progressHideTimer=setTimeout(()=>{this.write(PB),this._progressHideTimer=null},500)}},zB=class{tui;terminal;terminalOutput;rootNode;bridge;container;exitCallbacks=[];exitPromise;resolveExit;exitOnCtrlC;ownsTui;suspendable;onSuspended;cleanupSuspend;originalWarningListeners;warningInterceptor;constructor(e={}){this.exitOnCtrlC=e.exitOnCtrlC??!0,this.suspendable=e.suspendable??!1,this.onSuspended=e.onSuspended,e.tui?(this.tui=e.tui,this.terminal=e.tui.terminal,this.ownsTui=!1):e.terminal?(this.terminal=e.terminal,this.tui=new lL(this.terminal),this.ownsTui=!0):(this.terminal=new yL,this.tui=new lL(this.terminal),this.ownsTui=!0),this.terminalOutput=new RB({writer:e=>this.terminal.write(e)}),this.rootNode=qR(`jar-root`),this.rootNode.yogaNode.setFlexDirection(0),this.rootNode.yogaNode.setFlexGrow(1),this.rootNode.onRender=()=>{this.bridge.notifyCommit(),this.tui.requestRender(),performance.clearMeasures()},this.bridge=new _B(this.rootNode),this.tui.addChild(this.bridge),this.container=cz.createContainer(this.rootNode,0,null,!1,null,`jar`,()=>{},()=>{},()=>{},()=>{}),this.exitPromise=new Promise(e=>{this.resolveExit=e}),this.exitOnCtrlC&&this.tui.addInputListener(e=>{if(!UI(e)&&XI(e,`ctrl+c`))return this.exit(),{consume:!0}})}render(e){cz.updateContainerSync(e,this.container,null),cz.flushSyncWork()}start(){this.ownsTui&&this.tui.start(),this.setupWarningInterceptor(),this.suspendable&&(this.cleanupSuspend=this.setupSuspendHandler())}exit(e){for(let t of this.exitCallbacks)t(e);this.unmount()}onExit(e){this.exitCallbacks.push(e)}unmount(){if(this.warningInterceptor&&=(U.removeListener(`warning`,this.warningInterceptor),void 0),this.originalWarningListeners){let e=U.listeners(`warning`);for(let t of this.originalWarningListeners)e.includes(t)||U.on(`warning`,t);this.originalWarningListeners=void 0}this.cleanupSuspend?.(),this.ownsTui&&this.disableInputProtocols(),cz.updateContainerSync(null,this.container,null),cz.flushSyncWork(),this.tui.removeChild(this.bridge),this.ownsTui&&this.tui.stop(),this.rootNode.yogaNode?.unsetMeasureFunc(),this.rootNode.yogaNode?.free(),this.rootNode.yogaNode=void 0,this.resolveExit()}cleanupTerminal(){this.ownsTui&&(this.cleanupSuspend?.(),this.disableInputProtocols(),this.tui.stop(),U.stdout.write(yB))}disableInputProtocols(){this.terminal.write(xL),this.terminal.write(`\x1B[?2004l`),this.terminal.kittyProtocolActive&&this.terminal.write(`\x1B[<u`)}setupWarningInterceptor(){this.originalWarningListeners||(this.originalWarningListeners=U.rawListeners(`warning`),U.removeAllListeners(`warning`),this.warningInterceptor=()=>{},U.on(`warning`,this.warningInterceptor))}setupSuspendHandler(){if(U.platform===`win32`||!this.ownsTui)return()=>{};let e=!1,t=()=>{e=this.terminal.kittyProtocolActive,U.stdout.isTTY&&(this.disableInputProtocols(),U.stdout.write(yB)),U.stdin.isTTY&&U.stdin.isRaw&&U.stdin.setRawMode(!1),this.onSuspended?.(),U.removeListener(`SIGTSTP`,t),U.kill(U.pid,`SIGTSTP`)},n=()=>{U.stdin.isTTY&&U.stdin.setRawMode(!0),U.stdout.isTTY&&(U.stdout.write(bB),this.terminal.write(`\x1B[?2004h`),this.terminal.write(bL),e&&this.terminal.write(`\x1B[>7u`)),U.on(`SIGTSTP`,t),this.tui.requestRender(!0)};return U.on(`SIGTSTP`,t),U.on(`SIGCONT`,n),()=>{U.removeListener(`SIGTSTP`,t),U.removeListener(`SIGCONT`,n)}}waitUntilExit(){return this.exitPromise}getRootNode(){return this.rootNode}};function BB(e,t){let n=new zB(t),r=Y.createElement(mz,{tui:n.tui,terminal:n.terminal,terminalOutput:n.terminalOutput,exit:e=>n.exit(e),children:e});return n.render(r),n.start(),{rerender(e){let t=Y.createElement(mz,{tui:n.tui,terminal:n.terminal,terminalOutput:n.terminalOutput,exit:e=>n.exit(e),children:e});n.render(t)},unmount(){n.unmount()},waitUntilExit(){return n.waitUntilExit()},cleanupTerminal(){n.cleanupTerminal()}}}function X({children:e,...t}){return(0,J.jsx)(`jar-view`,{style:{flexWrap:`nowrap`,flexDirection:`row`,flexGrow:0,flexShrink:1,...t,overflowX:t.overflowX??t.overflow??`visible`,overflowY:t.overflowY??t.overflow??`visible`},children:e})}function Z({color:e,backgroundColor:t,dimColor:n=!1,bold:r=!1,italic:i=!1,underline:a=!1,strikethrough:o=!1,inverse:s=!1,wrap:c=`wrap`,transform:l,children:u}){if(u==null)return null;let d=(0,Y.useCallback)(c=>(n&&(c=aB().dim().render(c)),e&&(c=rB(c,e,`foreground`)),t&&(c=rB(c,t,`background`)),r&&(c=aB().bold().render(c)),i&&(c=aB().italic().render(c)),a&&(c=aB().underline().render(c)),o&&(c=aB().strikethrough().render(c)),s&&(c=aB().reverse().render(c)),l&&(c=l(c)),c),[e,t,n,r,i,a,o,s,l]);return(0,J.jsx)(`jar-text`,{style:{flexGrow:0,flexShrink:0,flexDirection:`row`,textWrap:c},internal_transform:d,children:u})}const VB=/\x1b\[[\d:]*;(\d+)/;function HB(e){let t=VB.exec(e);return t?(parseInt(t[1],10)-1&8)!=0:!1}const UB={upArrow:!1,downArrow:!1,leftArrow:!1,rightArrow:!1,pageDown:!1,pageUp:!1,home:!1,end:!1,return:!1,escape:!1,ctrl:!1,shift:!1,tab:!1,backspace:!1,delete:!1,meta:!1,super:!1,paste:!1,raw:``},WB=(e,t={})=>{let{addInputListener:n}=(0,Y.use)(dz),r=(0,Y.useRef)(e);r.current=e,(0,Y.useEffect)(()=>{if(t.isActive!==!1)return n(e=>{if(UI(e))return;if(e.startsWith(`\x1B[200~`)){let t=e.indexOf(`\x1B[201~`),n=t===-1?e.slice(6):e.slice(6,t);UB.upArrow=!1,UB.downArrow=!1,UB.leftArrow=!1,UB.rightArrow=!1,UB.pageDown=!1,UB.pageUp=!1,UB.home=!1,UB.end=!1,UB.return=!1,UB.escape=!1,UB.ctrl=!1,UB.shift=!1,UB.tab=!1,UB.backspace=!1,UB.delete=!1,UB.meta=!1,UB.super=!1,UB.paste=!0,UB.raw=e,r.current(n,{...UB});return}let t=ZI(e),n=t?t.split(`+`):[],i=n[n.length-1]??``,a=n.includes(`ctrl`),o=n.includes(`shift`),s=n.includes(`alt`);UB.upArrow=i===`up`,UB.downArrow=i===`down`,UB.leftArrow=i===`left`,UB.rightArrow=i===`right`,UB.pageDown=i===`pagedown`,UB.pageUp=i===`pageup`,UB.home=i===`home`,UB.end=i===`end`,UB.return=i===`return`||i===`enter`,UB.escape=i===`escape`,UB.ctrl=a,UB.shift=o,UB.tab=i===`tab`,UB.backspace=i===`backspace`,UB.delete=i===`delete`,UB.meta=s,UB.super=HB(e),UB.paste=!1,UB.raw=e;let c=UB,l=``;if(a&&i)l=i;else if(!c.upArrow&&!c.downArrow&&!c.leftArrow&&!c.rightArrow&&!c.pageDown&&!c.pageUp&&!c.home&&!c.end&&!c.return&&!c.escape&&!c.tab&&!c.backspace&&!c.delete){let t=eL(e);t===void 0?e.length===1?l=e:i.length===1&&(l=i):l=t}r.current(l,{...c})})},[t.isActive,n])},GB=({isActive:e=!0,autoFocus:t=!1,id:n}={})=>{let{activeId:r,add:i,remove:a,activate:o,deactivate:s,focus:c}=(0,Y.use)(lz),l=(0,Y.useMemo)(()=>n??Math.random().toString().slice(2,7),[n]);return(0,Y.useEffect)(()=>(i(l,{autoFocus:t}),()=>{a(l)}),[l,t]),(0,Y.useEffect)(()=>{e?o(l):s(l)},[e,l]),{isFocused:!!l&&r===l,focus:c}};function KB(){return(0,Y.use)(uz)}const qB=()=>{let e=(0,Y.use)(pz);if(!e)throw Error(`useTerminal must be used within a jar render context`);return e.output},JB=RegExp(`[\\x1b\\x9b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><~]|\\x1b\\][\\s\\S]*?(?:\\x07|\\x1b\\\\)`,`g`);function YB(){return new RegExp(JB.source,`g`)}function XB(e){return e.replace(JB,``)}function ZB(e){return e.replace(/[\x07\x1b\x9c]/g,``)}function QB(e){return`\x1B]2;`+ZB(e)+`\x07`}var $B=W(((e,t)=>{t.exports={name:`@codellm/cli`,version:`2.4.5`,private:!0,bin:{abacusai:`dist/index.mjs`},files:[`dist`,`LICENSE.txt`],type:`module`,scripts:{"prepare-publish":`bun ./scripts/prepare-publish.ts`,build:`tsdown`,"check-types":`tsgo -b --noEmit`,test:`FORCE_COLOR=1 vitest run`,"test:watch":`FORCE_COLOR=1 vitest`,"test:ui":`FORCE_COLOR=1 vitest --ui`,"test:coverage":`FORCE_COLOR=1 vitest run --coverage`},dependencies:{"@clack/prompts":`^0.11.0`,"@codellm/agent":`workspace:*`,"@codellm/api":`workspace:*`,"@codellm/auth":`workspace:*`,"@codellm/comms":`workspace:*`,"@codellm/jar":`workspace:*`,"@codellm/logging":`workspace:*`,"@codellm/product":`workspace:*`,"@logtape/logtape":`^2.0.5`,"@orpc/client":`catalog:`,"@orpc/contract":`catalog:`,"@orpc/server":`catalog:`,"@sentry/node-core":`10.46.0`,"@slack/web-api":`^7.0.0`,"@tanstack/react-query":`^5.90.19`,"@vscode/ripgrep":`1.17.0`,"ansi-styles":`^6.2.3`,"beautiful-mermaid":`^1.1.3`,"cli-boxes":`^4.0.1`,"cli-highlight":`^2.1.11`,conf:`^15.0.2`,diff:`^8.0.3`,fzf:`^0.5.2`,"gradient-string":`^3.0.0`,immer:`^11.1.4`,"isomorphic-git":`^1.36.1`,marked:`^17.0.4`,"patchright-core":`^1.58.2`,react:`^19.2.3`,"react-compiler-runtime":`^1.0.0`,remend:`^1.2.2`,semver:`^7.7.4`,"shell-history":`^2.0.1`,"string-width":`^8.1.0`,"strip-ansi":`^7.2.0`,trash:`^9.0.0`,zod:`catalog:`},devDependencies:{"@codellm/configs":`workspace:*`,"@playwright/mcp":`^0.0.68`,"@types/diff":`^8.0.0`,"@types/node":`catalog:`,"@types/react":`^19.2.9`,"@types/semver":`^7.7.1`,"@typescript/native-preview":`catalog:`,"@vitejs/plugin-react":`^5.1.2`,"@vitest/coverage-v8":`^4.0.18`,"@vitest/ui":`^4.0.18`,"@xterm/addon-serialize":`^0.14.0`,"@xterm/headless":`^6.0.0`,"babel-plugin-react-compiler":`^1.0.0`,"cli-testing-library":`^3.0.1`,jsdom:`^27.4.0`,"node-pty":`^1.1.0`,"react-devtools-core":`^6.1.5`,"svg-term-cli":`^2.1.1`,tsdown:`^0.21.0`,vite:`catalog:`,vitest:`^4.0.18`},engines:{node:`>=18`}}})),eV=Ge($B(),1);let tV=null;function nV(e){let t=(0,bF.prerelease)(e);return t&&t.length>0&&typeof t[0]==`string`?t[0]:`latest`}function rV(){let e=process.env.npm_command;if(e===`exec`||e===`dlx`)return!0;let t=process.argv[1]??``;return!!/_npx[/\\]|[/\\]dlx[/\\]|\.cache[/\\]/.test(t)}function iV(){if(process.versions.bun===void 0)return!1;let e=process.argv[1]??process.argv[0]??``;return/[/\\]\.abacusai[/\\]bin[/\\]/.test(e)}function aV(){let e=`${sn.internalEnvPrefix}DEV`,t=process.env[e];if(t===`1`||t===`true`)return!0;let n=process.argv[1]??``;try{n=v(n)}catch{}if(/[/\\]\.abacusai[/\\]bin[/\\]/.test(n))return!1;let r=/[/\\]node_modules[/\\]/.test(n)||/[/\\]\.npm[/\\]/.test(n)||/[/\\]\.bun[/\\]/.test(n),i=!!process.env.npm_config_user_agent;return!r&&!i}function oV(){return`${process.platform===`win32`?`win32`:process.platform===`darwin`?`darwin`:`linux`}-${process.arch===`arm64`?`arm64`:`x64`}`}function sV(){let e=process.env.npm_config_user_agent;if(e){let t=e.split(`/`)[0];if(t===`yarn`||t===`pnpm`||t===`bun`||t===`npm`)return t}if(process.versions.bun!==void 0)return`bun`;let t=process.argv[1]??``;return/[/\\]\.?yarn[/\\]/.test(t)?`yarn`:/[/\\]\.?pnpm[/\\]/.test(t)?`pnpm`:/[/\\]\.bun[/\\]/.test(t)?`bun`:`npm`}async function cV(e){let t=Date.now();if(tV&&t-tV.timestamp<6e4)return tV.tags;let n=await fetch(`https://registry.npmjs.org/${e}`,{signal:AbortSignal.timeout(1e4),headers:{accept:`application/json`}});if(!n.ok)throw Error(`Registry returned ${n.status}`);let r=(await n.json())[`dist-tags`]??{};return tV={tags:r,timestamp:t},r}async function lV(e,t,n,r){let i=t??nV(e),a=(r??`https://apps.abacus.ai`).replace(/\/$/,``),o=new URL(`${a}/api/v0/_getCodellmCliVersion`);o.searchParams.set(`channel`,i),n&&o.searchParams.set(`platform`,n),o.searchParams.set(`cli_version`,e);let s=await fetch(o.toString(),{signal:AbortSignal.timeout(1e4)});if(s.status===204)return null;if(!s.ok)throw Error(`API returned ${s.status}`);let c=await s.json();return{currentVersion:e,latestVersion:c.result.version,tag:c.result.channel,packageManager:sV(),isEphemeral:rV(),downloadUrl:c.result.url}}async function uV(e){let t=nV(e),n=sV(),r=rV(),i=(await cV(cn.publishName))[t];return!i&&t!==`latest`||!i||i===e?null:{currentVersion:e,latestVersion:i,tag:t,packageManager:n,isEphemeral:r}}async function dV(e,t,n){if(iV())try{return await lV(e,t,oV(),n)}catch{return null}return await uV(e)}function fV(){return`${sn.binName} upgrade`}function pV(e){let t=`${cn.publishName}@${e.tag}`;switch(e.packageManager){case`yarn`:return`yarn global add ${t}`;case`pnpm`:return`pnpm add -g ${t}`;case`bun`:return`bun add -g ${t}`;default:return`npm install -g ${t}`}}function mV(e){try{return se(pV(e),{stdio:`pipe`}),!0}catch{return!1}}function hV(e){try{return{ok:!0,output:se(pV(e),{stdio:`pipe`,encoding:`utf-8`}).trim()}}catch(e){return{ok:!1,output:e instanceof Error&&`stderr`in e?String(e.stderr).trim():e instanceof Error?e.message:`Unknown error`}}}async function gV(e){if(!e.downloadUrl)return{ok:!1,output:`No download URL`};let t=T.join(M.tmpdir(),`abacusai-update-${Date.now()}`),n=T.join(M.homedir(),`.${sn.configDirName}`,`bin`),r=process.platform===`win32`,i=r?`${sn.binName}.exe`:sn.binName;try{await ye.mkdir(t,{recursive:!0});let a=T.join(t,r?`update.zip`:`update.tar.gz`),o=await fetch(e.downloadUrl);if(!o.ok)throw Error(`Download failed: ${o.status}`);let s=Buffer.from(await o.arrayBuffer());await ye.writeFile(a,s),se(r?`powershell -Command "Expand-Archive -Path '${a}' -DestinationPath '${t}' -Force"`:`tar -xzf "${a}" -C "${t}"`,{stdio:`pipe`});let c=T.join(t,i),l=T.join(n,i);return await ye.copyFile(c,l),r||await ye.chmod(l,493),{ok:!0,output:`Updated to ${e.latestVersion}`}}catch(e){return{ok:!1,output:e instanceof Error?e.message:`Unknown error`}}finally{await ye.rm(t,{recursive:!0,force:!0}).catch(()=>{})}}function _V(e,t){let n=e=>{let n=e.toLowerCase();if(n===t)return 1e3;if(n.startsWith(t))return 900;let r=0,i=-1;for(let e of t){let t=n.indexOf(e,i+1);if(t===-1)return 0;r+=100-(t-i),i=t}return r+=Math.max(0,50-n.length),r},r=null,i=0;for(let t of e){let e=Math.max(n(t.name??``),n(t.llmName));e>i&&(i=e,r=t.llmName)}return i>=100?r:null}async function vV(e,t){let n=(await e.listLLMModels())?.result??[];return n.length||(process.stderr.write(`Error: No models available.
|
|
73328
73328
|
`),process.exit(1)),t?_V(n,t.toLowerCase())||(process.stderr.write(`Warning: Model "${t}" not found. Using default: ${n[0].llmName}\n`),n[0].llmName):n[0].llmName}const yV=rt([`codellm`,`cli`,`exit`]),bV=new Set,xV=new Set,SV=new Set;let CV=!1,wV=!1,TV=null,EV;async function DV(e){let t=e.map(e=>new Promise(t=>{let n=`writableLength`in e?e.writableLength:0;if((`bufferSize`in e?e.bufferSize:n)===0){t();return}let r=e.write.bind(e),i=!1,a=()=>{let n=`writableLength`in e?e.writableLength:0;(`bufferSize`in e?e.bufferSize:n)===0&&!i&&(i=!0,e.write=r,t())};e.once(`drain`,a),e.write(``,`utf-8`,()=>{a()}),e.write=function(){return!1}}));await Promise.all(t)}async function OV(e,t,n,r){if(CV)return;r?.debug?.(`Executing exit handlers`,{shouldManuallyExit:e,isSynchronous:t,signal:n,asyncCallbacks:bV.size,syncCallbacks:xV.size}),CV=!0,bV.size>0&&t&&yV.error`SYNCHRONOUS TERMINATION NOTICE: When explicitly exiting the process via process.exit or via a parent process, asynchronous tasks in your exitHooks will not run. Either remove these tasks, use gracefulExit() instead of process.exit(), or ensure your parent process sends a SIGINT to the process running this code.`;let i=0;n>0?i=128+n:EV===void 0?(typeof U.exitCode==`number`||typeof U.exitCode==`string`)&&(i=Number(U.exitCode)):i=EV;let a=(t=!1)=>{(t||e)&&(TV?TV.call(U,i):U.exit(i))};for(let e of xV)try{e(i)}catch(e){yV.error`Error in synchronous exit hook: ${e}`}if(t){a();return}let o=[],s=0;for(let[e,t]of bV)s=Math.max(s,t),o.push(Promise.resolve(e(i)).catch(e=>{yV.error`Error in asynchronous exit hook: ${e}`}));let c=Array.from(SV);c.length>0&&o.push(DV(c));let l=setTimeout(()=>{a(!0)},s);try{await Promise.all(o),clearTimeout(l),a()}catch(e){clearTimeout(l),yV.error`Error during exit cleanup: ${e}`,a(!0)}}function kV(){wV||(wV=!0,U.once(`beforeExit`,()=>{OV(!0,!1,-128)}),U.once(`SIGINT`,()=>{OV(!0,!1,2)}),U.once(`SIGTERM`,()=>{OV(!0,!1,15)}),U.once(`exit`,()=>{OV(!1,!0,0)}),U.on(`message`,e=>{e===`shutdown`&&OV(!0,!0,-128)}),TV||(TV=U.exit.bind(U),U.exit=function(e){if(EV===void 0&&(EV=e??0),bV.size===0&&SV.size===0){if(TV){TV(e??0);return}U.exit(e??0)}OV(!0,!1,-128).catch(e=>{yV.error`Error during exit: ${e}`,TV?TV(1):U.exit(1)})}))}function AV(e,t){if(typeof e!=`function`)throw TypeError(`callback must be a function`);if(CV)throw Error(`Cannot install exit hook while exit handlers are running`);t?.logger?.debug?.(`Registering exit hook`,{wait:t?.wait,hasStreams:t?.streams!==void 0}),kV();let n=t?.wait??0,r=t?.streams??[U.stdout,U.stderr];if(n>0){let t=[e,n];bV.add(t);for(let e of r)SV.add(e);return()=>{bV.delete(t);for(let e of r)SV.delete(e)}}return xV.add(e),()=>{xV.delete(e)}}function jV(e){e!==void 0&&(U.exitCode=e),OV(!0,!1,-128)}function MV(e){process.stdout.write(JSON.stringify(e)+`
|
|
73329
73329
|
`)}function NV(e){try{return JSON.parse(e)}catch{return null}}async function PV({agentArgs:e}){xl(`desktop-host started`,`cli`);let t=await RF.create(),n=new Pl(t,mn(),cn.userAgentNames.desktop,eV.default.version);if(!t.isAuthenticated())try{(await n.getUserInfo())?.result?.email||(process.stderr.write(`Error: Not authenticated. Set ABACUS_DEVICE_CODE environment variable.
|
|
73330
73330
|
`),process.exit(1))}catch{process.stderr.write(`Error: Not authenticated. Set ABACUS_DEVICE_CODE environment variable.
|
|
@@ -73423,7 +73423,7 @@ A few things to keep in mind (Add Relevant ONES BELOW AS TODOS):
|
|
|
73423
73423
|
- Create a validation table:
|
|
73424
73424
|
| Requirement | Expected | Actual | Pass/Fail |
|
|
73425
73425
|
- If ANY constraint fails: web_search for correct examples before proceeding AND FIX IT. Do not declare success.
|
|
73426
|
-
Follow TASK instructions EXACTLY. Do NOT take shortcuts that bypass task requirements. Add "Re-read ALL requirements from task description and CONFIRM they are met" 2 times to the list of todos.\nThis is the task description: <task_description>${f}</task_description>`);let p=d?`conversation: ${d}`:`conversation: new`;process.stderr.write(`model: ${s} | cwd: ${r} | ${p}\n`);let m=new _P(`cli-print`);await m.load(),m.append(f);let h=``,g=``,_=0;for await(let e of u.send(f))switch(e.type){case`text_delta`:h+=e.content;break;case`thinking_delta`:g+=e.content;break;case`tool_requested`:{let t=e.tool.name,n=e.tool.id;if(o===`stream-json`)CU({type:`tool_call`,name:t,id:n,input:e.tool.input});else{let n=Object.entries(e.tool.input??{}).slice(0,2).map(([e,t])=>`${e}=${JSON.stringify(t).slice(0,60)}`).join(`, `);process.stderr.write(` ⏺ ${t}(${n})\n`)}break}case`tool_execution_complete`:if(o===`stream-json`){let t=typeof e.result?.content==`string`?e.result.content.slice(0,200):``;CU({type:`tool_result`,id:e.tool.id,result:t})}break;case`notification`:o===`stream-json`?CU({type:`notification`,severity:e.severity,message:e.message,...e.actions?{actions:e.actions}:{}}):(e.severity===`error`||e.severity===`warning`)&&process.stderr.write(`[${e.severity}] ${e.message}\n`);break;case`error`:o===`stream-json`?CU({type:`error`,message:e.error.message}):process.stderr.write(`Error: ${e.error.message}\n`);break;case`credits`:_+=e.creditsUsed;break;default:break}o===`stream-json`?(g&&CU({type:`thinking`,content:g}),h&&CU({type:`text`,content:h}),_>0&&CU({type:`credits`,creditsUsed:_}),CU({type:`result`,success:!0})):(h&&(process.stdout.write(h),process.stdout.write(`
|
|
73426
|
+
Follow TASK instructions EXACTLY. Do NOT take shortcuts that bypass task requirements. Add "Re-read ALL requirements from task description and CONFIRM they are met" 2 times to the list of todos.\nThis is the task description: <task_description>${f}</task_description>`);let p=d?`conversation: ${d}`:`conversation: new`;process.stderr.write(`model: ${s} | cwd: ${r} | ${p}\n`);let m=new _P(`cli-print`);await m.load(),m.append(f);let h=``,g=``,_=0;for await(let e of u.send(f))switch(e.type){case`text_delta`:h+=e.content;break;case`thinking_delta`:g+=e.content;break;case`tool_requested`:{let t=e.tool.name,n=e.tool.id;if(o===`stream-json`)CU({type:`tool_call`,name:t,id:n,input:e.tool.input});else{let n=Object.entries(e.tool.input??{}).slice(0,2).map(([e,t])=>`${e}=${JSON.stringify(t).slice(0,60)}`).join(`, `);process.stderr.write(` ⏺ ${t}(${n})\n`)}break}case`tool_execution_complete`:if(o===`stream-json`){let t=typeof e.result?.content==`string`?e.result.content.slice(0,200):``;CU({type:`tool_result`,id:e.tool.id,result:t})}break;case`notification`:o===`stream-json`?CU({type:`notification`,severity:e.severity,message:e.message,...e.actions?{actions:e.actions}:{}}):(e.severity===`error`||e.severity===`warning`)&&process.stderr.write(`[${e.severity}] ${e.message}\n`);break;case`error`:o===`stream-json`?CU({type:`error`,message:e.error.message}):process.stderr.write(`Error: ${e.error.message}\n`);break;case`credits`:_+=e.creditsUsed;break;default:break}o===`stream-json`?(g&&CU({type:`thinking`,content:g}),h&&CU({type:`text`,content:h}),_>0&&CU({type:`credits`,creditsUsed:_}),CU({type:`result`,success:!0}),await new Promise(e=>{process.stdout.write(``,`utf8`,()=>e())})):(h&&(process.stdout.write(h),process.stdout.write(`
|
|
73427
73427
|
`)),_>0&&process.stderr.write(`Credits used: ${_.toFixed(2)}\n`)),process.exit(0)}var DU=class{constructor(){this.listeners=new Set,this.subscribe=this.subscribe.bind(this)}subscribe(e){return this.listeners.add(e),this.onSubscribe(),()=>{this.listeners.delete(e),this.onUnsubscribe()}}hasListeners(){return this.listeners.size>0}onSubscribe(){}onUnsubscribe(){}},OU={setTimeout:(e,t)=>setTimeout(e,t),clearTimeout:e=>clearTimeout(e),setInterval:(e,t)=>setInterval(e,t),clearInterval:e=>clearInterval(e)},kU=new class{#e=OU;setTimeoutProvider(e){this.#e=e}setTimeout(e,t){return this.#e.setTimeout(e,t)}clearTimeout(e){this.#e.clearTimeout(e)}setInterval(e,t){return this.#e.setInterval(e,t)}clearInterval(e){this.#e.clearInterval(e)}};function AU(e){setTimeout(e,0)}var jU=typeof window>`u`||`Deno`in globalThis;function MU(){}function NU(e,t){return typeof e==`function`?e(t):e}function PU(e){return typeof e==`number`&&e>=0&&e!==1/0}function FU(e,t){return Math.max(e+(t||0)-Date.now(),0)}function IU(e,t){return typeof e==`function`?e(t):e}function LU(e,t){return typeof e==`function`?e(t):e}function RU(e,t){let{type:n=`all`,exact:r,fetchStatus:i,predicate:a,queryKey:o,stale:s}=e;if(o){if(r){if(t.queryHash!==BU(o,t.options))return!1}else if(!HU(t.queryKey,o))return!1}if(n!==`all`){let e=t.isActive();if(n===`active`&&!e||n===`inactive`&&e)return!1}return!(typeof s==`boolean`&&t.isStale()!==s||i&&i!==t.state.fetchStatus||a&&!a(t))}function zU(e,t){let{exact:n,status:r,predicate:i,mutationKey:a}=e;if(a){if(!t.options.mutationKey)return!1;if(n){if(VU(t.options.mutationKey)!==VU(a))return!1}else if(!HU(t.options.mutationKey,a))return!1}return!(r&&t.state.status!==r||i&&!i(t))}function BU(e,t){return(t?.queryKeyHashFn||VU)(e)}function VU(e){return JSON.stringify(e,(e,t)=>qU(t)?Object.keys(t).sort().reduce((e,n)=>(e[n]=t[n],e),{}):t)}function HU(e,t){return e===t?!0:typeof e==typeof t&&e&&t&&typeof e==`object`&&typeof t==`object`?Object.keys(t).every(n=>HU(e[n],t[n])):!1}var UU=Object.prototype.hasOwnProperty;function WU(e,t,n=0){if(e===t)return e;if(n>500)return t;let r=KU(e)&&KU(t);if(!r&&!(qU(e)&&qU(t)))return t;let i=(r?e:Object.keys(e)).length,a=r?t:Object.keys(t),o=a.length,s=r?Array(o):{},c=0;for(let l=0;l<o;l++){let o=r?l:a[l],u=e[o],d=t[o];if(u===d){s[o]=u,(r?l<i:UU.call(e,o))&&c++;continue}if(u===null||d===null||typeof u!=`object`||typeof d!=`object`){s[o]=d;continue}let f=WU(u,d,n+1);s[o]=f,f===u&&c++}return i===o&&c===i?e:s}function GU(e,t){if(!t||Object.keys(e).length!==Object.keys(t).length)return!1;for(let n in e)if(e[n]!==t[n])return!1;return!0}function KU(e){return Array.isArray(e)&&e.length===Object.keys(e).length}function qU(e){if(!JU(e))return!1;let t=e.constructor;if(t===void 0)return!0;let n=t.prototype;return!(!JU(n)||!n.hasOwnProperty(`isPrototypeOf`)||Object.getPrototypeOf(e)!==Object.prototype)}function JU(e){return Object.prototype.toString.call(e)===`[object Object]`}function YU(e){return new Promise(t=>{kU.setTimeout(t,e)})}function XU(e,t,n){return typeof n.structuralSharing==`function`?n.structuralSharing(e,t):n.structuralSharing===!1?t:WU(e,t)}function ZU(e,t,n=0){let r=[...e,t];return n&&r.length>n?r.slice(1):r}function QU(e,t,n=0){let r=[t,...e];return n&&r.length>n?r.slice(0,-1):r}var $U=Symbol();function eW(e,t){return!e.queryFn&&t?.initialPromise?()=>t.initialPromise:!e.queryFn||e.queryFn===$U?()=>Promise.reject(Error(`Missing queryFn: '${e.queryHash}'`)):e.queryFn}function tW(e,t){return typeof e==`function`?e(...t):!!e}function nW(e,t,n){let r=!1,i;return Object.defineProperty(e,`signal`,{enumerable:!0,get:()=>(i??=t(),r?i:(r=!0,i.aborted?n():i.addEventListener(`abort`,n,{once:!0}),i))}),e}var rW=new class extends DU{#e;#t;#n;constructor(){super(),this.#n=e=>{if(!jU&&window.addEventListener){let t=()=>e();return window.addEventListener(`visibilitychange`,t,!1),()=>{window.removeEventListener(`visibilitychange`,t)}}}}onSubscribe(){this.#t||this.setEventListener(this.#n)}onUnsubscribe(){this.hasListeners()||(this.#t?.(),this.#t=void 0)}setEventListener(e){this.#n=e,this.#t?.(),this.#t=e(e=>{typeof e==`boolean`?this.setFocused(e):this.onFocus()})}setFocused(e){this.#e!==e&&(this.#e=e,this.onFocus())}onFocus(){let e=this.isFocused();this.listeners.forEach(t=>{t(e)})}isFocused(){return typeof this.#e==`boolean`?this.#e:globalThis.document?.visibilityState!==`hidden`}};function iW(){let e,t,n=new Promise((n,r)=>{e=n,t=r});n.status=`pending`,n.catch(()=>{});function r(e){Object.assign(n,e),delete n.resolve,delete n.reject}return n.resolve=t=>{r({status:`fulfilled`,value:t}),e(t)},n.reject=e=>{r({status:`rejected`,reason:e}),t(e)},n}var aW=AU;function oW(){let e=[],t=0,n=e=>{e()},r=e=>{e()},i=aW,a=r=>{t?e.push(r):i(()=>{n(r)})},o=()=>{let t=e;e=[],t.length&&i(()=>{r(()=>{t.forEach(e=>{n(e)})})})};return{batch:e=>{let n;t++;try{n=e()}finally{t--,t||o()}return n},batchCalls:e=>(...t)=>{a(()=>{e(...t)})},schedule:a,setNotifyFunction:e=>{n=e},setBatchNotifyFunction:e=>{r=e},setScheduler:e=>{i=e}}}var sW=oW(),cW=new class extends DU{#e=!0;#t;#n;constructor(){super(),this.#n=e=>{if(!jU&&window.addEventListener){let t=()=>e(!0),n=()=>e(!1);return window.addEventListener(`online`,t,!1),window.addEventListener(`offline`,n,!1),()=>{window.removeEventListener(`online`,t),window.removeEventListener(`offline`,n)}}}}onSubscribe(){this.#t||this.setEventListener(this.#n)}onUnsubscribe(){this.hasListeners()||(this.#t?.(),this.#t=void 0)}setEventListener(e){this.#n=e,this.#t?.(),this.#t=e(this.setOnline.bind(this))}setOnline(e){this.#e!==e&&(this.#e=e,this.listeners.forEach(t=>{t(e)}))}isOnline(){return this.#e}};function lW(e){return Math.min(1e3*2**e,3e4)}function uW(e){return(e??`online`)===`online`?cW.isOnline():!0}var dW=class extends Error{constructor(e){super(`CancelledError`),this.revert=e?.revert,this.silent=e?.silent}};function fW(e){let t=!1,n=0,r,i=iW(),a=()=>i.status!==`pending`,o=t=>{if(!a()){let n=new dW(t);f(n),e.onCancel?.(n)}},s=()=>{t=!0},c=()=>{t=!1},l=()=>rW.isFocused()&&(e.networkMode===`always`||cW.isOnline())&&e.canRun(),u=()=>uW(e.networkMode)&&e.canRun(),d=e=>{a()||(r?.(),i.resolve(e))},f=e=>{a()||(r?.(),i.reject(e))},p=()=>new Promise(t=>{r=e=>{(a()||l())&&t(e)},e.onPause?.()}).then(()=>{r=void 0,a()||e.onContinue?.()}),m=()=>{if(a())return;let r,i=n===0?e.initialPromise:void 0;try{r=i??e.fn()}catch(e){r=Promise.reject(e)}Promise.resolve(r).then(d).catch(r=>{if(a())return;let i=e.retry??(jU?0:3),o=e.retryDelay??lW,s=typeof o==`function`?o(n,r):o,c=i===!0||typeof i==`number`&&n<i||typeof i==`function`&&i(n,r);if(t||!c){f(r);return}n++,e.onFail?.(n,r),YU(s).then(()=>l()?void 0:p()).then(()=>{t?f(r):m()})})};return{promise:i,status:()=>i.status,cancel:o,continue:()=>(r?.(),i),cancelRetry:s,continueRetry:c,canStart:u,start:()=>(u()?m():p().then(m),i)}}var pW=class{#e;destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),PU(this.gcTime)&&(this.#e=kU.setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(e){this.gcTime=Math.max(this.gcTime||0,e??(jU?1/0:300*1e3))}clearGcTimeout(){this.#e&&=(kU.clearTimeout(this.#e),void 0)}},mW=class extends pW{#e;#t;#n;#r;#i;#a;#o;constructor(e){super(),this.#o=!1,this.#a=e.defaultOptions,this.setOptions(e.options),this.observers=[],this.#r=e.client,this.#n=this.#r.getQueryCache(),this.queryKey=e.queryKey,this.queryHash=e.queryHash,this.#e=_W(this.options),this.state=e.state??this.#e,this.scheduleGc()}get meta(){return this.options.meta}get promise(){return this.#i?.promise}setOptions(e){if(this.options={...this.#a,...e},this.updateGcTime(this.options.gcTime),this.state&&this.state.data===void 0){let e=_W(this.options);e.data!==void 0&&(this.setState(gW(e.data,e.dataUpdatedAt)),this.#e=e)}}optionalRemove(){!this.observers.length&&this.state.fetchStatus===`idle`&&this.#n.remove(this)}setData(e,t){let n=XU(this.state.data,e,this.options);return this.#s({data:n,type:`success`,dataUpdatedAt:t?.updatedAt,manual:t?.manual}),n}setState(e,t){this.#s({type:`setState`,state:e,setStateOptions:t})}cancel(e){let t=this.#i?.promise;return this.#i?.cancel(e),t?t.then(MU).catch(MU):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}reset(){this.destroy(),this.setState(this.#e)}isActive(){return this.observers.some(e=>LU(e.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===$U||this.state.dataUpdateCount+this.state.errorUpdateCount===0}isStatic(){return this.getObserversCount()>0?this.observers.some(e=>IU(e.options.staleTime,this)===`static`):!1}isStale(){return this.getObserversCount()>0?this.observers.some(e=>e.getCurrentResult().isStale):this.state.data===void 0||this.state.isInvalidated}isStaleByTime(e=0){return this.state.data===void 0?!0:e===`static`?!1:this.state.isInvalidated?!0:!FU(this.state.dataUpdatedAt,e)}onFocus(){this.observers.find(e=>e.shouldFetchOnWindowFocus())?.refetch({cancelRefetch:!1}),this.#i?.continue()}onOnline(){this.observers.find(e=>e.shouldFetchOnReconnect())?.refetch({cancelRefetch:!1}),this.#i?.continue()}addObserver(e){this.observers.includes(e)||(this.observers.push(e),this.clearGcTimeout(),this.#n.notify({type:`observerAdded`,query:this,observer:e}))}removeObserver(e){this.observers.includes(e)&&(this.observers=this.observers.filter(t=>t!==e),this.observers.length||(this.#i&&(this.#o?this.#i.cancel({revert:!0}):this.#i.cancelRetry()),this.scheduleGc()),this.#n.notify({type:`observerRemoved`,query:this,observer:e}))}getObserversCount(){return this.observers.length}invalidate(){this.state.isInvalidated||this.#s({type:`invalidate`})}async fetch(e,t){if(this.state.fetchStatus!==`idle`&&this.#i?.status()!==`rejected`){if(this.state.data!==void 0&&t?.cancelRefetch)this.cancel({silent:!0});else if(this.#i)return this.#i.continueRetry(),this.#i.promise}if(e&&this.setOptions(e),!this.options.queryFn){let e=this.observers.find(e=>e.options.queryFn);e&&this.setOptions(e.options)}let n=new AbortController,r=e=>{Object.defineProperty(e,`signal`,{enumerable:!0,get:()=>(this.#o=!0,n.signal)})},i=()=>{let e=eW(this.options,t),n=(()=>{let e={client:this.#r,queryKey:this.queryKey,meta:this.meta};return r(e),e})();return this.#o=!1,this.options.persister?this.options.persister(e,n,this):e(n)},a=(()=>{let e={fetchOptions:t,options:this.options,queryKey:this.queryKey,client:this.#r,state:this.state,fetchFn:i};return r(e),e})();this.options.behavior?.onFetch(a,this),this.#t=this.state,(this.state.fetchStatus===`idle`||this.state.fetchMeta!==a.fetchOptions?.meta)&&this.#s({type:`fetch`,meta:a.fetchOptions?.meta}),this.#i=fW({initialPromise:t?.initialPromise,fn:a.fetchFn,onCancel:e=>{e instanceof dW&&e.revert&&this.setState({...this.#t,fetchStatus:`idle`}),n.abort()},onFail:(e,t)=>{this.#s({type:`failed`,failureCount:e,error:t})},onPause:()=>{this.#s({type:`pause`})},onContinue:()=>{this.#s({type:`continue`})},retry:a.options.retry,retryDelay:a.options.retryDelay,networkMode:a.options.networkMode,canRun:()=>!0});try{let e=await this.#i.start();if(e===void 0)throw Error(`${this.queryHash} data is undefined`);return this.setData(e),this.#n.config.onSuccess?.(e,this),this.#n.config.onSettled?.(e,this.state.error,this),e}catch(e){if(e instanceof dW){if(e.silent)return this.#i.promise;if(e.revert){if(this.state.data===void 0)throw e;return this.state.data}}throw this.#s({type:`error`,error:e}),this.#n.config.onError?.(e,this),this.#n.config.onSettled?.(this.state.data,e,this),e}finally{this.scheduleGc()}}#s(e){this.state=(t=>{switch(e.type){case`failed`:return{...t,fetchFailureCount:e.failureCount,fetchFailureReason:e.error};case`pause`:return{...t,fetchStatus:`paused`};case`continue`:return{...t,fetchStatus:`fetching`};case`fetch`:return{...t,...hW(t.data,this.options),fetchMeta:e.meta??null};case`success`:let n={...t,...gW(e.data,e.dataUpdatedAt),dataUpdateCount:t.dataUpdateCount+1,...!e.manual&&{fetchStatus:`idle`,fetchFailureCount:0,fetchFailureReason:null}};return this.#t=e.manual?n:void 0,n;case`error`:let r=e.error;return{...t,error:r,errorUpdateCount:t.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:t.fetchFailureCount+1,fetchFailureReason:r,fetchStatus:`idle`,status:`error`,isInvalidated:!0};case`invalidate`:return{...t,isInvalidated:!0};case`setState`:return{...t,...e.state}}})(this.state),sW.batch(()=>{this.observers.forEach(e=>{e.onQueryUpdate()}),this.#n.notify({query:this,type:`updated`,action:e})})}};function hW(e,t){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:uW(t.networkMode)?`fetching`:`paused`,...e===void 0&&{error:null,status:`pending`}}}function gW(e,t){return{data:e,dataUpdatedAt:t??Date.now(),error:null,isInvalidated:!1,status:`success`}}function _W(e){let t=typeof e.initialData==`function`?e.initialData():e.initialData,n=t!==void 0,r=n?typeof e.initialDataUpdatedAt==`function`?e.initialDataUpdatedAt():e.initialDataUpdatedAt:0;return{data:t,dataUpdateCount:0,dataUpdatedAt:n?r??Date.now():0,error:null,errorUpdateCount:0,errorUpdatedAt:0,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:null,isInvalidated:!1,status:n?`success`:`pending`,fetchStatus:`idle`}}var vW=class extends DU{constructor(e,t){super(),this.options=t,this.#e=e,this.#s=null,this.#o=iW(),this.bindMethods(),this.setOptions(t)}#e;#t=void 0;#n=void 0;#r=void 0;#i;#a;#o;#s;#c;#l;#u;#d;#f;#p;#m=new Set;bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(this.#t.addObserver(this),bW(this.#t,this.options)?this.#h():this.updateResult(),this.#y())}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return xW(this.#t,this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return xW(this.#t,this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,this.#b(),this.#x(),this.#t.removeObserver(this)}setOptions(e){let t=this.options,n=this.#t;if(this.options=this.#e.defaultQueryOptions(e),this.options.enabled!==void 0&&typeof this.options.enabled!=`boolean`&&typeof this.options.enabled!=`function`&&typeof LU(this.options.enabled,this.#t)!=`boolean`)throw Error(`Expected enabled to be a boolean or a callback that returns a boolean`);this.#S(),this.#t.setOptions(this.options),t._defaulted&&!GU(this.options,t)&&this.#e.getQueryCache().notify({type:`observerOptionsUpdated`,query:this.#t,observer:this});let r=this.hasListeners();r&&SW(this.#t,n,this.options,t)&&this.#h(),this.updateResult(),r&&(this.#t!==n||LU(this.options.enabled,this.#t)!==LU(t.enabled,this.#t)||IU(this.options.staleTime,this.#t)!==IU(t.staleTime,this.#t))&&this.#g();let i=this.#_();r&&(this.#t!==n||LU(this.options.enabled,this.#t)!==LU(t.enabled,this.#t)||i!==this.#p)&&this.#v(i)}getOptimisticResult(e){let t=this.#e.getQueryCache().build(this.#e,e),n=this.createResult(t,e);return wW(this,n)&&(this.#r=n,this.#a=this.options,this.#i=this.#t.state),n}getCurrentResult(){return this.#r}trackResult(e,t){return new Proxy(e,{get:(e,n)=>(this.trackProp(n),t?.(n),n===`promise`&&(this.trackProp(`data`),!this.options.experimental_prefetchInRender&&this.#o.status===`pending`&&this.#o.reject(Error(`experimental_prefetchInRender feature flag is not enabled`))),Reflect.get(e,n))})}trackProp(e){this.#m.add(e)}getCurrentQuery(){return this.#t}refetch({...e}={}){return this.fetch({...e})}fetchOptimistic(e){let t=this.#e.defaultQueryOptions(e),n=this.#e.getQueryCache().build(this.#e,t);return n.fetch().then(()=>this.createResult(n,t))}fetch(e){return this.#h({...e,cancelRefetch:e.cancelRefetch??!0}).then(()=>(this.updateResult(),this.#r))}#h(e){this.#S();let t=this.#t.fetch(this.options,e);return e?.throwOnError||(t=t.catch(MU)),t}#g(){this.#b();let e=IU(this.options.staleTime,this.#t);if(jU||this.#r.isStale||!PU(e))return;let t=FU(this.#r.dataUpdatedAt,e)+1;this.#d=kU.setTimeout(()=>{this.#r.isStale||this.updateResult()},t)}#_(){return(typeof this.options.refetchInterval==`function`?this.options.refetchInterval(this.#t):this.options.refetchInterval)??!1}#v(e){this.#x(),this.#p=e,!(jU||LU(this.options.enabled,this.#t)===!1||!PU(this.#p)||this.#p===0)&&(this.#f=kU.setInterval(()=>{(this.options.refetchIntervalInBackground||rW.isFocused())&&this.#h()},this.#p))}#y(){this.#g(),this.#v(this.#_())}#b(){this.#d&&=(kU.clearTimeout(this.#d),void 0)}#x(){this.#f&&=(kU.clearInterval(this.#f),void 0)}createResult(e,t){let n=this.#t,r=this.options,i=this.#r,a=this.#i,o=this.#a,s=e===n?this.#n:e.state,{state:c}=e,l={...c},u=!1,d;if(t._optimisticResults){let i=this.hasListeners(),a=!i&&bW(e,t),o=i&&SW(e,n,t,r);(a||o)&&(l={...l,...hW(c.data,e.options)}),t._optimisticResults===`isRestoring`&&(l.fetchStatus=`idle`)}let{error:f,errorUpdatedAt:p,status:m}=l;d=l.data;let h=!1;if(t.placeholderData!==void 0&&d===void 0&&m===`pending`){let e;i?.isPlaceholderData&&t.placeholderData===o?.placeholderData?(e=i.data,h=!0):e=typeof t.placeholderData==`function`?t.placeholderData(this.#u?.state.data,this.#u):t.placeholderData,e!==void 0&&(m=`success`,d=XU(i?.data,e,t),u=!0)}if(t.select&&d!==void 0&&!h)if(i&&d===a?.data&&t.select===this.#c)d=this.#l;else try{this.#c=t.select,d=t.select(d),d=XU(i?.data,d,t),this.#l=d,this.#s=null}catch(e){this.#s=e}this.#s&&(f=this.#s,d=this.#l,p=Date.now(),m=`error`);let g=l.fetchStatus===`fetching`,_=m===`pending`,v=m===`error`,y=_&&g,b=d!==void 0,x={status:m,fetchStatus:l.fetchStatus,isPending:_,isSuccess:m===`success`,isError:v,isInitialLoading:y,isLoading:y,data:d,dataUpdatedAt:l.dataUpdatedAt,error:f,errorUpdatedAt:p,failureCount:l.fetchFailureCount,failureReason:l.fetchFailureReason,errorUpdateCount:l.errorUpdateCount,isFetched:l.dataUpdateCount>0||l.errorUpdateCount>0,isFetchedAfterMount:l.dataUpdateCount>s.dataUpdateCount||l.errorUpdateCount>s.errorUpdateCount,isFetching:g,isRefetching:g&&!_,isLoadingError:v&&!b,isPaused:l.fetchStatus===`paused`,isPlaceholderData:u,isRefetchError:v&&b,isStale:CW(e,t),refetch:this.refetch,promise:this.#o,isEnabled:LU(t.enabled,e)!==!1};if(this.options.experimental_prefetchInRender){let t=x.data!==void 0,r=x.status===`error`&&!t,i=e=>{r?e.reject(x.error):t&&e.resolve(x.data)},a=()=>{i(this.#o=x.promise=iW())},o=this.#o;switch(o.status){case`pending`:e.queryHash===n.queryHash&&i(o);break;case`fulfilled`:(r||x.data!==o.value)&&a();break;case`rejected`:(!r||x.error!==o.reason)&&a();break}}return x}updateResult(){let e=this.#r,t=this.createResult(this.#t,this.options);this.#i=this.#t.state,this.#a=this.options,this.#i.data!==void 0&&(this.#u=this.#t),!GU(t,e)&&(this.#r=t,this.#C({listeners:(()=>{if(!e)return!0;let{notifyOnChangeProps:t}=this.options,n=typeof t==`function`?t():t;if(n===`all`||!n&&!this.#m.size)return!0;let r=new Set(n??this.#m);return this.options.throwOnError&&r.add(`error`),Object.keys(this.#r).some(t=>{let n=t;return this.#r[n]!==e[n]&&r.has(n)})})()}))}#S(){let e=this.#e.getQueryCache().build(this.#e,this.options);if(e===this.#t)return;let t=this.#t;this.#t=e,this.#n=e.state,this.hasListeners()&&(t?.removeObserver(this),e.addObserver(this))}onQueryUpdate(){this.updateResult(),this.hasListeners()&&this.#y()}#C(e){sW.batch(()=>{e.listeners&&this.listeners.forEach(e=>{e(this.#r)}),this.#e.getQueryCache().notify({query:this.#t,type:`observerResultsUpdated`})})}};function yW(e,t){return LU(t.enabled,e)!==!1&&e.state.data===void 0&&!(e.state.status===`error`&&t.retryOnMount===!1)}function bW(e,t){return yW(e,t)||e.state.data!==void 0&&xW(e,t,t.refetchOnMount)}function xW(e,t,n){if(LU(t.enabled,e)!==!1&&IU(t.staleTime,e)!==`static`){let r=typeof n==`function`?n(e):n;return r===`always`||r!==!1&&CW(e,t)}return!1}function SW(e,t,n,r){return(e!==t||LU(r.enabled,e)===!1)&&(!n.suspense||e.state.status!==`error`)&&CW(e,n)}function CW(e,t){return LU(t.enabled,e)!==!1&&e.isStaleByTime(IU(t.staleTime,e))}function wW(e,t){return!GU(e.getCurrentResult(),t)}function TW(e){return{onFetch:(t,n)=>{let r=t.options,i=t.fetchOptions?.meta?.fetchMore?.direction,a=t.state.data?.pages||[],o=t.state.data?.pageParams||[],s={pages:[],pageParams:[]},c=0,l=async()=>{let n=!1,l=e=>{nW(e,()=>t.signal,()=>n=!0)},u=eW(t.options,t.fetchOptions),d=async(e,r,i)=>{if(n)return Promise.reject();if(r==null&&e.pages.length)return Promise.resolve(e);let a=await u((()=>{let e={client:t.client,queryKey:t.queryKey,pageParam:r,direction:i?`backward`:`forward`,meta:t.options.meta};return l(e),e})()),{maxPages:o}=t.options,s=i?QU:ZU;return{pages:s(e.pages,a,o),pageParams:s(e.pageParams,r,o)}};if(i&&a.length){let e=i===`backward`,t=e?DW:EW,n={pages:a,pageParams:o};s=await d(n,t(r,n),e)}else{let t=e??a.length;do{let e=c===0?o[0]??r.initialPageParam:EW(r,s);if(c>0&&e==null)break;s=await d(s,e),c++}while(c<t)}return s};t.options.persister?t.fetchFn=()=>t.options.persister?.(l,{client:t.client,queryKey:t.queryKey,meta:t.options.meta,signal:t.signal},n):t.fetchFn=l}}}function EW(e,{pages:t,pageParams:n}){let r=t.length-1;return t.length>0?e.getNextPageParam(t[r],t,n[r],n):void 0}function DW(e,{pages:t,pageParams:n}){return t.length>0?e.getPreviousPageParam?.(t[0],t,n[0],n):void 0}var OW=class extends pW{#e;#t;#n;#r;constructor(e){super(),this.#e=e.client,this.mutationId=e.mutationId,this.#n=e.mutationCache,this.#t=[],this.state=e.state||kW(),this.setOptions(e.options),this.scheduleGc()}setOptions(e){this.options=e,this.updateGcTime(this.options.gcTime)}get meta(){return this.options.meta}addObserver(e){this.#t.includes(e)||(this.#t.push(e),this.clearGcTimeout(),this.#n.notify({type:`observerAdded`,mutation:this,observer:e}))}removeObserver(e){this.#t=this.#t.filter(t=>t!==e),this.scheduleGc(),this.#n.notify({type:`observerRemoved`,mutation:this,observer:e})}optionalRemove(){this.#t.length||(this.state.status===`pending`?this.scheduleGc():this.#n.remove(this))}continue(){return this.#r?.continue()??this.execute(this.state.variables)}async execute(e){let t=()=>{this.#i({type:`continue`})},n={client:this.#e,meta:this.options.meta,mutationKey:this.options.mutationKey};this.#r=fW({fn:()=>this.options.mutationFn?this.options.mutationFn(e,n):Promise.reject(Error(`No mutationFn found`)),onFail:(e,t)=>{this.#i({type:`failed`,failureCount:e,error:t})},onPause:()=>{this.#i({type:`pause`})},onContinue:t,retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>this.#n.canRun(this)});let r=this.state.status===`pending`,i=!this.#r.canStart();try{if(r)t();else{this.#i({type:`pending`,variables:e,isPaused:i}),this.#n.config.onMutate&&await this.#n.config.onMutate(e,this,n);let t=await this.options.onMutate?.(e,n);t!==this.state.context&&this.#i({type:`pending`,context:t,variables:e,isPaused:i})}let a=await this.#r.start();return await this.#n.config.onSuccess?.(a,e,this.state.context,this,n),await this.options.onSuccess?.(a,e,this.state.context,n),await this.#n.config.onSettled?.(a,null,this.state.variables,this.state.context,this,n),await this.options.onSettled?.(a,null,e,this.state.context,n),this.#i({type:`success`,data:a}),a}catch(t){try{await this.#n.config.onError?.(t,e,this.state.context,this,n)}catch(e){Promise.reject(e)}try{await this.options.onError?.(t,e,this.state.context,n)}catch(e){Promise.reject(e)}try{await this.#n.config.onSettled?.(void 0,t,this.state.variables,this.state.context,this,n)}catch(e){Promise.reject(e)}try{await this.options.onSettled?.(void 0,t,e,this.state.context,n)}catch(e){Promise.reject(e)}throw this.#i({type:`error`,error:t}),t}finally{this.#n.runNext(this)}}#i(e){this.state=(t=>{switch(e.type){case`failed`:return{...t,failureCount:e.failureCount,failureReason:e.error};case`pause`:return{...t,isPaused:!0};case`continue`:return{...t,isPaused:!1};case`pending`:return{...t,context:e.context,data:void 0,failureCount:0,failureReason:null,error:null,isPaused:e.isPaused,status:`pending`,variables:e.variables,submittedAt:Date.now()};case`success`:return{...t,data:e.data,failureCount:0,failureReason:null,error:null,status:`success`,isPaused:!1};case`error`:return{...t,data:void 0,error:e.error,failureCount:t.failureCount+1,failureReason:e.error,isPaused:!1,status:`error`}}})(this.state),sW.batch(()=>{this.#t.forEach(t=>{t.onMutationUpdate(e)}),this.#n.notify({mutation:this,type:`updated`,action:e})})}};function kW(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:`idle`,variables:void 0,submittedAt:0}}var AW=class extends DU{constructor(e={}){super(),this.config=e,this.#e=new Set,this.#t=new Map,this.#n=0}#e;#t;#n;build(e,t,n){let r=new OW({client:e,mutationCache:this,mutationId:++this.#n,options:e.defaultMutationOptions(t),state:n});return this.add(r),r}add(e){this.#e.add(e);let t=jW(e);if(typeof t==`string`){let n=this.#t.get(t);n?n.push(e):this.#t.set(t,[e])}this.notify({type:`added`,mutation:e})}remove(e){if(this.#e.delete(e)){let t=jW(e);if(typeof t==`string`){let n=this.#t.get(t);if(n)if(n.length>1){let t=n.indexOf(e);t!==-1&&n.splice(t,1)}else n[0]===e&&this.#t.delete(t)}}this.notify({type:`removed`,mutation:e})}canRun(e){let t=jW(e);if(typeof t==`string`){let n=this.#t.get(t)?.find(e=>e.state.status===`pending`);return!n||n===e}else return!0}runNext(e){let t=jW(e);return typeof t==`string`?(this.#t.get(t)?.find(t=>t!==e&&t.state.isPaused))?.continue()??Promise.resolve():Promise.resolve()}clear(){sW.batch(()=>{this.#e.forEach(e=>{this.notify({type:`removed`,mutation:e})}),this.#e.clear(),this.#t.clear()})}getAll(){return Array.from(this.#e)}find(e){let t={exact:!0,...e};return this.getAll().find(e=>zU(t,e))}findAll(e={}){return this.getAll().filter(t=>zU(e,t))}notify(e){sW.batch(()=>{this.listeners.forEach(t=>{t(e)})})}resumePausedMutations(){let e=this.getAll().filter(e=>e.state.isPaused);return sW.batch(()=>Promise.all(e.map(e=>e.continue().catch(MU))))}};function jW(e){return e.options.scope?.id}var MW=class extends DU{constructor(e={}){super(),this.config=e,this.#e=new Map}#e;build(e,t,n){let r=t.queryKey,i=t.queryHash??BU(r,t),a=this.get(i);return a||(a=new mW({client:e,queryKey:r,queryHash:i,options:e.defaultQueryOptions(t),state:n,defaultOptions:e.getQueryDefaults(r)}),this.add(a)),a}add(e){this.#e.has(e.queryHash)||(this.#e.set(e.queryHash,e),this.notify({type:`added`,query:e}))}remove(e){let t=this.#e.get(e.queryHash);t&&(e.destroy(),t===e&&this.#e.delete(e.queryHash),this.notify({type:`removed`,query:e}))}clear(){sW.batch(()=>{this.getAll().forEach(e=>{this.remove(e)})})}get(e){return this.#e.get(e)}getAll(){return[...this.#e.values()]}find(e){let t={exact:!0,...e};return this.getAll().find(e=>RU(t,e))}findAll(e={}){let t=this.getAll();return Object.keys(e).length>0?t.filter(t=>RU(e,t)):t}notify(e){sW.batch(()=>{this.listeners.forEach(t=>{t(e)})})}onFocus(){sW.batch(()=>{this.getAll().forEach(e=>{e.onFocus()})})}onOnline(){sW.batch(()=>{this.getAll().forEach(e=>{e.onOnline()})})}},NW=class{#e;#t;#n;#r;#i;#a;#o;#s;constructor(e={}){this.#e=e.queryCache||new MW,this.#t=e.mutationCache||new AW,this.#n=e.defaultOptions||{},this.#r=new Map,this.#i=new Map,this.#a=0}mount(){this.#a++,this.#a===1&&(this.#o=rW.subscribe(async e=>{e&&(await this.resumePausedMutations(),this.#e.onFocus())}),this.#s=cW.subscribe(async e=>{e&&(await this.resumePausedMutations(),this.#e.onOnline())}))}unmount(){this.#a--,this.#a===0&&(this.#o?.(),this.#o=void 0,this.#s?.(),this.#s=void 0)}isFetching(e){return this.#e.findAll({...e,fetchStatus:`fetching`}).length}isMutating(e){return this.#t.findAll({...e,status:`pending`}).length}getQueryData(e){let t=this.defaultQueryOptions({queryKey:e});return this.#e.get(t.queryHash)?.state.data}ensureQueryData(e){let t=this.defaultQueryOptions(e),n=this.#e.build(this,t),r=n.state.data;return r===void 0?this.fetchQuery(e):(e.revalidateIfStale&&n.isStaleByTime(IU(t.staleTime,n))&&this.prefetchQuery(t),Promise.resolve(r))}getQueriesData(e){return this.#e.findAll(e).map(({queryKey:e,state:t})=>[e,t.data])}setQueryData(e,t,n){let r=this.defaultQueryOptions({queryKey:e}),i=this.#e.get(r.queryHash)?.state.data,a=NU(t,i);if(a!==void 0)return this.#e.build(this,r).setData(a,{...n,manual:!0})}setQueriesData(e,t,n){return sW.batch(()=>this.#e.findAll(e).map(({queryKey:e})=>[e,this.setQueryData(e,t,n)]))}getQueryState(e){let t=this.defaultQueryOptions({queryKey:e});return this.#e.get(t.queryHash)?.state}removeQueries(e){let t=this.#e;sW.batch(()=>{t.findAll(e).forEach(e=>{t.remove(e)})})}resetQueries(e,t){let n=this.#e;return sW.batch(()=>(n.findAll(e).forEach(e=>{e.reset()}),this.refetchQueries({type:`active`,...e},t)))}cancelQueries(e,t={}){let n={revert:!0,...t},r=sW.batch(()=>this.#e.findAll(e).map(e=>e.cancel(n)));return Promise.all(r).then(MU).catch(MU)}invalidateQueries(e,t={}){return sW.batch(()=>(this.#e.findAll(e).forEach(e=>{e.invalidate()}),e?.refetchType===`none`?Promise.resolve():this.refetchQueries({...e,type:e?.refetchType??e?.type??`active`},t)))}refetchQueries(e,t={}){let n={...t,cancelRefetch:t.cancelRefetch??!0},r=sW.batch(()=>this.#e.findAll(e).filter(e=>!e.isDisabled()&&!e.isStatic()).map(e=>{let t=e.fetch(void 0,n);return n.throwOnError||(t=t.catch(MU)),e.state.fetchStatus===`paused`?Promise.resolve():t}));return Promise.all(r).then(MU)}fetchQuery(e){let t=this.defaultQueryOptions(e);t.retry===void 0&&(t.retry=!1);let n=this.#e.build(this,t);return n.isStaleByTime(IU(t.staleTime,n))?n.fetch(t):Promise.resolve(n.state.data)}prefetchQuery(e){return this.fetchQuery(e).then(MU).catch(MU)}fetchInfiniteQuery(e){return e.behavior=TW(e.pages),this.fetchQuery(e)}prefetchInfiniteQuery(e){return this.fetchInfiniteQuery(e).then(MU).catch(MU)}ensureInfiniteQueryData(e){return e.behavior=TW(e.pages),this.ensureQueryData(e)}resumePausedMutations(){return cW.isOnline()?this.#t.resumePausedMutations():Promise.resolve()}getQueryCache(){return this.#e}getMutationCache(){return this.#t}getDefaultOptions(){return this.#n}setDefaultOptions(e){this.#n=e}setQueryDefaults(e,t){this.#r.set(VU(e),{queryKey:e,defaultOptions:t})}getQueryDefaults(e){let t=[...this.#r.values()],n={};return t.forEach(t=>{HU(e,t.queryKey)&&Object.assign(n,t.defaultOptions)}),n}setMutationDefaults(e,t){this.#i.set(VU(e),{mutationKey:e,defaultOptions:t})}getMutationDefaults(e){let t=[...this.#i.values()],n={};return t.forEach(t=>{HU(e,t.mutationKey)&&Object.assign(n,t.defaultOptions)}),n}defaultQueryOptions(e){if(e._defaulted)return e;let t={...this.#n.queries,...this.getQueryDefaults(e.queryKey),...e,_defaulted:!0};return t.queryHash||=BU(t.queryKey,t),t.refetchOnReconnect===void 0&&(t.refetchOnReconnect=t.networkMode!==`always`),t.throwOnError===void 0&&(t.throwOnError=!!t.suspense),!t.networkMode&&t.persister&&(t.networkMode=`offlineFirst`),t.queryFn===$U&&(t.enabled=!1),t}defaultMutationOptions(e){return e?._defaulted?e:{...this.#n.mutations,...e?.mutationKey&&this.getMutationDefaults(e.mutationKey),...e,_defaulted:!0}}clear(){this.#e.clear(),this.#t.clear()}},PW=Y.createContext(void 0),FW=e=>{let t=Y.useContext(PW);if(e)return e;if(!t)throw Error(`No QueryClient set, use QueryClientProvider to set one`);return t},IW=({client:e,children:t})=>(Y.useEffect(()=>(e.mount(),()=>{e.unmount()}),[e]),(0,J.jsx)(PW.Provider,{value:e,children:t})),LW=Y.createContext(!1),RW=()=>Y.useContext(LW);LW.Provider;function zW(){let e=!1;return{clearReset:()=>{e=!1},reset:()=>{e=!0},isReset:()=>e}}var BW=Y.createContext(zW()),VW=()=>Y.useContext(BW),HW=(e,t,n)=>{let r=n?.state.error&&typeof e.throwOnError==`function`?tW(e.throwOnError,[n.state.error,n]):e.throwOnError;(e.suspense||e.experimental_prefetchInRender||r)&&(t.isReset()||(e.retryOnMount=!1))},UW=e=>{Y.useEffect(()=>{e.clearReset()},[e])},WW=({result:e,errorResetBoundary:t,throwOnError:n,query:r,suspense:i})=>e.isError&&!t.isReset()&&!e.isFetching&&r&&(i&&e.data===void 0||tW(n,[e.error,r])),GW=e=>{if(e.suspense){let t=1e3,n=e=>e===`static`?e:Math.max(e??t,t),r=e.staleTime;e.staleTime=typeof r==`function`?(...e)=>n(r(...e)):n(r),typeof e.gcTime==`number`&&(e.gcTime=Math.max(e.gcTime,t))}},KW=(e,t)=>e.isLoading&&e.isFetching&&!t,qW=(e,t)=>e?.suspense&&t.isPending,JW=(e,t,n)=>t.fetchOptimistic(e).catch(()=>{n.clearReset()});function YW(e,t,n){let r=RW(),i=VW(),a=FW(n),o=a.defaultQueryOptions(e);a.getDefaultOptions().queries?._experimental_beforeQuery?.(o);let s=a.getQueryCache().get(o.queryHash);o._optimisticResults=r?`isRestoring`:`optimistic`,GW(o),HW(o,i,s),UW(i);let c=!a.getQueryCache().get(o.queryHash),[l]=Y.useState(()=>new t(a,o)),u=l.getOptimisticResult(o),d=!r&&e.subscribed!==!1;if(Y.useSyncExternalStore(Y.useCallback(e=>{let t=d?l.subscribe(sW.batchCalls(e)):MU;return l.updateResult(),t},[l,d]),()=>l.getCurrentResult(),()=>l.getCurrentResult()),Y.useEffect(()=>{l.setOptions(o)},[o,l]),qW(o,u))throw JW(o,l,i);if(WW({result:u,errorResetBoundary:i,throwOnError:o.throwOnError,query:s,suspense:o.suspense}))throw u.error;return a.getDefaultOptions().queries?._experimental_afterQuery?.(o,u),o.experimental_prefetchInRender&&!jU&&KW(u,r)&&(c?JW(o,l,i):s?.promise)?.catch(MU).finally(()=>{l.updateResult()}),o.notifyOnChangeProps?u:l.trackResult(u)}function XW(e,t){return YW(e,vW,t)}function ZW(e){return typeof e==`string`?e:Az()?e.dark:e.light}const QW=(e,t)=>({light:e,dark:t}),$W=QW(`#7c7f93`,`#585b70`),eG=QW(`#9ca0b0`,`#45475a`),tG=QW(`#1e66f5`,`#89b4fa`),nG=QW(`#8839ef`,`#cba6f7`),rG=QW(`#179299`,`#94e2d5`),iG=QW(`#40a02b`,`#a6e3a1`),aG=QW(`#d20f39`,`#f38ba8`),oG=QW(`#df8e1d`,`#f9e2af`),sG=QW(`#9ca0b0`,`#45475a`),cG=QW(`#d5edd4`,`#394545`),lG=QW(`#40a02b`,`#a6e3a1`),uG=QW(`#b5dbb3`,`#4a5f4f`),dG=QW(`#f0d0d5`,`#493446`),fG=QW(`#d20f39`,`#f38ba8`),pG=QW(`#e5aeb5`,`#5e3d51`),mG=QW(`#1e66f5`,`#89b4fa`),hG=QW(`#1e66f5`,`#89b4fa`),gG=QW(`#8839ef`,`#cba6f7`),_G=QW(`#dd7878`,`#f2cdcd`),vG=QW(`#8839ef`,`#cba6f7`),yG=QW(`#40a02b`,`#a6e3a1`),bG=QW(`#fe640b`,`#fab387`),xG=QW(`#9ca0b0`,`#45475a`),SG=QW(`#1e66f5`,`#89b4fa`),CG=QW(`#d20f39`,`#f38ba8`),wG=QW(`#df8e1d`,`#f9e2af`),TG=QW(`#4c4f69`,`#cdd6f4`);function EG(e){return(e.startsWith(`"`)&&e.endsWith(`"`)?e.slice(1,-1):e).replace(/<br\s*\/?>/gi,`
|
|
73428
73428
|
`).replace(/\\n/g,`
|
|
73429
73429
|
`).replace(/<\/?(?:sub|sup|small|mark)\s*>/gi,``).replace(/\*\*(.+?)\*\*/g,`<b>$1</b>`).replace(/(?<!\*)\*([^\s*](?:[^*]*[^\s*])?)\*(?!\*)/g,`<i>$1</i>`).replace(/~~(.+?)~~/g,`<s>$1</s>`)}function DG(e){let t=e.split(`
|