@aria-cli/cli 1.0.44 → 1.0.45

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 kQ0=Object.create;var{getPrototypeOf:fQ0,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 au(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 du(()=>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 du(()=>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 au(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 nu=_(()=>{W8()});var LG="x-aria-local-client-id",AG="x-aria-local-client-proof";import{existsSync as iu}from"fs";import{createRequire as EG0}from"module";import{join as _G0}from"path";function su(){return uC("bun:sqlite")}function ru(){let $=process.env.ARIA_BUN_CUSTOM_SQLITE_PATH?.trim();if($)return iu($)?$:null;if(process.platform==="darwin"){let J=["/opt/homebrew/opt/sqlite/lib/libsqlite3.dylib","/usr/local/opt/sqlite/lib/libsqlite3.dylib"].find((X)=>iu(X));if(J)return J}return null}function pC(){let $=globalThis,Z=$[ou];if(Z&&typeof Z==="object")return Z;let J={attempted:!1};return $[ou]=J,J}function tu(){let $=pC();if($.attempted)return;$.attempted=!0;let Z=ru();if(!Z)return;su().Database.setCustomSQLite?.(Z),$.customPath=Z}function qG(){tu()}function eu($){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 MG0($){return{run(...Z){return eu($.run(...Z))},get(...Z){let J=$.get(...Z);return J===null?void 0:J},all(...Z){return $.all(...Z)}}}function PG0(){return uC("better-sqlite3")}function jG0($){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 TG0($){let J=new(PG0())($.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 jG0(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=su()}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)}`)}tu();let J=pC(),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 MG0(Q)},transaction(Y){return X.transaction(Y)},close(){X.close()},loadExtension:X.loadExtension?(Y)=>{X.loadExtension(Y)}:void 0}}function CG0(){return uC("node:sqlite")}function RG0($){return{run(...Z){return eu($.run(...Z))},get(...Z){return $.get(...Z)},all(...Z){return $.all(...Z)}}}function wG0($){let{DatabaseSync:Z}=CG0(),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 RG0(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 TG0($)}catch{return wG0($)}}function mN(){return ru()}function cN(){return pC().customPath}var uC,ou="__ARIA_BUN_SQLITE_CONFIG_STATE__";var dC=_(()=>{uC=EG0(_G0(process.cwd(),"__aria_module_loader__.js"))});import $p from"fs";import SG0 from"os";import Zp from"path";function Jp($="test.db"){let Z=$p.mkdtempSync(Zp.join(SG0.tmpdir(),"aria-sqlite-test-")),J=Zp.join(Z,$),X=_7({path:J});return{db:X,dbPath:J,tempDir:Z,cleanup(){try{X.close()}catch{}$p.rmSync(Z,{recursive:!0,force:!0})}}}var Xp=_(()=>{dC()});var Yp={};M$(Yp,{openCompatSqliteDatabase:()=>_7,openBunRuntimeSqliteDatabase:()=>E7,getResolvedBunCustomSqlitePath:()=>mN,getConfiguredBunCustomSqlitePath:()=>cN,createTestDatabase:()=>Jp,configureBunCustomSqlite:()=>qG});var EG=_(()=>{dC();Xp()});import{createHash as IG0}from"crypto";function e$($,Z){let J=IG0("sha256");if(typeof $==="string")if(Z)J.update($,Z);else J.update($);else J.update($);return J.digest("hex")}var Qp=()=>{};import{EventEmitter as bG0}from"events";import{randomUUID as kG0}from"crypto";var UX;var lC=_(()=>{UX=class UX extends bG0{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=kG0(),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 fG0}from"child_process";import{EventEmitter as yG0}from"events";import{PassThrough as vG0,Writable as hG0}from"stream";function Gp($=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 xG0="1.0.44",gG0,U1;var aC=_(()=>{lC();gG0={name:"aria-cli",version:xG0};U1=class U1 extends yG0{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:gG0});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=fG0(this.config.command,this.config.args||[],{env:{...Gp(),...Gp(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 hG0({write:(Y,Q,G)=>{let V=Y.toString();this.postSSEMessages(V).then(()=>G()).catch((W)=>G(W))}}),J=new vG0;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 fG0}from"child_process";import{EventEmitter as yG0}from"events";import{PassThrough as vG0,Writable as hG0}from"stream";function Gp($=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 xG0="1.0.45",gG0,U1;var aC=_(()=>{lC();gG0={name:"aria-cli",version:xG0};U1=class U1 extends yG0{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:gG0});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=fG0(this.config.command,this.config.args||[],{env:{...Gp(),...Gp(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 hG0({write:(Y,Q,G)=>{let V=Y.toString();this.postSSEMessages(V).then(()=>G()).catch((W)=>G(W))}}),J=new vG0;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.44",
3
+ "version": "1.0.45",
4
4
  "description": "ARIA - Adaptive Reasoning Intelligence Agent",
5
5
  "type": "module",
6
6
  "bin": {