blink 0.1.80 → 0.1.81

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- import{import_websocket as e}from"./wrapper-B4vDwpOq.js";import{createRequire as t}from"node:module";import{createReadStream as n}from"node:fs";import{createRequire as r}from"module";import*as i from"fs/promises";import{z as a}from"zod";import*as o from"node:fs/promises";import{spawn as s}from"child_process";const c=(e,t)=>{let n=typeof e==`string`;typeof e==`string`&&(e=t.encode(e));let r=new Uint8Array(1+e.byteLength);return r[0]=n?0:1,r.set(new Uint8Array(e),1),r},l=(e,t)=>e[0]===0?t.decode(e.subarray(1)):new Uint8Array(e.subarray(1));let u=function(e){return e[e.REQUEST=0]=`REQUEST`,e[e.PROXY_INIT=1]=`PROXY_INIT`,e[e.PROXY_BODY=2]=`PROXY_BODY`,e[e.PROXY_WEBSOCKET_MESSAGE=3]=`PROXY_WEBSOCKET_MESSAGE`,e[e.PROXY_WEBSOCKET_CLOSE=4]=`PROXY_WEBSOCKET_CLOSE`,e}({}),d=function(e){return e[e.RESPONSE=0]=`RESPONSE`,e[e.NOTIFICATION=1]=`NOTIFICATION`,e[e.PROXY_INIT=2]=`PROXY_INIT`,e[e.PROXY_DATA=3]=`PROXY_DATA`,e[e.PROXY_WEBSOCKET_MESSAGE=4]=`PROXY_WEBSOCKET_MESSAGE`,e[e.PROXY_WEBSOCKET_CLOSE=5]=`PROXY_WEBSOCKET_CLOSE`,e}({});const f={[u.REQUEST]:a.string(),[u.PROXY_INIT]:a.object({method:a.string(),headers:a.record(a.string(),a.string()),url:a.string()}),[u.PROXY_BODY]:a.instanceof(Uint8Array),[u.PROXY_WEBSOCKET_MESSAGE]:a.object({type:a.enum([`text`,`binary`]),data:a.instanceof(Uint8Array)}),[u.PROXY_WEBSOCKET_CLOSE]:a.object({code:a.number().optional(),reason:a.string().optional()})};d.RESPONSE,a.string(),d.NOTIFICATION,a.string(),d.PROXY_INIT,a.object({status_code:a.number(),status_message:a.string(),headers:a.record(a.string(),a.string())}),d.PROXY_DATA,a.instanceof(Uint8Array),d.PROXY_WEBSOCKET_MESSAGE,a.instanceof(Uint8Array),d.PROXY_WEBSOCKET_CLOSE,a.object({code:a.number(),reason:a.string()}),u.PROXY_INIT,a.string(),a.record(a.string(),a.string()),a.string();const p={process_execute:a.object({command:a.string(),args:a.array(a.string()),env:a.record(a.string(),a.string()).optional(),cwd:a.string().optional()}),process_send_input:a.object({pid:a.number(),data:a.string()}),process_wait:a.object({pid:a.number(),output_idle_timeout_ms:a.number().optional(),timeout_ms:a.number().optional()}),process_list:a.object({include_dead:a.boolean().optional()}),process_read_plain_output:a.object({pid:a.number(),start_line:a.number().optional(),end_line:a.number().optional()}),process_kill:a.object({pid:a.number(),signal:a.string().optional()}),set_env:a.object({env:a.record(a.string(),a.string())}),read_file:a.object({path:a.string(),line_start:a.number().optional(),line_end:a.number().optional()}),write_file:a.object({path:a.string(),content:a.string(),base64:a.boolean().optional(),mode:a.number().optional()}),read_directory:a.object({path:a.string()}),watch_directory:a.object({path:a.string()}),deploy_static_files:a.object({path:a.string()})},m=a.object({pid:a.number(),command:a.string(),args:a.array(a.string()),title:a.string().optional(),cwd:a.string(),env:a.record(a.string(),a.string()),exit_code:a.number().optional(),exit_signal:a.number().optional(),duration_ms:a.number().optional(),output_total_lines:a.number()});m.extend({ansi_output:a.string(),plain_output:a.object({lines:a.array(a.string()),total_lines:a.number()})}),a.object({pid:a.number()}),a.object({}),a.object({processes:a.array(m)}),a.object({lines:a.array(a.string()),total_lines:a.number(),duration_ms:a.number(),exit_code:a.number().optional(),exit_signal:a.number().optional()}),a.object({}),a.object({}),a.object({total_lines:a.number(),lines_read:a.number(),start_line:a.number(),content:a.string(),mime_type:a.string()}),a.object({}),a.object({entries:a.array(a.object({name:a.string(),type:a.enum([`file`,`directory`,`symlink`])}))}),a.object({}),a.object({deployment_id:a.string()});const h=a.object({type:a.enum([`create`,`update`,`delete`]),path:a.string()}),g=a.object({type:a.enum([`context`,`added`,`deleted`]),content:a.string(),oldLineNumber:a.number().optional(),newLineNumber:a.number().optional()}),_=a.object({oldStart:a.number(),oldLines:a.number(),newStart:a.number(),newLines:a.number(),lines:a.array(g)}),v=a.object({path:a.string(),status:a.enum([`added`,`modified`,`deleted`,`renamed`,`copied`,`untracked`,`ignored`,`unmerged`,`typechange`]),oldPath:a.string().optional(),insertions:a.number(),deletions:a.number(),chunks:a.array(_)}),y=a.object({totalFiles:a.number(),totalInsertions:a.number(),totalDeletions:a.number(),netChange:a.number(),startHash:a.string().optional(),currentHash:a.string().optional(),timespan:a.number(),files:a.array(v)}),b=a.object({path:a.string(),status:a.enum([`added`,`modified`,`deleted`,`renamed`,`copied`,`untracked`,`ignored`,`unmerged`,`typechange`]),staged:a.boolean()}),x=a.object({hash:a.string(),shortHash:a.string(),message:a.string(),author:a.string(),email:a.string(),date:a.date(),timestamp:a.date(),filesChanged:a.number(),insertions:a.number(),deletions:a.number(),commitDiff:a.array(v).optional()});a.object({files:a.array(b),branch:a.string(),ahead:a.number(),behind:a.number(),timestamp:a.date(),sessionDiff:y.optional(),workingDirectoryDiff:y.optional(),newCommits:a.array(x),currentCommit:a.object({hash:a.string(),shortHash:a.string(),message:a.string(),author:a.string(),date:a.date()}).optional(),diffSkipped:a.boolean().optional(),payloadTruncated:a.boolean().optional(),estimatedSizeKB:a.number().optional()}),a.object({debounceDelay:a.number().optional(),gitStatusInterval:a.number().optional(),ignoreDotfiles:a.boolean().optional(),ignored:a.array(a.string()).optional(),watchGit:a.boolean().optional(),includeDiffs:a.boolean().optional(),maxDiffFiles:a.number().optional(),maxPayloadSizeKB:a.number().optional(),truncateLargeDiffs:a.boolean().optional()}),a.object({status:m}),a.object({pid:a.number(),output:a.string()}),a.object({changes:a.array(h)});var S=Object.create,C=Object.defineProperty,w=Object.getOwnPropertyDescriptor,T=Object.getOwnPropertyNames,E=Object.getPrototypeOf,D=Object.prototype.hasOwnProperty,O=(e,t)=>function(){return t||(0,e[T(e)[0]])((t={exports:{}}).exports,t),t.exports},k=(e,t,n,r)=>{if(t&&typeof t==`object`||typeof t==`function`)for(var i=T(t),a=0,o=i.length,s;a<o;a++)s=i[a],!D.call(e,s)&&s!==n&&C(e,s,{get:(e=>t[e]).bind(null,s),enumerable:!(r=w(t,s))||r.enumerable});return e},A=(e,t,n)=>(n=e==null?{}:S(E(e)),k(t||!e||!e.__esModule?C(n,`default`,{value:e,enumerable:!0}):n,e)),j=t(import.meta.url),M=class{listeners=[];get event(){return e=>(this.listeners.push(e),{dispose:()=>{this.listeners=this.listeners.filter(t=>t!==e)}})}emit(e){for(let t=this.listeners.length-1;t>=0;t--)this.listeners[t]?.(e)}dispose(){this.listeners=[]}};let N=function(e){return e[e.DATA=0]=`DATA`,e[e.CLOSE=1]=`CLOSE`,e[e.ERROR=2]=`ERROR`,e}({}),P=function(e){return e[e.NEW=1]=`NEW`,e}({});var F=class{static MAX_POOL_SIZE=100;static COMMON_SIZES=[64,256,1024,4096,16384];static pools=new Map;static{for(let e of this.COMMON_SIZES)this.pools.set(e,[])}static acquire(e){for(let t of this.COMMON_SIZES)if(t>=e){let e=this.pools.get(t);if(e&&e.length>0)return e.pop();break}return new Uint8Array(e)}static release(e){let t=e.length;for(let n of this.COMMON_SIZES)if(n===t){let t=this.pools.get(n);t&&t.length<this.MAX_POOL_SIZE&&t.push(e);break}}},I=class e{static HEADER_SIZE=4;static MAX_FRAME_SIZE=1024*1024-e.HEADER_SIZE;static encode(e){let t=e.payload.length;if(t>this.MAX_FRAME_SIZE)throw Error(`Frame payload too large: ${t} > ${this.MAX_FRAME_SIZE}`);let n=this.HEADER_SIZE+t,r=F.acquire(n),i=e.streamId<<8|e.type<<4|e.flags&15;return r[0]=i>>>24&255,r[1]=i>>>16&255,r[2]=i>>>8&255,r[3]=i&255,t>0&&r.set(e.payload,this.HEADER_SIZE),r.length===n?r:r.subarray(0,n)}static encodeTyped(t,n,r,i,a){let o=1+a.length;if(o>this.MAX_FRAME_SIZE)throw Error(`Frame payload too large: ${o} > ${this.MAX_FRAME_SIZE}`);let s=this.HEADER_SIZE+o,c=F.acquire(s),l=t<<8|n<<4|r&15;return c[0]=l>>>24&255,c[1]=l>>>16&255,c[2]=l>>>8&255,c[3]=l&255,c[e.HEADER_SIZE]=i&255,a.length>0&&c.set(a,e.HEADER_SIZE+1),c.length===s?c:c.subarray(0,s)}static decode(t){if(t.length<e.HEADER_SIZE)throw Error(`Invalid frame: too short (${t.length} < ${e.HEADER_SIZE})`);let n=t[0]<<24|t[1]<<16|t[2]<<8|t[3],r=n>>>8,i=n&255,a=i>>>4,o=i&15,s=t.length>e.HEADER_SIZE?t.subarray(e.HEADER_SIZE):new Uint8Array;return{streamId:r,type:a,flags:o,payload:s}}static releaseBuffer(e){F.release(e)}static getMaxPayloadSize(){return e.MAX_FRAME_SIZE}},ee=class{_onData;_onClose;_onError;_disposed=!1;_id;constructor(e,t,n){this.send=t,this.sendTypedCb=n,this._id=e}get id(){return this._id}get onData(){return this._onData||(this._onData=new M),this._onData.event}get onClose(){return this._onClose||(this._onClose=new M),this._onClose.event}get onError(){return this._onError||(this._onError=new M),this._onError.event}write(e,t=!1){if(this._disposed)throw Error(`Cannot write to disposed stream ${this.id}`);let n=I.getMaxPayloadSize();if(e.length<=n){this.send({streamId:this.id,type:N.DATA,flags:t?P.NEW:0,payload:e});return}let r=0,i=!0;for(;r<e.length;){let a=e.length-r,o=a>n?n:a,s=e.subarray(r,r+o);this.send({streamId:this.id,type:N.DATA,flags:t&&i?P.NEW:0,payload:s}),r+=o,i=!1}}writeTyped(e,t,n=!1){if(this._disposed)throw Error(`Cannot write to disposed stream ${this.id}`);if(!this.sendTypedCb){let r=new Uint8Array(1+t.length);r[0]=e&255,t.length&&r.set(t,1),this.write(r,n);return}let r=I.getMaxPayloadSize()-1;if(t.length<=r){this.sendTypedCb(this.id,n?P.NEW:0,e,t);return}let i=0,a=!0;for(;i<t.length;){let o=t.length-i,s=o>r?r:o,c=t.subarray(i,i+s);this.sendTypedCb(this.id,n&&a?P.NEW:0,e,c),i+=s,a=!1}}close(){this._disposed||(this.send({streamId:this.id,type:N.CLOSE,flags:0,payload:new Uint8Array}),this._dispose())}error(e){this._disposed||this.send({streamId:this.id,type:N.ERROR,flags:0,payload:new TextEncoder().encode(e)})}_handleFrame(e){if(!this._disposed)switch(e.type){case N.DATA:this._onData?.emit(e.payload);break;case N.CLOSE:this._onClose?.emit(),this._dispose();break;case N.ERROR:let t=new TextDecoder().decode(e.payload);this._onError?.emit(t),this._dispose();break}}_dispose(){this._disposed||(this._disposed=!0,this._onData?.dispose(),this._onClose?.dispose(),this._onError?.dispose(),this._onData=void 0,this._onClose=void 0,this._onError=void 0)}_reset(e,t,n){this._dispose(),this._id=e,this.send=t,this.sendTypedCb=n,this._disposed=!1}get createdByClient(){return this.id%2==1}get disposed(){return this._disposed}},L=class{static MAX_POOL_SIZE=200;static pool=[];static acquire(e,t,n){let r=this.pool.pop();return r?(r._reset(e,t,n),r):new ee(e,t,n)}static release(e){this.pool.length<this.MAX_POOL_SIZE&&this.pool.push(e)}},R=class{_onNextStreamIDChange=new M;onNextStreamIDChange=this._onNextStreamIDChange.event;_onStream=new M;onStream=this._onStream.event;streams=[];streamCount=0;nextStreamId=1;send;releaseAfterSend;constructor(e){this.nextStreamId=e.initialNextStreamID??(e.isClient?1:2),this.send=e.send,this.releaseAfterSend=!!e.releaseAfterSend}getStream(e){return this.streams[e]}createStream(e){e===void 0&&(e=this.nextStreamId,this.nextStreamId+=2,this._onNextStreamIDChange.emit(this.nextStreamId));let t=this.streams[e];if(t&&!t.disposed)throw Error(`Stream ${e} already exists`);let n=L.acquire(e,e=>this.sendFrame(e),(e,t,n,r)=>this.sendFrameTyped(e,n,t,r));return this.streams[e]=n,this.streamCount++,n}sendFrame(e){let t=I.encode(e);try{this.send(t)}finally{this.releaseAfterSend&&I.releaseBuffer(t)}}sendFrameTyped(e,t,n,r){let i=I.encodeTyped(e,N.DATA,n,t,r);try{this.send(i)}finally{this.releaseAfterSend&&I.releaseBuffer(i)}}handleMessage(e){this.handleFrame(I.decode(e))}handleFrame(e){let t=this.streams[e.streamId];(!t||t.disposed)&&(t=L.acquire(e.streamId,e=>this.sendFrame(e),(e,t,n,r)=>this.sendFrameTyped(e,n,t,r)),this.streams[e.streamId]=t,this.streamCount++,this._onStream.emit(t)),t._handleFrame(e),(e.type===N.CLOSE||e.type===N.ERROR)&&(this.streams[e.streamId]=void 0,this.streamCount--,L.release(t))}get activeStreamCount(){return this.streamCount}dispose(){for(let e of this.streams)e&&!e.disposed&&(e.close(),L.release(e));this.streams.length=0,this.streamCount=0,this._onNextStreamIDChange.dispose(),this._onStream.dispose()}},z=class extends Error{constructor(){super(`End-Of-Stream`),this.name=`EndOfStreamError`}},te=class extends Error{constructor(e=`The operation was aborted`){super(e),this.name=`AbortError`}},B=class{constructor(){this.endOfStream=!1,this.interrupted=!1,this.peekQueue=[]}async peek(e,t=!1){let n=await this.read(e,t);return this.peekQueue.push(e.subarray(0,n)),n}async read(e,t=!1){if(e.length===0)return 0;let n=this.readFromPeekBuffer(e);if(this.endOfStream||(n+=await this.readRemainderFromStream(e.subarray(n),t)),n===0&&!t)throw new z;return n}readFromPeekBuffer(e){let t=e.length,n=0;for(;this.peekQueue.length>0&&t>0;){let r=this.peekQueue.pop();if(!r)throw Error(`peekData should be defined`);let i=Math.min(r.length,t);e.set(r.subarray(0,i),n),n+=i,t-=i,i<r.length&&this.peekQueue.push(r.subarray(i))}return n}async readRemainderFromStream(e,t){let n=0;for(;n<e.length&&!this.endOfStream;){if(this.interrupted)throw new te;let r=await this.readFromStream(e.subarray(n),t);if(r===0)break;n+=r}if(!t&&n<e.length)throw new z;return n}},ne=class extends B{constructor(e){super(),this.reader=e}async abort(){return this.close()}async close(){this.reader.releaseLock()}},re=class extends ne{async readFromStream(e,t){if(e.length===0)return 0;let n=await this.reader.read(new Uint8Array(e.length),{min:t?void 0:e.length});return n.done&&(this.endOfStream=n.done),n.value?(e.set(n.value),n.value.length):0}},ie=class extends B{constructor(e){super(),this.reader=e,this.buffer=null}writeChunk(e,t){let n=Math.min(t.length,e.length);return e.set(t.subarray(0,n)),n<t.length?this.buffer=t.subarray(n):this.buffer=null,n}async readFromStream(e,t){if(e.length===0)return 0;let n=0;for(this.buffer&&(n+=this.writeChunk(e,this.buffer));n<e.length&&!this.endOfStream;){let t=await this.reader.read();if(t.done){this.endOfStream=!0;break}t.value&&(n+=this.writeChunk(e.subarray(n),t.value))}if(!t&&n===0&&this.endOfStream)throw new z;return n}abort(){return this.interrupted=!0,this.reader.cancel()}async close(){await this.abort(),this.reader.releaseLock()}};function ae(e){try{let t=e.getReader({mode:`byob`});return t instanceof ReadableStreamDefaultReader?new ie(t):new re(t)}catch(t){if(t instanceof TypeError)return new ie(e.getReader());throw t}}var oe=class{constructor(e){this.numBuffer=new Uint8Array(8),this.position=0,this.onClose=e?.onClose,e?.abortSignal&&e.abortSignal.addEventListener(`abort`,()=>{this.abort()})}async readToken(e,t=this.position){let n=new Uint8Array(e.len),r=await this.readBuffer(n,{position:t});if(r<e.len)throw new z;return e.get(n,0)}async peekToken(e,t=this.position){let n=new Uint8Array(e.len),r=await this.peekBuffer(n,{position:t});if(r<e.len)throw new z;return e.get(n,0)}async readNumber(e){let t=await this.readBuffer(this.numBuffer,{length:e.len});if(t<e.len)throw new z;return e.get(this.numBuffer,0)}async peekNumber(e){let t=await this.peekBuffer(this.numBuffer,{length:e.len});if(t<e.len)throw new z;return e.get(this.numBuffer,0)}async ignore(e){if(this.fileInfo.size!==void 0){let t=this.fileInfo.size-this.position;if(e>t)return this.position+=t,t}return this.position+=e,e}async close(){await this.abort(),await this.onClose?.()}normalizeOptions(e,t){if(!this.supportsRandomAccess()&&t&&t.position!==void 0&&t.position<this.position)throw Error("`options.position` must be equal or greater than `tokenizer.position`");return{mayBeLess:!1,offset:0,length:e.length,position:this.position,...t}}abort(){return Promise.resolve()}},se=class extends oe{constructor(e,t){super(t),this.streamReader=e,this.fileInfo=t?.fileInfo??{}}async readBuffer(e,t){let n=this.normalizeOptions(e,t),r=n.position-this.position;if(r>0)return await this.ignore(r),this.readBuffer(e,t);if(r<0)throw Error("`options.position` must be equal or greater than `tokenizer.position`");if(n.length===0)return 0;let i=await this.streamReader.read(e.subarray(0,n.length),n.mayBeLess);if(this.position+=i,(!t||!t.mayBeLess)&&i<n.length)throw new z;return i}async peekBuffer(e,t){let n=this.normalizeOptions(e,t),r=0;if(n.position){let t=n.position-this.position;if(t>0){let i=new Uint8Array(n.length+t);return r=await this.peekBuffer(i,{mayBeLess:n.mayBeLess}),e.set(i.subarray(t)),r-t}if(t<0)throw Error(`Cannot peek from a negative offset in a stream`)}if(n.length>0){try{r=await this.streamReader.peek(e.subarray(0,n.length),n.mayBeLess)}catch(e){if(t?.mayBeLess&&e instanceof z)return 0;throw e}if(!n.mayBeLess&&r<n.length)throw new z}return r}async ignore(e){let t=Math.min(256e3,e),n=new Uint8Array(t),r=0;for(;r<e;){let i=e-r,a=await this.readBuffer(n,{length:Math.min(t,i)});if(a<0)return a;r+=a}return r}abort(){return this.streamReader.abort()}async close(){return this.streamReader.close()}supportsRandomAccess(){return!1}},ce=class extends oe{constructor(e,t){super(t),this.uint8Array=e,this.fileInfo={...t?.fileInfo??{},size:e.length}}async readBuffer(e,t){t?.position&&(this.position=t.position);let n=await this.peekBuffer(e,t);return this.position+=n,n}async peekBuffer(e,t){let n=this.normalizeOptions(e,t),r=Math.min(this.uint8Array.length-n.position,n.length);if(!n.mayBeLess&&r<n.length)throw new z;return e.set(this.uint8Array.subarray(n.position,n.position+r)),r}close(){return super.close()}supportsRandomAccess(){return!0}setPosition(e){this.position=e}};function le(e,t){let n=ae(e),r=t??{},i=r.onClose;return r.onClose=async()=>{if(await n.close(),i)return i()},new se(n,r)}function ue(e,t){return new ce(e,t)}const de={128:`€`,130:`‚`,131:`ƒ`,132:`„`,133:`…`,134:`†`,135:`‡`,136:`ˆ`,137:`‰`,138:`Š`,139:`‹`,140:`Œ`,142:`Ž`,145:`‘`,146:`’`,147:`“`,148:`”`,149:`•`,150:`–`,151:`—`,152:`˜`,153:`™`,154:`š`,155:`›`,156:`œ`,158:`ž`,159:`Ÿ`},fe={};for(let[e,t]of Object.entries(de))fe[t]=Number.parseInt(e);function pe(e,t=`utf-8`){switch(t.toLowerCase()){case`utf-8`:case`utf8`:return globalThis.TextDecoder===void 0?me(e):new globalThis.TextDecoder(`utf-8`).decode(e);case`utf-16le`:return he(e);case`ascii`:return ge(e);case`latin1`:case`iso-8859-1`:return _e(e);case`windows-1252`:return ve(e);default:throw RangeError(`Encoding '${t}' not supported`)}}function me(e){let t=``,n=0;for(;n<e.length;){let r=e[n++];if(r<128)t+=String.fromCharCode(r);else if(r<224){let i=e[n++]&63;t+=String.fromCharCode((r&31)<<6|i)}else if(r<240){let i=e[n++]&63,a=e[n++]&63;t+=String.fromCharCode((r&15)<<12|i<<6|a)}else{let i=e[n++]&63,a=e[n++]&63,o=e[n++]&63,s=(r&7)<<18|i<<12|a<<6|o;s-=65536,t+=String.fromCharCode(55296+(s>>10&1023),56320+(s&1023))}}return t}function he(e){let t=``;for(let n=0;n<e.length;n+=2)t+=String.fromCharCode(e[n]|e[n+1]<<8);return t}function ge(e){return String.fromCharCode(...e.map(e=>e&127))}function _e(e){return String.fromCharCode(...e)}function ve(e){let t=``;for(let n of e)n>=128&&n<=159&&de[n]?t+=de[n]:t+=String.fromCharCode(n);return t}function V(e){return new DataView(e.buffer,e.byteOffset)}const ye={len:1,get(e,t){return V(e).getUint8(t)},put(e,t,n){return V(e).setUint8(t,n),t+1}},H={len:2,get(e,t){return V(e).getUint16(t,!0)},put(e,t,n){return V(e).setUint16(t,n,!0),t+2}},U={len:2,get(e,t){return V(e).getUint16(t)},put(e,t,n){return V(e).setUint16(t,n),t+2}},W={len:4,get(e,t){return V(e).getUint32(t,!0)},put(e,t,n){return V(e).setUint32(t,n,!0),t+4}},be={len:4,get(e,t){return V(e).getUint32(t)},put(e,t,n){return V(e).setUint32(t,n),t+4}},xe={len:4,get(e,t){return V(e).getInt32(t)},put(e,t,n){return V(e).setInt32(t,n),t+4}},Se={len:8,get(e,t){return V(e).getBigUint64(t,!0)},put(e,t,n){return V(e).setBigUint64(t,n,!0),t+8}};var G=class{constructor(e,t){this.len=e,this.encoding=t}get(e,t=0){let n=e.subarray(t,t+this.len);return pe(n,this.encoding)}},Ce=r(`/`),we;try{we=Ce(`worker_threads`).Worker}catch(e){}var K=Uint8Array,q=Uint16Array,Te=Int32Array,Ee=new K([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),De=new K([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),Oe=new K([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),ke=function(e,t){for(var n=new q(31),r=0;r<31;++r)n[r]=t+=1<<e[r-1];for(var i=new Te(n[30]),r=1;r<30;++r)for(var a=n[r];a<n[r+1];++a)i[a]=a-n[r]<<5|r;return{b:n,r:i}},Ae=ke(Ee,2),je=Ae.b,Me=Ae.r;je[28]=258,Me[258]=28;var Ne=ke(De,0),Pe=Ne.b;Ne.r;for(var Fe=new q(32768),J=0;J<32768;++J){var Y=(J&43690)>>1|(J&21845)<<1;Y=(Y&52428)>>2|(Y&13107)<<2,Y=(Y&61680)>>4|(Y&3855)<<4,Fe[J]=((Y&65280)>>8|(Y&255)<<8)>>1}for(var Ie=(function(e,t,n){for(var r=e.length,i=0,a=new q(t);i<r;++i)e[i]&&++a[e[i]-1];var o=new q(t);for(i=1;i<t;++i)o[i]=o[i-1]+a[i-1]<<1;var s;if(n){s=new q(1<<t);var c=15-t;for(i=0;i<r;++i)if(e[i])for(var l=i<<4|e[i],u=t-e[i],d=o[e[i]-1]++<<u,f=d|(1<<u)-1;d<=f;++d)s[Fe[d]>>c]=l}else for(s=new q(r),i=0;i<r;++i)e[i]&&(s[i]=Fe[o[e[i]-1]++]>>15-e[i]);return s}),Le=new K(288),J=0;J<144;++J)Le[J]=8;for(var J=144;J<256;++J)Le[J]=9;for(var J=256;J<280;++J)Le[J]=7;for(var J=280;J<288;++J)Le[J]=8;for(var Re=new K(32),J=0;J<32;++J)Re[J]=5;var ze=Ie(Le,9,1),Be=Ie(Re,5,1),Ve=function(e){for(var t=e[0],n=1;n<e.length;++n)e[n]>t&&(t=e[n]);return t},X=function(e,t,n){var r=t/8|0;return(e[r]|e[r+1]<<8)>>(t&7)&n},He=function(e,t){var n=t/8|0;return(e[n]|e[n+1]<<8|e[n+2]<<16)>>(t&7)},Ue=function(e){return(e+7)/8|0},We=function(e,t,n){return(t==null||t<0)&&(t=0),(n==null||n>e.length)&&(n=e.length),new K(e.subarray(t,n))},Ge=[`unexpected EOF`,`invalid block type`,`invalid length/literal`,`invalid distance`,`stream finished`,`no stream handler`,,`no callback`,`invalid UTF-8 data`,`extra field too long`,`date not in range 1980-2099`,`filename too long`,`stream finishing`,`invalid zip data`],Z=function(e,t,n){var r=Error(t||Ge[e]);if(r.code=e,Error.captureStackTrace&&Error.captureStackTrace(r,Z),!n)throw r;return r},Ke=function(e,t,n,r){var i=e.length,a=r?r.length:0;if(!i||t.f&&!t.l)return n||new K(0);var o=!n,s=o||t.i!=2,c=t.i;o&&(n=new K(i*3));var l=function(e){var t=n.length;if(e>t){var r=new K(Math.max(t*2,e));r.set(n),n=r}},u=t.f||0,d=t.p||0,f=t.b||0,p=t.l,m=t.d,h=t.m,g=t.n,_=i*8;do{if(!p){u=X(e,d,1);var v=X(e,d+1,3);if(d+=3,v)if(v==1)p=ze,m=Be,h=9,g=5;else if(v==2){var y=X(e,d,31)+257,b=X(e,d+10,15)+4,x=y+X(e,d+5,31)+1;d+=14;for(var S=new K(x),C=new K(19),w=0;w<b;++w)C[Oe[w]]=X(e,d+w*3,7);d+=b*3;for(var T=Ve(C),E=(1<<T)-1,D=Ie(C,T,1),w=0;w<x;){var O=D[X(e,d,E)];d+=O&15;var k=O>>4;if(k<16)S[w++]=k;else{var A=0,j=0;for(k==16?(j=3+X(e,d,3),d+=2,A=S[w-1]):k==17?(j=3+X(e,d,7),d+=3):k==18&&(j=11+X(e,d,127),d+=7);j--;)S[w++]=A}}var M=S.subarray(0,y),N=S.subarray(y);h=Ve(M),g=Ve(N),p=Ie(M,h,1),m=Ie(N,g,1)}else Z(1);else{var k=Ue(d)+4,P=e[k-4]|e[k-3]<<8,F=k+P;if(F>i){c&&Z(0);break}s&&l(f+P),n.set(e.subarray(k,F),f),t.b=f+=P,t.p=d=F*8,t.f=u;continue}if(d>_){c&&Z(0);break}}s&&l(f+131072);for(var I=(1<<h)-1,ee=(1<<g)-1,L=d;;L=d){var A=p[He(e,d)&I],R=A>>4;if(d+=A&15,d>_){c&&Z(0);break}if(A||Z(2),R<256)n[f++]=R;else if(R==256){L=d,p=null;break}else{var z=R-254;if(R>264){var w=R-257,te=Ee[w];z=X(e,d,(1<<te)-1)+je[w],d+=te}var B=m[He(e,d)&ee],ne=B>>4;B||Z(3),d+=B&15;var N=Pe[ne];if(ne>3){var te=De[ne];N+=He(e,d)&(1<<te)-1,d+=te}if(d>_){c&&Z(0);break}s&&l(f+131072);var re=f+z;if(f<N){var ie=a-N,ae=Math.min(N,re);for(ie+f<0&&Z(3);f<ae;++f)n[f]=r[ie+f]}for(;f<re;++f)n[f]=n[f-N]}}t.l=p,t.p=L,t.b=f,t.f=u,p&&(u=1,t.m=h,t.d=m,t.n=g)}while(!u);return f!=n.length&&o?We(n,0,f):n.subarray(0,f)},qe=new K(0),Je=function(e){(e[0]!=31||e[1]!=139||e[2]!=8)&&Z(6,`invalid gzip data`);var t=e[3],n=10;t&4&&(n+=(e[10]|e[11]<<8)+2);for(var r=(t>>3&1)+(t>>4&1);r>0;r-=!e[n++]);return n+(t&2)},Ye=function(e){var t=e.length;return(e[t-4]|e[t-3]<<8|e[t-2]<<16|e[t-1]<<24)>>>0},Xe=function(e,t){return((e[0]&15)!=8||e[0]>>4>7||(e[0]<<8|e[1])%31)&&Z(6,`invalid zlib data`),(e[1]>>5&1)==+!t&&Z(6,`invalid zlib data: `+(e[1]&32?`need`:`unexpected`)+` dictionary`),(e[1]>>3&4)+2};function Ze(e,t){return Ke(e,{i:2},t&&t.out,t&&t.dictionary)}function Qe(e,t){var n=Je(e);return n+8>e.length&&Z(6,`invalid gzip data`),Ke(e.subarray(n,-8),{i:2},t&&t.out||new K(Ye(e)),t&&t.dictionary)}function $e(e,t){return Ke(e.subarray(Xe(e,t&&t.dictionary),-4),{i:2},t&&t.out,t&&t.dictionary)}function et(e,t){return e[0]==31&&e[1]==139&&e[2]==8?Qe(e,t):(e[0]&15)!=8||e[0]>>4>7||(e[0]<<8|e[1])%31?Ze(e,t):$e(e,t)}var tt=typeof TextDecoder<`u`&&new TextDecoder,nt=0;try{tt.decode(qe,{stream:!0}),nt=1}catch(e){}var rt=O({"../../node_modules/ms/index.js":((exports,t)=>{var n=1e3,r=n*60,i=r*60,a=i*24,o=a*7,s=a*365.25;t.exports=function(e,t){t=t||{};var n=typeof e;if(n===`string`&&e.length>0)return c(e);if(n===`number`&&isFinite(e))return t.long?u(e):l(e);throw Error(`val is not a non-empty string or a valid number. val=`+JSON.stringify(e))};function c(e){if(e=String(e),!(e.length>100)){var t=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(e);if(t){var c=parseFloat(t[1]),l=(t[2]||`ms`).toLowerCase();switch(l){case`years`:case`year`:case`yrs`:case`yr`:case`y`:return c*s;case`weeks`:case`week`:case`w`:return c*o;case`days`:case`day`:case`d`:return c*a;case`hours`:case`hour`:case`hrs`:case`hr`:case`h`:return c*i;case`minutes`:case`minute`:case`mins`:case`min`:case`m`:return c*r;case`seconds`:case`second`:case`secs`:case`sec`:case`s`:return c*n;case`milliseconds`:case`millisecond`:case`msecs`:case`msec`:case`ms`:return c;default:return}}}}function l(e){var t=Math.abs(e);return t>=a?Math.round(e/a)+`d`:t>=i?Math.round(e/i)+`h`:t>=r?Math.round(e/r)+`m`:t>=n?Math.round(e/n)+`s`:e+`ms`}function u(e){var t=Math.abs(e);return t>=a?d(e,t,a,`day`):t>=i?d(e,t,i,`hour`):t>=r?d(e,t,r,`minute`):t>=n?d(e,t,n,`second`):e+` ms`}function d(e,t,n,r){var i=t>=n*1.5;return Math.round(e/n)+` `+r+(i?`s`:``)}})}),it=O({"../../node_modules/@tokenizer/inflate/node_modules/debug/src/common.js":((exports,t)=>{function n(e){n.debug=n,n.default=n,n.coerce=c,n.disable=o,n.enable=i,n.enabled=s,n.humanize=rt(),n.destroy=l,Object.keys(e).forEach(t=>{n[t]=e[t]}),n.names=[],n.skips=[],n.formatters={};function t(e){let t=0;for(let n=0;n<e.length;n++)t=(t<<5)-t+e.charCodeAt(n),t|=0;return n.colors[Math.abs(t)%n.colors.length]}n.selectColor=t;function n(e){let t,i=null,a,o;function s(...e){if(!s.enabled)return;let r=s,i=Number(new Date),a=i-(t||i);r.diff=a,r.prev=t,r.curr=i,t=i,e[0]=n.coerce(e[0]),typeof e[0]!=`string`&&e.unshift(`%O`);let o=0;e[0]=e[0].replace(/%([a-zA-Z%])/g,(t,i)=>{if(t===`%%`)return`%`;o++;let a=n.formatters[i];if(typeof a==`function`){let n=e[o];t=a.call(r,n),e.splice(o,1),o--}return t}),n.formatArgs.call(r,e);let c=r.log||n.log;c.apply(r,e)}return s.namespace=e,s.useColors=n.useColors(),s.color=n.selectColor(e),s.extend=r,s.destroy=n.destroy,Object.defineProperty(s,`enabled`,{enumerable:!0,configurable:!1,get:()=>i===null?(a!==n.namespaces&&(a=n.namespaces,o=n.enabled(e)),o):i,set:e=>{i=e}}),typeof n.init==`function`&&n.init(s),s}function r(e,t){let r=n(this.namespace+(t===void 0?`:`:t)+e);return r.log=this.log,r}function i(e){n.save(e),n.namespaces=e,n.names=[],n.skips=[];let t=(typeof e==`string`?e:``).trim().replace(/\s+/g,`,`).split(`,`).filter(Boolean);for(let e of t)e[0]===`-`?n.skips.push(e.slice(1)):n.names.push(e)}function a(e,t){let n=0,r=0,i=-1,a=0;for(;n<e.length;)if(r<t.length&&(t[r]===e[n]||t[r]===`*`))t[r]===`*`?(i=r,a=n,r++):(n++,r++);else if(i!==-1)r=i+1,a++,n=a;else return!1;for(;r<t.length&&t[r]===`*`;)r++;return r===t.length}function o(){let e=[...n.names,...n.skips.map(e=>`-`+e)].join(`,`);return n.enable(``),e}function s(e){for(let t of n.skips)if(a(e,t))return!1;for(let t of n.names)if(a(e,t))return!0;return!1}function c(e){return e instanceof Error?e.stack||e.message:e}function l(){console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")}return n.enable(n.load()),n}t.exports=n})}),at=O({"../../node_modules/@tokenizer/inflate/node_modules/debug/src/browser.js":((exports,t)=>{exports.formatArgs=r,exports.save=i,exports.load=a,exports.useColors=n,exports.storage=o(),exports.destroy=(()=>{let e=!1;return()=>{e||(e=!0,console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."))}})(),exports.colors=`#0000CC.#0000FF.#0033CC.#0033FF.#0066CC.#0066FF.#0099CC.#0099FF.#00CC00.#00CC33.#00CC66.#00CC99.#00CCCC.#00CCFF.#3300CC.#3300FF.#3333CC.#3333FF.#3366CC.#3366FF.#3399CC.#3399FF.#33CC00.#33CC33.#33CC66.#33CC99.#33CCCC.#33CCFF.#6600CC.#6600FF.#6633CC.#6633FF.#66CC00.#66CC33.#9900CC.#9900FF.#9933CC.#9933FF.#99CC00.#99CC33.#CC0000.#CC0033.#CC0066.#CC0099.#CC00CC.#CC00FF.#CC3300.#CC3333.#CC3366.#CC3399.#CC33CC.#CC33FF.#CC6600.#CC6633.#CC9900.#CC9933.#CCCC00.#CCCC33.#FF0000.#FF0033.#FF0066.#FF0099.#FF00CC.#FF00FF.#FF3300.#FF3333.#FF3366.#FF3399.#FF33CC.#FF33FF.#FF6600.#FF6633.#FF9900.#FF9933.#FFCC00.#FFCC33`.split(`.`);function n(){if(typeof window<`u`&&window.process&&(window.process.type===`renderer`||window.process.__nwjs))return!0;if(typeof navigator<`u`&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))return!1;let e;return typeof document<`u`&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||typeof window<`u`&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||typeof navigator<`u`&&navigator.userAgent&&(e=navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/))&&parseInt(e[1],10)>=31||typeof navigator<`u`&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)}function r(e){if(e[0]=(this.useColors?`%c`:``)+this.namespace+(this.useColors?` %c`:` `)+e[0]+(this.useColors?`%c `:` `)+`+`+t.exports.humanize(this.diff),!this.useColors)return;let n=`color: `+this.color;e.splice(1,0,n,`color: inherit`);let r=0,i=0;e[0].replace(/%[a-zA-Z%]/g,e=>{e!==`%%`&&(r++,e===`%c`&&(i=r))}),e.splice(i,0,n)}exports.log=console.debug||console.log||(()=>{});function i(t){try{t?exports.storage.setItem(`debug`,t):exports.storage.removeItem(`debug`)}catch(e){}}function a(){let t;try{t=exports.storage.getItem(`debug`)||exports.storage.getItem(`DEBUG`)}catch(e){}return!t&&typeof process<`u`&&`env`in process&&(t=process.env.DEBUG),t}function o(){try{return localStorage}catch(e){}}t.exports=it()(exports);let{formatters:s}=t.exports;s.j=function(e){try{return JSON.stringify(e)}catch(e){return`[UnexpectedJSONParseError]: `+e.message}}})}),ot=O({"../../node_modules/has-flag/index.js":((exports,t)=>{t.exports=(e,t=process.argv)=>{let n=e.startsWith(`-`)?``:e.length===1?`-`:`--`,r=t.indexOf(n+e),i=t.indexOf(`--`);return r!==-1&&(i===-1||r<i)}})}),st=O({"../../node_modules/supports-color/index.js":((exports,t)=>{let n=j(`os`),r=j(`tty`),i=ot(),{env:a}=process,o;i(`no-color`)||i(`no-colors`)||i(`color=false`)||i(`color=never`)?o=0:(i(`color`)||i(`colors`)||i(`color=true`)||i(`color=always`))&&(o=1),`FORCE_COLOR`in a&&(o=a.FORCE_COLOR===`true`?1:a.FORCE_COLOR===`false`?0:a.FORCE_COLOR.length===0?1:Math.min(parseInt(a.FORCE_COLOR,10),3));function s(e){return e===0?!1:{level:e,hasBasic:!0,has256:e>=2,has16m:e>=3}}function c(e,t){if(o===0)return 0;if(i(`color=16m`)||i(`color=full`)||i(`color=truecolor`))return 3;if(i(`color=256`))return 2;if(e&&!t&&o===void 0)return 0;let r=o||0;if(a.TERM===`dumb`)return r;if(process.platform===`win32`){let e=n.release().split(`.`);return Number(e[0])>=10&&Number(e[2])>=10586?Number(e[2])>=14931?3:2:1}if(`CI`in a)return[`TRAVIS`,`CIRCLECI`,`APPVEYOR`,`GITLAB_CI`,`GITHUB_ACTIONS`,`BUILDKITE`].some(e=>e in a)||a.CI_NAME===`codeship`?1:r;if(`TEAMCITY_VERSION`in a)return/^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(a.TEAMCITY_VERSION)?1:0;if(a.COLORTERM===`truecolor`)return 3;if(`TERM_PROGRAM`in a){let e=parseInt((a.TERM_PROGRAM_VERSION||``).split(`.`)[0],10);switch(a.TERM_PROGRAM){case`iTerm.app`:return e>=3?3:2;case`Apple_Terminal`:return 2}}return/-256(color)?$/i.test(a.TERM)?2:/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(a.TERM)||`COLORTERM`in a?1:r}function l(e){let t=c(e,e&&e.isTTY);return s(t)}t.exports={supportsColor:l,stdout:s(c(!0,r.isatty(1))),stderr:s(c(!0,r.isatty(2)))}})}),ct=O({"../../node_modules/@tokenizer/inflate/node_modules/debug/src/node.js":((exports,t)=>{let n=j(`tty`),r=j(`util`);exports.init=u,exports.log=s,exports.formatArgs=a,exports.save=c,exports.load=l,exports.useColors=i,exports.destroy=r.deprecate(()=>{},"Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."),exports.colors=[6,2,3,4,5,1];try{let t=st();t&&(t.stderr||t).level>=2&&(exports.colors=[20,21,26,27,32,33,38,39,40,41,42,43,44,45,56,57,62,63,68,69,74,75,76,77,78,79,80,81,92,93,98,99,112,113,128,129,134,135,148,149,160,161,162,163,164,165,166,167,168,169,170,171,172,173,178,179,184,185,196,197,198,199,200,201,202,203,204,205,206,207,208,209,214,215,220,221])}catch(e){}exports.inspectOpts=Object.keys(process.env).filter(e=>/^debug_/i.test(e)).reduce((e,t)=>{let n=t.substring(6).toLowerCase().replace(/_([a-z])/g,(e,t)=>t.toUpperCase()),r=process.env[t];return r=/^(yes|on|true|enabled)$/i.test(r)?!0:/^(no|off|false|disabled)$/i.test(r)?!1:r===`null`?null:Number(r),e[n]=r,e},{});function i(){return`colors`in exports.inspectOpts?!!exports.inspectOpts.colors:n.isatty(process.stderr.fd)}function a(e){let{namespace:n,useColors:r}=this;if(r){let r=this.color,i=`\x1B[3`+(r<8?r:`8;5;`+r),a=` ${i};1m${n} \u001B[0m`;e[0]=a+e[0].split(`
1
+ import{import_websocket as e}from"./wrapper-B4vDwpOq.js";import{createRequire as t}from"node:module";import{createReadStream as n}from"node:fs";import{createRequire as r}from"module";import*as i from"fs/promises";import{z as a}from"zod";import*as o from"node:fs/promises";import{spawn as s}from"child_process";const c=(e,t)=>{let n=typeof e==`string`;typeof e==`string`&&(e=t.encode(e));let r=new Uint8Array(1+e.byteLength);return r[0]=n?0:1,r.set(new Uint8Array(e),1),r},l=(e,t)=>e[0]===0?t.decode(e.subarray(1)):new Uint8Array(e.subarray(1));let u=function(e){return e[e.REQUEST=0]=`REQUEST`,e[e.PROXY_INIT=1]=`PROXY_INIT`,e[e.PROXY_BODY=2]=`PROXY_BODY`,e[e.PROXY_WEBSOCKET_MESSAGE=3]=`PROXY_WEBSOCKET_MESSAGE`,e[e.PROXY_WEBSOCKET_CLOSE=4]=`PROXY_WEBSOCKET_CLOSE`,e}({}),d=function(e){return e[e.RESPONSE=0]=`RESPONSE`,e[e.NOTIFICATION=1]=`NOTIFICATION`,e[e.PROXY_INIT=2]=`PROXY_INIT`,e[e.PROXY_DATA=3]=`PROXY_DATA`,e[e.PROXY_WEBSOCKET_MESSAGE=4]=`PROXY_WEBSOCKET_MESSAGE`,e[e.PROXY_WEBSOCKET_CLOSE=5]=`PROXY_WEBSOCKET_CLOSE`,e}({});const f={[u.REQUEST]:a.string(),[u.PROXY_INIT]:a.object({method:a.string(),headers:a.record(a.string(),a.string()),url:a.string()}),[u.PROXY_BODY]:a.instanceof(Uint8Array),[u.PROXY_WEBSOCKET_MESSAGE]:a.object({type:a.enum([`text`,`binary`]),data:a.instanceof(Uint8Array)}),[u.PROXY_WEBSOCKET_CLOSE]:a.object({code:a.number().optional(),reason:a.string().optional()})};d.RESPONSE,a.string(),d.NOTIFICATION,a.string(),d.PROXY_INIT,a.object({status_code:a.number(),status_message:a.string(),headers:a.record(a.string(),a.string())}),d.PROXY_DATA,a.instanceof(Uint8Array),d.PROXY_WEBSOCKET_MESSAGE,a.instanceof(Uint8Array),d.PROXY_WEBSOCKET_CLOSE,a.object({code:a.number(),reason:a.string()}),u.PROXY_INIT,a.string(),a.record(a.string(),a.string()),a.string();const p={process_execute:a.object({command:a.string(),args:a.array(a.string()),env_file:a.string().optional(),env:a.record(a.string(),a.string()).optional(),cwd:a.string().optional()}),process_send_input:a.object({pid:a.number(),data:a.string()}),process_wait:a.object({pid:a.number(),output_idle_timeout_ms:a.number().optional(),timeout_ms:a.number().optional()}),process_list:a.object({include_dead:a.boolean().optional()}),process_read_plain_output:a.object({pid:a.number(),start_line:a.number().optional(),end_line:a.number().optional()}),process_kill:a.object({pid:a.number(),signal:a.string().optional()}),set_env:a.object({env:a.record(a.string(),a.string())}),read_file:a.object({path:a.string(),line_start:a.number().optional(),line_end:a.number().optional()}),write_file:a.object({path:a.string(),content:a.string(),base64:a.boolean().optional(),mode:a.number().optional()}),read_directory:a.object({path:a.string()}),watch_directory:a.object({path:a.string()}),deploy_static_files:a.object({path:a.string()})},m=a.object({pid:a.number(),command:a.string(),args:a.array(a.string()),title:a.string().optional(),cwd:a.string(),env:a.record(a.string(),a.string()),exit_code:a.number().optional(),exit_signal:a.number().optional(),duration_ms:a.number().optional(),output_total_lines:a.number()});m.extend({ansi_output:a.string(),plain_output:a.object({lines:a.array(a.string()),total_lines:a.number()})}),a.object({pid:a.number()}),a.object({}),a.object({processes:a.array(m)}),a.object({lines:a.array(a.string()),total_lines:a.number(),duration_ms:a.number(),exit_code:a.number().optional(),exit_signal:a.number().optional()}),a.object({}),a.object({}),a.object({total_lines:a.number(),lines_read:a.number(),start_line:a.number(),content:a.string(),mime_type:a.string()}),a.object({}),a.object({entries:a.array(a.object({name:a.string(),type:a.enum([`file`,`directory`,`symlink`])}))}),a.object({}),a.object({deployment_id:a.string()});const h=a.object({type:a.enum([`create`,`update`,`delete`]),path:a.string()}),g=a.object({type:a.enum([`context`,`added`,`deleted`]),content:a.string(),oldLineNumber:a.number().optional(),newLineNumber:a.number().optional()}),_=a.object({oldStart:a.number(),oldLines:a.number(),newStart:a.number(),newLines:a.number(),lines:a.array(g)}),v=a.object({path:a.string(),status:a.enum([`added`,`modified`,`deleted`,`renamed`,`copied`,`untracked`,`ignored`,`unmerged`,`typechange`]),oldPath:a.string().optional(),insertions:a.number(),deletions:a.number(),chunks:a.array(_)}),y=a.object({totalFiles:a.number(),totalInsertions:a.number(),totalDeletions:a.number(),netChange:a.number(),startHash:a.string().optional(),currentHash:a.string().optional(),timespan:a.number(),files:a.array(v)}),b=a.object({path:a.string(),status:a.enum([`added`,`modified`,`deleted`,`renamed`,`copied`,`untracked`,`ignored`,`unmerged`,`typechange`]),staged:a.boolean()}),x=a.object({hash:a.string(),shortHash:a.string(),message:a.string(),author:a.string(),email:a.string(),date:a.date(),timestamp:a.date(),filesChanged:a.number(),insertions:a.number(),deletions:a.number(),commitDiff:a.array(v).optional()});a.object({files:a.array(b),branch:a.string(),ahead:a.number(),behind:a.number(),timestamp:a.date(),sessionDiff:y.optional(),workingDirectoryDiff:y.optional(),newCommits:a.array(x),currentCommit:a.object({hash:a.string(),shortHash:a.string(),message:a.string(),author:a.string(),date:a.date()}).optional(),diffSkipped:a.boolean().optional(),payloadTruncated:a.boolean().optional(),estimatedSizeKB:a.number().optional()}),a.object({debounceDelay:a.number().optional(),gitStatusInterval:a.number().optional(),ignoreDotfiles:a.boolean().optional(),ignored:a.array(a.string()).optional(),watchGit:a.boolean().optional(),includeDiffs:a.boolean().optional(),maxDiffFiles:a.number().optional(),maxPayloadSizeKB:a.number().optional(),truncateLargeDiffs:a.boolean().optional()}),a.object({status:m}),a.object({pid:a.number(),output:a.string()}),a.object({changes:a.array(h)});var S=Object.create,C=Object.defineProperty,w=Object.getOwnPropertyDescriptor,T=Object.getOwnPropertyNames,E=Object.getPrototypeOf,D=Object.prototype.hasOwnProperty,O=(e,t)=>function(){return t||(0,e[T(e)[0]])((t={exports:{}}).exports,t),t.exports},k=(e,t,n,r)=>{if(t&&typeof t==`object`||typeof t==`function`)for(var i=T(t),a=0,o=i.length,s;a<o;a++)s=i[a],!D.call(e,s)&&s!==n&&C(e,s,{get:(e=>t[e]).bind(null,s),enumerable:!(r=w(t,s))||r.enumerable});return e},A=(e,t,n)=>(n=e==null?{}:S(E(e)),k(t||!e||!e.__esModule?C(n,`default`,{value:e,enumerable:!0}):n,e)),j=t(import.meta.url),M=class{listeners=[];get event(){return e=>(this.listeners.push(e),{dispose:()=>{this.listeners=this.listeners.filter(t=>t!==e)}})}emit(e){for(let t=this.listeners.length-1;t>=0;t--)this.listeners[t]?.(e)}dispose(){this.listeners=[]}};let N=function(e){return e[e.DATA=0]=`DATA`,e[e.CLOSE=1]=`CLOSE`,e[e.ERROR=2]=`ERROR`,e}({}),P=function(e){return e[e.NEW=1]=`NEW`,e}({});var F=class{static MAX_POOL_SIZE=100;static COMMON_SIZES=[64,256,1024,4096,16384];static pools=new Map;static{for(let e of this.COMMON_SIZES)this.pools.set(e,[])}static acquire(e){for(let t of this.COMMON_SIZES)if(t>=e){let e=this.pools.get(t);if(e&&e.length>0)return e.pop();break}return new Uint8Array(e)}static release(e){let t=e.length;for(let n of this.COMMON_SIZES)if(n===t){let t=this.pools.get(n);t&&t.length<this.MAX_POOL_SIZE&&t.push(e);break}}},I=class e{static HEADER_SIZE=4;static MAX_FRAME_SIZE=1024*1024-e.HEADER_SIZE;static encode(e){let t=e.payload.length;if(t>this.MAX_FRAME_SIZE)throw Error(`Frame payload too large: ${t} > ${this.MAX_FRAME_SIZE}`);let n=this.HEADER_SIZE+t,r=F.acquire(n),i=e.streamId<<8|e.type<<4|e.flags&15;return r[0]=i>>>24&255,r[1]=i>>>16&255,r[2]=i>>>8&255,r[3]=i&255,t>0&&r.set(e.payload,this.HEADER_SIZE),r.length===n?r:r.subarray(0,n)}static encodeTyped(t,n,r,i,a){let o=1+a.length;if(o>this.MAX_FRAME_SIZE)throw Error(`Frame payload too large: ${o} > ${this.MAX_FRAME_SIZE}`);let s=this.HEADER_SIZE+o,c=F.acquire(s),l=t<<8|n<<4|r&15;return c[0]=l>>>24&255,c[1]=l>>>16&255,c[2]=l>>>8&255,c[3]=l&255,c[e.HEADER_SIZE]=i&255,a.length>0&&c.set(a,e.HEADER_SIZE+1),c.length===s?c:c.subarray(0,s)}static decode(t){if(t.length<e.HEADER_SIZE)throw Error(`Invalid frame: too short (${t.length} < ${e.HEADER_SIZE})`);let n=t[0]<<24|t[1]<<16|t[2]<<8|t[3],r=n>>>8,i=n&255,a=i>>>4,o=i&15,s=t.length>e.HEADER_SIZE?t.subarray(e.HEADER_SIZE):new Uint8Array;return{streamId:r,type:a,flags:o,payload:s}}static releaseBuffer(e){F.release(e)}static getMaxPayloadSize(){return e.MAX_FRAME_SIZE}},ee=class{_onData;_onClose;_onError;_disposed=!1;_id;constructor(e,t,n){this.send=t,this.sendTypedCb=n,this._id=e}get id(){return this._id}get onData(){return this._onData||(this._onData=new M),this._onData.event}get onClose(){return this._onClose||(this._onClose=new M),this._onClose.event}get onError(){return this._onError||(this._onError=new M),this._onError.event}write(e,t=!1){if(this._disposed)throw Error(`Cannot write to disposed stream ${this.id}`);let n=I.getMaxPayloadSize();if(e.length<=n){this.send({streamId:this.id,type:N.DATA,flags:t?P.NEW:0,payload:e});return}let r=0,i=!0;for(;r<e.length;){let a=e.length-r,o=a>n?n:a,s=e.subarray(r,r+o);this.send({streamId:this.id,type:N.DATA,flags:t&&i?P.NEW:0,payload:s}),r+=o,i=!1}}writeTyped(e,t,n=!1){if(this._disposed)throw Error(`Cannot write to disposed stream ${this.id}`);if(!this.sendTypedCb){let r=new Uint8Array(1+t.length);r[0]=e&255,t.length&&r.set(t,1),this.write(r,n);return}let r=I.getMaxPayloadSize()-1;if(t.length<=r){this.sendTypedCb(this.id,n?P.NEW:0,e,t);return}let i=0,a=!0;for(;i<t.length;){let o=t.length-i,s=o>r?r:o,c=t.subarray(i,i+s);this.sendTypedCb(this.id,n&&a?P.NEW:0,e,c),i+=s,a=!1}}close(){this._disposed||(this.send({streamId:this.id,type:N.CLOSE,flags:0,payload:new Uint8Array}),this._dispose())}error(e){this._disposed||this.send({streamId:this.id,type:N.ERROR,flags:0,payload:new TextEncoder().encode(e)})}_handleFrame(e){if(!this._disposed)switch(e.type){case N.DATA:this._onData?.emit(e.payload);break;case N.CLOSE:this._onClose?.emit(),this._dispose();break;case N.ERROR:let t=new TextDecoder().decode(e.payload);this._onError?.emit(t),this._dispose();break}}_dispose(){this._disposed||(this._disposed=!0,this._onData?.dispose(),this._onClose?.dispose(),this._onError?.dispose(),this._onData=void 0,this._onClose=void 0,this._onError=void 0)}_reset(e,t,n){this._dispose(),this._id=e,this.send=t,this.sendTypedCb=n,this._disposed=!1}get createdByClient(){return this.id%2==1}get disposed(){return this._disposed}},L=class{static MAX_POOL_SIZE=200;static pool=[];static acquire(e,t,n){let r=this.pool.pop();return r?(r._reset(e,t,n),r):new ee(e,t,n)}static release(e){this.pool.length<this.MAX_POOL_SIZE&&this.pool.push(e)}},R=class{_onNextStreamIDChange=new M;onNextStreamIDChange=this._onNextStreamIDChange.event;_onStream=new M;onStream=this._onStream.event;streams=[];streamCount=0;nextStreamId=1;send;releaseAfterSend;constructor(e){this.nextStreamId=e.initialNextStreamID??(e.isClient?1:2),this.send=e.send,this.releaseAfterSend=!!e.releaseAfterSend}getStream(e){return this.streams[e]}createStream(e){e===void 0&&(e=this.nextStreamId,this.nextStreamId+=2,this._onNextStreamIDChange.emit(this.nextStreamId));let t=this.streams[e];if(t&&!t.disposed)throw Error(`Stream ${e} already exists`);let n=L.acquire(e,e=>this.sendFrame(e),(e,t,n,r)=>this.sendFrameTyped(e,n,t,r));return this.streams[e]=n,this.streamCount++,n}sendFrame(e){let t=I.encode(e);try{this.send(t)}finally{this.releaseAfterSend&&I.releaseBuffer(t)}}sendFrameTyped(e,t,n,r){let i=I.encodeTyped(e,N.DATA,n,t,r);try{this.send(i)}finally{this.releaseAfterSend&&I.releaseBuffer(i)}}handleMessage(e){this.handleFrame(I.decode(e))}handleFrame(e){let t=this.streams[e.streamId];(!t||t.disposed)&&(t=L.acquire(e.streamId,e=>this.sendFrame(e),(e,t,n,r)=>this.sendFrameTyped(e,n,t,r)),this.streams[e.streamId]=t,this.streamCount++,this._onStream.emit(t)),t._handleFrame(e),(e.type===N.CLOSE||e.type===N.ERROR)&&(this.streams[e.streamId]=void 0,this.streamCount--,L.release(t))}get activeStreamCount(){return this.streamCount}dispose(){for(let e of this.streams)e&&!e.disposed&&(e.close(),L.release(e));this.streams.length=0,this.streamCount=0,this._onNextStreamIDChange.dispose(),this._onStream.dispose()}},z=class extends Error{constructor(){super(`End-Of-Stream`),this.name=`EndOfStreamError`}},te=class extends Error{constructor(e=`The operation was aborted`){super(e),this.name=`AbortError`}},B=class{constructor(){this.endOfStream=!1,this.interrupted=!1,this.peekQueue=[]}async peek(e,t=!1){let n=await this.read(e,t);return this.peekQueue.push(e.subarray(0,n)),n}async read(e,t=!1){if(e.length===0)return 0;let n=this.readFromPeekBuffer(e);if(this.endOfStream||(n+=await this.readRemainderFromStream(e.subarray(n),t)),n===0&&!t)throw new z;return n}readFromPeekBuffer(e){let t=e.length,n=0;for(;this.peekQueue.length>0&&t>0;){let r=this.peekQueue.pop();if(!r)throw Error(`peekData should be defined`);let i=Math.min(r.length,t);e.set(r.subarray(0,i),n),n+=i,t-=i,i<r.length&&this.peekQueue.push(r.subarray(i))}return n}async readRemainderFromStream(e,t){let n=0;for(;n<e.length&&!this.endOfStream;){if(this.interrupted)throw new te;let r=await this.readFromStream(e.subarray(n),t);if(r===0)break;n+=r}if(!t&&n<e.length)throw new z;return n}},ne=class extends B{constructor(e){super(),this.reader=e}async abort(){return this.close()}async close(){this.reader.releaseLock()}},re=class extends ne{async readFromStream(e,t){if(e.length===0)return 0;let n=await this.reader.read(new Uint8Array(e.length),{min:t?void 0:e.length});return n.done&&(this.endOfStream=n.done),n.value?(e.set(n.value),n.value.length):0}},ie=class extends B{constructor(e){super(),this.reader=e,this.buffer=null}writeChunk(e,t){let n=Math.min(t.length,e.length);return e.set(t.subarray(0,n)),n<t.length?this.buffer=t.subarray(n):this.buffer=null,n}async readFromStream(e,t){if(e.length===0)return 0;let n=0;for(this.buffer&&(n+=this.writeChunk(e,this.buffer));n<e.length&&!this.endOfStream;){let t=await this.reader.read();if(t.done){this.endOfStream=!0;break}t.value&&(n+=this.writeChunk(e.subarray(n),t.value))}if(!t&&n===0&&this.endOfStream)throw new z;return n}abort(){return this.interrupted=!0,this.reader.cancel()}async close(){await this.abort(),this.reader.releaseLock()}};function ae(e){try{let t=e.getReader({mode:`byob`});return t instanceof ReadableStreamDefaultReader?new ie(t):new re(t)}catch(t){if(t instanceof TypeError)return new ie(e.getReader());throw t}}var oe=class{constructor(e){this.numBuffer=new Uint8Array(8),this.position=0,this.onClose=e?.onClose,e?.abortSignal&&e.abortSignal.addEventListener(`abort`,()=>{this.abort()})}async readToken(e,t=this.position){let n=new Uint8Array(e.len),r=await this.readBuffer(n,{position:t});if(r<e.len)throw new z;return e.get(n,0)}async peekToken(e,t=this.position){let n=new Uint8Array(e.len),r=await this.peekBuffer(n,{position:t});if(r<e.len)throw new z;return e.get(n,0)}async readNumber(e){let t=await this.readBuffer(this.numBuffer,{length:e.len});if(t<e.len)throw new z;return e.get(this.numBuffer,0)}async peekNumber(e){let t=await this.peekBuffer(this.numBuffer,{length:e.len});if(t<e.len)throw new z;return e.get(this.numBuffer,0)}async ignore(e){if(this.fileInfo.size!==void 0){let t=this.fileInfo.size-this.position;if(e>t)return this.position+=t,t}return this.position+=e,e}async close(){await this.abort(),await this.onClose?.()}normalizeOptions(e,t){if(!this.supportsRandomAccess()&&t&&t.position!==void 0&&t.position<this.position)throw Error("`options.position` must be equal or greater than `tokenizer.position`");return{mayBeLess:!1,offset:0,length:e.length,position:this.position,...t}}abort(){return Promise.resolve()}},se=class extends oe{constructor(e,t){super(t),this.streamReader=e,this.fileInfo=t?.fileInfo??{}}async readBuffer(e,t){let n=this.normalizeOptions(e,t),r=n.position-this.position;if(r>0)return await this.ignore(r),this.readBuffer(e,t);if(r<0)throw Error("`options.position` must be equal or greater than `tokenizer.position`");if(n.length===0)return 0;let i=await this.streamReader.read(e.subarray(0,n.length),n.mayBeLess);if(this.position+=i,(!t||!t.mayBeLess)&&i<n.length)throw new z;return i}async peekBuffer(e,t){let n=this.normalizeOptions(e,t),r=0;if(n.position){let t=n.position-this.position;if(t>0){let i=new Uint8Array(n.length+t);return r=await this.peekBuffer(i,{mayBeLess:n.mayBeLess}),e.set(i.subarray(t)),r-t}if(t<0)throw Error(`Cannot peek from a negative offset in a stream`)}if(n.length>0){try{r=await this.streamReader.peek(e.subarray(0,n.length),n.mayBeLess)}catch(e){if(t?.mayBeLess&&e instanceof z)return 0;throw e}if(!n.mayBeLess&&r<n.length)throw new z}return r}async ignore(e){let t=Math.min(256e3,e),n=new Uint8Array(t),r=0;for(;r<e;){let i=e-r,a=await this.readBuffer(n,{length:Math.min(t,i)});if(a<0)return a;r+=a}return r}abort(){return this.streamReader.abort()}async close(){return this.streamReader.close()}supportsRandomAccess(){return!1}},ce=class extends oe{constructor(e,t){super(t),this.uint8Array=e,this.fileInfo={...t?.fileInfo??{},size:e.length}}async readBuffer(e,t){t?.position&&(this.position=t.position);let n=await this.peekBuffer(e,t);return this.position+=n,n}async peekBuffer(e,t){let n=this.normalizeOptions(e,t),r=Math.min(this.uint8Array.length-n.position,n.length);if(!n.mayBeLess&&r<n.length)throw new z;return e.set(this.uint8Array.subarray(n.position,n.position+r)),r}close(){return super.close()}supportsRandomAccess(){return!0}setPosition(e){this.position=e}};function le(e,t){let n=ae(e),r=t??{},i=r.onClose;return r.onClose=async()=>{if(await n.close(),i)return i()},new se(n,r)}function ue(e,t){return new ce(e,t)}const de={128:`€`,130:`‚`,131:`ƒ`,132:`„`,133:`…`,134:`†`,135:`‡`,136:`ˆ`,137:`‰`,138:`Š`,139:`‹`,140:`Œ`,142:`Ž`,145:`‘`,146:`’`,147:`“`,148:`”`,149:`•`,150:`–`,151:`—`,152:`˜`,153:`™`,154:`š`,155:`›`,156:`œ`,158:`ž`,159:`Ÿ`},fe={};for(let[e,t]of Object.entries(de))fe[t]=Number.parseInt(e);function pe(e,t=`utf-8`){switch(t.toLowerCase()){case`utf-8`:case`utf8`:return globalThis.TextDecoder===void 0?me(e):new globalThis.TextDecoder(`utf-8`).decode(e);case`utf-16le`:return he(e);case`ascii`:return ge(e);case`latin1`:case`iso-8859-1`:return _e(e);case`windows-1252`:return ve(e);default:throw RangeError(`Encoding '${t}' not supported`)}}function me(e){let t=``,n=0;for(;n<e.length;){let r=e[n++];if(r<128)t+=String.fromCharCode(r);else if(r<224){let i=e[n++]&63;t+=String.fromCharCode((r&31)<<6|i)}else if(r<240){let i=e[n++]&63,a=e[n++]&63;t+=String.fromCharCode((r&15)<<12|i<<6|a)}else{let i=e[n++]&63,a=e[n++]&63,o=e[n++]&63,s=(r&7)<<18|i<<12|a<<6|o;s-=65536,t+=String.fromCharCode(55296+(s>>10&1023),56320+(s&1023))}}return t}function he(e){let t=``;for(let n=0;n<e.length;n+=2)t+=String.fromCharCode(e[n]|e[n+1]<<8);return t}function ge(e){return String.fromCharCode(...e.map(e=>e&127))}function _e(e){return String.fromCharCode(...e)}function ve(e){let t=``;for(let n of e)n>=128&&n<=159&&de[n]?t+=de[n]:t+=String.fromCharCode(n);return t}function V(e){return new DataView(e.buffer,e.byteOffset)}const ye={len:1,get(e,t){return V(e).getUint8(t)},put(e,t,n){return V(e).setUint8(t,n),t+1}},H={len:2,get(e,t){return V(e).getUint16(t,!0)},put(e,t,n){return V(e).setUint16(t,n,!0),t+2}},U={len:2,get(e,t){return V(e).getUint16(t)},put(e,t,n){return V(e).setUint16(t,n),t+2}},W={len:4,get(e,t){return V(e).getUint32(t,!0)},put(e,t,n){return V(e).setUint32(t,n,!0),t+4}},be={len:4,get(e,t){return V(e).getUint32(t)},put(e,t,n){return V(e).setUint32(t,n),t+4}},xe={len:4,get(e,t){return V(e).getInt32(t)},put(e,t,n){return V(e).setInt32(t,n),t+4}},Se={len:8,get(e,t){return V(e).getBigUint64(t,!0)},put(e,t,n){return V(e).setBigUint64(t,n,!0),t+8}};var G=class{constructor(e,t){this.len=e,this.encoding=t}get(e,t=0){let n=e.subarray(t,t+this.len);return pe(n,this.encoding)}},Ce=r(`/`),we;try{we=Ce(`worker_threads`).Worker}catch(e){}var K=Uint8Array,q=Uint16Array,Te=Int32Array,Ee=new K([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),De=new K([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),Oe=new K([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),ke=function(e,t){for(var n=new q(31),r=0;r<31;++r)n[r]=t+=1<<e[r-1];for(var i=new Te(n[30]),r=1;r<30;++r)for(var a=n[r];a<n[r+1];++a)i[a]=a-n[r]<<5|r;return{b:n,r:i}},Ae=ke(Ee,2),je=Ae.b,Me=Ae.r;je[28]=258,Me[258]=28;var Ne=ke(De,0),Pe=Ne.b;Ne.r;for(var Fe=new q(32768),J=0;J<32768;++J){var Y=(J&43690)>>1|(J&21845)<<1;Y=(Y&52428)>>2|(Y&13107)<<2,Y=(Y&61680)>>4|(Y&3855)<<4,Fe[J]=((Y&65280)>>8|(Y&255)<<8)>>1}for(var Ie=(function(e,t,n){for(var r=e.length,i=0,a=new q(t);i<r;++i)e[i]&&++a[e[i]-1];var o=new q(t);for(i=1;i<t;++i)o[i]=o[i-1]+a[i-1]<<1;var s;if(n){s=new q(1<<t);var c=15-t;for(i=0;i<r;++i)if(e[i])for(var l=i<<4|e[i],u=t-e[i],d=o[e[i]-1]++<<u,f=d|(1<<u)-1;d<=f;++d)s[Fe[d]>>c]=l}else for(s=new q(r),i=0;i<r;++i)e[i]&&(s[i]=Fe[o[e[i]-1]++]>>15-e[i]);return s}),Le=new K(288),J=0;J<144;++J)Le[J]=8;for(var J=144;J<256;++J)Le[J]=9;for(var J=256;J<280;++J)Le[J]=7;for(var J=280;J<288;++J)Le[J]=8;for(var Re=new K(32),J=0;J<32;++J)Re[J]=5;var ze=Ie(Le,9,1),Be=Ie(Re,5,1),Ve=function(e){for(var t=e[0],n=1;n<e.length;++n)e[n]>t&&(t=e[n]);return t},X=function(e,t,n){var r=t/8|0;return(e[r]|e[r+1]<<8)>>(t&7)&n},He=function(e,t){var n=t/8|0;return(e[n]|e[n+1]<<8|e[n+2]<<16)>>(t&7)},Ue=function(e){return(e+7)/8|0},We=function(e,t,n){return(t==null||t<0)&&(t=0),(n==null||n>e.length)&&(n=e.length),new K(e.subarray(t,n))},Ge=[`unexpected EOF`,`invalid block type`,`invalid length/literal`,`invalid distance`,`stream finished`,`no stream handler`,,`no callback`,`invalid UTF-8 data`,`extra field too long`,`date not in range 1980-2099`,`filename too long`,`stream finishing`,`invalid zip data`],Z=function(e,t,n){var r=Error(t||Ge[e]);if(r.code=e,Error.captureStackTrace&&Error.captureStackTrace(r,Z),!n)throw r;return r},Ke=function(e,t,n,r){var i=e.length,a=r?r.length:0;if(!i||t.f&&!t.l)return n||new K(0);var o=!n,s=o||t.i!=2,c=t.i;o&&(n=new K(i*3));var l=function(e){var t=n.length;if(e>t){var r=new K(Math.max(t*2,e));r.set(n),n=r}},u=t.f||0,d=t.p||0,f=t.b||0,p=t.l,m=t.d,h=t.m,g=t.n,_=i*8;do{if(!p){u=X(e,d,1);var v=X(e,d+1,3);if(d+=3,v)if(v==1)p=ze,m=Be,h=9,g=5;else if(v==2){var y=X(e,d,31)+257,b=X(e,d+10,15)+4,x=y+X(e,d+5,31)+1;d+=14;for(var S=new K(x),C=new K(19),w=0;w<b;++w)C[Oe[w]]=X(e,d+w*3,7);d+=b*3;for(var T=Ve(C),E=(1<<T)-1,D=Ie(C,T,1),w=0;w<x;){var O=D[X(e,d,E)];d+=O&15;var k=O>>4;if(k<16)S[w++]=k;else{var A=0,j=0;for(k==16?(j=3+X(e,d,3),d+=2,A=S[w-1]):k==17?(j=3+X(e,d,7),d+=3):k==18&&(j=11+X(e,d,127),d+=7);j--;)S[w++]=A}}var M=S.subarray(0,y),N=S.subarray(y);h=Ve(M),g=Ve(N),p=Ie(M,h,1),m=Ie(N,g,1)}else Z(1);else{var k=Ue(d)+4,P=e[k-4]|e[k-3]<<8,F=k+P;if(F>i){c&&Z(0);break}s&&l(f+P),n.set(e.subarray(k,F),f),t.b=f+=P,t.p=d=F*8,t.f=u;continue}if(d>_){c&&Z(0);break}}s&&l(f+131072);for(var I=(1<<h)-1,ee=(1<<g)-1,L=d;;L=d){var A=p[He(e,d)&I],R=A>>4;if(d+=A&15,d>_){c&&Z(0);break}if(A||Z(2),R<256)n[f++]=R;else if(R==256){L=d,p=null;break}else{var z=R-254;if(R>264){var w=R-257,te=Ee[w];z=X(e,d,(1<<te)-1)+je[w],d+=te}var B=m[He(e,d)&ee],ne=B>>4;B||Z(3),d+=B&15;var N=Pe[ne];if(ne>3){var te=De[ne];N+=He(e,d)&(1<<te)-1,d+=te}if(d>_){c&&Z(0);break}s&&l(f+131072);var re=f+z;if(f<N){var ie=a-N,ae=Math.min(N,re);for(ie+f<0&&Z(3);f<ae;++f)n[f]=r[ie+f]}for(;f<re;++f)n[f]=n[f-N]}}t.l=p,t.p=L,t.b=f,t.f=u,p&&(u=1,t.m=h,t.d=m,t.n=g)}while(!u);return f!=n.length&&o?We(n,0,f):n.subarray(0,f)},qe=new K(0),Je=function(e){(e[0]!=31||e[1]!=139||e[2]!=8)&&Z(6,`invalid gzip data`);var t=e[3],n=10;t&4&&(n+=(e[10]|e[11]<<8)+2);for(var r=(t>>3&1)+(t>>4&1);r>0;r-=!e[n++]);return n+(t&2)},Ye=function(e){var t=e.length;return(e[t-4]|e[t-3]<<8|e[t-2]<<16|e[t-1]<<24)>>>0},Xe=function(e,t){return((e[0]&15)!=8||e[0]>>4>7||(e[0]<<8|e[1])%31)&&Z(6,`invalid zlib data`),(e[1]>>5&1)==+!t&&Z(6,`invalid zlib data: `+(e[1]&32?`need`:`unexpected`)+` dictionary`),(e[1]>>3&4)+2};function Ze(e,t){return Ke(e,{i:2},t&&t.out,t&&t.dictionary)}function Qe(e,t){var n=Je(e);return n+8>e.length&&Z(6,`invalid gzip data`),Ke(e.subarray(n,-8),{i:2},t&&t.out||new K(Ye(e)),t&&t.dictionary)}function $e(e,t){return Ke(e.subarray(Xe(e,t&&t.dictionary),-4),{i:2},t&&t.out,t&&t.dictionary)}function et(e,t){return e[0]==31&&e[1]==139&&e[2]==8?Qe(e,t):(e[0]&15)!=8||e[0]>>4>7||(e[0]<<8|e[1])%31?Ze(e,t):$e(e,t)}var tt=typeof TextDecoder<`u`&&new TextDecoder,nt=0;try{tt.decode(qe,{stream:!0}),nt=1}catch(e){}var rt=O({"../../node_modules/ms/index.js":((exports,t)=>{var n=1e3,r=n*60,i=r*60,a=i*24,o=a*7,s=a*365.25;t.exports=function(e,t){t=t||{};var n=typeof e;if(n===`string`&&e.length>0)return c(e);if(n===`number`&&isFinite(e))return t.long?u(e):l(e);throw Error(`val is not a non-empty string or a valid number. val=`+JSON.stringify(e))};function c(e){if(e=String(e),!(e.length>100)){var t=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(e);if(t){var c=parseFloat(t[1]),l=(t[2]||`ms`).toLowerCase();switch(l){case`years`:case`year`:case`yrs`:case`yr`:case`y`:return c*s;case`weeks`:case`week`:case`w`:return c*o;case`days`:case`day`:case`d`:return c*a;case`hours`:case`hour`:case`hrs`:case`hr`:case`h`:return c*i;case`minutes`:case`minute`:case`mins`:case`min`:case`m`:return c*r;case`seconds`:case`second`:case`secs`:case`sec`:case`s`:return c*n;case`milliseconds`:case`millisecond`:case`msecs`:case`msec`:case`ms`:return c;default:return}}}}function l(e){var t=Math.abs(e);return t>=a?Math.round(e/a)+`d`:t>=i?Math.round(e/i)+`h`:t>=r?Math.round(e/r)+`m`:t>=n?Math.round(e/n)+`s`:e+`ms`}function u(e){var t=Math.abs(e);return t>=a?d(e,t,a,`day`):t>=i?d(e,t,i,`hour`):t>=r?d(e,t,r,`minute`):t>=n?d(e,t,n,`second`):e+` ms`}function d(e,t,n,r){var i=t>=n*1.5;return Math.round(e/n)+` `+r+(i?`s`:``)}})}),it=O({"../../node_modules/@tokenizer/inflate/node_modules/debug/src/common.js":((exports,t)=>{function n(e){n.debug=n,n.default=n,n.coerce=c,n.disable=o,n.enable=i,n.enabled=s,n.humanize=rt(),n.destroy=l,Object.keys(e).forEach(t=>{n[t]=e[t]}),n.names=[],n.skips=[],n.formatters={};function t(e){let t=0;for(let n=0;n<e.length;n++)t=(t<<5)-t+e.charCodeAt(n),t|=0;return n.colors[Math.abs(t)%n.colors.length]}n.selectColor=t;function n(e){let t,i=null,a,o;function s(...e){if(!s.enabled)return;let r=s,i=Number(new Date),a=i-(t||i);r.diff=a,r.prev=t,r.curr=i,t=i,e[0]=n.coerce(e[0]),typeof e[0]!=`string`&&e.unshift(`%O`);let o=0;e[0]=e[0].replace(/%([a-zA-Z%])/g,(t,i)=>{if(t===`%%`)return`%`;o++;let a=n.formatters[i];if(typeof a==`function`){let n=e[o];t=a.call(r,n),e.splice(o,1),o--}return t}),n.formatArgs.call(r,e);let c=r.log||n.log;c.apply(r,e)}return s.namespace=e,s.useColors=n.useColors(),s.color=n.selectColor(e),s.extend=r,s.destroy=n.destroy,Object.defineProperty(s,`enabled`,{enumerable:!0,configurable:!1,get:()=>i===null?(a!==n.namespaces&&(a=n.namespaces,o=n.enabled(e)),o):i,set:e=>{i=e}}),typeof n.init==`function`&&n.init(s),s}function r(e,t){let r=n(this.namespace+(t===void 0?`:`:t)+e);return r.log=this.log,r}function i(e){n.save(e),n.namespaces=e,n.names=[],n.skips=[];let t=(typeof e==`string`?e:``).trim().replace(/\s+/g,`,`).split(`,`).filter(Boolean);for(let e of t)e[0]===`-`?n.skips.push(e.slice(1)):n.names.push(e)}function a(e,t){let n=0,r=0,i=-1,a=0;for(;n<e.length;)if(r<t.length&&(t[r]===e[n]||t[r]===`*`))t[r]===`*`?(i=r,a=n,r++):(n++,r++);else if(i!==-1)r=i+1,a++,n=a;else return!1;for(;r<t.length&&t[r]===`*`;)r++;return r===t.length}function o(){let e=[...n.names,...n.skips.map(e=>`-`+e)].join(`,`);return n.enable(``),e}function s(e){for(let t of n.skips)if(a(e,t))return!1;for(let t of n.names)if(a(e,t))return!0;return!1}function c(e){return e instanceof Error?e.stack||e.message:e}function l(){console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")}return n.enable(n.load()),n}t.exports=n})}),at=O({"../../node_modules/@tokenizer/inflate/node_modules/debug/src/browser.js":((exports,t)=>{exports.formatArgs=r,exports.save=i,exports.load=a,exports.useColors=n,exports.storage=o(),exports.destroy=(()=>{let e=!1;return()=>{e||(e=!0,console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."))}})(),exports.colors=`#0000CC.#0000FF.#0033CC.#0033FF.#0066CC.#0066FF.#0099CC.#0099FF.#00CC00.#00CC33.#00CC66.#00CC99.#00CCCC.#00CCFF.#3300CC.#3300FF.#3333CC.#3333FF.#3366CC.#3366FF.#3399CC.#3399FF.#33CC00.#33CC33.#33CC66.#33CC99.#33CCCC.#33CCFF.#6600CC.#6600FF.#6633CC.#6633FF.#66CC00.#66CC33.#9900CC.#9900FF.#9933CC.#9933FF.#99CC00.#99CC33.#CC0000.#CC0033.#CC0066.#CC0099.#CC00CC.#CC00FF.#CC3300.#CC3333.#CC3366.#CC3399.#CC33CC.#CC33FF.#CC6600.#CC6633.#CC9900.#CC9933.#CCCC00.#CCCC33.#FF0000.#FF0033.#FF0066.#FF0099.#FF00CC.#FF00FF.#FF3300.#FF3333.#FF3366.#FF3399.#FF33CC.#FF33FF.#FF6600.#FF6633.#FF9900.#FF9933.#FFCC00.#FFCC33`.split(`.`);function n(){if(typeof window<`u`&&window.process&&(window.process.type===`renderer`||window.process.__nwjs))return!0;if(typeof navigator<`u`&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))return!1;let e;return typeof document<`u`&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||typeof window<`u`&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||typeof navigator<`u`&&navigator.userAgent&&(e=navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/))&&parseInt(e[1],10)>=31||typeof navigator<`u`&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)}function r(e){if(e[0]=(this.useColors?`%c`:``)+this.namespace+(this.useColors?` %c`:` `)+e[0]+(this.useColors?`%c `:` `)+`+`+t.exports.humanize(this.diff),!this.useColors)return;let n=`color: `+this.color;e.splice(1,0,n,`color: inherit`);let r=0,i=0;e[0].replace(/%[a-zA-Z%]/g,e=>{e!==`%%`&&(r++,e===`%c`&&(i=r))}),e.splice(i,0,n)}exports.log=console.debug||console.log||(()=>{});function i(t){try{t?exports.storage.setItem(`debug`,t):exports.storage.removeItem(`debug`)}catch(e){}}function a(){let t;try{t=exports.storage.getItem(`debug`)||exports.storage.getItem(`DEBUG`)}catch(e){}return!t&&typeof process<`u`&&`env`in process&&(t=process.env.DEBUG),t}function o(){try{return localStorage}catch(e){}}t.exports=it()(exports);let{formatters:s}=t.exports;s.j=function(e){try{return JSON.stringify(e)}catch(e){return`[UnexpectedJSONParseError]: `+e.message}}})}),ot=O({"../../node_modules/has-flag/index.js":((exports,t)=>{t.exports=(e,t=process.argv)=>{let n=e.startsWith(`-`)?``:e.length===1?`-`:`--`,r=t.indexOf(n+e),i=t.indexOf(`--`);return r!==-1&&(i===-1||r<i)}})}),st=O({"../../node_modules/supports-color/index.js":((exports,t)=>{let n=j(`os`),r=j(`tty`),i=ot(),{env:a}=process,o;i(`no-color`)||i(`no-colors`)||i(`color=false`)||i(`color=never`)?o=0:(i(`color`)||i(`colors`)||i(`color=true`)||i(`color=always`))&&(o=1),`FORCE_COLOR`in a&&(o=a.FORCE_COLOR===`true`?1:a.FORCE_COLOR===`false`?0:a.FORCE_COLOR.length===0?1:Math.min(parseInt(a.FORCE_COLOR,10),3));function s(e){return e===0?!1:{level:e,hasBasic:!0,has256:e>=2,has16m:e>=3}}function c(e,t){if(o===0)return 0;if(i(`color=16m`)||i(`color=full`)||i(`color=truecolor`))return 3;if(i(`color=256`))return 2;if(e&&!t&&o===void 0)return 0;let r=o||0;if(a.TERM===`dumb`)return r;if(process.platform===`win32`){let e=n.release().split(`.`);return Number(e[0])>=10&&Number(e[2])>=10586?Number(e[2])>=14931?3:2:1}if(`CI`in a)return[`TRAVIS`,`CIRCLECI`,`APPVEYOR`,`GITLAB_CI`,`GITHUB_ACTIONS`,`BUILDKITE`].some(e=>e in a)||a.CI_NAME===`codeship`?1:r;if(`TEAMCITY_VERSION`in a)return/^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(a.TEAMCITY_VERSION)?1:0;if(a.COLORTERM===`truecolor`)return 3;if(`TERM_PROGRAM`in a){let e=parseInt((a.TERM_PROGRAM_VERSION||``).split(`.`)[0],10);switch(a.TERM_PROGRAM){case`iTerm.app`:return e>=3?3:2;case`Apple_Terminal`:return 2}}return/-256(color)?$/i.test(a.TERM)?2:/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(a.TERM)||`COLORTERM`in a?1:r}function l(e){let t=c(e,e&&e.isTTY);return s(t)}t.exports={supportsColor:l,stdout:s(c(!0,r.isatty(1))),stderr:s(c(!0,r.isatty(2)))}})}),ct=O({"../../node_modules/@tokenizer/inflate/node_modules/debug/src/node.js":((exports,t)=>{let n=j(`tty`),r=j(`util`);exports.init=u,exports.log=s,exports.formatArgs=a,exports.save=c,exports.load=l,exports.useColors=i,exports.destroy=r.deprecate(()=>{},"Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."),exports.colors=[6,2,3,4,5,1];try{let t=st();t&&(t.stderr||t).level>=2&&(exports.colors=[20,21,26,27,32,33,38,39,40,41,42,43,44,45,56,57,62,63,68,69,74,75,76,77,78,79,80,81,92,93,98,99,112,113,128,129,134,135,148,149,160,161,162,163,164,165,166,167,168,169,170,171,172,173,178,179,184,185,196,197,198,199,200,201,202,203,204,205,206,207,208,209,214,215,220,221])}catch(e){}exports.inspectOpts=Object.keys(process.env).filter(e=>/^debug_/i.test(e)).reduce((e,t)=>{let n=t.substring(6).toLowerCase().replace(/_([a-z])/g,(e,t)=>t.toUpperCase()),r=process.env[t];return r=/^(yes|on|true|enabled)$/i.test(r)?!0:/^(no|off|false|disabled)$/i.test(r)?!1:r===`null`?null:Number(r),e[n]=r,e},{});function i(){return`colors`in exports.inspectOpts?!!exports.inspectOpts.colors:n.isatty(process.stderr.fd)}function a(e){let{namespace:n,useColors:r}=this;if(r){let r=this.color,i=`\x1B[3`+(r<8?r:`8;5;`+r),a=` ${i};1m${n} \u001B[0m`;e[0]=a+e[0].split(`
2
2
  `).join(`
3
3
  `+a),e.push(i+`m+`+t.exports.humanize(this.diff)+`\x1B[0m`)}else e[0]=o()+n+` `+e[0]}function o(){return exports.inspectOpts.hideDate?``:new Date().toISOString()+` `}function s(...t){return process.stderr.write(r.formatWithOptions(exports.inspectOpts,...t)+`
4
4
  `)}function c(e){e?process.env.DEBUG=e:delete process.env.DEBUG}function l(){return process.env.DEBUG}function u(t){t.inspectOpts={};let n=Object.keys(exports.inspectOpts);for(let r=0;r<n.length;r++)t.inspectOpts[n[r]]=exports.inspectOpts[n[r]]}t.exports=it()(exports);let{formatters:d}=t.exports;d.o=function(e){return this.inspectOpts.colors=this.useColors,r.inspect(e,this.inspectOpts).split(`
@@ -9,6 +9,8 @@ import{import_websocket as e}from"./wrapper-B4vDwpOq.js";import{createRequire as
9
9
  `,t)}reset(){this._core.reset()}loadAddon(e){this._addonManager.loadAddon(this,e)}_verifyIntegers(...e){for(let t of e)if(t===1/0||isNaN(t)||t%1!=0)throw Error(`This API only accepts integers`)}}e.Terminal=u})();var a=exports;for(var o in i)a[o]=i[o];i.__esModule&&Object.defineProperty(a,`__esModule`,{value:!0})})()})}),Nt=A(jt(),1),Pt=A(Mt(),1),Ft=class e{static COLUMNS=80;static ROWS=24;static SCROLLBACK=128e3;globalEnv;processes=new Map;spawnListeners=[];nodePty;constructor(e){this.globalEnv=e?.env??{},this.nodePty=e?.nodePty}onSpawn(e){return this.spawnListeners.push(e),{dispose:()=>{this.spawnListeners=this.spawnListeners.filter(t=>t!==e)}}}setEnv(e){this.globalEnv={...this.globalEnv,...e},Object.keys(e).forEach(t=>{e[t]===``&&delete this.globalEnv[t]})}execute(t,n,r){let i=It(t,n,{name:`xterm-256color`,cols:e.COLUMNS,rows:e.ROWS,cwd:r?.cwd,env:{...globalThis.process.env,...this.globalEnv,...r?.env}},this.nodePty),a=new Pt.default.Terminal({allowProposedApi:!0,convertEol:!0,scrollback:e.SCROLLBACK,cols:e.COLUMNS,rows:e.ROWS}),o=new Nt.SerializeAddon;a.loadAddon(o);let s;i.onData(e=>{s=new Promise(t=>{a.write(e,t)})}),a.onData(e=>{i.write(e)});let c={command:t,args:n,cwd:r?.cwd??``,env:{...r?.env},startTimeMS:Date.now(),exitCode:void 0,exitSignal:void 0,pid:i.pid,pty:i,terminal:a,serializer:o,kill:e=>{i.kill(e)},onExit:e=>i.onExit(({exitCode:t,signal:n})=>{s?s.then(()=>{e(t,n)}):e(t,n)}),onOutput:e=>i.onData(t=>{e(t)}),sendInput:e=>{a.input(e)}};this.processes.set(i.pid,c),i.onExit(({exitCode:e,signal:t})=>{c.exitCode=e,c.exitSignal=t});for(let e of this.spawnListeners)e(c);return c}status(e){let t=this.processes.get(e);if(!t)throw Error(`Process with PID ${e} not found`);let n=this.readPlainOutput(e);return{pid:t.pid,command:t.command,title:t.pty.process,args:t.args,cwd:t.cwd,env:t.env,exit_code:t.exitCode,exit_signal:t.exitSignal,duration_ms:Date.now()-t.startTimeMS,output_total_lines:n.totalLines}}list(e){return Array.from(this.processes.values()).filter(t=>e||t.exitCode===void 0).map(e=>this.status(e.pid))}getProcess(e){return this.processes.get(e)}readANSIOutput(e,t){let n=this.processes.get(e);if(!n)throw Error(`Process with PID ${e} not found`);return n.serializer.serialize({scrollback:t})}readPlainOutput(t,n,r){let i=n?Math.max(0,n-1):0,a=r?Math.max(0,r-1):e.SCROLLBACK+e.ROWS-1,o=this.processes.get(t);if(!o)throw Error(`Process with PID ${t} not found`);let s=[];for(let t=0;t<e.SCROLLBACK+e.ROWS;t++){let e=o.terminal.buffer.normal.getLine(t);e&&s.push(e.translateToString(!0)??``)}for(;s.length>0&&s[s.length-1].trim()===``;)s.pop();return{lines:s.slice(i,a+1),totalLines:s.length}}close(){this.processes.forEach(e=>{e.pty.kill()})}};const It=(e,t,n,r)=>{if(!r||globalThis.Bun!==void 0){let r=new M,i=new M,a=s(e,t,{env:n.env,cwd:n.cwd,stdio:`pipe`});return a.stdout.on(`data`,e=>{i.emit(Buffer.from(e).toString(`utf-8`))}),a.stderr.on(`data`,e=>{i.emit(Buffer.from(e).toString(`utf-8`))}),a.on(`exit`,(e,t)=>{let n=e??-1,i=t?n:void 0;r.emit({exitCode:n,signal:i})}),a.on(`error`,e=>{throw e}),{pid:a.pid??-1,process:``,onExit:e=>r.event(e),kill(e){a.kill(e)},onData:e=>i.event(e),write(e){a.stdin?.write(e)}}}return r.spawn(e,t,n)};var Lt=O({"../../node_modules/fast-fifo/fixed-size.js":((exports,t)=>{t.exports=class{constructor(e){if(!(e>0)||e-1&e)throw Error(`Max size for a FixedFIFO should be a power of two`);this.buffer=Array(e),this.mask=e-1,this.top=0,this.btm=0,this.next=null}clear(){this.top=this.btm=0,this.next=null,this.buffer.fill(void 0)}push(e){return this.buffer[this.top]===void 0?(this.buffer[this.top]=e,this.top=this.top+1&this.mask,!0):!1}shift(){let e=this.buffer[this.btm];if(e!==void 0)return this.buffer[this.btm]=void 0,this.btm=this.btm+1&this.mask,e}peek(){return this.buffer[this.btm]}isEmpty(){return this.buffer[this.btm]===void 0}}})}),Rt=O({"../../node_modules/fast-fifo/index.js":((exports,t)=>{let n=Lt();t.exports=class{constructor(e){this.hwm=e||16,this.head=new n(this.hwm),this.tail=this.head,this.length=0}clear(){this.head=this.tail,this.head.clear(),this.length=0}push(e){if(this.length++,!this.head.push(e)){let t=this.head;this.head=t.next=new n(2*this.head.buffer.length),this.head.push(e)}}shift(){this.length!==0&&this.length--;let e=this.tail.shift();if(e===void 0&&this.tail.next){let e=this.tail.next;return this.tail.next=null,this.tail=e,this.tail.shift()}return e}peek(){let e=this.tail.peek();return e===void 0&&this.tail.next?this.tail.next.peek():e}isEmpty(){return this.length===0}}})}),zt=O({"../../node_modules/b4a/index.js":((exports,t)=>{function n(e){return Buffer.isBuffer(e)||e instanceof Uint8Array}function r(e){return Buffer.isEncoding(e)}function i(e,t,n){return Buffer.alloc(e,t,n)}function a(e){return Buffer.allocUnsafe(e)}function o(e){return Buffer.allocUnsafeSlow(e)}function s(e,t){return Buffer.byteLength(e,t)}function c(e,t){return Buffer.compare(e,t)}function l(e,t){return Buffer.concat(e,t)}function u(e,t,n,r,i){return b(e).copy(t,n,r,i)}function d(e,t){return b(e).equals(t)}function f(e,t,n,r,i){return b(e).fill(t,n,r,i)}function p(e,t,n){return Buffer.from(e,t,n)}function m(e,t,n,r){return b(e).includes(t,n,r)}function h(e,t,n,r){return b(e).indexOf(t,n,r)}function g(e,t,n,r){return b(e).lastIndexOf(t,n,r)}function _(e){return b(e).swap16()}function v(e){return b(e).swap32()}function y(e){return b(e).swap64()}function b(e){return Buffer.isBuffer(e)?e:Buffer.from(e.buffer,e.byteOffset,e.byteLength)}function x(e,t,n,r){return b(e).toString(t,n,r)}function S(e,t,n,r,i){return b(e).write(t,n,r,i)}function C(e,t,n){return b(e).writeDoubleLE(t,n)}function w(e,t,n){return b(e).writeFloatLE(t,n)}function T(e,t,n){return b(e).writeUInt32LE(t,n)}function E(e,t,n){return b(e).writeInt32LE(t,n)}function D(e,t){return b(e).readDoubleLE(t)}function O(e,t){return b(e).readFloatLE(t)}function k(e,t){return b(e).readUInt32LE(t)}function A(e,t){return b(e).readInt32LE(t)}function j(e,t,n){return b(e).writeDoubleBE(t,n)}function M(e,t,n){return b(e).writeFloatBE(t,n)}function N(e,t,n){return b(e).writeUInt32BE(t,n)}function P(e,t,n){return b(e).writeInt32BE(t,n)}function F(e,t){return b(e).readDoubleBE(t)}function I(e,t){return b(e).readFloatBE(t)}function ee(e,t){return b(e).readUInt32BE(t)}function L(e,t){return b(e).readInt32BE(t)}t.exports={isBuffer:n,isEncoding:r,alloc:i,allocUnsafe:a,allocUnsafeSlow:o,byteLength:s,compare:c,concat:l,copy:u,equals:d,fill:f,from:p,includes:m,indexOf:h,lastIndexOf:g,swap16:_,swap32:v,swap64:y,toBuffer:b,toString:x,write:S,writeDoubleLE:C,writeFloatLE:w,writeUInt32LE:T,writeInt32LE:E,readDoubleLE:D,readFloatLE:O,readUInt32LE:k,readInt32LE:A,writeDoubleBE:j,writeFloatBE:M,writeUInt32BE:N,writeInt32BE:P,readDoubleBE:F,readFloatBE:I,readUInt32BE:ee,readInt32BE:L}})}),Bt=O({"../../node_modules/text-decoder/lib/pass-through-decoder.js":((exports,t)=>{let n=zt();t.exports=class{constructor(e){this.encoding=e}get remaining(){return 0}decode(e){return n.toString(e,this.encoding)}flush(){return``}}})}),Vt=O({"../../node_modules/text-decoder/lib/utf8-decoder.js":((exports,t)=>{let n=zt();t.exports=class{constructor(){this.codePoint=0,this.bytesSeen=0,this.bytesNeeded=0,this.lowerBoundary=128,this.upperBoundary=191}get remaining(){return this.bytesSeen}decode(e){if(this.bytesNeeded===0){let t=!0;for(let n=Math.max(0,e.byteLength-4),r=e.byteLength;n<r&&t;n++)t=e[n]<=127;if(t)return n.toString(e,`utf8`)}let t=``;for(let n=0,r=e.byteLength;n<r;n++){let r=e[n];if(this.bytesNeeded===0){r<=127?t+=String.fromCharCode(r):(this.bytesSeen=1,r>=194&&r<=223?(this.bytesNeeded=2,this.codePoint=r&31):r>=224&&r<=239?(r===224?this.lowerBoundary=160:r===237&&(this.upperBoundary=159),this.bytesNeeded=3,this.codePoint=r&15):r>=240&&r<=244?(r===240&&(this.lowerBoundary=144),r===244&&(this.upperBoundary=143),this.bytesNeeded=4,this.codePoint=r&7):t+=`�`);continue}if(r<this.lowerBoundary||r>this.upperBoundary){this.codePoint=0,this.bytesNeeded=0,this.bytesSeen=0,this.lowerBoundary=128,this.upperBoundary=191,t+=`�`;continue}this.lowerBoundary=128,this.upperBoundary=191,this.codePoint=this.codePoint<<6|r&63,this.bytesSeen++,this.bytesSeen===this.bytesNeeded&&(t+=String.fromCodePoint(this.codePoint),this.codePoint=0,this.bytesNeeded=0,this.bytesSeen=0)}return t}flush(){let e=this.bytesNeeded>0?`�`:``;return this.codePoint=0,this.bytesNeeded=0,this.bytesSeen=0,this.lowerBoundary=128,this.upperBoundary=191,e}}})}),Ht=O({"../../node_modules/text-decoder/index.js":((exports,t)=>{let n=Bt(),r=Vt();t.exports=class{constructor(e=`utf8`){switch(this.encoding=i(e),this.encoding){case`utf8`:this.decoder=new r;break;case`utf16le`:case`base64`:throw Error(`Unsupported encoding: `+this.encoding);default:this.decoder=new n(this.encoding)}}get remaining(){return this.decoder.remaining}push(e){return typeof e==`string`?e:this.decoder.decode(e)}write(e){return this.push(e)}end(e){let t=``;return e&&(t=this.push(e)),t+=this.decoder.flush(),t}};function i(e){switch(e=e.toLowerCase(),e){case`utf8`:case`utf-8`:return`utf8`;case`ucs2`:case`ucs-2`:case`utf16le`:case`utf-16le`:return`utf16le`;case`latin1`:case`binary`:return`latin1`;case`base64`:case`ascii`:case`hex`:return e;default:throw Error(`Unknown encoding: `+e)}}})}),Ut=O({"../../node_modules/streamx/index.js":((exports,t)=>{let{EventEmitter:n}=j(`events`),r=Error(`Stream was destroyed`),i=Error(`Premature close`),a=Rt(),o=Ht(),s=typeof queueMicrotask>`u`?e=>global.process.nextTick(e):queueMicrotask,c=(1<<29)-1,l=c^1;c^2;let u=1024,d=2048,f=4096,p=8192,m=16384,h=32768,g=65536,_=131072;16|g,f|128;let v=256|_;c^16,c^64,c^(64|g);let y=c^g;c^256,c^(128|p),c^u;let b=c^768,x=c^h;c^32;let S=c^_;c^v;let C=1<<18,w=2<<18,T=4<<18,E=8<<18,D=16<<18,O=32<<18,k=64<<18,A=128<<18,M=256<<18,N=512<<18,P=1024<<18;c^(C|M);let F=c^T;c^(C|N),c^D,c^E;let I=c^A;c^w;let ee=c^P,L=16|C,R=c^L,z=m|O,te=14|z;F&536870847;let B=A|h;B&R;let ne=33587215;u|16399;let re=m|143;u|143,u|16398,h|1,N|8388623,E|D,E|C;let ie=270794767;T|C,C|M,O|134217742;let ae=Symbol.asyncIterator||Symbol(`asyncIterator`);var oe=class{constructor(e,{highWaterMark:t=16384,map:n=null,mapWritable:r,byteLength:i,byteLengthWritable:o}={}){this.stream=e,this.queue=new a,this.highWaterMark=t,this.buffered=0,this.error=null,this.pipeline=null,this.drains=null,this.byteLength=o||i||Me,this.map=r||n,this.afterWrite=pe.bind(this),this.afterUpdateNextTick=ge.bind(this)}get ended(){return(this.stream._duplexState&O)!==0}push(e){return this.stream._duplexState&142606350?!1:(this.map!==null&&(e=this.map(e)),this.buffered+=this.byteLength(e),this.queue.push(e),this.buffered<this.highWaterMark?(this.stream._duplexState|=E,!0):(this.stream._duplexState|=6291456,!1))}shift(){let e=this.queue.shift();return this.buffered-=this.byteLength(e),this.buffered===0&&(this.stream._duplexState&=534773759),e}end(e){typeof e==`function`?this.stream.once(`finish`,e):e!=null&&this.push(e),this.stream._duplexState=(this.stream._duplexState|N)&F}autoBatch(e,t){let n=[],r=this.stream;for(n.push(e);(r._duplexState&ie)===2359296;)n.push(r._writableState.shift());if(r._duplexState&15)return t(null);r._writev(n,t)}update(){let e=this.stream;e._duplexState|=w;do{for(;(e._duplexState&ie)===E;){let t=this.shift();e._duplexState|=67371008,e._write(t,this.afterWrite)}e._duplexState&1310720||this.updateNonPrimary()}while(this.continueUpdate()===!0);e._duplexState&=536346623}updateNonPrimary(){let e=this.stream;if((e._duplexState&144965647)===N){e._duplexState|=C,e._final(de.bind(this));return}if((e._duplexState&14)==4){(e._duplexState&B)===0&&(e._duplexState|=L,e._destroy(fe.bind(this)));return}(e._duplexState&ne)===1&&(e._duplexState=(e._duplexState|L)&l,e._open(ve.bind(this)))}continueUpdate(){return(this.stream._duplexState&A)===0?!1:(this.stream._duplexState&=I,!0)}updateCallback(){(this.stream._duplexState&35127311)===T?this.update():this.updateNextTick()}updateNextTick(){(this.stream._duplexState&A)===0&&(this.stream._duplexState|=A,(this.stream._duplexState&w)===0&&s(this.afterUpdateNextTick))}},se=class{constructor(e,{highWaterMark:t=16384,map:n=null,mapReadable:r,byteLength:i,byteLengthReadable:o}={}){this.stream=e,this.queue=new a,this.highWaterMark=t===0?1:t,this.buffered=0,this.readAhead=t>0,this.error=null,this.pipeline=null,this.byteLength=o||i||Me,this.map=r||n,this.pipeTo=null,this.afterRead=me.bind(this),this.afterUpdateNextTick=he.bind(this)}get ended(){return(this.stream._duplexState&m)!==0}pipe(e,t){if(this.pipeTo!==null)throw Error(`Can only pipe to one destination`);if(typeof t!=`function`&&(t=null),this.stream._duplexState|=512,this.pipeTo=e,this.pipeline=new le(this.stream,e,t),t&&this.stream.on(`error`,Ne),Te(e))e._writableState.pipeline=this.pipeline,t&&e.on(`error`,Ne),e.on(`finish`,this.pipeline.finished.bind(this.pipeline));else{let t=this.pipeline.done.bind(this.pipeline,e),n=this.pipeline.done.bind(this.pipeline,e,null);e.on(`error`,t),e.on(`close`,n),e.on(`finish`,this.pipeline.finished.bind(this.pipeline))}e.on(`drain`,ue.bind(this)),this.stream.emit(`piping`,e),e.emit(`pipe`,this.stream)}push(e){let t=this.stream;return e===null?(this.highWaterMark=0,t._duplexState=(t._duplexState|u)&536805311,!1):this.map!==null&&(e=this.map(e),e===null)?(t._duplexState&=y,this.buffered<this.highWaterMark):(this.buffered+=this.byteLength(e),this.queue.push(e),t._duplexState=(t._duplexState|128)&y,this.buffered<this.highWaterMark)}shift(){let e=this.queue.shift();return this.buffered-=this.byteLength(e),this.buffered===0&&(this.stream._duplexState&=536862591),e}unshift(e){let t=[this.map===null?e:this.map(e)];for(;this.buffered>0;)t.push(this.shift());for(let e=0;e<t.length-1;e++){let n=t[e];this.buffered+=this.byteLength(n),this.queue.push(n)}this.push(t[t.length-1])}read(){let e=this.stream;if((e._duplexState&re)===128){let t=this.shift();return this.pipeTo!==null&&this.pipeTo.write(t)===!1&&(e._duplexState&=b),(e._duplexState&d)!==0&&e.emit(`data`,t),t}return this.readAhead===!1&&(e._duplexState|=_,this.updateNextTick()),null}drain(){let e=this.stream;for(;(e._duplexState&re)===128&&e._duplexState&768;){let t=this.shift();this.pipeTo!==null&&this.pipeTo.write(t)===!1&&(e._duplexState&=b),(e._duplexState&d)!==0&&e.emit(`data`,t)}}update(){let e=this.stream;e._duplexState|=32;do{for(this.drain();this.buffered<this.highWaterMark&&(e._duplexState&214047)===_;)e._duplexState|=65552,e._read(this.afterRead),this.drain();(e._duplexState&12431)==4224&&(e._duplexState|=p,e.emit(`readable`)),e._duplexState&80||this.updateNonPrimary()}while(this.continueUpdate()===!0);e._duplexState&=536870879}updateNonPrimary(){let e=this.stream;if((e._duplexState&1167)===u&&(e._duplexState=(e._duplexState|m)&536869887,e.emit(`end`),(e._duplexState&te)===z&&(e._duplexState|=4),this.pipeTo!==null&&this.pipeTo.end()),(e._duplexState&14)==4){(e._duplexState&B)===0&&(e._duplexState|=L,e._destroy(fe.bind(this)));return}(e._duplexState&ne)===1&&(e._duplexState=(e._duplexState|L)&l,e._open(ve.bind(this)))}continueUpdate(){return(this.stream._duplexState&h)===0?!1:(this.stream._duplexState&=x,!0)}updateCallback(){(this.stream._duplexState&32879)==64?this.update():this.updateNextTick()}updateNextTickIfOpen(){this.stream._duplexState&32769||(this.stream._duplexState|=h,this.stream._duplexState&32||s(this.afterUpdateNextTick))}updateNextTick(){(this.stream._duplexState&h)===0&&(this.stream._duplexState|=h,this.stream._duplexState&32||s(this.afterUpdateNextTick))}},ce=class{constructor(e){this.data=null,this.afterTransform=V.bind(e),this.afterFinal=null}},le=class{constructor(e,t,n){this.from=e,this.to=t,this.afterPipe=n,this.error=null,this.pipeToFinished=!1}finished(){this.pipeToFinished=!0}done(e,t){if(t&&(this.error=t),e===this.to&&(this.to=null,this.from!==null)){((this.from._duplexState&m)===0||!this.pipeToFinished)&&this.from.destroy(this.error||Error(`Writable stream closed prematurely`));return}if(e===this.from&&(this.from=null,this.to!==null)){(e._duplexState&m)===0&&this.to.destroy(this.error||Error(`Readable stream closed before ending`));return}this.afterPipe!==null&&this.afterPipe(this.error),this.to=this.from=this.afterPipe=null}};function ue(){this.stream._duplexState|=512,this.updateCallback()}function de(e){let t=this.stream;e&&t.destroy(e),t._duplexState&14||(t._duplexState|=O,t.emit(`finish`)),(t._duplexState&te)===z&&(t._duplexState|=4),t._duplexState&=402391039,(t._duplexState&w)===0?this.update():this.updateNextTick()}function fe(e){let t=this.stream;!e&&this.error!==r&&(e=this.error),e&&t.emit(`error`,e),t._duplexState|=8,t.emit(`close`);let n=t._readableState,i=t._writableState;if(n!==null&&n.pipeline!==null&&n.pipeline.done(t,e),i!==null){for(;i.drains!==null&&i.drains.length>0;)i.drains.shift().resolve(!1);i.pipeline!==null&&i.pipeline.done(t,e)}}function pe(e){let t=this.stream;e&&t.destroy(e),t._duplexState&=469499903,this.drains!==null&&_e(this.drains),(t._duplexState&6553615)===D&&(t._duplexState&=532676607,(t._duplexState&k)===k&&t.emit(`drain`)),this.updateCallback()}function me(e){e&&this.stream.destroy(e),this.stream._duplexState&=536870895,this.readAhead===!1&&!(this.stream._duplexState&256)&&(this.stream._duplexState&=S),this.updateCallback()}function he(){this.stream._duplexState&32||(this.stream._duplexState&=x,this.update())}function ge(){(this.stream._duplexState&w)===0&&(this.stream._duplexState&=I,this.update())}function _e(e){for(let t=0;t<e.length;t++)--e[t].writes===0&&(e.shift().resolve(!0),t--)}function ve(e){let t=this.stream;e&&t.destroy(e),t._duplexState&4||(t._duplexState&17423||(t._duplexState|=64),t._duplexState&142606351||(t._duplexState|=T),t.emit(`open`)),t._duplexState&=R,t._writableState!==null&&t._writableState.updateCallback(),t._readableState!==null&&t._readableState.updateCallback()}function V(e,t){t!=null&&this.push(t),this._writableState.afterWrite(e)}function ye(e){this._readableState!==null&&(e===`data`&&(this._duplexState|=d|v,this._readableState.updateNextTick()),e===`readable`&&(this._duplexState|=f,this._readableState.updateNextTick())),this._writableState!==null&&e===`drain`&&(this._duplexState|=k,this._writableState.updateNextTick())}var H=class extends n{constructor(e){super(),this._duplexState=0,this._readableState=null,this._writableState=null,e&&(e.open&&(this._open=e.open),e.destroy&&(this._destroy=e.destroy),e.predestroy&&(this._predestroy=e.predestroy),e.signal&&e.signal.addEventListener(`abort`,Pe.bind(this))),this.on(`newListener`,ye)}_open(e){e(null)}_destroy(e){e(null)}_predestroy(){}get readable(){return this._readableState===null?void 0:!0}get writable(){return this._writableState===null?void 0:!0}get destroyed(){return(this._duplexState&8)!=0}get destroying(){return(this._duplexState&14)!=0}destroy(e){this._duplexState&14||(e||(e=r),this._duplexState=(this._duplexState|4)&535822271,this._readableState!==null&&(this._readableState.highWaterMark=0,this._readableState.error=e),this._writableState!==null&&(this._writableState.highWaterMark=0,this._writableState.error=e),this._duplexState|=2,this._predestroy(),this._duplexState&=536870909,this._readableState!==null&&this._readableState.updateNextTick(),this._writableState!==null&&this._writableState.updateNextTick())}},U=class e extends H{constructor(e){super(e),this._duplexState|=O|131073,this._readableState=new se(this,e),e&&(this._readableState.readAhead===!1&&(this._duplexState&=S),e.read&&(this._read=e.read),e.eagerOpen&&this._readableState.updateNextTick(),e.encoding&&this.setEncoding(e.encoding))}setEncoding(e){let t=new o(e),n=this._readableState.map||K;return this._readableState.map=r,this;function r(e){let r=t.push(e);return r===``&&(e.byteLength!==0||t.remaining>0)?null:n(r)}}_read(e){e(null)}pipe(e,t){return this._readableState.updateNextTick(),this._readableState.pipe(e,t),e}read(){return this._readableState.updateNextTick(),this._readableState.read()}push(e){return this._readableState.updateNextTickIfOpen(),this._readableState.push(e)}unshift(e){return this._readableState.updateNextTickIfOpen(),this._readableState.unshift(e)}resume(){return this._duplexState|=v,this._readableState.updateNextTick(),this}pause(){return this._duplexState&=this._readableState.readAhead===!1?536739583:536870655,this}static _fromAsyncIterator(t,n){let r,i=new e({...n,read(e){t.next().then(a).then(e.bind(null,null)).catch(e)},predestroy(){r=t.return()},destroy(e){if(!r)return e(null);r.then(e.bind(null,null)).catch(e)}});return i;function a(e){e.done?i.push(null):i.push(e.value)}}static from(t,n){if(ke(t))return t;if(t[ae])return this._fromAsyncIterator(t[ae](),n);Array.isArray(t)||(t=t===void 0?[]:[t]);let r=0;return new e({...n,read(e){this.push(r===t.length?null:t[r++]),e(null)}})}static isBackpressured(e){return(e._duplexState&17422)!=0||e._readableState.buffered>=e._readableState.highWaterMark}static isPaused(e){return(e._duplexState&256)==0}[ae](){let e=this,t=null,n=null,i=null;return this.on(`error`,e=>{t=e}),this.on(`readable`,a),this.on(`close`,o),{[ae](){return this},next(){return new Promise(function(t,r){n=t,i=r;let a=e.read();a===null?e._duplexState&8&&s(null):s(a)})},return(){return c(null)},throw(e){return c(e)}};function a(){n!==null&&s(e.read())}function o(){n!==null&&s(null)}function s(a){i!==null&&(t?i(t):a===null&&(e._duplexState&m)===0?i(r):n({value:a,done:a===null}),i=n=null)}function c(t){return e.destroy(t),new Promise((n,r)=>{if(e._duplexState&8)return n({value:void 0,done:!0});e.once(`close`,function(){t?r(t):n({value:void 0,done:!0})})})}}},W=class extends H{constructor(e){super(e),this._duplexState|=1|m,this._writableState=new oe(this,e),e&&(e.writev&&(this._writev=e.writev),e.write&&(this._write=e.write),e.final&&(this._final=e.final),e.eagerOpen&&this._writableState.updateNextTick())}cork(){this._duplexState|=P}uncork(){this._duplexState&=ee,this._writableState.updateNextTick()}_writev(e,t){t(null)}_write(e,t){this._writableState.autoBatch(e,t)}_final(e){e(null)}static isBackpressured(e){return(e._duplexState&146800654)!=0}static drained(e){if(e.destroyed)return Promise.resolve(!1);let t=e._writableState,n=Fe(e)?Math.min(1,t.queue.length):t.queue.length,r=n+(e._duplexState&M?1:0);return r===0?Promise.resolve(!0):(t.drains===null&&(t.drains=[]),new Promise(e=>{t.drains.push({writes:r,resolve:e})}))}write(e){return this._writableState.updateNextTick(),this._writableState.push(e)}end(e){return this._writableState.updateNextTick(),this._writableState.end(e),this}},be=class extends U{constructor(e){super(e),this._duplexState=1|this._duplexState&_,this._writableState=new oe(this,e),e&&(e.writev&&(this._writev=e.writev),e.write&&(this._write=e.write),e.final&&(this._final=e.final))}cork(){this._duplexState|=P}uncork(){this._duplexState&=ee,this._writableState.updateNextTick()}_writev(e,t){t(null)}_write(e,t){this._writableState.autoBatch(e,t)}_final(e){e(null)}write(e){return this._writableState.updateNextTick(),this._writableState.push(e)}end(e){return this._writableState.updateNextTick(),this._writableState.end(e),this}},xe=class extends be{constructor(e){super(e),this._transformState=new ce(this),e&&(e.transform&&(this._transform=e.transform),e.flush&&(this._flush=e.flush))}_write(e,t){this._readableState.buffered>=this._readableState.highWaterMark?this._transformState.data=e:this._transform(e,this._transformState.afterTransform)}_read(e){if(this._transformState.data!==null){let t=this._transformState.data;this._transformState.data=null,e(null),this._transform(t,this._transformState.afterTransform)}else e(null)}destroy(e){super.destroy(e),this._transformState.data!==null&&(this._transformState.data=null,this._transformState.afterTransform())}_transform(e,t){t(null,e)}_flush(e){e(null)}_final(e){this._transformState.afterFinal=e,this._flush(G.bind(this))}},Se=class extends xe{};function G(e,t){let n=this._transformState.afterFinal;if(e)return n(e);t!=null&&this.push(t),this.push(null),n(null)}function Ce(...e){return new Promise((t,n)=>we(...e,e=>{if(e)return n(e);t()}))}function we(e,...t){let n=Array.isArray(e)?[...e,...t]:[e,...t],r=n.length&&typeof n[n.length-1]==`function`?n.pop():null;if(n.length<2)throw Error(`Pipeline requires at least 2 streams`);let a=n[0],o=null,s=null;for(let e=1;e<n.length;e++)o=n[e],Te(a)?a.pipe(o,l):(c(a,!0,e>1,l),a.pipe(o)),a=o;if(r){let e=!1,t=Te(o)||!!(o._writableState&&o._writableState.autoDestroy);o.on(`error`,e=>{s===null&&(s=e)}),o.on(`finish`,()=>{e=!0,t||r(s)}),t&&o.on(`close`,()=>r(s||(e?null:i)))}return o;function c(e,t,n,r){e.on(`error`,r),e.on(`close`,a);function a(){if(t&&e._readableState&&!e._readableState.ended||n&&e._writableState&&!e._writableState.ended)return r(i)}}function l(e){if(!(!e||s)){s=e;for(let t of n)t.destroy(e)}}}function K(e){return e}function q(e){return!!e._readableState||!!e._writableState}function Te(e){return typeof e._duplexState==`number`&&q(e)}function Ee(e){return!!e._readableState&&e._readableState.ended}function De(e){return!!e._writableState&&e._writableState.ended}function Oe(e,t={}){let n=e._readableState&&e._readableState.error||e._writableState&&e._writableState.error;return!t.all&&n===r?null:n}function ke(e){return Te(e)&&e.readable}function Ae(e){return(e._duplexState&1)!=1||(e._duplexState&B)!==0}function je(e){return typeof e==`object`&&!!e&&typeof e.byteLength==`number`}function Me(e){return je(e)?e.byteLength:1024}function Ne(){}function Pe(){this.destroy(Error(`Stream aborted.`))}function Fe(e){return e._writev!==W.prototype._writev&&e._writev!==be.prototype._writev}t.exports={pipeline:we,pipelinePromise:Ce,isStream:q,isStreamx:Te,isEnded:Ee,isFinished:De,isDisturbed:Ae,getStreamError:Oe,Stream:H,Writable:W,Readable:U,Duplex:be,Transform:xe,PassThrough:Se}})}),Wt=O({"../../node_modules/tar-stream/headers.js":(exports=>{let t=zt(),n=t.from([117,115,116,97,114,0]),r=t.from([48,48]),i=t.from([117,115,116,97,114,32]),a=t.from([32,0]);exports.decodeLongPath=function(e,t){return v(e,0,e.length,t)},exports.encodePax=function(e){let n=``;e.name&&(n+=y(` path=`+e.name+`
10
10
  `)),e.linkname&&(n+=y(` linkpath=`+e.linkname+`
11
11
  `));let r=e.pax;if(r)for(let e in r)n+=y(` `+e+`=`+r[e]+`
12
- `);return t.from(n)},exports.decodePax=function(e){let n={};for(;e.length;){let r=0;for(;r<e.length&&e[r]!==32;)r++;let i=parseInt(t.toString(e.subarray(0,r)),10);if(!i)return n;let a=t.toString(e.subarray(r+1,i-1)),o=a.indexOf(`=`);if(o===-1)return n;n[a.slice(0,o)]=a.slice(o+1),e=e.subarray(i)}return n},exports.encode=function(e){let i=t.alloc(512),a=e.name,o=``;if(e.typeflag===5&&a[a.length-1]!==`/`&&(a+=`/`),t.byteLength(a)!==a.length)return null;for(;t.byteLength(a)>100;){let e=a.indexOf(`/`);if(e===-1)return null;o+=o?`/`+a.slice(0,e):a.slice(0,e),a=a.slice(e+1)}return t.byteLength(a)>100||t.byteLength(o)>155||e.linkname&&t.byteLength(e.linkname)>100?null:(t.write(i,a),t.write(i,p(e.mode&4095,6),100),t.write(i,p(e.uid,6),108),t.write(i,p(e.gid,6),116),h(e.size,i,124),t.write(i,p(e.mtime.getTime()/1e3|0,11),136),i[156]=48+u(e.type),e.linkname&&t.write(i,e.linkname,157),t.copy(n,i,257),t.copy(r,i,263),e.uname&&t.write(i,e.uname,265),e.gname&&t.write(i,e.gname,297),t.write(i,p(e.devmajor||0,6),329),t.write(i,p(e.devminor||0,6),337),o&&t.write(i,o,345),t.write(i,p(f(i),6),148),i)},exports.decode=function(e,t,n){let r=e[156]===0?0:e[156]-48,i=v(e,0,100,t),a=_(e,100,8),c=_(e,108,8),u=_(e,116,8),d=_(e,124,12),p=_(e,136,12),m=l(r),h=e[157]===0?null:v(e,157,100,t),g=v(e,265,32),y=v(e,297,32),b=_(e,329,8),x=_(e,337,8),S=f(e);if(S===256)return null;if(S!==_(e,148,8))throw Error(`Invalid tar header. Maybe the tar is corrupted or it needs to be gunzipped?`);if(o(e))e[345]&&(i=v(e,345,155,t)+`/`+i);else if(!s(e)&&!n)throw Error(`Invalid tar header: unknown format.`);return r===0&&i&&i[i.length-1]===`/`&&(r=5),{name:i,mode:a,uid:c,gid:u,size:d,mtime:new Date(1e3*p),type:m,linkname:h,uname:g,gname:y,devmajor:b,devminor:x,pax:null}};function o(e){return t.equals(n,e.subarray(257,263))}function s(e){return t.equals(i,e.subarray(257,263))&&t.equals(a,e.subarray(263,265))}function c(e,t,n){return typeof e==`number`?(e=~~e,e>=t?t:e>=0||(e+=t,e>=0)?e:0):n}function l(e){switch(e){case 0:return`file`;case 1:return`link`;case 2:return`symlink`;case 3:return`character-device`;case 4:return`block-device`;case 5:return`directory`;case 6:return`fifo`;case 7:return`contiguous-file`;case 72:return`pax-header`;case 55:return`pax-global-header`;case 27:return`gnu-long-link-path`;case 28:case 30:return`gnu-long-path`}return null}function u(e){switch(e){case`file`:return 0;case`link`:return 1;case`symlink`:return 2;case`character-device`:return 3;case`block-device`:return 4;case`directory`:return 5;case`fifo`:return 6;case`contiguous-file`:return 7;case`pax-header`:return 72}return 0}function d(e,t,n,r){for(;n<r;n++)if(e[n]===t)return n;return r}function f(e){let t=256;for(let n=0;n<148;n++)t+=e[n];for(let n=156;n<512;n++)t+=e[n];return t}function p(e,t){return e=e.toString(8),e.length>t?`7777777777777777777`.slice(0,t)+` `:`0000000000000000000`.slice(0,t-e.length)+e+` `}function m(e,t,n){t[n]=128;for(let r=11;r>0;r--)t[n+r]=e&255,e=Math.floor(e/256)}function h(e,n,r){e.toString(8).length>11?m(e,n,r):t.write(n,p(e,11),r)}function g(e){let t;if(e[0]===128)t=!0;else if(e[0]===255)t=!1;else return null;let n=[],r;for(r=e.length-1;r>0;r--){let i=e[r];t?n.push(i):n.push(255-i)}let i=0,a=n.length;for(r=0;r<a;r++)i+=n[r]*Math.pow(256,r);return t?i:-1*i}function _(e,n,r){if(e=e.subarray(n,n+r),n=0,e[n]&128)return g(e);{for(;n<e.length&&e[n]===32;)n++;let r=c(d(e,32,n,e.length),e.length,e.length);for(;n<r&&e[n]===0;)n++;return r===n?0:parseInt(t.toString(e.subarray(n,r)),8)}}function v(e,n,r,i){return t.toString(e.subarray(n,d(e,0,n,n+r)),i)}function y(e){let n=t.byteLength(e),r=Math.floor(Math.log(n)/Math.log(10))+1;return n+r>=Math.pow(10,r)&&r++,n+r+e}})}),Gt=O({"../../node_modules/tar-stream/extract.js":((exports,t)=>{let{Writable:n,Readable:r,getStreamError:i}=Ut(),a=Rt(),o=zt(),s=Wt(),c=o.alloc(0);var l=class{constructor(){this.buffered=0,this.shifted=0,this.queue=new a,this._offset=0}push(e){this.buffered+=e.byteLength,this.queue.push(e)}shiftFirst(e){return this._buffered===0?null:this._next(e)}shift(e){if(e>this.buffered)return null;if(e===0)return c;let t=this._next(e);if(e===t.byteLength)return t;let n=[t];for(;(e-=t.byteLength)>0;)t=this._next(e),n.push(t);return o.concat(n)}_next(e){let t=this.queue.peek(),n=t.byteLength-this._offset;if(e>=n){let e=this._offset?t.subarray(this._offset,t.byteLength):t;return this.queue.shift(),this._offset=0,this.buffered-=n,this.shifted+=n,e}return this.buffered-=e,this.shifted+=e,t.subarray(this._offset,this._offset+=e)}},u=class extends r{constructor(e,t,n){super(),this.header=t,this.offset=n,this._parent=e}_read(e){this.header.size===0&&this.push(null),this._parent._stream===this&&this._parent._update(),e(null)}_predestroy(){this._parent.destroy(i(this))}_detach(){this._parent._stream===this&&(this._parent._stream=null,this._parent._missing=p(this.header.size),this._parent._update())}_destroy(e){this._detach(),e(null)}},d=class extends n{constructor(e){super(e),e||(e={}),this._buffer=new l,this._offset=0,this._header=null,this._stream=null,this._missing=0,this._longHeader=!1,this._callback=f,this._locked=!1,this._finished=!1,this._pax=null,this._paxGlobal=null,this._gnuLongPath=null,this._gnuLongLinkPath=null,this._filenameEncoding=e.filenameEncoding||`utf-8`,this._allowUnknownFormat=!!e.allowUnknownFormat,this._unlockBound=this._unlock.bind(this)}_unlock(e){if(this._locked=!1,e){this.destroy(e),this._continueWrite(e);return}this._update()}_consumeHeader(){if(this._locked)return!1;this._offset=this._buffer.shifted;try{this._header=s.decode(this._buffer.shift(512),this._filenameEncoding,this._allowUnknownFormat)}catch(e){return this._continueWrite(e),!1}if(!this._header)return!0;switch(this._header.type){case`gnu-long-path`:case`gnu-long-link-path`:case`pax-global-header`:case`pax-header`:return this._longHeader=!0,this._missing=this._header.size,!0}return this._locked=!0,this._applyLongHeaders(),this._header.size===0||this._header.type===`directory`?(this.emit(`entry`,this._header,this._createStream(),this._unlockBound),!0):(this._stream=this._createStream(),this._missing=this._header.size,this.emit(`entry`,this._header,this._stream,this._unlockBound),!0)}_applyLongHeaders(){this._gnuLongPath&&(this._header.name=this._gnuLongPath,this._gnuLongPath=null),this._gnuLongLinkPath&&(this._header.linkname=this._gnuLongLinkPath,this._gnuLongLinkPath=null),this._pax&&(this._pax.path&&(this._header.name=this._pax.path),this._pax.linkpath&&(this._header.linkname=this._pax.linkpath),this._pax.size&&(this._header.size=parseInt(this._pax.size,10)),this._header.pax=this._pax,this._pax=null)}_decodeLongHeader(e){switch(this._header.type){case`gnu-long-path`:this._gnuLongPath=s.decodeLongPath(e,this._filenameEncoding);break;case`gnu-long-link-path`:this._gnuLongLinkPath=s.decodeLongPath(e,this._filenameEncoding);break;case`pax-global-header`:this._paxGlobal=s.decodePax(e);break;case`pax-header`:this._pax=this._paxGlobal===null?s.decodePax(e):Object.assign({},this._paxGlobal,s.decodePax(e));break}}_consumeLongHeader(){this._longHeader=!1,this._missing=p(this._header.size);let e=this._buffer.shift(this._header.size);try{this._decodeLongHeader(e)}catch(e){return this._continueWrite(e),!1}return!0}_consumeStream(){let e=this._buffer.shiftFirst(this._missing);if(e===null)return!1;this._missing-=e.byteLength;let t=this._stream.push(e);return this._missing===0?(this._stream.push(null),t&&this._stream._detach(),t&&this._locked===!1):t}_createStream(){return new u(this,this._header,this._offset)}_update(){for(;this._buffer.buffered>0&&!this.destroying;){if(this._missing>0){if(this._stream!==null){if(this._consumeStream()===!1)return;continue}if(this._longHeader===!0){if(this._missing>this._buffer.buffered)break;if(this._consumeLongHeader()===!1)return!1;continue}let e=this._buffer.shiftFirst(this._missing);e!==null&&(this._missing-=e.byteLength);continue}if(this._buffer.buffered<512)break;if(this._stream!==null||this._consumeHeader()===!1)return}this._continueWrite(null)}_continueWrite(e){let t=this._callback;this._callback=f,t(e)}_write(e,t){this._callback=t,this._buffer.push(e),this._update()}_final(e){this._finished=this._missing===0&&this._buffer.buffered===0,e(this._finished?null:Error(`Unexpected end of data`))}_predestroy(){this._continueWrite(null)}_destroy(e){this._stream&&this._stream.destroy(i(this)),e(null)}[Symbol.asyncIterator](){let e=null,t=null,n=null,r=null,i=null,a=this;return this.on(`entry`,c),this.on(`error`,t=>{e=t}),this.on(`close`,l),{[Symbol.asyncIterator](){return this},next(){return new Promise(s)},return(){return u(null)},throw(e){return u(e)}};function o(e){if(!i)return;let t=i;i=null,t(e)}function s(i,s){if(e)return s(e);if(r){i({value:r,done:!1}),r=null;return}t=i,n=s,o(null),a._finished&&t&&(t({value:void 0,done:!0}),t=n=null)}function c(e,a,o){i=o,a.on(`error`,f),t?(t({value:a,done:!1}),t=n=null):r=a}function l(){o(e),t&&(e?n(e):t({value:void 0,done:!0}),t=n=null)}function u(e){return a.destroy(e),o(e),new Promise((t,n)=>{if(a.destroyed)return t({value:void 0,done:!0});a.once(`close`,function(){e?n(e):t({value:void 0,done:!0})})})}}};t.exports=function(e){return new d(e)};function f(){}function p(e){return e&=511,e&&512-e}})}),Kt=O({"../../node_modules/tar-stream/constants.js":((exports,t)=>{let n={S_IFMT:61440,S_IFDIR:16384,S_IFCHR:8192,S_IFBLK:24576,S_IFIFO:4096,S_IFLNK:40960};try{t.exports=j(`fs`).constants||n}catch{t.exports=n}})}),qt=O({"../../node_modules/tar-stream/pack.js":((exports,t)=>{let{Readable:n,Writable:r,getStreamError:i}=Ut(),a=zt(),o=Kt(),s=Wt(),c=a.alloc(1024);var l=class extends r{constructor(e,t,n){super({mapWritable:m,eagerOpen:!0}),this.written=0,this.header=t,this._callback=n,this._linkname=null,this._isLinkname=t.type===`symlink`&&!t.linkname,this._isVoid=t.type!==`file`&&t.type!==`contiguous-file`,this._finished=!1,this._pack=e,this._openCallback=null,this._pack._stream===null?this._pack._stream=this:this._pack._pending.push(this)}_open(e){this._openCallback=e,this._pack._stream===this&&this._continueOpen()}_continuePack(e){if(this._callback===null)return;let t=this._callback;this._callback=null,t(e)}_continueOpen(){this._pack._stream===null&&(this._pack._stream=this);let e=this._openCallback;if(this._openCallback=null,e!==null){if(this._pack.destroying)return e(Error(`pack stream destroyed`));if(this._pack._finalized)return e(Error(`pack stream is already finalized`));this._pack._stream=this,this._isLinkname||this._pack._encode(this.header),this._isVoid&&(this._finish(),this._continuePack(null)),e(null)}}_write(e,t){if(this._isLinkname)return this._linkname=this._linkname?a.concat([this._linkname,e]):e,t(null);if(this._isVoid)return e.byteLength>0?t(Error(`No body allowed for this entry`)):t();if(this.written+=e.byteLength,this._pack.push(e))return t();this._pack._drain=t}_finish(){this._finished||(this._finished=!0,this._isLinkname&&(this.header.linkname=this._linkname?a.toString(this._linkname,`utf-8`):``,this._pack._encode(this.header)),p(this._pack,this.header.size),this._pack._done(this))}_final(e){if(this.written!==this.header.size)return e(Error(`Size mismatch`));this._finish(),e(null)}_getError(){return i(this)||Error(`tar entry destroyed`)}_predestroy(){this._pack.destroy(this._getError())}_destroy(e){this._pack._done(this),this._continuePack(this._finished?null:this._getError()),e()}},u=class extends n{constructor(e){super(e),this._drain=f,this._finalized=!1,this._finalizing=!1,this._pending=[],this._stream=null}entry(e,t,n){if(this._finalized||this.destroying)throw Error(`already finalized or destroyed`);typeof t==`function`&&(n=t,t=null),n||(n=f),(!e.size||e.type===`symlink`)&&(e.size=0),e.type||(e.type=d(e.mode)),e.mode||(e.mode=e.type===`directory`?493:420),e.uid||(e.uid=0),e.gid||(e.gid=0),e.mtime||(e.mtime=new Date),typeof t==`string`&&(t=a.from(t));let r=new l(this,e,n);return a.isBuffer(t)?(e.size=t.byteLength,r.write(t),r.end(),r):(r._isVoid,r)}finalize(){if(this._stream||this._pending.length>0){this._finalizing=!0;return}this._finalized||(this._finalized=!0,this.push(c),this.push(null))}_done(e){e===this._stream&&(this._stream=null,this._finalizing&&this.finalize(),this._pending.length&&this._pending.shift()._continueOpen())}_encode(e){if(!e.pax){let t=s.encode(e);if(t){this.push(t);return}}this._encodePax(e)}_encodePax(e){let t=s.encodePax({name:e.name,linkname:e.linkname,pax:e.pax}),n={name:`PaxHeader`,mode:e.mode,uid:e.uid,gid:e.gid,size:t.byteLength,mtime:e.mtime,type:`pax-header`,linkname:e.linkname&&`PaxHeader`,uname:e.uname,gname:e.gname,devmajor:e.devmajor,devminor:e.devminor};this.push(s.encode(n)),this.push(t),p(this,t.byteLength),n.size=e.size,n.type=e.type,this.push(s.encode(n))}_doDrain(){let e=this._drain;this._drain=f,e()}_predestroy(){let e=i(this);for(this._stream&&this._stream.destroy(e);this._pending.length;){let t=this._pending.shift();t.destroy(e),t._continueOpen()}this._doDrain()}_read(e){this._doDrain(),e()}};t.exports=function(e){return new u(e)};function d(e){switch(e&o.S_IFMT){case o.S_IFBLK:return`block-device`;case o.S_IFCHR:return`character-device`;case o.S_IFDIR:return`directory`;case o.S_IFIFO:return`fifo`;case o.S_IFLNK:return`symlink`}return`file`}function f(){}function p(e,t){t&=511,t&&e.push(c.subarray(0,512-t))}function m(e){return a.isBuffer(e)?e:a.from(e)}})}),Jt=O({"../../node_modules/tar-stream/index.js":(exports=>{exports.extract=Gt(),exports.pack=qt()})}),Yt=A(Jt(),1);const Xt=async(e,t)=>{let{maxBytes:r=50*1024*1024}=t??{},i=await o.stat(e);if(!i.isDirectory())throw Error(`Path is not a directory: ${e}`);let a=Yt.pack(),s=async(e,t=``)=>{let r=await o.readdir(e,{withFileTypes:!0});for(let i of r){let r=`${e}/${i.name}`,c=t?`${t}/${i.name}`:i.name;if(i.isDirectory()){a.entry({name:`${c}/`,type:`directory`}),await s(r,c);continue}if(i.isSymbolicLink?.()){let e=await o.readlink(r);a.entry({name:c,type:`symlink`,linkname:e});continue}if(i.isFile()){let e=await o.stat(r);await new Promise((t,i)=>{let o=n(r),s=a.entry({name:c,size:e.size,mode:e.mode,mtime:e.mtime},e=>{e&&i(e)});o.on(`error`,i),o.on(`data`,e=>s.write(e)),o.on(`end`,()=>{s.end(),t()})});continue}}};(async()=>{try{await s(e),a.finalize()}catch(e){a.destroy(e)}})();let c=a,l=0,u=!1;return new ReadableStream({start(e){let t=t=>{if(!u){if(l+=t.length,l>r){u=!0,e.error(Error(`Archive exceeds size limit (${r} bytes). Emitted=${l} bytes.`));try{c.destroy()}catch{}return}e.enqueue(new Uint8Array(t))}},n=t=>{u||(u=!0,e.error(t instanceof Error?t:Error(String(t))))},i=()=>{u||(u=!0,e.close())};c.on(`data`,t),c.once(`error`,n),c.once(`end`,i)},cancel(){try{c.destroy()}catch{}}})},Zt=(e,t)=>e.length<=t?e:e.slice(e.length-t),Qt=(e,t)=>{if(e.length===0)return{lines:[],truncated:!1};let n=0,r=e.length;for(let i=e.length-1;i>=0;i--){let a=e[i].length;if(n+a>t&&r!==e.length)break;n+=a,r=i}return r===0?{lines:e,truncated:!1}:{lines:e.slice(r),truncated:!0}};var $t=class{multiplexer;notificationStream;decoder=new TextDecoder;encoder=new TextEncoder;processManager;createDeploymentFromTar;proxyOnly;fetchProxyRequest;constructor(e){this.createDeploymentFromTar=e.createDeploymentFromTar,this.proxyOnly=e.proxyOnly,this.fetchProxyRequest=e.fetchProxyRequest,this.multiplexer=new R({send:t=>{e.send(t)}}),this.multiplexer.onStream(e=>{this.handleStream(e)}),this.notificationStream=this.multiplexer.createStream(),this.processManager=new Ft({env:e.env,nodePty:e.nodePty}),this.processManager.onSpawn(e=>{let t=()=>{this.sendNotification({type:`process_status`,payload:{status:this.processManager.status(e.pid)}})};t(),e.terminal.onTitleChange(()=>{t()}),e.onExit(()=>{this.sendNotification({type:`process_status`,payload:{status:this.processManager.status(e.pid)}})}),e.onOutput(t=>{let n=I.getMaxPayloadSize()-1;for(let r=0;r<t.length;r+=n){let i=t.slice(r,r+n);this.sendNotification({type:`process_output`,payload:{pid:e.pid,output:i}})}})})}handleMessage(e){this.multiplexer.handleMessage(e)}handleStream(e){let t=new AbortController;e.onClose(()=>{t.abort()}),e.onData(n=>{let r=n[0],i=n.subarray(1);switch(r){case u.REQUEST:{let n=JSON.parse(this.decoder.decode(i));if(this.proxyOnly){this.sendResponse(e,{id:n.id,error:`This server is in proxy only mode.`});return}this.handleRequest(e,n,t.signal).catch(t=>{this.sendResponse(e,{id:n.id,error:t instanceof Error?t.message:String(t)})});break}case u.PROXY_INIT:{let t=f[u.PROXY_INIT].safeParse(JSON.parse(this.decoder.decode(i)));if(!t.success)throw Error(`Invalid proxy init message`);let n;n=t.data.headers.upgrade===`websocket`?this.handleProxyWebSocket(e,t.data):this.handleProxyRequest(e,t.data),n.catch(t=>{e.error(t.message)});break}}})}async handleProxyWebSocket(t,n){let r=new URL(n.url);r.protocol===`http:`?r.protocol=`ws:`:r.protocol===`https:`&&(r.protocol=`wss:`);let i=new e.default(r.toString(),n.headers[`sec-websocket-protocol`]?n.headers[`sec-websocket-protocol`]:void 0,{headers:n.headers,perMessageDeflate:!1});i.addEventListener(`open`,()=>{let e={status_code:101,status_message:`Switching Protocols`,headers:{}};t.writeTyped(d.PROXY_INIT,this.encoder.encode(JSON.stringify(e)))}),i.addEventListener(`message`,e=>{t.disposed||t.writeTyped(d.PROXY_WEBSOCKET_MESSAGE,c(e.data,this.encoder))}),i.addEventListener(`close`,e=>{if(t.disposed)return;let n={code:e.code,reason:e.reason};t.writeTyped(d.PROXY_WEBSOCKET_CLOSE,this.encoder.encode(JSON.stringify(n))),t.close()}),i.addEventListener(`error`,e=>{console.log(`err`,e)}),t.onClose(()=>{i.close()}),t.onError(e=>{i.close(1011,e)}),t.onData(e=>{let n=e.subarray(1);switch(e[0]){case u.PROXY_WEBSOCKET_MESSAGE:{let e=l(n,this.decoder);i.send(e);break}case u.PROXY_WEBSOCKET_CLOSE:{let e=f[u.PROXY_WEBSOCKET_CLOSE].safeParse(JSON.parse(this.decoder.decode(n)));if(!e.success)throw Error(`Invalid proxy websocket close message`);try{i.close(e.data.code,e.data.reason)}catch(t){console.error(`Error closing websocket`,t,e.data)}break}default:t.error(`Unexpected message type: ${e[0]}`)}})}async handleProxyRequest(e,t){let n,r;if(t.method!==`GET`&&t.method!==`HEAD`&&t.method!==`OPTIONS`){let e=new TransformStream;n=e.writable.getWriter(),r=e.readable}e.onData(t=>{switch(t[0]){case u.PROXY_BODY:if(n){let e=t.subarray(1);e.length===0?n.close():n.write(e)}break;default:e.error(`Unexpected message type: ${t[0]}`)}});let i={headers:t.headers,method:t.method,body:r},a;a=this.fetchProxyRequest?await this.fetchProxyRequest(t.url,i):await fetch(t.url,i);let o={};a.headers.forEach((e,t)=>{o[t]=e});let s={headers:o,status_code:a.status,status_message:a.statusText};e.writeTyped(d.PROXY_INIT,this.encoder.encode(JSON.stringify(s)));let c=a.headers.get(`content-length`),l=c?parseInt(c):0,f=I.getMaxPayloadSize()-1;if(l>=f){if(!a.body){e.close();return}let t=a.body.getReader();try{for(;;){let{done:n,value:r}=await t.read();if(n)break;if(r){let t=0;for(;t<r.length;){let n=Math.min(f,r.length-t),i=r.subarray(t,t+n);e.writeTyped(d.PROXY_DATA,i),t+=n}}}}finally{t.releaseLock()}}else a.body&&await a.body.pipeTo(new WritableStream({write:t=>{e.writeTyped(d.PROXY_DATA,t)}}));e.close()}async handleRequest(e,t,n){let r=p[t.type],a=r.safeParse(t.payload);if(!a.success)throw Error(`Invalid request payload: ${a.error.message}`);switch(t.type){case`process_execute`:{let n=this.processManager.execute(t.payload.command,t.payload.args,{cwd:t.payload.cwd,env:t.payload.env});this.sendResponse(e,{id:t.id,payload:{pid:n.pid}});break}case`process_wait`:this.handleProcessWait(e,t,n);break;case`process_kill`:{let n=this.mustGetProcess(t.payload.pid);n.kill(t.payload.signal),this.sendResponse(e,{id:t.id,payload:{}});break}case`process_list`:this.sendResponse(e,{id:t.id,payload:{processes:this.processManager.list(t.payload.include_dead??!1)}});break;case`process_read_plain_output`:{let n=this.mustGetProcess(t.payload.pid),r=this.processManager.readPlainOutput(t.payload.pid,t.payload.start_line,t.payload.end_line),i=Qt(r.lines,256e3);this.sendResponse(e,{id:t.id,payload:{lines:i.lines,total_lines:r.totalLines,duration_ms:Date.now()-n.startTimeMS,exit_code:n.exitCode,exit_signal:n.exitSignal}});break}case`process_send_input`:{let n=this.mustGetProcess(t.payload.pid);n.sendInput(t.payload.data),this.sendResponse(e,{id:t.id,payload:{}});break}case`set_env`:this.processManager.setEnv(t.payload.env),this.sendResponse(e,{id:t.id,payload:{}});break;case`deploy_static_files`:{if(!this.createDeploymentFromTar)throw Error(`This server does not support static file deployments!`);let n=await Xt(t.payload.path),r=await this.createDeploymentFromTar(n);this.sendResponse(e,{id:t.id,payload:{deployment_id:r}});break}case`read_file`:{let n=await i.readFile(t.payload.path),r=await Ot(n),a=!r||r?.mime===`text/plain`;if(!a){this.sendResponse(e,{id:t.id,payload:{content:n.toString(`base64`),mime_type:r?.mime,total_lines:0,lines_read:0,start_line:0}});break}let o=n.toString(`utf-8`),s=o.split(`
12
+ `);return t.from(n)},exports.decodePax=function(e){let n={};for(;e.length;){let r=0;for(;r<e.length&&e[r]!==32;)r++;let i=parseInt(t.toString(e.subarray(0,r)),10);if(!i)return n;let a=t.toString(e.subarray(r+1,i-1)),o=a.indexOf(`=`);if(o===-1)return n;n[a.slice(0,o)]=a.slice(o+1),e=e.subarray(i)}return n},exports.encode=function(e){let i=t.alloc(512),a=e.name,o=``;if(e.typeflag===5&&a[a.length-1]!==`/`&&(a+=`/`),t.byteLength(a)!==a.length)return null;for(;t.byteLength(a)>100;){let e=a.indexOf(`/`);if(e===-1)return null;o+=o?`/`+a.slice(0,e):a.slice(0,e),a=a.slice(e+1)}return t.byteLength(a)>100||t.byteLength(o)>155||e.linkname&&t.byteLength(e.linkname)>100?null:(t.write(i,a),t.write(i,p(e.mode&4095,6),100),t.write(i,p(e.uid,6),108),t.write(i,p(e.gid,6),116),h(e.size,i,124),t.write(i,p(e.mtime.getTime()/1e3|0,11),136),i[156]=48+u(e.type),e.linkname&&t.write(i,e.linkname,157),t.copy(n,i,257),t.copy(r,i,263),e.uname&&t.write(i,e.uname,265),e.gname&&t.write(i,e.gname,297),t.write(i,p(e.devmajor||0,6),329),t.write(i,p(e.devminor||0,6),337),o&&t.write(i,o,345),t.write(i,p(f(i),6),148),i)},exports.decode=function(e,t,n){let r=e[156]===0?0:e[156]-48,i=v(e,0,100,t),a=_(e,100,8),c=_(e,108,8),u=_(e,116,8),d=_(e,124,12),p=_(e,136,12),m=l(r),h=e[157]===0?null:v(e,157,100,t),g=v(e,265,32),y=v(e,297,32),b=_(e,329,8),x=_(e,337,8),S=f(e);if(S===256)return null;if(S!==_(e,148,8))throw Error(`Invalid tar header. Maybe the tar is corrupted or it needs to be gunzipped?`);if(o(e))e[345]&&(i=v(e,345,155,t)+`/`+i);else if(!s(e)&&!n)throw Error(`Invalid tar header: unknown format.`);return r===0&&i&&i[i.length-1]===`/`&&(r=5),{name:i,mode:a,uid:c,gid:u,size:d,mtime:new Date(1e3*p),type:m,linkname:h,uname:g,gname:y,devmajor:b,devminor:x,pax:null}};function o(e){return t.equals(n,e.subarray(257,263))}function s(e){return t.equals(i,e.subarray(257,263))&&t.equals(a,e.subarray(263,265))}function c(e,t,n){return typeof e==`number`?(e=~~e,e>=t?t:e>=0||(e+=t,e>=0)?e:0):n}function l(e){switch(e){case 0:return`file`;case 1:return`link`;case 2:return`symlink`;case 3:return`character-device`;case 4:return`block-device`;case 5:return`directory`;case 6:return`fifo`;case 7:return`contiguous-file`;case 72:return`pax-header`;case 55:return`pax-global-header`;case 27:return`gnu-long-link-path`;case 28:case 30:return`gnu-long-path`}return null}function u(e){switch(e){case`file`:return 0;case`link`:return 1;case`symlink`:return 2;case`character-device`:return 3;case`block-device`:return 4;case`directory`:return 5;case`fifo`:return 6;case`contiguous-file`:return 7;case`pax-header`:return 72}return 0}function d(e,t,n,r){for(;n<r;n++)if(e[n]===t)return n;return r}function f(e){let t=256;for(let n=0;n<148;n++)t+=e[n];for(let n=156;n<512;n++)t+=e[n];return t}function p(e,t){return e=e.toString(8),e.length>t?`7777777777777777777`.slice(0,t)+` `:`0000000000000000000`.slice(0,t-e.length)+e+` `}function m(e,t,n){t[n]=128;for(let r=11;r>0;r--)t[n+r]=e&255,e=Math.floor(e/256)}function h(e,n,r){e.toString(8).length>11?m(e,n,r):t.write(n,p(e,11),r)}function g(e){let t;if(e[0]===128)t=!0;else if(e[0]===255)t=!1;else return null;let n=[],r;for(r=e.length-1;r>0;r--){let i=e[r];t?n.push(i):n.push(255-i)}let i=0,a=n.length;for(r=0;r<a;r++)i+=n[r]*Math.pow(256,r);return t?i:-1*i}function _(e,n,r){if(e=e.subarray(n,n+r),n=0,e[n]&128)return g(e);{for(;n<e.length&&e[n]===32;)n++;let r=c(d(e,32,n,e.length),e.length,e.length);for(;n<r&&e[n]===0;)n++;return r===n?0:parseInt(t.toString(e.subarray(n,r)),8)}}function v(e,n,r,i){return t.toString(e.subarray(n,d(e,0,n,n+r)),i)}function y(e){let n=t.byteLength(e),r=Math.floor(Math.log(n)/Math.log(10))+1;return n+r>=Math.pow(10,r)&&r++,n+r+e}})}),Gt=O({"../../node_modules/tar-stream/extract.js":((exports,t)=>{let{Writable:n,Readable:r,getStreamError:i}=Ut(),a=Rt(),o=zt(),s=Wt(),c=o.alloc(0);var l=class{constructor(){this.buffered=0,this.shifted=0,this.queue=new a,this._offset=0}push(e){this.buffered+=e.byteLength,this.queue.push(e)}shiftFirst(e){return this._buffered===0?null:this._next(e)}shift(e){if(e>this.buffered)return null;if(e===0)return c;let t=this._next(e);if(e===t.byteLength)return t;let n=[t];for(;(e-=t.byteLength)>0;)t=this._next(e),n.push(t);return o.concat(n)}_next(e){let t=this.queue.peek(),n=t.byteLength-this._offset;if(e>=n){let e=this._offset?t.subarray(this._offset,t.byteLength):t;return this.queue.shift(),this._offset=0,this.buffered-=n,this.shifted+=n,e}return this.buffered-=e,this.shifted+=e,t.subarray(this._offset,this._offset+=e)}},u=class extends r{constructor(e,t,n){super(),this.header=t,this.offset=n,this._parent=e}_read(e){this.header.size===0&&this.push(null),this._parent._stream===this&&this._parent._update(),e(null)}_predestroy(){this._parent.destroy(i(this))}_detach(){this._parent._stream===this&&(this._parent._stream=null,this._parent._missing=p(this.header.size),this._parent._update())}_destroy(e){this._detach(),e(null)}},d=class extends n{constructor(e){super(e),e||(e={}),this._buffer=new l,this._offset=0,this._header=null,this._stream=null,this._missing=0,this._longHeader=!1,this._callback=f,this._locked=!1,this._finished=!1,this._pax=null,this._paxGlobal=null,this._gnuLongPath=null,this._gnuLongLinkPath=null,this._filenameEncoding=e.filenameEncoding||`utf-8`,this._allowUnknownFormat=!!e.allowUnknownFormat,this._unlockBound=this._unlock.bind(this)}_unlock(e){if(this._locked=!1,e){this.destroy(e),this._continueWrite(e);return}this._update()}_consumeHeader(){if(this._locked)return!1;this._offset=this._buffer.shifted;try{this._header=s.decode(this._buffer.shift(512),this._filenameEncoding,this._allowUnknownFormat)}catch(e){return this._continueWrite(e),!1}if(!this._header)return!0;switch(this._header.type){case`gnu-long-path`:case`gnu-long-link-path`:case`pax-global-header`:case`pax-header`:return this._longHeader=!0,this._missing=this._header.size,!0}return this._locked=!0,this._applyLongHeaders(),this._header.size===0||this._header.type===`directory`?(this.emit(`entry`,this._header,this._createStream(),this._unlockBound),!0):(this._stream=this._createStream(),this._missing=this._header.size,this.emit(`entry`,this._header,this._stream,this._unlockBound),!0)}_applyLongHeaders(){this._gnuLongPath&&(this._header.name=this._gnuLongPath,this._gnuLongPath=null),this._gnuLongLinkPath&&(this._header.linkname=this._gnuLongLinkPath,this._gnuLongLinkPath=null),this._pax&&(this._pax.path&&(this._header.name=this._pax.path),this._pax.linkpath&&(this._header.linkname=this._pax.linkpath),this._pax.size&&(this._header.size=parseInt(this._pax.size,10)),this._header.pax=this._pax,this._pax=null)}_decodeLongHeader(e){switch(this._header.type){case`gnu-long-path`:this._gnuLongPath=s.decodeLongPath(e,this._filenameEncoding);break;case`gnu-long-link-path`:this._gnuLongLinkPath=s.decodeLongPath(e,this._filenameEncoding);break;case`pax-global-header`:this._paxGlobal=s.decodePax(e);break;case`pax-header`:this._pax=this._paxGlobal===null?s.decodePax(e):Object.assign({},this._paxGlobal,s.decodePax(e));break}}_consumeLongHeader(){this._longHeader=!1,this._missing=p(this._header.size);let e=this._buffer.shift(this._header.size);try{this._decodeLongHeader(e)}catch(e){return this._continueWrite(e),!1}return!0}_consumeStream(){let e=this._buffer.shiftFirst(this._missing);if(e===null)return!1;this._missing-=e.byteLength;let t=this._stream.push(e);return this._missing===0?(this._stream.push(null),t&&this._stream._detach(),t&&this._locked===!1):t}_createStream(){return new u(this,this._header,this._offset)}_update(){for(;this._buffer.buffered>0&&!this.destroying;){if(this._missing>0){if(this._stream!==null){if(this._consumeStream()===!1)return;continue}if(this._longHeader===!0){if(this._missing>this._buffer.buffered)break;if(this._consumeLongHeader()===!1)return!1;continue}let e=this._buffer.shiftFirst(this._missing);e!==null&&(this._missing-=e.byteLength);continue}if(this._buffer.buffered<512)break;if(this._stream!==null||this._consumeHeader()===!1)return}this._continueWrite(null)}_continueWrite(e){let t=this._callback;this._callback=f,t(e)}_write(e,t){this._callback=t,this._buffer.push(e),this._update()}_final(e){this._finished=this._missing===0&&this._buffer.buffered===0,e(this._finished?null:Error(`Unexpected end of data`))}_predestroy(){this._continueWrite(null)}_destroy(e){this._stream&&this._stream.destroy(i(this)),e(null)}[Symbol.asyncIterator](){let e=null,t=null,n=null,r=null,i=null,a=this;return this.on(`entry`,c),this.on(`error`,t=>{e=t}),this.on(`close`,l),{[Symbol.asyncIterator](){return this},next(){return new Promise(s)},return(){return u(null)},throw(e){return u(e)}};function o(e){if(!i)return;let t=i;i=null,t(e)}function s(i,s){if(e)return s(e);if(r){i({value:r,done:!1}),r=null;return}t=i,n=s,o(null),a._finished&&t&&(t({value:void 0,done:!0}),t=n=null)}function c(e,a,o){i=o,a.on(`error`,f),t?(t({value:a,done:!1}),t=n=null):r=a}function l(){o(e),t&&(e?n(e):t({value:void 0,done:!0}),t=n=null)}function u(e){return a.destroy(e),o(e),new Promise((t,n)=>{if(a.destroyed)return t({value:void 0,done:!0});a.once(`close`,function(){e?n(e):t({value:void 0,done:!0})})})}}};t.exports=function(e){return new d(e)};function f(){}function p(e){return e&=511,e&&512-e}})}),Kt=O({"../../node_modules/tar-stream/constants.js":((exports,t)=>{let n={S_IFMT:61440,S_IFDIR:16384,S_IFCHR:8192,S_IFBLK:24576,S_IFIFO:4096,S_IFLNK:40960};try{t.exports=j(`fs`).constants||n}catch{t.exports=n}})}),qt=O({"../../node_modules/tar-stream/pack.js":((exports,t)=>{let{Readable:n,Writable:r,getStreamError:i}=Ut(),a=zt(),o=Kt(),s=Wt(),c=a.alloc(1024);var l=class extends r{constructor(e,t,n){super({mapWritable:m,eagerOpen:!0}),this.written=0,this.header=t,this._callback=n,this._linkname=null,this._isLinkname=t.type===`symlink`&&!t.linkname,this._isVoid=t.type!==`file`&&t.type!==`contiguous-file`,this._finished=!1,this._pack=e,this._openCallback=null,this._pack._stream===null?this._pack._stream=this:this._pack._pending.push(this)}_open(e){this._openCallback=e,this._pack._stream===this&&this._continueOpen()}_continuePack(e){if(this._callback===null)return;let t=this._callback;this._callback=null,t(e)}_continueOpen(){this._pack._stream===null&&(this._pack._stream=this);let e=this._openCallback;if(this._openCallback=null,e!==null){if(this._pack.destroying)return e(Error(`pack stream destroyed`));if(this._pack._finalized)return e(Error(`pack stream is already finalized`));this._pack._stream=this,this._isLinkname||this._pack._encode(this.header),this._isVoid&&(this._finish(),this._continuePack(null)),e(null)}}_write(e,t){if(this._isLinkname)return this._linkname=this._linkname?a.concat([this._linkname,e]):e,t(null);if(this._isVoid)return e.byteLength>0?t(Error(`No body allowed for this entry`)):t();if(this.written+=e.byteLength,this._pack.push(e))return t();this._pack._drain=t}_finish(){this._finished||(this._finished=!0,this._isLinkname&&(this.header.linkname=this._linkname?a.toString(this._linkname,`utf-8`):``,this._pack._encode(this.header)),p(this._pack,this.header.size),this._pack._done(this))}_final(e){if(this.written!==this.header.size)return e(Error(`Size mismatch`));this._finish(),e(null)}_getError(){return i(this)||Error(`tar entry destroyed`)}_predestroy(){this._pack.destroy(this._getError())}_destroy(e){this._pack._done(this),this._continuePack(this._finished?null:this._getError()),e()}},u=class extends n{constructor(e){super(e),this._drain=f,this._finalized=!1,this._finalizing=!1,this._pending=[],this._stream=null}entry(e,t,n){if(this._finalized||this.destroying)throw Error(`already finalized or destroyed`);typeof t==`function`&&(n=t,t=null),n||(n=f),(!e.size||e.type===`symlink`)&&(e.size=0),e.type||(e.type=d(e.mode)),e.mode||(e.mode=e.type===`directory`?493:420),e.uid||(e.uid=0),e.gid||(e.gid=0),e.mtime||(e.mtime=new Date),typeof t==`string`&&(t=a.from(t));let r=new l(this,e,n);return a.isBuffer(t)?(e.size=t.byteLength,r.write(t),r.end(),r):(r._isVoid,r)}finalize(){if(this._stream||this._pending.length>0){this._finalizing=!0;return}this._finalized||(this._finalized=!0,this.push(c),this.push(null))}_done(e){e===this._stream&&(this._stream=null,this._finalizing&&this.finalize(),this._pending.length&&this._pending.shift()._continueOpen())}_encode(e){if(!e.pax){let t=s.encode(e);if(t){this.push(t);return}}this._encodePax(e)}_encodePax(e){let t=s.encodePax({name:e.name,linkname:e.linkname,pax:e.pax}),n={name:`PaxHeader`,mode:e.mode,uid:e.uid,gid:e.gid,size:t.byteLength,mtime:e.mtime,type:`pax-header`,linkname:e.linkname&&`PaxHeader`,uname:e.uname,gname:e.gname,devmajor:e.devmajor,devminor:e.devminor};this.push(s.encode(n)),this.push(t),p(this,t.byteLength),n.size=e.size,n.type=e.type,this.push(s.encode(n))}_doDrain(){let e=this._drain;this._drain=f,e()}_predestroy(){let e=i(this);for(this._stream&&this._stream.destroy(e);this._pending.length;){let t=this._pending.shift();t.destroy(e),t._continueOpen()}this._doDrain()}_read(e){this._doDrain(),e()}};t.exports=function(e){return new u(e)};function d(e){switch(e&o.S_IFMT){case o.S_IFBLK:return`block-device`;case o.S_IFCHR:return`character-device`;case o.S_IFDIR:return`directory`;case o.S_IFIFO:return`fifo`;case o.S_IFLNK:return`symlink`}return`file`}function f(){}function p(e,t){t&=511,t&&e.push(c.subarray(0,512-t))}function m(e){return a.isBuffer(e)?e:a.from(e)}})}),Jt=O({"../../node_modules/tar-stream/index.js":(exports=>{exports.extract=Gt(),exports.pack=qt()})}),Yt=A(Jt(),1);const Xt=async(e,t)=>{let{maxBytes:r=50*1024*1024}=t??{},i=await o.stat(e);if(!i.isDirectory())throw Error(`Path is not a directory: ${e}`);let a=Yt.pack(),s=async(e,t=``)=>{let r=await o.readdir(e,{withFileTypes:!0});for(let i of r){let r=`${e}/${i.name}`,c=t?`${t}/${i.name}`:i.name;if(i.isDirectory()){a.entry({name:`${c}/`,type:`directory`}),await s(r,c);continue}if(i.isSymbolicLink?.()){let e=await o.readlink(r);a.entry({name:c,type:`symlink`,linkname:e});continue}if(i.isFile()){let e=await o.stat(r);await new Promise((t,i)=>{let o=n(r),s=a.entry({name:c,size:e.size,mode:e.mode,mtime:e.mtime},e=>{e&&i(e)});o.on(`error`,i),o.on(`data`,e=>s.write(e)),o.on(`end`,()=>{s.end(),t()})});continue}}};(async()=>{try{await s(e),a.finalize()}catch(e){a.destroy(e)}})();let c=a,l=0,u=!1;return new ReadableStream({start(e){let t=t=>{if(!u){if(l+=t.length,l>r){u=!0,e.error(Error(`Archive exceeds size limit (${r} bytes). Emitted=${l} bytes.`));try{c.destroy()}catch{}return}e.enqueue(new Uint8Array(t))}},n=t=>{u||(u=!0,e.error(t instanceof Error?t:Error(String(t))))},i=()=>{u||(u=!0,e.close())};c.on(`data`,t),c.once(`error`,n),c.once(`end`,i)},cancel(){try{c.destroy()}catch{}}})};var Zt=O({"../../node_modules/dotenv/package.json":((exports,t)=>{t.exports={name:`dotenv`,version:`17.2.3`,description:`Loads environment variables from .env file`,main:`lib/main.js`,types:`lib/main.d.ts`,exports:{".":{types:`./lib/main.d.ts`,require:`./lib/main.js`,default:`./lib/main.js`},"./config":`./config.js`,"./config.js":`./config.js`,"./lib/env-options":`./lib/env-options.js`,"./lib/env-options.js":`./lib/env-options.js`,"./lib/cli-options":`./lib/cli-options.js`,"./lib/cli-options.js":`./lib/cli-options.js`,"./package.json":`./package.json`},scripts:{"dts-check":`tsc --project tests/types/tsconfig.json`,lint:`standard`,pretest:`npm run lint && npm run dts-check`,test:`tap run tests/**/*.js --allow-empty-coverage --disable-coverage --timeout=60000`,"test:coverage":`tap run tests/**/*.js --show-full-coverage --timeout=60000 --coverage-report=text --coverage-report=lcov`,prerelease:`npm test`,release:`standard-version`},repository:{type:`git`,url:`git://github.com/motdotla/dotenv.git`},homepage:`https://github.com/motdotla/dotenv#readme`,funding:`https://dotenvx.com`,keywords:[`dotenv`,`env`,`.env`,`environment`,`variables`,`config`,`settings`],readmeFilename:`README.md`,license:`BSD-2-Clause`,devDependencies:{"@types/node":`^18.11.3`,decache:`^4.6.2`,sinon:`^14.0.1`,standard:`^17.0.0`,"standard-version":`^9.5.0`,tap:`^19.2.0`,typescript:`^4.8.4`},engines:{node:`>=12`},browser:{fs:!1}}})}),Qt=O({"../../node_modules/dotenv/lib/main.js":((exports,t)=>{let n=j(`fs`),r=j(`path`),i=j(`os`),a=j(`crypto`),o=Zt(),s=o.version,c=[`🔐 encrypt with Dotenvx: https://dotenvx.com`,`🔐 prevent committing .env to code: https://dotenvx.com/precommit`,`🔐 prevent building .env in docker: https://dotenvx.com/prebuild`,`📡 add observability to secrets: https://dotenvx.com/ops`,`👥 sync secrets across teammates & machines: https://dotenvx.com/ops`,`🗂️ backup and recover secrets: https://dotenvx.com/ops`,`✅ audit secrets and track compliance: https://dotenvx.com/ops`,`🔄 add secrets lifecycle management: https://dotenvx.com/ops`,`🔑 add access controls to secrets: https://dotenvx.com/ops`,"🛠️ run anywhere with `dotenvx run -- yourcommand`",`⚙️ specify custom .env file path with { path: '/custom/path/.env' }`,`⚙️ enable debug logging with { debug: true }`,`⚙️ override existing env vars with { override: true }`,`⚙️ suppress all logs with { quiet: true }`,`⚙️ write to custom object with { processEnv: myObject }`,`⚙️ load multiple .env files with { path: ['.env.local', '.env'] }`];function l(){return c[Math.floor(Math.random()*c.length)]}function u(e){return typeof e==`string`?![`false`,`0`,`no`,`off`,``].includes(e.toLowerCase()):!!e}function d(){return process.stdout.isTTY}function f(e){return d()?`\x1b[2m${e}\x1b[0m`:e}let p=/(?:^|^)\s*(?:export\s+)?([\w.-]+)(?:\s*=\s*?|:\s+?)(\s*'(?:\\'|[^'])*'|\s*"(?:\\"|[^"])*"|\s*`(?:\\`|[^`])*`|[^#\r\n]+)?\s*(?:#.*)?(?:$|$)/gm;function m(e){let t={},n=e.toString();n=n.replace(/\r\n?/gm,`
13
+ `);let r;for(;(r=p.exec(n))!=null;){let e=r[1],n=r[2]||``;n=n.trim();let i=n[0];n=n.replace(/^(['"`])([\s\S]*)\1$/gm,`$2`),i===`"`&&(n=n.replace(/\\n/g,`
14
+ `),n=n.replace(/\\r/g,`\r`)),t[e]=n}return t}function h(e){e=e||{};let t=x(e);e.path=t;let n=O.configDotenv(e);if(!n.parsed){let e=Error(`MISSING_DATA: Cannot parse ${t} for an unknown reason`);throw e.code=`MISSING_DATA`,e}let r=y(e).split(`,`),i=r.length,a;for(let e=0;e<i;e++)try{let t=r[e].trim(),i=b(n,t);a=O.decrypt(i.ciphertext,i.key);break}catch(t){if(e+1>=i)throw t}return O.parse(a)}function g(e){console.error(`[dotenv@${s}][WARN] ${e}`)}function _(e){console.log(`[dotenv@${s}][DEBUG] ${e}`)}function v(e){console.log(`[dotenv@${s}] ${e}`)}function y(e){return e&&e.DOTENV_KEY&&e.DOTENV_KEY.length>0?e.DOTENV_KEY:process.env.DOTENV_KEY&&process.env.DOTENV_KEY.length>0?process.env.DOTENV_KEY:``}function b(e,t){let n;try{n=new URL(t)}catch(e){if(e.code===`ERR_INVALID_URL`){let e=Error(`INVALID_DOTENV_KEY: Wrong format. Must be in valid uri format like dotenv://:key_1234@dotenvx.com/vault/.env.vault?environment=development`);throw e.code=`INVALID_DOTENV_KEY`,e}throw e}let r=n.password;if(!r){let e=Error(`INVALID_DOTENV_KEY: Missing key part`);throw e.code=`INVALID_DOTENV_KEY`,e}let i=n.searchParams.get(`environment`);if(!i){let e=Error(`INVALID_DOTENV_KEY: Missing environment part`);throw e.code=`INVALID_DOTENV_KEY`,e}let a=`DOTENV_VAULT_${i.toUpperCase()}`,o=e.parsed[a];if(!o){let e=Error(`NOT_FOUND_DOTENV_ENVIRONMENT: Cannot locate environment ${a} in your .env.vault file.`);throw e.code=`NOT_FOUND_DOTENV_ENVIRONMENT`,e}return{ciphertext:o,key:r}}function x(e){let t=null;if(e&&e.path&&e.path.length>0)if(Array.isArray(e.path))for(let r of e.path)n.existsSync(r)&&(t=r.endsWith(`.vault`)?r:`${r}.vault`);else t=e.path.endsWith(`.vault`)?e.path:`${e.path}.vault`;else t=r.resolve(process.cwd(),`.env.vault`);return n.existsSync(t)?t:null}function S(e){return e[0]===`~`?r.join(i.homedir(),e.slice(1)):e}function C(e){let t=u(process.env.DOTENV_CONFIG_DEBUG||e&&e.debug),n=u(process.env.DOTENV_CONFIG_QUIET||e&&e.quiet);(t||!n)&&v(`Loading env from encrypted .env.vault`);let r=O._parseVault(e),i=process.env;return e&&e.processEnv!=null&&(i=e.processEnv),O.populate(i,r,e),{parsed:r}}function w(e){let t=r.resolve(process.cwd(),`.env`),i=`utf8`,a=process.env;e&&e.processEnv!=null&&(a=e.processEnv);let o=u(a.DOTENV_CONFIG_DEBUG||e&&e.debug),s=u(a.DOTENV_CONFIG_QUIET||e&&e.quiet);e&&e.encoding?i=e.encoding:o&&_(`No encoding is specified. UTF-8 is used by default`);let c=[t];if(e&&e.path)if(!Array.isArray(e.path))c=[S(e.path)];else{c=[];for(let t of e.path)c.push(S(t))}let d,p={};for(let t of c)try{let r=O.parse(n.readFileSync(t,{encoding:i}));O.populate(p,r,e)}catch(e){o&&_(`Failed to load ${t} ${e.message}`),d=e}let m=O.populate(a,p,e);if(o=u(a.DOTENV_CONFIG_DEBUG||o),s=u(a.DOTENV_CONFIG_QUIET||s),o||!s){let e=Object.keys(m).length,t=[];for(let e of c)try{let n=r.relative(process.cwd(),e);t.push(n)}catch(t){o&&_(`Failed to load ${e} ${t.message}`),d=t}v(`injecting env (${e}) from ${t.join(`,`)} ${f(`-- tip: ${l()}`)}`)}return d?{parsed:p,error:d}:{parsed:p}}function T(e){if(y(e).length===0)return O.configDotenv(e);let t=x(e);return t?O._configVault(e):(g(`You set DOTENV_KEY but you are missing a .env.vault file at ${t}. Did you forget to build it?`),O.configDotenv(e))}function E(e,t){let n=Buffer.from(t.slice(-64),`hex`),r=Buffer.from(e,`base64`),i=r.subarray(0,12),o=r.subarray(-16);r=r.subarray(12,-16);try{let e=a.createDecipheriv(`aes-256-gcm`,n,i);return e.setAuthTag(o),`${e.update(r)}${e.final()}`}catch(e){let t=e instanceof RangeError,n=e.message===`Invalid key length`,r=e.message===`Unsupported state or unable to authenticate data`;if(t||n){let e=Error(`INVALID_DOTENV_KEY: It must be 64 characters long (or more)`);throw e.code=`INVALID_DOTENV_KEY`,e}else if(r){let e=Error(`DECRYPTION_FAILED: Please check your DOTENV_KEY`);throw e.code=`DECRYPTION_FAILED`,e}else throw e}}function D(e,t,n={}){let r=!!(n&&n.debug),i=!!(n&&n.override),a={};if(typeof t!=`object`){let e=Error(`OBJECT_REQUIRED: Please check the processEnv argument being passed to populate`);throw e.code=`OBJECT_REQUIRED`,e}for(let n of Object.keys(t))Object.prototype.hasOwnProperty.call(e,n)?(i===!0&&(e[n]=t[n],a[n]=t[n]),r&&_(i===!0?`"${n}" is already defined and WAS overwritten`:`"${n}" is already defined and was NOT overwritten`)):(e[n]=t[n],a[n]=t[n]);return a}let O={configDotenv:w,_configVault:C,_parseVault:h,config:T,decrypt:E,parse:m,populate:D};t.exports.configDotenv=O.configDotenv,t.exports._configVault=O._configVault,t.exports._parseVault=O._parseVault,t.exports.config=O.config,t.exports.decrypt=O.decrypt,t.exports.parse=O.parse,t.exports.populate=O.populate,t.exports=O})}),$t=A(Qt(),1);const en=(e,t)=>e.length<=t?e:e.slice(e.length-t),tn=(e,t)=>{if(e.length===0)return{lines:[],truncated:!1};let n=0,r=e.length;for(let i=e.length-1;i>=0;i--){let a=e[i].length;if(n+a>t&&r!==e.length)break;n+=a,r=i}return r===0?{lines:e,truncated:!1}:{lines:e.slice(r),truncated:!0}};var nn=class{multiplexer;notificationStream;decoder=new TextDecoder;encoder=new TextEncoder;processManager;createDeploymentFromTar;proxyOnly;fetchProxyRequest;constructor(e){this.createDeploymentFromTar=e.createDeploymentFromTar,this.proxyOnly=e.proxyOnly,this.fetchProxyRequest=e.fetchProxyRequest,this.multiplexer=new R({send:t=>{e.send(t)}}),this.multiplexer.onStream(e=>{this.handleStream(e)}),this.notificationStream=this.multiplexer.createStream(),this.processManager=new Ft({env:e.env,nodePty:e.nodePty}),this.processManager.onSpawn(e=>{let t=()=>{this.sendNotification({type:`process_status`,payload:{status:this.processManager.status(e.pid)}})};t(),e.terminal.onTitleChange(()=>{t()}),e.onExit(()=>{this.sendNotification({type:`process_status`,payload:{status:this.processManager.status(e.pid)}})}),e.onOutput(t=>{let n=I.getMaxPayloadSize()-1;for(let r=0;r<t.length;r+=n){let i=t.slice(r,r+n);this.sendNotification({type:`process_output`,payload:{pid:e.pid,output:i}})}})})}handleMessage(e){this.multiplexer.handleMessage(e)}handleStream(e){let t=new AbortController;e.onClose(()=>{t.abort()}),e.onData(n=>{let r=n[0],i=n.subarray(1);switch(r){case u.REQUEST:{let n=JSON.parse(this.decoder.decode(i));if(this.proxyOnly){this.sendResponse(e,{id:n.id,error:`This server is in proxy only mode.`});return}this.handleRequest(e,n,t.signal).catch(t=>{this.sendResponse(e,{id:n.id,error:t instanceof Error?t.message:String(t)})});break}case u.PROXY_INIT:{let t=f[u.PROXY_INIT].safeParse(JSON.parse(this.decoder.decode(i)));if(!t.success)throw Error(`Invalid proxy init message`);let n;n=t.data.headers.upgrade===`websocket`?this.handleProxyWebSocket(e,t.data):this.handleProxyRequest(e,t.data),n.catch(t=>{e.error(t.message)});break}}})}async handleProxyWebSocket(t,n){let r=new URL(n.url);r.protocol===`http:`?r.protocol=`ws:`:r.protocol===`https:`&&(r.protocol=`wss:`);let i=new e.default(r.toString(),n.headers[`sec-websocket-protocol`]?n.headers[`sec-websocket-protocol`]:void 0,{headers:n.headers,perMessageDeflate:!1});i.addEventListener(`open`,()=>{let e={status_code:101,status_message:`Switching Protocols`,headers:{}};t.writeTyped(d.PROXY_INIT,this.encoder.encode(JSON.stringify(e)))}),i.addEventListener(`message`,e=>{t.disposed||t.writeTyped(d.PROXY_WEBSOCKET_MESSAGE,c(e.data,this.encoder))}),i.addEventListener(`close`,e=>{if(t.disposed)return;let n={code:e.code,reason:e.reason};t.writeTyped(d.PROXY_WEBSOCKET_CLOSE,this.encoder.encode(JSON.stringify(n))),t.close()}),i.addEventListener(`error`,e=>{console.log(`err`,e)}),t.onClose(()=>{i.close()}),t.onError(e=>{i.close(1011,e)}),t.onData(e=>{let n=e.subarray(1);switch(e[0]){case u.PROXY_WEBSOCKET_MESSAGE:{let e=l(n,this.decoder);i.send(e);break}case u.PROXY_WEBSOCKET_CLOSE:{let e=f[u.PROXY_WEBSOCKET_CLOSE].safeParse(JSON.parse(this.decoder.decode(n)));if(!e.success)throw Error(`Invalid proxy websocket close message`);try{i.close(e.data.code,e.data.reason)}catch(t){console.error(`Error closing websocket`,t,e.data)}break}default:t.error(`Unexpected message type: ${e[0]}`)}})}async handleProxyRequest(e,t){let n,r;if(t.method!==`GET`&&t.method!==`HEAD`&&t.method!==`OPTIONS`){let e=new TransformStream;n=e.writable.getWriter(),r=e.readable}e.onData(t=>{switch(t[0]){case u.PROXY_BODY:if(n){let e=t.subarray(1);e.length===0?n.close():n.write(e)}break;default:e.error(`Unexpected message type: ${t[0]}`)}});let i={headers:t.headers,method:t.method,body:r},a;a=this.fetchProxyRequest?await this.fetchProxyRequest(t.url,i):await fetch(t.url,i);let o={};a.headers.forEach((e,t)=>{o[t]=e});let s={headers:o,status_code:a.status,status_message:a.statusText};e.writeTyped(d.PROXY_INIT,this.encoder.encode(JSON.stringify(s)));let c=a.headers.get(`content-length`),l=c?parseInt(c):0,f=I.getMaxPayloadSize()-1;if(l>=f){if(!a.body){e.close();return}let t=a.body.getReader();try{for(;;){let{done:n,value:r}=await t.read();if(n)break;if(r){let t=0;for(;t<r.length;){let n=Math.min(f,r.length-t),i=r.subarray(t,t+n);e.writeTyped(d.PROXY_DATA,i),t+=n}}}}finally{t.releaseLock()}}else a.body&&await a.body.pipeTo(new WritableStream({write:t=>{e.writeTyped(d.PROXY_DATA,t)}}));e.close()}async handleRequest(e,t,n){let r=p[t.type],a=r.safeParse(t.payload);if(!a.success)throw Error(`Invalid request payload: ${a.error.message}`);switch(t.type){case`process_execute`:{if(t.payload.env_file){let e=await i.readFile(t.payload.env_file,`utf-8`),n=(0,$t.parse)(e);t.payload.env={...t.payload.env,...n}}let n=this.processManager.execute(t.payload.command,t.payload.args,{cwd:t.payload.cwd,env:t.payload.env});this.sendResponse(e,{id:t.id,payload:{pid:n.pid}});break}case`process_wait`:this.handleProcessWait(e,t,n);break;case`process_kill`:{let n=this.mustGetProcess(t.payload.pid);n.kill(t.payload.signal),this.sendResponse(e,{id:t.id,payload:{}});break}case`process_list`:this.sendResponse(e,{id:t.id,payload:{processes:this.processManager.list(t.payload.include_dead??!1)}});break;case`process_read_plain_output`:{let n=this.mustGetProcess(t.payload.pid),r=this.processManager.readPlainOutput(t.payload.pid,t.payload.start_line,t.payload.end_line),i=tn(r.lines,256e3);this.sendResponse(e,{id:t.id,payload:{lines:i.lines,total_lines:r.totalLines,duration_ms:Date.now()-n.startTimeMS,exit_code:n.exitCode,exit_signal:n.exitSignal}});break}case`process_send_input`:{let n=this.mustGetProcess(t.payload.pid);n.sendInput(t.payload.data),this.sendResponse(e,{id:t.id,payload:{}});break}case`set_env`:this.processManager.setEnv(t.payload.env),this.sendResponse(e,{id:t.id,payload:{}});break;case`deploy_static_files`:{if(!this.createDeploymentFromTar)throw Error(`This server does not support static file deployments!`);let n=await Xt(t.payload.path),r=await this.createDeploymentFromTar(n);this.sendResponse(e,{id:t.id,payload:{deployment_id:r}});break}case`read_file`:{let n=await i.readFile(t.payload.path),r=await Ot(n),a=!r||r?.mime===`text/plain`;if(!a){this.sendResponse(e,{id:t.id,payload:{content:n.toString(`base64`),mime_type:r?.mime,total_lines:0,lines_read:0,start_line:0}});break}let o=n.toString(`utf-8`),s=o.split(`
13
15
  `),c=Math.max(0,(t.payload.line_start??1)-1),l=Math.min(s.length,t.payload.line_end??s.length),u=s.slice(c,l);this.sendResponse(e,{id:t.id,payload:{content:u.join(`
14
- `),mime_type:`text/plain`,total_lines:s.length,lines_read:u.length,start_line:c}});break}case`write_file`:t.payload.base64?await i.writeFile(t.payload.path,Buffer.from(t.payload.content,`base64`)):await i.writeFile(t.payload.path,t.payload.content),typeof t.payload.mode==`number`&&await i.chmod(t.payload.path,t.payload.mode),this.sendResponse(e,{id:t.id,payload:{}});break;case`read_directory`:{let n=await i.readdir(t.payload.path,{withFileTypes:!0});this.sendResponse(e,{id:t.id,payload:{entries:n.map(e=>({name:e.name,type:e.isDirectory()?`directory`:e.isSymbolicLink()?`symlink`:`file`}))}});break}default:throw Error(`Unknown request type: ${t.type}`)}}sendResponse(e,t){e.writeTyped(d.RESPONSE,this.encoder.encode(JSON.stringify(t)))}sendNotification(e){this.notificationStream.write(new Uint8Array([d.NOTIFICATION,...this.encoder.encode(JSON.stringify(e))]))}handleProcessWait(e,t,n){let r=t.payload,i=this.mustGetProcess(r.pid),a,o,s=!1,c,l;typeof r.timeout_ms==`number`&&(l=setTimeout(()=>{u()},r.timeout_ms));let u=()=>{if(s||(s=!0,a&&a.dispose(),o&&o.dispose(),l&&clearTimeout(l),c&&clearTimeout(c),n?.aborted))return;let i=this.processManager.status(r.pid),u=this.processManager.readPlainOutput(i.pid),d=Zt(this.processManager.readANSIOutput(i.pid),64e3),f=Qt(u.lines,256e3);this.sendResponse(e,{id:t.id,payload:{...i,ansi_output:d,plain_output:{lines:f.lines,total_lines:u.totalLines}}})};if(typeof i.exitCode==`number`||typeof i.exitSignal==`number`){u();return}a=i.onOutput(()=>{c&&clearTimeout(c),typeof r.output_idle_timeout_ms==`number`&&(c=setTimeout(()=>{u()},r.output_idle_timeout_ms))}),o=i.onExit(()=>{setTimeout(()=>{u()},10)}),n.addEventListener(`abort`,()=>{u()})}mustGetProcess(e){let t=this.processManager.getProcess(e);if(!t)throw Error(`Process ${e} not found`);return t}},en=class{listeners=[];get event(){return e=>(this.listeners.push(e),{dispose:()=>{this.listeners=this.listeners.filter(t=>t!==e)}})}emit(e){for(let t=this.listeners.length-1;t>=0;t--)this.listeners[t]?.(e)}dispose(){this.listeners=[]}};export{en as Emitter,R as Multiplexer,$t as Server};
16
+ `),mime_type:`text/plain`,total_lines:s.length,lines_read:u.length,start_line:c}});break}case`write_file`:t.payload.base64?await i.writeFile(t.payload.path,Buffer.from(t.payload.content,`base64`)):await i.writeFile(t.payload.path,t.payload.content),typeof t.payload.mode==`number`&&await i.chmod(t.payload.path,t.payload.mode),this.sendResponse(e,{id:t.id,payload:{}});break;case`read_directory`:{let n=await i.readdir(t.payload.path,{withFileTypes:!0});this.sendResponse(e,{id:t.id,payload:{entries:n.map(e=>({name:e.name,type:e.isDirectory()?`directory`:e.isSymbolicLink()?`symlink`:`file`}))}});break}default:throw Error(`Unknown request type: ${t.type}`)}}sendResponse(e,t){e.writeTyped(d.RESPONSE,this.encoder.encode(JSON.stringify(t)))}sendNotification(e){this.notificationStream.write(new Uint8Array([d.NOTIFICATION,...this.encoder.encode(JSON.stringify(e))]))}handleProcessWait(e,t,n){let r=t.payload,i=this.mustGetProcess(r.pid),a,o,s=!1,c,l;typeof r.timeout_ms==`number`&&(l=setTimeout(()=>{u()},r.timeout_ms));let u=()=>{if(s||(s=!0,a&&a.dispose(),o&&o.dispose(),l&&clearTimeout(l),c&&clearTimeout(c),n?.aborted))return;let i=this.processManager.status(r.pid),u=this.processManager.readPlainOutput(i.pid),d=en(this.processManager.readANSIOutput(i.pid),64e3),f=tn(u.lines,256e3);this.sendResponse(e,{id:t.id,payload:{...i,ansi_output:d,plain_output:{lines:f.lines,total_lines:u.totalLines}}})};if(typeof i.exitCode==`number`||typeof i.exitSignal==`number`){u();return}a=i.onOutput(()=>{c&&clearTimeout(c),typeof r.output_idle_timeout_ms==`number`&&(c=setTimeout(()=>{u()},r.output_idle_timeout_ms))}),o=i.onExit(()=>{setTimeout(()=>{u()},10)}),n.addEventListener(`abort`,()=>{u()})}mustGetProcess(e){let t=this.processManager.getProcess(e);if(!t)throw Error(`Process ${e} not found`);return t}},rn=class{listeners=[];get event(){return e=>(this.listeners.push(e),{dispose:()=>{this.listeners=this.listeners.filter(t=>t!==e)}})}emit(e){for(let t=this.listeners.length-1;t>=0;t--)this.listeners[t]?.(e)}dispose(){this.listeners=[]}};export{rn as Emitter,R as Multiplexer,nn as Server};
@@ -0,0 +1,9 @@
1
+ import{__commonJSMin as e,__require as t}from"./chunk-ByIbJXPc.js";import n,{dirname as r,join as i}from"path";import{existsSync as a}from"fs";import{builtinModules as o}from"module";import{mkdir as s,rm as c,stat as l,writeFile as u}from"fs/promises";function d(e){return async t=>{let r=await import(`esbuild`),i=await r.context({entryPoints:[t.entry],outdir:t.outdir,bundle:!0,write:!1,logLevel:`silent`,format:`esm`,platform:`node`,target:`node22`,sourcemap:!1,mainFields:[`module`,`main`],conditions:[`import`,`module`],plugins:[{name:`blink-esm-require-to-import`,setup(e){e.onEnd(t=>{e.initialOptions.format!==`esm`||e.initialOptions.platform!==`node`||t.outputFiles?.forEach(e=>{if(e.path.endsWith(`.js`)||e.path.endsWith(`.mjs`)){let t=Buffer.from(e.contents).toString(`utf-8`),n=new Map,r=RegExp(`\\b__require\\("(${o.join(`|`)})"\\)`,`gm`);if(t=t.replace(r,(e,t)=>{let r=`__import_${t.toUpperCase().replace(/-/g,`_`)}`;return n.set(t,r),r}),n.size>0){let e=Array.from(n.entries()).map(([e,t])=>`import ${t} from "${e}";`).join(`
2
+ `);t=e+`
3
+
4
+ `+t}e.contents=Buffer.from(t,`utf-8`)}})})}},{name:`blink-dev-server`,setup(e){let r;e.onStart(()=>{t.onStart(),r=performance.now()}),e.onEnd(async e=>{await c(t.outdir,{recursive:!0,force:!0}),await s(t.outdir,{recursive:!0});let a=e.outputFiles?.map(e=>({path:e.path,contents:e.contents}))??[];a.push({path:n.resolve(t.outdir,`package.json`),contents:Buffer.from(JSON.stringify({type:`module`},null,2),`utf-8`)});for(let e of a)await u(e.path,e.contents);e.errors.length>0?t.onResult({error:{message:e.errors.map(e=>`${e.text} (${e.location?.file})`).join(`
5
+ `)}}):t.onResult({entry:n.resolve(t.outdir,n.basename(t.entry).replace(`.ts`,`.js`)),duration:performance.now()-r,outdir:t.outdir,warnings:e.warnings.map(e=>({message:e.text,file:e.location?.file}))}),t.watch||(i.dispose(),i.cancel())})}}],...e});await i.watch()}}function f(e){let r=[`blink.config.ts`],i;for(let o of r){let r=n.resolve(e,o);if(a(r)){let e=t(r);if(e.default){i={...e.default};break}}}if(i||(i={}),!i.entry){let t=[`src/agent.ts`,`src/agent.js`,`agent.ts`,`agent.js`];for(let r of t){let t=n.resolve(e,r);if(a(t)){i.entry=t;break}}if(!i.entry)throw Error(`Agent entrypoint not found.
6
+
7
+ Try creating "agent.ts" or specify "entry" in a blink.config.ts file.`)}return i.outdir||(i.outdir=n.resolve(e,`.blink/build`)),i.build||(i.build=d()),i}var p=e(((exports,t)=>{t.exports={name:`dotenv`,version:`17.2.3`,description:`Loads environment variables from .env file`,main:`lib/main.js`,types:`lib/main.d.ts`,exports:{".":{types:`./lib/main.d.ts`,require:`./lib/main.js`,default:`./lib/main.js`},"./config":`./config.js`,"./config.js":`./config.js`,"./lib/env-options":`./lib/env-options.js`,"./lib/env-options.js":`./lib/env-options.js`,"./lib/cli-options":`./lib/cli-options.js`,"./lib/cli-options.js":`./lib/cli-options.js`,"./package.json":`./package.json`},scripts:{"dts-check":`tsc --project tests/types/tsconfig.json`,lint:`standard`,pretest:`npm run lint && npm run dts-check`,test:`tap run tests/**/*.js --allow-empty-coverage --disable-coverage --timeout=60000`,"test:coverage":`tap run tests/**/*.js --show-full-coverage --timeout=60000 --coverage-report=text --coverage-report=lcov`,prerelease:`npm test`,release:`standard-version`},repository:{type:`git`,url:`git://github.com/motdotla/dotenv.git`},homepage:`https://github.com/motdotla/dotenv#readme`,funding:`https://dotenvx.com`,keywords:[`dotenv`,`env`,`.env`,`environment`,`variables`,`config`,`settings`],readmeFilename:`README.md`,license:`BSD-2-Clause`,devDependencies:{"@types/node":`^18.11.3`,decache:`^4.6.2`,sinon:`^14.0.1`,standard:`^17.0.0`,"standard-version":`^9.5.0`,tap:`^19.2.0`,typescript:`^4.8.4`},engines:{node:`>=12`},browser:{fs:!1}}})),m=e(((exports,n)=>{let r=t(`fs`),i=t(`path`),a=t(`os`),o=t(`crypto`),s=p(),c=s.version,l=[`🔐 encrypt with Dotenvx: https://dotenvx.com`,`🔐 prevent committing .env to code: https://dotenvx.com/precommit`,`🔐 prevent building .env in docker: https://dotenvx.com/prebuild`,`📡 add observability to secrets: https://dotenvx.com/ops`,`👥 sync secrets across teammates & machines: https://dotenvx.com/ops`,`🗂️ backup and recover secrets: https://dotenvx.com/ops`,`✅ audit secrets and track compliance: https://dotenvx.com/ops`,`🔄 add secrets lifecycle management: https://dotenvx.com/ops`,`🔑 add access controls to secrets: https://dotenvx.com/ops`,"🛠️ run anywhere with `dotenvx run -- yourcommand`",`⚙️ specify custom .env file path with { path: '/custom/path/.env' }`,`⚙️ enable debug logging with { debug: true }`,`⚙️ override existing env vars with { override: true }`,`⚙️ suppress all logs with { quiet: true }`,`⚙️ write to custom object with { processEnv: myObject }`,`⚙️ load multiple .env files with { path: ['.env.local', '.env'] }`];function u(){return l[Math.floor(Math.random()*l.length)]}function d(e){return typeof e==`string`?![`false`,`0`,`no`,`off`,``].includes(e.toLowerCase()):!!e}function f(){return process.stdout.isTTY}function m(e){return f()?`\x1b[2m${e}\x1b[0m`:e}let h=/(?:^|^)\s*(?:export\s+)?([\w.-]+)(?:\s*=\s*?|:\s+?)(\s*'(?:\\'|[^'])*'|\s*"(?:\\"|[^"])*"|\s*`(?:\\`|[^`])*`|[^#\r\n]+)?\s*(?:#.*)?(?:$|$)/gm;function g(e){let t={},n=e.toString();n=n.replace(/\r\n?/gm,`
8
+ `);let r;for(;(r=h.exec(n))!=null;){let e=r[1],n=r[2]||``;n=n.trim();let i=n[0];n=n.replace(/^(['"`])([\s\S]*)\1$/gm,`$2`),i===`"`&&(n=n.replace(/\\n/g,`
9
+ `),n=n.replace(/\\r/g,`\r`)),t[e]=n}return t}function _(e){e=e||{};let t=C(e);e.path=t;let n=A.configDotenv(e);if(!n.parsed){let e=Error(`MISSING_DATA: Cannot parse ${t} for an unknown reason`);throw e.code=`MISSING_DATA`,e}let r=x(e).split(`,`),i=r.length,a;for(let e=0;e<i;e++)try{let t=r[e].trim(),i=S(n,t);a=A.decrypt(i.ciphertext,i.key);break}catch(t){if(e+1>=i)throw t}return A.parse(a)}function v(e){console.error(`[dotenv@${c}][WARN] ${e}`)}function y(e){console.log(`[dotenv@${c}][DEBUG] ${e}`)}function b(e){console.log(`[dotenv@${c}] ${e}`)}function x(e){return e&&e.DOTENV_KEY&&e.DOTENV_KEY.length>0?e.DOTENV_KEY:process.env.DOTENV_KEY&&process.env.DOTENV_KEY.length>0?process.env.DOTENV_KEY:``}function S(e,t){let n;try{n=new URL(t)}catch(e){if(e.code===`ERR_INVALID_URL`){let e=Error(`INVALID_DOTENV_KEY: Wrong format. Must be in valid uri format like dotenv://:key_1234@dotenvx.com/vault/.env.vault?environment=development`);throw e.code=`INVALID_DOTENV_KEY`,e}throw e}let r=n.password;if(!r){let e=Error(`INVALID_DOTENV_KEY: Missing key part`);throw e.code=`INVALID_DOTENV_KEY`,e}let i=n.searchParams.get(`environment`);if(!i){let e=Error(`INVALID_DOTENV_KEY: Missing environment part`);throw e.code=`INVALID_DOTENV_KEY`,e}let a=`DOTENV_VAULT_${i.toUpperCase()}`,o=e.parsed[a];if(!o){let e=Error(`NOT_FOUND_DOTENV_ENVIRONMENT: Cannot locate environment ${a} in your .env.vault file.`);throw e.code=`NOT_FOUND_DOTENV_ENVIRONMENT`,e}return{ciphertext:o,key:r}}function C(e){let t=null;if(e&&e.path&&e.path.length>0)if(Array.isArray(e.path))for(let n of e.path)r.existsSync(n)&&(t=n.endsWith(`.vault`)?n:`${n}.vault`);else t=e.path.endsWith(`.vault`)?e.path:`${e.path}.vault`;else t=i.resolve(process.cwd(),`.env.vault`);return r.existsSync(t)?t:null}function w(e){return e[0]===`~`?i.join(a.homedir(),e.slice(1)):e}function T(e){let t=d(process.env.DOTENV_CONFIG_DEBUG||e&&e.debug),n=d(process.env.DOTENV_CONFIG_QUIET||e&&e.quiet);(t||!n)&&b(`Loading env from encrypted .env.vault`);let r=A._parseVault(e),i=process.env;return e&&e.processEnv!=null&&(i=e.processEnv),A.populate(i,r,e),{parsed:r}}function E(e){let t=i.resolve(process.cwd(),`.env`),n=`utf8`,a=process.env;e&&e.processEnv!=null&&(a=e.processEnv);let o=d(a.DOTENV_CONFIG_DEBUG||e&&e.debug),s=d(a.DOTENV_CONFIG_QUIET||e&&e.quiet);e&&e.encoding?n=e.encoding:o&&y(`No encoding is specified. UTF-8 is used by default`);let c=[t];if(e&&e.path)if(!Array.isArray(e.path))c=[w(e.path)];else{c=[];for(let t of e.path)c.push(w(t))}let l,f={};for(let t of c)try{let i=A.parse(r.readFileSync(t,{encoding:n}));A.populate(f,i,e)}catch(e){o&&y(`Failed to load ${t} ${e.message}`),l=e}let p=A.populate(a,f,e);if(o=d(a.DOTENV_CONFIG_DEBUG||o),s=d(a.DOTENV_CONFIG_QUIET||s),o||!s){let e=Object.keys(p).length,t=[];for(let e of c)try{let n=i.relative(process.cwd(),e);t.push(n)}catch(t){o&&y(`Failed to load ${e} ${t.message}`),l=t}b(`injecting env (${e}) from ${t.join(`,`)} ${m(`-- tip: ${u()}`)}`)}return l?{parsed:f,error:l}:{parsed:f}}function D(e){if(x(e).length===0)return A.configDotenv(e);let t=C(e);return t?A._configVault(e):(v(`You set DOTENV_KEY but you are missing a .env.vault file at ${t}. Did you forget to build it?`),A.configDotenv(e))}function O(e,t){let n=Buffer.from(t.slice(-64),`hex`),r=Buffer.from(e,`base64`),i=r.subarray(0,12),a=r.subarray(-16);r=r.subarray(12,-16);try{let e=o.createDecipheriv(`aes-256-gcm`,n,i);return e.setAuthTag(a),`${e.update(r)}${e.final()}`}catch(e){let t=e instanceof RangeError,n=e.message===`Invalid key length`,r=e.message===`Unsupported state or unable to authenticate data`;if(t||n){let e=Error(`INVALID_DOTENV_KEY: It must be 64 characters long (or more)`);throw e.code=`INVALID_DOTENV_KEY`,e}else if(r){let e=Error(`DECRYPTION_FAILED: Please check your DOTENV_KEY`);throw e.code=`DECRYPTION_FAILED`,e}else throw e}}function k(e,t,n={}){let r=!!(n&&n.debug),i=!!(n&&n.override),a={};if(typeof t!=`object`){let e=Error(`OBJECT_REQUIRED: Please check the processEnv argument being passed to populate`);throw e.code=`OBJECT_REQUIRED`,e}for(let n of Object.keys(t))Object.prototype.hasOwnProperty.call(e,n)?(i===!0&&(e[n]=t[n],a[n]=t[n]),r&&y(i===!0?`"${n}" is already defined and WAS overwritten`:`"${n}" is already defined and was NOT overwritten`)):(e[n]=t[n],a[n]=t[n]);return a}let A={configDotenv:E,_configVault:T,_parseVault:_,config:D,decrypt:O,parse:g,populate:k};n.exports.configDotenv=A.configDotenv,n.exports._configVault=A._configVault,n.exports._parseVault=A._parseVault,n.exports.config=A.config,n.exports.decrypt=A.decrypt,n.exports.parse=A.parse,n.exports.populate=A.populate,n.exports=A}));async function h(e,t){let n=e;for(;n!==r(n);){let e=i(n,t);try{return await l(e),e}catch{}n=r(n)}}var g=e(((exports,t)=>{function n(e){return Array.isArray(e)?e:[e]}let r=/^\s+$/,i=/(?:[^\\]|^)\\$/,a=/^\\!/,o=/^\\#/,s=/\r?\n/g,c=/^\.{0,2}\/|^\.{1,2}$/,l=/\/$/,u=`node-ignore`;typeof Symbol<`u`&&(u=Symbol.for(`node-ignore`));let d=u,f=(e,t,n)=>(Object.defineProperty(e,t,{value:n}),n),p=/([0-z])-([0-z])/g,m=()=>!1,h=e=>e.replace(p,(e,t,n)=>t.charCodeAt(0)<=n.charCodeAt(0)?e:``),g=e=>{let{length:t}=e;return e.slice(0,t-t%2)},_=[[/^\uFEFF/,()=>``],[/((?:\\\\)*?)(\\?\s+)$/,(e,t,n)=>t+(n.indexOf(`\\`)===0?` `:``)],[/(\\+?)\s/g,(e,t)=>{let{length:n}=t;return t.slice(0,n-n%2)+` `}],[/[\\$.|*+(){^]/g,e=>`\\${e}`],[/(?!\\)\?/g,()=>`[^/]`],[/^\//,()=>`^`],[/\//g,()=>`\\/`],[/^\^*\\\*\\\*\\\//,()=>`^(?:.*\\/)?`],[/^(?=[^^])/,function(){return/\/(?!$)/.test(this)?`^`:`(?:^|\\/)`}],[/\\\/\\\*\\\*(?=\\\/|$)/g,(e,t,n)=>t+6<n.length?`(?:\\/[^\\/]+)*`:`\\/.+`],[/(^|[^\\]+)(\\\*)+(?=.+)/g,(e,t,n)=>{let r=n.replace(/\\\*/g,`[^\\/]*`);return t+r}],[/\\\\\\(?=[$.|*+(){^])/g,()=>`\\`],[/\\\\/g,()=>`\\`],[/(\\)?\[([^\]/]*?)(\\*)($|\])/g,(e,t,n,r,i)=>t===`\\`?`\\[${n}${g(r)}${i}`:i===`]`&&r.length%2==0?`[${h(n)}${r}]`:`[]`],[/(?:[^*])$/,e=>/\/$/.test(e)?`${e}$`:`${e}(?=$|\\/$)`]],v=/(^|\\\/)?\\\*$/,y=`regex`,b=`checkRegex`,x={[y](e,t){let n=t?`${t}[^/]+`:`[^/]*`;return`${n}(?=$|\\/$)`},[b](e,t){let n=t?`${t}[^/]*`:`[^/]*`;return`${n}(?=$|\\/$)`}},S=e=>_.reduce((t,[n,r])=>t.replace(n,r.bind(e)),e),C=e=>typeof e==`string`,w=e=>e&&C(e)&&!r.test(e)&&!i.test(e)&&e.indexOf(`#`)!==0,T=e=>e.split(s).filter(Boolean);var E=class{constructor(e,t,n,r,i,a){this.pattern=e,this.mark=t,this.negative=i,f(this,`body`,n),f(this,`ignoreCase`,r),f(this,`regexPrefix`,a)}get regex(){let e=`_`+y;return this[e]?this[e]:this._make(y,e)}get checkRegex(){let e=`_`+b;return this[e]?this[e]:this._make(b,e)}_make(e,t){let n=this.regexPrefix.replace(v,x[e]),r=this.ignoreCase?new RegExp(n,`i`):new RegExp(n);return f(this,t,r)}};let D=({pattern:e,mark:t},n)=>{let r=!1,i=e;i.indexOf(`!`)===0&&(r=!0,i=i.substr(1)),i=i.replace(a,`!`).replace(o,`#`);let s=S(i);return new E(e,t,i,n,r,s)};var O=class{constructor(e){this._ignoreCase=e,this._rules=[]}_add(e){if(e&&e[d]){this._rules=this._rules.concat(e._rules._rules),this._added=!0;return}if(C(e)&&(e={pattern:e}),w(e.pattern)){let t=D(e,this._ignoreCase);this._added=!0,this._rules.push(t)}}add(e){return this._added=!1,n(C(e)?T(e):e).forEach(this._add,this),this._added}test(e,t,n){let r=!1,i=!1,a;this._rules.forEach(o=>{let{negative:s}=o;if(i===s&&r!==i||s&&!r&&!i&&!t)return;let c=o[n].test(e);c&&(r=!s,i=s,a=s?void 0:o)});let o={ignored:r,unignored:i};return a&&(o.rule=a),o}};let k=(e,t)=>{throw new t(e)},A=(e,t,n)=>C(e)?e?A.isNotRelative(e)?n(`path should be a \`path.relative()\`d string, but got "${t}"`,RangeError):!0:n(`path must not be empty`,TypeError):n(`path must be a string, but got \`${t}\``,TypeError),j=e=>c.test(e);A.isNotRelative=j,A.convert=e=>e;var M=class{constructor({ignorecase:e=!0,ignoreCase:t=e,allowRelativePaths:n=!1}={}){f(this,d,!0),this._rules=new O(t),this._strictPathCheck=!n,this._initCache()}_initCache(){this._ignoreCache=Object.create(null),this._testCache=Object.create(null)}add(e){return this._rules.add(e)&&this._initCache(),this}addPattern(e){return this.add(e)}_test(e,t,n,r){let i=e&&A.convert(e);return A(i,e,this._strictPathCheck?k:m),this._t(i,t,n,r)}checkIgnore(e){if(!l.test(e))return this.test(e);let t=e.split(`/`).filter(Boolean);if(t.pop(),t.length){let e=this._t(t.join(`/`)+`/`,this._testCache,!0,t);if(e.ignored)return e}return this._rules.test(e,!1,b)}_t(e,t,n,r){if(e in t)return t[e];if(r||(r=e.split(`/`).filter(Boolean)),r.pop(),!r.length)return t[e]=this._rules.test(e,n,y);let i=this._t(r.join(`/`)+`/`,t,n,r);return t[e]=i.ignored?i:this._rules.test(e,n,y)}ignores(e){return this._test(e,this._ignoreCache,!1).ignored}createFilter(){return e=>!this.ignores(e)}filter(e){return n(e).filter(this.createFilter())}test(e){return this._test(e,this._testCache,!0)}};let N=e=>new M(e),P=e=>A(e&&A.convert(e),e,m),F=()=>{let e=e=>/^\\\\\?\\/.test(e)||/["<>|\u0000-\u001F]+/u.test(e)?e:e.replace(/\\/g,`/`);A.convert=e;let t=/^[a-z]:\//i;A.isNotRelative=e=>t.test(e)||j(e)};typeof process<`u`&&process.platform===`win32`&&F(),t.exports=N,N.default=N,t.exports.isPathValid=P,f(t.exports,Symbol.for(`setupWindows`),F)}));export{h as findNearestEntry,g as require_ignore,m as require_main,f as resolveConfig};
package/dist/cli/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import{__commonJSMin as e,__require as t,__toESM as n}from"./chunk-ByIbJXPc.js";import{import_websocket as r}from"./wrapper-B4vDwpOq.js";import{findNearestEntry as i,require_ignore as a,require_main as o,resolveConfig as s}from"./ignore-BSx5uoz9.js";import{Client as c,Y as l,loginIfNeeded as u,pD as d,source_default as f,ve as p,ye as m}from"./auth-B3n8RcUK.js";import"./open-FpexaS6S.js";import{randomUUID as h}from"crypto";import{basename as g,dirname as _,join as v,relative as y}from"node:path";import{existsSync as ee}from"node:fs";import{mkdir as te,readdir as b,writeFile as ne}from"fs/promises";import{readFile as x,stat as S}from"node:fs/promises";var C=e((exports=>{var t=class extends Error{constructor(e,t,n){super(n),Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name,this.code=t,this.exitCode=e,this.nestedError=void 0}},n=class extends t{constructor(e){super(1,`commander.invalidArgument`,e),Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name}};exports.CommanderError=t,exports.InvalidArgumentError=n})),w=e((exports=>{let{InvalidArgumentError:t}=C();var n=class{constructor(e,t){switch(this.description=t||``,this.variadic=!1,this.parseArg=void 0,this.defaultValue=void 0,this.defaultValueDescription=void 0,this.argChoices=void 0,e[0]){case`<`:this.required=!0,this._name=e.slice(1,-1);break;case`[`:this.required=!1,this._name=e.slice(1,-1);break;default:this.required=!0,this._name=e;break}this._name.length>3&&this._name.slice(-3)===`...`&&(this.variadic=!0,this._name=this._name.slice(0,-3))}name(){return this._name}_concatValue(e,t){return t===this.defaultValue||!Array.isArray(t)?[e]:t.concat(e)}default(e,t){return this.defaultValue=e,this.defaultValueDescription=t,this}argParser(e){return this.parseArg=e,this}choices(e){return this.argChoices=e.slice(),this.parseArg=(e,n)=>{if(!this.argChoices.includes(e))throw new t(`Allowed choices are ${this.argChoices.join(`, `)}.`);return this.variadic?this._concatValue(e,n):e},this}argRequired(){return this.required=!0,this}argOptional(){return this.required=!1,this}};function r(e){let t=e.name()+(e.variadic===!0?`...`:``);return e.required?`<`+t+`>`:`[`+t+`]`}exports.Argument=n,exports.humanReadableArgName=r})),T=e((exports=>{let{humanReadableArgName:t}=w();var n=class{constructor(){this.helpWidth=void 0,this.minWidthToWrap=40,this.sortSubcommands=!1,this.sortOptions=!1,this.showGlobalOptions=!1}prepareContext(e){this.helpWidth=this.helpWidth??e.helpWidth??80}visibleCommands(e){let t=e.commands.filter(e=>!e._hidden),n=e._getHelpCommand();return n&&!n._hidden&&t.push(n),this.sortSubcommands&&t.sort((e,t)=>e.name().localeCompare(t.name())),t}compareOptions(e,t){let n=e=>e.short?e.short.replace(/^-/,``):e.long.replace(/^--/,``);return n(e).localeCompare(n(t))}visibleOptions(e){let t=e.options.filter(e=>!e.hidden),n=e._getHelpOption();if(n&&!n.hidden){let r=n.short&&e._findOption(n.short),i=n.long&&e._findOption(n.long);!r&&!i?t.push(n):n.long&&!i?t.push(e.createOption(n.long,n.description)):n.short&&!r&&t.push(e.createOption(n.short,n.description))}return this.sortOptions&&t.sort(this.compareOptions),t}visibleGlobalOptions(e){if(!this.showGlobalOptions)return[];let t=[];for(let n=e.parent;n;n=n.parent){let e=n.options.filter(e=>!e.hidden);t.push(...e)}return this.sortOptions&&t.sort(this.compareOptions),t}visibleArguments(e){return e._argsDescription&&e.registeredArguments.forEach(t=>{t.description=t.description||e._argsDescription[t.name()]||``}),e.registeredArguments.find(e=>e.description)?e.registeredArguments:[]}subcommandTerm(e){let n=e.registeredArguments.map(e=>t(e)).join(` `);return e._name+(e._aliases[0]?`|`+e._aliases[0]:``)+(e.options.length?` [options]`:``)+(n?` `+n:``)}optionTerm(e){return e.flags}argumentTerm(e){return e.name()}longestSubcommandTermLength(e,t){return t.visibleCommands(e).reduce((e,n)=>Math.max(e,this.displayWidth(t.styleSubcommandTerm(t.subcommandTerm(n)))),0)}longestOptionTermLength(e,t){return t.visibleOptions(e).reduce((e,n)=>Math.max(e,this.displayWidth(t.styleOptionTerm(t.optionTerm(n)))),0)}longestGlobalOptionTermLength(e,t){return t.visibleGlobalOptions(e).reduce((e,n)=>Math.max(e,this.displayWidth(t.styleOptionTerm(t.optionTerm(n)))),0)}longestArgumentTermLength(e,t){return t.visibleArguments(e).reduce((e,n)=>Math.max(e,this.displayWidth(t.styleArgumentTerm(t.argumentTerm(n)))),0)}commandUsage(e){let t=e._name;e._aliases[0]&&(t=t+`|`+e._aliases[0]);let n=``;for(let t=e.parent;t;t=t.parent)n=t.name()+` `+n;return n+t+` `+e.usage()}commandDescription(e){return e.description()}subcommandDescription(e){return e.summary()||e.description()}optionDescription(e){let t=[];if(e.argChoices&&t.push(`choices: ${e.argChoices.map(e=>JSON.stringify(e)).join(`, `)}`),e.defaultValue!==void 0){let n=e.required||e.optional||e.isBoolean()&&typeof e.defaultValue==`boolean`;n&&t.push(`default: ${e.defaultValueDescription||JSON.stringify(e.defaultValue)}`)}if(e.presetArg!==void 0&&e.optional&&t.push(`preset: ${JSON.stringify(e.presetArg)}`),e.envVar!==void 0&&t.push(`env: ${e.envVar}`),t.length>0){let n=`(${t.join(`, `)})`;return e.description?`${e.description} ${n}`:n}return e.description}argumentDescription(e){let t=[];if(e.argChoices&&t.push(`choices: ${e.argChoices.map(e=>JSON.stringify(e)).join(`, `)}`),e.defaultValue!==void 0&&t.push(`default: ${e.defaultValueDescription||JSON.stringify(e.defaultValue)}`),t.length>0){let n=`(${t.join(`, `)})`;return e.description?`${e.description} ${n}`:n}return e.description}formatItemList(e,t,n){return t.length===0?[]:[n.styleTitle(e),...t,``]}groupItems(e,t,n){let r=new Map;return e.forEach(e=>{let t=n(e);r.has(t)||r.set(t,[])}),t.forEach(e=>{let t=n(e);r.has(t)||r.set(t,[]),r.get(t).push(e)}),r}formatHelp(e,t){let n=t.padWidth(e,t),r=t.helpWidth??80;function i(e,r){return t.formatItem(e,n,r,t)}let a=[`${t.styleTitle(`Usage:`)} ${t.styleUsage(t.commandUsage(e))}`,``],o=t.commandDescription(e);o.length>0&&(a=a.concat([t.boxWrap(t.styleCommandDescription(o),r),``]));let s=t.visibleArguments(e).map(e=>i(t.styleArgumentTerm(t.argumentTerm(e)),t.styleArgumentDescription(t.argumentDescription(e))));a=a.concat(this.formatItemList(`Arguments:`,s,t));let c=this.groupItems(e.options,t.visibleOptions(e),e=>e.helpGroupHeading??`Options:`);if(c.forEach((e,n)=>{let r=e.map(e=>i(t.styleOptionTerm(t.optionTerm(e)),t.styleOptionDescription(t.optionDescription(e))));a=a.concat(this.formatItemList(n,r,t))}),t.showGlobalOptions){let n=t.visibleGlobalOptions(e).map(e=>i(t.styleOptionTerm(t.optionTerm(e)),t.styleOptionDescription(t.optionDescription(e))));a=a.concat(this.formatItemList(`Global Options:`,n,t))}let l=this.groupItems(e.commands,t.visibleCommands(e),e=>e.helpGroup()||`Commands:`);return l.forEach((e,n)=>{let r=e.map(e=>i(t.styleSubcommandTerm(t.subcommandTerm(e)),t.styleSubcommandDescription(t.subcommandDescription(e))));a=a.concat(this.formatItemList(n,r,t))}),a.join(`
2
+ import{__commonJSMin as e,__require as t,__toESM as n}from"./chunk-ByIbJXPc.js";import{import_websocket as r}from"./wrapper-B4vDwpOq.js";import{findNearestEntry as i,require_ignore as a,require_main as o,resolveConfig as s}from"./ignore-GLTkbIEj.js";import{Client as c,Y as l,loginIfNeeded as u,pD as d,source_default as f,ve as p,ye as m}from"./auth-xjF_htDn.js";import"./open-DfjrUP4O.js";import{randomUUID as h}from"crypto";import{basename as g,dirname as _,join as v,relative as y}from"node:path";import{existsSync as ee}from"node:fs";import{mkdir as te,readdir as b,writeFile as ne}from"fs/promises";import{readFile as x,stat as S}from"node:fs/promises";var C=e((exports=>{var t=class extends Error{constructor(e,t,n){super(n),Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name,this.code=t,this.exitCode=e,this.nestedError=void 0}},n=class extends t{constructor(e){super(1,`commander.invalidArgument`,e),Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name}};exports.CommanderError=t,exports.InvalidArgumentError=n})),w=e((exports=>{let{InvalidArgumentError:t}=C();var n=class{constructor(e,t){switch(this.description=t||``,this.variadic=!1,this.parseArg=void 0,this.defaultValue=void 0,this.defaultValueDescription=void 0,this.argChoices=void 0,e[0]){case`<`:this.required=!0,this._name=e.slice(1,-1);break;case`[`:this.required=!1,this._name=e.slice(1,-1);break;default:this.required=!0,this._name=e;break}this._name.length>3&&this._name.slice(-3)===`...`&&(this.variadic=!0,this._name=this._name.slice(0,-3))}name(){return this._name}_concatValue(e,t){return t===this.defaultValue||!Array.isArray(t)?[e]:t.concat(e)}default(e,t){return this.defaultValue=e,this.defaultValueDescription=t,this}argParser(e){return this.parseArg=e,this}choices(e){return this.argChoices=e.slice(),this.parseArg=(e,n)=>{if(!this.argChoices.includes(e))throw new t(`Allowed choices are ${this.argChoices.join(`, `)}.`);return this.variadic?this._concatValue(e,n):e},this}argRequired(){return this.required=!0,this}argOptional(){return this.required=!1,this}};function r(e){let t=e.name()+(e.variadic===!0?`...`:``);return e.required?`<`+t+`>`:`[`+t+`]`}exports.Argument=n,exports.humanReadableArgName=r})),T=e((exports=>{let{humanReadableArgName:t}=w();var n=class{constructor(){this.helpWidth=void 0,this.minWidthToWrap=40,this.sortSubcommands=!1,this.sortOptions=!1,this.showGlobalOptions=!1}prepareContext(e){this.helpWidth=this.helpWidth??e.helpWidth??80}visibleCommands(e){let t=e.commands.filter(e=>!e._hidden),n=e._getHelpCommand();return n&&!n._hidden&&t.push(n),this.sortSubcommands&&t.sort((e,t)=>e.name().localeCompare(t.name())),t}compareOptions(e,t){let n=e=>e.short?e.short.replace(/^-/,``):e.long.replace(/^--/,``);return n(e).localeCompare(n(t))}visibleOptions(e){let t=e.options.filter(e=>!e.hidden),n=e._getHelpOption();if(n&&!n.hidden){let r=n.short&&e._findOption(n.short),i=n.long&&e._findOption(n.long);!r&&!i?t.push(n):n.long&&!i?t.push(e.createOption(n.long,n.description)):n.short&&!r&&t.push(e.createOption(n.short,n.description))}return this.sortOptions&&t.sort(this.compareOptions),t}visibleGlobalOptions(e){if(!this.showGlobalOptions)return[];let t=[];for(let n=e.parent;n;n=n.parent){let e=n.options.filter(e=>!e.hidden);t.push(...e)}return this.sortOptions&&t.sort(this.compareOptions),t}visibleArguments(e){return e._argsDescription&&e.registeredArguments.forEach(t=>{t.description=t.description||e._argsDescription[t.name()]||``}),e.registeredArguments.find(e=>e.description)?e.registeredArguments:[]}subcommandTerm(e){let n=e.registeredArguments.map(e=>t(e)).join(` `);return e._name+(e._aliases[0]?`|`+e._aliases[0]:``)+(e.options.length?` [options]`:``)+(n?` `+n:``)}optionTerm(e){return e.flags}argumentTerm(e){return e.name()}longestSubcommandTermLength(e,t){return t.visibleCommands(e).reduce((e,n)=>Math.max(e,this.displayWidth(t.styleSubcommandTerm(t.subcommandTerm(n)))),0)}longestOptionTermLength(e,t){return t.visibleOptions(e).reduce((e,n)=>Math.max(e,this.displayWidth(t.styleOptionTerm(t.optionTerm(n)))),0)}longestGlobalOptionTermLength(e,t){return t.visibleGlobalOptions(e).reduce((e,n)=>Math.max(e,this.displayWidth(t.styleOptionTerm(t.optionTerm(n)))),0)}longestArgumentTermLength(e,t){return t.visibleArguments(e).reduce((e,n)=>Math.max(e,this.displayWidth(t.styleArgumentTerm(t.argumentTerm(n)))),0)}commandUsage(e){let t=e._name;e._aliases[0]&&(t=t+`|`+e._aliases[0]);let n=``;for(let t=e.parent;t;t=t.parent)n=t.name()+` `+n;return n+t+` `+e.usage()}commandDescription(e){return e.description()}subcommandDescription(e){return e.summary()||e.description()}optionDescription(e){let t=[];if(e.argChoices&&t.push(`choices: ${e.argChoices.map(e=>JSON.stringify(e)).join(`, `)}`),e.defaultValue!==void 0){let n=e.required||e.optional||e.isBoolean()&&typeof e.defaultValue==`boolean`;n&&t.push(`default: ${e.defaultValueDescription||JSON.stringify(e.defaultValue)}`)}if(e.presetArg!==void 0&&e.optional&&t.push(`preset: ${JSON.stringify(e.presetArg)}`),e.envVar!==void 0&&t.push(`env: ${e.envVar}`),t.length>0){let n=`(${t.join(`, `)})`;return e.description?`${e.description} ${n}`:n}return e.description}argumentDescription(e){let t=[];if(e.argChoices&&t.push(`choices: ${e.argChoices.map(e=>JSON.stringify(e)).join(`, `)}`),e.defaultValue!==void 0&&t.push(`default: ${e.defaultValueDescription||JSON.stringify(e.defaultValue)}`),t.length>0){let n=`(${t.join(`, `)})`;return e.description?`${e.description} ${n}`:n}return e.description}formatItemList(e,t,n){return t.length===0?[]:[n.styleTitle(e),...t,``]}groupItems(e,t,n){let r=new Map;return e.forEach(e=>{let t=n(e);r.has(t)||r.set(t,[])}),t.forEach(e=>{let t=n(e);r.has(t)||r.set(t,[]),r.get(t).push(e)}),r}formatHelp(e,t){let n=t.padWidth(e,t),r=t.helpWidth??80;function i(e,r){return t.formatItem(e,n,r,t)}let a=[`${t.styleTitle(`Usage:`)} ${t.styleUsage(t.commandUsage(e))}`,``],o=t.commandDescription(e);o.length>0&&(a=a.concat([t.boxWrap(t.styleCommandDescription(o),r),``]));let s=t.visibleArguments(e).map(e=>i(t.styleArgumentTerm(t.argumentTerm(e)),t.styleArgumentDescription(t.argumentDescription(e))));a=a.concat(this.formatItemList(`Arguments:`,s,t));let c=this.groupItems(e.options,t.visibleOptions(e),e=>e.helpGroupHeading??`Options:`);if(c.forEach((e,n)=>{let r=e.map(e=>i(t.styleOptionTerm(t.optionTerm(e)),t.styleOptionDescription(t.optionDescription(e))));a=a.concat(this.formatItemList(n,r,t))}),t.showGlobalOptions){let n=t.visibleGlobalOptions(e).map(e=>i(t.styleOptionTerm(t.optionTerm(e)),t.styleOptionDescription(t.optionDescription(e))));a=a.concat(this.formatItemList(`Global Options:`,n,t))}let l=this.groupItems(e.commands,t.visibleCommands(e),e=>e.helpGroup()||`Commands:`);return l.forEach((e,n)=>{let r=e.map(e=>i(t.styleSubcommandTerm(t.subcommandTerm(e)),t.styleSubcommandDescription(t.subcommandDescription(e))));a=a.concat(this.formatItemList(n,r,t))}),a.join(`
3
3
  `)}displayWidth(e){return r(e).length}styleTitle(e){return e}styleUsage(e){return e.split(` `).map(e=>e===`[options]`?this.styleOptionText(e):e===`[command]`?this.styleSubcommandText(e):e[0]===`[`||e[0]===`<`?this.styleArgumentText(e):this.styleCommandText(e)).join(` `)}styleCommandDescription(e){return this.styleDescriptionText(e)}styleOptionDescription(e){return this.styleDescriptionText(e)}styleSubcommandDescription(e){return this.styleDescriptionText(e)}styleArgumentDescription(e){return this.styleDescriptionText(e)}styleDescriptionText(e){return e}styleOptionTerm(e){return this.styleOptionText(e)}styleSubcommandTerm(e){return e.split(` `).map(e=>e===`[options]`?this.styleOptionText(e):e[0]===`[`||e[0]===`<`?this.styleArgumentText(e):this.styleSubcommandText(e)).join(` `)}styleArgumentTerm(e){return this.styleArgumentText(e)}styleOptionText(e){return e}styleArgumentText(e){return e}styleSubcommandText(e){return e}styleCommandText(e){return e}padWidth(e,t){return Math.max(t.longestOptionTermLength(e,t),t.longestGlobalOptionTermLength(e,t),t.longestSubcommandTermLength(e,t),t.longestArgumentTermLength(e,t))}preformatted(e){return/\n[^\S\r\n]/.test(e)}formatItem(e,t,n,r){let i=` `.repeat(2);if(!n)return i+e;let a=e.padEnd(t+e.length-r.displayWidth(e)),o=this.helpWidth??80,s=o-t-2-2,c;if(s<this.minWidthToWrap||r.preformatted(n))c=n;else{let e=r.boxWrap(n,s);c=e.replace(/\n/g,`
4
4
  `+` `.repeat(t+2))}return i+a+` `.repeat(2)+c.replace(/\n/g,`\n${i}`)}boxWrap(e,t){if(t<this.minWidthToWrap)return e;let n=e.split(/\r\n|\n/),r=/[\s]*[^\s]+/g,i=[];return n.forEach(e=>{let n=e.match(r);if(n===null){i.push(``);return}let a=[n.shift()],o=this.displayWidth(a[0]);n.forEach(e=>{let n=this.displayWidth(e);if(o+n<=t){a.push(e),o+=n;return}i.push(a.join(``));let r=e.trimStart();a=[r],o=this.displayWidth(r)}),i.push(a.join(``))}),i.join(`
5
5
  `)}};function r(e){let t=/\x1b\[\d*(;\d*)*m/g;return e.replace(t,``)}exports.Help=n,exports.stripColor=r})),E=e((exports=>{let{InvalidArgumentError:t}=C();var n=class{constructor(e,t){this.flags=e,this.description=t||``,this.required=e.includes(`<`),this.optional=e.includes(`[`),this.variadic=/\w\.\.\.[>\]]$/.test(e),this.mandatory=!1;let n=a(e);this.short=n.shortFlag,this.long=n.longFlag,this.negate=!1,this.long&&(this.negate=this.long.startsWith(`--no-`)),this.defaultValue=void 0,this.defaultValueDescription=void 0,this.presetArg=void 0,this.envVar=void 0,this.parseArg=void 0,this.hidden=!1,this.argChoices=void 0,this.conflictsWith=[],this.implied=void 0,this.helpGroupHeading=void 0}default(e,t){return this.defaultValue=e,this.defaultValueDescription=t,this}preset(e){return this.presetArg=e,this}conflicts(e){return this.conflictsWith=this.conflictsWith.concat(e),this}implies(e){let t=e;return typeof e==`string`&&(t={[e]:!0}),this.implied=Object.assign(this.implied||{},t),this}env(e){return this.envVar=e,this}argParser(e){return this.parseArg=e,this}makeOptionMandatory(e=!0){return this.mandatory=!!e,this}hideHelp(e=!0){return this.hidden=!!e,this}_concatValue(e,t){return t===this.defaultValue||!Array.isArray(t)?[e]:t.concat(e)}choices(e){return this.argChoices=e.slice(),this.parseArg=(e,n)=>{if(!this.argChoices.includes(e))throw new t(`Allowed choices are ${this.argChoices.join(`, `)}.`);return this.variadic?this._concatValue(e,n):e},this}name(){return this.long?this.long.replace(/^--/,``):this.short.replace(/^-/,``)}attributeName(){return this.negate?i(this.name().replace(/^no-/,``)):i(this.name())}helpGroup(e){return this.helpGroupHeading=e,this}is(e){return this.short===e||this.long===e}isBoolean(){return!this.required&&!this.optional&&!this.negate}},r=class{constructor(e){this.positiveOptions=new Map,this.negativeOptions=new Map,this.dualOptions=new Set,e.forEach(e=>{e.negate?this.negativeOptions.set(e.attributeName(),e):this.positiveOptions.set(e.attributeName(),e)}),this.negativeOptions.forEach((e,t)=>{this.positiveOptions.has(t)&&this.dualOptions.add(t)})}valueFromOption(e,t){let n=t.attributeName();if(!this.dualOptions.has(n))return!0;let r=this.negativeOptions.get(n).presetArg,i=r===void 0?!1:r;return t.negate===(i===e)}};function i(e){return e.split(`-`).reduce((e,t)=>e+t[0].toUpperCase()+t.slice(1))}function a(e){let t,n,r=/^-[^-]$/,i=/^--[^-]/,a=e.split(/[ |,]+/).concat(`guard`);if(r.test(a[0])&&(t=a.shift()),i.test(a[0])&&(n=a.shift()),!t&&r.test(a[0])&&(t=a.shift()),!t&&i.test(a[0])&&(t=n,n=a.shift()),a[0].startsWith(`-`)){let t=a[0],n=`option creation failed due to '${t}' in option flags '${e}'`;throw/^-[^-][^-]/.test(t)?Error(`${n}
@@ -17,6 +17,6 @@ Expecting one of '${n.join(`', '`)}'`);return this._lifeCycleHooks[e]?this._life
17
17
  - if the default executable name is not suitable, use the executableFile option to supply a custom name or path
18
18
  - ${r}`;throw Error(i)}_executeSubCommand(e,t){t=t.slice();let n=!1,s=[`.js`,`.ts`,`.tsx`,`.mjs`,`.cjs`];function c(e,t){let n=i.resolve(e,t);if(a.existsSync(n))return n;if(s.includes(i.extname(t)))return;let r=s.find(e=>a.existsSync(`${n}${e}`));if(r)return`${n}${r}`}this._checkForMissingMandatoryOptions(),this._checkForConflictingOptions();let u=e._executableFile||`${this._name}-${e._name}`,d=this._executableDir||``;if(this._scriptPath){let e;try{e=a.realpathSync(this._scriptPath)}catch{e=this._scriptPath}d=i.resolve(i.dirname(e),d)}if(d){let t=c(d,u);if(!t&&!e._executableFile&&this._scriptPath){let n=i.basename(this._scriptPath,i.extname(this._scriptPath));n!==this._name&&(t=c(d,`${n}-${e._name}`))}u=t||u}n=s.includes(i.extname(u));let f;if(o.platform===`win32`?(this._checkForMissingExecutable(u,d,e._name),t.unshift(u),t=g(o.execArgv).concat(t),f=r.spawn(o.execPath,t,{stdio:`inherit`})):n?(t.unshift(u),t=g(o.execArgv).concat(t),f=r.spawn(o.argv[0],t,{stdio:`inherit`})):f=r.spawn(u,t,{stdio:`inherit`}),!f.killed){let e=[`SIGUSR1`,`SIGUSR2`,`SIGTERM`,`SIGINT`,`SIGHUP`];e.forEach(e=>{o.on(e,()=>{f.killed===!1&&f.exitCode===null&&f.kill(e)})})}let p=this._exitCallback;f.on(`close`,e=>{e=e??1,p?p(new l(e,`commander.executeSubCommandAsync`,`(close)`)):o.exit(e)}),f.on(`error`,t=>{if(t.code===`ENOENT`)this._checkForMissingExecutable(u,d,e._name);else if(t.code===`EACCES`)throw Error(`'${u}' not executable`);if(!p)o.exit(1);else{let e=new l(1,`commander.executeSubCommandAsync`,`(error)`);e.nestedError=t,p(e)}}),this.runningCommand=f}_dispatchSubcommand(e,t,n){let r=this._findCommand(e);r||this.help({error:!0}),r._prepareForParse();let i;return i=this._chainOrCallSubCommandHook(i,r,`preSubcommand`),i=this._chainOrCall(i,()=>{if(r._executableHandler)this._executeSubCommand(r,t.concat(n));else return r._parseCommand(t,n)}),i}_dispatchHelpCommand(e){e||this.help();let t=this._findCommand(e);return t&&!t._executableHandler&&t.help(),this._dispatchSubcommand(e,[],[this._getHelpOption()?.long??this._getHelpOption()?.short??`--help`])}_checkNumberOfArguments(){this.registeredArguments.forEach((e,t)=>{e.required&&this.args[t]==null&&this.missingArgument(e.name())}),!(this.registeredArguments.length>0&&this.registeredArguments[this.registeredArguments.length-1].variadic)&&this.args.length>this.registeredArguments.length&&this._excessArguments(this.args)}_processArguments(){let e=(e,t,n)=>{let r=t;if(t!==null&&e.parseArg){let i=`error: command-argument value '${t}' is invalid for argument '${e.name()}'.`;r=this._callParseArg(e,t,n,i)}return r};this._checkNumberOfArguments();let t=[];this.registeredArguments.forEach((n,r)=>{let i=n.defaultValue;n.variadic?r<this.args.length?(i=this.args.slice(r),n.parseArg&&(i=i.reduce((t,r)=>e(n,r,t),n.defaultValue))):i===void 0&&(i=[]):r<this.args.length&&(i=this.args[r],n.parseArg&&(i=e(n,i,n.defaultValue))),t[r]=i}),this.processedArgs=t}_chainOrCall(e,t){return e&&e.then&&typeof e.then==`function`?e.then(()=>t()):t()}_chainOrCallHooks(e,t){let n=e,r=[];return this._getCommandAndAncestors().reverse().filter(e=>e._lifeCycleHooks[t]!==void 0).forEach(e=>{e._lifeCycleHooks[t].forEach(t=>{r.push({hookedCommand:e,callback:t})})}),t===`postAction`&&r.reverse(),r.forEach(e=>{n=this._chainOrCall(n,()=>e.callback(e.hookedCommand,this))}),n}_chainOrCallSubCommandHook(e,t,n){let r=e;return this._lifeCycleHooks[n]!==void 0&&this._lifeCycleHooks[n].forEach(e=>{r=this._chainOrCall(r,()=>e(this,t))}),r}_parseCommand(e,t){let n=this.parseOptions(t);if(this._parseOptionsEnv(),this._parseOptionsImplied(),e=e.concat(n.operands),t=n.unknown,this.args=e.concat(t),e&&this._findCommand(e[0]))return this._dispatchSubcommand(e[0],e.slice(1),t);if(this._getHelpCommand()&&e[0]===this._getHelpCommand().name())return this._dispatchHelpCommand(e[1]);if(this._defaultCommandName)return this._outputHelpIfRequested(t),this._dispatchSubcommand(this._defaultCommandName,e,t);this.commands.length&&this.args.length===0&&!this._actionHandler&&!this._defaultCommandName&&this.help({error:!0}),this._outputHelpIfRequested(n.unknown),this._checkForMissingMandatoryOptions(),this._checkForConflictingOptions();let r=()=>{n.unknown.length>0&&this.unknownOption(n.unknown[0])},i=`command:${this.name()}`;if(this._actionHandler){r(),this._processArguments();let n;return n=this._chainOrCallHooks(n,`preAction`),n=this._chainOrCall(n,()=>this._actionHandler(this.processedArgs)),this.parent&&(n=this._chainOrCall(n,()=>{this.parent.emit(i,e,t)})),n=this._chainOrCallHooks(n,`postAction`),n}if(this.parent&&this.parent.listenerCount(i))r(),this._processArguments(),this.parent.emit(i,e,t);else if(e.length){if(this._findCommand(`*`))return this._dispatchSubcommand(`*`,e,t);this.listenerCount(`command:*`)?this.emit(`command:*`,e,t):this.commands.length?this.unknownCommand():(r(),this._processArguments())}else this.commands.length?(r(),this.help({error:!0})):(r(),this._processArguments())}_findCommand(e){if(e)return this.commands.find(t=>t._name===e||t._aliases.includes(e))}_findOption(e){return this.options.find(t=>t.is(e))}_checkForMissingMandatoryOptions(){this._getCommandAndAncestors().forEach(e=>{e.options.forEach(t=>{t.mandatory&&e.getOptionValue(t.attributeName())===void 0&&e.missingMandatoryOptionValue(t)})})}_checkForConflictingLocalOptions(){let e=this.options.filter(e=>{let t=e.attributeName();return this.getOptionValue(t)===void 0?!1:this.getOptionValueSource(t)!==`default`}),t=e.filter(e=>e.conflictsWith.length>0);t.forEach(t=>{let n=e.find(e=>t.conflictsWith.includes(e.attributeName()));n&&this._conflictingOption(t,n)})}_checkForConflictingOptions(){this._getCommandAndAncestors().forEach(e=>{e._checkForConflictingLocalOptions()})}parseOptions(e){let t=[],n=[],r=t,i=e.slice();function a(e){return e.length>1&&e[0]===`-`}let o=e=>/^-\d*\.?\d+(e[+-]?\d+)?$/.test(e)?!this._getCommandAndAncestors().some(e=>e.options.map(e=>e.short).some(e=>/^-\d$/.test(e))):!1,s=null;for(;i.length;){let e=i.shift();if(e===`--`){r===n&&r.push(e),r.push(...i);break}if(s&&(!a(e)||o(e))){this.emit(`option:${s.name()}`,e);continue}if(s=null,a(e)){let t=this._findOption(e);if(t){if(t.required){let e=i.shift();e===void 0&&this.optionMissingArgument(t),this.emit(`option:${t.name()}`,e)}else if(t.optional){let e=null;i.length>0&&(!a(i[0])||o(i[0]))&&(e=i.shift()),this.emit(`option:${t.name()}`,e)}else this.emit(`option:${t.name()}`);s=t.variadic?t:null;continue}}if(e.length>2&&e[0]===`-`&&e[1]!==`-`){let t=this._findOption(`-${e[1]}`);if(t){t.required||t.optional&&this._combineFlagAndOptionalValue?this.emit(`option:${t.name()}`,e.slice(2)):(this.emit(`option:${t.name()}`),i.unshift(`-${e.slice(2)}`));continue}}if(/^--[^=]+=/.test(e)){let t=e.indexOf(`=`),n=this._findOption(e.slice(0,t));if(n&&(n.required||n.optional)){this.emit(`option:${n.name()}`,e.slice(t+1));continue}}if(r===t&&a(e)&&!(this.commands.length===0&&o(e))&&(r=n),(this._enablePositionalOptions||this._passThroughOptions)&&t.length===0&&n.length===0){if(this._findCommand(e)){t.push(e),i.length>0&&n.push(...i);break}else if(this._getHelpCommand()&&e===this._getHelpCommand().name()){t.push(e),i.length>0&&t.push(...i);break}else if(this._defaultCommandName){n.push(e),i.length>0&&n.push(...i);break}}if(this._passThroughOptions){r.push(e),i.length>0&&r.push(...i);break}r.push(e)}return{operands:t,unknown:n}}opts(){if(this._storeOptionsAsProperties){let e={},t=this.options.length;for(let n=0;n<t;n++){let t=this.options[n].attributeName();e[t]=t===this._versionOptionName?this._version:this[t]}return e}return this._optionValues}optsWithGlobals(){return this._getCommandAndAncestors().reduce((e,t)=>Object.assign(e,t.opts()),{})}error(e,t){this._outputConfiguration.outputError(`${e}\n`,this._outputConfiguration.writeErr),typeof this._showHelpAfterError==`string`?this._outputConfiguration.writeErr(`${this._showHelpAfterError}\n`):this._showHelpAfterError&&(this._outputConfiguration.writeErr(`
19
19
  `),this.outputHelp({error:!0}));let n=t||{},r=n.exitCode||1,i=n.code||`commander.error`;this._exit(r,i,e)}_parseOptionsEnv(){this.options.forEach(e=>{if(e.envVar&&e.envVar in o.env){let t=e.attributeName();(this.getOptionValue(t)===void 0||[`default`,`config`,`env`].includes(this.getOptionValueSource(t)))&&(e.required||e.optional?this.emit(`optionEnv:${e.name()}`,o.env[e.envVar]):this.emit(`optionEnv:${e.name()}`))}})}_parseOptionsImplied(){let e=new p(this.options),t=e=>this.getOptionValue(e)!==void 0&&![`default`,`implied`].includes(this.getOptionValueSource(e));this.options.filter(n=>n.implied!==void 0&&t(n.attributeName())&&e.valueFromOption(this.getOptionValue(n.attributeName()),n)).forEach(e=>{Object.keys(e.implied).filter(e=>!t(e)).forEach(t=>{this.setOptionValueWithSource(t,e.implied[t],`implied`)})})}missingArgument(e){let t=`error: missing required argument '${e}'`;this.error(t,{code:`commander.missingArgument`})}optionMissingArgument(e){let t=`error: option '${e.flags}' argument missing`;this.error(t,{code:`commander.optionMissingArgument`})}missingMandatoryOptionValue(e){let t=`error: required option '${e.flags}' not specified`;this.error(t,{code:`commander.missingMandatoryOptionValue`})}_conflictingOption(e,t){let n=e=>{let t=e.attributeName(),n=this.getOptionValue(t),r=this.options.find(e=>e.negate&&t===e.attributeName()),i=this.options.find(e=>!e.negate&&t===e.attributeName());return r&&(r.presetArg===void 0&&n===!1||r.presetArg!==void 0&&n===r.presetArg)?r:i||e},r=e=>{let t=n(e),r=t.attributeName(),i=this.getOptionValueSource(r);return i===`env`?`environment variable '${t.envVar}'`:`option '${t.flags}'`},i=`error: ${r(e)} cannot be used with ${r(t)}`;this.error(i,{code:`commander.conflictingOption`})}unknownOption(e){if(this._allowUnknownOption)return;let t=``;if(e.startsWith(`--`)&&this._showSuggestionAfterError){let n=[],r=this;do{let e=r.createHelp().visibleOptions(r).filter(e=>e.long).map(e=>e.long);n=n.concat(e),r=r.parent}while(r&&!r._enablePositionalOptions);t=m(e,n)}let n=`error: unknown option '${e}'${t}`;this.error(n,{code:`commander.unknownOption`})}_excessArguments(e){if(this._allowExcessArguments)return;let t=this.registeredArguments.length,n=t===1?``:`s`,r=this.parent?` for '${this.name()}'`:``,i=`error: too many arguments${r}. Expected ${t} argument${n} but got ${e.length}.`;this.error(i,{code:`commander.excessArguments`})}unknownCommand(){let e=this.args[0],t=``;if(this._showSuggestionAfterError){let n=[];this.createHelp().visibleCommands(this).forEach(e=>{n.push(e.name()),e.alias()&&n.push(e.alias())}),t=m(e,n)}let n=`error: unknown command '${e}'${t}`;this.error(n,{code:`commander.unknownCommand`})}version(e,t,n){if(e===void 0)return this._version;this._version=e,t=t||`-V, --version`,n=n||`output the version number`;let r=this.createOption(t,n);return this._versionOptionName=r.attributeName(),this._registerOption(r),this.on(`option:`+r.name(),()=>{this._outputConfiguration.writeOut(`${e}\n`),this._exit(0,`commander.version`,e)}),this}description(e,t){return e===void 0&&t===void 0?this._description:(this._description=e,t&&(this._argsDescription=t),this)}summary(e){return e===void 0?this._summary:(this._summary=e,this)}alias(e){if(e===void 0)return this._aliases[0];let t=this;if(this.commands.length!==0&&this.commands[this.commands.length-1]._executableHandler&&(t=this.commands[this.commands.length-1]),e===t._name)throw Error(`Command alias can't be the same as its name`);let n=this.parent?._findCommand(e);if(n){let t=[n.name()].concat(n.aliases()).join(`|`);throw Error(`cannot add alias '${e}' to command '${this.name()}' as already have command '${t}'`)}return t._aliases.push(e),this}aliases(e){return e===void 0?this._aliases:(e.forEach(e=>this.alias(e)),this)}usage(e){if(e===void 0){if(this._usage)return this._usage;let e=this.registeredArguments.map(e=>c(e));return[].concat(this.options.length||this._helpOption!==null?`[options]`:[],this.commands.length?`[command]`:[],this.registeredArguments.length?e:[]).join(` `)}return this._usage=e,this}name(e){return e===void 0?this._name:(this._name=e,this)}helpGroup(e){return e===void 0?this._helpGroupHeading??``:(this._helpGroupHeading=e,this)}commandsGroup(e){return e===void 0?this._defaultCommandGroup??``:(this._defaultCommandGroup=e,this)}optionsGroup(e){return e===void 0?this._defaultOptionGroup??``:(this._defaultOptionGroup=e,this)}_initOptionGroup(e){this._defaultOptionGroup&&!e.helpGroupHeading&&e.helpGroup(this._defaultOptionGroup)}_initCommandGroup(e){this._defaultCommandGroup&&!e.helpGroup()&&e.helpGroup(this._defaultCommandGroup)}nameFromFilename(e){return this._name=i.basename(e,i.extname(e)),this}executableDir(e){return e===void 0?this._executableDir:(this._executableDir=e,this)}helpInformation(e){let t=this.createHelp(),n=this._getOutputContext(e);t.prepareContext({error:n.error,helpWidth:n.helpWidth,outputHasColors:n.hasColors});let r=t.formatHelp(this,t);return n.hasColors?r:this._outputConfiguration.stripColor(r)}_getOutputContext(e){e=e||{};let t=!!e.error,n,r,i;t?(n=e=>this._outputConfiguration.writeErr(e),r=this._outputConfiguration.getErrHasColors(),i=this._outputConfiguration.getErrHelpWidth()):(n=e=>this._outputConfiguration.writeOut(e),r=this._outputConfiguration.getOutHasColors(),i=this._outputConfiguration.getOutHelpWidth());let a=e=>(r||(e=this._outputConfiguration.stripColor(e)),n(e));return{error:t,write:a,hasColors:r,helpWidth:i}}outputHelp(e){let t;typeof e==`function`&&(t=e,e=void 0);let n=this._getOutputContext(e),r={error:n.error,write:n.write,command:this};this._getCommandAndAncestors().reverse().forEach(e=>e.emit(`beforeAllHelp`,r)),this.emit(`beforeHelp`,r);let i=this.helpInformation({error:n.error});if(t&&(i=t(i),typeof i!=`string`&&!Buffer.isBuffer(i)))throw Error(`outputHelp callback must return a string or a Buffer`);n.write(i),this._getHelpOption()?.long&&this.emit(this._getHelpOption().long),this.emit(`afterHelp`,r),this._getCommandAndAncestors().forEach(e=>e.emit(`afterAllHelp`,r))}helpOption(e,t){return typeof e==`boolean`?(e?(this._helpOption===null&&(this._helpOption=void 0),this._defaultOptionGroup&&this._initOptionGroup(this._getHelpOption())):this._helpOption=null,this):(this._helpOption=this.createOption(e??`-h, --help`,t??`display help for command`),(e||t)&&this._initOptionGroup(this._helpOption),this)}_getHelpOption(){return this._helpOption===void 0&&this.helpOption(void 0,void 0),this._helpOption}addHelpOption(e){return this._helpOption=e,this._initOptionGroup(e),this}help(e){this.outputHelp(e);let t=Number(o.exitCode??0);t===0&&e&&typeof e!=`function`&&e.error&&(t=1),this._exit(t,`commander.help`,`(outputHelp)`)}addHelpText(e,t){let n=[`beforeAll`,`before`,`after`,`afterAll`];if(!n.includes(e))throw Error(`Unexpected value for position to addHelpText.
20
- Expecting one of '${n.join(`', '`)}'`);let r=`${e}Help`;return this.on(r,e=>{let n;n=typeof t==`function`?t({error:e.error,command:e.command}):t,n&&e.write(`${n}\n`)}),this}_outputHelpIfRequested(e){let t=this._getHelpOption(),n=t&&e.find(e=>t.is(e));n&&(this.outputHelp(),this._exit(0,`commander.helpDisplayed`,`(outputHelp)`))}};function g(e){return e.map(e=>{if(!e.startsWith(`--inspect`))return e;let t,n=`127.0.0.1`,r=`9229`,i;return(i=e.match(/^(--inspect(-brk)?)$/))===null?(i=e.match(/^(--inspect(-brk|-port)?)=([^:]+)$/))===null?(i=e.match(/^(--inspect(-brk|-port)?)=([^:]+):(\d+)$/))!==null&&(t=i[1],n=i[3],r=i[4]):(t=i[1],/^\d+$/.test(i[3])?r=i[3]:n=i[3]):t=i[1],t&&r!==`0`?`${t}=${n}:${parseInt(r)+1}`:e})}function _(){if(o.env.NO_COLOR||o.env.FORCE_COLOR===`0`||o.env.FORCE_COLOR===`false`)return!1;if(o.env.FORCE_COLOR||o.env.CLICOLOR_FORCE!==void 0)return!0}exports.Command=h,exports.useColor=_})),k=e((exports=>{let{Argument:t}=w(),{Command:n}=O(),{CommanderError:r,InvalidArgumentError:i}=C(),{Help:a}=T(),{Option:o}=E();exports.program=new n,exports.createCommand=e=>new n(e),exports.createOption=(e,t)=>new o(e,t),exports.createArgument=(e,n)=>new t(e,n),exports.Command=n,exports.Option=o,exports.Argument=t,exports.Help=a,exports.CommanderError=r,exports.InvalidArgumentError=i,exports.InvalidOptionArgumentError=i})),A=n(k(),1);const{program:j,createCommand:M,createArgument:N,createOption:re,CommanderError:P,InvalidArgumentError:ie,InvalidOptionArgumentError:F,Command:I,Argument:ae,Option:L,Help:R}=A.default;var z=`0.1.80`;async function B(e){e||(e=process.cwd());let t=s(e);await t.build({cwd:e,entry:t.entry,outdir:t.outdir,watch:!1,onStart:()=>{console.log(`Building agent...`)},onResult:e=>{`error`in e&&(console.error(e.error),process.exit(1));for(let t of e.warnings)console.warn(t.message);console.log(`Built agent to ${e.entry}`)}})}var V=n(o(),1),H=n(a(),1);async function U(e,t){e||(e=process.cwd());let n=await u(),r=new c({authToken:n,fetch:(e,t)=>{let n=new Headers(t?.headers);return n.set(`x-blink-cli-version`,z),fetch(e,{...t,headers:n})}}),a=await i(e,`package.json`);if(!a)throw Error(`package.json not found`);let o=await x(a,`utf-8`),h=JSON.parse(o),C=_(a),w=v(C,`.blink`,`config.json`),T={};if(ee(w)){let e=await x(w,`utf-8`);T=JSON.parse(e)}let E;if(T?.organizationId)try{let e=await r.organizations.get(T.organizationId);E=e.name}catch(e){T.organizationId=void 0}if(!T?.organizationId){let e=await r.organizations.list();if(e.length===1){let t=e[0];T.organizationId=t.id,E=t.name}else{let t=await p({message:`Which organization should contain this agent?`,options:e.map(e=>({value:e.id,label:e.name}))});if(d(t))return;T.organizationId=t,E=e.find(e=>e.id===t).name}}if(!T.organizationId)throw Error(`Developer error: No organization ID found.`);let D;if(T?.agentId)try{let e=await r.agents.get(T.agentId);D=e.name}catch(e){T.agentId=void 0}if(!T?.agentId)try{let e=await r.organizations.agents.get({organization_id:T.organizationId,agent_name:h.name});T.agentId=e.id,D=e.name}catch(e){let t=await r.agents.create({name:h.name,organization_id:T.organizationId});T.agentId=t.id,D=t.name}if(!T.agentId)throw Error(`Developer error: No agent ID found.`);await te(_(w),{recursive:!0}),await ne(w,JSON.stringify({_:`This file can be source controlled. It contains no secrets.`,...T},null,2),`utf-8`);let O=s(C),k=await new Promise((e,t)=>{O.build({cwd:C,entry:O.entry,outdir:O.outdir,watch:!1,onStart:()=>{},onResult:t=>{e(t)}}).catch(t)});if(!k)throw Error(`Failed to build agent`);if(`error`in k)throw Error(k.error.message);let A={},j=await b(k.outdir);for(let e of j)A[v(k.outdir,e)]=e;let M=v(e,`README.md`);await W(M)&&(A[M]=`README.md`);let N={},re=await se(C);for(let e of re){let t=y(C,e);N[e]=t}let P=Object.entries(A),ie=Object.entries(N),F=[...P,...ie],I=F.length,ae=0,L=0,R=0,B=Array(I);await oe(F,10,async([e,t],n)=>{let i=await S(e),a=i.size,o=++ae;K(`${f.dim(`[${o}/${I}]`)} Uploading ${t} (${G(a)})...`);let s=await x(e),c=await r.files.upload(new File([s],t));B[n]={path:t,id:c.id},L+=1,R+=a}),K(`${f.dim(`[${L}/${I}]`)} Uploaded files (${G(R)}).`),process.stdout.write(`
20
+ Expecting one of '${n.join(`', '`)}'`);let r=`${e}Help`;return this.on(r,e=>{let n;n=typeof t==`function`?t({error:e.error,command:e.command}):t,n&&e.write(`${n}\n`)}),this}_outputHelpIfRequested(e){let t=this._getHelpOption(),n=t&&e.find(e=>t.is(e));n&&(this.outputHelp(),this._exit(0,`commander.helpDisplayed`,`(outputHelp)`))}};function g(e){return e.map(e=>{if(!e.startsWith(`--inspect`))return e;let t,n=`127.0.0.1`,r=`9229`,i;return(i=e.match(/^(--inspect(-brk)?)$/))===null?(i=e.match(/^(--inspect(-brk|-port)?)=([^:]+)$/))===null?(i=e.match(/^(--inspect(-brk|-port)?)=([^:]+):(\d+)$/))!==null&&(t=i[1],n=i[3],r=i[4]):(t=i[1],/^\d+$/.test(i[3])?r=i[3]:n=i[3]):t=i[1],t&&r!==`0`?`${t}=${n}:${parseInt(r)+1}`:e})}function _(){if(o.env.NO_COLOR||o.env.FORCE_COLOR===`0`||o.env.FORCE_COLOR===`false`)return!1;if(o.env.FORCE_COLOR||o.env.CLICOLOR_FORCE!==void 0)return!0}exports.Command=h,exports.useColor=_})),k=e((exports=>{let{Argument:t}=w(),{Command:n}=O(),{CommanderError:r,InvalidArgumentError:i}=C(),{Help:a}=T(),{Option:o}=E();exports.program=new n,exports.createCommand=e=>new n(e),exports.createOption=(e,t)=>new o(e,t),exports.createArgument=(e,n)=>new t(e,n),exports.Command=n,exports.Option=o,exports.Argument=t,exports.Help=a,exports.CommanderError=r,exports.InvalidArgumentError=i,exports.InvalidOptionArgumentError=i})),A=n(k(),1);const{program:j,createCommand:M,createArgument:N,createOption:re,CommanderError:P,InvalidArgumentError:ie,InvalidOptionArgumentError:F,Command:I,Argument:ae,Option:L,Help:R}=A.default;var z=`0.1.81`;async function B(e){e||(e=process.cwd());let t=s(e);await t.build({cwd:e,entry:t.entry,outdir:t.outdir,watch:!1,onStart:()=>{console.log(`Building agent...`)},onResult:e=>{`error`in e&&(console.error(e.error),process.exit(1));for(let t of e.warnings)console.warn(t.message);console.log(`Built agent to ${e.entry}`)}})}var V=n(o(),1),H=n(a(),1);async function U(e,t){e||(e=process.cwd());let n=await u(),r=new c({authToken:n,fetch:(e,t)=>{let n=new Headers(t?.headers);return n.set(`x-blink-cli-version`,z),fetch(e,{...t,headers:n})}}),a=await i(e,`package.json`);if(!a)throw Error(`package.json not found`);let o=await x(a,`utf-8`),h=JSON.parse(o),C=_(a),w=v(C,`.blink`,`config.json`),T={};if(ee(w)){let e=await x(w,`utf-8`);T=JSON.parse(e)}let E;if(T?.organizationId)try{let e=await r.organizations.get(T.organizationId);E=e.name}catch(e){T.organizationId=void 0}if(!T?.organizationId){let e=await r.organizations.list();if(e.length===1){let t=e[0];T.organizationId=t.id,E=t.name}else{let t=await p({message:`Which organization should contain this agent?`,options:e.map(e=>({value:e.id,label:e.name}))});if(d(t))return;T.organizationId=t,E=e.find(e=>e.id===t).name}}if(!T.organizationId)throw Error(`Developer error: No organization ID found.`);let D;if(T?.agentId)try{let e=await r.agents.get(T.agentId);D=e.name}catch(e){T.agentId=void 0}if(!T?.agentId)try{let e=await r.organizations.agents.get({organization_id:T.organizationId,agent_name:h.name});T.agentId=e.id,D=e.name}catch(e){let t=await r.agents.create({name:h.name,organization_id:T.organizationId});T.agentId=t.id,D=t.name}if(!T.agentId)throw Error(`Developer error: No agent ID found.`);await te(_(w),{recursive:!0}),await ne(w,JSON.stringify({_:`This file can be source controlled. It contains no secrets.`,...T},null,2),`utf-8`);let O=s(C),k=await new Promise((e,t)=>{O.build({cwd:C,entry:O.entry,outdir:O.outdir,watch:!1,onStart:()=>{},onResult:t=>{e(t)}}).catch(t)});if(!k)throw Error(`Failed to build agent`);if(`error`in k)throw Error(k.error.message);let A={},j=await b(k.outdir);for(let e of j)A[v(k.outdir,e)]=e;let M=v(e,`README.md`);await W(M)&&(A[M]=`README.md`);let N={},re=await se(C);for(let e of re){let t=y(C,e);N[e]=t}let P=Object.entries(A),ie=Object.entries(N),F=[...P,...ie],I=F.length,ae=0,L=0,R=0,B=Array(I);await oe(F,10,async([e,t],n)=>{let i=await S(e),a=i.size,o=++ae;K(`${f.dim(`[${o}/${I}]`)} Uploading ${t} (${G(a)})...`);let s=await x(e),c=await r.files.upload(new File([s],t));B[n]={path:t,id:c.id},L+=1,R+=a}),K(`${f.dim(`[${L}/${I}]`)} Uploaded files (${G(R)}).`),process.stdout.write(`
21
21
  `);let H=B.filter(Boolean),U=H.slice(0,P.length),q=H.slice(P.length),J=v(e,`.env.local`),Y=[];if(await W(J)){let e=(0,V.parse)(await x(J,`utf-8`));Y=Object.keys(e)}let X=[],ce=await r.agents.env.list({agent_id:T.agentId});X=ce.map(e=>e.key);let Z=v(e,`.env.production`);if(await W(Z)){let e=(0,V.parse)(await x(Z,`utf-8`)),t=Object.entries(e),n=t.length,i=0;for(let[e,a]of t){let t=await r.agents.env.create({agent_id:T.agentId,key:e,value:a,target:[`production`,`preview`],secret:!0,upsert:!0});X.push(t.key),i+=1,K(`${f.dim(`[${i}/${n}]`)} Updating environment variable: ${e} ${f.dim(`(.env.production)`)}`)}K(`${f.dim(`[${i}/${n}]`)} Updated environment variables! ${f.dim(`(.env.production)`)}`),process.stdout.write(`
22
- `)}let le=Y.filter(e=>!X.includes(e));if(le.length>0){console.log(`Warning: The following environment variables are set in .env.local but not in .env.production:`);for(let e of le)console.log(`- ${e}`);let e=await m({message:`Do you want to deploy anyway?`});if(e===!1||d(e))return}let ue=await r.agents.deployments.create({agent_id:T.agentId,target:`production`,entrypoint:g(k.entry),output_files:U,source_files:q,message:t?.message}),Q=`https://blink.so/${E}/${D}/deployments/${ue.number}`;console.log(`Deployed:`,Q);let $=l();$.start(`Waiting for deployment to be live...`);try{for(;;){let e=await r.agents.deployments.get({agent_id:T.agentId,deployment_id:ue.id});if(e.status===`success`){let t=`Deployment successful.`;e.target===`production`&&(t+=` All chats will use this deployment!`),$.stop(t);let n=await r.agents.get(T.agentId);n.request_url&&console.log(`\nSend webhooks from anywhere: ${n.request_url}`);break}if(e.status===`failed`){let t=`Deployment failed.`;e.error_message&&(t+=` ${e.error_message}`),$.stop(t),console.log(`Read logs for details:`,Q);return}await new Promise(e=>setTimeout(e,500))}}catch(e){$.stop(`Failed to poll for deployment status.`),console.log(`Read logs for details:`,Q);return}}const W=async e=>{try{return await S(e),!0}catch(e){return!1}};async function oe(e,t,n){let r=Array(e.length),i=0,a=Array(Math.min(t,e.length)).fill(0).map(async()=>{for(;;){let t=i++;if(t>=e.length)break;r[t]=await n(e[t],t)}});return await Promise.all(a),r}function G(e){if(e===0)return`0B`;let t=1024,n=[`B`,`KB`,`MB`,`GB`,`TB`],r=Math.floor(Math.log(e)/Math.log(t)),i=e/Math.pow(t,r);return`${i.toFixed(i>=100?0:i>=10?1:2)}${n[r]}`}function K(e){if(process.stdout.isTTY)try{process.stdout.clearLine(0),process.stdout.cursorTo(0),process.stdout.write(e);return}catch{}console.log(e)}async function se(e){let t=[],n=[`.git`,`node_modules`,`.blink`,`.env`,`.env.*`],r=(0,H.default)().add(n),i=v(e,`.gitignore`);if(await W(i)){let e=await x(i,`utf-8`);r.add(e)}async function a(n,i=e){let o=await b(n,{withFileTypes:!0});for(let e of o){let o=v(n,e.name),s=y(i,o);if(r.ignores(s))continue;e.isDirectory()?await a(o,i):e.isFile()&&t.push(o)}}return await a(e),t}globalThis.WebSocket||(globalThis.WebSocket=r.default),globalThis.crypto||(globalThis.crypto={}),globalThis.crypto.randomUUID||(globalThis.crypto.randomUUID=()=>h()),j.name(`blink`).description(`Blink is a runtime for building and deploying AI agents.`).version(z).action(()=>{j.outputHelp()});const q=e=>async(...t)=>{let{default:n}=await e();return n(...t)};j.command(`init [directory]`).description(`Initialize a new Blink agent.`).action(q(()=>import(`./init-L8jM-POo.js`))),j.command(`dev [directory] [options]`).description(`Start a development server for your agent.`).action(q(()=>import(`./dev-CrkhpK_4.js`))),j.command(`deploy [directory]`).description(`Deploy your agent to the Blink Cloud.`).option(`-m, --message <message>`,`Message for this deployment`).action(U),j.command(`build [directory]`).description(`Build your agent for production.`).action(B),j.command(`telemetry [boolean]`).description(`Enable or disable telemetry.`),j.command(`start [directory]`).description("Starts the Blink runtime in production mode. The agent must be compiled with `blink build` first."),j.command(`connect`,{hidden:!0}).description(`Connect compute to the Blink Cloud.`).action(q(()=>import(`./connect-cXq6LnNs.js`))),j.command(`chat`,{hidden:!0}).description(`Start a Blink chat connected to your machine.`).action(q(()=>import(`./chat-CMGPcXH-.js`))),j.command(`login`,{hidden:!0}).description(`Log in to the Blink Cloud.`).action(q(()=>import(`./login-B8L9R4GV.js`))),j.parse(process.argv);export{};
22
+ `)}let le=Y.filter(e=>!X.includes(e));if(le.length>0){console.log(`Warning: The following environment variables are set in .env.local but not in .env.production:`);for(let e of le)console.log(`- ${e}`);let e=await m({message:`Do you want to deploy anyway?`});if(e===!1||d(e))return}let ue=await r.agents.deployments.create({agent_id:T.agentId,target:`production`,entrypoint:g(k.entry),output_files:U,source_files:q,message:t?.message}),Q=`https://blink.so/${E}/${D}/deployments/${ue.number}`;console.log(`Deployed:`,Q);let $=l();$.start(`Waiting for deployment to be live...`);try{for(;;){let e=await r.agents.deployments.get({agent_id:T.agentId,deployment_id:ue.id});if(e.status===`success`){let t=`Deployment successful.`;e.target===`production`&&(t+=` All chats will use this deployment!`),$.stop(t);let n=await r.agents.get(T.agentId);n.request_url&&console.log(`\nSend webhooks from anywhere: ${n.request_url}`);break}if(e.status===`failed`){let t=`Deployment failed.`;e.error_message&&(t+=` ${e.error_message}`),$.stop(t),console.log(`Read logs for details:`,Q);return}await new Promise(e=>setTimeout(e,500))}}catch(e){$.stop(`Failed to poll for deployment status.`),console.log(`Read logs for details:`,Q);return}}const W=async e=>{try{return await S(e),!0}catch(e){return!1}};async function oe(e,t,n){let r=Array(e.length),i=0,a=Array(Math.min(t,e.length)).fill(0).map(async()=>{for(;;){let t=i++;if(t>=e.length)break;r[t]=await n(e[t],t)}});return await Promise.all(a),r}function G(e){if(e===0)return`0B`;let t=1024,n=[`B`,`KB`,`MB`,`GB`,`TB`],r=Math.floor(Math.log(e)/Math.log(t)),i=e/Math.pow(t,r);return`${i.toFixed(i>=100?0:i>=10?1:2)}${n[r]}`}function K(e){if(process.stdout.isTTY)try{process.stdout.clearLine(0),process.stdout.cursorTo(0),process.stdout.write(e);return}catch{}console.log(e)}async function se(e){let t=[],n=[`.git`,`node_modules`,`.blink`,`.env`,`.env.*`],r=(0,H.default)().add(n),i=v(e,`.gitignore`);if(await W(i)){let e=await x(i,`utf-8`);r.add(e)}async function a(n,i=e){let o=await b(n,{withFileTypes:!0});for(let e of o){let o=v(n,e.name),s=y(i,o);if(r.ignores(s))continue;e.isDirectory()?await a(o,i):e.isFile()&&t.push(o)}}return await a(e),t}globalThis.WebSocket||(globalThis.WebSocket=r.default),globalThis.crypto||(globalThis.crypto={}),globalThis.crypto.randomUUID||(globalThis.crypto.randomUUID=()=>h()),j.name(`blink`).description(`Blink is a runtime for building and deploying AI agents.`).version(z).action(()=>{j.outputHelp()});const q=e=>async(...t)=>{let{default:n}=await e();return n(...t)};j.command(`init [directory]`).description(`Initialize a new Blink agent.`).action(q(()=>import(`./init-Cfm9Arxh.js`))),j.command(`dev [directory] [options]`).description(`Start a development server for your agent.`).action(q(()=>import(`./dev-vWY248GD.js`))),j.command(`deploy [directory]`).description(`Deploy your agent to the Blink Cloud.`).option(`-m, --message <message>`,`Message for this deployment`).action(U),j.command(`build [directory]`).description(`Build your agent for production.`).action(B),j.command(`telemetry [boolean]`).description(`Enable or disable telemetry.`),j.command(`start [directory]`).description("Starts the Blink runtime in production mode. The agent must be compiled with `blink build` first."),j.command(`connect`,{hidden:!0}).description(`Connect compute to the Blink Cloud.`).action(q(()=>import(`./connect-COxOUhV7.js`))),j.command(`chat`,{hidden:!0}).description(`Start a Blink chat connected to your machine.`).action(q(()=>import(`./chat-C_6OPF3i.js`))),j.command(`login`,{hidden:!0}).description(`Log in to the Blink Cloud.`).action(q(()=>import(`./login-C7Hi9NEW.js`))),j.parse(process.argv);export{};
@@ -1,4 +1,4 @@
1
- import{Ie as e,M as t,Se as n,pD as r,ve as i,xe as a,ye as o}from"./auth-B3n8RcUK.js";import"./open-FpexaS6S.js";import{basename as s,dirname as c,join as l}from"path";import{readdir as u,writeFile as d}from"fs/promises";import{spawn as f}from"child_process";async function p(c){if(c||(c=process.cwd()),e(`Initializing a new Blink Agent`),(await u(c)).length>0){let e=await o({message:`Directory is not empty. Do you want to initialize anyway?`});(e===!1||r(e))&&(a(`Initialization cancelled.`),process.exit(1))}let p=s(c).replace(/[^a-zA-Z0-9]/g,`-`),m;if(process.env.npm_config_user_agent?.includes(`bun/`)?m=`bun`:process.env.npm_config_user_agent?.includes(`pnpm/`)?m=`pnpm`:process.env.npm_config_user_agent?.includes(`yarn/`)?m=`yarn`:process.env.npm_config_user_agent?.includes(`npm/`)&&(m=`npm`),!m){let e=await i({options:[{label:`Bun`,value:`bun`},{label:`NPM`,value:`npm`},{label:`PNPM`,value:`pnpm`},{label:`Yarn`,value:`yarn`}],message:`What package manager do you want to use?`});r(e)&&process.exit(0),m=e}t.info(`Using ${m} as the package manager.`);let h={"package.json":JSON.stringify({name:p,main:`agent.ts`,type:`module`,private:!0}),"agent.ts":`import { convertToModelMessages, streamText, tool } from "ai";
1
+ import{Ie as e,M as t,Se as n,pD as r,ve as i,xe as a,ye as o}from"./auth-xjF_htDn.js";import"./open-DfjrUP4O.js";import{basename as s,dirname as c,join as l}from"path";import{readdir as u,writeFile as d}from"fs/promises";import{spawn as f}from"child_process";async function p(c){if(c||(c=process.cwd()),e(`Initializing a new Blink Agent`),(await u(c)).length>0){let e=await o({message:`Directory is not empty. Do you want to initialize anyway?`});(e===!1||r(e))&&(a(`Initialization cancelled.`),process.exit(1))}let p=s(c).replace(/[^a-zA-Z0-9]/g,`-`),m;if(process.env.npm_config_user_agent?.includes(`bun/`)?m=`bun`:process.env.npm_config_user_agent?.includes(`pnpm/`)?m=`pnpm`:process.env.npm_config_user_agent?.includes(`yarn/`)?m=`yarn`:process.env.npm_config_user_agent?.includes(`npm/`)&&(m=`npm`),!m){let e=await i({options:[{label:`Bun`,value:`bun`},{label:`NPM`,value:`npm`},{label:`PNPM`,value:`pnpm`},{label:`Yarn`,value:`yarn`}],message:`What package manager do you want to use?`});r(e)&&process.exit(0),m=e}t.info(`Using ${m} as the package manager.`);let h={"package.json":JSON.stringify({name:p,main:`agent.ts`,type:`module`,private:!0}),"agent.ts":`import { convertToModelMessages, streamText, tool } from "ai";
2
2
  import * as blink from "blink";
3
3
  import { z } from "zod";
4
4
 
@@ -0,0 +1 @@
1
+ import{login as e}from"./auth-xjF_htDn.js";import"./open-DfjrUP4O.js";async function t(){await e()}export{t as default};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "blink",
3
- "version": "0.1.80",
3
+ "version": "0.1.81",
4
4
  "description": "Blink is a JavaScript runtime for building and deploying AI agents.",
5
5
  "type": "module",
6
6
  "bin": {
@@ -70,7 +70,7 @@
70
70
  "@blink.so/api": "^0.0.11",
71
71
  "@clack/prompts": "^0.11.0",
72
72
  "@hono/node-server": "^1.19.3",
73
- "@hugodutka/gemini-cli": "^0.6.0-nightly-20250912-5",
73
+ "@hugodutka/gemini-cli": "npm:@kylecarbs/gemini-cli@0.6.0-nightly-20250912-6",
74
74
  "@opentelemetry/auto-instrumentations-node": "^0.64.6",
75
75
  "@types/marked-terminal": "^6.1.1",
76
76
  "@whatwg-node/server": "^0.10.12",
@@ -1 +0,0 @@
1
- import"./wrapper-B4vDwpOq.js";import"./events-DuTLUpwD.js";import{WorkspaceConnect as e,connect as t}from"./connect-C-uqbkic.js";export{e as WorkspaceConnect,t as default};