@cline/shared 0.0.90 → 0.0.91

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.js CHANGED
@@ -55,10 +55,10 @@ ${t.join(`
55
55
  }
56
56
  `)}return S.write("payload.value = newResult;"),S.write("return payload;"),S.compile()},s,a=Ue,c=!Y.jitless,d=c&&Ai.value,p=t.catchall,m;e._zod.parse=(f,g)=>{m??(m=o.value);let y=f.value;if(!a(y))return f.issues.push({expected:"object",code:"invalid_type",input:y,inst:e}),f;if(c&&d&&g?.async===!1&&g.jitless!==!0){if(!s)s=i(t.shape);if(f=s(f,g),!p)return f;return za([],y,f,g,m,e,g?.abortEarly===!0)}return n(f,g)}});function Zs(e,t,n,o){for(let i of e)if(i.issues.length===0)return t.value=i.value,t;let r=e.filter((i)=>!re(i));if(r.length===1)return t.value=r[0].value,r[0];return t.issues.push({code:"invalid_union",input:t.value,inst:n,errors:e.map((i)=>i.issues.map((s)=>pe(s,o,Q())))}),t}var lo=h("$ZodUnion",(e,t)=>{z.init(e,t),P(e,"optin",(o)=>o.def.options.some((r)=>r._zod.optin==="defaulted")?"defaulted":o.def.options.some((r)=>r._zod.optin!==void 0)?"optional":void 0),P(e,"optout",(o)=>o.def.options.some((r)=>r._zod.optout==="optional")?"optional":void 0),P(e,"values",(o)=>{if(o.def.options.every((r)=>r._zod.values))return new Set(o.def.options.flatMap((r)=>Array.from(r._zod.values)));return}),P(e,"pattern",(o)=>{if(o.def.options.every((r)=>r._zod.pattern)){let r=o.def.options.map((i)=>i._zod.pattern);return new RegExp(`^(${r.map((i)=>Bt(i.source)).join("|")})$`)}return});let n=t.options.length===1?t.options[0]._zod.run:null;e._zod.parse=(o,r)=>{if(n)return n(o,r);let i=!1,s=[];for(let a of t.options){let c=a._zod.run({value:o.value,issues:[]},r);if(c instanceof Promise)s.push(c),i=!0;else{if(c.issues.length===0)return c;s.push(c)}}if(!i)return Zs(s,o,e,r);return Promise.all(s).then((a)=>Zs(a,o,e,r))}});function tm(e){let t=new Map;for(let n of e.options){let o=n._zod.propValues?.[e.discriminator];if(!o||o.size===0)throw Error(`Invalid discriminated union option at index "${e.options.indexOf(n)}"`);for(let r of o)if(t.has(r)){if(r!==void 0)throw Error(`Duplicate discriminator value "${String(r)}"`);t.set(r,null)}else t.set(r,n)}return t}var $a=h("$ZodDiscriminatedUnion",(e,t)=>{t.inclusive=!1,lo.init(e,t);let n=e._zod.parse;P(e,"propValues",(r)=>{let i={},s=0;for(let a of r.def.options){let c=a._zod.propValues;if(!c||Object.keys(c).length===0)throw Error(`Invalid discriminated union option at index "${r.def.options.indexOf(a)}"`);if(c[r.def.discriminator]?.has(void 0))s++;for(let[l,d]of Object.entries(c)){if(!Object.prototype.hasOwnProperty.call(i,l))te(i,l,new Set);for(let p of d)i[l].add(p)}}if(!r.def.unionFallback&&s>1)i[r.def.discriminator]?.delete(void 0);return i}),t.options.forEach((r,i)=>{let s=gt(r._zod.def);if(s&&!Object.prototype.hasOwnProperty.call(s,t.discriminator))throw Error(`Invalid discriminated union option at index "${i}"`)});let o=ft(()=>tm(t));e._zod.parse=(r,i)=>{let s=r.value;if(!Ue(s))return r.issues.push({code:"invalid_type",expected:"object",input:s,inst:e}),r;let a=s?.[t.discriminator],c=o.value.get(a);if(c&&(a!==void 0||i.direction!=="backward"))return c._zod.run(r,i);if(t.unionFallback||i.direction==="backward")return n(r,i);return r.issues.push({code:"invalid_union",errors:[],note:"No matching discriminator",discriminator:t.discriminator,options:Array.from(o.value.keys()).filter((l)=>o.value.get(l)!==null),input:s,path:[t.discriminator],inst:e}),r}}),La=h("$ZodIntersection",(e,t)=>{z.init(e,t),e._zod.parse=(n,o)=>{let r=n.value,i=t.left._zod.run({value:r,issues:[]},o),s=t.right._zod.run({value:r,issues:[]},o);if(i instanceof Promise||s instanceof Promise)return Promise.all([i,s]).then(([c,l])=>Fs(n,c,l));return Fs(n,i,s)}});function so(e,t){if(e===t)return{valid:!0,data:e};if(e instanceof Date&&t instanceof Date&&+e===+t)return{valid:!0,data:e};if(ze(e)&&ze(t)){let n=Object.keys(t),o=Object.keys(e).filter((i)=>n.indexOf(i)!==-1),r={...e,...t};if(Object.prototype.hasOwnProperty.call(r,"__proto__"))delete r.__proto__;for(let i of o){if(i==="__proto__")continue;let s=so(e[i],t[i]);if(!s.valid)return{valid:!1,mergeErrorPath:[i,...s.mergeErrorPath]};r[i]=s.data}return{valid:!0,data:r}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};let n=[];for(let o=0;o<e.length;o++){let r=e[o],i=t[o],s=so(r,i);if(!s.valid)return{valid:!1,mergeErrorPath:[o,...s.mergeErrorPath]};n.push(s.data)}return{valid:!0,data:n}}return{valid:!1,mergeErrorPath:[]}}function Fs(e,t,n){let o=new Map,r,i=new Map,s=(l,d)=>{let p;if(l.code==="unrecognized_keys"&&!l.path?.length)r??(r=l),p=l.keys;else if(l.code==="invalid_key"&&l.origin==="record"&&l.path?.length===1){let m=String(l.path[0]);if(!i.has(m))i.set(m,l);p=[m]}else return!1;for(let m of p){if(!o.has(m))o.set(m,{});o.get(m)[d]=!0}return!0};for(let l of t.issues)if(!s(l,"l"))e.issues.push(l);for(let l of n.issues)if(!s(l,"r"))e.issues.push(l);let a=[...o].filter(([,l])=>l.l&&l.r).map(([l])=>l);if(a.length){let l=r?a.filter((d)=>r.keys.includes(d)):[];if(l.length)e.issues.push({...r,keys:l});for(let d of a)if(!l.includes(d)&&i.has(d))e.issues.push(i.get(d))}let c=so(t.value,n.value);if(!c.valid){if(re(e))return e;throw Error(`Unmergable intersection. Error path: ${JSON.stringify(c.mergeErrorPath)}`)}return e.value=c.data,e}var po=h("$ZodTuple",(e,t)=>{z.init(e,t);let n=t.items,o=Y.memoizer;o?.attach(e),e._zod.parse=(r,i)=>{let s=r.value;if(!Array.isArray(s))return r.issues.push({input:s,inst:e,expected:"tuple",code:"invalid_type"}),r;r.value=o?o.alloc(e,r,[],i):[];let a=[],c=Hs(n,"optin"),l=Hs(n,"optout");if(!t.rest){if(s.length<c)return r.issues.push({code:"too_small",minimum:c,inclusive:!0,input:s,inst:e,origin:"array"}),r;if(s.length>n.length)r.issues.push({code:"too_big",maximum:n.length,inclusive:!0,input:s,inst:e,origin:"array"})}let d=Array(n.length),p=t.rest?i?.abortEarly:void 0,m=!1;for(let f=0;f<n.length;f++){let g=n[f]._zod.run({value:s[f],issues:[]},i);if(g instanceof Promise)a.push(g.then((y)=>{d[f]=y}));else if(d[f]=g,p&&!m&&g.issues.length)m=re(g)}if(t.rest&&!m){let f=n.length-1,g=s.slice(n.length),y=r.issues.length;for(let S of g){if(p&&r.issues.length!==y){if(re(r,y))break;y=r.issues.length}f++;let v=t.rest._zod.run({value:S,issues:[]},i);if(v instanceof Promise)a.push(v.then((k)=>js(k,r,f)));else js(v,r,f)}}if(a.length)return Promise.all(a).then(()=>Vs(d,r,n,s,l));return Vs(d,r,n,s,l)}});function Hs(e,t){for(let n=e.length-1;n>=0;n--)if(!(t==="optin"?e[n]._zod.optin!==void 0:e[n]._zod.optout==="optional"))return n+1;return 0}function js(e,t,n){if(e.issues.length)t.issues.push(...de(n,e.issues));t.value[n]=e.value}function Vs(e,t,n,o,r){for(let i=0;i<n.length;i++){let s=e[i],a=i<o.length;if(!a&&i>=r&&n[i]._zod.optin==="optional"){t.value.length=i;break}if(s.issues.length){if(!a&&i>=r){t.value.length=i;break}t.issues.push(...de(i,s.issues))}t.value[i]=s.value}for(let i=t.value.length-1;i>=o.length;i--)if(n[i]._zod.optout==="optional"&&t.value[i]===void 0)t.value.length=i;else break;return t}var Da=h("$ZodRecord",(e,t)=>{z.init(e,t);let n=Y.memoizer;n?.attach(e),e._zod.parse=(o,r)=>{let i=o.value;if(!ze(i))return o.issues.push({expected:"record",code:"invalid_type",input:i,inst:e}),o;let s=[],a=t.keyType._zod.values;if(a&&!t.partial){o.value=n?n.alloc(e,o,{},r):{};let c=new Set;for(let d of a)if(typeof d==="string"||typeof d==="number"||typeof d==="symbol"){if(c.add(typeof d==="number"?d.toString():d),d==="__proto__")continue;let p=t.keyType._zod.run({value:d,issues:[]},r);if(p instanceof Promise)throw Error("Async schemas not supported in object keys currently");if(p.issues.length){o.issues.push({code:"invalid_key",origin:"record",issues:p.issues.map((g)=>pe(g,r,Q())),input:d,path:[d],inst:e});continue}let m=p.value;if(m==="__proto__")continue;let f=t.valueType._zod.run({value:i[d],issues:[]},r);if(f instanceof Promise)s.push(f.then((g)=>{if(g.issues.length)o.issues.push(...de(d,g.issues));o.value[m]=g.value}));else{if(f.issues.length)o.issues.push(...de(d,f.issues));o.value[m]=f.value}}let l;for(let d in i)if(!c.has(d))if(t.mode==="loose"){if(d==="__proto__")continue;o.value[d]=i[d]}else l=l??[],l.push(d);if(l&&l.length>0)o.issues.push({code:"unrecognized_keys",input:i,inst:e,keys:l,continue:!0})}else{o.value=n?n.alloc(e,o,{},r):{};let c;for(let l of Reflect.ownKeys(i)){if(l==="__proto__")continue;if(!Object.prototype.propertyIsEnumerable.call(i,l))continue;let d=t.keyType._zod.run({value:l,issues:[]},r);if(d instanceof Promise)throw Error("Async schemas not supported in object keys currently");if(typeof l==="string"&&xt.test(l)&&d.issues.length){let g=t.keyType._zod.run({value:Number(l),issues:[]},r);if(g instanceof Promise)throw Error("Async schemas not supported in object keys currently");if(g.issues.length===0)d=g}if(d.issues.length){if(t.mode==="loose")o.value[l]=i[l];else if(a)c=c??[],c.push(l);else o.issues.push({code:"invalid_key",origin:"record",issues:d.issues.map((g)=>pe(g,r,Q())),input:l,path:[l],inst:e});continue}let m=d.value;if(m==="__proto__")continue;let f=t.valueType._zod.run({value:i[l],issues:[]},r);if(f instanceof Promise)s.push(f.then((g)=>{if(g.issues.length)o.issues.push(...de(l,g.issues));o.value[m]=g.value}));else{if(f.issues.length)o.issues.push(...de(l,f.issues));o.value[m]=f.value}}if(c&&c.length>0)o.issues.push({code:"unrecognized_keys",input:i,inst:e,keys:c,continue:!0})}if(s.length)return Promise.all(s).then(()=>o);return o}});var Ba=h("$ZodEnum",(e,t)=>{z.init(e,t);let n=pt(t.entries),o=new Set(n);e._zod.values=o,P(e,"pattern",(r)=>{let i=pt(r.def.entries).filter((s)=>Ii.has(typeof s));return new RegExp(i.length?`^(${i.map((s)=>Ee(s.toString())).join("|")})$`:"^[^\\s\\S]$")}),e._zod.parse=(r,i)=>{let s=r.value;if(o.has(s))return r;return r.issues.push({code:"invalid_value",values:n,input:s,inst:e}),r}}),Ua=h("$ZodLiteral",(e,t)=>{z.init(e,t);let n=new Set(t.values);e._zod.values=n,P(e,"pattern",(o)=>{let r=o.def.values;return new RegExp(r.length?`^(${r.map((i)=>typeof i==="string"?Ee(i):i?Ee(i.toString()):String(i)).join("|")})$`:"^[^\\s\\S]$")}),e._zod.parse=(o,r)=>{let i=o.value;if(n.has(i))return o;return o.issues.push({code:"invalid_value",values:t.values,input:i,inst:e}),o}});var Za=h("$ZodTransform",(e,t)=>{z.init(e,t),e._zod.optin="optional",Y.memoizer?.guard(e),e._zod.parse=(n,o)=>{if(o.direction==="backward")throw new ht(e.constructor.name);let r=t.transform(n.value,n);if(o.async)return(r instanceof Promise?r:Promise.resolve(r)).then((s)=>(n.value=s,n));if(r instanceof Promise)throw new me;return n.value=r,n}});function qs(e,t){return e.value=t.issues.length?void 0:t.value,e}var mo=h("$ZodOptional",(e,t)=>{z.init(e,t),P(e,"optin",(n)=>n.def.innerType._zod.optin==="defaulted"?"defaulted":"optional"),e._zod.optout="optional",P(e,"values",(n)=>{let o=n.def.innerType._zod.values;return o?new Set([...o,void 0]):void 0}),P(e,"pattern",(n)=>{let o=n.def.innerType._zod.pattern;return o?new RegExp(`^(${Bt(o.source)})?$`):void 0}),e._zod.parse=(n,o)=>{if(n.value===void 0){if(t.innerType._zod.optin!=="defaulted")return n;let r=t.innerType._zod.run({value:n.value,issues:[]},o);if(r instanceof Promise)return r.then((i)=>qs(n,i));return qs(n,r)}return t.innerType._zod.run(n,o)}}),Fa=h("$ZodExactOptional",(e,t)=>{mo.init(e,t),P(e,"values",(n)=>n.def.innerType._zod.values),P(e,"pattern",(n)=>n.def.innerType._zod.pattern),e._zod.parse=(n,o)=>t.innerType._zod.run(n,o)}),Ha=h("$ZodNullable",(e,t)=>{z.init(e,t),P(e,"optin",(n)=>n.def.innerType._zod.optin),P(e,"optout",(n)=>n.def.innerType._zod.optout),P(e,"pattern",(n)=>{let o=n.def.innerType._zod.pattern;return o?new RegExp(`^(${Bt(o.source)}|null)$`):void 0}),P(e,"values",(n)=>n.def.innerType._zod.values?new Set([...n.def.innerType._zod.values,null]):void 0),e._zod.parse=(n,o)=>{if(n.value===null)return n;return t.innerType._zod.run(n,o)}}),ja=h("$ZodDefault",(e,t)=>{z.init(e,t),e._zod.optin="defaulted",P(e,"values",(n)=>n.def.innerType._zod.values),e._zod.parse=(n,o)=>{if(o.direction==="backward")return t.innerType._zod.run(n,o);if(n.value===void 0)return n.value=t.defaultValue,n;let r=t.innerType._zod.run(n,o);if(r instanceof Promise)return r.then((i)=>Gs(i,t));return Gs(r,t)}});function Gs(e,t){if(e.value===void 0)e.value=t.defaultValue;return e}var Va=h("$ZodPrefault",(e,t)=>{z.init(e,t),e._zod.optin="defaulted",P(e,"values",(n)=>n.def.innerType._zod.values),e._zod.parse=(n,o)=>{if(o.direction==="backward")return t.innerType._zod.run(n,o);if(n.value===void 0)n.value=t.defaultValue;return t.innerType._zod.run(n,o)}}),qa=h("$ZodNonOptional",(e,t)=>{z.init(e,t),P(e,"values",(n)=>{let o=n.def.innerType._zod.values;return o?new Set([...o].filter((r)=>r!==void 0)):void 0}),e._zod.parse=(n,o)=>{let r=t.innerType._zod.run(n,o);if(r instanceof Promise)return r.then((i)=>Ks(i,e));return Ks(r,e)}});function Ks(e,t){if(!e.issues.length&&e.value===void 0)e.issues.push({code:"invalid_type",expected:"nonoptional",input:e.value,inst:t});return e}function Ws(e,t,n,o){if(!t.issues.length){if(e.value=t.value,t.memo)e.memo=!0;return e}return e.value=n.catchValue({...t,value:e.value,error:{issues:t.issues.map((r)=>pe(r,o,Q()))},input:e.value}),e}var Ga=h("$ZodCatch",(e,t)=>{z.init(e,t),P(e,"optin",(n)=>n.def.innerType._zod.optin==="defaulted"?"defaulted":"optional"),P(e,"optout",(n)=>n.def.innerType._zod.optout),P(e,"values",(n)=>n.def.innerType._zod.values),e._zod.parse=(n,o)=>{if(o.direction==="backward")return t.innerType._zod.run(n,o);let r=t.innerType._zod.run({value:n.value,issues:[]},o);if(r instanceof Promise)return r.then((i)=>Ws(n,i,t,o));return Ws(n,r,t,o)}});var fo=h("$ZodPipe",(e,t)=>{z.init(e,t),P(e,"values",(n)=>n.def.in._zod.values),P(e,"optin",(n)=>n.def.in._zod.optin),P(e,"optout",(n)=>n.def.out._zod.optout),P(e,"propValues",(n)=>n.def.in._zod.propValues),e._zod.parse=(n,o)=>{if(o.direction==="backward"){let i=t.out._zod.run(n,o);if(i instanceof Promise)return i.then((s)=>Wt(s,t.in,o));return Wt(i,t.in,o)}let r=t.in._zod.run(n,o);if(r instanceof Promise)return r.then((i)=>Wt(i,t.out,o));return Wt(r,t.out,o)}});function Wt(e,t,n){if(e.issues.some((o)=>o.code!=="unrecognized_keys"))return e.aborted=!0,e;return t._zod.run({value:e.value,issues:e.issues},n)}var Ka=h("$ZodPreprocess",(e,t)=>{fo.init(e,t)}),Wa=h("$ZodReadonly",(e,t)=>{z.init(e,t),P(e,"propValues",(n)=>n.def.innerType._zod.propValues),P(e,"values",(n)=>n.def.innerType._zod.values),P(e,"optin",(n)=>n.def.innerType?._zod?.optin),P(e,"optout",(n)=>n.def.innerType?._zod?.optout),e._zod.parse=(n,o)=>{if(o.direction==="backward")return t.innerType._zod.run(n,o);let r=t.innerType._zod.run(n,o);if(r instanceof Promise)return r.then(Js);return Js(r)}});function Js(e){if(!e.memo)e.value=Object.freeze(e.value);return e}var Ja=h("$ZodFunction",(e,t)=>(z.init(e,t),Object.defineProperty(e,"_def",{value:t}),e._zod.def=t,e.implement=(n)=>{if(typeof n!=="function")throw Error("implement() must be called with a function");return Object.defineProperty(function(...o){let r=e._def.input?Wn(e._def.input,o):o,i=Reflect.apply(n,this,r);if(e._def.output)return Wn(e._def.output,i);return i},"_zod",{value:e._zod,enumerable:!1})},e.implementAsync=(n)=>{if(typeof n!=="function")throw Error("implementAsync() must be called with a function");return Object.defineProperty(async function(...o){let r=e._def.input?await Jn(e._def.input,o):o,i=await Reflect.apply(n,this,r);if(e._def.output)return await Jn(e._def.output,i);return i},"_zod",{value:e._zod,enumerable:!1})},e._zod.parse=(n,o)=>{if(typeof n.value!=="function")return n.issues.push({code:"invalid_type",expected:"function",input:n.value,inst:e}),n;if(e._def.output&&e._def.output._zod.def.type==="promise")n.value=e.implementAsync(n.value);else n.value=e.implement(n.value);return n},e.input=(...n)=>{let o=e.constructor;if(Array.isArray(n[0]))return new o({type:"function",input:new po({type:"tuple",items:n[0],rest:n[1]}),output:e._def.output});return new o({type:"function",input:n[0],output:e._def.output})},e.output=(n)=>new e.constructor({type:"function",input:e._def.input,output:n}),e)),Ya=h("$ZodPromise",(e,t)=>{z.init(e,t),e._zod.parse=(n,o)=>Promise.resolve(n.value).then((r)=>t.innerType._zod.run({value:r,issues:[]},o))});var Xa=h("$ZodCustom",(e,t)=>{G.init(e,t),z.init(e,t),e._zod.parse=(n,o)=>n,e._zod.check=(n)=>{let o=n.value,r=t.fn(o);if(r instanceof Promise)return r.then((i)=>Ys(i,n,o,e));Ys(r,n,o,e);return}});function Ys(e,t,n,o){if(!e){let r={code:"custom",input:n,inst:o,path:[...o._zod.def.path??[]],continue:!o._zod.def.abort};if(o._zod.def.params)r.params=o._zod.def.params;t.issues.push(Ne(r))}}class ec extends Error{constructor(){super("Cannot parse a reference cycle that closes through a transform");this.name="ZodCyclicError"}}var ho="~memo",Qa=[];function tc(e){return e!==null&&typeof e==="object"}function go(e){return e.map((t)=>t.path?{...t,path:t.path.slice()}:{...t})}var nc=new WeakMap,_t=0,nn=1,vt=2;function on(e,t,n){let o=nc.get(e);if(o!==void 0)return o?vt:_t;if(t.has(e))return vt;t.add(e);let r=_t,i=(d)=>{if(r!==vt&&d?._zod){let p=on(d,t,n);if(p>r)r=p}},s=(d,p)=>{let m=_t;for(let f of Reflect.ownKeys(d)){let g=Object.getOwnPropertyDescriptor(d,f);if(p&&!g.enumerable)continue;let y=g.get?nn:g.value?._zod?on(g.value,t,n):_t;if(y>m)m=y}return m},a=(d)=>{if(d>r)r=d},c=e._zod.def,l=c.type;switch(l){case"object":{let d=gt(c);a(d?s(d,!0):nn),i(c.catchall);break}case"array":i(c.element);break;case"tuple":for(let d of c.items)i(d);i(c.rest);break;case"record":case"map":i(c.keyType),i(c.valueType);break;case"set":i(c.valueType);break;case"union":for(let d of c.options)i(d);break;case"intersection":i(c.left),i(c.right);break;case"optional":case"nullable":case"default":case"prefault":case"catch":case"readonly":case"nonoptional":case"promise":case"success":i(c.innerType);break;case"pipe":i(c.in),i(c.out);break;case"function":i(c.input),i(c.output);break;case"lazy":{let d=c._cachedInner??(n?e._zod.innerType:void 0);a(d?on(d,t,!1):nn);break}case"template_literal":case"string":case"number":case"int":case"boolean":case"bigint":case"symbol":case"undefined":case"null":case"void":case"never":case"any":case"unknown":case"date":case"nan":case"enum":case"literal":case"file":case"transform":case"custom":break;default:for(let d in c){let p=Object.getOwnPropertyDescriptor(c,d);if(!p||p.get)continue;let m=p.value;if(!m||typeof m!=="object")continue;if(m._zod)i(m);else if(Array.isArray(m))for(let f of m)i(f)}}return t.delete(e),nm(e,r)}function nm(e,t){if(t!==nn)nc.set(e,t===vt);return t}function om(e,t){let n=e.buckets.get(t);if(!n)n=new WeakMap,e.buckets.set(t,n);return n}var en,tn=[],rm={alloc(e,t,n){let o=en;if(!o)return n;en=void 0;let r={value:n,issues:null};return o.set(t.value,r),tn.push(r),n},guard(e){var t;(t=e._zod).deferred??(t.deferred=[]),e._zod.deferred.push(()=>{let n=e._zod.parse,o=(r,i)=>{if(i.direction!=="backward"&&im(i,r.value))throw new ec;return n(r,i)};if(e._zod.parse=o,e._zod.run===n)e._zod.run=o})},attach(e){var t;let n,o=!1,r,i;(t=e._zod).deferred??(t.deferred=[]),e._zod.deferred.push(()=>{let s=e._zod.parse,a=(c,l)=>{if(n===void 0){let v=on(e,new Set,!1);if(v===_t){if(e._zod.parse=s,e._zod.run===a)e._zod.run=s;return s(c,l)}if(v===vt||o)n=!0;else o=!0}let d=c.value;if(!tc(d))return s(c,l);let p=l[ho];if(!p)p={buckets:new WeakMap,backEdges:void 0},l[ho]=p;let m;if(r===l)m=i;else m=om(p,e),r=l,i=m;let f=m.get(d);if(f){if(c.value=f.value,f.issues){if(f.issues.length)c.issues.push(...go(f.issues))}else c.memo=!0,p.backEdges??(p.backEdges=new WeakSet),p.backEdges.add(f.value);return c}en=m;let g=tn.length,y=s(c,l);en=void 0;let S=tn.length>g?tn.pop():void 0;if(y instanceof Promise)return y.then((v)=>{if(S)S.issues=v.issues.length?go(v.issues):Qa;return v});if(S)S.issues=y.issues.length?go(y.issues):Qa;return y};if(e._zod.parse=a,e._zod.run===s)e._zod.run=a})}};function yo(){return rm}function im(e,t){let n=e[ho]?.backEdges;return n!==void 0&&tc(t)&&n.has(t)}var sm=()=>{let e={string:{unit:"characters",verb:"to have"},file:{unit:"bytes",verb:"to have"},array:{unit:"items",verb:"to have"},set:{unit:"items",verb:"to have"},map:{unit:"entries",verb:"to have"}};function t(i){return e[i]??null}let n={regex:"input",email:"email address",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO datetime",date:"ISO date",time:"ISO time",duration:"ISO duration",ipv4:"IPv4 address",ipv6:"IPv6 address",mac:"MAC address",cidrv4:"IPv4 range",cidrv6:"IPv6 range",base64:"base64-encoded string",base64url:"base64url-encoded string",json_string:"JSON string",e164:"E.164 number",currency_code:"currency code",credit_card:"credit card number",iban:"IBAN",jwt:"JWT",template_literal:"input"},o={nan:"NaN"};function r(i,s){if(i==="number"&&typeof s==="number"&&!Number.isFinite(s))return String(s);return o[i]??i}return(i)=>{switch(i.code){case"invalid_type":{let s=r(i.expected),a=zi(i.input),c=r(a,i.input);return`Invalid input: expected ${s}, received ${c}`}case"invalid_value":if(i.values.length===1)return`Invalid input: expected ${Bn(i.values[0])}`;return`Invalid option: expected one of ${$n(i.values,"|")}`;case"too_big":{let s=i.exact?"exactly ":i.inclusive?"<=":"<",a=t(i.origin);if(a)return`Too big: expected ${i.origin??"value"} to have ${s}${i.maximum.toString()} ${a.unit??"elements"}`;return`Too big: expected ${i.origin??"value"} to be ${s}${i.maximum.toString()}`}case"too_small":{let s=i.exact?"exactly ":i.inclusive?">=":">",a=t(i.origin);if(a)return`Too small: expected ${i.origin} to have ${s}${i.minimum.toString()} ${a.unit}`;return`Too small: expected ${i.origin} to be ${s}${i.minimum.toString()}`}case"invalid_format":{let s=i;if(s.format==="starts_with")return`Invalid string: must start with "${s.prefix}"`;if(s.format==="ends_with")return`Invalid string: must end with "${s.suffix}"`;if(s.format==="includes")return`Invalid string: must include "${s.includes}"`;if(s.format==="regex")return`Invalid string: must match pattern ${s.pattern}`;return`Invalid ${n[s.format]??i.format}`}case"not_multiple_of":return`Invalid number: must be a multiple of ${i.divisor}`;case"unrecognized_keys":return`Unrecognized key${i.keys.length>1?"s":""}: ${$n(i.keys,", ")}`;case"invalid_key":return`Invalid key in ${i.origin}`;case"invalid_union":if(i.options&&Array.isArray(i.options)&&i.options.length>0)return`Invalid discriminator value. Expected ${i.options.map((a)=>`'${a}'`).join(" | ")}`;if(i.inclusive===!1)return"Invalid input: more than one option matched";return"Invalid input";case"invalid_element":return`Invalid value in ${i.origin}`;default:return"Invalid input"}}};function bo(){return{localeError:sm()}}var oc;class rc{constructor(){this._map=new WeakMap,this._idmap=new Map}add(e,...t){let n=t[0];if(this._map.set(e,n),n&&typeof n==="object"&&"id"in n)this._idmap.set(n.id,e);return this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(e){let t=this._map.get(e);if(t&&typeof t==="object"&&"id"in t)this._idmap.delete(t.id);return this._map.delete(e),this}get(e){let t=e._zod.parent;if(t){let n={...this.get(t)??{}};delete n.id;let o={...n,...this._map.get(e)};return Object.keys(o).length?o:void 0}return this._map.get(e)}has(e){return this._map.has(e)}}function ic(){return new rc}(oc=globalThis).__zod_globalRegistry??(oc.__zod_globalRegistry=ic());var Re=globalThis.__zod_globalRegistry;function sc(e){if(e.checks)e.checks=[...e.checks];return e}function ac(e,t){return new e(sc({type:"string",..._(t)}))}function cc(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,..._(t)})}function uc(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,..._(t)})}function lc(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,..._(t)})}function dc(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",..._(t)})}function pc(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",..._(t)})}function mc(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",..._(t)})}function fc(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,..._(t)})}function gc(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,..._(t)})}function hc(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,..._(t)})}function yc(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,..._(t)})}function bc(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,..._(t)})}function xc(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,..._(t)})}function Sc(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,..._(t)})}function _c(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,..._(t)})}function vc(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,..._(t)})}function Tc(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,..._(t)})}function Cc(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,..._(t)})}function kc(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,..._(t)})}function Ec(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,..._(t)})}function Rc(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,..._(t)})}function Ac(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,..._(t)})}function Ic(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,..._(t)})}function wc(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,..._(t)})}function Pc(e,t){return new e({type:"string",format:"date",check:"string_format",..._(t)})}function Mc(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,..._(t)})}function Oc(e,t){return new e({type:"string",format:"duration",check:"string_format",..._(t)})}function zc(e,t){return new e(sc({type:"number",checks:[],..._(t)}))}function Nc(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",..._(t)})}function $c(e,t){return new e({type:"boolean",..._(t)})}function Lc(e){return new e({type:"unknown"})}function Dc(e,t){return new e({type:"never",..._(t)})}function Bc(e,t){return new e({type:"void",..._(t)})}function Uc(e,t){return new e({type:"date",..._(t)})}function rn(e,t){return new oo({check:"less_than",..._(t),value:e,inclusive:!1})}function Fe(e,t){return new oo({check:"less_than",..._(t),value:e,inclusive:!0})}function sn(e,t){return new ro({check:"greater_than",..._(t),value:e,inclusive:!1})}function He(e,t){return new ro({check:"greater_than",..._(t),value:e,inclusive:!0})}function an(e,t){return new ks({check:"multiple_of",..._(t),value:e})}function cn(e,t){return new Rs({check:"max_length",..._(t),maximum:e})}function je(e,t){return new As({check:"min_length",..._(t),minimum:e})}function un(e,t){return new Is({check:"length_equals",..._(t),length:e})}function xo(e,t){return new ws({check:"string_format",format:"regex",..._(t),pattern:e})}function So(e){return new Ps({check:"string_format",format:"lowercase",..._(e)})}function _o(e){return new Ms({check:"string_format",format:"uppercase",..._(e)})}function vo(e,t){return new Os({check:"string_format",format:"includes",..._(t),includes:e})}function To(e,t){return new zs({check:"string_format",format:"starts_with",..._(t),prefix:e})}function Co(e,t){return new Ns({check:"string_format",format:"ends_with",..._(t),suffix:e})}function Ae(e){return new $s({check:"overwrite",tx:e})}function ko(e){return Ae((t)=>t.normalize(e))}function Eo(){return Ae((e)=>e.trim())}function Ro(){return Ae((e)=>e.toLowerCase())}function Ao(){return Ae((e)=>e.toUpperCase())}function Io(){return Ae((e)=>Ri(e))}function Zc(e,t,n){return new e({type:"array",element:t,..._(n)})}function Fc(e,t,n){let o=_(n);return o.abort??(o.abort=!0),new e({type:"custom",check:"custom",fn:t,...o})}function Hc(e,t,n){return new e({type:"custom",check:"custom",fn:t,..._(n)})}function jc(e,t){let n=am((o)=>(o.addIssue=(r)=>{if(typeof r==="string")o.issues.push(Ne(r,o.value,n._zod.def));else{let i=r;if(i.fatal)i.continue=!1;if(i.code??(i.code="custom"),!("input"in i))i.input=o.value;i.inst??(i.inst=n),i.continue??(i.continue=!n._zod.def.abort),o.issues.push(Ne(i))}},e(o.value,o)),t);return n}function am(e,t){let n=new G({check:"custom",..._(t)});return n._zod.check=e,n}function Tt(e,...t){for(let n of t)for(let o of Reflect.ownKeys(n))if(Object.prototype.propertyIsEnumerable.call(n,o))te(e,o,n[o]);return e}function kt(e){let t=e?.target??"draft-2020-12";if(t==="draft-4")t="draft-04";if(t==="draft-7")t="draft-07";return{processors:e.processors??{},metadataRegistry:e?.metadata??Re,target:t,unrepresentable:e?.unrepresentable??"throw",override:e?.override??(()=>{}),io:e?.io??"output",counter:0,seen:new Map,sharedDefsExtractedFor:void 0,sharedEmitDoneFor:void 0,cycles:e?.cycles??"ref",reused:e?.reused??"inline",intersections:[],deferred:[],external:e?.external??void 0}}function q(e,t,n,o,r){let i=typeof t.unrepresentable==="function"?t.unrepresentable({zodSchema:e,path:o.path,message:r}):t.unrepresentable;if(i==="any")return!1;if(i===void 0||i==="throw")throw Error(r);return Object.assign(n,i),!0}function D(e,t,n={path:[],schemaPath:[]}){var o;let r=e._zod.def,i=t.seen.get(e);if(i){if(i.count++,n.schemaPath.includes(e))i.cycle=n.path;return i.schema}let s={schema:{},count:1,cycle:void 0,path:n.path};t.seen.set(e,s),t.sharedDefsExtractedFor=void 0,t.sharedEmitDoneFor=void 0;let a=e._zod.toJSONSchema?.();if(a)s.schema=a;else{let d={...n,schemaPath:[...n.schemaPath,e],path:n.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,s.schema,d);else{let m=s.schema,f=t.processors[r.type];if(!f)throw Error(`[toJSONSchema]: Non-representable type encountered: ${r.type}`);f(e,t,m,d)}let p=e._zod.parent;if(p){if(!s.ref)s.ref=p;D(p,t,d),t.seen.get(p).isParent=!0}}let c=t.metadataRegistry.get(e);if(c)Tt(s.schema,c);if(t.io==="input"&&X(e))delete s.schema.examples,delete s.schema.default;if(t.io==="input"&&"_prefault"in s.schema)(o=s.schema).default??(o.default=s.schema._prefault);return delete s.schema._prefault,t.seen.get(e).schema}function Vc(e){return e.replace(/~/g,"~0").replace(/\//g,"~1")}function Et(e,t){let n=e.seen.get(t);if(!n)throw Error("Unprocessed schema. This is a bug in Zod.");if(e.external&&e.sharedDefsExtractedFor===e.external)return;let o=new Map;for(let s of e.seen.entries()){let a=e.metadataRegistry.get(s[0])?.id;if(a){let c=o.get(a);if(c&&c!==s[0])throw Error(`Duplicate schema id "${a}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);o.set(a,s[0])}}let r=(s)=>{let a=e.target==="draft-2020-12"?"$defs":"definitions";if(e.external){let p=e.external.registry.get(s[0])?.id,m=e.external.uri??((g)=>g);if(p)return{ref:m(p)};let f=s[1].defId??s[1].schema.id??`schema${e.counter++}`;return s[1].defId=f,{defId:f,ref:`${m("__shared")}#/${a}/${Vc(f)}`}}let c="#",l=`${c}/${a}/`;if(s[1]===n&&!s[1].schema.id)return{ref:c};let d=s[1].schema.id??`__schema${e.counter++}`;return{defId:d,ref:l+Vc(d)}},i=(s)=>{if(s[1].schema.$ref)return;let a=s[1],{ref:c,defId:l}=r(s);if(a.def={...a.schema},l)a.defId=l;let d=a.schema;for(let p in d)delete d[p];d.$ref=c};if(e.cycles==="throw")for(let s of e.seen.entries()){let a=s[1];if(a.cycle)throw Error(`Cycle detected: #/${a.cycle?.join("/")}/<root>
57
57
 
58
- Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let s of e.seen.entries()){let a=s[1];if(t===s[0]){i(s);continue}if(e.external){let l=e.external.registry.get(s[0])?.id;if(t!==s[0]&&l){i(s);continue}}if(e.metadataRegistry.get(s[0])?.id){i(s);continue}if(a.cycle){i(s);continue}if(a.count>1){if(e.reused==="ref")i(s)}}if(e.external)e.sharedDefsExtractedFor=e.external}function Kc(e){let t=e.anyOf;if(!Array.isArray(t)||t.length===0||e.type!==void 0)return;let n=[];for(let o of t){if(!o||typeof o!=="object")return;Kc(o);let r=Object.keys(o);if(r.length!==1||r[0]!=="type")return;let i=o.type;for(let s of Array.isArray(i)?i:[i]){if(typeof s!=="string")return;if(!n.includes(s))n.push(s)}}delete e.anyOf,e.type=n.length===1?n[0]:n}var Wc=new Set(["type","properties","required","additionalProperties"]),qc=["oneOf","anyOf"];function Gc(e){let t=e.additionalProperties;if(t===void 0||t===!1||typeof t!=="object"||t===null)return null;return Object.keys(t).length?t:null}function wo(e){let t=[];for(let i of e){if(typeof i!=="object"||i.type!=="object")return null;for(let s in i)if(!Wc.has(s))return null;t.push(i)}let n={},o=new Set;for(let i of t){for(let s in i.properties){if(Object.prototype.hasOwnProperty.call(n,s))continue;let a=[];for(let l of t){let d=l.properties?.[s]??Gc(l);if(d===null||d===void 0)continue;if(!a.some((p)=>JSON.stringify(p)===JSON.stringify(d)))a.push(d)}let c=a.length===1?a[0]:wo(a)??{allOf:a};te(n,s,c)}for(let s of i.required??[])o.add(s)}let r={type:"object",properties:n};if(o.size)r.required=[...o];if(t.every((i)=>i.additionalProperties===!1))r.additionalProperties=!1;else{let i=[];for(let s of t){let a=Gc(s);if(a&&!i.some((c)=>JSON.stringify(c)===JSON.stringify(a)))i.push(a)}if(i.length===1)r.additionalProperties=i[0];else if(i.length>1)r.additionalProperties={allOf:i}}return r}function cm(e){let t=e.allOf;if(!Array.isArray(t)||t.length<2)return;for(let r of Wc)if(r in e)return;let n=t.filter((r)=>qc.some((i)=>Array.isArray(r[i]))),o=null;if(!n.length)o=wo(t);else{let r=n[0],i=qc.find((c)=>Array.isArray(r[c]));if(Object.keys(r).length!==1)return;let s=t.filter((c)=>c!==r),a=r[i].map((c)=>wo([...s,c]));if(a.some((c)=>!c))return;o={[i]:a}}if(!o)return;delete e.allOf,Tt(e,o)}function Rt(e,t){let n=e.seen.get(t);if(!n)throw Error("Unprocessed schema. This is a bug in Zod.");let o=(a)=>{let c=e.seen.get(a);if(c.ref===null)return;let l=c.def??c.schema,d={...l},p=c.ref;if(c.ref=null,p){o(p);let f=e.seen.get(p),g=f.schema;if(g.$ref&&(e.target==="draft-07"||e.target==="draft-04"||e.target==="openapi-3.0"))l.allOf=l.allOf??[],l.allOf.push(g);else Tt(l,g);if(Tt(l,d),a._zod.parent===p)for(let S in l){if(S==="$ref"||S==="allOf")continue;if(!(S in d))delete l[S]}if(g.$ref&&f.def)for(let S in l){if(S==="$ref"||S==="allOf")continue;if(S in f.def&&JSON.stringify(l[S])===JSON.stringify(f.def[S]))delete l[S]}}let m=a._zod.parent;if(m&&m!==p){o(m);let f=e.seen.get(m);if(f?.schema.$ref){if(l.$ref=f.schema.$ref,f.def)for(let g in l){if(g==="$ref"||g==="allOf")continue;if(g in f.def&&JSON.stringify(l[g])===JSON.stringify(f.def[g]))delete l[g]}}}e.override({zodSchema:a,jsonSchema:l,path:c.path??[]})};if(!e.external||e.sharedEmitDoneFor!==e.external){for(let a of[...e.seen.entries()].reverse())o(a[0]);if(e.target!=="openapi-3.0")for(let a of e.seen.entries())Kc(a[1].def??a[1].schema);for(let a of e.deferred)a();if(e.intersections.length){let a=new Map;for(let c of e.seen.values())for(let l of[c.schema,c.def]){let d=l?.allOf;if(!Array.isArray(d))continue;let p=a.get(d);if(p)p.push(l);else a.set(d,[l])}for(let c of e.intersections)for(let l of a.get(c)??[])cm(l)}}let r={};if(e.target==="draft-2020-12")r.$schema="https://json-schema.org/draft/2020-12/schema";else if(e.target==="draft-07")r.$schema="http://json-schema.org/draft-07/schema#";else if(e.target==="draft-04")r.$schema="http://json-schema.org/draft-04/schema#";else if(e.target==="openapi-3.0");if(e.external?.uri){let a=e.external.registry.get(t)?.id;if(!a)throw Error("Schema is missing an `id` property");r.$id=e.external.uri(a)}Tt(r,n.defId?n.schema:n.def??n.schema);let i=e.metadataRegistry.get(t)?.id;if(i!==void 0&&r.id===i)delete r.id;let s=e.external?.defs??{};if(!e.external||e.sharedEmitDoneFor!==e.external)for(let a of e.seen.entries()){let c=a[1];if(c.def&&c.defId){if(c.def.id===c.defId)delete c.def.id;te(s,c.defId,c.def)}}if(e.external)e.sharedEmitDoneFor=e.external;if(e.external);else if(Object.keys(s).length>0)if(e.target==="draft-2020-12")r.$defs=s;else r.definitions=s;try{let a=JSON.parse(JSON.stringify(r));return Object.defineProperty(a,"~standard",{value:{...t["~standard"],jsonSchema:{input:Ct(t,"input",e.processors),output:Ct(t,"output",e.processors)}},enumerable:!1,writable:!1}),a}catch(a){throw Error("Error converting schema to JSON.")}}function X(e,t){let n=t??{seen:new Set};if(n.seen.has(e))return!1;n.seen.add(e);let o=e._zod.def;if(o.type==="transform")return!0;if(o.type==="array")return X(o.element,n);if(o.type==="set")return X(o.valueType,n);if(o.type==="lazy")return X(o.getter(),n);if(o.type==="promise"||o.type==="optional"||o.type==="nonoptional"||o.type==="nullable"||o.type==="readonly"||o.type==="default"||o.type==="prefault"||o.type==="catch")return X(o.innerType,n);if(o.type==="intersection")return X(o.left,n)||X(o.right,n);if(o.type==="record"||o.type==="map")return X(o.keyType,n)||X(o.valueType,n);if(o.type==="pipe"){if(e._zod.traits.has("$ZodCodec"))return!0;return X(o.in,n)||X(o.out,n)}if(o.type==="object"){for(let r in o.shape)if(X(o.shape[r],n))return!0;return!1}if(o.type==="union"){for(let r of o.options)if(X(r,n))return!0;return!1}if(o.type==="tuple"){for(let r of o.items)if(X(r,n))return!0;if(o.rest&&X(o.rest,n))return!0;return!1}return!1}var Jc=(e,t={})=>(n)=>{let o=kt({...n,processors:t});return D(e,o),Et(o,e),Rt(o,e)},Ct=(e,t,n={})=>(o)=>{let{libraryOptions:r,target:i}=o??{},s=kt({...r??{},target:i,io:t,processors:n});return D(e,s),Et(s,e),Rt(s,e)};var Ve=(e,t,n)=>{if(e[t]===void 0||n>e[t])e[t]=n},qe=(e,t,n)=>{if(e[t]===void 0||n<e[t])e[t]=n},Yc=(e,t)=>{Ve(e,"minimum",t),qe(e,"maximum",t)},nu=(e,t)=>{if(e.multipleOf??(e.multipleOf=[]),!e.multipleOf.includes(t))e.multipleOf.push(t)},ou=(e,t)=>{e.patterns??(e.patterns=new Set),e.patterns.add(t)},ru=(e,t)=>{e.mime=e.mime?e.mime.filter((n)=>t.includes(n)):[...t]},iu=(e,t)=>{if(e.format=t,t.includes("int"))e.isInt=!0},Xc=(e,t)=>Ve(e,"minimum",t.minimum),Qc=(e,t)=>qe(e,"maximum",t.maximum),eu=(e)=>(t,n)=>{iu(t,n.format);let[o,r]=e[n.format];Ve(t,"minimum",o),qe(t,"maximum",r)},um={greater_than:(e,t)=>Ve(e,t.inclusive?"minimum":"exclusiveMinimum",t.value),less_than:(e,t)=>qe(e,t.inclusive?"maximum":"exclusiveMaximum",t.value),multiple_of:(e,t)=>nu(e,t.value),number_format:eu(Ut),bigint_format:eu(Un),min_length:Xc,max_length:Qc,length_equals:(e,t)=>Yc(e,t.length),min_size:Xc,max_size:Qc,size_equals:(e,t)=>Yc(e,t.size),string_format:(e,t)=>{if(iu(e,t.format),t.pattern)ou(e,t.pattern);if(t.format==="base64"||t.format==="base64url")e.contentEncoding=t.format;if(t.local||t.precision===-1)e.laxFormat=!0},mime_type:(e,t)=>ru(e,t.mime)};function W(e){let t={},n=e._zod.def,o=e._zod.traits.has("$ZodCheck")?[e,...n.checks??[]]:n.checks??[];for(let i of o)um[i._zod.def.check]?.(t,i._zod.def);let r=e._zod.bag;if(r.minimum!==void 0)Ve(t,"minimum",r.minimum);if(r.exclusiveMinimum!==void 0)Ve(t,"exclusiveMinimum",r.exclusiveMinimum);if(r.maximum!==void 0)qe(t,"maximum",r.maximum);if(r.exclusiveMaximum!==void 0)qe(t,"exclusiveMaximum",r.exclusiveMaximum);if(r.multipleOf!==void 0)nu(t,r.multipleOf);if(r.format!==void 0){if(t.format??(t.format=r.format),r.format.includes("int"))t.isInt=!0}if(r.mime)ru(t,r.mime);for(let i of r.patterns??[])ou(t,i);return t}var lm={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},dm=new Map([[co,ms],[Qt,fs]]),su=(e)=>dm.get(e)??e,Oo=(e,t,n,o)=>{let r=n;r.type="string";let{minimum:i,maximum:s,format:a,patterns:c,contentEncoding:l,laxFormat:d}=W(e);if(typeof i==="number")r.minLength=i;if(typeof s==="number")r.maxLength=s;if(a){if(r.format=lm[a]??a,r.format==="")delete r.format;if(a==="time"||d)delete r.format}if(l)r.contentEncoding=l;if(c&&c.size>0){let p=[...c].map(su);if(p.length===1)r.pattern=p[0].source;else if(p.length>1)r.allOf=[...p.map((m)=>({...t.target==="draft-07"||t.target==="draft-04"||t.target==="openapi-3.0"?{type:"string"}:{},pattern:m.source}))]}},zo=(e,t,n,o)=>{let r=n,{minimum:i,maximum:s,multipleOf:a,exclusiveMaximum:c,exclusiveMinimum:l,isInt:d}=W(e);r.type=d?"integer":"number";let p=typeof l==="number"&&l>=(i??Number.NEGATIVE_INFINITY),m=typeof c==="number"&&c<=(s??Number.POSITIVE_INFINITY),f=t.target==="draft-04"||t.target==="openapi-3.0";if(p)if(f)r.minimum=l,r.exclusiveMinimum=!0;else r.exclusiveMinimum=l;else if(typeof i==="number")r.minimum=i;if(m)if(f)r.maximum=c,r.exclusiveMaximum=!0;else r.exclusiveMaximum=c;else if(typeof s==="number")r.maximum=s;if(a){let g=new Set;for(let v of a)if(Number.isFinite(v)&&v!==0)g.add(Math.abs(v));else q(e,t,r,o,`A multipleOf divisor of ${v} cannot be represented in JSON Schema`);let[y,...S]=g;if(y!==void 0)r.multipleOf=y;if(S.length)r.allOf=[...r.allOf??[],...S.map((v)=>({multipleOf:v}))]}},No=(e,t,n,o)=>{n.type="boolean"},au=(e,t,n,o)=>{q(e,t,n,o,"BigInt cannot be represented in JSON Schema")},cu=(e,t,n,o)=>{q(e,t,n,o,"Symbols cannot be represented in JSON Schema")},uu=(e,t,n,o)=>{if(t.target==="openapi-3.0")n.type="string",n.nullable=!0,n.enum=[null];else n.type="null"},lu=(e,t,n,o)=>{q(e,t,n,o,"Undefined cannot be represented in JSON Schema")},$o=(e,t,n,o)=>{q(e,t,n,o,"Void cannot be represented in JSON Schema")},Lo=(e,t,n,o)=>{n.not={}},du=(e,t,n,o)=>{},Do=(e,t,n,o)=>{},Bo=(e,t,n,o)=>{q(e,t,n,o,"Date cannot be represented in JSON Schema")},Uo=(e,t,n,o)=>{let r=e._zod.def,i=pt(r.entries);if(i.length===0){n.not={};return}if(i.every((s)=>typeof s==="number"))n.type="number";if(i.every((s)=>typeof s==="string"))n.type="string";n.enum=i},Zo=(e,t,n,o)=>{let r=e._zod.def;if(r.values.length===0){n.not={};return}let i=[];for(let s of r.values)if(s===void 0){if(q(e,t,n,o,"Literal `undefined` cannot be represented in JSON Schema"))return}else if(typeof s==="bigint"){if(q(e,t,n,o,"BigInt literals cannot be represented in JSON Schema"))return;i.push(Number(s))}else i.push(s);if(i.length===0);else if(i.length===1){let s=i[0];if(n.type=s===null?"null":typeof s,t.target==="draft-04"||t.target==="openapi-3.0")n.enum=[s];else n.const=s}else{if(i.every((s)=>typeof s==="number"))n.type="number";if(i.every((s)=>typeof s==="string"))n.type="string";if(i.every((s)=>typeof s==="boolean"))n.type="boolean";if(i.every((s)=>s===null))n.type="null";n.enum=i}},pu=(e,t,n,o)=>{q(e,t,n,o,"NaN cannot be represented in JSON Schema")},mu=(e,t,n,o)=>{let r=n,i=e._zod.pattern;if(!i)throw Error("Pattern not found in template literal");r.type="string",r.pattern=i.source},fu=(e,t,n,o)=>{let r=n;r.type="string",r.format="binary",r.contentEncoding="binary";let{minimum:i,maximum:s,mime:a}=W(e);if(i!==void 0)r.minLength=i;if(s!==void 0)r.maxLength=s;if(!a)return;if(a.length===0)r.not={};else if(a.length===1)r.contentMediaType=a[0];else r.anyOf=a.map((c)=>({contentMediaType:c}))},gu=(e,t,n,o)=>{n.type="boolean"},Fo=(e,t,n,o)=>{q(e,t,n,o,"Custom types cannot be represented in JSON Schema")},Ho=(e,t,n,o)=>{q(e,t,n,o,"Function types cannot be represented in JSON Schema")},jo=(e,t,n,o)=>{q(e,t,n,o,"Transforms cannot be represented in JSON Schema")},hu=(e,t,n,o)=>{q(e,t,n,o,"Map cannot be represented in JSON Schema")},yu=(e,t,n,o)=>{q(e,t,n,o,"Set cannot be represented in JSON Schema")},Vo=(e,t,n,o)=>{let r=n,i=e._zod.def,{minimum:s,maximum:a}=W(e);if(typeof s==="number")r.minItems=s;if(typeof a==="number")r.maxItems=a;r.type="array",r.items=D(i.element,t,{...o,path:[...o.path,"items"]})};function At(e){let t=e._zod.def;if(t.type==="pipe"&&t.in._zod.traits.has("$ZodTransform"))return At(t.out);if(t.type==="catch")return At(t.innerType);return e._zod.optin}var qo=(e,t,n,o)=>{let r=n,i=e._zod.def,s=i.shape;if(Object.getOwnPropertySymbols(s).length&&q(e,t,r,o,"Symbol keys cannot be represented in JSON Schema"))return;r.type="object",r.properties={};for(let l in s)te(r.properties,l,D(s[l],t,{...o,path:[...o.path,"properties",l]}));let c=[];for(let l of Object.keys(s)){let d=i.shape[l];if(t.io==="input"?At(d)===void 0:d._zod.optout===void 0)c.push(l)}if(c.length>0)r.required=c;if(i.catchall?._zod.def.type==="never")r.additionalProperties=!1;else if(!i.catchall){if(t.io==="output")r.additionalProperties=!1}else if(i.catchall)r.additionalProperties=D(i.catchall,t,{...o,path:[...o.path,"additionalProperties"]})},Go=(e,t,n,o)=>{let r=e._zod.def,i=r.inclusive===!1,s=r.options.map((a,c)=>D(a,t,{...o,path:[...o.path,i?"oneOf":"anyOf",c]}));if(i)n.oneOf=s;else n.anyOf=s},Ko=(e,t,n,o)=>{let r=e._zod.def,i=D(r.left,t,{...o,path:[...o.path,"allOf",0]}),s=D(r.right,t,{...o,path:[...o.path,"allOf",1]}),a=(l)=>("allOf"in l)&&Object.keys(l).length===1,c=[...a(i)?i.allOf:[i],...a(s)?s.allOf:[s]];n.allOf=c,t.intersections.push(c)},Wo=(e,t,n,o)=>{let r=n,i=e._zod.def;r.type="array";let s=t.target==="draft-2020-12"?"prefixItems":"items",a=t.target==="draft-2020-12"?"items":t.target==="openapi-3.0"?"items":"additionalItems",c=i.items.map((y,S)=>D(y,t,{...o,path:[...o.path,s,S]})),l=i.rest?D(i.rest,t,{...o,path:[...o.path,a,...t.target==="openapi-3.0"?[i.items.length]:[]]}):null,d=i.items.length;while(d>0){let y=i.items[d-1];if(!(t.io==="input"?At(y)!==void 0:y._zod.optout==="optional"))break;d--}let p=i.items.length,m=!i.rest;if(t.target==="draft-2020-12"){if(r.prefixItems=c,m)r.items=!1;else if(l)r.items=l;if(d>0)r.minItems=d;if(m)r.maxItems=p}else if(t.target==="openapi-3.0"){if(r.items={anyOf:c},l)r.items.anyOf.push(l);if(d>0)r.minItems=d;if(m)r.maxItems=p}else{if(r.items=c,m)r.additionalItems=!1;else if(l)r.additionalItems=l;if(d>0)r.minItems=d;if(m)r.maxItems=p}let{minimum:f,maximum:g}=W(e);if(typeof f==="number")r.minItems=f;if(typeof g==="number")r.maxItems=g};function Po(e,t,n){if(t.$ref){if(n.has(t))return t;n.add(t);let g=e.get(t)?.def;if(!g)return t;let y=Po(e,g,n);return y===g?t:y}for(let g of["anyOf","oneOf"]){let y=t[g];if(!Array.isArray(y))continue;let S=y.map((v)=>Po(e,v,n));if(S.some((v,k)=>v!==y[k]))t={...t,[g]:S}}let o=Array.isArray(t.type)?t.type:[t.type],r=!o.includes("string")&&o.some((g)=>g==="number"||g==="integer"),i=t.enum??(t.const!==void 0?[t.const]:void 0);if(!r&&!i?.some((g)=>typeof g==="number"))return t;let{minimum:s,maximum:a,exclusiveMinimum:c,exclusiveMaximum:l,multipleOf:d,format:p,id:m,...f}=t;if(f.enum)f.enum=f.enum.map((g)=>typeof g==="number"?String(g):g);else if(typeof f.const==="number")f.const=String(f.const);if(!r)return f;if(f.type="string",!i)f.pattern=(o.includes("number")?xt:to).source;return f}var Mo=new WeakMap;function pm(e){let t=new Map;for(let o of e.seen.values())if(o.def&&!t.has(o.schema))t.set(o.schema,o);let n=new Map;for(let o of Mo.get(e)??[]){let r=e.seen.get(o),i=(r?.def??r?.schema)?.propertyNames;if(!i||i===!0||n.has(i))continue;let s=Po(t,i,new Set);if(s!==i)n.set(i,s)}if(!n.size)return;for(let o of e.seen.values())for(let r of[o.schema,o.def]){let i=r&&n.get(r.propertyNames);if(i)r.propertyNames=i}}var Jo=(e,t,n,o)=>{let r=n,i=e._zod.def;r.type="object";let s=i.keyType,a=W(s).patterns;if(i.mode==="loose"&&a&&a.size>0){let d=D(i.valueType,t,{...o,path:[...o.path,"patternProperties","*"]});r.patternProperties={};for(let p of a)te(r.patternProperties,su(p).source,d)}else{if(t.target==="draft-07"||t.target==="draft-2020-12"){r.propertyNames=D(i.keyType,t,{...o,path:[...o.path,"propertyNames"]});let d=Mo.get(t);if(!d)d=[],Mo.set(t,d),t.deferred.push(()=>pm(t));d.push(e)}r.additionalProperties=D(i.valueType,t,{...o,path:[...o.path,"additionalProperties"]})}let c=s._zod.values,l=t.io==="input"&&At(i.valueType)!==void 0;if(c&&!i.partial&&!l){let d=[...c].filter((p)=>typeof p==="string"||typeof p==="number");if(d.length>0)r.required=d.map(String)}},Yo=(e,t,n,o)=>{let r=e._zod.def,i=D(r.innerType,t,o),s=t.seen.get(e);if(t.target==="openapi-3.0")s.ref=r.innerType,n.nullable=!0;else n.anyOf=[i,{type:"null"}]},Xo=(e,t,n,o)=>{let r=e._zod.def;D(r.innerType,t,o);let i=t.seen.get(e);i.ref=r.innerType},Qo=Symbol();function bu(e,t,n,o,r){let i=!1,s=JSON.stringify(e,(a,c)=>{if(typeof c!=="bigint")return c;return i=!0,null});if(!i)return JSON.parse(s);return q(t,n,o,r,"BigInt defaults cannot be represented in JSON Schema"),Qo}var er=(e,t,n,o)=>{let r=e._zod.def;D(r.innerType,t,o);let i=t.seen.get(e);i.ref=r.innerType;let s=bu(r.defaultValue,e,t,n,o);if(s!==Qo)n.default=s},tr=(e,t,n,o)=>{let r=e._zod.def;D(r.innerType,t,o);let i=t.seen.get(e);if(i.ref=r.innerType,t.io!=="input")return;let s=bu(r.defaultValue,e,t,n,o);if(s!==Qo)n._prefault=s},nr=(e,t,n,o)=>{let r=e._zod.def;D(r.innerType,t,o);let i=t.seen.get(e);i.ref=r.innerType;let s;try{s=r.catchValue(void 0)}catch{q(e,t,n,o,"Dynamic catch values are not supported in JSON Schema");return}n.default=s},or=(e,t,n,o)=>{let r=e._zod.def,i=r.in._zod.traits.has("$ZodTransform"),s=t.io==="input"?i?r.out:r.in:r.out;D(s,t,o);let a=t.seen.get(e);a.ref=s},rr=(e,t,n,o)=>{let r=e._zod.def;D(r.innerType,t,o);let i=t.seen.get(e);i.ref=r.innerType,n.readOnly=!0},ir=(e,t,n,o)=>{let r=e._zod.def;D(r.innerType,t,o);let i=t.seen.get(e);i.ref=r.innerType},ln=(e,t,n,o)=>{let r=e._zod.def;D(r.innerType,t,o);let i=t.seen.get(e);i.ref=r.innerType},xu=(e,t,n,o)=>{let r=e._zod.innerType;D(r,t,o);let i=t.seen.get(e);i.ref=r},tu={string:Oo,number:zo,boolean:No,bigint:au,symbol:cu,null:uu,undefined:lu,void:$o,never:Lo,any:du,unknown:Do,date:Bo,enum:Uo,literal:Zo,nan:pu,template_literal:mu,file:fu,success:gu,custom:Fo,function:Ho,transform:jo,map:hu,set:yu,array:Vo,object:qo,union:Go,intersection:Ko,tuple:Wo,record:Jo,nullable:Yo,nonoptional:Xo,default:er,prefault:tr,catch:nr,pipe:or,readonly:rr,promise:ir,optional:ln,lazy:xu};function Su(e,t){if("_idmap"in e){let o=e,r=kt({...t,processors:tu}),i={};for(let c of o._idmap.entries()){let[l,d]=c;D(d,r)}let s={},a={registry:o,uri:t?.uri,defs:i};r.external=a;for(let c of o._idmap.entries()){let[l,d]=c;Et(r,d),te(s,l,Rt(r,d))}if(Object.keys(i).length>0){let c=r.target==="draft-2020-12"?"$defs":"definitions";s.__shared={[c]:i}}return{schemas:s}}let n=kt({...t,processors:tu});return D(e,n),Et(n,e),Rt(n,e)}var _u=new WeakSet([Object.prototype,Error.prototype]);function pn(e,t,n){Object.defineProperty(e,t,{configurable:!0,enumerable:!1,get(){let o=n(this);return Object.defineProperty(this,t,{value:o,configurable:!0,writable:!0}),o},set(o){Object.defineProperty(this,t,{value:o,configurable:!0,writable:!0})}})}var _m=(e,t)=>{Zi.init(e,t),e.name="ZodError";let n=Object.getPrototypeOf(e);if(_u.has(n))return;_u.add(n),pn(n,"format",(o)=>(r)=>Kn(o,r)),pn(n,"flatten",(o)=>(r)=>Gn(o,r)),pn(n,"addIssue",(o)=>(r)=>{o.issues.push(r),o.message=JSON.stringify(o.issues,mt,2)}),pn(n,"addIssues",(o)=>(r)=>{o.issues.push(...r),o.message=JSON.stringify(o.issues,mt,2)}),Object.defineProperty(n,"isEmpty",{configurable:!0,enumerable:!1,get(){return this.issues.length===0}})};var oe=h("ZodError",_m,void 0,{Parent:Error});var vu=yt(oe),Tu=bt(oe),Cu=qt(oe),ku=Gt(oe),Eu=ji(oe),Ru=Vi(oe),Au=qi(oe),Iu=Gi(oe),wu=Ki(oe),Pu=Wi(oe),Mu=Ji(oe),Ou=Yi(oe);function Tm(){if(!Y.localeError)Q(bo())}function It(){if(!Y.memoizer)Q({memoizer:yo()})}var N=h("ZodType",(e,t)=>(Tm(),z.init(e,t),e.def=t,e.type=t.type,e),{check(...e){let t=this.def;return this.clone(ne(t,{checks:[...t.checks??[],...e.map((n)=>typeof n==="function"?{_zod:{check:n,def:{check:"custom"},onattach:[]}}:n)]}),{parent:!0})},with(...e){return this.check(...e)},clone(e,t){return ue(this,e,t)},brand(){return this},register(e,t){return e.add(this,t),this},refine(e,t){return this.check(kf(e,t))},superRefine(e,t){return this.check(Ef(e,t))},overwrite(e){return this.check(Ae(e))},optional(){return $u(this)},exactOptional(){return df(this)},nullable(){return Lu(this)},nullish(){return $u(Lu(this))},nonoptional(e){return yf(this,e)},array(){return E(this)},or(e){return Ge([this,e])},and(e){return sf(this,e)},transform(e){return Du(this,Fu(e))},default(e){return ff(this,e)},prefault(e){return hf(this,e)},catch(e){return xf(this,e)},pipe(e){return Du(this,e)},readonly(){return vf(this)},describe(e){let t=this.clone();return Re.add(t,{description:e}),t},meta(...e){if(e.length===0)return Re.get(this);let t=this.clone();return Re.add(t,e[0]),t},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(e,...t){return t.length===0?e(this):e(this,...t)},get "~standard"(){return jt(this,"~standard",{...ao(this),jsonSchema:{input:Ct(this,"input"),output:Ct(this,"output")}})},set "~standard"(e){xe(this,"~standard",e)},parse:function e(t,n){return vu(this,t,n,{callee:e})},parseAsync:async function e(t,n){return await Tu(this,t,n,{callee:e})},safeParse(e,t){return Cu(this,e,t)},async safeParseAsync(e,t){return ku(this,e,t)},get spa(){return this?.safeParseAsync},set spa(e){xe(this,"spa",e)},validate(e,t){return Yn(this,e,t)},validateAsync(e,t){return Xn(this,e,t)},encode:function e(t,n){return Eu(this,t,n,{callee:e})},decode:function e(t,n){return Ru(this,t,n,{callee:e})},encodeAsync:async function e(t,n){return await Au(this,t,n,{callee:e})},decodeAsync:async function e(t,n){return await Iu(this,t,n,{callee:e})},safeEncode(e,t){return wu(this,e,t)},safeDecode(e,t){return Pu(this,e,t)},async safeEncodeAsync(e,t){return Mu(this,e,t)},async safeDecodeAsync(e,t){return Ou(this,e,t)},toJSONSchema(e){return Jc(this,{})(e)},get description(){return Re.get(this)?.description},get _def(){return this._zod.def}}),Bu=h("_ZodString",(e,t)=>{Xt.init(e,t),N.init(e,t),e._zod.processJSONSchema=(n,o,r)=>Oo(e,n,o,r)},Fn({format:(e)=>W(e).format??null,minLength:(e)=>W(e).minimum??null,maxLength:(e)=>W(e).maximum??null},{regex(...e){return this.check(xo(...e))},includes(...e){return this.check(vo(...e))},startsWith(...e){return this.check(To(...e))},endsWith(...e){return this.check(Co(...e))},min(...e){return this.check(je(...e))},max(...e){return this.check(cn(...e))},length(...e){return this.check(un(...e))},nonempty(...e){return this.check(je(1,...e))},lowercase(e){return this.check(So(e))},uppercase(e){return this.check(_o(e))},trim(){return this.check(Eo())},normalize(...e){return this.check(ko(...e))},toLowerCase(){return this.check(Ro())},toUpperCase(){return this.check(Ao())},slugify(){return this.check(Io())}})),Cm=h("ZodString",(e,t)=>{Xt.init(e,t),Bu.init(e,t)},{email(e){return this.check(cc(Im,e))},url(e){return this.check(fc(Pm,e))},jwt(e){return this.check(Ic(qm,e))},emoji(e){return this.check(gc(Mm,e))},guid(e){return this.check(uc(wm,e))},uuid(e){return this.check(lc(mn,e))},uuidv4(e){return this.check(dc(mn,e))},uuidv6(e){return this.check(pc(mn,e))},uuidv7(e){return this.check(mc(mn,e))},nanoid(e){return this.check(hc(Om,e))},cuid(e){return this.check(yc(zm,e))},cuid2(e){return this.check(bc(Nm,e))},ulid(e){return this.check(xc($m,e))},base64(e){return this.check(Ec(Hm,e))},base64url(e){return this.check(Rc(jm,e))},xid(e){return this.check(Sc(Lm,e))},ksuid(e){return this.check(_c(Dm,e))},ipv4(e){return this.check(vc(Bm,e))},ipv6(e){return this.check(Tc(Um,e))},cidrv4(e){return this.check(Cc(Zm,e))},cidrv6(e){return this.check(kc(Fm,e))},e164(e){return this.check(Ac(Vm,e))},datetime(e){return this.check(wc(km,e))},date(e){return this.check(Pc(Em,e))},time(e){return this.check(Mc(Rm,e))},duration(e){return this.check(Oc(Am,e))}});function u(e){return ac(Cm,e)}var F=h("ZodStringFormat",(e,t)=>{U.init(e,t),Bu.init(e,t)}),km=h("ZodISODateTime",(e,t)=>{pa.init(e,t),F.init(e,t)}),Em=h("ZodISODate",(e,t)=>{ma.init(e,t),F.init(e,t)}),Rm=h("ZodISOTime",(e,t)=>{fa.init(e,t),F.init(e,t)}),Am=h("ZodISODuration",(e,t)=>{ga.init(e,t),F.init(e,t)}),Im=h("ZodEmail",(e,t)=>{ta.init(e,t),F.init(e,t)});var wm=h("ZodGUID",(e,t)=>{Qs.init(e,t),F.init(e,t)});var mn=h("ZodUUID",(e,t)=>{ea.init(e,t),F.init(e,t)});var Pm=h("ZodURL",(e,t)=>{ra.init(e,t),F.init(e,t)});var Mm=h("ZodEmoji",(e,t)=>{ia.init(e,t),F.init(e,t)});var Om=h("ZodNanoID",(e,t)=>{sa.init(e,t),F.init(e,t)});var zm=h("ZodCUID",(e,t)=>{aa.init(e,t),F.init(e,t)});var Nm=h("ZodCUID2",(e,t)=>{ca.init(e,t),F.init(e,t)});var $m=h("ZodULID",(e,t)=>{ua.init(e,t),F.init(e,t)});var Lm=h("ZodXID",(e,t)=>{la.init(e,t),F.init(e,t)});var Dm=h("ZodKSUID",(e,t)=>{da.init(e,t),F.init(e,t)});var Bm=h("ZodIPv4",(e,t)=>{ha.init(e,t),F.init(e,t)});var Um=h("ZodIPv6",(e,t)=>{ba.init(e,t),F.init(e,t)});var Zm=h("ZodCIDRv4",(e,t)=>{xa.init(e,t),F.init(e,t)});var Fm=h("ZodCIDRv6",(e,t)=>{Sa.init(e,t),F.init(e,t)});var Hm=h("ZodBase64",(e,t)=>{va.init(e,t),F.init(e,t)});var jm=h("ZodBase64URL",(e,t)=>{Ta.init(e,t),F.init(e,t)});var Vm=h("ZodE164",(e,t)=>{Ca.init(e,t),F.init(e,t)});var qm=h("ZodJWT",(e,t)=>{ka.init(e,t),F.init(e,t)});var Uu=h("ZodNumber",(e,t)=>{uo.init(e,t),N.init(e,t),e._zod.processJSONSchema=(n,o,r)=>zo(e,n,o,r),e.isFinite=!0},Fn({minValue:(e)=>{let{minimum:t,exclusiveMinimum:n}=W(e);return Math.max(t??Number.NEGATIVE_INFINITY,n??Number.NEGATIVE_INFINITY)},maxValue:(e)=>{let{maximum:t,exclusiveMaximum:n}=W(e);return Math.min(t??Number.POSITIVE_INFINITY,n??Number.POSITIVE_INFINITY)},isInt:(e)=>{let{isInt:t,multipleOf:n}=W(e);return!!t||!!n?.some(Number.isSafeInteger)},format:(e)=>W(e).format??null},{gt(e,t){return this.check(sn(e,t))},gte(e,t){return this.check(He(e,t))},min(e,t){return this.check(He(e,t))},lt(e,t){return this.check(rn(e,t))},lte(e,t){return this.check(Fe(e,t))},max(e,t){return this.check(Fe(e,t))},int(e){return this.check(zu(e))},safe(e){return this.check(zu(e))},positive(e){return this.check(sn(0,e))},nonnegative(e){return this.check(He(0,e))},negative(e){return this.check(rn(0,e))},nonpositive(e){return this.check(Fe(0,e))},multipleOf(e,t){return this.check(an(e,t))},step(e,t){return this.check(an(e,t))},finite(){return this}}));function x(e){return zc(Uu,e)}var Gm=h("ZodNumberFormat",(e,t)=>{Ea.init(e,t),Uu.init(e,t)});function zu(e){return Nc(Gm,e)}var Km=h("ZodBoolean",(e,t)=>{Ra.init(e,t),N.init(e,t),e._zod.processJSONSchema=(n,o,r)=>No(e,n,o,r)});function w(e){return $c(Km,e)}var Wm=h("ZodUnknown",(e,t)=>{Aa.init(e,t),N.init(e,t),e._zod.processJSONSchema=(n,o,r)=>Do(e,n,o,r)});function K(){return Lc(Wm)}var Jm=h("ZodNever",(e,t)=>{Ia.init(e,t),N.init(e,t),e._zod.processJSONSchema=(n,o,r)=>Lo(e,n,o,r)});function Ym(e){return Dc(Jm,e)}var Xm=h("ZodVoid",(e,t)=>{wa.init(e,t),N.init(e,t),e._zod.processJSONSchema=(n,o,r)=>$o(e,n,o,r)});function Qm(e){return Bc(Xm,e)}var ef=h("ZodDate",(e,t)=>{Pa.init(e,t),N.init(e,t),e._zod.processJSONSchema=(n,o,r)=>Bo(e,n,o,r),e.min=(n,o)=>e.check(He(n,o)),e.max=(n,o)=>e.check(Fe(n,o))},Fn({minDate:(e)=>{let{minimum:t}=W(e);return t?new Date(t):null},maxDate:(e)=>{let{maximum:t}=W(e);return t?new Date(t):null}},{}));function fn(e){return Uc(ef,e)}var tf=h("ZodArray",(e,t)=>{It(),Ma.init(e,t),N.init(e,t),e._zod.processJSONSchema=(n,o,r)=>Vo(e,n,o,r),e.element=t.element},{min(e,t){return this.check(je(e,t))},nonempty(e){return this.check(je(1,e))},max(e,t){return this.check(cn(e,t))},length(e,t){return this.check(un(e,t))},unwrap(){return this.element}});function E(e,t){return Zc(tf,e,t)}var nf=h("ZodObject",(e,t)=>{It(),Na.init(e,t),N.init(e,t),e._zod.processJSONSchema=(n,o,r)=>qo(e,n,o,r),Ip(e,"shape",(n)=>n._zod.def.shape,!1)},{keyof(){return I(Object.keys(this._zod.def.shape))},catchall(e){return this.clone(ne(this._zod.def,{catchall:e}))},passthrough(){return this.clone(ne(this._zod.def,{catchall:K()}))},loose(){return this.clone(ne(this._zod.def,{catchall:K()}))},strict(){return this.clone(ne(this._zod.def,{catchall:Ym()}))},strip(){return this.clone(ne(this._zod.def,{catchall:void 0}))},extend(e){return _p(this,e)},safeExtend(e){return vp(this,e)},merge(e){return Tp(this,e)},pick(e){return xp(this,e)},omit(e){return Sp(this,e)},partial(...e){return Mi(cr,this,e[0])},exactPartial(...e){return Mi(Hu,this,e[0],"exactPartial")},required(...e){return Cp(ju,this,e[0])}});function b(e,t){let n={type:"object",shape:e??{},..._(t)};return new nf(n)}var Zu=h("ZodUnion",(e,t)=>{lo.init(e,t),N.init(e,t),e._zod.processJSONSchema=(n,o,r)=>Go(e,n,o,r),e.options=t.options});function Ge(e,t){return new Zu({type:"union",options:e,..._(t)})}var of=h("ZodDiscriminatedUnion",(e,t)=>{Zu.init(e,t),$a.init(e,t)});function ar(e,t,n){return new of({type:"union",options:t,discriminator:e,..._(n)})}var rf=h("ZodIntersection",(e,t)=>{La.init(e,t),N.init(e,t),e._zod.processJSONSchema=(n,o,r)=>Ko(e,n,o,r)});function sf(e,t){return new rf({type:"intersection",left:e,right:t})}var af=h("ZodTuple",(e,t)=>{It(),po.init(e,t),N.init(e,t),e._zod.processJSONSchema=(n,o,r)=>Wo(e,n,o,r)},{rest(e){return this.clone({...this._zod.def,rest:e})},partial(){let e=this._zod.def;if(e.checks?.length)throw Error(".partial() cannot be used on tuple schemas containing refinements");return this.clone({...e,items:e.items.map((t)=>new cr({type:"optional",innerType:t}))})}});function cf(e,t,n){let o=t instanceof z,r=o?n:t;return new af({type:"tuple",items:e,rest:o?t:null,..._(r)})}var Nu=h("ZodRecord",(e,t)=>{It(),Da.init(e,t),N.init(e,t),e._zod.processJSONSchema=(n,o,r)=>Jo(e,n,o,r),e.keyType=t.keyType,e.valueType=t.valueType});function j(e,t,n){if(!t||!t._zod)return new Nu({type:"record",keyType:u(),valueType:e,..._(t)});return new Nu({type:"record",keyType:e,valueType:t,..._(n)})}var sr=h("ZodEnum",(e,t)=>{Ba.init(e,t),N.init(e,t),e._zod.processJSONSchema=(o,r,i)=>Uo(e,o,r,i),e.enum=t.entries,e.options=[...e._zod.values];let n=new Set(Object.keys(t.entries));e.extract=(o,r)=>{let i={};for(let s of o)if(n.has(s))i[s]=t.entries[s];else throw Error(`Key ${s} not found in enum`);return new sr({...t,checks:[],..._(r),entries:i})},e.exclude=(o,r)=>{let i={...t.entries};for(let s of o)if(n.has(s))delete i[s];else throw Error(`Key ${s} not found in enum`);return new sr({...t,checks:[],..._(r),entries:i})}});function I(e,t){let n=Array.isArray(e)?Object.fromEntries(e.map((o)=>[o,o])):e;return new sr({type:"enum",entries:n,..._(t)})}var uf=h("ZodLiteral",(e,t)=>{Ua.init(e,t),N.init(e,t),e._zod.processJSONSchema=(n,o,r)=>Zo(e,n,o,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 V(e,t){return new uf({type:"literal",values:Array.isArray(e)?e:[e],..._(t)})}var lf=h("ZodTransform",(e,t)=>{It(),Za.init(e,t),N.init(e,t),e._zod.processJSONSchema=(n,o,r)=>jo(e,n,o,r),e._zod.parse=(n,o)=>{if(o.direction==="backward")throw new ht(e.constructor.name);n.addIssue=(i)=>{if(typeof i==="string")n.issues.push(Ne(i,n.value,t));else{let s=i;if(s.fatal)s.continue=!1;if(s.code??(s.code="custom"),!("input"in s))s.input=n.value;s.inst??(s.inst=e),n.issues.push(Ne(s))}};let r=t.transform(n.value,n);if(r instanceof Promise)return r.then((i)=>(n.value=i,n));return n.value=r,n}});function Fu(e){return new lf({type:"transform",transform:e})}var cr=h("ZodOptional",(e,t)=>{mo.init(e,t),N.init(e,t),e._zod.processJSONSchema=(n,o,r)=>ln(e,n,o,r),e.unwrap=()=>e._zod.def.innerType});function $u(e){return new cr({type:"optional",innerType:e})}var Hu=h("ZodExactOptional",(e,t)=>{Fa.init(e,t),N.init(e,t),e._zod.processJSONSchema=(n,o,r)=>ln(e,n,o,r),e.unwrap=()=>e._zod.def.innerType});function df(e){return new Hu({type:"optional",innerType:e})}var pf=h("ZodNullable",(e,t)=>{Ha.init(e,t),N.init(e,t),e._zod.processJSONSchema=(n,o,r)=>Yo(e,n,o,r),e.unwrap=()=>e._zod.def.innerType});function Lu(e){return new pf({type:"nullable",innerType:e})}var mf=h("ZodDefault",(e,t)=>{ja.init(e,t),N.init(e,t),e._zod.processJSONSchema=(n,o,r)=>er(e,n,o,r),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function ff(e,t){return new mf({type:"default",innerType:e,get defaultValue(){return typeof t==="function"?t():Dn(t)}})}var gf=h("ZodPrefault",(e,t)=>{Va.init(e,t),N.init(e,t),e._zod.processJSONSchema=(n,o,r)=>tr(e,n,o,r),e.unwrap=()=>e._zod.def.innerType});function hf(e,t){return new gf({type:"prefault",innerType:e,get defaultValue(){return typeof t==="function"?t():Dn(t)}})}var ju=h("ZodNonOptional",(e,t)=>{qa.init(e,t),N.init(e,t),e._zod.processJSONSchema=(n,o,r)=>Xo(e,n,o,r),e.unwrap=()=>e._zod.def.innerType});function yf(e,t){return new ju({type:"nonoptional",innerType:e,..._(t)})}var bf=h("ZodCatch",(e,t)=>{Ga.init(e,t),N.init(e,t),e._zod.processJSONSchema=(n,o,r)=>nr(e,n,o,r),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function xf(e,t){return new bf({type:"catch",innerType:e,catchValue:typeof t==="function"?t:$i(t)})}var Vu=h("ZodPipe",(e,t)=>{fo.init(e,t),N.init(e,t),e._zod.processJSONSchema=(n,o,r)=>or(e,n,o,r),e.in=t.in,e.out=t.out});function Du(e,t){return new Vu({type:"pipe",in:e,out:t})}var Sf=h("ZodPreprocess",(e,t)=>{Vu.init(e,t),Ka.init(e,t)}),_f=h("ZodReadonly",(e,t)=>{Wa.init(e,t),N.init(e,t),e._zod.processJSONSchema=(n,o,r)=>rr(e,n,o,r),e.unwrap=()=>e._zod.def.innerType});function vf(e){return new _f({type:"readonly",innerType:e})}var Tf=h("ZodPromise",(e,t)=>{Ya.init(e,t),N.init(e,t),e._zod.processJSONSchema=(n,o,r)=>ir(e,n,o,r),e.unwrap=()=>e._zod.def.innerType});function ur(e){return new Tf({type:"promise",innerType:e})}var Cf=h("ZodFunction",(e,t)=>{Ja.init(e,t),N.init(e,t),e._zod.processJSONSchema=(n,o,r)=>Ho(e,n,o,r)});function gn(e){return new Cf({type:"function",input:Array.isArray(e?.input)?cf(e?.input):e?.input??E(K()),output:e?.output??K()})}var qu=h("ZodCustom",(e,t)=>{Xa.init(e,t),N.init(e,t),e._zod.processJSONSchema=(n,o,r)=>Fo(e,n,o,r)});function se(e,t){return Fc(qu,e??(()=>!0),t)}function kf(e,t={}){return Hc(qu,e,t)}function Ef(e,t){return jc(e,t)}function Gu(e,t){return new Sf({type:"pipe",in:Fu(e),out:t})}var hn=["none","minimal","low","medium","high","xhigh","max"],lr=I(hn),yn=lr.exclude(["none"]),Rf=I([...hn,"default"]).nullable(),dr=ar("type",[b({type:V("toggle")}).strict(),b({type:V("effort"),values:E(Rf)}).strict(),b({type:V("budget_tokens"),min:x().min(-1).optional(),max:x().min(0).optional()}).strict().refine((e)=>e.min===void 0||e.max===void 0||e.min<=e.max,{message:"Minimum reasoning budget cannot exceed maximum",path:["min"]})]);var Ku=I(["default","openai-responses","r1"]),Af={DEFAULT:"default",OPENAI_RESPONSES:"openai-responses",R1:"r1"},Wu=I(["images","video","tools","streaming","prompt-cache","reasoning","reasoning-effort","computer-use","global-endpoint","structured_output","temperature","files"]),Ju=I(["active","preview","deprecated","legacy"]),Yu=b({input:x().optional(),output:x().optional(),cacheWrite:x().optional(),cacheRead:x().optional()}),Xu=b({maxBudget:x().optional(),outputPrice:x().optional(),thinkingLevel:I(["low","high"]).optional()}),Qu=b({reasoningDefaultOn:w().optional(),apiProtocol:I(["openai-chat","openai-responses","anthropic","gemini"]).optional()}).catchall(K()),pr=I(["text","image","audio","video","pdf"]),el=b({input:E(pr),output:E(pr)});function tl(e){return(e?.input===void 0||e.input.includes("text"))&&(e?.output===void 0||e.output.includes("text"))}var nl=I(["language","image-generation","speech-generation","video-generation","transcription","realtime"]);function If(e){let t=e.modalities?.input,n=e.modalities?.output;return t?.length===1&&t[0]==="audio"&&n?.length===1&&n[0]==="text"}function wf(e){return(e.operation===void 0||e.operation==="language")&&tl(e.modalities)}var ol=I(["batch","streaming"]);function Pf(e){return e.modalities?.input.includes("text")===!0&&e.modalities.output.includes("image")}function Mf(e){return e.operation==="image-generation"}function mr(e,t,n){let o=e.capabilities;if(o===void 0||o.length===0)return n?.assumeWhenUnspecified??!1;return o.includes(t)}function Of(e){return mr(e,"tools",{assumeWhenUnspecified:!0})}function zf(e){return mr(e,"images",{assumeWhenUnspecified:!0})}var bn=b({id:u(),name:u().optional(),description:u().optional(),maxTokens:x().optional(),contextWindow:x().optional(),maxInputTokens:x().optional(),capabilities:E(Wu).optional(),operation:nl.optional(),operationModes:E(ol).optional(),modalities:el.optional(),reasoningOptions:E(dr).optional(),apiFormat:Ku.optional(),systemRole:I(["system","developer"]).optional(),temperature:x().optional(),pricing:Yu.optional(),thinkingConfig:Xu.optional(),status:Ju.optional(),deprecationNotice:u().optional(),replacedBy:u().optional(),releaseDate:u().optional(),deprecationDate:u().optional(),family:u().optional(),metadata:Qu.optional()});var Nf="This tool call was rejected by the user and not executed.",$f="NOT a tool or system failure. Clarify with user before proceeding.",fr=b({id:u(),name:u(),execution:I(["client","provider"]).optional(),input:K(),output:K(),error:u().optional(),durationMs:x(),startedAt:fn(),endedAt:fn()});var Lf=I(["completed","max_iterations","aborted","mistake_limit","error"]),Df=b({inputTokens:x(),outputTokens:x(),cacheReadTokens:x().optional(),cacheWriteTokens:x().optional(),totalCost:x().optional()}),iv=b({text:u(),usage:Df,messages:E(se()),toolCalls:E(fr),iterations:x(),finishReason:Lf,model:b({id:u(),provider:u(),info:bn.optional()}),startedAt:fn(),endedAt:fn(),durationMs:x()}),sv=b({distinctId:u().optional(),sessionId:u().optional(),providerId:u(),modelId:u(),apiKey:u().optional(),baseUrl:u().url().optional(),headers:j(u(),u()).optional(),knownModels:j(u(),bn).optional(),providerConfig:K().optional(),initialMessages:E(se()).optional(),systemPrompt:u(),tools:E(se()),modelTools:E(se()).optional(),maxIterations:x().positive().optional(),maxParallelToolCalls:x().int().positive().default(8),maxTokensPerTurn:x().positive().optional(),temperature:x().nonnegative().optional(),apiTimeoutMs:x().positive().default(180000),userFileContentLoader:gn().input([u()]).output(ur(u())).optional(),toolContextMetadata:j(u(),K()).optional(),execution:b({maxConsecutiveMistakes:x().int().positive().optional(),reminderAfterIterations:x().nonnegative().optional(),reminderText:u().optional(),loopDetection:Ge([V(!1),b({softThreshold:x().int().positive().optional(),hardThreshold:x().int().positive().optional()})]).optional()}).optional(),reasoningEffort:yn.optional(),thinkingBudgetTokens:x().positive().optional(),thinking:w().optional(),onEvent:gn().input([se()]).output(Qm()).optional(),hooks:se().optional(),parentAgentId:u().optional(),extensions:E(se()).optional(),hookErrorMode:I(["ignore","throw"]).default("ignore"),toolPolicies:j(u(),b({enabled:w().optional(),autoApprove:w().optional()})).optional(),requestToolApproval:gn().input([b({sessionId:u(),agentId:u(),conversationId:u(),iteration:x(),toolCallId:u(),toolName:u(),input:K(),policy:b({enabled:w().optional(),autoApprove:w().optional()}).default({})})]).output(Ge([b({approved:w(),reason:u().optional()}),ur(b({approved:w(),reason:u().optional()}))])).optional(),onConsecutiveMistakeLimitReached:gn().input([b({iteration:x().int().positive(),consecutiveMistakes:x().int().positive(),maxConsecutiveMistakes:x().int().positive(),reason:I(["api_error","invalid_tool_call","tool_execution_failed"]),details:u().optional()})]).output(Ge([b({action:V("continue"),guidance:u().optional()}),b({action:V("stop"),reason:u().optional()}),ur(Ge([b({action:V("continue"),guidance:u().optional()}),b({action:V("stop"),reason:u().optional()})]))])).optional(),logger:se().optional(),extensionContext:se().optional(),abortSignal:se().optional()});var rl=I(["connector.started","connector.stopping","session.authorize","message.received","message.denied","message.completed","message.failed","session.started","session.reused","session.reset","schedule.delivery.started","schedule.delivery.sent","schedule.delivery.failed"]),il=b({id:u().optional(),label:u().optional(),role:u().optional(),participantKey:u().optional(),participantLabel:u().optional(),platformUserId:u().optional(),metadata:j(u(),K()).optional()}),sl=b({source:u(),sourceEvent:u(),threadId:u(),channelId:u(),isDM:w(),sessionId:u().optional(),workspaceRoot:u().optional(),metadata:j(u(),K()).optional()}),Bf=b({actor:il,context:sl,payload:j(u(),K()).optional()}),Uf=b({action:I(["allow","deny"]).default("allow"),message:u().optional(),reason:u().optional(),metadata:j(u(),K()).optional()}),Zf=b({adapter:u(),botUserName:u().optional(),event:rl,payload:j(u(),K()),ts:u()});var al=[{name:"discord",description:"Discord interactions and gateway bridge backed by RPC runtime sessions"},{name:"gchat",description:"Google Chat webhook bridge backed by RPC runtime sessions"},{name:"linear",description:"Linear webhook bridge backed by RPC runtime sessions"},{name:"slack",description:"Slack webhook/socket bridge backed by RPC runtime sessions"},{name:"telegram",description:"Bridge Telegram bot messages into RPC chat sessions"},{name:"whatsapp",description:"Bridge WhatsApp webhook messages into RPC chat sessions"}];function cl(){return al.map((e)=>({...e}))}function ul(e,t){let n=e.includeWhen;if(!n)return!0;let o=t[n.flag]??"";if(n.equals!==void 0&&o!==n.equals)return!1;if(n.notEquals!==void 0&&o===n.notEquals)return!1;return!0}function Ff(e,t,n){let o={};for(let i of e.fields){let s=t[i.flag];o[i.flag]=typeof s==="string"?s.trim():i.initialValue??""}let r=[];for(let i of e.fields){if(!ul(i,o))continue;let s=o[i.flag]??"";if(!s){if(i.required)throw Error(`${i.label} is required`);continue}r.push(i.flag,s)}if(n?.enabled===!0&&e.security){let i={};for(let s of e.security.fields){let a=n.values[s.key]?.trim();if(!a)throw Error(s.requiredMessage);let c=s.validate?.(a);if(c)throw Error(c);i[s.key]=a}r.push(...e.security.buildArgs(i))}return r}function Hf(e,t){if(t.has(e))return{managed:!0,consumesNext:!0};for(let n of t)if(e.startsWith(`${n}=`))return{managed:!0,consumesNext:!1};return{managed:!1,consumesNext:!1}}function jf(e,t,n,o){let r=new Set([...e.fields.flatMap((s)=>[s.flag,...s.aliases??[]]),...e.derivedReconnectFlags??[]]);if(o.replaceSecurityArgs)for(let s of e.security?.argumentFlags??[])r.add(s);let i=[];for(let s=0;s<t.length;s+=1){let a=t[s]??"",c=Hf(a,r);if(!c.managed){i.push(a);continue}if(c.consumesNext)s+=1}return[...i,...n]}function Vf(e=ll){let t=new Set(cl().map((n)=>n.name));return e.filter((n)=>t.has(n.id)).map((n)=>({id:n.id,name:n.name,type:n.type,hint:n.hint,fields:n.fields.map((o)=>({flag:o.flag,label:o.label,placeholder:o.placeholder,required:o.required,help:o.help,initialValue:o.initialValue,options:o.options,includeWhen:o.includeWhen})),security:n.security?{prompt:n.security.prompt,fields:n.security.fields.map((o)=>({key:o.key,label:o.label,placeholder:o.placeholder,help:o.help,requiredMessage:o.requiredMessage}))}:void 0}))}function qf(e){return/^\d+$/.test(e)?void 0:"Telegram user ID must contain digits only"}function Gf(e){return/^T[A-Z0-9]+$/.test(e)?void 0:"Slack workspace ID must start with T and contain uppercase letters or digits only"}function Kf(e){return/^[UW][A-Z0-9]+$/.test(e)?void 0:"Slack member ID must start with U or W and contain uppercase letters or digits only"}var ll=[{id:"telegram",name:"Telegram",type:"polling",hint:"Easiest to set up. No public URL needed.",derivedReconnectFlags:["-m","--bot-username"],fields:[{flag:"-k",aliases:["--bot-token"],label:"Bot token",placeholder:"7123456789:AAH...",required:!0,help:["Open Telegram and start a chat with @BotFather","Send /newbot and follow the prompts","BotFather gives you this after creating the bot","It looks like 7123456789:AAHxxx..."]}],security:{prompt:"By default, anyone who finds your bot can message it and run tasks on your machine. Restrict access to your Telegram user ID?",fields:[{key:"userId",label:"Your Telegram user ID",placeholder:"123456789",help:["Message @userinfobot on Telegram","It will reply with your numeric user ID"],requiredMessage:"User ID is required to restrict access",validate:qf}],argumentFlags:["--allowed-user-id","--hook-command"],buildArgs:({userId:e})=>["--allowed-user-id",e??""]}},{id:"slack",name:"Slack",type:"hybrid",hint:"Public URL for webhook mode; leave blank for socket mode.",fields:[{flag:"--bot-token",label:"Bot token",placeholder:"xoxb-...",required:!0,help:["Go to api.slack.com/apps and create a new app","Add Bot Token Scopes: chat:write, app_mentions:read, channels:history, channels:read, im:history, im:read, im:write, users:read","Install to workspace and copy the Bot Token"]},{flag:"--base-url",label:"Public base URL",placeholder:"leave blank for socket mode",help:["Enter a publicly accessible URL for webhook mode","Leave blank to use Slack socket mode instead"]},{flag:"--signing-secret",label:"Signing secret",required:!0,help:["Found in your app's Basic Information page"],includeWhen:{flag:"--base-url",notEquals:""}},{flag:"--app-token",label:"App-level token",placeholder:"xapp-...",required:!0,help:["Enable Socket Mode in the Slack app","Generate an app-level token with the connections:write scope"],includeWhen:{flag:"--base-url",equals:""}}],security:{prompt:"Restrict which Slack users can interact with the bot?",fields:[{key:"teamId",label:"Allowed Slack workspace ID",placeholder:"T01ABC123",help:["Open your Slack workspace URL in a browser","The workspace ID is the segment after /client/, for example T01ABC123"],requiredMessage:"Workspace ID is required to restrict access",validate:Gf},{key:"userId",label:"Allowed Slack member ID",placeholder:"U01ABC123",help:["Click a user's name in Slack, then View full profile","Click ... and Copy member ID"],requiredMessage:"Member ID is required to restrict access",validate:Kf}],argumentFlags:["--hook-command"],buildArgs:({teamId:e,userId:t})=>["--hook-command",`jq -r ".payload.actor.participantKey" | grep -qx "slack:team:${e}:user:${t}" && echo '{"action":"allow"}' || echo '{"action":"deny"}'`]}},{id:"discord",name:"Discord",type:"webhook",hint:"Requires a Discord app and public URL.",fields:[{flag:"--application-id",aliases:["--app-id"],label:"Application ID",required:!0,help:["Go to discord.com/developers/applications","Create a new app, copy the Application ID"]},{flag:"--bot-token",aliases:["--token"],label:"Bot token",required:!0,help:["Go to Bot section, create a bot, copy the token"]},{flag:"--public-key",label:"Public key",required:!0,help:["Found in General Information of your app"]},{flag:"--base-url",label:"Public base URL",placeholder:"https://example.com",required:!0,help:["Base URL for the connector","For Discord, set the Interactions Endpoint URL to <base-url>/api/webhooks/discord"]}]},{id:"whatsapp",name:"WhatsApp",type:"webhook",hint:"Requires Meta developer account and public URL.",fields:[{flag:"--phone-number-id",label:"Phone number ID",required:!0,help:["From your WhatsApp Business account in Meta Developer portal"]},{flag:"--access-token",label:"Access token",required:!0,help:["Generate a permanent token in Meta Developer portal"]},{flag:"--app-secret",label:"App secret",required:!0,help:["Found in App Settings > Basic"]},{flag:"--verify-token",label:"Webhook verify token",placeholder:"my-verify-token",required:!0,help:["Any string you choose, used to verify webhook setup"]},{flag:"--base-url",label:"Public base URL",placeholder:"https://example.com",required:!0}]},{id:"gchat",name:"Google Chat",type:"webhook",hint:"Requires Google Cloud project and public URL.",fields:[{flag:"--credentials-json",label:"Service account credentials JSON",required:!0,help:["Create a service account in Google Cloud Console","Download the credentials JSON file","Paste the JSON content here"]},{flag:"--base-url",label:"Public base URL",placeholder:"https://example.com",required:!0}]},{id:"linear",name:"Linear",type:"webhook",hint:"React to Linear issues and comments.",fields:[{flag:"--api-key",label:"API key",required:!0,help:["Go to Linear Settings > API > Personal API keys"]},{flag:"--webhook-secret",label:"Webhook signing secret",required:!0,help:["Go to Settings > API > Webhooks, create one","Copy the signing secret"]},{flag:"--base-url",label:"Public base URL",placeholder:"https://example.com",required:!0}]}];var dl=[];function gr(e){dl.push(e)}async function Wf(){let e=dl.splice(0);await Promise.all(e.map((t)=>{try{return(typeof t==="function"?t():t.dispose())??Promise.resolve()}catch{return Promise.resolve()}}))}var Jf=["hooks","tools","commands","rules","skills","messageBuilders","providers","automationEvents","mcp"],Yf=new Set(Jf);function fl(e,t){return e.name||`extension_${String(t).padStart(4,"0")}`}function pl(e){return Array.isArray(e)&&e.every((t)=>typeof t==="string")}function ml(e){if(!Array.isArray(e))return;let t=e.filter((n)=>typeof n==="string").map((n)=>n.trim()).filter((n)=>n.length>0);return t.length>0?t:void 0}function gl(e){let t=ml(e.providerIds),n=ml(e.modelIds);return{...e,...t?{providerIds:t}:{},...n?{modelIds:n}:{}}}function Xf(e,t){let n=fl(e,t),o=e.manifest;if(!o||typeof o!=="object")throw Error(`Invalid manifest for extension "${n}": manifest is required`);if(!Array.isArray(o.capabilities)||o.capabilities.length===0)throw Error(`Invalid manifest for extension "${n}": capabilities must be a non-empty array`);let r=new Set;for(let a of o.capabilities){if(!Yf.has(a))throw Error(`Invalid manifest for extension "${n}": unsupported capability "${String(a)}"`);r.add(a)}if(Object.hasOwn(o,"providerIds")&&!pl(o.providerIds))throw Error(`Invalid manifest for extension "${n}": providerIds must be a string array when provided`);if(Object.hasOwn(o,"modelIds")&&!pl(o.modelIds))throw Error(`Invalid manifest for extension "${n}": modelIds must be a string array when provided`);let i=r.has("hooks");if(e.hooks!==void 0&&!i)throw Error(`Invalid manifest for extension "${n}": runtime hooks require the "hooks" capability`);return{capabilities:r,raw:gl(o)}}function Qf(e,t){if(!e||typeof e!=="object")throw Error(`Invalid automation event contribution for extension "${t}": expected object`);let n=typeof e.eventType==="string"?e.eventType.trim():"",o=typeof e.source==="string"?e.source.trim():"";if(!n)throw Error(`Invalid automation event contribution for extension "${t}": eventType is required`);if(!o)throw Error(`Invalid automation event contribution for extension "${t}": source is required`);return{...e,eventType:n,source:o,examples:e.examples?[...e.examples]:void 0,metadata:e.metadata?{...e.metadata}:void 0}}class hr{extensions;registry={tools:[],commands:[],rules:[],messageBuilder:[],providers:[],automationEventTypes:[],mcpServers:[]};normalized=[];phase="resolve";setupContext;constructor(e={}){this.extensions=e.extensions??[],this.setupContext=e.setupContext??{}}resolve(){if(this.phase!=="resolve")return;this.normalized=this.extensions.map((e,t)=>({extension:e,order:t,manifest:{capabilities:new Set,raw:e.manifest}})),this.phase="validate"}validate(){if(this.phase==="resolve")this.resolve();if(this.phase!=="validate")return;this.normalized=this.normalized.map((e)=>({...e,manifest:Xf(e.extension,e.order)})),this.phase="setup"}async setup(e={}){if(this.phase==="resolve")this.resolve();if(this.phase==="validate")this.validate();if(this.phase!=="setup")return;let t,n=[];for(let o of this.normalized){let{extension:r}=o;if(r.disabled)continue;let i=fl(r,o.order),s={tools:[],commands:[],rules:[],messageBuilder:[],providers:[],automationEventTypes:[],mcpServers:[]},a={registerTool:(l)=>s.tools.push(l),registerCommand:(l)=>s.commands.push(l),registerRule:(l)=>{if(!o.manifest.capabilities.has("rules"))throw Error(`Invalid setup for extension "${i}": registerRule requires the "rules" capability`);s.rules.push(l)},registerMessageBuilder:(l)=>s.messageBuilder.push(l),registerProvider:(l)=>s.providers.push(l),registerAutomationEventType:(l)=>{if(!o.manifest.capabilities.has("automationEvents"))throw Error(`Invalid setup for extension "${i}": registerAutomationEventType requires the "automationEvents" capability`);s.automationEventTypes.push(Qf(l,i))},registerMcpServer:(l)=>{if(!o.manifest.capabilities.has("mcp"))throw Error(`Invalid setup for extension "${i}": registerMcpServer requires the "mcp" capability`);s.mcpServers.push({...l,metadata:{...l.metadata??{},source:"plugin",plugin:i}})}},c=o.manifest.capabilities.has("automationEvents")?this.setupContext:{...this.setupContext,automation:void 0};try{await r.setup?.(a,c),n.push(s)}catch(l){if(e.tolerateSetupErrors!==!0)throw l;t??=l}}if(t&&e.tolerateSetupErrors!==!0)throw t;for(let o of n)this.registry.tools.push(...o.tools),this.registry.commands.push(...o.commands),this.registry.rules.push(...o.rules),this.registry.messageBuilder.push(...o.messageBuilder),this.registry.providers.push(...o.providers),this.registry.automationEventTypes.push(...o.automationEventTypes),this.registry.mcpServers.push(...o.mcpServers);if(this.phase="activate",t)throw t}activate(){if(this.phase==="resolve")this.resolve();if(this.phase==="validate")this.validate();if(this.phase==="setup")throw Error("Contribution registry setup must complete before activation");if(this.phase!=="activate")return;this.phase="run"}async initialize(e={}){this.resolve(),this.validate();try{await this.setup(e)}finally{if(this.phase==="activate")this.activate()}}isActivated(){return this.phase==="run"}getRegistrySnapshot(){return{tools:[...this.registry.tools],commands:[...this.registry.commands],rules:[...this.registry.rules],messageBuilder:[...this.registry.messageBuilder],providers:[...this.registry.providers],automationEventTypes:[...this.registry.automationEventTypes],mcpServers:[...this.registry.mcpServers]}}getRegisteredTools(){return[...this.registry.tools]}getRegisteredRules(){return[...this.registry.rules]}getRegisteredAutomationEventTypes(){return[...this.registry.automationEventTypes]}getRegisteredMcpServers(){return[...this.registry.mcpServers]}getValidatedExtensions(){if(this.phase==="resolve")this.resolve();if(this.phase==="validate")this.validate();return this.normalized.slice().sort((e,t)=>e.order-t.order).map(({extension:e})=>e)}}function eg(e={}){return new hr(e)}var tg=[".js",".ts"];var Ke={CLINE_PASS:"ext-cline-pass",CODE_CLOUD_AGENTS:"code-cloud-agents",CODE_ONBOARDING_GITHUB:"code-onboarding-github",CLINE_COMPOSIO_BETA:"CLINE_COMPOSIO_BETA"},ng={[Ke.CLINE_PASS]:!1,[Ke.CODE_CLOUD_AGENTS]:!1,[Ke.CODE_ONBOARDING_GITHUB]:!1,[Ke.CLINE_COMPOSIO_BETA]:!1},og=Object.values(Ke);var hl=I(["agent_start","agent_resume","agent_abort","agent_end","agent_error","tool_call","tool_result","prompt_submit","pre_compact","session_shutdown"]),$e=j(u(),u()),rg=b({toolName:u(),parameters:$e}),ig=b({toolName:u(),parameters:$e,result:u(),success:w(),executionTimeMs:x()}),sg=b({prompt:u(),attachments:E(u())}),ag=b({taskMetadata:$e}),cg=b({taskMetadata:$e,previousState:$e}),ug=b({taskMetadata:$e}),lg=b({taskMetadata:$e}),dg=b({taskId:u(),ulid:u(),contextSize:x(),compactionStrategy:u(),previousApiReqIndex:x(),tokensIn:x(),tokensOut:x(),tokensInCache:x(),tokensOutCache:x(),deletedRangeStart:x(),deletedRangeEnd:x(),contextJsonPath:u(),contextRawPath:u()}),yl=b({clineVersion:u(),hookName:hl,timestamp:u(),taskId:u(),sessionContext:b({rootSessionId:u().optional(),hookLogPath:u().optional()}).optional(),workspaceRoots:E(u()),workspaceInfo:se().optional(),userId:u(),agent_id:u(),parent_agent_id:u().nullable(),iteration:x().optional(),reason:u().optional(),tool_call:b({id:u(),name:u(),input:K()}).optional(),tool_result:se().optional(),turn:K().optional(),error:b({name:u(),message:u(),stack:u().optional()}).optional(),preToolUse:rg.optional(),postToolUse:ig.optional(),userPromptSubmit:sg.optional(),taskStart:ag.optional(),taskResume:cg.optional(),taskCancel:ug.optional(),taskComplete:lg.optional(),preCompact:dg.optional()}).passthrough();function pg(e){let t=yl.safeParse(e);if(!t.success)return;return t.data}var Sv="v1",_v="v1",vv="v1",Tv=["client.register","client.list","session.create","session.list","session.get","session.run","session.abort","schedule.create","schedule.list","task.create","task.list","task.get","task.update","task.approve","task.cancel","task.run","task.automation.get","task.automation.set","settings.get","settings.set","connector.start","connector.stop","connector.supervised","run.enqueue","run.list","hub.drain","hub.status","stream.replay"];function xn(e){let t=/^v(\d+)$/.exec(e?.trim()??"");if(!t)return;return Number.parseInt(t[1]??"",10)}function Cv(e,t="v1"){let n=xn(e.protocolVersion),o=xn(t);if(n===void 0||o===void 0)return{compatible:!1,reason:"missing_protocol"};let r=xn(e.minClientProtocolVersion)??n,i=xn(e.maxClientProtocolVersion)??n;return o>=r&&o<=i?{compatible:!0}:{compatible:!1,reason:"unsupported_protocol"}}var kv="approval.respond",Ev="0",Rv="__hubScheduleRunAt",bl=["act","plan","yolo"];function mg(e){return bl.some((t)=>t===e)}function Av(e,t){if(!e||!Object.hasOwn(e,"mode"))return t;let n=e.mode;if(mg(n))return n;throw Error(`mode must be one of: ${bl.join(", ")}`)}var fg=30000,Iv=5000;function gg(e){switch(e){case"run.start":case"session.send_input":return null;default:return fg}}function wv(e,t){return t===void 0?gg(e):t}var hg=["readFile","search","bash","webFetch","editor","applyPatch","skills","askQuestion","submit"],yg=new Set(hg);function Pv(e){return typeof e==="string"&&yg.has(e)}var Mv="tool_executor.",Ov="custom_tool.",zv="hook.",Nv="compaction.compact",$v="checkpoint.create",Lv="mistake_limit.decide",Dv="user_instructions.snapshot";function Bv(e){let t=e.activeSessionCount;if(typeof t!=="number"||t<=0)return"active sessions from other Cline clients";let n=`${t} active session${t===1?"":"s"}`,o=e.participantClientCount;if(typeof o!=="number"||o<=0)return n;return`${n} from ${o} connected Cline client${o===1?"":"s"}`}function yr(e,t){return`<file_content path="${e}">
58
+ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let s of e.seen.entries()){let a=s[1];if(t===s[0]){i(s);continue}if(e.external){let l=e.external.registry.get(s[0])?.id;if(t!==s[0]&&l){i(s);continue}}if(e.metadataRegistry.get(s[0])?.id){i(s);continue}if(a.cycle){i(s);continue}if(a.count>1){if(e.reused==="ref")i(s)}}if(e.external)e.sharedDefsExtractedFor=e.external}function Kc(e){let t=e.anyOf;if(!Array.isArray(t)||t.length===0||e.type!==void 0)return;let n=[];for(let o of t){if(!o||typeof o!=="object")return;Kc(o);let r=Object.keys(o);if(r.length!==1||r[0]!=="type")return;let i=o.type;for(let s of Array.isArray(i)?i:[i]){if(typeof s!=="string")return;if(!n.includes(s))n.push(s)}}delete e.anyOf,e.type=n.length===1?n[0]:n}var Wc=new Set(["type","properties","required","additionalProperties"]),qc=["oneOf","anyOf"];function Gc(e){let t=e.additionalProperties;if(t===void 0||t===!1||typeof t!=="object"||t===null)return null;return Object.keys(t).length?t:null}function wo(e){let t=[];for(let i of e){if(typeof i!=="object"||i.type!=="object")return null;for(let s in i)if(!Wc.has(s))return null;t.push(i)}let n={},o=new Set;for(let i of t){for(let s in i.properties){if(Object.prototype.hasOwnProperty.call(n,s))continue;let a=[];for(let l of t){let d=l.properties?.[s]??Gc(l);if(d===null||d===void 0)continue;if(!a.some((p)=>JSON.stringify(p)===JSON.stringify(d)))a.push(d)}let c=a.length===1?a[0]:wo(a)??{allOf:a};te(n,s,c)}for(let s of i.required??[])o.add(s)}let r={type:"object",properties:n};if(o.size)r.required=[...o];if(t.every((i)=>i.additionalProperties===!1))r.additionalProperties=!1;else{let i=[];for(let s of t){let a=Gc(s);if(a&&!i.some((c)=>JSON.stringify(c)===JSON.stringify(a)))i.push(a)}if(i.length===1)r.additionalProperties=i[0];else if(i.length>1)r.additionalProperties={allOf:i}}return r}function cm(e){let t=e.allOf;if(!Array.isArray(t)||t.length<2)return;for(let r of Wc)if(r in e)return;let n=t.filter((r)=>qc.some((i)=>Array.isArray(r[i]))),o=null;if(!n.length)o=wo(t);else{let r=n[0],i=qc.find((c)=>Array.isArray(r[c]));if(Object.keys(r).length!==1)return;let s=t.filter((c)=>c!==r),a=r[i].map((c)=>wo([...s,c]));if(a.some((c)=>!c))return;o={[i]:a}}if(!o)return;delete e.allOf,Tt(e,o)}function Rt(e,t){let n=e.seen.get(t);if(!n)throw Error("Unprocessed schema. This is a bug in Zod.");let o=(a)=>{let c=e.seen.get(a);if(c.ref===null)return;let l=c.def??c.schema,d={...l},p=c.ref;if(c.ref=null,p){o(p);let f=e.seen.get(p),g=f.schema;if(g.$ref&&(e.target==="draft-07"||e.target==="draft-04"||e.target==="openapi-3.0"))l.allOf=l.allOf??[],l.allOf.push(g);else Tt(l,g);if(Tt(l,d),a._zod.parent===p)for(let S in l){if(S==="$ref"||S==="allOf")continue;if(!(S in d))delete l[S]}if(g.$ref&&f.def)for(let S in l){if(S==="$ref"||S==="allOf")continue;if(S in f.def&&JSON.stringify(l[S])===JSON.stringify(f.def[S]))delete l[S]}}let m=a._zod.parent;if(m&&m!==p){o(m);let f=e.seen.get(m);if(f?.schema.$ref){if(l.$ref=f.schema.$ref,f.def)for(let g in l){if(g==="$ref"||g==="allOf")continue;if(g in f.def&&JSON.stringify(l[g])===JSON.stringify(f.def[g]))delete l[g]}}}e.override({zodSchema:a,jsonSchema:l,path:c.path??[]})};if(!e.external||e.sharedEmitDoneFor!==e.external){for(let a of[...e.seen.entries()].reverse())o(a[0]);if(e.target!=="openapi-3.0")for(let a of e.seen.entries())Kc(a[1].def??a[1].schema);for(let a of e.deferred)a();if(e.intersections.length){let a=new Map;for(let c of e.seen.values())for(let l of[c.schema,c.def]){let d=l?.allOf;if(!Array.isArray(d))continue;let p=a.get(d);if(p)p.push(l);else a.set(d,[l])}for(let c of e.intersections)for(let l of a.get(c)??[])cm(l)}}let r={};if(e.target==="draft-2020-12")r.$schema="https://json-schema.org/draft/2020-12/schema";else if(e.target==="draft-07")r.$schema="http://json-schema.org/draft-07/schema#";else if(e.target==="draft-04")r.$schema="http://json-schema.org/draft-04/schema#";else if(e.target==="openapi-3.0");if(e.external?.uri){let a=e.external.registry.get(t)?.id;if(!a)throw Error("Schema is missing an `id` property");r.$id=e.external.uri(a)}Tt(r,n.defId?n.schema:n.def??n.schema);let i=e.metadataRegistry.get(t)?.id;if(i!==void 0&&r.id===i)delete r.id;let s=e.external?.defs??{};if(!e.external||e.sharedEmitDoneFor!==e.external)for(let a of e.seen.entries()){let c=a[1];if(c.def&&c.defId){if(c.def.id===c.defId)delete c.def.id;te(s,c.defId,c.def)}}if(e.external)e.sharedEmitDoneFor=e.external;if(e.external);else if(Object.keys(s).length>0)if(e.target==="draft-2020-12")r.$defs=s;else r.definitions=s;try{let a=JSON.parse(JSON.stringify(r));return Object.defineProperty(a,"~standard",{value:{...t["~standard"],jsonSchema:{input:Ct(t,"input",e.processors),output:Ct(t,"output",e.processors)}},enumerable:!1,writable:!1}),a}catch(a){throw Error("Error converting schema to JSON.")}}function X(e,t){let n=t??{seen:new Set};if(n.seen.has(e))return!1;n.seen.add(e);let o=e._zod.def;if(o.type==="transform")return!0;if(o.type==="array")return X(o.element,n);if(o.type==="set")return X(o.valueType,n);if(o.type==="lazy")return X(o.getter(),n);if(o.type==="promise"||o.type==="optional"||o.type==="nonoptional"||o.type==="nullable"||o.type==="readonly"||o.type==="default"||o.type==="prefault"||o.type==="catch")return X(o.innerType,n);if(o.type==="intersection")return X(o.left,n)||X(o.right,n);if(o.type==="record"||o.type==="map")return X(o.keyType,n)||X(o.valueType,n);if(o.type==="pipe"){if(e._zod.traits.has("$ZodCodec"))return!0;return X(o.in,n)||X(o.out,n)}if(o.type==="object"){for(let r in o.shape)if(X(o.shape[r],n))return!0;return!1}if(o.type==="union"){for(let r of o.options)if(X(r,n))return!0;return!1}if(o.type==="tuple"){for(let r of o.items)if(X(r,n))return!0;if(o.rest&&X(o.rest,n))return!0;return!1}return!1}var Jc=(e,t={})=>(n)=>{let o=kt({...n,processors:t});return D(e,o),Et(o,e),Rt(o,e)},Ct=(e,t,n={})=>(o)=>{let{libraryOptions:r,target:i}=o??{},s=kt({...r??{},target:i,io:t,processors:n});return D(e,s),Et(s,e),Rt(s,e)};var Ve=(e,t,n)=>{if(e[t]===void 0||n>e[t])e[t]=n},qe=(e,t,n)=>{if(e[t]===void 0||n<e[t])e[t]=n},Yc=(e,t)=>{Ve(e,"minimum",t),qe(e,"maximum",t)},nu=(e,t)=>{if(e.multipleOf??(e.multipleOf=[]),!e.multipleOf.includes(t))e.multipleOf.push(t)},ou=(e,t)=>{e.patterns??(e.patterns=new Set),e.patterns.add(t)},ru=(e,t)=>{e.mime=e.mime?e.mime.filter((n)=>t.includes(n)):[...t]},iu=(e,t)=>{if(e.format=t,t.includes("int"))e.isInt=!0},Xc=(e,t)=>Ve(e,"minimum",t.minimum),Qc=(e,t)=>qe(e,"maximum",t.maximum),eu=(e)=>(t,n)=>{iu(t,n.format);let[o,r]=e[n.format];Ve(t,"minimum",o),qe(t,"maximum",r)},um={greater_than:(e,t)=>Ve(e,t.inclusive?"minimum":"exclusiveMinimum",t.value),less_than:(e,t)=>qe(e,t.inclusive?"maximum":"exclusiveMaximum",t.value),multiple_of:(e,t)=>nu(e,t.value),number_format:eu(Ut),bigint_format:eu(Un),min_length:Xc,max_length:Qc,length_equals:(e,t)=>Yc(e,t.length),min_size:Xc,max_size:Qc,size_equals:(e,t)=>Yc(e,t.size),string_format:(e,t)=>{if(iu(e,t.format),t.pattern)ou(e,t.pattern);if(t.format==="base64"||t.format==="base64url")e.contentEncoding=t.format;if(t.local||t.precision===-1)e.laxFormat=!0},mime_type:(e,t)=>ru(e,t.mime)};function W(e){let t={},n=e._zod.def,o=e._zod.traits.has("$ZodCheck")?[e,...n.checks??[]]:n.checks??[];for(let i of o)um[i._zod.def.check]?.(t,i._zod.def);let r=e._zod.bag;if(r.minimum!==void 0)Ve(t,"minimum",r.minimum);if(r.exclusiveMinimum!==void 0)Ve(t,"exclusiveMinimum",r.exclusiveMinimum);if(r.maximum!==void 0)qe(t,"maximum",r.maximum);if(r.exclusiveMaximum!==void 0)qe(t,"exclusiveMaximum",r.exclusiveMaximum);if(r.multipleOf!==void 0)nu(t,r.multipleOf);if(r.format!==void 0){if(t.format??(t.format=r.format),r.format.includes("int"))t.isInt=!0}if(r.mime)ru(t,r.mime);for(let i of r.patterns??[])ou(t,i);return t}var lm={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},dm=new Map([[co,ms],[Qt,fs]]),su=(e)=>dm.get(e)??e,Oo=(e,t,n,o)=>{let r=n;r.type="string";let{minimum:i,maximum:s,format:a,patterns:c,contentEncoding:l,laxFormat:d}=W(e);if(typeof i==="number")r.minLength=i;if(typeof s==="number")r.maxLength=s;if(a){if(r.format=lm[a]??a,r.format==="")delete r.format;if(a==="time"||d)delete r.format}if(l)r.contentEncoding=l;if(c&&c.size>0){let p=[...c].map(su);if(p.length===1)r.pattern=p[0].source;else if(p.length>1)r.allOf=[...p.map((m)=>({...t.target==="draft-07"||t.target==="draft-04"||t.target==="openapi-3.0"?{type:"string"}:{},pattern:m.source}))]}},zo=(e,t,n,o)=>{let r=n,{minimum:i,maximum:s,multipleOf:a,exclusiveMaximum:c,exclusiveMinimum:l,isInt:d}=W(e);r.type=d?"integer":"number";let p=typeof l==="number"&&l>=(i??Number.NEGATIVE_INFINITY),m=typeof c==="number"&&c<=(s??Number.POSITIVE_INFINITY),f=t.target==="draft-04"||t.target==="openapi-3.0";if(p)if(f)r.minimum=l,r.exclusiveMinimum=!0;else r.exclusiveMinimum=l;else if(typeof i==="number")r.minimum=i;if(m)if(f)r.maximum=c,r.exclusiveMaximum=!0;else r.exclusiveMaximum=c;else if(typeof s==="number")r.maximum=s;if(a){let g=new Set;for(let v of a)if(Number.isFinite(v)&&v!==0)g.add(Math.abs(v));else q(e,t,r,o,`A multipleOf divisor of ${v} cannot be represented in JSON Schema`);let[y,...S]=g;if(y!==void 0)r.multipleOf=y;if(S.length)r.allOf=[...r.allOf??[],...S.map((v)=>({multipleOf:v}))]}},No=(e,t,n,o)=>{n.type="boolean"},au=(e,t,n,o)=>{q(e,t,n,o,"BigInt cannot be represented in JSON Schema")},cu=(e,t,n,o)=>{q(e,t,n,o,"Symbols cannot be represented in JSON Schema")},uu=(e,t,n,o)=>{if(t.target==="openapi-3.0")n.type="string",n.nullable=!0,n.enum=[null];else n.type="null"},lu=(e,t,n,o)=>{q(e,t,n,o,"Undefined cannot be represented in JSON Schema")},$o=(e,t,n,o)=>{q(e,t,n,o,"Void cannot be represented in JSON Schema")},Lo=(e,t,n,o)=>{n.not={}},du=(e,t,n,o)=>{},Do=(e,t,n,o)=>{},Bo=(e,t,n,o)=>{q(e,t,n,o,"Date cannot be represented in JSON Schema")},Uo=(e,t,n,o)=>{let r=e._zod.def,i=pt(r.entries);if(i.length===0){n.not={};return}if(i.every((s)=>typeof s==="number"))n.type="number";if(i.every((s)=>typeof s==="string"))n.type="string";n.enum=i},Zo=(e,t,n,o)=>{let r=e._zod.def;if(r.values.length===0){n.not={};return}let i=[];for(let s of r.values)if(s===void 0){if(q(e,t,n,o,"Literal `undefined` cannot be represented in JSON Schema"))return}else if(typeof s==="bigint"){if(q(e,t,n,o,"BigInt literals cannot be represented in JSON Schema"))return;i.push(Number(s))}else i.push(s);if(i.length===0);else if(i.length===1){let s=i[0];if(n.type=s===null?"null":typeof s,t.target==="draft-04"||t.target==="openapi-3.0")n.enum=[s];else n.const=s}else{if(i.every((s)=>typeof s==="number"))n.type="number";if(i.every((s)=>typeof s==="string"))n.type="string";if(i.every((s)=>typeof s==="boolean"))n.type="boolean";if(i.every((s)=>s===null))n.type="null";n.enum=i}},pu=(e,t,n,o)=>{q(e,t,n,o,"NaN cannot be represented in JSON Schema")},mu=(e,t,n,o)=>{let r=n,i=e._zod.pattern;if(!i)throw Error("Pattern not found in template literal");r.type="string",r.pattern=i.source},fu=(e,t,n,o)=>{let r=n;r.type="string",r.format="binary",r.contentEncoding="binary";let{minimum:i,maximum:s,mime:a}=W(e);if(i!==void 0)r.minLength=i;if(s!==void 0)r.maxLength=s;if(!a)return;if(a.length===0)r.not={};else if(a.length===1)r.contentMediaType=a[0];else r.anyOf=a.map((c)=>({contentMediaType:c}))},gu=(e,t,n,o)=>{n.type="boolean"},Fo=(e,t,n,o)=>{q(e,t,n,o,"Custom types cannot be represented in JSON Schema")},Ho=(e,t,n,o)=>{q(e,t,n,o,"Function types cannot be represented in JSON Schema")},jo=(e,t,n,o)=>{q(e,t,n,o,"Transforms cannot be represented in JSON Schema")},hu=(e,t,n,o)=>{q(e,t,n,o,"Map cannot be represented in JSON Schema")},yu=(e,t,n,o)=>{q(e,t,n,o,"Set cannot be represented in JSON Schema")},Vo=(e,t,n,o)=>{let r=n,i=e._zod.def,{minimum:s,maximum:a}=W(e);if(typeof s==="number")r.minItems=s;if(typeof a==="number")r.maxItems=a;r.type="array",r.items=D(i.element,t,{...o,path:[...o.path,"items"]})};function At(e){let t=e._zod.def;if(t.type==="pipe"&&t.in._zod.traits.has("$ZodTransform"))return At(t.out);if(t.type==="catch")return At(t.innerType);return e._zod.optin}var qo=(e,t,n,o)=>{let r=n,i=e._zod.def,s=i.shape;if(Object.getOwnPropertySymbols(s).length&&q(e,t,r,o,"Symbol keys cannot be represented in JSON Schema"))return;r.type="object",r.properties={};for(let l in s)te(r.properties,l,D(s[l],t,{...o,path:[...o.path,"properties",l]}));let c=[];for(let l of Object.keys(s)){let d=i.shape[l];if(t.io==="input"?At(d)===void 0:d._zod.optout===void 0)c.push(l)}if(c.length>0)r.required=c;if(i.catchall?._zod.def.type==="never")r.additionalProperties=!1;else if(!i.catchall){if(t.io==="output")r.additionalProperties=!1}else if(i.catchall)r.additionalProperties=D(i.catchall,t,{...o,path:[...o.path,"additionalProperties"]})},Go=(e,t,n,o)=>{let r=e._zod.def,i=r.inclusive===!1,s=r.options.map((a,c)=>D(a,t,{...o,path:[...o.path,i?"oneOf":"anyOf",c]}));if(i)n.oneOf=s;else n.anyOf=s},Ko=(e,t,n,o)=>{let r=e._zod.def,i=D(r.left,t,{...o,path:[...o.path,"allOf",0]}),s=D(r.right,t,{...o,path:[...o.path,"allOf",1]}),a=(l)=>("allOf"in l)&&Object.keys(l).length===1,c=[...a(i)?i.allOf:[i],...a(s)?s.allOf:[s]];n.allOf=c,t.intersections.push(c)},Wo=(e,t,n,o)=>{let r=n,i=e._zod.def;r.type="array";let s=t.target==="draft-2020-12"?"prefixItems":"items",a=t.target==="draft-2020-12"?"items":t.target==="openapi-3.0"?"items":"additionalItems",c=i.items.map((y,S)=>D(y,t,{...o,path:[...o.path,s,S]})),l=i.rest?D(i.rest,t,{...o,path:[...o.path,a,...t.target==="openapi-3.0"?[i.items.length]:[]]}):null,d=i.items.length;while(d>0){let y=i.items[d-1];if(!(t.io==="input"?At(y)!==void 0:y._zod.optout==="optional"))break;d--}let p=i.items.length,m=!i.rest;if(t.target==="draft-2020-12"){if(r.prefixItems=c,m)r.items=!1;else if(l)r.items=l;if(d>0)r.minItems=d;if(m)r.maxItems=p}else if(t.target==="openapi-3.0"){if(r.items={anyOf:c},l)r.items.anyOf.push(l);if(d>0)r.minItems=d;if(m)r.maxItems=p}else{if(r.items=c,m)r.additionalItems=!1;else if(l)r.additionalItems=l;if(d>0)r.minItems=d;if(m)r.maxItems=p}let{minimum:f,maximum:g}=W(e);if(typeof f==="number")r.minItems=f;if(typeof g==="number")r.maxItems=g};function Po(e,t,n){if(t.$ref){if(n.has(t))return t;n.add(t);let g=e.get(t)?.def;if(!g)return t;let y=Po(e,g,n);return y===g?t:y}for(let g of["anyOf","oneOf"]){let y=t[g];if(!Array.isArray(y))continue;let S=y.map((v)=>Po(e,v,n));if(S.some((v,k)=>v!==y[k]))t={...t,[g]:S}}let o=Array.isArray(t.type)?t.type:[t.type],r=!o.includes("string")&&o.some((g)=>g==="number"||g==="integer"),i=t.enum??(t.const!==void 0?[t.const]:void 0);if(!r&&!i?.some((g)=>typeof g==="number"))return t;let{minimum:s,maximum:a,exclusiveMinimum:c,exclusiveMaximum:l,multipleOf:d,format:p,id:m,...f}=t;if(f.enum)f.enum=f.enum.map((g)=>typeof g==="number"?String(g):g);else if(typeof f.const==="number")f.const=String(f.const);if(!r)return f;if(f.type="string",!i)f.pattern=(o.includes("number")?xt:to).source;return f}var Mo=new WeakMap;function pm(e){let t=new Map;for(let o of e.seen.values())if(o.def&&!t.has(o.schema))t.set(o.schema,o);let n=new Map;for(let o of Mo.get(e)??[]){let r=e.seen.get(o),i=(r?.def??r?.schema)?.propertyNames;if(!i||i===!0||n.has(i))continue;let s=Po(t,i,new Set);if(s!==i)n.set(i,s)}if(!n.size)return;for(let o of e.seen.values())for(let r of[o.schema,o.def]){let i=r&&n.get(r.propertyNames);if(i)r.propertyNames=i}}var Jo=(e,t,n,o)=>{let r=n,i=e._zod.def;r.type="object";let s=i.keyType,a=W(s).patterns;if(i.mode==="loose"&&a&&a.size>0){let d=D(i.valueType,t,{...o,path:[...o.path,"patternProperties","*"]});r.patternProperties={};for(let p of a)te(r.patternProperties,su(p).source,d)}else{if(t.target==="draft-07"||t.target==="draft-2020-12"){r.propertyNames=D(i.keyType,t,{...o,path:[...o.path,"propertyNames"]});let d=Mo.get(t);if(!d)d=[],Mo.set(t,d),t.deferred.push(()=>pm(t));d.push(e)}r.additionalProperties=D(i.valueType,t,{...o,path:[...o.path,"additionalProperties"]})}let c=s._zod.values,l=t.io==="input"&&At(i.valueType)!==void 0;if(c&&!i.partial&&!l){let d=[...c].filter((p)=>typeof p==="string"||typeof p==="number");if(d.length>0)r.required=d.map(String)}},Yo=(e,t,n,o)=>{let r=e._zod.def,i=D(r.innerType,t,o),s=t.seen.get(e);if(t.target==="openapi-3.0")s.ref=r.innerType,n.nullable=!0;else n.anyOf=[i,{type:"null"}]},Xo=(e,t,n,o)=>{let r=e._zod.def;D(r.innerType,t,o);let i=t.seen.get(e);i.ref=r.innerType},Qo=Symbol();function bu(e,t,n,o,r){let i=!1,s=JSON.stringify(e,(a,c)=>{if(typeof c!=="bigint")return c;return i=!0,null});if(!i)return JSON.parse(s);return q(t,n,o,r,"BigInt defaults cannot be represented in JSON Schema"),Qo}var er=(e,t,n,o)=>{let r=e._zod.def;D(r.innerType,t,o);let i=t.seen.get(e);i.ref=r.innerType;let s=bu(r.defaultValue,e,t,n,o);if(s!==Qo)n.default=s},tr=(e,t,n,o)=>{let r=e._zod.def;D(r.innerType,t,o);let i=t.seen.get(e);if(i.ref=r.innerType,t.io!=="input")return;let s=bu(r.defaultValue,e,t,n,o);if(s!==Qo)n._prefault=s},nr=(e,t,n,o)=>{let r=e._zod.def;D(r.innerType,t,o);let i=t.seen.get(e);i.ref=r.innerType;let s;try{s=r.catchValue(void 0)}catch{q(e,t,n,o,"Dynamic catch values are not supported in JSON Schema");return}n.default=s},or=(e,t,n,o)=>{let r=e._zod.def,i=r.in._zod.traits.has("$ZodTransform"),s=t.io==="input"?i?r.out:r.in:r.out;D(s,t,o);let a=t.seen.get(e);a.ref=s},rr=(e,t,n,o)=>{let r=e._zod.def;D(r.innerType,t,o);let i=t.seen.get(e);i.ref=r.innerType,n.readOnly=!0},ir=(e,t,n,o)=>{let r=e._zod.def;D(r.innerType,t,o);let i=t.seen.get(e);i.ref=r.innerType},ln=(e,t,n,o)=>{let r=e._zod.def;D(r.innerType,t,o);let i=t.seen.get(e);i.ref=r.innerType},xu=(e,t,n,o)=>{let r=e._zod.innerType;D(r,t,o);let i=t.seen.get(e);i.ref=r},tu={string:Oo,number:zo,boolean:No,bigint:au,symbol:cu,null:uu,undefined:lu,void:$o,never:Lo,any:du,unknown:Do,date:Bo,enum:Uo,literal:Zo,nan:pu,template_literal:mu,file:fu,success:gu,custom:Fo,function:Ho,transform:jo,map:hu,set:yu,array:Vo,object:qo,union:Go,intersection:Ko,tuple:Wo,record:Jo,nullable:Yo,nonoptional:Xo,default:er,prefault:tr,catch:nr,pipe:or,readonly:rr,promise:ir,optional:ln,lazy:xu};function Su(e,t){if("_idmap"in e){let o=e,r=kt({...t,processors:tu}),i={};for(let c of o._idmap.entries()){let[l,d]=c;D(d,r)}let s={},a={registry:o,uri:t?.uri,defs:i};r.external=a;for(let c of o._idmap.entries()){let[l,d]=c;Et(r,d),te(s,l,Rt(r,d))}if(Object.keys(i).length>0){let c=r.target==="draft-2020-12"?"$defs":"definitions";s.__shared={[c]:i}}return{schemas:s}}let n=kt({...t,processors:tu});return D(e,n),Et(n,e),Rt(n,e)}var _u=new WeakSet([Object.prototype,Error.prototype]);function pn(e,t,n){Object.defineProperty(e,t,{configurable:!0,enumerable:!1,get(){let o=n(this);return Object.defineProperty(this,t,{value:o,configurable:!0,writable:!0}),o},set(o){Object.defineProperty(this,t,{value:o,configurable:!0,writable:!0})}})}var _m=(e,t)=>{Zi.init(e,t),e.name="ZodError";let n=Object.getPrototypeOf(e);if(_u.has(n))return;_u.add(n),pn(n,"format",(o)=>(r)=>Kn(o,r)),pn(n,"flatten",(o)=>(r)=>Gn(o,r)),pn(n,"addIssue",(o)=>(r)=>{o.issues.push(r),o.message=JSON.stringify(o.issues,mt,2)}),pn(n,"addIssues",(o)=>(r)=>{o.issues.push(...r),o.message=JSON.stringify(o.issues,mt,2)}),Object.defineProperty(n,"isEmpty",{configurable:!0,enumerable:!1,get(){return this.issues.length===0}})};var oe=h("ZodError",_m,void 0,{Parent:Error});var vu=yt(oe),Tu=bt(oe),Cu=qt(oe),ku=Gt(oe),Eu=ji(oe),Ru=Vi(oe),Au=qi(oe),Iu=Gi(oe),wu=Ki(oe),Pu=Wi(oe),Mu=Ji(oe),Ou=Yi(oe);function Tm(){if(!Y.localeError)Q(bo())}function It(){if(!Y.memoizer)Q({memoizer:yo()})}var N=h("ZodType",(e,t)=>(Tm(),z.init(e,t),e.def=t,e.type=t.type,e),{check(...e){let t=this.def;return this.clone(ne(t,{checks:[...t.checks??[],...e.map((n)=>typeof n==="function"?{_zod:{check:n,def:{check:"custom"},onattach:[]}}:n)]}),{parent:!0})},with(...e){return this.check(...e)},clone(e,t){return ue(this,e,t)},brand(){return this},register(e,t){return e.add(this,t),this},refine(e,t){return this.check(kf(e,t))},superRefine(e,t){return this.check(Ef(e,t))},overwrite(e){return this.check(Ae(e))},optional(){return $u(this)},exactOptional(){return df(this)},nullable(){return Lu(this)},nullish(){return $u(Lu(this))},nonoptional(e){return yf(this,e)},array(){return E(this)},or(e){return Ge([this,e])},and(e){return sf(this,e)},transform(e){return Du(this,Fu(e))},default(e){return ff(this,e)},prefault(e){return hf(this,e)},catch(e){return xf(this,e)},pipe(e){return Du(this,e)},readonly(){return vf(this)},describe(e){let t=this.clone();return Re.add(t,{description:e}),t},meta(...e){if(e.length===0)return Re.get(this);let t=this.clone();return Re.add(t,e[0]),t},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(e,...t){return t.length===0?e(this):e(this,...t)},get "~standard"(){return jt(this,"~standard",{...ao(this),jsonSchema:{input:Ct(this,"input"),output:Ct(this,"output")}})},set "~standard"(e){xe(this,"~standard",e)},parse:function e(t,n){return vu(this,t,n,{callee:e})},parseAsync:async function e(t,n){return await Tu(this,t,n,{callee:e})},safeParse(e,t){return Cu(this,e,t)},async safeParseAsync(e,t){return ku(this,e,t)},get spa(){return this?.safeParseAsync},set spa(e){xe(this,"spa",e)},validate(e,t){return Yn(this,e,t)},validateAsync(e,t){return Xn(this,e,t)},encode:function e(t,n){return Eu(this,t,n,{callee:e})},decode:function e(t,n){return Ru(this,t,n,{callee:e})},encodeAsync:async function e(t,n){return await Au(this,t,n,{callee:e})},decodeAsync:async function e(t,n){return await Iu(this,t,n,{callee:e})},safeEncode(e,t){return wu(this,e,t)},safeDecode(e,t){return Pu(this,e,t)},async safeEncodeAsync(e,t){return Mu(this,e,t)},async safeDecodeAsync(e,t){return Ou(this,e,t)},toJSONSchema(e){return Jc(this,{})(e)},get description(){return Re.get(this)?.description},get _def(){return this._zod.def}}),Bu=h("_ZodString",(e,t)=>{Xt.init(e,t),N.init(e,t),e._zod.processJSONSchema=(n,o,r)=>Oo(e,n,o,r)},Fn({format:(e)=>W(e).format??null,minLength:(e)=>W(e).minimum??null,maxLength:(e)=>W(e).maximum??null},{regex(...e){return this.check(xo(...e))},includes(...e){return this.check(vo(...e))},startsWith(...e){return this.check(To(...e))},endsWith(...e){return this.check(Co(...e))},min(...e){return this.check(je(...e))},max(...e){return this.check(cn(...e))},length(...e){return this.check(un(...e))},nonempty(...e){return this.check(je(1,...e))},lowercase(e){return this.check(So(e))},uppercase(e){return this.check(_o(e))},trim(){return this.check(Eo())},normalize(...e){return this.check(ko(...e))},toLowerCase(){return this.check(Ro())},toUpperCase(){return this.check(Ao())},slugify(){return this.check(Io())}})),Cm=h("ZodString",(e,t)=>{Xt.init(e,t),Bu.init(e,t)},{email(e){return this.check(cc(Im,e))},url(e){return this.check(fc(Pm,e))},jwt(e){return this.check(Ic(qm,e))},emoji(e){return this.check(gc(Mm,e))},guid(e){return this.check(uc(wm,e))},uuid(e){return this.check(lc(mn,e))},uuidv4(e){return this.check(dc(mn,e))},uuidv6(e){return this.check(pc(mn,e))},uuidv7(e){return this.check(mc(mn,e))},nanoid(e){return this.check(hc(Om,e))},cuid(e){return this.check(yc(zm,e))},cuid2(e){return this.check(bc(Nm,e))},ulid(e){return this.check(xc($m,e))},base64(e){return this.check(Ec(Hm,e))},base64url(e){return this.check(Rc(jm,e))},xid(e){return this.check(Sc(Lm,e))},ksuid(e){return this.check(_c(Dm,e))},ipv4(e){return this.check(vc(Bm,e))},ipv6(e){return this.check(Tc(Um,e))},cidrv4(e){return this.check(Cc(Zm,e))},cidrv6(e){return this.check(kc(Fm,e))},e164(e){return this.check(Ac(Vm,e))},datetime(e){return this.check(wc(km,e))},date(e){return this.check(Pc(Em,e))},time(e){return this.check(Mc(Rm,e))},duration(e){return this.check(Oc(Am,e))}});function u(e){return ac(Cm,e)}var F=h("ZodStringFormat",(e,t)=>{U.init(e,t),Bu.init(e,t)}),km=h("ZodISODateTime",(e,t)=>{pa.init(e,t),F.init(e,t)}),Em=h("ZodISODate",(e,t)=>{ma.init(e,t),F.init(e,t)}),Rm=h("ZodISOTime",(e,t)=>{fa.init(e,t),F.init(e,t)}),Am=h("ZodISODuration",(e,t)=>{ga.init(e,t),F.init(e,t)}),Im=h("ZodEmail",(e,t)=>{ta.init(e,t),F.init(e,t)});var wm=h("ZodGUID",(e,t)=>{Qs.init(e,t),F.init(e,t)});var mn=h("ZodUUID",(e,t)=>{ea.init(e,t),F.init(e,t)});var Pm=h("ZodURL",(e,t)=>{ra.init(e,t),F.init(e,t)});var Mm=h("ZodEmoji",(e,t)=>{ia.init(e,t),F.init(e,t)});var Om=h("ZodNanoID",(e,t)=>{sa.init(e,t),F.init(e,t)});var zm=h("ZodCUID",(e,t)=>{aa.init(e,t),F.init(e,t)});var Nm=h("ZodCUID2",(e,t)=>{ca.init(e,t),F.init(e,t)});var $m=h("ZodULID",(e,t)=>{ua.init(e,t),F.init(e,t)});var Lm=h("ZodXID",(e,t)=>{la.init(e,t),F.init(e,t)});var Dm=h("ZodKSUID",(e,t)=>{da.init(e,t),F.init(e,t)});var Bm=h("ZodIPv4",(e,t)=>{ha.init(e,t),F.init(e,t)});var Um=h("ZodIPv6",(e,t)=>{ba.init(e,t),F.init(e,t)});var Zm=h("ZodCIDRv4",(e,t)=>{xa.init(e,t),F.init(e,t)});var Fm=h("ZodCIDRv6",(e,t)=>{Sa.init(e,t),F.init(e,t)});var Hm=h("ZodBase64",(e,t)=>{va.init(e,t),F.init(e,t)});var jm=h("ZodBase64URL",(e,t)=>{Ta.init(e,t),F.init(e,t)});var Vm=h("ZodE164",(e,t)=>{Ca.init(e,t),F.init(e,t)});var qm=h("ZodJWT",(e,t)=>{ka.init(e,t),F.init(e,t)});var Uu=h("ZodNumber",(e,t)=>{uo.init(e,t),N.init(e,t),e._zod.processJSONSchema=(n,o,r)=>zo(e,n,o,r),e.isFinite=!0},Fn({minValue:(e)=>{let{minimum:t,exclusiveMinimum:n}=W(e);return Math.max(t??Number.NEGATIVE_INFINITY,n??Number.NEGATIVE_INFINITY)},maxValue:(e)=>{let{maximum:t,exclusiveMaximum:n}=W(e);return Math.min(t??Number.POSITIVE_INFINITY,n??Number.POSITIVE_INFINITY)},isInt:(e)=>{let{isInt:t,multipleOf:n}=W(e);return!!t||!!n?.some(Number.isSafeInteger)},format:(e)=>W(e).format??null},{gt(e,t){return this.check(sn(e,t))},gte(e,t){return this.check(He(e,t))},min(e,t){return this.check(He(e,t))},lt(e,t){return this.check(rn(e,t))},lte(e,t){return this.check(Fe(e,t))},max(e,t){return this.check(Fe(e,t))},int(e){return this.check(zu(e))},safe(e){return this.check(zu(e))},positive(e){return this.check(sn(0,e))},nonnegative(e){return this.check(He(0,e))},negative(e){return this.check(rn(0,e))},nonpositive(e){return this.check(Fe(0,e))},multipleOf(e,t){return this.check(an(e,t))},step(e,t){return this.check(an(e,t))},finite(){return this}}));function x(e){return zc(Uu,e)}var Gm=h("ZodNumberFormat",(e,t)=>{Ea.init(e,t),Uu.init(e,t)});function zu(e){return Nc(Gm,e)}var Km=h("ZodBoolean",(e,t)=>{Ra.init(e,t),N.init(e,t),e._zod.processJSONSchema=(n,o,r)=>No(e,n,o,r)});function w(e){return $c(Km,e)}var Wm=h("ZodUnknown",(e,t)=>{Aa.init(e,t),N.init(e,t),e._zod.processJSONSchema=(n,o,r)=>Do(e,n,o,r)});function K(){return Lc(Wm)}var Jm=h("ZodNever",(e,t)=>{Ia.init(e,t),N.init(e,t),e._zod.processJSONSchema=(n,o,r)=>Lo(e,n,o,r)});function Ym(e){return Dc(Jm,e)}var Xm=h("ZodVoid",(e,t)=>{wa.init(e,t),N.init(e,t),e._zod.processJSONSchema=(n,o,r)=>$o(e,n,o,r)});function Qm(e){return Bc(Xm,e)}var ef=h("ZodDate",(e,t)=>{Pa.init(e,t),N.init(e,t),e._zod.processJSONSchema=(n,o,r)=>Bo(e,n,o,r),e.min=(n,o)=>e.check(He(n,o)),e.max=(n,o)=>e.check(Fe(n,o))},Fn({minDate:(e)=>{let{minimum:t}=W(e);return t?new Date(t):null},maxDate:(e)=>{let{maximum:t}=W(e);return t?new Date(t):null}},{}));function fn(e){return Uc(ef,e)}var tf=h("ZodArray",(e,t)=>{It(),Ma.init(e,t),N.init(e,t),e._zod.processJSONSchema=(n,o,r)=>Vo(e,n,o,r),e.element=t.element},{min(e,t){return this.check(je(e,t))},nonempty(e){return this.check(je(1,e))},max(e,t){return this.check(cn(e,t))},length(e,t){return this.check(un(e,t))},unwrap(){return this.element}});function E(e,t){return Zc(tf,e,t)}var nf=h("ZodObject",(e,t)=>{It(),Na.init(e,t),N.init(e,t),e._zod.processJSONSchema=(n,o,r)=>qo(e,n,o,r),Ip(e,"shape",(n)=>n._zod.def.shape,!1)},{keyof(){return I(Object.keys(this._zod.def.shape))},catchall(e){return this.clone(ne(this._zod.def,{catchall:e}))},passthrough(){return this.clone(ne(this._zod.def,{catchall:K()}))},loose(){return this.clone(ne(this._zod.def,{catchall:K()}))},strict(){return this.clone(ne(this._zod.def,{catchall:Ym()}))},strip(){return this.clone(ne(this._zod.def,{catchall:void 0}))},extend(e){return _p(this,e)},safeExtend(e){return vp(this,e)},merge(e){return Tp(this,e)},pick(e){return xp(this,e)},omit(e){return Sp(this,e)},partial(...e){return Mi(cr,this,e[0])},exactPartial(...e){return Mi(Hu,this,e[0],"exactPartial")},required(...e){return Cp(ju,this,e[0])}});function b(e,t){let n={type:"object",shape:e??{},..._(t)};return new nf(n)}var Zu=h("ZodUnion",(e,t)=>{lo.init(e,t),N.init(e,t),e._zod.processJSONSchema=(n,o,r)=>Go(e,n,o,r),e.options=t.options});function Ge(e,t){return new Zu({type:"union",options:e,..._(t)})}var of=h("ZodDiscriminatedUnion",(e,t)=>{Zu.init(e,t),$a.init(e,t)});function ar(e,t,n){return new of({type:"union",options:t,discriminator:e,..._(n)})}var rf=h("ZodIntersection",(e,t)=>{La.init(e,t),N.init(e,t),e._zod.processJSONSchema=(n,o,r)=>Ko(e,n,o,r)});function sf(e,t){return new rf({type:"intersection",left:e,right:t})}var af=h("ZodTuple",(e,t)=>{It(),po.init(e,t),N.init(e,t),e._zod.processJSONSchema=(n,o,r)=>Wo(e,n,o,r)},{rest(e){return this.clone({...this._zod.def,rest:e})},partial(){let e=this._zod.def;if(e.checks?.length)throw Error(".partial() cannot be used on tuple schemas containing refinements");return this.clone({...e,items:e.items.map((t)=>new cr({type:"optional",innerType:t}))})}});function cf(e,t,n){let o=t instanceof z,r=o?n:t;return new af({type:"tuple",items:e,rest:o?t:null,..._(r)})}var Nu=h("ZodRecord",(e,t)=>{It(),Da.init(e,t),N.init(e,t),e._zod.processJSONSchema=(n,o,r)=>Jo(e,n,o,r),e.keyType=t.keyType,e.valueType=t.valueType});function j(e,t,n){if(!t||!t._zod)return new Nu({type:"record",keyType:u(),valueType:e,..._(t)});return new Nu({type:"record",keyType:e,valueType:t,..._(n)})}var sr=h("ZodEnum",(e,t)=>{Ba.init(e,t),N.init(e,t),e._zod.processJSONSchema=(o,r,i)=>Uo(e,o,r,i),e.enum=t.entries,e.options=[...e._zod.values];let n=new Set(Object.keys(t.entries));e.extract=(o,r)=>{let i={};for(let s of o)if(n.has(s))i[s]=t.entries[s];else throw Error(`Key ${s} not found in enum`);return new sr({...t,checks:[],..._(r),entries:i})},e.exclude=(o,r)=>{let i={...t.entries};for(let s of o)if(n.has(s))delete i[s];else throw Error(`Key ${s} not found in enum`);return new sr({...t,checks:[],..._(r),entries:i})}});function I(e,t){let n=Array.isArray(e)?Object.fromEntries(e.map((o)=>[o,o])):e;return new sr({type:"enum",entries:n,..._(t)})}var uf=h("ZodLiteral",(e,t)=>{Ua.init(e,t),N.init(e,t),e._zod.processJSONSchema=(n,o,r)=>Zo(e,n,o,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 V(e,t){return new uf({type:"literal",values:Array.isArray(e)?e:[e],..._(t)})}var lf=h("ZodTransform",(e,t)=>{It(),Za.init(e,t),N.init(e,t),e._zod.processJSONSchema=(n,o,r)=>jo(e,n,o,r),e._zod.parse=(n,o)=>{if(o.direction==="backward")throw new ht(e.constructor.name);n.addIssue=(i)=>{if(typeof i==="string")n.issues.push(Ne(i,n.value,t));else{let s=i;if(s.fatal)s.continue=!1;if(s.code??(s.code="custom"),!("input"in s))s.input=n.value;s.inst??(s.inst=e),n.issues.push(Ne(s))}};let r=t.transform(n.value,n);if(r instanceof Promise)return r.then((i)=>(n.value=i,n));return n.value=r,n}});function Fu(e){return new lf({type:"transform",transform:e})}var cr=h("ZodOptional",(e,t)=>{mo.init(e,t),N.init(e,t),e._zod.processJSONSchema=(n,o,r)=>ln(e,n,o,r),e.unwrap=()=>e._zod.def.innerType});function $u(e){return new cr({type:"optional",innerType:e})}var Hu=h("ZodExactOptional",(e,t)=>{Fa.init(e,t),N.init(e,t),e._zod.processJSONSchema=(n,o,r)=>ln(e,n,o,r),e.unwrap=()=>e._zod.def.innerType});function df(e){return new Hu({type:"optional",innerType:e})}var pf=h("ZodNullable",(e,t)=>{Ha.init(e,t),N.init(e,t),e._zod.processJSONSchema=(n,o,r)=>Yo(e,n,o,r),e.unwrap=()=>e._zod.def.innerType});function Lu(e){return new pf({type:"nullable",innerType:e})}var mf=h("ZodDefault",(e,t)=>{ja.init(e,t),N.init(e,t),e._zod.processJSONSchema=(n,o,r)=>er(e,n,o,r),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function ff(e,t){return new mf({type:"default",innerType:e,get defaultValue(){return typeof t==="function"?t():Dn(t)}})}var gf=h("ZodPrefault",(e,t)=>{Va.init(e,t),N.init(e,t),e._zod.processJSONSchema=(n,o,r)=>tr(e,n,o,r),e.unwrap=()=>e._zod.def.innerType});function hf(e,t){return new gf({type:"prefault",innerType:e,get defaultValue(){return typeof t==="function"?t():Dn(t)}})}var ju=h("ZodNonOptional",(e,t)=>{qa.init(e,t),N.init(e,t),e._zod.processJSONSchema=(n,o,r)=>Xo(e,n,o,r),e.unwrap=()=>e._zod.def.innerType});function yf(e,t){return new ju({type:"nonoptional",innerType:e,..._(t)})}var bf=h("ZodCatch",(e,t)=>{Ga.init(e,t),N.init(e,t),e._zod.processJSONSchema=(n,o,r)=>nr(e,n,o,r),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function xf(e,t){return new bf({type:"catch",innerType:e,catchValue:typeof t==="function"?t:$i(t)})}var Vu=h("ZodPipe",(e,t)=>{fo.init(e,t),N.init(e,t),e._zod.processJSONSchema=(n,o,r)=>or(e,n,o,r),e.in=t.in,e.out=t.out});function Du(e,t){return new Vu({type:"pipe",in:e,out:t})}var Sf=h("ZodPreprocess",(e,t)=>{Vu.init(e,t),Ka.init(e,t)}),_f=h("ZodReadonly",(e,t)=>{Wa.init(e,t),N.init(e,t),e._zod.processJSONSchema=(n,o,r)=>rr(e,n,o,r),e.unwrap=()=>e._zod.def.innerType});function vf(e){return new _f({type:"readonly",innerType:e})}var Tf=h("ZodPromise",(e,t)=>{Ya.init(e,t),N.init(e,t),e._zod.processJSONSchema=(n,o,r)=>ir(e,n,o,r),e.unwrap=()=>e._zod.def.innerType});function ur(e){return new Tf({type:"promise",innerType:e})}var Cf=h("ZodFunction",(e,t)=>{Ja.init(e,t),N.init(e,t),e._zod.processJSONSchema=(n,o,r)=>Ho(e,n,o,r)});function gn(e){return new Cf({type:"function",input:Array.isArray(e?.input)?cf(e?.input):e?.input??E(K()),output:e?.output??K()})}var qu=h("ZodCustom",(e,t)=>{Xa.init(e,t),N.init(e,t),e._zod.processJSONSchema=(n,o,r)=>Fo(e,n,o,r)});function se(e,t){return Fc(qu,e??(()=>!0),t)}function kf(e,t={}){return Hc(qu,e,t)}function Ef(e,t){return jc(e,t)}function Gu(e,t){return new Sf({type:"pipe",in:Fu(e),out:t})}var hn=["none","minimal","low","medium","high","xhigh","max"],lr=I(hn),yn=lr.exclude(["none"]),Rf=I([...hn,"default"]).nullable(),dr=ar("type",[b({type:V("toggle")}).strict(),b({type:V("effort"),values:E(Rf)}).strict(),b({type:V("budget_tokens"),min:x().min(-1).optional(),max:x().min(0).optional()}).strict().refine((e)=>e.min===void 0||e.max===void 0||e.min<=e.max,{message:"Minimum reasoning budget cannot exceed maximum",path:["min"]})]);var Ku=I(["default","openai-responses","r1"]),Af={DEFAULT:"default",OPENAI_RESPONSES:"openai-responses",R1:"r1"},Wu=I(["images","video","tools","streaming","prompt-cache","reasoning","reasoning-effort","computer-use","global-endpoint","structured_output","temperature","files"]),Ju=I(["active","preview","deprecated","legacy"]),Yu=b({input:x().optional(),output:x().optional(),cacheWrite:x().optional(),cacheRead:x().optional()}),Xu=b({maxBudget:x().optional(),outputPrice:x().optional(),thinkingLevel:I(["low","high"]).optional()}),Qu=b({reasoningDefaultOn:w().optional(),apiProtocol:I(["openai-chat","openai-responses","anthropic","gemini"]).optional()}).catchall(K()),pr=I(["text","image","audio","video","pdf"]),el=b({input:E(pr),output:E(pr)});function tl(e){return(e?.input===void 0||e.input.includes("text"))&&(e?.output===void 0||e.output.includes("text"))}var nl=I(["language","image-generation","speech-generation","video-generation","transcription","realtime"]);function If(e){let t=e.modalities?.input,n=e.modalities?.output;return t?.length===1&&t[0]==="audio"&&n?.length===1&&n[0]==="text"}function wf(e){return(e.operation===void 0||e.operation==="language")&&tl(e.modalities)}var ol=I(["batch","streaming"]);function Pf(e){return e.modalities?.input.includes("text")===!0&&e.modalities.output.includes("image")}function Mf(e){return e.operation==="image-generation"}function mr(e,t,n){let o=e.capabilities;if(o===void 0||o.length===0)return n?.assumeWhenUnspecified??!1;return o.includes(t)}function Of(e){return mr(e,"tools",{assumeWhenUnspecified:!0})}function zf(e){return mr(e,"images",{assumeWhenUnspecified:!0})}var bn=b({id:u(),name:u().optional(),description:u().optional(),maxTokens:x().optional(),contextWindow:x().optional(),maxInputTokens:x().optional(),capabilities:E(Wu).optional(),operation:nl.optional(),operationModes:E(ol).optional(),modalities:el.optional(),reasoningOptions:E(dr).optional(),apiFormat:Ku.optional(),systemRole:I(["system","developer"]).optional(),temperature:x().optional(),pricing:Yu.optional(),thinkingConfig:Xu.optional(),status:Ju.optional(),deprecationNotice:u().optional(),replacedBy:u().optional(),releaseDate:u().optional(),deprecationDate:u().optional(),family:u().optional(),metadata:Qu.optional()});var Nf="This tool call was rejected by the user and not executed.",$f="NOT a tool or system failure. Clarify with user before proceeding.",fr=b({id:u(),name:u(),execution:I(["client","provider"]).optional(),input:K(),output:K(),error:u().optional(),durationMs:x(),startedAt:fn(),endedAt:fn()});var Lf=I(["completed","max_iterations","aborted","mistake_limit","error"]),Df=b({inputTokens:x(),outputTokens:x(),cacheReadTokens:x().optional(),cacheWriteTokens:x().optional(),totalCost:x().optional()}),sv=b({text:u(),usage:Df,messages:E(se()),toolCalls:E(fr),iterations:x(),finishReason:Lf,model:b({id:u(),provider:u(),info:bn.optional()}),startedAt:fn(),endedAt:fn(),durationMs:x()}),av=b({distinctId:u().optional(),sessionId:u().optional(),providerId:u(),modelId:u(),apiKey:u().optional(),baseUrl:u().url().optional(),headers:j(u(),u()).optional(),knownModels:j(u(),bn).optional(),providerConfig:K().optional(),initialMessages:E(se()).optional(),systemPrompt:u(),tools:E(se()),modelTools:E(se()).optional(),maxIterations:x().positive().optional(),maxParallelToolCalls:x().int().positive().default(8),maxTokensPerTurn:x().positive().optional(),temperature:x().nonnegative().optional(),apiTimeoutMs:x().positive().default(180000),userFileContentLoader:gn().input([u()]).output(ur(u())).optional(),toolContextMetadata:j(u(),K()).optional(),execution:b({maxConsecutiveMistakes:x().int().positive().optional(),reminderAfterIterations:x().nonnegative().optional(),reminderText:u().optional(),loopDetection:Ge([V(!1),b({softThreshold:x().int().positive().optional(),hardThreshold:x().int().positive().optional()})]).optional()}).optional(),reasoningEffort:yn.optional(),thinkingBudgetTokens:x().positive().optional(),thinking:w().optional(),onEvent:gn().input([se()]).output(Qm()).optional(),hooks:se().optional(),parentAgentId:u().optional(),extensions:E(se()).optional(),hookErrorMode:I(["ignore","throw"]).default("ignore"),toolPolicies:j(u(),b({enabled:w().optional(),autoApprove:w().optional()})).optional(),requestToolApproval:gn().input([b({sessionId:u(),agentId:u(),conversationId:u(),iteration:x(),toolCallId:u(),toolName:u(),input:K(),policy:b({enabled:w().optional(),autoApprove:w().optional()}).default({})})]).output(Ge([b({approved:w(),reason:u().optional()}),ur(b({approved:w(),reason:u().optional()}))])).optional(),onConsecutiveMistakeLimitReached:gn().input([b({iteration:x().int().positive(),consecutiveMistakes:x().int().positive(),maxConsecutiveMistakes:x().int().positive(),reason:I(["api_error","invalid_tool_call","tool_execution_failed"]),details:u().optional()})]).output(Ge([b({action:V("continue"),guidance:u().optional()}),b({action:V("stop"),reason:u().optional()}),ur(Ge([b({action:V("continue"),guidance:u().optional()}),b({action:V("stop"),reason:u().optional()})]))])).optional(),logger:se().optional(),extensionContext:se().optional(),abortSignal:se().optional()});var rl=I(["connector.started","connector.stopping","session.authorize","message.received","message.denied","message.completed","message.failed","session.started","session.reused","session.reset","schedule.delivery.started","schedule.delivery.sent","schedule.delivery.failed"]),il=b({id:u().optional(),label:u().optional(),role:u().optional(),participantKey:u().optional(),participantLabel:u().optional(),platformUserId:u().optional(),metadata:j(u(),K()).optional()}),sl=b({source:u(),sourceEvent:u(),threadId:u(),channelId:u(),isDM:w(),sessionId:u().optional(),workspaceRoot:u().optional(),metadata:j(u(),K()).optional()}),Bf=b({actor:il,context:sl,payload:j(u(),K()).optional()}),Uf=b({action:I(["allow","deny"]).default("allow"),message:u().optional(),reason:u().optional(),metadata:j(u(),K()).optional()}),Zf=b({adapter:u(),botUserName:u().optional(),event:rl,payload:j(u(),K()),ts:u()});var al=[{name:"discord",description:"Discord interactions and gateway bridge backed by RPC runtime sessions"},{name:"gchat",description:"Google Chat webhook bridge backed by RPC runtime sessions"},{name:"linear",description:"Linear webhook bridge backed by RPC runtime sessions"},{name:"slack",description:"Slack webhook/socket bridge backed by RPC runtime sessions"},{name:"telegram",description:"Bridge Telegram bot messages into RPC chat sessions"},{name:"whatsapp",description:"Bridge WhatsApp webhook messages into RPC chat sessions"}];function cl(){return al.map((e)=>({...e}))}function ul(e,t){let n=e.includeWhen;if(!n)return!0;let o=t[n.flag]??"";if(n.equals!==void 0&&o!==n.equals)return!1;if(n.notEquals!==void 0&&o===n.notEquals)return!1;return!0}function Ff(e,t,n){let o={};for(let i of e.fields){let s=t[i.flag];o[i.flag]=typeof s==="string"?s.trim():i.initialValue??""}let r=[];for(let i of e.fields){if(!ul(i,o))continue;let s=o[i.flag]??"";if(!s){if(i.required)throw Error(`${i.label} is required`);continue}r.push(i.flag,s)}if(n?.enabled===!0&&e.security){let i={};for(let s of e.security.fields){let a=n.values[s.key]?.trim();if(!a)throw Error(s.requiredMessage);let c=s.validate?.(a);if(c)throw Error(c);i[s.key]=a}r.push(...e.security.buildArgs(i))}return r}function Hf(e,t){if(t.has(e))return{managed:!0,consumesNext:!0};for(let n of t)if(e.startsWith(`${n}=`))return{managed:!0,consumesNext:!1};return{managed:!1,consumesNext:!1}}function jf(e,t,n,o){let r=new Set([...e.fields.flatMap((s)=>[s.flag,...s.aliases??[]]),...e.derivedReconnectFlags??[]]);if(o.replaceSecurityArgs)for(let s of e.security?.argumentFlags??[])r.add(s);let i=[];for(let s=0;s<t.length;s+=1){let a=t[s]??"",c=Hf(a,r);if(!c.managed){i.push(a);continue}if(c.consumesNext)s+=1}return[...i,...n]}function Vf(e=ll){let t=new Set(cl().map((n)=>n.name));return e.filter((n)=>t.has(n.id)).map((n)=>({id:n.id,name:n.name,type:n.type,hint:n.hint,fields:n.fields.map((o)=>({flag:o.flag,label:o.label,placeholder:o.placeholder,required:o.required,help:o.help,initialValue:o.initialValue,options:o.options,includeWhen:o.includeWhen})),security:n.security?{prompt:n.security.prompt,fields:n.security.fields.map((o)=>({key:o.key,label:o.label,placeholder:o.placeholder,help:o.help,requiredMessage:o.requiredMessage}))}:void 0}))}function qf(e){return/^\d+$/.test(e)?void 0:"Telegram user ID must contain digits only"}function Gf(e){return/^T[A-Z0-9]+$/.test(e)?void 0:"Slack workspace ID must start with T and contain uppercase letters or digits only"}function Kf(e){return/^[UW][A-Z0-9]+$/.test(e)?void 0:"Slack member ID must start with U or W and contain uppercase letters or digits only"}var ll=[{id:"telegram",name:"Telegram",type:"polling",hint:"Easiest to set up. No public URL needed.",derivedReconnectFlags:["-m","--bot-username"],fields:[{flag:"-k",aliases:["--bot-token"],label:"Bot token",placeholder:"7123456789:AAH...",required:!0,help:["Open Telegram and start a chat with @BotFather","Send /newbot and follow the prompts","BotFather gives you this after creating the bot","It looks like 7123456789:AAHxxx..."]}],security:{prompt:"By default, anyone who finds your bot can message it and run tasks on your machine. Restrict access to your Telegram user ID?",fields:[{key:"userId",label:"Your Telegram user ID",placeholder:"123456789",help:["Message @userinfobot on Telegram","It will reply with your numeric user ID"],requiredMessage:"User ID is required to restrict access",validate:qf}],argumentFlags:["--allowed-user-id","--hook-command"],buildArgs:({userId:e})=>["--allowed-user-id",e??""]}},{id:"slack",name:"Slack",type:"hybrid",hint:"Public URL for webhook mode; leave blank for socket mode.",fields:[{flag:"--bot-token",label:"Bot token",placeholder:"xoxb-...",required:!0,help:["Go to api.slack.com/apps and create a new app","Add Bot Token Scopes: chat:write, app_mentions:read, channels:history, channels:read, im:history, im:read, im:write, users:read","Install to workspace and copy the Bot Token"]},{flag:"--base-url",label:"Public base URL",placeholder:"leave blank for socket mode",help:["Enter a publicly accessible URL for webhook mode","Leave blank to use Slack socket mode instead"]},{flag:"--signing-secret",label:"Signing secret",required:!0,help:["Found in your app's Basic Information page"],includeWhen:{flag:"--base-url",notEquals:""}},{flag:"--app-token",label:"App-level token",placeholder:"xapp-...",required:!0,help:["Enable Socket Mode in the Slack app","Generate an app-level token with the connections:write scope"],includeWhen:{flag:"--base-url",equals:""}}],security:{prompt:"Restrict which Slack users can interact with the bot?",fields:[{key:"teamId",label:"Allowed Slack workspace ID",placeholder:"T01ABC123",help:["Open your Slack workspace URL in a browser","The workspace ID is the segment after /client/, for example T01ABC123"],requiredMessage:"Workspace ID is required to restrict access",validate:Gf},{key:"userId",label:"Allowed Slack member ID",placeholder:"U01ABC123",help:["Click a user's name in Slack, then View full profile","Click ... and Copy member ID"],requiredMessage:"Member ID is required to restrict access",validate:Kf}],argumentFlags:["--hook-command"],buildArgs:({teamId:e,userId:t})=>["--hook-command",`jq -r ".payload.actor.participantKey" | grep -qx "slack:team:${e}:user:${t}" && echo '{"action":"allow"}' || echo '{"action":"deny"}'`]}},{id:"discord",name:"Discord",type:"webhook",hint:"Requires a Discord app and public URL.",fields:[{flag:"--application-id",aliases:["--app-id"],label:"Application ID",required:!0,help:["Go to discord.com/developers/applications","Create a new app, copy the Application ID"]},{flag:"--bot-token",aliases:["--token"],label:"Bot token",required:!0,help:["Go to Bot section, create a bot, copy the token"]},{flag:"--public-key",label:"Public key",required:!0,help:["Found in General Information of your app"]},{flag:"--base-url",label:"Public base URL",placeholder:"https://example.com",required:!0,help:["Base URL for the connector","For Discord, set the Interactions Endpoint URL to <base-url>/api/webhooks/discord"]}]},{id:"whatsapp",name:"WhatsApp",type:"webhook",hint:"Requires Meta developer account and public URL.",fields:[{flag:"--phone-number-id",label:"Phone number ID",required:!0,help:["From your WhatsApp Business account in Meta Developer portal"]},{flag:"--access-token",label:"Access token",required:!0,help:["Generate a permanent token in Meta Developer portal"]},{flag:"--app-secret",label:"App secret",required:!0,help:["Found in App Settings > Basic"]},{flag:"--verify-token",label:"Webhook verify token",placeholder:"my-verify-token",required:!0,help:["Any string you choose, used to verify webhook setup"]},{flag:"--base-url",label:"Public base URL",placeholder:"https://example.com",required:!0}]},{id:"gchat",name:"Google Chat",type:"webhook",hint:"Requires Google Cloud project and public URL.",fields:[{flag:"--credentials-json",label:"Service account credentials JSON",required:!0,help:["Create a service account in Google Cloud Console","Download the credentials JSON file","Paste the JSON content here"]},{flag:"--base-url",label:"Public base URL",placeholder:"https://example.com",required:!0}]},{id:"linear",name:"Linear",type:"webhook",hint:"React to Linear issues and comments.",fields:[{flag:"--api-key",label:"API key",required:!0,help:["Go to Linear Settings > API > Personal API keys"]},{flag:"--webhook-secret",label:"Webhook signing secret",required:!0,help:["Go to Settings > API > Webhooks, create one","Copy the signing secret"]},{flag:"--base-url",label:"Public base URL",placeholder:"https://example.com",required:!0}]}];var dl=[];function gr(e){dl.push(e)}async function Wf(){let e=dl.splice(0);await Promise.all(e.map((t)=>{try{return(typeof t==="function"?t():t.dispose())??Promise.resolve()}catch{return Promise.resolve()}}))}var Jf=["hooks","tools","commands","rules","skills","messageBuilders","providers","automationEvents","mcp"],Yf=new Set(Jf);function fl(e,t){return e.name||`extension_${String(t).padStart(4,"0")}`}function pl(e){return Array.isArray(e)&&e.every((t)=>typeof t==="string")}function ml(e){if(!Array.isArray(e))return;let t=e.filter((n)=>typeof n==="string").map((n)=>n.trim()).filter((n)=>n.length>0);return t.length>0?t:void 0}function gl(e){let t=ml(e.providerIds),n=ml(e.modelIds);return{...e,...t?{providerIds:t}:{},...n?{modelIds:n}:{}}}function Xf(e,t){let n=fl(e,t),o=e.manifest;if(!o||typeof o!=="object")throw Error(`Invalid manifest for extension "${n}": manifest is required`);if(!Array.isArray(o.capabilities)||o.capabilities.length===0)throw Error(`Invalid manifest for extension "${n}": capabilities must be a non-empty array`);let r=new Set;for(let a of o.capabilities){if(!Yf.has(a))throw Error(`Invalid manifest for extension "${n}": unsupported capability "${String(a)}"`);r.add(a)}if(Object.hasOwn(o,"providerIds")&&!pl(o.providerIds))throw Error(`Invalid manifest for extension "${n}": providerIds must be a string array when provided`);if(Object.hasOwn(o,"modelIds")&&!pl(o.modelIds))throw Error(`Invalid manifest for extension "${n}": modelIds must be a string array when provided`);let i=r.has("hooks");if(e.hooks!==void 0&&!i)throw Error(`Invalid manifest for extension "${n}": runtime hooks require the "hooks" capability`);return{capabilities:r,raw:gl(o)}}function Qf(e,t){if(!e||typeof e!=="object")throw Error(`Invalid automation event contribution for extension "${t}": expected object`);let n=typeof e.eventType==="string"?e.eventType.trim():"",o=typeof e.source==="string"?e.source.trim():"";if(!n)throw Error(`Invalid automation event contribution for extension "${t}": eventType is required`);if(!o)throw Error(`Invalid automation event contribution for extension "${t}": source is required`);return{...e,eventType:n,source:o,examples:e.examples?[...e.examples]:void 0,metadata:e.metadata?{...e.metadata}:void 0}}class hr{extensions;registry={tools:[],commands:[],rules:[],messageBuilder:[],providers:[],automationEventTypes:[],mcpServers:[]};normalized=[];phase="resolve";setupContext;constructor(e={}){this.extensions=e.extensions??[],this.setupContext=e.setupContext??{}}resolve(){if(this.phase!=="resolve")return;this.normalized=this.extensions.map((e,t)=>({extension:e,order:t,manifest:{capabilities:new Set,raw:e.manifest}})),this.phase="validate"}validate(){if(this.phase==="resolve")this.resolve();if(this.phase!=="validate")return;this.normalized=this.normalized.map((e)=>({...e,manifest:Xf(e.extension,e.order)})),this.phase="setup"}async setup(e={}){if(this.phase==="resolve")this.resolve();if(this.phase==="validate")this.validate();if(this.phase!=="setup")return;let t,n=[];for(let o of this.normalized){let{extension:r}=o;if(r.disabled)continue;let i=fl(r,o.order),s={tools:[],commands:[],rules:[],messageBuilder:[],providers:[],automationEventTypes:[],mcpServers:[]},a={registerTool:(l)=>s.tools.push(l),registerCommand:(l)=>s.commands.push(l),registerRule:(l)=>{if(!o.manifest.capabilities.has("rules"))throw Error(`Invalid setup for extension "${i}": registerRule requires the "rules" capability`);s.rules.push(l)},registerMessageBuilder:(l)=>s.messageBuilder.push(l),registerProvider:(l)=>s.providers.push(l),registerAutomationEventType:(l)=>{if(!o.manifest.capabilities.has("automationEvents"))throw Error(`Invalid setup for extension "${i}": registerAutomationEventType requires the "automationEvents" capability`);s.automationEventTypes.push(Qf(l,i))},registerMcpServer:(l)=>{if(!o.manifest.capabilities.has("mcp"))throw Error(`Invalid setup for extension "${i}": registerMcpServer requires the "mcp" capability`);s.mcpServers.push({...l,metadata:{...l.metadata??{},source:"plugin",plugin:i}})}},c=o.manifest.capabilities.has("automationEvents")?this.setupContext:{...this.setupContext,automation:void 0};try{await r.setup?.(a,c),n.push(s)}catch(l){if(e.tolerateSetupErrors!==!0)throw l;t??=l}}if(t&&e.tolerateSetupErrors!==!0)throw t;for(let o of n)this.registry.tools.push(...o.tools),this.registry.commands.push(...o.commands),this.registry.rules.push(...o.rules),this.registry.messageBuilder.push(...o.messageBuilder),this.registry.providers.push(...o.providers),this.registry.automationEventTypes.push(...o.automationEventTypes),this.registry.mcpServers.push(...o.mcpServers);if(this.phase="activate",t)throw t}activate(){if(this.phase==="resolve")this.resolve();if(this.phase==="validate")this.validate();if(this.phase==="setup")throw Error("Contribution registry setup must complete before activation");if(this.phase!=="activate")return;this.phase="run"}async initialize(e={}){this.resolve(),this.validate();try{await this.setup(e)}finally{if(this.phase==="activate")this.activate()}}isActivated(){return this.phase==="run"}getRegistrySnapshot(){return{tools:[...this.registry.tools],commands:[...this.registry.commands],rules:[...this.registry.rules],messageBuilder:[...this.registry.messageBuilder],providers:[...this.registry.providers],automationEventTypes:[...this.registry.automationEventTypes],mcpServers:[...this.registry.mcpServers]}}getRegisteredTools(){return[...this.registry.tools]}getRegisteredRules(){return[...this.registry.rules]}getRegisteredAutomationEventTypes(){return[...this.registry.automationEventTypes]}getRegisteredMcpServers(){return[...this.registry.mcpServers]}getValidatedExtensions(){if(this.phase==="resolve")this.resolve();if(this.phase==="validate")this.validate();return this.normalized.slice().sort((e,t)=>e.order-t.order).map(({extension:e})=>e)}}function eg(e={}){return new hr(e)}var tg=[".js",".ts"];var Ke={CLINE_PASS:"ext-cline-pass",CODE_CLOUD_AGENTS:"code-cloud-agents",CODE_ONBOARDING_GITHUB:"code-onboarding-github",CLINE_COMPOSIO_BETA:"CLINE_COMPOSIO_BETA"},ng={[Ke.CLINE_PASS]:!1,[Ke.CODE_CLOUD_AGENTS]:!1,[Ke.CODE_ONBOARDING_GITHUB]:!1,[Ke.CLINE_COMPOSIO_BETA]:!1},og=Object.values(Ke);var hl=I(["agent_start","agent_resume","agent_abort","agent_end","agent_error","tool_call","tool_result","prompt_submit","pre_compact","session_shutdown"]),$e=j(u(),u()),rg=b({toolName:u(),parameters:$e}),ig=b({toolName:u(),parameters:$e,result:u(),success:w(),executionTimeMs:x()}),sg=b({prompt:u(),attachments:E(u())}),ag=b({taskMetadata:$e}),cg=b({taskMetadata:$e,previousState:$e}),ug=b({taskMetadata:$e}),lg=b({taskMetadata:$e}),dg=b({taskId:u(),ulid:u(),contextSize:x(),compactionStrategy:u(),previousApiReqIndex:x(),tokensIn:x(),tokensOut:x(),tokensInCache:x(),tokensOutCache:x(),deletedRangeStart:x(),deletedRangeEnd:x(),contextJsonPath:u(),contextRawPath:u()}),yl=b({clineVersion:u(),hookName:hl,timestamp:u(),taskId:u(),sessionContext:b({rootSessionId:u().optional(),hookLogPath:u().optional()}).optional(),workspaceRoots:E(u()),workspaceInfo:se().optional(),userId:u(),agent_id:u(),parent_agent_id:u().nullable(),iteration:x().optional(),reason:u().optional(),tool_call:b({id:u(),name:u(),input:K()}).optional(),tool_result:se().optional(),turn:K().optional(),error:b({name:u(),message:u(),stack:u().optional()}).optional(),preToolUse:rg.optional(),postToolUse:ig.optional(),userPromptSubmit:sg.optional(),taskStart:ag.optional(),taskResume:cg.optional(),taskCancel:ug.optional(),taskComplete:lg.optional(),preCompact:dg.optional()}).passthrough();function pg(e){let t=yl.safeParse(e);if(!t.success)return;return t.data}var _v="v1",vv="v1",Tv="v1",Cv=["client.register","client.list","session.create","session.list","session.get","session.run","session.abort","schedule.create","schedule.list","task.create","task.list","task.get","task.update","task.approve","task.cancel","task.run","task.automation.get","task.automation.set","settings.get","settings.set","connector.start","connector.stop","connector.supervised","run.enqueue","run.list","hub.drain","hub.status","stream.replay"];function xn(e){let t=/^v(\d+)$/.exec(e?.trim()??"");if(!t)return;return Number.parseInt(t[1]??"",10)}function kv(e,t="v1"){let n=xn(e.protocolVersion),o=xn(t);if(n===void 0||o===void 0)return{compatible:!1,reason:"missing_protocol"};let r=xn(e.minClientProtocolVersion)??n,i=xn(e.maxClientProtocolVersion)??n;return o>=r&&o<=i?{compatible:!0}:{compatible:!1,reason:"unsupported_protocol"}}var Ev="approval.respond",Rv="0",Av="__hubScheduleRunAt",bl=["act","plan","yolo"];function mg(e){return bl.some((t)=>t===e)}function Iv(e,t){if(!e||!Object.hasOwn(e,"mode"))return t;let n=e.mode;if(mg(n))return n;throw Error(`mode must be one of: ${bl.join(", ")}`)}var fg=30000,wv=5000;function gg(e){switch(e){case"run.start":case"session.send_input":return null;default:return fg}}function Pv(e,t){return t===void 0?gg(e):t}var hg=["readFile","search","bash","webFetch","editor","applyPatch","skills","askQuestion","submit"],yg=new Set(hg);function Mv(e){return typeof e==="string"&&yg.has(e)}var Ov="tool_executor.",zv="custom_tool.",Nv="hook.",$v="compaction.compact",Lv="checkpoint.create",Dv="mistake_limit.decide",Bv="user_instructions.snapshot";function Uv(e){let t=e.activeSessionCount;if(typeof t!=="number"||t<=0)return"active sessions from other Cline clients";let n=`${t} active session${t===1?"":"s"}`,o=e.participantClientCount;if(typeof o!=="number"||o<=0)return n;return`${n} from ${o} connected Cline client${o===1?"":"s"}`}function yr(e,t){return`<file_content path="${e}">
59
59
  ${t}
60
- </file_content>`}function bg(e,t="act"){return`<user_input mode="${t}">${e}</user_input>`}function xg(e,t){return`<user_command slash="${t}">${e}</user_command>`}var Sg=/<user_input\b[^>]*\bmode="(act|plan|yolo)"/;function _g(e){let t=Sg.exec(e??"");return t?t[1]:void 0}function vg(e,t){return`<mode_notice>The user switched from ${e} mode to ${t} mode before sending this message.</mode_notice>`}function Tg(){let e=null;return{record(t,n){if(t===n)return;if(e){e=e.from===n?null:{from:e.from,to:n};return}e={from:t,to:n}},consume(){let t=e;return e=null,t}}}function Cg(e,t){let n=e.trim(),o=new RegExp(`^<${t}\\b([^>]*)>([\\s\\S]*?)<\\/${t}>$`,"i").exec(n);if(!o)return;return{attrs:o[1]??"",content:o[2]??""}}function kg(e,t){return new RegExp(`${t}="([^"]+)"`,"i").exec(e)?.[1]?.trim()||void 0}function xl(e){if(!e?.trim())return;let t=Cg(e,"user_command");if(!t)return;let n=kg(t.attrs,"slash");if(!n)return;return{slash:n,content:t.content.trim()}}function Sl(e){if(!e?.trim())return"";let t=e.trim();for(let n of["user_input","user_command"]){let o=kl(t,n);t=(o!==t?o:t.replace(new RegExp(`<${n}[^>]*>`,"g"),"")).trim()}return t}function _l(e){if(!e?.trim())return"";return Eg(e,"mode_notice").trim()}function Eg(e,t){let n=`<${t}>`,o=`</${t}>`,r=e,i=r.indexOf(n);while(i!==-1){let s=r.indexOf(o,i+n.length);if(s===-1)break;r=r.slice(0,i)+r.slice(s+o.length),i=r.indexOf(n,i)}return r}function br(e){let t=_l(Sl(e)),n=xl(e);if(!n)return t;if(n.slash.toLowerCase()==="team"){let r=t.toLowerCase().startsWith("spawn a team of agents for the following task:")?t.slice(46).trim():t;return r?`/team ${r}`:"/team"}return t?`/${n.slash} ${t}`:`/${n.slash}`}var vl=240,Tl=480;function Cl(e,t){let n=e.replace(/\s+/gu," ").trim();if(n.length<=t)return n;return`${n.slice(0,t-1).trimEnd()}…`}function Rg(e){return Cl(br(e),vl)}function Ag(e,t){let n=t?.trim()??"",o=e.toLowerCase(),r=o==="user"||o==="session"?br(n):n;return Cl(r,Tl)}function kl(e,t){if(!e?.trim())return"";if(!t)return e;let n=new RegExp(`<${t}\\b[^>]*>([\\s\\S]*?)</${t}>`,"g");return e.replace(n,"$1")}var We="[media omitted: invalid or exceeds size limit]",Je="[Image attached — this model cannot view images]",El=I(["image","audio","video","file"]),Rl=ar("type",[b({type:V("base64"),data:u().min(1)}),b({type:V("url"),url:u().url().refine((e)=>{let t=new URL(e).protocol;return t==="http:"||t==="https:"},"Generated media URLs must use HTTP or HTTPS")}),b({type:V("artifact"),artifactId:u().min(1)})]);function Al(e){if(e.startsWith("image/"))return"image";if(e.startsWith("audio/"))return"audio";if(e.startsWith("video/"))return"video";return"file"}var Il=b({id:u().min(1),modality:El,mediaType:u().min(1),source:Rl,name:u().min(1).optional(),sizeBytes:x().int().nonnegative().optional()}).refine((e)=>Al(e.mediaType)===e.modality,{message:"Generated media modality must match its media type",path:["modality"]});function Ig(e){return Il.safeParse(e).success}function wg(e){return Al(e)}var _n=["image/png","image/jpeg","image/gif","image/webp"],xr=5242880,fe=xr,Se=6291456,wl=8388608;function Pg(e){return e.length}function Sr(e){let t=e.endsWith("==")?2:e.endsWith("=")?1:0;return Math.floor(e.length*3/4)-t}function Mg(e=xr){return Math.floor(e*3/4)}function _r(e){return Math.ceil(e/3)*4}function vr(e={}){return{maxImageEncodedBytes:e.maxImageEncodedBytes??fe,maxImageDecodedBytes:e.maxImageDecodedBytes??Se,maxTotalMediaBytes:e.maxTotalMediaBytes??wl}}function vn(){return{totalEncodedBytes:0,keptImages:0,omittedImages:0,omittedReasons:{}}}function Sn(e,t){e.omittedImages+=1,e.omittedReasons[t]=(e.omittedReasons[t]??0)+1}function wt(e,t,n,o){let r=vr(n);if(e>r.maxImageEncodedBytes){let i={ok:!1,reason:"encoded_limit",message:`Image media exceeds the ${r.maxImageEncodedBytes} byte encoded limit`};return Sn(o,i.reason),i}if(t>r.maxImageDecodedBytes){let i={ok:!1,reason:"decoded_limit",message:`Image media exceeds the ${r.maxImageDecodedBytes} byte decoded limit`};return Sn(o,i.reason),i}if(o.totalEncodedBytes+e>r.maxTotalMediaBytes){let i={ok:!1,reason:"total_limit",message:`Image media exceeds the ${r.maxTotalMediaBytes} byte total media limit`};return Sn(o,i.reason),i}return o.totalEncodedBytes+=e,o.keptImages+=1,null}function Pl(e){return e>=65&&e<=90||e>=97&&e<=122||e>=48&&e<=57||e===43||e===47}function Og(e){return e.length>0&&Tr(e,0,e.length)}function zg(e,t,n){let o=Ml(e),r=o.end-o.start;if(r===0)return{ok:!1,reason:"invalid_base64",message:"Generated media must contain valid base64"};let i=vr(t);if(n.totalEncodedBytes+r>i.maxTotalMediaBytes)return{ok:!1,reason:"total_limit",message:`Generated media exceeds the ${i.maxTotalMediaBytes} byte total media limit`};if(!Tr(e,o.start,o.end))return{ok:!1,reason:"invalid_base64",message:"Generated media must contain valid base64"};let s=e.slice(o.start,o.end);return n.totalEncodedBytes+=r,{ok:!0,base64:s,encodedBytes:r,decodedBytes:Sr(s)}}function Tr(e,t,n){let o=n-t;if(o%4!==0)return!1;let r=n;if(o>=2&&e.charCodeAt(n-2)===61&&e.charCodeAt(n-1)===61)r-=2;else if(o>=1&&e.charCodeAt(n-1)===61)r-=1;for(let i=t;i<r;i++)if(!Pl(e.charCodeAt(i)))return!1;for(let i=r;i<n;i++)if(e.charCodeAt(i)!==61)return!1;return!0}function Ng(e,t,n){return n-t>=5&&(e.charCodeAt(t)|32)===100&&(e.charCodeAt(t+1)|32)===97&&(e.charCodeAt(t+2)|32)===116&&(e.charCodeAt(t+3)|32)===97&&e.charCodeAt(t+4)===58}function Ml(e){let t=0,n=e.length;while(t<n&&/\s/.test(e[t]??""))t+=1;while(n>t&&/\s/.test(e[n-1]??""))n-=1;return{start:t,end:n}}function $g(e,t,n){if(!Ng(e,t,n))return;let o=t+5,r=e.indexOf(",",o);if(r===-1||r>=n)return;if(r-o>128)return;let i=e.slice(o,r).toLowerCase(),s=";base64";if(!i.endsWith(s))return;let a=i.slice(0,-s.length);if(!a||a.includes(";"))return;return{mediaType:a,base64Start:r+1,base64End:n}}function Ol(e,t,n={}){let o=n.maxEncodedBytes??fe,r=n.maxDecodedBytes??Se,i=new Set(n.supportedMediaTypes??_n),s=e?.toLowerCase(),a=Ml(t),{start:c,end:l}=a,d=$g(t,a.start,a.end);if(d){if(s&&s!==d.mediaType)return{ok:!1,reason:"media_type_mismatch",message:`Image media type ${e} does not match data URL type ${d.mediaType}`};s=d.mediaType,c=d.base64Start,l=d.base64End}if(!s||!i.has(s))return{ok:!1,reason:"unsupported_media_type",message:`Unsupported image media type: ${e??"unknown"}`};let p=l-c;if(p===0)return{ok:!1,reason:"invalid_base64",message:"Image media must contain valid base64"};if(p>o)return{ok:!1,reason:"encoded_limit",message:`Image media exceeds the ${o} byte encoded limit`};if(!Tr(t,c,l))return{ok:!1,reason:"invalid_base64",message:"Image media must contain valid base64"};let m=t.slice(c,l),f=Sr(m);if(f>r)return{ok:!1,reason:"decoded_limit",message:`Image media exceeds the ${r} byte decoded limit`};return{ok:!0,mediaType:s,base64:m,encodedBytes:p,decodedBytes:f}}function Pt(e,t,n,o){let r=Ol(e,t,{maxEncodedBytes:n.maxImageEncodedBytes,maxDecodedBytes:n.maxImageDecodedBytes});if(!r.ok)return Sn(o,r.reason),r;let i=wt(r.encodedBytes,r.decodedBytes,n,o);if(i)return i;return r}function ae(e){return e.replace(/[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?<![\uD800-\uDBFF])[\uDC00-\uDFFF]/g,"�")}var Mt="ERROR: EMPTY CONTENT",Lg="[image attached]",Dg="[generated image]";function Bg(e){return`[generated ${e}]`}function Tn(e){return{type:"text",text:`[generated ${e.modality} unavailable to this model]`}}function Cr(e,t){let n=e[e.length-1];if(t.role==="tool"&&n?.role==="tool"&&Array.isArray(n.content)&&Array.isArray(t.content)){n.content.push(...t.content);return}e.push(t)}function Ug(e){if(!Array.isArray(e)||e.length===0)return!1;return e.every((t)=>{if(!t||typeof t!=="object")return!1;let n=t;if(n.type==="text")return typeof n.text==="string";if(n.type==="image")return typeof n.data==="string"&&typeof n.mediaType==="string";return!1})}function Le(){return{type:"text",text:We}}function zl(e){return wt(fe,0,{maxImageEncodedBytes:fe,maxImageDecodedBytes:Se},e)===null}function $l(e){try{return new URL(e).protocol}catch{return}}function kr(e,t){let n=Pt(e.mediaType,e.data,{maxImageEncodedBytes:fe,maxImageDecodedBytes:Se},t);if(!n.ok)return Le();return Ll(n.base64,n.mediaType)}function Ll(e,t){return{type:"file",data:{type:"data",data:e},mediaType:t}}function Ye(e,t){return{type:"file",data:e,mediaType:t??"image"}}function Er(e,t){if(e.image instanceof URL){if(e.image.protocol==="data:"){let s=Pt(e.mediaType,e.image.href,{maxImageEncodedBytes:fe,maxImageDecodedBytes:Se},t);if(!s.ok)return Le();return Ye(`data:${s.mediaType};base64,${s.base64}`,s.mediaType)}if(e.image.protocol!=="http:"&&e.image.protocol!=="https:")return Le();if(!zl(t))return Le();return Ye(e.image,e.mediaType)}if(typeof e.image==="string"){let s=$l(e.image);if(s==="http:"||s==="https:"){if(!zl(t))return Le();return Ye(e.image,e.mediaType)}let a=s==="data:",c=Pt(e.mediaType??(a?void 0:"image/png"),e.image,{maxImageEncodedBytes:fe,maxImageDecodedBytes:Se},t);if(!c.ok)return Le();return Ye(a?`data:${c.mediaType};base64,${c.base64}`:c.base64,c.mediaType)}let n=e.image.byteLength,o=_r(n),r=e.mediaType?.toLowerCase()??"image/png";if(!_n.includes(r)||wt(o,n,{maxImageEncodedBytes:fe,maxImageDecodedBytes:Se},t))return Le();return Ye(e.image,r)}function Zg(e,t){if(!t)return!0;if(e.modality==="file")return e.mediaType==="application/pdf"&&t.includes("pdf");return t.includes(e.modality)}function Nl(e,t,n){if(!Zg(e,n))return Tn(e);if(e.modality==="image"){if(e.source.type==="artifact")return Tn(e);return Er({type:"image",image:e.source.type==="url"?e.source.url:e.source.data,mediaType:e.mediaType},t)}if(e.source.type==="artifact")return Tn(e);if(e.source.type==="url"){let o=$l(e.source.url);if(o!=="http:"&&o!=="https:"&&o!=="data:")return Tn(e)}return Ye(e.source.type==="url"?e.source.url:e.source.data,e.mediaType)}function Rr(e,t,n,o){let{hoistImages:r,inlineImagePlaceholder:i}=o;if(e==null||typeof e!=="object")return{value:e,changed:!1,mediaChanged:!1};if(Array.isArray(e)){let d=[],p=!1,m=!1;for(let f of e){if(f&&typeof f==="object"){let y=f;if(y.type==="image"&&typeof y.data==="string"&&typeof y.mediaType==="string"){if(!r){d.push(i),p=!0,m=!0;continue}let S={type:"image",data:y.data,mediaType:y.mediaType},v=kr(S,n);if(v.type==="file")t.push({type:"image",data:v.data.data,mediaType:v.mediaType});else d.push(v.text);p=!0,m=!0;continue}if(y.type==="image"){d.push(We),p=!0,m=!0;continue}if(y.type==="text"&&typeof y.text==="string"){d.push(y.text),p=!0;continue}}let g=Rr(f,t,n,o);d.push(g.value),p||=g.changed,m||=g.mediaChanged}return{value:p?d:e,changed:p,mediaChanged:m}}let s=e;if(s.type==="image"){if(typeof s.data==="string"&&typeof s.mediaType==="string"){if(!r)return{value:i,changed:!0,mediaChanged:!0};let d={type:"image",data:s.data,mediaType:s.mediaType},p=kr(d,n);if(p.type==="file")return t.push({type:"image",data:p.data.data,mediaType:p.mediaType}),{value:Lg,changed:!0,mediaChanged:!0};return{value:p.text,changed:!0,mediaChanged:!0}}return{value:We,changed:!0,mediaChanged:!0}}let a={},c=!1,l=!1;for(let[d,p]of Object.entries(s)){let m=Rr(p,t,n,o);a[d]=m.value,c||=m.changed,l||=m.mediaChanged}return{value:c?a:e,changed:c,mediaChanged:l}}function Ot(e){if(typeof e==="string")return ae(e);if(Array.isArray(e))return e.map((t)=>Ot(t));if(e!==null&&typeof e==="object"){let t=e,n={};for(let[o,r]of Object.entries(t))n[o]=Ot(r);return n}return e}function Dl(e,t=!1,n=vn(),o){let r=o?.supportsImages??!0;if(typeof e==="string")return{type:t?"error-text":"text",value:ae(e)};if(!t&&Ug(e))return{type:"content",value:e.map((i)=>i.type==="image"?r?kr(i,n):{type:"text",text:Je}:{type:"text",text:ae(i.text)})};if(e!==null&&typeof e==="object"){let i=[],s=Rr(e,i,n,{hoistImages:!t&&r,inlineImagePlaceholder:r?We:Je});if(!t&&i.length>0)return{type:"content",value:[{type:"text",text:typeof s.value==="string"?ae(s.value):JSON.stringify(Ot(s.value))},...i.map((c)=>Ll(c.data,c.mediaType))]};if(s.mediaChanged)return{type:t?"error-json":"json",value:Ot(s.value)}}if(e===null||typeof e==="boolean"||typeof e==="number"||typeof e==="object")return{type:t?"error-json":"json",value:Ot(e)};return{type:t?"error-text":"text",value:ae(String(e))}}function Fg(e,t,n){let o=n?.assistantToolCallArgKey??"input",r=n?.supportedInputModalities,i=!r||r.includes("image"),s=[],a=vn(),c=[],l=()=>c.splice(0).map((p)=>p.type==="image"?i?Er(p,a):{type:"text",text:Je}:Nl(p.media,a,r));if(typeof e==="string"&&e.trim().length>0||Array.isArray(e)&&e.length>0)s.push({role:"system",content:typeof e==="string"?ae(e):e});for(let d of t){let p=d.content;if(typeof p==="string"){let y=d.role==="user"&&c.length>0?l():[];if(y.length>0){s.push({role:d.role,content:[{type:"text",text:p.trim().length>0?ae(p):Mt},...y]});continue}if(p.trim().length===0){s.push({role:d.role,content:[{type:"text",text:Mt}]});continue}s.push({role:d.role,content:ae(p)});continue}let m=[],f=[];if(p.length===0){s.push({role:d.role,content:[{type:"text",text:Mt}]});continue}for(let y of p)switch(y.type){case"text":m.push({type:"text",text:ae(y.text),...y.providerOptions?{providerOptions:y.providerOptions}:{}});break;case"reasoning":m.push({type:"reasoning",text:ae(y.text),...y.providerOptions?{providerOptions:y.providerOptions}:{}});break;case"image":if(d.role==="assistant")c.push(y),m.push({type:"text",text:Dg});else m.push(i?Er(y,a):{type:"text",text:Je});break;case"media":if(d.role==="assistant")c.push(y),m.push({type:"text",text:Bg(y.media.modality)});else m.push(Nl(y.media,a,r));break;case"file":m.push({type:"text",text:yr(y.path,ae(y.content))});break;case"tool-call":if(d.role==="assistant")m.push({type:"tool-call",toolCallId:y.toolCallId,toolName:y.toolName,[o]:y.input,...y.providerOptions?{providerOptions:y.providerOptions}:{}});break;case"tool-result":{f.push({type:"tool-result",toolCallId:y.toolCallId,toolName:y.toolName,output:Dl(y.output,y.isError??!1,a,{supportsImages:i})});break}}let g=f.length>0;if(d.role==="user"&&!g&&c.length>0)m.push(...l());if(m.length>0&&m.every((y)=>y.type==="text"&&typeof y.text==="string"&&y.text.trim().length===0))m.splice(0,m.length,{type:"text",text:Mt});if(m.length>0)Cr(s,{role:d.role,content:m});if(g)Cr(s,{role:"tool",content:f})}if(c.length>0)Cr(s,{role:"user",content:l()});return s}var Gv=["show","hide","subscription"];function Bl(e){return typeof e==="object"&&e!==null&&!Array.isArray(e)}function Hg(e,t){if(!e&&!t)return;let n=e?.metadata,o=t?.metadata,r={...e??{},...t??{}};if(Bl(n)&&Bl(o))r.metadata={...n,...o};return r}var Jv=["web_search","image_generation"],Yv=["web_search"];var zt={max:1,xhigh:0.95,high:0.8,medium:0.5,low:0.2,minimal:0.1,none:0},jg=void 0;function Vg(e,t){if(typeof e==="string"&&e.toLowerCase()in zt)return e.toLowerCase();return t?void 0:void 0}function Ul(e,t){let n=typeof e==="string"?e.toLowerCase():void 0;if(n&&n in zt)return zt[n];if(t?.fallbackEffort)return zt[t.fallbackEffort];return}function qg(e){let t=Ul(e.effort,{fallbackEffort:e.fallbackEffort});if(t===void 0)return;if(t<=0)return 0;let n=e.minimumBudget??1;if(e.maxBudget<n)return;let o=e.scaleTokens??e.maxBudget;return Math.min(Math.max(Math.floor(o*t),n),e.maxBudget)}function Gg(e){return e instanceof Error?{name:e.name,message:e.message}:e}var Kg=3;function Zl(e){return Math.max(1,Math.ceil(e/3))}function Ar(e){let t=new WeakSet;try{return JSON.stringify(e,(n,o)=>{if(typeof o==="bigint")return o.toString();if(typeof o!=="object"||o===null)return o;if(t.has(o))return"[Circular]";return t.add(o),o})??""}catch{return String(e??"")}}function Wg(e){let t;try{t=JSON.stringify({systemPrompt:e.systemPrompt,messages:e.messages,tools:e.tools})}catch{t=[Ar(e.systemPrompt),Ar(e.messages),Ar(e.tools)].join(`
61
- `)}return Zl(t.length)}var Jg={debug:()=>{},log:()=>{},error:()=>{}};var oT=60,rT=1,iT=3600;function Yg(e){return typeof e==="number"&&Number.isFinite(e)}function Xg(e){return Math.min(Math.max(e,1),3600)}function sT(e){if(!Yg(e))return 60;return Xg(e)}function aT(e,t,n){let o=n?` (${n})`:"",r=Math.round(t/100)/10;return`MCP request to "${e}"${o} timed out after ${r}s. Increase the "timeout" field (in seconds) for this server in cline_mcp_settings.json.`}function Qg(e){if(e instanceof Error)return e.message;return String(e)}function eh(e){if(e&&typeof e==="object"&&"code"in e&&typeof e.code==="string")return e.code;return""}class Ie extends Error{constructor(e,t){super(`${e} at position ${t}`);this.position=t}}function Fl(e){return/^[0-9A-Fa-f]$/.test(e)}function ve(e){return e>="0"&&e<="9"}function Hl(e){return e>=" "}function Qe(e){return`,:[]/{}()
60
+ </file_content>`}function bg(e,t="act"){return`<user_input mode="${t}">${e}</user_input>`}function xg(e,t){return`<user_command slash="${t}">${e}</user_command>`}var Sg=/<user_input\b[^>]*\bmode="(act|plan|yolo)"/;function _g(e){let t=Sg.exec(e??"");return t?t[1]:void 0}function vg(e,t){return`<mode_notice>The user switched from ${e} mode to ${t} mode before sending this message.</mode_notice>`}function Tg(){let e=null;return{record(t,n){if(t===n)return;if(e){e=e.from===n?null:{from:e.from,to:n};return}e={from:t,to:n}},consume(){let t=e;return e=null,t}}}function Cg(e,t){let n=e.trim(),o=new RegExp(`^<${t}\\b([^>]*)>([\\s\\S]*?)<\\/${t}>$`,"i").exec(n);if(!o)return;return{attrs:o[1]??"",content:o[2]??""}}function kg(e,t){return new RegExp(`${t}="([^"]+)"`,"i").exec(e)?.[1]?.trim()||void 0}function xl(e){if(!e?.trim())return;let t=Cg(e,"user_command");if(!t)return;let n=kg(t.attrs,"slash");if(!n)return;return{slash:n,content:t.content.trim()}}function Sl(e){if(!e?.trim())return"";let t=e.trim();for(let n of["user_input","user_command"]){let o=kl(t,n);t=(o!==t?o:t.replace(new RegExp(`<${n}[^>]*>`,"g"),"")).trim()}return t}function _l(e){if(!e?.trim())return"";return Eg(e,"mode_notice").trim()}function Eg(e,t){let n=`<${t}>`,o=`</${t}>`,r=e,i=r.indexOf(n);while(i!==-1){let s=r.indexOf(o,i+n.length);if(s===-1)break;r=r.slice(0,i)+r.slice(s+o.length),i=r.indexOf(n,i)}return r}function br(e){let t=_l(Sl(e)),n=xl(e);if(!n)return t;if(n.slash.toLowerCase()==="team"){let r=t.toLowerCase().startsWith("spawn a team of agents for the following task:")?t.slice(46).trim():t;return r?`/team ${r}`:"/team"}return t?`/${n.slash} ${t}`:`/${n.slash}`}var vl=240,Tl=480;function Cl(e,t){let n=e.replace(/\s+/gu," ").trim();if(n.length<=t)return n;return`${n.slice(0,t-1).trimEnd()}…`}function Rg(e){return Cl(br(e),vl)}function Ag(e,t){let n=t?.trim()??"",o=e.toLowerCase(),r=o==="user"||o==="session"?br(n):n;return Cl(r,Tl)}function kl(e,t){if(!e?.trim())return"";if(!t)return e;let n=new RegExp(`<${t}\\b[^>]*>([\\s\\S]*?)</${t}>`,"g");return e.replace(n,"$1")}var We="[media omitted: invalid or exceeds size limit]",Je="[Image attached — this model cannot view images]",El=I(["image","audio","video","file"]),Rl=ar("type",[b({type:V("base64"),data:u().min(1)}),b({type:V("url"),url:u().url().refine((e)=>{let t=new URL(e).protocol;return t==="http:"||t==="https:"},"Generated media URLs must use HTTP or HTTPS")}),b({type:V("artifact"),artifactId:u().min(1)})]);function Al(e){if(e.startsWith("image/"))return"image";if(e.startsWith("audio/"))return"audio";if(e.startsWith("video/"))return"video";return"file"}var Il=b({id:u().min(1),modality:El,mediaType:u().min(1),source:Rl,name:u().min(1).optional(),sizeBytes:x().int().nonnegative().optional()}).refine((e)=>Al(e.mediaType)===e.modality,{message:"Generated media modality must match its media type",path:["modality"]});function Ig(e){return Il.safeParse(e).success}function wg(e){return Al(e)}var _n=["image/png","image/jpeg","image/gif","image/webp"],xr=5242880,fe=xr,Se=6291456,wl=8388608;function Pg(e){return e.length}function Sr(e){let t=e.endsWith("==")?2:e.endsWith("=")?1:0;return Math.floor(e.length*3/4)-t}function Mg(e=xr){return Math.floor(e*3/4)}function _r(e){return Math.ceil(e/3)*4}function vr(e={}){return{maxImageEncodedBytes:e.maxImageEncodedBytes??fe,maxImageDecodedBytes:e.maxImageDecodedBytes??Se,maxTotalMediaBytes:e.maxTotalMediaBytes??wl}}function vn(){return{totalEncodedBytes:0,keptImages:0,omittedImages:0,omittedReasons:{}}}function Sn(e,t){e.omittedImages+=1,e.omittedReasons[t]=(e.omittedReasons[t]??0)+1}function wt(e,t,n,o){let r=vr(n);if(e>r.maxImageEncodedBytes){let i={ok:!1,reason:"encoded_limit",message:`Image media exceeds the ${r.maxImageEncodedBytes} byte encoded limit`};return Sn(o,i.reason),i}if(t>r.maxImageDecodedBytes){let i={ok:!1,reason:"decoded_limit",message:`Image media exceeds the ${r.maxImageDecodedBytes} byte decoded limit`};return Sn(o,i.reason),i}if(o.totalEncodedBytes+e>r.maxTotalMediaBytes){let i={ok:!1,reason:"total_limit",message:`Image media exceeds the ${r.maxTotalMediaBytes} byte total media limit`};return Sn(o,i.reason),i}return o.totalEncodedBytes+=e,o.keptImages+=1,null}function Pl(e){return e>=65&&e<=90||e>=97&&e<=122||e>=48&&e<=57||e===43||e===47}function Og(e){return e.length>0&&Tr(e,0,e.length)}function zg(e,t,n){let o=Ml(e),r=o.end-o.start;if(r===0)return{ok:!1,reason:"invalid_base64",message:"Generated media must contain valid base64"};let i=vr(t);if(n.totalEncodedBytes+r>i.maxTotalMediaBytes)return{ok:!1,reason:"total_limit",message:`Generated media exceeds the ${i.maxTotalMediaBytes} byte total media limit`};if(!Tr(e,o.start,o.end))return{ok:!1,reason:"invalid_base64",message:"Generated media must contain valid base64"};let s=e.slice(o.start,o.end);return n.totalEncodedBytes+=r,{ok:!0,base64:s,encodedBytes:r,decodedBytes:Sr(s)}}function Tr(e,t,n){let o=n-t;if(o%4!==0)return!1;let r=n;if(o>=2&&e.charCodeAt(n-2)===61&&e.charCodeAt(n-1)===61)r-=2;else if(o>=1&&e.charCodeAt(n-1)===61)r-=1;for(let i=t;i<r;i++)if(!Pl(e.charCodeAt(i)))return!1;for(let i=r;i<n;i++)if(e.charCodeAt(i)!==61)return!1;return!0}function Ng(e,t,n){return n-t>=5&&(e.charCodeAt(t)|32)===100&&(e.charCodeAt(t+1)|32)===97&&(e.charCodeAt(t+2)|32)===116&&(e.charCodeAt(t+3)|32)===97&&e.charCodeAt(t+4)===58}function Ml(e){let t=0,n=e.length;while(t<n&&/\s/.test(e[t]??""))t+=1;while(n>t&&/\s/.test(e[n-1]??""))n-=1;return{start:t,end:n}}function $g(e,t,n){if(!Ng(e,t,n))return;let o=t+5,r=e.indexOf(",",o);if(r===-1||r>=n)return;if(r-o>128)return;let i=e.slice(o,r).toLowerCase(),s=";base64";if(!i.endsWith(s))return;let a=i.slice(0,-s.length);if(!a||a.includes(";"))return;return{mediaType:a,base64Start:r+1,base64End:n}}function Ol(e,t,n={}){let o=n.maxEncodedBytes??fe,r=n.maxDecodedBytes??Se,i=new Set(n.supportedMediaTypes??_n),s=e?.toLowerCase(),a=Ml(t),{start:c,end:l}=a,d=$g(t,a.start,a.end);if(d){if(s&&s!==d.mediaType)return{ok:!1,reason:"media_type_mismatch",message:`Image media type ${e} does not match data URL type ${d.mediaType}`};s=d.mediaType,c=d.base64Start,l=d.base64End}if(!s||!i.has(s))return{ok:!1,reason:"unsupported_media_type",message:`Unsupported image media type: ${e??"unknown"}`};let p=l-c;if(p===0)return{ok:!1,reason:"invalid_base64",message:"Image media must contain valid base64"};if(p>o)return{ok:!1,reason:"encoded_limit",message:`Image media exceeds the ${o} byte encoded limit`};if(!Tr(t,c,l))return{ok:!1,reason:"invalid_base64",message:"Image media must contain valid base64"};let m=t.slice(c,l),f=Sr(m);if(f>r)return{ok:!1,reason:"decoded_limit",message:`Image media exceeds the ${r} byte decoded limit`};return{ok:!0,mediaType:s,base64:m,encodedBytes:p,decodedBytes:f}}function Pt(e,t,n,o){let r=Ol(e,t,{maxEncodedBytes:n.maxImageEncodedBytes,maxDecodedBytes:n.maxImageDecodedBytes});if(!r.ok)return Sn(o,r.reason),r;let i=wt(r.encodedBytes,r.decodedBytes,n,o);if(i)return i;return r}function ae(e){return e.replace(/[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?<![\uD800-\uDBFF])[\uDC00-\uDFFF]/g,"�")}var Mt="ERROR: EMPTY CONTENT",Lg="[image attached]",Dg="[generated image]";function Bg(e){return`[generated ${e}]`}function Tn(e){return{type:"text",text:`[generated ${e.modality} unavailable to this model]`}}function Cr(e,t){let n=e[e.length-1];if(t.role==="tool"&&n?.role==="tool"&&Array.isArray(n.content)&&Array.isArray(t.content)){n.content.push(...t.content);return}e.push(t)}function Ug(e){if(!Array.isArray(e)||e.length===0)return!1;return e.every((t)=>{if(!t||typeof t!=="object")return!1;let n=t;if(n.type==="text")return typeof n.text==="string";if(n.type==="image")return typeof n.data==="string"&&typeof n.mediaType==="string";return!1})}function Le(){return{type:"text",text:We}}function zl(e){return wt(fe,0,{maxImageEncodedBytes:fe,maxImageDecodedBytes:Se},e)===null}function $l(e){try{return new URL(e).protocol}catch{return}}function kr(e,t){let n=Pt(e.mediaType,e.data,{maxImageEncodedBytes:fe,maxImageDecodedBytes:Se},t);if(!n.ok)return Le();return Ll(n.base64,n.mediaType)}function Ll(e,t){return{type:"file",data:{type:"data",data:e},mediaType:t}}function Ye(e,t){return{type:"file",data:e,mediaType:t??"image"}}function Er(e,t){if(e.image instanceof URL){if(e.image.protocol==="data:"){let s=Pt(e.mediaType,e.image.href,{maxImageEncodedBytes:fe,maxImageDecodedBytes:Se},t);if(!s.ok)return Le();return Ye(`data:${s.mediaType};base64,${s.base64}`,s.mediaType)}if(e.image.protocol!=="http:"&&e.image.protocol!=="https:")return Le();if(!zl(t))return Le();return Ye(e.image,e.mediaType)}if(typeof e.image==="string"){let s=$l(e.image);if(s==="http:"||s==="https:"){if(!zl(t))return Le();return Ye(e.image,e.mediaType)}let a=s==="data:",c=Pt(e.mediaType??(a?void 0:"image/png"),e.image,{maxImageEncodedBytes:fe,maxImageDecodedBytes:Se},t);if(!c.ok)return Le();return Ye(a?`data:${c.mediaType};base64,${c.base64}`:c.base64,c.mediaType)}let n=e.image.byteLength,o=_r(n),r=e.mediaType?.toLowerCase()??"image/png";if(!_n.includes(r)||wt(o,n,{maxImageEncodedBytes:fe,maxImageDecodedBytes:Se},t))return Le();return Ye(e.image,r)}function Zg(e,t){if(!t)return!0;if(e.modality==="file")return e.mediaType==="application/pdf"&&t.includes("pdf");return t.includes(e.modality)}function Nl(e,t,n){if(!Zg(e,n))return Tn(e);if(e.modality==="image"){if(e.source.type==="artifact")return Tn(e);return Er({type:"image",image:e.source.type==="url"?e.source.url:e.source.data,mediaType:e.mediaType},t)}if(e.source.type==="artifact")return Tn(e);if(e.source.type==="url"){let o=$l(e.source.url);if(o!=="http:"&&o!=="https:"&&o!=="data:")return Tn(e)}return Ye(e.source.type==="url"?e.source.url:e.source.data,e.mediaType)}function Rr(e,t,n,o){let{hoistImages:r,inlineImagePlaceholder:i}=o;if(e==null||typeof e!=="object")return{value:e,changed:!1,mediaChanged:!1};if(Array.isArray(e)){let d=[],p=!1,m=!1;for(let f of e){if(f&&typeof f==="object"){let y=f;if(y.type==="image"&&typeof y.data==="string"&&typeof y.mediaType==="string"){if(!r){d.push(i),p=!0,m=!0;continue}let S={type:"image",data:y.data,mediaType:y.mediaType},v=kr(S,n);if(v.type==="file")t.push({type:"image",data:v.data.data,mediaType:v.mediaType});else d.push(v.text);p=!0,m=!0;continue}if(y.type==="image"){d.push(We),p=!0,m=!0;continue}if(y.type==="text"&&typeof y.text==="string"){d.push(y.text),p=!0;continue}}let g=Rr(f,t,n,o);d.push(g.value),p||=g.changed,m||=g.mediaChanged}return{value:p?d:e,changed:p,mediaChanged:m}}let s=e;if(s.type==="image"){if(typeof s.data==="string"&&typeof s.mediaType==="string"){if(!r)return{value:i,changed:!0,mediaChanged:!0};let d={type:"image",data:s.data,mediaType:s.mediaType},p=kr(d,n);if(p.type==="file")return t.push({type:"image",data:p.data.data,mediaType:p.mediaType}),{value:Lg,changed:!0,mediaChanged:!0};return{value:p.text,changed:!0,mediaChanged:!0}}return{value:We,changed:!0,mediaChanged:!0}}let a={},c=!1,l=!1;for(let[d,p]of Object.entries(s)){let m=Rr(p,t,n,o);a[d]=m.value,c||=m.changed,l||=m.mediaChanged}return{value:c?a:e,changed:c,mediaChanged:l}}function Ot(e){if(typeof e==="string")return ae(e);if(Array.isArray(e))return e.map((t)=>Ot(t));if(e!==null&&typeof e==="object"){let t=e,n={};for(let[o,r]of Object.entries(t))n[o]=Ot(r);return n}return e}function Dl(e,t=!1,n=vn(),o){let r=o?.supportsImages??!0;if(typeof e==="string")return{type:t?"error-text":"text",value:ae(e)};if(!t&&Ug(e))return{type:"content",value:e.map((i)=>i.type==="image"?r?kr(i,n):{type:"text",text:Je}:{type:"text",text:ae(i.text)})};if(e!==null&&typeof e==="object"){let i=[],s=Rr(e,i,n,{hoistImages:!t&&r,inlineImagePlaceholder:r?We:Je});if(!t&&i.length>0)return{type:"content",value:[{type:"text",text:typeof s.value==="string"?ae(s.value):JSON.stringify(Ot(s.value))},...i.map((c)=>Ll(c.data,c.mediaType))]};if(s.mediaChanged)return{type:t?"error-json":"json",value:Ot(s.value)}}if(e===null||typeof e==="boolean"||typeof e==="number"||typeof e==="object")return{type:t?"error-json":"json",value:Ot(e)};return{type:t?"error-text":"text",value:ae(String(e))}}function Fg(e,t,n){let o=n?.assistantToolCallArgKey??"input",r=n?.supportedInputModalities,i=!r||r.includes("image"),s=[],a=vn(),c=[],l=()=>c.splice(0).map((p)=>p.type==="image"?i?Er(p,a):{type:"text",text:Je}:Nl(p.media,a,r));if(typeof e==="string"&&e.trim().length>0||Array.isArray(e)&&e.length>0)s.push({role:"system",content:typeof e==="string"?ae(e):e});for(let d of t){let p=d.content;if(typeof p==="string"){let y=d.role==="user"&&c.length>0?l():[];if(y.length>0){s.push({role:d.role,content:[{type:"text",text:p.trim().length>0?ae(p):Mt},...y]});continue}if(p.trim().length===0){s.push({role:d.role,content:[{type:"text",text:Mt}]});continue}s.push({role:d.role,content:ae(p)});continue}let m=[],f=[];if(p.length===0){s.push({role:d.role,content:[{type:"text",text:Mt}]});continue}for(let y of p)switch(y.type){case"text":m.push({type:"text",text:ae(y.text),...y.providerOptions?{providerOptions:y.providerOptions}:{}});break;case"reasoning":m.push({type:"reasoning",text:ae(y.text),...y.providerOptions?{providerOptions:y.providerOptions}:{}});break;case"image":if(d.role==="assistant")c.push(y),m.push({type:"text",text:Dg});else m.push(i?Er(y,a):{type:"text",text:Je});break;case"media":if(d.role==="assistant")c.push(y),m.push({type:"text",text:Bg(y.media.modality)});else m.push(Nl(y.media,a,r));break;case"file":m.push({type:"text",text:yr(y.path,ae(y.content))});break;case"tool-call":if(d.role==="assistant")m.push({type:"tool-call",toolCallId:y.toolCallId,toolName:y.toolName,[o]:y.input,...y.providerOptions?{providerOptions:y.providerOptions}:{}});break;case"tool-result":{f.push({type:"tool-result",toolCallId:y.toolCallId,toolName:y.toolName,output:Dl(y.output,y.isError??!1,a,{supportsImages:i})});break}}let g=f.length>0;if(d.role==="user"&&!g&&c.length>0)m.push(...l());if(m.length>0&&m.every((y)=>y.type==="text"&&typeof y.text==="string"&&y.text.trim().length===0))m.splice(0,m.length,{type:"text",text:Mt});if(m.length>0)Cr(s,{role:d.role,content:m});if(g)Cr(s,{role:"tool",content:f})}if(c.length>0)Cr(s,{role:"user",content:l()});return s}var Kv=["show","hide","subscription"];function Bl(e){return typeof e==="object"&&e!==null&&!Array.isArray(e)}function Hg(e,t){if(!e&&!t)return;let n=e?.metadata,o=t?.metadata,r={...e??{},...t??{}};if(Bl(n)&&Bl(o))r.metadata={...n,...o};return r}var Yv=["web_search","image_generation"],Xv=["web_search"];var zt={max:1,xhigh:0.95,high:0.8,medium:0.5,low:0.2,minimal:0.1,none:0},jg=void 0;function Vg(e,t){if(typeof e==="string"&&e.toLowerCase()in zt)return e.toLowerCase();return t?void 0:void 0}function Ul(e,t){let n=typeof e==="string"?e.toLowerCase():void 0;if(n&&n in zt)return zt[n];if(t?.fallbackEffort)return zt[t.fallbackEffort];return}function qg(e){let t=Ul(e.effort,{fallbackEffort:e.fallbackEffort});if(t===void 0)return;if(t<=0)return 0;let n=e.minimumBudget??1;if(e.maxBudget<n)return;let o=e.scaleTokens??e.maxBudget;return Math.min(Math.max(Math.floor(o*t),n),e.maxBudget)}function Gg(e){return e instanceof Error?{name:e.name,message:e.message}:e}var Kg=3;function Zl(e){return Math.max(1,Math.ceil(e/3))}function Ar(e){let t=new WeakSet;try{return JSON.stringify(e,(n,o)=>{if(typeof o==="bigint")return o.toString();if(typeof o!=="object"||o===null)return o;if(t.has(o))return"[Circular]";return t.add(o),o})??""}catch{return String(e??"")}}function Wg(e){let t;try{t=JSON.stringify({systemPrompt:e.systemPrompt,messages:e.messages,tools:e.tools})}catch{t=[Ar(e.systemPrompt),Ar(e.messages),Ar(e.tools)].join(`
61
+ `)}return Zl(t.length)}var Jg={debug:()=>{},log:()=>{},error:()=>{}};var rT=60,iT=1,sT=3600;function Yg(e){return typeof e==="number"&&Number.isFinite(e)}function Xg(e){return Math.min(Math.max(e,1),3600)}function aT(e){if(!Yg(e))return 60;return Xg(e)}function cT(e,t,n){let o=n?` (${n})`:"",r=Math.round(t/100)/10;return`MCP request to "${e}"${o} timed out after ${r}s. Increase the "timeout" field (in seconds) for this server in cline_mcp_settings.json.`}function Qg(e){if(e instanceof Error)return e.message;return String(e)}function eh(e){if(e&&typeof e==="object"&&"code"in e&&typeof e.code==="string")return e.code;return""}class Ie extends Error{constructor(e,t){super(`${e} at position ${t}`);this.position=t}}function Fl(e){return/^[0-9A-Fa-f]$/.test(e)}function ve(e){return e>="0"&&e<="9"}function Hl(e){return e>=" "}function Qe(e){return`,:[]/{}()
62
62
  +`.includes(e)}function Ir(e){return e>="a"&&e<="z"||e>="A"&&e<="Z"||e==="_"||e==="$"}function Cn(e){return e>="a"&&e<="z"||e>="A"&&e<="Z"||e==="_"||e==="$"||e>="0"&&e<="9"}var wr=/^(http|https|ftp|mailto|file|data|irc):\/\/$/,Pr=/^[A-Za-z0-9-._~:/?#@!$&'()*+;=]$/;function Mr(e){return`,[]/{}
63
63
  +`.includes(e)}function Or(e){return et(e)||th.test(e)}var th=/^[[{\w-]$/;function zr(e){return e===`
64
64
  `||e==="\r"||e==="\t"||e==="\b"||e==="\f"}function _e(e,t){let n=e.charCodeAt(t);return n===32||n===10||n===9||n===13}function jl(e,t){let n=e.charCodeAt(t);return n===32||n===9||n===13}function Vl(e,t){let n=e.charCodeAt(t);return n===160||n===6158||n>=8192&&n<=8203||n===8239||n===8287||n===12288||n===65279}function et(e){return Nr(e)||kn(e)}function Nr(e){return e==='"'||e==="“"||e==="”"}function $r(e){return e==='"'}function kn(e){return e==="'"||e==="‘"||e==="’"||e==="`"||e==="´"}function Lr(e){return e==="'"}function tt(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!1,o=e.lastIndexOf(t);return o!==-1?e.substring(0,o)+(n?"":e.substring(o+1)):e}function ce(e,t){let n=e.length;if(!_e(e,n-1))return e+t;while(_e(e,n-1))n--;return e.substring(0,n)+t+e.substring(n)}function ql(e,t,n){return e.substring(0,t)+e.substring(t+n)}function Gl(e){return/[,\n][ \t\r]*$/.test(e)}var nh={"&quot;":'"',"&amp;":"&","&lt;":"<","&gt;":">","&apos;":"'"},Dr=12;function Br(e){if(e.charAt(0)!=="&")return null;let t=e.indexOf(";");if(t===-1)return null;let n=e.substring(0,t+1),o=nh[n];if(o!==void 0)return{char:o,length:n.length};if(e.charAt(1)==="#"){let r=e.substring(2,t),i=r.charAt(0)==="x"||r.charAt(0)==="X",s=i?r.substring(1):r;if(s.length>0){let a=Number.parseInt(s,i?16:10);if(!Number.isNaN(a)&&a>=0&&a<=1114111)return{char:String.fromCodePoint(a),length:n.length}}}return null}function Kl(e){return e!==null&&e.char==='"'}function Wl(e){return e!==null&&e.char==="'"}function Xe(e,t){let n=0;for(let o=0;o<e.length;o++)if(e.charAt(o)===t)n++;return n}function Jl(e,t){switch(t){case")":return Xe(e,"(")>Xe(e,")");case"]":return Xe(e,"[")>Xe(e,"]");case"}":return Xe(e,"{")>Xe(e,"}");default:return!1}}var Yl={"\b":"\\b","\f":"\\f","\n":"\\n","\r":"\\r","\t":"\\t"},oh={'"':'"',"\\":"\\","/":"/",b:"\b",f:"\f",n:`
@@ -164,27 +164,27 @@ ${o}`}function Lh(e){let{ide:t="Terminal Shell",mode:n,platform:o="unknown",work
164
164
 
165
165
  ${od(d,r,i)}`.trim();return g}let m=n==="yolo"?qr.YOLO:qr.ACT,f=[s,n==="yolo"?void 0:rd,n==="plan"?l?sd:ad:void 0].filter(Boolean).join(`
166
166
 
167
- `);return m.replace("{{PLATFORM_NAME}}",o).replace("{{CWD}}",d).replace("{{CURRENT_DATE}}",new Date().toLocaleDateString()).replace("{{IDE_NAME}}",t).replace("{{CLINE_METADATA}}",p?od(d,r,i):"").replace("{{CLINE_RULES}}",f).trim()}function Dh(e){let t=e?.metadata?.localCliCommand;if(typeof t!=="string"||!t.trim())return;return{command:t.trim(),docsUrl:e?.docsUrl}}var Bh="anthropic/claude-sonnet-5";import ge from"node:fs/promises";import Kr from"node:path";async function Uh(e){try{return await ge.access(e),!0}catch{return!1}}class Wr{filePath;constructor(e){this.filePath=e}async read(){try{return JSON.parse(await ge.readFile(this.filePath,"utf8"))}catch(e){if(e.code==="ENOENT")return;throw e}}async write(e){await ge.mkdir(Kr.dirname(this.filePath),{recursive:!0}),await ge.writeFile(this.filePath,JSON.stringify(e,null,2),"utf8")}async clear(){await ge.rm(this.filePath,{force:!0})}}class En{async writeText(e,t){await ge.mkdir(Kr.dirname(e),{recursive:!0}),await ge.writeFile(e,t,"utf8")}async remove(e){await ge.rm(e,{recursive:!0,force:!0})}async removeChildren(e){if(!await Uh(e))return;let t=await ge.readdir(e);await Promise.all(t.map((n)=>ge.rm(Kr.join(e,n),{recursive:!0,force:!0})))}}import{createHmac as jh}from"node:crypto";import{basename as Vh}from"node:path";var Yr=new TextEncoder,Zh={appstream2:"appstream",cloudhsmv2:"cloudhsm",email:"ses",marketplace:"aws-marketplace",mobile:"AWSMobileHubService",pinpoint:"mobiletargeting",queue:"sqs","git-codecommit":"codecommit","mturk-requester-sandbox":"mturk-requester","personalize-runtime":"personalize"},Fh=new Set(["authorization","content-type","content-length","user-agent","presigned-expires","expect","x-amzn-trace-id","range","connection"]);class Rn{constructor({accessKeyId:e,secretAccessKey:t,sessionToken:n,service:o,region:r,cache:i,retries:s,initRetryMs:a}){if(e==null)throw TypeError("accessKeyId is a required option");if(t==null)throw TypeError("secretAccessKey is a required option");this.accessKeyId=e,this.secretAccessKey=t,this.sessionToken=n,this.service=o,this.region=r,this.cache=i||new Map,this.retries=s!=null?s:10,this.initRetryMs=a||50}async sign(e,t){if(e instanceof Request){let{method:r,url:i,headers:s,body:a}=e;if(t=Object.assign({method:r,url:i,headers:s},t),t.body==null&&s.has("Content-Type"))t.body=a!=null&&s.has("X-Amz-Content-Sha256")?a:await e.clone().arrayBuffer();e=i}let n=new dd(Object.assign({url:e.toString()},t,this,t&&t.aws)),o=Object.assign({},t,await n.sign());delete o.aws;try{return new Request(o.url.toString(),o)}catch(r){if(r instanceof TypeError)return new Request(o.url.toString(),Object.assign({duplex:"half"},o));throw r}}async fetch(e,t){for(let n=0;n<=this.retries;n++){let o=fetch(await this.sign(e,t));if(n===this.retries)return o;let r=await o;if(r.status<500&&r.status!==429)return r;await new Promise((i)=>setTimeout(i,Math.random()*this.initRetryMs*Math.pow(2,n)))}throw Error("An unknown error occurred, ensure retries is not negative")}}class dd{constructor({method:e,url:t,headers:n,body:o,accessKeyId:r,secretAccessKey:i,sessionToken:s,service:a,region:c,cache:l,datetime:d,signQuery:p,appendSessionToken:m,allHeaders:f,singleEncode:g}){if(t==null)throw TypeError("url is a required option");if(r==null)throw TypeError("accessKeyId is a required option");if(i==null)throw TypeError("secretAccessKey is a required option");this.method=e||(o?"POST":"GET"),this.url=new URL(t),this.headers=new Headers(n||{}),this.body=o,this.accessKeyId=r,this.secretAccessKey=i,this.sessionToken=s;let y,S;if(!a||!c)[y,S]=Hh(this.url,this.headers);if(this.service=a||y||"",this.region=c||S||"us-east-1",this.cache=l||new Map,this.datetime=d||new Date().toISOString().replace(/[:-]|\.\d{3}/g,""),this.signQuery=p,this.appendSessionToken=m||this.service==="iotdevicegateway",this.headers.delete("Host"),this.service==="s3"&&!this.signQuery&&!this.headers.has("X-Amz-Content-Sha256"))this.headers.set("X-Amz-Content-Sha256","UNSIGNED-PAYLOAD");let v=this.signQuery?this.url.searchParams:this.headers;if(v.set("X-Amz-Date",this.datetime),this.sessionToken&&!this.appendSessionToken)v.set("X-Amz-Security-Token",this.sessionToken);if(this.signableHeaders=["host",...this.headers.keys()].filter((M)=>f||!Fh.has(M)).sort(),this.signedHeaders=this.signableHeaders.join(";"),this.canonicalHeaders=this.signableHeaders.map((M)=>M+":"+(M==="host"?this.url.host:(this.headers.get(M)||"").replace(/\s+/g," "))).join(`
167
+ `);return m.replace("{{PLATFORM_NAME}}",o).replace("{{CWD}}",d).replace("{{CURRENT_DATE}}",new Date().toLocaleDateString()).replace("{{IDE_NAME}}",t).replace("{{CLINE_METADATA}}",p?od(d,r,i):"").replace("{{CLINE_RULES}}",f).trim()}function Dh(e){return e?.metadata?.apiKeyOptional===!0}function Bh(e){let t=e?.metadata?.localCliCommand;if(typeof t!=="string"||!t.trim())return;return{command:t.trim(),docsUrl:e?.docsUrl}}var Uh="anthropic/claude-sonnet-5";import ge from"node:fs/promises";import Kr from"node:path";async function Zh(e){try{return await ge.access(e),!0}catch{return!1}}class Wr{filePath;constructor(e){this.filePath=e}async read(){try{return JSON.parse(await ge.readFile(this.filePath,"utf8"))}catch(e){if(e.code==="ENOENT")return;throw e}}async write(e){await ge.mkdir(Kr.dirname(this.filePath),{recursive:!0}),await ge.writeFile(this.filePath,JSON.stringify(e,null,2),"utf8")}async clear(){await ge.rm(this.filePath,{force:!0})}}class En{async writeText(e,t){await ge.mkdir(Kr.dirname(e),{recursive:!0}),await ge.writeFile(e,t,"utf8")}async remove(e){await ge.rm(e,{recursive:!0,force:!0})}async removeChildren(e){if(!await Zh(e))return;let t=await ge.readdir(e);await Promise.all(t.map((n)=>ge.rm(Kr.join(e,n),{recursive:!0,force:!0})))}}import{createHmac as Vh}from"node:crypto";import{basename as qh}from"node:path";var Yr=new TextEncoder,Fh={appstream2:"appstream",cloudhsmv2:"cloudhsm",email:"ses",marketplace:"aws-marketplace",mobile:"AWSMobileHubService",pinpoint:"mobiletargeting",queue:"sqs","git-codecommit":"codecommit","mturk-requester-sandbox":"mturk-requester","personalize-runtime":"personalize"},Hh=new Set(["authorization","content-type","content-length","user-agent","presigned-expires","expect","x-amzn-trace-id","range","connection"]);class Rn{constructor({accessKeyId:e,secretAccessKey:t,sessionToken:n,service:o,region:r,cache:i,retries:s,initRetryMs:a}){if(e==null)throw TypeError("accessKeyId is a required option");if(t==null)throw TypeError("secretAccessKey is a required option");this.accessKeyId=e,this.secretAccessKey=t,this.sessionToken=n,this.service=o,this.region=r,this.cache=i||new Map,this.retries=s!=null?s:10,this.initRetryMs=a||50}async sign(e,t){if(e instanceof Request){let{method:r,url:i,headers:s,body:a}=e;if(t=Object.assign({method:r,url:i,headers:s},t),t.body==null&&s.has("Content-Type"))t.body=a!=null&&s.has("X-Amz-Content-Sha256")?a:await e.clone().arrayBuffer();e=i}let n=new dd(Object.assign({url:e.toString()},t,this,t&&t.aws)),o=Object.assign({},t,await n.sign());delete o.aws;try{return new Request(o.url.toString(),o)}catch(r){if(r instanceof TypeError)return new Request(o.url.toString(),Object.assign({duplex:"half"},o));throw r}}async fetch(e,t){for(let n=0;n<=this.retries;n++){let o=fetch(await this.sign(e,t));if(n===this.retries)return o;let r=await o;if(r.status<500&&r.status!==429)return r;await new Promise((i)=>setTimeout(i,Math.random()*this.initRetryMs*Math.pow(2,n)))}throw Error("An unknown error occurred, ensure retries is not negative")}}class dd{constructor({method:e,url:t,headers:n,body:o,accessKeyId:r,secretAccessKey:i,sessionToken:s,service:a,region:c,cache:l,datetime:d,signQuery:p,appendSessionToken:m,allHeaders:f,singleEncode:g}){if(t==null)throw TypeError("url is a required option");if(r==null)throw TypeError("accessKeyId is a required option");if(i==null)throw TypeError("secretAccessKey is a required option");this.method=e||(o?"POST":"GET"),this.url=new URL(t),this.headers=new Headers(n||{}),this.body=o,this.accessKeyId=r,this.secretAccessKey=i,this.sessionToken=s;let y,S;if(!a||!c)[y,S]=jh(this.url,this.headers);if(this.service=a||y||"",this.region=c||S||"us-east-1",this.cache=l||new Map,this.datetime=d||new Date().toISOString().replace(/[:-]|\.\d{3}/g,""),this.signQuery=p,this.appendSessionToken=m||this.service==="iotdevicegateway",this.headers.delete("Host"),this.service==="s3"&&!this.signQuery&&!this.headers.has("X-Amz-Content-Sha256"))this.headers.set("X-Amz-Content-Sha256","UNSIGNED-PAYLOAD");let v=this.signQuery?this.url.searchParams:this.headers;if(v.set("X-Amz-Date",this.datetime),this.sessionToken&&!this.appendSessionToken)v.set("X-Amz-Security-Token",this.sessionToken);if(this.signableHeaders=["host",...this.headers.keys()].filter((M)=>f||!Hh.has(M)).sort(),this.signedHeaders=this.signableHeaders.join(";"),this.canonicalHeaders=this.signableHeaders.map((M)=>M+":"+(M==="host"?this.url.host:(this.headers.get(M)||"").replace(/\s+/g," "))).join(`
168
168
  `),this.credentialString=[this.datetime.slice(0,8),this.region,this.service,"aws4_request"].join("/"),this.signQuery){if(this.service==="s3"&&!v.has("X-Amz-Expires"))v.set("X-Amz-Expires","86400");v.set("X-Amz-Algorithm","AWS4-HMAC-SHA256"),v.set("X-Amz-Credential",this.accessKeyId+"/"+this.credentialString),v.set("X-Amz-SignedHeaders",this.signedHeaders)}if(this.service==="s3")try{this.encodedPath=decodeURIComponent(this.url.pathname.replace(/\+/g," "))}catch(M){this.encodedPath=this.url.pathname}else this.encodedPath=this.url.pathname.replace(/\/+/g,"/");if(!g)this.encodedPath=encodeURIComponent(this.encodedPath).replace(/%2F/g,"/");this.encodedPath=ld(this.encodedPath);let k=new Set;this.encodedSearch=[...this.url.searchParams].filter(([M])=>{if(!M)return!1;if(this.service==="s3"){if(k.has(M))return!1;k.add(M)}return!0}).map((M)=>M.map((R)=>ld(encodeURIComponent(R)))).sort(([M,R],[B,A])=>M<B?-1:M>B?1:R<A?-1:R>A?1:0).map((M)=>M.join("=")).join("&")}async sign(){if(this.signQuery){if(this.url.searchParams.set("X-Amz-Signature",await this.signature()),this.sessionToken&&this.appendSessionToken)this.url.searchParams.set("X-Amz-Security-Token",this.sessionToken)}else this.headers.set("Authorization",await this.authHeader());return{method:this.method,url:this.url,headers:this.headers,body:this.body}}async authHeader(){return["AWS4-HMAC-SHA256 Credential="+this.accessKeyId+"/"+this.credentialString,"SignedHeaders="+this.signedHeaders,"Signature="+await this.signature()].join(", ")}async signature(){let e=this.datetime.slice(0,8),t=[this.secretAccessKey,e,this.region,this.service].join(),n=this.cache.get(t);if(!n){let o=await Nt("AWS4"+this.secretAccessKey,e),r=await Nt(o,this.region),i=await Nt(r,this.service);n=await Nt(i,"aws4_request"),this.cache.set(t,n)}return Jr(await Nt(n,await this.stringToSign()))}async stringToSign(){return["AWS4-HMAC-SHA256",this.datetime,this.credentialString,Jr(await cd(await this.canonicalString()))].join(`
169
169
  `)}async canonicalString(){return[this.method.toUpperCase(),this.encodedPath,this.encodedSearch,this.canonicalHeaders+`
170
170
  `,this.signedHeaders,await this.hexBodyHash()].join(`
171
- `)}async hexBodyHash(){let e=this.headers.get("X-Amz-Content-Sha256")||(this.service==="s3"&&this.signQuery?"UNSIGNED-PAYLOAD":null);if(e==null){if(this.body&&typeof this.body!=="string"&&!("byteLength"in this.body))throw Error("body must be a string, ArrayBuffer or ArrayBufferView, unless you include the X-Amz-Content-Sha256 header");e=Jr(await cd(this.body||""))}return e}}async function Nt(e,t){let n=await crypto.subtle.importKey("raw",typeof e==="string"?Yr.encode(e):e,{name:"HMAC",hash:{name:"SHA-256"}},!1,["sign"]);return crypto.subtle.sign("HMAC",n,Yr.encode(t))}async function cd(e){return crypto.subtle.digest("SHA-256",typeof e==="string"?Yr.encode(e):e)}var ud=["0","1","2","3","4","5","6","7","8","9","a","b","c","d","e","f"];function Jr(e){let t=new Uint8Array(e),n="";for(let o=0;o<t.length;o++){let r=t[o];n+=ud[r>>>4&15],n+=ud[r&15]}return n}function ld(e){return e.replace(/[!'()*]/g,(t)=>"%"+t.charCodeAt(0).toString(16).toUpperCase())}function Hh(e,t){let{hostname:n,pathname:o}=e;if(n.endsWith(".on.aws")){let a=n.match(/^[^.]{1,63}\.lambda-url\.([^.]{1,63})\.on\.aws$/);return a!=null?["lambda",a[1]||""]:["",""]}if(n.endsWith(".r2.cloudflarestorage.com"))return["s3","auto"];if(n.endsWith(".backblazeb2.com")){let a=n.match(/^(?:[^.]{1,63}\.)?s3\.([^.]{1,63})\.backblazeb2\.com$/);return a!=null?["s3",a[1]||""]:["",""]}let r=n.replace("dualstack.","").match(/([^.]{1,63})\.(?:([^.]{0,63})\.)?amazonaws\.com(?:\.cn)?$/),i=r&&r[1]||"",s=r&&r[2];if(s==="us-gov")s="us-gov-west-1";else if(s==="s3"||s==="s3-accelerate")s="us-east-1",i="s3";else if(i==="iot")if(n.startsWith("iot."))i="execute-api";else if(n.startsWith("data.jobs.iot."))i="iot-jobs-data";else i=o==="/mqtt"?"iotdevicegateway":"iotdata";else if(i==="autoscaling"){let a=(t.get("X-Amz-Target")||"").split(".")[0];if(a==="AnyScaleFrontendService")i="application-autoscaling";else if(a==="AnyScaleScalingPlannerFrontendService")i="autoscaling-plans"}else if(s==null&&i.startsWith("s3-"))s=i.slice(3).replace(/^fips-|^external-1/,""),i="s3";else if(i.endsWith("-fips"))i=i.slice(0,-5);else if(s&&/-\d$/.test(i)&&!/-\d$/.test(s))[i,s]=[s,i];return[Zh[i]||i,s||""]}var md="enterprise.blobUpload",An=new Map;function Xr(e,t){return{adapterType:e,accessKeyId:t.accessKeyId,secretAccessKey:t.secretAccessKey,region:t.region,bucket:t.bucket,endpoint:t.endpoint,accountId:t.accountId}}function fd(e){return{adapterType:e.adapterType,bucket:e.bucket,region:e.region,endpoint:e.endpoint,accountId:e.accountId}}function qh(e){if(!e||e.enabled!==!0)return;if(e.type==="s3_access_keys"&&e.s3AccessSettings)return Xr("s3",e.s3AccessSettings);if(e.type==="r2_access_keys"&&e.r2AccessSettings)return Xr("r2",e.r2AccessSettings);if(e.type==="azure_access_keys"&&e.azureAccessSettings)return Xr("azure",e.azureAccessSettings);return}function gd(e){return qh(e?.enterpriseTelemetry?.promptUploading)}function Gh(e,t){let n=gd(e);if(!n)return;return{version:1,storage:fd(n),userDistinctId:t}}function Kh(e,t,n){let o=gd(t);if(!o){An.delete(e);return}return An.set(e,o),{version:1,storage:fd(o),userDistinctId:n}}function Wh(e){An.delete(e)}function hd(e,t,n){let o=`${t}/${n}`;return{async write(r,i){let s=await e.fetch(`${o}/${r}`,{method:"PUT",body:i,headers:{"Content-Type":"application/json; charset=utf-8"}});if(!s.ok)throw Error(`Failed to write ${r}: ${s.status}`)}}}function Jh(e){let{bucket:t,accessKeyId:n,secretAccessKey:o}=e;if(!t||!n||!o)return;let r=e.region||"us-east-1",i=e.endpoint||`https://s3.${r}.amazonaws.com`;return hd(new Rn({region:r,accessKeyId:n,secretAccessKey:o}),i,t)}function Yh(e){let{accountId:t,endpoint:n,bucket:o,accessKeyId:r,secretAccessKey:i}=e;if(!n&&!t||!o||!r||!i)return;return hd(new Rn({accessKeyId:r,secretAccessKey:i}),e.endpoint??`https://${t}.r2.cloudflarestorage.com`,o)}function Xh(e,t,n,o,r){let i=r["Content-Length"]||"",s=r["Content-Type"]||"",a=Object.entries(r).filter(([m])=>m.toLowerCase().startsWith("x-ms-")).sort(([m],[f])=>m.toLowerCase().localeCompare(f.toLowerCase())).map(([m,f])=>`${m.toLowerCase()}:${f}`).join(`
171
+ `)}async hexBodyHash(){let e=this.headers.get("X-Amz-Content-Sha256")||(this.service==="s3"&&this.signQuery?"UNSIGNED-PAYLOAD":null);if(e==null){if(this.body&&typeof this.body!=="string"&&!("byteLength"in this.body))throw Error("body must be a string, ArrayBuffer or ArrayBufferView, unless you include the X-Amz-Content-Sha256 header");e=Jr(await cd(this.body||""))}return e}}async function Nt(e,t){let n=await crypto.subtle.importKey("raw",typeof e==="string"?Yr.encode(e):e,{name:"HMAC",hash:{name:"SHA-256"}},!1,["sign"]);return crypto.subtle.sign("HMAC",n,Yr.encode(t))}async function cd(e){return crypto.subtle.digest("SHA-256",typeof e==="string"?Yr.encode(e):e)}var ud=["0","1","2","3","4","5","6","7","8","9","a","b","c","d","e","f"];function Jr(e){let t=new Uint8Array(e),n="";for(let o=0;o<t.length;o++){let r=t[o];n+=ud[r>>>4&15],n+=ud[r&15]}return n}function ld(e){return e.replace(/[!'()*]/g,(t)=>"%"+t.charCodeAt(0).toString(16).toUpperCase())}function jh(e,t){let{hostname:n,pathname:o}=e;if(n.endsWith(".on.aws")){let a=n.match(/^[^.]{1,63}\.lambda-url\.([^.]{1,63})\.on\.aws$/);return a!=null?["lambda",a[1]||""]:["",""]}if(n.endsWith(".r2.cloudflarestorage.com"))return["s3","auto"];if(n.endsWith(".backblazeb2.com")){let a=n.match(/^(?:[^.]{1,63}\.)?s3\.([^.]{1,63})\.backblazeb2\.com$/);return a!=null?["s3",a[1]||""]:["",""]}let r=n.replace("dualstack.","").match(/([^.]{1,63})\.(?:([^.]{0,63})\.)?amazonaws\.com(?:\.cn)?$/),i=r&&r[1]||"",s=r&&r[2];if(s==="us-gov")s="us-gov-west-1";else if(s==="s3"||s==="s3-accelerate")s="us-east-1",i="s3";else if(i==="iot")if(n.startsWith("iot."))i="execute-api";else if(n.startsWith("data.jobs.iot."))i="iot-jobs-data";else i=o==="/mqtt"?"iotdevicegateway":"iotdata";else if(i==="autoscaling"){let a=(t.get("X-Amz-Target")||"").split(".")[0];if(a==="AnyScaleFrontendService")i="application-autoscaling";else if(a==="AnyScaleScalingPlannerFrontendService")i="autoscaling-plans"}else if(s==null&&i.startsWith("s3-"))s=i.slice(3).replace(/^fips-|^external-1/,""),i="s3";else if(i.endsWith("-fips"))i=i.slice(0,-5);else if(s&&/-\d$/.test(i)&&!/-\d$/.test(s))[i,s]=[s,i];return[Fh[i]||i,s||""]}var md="enterprise.blobUpload",An=new Map;function Xr(e,t){return{adapterType:e,accessKeyId:t.accessKeyId,secretAccessKey:t.secretAccessKey,region:t.region,bucket:t.bucket,endpoint:t.endpoint,accountId:t.accountId}}function fd(e){return{adapterType:e.adapterType,bucket:e.bucket,region:e.region,endpoint:e.endpoint,accountId:e.accountId}}function Gh(e){if(!e||e.enabled!==!0)return;if(e.type==="s3_access_keys"&&e.s3AccessSettings)return Xr("s3",e.s3AccessSettings);if(e.type==="r2_access_keys"&&e.r2AccessSettings)return Xr("r2",e.r2AccessSettings);if(e.type==="azure_access_keys"&&e.azureAccessSettings)return Xr("azure",e.azureAccessSettings);return}function gd(e){return Gh(e?.enterpriseTelemetry?.promptUploading)}function Kh(e,t){let n=gd(e);if(!n)return;return{version:1,storage:fd(n),userDistinctId:t}}function Wh(e,t,n){let o=gd(t);if(!o){An.delete(e);return}return An.set(e,o),{version:1,storage:fd(o),userDistinctId:n}}function Jh(e){An.delete(e)}function hd(e,t,n){let o=`${t}/${n}`;return{async write(r,i){let s=await e.fetch(`${o}/${r}`,{method:"PUT",body:i,headers:{"Content-Type":"application/json; charset=utf-8"}});if(!s.ok)throw Error(`Failed to write ${r}: ${s.status}`)}}}function Yh(e){let{bucket:t,accessKeyId:n,secretAccessKey:o}=e;if(!t||!n||!o)return;let r=e.region||"us-east-1",i=e.endpoint||`https://s3.${r}.amazonaws.com`;return hd(new Rn({region:r,accessKeyId:n,secretAccessKey:o}),i,t)}function Xh(e){let{accountId:t,endpoint:n,bucket:o,accessKeyId:r,secretAccessKey:i}=e;if(!n&&!t||!o||!r||!i)return;return hd(new Rn({accessKeyId:r,secretAccessKey:i}),e.endpoint??`https://${t}.r2.cloudflarestorage.com`,o)}function Qh(e,t,n,o,r){let i=r["Content-Length"]||"",s=r["Content-Type"]||"",a=Object.entries(r).filter(([m])=>m.toLowerCase().startsWith("x-ms-")).sort(([m],[f])=>m.toLowerCase().localeCompare(f.toLowerCase())).map(([m,f])=>`${m.toLowerCase()}:${f}`).join(`
172
172
  `),c=`/${e}${o}`,l=[n,"","",i,"",s,"","","","","","",a,c].join(`
173
- `),d=Buffer.from(t,"base64"),p=jh("sha256",d).update(l,"utf8").digest("base64");return`SharedKey ${e}:${p}`}function Qh(e){let{accessKeyId:t,secretAccessKey:n,bucket:o}=e;if(!t||!n||!o)return;let r=e.endpoint||`https://${t}.blob.core.windows.net`;return{async write(i,s){let a=`/${o}/${i}`,c=new Date().toUTCString(),l=Buffer.from(s,"utf8"),d={"x-ms-date":c,"x-ms-version":"2024-11-04","x-ms-blob-type":"BlockBlob","Content-Type":"application/json; charset=utf-8","Content-Length":l.byteLength.toString()};d.Authorization=Xh(t,n,"PUT",a,d);let p=await fetch(`${r}${a}`,{method:"PUT",body:l,headers:d});if(!p.ok){let m=await p.text().catch(()=>"");throw Error(`Failed to write ${i}: ${p.status} ${m}`.trim())}}}}function ey(e){if(e.adapterType==="s3")return Jh(e);if(e.adapterType==="r2")return Yh(e);if(e.adapterType==="azure")return Qh(e);return}function pd(e){return typeof e==="object"&&e!==null&&!Array.isArray(e)}function yd(e){let t=e?.metadata?.[md];if(!pd(t))return;let n=t.storage;if(!pd(n))return;let o=n.adapterType;if(o!=="s3"&&o!=="r2"&&o!=="azure")return;if(typeof n.bucket!=="string")return;return{version:1,storage:{adapterType:o,bucket:n.bucket,region:typeof n.region==="string"?n.region:void 0,endpoint:typeof n.endpoint==="string"?n.endpoint:void 0,accountId:typeof n.accountId==="string"?n.accountId:void 0},keyPrefix:typeof t.keyPrefix==="string"?t.keyPrefix:void 0,userDistinctId:typeof t.userDistinctId==="string"?t.userDistinctId:void 0}}function ty(e,t,n){return["sessions",n.userDistinctId?.trim()||"unknown",e,t?.endsWith("messages.json")?"messages.json":Vh(t)].filter((i)=>Boolean(i?.trim())).join("/")}function ny(){let e=new Map;return{async uploadMessagesFile({sessionId:t,path:n,contents:o,row:r}){let i=yd(r);if(!i)return;let s=An.get(t);if(!s)return;let a=JSON.stringify(s),c=e.get(a);if(!c){if(c=ey(s),!c)return;e.set(a,c)}await c.write(ty(t,n,i),o)}}}function Qr(e,t,n){return{id:`remote-config:${e}:${n}:${t.name}`,name:t.name,kind:e,contents:t.contents,alwaysEnabled:t.alwaysEnabled}}var oy="remote://";function bd(e){let t="",n=!1;for(let o of e.trim().toLowerCase()){let r=o.charCodeAt(0);if(r>=97&&r<=122||r>=48&&r<=57||o==="."||o==="_"||o==="-"){if(n&&t&&t[t.length-1]!=="-")t+="-";n=!1,t+=o}else n=!0;if(t.length>=80)break}while(t.endsWith("-"))t=t.slice(0,-1);while(t.startsWith("-"))t=t.slice(1);return t||"item"}function ry(e){let t=e?.globalRules?.map((o,r)=>Qr("rule",o,`${r}`))??[],n=e?.globalWorkflows?.map((o,r)=>Qr("workflow",o,`${r}`))??[];return[...t,...n]}function iy(e){return[...ry(e.remoteConfig),...e.managedInstructions??[]]}function sy(e){return e.map((t)=>{let n=`## ${t.name}`,o=t.alwaysEnabled?`_Always enabled_
173
+ `),d=Buffer.from(t,"base64"),p=Vh("sha256",d).update(l,"utf8").digest("base64");return`SharedKey ${e}:${p}`}function ey(e){let{accessKeyId:t,secretAccessKey:n,bucket:o}=e;if(!t||!n||!o)return;let r=e.endpoint||`https://${t}.blob.core.windows.net`;return{async write(i,s){let a=`/${o}/${i}`,c=new Date().toUTCString(),l=Buffer.from(s,"utf8"),d={"x-ms-date":c,"x-ms-version":"2024-11-04","x-ms-blob-type":"BlockBlob","Content-Type":"application/json; charset=utf-8","Content-Length":l.byteLength.toString()};d.Authorization=Qh(t,n,"PUT",a,d);let p=await fetch(`${r}${a}`,{method:"PUT",body:l,headers:d});if(!p.ok){let m=await p.text().catch(()=>"");throw Error(`Failed to write ${i}: ${p.status} ${m}`.trim())}}}}function ty(e){if(e.adapterType==="s3")return Yh(e);if(e.adapterType==="r2")return Xh(e);if(e.adapterType==="azure")return ey(e);return}function pd(e){return typeof e==="object"&&e!==null&&!Array.isArray(e)}function yd(e){let t=e?.metadata?.[md];if(!pd(t))return;let n=t.storage;if(!pd(n))return;let o=n.adapterType;if(o!=="s3"&&o!=="r2"&&o!=="azure")return;if(typeof n.bucket!=="string")return;return{version:1,storage:{adapterType:o,bucket:n.bucket,region:typeof n.region==="string"?n.region:void 0,endpoint:typeof n.endpoint==="string"?n.endpoint:void 0,accountId:typeof n.accountId==="string"?n.accountId:void 0},keyPrefix:typeof t.keyPrefix==="string"?t.keyPrefix:void 0,userDistinctId:typeof t.userDistinctId==="string"?t.userDistinctId:void 0}}function ny(e,t,n){return["sessions",n.userDistinctId?.trim()||"unknown",e,t?.endsWith("messages.json")?"messages.json":qh(t)].filter((i)=>Boolean(i?.trim())).join("/")}function oy(){let e=new Map;return{async uploadMessagesFile({sessionId:t,path:n,contents:o,row:r}){let i=yd(r);if(!i)return;let s=An.get(t);if(!s)return;let a=JSON.stringify(s),c=e.get(a);if(!c){if(c=ty(s),!c)return;e.set(a,c)}await c.write(ny(t,n,i),o)}}}function Qr(e,t,n){return{id:`remote-config:${e}:${n}:${t.name}`,name:t.name,kind:e,contents:t.contents,alwaysEnabled:t.alwaysEnabled}}var ry="remote://";function bd(e){let t="",n=!1;for(let o of e.trim().toLowerCase()){let r=o.charCodeAt(0);if(r>=97&&r<=122||r>=48&&r<=57||o==="."||o==="_"||o==="-"){if(n&&t&&t[t.length-1]!=="-")t+="-";n=!1,t+=o}else n=!0;if(t.length>=80)break}while(t.endsWith("-"))t=t.slice(0,-1);while(t.startsWith("-"))t=t.slice(1);return t||"item"}function iy(e){let t=e?.globalRules?.map((o,r)=>Qr("rule",o,`${r}`))??[],n=e?.globalWorkflows?.map((o,r)=>Qr("workflow",o,`${r}`))??[];return[...t,...n]}function sy(e){return[...iy(e.remoteConfig),...e.managedInstructions??[]]}function ay(e){return e.map((t)=>{let n=`## ${t.name}`,o=t.alwaysEnabled?`_Always enabled_
174
174
  `:"";return`${n}
175
175
 
176
176
  ${o}${t.contents.trim()}`}).join(`
177
177
 
178
- `)}function ei(e,t){return e.filter((n)=>n.kind===t)}class ti{async materialize(e){let t=iy(e.bundle),n=ei(t,"rule"),o=ei(t,"workflow"),r=ei(t,"skill");await e.artifactStore.removeChildren(e.paths.workflowsPath),await e.artifactStore.removeChildren(e.paths.skillsPath);let i=[];if(n.length>0)await e.artifactStore.writeText(e.paths.rulesFilePath,sy(n)),i.push(...n.map((s)=>({kind:s.kind,filePath:e.paths.rulesFilePath,id:s.id,name:s.name})));else await e.artifactStore.remove(e.paths.rulesFilePath);for(let s of o){let a=`${e.paths.workflowsPath}/${bd(s.name.replace(/\.(md|markdown|txt)$/i,""))}.md`;await e.artifactStore.writeText(a,s.contents),i.push({kind:s.kind,filePath:a,id:s.id,name:s.name})}for(let s of r){let a=`${e.paths.skillsPath}/${bd(s.name)}/SKILL.md`;await e.artifactStore.writeText(a,s.contents),i.push({kind:s.kind,filePath:a,id:s.id,name:s.name})}return await e.artifactStore.writeText(e.paths.manifestPath,JSON.stringify({source:e.bundle.source,version:e.bundle.version,files:i},null,2)),{paths:e.paths,rulesFilePath:n.length>0?e.paths.rulesFilePath:void 0,files:i}}}import rt from"node:path";var ay="remote-config";function ni(e){let t=e.pluginName??ay,n=rt.join(e.workspacePath,".cline",t);return{pluginName:t,pluginPath:n,workflowsPath:rt.join(n,"workflows"),skillsPath:rt.join(n,"skills"),bundleCachePath:rt.join(n,"cache","bundle.json"),manifestPath:rt.join(n,"managed.json"),rulesFilePath:rt.join(n,"rules.md")}}function xd(e){return{workflowsDirectories:[e.workflowsPath],skillsDirectories:[e.skillsPath]}}function cy(e){if(!e)return;return{enabled:e.openTelemetryEnabled??!1,metricsExporter:e.openTelemetryMetricsExporter,logsExporter:e.openTelemetryLogsExporter,otlpProtocol:e.openTelemetryOtlpProtocol,otlpEndpoint:e.openTelemetryOtlpEndpoint,otlpHeaders:e.openTelemetryOtlpHeaders,otlpMetricsProtocol:e.openTelemetryOtlpMetricsProtocol,otlpMetricsEndpoint:e.openTelemetryOtlpMetricsEndpoint,otlpMetricsHeaders:e.openTelemetryOtlpMetricsHeaders,otlpLogsProtocol:e.openTelemetryOtlpLogsProtocol,otlpLogsEndpoint:e.openTelemetryOtlpLogsEndpoint,otlpLogsHeaders:e.openTelemetryOtlpLogsHeaders,metricExportInterval:e.openTelemetryMetricExportInterval,otlpInsecure:e.openTelemetryOtlpInsecure,logBatchSize:e.openTelemetryLogBatchSize,logBatchTimeout:e.openTelemetryLogBatchTimeout,logMaxQueueSize:e.openTelemetryLogMaxQueueSize}}function _d(e){return typeof e==="object"&&e!==null&&!Array.isArray(e)}function we(e,t){let n=e[t];return typeof n==="string"?n:void 0}function Sd(e,t){let n=e[t];return typeof n==="boolean"?n:void 0}function In(e,t){let n=e[t];return typeof n==="number"&&Number.isFinite(n)?n:void 0}function oi(e,t){let n=e[t];if(!_d(n))return;let o=Object.entries(n).filter((r)=>typeof r[1]==="string");return o.length>0?Object.fromEntries(o):void 0}function uy(e){if(!_d(e))return;let t={enabled:Sd(e,"enabled"),metricsExporter:we(e,"metricsExporter"),logsExporter:we(e,"logsExporter"),otlpProtocol:we(e,"otlpProtocol"),otlpEndpoint:we(e,"otlpEndpoint"),otlpHeaders:oi(e,"otlpHeaders"),otlpMetricsProtocol:we(e,"otlpMetricsProtocol"),otlpMetricsEndpoint:we(e,"otlpMetricsEndpoint"),otlpMetricsHeaders:oi(e,"otlpMetricsHeaders"),otlpLogsProtocol:we(e,"otlpLogsProtocol"),otlpLogsEndpoint:we(e,"otlpLogsEndpoint"),otlpLogsHeaders:oi(e,"otlpLogsHeaders"),metricExportInterval:In(e,"metricExportInterval"),otlpInsecure:Sd(e,"otlpInsecure"),logBatchSize:In(e,"logBatchSize"),logBatchTimeout:In(e,"logBatchTimeout"),logMaxQueueSize:In(e,"logMaxQueueSize")};return Object.values(t).some((n)=>n!==void 0)?t:void 0}class ri{name="remote-config";resolveTelemetry(e,t){return{...cy(e.remoteConfig),...uy(e.telemetry)}}}async function ly(e){let t=ni(e),n=e.artifactStore??new En;await n.removeChildren(t.workflowsPath),await n.removeChildren(t.skillsPath),await n.remove(t.rulesFilePath),await n.remove(t.manifestPath),await n.remove(t.bundleCachePath)}function vd(e){return e?.claims}function Td(e,t){if(!e)return[];if(t.claimsMapper)return t.claimsMapper.mapClaimsToRoles(e);return e.roles??[]}function dy(e,t){return{...e,metadata:{...e.metadata??{},paths:t}}}class Cd{options;constructor(e){this.options=e}async sync(e){let t=await this.options.controlPlane.fetchBundle({workspacePath:e.workspacePath,rootPath:e.rootPath,context:e.context,signal:e.signal,now:e.now,logger:this.options.logger});if(!t)throw Error("Remote config control plane returned no bundle");await this.options.bundleStore.write(t);let n=await this.options.materializer.materialize({bundle:t,paths:e.paths,artifactStore:this.options.artifactStore}),o=this.options.telemetryAdapter?await this.options.telemetryAdapter.resolveTelemetry(t,{workspacePath:e.workspacePath,rootPath:e.rootPath,context:e.context,signal:e.signal,now:e.now,logger:this.options.logger}):void 0,r=vd(t),i=Td(r,this.options);return{bundle:t,materialized:n,telemetry:o,roles:i,claims:r}}}function py(e){let t=e?.name??"remote-config";return{name:t,manifest:{capabilities:["providers"]},async setup(n,o){n.registerProvider?.({name:t,description:"Remote-config managed runtime integration"}),await e?.setup?.(n,o)}}}async function my(e){let t=ni({workspacePath:e.workspacePath,pluginName:e.pluginName}),n=e.bundleStore??new Wr(t.bundleCachePath),o=e.artifactStore??new En,r=e.materializer??new ti,i=e.telemetryAdapter??new ri,s,a,c=[],l,d=!1,p=!1;if(e.controlPlane){let f=new Cd({controlPlane:e.controlPlane,bundleStore:n,artifactStore:o,materializer:r,telemetryAdapter:i,claimsMapper:e.claimsMapper,logger:e.logger});try{let g=await f.sync({workspacePath:e.workspacePath,rootPath:e.rootPath,context:e.context,paths:t,signal:e.signal,now:e.now});s=g.bundle,a=g.telemetry,c=g.roles,l=g.claims,p=!0}catch(g){if(e.useCachedBundle!==!1)s=await n.read(),d=Boolean(s);if(!s)throw g}}else if(e.useCachedBundle!==!1)s=await n.read(),d=Boolean(s);if(!s&&e.requireBundle)throw Error("Remote config runtime preparation requires a bundle");if(s){let f=dy(s,t);if(await n.write(f),!p)await r.materialize({bundle:f,paths:t,artifactStore:o});l??=vd(f),c=c.length>0?c:Td(l,e),a??=await i.resolveTelemetry(f,{workspacePath:e.workspacePath,rootPath:e.rootPath,context:e.context,signal:e.signal,now:e.now,logger:e.logger}),s=f}let m=xd(t);return{pluginName:t.pluginName,pluginDefinition:py({name:t.pluginName}),paths:t,bundle:s,telemetry:a,roles:c,claims:l,usedCachedBundle:d,workflowsDirectories:m.workflowsDirectories,skillsDirectories:m.skillsDirectories}}var kd=b({id:u(),temperature:x().optional(),maxTokens:x().optional(),contextWindow:x().optional(),inputPrice:x().optional(),outputPrice:x().optional(),supportsImages:w().optional()}),Ed=b({models:E(kd).optional(),openAiBaseUrl:u().optional(),openAiHeaders:j(u(),u()).optional(),azureApiVersion:u().optional(),azureIdentity:w().optional()}),Rd=b({id:u(),thinkingBudgetTokens:x().optional()}),Ad=b({name:u(),baseModelId:u(),thinkingBudgetTokens:x().optional()}),Id=b({models:E(Rd).optional(),customModels:E(Ad).optional(),awsRegion:u().optional(),awsUseCrossRegionInference:w().optional(),awsUseGlobalInference:w().optional(),awsBedrockUsePromptCache:w().optional(),awsBedrockEndpoint:u().optional()}),wd=b({id:u()}),Pd=b({models:E(wd).optional()}),Md=b({id:u(),thinkingBudgetTokens:x().optional()}),Od=b({models:E(Md).optional(),vertexProjectId:u().optional(),vertexRegion:u().optional()}),zd=b({id:u(),thinkingBudgetTokens:x().optional(),promptCachingEnabled:w().optional()}),Nd=b({models:E(zd).optional(),baseUrl:u().optional()}),$d=b({id:u(),thinkingBudgetTokens:x().optional()}),Ld=b({models:E($d).optional(),baseUrl:u().optional()}),fy=b({OpenAiCompatible:Ed.optional(),AwsBedrock:Id.optional(),Cline:Pd.optional(),Vertex:Od.optional(),LiteLLM:Nd.optional(),Anthropic:Ld.optional()}),Dd=b({id:u()}),Bd=b({name:u(),url:u(),alwaysEnabled:w().optional(),headers:j(u(),u()).optional()}),ii=b({alwaysEnabled:w(),name:u(),contents:u()}),wn=b({bucket:u(),accessKeyId:u(),secretAccessKey:u(),region:u().optional(),endpoint:u().optional(),accountId:u().optional()}),Ud=b({enabled:w().optional(),type:Ge([V("s3_access_keys"),V("r2_access_keys"),V("azure_access_keys")]).optional(),s3AccessSettings:wn.optional(),r2AccessSettings:wn.optional(),azureAccessSettings:wn.optional()}),Zd=b({promptUploading:Ud.optional()}),gy=b({version:u(),providerSettings:fy.optional(),telemetryEnabled:w().optional(),kanbanEnabled:w().optional(),mcpMarketplaceEnabled:w().optional(),allowedMCPServers:E(Dd).optional(),remoteMCPServers:E(Bd).optional(),blockPersonalRemoteMCPServers:w().optional(),yoloModeAllowed:w().optional(),openTelemetryEnabled:w().optional(),openTelemetryMetricsExporter:u().optional(),openTelemetryLogsExporter:u().optional(),openTelemetryOtlpProtocol:u().optional(),openTelemetryOtlpEndpoint:u().optional(),openTelemetryOtlpHeaders:j(u(),u()).optional(),openTelemetryOtlpMetricsProtocol:u().optional(),openTelemetryOtlpMetricsEndpoint:u().optional(),openTelemetryOtlpMetricsHeaders:j(u(),u()).optional(),openTelemetryOtlpLogsProtocol:u().optional(),openTelemetryOtlpLogsEndpoint:u().optional(),openTelemetryOtlpLogsHeaders:j(u(),u()).optional(),openTelemetryMetricExportInterval:x().optional(),openTelemetryOtlpInsecure:w().optional(),openTelemetryLogBatchSize:x().optional(),openTelemetryLogBatchTimeout:x().optional(),openTelemetryLogMaxQueueSize:x().optional(),enterpriseTelemetry:Zd.optional(),globalRules:E(ii).optional(),globalWorkflows:E(ii).optional()}),hy=j(u(),u());var yy=25463,by=25466,xy=4317;var Sy="127.0.0.1:4317";var _y=I(["reasoning","prompt-cache","tools","provider-tools","oauth","temperature","files","streaming","vision","computer-use","local-auth","popular"]),vy=I(["anthropic","gemini","openai-chat","openai-responses","openai-r1","ai-sdk"]),Ty=I(["anthropic","ai-sdk","ai-sdk-community","openai","openai-compatible","openai-r1","gemini","bedrock","custom","fetch","vertex"]);var Cy="runtime.team.progress.v1",ky="runtime.team.lifecycle.v1";import{basename as Ey}from"node:path";var Pn="CLINE_BUILD_ENV",Fd="CLINE_DEBUG_HOST",Hd="CLINE_DEBUG_PORT_BASE";function jd(e){let t=e?.trim().toLowerCase();if(t==="development"||t==="production")return t;return}function Ry(e){for(let t=0;t<e.length;t+=1){let n=e[t]?.trim();if(!n)continue;if(n==="--conditions"&&e[t+1]?.trim()==="development")return!0;if(n.startsWith("--conditions=")&&n.slice(13).split(",").map((o)=>o.trim()).includes("development"))return!0}return!1}function Ay(e){if(!e?.trim())return!1;let t=Ey(e).toLowerCase();return t==="node"||t==="node.exe"||t==="bun"||t==="bun.exe"}function Iy(e){return e.some((t)=>t==="--inspect"||t.startsWith("--inspect=")||t==="--inspect-brk"||t.startsWith("--inspect-brk="))}function wy(e){return e.some((t)=>t==="--enable-source-maps")}function Py(e){return e[Fd]?.trim()||"127.0.0.1"}function My(e){let t=e[Hd]?.trim();if(!t)return;let n=Number.parseInt(t,10);return Number.isInteger(n)&&n>0?n:void 0}function Oy(e){switch(e){case"rpc":return 0;case"hook":return 1;case"plugin-sandbox":return 2;case"connector":return 3;case"sandbox":return 4;default:return 9}}function si(e={}){let t=e.env??process.env,n=e.execArgv??process.execArgv,o=jd(t[Pn]);if(o)return o;let r=t.NODE_ENV?.trim().toLowerCase();if(r==="production")return"production";if(r==="development")return"development";return Ry(n)?"development":"production"}function zy(e=process.env,t={}){if(jd(e[Pn]))return e;return{...e,[Pn]:si({env:e,execArgv:t.execArgv})}}function Ny(e,t={}){if(e.length===0||!Ay(e[0]))return[...e];if(si(t)!=="development")return[...e];let n=t.env??process.env,o=[...n.NODE_OPTIONS?.split(/\s+/).filter(Boolean)??[],...e.slice(1)],r=[];if(!Iy(o)){let i=Py(n),s=My(n),a=s===void 0?0:s+Oy(t.debugRole);r.push(`--inspect=${i}:${a}`)}if(!wy(o))r.push("--enable-source-maps");return[e[0],...r,...e.slice(1)]}function $y(e){let t=e?.trim();if(!t)return!1;if(t.startsWith("/$bunfs/"))return!0;return t.replace(/\\/g,"/").toLowerCase().startsWith("b:/~bun/")}function Vd(){return globalThis}function Ly(e){Vd().__clineClientIdentity=e}function Dy(){return Vd().__clineClientIdentity}var By="CLINE_ENVIRONMENT",Uy="CLINE_ENVIRONMENT_OVERRIDE",ai={production:{environment:"production",appBaseUrl:"https://app.cline.bot",apiBaseUrl:"https://api.cline.bot",mcpBaseUrl:"https://api.cline.bot/v1/mcp",workOsClientId:"client_01K3A541FN8TA3EPPHTD2325AR"},staging:{environment:"staging",appBaseUrl:"https://staging-app.cline.bot",apiBaseUrl:"https://core-api.staging.int.cline.bot",mcpBaseUrl:"https://core-api.staging.int.cline.bot/v1/mcp",workOsClientId:"client_01K3A5415VF6QBQBG3XYCW91G6"},local:{environment:"local",appBaseUrl:"http://localhost:3000",apiBaseUrl:"http://localhost:7777",mcpBaseUrl:"http://localhost:7777/v1/mcp",workOsClientId:"client_01K6XQAY7JK6T5HXVSZW2S5VYK"}},Zy="production";function qd(e){let t=e?.trim().toLowerCase();if(t==="production"||t==="staging"||t==="local")return t;return}function Gd(){if(typeof process>"u"||!process?.env)return{};return process.env}function Kd(){let e=Gd();return qd(e.CLINE_ENVIRONMENT_OVERRIDE)??qd(e.CLINE_ENVIRONMENT)??"production"}function Fy(e){if(typeof e==="string")return ai[e];return ai[Kd()]}function Hy(e,t){if(t.CLINE_API_BASE_URL)e={...e,apiBaseUrl:t.CLINE_API_BASE_URL,mcpBaseUrl:`${t.CLINE_API_BASE_URL}/v1/mcp`};return e}function jy(e){let t=Fy(e);return Hy(t,Gd())}var Vy="CLINE_RUN_AS_HUB_DAEMON",qy="CLINE_CONNECTOR_CLI_LAUNCH",Gy="CLINE_CONNECTOR_STARTING_INSTANCE",Ky="CLINE_CONNECTOR_SUPERVISED",ci;function Wy(e=process.env){return ci=e.CLINE_RUN_AS_HUB_DAEMON==="1",delete e.CLINE_RUN_AS_HUB_DAEMON,ci}function Jy(e){if(e)return e.CLINE_RUN_AS_HUB_DAEMON==="1";return ci??process.env.CLINE_RUN_AS_HUB_DAEMON==="1"}function Yy(e,t=process.env){t.CLINE_CONNECTOR_CLI_LAUNCH=JSON.stringify(e)}var ui;function Xy(e=process.env){return ui=e.CLINE_CONNECTOR_SUPERVISED==="1",delete e.CLINE_CONNECTOR_SUPERVISED,ui}function Qy(e){if(e)return e.CLINE_CONNECTOR_SUPERVISED==="1";return ui??process.env.CLINE_CONNECTOR_SUPERVISED==="1"}function eb(e,t=process.env){t.CLINE_CONNECTOR_STARTING_INSTANCE=JSON.stringify(e)}function tb(e=process.env){let t=e.CLINE_CONNECTOR_STARTING_INSTANCE;if(!t)return;try{let n=JSON.parse(t);if(typeof n.channel!=="string"||!n.channel.trim()||typeof n.instanceId!=="string"||!n.instanceId.trim())return;return{channel:n.channel,instanceId:n.instanceId}}catch{return}}function nb(e=process.env){let t=e.CLINE_CONNECTOR_CLI_LAUNCH;if(!t)return;try{let n=JSON.parse(t);if(typeof n.launcher!=="string"||!n.launcher.trim()||!Array.isArray(n.connectArgsPrefix)||!n.connectArgsPrefix.every((o)=>typeof o==="string")||typeof n.cwd!=="string"||!n.cwd.trim())return;return{launcher:n.launcher,connectArgsPrefix:n.connectArgsPrefix,cwd:n.cwd}}catch{return}}var ob=["HTTP_PROXY","http_proxy","HTTPS_PROXY","https_proxy","ALL_PROXY","all_proxy"],Jd=["localhost","127.0.0.1","::1","[::1]"];function rb(e){for(let t of ob){let n=e[t]?.trim();if(n)return n}return}function li(e){return(e??"").split(",").map((t)=>t.trim()).filter((t)=>t.length>0)}function ib(e,t){let n=[],o=new Set;for(let r of[...li(e),...li(t),...Jd]){let i=r.toLowerCase();if(i!=="*"&&!o.has(i))o.add(i),n.push(r)}return n.join(",")}function Wd(e){return li(e).includes("*")}function sb(e=process.env){if(!rb(e))return;let t=Wd(e.NO_PROXY),n=Wd(e.no_proxy);if(t&&n)return;let o=ib(e.NO_PROXY,e.no_proxy);if(!t)e.NO_PROXY=o;if(!n)e.no_proxy=o}var ab="NoDefaultCurrentDirectoryInExePath";function cb(e={}){let{env:t=process.env,platform:n=process.platform}=e;if(n!=="win32")return;t.NoDefaultCurrentDirectoryInExePath="1"}var ub="agent.reasoning.unexpected_tokens",lb="task.provider_request_started",db="task.provider_stream_started",pb="task.first_chunk_received",mb="task.provider_stream_failed",fb="task.cancelled",gb="task.max_tokens_recovery",hb=["initial","crash_restart","rollout_fallback","rollout_demotion","user_restart"],yb="sdk.error";var De=new Map;function bb(){De.clear()}function xb(e,t){let n=typeof t.error_message==="string"?t.error_message:"";return[e,t.component,t.operation,t.error_type,t.error_code??"",t.error_status??"",n.replace(/\d+/g,"#").replace(/\s+/g," ").trim().toLowerCase().slice(0,256)].join("\x00")}function Sb(e){let t=Date.now(),n=De.get(e);if(n&&t-n.startMs<3600000){if(n.emitted<5)return n.emitted+=1,{emit:!0,suppressed:0};return n.suppressed+=1,{emit:!1,suppressed:n.suppressed}}let o=n?.suppressed??0;if(De.delete(e),De.size>=512){let r=De.keys().next();if(!r.done)De.delete(r.value)}return De.set(e,{startMs:t,emitted:1,suppressed:0}),{emit:!0,suppressed:o}}function _b(e,t){e?.capture({event:"agent.reasoning.unexpected_tokens",properties:pi({sessionId:t.sessionId,agentId:t.agentId,runId:t.runId,iteration:t.iteration,providerId:t.providerId,modelId:t.modelId,requestedThinking:t.requestedThinking,reasoningTokenCount:t.reasoningTokenCount})})}function vb(e,t){if(!e)return;e.capture({event:t.event,properties:pi({sessionId:t.sessionId,ulid:t.ulid??t.sessionId,agentId:t.agentId,conversationId:t.conversationId,runId:t.runId,iteration:t.iteration,provider:t.providerId,providerId:t.providerId,model:t.modelId,modelId:t.modelId,phase:t.phase,durationMs:t.durationMs,eventType:t.eventType,...t.error===void 0?{}:mi(t.error,t.messageLimit),error_class:t.errorClass})})}function Tb(e,t){if(!e)return!1;let n=t.event??"sdk.error",o=Yd(t),r=0;try{let i=Sb(xb(n,o));if(!i.emit)return!0;r=i.suppressed}catch{}return e.capture({event:n,properties:r>0?{...o,suppressed_count:r}:o}),!0}function Yd(e){return pi({...e.context??{},component:e.component,operation:e.operation,severity:e.severity??"error",handled:e.handled??!0,...mi(e.error,e.messageLimit,e.errorMessage)})}function pi(e){let t={};for(let[n,o]of Object.entries(e))if(o!==void 0)t[n]=o;return t}function mi(e,t=500,n){let o=Eb(e)?e:void 0,r=e instanceof Error?e:void 0,i=$t(n)??$t(r?.message)??$t(o?.message)??Rb(e)??"Unknown error",s=Ab(o?.code),a=di(o?.status)??di(o?.statusCode)??di(o?.responseStatus);return{error_type:r?.name?.trim()||$t(o?.name)||r?.constructor?.name||"Error",error_message:kb(Cb(i),t),...s!==void 0?{error_code:s}:{},...a!==void 0?{error_status:a}:{}}}function Cb(e){return e.replace(/(authorization=Bearer\s+)[^&\s]+/gi,"$1[redacted]").replace(/(api[_-]?key|access[_-]?token|refresh[_-]?token|authorization|password|secret)=([^&\s]+)/gi,"$1=[redacted]").replace(/(Bearer\s+)[A-Za-z0-9._~+/-]+=*/gi,"$1[redacted]").replace(/\/Users\/[^/\s]+/g,"/Users/[redacted]").replace(/\/home\/[^/\s]+/g,"/home/[redacted]").replace(/([A-Za-z]:[\\/]+Users[\\/]+)[^\\/\s]+/g,"$1[redacted]")}function kb(e,t){let n=Math.max(1,Math.floor(t));return e.length>n?e.substring(0,n):e}function Eb(e){return typeof e==="object"&&e!==null}function $t(e){return typeof e==="string"&&e.trim().length>0?e:void 0}function Rb(e){if(e instanceof Error)return;let t=typeof e==="string"?e:String(e);return t==="[object Object]"?void 0:$t(t)}function Ab(e){if(typeof e==="string"&&e.trim().length>0)return e;if(typeof e==="number"&&Number.isFinite(e))return e;return}function di(e){return typeof e==="number"&&Number.isFinite(e)?e:void 0}var fi="_clineOtlpTraceRelay";function Ib(e){e[fi]=!0}function wb(e){return!!e&&typeof e==="object"&&e[fi]===!0}function Xd(e){let t={};if(!e)return t;return e.split(",").forEach((n)=>{let o=n.indexOf("=");if(o<=0)return;try{let r=decodeURIComponent(n.substring(0,o).trim()),i=decodeURIComponent(n.substring(o+1).trim());if(!r||!i)return;t[r]=i}catch{}}),t}function Pb(){if(!process.env)return{enabled:!1};return{enabled:process.env.OTEL_TELEMETRY_ENABLED==="1"||process.env.OTEL_TELEMETRY_ENABLED==="true",metricsExporter:process.env.OTEL_METRICS_EXPORTER||"otlp",logsExporter:process.env.OTEL_LOGS_EXPORTER||"otlp",tracesExporter:process.env.OTEL_TRACES_EXPORTER,otlpProtocol:process.env.OTEL_EXPORTER_OTLP_PROTOCOL||"http/json",otlpEndpoint:process.env.OTEL_EXPORTER_OTLP_ENDPOINT,metricExportInterval:process.env.OTEL_METRIC_EXPORT_INTERVAL?Number.parseInt(process.env.OTEL_METRIC_EXPORT_INTERVAL,10):void 0,otlpHeaders:process.env.OTEL_EXPORTER_OTLP_HEADERS?Xd(process.env.OTEL_EXPORTER_OTLP_HEADERS):void 0}}function Qd(e={}){return{extension_version:"unknown",cline_type:"unknown",platform:"terminal",platform_version:process?.version||"unknown",os_type:process?.platform||"unknown",os_version:process?.platform==="win32"?process?.env?.OS??"unknown":"unknown",...e}}function Mb(e={}){return{...Pb(),...e,metadata:Qd(e.metadata)}}function ep(e){let t=e?.trim();return t?t:void 0}function Ob(e,t){if(!e)return;let n=typeof e==="function"?e(t):e;if(!n)return;let o=ep(n.rootSessionId);if(!o)return;return{rootSessionId:o}}function zb(e){return ep(e?.rootSessionId)}import{webcrypto as tp}from"node:crypto";var Nb=128,Pe,it;function $b(e){if(e<0)throw RangeError("Wrong ID size");try{if(!Pe||Pe.length<e)Pe=Buffer.allocUnsafe(e*Nb),tp.getRandomValues(Pe),it=0;else if(it+e>Pe.length)tp.getRandomValues(Pe),it=0}catch(t){throw Pe=void 0,t}it+=e}function Lb(e){return $b(e|=0),Pe.subarray(it-e,it)}function Db(e,t,n){let o=256-256%e.length;if(o===256){let i=e.length-1;return(s=t)=>{if(!s)return"";let a="";while(!0){let c=n(s),l=s;while(l--)if(a+=e[c[l]&i],a.length>=s)return a}}}let r=Math.ceil(409.6*t/o);return(i=t)=>{if(!i)return"";let s="";while(!0){let a=n(r),c=r;while(c--)if(a[c]<o){if(s+=e[a[c]%e.length],s.length>=i)return s}}}}function np(e,t=21){return Db(e,t,Lb)}function Bb(e="",t=""){let n=np("1234567890abcdefghijklmnopqrstuvwxyz",10);return`${e}${Date.now()}_${n(5)}${t}`}var Ub=["idle","running","pending","completed","failed","cancelled"];var gi=["rules","skills","workflows","plugins","hooks"],op=gi,Zb=new Set(gi);function rp(e){return typeof e==="string"&&Zb.has(e)}function Fb(e){if(!Array.isArray(e))return;let t=e.map((n)=>typeof n==="string"?n.trim():"").filter(rp);return[...new Set(t)]}function Hb(e,t){return new Set(e??op).has(t)}var jb=b({rootPath:u().min(1),hint:u().min(1).optional(),associatedRemoteUrls:E(u().min(1)).optional(),latestGitCommitHash:u().min(1).optional(),latestGitBranchName:u().min(1).optional()}),Vb=b({currentWorkspacePath:u().min(1).optional(),workspaces:j(u().min(1),jb)});function HC(){return{workspaces:{}}}function jC(e,t){let n={...e,workspaces:{...e.workspaces,[t.rootPath]:t}};if(!n.currentWorkspacePath)n.currentWorkspacePath=t.rootPath;return Vb.parse(n)}var qb="workspaces",Gb="chat";function Kb(e){let t=e.trim(),n=/^[A-Za-z]:[\\/]/.test(t)||t.startsWith("\\\\"),o=t.startsWith("/");if(!n&&!o)return!1;let r=t.split(n?/[\\/]+/:/\/+/).filter(Boolean),i=r.at(-1)??"",s=r.at(-2)??"",a=r.at(-3)??"";return(r.at(-4)??"")===".cline"&&a==="data"&&s==="workspaces"&&i==="chat"}var Wb=["current_state","boundary_analysis","interface_proposal"],KC=3600000,WC=240,JC=400,le=Gu((e)=>e instanceof Date?e.toISOString():e,u().datetime()),st=I(["pending","in_progress","blocked","completed"]),ip=I(["queued","running","completed","failed","cancelled","interrupted"]),Mn=I(["draft","in_review","finalized"]),Jb=b({agentId:u(),role:I(["lead","teammate"]),description:u().optional(),status:I(["idle","running","stopped"])}),YC=b({agentId:u(),rolePrompt:u(),modelId:u().optional(),maxIterations:x().optional()});function Z(e){return Gu((t)=>t===null?void 0:t,e.optional())}var XC=b({agentId:u().min(1).describe("Teammate identifier"),rolePrompt:u().min(1).describe("System prompt describing teammate role")}).strict(),QC=b({agentId:u().min(1).describe("Teammate identifier"),reason:Z(u().min(1)).describe("Optional shutdown reason")}),ek=b({}),Yb={create:["title","description"],list:[],claim:["taskId"],complete:["taskId","summary"],block:["taskId","reason"]},tk={create:["status","taskId","summary","reason"]},nk=b({action:I(["create","list","claim","complete","block"]),title:Z(u().min(1)).describe("Task title"),description:Z(u().min(1)).describe("Task details"),dependsOn:Z(E(u().describe("Dependency task ID"))).describe("Array of dependency task IDs"),assignee:Z(u().min(1)).describe("Optional assignee"),status:Z(I(["pending","in_progress","blocked","completed"])).describe("Optional task status filter"),taskId:Z(u()).describe("Task ID"),summary:Z(u().min(1)).describe("Completion summary"),reason:Z(u().min(1)).describe("Blocking reason")}).superRefine((e,t)=>{for(let n of Yb[e.action]){if(e[n]!==void 0)continue;t.addIssue({code:"custom",path:[n],message:`Field "${n}" is required when action=${e.action}`})}}),ok=b({agentId:u().describe("Teammate agent ID"),task:u().min(1).describe("Task instructions for the teammate"),taskId:Z(u()).describe("Optional shared task list ID"),runMode:Z(I(["sync","async"])).describe("Execution mode: 'sync' blocks until the teammate finishes and returns the result (default if omitted); 'async' queues the run and returns a runId immediately — use team_await_runs to collect results later."),continueConversation:Z(w()).describe("If true, continue the teammate conversation; otherwise start fresh")}),rk=b({status:Z(I(["queued","running","completed","failed","cancelled","interrupted"])).describe("Optional run status filter. Omit to include all statuses."),agentId:Z(u().min(1)).describe("Optional teammate ID filter. Omit to include all teammates."),includeCompleted:Z(w()).describe("Include completed/failed runs (default true)")}),ik=b({runId:u().min(1).describe("Run ID"),reason:Z(u().min(1)).describe("Optional cancellation reason")}),sk=b({runId:Z(u().min(1)).describe("Optional async run ID to await. Omit to wait for all active async runs.")}).strict(),ak=b({toAgentId:u().min(1).describe("Recipient agent ID"),subject:u().min(1).describe("Message subject"),body:u().min(1).describe("Message body"),taskId:Z(u().min(1)).describe("Optional task ID context")}),ck=b({subject:u().min(1).describe("Message subject"),body:u().min(1).describe("Message body"),taskId:Z(u().min(1)).describe("Optional task ID context")}),uk=b({unreadOnly:Z(w()).describe("Only unread messages for read action (default true)")}),lk=b({kind:I(["progress","handoff","blocked","decision","done","error"]),summary:u().min(1).describe("Update summary"),taskId:Z(u().min(1)).describe("Optional task ID context"),evidence:Z(E(u().min(1))).describe("Optional evidence links/snippets"),nextAction:Z(u().min(1)).describe("Planned next step")}),dk=b({}),pk=b({title:u().describe("Outcome title"),requiredSections:E(u()).default(Wb).describe("Required sections for finalization gate (defaults to current_state,boundary_analysis,interface_proposal)")}),mk=b({outcomeId:u().describe("Outcome ID"),section:u().describe("Section name"),sourceRunId:Z(u()).describe("Optional source run ID"),content:u().describe("Section fragment content")}),fk=b({fragmentId:u().describe("Fragment ID"),approved:w().describe("Review decision")}),gk=b({outcomeId:u().describe("Outcome ID")}),hk=b({}),yk=b({teamId:u(),teamName:u(),members:E(Jb),taskCounts:j(st,x()),unreadMessages:x(),missionLogEntries:x(),activeRuns:x(),queuedRuns:x(),outcomeCounts:j(Mn,x())}),Xb=b({id:u(),title:u(),description:u(),status:st,createdAt:le,updatedAt:le,createdBy:u(),assignee:u().optional(),dependsOn:E(u()),summary:u().optional(),isReady:w(),blockedBy:E(u())}),bk=ar("action",[b({action:V("create"),taskId:u(),status:st,ignoredFields:E(u()).optional(),note:u().optional()}),b({action:V("list"),tasks:E(Xb)}),b({action:V("claim"),taskId:u(),status:st,nextStep:u()}),b({action:V("complete"),taskId:u(),status:st}),b({action:V("block"),taskId:u(),status:st})]),xk=b({agentId:u(),mode:I(["sync","async"]),status:I(["dispatched","running","queued","joined"]),dispatched:w(),message:u(),deduped:w().optional(),runId:u().optional(),text:u().optional(),iterations:x().optional()}),Qb=b({textPreview:u(),iterations:x(),finishReason:u(),durationMs:x(),usage:b({inputTokens:x(),outputTokens:x(),cacheReadTokens:x().optional(),cacheWriteTokens:x().optional(),totalCost:x().optional()})}),Sk=b({id:u(),agentId:u(),taskId:u().optional(),status:ip,messagePreview:u(),priority:x(),retryCount:x(),maxRetries:x(),nextAttemptAt:le.optional(),continueConversation:w().optional(),startedAt:le,endedAt:le.optional(),leaseOwner:u().optional(),heartbeatAt:le.optional(),lastProgressAt:le.optional(),lastProgressMessage:u().optional(),currentActivity:u().optional(),error:u().optional(),resultSummary:Qb.optional()}),_k=b({id:u(),teamId:u(),fromAgentId:u(),toAgentId:u(),subject:u(),body:u(),taskId:u().optional(),sentAt:le,readAt:le.optional()}),vk=b({id:u(),teamId:u(),title:u(),status:Mn,requiredSections:E(u()),createdBy:u(),createdAt:le,finalizedAt:le.optional()}),Tk=b({outcomeId:u(),status:Mn,requiredSections:E(u())}),Ck=b({agentId:u(),status:u()}),kk=b({runId:u(),status:ip}),Ek=b({id:u(),toAgentId:u()}),Rk=b({delivered:x()}),Ak=b({id:u()}),Ik=b({status:u()}),wk=b({fragmentId:u(),status:u()}),Pk=b({outcomeId:u(),status:Mn});var ex;((R)=>{R.TaskStart="task_start";R.TaskEnd="task_end";R.AgentEvent="agent_event";R.TeammateSpawned="teammate_spawned";R.TeammateShutdown="teammate_shutdown";R.TeamTaskUpdated="team_task_updated";R.TeamMessage="team_message";R.TeamMissionLog="team_mission_log";R.TeamTaskCompleted="team_task_completed";R.RunStarted="run_started";R.RunQueued="run_queued";R.RunProgress="run_progress";R.RunCompleted="run_completed";R.RunFailed="run_failed";R.RunCancelled="run_cancelled";R.RunInterrupted="run_interrupted";R.OutcomeCreated="outcome_created";R.OutcomeFragmentAttached="outcome_fragment_attached";R.OutcomeFragmentReviewed="outcome_fragment_reviewed";R.OutcomeFinalized="outcome_finalized"})(ex||={});function tx(e){let{$schema:t,...n}=e;if(typeof n.type==="string")return n;if("properties"in n||"required"in n||"additionalProperties"in n)return{type:"object",...n};for(let o of["oneOf","anyOf","allOf"]){let r=n[o];if(!Array.isArray(r)||r.length===0)continue;if(o==="allOf"){if(r.some((a)=>a&&typeof a==="object"&&a.type==="object"))return{type:"object",...n};throw Error('Tool inputSchema must describe an object at the top level, but the schema has a top-level "allOf" with no branch that asserts type: "object". Add type: "object" to at least one allOf branch to make the object constraint explicit.')}if(r.every((s)=>s&&typeof s==="object"&&s.type==="object"))return{type:"object",...n};throw Error(`Tool inputSchema must describe an object at the top level, but the schema has a top-level "${o}" whose branches include non-object types. Pass the strict object schema as inputSchema and reserve union/coercion schemas for use inside execute().`)}return n}function nx(e){let t=tx(e.inputSchema instanceof N?jr(e.inputSchema):e.inputSchema);return{name:e.name,resultPolicy:e.resultPolicy,description:e.description,inputSchema:t,lifecycle:e.lifecycle,executionMode:e.executionMode,timeoutMs:e.timeoutMs??30000,retryable:e.retryable??!0,maxRetries:e.maxRetries??3,execute:e.execute}}var sp=["401","403","unauthorized","forbidden","invalid token","expired token","authentication"];function ox(e){let t=(e instanceof Error?e.message:String(e)).toLowerCase();return sp.some((n)=>t.includes(n))}import{existsSync as rx,mkdirSync as ix,readFileSync as sx,writeFileSync as ax}from"node:fs";import{dirname as cx,resolve as ux}from"node:path";var lx=new Set(["accesskeyid","secretaccesskey","idtoken","refreshtoken","accesstoken","access_token","refresh_token","apikey","api_key","authorization","password","secret","token","email","displayname","display_name","userinfo"]),dx=["id","balance","cost","secret"];function px(e){let t=e.toLowerCase();if(lx.has(t))return!0;for(let n of dx){if(t===n)return!0;if(t.endsWith(n)&&t.length>n.length){let o=t[t.length-n.length-1];if(o==="_"||o==="-")return!0;let r=e[e.length-n.length];if(r&&r===r.toUpperCase()&&r!==r.toLowerCase())return!0}if(t.endsWith(`_${n}`))return!0}return!1}var mx=[{pattern:/AKIA[A-Z0-9]{16}/g,replacement:"AKIA_REDACTED"},{pattern:/\/Users\/[A-Za-z0-9._-]+/g,replacement:"/Users/REDACTED_USER"},{pattern:/\/home\/[A-Za-z0-9._-]+/g,replacement:"/home/REDACTED_USER"}];function cp(e){let t=e;for(let{pattern:n,replacement:o}of mx)t=t.replace(n,o);return t}function hi(e){if(Array.isArray(e))return e.map(hi);if(!e||typeof e!=="object")return e;return Object.fromEntries(Object.entries(e).sort(([t],[n])=>fx(t,n)).map(([t,n])=>[t,hi(n)]))}function fx(e,t){if(e<t)return-1;if(e>t)return 1;return 0}function ap(e){return JSON.stringify(hi(e))}var gx=[{pattern:/tasks\/[A-Za-z0-9._-]+\/[A-Za-z0-9._-]+\/api_conversation_history/g,replacement:"tasks/usr-test/taskid/api_conversation_history"},{pattern:/\/(org|usr|mbr|ses|gen|req|msg|tsk|sch|exe|srv|cli|wkr|evt|sub|tkn)-[A-Za-z0-9]{10,}(?=[/?#]|$)/g,replacement:"/$1-REDACTED"}];function yi(e){let t=e;for(let{pattern:n,replacement:o}of gx)t=t.replace(n,o);return t}function at(e){if(e===null||e===void 0)return e;if(typeof e==="string"){try{let t=JSON.parse(e);if(typeof t==="object"&&t!==null)return JSON.stringify(at(t))}catch{}return cp(e)}if(Array.isArray(e))return e.map(at);if(typeof e==="object"){let t={};for(let[n,o]of Object.entries(e))if(px(n)&&(typeof o==="string"||typeof o==="number"))t[n]="REDACTED";else t[n]=at(o);return t}return e}function hx(e){let t=new URLSearchParams(e),n=Array.from(t.entries());if(n.length===0||n.some(([r])=>r.length===0))return;let o={};for(let[r,i]of n){let s=o[r];if(s===void 0)o[r]=i;else if(Array.isArray(s))s.push(i);else o[r]=[s,i]}return o}function yx(e){return e?.toLowerCase().split(";")[0]?.trim()==="application/x-www-form-urlencoded"}function up(e,t){try{return ap(at(JSON.parse(e)))}catch{if(yx(t)){let n=hx(e);if(n)return ap(at(n))}return cp(e)}}function bx(e,t){let n={...e},o=t&&e.body!==void 0?up(e.body,e.requestContentType):void 0;if(delete n.body,delete n.requestContentType,o!==void 0)n.requestBody=o;if(typeof n.path==="string")n.path=yi(n.path);if(n.response!==void 0)n.response=at(n.response);return n}function lp(e){try{let t=new URL(e),n=`${t.protocol}//${t.host}`,o=t.pathname+t.search;return{scope:n,path:o}}catch{return{scope:"",path:e}}}function dp(e){if(typeof e==="string")return e;if(e instanceof URL)return e.toString();if(e&&typeof e.url==="string")return e.url;return String(e)}function pp(e,t){if(t?.method)return t.method.toUpperCase();if(e&&typeof e.method==="string")return e.method.toUpperCase();return"GET"}function xx(e){if(!e)return;return new Headers(e).get("content-type")??void 0}function mp(e,t){let n=xx(t?.headers);if(n)return n;if(t?.body instanceof URLSearchParams)return"application/x-www-form-urlencoded;charset=UTF-8";if(e instanceof Request)return e.headers.get("content-type")??void 0;return}async function fp(e,t){if(t?.body){if(typeof t.body==="string")return t.body;if(t.body instanceof URLSearchParams)return t.body.toString();if(t.body instanceof ArrayBuffer)return new TextDecoder().decode(t.body);if(ArrayBuffer.isView(t.body))return new TextDecoder().decode(new Uint8Array(t.body.buffer,t.body.byteOffset,t.body.byteLength));return}if(e instanceof Request)try{return await e.clone().text()}catch{return}return}function Sx(e){if(!e)return null;if(!process.env.CLINE_VCR_CASSETTE)return process.stderr.write(`[VCR] No CLINE_VCR_CASSETTE: requests will not be recorded or played back.
178
+ `)}function ei(e,t){return e.filter((n)=>n.kind===t)}class ti{async materialize(e){let t=sy(e.bundle),n=ei(t,"rule"),o=ei(t,"workflow"),r=ei(t,"skill");await e.artifactStore.removeChildren(e.paths.workflowsPath),await e.artifactStore.removeChildren(e.paths.skillsPath);let i=[];if(n.length>0)await e.artifactStore.writeText(e.paths.rulesFilePath,ay(n)),i.push(...n.map((s)=>({kind:s.kind,filePath:e.paths.rulesFilePath,id:s.id,name:s.name})));else await e.artifactStore.remove(e.paths.rulesFilePath);for(let s of o){let a=`${e.paths.workflowsPath}/${bd(s.name.replace(/\.(md|markdown|txt)$/i,""))}.md`;await e.artifactStore.writeText(a,s.contents),i.push({kind:s.kind,filePath:a,id:s.id,name:s.name})}for(let s of r){let a=`${e.paths.skillsPath}/${bd(s.name)}/SKILL.md`;await e.artifactStore.writeText(a,s.contents),i.push({kind:s.kind,filePath:a,id:s.id,name:s.name})}return await e.artifactStore.writeText(e.paths.manifestPath,JSON.stringify({source:e.bundle.source,version:e.bundle.version,files:i},null,2)),{paths:e.paths,rulesFilePath:n.length>0?e.paths.rulesFilePath:void 0,files:i}}}import rt from"node:path";var cy="remote-config";function ni(e){let t=e.pluginName??cy,n=rt.join(e.workspacePath,".cline",t);return{pluginName:t,pluginPath:n,workflowsPath:rt.join(n,"workflows"),skillsPath:rt.join(n,"skills"),bundleCachePath:rt.join(n,"cache","bundle.json"),manifestPath:rt.join(n,"managed.json"),rulesFilePath:rt.join(n,"rules.md")}}function xd(e){return{workflowsDirectories:[e.workflowsPath],skillsDirectories:[e.skillsPath]}}function uy(e){if(!e)return;return{enabled:e.openTelemetryEnabled??!1,metricsExporter:e.openTelemetryMetricsExporter,logsExporter:e.openTelemetryLogsExporter,otlpProtocol:e.openTelemetryOtlpProtocol,otlpEndpoint:e.openTelemetryOtlpEndpoint,otlpHeaders:e.openTelemetryOtlpHeaders,otlpMetricsProtocol:e.openTelemetryOtlpMetricsProtocol,otlpMetricsEndpoint:e.openTelemetryOtlpMetricsEndpoint,otlpMetricsHeaders:e.openTelemetryOtlpMetricsHeaders,otlpLogsProtocol:e.openTelemetryOtlpLogsProtocol,otlpLogsEndpoint:e.openTelemetryOtlpLogsEndpoint,otlpLogsHeaders:e.openTelemetryOtlpLogsHeaders,metricExportInterval:e.openTelemetryMetricExportInterval,otlpInsecure:e.openTelemetryOtlpInsecure,logBatchSize:e.openTelemetryLogBatchSize,logBatchTimeout:e.openTelemetryLogBatchTimeout,logMaxQueueSize:e.openTelemetryLogMaxQueueSize}}function _d(e){return typeof e==="object"&&e!==null&&!Array.isArray(e)}function we(e,t){let n=e[t];return typeof n==="string"?n:void 0}function Sd(e,t){let n=e[t];return typeof n==="boolean"?n:void 0}function In(e,t){let n=e[t];return typeof n==="number"&&Number.isFinite(n)?n:void 0}function oi(e,t){let n=e[t];if(!_d(n))return;let o=Object.entries(n).filter((r)=>typeof r[1]==="string");return o.length>0?Object.fromEntries(o):void 0}function ly(e){if(!_d(e))return;let t={enabled:Sd(e,"enabled"),metricsExporter:we(e,"metricsExporter"),logsExporter:we(e,"logsExporter"),otlpProtocol:we(e,"otlpProtocol"),otlpEndpoint:we(e,"otlpEndpoint"),otlpHeaders:oi(e,"otlpHeaders"),otlpMetricsProtocol:we(e,"otlpMetricsProtocol"),otlpMetricsEndpoint:we(e,"otlpMetricsEndpoint"),otlpMetricsHeaders:oi(e,"otlpMetricsHeaders"),otlpLogsProtocol:we(e,"otlpLogsProtocol"),otlpLogsEndpoint:we(e,"otlpLogsEndpoint"),otlpLogsHeaders:oi(e,"otlpLogsHeaders"),metricExportInterval:In(e,"metricExportInterval"),otlpInsecure:Sd(e,"otlpInsecure"),logBatchSize:In(e,"logBatchSize"),logBatchTimeout:In(e,"logBatchTimeout"),logMaxQueueSize:In(e,"logMaxQueueSize")};return Object.values(t).some((n)=>n!==void 0)?t:void 0}class ri{name="remote-config";resolveTelemetry(e,t){return{...uy(e.remoteConfig),...ly(e.telemetry)}}}async function dy(e){let t=ni(e),n=e.artifactStore??new En;await n.removeChildren(t.workflowsPath),await n.removeChildren(t.skillsPath),await n.remove(t.rulesFilePath),await n.remove(t.manifestPath),await n.remove(t.bundleCachePath)}function vd(e){return e?.claims}function Td(e,t){if(!e)return[];if(t.claimsMapper)return t.claimsMapper.mapClaimsToRoles(e);return e.roles??[]}function py(e,t){return{...e,metadata:{...e.metadata??{},paths:t}}}class Cd{options;constructor(e){this.options=e}async sync(e){let t=await this.options.controlPlane.fetchBundle({workspacePath:e.workspacePath,rootPath:e.rootPath,context:e.context,signal:e.signal,now:e.now,logger:this.options.logger});if(!t)throw Error("Remote config control plane returned no bundle");await this.options.bundleStore.write(t);let n=await this.options.materializer.materialize({bundle:t,paths:e.paths,artifactStore:this.options.artifactStore}),o=this.options.telemetryAdapter?await this.options.telemetryAdapter.resolveTelemetry(t,{workspacePath:e.workspacePath,rootPath:e.rootPath,context:e.context,signal:e.signal,now:e.now,logger:this.options.logger}):void 0,r=vd(t),i=Td(r,this.options);return{bundle:t,materialized:n,telemetry:o,roles:i,claims:r}}}function my(e){let t=e?.name??"remote-config";return{name:t,manifest:{capabilities:["providers"]},async setup(n,o){n.registerProvider?.({name:t,description:"Remote-config managed runtime integration"}),await e?.setup?.(n,o)}}}async function fy(e){let t=ni({workspacePath:e.workspacePath,pluginName:e.pluginName}),n=e.bundleStore??new Wr(t.bundleCachePath),o=e.artifactStore??new En,r=e.materializer??new ti,i=e.telemetryAdapter??new ri,s,a,c=[],l,d=!1,p=!1;if(e.controlPlane){let f=new Cd({controlPlane:e.controlPlane,bundleStore:n,artifactStore:o,materializer:r,telemetryAdapter:i,claimsMapper:e.claimsMapper,logger:e.logger});try{let g=await f.sync({workspacePath:e.workspacePath,rootPath:e.rootPath,context:e.context,paths:t,signal:e.signal,now:e.now});s=g.bundle,a=g.telemetry,c=g.roles,l=g.claims,p=!0}catch(g){if(e.useCachedBundle!==!1)s=await n.read(),d=Boolean(s);if(!s)throw g}}else if(e.useCachedBundle!==!1)s=await n.read(),d=Boolean(s);if(!s&&e.requireBundle)throw Error("Remote config runtime preparation requires a bundle");if(s){let f=py(s,t);if(await n.write(f),!p)await r.materialize({bundle:f,paths:t,artifactStore:o});l??=vd(f),c=c.length>0?c:Td(l,e),a??=await i.resolveTelemetry(f,{workspacePath:e.workspacePath,rootPath:e.rootPath,context:e.context,signal:e.signal,now:e.now,logger:e.logger}),s=f}let m=xd(t);return{pluginName:t.pluginName,pluginDefinition:my({name:t.pluginName}),paths:t,bundle:s,telemetry:a,roles:c,claims:l,usedCachedBundle:d,workflowsDirectories:m.workflowsDirectories,skillsDirectories:m.skillsDirectories}}var kd=b({id:u(),temperature:x().optional(),maxTokens:x().optional(),contextWindow:x().optional(),inputPrice:x().optional(),outputPrice:x().optional(),supportsImages:w().optional()}),Ed=b({models:E(kd).optional(),openAiBaseUrl:u().optional(),openAiHeaders:j(u(),u()).optional(),azureApiVersion:u().optional(),azureIdentity:w().optional()}),Rd=b({id:u(),thinkingBudgetTokens:x().optional()}),Ad=b({name:u(),baseModelId:u(),thinkingBudgetTokens:x().optional()}),Id=b({models:E(Rd).optional(),customModels:E(Ad).optional(),awsRegion:u().optional(),awsUseCrossRegionInference:w().optional(),awsUseGlobalInference:w().optional(),awsBedrockUsePromptCache:w().optional(),awsBedrockEndpoint:u().optional()}),wd=b({id:u()}),Pd=b({models:E(wd).optional()}),Md=b({id:u(),thinkingBudgetTokens:x().optional()}),Od=b({models:E(Md).optional(),vertexProjectId:u().optional(),vertexRegion:u().optional()}),zd=b({id:u(),thinkingBudgetTokens:x().optional(),promptCachingEnabled:w().optional()}),Nd=b({models:E(zd).optional(),baseUrl:u().optional()}),$d=b({id:u(),thinkingBudgetTokens:x().optional()}),Ld=b({models:E($d).optional(),baseUrl:u().optional()}),gy=b({OpenAiCompatible:Ed.optional(),AwsBedrock:Id.optional(),Cline:Pd.optional(),Vertex:Od.optional(),LiteLLM:Nd.optional(),Anthropic:Ld.optional()}),Dd=b({id:u()}),Bd=b({name:u(),url:u(),alwaysEnabled:w().optional(),headers:j(u(),u()).optional()}),ii=b({alwaysEnabled:w(),name:u(),contents:u()}),wn=b({bucket:u(),accessKeyId:u(),secretAccessKey:u(),region:u().optional(),endpoint:u().optional(),accountId:u().optional()}),Ud=b({enabled:w().optional(),type:Ge([V("s3_access_keys"),V("r2_access_keys"),V("azure_access_keys")]).optional(),s3AccessSettings:wn.optional(),r2AccessSettings:wn.optional(),azureAccessSettings:wn.optional()}),Zd=b({promptUploading:Ud.optional()}),hy=b({version:u(),providerSettings:gy.optional(),telemetryEnabled:w().optional(),kanbanEnabled:w().optional(),mcpMarketplaceEnabled:w().optional(),allowedMCPServers:E(Dd).optional(),remoteMCPServers:E(Bd).optional(),blockPersonalRemoteMCPServers:w().optional(),yoloModeAllowed:w().optional(),openTelemetryEnabled:w().optional(),openTelemetryMetricsExporter:u().optional(),openTelemetryLogsExporter:u().optional(),openTelemetryOtlpProtocol:u().optional(),openTelemetryOtlpEndpoint:u().optional(),openTelemetryOtlpHeaders:j(u(),u()).optional(),openTelemetryOtlpMetricsProtocol:u().optional(),openTelemetryOtlpMetricsEndpoint:u().optional(),openTelemetryOtlpMetricsHeaders:j(u(),u()).optional(),openTelemetryOtlpLogsProtocol:u().optional(),openTelemetryOtlpLogsEndpoint:u().optional(),openTelemetryOtlpLogsHeaders:j(u(),u()).optional(),openTelemetryMetricExportInterval:x().optional(),openTelemetryOtlpInsecure:w().optional(),openTelemetryLogBatchSize:x().optional(),openTelemetryLogBatchTimeout:x().optional(),openTelemetryLogMaxQueueSize:x().optional(),enterpriseTelemetry:Zd.optional(),globalRules:E(ii).optional(),globalWorkflows:E(ii).optional()}),yy=j(u(),u());var by=25463,xy=25466,Sy=4317;var _y="127.0.0.1:4317";var vy=I(["reasoning","prompt-cache","tools","provider-tools","oauth","temperature","files","streaming","vision","computer-use","local-auth","popular"]),Ty=I(["anthropic","gemini","openai-chat","openai-responses","openai-r1","ai-sdk"]),Cy=I(["anthropic","ai-sdk","ai-sdk-community","openai","openai-compatible","openai-r1","gemini","bedrock","custom","fetch","vertex"]);var ky="runtime.team.progress.v1",Ey="runtime.team.lifecycle.v1";import{basename as Ry}from"node:path";var Pn="CLINE_BUILD_ENV",Fd="CLINE_DEBUG_HOST",Hd="CLINE_DEBUG_PORT_BASE";function jd(e){let t=e?.trim().toLowerCase();if(t==="development"||t==="production")return t;return}function Ay(e){for(let t=0;t<e.length;t+=1){let n=e[t]?.trim();if(!n)continue;if(n==="--conditions"&&e[t+1]?.trim()==="development")return!0;if(n.startsWith("--conditions=")&&n.slice(13).split(",").map((o)=>o.trim()).includes("development"))return!0}return!1}function Iy(e){if(!e?.trim())return!1;let t=Ry(e).toLowerCase();return t==="node"||t==="node.exe"||t==="bun"||t==="bun.exe"}function wy(e){return e.some((t)=>t==="--inspect"||t.startsWith("--inspect=")||t==="--inspect-brk"||t.startsWith("--inspect-brk="))}function Py(e){return e.some((t)=>t==="--enable-source-maps")}function My(e){return e[Fd]?.trim()||"127.0.0.1"}function Oy(e){let t=e[Hd]?.trim();if(!t)return;let n=Number.parseInt(t,10);return Number.isInteger(n)&&n>0?n:void 0}function zy(e){switch(e){case"rpc":return 0;case"hook":return 1;case"plugin-sandbox":return 2;case"connector":return 3;case"sandbox":return 4;default:return 9}}function si(e={}){let t=e.env??process.env,n=e.execArgv??process.execArgv,o=jd(t[Pn]);if(o)return o;let r=t.NODE_ENV?.trim().toLowerCase();if(r==="production")return"production";if(r==="development")return"development";return Ay(n)?"development":"production"}function Ny(e=process.env,t={}){if(jd(e[Pn]))return e;return{...e,[Pn]:si({env:e,execArgv:t.execArgv})}}function $y(e,t={}){if(e.length===0||!Iy(e[0]))return[...e];if(si(t)!=="development")return[...e];let n=t.env??process.env,o=[...n.NODE_OPTIONS?.split(/\s+/).filter(Boolean)??[],...e.slice(1)],r=[];if(!wy(o)){let i=My(n),s=Oy(n),a=s===void 0?0:s+zy(t.debugRole);r.push(`--inspect=${i}:${a}`)}if(!Py(o))r.push("--enable-source-maps");return[e[0],...r,...e.slice(1)]}function Ly(e){let t=e?.trim();if(!t)return!1;if(t.startsWith("/$bunfs/"))return!0;return t.replace(/\\/g,"/").toLowerCase().startsWith("b:/~bun/")}function Vd(){return globalThis}function Dy(e){Vd().__clineClientIdentity=e}function By(){return Vd().__clineClientIdentity}var Uy="CLINE_ENVIRONMENT",Zy="CLINE_ENVIRONMENT_OVERRIDE",ai={production:{environment:"production",appBaseUrl:"https://app.cline.bot",apiBaseUrl:"https://api.cline.bot",mcpBaseUrl:"https://api.cline.bot/v1/mcp",workOsClientId:"client_01K3A541FN8TA3EPPHTD2325AR"},staging:{environment:"staging",appBaseUrl:"https://staging-app.cline.bot",apiBaseUrl:"https://core-api.staging.int.cline.bot",mcpBaseUrl:"https://core-api.staging.int.cline.bot/v1/mcp",workOsClientId:"client_01K3A5415VF6QBQBG3XYCW91G6"},local:{environment:"local",appBaseUrl:"http://localhost:3000",apiBaseUrl:"http://localhost:7777",mcpBaseUrl:"http://localhost:7777/v1/mcp",workOsClientId:"client_01K6XQAY7JK6T5HXVSZW2S5VYK"}},Fy="production";function qd(e){let t=e?.trim().toLowerCase();if(t==="production"||t==="staging"||t==="local")return t;return}function Gd(){if(typeof process>"u"||!process?.env)return{};return process.env}function Kd(){let e=Gd();return qd(e.CLINE_ENVIRONMENT_OVERRIDE)??qd(e.CLINE_ENVIRONMENT)??"production"}function Hy(e){if(typeof e==="string")return ai[e];return ai[Kd()]}function jy(e,t){if(t.CLINE_API_BASE_URL)e={...e,apiBaseUrl:t.CLINE_API_BASE_URL,mcpBaseUrl:`${t.CLINE_API_BASE_URL}/v1/mcp`};return e}function Vy(e){let t=Hy(e);return jy(t,Gd())}var qy="CLINE_RUN_AS_HUB_DAEMON",Gy="CLINE_CONNECTOR_CLI_LAUNCH",Ky="CLINE_CONNECTOR_STARTING_INSTANCE",Wy="CLINE_CONNECTOR_SUPERVISED",ci;function Jy(e=process.env){return ci=e.CLINE_RUN_AS_HUB_DAEMON==="1",delete e.CLINE_RUN_AS_HUB_DAEMON,ci}function Yy(e){if(e)return e.CLINE_RUN_AS_HUB_DAEMON==="1";return ci??process.env.CLINE_RUN_AS_HUB_DAEMON==="1"}function Xy(e,t=process.env){t.CLINE_CONNECTOR_CLI_LAUNCH=JSON.stringify(e)}var ui;function Qy(e=process.env){return ui=e.CLINE_CONNECTOR_SUPERVISED==="1",delete e.CLINE_CONNECTOR_SUPERVISED,ui}function eb(e){if(e)return e.CLINE_CONNECTOR_SUPERVISED==="1";return ui??process.env.CLINE_CONNECTOR_SUPERVISED==="1"}function tb(e,t=process.env){t.CLINE_CONNECTOR_STARTING_INSTANCE=JSON.stringify(e)}function nb(e=process.env){let t=e.CLINE_CONNECTOR_STARTING_INSTANCE;if(!t)return;try{let n=JSON.parse(t);if(typeof n.channel!=="string"||!n.channel.trim()||typeof n.instanceId!=="string"||!n.instanceId.trim())return;return{channel:n.channel,instanceId:n.instanceId}}catch{return}}function ob(e=process.env){let t=e.CLINE_CONNECTOR_CLI_LAUNCH;if(!t)return;try{let n=JSON.parse(t);if(typeof n.launcher!=="string"||!n.launcher.trim()||!Array.isArray(n.connectArgsPrefix)||!n.connectArgsPrefix.every((o)=>typeof o==="string")||typeof n.cwd!=="string"||!n.cwd.trim())return;return{launcher:n.launcher,connectArgsPrefix:n.connectArgsPrefix,cwd:n.cwd}}catch{return}}var rb=["HTTP_PROXY","http_proxy","HTTPS_PROXY","https_proxy","ALL_PROXY","all_proxy"],Jd=["localhost","127.0.0.1","::1","[::1]"];function ib(e){for(let t of rb){let n=e[t]?.trim();if(n)return n}return}function li(e){return(e??"").split(",").map((t)=>t.trim()).filter((t)=>t.length>0)}function sb(e,t){let n=[],o=new Set;for(let r of[...li(e),...li(t),...Jd]){let i=r.toLowerCase();if(i!=="*"&&!o.has(i))o.add(i),n.push(r)}return n.join(",")}function Wd(e){return li(e).includes("*")}function ab(e=process.env){if(!ib(e))return;let t=Wd(e.NO_PROXY),n=Wd(e.no_proxy);if(t&&n)return;let o=sb(e.NO_PROXY,e.no_proxy);if(!t)e.NO_PROXY=o;if(!n)e.no_proxy=o}var cb="NoDefaultCurrentDirectoryInExePath";function ub(e={}){let{env:t=process.env,platform:n=process.platform}=e;if(n!=="win32")return;t.NoDefaultCurrentDirectoryInExePath="1"}var lb="agent.reasoning.unexpected_tokens",db="task.provider_request_started",pb="task.provider_stream_started",mb="task.first_chunk_received",fb="task.provider_stream_failed",gb="task.cancelled",hb="task.max_tokens_recovery",yb=["initial","crash_restart","rollout_fallback","rollout_demotion","user_restart"],bb="sdk.error";var De=new Map;function xb(){De.clear()}function Sb(e,t){let n=typeof t.error_message==="string"?t.error_message:"";return[e,t.component,t.operation,t.error_type,t.error_code??"",t.error_status??"",n.replace(/\d+/g,"#").replace(/\s+/g," ").trim().toLowerCase().slice(0,256)].join("\x00")}function _b(e){let t=Date.now(),n=De.get(e);if(n&&t-n.startMs<3600000){if(n.emitted<5)return n.emitted+=1,{emit:!0,suppressed:0};return n.suppressed+=1,{emit:!1,suppressed:n.suppressed}}let o=n?.suppressed??0;if(De.delete(e),De.size>=512){let r=De.keys().next();if(!r.done)De.delete(r.value)}return De.set(e,{startMs:t,emitted:1,suppressed:0}),{emit:!0,suppressed:o}}function vb(e,t){e?.capture({event:"agent.reasoning.unexpected_tokens",properties:pi({sessionId:t.sessionId,agentId:t.agentId,runId:t.runId,iteration:t.iteration,providerId:t.providerId,modelId:t.modelId,requestedThinking:t.requestedThinking,reasoningTokenCount:t.reasoningTokenCount})})}function Tb(e,t){if(!e)return;e.capture({event:t.event,properties:pi({sessionId:t.sessionId,ulid:t.ulid??t.sessionId,agentId:t.agentId,conversationId:t.conversationId,runId:t.runId,iteration:t.iteration,provider:t.providerId,providerId:t.providerId,model:t.modelId,modelId:t.modelId,phase:t.phase,durationMs:t.durationMs,eventType:t.eventType,...t.error===void 0?{}:mi(t.error,t.messageLimit),error_class:t.errorClass})})}function Cb(e,t){if(!e)return!1;let n=t.event??"sdk.error",o=Yd(t),r=0;try{let i=_b(Sb(n,o));if(!i.emit)return!0;r=i.suppressed}catch{}return e.capture({event:n,properties:r>0?{...o,suppressed_count:r}:o}),!0}function Yd(e){return pi({...e.context??{},component:e.component,operation:e.operation,severity:e.severity??"error",handled:e.handled??!0,...mi(e.error,e.messageLimit,e.errorMessage)})}function pi(e){let t={};for(let[n,o]of Object.entries(e))if(o!==void 0)t[n]=o;return t}function mi(e,t=500,n){let o=Rb(e)?e:void 0,r=e instanceof Error?e:void 0,i=$t(n)??$t(r?.message)??$t(o?.message)??Ab(e)??"Unknown error",s=Ib(o?.code),a=di(o?.status)??di(o?.statusCode)??di(o?.responseStatus);return{error_type:r?.name?.trim()||$t(o?.name)||r?.constructor?.name||"Error",error_message:Eb(kb(i),t),...s!==void 0?{error_code:s}:{},...a!==void 0?{error_status:a}:{}}}function kb(e){return e.replace(/(authorization=Bearer\s+)[^&\s]+/gi,"$1[redacted]").replace(/(api[_-]?key|access[_-]?token|refresh[_-]?token|authorization|password|secret)=([^&\s]+)/gi,"$1=[redacted]").replace(/(Bearer\s+)[A-Za-z0-9._~+/-]+=*/gi,"$1[redacted]").replace(/\/Users\/[^/\s]+/g,"/Users/[redacted]").replace(/\/home\/[^/\s]+/g,"/home/[redacted]").replace(/([A-Za-z]:[\\/]+Users[\\/]+)[^\\/\s]+/g,"$1[redacted]")}function Eb(e,t){let n=Math.max(1,Math.floor(t));return e.length>n?e.substring(0,n):e}function Rb(e){return typeof e==="object"&&e!==null}function $t(e){return typeof e==="string"&&e.trim().length>0?e:void 0}function Ab(e){if(e instanceof Error)return;let t=typeof e==="string"?e:String(e);return t==="[object Object]"?void 0:$t(t)}function Ib(e){if(typeof e==="string"&&e.trim().length>0)return e;if(typeof e==="number"&&Number.isFinite(e))return e;return}function di(e){return typeof e==="number"&&Number.isFinite(e)?e:void 0}var fi="_clineOtlpTraceRelay";function wb(e){e[fi]=!0}function Pb(e){return!!e&&typeof e==="object"&&e[fi]===!0}function Xd(e){let t={};if(!e)return t;return e.split(",").forEach((n)=>{let o=n.indexOf("=");if(o<=0)return;try{let r=decodeURIComponent(n.substring(0,o).trim()),i=decodeURIComponent(n.substring(o+1).trim());if(!r||!i)return;t[r]=i}catch{}}),t}function Mb(){if(!process.env)return{enabled:!1};return{enabled:process.env.OTEL_TELEMETRY_ENABLED==="1"||process.env.OTEL_TELEMETRY_ENABLED==="true",metricsExporter:process.env.OTEL_METRICS_EXPORTER||"otlp",logsExporter:process.env.OTEL_LOGS_EXPORTER||"otlp",tracesExporter:process.env.OTEL_TRACES_EXPORTER,otlpProtocol:process.env.OTEL_EXPORTER_OTLP_PROTOCOL||"http/json",otlpEndpoint:process.env.OTEL_EXPORTER_OTLP_ENDPOINT,metricExportInterval:process.env.OTEL_METRIC_EXPORT_INTERVAL?Number.parseInt(process.env.OTEL_METRIC_EXPORT_INTERVAL,10):void 0,otlpHeaders:process.env.OTEL_EXPORTER_OTLP_HEADERS?Xd(process.env.OTEL_EXPORTER_OTLP_HEADERS):void 0}}function Qd(e={}){return{extension_version:"unknown",cline_type:"unknown",platform:"terminal",platform_version:process?.version||"unknown",os_type:process?.platform||"unknown",os_version:process?.platform==="win32"?process?.env?.OS??"unknown":"unknown",...e}}function Ob(e={}){return{...Mb(),...e,metadata:Qd(e.metadata)}}function ep(e){let t=e?.trim();return t?t:void 0}function zb(e,t){if(!e)return;let n=typeof e==="function"?e(t):e;if(!n)return;let o=ep(n.rootSessionId);if(!o)return;return{rootSessionId:o}}function Nb(e){return ep(e?.rootSessionId)}import{webcrypto as tp}from"node:crypto";var $b=128,Pe,it;function Lb(e){if(e<0)throw RangeError("Wrong ID size");try{if(!Pe||Pe.length<e)Pe=Buffer.allocUnsafe(e*$b),tp.getRandomValues(Pe),it=0;else if(it+e>Pe.length)tp.getRandomValues(Pe),it=0}catch(t){throw Pe=void 0,t}it+=e}function Db(e){return Lb(e|=0),Pe.subarray(it-e,it)}function Bb(e,t,n){let o=256-256%e.length;if(o===256){let i=e.length-1;return(s=t)=>{if(!s)return"";let a="";while(!0){let c=n(s),l=s;while(l--)if(a+=e[c[l]&i],a.length>=s)return a}}}let r=Math.ceil(409.6*t/o);return(i=t)=>{if(!i)return"";let s="";while(!0){let a=n(r),c=r;while(c--)if(a[c]<o){if(s+=e[a[c]%e.length],s.length>=i)return s}}}}function np(e,t=21){return Bb(e,t,Db)}function Ub(e="",t=""){let n=np("1234567890abcdefghijklmnopqrstuvwxyz",10);return`${e}${Date.now()}_${n(5)}${t}`}var Zb=["idle","running","pending","completed","failed","cancelled"];var gi=["rules","skills","workflows","plugins","hooks"],op=gi,Fb=new Set(gi);function rp(e){return typeof e==="string"&&Fb.has(e)}function Hb(e){if(!Array.isArray(e))return;let t=e.map((n)=>typeof n==="string"?n.trim():"").filter(rp);return[...new Set(t)]}function jb(e,t){return new Set(e??op).has(t)}var Vb=b({rootPath:u().min(1),hint:u().min(1).optional(),associatedRemoteUrls:E(u().min(1)).optional(),latestGitCommitHash:u().min(1).optional(),latestGitBranchName:u().min(1).optional()}),qb=b({currentWorkspacePath:u().min(1).optional(),workspaces:j(u().min(1),Vb)});function jC(){return{workspaces:{}}}function VC(e,t){let n={...e,workspaces:{...e.workspaces,[t.rootPath]:t}};if(!n.currentWorkspacePath)n.currentWorkspacePath=t.rootPath;return qb.parse(n)}var Gb="workspaces",Kb="chat";function Wb(e){let t=e.trim(),n=/^[A-Za-z]:[\\/]/.test(t)||t.startsWith("\\\\"),o=t.startsWith("/");if(!n&&!o)return!1;let r=t.split(n?/[\\/]+/:/\/+/).filter(Boolean),i=r.at(-1)??"",s=r.at(-2)??"",a=r.at(-3)??"";return(r.at(-4)??"")===".cline"&&a==="data"&&s==="workspaces"&&i==="chat"}var Jb=["current_state","boundary_analysis","interface_proposal"],WC=3600000,JC=240,YC=400,le=Gu((e)=>e instanceof Date?e.toISOString():e,u().datetime()),st=I(["pending","in_progress","blocked","completed"]),ip=I(["queued","running","completed","failed","cancelled","interrupted"]),Mn=I(["draft","in_review","finalized"]),Yb=b({agentId:u(),role:I(["lead","teammate"]),description:u().optional(),status:I(["idle","running","stopped"])}),XC=b({agentId:u(),rolePrompt:u(),modelId:u().optional(),maxIterations:x().optional()});function Z(e){return Gu((t)=>t===null?void 0:t,e.optional())}var QC=b({agentId:u().min(1).describe("Teammate identifier"),rolePrompt:u().min(1).describe("System prompt describing teammate role")}).strict(),ek=b({agentId:u().min(1).describe("Teammate identifier"),reason:Z(u().min(1)).describe("Optional shutdown reason")}),tk=b({}),Xb={create:["title","description"],list:[],claim:["taskId"],complete:["taskId","summary"],block:["taskId","reason"]},nk={create:["status","taskId","summary","reason"]},ok=b({action:I(["create","list","claim","complete","block"]),title:Z(u().min(1)).describe("Task title"),description:Z(u().min(1)).describe("Task details"),dependsOn:Z(E(u().describe("Dependency task ID"))).describe("Array of dependency task IDs"),assignee:Z(u().min(1)).describe("Optional assignee"),status:Z(I(["pending","in_progress","blocked","completed"])).describe("Optional task status filter"),taskId:Z(u()).describe("Task ID"),summary:Z(u().min(1)).describe("Completion summary"),reason:Z(u().min(1)).describe("Blocking reason")}).superRefine((e,t)=>{for(let n of Xb[e.action]){if(e[n]!==void 0)continue;t.addIssue({code:"custom",path:[n],message:`Field "${n}" is required when action=${e.action}`})}}),rk=b({agentId:u().describe("Teammate agent ID"),task:u().min(1).describe("Task instructions for the teammate"),taskId:Z(u()).describe("Optional shared task list ID"),runMode:Z(I(["sync","async"])).describe("Execution mode: 'sync' blocks until the teammate finishes and returns the result (default if omitted); 'async' queues the run and returns a runId immediately — use team_await_runs to collect results later."),continueConversation:Z(w()).describe("If true, continue the teammate conversation; otherwise start fresh")}),ik=b({status:Z(I(["queued","running","completed","failed","cancelled","interrupted"])).describe("Optional run status filter. Omit to include all statuses."),agentId:Z(u().min(1)).describe("Optional teammate ID filter. Omit to include all teammates."),includeCompleted:Z(w()).describe("Include completed/failed runs (default true)")}),sk=b({runId:u().min(1).describe("Run ID"),reason:Z(u().min(1)).describe("Optional cancellation reason")}),ak=b({runId:Z(u().min(1)).describe("Optional async run ID to await. Omit to wait for all active async runs.")}).strict(),ck=b({toAgentId:u().min(1).describe("Recipient agent ID"),subject:u().min(1).describe("Message subject"),body:u().min(1).describe("Message body"),taskId:Z(u().min(1)).describe("Optional task ID context")}),uk=b({subject:u().min(1).describe("Message subject"),body:u().min(1).describe("Message body"),taskId:Z(u().min(1)).describe("Optional task ID context")}),lk=b({unreadOnly:Z(w()).describe("Only unread messages for read action (default true)")}),dk=b({kind:I(["progress","handoff","blocked","decision","done","error"]),summary:u().min(1).describe("Update summary"),taskId:Z(u().min(1)).describe("Optional task ID context"),evidence:Z(E(u().min(1))).describe("Optional evidence links/snippets"),nextAction:Z(u().min(1)).describe("Planned next step")}),pk=b({}),mk=b({title:u().describe("Outcome title"),requiredSections:E(u()).default(Jb).describe("Required sections for finalization gate (defaults to current_state,boundary_analysis,interface_proposal)")}),fk=b({outcomeId:u().describe("Outcome ID"),section:u().describe("Section name"),sourceRunId:Z(u()).describe("Optional source run ID"),content:u().describe("Section fragment content")}),gk=b({fragmentId:u().describe("Fragment ID"),approved:w().describe("Review decision")}),hk=b({outcomeId:u().describe("Outcome ID")}),yk=b({}),bk=b({teamId:u(),teamName:u(),members:E(Yb),taskCounts:j(st,x()),unreadMessages:x(),missionLogEntries:x(),activeRuns:x(),queuedRuns:x(),outcomeCounts:j(Mn,x())}),Qb=b({id:u(),title:u(),description:u(),status:st,createdAt:le,updatedAt:le,createdBy:u(),assignee:u().optional(),dependsOn:E(u()),summary:u().optional(),isReady:w(),blockedBy:E(u())}),xk=ar("action",[b({action:V("create"),taskId:u(),status:st,ignoredFields:E(u()).optional(),note:u().optional()}),b({action:V("list"),tasks:E(Qb)}),b({action:V("claim"),taskId:u(),status:st,nextStep:u()}),b({action:V("complete"),taskId:u(),status:st}),b({action:V("block"),taskId:u(),status:st})]),Sk=b({agentId:u(),mode:I(["sync","async"]),status:I(["dispatched","running","queued","joined"]),dispatched:w(),message:u(),deduped:w().optional(),runId:u().optional(),text:u().optional(),iterations:x().optional()}),ex=b({textPreview:u(),iterations:x(),finishReason:u(),durationMs:x(),usage:b({inputTokens:x(),outputTokens:x(),cacheReadTokens:x().optional(),cacheWriteTokens:x().optional(),totalCost:x().optional()})}),_k=b({id:u(),agentId:u(),taskId:u().optional(),status:ip,messagePreview:u(),priority:x(),retryCount:x(),maxRetries:x(),nextAttemptAt:le.optional(),continueConversation:w().optional(),startedAt:le,endedAt:le.optional(),leaseOwner:u().optional(),heartbeatAt:le.optional(),lastProgressAt:le.optional(),lastProgressMessage:u().optional(),currentActivity:u().optional(),error:u().optional(),resultSummary:ex.optional()}),vk=b({id:u(),teamId:u(),fromAgentId:u(),toAgentId:u(),subject:u(),body:u(),taskId:u().optional(),sentAt:le,readAt:le.optional()}),Tk=b({id:u(),teamId:u(),title:u(),status:Mn,requiredSections:E(u()),createdBy:u(),createdAt:le,finalizedAt:le.optional()}),Ck=b({outcomeId:u(),status:Mn,requiredSections:E(u())}),kk=b({agentId:u(),status:u()}),Ek=b({runId:u(),status:ip}),Rk=b({id:u(),toAgentId:u()}),Ak=b({delivered:x()}),Ik=b({id:u()}),wk=b({status:u()}),Pk=b({fragmentId:u(),status:u()}),Mk=b({outcomeId:u(),status:Mn});var tx;((R)=>{R.TaskStart="task_start";R.TaskEnd="task_end";R.AgentEvent="agent_event";R.TeammateSpawned="teammate_spawned";R.TeammateShutdown="teammate_shutdown";R.TeamTaskUpdated="team_task_updated";R.TeamMessage="team_message";R.TeamMissionLog="team_mission_log";R.TeamTaskCompleted="team_task_completed";R.RunStarted="run_started";R.RunQueued="run_queued";R.RunProgress="run_progress";R.RunCompleted="run_completed";R.RunFailed="run_failed";R.RunCancelled="run_cancelled";R.RunInterrupted="run_interrupted";R.OutcomeCreated="outcome_created";R.OutcomeFragmentAttached="outcome_fragment_attached";R.OutcomeFragmentReviewed="outcome_fragment_reviewed";R.OutcomeFinalized="outcome_finalized"})(tx||={});function nx(e){let{$schema:t,...n}=e;if(typeof n.type==="string")return n;if("properties"in n||"required"in n||"additionalProperties"in n)return{type:"object",...n};for(let o of["oneOf","anyOf","allOf"]){let r=n[o];if(!Array.isArray(r)||r.length===0)continue;if(o==="allOf"){if(r.some((a)=>a&&typeof a==="object"&&a.type==="object"))return{type:"object",...n};throw Error('Tool inputSchema must describe an object at the top level, but the schema has a top-level "allOf" with no branch that asserts type: "object". Add type: "object" to at least one allOf branch to make the object constraint explicit.')}if(r.every((s)=>s&&typeof s==="object"&&s.type==="object"))return{type:"object",...n};throw Error(`Tool inputSchema must describe an object at the top level, but the schema has a top-level "${o}" whose branches include non-object types. Pass the strict object schema as inputSchema and reserve union/coercion schemas for use inside execute().`)}return n}function ox(e){let t=nx(e.inputSchema instanceof N?jr(e.inputSchema):e.inputSchema);return{name:e.name,resultPolicy:e.resultPolicy,description:e.description,inputSchema:t,lifecycle:e.lifecycle,executionMode:e.executionMode,timeoutMs:e.timeoutMs??30000,retryable:e.retryable??!0,maxRetries:e.maxRetries??3,execute:e.execute}}var sp=["401","403","unauthorized","forbidden","invalid token","expired token","authentication"];function rx(e){let t=(e instanceof Error?e.message:String(e)).toLowerCase();return sp.some((n)=>t.includes(n))}import{existsSync as ix,mkdirSync as sx,readFileSync as ax,writeFileSync as cx}from"node:fs";import{dirname as ux,resolve as lx}from"node:path";var dx=new Set(["accesskeyid","secretaccesskey","idtoken","refreshtoken","accesstoken","access_token","refresh_token","apikey","api_key","authorization","password","secret","token","email","displayname","display_name","userinfo"]),px=["id","balance","cost","secret"];function mx(e){let t=e.toLowerCase();if(dx.has(t))return!0;for(let n of px){if(t===n)return!0;if(t.endsWith(n)&&t.length>n.length){let o=t[t.length-n.length-1];if(o==="_"||o==="-")return!0;let r=e[e.length-n.length];if(r&&r===r.toUpperCase()&&r!==r.toLowerCase())return!0}if(t.endsWith(`_${n}`))return!0}return!1}var fx=[{pattern:/AKIA[A-Z0-9]{16}/g,replacement:"AKIA_REDACTED"},{pattern:/\/Users\/[A-Za-z0-9._-]+/g,replacement:"/Users/REDACTED_USER"},{pattern:/\/home\/[A-Za-z0-9._-]+/g,replacement:"/home/REDACTED_USER"}];function cp(e){let t=e;for(let{pattern:n,replacement:o}of fx)t=t.replace(n,o);return t}function hi(e){if(Array.isArray(e))return e.map(hi);if(!e||typeof e!=="object")return e;return Object.fromEntries(Object.entries(e).sort(([t],[n])=>gx(t,n)).map(([t,n])=>[t,hi(n)]))}function gx(e,t){if(e<t)return-1;if(e>t)return 1;return 0}function ap(e){return JSON.stringify(hi(e))}var hx=[{pattern:/tasks\/[A-Za-z0-9._-]+\/[A-Za-z0-9._-]+\/api_conversation_history/g,replacement:"tasks/usr-test/taskid/api_conversation_history"},{pattern:/\/(org|usr|mbr|ses|gen|req|msg|tsk|sch|exe|srv|cli|wkr|evt|sub|tkn)-[A-Za-z0-9]{10,}(?=[/?#]|$)/g,replacement:"/$1-REDACTED"}];function yi(e){let t=e;for(let{pattern:n,replacement:o}of hx)t=t.replace(n,o);return t}function at(e){if(e===null||e===void 0)return e;if(typeof e==="string"){try{let t=JSON.parse(e);if(typeof t==="object"&&t!==null)return JSON.stringify(at(t))}catch{}return cp(e)}if(Array.isArray(e))return e.map(at);if(typeof e==="object"){let t={};for(let[n,o]of Object.entries(e))if(mx(n)&&(typeof o==="string"||typeof o==="number"))t[n]="REDACTED";else t[n]=at(o);return t}return e}function yx(e){let t=new URLSearchParams(e),n=Array.from(t.entries());if(n.length===0||n.some(([r])=>r.length===0))return;let o={};for(let[r,i]of n){let s=o[r];if(s===void 0)o[r]=i;else if(Array.isArray(s))s.push(i);else o[r]=[s,i]}return o}function bx(e){return e?.toLowerCase().split(";")[0]?.trim()==="application/x-www-form-urlencoded"}function up(e,t){try{return ap(at(JSON.parse(e)))}catch{if(bx(t)){let n=yx(e);if(n)return ap(at(n))}return cp(e)}}function xx(e,t){let n={...e},o=t&&e.body!==void 0?up(e.body,e.requestContentType):void 0;if(delete n.body,delete n.requestContentType,o!==void 0)n.requestBody=o;if(typeof n.path==="string")n.path=yi(n.path);if(n.response!==void 0)n.response=at(n.response);return n}function lp(e){try{let t=new URL(e),n=`${t.protocol}//${t.host}`,o=t.pathname+t.search;return{scope:n,path:o}}catch{return{scope:"",path:e}}}function dp(e){if(typeof e==="string")return e;if(e instanceof URL)return e.toString();if(e&&typeof e.url==="string")return e.url;return String(e)}function pp(e,t){if(t?.method)return t.method.toUpperCase();if(e&&typeof e.method==="string")return e.method.toUpperCase();return"GET"}function Sx(e){if(!e)return;return new Headers(e).get("content-type")??void 0}function mp(e,t){let n=Sx(t?.headers);if(n)return n;if(t?.body instanceof URLSearchParams)return"application/x-www-form-urlencoded;charset=UTF-8";if(e instanceof Request)return e.headers.get("content-type")??void 0;return}async function fp(e,t){if(t?.body){if(typeof t.body==="string")return t.body;if(t.body instanceof URLSearchParams)return t.body.toString();if(t.body instanceof ArrayBuffer)return new TextDecoder().decode(t.body);if(ArrayBuffer.isView(t.body))return new TextDecoder().decode(new Uint8Array(t.body.buffer,t.body.byteOffset,t.body.byteLength));return}if(e instanceof Request)try{return await e.clone().text()}catch{return}return}function _x(e){if(!e)return null;if(!process.env.CLINE_VCR_CASSETTE)return process.stderr.write(`[VCR] No CLINE_VCR_CASSETTE: requests will not be recorded or played back.
179
179
  `),null;if(e!=="record"&&e!=="playback")process.stderr.write(`[VCR] Invalid CLINE_VCR value: "${e}". Expected "record" or "playback".
180
- `),process.exit(1);let t=ux(process.env.CLINE_VCR_CASSETTE),n=process.env.CLINE_VCR_FILTER??"",o=process.env.CLINE_VCR_INCLUDE_REQUEST_BODY==="1"||process.env.CLINE_VCR_INCLUDE_REQUEST_BODY==="true";return{mode:e,cassettePath:t,filter:n,includeRequestBody:o}}function _x(e,t,n){let o=[],r=[],i=globalThis.fetch;function s(d){if(d.finalized)return;d.finalized=!0;let p=new TextDecoder,m=d.chunks.map((g)=>p.decode(g,{stream:!0})).join("")+p.decode(),f;try{f=JSON.parse(m)}catch{f=m}o.push({scope:d.scope,method:d.method,path:d.path,body:d.body,requestContentType:d.requestContentType,status:d.status,response:f,responseIsBinary:!1,contentType:d.contentType})}globalThis.fetch=Object.assign(async(d,p)=>{let m=dp(d),f=pp(d,p),{scope:g,path:y}=lp(m),S=await fp(d,p),v=mp(d,p),k=await i(d,p);if(t&&!y.includes(t))return k;let M=k.headers.get("content-type")??void 0;if(!k.body)return o.push({scope:g,method:f,path:y,body:S??"",requestContentType:v,status:k.status,response:"",responseIsBinary:!1,contentType:M}),k;let R={scope:g,method:f,path:y,body:S??"",requestContentType:v,status:k.status,contentType:M,chunks:[],finalized:!1};r.push(R);let B=k.body,A=new TransformStream({transform(Te,Me){R.chunks.push(Te),Me.enqueue(Te)},flush(){s(R)}}),J=B.pipeThrough(A);return new Response(J,{status:k.status,statusText:k.statusText,headers:k.headers})},{preconnect:(d)=>{}});let a=t?`matching path "*${t}*"`:"all paths";process.stderr.write(`[VCR] Recording HTTP requests (${a}). Cassette will be saved to: ${e}
180
+ `),process.exit(1);let t=lx(process.env.CLINE_VCR_CASSETTE),n=process.env.CLINE_VCR_FILTER??"",o=process.env.CLINE_VCR_INCLUDE_REQUEST_BODY==="1"||process.env.CLINE_VCR_INCLUDE_REQUEST_BODY==="true";return{mode:e,cassettePath:t,filter:n,includeRequestBody:o}}function vx(e,t,n){let o=[],r=[],i=globalThis.fetch;function s(d){if(d.finalized)return;d.finalized=!0;let p=new TextDecoder,m=d.chunks.map((g)=>p.decode(g,{stream:!0})).join("")+p.decode(),f;try{f=JSON.parse(m)}catch{f=m}o.push({scope:d.scope,method:d.method,path:d.path,body:d.body,requestContentType:d.requestContentType,status:d.status,response:f,responseIsBinary:!1,contentType:d.contentType})}globalThis.fetch=Object.assign(async(d,p)=>{let m=dp(d),f=pp(d,p),{scope:g,path:y}=lp(m),S=await fp(d,p),v=mp(d,p),k=await i(d,p);if(t&&!y.includes(t))return k;let M=k.headers.get("content-type")??void 0;if(!k.body)return o.push({scope:g,method:f,path:y,body:S??"",requestContentType:v,status:k.status,response:"",responseIsBinary:!1,contentType:M}),k;let R={scope:g,method:f,path:y,body:S??"",requestContentType:v,status:k.status,contentType:M,chunks:[],finalized:!1};r.push(R);let B=k.body,A=new TransformStream({transform(Te,Me){R.chunks.push(Te),Me.enqueue(Te)},flush(){s(R)}}),J=B.pipeThrough(A);return new Response(J,{status:k.status,statusText:k.statusText,headers:k.headers})},{preconnect:(d)=>{}});let a=t?`matching path "*${t}*"`:"all paths";process.stderr.write(`[VCR] Recording HTTP requests (${a}). Cassette will be saved to: ${e}
181
181
  `);let c=!1;gr(()=>{if(c)return;c=!0,globalThis.fetch=i;for(let m of r)s(m);if(o.length===0){process.stderr.write(`[VCR] No HTTP requests${t?` matching "${t}"`:""} were recorded.
182
- `);return}let d=cx(e);ix(d,{recursive:!0});let p=o.map((m)=>bx(m,n));ax(e,JSON.stringify(p,null,2)),process.stderr.write(`[VCR] Saved ${p.length} recorded HTTP interaction(s) to ${e}
183
- `)})}function vx(e){let t=[],n=e.split(/\n\n/);for(let o of n){let r=o.trim();if(r)t.push(`${r}
182
+ `);return}let d=ux(e);sx(d,{recursive:!0});let p=o.map((m)=>xx(m,n));cx(e,JSON.stringify(p,null,2)),process.stderr.write(`[VCR] Saved ${p.length} recorded HTTP interaction(s) to ${e}
183
+ `)})}function Tx(e){let t=[],n=e.split(/\n\n/);for(let o of n){let r=o.trim();if(r)t.push(`${r}
184
184
 
185
- `)}return t}function Tx(e,t){let n=new TextEncoder,o=0;return new ReadableStream({async pull(r){if(o>=e.length){r.close();return}if(o>0&&t>0)await new Promise((s)=>setTimeout(s,t));let i=e[o];if(i===void 0){r.close();return}r.enqueue(n.encode(i)),o+=1}})}async function Cx(e){if(e.recording.requestBody===void 0)return;let t=await fp(e.requestInput,e.requestInit),n=mp(e.requestInput,e.requestInit),o=up(t??"",n);if(o!==e.recording.requestBody)throw Error(`[VCR] Request body mismatch for ${e.method} ${e.path}.
185
+ `)}return t}function Cx(e,t){let n=new TextEncoder,o=0;return new ReadableStream({async pull(r){if(o>=e.length){r.close();return}if(o>0&&t>0)await new Promise((s)=>setTimeout(s,t));let i=e[o];if(i===void 0){r.close();return}r.enqueue(n.encode(i)),o+=1}})}async function kx(e){if(e.recording.requestBody===void 0)return;let t=await fp(e.requestInput,e.requestInit),n=mp(e.requestInput,e.requestInit),o=up(t??"",n);if(o!==e.recording.requestBody)throw Error(`[VCR] Request body mismatch for ${e.method} ${e.path}.
186
186
  expected: ${e.recording.requestBody}
187
187
  actual: ${o}
188
- Re-record the cassette if the request change is intentional.`)}function kx(e,t){if(!rx(e))process.stderr.write(`[VCR] Cassette file not found: ${e}
189
- `),process.exit(1);let n=JSON.parse(sx(e,"utf-8")),o=Number.parseInt(process.env.CLINE_VCR_SSE_DELAY??"100",10),r=Array(n.length).fill(!1),i=globalThis.fetch;globalThis.fetch=Object.assign(async(a,c)=>{let l=dp(a),d=pp(a,c),{path:p}=lp(l),m=yi(p);if(t&&!p.includes(t))return i(a,c);let f=n.findIndex((g,y)=>{if(r[y])return!1;let S=yi(g.path);return g.method.toUpperCase()===d&&S===m});if(f>=0){let g=n[f];if(!g)return i(a,c);await Cx({recording:g,requestInput:a,requestInit:c,method:d,path:m}),r[f]=!0;let y=typeof g.response==="string"?g.response:JSON.stringify(g.response),S=new Headers;if(g.contentType)S.set("content-type",g.contentType);else if(typeof g.response==="string"&&g.response.trimStart().startsWith("data:"))S.set("content-type","text/event-stream");else if(typeof g.response==="object")S.set("content-type","application/json");let v=S.get("content-type")?.includes("text/event-stream")??!1;if(v)S.set("cache-control","no-cache"),S.set("connection","keep-alive");if(v&&typeof g.response==="string"){let k=vx(g.response);if(k.length>1){let M=Tx(k,o);return new Response(M,{status:g.status,headers:S})}}return new Response(y,{status:g.status,headers:S})}if(!t)throw Error(`[VCR] No matching recording for ${d} ${l} (path: ${m}). ${n.length} recording(s) loaded from ${e}.`);return i(a,c)},{preconnect:(a)=>{}});let s=t?`(only paths matching "*${t}*", all other requests go through normally)`:"(all requests intercepted)";process.stderr.write(`[VCR] Playing back ${n.length} recorded HTTP interaction(s) from ${e} ${s}
190
- `)}function Ex(e){let t=Sx(e);if(!t)return;if(t.mode==="record")_x(t.cassettePath,t.filter,t.includeRequestBody);else kx(t.cassettePath,t.filter)}export{ub as AGENT_UNEXPECTED_REASONING_TOKENS_EVENT,hy as APIKeySchema,sp as AUTH_ERROR_PATTERNS,sv as AgentConfigSchema,Lf as AgentFinishReasonSchema,iv as AgentResultSchema,Df as AgentUsageSchema,Dd as AllowedMCPServerSchema,$d as AnthropicModelSchema,Ld as AnthropicSchema,Af as ApiFormat,Ku as ApiFormatSchema,Ad as AwsBedrockCustomModelSchema,Rd as AwsBedrockModelSchema,Id as AwsBedrockSettingsSchema,Kg as CHARS_PER_TOKEN,Pn as CLINE_BUILD_ENV_ENV,Gb as CLINE_CHAT_WORKSPACE_DIRECTORY_NAME,qy as CLINE_CONNECTOR_CLI_LAUNCH_ENV,Gy as CLINE_CONNECTOR_STARTING_INSTANCE_ENV,Ky as CLINE_CONNECTOR_SUPERVISED_ENV,Fd as CLINE_DEBUG_HOST_ENV,Hd as CLINE_DEBUG_PORT_BASE_ENV,Bh as CLINE_DEFAULT_MODEL_ID,Sy as CLINE_DEFAULT_RPC_ADDRESS,xy as CLINE_DEFAULT_RPC_PORT,ai as CLINE_ENVIRONMENTS,By as CLINE_ENVIRONMENT_ENV,Uy as CLINE_ENVIRONMENT_OVERRIDE_ENV,by as CLINE_HUB_DEV_PORT,yy as CLINE_HUB_PORT,Vy as CLINE_RUN_AS_HUB_DAEMON_ENV,qb as CLINE_WORKSPACES_DIRECTORY_NAME,Yv as CONFIGURABLE_MODEL_TOOL_NAMES,al as CONNECTOR_CATALOG,ll as CONNECTOR_PLATFORMS,hb as CORE_SPAWN_REASONS,Sv as CURRENT_HUB_PROTOCOL_VERSION,wd as ClineModelSchema,Pd as ClineSettingsSchema,Uf as ConnectorAuthorizationDecisionSchema,Bf as ConnectorAuthorizationRequestSchema,il as ConnectorEventActorSchema,sl as ConnectorEventContextSchema,rl as ConnectorHookEventNameSchema,Zf as ConnectorHookEventSchema,hr as ContributionRegistry,Zy as DEFAULT_CLINE_ENVIRONMENT,xr as DEFAULT_MAX_IMAGE_BASE64_BYTES,Se as DEFAULT_MAX_IMAGE_DECODED_BYTES,fe as DEFAULT_MAX_IMAGE_ENCODED_BYTES,wl as DEFAULT_MAX_TOTAL_MEDIA_BYTES,oT as DEFAULT_MCP_TIMEOUT_SECONDS,Wb as DEFAULT_OUTCOME_REQUIRED_SECTIONS,jg as DEFAULT_REASONING_EFFORT,op as DEFAULT_RUNTIME_CONFIG_EXTENSIONS,Mt as EMPTY_CONTENT_TEXT,Zd as EnterpriseTelemetrySchema,og as FEATURE_FLAGS,Ke as FeatureFlag,ng as FeatureFlagDefaultValue,El as GeneratedMediaModalitySchema,Il as GeneratedMediaSchema,Rl as GeneratedMediaSourceSchema,ii as GlobalInstructionsFileSchema,Tv as HUB_CAPABILITIES,$v as HUB_CHECKPOINT_CAPABILITY,kv as HUB_CLIENT_TOOL_APPROVAL_CAPABILITY,Iv as HUB_COMMAND_SLOW_LOG_MS,Nv as HUB_COMPACTION_CAPABILITY,Ov as HUB_CUSTOM_TOOL_CAPABILITY_PREFIX,fg as HUB_DEFAULT_COMMAND_TIMEOUT_MS,zv as HUB_HOOK_CAPABILITY_PREFIX,Lv as HUB_MISTAKE_LIMIT_CAPABILITY,bl as HUB_SCHEDULE_MODES,Mv as HUB_TOOL_EXECUTOR_CAPABILITY_PREFIX,hg as HUB_TOOL_EXECUTOR_NAMES,Dv as HUB_USER_INSTRUCTIONS_SNAPSHOT_CAPABILITY,hl as HookEventNameSchema,yl as HookEventPayloadSchema,We as IMAGE_OMITTED_PLACEHOLDER,Je as IMAGE_UNSUPPORTED_PLACEHOLDER,Jd as LOOPBACK_NO_PROXY_HOSTS,zd as LiteLLMModelSchema,Nd as LiteLLMSchema,vv as MAX_CLIENT_HUB_PROTOCOL_VERSION,iT as MAX_MCP_TIMEOUT_SECONDS,_v as MIN_CLIENT_HUB_PROTOCOL_VERSION,rT as MIN_MCP_TIMEOUT_SECONDS,Jv as MODEL_TOOL_NAMES,rd as MODE_TAG_INSTRUCTIONS,Wu as ModelCapabilitySchema,bn as ModelInfoSchema,Qu as ModelMetadataSchema,el as ModelModalitiesSchema,pr as ModelModalitySchema,ol as ModelOperationModeSchema,nl as ModelOperationSchema,Yu as ModelPricingSchema,dr as ModelReasoningOptionSchema,Ju as ModelStatusSchema,ab as NO_DEFAULT_CURRENT_DIRECTORY_IN_EXE_PATH_ENV,Ev as ONE_TIME_SCHEDULE_CRON_PATTERN,Rv as ONE_TIME_SCHEDULE_RUN_AT_METADATA_KEY,fi as OTLP_TRACE_RELAY_MARKER,kd as OpenAiCompatibleModelSchema,Ed as OpenAiCompatibleSchema,sd as PLAN_MODE_INSTRUCTIONS,ad as PLAN_MODE_INSTRUCTIONS_MANUAL_SWITCH,tg as PLUGIN_FILE_EXTENSIONS,Ud as PromptUploadingSchema,_y as ProviderCapabilitySchema,Ty as ProviderClientSchema,vy as ProviderProtocolSchema,zt as REASONING_EFFORT_RATIOS,hn as REASONING_LEVELS,md as REMOTE_CONFIG_SESSION_BLOB_UPLOAD_METADATA_KEY,oy as REMOTE_URI_SCHEME,gi as RUNTIME_CONFIG_EXTENSION_KINDS,yn as ReasoningEffortSchema,lr as ReasoningLevelSchema,gy as RemoteConfigSchema,Bd as RemoteMCPServerSchema,wn as S3AccessKeySettingsSchema,yb as SDK_ERROR_TELEMETRY_EVENT,Tl as SESSION_SEARCH_PREVIEW_MAX_LENGTH,vl as SESSION_SEARCH_TITLE_MAX_LENGTH,Ub as SESSION_STATUS_VALUES,_n as SUPPORTED_IMAGE_MEDIA_TYPES,fb as TASK_CANCELLED_EVENT,pb as TASK_FIRST_CHUNK_RECEIVED_EVENT,gb as TASK_MAX_TOKENS_RECOVERY_EVENT,lb as TASK_PROVIDER_REQUEST_STARTED_EVENT,mb as TASK_PROVIDER_STREAM_FAILED_EVENT,db as TASK_PROVIDER_STREAM_STARTED_EVENT,KC as TEAM_AWAIT_TIMEOUT_MS,ky as TEAM_LIFECYCLE_EVENT_TYPE,Cy as TEAM_PROGRESS_EVENT_TYPE,WC as TEAM_RUN_MESSAGE_PREVIEW_LIMIT,JC as TEAM_RUN_TEXT_PREVIEW_LIMIT,tk as TEAM_TASK_IGNORED_FIELDS_BY_ACTION,$f as TOOL_REJECTION_SUFFIX,mk as TeamAttachOutcomeFragmentInputSchema,sk as TeamAwaitRunsInputSchema,ck as TeamBroadcastInputSchema,Rk as TeamBroadcastToolResultSchema,ik as TeamCancelRunInputSchema,kk as TeamCancelRunToolResultSchema,dk as TeamCleanupInputSchema,Ik as TeamCleanupToolResultSchema,pk as TeamCreateOutcomeInputSchema,Tk as TeamCreateOutcomeToolResultSchema,gk as TeamFinalizeOutcomeInputSchema,Pk as TeamFinalizeOutcomeToolResultSchema,hk as TeamListOutcomesInputSchema,rk as TeamListRunsInputSchema,_k as TeamMailboxMessageToolResultSchema,ex as TeamMessageType,lk as TeamMissionLogInputSchema,Ak as TeamMissionLogToolResultSchema,wk as TeamOutcomeFragmentToolResultSchema,vk as TeamOutcomeToolResultSchema,uk as TeamReadMailboxInputSchema,fk as TeamReviewOutcomeFragmentInputSchema,Qb as TeamRunResultSummarySchema,ok as TeamRunTaskInputSchema,xk as TeamRunTaskToolResultSchema,Sk as TeamRunToolSummarySchema,ak as TeamSendMessageInputSchema,Ek as TeamSendMessageToolResultSchema,QC as TeamShutdownTeammateInputSchema,Ck as TeamSimpleAgentStatusToolResultSchema,XC as TeamSpawnTeammateInputSchema,ek as TeamStatusInputSchema,yk as TeamStatusToolResultSchema,nk as TeamTaskInputSchema,Xb as TeamTaskListItemToolResultSchema,bk as TeamTaskToolResultSchema,YC as TeamTeammateSpecSchema,Xu as ThinkingConfigSchema,fr as ToolCallRecordSchema,Gv as USAGE_COST_DISPLAYS,Nf as USER_REJECTED_TOOL_REASON,Md as VertexModelSchema,Od as VertexSettingsSchema,jb as WorkspaceInfoSchema,Vb as WorkspaceManifestSchema,Ny as augmentNodeCommandForDebug,Lh as buildClineSystemPrompt,Ff as buildConnectorConnectArgs,Gh as buildRemoteConfigSessionBlobUploadMetadata,Yd as buildSdkErrorProperties,_b as captureAgentUnexpectedReasoningTokens,Tb as captureSdkError,vb as captureTaskLifecycleEvent,Wy as claimHubDaemonProcess,Xy as claimSupervisedConnectorProcess,Xg as clampMcpTimeoutSeconds,ly as clearMaterializedRemoteConfigRuntime,Wh as clearRemoteConfigSessionBlobUpload,Vf as connectorChannelsFromPlatforms,Mb as createClineTelemetryServiceConfig,Qd as createClineTelemetryServiceMetadata,eg as createContributionRegistry,vn as createMediaBudgetState,Tg as createModeSwitchNoticeTracker,ny as createRemoteConfigSessionMessagesArtifactUploader,Bb as createSessionId,nx as createTool,fh as decodeJwtPayload,Bv as describeOutdatedHubSessions,cb as disableCurrentDirectoryExecutableSearch,Wf as disposeAll,HC as emptyWorkspaceManifest,sb as ensureLoopbackProxyBypass,Wg as estimateRequestInputTokens,Zl as estimateTokens,br as formatDisplayUserInput,yr as formatFileContentBlock,Mh as formatHumanReadableDate,aT as formatMcpTimeoutErrorMessage,Fg as formatMessagesForAiSdk,vg as formatModeSwitchNotice,Ag as formatSessionSearchPreview,Rg as formatSessionSearchTitle,Oh as formatUptime,xg as formatUserCommandBlock,bg as formatUserInputBlock,wg as generatedMediaModalityFromMediaType,Dy as getClineClientIdentity,jy as getClineEnvironmentConfig,gg as getDefaultHubCommandTimeoutMs,bh as getDefaultShell,eh as getErrorCode,Qg as getErrorMessage,ot as getPowerShellEdition,Eh as getShellArgs,Ql as getShellInvocation,Hr as getShellKind,Hb as hasRuntimeConfigExtension,Sr as imageBase64DecodedByteLength,Pg as imageBase64EncodedByteLength,_r as imageBase64LengthForDecodedBytes,Mg as imageFileMaxDecodedBytesForBase64Limit,Ex as initVcr,Pl as isBase64Char,$y as isBunEmbeddedModulePath,Og as isCanonicalBase64,wf as isChatCompatibleModel,Kb as isChatWorkspacePath,Vr as isClineProvider,Ig as isGeneratedMedia,Jy as isHubDaemonProcess,Cv as isHubProtocolCompatible,mg as isHubScheduleMode,Pv as isHubToolExecutorName,ox as isLikelyAuthError,Yg as isMcpTimeoutConfigured,wb as isOtlpTraceRelayProvider,rp as isRuntimeConfigExtensionKind,Qy as isSupervisedConnectorProcess,If as isTranscriptionModel,cl as listConnectorCatalog,Ib as markOtlpTraceRelayProvider,wh as maskSecret,jf as mergeConnectorConnectArgs,Hg as mergeModelOptions,mr as modelHasCapability,Pf as modelProducesImages,zf as modelSupportsImageInput,Of as modelSupportsToolCalling,Jg as noopBasicLogger,Fr as normalizeJsonLikeStringsForSchema,gl as normalizePluginManifest,mi as normalizeSdkError,Sl as normalizeUserInput,gh as omitUndefinedValues,pg as parseHookEventPayload,ch as parseJsonStream,Fb as parseRuntimeConfigExtensions,xl as parseUserCommandEnvelope,_g as parseUserInputMode,my as prepareRemoteConfigRuntime,$h as processWorkspaceInfo,nb as readConnectorCliLaunchSpec,Av as readHubScheduleMode,yd as readRemoteConfigSessionBlobUploadMetadata,tb as readStartingConnectorInstance,gr as registerDisposable,Kh as registerRemoteConfigSessionBlobUpload,wt as reserveImageMediaBytes,bb as resetSdkErrorRateLimiterForTests,si as resolveClineBuildEnv,Kd as resolveClineEnvironment,Vg as resolveEffectiveReasoningEffort,Ob as resolveHookSessionContext,wv as resolveHubCommandTimeoutMs,sT as resolveMcpTimeoutSeconds,vr as resolveMediaBudget,Dh as resolveProviderLocalCli,qg as resolveReasoningBudgetFromRatio,Ul as resolveReasoningEffortRatio,zb as resolveRootSessionId,lh as safeJsonParse,uh as safeJsonStringify,Rh as sanitizeFileName,ae as sanitizeSurrogates,Gg as serializeAbortReason,Ly as setClineClientIdentity,Yy as setConnectorCliLaunchSpec,eb as setStartingConnectorInstance,ul as shouldIncludeConnectorField,_l as stripModeNotices,Ph as stripUtf8Bom,tl as supportsChatModalities,Dl as toAiSdkToolResultOutput,yh as toPosixSeparators,Ah as trimNonEmpty,Ih as truncateSplit,ed as truncateStr,jC as upsertWorkspaceInfo,Mf as usesImageGenerationOperation,zg as validateAndReserveBase64Media,Pt as validateAndReserveImageMedia,Ol as validateImageMedia,zh as validateWithZod,zy as withResolvedClineBuildEnv,kl as xmlTagsRemoval,jr as zodToJsonSchema};
188
+ Re-record the cassette if the request change is intentional.`)}function Ex(e,t){if(!ix(e))process.stderr.write(`[VCR] Cassette file not found: ${e}
189
+ `),process.exit(1);let n=JSON.parse(ax(e,"utf-8")),o=Number.parseInt(process.env.CLINE_VCR_SSE_DELAY??"100",10),r=Array(n.length).fill(!1),i=globalThis.fetch;globalThis.fetch=Object.assign(async(a,c)=>{let l=dp(a),d=pp(a,c),{path:p}=lp(l),m=yi(p);if(t&&!p.includes(t))return i(a,c);let f=n.findIndex((g,y)=>{if(r[y])return!1;let S=yi(g.path);return g.method.toUpperCase()===d&&S===m});if(f>=0){let g=n[f];if(!g)return i(a,c);await kx({recording:g,requestInput:a,requestInit:c,method:d,path:m}),r[f]=!0;let y=typeof g.response==="string"?g.response:JSON.stringify(g.response),S=new Headers;if(g.contentType)S.set("content-type",g.contentType);else if(typeof g.response==="string"&&g.response.trimStart().startsWith("data:"))S.set("content-type","text/event-stream");else if(typeof g.response==="object")S.set("content-type","application/json");let v=S.get("content-type")?.includes("text/event-stream")??!1;if(v)S.set("cache-control","no-cache"),S.set("connection","keep-alive");if(v&&typeof g.response==="string"){let k=Tx(g.response);if(k.length>1){let M=Cx(k,o);return new Response(M,{status:g.status,headers:S})}}return new Response(y,{status:g.status,headers:S})}if(!t)throw Error(`[VCR] No matching recording for ${d} ${l} (path: ${m}). ${n.length} recording(s) loaded from ${e}.`);return i(a,c)},{preconnect:(a)=>{}});let s=t?`(only paths matching "*${t}*", all other requests go through normally)`:"(all requests intercepted)";process.stderr.write(`[VCR] Playing back ${n.length} recorded HTTP interaction(s) from ${e} ${s}
190
+ `)}function Rx(e){let t=_x(e);if(!t)return;if(t.mode==="record")vx(t.cassettePath,t.filter,t.includeRequestBody);else Ex(t.cassettePath,t.filter)}export{lb as AGENT_UNEXPECTED_REASONING_TOKENS_EVENT,yy as APIKeySchema,sp as AUTH_ERROR_PATTERNS,av as AgentConfigSchema,Lf as AgentFinishReasonSchema,sv as AgentResultSchema,Df as AgentUsageSchema,Dd as AllowedMCPServerSchema,$d as AnthropicModelSchema,Ld as AnthropicSchema,Af as ApiFormat,Ku as ApiFormatSchema,Ad as AwsBedrockCustomModelSchema,Rd as AwsBedrockModelSchema,Id as AwsBedrockSettingsSchema,Kg as CHARS_PER_TOKEN,Pn as CLINE_BUILD_ENV_ENV,Kb as CLINE_CHAT_WORKSPACE_DIRECTORY_NAME,Gy as CLINE_CONNECTOR_CLI_LAUNCH_ENV,Ky as CLINE_CONNECTOR_STARTING_INSTANCE_ENV,Wy as CLINE_CONNECTOR_SUPERVISED_ENV,Fd as CLINE_DEBUG_HOST_ENV,Hd as CLINE_DEBUG_PORT_BASE_ENV,Uh as CLINE_DEFAULT_MODEL_ID,_y as CLINE_DEFAULT_RPC_ADDRESS,Sy as CLINE_DEFAULT_RPC_PORT,ai as CLINE_ENVIRONMENTS,Uy as CLINE_ENVIRONMENT_ENV,Zy as CLINE_ENVIRONMENT_OVERRIDE_ENV,xy as CLINE_HUB_DEV_PORT,by as CLINE_HUB_PORT,qy as CLINE_RUN_AS_HUB_DAEMON_ENV,Gb as CLINE_WORKSPACES_DIRECTORY_NAME,Xv as CONFIGURABLE_MODEL_TOOL_NAMES,al as CONNECTOR_CATALOG,ll as CONNECTOR_PLATFORMS,yb as CORE_SPAWN_REASONS,_v as CURRENT_HUB_PROTOCOL_VERSION,wd as ClineModelSchema,Pd as ClineSettingsSchema,Uf as ConnectorAuthorizationDecisionSchema,Bf as ConnectorAuthorizationRequestSchema,il as ConnectorEventActorSchema,sl as ConnectorEventContextSchema,rl as ConnectorHookEventNameSchema,Zf as ConnectorHookEventSchema,hr as ContributionRegistry,Fy as DEFAULT_CLINE_ENVIRONMENT,xr as DEFAULT_MAX_IMAGE_BASE64_BYTES,Se as DEFAULT_MAX_IMAGE_DECODED_BYTES,fe as DEFAULT_MAX_IMAGE_ENCODED_BYTES,wl as DEFAULT_MAX_TOTAL_MEDIA_BYTES,rT as DEFAULT_MCP_TIMEOUT_SECONDS,Jb as DEFAULT_OUTCOME_REQUIRED_SECTIONS,jg as DEFAULT_REASONING_EFFORT,op as DEFAULT_RUNTIME_CONFIG_EXTENSIONS,Mt as EMPTY_CONTENT_TEXT,Zd as EnterpriseTelemetrySchema,og as FEATURE_FLAGS,Ke as FeatureFlag,ng as FeatureFlagDefaultValue,El as GeneratedMediaModalitySchema,Il as GeneratedMediaSchema,Rl as GeneratedMediaSourceSchema,ii as GlobalInstructionsFileSchema,Cv as HUB_CAPABILITIES,Lv as HUB_CHECKPOINT_CAPABILITY,Ev as HUB_CLIENT_TOOL_APPROVAL_CAPABILITY,wv as HUB_COMMAND_SLOW_LOG_MS,$v as HUB_COMPACTION_CAPABILITY,zv as HUB_CUSTOM_TOOL_CAPABILITY_PREFIX,fg as HUB_DEFAULT_COMMAND_TIMEOUT_MS,Nv as HUB_HOOK_CAPABILITY_PREFIX,Dv as HUB_MISTAKE_LIMIT_CAPABILITY,bl as HUB_SCHEDULE_MODES,Ov as HUB_TOOL_EXECUTOR_CAPABILITY_PREFIX,hg as HUB_TOOL_EXECUTOR_NAMES,Bv as HUB_USER_INSTRUCTIONS_SNAPSHOT_CAPABILITY,hl as HookEventNameSchema,yl as HookEventPayloadSchema,We as IMAGE_OMITTED_PLACEHOLDER,Je as IMAGE_UNSUPPORTED_PLACEHOLDER,Jd as LOOPBACK_NO_PROXY_HOSTS,zd as LiteLLMModelSchema,Nd as LiteLLMSchema,Tv as MAX_CLIENT_HUB_PROTOCOL_VERSION,sT as MAX_MCP_TIMEOUT_SECONDS,vv as MIN_CLIENT_HUB_PROTOCOL_VERSION,iT as MIN_MCP_TIMEOUT_SECONDS,Yv as MODEL_TOOL_NAMES,rd as MODE_TAG_INSTRUCTIONS,Wu as ModelCapabilitySchema,bn as ModelInfoSchema,Qu as ModelMetadataSchema,el as ModelModalitiesSchema,pr as ModelModalitySchema,ol as ModelOperationModeSchema,nl as ModelOperationSchema,Yu as ModelPricingSchema,dr as ModelReasoningOptionSchema,Ju as ModelStatusSchema,cb as NO_DEFAULT_CURRENT_DIRECTORY_IN_EXE_PATH_ENV,Rv as ONE_TIME_SCHEDULE_CRON_PATTERN,Av as ONE_TIME_SCHEDULE_RUN_AT_METADATA_KEY,fi as OTLP_TRACE_RELAY_MARKER,kd as OpenAiCompatibleModelSchema,Ed as OpenAiCompatibleSchema,sd as PLAN_MODE_INSTRUCTIONS,ad as PLAN_MODE_INSTRUCTIONS_MANUAL_SWITCH,tg as PLUGIN_FILE_EXTENSIONS,Ud as PromptUploadingSchema,vy as ProviderCapabilitySchema,Cy as ProviderClientSchema,Ty as ProviderProtocolSchema,zt as REASONING_EFFORT_RATIOS,hn as REASONING_LEVELS,md as REMOTE_CONFIG_SESSION_BLOB_UPLOAD_METADATA_KEY,ry as REMOTE_URI_SCHEME,gi as RUNTIME_CONFIG_EXTENSION_KINDS,yn as ReasoningEffortSchema,lr as ReasoningLevelSchema,hy as RemoteConfigSchema,Bd as RemoteMCPServerSchema,wn as S3AccessKeySettingsSchema,bb as SDK_ERROR_TELEMETRY_EVENT,Tl as SESSION_SEARCH_PREVIEW_MAX_LENGTH,vl as SESSION_SEARCH_TITLE_MAX_LENGTH,Zb as SESSION_STATUS_VALUES,_n as SUPPORTED_IMAGE_MEDIA_TYPES,gb as TASK_CANCELLED_EVENT,mb as TASK_FIRST_CHUNK_RECEIVED_EVENT,hb as TASK_MAX_TOKENS_RECOVERY_EVENT,db as TASK_PROVIDER_REQUEST_STARTED_EVENT,fb as TASK_PROVIDER_STREAM_FAILED_EVENT,pb as TASK_PROVIDER_STREAM_STARTED_EVENT,WC as TEAM_AWAIT_TIMEOUT_MS,Ey as TEAM_LIFECYCLE_EVENT_TYPE,ky as TEAM_PROGRESS_EVENT_TYPE,JC as TEAM_RUN_MESSAGE_PREVIEW_LIMIT,YC as TEAM_RUN_TEXT_PREVIEW_LIMIT,nk as TEAM_TASK_IGNORED_FIELDS_BY_ACTION,$f as TOOL_REJECTION_SUFFIX,fk as TeamAttachOutcomeFragmentInputSchema,ak as TeamAwaitRunsInputSchema,uk as TeamBroadcastInputSchema,Ak as TeamBroadcastToolResultSchema,sk as TeamCancelRunInputSchema,Ek as TeamCancelRunToolResultSchema,pk as TeamCleanupInputSchema,wk as TeamCleanupToolResultSchema,mk as TeamCreateOutcomeInputSchema,Ck as TeamCreateOutcomeToolResultSchema,hk as TeamFinalizeOutcomeInputSchema,Mk as TeamFinalizeOutcomeToolResultSchema,yk as TeamListOutcomesInputSchema,ik as TeamListRunsInputSchema,vk as TeamMailboxMessageToolResultSchema,tx as TeamMessageType,dk as TeamMissionLogInputSchema,Ik as TeamMissionLogToolResultSchema,Pk as TeamOutcomeFragmentToolResultSchema,Tk as TeamOutcomeToolResultSchema,lk as TeamReadMailboxInputSchema,gk as TeamReviewOutcomeFragmentInputSchema,ex as TeamRunResultSummarySchema,rk as TeamRunTaskInputSchema,Sk as TeamRunTaskToolResultSchema,_k as TeamRunToolSummarySchema,ck as TeamSendMessageInputSchema,Rk as TeamSendMessageToolResultSchema,ek as TeamShutdownTeammateInputSchema,kk as TeamSimpleAgentStatusToolResultSchema,QC as TeamSpawnTeammateInputSchema,tk as TeamStatusInputSchema,bk as TeamStatusToolResultSchema,ok as TeamTaskInputSchema,Qb as TeamTaskListItemToolResultSchema,xk as TeamTaskToolResultSchema,XC as TeamTeammateSpecSchema,Xu as ThinkingConfigSchema,fr as ToolCallRecordSchema,Kv as USAGE_COST_DISPLAYS,Nf as USER_REJECTED_TOOL_REASON,Md as VertexModelSchema,Od as VertexSettingsSchema,Vb as WorkspaceInfoSchema,qb as WorkspaceManifestSchema,$y as augmentNodeCommandForDebug,Lh as buildClineSystemPrompt,Ff as buildConnectorConnectArgs,Kh as buildRemoteConfigSessionBlobUploadMetadata,Yd as buildSdkErrorProperties,vb as captureAgentUnexpectedReasoningTokens,Cb as captureSdkError,Tb as captureTaskLifecycleEvent,Jy as claimHubDaemonProcess,Qy as claimSupervisedConnectorProcess,Xg as clampMcpTimeoutSeconds,dy as clearMaterializedRemoteConfigRuntime,Jh as clearRemoteConfigSessionBlobUpload,Vf as connectorChannelsFromPlatforms,Ob as createClineTelemetryServiceConfig,Qd as createClineTelemetryServiceMetadata,eg as createContributionRegistry,vn as createMediaBudgetState,Tg as createModeSwitchNoticeTracker,oy as createRemoteConfigSessionMessagesArtifactUploader,Ub as createSessionId,ox as createTool,fh as decodeJwtPayload,Uv as describeOutdatedHubSessions,ub as disableCurrentDirectoryExecutableSearch,Wf as disposeAll,jC as emptyWorkspaceManifest,ab as ensureLoopbackProxyBypass,Wg as estimateRequestInputTokens,Zl as estimateTokens,br as formatDisplayUserInput,yr as formatFileContentBlock,Mh as formatHumanReadableDate,cT as formatMcpTimeoutErrorMessage,Fg as formatMessagesForAiSdk,vg as formatModeSwitchNotice,Ag as formatSessionSearchPreview,Rg as formatSessionSearchTitle,Oh as formatUptime,xg as formatUserCommandBlock,bg as formatUserInputBlock,wg as generatedMediaModalityFromMediaType,By as getClineClientIdentity,Vy as getClineEnvironmentConfig,gg as getDefaultHubCommandTimeoutMs,bh as getDefaultShell,eh as getErrorCode,Qg as getErrorMessage,ot as getPowerShellEdition,Eh as getShellArgs,Ql as getShellInvocation,Hr as getShellKind,jb as hasRuntimeConfigExtension,Sr as imageBase64DecodedByteLength,Pg as imageBase64EncodedByteLength,_r as imageBase64LengthForDecodedBytes,Mg as imageFileMaxDecodedBytesForBase64Limit,Rx as initVcr,Pl as isBase64Char,Ly as isBunEmbeddedModulePath,Og as isCanonicalBase64,wf as isChatCompatibleModel,Wb as isChatWorkspacePath,Vr as isClineProvider,Ig as isGeneratedMedia,Yy as isHubDaemonProcess,kv as isHubProtocolCompatible,mg as isHubScheduleMode,Mv as isHubToolExecutorName,rx as isLikelyAuthError,Yg as isMcpTimeoutConfigured,Pb as isOtlpTraceRelayProvider,rp as isRuntimeConfigExtensionKind,eb as isSupervisedConnectorProcess,If as isTranscriptionModel,cl as listConnectorCatalog,wb as markOtlpTraceRelayProvider,wh as maskSecret,jf as mergeConnectorConnectArgs,Hg as mergeModelOptions,mr as modelHasCapability,Pf as modelProducesImages,zf as modelSupportsImageInput,Of as modelSupportsToolCalling,Jg as noopBasicLogger,Fr as normalizeJsonLikeStringsForSchema,gl as normalizePluginManifest,mi as normalizeSdkError,Sl as normalizeUserInput,gh as omitUndefinedValues,pg as parseHookEventPayload,ch as parseJsonStream,Hb as parseRuntimeConfigExtensions,xl as parseUserCommandEnvelope,_g as parseUserInputMode,fy as prepareRemoteConfigRuntime,$h as processWorkspaceInfo,ob as readConnectorCliLaunchSpec,Iv as readHubScheduleMode,yd as readRemoteConfigSessionBlobUploadMetadata,nb as readStartingConnectorInstance,gr as registerDisposable,Wh as registerRemoteConfigSessionBlobUpload,wt as reserveImageMediaBytes,xb as resetSdkErrorRateLimiterForTests,si as resolveClineBuildEnv,Kd as resolveClineEnvironment,Vg as resolveEffectiveReasoningEffort,zb as resolveHookSessionContext,Pv as resolveHubCommandTimeoutMs,aT as resolveMcpTimeoutSeconds,vr as resolveMediaBudget,Dh as resolveProviderApiKeyOptional,Bh as resolveProviderLocalCli,qg as resolveReasoningBudgetFromRatio,Ul as resolveReasoningEffortRatio,Nb as resolveRootSessionId,lh as safeJsonParse,uh as safeJsonStringify,Rh as sanitizeFileName,ae as sanitizeSurrogates,Gg as serializeAbortReason,Dy as setClineClientIdentity,Xy as setConnectorCliLaunchSpec,tb as setStartingConnectorInstance,ul as shouldIncludeConnectorField,_l as stripModeNotices,Ph as stripUtf8Bom,tl as supportsChatModalities,Dl as toAiSdkToolResultOutput,yh as toPosixSeparators,Ah as trimNonEmpty,Ih as truncateSplit,ed as truncateStr,VC as upsertWorkspaceInfo,Mf as usesImageGenerationOperation,zg as validateAndReserveBase64Media,Pt as validateAndReserveImageMedia,Ol as validateImageMedia,zh as validateWithZod,Ny as withResolvedClineBuildEnv,kl as xmlTagsRemoval,jr as zodToJsonSchema};