@reddb-io/red-skills 4.1.17 → 4.1.18

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 Vdt=Object.create;var YW=Object.defineProperty;var Kdt=Object.getOwnPropertyDescriptor;var Zdt=Object.getOwnPropertyNames;var Jdt=Object.getPrototypeOf,Qdt=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)YW(e,r,{get:t[r],enumerable:!0})},Ydt=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of Zdt(t))!Qdt.call(e,o)&&o!==r&&YW(e,o,{get:()=>t[o],enumerable:!(n=Kdt(t,o))||n.enumerable});return e};var Ap=(e,t,r)=>(r=e!=null?Vdt(Jdt(e)):{},Ydt(t||!e||!e.__esModule?YW(r,"default",{value:e,enumerable:!0}):r,e));function XW(e){let t={app:e,version:Xdt(hk("__RED_BUILD_VERSION__",()=>"4.1.17")??"0.0.0-dev"),gitSha:hk("__RED_BUILD_GIT_SHA__",()=>"8b87457fe3ac2051f9d6df6a2bb1815f53ddb8f3")??"unknown",buildTime:hk("__RED_BUILD_TIME__",()=>"2026-08-21T03:49:58-03:00")??"unknown",bundleAsset:hk("__RED_BUNDLE_ASSET__",()=>"redskilled-mcp.bundle.min.mjs")??"unknown"},r=hk("__REDDB_SDK_VERSION__",()=>""),n=hk("__REDDB_BINARY_TAG__",()=>"");return r&&(t.reddbSdkVersion=r),n&&(t.reddbBinaryTag=n),t}function Xdt(e){return e.startsWith("v")?e.slice(1):e}function uSe(e){return`${e.app} ${e.version} ${e.gitSha}`}function hk(e,t){try{let r=t();return typeof r=="string"&&r.length>0?r:void 0}catch{return process.env[e.replace(/^__|__$/g,"")]}}var e4=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(Hy,e),Hy}var dSe,r4,n4,Hl,Bm,Hy,qy=p(()=>{r4=Object.freeze({status:"aborted"});n4=Symbol("zod_brand"),Hl=class extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}},Bm=class extends Error{constructor(t){super(`Encountered unidirectional transform during encode: ${t}`),this.name="ZodEncodeError"}};(dSe=globalThis).__zod_globalConfig??(dSe.__zod_globalConfig={});Hy=globalThis.__zod_globalConfig});var Re={};Vn(Re,{BIGINT_FORMAT_RANGES:()=>f4,Class:()=>i4,NUMBER_FORMAT_RANGES:()=>p4,aborted:()=>Zm,allowsEval:()=>c4,assert:()=>ipt,assertEqual:()=>tpt,assertIs:()=>npt,assertNever:()=>opt,assertNotEqual:()=>rpt,assignProp:()=>Vm,base64ToUint8Array:()=>fSe,base64urlToUint8Array:()=>_pt,cached:()=>yk,captureStackTrace:()=>A$,cleanEnum:()=>kpt,cleanRegex:()=>I0,clone:()=>Cs,cloneDef:()=>apt,createTransparentProxy:()=>fpt,defineLazy:()=>Jt,esc:()=>I$,escapeRegex:()=>Mc,explicitlyAborted:()=>m4,extend:()=>gpt,finalizeIssue:()=>Ps,floatSafeRemainder:()=>s4,getElementAtPath:()=>cpt,getEnumValues:()=>P0,getLengthableOrigin:()=>$0,getParsedType:()=>ppt,getSizableOrigin:()=>O0,hexToUint8Array:()=>vpt,isObject:()=>Gy,isPlainObject:()=>Km,issue:()=>bk,joinValues:()=>ne,jsonStringifyReplacer:()=>gk,merge:()=>bpt,mergeDefs:()=>Op,normalizeParams:()=>Ie,nullish:()=>Wm,numKeys:()=>dpt,objectClone:()=>spt,omit:()=>hpt,optionalKeys:()=>d4,parsedType:()=>Ee,partial:()=>xpt,pick:()=>mpt,prefixIssues:()=>ca,primitiveTypes:()=>u4,promiseAllObject:()=>lpt,propertyKeyTypes:()=>A0,randomString:()=>upt,required:()=>Spt,safeExtend:()=>ypt,shallowClone:()=>l4,slugify:()=>a4,stringifyPrimitive:()=>ve,uint8ArrayToBase64:()=>mSe,uint8ArrayToBase64url:()=>wpt,uint8ArrayToHex:()=>Ept,unwrapMessage:()=>C0});function tpt(e){return e}function rpt(e){return e}function npt(e){}function opt(e){throw new Error("Unexpected value in exhaustive check")}function ipt(e){}function P0(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 gk(e,t){return typeof t=="bigint"?t.toString():t}function yk(e){return{get value(){{let r=e();return Object.defineProperty(this,"value",{value:r}),r}throw new Error("cached value already set")}}}function Wm(e){return e==null}function I0(e){let t=e.startsWith("^")?1:0,r=e.endsWith("$")?e.length-1:e.length;return e.slice(t,r)}function s4(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!==pSe)return n===void 0&&(n=pSe,n=r()),n},set(o){Object.defineProperty(e,t,{value:o})},configurable:!0})}function spt(e){return Object.create(Object.getPrototypeOf(e),Object.getOwnPropertyDescriptors(e))}function Vm(e,t,r){Object.defineProperty(e,t,{value:r,writable:!0,enumerable:!0,configurable:!0})}function Op(...e){let t={};for(let r of e){let n=Object.getOwnPropertyDescriptors(r);Object.assign(t,n)}return Object.defineProperties({},t)}function apt(e){return Op(e._zod.def)}function cpt(e,t){return t?t.reduce((r,n)=>r?.[n],e):e}function lpt(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 upt(e=10){let t="abcdefghijklmnopqrstuvwxyz",r="";for(let n=0;n<e;n++)r+=t[Math.floor(Math.random()*t.length)];return r}function I$(e){return JSON.stringify(e)}function a4(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}function Gy(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function Km(e){if(Gy(e)===!1)return!1;let t=e.constructor;if(t===void 0||typeof t!="function")return!0;let r=t.prototype;return!(Gy(r)===!1||Object.prototype.hasOwnProperty.call(r,"isPrototypeOf")===!1)}function l4(e){return Km(e)?{...e}:Array.isArray(e)?[...e]:e instanceof Map?new Map(e):e instanceof Set?new Set(e):e}function dpt(e){let t=0;for(let r in e)Object.prototype.hasOwnProperty.call(e,r)&&t++;return t}function Mc(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 fpt(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 d4(e){return Object.keys(e).filter(t=>e[t]._zod.optin==="optional"&&e[t]._zod.optout==="optional")}function mpt(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=Op(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 Vm(this,"shape",s),s},checks:[]});return Cs(e,i)}function hpt(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=Op(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 Vm(this,"shape",s),s},checks:[]});return Cs(e,i)}function gpt(e,t){if(!Km(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=Op(e._zod.def,{get shape(){let i={...e._zod.def.shape,...t};return Vm(this,"shape",i),i}});return Cs(e,o)}function ypt(e,t){if(!Km(t))throw new Error("Invalid input to safeExtend: expected a plain object");let r=Op(e._zod.def,{get shape(){let n={...e._zod.def.shape,...t};return Vm(this,"shape",n),n}});return Cs(e,r)}function bpt(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=Op(e._zod.def,{get shape(){let n={...e._zod.def.shape,...t._zod.def.shape};return Vm(this,"shape",n),n},get catchall(){return t._zod.def.catchall},checks:t._zod.def.checks??[]});return Cs(e,r)}function xpt(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=Op(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 Vm(this,"shape",c),c},checks:[]});return Cs(t,s)}function Spt(e,t,r){let n=Op(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 Vm(this,"shape",i),i}});return Cs(t,n)}function Zm(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 m4(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 C0(e){return typeof e=="string"?e:e?.message}function Ps(e,t,r){let n=e.message?e.message:C0(e.inst?._zod.def?.error?.(e))??C0(t?.error?.(e))??C0(r.customError?.(e))??C0(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 O0(e){return e instanceof Set?"set":e instanceof Map?"map":e instanceof File?"file":"unknown"}function $0(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 bk(...e){let[t,r,n]=e;return typeof t=="string"?{message:t,code:"custom",input:r,inst:n}:{...t}}function kpt(e){return Object.entries(e).filter(([t,r])=>Number.isNaN(Number.parseInt(t,10))).map(t=>t[1])}function fSe(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 mSe(e){let t="";for(let r=0;r<e.length;r++)t+=String.fromCharCode(e[r]);return btoa(t)}function _pt(e){let t=e.replace(/-/g,"+").replace(/_/g,"/"),r="=".repeat((4-t.length%4)%4);return fSe(t+r)}function wpt(e){return mSe(e).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}function vpt(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 Ept(e){return Array.from(e).map(t=>t.toString(16).padStart(2,"0")).join("")}var pSe,A$,c4,ppt,A0,u4,p4,f4,i4,ot=p(()=>{qy();pSe=Symbol("evaluating");A$="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};c4=yk(()=>{if(Hy.jitless||typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{let e=Function;return new e(""),!0}catch{return!1}});ppt=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}`)}},A0=new Set(["string","number","symbol"]),u4=new Set(["string","number","bigint","boolean","symbol","undefined"]);p4={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]},f4={int64:[BigInt("-9223372036854775808"),BigInt("9223372036854775807")],uint64:[BigInt(0),BigInt("18446744073709551615")]};i4=class{constructor(...t){}}});function D0(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 N0(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 h4(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 gSe(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 g4(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 ${gSe(n.path)}`);return t.join(`
3
+ var Vdt=Object.create;var YW=Object.defineProperty;var Kdt=Object.getOwnPropertyDescriptor;var Zdt=Object.getOwnPropertyNames;var Jdt=Object.getPrototypeOf,Qdt=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)YW(e,r,{get:t[r],enumerable:!0})},Ydt=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of Zdt(t))!Qdt.call(e,o)&&o!==r&&YW(e,o,{get:()=>t[o],enumerable:!(n=Kdt(t,o))||n.enumerable});return e};var Ap=(e,t,r)=>(r=e!=null?Vdt(Jdt(e)):{},Ydt(t||!e||!e.__esModule?YW(r,"default",{value:e,enumerable:!0}):r,e));function XW(e){let t={app:e,version:Xdt(hk("__RED_BUILD_VERSION__",()=>"4.1.18")??"0.0.0-dev"),gitSha:hk("__RED_BUILD_GIT_SHA__",()=>"58e5f9e840fdc765140bda1632fecb43717d57bf")??"unknown",buildTime:hk("__RED_BUILD_TIME__",()=>"2026-08-21T04:08:28-03:00")??"unknown",bundleAsset:hk("__RED_BUNDLE_ASSET__",()=>"redskilled-mcp.bundle.min.mjs")??"unknown"},r=hk("__REDDB_SDK_VERSION__",()=>""),n=hk("__REDDB_BINARY_TAG__",()=>"");return r&&(t.reddbSdkVersion=r),n&&(t.reddbBinaryTag=n),t}function Xdt(e){return e.startsWith("v")?e.slice(1):e}function uSe(e){return`${e.app} ${e.version} ${e.gitSha}`}function hk(e,t){try{let r=t();return typeof r=="string"&&r.length>0?r:void 0}catch{return process.env[e.replace(/^__|__$/g,"")]}}var e4=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(Hy,e),Hy}var dSe,r4,n4,Hl,Bm,Hy,qy=p(()=>{r4=Object.freeze({status:"aborted"});n4=Symbol("zod_brand"),Hl=class extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}},Bm=class extends Error{constructor(t){super(`Encountered unidirectional transform during encode: ${t}`),this.name="ZodEncodeError"}};(dSe=globalThis).__zod_globalConfig??(dSe.__zod_globalConfig={});Hy=globalThis.__zod_globalConfig});var Re={};Vn(Re,{BIGINT_FORMAT_RANGES:()=>f4,Class:()=>i4,NUMBER_FORMAT_RANGES:()=>p4,aborted:()=>Zm,allowsEval:()=>c4,assert:()=>ipt,assertEqual:()=>tpt,assertIs:()=>npt,assertNever:()=>opt,assertNotEqual:()=>rpt,assignProp:()=>Vm,base64ToUint8Array:()=>fSe,base64urlToUint8Array:()=>_pt,cached:()=>yk,captureStackTrace:()=>A$,cleanEnum:()=>kpt,cleanRegex:()=>I0,clone:()=>Cs,cloneDef:()=>apt,createTransparentProxy:()=>fpt,defineLazy:()=>Jt,esc:()=>I$,escapeRegex:()=>Mc,explicitlyAborted:()=>m4,extend:()=>gpt,finalizeIssue:()=>Ps,floatSafeRemainder:()=>s4,getElementAtPath:()=>cpt,getEnumValues:()=>P0,getLengthableOrigin:()=>$0,getParsedType:()=>ppt,getSizableOrigin:()=>O0,hexToUint8Array:()=>vpt,isObject:()=>Gy,isPlainObject:()=>Km,issue:()=>bk,joinValues:()=>ne,jsonStringifyReplacer:()=>gk,merge:()=>bpt,mergeDefs:()=>Op,normalizeParams:()=>Ie,nullish:()=>Wm,numKeys:()=>dpt,objectClone:()=>spt,omit:()=>hpt,optionalKeys:()=>d4,parsedType:()=>Ee,partial:()=>xpt,pick:()=>mpt,prefixIssues:()=>ca,primitiveTypes:()=>u4,promiseAllObject:()=>lpt,propertyKeyTypes:()=>A0,randomString:()=>upt,required:()=>Spt,safeExtend:()=>ypt,shallowClone:()=>l4,slugify:()=>a4,stringifyPrimitive:()=>ve,uint8ArrayToBase64:()=>mSe,uint8ArrayToBase64url:()=>wpt,uint8ArrayToHex:()=>Ept,unwrapMessage:()=>C0});function tpt(e){return e}function rpt(e){return e}function npt(e){}function opt(e){throw new Error("Unexpected value in exhaustive check")}function ipt(e){}function P0(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 gk(e,t){return typeof t=="bigint"?t.toString():t}function yk(e){return{get value(){{let r=e();return Object.defineProperty(this,"value",{value:r}),r}throw new Error("cached value already set")}}}function Wm(e){return e==null}function I0(e){let t=e.startsWith("^")?1:0,r=e.endsWith("$")?e.length-1:e.length;return e.slice(t,r)}function s4(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!==pSe)return n===void 0&&(n=pSe,n=r()),n},set(o){Object.defineProperty(e,t,{value:o})},configurable:!0})}function spt(e){return Object.create(Object.getPrototypeOf(e),Object.getOwnPropertyDescriptors(e))}function Vm(e,t,r){Object.defineProperty(e,t,{value:r,writable:!0,enumerable:!0,configurable:!0})}function Op(...e){let t={};for(let r of e){let n=Object.getOwnPropertyDescriptors(r);Object.assign(t,n)}return Object.defineProperties({},t)}function apt(e){return Op(e._zod.def)}function cpt(e,t){return t?t.reduce((r,n)=>r?.[n],e):e}function lpt(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 upt(e=10){let t="abcdefghijklmnopqrstuvwxyz",r="";for(let n=0;n<e;n++)r+=t[Math.floor(Math.random()*t.length)];return r}function I$(e){return JSON.stringify(e)}function a4(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}function Gy(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function Km(e){if(Gy(e)===!1)return!1;let t=e.constructor;if(t===void 0||typeof t!="function")return!0;let r=t.prototype;return!(Gy(r)===!1||Object.prototype.hasOwnProperty.call(r,"isPrototypeOf")===!1)}function l4(e){return Km(e)?{...e}:Array.isArray(e)?[...e]:e instanceof Map?new Map(e):e instanceof Set?new Set(e):e}function dpt(e){let t=0;for(let r in e)Object.prototype.hasOwnProperty.call(e,r)&&t++;return t}function Mc(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 fpt(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 d4(e){return Object.keys(e).filter(t=>e[t]._zod.optin==="optional"&&e[t]._zod.optout==="optional")}function mpt(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=Op(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 Vm(this,"shape",s),s},checks:[]});return Cs(e,i)}function hpt(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=Op(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 Vm(this,"shape",s),s},checks:[]});return Cs(e,i)}function gpt(e,t){if(!Km(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=Op(e._zod.def,{get shape(){let i={...e._zod.def.shape,...t};return Vm(this,"shape",i),i}});return Cs(e,o)}function ypt(e,t){if(!Km(t))throw new Error("Invalid input to safeExtend: expected a plain object");let r=Op(e._zod.def,{get shape(){let n={...e._zod.def.shape,...t};return Vm(this,"shape",n),n}});return Cs(e,r)}function bpt(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=Op(e._zod.def,{get shape(){let n={...e._zod.def.shape,...t._zod.def.shape};return Vm(this,"shape",n),n},get catchall(){return t._zod.def.catchall},checks:t._zod.def.checks??[]});return Cs(e,r)}function xpt(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=Op(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 Vm(this,"shape",c),c},checks:[]});return Cs(t,s)}function Spt(e,t,r){let n=Op(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 Vm(this,"shape",i),i}});return Cs(t,n)}function Zm(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 m4(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 C0(e){return typeof e=="string"?e:e?.message}function Ps(e,t,r){let n=e.message?e.message:C0(e.inst?._zod.def?.error?.(e))??C0(t?.error?.(e))??C0(r.customError?.(e))??C0(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 O0(e){return e instanceof Set?"set":e instanceof Map?"map":e instanceof File?"file":"unknown"}function $0(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 bk(...e){let[t,r,n]=e;return typeof t=="string"?{message:t,code:"custom",input:r,inst:n}:{...t}}function kpt(e){return Object.entries(e).filter(([t,r])=>Number.isNaN(Number.parseInt(t,10))).map(t=>t[1])}function fSe(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 mSe(e){let t="";for(let r=0;r<e.length;r++)t+=String.fromCharCode(e[r]);return btoa(t)}function _pt(e){let t=e.replace(/-/g,"+").replace(/_/g,"/"),r="=".repeat((4-t.length%4)%4);return fSe(t+r)}function wpt(e){return mSe(e).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}function vpt(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 Ept(e){return Array.from(e).map(t=>t.toString(16).padStart(2,"0")).join("")}var pSe,A$,c4,ppt,A0,u4,p4,f4,i4,ot=p(()=>{qy();pSe=Symbol("evaluating");A$="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};c4=yk(()=>{if(Hy.jitless||typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{let e=Function;return new e(""),!0}catch{return!1}});ppt=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}`)}},A0=new Set(["string","number","symbol"]),u4=new Set(["string","number","bigint","boolean","symbol","undefined"]);p4={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]},f4={int64:[BigInt("-9223372036854775808"),BigInt("9223372036854775807")],uint64:[BigInt(0),BigInt("18446744073709551615")]};i4=class{constructor(...t){}}});function D0(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 N0(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 h4(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 gSe(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 g4(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 ${gSe(n.path)}`);return t.join(`
4
4
  `)}var hSe,M0,la,y4=p(()=>{qy();ot();hSe=(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,gk,2),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},M0=K("$ZodError",hSe),la=K("$ZodError",hSe,{Parent:Error})});var xk,O$,Sk,$$,kk,b4,_k,x4,M$,Tpt,D$,Cpt,N$,Ppt,z$,Ipt,L$,Apt,F$,Opt,j$,$pt,U$,Mpt,S4=p(()=>{qy();y4();ot();xk=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 A$(a,o?.callee),a}return s.value},O$=xk(la),Sk=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 A$(a,o?.callee),a}return s.value},$$=Sk(la),kk=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??M0)(i.issues.map(s=>Ps(s,o,yo())))}:{success:!0,data:i.value}},b4=kk(la),_k=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}},x4=_k(la),M$=e=>(t,r,n)=>{let o=n?{...n,direction:"backward"}:{direction:"backward"};return xk(e)(t,r,o)},Tpt=M$(la),D$=e=>(t,r,n)=>xk(e)(t,r,n),Cpt=D$(la),N$=e=>async(t,r,n)=>{let o=n?{...n,direction:"backward"}:{direction:"backward"};return Sk(e)(t,r,o)},Ppt=N$(la),z$=e=>async(t,r,n)=>Sk(e)(t,r,n),Ipt=z$(la),L$=e=>(t,r,n)=>{let o=n?{...n,direction:"backward"}:{direction:"backward"};return kk(e)(t,r,o)},Apt=L$(la),F$=e=>(t,r,n)=>kk(e)(t,r,n),Opt=F$(la),j$=e=>async(t,r,n)=>{let o=n?{...n,direction:"backward"}:{direction:"backward"};return _k(e)(t,r,o)},$pt=j$(la),U$=e=>async(t,r,n)=>_k(e)(t,r,n),Mpt=U$(la)});var Va={};Vn(Va,{base64:()=>N4,base64url:()=>H$,bigint:()=>q4,boolean:()=>B4,browserEmail:()=>Hpt,cidrv4:()=>M4,cidrv6:()=>D4,cuid:()=>k4,cuid2:()=>_4,date:()=>F4,datetime:()=>U4,domain:()=>Bpt,duration:()=>T4,e164:()=>L4,email:()=>P4,emoji:()=>I4,extendedDuration:()=>Dpt,guid:()=>C4,hex:()=>Wpt,hostname:()=>Gpt,html5Email:()=>Fpt,httpProtocol:()=>z4,idnEmail:()=>Upt,integer:()=>G4,ipv4:()=>A4,ipv6:()=>O4,ksuid:()=>E4,lowercase:()=>K4,mac:()=>$4,md5_base64:()=>Kpt,md5_base64url:()=>Zpt,md5_hex:()=>Vpt,nanoid:()=>R4,null:()=>W4,number:()=>q$,rfc5322Email:()=>jpt,sha1_base64:()=>Qpt,sha1_base64url:()=>Ypt,sha1_hex:()=>Jpt,sha256_base64:()=>eft,sha256_base64url:()=>tft,sha256_hex:()=>Xpt,sha384_base64:()=>nft,sha384_base64url:()=>oft,sha384_hex:()=>rft,sha512_base64:()=>sft,sha512_base64url:()=>aft,sha512_hex:()=>ift,string:()=>H4,time:()=>j4,ulid:()=>w4,undefined:()=>V4,unicodeEmail:()=>ySe,uppercase:()=>Z4,uuid:()=>By,uuid4:()=>Npt,uuid6:()=>zpt,uuid7:()=>Lpt,xid:()=>v4});function I4(){return new RegExp(qpt,"u")}function xSe(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 j4(e){return new RegExp(`^${xSe(e)}$`)}function U4(e){let t=xSe({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(`^${bSe}T(?:${n})$`)}function z0(e,t){return new RegExp(`^[A-Za-z0-9+/]{${e}}${t}$`)}function L0(e){return new RegExp(`^[A-Za-z0-9_-]{${e}}$`)}var k4,_4,w4,v4,E4,R4,T4,Dpt,C4,By,Npt,zpt,Lpt,P4,Fpt,jpt,ySe,Upt,Hpt,qpt,A4,O4,$4,M4,D4,N4,H$,Gpt,Bpt,z4,L4,bSe,F4,H4,q4,G4,q$,B4,W4,V4,K4,Z4,Wpt,Vpt,Kpt,Zpt,Jpt,Qpt,Ypt,Xpt,eft,tft,rft,nft,oft,ift,sft,aft,G$=p(()=>{ot();k4=/^[cC][0-9a-z]{6,}$/,_4=/^[0-9a-z]+$/,w4=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,v4=/^[0-9a-vA-V]{20}$/,E4=/^[A-Za-z0-9]{27}$/,R4=/^[a-zA-Z0-9_-]{21}$/,T4=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,Dpt=/^[-+]?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)?)??$/,C4=/^([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})$/,By=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)$/,Npt=By(4),zpt=By(6),Lpt=By(7),P4=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,Fpt=/^[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])?)*$/,jpt=/^(([^<>()\[\]\\.,;:\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,}))$/,ySe=/^[^\s@"]{1,64}@[^\s@]{1,255}$/u,Upt=ySe,Hpt=/^[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])?)*$/,qpt="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";A4=/^(?:(?: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])$/,O4=/^(([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}|:))$/,$4=e=>{let t=Mc(e??":");return new RegExp(`^(?:[0-9A-F]{2}${t}){5}[0-9A-F]{2}$|^(?:[0-9a-f]{2}${t}){5}[0-9a-f]{2}$`)},M4=/^((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])$/,D4=/^(([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])$/,N4=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,H$=/^[A-Za-z0-9_-]*$/,Gpt=/^(?=.{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])?)*\.?$/,Bpt=/^([a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?\.)+[a-zA-Z]{2,}$/,z4=/^https?$/,L4=/^\+[1-9]\d{6,14}$/,bSe="(?:(?:\\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])))",F4=new RegExp(`^${bSe}$`);H4=e=>{let t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??""}}`:"[\\s\\S]*";return new RegExp(`^${t}$`)},q4=/^-?\d+n?$/,G4=/^-?\d+$/,q$=/^-?\d+(?:\.\d+)?$/,B4=/^(?:true|false)$/i,W4=/^null$/i,V4=/^undefined$/i,K4=/^[^A-Z]*$/,Z4=/^[^a-z]*$/,Wpt=/^[0-9a-fA-F]*$/;Vpt=/^[0-9a-fA-F]{32}$/,Kpt=z0(22,"=="),Zpt=L0(22),Jpt=/^[0-9a-fA-F]{40}$/,Qpt=z0(27,"="),Ypt=L0(27),Xpt=/^[0-9a-fA-F]{64}$/,eft=z0(43,"="),tft=L0(43),rft=/^[0-9a-fA-F]{96}$/,nft=z0(64,""),oft=L0(64),ift=/^[0-9a-fA-F]{128}$/,sft=z0(86,"=="),aft=L0(86)});function SSe(e,t,r){e.issues.length&&t.issues.push(...ca(r,e.issues))}var un,kSe,B$,W$,J4,Q4,Y4,X4,eV,tV,rV,nV,oV,wk,iV,sV,aV,cV,lV,uV,dV,pV,fV,V$=p(()=>{qy();G$();ot();un=K("$ZodCheck",(e,t)=>{var r;e._zod??(e._zod={}),e._zod.def=t,(r=e._zod).onattach??(r.onattach=[])}),kSe={number:"number",bigint:"bigint",object:"date"},B$=K("$ZodCheckLessThan",(e,t)=>{un.init(e,t);let r=kSe[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})}}),W$=K("$ZodCheckGreaterThan",(e,t)=>{un.init(e,t);let r=kSe[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})}}),J4=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):s4(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})}}),Q4=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]=p4[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=G4)}),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})}}),Y4=K("$ZodCheckBigIntFormat",(e,t)=>{un.init(e,t);let[r,n]=f4[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})}}),X4=K("$ZodCheckMaxSize",(e,t)=>{var r;un.init(e,t),(r=e._zod.def).when??(r.when=n=>{let o=n.value;return!Wm(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:O0(o),code:"too_big",maximum:t.maximum,inclusive:!0,input:o,inst:e,continue:!t.abort})}}),eV=K("$ZodCheckMinSize",(e,t)=>{var r;un.init(e,t),(r=e._zod.def).when??(r.when=n=>{let o=n.value;return!Wm(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:O0(o),code:"too_small",minimum:t.minimum,inclusive:!0,input:o,inst:e,continue:!t.abort})}}),tV=K("$ZodCheckSizeEquals",(e,t)=>{var r;un.init(e,t),(r=e._zod.def).when??(r.when=n=>{let o=n.value;return!Wm(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:O0(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})}}),rV=K("$ZodCheckMaxLength",(e,t)=>{var r;un.init(e,t),(r=e._zod.def).when??(r.when=n=>{let o=n.value;return!Wm(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=$0(o);n.issues.push({origin:s,code:"too_big",maximum:t.maximum,inclusive:!0,input:o,inst:e,continue:!t.abort})}}),nV=K("$ZodCheckMinLength",(e,t)=>{var r;un.init(e,t),(r=e._zod.def).when??(r.when=n=>{let o=n.value;return!Wm(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=$0(o);n.issues.push({origin:s,code:"too_small",minimum:t.minimum,inclusive:!0,input:o,inst:e,continue:!t.abort})}}),oV=K("$ZodCheckLengthEquals",(e,t)=>{var r;un.init(e,t),(r=e._zod.def).when??(r.when=n=>{let o=n.value;return!Wm(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=$0(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})}}),wk=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=()=>{})}),iV=K("$ZodCheckRegex",(e,t)=>{wk.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})}}),sV=K("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=K4),wk.init(e,t)}),aV=K("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=Z4),wk.init(e,t)}),cV=K("$ZodCheckIncludes",(e,t)=>{un.init(e,t);let r=Mc(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})}}),lV=K("$ZodCheckStartsWith",(e,t)=>{un.init(e,t);let r=new RegExp(`^${Mc(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})}}),uV=K("$ZodCheckEndsWith",(e,t)=>{un.init(e,t);let r=new RegExp(`.*${Mc(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})}});dV=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=>SSe(o,r,t.property));SSe(n,r,t.property)}}),pV=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})}}),fV=K("$ZodCheckOverwrite",(e,t)=>{un.init(e,t),e._zod.check=r=>{r.value=t.tx(r.value)}})});var F0,mV=p(()=>{F0=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 hV,gV=p(()=>{hV={major:4,minor:4,patch:3}});function LV(e){if(e==="")return!0;if(/\s/.test(e)||e.length%4!==0)return!1;try{return atob(e),!0}catch{return!1}}function zSe(e){if(!H$.test(e))return!1;let t=e.replace(/[-_]/g,n=>n==="-"?"+":"/"),r=t.padEnd(Math.ceil(t.length/4)*4,"=");return LV(r)}function LSe(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 wSe(e,t,r){e.issues.length&&t.issues.push(...ca(r,e.issues)),t.value[r]=e.value}function Q$(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 FSe(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=d4(e.shape);return{...e,keys:t,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(r)}}function jSe(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(y=>Q$(y,r,f,t,u,d))):Q$(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 vSe(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=>!Zm(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 ESe(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 yV(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(Km(e)&&Km(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=yV(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=yV(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 RSe(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}),Zm(e))return e;let s=yV(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 TSe(e,t){for(let r=e.length-1;r>=0;r--)if(e[r]._zod[t]!=="optional")return r+1;return 0}function CSe(e,t,r){e.issues.length&&t.issues.push(...ca(r,e.issues)),t.value[r]=e.value}function PSe(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 ISe(e,t,r,n,o,i,s){e.issues.length&&(A0.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&&(A0.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 ASe(e,t){e.issues.length&&t.issues.push(...e.issues),t.value.add(e.value)}function OSe(e,t){return t===void 0&&(e.issues.length||e.fallback)?{issues:[],value:void 0}:e}function $Se(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}function MSe(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 K$(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 Z$(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=>J$(e,i,t.out,r)):J$(e,o,t.out,r)}else{let o=t.reverseTransform(e.value,e);return o instanceof Promise?o.then(i=>J$(e,i,t.in,r)):J$(e,o,t.in,r)}}function J$(e,t,r,n){return e.issues.length?(e.aborted=!0,e):r._zod.run({value:t,issues:e.issues},n)}function DSe(e){return e.value=Object.freeze(e.value),e}function NSe(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(bk(o))}}var At,Wy,Qr,bV,xV,SV,kV,_V,wV,vV,EV,RV,TV,CV,PV,IV,AV,OV,$V,MV,DV,NV,zV,FV,jV,UV,HV,qV,Y$,GV,j0,X$,BV,WV,VV,KV,ZV,JV,QV,YV,XV,e6,USe,t6,U0,r6,n6,o6,eM,i6,s6,a6,c6,l6,u6,d6,tM,p6,f6,m6,h6,g6,y6,b6,x6,rM,H0,S6,k6,_6,w6,v6,E6,R6,T6=p(()=>{V$();qy();mV();S4();G$();ot();gV();ot();At=K("$ZodType",(e,t)=>{var r;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=hV;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=Zm(s),u;for(let d of a){if(d._zod.def.when){if(m4(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=Zm(s,f)))});else{if(s.issues.length===f)continue;l||(l=Zm(s,f))}}return u?u.then(()=>s):s},i=(s,a,c)=>{if(Zm(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=b4(e,o);return i.success?{value:i.data}:{issues:i.error?.issues}}catch{return x4(e,o).then(s=>s.success?{value:s.data}:{issues:s.error?.issues})}},vendor:"zod",version:1}))}),Wy=K("$ZodString",(e,t)=>{At.init(e,t),e._zod.pattern=[...e?._zod.bag?.patterns??[]].pop()??H4(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}}),Qr=K("$ZodStringFormat",(e,t)=>{wk.init(e,t),Wy.init(e,t)}),bV=K("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=C4),Qr.init(e,t)}),xV=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=By(n))}else t.pattern??(t.pattern=By());Qr.init(e,t)}),SV=K("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=P4),Qr.init(e,t)}),kV=K("$ZodURL",(e,t)=>{Qr.init(e,t),e._zod.check=r=>{try{let n=r.value.trim();if(!t.normalize&&t.protocol?.source===z4.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})}}}),_V=K("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=I4()),Qr.init(e,t)}),wV=K("$ZodNanoID",(e,t)=>{t.pattern??(t.pattern=R4),Qr.init(e,t)}),vV=K("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=k4),Qr.init(e,t)}),EV=K("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=_4),Qr.init(e,t)}),RV=K("$ZodULID",(e,t)=>{t.pattern??(t.pattern=w4),Qr.init(e,t)}),TV=K("$ZodXID",(e,t)=>{t.pattern??(t.pattern=v4),Qr.init(e,t)}),CV=K("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=E4),Qr.init(e,t)}),PV=K("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=U4(t)),Qr.init(e,t)}),IV=K("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=F4),Qr.init(e,t)}),AV=K("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=j4(t)),Qr.init(e,t)}),OV=K("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=T4),Qr.init(e,t)}),$V=K("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=A4),Qr.init(e,t),e._zod.bag.format="ipv4"}),MV=K("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=O4),Qr.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})}}}),DV=K("$ZodMAC",(e,t)=>{t.pattern??(t.pattern=$4(t.delimiter)),Qr.init(e,t),e._zod.bag.format="mac"}),NV=K("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=M4),Qr.init(e,t)}),zV=K("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=D4),Qr.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})}}});FV=K("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=N4),Qr.init(e,t),e._zod.bag.contentEncoding="base64",e._zod.check=r=>{LV(r.value)||r.issues.push({code:"invalid_format",format:"base64",input:r.value,inst:e,continue:!t.abort})}});jV=K("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=H$),Qr.init(e,t),e._zod.bag.contentEncoding="base64url",e._zod.check=r=>{zSe(r.value)||r.issues.push({code:"invalid_format",format:"base64url",input:r.value,inst:e,continue:!t.abort})}}),UV=K("$ZodE164",(e,t)=>{t.pattern??(t.pattern=L4),Qr.init(e,t)});HV=K("$ZodJWT",(e,t)=>{Qr.init(e,t),e._zod.check=r=>{LSe(r.value,t.alg)||r.issues.push({code:"invalid_format",format:"jwt",input:r.value,inst:e,continue:!t.abort})}}),qV=K("$ZodCustomStringFormat",(e,t)=>{Qr.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})}}),Y$=K("$ZodNumber",(e,t)=>{At.init(e,t),e._zod.pattern=e._zod.bag.pattern??q$,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}}),GV=K("$ZodNumberFormat",(e,t)=>{Q4.init(e,t),Y$.init(e,t)}),j0=K("$ZodBoolean",(e,t)=>{At.init(e,t),e._zod.pattern=B4,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}}),X$=K("$ZodBigInt",(e,t)=>{At.init(e,t),e._zod.pattern=q4,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}}),BV=K("$ZodBigIntFormat",(e,t)=>{Y4.init(e,t),X$.init(e,t)}),WV=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}}),VV=K("$ZodUndefined",(e,t)=>{At.init(e,t),e._zod.pattern=V4,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}}),KV=K("$ZodNull",(e,t)=>{At.init(e,t),e._zod.pattern=W4,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}}),ZV=K("$ZodAny",(e,t)=>{At.init(e,t),e._zod.parse=r=>r}),JV=K("$ZodUnknown",(e,t)=>{At.init(e,t),e._zod.parse=r=>r}),QV=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)}),YV=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}}),XV=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}});e6=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=>wSe(l,r,s))):wSe(c,r,s)}return i.length?Promise.all(i).then(()=>r):r}});USe=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=yk(()=>FSe(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=Gy,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],y=m._zod.optin==="optional",S=m._zod.optout==="optional",_=m._zod.run({value:l[f],issues:[]},c);_ instanceof Promise?u.push(_.then(R=>Q$(R,a,f,l,y,S))):Q$(_,a,f,l,y,S)}return i?jSe(u,l,a,c,n.value,e):u.length?Promise.all(u).then(()=>a):a}}),t6=K("$ZodObjectJIT",(e,t)=>{USe.init(e,t);let r=e._zod.parse,n=yk(()=>FSe(t)),o=f=>{let m=new F0(["shape","payload","ctx"]),y=n.value,S=C=>{let O=I$(C);return`shape[${O}]._zod.run({ value: input[${O}], issues: [] }, ctx)`};m.write("const input = payload.value;");let _=Object.create(null),R=0;for(let C of y.keys)_[C]=`key_${R++}`;m.write("const newResult = {};");for(let C of y.keys){let O=_[C],M=I$(C),z=f[C],F=z?._zod?.optin==="optional",H=z?._zod?.optout==="optional";m.write(`const ${O} = ${S(C)};`),F&&H?m.write(`
@@ -441,7 +441,7 @@ naming the step that went inert.
441
441
  --demand-deadline-ms <n> how long the probe waits for the daemon's poll and
442
442
  the Worker it justifies (default: 60000)
443
443
  `});e4();import{connect as Z0t}from"node:net";import{Readable as J0t,Writable as Q0t}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"},t4={cancel_request:"$/cancel_request"};uR();uR();var ave=Symbol("skippedItem");function b(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 cve(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=cve(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=cve(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(ave)).transform(t=>t.filter(r=>r!==ave))}var th=be([rt(),g()]).nullable(),Ar=g(),fZ=x({sessionId:Ar,path:g(),content:g(),_meta:b(P(g(),T()).nullish(),()=>{})}),mZ=x({sessionId:Ar,path:g(),line:b(fr().gte(0).max(4294967295,{error:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),()=>{}),limit:b(fr().gte(0).max(4294967295,{error:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),()=>{}),_meta:b(P(g(),T()).nullish(),()=>{})}),hZ=g(),lve=be([$("read"),$("edit"),$("delete"),$("move"),$("search"),$("execute"),$("think"),$("fetch"),$("switch_mode"),$("other")]),uve=be([$("pending"),$("in_progress"),$("completed"),$("failed")]),Gmt=be([$("assistant"),$("user")]),dR=x({audience:b(Ve(Gmt).nullish(),()=>{}),lastModified:b(g().nullish(),()=>{}),priority:b(rt().nullish(),()=>{}),_meta:b(P(g(),T()).nullish(),()=>{})}),Bmt=x({annotations:b(dR.nullish(),()=>{}),text:g(),_meta:b(P(g(),T()).nullish(),()=>{})}),Wmt=x({annotations:b(dR.nullish(),()=>{}),data:g(),mimeType:g(),uri:b(g().nullish(),()=>{}),_meta:b(P(g(),T()).nullish(),()=>{})}),Vmt=x({annotations:b(dR.nullish(),()=>{}),data:g(),mimeType:g(),_meta:b(P(g(),T()).nullish(),()=>{})}),Kmt=x({annotations:b(dR.nullish(),()=>{}),description:b(g().nullish(),()=>{}),mimeType:b(g().nullish(),()=>{}),name:g(),size:b(rt().nullish(),()=>{}),title:b(g().nullish(),()=>{}),uri:g(),_meta:b(P(g(),T()).nullish(),()=>{})}),Zmt=x({mimeType:b(g().nullish(),()=>{}),text:g(),uri:g(),_meta:b(P(g(),T()).nullish(),()=>{})}),Jmt=x({blob:g(),mimeType:b(g().nullish(),()=>{}),uri:g(),_meta:b(P(g(),T()).nullish(),()=>{})}),Qmt=be([Zmt,Jmt]),Ymt=x({annotations:b(dR.nullish(),()=>{}),resource:Qmt,_meta:b(P(g(),T()).nullish(),()=>{})}),gZ=be([Bmt.and(x({type:$("text")})),Wmt.and(x({type:$("image")})),Vmt.and(x({type:$("audio")})),Kmt.and(x({type:$("resource_link")})),Ymt.and(x({type:$("resource")}))]),Xmt=x({content:gZ,_meta:b(P(g(),T()).nullish(),()=>{})}),eht=x({path:g(),oldText:b(g().nullish(),()=>{}),newText:g(),_meta:b(P(g(),T()).nullish(),()=>{})}),Wk=g(),tht=x({terminalId:Wk,_meta:b(P(g(),T()).nullish(),()=>{})}),dve=be([Xmt.and(x({type:$("content")})),eht.and(x({type:$("diff")})),tht.and(x({type:$("terminal")}))]),pve=x({path:g(),line:b(fr().gte(0).max(4294967295,{error:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),()=>{}),_meta:b(P(g(),T()).nullish(),()=>{})}),fve=x({toolCallId:hZ,kind:b(lve.nullish(),()=>{}),status:b(uve.nullish(),()=>{}),title:b(g().nullish(),()=>{}),name:b(g().nullish(),()=>{}),content:b(Ve(dve).nullish(),()=>{}),locations:b(Ve(pve).nullish(),()=>{}),rawInput:b(T().optional(),()=>{}),rawOutput:b(T().optional(),()=>{}),_meta:b(P(g(),T()).nullish(),()=>{})}),mve=g(),rht=be([$("allow_once"),$("allow_always"),$("reject_once"),$("reject_always")]),nht=x({optionId:mve,name:g(),kind:rht,_meta:b(P(g(),T()).nullish(),()=>{})}),yZ=x({sessionId:Ar,toolCall:fve,options:gt(nht),_meta:b(P(g(),T()).nullish(),()=>{})}),hve=x({name:g(),value:g(),_meta:b(P(g(),T()).nullish(),()=>{})}),bZ=x({sessionId:Ar,command:g(),args:b(Ve(g()).optional(),()=>[]),env:b(Ve(hve).optional(),()=>[]),cwd:b(g().nullish(),()=>{}),outputByteLimit:b(rt().nullish(),()=>{}),_meta:b(P(g(),T()).nullish(),()=>{})}),xZ=x({sessionId:Ar,terminalId:Wk,_meta:b(P(g(),T()).nullish(),()=>{})}),SZ=x({sessionId:Ar,terminalId:Wk,_meta:b(P(g(),T()).nullish(),()=>{})}),kZ=x({sessionId:Ar,terminalId:Wk,_meta:b(P(g(),T()).nullish(),()=>{})}),_Z=x({sessionId:Ar,terminalId:Wk,_meta:b(P(g(),T()).nullish(),()=>{})}),pR=x({sessionId:Ar,toolCallId:b(hZ.nullish(),()=>{})}),fR=x({requestId:th}),oht=$("object"),iht=be([$("email"),$("uri"),$("date"),$("date-time")]),gve=x({const:g(),title:g(),description:b(g().nullish(),()=>{}),_meta:b(P(g(),T()).nullish(),()=>{})}),wZ=x({title:b(g().nullish(),()=>{}),description:b(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:iht.nullish(),default:b(g().nullish(),()=>{}),enum:gt(g()).nullish(),oneOf:gt(gve).nullish(),_meta:b(P(g(),T()).nullish(),()=>{})}),vZ=x({title:b(g().nullish(),()=>{}),description:b(g().nullish(),()=>{}),minimum:rt().nullish(),maximum:rt().nullish(),default:b(rt().nullish(),()=>{}),_meta:b(P(g(),T()).nullish(),()=>{})}),EZ=x({title:b(g().nullish(),()=>{}),description:b(g().nullish(),()=>{}),minimum:rt().nullish(),maximum:rt().nullish(),default:b(rt().nullish(),()=>{}),_meta:b(P(g(),T()).nullish(),()=>{})}),RZ=x({title:b(g().nullish(),()=>{}),description:b(g().nullish(),()=>{}),default:b(mr().nullish(),()=>{}),_meta:b(P(g(),T()).nullish(),()=>{})}),TZ=x({enum:gt(g()),_meta:b(P(g(),T()).nullish(),()=>{})}),yve=x({anyOf:gt(gve),_meta:b(P(g(),T()).nullish(),()=>{})}),sht=Mn(be([TZ.and(x({type:$("string")})),$n(x({type:g()}),"type",["string"]),yve]),"type",["string"]),CZ=x({title:b(g().nullish(),()=>{}),description:b(g().nullish(),()=>{}),minItems:rt().nullish(),maxItems:rt().nullish(),items:sht,default:b(Ve(g()).nullish(),()=>{}),_meta:b(P(g(),T()).nullish(),()=>{})}),aht=Mn(be([wZ.and(x({type:$("string")})),vZ.and(x({type:$("number")})),EZ.and(x({type:$("integer")})),RZ.and(x({type:$("boolean")})),CZ.and(x({type:$("array")})),$n(x({type:g()}),"type",["array","boolean","integer","number","string"])]),"type",["array","boolean","integer","number","string"]),cht=x({type:b(oht.optional().default("object"),()=>"object"),title:b(g().nullish(),()=>{}),properties:P(g(),aht).optional().default({}),required:gt(g()).nullish(),description:b(g().nullish(),()=>{}),_meta:b(P(g(),T()).nullish(),()=>{})}),PZ=Ho(be([pR,fR]),x({requestedSchema:cht})),bve=g(),IZ=Ho(be([pR,fR]),x({elicitationId:bve,url:_r()})),AZ=Mn(Ho(be([PZ.and(x({mode:$("form")})),IZ.and(x({mode:$("url")})),$n(Ho(be([pR,fR]),x({mode:g()})),"mode",["form","url"])]),x({message:g(),_meta:b(P(g(),T()).nullish(),()=>{})})),"mode",["form","url"]),xve=g(),lht=x({serverId:xve,_meta:b(P(g(),T()).nullish(),()=>{})}),mD=g(),Sve=x({connectionId:mD,method:g(),params:P(g(),T()).nullish(),_meta:b(P(g(),T()).nullish(),()=>{})}),uht=x({connectionId:mD,_meta:b(P(g(),T()).nullish(),()=>{})}),kve=T(),Zpr=x({id:th,method:g(),params:be([fZ,mZ,yZ,bZ,xZ,SZ,kZ,_Z,AZ,lht,Sve,uht,kve]).nullish()}),_ve=fr().gte(0).lte(65535),dht=x({image:b(mr().optional().default(!1),()=>!1),audio:b(mr().optional().default(!1),()=>!1),embeddedContext:b(mr().optional().default(!1),()=>!1),_meta:b(P(g(),T()).nullish(),()=>{})}),pht=x({http:b(mr().optional().default(!1),()=>!1),sse:b(mr().optional().default(!1),()=>!1),acp:b(mr().optional().default(!1),()=>!1),_meta:b(P(g(),T()).nullish(),()=>{})}),fht=x({_meta:b(P(g(),T()).nullish(),()=>{})}),mht=x({_meta:b(P(g(),T()).nullish(),()=>{})}),hht=x({_meta:b(P(g(),T()).nullish(),()=>{})}),ght=x({_meta:b(P(g(),T()).nullish(),()=>{})}),yht=x({_meta:b(P(g(),T()).nullish(),()=>{})}),bht=x({_meta:b(P(g(),T()).nullish(),()=>{})}),xht=x({list:b(fht.nullish(),()=>{}),delete:b(mht.nullish(),()=>{}),additionalDirectories:b(hht.nullish(),()=>{}),fork:b(ght.nullish(),()=>{}),resume:b(yht.nullish(),()=>{}),close:b(bht.nullish(),()=>{}),_meta:b(P(g(),T()).nullish(),()=>{})}),Sht=x({_meta:b(P(g(),T()).nullish(),()=>{})}),kht=x({logout:b(Sht.nullish(),()=>{}),_meta:b(P(g(),T()).nullish(),()=>{})}),_ht=x({_meta:b(P(g(),T()).nullish(),()=>{})}),wht=x({_meta:b(P(g(),T()).nullish(),()=>{})}),vht=be([$("full"),$("incremental")]),Eht=x({syncKind:vht,_meta:b(P(g(),T()).nullish(),()=>{})}),Rht=x({_meta:b(P(g(),T()).nullish(),()=>{})}),Tht=x({_meta:b(P(g(),T()).nullish(),()=>{})}),Cht=x({_meta:b(P(g(),T()).nullish(),()=>{})}),Pht=x({didOpen:b(wht.nullish(),()=>{}),didChange:b(Eht.nullish(),()=>{}),didClose:b(Rht.nullish(),()=>{}),didSave:b(Tht.nullish(),()=>{}),didFocus:b(Cht.nullish(),()=>{}),_meta:b(P(g(),T()).nullish(),()=>{})}),Iht=x({document:b(Pht.nullish(),()=>{}),_meta:b(P(g(),T()).nullish(),()=>{})}),Aht=x({maxCount:b(fr().gte(0).max(4294967295,{error:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),()=>{}),_meta:b(P(g(),T()).nullish(),()=>{})}),Oht=x({_meta:b(P(g(),T()).nullish(),()=>{})}),$ht=x({maxCount:b(fr().gte(0).max(4294967295,{error:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),()=>{}),_meta:b(P(g(),T()).nullish(),()=>{})}),Mht=x({maxCount:b(fr().gte(0).max(4294967295,{error:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),()=>{}),_meta:b(P(g(),T()).nullish(),()=>{})}),Dht=x({_meta:b(P(g(),T()).nullish(),()=>{})}),Nht=x({_meta:b(P(g(),T()).nullish(),()=>{})}),zht=x({recentFiles:b(Aht.nullish(),()=>{}),relatedSnippets:b(Oht.nullish(),()=>{}),editHistory:b($ht.nullish(),()=>{}),userActions:b(Mht.nullish(),()=>{}),openFiles:b(Dht.nullish(),()=>{}),diagnostics:b(Nht.nullish(),()=>{}),_meta:b(P(g(),T()).nullish(),()=>{})}),Lht=x({events:b(Iht.nullish(),()=>{}),context:b(zht.nullish(),()=>{}),_meta:b(P(g(),T()).nullish(),()=>{})}),wve=be([$("utf-16"),$("utf-32"),$("utf-8")]),Fht=x({loadSession:b(mr().optional().default(!1),()=>!1),promptCapabilities:b(dht.optional().default({image:!1,audio:!1,embeddedContext:!1}),()=>({image:!1,audio:!1,embeddedContext:!1})),mcpCapabilities:b(pht.optional().default({http:!1,sse:!1,acp:!1}),()=>({http:!1,sse:!1,acp:!1})),sessionCapabilities:b(xht.optional().default({}),()=>({})),auth:b(kht.optional().default({}),()=>({})),providers:b(_ht.nullish(),()=>{}),nes:b(Lht.nullish(),()=>{}),positionEncoding:b(wve.nullish(),()=>{}),_meta:b(P(g(),T()).nullish(),()=>{})}),hD=g(),jht=x({name:g(),label:b(g().nullish(),()=>{}),secret:b(mr().optional().default(!0),()=>!0),optional:b(mr().optional().default(!1),()=>!1),_meta:b(P(g(),T()).nullish(),()=>{})}),Uht=x({id:hD,name:g(),description:b(g().nullish(),()=>{}),vars:Kn(Ve(jht),()=>[]),link:b(g().nullish(),()=>{}),_meta:b(P(g(),T()).nullish(),()=>{})}),Hht=x({id:hD,name:g(),description:b(g().nullish(),()=>{}),args:b(Ve(g()).optional(),()=>[]),env:b(P(g(),g()).optional(),()=>{}),_meta:b(P(g(),T()).nullish(),()=>{})}),qht=x({id:hD,name:g(),description:b(g().nullish(),()=>{}),_meta:b(P(g(),T()).nullish(),()=>{})}),Ght=be([Uht.and(x({type:$("env_var")})),Hht.and(x({type:$("terminal")})),qht]),vve=x({name:g(),title:b(g().nullish(),()=>{}),version:g(),_meta:b(P(g(),T()).nullish(),()=>{})}),Bht=x({protocolVersion:_ve,agentCapabilities:b(Fht.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:b(Ve(Ght).optional().default([]),()=>[]),agentInfo:b(vve.nullish(),()=>{}),_meta:b(P(g(),T()).nullish(),()=>{})}),Wht=x({_meta:b(P(g(),T()).nullish(),()=>{})}),OZ=g(),$Z=be([$("anthropic"),$("openai"),$("azure"),$("vertex"),$("bedrock"),g()]),Vht=x({apiType:$Z,baseUrl:g(),_meta:b(P(g(),T()).nullish(),()=>{})}),Kht=x({providerId:OZ,supported:Kn(Ve($Z),()=>[]),required:mr(),current:Vht.nullish(),_meta:b(P(g(),T()).nullish(),()=>{})}),Zht=x({providers:gt(Kht),_meta:b(P(g(),T()).nullish(),()=>{})}),Jht=x({_meta:b(P(g(),T()).nullish(),()=>{})}),Qht=x({_meta:b(P(g(),T()).nullish(),()=>{})}),Yht=x({_meta:b(P(g(),T()).nullish(),()=>{})}),gD=g(),Xht=x({id:gD,name:g(),description:b(g().nullish(),()=>{}),_meta:b(P(g(),T()).nullish(),()=>{})}),yD=x({currentModeId:gD,availableModes:Kn(Ve(Xht),()=>[]),_meta:b(P(g(),T()).nullish(),()=>{})}),Eve=g(),egt=be([$("mode"),$("model"),$("model_config"),$("thought_level"),g()]),MZ=g(),Rve=x({value:MZ,name:g(),description:b(g().nullish(),()=>{}),_meta:b(P(g(),T()).nullish(),()=>{})}),tgt=g(),rgt=x({group:tgt,name:g(),options:Kn(Ve(Rve),()=>[]),_meta:b(P(g(),T()).nullish(),()=>{})}),ngt=be([gt(Rve),gt(rgt)]),ogt=x({currentValue:MZ,options:ngt}),igt=x({currentValue:mr()}),Vk=Ho(be([ogt.and(x({type:$("select")})),igt.and(x({type:$("boolean")}))]),x({id:Eve,name:g(),description:b(g().nullish(),()=>{}),category:b(egt.nullish(),()=>{}),_meta:b(P(g(),T()).nullish(),()=>{})})),sgt=x({sessionId:Ar,modes:b(yD.nullish(),()=>{}),configOptions:b(Ve(Vk).nullish(),()=>{}),_meta:b(P(g(),T()).nullish(),()=>{})}),agt=x({modes:b(yD.nullish(),()=>{}),configOptions:b(Ve(Vk).nullish(),()=>{}),_meta:b(P(g(),T()).nullish(),()=>{})}),cgt=x({sessionId:Ar,cwd:g(),additionalDirectories:b(Ve(g()).optional(),()=>[]),title:b(g().nullish(),()=>{}),updatedAt:b(g().nullish(),()=>{}),_meta:b(P(g(),T()).nullish(),()=>{})}),lgt=x({sessions:Kn(Ve(cgt),()=>[]),nextCursor:b(g().nullish(),()=>{}),_meta:b(P(g(),T()).nullish(),()=>{})}),ugt=x({_meta:b(P(g(),T()).nullish(),()=>{})}),dgt=x({sessionId:Ar,modes:b(yD.nullish(),()=>{}),configOptions:b(Ve(Vk).nullish(),()=>{}),_meta:b(P(g(),T()).nullish(),()=>{})}),pgt=x({modes:b(yD.nullish(),()=>{}),configOptions:b(Ve(Vk).nullish(),()=>{}),_meta:b(P(g(),T()).nullish(),()=>{})}),fgt=x({_meta:b(P(g(),T()).nullish(),()=>{})}),mgt=x({_meta:b(P(g(),T()).nullish(),()=>{})}),hgt=x({configOptions:Kn(Ve(Vk),()=>[]),_meta:b(P(g(),T()).nullish(),()=>{})}),ggt=be([$("end_turn"),$("max_tokens"),$("max_turn_requests"),$("refusal"),$("cancelled")]),ygt=x({totalTokens:rt(),inputTokens:rt(),outputTokens:rt(),thoughtTokens:b(rt().nullish(),()=>{}),cachedReadTokens:b(rt().nullish(),()=>{}),cachedWriteTokens:b(rt().nullish(),()=>{}),_meta:b(P(g(),T()).nullish(),()=>{})}),bgt=x({stopReason:ggt,usage:b(ygt.nullish(),()=>{}),_meta:b(P(g(),T()).nullish(),()=>{})}),xgt=x({sessionId:Ar,_meta:b(P(g(),T()).nullish(),()=>{})}),Kk=g(),rh=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:b(P(g(),T()).nullish(),()=>{})}),Zk=x({start:rh,end:rh,_meta:b(P(g(),T()).nullish(),()=>{})}),Sgt=x({range:Zk,newText:g(),_meta:b(P(g(),T()).nullish(),()=>{})}),kgt=x({id:Kk,uri:g(),edits:gt(Sgt),cursorPosition:b(rh.nullish(),()=>{}),_meta:b(P(g(),T()).nullish(),()=>{})}),_gt=x({id:Kk,uri:g(),position:rh,_meta:b(P(g(),T()).nullish(),()=>{})}),wgt=x({id:Kk,uri:g(),position:rh,newName:g(),_meta:b(P(g(),T()).nullish(),()=>{})}),vgt=x({id:Kk,uri:g(),search:g(),replace:g(),isRegex:mr().nullish(),_meta:b(P(g(),T()).nullish(),()=>{})}),Egt=be([kgt.and(x({kind:$("edit")})),_gt.and(x({kind:$("jump")})),wgt.and(x({kind:$("rename")})),vgt.and(x({kind:$("searchAndReplace")}))]),Rgt=x({suggestions:gt(Egt),_meta:b(P(g(),T()).nullish(),()=>{})}),Tgt=x({_meta:b(P(g(),T()).nullish(),()=>{})}),Tve=T(),Cve=T(),Cgt=be([$(-32700),$(-32600),$(-32601),$(-32602),$(-32603),$(-32800),$(-32e3),$(-32002),fr().min(-2147483648,{error:"Invalid value: Expected int32 to be >= -2147483648"}).max(2147483647,{error:"Invalid value: Expected int32 to be <= 2147483647"})]),Pve=x({code:Cgt,message:g(),data:b(T().optional(),()=>{})}),Jpr=be([x({id:th,result:be([Bht,Wht,Zht,Jht,Qht,Yht,sgt,agt,lgt,ugt,dgt,pgt,fgt,mgt,hgt,bgt,xgt,Rgt,Tgt,Tve,Cve])}),x({id:th,error:Pve})]),Pgt=g(),dZ=x({content:gZ,messageId:b(Pgt.nullish(),()=>{}),_meta:b(P(g(),T()).nullish(),()=>{})}),Igt=x({toolCallId:hZ,title:g(),name:b(g().nullish(),()=>{}),kind:b(lve.optional(),()=>{}),status:b(uve.optional(),()=>{}),content:b(Ve(dve).optional(),()=>[]),locations:b(Ve(pve).optional(),()=>[]),rawInput:b(T().optional(),()=>{}),rawOutput:b(T().optional(),()=>{}),_meta:b(P(g(),T()).nullish(),()=>{})}),Agt=be([$("high"),$("medium"),$("low")]),Ogt=be([$("pending"),$("in_progress"),$("completed")]),Ive=x({content:g(),priority:Agt,status:Ogt,_meta:b(P(g(),T()).nullish(),()=>{})}),$gt=x({entries:Kn(Ve(Ive),()=>[]),_meta:b(P(g(),T()).nullish(),()=>{})}),bD=g(),Mgt=x({planId:bD,entries:Kn(Ve(Ive),()=>[]),_meta:b(P(g(),T()).nullish(),()=>{})}),Dgt=x({planId:bD,uri:g(),_meta:b(P(g(),T()).nullish(),()=>{})}),Ngt=x({planId:bD,content:g(),_meta:b(P(g(),T()).nullish(),()=>{})}),zgt=be([Mgt.and(x({type:$("items")})),Dgt.and(x({type:$("file")})),Ngt.and(x({type:$("markdown")}))]),Lgt=x({plan:zgt,_meta:b(P(g(),T()).nullish(),()=>{})}),Fgt=x({planId:bD,_meta:b(P(g(),T()).nullish(),()=>{})}),jgt=x({hint:g(),_meta:b(P(g(),T()).nullish(),()=>{})}),Ugt=jgt,Hgt=x({name:g(),description:g(),input:b(Ugt.nullish(),()=>{}),_meta:b(P(g(),T()).nullish(),()=>{})}),qgt=x({availableCommands:Kn(Ve(Hgt),()=>[]),_meta:b(P(g(),T()).nullish(),()=>{})}),Ggt=x({currentModeId:gD,_meta:b(P(g(),T()).nullish(),()=>{})}),Bgt=x({configOptions:Kn(Ve(Vk),()=>[]),_meta:b(P(g(),T()).nullish(),()=>{})}),Wgt=x({title:b(g().nullish(),()=>{}),updatedAt:b(g().nullish(),()=>{}),_meta:b(P(g(),T()).nullish(),()=>{})}),Vgt=x({amount:rt(),currency:g(),_meta:b(P(g(),T()).nullish(),()=>{})}),Kgt=x({used:rt(),size:rt(),cost:b(Vgt.nullish(),()=>{}),_meta:b(P(g(),T()).nullish(),()=>{})}),Zgt=be([dZ.and(x({sessionUpdate:$("user_message_chunk")})),dZ.and(x({sessionUpdate:$("agent_message_chunk")})),dZ.and(x({sessionUpdate:$("agent_thought_chunk")})),Igt.and(x({sessionUpdate:$("tool_call")})),fve.and(x({sessionUpdate:$("tool_call_update")})),$gt.and(x({sessionUpdate:$("plan")})),Lgt.and(x({sessionUpdate:$("plan_update")})),Fgt.and(x({sessionUpdate:$("plan_removed")})),qgt.and(x({sessionUpdate:$("available_commands_update")})),Ggt.and(x({sessionUpdate:$("current_mode_update")})),Bgt.and(x({sessionUpdate:$("config_option_update")})),Wgt.and(x({sessionUpdate:$("session_info_update")})),Kgt.and(x({sessionUpdate:$("usage_update")}))]),xD=x({sessionId:Ar,update:Zgt,_meta:b(P(g(),T()).nullish(),()=>{})}),DZ=x({elicitationId:bve,_meta:b(P(g(),T()).nullish(),()=>{})}),Ave=x({connectionId:mD,method:g(),params:b(P(g(),T()).nullish(),()=>{}),_meta:b(P(g(),T()).nullish(),()=>{})}),Ove=T(),Qpr=x({method:g(),params:be([xD,DZ,Ave,Ove]).nullish()}),Jgt=x({readTextFile:b(mr().optional().default(!1),()=>!1),writeTextFile:b(mr().optional().default(!1),()=>!1),_meta:b(P(g(),T()).nullish(),()=>{})}),Qgt=x({_meta:b(P(g(),T()).nullish(),()=>{})}),Ygt=x({boolean:b(Qgt.nullish(),()=>{}),_meta:b(P(g(),T()).nullish(),()=>{})}),Xgt=x({configOptions:b(Ygt.nullish(),()=>{}),_meta:b(P(g(),T()).nullish(),()=>{})}),eyt=x({_meta:b(P(g(),T()).nullish(),()=>{})}),tyt=x({terminal:b(mr().optional().default(!1),()=>!1),_meta:b(P(g(),T()).nullish(),()=>{})}),ryt=x({_meta:b(P(g(),T()).nullish(),()=>{})}),nyt=x({_meta:b(P(g(),T()).nullish(),()=>{})}),oyt=x({form:b(ryt.nullish(),()=>{}),url:b(nyt.nullish(),()=>{}),_meta:b(P(g(),T()).nullish(),()=>{})}),iyt=x({_meta:b(P(g(),T()).nullish(),()=>{})}),syt=x({_meta:b(P(g(),T()).nullish(),()=>{})}),ayt=x({_meta:b(P(g(),T()).nullish(),()=>{})}),cyt=x({jump:b(iyt.nullish(),()=>{}),rename:b(syt.nullish(),()=>{}),searchAndReplace:b(ayt.nullish(),()=>{}),_meta:b(P(g(),T()).nullish(),()=>{})}),lyt=x({fs:b(Jgt.optional().default({readTextFile:!1,writeTextFile:!1}),()=>({readTextFile:!1,writeTextFile:!1})),terminal:b(mr().optional().default(!1),()=>!1),session:b(Xgt.nullish(),()=>{}),plan:b(eyt.nullish(),()=>{}),auth:b(tyt.optional().default({terminal:!1}),()=>({terminal:!1})),elicitation:b(oyt.nullish(),()=>{}),nes:b(cyt.nullish(),()=>{}),positionEncodings:b(Ve(wve).optional(),()=>[]),_meta:b(P(g(),T()).nullish(),()=>{})}),SD=x({protocolVersion:_ve,clientCapabilities:b(lyt.optional().default({fs:{readTextFile:!1,writeTextFile:!1},terminal:!1,auth:{terminal:!1}}),()=>({fs:{readTextFile:!1,writeTextFile:!1},terminal:!1,auth:{terminal:!1}})),clientInfo:b(vve.nullish(),()=>{}),_meta:b(P(g(),T()).nullish(),()=>{})}),NZ=x({methodId:hD,_meta:b(P(g(),T()).nullish(),()=>{})}),zZ=x({_meta:b(P(g(),T()).nullish(),()=>{})}),LZ=x({providerId:OZ,apiType:$Z,baseUrl:g(),headers:P(g(),g()).optional(),_meta:b(P(g(),T()).nullish(),()=>{})}),FZ=x({providerId:OZ,_meta:b(P(g(),T()).nullish(),()=>{})}),jZ=x({_meta:b(P(g(),T()).nullish(),()=>{})}),$ve=x({name:g(),value:g(),_meta:b(P(g(),T()).nullish(),()=>{})}),uyt=x({name:g(),url:g(),headers:gt($ve),_meta:b(P(g(),T()).nullish(),()=>{})}),dyt=x({name:g(),url:g(),headers:gt($ve),_meta:b(P(g(),T()).nullish(),()=>{})}),pyt=x({name:g(),serverId:xve,_meta:b(P(g(),T()).nullish(),()=>{})}),fyt=x({name:g(),command:g(),args:gt(g()),env:gt(hve),_meta:b(P(g(),T()).nullish(),()=>{})}),kD=be([uyt.and(x({type:$("http")})),dyt.and(x({type:$("sse")})),pyt.and(x({type:$("acp")})),fyt]),UZ=x({cwd:g(),additionalDirectories:b(Ve(g()).optional(),()=>[]),mcpServers:Kn(Ve(kD),()=>[]),_meta:b(P(g(),T()).nullish(),()=>{})}),HZ=x({mcpServers:Kn(Ve(kD),()=>[]),cwd:g(),additionalDirectories:b(Ve(g()).optional(),()=>[]),sessionId:Ar,_meta:b(P(g(),T()).nullish(),()=>{})}),qZ=x({cwd:g().nullish(),cursor:g().nullish(),_meta:b(P(g(),T()).nullish(),()=>{})}),GZ=x({sessionId:Ar,_meta:b(P(g(),T()).nullish(),()=>{})}),BZ=x({sessionId:Ar,cwd:g(),additionalDirectories:b(Ve(g()).optional(),()=>[]),mcpServers:b(Ve(kD).optional(),()=>[]),_meta:b(P(g(),T()).nullish(),()=>{})}),WZ=x({sessionId:Ar,cwd:g(),additionalDirectories:b(Ve(g()).optional(),()=>[]),mcpServers:b(Ve(kD).optional(),()=>[]),_meta:b(P(g(),T()).nullish(),()=>{})}),VZ=x({sessionId:Ar,_meta:b(P(g(),T()).nullish(),()=>{})}),KZ=x({sessionId:Ar,modeId:gD,_meta:b(P(g(),T()).nullish(),()=>{})}),ZZ=Ho(be([x({value:mr(),type:$("boolean")}),x({value:MZ})]),x({sessionId:Ar,configId:Eve,_meta:b(P(g(),T()).nullish(),()=>{})})),JZ=x({sessionId:Ar,prompt:gt(gZ),_meta:b(P(g(),T()).nullish(),()=>{})}),myt=x({uri:g(),name:g(),_meta:b(P(g(),T()).nullish(),()=>{})}),hyt=x({name:g(),owner:g(),remoteUrl:g(),_meta:b(P(g(),T()).nullish(),()=>{})}),QZ=x({workspaceUri:b(g().nullish(),()=>{}),workspaceFolders:gt(myt).nullish(),repository:b(hyt.nullish(),()=>{}),_meta:b(P(g(),T()).nullish(),()=>{})}),gyt=be([$("automatic"),$("diagnostic"),$("manual")]),yyt=x({uri:g(),languageId:g(),text:g(),_meta:b(P(g(),T()).nullish(),()=>{})}),byt=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:b(P(g(),T()).nullish(),()=>{})}),xyt=x({uri:g(),excerpts:gt(byt),_meta:b(P(g(),T()).nullish(),()=>{})}),Syt=x({uri:g(),diff:g(),_meta:b(P(g(),T()).nullish(),()=>{})}),kyt=x({action:g(),uri:g(),position:rh,timestampMs:rt(),_meta:b(P(g(),T()).nullish(),()=>{})}),_yt=x({uri:g(),languageId:g(),visibleRange:b(Zk.nullish(),()=>{}),lastFocusedMs:b(rt().nullish(),()=>{}),_meta:b(P(g(),T()).nullish(),()=>{})}),wyt=be([$("error"),$("warning"),$("information"),$("hint")]),vyt=x({uri:g(),range:Zk,severity:wyt,message:g(),_meta:b(P(g(),T()).nullish(),()=>{})}),Eyt=x({recentFiles:gt(yyt).nullish(),relatedSnippets:gt(xyt).nullish(),editHistory:gt(Syt).nullish(),userActions:gt(kyt).nullish(),openFiles:gt(_yt).nullish(),diagnostics:gt(vyt).nullish(),_meta:b(P(g(),T()).nullish(),()=>{})}),YZ=x({sessionId:Ar,uri:g(),version:rt(),position:rh,selection:Zk.nullish(),triggerKind:gyt,context:Eyt.nullish(),_meta:b(P(g(),T()).nullish(),()=>{})}),XZ=x({sessionId:Ar,_meta:b(P(g(),T()).nullish(),()=>{})}),Ypr=x({id:th,method:g(),params:be([SD,NZ,zZ,LZ,FZ,jZ,UZ,HZ,qZ,GZ,BZ,WZ,VZ,KZ,ZZ,JZ,QZ,YZ,XZ,Sve,kve]).nullish()}),Ryt=x({_meta:b(P(g(),T()).nullish(),()=>{})}),Tyt=x({content:g(),_meta:b(P(g(),T()).nullish(),()=>{})}),Cyt=x({optionId:mve,_meta:b(P(g(),T()).nullish(),()=>{})}),Pyt=be([x({outcome:$("cancelled")}),Cyt.and(x({outcome:$("selected")}))]),Iyt=x({outcome:Pyt,_meta:b(P(g(),T()).nullish(),()=>{})}),Ayt=x({terminalId:Wk,_meta:b(P(g(),T()).nullish(),()=>{})}),Oyt=x({exitCode:b(fr().gte(0).max(4294967295,{error:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),()=>{}),signal:b(g().nullish(),()=>{}),_meta:b(P(g(),T()).nullish(),()=>{})}),$yt=x({output:g(),truncated:mr(),exitStatus:b(Oyt.nullish(),()=>{}),_meta:b(P(g(),T()).nullish(),()=>{})}),Myt=x({_meta:b(P(g(),T()).nullish(),()=>{})}),Dyt=x({exitCode:b(fr().gte(0).max(4294967295,{error:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),()=>{}),signal:b(g().nullish(),()=>{}),_meta:b(P(g(),T()).nullish(),()=>{})}),Nyt=x({_meta:b(P(g(),T()).nullish(),()=>{})}),zyt=be([g(),rt(),rt(),mr(),gt(g())]),e9=x({content:P(g(),zyt).nullish()}),Lyt=Mn(Ho(be([e9.and(x({action:$("accept")})),x({action:$("decline")}),x({action:$("cancel")}),$n(x({action:g()}),"action",["accept","cancel","decline"])]),x({_meta:b(P(g(),T()).nullish(),()=>{})})),"action",["accept","cancel","decline"]),Fyt=x({connectionId:mD,_meta:b(P(g(),T()).nullish(),()=>{})}),jyt=x({_meta:b(P(g(),T()).nullish(),()=>{})}),Xpr=be([x({id:th,result:be([Ryt,Tyt,Iyt,Ayt,$yt,Myt,Dyt,Nyt,Lyt,Fyt,jyt,Cve,Tve])}),x({id:th,error:Pve})]),t9=x({sessionId:Ar,_meta:b(P(g(),T()).nullish(),()=>{})}),r9=x({sessionId:Ar,uri:g(),languageId:g(),version:rt(),text:g(),_meta:b(P(g(),T()).nullish(),()=>{})}),Uyt=x({range:Zk.nullish(),text:g(),_meta:b(P(g(),T()).nullish(),()=>{})}),n9=x({sessionId:Ar,uri:g(),version:rt(),contentChanges:Kn(Ve(Uyt),()=>[]),_meta:b(P(g(),T()).nullish(),()=>{})}),o9=x({sessionId:Ar,uri:g(),_meta:b(P(g(),T()).nullish(),()=>{})}),i9=x({sessionId:Ar,uri:g(),_meta:b(P(g(),T()).nullish(),()=>{})}),s9=x({sessionId:Ar,uri:g(),version:rt(),position:rh,visibleRange:Zk,_meta:b(P(g(),T()).nullish(),()=>{})}),a9=x({sessionId:Ar,id:Kk,_meta:b(P(g(),T()).nullish(),()=>{})}),Hyt=be([$("rejected"),$("ignored"),$("replaced"),$("cancelled")]),c9=x({sessionId:Ar,id:Kk,reason:b(Hyt.nullish(),()=>{}),_meta:b(P(g(),T()).nullish(),()=>{})}),efr=x({method:g(),params:be([t9,r9,n9,o9,i9,s9,a9,c9,Ave,Ove]).nullish()}),tfr=x({requestId:th,_meta:b(P(g(),T()).nullish(),()=>{})});var Dve="$/cancel_request";function _D(e){return f9(e)&&"id"in e&&typeof e.method=="string"&&m9(e.id)}function p9(e){if(!f9(e)||"method"in e||!("id"in e)||!m9(e.id))return!1;let t=Object.hasOwn(e,"result"),r=Object.hasOwn(e,"error");return t===r?!1:!r||Gyt(e.error)}function Jk(e){return f9(e)&&!("id"in e)&&typeof e.method=="string"}function Dp(e){return typeof e=="object"&&e!==null}function f9(e){return Dp(e)&&e.jsonrpc==="2.0"}function m9(e){return e===null||typeof e=="string"||typeof e=="number"&&Number.isFinite(e)}function Nve(e){return Dp(e)&&!("method"in e)&&("id"in e||"result"in e||"error"in e)}function zve(e){let t=!1,r=!1,n=!1,o=!1;for(let i of e)t||=_D(i)||Jk(i),r||=p9(i),Dp(i)&&(n||="method"in i,o||="result"in i||"error"in i);return t?!1:r?!0:o&&!n}function qyt(e){if(!(!Dp(e)||!m9(e.requestId)))return e.requestId}function Gyt(e){return Dp(e)&&typeof e.code=="number"&&Number.isInteger(e.code)&&typeof e.message=="string"}var Dc={yes(){return{handled:!0}},no(e,t=!1){return{handled:!1,message:e,retry:t}}};function Qy(e){let t=Promise.reject(e);return t.catch(()=>{}),t}function Byt(e){if(e instanceof Error||typeof e=="object"&&e!=null&&"message"in e&&typeof e.message=="string")return e.message}function Wyt(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 Lve(e){if(e instanceof Xr)return e.toResult();if(Wyt(e))return Xr.invalidParams(e.format()).toResult();let t=Byt(e);try{return Xr.internalError(t?JSON.parse(t):{}).toResult()}catch{return Xr.internalError({details:t}).toResult()}}function Vyt(e){return e instanceof Xr&&e.code===-32800?e:Xr.requestCancelled(e)}function Kyt(e,t){let r=Zyt(e,t);return r?r.toResult():Lve(e)}function Zyt(e,t){if(!(!t.aborted||!Jyt(e)))return Vyt(t.reason)}function Jyt(e){if(typeof e!="object"||e===null)return!1;let t=e;return t.name==="AbortError"||t.code==="ABORT_ERR"}var l9=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?Qy(new Error("JSON-RPC request already responded")):(this.didRespond=!0,this.sendResult(t).finally(()=>{this.finishRequest?.()}))}},Np=class{disposeHandler;active=!0;constructor(t){this.disposeHandler=t}dispose(){this.active&&(this.active=!1,this.disposeHandler())}[Symbol.dispose](){this.dispose()}runIndefinitely(){return this}},u9=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}},zp=class{pendingResponses=new Map;incomingRequests=new Map;nextRequestId=0;staticHandlers=[];dynamicHandlers=new Set;stream;writeQueue=Promise.resolve();abortController=new AbortController;closedPromise;retryQueue=[];context=new u9(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 d9}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 Np(()=>{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 Qy(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 Qy(this.closedReason());if(!this.allowBatches)return Qy(new TypeError("JSON-RPC batches are not supported on this connection"));if(t.length===0)return Qy(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(Dve,{requestId:t})}sendNotification(t,r){return this.abortController.signal.aborted?Qy(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 Dc.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(!Dp(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=zve(t),o=r?0:t.reduce((u,d)=>u+(Jk(d)?0:1),0),i=t.reduce((u,d)=>u+(Jk(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){Nve(u)&&this.receiveMessage(u);continue}if(!_D(u)&&!Jk(u)){l({jsonrpc:"2.0",id:null,error:Xr.invalidRequest(u).toErrorResponse()}).catch(()=>{});continue}let d=this.receiveMessage(u,_D(u)?l:void 0);Jk(u)&&d.finally(()=>{i-=1,c().catch(f=>this.close(f))})}}receiveMessage(t,r){return this.abortController.signal.aborted?Promise.resolve():Dp(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(Kyt(o,r.responder.signal));else{let i=Lve(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 l9(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?.(),!p9(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!==Dve)return;let r=qyt(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?Qy(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)}},d9=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)??Dc.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 Dc.no(o);let s=r(o.params);return await n(s,o.responder,i)??Dc.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 Dc.no(o);let s=r(o.params);return await n(s,i)??Dc.yes()},describe:()=>`${this.connectionName??"notification"}:${t}`})}connect(t,r){return new zp(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 wD=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 h9(e,t){let r=new TextEncoder,n=new TextDecoder,o=!1,i,s=new ReadableStream({async start(c){let l=new wD,u=f=>{let m=n.decode(f).trim();if(m)try{let y=JSON.parse(m);Dp(y)||Array.isArray(y)?c.enqueue(y):console.warn("Skipping JSON line that is not an object:",m)}catch(y){console.error("Failed to parse JSON message:",m,y)}},d=t.getReader();i=d;try{for(;;){let{value:m,done:y}=await d.read();if(o)return;if(y)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)+`
444
- `,u=e.getWriter();try{await u.write(r.encode(l))}finally{u.releaseLock()}}});return{readable:s,writable:a}}var afr=PZ.and(x({mode:$("form")})).and(x({message:g()})),cfr=IZ.and(x({mode:$("url")})).and(x({message:g()})),lfr=be([pR,fR]).and(x({message:g()})),ufr=wZ.and(x({type:$("string")})),dfr=vZ.and(x({type:$("number")})),pfr=EZ.and(x({type:$("integer")})),ffr=RZ.and(x({type:$("boolean")})),mfr=CZ.and(x({type:$("array")})),hfr=TZ.and(x({type:$("string")}));var gfr=e9.and(x({action:$("accept")})),yfr=x({action:$("decline")}),bfr=x({action:$("cancel")});function _9(e,t){return h9(e,t)}function Nc(e){return e??{}}function Hve(e){return typeof e=="object"&&e!==null&&"readable"in e&&"writable"in e}function qve(){let e=new TransformStream,t=new TransformStream;return[{readable:t.readable,writable:e.writable},{readable:e.readable,writable:t.writable}]}var nh={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:t4.cancel_request}},Gve=Symbol("startActiveSession"),RD=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)}},mR=class e extends RD{constructor(t,r){super(t,r)}static create(t,r){return new e(t,r)}request(t,r,n){let o=Qve[t];return this.sendRequest(t,r,o?.mapResponse,n)}notify(t,r){return this.sendNotification(t,r)}},hR=class e extends RD{constructor(t,r){super(t,r)}static create(t,r){return new e(t,r)}[Gve](t,r){return this.sendRequest(Me.session_new,t,n=>this.attachSession(n),r)}buildSession(t){return typeof t=="string"?CD.create(this,{cwd:t,mcpServers:[]}):CD.create(this,t)}attachSession(t){let r=new b9,n=this.connectionContext.signal,o=()=>{r.fail(n.reason??new Error("ACP connection closed"))};n.aborted?o():n.addEventListener("abort",o);let i=Yve(this.connectionContext).attach(t,r),s=new Np(()=>{n.removeEventListener("abort",o)});return x9.create(this,t,r,[i,s])}request(t,r,n){let o=Jve[t];return this.sendRequest(t,r,o?.mapResponse,n)}notify(t,r){return this.sendNotification(t,r)}},TD=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)}},g9=class extends TD{connectHandlers;client;didStartConnectHandlers=!1;constructor(t,r=[]){super(t),this.connectHandlers=r,this.client=mR.create(t.getContext())}startConnectHandlers(){this.didStartConnectHandlers||(this.didStartConnectHandlers=!0,OD(this,this.connectHandlers))}},y9=class extends TD{connectHandlers;agent;didStartConnectHandlers=!1;constructor(t,r=[]){super(t),this.connectHandlers=r,this.agent=hR.create(t.getContext())}startConnectHandlers(){this.didStartConnectHandlers||(this.didStartConnectHandlers=!0,OD(this,this.connectHandlers))}};function Bve(e,t=[]){return new g9(e,t)}function Wve(e,t=[]){return new y9(e,t)}var b9=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 Fve(e){return{...e,additionalDirectories:e.additionalDirectories?[...e.additionalDirectories]:void 0,mcpServers:[...e.mcpServers]}}var CD=class e{cx;request;constructor(t,r){this.cx=t,this.request=Fve(r)}static create(t,r){return new e(t,r)}toRequest(){return Fve(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[Gve](this.toRequest(),t)}async withSession(t){let r=await this.start();try{return await t(r)}finally{r.dispose()}}},x9=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 Vve(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 Xu(e,t){return{method:e,params:t}}function Kve(e,t,r,n){e.onReceiveRequest(t.method,o=>Vve(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 Zve(e,t,r,n){e.onReceiveNotification(t.method,o=>Vve(t.params,o),(o,i)=>n(r(o,i,i.signal)))}function AD(e){let t={};for(let r of Object.values(e))t[r.method]=r;return t}var Qyt={initialize:en(Me.initialize,SD),newSession:en(Me.session_new,UZ),loadSession:en(Me.session_load,HZ,Nc),unstable_forkSession:en(Me.session_fork,BZ),listSessions:en(Me.session_list,qZ),deleteSession:en(Me.session_delete,GZ,Nc),resumeSession:en(Me.session_resume,WZ),closeSession:en(Me.session_close,VZ,Nc),setSessionMode:en(Me.session_set_mode,KZ,Nc),setSessionConfigOption:en(Me.session_set_config_option,ZZ),authenticate:en(Me.authenticate,NZ,Nc),unstable_listProviders:en(Me.providers_list,zZ),unstable_setProvider:en(Me.providers_set,LZ,Nc),unstable_disableProvider:en(Me.providers_disable,FZ,Nc),logout:en(Me.logout,jZ,Nc),prompt:en(Me.session_prompt,JZ),unstable_startNes:en(Me.nes_start,QZ),unstable_suggestNes:en(Me.nes_suggest,YZ),unstable_closeNes:en(Me.nes_close,XZ,Nc)},Yyt={cancel:Xu(Me.session_cancel,t9),unstable_didOpenDocument:Xu(Me.document_did_open,r9),unstable_didChangeDocument:Xu(Me.document_did_change,n9),unstable_didCloseDocument:Xu(Me.document_did_close,o9),unstable_didSaveDocument:Xu(Me.document_did_save,i9),unstable_didFocusDocument:Xu(Me.document_did_focus,s9),unstable_acceptNes:Xu(Me.nes_accept,a9),unstable_rejectNes:Xu(Me.nes_reject,c9)},Xyt={requestPermission:en(ir.session_request_permission,yZ),writeTextFile:en(ir.fs_write_text_file,fZ,Nc),readTextFile:en(ir.fs_read_text_file,mZ),createTerminal:en(ir.terminal_create,bZ),terminalOutput:en(ir.terminal_output,xZ),releaseTerminal:en(ir.terminal_release,SZ,Nc),waitForTerminalExit:en(ir.terminal_wait_for_exit,kZ),killTerminal:en(ir.terminal_kill,_Z,Nc),unstable_createElicitation:en(ir.elicitation_create,AZ)},ebt={sessionUpdate:Xu(ir.session_update,xD),unstable_completeElicitation:Xu(ir.elicitation_complete,DZ)},Jve=AD(Qyt),tbt=AD(Yyt),Qve=AD(Xyt),rbt=AD(ebt);function nbt(e,t,r,n){return{params:e,requestId:n,signal:r,client:t}}function obt(e,t,r){return{params:e,signal:r,client:t}}function ibt(e,t,r,n){return{params:e,requestId:n,signal:r,agent:t}}function sbt(e,t,r){return{params:e,signal:r,agent:t}}var S9=class{activeSessions=new Map;handleMessage(t){if(t.kind!=="notification"||t.method!==ir.session_update)return Dc.no(t);let r=xD.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 Dc.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 Np(()=>{n.delete(r),n.size===0&&this.activeSessions.delete(t.sessionId)})}},jve=new WeakMap;function Yve(e){let t=jve.get(e);return t||(t=new S9,jve.set(e,t)),t}function OD(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 PD=Symbol("appBuilder"),vD=Symbol("runAgentConnectHandlers"),ED=Symbol("runClientConnectHandlers"),ID={allowBatches:!1};var Uve=class{builder=zp.builder();connectHandlers=[];constructor(t={}){t.name&&this.builder.name(t.name)}[PD](){return this.builder}[vD](t){OD(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=Jve[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=tbt[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 Kve(this.builder,t,(n,o,i,s)=>nbt(n,mR.create(o,s),i,s),r),this}notification(t,r){return Zve(this.builder,t,(n,o,i)=>obt(n,mR.create(o),i),r),this}connectConnection(t,r={}){if(Hve(t)){let c=this.openStreamConnection(t);return r.deferConnectHandlers||this[vD](c.connection),c}let[n,o]=qve(),i=t[PD]().connect(o,ID),s=Wve(i),a=this.openStreamConnection(n);a.rawConnection.closed.then(()=>s.close()),i.closed.then(()=>a.connection.close());try{t[ED](s),this[vD](a.connection)}catch(c){throw s.close(c),a.connection.close(c),c}return a}openStreamConnection(t){let r=this.builder.connect(t,ID);return{rawConnection:r,connection:Bve(r,this.connectHandlers)}}};function Xve(e){return new k9(e)}var k9=class{builder=zp.builder();connectHandlers=[];constructor(t={}){t.name&&this.builder.name(t.name),this.builder.withHandler({handleMessage:(r,n)=>Yve(n).handleMessage(r),describe:()=>"client-session-update-router"})}[PD](){return this.builder}[ED](t){OD(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=Qve[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=rbt[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 Kve(this.builder,t,(n,o,i,s)=>ibt(n,hR.create(o,s),i,s),r),this}notification(t,r){return Zve(this.builder,t,(n,o,i)=>sbt(n,hR.create(o),i),r),this}connectConnection(t){if(Hve(t)){let a=this.openStreamConnection(t);return this[ED](a.connection),a}let[r,n]=qve(),o=t[PD]().connect(n,ID),i=Bve(o),s=this.openStreamConnection(r);s.rawConnection.closed.then(()=>i.close()),o.closed.then(()=>s.connection.close());try{t[vD](i),this[ED](s.connection)}catch(a){throw i.close(a),s.connection.close(a),a}return s}openStreamConnection(t){let r=this.builder.connect(t,ID);return{rawConnection:r,connection:Wve(r,this.connectHandlers)}}},Tfr=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]),Cfr=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]),Pfr=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]),Ifr=new Set([ir.session_update,ir.elicitation_complete]);U8();$8();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"},U1={cancel_request:"$/cancel_request"},Gp=2;var dh=be([rt(),g()]).nullable(),dn=g(),H1=g(),Lwt=be([$("read"),$("edit"),$("delete"),$("move"),$("search"),$("execute"),$("think"),$("fetch"),$("switch_mode"),$("other"),g()]),Fwt=be([$("pending"),$("in_progress"),$("completed"),$("failed"),$("cancelled"),g()]),jwt=be([$("assistant"),$("user"),g()]),KR=x({audience:b(Ve(jwt).nullish(),()=>{}),lastModified:b(Qu.datetime({offset:!0}).nullish(),()=>{}),priority:b(rt().gte(0).lte(1).nullish(),()=>{}),_meta:b(P(g(),T()).nullish(),()=>{})}),H8=x({text:g(),annotations:b(KR.nullish(),()=>{}),_meta:b(P(g(),T()).nullish(),()=>{})}),ub=g(),q8=x({data:g(),mimeType:ub,uri:b(_r().nullish(),()=>{}),annotations:b(KR.nullish(),()=>{}),_meta:b(P(g(),T()).nullish(),()=>{})}),G8=x({data:g(),mimeType:ub,annotations:b(KR.nullish(),()=>{}),_meta:b(P(g(),T()).nullish(),()=>{})}),Uwt=be([$("light"),$("dark"),g()]),Hwt=x({src:_r(),mimeType:b(ub.nullish(),()=>{}),sizes:b(Ve(g()).nullish(),()=>{}),theme:b(Uwt.nullish(),()=>{})}),B8=x({name:g(),uri:_r(),title:b(g().nullish(),()=>{}),description:b(g().nullish(),()=>{}),icons:b(Ve(Hwt).nullish(),()=>{}),mimeType:b(ub.nullish(),()=>{}),size:b(rt().nullish(),()=>{}),annotations:b(KR.nullish(),()=>{}),_meta:b(P(g(),T()).nullish(),()=>{})}),qwt=x({text:g(),uri:_r(),mimeType:b(ub.nullish(),()=>{}),_meta:b(P(g(),T()).nullish(),()=>{})}),Gwt=x({blob:g(),uri:_r(),mimeType:b(ub.nullish(),()=>{}),_meta:b(P(g(),T()).nullish(),()=>{})}),Bwt=be([qwt,Gwt]),W8=x({resource:Bwt,annotations:b(KR.nullish(),()=>{}),_meta:b(P(g(),T()).nullish(),()=>{})}),S_=Mn(be([H8.and(x({type:$("text")})),q8.and(x({type:$("image")})),G8.and(x({type:$("audio")})),B8.and(x({type:$("resource_link")})),W8.and(x({type:$("resource")})),$n(x({type:g()}),"type",["audio","image","resource","resource_link","text"])]),"type",["audio","image","resource","resource_link","text"]),V8=x({content:S_,_meta:b(P(g(),T()).nullish(),()=>{})}),Wwt=be([$("text"),$("binary"),$("directory"),$("symlink"),g()]),ss=g(),cb=x({path:ss}),VR=x({oldPath:ss,path:ss}),Vwt=Mn(Ho(be([cb.and(x({operation:$("add")})),cb.and(x({operation:$("delete")})),cb.and(x({operation:$("modify")})),VR.and(x({operation:$("move")})),VR.and(x({operation:$("copy")})),$n(x({operation:g()}),"operation",["add","copy","delete","modify","move"])]),x({fileType:b(Wwt.nullish(),()=>{}),mimeType:b(ub.nullish(),()=>{}),_meta:b(P(g(),T()).nullish(),()=>{})})),"operation",["add","copy","delete","modify","move"]),Kwt=be([$("git_patch"),g()]),Zwt=x({format:Kwt,text:g()}),K8=x({changes:Ve(Vwt),patch:b(Zwt.nullish(),()=>{}),_meta:b(P(g(),T()).nullish(),()=>{})}),q1=g(),Z8=x({terminalId:q1,_meta:b(P(g(),T()).nullish(),()=>{})}),FCe=Mn(be([V8.and(x({type:$("content")})),K8.and(x({type:$("diff")})),Z8.and(x({type:$("terminal")})),$n(x({type:g()}),"type",["content","diff","terminal"])]),"type",["content","diff","terminal"]),Jwt=x({path:ss,line:b(fr().gte(0).max(4294967295,{error:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),()=>{}),_meta:b(P(g(),T()).nullish(),()=>{})}),G1=x({toolCallId:H1,name:b(g().nullish(),()=>{}),title:b(g().nullish(),()=>{}),kind:b(Lwt.nullish(),()=>{}),status:b(Fwt.nullish(),()=>{}),content:b(Ve(FCe).nullish(),()=>{}),locations:b(Ve(Jwt).nullish(),()=>{}),rawInput:b(T().optional(),()=>{}),rawOutput:b(T().optional(),()=>{}),_meta:b(P(g(),T()).nullish(),()=>{})}),J8=x({toolCall:G1}),Q8=x({command:g(),cwd:ss,toolCallId:b(H1.nullish(),()=>{}),terminalId:b(q1.nullish(),()=>{}),_meta:b(P(g(),T()).nullish(),()=>{})}),Qwt=Mn(be([J8.and(x({type:$("tool_call")})),Q8.and(x({type:$("command")})),$n(x({type:g()}),"type",["command","tool_call"])]),"type",["command","tool_call"]),jCe=g(),Ywt=be([$("allow_once"),$("allow_always"),$("reject_once"),$("reject_always"),g()]),Xwt=x({optionId:jCe,name:g(),kind:Ywt,_meta:b(P(g(),T()).nullish(),()=>{})}),Y8=x({sessionId:dn,title:g(),description:b(g().nullish(),()=>{}),subject:Qwt.nullish(),options:gt(Xwt).min(1),_meta:b(P(g(),T()).nullish(),()=>{})}),ZR=x({sessionId:dn,toolCallId:b(H1.nullish(),()=>{})}),JR=x({requestId:dh}),evt=$("object"),tvt=be([$("email"),$("uri"),$("date"),$("date-time"),g()]),UCe=x({const:g(),title:g(),description:b(g().nullish(),()=>{}),_meta:b(P(g(),T()).nullish(),()=>{})}),X8=x({title:b(g().nullish(),()=>{}),description:b(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:tvt.nullish(),default:b(g().nullish(),()=>{}),enum:gt(g()).min(1).nullish(),oneOf:gt(UCe).min(1).nullish(),_meta:b(P(g(),T()).nullish(),()=>{})}),e5=x({title:b(g().nullish(),()=>{}),description:b(g().nullish(),()=>{}),minimum:rt().nullish(),maximum:rt().nullish(),default:b(rt().nullish(),()=>{}),_meta:b(P(g(),T()).nullish(),()=>{})}),t5=x({title:b(g().nullish(),()=>{}),description:b(g().nullish(),()=>{}),minimum:rt().nullish(),maximum:rt().nullish(),default:b(rt().nullish(),()=>{}),_meta:b(P(g(),T()).nullish(),()=>{})}),r5=x({title:b(g().nullish(),()=>{}),description:b(g().nullish(),()=>{}),default:b(mr().nullish(),()=>{}),_meta:b(P(g(),T()).nullish(),()=>{})}),n5=x({enum:gt(g()).min(1),_meta:b(P(g(),T()).nullish(),()=>{})}),HCe=x({anyOf:gt(UCe).min(1),_meta:b(P(g(),T()).nullish(),()=>{})}),rvt=Mn(be([n5.and(x({type:$("string")})),$n(x({type:g()}),"type",["string"]),HCe]),"type",["string"]),o5=x({title:b(g().nullish(),()=>{}),description:b(g().nullish(),()=>{}),minItems:rt().nullish(),maxItems:rt().nullish(),items:rvt,default:b(Ve(g()).nullish(),()=>{}),_meta:b(P(g(),T()).nullish(),()=>{})}),nvt=Mn(be([X8.and(x({type:$("string")})),e5.and(x({type:$("number")})),t5.and(x({type:$("integer")})),r5.and(x({type:$("boolean")})),o5.and(x({type:$("array")})),$n(x({type:g()}),"type",["array","boolean","integer","number","string"])]),"type",["array","boolean","integer","number","string"]),ovt=x({type:b(evt.optional().default("object"),()=>"object"),title:b(g().nullish(),()=>{}),properties:P(g(),nvt).optional().default({}),required:gt(g()).nullish(),description:b(g().nullish(),()=>{}),_meta:b(P(g(),T()).nullish(),()=>{})}),i5=Ho(be([ZR,JR]),x({requestedSchema:ovt})),qCe=g(),s5=Ho(be([ZR,JR]),x({elicitationId:qCe,url:_r()})),a5=Mn(Ho(be([i5.and(x({mode:$("form")})),s5.and(x({mode:$("url")})),$n(Ho(be([ZR,JR]),x({mode:g()})),"mode",["form","url"])]),x({message:g(),_meta:b(P(g(),T()).nullish(),()=>{})})),"mode",["form","url"]),GCe=g(),c5=x({serverId:GCe,_meta:b(P(g(),T()).nullish(),()=>{})}),B1=g(),QR=x({connectionId:B1,method:g(),params:P(g(),T()).nullish(),_meta:b(P(g(),T()).nullish(),()=>{})}),l5=x({connectionId:B1,_meta:b(P(g(),T()).nullish(),()=>{})}),BCe=T(),Bwr=x({id:dh,method:g(),params:be([Y8,a5,c5,QR,l5,BCe]).nullish()}),WCe=fr().gte(0).lte(65535),VCe=x({name:g(),title:b(g().nullish(),()=>{}),version:g(),_meta:b(P(g(),T()).nullish(),()=>{})}),ivt=x({_meta:b(P(g(),T()).nullish(),()=>{})}),svt=x({_meta:b(P(g(),T()).nullish(),()=>{})}),avt=x({_meta:b(P(g(),T()).nullish(),()=>{})}),cvt=x({image:b(ivt.nullish(),()=>{}),audio:b(svt.nullish(),()=>{}),embeddedContext:b(avt.nullish(),()=>{}),_meta:b(P(g(),T()).nullish(),()=>{})}),lvt=x({_meta:b(P(g(),T()).nullish(),()=>{})}),uvt=x({_meta:b(P(g(),T()).nullish(),()=>{})}),dvt=x({_meta:b(P(g(),T()).nullish(),()=>{})}),pvt=x({stdio:b(lvt.nullish(),()=>{}),http:b(uvt.nullish(),()=>{}),acp:b(dvt.nullish(),()=>{}),_meta:b(P(g(),T()).nullish(),()=>{})}),fvt=x({_meta:b(P(g(),T()).nullish(),()=>{})}),mvt=x({_meta:b(P(g(),T()).nullish(),()=>{})}),hvt=x({_meta:b(P(g(),T()).nullish(),()=>{})}),gvt=x({prompt:b(cvt.nullish(),()=>{}),mcp:b(pvt.nullish(),()=>{}),delete:b(fvt.nullish(),()=>{}),additionalDirectories:b(mvt.nullish(),()=>{}),fork:b(hvt.nullish(),()=>{}),_meta:b(P(g(),T()).nullish(),()=>{})}),yvt=x({_meta:b(P(g(),T()).nullish(),()=>{})}),bvt=x({_meta:b(P(g(),T()).nullish(),()=>{})}),xvt=x({_meta:b(P(g(),T()).nullish(),()=>{})}),Svt=be([$("full"),$("incremental")]),kvt=x({syncKind:Svt,_meta:b(P(g(),T()).nullish(),()=>{})}),_vt=x({_meta:b(P(g(),T()).nullish(),()=>{})}),wvt=x({_meta:b(P(g(),T()).nullish(),()=>{})}),vvt=x({_meta:b(P(g(),T()).nullish(),()=>{})}),Evt=x({didOpen:b(xvt.nullish(),()=>{}),didChange:b(kvt.nullish(),()=>{}),didClose:b(_vt.nullish(),()=>{}),didSave:b(wvt.nullish(),()=>{}),didFocus:b(vvt.nullish(),()=>{}),_meta:b(P(g(),T()).nullish(),()=>{})}),Rvt=x({document:b(Evt.nullish(),()=>{}),_meta:b(P(g(),T()).nullish(),()=>{})}),Tvt=x({maxCount:b(fr().gte(0).max(4294967295,{error:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),()=>{}),_meta:b(P(g(),T()).nullish(),()=>{})}),Cvt=x({_meta:b(P(g(),T()).nullish(),()=>{})}),Pvt=x({maxCount:b(fr().gte(0).max(4294967295,{error:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),()=>{}),_meta:b(P(g(),T()).nullish(),()=>{})}),Ivt=x({maxCount:b(fr().gte(0).max(4294967295,{error:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),()=>{}),_meta:b(P(g(),T()).nullish(),()=>{})}),Avt=x({_meta:b(P(g(),T()).nullish(),()=>{})}),Ovt=x({_meta:b(P(g(),T()).nullish(),()=>{})}),$vt=x({recentFiles:b(Tvt.nullish(),()=>{}),relatedSnippets:b(Cvt.nullish(),()=>{}),editHistory:b(Pvt.nullish(),()=>{}),userActions:b(Ivt.nullish(),()=>{}),openFiles:b(Avt.nullish(),()=>{}),diagnostics:b(Ovt.nullish(),()=>{}),_meta:b(P(g(),T()).nullish(),()=>{})}),Mvt=x({events:b(Rvt.nullish(),()=>{}),context:b($vt.nullish(),()=>{}),_meta:b(P(g(),T()).nullish(),()=>{})}),KCe=be([$("utf-16"),$("utf-32"),$("utf-8")]),Dvt=x({session:b(gvt.nullish(),()=>{}),auth:b(yvt.nullish(),()=>{}),providers:b(bvt.nullish(),()=>{}),nes:b(Mvt.nullish(),()=>{}),positionEncoding:b(KCe.nullish(),()=>{}),_meta:b(P(g(),T()).nullish(),()=>{})}),db=g(),Nvt=x({name:g(),label:b(g().nullish(),()=>{}),secret:b(mr().optional().default(!0),()=>!0),optional:b(mr().optional().default(!1),()=>!1),_meta:b(P(g(),T()).nullish(),()=>{})}),u5=x({methodId:db,name:g(),description:b(g().nullish(),()=>{}),vars:Kn(Ve(Nvt),()=>[]),link:b(_r().nullish(),()=>{}),_meta:b(P(g(),T()).nullish(),()=>{})}),ZCe=x({name:g(),value:g(),_meta:b(P(g(),T()).nullish(),()=>{})}),d5=x({methodId:db,name:g(),description:b(g().nullish(),()=>{}),args:b(Ve(g()).optional(),()=>[]),env:b(Ve(ZCe).optional(),()=>[]),_meta:b(P(g(),T()).nullish(),()=>{})}),p5=x({methodId:db,name:g(),description:b(g().nullish(),()=>{}),_meta:b(P(g(),T()).nullish(),()=>{})}),zvt=Mn(be([u5.and(x({type:$("env_var")})),d5.and(x({type:$("terminal")})),p5.and(x({type:$("agent")})),$n(x({type:g(),methodId:db,name:g(),description:b(g().nullish(),()=>{}),_meta:b(P(g(),T()).nullish(),()=>{})}),"type",["agent","env_var","terminal"])]),"type",["agent","env_var","terminal"]),f5=x({protocolVersion:WCe,info:VCe,capabilities:b(Dvt.optional().default({}),()=>({})),authMethods:b(Ve(zvt).optional(),()=>[]),_meta:b(P(g(),T()).nullish(),()=>{})}),Lvt=x({_meta:b(P(g(),T()).nullish(),()=>{})}),m5=g(),h5=be([$("anthropic"),$("openai"),$("azure"),$("vertex"),$("bedrock"),g()]),Fvt=x({apiType:h5,baseUrl:_r(),_meta:b(P(g(),T()).nullish(),()=>{})}),jvt=x({providerId:m5,supported:Kn(Ve(h5),()=>[]),required:mr(),current:Fvt.nullish(),_meta:b(P(g(),T()).nullish(),()=>{})}),Uvt=x({providers:gt(jvt),_meta:b(P(g(),T()).nullish(),()=>{})}),Hvt=x({_meta:b(P(g(),T()).nullish(),()=>{})}),qvt=x({_meta:b(P(g(),T()).nullish(),()=>{})}),Gvt=x({_meta:b(P(g(),T()).nullish(),()=>{})}),Bp=g(),Bvt=be([$("mode"),$("model"),$("model_config"),$("thought_level"),g()]),YR=g(),JCe=x({value:YR,name:g(),description:b(g().nullish(),()=>{}),_meta:b(P(g(),T()).nullish(),()=>{})}),Wvt=g(),Vvt=x({groupId:Wvt,name:g(),options:Kn(Ve(JCe),()=>[]),_meta:b(P(g(),T()).nullish(),()=>{})}),Kvt=be([gt(JCe),gt(Vvt)]),g5=x({currentValue:YR,options:Kvt}),y5=x({currentValue:mr()}),XR=Mn(Ho(be([g5.and(x({type:$("select")})),y5.and(x({type:$("boolean")})),$n(x({type:g()}),"type",["boolean","select"])]),x({configId:Bp,name:g(),description:b(g().nullish(),()=>{}),category:b(Bvt.nullish(),()=>{}),_meta:b(P(g(),T()).nullish(),()=>{})})),"type",["boolean","select"]),Zvt=x({sessionId:dn,configOptions:b(Ve(XR).optional(),()=>[]),_meta:b(P(g(),T()).nullish(),()=>{})}),Jvt=x({sessionId:dn,cwd:ss,additionalDirectories:b(Ve(ss).optional(),()=>[]),title:b(g().nullish(),()=>{}),updatedAt:b(Qu.datetime({offset:!0}).nullish(),()=>{}),_meta:b(P(g(),T()).nullish(),()=>{})}),QCe=g(),Qvt=x({sessions:Kn(Ve(Jvt),()=>[]),nextCursor:b(QCe.nullish(),()=>{}),_meta:b(P(g(),T()).nullish(),()=>{})}),Yvt=x({_meta:b(P(g(),T()).nullish(),()=>{})}),Xvt=x({sessionId:dn,configOptions:b(Ve(XR).optional(),()=>[]),_meta:b(P(g(),T()).nullish(),()=>{})}),eEt=x({configOptions:b(Ve(XR).optional(),()=>[]),_meta:b(P(g(),T()).nullish(),()=>{})}),tEt=x({_meta:b(P(g(),T()).nullish(),()=>{})}),rEt=x({configOptions:Kn(Ve(XR),()=>[]),_meta:b(P(g(),T()).nullish(),()=>{})}),nEt=x({_meta:b(P(g(),T()).nullish(),()=>{})}),oEt=x({sessionId:dn,_meta:b(P(g(),T()).nullish(),()=>{})}),Wp=g(),ph=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:b(P(g(),T()).nullish(),()=>{})}),k_=x({start:ph,end:ph,_meta:b(P(g(),T()).nullish(),()=>{})}),iEt=x({range:k_,newText:g(),_meta:b(P(g(),T()).nullish(),()=>{})}),b5=x({suggestionId:Wp,uri:_r(),edits:gt(iEt).min(1),cursorPosition:b(ph.nullish(),()=>{}),_meta:b(P(g(),T()).nullish(),()=>{})}),x5=x({suggestionId:Wp,uri:_r(),position:ph,_meta:b(P(g(),T()).nullish(),()=>{})}),S5=x({suggestionId:Wp,uri:_r(),position:ph,newName:g(),_meta:b(P(g(),T()).nullish(),()=>{})}),k5=x({suggestionId:Wp,uri:_r(),search:g(),replace:g(),isRegex:mr().nullish(),_meta:b(P(g(),T()).nullish(),()=>{})}),sEt=Mn(be([b5.and(x({kind:$("edit")})),x5.and(x({kind:$("jump")})),S5.and(x({kind:$("rename")})),k5.and(x({kind:$("searchAndReplace")})),$n(x({kind:g(),suggestionId:Wp}),"kind",["edit","jump","rename","searchAndReplace"])]),"kind",["edit","jump","rename","searchAndReplace"]),aEt=x({suggestions:gt(sEt),_meta:b(P(g(),T()).nullish(),()=>{})}),cEt=x({_meta:b(P(g(),T()).nullish(),()=>{})}),YCe=T(),XCe=T(),lEt=be([$(-32700),$(-32600),$(-32601),$(-32602),$(-32603),$(-32800),$(-32e3),$(-32002),fr().min(-2147483648,{error:"Invalid value: Expected int32 to be >= -2147483648"}).max(2147483647,{error:"Invalid value: Expected int32 to be <= 2147483647"})]),ePe=x({code:lEt,message:g(),data:b(T().optional(),()=>{})}),Wwr=be([x({id:dh,result:be([f5,Lvt,Uvt,Hvt,qvt,Gvt,Zvt,Qvt,Yvt,Xvt,eEt,tEt,rEt,nEt,oEt,aEt,cEt,YCe,XCe])}),x({id:dh,error:ePe})]),W1=g(),lb=x({messageId:W1,content:S_,_meta:b(P(g(),T()).nullish(),()=>{})}),_5=x({messageId:W1,content:b(Ve(S_).nullish(),()=>{}),_meta:b(P(g(),T()).nullish(),()=>{})}),w5=x({messageId:W1,content:b(Ve(S_).nullish(),()=>{}),_meta:b(P(g(),T()).nullish(),()=>{})}),v5=x({messageId:W1,content:b(Ve(S_).nullish(),()=>{}),_meta:b(P(g(),T()).nullish(),()=>{})}),E5=x({_meta:b(P(g(),T()).nullish(),()=>{})}),uEt=be([$("end_turn"),$("max_tokens"),$("max_turn_requests"),$("refusal"),$("cancelled"),g()]),dEt=x({totalTokens:rt(),inputTokens:rt(),outputTokens:rt(),thoughtTokens:b(rt().nullish(),()=>{}),cachedReadTokens:b(rt().nullish(),()=>{}),cachedWriteTokens:b(rt().nullish(),()=>{}),_meta:b(P(g(),T()).nullish(),()=>{})}),R5=x({stopReason:b(uEt.nullish(),()=>{}),usage:b(dEt.nullish(),()=>{}),_meta:b(P(g(),T()).nullish(),()=>{})}),T5=x({_meta:b(P(g(),T()).nullish(),()=>{})}),C5=Mn(be([E5.and(x({state:$("running")})),R5.and(x({state:$("idle")})),T5.and(x({state:$("requires_action")})),$n(x({state:g()}),"state",["idle","requires_action","running"])]),"state",["idle","requires_action","running"]),P5=x({toolCallId:H1,content:FCe,_meta:b(P(g(),T()).nullish(),()=>{})}),pEt=x({data:g(),_meta:b(P(g(),T()).nullish(),()=>{})}),fEt=x({exitCode:b(fr().gte(0).max(4294967295,{error:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),()=>{}),signal:b(g().nullish(),()=>{}),_meta:b(P(g(),T()).nullish(),()=>{})}),I5=x({terminalId:q1,command:b(g().nullish(),()=>{}),cwd:b(ss.nullish(),()=>{}),output:b(pEt.nullish(),()=>{}),exitStatus:b(fEt.nullish(),()=>{}),_meta:b(P(g(),T()).nullish(),()=>{})}),A5=x({terminalId:q1,data:g(),_meta:b(P(g(),T()).nullish(),()=>{})}),pb=g(),mEt=be([$("high"),$("medium"),$("low"),g()]),hEt=be([$("pending"),$("in_progress"),$("completed"),$("cancelled"),g()]),gEt=x({content:g(),priority:mEt,status:hEt,_meta:b(P(g(),T()).nullish(),()=>{})}),O5=x({planId:pb,entries:Kn(Ve(gEt),()=>[]),_meta:b(P(g(),T()).nullish(),()=>{})}),$5=x({planId:pb,uri:_r(),_meta:b(P(g(),T()).nullish(),()=>{})}),M5=x({planId:pb,content:g(),_meta:b(P(g(),T()).nullish(),()=>{})}),yEt=Mn(be([O5.and(x({type:$("items")})),$5.and(x({type:$("file")})),M5.and(x({type:$("markdown")})),$n(x({type:g(),planId:pb}),"type",["file","items","markdown"])]),"type",["file","items","markdown"]),D5=x({plan:yEt,_meta:b(P(g(),T()).nullish(),()=>{})}),N5=x({planId:pb,_meta:b(P(g(),T()).nullish(),()=>{})}),z5=x({hint:g(),_meta:b(P(g(),T()).nullish(),()=>{})}),bEt=Mn(be([z5.and(x({type:$("text")})),$n(x({type:g()}),"type",["text"])]),"type",["text"]),xEt=x({name:g(),description:g(),input:b(bEt.nullish(),()=>{}),_meta:b(P(g(),T()).nullish(),()=>{})}),L5=x({availableCommands:Kn(Ve(xEt),()=>[]),_meta:b(P(g(),T()).nullish(),()=>{})}),F5=x({configOptions:Kn(Ve(XR),()=>[]),_meta:b(P(g(),T()).nullish(),()=>{})}),j5=x({title:b(g().nullish(),()=>{}),updatedAt:b(Qu.datetime({offset:!0}).nullish(),()=>{}),_meta:b(P(g(),T()).nullish(),()=>{})}),SEt=x({amount:rt(),currency:g().regex(/^[A-Z]{3}$/),_meta:b(P(g(),T()).nullish(),()=>{})}),U5=x({used:rt(),size:rt(),cost:b(SEt.nullish(),()=>{}),_meta:b(P(g(),T()).nullish(),()=>{})}),kEt=Mn(be([lb.and(x({sessionUpdate:$("user_message_chunk")})),_5.and(x({sessionUpdate:$("user_message")})),lb.and(x({sessionUpdate:$("agent_message_chunk")})),w5.and(x({sessionUpdate:$("agent_message")})),lb.and(x({sessionUpdate:$("agent_thought_chunk")})),v5.and(x({sessionUpdate:$("agent_thought")})),C5.and(x({sessionUpdate:$("state_update")})),P5.and(x({sessionUpdate:$("tool_call_content_chunk")})),G1.and(x({sessionUpdate:$("tool_call_update")})),I5.and(x({sessionUpdate:$("terminal_update")})),A5.and(x({sessionUpdate:$("terminal_output_chunk")})),D5.and(x({sessionUpdate:$("plan_update")})),N5.and(x({sessionUpdate:$("plan_removed")})),L5.and(x({sessionUpdate:$("available_commands_update")})),F5.and(x({sessionUpdate:$("config_option_update")})),j5.and(x({sessionUpdate:$("session_info_update")})),U5.and(x({sessionUpdate:$("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"]),V1=x({sessionId:dn,update:kEt,_meta:b(P(g(),T()).nullish(),()=>{})}),H5=x({elicitationId:qCe,_meta:b(P(g(),T()).nullish(),()=>{})}),eT=x({connectionId:B1,method:g(),params:b(P(g(),T()).nullish(),()=>{}),_meta:b(P(g(),T()).nullish(),()=>{})}),tPe=T(),Vwr=x({method:g(),params:be([V1,H5,eT,tPe]).nullish()}),_Et=x({_meta:b(P(g(),T()).nullish(),()=>{})}),wEt=x({terminal:b(_Et.nullish(),()=>{}),_meta:b(P(g(),T()).nullish(),()=>{})}),vEt=x({_meta:b(P(g(),T()).nullish(),()=>{})}),EEt=x({_meta:b(P(g(),T()).nullish(),()=>{})}),REt=x({form:b(vEt.nullish(),()=>{}),url:b(EEt.nullish(),()=>{}),_meta:b(P(g(),T()).nullish(),()=>{})}),TEt=x({_meta:b(P(g(),T()).nullish(),()=>{})}),CEt=x({_meta:b(P(g(),T()).nullish(),()=>{})}),PEt=x({_meta:b(P(g(),T()).nullish(),()=>{})}),IEt=x({jump:b(TEt.nullish(),()=>{}),rename:b(CEt.nullish(),()=>{}),searchAndReplace:b(PEt.nullish(),()=>{}),_meta:b(P(g(),T()).nullish(),()=>{})}),AEt=x({auth:b(wEt.nullish(),()=>{}),elicitation:b(REt.nullish(),()=>{}),nes:b(IEt.nullish(),()=>{}),positionEncodings:b(Ve(KCe).optional(),()=>[]),_meta:b(P(g(),T()).nullish(),()=>{})}),K1=x({protocolVersion:WCe,info:VCe,capabilities:b(AEt.optional().default({}),()=>({})),_meta:b(P(g(),T()).nullish(),()=>{})}),q5=x({methodId:db,_meta:b(P(g(),T()).nullish(),()=>{})}),G5=x({_meta:b(P(g(),T()).nullish(),()=>{})}),B5=x({providerId:m5,apiType:h5,baseUrl:_r(),headers:P(g(),g()).optional(),_meta:b(P(g(),T()).nullish(),()=>{})}),W5=x({providerId:m5,_meta:b(P(g(),T()).nullish(),()=>{})}),V5=x({_meta:b(P(g(),T()).nullish(),()=>{})}),OEt=x({name:g(),value:g(),_meta:b(P(g(),T()).nullish(),()=>{})}),K5=x({name:g(),url:_r(),headers:gt(OEt).optional(),_meta:b(P(g(),T()).nullish(),()=>{})}),Z5=x({name:g(),serverId:GCe,_meta:b(P(g(),T()).nullish(),()=>{})}),J5=x({name:g(),command:ss,args:gt(g()).optional(),env:gt(ZCe).optional(),_meta:b(P(g(),T()).nullish(),()=>{})}),Q5=Mn(be([K5.and(x({type:$("http")})),Z5.and(x({type:$("acp")})),J5.and(x({type:$("stdio")})),$n(x({type:g()}),"type",["acp","http","stdio"])]),"type",["acp","http","stdio"]),Y5=x({cwd:ss,additionalDirectories:b(Ve(ss).optional(),()=>[]),mcpServers:b(Ve(Q5).optional(),()=>[]),_meta:b(P(g(),T()).nullish(),()=>{})}),X5=x({cwd:ss.nullish(),cursor:QCe.nullish(),_meta:b(P(g(),T()).nullish(),()=>{})}),e7=x({sessionId:dn,_meta:b(P(g(),T()).nullish(),()=>{})}),t7=x({sessionId:dn,cwd:ss,additionalDirectories:b(Ve(ss).optional(),()=>[]),mcpServers:b(Ve(Q5).optional(),()=>[]),_meta:b(P(g(),T()).nullish(),()=>{})}),r7=x({_meta:b(P(g(),T()).nullish(),()=>{})}),$Et=Mn(be([r7.and(x({type:$("start")})),$n(x({type:g(),_meta:b(P(g(),T()).nullish(),()=>{})}),"type",["start"])]),"type",["start"]),n7=x({sessionId:dn,cwd:ss,additionalDirectories:b(Ve(ss).optional(),()=>[]),mcpServers:b(Ve(Q5).optional(),()=>[]),replayFrom:b($Et.nullish(),()=>{}),_meta:b(P(g(),T()).nullish(),()=>{})}),o7=x({sessionId:dn,_meta:b(P(g(),T()).nullish(),()=>{})}),i7=Mn(Ho(be([x({value:YR,type:$("id")}),x({value:mr(),type:$("boolean")}),$n(x({type:g(),value:T()}),"type",["boolean","id"])]),x({sessionId:dn,configId:Bp,_meta:b(P(g(),T()).nullish(),()=>{})})),"type",["boolean","id"]),s7=x({sessionId:dn,prompt:gt(S_),_meta:b(P(g(),T()).nullish(),()=>{})}),MEt=x({uri:_r(),name:g(),_meta:b(P(g(),T()).nullish(),()=>{})}),DEt=x({name:g(),owner:g(),remoteUrl:g(),_meta:b(P(g(),T()).nullish(),()=>{})}),a7=x({workspaceUri:b(_r().nullish(),()=>{}),workspaceFolders:gt(MEt).nullish(),repository:b(DEt.nullish(),()=>{}),_meta:b(P(g(),T()).nullish(),()=>{})}),NEt=be([$("automatic"),$("diagnostic"),$("manual"),g()]),zEt=x({uri:_r(),languageId:g(),text:g(),_meta:b(P(g(),T()).nullish(),()=>{})}),LEt=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:b(P(g(),T()).nullish(),()=>{})}),FEt=x({uri:_r(),excerpts:gt(LEt),_meta:b(P(g(),T()).nullish(),()=>{})}),jEt=x({uri:_r(),diff:g(),_meta:b(P(g(),T()).nullish(),()=>{})}),UEt=x({action:g(),uri:_r(),position:ph,timestampMs:rt(),_meta:b(P(g(),T()).nullish(),()=>{})}),HEt=x({uri:_r(),languageId:g(),visibleRange:b(k_.nullish(),()=>{}),lastFocusedMs:b(rt().nullish(),()=>{}),_meta:b(P(g(),T()).nullish(),()=>{})}),qEt=be([$("error"),$("warning"),$("information"),$("hint"),g()]),GEt=x({uri:_r(),range:k_,severity:qEt,message:g(),_meta:b(P(g(),T()).nullish(),()=>{})}),BEt=x({recentFiles:gt(zEt).nullish(),relatedSnippets:gt(FEt).nullish(),editHistory:gt(jEt).nullish(),userActions:gt(UEt).nullish(),openFiles:gt(HEt).nullish(),diagnostics:gt(GEt).nullish(),_meta:b(P(g(),T()).nullish(),()=>{})}),c7=x({sessionId:dn,uri:_r(),version:rt(),position:ph,selection:k_.nullish(),triggerKind:NEt,context:BEt.nullish(),_meta:b(P(g(),T()).nullish(),()=>{})}),l7=x({sessionId:dn,_meta:b(P(g(),T()).nullish(),()=>{})}),Kwr=x({id:dh,method:g(),params:be([K1,q5,G5,B5,W5,V5,Y5,X5,e7,t7,n7,o7,i7,s7,a7,c7,l7,QR,BCe]).nullish()}),u7=x({optionId:jCe,_meta:b(P(g(),T()).nullish(),()=>{})}),WEt=Mn(be([x({outcome:$("cancelled")}),u7.and(x({outcome:$("selected")})),$n(x({outcome:g()}),"outcome",["cancelled","selected"])]),"outcome",["cancelled","selected"]),VEt=x({outcome:WEt,_meta:b(P(g(),T()).nullish(),()=>{})}),KEt=be([g(),rt(),rt(),mr(),gt(g())]),d7=x({content:P(g(),KEt).nullish()}),ZEt=Mn(Ho(be([d7.and(x({action:$("accept")})),x({action:$("decline")}),x({action:$("cancel")}),$n(x({action:g()}),"action",["accept","cancel","decline"])]),x({_meta:b(P(g(),T()).nullish(),()=>{})})),"action",["accept","cancel","decline"]),JEt=x({connectionId:B1,_meta:b(P(g(),T()).nullish(),()=>{})}),QEt=x({_meta:b(P(g(),T()).nullish(),()=>{})}),Zwr=be([x({id:dh,result:be([VEt,ZEt,JEt,QEt,XCe,YCe])}),x({id:dh,error:ePe})]),p7=x({sessionId:dn,_meta:b(P(g(),T()).nullish(),()=>{})}),f7=x({sessionId:dn,uri:_r(),languageId:g(),version:rt(),text:g(),_meta:b(P(g(),T()).nullish(),()=>{})}),YEt=x({range:k_.nullish(),text:g(),_meta:b(P(g(),T()).nullish(),()=>{})}),m7=x({sessionId:dn,uri:_r(),version:rt(),contentChanges:Kn(Ve(YEt),()=>[]),_meta:b(P(g(),T()).nullish(),()=>{})}),h7=x({sessionId:dn,uri:_r(),_meta:b(P(g(),T()).nullish(),()=>{})}),g7=x({sessionId:dn,uri:_r(),_meta:b(P(g(),T()).nullish(),()=>{})}),y7=x({sessionId:dn,uri:_r(),version:rt(),position:ph,visibleRange:k_,_meta:b(P(g(),T()).nullish(),()=>{})}),b7=x({sessionId:dn,suggestionId:Wp,_meta:b(P(g(),T()).nullish(),()=>{})}),XEt=be([$("rejected"),$("ignored"),$("replaced"),$("cancelled"),g()]),x7=x({sessionId:dn,suggestionId:Wp,reason:b(XEt.nullish(),()=>{}),_meta:b(P(g(),T()).nullish(),()=>{})}),Jwr=x({method:g(),params:be([p7,f7,m7,h7,g7,y7,b7,x7,eT,tPe]).nullish()}),e0t=x({requestId:dh,_meta:b(P(g(),T()).nullish(),()=>{})}),Qwr=x({method:g(),params:e0t.nullish()});function rn(e,t){return typeof e=="object"&&e!==null?e[t]:void 0}var Ywr=J8.and(x({type:$("tool_call")})),Xwr=Q8.and(x({type:$("command")})),evr=V8.and(x({type:$("content")})),tvr=K8.and(x({type:$("diff")})),rvr=Z8.and(x({type:$("terminal")})),t0t=H8.and(x({type:$("text")})),r0t=q8.and(x({type:$("image")})),n0t=G8.and(x({type:$("audio")})),o0t=B8.and(x({type:$("resource_link")})),i0t=W8.and(x({type:$("resource")})),nvr=cb.and(x({operation:$("add")})),ovr=cb.and(x({operation:$("delete")})),ivr=cb.and(x({operation:$("modify")})),svr=VR.and(x({operation:$("move")})),avr=VR.and(x({operation:$("copy")})),cvr=i5.and(x({mode:$("form")})).and(x({message:g()})),lvr=s5.and(x({mode:$("url")})).and(x({message:g()})),uvr=be([ZR,JR]).and(x({message:g()})),dvr=X8.and(x({type:$("string")})),pvr=e5.and(x({type:$("number")})),fvr=t5.and(x({type:$("integer")})),mvr=r5.and(x({type:$("boolean")})),hvr=o5.and(x({type:$("array")})),gvr=n5.and(x({type:$("string")}));var yvr=u5.and(x({type:$("env_var")})),bvr=d5.and(x({type:$("terminal")})),xvr=p5.and(x({type:$("agent")})),Svr=x({methodId:db,name:g()}),kvr=g5.and(x({type:$("select")})).and(x({configId:Bp,name:g()})),_vr=y5.and(x({type:$("boolean")})).and(x({configId:Bp,name:g()})),wvr=x({configId:Bp,name:g()}),vvr=b5.and(x({kind:$("edit")})),Evr=x5.and(x({kind:$("jump")})),Rvr=S5.and(x({kind:$("rename")})),Tvr=k5.and(x({kind:$("searchAndReplace")})),Cvr=x({suggestionId:Wp}),s0t=lb.and(x({sessionUpdate:$("user_message_chunk")})),a0t=_5.and(x({sessionUpdate:$("user_message")})),c0t=lb.and(x({sessionUpdate:$("agent_message_chunk")})),l0t=w5.and(x({sessionUpdate:$("agent_message")})),u0t=lb.and(x({sessionUpdate:$("agent_thought_chunk")})),d0t=v5.and(x({sessionUpdate:$("agent_thought")})),p0t=C5.and(x({sessionUpdate:$("state_update")})),f0t=P5.and(x({sessionUpdate:$("tool_call_content_chunk")})),m0t=G1.and(x({sessionUpdate:$("tool_call_update")})),h0t=I5.and(x({sessionUpdate:$("terminal_update")})),g0t=A5.and(x({sessionUpdate:$("terminal_output_chunk")})),y0t=D5.and(x({sessionUpdate:$("plan_update")})),b0t=N5.and(x({sessionUpdate:$("plan_removed")})),x0t=L5.and(x({sessionUpdate:$("available_commands_update")})),S0t=F5.and(x({sessionUpdate:$("config_option_update")})),k0t=j5.and(x({sessionUpdate:$("session_info_update")})),_0t=U5.and(x({sessionUpdate:$("usage_update")})),w0t=E5.and(x({state:$("running")})),v0t=R5.and(x({state:$("idle")})),E0t=T5.and(x({state:$("requires_action")})),Pvr=O5.and(x({type:$("items")})),Ivr=$5.and(x({type:$("file")})),Avr=M5.and(x({type:$("markdown")})),Ovr=x({planId:pb}),$vr=z5.and(x({type:$("text")})),Mvr=K5.and(x({type:$("http")})),Dvr=Z5.and(x({type:$("acp")})),Nvr=J5.and(x({type:$("stdio")})),zvr=r7.and(x({type:$("start")})),Lvr=x({type:$("id")}).and(x({value:YR})).and(x({sessionId:dn,configId:Bp})),Fvr=x({type:$("boolean")}).and(x({value:mr()})).and(x({sessionId:dn,configId:Bp})),jvr=x({value:T()}).and(x({sessionId:dn,configId:Bp})),Uvr=x({outcome:$("cancelled")}),Hvr=u7.and(x({outcome:$("selected")})),qvr=d7.and(x({action:$("accept")})),Gvr=x({action:$("decline")}),Bvr=x({action:$("cancel")});var S7={isText(e){return rn(e,"type")==="text"&&t0t.safeParse(e).success},isImage(e){return rn(e,"type")==="image"&&r0t.safeParse(e).success},isAudio(e){return rn(e,"type")==="audio"&&n0t.safeParse(e).success},isResourceLink(e){return rn(e,"type")==="resource_link"&&o0t.safeParse(e).success},isResource(e){return rn(e,"type")==="resource"&&i0t.safeParse(e).success},isCustom(e){let t=rn(e,"type");return typeof t=="string"&&!["audio","image","resource","resource_link","text"].includes(t)}};var tT={isUserMessageChunk(e){return rn(e,"sessionUpdate")==="user_message_chunk"&&s0t.safeParse(e).success},isUserMessage(e){return rn(e,"sessionUpdate")==="user_message"&&a0t.safeParse(e).success},isAgentMessageChunk(e){return rn(e,"sessionUpdate")==="agent_message_chunk"&&c0t.safeParse(e).success},isAgentMessage(e){return rn(e,"sessionUpdate")==="agent_message"&&l0t.safeParse(e).success},isAgentThoughtChunk(e){return rn(e,"sessionUpdate")==="agent_thought_chunk"&&u0t.safeParse(e).success},isAgentThought(e){return rn(e,"sessionUpdate")==="agent_thought"&&d0t.safeParse(e).success},isStateUpdate(e){return rn(e,"sessionUpdate")==="state_update"&&p0t.safeParse(e).success},isToolCallContentChunk(e){return rn(e,"sessionUpdate")==="tool_call_content_chunk"&&f0t.safeParse(e).success},isToolCallUpdate(e){return rn(e,"sessionUpdate")==="tool_call_update"&&m0t.safeParse(e).success},isTerminalUpdate(e){return rn(e,"sessionUpdate")==="terminal_update"&&h0t.safeParse(e).success},isTerminalOutputChunk(e){return rn(e,"sessionUpdate")==="terminal_output_chunk"&&g0t.safeParse(e).success},isPlanUpdate(e){return rn(e,"sessionUpdate")==="plan_update"&&y0t.safeParse(e).success},isPlanRemoved(e){return rn(e,"sessionUpdate")==="plan_removed"&&b0t.safeParse(e).success},isAvailableCommandsUpdate(e){return rn(e,"sessionUpdate")==="available_commands_update"&&x0t.safeParse(e).success},isConfigOptionUpdate(e){return rn(e,"sessionUpdate")==="config_option_update"&&S0t.safeParse(e).success},isSessionInfoUpdate(e){return rn(e,"sessionUpdate")==="session_info_update"&&k0t.safeParse(e).success},isUsageUpdate(e){return rn(e,"sessionUpdate")==="usage_update"&&_0t.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)}},k7={isRunning(e){return rn(e,"state")==="running"&&w0t.safeParse(e).success},isIdle(e){return rn(e,"state")==="idle"&&v0t.safeParse(e).success},isRequiresAction(e){return rn(e,"state")==="requires_action"&&E0t.safeParse(e).success},isCustom(e){let t=rn(e,"state");return typeof t=="string"&&!["idle","requires_action","running"].includes(t)}};function Vp(e){return e??{}}function Kp(e,t,r,n=!1){if(!(Object.hasOwn(t,e)||n&&e===U1.cancel_request)&&!e.startsWith("_"))throw new TypeError(`Custom ACP v2 ${r} method '${e}' must start with '_'`)}function aPe(e,t,r){for(let n of e)Kp(n.method,n.kind==="request"?t:r,n.kind,n.kind==="notification")}function cPe(e){let t=K1.parse(e);if(t.protocolVersion!==Gp)throw Xr.invalidParams({expectedProtocolVersion:Gp,receivedProtocolVersion:t.protocolVersion},`The v2 API only supports protocol version ${Gp}`);return t}function lPe(e){let t=typeof e=="object"&&e!==null&&!Array.isArray(e)?e:{};return cPe({...t,protocolVersion:Gp})}function uPe(e){let t=f5.parse(e);if(t.protocolVersion!==Gp)throw Xr.invalidRequest({expectedProtocolVersion:Gp,receivedProtocolVersion:t.protocolVersion},`The v2 API only supports protocol version ${Gp}`);return t}function T0t(e){return e.map(t=>{if(t.kind!=="request"||t.method!==ct.initialize)return t;let r=t.mapResponse;return{...t,params:lPe(t.params),mapResponse:n=>{let o=uPe(n);return r?r(o):o}}})}function dPe(e){return typeof e=="object"&&e!==null&&"readable"in e&&"writable"in e}function pPe(){let e=new TransformStream,t=new TransformStream;return[{readable:t.readable,writable:e.writable},{readable:e.readable,writable:t.writable}]}var bEr={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:U1.cancel_request}},fPe=Symbol("startActiveSession"),Q1=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)}},oT=class e extends Q1{constructor(t,r){super(t,r)}static create(t,r){return new e(t,r)}request(t,r,n){Kp(t,nT,"request");let o=nT[t];return this.sendRequest(t,r,o?.mapResponse,n)}notify(t,r){return Kp(t,tN,"notification",!0),this.sendNotification(t,r)}batch(t){return aPe(t,nT,tN),this.sendBatch(t)}},iT=class e extends Q1{constructor(t,r){super(t,r)}static create(t,r){return new e(t,r)}[fPe](t,r){return this.sendRequest(ct.session_new,t,n=>this.attachSession(n),r)}buildSession(t){return typeof t=="string"?X1.create(this,{cwd:t,mcpServers:[]}):X1.create(this,t)}attachSession(t){let r=new v7,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=xPe(this.connectionContext).attach(t,o),c=new Np(()=>{i.removeEventListener("abort",s)});return E7.create(this,t,o,[a,c])}request(t,r,n){Kp(t,rT,"request");let o=rT[t],i=t===ct.initialize?lPe(r):r;return this.sendRequest(t,i,o?.mapResponse,n)}notify(t,r){return Kp(t,eN,"notification",!0),this.sendNotification(t,r)}batch(t){return aPe(t,rT,eN),this.sendBatch(T0t(t))}},Y1=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)}},_7=class extends Y1{connectHandlers;client;didStartConnectHandlers=!1;constructor(t,r=[]){super(t),this.connectHandlers=r,this.client=oT.create(t.getContext())}startConnectHandlers(){this.didStartConnectHandlers||(this.didStartConnectHandlers=!0,oN(this,this.connectHandlers))}},w7=class extends Y1{connectHandlers;agent;didStartConnectHandlers=!1;constructor(t,r=[]){super(t),this.connectHandlers=r,this.agent=iT.create(t.getContext())}startConnectHandlers(){this.didStartConnectHandlers||(this.didStartConnectHandlers=!0,oN(this,this.connectHandlers))}};function mPe(e,t=[]){return new _7(e,t)}function hPe(e,t=[]){return new w7(e,t)}var v7=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 nPe(e){return structuredClone(e)}var X1=class e{cx;request;constructor(t,r){this.cx=t,this.request=nPe(r)}static create(t,r){return new e(t,r)}toRequest(){return nPe(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[fPe](this.toRequest(),t)}async withSession(t){let r=await this.start();try{return await t(r)}finally{r.dispose()}}},E7=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(S7.isText).map(c=>c.text).join("");let{update:a}=s;tT.isAgentMessage(a)?(i(a.messageId),a.content!==void 0&&o.set(a.messageId,a.content??[])):tT.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 gPe(e,t){return e?typeof e=="function"?e(t):e.parse(t):t}function ao(e,t,r){return{method:e,params:t,mapResponse:r}}function qc(e,t){return{method:e,params:t}}function yPe(e,t,r,n){e.onReceiveRequest(t.method,o=>gPe(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 bPe(e,t,r,n){e.onReceiveNotification(t.method,o=>gPe(t.params,o),(o,i)=>n(r(o,i,i.signal)))}function nN(e){let t=Object.create(null);for(let r of Object.values(e))t[r.method]=r;return t}var C0t={initialize:ao(ct.initialize,cPe,uPe),loginAuth:ao(ct.auth_login,q5,Vp),unstable_listProviders:ao(ct.providers_list,G5),unstable_setProvider:ao(ct.providers_set,B5,Vp),unstable_disableProvider:ao(ct.providers_disable,W5,Vp),newSession:ao(ct.session_new,Y5),setSessionConfigOption:ao(ct.session_set_config_option,i7),prompt:ao(ct.session_prompt,s7,Vp),unstable_messageMcp:ao(ct.mcp_message,QR),listSessions:ao(ct.session_list,X5),deleteSession:ao(ct.session_delete,e7,Vp),unstable_forkSession:ao(ct.session_fork,t7),resumeSession:ao(ct.session_resume,n7),closeSession:ao(ct.session_close,o7,Vp),logoutAuth:ao(ct.auth_logout,V5,Vp),unstable_startNes:ao(ct.nes_start,a7),unstable_suggestNes:ao(ct.nes_suggest,c7),unstable_closeNes:ao(ct.nes_close,l7,Vp)},P0t={cancelSession:qc(ct.session_cancel,p7),unstable_messageMcp:qc(ct.mcp_message,eT),unstable_didOpenDocument:qc(ct.document_did_open,f7),unstable_didChangeDocument:qc(ct.document_did_change,m7),unstable_didCloseDocument:qc(ct.document_did_close,h7),unstable_didSaveDocument:qc(ct.document_did_save,g7),unstable_didFocusDocument:qc(ct.document_did_focus,y7),unstable_acceptNes:qc(ct.nes_accept,b7),unstable_rejectNes:qc(ct.nes_reject,x7)},I0t={requestPermission:ao(vi.session_request_permission,Y8),unstable_connectMcp:ao(vi.mcp_connect,c5),unstable_messageMcp:ao(vi.mcp_message,QR),unstable_disconnectMcp:ao(vi.mcp_disconnect,l5,Vp),unstable_createElicitation:ao(vi.elicitation_create,a5)},A0t={sessionUpdate:qc(vi.session_update,V1),unstable_messageMcp:qc(vi.mcp_message,eT),unstable_completeElicitation:qc(vi.elicitation_complete,H5)},rT=nN(C0t),eN=nN(P0t),nT=nN(I0t),tN=nN(A0t);function O0t(e,t,r,n){return{params:e,requestId:n,signal:r,client:t}}function $0t(e,t,r){return{params:e,signal:r,client:t}}function M0t(e,t,r,n){return{params:e,requestId:n,signal:r,agent:t}}function D0t(e,t,r){return{params:e,signal:r,agent:t}}var R7=class{activeSessions=new Map;handleMessage(t){if(t.kind!=="notification"||t.method!==vi.session_update)return Dc.no(t);let r=V1.parse(t.params),{update:n}=r,o=tT.isStateUpdate(n)&&k7.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 Dc.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 Np(()=>{n.delete(r),n.size===0&&this.activeSessions.delete(t.sessionId)})}},oPe=new WeakMap;function xPe(e){let t=oPe.get(e);return t||(t=new R7,oPe.set(e,t)),t}function oN(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 rN=Symbol("appBuilder"),Z1=Symbol("runAgentConnectHandlers"),J1=Symbol("runClientConnectHandlers");var iPe=class{builder=zp.builder();connectHandlers=[];constructor(t={}){t.name&&this.builder.name(t.name)}[rN](){return this.builder}[Z1](t){oN(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 Kp(t,rT,"request"),this.request({method:t,params:r},n);let o=rT[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 Kp(t,eN,"notification",!0),this.notification({method:t,params:r},n);let o=eN[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 yPe(this.builder,t,(n,o,i,s)=>O0t(n,oT.create(o,s),i,s),r),this}notification(t,r){return bPe(this.builder,t,(n,o,i)=>$0t(n,oT.create(o),i),r),this}connectConnection(t,r={}){if(dPe(t)){let c=this.openStreamConnection(t);return r.deferConnectHandlers||this[Z1](c.connection),c}let[n,o]=pPe(),i=t[rN]().connect(o),s=hPe(i),a=this.openStreamConnection(n);a.rawConnection.closed.then(()=>s.close()),i.closed.then(()=>a.connection.close());try{t[J1](s),this[Z1](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:mPe(r,this.connectHandlers)}}};var sPe=class{builder=zp.builder();connectHandlers=[];constructor(t={}){t.name&&this.builder.name(t.name),this.builder.withHandler({handleMessage:(r,n)=>xPe(n).handleMessage(r),describe:()=>"client-session-update-router"})}[rN](){return this.builder}[J1](t){oN(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 Kp(t,nT,"request"),this.request({method:t,params:r},n);let o=nT[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 Kp(t,tN,"notification",!0),this.notification({method:t,params:r},n);let o=tN[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 yPe(this.builder,t,(n,o,i,s)=>M0t(n,iT.create(o,s),i,s),r),this}notification(t,r){return bPe(this.builder,t,(n,o,i)=>D0t(n,iT.create(o),i),r),this}connectConnection(t){if(dPe(t)){let a=this.openStreamConnection(t);return this[J1](a.connection),a}let[r,n]=pPe(),o=t[rN]().connect(n),i=mPe(o),s=this.openStreamConnection(r);s.rawConnection.closed.then(()=>i.close()),o.closed.then(()=>s.connection.close());try{t[Z1](i),this[J1](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:hPe(r,this.connectHandlers)}}};var SPe=1;var kPe=["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"},CEr=Object.values(Ms);var z0t=16e3,L0t={type:"object",additionalProperties:!1,required:["demand"],properties:{demand:{type:"string",minLength:1,maxLength:z0t,description:"The one-off demand this dispatch exists to satisfy."}}},F0t={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}}},OEr={version:1,method:Ms.goDispatch,params:L0t,answer:F0t};var j0t=64,_Pe=200,U0t=/^[a-z0-9][a-z0-9._-]*$/;var H0t={type:"object",additionalProperties:!1,required:["slug"],properties:{slug:{type:"string",minLength:1,maxLength:j0t,pattern:U0t.source,description:"What the human is about to work on; becomes the worktree directory name."},branch:{type:"string",minLength:1,maxLength:_Pe,description:"Branch to create; defaults to the daemon's convention for the slug."},base:{type:"string",minLength:1,maxLength:_Pe,description:"Trunk BRANCH to fork from; the remote is the Project's registered trunk remote."}}},q0t={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}}},G0t={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}}}}}},WEr={version:1,methods:{add:Ms.worktreeAdd,list:Ms.worktreeList},add:{params:H0t,answer:q0t},list:{answer:G0t}};sT();var Y0t={drain:Ms.projectDrain,stop:Ms.projectStop,status:Ms.projectStatus};async function P7(e={}){let t=e.cwd??process.cwd(),r=e.name??"RedSkills Project client",n=e.version??"1",o=e.paths??iN(),s=await X0t(async()=>{await WR(o);let l=(await ab(o)).paths,u=await nRt(l.acpSocketPath),d=[],f="",m=!1;u.once("close",()=>{m=!0}),u.once("error",()=>{m=!0});let y=Xve({name:r}).onNotification(nh.client.session.update,async({params:_})=>{_.sessionId===f&&(d.push(_.update),await e.onUpdate?.(_.update))});e.requestPermission!=null&&(y=y.onRequest(nh.client.session.requestPermission,({params:_})=>e.requestPermission(_)));let S=y.connect(_9(Q0t.toWeb(u),J0t.toWeb(u)));return await S.agent.request(nh.agent.initialize,{protocolVersion:1,clientCapabilities:{},clientInfo:{name:r,version:n},_meta:{redskills:{wireMajor:SPe}}}),f=(await S.agent.request(nh.agent.session.new,{cwd:t,mcpServers:[]})).sessionId,{connection:S,socket:u,sessionId:f,pendingUpdates:d,dead:()=>m,close(){m=!0,S.close(),u.destroy()}}}),a=s.ensure;return{control:async(l,u={})=>{let f=await(await a()).connection.agent.request(Y0t[l],{...u.target==null?{}:{target:u.target},...u.runner==null?{}:{runner:u.runner},...u.registration==null?{}:{registration:u.registration}});if(!PPe(f))throw new Error("redskilled returned an invalid Project control outcome");if(l==="status"&&!tRt(f))throw new Error("redskilled returned Project status without a valid RedSkills context");return f},async github(l){return await(await a()).connection.agent.request(Ms.githubRequest,{request:l})},async brain(l){return await(await a()).connection.agent.request(Ms.brainCall,{tool:l.tool,arguments:l.arguments})},async memory(l){return await(await a()).connection.agent.request(Ms.memoryCall,{tool:l.tool,arguments:l.arguments,...l.mode==null?{}:{mode:l.mode}})},async prompt(l){let u=await a(),d=u.pendingUpdates.length,f=await u.connection.agent.request(nh.agent.session.prompt,{sessionId:u.sessionId,prompt:[{type:"text",text:l}]});return{stopReason:f.stopReason,...eRt(f._meta),updates:u.pendingUpdates.slice(d)}},async cancel(){let l=await a();return await l.connection.agent.notify(nh.agent.session.cancel,{sessionId:l.sessionId})},async permission(l){return e.requestPermission==null?{outcome:{outcome:"cancelled"},_meta:{redskills:{permissionResolution:"hitl-required"}}}:await e.requestPermission(l)},close(){s.close()}}}async function X0t(e){let t=await e(),r=!1,n=null;return{async ensure(){if(r)throw new Error("this RedSkills Project ACP client is closed");return t.dead()?(n??=e().then(o=>(t=o,n=null,o),o=>{throw n=null,o}),await n):t},close(){r=!0,t.close()}}}function eRt(e){let r=Jp(Jp(e)?.redskills)?.projectControl;return PPe(r)?{projectControl:r}:{}}function PPe(e){let t=Jp(e);return t?.version===1&&typeof t.project_id=="string"&&typeof t.revision=="number"&&Array.isArray(t.updates)}function tRt(e){let t=Jp(Jp(e)?.context),r=Jp(t?.queue),n=Jp(t?.workers),o=Jp(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(rRt)&&(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 rRt(e){let t=Jp(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 Jp(e){return e!=null&&typeof e=="object"&&!Array.isArray(e)?e:void 0}async function nRt(e){return await new Promise((t,r)=>{let n=Z0t(e);n.once("connect",()=>t(n)),n.once("error",r)})}fee();yd();are();D_();yd();var Kz=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},Nb,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},Sh,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)}};cre();var Qz=class extends U_{constructor(t,r){super(r),this._serverInfo=t,this._loggingLevels=new Map,this.LOG_LEVEL_SEVERITY=new Map(DT.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 sw,this.setRequestHandler(iX,n=>this._oninitialize(n)),this.setNotificationHandler(aX,()=>this.oninitialized?.()),this._capabilities.logging&&this.setRequestHandler(EX,async(n,o)=>{let i=o.sessionId||o.requestInfo?.headers["mcp-session-id"]||void 0,{level:s}=n.params,a=DT.safeParse(s);return a.success&&this._loggingLevels.set(i,a.data),{}})}get experimental(){return this._experimental||(this._experimental={tasks:new Kz(this)}),this._experimental}registerCapabilities(t){if(this.transport)throw new Error("Cannot register capabilities after connecting to transport");this._capabilities=fz(this._capabilities,t)}setRequestHandler(t,r){let o=hd(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(j_,c);if(!u.success){let y=u.error instanceof Error?u.error.message:String(u.error);throw new ze(qe.InvalidParams,`Invalid tools/call request: ${y}`)}let{params:d}=u.data,f=await Promise.resolve(r(c,l));if(d.task){let y=Ns(nf,f);if(!y.success){let S=y.error instanceof Error?y.error.message:String(y.error);throw new ze(qe.InvalidParams,`Invalid task creation result: ${S}`)}return y.data}let m=Ns(gd,f);if(!m.success){let y=m.error instanceof Error?m.error.message:String(m.error);throw new ze(qe.InvalidParams,`Invalid tools/call result: ${y}`)}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){Jz(this._clientCapabilities?.tasks?.requests,t,"Client")}assertTaskHandlerCapability(t){this._capabilities&&Zz(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:jN.includes(r)?r:RT,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"},rf)}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},NT,r):this.request({method:"sampling/createMessage",params:t},Nb,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},Sh,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},Sh,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},PX,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"})}};D_();pee();yd();var jDe=Symbol.for("mcp.completable");function lre(e){return!!e&&typeof e=="object"&&jDe in e}function UDe(e){return e[jDe]?.complete}var FDe;(function(e){e.Completable="McpCompletable"})(FDe||(FDe={}));var Z1t=/^[A-Za-z0-9._-]{1,128}$/;function J1t(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"),!Z1t.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 Q1t(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 ure(e){let t=J1t(e);return Q1t(e,t.warnings),t.isValid}var Yz=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)}};fC();var aw=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 Qz(t,r)}get experimental(){return this._experimental||(this._experimental={tasks:new Yz(this)}),this._experimental}async connect(t){return await this.server.connect(t)}async close(){await this.server.close()}setToolRequestHandlers(){this._toolHandlersInitialized||(this.server.assertCanSetRequestHandler(Ah(tz)),this.server.assertCanSetRequestHandler(Ah(j_)),this.server.registerCapabilities({tools:{listChanged:!0}}),this.server.setRequestHandler(tz,()=>({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=M_(r.inputSchema);return o?lee(o,{strictUnions:!0,pipeStrategy:"input"}):Y1t})(),annotations:r.annotations,execution:r.execution,_meta:r._meta};if(r.outputSchema){let o=M_(r.outputSchema);o&&(n.outputSchema=lee(o,{strictUnions:!0,pipeStrategy:"output"}))}return n})})),this.server.setRequestHandler(j_,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=M_(t.inputSchema)??t.inputSchema,s=await MN(i,r);if(!s.success){let a="error"in s?s.error:"Unknown error",c=DN(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=M_(t.outputSchema),i=await MN(o,r.structuredContent);if(!i.success){let s="error"in i?i.error:"Unknown error",a=DN(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(Ah(rz)),this.server.registerCapabilities({completions:{}}),this.server.setRequestHandler(rz,async t=>{switch(t.params.ref.type){case"ref/prompt":return lOe(t),this.handlePromptCompletion(t,t.params.ref);case"ref/resource":return uOe(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 mC;let i=hd(n.argsSchema)?.[t.params.argument.name];if(!lre(i))return mC;let s=UDe(i);if(!s)return mC;let a=await s(t.params.argument.value,t.params.context);return qDe(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 mC;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 mC;let i=await o(t.params.argument.value,t.params.context);return qDe(i)}setResourceRequestHandlers(){this._resourceHandlersInitialized||(this.server.assertCanSetRequestHandler(Ah(L_)),this.server.assertCanSetRequestHandler(Ah(YN)),this.server.assertCanSetRequestHandler(Ah(F_)),this.server.registerCapabilities({resources:{listChanged:!0}}),this.server.setRequestHandler(L_,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(YN,async()=>({resourceTemplates:Object.entries(this._registeredResourceTemplates).map(([r,n])=>({name:r,uriTemplate:n.resourceTemplate.uriTemplate.toString(),...n.metadata}))})),this.server.setRequestHandler(F_,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(Ah(XN)),this.server.assertCanSetRequestHandler(Ah(ez)),this.server.registerCapabilities({prompts:{listChanged:!0}}),this.server.setRequestHandler(XN,()=>({prompts:Object.entries(this._registeredPrompts).filter(([,t])=>t.enabled).map(([t,r])=>({name:t,title:r.title,description:r.description,arguments:r.argsSchema?X1t(r.argsSchema):void 0}))})),this.server.setRequestHandler(ez,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=M_(n.argsSchema),i=await MN(o,t.params.arguments);if(!i.success){let c="error"in i?i.error:"Unknown error",l=DN(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:Db(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=Db(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 lre(l)})&&this.setCompletionRequestHandler(),s}_createRegisteredTool(t,r,n,o,i,s,a,c,l){ure(t);let u={title:r,description:n,inputSchema:HDe(o),outputSchema:HDe(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"&&ure(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=Db(d.paramsSchema)),typeof d.outputSchema<"u"&&(u.outputSchema=Db(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(dre(c))o=r.shift(),r.length>1&&typeof r[0]=="object"&&r[0]!==null&&!dre(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 Y1t={type:"object",properties:{}};function GDe(e){return e!==null&&typeof e=="object"&&"parse"in e&&typeof e.parse=="function"&&"safeParse"in e&&typeof e.safeParse=="function"}function BDe(e){return"_def"in e||"_zod"in e||GDe(e)}function dre(e){return typeof e!="object"||e===null||BDe(e)?!1:Object.keys(e).length===0?!0:Object.values(e).some(GDe)}function HDe(e){if(e){if(dre(e))return Db(e);if(!BDe(e))throw new Error("inputSchema must be a Zod schema or raw shape, received an unrecognized object");return e}}function X1t(e){let t=hd(e);return t?Object.entries(t).map(([r,n])=>{let o=bAe(n),i=xAe(n);return{name:r,description:o,required:!i}}):[]}function Ah(e){let r=hd(e)?.method;if(!r)throw new Error("Schema is missing a method literal");let n=NN(r);if(typeof n=="string")return n;throw new Error("Schema method literal must be a string")}function qDe(e){return{completion:{values:e.slice(0,100),total:e.length,hasMore:e.length>100}}}var mC={completion:{values:[],hasMore:!1}};pre();import WDe from"node:process";var hC=class{constructor(t=WDe.stdin,r=WDe.stdout){this._stdin=t,this._stdout=r,this._readBuffer=new cw,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=Xz(t);this._stdout.write(n)?r():this._stdout.once("drain",r)})}};import{resolve as P$}from"node:path";import{fileURLToPath as Gdt}from"node:url";Jn();function VDe(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)}]}h_();function fre(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)?e:null}function mre(e){return typeof e=="string"&&e.trim()!==""?e:null}function tNt(e){let t=fre(e);if(t===null)return null;let r=fre(t.demand);return mre(r?.refusal)??mre(t.latest_refusal)}function KDe(e){return{tool:"status",args:{scope:"project"},why:e}}function rNt(){return{tool:"status",args:{scope:"host"},why:"diagnose why the host daemon does not answer before changing registration"}}function nNt(e,t){let r=e.registration;return r.daemon_reachable?!r.held&&r.repair!==void 0&&r.repair!=="none"?m_():e.live_workers.length>0&&t===null?{tool:"status",args:{scope:"worker"},why:"observe the Workers already draining this project's queue"}:KDe(t!==null?"observe when the daemon's refusal clears and capacity begins draining again":"observe the next socket-local queue poll and Worker birth"):rNt()}function oNt(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 iNt(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 ZDe(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=oNt(r),i=tNt(n),s=nNt(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:mre(fre(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:iNt(t())}}}]}Jn();function JDe(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})}]}Jn();var sNt=["requeue","retake","park","close"];function QDe(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(sNt),rationale:w.string().min(1)},invoke:t=>e.hitlResolve(t)}]}Jn();var eL="2.0.0";function tL(e,t){return{version:eL,schema:e,projection:t}}var IOr=w.object({age_s:w.number(),stale:w.boolean(),stale_after_s:w.number(),reason:w.enum(["fresh","aged-out","never-observed","orphaned"])}),aNt=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"])}),cNt=w.object({tool:w.string().min(1),args:w.record(w.string(),w.unknown()),why:w.string().min(1)}),lNt=w.union([cNt,w.literal("none")]),uNt=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:lNt.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:aNt.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"})}),dNt=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()})}),pNt=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)}),gC=w.object({registration:uNt,validation_schedule:pNt,birth_latch:dNt.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()}),fNt=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()}),mNt=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()}),hNt=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()})}),XDe=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:fNt}),live:w.boolean(),active:w.boolean(),renderable_live:w.boolean(),liveness:w.enum(["active","quiet-but-live","dead"]),liveness_verdict:mNt,daemon_liveness:hNt.optional()}),rL=w.array(XDe),nL=w.array(XDe.partial()),gNt=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()}),yC=w.object({workers:w.array(gNt),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()}),YDe=w.object({number:w.number(),title:w.string(),labels:w.array(w.string())}),e1e=w.object({ready_for_agent:w.object({eligible:w.array(YDe),held_for_summon:w.array(YDe)}),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()}))}),t1e=tL(gC),AOr=tL(rL,{input:"fields",schema:nL}),OOr=tL(yC),r1e=tL(e1e);function yNt(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 n1e(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=yNt(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}}})}Jn();var o1e="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`).",hre=class extends Error{constructor(t){super(t===void 0||t===""?o1e:`fleet ${JSON.stringify(t)}: ${o1e}`),this.name="FleetNamingRemovedError"}};function lw(e){if(!(e==null||e===""))throw new hre(typeof e=="string"?e:String(e))}Jn();var bNt=w.object({tool:w.literal("status"),args:w.object({scope:w.enum(["worker","project","host"])})});function i1e(e){return w.object({deprecated:w.literal(!0),message:w.string().min(1),replacement:bNt,result:e})}function a1e(e){return{version:e.version,schema:i1e(e.schema),...e.projection===void 0?{}:{projection:{input:e.projection.input,schema:i1e(e.projection.schema)}}}}var xNt=w.object({status:w.unknown(),vitals:rL,monitor:yC}),SNt=w.object({status:w.unknown(),vitals:nL,monitor:yC}),s1e=w.object({state:w.unknown(),dashboard:w.unknown(),provision_check:w.unknown(),unit_status:w.unknown()}),kNt={version:eL,schema:w.union([gC,xNt,s1e]),projection:{input:"fields",schema:w.union([gC,SNt,s1e])}};function c1e(e,t,r){return{deprecated:!0,message:`${e} is deprecated; use status { scope: ${t} }`,replacement:{tool:"status",args:{scope:t}},result:r}}async function _Nt(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 l1e(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:kNt,invoke:t=>_Nt(e,t)}]}oL();var iL={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 p1e=w.record(w.string(),w.union([w.string(),w.number(),w.boolean()])),bC=w.string().optional().describe("REMOVED: naming a fleet is refused; a project has one producer.");function f1e(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:bC},outputContract:a1e(t1e),invoke:async({fleet:t})=>(lw(t),c1e("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(iL).optional(),config:p1e.optional(),base:w.string().min(1).optional(),fleet:bC},invoke:async t=>(lw(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(iL).optional(),config:p1e.optional(),base:w.string().min(1).optional(),fleet:bC},invoke:async t=>(lw(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:bC},invoke:async({latch:t,fleet:r})=>(lw(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:bC},invoke:async({force:t,fleet:r})=>(lw(r),e.projectStop({force:t}))}]}Jn();function m1e(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 h1e(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()}]}Jn();function g1e(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()}]}Jn();function y1e(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})}]}Jn();function b1e(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(iL).optional()},outputContract:r1e,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})}]}Jn();function x1e(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)}]}Jn();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)}]}Jn();Jn();h_();function yre(e){let t=ma({state:e instanceof Error?e.message:String(e),repair:sb("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 bre={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 xre(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 k1e(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:bre,invoke:t=>{let r;try{r=xre(t)}catch(n){return Promise.resolve(yre(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 _1e(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:{...bre,text:w.string().min(1)},invoke:t=>{let r;try{r=xre(t)}catch(n){return Promise.resolve(yre(n))}return e.workerRequest({...r,text:t.text})}}]}function w1e(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()}]}Jn();h_();function v1e(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:sb("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 E1e(e,t){return t==="allow"?e:e.map(r=>{if(!r.dangerClass)return r;if(t==="deny")return{...r,invoke:async i=>v1e("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 v1e("confirm",r.name,i);let{confirmation:s,...a}=i;return o(a)}}})}Jn();function R1e(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})}]}Jn();function T1e(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})}]}Jn();function C1e(e){return[{name:"standing_orders_show",title:"Show standing orders for this project",description:"READ-ONLY: return all standing orders for this project. Standing orders are an append-only, numbered register injected verbatim into every Worker brief.",inputSchema:{project_label:w.string().min(1).optional().describe("Override the current project label")},invoke:t=>e.standingOrdersShow(t)},{name:"standing_orders_append",title:"Append a standing order",description:"MUTATING: append a new standing order to this project's register. The order is injected verbatim into every Worker brief at admission and on resume. Append is append-only \u2014 existing orders are never mutated or renumbered.",inputSchema:{text:w.string().min(1).describe("The standing order text"),project_label:w.string().min(1).optional().describe("Override the current project label")},invoke:t=>e.standingOrdersAppend(t)}]}var sL="Call the redskilled MCP's `help` tool.\nFollow its guidance and invoke the returned `next` call.",Sre=[{name:"drain",title:"Drain this project's queue",description:"Find the next action for starting or continuing a project drain.",body:sL},{name:"diagnose",title:"Diagnose redskilled",description:"Find the next action for understanding a redskilled problem.",body:sL},{name:"configure",title:"Configure redskilled",description:"Find the next action for changing project execution configuration.",body:sL},{name:"stop",title:"Stop project work",description:"Find the next action for stopping project work safely.",body:sL}];var P1e="rs_dev";function I1e(e,t="allow"){let r=[],n=[...ZDe(e,()=>r),...l1e(e),...f1e(e),...b1e(e),...h1e(e),...k1e(e),..._1e(e),...g1e(e),...m1e(e),...y1e(e),...VDe(e),...JDe(e),...QDe(e),...T1e(e),...R1e(e),...S1e(e),...w1e(e),...x1e(e),...C1e(e)];return r=E1e(n1e(n),t),r}Yt();function uw(e){return tn(JSON.parse(JSON.stringify(e??null)),{objectArrayColumns:!0,primitiveArrayColumns:!0})}var wNt=new Map([["drain","drain"],["project_drain","drain"],["project_stop","stop"],["project_status","status"],["status","status"]]),vNt=new Set(["target","runner","scope","registration","live_only","fields","worker"]);async function A1e(e,t,r){let n=wNt.get(t);if(n!=null){let o=Object.keys(r).filter(i=>!vNt.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,ENt(r))}if(!TNt(t))throw new Error(`unsupported ACP Project capability ${JSON.stringify(t)}`);return await e.prompt(RNt(t,r))}function ENt(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 RNt(e,t){return`/${e} ${JSON.stringify(t)}`}function TNt(e){return/^[a-z][a-z0-9_]*$/.test(e)&&!e.startsWith("private_")&&!e.includes("worker_birth")&&!e.includes("daemon_protocol")&&!e.includes("github_client")}Ere();oL();import{execFileSync as zzt}from"node:child_process";wR();wd();function iNe(e){let t=aNe(e.repo).join("/"),r=e.selector??{},n=[`repo:${t}`,"is:issue","is:open",lL(e.readyLabel??su)];r.lane!=null&&r.lane!==""&&n.push(lL(`lane:${r.lane}`)),r.label!=null&&r.label!==""&&n.push(lL(r.label));for(let o of r.tags??[])o!==""&&n.push(lL(`${Tre}${o}`));return r.user!=null&&r.user!==""&&r.user!=="@me"&&n.push(`author:${r.user}`),n.join(" ")}function sNe(e){let[t,r]=aNe(e.repo),n=e.selector??{},o=e.readyLabel??su,i=[o];n.lane!=null&&n.lane!==""&&i.push(`lane:${n.lane}`),n.label!=null&&n.label!==""&&i.push(n.label);for(let a of n.tags??[])a!==""&&i.push(`${Tre}${a}`);let s=n.user!=null&&n.user!==""&&n.user!=="@me"?n.user:void 0;return{owner:t,repo:r,labels:i,...s===void 0?{}:{creator:s},counter_labels:{ready:o,human:Oh}}}function lL(e){return`label:${JSON.stringify(e)}`}function aNe(e){let t=e.trim().split("/");if(t.length!==2||t[0]===""||t[1]==="")throw new Error("a registration needs the repository its queue lives in: the daemon polls the string it is handed and cannot work out which tracker a checkout belongs to");return[t[0],t[1]]}var WNt="Implement issue #{{work_item}} in this workspace. The Ticket is already claimed for you, and the daemon runs the gate, publishes your commits and lands the pull request after you finish \u2014 so never touch GitHub yourself: no label moves, no claim or status comments, no PR. Your whole job is the change and its commits, right here. You are already standing in your own dedicated worktree on the Ticket's base branch: work and commit right here, and never create another worktree \u2014 the repository's worktree lanes govern interactive sessions, not Workers. When the change is committed, say <promise>DONE</promise>. If the work is genuinely blocked, say what blocks it and <promise>BLOCKED</promise>.";function cNe(e){let t={repo:e.repo,...e.selector==null?{}:{selector:e.selector},...e.readyLabel==null?{}:{readyLabel:e.readyLabel}};return{selector:iNe(t),queue_poll:sNe(t),argv:jp("red-skills-redskilled",["acp-worker",...e.runner==null?[]:["--child-agent",e.runner]],e.version).split(" "),workspace_path:e.workspacePath,trunk:{remote:"origin",branch:e.trunkBranch??"main"},prompt:WNt,...e.validationCommands==null||e.validationCommands.length===0?{}:{validation_commands:[...e.validationCommands]},target:e.target}}wC();lf();function wze(e,t,r={},n=vre){let o=Fzt(e,n);if(o==null)return;let i=typeof r.target=="number"&&Number.isInteger(r.target)&&r.target>=0?r.target:1,s=typeof r.runner=="string"&&r.runner.length>0?r.runner:void 0,a=Lzt(e);return cNe({repo:o,workspacePath:e,target:i,version:t,...s==null?{}:{runner:s},..._ze(e)==null?{}:{trunkBranch:_ze(e)},...a.length===0?{}:{validationCommands:a}})}function Lzt(e){try{let t=kze(_C(cu(e).configPath,{warn:()=>{}}));return[...t.post_done??[],...t.landing??[]]}catch{return[]}}function _ze(e){try{let r=zzt("git",["-C",e,"symbolic-ref","refs/remotes/origin/HEAD"],{encoding:"utf8",timeout:5e3}).trim().split("/").pop();return r==null||r===""?void 0:r}catch{return}}function Fzt(e,t=vre){let r;try{r=t(e).name}catch{return}return/^[^/\s]+\/[^/\s]+$/.test(r)?r:void 0}yd();var hw="redskilled://lanes/events",jzt=1e3;function vze(e,t,r={}){let n=r.bufferLimit??jzt,o=[],i=0,s,a=c=>{o.push(c.record),o.length>n&&o.splice(0,o.length-n),e.sendResourceUpdated({uri:hw})};return e.registerCapabilities({resources:{subscribe:!0}}),e.setRequestHandler(L_,()=>({resources:[{uri:hw,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(F_,c=>{let l=Qre(c);if(l!==hw)throw new Error(`unknown resource ${JSON.stringify(l)}`);let u=o.splice(0,o.length);return{contents:[{uri:hw,mimeType:"application/toon",text:uw({events:u})}]}}),e.setRequestHandler(mX,async c=>Qre(c)!==hw?{}:(i+=1,i===1&&(s=await t.subscribe(a),t.start(r.intervalMs)),{})),e.setRequestHandler(hX,c=>Qre(c)!==hw?{}:(i>0&&(i-=1),i===0&&(s?.(),s=void 0,t.stop()),{})),{poll:()=>t.poll(),stop:()=>{s?.(),s=void 0,t.stop()}}}function Qre(e){let t=e?.params;return typeof t?.uri=="string"?t.uri:""}function Rze(e){let t=new Set,r,n,o=async()=>{let s=await e("events_since",r===void 0?{}:{cursor:r});if(!Eze(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(Eze):[];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 Eze(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}Jn();var Yre="rs_github",Tze="github_request",bL=Ms.githubRequest;function Xre(){return[{name:Tze,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:bL,inputSchema:{method:w.enum(kPe),path:w.string().min(1),body:w.record(w.unknown()).optional(),headers:w.record(w.string()).optional()}}]}function Cze(e){return{request:{method:e.method,path:e.path,...e.body===void 0?{}:{body:e.body},...e.headers===void 0?{}:{headers:e.headers}}}}function ene(e){let t=new aw({name:Yre,version:e.version}),r=t.registerTool.bind(t);for(let n of e.tools??Xre())r(n.name,{title:n.title,description:n.description,inputSchema:n.inputSchema},async o=>({content:[{type:"text",text:uw(await e.invoke(n.method,Cze(o)))}]}));return t}var dk=XW("redskilled-mcp");function qlr(e=process.cwd(),t){let r=new aw({name:P1e,version:dk.version}),n=r.registerTool.bind(r),o=t??(async()=>{throw new Error("REDSKILLED_ACP_UNAVAILABLE: the stdio adapter has no ACP client")}),i={},s=(a,c)=>a==="drain"&&c.registration==null?{...c,registration:wze(e,dk.version,c)}:c;for(let a of I1e(i))n(a.name,{title:a.title,description:a.description,inputSchema:a.inputSchema},async c=>({content:[{type:"text",text:uw(await o(a.name,s(a.name,c)))}]}));for(let a of Sre)r.registerPrompt(a.name,{title:a.title,description:a.description},async()=>({messages:[{role:"user",content:{type:"text",text:a.body}}]}));return vze(r.server,Rze(o)),r}async function Bdt(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 P$(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 P$(Gdt(i.uri))}catch{}return P$(r)}async function Wdt(e){let t,r=new Promise(n=>{t=n});e.server.server.onclose=t,await e.server.connect(e.transport),await r}async function Glr(){let e=process.cwd(),t,r,n=()=>(t??=Bdt(r.server,process.env,e).then(i=>P7({cwd:i,name:"RedSkills GitHub MCP adapter",version:dk.version})),t);r=ene({version:dk.version,invoke:async(i,s)=>{if(i!==bL)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 Wdt({server:r,transport:new hC})}finally{if(t!==void 0)try{(await t).close()}catch{}process.removeListener("SIGINT",o),process.removeListener("SIGTERM",o)}}async function Blr(){let e=process.cwd(),t,r,n=()=>(t??=Bdt(r.server,process.env,e).then(i=>P7({cwd:i,name:"RedSkills MCP adapter",version:dk.version})),t);r=qlr(e,async(i,s)=>A1e(await n(),i,s));let o=()=>{r.close()};process.once("SIGINT",o),process.once("SIGTERM",o);try{await Wdt({server:r,transport:new hC})}finally{if(t!==void 0)try{(await t).close()}catch{}process.removeListener("SIGINT",o),process.removeListener("SIGTERM",o)}}var Wlr=`Usage: red-skills-redskilled-mcp [command]
444
+ `,u=e.getWriter();try{await u.write(r.encode(l))}finally{u.releaseLock()}}});return{readable:s,writable:a}}var afr=PZ.and(x({mode:$("form")})).and(x({message:g()})),cfr=IZ.and(x({mode:$("url")})).and(x({message:g()})),lfr=be([pR,fR]).and(x({message:g()})),ufr=wZ.and(x({type:$("string")})),dfr=vZ.and(x({type:$("number")})),pfr=EZ.and(x({type:$("integer")})),ffr=RZ.and(x({type:$("boolean")})),mfr=CZ.and(x({type:$("array")})),hfr=TZ.and(x({type:$("string")}));var gfr=e9.and(x({action:$("accept")})),yfr=x({action:$("decline")}),bfr=x({action:$("cancel")});function _9(e,t){return h9(e,t)}function Nc(e){return e??{}}function Hve(e){return typeof e=="object"&&e!==null&&"readable"in e&&"writable"in e}function qve(){let e=new TransformStream,t=new TransformStream;return[{readable:t.readable,writable:e.writable},{readable:e.readable,writable:t.writable}]}var nh={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:t4.cancel_request}},Gve=Symbol("startActiveSession"),RD=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)}},mR=class e extends RD{constructor(t,r){super(t,r)}static create(t,r){return new e(t,r)}request(t,r,n){let o=Qve[t];return this.sendRequest(t,r,o?.mapResponse,n)}notify(t,r){return this.sendNotification(t,r)}},hR=class e extends RD{constructor(t,r){super(t,r)}static create(t,r){return new e(t,r)}[Gve](t,r){return this.sendRequest(Me.session_new,t,n=>this.attachSession(n),r)}buildSession(t){return typeof t=="string"?CD.create(this,{cwd:t,mcpServers:[]}):CD.create(this,t)}attachSession(t){let r=new b9,n=this.connectionContext.signal,o=()=>{r.fail(n.reason??new Error("ACP connection closed"))};n.aborted?o():n.addEventListener("abort",o);let i=Yve(this.connectionContext).attach(t,r),s=new Np(()=>{n.removeEventListener("abort",o)});return x9.create(this,t,r,[i,s])}request(t,r,n){let o=Jve[t];return this.sendRequest(t,r,o?.mapResponse,n)}notify(t,r){return this.sendNotification(t,r)}},TD=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)}},g9=class extends TD{connectHandlers;client;didStartConnectHandlers=!1;constructor(t,r=[]){super(t),this.connectHandlers=r,this.client=mR.create(t.getContext())}startConnectHandlers(){this.didStartConnectHandlers||(this.didStartConnectHandlers=!0,OD(this,this.connectHandlers))}},y9=class extends TD{connectHandlers;agent;didStartConnectHandlers=!1;constructor(t,r=[]){super(t),this.connectHandlers=r,this.agent=hR.create(t.getContext())}startConnectHandlers(){this.didStartConnectHandlers||(this.didStartConnectHandlers=!0,OD(this,this.connectHandlers))}};function Bve(e,t=[]){return new g9(e,t)}function Wve(e,t=[]){return new y9(e,t)}var b9=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 Fve(e){return{...e,additionalDirectories:e.additionalDirectories?[...e.additionalDirectories]:void 0,mcpServers:[...e.mcpServers]}}var CD=class e{cx;request;constructor(t,r){this.cx=t,this.request=Fve(r)}static create(t,r){return new e(t,r)}toRequest(){return Fve(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[Gve](this.toRequest(),t)}async withSession(t){let r=await this.start();try{return await t(r)}finally{r.dispose()}}},x9=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 Vve(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 Xu(e,t){return{method:e,params:t}}function Kve(e,t,r,n){e.onReceiveRequest(t.method,o=>Vve(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 Zve(e,t,r,n){e.onReceiveNotification(t.method,o=>Vve(t.params,o),(o,i)=>n(r(o,i,i.signal)))}function AD(e){let t={};for(let r of Object.values(e))t[r.method]=r;return t}var Qyt={initialize:en(Me.initialize,SD),newSession:en(Me.session_new,UZ),loadSession:en(Me.session_load,HZ,Nc),unstable_forkSession:en(Me.session_fork,BZ),listSessions:en(Me.session_list,qZ),deleteSession:en(Me.session_delete,GZ,Nc),resumeSession:en(Me.session_resume,WZ),closeSession:en(Me.session_close,VZ,Nc),setSessionMode:en(Me.session_set_mode,KZ,Nc),setSessionConfigOption:en(Me.session_set_config_option,ZZ),authenticate:en(Me.authenticate,NZ,Nc),unstable_listProviders:en(Me.providers_list,zZ),unstable_setProvider:en(Me.providers_set,LZ,Nc),unstable_disableProvider:en(Me.providers_disable,FZ,Nc),logout:en(Me.logout,jZ,Nc),prompt:en(Me.session_prompt,JZ),unstable_startNes:en(Me.nes_start,QZ),unstable_suggestNes:en(Me.nes_suggest,YZ),unstable_closeNes:en(Me.nes_close,XZ,Nc)},Yyt={cancel:Xu(Me.session_cancel,t9),unstable_didOpenDocument:Xu(Me.document_did_open,r9),unstable_didChangeDocument:Xu(Me.document_did_change,n9),unstable_didCloseDocument:Xu(Me.document_did_close,o9),unstable_didSaveDocument:Xu(Me.document_did_save,i9),unstable_didFocusDocument:Xu(Me.document_did_focus,s9),unstable_acceptNes:Xu(Me.nes_accept,a9),unstable_rejectNes:Xu(Me.nes_reject,c9)},Xyt={requestPermission:en(ir.session_request_permission,yZ),writeTextFile:en(ir.fs_write_text_file,fZ,Nc),readTextFile:en(ir.fs_read_text_file,mZ),createTerminal:en(ir.terminal_create,bZ),terminalOutput:en(ir.terminal_output,xZ),releaseTerminal:en(ir.terminal_release,SZ,Nc),waitForTerminalExit:en(ir.terminal_wait_for_exit,kZ),killTerminal:en(ir.terminal_kill,_Z,Nc),unstable_createElicitation:en(ir.elicitation_create,AZ)},ebt={sessionUpdate:Xu(ir.session_update,xD),unstable_completeElicitation:Xu(ir.elicitation_complete,DZ)},Jve=AD(Qyt),tbt=AD(Yyt),Qve=AD(Xyt),rbt=AD(ebt);function nbt(e,t,r,n){return{params:e,requestId:n,signal:r,client:t}}function obt(e,t,r){return{params:e,signal:r,client:t}}function ibt(e,t,r,n){return{params:e,requestId:n,signal:r,agent:t}}function sbt(e,t,r){return{params:e,signal:r,agent:t}}var S9=class{activeSessions=new Map;handleMessage(t){if(t.kind!=="notification"||t.method!==ir.session_update)return Dc.no(t);let r=xD.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 Dc.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 Np(()=>{n.delete(r),n.size===0&&this.activeSessions.delete(t.sessionId)})}},jve=new WeakMap;function Yve(e){let t=jve.get(e);return t||(t=new S9,jve.set(e,t)),t}function OD(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 PD=Symbol("appBuilder"),vD=Symbol("runAgentConnectHandlers"),ED=Symbol("runClientConnectHandlers"),ID={allowBatches:!1};var Uve=class{builder=zp.builder();connectHandlers=[];constructor(t={}){t.name&&this.builder.name(t.name)}[PD](){return this.builder}[vD](t){OD(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=Jve[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=tbt[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 Kve(this.builder,t,(n,o,i,s)=>nbt(n,mR.create(o,s),i,s),r),this}notification(t,r){return Zve(this.builder,t,(n,o,i)=>obt(n,mR.create(o),i),r),this}connectConnection(t,r={}){if(Hve(t)){let c=this.openStreamConnection(t);return r.deferConnectHandlers||this[vD](c.connection),c}let[n,o]=qve(),i=t[PD]().connect(o,ID),s=Wve(i),a=this.openStreamConnection(n);a.rawConnection.closed.then(()=>s.close()),i.closed.then(()=>a.connection.close());try{t[ED](s),this[vD](a.connection)}catch(c){throw s.close(c),a.connection.close(c),c}return a}openStreamConnection(t){let r=this.builder.connect(t,ID);return{rawConnection:r,connection:Bve(r,this.connectHandlers)}}};function Xve(e){return new k9(e)}var k9=class{builder=zp.builder();connectHandlers=[];constructor(t={}){t.name&&this.builder.name(t.name),this.builder.withHandler({handleMessage:(r,n)=>Yve(n).handleMessage(r),describe:()=>"client-session-update-router"})}[PD](){return this.builder}[ED](t){OD(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=Qve[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=rbt[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 Kve(this.builder,t,(n,o,i,s)=>ibt(n,hR.create(o,s),i,s),r),this}notification(t,r){return Zve(this.builder,t,(n,o,i)=>sbt(n,hR.create(o),i),r),this}connectConnection(t){if(Hve(t)){let a=this.openStreamConnection(t);return this[ED](a.connection),a}let[r,n]=qve(),o=t[PD]().connect(n,ID),i=Bve(o),s=this.openStreamConnection(r);s.rawConnection.closed.then(()=>i.close()),o.closed.then(()=>s.connection.close());try{t[vD](i),this[ED](s.connection)}catch(a){throw i.close(a),s.connection.close(a),a}return s}openStreamConnection(t){let r=this.builder.connect(t,ID);return{rawConnection:r,connection:Wve(r,this.connectHandlers)}}},Tfr=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]),Cfr=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]),Pfr=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]),Ifr=new Set([ir.session_update,ir.elicitation_complete]);U8();$8();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"},U1={cancel_request:"$/cancel_request"},Gp=2;var dh=be([rt(),g()]).nullable(),dn=g(),H1=g(),Lwt=be([$("read"),$("edit"),$("delete"),$("move"),$("search"),$("execute"),$("think"),$("fetch"),$("switch_mode"),$("other"),g()]),Fwt=be([$("pending"),$("in_progress"),$("completed"),$("failed"),$("cancelled"),g()]),jwt=be([$("assistant"),$("user"),g()]),KR=x({audience:b(Ve(jwt).nullish(),()=>{}),lastModified:b(Qu.datetime({offset:!0}).nullish(),()=>{}),priority:b(rt().gte(0).lte(1).nullish(),()=>{}),_meta:b(P(g(),T()).nullish(),()=>{})}),H8=x({text:g(),annotations:b(KR.nullish(),()=>{}),_meta:b(P(g(),T()).nullish(),()=>{})}),ub=g(),q8=x({data:g(),mimeType:ub,uri:b(_r().nullish(),()=>{}),annotations:b(KR.nullish(),()=>{}),_meta:b(P(g(),T()).nullish(),()=>{})}),G8=x({data:g(),mimeType:ub,annotations:b(KR.nullish(),()=>{}),_meta:b(P(g(),T()).nullish(),()=>{})}),Uwt=be([$("light"),$("dark"),g()]),Hwt=x({src:_r(),mimeType:b(ub.nullish(),()=>{}),sizes:b(Ve(g()).nullish(),()=>{}),theme:b(Uwt.nullish(),()=>{})}),B8=x({name:g(),uri:_r(),title:b(g().nullish(),()=>{}),description:b(g().nullish(),()=>{}),icons:b(Ve(Hwt).nullish(),()=>{}),mimeType:b(ub.nullish(),()=>{}),size:b(rt().nullish(),()=>{}),annotations:b(KR.nullish(),()=>{}),_meta:b(P(g(),T()).nullish(),()=>{})}),qwt=x({text:g(),uri:_r(),mimeType:b(ub.nullish(),()=>{}),_meta:b(P(g(),T()).nullish(),()=>{})}),Gwt=x({blob:g(),uri:_r(),mimeType:b(ub.nullish(),()=>{}),_meta:b(P(g(),T()).nullish(),()=>{})}),Bwt=be([qwt,Gwt]),W8=x({resource:Bwt,annotations:b(KR.nullish(),()=>{}),_meta:b(P(g(),T()).nullish(),()=>{})}),S_=Mn(be([H8.and(x({type:$("text")})),q8.and(x({type:$("image")})),G8.and(x({type:$("audio")})),B8.and(x({type:$("resource_link")})),W8.and(x({type:$("resource")})),$n(x({type:g()}),"type",["audio","image","resource","resource_link","text"])]),"type",["audio","image","resource","resource_link","text"]),V8=x({content:S_,_meta:b(P(g(),T()).nullish(),()=>{})}),Wwt=be([$("text"),$("binary"),$("directory"),$("symlink"),g()]),ss=g(),cb=x({path:ss}),VR=x({oldPath:ss,path:ss}),Vwt=Mn(Ho(be([cb.and(x({operation:$("add")})),cb.and(x({operation:$("delete")})),cb.and(x({operation:$("modify")})),VR.and(x({operation:$("move")})),VR.and(x({operation:$("copy")})),$n(x({operation:g()}),"operation",["add","copy","delete","modify","move"])]),x({fileType:b(Wwt.nullish(),()=>{}),mimeType:b(ub.nullish(),()=>{}),_meta:b(P(g(),T()).nullish(),()=>{})})),"operation",["add","copy","delete","modify","move"]),Kwt=be([$("git_patch"),g()]),Zwt=x({format:Kwt,text:g()}),K8=x({changes:Ve(Vwt),patch:b(Zwt.nullish(),()=>{}),_meta:b(P(g(),T()).nullish(),()=>{})}),q1=g(),Z8=x({terminalId:q1,_meta:b(P(g(),T()).nullish(),()=>{})}),FCe=Mn(be([V8.and(x({type:$("content")})),K8.and(x({type:$("diff")})),Z8.and(x({type:$("terminal")})),$n(x({type:g()}),"type",["content","diff","terminal"])]),"type",["content","diff","terminal"]),Jwt=x({path:ss,line:b(fr().gte(0).max(4294967295,{error:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),()=>{}),_meta:b(P(g(),T()).nullish(),()=>{})}),G1=x({toolCallId:H1,name:b(g().nullish(),()=>{}),title:b(g().nullish(),()=>{}),kind:b(Lwt.nullish(),()=>{}),status:b(Fwt.nullish(),()=>{}),content:b(Ve(FCe).nullish(),()=>{}),locations:b(Ve(Jwt).nullish(),()=>{}),rawInput:b(T().optional(),()=>{}),rawOutput:b(T().optional(),()=>{}),_meta:b(P(g(),T()).nullish(),()=>{})}),J8=x({toolCall:G1}),Q8=x({command:g(),cwd:ss,toolCallId:b(H1.nullish(),()=>{}),terminalId:b(q1.nullish(),()=>{}),_meta:b(P(g(),T()).nullish(),()=>{})}),Qwt=Mn(be([J8.and(x({type:$("tool_call")})),Q8.and(x({type:$("command")})),$n(x({type:g()}),"type",["command","tool_call"])]),"type",["command","tool_call"]),jCe=g(),Ywt=be([$("allow_once"),$("allow_always"),$("reject_once"),$("reject_always"),g()]),Xwt=x({optionId:jCe,name:g(),kind:Ywt,_meta:b(P(g(),T()).nullish(),()=>{})}),Y8=x({sessionId:dn,title:g(),description:b(g().nullish(),()=>{}),subject:Qwt.nullish(),options:gt(Xwt).min(1),_meta:b(P(g(),T()).nullish(),()=>{})}),ZR=x({sessionId:dn,toolCallId:b(H1.nullish(),()=>{})}),JR=x({requestId:dh}),evt=$("object"),tvt=be([$("email"),$("uri"),$("date"),$("date-time"),g()]),UCe=x({const:g(),title:g(),description:b(g().nullish(),()=>{}),_meta:b(P(g(),T()).nullish(),()=>{})}),X8=x({title:b(g().nullish(),()=>{}),description:b(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:tvt.nullish(),default:b(g().nullish(),()=>{}),enum:gt(g()).min(1).nullish(),oneOf:gt(UCe).min(1).nullish(),_meta:b(P(g(),T()).nullish(),()=>{})}),e5=x({title:b(g().nullish(),()=>{}),description:b(g().nullish(),()=>{}),minimum:rt().nullish(),maximum:rt().nullish(),default:b(rt().nullish(),()=>{}),_meta:b(P(g(),T()).nullish(),()=>{})}),t5=x({title:b(g().nullish(),()=>{}),description:b(g().nullish(),()=>{}),minimum:rt().nullish(),maximum:rt().nullish(),default:b(rt().nullish(),()=>{}),_meta:b(P(g(),T()).nullish(),()=>{})}),r5=x({title:b(g().nullish(),()=>{}),description:b(g().nullish(),()=>{}),default:b(mr().nullish(),()=>{}),_meta:b(P(g(),T()).nullish(),()=>{})}),n5=x({enum:gt(g()).min(1),_meta:b(P(g(),T()).nullish(),()=>{})}),HCe=x({anyOf:gt(UCe).min(1),_meta:b(P(g(),T()).nullish(),()=>{})}),rvt=Mn(be([n5.and(x({type:$("string")})),$n(x({type:g()}),"type",["string"]),HCe]),"type",["string"]),o5=x({title:b(g().nullish(),()=>{}),description:b(g().nullish(),()=>{}),minItems:rt().nullish(),maxItems:rt().nullish(),items:rvt,default:b(Ve(g()).nullish(),()=>{}),_meta:b(P(g(),T()).nullish(),()=>{})}),nvt=Mn(be([X8.and(x({type:$("string")})),e5.and(x({type:$("number")})),t5.and(x({type:$("integer")})),r5.and(x({type:$("boolean")})),o5.and(x({type:$("array")})),$n(x({type:g()}),"type",["array","boolean","integer","number","string"])]),"type",["array","boolean","integer","number","string"]),ovt=x({type:b(evt.optional().default("object"),()=>"object"),title:b(g().nullish(),()=>{}),properties:P(g(),nvt).optional().default({}),required:gt(g()).nullish(),description:b(g().nullish(),()=>{}),_meta:b(P(g(),T()).nullish(),()=>{})}),i5=Ho(be([ZR,JR]),x({requestedSchema:ovt})),qCe=g(),s5=Ho(be([ZR,JR]),x({elicitationId:qCe,url:_r()})),a5=Mn(Ho(be([i5.and(x({mode:$("form")})),s5.and(x({mode:$("url")})),$n(Ho(be([ZR,JR]),x({mode:g()})),"mode",["form","url"])]),x({message:g(),_meta:b(P(g(),T()).nullish(),()=>{})})),"mode",["form","url"]),GCe=g(),c5=x({serverId:GCe,_meta:b(P(g(),T()).nullish(),()=>{})}),B1=g(),QR=x({connectionId:B1,method:g(),params:P(g(),T()).nullish(),_meta:b(P(g(),T()).nullish(),()=>{})}),l5=x({connectionId:B1,_meta:b(P(g(),T()).nullish(),()=>{})}),BCe=T(),Bwr=x({id:dh,method:g(),params:be([Y8,a5,c5,QR,l5,BCe]).nullish()}),WCe=fr().gte(0).lte(65535),VCe=x({name:g(),title:b(g().nullish(),()=>{}),version:g(),_meta:b(P(g(),T()).nullish(),()=>{})}),ivt=x({_meta:b(P(g(),T()).nullish(),()=>{})}),svt=x({_meta:b(P(g(),T()).nullish(),()=>{})}),avt=x({_meta:b(P(g(),T()).nullish(),()=>{})}),cvt=x({image:b(ivt.nullish(),()=>{}),audio:b(svt.nullish(),()=>{}),embeddedContext:b(avt.nullish(),()=>{}),_meta:b(P(g(),T()).nullish(),()=>{})}),lvt=x({_meta:b(P(g(),T()).nullish(),()=>{})}),uvt=x({_meta:b(P(g(),T()).nullish(),()=>{})}),dvt=x({_meta:b(P(g(),T()).nullish(),()=>{})}),pvt=x({stdio:b(lvt.nullish(),()=>{}),http:b(uvt.nullish(),()=>{}),acp:b(dvt.nullish(),()=>{}),_meta:b(P(g(),T()).nullish(),()=>{})}),fvt=x({_meta:b(P(g(),T()).nullish(),()=>{})}),mvt=x({_meta:b(P(g(),T()).nullish(),()=>{})}),hvt=x({_meta:b(P(g(),T()).nullish(),()=>{})}),gvt=x({prompt:b(cvt.nullish(),()=>{}),mcp:b(pvt.nullish(),()=>{}),delete:b(fvt.nullish(),()=>{}),additionalDirectories:b(mvt.nullish(),()=>{}),fork:b(hvt.nullish(),()=>{}),_meta:b(P(g(),T()).nullish(),()=>{})}),yvt=x({_meta:b(P(g(),T()).nullish(),()=>{})}),bvt=x({_meta:b(P(g(),T()).nullish(),()=>{})}),xvt=x({_meta:b(P(g(),T()).nullish(),()=>{})}),Svt=be([$("full"),$("incremental")]),kvt=x({syncKind:Svt,_meta:b(P(g(),T()).nullish(),()=>{})}),_vt=x({_meta:b(P(g(),T()).nullish(),()=>{})}),wvt=x({_meta:b(P(g(),T()).nullish(),()=>{})}),vvt=x({_meta:b(P(g(),T()).nullish(),()=>{})}),Evt=x({didOpen:b(xvt.nullish(),()=>{}),didChange:b(kvt.nullish(),()=>{}),didClose:b(_vt.nullish(),()=>{}),didSave:b(wvt.nullish(),()=>{}),didFocus:b(vvt.nullish(),()=>{}),_meta:b(P(g(),T()).nullish(),()=>{})}),Rvt=x({document:b(Evt.nullish(),()=>{}),_meta:b(P(g(),T()).nullish(),()=>{})}),Tvt=x({maxCount:b(fr().gte(0).max(4294967295,{error:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),()=>{}),_meta:b(P(g(),T()).nullish(),()=>{})}),Cvt=x({_meta:b(P(g(),T()).nullish(),()=>{})}),Pvt=x({maxCount:b(fr().gte(0).max(4294967295,{error:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),()=>{}),_meta:b(P(g(),T()).nullish(),()=>{})}),Ivt=x({maxCount:b(fr().gte(0).max(4294967295,{error:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),()=>{}),_meta:b(P(g(),T()).nullish(),()=>{})}),Avt=x({_meta:b(P(g(),T()).nullish(),()=>{})}),Ovt=x({_meta:b(P(g(),T()).nullish(),()=>{})}),$vt=x({recentFiles:b(Tvt.nullish(),()=>{}),relatedSnippets:b(Cvt.nullish(),()=>{}),editHistory:b(Pvt.nullish(),()=>{}),userActions:b(Ivt.nullish(),()=>{}),openFiles:b(Avt.nullish(),()=>{}),diagnostics:b(Ovt.nullish(),()=>{}),_meta:b(P(g(),T()).nullish(),()=>{})}),Mvt=x({events:b(Rvt.nullish(),()=>{}),context:b($vt.nullish(),()=>{}),_meta:b(P(g(),T()).nullish(),()=>{})}),KCe=be([$("utf-16"),$("utf-32"),$("utf-8")]),Dvt=x({session:b(gvt.nullish(),()=>{}),auth:b(yvt.nullish(),()=>{}),providers:b(bvt.nullish(),()=>{}),nes:b(Mvt.nullish(),()=>{}),positionEncoding:b(KCe.nullish(),()=>{}),_meta:b(P(g(),T()).nullish(),()=>{})}),db=g(),Nvt=x({name:g(),label:b(g().nullish(),()=>{}),secret:b(mr().optional().default(!0),()=>!0),optional:b(mr().optional().default(!1),()=>!1),_meta:b(P(g(),T()).nullish(),()=>{})}),u5=x({methodId:db,name:g(),description:b(g().nullish(),()=>{}),vars:Kn(Ve(Nvt),()=>[]),link:b(_r().nullish(),()=>{}),_meta:b(P(g(),T()).nullish(),()=>{})}),ZCe=x({name:g(),value:g(),_meta:b(P(g(),T()).nullish(),()=>{})}),d5=x({methodId:db,name:g(),description:b(g().nullish(),()=>{}),args:b(Ve(g()).optional(),()=>[]),env:b(Ve(ZCe).optional(),()=>[]),_meta:b(P(g(),T()).nullish(),()=>{})}),p5=x({methodId:db,name:g(),description:b(g().nullish(),()=>{}),_meta:b(P(g(),T()).nullish(),()=>{})}),zvt=Mn(be([u5.and(x({type:$("env_var")})),d5.and(x({type:$("terminal")})),p5.and(x({type:$("agent")})),$n(x({type:g(),methodId:db,name:g(),description:b(g().nullish(),()=>{}),_meta:b(P(g(),T()).nullish(),()=>{})}),"type",["agent","env_var","terminal"])]),"type",["agent","env_var","terminal"]),f5=x({protocolVersion:WCe,info:VCe,capabilities:b(Dvt.optional().default({}),()=>({})),authMethods:b(Ve(zvt).optional(),()=>[]),_meta:b(P(g(),T()).nullish(),()=>{})}),Lvt=x({_meta:b(P(g(),T()).nullish(),()=>{})}),m5=g(),h5=be([$("anthropic"),$("openai"),$("azure"),$("vertex"),$("bedrock"),g()]),Fvt=x({apiType:h5,baseUrl:_r(),_meta:b(P(g(),T()).nullish(),()=>{})}),jvt=x({providerId:m5,supported:Kn(Ve(h5),()=>[]),required:mr(),current:Fvt.nullish(),_meta:b(P(g(),T()).nullish(),()=>{})}),Uvt=x({providers:gt(jvt),_meta:b(P(g(),T()).nullish(),()=>{})}),Hvt=x({_meta:b(P(g(),T()).nullish(),()=>{})}),qvt=x({_meta:b(P(g(),T()).nullish(),()=>{})}),Gvt=x({_meta:b(P(g(),T()).nullish(),()=>{})}),Bp=g(),Bvt=be([$("mode"),$("model"),$("model_config"),$("thought_level"),g()]),YR=g(),JCe=x({value:YR,name:g(),description:b(g().nullish(),()=>{}),_meta:b(P(g(),T()).nullish(),()=>{})}),Wvt=g(),Vvt=x({groupId:Wvt,name:g(),options:Kn(Ve(JCe),()=>[]),_meta:b(P(g(),T()).nullish(),()=>{})}),Kvt=be([gt(JCe),gt(Vvt)]),g5=x({currentValue:YR,options:Kvt}),y5=x({currentValue:mr()}),XR=Mn(Ho(be([g5.and(x({type:$("select")})),y5.and(x({type:$("boolean")})),$n(x({type:g()}),"type",["boolean","select"])]),x({configId:Bp,name:g(),description:b(g().nullish(),()=>{}),category:b(Bvt.nullish(),()=>{}),_meta:b(P(g(),T()).nullish(),()=>{})})),"type",["boolean","select"]),Zvt=x({sessionId:dn,configOptions:b(Ve(XR).optional(),()=>[]),_meta:b(P(g(),T()).nullish(),()=>{})}),Jvt=x({sessionId:dn,cwd:ss,additionalDirectories:b(Ve(ss).optional(),()=>[]),title:b(g().nullish(),()=>{}),updatedAt:b(Qu.datetime({offset:!0}).nullish(),()=>{}),_meta:b(P(g(),T()).nullish(),()=>{})}),QCe=g(),Qvt=x({sessions:Kn(Ve(Jvt),()=>[]),nextCursor:b(QCe.nullish(),()=>{}),_meta:b(P(g(),T()).nullish(),()=>{})}),Yvt=x({_meta:b(P(g(),T()).nullish(),()=>{})}),Xvt=x({sessionId:dn,configOptions:b(Ve(XR).optional(),()=>[]),_meta:b(P(g(),T()).nullish(),()=>{})}),eEt=x({configOptions:b(Ve(XR).optional(),()=>[]),_meta:b(P(g(),T()).nullish(),()=>{})}),tEt=x({_meta:b(P(g(),T()).nullish(),()=>{})}),rEt=x({configOptions:Kn(Ve(XR),()=>[]),_meta:b(P(g(),T()).nullish(),()=>{})}),nEt=x({_meta:b(P(g(),T()).nullish(),()=>{})}),oEt=x({sessionId:dn,_meta:b(P(g(),T()).nullish(),()=>{})}),Wp=g(),ph=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:b(P(g(),T()).nullish(),()=>{})}),k_=x({start:ph,end:ph,_meta:b(P(g(),T()).nullish(),()=>{})}),iEt=x({range:k_,newText:g(),_meta:b(P(g(),T()).nullish(),()=>{})}),b5=x({suggestionId:Wp,uri:_r(),edits:gt(iEt).min(1),cursorPosition:b(ph.nullish(),()=>{}),_meta:b(P(g(),T()).nullish(),()=>{})}),x5=x({suggestionId:Wp,uri:_r(),position:ph,_meta:b(P(g(),T()).nullish(),()=>{})}),S5=x({suggestionId:Wp,uri:_r(),position:ph,newName:g(),_meta:b(P(g(),T()).nullish(),()=>{})}),k5=x({suggestionId:Wp,uri:_r(),search:g(),replace:g(),isRegex:mr().nullish(),_meta:b(P(g(),T()).nullish(),()=>{})}),sEt=Mn(be([b5.and(x({kind:$("edit")})),x5.and(x({kind:$("jump")})),S5.and(x({kind:$("rename")})),k5.and(x({kind:$("searchAndReplace")})),$n(x({kind:g(),suggestionId:Wp}),"kind",["edit","jump","rename","searchAndReplace"])]),"kind",["edit","jump","rename","searchAndReplace"]),aEt=x({suggestions:gt(sEt),_meta:b(P(g(),T()).nullish(),()=>{})}),cEt=x({_meta:b(P(g(),T()).nullish(),()=>{})}),YCe=T(),XCe=T(),lEt=be([$(-32700),$(-32600),$(-32601),$(-32602),$(-32603),$(-32800),$(-32e3),$(-32002),fr().min(-2147483648,{error:"Invalid value: Expected int32 to be >= -2147483648"}).max(2147483647,{error:"Invalid value: Expected int32 to be <= 2147483647"})]),ePe=x({code:lEt,message:g(),data:b(T().optional(),()=>{})}),Wwr=be([x({id:dh,result:be([f5,Lvt,Uvt,Hvt,qvt,Gvt,Zvt,Qvt,Yvt,Xvt,eEt,tEt,rEt,nEt,oEt,aEt,cEt,YCe,XCe])}),x({id:dh,error:ePe})]),W1=g(),lb=x({messageId:W1,content:S_,_meta:b(P(g(),T()).nullish(),()=>{})}),_5=x({messageId:W1,content:b(Ve(S_).nullish(),()=>{}),_meta:b(P(g(),T()).nullish(),()=>{})}),w5=x({messageId:W1,content:b(Ve(S_).nullish(),()=>{}),_meta:b(P(g(),T()).nullish(),()=>{})}),v5=x({messageId:W1,content:b(Ve(S_).nullish(),()=>{}),_meta:b(P(g(),T()).nullish(),()=>{})}),E5=x({_meta:b(P(g(),T()).nullish(),()=>{})}),uEt=be([$("end_turn"),$("max_tokens"),$("max_turn_requests"),$("refusal"),$("cancelled"),g()]),dEt=x({totalTokens:rt(),inputTokens:rt(),outputTokens:rt(),thoughtTokens:b(rt().nullish(),()=>{}),cachedReadTokens:b(rt().nullish(),()=>{}),cachedWriteTokens:b(rt().nullish(),()=>{}),_meta:b(P(g(),T()).nullish(),()=>{})}),R5=x({stopReason:b(uEt.nullish(),()=>{}),usage:b(dEt.nullish(),()=>{}),_meta:b(P(g(),T()).nullish(),()=>{})}),T5=x({_meta:b(P(g(),T()).nullish(),()=>{})}),C5=Mn(be([E5.and(x({state:$("running")})),R5.and(x({state:$("idle")})),T5.and(x({state:$("requires_action")})),$n(x({state:g()}),"state",["idle","requires_action","running"])]),"state",["idle","requires_action","running"]),P5=x({toolCallId:H1,content:FCe,_meta:b(P(g(),T()).nullish(),()=>{})}),pEt=x({data:g(),_meta:b(P(g(),T()).nullish(),()=>{})}),fEt=x({exitCode:b(fr().gte(0).max(4294967295,{error:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),()=>{}),signal:b(g().nullish(),()=>{}),_meta:b(P(g(),T()).nullish(),()=>{})}),I5=x({terminalId:q1,command:b(g().nullish(),()=>{}),cwd:b(ss.nullish(),()=>{}),output:b(pEt.nullish(),()=>{}),exitStatus:b(fEt.nullish(),()=>{}),_meta:b(P(g(),T()).nullish(),()=>{})}),A5=x({terminalId:q1,data:g(),_meta:b(P(g(),T()).nullish(),()=>{})}),pb=g(),mEt=be([$("high"),$("medium"),$("low"),g()]),hEt=be([$("pending"),$("in_progress"),$("completed"),$("cancelled"),g()]),gEt=x({content:g(),priority:mEt,status:hEt,_meta:b(P(g(),T()).nullish(),()=>{})}),O5=x({planId:pb,entries:Kn(Ve(gEt),()=>[]),_meta:b(P(g(),T()).nullish(),()=>{})}),$5=x({planId:pb,uri:_r(),_meta:b(P(g(),T()).nullish(),()=>{})}),M5=x({planId:pb,content:g(),_meta:b(P(g(),T()).nullish(),()=>{})}),yEt=Mn(be([O5.and(x({type:$("items")})),$5.and(x({type:$("file")})),M5.and(x({type:$("markdown")})),$n(x({type:g(),planId:pb}),"type",["file","items","markdown"])]),"type",["file","items","markdown"]),D5=x({plan:yEt,_meta:b(P(g(),T()).nullish(),()=>{})}),N5=x({planId:pb,_meta:b(P(g(),T()).nullish(),()=>{})}),z5=x({hint:g(),_meta:b(P(g(),T()).nullish(),()=>{})}),bEt=Mn(be([z5.and(x({type:$("text")})),$n(x({type:g()}),"type",["text"])]),"type",["text"]),xEt=x({name:g(),description:g(),input:b(bEt.nullish(),()=>{}),_meta:b(P(g(),T()).nullish(),()=>{})}),L5=x({availableCommands:Kn(Ve(xEt),()=>[]),_meta:b(P(g(),T()).nullish(),()=>{})}),F5=x({configOptions:Kn(Ve(XR),()=>[]),_meta:b(P(g(),T()).nullish(),()=>{})}),j5=x({title:b(g().nullish(),()=>{}),updatedAt:b(Qu.datetime({offset:!0}).nullish(),()=>{}),_meta:b(P(g(),T()).nullish(),()=>{})}),SEt=x({amount:rt(),currency:g().regex(/^[A-Z]{3}$/),_meta:b(P(g(),T()).nullish(),()=>{})}),U5=x({used:rt(),size:rt(),cost:b(SEt.nullish(),()=>{}),_meta:b(P(g(),T()).nullish(),()=>{})}),kEt=Mn(be([lb.and(x({sessionUpdate:$("user_message_chunk")})),_5.and(x({sessionUpdate:$("user_message")})),lb.and(x({sessionUpdate:$("agent_message_chunk")})),w5.and(x({sessionUpdate:$("agent_message")})),lb.and(x({sessionUpdate:$("agent_thought_chunk")})),v5.and(x({sessionUpdate:$("agent_thought")})),C5.and(x({sessionUpdate:$("state_update")})),P5.and(x({sessionUpdate:$("tool_call_content_chunk")})),G1.and(x({sessionUpdate:$("tool_call_update")})),I5.and(x({sessionUpdate:$("terminal_update")})),A5.and(x({sessionUpdate:$("terminal_output_chunk")})),D5.and(x({sessionUpdate:$("plan_update")})),N5.and(x({sessionUpdate:$("plan_removed")})),L5.and(x({sessionUpdate:$("available_commands_update")})),F5.and(x({sessionUpdate:$("config_option_update")})),j5.and(x({sessionUpdate:$("session_info_update")})),U5.and(x({sessionUpdate:$("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"]),V1=x({sessionId:dn,update:kEt,_meta:b(P(g(),T()).nullish(),()=>{})}),H5=x({elicitationId:qCe,_meta:b(P(g(),T()).nullish(),()=>{})}),eT=x({connectionId:B1,method:g(),params:b(P(g(),T()).nullish(),()=>{}),_meta:b(P(g(),T()).nullish(),()=>{})}),tPe=T(),Vwr=x({method:g(),params:be([V1,H5,eT,tPe]).nullish()}),_Et=x({_meta:b(P(g(),T()).nullish(),()=>{})}),wEt=x({terminal:b(_Et.nullish(),()=>{}),_meta:b(P(g(),T()).nullish(),()=>{})}),vEt=x({_meta:b(P(g(),T()).nullish(),()=>{})}),EEt=x({_meta:b(P(g(),T()).nullish(),()=>{})}),REt=x({form:b(vEt.nullish(),()=>{}),url:b(EEt.nullish(),()=>{}),_meta:b(P(g(),T()).nullish(),()=>{})}),TEt=x({_meta:b(P(g(),T()).nullish(),()=>{})}),CEt=x({_meta:b(P(g(),T()).nullish(),()=>{})}),PEt=x({_meta:b(P(g(),T()).nullish(),()=>{})}),IEt=x({jump:b(TEt.nullish(),()=>{}),rename:b(CEt.nullish(),()=>{}),searchAndReplace:b(PEt.nullish(),()=>{}),_meta:b(P(g(),T()).nullish(),()=>{})}),AEt=x({auth:b(wEt.nullish(),()=>{}),elicitation:b(REt.nullish(),()=>{}),nes:b(IEt.nullish(),()=>{}),positionEncodings:b(Ve(KCe).optional(),()=>[]),_meta:b(P(g(),T()).nullish(),()=>{})}),K1=x({protocolVersion:WCe,info:VCe,capabilities:b(AEt.optional().default({}),()=>({})),_meta:b(P(g(),T()).nullish(),()=>{})}),q5=x({methodId:db,_meta:b(P(g(),T()).nullish(),()=>{})}),G5=x({_meta:b(P(g(),T()).nullish(),()=>{})}),B5=x({providerId:m5,apiType:h5,baseUrl:_r(),headers:P(g(),g()).optional(),_meta:b(P(g(),T()).nullish(),()=>{})}),W5=x({providerId:m5,_meta:b(P(g(),T()).nullish(),()=>{})}),V5=x({_meta:b(P(g(),T()).nullish(),()=>{})}),OEt=x({name:g(),value:g(),_meta:b(P(g(),T()).nullish(),()=>{})}),K5=x({name:g(),url:_r(),headers:gt(OEt).optional(),_meta:b(P(g(),T()).nullish(),()=>{})}),Z5=x({name:g(),serverId:GCe,_meta:b(P(g(),T()).nullish(),()=>{})}),J5=x({name:g(),command:ss,args:gt(g()).optional(),env:gt(ZCe).optional(),_meta:b(P(g(),T()).nullish(),()=>{})}),Q5=Mn(be([K5.and(x({type:$("http")})),Z5.and(x({type:$("acp")})),J5.and(x({type:$("stdio")})),$n(x({type:g()}),"type",["acp","http","stdio"])]),"type",["acp","http","stdio"]),Y5=x({cwd:ss,additionalDirectories:b(Ve(ss).optional(),()=>[]),mcpServers:b(Ve(Q5).optional(),()=>[]),_meta:b(P(g(),T()).nullish(),()=>{})}),X5=x({cwd:ss.nullish(),cursor:QCe.nullish(),_meta:b(P(g(),T()).nullish(),()=>{})}),e7=x({sessionId:dn,_meta:b(P(g(),T()).nullish(),()=>{})}),t7=x({sessionId:dn,cwd:ss,additionalDirectories:b(Ve(ss).optional(),()=>[]),mcpServers:b(Ve(Q5).optional(),()=>[]),_meta:b(P(g(),T()).nullish(),()=>{})}),r7=x({_meta:b(P(g(),T()).nullish(),()=>{})}),$Et=Mn(be([r7.and(x({type:$("start")})),$n(x({type:g(),_meta:b(P(g(),T()).nullish(),()=>{})}),"type",["start"])]),"type",["start"]),n7=x({sessionId:dn,cwd:ss,additionalDirectories:b(Ve(ss).optional(),()=>[]),mcpServers:b(Ve(Q5).optional(),()=>[]),replayFrom:b($Et.nullish(),()=>{}),_meta:b(P(g(),T()).nullish(),()=>{})}),o7=x({sessionId:dn,_meta:b(P(g(),T()).nullish(),()=>{})}),i7=Mn(Ho(be([x({value:YR,type:$("id")}),x({value:mr(),type:$("boolean")}),$n(x({type:g(),value:T()}),"type",["boolean","id"])]),x({sessionId:dn,configId:Bp,_meta:b(P(g(),T()).nullish(),()=>{})})),"type",["boolean","id"]),s7=x({sessionId:dn,prompt:gt(S_),_meta:b(P(g(),T()).nullish(),()=>{})}),MEt=x({uri:_r(),name:g(),_meta:b(P(g(),T()).nullish(),()=>{})}),DEt=x({name:g(),owner:g(),remoteUrl:g(),_meta:b(P(g(),T()).nullish(),()=>{})}),a7=x({workspaceUri:b(_r().nullish(),()=>{}),workspaceFolders:gt(MEt).nullish(),repository:b(DEt.nullish(),()=>{}),_meta:b(P(g(),T()).nullish(),()=>{})}),NEt=be([$("automatic"),$("diagnostic"),$("manual"),g()]),zEt=x({uri:_r(),languageId:g(),text:g(),_meta:b(P(g(),T()).nullish(),()=>{})}),LEt=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:b(P(g(),T()).nullish(),()=>{})}),FEt=x({uri:_r(),excerpts:gt(LEt),_meta:b(P(g(),T()).nullish(),()=>{})}),jEt=x({uri:_r(),diff:g(),_meta:b(P(g(),T()).nullish(),()=>{})}),UEt=x({action:g(),uri:_r(),position:ph,timestampMs:rt(),_meta:b(P(g(),T()).nullish(),()=>{})}),HEt=x({uri:_r(),languageId:g(),visibleRange:b(k_.nullish(),()=>{}),lastFocusedMs:b(rt().nullish(),()=>{}),_meta:b(P(g(),T()).nullish(),()=>{})}),qEt=be([$("error"),$("warning"),$("information"),$("hint"),g()]),GEt=x({uri:_r(),range:k_,severity:qEt,message:g(),_meta:b(P(g(),T()).nullish(),()=>{})}),BEt=x({recentFiles:gt(zEt).nullish(),relatedSnippets:gt(FEt).nullish(),editHistory:gt(jEt).nullish(),userActions:gt(UEt).nullish(),openFiles:gt(HEt).nullish(),diagnostics:gt(GEt).nullish(),_meta:b(P(g(),T()).nullish(),()=>{})}),c7=x({sessionId:dn,uri:_r(),version:rt(),position:ph,selection:k_.nullish(),triggerKind:NEt,context:BEt.nullish(),_meta:b(P(g(),T()).nullish(),()=>{})}),l7=x({sessionId:dn,_meta:b(P(g(),T()).nullish(),()=>{})}),Kwr=x({id:dh,method:g(),params:be([K1,q5,G5,B5,W5,V5,Y5,X5,e7,t7,n7,o7,i7,s7,a7,c7,l7,QR,BCe]).nullish()}),u7=x({optionId:jCe,_meta:b(P(g(),T()).nullish(),()=>{})}),WEt=Mn(be([x({outcome:$("cancelled")}),u7.and(x({outcome:$("selected")})),$n(x({outcome:g()}),"outcome",["cancelled","selected"])]),"outcome",["cancelled","selected"]),VEt=x({outcome:WEt,_meta:b(P(g(),T()).nullish(),()=>{})}),KEt=be([g(),rt(),rt(),mr(),gt(g())]),d7=x({content:P(g(),KEt).nullish()}),ZEt=Mn(Ho(be([d7.and(x({action:$("accept")})),x({action:$("decline")}),x({action:$("cancel")}),$n(x({action:g()}),"action",["accept","cancel","decline"])]),x({_meta:b(P(g(),T()).nullish(),()=>{})})),"action",["accept","cancel","decline"]),JEt=x({connectionId:B1,_meta:b(P(g(),T()).nullish(),()=>{})}),QEt=x({_meta:b(P(g(),T()).nullish(),()=>{})}),Zwr=be([x({id:dh,result:be([VEt,ZEt,JEt,QEt,XCe,YCe])}),x({id:dh,error:ePe})]),p7=x({sessionId:dn,_meta:b(P(g(),T()).nullish(),()=>{})}),f7=x({sessionId:dn,uri:_r(),languageId:g(),version:rt(),text:g(),_meta:b(P(g(),T()).nullish(),()=>{})}),YEt=x({range:k_.nullish(),text:g(),_meta:b(P(g(),T()).nullish(),()=>{})}),m7=x({sessionId:dn,uri:_r(),version:rt(),contentChanges:Kn(Ve(YEt),()=>[]),_meta:b(P(g(),T()).nullish(),()=>{})}),h7=x({sessionId:dn,uri:_r(),_meta:b(P(g(),T()).nullish(),()=>{})}),g7=x({sessionId:dn,uri:_r(),_meta:b(P(g(),T()).nullish(),()=>{})}),y7=x({sessionId:dn,uri:_r(),version:rt(),position:ph,visibleRange:k_,_meta:b(P(g(),T()).nullish(),()=>{})}),b7=x({sessionId:dn,suggestionId:Wp,_meta:b(P(g(),T()).nullish(),()=>{})}),XEt=be([$("rejected"),$("ignored"),$("replaced"),$("cancelled"),g()]),x7=x({sessionId:dn,suggestionId:Wp,reason:b(XEt.nullish(),()=>{}),_meta:b(P(g(),T()).nullish(),()=>{})}),Jwr=x({method:g(),params:be([p7,f7,m7,h7,g7,y7,b7,x7,eT,tPe]).nullish()}),e0t=x({requestId:dh,_meta:b(P(g(),T()).nullish(),()=>{})}),Qwr=x({method:g(),params:e0t.nullish()});function rn(e,t){return typeof e=="object"&&e!==null?e[t]:void 0}var Ywr=J8.and(x({type:$("tool_call")})),Xwr=Q8.and(x({type:$("command")})),evr=V8.and(x({type:$("content")})),tvr=K8.and(x({type:$("diff")})),rvr=Z8.and(x({type:$("terminal")})),t0t=H8.and(x({type:$("text")})),r0t=q8.and(x({type:$("image")})),n0t=G8.and(x({type:$("audio")})),o0t=B8.and(x({type:$("resource_link")})),i0t=W8.and(x({type:$("resource")})),nvr=cb.and(x({operation:$("add")})),ovr=cb.and(x({operation:$("delete")})),ivr=cb.and(x({operation:$("modify")})),svr=VR.and(x({operation:$("move")})),avr=VR.and(x({operation:$("copy")})),cvr=i5.and(x({mode:$("form")})).and(x({message:g()})),lvr=s5.and(x({mode:$("url")})).and(x({message:g()})),uvr=be([ZR,JR]).and(x({message:g()})),dvr=X8.and(x({type:$("string")})),pvr=e5.and(x({type:$("number")})),fvr=t5.and(x({type:$("integer")})),mvr=r5.and(x({type:$("boolean")})),hvr=o5.and(x({type:$("array")})),gvr=n5.and(x({type:$("string")}));var yvr=u5.and(x({type:$("env_var")})),bvr=d5.and(x({type:$("terminal")})),xvr=p5.and(x({type:$("agent")})),Svr=x({methodId:db,name:g()}),kvr=g5.and(x({type:$("select")})).and(x({configId:Bp,name:g()})),_vr=y5.and(x({type:$("boolean")})).and(x({configId:Bp,name:g()})),wvr=x({configId:Bp,name:g()}),vvr=b5.and(x({kind:$("edit")})),Evr=x5.and(x({kind:$("jump")})),Rvr=S5.and(x({kind:$("rename")})),Tvr=k5.and(x({kind:$("searchAndReplace")})),Cvr=x({suggestionId:Wp}),s0t=lb.and(x({sessionUpdate:$("user_message_chunk")})),a0t=_5.and(x({sessionUpdate:$("user_message")})),c0t=lb.and(x({sessionUpdate:$("agent_message_chunk")})),l0t=w5.and(x({sessionUpdate:$("agent_message")})),u0t=lb.and(x({sessionUpdate:$("agent_thought_chunk")})),d0t=v5.and(x({sessionUpdate:$("agent_thought")})),p0t=C5.and(x({sessionUpdate:$("state_update")})),f0t=P5.and(x({sessionUpdate:$("tool_call_content_chunk")})),m0t=G1.and(x({sessionUpdate:$("tool_call_update")})),h0t=I5.and(x({sessionUpdate:$("terminal_update")})),g0t=A5.and(x({sessionUpdate:$("terminal_output_chunk")})),y0t=D5.and(x({sessionUpdate:$("plan_update")})),b0t=N5.and(x({sessionUpdate:$("plan_removed")})),x0t=L5.and(x({sessionUpdate:$("available_commands_update")})),S0t=F5.and(x({sessionUpdate:$("config_option_update")})),k0t=j5.and(x({sessionUpdate:$("session_info_update")})),_0t=U5.and(x({sessionUpdate:$("usage_update")})),w0t=E5.and(x({state:$("running")})),v0t=R5.and(x({state:$("idle")})),E0t=T5.and(x({state:$("requires_action")})),Pvr=O5.and(x({type:$("items")})),Ivr=$5.and(x({type:$("file")})),Avr=M5.and(x({type:$("markdown")})),Ovr=x({planId:pb}),$vr=z5.and(x({type:$("text")})),Mvr=K5.and(x({type:$("http")})),Dvr=Z5.and(x({type:$("acp")})),Nvr=J5.and(x({type:$("stdio")})),zvr=r7.and(x({type:$("start")})),Lvr=x({type:$("id")}).and(x({value:YR})).and(x({sessionId:dn,configId:Bp})),Fvr=x({type:$("boolean")}).and(x({value:mr()})).and(x({sessionId:dn,configId:Bp})),jvr=x({value:T()}).and(x({sessionId:dn,configId:Bp})),Uvr=x({outcome:$("cancelled")}),Hvr=u7.and(x({outcome:$("selected")})),qvr=d7.and(x({action:$("accept")})),Gvr=x({action:$("decline")}),Bvr=x({action:$("cancel")});var S7={isText(e){return rn(e,"type")==="text"&&t0t.safeParse(e).success},isImage(e){return rn(e,"type")==="image"&&r0t.safeParse(e).success},isAudio(e){return rn(e,"type")==="audio"&&n0t.safeParse(e).success},isResourceLink(e){return rn(e,"type")==="resource_link"&&o0t.safeParse(e).success},isResource(e){return rn(e,"type")==="resource"&&i0t.safeParse(e).success},isCustom(e){let t=rn(e,"type");return typeof t=="string"&&!["audio","image","resource","resource_link","text"].includes(t)}};var tT={isUserMessageChunk(e){return rn(e,"sessionUpdate")==="user_message_chunk"&&s0t.safeParse(e).success},isUserMessage(e){return rn(e,"sessionUpdate")==="user_message"&&a0t.safeParse(e).success},isAgentMessageChunk(e){return rn(e,"sessionUpdate")==="agent_message_chunk"&&c0t.safeParse(e).success},isAgentMessage(e){return rn(e,"sessionUpdate")==="agent_message"&&l0t.safeParse(e).success},isAgentThoughtChunk(e){return rn(e,"sessionUpdate")==="agent_thought_chunk"&&u0t.safeParse(e).success},isAgentThought(e){return rn(e,"sessionUpdate")==="agent_thought"&&d0t.safeParse(e).success},isStateUpdate(e){return rn(e,"sessionUpdate")==="state_update"&&p0t.safeParse(e).success},isToolCallContentChunk(e){return rn(e,"sessionUpdate")==="tool_call_content_chunk"&&f0t.safeParse(e).success},isToolCallUpdate(e){return rn(e,"sessionUpdate")==="tool_call_update"&&m0t.safeParse(e).success},isTerminalUpdate(e){return rn(e,"sessionUpdate")==="terminal_update"&&h0t.safeParse(e).success},isTerminalOutputChunk(e){return rn(e,"sessionUpdate")==="terminal_output_chunk"&&g0t.safeParse(e).success},isPlanUpdate(e){return rn(e,"sessionUpdate")==="plan_update"&&y0t.safeParse(e).success},isPlanRemoved(e){return rn(e,"sessionUpdate")==="plan_removed"&&b0t.safeParse(e).success},isAvailableCommandsUpdate(e){return rn(e,"sessionUpdate")==="available_commands_update"&&x0t.safeParse(e).success},isConfigOptionUpdate(e){return rn(e,"sessionUpdate")==="config_option_update"&&S0t.safeParse(e).success},isSessionInfoUpdate(e){return rn(e,"sessionUpdate")==="session_info_update"&&k0t.safeParse(e).success},isUsageUpdate(e){return rn(e,"sessionUpdate")==="usage_update"&&_0t.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)}},k7={isRunning(e){return rn(e,"state")==="running"&&w0t.safeParse(e).success},isIdle(e){return rn(e,"state")==="idle"&&v0t.safeParse(e).success},isRequiresAction(e){return rn(e,"state")==="requires_action"&&E0t.safeParse(e).success},isCustom(e){let t=rn(e,"state");return typeof t=="string"&&!["idle","requires_action","running"].includes(t)}};function Vp(e){return e??{}}function Kp(e,t,r,n=!1){if(!(Object.hasOwn(t,e)||n&&e===U1.cancel_request)&&!e.startsWith("_"))throw new TypeError(`Custom ACP v2 ${r} method '${e}' must start with '_'`)}function aPe(e,t,r){for(let n of e)Kp(n.method,n.kind==="request"?t:r,n.kind,n.kind==="notification")}function cPe(e){let t=K1.parse(e);if(t.protocolVersion!==Gp)throw Xr.invalidParams({expectedProtocolVersion:Gp,receivedProtocolVersion:t.protocolVersion},`The v2 API only supports protocol version ${Gp}`);return t}function lPe(e){let t=typeof e=="object"&&e!==null&&!Array.isArray(e)?e:{};return cPe({...t,protocolVersion:Gp})}function uPe(e){let t=f5.parse(e);if(t.protocolVersion!==Gp)throw Xr.invalidRequest({expectedProtocolVersion:Gp,receivedProtocolVersion:t.protocolVersion},`The v2 API only supports protocol version ${Gp}`);return t}function T0t(e){return e.map(t=>{if(t.kind!=="request"||t.method!==ct.initialize)return t;let r=t.mapResponse;return{...t,params:lPe(t.params),mapResponse:n=>{let o=uPe(n);return r?r(o):o}}})}function dPe(e){return typeof e=="object"&&e!==null&&"readable"in e&&"writable"in e}function pPe(){let e=new TransformStream,t=new TransformStream;return[{readable:t.readable,writable:e.writable},{readable:e.readable,writable:t.writable}]}var bEr={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:U1.cancel_request}},fPe=Symbol("startActiveSession"),Q1=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)}},oT=class e extends Q1{constructor(t,r){super(t,r)}static create(t,r){return new e(t,r)}request(t,r,n){Kp(t,nT,"request");let o=nT[t];return this.sendRequest(t,r,o?.mapResponse,n)}notify(t,r){return Kp(t,tN,"notification",!0),this.sendNotification(t,r)}batch(t){return aPe(t,nT,tN),this.sendBatch(t)}},iT=class e extends Q1{constructor(t,r){super(t,r)}static create(t,r){return new e(t,r)}[fPe](t,r){return this.sendRequest(ct.session_new,t,n=>this.attachSession(n),r)}buildSession(t){return typeof t=="string"?X1.create(this,{cwd:t,mcpServers:[]}):X1.create(this,t)}attachSession(t){let r=new v7,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=xPe(this.connectionContext).attach(t,o),c=new Np(()=>{i.removeEventListener("abort",s)});return E7.create(this,t,o,[a,c])}request(t,r,n){Kp(t,rT,"request");let o=rT[t],i=t===ct.initialize?lPe(r):r;return this.sendRequest(t,i,o?.mapResponse,n)}notify(t,r){return Kp(t,eN,"notification",!0),this.sendNotification(t,r)}batch(t){return aPe(t,rT,eN),this.sendBatch(T0t(t))}},Y1=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)}},_7=class extends Y1{connectHandlers;client;didStartConnectHandlers=!1;constructor(t,r=[]){super(t),this.connectHandlers=r,this.client=oT.create(t.getContext())}startConnectHandlers(){this.didStartConnectHandlers||(this.didStartConnectHandlers=!0,oN(this,this.connectHandlers))}},w7=class extends Y1{connectHandlers;agent;didStartConnectHandlers=!1;constructor(t,r=[]){super(t),this.connectHandlers=r,this.agent=iT.create(t.getContext())}startConnectHandlers(){this.didStartConnectHandlers||(this.didStartConnectHandlers=!0,oN(this,this.connectHandlers))}};function mPe(e,t=[]){return new _7(e,t)}function hPe(e,t=[]){return new w7(e,t)}var v7=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 nPe(e){return structuredClone(e)}var X1=class e{cx;request;constructor(t,r){this.cx=t,this.request=nPe(r)}static create(t,r){return new e(t,r)}toRequest(){return nPe(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[fPe](this.toRequest(),t)}async withSession(t){let r=await this.start();try{return await t(r)}finally{r.dispose()}}},E7=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(S7.isText).map(c=>c.text).join("");let{update:a}=s;tT.isAgentMessage(a)?(i(a.messageId),a.content!==void 0&&o.set(a.messageId,a.content??[])):tT.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 gPe(e,t){return e?typeof e=="function"?e(t):e.parse(t):t}function ao(e,t,r){return{method:e,params:t,mapResponse:r}}function qc(e,t){return{method:e,params:t}}function yPe(e,t,r,n){e.onReceiveRequest(t.method,o=>gPe(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 bPe(e,t,r,n){e.onReceiveNotification(t.method,o=>gPe(t.params,o),(o,i)=>n(r(o,i,i.signal)))}function nN(e){let t=Object.create(null);for(let r of Object.values(e))t[r.method]=r;return t}var C0t={initialize:ao(ct.initialize,cPe,uPe),loginAuth:ao(ct.auth_login,q5,Vp),unstable_listProviders:ao(ct.providers_list,G5),unstable_setProvider:ao(ct.providers_set,B5,Vp),unstable_disableProvider:ao(ct.providers_disable,W5,Vp),newSession:ao(ct.session_new,Y5),setSessionConfigOption:ao(ct.session_set_config_option,i7),prompt:ao(ct.session_prompt,s7,Vp),unstable_messageMcp:ao(ct.mcp_message,QR),listSessions:ao(ct.session_list,X5),deleteSession:ao(ct.session_delete,e7,Vp),unstable_forkSession:ao(ct.session_fork,t7),resumeSession:ao(ct.session_resume,n7),closeSession:ao(ct.session_close,o7,Vp),logoutAuth:ao(ct.auth_logout,V5,Vp),unstable_startNes:ao(ct.nes_start,a7),unstable_suggestNes:ao(ct.nes_suggest,c7),unstable_closeNes:ao(ct.nes_close,l7,Vp)},P0t={cancelSession:qc(ct.session_cancel,p7),unstable_messageMcp:qc(ct.mcp_message,eT),unstable_didOpenDocument:qc(ct.document_did_open,f7),unstable_didChangeDocument:qc(ct.document_did_change,m7),unstable_didCloseDocument:qc(ct.document_did_close,h7),unstable_didSaveDocument:qc(ct.document_did_save,g7),unstable_didFocusDocument:qc(ct.document_did_focus,y7),unstable_acceptNes:qc(ct.nes_accept,b7),unstable_rejectNes:qc(ct.nes_reject,x7)},I0t={requestPermission:ao(vi.session_request_permission,Y8),unstable_connectMcp:ao(vi.mcp_connect,c5),unstable_messageMcp:ao(vi.mcp_message,QR),unstable_disconnectMcp:ao(vi.mcp_disconnect,l5,Vp),unstable_createElicitation:ao(vi.elicitation_create,a5)},A0t={sessionUpdate:qc(vi.session_update,V1),unstable_messageMcp:qc(vi.mcp_message,eT),unstable_completeElicitation:qc(vi.elicitation_complete,H5)},rT=nN(C0t),eN=nN(P0t),nT=nN(I0t),tN=nN(A0t);function O0t(e,t,r,n){return{params:e,requestId:n,signal:r,client:t}}function $0t(e,t,r){return{params:e,signal:r,client:t}}function M0t(e,t,r,n){return{params:e,requestId:n,signal:r,agent:t}}function D0t(e,t,r){return{params:e,signal:r,agent:t}}var R7=class{activeSessions=new Map;handleMessage(t){if(t.kind!=="notification"||t.method!==vi.session_update)return Dc.no(t);let r=V1.parse(t.params),{update:n}=r,o=tT.isStateUpdate(n)&&k7.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 Dc.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 Np(()=>{n.delete(r),n.size===0&&this.activeSessions.delete(t.sessionId)})}},oPe=new WeakMap;function xPe(e){let t=oPe.get(e);return t||(t=new R7,oPe.set(e,t)),t}function oN(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 rN=Symbol("appBuilder"),Z1=Symbol("runAgentConnectHandlers"),J1=Symbol("runClientConnectHandlers");var iPe=class{builder=zp.builder();connectHandlers=[];constructor(t={}){t.name&&this.builder.name(t.name)}[rN](){return this.builder}[Z1](t){oN(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 Kp(t,rT,"request"),this.request({method:t,params:r},n);let o=rT[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 Kp(t,eN,"notification",!0),this.notification({method:t,params:r},n);let o=eN[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 yPe(this.builder,t,(n,o,i,s)=>O0t(n,oT.create(o,s),i,s),r),this}notification(t,r){return bPe(this.builder,t,(n,o,i)=>$0t(n,oT.create(o),i),r),this}connectConnection(t,r={}){if(dPe(t)){let c=this.openStreamConnection(t);return r.deferConnectHandlers||this[Z1](c.connection),c}let[n,o]=pPe(),i=t[rN]().connect(o),s=hPe(i),a=this.openStreamConnection(n);a.rawConnection.closed.then(()=>s.close()),i.closed.then(()=>a.connection.close());try{t[J1](s),this[Z1](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:mPe(r,this.connectHandlers)}}};var sPe=class{builder=zp.builder();connectHandlers=[];constructor(t={}){t.name&&this.builder.name(t.name),this.builder.withHandler({handleMessage:(r,n)=>xPe(n).handleMessage(r),describe:()=>"client-session-update-router"})}[rN](){return this.builder}[J1](t){oN(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 Kp(t,nT,"request"),this.request({method:t,params:r},n);let o=nT[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 Kp(t,tN,"notification",!0),this.notification({method:t,params:r},n);let o=tN[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 yPe(this.builder,t,(n,o,i,s)=>M0t(n,iT.create(o,s),i,s),r),this}notification(t,r){return bPe(this.builder,t,(n,o,i)=>D0t(n,iT.create(o),i),r),this}connectConnection(t){if(dPe(t)){let a=this.openStreamConnection(t);return this[J1](a.connection),a}let[r,n]=pPe(),o=t[rN]().connect(n),i=mPe(o),s=this.openStreamConnection(r);s.rawConnection.closed.then(()=>i.close()),o.closed.then(()=>s.connection.close());try{t[Z1](i),this[J1](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:hPe(r,this.connectHandlers)}}};var SPe=1;var kPe=["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"},CEr=Object.values(Ms);var z0t=16e3,L0t={type:"object",additionalProperties:!1,required:["demand"],properties:{demand:{type:"string",minLength:1,maxLength:z0t,description:"The one-off demand this dispatch exists to satisfy."}}},F0t={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}}},OEr={version:1,method:Ms.goDispatch,params:L0t,answer:F0t};var j0t=64,_Pe=200,U0t=/^[a-z0-9][a-z0-9._-]*$/;var H0t={type:"object",additionalProperties:!1,required:["slug"],properties:{slug:{type:"string",minLength:1,maxLength:j0t,pattern:U0t.source,description:"What the human is about to work on; becomes the worktree directory name."},branch:{type:"string",minLength:1,maxLength:_Pe,description:"Branch to create; defaults to the daemon's convention for the slug."},base:{type:"string",minLength:1,maxLength:_Pe,description:"Trunk BRANCH to fork from; the remote is the Project's registered trunk remote."}}},q0t={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}}},G0t={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}}}}}},WEr={version:1,methods:{add:Ms.worktreeAdd,list:Ms.worktreeList},add:{params:H0t,answer:q0t},list:{answer:G0t}};sT();var Y0t={drain:Ms.projectDrain,stop:Ms.projectStop,status:Ms.projectStatus};async function P7(e={}){let t=e.cwd??process.cwd(),r=e.name??"RedSkills Project client",n=e.version??"1",o=e.paths??iN(),s=await X0t(async()=>{await WR(o);let l=(await ab(o)).paths,u=await nRt(l.acpSocketPath),d=[],f="",m=!1;u.once("close",()=>{m=!0}),u.once("error",()=>{m=!0});let y=Xve({name:r}).onNotification(nh.client.session.update,async({params:_})=>{_.sessionId===f&&(d.push(_.update),await e.onUpdate?.(_.update))});e.requestPermission!=null&&(y=y.onRequest(nh.client.session.requestPermission,({params:_})=>e.requestPermission(_)));let S=y.connect(_9(Q0t.toWeb(u),J0t.toWeb(u)));return await S.agent.request(nh.agent.initialize,{protocolVersion:1,clientCapabilities:{},clientInfo:{name:r,version:n},_meta:{redskills:{wireMajor:SPe}}}),f=(await S.agent.request(nh.agent.session.new,{cwd:t,mcpServers:[]})).sessionId,{connection:S,socket:u,sessionId:f,pendingUpdates:d,dead:()=>m,close(){m=!0,S.close(),u.destroy()}}}),a=s.ensure;return{control:async(l,u={})=>{let f=await(await a()).connection.agent.request(Y0t[l],{...u.target==null?{}:{target:u.target},...u.runner==null?{}:{runner:u.runner},...u.registration==null?{}:{registration:u.registration}});if(!PPe(f))throw new Error("redskilled returned an invalid Project control outcome");if(l==="status"&&!tRt(f))throw new Error("redskilled returned Project status without a valid RedSkills context");return f},async github(l){return await(await a()).connection.agent.request(Ms.githubRequest,{request:l})},async brain(l){return await(await a()).connection.agent.request(Ms.brainCall,{tool:l.tool,arguments:l.arguments})},async memory(l){return await(await a()).connection.agent.request(Ms.memoryCall,{tool:l.tool,arguments:l.arguments,...l.mode==null?{}:{mode:l.mode}})},async prompt(l){let u=await a(),d=u.pendingUpdates.length,f=await u.connection.agent.request(nh.agent.session.prompt,{sessionId:u.sessionId,prompt:[{type:"text",text:l}]});return{stopReason:f.stopReason,...eRt(f._meta),updates:u.pendingUpdates.slice(d)}},async cancel(){let l=await a();return await l.connection.agent.notify(nh.agent.session.cancel,{sessionId:l.sessionId})},async permission(l){return e.requestPermission==null?{outcome:{outcome:"cancelled"},_meta:{redskills:{permissionResolution:"hitl-required"}}}:await e.requestPermission(l)},close(){s.close()}}}async function X0t(e){let t=await e(),r=!1,n=null;return{async ensure(){if(r)throw new Error("this RedSkills Project ACP client is closed");return t.dead()?(n??=e().then(o=>(t=o,n=null,o),o=>{throw n=null,o}),await n):t},close(){r=!0,t.close()}}}function eRt(e){let r=Jp(Jp(e)?.redskills)?.projectControl;return PPe(r)?{projectControl:r}:{}}function PPe(e){let t=Jp(e);return t?.version===1&&typeof t.project_id=="string"&&typeof t.revision=="number"&&Array.isArray(t.updates)}function tRt(e){let t=Jp(Jp(e)?.context),r=Jp(t?.queue),n=Jp(t?.workers),o=Jp(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(rRt)&&(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 rRt(e){let t=Jp(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 Jp(e){return e!=null&&typeof e=="object"&&!Array.isArray(e)?e:void 0}async function nRt(e){return await new Promise((t,r)=>{let n=Z0t(e);n.once("connect",()=>t(n)),n.once("error",r)})}fee();yd();are();D_();yd();var Kz=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},Nb,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},Sh,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)}};cre();var Qz=class extends U_{constructor(t,r){super(r),this._serverInfo=t,this._loggingLevels=new Map,this.LOG_LEVEL_SEVERITY=new Map(DT.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 sw,this.setRequestHandler(iX,n=>this._oninitialize(n)),this.setNotificationHandler(aX,()=>this.oninitialized?.()),this._capabilities.logging&&this.setRequestHandler(EX,async(n,o)=>{let i=o.sessionId||o.requestInfo?.headers["mcp-session-id"]||void 0,{level:s}=n.params,a=DT.safeParse(s);return a.success&&this._loggingLevels.set(i,a.data),{}})}get experimental(){return this._experimental||(this._experimental={tasks:new Kz(this)}),this._experimental}registerCapabilities(t){if(this.transport)throw new Error("Cannot register capabilities after connecting to transport");this._capabilities=fz(this._capabilities,t)}setRequestHandler(t,r){let o=hd(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(j_,c);if(!u.success){let y=u.error instanceof Error?u.error.message:String(u.error);throw new ze(qe.InvalidParams,`Invalid tools/call request: ${y}`)}let{params:d}=u.data,f=await Promise.resolve(r(c,l));if(d.task){let y=Ns(nf,f);if(!y.success){let S=y.error instanceof Error?y.error.message:String(y.error);throw new ze(qe.InvalidParams,`Invalid task creation result: ${S}`)}return y.data}let m=Ns(gd,f);if(!m.success){let y=m.error instanceof Error?m.error.message:String(m.error);throw new ze(qe.InvalidParams,`Invalid tools/call result: ${y}`)}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){Jz(this._clientCapabilities?.tasks?.requests,t,"Client")}assertTaskHandlerCapability(t){this._capabilities&&Zz(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:jN.includes(r)?r:RT,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"},rf)}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},NT,r):this.request({method:"sampling/createMessage",params:t},Nb,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},Sh,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},Sh,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},PX,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"})}};D_();pee();yd();var jDe=Symbol.for("mcp.completable");function lre(e){return!!e&&typeof e=="object"&&jDe in e}function UDe(e){return e[jDe]?.complete}var FDe;(function(e){e.Completable="McpCompletable"})(FDe||(FDe={}));var Z1t=/^[A-Za-z0-9._-]{1,128}$/;function J1t(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"),!Z1t.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 Q1t(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 ure(e){let t=J1t(e);return Q1t(e,t.warnings),t.isValid}var Yz=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)}};fC();var aw=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 Qz(t,r)}get experimental(){return this._experimental||(this._experimental={tasks:new Yz(this)}),this._experimental}async connect(t){return await this.server.connect(t)}async close(){await this.server.close()}setToolRequestHandlers(){this._toolHandlersInitialized||(this.server.assertCanSetRequestHandler(Ah(tz)),this.server.assertCanSetRequestHandler(Ah(j_)),this.server.registerCapabilities({tools:{listChanged:!0}}),this.server.setRequestHandler(tz,()=>({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=M_(r.inputSchema);return o?lee(o,{strictUnions:!0,pipeStrategy:"input"}):Y1t})(),annotations:r.annotations,execution:r.execution,_meta:r._meta};if(r.outputSchema){let o=M_(r.outputSchema);o&&(n.outputSchema=lee(o,{strictUnions:!0,pipeStrategy:"output"}))}return n})})),this.server.setRequestHandler(j_,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=M_(t.inputSchema)??t.inputSchema,s=await MN(i,r);if(!s.success){let a="error"in s?s.error:"Unknown error",c=DN(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=M_(t.outputSchema),i=await MN(o,r.structuredContent);if(!i.success){let s="error"in i?i.error:"Unknown error",a=DN(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(Ah(rz)),this.server.registerCapabilities({completions:{}}),this.server.setRequestHandler(rz,async t=>{switch(t.params.ref.type){case"ref/prompt":return lOe(t),this.handlePromptCompletion(t,t.params.ref);case"ref/resource":return uOe(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 mC;let i=hd(n.argsSchema)?.[t.params.argument.name];if(!lre(i))return mC;let s=UDe(i);if(!s)return mC;let a=await s(t.params.argument.value,t.params.context);return qDe(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 mC;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 mC;let i=await o(t.params.argument.value,t.params.context);return qDe(i)}setResourceRequestHandlers(){this._resourceHandlersInitialized||(this.server.assertCanSetRequestHandler(Ah(L_)),this.server.assertCanSetRequestHandler(Ah(YN)),this.server.assertCanSetRequestHandler(Ah(F_)),this.server.registerCapabilities({resources:{listChanged:!0}}),this.server.setRequestHandler(L_,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(YN,async()=>({resourceTemplates:Object.entries(this._registeredResourceTemplates).map(([r,n])=>({name:r,uriTemplate:n.resourceTemplate.uriTemplate.toString(),...n.metadata}))})),this.server.setRequestHandler(F_,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(Ah(XN)),this.server.assertCanSetRequestHandler(Ah(ez)),this.server.registerCapabilities({prompts:{listChanged:!0}}),this.server.setRequestHandler(XN,()=>({prompts:Object.entries(this._registeredPrompts).filter(([,t])=>t.enabled).map(([t,r])=>({name:t,title:r.title,description:r.description,arguments:r.argsSchema?X1t(r.argsSchema):void 0}))})),this.server.setRequestHandler(ez,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=M_(n.argsSchema),i=await MN(o,t.params.arguments);if(!i.success){let c="error"in i?i.error:"Unknown error",l=DN(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:Db(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=Db(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 lre(l)})&&this.setCompletionRequestHandler(),s}_createRegisteredTool(t,r,n,o,i,s,a,c,l){ure(t);let u={title:r,description:n,inputSchema:HDe(o),outputSchema:HDe(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"&&ure(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=Db(d.paramsSchema)),typeof d.outputSchema<"u"&&(u.outputSchema=Db(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(dre(c))o=r.shift(),r.length>1&&typeof r[0]=="object"&&r[0]!==null&&!dre(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 Y1t={type:"object",properties:{}};function GDe(e){return e!==null&&typeof e=="object"&&"parse"in e&&typeof e.parse=="function"&&"safeParse"in e&&typeof e.safeParse=="function"}function BDe(e){return"_def"in e||"_zod"in e||GDe(e)}function dre(e){return typeof e!="object"||e===null||BDe(e)?!1:Object.keys(e).length===0?!0:Object.values(e).some(GDe)}function HDe(e){if(e){if(dre(e))return Db(e);if(!BDe(e))throw new Error("inputSchema must be a Zod schema or raw shape, received an unrecognized object");return e}}function X1t(e){let t=hd(e);return t?Object.entries(t).map(([r,n])=>{let o=bAe(n),i=xAe(n);return{name:r,description:o,required:!i}}):[]}function Ah(e){let r=hd(e)?.method;if(!r)throw new Error("Schema is missing a method literal");let n=NN(r);if(typeof n=="string")return n;throw new Error("Schema method literal must be a string")}function qDe(e){return{completion:{values:e.slice(0,100),total:e.length,hasMore:e.length>100}}}var mC={completion:{values:[],hasMore:!1}};pre();import WDe from"node:process";var hC=class{constructor(t=WDe.stdin,r=WDe.stdout){this._stdin=t,this._stdout=r,this._readBuffer=new cw,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=Xz(t);this._stdout.write(n)?r():this._stdout.once("drain",r)})}};import{resolve as P$}from"node:path";import{fileURLToPath as Gdt}from"node:url";Jn();function VDe(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)}]}h_();function fre(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)?e:null}function mre(e){return typeof e=="string"&&e.trim()!==""?e:null}function tNt(e){let t=fre(e);if(t===null)return null;let r=fre(t.demand);return mre(r?.refusal)??mre(t.latest_refusal)}function KDe(e){return{tool:"status",args:{scope:"project"},why:e}}function rNt(){return{tool:"status",args:{scope:"host"},why:"diagnose why the host daemon does not answer before changing registration"}}function nNt(e,t){let r=e.registration;return r.daemon_reachable?!r.held&&r.repair!==void 0&&r.repair!=="none"?m_():e.live_workers.length>0&&t===null?{tool:"status",args:{scope:"worker"},why:"observe the Workers already draining this project's queue"}:KDe(t!==null?"observe when the daemon's refusal clears and capacity begins draining again":"observe the next socket-local queue poll and Worker birth"):rNt()}function oNt(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 iNt(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 ZDe(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=oNt(r),i=tNt(n),s=nNt(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:mre(fre(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:iNt(t())}}}]}Jn();function JDe(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})}]}Jn();var sNt=["requeue","retake","park","close"];function QDe(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(sNt),rationale:w.string().min(1)},invoke:t=>e.hitlResolve(t)}]}Jn();var eL="2.0.0";function tL(e,t){return{version:eL,schema:e,projection:t}}var IOr=w.object({age_s:w.number(),stale:w.boolean(),stale_after_s:w.number(),reason:w.enum(["fresh","aged-out","never-observed","orphaned"])}),aNt=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"])}),cNt=w.object({tool:w.string().min(1),args:w.record(w.string(),w.unknown()),why:w.string().min(1)}),lNt=w.union([cNt,w.literal("none")]),uNt=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:lNt.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:aNt.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"})}),dNt=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()})}),pNt=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)}),gC=w.object({registration:uNt,validation_schedule:pNt,birth_latch:dNt.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()}),fNt=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()}),mNt=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()}),hNt=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()})}),XDe=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:fNt}),live:w.boolean(),active:w.boolean(),renderable_live:w.boolean(),liveness:w.enum(["active","quiet-but-live","dead"]),liveness_verdict:mNt,daemon_liveness:hNt.optional()}),rL=w.array(XDe),nL=w.array(XDe.partial()),gNt=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()}),yC=w.object({workers:w.array(gNt),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()}),YDe=w.object({number:w.number(),title:w.string(),labels:w.array(w.string())}),e1e=w.object({ready_for_agent:w.object({eligible:w.array(YDe),held_for_summon:w.array(YDe)}),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()}))}),t1e=tL(gC),AOr=tL(rL,{input:"fields",schema:nL}),OOr=tL(yC),r1e=tL(e1e);function yNt(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 n1e(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=yNt(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}}})}Jn();var o1e="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`).",hre=class extends Error{constructor(t){super(t===void 0||t===""?o1e:`fleet ${JSON.stringify(t)}: ${o1e}`),this.name="FleetNamingRemovedError"}};function lw(e){if(!(e==null||e===""))throw new hre(typeof e=="string"?e:String(e))}Jn();var bNt=w.object({tool:w.literal("status"),args:w.object({scope:w.enum(["worker","project","host"])})});function i1e(e){return w.object({deprecated:w.literal(!0),message:w.string().min(1),replacement:bNt,result:e})}function a1e(e){return{version:e.version,schema:i1e(e.schema),...e.projection===void 0?{}:{projection:{input:e.projection.input,schema:i1e(e.projection.schema)}}}}var xNt=w.object({status:w.unknown(),vitals:rL,monitor:yC}),SNt=w.object({status:w.unknown(),vitals:nL,monitor:yC}),s1e=w.object({state:w.unknown(),dashboard:w.unknown(),provision_check:w.unknown(),unit_status:w.unknown()}),kNt={version:eL,schema:w.union([gC,xNt,s1e]),projection:{input:"fields",schema:w.union([gC,SNt,s1e])}};function c1e(e,t,r){return{deprecated:!0,message:`${e} is deprecated; use status { scope: ${t} }`,replacement:{tool:"status",args:{scope:t}},result:r}}async function _Nt(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 l1e(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:kNt,invoke:t=>_Nt(e,t)}]}oL();var iL={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 p1e=w.record(w.string(),w.union([w.string(),w.number(),w.boolean()])),bC=w.string().optional().describe("REMOVED: naming a fleet is refused; a project has one producer.");function f1e(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:bC},outputContract:a1e(t1e),invoke:async({fleet:t})=>(lw(t),c1e("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(iL).optional(),config:p1e.optional(),base:w.string().min(1).optional(),fleet:bC},invoke:async t=>(lw(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(iL).optional(),config:p1e.optional(),base:w.string().min(1).optional(),fleet:bC},invoke:async t=>(lw(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:bC},invoke:async({latch:t,fleet:r})=>(lw(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:bC},invoke:async({force:t,fleet:r})=>(lw(r),e.projectStop({force:t}))}]}Jn();function m1e(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 h1e(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()}]}Jn();function g1e(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()}]}Jn();function y1e(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})}]}Jn();function b1e(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(iL).optional()},outputContract:r1e,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})}]}Jn();function x1e(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)}]}Jn();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)}]}Jn();Jn();h_();function yre(e){let t=ma({state:e instanceof Error?e.message:String(e),repair:sb("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 bre={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 xre(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 k1e(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:bre,invoke:t=>{let r;try{r=xre(t)}catch(n){return Promise.resolve(yre(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 _1e(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:{...bre,text:w.string().min(1)},invoke:t=>{let r;try{r=xre(t)}catch(n){return Promise.resolve(yre(n))}return e.workerRequest({...r,text:t.text})}}]}function w1e(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()}]}Jn();h_();function v1e(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:sb("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 E1e(e,t){return t==="allow"?e:e.map(r=>{if(!r.dangerClass)return r;if(t==="deny")return{...r,invoke:async i=>v1e("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 v1e("confirm",r.name,i);let{confirmation:s,...a}=i;return o(a)}}})}Jn();function R1e(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})}]}Jn();function T1e(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})}]}Jn();function C1e(e){return[{name:"standing_orders_show",title:"Show standing orders for this project",description:"READ-ONLY: return all standing orders for this project. Standing orders are an append-only, numbered register injected verbatim into every Worker brief.",inputSchema:{project_label:w.string().min(1).optional().describe("Override the current project label")},invoke:t=>e.standingOrdersShow(t)},{name:"standing_orders_append",title:"Append a standing order",description:"MUTATING: append a new standing order to this project's register. The order is injected verbatim into every Worker brief at admission and on resume. Append is append-only \u2014 existing orders are never mutated or renumbered.",inputSchema:{text:w.string().min(1).describe("The standing order text"),project_label:w.string().min(1).optional().describe("Override the current project label")},invoke:t=>e.standingOrdersAppend(t)}]}var sL="Call the redskilled MCP's `help` tool.\nFollow its guidance and invoke the returned `next` call.",Sre=[{name:"drain",title:"Drain this project's queue",description:"Find the next action for starting or continuing a project drain.",body:sL},{name:"diagnose",title:"Diagnose redskilled",description:"Find the next action for understanding a redskilled problem.",body:sL},{name:"configure",title:"Configure redskilled",description:"Find the next action for changing project execution configuration.",body:sL},{name:"stop",title:"Stop project work",description:"Find the next action for stopping project work safely.",body:sL}];var P1e="rs_dev";function I1e(e,t="allow"){let r=[],n=[...ZDe(e,()=>r),...l1e(e),...f1e(e),...b1e(e),...h1e(e),...k1e(e),..._1e(e),...g1e(e),...m1e(e),...y1e(e),...VDe(e),...JDe(e),...QDe(e),...T1e(e),...R1e(e),...S1e(e),...w1e(e),...x1e(e),...C1e(e)];return r=E1e(n1e(n),t),r}Yt();function uw(e){return tn(JSON.parse(JSON.stringify(e??null)),{objectArrayColumns:!0,primitiveArrayColumns:!0})}var wNt=new Map([["drain","drain"],["project_drain","drain"],["project_stop","stop"],["project_status","status"],["status","status"]]),vNt=new Set(["target","runner","scope","registration","live_only","fields","worker"]);async function A1e(e,t,r){let n=wNt.get(t);if(n!=null){let o=Object.keys(r).filter(i=>!vNt.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,ENt(r))}if(!TNt(t))throw new Error(`unsupported ACP Project capability ${JSON.stringify(t)}`);return await e.prompt(RNt(t,r))}function ENt(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 RNt(e,t){return`/${e} ${JSON.stringify(t)}`}function TNt(e){return/^[a-z][a-z0-9_]*$/.test(e)&&!e.startsWith("private_")&&!e.includes("worker_birth")&&!e.includes("daemon_protocol")&&!e.includes("github_client")}Ere();oL();import{execFileSync as zzt}from"node:child_process";wR();wd();function iNe(e){let t=aNe(e.repo).join("/"),r=e.selector??{},n=[`repo:${t}`,"is:issue","is:open",lL(e.readyLabel??su)];r.lane!=null&&r.lane!==""&&n.push(lL(`lane:${r.lane}`)),r.label!=null&&r.label!==""&&n.push(lL(r.label));for(let o of r.tags??[])o!==""&&n.push(lL(`${Tre}${o}`));return r.user!=null&&r.user!==""&&r.user!=="@me"&&n.push(`author:${r.user}`),n.join(" ")}function sNe(e){let[t,r]=aNe(e.repo),n=e.selector??{},o=e.readyLabel??su,i=[o];n.lane!=null&&n.lane!==""&&i.push(`lane:${n.lane}`),n.label!=null&&n.label!==""&&i.push(n.label);for(let a of n.tags??[])a!==""&&i.push(`${Tre}${a}`);let s=n.user!=null&&n.user!==""&&n.user!=="@me"?n.user:void 0;return{owner:t,repo:r,labels:i,...s===void 0?{}:{creator:s},counter_labels:{ready:o,human:Oh}}}function lL(e){return`label:${JSON.stringify(e)}`}function aNe(e){let t=e.trim().split("/");if(t.length!==2||t[0]===""||t[1]==="")throw new Error("a registration needs the repository its queue lives in: the daemon polls the string it is handed and cannot work out which tracker a checkout belongs to");return[t[0],t[1]]}var WNt="Implement issue #{{work_item}} in this workspace. The Ticket is already claimed for you, and the daemon runs the gate, publishes your commits and lands the pull request after you finish \u2014 so never touch GitHub yourself: no label moves, no claim or status comments, no PR. Your whole job is the change and its commits, right here. You are already standing in your own dedicated worktree on the Ticket's base branch: work and commit right here, and never create another worktree \u2014 the repository's worktree lanes govern interactive sessions, not Workers. If your change touches apps/ or packages/, also write a .changeset/<slug>.md entry naming each touched package by its package.json name with a patch bump, and commit it with the change. When the change is committed, say <promise>DONE</promise>. If the work is genuinely blocked, say what blocks it and <promise>BLOCKED</promise>.";function cNe(e){let t={repo:e.repo,...e.selector==null?{}:{selector:e.selector},...e.readyLabel==null?{}:{readyLabel:e.readyLabel}};return{selector:iNe(t),queue_poll:sNe(t),argv:jp("red-skills-redskilled",["acp-worker",...e.runner==null?[]:["--child-agent",e.runner]],e.version).split(" "),workspace_path:e.workspacePath,trunk:{remote:"origin",branch:e.trunkBranch??"main"},prompt:WNt,...e.validationCommands==null||e.validationCommands.length===0?{}:{validation_commands:[...e.validationCommands]},target:e.target}}wC();lf();function wze(e,t,r={},n=vre){let o=Fzt(e,n);if(o==null)return;let i=typeof r.target=="number"&&Number.isInteger(r.target)&&r.target>=0?r.target:1,s=typeof r.runner=="string"&&r.runner.length>0?r.runner:void 0,a=Lzt(e);return cNe({repo:o,workspacePath:e,target:i,version:t,...s==null?{}:{runner:s},..._ze(e)==null?{}:{trunkBranch:_ze(e)},...a.length===0?{}:{validationCommands:a}})}function Lzt(e){try{let t=kze(_C(cu(e).configPath,{warn:()=>{}}));return[...t.post_done??[],...t.landing??[]]}catch{return[]}}function _ze(e){try{let r=zzt("git",["-C",e,"symbolic-ref","refs/remotes/origin/HEAD"],{encoding:"utf8",timeout:5e3}).trim().split("/").pop();return r==null||r===""?void 0:r}catch{return}}function Fzt(e,t=vre){let r;try{r=t(e).name}catch{return}return/^[^/\s]+\/[^/\s]+$/.test(r)?r:void 0}yd();var hw="redskilled://lanes/events",jzt=1e3;function vze(e,t,r={}){let n=r.bufferLimit??jzt,o=[],i=0,s,a=c=>{o.push(c.record),o.length>n&&o.splice(0,o.length-n),e.sendResourceUpdated({uri:hw})};return e.registerCapabilities({resources:{subscribe:!0}}),e.setRequestHandler(L_,()=>({resources:[{uri:hw,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(F_,c=>{let l=Qre(c);if(l!==hw)throw new Error(`unknown resource ${JSON.stringify(l)}`);let u=o.splice(0,o.length);return{contents:[{uri:hw,mimeType:"application/toon",text:uw({events:u})}]}}),e.setRequestHandler(mX,async c=>Qre(c)!==hw?{}:(i+=1,i===1&&(s=await t.subscribe(a),t.start(r.intervalMs)),{})),e.setRequestHandler(hX,c=>Qre(c)!==hw?{}:(i>0&&(i-=1),i===0&&(s?.(),s=void 0,t.stop()),{})),{poll:()=>t.poll(),stop:()=>{s?.(),s=void 0,t.stop()}}}function Qre(e){let t=e?.params;return typeof t?.uri=="string"?t.uri:""}function Rze(e){let t=new Set,r,n,o=async()=>{let s=await e("events_since",r===void 0?{}:{cursor:r});if(!Eze(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(Eze):[];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 Eze(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}Jn();var Yre="rs_github",Tze="github_request",bL=Ms.githubRequest;function Xre(){return[{name:Tze,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:bL,inputSchema:{method:w.enum(kPe),path:w.string().min(1),body:w.record(w.unknown()).optional(),headers:w.record(w.string()).optional()}}]}function Cze(e){return{request:{method:e.method,path:e.path,...e.body===void 0?{}:{body:e.body},...e.headers===void 0?{}:{headers:e.headers}}}}function ene(e){let t=new aw({name:Yre,version:e.version}),r=t.registerTool.bind(t);for(let n of e.tools??Xre())r(n.name,{title:n.title,description:n.description,inputSchema:n.inputSchema},async o=>({content:[{type:"text",text:uw(await e.invoke(n.method,Cze(o)))}]}));return t}var dk=XW("redskilled-mcp");function qlr(e=process.cwd(),t){let r=new aw({name:P1e,version:dk.version}),n=r.registerTool.bind(r),o=t??(async()=>{throw new Error("REDSKILLED_ACP_UNAVAILABLE: the stdio adapter has no ACP client")}),i={},s=(a,c)=>a==="drain"&&c.registration==null?{...c,registration:wze(e,dk.version,c)}:c;for(let a of I1e(i))n(a.name,{title:a.title,description:a.description,inputSchema:a.inputSchema},async c=>({content:[{type:"text",text:uw(await o(a.name,s(a.name,c)))}]}));for(let a of Sre)r.registerPrompt(a.name,{title:a.title,description:a.description},async()=>({messages:[{role:"user",content:{type:"text",text:a.body}}]}));return vze(r.server,Rze(o)),r}async function Bdt(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 P$(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 P$(Gdt(i.uri))}catch{}return P$(r)}async function Wdt(e){let t,r=new Promise(n=>{t=n});e.server.server.onclose=t,await e.server.connect(e.transport),await r}async function Glr(){let e=process.cwd(),t,r,n=()=>(t??=Bdt(r.server,process.env,e).then(i=>P7({cwd:i,name:"RedSkills GitHub MCP adapter",version:dk.version})),t);r=ene({version:dk.version,invoke:async(i,s)=>{if(i!==bL)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 Wdt({server:r,transport:new hC})}finally{if(t!==void 0)try{(await t).close()}catch{}process.removeListener("SIGINT",o),process.removeListener("SIGTERM",o)}}async function Blr(){let e=process.cwd(),t,r,n=()=>(t??=Bdt(r.server,process.env,e).then(i=>P7({cwd:i,name:"RedSkills MCP adapter",version:dk.version})),t);r=qlr(e,async(i,s)=>A1e(await n(),i,s));let o=()=>{r.close()};process.once("SIGINT",o),process.once("SIGTERM",o);try{await Wdt({server:r,transport:new hC})}finally{if(t!==void 0)try{(await t).close()}catch{}process.removeListener("SIGINT",o),process.removeListener("SIGTERM",o)}}var Wlr=`Usage: red-skills-redskilled-mcp [command]
445
445
 
446
446
  Commands:
447
447
  (none) serve the rs_dev MCP surface over stdio