@reddb-io/red-skills 4.0.0 → 4.0.1

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.
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env node
2
2
  import { createRequire as __cr } from 'node:module'; const require = __cr(import.meta.url);
3
- var ddt=Object.create;var BW=Object.defineProperty;var pdt=Object.getOwnPropertyDescriptor;var fdt=Object.getOwnPropertyNames;var mdt=Object.getPrototypeOf,hdt=Object.prototype.hasOwnProperty;var On=(e=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(e,{get:(t,r)=>(typeof require<"u"?require:t)[r]}):e)(function(e){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+e+'" is not supported')});var p=(e,t)=>()=>(e&&(t=e(e=0)),t);var ee=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),Vn=(e,t)=>{for(var r in t)BW(e,r,{get:t[r],enumerable:!0})},gdt=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of fdt(t))!hdt.call(e,o)&&o!==r&&BW(e,o,{get:()=>t[o],enumerable:!(n=pdt(t,o))||n.enumerable});return e};var Rp=(e,t,r)=>(r=e!=null?ddt(mdt(e)):{},gdt(t||!e||!e.__esModule?BW(r,"default",{value:e,enumerable:!0}):r,e));function WW(e){let t={app:e,version:ydt(dk("__RED_BUILD_VERSION__",()=>"4.0.0")??"0.0.0-dev"),gitSha:dk("__RED_BUILD_GIT_SHA__",()=>"6c163bc47f1b153cc1504df500caf8005238c0fe")??"unknown",buildTime:dk("__RED_BUILD_TIME__",()=>"2026-08-19T21:24:35Z")??"unknown",bundleAsset:dk("__RED_BUNDLE_ASSET__",()=>"redskilled-mcp.bundle.min.mjs")??"unknown"},r=dk("__REDDB_SDK_VERSION__",()=>""),n=dk("__REDDB_BINARY_TAG__",()=>"");return r&&(t.reddbSdkVersion=r),n&&(t.reddbBinaryTag=n),t}function ydt(e){return e.startsWith("v")?e.slice(1):e}function Zxe(e){return`${e.app} ${e.version} ${e.gitSha}`}function dk(e,t){try{let r=t();return typeof r=="string"&&r.length>0?r:void 0}catch{return process.env[e.replace(/^__|__$/g,"")]}}var VW=p(()=>{});function K(e,t,r){function n(a,c){if(a._zod||Object.defineProperty(a,"_zod",{value:{def:c,constr:s,traits:new Set},enumerable:!1}),a._zod.traits.has(e))return;a._zod.traits.add(e),t(a,c);let l=s.prototype,u=Object.keys(l);for(let d=0;d<u.length;d++){let f=u[d];f in a||(a[f]=l[f].bind(a))}}let o=r?.Parent??Object;class i extends o{}Object.defineProperty(i,"name",{value:e});function s(a){var c;let l=r?.Parent?new i:this;n(l,a),(c=l._zod).deferred??(c.deferred=[]);for(let u of l._zod.deferred)u();return l}return Object.defineProperty(s,"init",{value:n}),Object.defineProperty(s,Symbol.hasInstance,{value:a=>r?.Parent&&a instanceof r.Parent?!0:a?._zod?.traits?.has(e)}),Object.defineProperty(s,"name",{value:e}),s}function yo(e){return e&&Object.assign(Ly,e),Ly}var Jxe,ZW,JW,Hl,Um,Ly,Fy=p(()=>{ZW=Object.freeze({status:"aborted"});JW=Symbol("zod_brand"),Hl=class extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}},Um=class extends Error{constructor(t){super(`Encountered unidirectional transform during encode: ${t}`),this.name="ZodEncodeError"}};(Jxe=globalThis).__zod_globalConfig??(Jxe.__zod_globalConfig={});Ly=globalThis.__zod_globalConfig});var Re={};Vn(Re,{BIGINT_FORMAT_RANGES:()=>s4,Class:()=>QW,NUMBER_FORMAT_RANGES:()=>i4,aborted:()=>Bm,allowsEval:()=>t4,assert:()=>wdt,assertEqual:()=>xdt,assertIs:()=>kdt,assertNever:()=>_dt,assertNotEqual:()=>Sdt,assignProp:()=>qm,base64ToUint8Array:()=>Qxe,base64urlToUint8Array:()=>jdt,cached:()=>fk,captureStackTrace:()=>R$,cleanEnum:()=>Fdt,cleanRegex:()=>C0,clone:()=>Cs,cloneDef:()=>Edt,createTransparentProxy:()=>Adt,defineLazy:()=>Jt,esc:()=>E$,escapeRegex:()=>$c,explicitlyAborted:()=>a4,extend:()=>Mdt,finalizeIssue:()=>Ps,floatSafeRemainder:()=>XW,getElementAtPath:()=>Rdt,getEnumValues:()=>T0,getLengthableOrigin:()=>A0,getParsedType:()=>Idt,getSizableOrigin:()=>I0,hexToUint8Array:()=>Hdt,isObject:()=>jy,isPlainObject:()=>Gm,issue:()=>mk,joinValues:()=>ne,jsonStringifyReplacer:()=>pk,merge:()=>Ndt,mergeDefs:()=>Tp,normalizeParams:()=>Ie,nullish:()=>Hm,numKeys:()=>Pdt,objectClone:()=>vdt,omit:()=>$dt,optionalKeys:()=>o4,parsedType:()=>Ee,partial:()=>zdt,pick:()=>Odt,prefixIssues:()=>ca,primitiveTypes:()=>n4,promiseAllObject:()=>Tdt,propertyKeyTypes:()=>P0,randomString:()=>Cdt,required:()=>Ldt,safeExtend:()=>Ddt,shallowClone:()=>r4,slugify:()=>e4,stringifyPrimitive:()=>ve,uint8ArrayToBase64:()=>Xxe,uint8ArrayToBase64url:()=>Udt,uint8ArrayToHex:()=>qdt,unwrapMessage:()=>R0});function xdt(e){return e}function Sdt(e){return e}function kdt(e){}function _dt(e){throw new Error("Unexpected value in exhaustive check")}function wdt(e){}function T0(e){let t=Object.values(e).filter(n=>typeof n=="number");return Object.entries(e).filter(([n,o])=>t.indexOf(+n)===-1).map(([n,o])=>o)}function ne(e,t="|"){return e.map(r=>ve(r)).join(t)}function pk(e,t){return typeof t=="bigint"?t.toString():t}function fk(e){return{get value(){{let r=e();return Object.defineProperty(this,"value",{value:r}),r}throw new Error("cached value already set")}}}function Hm(e){return e==null}function C0(e){let t=e.startsWith("^")?1:0,r=e.endsWith("$")?e.length-1:e.length;return e.slice(t,r)}function XW(e,t){let r=e/t,n=Math.round(r),o=Number.EPSILON*Math.max(Math.abs(r),1);return Math.abs(r-n)<o?0:r-n}function Jt(e,t,r){let n;Object.defineProperty(e,t,{get(){if(n!==Yxe)return n===void 0&&(n=Yxe,n=r()),n},set(o){Object.defineProperty(e,t,{value:o})},configurable:!0})}function vdt(e){return Object.create(Object.getPrototypeOf(e),Object.getOwnPropertyDescriptors(e))}function qm(e,t,r){Object.defineProperty(e,t,{value:r,writable:!0,enumerable:!0,configurable:!0})}function Tp(...e){let t={};for(let r of e){let n=Object.getOwnPropertyDescriptors(r);Object.assign(t,n)}return Object.defineProperties({},t)}function Edt(e){return Tp(e._zod.def)}function Rdt(e,t){return t?t.reduce((r,n)=>r?.[n],e):e}function Tdt(e){let t=Object.keys(e),r=t.map(n=>e[n]);return Promise.all(r).then(n=>{let o={};for(let i=0;i<t.length;i++)o[t[i]]=n[i];return o})}function Cdt(e=10){let t="abcdefghijklmnopqrstuvwxyz",r="";for(let n=0;n<e;n++)r+=t[Math.floor(Math.random()*t.length)];return r}function E$(e){return JSON.stringify(e)}function e4(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}function jy(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function Gm(e){if(jy(e)===!1)return!1;let t=e.constructor;if(t===void 0||typeof t!="function")return!0;let r=t.prototype;return!(jy(r)===!1||Object.prototype.hasOwnProperty.call(r,"isPrototypeOf")===!1)}function r4(e){return Gm(e)?{...e}:Array.isArray(e)?[...e]:e instanceof Map?new Map(e):e instanceof Set?new Set(e):e}function Pdt(e){let t=0;for(let r in e)Object.prototype.hasOwnProperty.call(e,r)&&t++;return t}function $c(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Cs(e,t,r){let n=new e._zod.constr(t??e._zod.def);return(!t||r?.parent)&&(n._zod.parent=e),n}function Ie(e){let t=e;if(!t)return{};if(typeof t=="string")return{error:()=>t};if(t?.message!==void 0){if(t?.error!==void 0)throw new Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,typeof t.error=="string"?{...t,error:()=>t.error}:t}function Adt(e){let t;return new Proxy({},{get(r,n,o){return t??(t=e()),Reflect.get(t,n,o)},set(r,n,o,i){return t??(t=e()),Reflect.set(t,n,o,i)},has(r,n){return t??(t=e()),Reflect.has(t,n)},deleteProperty(r,n){return t??(t=e()),Reflect.deleteProperty(t,n)},ownKeys(r){return t??(t=e()),Reflect.ownKeys(t)},getOwnPropertyDescriptor(r,n){return t??(t=e()),Reflect.getOwnPropertyDescriptor(t,n)},defineProperty(r,n,o){return t??(t=e()),Reflect.defineProperty(t,n,o)}})}function ve(e){return typeof e=="bigint"?e.toString()+"n":typeof e=="string"?`"${e}"`:`${e}`}function o4(e){return Object.keys(e).filter(t=>e[t]._zod.optin==="optional"&&e[t]._zod.optout==="optional")}function Odt(e,t){let r=e._zod.def,n=r.checks;if(n&&n.length>0)throw new Error(".pick() cannot be used on object schemas containing refinements");let i=Tp(e._zod.def,{get shape(){let s={};for(let a in t){if(!(a in r.shape))throw new Error(`Unrecognized key: "${a}"`);t[a]&&(s[a]=r.shape[a])}return qm(this,"shape",s),s},checks:[]});return Cs(e,i)}function $dt(e,t){let r=e._zod.def,n=r.checks;if(n&&n.length>0)throw new Error(".omit() cannot be used on object schemas containing refinements");let i=Tp(e._zod.def,{get shape(){let s={...e._zod.def.shape};for(let a in t){if(!(a in r.shape))throw new Error(`Unrecognized key: "${a}"`);t[a]&&delete s[a]}return qm(this,"shape",s),s},checks:[]});return Cs(e,i)}function Mdt(e,t){if(!Gm(t))throw new Error("Invalid input to extend: expected a plain object");let r=e._zod.def.checks;if(r&&r.length>0){let i=e._zod.def.shape;for(let s in t)if(Object.getOwnPropertyDescriptor(i,s)!==void 0)throw new Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}let o=Tp(e._zod.def,{get shape(){let i={...e._zod.def.shape,...t};return qm(this,"shape",i),i}});return Cs(e,o)}function Ddt(e,t){if(!Gm(t))throw new Error("Invalid input to safeExtend: expected a plain object");let r=Tp(e._zod.def,{get shape(){let n={...e._zod.def.shape,...t};return qm(this,"shape",n),n}});return Cs(e,r)}function Ndt(e,t){if(e._zod.def.checks?.length)throw new Error(".merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.");let r=Tp(e._zod.def,{get shape(){let n={...e._zod.def.shape,...t._zod.def.shape};return qm(this,"shape",n),n},get catchall(){return t._zod.def.catchall},checks:t._zod.def.checks??[]});return Cs(e,r)}function zdt(e,t,r){let o=t._zod.def.checks;if(o&&o.length>0)throw new Error(".partial() cannot be used on object schemas containing refinements");let s=Tp(t._zod.def,{get shape(){let a=t._zod.def.shape,c={...a};if(r)for(let l in r){if(!(l in a))throw new Error(`Unrecognized key: "${l}"`);r[l]&&(c[l]=e?new e({type:"optional",innerType:a[l]}):a[l])}else for(let l in a)c[l]=e?new e({type:"optional",innerType:a[l]}):a[l];return qm(this,"shape",c),c},checks:[]});return Cs(t,s)}function Ldt(e,t,r){let n=Tp(t._zod.def,{get shape(){let o=t._zod.def.shape,i={...o};if(r)for(let s in r){if(!(s in i))throw new Error(`Unrecognized key: "${s}"`);r[s]&&(i[s]=new e({type:"nonoptional",innerType:o[s]}))}else for(let s in o)i[s]=new e({type:"nonoptional",innerType:o[s]});return qm(this,"shape",i),i}});return Cs(t,n)}function Bm(e,t=0){if(e.aborted===!0)return!0;for(let r=t;r<e.issues.length;r++)if(e.issues[r]?.continue!==!0)return!0;return!1}function a4(e,t=0){if(e.aborted===!0)return!0;for(let r=t;r<e.issues.length;r++)if(e.issues[r]?.continue===!1)return!0;return!1}function ca(e,t){return t.map(r=>{var n;return(n=r).path??(n.path=[]),r.path.unshift(e),r})}function R0(e){return typeof e=="string"?e:e?.message}function Ps(e,t,r){let n=e.message?e.message:R0(e.inst?._zod.def?.error?.(e))??R0(t?.error?.(e))??R0(r.customError?.(e))??R0(r.localeError?.(e))??"Invalid input",{inst:o,continue:i,input:s,...a}=e;return a.path??(a.path=[]),a.message=n,t?.reportInput&&(a.input=s),a}function I0(e){return e instanceof Set?"set":e instanceof Map?"map":e instanceof File?"file":"unknown"}function A0(e){return Array.isArray(e)?"array":typeof e=="string"?"string":"unknown"}function Ee(e){let t=typeof e;switch(t){case"number":return Number.isNaN(e)?"nan":"number";case"object":{if(e===null)return"null";if(Array.isArray(e))return"array";let r=e;if(r&&Object.getPrototypeOf(r)!==Object.prototype&&"constructor"in r&&r.constructor)return r.constructor.name}}return t}function mk(...e){let[t,r,n]=e;return typeof t=="string"?{message:t,code:"custom",input:r,inst:n}:{...t}}function Fdt(e){return Object.entries(e).filter(([t,r])=>Number.isNaN(Number.parseInt(t,10))).map(t=>t[1])}function Qxe(e){let t=atob(e),r=new Uint8Array(t.length);for(let n=0;n<t.length;n++)r[n]=t.charCodeAt(n);return r}function Xxe(e){let t="";for(let r=0;r<e.length;r++)t+=String.fromCharCode(e[r]);return btoa(t)}function jdt(e){let t=e.replace(/-/g,"+").replace(/_/g,"/"),r="=".repeat((4-t.length%4)%4);return Qxe(t+r)}function Udt(e){return Xxe(e).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}function Hdt(e){let t=e.replace(/^0x/,"");if(t.length%2!==0)throw new Error("Invalid hex string length");let r=new Uint8Array(t.length/2);for(let n=0;n<t.length;n+=2)r[n/2]=Number.parseInt(t.slice(n,n+2),16);return r}function qdt(e){return Array.from(e).map(t=>t.toString(16).padStart(2,"0")).join("")}var Yxe,R$,t4,Idt,P0,n4,i4,s4,QW,ot=p(()=>{Fy();Yxe=Symbol("evaluating");R$="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};t4=fk(()=>{if(Ly.jitless||typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{let e=Function;return new e(""),!0}catch{return!1}});Idt=e=>{let t=typeof e;switch(t){case"undefined":return"undefined";case"string":return"string";case"number":return Number.isNaN(e)?"nan":"number";case"boolean":return"boolean";case"function":return"function";case"bigint":return"bigint";case"symbol":return"symbol";case"object":return Array.isArray(e)?"array":e===null?"null":e.then&&typeof e.then=="function"&&e.catch&&typeof e.catch=="function"?"promise":typeof Map<"u"&&e instanceof Map?"map":typeof Set<"u"&&e instanceof Set?"set":typeof Date<"u"&&e instanceof Date?"date":typeof File<"u"&&e instanceof File?"file":"object";default:throw new Error(`Unknown data type: ${t}`)}},P0=new Set(["string","number","symbol"]),n4=new Set(["string","number","bigint","boolean","symbol","undefined"]);i4={safeint:[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]},s4={int64:[BigInt("-9223372036854775808"),BigInt("9223372036854775807")],uint64:[BigInt(0),BigInt("18446744073709551615")]};QW=class{constructor(...t){}}});function $0(e,t=r=>r.message){let r={},n=[];for(let o of e.issues)o.path.length>0?(r[o.path[0]]=r[o.path[0]]||[],r[o.path[0]].push(t(o))):n.push(t(o));return{formErrors:n,fieldErrors:r}}function M0(e,t=r=>r.message){let r={_errors:[]},n=(o,i=[])=>{for(let s of o.issues)if(s.code==="invalid_union"&&s.errors.length)s.errors.map(a=>n({issues:a},[...i,...s.path]));else if(s.code==="invalid_key")n({issues:s.issues},[...i,...s.path]);else if(s.code==="invalid_element")n({issues:s.issues},[...i,...s.path]);else{let a=[...i,...s.path];if(a.length===0)r._errors.push(t(s));else{let c=r,l=0;for(;l<a.length;){let u=a[l];l===a.length-1?(c[u]=c[u]||{_errors:[]},c[u]._errors.push(t(s))):c[u]=c[u]||{_errors:[]},c=c[u],l++}}}};return n(e),r}function c4(e,t=r=>r.message){let r={errors:[]},n=(o,i=[])=>{var s,a;for(let c of o.issues)if(c.code==="invalid_union"&&c.errors.length)c.errors.map(l=>n({issues:l},[...i,...c.path]));else if(c.code==="invalid_key")n({issues:c.issues},[...i,...c.path]);else if(c.code==="invalid_element")n({issues:c.issues},[...i,...c.path]);else{let l=[...i,...c.path];if(l.length===0){r.errors.push(t(c));continue}let u=r,d=0;for(;d<l.length;){let f=l[d],m=d===l.length-1;typeof f=="string"?(u.properties??(u.properties={}),(s=u.properties)[f]??(s[f]={errors:[]}),u=u.properties[f]):(u.items??(u.items=[]),(a=u.items)[f]??(a[f]={errors:[]}),u=u.items[f]),m&&u.errors.push(t(c)),d++}}};return n(e),r}function tSe(e){let t=[],r=e.map(n=>typeof n=="object"?n.key:n);for(let n of r)typeof n=="number"?t.push(`[${n}]`):typeof n=="symbol"?t.push(`[${JSON.stringify(String(n))}]`):/[^\w$]/.test(n)?t.push(`[${JSON.stringify(n)}]`):(t.length&&t.push("."),t.push(n));return t.join("")}function l4(e){let t=[],r=[...e.issues].sort((n,o)=>(n.path??[]).length-(o.path??[]).length);for(let n of r)t.push(`\u2716 ${n.message}`),n.path?.length&&t.push(` \u2192 at ${tSe(n.path)}`);return t.join(`
3
+ var ddt=Object.create;var BW=Object.defineProperty;var pdt=Object.getOwnPropertyDescriptor;var fdt=Object.getOwnPropertyNames;var mdt=Object.getPrototypeOf,hdt=Object.prototype.hasOwnProperty;var On=(e=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(e,{get:(t,r)=>(typeof require<"u"?require:t)[r]}):e)(function(e){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+e+'" is not supported')});var p=(e,t)=>()=>(e&&(t=e(e=0)),t);var ee=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),Vn=(e,t)=>{for(var r in t)BW(e,r,{get:t[r],enumerable:!0})},gdt=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of fdt(t))!hdt.call(e,o)&&o!==r&&BW(e,o,{get:()=>t[o],enumerable:!(n=pdt(t,o))||n.enumerable});return e};var Rp=(e,t,r)=>(r=e!=null?ddt(mdt(e)):{},gdt(t||!e||!e.__esModule?BW(r,"default",{value:e,enumerable:!0}):r,e));function WW(e){let t={app:e,version:ydt(dk("__RED_BUILD_VERSION__",()=>"4.0.1")??"0.0.0-dev"),gitSha:dk("__RED_BUILD_GIT_SHA__",()=>"e0dea944979cf41c5f70fec5350b94c56a2a2792")??"unknown",buildTime:dk("__RED_BUILD_TIME__",()=>"2026-08-19T19:55:56-03:00")??"unknown",bundleAsset:dk("__RED_BUNDLE_ASSET__",()=>"redskilled-mcp.bundle.min.mjs")??"unknown"},r=dk("__REDDB_SDK_VERSION__",()=>""),n=dk("__REDDB_BINARY_TAG__",()=>"");return r&&(t.reddbSdkVersion=r),n&&(t.reddbBinaryTag=n),t}function ydt(e){return e.startsWith("v")?e.slice(1):e}function Zxe(e){return`${e.app} ${e.version} ${e.gitSha}`}function dk(e,t){try{let r=t();return typeof r=="string"&&r.length>0?r:void 0}catch{return process.env[e.replace(/^__|__$/g,"")]}}var VW=p(()=>{});function K(e,t,r){function n(a,c){if(a._zod||Object.defineProperty(a,"_zod",{value:{def:c,constr:s,traits:new Set},enumerable:!1}),a._zod.traits.has(e))return;a._zod.traits.add(e),t(a,c);let l=s.prototype,u=Object.keys(l);for(let d=0;d<u.length;d++){let f=u[d];f in a||(a[f]=l[f].bind(a))}}let o=r?.Parent??Object;class i extends o{}Object.defineProperty(i,"name",{value:e});function s(a){var c;let l=r?.Parent?new i:this;n(l,a),(c=l._zod).deferred??(c.deferred=[]);for(let u of l._zod.deferred)u();return l}return Object.defineProperty(s,"init",{value:n}),Object.defineProperty(s,Symbol.hasInstance,{value:a=>r?.Parent&&a instanceof r.Parent?!0:a?._zod?.traits?.has(e)}),Object.defineProperty(s,"name",{value:e}),s}function yo(e){return e&&Object.assign(Ly,e),Ly}var Jxe,ZW,JW,Hl,Um,Ly,Fy=p(()=>{ZW=Object.freeze({status:"aborted"});JW=Symbol("zod_brand"),Hl=class extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}},Um=class extends Error{constructor(t){super(`Encountered unidirectional transform during encode: ${t}`),this.name="ZodEncodeError"}};(Jxe=globalThis).__zod_globalConfig??(Jxe.__zod_globalConfig={});Ly=globalThis.__zod_globalConfig});var Re={};Vn(Re,{BIGINT_FORMAT_RANGES:()=>s4,Class:()=>QW,NUMBER_FORMAT_RANGES:()=>i4,aborted:()=>Bm,allowsEval:()=>t4,assert:()=>wdt,assertEqual:()=>xdt,assertIs:()=>kdt,assertNever:()=>_dt,assertNotEqual:()=>Sdt,assignProp:()=>qm,base64ToUint8Array:()=>Qxe,base64urlToUint8Array:()=>jdt,cached:()=>fk,captureStackTrace:()=>R$,cleanEnum:()=>Fdt,cleanRegex:()=>C0,clone:()=>Cs,cloneDef:()=>Edt,createTransparentProxy:()=>Adt,defineLazy:()=>Jt,esc:()=>E$,escapeRegex:()=>$c,explicitlyAborted:()=>a4,extend:()=>Mdt,finalizeIssue:()=>Ps,floatSafeRemainder:()=>XW,getElementAtPath:()=>Rdt,getEnumValues:()=>T0,getLengthableOrigin:()=>A0,getParsedType:()=>Idt,getSizableOrigin:()=>I0,hexToUint8Array:()=>Hdt,isObject:()=>jy,isPlainObject:()=>Gm,issue:()=>mk,joinValues:()=>ne,jsonStringifyReplacer:()=>pk,merge:()=>Ndt,mergeDefs:()=>Tp,normalizeParams:()=>Ie,nullish:()=>Hm,numKeys:()=>Pdt,objectClone:()=>vdt,omit:()=>$dt,optionalKeys:()=>o4,parsedType:()=>Ee,partial:()=>zdt,pick:()=>Odt,prefixIssues:()=>ca,primitiveTypes:()=>n4,promiseAllObject:()=>Tdt,propertyKeyTypes:()=>P0,randomString:()=>Cdt,required:()=>Ldt,safeExtend:()=>Ddt,shallowClone:()=>r4,slugify:()=>e4,stringifyPrimitive:()=>ve,uint8ArrayToBase64:()=>Xxe,uint8ArrayToBase64url:()=>Udt,uint8ArrayToHex:()=>qdt,unwrapMessage:()=>R0});function xdt(e){return e}function Sdt(e){return e}function kdt(e){}function _dt(e){throw new Error("Unexpected value in exhaustive check")}function wdt(e){}function T0(e){let t=Object.values(e).filter(n=>typeof n=="number");return Object.entries(e).filter(([n,o])=>t.indexOf(+n)===-1).map(([n,o])=>o)}function ne(e,t="|"){return e.map(r=>ve(r)).join(t)}function pk(e,t){return typeof t=="bigint"?t.toString():t}function fk(e){return{get value(){{let r=e();return Object.defineProperty(this,"value",{value:r}),r}throw new Error("cached value already set")}}}function Hm(e){return e==null}function C0(e){let t=e.startsWith("^")?1:0,r=e.endsWith("$")?e.length-1:e.length;return e.slice(t,r)}function XW(e,t){let r=e/t,n=Math.round(r),o=Number.EPSILON*Math.max(Math.abs(r),1);return Math.abs(r-n)<o?0:r-n}function Jt(e,t,r){let n;Object.defineProperty(e,t,{get(){if(n!==Yxe)return n===void 0&&(n=Yxe,n=r()),n},set(o){Object.defineProperty(e,t,{value:o})},configurable:!0})}function vdt(e){return Object.create(Object.getPrototypeOf(e),Object.getOwnPropertyDescriptors(e))}function qm(e,t,r){Object.defineProperty(e,t,{value:r,writable:!0,enumerable:!0,configurable:!0})}function Tp(...e){let t={};for(let r of e){let n=Object.getOwnPropertyDescriptors(r);Object.assign(t,n)}return Object.defineProperties({},t)}function Edt(e){return Tp(e._zod.def)}function Rdt(e,t){return t?t.reduce((r,n)=>r?.[n],e):e}function Tdt(e){let t=Object.keys(e),r=t.map(n=>e[n]);return Promise.all(r).then(n=>{let o={};for(let i=0;i<t.length;i++)o[t[i]]=n[i];return o})}function Cdt(e=10){let t="abcdefghijklmnopqrstuvwxyz",r="";for(let n=0;n<e;n++)r+=t[Math.floor(Math.random()*t.length)];return r}function E$(e){return JSON.stringify(e)}function e4(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}function jy(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function Gm(e){if(jy(e)===!1)return!1;let t=e.constructor;if(t===void 0||typeof t!="function")return!0;let r=t.prototype;return!(jy(r)===!1||Object.prototype.hasOwnProperty.call(r,"isPrototypeOf")===!1)}function r4(e){return Gm(e)?{...e}:Array.isArray(e)?[...e]:e instanceof Map?new Map(e):e instanceof Set?new Set(e):e}function Pdt(e){let t=0;for(let r in e)Object.prototype.hasOwnProperty.call(e,r)&&t++;return t}function $c(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Cs(e,t,r){let n=new e._zod.constr(t??e._zod.def);return(!t||r?.parent)&&(n._zod.parent=e),n}function Ie(e){let t=e;if(!t)return{};if(typeof t=="string")return{error:()=>t};if(t?.message!==void 0){if(t?.error!==void 0)throw new Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,typeof t.error=="string"?{...t,error:()=>t.error}:t}function Adt(e){let t;return new Proxy({},{get(r,n,o){return t??(t=e()),Reflect.get(t,n,o)},set(r,n,o,i){return t??(t=e()),Reflect.set(t,n,o,i)},has(r,n){return t??(t=e()),Reflect.has(t,n)},deleteProperty(r,n){return t??(t=e()),Reflect.deleteProperty(t,n)},ownKeys(r){return t??(t=e()),Reflect.ownKeys(t)},getOwnPropertyDescriptor(r,n){return t??(t=e()),Reflect.getOwnPropertyDescriptor(t,n)},defineProperty(r,n,o){return t??(t=e()),Reflect.defineProperty(t,n,o)}})}function ve(e){return typeof e=="bigint"?e.toString()+"n":typeof e=="string"?`"${e}"`:`${e}`}function o4(e){return Object.keys(e).filter(t=>e[t]._zod.optin==="optional"&&e[t]._zod.optout==="optional")}function Odt(e,t){let r=e._zod.def,n=r.checks;if(n&&n.length>0)throw new Error(".pick() cannot be used on object schemas containing refinements");let i=Tp(e._zod.def,{get shape(){let s={};for(let a in t){if(!(a in r.shape))throw new Error(`Unrecognized key: "${a}"`);t[a]&&(s[a]=r.shape[a])}return qm(this,"shape",s),s},checks:[]});return Cs(e,i)}function $dt(e,t){let r=e._zod.def,n=r.checks;if(n&&n.length>0)throw new Error(".omit() cannot be used on object schemas containing refinements");let i=Tp(e._zod.def,{get shape(){let s={...e._zod.def.shape};for(let a in t){if(!(a in r.shape))throw new Error(`Unrecognized key: "${a}"`);t[a]&&delete s[a]}return qm(this,"shape",s),s},checks:[]});return Cs(e,i)}function Mdt(e,t){if(!Gm(t))throw new Error("Invalid input to extend: expected a plain object");let r=e._zod.def.checks;if(r&&r.length>0){let i=e._zod.def.shape;for(let s in t)if(Object.getOwnPropertyDescriptor(i,s)!==void 0)throw new Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}let o=Tp(e._zod.def,{get shape(){let i={...e._zod.def.shape,...t};return qm(this,"shape",i),i}});return Cs(e,o)}function Ddt(e,t){if(!Gm(t))throw new Error("Invalid input to safeExtend: expected a plain object");let r=Tp(e._zod.def,{get shape(){let n={...e._zod.def.shape,...t};return qm(this,"shape",n),n}});return Cs(e,r)}function Ndt(e,t){if(e._zod.def.checks?.length)throw new Error(".merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.");let r=Tp(e._zod.def,{get shape(){let n={...e._zod.def.shape,...t._zod.def.shape};return qm(this,"shape",n),n},get catchall(){return t._zod.def.catchall},checks:t._zod.def.checks??[]});return Cs(e,r)}function zdt(e,t,r){let o=t._zod.def.checks;if(o&&o.length>0)throw new Error(".partial() cannot be used on object schemas containing refinements");let s=Tp(t._zod.def,{get shape(){let a=t._zod.def.shape,c={...a};if(r)for(let l in r){if(!(l in a))throw new Error(`Unrecognized key: "${l}"`);r[l]&&(c[l]=e?new e({type:"optional",innerType:a[l]}):a[l])}else for(let l in a)c[l]=e?new e({type:"optional",innerType:a[l]}):a[l];return qm(this,"shape",c),c},checks:[]});return Cs(t,s)}function Ldt(e,t,r){let n=Tp(t._zod.def,{get shape(){let o=t._zod.def.shape,i={...o};if(r)for(let s in r){if(!(s in i))throw new Error(`Unrecognized key: "${s}"`);r[s]&&(i[s]=new e({type:"nonoptional",innerType:o[s]}))}else for(let s in o)i[s]=new e({type:"nonoptional",innerType:o[s]});return qm(this,"shape",i),i}});return Cs(t,n)}function Bm(e,t=0){if(e.aborted===!0)return!0;for(let r=t;r<e.issues.length;r++)if(e.issues[r]?.continue!==!0)return!0;return!1}function a4(e,t=0){if(e.aborted===!0)return!0;for(let r=t;r<e.issues.length;r++)if(e.issues[r]?.continue===!1)return!0;return!1}function ca(e,t){return t.map(r=>{var n;return(n=r).path??(n.path=[]),r.path.unshift(e),r})}function R0(e){return typeof e=="string"?e:e?.message}function Ps(e,t,r){let n=e.message?e.message:R0(e.inst?._zod.def?.error?.(e))??R0(t?.error?.(e))??R0(r.customError?.(e))??R0(r.localeError?.(e))??"Invalid input",{inst:o,continue:i,input:s,...a}=e;return a.path??(a.path=[]),a.message=n,t?.reportInput&&(a.input=s),a}function I0(e){return e instanceof Set?"set":e instanceof Map?"map":e instanceof File?"file":"unknown"}function A0(e){return Array.isArray(e)?"array":typeof e=="string"?"string":"unknown"}function Ee(e){let t=typeof e;switch(t){case"number":return Number.isNaN(e)?"nan":"number";case"object":{if(e===null)return"null";if(Array.isArray(e))return"array";let r=e;if(r&&Object.getPrototypeOf(r)!==Object.prototype&&"constructor"in r&&r.constructor)return r.constructor.name}}return t}function mk(...e){let[t,r,n]=e;return typeof t=="string"?{message:t,code:"custom",input:r,inst:n}:{...t}}function Fdt(e){return Object.entries(e).filter(([t,r])=>Number.isNaN(Number.parseInt(t,10))).map(t=>t[1])}function Qxe(e){let t=atob(e),r=new Uint8Array(t.length);for(let n=0;n<t.length;n++)r[n]=t.charCodeAt(n);return r}function Xxe(e){let t="";for(let r=0;r<e.length;r++)t+=String.fromCharCode(e[r]);return btoa(t)}function jdt(e){let t=e.replace(/-/g,"+").replace(/_/g,"/"),r="=".repeat((4-t.length%4)%4);return Qxe(t+r)}function Udt(e){return Xxe(e).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}function Hdt(e){let t=e.replace(/^0x/,"");if(t.length%2!==0)throw new Error("Invalid hex string length");let r=new Uint8Array(t.length/2);for(let n=0;n<t.length;n+=2)r[n/2]=Number.parseInt(t.slice(n,n+2),16);return r}function qdt(e){return Array.from(e).map(t=>t.toString(16).padStart(2,"0")).join("")}var Yxe,R$,t4,Idt,P0,n4,i4,s4,QW,ot=p(()=>{Fy();Yxe=Symbol("evaluating");R$="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};t4=fk(()=>{if(Ly.jitless||typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{let e=Function;return new e(""),!0}catch{return!1}});Idt=e=>{let t=typeof e;switch(t){case"undefined":return"undefined";case"string":return"string";case"number":return Number.isNaN(e)?"nan":"number";case"boolean":return"boolean";case"function":return"function";case"bigint":return"bigint";case"symbol":return"symbol";case"object":return Array.isArray(e)?"array":e===null?"null":e.then&&typeof e.then=="function"&&e.catch&&typeof e.catch=="function"?"promise":typeof Map<"u"&&e instanceof Map?"map":typeof Set<"u"&&e instanceof Set?"set":typeof Date<"u"&&e instanceof Date?"date":typeof File<"u"&&e instanceof File?"file":"object";default:throw new Error(`Unknown data type: ${t}`)}},P0=new Set(["string","number","symbol"]),n4=new Set(["string","number","bigint","boolean","symbol","undefined"]);i4={safeint:[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]},s4={int64:[BigInt("-9223372036854775808"),BigInt("9223372036854775807")],uint64:[BigInt(0),BigInt("18446744073709551615")]};QW=class{constructor(...t){}}});function $0(e,t=r=>r.message){let r={},n=[];for(let o of e.issues)o.path.length>0?(r[o.path[0]]=r[o.path[0]]||[],r[o.path[0]].push(t(o))):n.push(t(o));return{formErrors:n,fieldErrors:r}}function M0(e,t=r=>r.message){let r={_errors:[]},n=(o,i=[])=>{for(let s of o.issues)if(s.code==="invalid_union"&&s.errors.length)s.errors.map(a=>n({issues:a},[...i,...s.path]));else if(s.code==="invalid_key")n({issues:s.issues},[...i,...s.path]);else if(s.code==="invalid_element")n({issues:s.issues},[...i,...s.path]);else{let a=[...i,...s.path];if(a.length===0)r._errors.push(t(s));else{let c=r,l=0;for(;l<a.length;){let u=a[l];l===a.length-1?(c[u]=c[u]||{_errors:[]},c[u]._errors.push(t(s))):c[u]=c[u]||{_errors:[]},c=c[u],l++}}}};return n(e),r}function c4(e,t=r=>r.message){let r={errors:[]},n=(o,i=[])=>{var s,a;for(let c of o.issues)if(c.code==="invalid_union"&&c.errors.length)c.errors.map(l=>n({issues:l},[...i,...c.path]));else if(c.code==="invalid_key")n({issues:c.issues},[...i,...c.path]);else if(c.code==="invalid_element")n({issues:c.issues},[...i,...c.path]);else{let l=[...i,...c.path];if(l.length===0){r.errors.push(t(c));continue}let u=r,d=0;for(;d<l.length;){let f=l[d],m=d===l.length-1;typeof f=="string"?(u.properties??(u.properties={}),(s=u.properties)[f]??(s[f]={errors:[]}),u=u.properties[f]):(u.items??(u.items=[]),(a=u.items)[f]??(a[f]={errors:[]}),u=u.items[f]),m&&u.errors.push(t(c)),d++}}};return n(e),r}function tSe(e){let t=[],r=e.map(n=>typeof n=="object"?n.key:n);for(let n of r)typeof n=="number"?t.push(`[${n}]`):typeof n=="symbol"?t.push(`[${JSON.stringify(String(n))}]`):/[^\w$]/.test(n)?t.push(`[${JSON.stringify(n)}]`):(t.length&&t.push("."),t.push(n));return t.join("")}function l4(e){let t=[],r=[...e.issues].sort((n,o)=>(n.path??[]).length-(o.path??[]).length);for(let n of r)t.push(`\u2716 ${n.message}`),n.path?.length&&t.push(` \u2192 at ${tSe(n.path)}`);return t.join(`
4
4
  `)}var eSe,O0,la,u4=p(()=>{Fy();ot();eSe=(e,t)=>{e.name="$ZodError",Object.defineProperty(e,"_zod",{value:e._zod,enumerable:!1}),Object.defineProperty(e,"issues",{value:t,enumerable:!1}),e.message=JSON.stringify(t,pk,2),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},O0=K("$ZodError",eSe),la=K("$ZodError",eSe,{Parent:Error})});var hk,T$,gk,C$,yk,d4,bk,p4,P$,Bdt,I$,Wdt,A$,Vdt,O$,Kdt,$$,Zdt,M$,Jdt,D$,Ydt,N$,Qdt,f4=p(()=>{Fy();u4();ot();hk=e=>(t,r,n,o)=>{let i=n?{...n,async:!1}:{async:!1},s=t._zod.run({value:r,issues:[]},i);if(s instanceof Promise)throw new Hl;if(s.issues.length){let a=new(o?.Err??e)(s.issues.map(c=>Ps(c,i,yo())));throw R$(a,o?.callee),a}return s.value},T$=hk(la),gk=e=>async(t,r,n,o)=>{let i=n?{...n,async:!0}:{async:!0},s=t._zod.run({value:r,issues:[]},i);if(s instanceof Promise&&(s=await s),s.issues.length){let a=new(o?.Err??e)(s.issues.map(c=>Ps(c,i,yo())));throw R$(a,o?.callee),a}return s.value},C$=gk(la),yk=e=>(t,r,n)=>{let o=n?{...n,async:!1}:{async:!1},i=t._zod.run({value:r,issues:[]},o);if(i instanceof Promise)throw new Hl;return i.issues.length?{success:!1,error:new(e??O0)(i.issues.map(s=>Ps(s,o,yo())))}:{success:!0,data:i.value}},d4=yk(la),bk=e=>async(t,r,n)=>{let o=n?{...n,async:!0}:{async:!0},i=t._zod.run({value:r,issues:[]},o);return i instanceof Promise&&(i=await i),i.issues.length?{success:!1,error:new e(i.issues.map(s=>Ps(s,o,yo())))}:{success:!0,data:i.value}},p4=bk(la),P$=e=>(t,r,n)=>{let o=n?{...n,direction:"backward"}:{direction:"backward"};return hk(e)(t,r,o)},Bdt=P$(la),I$=e=>(t,r,n)=>hk(e)(t,r,n),Wdt=I$(la),A$=e=>async(t,r,n)=>{let o=n?{...n,direction:"backward"}:{direction:"backward"};return gk(e)(t,r,o)},Vdt=A$(la),O$=e=>async(t,r,n)=>gk(e)(t,r,n),Kdt=O$(la),$$=e=>(t,r,n)=>{let o=n?{...n,direction:"backward"}:{direction:"backward"};return yk(e)(t,r,o)},Zdt=$$(la),M$=e=>(t,r,n)=>yk(e)(t,r,n),Jdt=M$(la),D$=e=>async(t,r,n)=>{let o=n?{...n,direction:"backward"}:{direction:"backward"};return bk(e)(t,r,o)},Ydt=D$(la),N$=e=>async(t,r,n)=>bk(e)(t,r,n),Qdt=N$(la)});var Va={};Vn(Va,{base64:()=>P4,base64url:()=>z$,bigint:()=>N4,boolean:()=>L4,browserEmail:()=>spt,cidrv4:()=>T4,cidrv6:()=>C4,cuid:()=>m4,cuid2:()=>h4,date:()=>O4,datetime:()=>M4,domain:()=>lpt,duration:()=>S4,e164:()=>A4,email:()=>_4,emoji:()=>w4,extendedDuration:()=>Xdt,guid:()=>k4,hex:()=>upt,hostname:()=>cpt,html5Email:()=>npt,httpProtocol:()=>I4,idnEmail:()=>ipt,integer:()=>z4,ipv4:()=>v4,ipv6:()=>E4,ksuid:()=>b4,lowercase:()=>U4,mac:()=>R4,md5_base64:()=>ppt,md5_base64url:()=>fpt,md5_hex:()=>dpt,nanoid:()=>x4,null:()=>F4,number:()=>L$,rfc5322Email:()=>opt,sha1_base64:()=>hpt,sha1_base64url:()=>gpt,sha1_hex:()=>mpt,sha256_base64:()=>bpt,sha256_base64url:()=>xpt,sha256_hex:()=>ypt,sha384_base64:()=>kpt,sha384_base64url:()=>_pt,sha384_hex:()=>Spt,sha512_base64:()=>vpt,sha512_base64url:()=>Ept,sha512_hex:()=>wpt,string:()=>D4,time:()=>$4,ulid:()=>g4,undefined:()=>j4,unicodeEmail:()=>rSe,uppercase:()=>H4,uuid:()=>Uy,uuid4:()=>ept,uuid6:()=>tpt,uuid7:()=>rpt,xid:()=>y4});function w4(){return new RegExp(apt,"u")}function oSe(e){let t="(?:[01]\\d|2[0-3]):[0-5]\\d";return typeof e.precision=="number"?e.precision===-1?`${t}`:e.precision===0?`${t}:[0-5]\\d`:`${t}:[0-5]\\d\\.\\d{${e.precision}}`:`${t}(?::[0-5]\\d(?:\\.\\d+)?)?`}function $4(e){return new RegExp(`^${oSe(e)}$`)}function M4(e){let t=oSe({precision:e.precision}),r=["Z"];e.local&&r.push(""),e.offset&&r.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");let n=`${t}(?:${r.join("|")})`;return new RegExp(`^${nSe}T(?:${n})$`)}function D0(e,t){return new RegExp(`^[A-Za-z0-9+/]{${e}}${t}$`)}function N0(e){return new RegExp(`^[A-Za-z0-9_-]{${e}}$`)}var m4,h4,g4,y4,b4,x4,S4,Xdt,k4,Uy,ept,tpt,rpt,_4,npt,opt,rSe,ipt,spt,apt,v4,E4,R4,T4,C4,P4,z$,cpt,lpt,I4,A4,nSe,O4,D4,N4,z4,L$,L4,F4,j4,U4,H4,upt,dpt,ppt,fpt,mpt,hpt,gpt,ypt,bpt,xpt,Spt,kpt,_pt,wpt,vpt,Ept,F$=p(()=>{ot();m4=/^[cC][0-9a-z]{6,}$/,h4=/^[0-9a-z]+$/,g4=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,y4=/^[0-9a-vA-V]{20}$/,b4=/^[A-Za-z0-9]{27}$/,x4=/^[a-zA-Z0-9_-]{21}$/,S4=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,Xdt=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,k4=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,Uy=e=>e?new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/,ept=Uy(4),tpt=Uy(6),rpt=Uy(7),_4=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,npt=/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/,opt=/^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/,rSe=/^[^\s@"]{1,64}@[^\s@]{1,255}$/u,ipt=rSe,spt=/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/,apt="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";v4=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,E4=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/,R4=e=>{let t=$c(e??":");return new RegExp(`^(?:[0-9A-F]{2}${t}){5}[0-9A-F]{2}$|^(?:[0-9a-f]{2}${t}){5}[0-9a-f]{2}$`)},T4=/^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/,C4=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,P4=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,z$=/^[A-Za-z0-9_-]*$/,cpt=/^(?=.{1,253}\.?$)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[-0-9a-zA-Z]{0,61}[0-9a-zA-Z])?)*\.?$/,lpt=/^([a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?\.)+[a-zA-Z]{2,}$/,I4=/^https?$/,A4=/^\+[1-9]\d{6,14}$/,nSe="(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))",O4=new RegExp(`^${nSe}$`);D4=e=>{let t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??""}}`:"[\\s\\S]*";return new RegExp(`^${t}$`)},N4=/^-?\d+n?$/,z4=/^-?\d+$/,L$=/^-?\d+(?:\.\d+)?$/,L4=/^(?:true|false)$/i,F4=/^null$/i,j4=/^undefined$/i,U4=/^[^A-Z]*$/,H4=/^[^a-z]*$/,upt=/^[0-9a-fA-F]*$/;dpt=/^[0-9a-fA-F]{32}$/,ppt=D0(22,"=="),fpt=N0(22),mpt=/^[0-9a-fA-F]{40}$/,hpt=D0(27,"="),gpt=N0(27),ypt=/^[0-9a-fA-F]{64}$/,bpt=D0(43,"="),xpt=N0(43),Spt=/^[0-9a-fA-F]{96}$/,kpt=D0(64,""),_pt=N0(64),wpt=/^[0-9a-fA-F]{128}$/,vpt=D0(86,"=="),Ept=N0(86)});function iSe(e,t,r){e.issues.length&&t.issues.push(...ca(r,e.issues))}var un,sSe,j$,U$,q4,G4,B4,W4,V4,K4,Z4,J4,Y4,xk,Q4,X4,eV,tV,rV,nV,oV,iV,sV,H$=p(()=>{Fy();F$();ot();un=K("$ZodCheck",(e,t)=>{var r;e._zod??(e._zod={}),e._zod.def=t,(r=e._zod).onattach??(r.onattach=[])}),sSe={number:"number",bigint:"bigint",object:"date"},j$=K("$ZodCheckLessThan",(e,t)=>{un.init(e,t);let r=sSe[typeof t.value];e._zod.onattach.push(n=>{let o=n._zod.bag,i=(t.inclusive?o.maximum:o.exclusiveMaximum)??Number.POSITIVE_INFINITY;t.value<i&&(t.inclusive?o.maximum=t.value:o.exclusiveMaximum=t.value)}),e._zod.check=n=>{(t.inclusive?n.value<=t.value:n.value<t.value)||n.issues.push({origin:r,code:"too_big",maximum:typeof t.value=="object"?t.value.getTime():t.value,input:n.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),U$=K("$ZodCheckGreaterThan",(e,t)=>{un.init(e,t);let r=sSe[typeof t.value];e._zod.onattach.push(n=>{let o=n._zod.bag,i=(t.inclusive?o.minimum:o.exclusiveMinimum)??Number.NEGATIVE_INFINITY;t.value>i&&(t.inclusive?o.minimum=t.value:o.exclusiveMinimum=t.value)}),e._zod.check=n=>{(t.inclusive?n.value>=t.value:n.value>t.value)||n.issues.push({origin:r,code:"too_small",minimum:typeof t.value=="object"?t.value.getTime():t.value,input:n.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),q4=K("$ZodCheckMultipleOf",(e,t)=>{un.init(e,t),e._zod.onattach.push(r=>{var n;(n=r._zod.bag).multipleOf??(n.multipleOf=t.value)}),e._zod.check=r=>{if(typeof r.value!=typeof t.value)throw new Error("Cannot mix number and bigint in multiple_of check.");(typeof r.value=="bigint"?r.value%t.value===BigInt(0):XW(r.value,t.value)===0)||r.issues.push({origin:typeof r.value,code:"not_multiple_of",divisor:t.value,input:r.value,inst:e,continue:!t.abort})}}),G4=K("$ZodCheckNumberFormat",(e,t)=>{un.init(e,t),t.format=t.format||"float64";let r=t.format?.includes("int"),n=r?"int":"number",[o,i]=i4[t.format];e._zod.onattach.push(s=>{let a=s._zod.bag;a.format=t.format,a.minimum=o,a.maximum=i,r&&(a.pattern=z4)}),e._zod.check=s=>{let a=s.value;if(r){if(!Number.isInteger(a)){s.issues.push({expected:n,format:t.format,code:"invalid_type",continue:!1,input:a,inst:e});return}if(!Number.isSafeInteger(a)){a>0?s.issues.push({input:a,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:n,inclusive:!0,continue:!t.abort}):s.issues.push({input:a,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:n,inclusive:!0,continue:!t.abort});return}}a<o&&s.issues.push({origin:"number",input:a,code:"too_small",minimum:o,inclusive:!0,inst:e,continue:!t.abort}),a>i&&s.issues.push({origin:"number",input:a,code:"too_big",maximum:i,inclusive:!0,inst:e,continue:!t.abort})}}),B4=K("$ZodCheckBigIntFormat",(e,t)=>{un.init(e,t);let[r,n]=s4[t.format];e._zod.onattach.push(o=>{let i=o._zod.bag;i.format=t.format,i.minimum=r,i.maximum=n}),e._zod.check=o=>{let i=o.value;i<r&&o.issues.push({origin:"bigint",input:i,code:"too_small",minimum:r,inclusive:!0,inst:e,continue:!t.abort}),i>n&&o.issues.push({origin:"bigint",input:i,code:"too_big",maximum:n,inclusive:!0,inst:e,continue:!t.abort})}}),W4=K("$ZodCheckMaxSize",(e,t)=>{var r;un.init(e,t),(r=e._zod.def).when??(r.when=n=>{let o=n.value;return!Hm(o)&&o.size!==void 0}),e._zod.onattach.push(n=>{let o=n._zod.bag.maximum??Number.POSITIVE_INFINITY;t.maximum<o&&(n._zod.bag.maximum=t.maximum)}),e._zod.check=n=>{let o=n.value;o.size<=t.maximum||n.issues.push({origin:I0(o),code:"too_big",maximum:t.maximum,inclusive:!0,input:o,inst:e,continue:!t.abort})}}),V4=K("$ZodCheckMinSize",(e,t)=>{var r;un.init(e,t),(r=e._zod.def).when??(r.when=n=>{let o=n.value;return!Hm(o)&&o.size!==void 0}),e._zod.onattach.push(n=>{let o=n._zod.bag.minimum??Number.NEGATIVE_INFINITY;t.minimum>o&&(n._zod.bag.minimum=t.minimum)}),e._zod.check=n=>{let o=n.value;o.size>=t.minimum||n.issues.push({origin:I0(o),code:"too_small",minimum:t.minimum,inclusive:!0,input:o,inst:e,continue:!t.abort})}}),K4=K("$ZodCheckSizeEquals",(e,t)=>{var r;un.init(e,t),(r=e._zod.def).when??(r.when=n=>{let o=n.value;return!Hm(o)&&o.size!==void 0}),e._zod.onattach.push(n=>{let o=n._zod.bag;o.minimum=t.size,o.maximum=t.size,o.size=t.size}),e._zod.check=n=>{let o=n.value,i=o.size;if(i===t.size)return;let s=i>t.size;n.issues.push({origin:I0(o),...s?{code:"too_big",maximum:t.size}:{code:"too_small",minimum:t.size},inclusive:!0,exact:!0,input:n.value,inst:e,continue:!t.abort})}}),Z4=K("$ZodCheckMaxLength",(e,t)=>{var r;un.init(e,t),(r=e._zod.def).when??(r.when=n=>{let o=n.value;return!Hm(o)&&o.length!==void 0}),e._zod.onattach.push(n=>{let o=n._zod.bag.maximum??Number.POSITIVE_INFINITY;t.maximum<o&&(n._zod.bag.maximum=t.maximum)}),e._zod.check=n=>{let o=n.value;if(o.length<=t.maximum)return;let s=A0(o);n.issues.push({origin:s,code:"too_big",maximum:t.maximum,inclusive:!0,input:o,inst:e,continue:!t.abort})}}),J4=K("$ZodCheckMinLength",(e,t)=>{var r;un.init(e,t),(r=e._zod.def).when??(r.when=n=>{let o=n.value;return!Hm(o)&&o.length!==void 0}),e._zod.onattach.push(n=>{let o=n._zod.bag.minimum??Number.NEGATIVE_INFINITY;t.minimum>o&&(n._zod.bag.minimum=t.minimum)}),e._zod.check=n=>{let o=n.value;if(o.length>=t.minimum)return;let s=A0(o);n.issues.push({origin:s,code:"too_small",minimum:t.minimum,inclusive:!0,input:o,inst:e,continue:!t.abort})}}),Y4=K("$ZodCheckLengthEquals",(e,t)=>{var r;un.init(e,t),(r=e._zod.def).when??(r.when=n=>{let o=n.value;return!Hm(o)&&o.length!==void 0}),e._zod.onattach.push(n=>{let o=n._zod.bag;o.minimum=t.length,o.maximum=t.length,o.length=t.length}),e._zod.check=n=>{let o=n.value,i=o.length;if(i===t.length)return;let s=A0(o),a=i>t.length;n.issues.push({origin:s,...a?{code:"too_big",maximum:t.length}:{code:"too_small",minimum:t.length},inclusive:!0,exact:!0,input:n.value,inst:e,continue:!t.abort})}}),xk=K("$ZodCheckStringFormat",(e,t)=>{var r,n;un.init(e,t),e._zod.onattach.push(o=>{let i=o._zod.bag;i.format=t.format,t.pattern&&(i.patterns??(i.patterns=new Set),i.patterns.add(t.pattern))}),t.pattern?(r=e._zod).check??(r.check=o=>{t.pattern.lastIndex=0,!t.pattern.test(o.value)&&o.issues.push({origin:"string",code:"invalid_format",format:t.format,input:o.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(n=e._zod).check??(n.check=()=>{})}),Q4=K("$ZodCheckRegex",(e,t)=>{xk.init(e,t),e._zod.check=r=>{t.pattern.lastIndex=0,!t.pattern.test(r.value)&&r.issues.push({origin:"string",code:"invalid_format",format:"regex",input:r.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),X4=K("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=U4),xk.init(e,t)}),eV=K("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=H4),xk.init(e,t)}),tV=K("$ZodCheckIncludes",(e,t)=>{un.init(e,t);let r=$c(t.includes),n=new RegExp(typeof t.position=="number"?`^.{${t.position}}${r}`:r);t.pattern=n,e._zod.onattach.push(o=>{let i=o._zod.bag;i.patterns??(i.patterns=new Set),i.patterns.add(n)}),e._zod.check=o=>{o.value.includes(t.includes,t.position)||o.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:t.includes,input:o.value,inst:e,continue:!t.abort})}}),rV=K("$ZodCheckStartsWith",(e,t)=>{un.init(e,t);let r=new RegExp(`^${$c(t.prefix)}.*`);t.pattern??(t.pattern=r),e._zod.onattach.push(n=>{let o=n._zod.bag;o.patterns??(o.patterns=new Set),o.patterns.add(r)}),e._zod.check=n=>{n.value.startsWith(t.prefix)||n.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:t.prefix,input:n.value,inst:e,continue:!t.abort})}}),nV=K("$ZodCheckEndsWith",(e,t)=>{un.init(e,t);let r=new RegExp(`.*${$c(t.suffix)}$`);t.pattern??(t.pattern=r),e._zod.onattach.push(n=>{let o=n._zod.bag;o.patterns??(o.patterns=new Set),o.patterns.add(r)}),e._zod.check=n=>{n.value.endsWith(t.suffix)||n.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:t.suffix,input:n.value,inst:e,continue:!t.abort})}});oV=K("$ZodCheckProperty",(e,t)=>{un.init(e,t),e._zod.check=r=>{let n=t.schema._zod.run({value:r.value[t.property],issues:[]},{});if(n instanceof Promise)return n.then(o=>iSe(o,r,t.property));iSe(n,r,t.property)}}),iV=K("$ZodCheckMimeType",(e,t)=>{un.init(e,t);let r=new Set(t.mime);e._zod.onattach.push(n=>{n._zod.bag.mime=t.mime}),e._zod.check=n=>{r.has(n.value.type)||n.issues.push({code:"invalid_value",values:t.mime,input:n.value.type,inst:e,continue:!t.abort})}}),sV=K("$ZodCheckOverwrite",(e,t)=>{un.init(e,t),e._zod.check=r=>{r.value=t.tx(r.value)}})});var z0,aV=p(()=>{z0=class{constructor(t=[]){this.content=[],this.indent=0,this&&(this.args=t)}indented(t){this.indent+=1,t(this),this.indent-=1}write(t){if(typeof t=="function"){t(this,{execution:"sync"}),t(this,{execution:"async"});return}let n=t.split(`
5
5
  `).filter(s=>s),o=Math.min(...n.map(s=>s.length-s.trimStart().length)),i=n.map(s=>s.slice(o)).map(s=>" ".repeat(this.indent*2)+s);for(let s of i)this.content.push(s)}compile(){let t=Function,r=this?.args,o=[...(this?.content??[""]).map(i=>` ${i}`)];return new t(...r,o.join(`
6
6
  `))}}});var cV,lV=p(()=>{cV={major:4,minor:4,patch:3}});function AV(e){if(e==="")return!0;if(/\s/.test(e)||e.length%4!==0)return!1;try{return atob(e),!0}catch{return!1}}function _Se(e){if(!z$.test(e))return!1;let t=e.replace(/[-_]/g,n=>n==="-"?"+":"/"),r=t.padEnd(Math.ceil(t.length/4)*4,"=");return AV(r)}function wSe(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));return!("typ"in o&&o?.typ!=="JWT"||!o.alg||t&&(!("alg"in o)||o.alg!==t))}catch{return!1}}function cSe(e,t,r){e.issues.length&&t.issues.push(...ca(r,e.issues)),t.value[r]=e.value}function W$(e,t,r,n,o,i){let s=r in n;if(e.issues.length){if(o&&i&&!s)return;t.issues.push(...ca(r,e.issues))}if(!s&&!o){e.issues.length||t.issues.push({code:"invalid_type",expected:"nonoptional",input:void 0,path:[r]});return}e.value===void 0?s&&(t.value[r]=void 0):t.value[r]=e.value}function vSe(e){let t=Object.keys(e.shape);for(let n of t)if(!e.shape?.[n]?._zod?.traits?.has("$ZodType"))throw new Error(`Invalid element at key "${n}": expected a Zod schema`);let r=o4(e.shape);return{...e,keys:t,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(r)}}function ESe(e,t,r,n,o,i){let s=[],a=o.keySet,c=o.catchall._zod,l=c.def.type,u=c.optin==="optional",d=c.optout==="optional";for(let f in t){if(f==="__proto__"||a.has(f))continue;if(l==="never"){s.push(f);continue}let m=c.run({value:t[f],issues:[]},n);m instanceof Promise?e.push(m.then(b=>W$(b,r,f,t,u,d))):W$(m,r,f,t,u,d)}return s.length&&r.issues.push({code:"unrecognized_keys",keys:s,input:t,inst:i}),e.length?Promise.all(e).then(()=>r):r}function lSe(e,t,r,n){for(let i of e)if(i.issues.length===0)return t.value=i.value,t;let o=e.filter(i=>!Bm(i));return o.length===1?(t.value=o[0].value,o[0]):(t.issues.push({code:"invalid_union",input:t.value,inst:r,errors:e.map(i=>i.issues.map(s=>Ps(s,n,yo())))}),t)}function uSe(e,t,r,n){let o=e.filter(i=>i.issues.length===0);return o.length===1?(t.value=o[0].value,t):(o.length===0?t.issues.push({code:"invalid_union",input:t.value,inst:r,errors:e.map(i=>i.issues.map(s=>Ps(s,n,yo())))}):t.issues.push({code:"invalid_union",input:t.value,inst:r,errors:[],inclusive:!1}),t)}function uV(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(Gm(e)&&Gm(t)){let r=Object.keys(t),n=Object.keys(e).filter(i=>r.indexOf(i)!==-1),o={...e,...t};for(let i of n){let s=uV(e[i],t[i]);if(!s.valid)return{valid:!1,mergeErrorPath:[i,...s.mergeErrorPath]};o[i]=s.data}return{valid:!0,data:o}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};let r=[];for(let n=0;n<e.length;n++){let o=e[n],i=t[n],s=uV(o,i);if(!s.valid)return{valid:!1,mergeErrorPath:[n,...s.mergeErrorPath]};r.push(s.data)}return{valid:!0,data:r}}return{valid:!1,mergeErrorPath:[]}}function dSe(e,t,r){let n=new Map,o;for(let a of t.issues)if(a.code==="unrecognized_keys"){o??(o=a);for(let c of a.keys)n.has(c)||n.set(c,{}),n.get(c).l=!0}else e.issues.push(a);for(let a of r.issues)if(a.code==="unrecognized_keys")for(let c of a.keys)n.has(c)||n.set(c,{}),n.get(c).r=!0;else e.issues.push(a);let i=[...n].filter(([,a])=>a.l&&a.r).map(([a])=>a);if(i.length&&o&&e.issues.push({...o,keys:i}),Bm(e))return e;let s=uV(t.value,r.value);if(!s.valid)throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(s.mergeErrorPath)}`);return e.value=s.data,e}function pSe(e,t){for(let r=e.length-1;r>=0;r--)if(e[r]._zod[t]!=="optional")return r+1;return 0}function fSe(e,t,r){e.issues.length&&t.issues.push(...ca(r,e.issues)),t.value[r]=e.value}function mSe(e,t,r,n,o){for(let i=0;i<r.length;i++){let s=e[i],a=i<n.length;if(s.issues.length){if(!a&&i>=o){t.value.length=i;break}t.issues.push(...ca(i,s.issues))}t.value[i]=s.value}for(let i=t.value.length-1;i>=n.length&&(r[i]._zod.optout==="optional"&&t.value[i]===void 0);i--)t.value.length=i;return t}function hSe(e,t,r,n,o,i,s){e.issues.length&&(P0.has(typeof n)?r.issues.push(...ca(n,e.issues)):r.issues.push({code:"invalid_key",origin:"map",input:o,inst:i,issues:e.issues.map(a=>Ps(a,s,yo()))})),t.issues.length&&(P0.has(typeof n)?r.issues.push(...ca(n,t.issues)):r.issues.push({origin:"map",code:"invalid_element",input:o,inst:i,key:n,issues:t.issues.map(a=>Ps(a,s,yo()))})),r.value.set(e.value,t.value)}function gSe(e,t){e.issues.length&&t.issues.push(...e.issues),t.value.add(e.value)}function ySe(e,t){return t===void 0&&(e.issues.length||e.fallback)?{issues:[],value:void 0}:e}function bSe(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}function xSe(e,t){return!e.issues.length&&e.value===void 0&&e.issues.push({code:"invalid_type",expected:"nonoptional",input:e.value,inst:t}),e}function q$(e,t,r){return e.issues.length?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues,fallback:e.fallback},r)}function G$(e,t,r){if(e.issues.length)return e.aborted=!0,e;if((r.direction||"forward")==="forward"){let o=t.transform(e.value,e);return o instanceof Promise?o.then(i=>B$(e,i,t.out,r)):B$(e,o,t.out,r)}else{let o=t.reverseTransform(e.value,e);return o instanceof Promise?o.then(i=>B$(e,i,t.in,r)):B$(e,o,t.in,r)}}function B$(e,t,r,n){return e.issues.length?(e.aborted=!0,e):r._zod.run({value:t,issues:e.issues},n)}function SSe(e){return e.value=Object.freeze(e.value),e}function kSe(e,t,r,n){if(!e){let o={code:"custom",input:r,inst:n,path:[...n._zod.def.path??[]],continue:!n._zod.def.abort};n._zod.def.params&&(o.params=n._zod.def.params),t.issues.push(mk(o))}}var At,Hy,Yr,dV,pV,fV,mV,hV,gV,yV,bV,xV,SV,kV,_V,wV,vV,EV,RV,TV,CV,PV,IV,OV,$V,MV,DV,NV,V$,zV,L0,K$,LV,FV,jV,UV,HV,qV,GV,BV,WV,VV,RSe,KV,F0,ZV,JV,YV,Z$,QV,XV,e6,t6,r6,n6,o6,J$,i6,s6,a6,c6,l6,u6,d6,p6,Y$,j0,f6,m6,h6,g6,y6,b6,x6,S6=p(()=>{H$();Fy();aV();f4();F$();ot();lV();ot();At=K("$ZodType",(e,t)=>{var r;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=cV;let n=[...e._zod.def.checks??[]];e._zod.traits.has("$ZodCheck")&&n.unshift(e);for(let o of n)for(let i of o._zod.onattach)i(e);if(n.length===0)(r=e._zod).deferred??(r.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{let o=(s,a,c)=>{let l=Bm(s),u;for(let d of a){if(d._zod.def.when){if(a4(s)||!d._zod.def.when(s))continue}else if(l)continue;let f=s.issues.length,m=d._zod.check(s);if(m instanceof Promise&&c?.async===!1)throw new Hl;if(u||m instanceof Promise)u=(u??Promise.resolve()).then(async()=>{await m,s.issues.length!==f&&(l||(l=Bm(s,f)))});else{if(s.issues.length===f)continue;l||(l=Bm(s,f))}}return u?u.then(()=>s):s},i=(s,a,c)=>{if(Bm(s))return s.aborted=!0,s;let l=o(a,n,c);if(l instanceof Promise){if(c.async===!1)throw new Hl;return l.then(u=>e._zod.parse(u,c))}return e._zod.parse(l,c)};e._zod.run=(s,a)=>{if(a.skipChecks)return e._zod.parse(s,a);if(a.direction==="backward"){let l=e._zod.parse({value:s.value,issues:[]},{...a,skipChecks:!0});return l instanceof Promise?l.then(u=>i(u,s,a)):i(l,s,a)}let c=e._zod.parse(s,a);if(c instanceof Promise){if(a.async===!1)throw new Hl;return c.then(l=>o(l,n,a))}return o(c,n,a)}}Jt(e,"~standard",()=>({validate:o=>{try{let i=d4(e,o);return i.success?{value:i.data}:{issues:i.error?.issues}}catch{return p4(e,o).then(s=>s.success?{value:s.data}:{issues:s.error?.issues})}},vendor:"zod",version:1}))}),Hy=K("$ZodString",(e,t)=>{At.init(e,t),e._zod.pattern=[...e?._zod.bag?.patterns??[]].pop()??D4(e._zod.bag),e._zod.parse=(r,n)=>{if(t.coerce)try{r.value=String(r.value)}catch{}return typeof r.value=="string"||r.issues.push({expected:"string",code:"invalid_type",input:r.value,inst:e}),r}}),Yr=K("$ZodStringFormat",(e,t)=>{xk.init(e,t),Hy.init(e,t)}),dV=K("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=k4),Yr.init(e,t)}),pV=K("$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 new Error(`Invalid UUID version: "${t.version}"`);t.pattern??(t.pattern=Uy(n))}else t.pattern??(t.pattern=Uy());Yr.init(e,t)}),fV=K("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=_4),Yr.init(e,t)}),mV=K("$ZodURL",(e,t)=>{Yr.init(e,t),e._zod.check=r=>{try{let n=r.value.trim();if(!t.normalize&&t.protocol?.source===I4.source&&!/^https?:\/\//i.test(n)){r.issues.push({code:"invalid_format",format:"url",note:"Invalid URL format",input:r.value,inst:e,continue:!t.abort});return}let o=new URL(n);t.hostname&&(t.hostname.lastIndex=0,t.hostname.test(o.hostname)||r.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:t.hostname.source,input:r.value,inst:e,continue:!t.abort})),t.protocol&&(t.protocol.lastIndex=0,t.protocol.test(o.protocol.endsWith(":")?o.protocol.slice(0,-1):o.protocol)||r.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:t.protocol.source,input:r.value,inst:e,continue:!t.abort})),t.normalize?r.value=o.href:r.value=n;return}catch{r.issues.push({code:"invalid_format",format:"url",input:r.value,inst:e,continue:!t.abort})}}}),hV=K("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=w4()),Yr.init(e,t)}),gV=K("$ZodNanoID",(e,t)=>{t.pattern??(t.pattern=x4),Yr.init(e,t)}),yV=K("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=m4),Yr.init(e,t)}),bV=K("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=h4),Yr.init(e,t)}),xV=K("$ZodULID",(e,t)=>{t.pattern??(t.pattern=g4),Yr.init(e,t)}),SV=K("$ZodXID",(e,t)=>{t.pattern??(t.pattern=y4),Yr.init(e,t)}),kV=K("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=b4),Yr.init(e,t)}),_V=K("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=M4(t)),Yr.init(e,t)}),wV=K("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=O4),Yr.init(e,t)}),vV=K("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=$4(t)),Yr.init(e,t)}),EV=K("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=S4),Yr.init(e,t)}),RV=K("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=v4),Yr.init(e,t),e._zod.bag.format="ipv4"}),TV=K("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=E4),Yr.init(e,t),e._zod.bag.format="ipv6",e._zod.check=r=>{try{new URL(`http://[${r.value}]`)}catch{r.issues.push({code:"invalid_format",format:"ipv6",input:r.value,inst:e,continue:!t.abort})}}}),CV=K("$ZodMAC",(e,t)=>{t.pattern??(t.pattern=R4(t.delimiter)),Yr.init(e,t),e._zod.bag.format="mac"}),PV=K("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=T4),Yr.init(e,t)}),IV=K("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=C4),Yr.init(e,t),e._zod.check=r=>{let n=r.value.split("/");try{if(n.length!==2)throw new Error;let[o,i]=n;if(!i)throw new Error;let s=Number(i);if(`${s}`!==i)throw new Error;if(s<0||s>128)throw new Error;new URL(`http://[${o}]`)}catch{r.issues.push({code:"invalid_format",format:"cidrv6",input:r.value,inst:e,continue:!t.abort})}}});OV=K("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=P4),Yr.init(e,t),e._zod.bag.contentEncoding="base64",e._zod.check=r=>{AV(r.value)||r.issues.push({code:"invalid_format",format:"base64",input:r.value,inst:e,continue:!t.abort})}});$V=K("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=z$),Yr.init(e,t),e._zod.bag.contentEncoding="base64url",e._zod.check=r=>{_Se(r.value)||r.issues.push({code:"invalid_format",format:"base64url",input:r.value,inst:e,continue:!t.abort})}}),MV=K("$ZodE164",(e,t)=>{t.pattern??(t.pattern=A4),Yr.init(e,t)});DV=K("$ZodJWT",(e,t)=>{Yr.init(e,t),e._zod.check=r=>{wSe(r.value,t.alg)||r.issues.push({code:"invalid_format",format:"jwt",input:r.value,inst:e,continue:!t.abort})}}),NV=K("$ZodCustomStringFormat",(e,t)=>{Yr.init(e,t),e._zod.check=r=>{t.fn(r.value)||r.issues.push({code:"invalid_format",format:t.format,input:r.value,inst:e,continue:!t.abort})}}),V$=K("$ZodNumber",(e,t)=>{At.init(e,t),e._zod.pattern=e._zod.bag.pattern??L$,e._zod.parse=(r,n)=>{if(t.coerce)try{r.value=Number(r.value)}catch{}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)?void 0:"Infinity":void 0;return r.issues.push({expected:"number",code:"invalid_type",input:o,inst:e,...i?{received:i}:{}}),r}}),zV=K("$ZodNumberFormat",(e,t)=>{G4.init(e,t),V$.init(e,t)}),L0=K("$ZodBoolean",(e,t)=>{At.init(e,t),e._zod.pattern=L4,e._zod.parse=(r,n)=>{if(t.coerce)try{r.value=!!r.value}catch{}let o=r.value;return typeof o=="boolean"||r.issues.push({expected:"boolean",code:"invalid_type",input:o,inst:e}),r}}),K$=K("$ZodBigInt",(e,t)=>{At.init(e,t),e._zod.pattern=N4,e._zod.parse=(r,n)=>{if(t.coerce)try{r.value=BigInt(r.value)}catch{}return typeof r.value=="bigint"||r.issues.push({expected:"bigint",code:"invalid_type",input:r.value,inst:e}),r}}),LV=K("$ZodBigIntFormat",(e,t)=>{B4.init(e,t),K$.init(e,t)}),FV=K("$ZodSymbol",(e,t)=>{At.init(e,t),e._zod.parse=(r,n)=>{let o=r.value;return typeof o=="symbol"||r.issues.push({expected:"symbol",code:"invalid_type",input:o,inst:e}),r}}),jV=K("$ZodUndefined",(e,t)=>{At.init(e,t),e._zod.pattern=j4,e._zod.values=new Set([void 0]),e._zod.parse=(r,n)=>{let o=r.value;return typeof o>"u"||r.issues.push({expected:"undefined",code:"invalid_type",input:o,inst:e}),r}}),UV=K("$ZodNull",(e,t)=>{At.init(e,t),e._zod.pattern=F4,e._zod.values=new Set([null]),e._zod.parse=(r,n)=>{let o=r.value;return o===null||r.issues.push({expected:"null",code:"invalid_type",input:o,inst:e}),r}}),HV=K("$ZodAny",(e,t)=>{At.init(e,t),e._zod.parse=r=>r}),qV=K("$ZodUnknown",(e,t)=>{At.init(e,t),e._zod.parse=r=>r}),GV=K("$ZodNever",(e,t)=>{At.init(e,t),e._zod.parse=(r,n)=>(r.issues.push({expected:"never",code:"invalid_type",input:r.value,inst:e}),r)}),BV=K("$ZodVoid",(e,t)=>{At.init(e,t),e._zod.parse=(r,n)=>{let o=r.value;return typeof o>"u"||r.issues.push({expected:"void",code:"invalid_type",input:o,inst:e}),r}}),WV=K("$ZodDate",(e,t)=>{At.init(e,t),e._zod.parse=(r,n)=>{if(t.coerce)try{r.value=new Date(r.value)}catch{}let o=r.value,i=o instanceof Date;return i&&!Number.isNaN(o.getTime())||r.issues.push({expected:"date",code:"invalid_type",input:o,...i?{received:"Invalid Date"}:{},inst:e}),r}});VV=K("$ZodArray",(e,t)=>{At.init(e,t),e._zod.parse=(r,n)=>{let o=r.value;if(!Array.isArray(o))return r.issues.push({expected:"array",code:"invalid_type",input:o,inst:e}),r;r.value=Array(o.length);let i=[];for(let s=0;s<o.length;s++){let a=o[s],c=t.element._zod.run({value:a,issues:[]},n);c instanceof Promise?i.push(c.then(l=>cSe(l,r,s))):cSe(c,r,s)}return i.length?Promise.all(i).then(()=>r):r}});RSe=K("$ZodObject",(e,t)=>{if(At.init(e,t),!Object.getOwnPropertyDescriptor(t,"shape")?.get){let a=t.shape;Object.defineProperty(t,"shape",{get:()=>{let c={...a};return Object.defineProperty(t,"shape",{value:c}),c}})}let n=fk(()=>vSe(t));Jt(e._zod,"propValues",()=>{let a=t.shape,c={};for(let l in a){let u=a[l]._zod;if(u.values){c[l]??(c[l]=new Set);for(let d of u.values)c[l].add(d)}}return c});let o=jy,i=t.catchall,s;e._zod.parse=(a,c)=>{s??(s=n.value);let l=a.value;if(!o(l))return a.issues.push({expected:"object",code:"invalid_type",input:l,inst:e}),a;a.value={};let u=[],d=s.shape;for(let f of s.keys){let m=d[f],b=m._zod.optin==="optional",S=m._zod.optout==="optional",_=m._zod.run({value:l[f],issues:[]},c);_ instanceof Promise?u.push(_.then(E=>W$(E,a,f,l,b,S))):W$(_,a,f,l,b,S)}return i?ESe(u,l,a,c,n.value,e):u.length?Promise.all(u).then(()=>a):a}}),KV=K("$ZodObjectJIT",(e,t)=>{RSe.init(e,t);let r=e._zod.parse,n=fk(()=>vSe(t)),o=f=>{let m=new z0(["shape","payload","ctx"]),b=n.value,S=A=>{let $=E$(A);return`shape[${$}]._zod.run({ value: input[${$}], issues: [] }, ctx)`};m.write("const input = payload.value;");let _=Object.create(null),E=0;for(let A of b.keys)_[A]=`key_${E++}`;m.write("const newResult = {};");for(let A of b.keys){let $=_[A],M=E$(A),L=f[A],F=L?._zod?.optin==="optional",H=L?._zod?.optout==="optional";m.write(`const ${$} = ${S(A)};`),F&&H?m.write(`
@@ -436,7 +436,7 @@ naming the step that went inert.
436
436
  --demand-deadline-ms <n> how long the probe waits for the daemon's poll and
437
437
  the Worker it justifies (default: 60000)
438
438
  `});VW();import{connect as f0t}from"node:net";import{Readable as m0t,Writable as h0t}from"node:stream";var Me={initialize:"initialize",authenticate:"authenticate",providers_list:"providers/list",providers_set:"providers/set",providers_disable:"providers/disable",session_new:"session/new",session_load:"session/load",session_set_mode:"session/set_mode",session_set_config_option:"session/set_config_option",session_prompt:"session/prompt",session_cancel:"session/cancel",mcp_message:"mcp/message",session_list:"session/list",session_delete:"session/delete",session_fork:"session/fork",session_resume:"session/resume",session_close:"session/close",logout:"logout",nes_start:"nes/start",nes_suggest:"nes/suggest",nes_accept:"nes/accept",nes_reject:"nes/reject",nes_close:"nes/close",document_did_open:"document/didOpen",document_did_change:"document/didChange",document_did_close:"document/didClose",document_did_save:"document/didSave",document_did_focus:"document/didFocus"},ir={session_request_permission:"session/request_permission",session_update:"session/update",fs_write_text_file:"fs/write_text_file",fs_read_text_file:"fs/read_text_file",terminal_create:"terminal/create",terminal_output:"terminal/output",terminal_release:"terminal/release",terminal_wait_for_exit:"terminal/wait_for_exit",terminal_kill:"terminal/kill",mcp_connect:"mcp/connect",mcp_message:"mcp/message",mcp_disconnect:"mcp/disconnect",elicitation_create:"elicitation/create",elicitation_complete:"elicitation/complete"},KW={cancel_request:"$/cancel_request"};cR();cR();var Wwe=Symbol("skippedItem");function y(e,t){return e.catch(t)}function Kn(e,t){let r=e.catch(t);return ki.unknown().transform((n,o)=>n!==void 0?r.parse(n):(o.addIssue({code:"custom",message:"Required value is missing"}),ki.NEVER))}function Vwe(e,t){if(e===null||typeof e!="object"||Array.isArray(e))return;let r=e[t];return typeof r=="string"?r:void 0}function $n(e,t,r){return e.superRefine((n,o)=>{let i=Vwe(n,t);i!==void 0&&r.includes(i)&&o.addIssue({code:"custom",path:[t],message:`${t} ${JSON.stringify(i)} is reserved by a known variant, but the value does not match that variant's schema`})})}function Mn(e,t,r){return ki.unknown().transform((n,o)=>{let i=e.safeParse(n);if(!i.success){for(let c of i.error.issues)o.addIssue({...c,input:n});return ki.NEVER}let s=i.data,a=Vwe(n,t);if(a!==void 0&&!r.includes(a)){let c=n;for(let[l,u]of Object.entries(c))l!=="__proto__"&&(Object.hasOwn(s,l)||(s[l]=u))}return s})}function Ve(e){return ki.array(e.catch(Wwe)).transform(t=>t.filter(r=>r!==Wwe))}var Ym=be([rt(),g()]).nullable(),Ar=g(),sZ=x({sessionId:Ar,path:g(),content:g(),_meta:y(C(g(),T()).nullish(),()=>{})}),aZ=x({sessionId:Ar,path:g(),line:y(fr().gte(0).max(4294967295,{error:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),()=>{}),limit:y(fr().gte(0).max(4294967295,{error:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),()=>{}),_meta:y(C(g(),T()).nullish(),()=>{})}),cZ=g(),Kwe=be([O("read"),O("edit"),O("delete"),O("move"),O("search"),O("execute"),O("think"),O("fetch"),O("switch_mode"),O("other")]),Zwe=be([O("pending"),O("in_progress"),O("completed"),O("failed")]),cmt=be([O("assistant"),O("user")]),lR=x({audience:y(Ve(cmt).nullish(),()=>{}),lastModified:y(g().nullish(),()=>{}),priority:y(rt().nullish(),()=>{}),_meta:y(C(g(),T()).nullish(),()=>{})}),lmt=x({annotations:y(lR.nullish(),()=>{}),text:g(),_meta:y(C(g(),T()).nullish(),()=>{})}),umt=x({annotations:y(lR.nullish(),()=>{}),data:g(),mimeType:g(),uri:y(g().nullish(),()=>{}),_meta:y(C(g(),T()).nullish(),()=>{})}),dmt=x({annotations:y(lR.nullish(),()=>{}),data:g(),mimeType:g(),_meta:y(C(g(),T()).nullish(),()=>{})}),pmt=x({annotations:y(lR.nullish(),()=>{}),description:y(g().nullish(),()=>{}),mimeType:y(g().nullish(),()=>{}),name:g(),size:y(rt().nullish(),()=>{}),title:y(g().nullish(),()=>{}),uri:g(),_meta:y(C(g(),T()).nullish(),()=>{})}),fmt=x({mimeType:y(g().nullish(),()=>{}),text:g(),uri:g(),_meta:y(C(g(),T()).nullish(),()=>{})}),mmt=x({blob:g(),mimeType:y(g().nullish(),()=>{}),uri:g(),_meta:y(C(g(),T()).nullish(),()=>{})}),hmt=be([fmt,mmt]),gmt=x({annotations:y(lR.nullish(),()=>{}),resource:hmt,_meta:y(C(g(),T()).nullish(),()=>{})}),lZ=be([lmt.and(x({type:O("text")})),umt.and(x({type:O("image")})),dmt.and(x({type:O("audio")})),pmt.and(x({type:O("resource_link")})),gmt.and(x({type:O("resource")}))]),ymt=x({content:lZ,_meta:y(C(g(),T()).nullish(),()=>{})}),bmt=x({path:g(),oldText:y(g().nullish(),()=>{}),newText:g(),_meta:y(C(g(),T()).nullish(),()=>{})}),Hk=g(),xmt=x({terminalId:Hk,_meta:y(C(g(),T()).nullish(),()=>{})}),Jwe=be([ymt.and(x({type:O("content")})),bmt.and(x({type:O("diff")})),xmt.and(x({type:O("terminal")}))]),Ywe=x({path:g(),line:y(fr().gte(0).max(4294967295,{error:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),()=>{}),_meta:y(C(g(),T()).nullish(),()=>{})}),Qwe=x({toolCallId:cZ,kind:y(Kwe.nullish(),()=>{}),status:y(Zwe.nullish(),()=>{}),title:y(g().nullish(),()=>{}),name:y(g().nullish(),()=>{}),content:y(Ve(Jwe).nullish(),()=>{}),locations:y(Ve(Ywe).nullish(),()=>{}),rawInput:y(T().optional(),()=>{}),rawOutput:y(T().optional(),()=>{}),_meta:y(C(g(),T()).nullish(),()=>{})}),Xwe=g(),Smt=be([O("allow_once"),O("allow_always"),O("reject_once"),O("reject_always")]),kmt=x({optionId:Xwe,name:g(),kind:Smt,_meta:y(C(g(),T()).nullish(),()=>{})}),uZ=x({sessionId:Ar,toolCall:Qwe,options:gt(kmt),_meta:y(C(g(),T()).nullish(),()=>{})}),eve=x({name:g(),value:g(),_meta:y(C(g(),T()).nullish(),()=>{})}),dZ=x({sessionId:Ar,command:g(),args:y(Ve(g()).optional(),()=>[]),env:y(Ve(eve).optional(),()=>[]),cwd:y(g().nullish(),()=>{}),outputByteLimit:y(rt().nullish(),()=>{}),_meta:y(C(g(),T()).nullish(),()=>{})}),pZ=x({sessionId:Ar,terminalId:Hk,_meta:y(C(g(),T()).nullish(),()=>{})}),fZ=x({sessionId:Ar,terminalId:Hk,_meta:y(C(g(),T()).nullish(),()=>{})}),mZ=x({sessionId:Ar,terminalId:Hk,_meta:y(C(g(),T()).nullish(),()=>{})}),hZ=x({sessionId:Ar,terminalId:Hk,_meta:y(C(g(),T()).nullish(),()=>{})}),uR=x({sessionId:Ar,toolCallId:y(cZ.nullish(),()=>{})}),dR=x({requestId:Ym}),_mt=O("object"),wmt=be([O("email"),O("uri"),O("date"),O("date-time")]),tve=x({const:g(),title:g(),description:y(g().nullish(),()=>{}),_meta:y(C(g(),T()).nullish(),()=>{})}),gZ=x({title:y(g().nullish(),()=>{}),description:y(g().nullish(),()=>{}),minLength:fr().gte(0).max(4294967295,{error:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),maxLength:fr().gte(0).max(4294967295,{error:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),pattern:g().nullish(),format:wmt.nullish(),default:y(g().nullish(),()=>{}),enum:gt(g()).nullish(),oneOf:gt(tve).nullish(),_meta:y(C(g(),T()).nullish(),()=>{})}),yZ=x({title:y(g().nullish(),()=>{}),description:y(g().nullish(),()=>{}),minimum:rt().nullish(),maximum:rt().nullish(),default:y(rt().nullish(),()=>{}),_meta:y(C(g(),T()).nullish(),()=>{})}),bZ=x({title:y(g().nullish(),()=>{}),description:y(g().nullish(),()=>{}),minimum:rt().nullish(),maximum:rt().nullish(),default:y(rt().nullish(),()=>{}),_meta:y(C(g(),T()).nullish(),()=>{})}),xZ=x({title:y(g().nullish(),()=>{}),description:y(g().nullish(),()=>{}),default:y(mr().nullish(),()=>{}),_meta:y(C(g(),T()).nullish(),()=>{})}),SZ=x({enum:gt(g()),_meta:y(C(g(),T()).nullish(),()=>{})}),rve=x({anyOf:gt(tve),_meta:y(C(g(),T()).nullish(),()=>{})}),vmt=Mn(be([SZ.and(x({type:O("string")})),$n(x({type:g()}),"type",["string"]),rve]),"type",["string"]),kZ=x({title:y(g().nullish(),()=>{}),description:y(g().nullish(),()=>{}),minItems:rt().nullish(),maxItems:rt().nullish(),items:vmt,default:y(Ve(g()).nullish(),()=>{}),_meta:y(C(g(),T()).nullish(),()=>{})}),Emt=Mn(be([gZ.and(x({type:O("string")})),yZ.and(x({type:O("number")})),bZ.and(x({type:O("integer")})),xZ.and(x({type:O("boolean")})),kZ.and(x({type:O("array")})),$n(x({type:g()}),"type",["array","boolean","integer","number","string"])]),"type",["array","boolean","integer","number","string"]),Rmt=x({type:y(_mt.optional().default("object"),()=>"object"),title:y(g().nullish(),()=>{}),properties:C(g(),Emt).optional().default({}),required:gt(g()).nullish(),description:y(g().nullish(),()=>{}),_meta:y(C(g(),T()).nullish(),()=>{})}),_Z=Ho(be([uR,dR]),x({requestedSchema:Rmt})),nve=g(),wZ=Ho(be([uR,dR]),x({elicitationId:nve,url:_r()})),vZ=Mn(Ho(be([_Z.and(x({mode:O("form")})),wZ.and(x({mode:O("url")})),$n(Ho(be([uR,dR]),x({mode:g()})),"mode",["form","url"])]),x({message:g(),_meta:y(C(g(),T()).nullish(),()=>{})})),"mode",["form","url"]),ove=g(),Tmt=x({serverId:ove,_meta:y(C(g(),T()).nullish(),()=>{})}),lD=g(),ive=x({connectionId:lD,method:g(),params:C(g(),T()).nullish(),_meta:y(C(g(),T()).nullish(),()=>{})}),Cmt=x({connectionId:lD,_meta:y(C(g(),T()).nullish(),()=>{})}),sve=T(),Idr=x({id:Ym,method:g(),params:be([sZ,aZ,uZ,dZ,pZ,fZ,mZ,hZ,vZ,Tmt,ive,Cmt,sve]).nullish()}),ave=fr().gte(0).lte(65535),Pmt=x({image:y(mr().optional().default(!1),()=>!1),audio:y(mr().optional().default(!1),()=>!1),embeddedContext:y(mr().optional().default(!1),()=>!1),_meta:y(C(g(),T()).nullish(),()=>{})}),Imt=x({http:y(mr().optional().default(!1),()=>!1),sse:y(mr().optional().default(!1),()=>!1),acp:y(mr().optional().default(!1),()=>!1),_meta:y(C(g(),T()).nullish(),()=>{})}),Amt=x({_meta:y(C(g(),T()).nullish(),()=>{})}),Omt=x({_meta:y(C(g(),T()).nullish(),()=>{})}),$mt=x({_meta:y(C(g(),T()).nullish(),()=>{})}),Mmt=x({_meta:y(C(g(),T()).nullish(),()=>{})}),Dmt=x({_meta:y(C(g(),T()).nullish(),()=>{})}),Nmt=x({_meta:y(C(g(),T()).nullish(),()=>{})}),zmt=x({list:y(Amt.nullish(),()=>{}),delete:y(Omt.nullish(),()=>{}),additionalDirectories:y($mt.nullish(),()=>{}),fork:y(Mmt.nullish(),()=>{}),resume:y(Dmt.nullish(),()=>{}),close:y(Nmt.nullish(),()=>{}),_meta:y(C(g(),T()).nullish(),()=>{})}),Lmt=x({_meta:y(C(g(),T()).nullish(),()=>{})}),Fmt=x({logout:y(Lmt.nullish(),()=>{}),_meta:y(C(g(),T()).nullish(),()=>{})}),jmt=x({_meta:y(C(g(),T()).nullish(),()=>{})}),Umt=x({_meta:y(C(g(),T()).nullish(),()=>{})}),Hmt=be([O("full"),O("incremental")]),qmt=x({syncKind:Hmt,_meta:y(C(g(),T()).nullish(),()=>{})}),Gmt=x({_meta:y(C(g(),T()).nullish(),()=>{})}),Bmt=x({_meta:y(C(g(),T()).nullish(),()=>{})}),Wmt=x({_meta:y(C(g(),T()).nullish(),()=>{})}),Vmt=x({didOpen:y(Umt.nullish(),()=>{}),didChange:y(qmt.nullish(),()=>{}),didClose:y(Gmt.nullish(),()=>{}),didSave:y(Bmt.nullish(),()=>{}),didFocus:y(Wmt.nullish(),()=>{}),_meta:y(C(g(),T()).nullish(),()=>{})}),Kmt=x({document:y(Vmt.nullish(),()=>{}),_meta:y(C(g(),T()).nullish(),()=>{})}),Zmt=x({maxCount:y(fr().gte(0).max(4294967295,{error:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),()=>{}),_meta:y(C(g(),T()).nullish(),()=>{})}),Jmt=x({_meta:y(C(g(),T()).nullish(),()=>{})}),Ymt=x({maxCount:y(fr().gte(0).max(4294967295,{error:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),()=>{}),_meta:y(C(g(),T()).nullish(),()=>{})}),Qmt=x({maxCount:y(fr().gte(0).max(4294967295,{error:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),()=>{}),_meta:y(C(g(),T()).nullish(),()=>{})}),Xmt=x({_meta:y(C(g(),T()).nullish(),()=>{})}),eht=x({_meta:y(C(g(),T()).nullish(),()=>{})}),tht=x({recentFiles:y(Zmt.nullish(),()=>{}),relatedSnippets:y(Jmt.nullish(),()=>{}),editHistory:y(Ymt.nullish(),()=>{}),userActions:y(Qmt.nullish(),()=>{}),openFiles:y(Xmt.nullish(),()=>{}),diagnostics:y(eht.nullish(),()=>{}),_meta:y(C(g(),T()).nullish(),()=>{})}),rht=x({events:y(Kmt.nullish(),()=>{}),context:y(tht.nullish(),()=>{}),_meta:y(C(g(),T()).nullish(),()=>{})}),cve=be([O("utf-16"),O("utf-32"),O("utf-8")]),nht=x({loadSession:y(mr().optional().default(!1),()=>!1),promptCapabilities:y(Pmt.optional().default({image:!1,audio:!1,embeddedContext:!1}),()=>({image:!1,audio:!1,embeddedContext:!1})),mcpCapabilities:y(Imt.optional().default({http:!1,sse:!1,acp:!1}),()=>({http:!1,sse:!1,acp:!1})),sessionCapabilities:y(zmt.optional().default({}),()=>({})),auth:y(Fmt.optional().default({}),()=>({})),providers:y(jmt.nullish(),()=>{}),nes:y(rht.nullish(),()=>{}),positionEncoding:y(cve.nullish(),()=>{}),_meta:y(C(g(),T()).nullish(),()=>{})}),uD=g(),oht=x({name:g(),label:y(g().nullish(),()=>{}),secret:y(mr().optional().default(!0),()=>!0),optional:y(mr().optional().default(!1),()=>!1),_meta:y(C(g(),T()).nullish(),()=>{})}),iht=x({id:uD,name:g(),description:y(g().nullish(),()=>{}),vars:Kn(Ve(oht),()=>[]),link:y(g().nullish(),()=>{}),_meta:y(C(g(),T()).nullish(),()=>{})}),sht=x({id:uD,name:g(),description:y(g().nullish(),()=>{}),args:y(Ve(g()).optional(),()=>[]),env:y(C(g(),g()).optional(),()=>{}),_meta:y(C(g(),T()).nullish(),()=>{})}),aht=x({id:uD,name:g(),description:y(g().nullish(),()=>{}),_meta:y(C(g(),T()).nullish(),()=>{})}),cht=be([iht.and(x({type:O("env_var")})),sht.and(x({type:O("terminal")})),aht]),lve=x({name:g(),title:y(g().nullish(),()=>{}),version:g(),_meta:y(C(g(),T()).nullish(),()=>{})}),lht=x({protocolVersion:ave,agentCapabilities:y(nht.optional().default({loadSession:!1,promptCapabilities:{image:!1,audio:!1,embeddedContext:!1},mcpCapabilities:{http:!1,sse:!1,acp:!1},sessionCapabilities:{},auth:{}}),()=>({loadSession:!1,promptCapabilities:{image:!1,audio:!1,embeddedContext:!1},mcpCapabilities:{http:!1,sse:!1,acp:!1},sessionCapabilities:{},auth:{}})),authMethods:y(Ve(cht).optional().default([]),()=>[]),agentInfo:y(lve.nullish(),()=>{}),_meta:y(C(g(),T()).nullish(),()=>{})}),uht=x({_meta:y(C(g(),T()).nullish(),()=>{})}),EZ=g(),RZ=be([O("anthropic"),O("openai"),O("azure"),O("vertex"),O("bedrock"),g()]),dht=x({apiType:RZ,baseUrl:g(),_meta:y(C(g(),T()).nullish(),()=>{})}),pht=x({providerId:EZ,supported:Kn(Ve(RZ),()=>[]),required:mr(),current:dht.nullish(),_meta:y(C(g(),T()).nullish(),()=>{})}),fht=x({providers:gt(pht),_meta:y(C(g(),T()).nullish(),()=>{})}),mht=x({_meta:y(C(g(),T()).nullish(),()=>{})}),hht=x({_meta:y(C(g(),T()).nullish(),()=>{})}),ght=x({_meta:y(C(g(),T()).nullish(),()=>{})}),dD=g(),yht=x({id:dD,name:g(),description:y(g().nullish(),()=>{}),_meta:y(C(g(),T()).nullish(),()=>{})}),pD=x({currentModeId:dD,availableModes:Kn(Ve(yht),()=>[]),_meta:y(C(g(),T()).nullish(),()=>{})}),uve=g(),bht=be([O("mode"),O("model"),O("model_config"),O("thought_level"),g()]),TZ=g(),dve=x({value:TZ,name:g(),description:y(g().nullish(),()=>{}),_meta:y(C(g(),T()).nullish(),()=>{})}),xht=g(),Sht=x({group:xht,name:g(),options:Kn(Ve(dve),()=>[]),_meta:y(C(g(),T()).nullish(),()=>{})}),kht=be([gt(dve),gt(Sht)]),_ht=x({currentValue:TZ,options:kht}),wht=x({currentValue:mr()}),qk=Ho(be([_ht.and(x({type:O("select")})),wht.and(x({type:O("boolean")}))]),x({id:uve,name:g(),description:y(g().nullish(),()=>{}),category:y(bht.nullish(),()=>{}),_meta:y(C(g(),T()).nullish(),()=>{})})),vht=x({sessionId:Ar,modes:y(pD.nullish(),()=>{}),configOptions:y(Ve(qk).nullish(),()=>{}),_meta:y(C(g(),T()).nullish(),()=>{})}),Eht=x({modes:y(pD.nullish(),()=>{}),configOptions:y(Ve(qk).nullish(),()=>{}),_meta:y(C(g(),T()).nullish(),()=>{})}),Rht=x({sessionId:Ar,cwd:g(),additionalDirectories:y(Ve(g()).optional(),()=>[]),title:y(g().nullish(),()=>{}),updatedAt:y(g().nullish(),()=>{}),_meta:y(C(g(),T()).nullish(),()=>{})}),Tht=x({sessions:Kn(Ve(Rht),()=>[]),nextCursor:y(g().nullish(),()=>{}),_meta:y(C(g(),T()).nullish(),()=>{})}),Cht=x({_meta:y(C(g(),T()).nullish(),()=>{})}),Pht=x({sessionId:Ar,modes:y(pD.nullish(),()=>{}),configOptions:y(Ve(qk).nullish(),()=>{}),_meta:y(C(g(),T()).nullish(),()=>{})}),Iht=x({modes:y(pD.nullish(),()=>{}),configOptions:y(Ve(qk).nullish(),()=>{}),_meta:y(C(g(),T()).nullish(),()=>{})}),Aht=x({_meta:y(C(g(),T()).nullish(),()=>{})}),Oht=x({_meta:y(C(g(),T()).nullish(),()=>{})}),$ht=x({configOptions:Kn(Ve(qk),()=>[]),_meta:y(C(g(),T()).nullish(),()=>{})}),Mht=be([O("end_turn"),O("max_tokens"),O("max_turn_requests"),O("refusal"),O("cancelled")]),Dht=x({totalTokens:rt(),inputTokens:rt(),outputTokens:rt(),thoughtTokens:y(rt().nullish(),()=>{}),cachedReadTokens:y(rt().nullish(),()=>{}),cachedWriteTokens:y(rt().nullish(),()=>{}),_meta:y(C(g(),T()).nullish(),()=>{})}),Nht=x({stopReason:Mht,usage:y(Dht.nullish(),()=>{}),_meta:y(C(g(),T()).nullish(),()=>{})}),zht=x({sessionId:Ar,_meta:y(C(g(),T()).nullish(),()=>{})}),Gk=g(),Qm=x({line:fr().gte(0).max(4294967295,{error:"Invalid value: Expected uint32 to be <= 4294967295"}),character:fr().gte(0).max(4294967295,{error:"Invalid value: Expected uint32 to be <= 4294967295"}),_meta:y(C(g(),T()).nullish(),()=>{})}),Bk=x({start:Qm,end:Qm,_meta:y(C(g(),T()).nullish(),()=>{})}),Lht=x({range:Bk,newText:g(),_meta:y(C(g(),T()).nullish(),()=>{})}),Fht=x({id:Gk,uri:g(),edits:gt(Lht),cursorPosition:y(Qm.nullish(),()=>{}),_meta:y(C(g(),T()).nullish(),()=>{})}),jht=x({id:Gk,uri:g(),position:Qm,_meta:y(C(g(),T()).nullish(),()=>{})}),Uht=x({id:Gk,uri:g(),position:Qm,newName:g(),_meta:y(C(g(),T()).nullish(),()=>{})}),Hht=x({id:Gk,uri:g(),search:g(),replace:g(),isRegex:mr().nullish(),_meta:y(C(g(),T()).nullish(),()=>{})}),qht=be([Fht.and(x({kind:O("edit")})),jht.and(x({kind:O("jump")})),Uht.and(x({kind:O("rename")})),Hht.and(x({kind:O("searchAndReplace")}))]),Ght=x({suggestions:gt(qht),_meta:y(C(g(),T()).nullish(),()=>{})}),Bht=x({_meta:y(C(g(),T()).nullish(),()=>{})}),pve=T(),fve=T(),Wht=be([O(-32700),O(-32600),O(-32601),O(-32602),O(-32603),O(-32800),O(-32e3),O(-32002),fr().min(-2147483648,{error:"Invalid value: Expected int32 to be >= -2147483648"}).max(2147483647,{error:"Invalid value: Expected int32 to be <= 2147483647"})]),mve=x({code:Wht,message:g(),data:y(T().optional(),()=>{})}),Adr=be([x({id:Ym,result:be([lht,uht,fht,mht,hht,ght,vht,Eht,Tht,Cht,Pht,Iht,Aht,Oht,$ht,Nht,zht,Ght,Bht,pve,fve])}),x({id:Ym,error:mve})]),Vht=g(),oZ=x({content:lZ,messageId:y(Vht.nullish(),()=>{}),_meta:y(C(g(),T()).nullish(),()=>{})}),Kht=x({toolCallId:cZ,title:g(),name:y(g().nullish(),()=>{}),kind:y(Kwe.optional(),()=>{}),status:y(Zwe.optional(),()=>{}),content:y(Ve(Jwe).optional(),()=>[]),locations:y(Ve(Ywe).optional(),()=>[]),rawInput:y(T().optional(),()=>{}),rawOutput:y(T().optional(),()=>{}),_meta:y(C(g(),T()).nullish(),()=>{})}),Zht=be([O("high"),O("medium"),O("low")]),Jht=be([O("pending"),O("in_progress"),O("completed")]),hve=x({content:g(),priority:Zht,status:Jht,_meta:y(C(g(),T()).nullish(),()=>{})}),Yht=x({entries:Kn(Ve(hve),()=>[]),_meta:y(C(g(),T()).nullish(),()=>{})}),fD=g(),Qht=x({planId:fD,entries:Kn(Ve(hve),()=>[]),_meta:y(C(g(),T()).nullish(),()=>{})}),Xht=x({planId:fD,uri:g(),_meta:y(C(g(),T()).nullish(),()=>{})}),egt=x({planId:fD,content:g(),_meta:y(C(g(),T()).nullish(),()=>{})}),tgt=be([Qht.and(x({type:O("items")})),Xht.and(x({type:O("file")})),egt.and(x({type:O("markdown")}))]),rgt=x({plan:tgt,_meta:y(C(g(),T()).nullish(),()=>{})}),ngt=x({planId:fD,_meta:y(C(g(),T()).nullish(),()=>{})}),ogt=x({hint:g(),_meta:y(C(g(),T()).nullish(),()=>{})}),igt=ogt,sgt=x({name:g(),description:g(),input:y(igt.nullish(),()=>{}),_meta:y(C(g(),T()).nullish(),()=>{})}),agt=x({availableCommands:Kn(Ve(sgt),()=>[]),_meta:y(C(g(),T()).nullish(),()=>{})}),cgt=x({currentModeId:dD,_meta:y(C(g(),T()).nullish(),()=>{})}),lgt=x({configOptions:Kn(Ve(qk),()=>[]),_meta:y(C(g(),T()).nullish(),()=>{})}),ugt=x({title:y(g().nullish(),()=>{}),updatedAt:y(g().nullish(),()=>{}),_meta:y(C(g(),T()).nullish(),()=>{})}),dgt=x({amount:rt(),currency:g(),_meta:y(C(g(),T()).nullish(),()=>{})}),pgt=x({used:rt(),size:rt(),cost:y(dgt.nullish(),()=>{}),_meta:y(C(g(),T()).nullish(),()=>{})}),fgt=be([oZ.and(x({sessionUpdate:O("user_message_chunk")})),oZ.and(x({sessionUpdate:O("agent_message_chunk")})),oZ.and(x({sessionUpdate:O("agent_thought_chunk")})),Kht.and(x({sessionUpdate:O("tool_call")})),Qwe.and(x({sessionUpdate:O("tool_call_update")})),Yht.and(x({sessionUpdate:O("plan")})),rgt.and(x({sessionUpdate:O("plan_update")})),ngt.and(x({sessionUpdate:O("plan_removed")})),agt.and(x({sessionUpdate:O("available_commands_update")})),cgt.and(x({sessionUpdate:O("current_mode_update")})),lgt.and(x({sessionUpdate:O("config_option_update")})),ugt.and(x({sessionUpdate:O("session_info_update")})),pgt.and(x({sessionUpdate:O("usage_update")}))]),mD=x({sessionId:Ar,update:fgt,_meta:y(C(g(),T()).nullish(),()=>{})}),CZ=x({elicitationId:nve,_meta:y(C(g(),T()).nullish(),()=>{})}),gve=x({connectionId:lD,method:g(),params:y(C(g(),T()).nullish(),()=>{}),_meta:y(C(g(),T()).nullish(),()=>{})}),yve=T(),Odr=x({method:g(),params:be([mD,CZ,gve,yve]).nullish()}),mgt=x({readTextFile:y(mr().optional().default(!1),()=>!1),writeTextFile:y(mr().optional().default(!1),()=>!1),_meta:y(C(g(),T()).nullish(),()=>{})}),hgt=x({_meta:y(C(g(),T()).nullish(),()=>{})}),ggt=x({boolean:y(hgt.nullish(),()=>{}),_meta:y(C(g(),T()).nullish(),()=>{})}),ygt=x({configOptions:y(ggt.nullish(),()=>{}),_meta:y(C(g(),T()).nullish(),()=>{})}),bgt=x({_meta:y(C(g(),T()).nullish(),()=>{})}),xgt=x({terminal:y(mr().optional().default(!1),()=>!1),_meta:y(C(g(),T()).nullish(),()=>{})}),Sgt=x({_meta:y(C(g(),T()).nullish(),()=>{})}),kgt=x({_meta:y(C(g(),T()).nullish(),()=>{})}),_gt=x({form:y(Sgt.nullish(),()=>{}),url:y(kgt.nullish(),()=>{}),_meta:y(C(g(),T()).nullish(),()=>{})}),wgt=x({_meta:y(C(g(),T()).nullish(),()=>{})}),vgt=x({_meta:y(C(g(),T()).nullish(),()=>{})}),Egt=x({_meta:y(C(g(),T()).nullish(),()=>{})}),Rgt=x({jump:y(wgt.nullish(),()=>{}),rename:y(vgt.nullish(),()=>{}),searchAndReplace:y(Egt.nullish(),()=>{}),_meta:y(C(g(),T()).nullish(),()=>{})}),Tgt=x({fs:y(mgt.optional().default({readTextFile:!1,writeTextFile:!1}),()=>({readTextFile:!1,writeTextFile:!1})),terminal:y(mr().optional().default(!1),()=>!1),session:y(ygt.nullish(),()=>{}),plan:y(bgt.nullish(),()=>{}),auth:y(xgt.optional().default({terminal:!1}),()=>({terminal:!1})),elicitation:y(_gt.nullish(),()=>{}),nes:y(Rgt.nullish(),()=>{}),positionEncodings:y(Ve(cve).optional(),()=>[]),_meta:y(C(g(),T()).nullish(),()=>{})}),hD=x({protocolVersion:ave,clientCapabilities:y(Tgt.optional().default({fs:{readTextFile:!1,writeTextFile:!1},terminal:!1,auth:{terminal:!1}}),()=>({fs:{readTextFile:!1,writeTextFile:!1},terminal:!1,auth:{terminal:!1}})),clientInfo:y(lve.nullish(),()=>{}),_meta:y(C(g(),T()).nullish(),()=>{})}),PZ=x({methodId:uD,_meta:y(C(g(),T()).nullish(),()=>{})}),IZ=x({_meta:y(C(g(),T()).nullish(),()=>{})}),AZ=x({providerId:EZ,apiType:RZ,baseUrl:g(),headers:C(g(),g()).optional(),_meta:y(C(g(),T()).nullish(),()=>{})}),OZ=x({providerId:EZ,_meta:y(C(g(),T()).nullish(),()=>{})}),$Z=x({_meta:y(C(g(),T()).nullish(),()=>{})}),bve=x({name:g(),value:g(),_meta:y(C(g(),T()).nullish(),()=>{})}),Cgt=x({name:g(),url:g(),headers:gt(bve),_meta:y(C(g(),T()).nullish(),()=>{})}),Pgt=x({name:g(),url:g(),headers:gt(bve),_meta:y(C(g(),T()).nullish(),()=>{})}),Igt=x({name:g(),serverId:ove,_meta:y(C(g(),T()).nullish(),()=>{})}),Agt=x({name:g(),command:g(),args:gt(g()),env:gt(eve),_meta:y(C(g(),T()).nullish(),()=>{})}),gD=be([Cgt.and(x({type:O("http")})),Pgt.and(x({type:O("sse")})),Igt.and(x({type:O("acp")})),Agt]),MZ=x({cwd:g(),additionalDirectories:y(Ve(g()).optional(),()=>[]),mcpServers:Kn(Ve(gD),()=>[]),_meta:y(C(g(),T()).nullish(),()=>{})}),DZ=x({mcpServers:Kn(Ve(gD),()=>[]),cwd:g(),additionalDirectories:y(Ve(g()).optional(),()=>[]),sessionId:Ar,_meta:y(C(g(),T()).nullish(),()=>{})}),NZ=x({cwd:g().nullish(),cursor:g().nullish(),_meta:y(C(g(),T()).nullish(),()=>{})}),zZ=x({sessionId:Ar,_meta:y(C(g(),T()).nullish(),()=>{})}),LZ=x({sessionId:Ar,cwd:g(),additionalDirectories:y(Ve(g()).optional(),()=>[]),mcpServers:y(Ve(gD).optional(),()=>[]),_meta:y(C(g(),T()).nullish(),()=>{})}),FZ=x({sessionId:Ar,cwd:g(),additionalDirectories:y(Ve(g()).optional(),()=>[]),mcpServers:y(Ve(gD).optional(),()=>[]),_meta:y(C(g(),T()).nullish(),()=>{})}),jZ=x({sessionId:Ar,_meta:y(C(g(),T()).nullish(),()=>{})}),UZ=x({sessionId:Ar,modeId:dD,_meta:y(C(g(),T()).nullish(),()=>{})}),HZ=Ho(be([x({value:mr(),type:O("boolean")}),x({value:TZ})]),x({sessionId:Ar,configId:uve,_meta:y(C(g(),T()).nullish(),()=>{})})),qZ=x({sessionId:Ar,prompt:gt(lZ),_meta:y(C(g(),T()).nullish(),()=>{})}),Ogt=x({uri:g(),name:g(),_meta:y(C(g(),T()).nullish(),()=>{})}),$gt=x({name:g(),owner:g(),remoteUrl:g(),_meta:y(C(g(),T()).nullish(),()=>{})}),GZ=x({workspaceUri:y(g().nullish(),()=>{}),workspaceFolders:gt(Ogt).nullish(),repository:y($gt.nullish(),()=>{}),_meta:y(C(g(),T()).nullish(),()=>{})}),Mgt=be([O("automatic"),O("diagnostic"),O("manual")]),Dgt=x({uri:g(),languageId:g(),text:g(),_meta:y(C(g(),T()).nullish(),()=>{})}),Ngt=x({startLine:fr().gte(0).max(4294967295,{error:"Invalid value: Expected uint32 to be <= 4294967295"}),endLine:fr().gte(0).max(4294967295,{error:"Invalid value: Expected uint32 to be <= 4294967295"}),text:g(),_meta:y(C(g(),T()).nullish(),()=>{})}),zgt=x({uri:g(),excerpts:gt(Ngt),_meta:y(C(g(),T()).nullish(),()=>{})}),Lgt=x({uri:g(),diff:g(),_meta:y(C(g(),T()).nullish(),()=>{})}),Fgt=x({action:g(),uri:g(),position:Qm,timestampMs:rt(),_meta:y(C(g(),T()).nullish(),()=>{})}),jgt=x({uri:g(),languageId:g(),visibleRange:y(Bk.nullish(),()=>{}),lastFocusedMs:y(rt().nullish(),()=>{}),_meta:y(C(g(),T()).nullish(),()=>{})}),Ugt=be([O("error"),O("warning"),O("information"),O("hint")]),Hgt=x({uri:g(),range:Bk,severity:Ugt,message:g(),_meta:y(C(g(),T()).nullish(),()=>{})}),qgt=x({recentFiles:gt(Dgt).nullish(),relatedSnippets:gt(zgt).nullish(),editHistory:gt(Lgt).nullish(),userActions:gt(Fgt).nullish(),openFiles:gt(jgt).nullish(),diagnostics:gt(Hgt).nullish(),_meta:y(C(g(),T()).nullish(),()=>{})}),BZ=x({sessionId:Ar,uri:g(),version:rt(),position:Qm,selection:Bk.nullish(),triggerKind:Mgt,context:qgt.nullish(),_meta:y(C(g(),T()).nullish(),()=>{})}),WZ=x({sessionId:Ar,_meta:y(C(g(),T()).nullish(),()=>{})}),$dr=x({id:Ym,method:g(),params:be([hD,PZ,IZ,AZ,OZ,$Z,MZ,DZ,NZ,zZ,LZ,FZ,jZ,UZ,HZ,qZ,GZ,BZ,WZ,ive,sve]).nullish()}),Ggt=x({_meta:y(C(g(),T()).nullish(),()=>{})}),Bgt=x({content:g(),_meta:y(C(g(),T()).nullish(),()=>{})}),Wgt=x({optionId:Xwe,_meta:y(C(g(),T()).nullish(),()=>{})}),Vgt=be([x({outcome:O("cancelled")}),Wgt.and(x({outcome:O("selected")}))]),Kgt=x({outcome:Vgt,_meta:y(C(g(),T()).nullish(),()=>{})}),Zgt=x({terminalId:Hk,_meta:y(C(g(),T()).nullish(),()=>{})}),Jgt=x({exitCode:y(fr().gte(0).max(4294967295,{error:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),()=>{}),signal:y(g().nullish(),()=>{}),_meta:y(C(g(),T()).nullish(),()=>{})}),Ygt=x({output:g(),truncated:mr(),exitStatus:y(Jgt.nullish(),()=>{}),_meta:y(C(g(),T()).nullish(),()=>{})}),Qgt=x({_meta:y(C(g(),T()).nullish(),()=>{})}),Xgt=x({exitCode:y(fr().gte(0).max(4294967295,{error:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),()=>{}),signal:y(g().nullish(),()=>{}),_meta:y(C(g(),T()).nullish(),()=>{})}),eyt=x({_meta:y(C(g(),T()).nullish(),()=>{})}),tyt=be([g(),rt(),rt(),mr(),gt(g())]),VZ=x({content:C(g(),tyt).nullish()}),ryt=Mn(Ho(be([VZ.and(x({action:O("accept")})),x({action:O("decline")}),x({action:O("cancel")}),$n(x({action:g()}),"action",["accept","cancel","decline"])]),x({_meta:y(C(g(),T()).nullish(),()=>{})})),"action",["accept","cancel","decline"]),nyt=x({connectionId:lD,_meta:y(C(g(),T()).nullish(),()=>{})}),oyt=x({_meta:y(C(g(),T()).nullish(),()=>{})}),Mdr=be([x({id:Ym,result:be([Ggt,Bgt,Kgt,Zgt,Ygt,Qgt,Xgt,eyt,ryt,nyt,oyt,fve,pve])}),x({id:Ym,error:mve})]),KZ=x({sessionId:Ar,_meta:y(C(g(),T()).nullish(),()=>{})}),ZZ=x({sessionId:Ar,uri:g(),languageId:g(),version:rt(),text:g(),_meta:y(C(g(),T()).nullish(),()=>{})}),iyt=x({range:Bk.nullish(),text:g(),_meta:y(C(g(),T()).nullish(),()=>{})}),JZ=x({sessionId:Ar,uri:g(),version:rt(),contentChanges:Kn(Ve(iyt),()=>[]),_meta:y(C(g(),T()).nullish(),()=>{})}),YZ=x({sessionId:Ar,uri:g(),_meta:y(C(g(),T()).nullish(),()=>{})}),QZ=x({sessionId:Ar,uri:g(),_meta:y(C(g(),T()).nullish(),()=>{})}),XZ=x({sessionId:Ar,uri:g(),version:rt(),position:Qm,visibleRange:Bk,_meta:y(C(g(),T()).nullish(),()=>{})}),e9=x({sessionId:Ar,id:Gk,_meta:y(C(g(),T()).nullish(),()=>{})}),syt=be([O("rejected"),O("ignored"),O("replaced"),O("cancelled")]),t9=x({sessionId:Ar,id:Gk,reason:y(syt.nullish(),()=>{}),_meta:y(C(g(),T()).nullish(),()=>{})}),Ddr=x({method:g(),params:be([KZ,ZZ,JZ,YZ,QZ,XZ,e9,t9,gve,yve]).nullish()}),Ndr=x({requestId:Ym,_meta:y(C(g(),T()).nullish(),()=>{})});var Sve="$/cancel_request";function yD(e){return s9(e)&&"id"in e&&typeof e.method=="string"&&a9(e.id)}function i9(e){if(!s9(e)||"method"in e||!("id"in e)||!a9(e.id))return!1;let t=Object.hasOwn(e,"result"),r=Object.hasOwn(e,"error");return t===r?!1:!r||cyt(e.error)}function Wk(e){return s9(e)&&!("id"in e)&&typeof e.method=="string"}function Ip(e){return typeof e=="object"&&e!==null}function s9(e){return Ip(e)&&e.jsonrpc==="2.0"}function a9(e){return e===null||typeof e=="string"||typeof e=="number"&&Number.isFinite(e)}function kve(e){return Ip(e)&&!("method"in e)&&("id"in e||"result"in e||"error"in e)}function _ve(e){let t=!1,r=!1,n=!1,o=!1;for(let i of e)t||=yD(i)||Wk(i),r||=i9(i),Ip(i)&&(n||="method"in i,o||="result"in i||"error"in i);return t?!1:r?!0:o&&!n}function ayt(e){if(!(!Ip(e)||!a9(e.requestId)))return e.requestId}function cyt(e){return Ip(e)&&typeof e.code=="number"&&Number.isInteger(e.code)&&typeof e.message=="string"}var Mc={yes(){return{handled:!0}},no(e,t=!1){return{handled:!1,message:e,retry:t}}};function Vy(e){let t=Promise.reject(e);return t.catch(()=>{}),t}function lyt(e){if(e instanceof Error||typeof e=="object"&&e!=null&&"message"in e&&typeof e.message=="string")return e.message}function uyt(e){return typeof e=="object"&&e!==null&&"name"in e&&e.name==="ZodError"&&"issues"in e&&Array.isArray(e.issues)&&"format"in e&&typeof e.format=="function"}function wve(e){if(e instanceof Xr)return e.toResult();if(uyt(e))return Xr.invalidParams(e.format()).toResult();let t=lyt(e);try{return Xr.internalError(t?JSON.parse(t):{}).toResult()}catch{return Xr.internalError({details:t}).toResult()}}function dyt(e){return e instanceof Xr&&e.code===-32800?e:Xr.requestCancelled(e)}function pyt(e,t){let r=fyt(e,t);return r?r.toResult():wve(e)}function fyt(e,t){if(!(!t.aborted||!myt(e)))return dyt(t.reason)}function myt(e){if(typeof e!="object"||e===null)return!1;let t=e;return t.name==="AbortError"||t.code==="ABORT_ERR"}var r9=class{id;sendResult;signal;finishRequest;didRespond=!1;constructor(t,r,n=new AbortController().signal,o){this.id=t,this.sendResult=r,this.signal=n,this.finishRequest=o}get responded(){return this.didRespond}respond(t){return this.respondWithResult({result:t??null})}respondWithError(t){let r=t instanceof Xr?t.toErrorResponse():t;return this.respondWithResult({error:r})}respondWithResult(t){return this.didRespond?Vy(new Error("JSON-RPC request already responded")):(this.didRespond=!0,this.sendResult(t).finally(()=>{this.finishRequest?.()}))}},Ap=class{disposeHandler;active=!0;constructor(t){this.disposeHandler=t}dispose(){this.active&&(this.active=!1,this.disposeHandler())}[Symbol.dispose](){this.dispose()}runIndefinitely(){return this}},n9=class{connection;constructor(t){this.connection=t}sendRequest(t,r,n,o){return this.connection.sendRequest(t,r,n,o)}sendNotification(t,r){return this.connection.sendNotification(t,r)}sendBatch(t){return this.connection.sendBatch(t)}sendCancelRequest(t){return this.connection.sendCancelRequest(t)}addDynamicHandler(t){return this.connection.addDynamicHandler(t)}get signal(){return this.connection.signal}get closed(){return this.connection.closed}},Op=class{pendingResponses=new Map;incomingRequests=new Map;nextRequestId=0;staticHandlers=[];dynamicHandlers=new Set;stream;writeQueue=Promise.resolve();abortController=new AbortController;closedPromise;retryQueue=[];context=new n9(this);receiveReader;allowBatches=!0;constructor(t,r,n,o){if(typeof t=="function"){let c=t,l=r,u=n;this.initialize(u,[...o?.handlers??[],this.legacyHandler(c,l)],o);return}let i=t,s=r,a=n;this.initialize(i,[...a?.handlers??[],...s],a)}static builder(){return new o9}runUntil(t){let r=!1,n=Promise.resolve().then(()=>t(this.context)).finally(()=>{r=!0}),o=this.closed.then(()=>{if(r)return new Promise(()=>{});throw this.closedReason()});return Promise.race([n,o]).finally(()=>{r=!0,this.close()})}addDynamicHandler(t){if(this.dynamicHandlers.add(t),this.retryQueue.length>0)for(let r of this.retryQueue.splice(0))this.processIncomingMessage(r).catch(n=>this.close(n));return new Ap(()=>{this.dynamicHandlers.delete(t)})}get signal(){return this.abortController.signal}get closed(){return this.closedPromise}getContext(){return this.context}sendRequest(t,r,n,o={}){if(this.abortController.signal.aborted)return Vy(this.closedReason());let i=this.prepareRequest(t,r,n,o);return this.sendWireMessage(i.message).catch(()=>{}),o.cancellationSignal?.aborted&&i.cancel(),i.response}sendBatch(t){if(this.abortController.signal.aborted)return Vy(this.closedReason());if(!this.allowBatches)return Vy(new TypeError("JSON-RPC batches are not supported on this connection"));if(t.length===0)return Vy(new TypeError("JSON-RPC batch must contain at least one entry"));let r=[],n=[],o=[];for(let c of t){if(c.kind==="notification"){r.push({jsonrpc:"2.0",method:c.method,params:c.params}),o.push(Promise.resolve(void 0));continue}let l=this.prepareRequest(c.method,c.params,c.mapResponse,c.options);r.push(l.message),o.push(l.response),n.push({signal:c.options?.cancellationSignal,cancel:l.cancel})}let i=r,s=this.sendWireMessage(i);for(let c of n)c.signal?.aborted&&c.cancel();let a=Promise.all([s,...o]).then(([,...c])=>c);return a.catch(()=>{}),a}sendCancelRequest(t){return this.sendNotification(Sve,{requestId:t})}sendNotification(t,r){return this.abortController.signal.aborted?Vy(this.closedReason()):this.sendWireMessage({jsonrpc:"2.0",method:t,params:r})}prepareRequest(t,r,n,o={}){let i=this.nextRequestId++,s=()=>{},a=new Promise((c,l)=>{let u={resolve:d=>{try{c(n?n(d):d)}catch(f){l(f)}},reject:l};s=()=>{u.cancellationSent||(u.cancellationSent=!0,u.cleanup?.(),this.sendCancelRequest(i).catch(()=>{}))},o.cancellationSignal?.addEventListener("abort",s,{once:!0}),u.cleanup=()=>{o.cancellationSignal?.removeEventListener("abort",s)},this.pendingResponses.set(i,u)});return a.catch(()=>{}),{message:{jsonrpc:"2.0",id:i,method:t,params:r},response:a,cancel:()=>s()}}close(t){if(this.abortController.signal.aborted)return;let r=t??new Error("ACP connection closed");this.abortController.abort(r);for(let n of this.pendingResponses.values())n.cleanup?.(),n.reject(r);this.pendingResponses.clear();for(let n of this.incomingRequests.values())n.abort(r);this.incomingRequests.clear(),this.receiveReader?.cancel(r).catch(()=>{})}initialize(t,r,n){this.stream=t,this.staticHandlers=r,this.allowBatches=n?.allowBatches??!0,this.closedPromise=new Promise(o=>{this.abortController.signal.addEventListener("abort",()=>o())}),this.receive()}legacyHandler(t,r){return{handleMessage:async(n,o)=>{if(n.kind==="request"){let i=await t(n.method,n.params,o);await n.responder.respond(i)}else await r(n.method,n.params,o);return Mc.yes()}}}async receive(){let t;try{let r=this.stream.readable.getReader();this.receiveReader=r;try{for(;!this.abortController.signal.aborted;){let{value:n,done:o}=await r.read();if(this.abortController.signal.aborted||o)break;n&&this.receiveWireMessage(n)}}finally{this.receiveReader===r&&(this.receiveReader=void 0),r.releaseLock()}}catch(r){t=r}finally{this.close(t)}}receiveWireMessage(t){if(Array.isArray(t)){if(!this.allowBatches){this.close(new TypeError("JSON-RPC batches are not supported on this connection"));return}this.receiveBatch(t);return}if(!Ip(t)){console.error("Invalid message",{message:t});return}this.receiveMessage(t)}receiveBatch(t){if(t.length===0){this.sendWireMessage({jsonrpc:"2.0",id:null,error:Xr.invalidRequest(t).toErrorResponse()}).catch(()=>{});return}let r=_ve(t),o=r?0:t.reduce((u,d)=>u+(Wk(d)?0:1),0),i=t.reduce((u,d)=>u+(Wk(d)?1:0),0),s=!1,a=[],c=async()=>{s||o!==0||i!==0||a.length===0||(s=!0,await this.sendWireMessage(a))},l=async u=>{a.push(u),o-=1,await c()};for(let u of t){if(r){kve(u)&&this.receiveMessage(u);continue}if(!yD(u)&&!Wk(u)){l({jsonrpc:"2.0",id:null,error:Xr.invalidRequest(u).toErrorResponse()}).catch(()=>{});continue}let d=this.receiveMessage(u,yD(u)?l:void 0);Wk(u)&&d.finally(()=>{i-=1,c().catch(f=>this.close(f))})}}receiveMessage(t,r){return this.abortController.signal.aborted?Promise.resolve():Ip(t)?"method"in t?("id"in t||this.handleProtocolNotification(t),this.processIncomingMessage(this.toIncomingMessage(t,r)).catch(n=>this.close(n))):("id"in t?this.handleResponse(t):console.error("Invalid message",{message:t}),Promise.resolve()):(console.error("Invalid message",{message:t}),Promise.resolve())}async processIncomingMessage(t){if(this.abortController.signal.aborted)return;let r=t,n=!1;try{for(let o of[...this.staticHandlers,...this.dynamicHandlers.values()]){if(this.abortController.signal.aborted)return;let i=await o.handleMessage(r,this.context)??{handled:!0};if(i.handled)return;r=i.message??r,n=n||!!i.retry}n?this.retryQueue.push(r):r.kind==="request"&&await r.responder.respondWithError(Xr.methodNotFound(r.method))}catch(o){if(this.abortController.signal.aborted)return;if(r.kind==="request"&&!r.responder.responded)await r.responder.respondWithResult(pyt(o,r.responder.signal));else{let i=wve(o);"error"in i&&console.error("Error handling notification",t.raw,i.error)}}}toIncomingMessage(t,r){if("id"in t){let n=new AbortController;this.incomingRequests.set(t.id,n);let o=()=>{this.incomingRequests.get(t.id)===n&&this.incomingRequests.delete(t.id)};return{kind:"request",method:t.method,params:t.params,raw:t,signal:n.signal,responder:new r9(t.id,i=>{let s={jsonrpc:"2.0",id:t.id,...i};return r?r(s):this.sendWireMessage(s)},n.signal,o)}}return{kind:"notification",method:t.method,params:t.params,raw:t}}handleResponse(t){let r=this.pendingResponses.get(t.id);if(r)if(this.pendingResponses.delete(t.id),r.cleanup?.(),!i9(t))r.reject(Xr.invalidRequest(t));else if("result"in t)r.resolve(t.result);else{let{code:n,message:o,data:i}=t.error;r.reject(new Xr(n,o,i))}else console.error("Got response to unknown request",t.id)}handleProtocolNotification(t){if(t.method!==Sve)return;let r=ayt(t.params);if(r===void 0)return;let n=this.incomingRequests.get(r);!n||n.signal.aborted||n.abort(Xr.requestCancelled({requestId:r}))}closedReason(){return this.abortController.signal.reason??new Error("ACP connection closed")}async sendWireMessage(t){return this.abortController.signal.aborted?Vy(this.closedReason()):(this.writeQueue=this.writeQueue.then(async()=>{if(this.abortController.signal.aborted)throw this.closedReason();let r=this.stream.writable.getWriter();try{await r.write(t)}finally{r.releaseLock()}}).catch(r=>{throw this.close(r),r}),this.writeQueue)}},o9=class{handlers=[];connectionName;name(t){return this.connectionName=t,this}withHandler(t){return this.handlers.push(t),this}onReceiveMessage(t){return this.withHandler({handleMessage:async(r,n)=>await t(r,n)??Mc.no(r),describe:()=>this.connectionName??"onReceiveMessage"})}onReceiveRequest(t,r,n){return this.withHandler({handleMessage:async(o,i)=>{if(o.kind!=="request"||o.method!==t)return Mc.no(o);let s=r(o.params);return await n(s,o.responder,i)??Mc.yes()},describe:()=>`${this.connectionName??"request"}:${t}`})}onReceiveNotification(t,r,n){return this.withHandler({handleMessage:async(o,i)=>{if(o.kind!=="notification"||o.method!==t)return Mc.no(o);let s=r(o.params);return await n(s,i)??Mc.yes()},describe:()=>`${this.connectionName??"notification"}:${t}`})}connect(t,r){return new Op(t,this.handlers,r)}connectWith(t,r,n){return this.connect(t,n).runUntil(r)}},Xr=class e extends Error{code;data;constructor(t,r,n){super(r),this.code=t,this.name="RequestError",this.data=n}static parseError(t,r){return new e(-32700,`Parse error${r?`: ${r}`:""}`,t)}static invalidRequest(t,r){return new e(-32600,`Invalid request${r?`: ${r}`:""}`,t)}static methodNotFound(t){return new e(-32601,`"Method not found": ${t}`,{method:t})}static invalidParams(t,r){return new e(-32602,`Invalid params${r?`: ${r}`:""}`,t)}static internalError(t,r){return new e(-32603,`Internal error${r?`: ${r}`:""}`,t)}static requestCancelled(t,r){return new e(-32800,`Request cancelled${r?`: ${r}`:""}`,t)}static authRequired(t,r){return new e(-32e3,`Authentication required${r?`: ${r}`:""}`,t)}static resourceNotFound(t){return new e(-32002,`Resource not found${t?`: ${t}`:""}`,t&&{uri:t})}toResult(){return{error:{code:this.code,message:this.message,data:this.data}}}toErrorResponse(){return{code:this.code,message:this.message,data:this.data}}};var bD=class{#e=[];push(t){let r=[],n=0,o=t.indexOf(10,n);for(;o!==-1;)r.push(this.#t(t.subarray(n,o))),n=o+1,o=t.indexOf(10,n);return n<t.byteLength&&this.#e.push(n===0?t:new Uint8Array(t.subarray(n))),r}flush(){if(this.#e.length!==0)return this.#t(new Uint8Array(0))}#t(t){if(this.#e.length===0)return t;let r=t.byteLength;for(let i of this.#e)r+=i.byteLength;let n=new Uint8Array(r),o=0;for(let i of this.#e)n.set(i,o),o+=i.byteLength;return n.set(t,o),this.#e=[],n}};function c9(e,t){let r=new TextEncoder,n=new TextDecoder,o=!1,i,s=new ReadableStream({async start(c){let l=new bD,u=f=>{let m=n.decode(f).trim();if(m)try{let b=JSON.parse(m);Ip(b)||Array.isArray(b)?c.enqueue(b):console.warn("Skipping JSON line that is not an object:",m)}catch(b){console.error("Failed to parse JSON message:",m,b)}},d=t.getReader();i=d;try{for(;;){let{value:m,done:b}=await d.read();if(o)return;if(b)break;if(m){for(let S of l.push(m))if(u(S),o)return}}if(o)return;let f=l.flush();f&&u(f)}catch(f){if(o)return;c.error(f);return}finally{i===d&&(i=void 0),d.releaseLock()}o||c.close()},cancel(c){return o=!0,i?.cancel(c)}}),a=new WritableStream({async write(c){let l=JSON.stringify(c)+`
439
- `,u=e.getWriter();try{await u.write(r.encode(l))}finally{u.releaseLock()}}});return{readable:s,writable:a}}var Hdr=_Z.and(x({mode:O("form")})).and(x({message:g()})),qdr=wZ.and(x({mode:O("url")})).and(x({message:g()})),Gdr=be([uR,dR]).and(x({message:g()})),Bdr=gZ.and(x({type:O("string")})),Wdr=yZ.and(x({type:O("number")})),Vdr=bZ.and(x({type:O("integer")})),Kdr=xZ.and(x({type:O("boolean")})),Zdr=kZ.and(x({type:O("array")})),Jdr=SZ.and(x({type:O("string")}));var Ydr=VZ.and(x({action:O("accept")})),Qdr=x({action:O("decline")}),Xdr=x({action:O("cancel")});function h9(e,t){return c9(e,t)}function Dc(e){return e??{}}function Tve(e){return typeof e=="object"&&e!==null&&"readable"in e&&"writable"in e}function Cve(){let e=new TransformStream,t=new TransformStream;return[{readable:t.readable,writable:e.writable},{readable:e.readable,writable:t.writable}]}var Xm={agent:{initialize:Me.initialize,authenticate:Me.authenticate,logout:Me.logout,providers:{list:Me.providers_list,set:Me.providers_set,disable:Me.providers_disable},session:{new:Me.session_new,load:Me.session_load,list:Me.session_list,delete:Me.session_delete,fork:Me.session_fork,resume:Me.session_resume,close:Me.session_close,setMode:Me.session_set_mode,setConfigOption:Me.session_set_config_option,prompt:Me.session_prompt,cancel:Me.session_cancel},nes:{start:Me.nes_start,suggest:Me.nes_suggest,accept:Me.nes_accept,reject:Me.nes_reject,close:Me.nes_close},document:{didOpen:Me.document_did_open,didChange:Me.document_did_change,didClose:Me.document_did_close,didSave:Me.document_did_save,didFocus:Me.document_did_focus}},client:{session:{requestPermission:ir.session_request_permission,update:ir.session_update},fs:{writeTextFile:ir.fs_write_text_file,readTextFile:ir.fs_read_text_file},terminal:{create:ir.terminal_create,output:ir.terminal_output,release:ir.terminal_release,waitForExit:ir.terminal_wait_for_exit,kill:ir.terminal_kill},elicitation:{create:ir.elicitation_create,complete:ir.elicitation_complete}},protocol:{cancelRequest:KW.cancel_request}},Pve=Symbol("startActiveSession"),kD=class{cx;currentRequestId;constructor(t,r){this.cx=t,this.currentRequestId=r}get requestId(){return this.currentRequestId}get connectionContext(){return this.cx}sendRequest(t,r,n,o){return this.cx.sendRequest(t,r,n,o)}sendNotification(t,r){return this.cx.sendNotification(t,r)}addDynamicHandler(t){return this.cx.addDynamicHandler(t)}},pR=class e extends kD{constructor(t,r){super(t,r)}static create(t,r){return new e(t,r)}request(t,r,n){let o=Nve[t];return this.sendRequest(t,r,o?.mapResponse,n)}notify(t,r){return this.sendNotification(t,r)}},fR=class e extends kD{constructor(t,r){super(t,r)}static create(t,r){return new e(t,r)}[Pve](t,r){return this.sendRequest(Me.session_new,t,n=>this.attachSession(n),r)}buildSession(t){return typeof t=="string"?wD.create(this,{cwd:t,mcpServers:[]}):wD.create(this,t)}attachSession(t){let r=new d9,n=this.connectionContext.signal,o=()=>{r.fail(n.reason??new Error("ACP connection closed"))};n.aborted?o():n.addEventListener("abort",o);let i=zve(this.connectionContext).attach(t,r),s=new Ap(()=>{n.removeEventListener("abort",o)});return p9.create(this,t,r,[i,s])}request(t,r,n){let o=Dve[t];return this.sendRequest(t,r,o?.mapResponse,n)}notify(t,r){return this.sendNotification(t,r)}},_D=class{connection;constructor(t){this.connection=t}get signal(){return this.connection.signal}get closed(){return this.connection.closed}close(t){this.connection.close(t)}},l9=class extends _D{connectHandlers;client;didStartConnectHandlers=!1;constructor(t,r=[]){super(t),this.connectHandlers=r,this.client=pR.create(t.getContext())}startConnectHandlers(){this.didStartConnectHandlers||(this.didStartConnectHandlers=!0,TD(this,this.connectHandlers))}},u9=class extends _D{connectHandlers;agent;didStartConnectHandlers=!1;constructor(t,r=[]){super(t),this.connectHandlers=r,this.agent=fR.create(t.getContext())}startConnectHandlers(){this.didStartConnectHandlers||(this.didStartConnectHandlers=!0,TD(this,this.connectHandlers))}};function Ive(e,t=[]){return new l9(e,t)}function Ave(e,t=[]){return new u9(e,t)}var d9=class{values=[];waiters=[];failed=!1;failure;enqueue(t){if(this.failed)return;let r=this.waiters.shift();r?r.resolve(t):this.values.push({kind:"value",value:t})}reject(t){if(!this.failed){if(this.waiters.length>0){for(let r of this.waiters.splice(0))r.reject(t);return}this.values.push({kind:"error",error:t})}}clearErrors(){this.values=this.values.filter(t=>t.kind==="value")}fail(t){if(!this.failed){this.failed=!0,this.failure=t;for(let r of this.waiters.splice(0))r.reject(t)}}next(){if(this.values.length>0){let t=this.values.shift();return t.kind==="error"?Promise.reject(t.error):Promise.resolve(t.value)}return this.failed?Promise.reject(this.failure):new Promise((t,r)=>{this.waiters.push({resolve:t,reject:r})})}};function vve(e){return{...e,additionalDirectories:e.additionalDirectories?[...e.additionalDirectories]:void 0,mcpServers:[...e.mcpServers]}}var wD=class e{cx;request;constructor(t,r){this.cx=t,this.request=vve(r)}static create(t,r){return new e(t,r)}toRequest(){return vve(this.request)}withAdditionalDirectories(t){return this.request={...this.request,additionalDirectories:[...t]},this}withMcpServer(t){return this.request={...this.request,mcpServers:[...this.request.mcpServers,t]},this}async start(t){return this.cx[Pve](this.toRequest(),t)}async withSession(t){let r=await this.start();try{return await t(r)}finally{r.dispose()}}},p9=class e{cx;sessionResponse;updates;registrations;constructor(t,r,n,o){this.cx=t,this.sessionResponse=r,this.updates=n,this.registrations=o}static create(t,r,n,o){return new e(t,r,n,o)}get sessionId(){return this.sessionResponse.sessionId}get modes(){return this.sessionResponse.modes}get meta(){return this.sessionResponse._meta}get newSessionResponse(){return this.sessionResponse}prompt(t,r){this.updates.clearErrors();let n=this.cx.request(Me.session_prompt,{sessionId:this.sessionId,prompt:this.promptBlocks(t)},r);return n.then(o=>{this.updates.enqueue({kind:"stop",response:o,stopReason:o.stopReason})},o=>{this.updates.reject(o)}),n}nextUpdate(){return this.updates.next()}async readText(){let t="";for(;;){let r=await this.nextUpdate();if(r.kind==="stop")return t;let{update:n}=r;n.sessionUpdate==="agent_message_chunk"&&n.content.type==="text"&&(t+=n.content.text)}}dispose(){for(let t of this.registrations.splice(0))t.dispose();this.updates.fail(new Error("Active session disposed"))}[Symbol.dispose](){this.dispose()}promptBlocks(t){return typeof t=="string"?[{type:"text",text:t}]:Array.isArray(t)?t:[t]}};function Ove(e,t){return e?typeof e=="function"?e(t):e.parse(t):t}function en(e,t,r){return{method:e,params:t,mapResponse:r}}function Ju(e,t){return{method:e,params:t}}function $ve(e,t,r,n){e.onReceiveRequest(t.method,o=>Ove(t.params,o),async(o,i,s)=>{let a=await n(r(o,s,i.signal,i.id));await i.respond(t.mapResponse?t.mapResponse(a):a)})}function Mve(e,t,r,n){e.onReceiveNotification(t.method,o=>Ove(t.params,o),(o,i)=>n(r(o,i,i.signal)))}function RD(e){let t={};for(let r of Object.values(e))t[r.method]=r;return t}var hyt={initialize:en(Me.initialize,hD),newSession:en(Me.session_new,MZ),loadSession:en(Me.session_load,DZ,Dc),unstable_forkSession:en(Me.session_fork,LZ),listSessions:en(Me.session_list,NZ),deleteSession:en(Me.session_delete,zZ,Dc),resumeSession:en(Me.session_resume,FZ),closeSession:en(Me.session_close,jZ,Dc),setSessionMode:en(Me.session_set_mode,UZ,Dc),setSessionConfigOption:en(Me.session_set_config_option,HZ),authenticate:en(Me.authenticate,PZ,Dc),unstable_listProviders:en(Me.providers_list,IZ),unstable_setProvider:en(Me.providers_set,AZ,Dc),unstable_disableProvider:en(Me.providers_disable,OZ,Dc),logout:en(Me.logout,$Z,Dc),prompt:en(Me.session_prompt,qZ),unstable_startNes:en(Me.nes_start,GZ),unstable_suggestNes:en(Me.nes_suggest,BZ),unstable_closeNes:en(Me.nes_close,WZ,Dc)},gyt={cancel:Ju(Me.session_cancel,KZ),unstable_didOpenDocument:Ju(Me.document_did_open,ZZ),unstable_didChangeDocument:Ju(Me.document_did_change,JZ),unstable_didCloseDocument:Ju(Me.document_did_close,YZ),unstable_didSaveDocument:Ju(Me.document_did_save,QZ),unstable_didFocusDocument:Ju(Me.document_did_focus,XZ),unstable_acceptNes:Ju(Me.nes_accept,e9),unstable_rejectNes:Ju(Me.nes_reject,t9)},yyt={requestPermission:en(ir.session_request_permission,uZ),writeTextFile:en(ir.fs_write_text_file,sZ,Dc),readTextFile:en(ir.fs_read_text_file,aZ),createTerminal:en(ir.terminal_create,dZ),terminalOutput:en(ir.terminal_output,pZ),releaseTerminal:en(ir.terminal_release,fZ,Dc),waitForTerminalExit:en(ir.terminal_wait_for_exit,mZ),killTerminal:en(ir.terminal_kill,hZ,Dc),unstable_createElicitation:en(ir.elicitation_create,vZ)},byt={sessionUpdate:Ju(ir.session_update,mD),unstable_completeElicitation:Ju(ir.elicitation_complete,CZ)},Dve=RD(hyt),xyt=RD(gyt),Nve=RD(yyt),Syt=RD(byt);function kyt(e,t,r,n){return{params:e,requestId:n,signal:r,client:t}}function _yt(e,t,r){return{params:e,signal:r,client:t}}function wyt(e,t,r,n){return{params:e,requestId:n,signal:r,agent:t}}function vyt(e,t,r){return{params:e,signal:r,agent:t}}var f9=class{activeSessions=new Map;handleMessage(t){if(t.kind!=="notification"||t.method!==ir.session_update)return Mc.no(t);let r=mD.parse(t.params),n={kind:"session_update",notification:r,update:r.update},o=this.activeSessions.get(r.sessionId);if(o&&o.size>0)for(let i of o)i.enqueue(n);return Mc.no(t)}attach(t,r){let n=this.activeSessions.get(t.sessionId)??new Set;return n.add(r),this.activeSessions.set(t.sessionId,n),new Ap(()=>{n.delete(r),n.size===0&&this.activeSessions.delete(t.sessionId)})}},Eve=new WeakMap;function zve(e){let t=Eve.get(e);return t||(t=new f9,Eve.set(e,t)),t}function TD(e,t){for(let r of t){let n;try{n=r(e)}catch(o){throw e.close(o),o}Promise.resolve(n).catch(o=>{e.close(o)})}}var vD=Symbol("appBuilder"),xD=Symbol("runAgentConnectHandlers"),SD=Symbol("runClientConnectHandlers"),ED={allowBatches:!1};var Rve=class{builder=Op.builder();connectHandlers=[];constructor(t={}){t.name&&this.builder.name(t.name)}[vD](){return this.builder}[xD](t){TD(t,this.connectHandlers)}connect(t,r={}){return this.connectConnection(t,r).connection}connectWith(t,r){let{rawConnection:n,connection:o}=this.connectConnection(t);return n.runUntil(()=>r(o.client))}onConnect(t){return this.connectHandlers.push(t),this}onRequest(t,r,n){if(n)return this.request({method:t,params:r},n);let o=Dve[t];if(!o)throw new Error(`Unknown ACP request method '${t}'. Pass a params parser for custom methods.`);return this.request(o,r)}onNotification(t,r,n){if(n)return this.notification({method:t,params:r},n);let o=xyt[t];if(!o)throw new Error(`Unknown ACP notification method '${t}'. Pass a params parser for custom methods.`);return this.notification(o,r)}request(t,r){return $ve(this.builder,t,(n,o,i,s)=>kyt(n,pR.create(o,s),i,s),r),this}notification(t,r){return Mve(this.builder,t,(n,o,i)=>_yt(n,pR.create(o),i),r),this}connectConnection(t,r={}){if(Tve(t)){let c=this.openStreamConnection(t);return r.deferConnectHandlers||this[xD](c.connection),c}let[n,o]=Cve(),i=t[vD]().connect(o,ED),s=Ave(i),a=this.openStreamConnection(n);a.rawConnection.closed.then(()=>s.close()),i.closed.then(()=>a.connection.close());try{t[SD](s),this[xD](a.connection)}catch(c){throw s.close(c),a.connection.close(c),c}return a}openStreamConnection(t){let r=this.builder.connect(t,ED);return{rawConnection:r,connection:Ive(r,this.connectHandlers)}}};function Lve(e){return new m9(e)}var m9=class{builder=Op.builder();connectHandlers=[];constructor(t={}){t.name&&this.builder.name(t.name),this.builder.withHandler({handleMessage:(r,n)=>zve(n).handleMessage(r),describe:()=>"client-session-update-router"})}[vD](){return this.builder}[SD](t){TD(t,this.connectHandlers)}connect(t){return this.connectConnection(t).connection}connectWith(t,r){let{rawConnection:n,connection:o}=this.connectConnection(t);return n.runUntil(()=>r(o.agent))}onConnect(t){return this.connectHandlers.push(t),this}onRequest(t,r,n){if(n)return this.request({method:t,params:r},n);let o=Nve[t];if(!o)throw new Error(`Unknown ACP request method '${t}'. Pass a params parser for custom methods.`);return this.request(o,r)}onNotification(t,r,n){if(n)return this.notification({method:t,params:r},n);let o=Syt[t];if(!o)throw new Error(`Unknown ACP notification method '${t}'. Pass a params parser for custom methods.`);return this.notification(o,r)}request(t,r){return $ve(this.builder,t,(n,o,i,s)=>wyt(n,fR.create(o,s),i,s),r),this}notification(t,r){return Mve(this.builder,t,(n,o,i)=>vyt(n,fR.create(o),i),r),this}connectConnection(t){if(Tve(t)){let a=this.openStreamConnection(t);return this[SD](a.connection),a}let[r,n]=Cve(),o=t[vD]().connect(n,ED),i=Ive(o),s=this.openStreamConnection(r);s.rawConnection.closed.then(()=>i.close()),o.closed.then(()=>s.connection.close());try{t[xD](i),this[SD](s.connection)}catch(a){throw i.close(a),s.connection.close(a),a}return s}openStreamConnection(t){let r=this.builder.connect(t,ED);return{rawConnection:r,connection:Ave(r,this.connectHandlers)}}},cpr=new Set([Me.initialize,Me.authenticate,Me.providers_list,Me.providers_set,Me.providers_disable,Me.session_new,Me.session_load,Me.session_set_mode,Me.session_set_config_option,Me.session_prompt,Me.session_list,Me.session_delete,Me.session_fork,Me.session_resume,Me.session_close,Me.logout,Me.nes_start,Me.nes_suggest,Me.nes_close]),lpr=new Set([Me.session_cancel,Me.nes_accept,Me.nes_reject,Me.document_did_open,Me.document_did_change,Me.document_did_close,Me.document_did_save,Me.document_did_focus]),upr=new Set([ir.session_request_permission,ir.fs_write_text_file,ir.fs_read_text_file,ir.terminal_create,ir.terminal_output,ir.terminal_release,ir.terminal_wait_for_exit,ir.terminal_kill,ir.elicitation_create]),dpr=new Set([ir.session_update,ir.elicitation_complete]);$8();E8();var ct={initialize:"initialize",auth_login:"auth/login",providers_list:"providers/list",providers_set:"providers/set",providers_disable:"providers/disable",session_new:"session/new",session_set_config_option:"session/set_config_option",session_prompt:"session/prompt",session_cancel:"session/cancel",mcp_message:"mcp/message",session_list:"session/list",session_delete:"session/delete",session_fork:"session/fork",session_resume:"session/resume",session_close:"session/close",auth_logout:"auth/logout",nes_start:"nes/start",nes_suggest:"nes/suggest",nes_accept:"nes/accept",nes_reject:"nes/reject",nes_close:"nes/close",document_did_open:"document/didOpen",document_did_change:"document/didChange",document_did_close:"document/didClose",document_did_save:"document/didSave",document_did_focus:"document/didFocus"},vi={session_request_permission:"session/request_permission",session_update:"session/update",mcp_connect:"mcp/connect",mcp_message:"mcp/message",mcp_disconnect:"mcp/disconnect",elicitation_create:"elicitation/create",elicitation_complete:"elicitation/complete"},N1={cancel_request:"$/cancel_request"},Fp=2;var ah=be([rt(),g()]).nullable(),dn=g(),z1=g(),rwt=be([O("read"),O("edit"),O("delete"),O("move"),O("search"),O("execute"),O("think"),O("fetch"),O("switch_mode"),O("other"),g()]),nwt=be([O("pending"),O("in_progress"),O("completed"),O("failed"),O("cancelled"),g()]),owt=be([O("assistant"),O("user"),g()]),BR=x({audience:y(Ve(owt).nullish(),()=>{}),lastModified:y(Ku.datetime({offset:!0}).nullish(),()=>{}),priority:y(rt().gte(0).lte(1).nullish(),()=>{}),_meta:y(C(g(),T()).nullish(),()=>{})}),M8=x({text:g(),annotations:y(BR.nullish(),()=>{}),_meta:y(C(g(),T()).nullish(),()=>{})}),ab=g(),D8=x({data:g(),mimeType:ab,uri:y(_r().nullish(),()=>{}),annotations:y(BR.nullish(),()=>{}),_meta:y(C(g(),T()).nullish(),()=>{})}),N8=x({data:g(),mimeType:ab,annotations:y(BR.nullish(),()=>{}),_meta:y(C(g(),T()).nullish(),()=>{})}),iwt=be([O("light"),O("dark"),g()]),swt=x({src:_r(),mimeType:y(ab.nullish(),()=>{}),sizes:y(Ve(g()).nullish(),()=>{}),theme:y(iwt.nullish(),()=>{})}),z8=x({name:g(),uri:_r(),title:y(g().nullish(),()=>{}),description:y(g().nullish(),()=>{}),icons:y(Ve(swt).nullish(),()=>{}),mimeType:y(ab.nullish(),()=>{}),size:y(rt().nullish(),()=>{}),annotations:y(BR.nullish(),()=>{}),_meta:y(C(g(),T()).nullish(),()=>{})}),awt=x({text:g(),uri:_r(),mimeType:y(ab.nullish(),()=>{}),_meta:y(C(g(),T()).nullish(),()=>{})}),cwt=x({blob:g(),uri:_r(),mimeType:y(ab.nullish(),()=>{}),_meta:y(C(g(),T()).nullish(),()=>{})}),lwt=be([awt,cwt]),L8=x({resource:lwt,annotations:y(BR.nullish(),()=>{}),_meta:y(C(g(),T()).nullish(),()=>{})}),g_=Mn(be([M8.and(x({type:O("text")})),D8.and(x({type:O("image")})),N8.and(x({type:O("audio")})),z8.and(x({type:O("resource_link")})),L8.and(x({type:O("resource")})),$n(x({type:g()}),"type",["audio","image","resource","resource_link","text"])]),"type",["audio","image","resource","resource_link","text"]),F8=x({content:g_,_meta:y(C(g(),T()).nullish(),()=>{})}),uwt=be([O("text"),O("binary"),O("directory"),O("symlink"),g()]),ss=g(),ib=x({path:ss}),GR=x({oldPath:ss,path:ss}),dwt=Mn(Ho(be([ib.and(x({operation:O("add")})),ib.and(x({operation:O("delete")})),ib.and(x({operation:O("modify")})),GR.and(x({operation:O("move")})),GR.and(x({operation:O("copy")})),$n(x({operation:g()}),"operation",["add","copy","delete","modify","move"])]),x({fileType:y(uwt.nullish(),()=>{}),mimeType:y(ab.nullish(),()=>{}),_meta:y(C(g(),T()).nullish(),()=>{})})),"operation",["add","copy","delete","modify","move"]),pwt=be([O("git_patch"),g()]),fwt=x({format:pwt,text:g()}),j8=x({changes:Ve(dwt),patch:y(fwt.nullish(),()=>{}),_meta:y(C(g(),T()).nullish(),()=>{})}),L1=g(),U8=x({terminalId:L1,_meta:y(C(g(),T()).nullish(),()=>{})}),ECe=Mn(be([F8.and(x({type:O("content")})),j8.and(x({type:O("diff")})),U8.and(x({type:O("terminal")})),$n(x({type:g()}),"type",["content","diff","terminal"])]),"type",["content","diff","terminal"]),mwt=x({path:ss,line:y(fr().gte(0).max(4294967295,{error:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),()=>{}),_meta:y(C(g(),T()).nullish(),()=>{})}),F1=x({toolCallId:z1,name:y(g().nullish(),()=>{}),title:y(g().nullish(),()=>{}),kind:y(rwt.nullish(),()=>{}),status:y(nwt.nullish(),()=>{}),content:y(Ve(ECe).nullish(),()=>{}),locations:y(Ve(mwt).nullish(),()=>{}),rawInput:y(T().optional(),()=>{}),rawOutput:y(T().optional(),()=>{}),_meta:y(C(g(),T()).nullish(),()=>{})}),H8=x({toolCall:F1}),q8=x({command:g(),cwd:ss,toolCallId:y(z1.nullish(),()=>{}),terminalId:y(L1.nullish(),()=>{}),_meta:y(C(g(),T()).nullish(),()=>{})}),hwt=Mn(be([H8.and(x({type:O("tool_call")})),q8.and(x({type:O("command")})),$n(x({type:g()}),"type",["command","tool_call"])]),"type",["command","tool_call"]),RCe=g(),gwt=be([O("allow_once"),O("allow_always"),O("reject_once"),O("reject_always"),g()]),ywt=x({optionId:RCe,name:g(),kind:gwt,_meta:y(C(g(),T()).nullish(),()=>{})}),G8=x({sessionId:dn,title:g(),description:y(g().nullish(),()=>{}),subject:hwt.nullish(),options:gt(ywt).min(1),_meta:y(C(g(),T()).nullish(),()=>{})}),WR=x({sessionId:dn,toolCallId:y(z1.nullish(),()=>{})}),VR=x({requestId:ah}),bwt=O("object"),xwt=be([O("email"),O("uri"),O("date"),O("date-time"),g()]),TCe=x({const:g(),title:g(),description:y(g().nullish(),()=>{}),_meta:y(C(g(),T()).nullish(),()=>{})}),B8=x({title:y(g().nullish(),()=>{}),description:y(g().nullish(),()=>{}),minLength:fr().gte(0).max(4294967295,{error:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),maxLength:fr().gte(0).max(4294967295,{error:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),pattern:g().nullish(),format:xwt.nullish(),default:y(g().nullish(),()=>{}),enum:gt(g()).min(1).nullish(),oneOf:gt(TCe).min(1).nullish(),_meta:y(C(g(),T()).nullish(),()=>{})}),W8=x({title:y(g().nullish(),()=>{}),description:y(g().nullish(),()=>{}),minimum:rt().nullish(),maximum:rt().nullish(),default:y(rt().nullish(),()=>{}),_meta:y(C(g(),T()).nullish(),()=>{})}),V8=x({title:y(g().nullish(),()=>{}),description:y(g().nullish(),()=>{}),minimum:rt().nullish(),maximum:rt().nullish(),default:y(rt().nullish(),()=>{}),_meta:y(C(g(),T()).nullish(),()=>{})}),K8=x({title:y(g().nullish(),()=>{}),description:y(g().nullish(),()=>{}),default:y(mr().nullish(),()=>{}),_meta:y(C(g(),T()).nullish(),()=>{})}),Z8=x({enum:gt(g()).min(1),_meta:y(C(g(),T()).nullish(),()=>{})}),CCe=x({anyOf:gt(TCe).min(1),_meta:y(C(g(),T()).nullish(),()=>{})}),Swt=Mn(be([Z8.and(x({type:O("string")})),$n(x({type:g()}),"type",["string"]),CCe]),"type",["string"]),J8=x({title:y(g().nullish(),()=>{}),description:y(g().nullish(),()=>{}),minItems:rt().nullish(),maxItems:rt().nullish(),items:Swt,default:y(Ve(g()).nullish(),()=>{}),_meta:y(C(g(),T()).nullish(),()=>{})}),kwt=Mn(be([B8.and(x({type:O("string")})),W8.and(x({type:O("number")})),V8.and(x({type:O("integer")})),K8.and(x({type:O("boolean")})),J8.and(x({type:O("array")})),$n(x({type:g()}),"type",["array","boolean","integer","number","string"])]),"type",["array","boolean","integer","number","string"]),_wt=x({type:y(bwt.optional().default("object"),()=>"object"),title:y(g().nullish(),()=>{}),properties:C(g(),kwt).optional().default({}),required:gt(g()).nullish(),description:y(g().nullish(),()=>{}),_meta:y(C(g(),T()).nullish(),()=>{})}),Y8=Ho(be([WR,VR]),x({requestedSchema:_wt})),PCe=g(),Q8=Ho(be([WR,VR]),x({elicitationId:PCe,url:_r()})),X8=Mn(Ho(be([Y8.and(x({mode:O("form")})),Q8.and(x({mode:O("url")})),$n(Ho(be([WR,VR]),x({mode:g()})),"mode",["form","url"])]),x({message:g(),_meta:y(C(g(),T()).nullish(),()=>{})})),"mode",["form","url"]),ICe=g(),e5=x({serverId:ICe,_meta:y(C(g(),T()).nullish(),()=>{})}),j1=g(),KR=x({connectionId:j1,method:g(),params:C(g(),T()).nullish(),_meta:y(C(g(),T()).nullish(),()=>{})}),t5=x({connectionId:j1,_meta:y(C(g(),T()).nullish(),()=>{})}),ACe=T(),v_r=x({id:ah,method:g(),params:be([G8,X8,e5,KR,t5,ACe]).nullish()}),OCe=fr().gte(0).lte(65535),$Ce=x({name:g(),title:y(g().nullish(),()=>{}),version:g(),_meta:y(C(g(),T()).nullish(),()=>{})}),wwt=x({_meta:y(C(g(),T()).nullish(),()=>{})}),vwt=x({_meta:y(C(g(),T()).nullish(),()=>{})}),Ewt=x({_meta:y(C(g(),T()).nullish(),()=>{})}),Rwt=x({image:y(wwt.nullish(),()=>{}),audio:y(vwt.nullish(),()=>{}),embeddedContext:y(Ewt.nullish(),()=>{}),_meta:y(C(g(),T()).nullish(),()=>{})}),Twt=x({_meta:y(C(g(),T()).nullish(),()=>{})}),Cwt=x({_meta:y(C(g(),T()).nullish(),()=>{})}),Pwt=x({_meta:y(C(g(),T()).nullish(),()=>{})}),Iwt=x({stdio:y(Twt.nullish(),()=>{}),http:y(Cwt.nullish(),()=>{}),acp:y(Pwt.nullish(),()=>{}),_meta:y(C(g(),T()).nullish(),()=>{})}),Awt=x({_meta:y(C(g(),T()).nullish(),()=>{})}),Owt=x({_meta:y(C(g(),T()).nullish(),()=>{})}),$wt=x({_meta:y(C(g(),T()).nullish(),()=>{})}),Mwt=x({prompt:y(Rwt.nullish(),()=>{}),mcp:y(Iwt.nullish(),()=>{}),delete:y(Awt.nullish(),()=>{}),additionalDirectories:y(Owt.nullish(),()=>{}),fork:y($wt.nullish(),()=>{}),_meta:y(C(g(),T()).nullish(),()=>{})}),Dwt=x({_meta:y(C(g(),T()).nullish(),()=>{})}),Nwt=x({_meta:y(C(g(),T()).nullish(),()=>{})}),zwt=x({_meta:y(C(g(),T()).nullish(),()=>{})}),Lwt=be([O("full"),O("incremental")]),Fwt=x({syncKind:Lwt,_meta:y(C(g(),T()).nullish(),()=>{})}),jwt=x({_meta:y(C(g(),T()).nullish(),()=>{})}),Uwt=x({_meta:y(C(g(),T()).nullish(),()=>{})}),Hwt=x({_meta:y(C(g(),T()).nullish(),()=>{})}),qwt=x({didOpen:y(zwt.nullish(),()=>{}),didChange:y(Fwt.nullish(),()=>{}),didClose:y(jwt.nullish(),()=>{}),didSave:y(Uwt.nullish(),()=>{}),didFocus:y(Hwt.nullish(),()=>{}),_meta:y(C(g(),T()).nullish(),()=>{})}),Gwt=x({document:y(qwt.nullish(),()=>{}),_meta:y(C(g(),T()).nullish(),()=>{})}),Bwt=x({maxCount:y(fr().gte(0).max(4294967295,{error:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),()=>{}),_meta:y(C(g(),T()).nullish(),()=>{})}),Wwt=x({_meta:y(C(g(),T()).nullish(),()=>{})}),Vwt=x({maxCount:y(fr().gte(0).max(4294967295,{error:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),()=>{}),_meta:y(C(g(),T()).nullish(),()=>{})}),Kwt=x({maxCount:y(fr().gte(0).max(4294967295,{error:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),()=>{}),_meta:y(C(g(),T()).nullish(),()=>{})}),Zwt=x({_meta:y(C(g(),T()).nullish(),()=>{})}),Jwt=x({_meta:y(C(g(),T()).nullish(),()=>{})}),Ywt=x({recentFiles:y(Bwt.nullish(),()=>{}),relatedSnippets:y(Wwt.nullish(),()=>{}),editHistory:y(Vwt.nullish(),()=>{}),userActions:y(Kwt.nullish(),()=>{}),openFiles:y(Zwt.nullish(),()=>{}),diagnostics:y(Jwt.nullish(),()=>{}),_meta:y(C(g(),T()).nullish(),()=>{})}),Qwt=x({events:y(Gwt.nullish(),()=>{}),context:y(Ywt.nullish(),()=>{}),_meta:y(C(g(),T()).nullish(),()=>{})}),MCe=be([O("utf-16"),O("utf-32"),O("utf-8")]),Xwt=x({session:y(Mwt.nullish(),()=>{}),auth:y(Dwt.nullish(),()=>{}),providers:y(Nwt.nullish(),()=>{}),nes:y(Qwt.nullish(),()=>{}),positionEncoding:y(MCe.nullish(),()=>{}),_meta:y(C(g(),T()).nullish(),()=>{})}),cb=g(),evt=x({name:g(),label:y(g().nullish(),()=>{}),secret:y(mr().optional().default(!0),()=>!0),optional:y(mr().optional().default(!1),()=>!1),_meta:y(C(g(),T()).nullish(),()=>{})}),r5=x({methodId:cb,name:g(),description:y(g().nullish(),()=>{}),vars:Kn(Ve(evt),()=>[]),link:y(_r().nullish(),()=>{}),_meta:y(C(g(),T()).nullish(),()=>{})}),DCe=x({name:g(),value:g(),_meta:y(C(g(),T()).nullish(),()=>{})}),n5=x({methodId:cb,name:g(),description:y(g().nullish(),()=>{}),args:y(Ve(g()).optional(),()=>[]),env:y(Ve(DCe).optional(),()=>[]),_meta:y(C(g(),T()).nullish(),()=>{})}),o5=x({methodId:cb,name:g(),description:y(g().nullish(),()=>{}),_meta:y(C(g(),T()).nullish(),()=>{})}),tvt=Mn(be([r5.and(x({type:O("env_var")})),n5.and(x({type:O("terminal")})),o5.and(x({type:O("agent")})),$n(x({type:g(),methodId:cb,name:g(),description:y(g().nullish(),()=>{}),_meta:y(C(g(),T()).nullish(),()=>{})}),"type",["agent","env_var","terminal"])]),"type",["agent","env_var","terminal"]),i5=x({protocolVersion:OCe,info:$Ce,capabilities:y(Xwt.optional().default({}),()=>({})),authMethods:y(Ve(tvt).optional(),()=>[]),_meta:y(C(g(),T()).nullish(),()=>{})}),rvt=x({_meta:y(C(g(),T()).nullish(),()=>{})}),s5=g(),a5=be([O("anthropic"),O("openai"),O("azure"),O("vertex"),O("bedrock"),g()]),nvt=x({apiType:a5,baseUrl:_r(),_meta:y(C(g(),T()).nullish(),()=>{})}),ovt=x({providerId:s5,supported:Kn(Ve(a5),()=>[]),required:mr(),current:nvt.nullish(),_meta:y(C(g(),T()).nullish(),()=>{})}),ivt=x({providers:gt(ovt),_meta:y(C(g(),T()).nullish(),()=>{})}),svt=x({_meta:y(C(g(),T()).nullish(),()=>{})}),avt=x({_meta:y(C(g(),T()).nullish(),()=>{})}),cvt=x({_meta:y(C(g(),T()).nullish(),()=>{})}),jp=g(),lvt=be([O("mode"),O("model"),O("model_config"),O("thought_level"),g()]),ZR=g(),NCe=x({value:ZR,name:g(),description:y(g().nullish(),()=>{}),_meta:y(C(g(),T()).nullish(),()=>{})}),uvt=g(),dvt=x({groupId:uvt,name:g(),options:Kn(Ve(NCe),()=>[]),_meta:y(C(g(),T()).nullish(),()=>{})}),pvt=be([gt(NCe),gt(dvt)]),c5=x({currentValue:ZR,options:pvt}),l5=x({currentValue:mr()}),JR=Mn(Ho(be([c5.and(x({type:O("select")})),l5.and(x({type:O("boolean")})),$n(x({type:g()}),"type",["boolean","select"])]),x({configId:jp,name:g(),description:y(g().nullish(),()=>{}),category:y(lvt.nullish(),()=>{}),_meta:y(C(g(),T()).nullish(),()=>{})})),"type",["boolean","select"]),fvt=x({sessionId:dn,configOptions:y(Ve(JR).optional(),()=>[]),_meta:y(C(g(),T()).nullish(),()=>{})}),mvt=x({sessionId:dn,cwd:ss,additionalDirectories:y(Ve(ss).optional(),()=>[]),title:y(g().nullish(),()=>{}),updatedAt:y(Ku.datetime({offset:!0}).nullish(),()=>{}),_meta:y(C(g(),T()).nullish(),()=>{})}),zCe=g(),hvt=x({sessions:Kn(Ve(mvt),()=>[]),nextCursor:y(zCe.nullish(),()=>{}),_meta:y(C(g(),T()).nullish(),()=>{})}),gvt=x({_meta:y(C(g(),T()).nullish(),()=>{})}),yvt=x({sessionId:dn,configOptions:y(Ve(JR).optional(),()=>[]),_meta:y(C(g(),T()).nullish(),()=>{})}),bvt=x({configOptions:y(Ve(JR).optional(),()=>[]),_meta:y(C(g(),T()).nullish(),()=>{})}),xvt=x({_meta:y(C(g(),T()).nullish(),()=>{})}),Svt=x({configOptions:Kn(Ve(JR),()=>[]),_meta:y(C(g(),T()).nullish(),()=>{})}),kvt=x({_meta:y(C(g(),T()).nullish(),()=>{})}),_vt=x({sessionId:dn,_meta:y(C(g(),T()).nullish(),()=>{})}),Up=g(),ch=x({line:fr().gte(0).max(4294967295,{error:"Invalid value: Expected uint32 to be <= 4294967295"}),character:fr().gte(0).max(4294967295,{error:"Invalid value: Expected uint32 to be <= 4294967295"}),_meta:y(C(g(),T()).nullish(),()=>{})}),y_=x({start:ch,end:ch,_meta:y(C(g(),T()).nullish(),()=>{})}),wvt=x({range:y_,newText:g(),_meta:y(C(g(),T()).nullish(),()=>{})}),u5=x({suggestionId:Up,uri:_r(),edits:gt(wvt).min(1),cursorPosition:y(ch.nullish(),()=>{}),_meta:y(C(g(),T()).nullish(),()=>{})}),d5=x({suggestionId:Up,uri:_r(),position:ch,_meta:y(C(g(),T()).nullish(),()=>{})}),p5=x({suggestionId:Up,uri:_r(),position:ch,newName:g(),_meta:y(C(g(),T()).nullish(),()=>{})}),f5=x({suggestionId:Up,uri:_r(),search:g(),replace:g(),isRegex:mr().nullish(),_meta:y(C(g(),T()).nullish(),()=>{})}),vvt=Mn(be([u5.and(x({kind:O("edit")})),d5.and(x({kind:O("jump")})),p5.and(x({kind:O("rename")})),f5.and(x({kind:O("searchAndReplace")})),$n(x({kind:g(),suggestionId:Up}),"kind",["edit","jump","rename","searchAndReplace"])]),"kind",["edit","jump","rename","searchAndReplace"]),Evt=x({suggestions:gt(vvt),_meta:y(C(g(),T()).nullish(),()=>{})}),Rvt=x({_meta:y(C(g(),T()).nullish(),()=>{})}),LCe=T(),FCe=T(),Tvt=be([O(-32700),O(-32600),O(-32601),O(-32602),O(-32603),O(-32800),O(-32e3),O(-32002),fr().min(-2147483648,{error:"Invalid value: Expected int32 to be >= -2147483648"}).max(2147483647,{error:"Invalid value: Expected int32 to be <= 2147483647"})]),jCe=x({code:Tvt,message:g(),data:y(T().optional(),()=>{})}),E_r=be([x({id:ah,result:be([i5,rvt,ivt,svt,avt,cvt,fvt,hvt,gvt,yvt,bvt,xvt,Svt,kvt,_vt,Evt,Rvt,LCe,FCe])}),x({id:ah,error:jCe})]),U1=g(),sb=x({messageId:U1,content:g_,_meta:y(C(g(),T()).nullish(),()=>{})}),m5=x({messageId:U1,content:y(Ve(g_).nullish(),()=>{}),_meta:y(C(g(),T()).nullish(),()=>{})}),h5=x({messageId:U1,content:y(Ve(g_).nullish(),()=>{}),_meta:y(C(g(),T()).nullish(),()=>{})}),g5=x({messageId:U1,content:y(Ve(g_).nullish(),()=>{}),_meta:y(C(g(),T()).nullish(),()=>{})}),y5=x({_meta:y(C(g(),T()).nullish(),()=>{})}),Cvt=be([O("end_turn"),O("max_tokens"),O("max_turn_requests"),O("refusal"),O("cancelled"),g()]),Pvt=x({totalTokens:rt(),inputTokens:rt(),outputTokens:rt(),thoughtTokens:y(rt().nullish(),()=>{}),cachedReadTokens:y(rt().nullish(),()=>{}),cachedWriteTokens:y(rt().nullish(),()=>{}),_meta:y(C(g(),T()).nullish(),()=>{})}),b5=x({stopReason:y(Cvt.nullish(),()=>{}),usage:y(Pvt.nullish(),()=>{}),_meta:y(C(g(),T()).nullish(),()=>{})}),x5=x({_meta:y(C(g(),T()).nullish(),()=>{})}),S5=Mn(be([y5.and(x({state:O("running")})),b5.and(x({state:O("idle")})),x5.and(x({state:O("requires_action")})),$n(x({state:g()}),"state",["idle","requires_action","running"])]),"state",["idle","requires_action","running"]),k5=x({toolCallId:z1,content:ECe,_meta:y(C(g(),T()).nullish(),()=>{})}),Ivt=x({data:g(),_meta:y(C(g(),T()).nullish(),()=>{})}),Avt=x({exitCode:y(fr().gte(0).max(4294967295,{error:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),()=>{}),signal:y(g().nullish(),()=>{}),_meta:y(C(g(),T()).nullish(),()=>{})}),_5=x({terminalId:L1,command:y(g().nullish(),()=>{}),cwd:y(ss.nullish(),()=>{}),output:y(Ivt.nullish(),()=>{}),exitStatus:y(Avt.nullish(),()=>{}),_meta:y(C(g(),T()).nullish(),()=>{})}),w5=x({terminalId:L1,data:g(),_meta:y(C(g(),T()).nullish(),()=>{})}),lb=g(),Ovt=be([O("high"),O("medium"),O("low"),g()]),$vt=be([O("pending"),O("in_progress"),O("completed"),O("cancelled"),g()]),Mvt=x({content:g(),priority:Ovt,status:$vt,_meta:y(C(g(),T()).nullish(),()=>{})}),v5=x({planId:lb,entries:Kn(Ve(Mvt),()=>[]),_meta:y(C(g(),T()).nullish(),()=>{})}),E5=x({planId:lb,uri:_r(),_meta:y(C(g(),T()).nullish(),()=>{})}),R5=x({planId:lb,content:g(),_meta:y(C(g(),T()).nullish(),()=>{})}),Dvt=Mn(be([v5.and(x({type:O("items")})),E5.and(x({type:O("file")})),R5.and(x({type:O("markdown")})),$n(x({type:g(),planId:lb}),"type",["file","items","markdown"])]),"type",["file","items","markdown"]),T5=x({plan:Dvt,_meta:y(C(g(),T()).nullish(),()=>{})}),C5=x({planId:lb,_meta:y(C(g(),T()).nullish(),()=>{})}),P5=x({hint:g(),_meta:y(C(g(),T()).nullish(),()=>{})}),Nvt=Mn(be([P5.and(x({type:O("text")})),$n(x({type:g()}),"type",["text"])]),"type",["text"]),zvt=x({name:g(),description:g(),input:y(Nvt.nullish(),()=>{}),_meta:y(C(g(),T()).nullish(),()=>{})}),I5=x({availableCommands:Kn(Ve(zvt),()=>[]),_meta:y(C(g(),T()).nullish(),()=>{})}),A5=x({configOptions:Kn(Ve(JR),()=>[]),_meta:y(C(g(),T()).nullish(),()=>{})}),O5=x({title:y(g().nullish(),()=>{}),updatedAt:y(Ku.datetime({offset:!0}).nullish(),()=>{}),_meta:y(C(g(),T()).nullish(),()=>{})}),Lvt=x({amount:rt(),currency:g().regex(/^[A-Z]{3}$/),_meta:y(C(g(),T()).nullish(),()=>{})}),$5=x({used:rt(),size:rt(),cost:y(Lvt.nullish(),()=>{}),_meta:y(C(g(),T()).nullish(),()=>{})}),Fvt=Mn(be([sb.and(x({sessionUpdate:O("user_message_chunk")})),m5.and(x({sessionUpdate:O("user_message")})),sb.and(x({sessionUpdate:O("agent_message_chunk")})),h5.and(x({sessionUpdate:O("agent_message")})),sb.and(x({sessionUpdate:O("agent_thought_chunk")})),g5.and(x({sessionUpdate:O("agent_thought")})),S5.and(x({sessionUpdate:O("state_update")})),k5.and(x({sessionUpdate:O("tool_call_content_chunk")})),F1.and(x({sessionUpdate:O("tool_call_update")})),_5.and(x({sessionUpdate:O("terminal_update")})),w5.and(x({sessionUpdate:O("terminal_output_chunk")})),T5.and(x({sessionUpdate:O("plan_update")})),C5.and(x({sessionUpdate:O("plan_removed")})),I5.and(x({sessionUpdate:O("available_commands_update")})),A5.and(x({sessionUpdate:O("config_option_update")})),O5.and(x({sessionUpdate:O("session_info_update")})),$5.and(x({sessionUpdate:O("usage_update")})),$n(x({sessionUpdate:g()}),"sessionUpdate",["agent_message","agent_message_chunk","agent_thought","agent_thought_chunk","available_commands_update","config_option_update","plan_removed","plan_update","session_info_update","state_update","terminal_output_chunk","terminal_update","tool_call_content_chunk","tool_call_update","usage_update","user_message","user_message_chunk"])]),"sessionUpdate",["agent_message","agent_message_chunk","agent_thought","agent_thought_chunk","available_commands_update","config_option_update","plan_removed","plan_update","session_info_update","state_update","terminal_output_chunk","terminal_update","tool_call_content_chunk","tool_call_update","usage_update","user_message","user_message_chunk"]),H1=x({sessionId:dn,update:Fvt,_meta:y(C(g(),T()).nullish(),()=>{})}),M5=x({elicitationId:PCe,_meta:y(C(g(),T()).nullish(),()=>{})}),YR=x({connectionId:j1,method:g(),params:y(C(g(),T()).nullish(),()=>{}),_meta:y(C(g(),T()).nullish(),()=>{})}),UCe=T(),R_r=x({method:g(),params:be([H1,M5,YR,UCe]).nullish()}),jvt=x({_meta:y(C(g(),T()).nullish(),()=>{})}),Uvt=x({terminal:y(jvt.nullish(),()=>{}),_meta:y(C(g(),T()).nullish(),()=>{})}),Hvt=x({_meta:y(C(g(),T()).nullish(),()=>{})}),qvt=x({_meta:y(C(g(),T()).nullish(),()=>{})}),Gvt=x({form:y(Hvt.nullish(),()=>{}),url:y(qvt.nullish(),()=>{}),_meta:y(C(g(),T()).nullish(),()=>{})}),Bvt=x({_meta:y(C(g(),T()).nullish(),()=>{})}),Wvt=x({_meta:y(C(g(),T()).nullish(),()=>{})}),Vvt=x({_meta:y(C(g(),T()).nullish(),()=>{})}),Kvt=x({jump:y(Bvt.nullish(),()=>{}),rename:y(Wvt.nullish(),()=>{}),searchAndReplace:y(Vvt.nullish(),()=>{}),_meta:y(C(g(),T()).nullish(),()=>{})}),Zvt=x({auth:y(Uvt.nullish(),()=>{}),elicitation:y(Gvt.nullish(),()=>{}),nes:y(Kvt.nullish(),()=>{}),positionEncodings:y(Ve(MCe).optional(),()=>[]),_meta:y(C(g(),T()).nullish(),()=>{})}),q1=x({protocolVersion:OCe,info:$Ce,capabilities:y(Zvt.optional().default({}),()=>({})),_meta:y(C(g(),T()).nullish(),()=>{})}),D5=x({methodId:cb,_meta:y(C(g(),T()).nullish(),()=>{})}),N5=x({_meta:y(C(g(),T()).nullish(),()=>{})}),z5=x({providerId:s5,apiType:a5,baseUrl:_r(),headers:C(g(),g()).optional(),_meta:y(C(g(),T()).nullish(),()=>{})}),L5=x({providerId:s5,_meta:y(C(g(),T()).nullish(),()=>{})}),F5=x({_meta:y(C(g(),T()).nullish(),()=>{})}),Jvt=x({name:g(),value:g(),_meta:y(C(g(),T()).nullish(),()=>{})}),j5=x({name:g(),url:_r(),headers:gt(Jvt).optional(),_meta:y(C(g(),T()).nullish(),()=>{})}),U5=x({name:g(),serverId:ICe,_meta:y(C(g(),T()).nullish(),()=>{})}),H5=x({name:g(),command:ss,args:gt(g()).optional(),env:gt(DCe).optional(),_meta:y(C(g(),T()).nullish(),()=>{})}),q5=Mn(be([j5.and(x({type:O("http")})),U5.and(x({type:O("acp")})),H5.and(x({type:O("stdio")})),$n(x({type:g()}),"type",["acp","http","stdio"])]),"type",["acp","http","stdio"]),G5=x({cwd:ss,additionalDirectories:y(Ve(ss).optional(),()=>[]),mcpServers:y(Ve(q5).optional(),()=>[]),_meta:y(C(g(),T()).nullish(),()=>{})}),B5=x({cwd:ss.nullish(),cursor:zCe.nullish(),_meta:y(C(g(),T()).nullish(),()=>{})}),W5=x({sessionId:dn,_meta:y(C(g(),T()).nullish(),()=>{})}),V5=x({sessionId:dn,cwd:ss,additionalDirectories:y(Ve(ss).optional(),()=>[]),mcpServers:y(Ve(q5).optional(),()=>[]),_meta:y(C(g(),T()).nullish(),()=>{})}),K5=x({_meta:y(C(g(),T()).nullish(),()=>{})}),Yvt=Mn(be([K5.and(x({type:O("start")})),$n(x({type:g(),_meta:y(C(g(),T()).nullish(),()=>{})}),"type",["start"])]),"type",["start"]),Z5=x({sessionId:dn,cwd:ss,additionalDirectories:y(Ve(ss).optional(),()=>[]),mcpServers:y(Ve(q5).optional(),()=>[]),replayFrom:y(Yvt.nullish(),()=>{}),_meta:y(C(g(),T()).nullish(),()=>{})}),J5=x({sessionId:dn,_meta:y(C(g(),T()).nullish(),()=>{})}),Y5=Mn(Ho(be([x({value:ZR,type:O("id")}),x({value:mr(),type:O("boolean")}),$n(x({type:g(),value:T()}),"type",["boolean","id"])]),x({sessionId:dn,configId:jp,_meta:y(C(g(),T()).nullish(),()=>{})})),"type",["boolean","id"]),Q5=x({sessionId:dn,prompt:gt(g_),_meta:y(C(g(),T()).nullish(),()=>{})}),Qvt=x({uri:_r(),name:g(),_meta:y(C(g(),T()).nullish(),()=>{})}),Xvt=x({name:g(),owner:g(),remoteUrl:g(),_meta:y(C(g(),T()).nullish(),()=>{})}),X5=x({workspaceUri:y(_r().nullish(),()=>{}),workspaceFolders:gt(Qvt).nullish(),repository:y(Xvt.nullish(),()=>{}),_meta:y(C(g(),T()).nullish(),()=>{})}),eEt=be([O("automatic"),O("diagnostic"),O("manual"),g()]),tEt=x({uri:_r(),languageId:g(),text:g(),_meta:y(C(g(),T()).nullish(),()=>{})}),rEt=x({startLine:fr().gte(0).max(4294967295,{error:"Invalid value: Expected uint32 to be <= 4294967295"}),endLine:fr().gte(0).max(4294967295,{error:"Invalid value: Expected uint32 to be <= 4294967295"}),text:g(),_meta:y(C(g(),T()).nullish(),()=>{})}),nEt=x({uri:_r(),excerpts:gt(rEt),_meta:y(C(g(),T()).nullish(),()=>{})}),oEt=x({uri:_r(),diff:g(),_meta:y(C(g(),T()).nullish(),()=>{})}),iEt=x({action:g(),uri:_r(),position:ch,timestampMs:rt(),_meta:y(C(g(),T()).nullish(),()=>{})}),sEt=x({uri:_r(),languageId:g(),visibleRange:y(y_.nullish(),()=>{}),lastFocusedMs:y(rt().nullish(),()=>{}),_meta:y(C(g(),T()).nullish(),()=>{})}),aEt=be([O("error"),O("warning"),O("information"),O("hint"),g()]),cEt=x({uri:_r(),range:y_,severity:aEt,message:g(),_meta:y(C(g(),T()).nullish(),()=>{})}),lEt=x({recentFiles:gt(tEt).nullish(),relatedSnippets:gt(nEt).nullish(),editHistory:gt(oEt).nullish(),userActions:gt(iEt).nullish(),openFiles:gt(sEt).nullish(),diagnostics:gt(cEt).nullish(),_meta:y(C(g(),T()).nullish(),()=>{})}),e7=x({sessionId:dn,uri:_r(),version:rt(),position:ch,selection:y_.nullish(),triggerKind:eEt,context:lEt.nullish(),_meta:y(C(g(),T()).nullish(),()=>{})}),t7=x({sessionId:dn,_meta:y(C(g(),T()).nullish(),()=>{})}),T_r=x({id:ah,method:g(),params:be([q1,D5,N5,z5,L5,F5,G5,B5,W5,V5,Z5,J5,Y5,Q5,X5,e7,t7,KR,ACe]).nullish()}),r7=x({optionId:RCe,_meta:y(C(g(),T()).nullish(),()=>{})}),uEt=Mn(be([x({outcome:O("cancelled")}),r7.and(x({outcome:O("selected")})),$n(x({outcome:g()}),"outcome",["cancelled","selected"])]),"outcome",["cancelled","selected"]),dEt=x({outcome:uEt,_meta:y(C(g(),T()).nullish(),()=>{})}),pEt=be([g(),rt(),rt(),mr(),gt(g())]),n7=x({content:C(g(),pEt).nullish()}),fEt=Mn(Ho(be([n7.and(x({action:O("accept")})),x({action:O("decline")}),x({action:O("cancel")}),$n(x({action:g()}),"action",["accept","cancel","decline"])]),x({_meta:y(C(g(),T()).nullish(),()=>{})})),"action",["accept","cancel","decline"]),mEt=x({connectionId:j1,_meta:y(C(g(),T()).nullish(),()=>{})}),hEt=x({_meta:y(C(g(),T()).nullish(),()=>{})}),C_r=be([x({id:ah,result:be([dEt,fEt,mEt,hEt,FCe,LCe])}),x({id:ah,error:jCe})]),o7=x({sessionId:dn,_meta:y(C(g(),T()).nullish(),()=>{})}),i7=x({sessionId:dn,uri:_r(),languageId:g(),version:rt(),text:g(),_meta:y(C(g(),T()).nullish(),()=>{})}),gEt=x({range:y_.nullish(),text:g(),_meta:y(C(g(),T()).nullish(),()=>{})}),s7=x({sessionId:dn,uri:_r(),version:rt(),contentChanges:Kn(Ve(gEt),()=>[]),_meta:y(C(g(),T()).nullish(),()=>{})}),a7=x({sessionId:dn,uri:_r(),_meta:y(C(g(),T()).nullish(),()=>{})}),c7=x({sessionId:dn,uri:_r(),_meta:y(C(g(),T()).nullish(),()=>{})}),l7=x({sessionId:dn,uri:_r(),version:rt(),position:ch,visibleRange:y_,_meta:y(C(g(),T()).nullish(),()=>{})}),u7=x({sessionId:dn,suggestionId:Up,_meta:y(C(g(),T()).nullish(),()=>{})}),yEt=be([O("rejected"),O("ignored"),O("replaced"),O("cancelled"),g()]),d7=x({sessionId:dn,suggestionId:Up,reason:y(yEt.nullish(),()=>{}),_meta:y(C(g(),T()).nullish(),()=>{})}),P_r=x({method:g(),params:be([o7,i7,s7,a7,c7,l7,u7,d7,YR,UCe]).nullish()}),bEt=x({requestId:ah,_meta:y(C(g(),T()).nullish(),()=>{})}),I_r=x({method:g(),params:bEt.nullish()});function rn(e,t){return typeof e=="object"&&e!==null?e[t]:void 0}var A_r=H8.and(x({type:O("tool_call")})),O_r=q8.and(x({type:O("command")})),$_r=F8.and(x({type:O("content")})),M_r=j8.and(x({type:O("diff")})),D_r=U8.and(x({type:O("terminal")})),xEt=M8.and(x({type:O("text")})),SEt=D8.and(x({type:O("image")})),kEt=N8.and(x({type:O("audio")})),_Et=z8.and(x({type:O("resource_link")})),wEt=L8.and(x({type:O("resource")})),N_r=ib.and(x({operation:O("add")})),z_r=ib.and(x({operation:O("delete")})),L_r=ib.and(x({operation:O("modify")})),F_r=GR.and(x({operation:O("move")})),j_r=GR.and(x({operation:O("copy")})),U_r=Y8.and(x({mode:O("form")})).and(x({message:g()})),H_r=Q8.and(x({mode:O("url")})).and(x({message:g()})),q_r=be([WR,VR]).and(x({message:g()})),G_r=B8.and(x({type:O("string")})),B_r=W8.and(x({type:O("number")})),W_r=V8.and(x({type:O("integer")})),V_r=K8.and(x({type:O("boolean")})),K_r=J8.and(x({type:O("array")})),Z_r=Z8.and(x({type:O("string")}));var J_r=r5.and(x({type:O("env_var")})),Y_r=n5.and(x({type:O("terminal")})),Q_r=o5.and(x({type:O("agent")})),X_r=x({methodId:cb,name:g()}),ewr=c5.and(x({type:O("select")})).and(x({configId:jp,name:g()})),twr=l5.and(x({type:O("boolean")})).and(x({configId:jp,name:g()})),rwr=x({configId:jp,name:g()}),nwr=u5.and(x({kind:O("edit")})),owr=d5.and(x({kind:O("jump")})),iwr=p5.and(x({kind:O("rename")})),swr=f5.and(x({kind:O("searchAndReplace")})),awr=x({suggestionId:Up}),vEt=sb.and(x({sessionUpdate:O("user_message_chunk")})),EEt=m5.and(x({sessionUpdate:O("user_message")})),REt=sb.and(x({sessionUpdate:O("agent_message_chunk")})),TEt=h5.and(x({sessionUpdate:O("agent_message")})),CEt=sb.and(x({sessionUpdate:O("agent_thought_chunk")})),PEt=g5.and(x({sessionUpdate:O("agent_thought")})),IEt=S5.and(x({sessionUpdate:O("state_update")})),AEt=k5.and(x({sessionUpdate:O("tool_call_content_chunk")})),OEt=F1.and(x({sessionUpdate:O("tool_call_update")})),$Et=_5.and(x({sessionUpdate:O("terminal_update")})),MEt=w5.and(x({sessionUpdate:O("terminal_output_chunk")})),DEt=T5.and(x({sessionUpdate:O("plan_update")})),NEt=C5.and(x({sessionUpdate:O("plan_removed")})),zEt=I5.and(x({sessionUpdate:O("available_commands_update")})),LEt=A5.and(x({sessionUpdate:O("config_option_update")})),FEt=O5.and(x({sessionUpdate:O("session_info_update")})),jEt=$5.and(x({sessionUpdate:O("usage_update")})),UEt=y5.and(x({state:O("running")})),HEt=b5.and(x({state:O("idle")})),qEt=x5.and(x({state:O("requires_action")})),cwr=v5.and(x({type:O("items")})),lwr=E5.and(x({type:O("file")})),uwr=R5.and(x({type:O("markdown")})),dwr=x({planId:lb}),pwr=P5.and(x({type:O("text")})),fwr=j5.and(x({type:O("http")})),mwr=U5.and(x({type:O("acp")})),hwr=H5.and(x({type:O("stdio")})),gwr=K5.and(x({type:O("start")})),ywr=x({type:O("id")}).and(x({value:ZR})).and(x({sessionId:dn,configId:jp})),bwr=x({type:O("boolean")}).and(x({value:mr()})).and(x({sessionId:dn,configId:jp})),xwr=x({value:T()}).and(x({sessionId:dn,configId:jp})),Swr=x({outcome:O("cancelled")}),kwr=r7.and(x({outcome:O("selected")})),_wr=n7.and(x({action:O("accept")})),wwr=x({action:O("decline")}),vwr=x({action:O("cancel")});var p7={isText(e){return rn(e,"type")==="text"&&xEt.safeParse(e).success},isImage(e){return rn(e,"type")==="image"&&SEt.safeParse(e).success},isAudio(e){return rn(e,"type")==="audio"&&kEt.safeParse(e).success},isResourceLink(e){return rn(e,"type")==="resource_link"&&_Et.safeParse(e).success},isResource(e){return rn(e,"type")==="resource"&&wEt.safeParse(e).success},isCustom(e){let t=rn(e,"type");return typeof t=="string"&&!["audio","image","resource","resource_link","text"].includes(t)}};var QR={isUserMessageChunk(e){return rn(e,"sessionUpdate")==="user_message_chunk"&&vEt.safeParse(e).success},isUserMessage(e){return rn(e,"sessionUpdate")==="user_message"&&EEt.safeParse(e).success},isAgentMessageChunk(e){return rn(e,"sessionUpdate")==="agent_message_chunk"&&REt.safeParse(e).success},isAgentMessage(e){return rn(e,"sessionUpdate")==="agent_message"&&TEt.safeParse(e).success},isAgentThoughtChunk(e){return rn(e,"sessionUpdate")==="agent_thought_chunk"&&CEt.safeParse(e).success},isAgentThought(e){return rn(e,"sessionUpdate")==="agent_thought"&&PEt.safeParse(e).success},isStateUpdate(e){return rn(e,"sessionUpdate")==="state_update"&&IEt.safeParse(e).success},isToolCallContentChunk(e){return rn(e,"sessionUpdate")==="tool_call_content_chunk"&&AEt.safeParse(e).success},isToolCallUpdate(e){return rn(e,"sessionUpdate")==="tool_call_update"&&OEt.safeParse(e).success},isTerminalUpdate(e){return rn(e,"sessionUpdate")==="terminal_update"&&$Et.safeParse(e).success},isTerminalOutputChunk(e){return rn(e,"sessionUpdate")==="terminal_output_chunk"&&MEt.safeParse(e).success},isPlanUpdate(e){return rn(e,"sessionUpdate")==="plan_update"&&DEt.safeParse(e).success},isPlanRemoved(e){return rn(e,"sessionUpdate")==="plan_removed"&&NEt.safeParse(e).success},isAvailableCommandsUpdate(e){return rn(e,"sessionUpdate")==="available_commands_update"&&zEt.safeParse(e).success},isConfigOptionUpdate(e){return rn(e,"sessionUpdate")==="config_option_update"&&LEt.safeParse(e).success},isSessionInfoUpdate(e){return rn(e,"sessionUpdate")==="session_info_update"&&FEt.safeParse(e).success},isUsageUpdate(e){return rn(e,"sessionUpdate")==="usage_update"&&jEt.safeParse(e).success},isCustom(e){let t=rn(e,"sessionUpdate");return typeof t=="string"&&!["agent_message","agent_message_chunk","agent_thought","agent_thought_chunk","available_commands_update","config_option_update","plan_removed","plan_update","session_info_update","state_update","terminal_output_chunk","terminal_update","tool_call_content_chunk","tool_call_update","usage_update","user_message","user_message_chunk"].includes(t)}},f7={isRunning(e){return rn(e,"state")==="running"&&UEt.safeParse(e).success},isIdle(e){return rn(e,"state")==="idle"&&HEt.safeParse(e).success},isRequiresAction(e){return rn(e,"state")==="requires_action"&&qEt.safeParse(e).success},isCustom(e){let t=rn(e,"state");return typeof t=="string"&&!["idle","requires_action","running"].includes(t)}};function Hp(e){return e??{}}function qp(e,t,r,n=!1){if(!(Object.hasOwn(t,e)||n&&e===N1.cancel_request)&&!e.startsWith("_"))throw new TypeError(`Custom ACP v2 ${r} method '${e}' must start with '_'`)}function VCe(e,t,r){for(let n of e)qp(n.method,n.kind==="request"?t:r,n.kind,n.kind==="notification")}function KCe(e){let t=q1.parse(e);if(t.protocolVersion!==Fp)throw Xr.invalidParams({expectedProtocolVersion:Fp,receivedProtocolVersion:t.protocolVersion},`The v2 API only supports protocol version ${Fp}`);return t}function ZCe(e){let t=typeof e=="object"&&e!==null&&!Array.isArray(e)?e:{};return KCe({...t,protocolVersion:Fp})}function JCe(e){let t=i5.parse(e);if(t.protocolVersion!==Fp)throw Xr.invalidRequest({expectedProtocolVersion:Fp,receivedProtocolVersion:t.protocolVersion},`The v2 API only supports protocol version ${Fp}`);return t}function BEt(e){return e.map(t=>{if(t.kind!=="request"||t.method!==ct.initialize)return t;let r=t.mapResponse;return{...t,params:ZCe(t.params),mapResponse:n=>{let o=JCe(n);return r?r(o):o}}})}function YCe(e){return typeof e=="object"&&e!==null&&"readable"in e&&"writable"in e}function QCe(){let e=new TransformStream,t=new TransformStream;return[{readable:t.readable,writable:e.writable},{readable:e.readable,writable:t.writable}]}var Ywr={agent:{initialize:ct.initialize,auth:{login:ct.auth_login,logout:ct.auth_logout},providers:{list:ct.providers_list,set:ct.providers_set,disable:ct.providers_disable},session:{new:ct.session_new,list:ct.session_list,delete:ct.session_delete,fork:ct.session_fork,resume:ct.session_resume,close:ct.session_close,setConfigOption:ct.session_set_config_option,prompt:ct.session_prompt,cancel:ct.session_cancel},mcp:{message:ct.mcp_message},nes:{start:ct.nes_start,suggest:ct.nes_suggest,accept:ct.nes_accept,reject:ct.nes_reject,close:ct.nes_close},document:{didOpen:ct.document_did_open,didChange:ct.document_did_change,didClose:ct.document_did_close,didSave:ct.document_did_save,didFocus:ct.document_did_focus}},client:{session:{requestPermission:vi.session_request_permission,update:vi.session_update},mcp:{connect:vi.mcp_connect,message:vi.mcp_message,disconnect:vi.mcp_disconnect},elicitation:{create:vi.elicitation_create,complete:vi.elicitation_complete}},protocol:{cancelRequest:N1.cancel_request}},XCe=Symbol("startActiveSession"),W1=class{cx;currentRequestId;constructor(t,r){this.cx=t,this.currentRequestId=r}get requestId(){return this.currentRequestId}get connectionContext(){return this.cx}sendRequest(t,r,n,o){return this.cx.sendRequest(t,r,n,o)}sendNotification(t,r){return this.cx.sendNotification(t,r)}sendBatch(t){return this.cx.sendBatch(t)}addDynamicHandler(t){return this.cx.addDynamicHandler(t)}},tT=class e extends W1{constructor(t,r){super(t,r)}static create(t,r){return new e(t,r)}request(t,r,n){qp(t,eT,"request");let o=eT[t];return this.sendRequest(t,r,o?.mapResponse,n)}notify(t,r){return qp(t,J1,"notification",!0),this.sendNotification(t,r)}batch(t){return VCe(t,eT,J1),this.sendBatch(t)}},rT=class e extends W1{constructor(t,r){super(t,r)}static create(t,r){return new e(t,r)}[XCe](t,r){return this.sendRequest(ct.session_new,t,n=>this.attachSession(n),r)}buildSession(t){return typeof t=="string"?K1.create(this,{cwd:t,mcpServers:[]}):K1.create(this,t)}attachSession(t){let r=new g7,n=new Set,o={enqueue:l=>r.enqueue(l),reject:l=>r.reject(l),clearErrors:()=>r.clearErrors(),fail:l=>r.fail(l),next:()=>r.next(),nextAfter:(l,u)=>r.nextAfter(l,u),beginPrompt:()=>{let l={updateCursor:r.cursor(),overlapController:new AbortController};if(n.size>0){let u=new Error("readText() cannot attribute updates across overlapping prompts; use nextUpdate() instead");for(let d of n)d.overlapController.abort(u);l.overlapController.abort(u)}return n.add(l),l},cancelPrompt:l=>n.delete(l),isAwaitingPromptCompletion:()=>n.size>0,completePrompt:()=>{n.clear()}},i=this.connectionContext.signal,s=()=>{r.fail(i.reason??new Error("ACP connection closed"))};i.aborted?s():i.addEventListener("abort",s);let a=iPe(this.connectionContext).attach(t,o),c=new Ap(()=>{i.removeEventListener("abort",s)});return y7.create(this,t,o,[a,c])}request(t,r,n){qp(t,XR,"request");let o=XR[t],i=t===ct.initialize?ZCe(r):r;return this.sendRequest(t,i,o?.mapResponse,n)}notify(t,r){return qp(t,Z1,"notification",!0),this.sendNotification(t,r)}batch(t){return VCe(t,XR,Z1),this.sendBatch(BEt(t))}},V1=class{connection;constructor(t){this.connection=t}get signal(){return this.connection.signal}get closed(){return this.connection.closed}close(t){this.connection.close(t)}},m7=class extends V1{connectHandlers;client;didStartConnectHandlers=!1;constructor(t,r=[]){super(t),this.connectHandlers=r,this.client=tT.create(t.getContext())}startConnectHandlers(){this.didStartConnectHandlers||(this.didStartConnectHandlers=!0,X1(this,this.connectHandlers))}},h7=class extends V1{connectHandlers;agent;didStartConnectHandlers=!1;constructor(t,r=[]){super(t),this.connectHandlers=r,this.agent=rT.create(t.getContext())}startConnectHandlers(){this.didStartConnectHandlers||(this.didStartConnectHandlers=!0,X1(this,this.connectHandlers))}};function ePe(e,t=[]){return new m7(e,t)}function tPe(e,t=[]){return new h7(e,t)}var g7=class{values=[];waiters=[];failed=!1;failure;nextSequence=0;enqueue(t){if(this.failed)return;let r=this.nextSequence++,n=this.waiters.shift();n?n.resolve(t):this.values.push({kind:"value",value:t,sequence:r})}reject(t){if(this.failed)return;let r=this.nextSequence++;if(this.waiters.length>0){for(let n of this.waiters.splice(0))n.reject(t);return}this.values.push({kind:"error",error:t,sequence:r})}clearErrors(){this.values=this.values.filter(t=>t.kind==="value")}cursor(){return this.nextSequence}nextAfter(t,r){if(r?.aborted)return Promise.reject(r.reason);for(;this.values[0]&&this.values[0].sequence<t;)this.values.shift();return this.next(r)}fail(t){if(!this.failed){this.failed=!0,this.failure=t;for(let r of this.waiters.splice(0))r.reject(t)}}next(t){if(t?.aborted)return Promise.reject(t.reason);if(this.values.length>0){let r=this.values.shift();return r.kind==="error"?Promise.reject(r.error):Promise.resolve(r.value)}return this.failed?Promise.reject(this.failure):new Promise((r,n)=>{let o=()=>{t?.removeEventListener("abort",s)},i={resolve:a=>{o(),r(a)},reject:a=>{o(),n(a)}},s=()=>{let a=this.waiters.indexOf(i);a>=0&&this.waiters.splice(a,1),i.reject(t?.reason)};this.waiters.push(i),t?.addEventListener("abort",s,{once:!0}),t?.aborted&&s()})}};function qCe(e){return structuredClone(e)}var K1=class e{cx;request;constructor(t,r){this.cx=t,this.request=qCe(r)}static create(t,r){return new e(t,r)}toRequest(){return qCe(this.request)}withAdditionalDirectories(t){return this.request={...this.request,additionalDirectories:[...t]},this}withMcpServer(t){return this.request={...this.request,mcpServers:[...this.request.mcpServers??[],structuredClone(t)]},this}async start(t){return this.cx[XCe](this.toRequest(),t)}async withSession(t){let r=await this.start();try{return await t(r)}finally{r.dispose()}}},y7=class e{cx;sessionResponse;updates;registrations;latestPrompt;constructor(t,r,n,o){this.cx=t,this.sessionResponse=r,this.updates=n,this.registrations=o}static create(t,r,n,o){return new e(t,r,n,o)}get sessionId(){return this.sessionResponse.sessionId}get configOptions(){return this.sessionResponse.configOptions}get meta(){return this.sessionResponse._meta}get newSessionResponse(){return this.sessionResponse}prompt(t,r){this.updates.clearErrors();let n=this.updates.beginPrompt();this.latestPrompt=n;let o=this.cx.request(ct.session_prompt,{sessionId:this.sessionId,prompt:this.promptBlocks(t)},r);return o.catch(i=>{this.updates.cancelPrompt(n)&&this.updates.reject(i)}),o}nextUpdate(){return this.updates.next()}async readText(){let t=this.latestPrompt,r=t?.updateCursor,n=[],o=new Map,i=s=>{let a=o.get(s);return a||(a=[],n.push(s),o.set(s,a)),a};for(;;){let s=r===void 0?await this.nextUpdate():await this.updates.nextAfter(r,t?.overlapController.signal);if(s.kind==="stop")return n.flatMap(c=>o.get(c)??[]).filter(p7.isText).map(c=>c.text).join("");let{update:a}=s;QR.isAgentMessage(a)?(i(a.messageId),a.content!==void 0&&o.set(a.messageId,a.content??[])):QR.isAgentMessageChunk(a)&&i(a.messageId).push(a.content)}}dispose(){for(let t of this.registrations.splice(0))t.dispose();this.updates.fail(new Error("Active session disposed"))}[Symbol.dispose](){this.dispose()}promptBlocks(t){return typeof t=="string"?[{type:"text",text:t}]:Array.isArray(t)?t:[t]}};function rPe(e,t){return e?typeof e=="function"?e(t):e.parse(t):t}function so(e,t,r){return{method:e,params:t,mapResponse:r}}function qc(e,t){return{method:e,params:t}}function nPe(e,t,r,n){e.onReceiveRequest(t.method,o=>rPe(t.params,o),async(o,i,s)=>{let a=await n(r(o,s,i.signal,i.id));await i.respond(t.mapResponse?t.mapResponse(a):a)})}function oPe(e,t,r,n){e.onReceiveNotification(t.method,o=>rPe(t.params,o),(o,i)=>n(r(o,i,i.signal)))}function Q1(e){let t=Object.create(null);for(let r of Object.values(e))t[r.method]=r;return t}var WEt={initialize:so(ct.initialize,KCe,JCe),loginAuth:so(ct.auth_login,D5,Hp),unstable_listProviders:so(ct.providers_list,N5),unstable_setProvider:so(ct.providers_set,z5,Hp),unstable_disableProvider:so(ct.providers_disable,L5,Hp),newSession:so(ct.session_new,G5),setSessionConfigOption:so(ct.session_set_config_option,Y5),prompt:so(ct.session_prompt,Q5,Hp),unstable_messageMcp:so(ct.mcp_message,KR),listSessions:so(ct.session_list,B5),deleteSession:so(ct.session_delete,W5,Hp),unstable_forkSession:so(ct.session_fork,V5),resumeSession:so(ct.session_resume,Z5),closeSession:so(ct.session_close,J5,Hp),logoutAuth:so(ct.auth_logout,F5,Hp),unstable_startNes:so(ct.nes_start,X5),unstable_suggestNes:so(ct.nes_suggest,e7),unstable_closeNes:so(ct.nes_close,t7,Hp)},VEt={cancelSession:qc(ct.session_cancel,o7),unstable_messageMcp:qc(ct.mcp_message,YR),unstable_didOpenDocument:qc(ct.document_did_open,i7),unstable_didChangeDocument:qc(ct.document_did_change,s7),unstable_didCloseDocument:qc(ct.document_did_close,a7),unstable_didSaveDocument:qc(ct.document_did_save,c7),unstable_didFocusDocument:qc(ct.document_did_focus,l7),unstable_acceptNes:qc(ct.nes_accept,u7),unstable_rejectNes:qc(ct.nes_reject,d7)},KEt={requestPermission:so(vi.session_request_permission,G8),unstable_connectMcp:so(vi.mcp_connect,e5),unstable_messageMcp:so(vi.mcp_message,KR),unstable_disconnectMcp:so(vi.mcp_disconnect,t5,Hp),unstable_createElicitation:so(vi.elicitation_create,X8)},ZEt={sessionUpdate:qc(vi.session_update,H1),unstable_messageMcp:qc(vi.mcp_message,YR),unstable_completeElicitation:qc(vi.elicitation_complete,M5)},XR=Q1(WEt),Z1=Q1(VEt),eT=Q1(KEt),J1=Q1(ZEt);function JEt(e,t,r,n){return{params:e,requestId:n,signal:r,client:t}}function YEt(e,t,r){return{params:e,signal:r,client:t}}function QEt(e,t,r,n){return{params:e,requestId:n,signal:r,agent:t}}function XEt(e,t,r){return{params:e,signal:r,agent:t}}var b7=class{activeSessions=new Map;handleMessage(t){if(t.kind!=="notification"||t.method!==vi.session_update)return Mc.no(t);let r=H1.parse(t.params),{update:n}=r,o=QR.isStateUpdate(n)&&f7.isIdle(n),i=this.activeSessions.get(r.sessionId);if(i&&i.size>0)for(let s of i)o&&s.isAwaitingPromptCompletion()?(s.completePrompt(),s.enqueue({kind:"stop",notification:r,update:n,stopReason:n.stopReason})):s.enqueue({kind:"session_update",notification:r,update:n});return Mc.no(t)}attach(t,r){let n=this.activeSessions.get(t.sessionId)??new Set;return n.add(r),this.activeSessions.set(t.sessionId,n),new Ap(()=>{n.delete(r),n.size===0&&this.activeSessions.delete(t.sessionId)})}},GCe=new WeakMap;function iPe(e){let t=GCe.get(e);return t||(t=new b7,GCe.set(e,t)),t}function X1(e,t){for(let r of t){let n;try{n=r(e)}catch(o){throw e.close(o),o}Promise.resolve(n).catch(o=>{e.close(o)})}}var Y1=Symbol("appBuilder"),G1=Symbol("runAgentConnectHandlers"),B1=Symbol("runClientConnectHandlers");var BCe=class{builder=Op.builder();connectHandlers=[];constructor(t={}){t.name&&this.builder.name(t.name)}[Y1](){return this.builder}[G1](t){X1(t,this.connectHandlers)}connect(t,r={}){return this.connectConnection(t,r).connection}connectWith(t,r){let{rawConnection:n,connection:o}=this.connectConnection(t);return n.runUntil(()=>r(o.client))}onConnect(t){return this.connectHandlers.push(t),this}onRequest(t,r,n){if(n)return qp(t,XR,"request"),this.request({method:t,params:r},n);let o=XR[t];if(!o)throw new Error(`Unknown ACP request method '${t}'. Pass a params parser for custom methods.`);return this.request(o,r)}onNotification(t,r,n){if(n)return qp(t,Z1,"notification",!0),this.notification({method:t,params:r},n);let o=Z1[t];if(!o)throw new Error(`Unknown ACP notification method '${t}'. Pass a params parser for custom methods.`);return this.notification(o,r)}request(t,r){return nPe(this.builder,t,(n,o,i,s)=>JEt(n,tT.create(o,s),i,s),r),this}notification(t,r){return oPe(this.builder,t,(n,o,i)=>YEt(n,tT.create(o),i),r),this}connectConnection(t,r={}){if(YCe(t)){let c=this.openStreamConnection(t);return r.deferConnectHandlers||this[G1](c.connection),c}let[n,o]=QCe(),i=t[Y1]().connect(o),s=tPe(i),a=this.openStreamConnection(n);a.rawConnection.closed.then(()=>s.close()),i.closed.then(()=>a.connection.close());try{t[B1](s),this[G1](a.connection)}catch(c){throw s.close(c),a.connection.close(c),c}return a}openStreamConnection(t){let r=this.builder.connect(t);return{rawConnection:r,connection:ePe(r,this.connectHandlers)}}};var WCe=class{builder=Op.builder();connectHandlers=[];constructor(t={}){t.name&&this.builder.name(t.name),this.builder.withHandler({handleMessage:(r,n)=>iPe(n).handleMessage(r),describe:()=>"client-session-update-router"})}[Y1](){return this.builder}[B1](t){X1(t,this.connectHandlers)}connect(t){return this.connectConnection(t).connection}connectWith(t,r){let{rawConnection:n,connection:o}=this.connectConnection(t);return n.runUntil(()=>r(o.agent))}onConnect(t){return this.connectHandlers.push(t),this}onRequest(t,r,n){if(n)return qp(t,eT,"request"),this.request({method:t,params:r},n);let o=eT[t];if(!o)throw new Error(`Unknown ACP request method '${t}'. Pass a params parser for custom methods.`);return this.request(o,r)}onNotification(t,r,n){if(n)return qp(t,J1,"notification",!0),this.notification({method:t,params:r},n);let o=J1[t];if(!o)throw new Error(`Unknown ACP notification method '${t}'. Pass a params parser for custom methods.`);return this.notification(o,r)}request(t,r){return nPe(this.builder,t,(n,o,i,s)=>QEt(n,rT.create(o,s),i,s),r),this}notification(t,r){return oPe(this.builder,t,(n,o,i)=>XEt(n,rT.create(o),i),r),this}connectConnection(t){if(YCe(t)){let a=this.openStreamConnection(t);return this[B1](a.connection),a}let[r,n]=QCe(),o=t[Y1]().connect(n),i=ePe(o),s=this.openStreamConnection(r);s.rawConnection.closed.then(()=>i.close()),o.closed.then(()=>s.connection.close());try{t[G1](i),this[B1](s.connection)}catch(a){throw i.close(a),s.connection.close(a),a}return s}openStreamConnection(t){let r=this.builder.connect(t);return{rawConnection:r,connection:tPe(r,this.connectHandlers)}}};var sPe=1;var aPe=["GET","HEAD","POST","PATCH","PUT","DELETE"];var Ms={hostState:"_redskills/host_state",hostBudgets:"_redskills/host_budgets",projectDrain:"_redskills/project_drain",projectStop:"_redskills/project_stop",projectStatus:"_redskills/project_status",projectBudget:"_redskills/project_budget",githubRead:"_redskills/github_read",githubRequest:"_redskills/github_request",githubWrite:"_redskills/github_write",githubUpdate:"_redskills/github_update",githubCustodyHandoff:"_redskills/github_custody_handoff",publish:"_redskills/publish",land:"_redskills/land",workerBudgetGrace:"_redskills/worker_budget_grace",goDispatch:"_redskills/go_dispatch",worktreeAdd:"_redskills/worktree_add",worktreeList:"_redskills/worktree_list",metrics:"_redskills/metrics",brainCall:"_redskills/brain_call",memoryCall:"_redskills/memory_call"},avr=Object.values(Ms);var t0t=16e3,r0t={type:"object",additionalProperties:!1,required:["demand"],properties:{demand:{type:"string",minLength:1,maxLength:t0t,description:"The one-off demand this dispatch exists to satisfy."}}},n0t={type:"object",additionalProperties:!1,required:["version","worker_id","ticket","lane"],properties:{version:{const:1},worker_id:{type:"string",minLength:1},ticket:{type:"integer",minimum:1},lane:{type:"string",minLength:1},session_id:{type:"string",minLength:1}}},dvr={version:1,method:Ms.goDispatch,params:r0t,answer:n0t};var o0t=64,cPe=200,i0t=/^[a-z0-9][a-z0-9._-]*$/;var s0t={type:"object",additionalProperties:!1,required:["slug"],properties:{slug:{type:"string",minLength:1,maxLength:o0t,pattern:i0t.source,description:"What the human is about to work on; becomes the worktree directory name."},branch:{type:"string",minLength:1,maxLength:cPe,description:"Branch to create; defaults to the daemon's convention for the slug."},base:{type:"string",minLength:1,maxLength:cPe,description:"Trunk BRANCH to fork from; the remote is the Project's registered trunk remote."}}},a0t={type:"object",additionalProperties:!1,required:["version","kind","path","branch","base","lane","project_label"],properties:{version:{const:1},kind:{const:"interactive"},path:{type:"string",minLength:1},branch:{type:"string",minLength:1},base:{type:"string",minLength:1},lane:{type:"string",minLength:1},project_label:{type:"string",minLength:1}}},c0t={type:"object",additionalProperties:!1,required:["version","project_label","worktrees"],properties:{version:{const:1},project_label:{type:"string",minLength:1},worktrees:{type:"array",items:{type:"object",additionalProperties:!1,required:["kind","path","branch"],properties:{kind:{enum:["checkout","interactive","worker","unregistered"]},path:{type:"string",minLength:1},branch:{type:["string","null"]},lane:{type:"string",minLength:1},worker_id:{type:"string",minLength:1}}}}}},Evr={version:1,methods:{add:Ms.worktreeAdd,list:Ms.worktreeList},add:{params:s0t,answer:a0t},list:{answer:c0t}};nT();var g0t={drain:Ms.projectDrain,stop:Ms.projectStop,status:Ms.projectStatus};async function k7(e={}){let t=e.cwd??process.cwd(),r=e.name??"RedSkills Project client",n=e.version??"1",o=e.paths??eN();await qR(o);let i=(await ob(o)).paths,s=await S0t(i.acpSocketPath),a=[],c="",l=Lve({name:r}).onNotification(Xm.client.session.update,async({params:f})=>{f.sessionId===c&&(a.push(f.update),await e.onUpdate?.(f.update))});e.requestPermission!=null&&(l=l.onRequest(Xm.client.session.requestPermission,({params:f})=>e.requestPermission(f)));let u=l.connect(h9(h0t.toWeb(s),m0t.toWeb(s)));return await u.agent.request(Xm.agent.initialize,{protocolVersion:1,clientCapabilities:{},clientInfo:{name:r,version:n},_meta:{redskills:{wireMajor:sPe}}}),c=(await u.agent.request(Xm.agent.session.new,{cwd:t,mcpServers:[]})).sessionId,{control:async(f,m={})=>{let b=await u.agent.request(g0t[f],{...m.target==null?{}:{target:m.target},...m.runner==null?{}:{runner:m.runner}});if(!hPe(b))throw new Error("redskilled returned an invalid Project control outcome");if(f==="status"&&!b0t(b))throw new Error("redskilled returned Project status without a valid RedSkills context");return b},github(f){return u.agent.request(Ms.githubRequest,{request:f})},brain(f){return u.agent.request(Ms.brainCall,{tool:f.tool,arguments:f.arguments})},memory(f){return u.agent.request(Ms.memoryCall,{tool:f.tool,arguments:f.arguments,...f.mode==null?{}:{mode:f.mode}})},async prompt(f){let m=a.length,b=await u.agent.request(Xm.agent.session.prompt,{sessionId:c,prompt:[{type:"text",text:f}]});return{stopReason:b.stopReason,...y0t(b._meta),updates:a.slice(m)}},cancel(){return u.agent.notify(Xm.agent.session.cancel,{sessionId:c})},async permission(f){return e.requestPermission==null?{outcome:{outcome:"cancelled"},_meta:{redskills:{permissionResolution:"hitl-required"}}}:await e.requestPermission(f)},close(){u.close(),s.destroy()}}}function y0t(e){let r=Bp(Bp(e)?.redskills)?.projectControl;return hPe(r)?{projectControl:r}:{}}function hPe(e){let t=Bp(e);return t?.version===1&&typeof t.project_id=="string"&&typeof t.revision=="number"&&Array.isArray(t.updates)}function b0t(e){let t=Bp(Bp(e)?.context),r=Bp(t?.queue),n=Bp(t?.workers),o=Bp(t?.adapter_health);return t?.version===1&&typeof t.observed_at=="string"&&typeof r?.posture=="string"&&(r.depth===null||typeof r.depth=="number")&&(r.target===null||typeof r.target=="number")&&typeof r.live=="number"&&(r.wanted===null||typeof r.wanted=="number")&&(r.observed_at===null||typeof r.observed_at=="string")&&(r.age_ms===null||typeof r.age_ms=="number")&&(r.freshness==="fresh"||r.freshness==="stale"||r.freshness==="unknown")&&typeof r.detail=="string"&&n?.freshness==="fresh"&&typeof n.observed_at=="string"&&typeof n.total=="number"&&Array.isArray(n.items)&&n.items.every(x0t)&&(o?.status==="healthy"||o?.status==="degraded"||o?.status==="unknown")&&(o.checked_at===null||typeof o.checked_at=="string")&&(o.last_success_at===null||typeof o.last_success_at=="string")&&(o.last_failure_at===null||typeof o.last_failure_at=="string")&&typeof o.detail=="string"}function x0t(e){let t=Bp(e);return typeof t?.worker_id=="string"&&t.state==="running"&&typeof t.started_at=="string"&&typeof t.isolated=="boolean"&&Array.isArray(t.warnings)&&t.warnings.every(r=>typeof r=="string")&&(t.base_commits_ahead===null||typeof t.base_commits_ahead=="number")}function Bp(e){return e!=null&&typeof e=="object"&&!Array.isArray(e)?e:void 0}async function S0t(e){return await new Promise((t,r)=>{let n=f0t(e);n.once("connect",()=>t(n)),n.once("error",r)})}iee();fd();Xte();A_();fd();var qz=class{constructor(t){this._server=t}requestStream(t,r,n){return this._server.requestStream(t,r,n)}createMessageStream(t,r){let n=this._server.getClientCapabilities();if((t.tools||t.toolChoice)&&!n?.sampling?.tools)throw new Error("Client does not support sampling tools capability.");if(t.messages.length>0){let o=t.messages[t.messages.length-1],i=Array.isArray(o.content)?o.content:[o.content],s=i.some(u=>u.type==="tool_result"),a=t.messages.length>1?t.messages[t.messages.length-2]:void 0,c=a?Array.isArray(a.content)?a.content:[a.content]:[],l=c.some(u=>u.type==="tool_use");if(s){if(i.some(u=>u.type!=="tool_result"))throw new Error("The last message must contain only tool_result content if any is present");if(!l)throw new Error("tool_result blocks are not matching any tool_use from the previous message")}if(l){let u=new Set(c.filter(f=>f.type==="tool_use").map(f=>f.id)),d=new Set(i.filter(f=>f.type==="tool_result").map(f=>f.toolUseId));if(u.size!==d.size||![...u].every(f=>d.has(f)))throw new Error("ids of tool_result blocks and tool_use blocks from previous message do not match")}}return this.requestStream({method:"sampling/createMessage",params:t},$b,r)}elicitInputStream(t,r){let n=this._server.getClientCapabilities(),o=t.mode??"form";switch(o){case"url":{if(!n?.elicitation?.url)throw new Error("Client does not support url elicitation.");break}case"form":{if(!n?.elicitation?.form)throw new Error("Client does not support form elicitation.");break}}let i=o==="form"&&t.mode===void 0?{...t,mode:"form"}:t;return this.requestStream({method:"elicitation/create",params:i},gh,r)}async getTask(t,r){return this._server.getTask({taskId:t},r)}async getTaskResult(t,r,n){return this._server.getTaskResult({taskId:t},r,n)}async listTasks(t,r){return this._server.listTasks(t?{cursor:t}:void 0,r)}async cancelTask(t,r){return this._server.cancelTask({taskId:t},r)}};ere();var Wz=class extends z_{constructor(t,r){super(r),this._serverInfo=t,this._loggingLevels=new Map,this.LOG_LEVEL_SEVERITY=new Map(OT.options.map((n,o)=>[n,o])),this.isMessageIgnored=(n,o)=>{let i=this._loggingLevels.get(o);return i?this.LOG_LEVEL_SEVERITY.get(n)<this.LOG_LEVEL_SEVERITY.get(i):!1},this._capabilities=r?.capabilities??{},this._instructions=r?.instructions,this._jsonSchemaValidator=r?.jsonSchemaValidator??new rw,this.setRequestHandler(YQ,n=>this._oninitialize(n)),this.setNotificationHandler(XQ,()=>this.oninitialized?.()),this._capabilities.logging&&this.setRequestHandler(yX,async(n,o)=>{let i=o.sessionId||o.requestInfo?.headers["mcp-session-id"]||void 0,{level:s}=n.params,a=OT.safeParse(s);return a.success&&this._loggingLevels.set(i,a.data),{}})}get experimental(){return this._experimental||(this._experimental={tasks:new qz(this)}),this._experimental}registerCapabilities(t){if(this.transport)throw new Error("Cannot register capabilities after connecting to transport");this._capabilities=cz(this._capabilities,t)}setRequestHandler(t,r){let o=dd(t)?.method;if(!o)throw new Error("Schema is missing a method literal");let i;if(ba(o)){let a=o;i=a._zod?.def?.value??a.value}else{let a=o;i=a._def?.value??a.value}if(typeof i!="string")throw new Error("Schema method literal must be a string");if(i==="tools/call"){let a=async(c,l)=>{let u=Ns(N_,c);if(!u.success){let b=u.error instanceof Error?u.error.message:String(u.error);throw new ze(qe.InvalidParams,`Invalid tools/call request: ${b}`)}let{params:d}=u.data,f=await Promise.resolve(r(c,l));if(d.task){let b=Ns(Qp,f);if(!b.success){let S=b.error instanceof Error?b.error.message:String(b.error);throw new ze(qe.InvalidParams,`Invalid task creation result: ${S}`)}return b.data}let m=Ns(pd,f);if(!m.success){let b=m.error instanceof Error?m.error.message:String(m.error);throw new ze(qe.InvalidParams,`Invalid tools/call result: ${b}`)}return m.data};return super.setRequestHandler(t,a)}return super.setRequestHandler(t,r)}assertCapabilityForMethod(t){switch(t){case"sampling/createMessage":if(!this._clientCapabilities?.sampling)throw new Error(`Client does not support sampling (required for ${t})`);break;case"elicitation/create":if(!this._clientCapabilities?.elicitation)throw new Error(`Client does not support elicitation (required for ${t})`);break;case"roots/list":if(!this._clientCapabilities?.roots)throw new Error(`Client does not support listing roots (required for ${t})`);break;case"ping":break}}assertNotificationCapability(t){switch(t){case"notifications/message":if(!this._capabilities.logging)throw new Error(`Server does not support logging (required for ${t})`);break;case"notifications/resources/updated":case"notifications/resources/list_changed":if(!this._capabilities.resources)throw new Error(`Server does not support notifying about resources (required for ${t})`);break;case"notifications/tools/list_changed":if(!this._capabilities.tools)throw new Error(`Server does not support notifying of tool list changes (required for ${t})`);break;case"notifications/prompts/list_changed":if(!this._capabilities.prompts)throw new Error(`Server does not support notifying of prompt list changes (required for ${t})`);break;case"notifications/elicitation/complete":if(!this._clientCapabilities?.elicitation?.url)throw new Error(`Client does not support URL elicitation (required for ${t})`);break;case"notifications/cancelled":break;case"notifications/progress":break}}assertRequestHandlerCapability(t){if(this._capabilities)switch(t){case"completion/complete":if(!this._capabilities.completions)throw new Error(`Server does not support completions (required for ${t})`);break;case"logging/setLevel":if(!this._capabilities.logging)throw new Error(`Server does not support logging (required for ${t})`);break;case"prompts/get":case"prompts/list":if(!this._capabilities.prompts)throw new Error(`Server does not support prompts (required for ${t})`);break;case"resources/list":case"resources/templates/list":case"resources/read":if(!this._capabilities.resources)throw new Error(`Server does not support resources (required for ${t})`);break;case"tools/call":case"tools/list":if(!this._capabilities.tools)throw new Error(`Server does not support tools (required for ${t})`);break;case"tasks/get":case"tasks/list":case"tasks/result":case"tasks/cancel":if(!this._capabilities.tasks)throw new Error(`Server does not support tasks capability (required for ${t})`);break;case"ping":case"initialize":break}}assertTaskCapability(t){Bz(this._clientCapabilities?.tasks?.requests,t,"Client")}assertTaskHandlerCapability(t){this._capabilities&&Gz(this._capabilities.tasks?.requests,t,"Server")}async _oninitialize(t){let r=t.params.protocolVersion;return this._clientCapabilities=t.params.capabilities,this._clientVersion=t.params.clientInfo,{protocolVersion:DN.includes(r)?r:wT,capabilities:this.getCapabilities(),serverInfo:this._serverInfo,...this._instructions&&{instructions:this._instructions}}}getClientCapabilities(){return this._clientCapabilities}getClientVersion(){return this._clientVersion}getCapabilities(){return this._capabilities}async ping(){return this.request({method:"ping"},Yp)}async createMessage(t,r){if((t.tools||t.toolChoice)&&!this._clientCapabilities?.sampling?.tools)throw new Error("Client does not support sampling tools capability.");if(t.messages.length>0){let n=t.messages[t.messages.length-1],o=Array.isArray(n.content)?n.content:[n.content],i=o.some(l=>l.type==="tool_result"),s=t.messages.length>1?t.messages[t.messages.length-2]:void 0,a=s?Array.isArray(s.content)?s.content:[s.content]:[],c=a.some(l=>l.type==="tool_use");if(i){if(o.some(l=>l.type!=="tool_result"))throw new Error("The last message must contain only tool_result content if any is present");if(!c)throw new Error("tool_result blocks are not matching any tool_use from the previous message")}if(c){let l=new Set(a.filter(d=>d.type==="tool_use").map(d=>d.id)),u=new Set(o.filter(d=>d.type==="tool_result").map(d=>d.toolUseId));if(l.size!==u.size||![...l].every(d=>u.has(d)))throw new Error("ids of tool_result blocks and tool_use blocks from previous message do not match")}}return t.tools?this.request({method:"sampling/createMessage",params:t},$T,r):this.request({method:"sampling/createMessage",params:t},$b,r)}async elicitInput(t,r){switch(t.mode??"form"){case"url":{if(!this._clientCapabilities?.elicitation?.url)throw new Error("Client does not support url elicitation.");let o=t;return this.request({method:"elicitation/create",params:o},gh,r)}case"form":{if(!this._clientCapabilities?.elicitation?.form)throw new Error("Client does not support form elicitation.");let o=t.mode==="form"?t:{...t,mode:"form"},i=await this.request({method:"elicitation/create",params:o},gh,r);if(i.action==="accept"&&i.content&&o.requestedSchema)try{let a=this._jsonSchemaValidator.getValidator(o.requestedSchema)(i.content);if(!a.valid)throw new ze(qe.InvalidParams,`Elicitation response content does not match requested schema: ${a.errorMessage}`)}catch(s){throw s instanceof ze?s:new ze(qe.InternalError,`Error validating elicitation response: ${s instanceof Error?s.message:String(s)}`)}return i}}}createElicitationCompletionNotifier(t,r){if(!this._clientCapabilities?.elicitation?.url)throw new Error("Client does not support URL elicitation (required for notifications/elicitation/complete)");return()=>this.notification({method:"notifications/elicitation/complete",params:{elicitationId:t}},r)}async listRoots(t,r){return this.request({method:"roots/list",params:t},kX,r)}async sendLoggingMessage(t,r){if(this._capabilities.logging&&!this.isMessageIgnored(t.level,r))return this.notification({method:"notifications/message",params:t})}async sendResourceUpdated(t){return this.notification({method:"notifications/resources/updated",params:t})}async sendResourceListChanged(){return this.notification({method:"notifications/resources/list_changed"})}async sendToolListChanged(){return this.notification({method:"notifications/tools/list_changed"})}async sendPromptListChanged(){return this.notification({method:"notifications/prompts/list_changed"})}};A_();oee();fd();var RDe=Symbol.for("mcp.completable");function tre(e){return!!e&&typeof e=="object"&&RDe in e}function TDe(e){return e[RDe]?.complete}var EDe;(function(e){e.Completable="McpCompletable"})(EDe||(EDe={}));var p1t=/^[A-Za-z0-9._-]{1,128}$/;function f1t(e){let t=[];if(e.length===0)return{isValid:!1,warnings:["Tool name cannot be empty"]};if(e.length>128)return{isValid:!1,warnings:[`Tool name exceeds maximum length of 128 characters (current: ${e.length})`]};if(e.includes(" ")&&t.push("Tool name contains spaces, which may cause parsing issues"),e.includes(",")&&t.push("Tool name contains commas, which may cause parsing issues"),(e.startsWith("-")||e.endsWith("-"))&&t.push("Tool name starts or ends with a dash, which may cause parsing issues in some contexts"),(e.startsWith(".")||e.endsWith("."))&&t.push("Tool name starts or ends with a dot, which may cause parsing issues in some contexts"),!p1t.test(e)){let r=e.split("").filter(n=>!/[A-Za-z0-9._-]/.test(n)).filter((n,o,i)=>i.indexOf(n)===o);return t.push(`Tool name contains invalid characters: ${r.map(n=>`"${n}"`).join(", ")}`,"Allowed characters are: A-Z, a-z, 0-9, underscore (_), dash (-), and dot (.)"),{isValid:!1,warnings:t}}return{isValid:!0,warnings:t}}function m1t(e,t){if(t.length>0){console.warn(`Tool name validation warning for "${e}":`);for(let r of t)console.warn(` - ${r}`);console.warn("Tool registration will proceed, but this may cause compatibility issues."),console.warn("Consider updating the tool name to conform to the MCP tool naming standard."),console.warn("See SEP: Specify Format for Tool Names (https://github.com/modelcontextprotocol/modelcontextprotocol/issues/986) for more details.")}}function rre(e){let t=f1t(e);return m1t(e,t.warnings),t.isValid}var Vz=class{constructor(t){this._mcpServer=t}registerToolTask(t,r,n){let o={taskSupport:"required",...r.execution};if(o.taskSupport==="forbidden")throw new Error(`Cannot register task-based tool '${t}' with taskSupport 'forbidden'. Use registerTool() instead.`);return this._mcpServer._createRegisteredTool(t,r.title,r.description,r.inputSchema,r.outputSchema,r.annotations,o,r._meta,n)}};uC();var nw=class{constructor(t,r){this._registeredResources={},this._registeredResourceTemplates={},this._registeredTools={},this._registeredPrompts={},this._toolHandlersInitialized=!1,this._completionHandlerInitialized=!1,this._resourceHandlersInitialized=!1,this._promptHandlersInitialized=!1,this.server=new Wz(t,r)}get experimental(){return this._experimental||(this._experimental={tasks:new Vz(this)}),this._experimental}async connect(t){return await this.server.connect(t)}async close(){await this.server.close()}setToolRequestHandlers(){this._toolHandlersInitialized||(this.server.assertCanSetRequestHandler(Th(JN)),this.server.assertCanSetRequestHandler(Th(N_)),this.server.registerCapabilities({tools:{listChanged:!0}}),this.server.setRequestHandler(JN,()=>({tools:Object.entries(this._registeredTools).filter(([,t])=>t.enabled).map(([t,r])=>{let n={name:t,title:r.title,description:r.description,inputSchema:(()=>{let o=I_(r.inputSchema);return o?tee(o,{strictUnions:!0,pipeStrategy:"input"}):h1t})(),annotations:r.annotations,execution:r.execution,_meta:r._meta};if(r.outputSchema){let o=I_(r.outputSchema);o&&(n.outputSchema=tee(o,{strictUnions:!0,pipeStrategy:"output"}))}return n})})),this.server.setRequestHandler(N_,async(t,r)=>{try{let n=this._registeredTools[t.params.name];if(!n)throw new ze(qe.InvalidParams,`Tool ${t.params.name} not found`);if(!n.enabled)throw new ze(qe.InvalidParams,`Tool ${t.params.name} disabled`);let o=!!t.params.task,i=n.execution?.taskSupport,s="createTask"in n.handler;if((i==="required"||i==="optional")&&!s)throw new ze(qe.InternalError,`Tool ${t.params.name} has taskSupport '${i}' but was not registered with registerToolTask`);if(i==="required"&&!o)throw new ze(qe.MethodNotFound,`Tool ${t.params.name} requires task augmentation (taskSupport: 'required')`);if(i==="optional"&&!o&&s)return await this.handleAutomaticTaskPolling(n,t,r);let a=await this.validateToolInput(n,t.params.arguments,t.params.name),c=await this.executeToolHandler(n,a,r);return o||await this.validateToolOutput(n,c,t.params.name),c}catch(n){if(n instanceof ze&&n.code===qe.UrlElicitationRequired)throw n;return this.createToolError(n instanceof Error?n.message:String(n))}}),this._toolHandlersInitialized=!0)}createToolError(t){return{content:[{type:"text",text:t}],isError:!0}}async validateToolInput(t,r,n){if(!t.inputSchema)return;let i=I_(t.inputSchema)??t.inputSchema,s=await PN(i,r);if(!s.success){let a="error"in s?s.error:"Unknown error",c=IN(a);throw new ze(qe.InvalidParams,`Input validation error: Invalid arguments for tool ${n}: ${c}`)}return s.data}async validateToolOutput(t,r,n){if(!t.outputSchema||!("content"in r)||r.isError)return;if(!r.structuredContent)throw new ze(qe.InvalidParams,`Output validation error: Tool ${n} has an output schema but no structured content was provided`);let o=I_(t.outputSchema),i=await PN(o,r.structuredContent);if(!i.success){let s="error"in i?i.error:"Unknown error",a=IN(s);throw new ze(qe.InvalidParams,`Output validation error: Invalid structured content for tool ${n}: ${a}`)}}async executeToolHandler(t,r,n){let o=t.handler;if("createTask"in o){if(!n.taskStore)throw new Error("No task store provided.");let s={...n,taskStore:n.taskStore};if(t.inputSchema){let a=o;return await Promise.resolve(a.createTask(r,s))}else{let a=o;return await Promise.resolve(a.createTask(s))}}if(t.inputSchema){let s=o;return await Promise.resolve(s(r,n))}else{let s=o;return await Promise.resolve(s(n))}}async handleAutomaticTaskPolling(t,r,n){if(!n.taskStore)throw new Error("No task store provided for task-capable tool.");let o=await this.validateToolInput(t,r.params.arguments,r.params.name),i=t.handler,s={...n,taskStore:n.taskStore},a=o?await Promise.resolve(i.createTask(o,s)):await Promise.resolve(i.createTask(s)),c=a.task.taskId,l=a.task,u=l.pollInterval??5e3;for(;l.status!=="completed"&&l.status!=="failed"&&l.status!=="cancelled";){await new Promise(f=>setTimeout(f,u));let d=await n.taskStore.getTask(c);if(!d)throw new ze(qe.InternalError,`Task ${c} not found during polling`);l=d}return await n.taskStore.getTaskResult(c)}setCompletionRequestHandler(){this._completionHandlerInitialized||(this.server.assertCanSetRequestHandler(Th(YN)),this.server.registerCapabilities({completions:{}}),this.server.setRequestHandler(YN,async t=>{switch(t.params.ref.type){case"ref/prompt":return ZAe(t),this.handlePromptCompletion(t,t.params.ref);case"ref/resource":return JAe(t),this.handleResourceCompletion(t,t.params.ref);default:throw new ze(qe.InvalidParams,`Invalid completion reference: ${t.params.ref}`)}}),this._completionHandlerInitialized=!0)}async handlePromptCompletion(t,r){let n=this._registeredPrompts[r.name];if(!n)throw new ze(qe.InvalidParams,`Prompt ${r.name} not found`);if(!n.enabled)throw new ze(qe.InvalidParams,`Prompt ${r.name} disabled`);if(!n.argsSchema)return dC;let i=dd(n.argsSchema)?.[t.params.argument.name];if(!tre(i))return dC;let s=TDe(i);if(!s)return dC;let a=await s(t.params.argument.value,t.params.context);return PDe(a)}async handleResourceCompletion(t,r){let n=Object.values(this._registeredResourceTemplates).find(s=>s.resourceTemplate.uriTemplate.toString()===r.uri);if(!n){if(this._registeredResources[r.uri])return dC;throw new ze(qe.InvalidParams,`Resource template ${t.params.ref.uri} not found`)}let o=n.resourceTemplate.completeCallback(t.params.argument.name);if(!o)return dC;let i=await o(t.params.argument.value,t.params.context);return PDe(i)}setResourceRequestHandlers(){this._resourceHandlersInitialized||(this.server.assertCanSetRequestHandler(Th(M_)),this.server.assertCanSetRequestHandler(Th(VN)),this.server.assertCanSetRequestHandler(Th(D_)),this.server.registerCapabilities({resources:{listChanged:!0}}),this.server.setRequestHandler(M_,async(t,r)=>{let n=Object.entries(this._registeredResources).filter(([i,s])=>s.enabled).map(([i,s])=>({uri:i,name:s.name,...s.metadata})),o=[];for(let i of Object.values(this._registeredResourceTemplates)){if(!i.resourceTemplate.listCallback)continue;let s=await i.resourceTemplate.listCallback(r);for(let a of s.resources)o.push({...i.metadata,...a})}return{resources:[...n,...o]}}),this.server.setRequestHandler(VN,async()=>({resourceTemplates:Object.entries(this._registeredResourceTemplates).map(([r,n])=>({name:r,uriTemplate:n.resourceTemplate.uriTemplate.toString(),...n.metadata}))})),this.server.setRequestHandler(D_,async(t,r)=>{let n=new URL(t.params.uri),o=this._registeredResources[n.toString()];if(o){if(!o.enabled)throw new ze(qe.InvalidParams,`Resource ${n} disabled`);return o.readCallback(n,r)}for(let i of Object.values(this._registeredResourceTemplates)){let s=i.resourceTemplate.uriTemplate.match(n.toString());if(s)return i.readCallback(n,s,r)}throw new ze(qe.InvalidParams,`Resource ${n} not found`)}),this._resourceHandlersInitialized=!0)}setPromptRequestHandlers(){this._promptHandlersInitialized||(this.server.assertCanSetRequestHandler(Th(KN)),this.server.assertCanSetRequestHandler(Th(ZN)),this.server.registerCapabilities({prompts:{listChanged:!0}}),this.server.setRequestHandler(KN,()=>({prompts:Object.entries(this._registeredPrompts).filter(([,t])=>t.enabled).map(([t,r])=>({name:t,title:r.title,description:r.description,arguments:r.argsSchema?g1t(r.argsSchema):void 0}))})),this.server.setRequestHandler(ZN,async(t,r)=>{let n=this._registeredPrompts[t.params.name];if(!n)throw new ze(qe.InvalidParams,`Prompt ${t.params.name} not found`);if(!n.enabled)throw new ze(qe.InvalidParams,`Prompt ${t.params.name} disabled`);if(n.argsSchema){let o=I_(n.argsSchema),i=await PN(o,t.params.arguments);if(!i.success){let c="error"in i?i.error:"Unknown error",l=IN(c);throw new ze(qe.InvalidParams,`Invalid arguments for prompt ${t.params.name}: ${l}`)}let s=i.data,a=n.callback;return await Promise.resolve(a(s,r))}else{let o=n.callback;return await Promise.resolve(o(r))}}),this._promptHandlersInitialized=!0)}resource(t,r,...n){let o;typeof n[0]=="object"&&(o=n.shift());let i=n[0];if(typeof r=="string"){if(this._registeredResources[r])throw new Error(`Resource ${r} is already registered`);let s=this._createRegisteredResource(t,void 0,r,o,i);return this.setResourceRequestHandlers(),this.sendResourceListChanged(),s}else{if(this._registeredResourceTemplates[t])throw new Error(`Resource template ${t} is already registered`);let s=this._createRegisteredResourceTemplate(t,void 0,r,o,i);return this.setResourceRequestHandlers(),this.sendResourceListChanged(),s}}registerResource(t,r,n,o){if(typeof r=="string"){if(this._registeredResources[r])throw new Error(`Resource ${r} is already registered`);let i=this._createRegisteredResource(t,n.title,r,n,o);return this.setResourceRequestHandlers(),this.sendResourceListChanged(),i}else{if(this._registeredResourceTemplates[t])throw new Error(`Resource template ${t} is already registered`);let i=this._createRegisteredResourceTemplate(t,n.title,r,n,o);return this.setResourceRequestHandlers(),this.sendResourceListChanged(),i}}_createRegisteredResource(t,r,n,o,i){let s={name:t,title:r,metadata:o,readCallback:i,enabled:!0,disable:()=>s.update({enabled:!1}),enable:()=>s.update({enabled:!0}),remove:()=>s.update({uri:null}),update:a=>{typeof a.uri<"u"&&a.uri!==n&&(delete this._registeredResources[n],a.uri&&(this._registeredResources[a.uri]=s)),typeof a.name<"u"&&(s.name=a.name),typeof a.title<"u"&&(s.title=a.title),typeof a.metadata<"u"&&(s.metadata=a.metadata),typeof a.callback<"u"&&(s.readCallback=a.callback),typeof a.enabled<"u"&&(s.enabled=a.enabled),this.sendResourceListChanged()}};return this._registeredResources[n]=s,s}_createRegisteredResourceTemplate(t,r,n,o,i){let s={resourceTemplate:n,title:r,metadata:o,readCallback:i,enabled:!0,disable:()=>s.update({enabled:!1}),enable:()=>s.update({enabled:!0}),remove:()=>s.update({name:null}),update:l=>{typeof l.name<"u"&&l.name!==t&&(delete this._registeredResourceTemplates[t],l.name&&(this._registeredResourceTemplates[l.name]=s)),typeof l.title<"u"&&(s.title=l.title),typeof l.template<"u"&&(s.resourceTemplate=l.template),typeof l.metadata<"u"&&(s.metadata=l.metadata),typeof l.callback<"u"&&(s.readCallback=l.callback),typeof l.enabled<"u"&&(s.enabled=l.enabled),this.sendResourceListChanged()}};this._registeredResourceTemplates[t]=s;let a=n.uriTemplate.variableNames;return Array.isArray(a)&&a.some(l=>!!n.completeCallback(l))&&this.setCompletionRequestHandler(),s}_createRegisteredPrompt(t,r,n,o,i){let s={title:r,description:n,argsSchema:o===void 0?void 0:Ob(o),callback:i,enabled:!0,disable:()=>s.update({enabled:!1}),enable:()=>s.update({enabled:!0}),remove:()=>s.update({name:null}),update:a=>{typeof a.name<"u"&&a.name!==t&&(delete this._registeredPrompts[t],a.name&&(this._registeredPrompts[a.name]=s)),typeof a.title<"u"&&(s.title=a.title),typeof a.description<"u"&&(s.description=a.description),typeof a.argsSchema<"u"&&(s.argsSchema=Ob(a.argsSchema)),typeof a.callback<"u"&&(s.callback=a.callback),typeof a.enabled<"u"&&(s.enabled=a.enabled),this.sendPromptListChanged()}};return this._registeredPrompts[t]=s,o&&Object.values(o).some(c=>{let l=c instanceof ga?c._def?.innerType:c;return tre(l)})&&this.setCompletionRequestHandler(),s}_createRegisteredTool(t,r,n,o,i,s,a,c,l){rre(t);let u={title:r,description:n,inputSchema:CDe(o),outputSchema:CDe(i),annotations:s,execution:a,_meta:c,handler:l,enabled:!0,disable:()=>u.update({enabled:!1}),enable:()=>u.update({enabled:!0}),remove:()=>u.update({name:null}),update:d=>{typeof d.name<"u"&&d.name!==t&&(typeof d.name=="string"&&rre(d.name),delete this._registeredTools[t],d.name&&(this._registeredTools[d.name]=u)),typeof d.title<"u"&&(u.title=d.title),typeof d.description<"u"&&(u.description=d.description),typeof d.paramsSchema<"u"&&(u.inputSchema=Ob(d.paramsSchema)),typeof d.outputSchema<"u"&&(u.outputSchema=Ob(d.outputSchema)),typeof d.callback<"u"&&(u.handler=d.callback),typeof d.annotations<"u"&&(u.annotations=d.annotations),typeof d._meta<"u"&&(u._meta=d._meta),typeof d.enabled<"u"&&(u.enabled=d.enabled),this.sendToolListChanged()}};return this._registeredTools[t]=u,this.setToolRequestHandlers(),this.sendToolListChanged(),u}tool(t,...r){if(this._registeredTools[t])throw new Error(`Tool ${t} is already registered`);let n,o,i,s;if(typeof r[0]=="string"&&(n=r.shift()),r.length>1){let c=r[0];if(nre(c))o=r.shift(),r.length>1&&typeof r[0]=="object"&&r[0]!==null&&!nre(r[0])&&(s=r.shift());else if(typeof c=="object"&&c!==null){if(Object.values(c).some(l=>typeof l=="object"&&l!==null))throw new Error(`Tool ${t} expected a Zod schema or ToolAnnotations, but received an unrecognized object`);s=r.shift()}}let a=r[0];return this._createRegisteredTool(t,void 0,n,o,i,s,{taskSupport:"forbidden"},void 0,a)}registerTool(t,r,n){if(this._registeredTools[t])throw new Error(`Tool ${t} is already registered`);let{title:o,description:i,inputSchema:s,outputSchema:a,annotations:c,_meta:l}=r;return this._createRegisteredTool(t,o,i,s,a,c,{taskSupport:"forbidden"},l,n)}prompt(t,...r){if(this._registeredPrompts[t])throw new Error(`Prompt ${t} is already registered`);let n;typeof r[0]=="string"&&(n=r.shift());let o;r.length>1&&(o=r.shift());let i=r[0],s=this._createRegisteredPrompt(t,void 0,n,o,i);return this.setPromptRequestHandlers(),this.sendPromptListChanged(),s}registerPrompt(t,r,n){if(this._registeredPrompts[t])throw new Error(`Prompt ${t} is already registered`);let{title:o,description:i,argsSchema:s}=r,a=this._createRegisteredPrompt(t,o,i,s,n);return this.setPromptRequestHandlers(),this.sendPromptListChanged(),a}isConnected(){return this.server.transport!==void 0}async sendLoggingMessage(t,r){return this.server.sendLoggingMessage(t,r)}sendResourceListChanged(){this.isConnected()&&this.server.sendResourceListChanged()}sendToolListChanged(){this.isConnected()&&this.server.sendToolListChanged()}sendPromptListChanged(){this.isConnected()&&this.server.sendPromptListChanged()}};var h1t={type:"object",properties:{}};function IDe(e){return e!==null&&typeof e=="object"&&"parse"in e&&typeof e.parse=="function"&&"safeParse"in e&&typeof e.safeParse=="function"}function ADe(e){return"_def"in e||"_zod"in e||IDe(e)}function nre(e){return typeof e!="object"||e===null||ADe(e)?!1:Object.keys(e).length===0?!0:Object.values(e).some(IDe)}function CDe(e){if(e){if(nre(e))return Ob(e);if(!ADe(e))throw new Error("inputSchema must be a Zod schema or raw shape, received an unrecognized object");return e}}function g1t(e){let t=dd(e);return t?Object.entries(t).map(([r,n])=>{let o=oAe(n),i=iAe(n);return{name:r,description:o,required:!i}}):[]}function Th(e){let r=dd(e)?.method;if(!r)throw new Error("Schema is missing a method literal");let n=AN(r);if(typeof n=="string")return n;throw new Error("Schema method literal must be a string")}function PDe(e){return{completion:{values:e.slice(0,100),total:e.length,hasMore:e.length>100}}}var dC={completion:{values:[],hasMore:!1}};ore();import ODe from"node:process";var pC=class{constructor(t=ODe.stdin,r=ODe.stdout){this._stdin=t,this._stdout=r,this._readBuffer=new ow,this._started=!1,this._ondata=n=>{this._readBuffer.append(n),this.processReadBuffer()},this._onerror=n=>{this.onerror?.(n)}}async start(){if(this._started)throw new Error("StdioServerTransport already started! If using Server class, note that connect() calls start() automatically.");this._started=!0,this._stdin.on("data",this._ondata),this._stdin.on("error",this._onerror)}processReadBuffer(){for(;;)try{let t=this._readBuffer.readMessage();if(t===null)break;this.onmessage?.(t)}catch(t){this.onerror?.(t)}}async close(){this._stdin.off("data",this._ondata),this._stdin.off("error",this._onerror),this._stdin.listenerCount("data")===0&&this._stdin.pause(),this._readBuffer.clear(),this.onclose?.()}send(t){return new Promise(r=>{let n=Kz(t);this._stdout.write(n)?r():this._stdout.once("drain",r)})}};import{resolve as v$}from"node:path";import{fileURLToPath as cdt}from"node:url";ao();function $De(e){return[{name:"claim_status",title:"Read AFK claim",description:"Return the parsed claim marker records and current holder for one issue (`issue`) or a batch (`issues`), keyed per issue.",inputSchema:{issue:w.number().int().positive().optional(),issues:w.array(w.number().int().positive()).min(1).optional()},invoke:t=>e.claimStatus(t)},{name:"claim_release",title:"Release AFK claim",description:"MUTATING: post a concede marker for every un-conceded claim holder so the issue (`issue`) or each issue in a batch (`issues`) becomes claimable again.",inputSchema:{issue:w.number().int().positive().optional(),issues:w.array(w.number().int().positive()).min(1).optional()},invoke:t=>e.claimRelease(t)}]}d_();function ire(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)?e:null}function sre(e){return typeof e=="string"&&e.trim()!==""?e:null}function b1t(e){let t=ire(e);if(t===null)return null;let r=ire(t.demand);return sre(r?.refusal)??sre(t.latest_refusal)}function MDe(e){return{tool:"status",args:{scope:"project"},why:e}}function x1t(){return{tool:"status",args:{scope:"host"},why:"diagnose why the host daemon does not answer before changing registration"}}function S1t(e,t){let r=e.registration;return r.daemon_reachable?!r.held&&r.repair!==void 0&&r.repair!=="none"?u_():e.live_workers.length>0&&t===null?{tool:"status",args:{scope:"worker"},why:"observe the Workers already draining this project's queue"}:MDe(t!==null?"observe when the daemon's refusal clears and capacity begins draining again":"observe the next socket-local queue poll and Worker birth"):x1t()}function k1t(e){let t=e.registration;if(!t.daemon_reachable)return"daemon unreachable: this project cannot read or change its host registration";if(!t.held)return"unregistered: the daemon is reachable but holds no registration for this project";let r=t.last_poll?.depth,n=r==null?"an unknown queue":`${r} queued`;return`draining: ${e.slots.busy} of ${e.slots.total} Worker slots are busy with ${n}`}function _1t(e){return[{intent:"choose the capability that matches your intent",tools:e.filter(t=>!t.description.startsWith("DEPRECATED:")).map(({name:t,title:r})=>({name:t,title:r}))}]}function DDe(e,t){return[{name:"help",title:"Find the next redskilled action",description:"Read live daemon, registration, queue, Worker, and refusal state; return the pasteable next call and a generated intent map. Makes no GitHub request.",inputSchema:{},invoke:async()=>{let[r,n]=await Promise.all([e.projectStatus(),e.hostState().catch(()=>null)]),o=k1t(r),i=b1t(n),s=S1t(r,i),a=ma({state:`you are ${o}`,repair:s});if(a.repair==="none")throw new Error("help produced no callable next action");return{here:o,state:{daemon:{reachable:r.registration.daemon_reachable,version:sre(ire(n)?.daemon_version)??""},registration:{held:r.registration.held,project:r.registration.project,renewal:r.registration.renewal,target:r.registration.target},queue:r.registration.last_poll==null?null:{at:r.registration.last_poll.at,outcome:r.registration.last_poll.outcome,depth:r.registration.last_poll.depth,detail:r.registration.last_poll.detail},workers:{busy:r.slots.busy,free:r.slots.free,live:r.live_workers.length,target:r.slots.total},validation_schedule:r.validation_schedule,last_refusal:i,warnings:r.warnings??[]},guidance:a.prose,next:a.repair,intent_map:_1t(t())}}}]}ao();function NDe(e){return[{name:"merge_arm",title:"Arm PR for the merge driver",description:"MUTATING: hand one open PR to a live project merge-driver process \u2014 it owns the PR to a terminal state (update-branch when BEHIND, merge-commit once green at head, bounded retries, needs-medic/needs-human classification) without GitHub native auto-merge. Refuses when the merge-driver process is missing so custody cannot become orphaned.",inputSchema:{pr:w.number().int().positive()},invoke:({pr:t})=>e.mergeArm({pr:t})},{name:"merge_status",title:"Read merge driver state",description:"Return whether the merge-driver process is ticking plus durable per-PR records: armed records labeled driver-ticking or orphaned, attempts, last observed state, and terminal classifications.",inputSchema:{},invoke:()=>e.mergeStatus()},{name:"merge_release",title:"Release PR from the merge driver",description:"MUTATING: stop driver ownership of one PR. The record is kept as released for observability.",inputSchema:{pr:w.number().int().positive()},invoke:({pr:t})=>e.mergeRelease({pr:t})}]}ao();var w1t=["requeue","retake","park","close"];function zDe(e){return[{name:"hitl_resolve",title:"Resolve parked issue with a human decision",description:"MUTATING: encode one human decision on a parked issue atomically \u2014 requeue (concede dangling claims, strip park labels, ready-for-agent), retake (route to the no-agent landing lane), park (keep ready-for-human, record why), or close. The rationale is posted as an issue comment for the audit trail.",inputSchema:{issue:w.number().int().positive(),decision:w.enum(w1t),rationale:w.string().min(1)},invoke:t=>e.hitlResolve(t)}]}ao();var Zz="2.0.0";function Jz(e,t){return{version:Zz,schema:e,projection:t}}var lAr=w.object({age_s:w.number(),stale:w.boolean(),stale_after_s:w.number(),reason:w.enum(["fresh","aged-out","never-observed","orphaned"])}),v1t=w.object({version:w.string(),source:w.enum(["registry","recorded","installed-plugin","bundle-cache","unresolved"]),age_ms:w.number(),stale_after_ms:w.number(),stale:w.boolean(),reason:w.enum(["fresh","aged-out","installed-only","cache-only","never-observed"])}),E1t=w.object({tool:w.string().min(1),args:w.record(w.string(),w.unknown()),why:w.string().min(1)}),R1t=w.union([E1t,w.literal("none")]),T1t=w.object({held:w.boolean(),daemon_reachable:w.boolean(),project:w.string(),socket:w.string(),selector:w.string(),target:w.number(),renewal:w.enum(["renewing","self-renewing","running-on","unknown"]),renew_by:w.string(),renewals:w.number(),lapsed_at:w.string(),reason:w.string(),repair:R1t.optional(),repair_reason:w.string().min(1).optional(),launch_revision:w.number(),bundle_version:w.string(),plugin_cache_version:w.string(),last_poll:w.object({at:w.string(),outcome:w.string(),depth:w.number().nullable(),request_count:w.number(),detail:w.string()}).optional(),published_version:v1t.optional()}).superRefine((e,t)=>{!e.held&&e.repair===void 0&&t.addIssue({code:w.ZodIssueCode.custom,path:["repair"],message:"an absent registration must carry a repair or an argued none"}),e.repair==="none"&&e.repair_reason===void 0&&t.addIssue({code:w.ZodIssueCode.custom,path:["repair_reason"],message:"repair none must state why no callable cure is safe"})}),C1t=w.object({name:w.literal("project-birth-breaker"),project_label:w.string(),state:w.enum(["open","half-open"]),opened_at:w.string(),reason:w.string(),closes:w.string(),probe_worker_id:w.string().nullable(),repair:w.object({tool:w.literal("project_reset"),args:w.object({latch:w.literal("project-birth-breaker")}),why:w.string()})}),P1t=w.object({narration:w.string(),moments:w.array(w.object({moment:w.enum(["iteration","post_done","landing"]),state:w.enum(["declared","skip"]),declared:w.boolean(),commands:w.array(w.string())})).length(3)}),fC=w.object({registration:T1t,validation_schedule:P1t,birth_latch:C1t.nullable(),slots:w.object({busy:w.number(),free:w.number(),parked:w.number(),total:w.number(),interactive_reservation:w.number()}),live_workers:w.array(w.object({id:w.string(),pid:w.number(),issue:w.string(),activity:w.string(),origin:w.string()})),unattributed_workers:w.array(w.object({id:w.string(),pid:w.number(),issue:w.string(),activity:w.string(),origin:w.string()})),warnings:w.array(w.string()).optional()}),I1t=w.object({number:w.union([w.number(),w.string()]),runner:w.string(),retries:w.number(),phase:w.string(),iteration:w.union([w.number(),w.string()]),activity:w.string(),loc_added:w.number(),loc_removed:w.number(),last_commit_at:w.string(),tools_called_count:w.number(),text_chunk_count:w.number(),reasoning_events:w.number(),reasoning_tokens:w.number(),last_event_at:w.string(),waiting_count:w.number(),input_tokens:w.number(),output_tokens:w.number(),cost_usd:w.number()}),A1t=w.object({status:w.enum(["alive","stalled","capped","unknown"]),laneFresh:w.boolean(),laneAgeMs:w.number().optional(),crossCheckArmed:w.boolean(),liveDescendants:w.boolean().optional(),reason:w.string()}),O1t=w.object({verdict:w.enum(["alive","dead","unknown"]),anchor:w.enum(["daemon","none"]),project_label:w.string().nullable(),pid:w.number().nullable(),staleness:w.object({stale:w.boolean(),age_ms:w.number().nullable(),threshold_ms:w.number().nullable(),reason:w.string()})}),FDe=w.object({worker:w.object({id:w.string(),pid:w.number(),runner:w.string(),origin:w.string(),started_at:w.string(),done:w.number(),total:w.number(),blocked:w.number(),failed:w.number(),current:I1t}),live:w.boolean(),active:w.boolean(),renderable_live:w.boolean(),liveness:w.enum(["active","quiet-but-live","dead"]),liveness_verdict:A1t,daemon_liveness:O1t.optional()}),Yz=w.array(FDe),Qz=w.array(FDe.partial()),$1t=w.object({state:w.object({worker_id:w.string(),pid:w.number(),runner:w.string(),started_at:w.string(),total:w.number(),done:w.number(),blocked:w.number(),failed:w.number(),current:w.object({number:w.union([w.number(),w.string()]),title:w.string(),activity:w.string(),started_at:w.string()})}),live:w.boolean()}),mC=w.object({workers:w.array($1t),events:w.array(w.object({event:w.string(),epoch:w.number()})),fleet:w.object({ts:w.string(),epoch:w.number(),runner:w.string(),readyForAgent:w.number(),slotsBusy:w.number(),slotsFree:w.number(),slotsTotal:w.number(),slotsParked:w.number(),interactiveReservation:w.number(),spawnsThisTick:w.number()}).nullable(),remoteQueue:w.number().optional(),remoteHuman:w.number().optional(),remoteCacheAgeS:w.number().optional()}),LDe=w.object({number:w.number(),title:w.string(),labels:w.array(w.string())}),jDe=w.object({ready_for_agent:w.object({eligible:w.array(LDe),held_for_summon:w.array(LDe)}),ready_for_human:w.array(w.object({number:w.number(),title:w.string(),labels:w.array(w.string()),body:w.string().optional(),createdAt:w.string().nullable().optional()})),counts:w.object({ready_for_agent_eligible:w.number(),ready_for_agent_held:w.number(),ready_for_human:w.number()}),degraded:w.boolean(),errors:w.array(w.object({kind:w.literal("trust-read"),number:w.number(),message:w.string()}))}),UDe=Jz(fC),uAr=Jz(Yz,{input:"fields",schema:Qz}),dAr=Jz(mC),HDe=Jz(jDe);function M1t(e,t){let{projection:r}=e;if(!r)return e.schema;let n=t[r.input];return Array.isArray(n)&&n.length>0?r.schema:e.schema}function qDe(e){return e.map(t=>{let r=t.outputContract;if(!r)return t;let n=t.invoke.bind(t);return{...t,invoke:async o=>{let i=await n(o),s=M1t(r,o).safeParse(i);if(!s.success)throw new Error(`${t.name} output violates contract ${r.version}: ${s.error.issues.map(a=>`${a.path.join(".")||"<root>"}: ${a.message}`).join("; ")}`);return i}}})}ao();var GDe="named fleets were removed (ADR 0130): the host daemon owns the budget and each project has exactly one demand producer, so a fleet name addresses nothing. Drop the name \u2014 the work scope, the runner and the base branch now ride with the project's producer: pass `selector` / `runner` / `base` to the rs_dev `project_start` tool (status: `project_status`, resize: `project_resize`, stop: `project_stop`).",are=class extends Error{constructor(t){super(t===void 0||t===""?GDe:`fleet ${JSON.stringify(t)}: ${GDe}`),this.name="FleetNamingRemovedError"}};function iw(e){if(!(e==null||e===""))throw new are(typeof e=="string"?e:String(e))}ao();var D1t=w.object({tool:w.literal("status"),args:w.object({scope:w.enum(["worker","project","host"])})});function BDe(e){return w.object({deprecated:w.literal(!0),message:w.string().min(1),replacement:D1t,result:e})}function VDe(e){return{version:e.version,schema:BDe(e.schema),...e.projection===void 0?{}:{projection:{input:e.projection.input,schema:BDe(e.projection.schema)}}}}var N1t=w.object({status:w.unknown(),vitals:Yz,monitor:mC}),z1t=w.object({status:w.unknown(),vitals:Qz,monitor:mC}),WDe=w.object({state:w.unknown(),dashboard:w.unknown(),provision_check:w.unknown(),unit_status:w.unknown()}),L1t={version:Zz,schema:w.union([fC,N1t,WDe]),projection:{input:"fields",schema:w.union([fC,z1t,WDe])}};function KDe(e,t,r){return{deprecated:!0,message:`${e} is deprecated; use status { scope: ${t} }`,replacement:{tool:"status",args:{scope:t}},result:r}}async function F1t(e,t){if(t.scope==="project")return e.projectStatus();if(t.scope==="host"){let[s,a,c,l]=await Promise.all([e.hostState(),e.hostDashboard(),e.hostProvisionCheck(),e.hostUnitStatus()]);return{state:s,dashboard:a,provision_check:c,unit_status:l}}let r={worker:t.worker,live_only:t.live_only??!0,fields:t.fields},[n,o,i]=await Promise.all([e.workerStatus(r),e.workerVitals({live_only:r.live_only,fields:r.fields}),e.monitor()]);return{status:n,vitals:o,monitor:i}}function ZDe(e){return[{name:"status",title:"Read redskilled status",description:"Answer the current worker, project, or host status through one intent-scoped read.",inputSchema:{scope:w.enum(["worker","project","host"]),worker:w.string().min(1).optional(),live_only:w.boolean().default(!0),fields:w.array(w.string().min(1)).optional()},outputContract:L1t,invoke:t=>F1t(e,t)}]}cre();var Xz={spec:w.number().int().positive().optional(),lane:w.string().min(1).optional(),label:w.string().min(1).optional(),issues:w.array(w.number().int().positive()).optional(),tags:w.array(w.string().min(1)).optional(),user:w.string().min(1).optional()};var QDe=w.record(w.string(),w.union([w.string(),w.number(),w.boolean()])),hC=w.string().optional().describe("REMOVED: naming a fleet is refused; a project has one producer.");function XDe(e){return[{name:"project_activation",title:"Preview this project's redskilled activation",description:"READ-ONLY: report whether this project opted into RedSkills and the canonical runner and target a no-argument drain would register.",inputSchema:{},invoke:()=>e.projectActivation()},{name:"project_status",title:"Deprecated project status alias",description:"DEPRECATED: use status { scope: project }. Returns the project answer and names its replacement.",inputSchema:{fleet:hC},outputContract:VDe(UDe),invoke:async({fleet:t})=>(iw(t),KDe("project_status","project",await e.projectStatus()))},{name:"drain",title:"Make this project drain",description:"MUTATING: ensure the daemon is reachable and this project is registered. Omitted runner and target resolve from this project's canonical RedSkills configuration; repeated calls report what was kept.",inputSchema:{runner:w.string().min(1).optional(),target:w.number().int().min(0).optional()},invoke:async t=>e.drain(t)},{name:"project_start",title:"Start this project's workers",description:"MUTATING: register this project with the host daemon \u2014 a runner, a target width, and its work policy. Registers rather than launches: the project contributes a record, never a process of its own.",inputSchema:{runner:w.string().min(1),target:w.number().int().min(0).default(1),selector:w.object(Xz).optional(),config:QDe.optional(),base:w.string().min(1).optional(),fleet:hC},invoke:async t=>(iw(t.fleet),e.projectStart(t))},{name:"project_resize",title:"Re-aim this project's workers",description:"MUTATING: change this project's target width, runner, or work policy and send the live directive.",inputSchema:{runner:w.string().min(1).optional(),target:w.number().int().min(0).optional(),selector:w.object(Xz).optional(),config:QDe.optional(),base:w.string().min(1).optional(),fleet:hC},invoke:async t=>(iw(t.fleet),e.projectResize(t))},{name:"project_reset",title:"Reset project execution latch",description:"MUTATING: clear a named in-memory latch for this project so autonomous demand may retry immediately.",inputSchema:{latch:w.literal("project-birth-breaker"),fleet:hC},invoke:async({latch:t,fleet:r})=>(iw(r),e.projectReset({latch:t}))},{name:"project_stop",title:"Stop this project's workers",description:"MUTATING: stop this project's work and give its registration back; force hard teardown explicitly.",inputSchema:{force:w.boolean().optional(),fleet:hC},invoke:async({force:t,fleet:r})=>(iw(r),e.projectStop({force:t}))}]}ao();function e1e(e){return[{name:"gate_run",title:"Run the AFK gate",description:"MUTATING: materialize the branch's feedback worktree and run the package-scoped validation gate against it.",dangerClass:"mutating",inputSchema:{branch:w.string().min(1),base:w.string().min(1).optional()},invoke:t=>e.gateRun(t)}]}function t1e(e){return[{name:"deadend_audit",title:"Audit AFK deadends",description:"Return the read-only deadend audit: dangling claims, red PRs with dead owners, superseded PRs, executable Tickets carrying an active Current blocker, dependency blocks whose req targets all closed, human-queue age outliers, and stale worktrees \u2014 each class paired with its recommended cure. Cache-backed: repeated calls within the refresh window cost zero GitHub quota.",inputSchema:{},invoke:()=>e.deadendAudit()}]}ao();function r1e(e){return[{name:"requeue",title:"Requeue AFK issue",description:"MUTATING: apply the complete parked-issue requeue transition and record human guidance.",inputSchema:{issue:w.number().int().positive(),guidance:w.string().min(1),repo:w.string().min(1).optional(),dryRun:w.boolean().optional(),adoptBranch:w.string().min(1).optional()},invoke:t=>e.requeue(t)},{name:"retake",title:"Recommend AFK retake",description:"Return the structured issue, PR, branch, worktree, worker-state, and recommended-next-action report.",inputSchema:{issue:w.number().int().positive(),repo:w.string().min(1).optional(),prLimit:w.number().int().positive().max(1e3).optional()},invoke:t=>e.retake(t)},{name:"reap",title:"Reap AFK branches",description:"MUTATING: classify and delete stale local and remote AFK branches.",inputSchema:{},invoke:()=>e.reap()},{name:"unblock_sweep",title:"Sweep dependency blocks",description:"MUTATING: promote dependency-blocked issues whose requirements are all closed.",inputSchema:{},invoke:()=>e.unblockSweep()}]}ao();function n1e(e){return[{name:"land_branch",title:"Land AFK branch",description:"MUTATING: land one validated worker branch into its base through the complete landing sequence.",dangerClass:"mutating",inputSchema:{issue:w.number().int().positive(),branch:w.string().min(1),base:w.string().min(1).optional(),title:w.string().min(1).optional(),openPr:w.boolean().optional()},invoke:t=>e.landBranch(t)},{name:"cascade_status",title:"Read close cascade",description:"Return the dependents of one issue and which of them the close cascade would promote.",inputSchema:{issue:w.number().int().positive()},invoke:({issue:t})=>e.cascadeStatus({issue:t})}]}ao();function o1e(e){return[{name:"logs",title:"Read redskilled logs",description:"Return the newest CastleLaneRecord entries from one structured lane; bounded by `limit` (default 200, max 10 000). Pass `kind` to filter before the limit.",inputSchema:{lane:w.enum(["worker","supervisor","monitor","liveness"]),id:w.string().min(1),limit:w.number().int().positive().max(1e4).default(200),kind:w.string().optional()},invoke:t=>e.logs(t)},{name:"dashboard",title:"Build AFK dashboard",description:"Build the structured operational dashboard from GitHub and local state.",inputSchema:{periodDays:w.number().int().positive().default(30)},invoke:({periodDays:t})=>e.dashboard({periodDays:t})},{name:"history",title:"Read redskilled history",description:"Return structured AFK history records, newest records last.",inputSchema:{limit:w.number().int().positive().max(1e4).optional()},invoke:({limit:t})=>e.history({limit:t})},{name:"queue_status",title:"Read AFK queues",description:"Return ready-for-agent and ready-for-human queue candidates, retaining successful candidates and naming partial trust-read failures as a degraded result. Pass `selector` to preview the producer's scoped view of the ready queue (same facets as its work selector, e.g. tags/user).",inputSchema:{selector:w.object(Xz).optional()},outputContract:HDe,invoke:t=>e.queueStatus({selector:t.selector})},{name:"events_since",title:"Poll events since cursor",description:"Return AFK history events and Worker lane records after an opaque cursor, plus the next cursor. Omit cursor to get a fresh baseline cursor with no events. Unknown or expired cursors are refused with a re-baseline prompt.",inputSchema:{cursor:w.string().min(1).optional()},invoke:t=>e.eventsSince({cursor:t.cursor})}]}ao();function i1e(e){return[{name:"manager",title:"Route work through the Manager",description:"MUTATING: take one operator intent into the Manager \u2014 intake, route an effort to a skill, attach an artifact, read effort status, or export/import the checkpoint \u2014 and return the effort record it acted on.",inputSchema:{intent:w.string().min(1).optional(),action:w.enum(["intake","route","artifact","status","checkpoint"]).optional(),effort:w.string().min(1).optional(),skill:w.string().min(1).optional(),artifact:w.string().min(1).optional(),checkpoint:w.enum(["export","import"]).optional(),path:w.string().min(1).optional()},invoke:t=>e.manager(t)},{name:"red_doctor",title:"Diagnose this repository's RedSkills setup",description:"READ-ONLY: return every doctor finding for this repository \u2014 operational probes, host toolchain, lane and process census, executable acceptance, HUMAN-ONLY type declarations and disposable-lane hygiene \u2014 each paired with the route that repairs it. Applying a repair is the `/red-doctor` skill's own fix lane, never a side effect of the read.",inputSchema:{checks:w.array(w.string().min(1)).optional()},invoke:t=>e.redDoctor(t)},{name:"audit_skills",title:"Audit the shipped skills",description:"Return the ranked skill-audit scores for this repository's skill tree. Pass `mechanical_only` to score without the judge, which makes the read deterministic and free of agent cost.",inputSchema:{mechanical_only:w.boolean().optional(),runner:w.string().min(1).optional()},invoke:t=>e.auditSkills(t)},{name:"install_type_labels",title:"Install Wayfinder type labels",description:"MUTATING: create the Wayfinder ticket type labels on the tracker AND declare the HUMAN-ONLY ones in this project's configuration, in one act \u2014 the two are one protection with two halves, and installing only the labels leaves the repository looking protected while unblocked decision Tickets enter the autonomous queue (#3013).",inputSchema:{labels:w.array(w.string().min(1)).optional(),repo:w.string().min(1).optional(),dry_run:w.boolean().optional()},invoke:t=>e.installTypeLabels(t)},{name:"codex_statusline",title:"Inspect the Codex footer preference",description:"READ-ONLY: return the active Codex configuration's status-line inspection \u2014 the file read, the current preference, and the problem that keeps the RedSkills footer from rendering.",inputSchema:{config:w.string().min(1).optional()},invoke:t=>e.codexStatusline(t)},{name:"codex_monitor_agent",title:"Build the Codex monitor agent brief",description:"Return the read-only monitor brief a Codex sub-agent is spawned with: what to poll, how often, and the conditions under which it closes itself. It spawns nothing \u2014 the host's own spawn primitive does.",inputSchema:{project_root:w.string().min(1).optional(),mode:w.string().min(1).optional(),interval_seconds:w.number().int().positive().optional()},invoke:t=>e.codexMonitorAgent(t)},{name:"reconcile_engine",title:"Reconcile this project's engine delivery",description:"MUTATING: warm the published engine bundle into the stable cache path and re-point a standing registration at it in one operation, then return the version, the bundle path, and what happened to the registration.",inputSchema:{version:w.string().min(1).optional()},invoke:t=>e.reconcileEngine(t)}]}ao();function s1e(e){return[{name:"daily_review",title:"Build daily activity review",description:"Return the structured daily activity review report for the local window.",inputSchema:{},invoke:()=>e.dailyReview({})},{name:"weekly_review",title:"Build weekly activity review",description:"Return the structured weekly activity review report for the local window.",inputSchema:{},invoke:()=>e.weeklyReview({})},{name:"triage",title:"Apply triage decision",description:"MUTATING: apply the decided triage transition to one issue, gated by the per-repo trust policy.",inputSchema:{issue:w.number().int().positive(),decision:w.enum(["ready-for-agent","needs-info","ready-for-human","wontfix"]),summon:w.boolean().optional(),repo:w.string().min(1).optional()},invoke:t=>e.triage(t)},{name:"respond",title:"Handle comment event",description:"MUTATING: parse a /dev comment summon, authorize the commenter, and route the advisory or mutation verb.",inputSchema:{body:w.string(),number:w.number().int().positive(),author:w.string().min(1).optional(),is_pr:w.boolean().optional(),runner:w.string().min(1).optional(),repo:w.string().min(1).optional()},invoke:t=>e.respond(t)}]}ao();ao();d_();function lre(e){let t=ma({state:e instanceof Error?e.message:String(e),repair:nb("the caller must choose one dispatch intent before retrying")});if(t.repair!=="none")throw new Error("invalid worker refusal repair");return{refused:!0,reason:t.prose,repair:t.repair,repair_reason:t.repair_reason}}var ure={issue:w.number().int().positive().optional(),demand:w.string().min(1).optional(),runner:w.string().min(1).optional(),mode:w.enum(["no-mistakes","direct-PR","local-only","scout"]).optional()};function dre(e){let t=e;if(t.issue===void 0==(t.demand===void 0))throw new Error("exactly one of issue or demand is required");if(t.mode==="scout"&&t.issue!==void 0)throw new Error("mode: scout is demand-only \u2014 combine scout with demand, not issue");if(t.issue!==void 0&&t.mode!==void 0)throw new Error("mode is only valid for demand dispatches");return t}function a1e(e){return[{name:"worker_dispatch",title:"Dispatch AFK worker",description:"MUTATING: run one tracked issue or mint and run one disposable demand through the AFK worker lifecycle.",inputSchema:ure,invoke:t=>{let r;try{r=dre(t)}catch(n){return Promise.resolve(lre(n))}return e.workerDispatch(r)}},{name:"worker_stop",title:"Stop AFK worker",description:"MUTATING: terminate one worker process tree.",inputSchema:{worker:w.string().min(1)},invoke:({worker:t})=>e.workerStop({worker:t,recycle:!1})},{name:"worker_recycle",title:"Recycle AFK worker",description:"MUTATING: terminate one fleet worker so its supervisor can replace the slot.",inputSchema:{worker:w.string().min(1)},invoke:({worker:t})=>e.workerStop({worker:t,recycle:!0})}]}function c1e(e){return[{name:"runner_list",title:"List AFK runners",description:"Return the canonical runner specification registry.",inputSchema:{},invoke:()=>e.runnerList()},{name:"runner_detect",title:"Detect AFK runner",description:"Resolve the runner selected by an explicit override or the current host environment.",inputSchema:{runner:w.string().min(1).optional()},invoke:({runner:t})=>e.runnerDetect({runner:t})},{name:"runner_steer",title:"Steer live AFK worker",description:"MUTATING: write a live-steer request into a running worker's next iteration.",inputSchema:{worker:w.string().min(1),text:w.string().min(1)},invoke:t=>e.runnerSteer(t)},{name:"steer_status",title:"Read steer status",description:"Return the live-steer status for a worker: none (no steer ever written), pending (written, not yet consumed), or consumed (consumed at a specific iteration).",inputSchema:{worker:w.string().min(1)},invoke:t=>e.steerStatus(t)},{name:"worker_request",title:"Dispatch worker with request",description:"MUTATING: dispatch a new worker and inject a special request into its spawn-time handoff.",inputSchema:{...ure,text:w.string().min(1)},invoke:t=>{let r;try{r=dre(t)}catch(n){return Promise.resolve(lre(n))}return e.workerRequest({...r,text:t.text})}}]}function l1e(e){return[{name:"statusline_aggregate",title:"Read statusline aggregate",description:"Return the project-side statusline aggregate (project, repo counters, docs drift, drain, Worker rows, aggregated AFK block, queue) as structured data, using the same collector cores and cache discipline as the command-backed statusLine. Host-side fields (session model/effort, context %, usage quotas) are out of scope.",inputSchema:{},invoke:()=>e.statuslineAggregate()}]}ao();d_();function u1e(e,t,r={}){let n=e==="confirm"?ma({state:"dangerous tool requires explicit confirmation",repair:{tool:t,args:{...r,confirmation:!0},why:"retry the same operation with explicit confirmation"}}):ma({state:"dangerous tool is denied by the configured posture",repair:nb("the configured posture deliberately forbids this tool")});return{refused:!0,posture:e,action:t,reason:n.prose,repair:n.repair,...n.repair==="none"?{repair_reason:n.repair_reason}:{}}}function d1e(e,t){return t==="allow"?e:e.map(r=>{if(!r.dangerClass)return r;if(t==="deny")return{...r,invoke:async i=>u1e("deny",r.name)};let n={...r.inputSchema,confirmation:w.boolean().optional()},o=r.invoke.bind(r);return{...r,inputSchema:n,invoke:async i=>{if(i.confirmation!==!0)return u1e("confirm",r.name,i);let{confirmation:s,...a}=i;return o(a)}}})}ao();function p1e(e){return[{name:"wait_start",title:"Start rsp wait",description:"MUTATING: spawn a detached rsp wait (pr | run | release | cmd) and return its registry id.",inputSchema:{kind:w.enum(["pr","run","release","cmd"]),target:w.string().min(1),timeout_ms:w.number().int().positive().optional(),reason:w.string().optional()},invoke:t=>e.waitStart(t)},{name:"wait_list",title:"List active rsp waits",description:"Return the active-wait registry from .red/tmp/waits.",inputSchema:{},invoke:()=>e.waitList()},{name:"wait_status",title:"Read rsp wait status",description:"Return the registry entry for a running wait or the sealed result envelope for a finished one.",inputSchema:{id:w.string().min(1)},invoke:({id:t})=>e.waitStatus({id:t})}]}ao();function f1e(e){return[{name:"worktree_list",title:"List disposable worktrees",description:"Enumerate every checkout under the disposable `.red/tmp/worktrees/*` lanes.",inputSchema:{},invoke:()=>e.worktreeList()},{name:"worktree_remove",title:"Remove disposable worktree",description:"MUTATING: remove one checkout under the disposable `.red/tmp/worktrees/*` lanes.",inputSchema:{path:w.string().min(1)},invoke:({path:t})=>e.worktreeRemove({path:t})}]}var eL="Call the redskilled MCP's `help` tool.\nFollow its guidance and invoke the returned `next` call.",pre=[{name:"drain",title:"Drain this project's queue",description:"Find the next action for starting or continuing a project drain.",body:eL},{name:"diagnose",title:"Diagnose redskilled",description:"Find the next action for understanding a redskilled problem.",body:eL},{name:"configure",title:"Configure redskilled",description:"Find the next action for changing project execution configuration.",body:eL},{name:"stop",title:"Stop project work",description:"Find the next action for stopping project work safely.",body:eL}];var m1e="rs_dev";function h1e(e,t="allow"){let r=[],n=[...DDe(e,()=>r),...ZDe(e),...XDe(e),...o1e(e),...t1e(e),...a1e(e),...c1e(e),...r1e(e),...e1e(e),...n1e(e),...$De(e),...NDe(e),...zDe(e),...f1e(e),...p1e(e),...s1e(e),...l1e(e),...i1e(e)];return r=d1e(qDe(n),t),r}Qt();function sw(e){return tn(JSON.parse(JSON.stringify(e??null)),{objectArrayColumns:!0,primitiveArrayColumns:!0})}var U1t=new Map([["drain","drain"],["project_drain","drain"],["project_stop","stop"],["project_status","status"],["status","status"]]),H1t=new Set(["target","runner","scope"]);async function g1e(e,t,r){let n=U1t.get(t);if(n!=null){let o=Object.keys(r).filter(i=>!H1t.has(i));if(o.length>0)throw new Error(`the Project control surface cannot express ${JSON.stringify(o.sort())} for ${JSON.stringify(t)}`);return n==="status"?await e.control("status"):await e.control(n,q1t(r))}if(!B1t(t))throw new Error(`unsupported ACP Project capability ${JSON.stringify(t)}`);return await e.prompt(G1t(t,r))}function q1t(e){let t=e.target,r=e.runner;return{...typeof t=="number"&&Number.isInteger(t)&&t>=0?{target:t}:{},...typeof r=="string"&&r.length>0?{runner:r}:{}}}function G1t(e,t){return`/${e} ${JSON.stringify(t)}`}function B1t(e){return/^[a-z][a-z0-9_]*$/.test(e)&&!e.startsWith("private_")&&!e.includes("worker_birth")&&!e.includes("daemon_protocol")&&!e.includes("github_client")}fd();var aw="redskilled://lanes/events",W1t=1e3;function y1e(e,t,r={}){let n=r.bufferLimit??W1t,o=[],i=0,s,a=c=>{o.push(c.record),o.length>n&&o.splice(0,o.length-n),e.sendResourceUpdated({uri:aw})};return e.registerCapabilities({resources:{subscribe:!0}}),e.setRequestHandler(M_,()=>({resources:[{uri:aw,name:"Redskilled lane events",description:"Subscribe to receive AFK lane records (Worker landings, deaths, lost claims, supervisor halts) appended after subscription. Payloads are byte-compatible with the `logs` tool's CastleLaneRecord shape.",mimeType:"application/toon"}]})),e.setRequestHandler(D_,c=>{let l=fre(c);if(l!==aw)throw new Error(`unknown resource ${JSON.stringify(l)}`);let u=o.splice(0,o.length);return{contents:[{uri:aw,mimeType:"application/toon",text:sw({events:u})}]}}),e.setRequestHandler(sX,async c=>fre(c)!==aw?{}:(i+=1,i===1&&(s=await t.subscribe(a),t.start(r.intervalMs)),{})),e.setRequestHandler(aX,c=>fre(c)!==aw?{}:(i>0&&(i-=1),i===0&&(s?.(),s=void 0,t.stop()),{})),{poll:()=>t.poll(),stop:()=>{s?.(),s=void 0,t.stop()}}}function fre(e){let t=e?.params;return typeof t?.uri=="string"?t.uri:""}function x1e(e){let t=new Set,r,n,o=async()=>{let s=await e("events_since",r===void 0?{}:{cursor:r});if(!b1e(s)||typeof s.cursor!="string")throw new Error("redskilled ACP returned an invalid events_since envelope");let a=Array.isArray(s.lane_records)?s.lane_records.filter(b1e):[];return{cursor:s.cursor,lane_records:a}},i={async subscribe(s){return r===void 0&&(r=(await o()).cursor),t.add(s),()=>t.delete(s)},async poll(){if(t.size===0)return 0;let s=await o();r=s.cursor;for(let a of s.lane_records)for(let c of t)c({path:"redskilled-acp",record:a});return s.lane_records.length},start(s=1e3){n===void 0&&(n=setInterval(()=>void i.poll().catch(()=>{}),s),n.unref())},stop(){n!==void 0&&clearInterval(n),n=void 0,t.clear()}};return i}function b1e(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}ao();var mre="rs_github",S1e="github_request",tL=Ms.githubRequest;function hre(){return[{name:S1e,title:"Request the Project's forge",description:"MUTATING: forward one REST request to the Project's GitHub gateway. An observing method (GET, HEAD) is served from the daemon's Project cache and carries the age of what it served; concurrent identical reads share one upstream call. A mutating method is scheduled through the daemon's durable outbox and answers with its publication receipt. Paths are repository-relative \u2014 `issues/17` \u2014 or the full `repos/<owner>/<repo>/\u2026` form of this Project's own repository; another repository is refused.",method:tL,inputSchema:{method:w.enum(aPe),path:w.string().min(1),body:w.record(w.unknown()).optional(),headers:w.record(w.string()).optional()}}]}function k1e(e){return{request:{method:e.method,path:e.path,...e.body===void 0?{}:{body:e.body},...e.headers===void 0?{}:{headers:e.headers}}}}function gre(e){let t=new nw({name:mre,version:e.version}),r=t.registerTool.bind(t);for(let n of e.tools??hre())r(n.name,{title:n.title,description:n.description,inputSchema:n.inputSchema},async o=>({content:[{type:"text",text:sw(await e.invoke(n.method,k1e(o)))}]}));return t}var _0=WW("redskilled-mcp");function vcr(e=process.cwd(),t){let r=new nw({name:m1e,version:_0.version}),n=r.registerTool.bind(r),o=t??(async()=>{throw new Error("REDSKILLED_ACP_UNAVAILABLE: the stdio adapter has no ACP client")}),i={};for(let s of h1e(i))n(s.name,{title:s.title,description:s.description,inputSchema:s.inputSchema},async a=>({content:[{type:"text",text:sw(await o(s.name,a))}]}));for(let s of pre)r.registerPrompt(s.name,{title:s.title,description:s.description},async()=>({messages:[{role:"user",content:{type:"text",text:s.body}}]}));return y1e(r.server,x1e(o)),r}async function ldt(e,t=process.env,r=process.cwd()){let n=(t.RED_SKILLS_PROJECT_ROOT??t.CLAUDE_PROJECT_DIR??t.CODEX_PROJECT_DIR??t.OPENCODE_PROJECT_DIR??"").trim();if(n!=="")return v$(n);if(e.getClientCapabilities()?.roots!==void 0)try{let o=await e.listRoots();for(let i of o.roots)if(i.uri.startsWith("file:"))return v$(cdt(i.uri))}catch{}return v$(r)}async function udt(e){let t,r=new Promise(n=>{t=n});e.server.server.onclose=t,await e.server.connect(e.transport),await r}async function Ecr(){let e=process.cwd(),t,r,n=()=>(t??=ldt(r.server,process.env,e).then(i=>k7({cwd:i,name:"RedSkills GitHub MCP adapter",version:_0.version})),t);r=gre({version:_0.version,invoke:async(i,s)=>{if(i!==tL)throw new Error(`rs_github: no daemon method ${JSON.stringify(i)}`);return(await n()).github(s.request)}});let o=()=>{r.close()};process.once("SIGINT",o),process.once("SIGTERM",o);try{await udt({server:r,transport:new pC})}finally{if(t!==void 0)try{(await t).close()}catch{}process.removeListener("SIGINT",o),process.removeListener("SIGTERM",o)}}async function Rcr(){let e=process.cwd(),t,r,n=()=>(t??=ldt(r.server,process.env,e).then(i=>k7({cwd:i,name:"RedSkills MCP adapter",version:_0.version})),t);r=vcr(e,async(i,s)=>g1e(await n(),i,s));let o=()=>{r.close()};process.once("SIGINT",o),process.once("SIGTERM",o);try{await udt({server:r,transport:new pC})}finally{if(t!==void 0)try{(await t).close()}catch{}process.removeListener("SIGINT",o),process.removeListener("SIGTERM",o)}}var Tcr=`Usage: red-skills-redskilled-mcp [command]
439
+ `,u=e.getWriter();try{await u.write(r.encode(l))}finally{u.releaseLock()}}});return{readable:s,writable:a}}var Hdr=_Z.and(x({mode:O("form")})).and(x({message:g()})),qdr=wZ.and(x({mode:O("url")})).and(x({message:g()})),Gdr=be([uR,dR]).and(x({message:g()})),Bdr=gZ.and(x({type:O("string")})),Wdr=yZ.and(x({type:O("number")})),Vdr=bZ.and(x({type:O("integer")})),Kdr=xZ.and(x({type:O("boolean")})),Zdr=kZ.and(x({type:O("array")})),Jdr=SZ.and(x({type:O("string")}));var Ydr=VZ.and(x({action:O("accept")})),Qdr=x({action:O("decline")}),Xdr=x({action:O("cancel")});function h9(e,t){return c9(e,t)}function Dc(e){return e??{}}function Tve(e){return typeof e=="object"&&e!==null&&"readable"in e&&"writable"in e}function Cve(){let e=new TransformStream,t=new TransformStream;return[{readable:t.readable,writable:e.writable},{readable:e.readable,writable:t.writable}]}var Xm={agent:{initialize:Me.initialize,authenticate:Me.authenticate,logout:Me.logout,providers:{list:Me.providers_list,set:Me.providers_set,disable:Me.providers_disable},session:{new:Me.session_new,load:Me.session_load,list:Me.session_list,delete:Me.session_delete,fork:Me.session_fork,resume:Me.session_resume,close:Me.session_close,setMode:Me.session_set_mode,setConfigOption:Me.session_set_config_option,prompt:Me.session_prompt,cancel:Me.session_cancel},nes:{start:Me.nes_start,suggest:Me.nes_suggest,accept:Me.nes_accept,reject:Me.nes_reject,close:Me.nes_close},document:{didOpen:Me.document_did_open,didChange:Me.document_did_change,didClose:Me.document_did_close,didSave:Me.document_did_save,didFocus:Me.document_did_focus}},client:{session:{requestPermission:ir.session_request_permission,update:ir.session_update},fs:{writeTextFile:ir.fs_write_text_file,readTextFile:ir.fs_read_text_file},terminal:{create:ir.terminal_create,output:ir.terminal_output,release:ir.terminal_release,waitForExit:ir.terminal_wait_for_exit,kill:ir.terminal_kill},elicitation:{create:ir.elicitation_create,complete:ir.elicitation_complete}},protocol:{cancelRequest:KW.cancel_request}},Pve=Symbol("startActiveSession"),kD=class{cx;currentRequestId;constructor(t,r){this.cx=t,this.currentRequestId=r}get requestId(){return this.currentRequestId}get connectionContext(){return this.cx}sendRequest(t,r,n,o){return this.cx.sendRequest(t,r,n,o)}sendNotification(t,r){return this.cx.sendNotification(t,r)}addDynamicHandler(t){return this.cx.addDynamicHandler(t)}},pR=class e extends kD{constructor(t,r){super(t,r)}static create(t,r){return new e(t,r)}request(t,r,n){let o=Nve[t];return this.sendRequest(t,r,o?.mapResponse,n)}notify(t,r){return this.sendNotification(t,r)}},fR=class e extends kD{constructor(t,r){super(t,r)}static create(t,r){return new e(t,r)}[Pve](t,r){return this.sendRequest(Me.session_new,t,n=>this.attachSession(n),r)}buildSession(t){return typeof t=="string"?wD.create(this,{cwd:t,mcpServers:[]}):wD.create(this,t)}attachSession(t){let r=new d9,n=this.connectionContext.signal,o=()=>{r.fail(n.reason??new Error("ACP connection closed"))};n.aborted?o():n.addEventListener("abort",o);let i=zve(this.connectionContext).attach(t,r),s=new Ap(()=>{n.removeEventListener("abort",o)});return p9.create(this,t,r,[i,s])}request(t,r,n){let o=Dve[t];return this.sendRequest(t,r,o?.mapResponse,n)}notify(t,r){return this.sendNotification(t,r)}},_D=class{connection;constructor(t){this.connection=t}get signal(){return this.connection.signal}get closed(){return this.connection.closed}close(t){this.connection.close(t)}},l9=class extends _D{connectHandlers;client;didStartConnectHandlers=!1;constructor(t,r=[]){super(t),this.connectHandlers=r,this.client=pR.create(t.getContext())}startConnectHandlers(){this.didStartConnectHandlers||(this.didStartConnectHandlers=!0,TD(this,this.connectHandlers))}},u9=class extends _D{connectHandlers;agent;didStartConnectHandlers=!1;constructor(t,r=[]){super(t),this.connectHandlers=r,this.agent=fR.create(t.getContext())}startConnectHandlers(){this.didStartConnectHandlers||(this.didStartConnectHandlers=!0,TD(this,this.connectHandlers))}};function Ive(e,t=[]){return new l9(e,t)}function Ave(e,t=[]){return new u9(e,t)}var d9=class{values=[];waiters=[];failed=!1;failure;enqueue(t){if(this.failed)return;let r=this.waiters.shift();r?r.resolve(t):this.values.push({kind:"value",value:t})}reject(t){if(!this.failed){if(this.waiters.length>0){for(let r of this.waiters.splice(0))r.reject(t);return}this.values.push({kind:"error",error:t})}}clearErrors(){this.values=this.values.filter(t=>t.kind==="value")}fail(t){if(!this.failed){this.failed=!0,this.failure=t;for(let r of this.waiters.splice(0))r.reject(t)}}next(){if(this.values.length>0){let t=this.values.shift();return t.kind==="error"?Promise.reject(t.error):Promise.resolve(t.value)}return this.failed?Promise.reject(this.failure):new Promise((t,r)=>{this.waiters.push({resolve:t,reject:r})})}};function vve(e){return{...e,additionalDirectories:e.additionalDirectories?[...e.additionalDirectories]:void 0,mcpServers:[...e.mcpServers]}}var wD=class e{cx;request;constructor(t,r){this.cx=t,this.request=vve(r)}static create(t,r){return new e(t,r)}toRequest(){return vve(this.request)}withAdditionalDirectories(t){return this.request={...this.request,additionalDirectories:[...t]},this}withMcpServer(t){return this.request={...this.request,mcpServers:[...this.request.mcpServers,t]},this}async start(t){return this.cx[Pve](this.toRequest(),t)}async withSession(t){let r=await this.start();try{return await t(r)}finally{r.dispose()}}},p9=class e{cx;sessionResponse;updates;registrations;constructor(t,r,n,o){this.cx=t,this.sessionResponse=r,this.updates=n,this.registrations=o}static create(t,r,n,o){return new e(t,r,n,o)}get sessionId(){return this.sessionResponse.sessionId}get modes(){return this.sessionResponse.modes}get meta(){return this.sessionResponse._meta}get newSessionResponse(){return this.sessionResponse}prompt(t,r){this.updates.clearErrors();let n=this.cx.request(Me.session_prompt,{sessionId:this.sessionId,prompt:this.promptBlocks(t)},r);return n.then(o=>{this.updates.enqueue({kind:"stop",response:o,stopReason:o.stopReason})},o=>{this.updates.reject(o)}),n}nextUpdate(){return this.updates.next()}async readText(){let t="";for(;;){let r=await this.nextUpdate();if(r.kind==="stop")return t;let{update:n}=r;n.sessionUpdate==="agent_message_chunk"&&n.content.type==="text"&&(t+=n.content.text)}}dispose(){for(let t of this.registrations.splice(0))t.dispose();this.updates.fail(new Error("Active session disposed"))}[Symbol.dispose](){this.dispose()}promptBlocks(t){return typeof t=="string"?[{type:"text",text:t}]:Array.isArray(t)?t:[t]}};function Ove(e,t){return e?typeof e=="function"?e(t):e.parse(t):t}function en(e,t,r){return{method:e,params:t,mapResponse:r}}function Ju(e,t){return{method:e,params:t}}function $ve(e,t,r,n){e.onReceiveRequest(t.method,o=>Ove(t.params,o),async(o,i,s)=>{let a=await n(r(o,s,i.signal,i.id));await i.respond(t.mapResponse?t.mapResponse(a):a)})}function Mve(e,t,r,n){e.onReceiveNotification(t.method,o=>Ove(t.params,o),(o,i)=>n(r(o,i,i.signal)))}function RD(e){let t={};for(let r of Object.values(e))t[r.method]=r;return t}var hyt={initialize:en(Me.initialize,hD),newSession:en(Me.session_new,MZ),loadSession:en(Me.session_load,DZ,Dc),unstable_forkSession:en(Me.session_fork,LZ),listSessions:en(Me.session_list,NZ),deleteSession:en(Me.session_delete,zZ,Dc),resumeSession:en(Me.session_resume,FZ),closeSession:en(Me.session_close,jZ,Dc),setSessionMode:en(Me.session_set_mode,UZ,Dc),setSessionConfigOption:en(Me.session_set_config_option,HZ),authenticate:en(Me.authenticate,PZ,Dc),unstable_listProviders:en(Me.providers_list,IZ),unstable_setProvider:en(Me.providers_set,AZ,Dc),unstable_disableProvider:en(Me.providers_disable,OZ,Dc),logout:en(Me.logout,$Z,Dc),prompt:en(Me.session_prompt,qZ),unstable_startNes:en(Me.nes_start,GZ),unstable_suggestNes:en(Me.nes_suggest,BZ),unstable_closeNes:en(Me.nes_close,WZ,Dc)},gyt={cancel:Ju(Me.session_cancel,KZ),unstable_didOpenDocument:Ju(Me.document_did_open,ZZ),unstable_didChangeDocument:Ju(Me.document_did_change,JZ),unstable_didCloseDocument:Ju(Me.document_did_close,YZ),unstable_didSaveDocument:Ju(Me.document_did_save,QZ),unstable_didFocusDocument:Ju(Me.document_did_focus,XZ),unstable_acceptNes:Ju(Me.nes_accept,e9),unstable_rejectNes:Ju(Me.nes_reject,t9)},yyt={requestPermission:en(ir.session_request_permission,uZ),writeTextFile:en(ir.fs_write_text_file,sZ,Dc),readTextFile:en(ir.fs_read_text_file,aZ),createTerminal:en(ir.terminal_create,dZ),terminalOutput:en(ir.terminal_output,pZ),releaseTerminal:en(ir.terminal_release,fZ,Dc),waitForTerminalExit:en(ir.terminal_wait_for_exit,mZ),killTerminal:en(ir.terminal_kill,hZ,Dc),unstable_createElicitation:en(ir.elicitation_create,vZ)},byt={sessionUpdate:Ju(ir.session_update,mD),unstable_completeElicitation:Ju(ir.elicitation_complete,CZ)},Dve=RD(hyt),xyt=RD(gyt),Nve=RD(yyt),Syt=RD(byt);function kyt(e,t,r,n){return{params:e,requestId:n,signal:r,client:t}}function _yt(e,t,r){return{params:e,signal:r,client:t}}function wyt(e,t,r,n){return{params:e,requestId:n,signal:r,agent:t}}function vyt(e,t,r){return{params:e,signal:r,agent:t}}var f9=class{activeSessions=new Map;handleMessage(t){if(t.kind!=="notification"||t.method!==ir.session_update)return Mc.no(t);let r=mD.parse(t.params),n={kind:"session_update",notification:r,update:r.update},o=this.activeSessions.get(r.sessionId);if(o&&o.size>0)for(let i of o)i.enqueue(n);return Mc.no(t)}attach(t,r){let n=this.activeSessions.get(t.sessionId)??new Set;return n.add(r),this.activeSessions.set(t.sessionId,n),new Ap(()=>{n.delete(r),n.size===0&&this.activeSessions.delete(t.sessionId)})}},Eve=new WeakMap;function zve(e){let t=Eve.get(e);return t||(t=new f9,Eve.set(e,t)),t}function TD(e,t){for(let r of t){let n;try{n=r(e)}catch(o){throw e.close(o),o}Promise.resolve(n).catch(o=>{e.close(o)})}}var vD=Symbol("appBuilder"),xD=Symbol("runAgentConnectHandlers"),SD=Symbol("runClientConnectHandlers"),ED={allowBatches:!1};var Rve=class{builder=Op.builder();connectHandlers=[];constructor(t={}){t.name&&this.builder.name(t.name)}[vD](){return this.builder}[xD](t){TD(t,this.connectHandlers)}connect(t,r={}){return this.connectConnection(t,r).connection}connectWith(t,r){let{rawConnection:n,connection:o}=this.connectConnection(t);return n.runUntil(()=>r(o.client))}onConnect(t){return this.connectHandlers.push(t),this}onRequest(t,r,n){if(n)return this.request({method:t,params:r},n);let o=Dve[t];if(!o)throw new Error(`Unknown ACP request method '${t}'. Pass a params parser for custom methods.`);return this.request(o,r)}onNotification(t,r,n){if(n)return this.notification({method:t,params:r},n);let o=xyt[t];if(!o)throw new Error(`Unknown ACP notification method '${t}'. Pass a params parser for custom methods.`);return this.notification(o,r)}request(t,r){return $ve(this.builder,t,(n,o,i,s)=>kyt(n,pR.create(o,s),i,s),r),this}notification(t,r){return Mve(this.builder,t,(n,o,i)=>_yt(n,pR.create(o),i),r),this}connectConnection(t,r={}){if(Tve(t)){let c=this.openStreamConnection(t);return r.deferConnectHandlers||this[xD](c.connection),c}let[n,o]=Cve(),i=t[vD]().connect(o,ED),s=Ave(i),a=this.openStreamConnection(n);a.rawConnection.closed.then(()=>s.close()),i.closed.then(()=>a.connection.close());try{t[SD](s),this[xD](a.connection)}catch(c){throw s.close(c),a.connection.close(c),c}return a}openStreamConnection(t){let r=this.builder.connect(t,ED);return{rawConnection:r,connection:Ive(r,this.connectHandlers)}}};function Lve(e){return new m9(e)}var m9=class{builder=Op.builder();connectHandlers=[];constructor(t={}){t.name&&this.builder.name(t.name),this.builder.withHandler({handleMessage:(r,n)=>zve(n).handleMessage(r),describe:()=>"client-session-update-router"})}[vD](){return this.builder}[SD](t){TD(t,this.connectHandlers)}connect(t){return this.connectConnection(t).connection}connectWith(t,r){let{rawConnection:n,connection:o}=this.connectConnection(t);return n.runUntil(()=>r(o.agent))}onConnect(t){return this.connectHandlers.push(t),this}onRequest(t,r,n){if(n)return this.request({method:t,params:r},n);let o=Nve[t];if(!o)throw new Error(`Unknown ACP request method '${t}'. Pass a params parser for custom methods.`);return this.request(o,r)}onNotification(t,r,n){if(n)return this.notification({method:t,params:r},n);let o=Syt[t];if(!o)throw new Error(`Unknown ACP notification method '${t}'. Pass a params parser for custom methods.`);return this.notification(o,r)}request(t,r){return $ve(this.builder,t,(n,o,i,s)=>wyt(n,fR.create(o,s),i,s),r),this}notification(t,r){return Mve(this.builder,t,(n,o,i)=>vyt(n,fR.create(o),i),r),this}connectConnection(t){if(Tve(t)){let a=this.openStreamConnection(t);return this[SD](a.connection),a}let[r,n]=Cve(),o=t[vD]().connect(n,ED),i=Ive(o),s=this.openStreamConnection(r);s.rawConnection.closed.then(()=>i.close()),o.closed.then(()=>s.connection.close());try{t[xD](i),this[SD](s.connection)}catch(a){throw i.close(a),s.connection.close(a),a}return s}openStreamConnection(t){let r=this.builder.connect(t,ED);return{rawConnection:r,connection:Ave(r,this.connectHandlers)}}},cpr=new Set([Me.initialize,Me.authenticate,Me.providers_list,Me.providers_set,Me.providers_disable,Me.session_new,Me.session_load,Me.session_set_mode,Me.session_set_config_option,Me.session_prompt,Me.session_list,Me.session_delete,Me.session_fork,Me.session_resume,Me.session_close,Me.logout,Me.nes_start,Me.nes_suggest,Me.nes_close]),lpr=new Set([Me.session_cancel,Me.nes_accept,Me.nes_reject,Me.document_did_open,Me.document_did_change,Me.document_did_close,Me.document_did_save,Me.document_did_focus]),upr=new Set([ir.session_request_permission,ir.fs_write_text_file,ir.fs_read_text_file,ir.terminal_create,ir.terminal_output,ir.terminal_release,ir.terminal_wait_for_exit,ir.terminal_kill,ir.elicitation_create]),dpr=new Set([ir.session_update,ir.elicitation_complete]);$8();E8();var ct={initialize:"initialize",auth_login:"auth/login",providers_list:"providers/list",providers_set:"providers/set",providers_disable:"providers/disable",session_new:"session/new",session_set_config_option:"session/set_config_option",session_prompt:"session/prompt",session_cancel:"session/cancel",mcp_message:"mcp/message",session_list:"session/list",session_delete:"session/delete",session_fork:"session/fork",session_resume:"session/resume",session_close:"session/close",auth_logout:"auth/logout",nes_start:"nes/start",nes_suggest:"nes/suggest",nes_accept:"nes/accept",nes_reject:"nes/reject",nes_close:"nes/close",document_did_open:"document/didOpen",document_did_change:"document/didChange",document_did_close:"document/didClose",document_did_save:"document/didSave",document_did_focus:"document/didFocus"},vi={session_request_permission:"session/request_permission",session_update:"session/update",mcp_connect:"mcp/connect",mcp_message:"mcp/message",mcp_disconnect:"mcp/disconnect",elicitation_create:"elicitation/create",elicitation_complete:"elicitation/complete"},N1={cancel_request:"$/cancel_request"},Fp=2;var ah=be([rt(),g()]).nullable(),dn=g(),z1=g(),rwt=be([O("read"),O("edit"),O("delete"),O("move"),O("search"),O("execute"),O("think"),O("fetch"),O("switch_mode"),O("other"),g()]),nwt=be([O("pending"),O("in_progress"),O("completed"),O("failed"),O("cancelled"),g()]),owt=be([O("assistant"),O("user"),g()]),BR=x({audience:y(Ve(owt).nullish(),()=>{}),lastModified:y(Ku.datetime({offset:!0}).nullish(),()=>{}),priority:y(rt().gte(0).lte(1).nullish(),()=>{}),_meta:y(C(g(),T()).nullish(),()=>{})}),M8=x({text:g(),annotations:y(BR.nullish(),()=>{}),_meta:y(C(g(),T()).nullish(),()=>{})}),ab=g(),D8=x({data:g(),mimeType:ab,uri:y(_r().nullish(),()=>{}),annotations:y(BR.nullish(),()=>{}),_meta:y(C(g(),T()).nullish(),()=>{})}),N8=x({data:g(),mimeType:ab,annotations:y(BR.nullish(),()=>{}),_meta:y(C(g(),T()).nullish(),()=>{})}),iwt=be([O("light"),O("dark"),g()]),swt=x({src:_r(),mimeType:y(ab.nullish(),()=>{}),sizes:y(Ve(g()).nullish(),()=>{}),theme:y(iwt.nullish(),()=>{})}),z8=x({name:g(),uri:_r(),title:y(g().nullish(),()=>{}),description:y(g().nullish(),()=>{}),icons:y(Ve(swt).nullish(),()=>{}),mimeType:y(ab.nullish(),()=>{}),size:y(rt().nullish(),()=>{}),annotations:y(BR.nullish(),()=>{}),_meta:y(C(g(),T()).nullish(),()=>{})}),awt=x({text:g(),uri:_r(),mimeType:y(ab.nullish(),()=>{}),_meta:y(C(g(),T()).nullish(),()=>{})}),cwt=x({blob:g(),uri:_r(),mimeType:y(ab.nullish(),()=>{}),_meta:y(C(g(),T()).nullish(),()=>{})}),lwt=be([awt,cwt]),L8=x({resource:lwt,annotations:y(BR.nullish(),()=>{}),_meta:y(C(g(),T()).nullish(),()=>{})}),g_=Mn(be([M8.and(x({type:O("text")})),D8.and(x({type:O("image")})),N8.and(x({type:O("audio")})),z8.and(x({type:O("resource_link")})),L8.and(x({type:O("resource")})),$n(x({type:g()}),"type",["audio","image","resource","resource_link","text"])]),"type",["audio","image","resource","resource_link","text"]),F8=x({content:g_,_meta:y(C(g(),T()).nullish(),()=>{})}),uwt=be([O("text"),O("binary"),O("directory"),O("symlink"),g()]),ss=g(),ib=x({path:ss}),GR=x({oldPath:ss,path:ss}),dwt=Mn(Ho(be([ib.and(x({operation:O("add")})),ib.and(x({operation:O("delete")})),ib.and(x({operation:O("modify")})),GR.and(x({operation:O("move")})),GR.and(x({operation:O("copy")})),$n(x({operation:g()}),"operation",["add","copy","delete","modify","move"])]),x({fileType:y(uwt.nullish(),()=>{}),mimeType:y(ab.nullish(),()=>{}),_meta:y(C(g(),T()).nullish(),()=>{})})),"operation",["add","copy","delete","modify","move"]),pwt=be([O("git_patch"),g()]),fwt=x({format:pwt,text:g()}),j8=x({changes:Ve(dwt),patch:y(fwt.nullish(),()=>{}),_meta:y(C(g(),T()).nullish(),()=>{})}),L1=g(),U8=x({terminalId:L1,_meta:y(C(g(),T()).nullish(),()=>{})}),ECe=Mn(be([F8.and(x({type:O("content")})),j8.and(x({type:O("diff")})),U8.and(x({type:O("terminal")})),$n(x({type:g()}),"type",["content","diff","terminal"])]),"type",["content","diff","terminal"]),mwt=x({path:ss,line:y(fr().gte(0).max(4294967295,{error:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),()=>{}),_meta:y(C(g(),T()).nullish(),()=>{})}),F1=x({toolCallId:z1,name:y(g().nullish(),()=>{}),title:y(g().nullish(),()=>{}),kind:y(rwt.nullish(),()=>{}),status:y(nwt.nullish(),()=>{}),content:y(Ve(ECe).nullish(),()=>{}),locations:y(Ve(mwt).nullish(),()=>{}),rawInput:y(T().optional(),()=>{}),rawOutput:y(T().optional(),()=>{}),_meta:y(C(g(),T()).nullish(),()=>{})}),H8=x({toolCall:F1}),q8=x({command:g(),cwd:ss,toolCallId:y(z1.nullish(),()=>{}),terminalId:y(L1.nullish(),()=>{}),_meta:y(C(g(),T()).nullish(),()=>{})}),hwt=Mn(be([H8.and(x({type:O("tool_call")})),q8.and(x({type:O("command")})),$n(x({type:g()}),"type",["command","tool_call"])]),"type",["command","tool_call"]),RCe=g(),gwt=be([O("allow_once"),O("allow_always"),O("reject_once"),O("reject_always"),g()]),ywt=x({optionId:RCe,name:g(),kind:gwt,_meta:y(C(g(),T()).nullish(),()=>{})}),G8=x({sessionId:dn,title:g(),description:y(g().nullish(),()=>{}),subject:hwt.nullish(),options:gt(ywt).min(1),_meta:y(C(g(),T()).nullish(),()=>{})}),WR=x({sessionId:dn,toolCallId:y(z1.nullish(),()=>{})}),VR=x({requestId:ah}),bwt=O("object"),xwt=be([O("email"),O("uri"),O("date"),O("date-time"),g()]),TCe=x({const:g(),title:g(),description:y(g().nullish(),()=>{}),_meta:y(C(g(),T()).nullish(),()=>{})}),B8=x({title:y(g().nullish(),()=>{}),description:y(g().nullish(),()=>{}),minLength:fr().gte(0).max(4294967295,{error:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),maxLength:fr().gte(0).max(4294967295,{error:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),pattern:g().nullish(),format:xwt.nullish(),default:y(g().nullish(),()=>{}),enum:gt(g()).min(1).nullish(),oneOf:gt(TCe).min(1).nullish(),_meta:y(C(g(),T()).nullish(),()=>{})}),W8=x({title:y(g().nullish(),()=>{}),description:y(g().nullish(),()=>{}),minimum:rt().nullish(),maximum:rt().nullish(),default:y(rt().nullish(),()=>{}),_meta:y(C(g(),T()).nullish(),()=>{})}),V8=x({title:y(g().nullish(),()=>{}),description:y(g().nullish(),()=>{}),minimum:rt().nullish(),maximum:rt().nullish(),default:y(rt().nullish(),()=>{}),_meta:y(C(g(),T()).nullish(),()=>{})}),K8=x({title:y(g().nullish(),()=>{}),description:y(g().nullish(),()=>{}),default:y(mr().nullish(),()=>{}),_meta:y(C(g(),T()).nullish(),()=>{})}),Z8=x({enum:gt(g()).min(1),_meta:y(C(g(),T()).nullish(),()=>{})}),CCe=x({anyOf:gt(TCe).min(1),_meta:y(C(g(),T()).nullish(),()=>{})}),Swt=Mn(be([Z8.and(x({type:O("string")})),$n(x({type:g()}),"type",["string"]),CCe]),"type",["string"]),J8=x({title:y(g().nullish(),()=>{}),description:y(g().nullish(),()=>{}),minItems:rt().nullish(),maxItems:rt().nullish(),items:Swt,default:y(Ve(g()).nullish(),()=>{}),_meta:y(C(g(),T()).nullish(),()=>{})}),kwt=Mn(be([B8.and(x({type:O("string")})),W8.and(x({type:O("number")})),V8.and(x({type:O("integer")})),K8.and(x({type:O("boolean")})),J8.and(x({type:O("array")})),$n(x({type:g()}),"type",["array","boolean","integer","number","string"])]),"type",["array","boolean","integer","number","string"]),_wt=x({type:y(bwt.optional().default("object"),()=>"object"),title:y(g().nullish(),()=>{}),properties:C(g(),kwt).optional().default({}),required:gt(g()).nullish(),description:y(g().nullish(),()=>{}),_meta:y(C(g(),T()).nullish(),()=>{})}),Y8=Ho(be([WR,VR]),x({requestedSchema:_wt})),PCe=g(),Q8=Ho(be([WR,VR]),x({elicitationId:PCe,url:_r()})),X8=Mn(Ho(be([Y8.and(x({mode:O("form")})),Q8.and(x({mode:O("url")})),$n(Ho(be([WR,VR]),x({mode:g()})),"mode",["form","url"])]),x({message:g(),_meta:y(C(g(),T()).nullish(),()=>{})})),"mode",["form","url"]),ICe=g(),e5=x({serverId:ICe,_meta:y(C(g(),T()).nullish(),()=>{})}),j1=g(),KR=x({connectionId:j1,method:g(),params:C(g(),T()).nullish(),_meta:y(C(g(),T()).nullish(),()=>{})}),t5=x({connectionId:j1,_meta:y(C(g(),T()).nullish(),()=>{})}),ACe=T(),v_r=x({id:ah,method:g(),params:be([G8,X8,e5,KR,t5,ACe]).nullish()}),OCe=fr().gte(0).lte(65535),$Ce=x({name:g(),title:y(g().nullish(),()=>{}),version:g(),_meta:y(C(g(),T()).nullish(),()=>{})}),wwt=x({_meta:y(C(g(),T()).nullish(),()=>{})}),vwt=x({_meta:y(C(g(),T()).nullish(),()=>{})}),Ewt=x({_meta:y(C(g(),T()).nullish(),()=>{})}),Rwt=x({image:y(wwt.nullish(),()=>{}),audio:y(vwt.nullish(),()=>{}),embeddedContext:y(Ewt.nullish(),()=>{}),_meta:y(C(g(),T()).nullish(),()=>{})}),Twt=x({_meta:y(C(g(),T()).nullish(),()=>{})}),Cwt=x({_meta:y(C(g(),T()).nullish(),()=>{})}),Pwt=x({_meta:y(C(g(),T()).nullish(),()=>{})}),Iwt=x({stdio:y(Twt.nullish(),()=>{}),http:y(Cwt.nullish(),()=>{}),acp:y(Pwt.nullish(),()=>{}),_meta:y(C(g(),T()).nullish(),()=>{})}),Awt=x({_meta:y(C(g(),T()).nullish(),()=>{})}),Owt=x({_meta:y(C(g(),T()).nullish(),()=>{})}),$wt=x({_meta:y(C(g(),T()).nullish(),()=>{})}),Mwt=x({prompt:y(Rwt.nullish(),()=>{}),mcp:y(Iwt.nullish(),()=>{}),delete:y(Awt.nullish(),()=>{}),additionalDirectories:y(Owt.nullish(),()=>{}),fork:y($wt.nullish(),()=>{}),_meta:y(C(g(),T()).nullish(),()=>{})}),Dwt=x({_meta:y(C(g(),T()).nullish(),()=>{})}),Nwt=x({_meta:y(C(g(),T()).nullish(),()=>{})}),zwt=x({_meta:y(C(g(),T()).nullish(),()=>{})}),Lwt=be([O("full"),O("incremental")]),Fwt=x({syncKind:Lwt,_meta:y(C(g(),T()).nullish(),()=>{})}),jwt=x({_meta:y(C(g(),T()).nullish(),()=>{})}),Uwt=x({_meta:y(C(g(),T()).nullish(),()=>{})}),Hwt=x({_meta:y(C(g(),T()).nullish(),()=>{})}),qwt=x({didOpen:y(zwt.nullish(),()=>{}),didChange:y(Fwt.nullish(),()=>{}),didClose:y(jwt.nullish(),()=>{}),didSave:y(Uwt.nullish(),()=>{}),didFocus:y(Hwt.nullish(),()=>{}),_meta:y(C(g(),T()).nullish(),()=>{})}),Gwt=x({document:y(qwt.nullish(),()=>{}),_meta:y(C(g(),T()).nullish(),()=>{})}),Bwt=x({maxCount:y(fr().gte(0).max(4294967295,{error:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),()=>{}),_meta:y(C(g(),T()).nullish(),()=>{})}),Wwt=x({_meta:y(C(g(),T()).nullish(),()=>{})}),Vwt=x({maxCount:y(fr().gte(0).max(4294967295,{error:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),()=>{}),_meta:y(C(g(),T()).nullish(),()=>{})}),Kwt=x({maxCount:y(fr().gte(0).max(4294967295,{error:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),()=>{}),_meta:y(C(g(),T()).nullish(),()=>{})}),Zwt=x({_meta:y(C(g(),T()).nullish(),()=>{})}),Jwt=x({_meta:y(C(g(),T()).nullish(),()=>{})}),Ywt=x({recentFiles:y(Bwt.nullish(),()=>{}),relatedSnippets:y(Wwt.nullish(),()=>{}),editHistory:y(Vwt.nullish(),()=>{}),userActions:y(Kwt.nullish(),()=>{}),openFiles:y(Zwt.nullish(),()=>{}),diagnostics:y(Jwt.nullish(),()=>{}),_meta:y(C(g(),T()).nullish(),()=>{})}),Qwt=x({events:y(Gwt.nullish(),()=>{}),context:y(Ywt.nullish(),()=>{}),_meta:y(C(g(),T()).nullish(),()=>{})}),MCe=be([O("utf-16"),O("utf-32"),O("utf-8")]),Xwt=x({session:y(Mwt.nullish(),()=>{}),auth:y(Dwt.nullish(),()=>{}),providers:y(Nwt.nullish(),()=>{}),nes:y(Qwt.nullish(),()=>{}),positionEncoding:y(MCe.nullish(),()=>{}),_meta:y(C(g(),T()).nullish(),()=>{})}),cb=g(),evt=x({name:g(),label:y(g().nullish(),()=>{}),secret:y(mr().optional().default(!0),()=>!0),optional:y(mr().optional().default(!1),()=>!1),_meta:y(C(g(),T()).nullish(),()=>{})}),r5=x({methodId:cb,name:g(),description:y(g().nullish(),()=>{}),vars:Kn(Ve(evt),()=>[]),link:y(_r().nullish(),()=>{}),_meta:y(C(g(),T()).nullish(),()=>{})}),DCe=x({name:g(),value:g(),_meta:y(C(g(),T()).nullish(),()=>{})}),n5=x({methodId:cb,name:g(),description:y(g().nullish(),()=>{}),args:y(Ve(g()).optional(),()=>[]),env:y(Ve(DCe).optional(),()=>[]),_meta:y(C(g(),T()).nullish(),()=>{})}),o5=x({methodId:cb,name:g(),description:y(g().nullish(),()=>{}),_meta:y(C(g(),T()).nullish(),()=>{})}),tvt=Mn(be([r5.and(x({type:O("env_var")})),n5.and(x({type:O("terminal")})),o5.and(x({type:O("agent")})),$n(x({type:g(),methodId:cb,name:g(),description:y(g().nullish(),()=>{}),_meta:y(C(g(),T()).nullish(),()=>{})}),"type",["agent","env_var","terminal"])]),"type",["agent","env_var","terminal"]),i5=x({protocolVersion:OCe,info:$Ce,capabilities:y(Xwt.optional().default({}),()=>({})),authMethods:y(Ve(tvt).optional(),()=>[]),_meta:y(C(g(),T()).nullish(),()=>{})}),rvt=x({_meta:y(C(g(),T()).nullish(),()=>{})}),s5=g(),a5=be([O("anthropic"),O("openai"),O("azure"),O("vertex"),O("bedrock"),g()]),nvt=x({apiType:a5,baseUrl:_r(),_meta:y(C(g(),T()).nullish(),()=>{})}),ovt=x({providerId:s5,supported:Kn(Ve(a5),()=>[]),required:mr(),current:nvt.nullish(),_meta:y(C(g(),T()).nullish(),()=>{})}),ivt=x({providers:gt(ovt),_meta:y(C(g(),T()).nullish(),()=>{})}),svt=x({_meta:y(C(g(),T()).nullish(),()=>{})}),avt=x({_meta:y(C(g(),T()).nullish(),()=>{})}),cvt=x({_meta:y(C(g(),T()).nullish(),()=>{})}),jp=g(),lvt=be([O("mode"),O("model"),O("model_config"),O("thought_level"),g()]),ZR=g(),NCe=x({value:ZR,name:g(),description:y(g().nullish(),()=>{}),_meta:y(C(g(),T()).nullish(),()=>{})}),uvt=g(),dvt=x({groupId:uvt,name:g(),options:Kn(Ve(NCe),()=>[]),_meta:y(C(g(),T()).nullish(),()=>{})}),pvt=be([gt(NCe),gt(dvt)]),c5=x({currentValue:ZR,options:pvt}),l5=x({currentValue:mr()}),JR=Mn(Ho(be([c5.and(x({type:O("select")})),l5.and(x({type:O("boolean")})),$n(x({type:g()}),"type",["boolean","select"])]),x({configId:jp,name:g(),description:y(g().nullish(),()=>{}),category:y(lvt.nullish(),()=>{}),_meta:y(C(g(),T()).nullish(),()=>{})})),"type",["boolean","select"]),fvt=x({sessionId:dn,configOptions:y(Ve(JR).optional(),()=>[]),_meta:y(C(g(),T()).nullish(),()=>{})}),mvt=x({sessionId:dn,cwd:ss,additionalDirectories:y(Ve(ss).optional(),()=>[]),title:y(g().nullish(),()=>{}),updatedAt:y(Ku.datetime({offset:!0}).nullish(),()=>{}),_meta:y(C(g(),T()).nullish(),()=>{})}),zCe=g(),hvt=x({sessions:Kn(Ve(mvt),()=>[]),nextCursor:y(zCe.nullish(),()=>{}),_meta:y(C(g(),T()).nullish(),()=>{})}),gvt=x({_meta:y(C(g(),T()).nullish(),()=>{})}),yvt=x({sessionId:dn,configOptions:y(Ve(JR).optional(),()=>[]),_meta:y(C(g(),T()).nullish(),()=>{})}),bvt=x({configOptions:y(Ve(JR).optional(),()=>[]),_meta:y(C(g(),T()).nullish(),()=>{})}),xvt=x({_meta:y(C(g(),T()).nullish(),()=>{})}),Svt=x({configOptions:Kn(Ve(JR),()=>[]),_meta:y(C(g(),T()).nullish(),()=>{})}),kvt=x({_meta:y(C(g(),T()).nullish(),()=>{})}),_vt=x({sessionId:dn,_meta:y(C(g(),T()).nullish(),()=>{})}),Up=g(),ch=x({line:fr().gte(0).max(4294967295,{error:"Invalid value: Expected uint32 to be <= 4294967295"}),character:fr().gte(0).max(4294967295,{error:"Invalid value: Expected uint32 to be <= 4294967295"}),_meta:y(C(g(),T()).nullish(),()=>{})}),y_=x({start:ch,end:ch,_meta:y(C(g(),T()).nullish(),()=>{})}),wvt=x({range:y_,newText:g(),_meta:y(C(g(),T()).nullish(),()=>{})}),u5=x({suggestionId:Up,uri:_r(),edits:gt(wvt).min(1),cursorPosition:y(ch.nullish(),()=>{}),_meta:y(C(g(),T()).nullish(),()=>{})}),d5=x({suggestionId:Up,uri:_r(),position:ch,_meta:y(C(g(),T()).nullish(),()=>{})}),p5=x({suggestionId:Up,uri:_r(),position:ch,newName:g(),_meta:y(C(g(),T()).nullish(),()=>{})}),f5=x({suggestionId:Up,uri:_r(),search:g(),replace:g(),isRegex:mr().nullish(),_meta:y(C(g(),T()).nullish(),()=>{})}),vvt=Mn(be([u5.and(x({kind:O("edit")})),d5.and(x({kind:O("jump")})),p5.and(x({kind:O("rename")})),f5.and(x({kind:O("searchAndReplace")})),$n(x({kind:g(),suggestionId:Up}),"kind",["edit","jump","rename","searchAndReplace"])]),"kind",["edit","jump","rename","searchAndReplace"]),Evt=x({suggestions:gt(vvt),_meta:y(C(g(),T()).nullish(),()=>{})}),Rvt=x({_meta:y(C(g(),T()).nullish(),()=>{})}),LCe=T(),FCe=T(),Tvt=be([O(-32700),O(-32600),O(-32601),O(-32602),O(-32603),O(-32800),O(-32e3),O(-32002),fr().min(-2147483648,{error:"Invalid value: Expected int32 to be >= -2147483648"}).max(2147483647,{error:"Invalid value: Expected int32 to be <= 2147483647"})]),jCe=x({code:Tvt,message:g(),data:y(T().optional(),()=>{})}),E_r=be([x({id:ah,result:be([i5,rvt,ivt,svt,avt,cvt,fvt,hvt,gvt,yvt,bvt,xvt,Svt,kvt,_vt,Evt,Rvt,LCe,FCe])}),x({id:ah,error:jCe})]),U1=g(),sb=x({messageId:U1,content:g_,_meta:y(C(g(),T()).nullish(),()=>{})}),m5=x({messageId:U1,content:y(Ve(g_).nullish(),()=>{}),_meta:y(C(g(),T()).nullish(),()=>{})}),h5=x({messageId:U1,content:y(Ve(g_).nullish(),()=>{}),_meta:y(C(g(),T()).nullish(),()=>{})}),g5=x({messageId:U1,content:y(Ve(g_).nullish(),()=>{}),_meta:y(C(g(),T()).nullish(),()=>{})}),y5=x({_meta:y(C(g(),T()).nullish(),()=>{})}),Cvt=be([O("end_turn"),O("max_tokens"),O("max_turn_requests"),O("refusal"),O("cancelled"),g()]),Pvt=x({totalTokens:rt(),inputTokens:rt(),outputTokens:rt(),thoughtTokens:y(rt().nullish(),()=>{}),cachedReadTokens:y(rt().nullish(),()=>{}),cachedWriteTokens:y(rt().nullish(),()=>{}),_meta:y(C(g(),T()).nullish(),()=>{})}),b5=x({stopReason:y(Cvt.nullish(),()=>{}),usage:y(Pvt.nullish(),()=>{}),_meta:y(C(g(),T()).nullish(),()=>{})}),x5=x({_meta:y(C(g(),T()).nullish(),()=>{})}),S5=Mn(be([y5.and(x({state:O("running")})),b5.and(x({state:O("idle")})),x5.and(x({state:O("requires_action")})),$n(x({state:g()}),"state",["idle","requires_action","running"])]),"state",["idle","requires_action","running"]),k5=x({toolCallId:z1,content:ECe,_meta:y(C(g(),T()).nullish(),()=>{})}),Ivt=x({data:g(),_meta:y(C(g(),T()).nullish(),()=>{})}),Avt=x({exitCode:y(fr().gte(0).max(4294967295,{error:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),()=>{}),signal:y(g().nullish(),()=>{}),_meta:y(C(g(),T()).nullish(),()=>{})}),_5=x({terminalId:L1,command:y(g().nullish(),()=>{}),cwd:y(ss.nullish(),()=>{}),output:y(Ivt.nullish(),()=>{}),exitStatus:y(Avt.nullish(),()=>{}),_meta:y(C(g(),T()).nullish(),()=>{})}),w5=x({terminalId:L1,data:g(),_meta:y(C(g(),T()).nullish(),()=>{})}),lb=g(),Ovt=be([O("high"),O("medium"),O("low"),g()]),$vt=be([O("pending"),O("in_progress"),O("completed"),O("cancelled"),g()]),Mvt=x({content:g(),priority:Ovt,status:$vt,_meta:y(C(g(),T()).nullish(),()=>{})}),v5=x({planId:lb,entries:Kn(Ve(Mvt),()=>[]),_meta:y(C(g(),T()).nullish(),()=>{})}),E5=x({planId:lb,uri:_r(),_meta:y(C(g(),T()).nullish(),()=>{})}),R5=x({planId:lb,content:g(),_meta:y(C(g(),T()).nullish(),()=>{})}),Dvt=Mn(be([v5.and(x({type:O("items")})),E5.and(x({type:O("file")})),R5.and(x({type:O("markdown")})),$n(x({type:g(),planId:lb}),"type",["file","items","markdown"])]),"type",["file","items","markdown"]),T5=x({plan:Dvt,_meta:y(C(g(),T()).nullish(),()=>{})}),C5=x({planId:lb,_meta:y(C(g(),T()).nullish(),()=>{})}),P5=x({hint:g(),_meta:y(C(g(),T()).nullish(),()=>{})}),Nvt=Mn(be([P5.and(x({type:O("text")})),$n(x({type:g()}),"type",["text"])]),"type",["text"]),zvt=x({name:g(),description:g(),input:y(Nvt.nullish(),()=>{}),_meta:y(C(g(),T()).nullish(),()=>{})}),I5=x({availableCommands:Kn(Ve(zvt),()=>[]),_meta:y(C(g(),T()).nullish(),()=>{})}),A5=x({configOptions:Kn(Ve(JR),()=>[]),_meta:y(C(g(),T()).nullish(),()=>{})}),O5=x({title:y(g().nullish(),()=>{}),updatedAt:y(Ku.datetime({offset:!0}).nullish(),()=>{}),_meta:y(C(g(),T()).nullish(),()=>{})}),Lvt=x({amount:rt(),currency:g().regex(/^[A-Z]{3}$/),_meta:y(C(g(),T()).nullish(),()=>{})}),$5=x({used:rt(),size:rt(),cost:y(Lvt.nullish(),()=>{}),_meta:y(C(g(),T()).nullish(),()=>{})}),Fvt=Mn(be([sb.and(x({sessionUpdate:O("user_message_chunk")})),m5.and(x({sessionUpdate:O("user_message")})),sb.and(x({sessionUpdate:O("agent_message_chunk")})),h5.and(x({sessionUpdate:O("agent_message")})),sb.and(x({sessionUpdate:O("agent_thought_chunk")})),g5.and(x({sessionUpdate:O("agent_thought")})),S5.and(x({sessionUpdate:O("state_update")})),k5.and(x({sessionUpdate:O("tool_call_content_chunk")})),F1.and(x({sessionUpdate:O("tool_call_update")})),_5.and(x({sessionUpdate:O("terminal_update")})),w5.and(x({sessionUpdate:O("terminal_output_chunk")})),T5.and(x({sessionUpdate:O("plan_update")})),C5.and(x({sessionUpdate:O("plan_removed")})),I5.and(x({sessionUpdate:O("available_commands_update")})),A5.and(x({sessionUpdate:O("config_option_update")})),O5.and(x({sessionUpdate:O("session_info_update")})),$5.and(x({sessionUpdate:O("usage_update")})),$n(x({sessionUpdate:g()}),"sessionUpdate",["agent_message","agent_message_chunk","agent_thought","agent_thought_chunk","available_commands_update","config_option_update","plan_removed","plan_update","session_info_update","state_update","terminal_output_chunk","terminal_update","tool_call_content_chunk","tool_call_update","usage_update","user_message","user_message_chunk"])]),"sessionUpdate",["agent_message","agent_message_chunk","agent_thought","agent_thought_chunk","available_commands_update","config_option_update","plan_removed","plan_update","session_info_update","state_update","terminal_output_chunk","terminal_update","tool_call_content_chunk","tool_call_update","usage_update","user_message","user_message_chunk"]),H1=x({sessionId:dn,update:Fvt,_meta:y(C(g(),T()).nullish(),()=>{})}),M5=x({elicitationId:PCe,_meta:y(C(g(),T()).nullish(),()=>{})}),YR=x({connectionId:j1,method:g(),params:y(C(g(),T()).nullish(),()=>{}),_meta:y(C(g(),T()).nullish(),()=>{})}),UCe=T(),R_r=x({method:g(),params:be([H1,M5,YR,UCe]).nullish()}),jvt=x({_meta:y(C(g(),T()).nullish(),()=>{})}),Uvt=x({terminal:y(jvt.nullish(),()=>{}),_meta:y(C(g(),T()).nullish(),()=>{})}),Hvt=x({_meta:y(C(g(),T()).nullish(),()=>{})}),qvt=x({_meta:y(C(g(),T()).nullish(),()=>{})}),Gvt=x({form:y(Hvt.nullish(),()=>{}),url:y(qvt.nullish(),()=>{}),_meta:y(C(g(),T()).nullish(),()=>{})}),Bvt=x({_meta:y(C(g(),T()).nullish(),()=>{})}),Wvt=x({_meta:y(C(g(),T()).nullish(),()=>{})}),Vvt=x({_meta:y(C(g(),T()).nullish(),()=>{})}),Kvt=x({jump:y(Bvt.nullish(),()=>{}),rename:y(Wvt.nullish(),()=>{}),searchAndReplace:y(Vvt.nullish(),()=>{}),_meta:y(C(g(),T()).nullish(),()=>{})}),Zvt=x({auth:y(Uvt.nullish(),()=>{}),elicitation:y(Gvt.nullish(),()=>{}),nes:y(Kvt.nullish(),()=>{}),positionEncodings:y(Ve(MCe).optional(),()=>[]),_meta:y(C(g(),T()).nullish(),()=>{})}),q1=x({protocolVersion:OCe,info:$Ce,capabilities:y(Zvt.optional().default({}),()=>({})),_meta:y(C(g(),T()).nullish(),()=>{})}),D5=x({methodId:cb,_meta:y(C(g(),T()).nullish(),()=>{})}),N5=x({_meta:y(C(g(),T()).nullish(),()=>{})}),z5=x({providerId:s5,apiType:a5,baseUrl:_r(),headers:C(g(),g()).optional(),_meta:y(C(g(),T()).nullish(),()=>{})}),L5=x({providerId:s5,_meta:y(C(g(),T()).nullish(),()=>{})}),F5=x({_meta:y(C(g(),T()).nullish(),()=>{})}),Jvt=x({name:g(),value:g(),_meta:y(C(g(),T()).nullish(),()=>{})}),j5=x({name:g(),url:_r(),headers:gt(Jvt).optional(),_meta:y(C(g(),T()).nullish(),()=>{})}),U5=x({name:g(),serverId:ICe,_meta:y(C(g(),T()).nullish(),()=>{})}),H5=x({name:g(),command:ss,args:gt(g()).optional(),env:gt(DCe).optional(),_meta:y(C(g(),T()).nullish(),()=>{})}),q5=Mn(be([j5.and(x({type:O("http")})),U5.and(x({type:O("acp")})),H5.and(x({type:O("stdio")})),$n(x({type:g()}),"type",["acp","http","stdio"])]),"type",["acp","http","stdio"]),G5=x({cwd:ss,additionalDirectories:y(Ve(ss).optional(),()=>[]),mcpServers:y(Ve(q5).optional(),()=>[]),_meta:y(C(g(),T()).nullish(),()=>{})}),B5=x({cwd:ss.nullish(),cursor:zCe.nullish(),_meta:y(C(g(),T()).nullish(),()=>{})}),W5=x({sessionId:dn,_meta:y(C(g(),T()).nullish(),()=>{})}),V5=x({sessionId:dn,cwd:ss,additionalDirectories:y(Ve(ss).optional(),()=>[]),mcpServers:y(Ve(q5).optional(),()=>[]),_meta:y(C(g(),T()).nullish(),()=>{})}),K5=x({_meta:y(C(g(),T()).nullish(),()=>{})}),Yvt=Mn(be([K5.and(x({type:O("start")})),$n(x({type:g(),_meta:y(C(g(),T()).nullish(),()=>{})}),"type",["start"])]),"type",["start"]),Z5=x({sessionId:dn,cwd:ss,additionalDirectories:y(Ve(ss).optional(),()=>[]),mcpServers:y(Ve(q5).optional(),()=>[]),replayFrom:y(Yvt.nullish(),()=>{}),_meta:y(C(g(),T()).nullish(),()=>{})}),J5=x({sessionId:dn,_meta:y(C(g(),T()).nullish(),()=>{})}),Y5=Mn(Ho(be([x({value:ZR,type:O("id")}),x({value:mr(),type:O("boolean")}),$n(x({type:g(),value:T()}),"type",["boolean","id"])]),x({sessionId:dn,configId:jp,_meta:y(C(g(),T()).nullish(),()=>{})})),"type",["boolean","id"]),Q5=x({sessionId:dn,prompt:gt(g_),_meta:y(C(g(),T()).nullish(),()=>{})}),Qvt=x({uri:_r(),name:g(),_meta:y(C(g(),T()).nullish(),()=>{})}),Xvt=x({name:g(),owner:g(),remoteUrl:g(),_meta:y(C(g(),T()).nullish(),()=>{})}),X5=x({workspaceUri:y(_r().nullish(),()=>{}),workspaceFolders:gt(Qvt).nullish(),repository:y(Xvt.nullish(),()=>{}),_meta:y(C(g(),T()).nullish(),()=>{})}),eEt=be([O("automatic"),O("diagnostic"),O("manual"),g()]),tEt=x({uri:_r(),languageId:g(),text:g(),_meta:y(C(g(),T()).nullish(),()=>{})}),rEt=x({startLine:fr().gte(0).max(4294967295,{error:"Invalid value: Expected uint32 to be <= 4294967295"}),endLine:fr().gte(0).max(4294967295,{error:"Invalid value: Expected uint32 to be <= 4294967295"}),text:g(),_meta:y(C(g(),T()).nullish(),()=>{})}),nEt=x({uri:_r(),excerpts:gt(rEt),_meta:y(C(g(),T()).nullish(),()=>{})}),oEt=x({uri:_r(),diff:g(),_meta:y(C(g(),T()).nullish(),()=>{})}),iEt=x({action:g(),uri:_r(),position:ch,timestampMs:rt(),_meta:y(C(g(),T()).nullish(),()=>{})}),sEt=x({uri:_r(),languageId:g(),visibleRange:y(y_.nullish(),()=>{}),lastFocusedMs:y(rt().nullish(),()=>{}),_meta:y(C(g(),T()).nullish(),()=>{})}),aEt=be([O("error"),O("warning"),O("information"),O("hint"),g()]),cEt=x({uri:_r(),range:y_,severity:aEt,message:g(),_meta:y(C(g(),T()).nullish(),()=>{})}),lEt=x({recentFiles:gt(tEt).nullish(),relatedSnippets:gt(nEt).nullish(),editHistory:gt(oEt).nullish(),userActions:gt(iEt).nullish(),openFiles:gt(sEt).nullish(),diagnostics:gt(cEt).nullish(),_meta:y(C(g(),T()).nullish(),()=>{})}),e7=x({sessionId:dn,uri:_r(),version:rt(),position:ch,selection:y_.nullish(),triggerKind:eEt,context:lEt.nullish(),_meta:y(C(g(),T()).nullish(),()=>{})}),t7=x({sessionId:dn,_meta:y(C(g(),T()).nullish(),()=>{})}),T_r=x({id:ah,method:g(),params:be([q1,D5,N5,z5,L5,F5,G5,B5,W5,V5,Z5,J5,Y5,Q5,X5,e7,t7,KR,ACe]).nullish()}),r7=x({optionId:RCe,_meta:y(C(g(),T()).nullish(),()=>{})}),uEt=Mn(be([x({outcome:O("cancelled")}),r7.and(x({outcome:O("selected")})),$n(x({outcome:g()}),"outcome",["cancelled","selected"])]),"outcome",["cancelled","selected"]),dEt=x({outcome:uEt,_meta:y(C(g(),T()).nullish(),()=>{})}),pEt=be([g(),rt(),rt(),mr(),gt(g())]),n7=x({content:C(g(),pEt).nullish()}),fEt=Mn(Ho(be([n7.and(x({action:O("accept")})),x({action:O("decline")}),x({action:O("cancel")}),$n(x({action:g()}),"action",["accept","cancel","decline"])]),x({_meta:y(C(g(),T()).nullish(),()=>{})})),"action",["accept","cancel","decline"]),mEt=x({connectionId:j1,_meta:y(C(g(),T()).nullish(),()=>{})}),hEt=x({_meta:y(C(g(),T()).nullish(),()=>{})}),C_r=be([x({id:ah,result:be([dEt,fEt,mEt,hEt,FCe,LCe])}),x({id:ah,error:jCe})]),o7=x({sessionId:dn,_meta:y(C(g(),T()).nullish(),()=>{})}),i7=x({sessionId:dn,uri:_r(),languageId:g(),version:rt(),text:g(),_meta:y(C(g(),T()).nullish(),()=>{})}),gEt=x({range:y_.nullish(),text:g(),_meta:y(C(g(),T()).nullish(),()=>{})}),s7=x({sessionId:dn,uri:_r(),version:rt(),contentChanges:Kn(Ve(gEt),()=>[]),_meta:y(C(g(),T()).nullish(),()=>{})}),a7=x({sessionId:dn,uri:_r(),_meta:y(C(g(),T()).nullish(),()=>{})}),c7=x({sessionId:dn,uri:_r(),_meta:y(C(g(),T()).nullish(),()=>{})}),l7=x({sessionId:dn,uri:_r(),version:rt(),position:ch,visibleRange:y_,_meta:y(C(g(),T()).nullish(),()=>{})}),u7=x({sessionId:dn,suggestionId:Up,_meta:y(C(g(),T()).nullish(),()=>{})}),yEt=be([O("rejected"),O("ignored"),O("replaced"),O("cancelled"),g()]),d7=x({sessionId:dn,suggestionId:Up,reason:y(yEt.nullish(),()=>{}),_meta:y(C(g(),T()).nullish(),()=>{})}),P_r=x({method:g(),params:be([o7,i7,s7,a7,c7,l7,u7,d7,YR,UCe]).nullish()}),bEt=x({requestId:ah,_meta:y(C(g(),T()).nullish(),()=>{})}),I_r=x({method:g(),params:bEt.nullish()});function rn(e,t){return typeof e=="object"&&e!==null?e[t]:void 0}var A_r=H8.and(x({type:O("tool_call")})),O_r=q8.and(x({type:O("command")})),$_r=F8.and(x({type:O("content")})),M_r=j8.and(x({type:O("diff")})),D_r=U8.and(x({type:O("terminal")})),xEt=M8.and(x({type:O("text")})),SEt=D8.and(x({type:O("image")})),kEt=N8.and(x({type:O("audio")})),_Et=z8.and(x({type:O("resource_link")})),wEt=L8.and(x({type:O("resource")})),N_r=ib.and(x({operation:O("add")})),z_r=ib.and(x({operation:O("delete")})),L_r=ib.and(x({operation:O("modify")})),F_r=GR.and(x({operation:O("move")})),j_r=GR.and(x({operation:O("copy")})),U_r=Y8.and(x({mode:O("form")})).and(x({message:g()})),H_r=Q8.and(x({mode:O("url")})).and(x({message:g()})),q_r=be([WR,VR]).and(x({message:g()})),G_r=B8.and(x({type:O("string")})),B_r=W8.and(x({type:O("number")})),W_r=V8.and(x({type:O("integer")})),V_r=K8.and(x({type:O("boolean")})),K_r=J8.and(x({type:O("array")})),Z_r=Z8.and(x({type:O("string")}));var J_r=r5.and(x({type:O("env_var")})),Y_r=n5.and(x({type:O("terminal")})),Q_r=o5.and(x({type:O("agent")})),X_r=x({methodId:cb,name:g()}),ewr=c5.and(x({type:O("select")})).and(x({configId:jp,name:g()})),twr=l5.and(x({type:O("boolean")})).and(x({configId:jp,name:g()})),rwr=x({configId:jp,name:g()}),nwr=u5.and(x({kind:O("edit")})),owr=d5.and(x({kind:O("jump")})),iwr=p5.and(x({kind:O("rename")})),swr=f5.and(x({kind:O("searchAndReplace")})),awr=x({suggestionId:Up}),vEt=sb.and(x({sessionUpdate:O("user_message_chunk")})),EEt=m5.and(x({sessionUpdate:O("user_message")})),REt=sb.and(x({sessionUpdate:O("agent_message_chunk")})),TEt=h5.and(x({sessionUpdate:O("agent_message")})),CEt=sb.and(x({sessionUpdate:O("agent_thought_chunk")})),PEt=g5.and(x({sessionUpdate:O("agent_thought")})),IEt=S5.and(x({sessionUpdate:O("state_update")})),AEt=k5.and(x({sessionUpdate:O("tool_call_content_chunk")})),OEt=F1.and(x({sessionUpdate:O("tool_call_update")})),$Et=_5.and(x({sessionUpdate:O("terminal_update")})),MEt=w5.and(x({sessionUpdate:O("terminal_output_chunk")})),DEt=T5.and(x({sessionUpdate:O("plan_update")})),NEt=C5.and(x({sessionUpdate:O("plan_removed")})),zEt=I5.and(x({sessionUpdate:O("available_commands_update")})),LEt=A5.and(x({sessionUpdate:O("config_option_update")})),FEt=O5.and(x({sessionUpdate:O("session_info_update")})),jEt=$5.and(x({sessionUpdate:O("usage_update")})),UEt=y5.and(x({state:O("running")})),HEt=b5.and(x({state:O("idle")})),qEt=x5.and(x({state:O("requires_action")})),cwr=v5.and(x({type:O("items")})),lwr=E5.and(x({type:O("file")})),uwr=R5.and(x({type:O("markdown")})),dwr=x({planId:lb}),pwr=P5.and(x({type:O("text")})),fwr=j5.and(x({type:O("http")})),mwr=U5.and(x({type:O("acp")})),hwr=H5.and(x({type:O("stdio")})),gwr=K5.and(x({type:O("start")})),ywr=x({type:O("id")}).and(x({value:ZR})).and(x({sessionId:dn,configId:jp})),bwr=x({type:O("boolean")}).and(x({value:mr()})).and(x({sessionId:dn,configId:jp})),xwr=x({value:T()}).and(x({sessionId:dn,configId:jp})),Swr=x({outcome:O("cancelled")}),kwr=r7.and(x({outcome:O("selected")})),_wr=n7.and(x({action:O("accept")})),wwr=x({action:O("decline")}),vwr=x({action:O("cancel")});var p7={isText(e){return rn(e,"type")==="text"&&xEt.safeParse(e).success},isImage(e){return rn(e,"type")==="image"&&SEt.safeParse(e).success},isAudio(e){return rn(e,"type")==="audio"&&kEt.safeParse(e).success},isResourceLink(e){return rn(e,"type")==="resource_link"&&_Et.safeParse(e).success},isResource(e){return rn(e,"type")==="resource"&&wEt.safeParse(e).success},isCustom(e){let t=rn(e,"type");return typeof t=="string"&&!["audio","image","resource","resource_link","text"].includes(t)}};var QR={isUserMessageChunk(e){return rn(e,"sessionUpdate")==="user_message_chunk"&&vEt.safeParse(e).success},isUserMessage(e){return rn(e,"sessionUpdate")==="user_message"&&EEt.safeParse(e).success},isAgentMessageChunk(e){return rn(e,"sessionUpdate")==="agent_message_chunk"&&REt.safeParse(e).success},isAgentMessage(e){return rn(e,"sessionUpdate")==="agent_message"&&TEt.safeParse(e).success},isAgentThoughtChunk(e){return rn(e,"sessionUpdate")==="agent_thought_chunk"&&CEt.safeParse(e).success},isAgentThought(e){return rn(e,"sessionUpdate")==="agent_thought"&&PEt.safeParse(e).success},isStateUpdate(e){return rn(e,"sessionUpdate")==="state_update"&&IEt.safeParse(e).success},isToolCallContentChunk(e){return rn(e,"sessionUpdate")==="tool_call_content_chunk"&&AEt.safeParse(e).success},isToolCallUpdate(e){return rn(e,"sessionUpdate")==="tool_call_update"&&OEt.safeParse(e).success},isTerminalUpdate(e){return rn(e,"sessionUpdate")==="terminal_update"&&$Et.safeParse(e).success},isTerminalOutputChunk(e){return rn(e,"sessionUpdate")==="terminal_output_chunk"&&MEt.safeParse(e).success},isPlanUpdate(e){return rn(e,"sessionUpdate")==="plan_update"&&DEt.safeParse(e).success},isPlanRemoved(e){return rn(e,"sessionUpdate")==="plan_removed"&&NEt.safeParse(e).success},isAvailableCommandsUpdate(e){return rn(e,"sessionUpdate")==="available_commands_update"&&zEt.safeParse(e).success},isConfigOptionUpdate(e){return rn(e,"sessionUpdate")==="config_option_update"&&LEt.safeParse(e).success},isSessionInfoUpdate(e){return rn(e,"sessionUpdate")==="session_info_update"&&FEt.safeParse(e).success},isUsageUpdate(e){return rn(e,"sessionUpdate")==="usage_update"&&jEt.safeParse(e).success},isCustom(e){let t=rn(e,"sessionUpdate");return typeof t=="string"&&!["agent_message","agent_message_chunk","agent_thought","agent_thought_chunk","available_commands_update","config_option_update","plan_removed","plan_update","session_info_update","state_update","terminal_output_chunk","terminal_update","tool_call_content_chunk","tool_call_update","usage_update","user_message","user_message_chunk"].includes(t)}},f7={isRunning(e){return rn(e,"state")==="running"&&UEt.safeParse(e).success},isIdle(e){return rn(e,"state")==="idle"&&HEt.safeParse(e).success},isRequiresAction(e){return rn(e,"state")==="requires_action"&&qEt.safeParse(e).success},isCustom(e){let t=rn(e,"state");return typeof t=="string"&&!["idle","requires_action","running"].includes(t)}};function Hp(e){return e??{}}function qp(e,t,r,n=!1){if(!(Object.hasOwn(t,e)||n&&e===N1.cancel_request)&&!e.startsWith("_"))throw new TypeError(`Custom ACP v2 ${r} method '${e}' must start with '_'`)}function VCe(e,t,r){for(let n of e)qp(n.method,n.kind==="request"?t:r,n.kind,n.kind==="notification")}function KCe(e){let t=q1.parse(e);if(t.protocolVersion!==Fp)throw Xr.invalidParams({expectedProtocolVersion:Fp,receivedProtocolVersion:t.protocolVersion},`The v2 API only supports protocol version ${Fp}`);return t}function ZCe(e){let t=typeof e=="object"&&e!==null&&!Array.isArray(e)?e:{};return KCe({...t,protocolVersion:Fp})}function JCe(e){let t=i5.parse(e);if(t.protocolVersion!==Fp)throw Xr.invalidRequest({expectedProtocolVersion:Fp,receivedProtocolVersion:t.protocolVersion},`The v2 API only supports protocol version ${Fp}`);return t}function BEt(e){return e.map(t=>{if(t.kind!=="request"||t.method!==ct.initialize)return t;let r=t.mapResponse;return{...t,params:ZCe(t.params),mapResponse:n=>{let o=JCe(n);return r?r(o):o}}})}function YCe(e){return typeof e=="object"&&e!==null&&"readable"in e&&"writable"in e}function QCe(){let e=new TransformStream,t=new TransformStream;return[{readable:t.readable,writable:e.writable},{readable:e.readable,writable:t.writable}]}var Ywr={agent:{initialize:ct.initialize,auth:{login:ct.auth_login,logout:ct.auth_logout},providers:{list:ct.providers_list,set:ct.providers_set,disable:ct.providers_disable},session:{new:ct.session_new,list:ct.session_list,delete:ct.session_delete,fork:ct.session_fork,resume:ct.session_resume,close:ct.session_close,setConfigOption:ct.session_set_config_option,prompt:ct.session_prompt,cancel:ct.session_cancel},mcp:{message:ct.mcp_message},nes:{start:ct.nes_start,suggest:ct.nes_suggest,accept:ct.nes_accept,reject:ct.nes_reject,close:ct.nes_close},document:{didOpen:ct.document_did_open,didChange:ct.document_did_change,didClose:ct.document_did_close,didSave:ct.document_did_save,didFocus:ct.document_did_focus}},client:{session:{requestPermission:vi.session_request_permission,update:vi.session_update},mcp:{connect:vi.mcp_connect,message:vi.mcp_message,disconnect:vi.mcp_disconnect},elicitation:{create:vi.elicitation_create,complete:vi.elicitation_complete}},protocol:{cancelRequest:N1.cancel_request}},XCe=Symbol("startActiveSession"),W1=class{cx;currentRequestId;constructor(t,r){this.cx=t,this.currentRequestId=r}get requestId(){return this.currentRequestId}get connectionContext(){return this.cx}sendRequest(t,r,n,o){return this.cx.sendRequest(t,r,n,o)}sendNotification(t,r){return this.cx.sendNotification(t,r)}sendBatch(t){return this.cx.sendBatch(t)}addDynamicHandler(t){return this.cx.addDynamicHandler(t)}},tT=class e extends W1{constructor(t,r){super(t,r)}static create(t,r){return new e(t,r)}request(t,r,n){qp(t,eT,"request");let o=eT[t];return this.sendRequest(t,r,o?.mapResponse,n)}notify(t,r){return qp(t,J1,"notification",!0),this.sendNotification(t,r)}batch(t){return VCe(t,eT,J1),this.sendBatch(t)}},rT=class e extends W1{constructor(t,r){super(t,r)}static create(t,r){return new e(t,r)}[XCe](t,r){return this.sendRequest(ct.session_new,t,n=>this.attachSession(n),r)}buildSession(t){return typeof t=="string"?K1.create(this,{cwd:t,mcpServers:[]}):K1.create(this,t)}attachSession(t){let r=new g7,n=new Set,o={enqueue:l=>r.enqueue(l),reject:l=>r.reject(l),clearErrors:()=>r.clearErrors(),fail:l=>r.fail(l),next:()=>r.next(),nextAfter:(l,u)=>r.nextAfter(l,u),beginPrompt:()=>{let l={updateCursor:r.cursor(),overlapController:new AbortController};if(n.size>0){let u=new Error("readText() cannot attribute updates across overlapping prompts; use nextUpdate() instead");for(let d of n)d.overlapController.abort(u);l.overlapController.abort(u)}return n.add(l),l},cancelPrompt:l=>n.delete(l),isAwaitingPromptCompletion:()=>n.size>0,completePrompt:()=>{n.clear()}},i=this.connectionContext.signal,s=()=>{r.fail(i.reason??new Error("ACP connection closed"))};i.aborted?s():i.addEventListener("abort",s);let a=iPe(this.connectionContext).attach(t,o),c=new Ap(()=>{i.removeEventListener("abort",s)});return y7.create(this,t,o,[a,c])}request(t,r,n){qp(t,XR,"request");let o=XR[t],i=t===ct.initialize?ZCe(r):r;return this.sendRequest(t,i,o?.mapResponse,n)}notify(t,r){return qp(t,Z1,"notification",!0),this.sendNotification(t,r)}batch(t){return VCe(t,XR,Z1),this.sendBatch(BEt(t))}},V1=class{connection;constructor(t){this.connection=t}get signal(){return this.connection.signal}get closed(){return this.connection.closed}close(t){this.connection.close(t)}},m7=class extends V1{connectHandlers;client;didStartConnectHandlers=!1;constructor(t,r=[]){super(t),this.connectHandlers=r,this.client=tT.create(t.getContext())}startConnectHandlers(){this.didStartConnectHandlers||(this.didStartConnectHandlers=!0,X1(this,this.connectHandlers))}},h7=class extends V1{connectHandlers;agent;didStartConnectHandlers=!1;constructor(t,r=[]){super(t),this.connectHandlers=r,this.agent=rT.create(t.getContext())}startConnectHandlers(){this.didStartConnectHandlers||(this.didStartConnectHandlers=!0,X1(this,this.connectHandlers))}};function ePe(e,t=[]){return new m7(e,t)}function tPe(e,t=[]){return new h7(e,t)}var g7=class{values=[];waiters=[];failed=!1;failure;nextSequence=0;enqueue(t){if(this.failed)return;let r=this.nextSequence++,n=this.waiters.shift();n?n.resolve(t):this.values.push({kind:"value",value:t,sequence:r})}reject(t){if(this.failed)return;let r=this.nextSequence++;if(this.waiters.length>0){for(let n of this.waiters.splice(0))n.reject(t);return}this.values.push({kind:"error",error:t,sequence:r})}clearErrors(){this.values=this.values.filter(t=>t.kind==="value")}cursor(){return this.nextSequence}nextAfter(t,r){if(r?.aborted)return Promise.reject(r.reason);for(;this.values[0]&&this.values[0].sequence<t;)this.values.shift();return this.next(r)}fail(t){if(!this.failed){this.failed=!0,this.failure=t;for(let r of this.waiters.splice(0))r.reject(t)}}next(t){if(t?.aborted)return Promise.reject(t.reason);if(this.values.length>0){let r=this.values.shift();return r.kind==="error"?Promise.reject(r.error):Promise.resolve(r.value)}return this.failed?Promise.reject(this.failure):new Promise((r,n)=>{let o=()=>{t?.removeEventListener("abort",s)},i={resolve:a=>{o(),r(a)},reject:a=>{o(),n(a)}},s=()=>{let a=this.waiters.indexOf(i);a>=0&&this.waiters.splice(a,1),i.reject(t?.reason)};this.waiters.push(i),t?.addEventListener("abort",s,{once:!0}),t?.aborted&&s()})}};function qCe(e){return structuredClone(e)}var K1=class e{cx;request;constructor(t,r){this.cx=t,this.request=qCe(r)}static create(t,r){return new e(t,r)}toRequest(){return qCe(this.request)}withAdditionalDirectories(t){return this.request={...this.request,additionalDirectories:[...t]},this}withMcpServer(t){return this.request={...this.request,mcpServers:[...this.request.mcpServers??[],structuredClone(t)]},this}async start(t){return this.cx[XCe](this.toRequest(),t)}async withSession(t){let r=await this.start();try{return await t(r)}finally{r.dispose()}}},y7=class e{cx;sessionResponse;updates;registrations;latestPrompt;constructor(t,r,n,o){this.cx=t,this.sessionResponse=r,this.updates=n,this.registrations=o}static create(t,r,n,o){return new e(t,r,n,o)}get sessionId(){return this.sessionResponse.sessionId}get configOptions(){return this.sessionResponse.configOptions}get meta(){return this.sessionResponse._meta}get newSessionResponse(){return this.sessionResponse}prompt(t,r){this.updates.clearErrors();let n=this.updates.beginPrompt();this.latestPrompt=n;let o=this.cx.request(ct.session_prompt,{sessionId:this.sessionId,prompt:this.promptBlocks(t)},r);return o.catch(i=>{this.updates.cancelPrompt(n)&&this.updates.reject(i)}),o}nextUpdate(){return this.updates.next()}async readText(){let t=this.latestPrompt,r=t?.updateCursor,n=[],o=new Map,i=s=>{let a=o.get(s);return a||(a=[],n.push(s),o.set(s,a)),a};for(;;){let s=r===void 0?await this.nextUpdate():await this.updates.nextAfter(r,t?.overlapController.signal);if(s.kind==="stop")return n.flatMap(c=>o.get(c)??[]).filter(p7.isText).map(c=>c.text).join("");let{update:a}=s;QR.isAgentMessage(a)?(i(a.messageId),a.content!==void 0&&o.set(a.messageId,a.content??[])):QR.isAgentMessageChunk(a)&&i(a.messageId).push(a.content)}}dispose(){for(let t of this.registrations.splice(0))t.dispose();this.updates.fail(new Error("Active session disposed"))}[Symbol.dispose](){this.dispose()}promptBlocks(t){return typeof t=="string"?[{type:"text",text:t}]:Array.isArray(t)?t:[t]}};function rPe(e,t){return e?typeof e=="function"?e(t):e.parse(t):t}function so(e,t,r){return{method:e,params:t,mapResponse:r}}function qc(e,t){return{method:e,params:t}}function nPe(e,t,r,n){e.onReceiveRequest(t.method,o=>rPe(t.params,o),async(o,i,s)=>{let a=await n(r(o,s,i.signal,i.id));await i.respond(t.mapResponse?t.mapResponse(a):a)})}function oPe(e,t,r,n){e.onReceiveNotification(t.method,o=>rPe(t.params,o),(o,i)=>n(r(o,i,i.signal)))}function Q1(e){let t=Object.create(null);for(let r of Object.values(e))t[r.method]=r;return t}var WEt={initialize:so(ct.initialize,KCe,JCe),loginAuth:so(ct.auth_login,D5,Hp),unstable_listProviders:so(ct.providers_list,N5),unstable_setProvider:so(ct.providers_set,z5,Hp),unstable_disableProvider:so(ct.providers_disable,L5,Hp),newSession:so(ct.session_new,G5),setSessionConfigOption:so(ct.session_set_config_option,Y5),prompt:so(ct.session_prompt,Q5,Hp),unstable_messageMcp:so(ct.mcp_message,KR),listSessions:so(ct.session_list,B5),deleteSession:so(ct.session_delete,W5,Hp),unstable_forkSession:so(ct.session_fork,V5),resumeSession:so(ct.session_resume,Z5),closeSession:so(ct.session_close,J5,Hp),logoutAuth:so(ct.auth_logout,F5,Hp),unstable_startNes:so(ct.nes_start,X5),unstable_suggestNes:so(ct.nes_suggest,e7),unstable_closeNes:so(ct.nes_close,t7,Hp)},VEt={cancelSession:qc(ct.session_cancel,o7),unstable_messageMcp:qc(ct.mcp_message,YR),unstable_didOpenDocument:qc(ct.document_did_open,i7),unstable_didChangeDocument:qc(ct.document_did_change,s7),unstable_didCloseDocument:qc(ct.document_did_close,a7),unstable_didSaveDocument:qc(ct.document_did_save,c7),unstable_didFocusDocument:qc(ct.document_did_focus,l7),unstable_acceptNes:qc(ct.nes_accept,u7),unstable_rejectNes:qc(ct.nes_reject,d7)},KEt={requestPermission:so(vi.session_request_permission,G8),unstable_connectMcp:so(vi.mcp_connect,e5),unstable_messageMcp:so(vi.mcp_message,KR),unstable_disconnectMcp:so(vi.mcp_disconnect,t5,Hp),unstable_createElicitation:so(vi.elicitation_create,X8)},ZEt={sessionUpdate:qc(vi.session_update,H1),unstable_messageMcp:qc(vi.mcp_message,YR),unstable_completeElicitation:qc(vi.elicitation_complete,M5)},XR=Q1(WEt),Z1=Q1(VEt),eT=Q1(KEt),J1=Q1(ZEt);function JEt(e,t,r,n){return{params:e,requestId:n,signal:r,client:t}}function YEt(e,t,r){return{params:e,signal:r,client:t}}function QEt(e,t,r,n){return{params:e,requestId:n,signal:r,agent:t}}function XEt(e,t,r){return{params:e,signal:r,agent:t}}var b7=class{activeSessions=new Map;handleMessage(t){if(t.kind!=="notification"||t.method!==vi.session_update)return Mc.no(t);let r=H1.parse(t.params),{update:n}=r,o=QR.isStateUpdate(n)&&f7.isIdle(n),i=this.activeSessions.get(r.sessionId);if(i&&i.size>0)for(let s of i)o&&s.isAwaitingPromptCompletion()?(s.completePrompt(),s.enqueue({kind:"stop",notification:r,update:n,stopReason:n.stopReason})):s.enqueue({kind:"session_update",notification:r,update:n});return Mc.no(t)}attach(t,r){let n=this.activeSessions.get(t.sessionId)??new Set;return n.add(r),this.activeSessions.set(t.sessionId,n),new Ap(()=>{n.delete(r),n.size===0&&this.activeSessions.delete(t.sessionId)})}},GCe=new WeakMap;function iPe(e){let t=GCe.get(e);return t||(t=new b7,GCe.set(e,t)),t}function X1(e,t){for(let r of t){let n;try{n=r(e)}catch(o){throw e.close(o),o}Promise.resolve(n).catch(o=>{e.close(o)})}}var Y1=Symbol("appBuilder"),G1=Symbol("runAgentConnectHandlers"),B1=Symbol("runClientConnectHandlers");var BCe=class{builder=Op.builder();connectHandlers=[];constructor(t={}){t.name&&this.builder.name(t.name)}[Y1](){return this.builder}[G1](t){X1(t,this.connectHandlers)}connect(t,r={}){return this.connectConnection(t,r).connection}connectWith(t,r){let{rawConnection:n,connection:o}=this.connectConnection(t);return n.runUntil(()=>r(o.client))}onConnect(t){return this.connectHandlers.push(t),this}onRequest(t,r,n){if(n)return qp(t,XR,"request"),this.request({method:t,params:r},n);let o=XR[t];if(!o)throw new Error(`Unknown ACP request method '${t}'. Pass a params parser for custom methods.`);return this.request(o,r)}onNotification(t,r,n){if(n)return qp(t,Z1,"notification",!0),this.notification({method:t,params:r},n);let o=Z1[t];if(!o)throw new Error(`Unknown ACP notification method '${t}'. Pass a params parser for custom methods.`);return this.notification(o,r)}request(t,r){return nPe(this.builder,t,(n,o,i,s)=>JEt(n,tT.create(o,s),i,s),r),this}notification(t,r){return oPe(this.builder,t,(n,o,i)=>YEt(n,tT.create(o),i),r),this}connectConnection(t,r={}){if(YCe(t)){let c=this.openStreamConnection(t);return r.deferConnectHandlers||this[G1](c.connection),c}let[n,o]=QCe(),i=t[Y1]().connect(o),s=tPe(i),a=this.openStreamConnection(n);a.rawConnection.closed.then(()=>s.close()),i.closed.then(()=>a.connection.close());try{t[B1](s),this[G1](a.connection)}catch(c){throw s.close(c),a.connection.close(c),c}return a}openStreamConnection(t){let r=this.builder.connect(t);return{rawConnection:r,connection:ePe(r,this.connectHandlers)}}};var WCe=class{builder=Op.builder();connectHandlers=[];constructor(t={}){t.name&&this.builder.name(t.name),this.builder.withHandler({handleMessage:(r,n)=>iPe(n).handleMessage(r),describe:()=>"client-session-update-router"})}[Y1](){return this.builder}[B1](t){X1(t,this.connectHandlers)}connect(t){return this.connectConnection(t).connection}connectWith(t,r){let{rawConnection:n,connection:o}=this.connectConnection(t);return n.runUntil(()=>r(o.agent))}onConnect(t){return this.connectHandlers.push(t),this}onRequest(t,r,n){if(n)return qp(t,eT,"request"),this.request({method:t,params:r},n);let o=eT[t];if(!o)throw new Error(`Unknown ACP request method '${t}'. Pass a params parser for custom methods.`);return this.request(o,r)}onNotification(t,r,n){if(n)return qp(t,J1,"notification",!0),this.notification({method:t,params:r},n);let o=J1[t];if(!o)throw new Error(`Unknown ACP notification method '${t}'. Pass a params parser for custom methods.`);return this.notification(o,r)}request(t,r){return nPe(this.builder,t,(n,o,i,s)=>QEt(n,rT.create(o,s),i,s),r),this}notification(t,r){return oPe(this.builder,t,(n,o,i)=>XEt(n,rT.create(o),i),r),this}connectConnection(t){if(YCe(t)){let a=this.openStreamConnection(t);return this[B1](a.connection),a}let[r,n]=QCe(),o=t[Y1]().connect(n),i=ePe(o),s=this.openStreamConnection(r);s.rawConnection.closed.then(()=>i.close()),o.closed.then(()=>s.connection.close());try{t[G1](i),this[B1](s.connection)}catch(a){throw i.close(a),s.connection.close(a),a}return s}openStreamConnection(t){let r=this.builder.connect(t);return{rawConnection:r,connection:tPe(r,this.connectHandlers)}}};var sPe=1;var aPe=["GET","HEAD","POST","PATCH","PUT","DELETE"];var Ms={hostState:"_redskills/host_state",hostBudgets:"_redskills/host_budgets",projectDrain:"_redskills/project_drain",projectStop:"_redskills/project_stop",projectStatus:"_redskills/project_status",projectBudget:"_redskills/project_budget",githubRead:"_redskills/github_read",githubRequest:"_redskills/github_request",githubWrite:"_redskills/github_write",githubUpdate:"_redskills/github_update",githubCustodyHandoff:"_redskills/github_custody_handoff",publish:"_redskills/publish",land:"_redskills/land",workerBudgetGrace:"_redskills/worker_budget_grace",goDispatch:"_redskills/go_dispatch",worktreeAdd:"_redskills/worktree_add",worktreeList:"_redskills/worktree_list",metrics:"_redskills/metrics",brainCall:"_redskills/brain_call",memoryCall:"_redskills/memory_call"},avr=Object.values(Ms);var t0t=16e3,r0t={type:"object",additionalProperties:!1,required:["demand"],properties:{demand:{type:"string",minLength:1,maxLength:t0t,description:"The one-off demand this dispatch exists to satisfy."}}},n0t={type:"object",additionalProperties:!1,required:["version","worker_id","ticket","lane"],properties:{version:{const:1},worker_id:{type:"string",minLength:1},ticket:{type:"integer",minimum:1},lane:{type:"string",minLength:1},session_id:{type:"string",minLength:1}}},dvr={version:1,method:Ms.goDispatch,params:r0t,answer:n0t};var o0t=64,cPe=200,i0t=/^[a-z0-9][a-z0-9._-]*$/;var s0t={type:"object",additionalProperties:!1,required:["slug"],properties:{slug:{type:"string",minLength:1,maxLength:o0t,pattern:i0t.source,description:"What the human is about to work on; becomes the worktree directory name."},branch:{type:"string",minLength:1,maxLength:cPe,description:"Branch to create; defaults to the daemon's convention for the slug."},base:{type:"string",minLength:1,maxLength:cPe,description:"Trunk BRANCH to fork from; the remote is the Project's registered trunk remote."}}},a0t={type:"object",additionalProperties:!1,required:["version","kind","path","branch","base","lane","project_label"],properties:{version:{const:1},kind:{const:"interactive"},path:{type:"string",minLength:1},branch:{type:"string",minLength:1},base:{type:"string",minLength:1},lane:{type:"string",minLength:1},project_label:{type:"string",minLength:1}}},c0t={type:"object",additionalProperties:!1,required:["version","project_label","worktrees"],properties:{version:{const:1},project_label:{type:"string",minLength:1},worktrees:{type:"array",items:{type:"object",additionalProperties:!1,required:["kind","path","branch"],properties:{kind:{enum:["checkout","interactive","worker","unregistered"]},path:{type:"string",minLength:1},branch:{type:["string","null"]},lane:{type:"string",minLength:1},worker_id:{type:"string",minLength:1}}}}}},Evr={version:1,methods:{add:Ms.worktreeAdd,list:Ms.worktreeList},add:{params:s0t,answer:a0t},list:{answer:c0t}};nT();var g0t={drain:Ms.projectDrain,stop:Ms.projectStop,status:Ms.projectStatus};async function k7(e={}){let t=e.cwd??process.cwd(),r=e.name??"RedSkills Project client",n=e.version??"1",o=e.paths??eN();await qR(o);let i=(await ob(o)).paths,s=await S0t(i.acpSocketPath),a=[],c="",l=Lve({name:r}).onNotification(Xm.client.session.update,async({params:f})=>{f.sessionId===c&&(a.push(f.update),await e.onUpdate?.(f.update))});e.requestPermission!=null&&(l=l.onRequest(Xm.client.session.requestPermission,({params:f})=>e.requestPermission(f)));let u=l.connect(h9(h0t.toWeb(s),m0t.toWeb(s)));return await u.agent.request(Xm.agent.initialize,{protocolVersion:1,clientCapabilities:{},clientInfo:{name:r,version:n},_meta:{redskills:{wireMajor:sPe}}}),c=(await u.agent.request(Xm.agent.session.new,{cwd:t,mcpServers:[]})).sessionId,{control:async(f,m={})=>{let b=await u.agent.request(g0t[f],{...m.target==null?{}:{target:m.target},...m.runner==null?{}:{runner:m.runner},...m.registration==null?{}:{registration:m.registration}});if(!hPe(b))throw new Error("redskilled returned an invalid Project control outcome");if(f==="status"&&!b0t(b))throw new Error("redskilled returned Project status without a valid RedSkills context");return b},github(f){return u.agent.request(Ms.githubRequest,{request:f})},brain(f){return u.agent.request(Ms.brainCall,{tool:f.tool,arguments:f.arguments})},memory(f){return u.agent.request(Ms.memoryCall,{tool:f.tool,arguments:f.arguments,...f.mode==null?{}:{mode:f.mode}})},async prompt(f){let m=a.length,b=await u.agent.request(Xm.agent.session.prompt,{sessionId:c,prompt:[{type:"text",text:f}]});return{stopReason:b.stopReason,...y0t(b._meta),updates:a.slice(m)}},cancel(){return u.agent.notify(Xm.agent.session.cancel,{sessionId:c})},async permission(f){return e.requestPermission==null?{outcome:{outcome:"cancelled"},_meta:{redskills:{permissionResolution:"hitl-required"}}}:await e.requestPermission(f)},close(){u.close(),s.destroy()}}}function y0t(e){let r=Bp(Bp(e)?.redskills)?.projectControl;return hPe(r)?{projectControl:r}:{}}function hPe(e){let t=Bp(e);return t?.version===1&&typeof t.project_id=="string"&&typeof t.revision=="number"&&Array.isArray(t.updates)}function b0t(e){let t=Bp(Bp(e)?.context),r=Bp(t?.queue),n=Bp(t?.workers),o=Bp(t?.adapter_health);return t?.version===1&&typeof t.observed_at=="string"&&typeof r?.posture=="string"&&(r.depth===null||typeof r.depth=="number")&&(r.target===null||typeof r.target=="number")&&typeof r.live=="number"&&(r.wanted===null||typeof r.wanted=="number")&&(r.observed_at===null||typeof r.observed_at=="string")&&(r.age_ms===null||typeof r.age_ms=="number")&&(r.freshness==="fresh"||r.freshness==="stale"||r.freshness==="unknown")&&typeof r.detail=="string"&&n?.freshness==="fresh"&&typeof n.observed_at=="string"&&typeof n.total=="number"&&Array.isArray(n.items)&&n.items.every(x0t)&&(o?.status==="healthy"||o?.status==="degraded"||o?.status==="unknown")&&(o.checked_at===null||typeof o.checked_at=="string")&&(o.last_success_at===null||typeof o.last_success_at=="string")&&(o.last_failure_at===null||typeof o.last_failure_at=="string")&&typeof o.detail=="string"}function x0t(e){let t=Bp(e);return typeof t?.worker_id=="string"&&t.state==="running"&&typeof t.started_at=="string"&&typeof t.isolated=="boolean"&&Array.isArray(t.warnings)&&t.warnings.every(r=>typeof r=="string")&&(t.base_commits_ahead===null||typeof t.base_commits_ahead=="number")}function Bp(e){return e!=null&&typeof e=="object"&&!Array.isArray(e)?e:void 0}async function S0t(e){return await new Promise((t,r)=>{let n=f0t(e);n.once("connect",()=>t(n)),n.once("error",r)})}iee();fd();Xte();A_();fd();var qz=class{constructor(t){this._server=t}requestStream(t,r,n){return this._server.requestStream(t,r,n)}createMessageStream(t,r){let n=this._server.getClientCapabilities();if((t.tools||t.toolChoice)&&!n?.sampling?.tools)throw new Error("Client does not support sampling tools capability.");if(t.messages.length>0){let o=t.messages[t.messages.length-1],i=Array.isArray(o.content)?o.content:[o.content],s=i.some(u=>u.type==="tool_result"),a=t.messages.length>1?t.messages[t.messages.length-2]:void 0,c=a?Array.isArray(a.content)?a.content:[a.content]:[],l=c.some(u=>u.type==="tool_use");if(s){if(i.some(u=>u.type!=="tool_result"))throw new Error("The last message must contain only tool_result content if any is present");if(!l)throw new Error("tool_result blocks are not matching any tool_use from the previous message")}if(l){let u=new Set(c.filter(f=>f.type==="tool_use").map(f=>f.id)),d=new Set(i.filter(f=>f.type==="tool_result").map(f=>f.toolUseId));if(u.size!==d.size||![...u].every(f=>d.has(f)))throw new Error("ids of tool_result blocks and tool_use blocks from previous message do not match")}}return this.requestStream({method:"sampling/createMessage",params:t},$b,r)}elicitInputStream(t,r){let n=this._server.getClientCapabilities(),o=t.mode??"form";switch(o){case"url":{if(!n?.elicitation?.url)throw new Error("Client does not support url elicitation.");break}case"form":{if(!n?.elicitation?.form)throw new Error("Client does not support form elicitation.");break}}let i=o==="form"&&t.mode===void 0?{...t,mode:"form"}:t;return this.requestStream({method:"elicitation/create",params:i},gh,r)}async getTask(t,r){return this._server.getTask({taskId:t},r)}async getTaskResult(t,r,n){return this._server.getTaskResult({taskId:t},r,n)}async listTasks(t,r){return this._server.listTasks(t?{cursor:t}:void 0,r)}async cancelTask(t,r){return this._server.cancelTask({taskId:t},r)}};ere();var Wz=class extends z_{constructor(t,r){super(r),this._serverInfo=t,this._loggingLevels=new Map,this.LOG_LEVEL_SEVERITY=new Map(OT.options.map((n,o)=>[n,o])),this.isMessageIgnored=(n,o)=>{let i=this._loggingLevels.get(o);return i?this.LOG_LEVEL_SEVERITY.get(n)<this.LOG_LEVEL_SEVERITY.get(i):!1},this._capabilities=r?.capabilities??{},this._instructions=r?.instructions,this._jsonSchemaValidator=r?.jsonSchemaValidator??new rw,this.setRequestHandler(YQ,n=>this._oninitialize(n)),this.setNotificationHandler(XQ,()=>this.oninitialized?.()),this._capabilities.logging&&this.setRequestHandler(yX,async(n,o)=>{let i=o.sessionId||o.requestInfo?.headers["mcp-session-id"]||void 0,{level:s}=n.params,a=OT.safeParse(s);return a.success&&this._loggingLevels.set(i,a.data),{}})}get experimental(){return this._experimental||(this._experimental={tasks:new qz(this)}),this._experimental}registerCapabilities(t){if(this.transport)throw new Error("Cannot register capabilities after connecting to transport");this._capabilities=cz(this._capabilities,t)}setRequestHandler(t,r){let o=dd(t)?.method;if(!o)throw new Error("Schema is missing a method literal");let i;if(ba(o)){let a=o;i=a._zod?.def?.value??a.value}else{let a=o;i=a._def?.value??a.value}if(typeof i!="string")throw new Error("Schema method literal must be a string");if(i==="tools/call"){let a=async(c,l)=>{let u=Ns(N_,c);if(!u.success){let b=u.error instanceof Error?u.error.message:String(u.error);throw new ze(qe.InvalidParams,`Invalid tools/call request: ${b}`)}let{params:d}=u.data,f=await Promise.resolve(r(c,l));if(d.task){let b=Ns(Qp,f);if(!b.success){let S=b.error instanceof Error?b.error.message:String(b.error);throw new ze(qe.InvalidParams,`Invalid task creation result: ${S}`)}return b.data}let m=Ns(pd,f);if(!m.success){let b=m.error instanceof Error?m.error.message:String(m.error);throw new ze(qe.InvalidParams,`Invalid tools/call result: ${b}`)}return m.data};return super.setRequestHandler(t,a)}return super.setRequestHandler(t,r)}assertCapabilityForMethod(t){switch(t){case"sampling/createMessage":if(!this._clientCapabilities?.sampling)throw new Error(`Client does not support sampling (required for ${t})`);break;case"elicitation/create":if(!this._clientCapabilities?.elicitation)throw new Error(`Client does not support elicitation (required for ${t})`);break;case"roots/list":if(!this._clientCapabilities?.roots)throw new Error(`Client does not support listing roots (required for ${t})`);break;case"ping":break}}assertNotificationCapability(t){switch(t){case"notifications/message":if(!this._capabilities.logging)throw new Error(`Server does not support logging (required for ${t})`);break;case"notifications/resources/updated":case"notifications/resources/list_changed":if(!this._capabilities.resources)throw new Error(`Server does not support notifying about resources (required for ${t})`);break;case"notifications/tools/list_changed":if(!this._capabilities.tools)throw new Error(`Server does not support notifying of tool list changes (required for ${t})`);break;case"notifications/prompts/list_changed":if(!this._capabilities.prompts)throw new Error(`Server does not support notifying of prompt list changes (required for ${t})`);break;case"notifications/elicitation/complete":if(!this._clientCapabilities?.elicitation?.url)throw new Error(`Client does not support URL elicitation (required for ${t})`);break;case"notifications/cancelled":break;case"notifications/progress":break}}assertRequestHandlerCapability(t){if(this._capabilities)switch(t){case"completion/complete":if(!this._capabilities.completions)throw new Error(`Server does not support completions (required for ${t})`);break;case"logging/setLevel":if(!this._capabilities.logging)throw new Error(`Server does not support logging (required for ${t})`);break;case"prompts/get":case"prompts/list":if(!this._capabilities.prompts)throw new Error(`Server does not support prompts (required for ${t})`);break;case"resources/list":case"resources/templates/list":case"resources/read":if(!this._capabilities.resources)throw new Error(`Server does not support resources (required for ${t})`);break;case"tools/call":case"tools/list":if(!this._capabilities.tools)throw new Error(`Server does not support tools (required for ${t})`);break;case"tasks/get":case"tasks/list":case"tasks/result":case"tasks/cancel":if(!this._capabilities.tasks)throw new Error(`Server does not support tasks capability (required for ${t})`);break;case"ping":case"initialize":break}}assertTaskCapability(t){Bz(this._clientCapabilities?.tasks?.requests,t,"Client")}assertTaskHandlerCapability(t){this._capabilities&&Gz(this._capabilities.tasks?.requests,t,"Server")}async _oninitialize(t){let r=t.params.protocolVersion;return this._clientCapabilities=t.params.capabilities,this._clientVersion=t.params.clientInfo,{protocolVersion:DN.includes(r)?r:wT,capabilities:this.getCapabilities(),serverInfo:this._serverInfo,...this._instructions&&{instructions:this._instructions}}}getClientCapabilities(){return this._clientCapabilities}getClientVersion(){return this._clientVersion}getCapabilities(){return this._capabilities}async ping(){return this.request({method:"ping"},Yp)}async createMessage(t,r){if((t.tools||t.toolChoice)&&!this._clientCapabilities?.sampling?.tools)throw new Error("Client does not support sampling tools capability.");if(t.messages.length>0){let n=t.messages[t.messages.length-1],o=Array.isArray(n.content)?n.content:[n.content],i=o.some(l=>l.type==="tool_result"),s=t.messages.length>1?t.messages[t.messages.length-2]:void 0,a=s?Array.isArray(s.content)?s.content:[s.content]:[],c=a.some(l=>l.type==="tool_use");if(i){if(o.some(l=>l.type!=="tool_result"))throw new Error("The last message must contain only tool_result content if any is present");if(!c)throw new Error("tool_result blocks are not matching any tool_use from the previous message")}if(c){let l=new Set(a.filter(d=>d.type==="tool_use").map(d=>d.id)),u=new Set(o.filter(d=>d.type==="tool_result").map(d=>d.toolUseId));if(l.size!==u.size||![...l].every(d=>u.has(d)))throw new Error("ids of tool_result blocks and tool_use blocks from previous message do not match")}}return t.tools?this.request({method:"sampling/createMessage",params:t},$T,r):this.request({method:"sampling/createMessage",params:t},$b,r)}async elicitInput(t,r){switch(t.mode??"form"){case"url":{if(!this._clientCapabilities?.elicitation?.url)throw new Error("Client does not support url elicitation.");let o=t;return this.request({method:"elicitation/create",params:o},gh,r)}case"form":{if(!this._clientCapabilities?.elicitation?.form)throw new Error("Client does not support form elicitation.");let o=t.mode==="form"?t:{...t,mode:"form"},i=await this.request({method:"elicitation/create",params:o},gh,r);if(i.action==="accept"&&i.content&&o.requestedSchema)try{let a=this._jsonSchemaValidator.getValidator(o.requestedSchema)(i.content);if(!a.valid)throw new ze(qe.InvalidParams,`Elicitation response content does not match requested schema: ${a.errorMessage}`)}catch(s){throw s instanceof ze?s:new ze(qe.InternalError,`Error validating elicitation response: ${s instanceof Error?s.message:String(s)}`)}return i}}}createElicitationCompletionNotifier(t,r){if(!this._clientCapabilities?.elicitation?.url)throw new Error("Client does not support URL elicitation (required for notifications/elicitation/complete)");return()=>this.notification({method:"notifications/elicitation/complete",params:{elicitationId:t}},r)}async listRoots(t,r){return this.request({method:"roots/list",params:t},kX,r)}async sendLoggingMessage(t,r){if(this._capabilities.logging&&!this.isMessageIgnored(t.level,r))return this.notification({method:"notifications/message",params:t})}async sendResourceUpdated(t){return this.notification({method:"notifications/resources/updated",params:t})}async sendResourceListChanged(){return this.notification({method:"notifications/resources/list_changed"})}async sendToolListChanged(){return this.notification({method:"notifications/tools/list_changed"})}async sendPromptListChanged(){return this.notification({method:"notifications/prompts/list_changed"})}};A_();oee();fd();var RDe=Symbol.for("mcp.completable");function tre(e){return!!e&&typeof e=="object"&&RDe in e}function TDe(e){return e[RDe]?.complete}var EDe;(function(e){e.Completable="McpCompletable"})(EDe||(EDe={}));var p1t=/^[A-Za-z0-9._-]{1,128}$/;function f1t(e){let t=[];if(e.length===0)return{isValid:!1,warnings:["Tool name cannot be empty"]};if(e.length>128)return{isValid:!1,warnings:[`Tool name exceeds maximum length of 128 characters (current: ${e.length})`]};if(e.includes(" ")&&t.push("Tool name contains spaces, which may cause parsing issues"),e.includes(",")&&t.push("Tool name contains commas, which may cause parsing issues"),(e.startsWith("-")||e.endsWith("-"))&&t.push("Tool name starts or ends with a dash, which may cause parsing issues in some contexts"),(e.startsWith(".")||e.endsWith("."))&&t.push("Tool name starts or ends with a dot, which may cause parsing issues in some contexts"),!p1t.test(e)){let r=e.split("").filter(n=>!/[A-Za-z0-9._-]/.test(n)).filter((n,o,i)=>i.indexOf(n)===o);return t.push(`Tool name contains invalid characters: ${r.map(n=>`"${n}"`).join(", ")}`,"Allowed characters are: A-Z, a-z, 0-9, underscore (_), dash (-), and dot (.)"),{isValid:!1,warnings:t}}return{isValid:!0,warnings:t}}function m1t(e,t){if(t.length>0){console.warn(`Tool name validation warning for "${e}":`);for(let r of t)console.warn(` - ${r}`);console.warn("Tool registration will proceed, but this may cause compatibility issues."),console.warn("Consider updating the tool name to conform to the MCP tool naming standard."),console.warn("See SEP: Specify Format for Tool Names (https://github.com/modelcontextprotocol/modelcontextprotocol/issues/986) for more details.")}}function rre(e){let t=f1t(e);return m1t(e,t.warnings),t.isValid}var Vz=class{constructor(t){this._mcpServer=t}registerToolTask(t,r,n){let o={taskSupport:"required",...r.execution};if(o.taskSupport==="forbidden")throw new Error(`Cannot register task-based tool '${t}' with taskSupport 'forbidden'. Use registerTool() instead.`);return this._mcpServer._createRegisteredTool(t,r.title,r.description,r.inputSchema,r.outputSchema,r.annotations,o,r._meta,n)}};uC();var nw=class{constructor(t,r){this._registeredResources={},this._registeredResourceTemplates={},this._registeredTools={},this._registeredPrompts={},this._toolHandlersInitialized=!1,this._completionHandlerInitialized=!1,this._resourceHandlersInitialized=!1,this._promptHandlersInitialized=!1,this.server=new Wz(t,r)}get experimental(){return this._experimental||(this._experimental={tasks:new Vz(this)}),this._experimental}async connect(t){return await this.server.connect(t)}async close(){await this.server.close()}setToolRequestHandlers(){this._toolHandlersInitialized||(this.server.assertCanSetRequestHandler(Th(JN)),this.server.assertCanSetRequestHandler(Th(N_)),this.server.registerCapabilities({tools:{listChanged:!0}}),this.server.setRequestHandler(JN,()=>({tools:Object.entries(this._registeredTools).filter(([,t])=>t.enabled).map(([t,r])=>{let n={name:t,title:r.title,description:r.description,inputSchema:(()=>{let o=I_(r.inputSchema);return o?tee(o,{strictUnions:!0,pipeStrategy:"input"}):h1t})(),annotations:r.annotations,execution:r.execution,_meta:r._meta};if(r.outputSchema){let o=I_(r.outputSchema);o&&(n.outputSchema=tee(o,{strictUnions:!0,pipeStrategy:"output"}))}return n})})),this.server.setRequestHandler(N_,async(t,r)=>{try{let n=this._registeredTools[t.params.name];if(!n)throw new ze(qe.InvalidParams,`Tool ${t.params.name} not found`);if(!n.enabled)throw new ze(qe.InvalidParams,`Tool ${t.params.name} disabled`);let o=!!t.params.task,i=n.execution?.taskSupport,s="createTask"in n.handler;if((i==="required"||i==="optional")&&!s)throw new ze(qe.InternalError,`Tool ${t.params.name} has taskSupport '${i}' but was not registered with registerToolTask`);if(i==="required"&&!o)throw new ze(qe.MethodNotFound,`Tool ${t.params.name} requires task augmentation (taskSupport: 'required')`);if(i==="optional"&&!o&&s)return await this.handleAutomaticTaskPolling(n,t,r);let a=await this.validateToolInput(n,t.params.arguments,t.params.name),c=await this.executeToolHandler(n,a,r);return o||await this.validateToolOutput(n,c,t.params.name),c}catch(n){if(n instanceof ze&&n.code===qe.UrlElicitationRequired)throw n;return this.createToolError(n instanceof Error?n.message:String(n))}}),this._toolHandlersInitialized=!0)}createToolError(t){return{content:[{type:"text",text:t}],isError:!0}}async validateToolInput(t,r,n){if(!t.inputSchema)return;let i=I_(t.inputSchema)??t.inputSchema,s=await PN(i,r);if(!s.success){let a="error"in s?s.error:"Unknown error",c=IN(a);throw new ze(qe.InvalidParams,`Input validation error: Invalid arguments for tool ${n}: ${c}`)}return s.data}async validateToolOutput(t,r,n){if(!t.outputSchema||!("content"in r)||r.isError)return;if(!r.structuredContent)throw new ze(qe.InvalidParams,`Output validation error: Tool ${n} has an output schema but no structured content was provided`);let o=I_(t.outputSchema),i=await PN(o,r.structuredContent);if(!i.success){let s="error"in i?i.error:"Unknown error",a=IN(s);throw new ze(qe.InvalidParams,`Output validation error: Invalid structured content for tool ${n}: ${a}`)}}async executeToolHandler(t,r,n){let o=t.handler;if("createTask"in o){if(!n.taskStore)throw new Error("No task store provided.");let s={...n,taskStore:n.taskStore};if(t.inputSchema){let a=o;return await Promise.resolve(a.createTask(r,s))}else{let a=o;return await Promise.resolve(a.createTask(s))}}if(t.inputSchema){let s=o;return await Promise.resolve(s(r,n))}else{let s=o;return await Promise.resolve(s(n))}}async handleAutomaticTaskPolling(t,r,n){if(!n.taskStore)throw new Error("No task store provided for task-capable tool.");let o=await this.validateToolInput(t,r.params.arguments,r.params.name),i=t.handler,s={...n,taskStore:n.taskStore},a=o?await Promise.resolve(i.createTask(o,s)):await Promise.resolve(i.createTask(s)),c=a.task.taskId,l=a.task,u=l.pollInterval??5e3;for(;l.status!=="completed"&&l.status!=="failed"&&l.status!=="cancelled";){await new Promise(f=>setTimeout(f,u));let d=await n.taskStore.getTask(c);if(!d)throw new ze(qe.InternalError,`Task ${c} not found during polling`);l=d}return await n.taskStore.getTaskResult(c)}setCompletionRequestHandler(){this._completionHandlerInitialized||(this.server.assertCanSetRequestHandler(Th(YN)),this.server.registerCapabilities({completions:{}}),this.server.setRequestHandler(YN,async t=>{switch(t.params.ref.type){case"ref/prompt":return ZAe(t),this.handlePromptCompletion(t,t.params.ref);case"ref/resource":return JAe(t),this.handleResourceCompletion(t,t.params.ref);default:throw new ze(qe.InvalidParams,`Invalid completion reference: ${t.params.ref}`)}}),this._completionHandlerInitialized=!0)}async handlePromptCompletion(t,r){let n=this._registeredPrompts[r.name];if(!n)throw new ze(qe.InvalidParams,`Prompt ${r.name} not found`);if(!n.enabled)throw new ze(qe.InvalidParams,`Prompt ${r.name} disabled`);if(!n.argsSchema)return dC;let i=dd(n.argsSchema)?.[t.params.argument.name];if(!tre(i))return dC;let s=TDe(i);if(!s)return dC;let a=await s(t.params.argument.value,t.params.context);return PDe(a)}async handleResourceCompletion(t,r){let n=Object.values(this._registeredResourceTemplates).find(s=>s.resourceTemplate.uriTemplate.toString()===r.uri);if(!n){if(this._registeredResources[r.uri])return dC;throw new ze(qe.InvalidParams,`Resource template ${t.params.ref.uri} not found`)}let o=n.resourceTemplate.completeCallback(t.params.argument.name);if(!o)return dC;let i=await o(t.params.argument.value,t.params.context);return PDe(i)}setResourceRequestHandlers(){this._resourceHandlersInitialized||(this.server.assertCanSetRequestHandler(Th(M_)),this.server.assertCanSetRequestHandler(Th(VN)),this.server.assertCanSetRequestHandler(Th(D_)),this.server.registerCapabilities({resources:{listChanged:!0}}),this.server.setRequestHandler(M_,async(t,r)=>{let n=Object.entries(this._registeredResources).filter(([i,s])=>s.enabled).map(([i,s])=>({uri:i,name:s.name,...s.metadata})),o=[];for(let i of Object.values(this._registeredResourceTemplates)){if(!i.resourceTemplate.listCallback)continue;let s=await i.resourceTemplate.listCallback(r);for(let a of s.resources)o.push({...i.metadata,...a})}return{resources:[...n,...o]}}),this.server.setRequestHandler(VN,async()=>({resourceTemplates:Object.entries(this._registeredResourceTemplates).map(([r,n])=>({name:r,uriTemplate:n.resourceTemplate.uriTemplate.toString(),...n.metadata}))})),this.server.setRequestHandler(D_,async(t,r)=>{let n=new URL(t.params.uri),o=this._registeredResources[n.toString()];if(o){if(!o.enabled)throw new ze(qe.InvalidParams,`Resource ${n} disabled`);return o.readCallback(n,r)}for(let i of Object.values(this._registeredResourceTemplates)){let s=i.resourceTemplate.uriTemplate.match(n.toString());if(s)return i.readCallback(n,s,r)}throw new ze(qe.InvalidParams,`Resource ${n} not found`)}),this._resourceHandlersInitialized=!0)}setPromptRequestHandlers(){this._promptHandlersInitialized||(this.server.assertCanSetRequestHandler(Th(KN)),this.server.assertCanSetRequestHandler(Th(ZN)),this.server.registerCapabilities({prompts:{listChanged:!0}}),this.server.setRequestHandler(KN,()=>({prompts:Object.entries(this._registeredPrompts).filter(([,t])=>t.enabled).map(([t,r])=>({name:t,title:r.title,description:r.description,arguments:r.argsSchema?g1t(r.argsSchema):void 0}))})),this.server.setRequestHandler(ZN,async(t,r)=>{let n=this._registeredPrompts[t.params.name];if(!n)throw new ze(qe.InvalidParams,`Prompt ${t.params.name} not found`);if(!n.enabled)throw new ze(qe.InvalidParams,`Prompt ${t.params.name} disabled`);if(n.argsSchema){let o=I_(n.argsSchema),i=await PN(o,t.params.arguments);if(!i.success){let c="error"in i?i.error:"Unknown error",l=IN(c);throw new ze(qe.InvalidParams,`Invalid arguments for prompt ${t.params.name}: ${l}`)}let s=i.data,a=n.callback;return await Promise.resolve(a(s,r))}else{let o=n.callback;return await Promise.resolve(o(r))}}),this._promptHandlersInitialized=!0)}resource(t,r,...n){let o;typeof n[0]=="object"&&(o=n.shift());let i=n[0];if(typeof r=="string"){if(this._registeredResources[r])throw new Error(`Resource ${r} is already registered`);let s=this._createRegisteredResource(t,void 0,r,o,i);return this.setResourceRequestHandlers(),this.sendResourceListChanged(),s}else{if(this._registeredResourceTemplates[t])throw new Error(`Resource template ${t} is already registered`);let s=this._createRegisteredResourceTemplate(t,void 0,r,o,i);return this.setResourceRequestHandlers(),this.sendResourceListChanged(),s}}registerResource(t,r,n,o){if(typeof r=="string"){if(this._registeredResources[r])throw new Error(`Resource ${r} is already registered`);let i=this._createRegisteredResource(t,n.title,r,n,o);return this.setResourceRequestHandlers(),this.sendResourceListChanged(),i}else{if(this._registeredResourceTemplates[t])throw new Error(`Resource template ${t} is already registered`);let i=this._createRegisteredResourceTemplate(t,n.title,r,n,o);return this.setResourceRequestHandlers(),this.sendResourceListChanged(),i}}_createRegisteredResource(t,r,n,o,i){let s={name:t,title:r,metadata:o,readCallback:i,enabled:!0,disable:()=>s.update({enabled:!1}),enable:()=>s.update({enabled:!0}),remove:()=>s.update({uri:null}),update:a=>{typeof a.uri<"u"&&a.uri!==n&&(delete this._registeredResources[n],a.uri&&(this._registeredResources[a.uri]=s)),typeof a.name<"u"&&(s.name=a.name),typeof a.title<"u"&&(s.title=a.title),typeof a.metadata<"u"&&(s.metadata=a.metadata),typeof a.callback<"u"&&(s.readCallback=a.callback),typeof a.enabled<"u"&&(s.enabled=a.enabled),this.sendResourceListChanged()}};return this._registeredResources[n]=s,s}_createRegisteredResourceTemplate(t,r,n,o,i){let s={resourceTemplate:n,title:r,metadata:o,readCallback:i,enabled:!0,disable:()=>s.update({enabled:!1}),enable:()=>s.update({enabled:!0}),remove:()=>s.update({name:null}),update:l=>{typeof l.name<"u"&&l.name!==t&&(delete this._registeredResourceTemplates[t],l.name&&(this._registeredResourceTemplates[l.name]=s)),typeof l.title<"u"&&(s.title=l.title),typeof l.template<"u"&&(s.resourceTemplate=l.template),typeof l.metadata<"u"&&(s.metadata=l.metadata),typeof l.callback<"u"&&(s.readCallback=l.callback),typeof l.enabled<"u"&&(s.enabled=l.enabled),this.sendResourceListChanged()}};this._registeredResourceTemplates[t]=s;let a=n.uriTemplate.variableNames;return Array.isArray(a)&&a.some(l=>!!n.completeCallback(l))&&this.setCompletionRequestHandler(),s}_createRegisteredPrompt(t,r,n,o,i){let s={title:r,description:n,argsSchema:o===void 0?void 0:Ob(o),callback:i,enabled:!0,disable:()=>s.update({enabled:!1}),enable:()=>s.update({enabled:!0}),remove:()=>s.update({name:null}),update:a=>{typeof a.name<"u"&&a.name!==t&&(delete this._registeredPrompts[t],a.name&&(this._registeredPrompts[a.name]=s)),typeof a.title<"u"&&(s.title=a.title),typeof a.description<"u"&&(s.description=a.description),typeof a.argsSchema<"u"&&(s.argsSchema=Ob(a.argsSchema)),typeof a.callback<"u"&&(s.callback=a.callback),typeof a.enabled<"u"&&(s.enabled=a.enabled),this.sendPromptListChanged()}};return this._registeredPrompts[t]=s,o&&Object.values(o).some(c=>{let l=c instanceof ga?c._def?.innerType:c;return tre(l)})&&this.setCompletionRequestHandler(),s}_createRegisteredTool(t,r,n,o,i,s,a,c,l){rre(t);let u={title:r,description:n,inputSchema:CDe(o),outputSchema:CDe(i),annotations:s,execution:a,_meta:c,handler:l,enabled:!0,disable:()=>u.update({enabled:!1}),enable:()=>u.update({enabled:!0}),remove:()=>u.update({name:null}),update:d=>{typeof d.name<"u"&&d.name!==t&&(typeof d.name=="string"&&rre(d.name),delete this._registeredTools[t],d.name&&(this._registeredTools[d.name]=u)),typeof d.title<"u"&&(u.title=d.title),typeof d.description<"u"&&(u.description=d.description),typeof d.paramsSchema<"u"&&(u.inputSchema=Ob(d.paramsSchema)),typeof d.outputSchema<"u"&&(u.outputSchema=Ob(d.outputSchema)),typeof d.callback<"u"&&(u.handler=d.callback),typeof d.annotations<"u"&&(u.annotations=d.annotations),typeof d._meta<"u"&&(u._meta=d._meta),typeof d.enabled<"u"&&(u.enabled=d.enabled),this.sendToolListChanged()}};return this._registeredTools[t]=u,this.setToolRequestHandlers(),this.sendToolListChanged(),u}tool(t,...r){if(this._registeredTools[t])throw new Error(`Tool ${t} is already registered`);let n,o,i,s;if(typeof r[0]=="string"&&(n=r.shift()),r.length>1){let c=r[0];if(nre(c))o=r.shift(),r.length>1&&typeof r[0]=="object"&&r[0]!==null&&!nre(r[0])&&(s=r.shift());else if(typeof c=="object"&&c!==null){if(Object.values(c).some(l=>typeof l=="object"&&l!==null))throw new Error(`Tool ${t} expected a Zod schema or ToolAnnotations, but received an unrecognized object`);s=r.shift()}}let a=r[0];return this._createRegisteredTool(t,void 0,n,o,i,s,{taskSupport:"forbidden"},void 0,a)}registerTool(t,r,n){if(this._registeredTools[t])throw new Error(`Tool ${t} is already registered`);let{title:o,description:i,inputSchema:s,outputSchema:a,annotations:c,_meta:l}=r;return this._createRegisteredTool(t,o,i,s,a,c,{taskSupport:"forbidden"},l,n)}prompt(t,...r){if(this._registeredPrompts[t])throw new Error(`Prompt ${t} is already registered`);let n;typeof r[0]=="string"&&(n=r.shift());let o;r.length>1&&(o=r.shift());let i=r[0],s=this._createRegisteredPrompt(t,void 0,n,o,i);return this.setPromptRequestHandlers(),this.sendPromptListChanged(),s}registerPrompt(t,r,n){if(this._registeredPrompts[t])throw new Error(`Prompt ${t} is already registered`);let{title:o,description:i,argsSchema:s}=r,a=this._createRegisteredPrompt(t,o,i,s,n);return this.setPromptRequestHandlers(),this.sendPromptListChanged(),a}isConnected(){return this.server.transport!==void 0}async sendLoggingMessage(t,r){return this.server.sendLoggingMessage(t,r)}sendResourceListChanged(){this.isConnected()&&this.server.sendResourceListChanged()}sendToolListChanged(){this.isConnected()&&this.server.sendToolListChanged()}sendPromptListChanged(){this.isConnected()&&this.server.sendPromptListChanged()}};var h1t={type:"object",properties:{}};function IDe(e){return e!==null&&typeof e=="object"&&"parse"in e&&typeof e.parse=="function"&&"safeParse"in e&&typeof e.safeParse=="function"}function ADe(e){return"_def"in e||"_zod"in e||IDe(e)}function nre(e){return typeof e!="object"||e===null||ADe(e)?!1:Object.keys(e).length===0?!0:Object.values(e).some(IDe)}function CDe(e){if(e){if(nre(e))return Ob(e);if(!ADe(e))throw new Error("inputSchema must be a Zod schema or raw shape, received an unrecognized object");return e}}function g1t(e){let t=dd(e);return t?Object.entries(t).map(([r,n])=>{let o=oAe(n),i=iAe(n);return{name:r,description:o,required:!i}}):[]}function Th(e){let r=dd(e)?.method;if(!r)throw new Error("Schema is missing a method literal");let n=AN(r);if(typeof n=="string")return n;throw new Error("Schema method literal must be a string")}function PDe(e){return{completion:{values:e.slice(0,100),total:e.length,hasMore:e.length>100}}}var dC={completion:{values:[],hasMore:!1}};ore();import ODe from"node:process";var pC=class{constructor(t=ODe.stdin,r=ODe.stdout){this._stdin=t,this._stdout=r,this._readBuffer=new ow,this._started=!1,this._ondata=n=>{this._readBuffer.append(n),this.processReadBuffer()},this._onerror=n=>{this.onerror?.(n)}}async start(){if(this._started)throw new Error("StdioServerTransport already started! If using Server class, note that connect() calls start() automatically.");this._started=!0,this._stdin.on("data",this._ondata),this._stdin.on("error",this._onerror)}processReadBuffer(){for(;;)try{let t=this._readBuffer.readMessage();if(t===null)break;this.onmessage?.(t)}catch(t){this.onerror?.(t)}}async close(){this._stdin.off("data",this._ondata),this._stdin.off("error",this._onerror),this._stdin.listenerCount("data")===0&&this._stdin.pause(),this._readBuffer.clear(),this.onclose?.()}send(t){return new Promise(r=>{let n=Kz(t);this._stdout.write(n)?r():this._stdout.once("drain",r)})}};import{resolve as v$}from"node:path";import{fileURLToPath as cdt}from"node:url";ao();function $De(e){return[{name:"claim_status",title:"Read AFK claim",description:"Return the parsed claim marker records and current holder for one issue (`issue`) or a batch (`issues`), keyed per issue.",inputSchema:{issue:w.number().int().positive().optional(),issues:w.array(w.number().int().positive()).min(1).optional()},invoke:t=>e.claimStatus(t)},{name:"claim_release",title:"Release AFK claim",description:"MUTATING: post a concede marker for every un-conceded claim holder so the issue (`issue`) or each issue in a batch (`issues`) becomes claimable again.",inputSchema:{issue:w.number().int().positive().optional(),issues:w.array(w.number().int().positive()).min(1).optional()},invoke:t=>e.claimRelease(t)}]}d_();function ire(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)?e:null}function sre(e){return typeof e=="string"&&e.trim()!==""?e:null}function b1t(e){let t=ire(e);if(t===null)return null;let r=ire(t.demand);return sre(r?.refusal)??sre(t.latest_refusal)}function MDe(e){return{tool:"status",args:{scope:"project"},why:e}}function x1t(){return{tool:"status",args:{scope:"host"},why:"diagnose why the host daemon does not answer before changing registration"}}function S1t(e,t){let r=e.registration;return r.daemon_reachable?!r.held&&r.repair!==void 0&&r.repair!=="none"?u_():e.live_workers.length>0&&t===null?{tool:"status",args:{scope:"worker"},why:"observe the Workers already draining this project's queue"}:MDe(t!==null?"observe when the daemon's refusal clears and capacity begins draining again":"observe the next socket-local queue poll and Worker birth"):x1t()}function k1t(e){let t=e.registration;if(!t.daemon_reachable)return"daemon unreachable: this project cannot read or change its host registration";if(!t.held)return"unregistered: the daemon is reachable but holds no registration for this project";let r=t.last_poll?.depth,n=r==null?"an unknown queue":`${r} queued`;return`draining: ${e.slots.busy} of ${e.slots.total} Worker slots are busy with ${n}`}function _1t(e){return[{intent:"choose the capability that matches your intent",tools:e.filter(t=>!t.description.startsWith("DEPRECATED:")).map(({name:t,title:r})=>({name:t,title:r}))}]}function DDe(e,t){return[{name:"help",title:"Find the next redskilled action",description:"Read live daemon, registration, queue, Worker, and refusal state; return the pasteable next call and a generated intent map. Makes no GitHub request.",inputSchema:{},invoke:async()=>{let[r,n]=await Promise.all([e.projectStatus(),e.hostState().catch(()=>null)]),o=k1t(r),i=b1t(n),s=S1t(r,i),a=ma({state:`you are ${o}`,repair:s});if(a.repair==="none")throw new Error("help produced no callable next action");return{here:o,state:{daemon:{reachable:r.registration.daemon_reachable,version:sre(ire(n)?.daemon_version)??""},registration:{held:r.registration.held,project:r.registration.project,renewal:r.registration.renewal,target:r.registration.target},queue:r.registration.last_poll==null?null:{at:r.registration.last_poll.at,outcome:r.registration.last_poll.outcome,depth:r.registration.last_poll.depth,detail:r.registration.last_poll.detail},workers:{busy:r.slots.busy,free:r.slots.free,live:r.live_workers.length,target:r.slots.total},validation_schedule:r.validation_schedule,last_refusal:i,warnings:r.warnings??[]},guidance:a.prose,next:a.repair,intent_map:_1t(t())}}}]}ao();function NDe(e){return[{name:"merge_arm",title:"Arm PR for the merge driver",description:"MUTATING: hand one open PR to a live project merge-driver process \u2014 it owns the PR to a terminal state (update-branch when BEHIND, merge-commit once green at head, bounded retries, needs-medic/needs-human classification) without GitHub native auto-merge. Refuses when the merge-driver process is missing so custody cannot become orphaned.",inputSchema:{pr:w.number().int().positive()},invoke:({pr:t})=>e.mergeArm({pr:t})},{name:"merge_status",title:"Read merge driver state",description:"Return whether the merge-driver process is ticking plus durable per-PR records: armed records labeled driver-ticking or orphaned, attempts, last observed state, and terminal classifications.",inputSchema:{},invoke:()=>e.mergeStatus()},{name:"merge_release",title:"Release PR from the merge driver",description:"MUTATING: stop driver ownership of one PR. The record is kept as released for observability.",inputSchema:{pr:w.number().int().positive()},invoke:({pr:t})=>e.mergeRelease({pr:t})}]}ao();var w1t=["requeue","retake","park","close"];function zDe(e){return[{name:"hitl_resolve",title:"Resolve parked issue with a human decision",description:"MUTATING: encode one human decision on a parked issue atomically \u2014 requeue (concede dangling claims, strip park labels, ready-for-agent), retake (route to the no-agent landing lane), park (keep ready-for-human, record why), or close. The rationale is posted as an issue comment for the audit trail.",inputSchema:{issue:w.number().int().positive(),decision:w.enum(w1t),rationale:w.string().min(1)},invoke:t=>e.hitlResolve(t)}]}ao();var Zz="2.0.0";function Jz(e,t){return{version:Zz,schema:e,projection:t}}var lAr=w.object({age_s:w.number(),stale:w.boolean(),stale_after_s:w.number(),reason:w.enum(["fresh","aged-out","never-observed","orphaned"])}),v1t=w.object({version:w.string(),source:w.enum(["registry","recorded","installed-plugin","bundle-cache","unresolved"]),age_ms:w.number(),stale_after_ms:w.number(),stale:w.boolean(),reason:w.enum(["fresh","aged-out","installed-only","cache-only","never-observed"])}),E1t=w.object({tool:w.string().min(1),args:w.record(w.string(),w.unknown()),why:w.string().min(1)}),R1t=w.union([E1t,w.literal("none")]),T1t=w.object({held:w.boolean(),daemon_reachable:w.boolean(),project:w.string(),socket:w.string(),selector:w.string(),target:w.number(),renewal:w.enum(["renewing","self-renewing","running-on","unknown"]),renew_by:w.string(),renewals:w.number(),lapsed_at:w.string(),reason:w.string(),repair:R1t.optional(),repair_reason:w.string().min(1).optional(),launch_revision:w.number(),bundle_version:w.string(),plugin_cache_version:w.string(),last_poll:w.object({at:w.string(),outcome:w.string(),depth:w.number().nullable(),request_count:w.number(),detail:w.string()}).optional(),published_version:v1t.optional()}).superRefine((e,t)=>{!e.held&&e.repair===void 0&&t.addIssue({code:w.ZodIssueCode.custom,path:["repair"],message:"an absent registration must carry a repair or an argued none"}),e.repair==="none"&&e.repair_reason===void 0&&t.addIssue({code:w.ZodIssueCode.custom,path:["repair_reason"],message:"repair none must state why no callable cure is safe"})}),C1t=w.object({name:w.literal("project-birth-breaker"),project_label:w.string(),state:w.enum(["open","half-open"]),opened_at:w.string(),reason:w.string(),closes:w.string(),probe_worker_id:w.string().nullable(),repair:w.object({tool:w.literal("project_reset"),args:w.object({latch:w.literal("project-birth-breaker")}),why:w.string()})}),P1t=w.object({narration:w.string(),moments:w.array(w.object({moment:w.enum(["iteration","post_done","landing"]),state:w.enum(["declared","skip"]),declared:w.boolean(),commands:w.array(w.string())})).length(3)}),fC=w.object({registration:T1t,validation_schedule:P1t,birth_latch:C1t.nullable(),slots:w.object({busy:w.number(),free:w.number(),parked:w.number(),total:w.number(),interactive_reservation:w.number()}),live_workers:w.array(w.object({id:w.string(),pid:w.number(),issue:w.string(),activity:w.string(),origin:w.string()})),unattributed_workers:w.array(w.object({id:w.string(),pid:w.number(),issue:w.string(),activity:w.string(),origin:w.string()})),warnings:w.array(w.string()).optional()}),I1t=w.object({number:w.union([w.number(),w.string()]),runner:w.string(),retries:w.number(),phase:w.string(),iteration:w.union([w.number(),w.string()]),activity:w.string(),loc_added:w.number(),loc_removed:w.number(),last_commit_at:w.string(),tools_called_count:w.number(),text_chunk_count:w.number(),reasoning_events:w.number(),reasoning_tokens:w.number(),last_event_at:w.string(),waiting_count:w.number(),input_tokens:w.number(),output_tokens:w.number(),cost_usd:w.number()}),A1t=w.object({status:w.enum(["alive","stalled","capped","unknown"]),laneFresh:w.boolean(),laneAgeMs:w.number().optional(),crossCheckArmed:w.boolean(),liveDescendants:w.boolean().optional(),reason:w.string()}),O1t=w.object({verdict:w.enum(["alive","dead","unknown"]),anchor:w.enum(["daemon","none"]),project_label:w.string().nullable(),pid:w.number().nullable(),staleness:w.object({stale:w.boolean(),age_ms:w.number().nullable(),threshold_ms:w.number().nullable(),reason:w.string()})}),FDe=w.object({worker:w.object({id:w.string(),pid:w.number(),runner:w.string(),origin:w.string(),started_at:w.string(),done:w.number(),total:w.number(),blocked:w.number(),failed:w.number(),current:I1t}),live:w.boolean(),active:w.boolean(),renderable_live:w.boolean(),liveness:w.enum(["active","quiet-but-live","dead"]),liveness_verdict:A1t,daemon_liveness:O1t.optional()}),Yz=w.array(FDe),Qz=w.array(FDe.partial()),$1t=w.object({state:w.object({worker_id:w.string(),pid:w.number(),runner:w.string(),started_at:w.string(),total:w.number(),done:w.number(),blocked:w.number(),failed:w.number(),current:w.object({number:w.union([w.number(),w.string()]),title:w.string(),activity:w.string(),started_at:w.string()})}),live:w.boolean()}),mC=w.object({workers:w.array($1t),events:w.array(w.object({event:w.string(),epoch:w.number()})),fleet:w.object({ts:w.string(),epoch:w.number(),runner:w.string(),readyForAgent:w.number(),slotsBusy:w.number(),slotsFree:w.number(),slotsTotal:w.number(),slotsParked:w.number(),interactiveReservation:w.number(),spawnsThisTick:w.number()}).nullable(),remoteQueue:w.number().optional(),remoteHuman:w.number().optional(),remoteCacheAgeS:w.number().optional()}),LDe=w.object({number:w.number(),title:w.string(),labels:w.array(w.string())}),jDe=w.object({ready_for_agent:w.object({eligible:w.array(LDe),held_for_summon:w.array(LDe)}),ready_for_human:w.array(w.object({number:w.number(),title:w.string(),labels:w.array(w.string()),body:w.string().optional(),createdAt:w.string().nullable().optional()})),counts:w.object({ready_for_agent_eligible:w.number(),ready_for_agent_held:w.number(),ready_for_human:w.number()}),degraded:w.boolean(),errors:w.array(w.object({kind:w.literal("trust-read"),number:w.number(),message:w.string()}))}),UDe=Jz(fC),uAr=Jz(Yz,{input:"fields",schema:Qz}),dAr=Jz(mC),HDe=Jz(jDe);function M1t(e,t){let{projection:r}=e;if(!r)return e.schema;let n=t[r.input];return Array.isArray(n)&&n.length>0?r.schema:e.schema}function qDe(e){return e.map(t=>{let r=t.outputContract;if(!r)return t;let n=t.invoke.bind(t);return{...t,invoke:async o=>{let i=await n(o),s=M1t(r,o).safeParse(i);if(!s.success)throw new Error(`${t.name} output violates contract ${r.version}: ${s.error.issues.map(a=>`${a.path.join(".")||"<root>"}: ${a.message}`).join("; ")}`);return i}}})}ao();var GDe="named fleets were removed (ADR 0130): the host daemon owns the budget and each project has exactly one demand producer, so a fleet name addresses nothing. Drop the name \u2014 the work scope, the runner and the base branch now ride with the project's producer: pass `selector` / `runner` / `base` to the rs_dev `project_start` tool (status: `project_status`, resize: `project_resize`, stop: `project_stop`).",are=class extends Error{constructor(t){super(t===void 0||t===""?GDe:`fleet ${JSON.stringify(t)}: ${GDe}`),this.name="FleetNamingRemovedError"}};function iw(e){if(!(e==null||e===""))throw new are(typeof e=="string"?e:String(e))}ao();var D1t=w.object({tool:w.literal("status"),args:w.object({scope:w.enum(["worker","project","host"])})});function BDe(e){return w.object({deprecated:w.literal(!0),message:w.string().min(1),replacement:D1t,result:e})}function VDe(e){return{version:e.version,schema:BDe(e.schema),...e.projection===void 0?{}:{projection:{input:e.projection.input,schema:BDe(e.projection.schema)}}}}var N1t=w.object({status:w.unknown(),vitals:Yz,monitor:mC}),z1t=w.object({status:w.unknown(),vitals:Qz,monitor:mC}),WDe=w.object({state:w.unknown(),dashboard:w.unknown(),provision_check:w.unknown(),unit_status:w.unknown()}),L1t={version:Zz,schema:w.union([fC,N1t,WDe]),projection:{input:"fields",schema:w.union([fC,z1t,WDe])}};function KDe(e,t,r){return{deprecated:!0,message:`${e} is deprecated; use status { scope: ${t} }`,replacement:{tool:"status",args:{scope:t}},result:r}}async function F1t(e,t){if(t.scope==="project")return e.projectStatus();if(t.scope==="host"){let[s,a,c,l]=await Promise.all([e.hostState(),e.hostDashboard(),e.hostProvisionCheck(),e.hostUnitStatus()]);return{state:s,dashboard:a,provision_check:c,unit_status:l}}let r={worker:t.worker,live_only:t.live_only??!0,fields:t.fields},[n,o,i]=await Promise.all([e.workerStatus(r),e.workerVitals({live_only:r.live_only,fields:r.fields}),e.monitor()]);return{status:n,vitals:o,monitor:i}}function ZDe(e){return[{name:"status",title:"Read redskilled status",description:"Answer the current worker, project, or host status through one intent-scoped read.",inputSchema:{scope:w.enum(["worker","project","host"]),worker:w.string().min(1).optional(),live_only:w.boolean().default(!0),fields:w.array(w.string().min(1)).optional()},outputContract:L1t,invoke:t=>F1t(e,t)}]}cre();var Xz={spec:w.number().int().positive().optional(),lane:w.string().min(1).optional(),label:w.string().min(1).optional(),issues:w.array(w.number().int().positive()).optional(),tags:w.array(w.string().min(1)).optional(),user:w.string().min(1).optional()};var QDe=w.record(w.string(),w.union([w.string(),w.number(),w.boolean()])),hC=w.string().optional().describe("REMOVED: naming a fleet is refused; a project has one producer.");function XDe(e){return[{name:"project_activation",title:"Preview this project's redskilled activation",description:"READ-ONLY: report whether this project opted into RedSkills and the canonical runner and target a no-argument drain would register.",inputSchema:{},invoke:()=>e.projectActivation()},{name:"project_status",title:"Deprecated project status alias",description:"DEPRECATED: use status { scope: project }. Returns the project answer and names its replacement.",inputSchema:{fleet:hC},outputContract:VDe(UDe),invoke:async({fleet:t})=>(iw(t),KDe("project_status","project",await e.projectStatus()))},{name:"drain",title:"Make this project drain",description:"MUTATING: ensure the daemon is reachable and this project is registered. Omitted runner and target resolve from this project's canonical RedSkills configuration; repeated calls report what was kept.",inputSchema:{runner:w.string().min(1).optional(),target:w.number().int().min(0).optional()},invoke:async t=>e.drain(t)},{name:"project_start",title:"Start this project's workers",description:"MUTATING: register this project with the host daemon \u2014 a runner, a target width, and its work policy. Registers rather than launches: the project contributes a record, never a process of its own.",inputSchema:{runner:w.string().min(1),target:w.number().int().min(0).default(1),selector:w.object(Xz).optional(),config:QDe.optional(),base:w.string().min(1).optional(),fleet:hC},invoke:async t=>(iw(t.fleet),e.projectStart(t))},{name:"project_resize",title:"Re-aim this project's workers",description:"MUTATING: change this project's target width, runner, or work policy and send the live directive.",inputSchema:{runner:w.string().min(1).optional(),target:w.number().int().min(0).optional(),selector:w.object(Xz).optional(),config:QDe.optional(),base:w.string().min(1).optional(),fleet:hC},invoke:async t=>(iw(t.fleet),e.projectResize(t))},{name:"project_reset",title:"Reset project execution latch",description:"MUTATING: clear a named in-memory latch for this project so autonomous demand may retry immediately.",inputSchema:{latch:w.literal("project-birth-breaker"),fleet:hC},invoke:async({latch:t,fleet:r})=>(iw(r),e.projectReset({latch:t}))},{name:"project_stop",title:"Stop this project's workers",description:"MUTATING: stop this project's work and give its registration back; force hard teardown explicitly.",inputSchema:{force:w.boolean().optional(),fleet:hC},invoke:async({force:t,fleet:r})=>(iw(r),e.projectStop({force:t}))}]}ao();function e1e(e){return[{name:"gate_run",title:"Run the AFK gate",description:"MUTATING: materialize the branch's feedback worktree and run the package-scoped validation gate against it.",dangerClass:"mutating",inputSchema:{branch:w.string().min(1),base:w.string().min(1).optional()},invoke:t=>e.gateRun(t)}]}function t1e(e){return[{name:"deadend_audit",title:"Audit AFK deadends",description:"Return the read-only deadend audit: dangling claims, red PRs with dead owners, superseded PRs, executable Tickets carrying an active Current blocker, dependency blocks whose req targets all closed, human-queue age outliers, and stale worktrees \u2014 each class paired with its recommended cure. Cache-backed: repeated calls within the refresh window cost zero GitHub quota.",inputSchema:{},invoke:()=>e.deadendAudit()}]}ao();function r1e(e){return[{name:"requeue",title:"Requeue AFK issue",description:"MUTATING: apply the complete parked-issue requeue transition and record human guidance.",inputSchema:{issue:w.number().int().positive(),guidance:w.string().min(1),repo:w.string().min(1).optional(),dryRun:w.boolean().optional(),adoptBranch:w.string().min(1).optional()},invoke:t=>e.requeue(t)},{name:"retake",title:"Recommend AFK retake",description:"Return the structured issue, PR, branch, worktree, worker-state, and recommended-next-action report.",inputSchema:{issue:w.number().int().positive(),repo:w.string().min(1).optional(),prLimit:w.number().int().positive().max(1e3).optional()},invoke:t=>e.retake(t)},{name:"reap",title:"Reap AFK branches",description:"MUTATING: classify and delete stale local and remote AFK branches.",inputSchema:{},invoke:()=>e.reap()},{name:"unblock_sweep",title:"Sweep dependency blocks",description:"MUTATING: promote dependency-blocked issues whose requirements are all closed.",inputSchema:{},invoke:()=>e.unblockSweep()}]}ao();function n1e(e){return[{name:"land_branch",title:"Land AFK branch",description:"MUTATING: land one validated worker branch into its base through the complete landing sequence.",dangerClass:"mutating",inputSchema:{issue:w.number().int().positive(),branch:w.string().min(1),base:w.string().min(1).optional(),title:w.string().min(1).optional(),openPr:w.boolean().optional()},invoke:t=>e.landBranch(t)},{name:"cascade_status",title:"Read close cascade",description:"Return the dependents of one issue and which of them the close cascade would promote.",inputSchema:{issue:w.number().int().positive()},invoke:({issue:t})=>e.cascadeStatus({issue:t})}]}ao();function o1e(e){return[{name:"logs",title:"Read redskilled logs",description:"Return the newest CastleLaneRecord entries from one structured lane; bounded by `limit` (default 200, max 10 000). Pass `kind` to filter before the limit.",inputSchema:{lane:w.enum(["worker","supervisor","monitor","liveness"]),id:w.string().min(1),limit:w.number().int().positive().max(1e4).default(200),kind:w.string().optional()},invoke:t=>e.logs(t)},{name:"dashboard",title:"Build AFK dashboard",description:"Build the structured operational dashboard from GitHub and local state.",inputSchema:{periodDays:w.number().int().positive().default(30)},invoke:({periodDays:t})=>e.dashboard({periodDays:t})},{name:"history",title:"Read redskilled history",description:"Return structured AFK history records, newest records last.",inputSchema:{limit:w.number().int().positive().max(1e4).optional()},invoke:({limit:t})=>e.history({limit:t})},{name:"queue_status",title:"Read AFK queues",description:"Return ready-for-agent and ready-for-human queue candidates, retaining successful candidates and naming partial trust-read failures as a degraded result. Pass `selector` to preview the producer's scoped view of the ready queue (same facets as its work selector, e.g. tags/user).",inputSchema:{selector:w.object(Xz).optional()},outputContract:HDe,invoke:t=>e.queueStatus({selector:t.selector})},{name:"events_since",title:"Poll events since cursor",description:"Return AFK history events and Worker lane records after an opaque cursor, plus the next cursor. Omit cursor to get a fresh baseline cursor with no events. Unknown or expired cursors are refused with a re-baseline prompt.",inputSchema:{cursor:w.string().min(1).optional()},invoke:t=>e.eventsSince({cursor:t.cursor})}]}ao();function i1e(e){return[{name:"manager",title:"Route work through the Manager",description:"MUTATING: take one operator intent into the Manager \u2014 intake, route an effort to a skill, attach an artifact, read effort status, or export/import the checkpoint \u2014 and return the effort record it acted on.",inputSchema:{intent:w.string().min(1).optional(),action:w.enum(["intake","route","artifact","status","checkpoint"]).optional(),effort:w.string().min(1).optional(),skill:w.string().min(1).optional(),artifact:w.string().min(1).optional(),checkpoint:w.enum(["export","import"]).optional(),path:w.string().min(1).optional()},invoke:t=>e.manager(t)},{name:"red_doctor",title:"Diagnose this repository's RedSkills setup",description:"READ-ONLY: return every doctor finding for this repository \u2014 operational probes, host toolchain, lane and process census, executable acceptance, HUMAN-ONLY type declarations and disposable-lane hygiene \u2014 each paired with the route that repairs it. Applying a repair is the `/red-doctor` skill's own fix lane, never a side effect of the read.",inputSchema:{checks:w.array(w.string().min(1)).optional()},invoke:t=>e.redDoctor(t)},{name:"audit_skills",title:"Audit the shipped skills",description:"Return the ranked skill-audit scores for this repository's skill tree. Pass `mechanical_only` to score without the judge, which makes the read deterministic and free of agent cost.",inputSchema:{mechanical_only:w.boolean().optional(),runner:w.string().min(1).optional()},invoke:t=>e.auditSkills(t)},{name:"install_type_labels",title:"Install Wayfinder type labels",description:"MUTATING: create the Wayfinder ticket type labels on the tracker AND declare the HUMAN-ONLY ones in this project's configuration, in one act \u2014 the two are one protection with two halves, and installing only the labels leaves the repository looking protected while unblocked decision Tickets enter the autonomous queue (#3013).",inputSchema:{labels:w.array(w.string().min(1)).optional(),repo:w.string().min(1).optional(),dry_run:w.boolean().optional()},invoke:t=>e.installTypeLabels(t)},{name:"codex_statusline",title:"Inspect the Codex footer preference",description:"READ-ONLY: return the active Codex configuration's status-line inspection \u2014 the file read, the current preference, and the problem that keeps the RedSkills footer from rendering.",inputSchema:{config:w.string().min(1).optional()},invoke:t=>e.codexStatusline(t)},{name:"codex_monitor_agent",title:"Build the Codex monitor agent brief",description:"Return the read-only monitor brief a Codex sub-agent is spawned with: what to poll, how often, and the conditions under which it closes itself. It spawns nothing \u2014 the host's own spawn primitive does.",inputSchema:{project_root:w.string().min(1).optional(),mode:w.string().min(1).optional(),interval_seconds:w.number().int().positive().optional()},invoke:t=>e.codexMonitorAgent(t)},{name:"reconcile_engine",title:"Reconcile this project's engine delivery",description:"MUTATING: warm the published engine bundle into the stable cache path and re-point a standing registration at it in one operation, then return the version, the bundle path, and what happened to the registration.",inputSchema:{version:w.string().min(1).optional()},invoke:t=>e.reconcileEngine(t)}]}ao();function s1e(e){return[{name:"daily_review",title:"Build daily activity review",description:"Return the structured daily activity review report for the local window.",inputSchema:{},invoke:()=>e.dailyReview({})},{name:"weekly_review",title:"Build weekly activity review",description:"Return the structured weekly activity review report for the local window.",inputSchema:{},invoke:()=>e.weeklyReview({})},{name:"triage",title:"Apply triage decision",description:"MUTATING: apply the decided triage transition to one issue, gated by the per-repo trust policy.",inputSchema:{issue:w.number().int().positive(),decision:w.enum(["ready-for-agent","needs-info","ready-for-human","wontfix"]),summon:w.boolean().optional(),repo:w.string().min(1).optional()},invoke:t=>e.triage(t)},{name:"respond",title:"Handle comment event",description:"MUTATING: parse a /dev comment summon, authorize the commenter, and route the advisory or mutation verb.",inputSchema:{body:w.string(),number:w.number().int().positive(),author:w.string().min(1).optional(),is_pr:w.boolean().optional(),runner:w.string().min(1).optional(),repo:w.string().min(1).optional()},invoke:t=>e.respond(t)}]}ao();ao();d_();function lre(e){let t=ma({state:e instanceof Error?e.message:String(e),repair:nb("the caller must choose one dispatch intent before retrying")});if(t.repair!=="none")throw new Error("invalid worker refusal repair");return{refused:!0,reason:t.prose,repair:t.repair,repair_reason:t.repair_reason}}var ure={issue:w.number().int().positive().optional(),demand:w.string().min(1).optional(),runner:w.string().min(1).optional(),mode:w.enum(["no-mistakes","direct-PR","local-only","scout"]).optional()};function dre(e){let t=e;if(t.issue===void 0==(t.demand===void 0))throw new Error("exactly one of issue or demand is required");if(t.mode==="scout"&&t.issue!==void 0)throw new Error("mode: scout is demand-only \u2014 combine scout with demand, not issue");if(t.issue!==void 0&&t.mode!==void 0)throw new Error("mode is only valid for demand dispatches");return t}function a1e(e){return[{name:"worker_dispatch",title:"Dispatch AFK worker",description:"MUTATING: run one tracked issue or mint and run one disposable demand through the AFK worker lifecycle.",inputSchema:ure,invoke:t=>{let r;try{r=dre(t)}catch(n){return Promise.resolve(lre(n))}return e.workerDispatch(r)}},{name:"worker_stop",title:"Stop AFK worker",description:"MUTATING: terminate one worker process tree.",inputSchema:{worker:w.string().min(1)},invoke:({worker:t})=>e.workerStop({worker:t,recycle:!1})},{name:"worker_recycle",title:"Recycle AFK worker",description:"MUTATING: terminate one fleet worker so its supervisor can replace the slot.",inputSchema:{worker:w.string().min(1)},invoke:({worker:t})=>e.workerStop({worker:t,recycle:!0})}]}function c1e(e){return[{name:"runner_list",title:"List AFK runners",description:"Return the canonical runner specification registry.",inputSchema:{},invoke:()=>e.runnerList()},{name:"runner_detect",title:"Detect AFK runner",description:"Resolve the runner selected by an explicit override or the current host environment.",inputSchema:{runner:w.string().min(1).optional()},invoke:({runner:t})=>e.runnerDetect({runner:t})},{name:"runner_steer",title:"Steer live AFK worker",description:"MUTATING: write a live-steer request into a running worker's next iteration.",inputSchema:{worker:w.string().min(1),text:w.string().min(1)},invoke:t=>e.runnerSteer(t)},{name:"steer_status",title:"Read steer status",description:"Return the live-steer status for a worker: none (no steer ever written), pending (written, not yet consumed), or consumed (consumed at a specific iteration).",inputSchema:{worker:w.string().min(1)},invoke:t=>e.steerStatus(t)},{name:"worker_request",title:"Dispatch worker with request",description:"MUTATING: dispatch a new worker and inject a special request into its spawn-time handoff.",inputSchema:{...ure,text:w.string().min(1)},invoke:t=>{let r;try{r=dre(t)}catch(n){return Promise.resolve(lre(n))}return e.workerRequest({...r,text:t.text})}}]}function l1e(e){return[{name:"statusline_aggregate",title:"Read statusline aggregate",description:"Return the project-side statusline aggregate (project, repo counters, docs drift, drain, Worker rows, aggregated AFK block, queue) as structured data, using the same collector cores and cache discipline as the command-backed statusLine. Host-side fields (session model/effort, context %, usage quotas) are out of scope.",inputSchema:{},invoke:()=>e.statuslineAggregate()}]}ao();d_();function u1e(e,t,r={}){let n=e==="confirm"?ma({state:"dangerous tool requires explicit confirmation",repair:{tool:t,args:{...r,confirmation:!0},why:"retry the same operation with explicit confirmation"}}):ma({state:"dangerous tool is denied by the configured posture",repair:nb("the configured posture deliberately forbids this tool")});return{refused:!0,posture:e,action:t,reason:n.prose,repair:n.repair,...n.repair==="none"?{repair_reason:n.repair_reason}:{}}}function d1e(e,t){return t==="allow"?e:e.map(r=>{if(!r.dangerClass)return r;if(t==="deny")return{...r,invoke:async i=>u1e("deny",r.name)};let n={...r.inputSchema,confirmation:w.boolean().optional()},o=r.invoke.bind(r);return{...r,inputSchema:n,invoke:async i=>{if(i.confirmation!==!0)return u1e("confirm",r.name,i);let{confirmation:s,...a}=i;return o(a)}}})}ao();function p1e(e){return[{name:"wait_start",title:"Start rsp wait",description:"MUTATING: spawn a detached rsp wait (pr | run | release | cmd) and return its registry id.",inputSchema:{kind:w.enum(["pr","run","release","cmd"]),target:w.string().min(1),timeout_ms:w.number().int().positive().optional(),reason:w.string().optional()},invoke:t=>e.waitStart(t)},{name:"wait_list",title:"List active rsp waits",description:"Return the active-wait registry from .red/tmp/waits.",inputSchema:{},invoke:()=>e.waitList()},{name:"wait_status",title:"Read rsp wait status",description:"Return the registry entry for a running wait or the sealed result envelope for a finished one.",inputSchema:{id:w.string().min(1)},invoke:({id:t})=>e.waitStatus({id:t})}]}ao();function f1e(e){return[{name:"worktree_list",title:"List disposable worktrees",description:"Enumerate every checkout under the disposable `.red/tmp/worktrees/*` lanes.",inputSchema:{},invoke:()=>e.worktreeList()},{name:"worktree_remove",title:"Remove disposable worktree",description:"MUTATING: remove one checkout under the disposable `.red/tmp/worktrees/*` lanes.",inputSchema:{path:w.string().min(1)},invoke:({path:t})=>e.worktreeRemove({path:t})}]}var eL="Call the redskilled MCP's `help` tool.\nFollow its guidance and invoke the returned `next` call.",pre=[{name:"drain",title:"Drain this project's queue",description:"Find the next action for starting or continuing a project drain.",body:eL},{name:"diagnose",title:"Diagnose redskilled",description:"Find the next action for understanding a redskilled problem.",body:eL},{name:"configure",title:"Configure redskilled",description:"Find the next action for changing project execution configuration.",body:eL},{name:"stop",title:"Stop project work",description:"Find the next action for stopping project work safely.",body:eL}];var m1e="rs_dev";function h1e(e,t="allow"){let r=[],n=[...DDe(e,()=>r),...ZDe(e),...XDe(e),...o1e(e),...t1e(e),...a1e(e),...c1e(e),...r1e(e),...e1e(e),...n1e(e),...$De(e),...NDe(e),...zDe(e),...f1e(e),...p1e(e),...s1e(e),...l1e(e),...i1e(e)];return r=d1e(qDe(n),t),r}Qt();function sw(e){return tn(JSON.parse(JSON.stringify(e??null)),{objectArrayColumns:!0,primitiveArrayColumns:!0})}var U1t=new Map([["drain","drain"],["project_drain","drain"],["project_stop","stop"],["project_status","status"],["status","status"]]),H1t=new Set(["target","runner","scope","registration"]);async function g1e(e,t,r){let n=U1t.get(t);if(n!=null){let o=Object.keys(r).filter(i=>!H1t.has(i));if(o.length>0)throw new Error(`the Project control surface cannot express ${JSON.stringify(o.sort())} for ${JSON.stringify(t)}`);return n==="status"?await e.control("status"):await e.control(n,q1t(r))}if(!B1t(t))throw new Error(`unsupported ACP Project capability ${JSON.stringify(t)}`);return await e.prompt(G1t(t,r))}function q1t(e){let t=e.target,r=e.runner,n=e.registration;return{...typeof t=="number"&&Number.isInteger(t)&&t>=0?{target:t}:{},...typeof r=="string"&&r.length>0?{runner:r}:{},...n!=null&&typeof n=="object"&&!Array.isArray(n)?{registration:n}:{}}}function G1t(e,t){return`/${e} ${JSON.stringify(t)}`}function B1t(e){return/^[a-z][a-z0-9_]*$/.test(e)&&!e.startsWith("private_")&&!e.includes("worker_birth")&&!e.includes("daemon_protocol")&&!e.includes("github_client")}fd();var aw="redskilled://lanes/events",W1t=1e3;function y1e(e,t,r={}){let n=r.bufferLimit??W1t,o=[],i=0,s,a=c=>{o.push(c.record),o.length>n&&o.splice(0,o.length-n),e.sendResourceUpdated({uri:aw})};return e.registerCapabilities({resources:{subscribe:!0}}),e.setRequestHandler(M_,()=>({resources:[{uri:aw,name:"Redskilled lane events",description:"Subscribe to receive AFK lane records (Worker landings, deaths, lost claims, supervisor halts) appended after subscription. Payloads are byte-compatible with the `logs` tool's CastleLaneRecord shape.",mimeType:"application/toon"}]})),e.setRequestHandler(D_,c=>{let l=fre(c);if(l!==aw)throw new Error(`unknown resource ${JSON.stringify(l)}`);let u=o.splice(0,o.length);return{contents:[{uri:aw,mimeType:"application/toon",text:sw({events:u})}]}}),e.setRequestHandler(sX,async c=>fre(c)!==aw?{}:(i+=1,i===1&&(s=await t.subscribe(a),t.start(r.intervalMs)),{})),e.setRequestHandler(aX,c=>fre(c)!==aw?{}:(i>0&&(i-=1),i===0&&(s?.(),s=void 0,t.stop()),{})),{poll:()=>t.poll(),stop:()=>{s?.(),s=void 0,t.stop()}}}function fre(e){let t=e?.params;return typeof t?.uri=="string"?t.uri:""}function x1e(e){let t=new Set,r,n,o=async()=>{let s=await e("events_since",r===void 0?{}:{cursor:r});if(!b1e(s)||typeof s.cursor!="string")throw new Error("redskilled ACP returned an invalid events_since envelope");let a=Array.isArray(s.lane_records)?s.lane_records.filter(b1e):[];return{cursor:s.cursor,lane_records:a}},i={async subscribe(s){return r===void 0&&(r=(await o()).cursor),t.add(s),()=>t.delete(s)},async poll(){if(t.size===0)return 0;let s=await o();r=s.cursor;for(let a of s.lane_records)for(let c of t)c({path:"redskilled-acp",record:a});return s.lane_records.length},start(s=1e3){n===void 0&&(n=setInterval(()=>void i.poll().catch(()=>{}),s),n.unref())},stop(){n!==void 0&&clearInterval(n),n=void 0,t.clear()}};return i}function b1e(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}ao();var mre="rs_github",S1e="github_request",tL=Ms.githubRequest;function hre(){return[{name:S1e,title:"Request the Project's forge",description:"MUTATING: forward one REST request to the Project's GitHub gateway. An observing method (GET, HEAD) is served from the daemon's Project cache and carries the age of what it served; concurrent identical reads share one upstream call. A mutating method is scheduled through the daemon's durable outbox and answers with its publication receipt. Paths are repository-relative \u2014 `issues/17` \u2014 or the full `repos/<owner>/<repo>/\u2026` form of this Project's own repository; another repository is refused.",method:tL,inputSchema:{method:w.enum(aPe),path:w.string().min(1),body:w.record(w.unknown()).optional(),headers:w.record(w.string()).optional()}}]}function k1e(e){return{request:{method:e.method,path:e.path,...e.body===void 0?{}:{body:e.body},...e.headers===void 0?{}:{headers:e.headers}}}}function gre(e){let t=new nw({name:mre,version:e.version}),r=t.registerTool.bind(t);for(let n of e.tools??hre())r(n.name,{title:n.title,description:n.description,inputSchema:n.inputSchema},async o=>({content:[{type:"text",text:sw(await e.invoke(n.method,k1e(o)))}]}));return t}var _0=WW("redskilled-mcp");function vcr(e=process.cwd(),t){let r=new nw({name:m1e,version:_0.version}),n=r.registerTool.bind(r),o=t??(async()=>{throw new Error("REDSKILLED_ACP_UNAVAILABLE: the stdio adapter has no ACP client")}),i={};for(let s of h1e(i))n(s.name,{title:s.title,description:s.description,inputSchema:s.inputSchema},async a=>({content:[{type:"text",text:sw(await o(s.name,a))}]}));for(let s of pre)r.registerPrompt(s.name,{title:s.title,description:s.description},async()=>({messages:[{role:"user",content:{type:"text",text:s.body}}]}));return y1e(r.server,x1e(o)),r}async function ldt(e,t=process.env,r=process.cwd()){let n=(t.RED_SKILLS_PROJECT_ROOT??t.CLAUDE_PROJECT_DIR??t.CODEX_PROJECT_DIR??t.OPENCODE_PROJECT_DIR??"").trim();if(n!=="")return v$(n);if(e.getClientCapabilities()?.roots!==void 0)try{let o=await e.listRoots();for(let i of o.roots)if(i.uri.startsWith("file:"))return v$(cdt(i.uri))}catch{}return v$(r)}async function udt(e){let t,r=new Promise(n=>{t=n});e.server.server.onclose=t,await e.server.connect(e.transport),await r}async function Ecr(){let e=process.cwd(),t,r,n=()=>(t??=ldt(r.server,process.env,e).then(i=>k7({cwd:i,name:"RedSkills GitHub MCP adapter",version:_0.version})),t);r=gre({version:_0.version,invoke:async(i,s)=>{if(i!==tL)throw new Error(`rs_github: no daemon method ${JSON.stringify(i)}`);return(await n()).github(s.request)}});let o=()=>{r.close()};process.once("SIGINT",o),process.once("SIGTERM",o);try{await udt({server:r,transport:new pC})}finally{if(t!==void 0)try{(await t).close()}catch{}process.removeListener("SIGINT",o),process.removeListener("SIGTERM",o)}}async function Rcr(){let e=process.cwd(),t,r,n=()=>(t??=ldt(r.server,process.env,e).then(i=>k7({cwd:i,name:"RedSkills MCP adapter",version:_0.version})),t);r=vcr(e,async(i,s)=>g1e(await n(),i,s));let o=()=>{r.close()};process.once("SIGINT",o),process.once("SIGTERM",o);try{await udt({server:r,transport:new pC})}finally{if(t!==void 0)try{(await t).close()}catch{}process.removeListener("SIGINT",o),process.removeListener("SIGTERM",o)}}var Tcr=`Usage: red-skills-redskilled-mcp [command]
440
440
 
441
441
  Commands:
442
442
  (none) serve the rs_dev MCP surface over stdio