@yukino.js/yukino 0.0.7 → 0.0.8

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.
Files changed (40) hide show
  1. package/README.md +130 -25
  2. package/dist/a2a-GBVNBDMY.js +14 -0
  3. package/dist/{acp-76S2XII3.js → acp-C6VUCEZ6.js} +7 -7
  4. package/dist/anthropic-ZEQI4K52.js +4 -0
  5. package/dist/chunk-37IAJFPF.js +4 -0
  6. package/dist/{chunk-NG62ISUV.js → chunk-3P7BR7SO.js} +8 -8
  7. package/dist/{chunk-7PPWFSIC.js → chunk-6XDMANXO.js} +1 -1
  8. package/dist/{chunk-HWDSXNX4.js → chunk-L5C5JBLP.js} +1 -1
  9. package/dist/chunk-MU6PSBZT.js +358 -0
  10. package/dist/chunk-WGFROGUC.js +8 -0
  11. package/dist/{chunk-QRO6H32L.js → chunk-YHE4BT76.js} +148 -148
  12. package/dist/esm-4KOJC56H.js +225 -0
  13. package/dist/fe/dist/index.html +21 -0
  14. package/dist/fe/dist/static/index.css +2 -0
  15. package/dist/fe/dist/static/index.js +203 -0
  16. package/dist/lib/{anthropic-CDPTNR5L.js → anthropic-K7VWTSFH.js} +2 -2
  17. package/dist/lib/{chunk-EO23VPDZ.js → chunk-2NA2RSV7.js} +1 -9
  18. package/dist/lib/{chunk-PEV5NGQ2.js → chunk-E2DXHLHR.js} +1 -1
  19. package/dist/lib/{chunk-HE4RUUZP.js → chunk-IIL5NGQF.js} +461 -457
  20. package/dist/lib/{chunk-OYQY3Q45.js → chunk-K532PPI6.js} +0 -2
  21. package/dist/lib/{chunk-TKCJSTWI.js → chunk-RJQT6B2O.js} +1 -1
  22. package/dist/lib/index.d.ts +402 -3616
  23. package/dist/lib/index.js +2733 -1893
  24. package/dist/lib/{openai-TEFKPV7T.js → openai-6MPSWGKN.js} +2 -2
  25. package/dist/lib/{providers-2X5JB2JX.js → providers-N52Y2QTJ.js} +1 -1
  26. package/dist/lib/{tool-filter-HUVHJN3O.js → tool-filter-F4S25GMJ.js} +1 -1
  27. package/dist/main.js +366 -237
  28. package/dist/{openai-RYXW7AKZ.js → openai-VV2RYB77.js} +1 -1
  29. package/dist/{providers-YG2HYIG6.js → providers-UD3DPALA.js} +1 -1
  30. package/dist/server-FXK26WN2.js +4 -0
  31. package/package.json +11 -12
  32. package/dist/anthropic-WK6EYMUE.js +0 -4
  33. package/dist/chunk-4GE22WHI.js +0 -4
  34. package/dist/chunk-7ZBAF7M4.js +0 -4
  35. package/dist/chunk-QQZCYWYI.js +0 -241
  36. package/dist/esm-5V3TYPZK.js +0 -229
  37. package/dist/lib/chunk-EFNPK4SJ.js +0 -137
  38. package/dist/lib/sandbox-runtime-QDN5SXPM.js +0 -9
  39. package/dist/sandbox-runtime-ELKAYRIL.js +0 -4
  40. package/dist/server-66HLMSUR.js +0 -4
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  import { createRequire as __yukinoCreateRequire } from "node:module";
3
3
  const require = __yukinoCreateRequire(import.meta.url);
4
- import{a as cn}from"./chunk-P6DHMU7R.js";import{a as on}from"./chunk-7ZBAF7M4.js";import{$ as so,B as to,L as Wr,M as Ae,N as ro,O as an,U as oe,Y as un,Z as Ct,_ as Is,aa as de,ba as Ps,ca as xs,o as en,q as tn,s as rn,t as sn,w as nn}from"./chunk-NG62ISUV.js";import"./chunk-IW5L5276.js";import"./chunk-7MKA3SHV.js";function x(r,e,t,s,n){if(s==="m")throw new TypeError("Private method is not writable");if(s==="a"&&!n)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?r!==e||!n:!e.has(r))throw new TypeError("Cannot write private member to an object whose class did not declare it");return s==="a"?n.call(r,t):n?n.value=t:e.set(r,t),t}function c(r,e,t,s){if(t==="a"&&!s)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?r!==e||!s:!e.has(r))throw new TypeError("Cannot read private member from an object whose class did not declare it");return t==="m"?s:t==="a"?s.call(r):s?s.value:e.get(r)}var Xe=function(){let{crypto:r}=globalThis;if(r?.randomUUID)return Xe=r.randomUUID.bind(r),r.randomUUID();let e=new Uint8Array(1),t=r?()=>r.getRandomValues(e)[0]:()=>Math.random()*255&255;return"10000000-1000-4000-8000-100000000000".replace(/[018]/g,s=>(+s^t()&15>>+s/4).toString(16))};function Jr(r){return typeof r=="object"&&r!==null&&("name"in r&&r.name==="AbortError"||"message"in r&&String(r.message).includes("FetchRequestCanceledException"))}var Xr=r=>{if(r instanceof Error)return r;if(typeof r=="object"&&r!==null){try{if(Object.prototype.toString.call(r)==="[object Error]"){let e=new Error(r.message,r.cause?{cause:r.cause}:{});return r.stack&&(e.stack=r.stack),r.cause&&!e.cause&&(e.cause=r.cause),r.name&&(e.name=r.name),e}}catch{}try{return new Error(JSON.stringify(r))}catch{}}return new Error(r)};var y=class extends Error{},N=class r extends y{constructor(e,t,s,n){super(`${r.makeMessage(e,t,s)}`),this.status=e,this.headers=n,this.requestID=n?.get("x-request-id"),this.error=t;let o=t;this.code=o?.code,this.param=o?.param,this.type=o?.type}static makeMessage(e,t,s){let n=t?.message?typeof t.message=="string"?t.message:JSON.stringify(t.message):t?JSON.stringify(t):s;return e&&n?`${e} ${n}`:e?`${e} status code (no body)`:n||"(no status code or body)"}static generate(e,t,s,n){if(!e||!n)return new $e({message:s,cause:Xr(t)});let o=t?.error;return e===400?new St(e,o,s,n):e===401?new kt(e,o,s,n):e===403?new $t(e,o,s,n):e===404?new Et(e,o,s,n):e===409?new vt(e,o,s,n):e===422?new Ot(e,o,s,n):e===429?new Tt(e,o,s,n):e>=500?new Lt(e,o,s,n):new r(e,o,s,n)}},M=class extends N{constructor({message:e}={}){super(void 0,void 0,e||"Request was aborted.",void 0)}},$e=class extends N{constructor({message:e,cause:t}){super(void 0,void 0,e||"Connection error.",void 0),t&&(this.cause=t)}},Ee=class extends $e{constructor({message:e}={}){super({message:e??"Request timed out."})}},St=class extends N{},kt=class extends N{},$t=class extends N{},Et=class extends N{},vt=class extends N{},Ot=class extends N{},Tt=class extends N{},Lt=class extends N{},jt=class extends y{constructor(){super("Could not parse response content as the length limit was reached")}},Ft=class extends y{constructor(){super("Could not parse response content as the request was rejected by the content filter")}},fe=class extends Error{constructor(e){super(e)}},Ve=class extends N{constructor(e,t,s){let n="OAuth2 authentication error",o;if(t&&typeof t=="object"){let a=t;o=a.error;let l=a.error_description;l&&typeof l=="string"?n=l:o&&(n=o)}super(e,t,n,s),this.error_code=o}},Vr=class extends y{constructor(e,t,s){super(e),this.provider=t,this.cause=s}};var Ri=/^[a-z][a-z0-9+.-]*:/i,no=r=>Ri.test(r),V=r=>(V=Array.isArray,V(r)),ln=V;function Rs(r){return typeof r!="object"?{}:r??{}}function pn(r){if(!r)return!0;for(let e in r)return!1;return!0}function oo(r,e){return Object.prototype.hasOwnProperty.call(r,e)}function Gr(r){return r!=null&&typeof r=="object"&&!Array.isArray(r)}var io=(r,e)=>{if(typeof e!="number"||!Number.isInteger(e))throw new y(`${r} must be an integer`);if(e<0)throw new y(`${r} must be a positive integer`);return e};var ao=r=>{try{return JSON.parse(r)}catch{return}};var he=r=>new Promise(e=>setTimeout(e,r));var ve="6.49.0";var po=()=>typeof window<"u"&&typeof window.document<"u"&&typeof navigator<"u";function Ci(){return typeof Deno<"u"&&Deno.build!=null?"deno":typeof EdgeRuntime<"u"?"edge":Object.prototype.toString.call(typeof globalThis.process<"u"?globalThis.process:0)==="[object process]"?"node":"unknown"}var Si=()=>{let r=Ci();if(r==="deno")return{"X-Stainless-Lang":"js","X-Stainless-Package-Version":ve,"X-Stainless-OS":co(Deno.build.os),"X-Stainless-Arch":uo(Deno.build.arch),"X-Stainless-Runtime":"deno","X-Stainless-Runtime-Version":typeof Deno.version=="string"?Deno.version:Deno.version?.deno??"unknown"};if(typeof EdgeRuntime<"u")return{"X-Stainless-Lang":"js","X-Stainless-Package-Version":ve,"X-Stainless-OS":"Unknown","X-Stainless-Arch":`other:${EdgeRuntime}`,"X-Stainless-Runtime":"edge","X-Stainless-Runtime-Version":globalThis.process.version};if(r==="node")return{"X-Stainless-Lang":"js","X-Stainless-Package-Version":ve,"X-Stainless-OS":co(globalThis.process.platform??"unknown"),"X-Stainless-Arch":uo(globalThis.process.arch??"unknown"),"X-Stainless-Runtime":"node","X-Stainless-Runtime-Version":globalThis.process.version??"unknown"};let e=ki();return e?{"X-Stainless-Lang":"js","X-Stainless-Package-Version":ve,"X-Stainless-OS":"Unknown","X-Stainless-Arch":"unknown","X-Stainless-Runtime":`browser:${e.browser}`,"X-Stainless-Runtime-Version":e.version}:{"X-Stainless-Lang":"js","X-Stainless-Package-Version":ve,"X-Stainless-OS":"Unknown","X-Stainless-Arch":"unknown","X-Stainless-Runtime":"unknown","X-Stainless-Runtime-Version":"unknown"}};function ki(){if(typeof navigator>"u"||!navigator)return null;let r=[{key:"edge",pattern:/Edge(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"ie",pattern:/MSIE(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"ie",pattern:/Trident(?:.*rv\:(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"chrome",pattern:/Chrome(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"firefox",pattern:/Firefox(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"safari",pattern:/(?:Version\W+(\d+)\.(\d+)(?:\.(\d+))?)?(?:\W+Mobile\S*)?\W+Safari/}];for(let{key:e,pattern:t}of r){let s=t.exec(navigator.userAgent);if(s){let n=s[1]||0,o=s[2]||0,a=s[3]||0;return{browser:e,version:`${n}.${o}.${a}`}}}return null}var uo=r=>r==="x32"?"x32":r==="x86_64"||r==="x64"?"x64":r==="arm"?"arm":r==="aarch64"||r==="arm64"?"arm64":r?`other:${r}`:"unknown",co=r=>(r=r.toLowerCase(),r.includes("ios")?"iOS":r==="android"?"Android":r==="darwin"?"MacOS":r==="win32"?"Windows":r==="freebsd"?"FreeBSD":r==="openbsd"?"OpenBSD":r==="linux"?"Linux":r?`Other:${r}`:"Unknown"),lo,fo=()=>lo??(lo=Si());function Cs(){if(typeof fetch<"u")return fetch;throw new Error("`fetch` is not defined as a global; Either pass `fetch` to the client, `new OpenAI({ fetch })` or polyfill the global, `globalThis.fetch = fetch`")}function dn(...r){let e=globalThis.ReadableStream;if(typeof e>"u")throw new Error("`ReadableStream` is not defined as a global; You will need to polyfill it, `globalThis.ReadableStream = ReadableStream`");return new e(...r)}function Qr(r){let e=Symbol.asyncIterator in r?r[Symbol.asyncIterator]():r[Symbol.iterator]();return dn({start(){},async pull(t){let{done:s,value:n}=await e.next();s?t.close():t.enqueue(n)},async cancel(){await e.return?.()}})}function Ss(r){if(r[Symbol.asyncIterator])return r;let e=r.getReader();return{async next(){try{let t=await e.read();return t?.done&&e.releaseLock(),t}catch(t){throw e.releaseLock(),t}},async return(){let t=e.cancel();return e.releaseLock(),await t,{done:!0,value:void 0}},[Symbol.asyncIterator](){return this}}}async function fn(r){if(r===null||typeof r!="object")return;if(r[Symbol.asyncIterator]){await r[Symbol.asyncIterator]().return?.();return}let e=r.getReader(),t=e.cancel();e.releaseLock(),await t}var mo=({headers:r,body:e})=>({bodyHeaders:{"content-type":"application/json"},body:JSON.stringify(e)});var hn="RFC3986",mn=r=>String(r),_n={RFC1738:r=>String(r).replace(/%20/g,"+"),RFC3986:mn},_o="RFC1738";var ks=(r,e)=>(ks=Object.hasOwn??Function.prototype.call.bind(Object.prototype.hasOwnProperty),ks(r,e)),me=(()=>{let r=[];for(let e=0;e<256;++e)r.push("%"+((e<16?"0":"")+e.toString(16)).toUpperCase());return r})();var yn=1024,yo=(r,e,t,s,n)=>{if(r.length===0)return r;let o=r;if(typeof r=="symbol"?o=Symbol.prototype.toString.call(r):typeof r!="string"&&(o=String(r)),t==="iso-8859-1")return escape(o).replace(/%u[0-9a-f]{4}/gi,function(l){return"%26%23"+parseInt(l.slice(2),16)+"%3B"});let a="";for(let l=0;l<o.length;l+=yn){let f=o.length>=yn?o.slice(l,l+yn):o,p=[];for(let h=0;h<f.length;++h){let _=f.charCodeAt(h);if(_===45||_===46||_===95||_===126||_>=48&&_<=57||_>=65&&_<=90||_>=97&&_<=122||n===_o&&(_===40||_===41)){p[p.length]=f.charAt(h);continue}if(_<128){p[p.length]=me[_];continue}if(_<2048){p[p.length]=me[192|_>>6]+me[128|_&63];continue}if(_<55296||_>=57344){p[p.length]=me[224|_>>12]+me[128|_>>6&63]+me[128|_&63];continue}h+=1,_=65536+((_&1023)<<10|f.charCodeAt(h)&1023),p[p.length]=me[240|_>>18]+me[128|_>>12&63]+me[128|_>>6&63]+me[128|_&63]}a+=p.join("")}return a};function go(r){return!r||typeof r!="object"?!1:!!(r.constructor&&r.constructor.isBuffer&&r.constructor.isBuffer(r))}function gn(r,e){if(V(r)){let t=[];for(let s=0;s<r.length;s+=1)t.push(e(r[s]));return t}return e(r)}var bo={brackets(r){return String(r)+"[]"},comma:"comma",indices(r,e){return String(r)+"["+e+"]"},repeat(r){return String(r)}},wo=function(r,e){Array.prototype.push.apply(r,V(e)?e:[e])},Ao,z={addQueryPrefix:!1,allowDots:!1,allowEmptyArrays:!1,arrayFormat:"indices",charset:"utf-8",charsetSentinel:!1,delimiter:"&",encode:!0,encodeDotInKeys:!1,encoder:yo,encodeValuesOnly:!1,format:hn,formatter:mn,indices:!1,serializeDate(r){return(Ao??(Ao=Function.prototype.call.bind(Date.prototype.toISOString)))(r)},skipNulls:!1,strictNullHandling:!1};function Ei(r){return typeof r=="string"||typeof r=="number"||typeof r=="boolean"||typeof r=="symbol"||typeof r=="bigint"}var An={};function Io(r,e,t,s,n,o,a,l,f,p,h,_,m,w,P,b,I,$){let g=r,E=$,R=0,S=!1;for(;(E=E.get(An))!==void 0&&!S;){let L=E.get(r);if(R+=1,typeof L<"u"){if(L===R)throw new RangeError("Cyclic object value");S=!0}typeof E.get(An)>"u"&&(R=0)}if(typeof p=="function"?g=p(e,g):g instanceof Date?g=m?.(g):t==="comma"&&V(g)&&(g=gn(g,function(L){return L instanceof Date?m?.(L):L})),g===null){if(o)return f&&!b?f(e,z.encoder,I,"key",w):e;g=""}if(Ei(g)||go(g)){if(f){let L=b?e:f(e,z.encoder,I,"key",w);return[P?.(L)+"="+P?.(f(g,z.encoder,I,"value",w))]}return[P?.(e)+"="+P?.(String(g))]}let A=[];if(typeof g>"u")return A;let v;if(t==="comma"&&V(g))b&&f&&(g=gn(g,f)),v=[{value:g.length>0?g.join(",")||null:void 0}];else if(V(p))v=p;else{let L=Object.keys(g);v=h?L.sort(h):L}let j=l?String(e).replace(/\./g,"%2E"):String(e),F=s&&V(g)&&g.length===1?j+"[]":j;if(n&&V(g)&&g.length===0)return F+"[]";for(let L=0;L<v.length;++L){let W=v[L],Rt=typeof W=="object"&&typeof W.value<"u"?W.value:g[W];if(a&&Rt===null)continue;let J=_&&l?W.replace(/\./g,"%2E"):W,bs=V(g)?typeof t=="function"?t(F,J):F:F+(_?"."+J:"["+J+"]");$.set(r,R);let ws=new WeakMap;ws.set(An,$),wo(A,Io(Rt,bs,t,s,n,o,a,l,t==="comma"&&b&&V(g)?null:f,p,h,_,m,w,P,b,I,ws))}return A}function vi(r=z){if(typeof r.allowEmptyArrays<"u"&&typeof r.allowEmptyArrays!="boolean")throw new TypeError("`allowEmptyArrays` option can only be `true` or `false`, when provided");if(typeof r.encodeDotInKeys<"u"&&typeof r.encodeDotInKeys!="boolean")throw new TypeError("`encodeDotInKeys` option can only be `true` or `false`, when provided");if(r.encoder!==null&&typeof r.encoder<"u"&&typeof r.encoder!="function")throw new TypeError("Encoder has to be a function.");let e=r.charset||z.charset;if(typeof r.charset<"u"&&r.charset!=="utf-8"&&r.charset!=="iso-8859-1")throw new TypeError("The charset option must be either utf-8, iso-8859-1, or undefined");let t=hn;if(typeof r.format<"u"){if(!ks(_n,r.format))throw new TypeError("Unknown format option provided.");t=r.format}let s=_n[t],n=z.filter;(typeof r.filter=="function"||V(r.filter))&&(n=r.filter);let o;if(r.arrayFormat&&r.arrayFormat in bo?o=r.arrayFormat:"indices"in r?o=r.indices?"indices":"repeat":o=z.arrayFormat,"commaRoundTrip"in r&&typeof r.commaRoundTrip!="boolean")throw new TypeError("`commaRoundTrip` must be a boolean, or absent");let a=typeof r.allowDots>"u"?r.encodeDotInKeys?!0:z.allowDots:!!r.allowDots;return{addQueryPrefix:typeof r.addQueryPrefix=="boolean"?r.addQueryPrefix:z.addQueryPrefix,allowDots:a,allowEmptyArrays:typeof r.allowEmptyArrays=="boolean"?!!r.allowEmptyArrays:z.allowEmptyArrays,arrayFormat:o,charset:e,charsetSentinel:typeof r.charsetSentinel=="boolean"?r.charsetSentinel:z.charsetSentinel,commaRoundTrip:!!r.commaRoundTrip,delimiter:typeof r.delimiter>"u"?z.delimiter:r.delimiter,encode:typeof r.encode=="boolean"?r.encode:z.encode,encodeDotInKeys:typeof r.encodeDotInKeys=="boolean"?r.encodeDotInKeys:z.encodeDotInKeys,encoder:typeof r.encoder=="function"?r.encoder:z.encoder,encodeValuesOnly:typeof r.encodeValuesOnly=="boolean"?r.encodeValuesOnly:z.encodeValuesOnly,filter:n,format:t,formatter:s,serializeDate:typeof r.serializeDate=="function"?r.serializeDate:z.serializeDate,skipNulls:typeof r.skipNulls=="boolean"?r.skipNulls:z.skipNulls,sort:typeof r.sort=="function"?r.sort:null,strictNullHandling:typeof r.strictNullHandling=="boolean"?r.strictNullHandling:z.strictNullHandling}}function Po(r,e={}){let t=r,s=vi(e),n,o;typeof s.filter=="function"?(o=s.filter,t=o("",t)):V(s.filter)&&(o=s.filter,n=o);let a=[];if(typeof t!="object"||t===null)return"";let l=bo[s.arrayFormat],f=l==="comma"&&s.commaRoundTrip;n||(n=Object.keys(t)),s.sort&&n.sort(s.sort);let p=new WeakMap;for(let m=0;m<n.length;++m){let w=n[m];s.skipNulls&&t[w]===null||wo(a,Io(t[w],w,l,f,s.allowEmptyArrays,s.strictNullHandling,s.skipNulls,s.encodeDotInKeys,s.encode?s.encoder:null,s.filter,s.sort,s.allowDots,s.serializeDate,s.format,s.formatter,s.encodeValuesOnly,s.charset,p))}let h=a.join(s.delimiter),_=s.addQueryPrefix===!0?"?":"";return s.charsetSentinel&&(s.charset==="iso-8859-1"?_+="utf8=%26%2310003%3B&":_+="utf8=%E2%9C%93&"),h.length>0?_+h:""}function xo(r){return Po(r,{arrayFormat:"brackets"})}function So(r){let e=0;for(let n of r)e+=n.length;let t=new Uint8Array(e),s=0;for(let n of r)t.set(n,s),s+=n.length;return t}var Ro;function ee(r){let e;return(Ro??(e=new globalThis.TextEncoder,Ro=e.encode.bind(e)))(r)}var Co;function bn(r){let e;return(Co??(e=new globalThis.TextDecoder,Co=e.decode.bind(e)))(r)}var te,re,Ge=class{constructor(){te.set(this,void 0),re.set(this,void 0),x(this,te,new Uint8Array,"f"),x(this,re,null,"f")}decode(e){if(e==null)return[];let t=e instanceof ArrayBuffer?new Uint8Array(e):typeof e=="string"?ee(e):e;x(this,te,So([c(this,te,"f"),t]),"f");let s=[],n;for(;(n=Ti(c(this,te,"f"),c(this,re,"f")))!=null;){if(n.carriage&&c(this,re,"f")==null){x(this,re,n.index,"f");continue}if(c(this,re,"f")!=null&&(n.index!==c(this,re,"f")+1||n.carriage)){s.push(bn(c(this,te,"f").subarray(0,c(this,re,"f")-1))),x(this,te,c(this,te,"f").subarray(c(this,re,"f")),"f"),x(this,re,null,"f");continue}let o=c(this,re,"f")!==null?n.preceding-1:n.preceding,a=bn(c(this,te,"f").subarray(0,o));s.push(a),x(this,te,c(this,te,"f").subarray(n.index),"f"),x(this,re,null,"f")}return s}flush(){return c(this,te,"f").length?this.decode(`
4
+ import{a as cn}from"./chunk-P6DHMU7R.js";import{a as on}from"./chunk-37IAJFPF.js";import{$ as Is,C as to,M as Wr,N as Ae,O as ro,P as an,V as oe,Z as un,_ as Ct,aa as so,ba as de,ca as Ps,da as xs,p as en,r as tn,t as rn,u as sn,x as nn}from"./chunk-3P7BR7SO.js";import"./chunk-IW5L5276.js";import"./chunk-7MKA3SHV.js";function x(r,e,t,s,n){if(s==="m")throw new TypeError("Private method is not writable");if(s==="a"&&!n)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?r!==e||!n:!e.has(r))throw new TypeError("Cannot write private member to an object whose class did not declare it");return s==="a"?n.call(r,t):n?n.value=t:e.set(r,t),t}function c(r,e,t,s){if(t==="a"&&!s)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?r!==e||!s:!e.has(r))throw new TypeError("Cannot read private member from an object whose class did not declare it");return t==="m"?s:t==="a"?s.call(r):s?s.value:e.get(r)}var Xe=function(){let{crypto:r}=globalThis;if(r?.randomUUID)return Xe=r.randomUUID.bind(r),r.randomUUID();let e=new Uint8Array(1),t=r?()=>r.getRandomValues(e)[0]:()=>Math.random()*255&255;return"10000000-1000-4000-8000-100000000000".replace(/[018]/g,s=>(+s^t()&15>>+s/4).toString(16))};function Jr(r){return typeof r=="object"&&r!==null&&("name"in r&&r.name==="AbortError"||"message"in r&&String(r.message).includes("FetchRequestCanceledException"))}var Xr=r=>{if(r instanceof Error)return r;if(typeof r=="object"&&r!==null){try{if(Object.prototype.toString.call(r)==="[object Error]"){let e=new Error(r.message,r.cause?{cause:r.cause}:{});return r.stack&&(e.stack=r.stack),r.cause&&!e.cause&&(e.cause=r.cause),r.name&&(e.name=r.name),e}}catch{}try{return new Error(JSON.stringify(r))}catch{}}return new Error(r)};var y=class extends Error{},N=class r extends y{constructor(e,t,s,n){super(`${r.makeMessage(e,t,s)}`),this.status=e,this.headers=n,this.requestID=n?.get("x-request-id"),this.error=t;let o=t;this.code=o?.code,this.param=o?.param,this.type=o?.type}static makeMessage(e,t,s){let n=t?.message?typeof t.message=="string"?t.message:JSON.stringify(t.message):t?JSON.stringify(t):s;return e&&n?`${e} ${n}`:e?`${e} status code (no body)`:n||"(no status code or body)"}static generate(e,t,s,n){if(!e||!n)return new $e({message:s,cause:Xr(t)});let o=t?.error;return e===400?new St(e,o,s,n):e===401?new kt(e,o,s,n):e===403?new $t(e,o,s,n):e===404?new Et(e,o,s,n):e===409?new vt(e,o,s,n):e===422?new Ot(e,o,s,n):e===429?new Tt(e,o,s,n):e>=500?new Lt(e,o,s,n):new r(e,o,s,n)}},M=class extends N{constructor({message:e}={}){super(void 0,void 0,e||"Request was aborted.",void 0)}},$e=class extends N{constructor({message:e,cause:t}){super(void 0,void 0,e||"Connection error.",void 0),t&&(this.cause=t)}},Ee=class extends $e{constructor({message:e}={}){super({message:e??"Request timed out."})}},St=class extends N{},kt=class extends N{},$t=class extends N{},Et=class extends N{},vt=class extends N{},Ot=class extends N{},Tt=class extends N{},Lt=class extends N{},jt=class extends y{constructor(){super("Could not parse response content as the length limit was reached")}},Ft=class extends y{constructor(){super("Could not parse response content as the request was rejected by the content filter")}},fe=class extends Error{constructor(e){super(e)}},Ve=class extends N{constructor(e,t,s){let n="OAuth2 authentication error",o;if(t&&typeof t=="object"){let a=t;o=a.error;let l=a.error_description;l&&typeof l=="string"?n=l:o&&(n=o)}super(e,t,n,s),this.error_code=o}},Vr=class extends y{constructor(e,t,s){super(e),this.provider=t,this.cause=s}};var Ri=/^[a-z][a-z0-9+.-]*:/i,no=r=>Ri.test(r),V=r=>(V=Array.isArray,V(r)),ln=V;function Rs(r){return typeof r!="object"?{}:r??{}}function pn(r){if(!r)return!0;for(let e in r)return!1;return!0}function oo(r,e){return Object.prototype.hasOwnProperty.call(r,e)}function Gr(r){return r!=null&&typeof r=="object"&&!Array.isArray(r)}var io=(r,e)=>{if(typeof e!="number"||!Number.isInteger(e))throw new y(`${r} must be an integer`);if(e<0)throw new y(`${r} must be a positive integer`);return e};var ao=r=>{try{return JSON.parse(r)}catch{return}};var he=r=>new Promise(e=>setTimeout(e,r));var ve="6.49.0";var po=()=>typeof window<"u"&&typeof window.document<"u"&&typeof navigator<"u";function Ci(){return typeof Deno<"u"&&Deno.build!=null?"deno":typeof EdgeRuntime<"u"?"edge":Object.prototype.toString.call(typeof globalThis.process<"u"?globalThis.process:0)==="[object process]"?"node":"unknown"}var Si=()=>{let r=Ci();if(r==="deno")return{"X-Stainless-Lang":"js","X-Stainless-Package-Version":ve,"X-Stainless-OS":co(Deno.build.os),"X-Stainless-Arch":uo(Deno.build.arch),"X-Stainless-Runtime":"deno","X-Stainless-Runtime-Version":typeof Deno.version=="string"?Deno.version:Deno.version?.deno??"unknown"};if(typeof EdgeRuntime<"u")return{"X-Stainless-Lang":"js","X-Stainless-Package-Version":ve,"X-Stainless-OS":"Unknown","X-Stainless-Arch":`other:${EdgeRuntime}`,"X-Stainless-Runtime":"edge","X-Stainless-Runtime-Version":globalThis.process.version};if(r==="node")return{"X-Stainless-Lang":"js","X-Stainless-Package-Version":ve,"X-Stainless-OS":co(globalThis.process.platform??"unknown"),"X-Stainless-Arch":uo(globalThis.process.arch??"unknown"),"X-Stainless-Runtime":"node","X-Stainless-Runtime-Version":globalThis.process.version??"unknown"};let e=ki();return e?{"X-Stainless-Lang":"js","X-Stainless-Package-Version":ve,"X-Stainless-OS":"Unknown","X-Stainless-Arch":"unknown","X-Stainless-Runtime":`browser:${e.browser}`,"X-Stainless-Runtime-Version":e.version}:{"X-Stainless-Lang":"js","X-Stainless-Package-Version":ve,"X-Stainless-OS":"Unknown","X-Stainless-Arch":"unknown","X-Stainless-Runtime":"unknown","X-Stainless-Runtime-Version":"unknown"}};function ki(){if(typeof navigator>"u"||!navigator)return null;let r=[{key:"edge",pattern:/Edge(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"ie",pattern:/MSIE(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"ie",pattern:/Trident(?:.*rv\:(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"chrome",pattern:/Chrome(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"firefox",pattern:/Firefox(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"safari",pattern:/(?:Version\W+(\d+)\.(\d+)(?:\.(\d+))?)?(?:\W+Mobile\S*)?\W+Safari/}];for(let{key:e,pattern:t}of r){let s=t.exec(navigator.userAgent);if(s){let n=s[1]||0,o=s[2]||0,a=s[3]||0;return{browser:e,version:`${n}.${o}.${a}`}}}return null}var uo=r=>r==="x32"?"x32":r==="x86_64"||r==="x64"?"x64":r==="arm"?"arm":r==="aarch64"||r==="arm64"?"arm64":r?`other:${r}`:"unknown",co=r=>(r=r.toLowerCase(),r.includes("ios")?"iOS":r==="android"?"Android":r==="darwin"?"MacOS":r==="win32"?"Windows":r==="freebsd"?"FreeBSD":r==="openbsd"?"OpenBSD":r==="linux"?"Linux":r?`Other:${r}`:"Unknown"),lo,fo=()=>lo??(lo=Si());function Cs(){if(typeof fetch<"u")return fetch;throw new Error("`fetch` is not defined as a global; Either pass `fetch` to the client, `new OpenAI({ fetch })` or polyfill the global, `globalThis.fetch = fetch`")}function dn(...r){let e=globalThis.ReadableStream;if(typeof e>"u")throw new Error("`ReadableStream` is not defined as a global; You will need to polyfill it, `globalThis.ReadableStream = ReadableStream`");return new e(...r)}function Qr(r){let e=Symbol.asyncIterator in r?r[Symbol.asyncIterator]():r[Symbol.iterator]();return dn({start(){},async pull(t){let{done:s,value:n}=await e.next();s?t.close():t.enqueue(n)},async cancel(){await e.return?.()}})}function Ss(r){if(r[Symbol.asyncIterator])return r;let e=r.getReader();return{async next(){try{let t=await e.read();return t?.done&&e.releaseLock(),t}catch(t){throw e.releaseLock(),t}},async return(){let t=e.cancel();return e.releaseLock(),await t,{done:!0,value:void 0}},[Symbol.asyncIterator](){return this}}}async function fn(r){if(r===null||typeof r!="object")return;if(r[Symbol.asyncIterator]){await r[Symbol.asyncIterator]().return?.();return}let e=r.getReader(),t=e.cancel();e.releaseLock(),await t}var mo=({headers:r,body:e})=>({bodyHeaders:{"content-type":"application/json"},body:JSON.stringify(e)});var hn="RFC3986",mn=r=>String(r),_n={RFC1738:r=>String(r).replace(/%20/g,"+"),RFC3986:mn},_o="RFC1738";var ks=(r,e)=>(ks=Object.hasOwn??Function.prototype.call.bind(Object.prototype.hasOwnProperty),ks(r,e)),me=(()=>{let r=[];for(let e=0;e<256;++e)r.push("%"+((e<16?"0":"")+e.toString(16)).toUpperCase());return r})();var yn=1024,yo=(r,e,t,s,n)=>{if(r.length===0)return r;let o=r;if(typeof r=="symbol"?o=Symbol.prototype.toString.call(r):typeof r!="string"&&(o=String(r)),t==="iso-8859-1")return escape(o).replace(/%u[0-9a-f]{4}/gi,function(l){return"%26%23"+parseInt(l.slice(2),16)+"%3B"});let a="";for(let l=0;l<o.length;l+=yn){let f=o.length>=yn?o.slice(l,l+yn):o,p=[];for(let h=0;h<f.length;++h){let _=f.charCodeAt(h);if(_===45||_===46||_===95||_===126||_>=48&&_<=57||_>=65&&_<=90||_>=97&&_<=122||n===_o&&(_===40||_===41)){p[p.length]=f.charAt(h);continue}if(_<128){p[p.length]=me[_];continue}if(_<2048){p[p.length]=me[192|_>>6]+me[128|_&63];continue}if(_<55296||_>=57344){p[p.length]=me[224|_>>12]+me[128|_>>6&63]+me[128|_&63];continue}h+=1,_=65536+((_&1023)<<10|f.charCodeAt(h)&1023),p[p.length]=me[240|_>>18]+me[128|_>>12&63]+me[128|_>>6&63]+me[128|_&63]}a+=p.join("")}return a};function go(r){return!r||typeof r!="object"?!1:!!(r.constructor&&r.constructor.isBuffer&&r.constructor.isBuffer(r))}function gn(r,e){if(V(r)){let t=[];for(let s=0;s<r.length;s+=1)t.push(e(r[s]));return t}return e(r)}var bo={brackets(r){return String(r)+"[]"},comma:"comma",indices(r,e){return String(r)+"["+e+"]"},repeat(r){return String(r)}},wo=function(r,e){Array.prototype.push.apply(r,V(e)?e:[e])},Ao,z={addQueryPrefix:!1,allowDots:!1,allowEmptyArrays:!1,arrayFormat:"indices",charset:"utf-8",charsetSentinel:!1,delimiter:"&",encode:!0,encodeDotInKeys:!1,encoder:yo,encodeValuesOnly:!1,format:hn,formatter:mn,indices:!1,serializeDate(r){return(Ao??(Ao=Function.prototype.call.bind(Date.prototype.toISOString)))(r)},skipNulls:!1,strictNullHandling:!1};function Ei(r){return typeof r=="string"||typeof r=="number"||typeof r=="boolean"||typeof r=="symbol"||typeof r=="bigint"}var An={};function Io(r,e,t,s,n,o,a,l,f,p,h,_,m,w,P,b,I,$){let g=r,E=$,R=0,S=!1;for(;(E=E.get(An))!==void 0&&!S;){let L=E.get(r);if(R+=1,typeof L<"u"){if(L===R)throw new RangeError("Cyclic object value");S=!0}typeof E.get(An)>"u"&&(R=0)}if(typeof p=="function"?g=p(e,g):g instanceof Date?g=m?.(g):t==="comma"&&V(g)&&(g=gn(g,function(L){return L instanceof Date?m?.(L):L})),g===null){if(o)return f&&!b?f(e,z.encoder,I,"key",w):e;g=""}if(Ei(g)||go(g)){if(f){let L=b?e:f(e,z.encoder,I,"key",w);return[P?.(L)+"="+P?.(f(g,z.encoder,I,"value",w))]}return[P?.(e)+"="+P?.(String(g))]}let A=[];if(typeof g>"u")return A;let v;if(t==="comma"&&V(g))b&&f&&(g=gn(g,f)),v=[{value:g.length>0?g.join(",")||null:void 0}];else if(V(p))v=p;else{let L=Object.keys(g);v=h?L.sort(h):L}let j=l?String(e).replace(/\./g,"%2E"):String(e),F=s&&V(g)&&g.length===1?j+"[]":j;if(n&&V(g)&&g.length===0)return F+"[]";for(let L=0;L<v.length;++L){let W=v[L],Rt=typeof W=="object"&&typeof W.value<"u"?W.value:g[W];if(a&&Rt===null)continue;let J=_&&l?W.replace(/\./g,"%2E"):W,bs=V(g)?typeof t=="function"?t(F,J):F:F+(_?"."+J:"["+J+"]");$.set(r,R);let ws=new WeakMap;ws.set(An,$),wo(A,Io(Rt,bs,t,s,n,o,a,l,t==="comma"&&b&&V(g)?null:f,p,h,_,m,w,P,b,I,ws))}return A}function vi(r=z){if(typeof r.allowEmptyArrays<"u"&&typeof r.allowEmptyArrays!="boolean")throw new TypeError("`allowEmptyArrays` option can only be `true` or `false`, when provided");if(typeof r.encodeDotInKeys<"u"&&typeof r.encodeDotInKeys!="boolean")throw new TypeError("`encodeDotInKeys` option can only be `true` or `false`, when provided");if(r.encoder!==null&&typeof r.encoder<"u"&&typeof r.encoder!="function")throw new TypeError("Encoder has to be a function.");let e=r.charset||z.charset;if(typeof r.charset<"u"&&r.charset!=="utf-8"&&r.charset!=="iso-8859-1")throw new TypeError("The charset option must be either utf-8, iso-8859-1, or undefined");let t=hn;if(typeof r.format<"u"){if(!ks(_n,r.format))throw new TypeError("Unknown format option provided.");t=r.format}let s=_n[t],n=z.filter;(typeof r.filter=="function"||V(r.filter))&&(n=r.filter);let o;if(r.arrayFormat&&r.arrayFormat in bo?o=r.arrayFormat:"indices"in r?o=r.indices?"indices":"repeat":o=z.arrayFormat,"commaRoundTrip"in r&&typeof r.commaRoundTrip!="boolean")throw new TypeError("`commaRoundTrip` must be a boolean, or absent");let a=typeof r.allowDots>"u"?r.encodeDotInKeys?!0:z.allowDots:!!r.allowDots;return{addQueryPrefix:typeof r.addQueryPrefix=="boolean"?r.addQueryPrefix:z.addQueryPrefix,allowDots:a,allowEmptyArrays:typeof r.allowEmptyArrays=="boolean"?!!r.allowEmptyArrays:z.allowEmptyArrays,arrayFormat:o,charset:e,charsetSentinel:typeof r.charsetSentinel=="boolean"?r.charsetSentinel:z.charsetSentinel,commaRoundTrip:!!r.commaRoundTrip,delimiter:typeof r.delimiter>"u"?z.delimiter:r.delimiter,encode:typeof r.encode=="boolean"?r.encode:z.encode,encodeDotInKeys:typeof r.encodeDotInKeys=="boolean"?r.encodeDotInKeys:z.encodeDotInKeys,encoder:typeof r.encoder=="function"?r.encoder:z.encoder,encodeValuesOnly:typeof r.encodeValuesOnly=="boolean"?r.encodeValuesOnly:z.encodeValuesOnly,filter:n,format:t,formatter:s,serializeDate:typeof r.serializeDate=="function"?r.serializeDate:z.serializeDate,skipNulls:typeof r.skipNulls=="boolean"?r.skipNulls:z.skipNulls,sort:typeof r.sort=="function"?r.sort:null,strictNullHandling:typeof r.strictNullHandling=="boolean"?r.strictNullHandling:z.strictNullHandling}}function Po(r,e={}){let t=r,s=vi(e),n,o;typeof s.filter=="function"?(o=s.filter,t=o("",t)):V(s.filter)&&(o=s.filter,n=o);let a=[];if(typeof t!="object"||t===null)return"";let l=bo[s.arrayFormat],f=l==="comma"&&s.commaRoundTrip;n||(n=Object.keys(t)),s.sort&&n.sort(s.sort);let p=new WeakMap;for(let m=0;m<n.length;++m){let w=n[m];s.skipNulls&&t[w]===null||wo(a,Io(t[w],w,l,f,s.allowEmptyArrays,s.strictNullHandling,s.skipNulls,s.encodeDotInKeys,s.encode?s.encoder:null,s.filter,s.sort,s.allowDots,s.serializeDate,s.format,s.formatter,s.encodeValuesOnly,s.charset,p))}let h=a.join(s.delimiter),_=s.addQueryPrefix===!0?"?":"";return s.charsetSentinel&&(s.charset==="iso-8859-1"?_+="utf8=%26%2310003%3B&":_+="utf8=%E2%9C%93&"),h.length>0?_+h:""}function xo(r){return Po(r,{arrayFormat:"brackets"})}function So(r){let e=0;for(let n of r)e+=n.length;let t=new Uint8Array(e),s=0;for(let n of r)t.set(n,s),s+=n.length;return t}var Ro;function ee(r){let e;return(Ro??(e=new globalThis.TextEncoder,Ro=e.encode.bind(e)))(r)}var Co;function bn(r){let e;return(Co??(e=new globalThis.TextDecoder,Co=e.decode.bind(e)))(r)}var te,re,Ge=class{constructor(){te.set(this,void 0),re.set(this,void 0),x(this,te,new Uint8Array,"f"),x(this,re,null,"f")}decode(e){if(e==null)return[];let t=e instanceof ArrayBuffer?new Uint8Array(e):typeof e=="string"?ee(e):e;x(this,te,So([c(this,te,"f"),t]),"f");let s=[],n;for(;(n=Ti(c(this,te,"f"),c(this,re,"f")))!=null;){if(n.carriage&&c(this,re,"f")==null){x(this,re,n.index,"f");continue}if(c(this,re,"f")!=null&&(n.index!==c(this,re,"f")+1||n.carriage)){s.push(bn(c(this,te,"f").subarray(0,c(this,re,"f")-1))),x(this,te,c(this,te,"f").subarray(c(this,re,"f")),"f"),x(this,re,null,"f");continue}let o=c(this,re,"f")!==null?n.preceding-1:n.preceding,a=bn(c(this,te,"f").subarray(0,o));s.push(a),x(this,te,c(this,te,"f").subarray(n.index),"f"),x(this,re,null,"f")}return s}flush(){return c(this,te,"f").length?this.decode(`
5
5
  `):[]}};te=new WeakMap,re=new WeakMap;Ge.NEWLINE_CHARS=new Set([`
6
6
  `,"\r"]);Ge.NEWLINE_REGEXP=/\r\n|[\n\r]/g;function Ti(r,e){for(let n=e??0;n<r.length;n++){if(r[n]===10)return{preceding:n,index:n+1,carriage:!1};if(r[n]===13)return{preceding:n,index:n+1,carriage:!0}}return null}function ko(r){for(let s=0;s<r.length-1;s++){if(r[s]===10&&r[s+1]===10||r[s]===13&&r[s+1]===13)return s+2;if(r[s]===13&&r[s+1]===10&&s+3<r.length&&r[s+2]===13&&r[s+3]===10)return s+4}return-1}var Es={off:0,error:200,warn:300,info:400,debug:500},wn=(r,e,t)=>{if(r){if(oo(Es,r))return r;K(t).warn(`${e} was set to ${JSON.stringify(r)}, expected one of ${JSON.stringify(Object.keys(Es))}`)}};function Yr(){}function $s(r,e,t){return!e||Es[r]>Es[t]?Yr:e[r].bind(e)}var Li={error:Yr,warn:Yr,info:Yr,debug:Yr},$o=new WeakMap;function K(r){let e=r.logger,t=r.logLevel??"off";if(!e)return Li;let s=$o.get(e);if(s&&s[0]===t)return s[1];let n={error:$s("error",e,t),warn:$s("warn",e,t),info:$s("info",e,t),debug:$s("debug",e,t)};return $o.set(e,[t,n]),n}var be=r=>(r.options&&(r.options={...r.options},delete r.options.headers),r.headers&&(r.headers=Object.fromEntries((r.headers instanceof Headers?[...r.headers]:Object.entries(r.headers)).map(([e,t])=>[e,e.toLowerCase()==="authorization"||e.toLowerCase()==="api-key"||e.toLowerCase()==="x-api-key"||e.toLowerCase()==="x-amz-security-token"||e.toLowerCase()==="cookie"||e.toLowerCase()==="set-cookie"?"***":t]))),"retryOfRequestLogID"in r&&(r.retryOfRequestLogID&&(r.retryOf=r.retryOfRequestLogID),delete r.retryOfRequestLogID),r);var Zr,Z=class r{constructor(e,t,s){this.iterator=e,Zr.set(this,void 0),this.controller=t,x(this,Zr,s,"f")}static fromSSEResponse(e,t,s,n){let o=!1,a=s?K(s):console;async function*l(){if(o)throw new y("Cannot iterate over a consumed stream, use `.tee()` to split the stream.");o=!0;let f=!1;try{for await(let p of ji(e,t))if(!f){if(p.data.startsWith("[DONE]")){f=!0;continue}if(p.event===null||!p.event.startsWith("thread.")){let h;try{h=JSON.parse(p.data)}catch(_){throw a.error("Could not parse message into JSON:",p.data),a.error("From chunk:",p.raw),_}if(h&&h.error)throw new N(void 0,h.error,void 0,e.headers);yield n?{event:p.event,data:h}:h}else{let h;try{h=JSON.parse(p.data)}catch(_){throw console.error("Could not parse message into JSON:",p.data),console.error("From chunk:",p.raw),_}if(p.event=="error")throw new N(void 0,h.error,h.message,void 0);yield{event:p.event,data:h}}}f=!0}catch(p){if(Jr(p))return;throw p}finally{f||t.abort()}}return new r(l,t,s)}static fromReadableStream(e,t,s){let n=!1;async function*o(){let l=new Ge,f=e.getReader(),p=!1,h,_=()=>{h??(h=f.cancel()),h.catch(()=>{})};t.signal.addEventListener("abort",_,{once:!0});try{if(t.signal.aborted){_();return}for(;;){let{value:m,done:w}=await f.read();if(w){p=!0;break}if(t.signal.aborted)return;for(let P of l.decode(m)){if(t.signal.aborted)return;yield P}}if(t.signal.aborted)return;for(let m of l.flush()){if(t.signal.aborted)return;yield m}}finally{t.signal.removeEventListener("abort",_),p||_(),f.releaseLock()}}async function*a(){if(n)throw new y("Cannot iterate over a consumed stream, use `.tee()` to split the stream.");n=!0;let l=!1;try{for await(let f of o())l||f&&(yield JSON.parse(f));l=!0}catch(f){if(t.signal.aborted||Jr(f))return;throw f}finally{l||t.abort()}}return new r(a,t,s)}[(Zr=new WeakMap,Symbol.asyncIterator)](){return this.iterator()}tee(){let e=[],t=[],s=this.iterator(),n=o=>({next:()=>{if(o.length===0){let a=s.next();e.push(a),t.push(a)}return o.shift()}});return[new r(()=>n(e),this.controller,c(this,Zr,"f")),new r(()=>n(t),this.controller,c(this,Zr,"f"))]}toReadableStream(){let e=this,t;return dn({async start(){t=e[Symbol.asyncIterator]()},async pull(s){try{let{value:n,done:o}=await t.next();if(o)return s.close();let a=ee(JSON.stringify(n)+`
7
7
  `);s.enqueue(a)}catch(n){s.error(n)}},async cancel(){await t.return?.()}})}};async function*ji(r,e){if(!r.body)throw e.abort(),typeof globalThis.navigator<"u"&&globalThis.navigator.product==="ReactNative"?new y("The default react-native fetch implementation does not support streaming. Please use expo/fetch: https://docs.expo.dev/versions/latest/sdk/expo/#expofetch-api"):new y("Attempted to iterate over a response with no body");let t=new In,s=new Ge,n=Ss(r.body);for await(let o of Fi(n))for(let a of s.decode(o)){let l=t.decode(a);l&&(yield l)}for(let o of s.flush()){let a=t.decode(o);a&&(yield a)}}async function*Fi(r){let e=new Uint8Array;for await(let t of r){if(t==null)continue;let s=t instanceof ArrayBuffer?new Uint8Array(t):typeof t=="string"?ee(t):t,n=new Uint8Array(e.length+s.length);n.set(e),n.set(s,e.length),e=n;let o;for(;(o=ko(e))!==-1;)yield e.slice(0,o),e=e.slice(o)}e.length>0&&(yield e)}var In=class{constructor(){this.event=null,this.data=[],this.chunks=[]}decode(e){if(e.endsWith("\r")&&(e=e.substring(0,e.length-1)),!e){if(!this.event&&!this.data.length)return null;let o={event:this.event,data:this.data.join(`
@@ -1,4 +1,4 @@
1
1
  #!/usr/bin/env node
2
2
  import { createRequire as __yukinoCreateRequire } from "node:module";
3
3
  const require = __yukinoCreateRequire(import.meta.url);
4
- import{b as a,c as b}from"./chunk-HWDSXNX4.js";import"./chunk-JFKC4VCA.js";import"./chunk-IW5L5276.js";import"./chunk-HMZQYFYG.js";import"./chunk-3QL446GD.js";import"./chunk-AGSYLE4E.js";import"./chunk-CU3IISCC.js";import"./chunk-VCIRD267.js";import"./chunk-7MKA3SHV.js";export{b as createTelemetryRuntime,a as parseExporterTypes};
4
+ import{b as a,c as b}from"./chunk-L5C5JBLP.js";import"./chunk-JFKC4VCA.js";import"./chunk-IW5L5276.js";import"./chunk-HMZQYFYG.js";import"./chunk-3QL446GD.js";import"./chunk-AGSYLE4E.js";import"./chunk-CU3IISCC.js";import"./chunk-VCIRD267.js";import"./chunk-7MKA3SHV.js";export{b as createTelemetryRuntime,a as parseExporterTypes};
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env node
2
+ import { createRequire as __yukinoCreateRequire } from "node:module";
3
+ const require = __yukinoCreateRequire(import.meta.url);
4
+ import{c as a,d as b}from"./chunk-MU6PSBZT.js";import"./chunk-WGFROGUC.js";import"./chunk-YHE4BT76.js";import"./chunk-VU3JWAJR.js";import"./chunk-L5C5JBLP.js";import"./chunk-JFKC4VCA.js";import"./chunk-6XDMANXO.js";import"./chunk-3P7BR7SO.js";import"./chunk-IW5L5276.js";import"./chunk-NAQRFHUX.js";import"./chunk-VM4YKTHC.js";import"./chunk-HMZQYFYG.js";import"./chunk-3QL446GD.js";import"./chunk-AGSYLE4E.js";import"./chunk-CU3IISCC.js";import"./chunk-VCIRD267.js";import"./chunk-7MKA3SHV.js";export{b as RemoteServer,a as createRemoteAgent};
package/package.json CHANGED
@@ -1,8 +1,9 @@
1
1
  {
2
2
  "name": "@yukino.js/yukino",
3
- "version": "0.0.7",
3
+ "version": "0.0.8",
4
4
  "description": "Yukino is a terminal-based AI coding agent. It provides an interactive UI (terminal user interface) for conversing with large language models, executing code, manipulating files, and orchestrating multi-agent workflows, all from the command line.",
5
5
  "keywords": [
6
+ "a2a",
6
7
  "acp",
7
8
  "agent",
8
9
  "agent-team",
@@ -75,21 +76,19 @@
75
76
  "access": "public"
76
77
  },
77
78
  "dependencies": {
79
+ "@a2a-js/sdk": "^1.3.0",
78
80
  "@agentclientprotocol/sdk": "^1.5.1",
79
- "@anthropic-ai/sandbox-runtime": "^0.0.76",
80
81
  "@anthropic-ai/sdk": "^0.104.2",
81
- "@modelcontextprotocol/sdk": "^1.30.1",
82
+ "@modelcontextprotocol/sdk": "^1.31.0",
82
83
  "ansi-escapes": "^7.3.0",
83
84
  "ansi-regex": "^6.4.0",
84
85
  "chalk": "^5.6.2",
85
- "cli-highlight": "^2.1.11",
86
- "cli-table3": "^0.6.5",
87
86
  "dompurify": "^3.4.16",
87
+ "express": "^5.2.1",
88
88
  "fuse.js": "^7.5.0",
89
89
  "glob": "^13.0.6",
90
90
  "ink": "^7.1.1",
91
91
  "js-yaml": "^4.3.2",
92
- "koa": "^3.2.1",
93
92
  "marked": "^18.0.14",
94
93
  "minimatch": "^10.2.6",
95
94
  "node-emoji": "^2.2.0",
@@ -98,6 +97,7 @@
98
97
  "react": "19.2.7",
99
98
  "react-dom": "19.2.7",
100
99
  "sharp": "^0.35.5",
100
+ "shiki": "^4.4.3",
101
101
  "slice-ansi": "^9.0.1",
102
102
  "string-width": "^8.3.0",
103
103
  "supports-hyperlinks": "^4.5.0",
@@ -130,16 +130,15 @@
130
130
  "@sentry/node": "^10.75.3"
131
131
  },
132
132
  "devDependencies": {
133
- "@biomejs/biome": "2.4.15",
134
133
  "@eslint/js": "^9.39.5",
135
134
  "@tailwindcss/postcss": "^4.3.3",
135
+ "@types/express": "^5.0.6",
136
136
  "@types/js-yaml": "^4.0.9",
137
- "@types/koa": "^3.0.3",
138
137
  "@types/node": "^24.19.0",
139
138
  "@types/react": "^19.3.0",
140
139
  "@types/react-dom": "^19.3.0",
141
140
  "@types/turndown": "^5.0.6",
142
- "@types/ws": "^8.18.1",
141
+ "@types/ws": "^8.18.2",
143
142
  "@vitest/coverage-v8": "^4.1.11",
144
143
  "eslint": "^9.39.5",
145
144
  "eslint-plugin-import": "^2.32.0",
@@ -154,7 +153,7 @@
154
153
  "tsup": "^8.5.1",
155
154
  "tsx": "^4.23.15",
156
155
  "typescript": "^5.9.3",
157
- "typescript-eslint": "^8.70.1",
156
+ "typescript-eslint": "^8.71.0",
158
157
  "vitest": "^4.1.11"
159
158
  },
160
159
  "engines": {
@@ -164,8 +163,8 @@
164
163
  "dev:fe": "cd src/remote/fe && tsup --watch",
165
164
  "build:fe": "cd src/remote/fe && rm -rf ./dist && tsup",
166
165
  "preview:fe": "pnpm dlx serve src/remote/fe/dist",
167
- "dev": "tsx ./src/main.tsx",
168
- "build": "rm -rf ./dist && tsup",
166
+ "dev": "pnpm build:fe && tsx ./src/main.tsx",
167
+ "build": "pnpm build:fe && rm -rf ./dist && tsup",
169
168
  "lint": "eslint --cache --quiet ./src ./tests",
170
169
  "lint:fix": "eslint --cache --fix --quiet ./src ./tests",
171
170
  "test": "vitest run --maxWorkers=2",
@@ -1,4 +0,0 @@
1
- #!/usr/bin/env node
2
- import { createRequire as __yukinoCreateRequire } from "node:module";
3
- const require = __yukinoCreateRequire(import.meta.url);
4
- import{g as w}from"./chunk-MDPSQ6L7.js";import{a as W}from"./chunk-P6DHMU7R.js";import{a as V,g as D,h as J}from"./chunk-7PPWFSIC.js";import{a as j}from"./chunk-7ZBAF7M4.js";import{$ as z,B as U,L as K,O as h,P as $,U as F,Y as H,Z as q,_ as P,aa as g,ba as G,ca as Y,m as S,o as C,p as M,q as N,r as R,s as B,t as O,w as L}from"./chunk-NG62ISUV.js";import"./chunk-IW5L5276.js";import"./chunk-7MKA3SHV.js";function Z(o){for(let t=o.length-1;t>=0;t--){let e=o[t];if(e.defer_loading!==!0){e.cache_control={type:"ephemeral"};return}}}function ee(o){return o.some(t=>"defer_loading"in t&&t.defer_loading===!0)}function te(o,t){if("input_schema"in o){let e=o,{cache_control:n,...i}=e;return t||delete i.type,{...i,...t?{type:"custom"}:{},...e.defer_loading!==!0&&n?{cache_control:n}:{}}}throw new Error("Anthropic received a tool schema serialized for another protocol.")}var oe=U({module:"llm"});function f(o){return typeof o=="string"?[{type:"text",text:o}]:o.map(t=>{let e=V(t);if(!e||e.type==="tool_reference")throw new Error(`Unsupported user content block: ${F(t,"type","unknown")}`);return e})}function ne(o){let t=[];for(let e of o)if(e.role==="assistant"){let n=[];if(e.thinkingBlocks)for(let l of e.thinkingBlocks)n.push({type:"thinking",thinking:l.thinking,signature:l.signature});let i=typeof e.content=="string"?e.content:K(e.content);if(i&&n.push({type:"text",text:i}),e.toolUses)for(let l of e.toolUses)n.push({type:"tool_use",id:l.toolUseId,name:l.toolName==="ComputerUse"?"computer":l.toolName,input:l.arguments});n.length===0&&n.push({type:"text",text:""}),t.push({role:"assistant",content:n})}else if(e.toolResults&&e.toolResults.length>0){let n=[];for(let i of e.toolResults)n.push({type:"tool_result",tool_use_id:i.toolUseId,is_error:i.isError,content:i.contentBlocks?.length?i.contentBlocks:i.content});e.content.length>0&&n.push(...f(e.content)),t.push({role:"user",content:n})}else{if(t.length===0){t.push({role:"user",content:f(e.content)});continue}let n=t[t.length-1],i=n.content;n.role==="user"?(typeof i=="string"&&(i=n.content=i.trim().length>0?[{type:"text",text:i}]:[]),i.push(...f(e.content))):t.push({role:"user",content:f(e.content)})}return t}var Q=class{protocol="anthropic";client;model;thinkingLevel;systemPrompt;maxOutputTokens;config;useExplicitCustomToolType;constructor(t,e){let n=j(t);if(!n)throw new P("Anthropic API key not found, set ANTHROPIC_API_KEY in ~/.yukino/config.yaml, or via ANTHROPIC_API_KEY env variable.");this.client=new w({apiKey:n,baseURL:t.base_url}),this.useExplicitCustomToolType=J(t.base_url),this.model=t.model,this.config={...t},this.thinkingLevel=C(t),this.systemPrompt=e,this.maxOutputTokens=L(t)}setSystemPrompt(t){this.systemPrompt=t}setMaxOutputTokens(t){this.config={...this.config,max_output_tokens:t},this.maxOutputTokens=L(this.config),this.setThinkingLevel(this.thinkingLevel)}setThinkingLevel(t){return this.thinkingLevel=O(this.config,t),this.thinkingLevel}getThinkingLevel(){return this.thinkingLevel}getSupportedThinkingLevels(){return B(this.config)}async*stream(t,e,n){let i=ne(H(t.getMessages())),l=ee(e),d=e.map(r=>te(r,this.useExplicitCustomToolType));Z(d),se(i);let p={model:this.model,max_tokens:this.maxOutputTokens,stream:!0,system:[{type:"text",text:this.systemPrompt,cache_control:{type:"ephemeral"}}],messages:i,...d.length>0?{tools:d}:{}},k=this.getThinkingLevel();if(this.config.reasoning!==!1)if(k==="off")p.thinking={type:"disabled"};else if(this.config.thinking_mode==="adaptive"){let r=R(k,this.config);r!==null&&(p.thinking={type:"adaptive"},p.output_config={effort:r})}else{let r=N(k,this.config);r!==null&&r!=="none"&&(p.thinking={type:"enabled",budget_tokens:Math.min(M(r),this.maxOutputTokens-S)})}let _=0,y=0,T=0,v=0,E="end_turn",A="",b="",x=!1,I=!1;try{let r=[...l?[D]:[]],X=this.client.messages.stream(p,{...n?{signal:n}:{},...r.length>0?{headers:{"anthropic-beta":r.join(",")}}:{}}),c="",u="",m="";for await(let a of X)switch(a.type){case"content_block_start":{let s=a.content_block;if(s.type==="thinking")x=!0,A="",b="";else if(s.type==="tool_use"){if(!s.id||!s.name)throw new g("Anthropic tool call started without a valid id or name");u=s.id,c=s.name==="computer"?"ComputerUse":s.name,m="",yield{type:"tool_call_start",toolName:c,toolId:u}}break}case"content_block_delta":{let s=a.delta;if(s.type==="thinking_delta")A+=s.thinking,yield{type:"thinking_delta",text:s.thinking};else if(s.type==="signature_delta")b+=s.signature;else if(s.type==="text_delta")yield{type:"text_delta",text:s.text};else if(s.type==="input_json_delta"){if(!u||!c)throw new g("Anthropic tool arguments arrived before a valid tool call");m+=s.partial_json,yield{type:"tool_call_delta",text:s.partial_json}}break}case"content_block_stop":{if(x&&(yield{type:"thinking_complete",thinking:A,signature:b},x=!1),c){let s=W(m);yield{type:"tool_call_complete",toolId:u,toolName:c,arguments:s.arguments,...s.parseError?{parseError:s.parseError}:{}},c="",u="",m=""}break}case"message_delta":{a.delta.stop_reason&&(E=a.delta.stop_reason);let s=a.usage;typeof s.output_tokens=="number"&&(y=s.output_tokens),typeof s.input_tokens=="number"&&(_=s.input_tokens),typeof s.cache_read_input_tokens=="number"&&(T=s.cache_read_input_tokens),typeof s.cache_creation_input_tokens=="number"&&(v=s.cache_creation_input_tokens);break}case"message_stop":{I=!0;break}case"message_start":{_=a.message.usage.input_tokens,y=a.message.usage.output_tokens,T=a.message.usage.cache_read_input_tokens??0,v=a.message.usage.cache_creation_input_tokens??0;break}}if(!I)throw new g("Anthropic stream ended without message_stop; response was truncated");yield{type:"stream_end",stopReason:E,usage:{inputTokens:_,outputTokens:y,cacheReadInputTokens:T,cacheCreationInputTokens:v}}}catch(r){throw oe.error({err:r},"llm operation failed"),ie(r)}}};function se(o){for(let t=o.length-1;t>=0;t--){if(o[t].role!=="user")continue;let e=o[t].content;if(typeof e=="string"&&e.length===0||Array.isArray(e)&&e.length===0)return;typeof e=="string"&&(e=o[t].content=[{type:"text",text:e}]);let n=e[e.length-1];for(let i=e.length-1;i>=0;i--)if(e[i].type!=="image"){n=e[i];break}Reflect.set(n,"cache_control",{type:"ephemeral"});return}}function ie(o){if(o instanceof w.APIError){if(o.status===413||o.status===400&&Y(o.message))return new G(`Prompt too long: ${o.message}`);if(o.status===401)return new P(`Invalid API key: ${o.message}`);if(o.status===429){let t=o.headers,e=t instanceof Headers?t.get("retry-after"):void 0,n="Rate Limited";if(e){let i=Number.parseInt(h(e));Number.isNaN(i)?n+=", please wait.":n+=`, retry after ${h(i)}s.`}else n+=", please wait.";return new z(n,e?h(e):void 0)}return new q(`Anthropic API error (${h(o.status)}): ${o.message}`)}return new g(`Network error: ${$(o)}`)}export{Q as AnthropicClient,ne as buildAnthropicMessages,se as markLastUserTailForCache,Z as markToolsForCache,ee as needsToolSearchBeta};
@@ -1,4 +0,0 @@
1
- #!/usr/bin/env node
2
- import { createRequire as __yukinoCreateRequire } from "node:module";
3
- const require = __yukinoCreateRequire(import.meta.url);
4
- import{isAbsolute as c,resolve as p}from"path";async function x(){return await import("@anthropic-ai/sandbox-runtime")}function m(e,i){return e.map(a=>c(a)?a:p(i,a))}function g(e,i){return{network:{allowedDomains:[],deniedDomains:e.networkEnabled?[]:["*"],strictAllowlist:!e.networkEnabled},filesystem:{denyRead:[],allowWrite:m(e.allowWrite,i),denyWrite:m(e.denyWrite,i),allowGitConfig:!1}}}var b=class{implementation="sandbox-runtime";availabilityError;availabilityPromise;configKey;initializationPromise;runtimePromise;available(){return this.availabilityPromise??=this.checkAvailability()}async prepare(i,a,t){if(!await this.available())throw new Error(this.availabilityError??"sandbox runtime is unavailable");let n=await this.loadRuntime(),r=n.SandboxRuntimeConfigSchema.parse(g(a,t.cwd)),o=JSON.stringify(r);if(this.initializationPromise&&await this.initializationPromise,this.configKey!==o||!n.SandboxManager.isSandboxingEnabled()){this.initializationPromise=(async()=>{n.SandboxManager.isSandboxingEnabled()&&await n.SandboxManager.reset(),await n.SandboxManager.initialize(r,a.networkEnabled?()=>Promise.resolve(!0):void 0),this.configKey=o})();try{await this.initializationPromise}finally{this.initializationPromise=void 0}}let s=t.commandId??i,d=await n.SandboxManager.wrapWithSandboxArgv(i,"/bin/bash",void 0,t.abortSignal,t.cwd,{commandId:s,commandText:i}),[l,...u]=d.argv;if(!l)throw new Error("sandbox runtime returned an empty command");return{executable:l,args:u,env:d.env,annotateStderr:f=>n.SandboxManager.annotateStderrWithSandboxFailures(s,f),cleanup:()=>{n.SandboxManager.cleanupAfterCommand()}}}async dispose(){if(!this.runtimePromise)return;await this.initializationPromise,await(await this.runtimePromise).SandboxManager.reset(),this.configKey=void 0}async checkAvailability(){try{let i=await this.loadRuntime();if(!i.SandboxManager.isSupportedPlatform())return this.availabilityError="sandbox runtime does not support this platform",!1;let a=await i.SandboxManager.checkDependenciesAsync();return a.errors.length>0?(this.availabilityError=a.errors.join("; "),!1):(this.availabilityError=void 0,!0)}catch(i){return this.availabilityError=i instanceof Error?i.message:String(i),!1}}loadRuntime(){return this.runtimePromise??=x()}};export{g as a,b};
@@ -1,4 +0,0 @@
1
- #!/usr/bin/env node
2
- import { createRequire as __yukinoCreateRequire } from "node:module";
3
- const require = __yukinoCreateRequire(import.meta.url);
4
- import{B as P,a as d,d as u,f as C,g as S,i as g,u as v}from"./chunk-NG62ISUV.js";import{D as o}from"./chunk-IW5L5276.js";import{existsSync as E,readFileSync as $}from"fs";import{join as Y}from"path";var m=P({module:"config"}),A={anthropic:"ANTHROPIC_API_KEY",openai:"OPENAI_API_KEY","openai-compat":"OPENAI_API_KEY"};function J(r){return b.has(r)}var b=new Set(Object.keys(A)),a=class extends Error{constructor(n){super(n),this.name="ConfigError"}};function X(r){if(r.api_key)return r.api_key;let n=J(r.protocol)?A[r.protocol]:"";return n?process.env[n]??"":""}var j=o.object({name:o.string(),command:o.string().optional(),args:o.array(o.string()).optional(),url:o.string().optional(),transport:o.string().optional(),headers:o.record(o.string(),o.string()).optional(),env:o.record(o.string(),o.string()).optional()}),I=o.object({id:o.string().optional(),event:o.string(),condition:o.string().optional(),action:o.object({type:o.string(),command:o.string().optional(),url:o.string().optional(),method:o.string().optional(),prompt:o.string().optional()}),reject:o.boolean().optional(),once:o.boolean().optional(),async:o.boolean().optional(),on_error:o.string().optional()}),O=o.object({enabled:o.boolean().optional(),backend:o.enum(["native","sandbox-runtime"]).optional(),auto_allow:o.boolean().optional(),network_enabled:o.boolean().optional()}),K=o.looseObject({default_provider:o.number().default(0),providers:o.array(g),permission_mode:o.string().optional(),mcp_servers:o.array(j).default([]),hooks:o.array(I).default([]),sandbox:O.optional(),enable_coordinator_mode:o.boolean().optional(),enable_fork:o.boolean().optional(),memory:o.boolean().optional()});function Z(r){return r.enable_fork!==!1}function oo(r){return r.memory!==!1}function N(r){return typeof r=="object"&&r!==null}function k(r){let n=$(r,"utf-8"),e=C.load(n);if(!N(e))return m.error({path:r},"invalid yaml"),{default_provider:0,providers:[],mcp_servers:[],hooks:[]};let t=d(K,e);if(t.success){let s=t.data;return{...s,providers:s.providers.map(v)}}m.error({error:t.error},"config error");let i=0,p=[],c,l=[],f=[],_,h=!1,y=!0,w=!0;if("default_provider"in e){let s=d(o.number(),e.default_provider);s.success&&(i=s.data)}if("providers"in e){let s=d(o.array(g),e.providers);if(s.success)p=s.data.map(v);else throw new a(`Invalid provider configuration in ${r}: ${u(s.error)}`)}if("permission_mode"in e&&typeof e.permission_mode=="string"&&(c=e.permission_mode),"mcp_servers"in e){let s=d(o.array(j),e.mcp_servers);if(s.success)l=s.data;else throw new a(`Invalid MCP server configuration in ${r}: ${u(s.error)}`)}if("hooks"in e){let s=d(o.array(I),e.hooks);if(s.success)f=s.data;else throw new a(`Invalid hooks configuration in ${r}: ${u(s.error)}`)}if("sandbox"in e){let s=d(O,e.sandbox);if(s.success)_=s.data;else throw new a(`Invalid sandbox configuration in ${r}: ${u(s.error)}`)}return"enable_coordinator_mode"in e&&(h=!!e.enable_coordinator_mode),"enable_fork"in e&&(y=!!e.enable_fork),"memory"in e&&(w=!!e.memory),{default_provider:i,providers:p,permission_mode:c,mcp_servers:l,hooks:f,sandbox:_,enable_coordinator_mode:h,enable_fork:y,memory:w}}function M(r){if(r.providers.length===0)throw new a("At least one provider MUST be configured.");let n=["name","protocol","base_url","model"],e=new Map;for(let t=0;t<r.providers.length;t++){let i=r.providers[t],p={name:i.name,protocol:i.protocol,base_url:i.base_url,model:i.model},c=n.filter(f=>!p[f].trim());if(c.length>0)throw new a(`Provider #${String(t+1)}: missing fields: ${c.join(", ")}`);if(!b.has(i.protocol))throw new a(`Provider #${String(t+1)}: invalid protocol '${i.protocol}', MUST be one of: ${Array.from(b).join(", ")}`);let l=e.get(i.base_url);if(l!==void 0)throw new a(`Provider #${String(t+1)}: duplicate base_url '${i.base_url}' (already used by provider #${String(l+1)}).`);e.set(i.base_url,t)}}function x(r){let n=new Map;for(let e=0;e<r.mcp_servers.length;e++){let t=r.mcp_servers[e],i=`MCP server #${String(e+1)}`;if(!t.name.trim())throw new a(`${i}: name must not be empty.`);let p=n.get(t.name);if(p!==void 0)throw new a(`${i}: duplicate name '${t.name}' (already used by MCP server #${String(p+1)}).`);n.set(t.name,e);let c=!!t.command?.trim(),l=!!t.url?.trim();if(c===l)throw new a(`${i} '${t.name}': configure exactly one of command or url.`);if(c&&t.transport&&t.transport!=="stdio")throw new a(`${i} '${t.name}': command servers must use stdio.`);if(l&&t.transport&&!["http","sse"].includes(t.transport))throw new a(`${i} '${t.name}': URL transport must be http or sse.`)}}var F=".mcp.json",z=o.looseObject({command:o.string().optional(),args:o.array(o.string()).optional(),env:o.record(o.string(),o.string()).optional(),type:o.enum(["stdio","sse","http"]).optional(),url:o.string().optional(),headers:o.record(o.string(),o.string()).optional()}),L=o.looseObject({mcpServers:o.record(o.string(),o.unknown()).default({})});function R(r,n){let e=n.type??(n.command!==void 0?"stdio":"http");return e==="stdio"?!n.command||n.url!==void 0?null:{name:r,command:n.command,args:n.args,env:n.env}:!n.url||n.command!==void 0?null:{name:r,url:n.url,transport:e,headers:n.headers}}function T(r){let n=Y(r,F);if(!E(n))return[];let e;try{e=JSON.parse($(n,"utf-8"))}catch(p){return m.error({err:p,path:n},"invalid .mcp.json"),[]}let t=d(L,e);if(!t.success)return m.error({error:t.error,path:n},"invalid .mcp.json"),[];let i=[];for(let[p,c]of Object.entries(t.data.mcpServers)){let l=d(z,c);if(!p.trim()||!l.success){m.warn({name:p,path:n,error:l.success?void 0:l.error},"skipping invalid .mcp.json server entry");continue}let f=R(p,l.data);f?i.push(f):m.warn({name:p,path:n},"skipping invalid .mcp.json server entry")}return i}function eo(r,n){let e=T(n);if(e.length===0)return r;let t=new Set(r.mcp_servers.map(i=>i.name));return{...r,mcp_servers:[...r.mcp_servers,...e.filter(i=>!t.has(i.name))]}}function ro(r,n={}){if(r){let i=k(r);return x(i),(!n.allowEmptyProviders||i.providers.length>0)&&M(i),i}let e=S();if(!E(e)){if(n.allowEmptyProviders)return{default_provider:0,providers:[],mcp_servers:[],hooks:[]};throw new a(`No config file found, expected ${e}.`)}let t=k(e);return x(t),(!n.allowEmptyProviders||t.providers.length>0)&&M(t),t}export{X as a,Z as b,oo as c,eo as d,ro as e};