@aria-cli/cli 1.0.47 → 1.0.48

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/bin/aria.mjs +1 -1
  2. package/package.json +1 -1
package/bin/aria.mjs CHANGED
@@ -13,7 +13,7 @@ var hQ0=Object.create;var{getPrototypeOf:xQ0,defineProperty:MK,getOwnPropertyNam
13
13
  `)});let F=()=>{H=!0,V.destroy(),B()};Y?.addEventListener("abort",F,{once:!0}),V.on("data",(D)=>{W+=D;while(!0){let O=W.indexOf(`
14
14
  `);if(O===-1)break;let L=W.slice(0,O).trim();if(W=W.slice(O+1),L.length===0)continue;try{let q=R5.parse(JSON.parse(L));if(q.id!==G.id){K=Error("Local control socket response ID mismatch");break}if(!q.ok){let A=T5(q.error,q.diagnostic);if("reason"in q&&typeof q.reason==="string")A.reason=q.reason;K=A;break}z.push(X(q.payload))}catch(q){K=q;break}}B()}),V.once("error",(D)=>{K=D,B()}),V.once("end",()=>{H=!0,B()}),V.once("close",()=>{H=!0,B()});try{while(!0){if(z.length>0){yield z.shift();continue}if(K)throw K;if(H)return;await new Promise((D)=>{U=D})}}finally{Y?.removeEventListener("abort",F),V.destroy()}}}}function rK($){let Z=$.pollIntervalMs??1000,J=async(X)=>j$($.runtimeSocket,"listInbox",r9.optional().parse(X),(Y)=>c8.array().parse(Y));return{async submitRun(X){let Y=j8.parse(X);return ou(j$($.runtimeSocket,"submitRun",Y,(Q)=>k9.parse(Q)))},async resumeRun(X){return j$($.runtimeSocket,"resumeRun",l4.parse(X),(Y)=>k9.parse(Y))},streamRun(X,Y){return gN($.runtimeSocket,"streamRun",j8.parse(X),(Q)=>q6.parse(Q),Y)},subscribeRuntimeEvents(X){return gN($.runtimeSocket,"subscribeRuntimeEvents",L7.optional().parse(X),(Y)=>Y1.parse(Y))},async sendBestEffort(X){return j$($.runtimeSocket,"sendBestEffort",G8.parse(X),(Y)=>a4.parse(Y))},async sendDurable(X){return j$($.runtimeSocket,"sendDurable",G8.parse(X),(Y)=>n4.parse(Y))},listInbox:J,subscribeInbox(X){return nu(()=>J({limit:100,unreadOnly:!1}),{pollIntervalMs:Z,initialAfterCreatedAt:X?.afterCreatedAt??0})},async listPeers(){return j$($.runtimeSocket,"listPeers",void 0,(X)=>A4.array().parse(X))},async listNearbyPeers(){return j$($.runtimeSocket,"listNearbyPeers",void 0,(X)=>E6.array().parse(X))},subscribePeers(){return nu(()=>j$($.runtimeSocket,"listPeers",void 0,(X)=>A4.array().parse(X)),{pollIntervalMs:Z,getVersionKey:(X)=>[X.updatedAt,X.endpointRevision,X.identityState,X.transportState,X.lastSeenAt??"",X.transportPublicKey,X.displayNameSnapshot??""].join("|")})},async getRuntimeStatus(){return j$($.runtimeSocket,"getRuntimeStatus",void 0,(X)=>f8.parse(X))},async getModelSnapshot(){return j$($.runtimeSocket,"getModelSnapshot",void 0,(X)=>s2.parse(X))},async refreshModelSnapshot(X){return j$($.runtimeSocket,"refreshModelSnapshot",X,(Y)=>s2.parse(Y))},async setCurrentModel(X){return j$($.runtimeSocket,"setCurrentModel",{model:X},(Y)=>s2.parse(Y))},async getSessionCredentialOverlayState(){return j$($.runtimeSocket,"getSessionCredentialOverlayState",void 0,(X)=>o2.parse(X))},async setSessionCredentialOverlay(X){return j$($.runtimeSocket,"setSessionCredentialOverlay",UG.parse(X),(Y)=>o2.parse(Y))},async clearSessionCredentialOverlay(){return j$($.runtimeSocket,"clearSessionCredentialOverlay",void 0,(X)=>o2.parse(X))},async startAutonomousLoop(X){return j$($.runtimeSocket,"startAutonomousLoop",n2.optional().parse(X),(Y)=>f8.parse(Y))},async stopAutonomousLoop(){return j$($.runtimeSocket,"stopAutonomousLoop",void 0,(X)=>f8.parse(X))},async getRuntimeBootstrap(){return j$($.runtimeSocket,"getRuntimeBootstrap",void 0,(X)=>u8.parse(X))},async listPendingPairRequests(){return j$($.runtimeSocket,"listPendingPairRequests",void 0,(X)=>_6.array().parse(X))},async respondToPairRequest(X){return j$($.runtimeSocket,"respondToPairRequest",E4.parse(X),(Y)=>M6.parse(Y))},async createInvite(X){return j$($.runtimeSocket,"createInvite",i4.parse(X),(Y)=>o4.parse(Y))},async listPendingInvites(){return j$($.runtimeSocket,"listPendingInvites",void 0,(X)=>q4.array().parse(X))},async acceptInviteToken(X){return j$($.runtimeSocket,"acceptInviteToken",r4.parse(X),(Y)=>t4.parse(Y))},async cancelInvite(X){return j$($.runtimeSocket,"cancelInvite",n6.parse(X),(Y)=>i6.parse(Y))},async invitePeer(X){return j$($.runtimeSocket,"invitePeer",s4.parse(X),(Y)=>a6.parse(Y))},async acceptInvite(X){return j$($.runtimeSocket,"acceptInvite",L4.parse(X),(Y)=>G1.parse(Y))},async directPair(X){return j$($.runtimeSocket,"directPair",z9.parse(X),(Y)=>P6.parse(Y))},async revokePeer(X){return j$($.runtimeSocket,"revokePeer",_4.parse(X),(Y)=>j6.parse(Y))},async repairPeer(X){return j$($.runtimeSocket,"repairPeer",e4.parse(X),(Y)=>o6.parse(Y))},async appendSessionMessages(X,Y){await j$($.runtimeSocket,"sessionAppendMessages",{sessionId:X,messages:Y},()=>{return})},async markSessionCompleted(X){await j$($.runtimeSocket,"sessionMarkCompleted",{sessionId:X},()=>{return})},async replaceSessionMessages(X,Y){await j$($.runtimeSocket,"sessionReplaceMessages",{sessionId:X,messages:Y},()=>{return})}}}function tK($){let Z=s6.parse($.auth);return{...rK({runtimeSocket:$.runtimeSocket,pollIntervalMs:$.pollIntervalMs}),async sendBestEffort(Y){return j$($.runtimeSocket,"sendBestEffort",G8.parse(Y),(Q)=>a4.parse(Q),Z)},async sendDurable(Y){return j$($.runtimeSocket,"sendDurable",G8.parse(Y),(Q)=>n4.parse(Q),Z)},async submitRun(Y){let Q=j8.parse(Y);return ou(j$($.runtimeSocket,"submitRun",Q,(G)=>k9.parse(G),Z))},async resumeRun(Y){return j$($.runtimeSocket,"resumeRun",l4.parse(Y),(Q)=>k9.parse(Q),Z)},streamRun(Y,Q){return gN($.runtimeSocket,"streamRun",j8.parse(Y),(G)=>q6.parse(G),Q,Z)},async listAttachedClients(){return j$($.runtimeSocket,"listAttachedClients",void 0,(Y)=>bZ.array().parse(Y),Z)},listDirectClientInbox:async(Y)=>j$($.runtimeSocket,"listDirectClientInbox",r9.optional().parse(Y),(Q)=>c8.array().parse(Q),Z),subscribeDirectClientInbox(Y){return gN($.runtimeSocket,"subscribeDirectClientInbox",A7.optional().parse(Y),(Q)=>c8.parse(Q),void 0,Z)}}}var su=_(()=>{W8()});var LG="x-aria-local-client-id",AG="x-aria-local-client-proof";import{existsSync as ru}from"fs";import{createRequire as jG0}from"module";import{join as TG0}from"path";function eu(){return cC("bun:sqlite")}function $p(){let $=process.env.ARIA_BUN_CUSTOM_SQLITE_PATH?.trim();if($)return ru($)?$:null;if(process.platform==="darwin"){let J=["/opt/homebrew/opt/sqlite/lib/libsqlite3.dylib","/usr/local/opt/sqlite/lib/libsqlite3.dylib"].find((X)=>ru(X));if(J)return J}return null}function uC(){let $=globalThis,Z=$[tu];if(Z&&typeof Z==="object")return Z;let J={attempted:!1};return $[tu]=J,J}function Zp(){let $=uC();if($.attempted)return;$.attempted=!0;let Z=$p();if(!Z)return;eu().Database.setCustomSQLite?.(Z),$.customPath=Z}function qG(){Zp()}function Jp($){if($&&typeof $==="object"){let Z=$;return{changes:typeof Z.changes==="number"?Z.changes:typeof Z.affectedRows==="number"?Z.affectedRows:0,lastInsertRowid:typeof Z.lastInsertRowid==="number"||typeof Z.lastInsertRowid==="bigint"?Z.lastInsertRowid:void 0}}return{changes:0}}function CG0($){return{run(...Z){return Jp($.run(...Z))},get(...Z){let J=$.get(...Z);return J===null?void 0:J},all(...Z){return $.all(...Z)}}}function RG0(){return cC("better-sqlite3")}function wG0($){return{run(...Z){let J=$.run(...Z);return{changes:J.changes,lastInsertRowid:J.lastInsertRowid}},get(...Z){return $.get(...Z)},all(...Z){return $.all(...Z)}}}function SG0($){let J=new(RG0())($.path,$.readonly?{readonly:!0}:void 0);return{kind:"better-sqlite3",nativeHandle:J,capabilities:{pragmas:!0,transactions:!0,preparedStatements:!0,loadableExtensions:!0,customSQLiteConfigured:!1},pragma(X,Y){let Q=X.trim();if(Q.includes("=")||/^wal_checkpoint/i.test(Q)){J.pragma(Q);return}if(Y?.simple)return J.pragma(Q,{simple:!0});return J.prepare(`PRAGMA ${Q}`).all()},exec(X){J.exec(X)},prepare(X){return wG0(J.prepare(X))},transaction(X){return J.transaction(X)},close(){J.close()},loadExtension:J.loadExtension?(X)=>{J.loadExtension(X)}:void 0}}function E7($){let Z;try{Z=eu()}catch(Y){if(process.env.VITEST||process.argv.some((Q)=>Q.includes("vitest"))||process.argv.some((Q)=>Q.includes("vite")))return _7($);throw Error(`[sqlite-open] bun:sqlite failed to load under Bun runtime: ${Y instanceof Error?Y.message:String(Y)}`)}Zp();let J=uC(),X=new Z.Database($.path,{create:!$.readonly,readonly:$.readonly??!1});return{kind:"bun",nativeHandle:X,capabilities:{pragmas:!0,transactions:!0,preparedStatements:!0,loadableExtensions:J.customPath!==void 0||process.platform!=="darwin",customSQLiteConfigured:J.customPath!==void 0,...J.customPath?{customSQLitePath:J.customPath}:{}},pragma(Y,Q){let G=Y.trim();if(G.includes("=")||/^wal_checkpoint/i.test(G)){X.exec(`PRAGMA ${G}`);return}let V=typeof X.query==="function"?X.query.bind(X):X.prepare?.bind(X);if(!V){X.exec(`PRAGMA ${G}`);return}if(Q?.simple){let W=V(`PRAGMA ${G}`).get();if(!W)return;let H=Object.values(W);return H.length===1?H[0]:W}return V(`PRAGMA ${G}`).all()},exec(Y){X.exec(Y)},prepare(Y){let Q=typeof X.prepare==="function"?X.prepare(Y):X.query?.(Y);if(!Q)throw Error("[sqlite] No prepare/query API available on bun:sqlite Database");return CG0(Q)},transaction(Y){return X.transaction(Y)},close(){X.close()},loadExtension:X.loadExtension?(Y)=>{X.loadExtension(Y)}:void 0}}function IG0(){return cC("node:sqlite")}function bG0($){return{run(...Z){return Jp($.run(...Z))},get(...Z){return $.get(...Z)},all(...Z){return $.all(...Z)}}}function kG0($){let{DatabaseSync:Z}=IG0(),J=new Z($.path,{readOnly:$.readonly??!1,open:!0});return{kind:"node:sqlite",nativeHandle:J,capabilities:{pragmas:!0,transactions:!0,preparedStatements:!0,loadableExtensions:!1,customSQLiteConfigured:!1},pragma(X,Y){let Q=X.trim();if(Q.includes("=")||/^wal_checkpoint/i.test(Q)){J.exec(`PRAGMA ${Q}`);return}let G=J.prepare(`PRAGMA ${Q}`);if(Y?.simple){let V=G.get();if(!V)return;let W=Object.values(V);return W.length===1?W[0]:V}return G.all()},exec(X){J.exec(X)},prepare(X){return bG0(J.prepare(X))},transaction(X){return(...Y)=>{J.exec("BEGIN");try{let Q=X(...Y);return J.exec("COMMIT"),Q}catch(Q){throw J.exec("ROLLBACK"),Q}}},close(){J.close()}}}function _7($){try{return SG0($)}catch{return kG0($)}}function mN(){return $p()}function cN(){return uC().customPath}var cC,tu="__ARIA_BUN_SQLITE_CONFIG_STATE__";var pC=_(()=>{cC=jG0(TG0(process.cwd(),"__aria_module_loader__.js"))});import Xp from"fs";import fG0 from"os";import Yp from"path";function Qp($="test.db"){let Z=Xp.mkdtempSync(Yp.join(fG0.tmpdir(),"aria-sqlite-test-")),J=Yp.join(Z,$),X=_7({path:J});return{db:X,dbPath:J,tempDir:Z,cleanup(){try{X.close()}catch{}Xp.rmSync(Z,{recursive:!0,force:!0})}}}var Gp=_(()=>{pC()});var Vp={};M$(Vp,{openCompatSqliteDatabase:()=>_7,openBunRuntimeSqliteDatabase:()=>E7,getResolvedBunCustomSqlitePath:()=>mN,getConfiguredBunCustomSqlitePath:()=>cN,createTestDatabase:()=>Qp,configureBunCustomSqlite:()=>qG});var EG=_(()=>{pC();Gp()});import{createHash as yG0}from"crypto";function e$($,Z){let J=yG0("sha256");if(typeof $==="string")if(Z)J.update($,Z);else J.update($);else J.update($);return J.digest("hex")}var Wp=()=>{};import{EventEmitter as vG0}from"events";import{randomUUID as hG0}from"crypto";var UX;var dC=_(()=>{UX=class UX extends vG0{stdin;stdout;pending=new Map;buffer="";requestTimeout;constructor($={}){super();this.requestTimeout=$.timeout??30000}connect($,Z){this.stdin=$,this.stdout=Z,Z.on("data",(J)=>{this.buffer+=J.toString(),this.processBuffer()}),Z.on("error",(J)=>{this.emit("error",J)}),Z.on("end",()=>{this.emit("close")})}processBuffer(){let $;while(($=this.buffer.indexOf(`
15
15
  `))!==-1){let Z=this.buffer.slice(0,$).trim();if(this.buffer=this.buffer.slice($+1),Z)try{this.handleMessage(JSON.parse(Z))}catch(J){this.emit("error",Error(`Invalid JSON: ${Z}`))}}}handleMessage($){if(typeof $!=="object"||$===null||!("jsonrpc"in $)||$.jsonrpc!=="2.0")return;let Z=$;if("id"in Z&&Z.id!==void 0){let J=Z,X=this.pending.get(String(J.id));if(X)if(this.pending.delete(String(J.id)),clearTimeout(X.timeout),J.error)X.reject(Error(`${J.error.code}: ${J.error.message}`));else X.resolve(J.result);return}if("method"in Z){let J=Z;this.emit(J.method,J.params),this.emit("notification",{method:J.method,params:J.params})}}async request($,Z){if(!this.stdin)throw Error("Not connected");let J=hG0(),X={jsonrpc:"2.0",id:J,method:$,params:Z};return new Promise((Y,Q)=>{let G=setTimeout(()=>{if(this.pending.has(J))this.pending.delete(J),Q(Error(`Request timeout: ${$}`))},this.requestTimeout);this.pending.set(J,{resolve:Y,reject:Q,timeout:G}),this.send(X)})}notify($,Z){let J={jsonrpc:"2.0",method:$,params:Z};this.send(J)}send($){if(!this.stdin)throw Error("Not connected");this.stdin.write(JSON.stringify($)+`
16
- `)}close(){for(let[,$]of this.pending)clearTimeout($.timeout),$.reject(Error("Connection closed"));this.pending.clear(),this.buffer="",this.stdin=void 0,this.stdout?.removeAllListeners(),this.stdout=void 0}}});import{spawn as xG0}from"child_process";import{EventEmitter as gG0}from"events";import{PassThrough as mG0,Writable as cG0}from"stream";function Hp($=process.env){let Z={};for(let[J,X]of Object.entries($)){if(X===void 0)continue;if(J.toUpperCase().startsWith("GIT_"))continue;Z[J]=X}return Z}var uG0="1.0.47",pG0,U1;var lC=_(()=>{dC();pG0={name:"aria-cli",version:uG0};U1=class U1 extends gG0{config;process;transport="stdio";rpc;capabilities={};_initialized=!1;sseAbortController;sseStreamPromise;ssePostUrl;sseSessionId;sseOutput;_disconnecting=!1;_reconnecting=!1;_reconnectAttempts=0;static RECONNECT_BASE_DELAY_MS=1000;static RECONNECT_MAX_DELAY_MS=30000;static RECONNECT_MAX_ATTEMPTS=5;constructor($){super();this.config=$,this.rpc=new UX}get name(){return this.config.name}get initialized(){return this._initialized}async initialize(){if(!this._reconnecting)this._disconnecting=!1,this._reconnectAttempts=0;this.transport=this.config.transport??"stdio";try{if(this.transport==="stdio")await this.initializeStdioTransport();else await this.initializeSSETransport();this.rpc.on("notifications/tools/list_changed",()=>this.emit("tools/list_changed")),this.rpc.on("notifications/resources/list_changed",()=>this.emit("resources/list_changed")),this.rpc.on("notifications/prompts/list_changed",()=>this.emit("prompts/list_changed"));let $=await this.rpc.request("initialize",{protocolVersion:"2024-11-05",capabilities:{roots:{listChanged:!0}},clientInfo:pG0});return this.capabilities=$.capabilities||{},this._initialized=!0,this.rpc.notify("notifications/initialized",{}),this.capabilities}catch($){throw await this.cleanupAfterInitializeFailure(),$}}async attemptReconnect(){if(this._disconnecting||this._reconnecting)return;this._reconnecting=!0;while(this._reconnectAttempts<U1.RECONNECT_MAX_ATTEMPTS&&!this._disconnecting){this._reconnectAttempts++;let $=Math.min(U1.RECONNECT_BASE_DELAY_MS*Math.pow(2,this._reconnectAttempts-1),U1.RECONNECT_MAX_DELAY_MS);if(this.emit("log",{level:"info",message:`Reconnect attempt ${this._reconnectAttempts}/${U1.RECONNECT_MAX_ATTEMPTS} in ${$}ms`}),await new Promise((Z)=>setTimeout(Z,$)),this._disconnecting)break;try{this.rpc.close(),this.rpc=new UX,await this.initialize(),this._reconnectAttempts=0,this._reconnecting=!1,this.emit("reconnected");return}catch(Z){this.emit("log",{level:"error",message:`Reconnect attempt ${this._reconnectAttempts} failed: ${Z.message}`})}}if(this._reconnecting=!1,!this._disconnecting)this._initialized=!1,this.emit("error",Error(`Failed to reconnect after ${U1.RECONNECT_MAX_ATTEMPTS} attempts`))}async initializeStdioTransport(){if(!this.config.command)throw Error("Command required for stdio transport");if(this.process=xG0(this.config.command,this.config.args||[],{env:{...Hp(),...Hp(this.config.env??{})},stdio:["pipe","pipe","pipe"]}),!this.process.stdin||!this.process.stdout)throw Error("Failed to create stdio streams");this.rpc.connect(this.process.stdin,this.process.stdout),this.process.stderr?.on("data",($)=>{this.emit("log",{level:"error",message:$.toString()})}),this.process.on("exit",($)=>{if(this._initialized=!1,this.rpc.close(),this.emit("exit",$),!this._disconnecting)this.attemptReconnect()})}async initializeSSETransport(){let $=this.config.url;if(!$)throw Error("URL required for sse transport");let Z=new cG0({write:(Y,Q,G)=>{let V=Y.toString();this.postSSEMessages(V).then(()=>G()).catch((W)=>G(W))}}),J=new mG0;this.sseOutput=J,this.rpc.connect(Z,J),this.sseAbortController=new AbortController;let X=await fetch($,{method:"GET",headers:{Accept:"text/event-stream"},signal:this.sseAbortController.signal});if(!X.ok||!X.body){let Y=await X.text();throw Error(`Failed to connect SSE transport: ${X.status} ${X.statusText} ${Y}`)}this.sseSessionId=X.headers.get("mcp-session-id")??void 0,this.ssePostUrl=$,this.sseStreamPromise=this.consumeSSE(X.body,$)}async postSSEMessages($){let Z=$.trim();if(!Z)return;let J=this.ssePostUrl||this.config.url;if(!J)throw Error("SSE transport endpoint is not configured");let X=Z.split(`
16
+ `)}close(){for(let[,$]of this.pending)clearTimeout($.timeout),$.reject(Error("Connection closed"));this.pending.clear(),this.buffer="",this.stdin=void 0,this.stdout?.removeAllListeners(),this.stdout=void 0}}});import{spawn as xG0}from"child_process";import{EventEmitter as gG0}from"events";import{PassThrough as mG0,Writable as cG0}from"stream";function Hp($=process.env){let Z={};for(let[J,X]of Object.entries($)){if(X===void 0)continue;if(J.toUpperCase().startsWith("GIT_"))continue;Z[J]=X}return Z}var uG0="1.0.48",pG0,U1;var lC=_(()=>{dC();pG0={name:"aria-cli",version:uG0};U1=class U1 extends gG0{config;process;transport="stdio";rpc;capabilities={};_initialized=!1;sseAbortController;sseStreamPromise;ssePostUrl;sseSessionId;sseOutput;_disconnecting=!1;_reconnecting=!1;_reconnectAttempts=0;static RECONNECT_BASE_DELAY_MS=1000;static RECONNECT_MAX_DELAY_MS=30000;static RECONNECT_MAX_ATTEMPTS=5;constructor($){super();this.config=$,this.rpc=new UX}get name(){return this.config.name}get initialized(){return this._initialized}async initialize(){if(!this._reconnecting)this._disconnecting=!1,this._reconnectAttempts=0;this.transport=this.config.transport??"stdio";try{if(this.transport==="stdio")await this.initializeStdioTransport();else await this.initializeSSETransport();this.rpc.on("notifications/tools/list_changed",()=>this.emit("tools/list_changed")),this.rpc.on("notifications/resources/list_changed",()=>this.emit("resources/list_changed")),this.rpc.on("notifications/prompts/list_changed",()=>this.emit("prompts/list_changed"));let $=await this.rpc.request("initialize",{protocolVersion:"2024-11-05",capabilities:{roots:{listChanged:!0}},clientInfo:pG0});return this.capabilities=$.capabilities||{},this._initialized=!0,this.rpc.notify("notifications/initialized",{}),this.capabilities}catch($){throw await this.cleanupAfterInitializeFailure(),$}}async attemptReconnect(){if(this._disconnecting||this._reconnecting)return;this._reconnecting=!0;while(this._reconnectAttempts<U1.RECONNECT_MAX_ATTEMPTS&&!this._disconnecting){this._reconnectAttempts++;let $=Math.min(U1.RECONNECT_BASE_DELAY_MS*Math.pow(2,this._reconnectAttempts-1),U1.RECONNECT_MAX_DELAY_MS);if(this.emit("log",{level:"info",message:`Reconnect attempt ${this._reconnectAttempts}/${U1.RECONNECT_MAX_ATTEMPTS} in ${$}ms`}),await new Promise((Z)=>setTimeout(Z,$)),this._disconnecting)break;try{this.rpc.close(),this.rpc=new UX,await this.initialize(),this._reconnectAttempts=0,this._reconnecting=!1,this.emit("reconnected");return}catch(Z){this.emit("log",{level:"error",message:`Reconnect attempt ${this._reconnectAttempts} failed: ${Z.message}`})}}if(this._reconnecting=!1,!this._disconnecting)this._initialized=!1,this.emit("error",Error(`Failed to reconnect after ${U1.RECONNECT_MAX_ATTEMPTS} attempts`))}async initializeStdioTransport(){if(!this.config.command)throw Error("Command required for stdio transport");if(this.process=xG0(this.config.command,this.config.args||[],{env:{...Hp(),...Hp(this.config.env??{})},stdio:["pipe","pipe","pipe"]}),!this.process.stdin||!this.process.stdout)throw Error("Failed to create stdio streams");this.rpc.connect(this.process.stdin,this.process.stdout),this.process.stderr?.on("data",($)=>{this.emit("log",{level:"error",message:$.toString()})}),this.process.on("exit",($)=>{if(this._initialized=!1,this.rpc.close(),this.emit("exit",$),!this._disconnecting)this.attemptReconnect()})}async initializeSSETransport(){let $=this.config.url;if(!$)throw Error("URL required for sse transport");let Z=new cG0({write:(Y,Q,G)=>{let V=Y.toString();this.postSSEMessages(V).then(()=>G()).catch((W)=>G(W))}}),J=new mG0;this.sseOutput=J,this.rpc.connect(Z,J),this.sseAbortController=new AbortController;let X=await fetch($,{method:"GET",headers:{Accept:"text/event-stream"},signal:this.sseAbortController.signal});if(!X.ok||!X.body){let Y=await X.text();throw Error(`Failed to connect SSE transport: ${X.status} ${X.statusText} ${Y}`)}this.sseSessionId=X.headers.get("mcp-session-id")??void 0,this.ssePostUrl=$,this.sseStreamPromise=this.consumeSSE(X.body,$)}async postSSEMessages($){let Z=$.trim();if(!Z)return;let J=this.ssePostUrl||this.config.url;if(!J)throw Error("SSE transport endpoint is not configured");let X=Z.split(`
17
17
  `).map((Y)=>Y.trim()).filter((Y)=>Y.length>0);for(let Y of X){let Q=await fetch(J,{method:"POST",headers:{"Content-Type":"application/json",...this.sseSessionId?{"mcp-session-id":this.sseSessionId}:{}},body:Y});if(!Q.ok){let V=await Q.text();throw Error(`SSE transport POST failed: ${Q.status} ${Q.statusText} ${V}`)}let G=(await Q.text()).trim();if(!G||!this.sseOutput)continue;for(let V of G.split(`
18
18
  `)){let W=V.trim();if(!W)continue;if(W.startsWith("{")&&W.endsWith("}"))this.sseOutput.write(`${W}
19
19
  `)}}}async consumeSSE($,Z){let J=$.getReader(),X=new TextDecoder,Y="",Q="",G=[],V=()=>{if(G.length===0){Q="";return}let W=G.join(`
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aria-cli/cli",
3
- "version": "1.0.47",
3
+ "version": "1.0.48",
4
4
  "description": "ARIA - Adaptive Reasoning Intelligence Agent",
5
5
  "type": "module",
6
6
  "bin": {