@yukino.js/yukino 0.0.19 → 0.0.21-dev
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/README.md +36 -65
- package/dist/anthropic-LB4T3BEN.js +4 -0
- package/dist/browser/dist/index.html +2 -2
- package/dist/browser/dist/static/chunk-3HWUJ4KR.js +1 -0
- package/dist/browser/dist/static/{highlight-ZDY7K2CR.js → highlight-KNDEBJWF.js} +10 -10
- package/dist/browser/dist/static/index.css +1 -1
- package/dist/browser/dist/static/index.js +40 -40
- package/dist/chunk-2N7OIUQW.js +884 -0
- package/dist/{chunk-QDMUFOED.js → chunk-57IGGFHK.js} +6 -6
- package/dist/chunk-5AOJ5ZSQ.js +30 -0
- package/dist/chunk-5D3QKHYQ.js +36 -0
- package/dist/{chunk-PYFRT6N5.js → chunk-7WP7SERS.js} +1 -1
- package/dist/{chunk-S56AXDDN.js → chunk-EQABLL4S.js} +1 -1
- package/dist/{chunk-UX5DJPHN.js → chunk-P6K7EQHF.js} +29 -29
- package/dist/{chunk-WGRGSG2J.js → chunk-QSKJBSCI.js} +1 -1
- package/dist/chunk-WKTO7XPO.js +4 -0
- package/dist/lib/{anthropic-I7ZSAP7Z.js → anthropic-TYBMDJP3.js} +3 -3
- package/dist/lib/{chunk-T4WEXOQ7.js → chunk-3QGT2MSI.js} +1 -83
- package/dist/lib/{chunk-MJHQUFUL.js → chunk-IPKULHXR.js} +2 -2
- package/dist/lib/{chunk-UU6ZV6GB.js → chunk-NIUCGP4C.js} +82 -241
- package/dist/lib/{chunk-TO34ITLQ.js → chunk-OPEO6D4O.js} +2 -5
- package/dist/lib/chunk-XVXFUSSS.js +217 -0
- package/dist/lib/index.d.ts +1024 -1720
- package/dist/lib/index.js +5859 -9076
- package/dist/lib/{openai-Y4P7SWUB.js → openai-Z2JCYL6F.js} +3 -3
- package/dist/lib/{chunk-YZURLYHG.js → providers-2NPR2VR4.js} +28 -207
- package/dist/{main-MHJXHOY6.js → main-OMIZDIYB.js} +211 -275
- package/dist/main.js +4 -6
- package/dist/{openai-3IGA2BCD.js → openai-UOCUBMFA.js} +1 -1
- package/dist/{chunk-7WYSSZKU.js → providers-G5SKN22T.js} +9 -9
- package/dist/server-ESDMJACZ.js +14 -0
- package/dist/server-Z742CQSK.js +4 -0
- package/package.json +4 -6
- package/dist/anthropic-D72CIYEQ.js +0 -4
- package/dist/chunk-676RWZYX.js +0 -38
- package/dist/chunk-A4IB5PNW.js +0 -8
- package/dist/chunk-BCYFGWSM.js +0 -30
- package/dist/chunk-DGDF5PBF.js +0 -869
- package/dist/lib/providers-MRGAAMBB.js +0 -10
- package/dist/providers-GRYPIKCY.js +0 -4
- package/dist/server-XBVP3S5Q.js +0 -4
- package/dist/server-ZYP54JBK.js +0 -15
- package/dist/stdio-UHDEALLA.js +0 -5
- package/dist/websocket-J5DE5FRQ.js +0 -9
package/dist/chunk-676RWZYX.js
DELETED
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
import { createRequire as __yukinoCreateRequire } from "node:module";
|
|
3
|
-
const require = __yukinoCreateRequire(import.meta.url);
|
|
4
|
-
import{Mc as en,Sa as Dn,a as Nn,e as kn,h as Mn,j as De,m as Pn}from"./chunk-BCYFGWSM.js";import{C as p,b as Ze}from"./chunk-WGRGSG2J.js";var ie=["off","minimal","low","medium","high","xhigh","max"],Fn="high";var Un={minimal:1024,low:2048,medium:8192,high:16384,xhigh:32768,max:65536},Hn=1024,Yn=1024,nn={anthropic:"ANTHROPIC_API_KEY",openai:"OPENAI_API_KEY","openai-compat":"OPENAI_API_KEY"},Fe=new Set(Object.keys(nn)),jn=["auto","eager","native","dispatch"],qn=["auto","dark","light"],Ue="config.yaml",Bn=".mcp.json",Kn="At least one provider MUST be configured.",rn="YAML parse error";function se(){return Pn(Ue)}var ue=p.enum(["none","minimal","low","medium","high","xhigh","max"]),ii=p.enum(["low","medium","high","xhigh","max"]),oi=p.strictObject({off:p.literal("none").nullable().optional(),minimal:ue.nullable().optional(),low:ue.nullable().optional(),medium:ue.nullable().optional(),high:ue.nullable().optional(),xhigh:ue.nullable().optional(),max:ue.nullable().optional()}),Se=p.looseObject({name:p.string(),protocol:p.enum(["anthropic","openai","openai-compat"]),base_url:p.string(),model:p.string(),api_key:p.string().optional(),thinking:p.enum(ie).optional(),reasoning:p.boolean().optional(),thinking_level_map:oi.optional(),thinking_mode:p.enum(["budget","adaptive"]).optional(),context_window:p.coerce.number().optional(),max_output_tokens:p.coerce.number().optional()});function qi(r,i){return r[i]??r[0]}function Bi(r){return ie.some(i=>i===r)}function on(r){return ui(r,r.thinking??Fn)}function ti(r){return r==="off"?0:Un[r]}function Ki(r,i){let c=tn(i,r);return c===null||c==="none"?0:ti(c)}function tn(r,i){if(i?.reasoning===!1)return null;if(r==="off")return"none";let c=i?.thinking_level_map?.[r];if(c!==void 0)return c;if(i?.protocol==="anthropic"&&i.thinking_mode==="adaptive"){if(r==="minimal")return"low";if(r==="xhigh")return"high"}return r}function li(r,i){let c=ii.safeParse(tn(r,i));return c.success?c.data:null}function ci(r){return r.reasoning===!1||r.protocol==="anthropic"&&r.thinking_mode!=="adaptive"&&zn(r)<Hn+Yn?["off"]:ie.filter(i=>{if(i==="off")return!0;if(r.protocol==="anthropic"&&r.thinking_mode==="adaptive")return li(i,r)!==null;let c=tn(i,r);return c!==null&&c!=="none"})}function ui(r,i){let c=ci(r),m="off";for(let l of ie)if(c.includes(l)&&(m=l),l===i)break;return m}function Gn(r){return{...r,thinking:on(r),context_window:$n(r),max_output_tokens:zn(r)}}function $n(r){return Number.isSafeInteger(r.context_window)&&(r.context_window??0)>0?r.context_window??1e6:1e6}function zn(r){let i=r.max_output_tokens,c=Number.isSafeInteger(i)&&(i??0)>0?i??128e3:128e3;return Math.min(c,$n(r))}import{randomUUID as gi}from"crypto";import{existsSync as Fr,renameSync as _i,unlinkSync as Ei}from"fs";import{dirname as Ai,join as yi}from"path";function fi(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}var U={},je={},ee={},Vn;function Te(){if(Vn)return ee;Vn=1;function r(g){return typeof g>"u"||g===null}function i(g){return typeof g=="object"&&g!==null}function c(g){return Array.isArray(g)?g:r(g)?[]:[g]}function m(g,u){if(u){let T=Object.keys(u);for(let s=0,d=T.length;s<d;s+=1){let O=T[s];g[O]=u[O]}}return g}function l(g,u){let T="";for(let s=0;s<u;s+=1)T+=g;return T}function h(g){return g===0&&Number.NEGATIVE_INFINITY===1/g}return ee.isNothing=r,ee.isObject=i,ee.toArray=c,ee.repeat=l,ee.isNegativeZero=h,ee.extend=m,ee}var ln,Wn;function xe(){if(Wn)return ln;Wn=1;function r(c,m){let l="",h=c.reason||"(unknown reason)";return c.mark?(c.mark.name&&(l+='in "'+c.mark.name+'" '),l+="("+(c.mark.line+1)+":"+(c.mark.column+1)+")",!m&&c.mark.snippet&&(l+=`
|
|
5
|
-
|
|
6
|
-
`+c.mark.snippet),h+" "+l):h}function i(c,m){Error.call(this),this.name="YAMLException",this.reason=c,this.mark=m,this.message=r(this,!1),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=new Error().stack||""}return i.prototype=Object.create(Error.prototype),i.prototype.constructor=i,i.prototype.toString=function(m){return this.name+": "+r(this,m)},ln=i,ln}var cn,Xn;function ai(){if(Xn)return cn;Xn=1;let r=Te();function i(l,h,g,u,T){let s="",d="",O=Math.floor(T/2)-1;return u-h>O&&(s=" ... ",h=u-O+s.length),g-u>O&&(d=" ...",g=u+O-d.length),{str:s+l.slice(h,g).replace(/\t/g,"\u2192")+d,pos:u-h+s.length}}function c(l,h){return r.repeat(" ",h-l.length)+l}function m(l,h){if(h=Object.create(h||null),!l.buffer)return null;h.maxLength||(h.maxLength=79),typeof h.indent!="number"&&(h.indent=1),typeof h.linesBefore!="number"&&(h.linesBefore=3),typeof h.linesAfter!="number"&&(h.linesAfter=2);let g=/\r?\n|\r|\0/g,u=[0],T=[],s,d=-1;for(;s=g.exec(l.buffer);)T.push(s.index),u.push(s.index+s[0].length),l.position<=s.index&&d<0&&(d=u.length-2);d<0&&(d=u.length-1);let O="",R=Math.min(l.line+h.linesAfter,T.length).toString().length,k=h.maxLength-(h.indent+R+3);for(let M=1;M<=h.linesBefore&&!(d-M<0);M++){let K=i(l.buffer,u[d-M],T[d-M],l.position-(u[d]-u[d-M]),k);O=r.repeat(" ",h.indent)+c((l.line-M+1).toString(),R)+" | "+K.str+`
|
|
7
|
-
`+O}let V=i(l.buffer,u[d],T[d],l.position,k);O+=r.repeat(" ",h.indent)+c((l.line+1).toString(),R)+" | "+V.str+`
|
|
8
|
-
`,O+=r.repeat("-",h.indent+R+3+V.pos)+`^
|
|
9
|
-
`;for(let M=1;M<=h.linesAfter&&!(d+M>=T.length);M++){let K=i(l.buffer,u[d+M],T[d+M],l.position-(u[d]-u[d+M]),k);O+=r.repeat(" ",h.indent)+c((l.line+M+1).toString(),R)+" | "+K.str+`
|
|
10
|
-
`}return O.replace(/\n$/,"")}return cn=m,cn}var un,Jn;function H(){if(Jn)return un;Jn=1;let r=xe(),i=["kind","multi","resolve","construct","instanceOf","predicate","represent","representName","defaultStyle","styleAliases"],c=["scalar","sequence","mapping"];function m(h){let g={};return h!==null&&Object.keys(h).forEach(function(u){h[u].forEach(function(T){g[String(T)]=u})}),g}function l(h,g){if(g=g||{},Object.keys(g).forEach(function(u){if(i.indexOf(u)===-1)throw new r('Unknown option "'+u+'" is met in definition of "'+h+'" YAML type.')}),this.options=g,this.tag=h,this.kind=g.kind||null,this.resolve=g.resolve||function(){return!0},this.construct=g.construct||function(u){return u},this.instanceOf=g.instanceOf||null,this.predicate=g.predicate||null,this.represent=g.represent||null,this.representName=g.representName||null,this.defaultStyle=g.defaultStyle||null,this.multi=g.multi||!1,this.styleAliases=m(g.styleAliases||null),c.indexOf(this.kind)===-1)throw new r('Unknown kind "'+this.kind+'" is specified for "'+h+'" YAML type.')}return un=l,un}var sn,Qn;function Ar(){if(Qn)return sn;Qn=1;let r=xe(),i=H();function c(h,g){let u=[];return h[g].forEach(function(T){let s=u.length;u.forEach(function(d,O){d.tag===T.tag&&d.kind===T.kind&&d.multi===T.multi&&(s=O)}),u[s]=T}),u}function m(){let h={scalar:{},sequence:{},mapping:{},fallback:{},multi:{scalar:[],sequence:[],mapping:[],fallback:[]}};function g(u){u.multi?(h.multi[u.kind].push(u),h.multi.fallback.push(u)):h[u.kind][u.tag]=h.fallback[u.tag]=u}for(let u=0,T=arguments.length;u<T;u+=1)arguments[u].forEach(g);return h}function l(h){return this.extend(h)}return l.prototype.extend=function(g){let u=[],T=[];if(g instanceof i)T.push(g);else if(Array.isArray(g))T=T.concat(g);else if(g&&(Array.isArray(g.implicit)||Array.isArray(g.explicit)))g.implicit&&(u=u.concat(g.implicit)),g.explicit&&(T=T.concat(g.explicit));else throw new r("Schema.extend argument should be a Type, [ Type ], or a schema definition ({ implicit: [...], explicit: [...] })");u.forEach(function(d){if(!(d instanceof i))throw new r("Specified list of YAML types (or a single Type object) contains a non-Type object.");if(d.loadKind&&d.loadKind!=="scalar")throw new r("There is a non-scalar type in the implicit list of a schema. Implicit resolving of such types is not supported.");if(d.multi)throw new r("There is a multi type in the implicit list of a schema. Multi tags can only be listed as explicit.")}),T.forEach(function(d){if(!(d instanceof i))throw new r("Specified list of YAML types (or a single Type object) contains a non-Type object.")});let s=Object.create(l.prototype);return s.implicit=(this.implicit||[]).concat(u),s.explicit=(this.explicit||[]).concat(T),s.compiledImplicit=c(s,"implicit"),s.compiledExplicit=c(s,"explicit"),s.compiledTypeMap=m(s.compiledImplicit,s.compiledExplicit),s},sn=l,sn}var fn,Zn;function yr(){if(Zn)return fn;Zn=1;let r=H();return fn=new r("tag:yaml.org,2002:str",{kind:"scalar",construct:function(i){return i!==null?i:""}}),fn}var an,er;function Sr(){if(er)return an;er=1;let r=H();return an=new r("tag:yaml.org,2002:seq",{kind:"sequence",construct:function(i){return i!==null?i:[]}}),an}var pn,nr;function Tr(){if(nr)return pn;nr=1;let r=H();return pn=new r("tag:yaml.org,2002:map",{kind:"mapping",construct:function(i){return i!==null?i:{}}}),pn}var dn,rr;function xr(){if(rr)return dn;rr=1;let r=Ar();return dn=new r({explicit:[yr(),Sr(),Tr()]}),dn}var hn,ir;function Cr(){if(ir)return hn;ir=1;let r=H();function i(l){if(l===null)return!0;let h=l.length;return h===1&&l==="~"||h===4&&(l==="null"||l==="Null"||l==="NULL")}function c(){return null}function m(l){return l===null}return hn=new r("tag:yaml.org,2002:null",{kind:"scalar",resolve:i,construct:c,predicate:m,represent:{canonical:function(){return"~"},lowercase:function(){return"null"},uppercase:function(){return"NULL"},camelcase:function(){return"Null"},empty:function(){return""}},defaultStyle:"lowercase"}),hn}var mn,or;function Or(){if(or)return mn;or=1;let r=H();function i(l){if(l===null)return!1;let h=l.length;return h===4&&(l==="true"||l==="True"||l==="TRUE")||h===5&&(l==="false"||l==="False"||l==="FALSE")}function c(l){return l==="true"||l==="True"||l==="TRUE"}function m(l){return Object.prototype.toString.call(l)==="[object Boolean]"}return mn=new r("tag:yaml.org,2002:bool",{kind:"scalar",resolve:i,construct:c,predicate:m,represent:{lowercase:function(l){return l?"true":"false"},uppercase:function(l){return l?"TRUE":"FALSE"},camelcase:function(l){return l?"True":"False"}},defaultStyle:"lowercase"}),mn}var gn,tr;function Ir(){if(tr)return gn;tr=1;let r=Te(),i=H();function c(s){return s>=48&&s<=57||s>=65&&s<=70||s>=97&&s<=102}function m(s){return s>=48&&s<=55}function l(s){return s>=48&&s<=57}function h(s){if(s===null)return!1;let d=s.length,O=0,R=!1;if(!d)return!1;let k=s[O];if((k==="-"||k==="+")&&(k=s[++O]),k==="0"){if(O+1===d)return!0;if(k=s[++O],k==="b"){for(O++;O<d;O++){if(k=s[O],k!=="0"&&k!=="1")return!1;R=!0}return R&&isFinite(g(s))}if(k==="x"){for(O++;O<d;O++){if(!c(s.charCodeAt(O)))return!1;R=!0}return R&&isFinite(g(s))}if(k==="o"){for(O++;O<d;O++){if(!m(s.charCodeAt(O)))return!1;R=!0}return R&&isFinite(g(s))}}for(;O<d;O++){if(!l(s.charCodeAt(O)))return!1;R=!0}return R?isFinite(g(s)):!1}function g(s){let d=s,O=1,R=d[0];if((R==="-"||R==="+")&&(R==="-"&&(O=-1),d=d.slice(1),R=d[0]),d==="0")return 0;if(R==="0"){if(d[1]==="b")return O*parseInt(d.slice(2),2);if(d[1]==="x")return O*parseInt(d.slice(2),16);if(d[1]==="o")return O*parseInt(d.slice(2),8)}return O*parseInt(d,10)}function u(s){return g(s)}function T(s){return Object.prototype.toString.call(s)==="[object Number]"&&s%1===0&&!r.isNegativeZero(s)}return gn=new i("tag:yaml.org,2002:int",{kind:"scalar",resolve:h,construct:u,predicate:T,represent:{binary:function(s){return s>=0?"0b"+s.toString(2):"-0b"+s.toString(2).slice(1)},octal:function(s){return s>=0?"0o"+s.toString(8):"-0o"+s.toString(8).slice(1)},decimal:function(s){return s.toString(10)},hexadecimal:function(s){return s>=0?"0x"+s.toString(16).toUpperCase():"-0x"+s.toString(16).toUpperCase().slice(1)}},defaultStyle:"decimal",styleAliases:{binary:[2,"bin"],octal:[8,"oct"],decimal:[10,"dec"],hexadecimal:[16,"hex"]}}),gn}var _n,lr;function vr(){if(lr)return _n;lr=1;let r=Te(),i=H(),c=new RegExp("^(?:[-+]?(?:[0-9]+)(?:\\.[0-9]*)?(?:[eE][-+]?[0-9]+)?|\\.[0-9]+(?:[eE][-+]?[0-9]+)?|[-+]?\\.(?:inf|Inf|INF)|\\.(?:nan|NaN|NAN))$"),m=new RegExp("^(?:[-+]?\\.(?:inf|Inf|INF)|\\.(?:nan|NaN|NAN))$");function l(s){return s===null||!c.test(s)?!1:isFinite(parseFloat(s,10))?!0:m.test(s)}function h(s){let d=s.toLowerCase(),O=d[0]==="-"?-1:1;return"+-".indexOf(d[0])>=0&&(d=d.slice(1)),d===".inf"?O===1?Number.POSITIVE_INFINITY:Number.NEGATIVE_INFINITY:d===".nan"?NaN:O*parseFloat(d,10)}let g=/^[-+]?[0-9]+e/;function u(s,d){if(isNaN(s))switch(d){case"lowercase":return".nan";case"uppercase":return".NAN";case"camelcase":return".NaN"}else if(Number.POSITIVE_INFINITY===s)switch(d){case"lowercase":return".inf";case"uppercase":return".INF";case"camelcase":return".Inf"}else if(Number.NEGATIVE_INFINITY===s)switch(d){case"lowercase":return"-.inf";case"uppercase":return"-.INF";case"camelcase":return"-.Inf"}else if(r.isNegativeZero(s))return"-0.0";let O=s.toString(10);return g.test(O)?O.replace("e",".e"):O}function T(s){return Object.prototype.toString.call(s)==="[object Number]"&&(s%1!==0||r.isNegativeZero(s))}return _n=new i("tag:yaml.org,2002:float",{kind:"scalar",resolve:l,construct:h,predicate:T,represent:u,defaultStyle:"lowercase"}),_n}var En,cr;function br(){return cr||(cr=1,En=xr().extend({implicit:[Cr(),Or(),Ir(),vr()]})),En}var An,ur;function wr(){return ur||(ur=1,An=br()),An}var yn,sr;function Rr(){if(sr)return yn;sr=1;let r=H(),i=new RegExp("^([0-9][0-9][0-9][0-9])-([0-9][0-9])-([0-9][0-9])$"),c=new RegExp("^([0-9][0-9][0-9][0-9])-([0-9][0-9]?)-([0-9][0-9]?)(?:[Tt]|[ \\t]+)([0-9][0-9]?):([0-9][0-9]):([0-9][0-9])(?:\\.([0-9]*))?(?:[ \\t]*(Z|([-+])([0-9][0-9]?)(?::([0-9][0-9]))?))?$");function m(g){return g===null?!1:i.exec(g)!==null||c.exec(g)!==null}function l(g){let u=0,T=null,s=i.exec(g);if(s===null&&(s=c.exec(g)),s===null)throw new Error("Date resolve error");let d=+s[1],O=+s[2]-1,R=+s[3];if(!s[4])return new Date(Date.UTC(d,O,R));let k=+s[4],V=+s[5],M=+s[6];if(s[7]){for(u=s[7].slice(0,3);u.length<3;)u+="0";u=+u}if(s[9]){let ne=+s[10],Y=+(s[11]||0);T=(ne*60+Y)*6e4,s[9]==="-"&&(T=-T)}let K=new Date(Date.UTC(d,O,R,k,V,M,u));return T&&K.setTime(K.getTime()-T),K}function h(g){return g.toISOString()}return yn=new r("tag:yaml.org,2002:timestamp",{kind:"scalar",resolve:m,construct:l,instanceOf:Date,represent:h}),yn}var Sn,fr;function Lr(){if(fr)return Sn;fr=1;let r=H();function i(c){return c==="<<"||c===null}return Sn=new r("tag:yaml.org,2002:merge",{kind:"scalar",resolve:i}),Sn}var Tn,ar;function Nr(){if(ar)return Tn;ar=1;let r=H(),i=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=
|
|
11
|
-
\r`;function c(g){if(g===null)return!1;let u=0,T=g.length,s=i;for(let d=0;d<T;d++){let O=s.indexOf(g.charAt(d));if(!(O>64)){if(O<0)return!1;u+=6}}return u%8===0}function m(g){let u=g.replace(/[\r\n=]/g,""),T=u.length,s=i,d=0,O=[];for(let k=0;k<T;k++)k%4===0&&k&&(O.push(d>>16&255),O.push(d>>8&255),O.push(d&255)),d=d<<6|s.indexOf(u.charAt(k));let R=T%4*6;return R===0?(O.push(d>>16&255),O.push(d>>8&255),O.push(d&255)):R===18?(O.push(d>>10&255),O.push(d>>2&255)):R===12&&O.push(d>>4&255),new Uint8Array(O)}function l(g){let u="",T=0,s=g.length,d=i;for(let R=0;R<s;R++)R%3===0&&R&&(u+=d[T>>18&63],u+=d[T>>12&63],u+=d[T>>6&63],u+=d[T&63]),T=(T<<8)+g[R];let O=s%3;return O===0?(u+=d[T>>18&63],u+=d[T>>12&63],u+=d[T>>6&63],u+=d[T&63]):O===2?(u+=d[T>>10&63],u+=d[T>>4&63],u+=d[T<<2&63],u+=d[64]):O===1&&(u+=d[T>>2&63],u+=d[T<<4&63],u+=d[64],u+=d[64]),u}function h(g){return Object.prototype.toString.call(g)==="[object Uint8Array]"}return Tn=new r("tag:yaml.org,2002:binary",{kind:"scalar",resolve:c,construct:m,predicate:h,represent:l}),Tn}var xn,pr;function kr(){if(pr)return xn;pr=1;let r=H(),i=Object.prototype.hasOwnProperty,c=Object.prototype.toString;function m(h){if(h===null)return!0;let g={},u=h;for(let T=0,s=u.length;T<s;T+=1){let d=u[T],O=!1;if(c.call(d)!=="[object Object]")return!1;let R;for(R in d)if(i.call(d,R))if(!O)O=!0;else return!1;if(!O||i.call(g,R))return!1;Object.defineProperty(g,R,{value:!0})}return!0}function l(h){return h!==null?h:[]}return xn=new r("tag:yaml.org,2002:omap",{kind:"sequence",resolve:m,construct:l}),xn}var Cn,dr;function Mr(){if(dr)return Cn;dr=1;let r=H(),i=Object.prototype.toString;function c(l){if(l===null)return!0;let h=l,g=new Array(h.length);for(let u=0,T=h.length;u<T;u+=1){let s=h[u];if(i.call(s)!=="[object Object]")return!1;let d=Object.keys(s);if(d.length!==1)return!1;g[u]=[d[0],s[d[0]]]}return!0}function m(l){if(l===null)return[];let h=l,g=new Array(h.length);for(let u=0,T=h.length;u<T;u+=1){let s=h[u],d=Object.keys(s);g[u]=[d[0],s[d[0]]]}return g}return Cn=new r("tag:yaml.org,2002:pairs",{kind:"sequence",resolve:c,construct:m}),Cn}var On,hr;function Pr(){if(hr)return On;hr=1;let r=H(),i=Object.prototype.hasOwnProperty;function c(l){if(l===null)return!0;let h=l;for(let g in h)if(i.call(h,g)&&h[g]!==null)return!1;return!0}function m(l){return l!==null?l:{}}return On=new r("tag:yaml.org,2002:set",{kind:"mapping",resolve:c,construct:m}),On}var In,mr;function bn(){return mr||(mr=1,In=wr().extend({implicit:[Rr(),Lr()],explicit:[Nr(),kr(),Mr(),Pr()]})),In}var gr;function pi(){if(gr)return je;gr=1;let r=Te(),i=xe(),c=ai(),m=bn(),l=Object.prototype.hasOwnProperty,h=1,g=2,u=3,T=4,s=1,d=2,O=3,R=/[\x00-\x08\x0B\x0C\x0E-\x1F\x7F-\x84\x86-\x9F\uFFFE\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/,k=/[\x85\u2028\u2029]/,V=/[,\[\]{}]/,M=/^(?:!|!!|![0-9A-Za-z-]+!)$/,K=/^(?:!|[^,\[\]{}])(?:%[0-9a-f]{2}|[0-9a-z\-#;/?:@&=+$,_.!~*'()\[\]])*$/i;function ne(e){return Object.prototype.toString.call(e)}function Y(e){return e===10||e===13}function j(e){return e===9||e===32}function F(e){return e===9||e===32||e===10||e===13}function W(e){return e===44||e===91||e===93||e===123||e===125}function Ke(e){if(e>=48&&e<=57)return e-48;let o=e|32;return o>=97&&o<=102?o-97+10:-1}function Ge(e){return e===120?2:e===117?4:e===85?8:0}function Ce(e){return e>=48&&e<=57?e-48:-1}function ae(e){switch(e){case 48:return"\0";case 97:return"\x07";case 98:return"\b";case 116:return" ";case 9:return" ";case 110:return`
|
|
12
|
-
`;case 118:return"\v";case 102:return"\f";case 114:return"\r";case 101:return"\x1B";case 32:return" ";case 34:return'"';case 47:return"/";case 92:return"\\";case 78:return"\x85";case 95:return"\xA0";case 76:return"\u2028";case 80:return"\u2029";default:return""}}function $e(e){return e<=65535?String.fromCharCode(e):String.fromCharCode((e-65536>>10)+55296,(e-65536&1023)+56320)}function pe(e,o,E){o==="__proto__"?Object.defineProperty(e,o,{configurable:!0,enumerable:!0,writable:!0,value:E}):e[o]=E}let Oe=new Array(256),de=new Array(256);for(let e=0;e<256;e++)Oe[e]=ae(e)?1:0,de[e]=ae(e);function D(e,o){this.input=e,this.filename=o.filename||null,this.schema=o.schema||m,this.onWarning=o.onWarning||null,this.legacy=o.legacy||!1,this.json=o.json||!1,this.listener=o.listener||null,this.maxDepth=typeof o.maxDepth=="number"?o.maxDepth:100,this.maxTotalMergeKeys=typeof o.maxTotalMergeKeys=="number"?o.maxTotalMergeKeys:1e4,this.implicitTypes=this.schema.compiledImplicit,this.typeMap=this.schema.compiledTypeMap,this.length=e.length,this.position=0,this.line=0,this.lineStart=0,this.lineIndent=0,this.depth=0,this.totalMergeKeys=0,this.firstTabInLine=-1,this.documents=[],this.anchorMapTransactions=[]}function Ie(e,o){let E={name:e.filename,buffer:e.input.slice(0,-1),position:e.position,line:e.line,column:e.position-e.lineStart};return E.snippet=c(E),new i(o,E)}function v(e,o){throw Ie(e,o)}function te(e,o){e.onWarning&&e.onWarning.call(null,Ie(e,o))}function $(e,o,E){let A=e.anchorMapTransactions;if(A.length!==0){let a=A[A.length-1];l.call(a,o)||(a[o]={existed:l.call(e.anchorMap,o),value:e.anchorMap[o]})}e.anchorMap[o]=E}function ze(e){e.anchorMapTransactions.push(Object.create(null))}function re(e){let o=e.anchorMapTransactions.pop(),E=e.anchorMapTransactions;if(E.length===0)return;let A=E[E.length-1],a=Object.keys(o);for(let n=0,t=a.length;n<t;n+=1){let f=a[n];l.call(A,f)||(A[f]=o[f])}}function Ve(e){let o=e.anchorMapTransactions.pop(),E=Object.keys(o);for(let A=E.length-1;A>=0;A-=1){let a=o[E[A]];a.existed?e.anchorMap[E[A]]=a.value:delete e.anchorMap[E[A]]}}function he(e){return{position:e.position,line:e.line,lineStart:e.lineStart,lineIndent:e.lineIndent,firstTabInLine:e.firstTabInLine,tag:e.tag,anchor:e.anchor,kind:e.kind,result:e.result}}function le(e,o){e.position=o.position,e.line=o.line,e.lineStart=o.lineStart,e.lineIndent=o.lineIndent,e.firstTabInLine=o.firstTabInLine,e.tag=o.tag,e.anchor=o.anchor,e.kind=o.kind,e.result=o.result}let ve={YAML:function(o,E,A){o.version!==null&&v(o,"duplication of %YAML directive"),A.length!==1&&v(o,"YAML directive accepts exactly one argument");let a=/^([0-9]+)\.([0-9]+)$/.exec(A[0]);a===null&&v(o,"ill-formed argument of the YAML directive");let n=parseInt(a[1],10),t=parseInt(a[2],10);n!==1&&v(o,"unacceptable YAML version of the document"),o.version=A[0],o.checkLineBreaks=t<2,t!==1&&t!==2&&te(o,"unsupported YAML version of the document")},TAG:function(o,E,A){let a;A.length!==2&&v(o,"TAG directive accepts exactly two arguments");let n=A[0];a=A[1],M.test(n)||v(o,"ill-formed tag handle (first argument) of the TAG directive"),l.call(o.tagMap,n)&&v(o,'there is a previously declared suffix for "'+n+'" tag handle'),K.test(a)||v(o,"ill-formed tag prefix (second argument) of the TAG directive");try{a=decodeURIComponent(a)}catch{v(o,"tag prefix is malformed: "+a)}o.tagMap[n]=a}};function B(e,o,E,A){if(o<E){let a=e.input.slice(o,E);if(A)for(let n=0,t=a.length;n<t;n+=1){let f=a.charCodeAt(n);f===9||f>=32&&f<=1114111||v(e,"expected valid JSON character")}else R.test(a)&&v(e,"the stream contains non-printable characters");e.result+=a}}function X(e){e.totalMergeKeys++,e.maxTotalMergeKeys!==-1&&e.totalMergeKeys>e.maxTotalMergeKeys&&v(e,"merge keys exceeded maxTotalMergeKeys ("+e.maxTotalMergeKeys+")")}function me(e,o,E,A){r.isObject(E)||v(e,"cannot merge mappings; the provided source object is unacceptable"),X(e);let a=Object.keys(E);for(let n=0,t=a.length;n<t;n+=1){let f=a[n];X(e),l.call(o,f)||(pe(o,f,E[f]),A[f]=!0)}}function z(e,o,E,A,a,n,t,f,y){if(Array.isArray(a)){a=Array.prototype.slice.call(a);for(let S=0,x=a.length;S<x;S+=1)Array.isArray(a[S])&&v(e,"nested arrays are not supported inside keys"),typeof a=="object"&&ne(a[S])==="[object Object]"&&(a[S]="[object Object]")}if(typeof a=="object"&&ne(a)==="[object Object]"&&(a="[object Object]"),a=String(a),o===null&&(o={}),A==="tag:yaml.org,2002:merge")if(Array.isArray(n)){n.length>100&&v(e,"abnormal merge sequence size");for(let S=0,x=n.length;S<x;S+=1)me(e,o,n[S],E)}else me(e,o,n,E);else!e.json&&!l.call(E,a)&&l.call(o,a)&&(e.line=t||e.line,e.lineStart=f||e.lineStart,e.position=y||e.position,v(e,"duplicated mapping key")),pe(o,a,n),delete E[a];return o}function ge(e){let o=e.input.charCodeAt(e.position);o===10?e.position++:o===13?(e.position++,e.input.charCodeAt(e.position)===10&&e.position++):v(e,"a line break is expected"),e.line+=1,e.lineStart=e.position,e.firstTabInLine=-1}function P(e,o,E){let A=0,a=e.input.charCodeAt(e.position);for(;a!==0;){for(;j(a);)a===9&&e.firstTabInLine===-1&&(e.firstTabInLine=e.position),a=e.input.charCodeAt(++e.position);if(o&&a===35)do a=e.input.charCodeAt(++e.position);while(a!==10&&a!==13&&a!==0);if(Y(a))for(ge(e),a=e.input.charCodeAt(e.position),A++,e.lineIndent=0;a===32;)e.lineIndent++,a=e.input.charCodeAt(++e.position);else break}return E!==-1&&A!==0&&e.lineIndent<E&&te(e,"deficient indentation"),A}function G(e){let o=e.position,E=e.input.charCodeAt(o);return!!((E===45||E===46)&&E===e.input.charCodeAt(o+1)&&E===e.input.charCodeAt(o+2)&&(o+=3,E=e.input.charCodeAt(o),E===0||F(E)))}function ce(e,o){o===1?e.result+=" ":o>1&&(e.result+=r.repeat(`
|
|
13
|
-
`,o-1))}function be(e,o,E){let A,a,n,t,f,y,S=e.kind,x=e.result,_=e.input.charCodeAt(e.position);if(F(_)||W(_)||_===35||_===38||_===42||_===33||_===124||_===62||_===39||_===34||_===37||_===64||_===96)return!1;if(_===63||_===45){let C=e.input.charCodeAt(e.position+1);if(F(C)||E&&W(C))return!1}for(e.kind="scalar",e.result="",A=a=e.position,n=!1;_!==0;){if(_===58){let C=e.input.charCodeAt(e.position+1);if(F(C)||E&&W(C))break}else if(_===35){let C=e.input.charCodeAt(e.position-1);if(F(C))break}else{if(e.position===e.lineStart&&G(e)||E&&W(_))break;if(Y(_))if(t=e.line,f=e.lineStart,y=e.lineIndent,P(e,!1,-1),e.lineIndent>=o){n=!0,_=e.input.charCodeAt(e.position);continue}else{e.position=a,e.line=t,e.lineStart=f,e.lineIndent=y;break}}n&&(B(e,A,a,!1),ce(e,e.line-t),A=a=e.position,n=!1),j(_)||(a=e.position+1),_=e.input.charCodeAt(++e.position)}return B(e,A,a,!1),e.result?!0:(e.kind=S,e.result=x,!1)}function _e(e,o){let E,A,a=e.input.charCodeAt(e.position);if(a!==39)return!1;for(e.kind="scalar",e.result="",e.position++,E=A=e.position;(a=e.input.charCodeAt(e.position))!==0;)if(a===39)if(B(e,E,e.position,!0),a=e.input.charCodeAt(++e.position),a===39)E=e.position,e.position++,A=e.position;else return!0;else Y(a)?(B(e,E,A,!0),ce(e,P(e,!1,o)),E=A=e.position):e.position===e.lineStart&&G(e)?v(e,"unexpected end of the document within a single quoted scalar"):(e.position++,j(a)||(A=e.position));v(e,"unexpected end of the stream within a single quoted scalar")}function we(e,o){let E,A,a,n=e.input.charCodeAt(e.position);if(n!==34)return!1;for(e.kind="scalar",e.result="",e.position++,E=A=e.position;(n=e.input.charCodeAt(e.position))!==0;){if(n===34)return B(e,E,e.position,!0),e.position++,!0;if(n===92){if(B(e,E,e.position,!0),n=e.input.charCodeAt(++e.position),Y(n))P(e,!1,o);else if(n<256&&Oe[n])e.result+=de[n],e.position++;else if((a=Ge(n))>0){let t=a,f=0;for(;t>0;t--)n=e.input.charCodeAt(++e.position),(a=Ke(n))>=0?f=(f<<4)+a:v(e,"expected hexadecimal character");e.result+=$e(f),e.position++}else v(e,"unknown escape sequence");E=A=e.position}else Y(n)?(B(e,E,A,!0),ce(e,P(e,!1,o)),E=A=e.position):e.position===e.lineStart&&G(e)?v(e,"unexpected end of the document within a double quoted scalar"):(e.position++,j(n)||(A=e.position))}v(e,"unexpected end of the stream within a double quoted scalar")}function Re(e,o){let E=!0,A,a,n,t=e.tag,f,y=e.anchor,S,x,_,C,I=Object.create(null),b,w,L,N=e.input.charCodeAt(e.position);if(N===91)S=93,C=!1,f=[];else if(N===123)S=125,C=!0,f={};else return!1;for(e.anchor!==null&&$(e,e.anchor,f),N=e.input.charCodeAt(++e.position);N!==0;){if(P(e,!0,o),N=e.input.charCodeAt(e.position),N===S)return e.position++,e.tag=t,e.anchor=y,e.kind=C?"mapping":"sequence",e.result=f,!0;if(E?N===44&&v(e,"expected the node content, but found ','"):v(e,"missed comma between flow collection entries"),w=b=L=null,x=_=!1,N===63){let Z=e.input.charCodeAt(e.position+1);F(Z)&&(x=_=!0,e.position++,P(e,!0,o))}A=e.line,a=e.lineStart,n=e.position,Q(e,o,h,!1,!0),w=e.tag,b=e.result,P(e,!0,o),N=e.input.charCodeAt(e.position),(_||e.line===A)&&N===58&&(x=!0,N=e.input.charCodeAt(++e.position),P(e,!0,o),Q(e,o,h,!1,!0),L=e.result),C?z(e,f,I,w,b,L,A,a,n):x?f.push(z(e,null,I,w,b,L,A,a,n)):f.push(b),P(e,!0,o),N=e.input.charCodeAt(e.position),N===44?(E=!0,N=e.input.charCodeAt(++e.position)):E=!1}v(e,"unexpected end of the stream within a flow collection")}function J(e,o){let E,A=s,a=!1,n=!1,t=o,f=0,y=!1,S,x=e.input.charCodeAt(e.position);if(x===124)E=!1;else if(x===62)E=!0;else return!1;for(e.kind="scalar",e.result="";x!==0;)if(x=e.input.charCodeAt(++e.position),x===43||x===45)s===A?A=x===43?O:d:v(e,"repeat of a chomping mode identifier");else if((S=Ce(x))>=0)S===0?v(e,"bad explicit indentation width of a block scalar; it cannot be less than one"):n?v(e,"repeat of an indentation width identifier"):(t=o+S-1,n=!0);else break;if(j(x)){do x=e.input.charCodeAt(++e.position);while(j(x));if(x===35)do x=e.input.charCodeAt(++e.position);while(!Y(x)&&x!==0)}for(;x!==0;){for(ge(e),e.lineIndent=0,x=e.input.charCodeAt(e.position);(!n||e.lineIndent<t)&&x===32;)e.lineIndent++,x=e.input.charCodeAt(++e.position);if(!n&&e.lineIndent>t&&(t=e.lineIndent),Y(x)){f++;continue}if(!n&&t===0&&v(e,"missing indentation for block scalar"),e.lineIndent<t){A===O?e.result+=r.repeat(`
|
|
14
|
-
`,a?1+f:f):A===s&&a&&(e.result+=`
|
|
15
|
-
`);break}E?j(x)?(y=!0,e.result+=r.repeat(`
|
|
16
|
-
`,a?1+f:f)):y?(y=!1,e.result+=r.repeat(`
|
|
17
|
-
`,f+1)):f===0?a&&(e.result+=" "):e.result+=r.repeat(`
|
|
18
|
-
`,f):e.result+=r.repeat(`
|
|
19
|
-
`,a?1+f:f),a=!0,n=!0,f=0;let _=e.position;for(;!Y(x)&&x!==0;)x=e.input.charCodeAt(++e.position);B(e,_,e.position,!1)}return!0}function Le(e,o){let E=e.tag,A=e.anchor,a=[],n=!1;if(e.firstTabInLine!==-1)return!1;e.anchor!==null&&$(e,e.anchor,a);let t=e.input.charCodeAt(e.position);for(;t!==0&&(e.firstTabInLine!==-1&&(e.position=e.firstTabInLine,v(e,"tab characters must not be used in indentation")),t===45);){let f=e.input.charCodeAt(e.position+1);if(!F(f))break;if(n=!0,e.position++,P(e,!0,-1)&&e.lineIndent<=o){a.push(null),t=e.input.charCodeAt(e.position);continue}let y=e.line;if(Q(e,o,u,!1,!0),a.push(e.result),P(e,!0,-1),t=e.input.charCodeAt(e.position),(e.line===y||e.lineIndent>o)&&t!==0)v(e,"bad indentation of a sequence entry");else if(e.lineIndent<o)break}return n?(e.tag=E,e.anchor=A,e.kind="sequence",e.result=a,!0):!1}function Ne(e,o,E){let A,a,n,t,f=e.tag,y=e.anchor,S={},x=Object.create(null),_=null,C=null,I=null,b=!1,w=!1;if(e.firstTabInLine!==-1)return!1;e.anchor!==null&&$(e,e.anchor,S);let L=e.input.charCodeAt(e.position);for(;L!==0;){!b&&e.firstTabInLine!==-1&&(e.position=e.firstTabInLine,v(e,"tab characters must not be used in indentation"));let N=e.input.charCodeAt(e.position+1),Z=e.line;if((L===63||L===58)&&F(N))L===63?(b&&(z(e,S,x,_,C,null,a,n,t),_=C=I=null),w=!0,b=!0,A=!0):b?(b=!1,A=!0):v(e,"incomplete explicit mapping pair; a key node is missed; or followed by a non-tabulated empty line"),e.position+=1,L=N;else{if(a=e.line,n=e.lineStart,t=e.position,!Q(e,E,g,!1,!0))break;if(e.line===Z){for(L=e.input.charCodeAt(e.position);j(L);)L=e.input.charCodeAt(++e.position);if(L===58)L=e.input.charCodeAt(++e.position),F(L)||v(e,"a whitespace character is expected after the key-value separator within a block mapping"),b&&(z(e,S,x,_,C,null,a,n,t),_=C=I=null),w=!0,b=!1,A=!1,_=e.tag,C=e.result;else if(w)v(e,"can not read an implicit mapping pair; a colon is missed");else return e.tag=f,e.anchor=y,!0}else if(w)v(e,"can not read a block mapping entry; a multiline key may not be an implicit key");else return e.tag=f,e.anchor=y,!0}if((e.line===Z||e.lineIndent>o)&&(b&&(a=e.line,n=e.lineStart,t=e.position),Q(e,o,T,!0,A)&&(b?C=e.result:I=e.result),b||(z(e,S,x,_,C,I,a,n,t),_=C=I=null),P(e,!0,-1),L=e.input.charCodeAt(e.position)),(e.line===Z||e.lineIndent>o)&&L!==0)v(e,"bad indentation of a mapping entry");else if(e.lineIndent<o)break}return b&&z(e,S,x,_,C,null,a,n,t),w&&(e.tag=f,e.anchor=y,e.kind="mapping",e.result=S),w}function ke(e){let o=!1,E=!1,A,a,n=e.input.charCodeAt(e.position);if(n!==33)return!1;e.tag!==null&&v(e,"duplication of a tag property"),n=e.input.charCodeAt(++e.position),n===60?(o=!0,n=e.input.charCodeAt(++e.position)):n===33?(E=!0,A="!!",n=e.input.charCodeAt(++e.position)):A="!";let t=e.position;if(o){do n=e.input.charCodeAt(++e.position);while(n!==0&&n!==62);e.position<e.length?(a=e.input.slice(t,e.position),n=e.input.charCodeAt(++e.position)):v(e,"unexpected end of the stream within a verbatim tag")}else{for(;n!==0&&!F(n);)n===33&&(E?v(e,"tag suffix cannot contain exclamation marks"):(A=e.input.slice(t-1,e.position+1),M.test(A)||v(e,"named tag handle cannot contain such characters"),E=!0,t=e.position+1)),n=e.input.charCodeAt(++e.position);a=e.input.slice(t,e.position),V.test(a)&&v(e,"tag suffix cannot contain flow indicator characters")}a&&!K.test(a)&&v(e,"tag name cannot contain such characters: "+a);try{a=decodeURIComponent(a)}catch{v(e,"tag name is malformed: "+a)}return o?e.tag=a:l.call(e.tagMap,A)?e.tag=e.tagMap[A]+a:A==="!"?e.tag="!"+a:A==="!!"?e.tag="tag:yaml.org,2002:"+a:v(e,'undeclared tag handle "'+A+'"'),!0}function Me(e){let o=e.input.charCodeAt(e.position);if(o!==38)return!1;e.anchor!==null&&v(e,"duplication of an anchor property"),o=e.input.charCodeAt(++e.position);let E=e.position;for(;o!==0&&!F(o)&&!W(o);)o=e.input.charCodeAt(++e.position);return e.position===E&&v(e,"name of an anchor node must contain at least one character"),e.anchor=e.input.slice(E,e.position),!0}function We(e){let o=e.input.charCodeAt(e.position);if(o!==42)return!1;o=e.input.charCodeAt(++e.position);let E=e.position;for(;o!==0&&!F(o)&&!W(o);)o=e.input.charCodeAt(++e.position);e.position===E&&v(e,"name of an alias node must contain at least one character");let A=e.input.slice(E,e.position);return l.call(e.anchorMap,A)||v(e,'unidentified alias "'+A+'"'),e.result=e.anchorMap[A],P(e,!0,-1),!0}function Pe(e,o,E,A){let a=he(e);return ze(e),le(e,o),e.tag=null,e.anchor=null,e.kind=null,e.result=null,Ne(e,E,A)&&e.kind==="mapping"?(re(e),!0):(Ve(e),le(e,a),!1)}function Q(e,o,E,A,a){let n,t,f=1,y=!1,S=!1,x=null,_,C,I;e.depth>=e.maxDepth&&v(e,"nesting exceeded maxDepth ("+e.maxDepth+")"),e.depth+=1,e.listener!==null&&e.listener("open",e),e.tag=null,e.anchor=null,e.kind=null,e.result=null;let b=n=t=T===E||u===E;if(A&&P(e,!0,-1)&&(y=!0,e.lineIndent>o?f=1:e.lineIndent===o?f=0:e.lineIndent<o&&(f=-1)),f===1)for(;;){let w=e.input.charCodeAt(e.position),L=he(e);if(y&&(w===33&&e.tag!==null||w===38&&e.anchor!==null)||!ke(e)&&!Me(e))break;x===null&&(x=L),P(e,!0,-1)?(y=!0,t=b,e.lineIndent>o?f=1:e.lineIndent===o?f=0:e.lineIndent<o&&(f=-1)):t=!1}if(t&&(t=y||a),f===1||T===E)if(h===E||g===E?C=o:C=o+1,I=e.position-e.lineStart,f===1)if(t&&(Le(e,I)||Ne(e,I,C))||Re(e,C))S=!0;else{let w=e.input.charCodeAt(e.position);x!==null&&b&&!t&&w!==124&&w!==62&&Pe(e,x,x.position-x.lineStart,C)||n&&J(e,C)||_e(e,C)||we(e,C)?S=!0:We(e)?(S=!0,(e.tag!==null||e.anchor!==null)&&v(e,"alias node should not have any properties")):be(e,C,h===E)&&(S=!0,e.tag===null&&(e.tag="?")),e.anchor!==null&&$(e,e.anchor,e.result)}else f===0&&(S=t&&Le(e,I));if(e.tag===null)e.anchor!==null&&$(e,e.anchor,e.result);else if(e.tag==="?"){e.result!==null&&e.kind!=="scalar"&&v(e,'unacceptable node kind for !<?> tag; it should be "scalar", not "'+e.kind+'"');for(let w=0,L=e.implicitTypes.length;w<L;w+=1)if(_=e.implicitTypes[w],_.resolve(e.result)){e.result=_.construct(e.result),e.tag=_.tag,e.anchor!==null&&$(e,e.anchor,e.result);break}}else if(e.tag!=="!"){if(l.call(e.typeMap[e.kind||"fallback"],e.tag))_=e.typeMap[e.kind||"fallback"][e.tag];else{_=null;let w=e.typeMap.multi[e.kind||"fallback"];for(let L=0,N=w.length;L<N;L+=1)if(e.tag.slice(0,w[L].tag.length)===w[L].tag){_=w[L];break}}_||v(e,"unknown tag !<"+e.tag+">"),e.result!==null&&_.kind!==e.kind&&v(e,"unacceptable node kind for !<"+e.tag+'> tag; it should be "'+_.kind+'", not "'+e.kind+'"'),_.resolve(e.result,e.tag)?(e.result=_.construct(e.result,e.tag),e.anchor!==null&&$(e,e.anchor,e.result)):v(e,"cannot resolve a node with !<"+e.tag+"> explicit tag")}return e.listener!==null&&e.listener("close",e),e.depth-=1,e.tag!==null||e.anchor!==null||S}function Xe(e){let o=e.position,E=!1,A;for(e.version=null,e.checkLineBreaks=e.legacy,e.tagMap=Object.create(null),e.anchorMap=Object.create(null);(A=e.input.charCodeAt(e.position))!==0&&(P(e,!0,-1),A=e.input.charCodeAt(e.position),!(e.lineIndent>0||A!==37));){E=!0,A=e.input.charCodeAt(++e.position);let a=e.position;for(;A!==0&&!F(A);)A=e.input.charCodeAt(++e.position);let n=e.input.slice(a,e.position),t=[];for(n.length<1&&v(e,"directive name must not be less than one character in length");A!==0;){for(;j(A);)A=e.input.charCodeAt(++e.position);if(A===35){do A=e.input.charCodeAt(++e.position);while(A!==0&&!Y(A));break}if(Y(A))break;for(a=e.position;A!==0&&!F(A);)A=e.input.charCodeAt(++e.position);t.push(e.input.slice(a,e.position))}A!==0&&ge(e),l.call(ve,n)?ve[n](e,n,t):te(e,'unknown document directive "'+n+'"')}if(P(e,!0,-1),e.lineIndent===0&&e.input.charCodeAt(e.position)===45&&e.input.charCodeAt(e.position+1)===45&&e.input.charCodeAt(e.position+2)===45?(e.position+=3,P(e,!0,-1)):E&&v(e,"directives end mark is expected"),Q(e,e.lineIndent-1,T,!1,!0),P(e,!0,-1),e.checkLineBreaks&&k.test(e.input.slice(o,e.position))&&te(e,"non-ASCII line breaks are interpreted as content"),e.documents.push(e.result),e.position===e.lineStart&&G(e)){e.input.charCodeAt(e.position)===46&&(e.position+=3,P(e,!0,-1));return}e.position<e.length-1&&v(e,"end of the stream or a document separator is expected")}function Ee(e,o){e=String(e),o=o||{},e.length!==0&&(e.charCodeAt(e.length-1)!==10&&e.charCodeAt(e.length-1)!==13&&(e+=`
|
|
20
|
-
`),e.charCodeAt(0)===65279&&(e=e.slice(1)));let E=new D(e,o),A=e.indexOf("\0");for(A!==-1&&(E.position=A,v(E,"null byte is not allowed in input")),E.input+="\0";E.input.charCodeAt(E.position)===32;)E.lineIndent+=1,E.position+=1;for(;E.position<E.length-1;)Xe(E);return E.documents}function Je(e,o,E){o!==null&&typeof o=="object"&&typeof E>"u"&&(E=o,o=null);let A=Ee(e,E);if(typeof o!="function")return A;for(let a=0,n=A.length;a<n;a+=1)o(A[a])}function Qe(e,o){let E=Ee(e,o);if(E.length!==0){if(E.length===1)return E[0];throw new i("expected a single document in the stream, but found more")}}return je.loadAll=Je,je.load=Qe,je}var vn={},_r;function di(){if(_r)return vn;_r=1;let r=Te(),i=xe(),c=bn(),m=Object.prototype.toString,l=Object.prototype.hasOwnProperty,h=65279,g=9,u=10,T=13,s=32,d=33,O=34,R=35,k=37,V=38,M=39,K=42,ne=44,Y=45,j=58,F=61,W=62,Ke=63,Ge=64,Ce=91,ae=93,$e=96,pe=123,Oe=124,de=125,D={};D[0]="\\0",D[7]="\\a",D[8]="\\b",D[9]="\\t",D[10]="\\n",D[11]="\\v",D[12]="\\f",D[13]="\\r",D[27]="\\e",D[34]='\\"',D[92]="\\\\",D[133]="\\N",D[160]="\\_",D[8232]="\\L",D[8233]="\\P";let Ie=["y","Y","yes","Yes","YES","on","On","ON","n","N","no","No","NO","off","Off","OFF"],v=/^[-+]?[0-9_]+(?::[0-9_]+)+(?:\.[0-9_]*)?$/;function te(n,t){if(t===null)return{};let f={},y=Object.keys(t);for(let S=0,x=y.length;S<x;S+=1){let _=y[S],C=String(t[_]);_.slice(0,2)==="!!"&&(_="tag:yaml.org,2002:"+_.slice(2));let I=n.compiledTypeMap.fallback[_];I&&l.call(I.styleAliases,C)&&(C=I.styleAliases[C]),f[_]=C}return f}function $(n){let t,f,y=n.toString(16).toUpperCase();if(n<=255)t="x",f=2;else if(n<=65535)t="u",f=4;else if(n<=4294967295)t="U",f=8;else throw new i("code point within a string may not be greater than 0xFFFFFFFF");return"\\"+t+r.repeat("0",f-y.length)+y}let ze=1,re=2;function Ve(n){this.schema=n.schema||c,this.indent=Math.max(1,n.indent||2),this.noArrayIndent=n.noArrayIndent||!1,this.skipInvalid=n.skipInvalid||!1,this.flowLevel=r.isNothing(n.flowLevel)?-1:n.flowLevel,this.styleMap=te(this.schema,n.styles||null),this.sortKeys=n.sortKeys||!1,this.lineWidth=n.lineWidth||80,this.noRefs=n.noRefs||!1,this.noCompatMode=n.noCompatMode||!1,this.condenseFlow=n.condenseFlow||!1,this.quotingType=n.quotingType==='"'?re:ze,this.forceQuotes=n.forceQuotes||!1,this.replacer=typeof n.replacer=="function"?n.replacer:null,this.implicitTypes=this.schema.compiledImplicit,this.explicitTypes=this.schema.compiledExplicit,this.tag=null,this.result="",this.duplicates=[],this.usedDuplicates=null}function he(n,t){let f=r.repeat(" ",t),y=0,S="",x=n.length;for(;y<x;){let _,C=n.indexOf(`
|
|
21
|
-
`,y);C===-1?(_=n.slice(y),y=x):(_=n.slice(y,C+1),y=C+1),_.length&&_!==`
|
|
22
|
-
`&&(S+=f),S+=_}return S}function le(n,t){return`
|
|
23
|
-
`+r.repeat(" ",n.indent*t)}function ve(n,t){for(let f=0,y=n.implicitTypes.length;f<y;f+=1)if(n.implicitTypes[f].resolve(t))return!0;return!1}function B(n){return n===s||n===g}function X(n){return n>=32&&n<=126||n>=161&&n<=55295&&n!==8232&&n!==8233||n>=57344&&n<=65533&&n!==h||n>=65536&&n<=1114111}function me(n){return X(n)&&n!==h&&n!==T&&n!==u}function z(n,t,f){let y=me(n),S=y&&!B(n);return(f?y:y&&n!==ne&&n!==Ce&&n!==ae&&n!==pe&&n!==de)&&n!==R&&!(t===j&&!S)||me(t)&&!B(t)&&n===R||t===j&&S}function ge(n){return X(n)&&n!==h&&!B(n)&&n!==Y&&n!==Ke&&n!==j&&n!==ne&&n!==Ce&&n!==ae&&n!==pe&&n!==de&&n!==R&&n!==V&&n!==K&&n!==d&&n!==Oe&&n!==F&&n!==W&&n!==M&&n!==O&&n!==k&&n!==Ge&&n!==$e}function P(n){return!B(n)&&n!==j}function G(n,t){let f=n.charCodeAt(t),y;return f>=55296&&f<=56319&&t+1<n.length&&(y=n.charCodeAt(t+1),y>=56320&&y<=57343)?(f-55296)*1024+y-56320+65536:f}function ce(n){return/^\n* /.test(n)}let be=1,_e=2,we=3,Re=4,J=5;function Le(n,t,f,y,S,x,_,C){let I,b=0,w=null,L=!1,N=!1,Z=y!==-1,Ae=-1,ye=ge(G(n,0))&&P(G(n,n.length-1));if(t||_)for(I=0;I<n.length;b>=65536?I+=2:I++){if(b=G(n,I),!X(b))return J;ye=ye&&z(b,w,C),w=b}else{for(I=0;I<n.length;b>=65536?I+=2:I++){if(b=G(n,I),b===u)L=!0,Z&&(N=N||I-Ae-1>y&&n[Ae+1]!==" ",Ae=I);else if(!X(b))return J;ye=ye&&z(b,w,C),w=b}N=N||Z&&I-Ae-1>y&&n[Ae+1]!==" "}return!L&&!N?ye&&!_&&!S(n)?be:x===re?J:_e:f>9&&ce(n)?J:_?x===re?J:_e:N?Re:we}function Ne(n,t,f,y,S){n.dump=(function(){if(t.length===0)return n.quotingType===re?'""':"''";if(!n.noCompatMode&&(Ie.indexOf(t)!==-1||v.test(t)))return n.quotingType===re?'"'+t+'"':"'"+t+"'";let x=n.indent*Math.max(1,f),_=n.lineWidth===-1?-1:Math.max(Math.min(n.lineWidth,40),n.lineWidth-x),C=y||n.flowLevel>-1&&f>=n.flowLevel;function I(b){return ve(n,b)}switch(Le(t,C,n.indent,_,I,n.quotingType,n.forceQuotes&&!y,S)){case be:return t;case _e:return"'"+t.replace(/'/g,"''")+"'";case we:return"|"+ke(t,n.indent)+Me(he(t,x));case Re:return">"+ke(t,n.indent)+Me(he(We(t,_),x));case J:return'"'+Q(t)+'"';default:throw new i("impossible error: invalid scalar style")}})()}function ke(n,t){let f=ce(n)?String(t):"",y=n[n.length-1]===`
|
|
24
|
-
`,x=y&&(n[n.length-2]===`
|
|
25
|
-
`||n===`
|
|
26
|
-
`)?"+":y?"":"-";return f+x+`
|
|
27
|
-
`}function Me(n){return n[n.length-1]===`
|
|
28
|
-
`?n.slice(0,-1):n}function We(n,t){let f=/(\n+)([^\n]*)/g,y=(function(){let C=n.indexOf(`
|
|
29
|
-
`);return C=C!==-1?C:n.length,f.lastIndex=C,Pe(n.slice(0,C),t)})(),S=n[0]===`
|
|
30
|
-
`||n[0]===" ",x,_;for(;_=f.exec(n);){let C=_[1],I=_[2];x=I[0]===" ",y+=C+(!S&&!x&&I!==""?`
|
|
31
|
-
`:"")+Pe(I,t),S=x}return y}function Pe(n,t){if(n===""||n[0]===" ")return n;let f=/ [^ ]/g,y,S=0,x,_=0,C=0,I="";for(;y=f.exec(n);)C=y.index,C-S>t&&(x=_>S?_:C,I+=`
|
|
32
|
-
`+n.slice(S,x),S=x+1),_=C;return I+=`
|
|
33
|
-
`,n.length-S>t&&_>S?I+=n.slice(S,_)+`
|
|
34
|
-
`+n.slice(_+1):I+=n.slice(S),I.slice(1)}function Q(n){let t="",f=0;for(let y=0;y<n.length;f>=65536?y+=2:y++){f=G(n,y);let S=D[f];!S&&X(f)?(t+=n[y],f>=65536&&(t+=n[y+1])):t+=S||$(f)}return t}function Xe(n,t,f){let y="",S=n.tag;for(let x=0,_=f.length;x<_;x+=1){let C=f[x];n.replacer&&(C=n.replacer.call(f,String(x),C)),(o(n,t,C,!1,!1)||typeof C>"u"&&o(n,t,null,!1,!1))&&(y!==""&&(y+=","+(n.condenseFlow?"":" ")),y+=n.dump)}n.tag=S,n.dump="["+y+"]"}function Ee(n,t,f,y){let S="",x=n.tag;for(let _=0,C=f.length;_<C;_+=1){let I=f[_];n.replacer&&(I=n.replacer.call(f,String(_),I)),(o(n,t+1,I,!0,!0,!1,!0)||typeof I>"u"&&o(n,t+1,null,!0,!0,!1,!0))&&((!y||S!=="")&&(S+=le(n,t)),n.dump&&u===n.dump.charCodeAt(0)?S+="-":S+="- ",S+=n.dump)}n.tag=x,n.dump=S||"[]"}function Je(n,t,f){let y="",S=n.tag,x=Object.keys(f);for(let _=0,C=x.length;_<C;_+=1){let I="";y!==""&&(I+=", "),n.condenseFlow&&(I+='"');let b=x[_],w=f[b];n.replacer&&(w=n.replacer.call(f,b,w)),o(n,t,b,!1,!1)&&(n.dump.length>1024&&(I+="? "),I+=n.dump+(n.condenseFlow?'"':"")+":"+(n.condenseFlow?"":" "),o(n,t,w,!1,!1)&&(I+=n.dump,y+=I))}n.tag=S,n.dump="{"+y+"}"}function Qe(n,t,f,y){let S="",x=n.tag,_=Object.keys(f);if(n.sortKeys===!0)_.sort();else if(typeof n.sortKeys=="function")_.sort(n.sortKeys);else if(n.sortKeys)throw new i("sortKeys must be a boolean or a function");for(let C=0,I=_.length;C<I;C+=1){let b="";(!y||S!=="")&&(b+=le(n,t));let w=_[C],L=f[w];if(n.replacer&&(L=n.replacer.call(f,w,L)),!o(n,t+1,w,!0,!0,!0))continue;let N=n.tag!==null&&n.tag!=="?"||n.dump&&n.dump.length>1024;N&&(n.dump&&u===n.dump.charCodeAt(0)?b+="?":b+="? "),b+=n.dump,N&&(b+=le(n,t)),o(n,t+1,L,!0,N)&&(n.dump&&u===n.dump.charCodeAt(0)?b+=":":b+=": ",b+=n.dump,S+=b)}n.tag=x,n.dump=S||"{}"}function e(n,t,f){let y=f?n.explicitTypes:n.implicitTypes;for(let S=0,x=y.length;S<x;S+=1){let _=y[S];if((_.instanceOf||_.predicate)&&(!_.instanceOf||typeof t=="object"&&t instanceof _.instanceOf)&&(!_.predicate||_.predicate(t))){if(f?_.multi&&_.representName?n.tag=_.representName(t):n.tag=_.tag:n.tag="?",_.represent){let C=n.styleMap[_.tag]||_.defaultStyle,I;if(m.call(_.represent)==="[object Function]")I=_.represent(t,C);else if(l.call(_.represent,C))I=_.represent[C](t,C);else throw new i("!<"+_.tag+'> tag resolver accepts not "'+C+'" style');n.dump=I}return!0}}return!1}function o(n,t,f,y,S,x,_){n.tag=null,n.dump=f,e(n,f,!1)||e(n,f,!0);let C=m.call(n.dump),I=y;y&&(y=n.flowLevel<0||n.flowLevel>t);let b=C==="[object Object]"||C==="[object Array]",w,L;if(b&&(w=n.duplicates.indexOf(f),L=w!==-1),(n.tag!==null&&n.tag!=="?"||L||n.indent!==2&&t>0)&&(S=!1),L&&n.usedDuplicates[w])n.dump="*ref_"+w;else{if(b&&L&&!n.usedDuplicates[w]&&(n.usedDuplicates[w]=!0),C==="[object Object]")y&&Object.keys(n.dump).length!==0?(Qe(n,t,n.dump,S),L&&(n.dump="&ref_"+w+n.dump)):(Je(n,t,n.dump),L&&(n.dump="&ref_"+w+" "+n.dump));else if(C==="[object Array]")y&&n.dump.length!==0?(n.noArrayIndent&&!_&&t>0?Ee(n,t-1,n.dump,S):Ee(n,t,n.dump,S),L&&(n.dump="&ref_"+w+n.dump)):(Xe(n,t,n.dump),L&&(n.dump="&ref_"+w+" "+n.dump));else if(C==="[object String]")n.tag!=="?"&&Ne(n,n.dump,t,x,I);else{if(C==="[object Undefined]")return!1;if(n.skipInvalid)return!1;throw new i("unacceptable kind of an object to dump "+C)}if(n.tag!==null&&n.tag!=="?"){let N=encodeURI(n.tag[0]==="!"?n.tag.slice(1):n.tag).replace(/!/g,"%21");n.tag[0]==="!"?N="!"+N:N.slice(0,18)==="tag:yaml.org,2002:"?N="!!"+N.slice(18):N="!<"+N+">",n.dump=N+" "+n.dump}}return!0}function E(n,t){let f=[],y=[];A(n,f,y);let S=y.length;for(let x=0;x<S;x+=1)t.duplicates.push(f[y[x]]);t.usedDuplicates=new Array(S)}function A(n,t,f){if(n!==null&&typeof n=="object"){let y=t.indexOf(n);if(y!==-1)f.indexOf(y)===-1&&f.push(y);else if(t.push(n),Array.isArray(n))for(let S=0,x=n.length;S<x;S+=1)A(n[S],t,f);else{let S=Object.keys(n);for(let x=0,_=S.length;x<_;x+=1)A(n[S[x]],t,f)}}}function a(n,t){t=t||{};let f=new Ve(t);f.noRefs||E(n,f);let y=n;return f.replacer&&(y=f.replacer.call({"":y},"",y)),o(f,0,y,!0,!0)?f.dump+`
|
|
35
|
-
`:""}return vn.dump=a,vn}var Er;function hi(){if(Er)return U;Er=1;let r=pi(),i=di();function c(m,l){return function(){throw new Error("Function yaml."+m+" is removed in js-yaml 4. Use yaml."+l+" instead, which is now safe by default.")}}return U.Type=H(),U.Schema=Ar(),U.FAILSAFE_SCHEMA=xr(),U.JSON_SCHEMA=br(),U.CORE_SCHEMA=wr(),U.DEFAULT_SCHEMA=bn(),U.load=r.load,U.loadAll=r.loadAll,U.dump=i.dump,U.YAMLException=xe(),U.types={binary:Nr(),float:vr(),map:Tr(),null:Cr(),pairs:Mr(),set:Pr(),timestamp:Rr(),bool:Or(),int:Ir(),merge:Lr(),omap:kr(),seq:Sr(),str:yr()},U.safeLoad=c("safeLoad","load"),U.safeLoadAll=c("safeLoadAll","loadAll"),U.safeDump=c("safeDump","dump"),U}var mi=hi(),fe=fi(mi),{Type:Gi,Schema:$i,FAILSAFE_SCHEMA:zi,JSON_SCHEMA:Vi,CORE_SCHEMA:Wi,DEFAULT_SCHEMA:Xi,load:Ji,loadAll:Qi,dump:Zi,YAMLException:eo,types:no,safeLoad:ro,safeLoadAll:io,safeDump:oo}=fe;var Dr=(r,i,c)=>p.preprocess(m=>m===void 0||typeof m=="string"&&!m.trim()?r:m,p.union([p.number(),p.string().trim().regex(/^\d+$/,"Enter a whole number").transform(Number)]).pipe(p.number().int().min(i).max(c))),Si=Se.extend({name:p.string().trim().min(1,"Name is required"),base_url:p.url("Enter a valid HTTP(S) URL").refine(r=>/^https?:\/\//i.test(r),"Use an HTTP(S) URL"),api_key:p.string().trim().min(1,"API key is required"),model:p.string().trim().min(1,"Model is required"),thinking:p.enum(ie).optional(),context_window:Dr(1e6,1e3,1e7),max_output_tokens:Dr(128e3,1,1e6)}).refine(r=>r.max_output_tokens<=r.context_window,{path:["max_output_tokens"],message:"Max output tokens must not exceed the context window"}).transform(r=>({...r,thinking:on(r)}));function wn(r){if(!Fr(r))return{};let i;try{i=fe.load(De(r,"utf-8"))}catch{throw new Error(`Unable to read existing ${r}; it has not been changed.`)}return p.record(p.string(),p.unknown()).parse(i??{})}function Rn(r,i){let c=Ai(r);kn(c,{recursive:!0});let m=yi(c,`.config-${gi()}.tmp`);try{Mn(m,fe.dump(i,{lineWidth:-1,noRefs:!0}),{encoding:"utf-8",mode:384,flag:"wx"}),_i(m,r)}finally{Fr(m)&&Ei(m)}}function mo(r,i){let c=Si.parse(r),m=se(),l=wn(m),g=[...p.array(p.record(p.string(),p.unknown())).parse(l.providers??[])];for(let d of i)g.some(O=>O.base_url===d.base_url)||g.push({...d});let u=[],T=!1;for(let d of g){if(d.base_url!==c.base_url){u.push(d);continue}T||(T=!0,u.push(c))}T||u.push(c);let s=u.map(d=>Se.parse(d));return Rn(m,{...l,providers:u}),{provider:c,providers:s,replaced:T,path:m}}function Ur(r,i,c){let m=se(),l=wn(m),h=p.array(p.record(p.string(),p.unknown())).parse(l.providers??[]),g=h.filter(T=>T.base_url===r);if(g.length===0)throw new Error(`Provider with base URL "${r}" not found in ${m}.`);let u=g.filter(T=>T[i]!==c);if(u.length!==0){for(let T of u)T[i]=c;Rn(m,{...l,providers:h})}}function go(r,i){Ur(r,"thinking",i)}function _o(r,i){Ur(r,"model",i)}function Eo(r){let i=se(),c=wn(i);c.default_provider!==r&&Rn(i,{...c,default_provider:r})}import{existsSync as zr,readFileSync as Oi}from"fs";import{join as Ii}from"path";function Ln(r){return!!r._zod}function qe(r,i){return Ln(r)?Ze(r,i):r.safeParse(i)}function Po(r){if(!r)return;let i;if(Ln(r)?i=r._zod?.def?.shape:i=r.shape,!!i){if(typeof i=="function")try{return i()}catch{return}return i}}function Ci(r){return r.length===0?"object root":r.reduce((i,c,m)=>m===0?String(c):typeof c=="number"?`${i}[${c}]`:`${i}.${c}`,"")}function Hr(r){if(r&&typeof r=="object"){if("issues"in r&&Array.isArray(r.issues)&&r.issues.length>0)return r.issues.map(i=>i.path?.length?`${i.message} at ${Ci(i.path)}`:i.message).join(`
|
|
36
|
-
`);if("message"in r&&typeof r.message=="string")return r.message;try{return JSON.stringify(r)}catch{return String(r)}}return String(r)}function Do(r){if(Ln(r)){let h=r._zod?.def;if(h){if(h.value!==void 0)return h.value;if(Array.isArray(h.values)&&h.values.length>0)return h.values[0]}}let c=r._def;if(c){if(c.value!==void 0)return c.value;if(Array.isArray(c.values)&&c.values.length>0)return c.values[0]}let m=r.value;if(m!==void 0)return m}var Uo="Content-Length",Ho=/^Content-Length:\s*(\d+)\s*$/gimu,Yo=`\r
|
|
37
|
-
\r
|
|
38
|
-
`;var jo="initialize",qo="initialized",Bo="shutdown",Ko="exit",Go="$/cancelRequest",$o="workspace/didChangeConfiguration",zo="workspace/applyEdit",Vo="workspace/configuration",Wo="workspace/workspaceFolders",Xo="window/showMessageRequest",Jo="window/workDoneProgress/create";var Qo="yukino",Zo="utf-16",et="LSP request interrupted",nt="LSP header exceeds 8KB",rt="Expected one Content-Length header",it="LSP message exceeds 16MB",ot="Invalid JSON-RPC message",tt="LSP request failed",lt="Unsupported read-only client method",ct="Yukino LSP is read-only; use authorized file tools for edits.",ut="Invalid LSP initialize response",st="Only UTF-16 LSP positions are supported",ft="LSP client disposed",Yr=/^\.[\w-]+$/u,jr="At least one file extension is required";var qr=p.object({name:p.string().trim().min(1),command:p.string().min(1),args:p.array(p.string()).optional(),languages:p.record(p.string().regex(Yr),p.string().min(1)).refine(r=>Object.keys(r).length>0,jr),env:p.record(p.string(),p.string()).optional(),initialization_options:p.record(p.string(),p.unknown()).optional(),settings:p.record(p.string(),p.unknown()).optional(),timeout_ms:p.number().int().min(100).max(6e4).optional()});var Be=Dn({module:"config"});function vi(r){return Fe.has(r)}var q=class extends Error{constructor(i,c){super(i,c),this.name="ConfigError"}};function It(r){if(r.api_key)return r.api_key;let i=vi(r.protocol)?nn[r.protocol]:"";return i?process.env[i]??"":""}var bi=p.object({name:p.string(),enabled:p.boolean().optional(),command:p.string().optional(),args:p.array(p.string()).optional(),url:p.string().optional(),transport:p.string().optional(),headers:p.record(p.string(),p.string()).optional(),env:p.record(p.string(),p.string()).optional()}),wi=p.object({id:p.string().optional(),event:p.string(),condition:p.string().optional(),action:p.object({type:p.string(),command:p.string().optional(),url:p.string().optional(),method:p.string().optional(),prompt:p.string().optional()}),reject:p.boolean().optional(),once:p.boolean().optional(),async:p.boolean().optional(),on_error:p.string().optional()}),Ri=p.object({enabled:p.boolean().optional(),auto_allow:p.boolean().optional(),network_enabled:p.boolean().optional()}),Br=p.union([p.string(),p.number(),p.boolean()]).nullish().transform(r=>r==null?"":String(r)),Li=p.union([p.record(p.string(),Br),p.array(p.record(p.string(),Br)),p.null()]).transform(r=>{if(r===null)return{};if(!Array.isArray(r))return r;let i={};for(let c of r)for(let[m,l]of Object.entries(c))i[m]=l;return i}),Vr=p.looseObject({default_provider:p.number().default(0),providers:p.array(Se),permission_mode:p.string().optional(),mcp_loading:p.enum(jn).default("auto"),theme:p.enum(qn).default("auto"),mcp_servers:p.array(bi).default([]),lsp_servers:p.array(qr).refine(r=>new Set(r.map(i=>i.name)).size===r.length,"LSP server names must be unique").optional(),hooks:p.array(wi).default([]),sandbox:Ri.optional(),enable_coordinator_mode:p.boolean().optional(),enable_fork:p.boolean().optional(),enable_memory:p.boolean().optional(),env:Li.optional()});function vt(r){return r.enable_fork!==!1}function bt(r){return r.enable_memory!==!1}function Ni(r){if(r)for(let[i,c]of Object.entries(r))process.env[i]===void 0&&(process.env[i]=c)}function wt(){try{Ui(void 0,{allowEmptyProviders:!0})}catch{}}function ki(r){if(!r||typeof r!="object")return rn;let i=en(r),c=typeof i.reason=="string"&&i.reason.length>0?i.reason:rn,m=en(i.mark);if(typeof m.line=="number"){let l=String(m.line+1),h=typeof m.column=="number"?`, column ${String(m.column+1)}`:"";return`${c} (line ${l}${h})`}return c}function Kr(r){let i=De(r,"utf-8"),c;try{c=fe.load(i)}catch(h){throw new q(`Invalid YAML in ${r}: ${ki(h)}`,{cause:h})}let m=qe(Vr,c);if(!m.success)throw new q(`Invalid configuration in ${r}: ${Hr(m.error)}`);let l=m.data;return Ni(l.env),{...l,providers:l.providers.map(Gn)}}function Gr(r){if(r.providers.length===0)throw new q(Kn);let i=["name","protocol","base_url","model"],c=new Map;for(let m=0;m<r.providers.length;m++){let l=r.providers[m],h={name:l.name,protocol:l.protocol,base_url:l.base_url,model:l.model},g=i.filter(T=>!h[T].trim());if(g.length>0)throw new q(`Provider #${String(m+1)}: missing fields: ${g.join(", ")}`);if(!Fe.has(l.protocol))throw new q(`Provider #${String(m+1)}: invalid protocol '${l.protocol}', MUST be one of: ${Array.from(Fe).join(", ")}`);let u=c.get(l.base_url);if(u!==void 0)throw new q(`Provider #${String(m+1)}: duplicate base_url '${l.base_url}' (already used by provider #${String(u+1)}).`);c.set(l.base_url,m)}}function $r(r){let i=new Map;for(let c=0;c<r.mcp_servers.length;c++){let m=r.mcp_servers[c],l=`MCP server #${String(c+1)}`;if(!m.name.trim())throw new q(`${l}: name must not be empty.`);let h=i.get(m.name);if(h!==void 0)throw new q(`${l}: duplicate name '${m.name}' (already used by MCP server #${String(h+1)}).`);i.set(m.name,c);let g=!!m.command?.trim(),u=!!m.url?.trim();if(g===u)throw new q(`${l} '${m.name}': configure exactly one of command or url.`);if(g&&m.transport&&m.transport!=="stdio")throw new q(`${l} '${m.name}': command servers must use stdio.`);if(u&&m.transport&&!["http","sse"].includes(m.transport))throw new q(`${l} '${m.name}': URL transport must be http or sse.`)}}var Mi=p.looseObject({enabled:p.boolean().default(!0),command:p.string().optional(),args:p.array(p.string()).optional(),env:p.record(p.string(),p.string()).optional(),type:p.enum(["stdio","sse","http"]).optional(),url:p.string().optional(),headers:p.record(p.string(),p.string()).optional()}),Pi=p.looseObject({mcpServers:p.record(p.string(),p.unknown()).default({})});function Di(r,i){let c=i.type??(i.command!==void 0?"stdio":"http");return c==="stdio"?!i.command||i.url!==void 0?null:{name:r,command:i.command,args:i.args,env:i.env}:!i.url||i.command!==void 0?null:{name:r,url:i.url,transport:c,headers:i.headers}}function Fi(r){let i=Ii(r,Bn);if(!zr(i))return[];let c;try{c=JSON.parse(Oi(i,"utf-8"))}catch(h){return Be.error({err:h,path:i},"invalid .mcp.json"),[]}let m=qe(Pi,c);if(!m.success)return Be.error({error:m.error,path:i},"invalid .mcp.json"),[];let l=[];for(let[h,g]of Object.entries(m.data.mcpServers)){let u=qe(Mi,g);if(!h.trim()||!u.success){Be.warn({name:h,path:i,error:u.success?void 0:u.error},"skipping invalid .mcp.json server entry");continue}if(!u.data.enabled)continue;let T=Di(h,u.data);T?l.push(T):Be.warn({name:h,path:i},"skipping invalid .mcp.json server entry")}return l}function Rt(r,i){let c=Fi(i);if(c.length===0)return r;let m=new Set(r.mcp_servers.map(l=>l.name));return{...r,mcp_servers:[...r.mcp_servers,...c.filter(l=>!m.has(l.name))]}}function Ui(r,i={}){if(r){let l=Kr(r);return $r(l),(!i.allowEmptyProviders||l.providers.length>0)&&Gr(l),l}let c=se();if(!zr(c)){if(i.allowEmptyProviders)return Vr.parse({providers:[]});throw new q(`No config file found, expected ${c}.`)}let m=Kr(c);return $r(m),(!i.allowEmptyProviders||m.providers.length>0)&&Gr(m),m}var Wr="Tool execution was interrupted. The tool may or may not have completed; verify before relying on its effects.",Nt="The user rejected this tool use. Nothing was changed (for file edits, the new content was NOT written).",kt="<system-reminder>",Mt="</system-reminder>",Pt=/<(?=\s*\/?\s*system-reminder\b)/giu,Dt=/^(.+)#L(\d+)(?:-(\d+))?$/,Ft=/(?:^|\s)(?:'@([^']+)'|"@([^"]+)"|@"([^"]+)"|@'([^']+)'|@([^\s]+))/g;function Yt(r){let i=[];for(let c=0;c<r.length;c++){let m=r[c];if(m.role==="assistant"&&m.toolUses?.length){i.push(m);let l=new Set(m.toolUses.map(u=>u.toolUseId)),h=[],g=[];for(;c+1<r.length;){let u=r[c+1];if(u.role!=="user"||!u.toolResults?.length||u.toolUses?.length)break;c++,g.push(u);for(let T of u.toolResults)l.delete(T.toolUseId)&&h.push(T)}for(let u of l)h.push({toolUseId:u,content:Wr,isError:!0});i.push({...g[0]??{role:"user",content:""},toolResults:h});for(let u of g.slice(1))(u.content.length>0||u.thinkingBlocks?.length)&&i.push({...u,toolResults:[]});continue}if((m.toolResults?.length??0)>0){if(m.content.length===0&&!m.toolUses?.length&&!m.thinkingBlocks?.length)continue;i.push({...m,toolResults:[]})}else i.push(m)}return i}var oe=class extends Error{constructor(i){super(i),this.name="LLMError"}},Xr=class extends oe{constructor(i){super(i),this.name="AuthenticationError"}},Jr=class extends oe{retryAfter;constructor(i,c){super(i),this.name="RateLimitError",this.retryAfter=c}},Qr=class extends oe{constructor(i){super(i),this.name="NetworkError"}},Zr=class extends oe{constructor(c,m){super(c);this.retryAfter=m;this.name="ServerError"}retryAfter},ei=class extends oe{constructor(i){super(i),this.name="ContextTooLongError"}};function qt(r){return/context_length_exceeded/i.test(r)||/maximum\s+context\s+length/i.test(r)||/prompts?\s+(?:is\s+)?too\s+long/i.test(r)}var $t=5e3,zt=10,Vt="2023-06-01",Wt="Model discovery failed",Xt=3,Jt=6e4,Qt=1e3,Zt=5e3,ni=`~/${Nn}/${Ue}`,el=`Anthropic API key not found, set ANTHROPIC_API_KEY in ${ni}, or via ANTHROPIC_API_KEY env variable.`,nl=`OpenAI API key not found, set OPENAI_API_KEY in ${ni}, or via OPENAI_API_KEY env variable.`;export{qe as a,Po as b,Do as c,fe as d,ie as e,Fn as f,Hn as g,Yn as h,se as i,qi as j,Bi as k,on as l,Ki as m,tn as n,li as o,ci as p,ui as q,$n as r,zn as s,Uo as t,Ho as u,Yo as v,jo as w,qo as x,Bo as y,Ko as z,Go as A,$o as B,zo as C,Vo as D,Wo as E,Xo as F,Jo as G,Qo as H,Zo as I,et as J,nt as K,rt as L,it as M,ot as N,tt as O,lt as P,ct as Q,ut as R,st as S,ft as T,Si as U,mo as V,go as W,_o as X,Eo as Y,It as Z,vt as _,bt as $,wt as aa,Rt as ba,Ui as ca,Nt as da,kt as ea,Mt as fa,Pt as ga,Dt as ha,Ft as ia,Yt as ja,oe as ka,Xr as la,Jr as ma,Qr as na,Zr as oa,ei as pa,qt as qa,$t as ra,zt as sa,Vt as ta,Wt as ua,Xt as va,Jt as wa,Qt as xa,Zt as ya,el as za,nl as Aa};
|
package/dist/chunk-A4IB5PNW.js
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
import { createRequire as __yukinoCreateRequire } from "node:module";
|
|
3
|
-
const require = __yukinoCreateRequire(import.meta.url);
|
|
4
|
-
import{h as mn}from"./chunk-UX5DJPHN.js";import{C as zn,D as pn,E as hn,Za as fn,q as ln,t as un,v as dn}from"./chunk-DGDF5PBF.js";import{$ as rn,_ as on,ba as an,ca as cn,j as sn}from"./chunk-676RWZYX.js";import{Kc as Me,Rc as qe}from"./chunk-BCYFGWSM.js";import{a as nn}from"./chunk-S56AXDDN.js";import{C as U,f as n,g as en,h as x,i as q,j as C,k as ze,m as a,n as b,o as i,p as tn,q as h,s as H,t as l,v as u}from"./chunk-WGRGSG2J.js";var z={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"},f={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_message:"mcp/message",elicitation_create:"elicitation/create",elicitation_complete:"elicitation/complete"},Ae={cancel_request:"$/cancel_request"},je=1;var gn=Symbol("skippedItem");function s(o,e){return o.catch(e)}function v(o,e){let t=o.catch(e);return U.unknown().transform((r,c)=>r!==void 0?t.parse(r):(c.addIssue({code:"custom",message:"Required value is missing"}),U.NEVER))}function _n(o,e){if(o===null||typeof o!="object"||Array.isArray(o))return;let t=o[e];return typeof t=="string"?t:void 0}function W(o,e,t){return o.superRefine((r,c)=>{let d=_n(r,e);d!==void 0&&t.includes(d)&&c.addIssue({code:"custom",path:[e],message:`${e} ${JSON.stringify(d)} is reserved by a known variant, but the value does not match that variant's schema`})})}function $(o,e,t){return U.unknown().transform((r,c)=>{let d=o.safeParse(r);if(!d.success){for(let g of d.error.issues)c.addIssue({...g,input:r});return U.NEVER}let p=d.data,m=_n(r,e);if(m!==void 0&&!t.includes(m)){let g=r;for(let[E,S]of Object.entries(g))E!=="__proto__"&&(Object.hasOwn(p,E)||(p[E]=S))}return p})}function Sn(o,e){return U.preprocess(t=>{if(t===null||typeof t!="object"||Array.isArray(t))return t;let r=t,c=r[e];if(c==null||typeof c=="string")return t;let d={...r};return delete d[e],d},o)}function w(o){return U.array(o.catch(gn)).transform(e=>e.filter(t=>t!==gn))}var L=h([x(),n()]).nullable(),R=n(),ve=i({sessionId:R,path:n(),content:n(),_meta:s(l(n(),a()).nullish(),()=>{})}),De=i({sessionId:R,path:n(),line:q().gte(0).max(4294967295,{error:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),limit:q().gte(0).max(4294967295,{error:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),_meta:s(l(n(),a()).nullish(),()=>{})}),He=n(),bn=h([u("read"),u("edit"),u("delete"),u("move"),u("search"),u("execute"),u("think"),u("fetch"),u("switch_mode"),u("other")]),En=h([u("pending"),u("in_progress"),u("completed"),u("failed")]),Gs=h([u("assistant"),u("user")]),se=i({audience:s(w(Gs).nullish(),()=>{}),lastModified:s(n().nullish(),()=>{}),priority:s(x().nullish(),()=>{}),_meta:s(l(n(),a()).nullish(),()=>{})}),Fs=i({annotations:s(se.nullish(),()=>{}),text:n(),_meta:s(l(n(),a()).nullish(),()=>{})}),Bs=i({annotations:s(se.nullish(),()=>{}),data:n(),mimeType:n(),uri:s(n().nullish(),()=>{}),_meta:s(l(n(),a()).nullish(),()=>{})}),Ws=i({annotations:s(se.nullish(),()=>{}),data:n(),mimeType:n(),_meta:s(l(n(),a()).nullish(),()=>{})}),$s=i({annotations:s(se.nullish(),()=>{}),description:s(n().nullish(),()=>{}),mimeType:s(n().nullish(),()=>{}),name:n(),size:s(x().nullish(),()=>{}),title:s(n().nullish(),()=>{}),uri:n(),_meta:s(l(n(),a()).nullish(),()=>{})}),Vs=i({mimeType:s(n().nullish(),()=>{}),text:n(),uri:n(),_meta:s(l(n(),a()).nullish(),()=>{})}),Ks=i({blob:n(),mimeType:s(n().nullish(),()=>{}),uri:n(),_meta:s(l(n(),a()).nullish(),()=>{})}),Js=h([Vs,Ks]),Qs=i({annotations:s(se.nullish(),()=>{}),resource:Js,_meta:s(l(n(),a()).nullish(),()=>{})}),G=h([Fs.and(i({type:u("text")})),Bs.and(i({type:u("image")})),Ws.and(i({type:u("audio")})),$s.and(i({type:u("resource_link")})),Qs.and(i({type:u("resource")}))]),Ys=i({content:G,_meta:s(l(n(),a()).nullish(),()=>{})}),Xs=i({path:n(),oldText:s(n().nullish(),()=>{}),newText:n(),_meta:s(l(n(),a()).nullish(),()=>{})}),Q=n(),Zs=i({terminalId:Q,_meta:s(l(n(),a()).nullish(),()=>{})}),Rn=h([Ys.and(i({type:u("content")})),Xs.and(i({type:u("diff")})),Zs.and(i({type:u("terminal")}))]),Tn=i({path:n(),line:s(q().gte(0).max(4294967295,{error:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),()=>{}),_meta:s(l(n(),a()).nullish(),()=>{})}),xn=i({toolCallId:He,kind:s(bn.nullish(),()=>{}),status:s(En.nullish(),()=>{}),title:s(n().nullish(),()=>{}),name:s(n().nullish(),()=>{}),content:s(w(Rn).nullish(),()=>{}),locations:s(w(Tn).nullish(),()=>{}),rawInput:s(a().optional(),()=>{}),rawOutput:s(a().optional(),()=>{}),_meta:s(l(n(),a()).nullish(),()=>{})}),wn=n(),eo=h([u("allow_once"),u("allow_always"),u("reject_once"),u("reject_always")]),to=i({optionId:wn,name:n(),kind:eo,_meta:s(l(n(),a()).nullish(),()=>{})}),Ue=i({sessionId:R,toolCall:xn,options:b(to),_meta:s(l(n(),a()).nullish(),()=>{})}),yn=i({name:n(),value:n(),_meta:s(l(n(),a()).nullish(),()=>{})}),Le=i({sessionId:R,command:n(),args:b(n()).optional(),env:b(yn).optional(),cwd:n().nullish(),outputByteLimit:x().nullish(),_meta:s(l(n(),a()).nullish(),()=>{})}),Ge=i({sessionId:R,terminalId:Q,_meta:s(l(n(),a()).nullish(),()=>{})}),Fe=i({sessionId:R,terminalId:Q,_meta:s(l(n(),a()).nullish(),()=>{})}),Be=i({sessionId:R,terminalId:Q,_meta:s(l(n(),a()).nullish(),()=>{})}),We=i({sessionId:R,terminalId:Q,_meta:s(l(n(),a()).nullish(),()=>{})}),oe=i({sessionId:R,toolCallId:s(He.nullish(),()=>{})}),ie=i({requestId:L}),no=u("object"),so=h([u("email"),u("uri"),u("date"),u("date-time")]),Cn=i({const:n(),title:n(),description:s(n().nullish(),()=>{}),_meta:s(l(n(),a()).nullish(),()=>{})}),$e=i({title:s(n().nullish(),()=>{}),description:s(n().nullish(),()=>{}),minLength:q().gte(0).max(4294967295,{error:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),maxLength:q().gte(0).max(4294967295,{error:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),pattern:n().nullish(),format:so.nullish(),default:s(n().nullish(),()=>{}),enum:b(n()).nullish(),oneOf:b(Cn).nullish(),_meta:s(l(n(),a()).nullish(),()=>{})}),Ve=i({title:s(n().nullish(),()=>{}),description:s(n().nullish(),()=>{}),minimum:x().nullish(),maximum:x().nullish(),default:s(x().nullish(),()=>{}),_meta:s(l(n(),a()).nullish(),()=>{})}),Ke=i({title:s(n().nullish(),()=>{}),description:s(n().nullish(),()=>{}),minimum:x().nullish(),maximum:x().nullish(),default:s(x().nullish(),()=>{}),_meta:s(l(n(),a()).nullish(),()=>{})}),Je=i({title:s(n().nullish(),()=>{}),description:s(n().nullish(),()=>{}),default:s(C().nullish(),()=>{}),_meta:s(l(n(),a()).nullish(),()=>{})}),Qe=i({enum:b(n()),_meta:s(l(n(),a()).nullish(),()=>{})}),On=i({anyOf:b(Cn),_meta:s(l(n(),a()).nullish(),()=>{})}),oo=$(h([Qe.and(i({type:u("string")})),W(i({type:n()}),"type",["string"]),On]),"type",["string"]),Ye=i({title:s(n().nullish(),()=>{}),description:s(n().nullish(),()=>{}),minItems:x().nullish(),maxItems:x().nullish(),items:oo,default:s(w(n()).nullish(),()=>{}),_meta:s(l(n(),a()).nullish(),()=>{})}),io=$(h([$e.and(i({type:u("string")})),Ve.and(i({type:u("number")})),Ke.and(i({type:u("integer")})),Je.and(i({type:u("boolean")})),Ye.and(i({type:u("array")})),W(i({type:n()}),"type",["array","boolean","integer","number","string"])]),"type",["array","boolean","integer","number","string"]),ro=i({type:s(no.optional().default("object"),()=>"object"),title:s(n().nullish(),()=>{}),properties:l(n(),io).optional().default({}),required:b(n()).nullish(),description:s(n().nullish(),()=>{}),_meta:s(l(n(),a()).nullish(),()=>{})}),Xe=H(h([oe,ie]),i({requestedSchema:ro})),In=n(),Ze=H(h([oe,ie]),i({elicitationId:In,url:en()})),et=$(H(h([Xe.and(i({mode:u("form")})),Ze.and(i({mode:u("url")})),W(H(h([oe,ie]),i({mode:n()})),"mode",["form","url"])]),i({message:n(),_meta:s(l(n(),a()).nullish(),()=>{})})),"mode",["form","url"]),tt=n(),kn=n(),ao=i({serverId:tt,requestId:kn,method:n(),params:l(n(),a()).nullish(),_meta:s(l(n(),a()).nullish(),()=>{})}),Nn=a(),Vr=i({id:L,method:n(),params:h([ve,De,Ue,Le,Ge,Fe,Be,We,et,ao,Nn]).nullish()}),Mn=q().gte(0).lte(65535),co=i({image:s(C().optional().default(!1),()=>!1),audio:s(C().optional().default(!1),()=>!1),embeddedContext:s(C().optional().default(!1),()=>!1),_meta:s(l(n(),a()).nullish(),()=>{})}),lo=i({http:s(C().optional().default(!1),()=>!1),sse:s(C().optional().default(!1),()=>!1),acp:s(C().optional().default(!1),()=>!1),_meta:s(l(n(),a()).nullish(),()=>{})}),uo=i({_meta:s(l(n(),a()).nullish(),()=>{})}),zo=i({_meta:s(l(n(),a()).nullish(),()=>{})}),po=i({_meta:s(l(n(),a()).nullish(),()=>{})}),ho=i({_meta:s(l(n(),a()).nullish(),()=>{})}),fo=i({override:s(ho.nullish(),()=>{}),_meta:s(l(n(),a()).nullish(),()=>{})}),mo=i({mode:s(fo.nullish(),()=>{}),_meta:s(l(n(),a()).nullish(),()=>{})}),go=i({_meta:s(l(n(),a()).nullish(),()=>{})}),_o=i({_meta:s(l(n(),a()).nullish(),()=>{})}),So=i({_meta:s(l(n(),a()).nullish(),()=>{})}),bo=i({list:s(uo.nullish(),()=>{}),delete:s(zo.nullish(),()=>{}),additionalDirectories:s(po.nullish(),()=>{}),systemPrompt:s(mo.nullish(),()=>{}),fork:s(go.nullish(),()=>{}),resume:s(_o.nullish(),()=>{}),close:s(So.nullish(),()=>{}),_meta:s(l(n(),a()).nullish(),()=>{})}),Eo=i({_meta:s(l(n(),a()).nullish(),()=>{})}),Ro=i({logout:s(Eo.nullish(),()=>{}),_meta:s(l(n(),a()).nullish(),()=>{})}),To=i({_meta:s(l(n(),a()).nullish(),()=>{})}),xo=i({loadSession:s(C().optional().default(!1),()=>!1),promptCapabilities:s(co.optional().default({image:!1,audio:!1,embeddedContext:!1}),()=>({image:!1,audio:!1,embeddedContext:!1})),mcpCapabilities:s(lo.optional().default({http:!1,sse:!1,acp:!1}),()=>({http:!1,sse:!1,acp:!1})),sessionCapabilities:s(bo.optional().default({}),()=>({})),auth:s(Ro.optional().default({}),()=>({})),providers:s(To.nullish(),()=>{}),_meta:s(l(n(),a()).nullish(),()=>{})}),nt=n(),wo=i({id:nt,name:n(),description:s(n().nullish(),()=>{}),args:b(n()).optional(),env:l(n(),n()).optional(),_meta:s(l(n(),a()).nullish(),()=>{})}),yo=i({id:nt,name:n(),description:s(n().nullish(),()=>{}),_meta:s(l(n(),a()).nullish(),()=>{})}),Co=h([wo.and(i({type:u("terminal")})),yo]),qn=i({name:n(),title:s(n().nullish(),()=>{}),version:n(),_meta:s(l(n(),a()).nullish(),()=>{})}),Oo=i({protocolVersion:Mn,agentCapabilities:s(xo.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:s(w(Co).optional().default([]),()=>[]),agentInfo:s(qn.nullish(),()=>{}),_meta:s(l(n(),a()).nullish(),()=>{})}),Io=i({_meta:s(l(n(),a()).nullish(),()=>{})}),st=n(),ot=h([u("anthropic"),u("openai"),u("azure"),u("vertex"),u("bedrock"),n()]),ko=i({apiType:ot,baseUrl:n(),_meta:s(l(n(),a()).nullish(),()=>{})}),No=i({providerId:st,supported:v(w(ot),()=>[]),required:C(),current:ko.nullish(),_meta:s(l(n(),a()).nullish(),()=>{})}),Mo=i({providers:b(No),_meta:s(l(n(),a()).nullish(),()=>{})}),qo=i({_meta:s(l(n(),a()).nullish(),()=>{})}),Ao=i({_meta:s(l(n(),a()).nullish(),()=>{})}),jo=i({_meta:s(l(n(),a()).nullish(),()=>{})}),pe=n(),Po=i({id:pe,name:n(),description:s(n().nullish(),()=>{}),_meta:s(l(n(),a()).nullish(),()=>{})}),he=i({currentModeId:pe,availableModes:v(w(Po),()=>[]),_meta:s(l(n(),a()).nullish(),()=>{})}),An=n(),vo=h([u("mode"),u("model"),u("model_config"),u("thought_level"),n()]),it=n(),jn=i({value:it,name:n(),description:s(n().nullish(),()=>{}),_meta:s(l(n(),a()).nullish(),()=>{})}),Do=n(),Ho=i({group:Do,name:n(),options:v(w(jn),()=>[]),_meta:s(l(n(),a()).nullish(),()=>{})}),Uo=h([b(jn),b(Ho)]),Lo=i({currentValue:it,options:Uo}),Go=i({currentValue:C()}),Y=H(h([Lo.and(i({type:u("select")})),Go.and(i({type:u("boolean")}))]),i({id:An,name:n(),description:s(n().nullish(),()=>{}),category:s(vo.nullish(),()=>{}),_meta:s(l(n(),a()).nullish(),()=>{})})),Fo=i({sessionId:R,modes:s(he.nullish(),()=>{}),configOptions:s(w(Y).nullish(),()=>{}),_meta:s(l(n(),a()).nullish(),()=>{})}),Bo=i({modes:s(he.nullish(),()=>{}),configOptions:s(w(Y).nullish(),()=>{}),_meta:s(l(n(),a()).nullish(),()=>{})}),Wo=i({sessionId:R,cwd:n(),additionalDirectories:s(w(n()).optional(),()=>[]),title:s(n().nullish(),()=>{}),updatedAt:s(n().nullish(),()=>{}),_meta:s(l(n(),a()).nullish(),()=>{})}),$o=i({sessions:v(w(Wo),()=>[]),nextCursor:s(n().nullish(),()=>{}),_meta:s(l(n(),a()).nullish(),()=>{})}),Vo=i({_meta:s(l(n(),a()).nullish(),()=>{})}),Ko=i({sessionId:R,modes:s(he.nullish(),()=>{}),configOptions:s(w(Y).nullish(),()=>{}),_meta:s(l(n(),a()).nullish(),()=>{})}),Jo=i({modes:s(he.nullish(),()=>{}),configOptions:s(w(Y).nullish(),()=>{}),_meta:s(l(n(),a()).nullish(),()=>{})}),Qo=i({_meta:s(l(n(),a()).nullish(),()=>{})}),Yo=i({_meta:s(l(n(),a()).nullish(),()=>{})}),Xo=i({configOptions:v(w(Y),()=>[]),_meta:s(l(n(),a()).nullish(),()=>{})}),Zo=h([u("end_turn"),u("max_tokens"),u("max_turn_requests"),u("refusal"),u("cancelled")]),fe=i({totalTokens:x(),inputTokens:x(),outputTokens:x(),thoughtTokens:s(x().nullish(),()=>{}),cachedReadTokens:s(x().nullish(),()=>{}),cachedWriteTokens:s(x().nullish(),()=>{}),_meta:s(l(n(),a()).nullish(),()=>{})}),ei=i({stopReason:Zo,usage:s(fe.nullish(),()=>{}),_meta:s(l(n(),a()).nullish(),()=>{})}),Pn=a(),ti=h([u(-32700),u(-32600),u(-32601),u(-32602),u(-32603),u(-32800),u(-32e3),u(-32002),q().min(-2147483648,{error:"Invalid value: Expected int32 to be >= -2147483648"}).max(2147483647,{error:"Invalid value: Expected int32 to be <= 2147483647"})]),re=i({code:ti,message:n(),data:s(a().optional(),()=>{})}),Kr=h([i({id:L,result:h([Oo,Io,Mo,qo,Ao,jo,Fo,Bo,$o,Vo,Ko,Jo,Qo,Yo,Xo,ei,Pn])}),i({id:L,error:re})]),rt=n(),Pe=i({content:G,messageId:s(rt.nullish(),()=>{}),_meta:s(l(n(),a()).nullish(),()=>{})}),ni=i({toolCallId:He,title:n(),name:s(n().nullish(),()=>{}),kind:s(bn.optional(),()=>{}),status:s(En.optional(),()=>{}),content:s(w(Rn).optional(),()=>[]),locations:s(w(Tn).optional(),()=>[]),rawInput:s(a().optional(),()=>{}),rawOutput:s(a().optional(),()=>{}),_meta:s(l(n(),a()).nullish(),()=>{})}),si=h([u("high"),u("medium"),u("low")]),oi=h([u("pending"),u("in_progress"),u("completed")]),vn=i({content:n(),priority:si,status:oi,_meta:s(l(n(),a()).nullish(),()=>{})}),ii=i({entries:v(w(vn),()=>[]),_meta:s(l(n(),a()).nullish(),()=>{})}),me=n(),ri=i({planId:me,entries:v(w(vn),()=>[]),_meta:s(l(n(),a()).nullish(),()=>{})}),ai=i({planId:me,uri:n(),_meta:s(l(n(),a()).nullish(),()=>{})}),ci=i({planId:me,content:n(),_meta:s(l(n(),a()).nullish(),()=>{})}),li=h([ri.and(i({type:u("items")})),ai.and(i({type:u("file")})),ci.and(i({type:u("markdown")}))]),ui=i({plan:li,_meta:s(l(n(),a()).nullish(),()=>{})}),di=i({planId:me,_meta:s(l(n(),a()).nullish(),()=>{})}),zi=i({hint:n(),_meta:s(l(n(),a()).nullish(),()=>{})}),pi=zi,hi=i({name:n(),description:n(),input:s(pi.nullish(),()=>{}),_meta:s(l(n(),a()).nullish(),()=>{})}),fi=i({availableCommands:v(w(hi),()=>[]),_meta:s(l(n(),a()).nullish(),()=>{})}),mi=i({currentModeId:pe,_meta:s(l(n(),a()).nullish(),()=>{})}),gi=i({configOptions:v(w(Y),()=>[]),_meta:s(l(n(),a()).nullish(),()=>{})}),_i=i({title:s(n().nullish(),()=>{}),updatedAt:s(n().nullish(),()=>{}),_meta:s(l(n(),a()).nullish(),()=>{})}),Si=i({amount:x(),currency:n(),_meta:s(l(n(),a()).nullish(),()=>{})}),bi=i({used:x(),size:x(),cost:s(Si.nullish(),()=>{}),_meta:s(l(n(),a()).nullish(),()=>{})}),Ei=h([u("info"),u("warning"),u("error"),n()]),Ri=i({severity:Ei,title:n().min(1),description:s(n().nullish(),()=>{}),_meta:s(l(n(),a()).nullish(),()=>{})}),Dn=n(),Ti=h([u("in_progress"),u("completed"),u("failed"),u("cancelled"),n()]),xi=i({compactionId:Dn,status:Ti,summary:s(w(G).nullish(),()=>{}),error:s(n().nullish(),()=>{}),_meta:s(l(n(),a()).nullish(),()=>{})}),wi=i({compactionId:Dn,content:G,_meta:s(l(n(),a()).nullish(),()=>{})}),yi=i({_meta:s(l(n(),a()).nullish(),()=>{})}),Ci=i({cancel:s(yi.nullish(),()=>{}),_meta:s(l(n(),a()).nullish(),()=>{})}),at=i({_meta:s(l(n(),a()).nullish(),()=>{})}),ct=i({error:s(re.nullish(),()=>{})}),lt=Sn($(H(h([i({stopReason:u("end_turn")}),i({stopReason:u("max_tokens")}),i({stopReason:u("max_turn_requests")}),i({stopReason:u("refusal")}),i({stopReason:u("cancelled")}),ct.and(i({stopReason:u("error")})),W(i({stopReason:n()}),"stopReason",["cancelled","end_turn","error","max_tokens","max_turn_requests","refusal"]),i({stopReason:ze().optional()})]),i({usage:s(fe.nullish(),()=>{}),_meta:s(l(n(),a()).nullish(),()=>{}),stopReason:s(n().nullish(),()=>{})})),"stopReason",["cancelled","end_turn","error","max_tokens","max_turn_requests","refusal"]),"stopReason"),ut=i({_meta:s(l(n(),a()).nullish(),()=>{})}),dt=i({_meta:s(l(n(),a()).nullish(),()=>{})}),Oi=$(h([at.and(i({state:u("running")})),lt.and(i({state:u("idle")})),ut.and(i({state:u("requires_action")})),dt.and(i({state:u("unknown")})),W(i({state:n()}),"state",["idle","requires_action","running","unknown"])]),"state",["idle","requires_action","running","unknown"]),Ii=i({sessionId:R,title:s(n().nullish(),()=>{}),description:s(n().nullish(),()=>{}),capabilities:s(Ci.nullish(),()=>{}),state:s(Oi.nullish(),()=>{}),_meta:s(l(n(),a()).nullish(),()=>{})}),ki=i({messageId:rt,senderSessionId:s(R.nullish(),()=>{}),recipientSessionId:s(R.nullish(),()=>{}),content:s(w(G).nullish(),()=>{}),_meta:s(l(n(),a()).nullish(),()=>{})}),Ni=i({messageId:rt,senderSessionId:s(R.nullish(),()=>{}),recipientSessionId:s(R.nullish(),()=>{}),content:G,_meta:s(l(n(),a()).nullish(),()=>{})}),Mi=h([Pe.and(i({sessionUpdate:u("user_message_chunk")})),Pe.and(i({sessionUpdate:u("agent_message_chunk")})),Pe.and(i({sessionUpdate:u("agent_thought_chunk")})),ni.and(i({sessionUpdate:u("tool_call")})),xn.and(i({sessionUpdate:u("tool_call_update")})),ii.and(i({sessionUpdate:u("plan")})),ui.and(i({sessionUpdate:u("plan_update")})),di.and(i({sessionUpdate:u("plan_removed")})),fi.and(i({sessionUpdate:u("available_commands_update")})),mi.and(i({sessionUpdate:u("current_mode_update")})),gi.and(i({sessionUpdate:u("config_option_update")})),_i.and(i({sessionUpdate:u("session_info_update")})),bi.and(i({sessionUpdate:u("usage_update")})),Ri.and(i({sessionUpdate:u("notice")})),xi.and(i({sessionUpdate:u("compaction_update")})),wi.and(i({sessionUpdate:u("compaction_summary_chunk")})),Ii.and(i({sessionUpdate:u("subagent_update")})),ki.and(i({sessionUpdate:u("session_message")})),Ni.and(i({sessionUpdate:u("session_message_chunk")}))]),ge=i({sessionId:R,update:Mi,_meta:s(l(n(),a()).nullish(),()=>{})}),zt=i({elicitationId:In,_meta:s(l(n(),a()).nullish(),()=>{})}),Hn=a(),Jr=i({method:n(),params:h([ge,zt,Hn]).nullish()}),qi=i({readTextFile:s(C().optional().default(!1),()=>!1),writeTextFile:s(C().optional().default(!1),()=>!1),_meta:s(l(n(),a()).nullish(),()=>{})}),Ai=l(n(),a()),ji=i({_meta:s(l(n(),a()).nullish(),()=>{})}),Pi=i({boolean:s(ji.nullish(),()=>{}),_meta:s(l(n(),a()).nullish(),()=>{})}),vi=l(n(),a()),Di=i({compaction:s(Ai.nullish(),()=>{}),configOptions:s(Pi.nullish(),()=>{}),notices:s(vi.nullish(),()=>{}),_meta:s(l(n(),a()).nullish(),()=>{})}),Hi=i({_meta:s(l(n(),a()).nullish(),()=>{})}),Ui=i({_meta:s(l(n(),a()).nullish(),()=>{})}),Li=i({terminal:s(C().optional().default(!1),()=>!1),_meta:s(l(n(),a()).nullish(),()=>{})}),Gi=i({_meta:s(l(n(),a()).nullish(),()=>{})}),Fi=i({_meta:s(l(n(),a()).nullish(),()=>{})}),Bi=i({form:s(Gi.nullish(),()=>{}),url:s(Fi.nullish(),()=>{}),_meta:s(l(n(),a()).nullish(),()=>{})}),Wi=i({fs:s(qi.optional().default({readTextFile:!1,writeTextFile:!1}),()=>({readTextFile:!1,writeTextFile:!1})),terminal:s(C().optional().default(!1),()=>!1),session:s(Di.nullish(),()=>{}),subagents:s(Hi.nullish(),()=>{}),plan:s(Ui.nullish(),()=>{}),auth:s(Li.optional().default({terminal:!1}),()=>({terminal:!1})),elicitation:s(Bi.nullish(),()=>{}),_meta:s(l(n(),a()).nullish(),()=>{})}),pt=i({protocolVersion:Mn,clientCapabilities:s(Wi.optional().default({fs:{readTextFile:!1,writeTextFile:!1},terminal:!1,auth:{terminal:!1}}),()=>({fs:{readTextFile:!1,writeTextFile:!1},terminal:!1,auth:{terminal:!1}})),clientInfo:s(qn.nullish(),()=>{}),_meta:s(l(n(),a()).nullish(),()=>{})}),ht=i({methodId:nt,_meta:s(l(n(),a()).nullish(),()=>{})}),ft=i({_meta:s(l(n(),a()).nullish(),()=>{})}),mt=i({providerId:st,apiType:ot,baseUrl:n(),headers:l(n(),n()).optional(),_meta:s(l(n(),a()).nullish(),()=>{})}),gt=i({providerId:st,_meta:s(l(n(),a()).nullish(),()=>{})}),_t=i({_meta:s(l(n(),a()).nullish(),()=>{})}),Un=i({name:n(),value:n(),_meta:s(l(n(),a()).nullish(),()=>{})}),$i=i({name:n(),url:n(),headers:b(Un),_meta:s(l(n(),a()).nullish(),()=>{})}),Vi=i({name:n(),url:n(),headers:b(Un),_meta:s(l(n(),a()).nullish(),()=>{})}),Ki=i({name:n(),serverId:tt,_meta:s(l(n(),a()).nullish(),()=>{})}),Ji=i({name:n(),command:n(),args:b(n()),env:b(yn),_meta:s(l(n(),a()).nullish(),()=>{})}),_e=h([$i.and(i({type:u("http")})),Vi.and(i({type:u("sse")})),Ki.and(i({type:u("acp")})),Ji]),Qi=h([u("append"),u("override"),n()]),Se=i({mode:Qi,content:b(G),_meta:s(l(n(),a()).nullish(),()=>{})}),St=i({cwd:n(),additionalDirectories:b(n()).optional(),mcpServers:b(_e),systemPrompt:Se.nullish(),_meta:s(l(n(),a()).nullish(),()=>{})}),bt=i({mcpServers:b(_e),cwd:n(),additionalDirectories:b(n()).optional(),sessionId:R,systemPrompt:Se.nullish(),_meta:s(l(n(),a()).nullish(),()=>{})}),Et=i({cwd:n().nullish(),cursor:n().nullish(),_meta:s(l(n(),a()).nullish(),()=>{})}),Rt=i({sessionId:R,_meta:s(l(n(),a()).nullish(),()=>{})}),Tt=i({sessionId:R,cwd:n(),additionalDirectories:b(n()).optional(),mcpServers:b(_e).optional(),systemPrompt:Se.nullish(),_meta:s(l(n(),a()).nullish(),()=>{})}),xt=i({sessionId:R,cwd:n(),additionalDirectories:b(n()).optional(),mcpServers:b(_e).optional(),systemPrompt:Se.nullish(),_meta:s(l(n(),a()).nullish(),()=>{})}),wt=i({sessionId:R,_meta:s(l(n(),a()).nullish(),()=>{})}),yt=i({sessionId:R,modeId:pe,_meta:s(l(n(),a()).nullish(),()=>{})}),Ct=H(h([i({value:C(),type:u("boolean")}),i({value:it})]),i({sessionId:R,configId:An,_meta:s(l(n(),a()).nullish(),()=>{})})),Ot=i({sessionId:R,prompt:b(G),_meta:s(l(n(),a()).nullish(),()=>{})}),Qr=i({id:L,method:n(),params:h([pt,ht,ft,mt,gt,_t,St,bt,Et,Rt,Tt,xt,wt,yt,Ct,Ot,Nn]).nullish()}),Yi=i({_meta:s(l(n(),a()).nullish(),()=>{})}),Xi=i({content:n(),_meta:s(l(n(),a()).nullish(),()=>{})}),Zi=i({optionId:wn,_meta:s(l(n(),a()).nullish(),()=>{})}),er=h([i({outcome:u("cancelled")}),Zi.and(i({outcome:u("selected")}))]),tr=i({outcome:er,_meta:s(l(n(),a()).nullish(),()=>{})}),nr=i({terminalId:Q,_meta:s(l(n(),a()).nullish(),()=>{})}),sr=i({exitCode:s(q().gte(0).max(4294967295,{error:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),()=>{}),signal:s(n().nullish(),()=>{}),_meta:s(l(n(),a()).nullish(),()=>{})}),or=i({output:n(),truncated:C(),exitStatus:s(sr.nullish(),()=>{}),_meta:s(l(n(),a()).nullish(),()=>{})}),ir=i({_meta:s(l(n(),a()).nullish(),()=>{})}),rr=i({exitCode:s(q().gte(0).max(4294967295,{error:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),()=>{}),signal:s(n().nullish(),()=>{}),_meta:s(l(n(),a()).nullish(),()=>{})}),ar=i({_meta:s(l(n(),a()).nullish(),()=>{})}),cr=h([n(),x(),x(),C(),b(n())]),It=i({content:l(n(),cr).nullish()}),lr=$(H(h([It.and(i({action:u("accept")})),i({action:u("decline")}),i({action:u("cancel")}),W(i({action:n()}),"action",["accept","cancel","decline"])]),i({_meta:s(l(n(),a()).nullish(),()=>{})})),"action",["accept","cancel","decline"]),ur=tn({code:q().min(-2147483648,{error:"Invalid value: Expected int32 to be >= -2147483648"}).max(2147483647,{error:"Invalid value: Expected int32 to be <= 2147483647"}),message:n(),data:a().optional()}),dr=h([i({result:a(),_meta:s(l(n(),a()).nullish(),()=>{})}),i({error:ur,_meta:s(l(n(),a()).nullish(),()=>{})})]),Yr=h([i({id:L,result:h([Yi,Xi,tr,nr,or,ir,rr,ar,lr,dr,Pn])}),i({id:L,error:re})]),kt=i({sessionId:R,_meta:s(l(n(),a()).nullish(),()=>{})}),zr=i({serverId:tt,requestId:kn,method:n(),params:l(n(),a()).nullish(),_meta:s(l(n(),a()).nullish(),()=>{})}),Xr=i({method:n(),params:h([kt,zr,Hn]).nullish()}),Zr=i({requestId:L,_meta:s(l(n(),a()).nullish(),()=>{})});var Gn="$/cancel_request";function be(o){return At(o)&&"id"in o&&typeof o.method=="string"&&jt(o.id)}function Bn(o){if(!At(o)||"method"in o||!("id"in o)||!jt(o.id))return!1;let e=Object.hasOwn(o,"result"),t=Object.hasOwn(o,"error");return e===t?!1:!t||fr(o.error)}function X(o){return At(o)&&!("id"in o)&&typeof o.method=="string"}function F(o){return typeof o=="object"&&o!==null}function At(o){return F(o)&&o.jsonrpc==="2.0"}function jt(o){return o===null||typeof o=="string"||typeof o=="number"&&Number.isFinite(o)}function Fn(o){return F(o)&&!("method"in o)&&("id"in o||"result"in o||"error"in o)}function pr(o){let e=!1,t=!1,r=!1,c=!1;for(let d of o)e||=be(d)||X(d),t||=Bn(d),F(d)&&(r||="method"in d,c||="result"in d||"error"in d);return e?!1:t?!0:c&&!r}function hr(o){if(!(!F(o)||!jt(o.requestId)))return o.requestId}function fr(o){return F(o)&&typeof o.code=="number"&&Number.isInteger(o.code)&&typeof o.message=="string"}var k={yes(){return{handled:!0}},no(o,e=!1){return{handled:!1,message:o,retry:e}}};function V(o){let e=Promise.reject(o);return e.catch(()=>{}),e}function mr(o){if(o instanceof Error||typeof o=="object"&&o!=null&&"message"in o&&typeof o.message=="string")return o.message}function gr(o){return typeof o=="object"&&o!==null&&"name"in o&&o.name==="ZodError"&&"issues"in o&&Array.isArray(o.issues)&&"format"in o&&typeof o.format=="function"}function Wn(o){if(o instanceof _)return o.toResult();if(gr(o))return _.invalidParams(o.format()).toResult();let e=mr(o);try{return _.internalError(e?JSON.parse(e):{}).toResult()}catch{return _.internalError({details:e}).toResult()}}function _r(o){return o instanceof _&&o.code===-32800?o:_.requestCancelled(o)}function Sr(o,e){let t=br(o,e);return t?t.toResult():Wn(o)}function br(o,e){if(!(!e.aborted||!Er(o)))return _r(e.reason)}function Er(o){if(typeof o!="object"||o===null)return!1;let e=o;return e.name==="AbortError"||e.code==="ABORT_ERR"}var Nt=class{id;sendResult;signal;finishRequest;didRespond=!1;constructor(e,t,r=new AbortController().signal,c){this.id=e,this.sendResult=t,this.signal=r,this.finishRequest=c}get responded(){return this.didRespond}respond(e){return this.respondWithResult({result:e??null})}respondWithError(e){let t=e instanceof _?e.toErrorResponse():e;return this.respondWithResult({error:t})}respondWithResult(e){return this.didRespond?V(new Error("JSON-RPC request already responded")):(this.didRespond=!0,this.sendResult(e).finally(()=>{this.finishRequest?.()}))}},Rr=new WeakMap;var ee=class{disposeHandler;active=!0;constructor(e){this.disposeHandler=e}dispose(){this.active&&(this.active=!1,this.disposeHandler())}[Symbol.dispose](){this.dispose()}runIndefinitely(){return this}},Mt=class{connection;constructor(e){this.connection=e}sendRequest(e,t,r,c){return this.connection.sendRequest(e,t,r,c)}sendNotification(e,t){return this.connection.sendNotification(e,t)}sendBatch(e){return this.connection.sendBatch(e)}sendCancelRequest(e){return this.connection.sendCancelRequest(e)}addDynamicHandler(e){return this.connection.addDynamicHandler(e)}get signal(){return this.connection.signal}get closed(){return this.connection.closed}},te=class{pendingResponses=new Map;incomingRequests=new Map;nextRequestId=0;staticHandlers=[];dynamicHandlers=new Set;stream;writeQueue=Promise.resolve();abortController=new AbortController;closedPromise;retryQueue=[];context=new Mt(this);receiveReader;allowBatches=!0;constructor(e,t,r,c){if(typeof e=="function"){let g=e,E=t,S=r;this.initialize(S,[...c?.handlers??[],this.legacyHandler(g,E)],c);return}let d=e,p=t,m=r;this.initialize(d,[...m?.handlers??[],...p],m)}static builder(){return new qt}runUntil(e){let t=!1,r=Promise.resolve().then(()=>e(this.context)).finally(()=>{t=!0}),c=this.closed.then(()=>{if(t)return new Promise(()=>{});throw this.closedReason()});return Promise.race([r,c]).finally(()=>{t=!0,this.close()})}addDynamicHandler(e){if(this.dynamicHandlers.add(e),this.retryQueue.length>0)for(let t of this.retryQueue.splice(0))this.processIncomingMessage(t).catch(r=>this.close(r));return new ee(()=>{this.dynamicHandlers.delete(e)})}get signal(){return this.abortController.signal}get closed(){return this.closedPromise}getContext(){return this.context}sendRequest(e,t,r,c={}){if(this.abortController.signal.aborted)return V(this.closedReason());let d=this.prepareRequest(e,t,r,c);return this.sendWireMessage(d.message).catch(()=>{}),c.cancellationSignal?.aborted&&d.cancel(),d.response}sendBatch(e){if(this.abortController.signal.aborted)return V(this.closedReason());if(!this.allowBatches)return V(new TypeError("JSON-RPC batches are not supported on this connection"));if(e.length===0)return V(new TypeError("JSON-RPC batch must contain at least one entry"));let t=[],r=[],c=[];for(let g of e){if(g.kind==="notification"){t.push({jsonrpc:"2.0",method:g.method,params:g.params}),c.push(Promise.resolve(void 0));continue}let E=this.prepareRequest(g.method,g.params,g.mapResponse,g.options);t.push(E.message),c.push(E.response),r.push({signal:g.options?.cancellationSignal,cancel:E.cancel})}let d=t,p=this.sendWireMessage(d);for(let g of r)g.signal?.aborted&&g.cancel();let m=Promise.all([p,...c]).then(([,...g])=>g);return m.catch(()=>{}),m}sendCancelRequest(e){return this.sendNotification(Gn,{requestId:e})}sendNotification(e,t){return this.abortController.signal.aborted?V(this.closedReason()):this.sendWireMessage({jsonrpc:"2.0",method:e,params:t})}prepareRequest(e,t,r,c={}){let d=this.nextRequestId++,p=()=>{},m=new Promise((g,E)=>{let S={resolve:O=>{try{g(r?r(O):O)}catch(y){E(y)}},reject:E};p=()=>{S.cancellationSent||(S.cancellationSent=!0,S.cleanup?.(),this.sendCancelRequest(d).catch(()=>{}))},c.cancellationSignal?.addEventListener("abort",p,{once:!0}),S.cleanup=()=>{c.cancellationSignal?.removeEventListener("abort",p)},this.pendingResponses.set(d,S)});return m.catch(()=>{}),{message:{jsonrpc:"2.0",id:d,method:e,params:t},response:m,cancel:()=>p()}}close(e){if(this.abortController.signal.aborted)return;let t=e??new Error("ACP connection closed");this.abortController.abort(t);for(let r of this.pendingResponses.values())r.cleanup?.(),r.reject(t);this.pendingResponses.clear();for(let r of this.incomingRequests.values())r.abort(t);this.incomingRequests.clear(),this.receiveReader?.cancel(t).catch(()=>{})}initialize(e,t,r){this.stream=e,this.staticHandlers=t,this.allowBatches=r?.allowBatches??!0,this.closedPromise=new Promise(c=>{this.abortController.signal.addEventListener("abort",()=>c())}),this.receive()}legacyHandler(e,t){return{handleMessage:async(r,c)=>{if(r.kind==="request"){let d=await e(r.method,r.params,c);await r.responder.respond(d)}else await t(r.method,r.params,c);return k.yes()}}}async receive(){let e;try{let t=this.stream.readable.getReader();this.receiveReader=t;try{for(;!this.abortController.signal.aborted;){let{value:r,done:c}=await t.read();if(this.abortController.signal.aborted||c)break;this.receiveWireMessage(r)}}finally{this.receiveReader===t&&(this.receiveReader=void 0),t.releaseLock()}}catch(t){e=t}finally{this.close(e)}}receiveWireMessage(e){if(Array.isArray(e)){if(!this.allowBatches){this.close(new TypeError("JSON-RPC batches are not supported on this connection"));return}this.receiveBatch(e);return}if(!be(e)&&!X(e)&&!Fn(e)){this.sendWireMessage(Z(_.invalidRequest(e))).catch(()=>{});return}this.receiveMessage(e)}receiveBatch(e){if(e.length===0){this.sendWireMessage(Z(_.invalidRequest(e))).catch(()=>{});return}let t=pr(e),c=t?0:e.reduce((S,O)=>S+(X(O)?0:1),0),d=e.reduce((S,O)=>S+(X(O)?1:0),0),p=!1,m=[],g=async()=>{p||c!==0||d!==0||m.length===0||(p=!0,await this.sendWireMessage(m))},E=async S=>{m.push(S),c-=1,await g()};for(let S of e){if(t){Fn(S)&&this.receiveMessage(S);continue}if(!be(S)&&!X(S)){E(Z(_.invalidRequest(S))).catch(()=>{});continue}let O=this.receiveMessage(S,be(S)?E:void 0,e.length);X(S)&&O.finally(()=>{d-=1,g().catch(y=>this.close(y))})}}receiveMessage(e,t,r){return this.abortController.signal.aborted?Promise.resolve():F(e)?"method"in e?("id"in e||this.handleProtocolNotification(e),this.processIncomingMessage(this.toIncomingMessage(e,t,r)).catch(c=>this.close(c))):("id"in e?this.handleResponse(e):console.error("Invalid message",{message:e}),Promise.resolve()):(console.error("Invalid message",{message:e}),Promise.resolve())}async processIncomingMessage(e){if(this.abortController.signal.aborted)return;let t=e,r=!1;try{for(let c of[...this.staticHandlers,...this.dynamicHandlers.values()]){if(this.abortController.signal.aborted)return;let d=await c.handleMessage(t,this.context)??{handled:!0};if(d.handled)return;t=d.message??t,r=r||!!d.retry}r?this.retryQueue.push(t):t.kind==="request"&&await t.responder.respondWithError(_.methodNotFound(t.method))}catch(c){if(this.abortController.signal.aborted)return;if(t.kind==="request"&&!t.responder.responded)await t.responder.respondWithResult(Sr(c,t.responder.signal));else{let d=Wn(c);"error"in d&&console.error("Error handling notification",e.raw,d.error)}}}toIncomingMessage(e,t,r){if("id"in e){let c=new AbortController;this.incomingRequests.set(e.id,c);let d=()=>{this.incomingRequests.get(e.id)===c&&this.incomingRequests.delete(e.id)},p=new Nt(e.id,m=>{let g={jsonrpc:"2.0",id:e.id,...m};return t?t(g):this.sendWireMessage(g)},c.signal,d);return r!==void 0&&Rr.set(p,r),{kind:"request",method:e.method,params:e.params,raw:e,signal:c.signal,responder:p}}return{kind:"notification",method:e.method,params:e.params,raw:e}}handleResponse(e){let t=this.pendingResponses.get(e.id);if(t)if(this.pendingResponses.delete(e.id),t.cleanup?.(),!Bn(e))t.reject(_.invalidRequest(e));else if("result"in e)t.resolve(e.result);else{let{code:r,message:c,data:d}=e.error;t.reject(new _(r,c,d))}else console.error("Got response to unknown request",e.id)}handleProtocolNotification(e){if(e.method!==Gn)return;let t=hr(e.params);if(t===void 0)return;let r=this.incomingRequests.get(t);!r||r.signal.aborted||r.abort(_.requestCancelled({requestId:t}))}closedReason(){return this.abortController.signal.reason??new Error("ACP connection closed")}async sendWireMessage(e){return this.abortController.signal.aborted?V(this.closedReason()):(this.writeQueue=this.writeQueue.then(async()=>{if(this.abortController.signal.aborted)throw this.closedReason();let t=this.stream.writable.getWriter();try{await t.write(e)}finally{t.releaseLock()}}).catch(t=>{throw this.close(t),t}),this.writeQueue)}},qt=class{handlers=[];connectionName;name(e){return this.connectionName=e,this}withHandler(e){return this.handlers.push(e),this}onReceiveMessage(e){return this.withHandler({handleMessage:async(t,r)=>await e(t,r)??k.no(t),describe:()=>this.connectionName??"onReceiveMessage"})}onReceiveRequest(e,t,r){return this.withHandler({handleMessage:async(c,d)=>{if(c.kind!=="request"||c.method!==e)return k.no(c);let p=t(c.params);return await r(p,c.responder,d)??k.yes()},describe:()=>`${this.connectionName??"request"}:${e}`})}onReceiveNotification(e,t,r){return this.withHandler({handleMessage:async(c,d)=>{if(c.kind!=="notification"||c.method!==e)return k.no(c);let p=t(c.params);return await r(p,d)??k.yes()},describe:()=>`${this.connectionName??"notification"}:${e}`})}connect(e,t){return new te(e,this.handlers,t)}connectWith(e,t,r){return this.connect(e,r).runUntil(t)}},_=class o extends Error{code;data;constructor(e,t,r){super(t),this.code=e,this.name="RequestError",this.data=r}static parseError(e,t){return new o(-32700,`Parse error${t?`: ${t}`:""}`,e)}static invalidRequest(e,t){return new o(-32600,`Invalid request${t?`: ${t}`:""}`,e)}static methodNotFound(e){return new o(-32601,`"Method not found": ${e}`,{method:e})}static invalidParams(e,t){return new o(-32602,`Invalid params${t?`: ${t}`:""}`,e)}static internalError(e,t){return new o(-32603,`Internal error${t?`: ${t}`:""}`,e)}static requestCancelled(e,t){return new o(-32800,`Request cancelled${t?`: ${t}`:""}`,e)}static authRequired(e,t){return new o(-32e3,`Authentication required${t?`: ${t}`:""}`,e)}static resourceNotFound(e){return new o(-32002,`Resource not found${e?`: ${e}`:""}`,e&&{uri:e})}static unsupportedProtocolVersion(e,t){return new o(-32022,"Unsupported protocol version",{requested:e,supported:[...t]})}toResult(){return{error:{code:this.code,message:this.message,data:this.data}}}toErrorResponse(){return{code:this.code,message:this.message,data:this.data}}};function Z(o){return{jsonrpc:"2.0",id:null,error:o.toErrorResponse()}}var ne=class extends Error{maxMessageBytes;constructor(e){super(`Incoming ACP data exceeds the configured ${e} byte limit`),this.maxMessageBytes=e,this.name="MessageTooLargeError"}};function ae(o){let e=o??33554432;if(!Number.isSafeInteger(e)||e<=0)throw new RangeError("maxMessageBytes must be a positive safe integer");return e}var Ee=class{#e=new Uint8Array(0);#t=0;#n;constructor(e){this.#n=ae(e)}get byteLength(){return this.#t}get lastByte(){return this.#e[this.#t-1]}#s(e){if(e>this.#n-this.#t)throw this.clear(),new ne(this.#n)}append(e){this.#s(e.byteLength);let t=this.#t+e.byteLength;if(t>this.#e.byteLength){let r=Math.min(this.#n,Math.max(t,this.#e.byteLength*2,1024)),c=new Uint8Array(r);c.set(this.#e.subarray(0,this.#t)),this.#e=c}this.#e.set(e,this.#t),this.#t=t}take(){let e=this.#e.subarray(0,this.#t);return this.clear(),e}clear(){this.#e=new Uint8Array(0),this.#t=0}};var $n=10,Re=class{#e;#t;constructor(e){this.#t=ae(e),this.#e=new Ee(Math.min(Number.MAX_SAFE_INTEGER,this.#t+1))}*push(e){let t=0,r=e.indexOf($n,t);for(;r!==-1;)yield this.#n(e.subarray(t,r)),t=r+1,r=e.indexOf($n,t);if(t<e.byteLength){let c=e.subarray(t);this.#s(c),this.#e.append(c)}}flush(){if(this.#e.byteLength!==0)return Pt(this.#e.take())}clear(){this.#e.clear()}#n(e){return this.#s(e),this.#e.byteLength===0?Pt(e):(this.#e.append(e),Pt(this.#e.take()))}#s(e){let t=e.byteLength>0?e[e.byteLength-1]:this.#e.lastByte;if(this.#e.byteLength+e.byteLength-(t===13?1:0)>this.#t)throw this.clear(),new ne(this.#t)}};function Pt(o){return o[o.byteLength-1]===13?o.subarray(0,-1):o}function Vn(o,e,t={}){let r=ae(t.maxMessageBytes),c=new TextEncoder,d=new TextDecoder,p=!1,m,g=Promise.resolve(),E=y=>{let A=JSON.stringify(y)+`
|
|
5
|
-
`,B=g.then(async()=>{let j=o.getWriter();try{await j.write(c.encode(A))}finally{j.releaseLock()}});return g=B.catch(()=>{}),B},S=new ReadableStream({async start(y){let A=new Re(r),B=async M=>{let P=d.decode(M).trim();if(!P)return;let D;try{D=JSON.parse(P)}catch{await E(Z(_.parseError()));return}F(D)||Array.isArray(D)?y.enqueue(D):await E(Z(_.invalidRequest(D)))},j=e.getReader();m=j;try{for(;;){let{value:P,done:D}=await j.read();if(p)return;if(D)break;if(P){for(let J of A.push(P))if(await B(J),p)return}}if(p)return;let M=A.flush();M&&await B(M)}catch(M){if(p)return;y.error(M),j.cancel(M).catch(()=>{});return}finally{A.clear(),m===j&&(m=void 0),j.releaseLock()}p||y.close()},cancel(y){return p=!0,m?.cancel(y)}}),O=new WritableStream({write(y){return E(y)}});return{readable:S,writable:O}}var ca=Xe.and(i({mode:u("form")})).and(i({message:n()})),la=Ze.and(i({mode:u("url")})).and(i({message:n()})),ua=h([oe,ie]).and(i({message:n()})),da=$e.and(i({type:u("string")})),za=Ve.and(i({type:u("number")})),pa=Ke.and(i({type:u("integer")})),ha=Je.and(i({type:u("boolean")})),fa=Ye.and(i({type:u("array")})),ma=Qe.and(i({type:u("string")}));var ga=at.and(i({state:u("running")})),_a=lt.and(i({usage:fe.nullish()})).and(i({state:u("idle")})),Sa=ut.and(i({state:u("requires_action")})),ba=dt.and(i({state:u("unknown")})),Ea=i({stopReason:u("end_turn")}),Ra=i({stopReason:u("max_tokens")}),Ta=i({stopReason:u("max_turn_requests")}),xa=i({stopReason:u("refusal")}),wa=i({stopReason:u("cancelled")}),ya=ct.and(i({error:re.nullish()})).and(i({stopReason:u("error")})),Ca=i({stopReason:ze().optional()}),Oa=It.and(i({action:u("accept")})),Ia=i({action:u("decline")}),ka=i({action:u("cancel")});function Ua(o,e,t){return Vn(o,e,t)}function I(o){return o??{}}function Xn(o){return typeof o=="object"&&o!==null&&"readable"in o&&"writable"in o}function Zn(){let o=new TransformStream,e=new TransformStream;return[{readable:e.readable,writable:o.writable},{readable:o.readable,writable:e.writable}]}var N={agent:{initialize:z.initialize,authenticate:z.authenticate,logout:z.logout,providers:{list:z.providers_list,set:z.providers_set,disable:z.providers_disable},session:{new:z.session_new,load:z.session_load,list:z.session_list,delete:z.session_delete,fork:z.session_fork,resume:z.session_resume,close:z.session_close,setMode:z.session_set_mode,setConfigOption:z.session_set_config_option,prompt:z.session_prompt,cancel:z.session_cancel}},client:{session:{requestPermission:f.session_request_permission,update:f.session_update},fs:{writeTextFile:f.fs_write_text_file,readTextFile:f.fs_read_text_file},terminal:{create:f.terminal_create,output:f.terminal_output,release:f.terminal_release,waitForExit:f.terminal_wait_for_exit,kill:f.terminal_kill},elicitation:{create:f.elicitation_create,complete:f.elicitation_complete}},protocol:{cancelRequest:Ae.cancel_request}},es=Symbol("startActiveSession"),we=class{cx;currentRequestId;constructor(e,t){this.cx=e,this.currentRequestId=t}get requestId(){return this.currentRequestId}get connectionContext(){return this.cx}sendRequest(e,t,r,c){return this.cx.sendRequest(e,t,r,c)}sendNotification(e,t){return this.cx.sendNotification(e,t)}addDynamicHandler(e){return this.cx.addDynamicHandler(e)}},ce=class o extends we{constructor(e,t){super(e,t)}static create(e,t){return new o(e,t)}request(e,t,r){let c=$t[e];return this.sendRequest(e,t,c?.mapResponse,r)}notify(e,t){return this.sendNotification(e,t)}},le=class o extends we{constructor(e,t){super(e,t)}static create(e,t){return new o(e,t)}[es](e,t){return this.sendRequest(z.session_new,e,r=>this.attachSession(r),t)}buildSession(e){return typeof e=="string"?Ce.create(this,{cwd:e,mcpServers:[]}):Ce.create(this,e)}attachSession(e){let t=new Ht,r=this.connectionContext.signal,c=()=>{t.fail(r.reason??new Error("ACP connection closed"))};r.aborted?c():r.addEventListener("abort",c);let d=rs(this.connectionContext).attach(e,t),p=new ee(()=>{r.removeEventListener("abort",c)});return Ut.create(this,e,t,[d,p])}request(e,t,r){let c=is[e];return this.sendRequest(e,t,c?.mapResponse,r)}notify(e,t){return this.sendNotification(e,t)}},ye=class{connection;constructor(e){this.connection=e}get signal(){return this.connection.signal}get closed(){return this.connection.closed}close(e){this.connection.close(e)}},vt=class extends ye{connectHandlers;client;didStartConnectHandlers=!1;constructor(e,t=[]){super(e),this.connectHandlers=t,this.client=ce.create(e.getContext())}startConnectHandlers(){this.didStartConnectHandlers||(this.didStartConnectHandlers=!0,Ie(this,this.connectHandlers))}},Dt=class extends ye{connectHandlers;agent;didStartConnectHandlers=!1;constructor(e,t=[]){super(e),this.connectHandlers=t,this.agent=le.create(e.getContext())}startConnectHandlers(){this.didStartConnectHandlers||(this.didStartConnectHandlers=!0,Ie(this,this.connectHandlers))}};function ts(o,e=[]){return new vt(o,e)}function ns(o,e=[]){return new Dt(o,e)}var Ht=class{values=[];waiters=[];failed=!1;failure;enqueue(e){if(this.failed)return;let t=this.waiters.shift();t?t.resolve(e):this.values.push({kind:"value",value:e})}reject(e){if(!this.failed){if(this.waiters.length>0){for(let t of this.waiters.splice(0))t.reject(e);return}this.values.push({kind:"error",error:e})}}clearErrors(){this.values=this.values.filter(e=>e.kind==="value")}fail(e){if(!this.failed){this.failed=!0,this.failure=e;for(let t of this.waiters.splice(0))t.reject(e)}}next(){if(this.values.length>0){let e=this.values.shift();return e.kind==="error"?Promise.reject(e.error):Promise.resolve(e.value)}return this.failed?Promise.reject(this.failure):new Promise((e,t)=>{this.waiters.push({resolve:e,reject:t})})}};function Kn(o){return{...o,additionalDirectories:o.additionalDirectories?[...o.additionalDirectories]:void 0,mcpServers:[...o.mcpServers]}}var Ce=class o{cx;request;constructor(e,t){this.cx=e,this.request=Kn(t)}static create(e,t){return new o(e,t)}toRequest(){return Kn(this.request)}withAdditionalDirectories(e){return this.request={...this.request,additionalDirectories:[...e]},this}withMcpServer(e){return this.request={...this.request,mcpServers:[...this.request.mcpServers,e]},this}async start(e){return this.cx[es](this.toRequest(),e)}async withSession(e){let t=await this.start();try{return await e(t)}finally{t.dispose()}}},Ut=class o{cx;sessionResponse;updates;registrations;constructor(e,t,r,c){this.cx=e,this.sessionResponse=t,this.updates=r,this.registrations=c}static create(e,t,r,c){return new o(e,t,r,c)}get sessionId(){return this.sessionResponse.sessionId}get modes(){return this.sessionResponse.modes}get meta(){return this.sessionResponse._meta}get newSessionResponse(){return this.sessionResponse}prompt(e,t){this.updates.clearErrors();let r=this.cx.request(z.session_prompt,{sessionId:this.sessionId,prompt:this.promptBlocks(e)},t);return r.then(c=>{this.updates.enqueue({kind:"stop",response:c,stopReason:c.stopReason})},c=>{this.updates.reject(c)}),r}nextUpdate(){return this.updates.next()}async readText(){let e="";for(;;){let t=await this.nextUpdate();if(t.kind==="stop")return e;let{update:r}=t;r.sessionUpdate==="agent_message_chunk"&&r.content.type==="text"&&(e+=r.content.text)}}dispose(){for(let e of this.registrations.splice(0))e.dispose();this.updates.fail(new Error("Active session disposed"))}[Symbol.dispose](){this.dispose()}promptBlocks(e){return typeof e=="string"?[{type:"text",text:e}]:Array.isArray(e)?e:[e]}};function Wt(o,e){return o?typeof o=="function"?o(e):o.parse(e):e}function T(o,e,t){return{method:o,params:r=>Wt(e,r??{}),mapResponse:t}}function Lt(o,e){return{method:o,params:e}}function ss(o,e,t,r){o.onReceiveRequest(e.method,c=>Wt(e.params,c),async(c,d,p)=>{let m=await r(t(c,p,d.signal,d.id));await d.respond(e.mapResponse?e.mapResponse(m):m)})}function os(o,e,t,r){o.onReceiveNotification(e.method,c=>Wt(e.params,c),(c,d)=>r(t(c,d,d.signal)))}function Oe(o){let e={};for(let t of Object.values(o))e[t.method]=t;return e}var Tr={initialize:T(z.initialize,pt),newSession:T(z.session_new,St),loadSession:T(z.session_load,bt,I),unstable_forkSession:T(z.session_fork,Tt),listSessions:T(z.session_list,Et),deleteSession:T(z.session_delete,Rt,I),resumeSession:T(z.session_resume,xt),closeSession:T(z.session_close,wt,I),setSessionMode:T(z.session_set_mode,yt,I),setSessionConfigOption:T(z.session_set_config_option,Ct),authenticate:T(z.authenticate,ht,I),unstable_listProviders:T(z.providers_list,ft),unstable_setProvider:T(z.providers_set,mt,I),unstable_disableProvider:T(z.providers_disable,gt,I),logout:T(z.logout,_t,I),prompt:T(z.session_prompt,Ot)},xr={cancel:Lt(z.session_cancel,kt)},wr={requestPermission:T(f.session_request_permission,Ue),writeTextFile:T(f.fs_write_text_file,ve,I),readTextFile:T(f.fs_read_text_file,De),createTerminal:T(f.terminal_create,Le),terminalOutput:T(f.terminal_output,Ge),releaseTerminal:T(f.terminal_release,Fe,I),waitForTerminalExit:T(f.terminal_wait_for_exit,Be),killTerminal:T(f.terminal_kill,We,I),createElicitation:T(f.elicitation_create,et)},yr={sessionUpdate:Lt(f.session_update,ge),completeElicitation:Lt(f.elicitation_complete,zt)},is=Oe(Tr),Cr=Oe(xr),$t=Oe(wr),Or=Oe(yr);function Ir(o,e,t,r){return{params:o,requestId:r,signal:t,client:e}}function kr(o,e,t){return{params:o,signal:t,client:e}}function Nr(o,e,t,r){return{params:o,requestId:r,signal:t,agent:e}}function Mr(o,e,t){return{params:o,signal:t,agent:e}}var Gt=class{activeSessions=new Map;handleMessage(e){if(e.kind!=="notification"||e.method!==f.session_update)return k.no(e);let t=ge.parse(e.params),r={kind:"session_update",notification:t,update:t.update},c=this.activeSessions.get(t.sessionId);if(c&&c.size>0)for(let d of c)d.enqueue(r);return k.no(e)}attach(e,t){let r=this.activeSessions.get(e.sessionId)??new Set;return r.add(t),this.activeSessions.set(e.sessionId,r),new ee(()=>{r.delete(t),r.size===0&&this.activeSessions.delete(e.sessionId)})}},Jn=new WeakMap;function rs(o){let e=Jn.get(o);return e||(e=new Gt,Jn.set(o,e)),e}function Ie(o,e){for(let t of e){let r;try{r=t(o)}catch(c){throw o.close(c),c}Promise.resolve(r).catch(c=>{o.close(c)})}}var K=Symbol("appBuilder"),Te=Symbol("runAgentConnectHandlers"),xe=Symbol("runClientConnectHandlers"),ue={allowBatches:!1};function Vt(o){return new Ft(o)}var Ft=class{builder=te.builder();connectHandlers=[];constructor(e={}){e.name&&this.builder.name(e.name)}[K](){return this.builder}[Te](e){Ie(e,this.connectHandlers)}connect(e,t={}){return this.connectConnection(e,t).connection}connectWith(e,t){let{rawConnection:r,connection:c}=this.connectConnection(e);return r.runUntil(()=>t(c.client))}onConnect(e){return this.connectHandlers.push(e),this}onRequest(e,t,r){if(r)return this.request({method:e,params:t},r);let c=is[e];if(!c)throw new Error(`Unknown ACP request method '${e}'. Pass a params parser for custom methods.`);return this.request(c,t)}onNotification(e,t,r){if(r)return this.notification({method:e,params:t},r);let c=Cr[e];if(!c)throw new Error(`Unknown ACP notification method '${e}'. Pass a params parser for custom methods.`);return this.notification(c,t)}request(e,t){return ss(this.builder,e,(r,c,d,p)=>Ir(r,ce.create(c,p),d,p),t),this}notification(e,t){return os(this.builder,e,(r,c,d)=>kr(r,ce.create(c),d),t),this}connectConnection(e,t={}){if(Xn(e)){let g=this.openStreamConnection(e);return t.deferConnectHandlers||this[Te](g.connection),g}let[r,c]=Zn(),d=e[K]().connect(c,ue),p=ns(d),m=this.openStreamConnection(r);m.rawConnection.closed.then(()=>p.close()),d.closed.then(()=>m.connection.close());try{e[xe](p),this[Te](m.connection)}catch(g){throw p.close(g),m.connection.close(g),g}return m}openStreamConnection(e){let t=this.builder.connect(e,ue);return{rawConnection:t,connection:ts(t,this.connectHandlers)}}};var Qn=class{builder=te.builder();connectHandlers=[];constructor(e={}){e.name&&this.builder.name(e.name),this.builder.withHandler({handleMessage:(t,r)=>rs(r).handleMessage(t),describe:()=>"client-session-update-router"})}[K](){return this.builder}[xe](e){Ie(e,this.connectHandlers)}connect(e){return this.connectConnection(e).connection}connectWith(e,t){let{rawConnection:r,connection:c}=this.connectConnection(e);return r.runUntil(()=>t(c.agent))}onConnect(e){return this.connectHandlers.push(e),this}onRequest(e,t,r){if(r)return this.request({method:e,params:t},r);let c=$t[e];if(!c)throw new Error(`Unknown ACP request method '${e}'. Pass a params parser for custom methods.`);return this.request(c,t)}onNotification(e,t,r){if(r)return this.notification({method:e,params:t},r);let c=Or[e];if(!c)throw new Error(`Unknown ACP notification method '${e}'. Pass a params parser for custom methods.`);return this.notification(c,t)}request(e,t){return ss(this.builder,e,(r,c,d,p)=>Nr(r,le.create(c,p),d,p),t),this}notification(e,t){return os(this.builder,e,(r,c,d)=>Mr(r,le.create(c),d),t),this}connectConnection(e){if(Xn(e)){let m=this.openStreamConnection(e);return this[xe](m.connection),m}let[t,r]=Zn(),c=e[K]().connect(r,ue),d=ts(c),p=this.openStreamConnection(t);p.rawConnection.closed.then(()=>d.close()),c.closed.then(()=>p.connection.close());try{e[Te](d),this[xe](p.connection)}catch(m){throw d.close(m),p.connection.close(m),m}return p}openStreamConnection(e){let t=this.builder.connect(e,ue);return{rawConnection:t,connection:ns(t,this.connectHandlers)}}},qr=new Set([z.initialize,z.authenticate,z.providers_list,z.providers_set,z.providers_disable,z.session_new,z.session_load,z.session_set_mode,z.session_set_config_option,z.session_prompt,z.session_list,z.session_delete,z.session_fork,z.session_resume,z.session_close,z.logout]),Ar=new Set([z.session_cancel]),Ga=new Set([f.session_request_permission,f.fs_write_text_file,f.fs_read_text_file,f.terminal_create,f.terminal_output,f.terminal_release,f.terminal_wait_for_exit,f.terminal_kill,f.elicitation_create]),Fa=new Set([f.session_update,f.elicitation_complete]);function jr(o){let e=Vt().onRequest(z.initialize,t=>o.initialize(t.params)).onRequest(z.session_new,t=>o.newSession(t.params)).onRequest(z.authenticate,async t=>await o.authenticate(t.params)??{}).onRequest(z.session_prompt,t=>o.prompt(t.params)).onNotification(z.session_cancel,t=>o.cancel(t.params));return o.loadSession&&e.onRequest(z.session_load,t=>o.loadSession(t.params)),o.listSessions&&e.onRequest(z.session_list,t=>o.listSessions(t.params)),o.deleteSession&&e.onRequest(z.session_delete,async t=>await o.deleteSession(t.params)??{}),o.unstable_forkSession&&e.onRequest(z.session_fork,t=>o.unstable_forkSession(t.params)),o.resumeSession&&e.onRequest(z.session_resume,t=>o.resumeSession(t.params)),o.closeSession&&e.onRequest(z.session_close,async t=>await o.closeSession(t.params)??{}),o.setSessionMode&&e.onRequest(z.session_set_mode,async t=>await o.setSessionMode(t.params)??{}),o.setSessionConfigOption&&e.onRequest(z.session_set_config_option,t=>o.setSessionConfigOption(t.params)),o.unstable_listProviders&&e.onRequest(z.providers_list,t=>o.unstable_listProviders(t.params)),o.unstable_setProvider&&e.onRequest(z.providers_set,async t=>await o.unstable_setProvider(t.params)??{}),o.unstable_disableProvider&&e.onRequest(z.providers_disable,async t=>await o.unstable_disableProvider(t.params)??{}),o.logout&&e.onRequest(z.logout,async t=>await o.logout(t.params)??{}),o.extMethod&&e[K]().withHandler({handleMessage:async t=>t.kind!=="request"||qr.has(t.method)?k.no(t):(await t.responder.respond(await o.extMethod(t.method,t.params)),k.yes()),describe:()=>"legacy-agent-extension-request"}),o.extNotification&&e[K]().withHandler({handleMessage:async t=>t.kind!=="notification"||Ar.has(t.method)?k.no(t):(await o.extNotification(t.method,t.params),k.yes()),describe:()=>"legacy-agent-extension-notification"}),e}var Yn=class{connection;constructor(e,t){this.connection=jr(e(this))[K]().connect(t,ue)}sessionUpdate(e){return this.connection.sendNotification(f.session_update,e)}requestPermission(e){return this.connection.sendRequest(f.session_request_permission,e)}readTextFile(e){return this.connection.sendRequest(f.fs_read_text_file,e)}writeTextFile(e){return this.connection.sendRequest(f.fs_write_text_file,e,I)}createTerminal(e){return this.connection.sendRequest(f.terminal_create,e,t=>Bt.create(t.terminalId,e.sessionId,this.connection))}createElicitation(e){return this.connection.sendRequest(f.elicitation_create,e)}completeElicitation(e){return this.connection.sendNotification(f.elicitation_complete,e)}request(e,t,r){let c=$t[e];return this.connection.sendRequest(e,t,c?.mapResponse,r)}notify(e,t){return this.connection.sendNotification(e,t)}extMethod(e,t){return this.request(e,t)}extNotification(e,t){return this.notify(e,t)}get signal(){return this.connection.signal}get closed(){return this.connection.closed}},Bt=class o{id;sessionId;connection;constructor(e,t,r){this.id=e,this.sessionId=t,this.connection=r}static create(e,t,r){return new o(e,t,r)}currentOutput(){return this.connection.sendRequest(f.terminal_output,{sessionId:this.sessionId,terminalId:this.id})}waitForExit(){return this.connection.sendRequest(f.terminal_wait_for_exit,{sessionId:this.sessionId,terminalId:this.id})}kill(){return this.connection.sendRequest(f.terminal_kill,{sessionId:this.sessionId,terminalId:this.id},I)}release(){return this.connection.sendRequest(f.terminal_release,{sessionId:this.sessionId,terminalId:this.id},I)}async[Symbol.asyncDispose](){await this.release()}};var as=/^[a-z0-9]+-[a-f0-9]{8}$/u,Ka="/acp";var Ja=`127.0.0.1:${String(18889)}`,Kt="yukino",cs="Yukino",ls="tool_call",us="tool_call_update",Jt="agent_message_chunk",ds="agent_thought_chunk",zs="user_message_chunk",ps="usage_update",ke="end_turn",Ne="cancelled",hs="max_tokens",fs="max_turn_requests",ms="refusal",gs="No provider configured.",_s="Session cwd must be absolute.",Ss="Invalid session ID.",bs="Client-provided MCP servers are not supported.",Es="Additional workspace directories are not supported.",Rs="Session cwd does not match.",Ts="Session pagination is not supported.",xs="Binary resources are not supported.",ws="Image prompts are not supported.",ys="Audio prompts are not supported.",Cs="Prompt must contain text or a resource link.",Qa="ACP WebSocket must listen on a loopback address.",Ya="ACP WebSocket server did not bind to a TCP address.";import{existsSync as Hr}from"fs";import{isAbsolute as Ur}from"path";import{isAbsolute as vr,resolve as Dr}from"path";function Os(o){let e=[];for(let r of o)switch(r.type){case"text":r.text.trim()&&e.push(r.text);break;case"resource_link":e.push(`Resource: ${r.name} (${r.uri})`);break;case"resource":if("text"in r.resource){e.push(`Resource: ${r.resource.uri}
|
|
6
|
-
${r.resource.text}`);break}throw _.invalidParams(void 0,xs);case"image":throw _.invalidParams(void 0,ws);case"audio":throw _.invalidParams(void 0,ys)}let t=e.join(`
|
|
7
|
-
|
|
8
|
-
`).trim();if(!t)throw _.invalidParams(void 0,Cs);return t}function Qt(o){return/^(ReadFile)$/u.test(o)?"read":/^(WriteFile|EditFile)$/u.test(o)?"edit":/^(Glob|Grep|ToolSearch|LSP)$/u.test(o)?"search":/^(Bash|PowerShell|ComputerUse)$/u.test(o)?"execute":/^(Agent|TaskStop|TaskOutput|TodoWrite)$/u.test(o)?"think":o==="ExitPlanMode"?"switch_mode":o==="WebFetch"?"fetch":"other"}function Yt(o,e){let t=qe(o,"file_path")||qe(o,"path");if(t)return[{path:vr(t)?t:Dr(e,t)}]}function Is(o,e,t,r){return{sessionUpdate:ls,toolCallId:e,title:o,kind:Qt(o),status:"pending",rawInput:t,locations:Yt(t,r)}}function ks(o,e,t,r){return{sessionUpdate:us,toolCallId:o,status:t?"failed":"completed",content:e?[{type:"content",content:{type:"text",text:e}}]:void 0,rawOutput:{output:e,isError:t,...r===void 0?{}:{elapsed:r}}}}function Ns(o,e,t){switch(o.type){case"stream_text":return{sessionUpdate:Jt,content:{type:"text",text:o.text}};case"thinking_text":return{sessionUpdate:ds,content:{type:"text",text:o.text}};case"tool_use":return Is(o.toolName,o.toolId,o.args,e);case"tool_result":return ks(o.toolId,o.output,o.isError,o.elapsed);case"usage":return{sessionUpdate:ps,used:o.usage.inputTokens+o.usage.cacheReadInputTokens+o.usage.cacheCreationInputTokens,size:t};default:return null}}function Ms(o,e){let t=o.inputTokens+e.usage.inputTokens,r=o.outputTokens+e.usage.outputTokens,c=(o.cachedReadTokens??0)+e.usage.cacheReadInputTokens,d=(o.cachedWriteTokens??0)+e.usage.cacheCreationInputTokens;return{inputTokens:t,outputTokens:r,cachedReadTokens:c,cachedWriteTokens:d,totalTokens:t+r+c+d}}function qs(){return{totalTokens:0,inputTokens:0,outputTokens:0,cachedReadTokens:0,cachedWriteTokens:0}}function As(o){switch(o){case"max_tokens":return hs;case"max_turn_requests":return fs;case"refusal":return ms;case"cancelled":case"interrupted":return Ne;default:return ke}}function*js(o,e,t){for(let r of e){if(r.type===un||r.role!=="user"&&r.role!=="assistant")continue;let c=Me(r.content);c&&(yield{sessionId:o,update:{sessionUpdate:r.role==="assistant"?Jt:zs,content:{type:"text",text:c}}});for(let d of r.tool_uses??[])yield{sessionId:o,update:Is(d.tool_name,d.tool_use_id,d.arguments??{},t)};for(let d of r.tool_results??[]){let p=Me(d.content);yield{sessionId:o,update:ks(d.tool_use_id,p,d.is_error??!1)}}}}async function Lr(o,e){let t=an(cn(),o),r=sn(t.providers,t.default_provider);if(!r)throw _.internalError(void 0,gs);let c=await mn({enableModelPlanMode:!1,provider:r,cwd:o,hooks:t.hooks,mcpServers:t.mcp_servers,mcpLoading:t.mcp_loading,lspServers:t.lsp_servers,sandboxConfig:t.sandbox,enableCoordinatorMode:t.enable_coordinator_mode??!1,forkDisabled:!on(t),memoryEnabled:rn(t),sessionId:e});return{sessionId:c.sessionId,cwd:c.cwd,contextWindow:c.contextWindow,conv:c.conv,run:c.run.bind(c),abort:()=>{c.abort()},dispose:()=>c.dispose()}}function vs(o){if(!Ur(o))throw _.invalidParams(void 0,_s)}function Xt(o){if(!as.test(o))throw _.invalidParams(void 0,Ss)}function Ps(o){if(vs(o.cwd),(o.mcpServers?.length??0)>0)throw _.invalidParams(void 0,bs);if((o.additionalDirectories?.length??0)>0)throw _.invalidParams(void 0,Es)}var Zt=class{constructor(e=Lr){this.runtimeFactory=e}runtimeFactory;sessions=new Map;initialize(e){return{protocolVersion:je,authMethods:[],agentInfo:{name:Kt,title:cs,version:nn},agentCapabilities:{loadSession:!0,promptCapabilities:{embeddedContext:!0},sessionCapabilities:{list:{},resume:{},close:{}}}}}authenticate(){return{}}addSession(e){let t={runtime:e,generation:0,tail:Promise.resolve(),turnAbort:null,closed:!1};return this.sessions.set(e.sessionId,t),t}async newSession(e){Ps(e);let t=await this.runtimeFactory(e.cwd);return this.addSession(t),{sessionId:t.sessionId}}async loadSession(e,t,r){Ps(e),Xt(e.sessionId);let c=this.sessions.get(e.sessionId);if(c&&c.runtime.cwd!==e.cwd)throw _.invalidParams(void 0,Rs);if(c&&!r)return{};let d=zn(e.cwd,e.sessionId);if(!c&&!Hr(dn(e.cwd,e.sessionId)))throw _.resourceNotFound(e.sessionId);if(!c){let p=await this.runtimeFactory(e.cwd,e.sessionId);p.conv.reset(),p.conv.appendMessages(pn(d)),c=this.addSession(p)}if(r)for(let p of js(e.sessionId,d,e.cwd))await t.notify(N.client.session.update,p);return{}}listSessions(e){if(e.cursor)throw _.invalidParams(void 0,Ts);let t=e.cwd??process.cwd();return vs(t),{sessions:hn(t).map(r=>({sessionId:r.id,cwd:t,title:r.firstMessage||void 0,updatedAt:r.modTime.toISOString()}))}}prompt(e,t){let r=this.requireSession(e.sessionId),c=Os(e.prompt),d=r.generation,p=r.tail.catch(()=>{}).then(async()=>{if(r.closed||d!==r.generation||t.signal.aborted)return{stopReason:Ne};let m=new AbortController;r.turnAbort=m;let g=AbortSignal.any([t.signal,m.signal]),E=()=>{r.runtime.abort()};g.aborted?E():g.addEventListener("abort",E,{once:!0});try{return await this.runPrompt(r,e.sessionId,c,t,g)}finally{g.removeEventListener("abort",E),r.turnAbort===m&&(r.turnAbort=null)}});return r.tail=p.then(()=>{},()=>{}),p}cancel(e){let t=this.sessions.get(e.sessionId);t&&(t.generation+=1,t.turnAbort?.abort(),t.runtime.abort())}async closeSession(e){Xt(e.sessionId);let t=this.sessions.get(e.sessionId);return t?(t.closed=!0,t.generation+=1,t.turnAbort?.abort(),t.runtime.abort(),await t.tail.catch(()=>{}),await t.runtime.dispose(),this.sessions.delete(e.sessionId),{}):{}}async dispose(){let e=[...this.sessions.values()];this.sessions.clear();for(let t of e)t.closed=!0,t.generation+=1,t.turnAbort?.abort(),t.runtime.abort();await Promise.all(e.map(async t=>{await t.tail.catch(()=>{}),await t.runtime.dispose()}))}requireSession(e){Xt(e);let t=this.sessions.get(e);if(!t||t.closed)throw _.resourceNotFound(e);return t}async runPrompt(e,t,r,c,d){let p=ln({cwd:e.runtime.cwd,sessionId:t,source:"acp",text:r,commandName:fn(r)?.name==="goal"?"goal":null}),m=ke,g=!1,E=qs();for await(let S of e.runtime.run(r,{input:p,userContent:r,onPermissionRequest:async(O,y,A,B,j,M)=>{let P=j??d,D=c.client.request(N.client.session.requestPermission,{sessionId:t,toolCall:{toolCallId:B,title:`${M?`${M.agentName} \xB7 ${M.cwd} \xB7 `:""}${O}: ${A.reason}`,kind:Qt(O),status:"pending",rawInput:y,locations:Yt(y,M?.cwd??e.runtime.cwd)},options:[{optionId:"allow",name:"Allow once",kind:"allow_once"},...A.rememberPatterns?.length?[{optionId:"allowAlways",name:`Remember for all project agents: ${A.rememberPatterns.join(", ")}`,kind:"allow_always"}]:[],{optionId:"deny",name:"Reject",kind:"reject_once"}]}),J=()=>{},Ds=new Promise(Hs=>{J=()=>{Hs(null)},P.aborted?J():P.addEventListener("abort",J,{once:!0})}),de=await Promise.race([D,Ds]);return P.removeEventListener("abort",J),!de||de.outcome.outcome==="cancelled"?((d.aborted||!P.aborted)&&e.runtime.abort(),"deny"):de.outcome.optionId==="allowAlways"?A.rememberPatterns?.length?"allowAlways":"allow":de.outcome.optionId==="allow"?"allow":"deny"}})){if(S.type==="error")throw _.internalError(void 0,S.error.message);S.type==="loop_complete"&&(m=As(S.stopReason)),S.type==="usage"&&(E=Ms(E,S),g=!0);let O=Ns(S,e.runtime.cwd,e.runtime.contextWindow);if(O){let y={sessionId:t,update:O};await c.client.notify(N.client.session.update,y)}}return{stopReason:m,...g?{usage:E}:{}}}};function gc(o){let e=new Zt(o);return{app:Vt({name:Kt}).onRequest(N.agent.initialize,r=>e.initialize(r.params)).onRequest(N.agent.authenticate,()=>e.authenticate()).onRequest(N.agent.session.new,r=>e.newSession(r.params)).onRequest(N.agent.session.prompt,r=>e.prompt(r.params,r)).onRequest(N.agent.session.list,r=>e.listSessions(r.params)).onRequest(N.agent.session.load,r=>e.loadSession(r.params,r.client,!0)).onRequest(N.agent.session.resume,r=>e.loadSession(r.params,r.client,!1)).onRequest(N.agent.session.close,r=>e.closeSession(r.params)).onNotification(N.agent.session.cancel,r=>{e.cancel(r.params)}).onConnect(r=>{r.signal.addEventListener("abort",()=>{e.dispose()},{once:!0})}),dispose:()=>e.dispose()}}export{z as a,be as b,Bn as c,X as d,F as e,Fn as f,pr as g,_ as h,Z as i,Ua as j,Yn as k,Ka as l,Ja as m,Qa as n,Ya as o,gc as p};
|