@cline/shared 0.0.92-nightly.1791773200 → 0.0.93

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.
@@ -6,11 +6,34 @@
6
6
  */
7
7
  export declare const CHARS_PER_TOKEN = 3;
8
8
  export declare function estimateTokens(chars: number): number;
9
+ /**
10
+ * Flat per-image token cost used in place of the char-based estimate for an
11
+ * image block's base64 payload. Real vision-model costs depend on pixel
12
+ * dimensions, not encoded byte size, and top out around ~1.6k tokens even
13
+ * for a large image; this sits comfortably above typical per-image cost
14
+ * without scaling with the base64 string length.
15
+ */
16
+ export declare const ESTIMATED_TOKENS_PER_IMAGE = 1600;
9
17
  export interface TokenEstimatedRequest {
10
18
  systemPrompt?: string;
11
19
  messages: readonly unknown[];
12
20
  tools?: readonly unknown[];
13
21
  }
22
+ /**
23
+ * Build a JSON.stringify replacer that blanks an image node's base64
24
+ * payload wherever it's nested in the serialized value, so it's never
25
+ * billed at CHARS_PER_TOKEN. Two image shapes reach this replacer:
26
+ * `ImageContent { type: "image", data: string }` (compaction's
27
+ * `MessageWithMetadata`) and `AgentImagePart { type: "image", image:
28
+ * string | Uint8Array | ArrayBuffer | URL }` (the gateway's
29
+ * `AgentMessage`). Returns the replacer alongside an `imageCount`
30
+ * accessor so the caller can add a flat per-image token cost back in
31
+ * afterwards.
32
+ */
33
+ export declare function createImageAwareReplacer(): {
34
+ replacer: (key: string, value: unknown) => unknown;
35
+ imageCount: () => number;
36
+ };
14
37
  /**
15
38
  * Estimate the complete provider request payload so request execution and
16
39
  * pre-request policies use the same definition of input utilization.
@@ -14,7 +14,7 @@ ${n}${t.contents.trim()}`}).join(`
14
14
  `).filter((i)=>i),n=Math.min(...r.map((i)=>i.length-i.trimStart().length)),o=r.map((i)=>i.slice(n)).map((i)=>" ".repeat(this.indent*2)+i);for(let i of o)this.content.push(i)}compile(){let e=Function,t=this?.content??[""];return new e(...Object.keys(this.closed),`return function (${this.args.join(", ")}) {
15
15
  ${t.join(`
16
16
  `)}
17
- };`)(...Object.values(this.closed))}}var Lo={major:4,minor:6,patch:6};var z=p("$ZodType",(e,t)=>{var r;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=Lo;let n=e._zod.def.checks,o=e._zod.traits.has("$ZodCheck")?[e,...n??[]]:n?.length?[...n]:[];for(let i of o)for(let s of i._zod.onattach)s(e);if(o.length===0)(r=e._zod).deferred??(r.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{let i=(c,a,u)=>{if(c.memo)return c;let l=J(c),f;for(let m of a){if(m._zod.def.when){if(In(c))continue;if(!m._zod.def.when(c))continue}else if(l)continue;let d=c.issues.length,h=m._zod.check(c);if(h instanceof Promise&&u?.async===!1)throw new Q;if(f||h instanceof Promise)f=(f??Promise.resolve()).then(async()=>{if(await h,c.issues.length===d)return;if(Ve(c.issues,d,e),!l)l=J(c,d)});else{if(c.issues.length===d)continue;if(Ve(c.issues,d,e),!l)l=J(c,d)}}if(f)return f.then(()=>c);return c},s=(c,a,u)=>{if(J(c))return c.aborted=!0,c;let l=i(a,o,u);if(l instanceof Promise){if(u.async===!1)throw new Q;return l.then((f)=>e._zod.parse(f,u))}return e._zod.parse(l,u)};e._zod.run=(c,a)=>{if(a.skipChecks)return e._zod.parse(c,a);if(a.direction==="backward"){let l=e._zod.parse({value:c.value,issues:[]},{...a,skipChecks:!0});if(l instanceof Promise)return l.then((f)=>s(f,c,a));return s(l,c,a)}let u=e._zod.parse(c,a);if(u instanceof Promise){if(a.async===!1)throw new Q;return u.then((l)=>i(l,o,a))}return i(u,o,a)}}},{get "~standard"(){return Ge(this,"~standard",tr(this))},set "~standard"(e){te(this,"~standard",e)}}),ei=(e,t)=>e.issues.length?{issues:e.issues.map((r)=>Y(r,t,F()))}:{value:e.value};async function Va(e,t){let r={async:!0};return ei(await e._zod.run({value:t,issues:[]},r),r)}function tr(e){return{validate:(t)=>{let r={async:!1};try{let n=e._zod.run({value:t,issues:[]},r);if(!(n instanceof Promise))return ei(n,r)}catch(n){}return Va(e,t)},vendor:"zod",version:1}}var nt=p("$ZodString",(e,t)=>{z.init(e,t),e._zod.pattern=t.pattern??wo,e._zod.parse=(r,n)=>{if(t.coerce)try{r.value=String(r.value)}catch(o){}if(typeof r.value==="string")return r;return r.issues.push({expected:"string",code:"invalid_type",input:r.value,inst:e}),r}}),P=p("$ZodStringFormat",(e,t)=>{Ze.init(e,t),nt.init(e,t)}),ti=p("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=co),P.init(e,t)}),ri=p("$ZodUUID",(e,t)=>{if(t.version){let n={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(n===void 0)throw Error(`Invalid UUID version: "${t.version}"`);t.pattern??(t.pattern=Wt(n))}else t.pattern??(t.pattern=Wt());P.init(e,t)}),ni=p("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=ao),P.init(e,t)}),oi=1,tt=2;function ii(e){try{if(typeof URL<"u"&&typeof URL.canParse==="function")return URL.canParse(e);return new URL(e),!0}catch{return!1}}function Ha(e,t){if(!("normalize"in t)&&!("hostname"in t)&&!("protocol"in t))return ii(e)||tt;return Wa(e,t)}function Wa(e,t){if(!t.normalize&&t.protocol?.source===yo.source&&!/^https?:\/\//i.test(e))return oi;try{if(typeof URL<"u"){let r=URL;if(typeof r.parse==="function")return r.parse(e)??tt}return new URL(e)}catch{return tt}}var Ga=/[\t\n\r]/g;function Bo(e){return e.replace(Ga,"")}function Xa(e,t){return t.lastIndex=0,t.test(e.hostname)}function qa(e,t){return t.lastIndex=0,t.test(e.protocol.endsWith(":")?e.protocol.slice(0,-1):e.protocol)}var si=p("$ZodURL",(e,t)=>{P.init(e,t),e._zod.check=(r)=>{try{let n=r.value.trim(),o=Ha(n,t);if(o===oi){r.issues.push({code:"invalid_format",format:"url",note:"Invalid URL format",input:r.value,inst:e,continue:!t.abort});return}if(o===tt){r.issues.push({code:"invalid_format",format:"url",input:r.value,inst:e,continue:!t.abort});return}if(o===!0){r.value=Bo(n);return}if(t.hostname&&!Xa(o,t.hostname))r.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:t.hostname.source,input:r.value,inst:e,continue:!t.abort});if(t.protocol&&!qa(o,t.protocol))r.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:t.protocol.source,input:r.value,inst:e,continue:!t.abort});r.value=t.normalize?o.href:Bo(n);return}catch(n){r.issues.push({code:"invalid_format",format:"url",input:r.value,inst:e,continue:!t.abort})}}}),ci=p("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=uo()),P.init(e,t)}),ai=p("$ZodNanoID",(e,t)=>{if(t.length!==void 0&&(!Number.isInteger(t.length)||t.length<1))throw Error(`Invalid nanoid length: ${t.length}`);t.pattern??(t.pattern=t.length===void 0?oo:io(t.length)),P.init(e,t)}),ui=p("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=Qn),P.init(e,t)}),li=p("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=eo),P.init(e,t)}),pi=p("$ZodULID",(e,t)=>{t.pattern??(t.pattern=to),P.init(e,t)}),fi=p("$ZodXID",(e,t)=>{t.pattern??(t.pattern=ro),P.init(e,t)}),di=p("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=no),P.init(e,t)}),mi=p("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=zo(t)),P.init(e,t)}),hi=p("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=bo),P.init(e,t)}),gi=p("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=vo(t)),P.init(e,t)}),yi=p("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=so),P.init(e,t)}),_i=p("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=lo),P.init(e,t)}),Ya=/^[0-9a-fA-F:.]+$/;function xi(e){if(!Ya.test(e))return!1;return ii(`http://[${e}]`)}var bi=p("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=po),P.init(e,t),e._zod.check=(r)=>{if(!xi(r.value))r.issues.push({code:"invalid_format",format:"ipv6",input:r.value,inst:e,continue:!t.abort})}});var vi=p("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=fo),P.init(e,t)});function Qa(e){let t=e.split("/");if(t.length!==2)return!1;let[r,n]=t;if(!n)return!1;let o=Number(n);if(`${o}`!==n)return!1;if(o<0||o>128)return!1;return xi(r)}var zi=p("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=mo),P.init(e,t),e._zod.check=(r)=>{if(!Qa(r.value))r.issues.push({code:"invalid_format",format:"cidrv6",input:r.value,inst:e,continue:!t.abort})}});function wi(e){if(e==="")return!0;if(/\s/.test(e))return!1;if(e.length%4!==0)return!1;try{return atob(e),!0}catch{return!1}}var rr=/^[0-9a-zA-Z+/]*={0,2}$/,$i=p("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=rr),P.init(e,t),e._zod.check=(r)=>{if(wi(r.value))return;r.issues.push({code:"invalid_format",format:"base64",input:r.value,inst:e,continue:!t.abort})}}),ot=/^[A-Za-z0-9_-]*$/;function eu(e){if(!ot.test(e))return!1;let t=e.replace(/[-_]/g,(n)=>n==="-"?"+":"/"),r=t.padEnd(Math.ceil(t.length/4)*4,"=");return wi(r)}var Si=p("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=ot),P.init(e,t),e._zod.check=(r)=>{if(eu(r.value))return;r.issues.push({code:"invalid_format",format:"base64url",input:r.value,inst:e,continue:!t.abort})}}),ki=p("$ZodE164",(e,t)=>{t.pattern??(t.pattern=_o),P.init(e,t)});function tu(e,t=null){try{let r=e.split(".");if(r.length!==3)return!1;let[n]=r;if(!n)return!1;let o=JSON.parse(atob(n));if("typ"in o&&o?.typ!=="JWT")return!1;if(!o.alg)return!1;if(t&&(!("alg"in o)||o.alg!==t))return!1;return!0}catch{return!1}}var Pi=p("$ZodJWT",(e,t)=>{P.init(e,t),e._zod.check=(r)=>{if(tu(r.value,t.alg))return;r.issues.push({code:"invalid_format",format:"jwt",input:r.value,inst:e,continue:!t.abort})}});var nr=p("$ZodNumber",(e,t)=>{z.init(e,t),e._zod.pattern=Pe,e._zod.parse=(r,n)=>{if(t.coerce)try{r.value=Number(r.value)}catch(s){}let o=r.value;if(typeof o==="number"&&!Number.isNaN(o)&&Number.isFinite(o))return r;let i=typeof o==="number"?Number.isNaN(o)?"NaN":!Number.isFinite(o)?String(o):void 0:void 0;return r.issues.push({expected:"number",code:"invalid_type",input:o,inst:e,...i?{received:i}:{}}),r}}),Ci=p("$ZodNumberFormat",(e,t)=>{Co.init(e,t),nr.init(e,t)}),Zi=p("$ZodBoolean",(e,t)=>{z.init(e,t),e._zod.pattern=$o,e._zod.parse=(r,n)=>{if(t.coerce)try{r.value=Boolean(r.value)}catch(i){}let o=r.value;if(typeof o==="boolean")return r;return r.issues.push({expected:"boolean",code:"invalid_type",input:o,inst:e}),r}});var Ri=p("$ZodUnknown",(e,t)=>{z.init(e,t),e._zod.parse=(r)=>r}),Ai=p("$ZodNever",(e,t)=>{z.init(e,t),e._zod.parse=(r,n)=>(r.issues.push({expected:"never",code:"invalid_type",input:r.value,inst:e}),r)}),Oi=p("$ZodVoid",(e,t)=>{z.init(e,t),e._zod.parse=(r,n)=>{let o=r.value;if(typeof o>"u")return r;return r.issues.push({expected:"void",code:"invalid_type",input:o,inst:e}),r}}),Ii=p("$ZodDate",(e,t)=>{z.init(e,t),e._zod.parse=(r,n)=>{if(t.coerce)try{r.value=new Date(r.value)}catch(c){}let o=r.value,i=o instanceof Date;if(i&&!Number.isNaN(o.getTime()))return r;return r.issues.push({expected:"date",code:"invalid_type",input:o,...i?{received:"Invalid Date"}:{},inst:e}),r}});function ru(e,t){let r=Nt(e._zod.def.checks);if(!r.length)return;let n=Math.min(...r.map((i)=>i[0])),o=e._zod.parse;e._zod.parse=(i,s)=>{let c=t(i.value);if(c>n&&!s?.skipChecks&&s?.direction!=="backward"){for(let[a,u]of Nt(e._zod.def.checks))if(c>a&&u._zod.def.when(i)){let l=i.issues.length;return u._zod.check(i),i.issues[l].continue=!1,Ve(i.issues,l,e),i}}return o(i,s)}}var nu=(e)=>Array.isArray(e)?e.length:-1;function Fo(e,t,r){if(e.issues.length)t.issues.push(...q(r,e.issues));t.value[r]=e.value}var Ti=p("$ZodArray",(e,t)=>{z.init(e,t);let r=N.memoizer;r?.attach(e),e._zod.parse=(n,o)=>{let i=n.value;if(!Array.isArray(i))return n.issues.push({expected:"array",code:"invalid_type",input:i,inst:e}),n;n.value=r?r.alloc(e,n,Array(i.length),o):Array(i.length);let s=[],c=o?.abortEarly;for(let a=0;a<i.length;a++){let u=i[a],l=t.element._zod.run({value:u,issues:[]},o);if(l instanceof Promise)s.push(l.then((f)=>Fo(f,n,a)));else if(Fo(l,n,a),c&&l.issues.length!==0&&J(l))break}if(s.length)return Promise.all(s).then(()=>n);return n},ru(e,nu)});function rt(e,t,r,n,o,i){let s=r in n,c=i==="optional";if(!s&&c&&o==="optional")return;if(e.issues.length){if(o!==void 0&&c&&!s)return;t.issues.push(...q(r,e.issues))}if(!s&&o===void 0){if(!e.issues.length)t.issues.push({code:"invalid_type",expected:"nonoptional",input:void 0,path:[r]});return}if(e.value===void 0){if(s||o==="defaulted"&&!c)t.value[r]=void 0}else t.value[r]=e.value}var ou=[];function Ei(e){let t=Object.keys(e.shape),r=Object.getOwnPropertySymbols(e.shape),n=r.length?r:ou,o=n.length?[...t,...n]:t;for(let s of o)if(!e.shape?.[s]?._zod?.traits?.has("$ZodType"))throw Error(`Invalid element at key "${String(s)}": expected a Zod schema`);let i=Rn(e.shape);return{...e,allKeys:o,symbolKeys:n,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(i)}}function Mi(e,t,r,n,o,i,s){let c=[],a=o.keySet,u=o.catchall._zod,l=u.def.type,{optin:f,optout:m}=u,d=0;for(let h in t){if(s&&r.issues.length!==d){if(J(r,d))break;d=r.issues.length}if(a.has(h))continue;if(h==="__proto__"){if(l==="never")c.push(h);continue}if(l==="never"){c.push(h);continue}let y=u.run({value:t[h],issues:[]},n);if(y instanceof Promise)e.push(y.then((_)=>rt(_,r,h,t,f,m)));else rt(y,r,h,t,f,m)}if(c.length)r.issues.push({code:"unrecognized_keys",keys:c,input:t,inst:i,continue:!0});if(!e.length)return r;return Promise.all(e).then(()=>r)}var iu=p("$ZodObject",(e,t)=>{z.init(e,t);let r=Object.getOwnPropertyDescriptor(t,"shape"),n=r?.get?r.get.raw:t.shape??{};if(n){let u=()=>{let l={...n};return Object.defineProperty(t,"shape",{value:l}),u.raw=l,l};u.raw=n,Object.defineProperty(t,"shape",{get:u})}let o=ze(()=>Ei(t));v(e,"propValues",(u)=>{let l=u.def.shape,f={};for(let m in l){let d=l[m]._zod;if(d.values){if(!Object.prototype.hasOwnProperty.call(f,m))L(f,m,new Set);for(let h of d.values)f[m].add(h);if(d.optin!==void 0)f[m].add(void 0)}}return f});let i=pe,s=t.catchall,c,a=N.memoizer;a?.attach(e),e._zod.parse=(u,l)=>{c??(c=o.value);let f=u.value;if(!i(f))return u.issues.push({expected:"object",code:"invalid_type",input:f,inst:e}),u;u.value=a?a.alloc(e,u,{},l):{};let m=[],d=c.shape,h=l?.abortEarly,y=u.issues.length;for(let _ of c.allKeys){if(h&&u.issues.length!==y){if(J(u,y))break;y=u.issues.length}if(_==="__proto__")continue;let b=d[_],I=b._zod.optin,C=b._zod.optout,H=b._zod.run({value:f[_],issues:[]},l);if(H instanceof Promise)m.push(H.then((R)=>rt(R,u,_,f,I,C)));else rt(H,u,_,f,I,C)}if(!s)return m.length?Promise.all(m).then(()=>u):u;return Mi(m,f,u,l,o.value,e,h===!0)}}),Ni=p("$ZodObjectJIT",(e,t)=>{iu.init(e,t);let r=e._zod.parse,n=ze(()=>Ei(t)),o=N.memoizer,i=(d)=>{let h=n.value,y=h.symbolKeys,_=new Qt(["payload","ctx"],{shape:d,inst:e,memo:o,syms:y}),b=(R)=>`shape[${R}]._zod.run({ value: input[${R}], issues: [] }, ctx)`,I=(R,w)=>`
17
+ };`)(...Object.values(this.closed))}}var Lo={major:4,minor:6,patch:7};var z=p("$ZodType",(e,t)=>{var r;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=Lo;let n=e._zod.def.checks,o=e._zod.traits.has("$ZodCheck")?[e,...n??[]]:n?.length?[...n]:[];for(let i of o)for(let s of i._zod.onattach)s(e);if(o.length===0)(r=e._zod).deferred??(r.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{let i=(c,a,u)=>{if(c.memo)return c;let l=J(c),f;for(let m of a){if(m._zod.def.when){if(In(c))continue;if(!m._zod.def.when(c))continue}else if(l)continue;let d=c.issues.length,h=m._zod.check(c);if(h instanceof Promise&&u?.async===!1)throw new Q;if(f||h instanceof Promise)f=(f??Promise.resolve()).then(async()=>{if(await h,c.issues.length===d)return;if(Ve(c.issues,d,e),!l)l=J(c,d)});else{if(c.issues.length===d)continue;if(Ve(c.issues,d,e),!l)l=J(c,d)}}if(f)return f.then(()=>c);return c},s=(c,a,u)=>{if(J(c))return c.aborted=!0,c;let l=i(a,o,u);if(l instanceof Promise){if(u.async===!1)throw new Q;return l.then((f)=>e._zod.parse(f,u))}return e._zod.parse(l,u)};e._zod.run=(c,a)=>{if(a.skipChecks)return e._zod.parse(c,a);if(a.direction==="backward"){let l=e._zod.parse({value:c.value,issues:[]},{...a,skipChecks:!0});if(l instanceof Promise)return l.then((f)=>s(f,c,a));return s(l,c,a)}let u=e._zod.parse(c,a);if(u instanceof Promise){if(a.async===!1)throw new Q;return u.then((l)=>i(l,o,a))}return i(u,o,a)}}},{get "~standard"(){return Ge(this,"~standard",tr(this))},set "~standard"(e){te(this,"~standard",e)}}),ei=(e,t)=>e.issues.length?{issues:e.issues.map((r)=>Y(r,t,F()))}:{value:e.value};async function Va(e,t){let r={async:!0};return ei(await e._zod.run({value:t,issues:[]},r),r)}function tr(e){return{validate:(t)=>{let r={async:!1};try{let n=e._zod.run({value:t,issues:[]},r);if(!(n instanceof Promise))return ei(n,r)}catch(n){}return Va(e,t)},vendor:"zod",version:1}}var nt=p("$ZodString",(e,t)=>{z.init(e,t),e._zod.pattern=t.pattern??wo,e._zod.parse=(r,n)=>{if(t.coerce)try{r.value=String(r.value)}catch(o){}if(typeof r.value==="string")return r;return r.issues.push({expected:"string",code:"invalid_type",input:r.value,inst:e}),r}}),P=p("$ZodStringFormat",(e,t)=>{Ze.init(e,t),nt.init(e,t)}),ti=p("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=co),P.init(e,t)}),ri=p("$ZodUUID",(e,t)=>{if(t.version){let n={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(n===void 0)throw Error(`Invalid UUID version: "${t.version}"`);t.pattern??(t.pattern=Wt(n))}else t.pattern??(t.pattern=Wt());P.init(e,t)}),ni=p("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=ao),P.init(e,t)}),oi=1,tt=2;function ii(e){try{if(typeof URL<"u"&&typeof URL.canParse==="function")return URL.canParse(e);return new URL(e),!0}catch{return!1}}function Ha(e,t){if(!("normalize"in t)&&!("hostname"in t)&&!("protocol"in t))return ii(e)||tt;return Wa(e,t)}function Wa(e,t){if(!t.normalize&&t.protocol?.source===yo.source&&!/^https?:\/\//i.test(e))return oi;try{if(typeof URL<"u"){let r=URL;if(typeof r.parse==="function")return r.parse(e)??tt}return new URL(e)}catch{return tt}}var Ga=/[\t\n\r]/g;function Bo(e){return e.replace(Ga,"")}function Xa(e,t){return t.lastIndex=0,t.test(e.hostname)}function qa(e,t){return t.lastIndex=0,t.test(e.protocol.endsWith(":")?e.protocol.slice(0,-1):e.protocol)}var si=p("$ZodURL",(e,t)=>{P.init(e,t),e._zod.check=(r)=>{try{let n=r.value.trim(),o=Ha(n,t);if(o===oi){r.issues.push({code:"invalid_format",format:"url",note:"Invalid URL format",input:r.value,inst:e,continue:!t.abort});return}if(o===tt){r.issues.push({code:"invalid_format",format:"url",input:r.value,inst:e,continue:!t.abort});return}if(o===!0){r.value=Bo(n);return}if(t.hostname&&!Xa(o,t.hostname))r.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:t.hostname.source,input:r.value,inst:e,continue:!t.abort});if(t.protocol&&!qa(o,t.protocol))r.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:t.protocol.source,input:r.value,inst:e,continue:!t.abort});r.value=t.normalize?o.href:Bo(n);return}catch(n){r.issues.push({code:"invalid_format",format:"url",input:r.value,inst:e,continue:!t.abort})}}}),ci=p("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=uo()),P.init(e,t)}),ai=p("$ZodNanoID",(e,t)=>{if(t.length!==void 0&&(!Number.isInteger(t.length)||t.length<1))throw Error(`Invalid nanoid length: ${t.length}`);t.pattern??(t.pattern=t.length===void 0?oo:io(t.length)),P.init(e,t)}),ui=p("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=Qn),P.init(e,t)}),li=p("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=eo),P.init(e,t)}),pi=p("$ZodULID",(e,t)=>{t.pattern??(t.pattern=to),P.init(e,t)}),fi=p("$ZodXID",(e,t)=>{t.pattern??(t.pattern=ro),P.init(e,t)}),di=p("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=no),P.init(e,t)}),mi=p("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=zo(t)),P.init(e,t)}),hi=p("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=bo),P.init(e,t)}),gi=p("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=vo(t)),P.init(e,t)}),yi=p("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=so),P.init(e,t)}),_i=p("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=lo),P.init(e,t)}),Ya=/^[0-9a-fA-F:.]+$/;function xi(e){if(!Ya.test(e))return!1;return ii(`http://[${e}]`)}var bi=p("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=po),P.init(e,t),e._zod.check=(r)=>{if(!xi(r.value))r.issues.push({code:"invalid_format",format:"ipv6",input:r.value,inst:e,continue:!t.abort})}});var vi=p("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=fo),P.init(e,t)});function Qa(e){let t=e.split("/");if(t.length!==2)return!1;let[r,n]=t;if(!n)return!1;let o=Number(n);if(`${o}`!==n)return!1;if(o<0||o>128)return!1;return xi(r)}var zi=p("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=mo),P.init(e,t),e._zod.check=(r)=>{if(!Qa(r.value))r.issues.push({code:"invalid_format",format:"cidrv6",input:r.value,inst:e,continue:!t.abort})}});function wi(e){if(e==="")return!0;if(/\s/.test(e))return!1;if(e.length%4!==0)return!1;try{return atob(e),!0}catch{return!1}}var rr=/^[0-9a-zA-Z+/]*={0,2}$/,$i=p("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=rr),P.init(e,t),e._zod.check=(r)=>{if(wi(r.value))return;r.issues.push({code:"invalid_format",format:"base64",input:r.value,inst:e,continue:!t.abort})}}),ot=/^[A-Za-z0-9_-]*$/;function eu(e){if(!ot.test(e))return!1;let t=e.replace(/[-_]/g,(n)=>n==="-"?"+":"/"),r=t.padEnd(Math.ceil(t.length/4)*4,"=");return wi(r)}var Si=p("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=ot),P.init(e,t),e._zod.check=(r)=>{if(eu(r.value))return;r.issues.push({code:"invalid_format",format:"base64url",input:r.value,inst:e,continue:!t.abort})}}),ki=p("$ZodE164",(e,t)=>{t.pattern??(t.pattern=_o),P.init(e,t)});function tu(e,t=null){try{let r=e.split(".");if(r.length!==3)return!1;let[n]=r;if(!n)return!1;let o=JSON.parse(atob(n));if("typ"in o&&o?.typ!=="JWT")return!1;if(!o.alg)return!1;if(t&&(!("alg"in o)||o.alg!==t))return!1;return!0}catch{return!1}}var Pi=p("$ZodJWT",(e,t)=>{P.init(e,t),e._zod.check=(r)=>{if(tu(r.value,t.alg))return;r.issues.push({code:"invalid_format",format:"jwt",input:r.value,inst:e,continue:!t.abort})}});var nr=p("$ZodNumber",(e,t)=>{z.init(e,t),e._zod.pattern=Pe,e._zod.parse=(r,n)=>{if(t.coerce)try{r.value=Number(r.value)}catch(s){}let o=r.value;if(typeof o==="number"&&!Number.isNaN(o)&&Number.isFinite(o))return r;let i=typeof o==="number"?Number.isNaN(o)?"NaN":!Number.isFinite(o)?String(o):void 0:void 0;return r.issues.push({expected:"number",code:"invalid_type",input:o,inst:e,...i?{received:i}:{}}),r}}),Ci=p("$ZodNumberFormat",(e,t)=>{Co.init(e,t),nr.init(e,t)}),Zi=p("$ZodBoolean",(e,t)=>{z.init(e,t),e._zod.pattern=$o,e._zod.parse=(r,n)=>{if(t.coerce)try{r.value=Boolean(r.value)}catch(i){}let o=r.value;if(typeof o==="boolean")return r;return r.issues.push({expected:"boolean",code:"invalid_type",input:o,inst:e}),r}});var Ri=p("$ZodUnknown",(e,t)=>{z.init(e,t),e._zod.parse=(r)=>r}),Ai=p("$ZodNever",(e,t)=>{z.init(e,t),e._zod.parse=(r,n)=>(r.issues.push({expected:"never",code:"invalid_type",input:r.value,inst:e}),r)}),Oi=p("$ZodVoid",(e,t)=>{z.init(e,t),e._zod.parse=(r,n)=>{let o=r.value;if(typeof o>"u")return r;return r.issues.push({expected:"void",code:"invalid_type",input:o,inst:e}),r}}),Ii=p("$ZodDate",(e,t)=>{z.init(e,t),e._zod.parse=(r,n)=>{if(t.coerce)try{r.value=new Date(r.value)}catch(c){}let o=r.value,i=o instanceof Date;if(i&&!Number.isNaN(o.getTime()))return r;return r.issues.push({expected:"date",code:"invalid_type",input:o,...i?{received:"Invalid Date"}:{},inst:e}),r}});function ru(e,t){let r=Nt(e._zod.def.checks);if(!r.length)return;let n=Math.min(...r.map((i)=>i[0])),o=e._zod.parse;e._zod.parse=(i,s)=>{let c=t(i.value);if(c>n&&!s?.skipChecks&&s?.direction!=="backward"){for(let[a,u]of Nt(e._zod.def.checks))if(c>a&&u._zod.def.when(i)){let l=i.issues.length;return u._zod.check(i),i.issues[l].continue=!1,Ve(i.issues,l,e),i}}return o(i,s)}}var nu=(e)=>Array.isArray(e)?e.length:-1;function Fo(e,t,r){if(e.issues.length)t.issues.push(...q(r,e.issues));t.value[r]=e.value}var Ti=p("$ZodArray",(e,t)=>{z.init(e,t);let r=N.memoizer;r?.attach(e),e._zod.parse=(n,o)=>{let i=n.value;if(!Array.isArray(i))return n.issues.push({expected:"array",code:"invalid_type",input:i,inst:e}),n;n.value=r?r.alloc(e,n,Array(i.length),o):Array(i.length);let s=[],c=o?.abortEarly;for(let a=0;a<i.length;a++){let u=i[a],l=t.element._zod.run({value:u,issues:[]},o);if(l instanceof Promise)s.push(l.then((f)=>Fo(f,n,a)));else if(Fo(l,n,a),c&&l.issues.length!==0&&J(l))break}if(s.length)return Promise.all(s).then(()=>n);return n},ru(e,nu)});function rt(e,t,r,n,o,i){let s=r in n,c=i==="optional";if(!s&&c&&o==="optional")return;if(e.issues.length){if(o!==void 0&&c&&!s)return;t.issues.push(...q(r,e.issues))}if(!s&&o===void 0){if(!e.issues.length)t.issues.push({code:"invalid_type",expected:"nonoptional",input:void 0,path:[r]});return}if(e.value===void 0){if(s||o==="defaulted"&&!c)t.value[r]=void 0}else t.value[r]=e.value}var ou=[];function Ei(e){let t=Object.keys(e.shape),r=Object.getOwnPropertySymbols(e.shape),n=r.length?r:ou,o=n.length?[...t,...n]:t;for(let s of o)if(!e.shape?.[s]?._zod?.traits?.has("$ZodType"))throw Error(`Invalid element at key "${String(s)}": expected a Zod schema`);let i=Rn(e.shape);return{...e,allKeys:o,symbolKeys:n,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(i)}}function Mi(e,t,r,n,o,i,s){let c=[],a=o.keySet,u=o.catchall._zod,l=u.def.type,{optin:f,optout:m}=u,d=0;for(let h in t){if(s&&r.issues.length!==d){if(J(r,d))break;d=r.issues.length}if(a.has(h))continue;if(h==="__proto__"){if(l==="never")c.push(h);continue}if(l==="never"){c.push(h);continue}let y=u.run({value:t[h],issues:[]},n);if(y instanceof Promise)e.push(y.then((_)=>rt(_,r,h,t,f,m)));else rt(y,r,h,t,f,m)}if(c.length)r.issues.push({code:"unrecognized_keys",keys:c,input:t,inst:i,continue:!0});if(!e.length)return r;return Promise.all(e).then(()=>r)}var iu=p("$ZodObject",(e,t)=>{z.init(e,t);let r=Object.getOwnPropertyDescriptor(t,"shape"),n=r?.get?r.get.raw:t.shape??{};if(n){let u=()=>{let l={...n};return Object.defineProperty(t,"shape",{value:l}),u.raw=l,l};u.raw=n,Object.defineProperty(t,"shape",{get:u})}let o=ze(()=>Ei(t));v(e,"propValues",(u)=>{let l=u.def.shape,f={};for(let m in l){let d=l[m]._zod;if(d.values){if(!Object.prototype.hasOwnProperty.call(f,m))L(f,m,new Set);for(let h of d.values)f[m].add(h);if(d.optin!==void 0)f[m].add(void 0)}}return f});let i=pe,s=t.catchall,c,a=N.memoizer;a?.attach(e),e._zod.parse=(u,l)=>{c??(c=o.value);let f=u.value;if(!i(f))return u.issues.push({expected:"object",code:"invalid_type",input:f,inst:e}),u;u.value=a?a.alloc(e,u,{},l):{};let m=[],d=c.shape,h=l?.abortEarly,y=u.issues.length;for(let _ of c.allKeys){if(h&&u.issues.length!==y){if(J(u,y))break;y=u.issues.length}if(_==="__proto__")continue;let b=d[_],I=b._zod.optin,C=b._zod.optout,H=b._zod.run({value:f[_],issues:[]},l);if(H instanceof Promise)m.push(H.then((R)=>rt(R,u,_,f,I,C)));else rt(H,u,_,f,I,C)}if(!s)return m.length?Promise.all(m).then(()=>u):u;return Mi(m,f,u,l,o.value,e,h===!0)}}),Ni=p("$ZodObjectJIT",(e,t)=>{iu.init(e,t);let r=e._zod.parse,n=ze(()=>Ei(t)),o=N.memoizer,i=(d)=>{let h=n.value,y=h.symbolKeys,_=new Qt(["payload","ctx"],{shape:d,inst:e,memo:o,syms:y}),b=(R)=>`shape[${R}]._zod.run({ value: input[${R}], issues: [] }, ctx)`,I=(R,w)=>`
18
18
  let ${R}_ab = false;
19
19
  for (let i = 0; i < ${R}.issues.length; i++) {
20
20
  const iss = ${R}.issues[i];
@@ -1,5 +1,5 @@
1
1
  import z from "zod";
2
- import type { HubToolExecutorName } from "../hub";
2
+ import type { HubToolExecutorName, PluginPolicies, SessionPluginIssue } from "../hub";
3
3
  import type { ModelModality, ModelOperation, ModelOperationMode } from "../llms/model-info";
4
4
  import type { ModelToolName } from "../llms/model-tools";
5
5
  import type { ReasoningLevel } from "../llms/reasoning-options";
@@ -20,6 +20,8 @@ export interface ChatRuntimeConfig extends SessionPromptConfig {
20
20
  missionTimeIntervalMs?: number;
21
21
  timeoutSeconds?: number;
22
22
  toolPolicies?: SessionExecutionConfig["toolPolicies"];
23
+ /** Per-session plugin selection, shaped like `toolPolicies`. */
24
+ plugins?: PluginPolicies;
23
25
  toolExecutors?: HubToolExecutorName[];
24
26
  configExtensions?: RuntimeConfigExtensionKind[];
25
27
  }
@@ -46,6 +48,8 @@ export interface ChatStartSessionArtifacts {
46
48
  export interface ChatStartSessionResponse {
47
49
  sessionId: string;
48
50
  startResult?: ChatStartSessionArtifacts;
51
+ /** Plugins the session asked for but does not have (failed or disabled). */
52
+ pluginIssues?: SessionPluginIssue[];
49
53
  }
50
54
  export interface ChatAttachmentFile {
51
55
  name: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cline/shared",
3
- "version": "0.0.92-nightly.1791773200",
3
+ "version": "0.0.93",
4
4
  "description": "Shared utilities, types, and schemas for Cline packages",
5
5
  "repository": {
6
6
  "type": "git",