@reddb-io/red-skills 4.1.13 → 4.1.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/code-nav.bundle.min.mjs +1 -1
- package/dist/opencode-host.bundle.min.mjs +1 -1
- package/dist/redskilled-mcp.bundle.min.mjs +2 -2
- package/dist/redskilled.bundle.min.mjs +2 -2
- package/dist/release.bundle.min.mjs +1 -1
- package/dist/rsp-core.bundle.min.mjs +1 -1
- package/dist/rsp.bundle.min.mjs +1 -1
- package/package.json +1 -1
|
@@ -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 Wdt=Object.create;var QW=Object.defineProperty;var Vdt=Object.getOwnPropertyDescriptor;var Kdt=Object.getOwnPropertyNames;var Zdt=Object.getPrototypeOf,Jdt=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)QW(e,r,{get:t[r],enumerable:!0})},Qdt=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of Kdt(t))!Jdt.call(e,o)&&o!==r&&QW(e,o,{get:()=>t[o],enumerable:!(n=Vdt(t,o))||n.enumerable});return e};var Ip=(e,t,r)=>(r=e!=null?Wdt(Zdt(e)):{},Qdt(t||!e||!e.__esModule?QW(r,"default",{value:e,enumerable:!0}):r,e));function YW(e){let t={app:e,version:Ydt(hk("__RED_BUILD_VERSION__",()=>"4.1.13")??"0.0.0-dev"),gitSha:hk("__RED_BUILD_GIT_SHA__",()=>"19ba7780d0a8be832373d24cce303d1833430d2d")??"unknown",buildTime:hk("__RED_BUILD_TIME__",()=>"2026-08-21T01:42:13-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 Ydt(e){return e.startsWith("v")?e.slice(1):e}function lSe(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 XW=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 uSe,t4,r4,Hl,Bm,Hy,qy=p(()=>{t4=Object.freeze({status:"aborted"});r4=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"}};(uSe=globalThis).__zod_globalConfig??(uSe.__zod_globalConfig={});Hy=globalThis.__zod_globalConfig});var Re={};Vn(Re,{BIGINT_FORMAT_RANGES:()=>p4,Class:()=>o4,NUMBER_FORMAT_RANGES:()=>d4,aborted:()=>Zm,allowsEval:()=>a4,assert:()=>opt,assertEqual:()=>ept,assertIs:()=>rpt,assertNever:()=>npt,assertNotEqual:()=>tpt,assignProp:()=>Vm,base64ToUint8Array:()=>pSe,base64urlToUint8Array:()=>kpt,cached:()=>yk,captureStackTrace:()=>A$,cleanEnum:()=>Spt,cleanRegex:()=>I0,clone:()=>Cs,cloneDef:()=>spt,createTransparentProxy:()=>ppt,defineLazy:()=>Jt,esc:()=>I$,escapeRegex:()=>$c,explicitlyAborted:()=>f4,extend:()=>hpt,finalizeIssue:()=>Ps,floatSafeRemainder:()=>i4,getElementAtPath:()=>apt,getEnumValues:()=>P0,getLengthableOrigin:()=>$0,getParsedType:()=>dpt,getSizableOrigin:()=>O0,hexToUint8Array:()=>wpt,isObject:()=>Gy,isPlainObject:()=>Km,issue:()=>bk,joinValues:()=>ne,jsonStringifyReplacer:()=>gk,merge:()=>ypt,mergeDefs:()=>Ap,normalizeParams:()=>Ie,nullish:()=>Wm,numKeys:()=>upt,objectClone:()=>ipt,omit:()=>mpt,optionalKeys:()=>u4,parsedType:()=>Ee,partial:()=>bpt,pick:()=>fpt,prefixIssues:()=>ca,primitiveTypes:()=>l4,promiseAllObject:()=>cpt,propertyKeyTypes:()=>A0,randomString:()=>lpt,required:()=>xpt,safeExtend:()=>gpt,shallowClone:()=>c4,slugify:()=>s4,stringifyPrimitive:()=>ve,uint8ArrayToBase64:()=>fSe,uint8ArrayToBase64url:()=>_pt,uint8ArrayToHex:()=>vpt,unwrapMessage:()=>C0});function ept(e){return e}function tpt(e){return e}function rpt(e){}function npt(e){throw new Error("Unexpected value in exhaustive check")}function opt(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 i4(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!==dSe)return n===void 0&&(n=dSe,n=r()),n},set(o){Object.defineProperty(e,t,{value:o})},configurable:!0})}function ipt(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 Ap(...e){let t={};for(let r of e){let n=Object.getOwnPropertyDescriptors(r);Object.assign(t,n)}return Object.defineProperties({},t)}function spt(e){return Ap(e._zod.def)}function apt(e,t){return t?t.reduce((r,n)=>r?.[n],e):e}function cpt(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 lpt(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 s4(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 c4(e){return Km(e)?{...e}:Array.isArray(e)?[...e]:e instanceof Map?new Map(e):e instanceof Set?new Set(e):e}function upt(e){let t=0;for(let r in e)Object.prototype.hasOwnProperty.call(e,r)&&t++;return t}function $c(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Cs(e,t,r){let n=new e._zod.constr(t??e._zod.def);return(!t||r?.parent)&&(n._zod.parent=e),n}function Ie(e){let t=e;if(!t)return{};if(typeof t=="string")return{error:()=>t};if(t?.message!==void 0){if(t?.error!==void 0)throw new Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,typeof t.error=="string"?{...t,error:()=>t.error}:t}function ppt(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 u4(e){return Object.keys(e).filter(t=>e[t]._zod.optin==="optional"&&e[t]._zod.optout==="optional")}function fpt(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=Ap(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 mpt(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=Ap(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 hpt(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=Ap(e._zod.def,{get shape(){let i={...e._zod.def.shape,...t};return Vm(this,"shape",i),i}});return Cs(e,o)}function gpt(e,t){if(!Km(t))throw new Error("Invalid input to safeExtend: expected a plain object");let r=Ap(e._zod.def,{get shape(){let n={...e._zod.def.shape,...t};return Vm(this,"shape",n),n}});return Cs(e,r)}function ypt(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=Ap(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 bpt(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=Ap(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 xpt(e,t,r){let n=Ap(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 f4(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 Spt(e){return Object.entries(e).filter(([t,r])=>Number.isNaN(Number.parseInt(t,10))).map(t=>t[1])}function pSe(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 fSe(e){let t="";for(let r=0;r<e.length;r++)t+=String.fromCharCode(e[r]);return btoa(t)}function kpt(e){let t=e.replace(/-/g,"+").replace(/_/g,"/"),r="=".repeat((4-t.length%4)%4);return pSe(t+r)}function _pt(e){return fSe(e).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}function wpt(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 vpt(e){return Array.from(e).map(t=>t.toString(16).padStart(2,"0")).join("")}var dSe,A$,a4,dpt,A0,l4,d4,p4,o4,ot=p(()=>{qy();dSe=Symbol("evaluating");A$="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};a4=yk(()=>{if(Hy.jitless||typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{let e=Function;return new e(""),!0}catch{return!1}});dpt=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"]),l4=new Set(["string","number","bigint","boolean","symbol","undefined"]);d4={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]},p4={int64:[BigInt("-9223372036854775808"),BigInt("9223372036854775807")],uint64:[BigInt(0),BigInt("18446744073709551615")]};o4=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 m4(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 hSe(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 h4(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 ${hSe(n.path)}`);return t.join(`
|
|
3
|
+
var Wdt=Object.create;var QW=Object.defineProperty;var Vdt=Object.getOwnPropertyDescriptor;var Kdt=Object.getOwnPropertyNames;var Zdt=Object.getPrototypeOf,Jdt=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)QW(e,r,{get:t[r],enumerable:!0})},Qdt=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of Kdt(t))!Jdt.call(e,o)&&o!==r&&QW(e,o,{get:()=>t[o],enumerable:!(n=Vdt(t,o))||n.enumerable});return e};var Ip=(e,t,r)=>(r=e!=null?Wdt(Zdt(e)):{},Qdt(t||!e||!e.__esModule?QW(r,"default",{value:e,enumerable:!0}):r,e));function YW(e){let t={app:e,version:Ydt(hk("__RED_BUILD_VERSION__",()=>"4.1.15")??"0.0.0-dev"),gitSha:hk("__RED_BUILD_GIT_SHA__",()=>"7d65b0d974114dba01d5cad11de71362f5a8682f")??"unknown",buildTime:hk("__RED_BUILD_TIME__",()=>"2026-08-21T02:38:22-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 Ydt(e){return e.startsWith("v")?e.slice(1):e}function lSe(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 XW=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 uSe,t4,r4,Hl,Bm,Hy,qy=p(()=>{t4=Object.freeze({status:"aborted"});r4=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"}};(uSe=globalThis).__zod_globalConfig??(uSe.__zod_globalConfig={});Hy=globalThis.__zod_globalConfig});var Re={};Vn(Re,{BIGINT_FORMAT_RANGES:()=>p4,Class:()=>o4,NUMBER_FORMAT_RANGES:()=>d4,aborted:()=>Zm,allowsEval:()=>a4,assert:()=>opt,assertEqual:()=>ept,assertIs:()=>rpt,assertNever:()=>npt,assertNotEqual:()=>tpt,assignProp:()=>Vm,base64ToUint8Array:()=>pSe,base64urlToUint8Array:()=>kpt,cached:()=>yk,captureStackTrace:()=>A$,cleanEnum:()=>Spt,cleanRegex:()=>I0,clone:()=>Cs,cloneDef:()=>spt,createTransparentProxy:()=>ppt,defineLazy:()=>Jt,esc:()=>I$,escapeRegex:()=>$c,explicitlyAborted:()=>f4,extend:()=>hpt,finalizeIssue:()=>Ps,floatSafeRemainder:()=>i4,getElementAtPath:()=>apt,getEnumValues:()=>P0,getLengthableOrigin:()=>$0,getParsedType:()=>dpt,getSizableOrigin:()=>O0,hexToUint8Array:()=>wpt,isObject:()=>Gy,isPlainObject:()=>Km,issue:()=>bk,joinValues:()=>ne,jsonStringifyReplacer:()=>gk,merge:()=>ypt,mergeDefs:()=>Ap,normalizeParams:()=>Ie,nullish:()=>Wm,numKeys:()=>upt,objectClone:()=>ipt,omit:()=>mpt,optionalKeys:()=>u4,parsedType:()=>Ee,partial:()=>bpt,pick:()=>fpt,prefixIssues:()=>ca,primitiveTypes:()=>l4,promiseAllObject:()=>cpt,propertyKeyTypes:()=>A0,randomString:()=>lpt,required:()=>xpt,safeExtend:()=>gpt,shallowClone:()=>c4,slugify:()=>s4,stringifyPrimitive:()=>ve,uint8ArrayToBase64:()=>fSe,uint8ArrayToBase64url:()=>_pt,uint8ArrayToHex:()=>vpt,unwrapMessage:()=>C0});function ept(e){return e}function tpt(e){return e}function rpt(e){}function npt(e){throw new Error("Unexpected value in exhaustive check")}function opt(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 i4(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!==dSe)return n===void 0&&(n=dSe,n=r()),n},set(o){Object.defineProperty(e,t,{value:o})},configurable:!0})}function ipt(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 Ap(...e){let t={};for(let r of e){let n=Object.getOwnPropertyDescriptors(r);Object.assign(t,n)}return Object.defineProperties({},t)}function spt(e){return Ap(e._zod.def)}function apt(e,t){return t?t.reduce((r,n)=>r?.[n],e):e}function cpt(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 lpt(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 s4(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 c4(e){return Km(e)?{...e}:Array.isArray(e)?[...e]:e instanceof Map?new Map(e):e instanceof Set?new Set(e):e}function upt(e){let t=0;for(let r in e)Object.prototype.hasOwnProperty.call(e,r)&&t++;return t}function $c(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Cs(e,t,r){let n=new e._zod.constr(t??e._zod.def);return(!t||r?.parent)&&(n._zod.parent=e),n}function Ie(e){let t=e;if(!t)return{};if(typeof t=="string")return{error:()=>t};if(t?.message!==void 0){if(t?.error!==void 0)throw new Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,typeof t.error=="string"?{...t,error:()=>t.error}:t}function ppt(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 u4(e){return Object.keys(e).filter(t=>e[t]._zod.optin==="optional"&&e[t]._zod.optout==="optional")}function fpt(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=Ap(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 mpt(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=Ap(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 hpt(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=Ap(e._zod.def,{get shape(){let i={...e._zod.def.shape,...t};return Vm(this,"shape",i),i}});return Cs(e,o)}function gpt(e,t){if(!Km(t))throw new Error("Invalid input to safeExtend: expected a plain object");let r=Ap(e._zod.def,{get shape(){let n={...e._zod.def.shape,...t};return Vm(this,"shape",n),n}});return Cs(e,r)}function ypt(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=Ap(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 bpt(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=Ap(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 xpt(e,t,r){let n=Ap(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 f4(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 Spt(e){return Object.entries(e).filter(([t,r])=>Number.isNaN(Number.parseInt(t,10))).map(t=>t[1])}function pSe(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 fSe(e){let t="";for(let r=0;r<e.length;r++)t+=String.fromCharCode(e[r]);return btoa(t)}function kpt(e){let t=e.replace(/-/g,"+").replace(/_/g,"/"),r="=".repeat((4-t.length%4)%4);return pSe(t+r)}function _pt(e){return fSe(e).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}function wpt(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 vpt(e){return Array.from(e).map(t=>t.toString(16).padStart(2,"0")).join("")}var dSe,A$,a4,dpt,A0,l4,d4,p4,o4,ot=p(()=>{qy();dSe=Symbol("evaluating");A$="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};a4=yk(()=>{if(Hy.jitless||typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{let e=Function;return new e(""),!0}catch{return!1}});dpt=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"]),l4=new Set(["string","number","bigint","boolean","symbol","undefined"]);d4={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]},p4={int64:[BigInt("-9223372036854775808"),BigInt("9223372036854775807")],uint64:[BigInt(0),BigInt("18446744073709551615")]};o4=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 m4(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 hSe(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 h4(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 ${hSe(n.path)}`);return t.join(`
|
|
4
4
|
`)}var mSe,M0,la,g4=p(()=>{qy();ot();mSe=(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",mSe),la=K("$ZodError",mSe,{Parent:Error})});var xk,O$,Sk,$$,kk,y4,_k,b4,M$,Rpt,D$,Tpt,N$,Cpt,z$,Ppt,L$,Ipt,F$,Apt,j$,Opt,U$,$pt,x4=p(()=>{qy();g4();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}},y4=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}},b4=_k(la),M$=e=>(t,r,n)=>{let o=n?{...n,direction:"backward"}:{direction:"backward"};return xk(e)(t,r,o)},Rpt=M$(la),D$=e=>(t,r,n)=>xk(e)(t,r,n),Tpt=D$(la),N$=e=>async(t,r,n)=>{let o=n?{...n,direction:"backward"}:{direction:"backward"};return Sk(e)(t,r,o)},Cpt=N$(la),z$=e=>async(t,r,n)=>Sk(e)(t,r,n),Ppt=z$(la),L$=e=>(t,r,n)=>{let o=n?{...n,direction:"backward"}:{direction:"backward"};return kk(e)(t,r,o)},Ipt=L$(la),F$=e=>(t,r,n)=>kk(e)(t,r,n),Apt=F$(la),j$=e=>async(t,r,n)=>{let o=n?{...n,direction:"backward"}:{direction:"backward"};return _k(e)(t,r,o)},Opt=j$(la),U$=e=>async(t,r,n)=>_k(e)(t,r,n),$pt=U$(la)});var Va={};Vn(Va,{base64:()=>D4,base64url:()=>H$,bigint:()=>H4,boolean:()=>G4,browserEmail:()=>Upt,cidrv4:()=>$4,cidrv6:()=>M4,cuid:()=>S4,cuid2:()=>k4,date:()=>L4,datetime:()=>j4,domain:()=>Gpt,duration:()=>R4,e164:()=>z4,email:()=>C4,emoji:()=>P4,extendedDuration:()=>Mpt,guid:()=>T4,hex:()=>Bpt,hostname:()=>qpt,html5Email:()=>Lpt,httpProtocol:()=>N4,idnEmail:()=>jpt,integer:()=>q4,ipv4:()=>I4,ipv6:()=>A4,ksuid:()=>v4,lowercase:()=>V4,mac:()=>O4,md5_base64:()=>Vpt,md5_base64url:()=>Kpt,md5_hex:()=>Wpt,nanoid:()=>E4,null:()=>B4,number:()=>q$,rfc5322Email:()=>Fpt,sha1_base64:()=>Jpt,sha1_base64url:()=>Qpt,sha1_hex:()=>Zpt,sha256_base64:()=>Xpt,sha256_base64url:()=>eft,sha256_hex:()=>Ypt,sha384_base64:()=>rft,sha384_base64url:()=>nft,sha384_hex:()=>tft,sha512_base64:()=>ift,sha512_base64url:()=>sft,sha512_hex:()=>oft,string:()=>U4,time:()=>F4,ulid:()=>_4,undefined:()=>W4,unicodeEmail:()=>gSe,uppercase:()=>K4,uuid:()=>By,uuid4:()=>Dpt,uuid6:()=>Npt,uuid7:()=>zpt,xid:()=>w4});function P4(){return new RegExp(Hpt,"u")}function bSe(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 F4(e){return new RegExp(`^${bSe(e)}$`)}function j4(e){let t=bSe({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(`^${ySe}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 S4,k4,_4,w4,v4,E4,R4,Mpt,T4,By,Dpt,Npt,zpt,C4,Lpt,Fpt,gSe,jpt,Upt,Hpt,I4,A4,O4,$4,M4,D4,H$,qpt,Gpt,N4,z4,ySe,L4,U4,H4,q4,q$,G4,B4,W4,V4,K4,Bpt,Wpt,Vpt,Kpt,Zpt,Jpt,Qpt,Ypt,Xpt,eft,tft,rft,nft,oft,ift,sft,G$=p(()=>{ot();S4=/^[cC][0-9a-z]{6,}$/,k4=/^[0-9a-z]+$/,_4=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,w4=/^[0-9a-vA-V]{20}$/,v4=/^[A-Za-z0-9]{27}$/,E4=/^[a-zA-Z0-9_-]{21}$/,R4=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,Mpt=/^[-+]?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)?)??$/,T4=/^([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)$/,Dpt=By(4),Npt=By(6),zpt=By(7),C4=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,Lpt=/^[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])?)*$/,Fpt=/^(([^<>()\[\]\\.,;:\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,}))$/,gSe=/^[^\s@"]{1,64}@[^\s@]{1,255}$/u,jpt=gSe,Upt=/^[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])?)*$/,Hpt="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";I4=/^(?:(?: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])$/,A4=/^(([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}|:))$/,O4=e=>{let t=$c(e??":");return new RegExp(`^(?:[0-9A-F]{2}${t}){5}[0-9A-F]{2}$|^(?:[0-9a-f]{2}${t}){5}[0-9a-f]{2}$`)},$4=/^((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])$/,M4=/^(([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])$/,D4=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,H$=/^[A-Za-z0-9_-]*$/,qpt=/^(?=.{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])?)*\.?$/,Gpt=/^([a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?\.)+[a-zA-Z]{2,}$/,N4=/^https?$/,z4=/^\+[1-9]\d{6,14}$/,ySe="(?:(?:\\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])))",L4=new RegExp(`^${ySe}$`);U4=e=>{let t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??""}}`:"[\\s\\S]*";return new RegExp(`^${t}$`)},H4=/^-?\d+n?$/,q4=/^-?\d+$/,q$=/^-?\d+(?:\.\d+)?$/,G4=/^(?:true|false)$/i,B4=/^null$/i,W4=/^undefined$/i,V4=/^[^A-Z]*$/,K4=/^[^a-z]*$/,Bpt=/^[0-9a-fA-F]*$/;Wpt=/^[0-9a-fA-F]{32}$/,Vpt=z0(22,"=="),Kpt=L0(22),Zpt=/^[0-9a-fA-F]{40}$/,Jpt=z0(27,"="),Qpt=L0(27),Ypt=/^[0-9a-fA-F]{64}$/,Xpt=z0(43,"="),eft=L0(43),tft=/^[0-9a-fA-F]{96}$/,rft=z0(64,""),nft=L0(64),oft=/^[0-9a-fA-F]{128}$/,ift=z0(86,"=="),sft=L0(86)});function xSe(e,t,r){e.issues.length&&t.issues.push(...ca(r,e.issues))}var un,SSe,B$,W$,Z4,J4,Q4,Y4,X4,eV,tV,rV,nV,wk,oV,iV,sV,aV,cV,lV,uV,dV,pV,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=[])}),SSe={number:"number",bigint:"bigint",object:"date"},B$=K("$ZodCheckLessThan",(e,t)=>{un.init(e,t);let r=SSe[typeof t.value];e._zod.onattach.push(n=>{let o=n._zod.bag,i=(t.inclusive?o.maximum:o.exclusiveMaximum)??Number.POSITIVE_INFINITY;t.value<i&&(t.inclusive?o.maximum=t.value:o.exclusiveMaximum=t.value)}),e._zod.check=n=>{(t.inclusive?n.value<=t.value:n.value<t.value)||n.issues.push({origin:r,code:"too_big",maximum:typeof t.value=="object"?t.value.getTime():t.value,input:n.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),W$=K("$ZodCheckGreaterThan",(e,t)=>{un.init(e,t);let r=SSe[typeof t.value];e._zod.onattach.push(n=>{let o=n._zod.bag,i=(t.inclusive?o.minimum:o.exclusiveMinimum)??Number.NEGATIVE_INFINITY;t.value>i&&(t.inclusive?o.minimum=t.value:o.exclusiveMinimum=t.value)}),e._zod.check=n=>{(t.inclusive?n.value>=t.value:n.value>t.value)||n.issues.push({origin:r,code:"too_small",minimum:typeof t.value=="object"?t.value.getTime():t.value,input:n.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),Z4=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):i4(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})}}),J4=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]=d4[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=q4)}),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})}}),Q4=K("$ZodCheckBigIntFormat",(e,t)=>{un.init(e,t);let[r,n]=p4[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})}}),Y4=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})}}),X4=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})}}),eV=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})}}),tV=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})}}),rV=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})}}),nV=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=()=>{})}),oV=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})}}),iV=K("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=V4),wk.init(e,t)}),sV=K("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=K4),wk.init(e,t)}),aV=K("$ZodCheckIncludes",(e,t)=>{un.init(e,t);let r=$c(t.includes),n=new RegExp(typeof t.position=="number"?`^.{${t.position}}${r}`:r);t.pattern=n,e._zod.onattach.push(o=>{let i=o._zod.bag;i.patterns??(i.patterns=new Set),i.patterns.add(n)}),e._zod.check=o=>{o.value.includes(t.includes,t.position)||o.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:t.includes,input:o.value,inst:e,continue:!t.abort})}}),cV=K("$ZodCheckStartsWith",(e,t)=>{un.init(e,t);let r=new RegExp(`^${$c(t.prefix)}.*`);t.pattern??(t.pattern=r),e._zod.onattach.push(n=>{let o=n._zod.bag;o.patterns??(o.patterns=new Set),o.patterns.add(r)}),e._zod.check=n=>{n.value.startsWith(t.prefix)||n.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:t.prefix,input:n.value,inst:e,continue:!t.abort})}}),lV=K("$ZodCheckEndsWith",(e,t)=>{un.init(e,t);let r=new RegExp(`.*${$c(t.suffix)}$`);t.pattern??(t.pattern=r),e._zod.onattach.push(n=>{let o=n._zod.bag;o.patterns??(o.patterns=new Set),o.patterns.add(r)}),e._zod.check=n=>{n.value.endsWith(t.suffix)||n.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:t.suffix,input:n.value,inst:e,continue:!t.abort})}});uV=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=>xSe(o,r,t.property));xSe(n,r,t.property)}}),dV=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})}}),pV=K("$ZodCheckOverwrite",(e,t)=>{un.init(e,t),e._zod.check=r=>{r.value=t.tx(r.value)}})});var F0,fV=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 mV,hV=p(()=>{mV={major:4,minor:4,patch:3}});function zV(e){if(e==="")return!0;if(/\s/.test(e)||e.length%4!==0)return!1;try{return atob(e),!0}catch{return!1}}function NSe(e){if(!H$.test(e))return!1;let t=e.replace(/[-_]/g,n=>n==="-"?"+":"/"),r=t.padEnd(Math.ceil(t.length/4)*4,"=");return zV(r)}function zSe(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 _Se(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 LSe(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=u4(e.shape);return{...e,keys:t,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(r)}}function FSe(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 wSe(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 vSe(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 gV(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=gV(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=gV(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 ESe(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=gV(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 RSe(e,t){for(let r=e.length-1;r>=0;r--)if(e[r]._zod[t]!=="optional")return r+1;return 0}function TSe(e,t,r){e.issues.length&&t.issues.push(...ca(r,e.issues)),t.value[r]=e.value}function CSe(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 PSe(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 ISe(e,t){e.issues.length&&t.issues.push(...e.issues),t.value.add(e.value)}function ASe(e,t){return t===void 0&&(e.issues.length||e.fallback)?{issues:[],value:void 0}:e}function OSe(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}function $Se(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 MSe(e){return e.value=Object.freeze(e.value),e}function DSe(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,yV,bV,xV,SV,kV,_V,wV,vV,EV,RV,TV,CV,PV,IV,AV,OV,$V,MV,DV,NV,LV,FV,jV,UV,HV,Y$,qV,j0,X$,GV,BV,WV,VV,KV,ZV,JV,QV,YV,XV,jSe,e6,U0,t6,r6,n6,eM,o6,i6,s6,a6,c6,l6,u6,tM,d6,p6,f6,m6,h6,g6,y6,b6,rM,H0,x6,S6,k6,_6,w6,v6,E6,R6=p(()=>{V$();qy();fV();x4();G$();ot();hV();ot();At=K("$ZodType",(e,t)=>{var r;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=mV;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(f4(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=y4(e,o);return i.success?{value:i.data}:{issues:i.error?.issues}}catch{return b4(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()??U4(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)}),yV=K("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=T4),Qr.init(e,t)}),bV=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)}),xV=K("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=C4),Qr.init(e,t)}),SV=K("$ZodURL",(e,t)=>{Qr.init(e,t),e._zod.check=r=>{try{let n=r.value.trim();if(!t.normalize&&t.protocol?.source===N4.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})}}}),kV=K("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=P4()),Qr.init(e,t)}),_V=K("$ZodNanoID",(e,t)=>{t.pattern??(t.pattern=E4),Qr.init(e,t)}),wV=K("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=S4),Qr.init(e,t)}),vV=K("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=k4),Qr.init(e,t)}),EV=K("$ZodULID",(e,t)=>{t.pattern??(t.pattern=_4),Qr.init(e,t)}),RV=K("$ZodXID",(e,t)=>{t.pattern??(t.pattern=w4),Qr.init(e,t)}),TV=K("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=v4),Qr.init(e,t)}),CV=K("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=j4(t)),Qr.init(e,t)}),PV=K("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=L4),Qr.init(e,t)}),IV=K("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=F4(t)),Qr.init(e,t)}),AV=K("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=R4),Qr.init(e,t)}),OV=K("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=I4),Qr.init(e,t),e._zod.bag.format="ipv4"}),$V=K("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=A4),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})}}}),MV=K("$ZodMAC",(e,t)=>{t.pattern??(t.pattern=O4(t.delimiter)),Qr.init(e,t),e._zod.bag.format="mac"}),DV=K("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=$4),Qr.init(e,t)}),NV=K("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=M4),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})}}});LV=K("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=D4),Qr.init(e,t),e._zod.bag.contentEncoding="base64",e._zod.check=r=>{zV(r.value)||r.issues.push({code:"invalid_format",format:"base64",input:r.value,inst:e,continue:!t.abort})}});FV=K("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=H$),Qr.init(e,t),e._zod.bag.contentEncoding="base64url",e._zod.check=r=>{NSe(r.value)||r.issues.push({code:"invalid_format",format:"base64url",input:r.value,inst:e,continue:!t.abort})}}),jV=K("$ZodE164",(e,t)=>{t.pattern??(t.pattern=z4),Qr.init(e,t)});UV=K("$ZodJWT",(e,t)=>{Qr.init(e,t),e._zod.check=r=>{zSe(r.value,t.alg)||r.issues.push({code:"invalid_format",format:"jwt",input:r.value,inst:e,continue:!t.abort})}}),HV=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}}),qV=K("$ZodNumberFormat",(e,t)=>{J4.init(e,t),Y$.init(e,t)}),j0=K("$ZodBoolean",(e,t)=>{At.init(e,t),e._zod.pattern=G4,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=H4,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}}),GV=K("$ZodBigIntFormat",(e,t)=>{Q4.init(e,t),X$.init(e,t)}),BV=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}}),WV=K("$ZodUndefined",(e,t)=>{At.init(e,t),e._zod.pattern=W4,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}}),VV=K("$ZodNull",(e,t)=>{At.init(e,t),e._zod.pattern=B4,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}}),KV=K("$ZodAny",(e,t)=>{At.init(e,t),e._zod.parse=r=>r}),ZV=K("$ZodUnknown",(e,t)=>{At.init(e,t),e._zod.parse=r=>r}),JV=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)}),QV=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}}),YV=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}});XV=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=>_Se(l,r,s))):_Se(c,r,s)}return i.length?Promise.all(i).then(()=>r):r}});jSe=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(()=>LSe(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?FSe(u,l,a,c,n.value,e):u.length?Promise.all(u).then(()=>a):a}}),e6=K("$ZodObjectJIT",(e,t)=>{jSe.init(e,t);let r=e._zod.parse,n=yk(()=>LSe(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
|
`});XW();import{connect as K0t}from"node:net";import{Readable as Z0t,Writable as J0t}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"},e4={cancel_request:"$/cancel_request"};uR();uR();var sve=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 ave(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=ave(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=ave(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(sve)).transform(t=>t.filter(r=>r!==sve))}var th=be([rt(),g()]).nullable(),Ar=g(),pZ=x({sessionId:Ar,path:g(),content:g(),_meta:b(P(g(),T()).nullish(),()=>{})}),fZ=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(),()=>{})}),mZ=g(),cve=be([$("read"),$("edit"),$("delete"),$("move"),$("search"),$("execute"),$("think"),$("fetch"),$("switch_mode"),$("other")]),lve=be([$("pending"),$("in_progress"),$("completed"),$("failed")]),qmt=be([$("assistant"),$("user")]),dR=x({audience:b(Ve(qmt).nullish(),()=>{}),lastModified:b(g().nullish(),()=>{}),priority:b(rt().nullish(),()=>{}),_meta:b(P(g(),T()).nullish(),()=>{})}),Gmt=x({annotations:b(dR.nullish(),()=>{}),text:g(),_meta:b(P(g(),T()).nullish(),()=>{})}),Bmt=x({annotations:b(dR.nullish(),()=>{}),data:g(),mimeType:g(),uri:b(g().nullish(),()=>{}),_meta:b(P(g(),T()).nullish(),()=>{})}),Wmt=x({annotations:b(dR.nullish(),()=>{}),data:g(),mimeType:g(),_meta:b(P(g(),T()).nullish(),()=>{})}),Vmt=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(),()=>{})}),Kmt=x({mimeType:b(g().nullish(),()=>{}),text:g(),uri:g(),_meta:b(P(g(),T()).nullish(),()=>{})}),Zmt=x({blob:g(),mimeType:b(g().nullish(),()=>{}),uri:g(),_meta:b(P(g(),T()).nullish(),()=>{})}),Jmt=be([Kmt,Zmt]),Qmt=x({annotations:b(dR.nullish(),()=>{}),resource:Jmt,_meta:b(P(g(),T()).nullish(),()=>{})}),hZ=be([Gmt.and(x({type:$("text")})),Bmt.and(x({type:$("image")})),Wmt.and(x({type:$("audio")})),Vmt.and(x({type:$("resource_link")})),Qmt.and(x({type:$("resource")}))]),Ymt=x({content:hZ,_meta:b(P(g(),T()).nullish(),()=>{})}),Xmt=x({path:g(),oldText:b(g().nullish(),()=>{}),newText:g(),_meta:b(P(g(),T()).nullish(),()=>{})}),Wk=g(),eht=x({terminalId:Wk,_meta:b(P(g(),T()).nullish(),()=>{})}),uve=be([Ymt.and(x({type:$("content")})),Xmt.and(x({type:$("diff")})),eht.and(x({type:$("terminal")}))]),dve=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(),()=>{})}),pve=x({toolCallId:mZ,kind:b(cve.nullish(),()=>{}),status:b(lve.nullish(),()=>{}),title:b(g().nullish(),()=>{}),name:b(g().nullish(),()=>{}),content:b(Ve(uve).nullish(),()=>{}),locations:b(Ve(dve).nullish(),()=>{}),rawInput:b(T().optional(),()=>{}),rawOutput:b(T().optional(),()=>{}),_meta:b(P(g(),T()).nullish(),()=>{})}),fve=g(),tht=be([$("allow_once"),$("allow_always"),$("reject_once"),$("reject_always")]),rht=x({optionId:fve,name:g(),kind:tht,_meta:b(P(g(),T()).nullish(),()=>{})}),gZ=x({sessionId:Ar,toolCall:pve,options:gt(rht),_meta:b(P(g(),T()).nullish(),()=>{})}),mve=x({name:g(),value:g(),_meta:b(P(g(),T()).nullish(),()=>{})}),yZ=x({sessionId:Ar,command:g(),args:b(Ve(g()).optional(),()=>[]),env:b(Ve(mve).optional(),()=>[]),cwd:b(g().nullish(),()=>{}),outputByteLimit:b(rt().nullish(),()=>{}),_meta:b(P(g(),T()).nullish(),()=>{})}),bZ=x({sessionId:Ar,terminalId:Wk,_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(),()=>{})}),pR=x({sessionId:Ar,toolCallId:b(mZ.nullish(),()=>{})}),fR=x({requestId:th}),nht=$("object"),oht=be([$("email"),$("uri"),$("date"),$("date-time")]),hve=x({const:g(),title:g(),description:b(g().nullish(),()=>{}),_meta:b(P(g(),T()).nullish(),()=>{})}),_Z=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:oht.nullish(),default:b(g().nullish(),()=>{}),enum:gt(g()).nullish(),oneOf:gt(hve).nullish(),_meta:b(P(g(),T()).nullish(),()=>{})}),wZ=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(),()=>{})}),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(),()=>{}),default:b(mr().nullish(),()=>{}),_meta:b(P(g(),T()).nullish(),()=>{})}),RZ=x({enum:gt(g()),_meta:b(P(g(),T()).nullish(),()=>{})}),gve=x({anyOf:gt(hve),_meta:b(P(g(),T()).nullish(),()=>{})}),iht=Mn(be([RZ.and(x({type:$("string")})),$n(x({type:g()}),"type",["string"]),gve]),"type",["string"]),TZ=x({title:b(g().nullish(),()=>{}),description:b(g().nullish(),()=>{}),minItems:rt().nullish(),maxItems:rt().nullish(),items:iht,default:b(Ve(g()).nullish(),()=>{}),_meta:b(P(g(),T()).nullish(),()=>{})}),sht=Mn(be([_Z.and(x({type:$("string")})),wZ.and(x({type:$("number")})),vZ.and(x({type:$("integer")})),EZ.and(x({type:$("boolean")})),TZ.and(x({type:$("array")})),$n(x({type:g()}),"type",["array","boolean","integer","number","string"])]),"type",["array","boolean","integer","number","string"]),aht=x({type:b(nht.optional().default("object"),()=>"object"),title:b(g().nullish(),()=>{}),properties:P(g(),sht).optional().default({}),required:gt(g()).nullish(),description:b(g().nullish(),()=>{}),_meta:b(P(g(),T()).nullish(),()=>{})}),CZ=Ho(be([pR,fR]),x({requestedSchema:aht})),yve=g(),PZ=Ho(be([pR,fR]),x({elicitationId:yve,url:_r()})),IZ=Mn(Ho(be([CZ.and(x({mode:$("form")})),PZ.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"]),bve=g(),cht=x({serverId:bve,_meta:b(P(g(),T()).nullish(),()=>{})}),mD=g(),xve=x({connectionId:mD,method:g(),params:P(g(),T()).nullish(),_meta:b(P(g(),T()).nullish(),()=>{})}),lht=x({connectionId:mD,_meta:b(P(g(),T()).nullish(),()=>{})}),Sve=T(),Vpr=x({id:th,method:g(),params:be([pZ,fZ,gZ,yZ,bZ,xZ,SZ,kZ,IZ,cht,xve,lht,Sve]).nullish()}),kve=fr().gte(0).lte(65535),uht=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(),()=>{})}),dht=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(),()=>{})}),pht=x({_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({list:b(pht.nullish(),()=>{}),delete:b(fht.nullish(),()=>{}),additionalDirectories:b(mht.nullish(),()=>{}),fork:b(hht.nullish(),()=>{}),resume:b(ght.nullish(),()=>{}),close:b(yht.nullish(),()=>{}),_meta:b(P(g(),T()).nullish(),()=>{})}),xht=x({_meta:b(P(g(),T()).nullish(),()=>{})}),Sht=x({logout:b(xht.nullish(),()=>{}),_meta:b(P(g(),T()).nullish(),()=>{})}),kht=x({_meta:b(P(g(),T()).nullish(),()=>{})}),_ht=x({_meta:b(P(g(),T()).nullish(),()=>{})}),wht=be([$("full"),$("incremental")]),vht=x({syncKind:wht,_meta:b(P(g(),T()).nullish(),()=>{})}),Eht=x({_meta:b(P(g(),T()).nullish(),()=>{})}),Rht=x({_meta:b(P(g(),T()).nullish(),()=>{})}),Tht=x({_meta:b(P(g(),T()).nullish(),()=>{})}),Cht=x({didOpen:b(_ht.nullish(),()=>{}),didChange:b(vht.nullish(),()=>{}),didClose:b(Eht.nullish(),()=>{}),didSave:b(Rht.nullish(),()=>{}),didFocus:b(Tht.nullish(),()=>{}),_meta:b(P(g(),T()).nullish(),()=>{})}),Pht=x({document:b(Cht.nullish(),()=>{}),_meta:b(P(g(),T()).nullish(),()=>{})}),Iht=x({maxCount:b(fr().gte(0).max(4294967295,{error:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),()=>{}),_meta:b(P(g(),T()).nullish(),()=>{})}),Aht=x({_meta:b(P(g(),T()).nullish(),()=>{})}),Oht=x({maxCount:b(fr().gte(0).max(4294967295,{error:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),()=>{}),_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({_meta:b(P(g(),T()).nullish(),()=>{})}),Dht=x({_meta:b(P(g(),T()).nullish(),()=>{})}),Nht=x({recentFiles:b(Iht.nullish(),()=>{}),relatedSnippets:b(Aht.nullish(),()=>{}),editHistory:b(Oht.nullish(),()=>{}),userActions:b($ht.nullish(),()=>{}),openFiles:b(Mht.nullish(),()=>{}),diagnostics:b(Dht.nullish(),()=>{}),_meta:b(P(g(),T()).nullish(),()=>{})}),zht=x({events:b(Pht.nullish(),()=>{}),context:b(Nht.nullish(),()=>{}),_meta:b(P(g(),T()).nullish(),()=>{})}),_ve=be([$("utf-16"),$("utf-32"),$("utf-8")]),Lht=x({loadSession:b(mr().optional().default(!1),()=>!1),promptCapabilities:b(uht.optional().default({image:!1,audio:!1,embeddedContext:!1}),()=>({image:!1,audio:!1,embeddedContext:!1})),mcpCapabilities:b(dht.optional().default({http:!1,sse:!1,acp:!1}),()=>({http:!1,sse:!1,acp:!1})),sessionCapabilities:b(bht.optional().default({}),()=>({})),auth:b(Sht.optional().default({}),()=>({})),providers:b(kht.nullish(),()=>{}),nes:b(zht.nullish(),()=>{}),positionEncoding:b(_ve.nullish(),()=>{}),_meta:b(P(g(),T()).nullish(),()=>{})}),hD=g(),Fht=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(),()=>{})}),jht=x({id:hD,name:g(),description:b(g().nullish(),()=>{}),vars:Kn(Ve(Fht),()=>[]),link:b(g().nullish(),()=>{}),_meta:b(P(g(),T()).nullish(),()=>{})}),Uht=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(),()=>{})}),Hht=x({id:hD,name:g(),description:b(g().nullish(),()=>{}),_meta:b(P(g(),T()).nullish(),()=>{})}),qht=be([jht.and(x({type:$("env_var")})),Uht.and(x({type:$("terminal")})),Hht]),wve=x({name:g(),title:b(g().nullish(),()=>{}),version:g(),_meta:b(P(g(),T()).nullish(),()=>{})}),Ght=x({protocolVersion:kve,agentCapabilities:b(Lht.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(qht).optional().default([]),()=>[]),agentInfo:b(wve.nullish(),()=>{}),_meta:b(P(g(),T()).nullish(),()=>{})}),Bht=x({_meta:b(P(g(),T()).nullish(),()=>{})}),AZ=g(),OZ=be([$("anthropic"),$("openai"),$("azure"),$("vertex"),$("bedrock"),g()]),Wht=x({apiType:OZ,baseUrl:g(),_meta:b(P(g(),T()).nullish(),()=>{})}),Vht=x({providerId:AZ,supported:Kn(Ve(OZ),()=>[]),required:mr(),current:Wht.nullish(),_meta:b(P(g(),T()).nullish(),()=>{})}),Kht=x({providers:gt(Vht),_meta:b(P(g(),T()).nullish(),()=>{})}),Zht=x({_meta:b(P(g(),T()).nullish(),()=>{})}),Jht=x({_meta:b(P(g(),T()).nullish(),()=>{})}),Qht=x({_meta:b(P(g(),T()).nullish(),()=>{})}),gD=g(),Yht=x({id:gD,name:g(),description:b(g().nullish(),()=>{}),_meta:b(P(g(),T()).nullish(),()=>{})}),yD=x({currentModeId:gD,availableModes:Kn(Ve(Yht),()=>[]),_meta:b(P(g(),T()).nullish(),()=>{})}),vve=g(),Xht=be([$("mode"),$("model"),$("model_config"),$("thought_level"),g()]),$Z=g(),Eve=x({value:$Z,name:g(),description:b(g().nullish(),()=>{}),_meta:b(P(g(),T()).nullish(),()=>{})}),egt=g(),tgt=x({group:egt,name:g(),options:Kn(Ve(Eve),()=>[]),_meta:b(P(g(),T()).nullish(),()=>{})}),rgt=be([gt(Eve),gt(tgt)]),ngt=x({currentValue:$Z,options:rgt}),ogt=x({currentValue:mr()}),Vk=Ho(be([ngt.and(x({type:$("select")})),ogt.and(x({type:$("boolean")}))]),x({id:vve,name:g(),description:b(g().nullish(),()=>{}),category:b(Xht.nullish(),()=>{}),_meta:b(P(g(),T()).nullish(),()=>{})})),igt=x({sessionId:Ar,modes:b(yD.nullish(),()=>{}),configOptions:b(Ve(Vk).nullish(),()=>{}),_meta:b(P(g(),T()).nullish(),()=>{})}),sgt=x({modes:b(yD.nullish(),()=>{}),configOptions:b(Ve(Vk).nullish(),()=>{}),_meta:b(P(g(),T()).nullish(),()=>{})}),agt=x({sessionId:Ar,cwd:g(),additionalDirectories:b(Ve(g()).optional(),()=>[]),title:b(g().nullish(),()=>{}),updatedAt:b(g().nullish(),()=>{}),_meta:b(P(g(),T()).nullish(),()=>{})}),cgt=x({sessions:Kn(Ve(agt),()=>[]),nextCursor:b(g().nullish(),()=>{}),_meta:b(P(g(),T()).nullish(),()=>{})}),lgt=x({_meta:b(P(g(),T()).nullish(),()=>{})}),ugt=x({sessionId:Ar,modes:b(yD.nullish(),()=>{}),configOptions:b(Ve(Vk).nullish(),()=>{}),_meta:b(P(g(),T()).nullish(),()=>{})}),dgt=x({modes:b(yD.nullish(),()=>{}),configOptions:b(Ve(Vk).nullish(),()=>{}),_meta:b(P(g(),T()).nullish(),()=>{})}),pgt=x({_meta:b(P(g(),T()).nullish(),()=>{})}),fgt=x({_meta:b(P(g(),T()).nullish(),()=>{})}),mgt=x({configOptions:Kn(Ve(Vk),()=>[]),_meta:b(P(g(),T()).nullish(),()=>{})}),hgt=be([$("end_turn"),$("max_tokens"),$("max_turn_requests"),$("refusal"),$("cancelled")]),ggt=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(),()=>{})}),ygt=x({stopReason:hgt,usage:b(ggt.nullish(),()=>{}),_meta:b(P(g(),T()).nullish(),()=>{})}),bgt=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(),()=>{})}),xgt=x({range:Zk,newText:g(),_meta:b(P(g(),T()).nullish(),()=>{})}),Sgt=x({id:Kk,uri:g(),edits:gt(xgt),cursorPosition:b(rh.nullish(),()=>{}),_meta:b(P(g(),T()).nullish(),()=>{})}),kgt=x({id:Kk,uri:g(),position:rh,_meta:b(P(g(),T()).nullish(),()=>{})}),_gt=x({id:Kk,uri:g(),position:rh,newName:g(),_meta:b(P(g(),T()).nullish(),()=>{})}),wgt=x({id:Kk,uri:g(),search:g(),replace:g(),isRegex:mr().nullish(),_meta:b(P(g(),T()).nullish(),()=>{})}),vgt=be([Sgt.and(x({kind:$("edit")})),kgt.and(x({kind:$("jump")})),_gt.and(x({kind:$("rename")})),wgt.and(x({kind:$("searchAndReplace")}))]),Egt=x({suggestions:gt(vgt),_meta:b(P(g(),T()).nullish(),()=>{})}),Rgt=x({_meta:b(P(g(),T()).nullish(),()=>{})}),Rve=T(),Tve=T(),Tgt=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"})]),Cve=x({code:Tgt,message:g(),data:b(T().optional(),()=>{})}),Kpr=be([x({id:th,result:be([Ght,Bht,Kht,Zht,Jht,Qht,igt,sgt,cgt,lgt,ugt,dgt,pgt,fgt,mgt,ygt,bgt,Egt,Rgt,Rve,Tve])}),x({id:th,error:Cve})]),Cgt=g(),uZ=x({content:hZ,messageId:b(Cgt.nullish(),()=>{}),_meta:b(P(g(),T()).nullish(),()=>{})}),Pgt=x({toolCallId:mZ,title:g(),name:b(g().nullish(),()=>{}),kind:b(cve.optional(),()=>{}),status:b(lve.optional(),()=>{}),content:b(Ve(uve).optional(),()=>[]),locations:b(Ve(dve).optional(),()=>[]),rawInput:b(T().optional(),()=>{}),rawOutput:b(T().optional(),()=>{}),_meta:b(P(g(),T()).nullish(),()=>{})}),Igt=be([$("high"),$("medium"),$("low")]),Agt=be([$("pending"),$("in_progress"),$("completed")]),Pve=x({content:g(),priority:Igt,status:Agt,_meta:b(P(g(),T()).nullish(),()=>{})}),Ogt=x({entries:Kn(Ve(Pve),()=>[]),_meta:b(P(g(),T()).nullish(),()=>{})}),bD=g(),$gt=x({planId:bD,entries:Kn(Ve(Pve),()=>[]),_meta:b(P(g(),T()).nullish(),()=>{})}),Mgt=x({planId:bD,uri:g(),_meta:b(P(g(),T()).nullish(),()=>{})}),Dgt=x({planId:bD,content:g(),_meta:b(P(g(),T()).nullish(),()=>{})}),Ngt=be([$gt.and(x({type:$("items")})),Mgt.and(x({type:$("file")})),Dgt.and(x({type:$("markdown")}))]),zgt=x({plan:Ngt,_meta:b(P(g(),T()).nullish(),()=>{})}),Lgt=x({planId:bD,_meta:b(P(g(),T()).nullish(),()=>{})}),Fgt=x({hint:g(),_meta:b(P(g(),T()).nullish(),()=>{})}),jgt=Fgt,Ugt=x({name:g(),description:g(),input:b(jgt.nullish(),()=>{}),_meta:b(P(g(),T()).nullish(),()=>{})}),Hgt=x({availableCommands:Kn(Ve(Ugt),()=>[]),_meta:b(P(g(),T()).nullish(),()=>{})}),qgt=x({currentModeId:gD,_meta:b(P(g(),T()).nullish(),()=>{})}),Ggt=x({configOptions:Kn(Ve(Vk),()=>[]),_meta:b(P(g(),T()).nullish(),()=>{})}),Bgt=x({title:b(g().nullish(),()=>{}),updatedAt:b(g().nullish(),()=>{}),_meta:b(P(g(),T()).nullish(),()=>{})}),Wgt=x({amount:rt(),currency:g(),_meta:b(P(g(),T()).nullish(),()=>{})}),Vgt=x({used:rt(),size:rt(),cost:b(Wgt.nullish(),()=>{}),_meta:b(P(g(),T()).nullish(),()=>{})}),Kgt=be([uZ.and(x({sessionUpdate:$("user_message_chunk")})),uZ.and(x({sessionUpdate:$("agent_message_chunk")})),uZ.and(x({sessionUpdate:$("agent_thought_chunk")})),Pgt.and(x({sessionUpdate:$("tool_call")})),pve.and(x({sessionUpdate:$("tool_call_update")})),Ogt.and(x({sessionUpdate:$("plan")})),zgt.and(x({sessionUpdate:$("plan_update")})),Lgt.and(x({sessionUpdate:$("plan_removed")})),Hgt.and(x({sessionUpdate:$("available_commands_update")})),qgt.and(x({sessionUpdate:$("current_mode_update")})),Ggt.and(x({sessionUpdate:$("config_option_update")})),Bgt.and(x({sessionUpdate:$("session_info_update")})),Vgt.and(x({sessionUpdate:$("usage_update")}))]),xD=x({sessionId:Ar,update:Kgt,_meta:b(P(g(),T()).nullish(),()=>{})}),MZ=x({elicitationId:yve,_meta:b(P(g(),T()).nullish(),()=>{})}),Ive=x({connectionId:mD,method:g(),params:b(P(g(),T()).nullish(),()=>{}),_meta:b(P(g(),T()).nullish(),()=>{})}),Ave=T(),Zpr=x({method:g(),params:be([xD,MZ,Ive,Ave]).nullish()}),Zgt=x({readTextFile:b(mr().optional().default(!1),()=>!1),writeTextFile:b(mr().optional().default(!1),()=>!1),_meta:b(P(g(),T()).nullish(),()=>{})}),Jgt=x({_meta:b(P(g(),T()).nullish(),()=>{})}),Qgt=x({boolean:b(Jgt.nullish(),()=>{}),_meta:b(P(g(),T()).nullish(),()=>{})}),Ygt=x({configOptions:b(Qgt.nullish(),()=>{}),_meta:b(P(g(),T()).nullish(),()=>{})}),Xgt=x({_meta:b(P(g(),T()).nullish(),()=>{})}),eyt=x({terminal:b(mr().optional().default(!1),()=>!1),_meta:b(P(g(),T()).nullish(),()=>{})}),tyt=x({_meta:b(P(g(),T()).nullish(),()=>{})}),ryt=x({_meta:b(P(g(),T()).nullish(),()=>{})}),nyt=x({form:b(tyt.nullish(),()=>{}),url:b(ryt.nullish(),()=>{}),_meta:b(P(g(),T()).nullish(),()=>{})}),oyt=x({_meta:b(P(g(),T()).nullish(),()=>{})}),iyt=x({_meta:b(P(g(),T()).nullish(),()=>{})}),syt=x({_meta:b(P(g(),T()).nullish(),()=>{})}),ayt=x({jump:b(oyt.nullish(),()=>{}),rename:b(iyt.nullish(),()=>{}),searchAndReplace:b(syt.nullish(),()=>{}),_meta:b(P(g(),T()).nullish(),()=>{})}),cyt=x({fs:b(Zgt.optional().default({readTextFile:!1,writeTextFile:!1}),()=>({readTextFile:!1,writeTextFile:!1})),terminal:b(mr().optional().default(!1),()=>!1),session:b(Ygt.nullish(),()=>{}),plan:b(Xgt.nullish(),()=>{}),auth:b(eyt.optional().default({terminal:!1}),()=>({terminal:!1})),elicitation:b(nyt.nullish(),()=>{}),nes:b(ayt.nullish(),()=>{}),positionEncodings:b(Ve(_ve).optional(),()=>[]),_meta:b(P(g(),T()).nullish(),()=>{})}),SD=x({protocolVersion:kve,clientCapabilities:b(cyt.optional().default({fs:{readTextFile:!1,writeTextFile:!1},terminal:!1,auth:{terminal:!1}}),()=>({fs:{readTextFile:!1,writeTextFile:!1},terminal:!1,auth:{terminal:!1}})),clientInfo:b(wve.nullish(),()=>{}),_meta:b(P(g(),T()).nullish(),()=>{})}),DZ=x({methodId:hD,_meta:b(P(g(),T()).nullish(),()=>{})}),NZ=x({_meta:b(P(g(),T()).nullish(),()=>{})}),zZ=x({providerId:AZ,apiType:OZ,baseUrl:g(),headers:P(g(),g()).optional(),_meta:b(P(g(),T()).nullish(),()=>{})}),LZ=x({providerId:AZ,_meta:b(P(g(),T()).nullish(),()=>{})}),FZ=x({_meta:b(P(g(),T()).nullish(),()=>{})}),Ove=x({name:g(),value:g(),_meta:b(P(g(),T()).nullish(),()=>{})}),lyt=x({name:g(),url:g(),headers:gt(Ove),_meta:b(P(g(),T()).nullish(),()=>{})}),uyt=x({name:g(),url:g(),headers:gt(Ove),_meta:b(P(g(),T()).nullish(),()=>{})}),dyt=x({name:g(),serverId:bve,_meta:b(P(g(),T()).nullish(),()=>{})}),pyt=x({name:g(),command:g(),args:gt(g()),env:gt(mve),_meta:b(P(g(),T()).nullish(),()=>{})}),kD=be([lyt.and(x({type:$("http")})),uyt.and(x({type:$("sse")})),dyt.and(x({type:$("acp")})),pyt]),jZ=x({cwd:g(),additionalDirectories:b(Ve(g()).optional(),()=>[]),mcpServers:Kn(Ve(kD),()=>[]),_meta:b(P(g(),T()).nullish(),()=>{})}),UZ=x({mcpServers:Kn(Ve(kD),()=>[]),cwd:g(),additionalDirectories:b(Ve(g()).optional(),()=>[]),sessionId:Ar,_meta:b(P(g(),T()).nullish(),()=>{})}),HZ=x({cwd:g().nullish(),cursor:g().nullish(),_meta:b(P(g(),T()).nullish(),()=>{})}),qZ=x({sessionId:Ar,_meta:b(P(g(),T()).nullish(),()=>{})}),GZ=x({sessionId:Ar,cwd:g(),additionalDirectories:b(Ve(g()).optional(),()=>[]),mcpServers:b(Ve(kD).optional(),()=>[]),_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,_meta:b(P(g(),T()).nullish(),()=>{})}),VZ=x({sessionId:Ar,modeId:gD,_meta:b(P(g(),T()).nullish(),()=>{})}),KZ=Ho(be([x({value:mr(),type:$("boolean")}),x({value:$Z})]),x({sessionId:Ar,configId:vve,_meta:b(P(g(),T()).nullish(),()=>{})})),ZZ=x({sessionId:Ar,prompt:gt(hZ),_meta:b(P(g(),T()).nullish(),()=>{})}),fyt=x({uri:g(),name:g(),_meta:b(P(g(),T()).nullish(),()=>{})}),myt=x({name:g(),owner:g(),remoteUrl:g(),_meta:b(P(g(),T()).nullish(),()=>{})}),JZ=x({workspaceUri:b(g().nullish(),()=>{}),workspaceFolders:gt(fyt).nullish(),repository:b(myt.nullish(),()=>{}),_meta:b(P(g(),T()).nullish(),()=>{})}),hyt=be([$("automatic"),$("diagnostic"),$("manual")]),gyt=x({uri:g(),languageId:g(),text:g(),_meta:b(P(g(),T()).nullish(),()=>{})}),yyt=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(),()=>{})}),byt=x({uri:g(),excerpts:gt(yyt),_meta:b(P(g(),T()).nullish(),()=>{})}),xyt=x({uri:g(),diff:g(),_meta:b(P(g(),T()).nullish(),()=>{})}),Syt=x({action:g(),uri:g(),position:rh,timestampMs:rt(),_meta:b(P(g(),T()).nullish(),()=>{})}),kyt=x({uri:g(),languageId:g(),visibleRange:b(Zk.nullish(),()=>{}),lastFocusedMs:b(rt().nullish(),()=>{}),_meta:b(P(g(),T()).nullish(),()=>{})}),_yt=be([$("error"),$("warning"),$("information"),$("hint")]),wyt=x({uri:g(),range:Zk,severity:_yt,message:g(),_meta:b(P(g(),T()).nullish(),()=>{})}),vyt=x({recentFiles:gt(gyt).nullish(),relatedSnippets:gt(byt).nullish(),editHistory:gt(xyt).nullish(),userActions:gt(Syt).nullish(),openFiles:gt(kyt).nullish(),diagnostics:gt(wyt).nullish(),_meta:b(P(g(),T()).nullish(),()=>{})}),QZ=x({sessionId:Ar,uri:g(),version:rt(),position:rh,selection:Zk.nullish(),triggerKind:hyt,context:vyt.nullish(),_meta:b(P(g(),T()).nullish(),()=>{})}),YZ=x({sessionId:Ar,_meta:b(P(g(),T()).nullish(),()=>{})}),Jpr=x({id:th,method:g(),params:be([SD,DZ,NZ,zZ,LZ,FZ,jZ,UZ,HZ,qZ,GZ,BZ,WZ,VZ,KZ,ZZ,JZ,QZ,YZ,xve,Sve]).nullish()}),Eyt=x({_meta:b(P(g(),T()).nullish(),()=>{})}),Ryt=x({content:g(),_meta:b(P(g(),T()).nullish(),()=>{})}),Tyt=x({optionId:fve,_meta:b(P(g(),T()).nullish(),()=>{})}),Cyt=be([x({outcome:$("cancelled")}),Tyt.and(x({outcome:$("selected")}))]),Pyt=x({outcome:Cyt,_meta:b(P(g(),T()).nullish(),()=>{})}),Iyt=x({terminalId:Wk,_meta:b(P(g(),T()).nullish(),()=>{})}),Ayt=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(),()=>{})}),Oyt=x({output:g(),truncated:mr(),exitStatus:b(Ayt.nullish(),()=>{}),_meta:b(P(g(),T()).nullish(),()=>{})}),$yt=x({_meta:b(P(g(),T()).nullish(),()=>{})}),Myt=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(),()=>{})}),Dyt=x({_meta:b(P(g(),T()).nullish(),()=>{})}),Nyt=be([g(),rt(),rt(),mr(),gt(g())]),XZ=x({content:P(g(),Nyt).nullish()}),zyt=Mn(Ho(be([XZ.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"]),Lyt=x({connectionId:mD,_meta:b(P(g(),T()).nullish(),()=>{})}),Fyt=x({_meta:b(P(g(),T()).nullish(),()=>{})}),Qpr=be([x({id:th,result:be([Eyt,Ryt,Pyt,Iyt,Oyt,$yt,Myt,Dyt,zyt,Lyt,Fyt,Tve,Rve])}),x({id:th,error:Cve})]),e9=x({sessionId:Ar,_meta:b(P(g(),T()).nullish(),()=>{})}),t9=x({sessionId:Ar,uri:g(),languageId:g(),version:rt(),text:g(),_meta:b(P(g(),T()).nullish(),()=>{})}),jyt=x({range:Zk.nullish(),text:g(),_meta:b(P(g(),T()).nullish(),()=>{})}),r9=x({sessionId:Ar,uri:g(),version:rt(),contentChanges:Kn(Ve(jyt),()=>[]),_meta:b(P(g(),T()).nullish(),()=>{})}),n9=x({sessionId:Ar,uri:g(),_meta:b(P(g(),T()).nullish(),()=>{})}),o9=x({sessionId:Ar,uri:g(),_meta:b(P(g(),T()).nullish(),()=>{})}),i9=x({sessionId:Ar,uri:g(),version:rt(),position:rh,visibleRange:Zk,_meta:b(P(g(),T()).nullish(),()=>{})}),s9=x({sessionId:Ar,id:Kk,_meta:b(P(g(),T()).nullish(),()=>{})}),Uyt=be([$("rejected"),$("ignored"),$("replaced"),$("cancelled")]),a9=x({sessionId:Ar,id:Kk,reason:b(Uyt.nullish(),()=>{}),_meta:b(P(g(),T()).nullish(),()=>{})}),Ypr=x({method:g(),params:be([e9,t9,r9,n9,o9,i9,s9,a9,Ive,Ave]).nullish()}),Xpr=x({requestId:th,_meta:b(P(g(),T()).nullish(),()=>{})});var Mve="$/cancel_request";function _D(e){return p9(e)&&"id"in e&&typeof e.method=="string"&&f9(e.id)}function d9(e){if(!p9(e)||"method"in e||!("id"in e)||!f9(e.id))return!1;let t=Object.hasOwn(e,"result"),r=Object.hasOwn(e,"error");return t===r?!1:!r||qyt(e.error)}function Jk(e){return p9(e)&&!("id"in e)&&typeof e.method=="string"}function Mp(e){return typeof e=="object"&&e!==null}function p9(e){return Mp(e)&&e.jsonrpc==="2.0"}function f9(e){return e===null||typeof e=="string"||typeof e=="number"&&Number.isFinite(e)}function Dve(e){return Mp(e)&&!("method"in e)&&("id"in e||"result"in e||"error"in e)}function Nve(e){let t=!1,r=!1,n=!1,o=!1;for(let i of e)t||=_D(i)||Jk(i),r||=d9(i),Mp(i)&&(n||="method"in i,o||="result"in i||"error"in i);return t?!1:r?!0:o&&!n}function Hyt(e){if(!(!Mp(e)||!f9(e.requestId)))return e.requestId}function qyt(e){return Mp(e)&&typeof e.code=="number"&&Number.isInteger(e.code)&&typeof e.message=="string"}var Mc={yes(){return{handled:!0}},no(e,t=!1){return{handled:!1,message:e,retry:t}}};function Qy(e){let t=Promise.reject(e);return t.catch(()=>{}),t}function Gyt(e){if(e instanceof Error||typeof e=="object"&&e!=null&&"message"in e&&typeof e.message=="string")return e.message}function Byt(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 zve(e){if(e instanceof Xr)return e.toResult();if(Byt(e))return Xr.invalidParams(e.format()).toResult();let t=Gyt(e);try{return Xr.internalError(t?JSON.parse(t):{}).toResult()}catch{return Xr.internalError({details:t}).toResult()}}function Wyt(e){return e instanceof Xr&&e.code===-32800?e:Xr.requestCancelled(e)}function Vyt(e,t){let r=Kyt(e,t);return r?r.toResult():zve(e)}function Kyt(e,t){if(!(!t.aborted||!Zyt(e)))return Wyt(t.reason)}function Zyt(e){if(typeof e!="object"||e===null)return!1;let t=e;return t.name==="AbortError"||t.code==="ABORT_ERR"}var c9=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?.()}))}},Dp=class{disposeHandler;active=!0;constructor(t){this.disposeHandler=t}dispose(){this.active&&(this.active=!1,this.disposeHandler())}[Symbol.dispose](){this.dispose()}runIndefinitely(){return this}},l9=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}},Np=class{pendingResponses=new Map;incomingRequests=new Map;nextRequestId=0;staticHandlers=[];dynamicHandlers=new Set;stream;writeQueue=Promise.resolve();abortController=new AbortController;closedPromise;retryQueue=[];context=new l9(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 u9}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 Dp(()=>{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(Mve,{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 Mc.yes()}}}async receive(){let t;try{let r=this.stream.readable.getReader();this.receiveReader=r;try{for(;!this.abortController.signal.aborted;){let{value:n,done:o}=await r.read();if(this.abortController.signal.aborted||o)break;n&&this.receiveWireMessage(n)}}finally{this.receiveReader===r&&(this.receiveReader=void 0),r.releaseLock()}}catch(r){t=r}finally{this.close(t)}}receiveWireMessage(t){if(Array.isArray(t)){if(!this.allowBatches){this.close(new TypeError("JSON-RPC batches are not supported on this connection"));return}this.receiveBatch(t);return}if(!Mp(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=Nve(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){Dve(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():Mp(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(Vyt(o,r.responder.signal));else{let i=zve(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 c9(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?.(),!d9(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!==Mve)return;let r=Hyt(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)}},u9=class{handlers=[];connectionName;name(t){return this.connectionName=t,this}withHandler(t){return this.handlers.push(t),this}onReceiveMessage(t){return this.withHandler({handleMessage:async(r,n)=>await t(r,n)??Mc.no(r),describe:()=>this.connectionName??"onReceiveMessage"})}onReceiveRequest(t,r,n){return this.withHandler({handleMessage:async(o,i)=>{if(o.kind!=="request"||o.method!==t)return Mc.no(o);let s=r(o.params);return await n(s,o.responder,i)??Mc.yes()},describe:()=>`${this.connectionName??"request"}:${t}`})}onReceiveNotification(t,r,n){return this.withHandler({handleMessage:async(o,i)=>{if(o.kind!=="notification"||o.method!==t)return Mc.no(o);let s=r(o.params);return await n(s,i)??Mc.yes()},describe:()=>`${this.connectionName??"notification"}:${t}`})}connect(t,r){return new Np(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 m9(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);Mp(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 ifr=CZ.and(x({mode:$("form")})).and(x({message:g()})),sfr=PZ.and(x({mode:$("url")})).and(x({message:g()})),afr=be([pR,fR]).and(x({message:g()})),cfr=_Z.and(x({type:$("string")})),lfr=wZ.and(x({type:$("number")})),ufr=vZ.and(x({type:$("integer")})),dfr=EZ.and(x({type:$("boolean")})),pfr=TZ.and(x({type:$("array")})),ffr=RZ.and(x({type:$("string")}));var mfr=XZ.and(x({action:$("accept")})),hfr=x({action:$("decline")}),gfr=x({action:$("cancel")});function k9(e,t){return m9(e,t)}function Dc(e){return e??{}}function Uve(e){return typeof e=="object"&&e!==null&&"readable"in e&&"writable"in e}function Hve(){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:e4.cancel_request}},qve=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=Jve[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)}[qve](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 y9,n=this.connectionContext.signal,o=()=>{r.fail(n.reason??new Error("ACP connection closed"))};n.aborted?o():n.addEventListener("abort",o);let i=Qve(this.connectionContext).attach(t,r),s=new Dp(()=>{n.removeEventListener("abort",o)});return b9.create(this,t,r,[i,s])}request(t,r,n){let o=Zve[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)}},h9=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))}},g9=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 Gve(e,t=[]){return new h9(e,t)}function Bve(e,t=[]){return new g9(e,t)}var y9=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 Lve(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=Lve(r)}static create(t,r){return new e(t,r)}toRequest(){return Lve(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[qve](this.toRequest(),t)}async withSession(t){let r=await this.start();try{return await t(r)}finally{r.dispose()}}},b9=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 Wve(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 Vve(e,t,r,n){e.onReceiveRequest(t.method,o=>Wve(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 Kve(e,t,r,n){e.onReceiveNotification(t.method,o=>Wve(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 Jyt={initialize:en(Me.initialize,SD),newSession:en(Me.session_new,jZ),loadSession:en(Me.session_load,UZ,Dc),unstable_forkSession:en(Me.session_fork,GZ),listSessions:en(Me.session_list,HZ),deleteSession:en(Me.session_delete,qZ,Dc),resumeSession:en(Me.session_resume,BZ),closeSession:en(Me.session_close,WZ,Dc),setSessionMode:en(Me.session_set_mode,VZ,Dc),setSessionConfigOption:en(Me.session_set_config_option,KZ),authenticate:en(Me.authenticate,DZ,Dc),unstable_listProviders:en(Me.providers_list,NZ),unstable_setProvider:en(Me.providers_set,zZ,Dc),unstable_disableProvider:en(Me.providers_disable,LZ,Dc),logout:en(Me.logout,FZ,Dc),prompt:en(Me.session_prompt,ZZ),unstable_startNes:en(Me.nes_start,JZ),unstable_suggestNes:en(Me.nes_suggest,QZ),unstable_closeNes:en(Me.nes_close,YZ,Dc)},Qyt={cancel:Xu(Me.session_cancel,e9),unstable_didOpenDocument:Xu(Me.document_did_open,t9),unstable_didChangeDocument:Xu(Me.document_did_change,r9),unstable_didCloseDocument:Xu(Me.document_did_close,n9),unstable_didSaveDocument:Xu(Me.document_did_save,o9),unstable_didFocusDocument:Xu(Me.document_did_focus,i9),unstable_acceptNes:Xu(Me.nes_accept,s9),unstable_rejectNes:Xu(Me.nes_reject,a9)},Yyt={requestPermission:en(ir.session_request_permission,gZ),writeTextFile:en(ir.fs_write_text_file,pZ,Dc),readTextFile:en(ir.fs_read_text_file,fZ),createTerminal:en(ir.terminal_create,yZ),terminalOutput:en(ir.terminal_output,bZ),releaseTerminal:en(ir.terminal_release,xZ,Dc),waitForTerminalExit:en(ir.terminal_wait_for_exit,SZ),killTerminal:en(ir.terminal_kill,kZ,Dc),unstable_createElicitation:en(ir.elicitation_create,IZ)},Xyt={sessionUpdate:Xu(ir.session_update,xD),unstable_completeElicitation:Xu(ir.elicitation_complete,MZ)},Zve=AD(Jyt),ebt=AD(Qyt),Jve=AD(Yyt),tbt=AD(Xyt);function rbt(e,t,r,n){return{params:e,requestId:n,signal:r,client:t}}function nbt(e,t,r){return{params:e,signal:r,client:t}}function obt(e,t,r,n){return{params:e,requestId:n,signal:r,agent:t}}function ibt(e,t,r){return{params:e,signal:r,agent:t}}var x9=class{activeSessions=new Map;handleMessage(t){if(t.kind!=="notification"||t.method!==ir.session_update)return Mc.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 Mc.no(t)}attach(t,r){let n=this.activeSessions.get(t.sessionId)??new Set;return n.add(r),this.activeSessions.set(t.sessionId,n),new Dp(()=>{n.delete(r),n.size===0&&this.activeSessions.delete(t.sessionId)})}},Fve=new WeakMap;function Qve(e){let t=Fve.get(e);return t||(t=new x9,Fve.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 jve=class{builder=Np.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=Zve[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=ebt[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 Vve(this.builder,t,(n,o,i,s)=>rbt(n,mR.create(o,s),i,s),r),this}notification(t,r){return Kve(this.builder,t,(n,o,i)=>nbt(n,mR.create(o),i),r),this}connectConnection(t,r={}){if(Uve(t)){let c=this.openStreamConnection(t);return r.deferConnectHandlers||this[vD](c.connection),c}let[n,o]=Hve(),i=t[PD]().connect(o,ID),s=Bve(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:Gve(r,this.connectHandlers)}}};function Yve(e){return new S9(e)}var S9=class{builder=Np.builder();connectHandlers=[];constructor(t={}){t.name&&this.builder.name(t.name),this.builder.withHandler({handleMessage:(r,n)=>Qve(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=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 Vve(this.builder,t,(n,o,i,s)=>obt(n,hR.create(o,s),i,s),r),this}notification(t,r){return Kve(this.builder,t,(n,o,i)=>ibt(n,hR.create(o),i),r),this}connectConnection(t){if(Uve(t)){let a=this.openStreamConnection(t);return this[ED](a.connection),a}let[r,n]=Hve(),o=t[PD]().connect(n,ID),i=Gve(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:Bve(r,this.connectHandlers)}}},Efr=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]),Rfr=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]),Tfr=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]),Cfr=new Set([ir.session_update,ir.elicitation_complete]);j8();O8();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"},j1={cancel_request:"$/cancel_request"},Gp=2;var dh=be([rt(),g()]).nullable(),dn=g(),U1=g(),zwt=be([$("read"),$("edit"),$("delete"),$("move"),$("search"),$("execute"),$("think"),$("fetch"),$("switch_mode"),$("other"),g()]),Lwt=be([$("pending"),$("in_progress"),$("completed"),$("failed"),$("cancelled"),g()]),Fwt=be([$("assistant"),$("user"),g()]),KR=x({audience:b(Ve(Fwt).nullish(),()=>{}),lastModified:b(Qu.datetime({offset:!0}).nullish(),()=>{}),priority:b(rt().gte(0).lte(1).nullish(),()=>{}),_meta:b(P(g(),T()).nullish(),()=>{})}),U8=x({text:g(),annotations:b(KR.nullish(),()=>{}),_meta:b(P(g(),T()).nullish(),()=>{})}),ub=g(),H8=x({data:g(),mimeType:ub,uri:b(_r().nullish(),()=>{}),annotations:b(KR.nullish(),()=>{}),_meta:b(P(g(),T()).nullish(),()=>{})}),q8=x({data:g(),mimeType:ub,annotations:b(KR.nullish(),()=>{}),_meta:b(P(g(),T()).nullish(),()=>{})}),jwt=be([$("light"),$("dark"),g()]),Uwt=x({src:_r(),mimeType:b(ub.nullish(),()=>{}),sizes:b(Ve(g()).nullish(),()=>{}),theme:b(jwt.nullish(),()=>{})}),G8=x({name:g(),uri:_r(),title:b(g().nullish(),()=>{}),description:b(g().nullish(),()=>{}),icons:b(Ve(Uwt).nullish(),()=>{}),mimeType:b(ub.nullish(),()=>{}),size:b(rt().nullish(),()=>{}),annotations:b(KR.nullish(),()=>{}),_meta:b(P(g(),T()).nullish(),()=>{})}),Hwt=x({text:g(),uri:_r(),mimeType:b(ub.nullish(),()=>{}),_meta:b(P(g(),T()).nullish(),()=>{})}),qwt=x({blob:g(),uri:_r(),mimeType:b(ub.nullish(),()=>{}),_meta:b(P(g(),T()).nullish(),()=>{})}),Gwt=be([Hwt,qwt]),B8=x({resource:Gwt,annotations:b(KR.nullish(),()=>{}),_meta:b(P(g(),T()).nullish(),()=>{})}),S_=Mn(be([U8.and(x({type:$("text")})),H8.and(x({type:$("image")})),q8.and(x({type:$("audio")})),G8.and(x({type:$("resource_link")})),B8.and(x({type:$("resource")})),$n(x({type:g()}),"type",["audio","image","resource","resource_link","text"])]),"type",["audio","image","resource","resource_link","text"]),W8=x({content:S_,_meta:b(P(g(),T()).nullish(),()=>{})}),Bwt=be([$("text"),$("binary"),$("directory"),$("symlink"),g()]),ss=g(),cb=x({path:ss}),VR=x({oldPath:ss,path:ss}),Wwt=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(Bwt.nullish(),()=>{}),mimeType:b(ub.nullish(),()=>{}),_meta:b(P(g(),T()).nullish(),()=>{})})),"operation",["add","copy","delete","modify","move"]),Vwt=be([$("git_patch"),g()]),Kwt=x({format:Vwt,text:g()}),V8=x({changes:Ve(Wwt),patch:b(Kwt.nullish(),()=>{}),_meta:b(P(g(),T()).nullish(),()=>{})}),H1=g(),K8=x({terminalId:H1,_meta:b(P(g(),T()).nullish(),()=>{})}),LCe=Mn(be([W8.and(x({type:$("content")})),V8.and(x({type:$("diff")})),K8.and(x({type:$("terminal")})),$n(x({type:g()}),"type",["content","diff","terminal"])]),"type",["content","diff","terminal"]),Zwt=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(),()=>{})}),q1=x({toolCallId:U1,name:b(g().nullish(),()=>{}),title:b(g().nullish(),()=>{}),kind:b(zwt.nullish(),()=>{}),status:b(Lwt.nullish(),()=>{}),content:b(Ve(LCe).nullish(),()=>{}),locations:b(Ve(Zwt).nullish(),()=>{}),rawInput:b(T().optional(),()=>{}),rawOutput:b(T().optional(),()=>{}),_meta:b(P(g(),T()).nullish(),()=>{})}),Z8=x({toolCall:q1}),J8=x({command:g(),cwd:ss,toolCallId:b(U1.nullish(),()=>{}),terminalId:b(H1.nullish(),()=>{}),_meta:b(P(g(),T()).nullish(),()=>{})}),Jwt=Mn(be([Z8.and(x({type:$("tool_call")})),J8.and(x({type:$("command")})),$n(x({type:g()}),"type",["command","tool_call"])]),"type",["command","tool_call"]),FCe=g(),Qwt=be([$("allow_once"),$("allow_always"),$("reject_once"),$("reject_always"),g()]),Ywt=x({optionId:FCe,name:g(),kind:Qwt,_meta:b(P(g(),T()).nullish(),()=>{})}),Q8=x({sessionId:dn,title:g(),description:b(g().nullish(),()=>{}),subject:Jwt.nullish(),options:gt(Ywt).min(1),_meta:b(P(g(),T()).nullish(),()=>{})}),ZR=x({sessionId:dn,toolCallId:b(U1.nullish(),()=>{})}),JR=x({requestId:dh}),Xwt=$("object"),evt=be([$("email"),$("uri"),$("date"),$("date-time"),g()]),jCe=x({const:g(),title:g(),description:b(g().nullish(),()=>{}),_meta:b(P(g(),T()).nullish(),()=>{})}),Y8=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:evt.nullish(),default:b(g().nullish(),()=>{}),enum:gt(g()).min(1).nullish(),oneOf:gt(jCe).min(1).nullish(),_meta:b(P(g(),T()).nullish(),()=>{})}),X8=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(),()=>{})}),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(),()=>{}),default:b(mr().nullish(),()=>{}),_meta:b(P(g(),T()).nullish(),()=>{})}),r5=x({enum:gt(g()).min(1),_meta:b(P(g(),T()).nullish(),()=>{})}),UCe=x({anyOf:gt(jCe).min(1),_meta:b(P(g(),T()).nullish(),()=>{})}),tvt=Mn(be([r5.and(x({type:$("string")})),$n(x({type:g()}),"type",["string"]),UCe]),"type",["string"]),n5=x({title:b(g().nullish(),()=>{}),description:b(g().nullish(),()=>{}),minItems:rt().nullish(),maxItems:rt().nullish(),items:tvt,default:b(Ve(g()).nullish(),()=>{}),_meta:b(P(g(),T()).nullish(),()=>{})}),rvt=Mn(be([Y8.and(x({type:$("string")})),X8.and(x({type:$("number")})),e5.and(x({type:$("integer")})),t5.and(x({type:$("boolean")})),n5.and(x({type:$("array")})),$n(x({type:g()}),"type",["array","boolean","integer","number","string"])]),"type",["array","boolean","integer","number","string"]),nvt=x({type:b(Xwt.optional().default("object"),()=>"object"),title:b(g().nullish(),()=>{}),properties:P(g(),rvt).optional().default({}),required:gt(g()).nullish(),description:b(g().nullish(),()=>{}),_meta:b(P(g(),T()).nullish(),()=>{})}),o5=Ho(be([ZR,JR]),x({requestedSchema:nvt})),HCe=g(),i5=Ho(be([ZR,JR]),x({elicitationId:HCe,url:_r()})),s5=Mn(Ho(be([o5.and(x({mode:$("form")})),i5.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"]),qCe=g(),a5=x({serverId:qCe,_meta:b(P(g(),T()).nullish(),()=>{})}),G1=g(),QR=x({connectionId:G1,method:g(),params:P(g(),T()).nullish(),_meta:b(P(g(),T()).nullish(),()=>{})}),c5=x({connectionId:G1,_meta:b(P(g(),T()).nullish(),()=>{})}),GCe=T(),qwr=x({id:dh,method:g(),params:be([Q8,s5,a5,QR,c5,GCe]).nullish()}),BCe=fr().gte(0).lte(65535),WCe=x({name:g(),title:b(g().nullish(),()=>{}),version:g(),_meta:b(P(g(),T()).nullish(),()=>{})}),ovt=x({_meta:b(P(g(),T()).nullish(),()=>{})}),ivt=x({_meta:b(P(g(),T()).nullish(),()=>{})}),svt=x({_meta:b(P(g(),T()).nullish(),()=>{})}),avt=x({image:b(ovt.nullish(),()=>{}),audio:b(ivt.nullish(),()=>{}),embeddedContext:b(svt.nullish(),()=>{}),_meta:b(P(g(),T()).nullish(),()=>{})}),cvt=x({_meta:b(P(g(),T()).nullish(),()=>{})}),lvt=x({_meta:b(P(g(),T()).nullish(),()=>{})}),uvt=x({_meta:b(P(g(),T()).nullish(),()=>{})}),dvt=x({stdio:b(cvt.nullish(),()=>{}),http:b(lvt.nullish(),()=>{}),acp:b(uvt.nullish(),()=>{}),_meta:b(P(g(),T()).nullish(),()=>{})}),pvt=x({_meta:b(P(g(),T()).nullish(),()=>{})}),fvt=x({_meta:b(P(g(),T()).nullish(),()=>{})}),mvt=x({_meta:b(P(g(),T()).nullish(),()=>{})}),hvt=x({prompt:b(avt.nullish(),()=>{}),mcp:b(dvt.nullish(),()=>{}),delete:b(pvt.nullish(),()=>{}),additionalDirectories:b(fvt.nullish(),()=>{}),fork:b(mvt.nullish(),()=>{}),_meta:b(P(g(),T()).nullish(),()=>{})}),gvt=x({_meta:b(P(g(),T()).nullish(),()=>{})}),yvt=x({_meta:b(P(g(),T()).nullish(),()=>{})}),bvt=x({_meta:b(P(g(),T()).nullish(),()=>{})}),xvt=be([$("full"),$("incremental")]),Svt=x({syncKind:xvt,_meta:b(P(g(),T()).nullish(),()=>{})}),kvt=x({_meta:b(P(g(),T()).nullish(),()=>{})}),_vt=x({_meta:b(P(g(),T()).nullish(),()=>{})}),wvt=x({_meta:b(P(g(),T()).nullish(),()=>{})}),vvt=x({didOpen:b(bvt.nullish(),()=>{}),didChange:b(Svt.nullish(),()=>{}),didClose:b(kvt.nullish(),()=>{}),didSave:b(_vt.nullish(),()=>{}),didFocus:b(wvt.nullish(),()=>{}),_meta:b(P(g(),T()).nullish(),()=>{})}),Evt=x({document:b(vvt.nullish(),()=>{}),_meta:b(P(g(),T()).nullish(),()=>{})}),Rvt=x({maxCount:b(fr().gte(0).max(4294967295,{error:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),()=>{}),_meta:b(P(g(),T()).nullish(),()=>{})}),Tvt=x({_meta:b(P(g(),T()).nullish(),()=>{})}),Cvt=x({maxCount:b(fr().gte(0).max(4294967295,{error:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),()=>{}),_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({_meta:b(P(g(),T()).nullish(),()=>{})}),Avt=x({_meta:b(P(g(),T()).nullish(),()=>{})}),Ovt=x({recentFiles:b(Rvt.nullish(),()=>{}),relatedSnippets:b(Tvt.nullish(),()=>{}),editHistory:b(Cvt.nullish(),()=>{}),userActions:b(Pvt.nullish(),()=>{}),openFiles:b(Ivt.nullish(),()=>{}),diagnostics:b(Avt.nullish(),()=>{}),_meta:b(P(g(),T()).nullish(),()=>{})}),$vt=x({events:b(Evt.nullish(),()=>{}),context:b(Ovt.nullish(),()=>{}),_meta:b(P(g(),T()).nullish(),()=>{})}),VCe=be([$("utf-16"),$("utf-32"),$("utf-8")]),Mvt=x({session:b(hvt.nullish(),()=>{}),auth:b(gvt.nullish(),()=>{}),providers:b(yvt.nullish(),()=>{}),nes:b($vt.nullish(),()=>{}),positionEncoding:b(VCe.nullish(),()=>{}),_meta:b(P(g(),T()).nullish(),()=>{})}),db=g(),Dvt=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(),()=>{})}),l5=x({methodId:db,name:g(),description:b(g().nullish(),()=>{}),vars:Kn(Ve(Dvt),()=>[]),link:b(_r().nullish(),()=>{}),_meta:b(P(g(),T()).nullish(),()=>{})}),KCe=x({name:g(),value:g(),_meta:b(P(g(),T()).nullish(),()=>{})}),u5=x({methodId:db,name:g(),description:b(g().nullish(),()=>{}),args:b(Ve(g()).optional(),()=>[]),env:b(Ve(KCe).optional(),()=>[]),_meta:b(P(g(),T()).nullish(),()=>{})}),d5=x({methodId:db,name:g(),description:b(g().nullish(),()=>{}),_meta:b(P(g(),T()).nullish(),()=>{})}),Nvt=Mn(be([l5.and(x({type:$("env_var")})),u5.and(x({type:$("terminal")})),d5.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"]),p5=x({protocolVersion:BCe,info:WCe,capabilities:b(Mvt.optional().default({}),()=>({})),authMethods:b(Ve(Nvt).optional(),()=>[]),_meta:b(P(g(),T()).nullish(),()=>{})}),zvt=x({_meta:b(P(g(),T()).nullish(),()=>{})}),f5=g(),m5=be([$("anthropic"),$("openai"),$("azure"),$("vertex"),$("bedrock"),g()]),Lvt=x({apiType:m5,baseUrl:_r(),_meta:b(P(g(),T()).nullish(),()=>{})}),Fvt=x({providerId:f5,supported:Kn(Ve(m5),()=>[]),required:mr(),current:Lvt.nullish(),_meta:b(P(g(),T()).nullish(),()=>{})}),jvt=x({providers:gt(Fvt),_meta:b(P(g(),T()).nullish(),()=>{})}),Uvt=x({_meta:b(P(g(),T()).nullish(),()=>{})}),Hvt=x({_meta:b(P(g(),T()).nullish(),()=>{})}),qvt=x({_meta:b(P(g(),T()).nullish(),()=>{})}),Bp=g(),Gvt=be([$("mode"),$("model"),$("model_config"),$("thought_level"),g()]),YR=g(),ZCe=x({value:YR,name:g(),description:b(g().nullish(),()=>{}),_meta:b(P(g(),T()).nullish(),()=>{})}),Bvt=g(),Wvt=x({groupId:Bvt,name:g(),options:Kn(Ve(ZCe),()=>[]),_meta:b(P(g(),T()).nullish(),()=>{})}),Vvt=be([gt(ZCe),gt(Wvt)]),h5=x({currentValue:YR,options:Vvt}),g5=x({currentValue:mr()}),XR=Mn(Ho(be([h5.and(x({type:$("select")})),g5.and(x({type:$("boolean")})),$n(x({type:g()}),"type",["boolean","select"])]),x({configId:Bp,name:g(),description:b(g().nullish(),()=>{}),category:b(Gvt.nullish(),()=>{}),_meta:b(P(g(),T()).nullish(),()=>{})})),"type",["boolean","select"]),Kvt=x({sessionId:dn,configOptions:b(Ve(XR).optional(),()=>[]),_meta:b(P(g(),T()).nullish(),()=>{})}),Zvt=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(),()=>{})}),JCe=g(),Jvt=x({sessions:Kn(Ve(Zvt),()=>[]),nextCursor:b(JCe.nullish(),()=>{}),_meta:b(P(g(),T()).nullish(),()=>{})}),Qvt=x({_meta:b(P(g(),T()).nullish(),()=>{})}),Yvt=x({sessionId:dn,configOptions:b(Ve(XR).optional(),()=>[]),_meta:b(P(g(),T()).nullish(),()=>{})}),Xvt=x({configOptions:b(Ve(XR).optional(),()=>[]),_meta:b(P(g(),T()).nullish(),()=>{})}),eEt=x({_meta:b(P(g(),T()).nullish(),()=>{})}),tEt=x({configOptions:Kn(Ve(XR),()=>[]),_meta:b(P(g(),T()).nullish(),()=>{})}),rEt=x({_meta:b(P(g(),T()).nullish(),()=>{})}),nEt=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(),()=>{})}),oEt=x({range:k_,newText:g(),_meta:b(P(g(),T()).nullish(),()=>{})}),y5=x({suggestionId:Wp,uri:_r(),edits:gt(oEt).min(1),cursorPosition:b(ph.nullish(),()=>{}),_meta:b(P(g(),T()).nullish(),()=>{})}),b5=x({suggestionId:Wp,uri:_r(),position:ph,_meta:b(P(g(),T()).nullish(),()=>{})}),x5=x({suggestionId:Wp,uri:_r(),position:ph,newName:g(),_meta:b(P(g(),T()).nullish(),()=>{})}),S5=x({suggestionId:Wp,uri:_r(),search:g(),replace:g(),isRegex:mr().nullish(),_meta:b(P(g(),T()).nullish(),()=>{})}),iEt=Mn(be([y5.and(x({kind:$("edit")})),b5.and(x({kind:$("jump")})),x5.and(x({kind:$("rename")})),S5.and(x({kind:$("searchAndReplace")})),$n(x({kind:g(),suggestionId:Wp}),"kind",["edit","jump","rename","searchAndReplace"])]),"kind",["edit","jump","rename","searchAndReplace"]),sEt=x({suggestions:gt(iEt),_meta:b(P(g(),T()).nullish(),()=>{})}),aEt=x({_meta:b(P(g(),T()).nullish(),()=>{})}),QCe=T(),YCe=T(),cEt=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"})]),XCe=x({code:cEt,message:g(),data:b(T().optional(),()=>{})}),Gwr=be([x({id:dh,result:be([p5,zvt,jvt,Uvt,Hvt,qvt,Kvt,Jvt,Qvt,Yvt,Xvt,eEt,tEt,rEt,nEt,sEt,aEt,QCe,YCe])}),x({id:dh,error:XCe})]),B1=g(),lb=x({messageId:B1,content:S_,_meta:b(P(g(),T()).nullish(),()=>{})}),k5=x({messageId:B1,content:b(Ve(S_).nullish(),()=>{}),_meta:b(P(g(),T()).nullish(),()=>{})}),_5=x({messageId:B1,content:b(Ve(S_).nullish(),()=>{}),_meta:b(P(g(),T()).nullish(),()=>{})}),w5=x({messageId:B1,content:b(Ve(S_).nullish(),()=>{}),_meta:b(P(g(),T()).nullish(),()=>{})}),v5=x({_meta:b(P(g(),T()).nullish(),()=>{})}),lEt=be([$("end_turn"),$("max_tokens"),$("max_turn_requests"),$("refusal"),$("cancelled"),g()]),uEt=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(),()=>{})}),E5=x({stopReason:b(lEt.nullish(),()=>{}),usage:b(uEt.nullish(),()=>{}),_meta:b(P(g(),T()).nullish(),()=>{})}),R5=x({_meta:b(P(g(),T()).nullish(),()=>{})}),T5=Mn(be([v5.and(x({state:$("running")})),E5.and(x({state:$("idle")})),R5.and(x({state:$("requires_action")})),$n(x({state:g()}),"state",["idle","requires_action","running"])]),"state",["idle","requires_action","running"]),C5=x({toolCallId:U1,content:LCe,_meta:b(P(g(),T()).nullish(),()=>{})}),dEt=x({data:g(),_meta:b(P(g(),T()).nullish(),()=>{})}),pEt=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(),()=>{})}),P5=x({terminalId:H1,command:b(g().nullish(),()=>{}),cwd:b(ss.nullish(),()=>{}),output:b(dEt.nullish(),()=>{}),exitStatus:b(pEt.nullish(),()=>{}),_meta:b(P(g(),T()).nullish(),()=>{})}),I5=x({terminalId:H1,data:g(),_meta:b(P(g(),T()).nullish(),()=>{})}),pb=g(),fEt=be([$("high"),$("medium"),$("low"),g()]),mEt=be([$("pending"),$("in_progress"),$("completed"),$("cancelled"),g()]),hEt=x({content:g(),priority:fEt,status:mEt,_meta:b(P(g(),T()).nullish(),()=>{})}),A5=x({planId:pb,entries:Kn(Ve(hEt),()=>[]),_meta:b(P(g(),T()).nullish(),()=>{})}),O5=x({planId:pb,uri:_r(),_meta:b(P(g(),T()).nullish(),()=>{})}),$5=x({planId:pb,content:g(),_meta:b(P(g(),T()).nullish(),()=>{})}),gEt=Mn(be([A5.and(x({type:$("items")})),O5.and(x({type:$("file")})),$5.and(x({type:$("markdown")})),$n(x({type:g(),planId:pb}),"type",["file","items","markdown"])]),"type",["file","items","markdown"]),M5=x({plan:gEt,_meta:b(P(g(),T()).nullish(),()=>{})}),D5=x({planId:pb,_meta:b(P(g(),T()).nullish(),()=>{})}),N5=x({hint:g(),_meta:b(P(g(),T()).nullish(),()=>{})}),yEt=Mn(be([N5.and(x({type:$("text")})),$n(x({type:g()}),"type",["text"])]),"type",["text"]),bEt=x({name:g(),description:g(),input:b(yEt.nullish(),()=>{}),_meta:b(P(g(),T()).nullish(),()=>{})}),z5=x({availableCommands:Kn(Ve(bEt),()=>[]),_meta:b(P(g(),T()).nullish(),()=>{})}),L5=x({configOptions:Kn(Ve(XR),()=>[]),_meta:b(P(g(),T()).nullish(),()=>{})}),F5=x({title:b(g().nullish(),()=>{}),updatedAt:b(Qu.datetime({offset:!0}).nullish(),()=>{}),_meta:b(P(g(),T()).nullish(),()=>{})}),xEt=x({amount:rt(),currency:g().regex(/^[A-Z]{3}$/),_meta:b(P(g(),T()).nullish(),()=>{})}),j5=x({used:rt(),size:rt(),cost:b(xEt.nullish(),()=>{}),_meta:b(P(g(),T()).nullish(),()=>{})}),SEt=Mn(be([lb.and(x({sessionUpdate:$("user_message_chunk")})),k5.and(x({sessionUpdate:$("user_message")})),lb.and(x({sessionUpdate:$("agent_message_chunk")})),_5.and(x({sessionUpdate:$("agent_message")})),lb.and(x({sessionUpdate:$("agent_thought_chunk")})),w5.and(x({sessionUpdate:$("agent_thought")})),T5.and(x({sessionUpdate:$("state_update")})),C5.and(x({sessionUpdate:$("tool_call_content_chunk")})),q1.and(x({sessionUpdate:$("tool_call_update")})),P5.and(x({sessionUpdate:$("terminal_update")})),I5.and(x({sessionUpdate:$("terminal_output_chunk")})),M5.and(x({sessionUpdate:$("plan_update")})),D5.and(x({sessionUpdate:$("plan_removed")})),z5.and(x({sessionUpdate:$("available_commands_update")})),L5.and(x({sessionUpdate:$("config_option_update")})),F5.and(x({sessionUpdate:$("session_info_update")})),j5.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"]),W1=x({sessionId:dn,update:SEt,_meta:b(P(g(),T()).nullish(),()=>{})}),U5=x({elicitationId:HCe,_meta:b(P(g(),T()).nullish(),()=>{})}),eT=x({connectionId:G1,method:g(),params:b(P(g(),T()).nullish(),()=>{}),_meta:b(P(g(),T()).nullish(),()=>{})}),ePe=T(),Bwr=x({method:g(),params:be([W1,U5,eT,ePe]).nullish()}),kEt=x({_meta:b(P(g(),T()).nullish(),()=>{})}),_Et=x({terminal:b(kEt.nullish(),()=>{}),_meta:b(P(g(),T()).nullish(),()=>{})}),wEt=x({_meta:b(P(g(),T()).nullish(),()=>{})}),vEt=x({_meta:b(P(g(),T()).nullish(),()=>{})}),EEt=x({form:b(wEt.nullish(),()=>{}),url:b(vEt.nullish(),()=>{}),_meta:b(P(g(),T()).nullish(),()=>{})}),REt=x({_meta:b(P(g(),T()).nullish(),()=>{})}),TEt=x({_meta:b(P(g(),T()).nullish(),()=>{})}),CEt=x({_meta:b(P(g(),T()).nullish(),()=>{})}),PEt=x({jump:b(REt.nullish(),()=>{}),rename:b(TEt.nullish(),()=>{}),searchAndReplace:b(CEt.nullish(),()=>{}),_meta:b(P(g(),T()).nullish(),()=>{})}),IEt=x({auth:b(_Et.nullish(),()=>{}),elicitation:b(EEt.nullish(),()=>{}),nes:b(PEt.nullish(),()=>{}),positionEncodings:b(Ve(VCe).optional(),()=>[]),_meta:b(P(g(),T()).nullish(),()=>{})}),V1=x({protocolVersion:BCe,info:WCe,capabilities:b(IEt.optional().default({}),()=>({})),_meta:b(P(g(),T()).nullish(),()=>{})}),H5=x({methodId:db,_meta:b(P(g(),T()).nullish(),()=>{})}),q5=x({_meta:b(P(g(),T()).nullish(),()=>{})}),G5=x({providerId:f5,apiType:m5,baseUrl:_r(),headers:P(g(),g()).optional(),_meta:b(P(g(),T()).nullish(),()=>{})}),B5=x({providerId:f5,_meta:b(P(g(),T()).nullish(),()=>{})}),W5=x({_meta:b(P(g(),T()).nullish(),()=>{})}),AEt=x({name:g(),value:g(),_meta:b(P(g(),T()).nullish(),()=>{})}),V5=x({name:g(),url:_r(),headers:gt(AEt).optional(),_meta:b(P(g(),T()).nullish(),()=>{})}),K5=x({name:g(),serverId:qCe,_meta:b(P(g(),T()).nullish(),()=>{})}),Z5=x({name:g(),command:ss,args:gt(g()).optional(),env:gt(KCe).optional(),_meta:b(P(g(),T()).nullish(),()=>{})}),J5=Mn(be([V5.and(x({type:$("http")})),K5.and(x({type:$("acp")})),Z5.and(x({type:$("stdio")})),$n(x({type:g()}),"type",["acp","http","stdio"])]),"type",["acp","http","stdio"]),Q5=x({cwd:ss,additionalDirectories:b(Ve(ss).optional(),()=>[]),mcpServers:b(Ve(J5).optional(),()=>[]),_meta:b(P(g(),T()).nullish(),()=>{})}),Y5=x({cwd:ss.nullish(),cursor:JCe.nullish(),_meta:b(P(g(),T()).nullish(),()=>{})}),X5=x({sessionId:dn,_meta:b(P(g(),T()).nullish(),()=>{})}),e7=x({sessionId:dn,cwd:ss,additionalDirectories:b(Ve(ss).optional(),()=>[]),mcpServers:b(Ve(J5).optional(),()=>[]),_meta:b(P(g(),T()).nullish(),()=>{})}),t7=x({_meta:b(P(g(),T()).nullish(),()=>{})}),OEt=Mn(be([t7.and(x({type:$("start")})),$n(x({type:g(),_meta:b(P(g(),T()).nullish(),()=>{})}),"type",["start"])]),"type",["start"]),r7=x({sessionId:dn,cwd:ss,additionalDirectories:b(Ve(ss).optional(),()=>[]),mcpServers:b(Ve(J5).optional(),()=>[]),replayFrom:b(OEt.nullish(),()=>{}),_meta:b(P(g(),T()).nullish(),()=>{})}),n7=x({sessionId:dn,_meta:b(P(g(),T()).nullish(),()=>{})}),o7=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"]),i7=x({sessionId:dn,prompt:gt(S_),_meta:b(P(g(),T()).nullish(),()=>{})}),$Et=x({uri:_r(),name:g(),_meta:b(P(g(),T()).nullish(),()=>{})}),MEt=x({name:g(),owner:g(),remoteUrl:g(),_meta:b(P(g(),T()).nullish(),()=>{})}),s7=x({workspaceUri:b(_r().nullish(),()=>{}),workspaceFolders:gt($Et).nullish(),repository:b(MEt.nullish(),()=>{}),_meta:b(P(g(),T()).nullish(),()=>{})}),DEt=be([$("automatic"),$("diagnostic"),$("manual"),g()]),NEt=x({uri:_r(),languageId:g(),text:g(),_meta:b(P(g(),T()).nullish(),()=>{})}),zEt=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(),()=>{})}),LEt=x({uri:_r(),excerpts:gt(zEt),_meta:b(P(g(),T()).nullish(),()=>{})}),FEt=x({uri:_r(),diff:g(),_meta:b(P(g(),T()).nullish(),()=>{})}),jEt=x({action:g(),uri:_r(),position:ph,timestampMs:rt(),_meta:b(P(g(),T()).nullish(),()=>{})}),UEt=x({uri:_r(),languageId:g(),visibleRange:b(k_.nullish(),()=>{}),lastFocusedMs:b(rt().nullish(),()=>{}),_meta:b(P(g(),T()).nullish(),()=>{})}),HEt=be([$("error"),$("warning"),$("information"),$("hint"),g()]),qEt=x({uri:_r(),range:k_,severity:HEt,message:g(),_meta:b(P(g(),T()).nullish(),()=>{})}),GEt=x({recentFiles:gt(NEt).nullish(),relatedSnippets:gt(LEt).nullish(),editHistory:gt(FEt).nullish(),userActions:gt(jEt).nullish(),openFiles:gt(UEt).nullish(),diagnostics:gt(qEt).nullish(),_meta:b(P(g(),T()).nullish(),()=>{})}),a7=x({sessionId:dn,uri:_r(),version:rt(),position:ph,selection:k_.nullish(),triggerKind:DEt,context:GEt.nullish(),_meta:b(P(g(),T()).nullish(),()=>{})}),c7=x({sessionId:dn,_meta:b(P(g(),T()).nullish(),()=>{})}),Wwr=x({id:dh,method:g(),params:be([V1,H5,q5,G5,B5,W5,Q5,Y5,X5,e7,r7,n7,o7,i7,s7,a7,c7,QR,GCe]).nullish()}),l7=x({optionId:FCe,_meta:b(P(g(),T()).nullish(),()=>{})}),BEt=Mn(be([x({outcome:$("cancelled")}),l7.and(x({outcome:$("selected")})),$n(x({outcome:g()}),"outcome",["cancelled","selected"])]),"outcome",["cancelled","selected"]),WEt=x({outcome:BEt,_meta:b(P(g(),T()).nullish(),()=>{})}),VEt=be([g(),rt(),rt(),mr(),gt(g())]),u7=x({content:P(g(),VEt).nullish()}),KEt=Mn(Ho(be([u7.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"]),ZEt=x({connectionId:G1,_meta:b(P(g(),T()).nullish(),()=>{})}),JEt=x({_meta:b(P(g(),T()).nullish(),()=>{})}),Vwr=be([x({id:dh,result:be([WEt,KEt,ZEt,JEt,YCe,QCe])}),x({id:dh,error:XCe})]),d7=x({sessionId:dn,_meta:b(P(g(),T()).nullish(),()=>{})}),p7=x({sessionId:dn,uri:_r(),languageId:g(),version:rt(),text:g(),_meta:b(P(g(),T()).nullish(),()=>{})}),QEt=x({range:k_.nullish(),text:g(),_meta:b(P(g(),T()).nullish(),()=>{})}),f7=x({sessionId:dn,uri:_r(),version:rt(),contentChanges:Kn(Ve(QEt),()=>[]),_meta:b(P(g(),T()).nullish(),()=>{})}),m7=x({sessionId:dn,uri:_r(),_meta:b(P(g(),T()).nullish(),()=>{})}),h7=x({sessionId:dn,uri:_r(),_meta:b(P(g(),T()).nullish(),()=>{})}),g7=x({sessionId:dn,uri:_r(),version:rt(),position:ph,visibleRange:k_,_meta:b(P(g(),T()).nullish(),()=>{})}),y7=x({sessionId:dn,suggestionId:Wp,_meta:b(P(g(),T()).nullish(),()=>{})}),YEt=be([$("rejected"),$("ignored"),$("replaced"),$("cancelled"),g()]),b7=x({sessionId:dn,suggestionId:Wp,reason:b(YEt.nullish(),()=>{}),_meta:b(P(g(),T()).nullish(),()=>{})}),Kwr=x({method:g(),params:be([d7,p7,f7,m7,h7,g7,y7,b7,eT,ePe]).nullish()}),XEt=x({requestId:dh,_meta:b(P(g(),T()).nullish(),()=>{})}),Zwr=x({method:g(),params:XEt.nullish()});function rn(e,t){return typeof e=="object"&&e!==null?e[t]:void 0}var Jwr=Z8.and(x({type:$("tool_call")})),Qwr=J8.and(x({type:$("command")})),Ywr=W8.and(x({type:$("content")})),Xwr=V8.and(x({type:$("diff")})),evr=K8.and(x({type:$("terminal")})),e0t=U8.and(x({type:$("text")})),t0t=H8.and(x({type:$("image")})),r0t=q8.and(x({type:$("audio")})),n0t=G8.and(x({type:$("resource_link")})),o0t=B8.and(x({type:$("resource")})),tvr=cb.and(x({operation:$("add")})),rvr=cb.and(x({operation:$("delete")})),nvr=cb.and(x({operation:$("modify")})),ovr=VR.and(x({operation:$("move")})),ivr=VR.and(x({operation:$("copy")})),svr=o5.and(x({mode:$("form")})).and(x({message:g()})),avr=i5.and(x({mode:$("url")})).and(x({message:g()})),cvr=be([ZR,JR]).and(x({message:g()})),lvr=Y8.and(x({type:$("string")})),uvr=X8.and(x({type:$("number")})),dvr=e5.and(x({type:$("integer")})),pvr=t5.and(x({type:$("boolean")})),fvr=n5.and(x({type:$("array")})),mvr=r5.and(x({type:$("string")}));var hvr=l5.and(x({type:$("env_var")})),gvr=u5.and(x({type:$("terminal")})),yvr=d5.and(x({type:$("agent")})),bvr=x({methodId:db,name:g()}),xvr=h5.and(x({type:$("select")})).and(x({configId:Bp,name:g()})),Svr=g5.and(x({type:$("boolean")})).and(x({configId:Bp,name:g()})),kvr=x({configId:Bp,name:g()}),_vr=y5.and(x({kind:$("edit")})),wvr=b5.and(x({kind:$("jump")})),vvr=x5.and(x({kind:$("rename")})),Evr=S5.and(x({kind:$("searchAndReplace")})),Rvr=x({suggestionId:Wp}),i0t=lb.and(x({sessionUpdate:$("user_message_chunk")})),s0t=k5.and(x({sessionUpdate:$("user_message")})),a0t=lb.and(x({sessionUpdate:$("agent_message_chunk")})),c0t=_5.and(x({sessionUpdate:$("agent_message")})),l0t=lb.and(x({sessionUpdate:$("agent_thought_chunk")})),u0t=w5.and(x({sessionUpdate:$("agent_thought")})),d0t=T5.and(x({sessionUpdate:$("state_update")})),p0t=C5.and(x({sessionUpdate:$("tool_call_content_chunk")})),f0t=q1.and(x({sessionUpdate:$("tool_call_update")})),m0t=P5.and(x({sessionUpdate:$("terminal_update")})),h0t=I5.and(x({sessionUpdate:$("terminal_output_chunk")})),g0t=M5.and(x({sessionUpdate:$("plan_update")})),y0t=D5.and(x({sessionUpdate:$("plan_removed")})),b0t=z5.and(x({sessionUpdate:$("available_commands_update")})),x0t=L5.and(x({sessionUpdate:$("config_option_update")})),S0t=F5.and(x({sessionUpdate:$("session_info_update")})),k0t=j5.and(x({sessionUpdate:$("usage_update")})),_0t=v5.and(x({state:$("running")})),w0t=E5.and(x({state:$("idle")})),v0t=R5.and(x({state:$("requires_action")})),Tvr=A5.and(x({type:$("items")})),Cvr=O5.and(x({type:$("file")})),Pvr=$5.and(x({type:$("markdown")})),Ivr=x({planId:pb}),Avr=N5.and(x({type:$("text")})),Ovr=V5.and(x({type:$("http")})),$vr=K5.and(x({type:$("acp")})),Mvr=Z5.and(x({type:$("stdio")})),Dvr=t7.and(x({type:$("start")})),Nvr=x({type:$("id")}).and(x({value:YR})).and(x({sessionId:dn,configId:Bp})),zvr=x({type:$("boolean")}).and(x({value:mr()})).and(x({sessionId:dn,configId:Bp})),Lvr=x({value:T()}).and(x({sessionId:dn,configId:Bp})),Fvr=x({outcome:$("cancelled")}),jvr=l7.and(x({outcome:$("selected")})),Uvr=u7.and(x({action:$("accept")})),Hvr=x({action:$("decline")}),qvr=x({action:$("cancel")});var x7={isText(e){return rn(e,"type")==="text"&&e0t.safeParse(e).success},isImage(e){return rn(e,"type")==="image"&&t0t.safeParse(e).success},isAudio(e){return rn(e,"type")==="audio"&&r0t.safeParse(e).success},isResourceLink(e){return rn(e,"type")==="resource_link"&&n0t.safeParse(e).success},isResource(e){return rn(e,"type")==="resource"&&o0t.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"&&i0t.safeParse(e).success},isUserMessage(e){return rn(e,"sessionUpdate")==="user_message"&&s0t.safeParse(e).success},isAgentMessageChunk(e){return rn(e,"sessionUpdate")==="agent_message_chunk"&&a0t.safeParse(e).success},isAgentMessage(e){return rn(e,"sessionUpdate")==="agent_message"&&c0t.safeParse(e).success},isAgentThoughtChunk(e){return rn(e,"sessionUpdate")==="agent_thought_chunk"&&l0t.safeParse(e).success},isAgentThought(e){return rn(e,"sessionUpdate")==="agent_thought"&&u0t.safeParse(e).success},isStateUpdate(e){return rn(e,"sessionUpdate")==="state_update"&&d0t.safeParse(e).success},isToolCallContentChunk(e){return rn(e,"sessionUpdate")==="tool_call_content_chunk"&&p0t.safeParse(e).success},isToolCallUpdate(e){return rn(e,"sessionUpdate")==="tool_call_update"&&f0t.safeParse(e).success},isTerminalUpdate(e){return rn(e,"sessionUpdate")==="terminal_update"&&m0t.safeParse(e).success},isTerminalOutputChunk(e){return rn(e,"sessionUpdate")==="terminal_output_chunk"&&h0t.safeParse(e).success},isPlanUpdate(e){return rn(e,"sessionUpdate")==="plan_update"&&g0t.safeParse(e).success},isPlanRemoved(e){return rn(e,"sessionUpdate")==="plan_removed"&&y0t.safeParse(e).success},isAvailableCommandsUpdate(e){return rn(e,"sessionUpdate")==="available_commands_update"&&b0t.safeParse(e).success},isConfigOptionUpdate(e){return rn(e,"sessionUpdate")==="config_option_update"&&x0t.safeParse(e).success},isSessionInfoUpdate(e){return rn(e,"sessionUpdate")==="session_info_update"&&S0t.safeParse(e).success},isUsageUpdate(e){return rn(e,"sessionUpdate")==="usage_update"&&k0t.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)}},S7={isRunning(e){return rn(e,"state")==="running"&&_0t.safeParse(e).success},isIdle(e){return rn(e,"state")==="idle"&&w0t.safeParse(e).success},isRequiresAction(e){return rn(e,"state")==="requires_action"&&v0t.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===j1.cancel_request)&&!e.startsWith("_"))throw new TypeError(`Custom ACP v2 ${r} method '${e}' must start with '_'`)}function sPe(e,t,r){for(let n of e)Kp(n.method,n.kind==="request"?t:r,n.kind,n.kind==="notification")}function aPe(e){let t=V1.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 cPe(e){let t=typeof e=="object"&&e!==null&&!Array.isArray(e)?e:{};return aPe({...t,protocolVersion:Gp})}function lPe(e){let t=p5.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 R0t(e){return e.map(t=>{if(t.kind!=="request"||t.method!==ct.initialize)return t;let r=t.mapResponse;return{...t,params:cPe(t.params),mapResponse:n=>{let o=lPe(n);return r?r(o):o}}})}function uPe(e){return typeof e=="object"&&e!==null&&"readable"in e&&"writable"in e}function dPe(){let e=new TransformStream,t=new TransformStream;return[{readable:t.readable,writable:e.writable},{readable:e.readable,writable:t.writable}]}var gEr={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:j1.cancel_request}},pPe=Symbol("startActiveSession"),J1=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 J1{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,eN,"notification",!0),this.sendNotification(t,r)}batch(t){return sPe(t,nT,eN),this.sendBatch(t)}},iT=class e extends J1{constructor(t,r){super(t,r)}static create(t,r){return new e(t,r)}[pPe](t,r){return this.sendRequest(ct.session_new,t,n=>this.attachSession(n),r)}buildSession(t){return typeof t=="string"?Y1.create(this,{cwd:t,mcpServers:[]}):Y1.create(this,t)}attachSession(t){let r=new w7,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=bPe(this.connectionContext).attach(t,o),c=new Dp(()=>{i.removeEventListener("abort",s)});return v7.create(this,t,o,[a,c])}request(t,r,n){Kp(t,rT,"request");let o=rT[t],i=t===ct.initialize?cPe(r):r;return this.sendRequest(t,i,o?.mapResponse,n)}notify(t,r){return Kp(t,X1,"notification",!0),this.sendNotification(t,r)}batch(t){return sPe(t,rT,X1),this.sendBatch(R0t(t))}},Q1=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)}},k7=class extends Q1{connectHandlers;client;didStartConnectHandlers=!1;constructor(t,r=[]){super(t),this.connectHandlers=r,this.client=oT.create(t.getContext())}startConnectHandlers(){this.didStartConnectHandlers||(this.didStartConnectHandlers=!0,nN(this,this.connectHandlers))}},_7=class extends Q1{connectHandlers;agent;didStartConnectHandlers=!1;constructor(t,r=[]){super(t),this.connectHandlers=r,this.agent=iT.create(t.getContext())}startConnectHandlers(){this.didStartConnectHandlers||(this.didStartConnectHandlers=!0,nN(this,this.connectHandlers))}};function fPe(e,t=[]){return new k7(e,t)}function mPe(e,t=[]){return new _7(e,t)}var w7=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 rPe(e){return structuredClone(e)}var Y1=class e{cx;request;constructor(t,r){this.cx=t,this.request=rPe(r)}static create(t,r){return new e(t,r)}toRequest(){return rPe(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[pPe](this.toRequest(),t)}async withSession(t){let r=await this.start();try{return await t(r)}finally{r.dispose()}}},v7=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(x7.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 hPe(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 gPe(e,t,r,n){e.onReceiveRequest(t.method,o=>hPe(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 yPe(e,t,r,n){e.onReceiveNotification(t.method,o=>hPe(t.params,o),(o,i)=>n(r(o,i,i.signal)))}function rN(e){let t=Object.create(null);for(let r of Object.values(e))t[r.method]=r;return t}var T0t={initialize:ao(ct.initialize,aPe,lPe),loginAuth:ao(ct.auth_login,H5,Vp),unstable_listProviders:ao(ct.providers_list,q5),unstable_setProvider:ao(ct.providers_set,G5,Vp),unstable_disableProvider:ao(ct.providers_disable,B5,Vp),newSession:ao(ct.session_new,Q5),setSessionConfigOption:ao(ct.session_set_config_option,o7),prompt:ao(ct.session_prompt,i7,Vp),unstable_messageMcp:ao(ct.mcp_message,QR),listSessions:ao(ct.session_list,Y5),deleteSession:ao(ct.session_delete,X5,Vp),unstable_forkSession:ao(ct.session_fork,e7),resumeSession:ao(ct.session_resume,r7),closeSession:ao(ct.session_close,n7,Vp),logoutAuth:ao(ct.auth_logout,W5,Vp),unstable_startNes:ao(ct.nes_start,s7),unstable_suggestNes:ao(ct.nes_suggest,a7),unstable_closeNes:ao(ct.nes_close,c7,Vp)},C0t={cancelSession:qc(ct.session_cancel,d7),unstable_messageMcp:qc(ct.mcp_message,eT),unstable_didOpenDocument:qc(ct.document_did_open,p7),unstable_didChangeDocument:qc(ct.document_did_change,f7),unstable_didCloseDocument:qc(ct.document_did_close,m7),unstable_didSaveDocument:qc(ct.document_did_save,h7),unstable_didFocusDocument:qc(ct.document_did_focus,g7),unstable_acceptNes:qc(ct.nes_accept,y7),unstable_rejectNes:qc(ct.nes_reject,b7)},P0t={requestPermission:ao(vi.session_request_permission,Q8),unstable_connectMcp:ao(vi.mcp_connect,a5),unstable_messageMcp:ao(vi.mcp_message,QR),unstable_disconnectMcp:ao(vi.mcp_disconnect,c5,Vp),unstable_createElicitation:ao(vi.elicitation_create,s5)},I0t={sessionUpdate:qc(vi.session_update,W1),unstable_messageMcp:qc(vi.mcp_message,eT),unstable_completeElicitation:qc(vi.elicitation_complete,U5)},rT=rN(T0t),X1=rN(C0t),nT=rN(P0t),eN=rN(I0t);function A0t(e,t,r,n){return{params:e,requestId:n,signal:r,client:t}}function O0t(e,t,r){return{params:e,signal:r,client:t}}function $0t(e,t,r,n){return{params:e,requestId:n,signal:r,agent:t}}function M0t(e,t,r){return{params:e,signal:r,agent:t}}var E7=class{activeSessions=new Map;handleMessage(t){if(t.kind!=="notification"||t.method!==vi.session_update)return Mc.no(t);let r=W1.parse(t.params),{update:n}=r,o=tT.isStateUpdate(n)&&S7.isIdle(n),i=this.activeSessions.get(r.sessionId);if(i&&i.size>0)for(let s of i)o&&s.isAwaitingPromptCompletion()?(s.completePrompt(),s.enqueue({kind:"stop",notification:r,update:n,stopReason:n.stopReason})):s.enqueue({kind:"session_update",notification:r,update:n});return Mc.no(t)}attach(t,r){let n=this.activeSessions.get(t.sessionId)??new Set;return n.add(r),this.activeSessions.set(t.sessionId,n),new Dp(()=>{n.delete(r),n.size===0&&this.activeSessions.delete(t.sessionId)})}},nPe=new WeakMap;function bPe(e){let t=nPe.get(e);return t||(t=new E7,nPe.set(e,t)),t}function nN(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 tN=Symbol("appBuilder"),K1=Symbol("runAgentConnectHandlers"),Z1=Symbol("runClientConnectHandlers");var oPe=class{builder=Np.builder();connectHandlers=[];constructor(t={}){t.name&&this.builder.name(t.name)}[tN](){return this.builder}[K1](t){nN(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,X1,"notification",!0),this.notification({method:t,params:r},n);let o=X1[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 gPe(this.builder,t,(n,o,i,s)=>A0t(n,oT.create(o,s),i,s),r),this}notification(t,r){return yPe(this.builder,t,(n,o,i)=>O0t(n,oT.create(o),i),r),this}connectConnection(t,r={}){if(uPe(t)){let c=this.openStreamConnection(t);return r.deferConnectHandlers||this[K1](c.connection),c}let[n,o]=dPe(),i=t[tN]().connect(o),s=mPe(i),a=this.openStreamConnection(n);a.rawConnection.closed.then(()=>s.close()),i.closed.then(()=>a.connection.close());try{t[Z1](s),this[K1](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:fPe(r,this.connectHandlers)}}};var iPe=class{builder=Np.builder();connectHandlers=[];constructor(t={}){t.name&&this.builder.name(t.name),this.builder.withHandler({handleMessage:(r,n)=>bPe(n).handleMessage(r),describe:()=>"client-session-update-router"})}[tN](){return this.builder}[Z1](t){nN(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,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 gPe(this.builder,t,(n,o,i,s)=>$0t(n,iT.create(o,s),i,s),r),this}notification(t,r){return yPe(this.builder,t,(n,o,i)=>M0t(n,iT.create(o),i),r),this}connectConnection(t){if(uPe(t)){let a=this.openStreamConnection(t);return this[Z1](a.connection),a}let[r,n]=dPe(),o=t[tN]().connect(n),i=fPe(o),s=this.openStreamConnection(r);s.rawConnection.closed.then(()=>i.close()),o.closed.then(()=>s.connection.close());try{t[K1](i),this[Z1](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:mPe(r,this.connectHandlers)}}};var xPe=1;var SPe=["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"},REr=Object.values(Ms);var N0t=16e3,z0t={type:"object",additionalProperties:!1,required:["demand"],properties:{demand:{type:"string",minLength:1,maxLength:N0t,description:"The one-off demand this dispatch exists to satisfy."}}},L0t={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}}},IEr={version:1,method:Ms.goDispatch,params:z0t,answer:L0t};var F0t=64,kPe=200,j0t=/^[a-z0-9][a-z0-9._-]*$/;var U0t={type:"object",additionalProperties:!1,required:["slug"],properties:{slug:{type:"string",minLength:1,maxLength:F0t,pattern:j0t.source,description:"What the human is about to work on; becomes the worktree directory name."},branch:{type:"string",minLength:1,maxLength:kPe,description:"Branch to create; defaults to the daemon's convention for the slug."},base:{type:"string",minLength:1,maxLength:kPe,description:"Trunk BRANCH to fork from; the remote is the Project's registered trunk remote."}}},H0t={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}}},q0t={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}}}}}},GEr={version:1,methods:{add:Ms.worktreeAdd,list:Ms.worktreeList},add:{params:U0t,answer:H0t},list:{answer:q0t}};sT();var Q0t={drain:Ms.projectDrain,stop:Ms.projectStop,status:Ms.projectStatus};async function C7(e={}){let t=e.cwd??process.cwd(),r=e.name??"RedSkills Project client",n=e.version??"1",o=e.paths??oN();await WR(o);let i=(await ab(o)).paths,s=await tRt(i.acpSocketPath),a=[],c="",l=Yve({name:r}).onNotification(nh.client.session.update,async({params:f})=>{f.sessionId===c&&(a.push(f.update),await e.onUpdate?.(f.update))});e.requestPermission!=null&&(l=l.onRequest(nh.client.session.requestPermission,({params:f})=>e.requestPermission(f)));let u=l.connect(k9(J0t.toWeb(s),Z0t.toWeb(s)));return await u.agent.request(nh.agent.initialize,{protocolVersion:1,clientCapabilities:{},clientInfo:{name:r,version:n},_meta:{redskills:{wireMajor:xPe}}}),c=(await u.agent.request(nh.agent.session.new,{cwd:t,mcpServers:[]})).sessionId,{control:async(f,m={})=>{let y=await u.agent.request(Q0t[f],{...m.target==null?{}:{target:m.target},...m.runner==null?{}:{runner:m.runner},...m.registration==null?{}:{registration:m.registration}});if(!CPe(y))throw new Error("redskilled returned an invalid Project control outcome");if(f==="status"&&!X0t(y))throw new Error("redskilled returned Project status without a valid RedSkills context");return y},github(f){return u.agent.request(Ms.githubRequest,{request:f})},brain(f){return u.agent.request(Ms.brainCall,{tool:f.tool,arguments:f.arguments})},memory(f){return u.agent.request(Ms.memoryCall,{tool:f.tool,arguments:f.arguments,...f.mode==null?{}:{mode:f.mode}})},async prompt(f){let m=a.length,y=await u.agent.request(nh.agent.session.prompt,{sessionId:c,prompt:[{type:"text",text:f}]});return{stopReason:y.stopReason,...Y0t(y._meta),updates:a.slice(m)}},cancel(){return u.agent.notify(nh.agent.session.cancel,{sessionId:c})},async permission(f){return e.requestPermission==null?{outcome:{outcome:"cancelled"},_meta:{redskills:{permissionResolution:"hitl-required"}}}:await e.requestPermission(f)},close(){u.close(),s.destroy()}}}function Y0t(e){let r=Jp(Jp(e)?.redskills)?.projectControl;return CPe(r)?{projectControl:r}:{}}function CPe(e){let t=Jp(e);return t?.version===1&&typeof t.project_id=="string"&&typeof t.revision=="number"&&Array.isArray(t.updates)}function X0t(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(eRt)&&(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 eRt(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 tRt(e){return await new Promise((t,r)=>{let n=K0t(e);n.once("connect",()=>t(n)),n.once("error",r)})}pee();gd();sre();D_();gd();var Vz=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)}};are();var Jz=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(oX,n=>this._oninitialize(n)),this.setNotificationHandler(sX,()=>this.oninitialized?.()),this._capabilities.logging&&this.setRequestHandler(vX,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 Vz(this)}),this._experimental}registerCapabilities(t){if(this.transport)throw new Error("Cannot register capabilities after connecting to transport");this._capabilities=pz(this._capabilities,t)}setRequestHandler(t,r){let o=md(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(hd,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){Zz(this._clientCapabilities?.tasks?.requests,t,"Client")}assertTaskHandlerCapability(t){this._capabilities&&Kz(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:FN.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},CX,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_();dee();gd();var FDe=Symbol.for("mcp.completable");function cre(e){return!!e&&typeof e=="object"&&FDe in e}function jDe(e){return e[FDe]?.complete}var LDe;(function(e){e.Completable="McpCompletable"})(LDe||(LDe={}));var V1t=/^[A-Za-z0-9._-]{1,128}$/;function K1t(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"),!V1t.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 Z1t(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 lre(e){let t=K1t(e);return Z1t(e,t.warnings),t.isValid}var Qz=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 Jz(t,r)}get experimental(){return this._experimental||(this._experimental={tasks:new Qz(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(ez)),this.server.assertCanSetRequestHandler(Ah(j_)),this.server.registerCapabilities({tools:{listChanged:!0}}),this.server.setRequestHandler(ez,()=>({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?cee(o,{strictUnions:!0,pipeStrategy:"input"}):J1t})(),annotations:r.annotations,execution:r.execution,_meta:r._meta};if(r.outputSchema){let o=M_(r.outputSchema);o&&(n.outputSchema=cee(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 $N(i,r);if(!s.success){let a="error"in s?s.error:"Unknown error",c=MN(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 $N(o,r.structuredContent);if(!i.success){let s="error"in i?i.error:"Unknown error",a=MN(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(tz)),this.server.registerCapabilities({completions:{}}),this.server.setRequestHandler(tz,async t=>{switch(t.params.ref.type){case"ref/prompt":return cOe(t),this.handlePromptCompletion(t,t.params.ref);case"ref/resource":return lOe(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=md(n.argsSchema)?.[t.params.argument.name];if(!cre(i))return mC;let s=jDe(i);if(!s)return mC;let a=await s(t.params.argument.value,t.params.context);return HDe(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 HDe(i)}setResourceRequestHandlers(){this._resourceHandlersInitialized||(this.server.assertCanSetRequestHandler(Ah(L_)),this.server.assertCanSetRequestHandler(Ah(QN)),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(QN,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(YN)),this.server.assertCanSetRequestHandler(Ah(XN)),this.server.registerCapabilities({prompts:{listChanged:!0}}),this.server.setRequestHandler(YN,()=>({prompts:Object.entries(this._registeredPrompts).filter(([,t])=>t.enabled).map(([t,r])=>({name:t,title:r.title,description:r.description,arguments:r.argsSchema?Q1t(r.argsSchema):void 0}))})),this.server.setRequestHandler(XN,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 $N(o,t.params.arguments);if(!i.success){let c="error"in i?i.error:"Unknown error",l=MN(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 cre(l)})&&this.setCompletionRequestHandler(),s}_createRegisteredTool(t,r,n,o,i,s,a,c,l){lre(t);let u={title:r,description:n,inputSchema:UDe(o),outputSchema:UDe(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"&&lre(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(ure(c))o=r.shift(),r.length>1&&typeof r[0]=="object"&&r[0]!==null&&!ure(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 J1t={type:"object",properties:{}};function qDe(e){return e!==null&&typeof e=="object"&&"parse"in e&&typeof e.parse=="function"&&"safeParse"in e&&typeof e.safeParse=="function"}function GDe(e){return"_def"in e||"_zod"in e||qDe(e)}function ure(e){return typeof e!="object"||e===null||GDe(e)?!1:Object.keys(e).length===0?!0:Object.values(e).some(qDe)}function UDe(e){if(e){if(ure(e))return Db(e);if(!GDe(e))throw new Error("inputSchema must be a Zod schema or raw shape, received an unrecognized object");return e}}function Q1t(e){let t=md(e);return t?Object.entries(t).map(([r,n])=>{let o=yAe(n),i=bAe(n);return{name:r,description:o,required:!i}}):[]}function Ah(e){let r=md(e)?.method;if(!r)throw new Error("Schema is missing a method literal");let n=DN(r);if(typeof n=="string")return n;throw new Error("Schema method literal must be a string")}function HDe(e){return{completion:{values:e.slice(0,100),total:e.length,hasMore:e.length>100}}}var mC={completion:{values:[],hasMore:!1}};dre();import BDe from"node:process";var hC=class{constructor(t=BDe.stdin,r=BDe.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=Yz(t);this._stdout.write(n)?r():this._stdout.once("drain",r)})}};import{resolve as P$}from"node:path";import{fileURLToPath as qdt}from"node:url";Jn();function WDe(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 pre(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)?e:null}function fre(e){return typeof e=="string"&&e.trim()!==""?e:null}function X1t(e){let t=pre(e);if(t===null)return null;let r=pre(t.demand);return fre(r?.refusal)??fre(t.latest_refusal)}function VDe(e){return{tool:"status",args:{scope:"project"},why:e}}function eNt(){return{tool:"status",args:{scope:"host"},why:"diagnose why the host daemon does not answer before changing registration"}}function tNt(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"}:VDe(t!==null?"observe when the daemon's refusal clears and capacity begins draining again":"observe the next socket-local queue poll and Worker birth"):eNt()}function rNt(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 nNt(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 KDe(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=rNt(r),i=X1t(n),s=tNt(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:fre(pre(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:nNt(t())}}}]}Jn();function ZDe(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 oNt=["requeue","retake","park","close"];function JDe(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(oNt),rationale:w.string().min(1)},invoke:t=>e.hitlResolve(t)}]}Jn();var Xz="2.0.0";function eL(e,t){return{version:Xz,schema:e,projection:t}}var COr=w.object({age_s:w.number(),stale:w.boolean(),stale_after_s:w.number(),reason:w.enum(["fresh","aged-out","never-observed","orphaned"])}),iNt=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"])}),sNt=w.object({tool:w.string().min(1),args:w.record(w.string(),w.unknown()),why:w.string().min(1)}),aNt=w.union([sNt,w.literal("none")]),cNt=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:aNt.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:iNt.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"})}),lNt=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()})}),uNt=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:cNt,validation_schedule:uNt,birth_latch:lNt.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()}),dNt=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()}),pNt=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()}),fNt=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()})}),YDe=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:dNt}),live:w.boolean(),active:w.boolean(),renderable_live:w.boolean(),liveness:w.enum(["active","quiet-but-live","dead"]),liveness_verdict:pNt,daemon_liveness:fNt.optional()}),tL=w.array(YDe),rL=w.array(YDe.partial()),mNt=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(mNt),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()}),QDe=w.object({number:w.number(),title:w.string(),labels:w.array(w.string())}),XDe=w.object({ready_for_agent:w.object({eligible:w.array(QDe),held_for_summon:w.array(QDe)}),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()}))}),e1e=eL(gC),POr=eL(tL,{input:"fields",schema:rL}),IOr=eL(yC),t1e=eL(XDe);function hNt(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 r1e(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=hNt(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 n1e="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`).",mre=class extends Error{constructor(t){super(t===void 0||t===""?n1e:`fleet ${JSON.stringify(t)}: ${n1e}`),this.name="FleetNamingRemovedError"}};function lw(e){if(!(e==null||e===""))throw new mre(typeof e=="string"?e:String(e))}Jn();var gNt=w.object({tool:w.literal("status"),args:w.object({scope:w.enum(["worker","project","host"])})});function o1e(e){return w.object({deprecated:w.literal(!0),message:w.string().min(1),replacement:gNt,result:e})}function s1e(e){return{version:e.version,schema:o1e(e.schema),...e.projection===void 0?{}:{projection:{input:e.projection.input,schema:o1e(e.projection.schema)}}}}var yNt=w.object({status:w.unknown(),vitals:tL,monitor:yC}),bNt=w.object({status:w.unknown(),vitals:rL,monitor:yC}),i1e=w.object({state:w.unknown(),dashboard:w.unknown(),provision_check:w.unknown(),unit_status:w.unknown()}),xNt={version:Xz,schema:w.union([gC,yNt,i1e]),projection:{input:"fields",schema:w.union([gC,bNt,i1e])}};function a1e(e,t,r){return{deprecated:!0,message:`${e} is deprecated; use status { scope: ${t} }`,replacement:{tool:"status",args:{scope:t}},result:r}}async function SNt(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 c1e(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:xNt,invoke:t=>SNt(e,t)}]}nL();var oL={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 d1e=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 p1e(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:s1e(e1e),invoke:async({fleet:t})=>(lw(t),a1e("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(oL).optional(),config:d1e.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(oL).optional(),config:d1e.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 f1e(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 m1e(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 h1e(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 g1e(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 y1e(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(oL).optional()},outputContract:t1e,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 b1e(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 x1e(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 gre(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 yre={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 bre(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 S1e(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:yre,invoke:t=>{let r;try{r=bre(t)}catch(n){return Promise.resolve(gre(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 k1e(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:{...yre,text:w.string().min(1)},invoke:t=>{let r;try{r=bre(t)}catch(n){return Promise.resolve(gre(n))}return e.workerRequest({...r,text:t.text})}}]}function _1e(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 w1e(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 v1e(e,t){return t==="allow"?e:e.map(r=>{if(!r.dangerClass)return r;if(t==="deny")return{...r,invoke:async i=>w1e("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 w1e("confirm",r.name,i);let{confirmation:s,...a}=i;return o(a)}}})}Jn();function E1e(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 R1e(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 T1e(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 iL="Call the redskilled MCP's `help` tool.\nFollow its guidance and invoke the returned `next` call.",xre=[{name:"drain",title:"Drain this project's queue",description:"Find the next action for starting or continuing a project drain.",body:iL},{name:"diagnose",title:"Diagnose redskilled",description:"Find the next action for understanding a redskilled problem.",body:iL},{name:"configure",title:"Configure redskilled",description:"Find the next action for changing project execution configuration.",body:iL},{name:"stop",title:"Stop project work",description:"Find the next action for stopping project work safely.",body:iL}];var C1e="rs_dev";function P1e(e,t="allow"){let r=[],n=[...KDe(e,()=>r),...c1e(e),...p1e(e),...y1e(e),...m1e(e),...S1e(e),...k1e(e),...h1e(e),...f1e(e),...g1e(e),...WDe(e),...ZDe(e),...JDe(e),...R1e(e),...E1e(e),...x1e(e),..._1e(e),...b1e(e),...T1e(e)];return r=v1e(r1e(n),t),r}Yt();function uw(e){return tn(JSON.parse(JSON.stringify(e??null)),{objectArrayColumns:!0,primitiveArrayColumns:!0})}var kNt=new Map([["drain","drain"],["project_drain","drain"],["project_stop","stop"],["project_status","status"],["status","status"]]),_Nt=new Set(["target","runner","scope","registration","live_only","fields","worker"]);async function I1e(e,t,r){let n=kNt.get(t);if(n!=null){let o=Object.keys(r).filter(i=>!_Nt.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,wNt(r))}if(!ENt(t))throw new Error(`unsupported ACP Project capability ${JSON.stringify(t)}`);return await e.prompt(vNt(t,r))}function wNt(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 vNt(e,t){return`/${e} ${JSON.stringify(t)}`}function ENt(e){return/^[a-z][a-z0-9_]*$/.test(e)&&!e.startsWith("private_")&&!e.includes("worker_birth")&&!e.includes("daemon_protocol")&&!e.includes("github_client")}vre();nL();import{execFileSync as Dzt}from"node:child_process";wR();_d();function oNe(e){let t=sNe(e.repo).join("/"),r=e.selector??{},n=[`repo:${t}`,"is:issue","is:open",cL(e.readyLabel??su)];r.lane!=null&&r.lane!==""&&n.push(cL(`lane:${r.lane}`)),r.label!=null&&r.label!==""&&n.push(cL(r.label));for(let o of r.tags??[])o!==""&&n.push(cL(`${Rre}${o}`));return r.user!=null&&r.user!==""&&r.user!=="@me"&&n.push(`author:${r.user}`),n.join(" ")}function iNe(e){let[t,r]=sNe(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(`${Rre}${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 cL(e){return`label:${JSON.stringify(e)}`}function sNe(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 GNt="Work issue #{{work_item}} in this repository to a merged pull request, following the /afk skill: claim it, implement it in this workspace, run the gate, open the PR, and land it. 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 you cannot claim it or the work is blocked, say so plainly and stop.";function aNe(e){let t={repo:e.repo,...e.selector==null?{}:{selector:e.selector},...e.readyLabel==null?{}:{readyLabel:e.readyLabel}};return{selector:oNe(t),queue_poll:iNe(t),argv:Fp("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:GNt,...e.validationCommands==null||e.validationCommands.length===0?{}:{validation_commands:[...e.validationCommands]},target:e.target}}wC();lf();function _ze(e,t,r={},n=wre){let o=zzt(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=Nzt(e);return aNe({repo:o,workspacePath:e,target:i,version:t,...s==null?{}:{runner:s},...kze(e)==null?{}:{trunkBranch:kze(e)},...a.length===0?{}:{validationCommands:a}})}function Nzt(e){try{let t=Sze(_C(cu(e).configPath,{warn:()=>{}}));return[...t.post_done??[],...t.landing??[]]}catch{return[]}}function kze(e){try{let r=Dzt("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 zzt(e,t=wre){let r;try{r=t(e).name}catch{return}return/^[^/\s]+\/[^/\s]+$/.test(r)?r:void 0}gd();var hw="redskilled://lanes/events",Lzt=1e3;function wze(e,t,r={}){let n=r.bufferLimit??Lzt,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=Jre(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(fX,async c=>Jre(c)!==hw?{}:(i+=1,i===1&&(s=await t.subscribe(a),t.start(r.intervalMs)),{})),e.setRequestHandler(mX,c=>Jre(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 Jre(e){let t=e?.params;return typeof t?.uri=="string"?t.uri:""}function Eze(e){let t=new Set,r,n,o=async()=>{let s=await e("events_since",r===void 0?{}:{cursor:r});if(!vze(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(vze):[];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 vze(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}Jn();var Qre="rs_github",Rze="github_request",yL=Ms.githubRequest;function Yre(){return[{name:Rze,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:yL,inputSchema:{method:w.enum(SPe),path:w.string().min(1),body:w.record(w.unknown()).optional(),headers:w.record(w.string()).optional()}}]}function Tze(e){return{request:{method:e.method,path:e.path,...e.body===void 0?{}:{body:e.body},...e.headers===void 0?{}:{headers:e.headers}}}}function Xre(e){let t=new aw({name:Qre,version:e.version}),r=t.registerTool.bind(t);for(let n of e.tools??Yre())r(n.name,{title:n.title,description:n.description,inputSchema:n.inputSchema},async o=>({content:[{type:"text",text:uw(await e.invoke(n.method,Tze(o)))}]}));return t}var dk=YW("redskilled-mcp");function Ulr(e=process.cwd(),t){let r=new aw({name:C1e,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:_ze(e,dk.version,c)}:c;for(let a of P1e(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 xre)r.registerPrompt(a.name,{title:a.title,description:a.description},async()=>({messages:[{role:"user",content:{type:"text",text:a.body}}]}));return wze(r.server,Eze(o)),r}async function Gdt(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$(qdt(i.uri))}catch{}return P$(r)}async function Bdt(e){let t,r=new Promise(n=>{t=n});e.server.server.onclose=t,await e.server.connect(e.transport),await r}async function Hlr(){let e=process.cwd(),t,r,n=()=>(t??=Gdt(r.server,process.env,e).then(i=>C7({cwd:i,name:"RedSkills GitHub MCP adapter",version:dk.version})),t);r=Xre({version:dk.version,invoke:async(i,s)=>{if(i!==yL)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 Bdt({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 qlr(){let e=process.cwd(),t,r,n=()=>(t??=Gdt(r.server,process.env,e).then(i=>C7({cwd:i,name:"RedSkills MCP adapter",version:dk.version})),t);r=Ulr(e,async(i,s)=>I1e(await n(),i,s));let o=()=>{r.close()};process.once("SIGINT",o),process.once("SIGTERM",o);try{await Bdt({server:r,transport:new hC})}finally{if(t!==void 0)try{(await t).close()}catch{}process.removeListener("SIGINT",o),process.removeListener("SIGTERM",o)}}var Glr=`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 ifr=CZ.and(x({mode:$("form")})).and(x({message:g()})),sfr=PZ.and(x({mode:$("url")})).and(x({message:g()})),afr=be([pR,fR]).and(x({message:g()})),cfr=_Z.and(x({type:$("string")})),lfr=wZ.and(x({type:$("number")})),ufr=vZ.and(x({type:$("integer")})),dfr=EZ.and(x({type:$("boolean")})),pfr=TZ.and(x({type:$("array")})),ffr=RZ.and(x({type:$("string")}));var mfr=XZ.and(x({action:$("accept")})),hfr=x({action:$("decline")}),gfr=x({action:$("cancel")});function k9(e,t){return m9(e,t)}function Dc(e){return e??{}}function Uve(e){return typeof e=="object"&&e!==null&&"readable"in e&&"writable"in e}function Hve(){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:e4.cancel_request}},qve=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=Jve[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)}[qve](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 y9,n=this.connectionContext.signal,o=()=>{r.fail(n.reason??new Error("ACP connection closed"))};n.aborted?o():n.addEventListener("abort",o);let i=Qve(this.connectionContext).attach(t,r),s=new Dp(()=>{n.removeEventListener("abort",o)});return b9.create(this,t,r,[i,s])}request(t,r,n){let o=Zve[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)}},h9=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))}},g9=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 Gve(e,t=[]){return new h9(e,t)}function Bve(e,t=[]){return new g9(e,t)}var y9=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 Lve(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=Lve(r)}static create(t,r){return new e(t,r)}toRequest(){return Lve(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[qve](this.toRequest(),t)}async withSession(t){let r=await this.start();try{return await t(r)}finally{r.dispose()}}},b9=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 Wve(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 Vve(e,t,r,n){e.onReceiveRequest(t.method,o=>Wve(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 Kve(e,t,r,n){e.onReceiveNotification(t.method,o=>Wve(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 Jyt={initialize:en(Me.initialize,SD),newSession:en(Me.session_new,jZ),loadSession:en(Me.session_load,UZ,Dc),unstable_forkSession:en(Me.session_fork,GZ),listSessions:en(Me.session_list,HZ),deleteSession:en(Me.session_delete,qZ,Dc),resumeSession:en(Me.session_resume,BZ),closeSession:en(Me.session_close,WZ,Dc),setSessionMode:en(Me.session_set_mode,VZ,Dc),setSessionConfigOption:en(Me.session_set_config_option,KZ),authenticate:en(Me.authenticate,DZ,Dc),unstable_listProviders:en(Me.providers_list,NZ),unstable_setProvider:en(Me.providers_set,zZ,Dc),unstable_disableProvider:en(Me.providers_disable,LZ,Dc),logout:en(Me.logout,FZ,Dc),prompt:en(Me.session_prompt,ZZ),unstable_startNes:en(Me.nes_start,JZ),unstable_suggestNes:en(Me.nes_suggest,QZ),unstable_closeNes:en(Me.nes_close,YZ,Dc)},Qyt={cancel:Xu(Me.session_cancel,e9),unstable_didOpenDocument:Xu(Me.document_did_open,t9),unstable_didChangeDocument:Xu(Me.document_did_change,r9),unstable_didCloseDocument:Xu(Me.document_did_close,n9),unstable_didSaveDocument:Xu(Me.document_did_save,o9),unstable_didFocusDocument:Xu(Me.document_did_focus,i9),unstable_acceptNes:Xu(Me.nes_accept,s9),unstable_rejectNes:Xu(Me.nes_reject,a9)},Yyt={requestPermission:en(ir.session_request_permission,gZ),writeTextFile:en(ir.fs_write_text_file,pZ,Dc),readTextFile:en(ir.fs_read_text_file,fZ),createTerminal:en(ir.terminal_create,yZ),terminalOutput:en(ir.terminal_output,bZ),releaseTerminal:en(ir.terminal_release,xZ,Dc),waitForTerminalExit:en(ir.terminal_wait_for_exit,SZ),killTerminal:en(ir.terminal_kill,kZ,Dc),unstable_createElicitation:en(ir.elicitation_create,IZ)},Xyt={sessionUpdate:Xu(ir.session_update,xD),unstable_completeElicitation:Xu(ir.elicitation_complete,MZ)},Zve=AD(Jyt),ebt=AD(Qyt),Jve=AD(Yyt),tbt=AD(Xyt);function rbt(e,t,r,n){return{params:e,requestId:n,signal:r,client:t}}function nbt(e,t,r){return{params:e,signal:r,client:t}}function obt(e,t,r,n){return{params:e,requestId:n,signal:r,agent:t}}function ibt(e,t,r){return{params:e,signal:r,agent:t}}var x9=class{activeSessions=new Map;handleMessage(t){if(t.kind!=="notification"||t.method!==ir.session_update)return Mc.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 Mc.no(t)}attach(t,r){let n=this.activeSessions.get(t.sessionId)??new Set;return n.add(r),this.activeSessions.set(t.sessionId,n),new Dp(()=>{n.delete(r),n.size===0&&this.activeSessions.delete(t.sessionId)})}},Fve=new WeakMap;function Qve(e){let t=Fve.get(e);return t||(t=new x9,Fve.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 jve=class{builder=Np.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=Zve[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=ebt[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 Vve(this.builder,t,(n,o,i,s)=>rbt(n,mR.create(o,s),i,s),r),this}notification(t,r){return Kve(this.builder,t,(n,o,i)=>nbt(n,mR.create(o),i),r),this}connectConnection(t,r={}){if(Uve(t)){let c=this.openStreamConnection(t);return r.deferConnectHandlers||this[vD](c.connection),c}let[n,o]=Hve(),i=t[PD]().connect(o,ID),s=Bve(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:Gve(r,this.connectHandlers)}}};function Yve(e){return new S9(e)}var S9=class{builder=Np.builder();connectHandlers=[];constructor(t={}){t.name&&this.builder.name(t.name),this.builder.withHandler({handleMessage:(r,n)=>Qve(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=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 Vve(this.builder,t,(n,o,i,s)=>obt(n,hR.create(o,s),i,s),r),this}notification(t,r){return Kve(this.builder,t,(n,o,i)=>ibt(n,hR.create(o),i),r),this}connectConnection(t){if(Uve(t)){let a=this.openStreamConnection(t);return this[ED](a.connection),a}let[r,n]=Hve(),o=t[PD]().connect(n,ID),i=Gve(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:Bve(r,this.connectHandlers)}}},Efr=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]),Rfr=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]),Tfr=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]),Cfr=new Set([ir.session_update,ir.elicitation_complete]);j8();O8();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"},j1={cancel_request:"$/cancel_request"},Gp=2;var dh=be([rt(),g()]).nullable(),dn=g(),U1=g(),zwt=be([$("read"),$("edit"),$("delete"),$("move"),$("search"),$("execute"),$("think"),$("fetch"),$("switch_mode"),$("other"),g()]),Lwt=be([$("pending"),$("in_progress"),$("completed"),$("failed"),$("cancelled"),g()]),Fwt=be([$("assistant"),$("user"),g()]),KR=x({audience:b(Ve(Fwt).nullish(),()=>{}),lastModified:b(Qu.datetime({offset:!0}).nullish(),()=>{}),priority:b(rt().gte(0).lte(1).nullish(),()=>{}),_meta:b(P(g(),T()).nullish(),()=>{})}),U8=x({text:g(),annotations:b(KR.nullish(),()=>{}),_meta:b(P(g(),T()).nullish(),()=>{})}),ub=g(),H8=x({data:g(),mimeType:ub,uri:b(_r().nullish(),()=>{}),annotations:b(KR.nullish(),()=>{}),_meta:b(P(g(),T()).nullish(),()=>{})}),q8=x({data:g(),mimeType:ub,annotations:b(KR.nullish(),()=>{}),_meta:b(P(g(),T()).nullish(),()=>{})}),jwt=be([$("light"),$("dark"),g()]),Uwt=x({src:_r(),mimeType:b(ub.nullish(),()=>{}),sizes:b(Ve(g()).nullish(),()=>{}),theme:b(jwt.nullish(),()=>{})}),G8=x({name:g(),uri:_r(),title:b(g().nullish(),()=>{}),description:b(g().nullish(),()=>{}),icons:b(Ve(Uwt).nullish(),()=>{}),mimeType:b(ub.nullish(),()=>{}),size:b(rt().nullish(),()=>{}),annotations:b(KR.nullish(),()=>{}),_meta:b(P(g(),T()).nullish(),()=>{})}),Hwt=x({text:g(),uri:_r(),mimeType:b(ub.nullish(),()=>{}),_meta:b(P(g(),T()).nullish(),()=>{})}),qwt=x({blob:g(),uri:_r(),mimeType:b(ub.nullish(),()=>{}),_meta:b(P(g(),T()).nullish(),()=>{})}),Gwt=be([Hwt,qwt]),B8=x({resource:Gwt,annotations:b(KR.nullish(),()=>{}),_meta:b(P(g(),T()).nullish(),()=>{})}),S_=Mn(be([U8.and(x({type:$("text")})),H8.and(x({type:$("image")})),q8.and(x({type:$("audio")})),G8.and(x({type:$("resource_link")})),B8.and(x({type:$("resource")})),$n(x({type:g()}),"type",["audio","image","resource","resource_link","text"])]),"type",["audio","image","resource","resource_link","text"]),W8=x({content:S_,_meta:b(P(g(),T()).nullish(),()=>{})}),Bwt=be([$("text"),$("binary"),$("directory"),$("symlink"),g()]),ss=g(),cb=x({path:ss}),VR=x({oldPath:ss,path:ss}),Wwt=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(Bwt.nullish(),()=>{}),mimeType:b(ub.nullish(),()=>{}),_meta:b(P(g(),T()).nullish(),()=>{})})),"operation",["add","copy","delete","modify","move"]),Vwt=be([$("git_patch"),g()]),Kwt=x({format:Vwt,text:g()}),V8=x({changes:Ve(Wwt),patch:b(Kwt.nullish(),()=>{}),_meta:b(P(g(),T()).nullish(),()=>{})}),H1=g(),K8=x({terminalId:H1,_meta:b(P(g(),T()).nullish(),()=>{})}),LCe=Mn(be([W8.and(x({type:$("content")})),V8.and(x({type:$("diff")})),K8.and(x({type:$("terminal")})),$n(x({type:g()}),"type",["content","diff","terminal"])]),"type",["content","diff","terminal"]),Zwt=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(),()=>{})}),q1=x({toolCallId:U1,name:b(g().nullish(),()=>{}),title:b(g().nullish(),()=>{}),kind:b(zwt.nullish(),()=>{}),status:b(Lwt.nullish(),()=>{}),content:b(Ve(LCe).nullish(),()=>{}),locations:b(Ve(Zwt).nullish(),()=>{}),rawInput:b(T().optional(),()=>{}),rawOutput:b(T().optional(),()=>{}),_meta:b(P(g(),T()).nullish(),()=>{})}),Z8=x({toolCall:q1}),J8=x({command:g(),cwd:ss,toolCallId:b(U1.nullish(),()=>{}),terminalId:b(H1.nullish(),()=>{}),_meta:b(P(g(),T()).nullish(),()=>{})}),Jwt=Mn(be([Z8.and(x({type:$("tool_call")})),J8.and(x({type:$("command")})),$n(x({type:g()}),"type",["command","tool_call"])]),"type",["command","tool_call"]),FCe=g(),Qwt=be([$("allow_once"),$("allow_always"),$("reject_once"),$("reject_always"),g()]),Ywt=x({optionId:FCe,name:g(),kind:Qwt,_meta:b(P(g(),T()).nullish(),()=>{})}),Q8=x({sessionId:dn,title:g(),description:b(g().nullish(),()=>{}),subject:Jwt.nullish(),options:gt(Ywt).min(1),_meta:b(P(g(),T()).nullish(),()=>{})}),ZR=x({sessionId:dn,toolCallId:b(U1.nullish(),()=>{})}),JR=x({requestId:dh}),Xwt=$("object"),evt=be([$("email"),$("uri"),$("date"),$("date-time"),g()]),jCe=x({const:g(),title:g(),description:b(g().nullish(),()=>{}),_meta:b(P(g(),T()).nullish(),()=>{})}),Y8=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:evt.nullish(),default:b(g().nullish(),()=>{}),enum:gt(g()).min(1).nullish(),oneOf:gt(jCe).min(1).nullish(),_meta:b(P(g(),T()).nullish(),()=>{})}),X8=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(),()=>{})}),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(),()=>{}),default:b(mr().nullish(),()=>{}),_meta:b(P(g(),T()).nullish(),()=>{})}),r5=x({enum:gt(g()).min(1),_meta:b(P(g(),T()).nullish(),()=>{})}),UCe=x({anyOf:gt(jCe).min(1),_meta:b(P(g(),T()).nullish(),()=>{})}),tvt=Mn(be([r5.and(x({type:$("string")})),$n(x({type:g()}),"type",["string"]),UCe]),"type",["string"]),n5=x({title:b(g().nullish(),()=>{}),description:b(g().nullish(),()=>{}),minItems:rt().nullish(),maxItems:rt().nullish(),items:tvt,default:b(Ve(g()).nullish(),()=>{}),_meta:b(P(g(),T()).nullish(),()=>{})}),rvt=Mn(be([Y8.and(x({type:$("string")})),X8.and(x({type:$("number")})),e5.and(x({type:$("integer")})),t5.and(x({type:$("boolean")})),n5.and(x({type:$("array")})),$n(x({type:g()}),"type",["array","boolean","integer","number","string"])]),"type",["array","boolean","integer","number","string"]),nvt=x({type:b(Xwt.optional().default("object"),()=>"object"),title:b(g().nullish(),()=>{}),properties:P(g(),rvt).optional().default({}),required:gt(g()).nullish(),description:b(g().nullish(),()=>{}),_meta:b(P(g(),T()).nullish(),()=>{})}),o5=Ho(be([ZR,JR]),x({requestedSchema:nvt})),HCe=g(),i5=Ho(be([ZR,JR]),x({elicitationId:HCe,url:_r()})),s5=Mn(Ho(be([o5.and(x({mode:$("form")})),i5.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"]),qCe=g(),a5=x({serverId:qCe,_meta:b(P(g(),T()).nullish(),()=>{})}),G1=g(),QR=x({connectionId:G1,method:g(),params:P(g(),T()).nullish(),_meta:b(P(g(),T()).nullish(),()=>{})}),c5=x({connectionId:G1,_meta:b(P(g(),T()).nullish(),()=>{})}),GCe=T(),qwr=x({id:dh,method:g(),params:be([Q8,s5,a5,QR,c5,GCe]).nullish()}),BCe=fr().gte(0).lte(65535),WCe=x({name:g(),title:b(g().nullish(),()=>{}),version:g(),_meta:b(P(g(),T()).nullish(),()=>{})}),ovt=x({_meta:b(P(g(),T()).nullish(),()=>{})}),ivt=x({_meta:b(P(g(),T()).nullish(),()=>{})}),svt=x({_meta:b(P(g(),T()).nullish(),()=>{})}),avt=x({image:b(ovt.nullish(),()=>{}),audio:b(ivt.nullish(),()=>{}),embeddedContext:b(svt.nullish(),()=>{}),_meta:b(P(g(),T()).nullish(),()=>{})}),cvt=x({_meta:b(P(g(),T()).nullish(),()=>{})}),lvt=x({_meta:b(P(g(),T()).nullish(),()=>{})}),uvt=x({_meta:b(P(g(),T()).nullish(),()=>{})}),dvt=x({stdio:b(cvt.nullish(),()=>{}),http:b(lvt.nullish(),()=>{}),acp:b(uvt.nullish(),()=>{}),_meta:b(P(g(),T()).nullish(),()=>{})}),pvt=x({_meta:b(P(g(),T()).nullish(),()=>{})}),fvt=x({_meta:b(P(g(),T()).nullish(),()=>{})}),mvt=x({_meta:b(P(g(),T()).nullish(),()=>{})}),hvt=x({prompt:b(avt.nullish(),()=>{}),mcp:b(dvt.nullish(),()=>{}),delete:b(pvt.nullish(),()=>{}),additionalDirectories:b(fvt.nullish(),()=>{}),fork:b(mvt.nullish(),()=>{}),_meta:b(P(g(),T()).nullish(),()=>{})}),gvt=x({_meta:b(P(g(),T()).nullish(),()=>{})}),yvt=x({_meta:b(P(g(),T()).nullish(),()=>{})}),bvt=x({_meta:b(P(g(),T()).nullish(),()=>{})}),xvt=be([$("full"),$("incremental")]),Svt=x({syncKind:xvt,_meta:b(P(g(),T()).nullish(),()=>{})}),kvt=x({_meta:b(P(g(),T()).nullish(),()=>{})}),_vt=x({_meta:b(P(g(),T()).nullish(),()=>{})}),wvt=x({_meta:b(P(g(),T()).nullish(),()=>{})}),vvt=x({didOpen:b(bvt.nullish(),()=>{}),didChange:b(Svt.nullish(),()=>{}),didClose:b(kvt.nullish(),()=>{}),didSave:b(_vt.nullish(),()=>{}),didFocus:b(wvt.nullish(),()=>{}),_meta:b(P(g(),T()).nullish(),()=>{})}),Evt=x({document:b(vvt.nullish(),()=>{}),_meta:b(P(g(),T()).nullish(),()=>{})}),Rvt=x({maxCount:b(fr().gte(0).max(4294967295,{error:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),()=>{}),_meta:b(P(g(),T()).nullish(),()=>{})}),Tvt=x({_meta:b(P(g(),T()).nullish(),()=>{})}),Cvt=x({maxCount:b(fr().gte(0).max(4294967295,{error:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),()=>{}),_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({_meta:b(P(g(),T()).nullish(),()=>{})}),Avt=x({_meta:b(P(g(),T()).nullish(),()=>{})}),Ovt=x({recentFiles:b(Rvt.nullish(),()=>{}),relatedSnippets:b(Tvt.nullish(),()=>{}),editHistory:b(Cvt.nullish(),()=>{}),userActions:b(Pvt.nullish(),()=>{}),openFiles:b(Ivt.nullish(),()=>{}),diagnostics:b(Avt.nullish(),()=>{}),_meta:b(P(g(),T()).nullish(),()=>{})}),$vt=x({events:b(Evt.nullish(),()=>{}),context:b(Ovt.nullish(),()=>{}),_meta:b(P(g(),T()).nullish(),()=>{})}),VCe=be([$("utf-16"),$("utf-32"),$("utf-8")]),Mvt=x({session:b(hvt.nullish(),()=>{}),auth:b(gvt.nullish(),()=>{}),providers:b(yvt.nullish(),()=>{}),nes:b($vt.nullish(),()=>{}),positionEncoding:b(VCe.nullish(),()=>{}),_meta:b(P(g(),T()).nullish(),()=>{})}),db=g(),Dvt=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(),()=>{})}),l5=x({methodId:db,name:g(),description:b(g().nullish(),()=>{}),vars:Kn(Ve(Dvt),()=>[]),link:b(_r().nullish(),()=>{}),_meta:b(P(g(),T()).nullish(),()=>{})}),KCe=x({name:g(),value:g(),_meta:b(P(g(),T()).nullish(),()=>{})}),u5=x({methodId:db,name:g(),description:b(g().nullish(),()=>{}),args:b(Ve(g()).optional(),()=>[]),env:b(Ve(KCe).optional(),()=>[]),_meta:b(P(g(),T()).nullish(),()=>{})}),d5=x({methodId:db,name:g(),description:b(g().nullish(),()=>{}),_meta:b(P(g(),T()).nullish(),()=>{})}),Nvt=Mn(be([l5.and(x({type:$("env_var")})),u5.and(x({type:$("terminal")})),d5.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"]),p5=x({protocolVersion:BCe,info:WCe,capabilities:b(Mvt.optional().default({}),()=>({})),authMethods:b(Ve(Nvt).optional(),()=>[]),_meta:b(P(g(),T()).nullish(),()=>{})}),zvt=x({_meta:b(P(g(),T()).nullish(),()=>{})}),f5=g(),m5=be([$("anthropic"),$("openai"),$("azure"),$("vertex"),$("bedrock"),g()]),Lvt=x({apiType:m5,baseUrl:_r(),_meta:b(P(g(),T()).nullish(),()=>{})}),Fvt=x({providerId:f5,supported:Kn(Ve(m5),()=>[]),required:mr(),current:Lvt.nullish(),_meta:b(P(g(),T()).nullish(),()=>{})}),jvt=x({providers:gt(Fvt),_meta:b(P(g(),T()).nullish(),()=>{})}),Uvt=x({_meta:b(P(g(),T()).nullish(),()=>{})}),Hvt=x({_meta:b(P(g(),T()).nullish(),()=>{})}),qvt=x({_meta:b(P(g(),T()).nullish(),()=>{})}),Bp=g(),Gvt=be([$("mode"),$("model"),$("model_config"),$("thought_level"),g()]),YR=g(),ZCe=x({value:YR,name:g(),description:b(g().nullish(),()=>{}),_meta:b(P(g(),T()).nullish(),()=>{})}),Bvt=g(),Wvt=x({groupId:Bvt,name:g(),options:Kn(Ve(ZCe),()=>[]),_meta:b(P(g(),T()).nullish(),()=>{})}),Vvt=be([gt(ZCe),gt(Wvt)]),h5=x({currentValue:YR,options:Vvt}),g5=x({currentValue:mr()}),XR=Mn(Ho(be([h5.and(x({type:$("select")})),g5.and(x({type:$("boolean")})),$n(x({type:g()}),"type",["boolean","select"])]),x({configId:Bp,name:g(),description:b(g().nullish(),()=>{}),category:b(Gvt.nullish(),()=>{}),_meta:b(P(g(),T()).nullish(),()=>{})})),"type",["boolean","select"]),Kvt=x({sessionId:dn,configOptions:b(Ve(XR).optional(),()=>[]),_meta:b(P(g(),T()).nullish(),()=>{})}),Zvt=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(),()=>{})}),JCe=g(),Jvt=x({sessions:Kn(Ve(Zvt),()=>[]),nextCursor:b(JCe.nullish(),()=>{}),_meta:b(P(g(),T()).nullish(),()=>{})}),Qvt=x({_meta:b(P(g(),T()).nullish(),()=>{})}),Yvt=x({sessionId:dn,configOptions:b(Ve(XR).optional(),()=>[]),_meta:b(P(g(),T()).nullish(),()=>{})}),Xvt=x({configOptions:b(Ve(XR).optional(),()=>[]),_meta:b(P(g(),T()).nullish(),()=>{})}),eEt=x({_meta:b(P(g(),T()).nullish(),()=>{})}),tEt=x({configOptions:Kn(Ve(XR),()=>[]),_meta:b(P(g(),T()).nullish(),()=>{})}),rEt=x({_meta:b(P(g(),T()).nullish(),()=>{})}),nEt=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(),()=>{})}),oEt=x({range:k_,newText:g(),_meta:b(P(g(),T()).nullish(),()=>{})}),y5=x({suggestionId:Wp,uri:_r(),edits:gt(oEt).min(1),cursorPosition:b(ph.nullish(),()=>{}),_meta:b(P(g(),T()).nullish(),()=>{})}),b5=x({suggestionId:Wp,uri:_r(),position:ph,_meta:b(P(g(),T()).nullish(),()=>{})}),x5=x({suggestionId:Wp,uri:_r(),position:ph,newName:g(),_meta:b(P(g(),T()).nullish(),()=>{})}),S5=x({suggestionId:Wp,uri:_r(),search:g(),replace:g(),isRegex:mr().nullish(),_meta:b(P(g(),T()).nullish(),()=>{})}),iEt=Mn(be([y5.and(x({kind:$("edit")})),b5.and(x({kind:$("jump")})),x5.and(x({kind:$("rename")})),S5.and(x({kind:$("searchAndReplace")})),$n(x({kind:g(),suggestionId:Wp}),"kind",["edit","jump","rename","searchAndReplace"])]),"kind",["edit","jump","rename","searchAndReplace"]),sEt=x({suggestions:gt(iEt),_meta:b(P(g(),T()).nullish(),()=>{})}),aEt=x({_meta:b(P(g(),T()).nullish(),()=>{})}),QCe=T(),YCe=T(),cEt=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"})]),XCe=x({code:cEt,message:g(),data:b(T().optional(),()=>{})}),Gwr=be([x({id:dh,result:be([p5,zvt,jvt,Uvt,Hvt,qvt,Kvt,Jvt,Qvt,Yvt,Xvt,eEt,tEt,rEt,nEt,sEt,aEt,QCe,YCe])}),x({id:dh,error:XCe})]),B1=g(),lb=x({messageId:B1,content:S_,_meta:b(P(g(),T()).nullish(),()=>{})}),k5=x({messageId:B1,content:b(Ve(S_).nullish(),()=>{}),_meta:b(P(g(),T()).nullish(),()=>{})}),_5=x({messageId:B1,content:b(Ve(S_).nullish(),()=>{}),_meta:b(P(g(),T()).nullish(),()=>{})}),w5=x({messageId:B1,content:b(Ve(S_).nullish(),()=>{}),_meta:b(P(g(),T()).nullish(),()=>{})}),v5=x({_meta:b(P(g(),T()).nullish(),()=>{})}),lEt=be([$("end_turn"),$("max_tokens"),$("max_turn_requests"),$("refusal"),$("cancelled"),g()]),uEt=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(),()=>{})}),E5=x({stopReason:b(lEt.nullish(),()=>{}),usage:b(uEt.nullish(),()=>{}),_meta:b(P(g(),T()).nullish(),()=>{})}),R5=x({_meta:b(P(g(),T()).nullish(),()=>{})}),T5=Mn(be([v5.and(x({state:$("running")})),E5.and(x({state:$("idle")})),R5.and(x({state:$("requires_action")})),$n(x({state:g()}),"state",["idle","requires_action","running"])]),"state",["idle","requires_action","running"]),C5=x({toolCallId:U1,content:LCe,_meta:b(P(g(),T()).nullish(),()=>{})}),dEt=x({data:g(),_meta:b(P(g(),T()).nullish(),()=>{})}),pEt=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(),()=>{})}),P5=x({terminalId:H1,command:b(g().nullish(),()=>{}),cwd:b(ss.nullish(),()=>{}),output:b(dEt.nullish(),()=>{}),exitStatus:b(pEt.nullish(),()=>{}),_meta:b(P(g(),T()).nullish(),()=>{})}),I5=x({terminalId:H1,data:g(),_meta:b(P(g(),T()).nullish(),()=>{})}),pb=g(),fEt=be([$("high"),$("medium"),$("low"),g()]),mEt=be([$("pending"),$("in_progress"),$("completed"),$("cancelled"),g()]),hEt=x({content:g(),priority:fEt,status:mEt,_meta:b(P(g(),T()).nullish(),()=>{})}),A5=x({planId:pb,entries:Kn(Ve(hEt),()=>[]),_meta:b(P(g(),T()).nullish(),()=>{})}),O5=x({planId:pb,uri:_r(),_meta:b(P(g(),T()).nullish(),()=>{})}),$5=x({planId:pb,content:g(),_meta:b(P(g(),T()).nullish(),()=>{})}),gEt=Mn(be([A5.and(x({type:$("items")})),O5.and(x({type:$("file")})),$5.and(x({type:$("markdown")})),$n(x({type:g(),planId:pb}),"type",["file","items","markdown"])]),"type",["file","items","markdown"]),M5=x({plan:gEt,_meta:b(P(g(),T()).nullish(),()=>{})}),D5=x({planId:pb,_meta:b(P(g(),T()).nullish(),()=>{})}),N5=x({hint:g(),_meta:b(P(g(),T()).nullish(),()=>{})}),yEt=Mn(be([N5.and(x({type:$("text")})),$n(x({type:g()}),"type",["text"])]),"type",["text"]),bEt=x({name:g(),description:g(),input:b(yEt.nullish(),()=>{}),_meta:b(P(g(),T()).nullish(),()=>{})}),z5=x({availableCommands:Kn(Ve(bEt),()=>[]),_meta:b(P(g(),T()).nullish(),()=>{})}),L5=x({configOptions:Kn(Ve(XR),()=>[]),_meta:b(P(g(),T()).nullish(),()=>{})}),F5=x({title:b(g().nullish(),()=>{}),updatedAt:b(Qu.datetime({offset:!0}).nullish(),()=>{}),_meta:b(P(g(),T()).nullish(),()=>{})}),xEt=x({amount:rt(),currency:g().regex(/^[A-Z]{3}$/),_meta:b(P(g(),T()).nullish(),()=>{})}),j5=x({used:rt(),size:rt(),cost:b(xEt.nullish(),()=>{}),_meta:b(P(g(),T()).nullish(),()=>{})}),SEt=Mn(be([lb.and(x({sessionUpdate:$("user_message_chunk")})),k5.and(x({sessionUpdate:$("user_message")})),lb.and(x({sessionUpdate:$("agent_message_chunk")})),_5.and(x({sessionUpdate:$("agent_message")})),lb.and(x({sessionUpdate:$("agent_thought_chunk")})),w5.and(x({sessionUpdate:$("agent_thought")})),T5.and(x({sessionUpdate:$("state_update")})),C5.and(x({sessionUpdate:$("tool_call_content_chunk")})),q1.and(x({sessionUpdate:$("tool_call_update")})),P5.and(x({sessionUpdate:$("terminal_update")})),I5.and(x({sessionUpdate:$("terminal_output_chunk")})),M5.and(x({sessionUpdate:$("plan_update")})),D5.and(x({sessionUpdate:$("plan_removed")})),z5.and(x({sessionUpdate:$("available_commands_update")})),L5.and(x({sessionUpdate:$("config_option_update")})),F5.and(x({sessionUpdate:$("session_info_update")})),j5.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"]),W1=x({sessionId:dn,update:SEt,_meta:b(P(g(),T()).nullish(),()=>{})}),U5=x({elicitationId:HCe,_meta:b(P(g(),T()).nullish(),()=>{})}),eT=x({connectionId:G1,method:g(),params:b(P(g(),T()).nullish(),()=>{}),_meta:b(P(g(),T()).nullish(),()=>{})}),ePe=T(),Bwr=x({method:g(),params:be([W1,U5,eT,ePe]).nullish()}),kEt=x({_meta:b(P(g(),T()).nullish(),()=>{})}),_Et=x({terminal:b(kEt.nullish(),()=>{}),_meta:b(P(g(),T()).nullish(),()=>{})}),wEt=x({_meta:b(P(g(),T()).nullish(),()=>{})}),vEt=x({_meta:b(P(g(),T()).nullish(),()=>{})}),EEt=x({form:b(wEt.nullish(),()=>{}),url:b(vEt.nullish(),()=>{}),_meta:b(P(g(),T()).nullish(),()=>{})}),REt=x({_meta:b(P(g(),T()).nullish(),()=>{})}),TEt=x({_meta:b(P(g(),T()).nullish(),()=>{})}),CEt=x({_meta:b(P(g(),T()).nullish(),()=>{})}),PEt=x({jump:b(REt.nullish(),()=>{}),rename:b(TEt.nullish(),()=>{}),searchAndReplace:b(CEt.nullish(),()=>{}),_meta:b(P(g(),T()).nullish(),()=>{})}),IEt=x({auth:b(_Et.nullish(),()=>{}),elicitation:b(EEt.nullish(),()=>{}),nes:b(PEt.nullish(),()=>{}),positionEncodings:b(Ve(VCe).optional(),()=>[]),_meta:b(P(g(),T()).nullish(),()=>{})}),V1=x({protocolVersion:BCe,info:WCe,capabilities:b(IEt.optional().default({}),()=>({})),_meta:b(P(g(),T()).nullish(),()=>{})}),H5=x({methodId:db,_meta:b(P(g(),T()).nullish(),()=>{})}),q5=x({_meta:b(P(g(),T()).nullish(),()=>{})}),G5=x({providerId:f5,apiType:m5,baseUrl:_r(),headers:P(g(),g()).optional(),_meta:b(P(g(),T()).nullish(),()=>{})}),B5=x({providerId:f5,_meta:b(P(g(),T()).nullish(),()=>{})}),W5=x({_meta:b(P(g(),T()).nullish(),()=>{})}),AEt=x({name:g(),value:g(),_meta:b(P(g(),T()).nullish(),()=>{})}),V5=x({name:g(),url:_r(),headers:gt(AEt).optional(),_meta:b(P(g(),T()).nullish(),()=>{})}),K5=x({name:g(),serverId:qCe,_meta:b(P(g(),T()).nullish(),()=>{})}),Z5=x({name:g(),command:ss,args:gt(g()).optional(),env:gt(KCe).optional(),_meta:b(P(g(),T()).nullish(),()=>{})}),J5=Mn(be([V5.and(x({type:$("http")})),K5.and(x({type:$("acp")})),Z5.and(x({type:$("stdio")})),$n(x({type:g()}),"type",["acp","http","stdio"])]),"type",["acp","http","stdio"]),Q5=x({cwd:ss,additionalDirectories:b(Ve(ss).optional(),()=>[]),mcpServers:b(Ve(J5).optional(),()=>[]),_meta:b(P(g(),T()).nullish(),()=>{})}),Y5=x({cwd:ss.nullish(),cursor:JCe.nullish(),_meta:b(P(g(),T()).nullish(),()=>{})}),X5=x({sessionId:dn,_meta:b(P(g(),T()).nullish(),()=>{})}),e7=x({sessionId:dn,cwd:ss,additionalDirectories:b(Ve(ss).optional(),()=>[]),mcpServers:b(Ve(J5).optional(),()=>[]),_meta:b(P(g(),T()).nullish(),()=>{})}),t7=x({_meta:b(P(g(),T()).nullish(),()=>{})}),OEt=Mn(be([t7.and(x({type:$("start")})),$n(x({type:g(),_meta:b(P(g(),T()).nullish(),()=>{})}),"type",["start"])]),"type",["start"]),r7=x({sessionId:dn,cwd:ss,additionalDirectories:b(Ve(ss).optional(),()=>[]),mcpServers:b(Ve(J5).optional(),()=>[]),replayFrom:b(OEt.nullish(),()=>{}),_meta:b(P(g(),T()).nullish(),()=>{})}),n7=x({sessionId:dn,_meta:b(P(g(),T()).nullish(),()=>{})}),o7=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"]),i7=x({sessionId:dn,prompt:gt(S_),_meta:b(P(g(),T()).nullish(),()=>{})}),$Et=x({uri:_r(),name:g(),_meta:b(P(g(),T()).nullish(),()=>{})}),MEt=x({name:g(),owner:g(),remoteUrl:g(),_meta:b(P(g(),T()).nullish(),()=>{})}),s7=x({workspaceUri:b(_r().nullish(),()=>{}),workspaceFolders:gt($Et).nullish(),repository:b(MEt.nullish(),()=>{}),_meta:b(P(g(),T()).nullish(),()=>{})}),DEt=be([$("automatic"),$("diagnostic"),$("manual"),g()]),NEt=x({uri:_r(),languageId:g(),text:g(),_meta:b(P(g(),T()).nullish(),()=>{})}),zEt=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(),()=>{})}),LEt=x({uri:_r(),excerpts:gt(zEt),_meta:b(P(g(),T()).nullish(),()=>{})}),FEt=x({uri:_r(),diff:g(),_meta:b(P(g(),T()).nullish(),()=>{})}),jEt=x({action:g(),uri:_r(),position:ph,timestampMs:rt(),_meta:b(P(g(),T()).nullish(),()=>{})}),UEt=x({uri:_r(),languageId:g(),visibleRange:b(k_.nullish(),()=>{}),lastFocusedMs:b(rt().nullish(),()=>{}),_meta:b(P(g(),T()).nullish(),()=>{})}),HEt=be([$("error"),$("warning"),$("information"),$("hint"),g()]),qEt=x({uri:_r(),range:k_,severity:HEt,message:g(),_meta:b(P(g(),T()).nullish(),()=>{})}),GEt=x({recentFiles:gt(NEt).nullish(),relatedSnippets:gt(LEt).nullish(),editHistory:gt(FEt).nullish(),userActions:gt(jEt).nullish(),openFiles:gt(UEt).nullish(),diagnostics:gt(qEt).nullish(),_meta:b(P(g(),T()).nullish(),()=>{})}),a7=x({sessionId:dn,uri:_r(),version:rt(),position:ph,selection:k_.nullish(),triggerKind:DEt,context:GEt.nullish(),_meta:b(P(g(),T()).nullish(),()=>{})}),c7=x({sessionId:dn,_meta:b(P(g(),T()).nullish(),()=>{})}),Wwr=x({id:dh,method:g(),params:be([V1,H5,q5,G5,B5,W5,Q5,Y5,X5,e7,r7,n7,o7,i7,s7,a7,c7,QR,GCe]).nullish()}),l7=x({optionId:FCe,_meta:b(P(g(),T()).nullish(),()=>{})}),BEt=Mn(be([x({outcome:$("cancelled")}),l7.and(x({outcome:$("selected")})),$n(x({outcome:g()}),"outcome",["cancelled","selected"])]),"outcome",["cancelled","selected"]),WEt=x({outcome:BEt,_meta:b(P(g(),T()).nullish(),()=>{})}),VEt=be([g(),rt(),rt(),mr(),gt(g())]),u7=x({content:P(g(),VEt).nullish()}),KEt=Mn(Ho(be([u7.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"]),ZEt=x({connectionId:G1,_meta:b(P(g(),T()).nullish(),()=>{})}),JEt=x({_meta:b(P(g(),T()).nullish(),()=>{})}),Vwr=be([x({id:dh,result:be([WEt,KEt,ZEt,JEt,YCe,QCe])}),x({id:dh,error:XCe})]),d7=x({sessionId:dn,_meta:b(P(g(),T()).nullish(),()=>{})}),p7=x({sessionId:dn,uri:_r(),languageId:g(),version:rt(),text:g(),_meta:b(P(g(),T()).nullish(),()=>{})}),QEt=x({range:k_.nullish(),text:g(),_meta:b(P(g(),T()).nullish(),()=>{})}),f7=x({sessionId:dn,uri:_r(),version:rt(),contentChanges:Kn(Ve(QEt),()=>[]),_meta:b(P(g(),T()).nullish(),()=>{})}),m7=x({sessionId:dn,uri:_r(),_meta:b(P(g(),T()).nullish(),()=>{})}),h7=x({sessionId:dn,uri:_r(),_meta:b(P(g(),T()).nullish(),()=>{})}),g7=x({sessionId:dn,uri:_r(),version:rt(),position:ph,visibleRange:k_,_meta:b(P(g(),T()).nullish(),()=>{})}),y7=x({sessionId:dn,suggestionId:Wp,_meta:b(P(g(),T()).nullish(),()=>{})}),YEt=be([$("rejected"),$("ignored"),$("replaced"),$("cancelled"),g()]),b7=x({sessionId:dn,suggestionId:Wp,reason:b(YEt.nullish(),()=>{}),_meta:b(P(g(),T()).nullish(),()=>{})}),Kwr=x({method:g(),params:be([d7,p7,f7,m7,h7,g7,y7,b7,eT,ePe]).nullish()}),XEt=x({requestId:dh,_meta:b(P(g(),T()).nullish(),()=>{})}),Zwr=x({method:g(),params:XEt.nullish()});function rn(e,t){return typeof e=="object"&&e!==null?e[t]:void 0}var Jwr=Z8.and(x({type:$("tool_call")})),Qwr=J8.and(x({type:$("command")})),Ywr=W8.and(x({type:$("content")})),Xwr=V8.and(x({type:$("diff")})),evr=K8.and(x({type:$("terminal")})),e0t=U8.and(x({type:$("text")})),t0t=H8.and(x({type:$("image")})),r0t=q8.and(x({type:$("audio")})),n0t=G8.and(x({type:$("resource_link")})),o0t=B8.and(x({type:$("resource")})),tvr=cb.and(x({operation:$("add")})),rvr=cb.and(x({operation:$("delete")})),nvr=cb.and(x({operation:$("modify")})),ovr=VR.and(x({operation:$("move")})),ivr=VR.and(x({operation:$("copy")})),svr=o5.and(x({mode:$("form")})).and(x({message:g()})),avr=i5.and(x({mode:$("url")})).and(x({message:g()})),cvr=be([ZR,JR]).and(x({message:g()})),lvr=Y8.and(x({type:$("string")})),uvr=X8.and(x({type:$("number")})),dvr=e5.and(x({type:$("integer")})),pvr=t5.and(x({type:$("boolean")})),fvr=n5.and(x({type:$("array")})),mvr=r5.and(x({type:$("string")}));var hvr=l5.and(x({type:$("env_var")})),gvr=u5.and(x({type:$("terminal")})),yvr=d5.and(x({type:$("agent")})),bvr=x({methodId:db,name:g()}),xvr=h5.and(x({type:$("select")})).and(x({configId:Bp,name:g()})),Svr=g5.and(x({type:$("boolean")})).and(x({configId:Bp,name:g()})),kvr=x({configId:Bp,name:g()}),_vr=y5.and(x({kind:$("edit")})),wvr=b5.and(x({kind:$("jump")})),vvr=x5.and(x({kind:$("rename")})),Evr=S5.and(x({kind:$("searchAndReplace")})),Rvr=x({suggestionId:Wp}),i0t=lb.and(x({sessionUpdate:$("user_message_chunk")})),s0t=k5.and(x({sessionUpdate:$("user_message")})),a0t=lb.and(x({sessionUpdate:$("agent_message_chunk")})),c0t=_5.and(x({sessionUpdate:$("agent_message")})),l0t=lb.and(x({sessionUpdate:$("agent_thought_chunk")})),u0t=w5.and(x({sessionUpdate:$("agent_thought")})),d0t=T5.and(x({sessionUpdate:$("state_update")})),p0t=C5.and(x({sessionUpdate:$("tool_call_content_chunk")})),f0t=q1.and(x({sessionUpdate:$("tool_call_update")})),m0t=P5.and(x({sessionUpdate:$("terminal_update")})),h0t=I5.and(x({sessionUpdate:$("terminal_output_chunk")})),g0t=M5.and(x({sessionUpdate:$("plan_update")})),y0t=D5.and(x({sessionUpdate:$("plan_removed")})),b0t=z5.and(x({sessionUpdate:$("available_commands_update")})),x0t=L5.and(x({sessionUpdate:$("config_option_update")})),S0t=F5.and(x({sessionUpdate:$("session_info_update")})),k0t=j5.and(x({sessionUpdate:$("usage_update")})),_0t=v5.and(x({state:$("running")})),w0t=E5.and(x({state:$("idle")})),v0t=R5.and(x({state:$("requires_action")})),Tvr=A5.and(x({type:$("items")})),Cvr=O5.and(x({type:$("file")})),Pvr=$5.and(x({type:$("markdown")})),Ivr=x({planId:pb}),Avr=N5.and(x({type:$("text")})),Ovr=V5.and(x({type:$("http")})),$vr=K5.and(x({type:$("acp")})),Mvr=Z5.and(x({type:$("stdio")})),Dvr=t7.and(x({type:$("start")})),Nvr=x({type:$("id")}).and(x({value:YR})).and(x({sessionId:dn,configId:Bp})),zvr=x({type:$("boolean")}).and(x({value:mr()})).and(x({sessionId:dn,configId:Bp})),Lvr=x({value:T()}).and(x({sessionId:dn,configId:Bp})),Fvr=x({outcome:$("cancelled")}),jvr=l7.and(x({outcome:$("selected")})),Uvr=u7.and(x({action:$("accept")})),Hvr=x({action:$("decline")}),qvr=x({action:$("cancel")});var x7={isText(e){return rn(e,"type")==="text"&&e0t.safeParse(e).success},isImage(e){return rn(e,"type")==="image"&&t0t.safeParse(e).success},isAudio(e){return rn(e,"type")==="audio"&&r0t.safeParse(e).success},isResourceLink(e){return rn(e,"type")==="resource_link"&&n0t.safeParse(e).success},isResource(e){return rn(e,"type")==="resource"&&o0t.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"&&i0t.safeParse(e).success},isUserMessage(e){return rn(e,"sessionUpdate")==="user_message"&&s0t.safeParse(e).success},isAgentMessageChunk(e){return rn(e,"sessionUpdate")==="agent_message_chunk"&&a0t.safeParse(e).success},isAgentMessage(e){return rn(e,"sessionUpdate")==="agent_message"&&c0t.safeParse(e).success},isAgentThoughtChunk(e){return rn(e,"sessionUpdate")==="agent_thought_chunk"&&l0t.safeParse(e).success},isAgentThought(e){return rn(e,"sessionUpdate")==="agent_thought"&&u0t.safeParse(e).success},isStateUpdate(e){return rn(e,"sessionUpdate")==="state_update"&&d0t.safeParse(e).success},isToolCallContentChunk(e){return rn(e,"sessionUpdate")==="tool_call_content_chunk"&&p0t.safeParse(e).success},isToolCallUpdate(e){return rn(e,"sessionUpdate")==="tool_call_update"&&f0t.safeParse(e).success},isTerminalUpdate(e){return rn(e,"sessionUpdate")==="terminal_update"&&m0t.safeParse(e).success},isTerminalOutputChunk(e){return rn(e,"sessionUpdate")==="terminal_output_chunk"&&h0t.safeParse(e).success},isPlanUpdate(e){return rn(e,"sessionUpdate")==="plan_update"&&g0t.safeParse(e).success},isPlanRemoved(e){return rn(e,"sessionUpdate")==="plan_removed"&&y0t.safeParse(e).success},isAvailableCommandsUpdate(e){return rn(e,"sessionUpdate")==="available_commands_update"&&b0t.safeParse(e).success},isConfigOptionUpdate(e){return rn(e,"sessionUpdate")==="config_option_update"&&x0t.safeParse(e).success},isSessionInfoUpdate(e){return rn(e,"sessionUpdate")==="session_info_update"&&S0t.safeParse(e).success},isUsageUpdate(e){return rn(e,"sessionUpdate")==="usage_update"&&k0t.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)}},S7={isRunning(e){return rn(e,"state")==="running"&&_0t.safeParse(e).success},isIdle(e){return rn(e,"state")==="idle"&&w0t.safeParse(e).success},isRequiresAction(e){return rn(e,"state")==="requires_action"&&v0t.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===j1.cancel_request)&&!e.startsWith("_"))throw new TypeError(`Custom ACP v2 ${r} method '${e}' must start with '_'`)}function sPe(e,t,r){for(let n of e)Kp(n.method,n.kind==="request"?t:r,n.kind,n.kind==="notification")}function aPe(e){let t=V1.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 cPe(e){let t=typeof e=="object"&&e!==null&&!Array.isArray(e)?e:{};return aPe({...t,protocolVersion:Gp})}function lPe(e){let t=p5.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 R0t(e){return e.map(t=>{if(t.kind!=="request"||t.method!==ct.initialize)return t;let r=t.mapResponse;return{...t,params:cPe(t.params),mapResponse:n=>{let o=lPe(n);return r?r(o):o}}})}function uPe(e){return typeof e=="object"&&e!==null&&"readable"in e&&"writable"in e}function dPe(){let e=new TransformStream,t=new TransformStream;return[{readable:t.readable,writable:e.writable},{readable:e.readable,writable:t.writable}]}var gEr={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:j1.cancel_request}},pPe=Symbol("startActiveSession"),J1=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 J1{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,eN,"notification",!0),this.sendNotification(t,r)}batch(t){return sPe(t,nT,eN),this.sendBatch(t)}},iT=class e extends J1{constructor(t,r){super(t,r)}static create(t,r){return new e(t,r)}[pPe](t,r){return this.sendRequest(ct.session_new,t,n=>this.attachSession(n),r)}buildSession(t){return typeof t=="string"?Y1.create(this,{cwd:t,mcpServers:[]}):Y1.create(this,t)}attachSession(t){let r=new w7,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=bPe(this.connectionContext).attach(t,o),c=new Dp(()=>{i.removeEventListener("abort",s)});return v7.create(this,t,o,[a,c])}request(t,r,n){Kp(t,rT,"request");let o=rT[t],i=t===ct.initialize?cPe(r):r;return this.sendRequest(t,i,o?.mapResponse,n)}notify(t,r){return Kp(t,X1,"notification",!0),this.sendNotification(t,r)}batch(t){return sPe(t,rT,X1),this.sendBatch(R0t(t))}},Q1=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)}},k7=class extends Q1{connectHandlers;client;didStartConnectHandlers=!1;constructor(t,r=[]){super(t),this.connectHandlers=r,this.client=oT.create(t.getContext())}startConnectHandlers(){this.didStartConnectHandlers||(this.didStartConnectHandlers=!0,nN(this,this.connectHandlers))}},_7=class extends Q1{connectHandlers;agent;didStartConnectHandlers=!1;constructor(t,r=[]){super(t),this.connectHandlers=r,this.agent=iT.create(t.getContext())}startConnectHandlers(){this.didStartConnectHandlers||(this.didStartConnectHandlers=!0,nN(this,this.connectHandlers))}};function fPe(e,t=[]){return new k7(e,t)}function mPe(e,t=[]){return new _7(e,t)}var w7=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 rPe(e){return structuredClone(e)}var Y1=class e{cx;request;constructor(t,r){this.cx=t,this.request=rPe(r)}static create(t,r){return new e(t,r)}toRequest(){return rPe(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[pPe](this.toRequest(),t)}async withSession(t){let r=await this.start();try{return await t(r)}finally{r.dispose()}}},v7=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(x7.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 hPe(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 gPe(e,t,r,n){e.onReceiveRequest(t.method,o=>hPe(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 yPe(e,t,r,n){e.onReceiveNotification(t.method,o=>hPe(t.params,o),(o,i)=>n(r(o,i,i.signal)))}function rN(e){let t=Object.create(null);for(let r of Object.values(e))t[r.method]=r;return t}var T0t={initialize:ao(ct.initialize,aPe,lPe),loginAuth:ao(ct.auth_login,H5,Vp),unstable_listProviders:ao(ct.providers_list,q5),unstable_setProvider:ao(ct.providers_set,G5,Vp),unstable_disableProvider:ao(ct.providers_disable,B5,Vp),newSession:ao(ct.session_new,Q5),setSessionConfigOption:ao(ct.session_set_config_option,o7),prompt:ao(ct.session_prompt,i7,Vp),unstable_messageMcp:ao(ct.mcp_message,QR),listSessions:ao(ct.session_list,Y5),deleteSession:ao(ct.session_delete,X5,Vp),unstable_forkSession:ao(ct.session_fork,e7),resumeSession:ao(ct.session_resume,r7),closeSession:ao(ct.session_close,n7,Vp),logoutAuth:ao(ct.auth_logout,W5,Vp),unstable_startNes:ao(ct.nes_start,s7),unstable_suggestNes:ao(ct.nes_suggest,a7),unstable_closeNes:ao(ct.nes_close,c7,Vp)},C0t={cancelSession:qc(ct.session_cancel,d7),unstable_messageMcp:qc(ct.mcp_message,eT),unstable_didOpenDocument:qc(ct.document_did_open,p7),unstable_didChangeDocument:qc(ct.document_did_change,f7),unstable_didCloseDocument:qc(ct.document_did_close,m7),unstable_didSaveDocument:qc(ct.document_did_save,h7),unstable_didFocusDocument:qc(ct.document_did_focus,g7),unstable_acceptNes:qc(ct.nes_accept,y7),unstable_rejectNes:qc(ct.nes_reject,b7)},P0t={requestPermission:ao(vi.session_request_permission,Q8),unstable_connectMcp:ao(vi.mcp_connect,a5),unstable_messageMcp:ao(vi.mcp_message,QR),unstable_disconnectMcp:ao(vi.mcp_disconnect,c5,Vp),unstable_createElicitation:ao(vi.elicitation_create,s5)},I0t={sessionUpdate:qc(vi.session_update,W1),unstable_messageMcp:qc(vi.mcp_message,eT),unstable_completeElicitation:qc(vi.elicitation_complete,U5)},rT=rN(T0t),X1=rN(C0t),nT=rN(P0t),eN=rN(I0t);function A0t(e,t,r,n){return{params:e,requestId:n,signal:r,client:t}}function O0t(e,t,r){return{params:e,signal:r,client:t}}function $0t(e,t,r,n){return{params:e,requestId:n,signal:r,agent:t}}function M0t(e,t,r){return{params:e,signal:r,agent:t}}var E7=class{activeSessions=new Map;handleMessage(t){if(t.kind!=="notification"||t.method!==vi.session_update)return Mc.no(t);let r=W1.parse(t.params),{update:n}=r,o=tT.isStateUpdate(n)&&S7.isIdle(n),i=this.activeSessions.get(r.sessionId);if(i&&i.size>0)for(let s of i)o&&s.isAwaitingPromptCompletion()?(s.completePrompt(),s.enqueue({kind:"stop",notification:r,update:n,stopReason:n.stopReason})):s.enqueue({kind:"session_update",notification:r,update:n});return Mc.no(t)}attach(t,r){let n=this.activeSessions.get(t.sessionId)??new Set;return n.add(r),this.activeSessions.set(t.sessionId,n),new Dp(()=>{n.delete(r),n.size===0&&this.activeSessions.delete(t.sessionId)})}},nPe=new WeakMap;function bPe(e){let t=nPe.get(e);return t||(t=new E7,nPe.set(e,t)),t}function nN(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 tN=Symbol("appBuilder"),K1=Symbol("runAgentConnectHandlers"),Z1=Symbol("runClientConnectHandlers");var oPe=class{builder=Np.builder();connectHandlers=[];constructor(t={}){t.name&&this.builder.name(t.name)}[tN](){return this.builder}[K1](t){nN(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,X1,"notification",!0),this.notification({method:t,params:r},n);let o=X1[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 gPe(this.builder,t,(n,o,i,s)=>A0t(n,oT.create(o,s),i,s),r),this}notification(t,r){return yPe(this.builder,t,(n,o,i)=>O0t(n,oT.create(o),i),r),this}connectConnection(t,r={}){if(uPe(t)){let c=this.openStreamConnection(t);return r.deferConnectHandlers||this[K1](c.connection),c}let[n,o]=dPe(),i=t[tN]().connect(o),s=mPe(i),a=this.openStreamConnection(n);a.rawConnection.closed.then(()=>s.close()),i.closed.then(()=>a.connection.close());try{t[Z1](s),this[K1](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:fPe(r,this.connectHandlers)}}};var iPe=class{builder=Np.builder();connectHandlers=[];constructor(t={}){t.name&&this.builder.name(t.name),this.builder.withHandler({handleMessage:(r,n)=>bPe(n).handleMessage(r),describe:()=>"client-session-update-router"})}[tN](){return this.builder}[Z1](t){nN(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,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 gPe(this.builder,t,(n,o,i,s)=>$0t(n,iT.create(o,s),i,s),r),this}notification(t,r){return yPe(this.builder,t,(n,o,i)=>M0t(n,iT.create(o),i),r),this}connectConnection(t){if(uPe(t)){let a=this.openStreamConnection(t);return this[Z1](a.connection),a}let[r,n]=dPe(),o=t[tN]().connect(n),i=fPe(o),s=this.openStreamConnection(r);s.rawConnection.closed.then(()=>i.close()),o.closed.then(()=>s.connection.close());try{t[K1](i),this[Z1](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:mPe(r,this.connectHandlers)}}};var xPe=1;var SPe=["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"},REr=Object.values(Ms);var N0t=16e3,z0t={type:"object",additionalProperties:!1,required:["demand"],properties:{demand:{type:"string",minLength:1,maxLength:N0t,description:"The one-off demand this dispatch exists to satisfy."}}},L0t={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}}},IEr={version:1,method:Ms.goDispatch,params:z0t,answer:L0t};var F0t=64,kPe=200,j0t=/^[a-z0-9][a-z0-9._-]*$/;var U0t={type:"object",additionalProperties:!1,required:["slug"],properties:{slug:{type:"string",minLength:1,maxLength:F0t,pattern:j0t.source,description:"What the human is about to work on; becomes the worktree directory name."},branch:{type:"string",minLength:1,maxLength:kPe,description:"Branch to create; defaults to the daemon's convention for the slug."},base:{type:"string",minLength:1,maxLength:kPe,description:"Trunk BRANCH to fork from; the remote is the Project's registered trunk remote."}}},H0t={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}}},q0t={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}}}}}},GEr={version:1,methods:{add:Ms.worktreeAdd,list:Ms.worktreeList},add:{params:U0t,answer:H0t},list:{answer:q0t}};sT();var Q0t={drain:Ms.projectDrain,stop:Ms.projectStop,status:Ms.projectStatus};async function C7(e={}){let t=e.cwd??process.cwd(),r=e.name??"RedSkills Project client",n=e.version??"1",o=e.paths??oN();await WR(o);let i=(await ab(o)).paths,s=await tRt(i.acpSocketPath),a=[],c="",l=Yve({name:r}).onNotification(nh.client.session.update,async({params:f})=>{f.sessionId===c&&(a.push(f.update),await e.onUpdate?.(f.update))});e.requestPermission!=null&&(l=l.onRequest(nh.client.session.requestPermission,({params:f})=>e.requestPermission(f)));let u=l.connect(k9(J0t.toWeb(s),Z0t.toWeb(s)));return await u.agent.request(nh.agent.initialize,{protocolVersion:1,clientCapabilities:{},clientInfo:{name:r,version:n},_meta:{redskills:{wireMajor:xPe}}}),c=(await u.agent.request(nh.agent.session.new,{cwd:t,mcpServers:[]})).sessionId,{control:async(f,m={})=>{let y=await u.agent.request(Q0t[f],{...m.target==null?{}:{target:m.target},...m.runner==null?{}:{runner:m.runner},...m.registration==null?{}:{registration:m.registration}});if(!CPe(y))throw new Error("redskilled returned an invalid Project control outcome");if(f==="status"&&!X0t(y))throw new Error("redskilled returned Project status without a valid RedSkills context");return y},github(f){return u.agent.request(Ms.githubRequest,{request:f})},brain(f){return u.agent.request(Ms.brainCall,{tool:f.tool,arguments:f.arguments})},memory(f){return u.agent.request(Ms.memoryCall,{tool:f.tool,arguments:f.arguments,...f.mode==null?{}:{mode:f.mode}})},async prompt(f){let m=a.length,y=await u.agent.request(nh.agent.session.prompt,{sessionId:c,prompt:[{type:"text",text:f}]});return{stopReason:y.stopReason,...Y0t(y._meta),updates:a.slice(m)}},cancel(){return u.agent.notify(nh.agent.session.cancel,{sessionId:c})},async permission(f){return e.requestPermission==null?{outcome:{outcome:"cancelled"},_meta:{redskills:{permissionResolution:"hitl-required"}}}:await e.requestPermission(f)},close(){u.close(),s.destroy()}}}function Y0t(e){let r=Jp(Jp(e)?.redskills)?.projectControl;return CPe(r)?{projectControl:r}:{}}function CPe(e){let t=Jp(e);return t?.version===1&&typeof t.project_id=="string"&&typeof t.revision=="number"&&Array.isArray(t.updates)}function X0t(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(eRt)&&(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 eRt(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 tRt(e){return await new Promise((t,r)=>{let n=K0t(e);n.once("connect",()=>t(n)),n.once("error",r)})}pee();gd();sre();D_();gd();var Vz=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)}};are();var Jz=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(oX,n=>this._oninitialize(n)),this.setNotificationHandler(sX,()=>this.oninitialized?.()),this._capabilities.logging&&this.setRequestHandler(vX,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 Vz(this)}),this._experimental}registerCapabilities(t){if(this.transport)throw new Error("Cannot register capabilities after connecting to transport");this._capabilities=pz(this._capabilities,t)}setRequestHandler(t,r){let o=md(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(hd,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){Zz(this._clientCapabilities?.tasks?.requests,t,"Client")}assertTaskHandlerCapability(t){this._capabilities&&Kz(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:FN.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},CX,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_();dee();gd();var FDe=Symbol.for("mcp.completable");function cre(e){return!!e&&typeof e=="object"&&FDe in e}function jDe(e){return e[FDe]?.complete}var LDe;(function(e){e.Completable="McpCompletable"})(LDe||(LDe={}));var V1t=/^[A-Za-z0-9._-]{1,128}$/;function K1t(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"),!V1t.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 Z1t(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 lre(e){let t=K1t(e);return Z1t(e,t.warnings),t.isValid}var Qz=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 Jz(t,r)}get experimental(){return this._experimental||(this._experimental={tasks:new Qz(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(ez)),this.server.assertCanSetRequestHandler(Ah(j_)),this.server.registerCapabilities({tools:{listChanged:!0}}),this.server.setRequestHandler(ez,()=>({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?cee(o,{strictUnions:!0,pipeStrategy:"input"}):J1t})(),annotations:r.annotations,execution:r.execution,_meta:r._meta};if(r.outputSchema){let o=M_(r.outputSchema);o&&(n.outputSchema=cee(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 $N(i,r);if(!s.success){let a="error"in s?s.error:"Unknown error",c=MN(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 $N(o,r.structuredContent);if(!i.success){let s="error"in i?i.error:"Unknown error",a=MN(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(tz)),this.server.registerCapabilities({completions:{}}),this.server.setRequestHandler(tz,async t=>{switch(t.params.ref.type){case"ref/prompt":return cOe(t),this.handlePromptCompletion(t,t.params.ref);case"ref/resource":return lOe(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=md(n.argsSchema)?.[t.params.argument.name];if(!cre(i))return mC;let s=jDe(i);if(!s)return mC;let a=await s(t.params.argument.value,t.params.context);return HDe(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 HDe(i)}setResourceRequestHandlers(){this._resourceHandlersInitialized||(this.server.assertCanSetRequestHandler(Ah(L_)),this.server.assertCanSetRequestHandler(Ah(QN)),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(QN,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(YN)),this.server.assertCanSetRequestHandler(Ah(XN)),this.server.registerCapabilities({prompts:{listChanged:!0}}),this.server.setRequestHandler(YN,()=>({prompts:Object.entries(this._registeredPrompts).filter(([,t])=>t.enabled).map(([t,r])=>({name:t,title:r.title,description:r.description,arguments:r.argsSchema?Q1t(r.argsSchema):void 0}))})),this.server.setRequestHandler(XN,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 $N(o,t.params.arguments);if(!i.success){let c="error"in i?i.error:"Unknown error",l=MN(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 cre(l)})&&this.setCompletionRequestHandler(),s}_createRegisteredTool(t,r,n,o,i,s,a,c,l){lre(t);let u={title:r,description:n,inputSchema:UDe(o),outputSchema:UDe(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"&&lre(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(ure(c))o=r.shift(),r.length>1&&typeof r[0]=="object"&&r[0]!==null&&!ure(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 J1t={type:"object",properties:{}};function qDe(e){return e!==null&&typeof e=="object"&&"parse"in e&&typeof e.parse=="function"&&"safeParse"in e&&typeof e.safeParse=="function"}function GDe(e){return"_def"in e||"_zod"in e||qDe(e)}function ure(e){return typeof e!="object"||e===null||GDe(e)?!1:Object.keys(e).length===0?!0:Object.values(e).some(qDe)}function UDe(e){if(e){if(ure(e))return Db(e);if(!GDe(e))throw new Error("inputSchema must be a Zod schema or raw shape, received an unrecognized object");return e}}function Q1t(e){let t=md(e);return t?Object.entries(t).map(([r,n])=>{let o=yAe(n),i=bAe(n);return{name:r,description:o,required:!i}}):[]}function Ah(e){let r=md(e)?.method;if(!r)throw new Error("Schema is missing a method literal");let n=DN(r);if(typeof n=="string")return n;throw new Error("Schema method literal must be a string")}function HDe(e){return{completion:{values:e.slice(0,100),total:e.length,hasMore:e.length>100}}}var mC={completion:{values:[],hasMore:!1}};dre();import BDe from"node:process";var hC=class{constructor(t=BDe.stdin,r=BDe.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=Yz(t);this._stdout.write(n)?r():this._stdout.once("drain",r)})}};import{resolve as P$}from"node:path";import{fileURLToPath as qdt}from"node:url";Jn();function WDe(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 pre(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)?e:null}function fre(e){return typeof e=="string"&&e.trim()!==""?e:null}function X1t(e){let t=pre(e);if(t===null)return null;let r=pre(t.demand);return fre(r?.refusal)??fre(t.latest_refusal)}function VDe(e){return{tool:"status",args:{scope:"project"},why:e}}function eNt(){return{tool:"status",args:{scope:"host"},why:"diagnose why the host daemon does not answer before changing registration"}}function tNt(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"}:VDe(t!==null?"observe when the daemon's refusal clears and capacity begins draining again":"observe the next socket-local queue poll and Worker birth"):eNt()}function rNt(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 nNt(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 KDe(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=rNt(r),i=X1t(n),s=tNt(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:fre(pre(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:nNt(t())}}}]}Jn();function ZDe(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 oNt=["requeue","retake","park","close"];function JDe(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(oNt),rationale:w.string().min(1)},invoke:t=>e.hitlResolve(t)}]}Jn();var Xz="2.0.0";function eL(e,t){return{version:Xz,schema:e,projection:t}}var COr=w.object({age_s:w.number(),stale:w.boolean(),stale_after_s:w.number(),reason:w.enum(["fresh","aged-out","never-observed","orphaned"])}),iNt=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"])}),sNt=w.object({tool:w.string().min(1),args:w.record(w.string(),w.unknown()),why:w.string().min(1)}),aNt=w.union([sNt,w.literal("none")]),cNt=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:aNt.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:iNt.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"})}),lNt=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()})}),uNt=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:cNt,validation_schedule:uNt,birth_latch:lNt.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()}),dNt=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()}),pNt=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()}),fNt=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()})}),YDe=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:dNt}),live:w.boolean(),active:w.boolean(),renderable_live:w.boolean(),liveness:w.enum(["active","quiet-but-live","dead"]),liveness_verdict:pNt,daemon_liveness:fNt.optional()}),tL=w.array(YDe),rL=w.array(YDe.partial()),mNt=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(mNt),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()}),QDe=w.object({number:w.number(),title:w.string(),labels:w.array(w.string())}),XDe=w.object({ready_for_agent:w.object({eligible:w.array(QDe),held_for_summon:w.array(QDe)}),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()}))}),e1e=eL(gC),POr=eL(tL,{input:"fields",schema:rL}),IOr=eL(yC),t1e=eL(XDe);function hNt(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 r1e(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=hNt(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 n1e="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`).",mre=class extends Error{constructor(t){super(t===void 0||t===""?n1e:`fleet ${JSON.stringify(t)}: ${n1e}`),this.name="FleetNamingRemovedError"}};function lw(e){if(!(e==null||e===""))throw new mre(typeof e=="string"?e:String(e))}Jn();var gNt=w.object({tool:w.literal("status"),args:w.object({scope:w.enum(["worker","project","host"])})});function o1e(e){return w.object({deprecated:w.literal(!0),message:w.string().min(1),replacement:gNt,result:e})}function s1e(e){return{version:e.version,schema:o1e(e.schema),...e.projection===void 0?{}:{projection:{input:e.projection.input,schema:o1e(e.projection.schema)}}}}var yNt=w.object({status:w.unknown(),vitals:tL,monitor:yC}),bNt=w.object({status:w.unknown(),vitals:rL,monitor:yC}),i1e=w.object({state:w.unknown(),dashboard:w.unknown(),provision_check:w.unknown(),unit_status:w.unknown()}),xNt={version:Xz,schema:w.union([gC,yNt,i1e]),projection:{input:"fields",schema:w.union([gC,bNt,i1e])}};function a1e(e,t,r){return{deprecated:!0,message:`${e} is deprecated; use status { scope: ${t} }`,replacement:{tool:"status",args:{scope:t}},result:r}}async function SNt(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 c1e(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:xNt,invoke:t=>SNt(e,t)}]}nL();var oL={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 d1e=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 p1e(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:s1e(e1e),invoke:async({fleet:t})=>(lw(t),a1e("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(oL).optional(),config:d1e.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(oL).optional(),config:d1e.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 f1e(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 m1e(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 h1e(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 g1e(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 y1e(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(oL).optional()},outputContract:t1e,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 b1e(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 x1e(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 gre(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 yre={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 bre(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 S1e(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:yre,invoke:t=>{let r;try{r=bre(t)}catch(n){return Promise.resolve(gre(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 k1e(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:{...yre,text:w.string().min(1)},invoke:t=>{let r;try{r=bre(t)}catch(n){return Promise.resolve(gre(n))}return e.workerRequest({...r,text:t.text})}}]}function _1e(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 w1e(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 v1e(e,t){return t==="allow"?e:e.map(r=>{if(!r.dangerClass)return r;if(t==="deny")return{...r,invoke:async i=>w1e("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 w1e("confirm",r.name,i);let{confirmation:s,...a}=i;return o(a)}}})}Jn();function E1e(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 R1e(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 T1e(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 iL="Call the redskilled MCP's `help` tool.\nFollow its guidance and invoke the returned `next` call.",xre=[{name:"drain",title:"Drain this project's queue",description:"Find the next action for starting or continuing a project drain.",body:iL},{name:"diagnose",title:"Diagnose redskilled",description:"Find the next action for understanding a redskilled problem.",body:iL},{name:"configure",title:"Configure redskilled",description:"Find the next action for changing project execution configuration.",body:iL},{name:"stop",title:"Stop project work",description:"Find the next action for stopping project work safely.",body:iL}];var C1e="rs_dev";function P1e(e,t="allow"){let r=[],n=[...KDe(e,()=>r),...c1e(e),...p1e(e),...y1e(e),...m1e(e),...S1e(e),...k1e(e),...h1e(e),...f1e(e),...g1e(e),...WDe(e),...ZDe(e),...JDe(e),...R1e(e),...E1e(e),...x1e(e),..._1e(e),...b1e(e),...T1e(e)];return r=v1e(r1e(n),t),r}Yt();function uw(e){return tn(JSON.parse(JSON.stringify(e??null)),{objectArrayColumns:!0,primitiveArrayColumns:!0})}var kNt=new Map([["drain","drain"],["project_drain","drain"],["project_stop","stop"],["project_status","status"],["status","status"]]),_Nt=new Set(["target","runner","scope","registration","live_only","fields","worker"]);async function I1e(e,t,r){let n=kNt.get(t);if(n!=null){let o=Object.keys(r).filter(i=>!_Nt.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,wNt(r))}if(!ENt(t))throw new Error(`unsupported ACP Project capability ${JSON.stringify(t)}`);return await e.prompt(vNt(t,r))}function wNt(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 vNt(e,t){return`/${e} ${JSON.stringify(t)}`}function ENt(e){return/^[a-z][a-z0-9_]*$/.test(e)&&!e.startsWith("private_")&&!e.includes("worker_birth")&&!e.includes("daemon_protocol")&&!e.includes("github_client")}vre();nL();import{execFileSync as Dzt}from"node:child_process";wR();_d();function oNe(e){let t=sNe(e.repo).join("/"),r=e.selector??{},n=[`repo:${t}`,"is:issue","is:open",cL(e.readyLabel??su)];r.lane!=null&&r.lane!==""&&n.push(cL(`lane:${r.lane}`)),r.label!=null&&r.label!==""&&n.push(cL(r.label));for(let o of r.tags??[])o!==""&&n.push(cL(`${Rre}${o}`));return r.user!=null&&r.user!==""&&r.user!=="@me"&&n.push(`author:${r.user}`),n.join(" ")}function iNe(e){let[t,r]=sNe(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(`${Rre}${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 cL(e){return`label:${JSON.stringify(e)}`}function sNe(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 GNt="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 aNe(e){let t={repo:e.repo,...e.selector==null?{}:{selector:e.selector},...e.readyLabel==null?{}:{readyLabel:e.readyLabel}};return{selector:oNe(t),queue_poll:iNe(t),argv:Fp("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:GNt,...e.validationCommands==null||e.validationCommands.length===0?{}:{validation_commands:[...e.validationCommands]},target:e.target}}wC();lf();function _ze(e,t,r={},n=wre){let o=zzt(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=Nzt(e);return aNe({repo:o,workspacePath:e,target:i,version:t,...s==null?{}:{runner:s},...kze(e)==null?{}:{trunkBranch:kze(e)},...a.length===0?{}:{validationCommands:a}})}function Nzt(e){try{let t=Sze(_C(cu(e).configPath,{warn:()=>{}}));return[...t.post_done??[],...t.landing??[]]}catch{return[]}}function kze(e){try{let r=Dzt("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 zzt(e,t=wre){let r;try{r=t(e).name}catch{return}return/^[^/\s]+\/[^/\s]+$/.test(r)?r:void 0}gd();var hw="redskilled://lanes/events",Lzt=1e3;function wze(e,t,r={}){let n=r.bufferLimit??Lzt,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=Jre(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(fX,async c=>Jre(c)!==hw?{}:(i+=1,i===1&&(s=await t.subscribe(a),t.start(r.intervalMs)),{})),e.setRequestHandler(mX,c=>Jre(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 Jre(e){let t=e?.params;return typeof t?.uri=="string"?t.uri:""}function Eze(e){let t=new Set,r,n,o=async()=>{let s=await e("events_since",r===void 0?{}:{cursor:r});if(!vze(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(vze):[];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 vze(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}Jn();var Qre="rs_github",Rze="github_request",yL=Ms.githubRequest;function Yre(){return[{name:Rze,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:yL,inputSchema:{method:w.enum(SPe),path:w.string().min(1),body:w.record(w.unknown()).optional(),headers:w.record(w.string()).optional()}}]}function Tze(e){return{request:{method:e.method,path:e.path,...e.body===void 0?{}:{body:e.body},...e.headers===void 0?{}:{headers:e.headers}}}}function Xre(e){let t=new aw({name:Qre,version:e.version}),r=t.registerTool.bind(t);for(let n of e.tools??Yre())r(n.name,{title:n.title,description:n.description,inputSchema:n.inputSchema},async o=>({content:[{type:"text",text:uw(await e.invoke(n.method,Tze(o)))}]}));return t}var dk=YW("redskilled-mcp");function Ulr(e=process.cwd(),t){let r=new aw({name:C1e,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:_ze(e,dk.version,c)}:c;for(let a of P1e(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 xre)r.registerPrompt(a.name,{title:a.title,description:a.description},async()=>({messages:[{role:"user",content:{type:"text",text:a.body}}]}));return wze(r.server,Eze(o)),r}async function Gdt(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$(qdt(i.uri))}catch{}return P$(r)}async function Bdt(e){let t,r=new Promise(n=>{t=n});e.server.server.onclose=t,await e.server.connect(e.transport),await r}async function Hlr(){let e=process.cwd(),t,r,n=()=>(t??=Gdt(r.server,process.env,e).then(i=>C7({cwd:i,name:"RedSkills GitHub MCP adapter",version:dk.version})),t);r=Xre({version:dk.version,invoke:async(i,s)=>{if(i!==yL)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 Bdt({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 qlr(){let e=process.cwd(),t,r,n=()=>(t??=Gdt(r.server,process.env,e).then(i=>C7({cwd:i,name:"RedSkills MCP adapter",version:dk.version})),t);r=Ulr(e,async(i,s)=>I1e(await n(),i,s));let o=()=>{r.close()};process.once("SIGINT",o),process.once("SIGTERM",o);try{await Bdt({server:r,transport:new hC})}finally{if(t!==void 0)try{(await t).close()}catch{}process.removeListener("SIGINT",o),process.removeListener("SIGTERM",o)}}var Glr=`Usage: red-skills-redskilled-mcp [command]
|
|
445
445
|
|
|
446
446
|
Commands:
|
|
447
447
|
(none) serve the rs_dev MCP surface over stdio
|