@aria-cli/cli 1.0.63 → 1.0.64

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 +2 -2
  2. package/package.json +4 -4
package/bin/aria.mjs CHANGED
@@ -14,7 +14,7 @@ var HG0=Object.create;var{getPrototypeOf:KG0,defineProperty:MK,getOwnPropertyNam
14
14
  `)});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(`
15
15
  `);if(O===-1)break;let L=W.slice(0,O).trim();if(W=W.slice(O+1),L.length===0)continue;try{let q=I5.parse(JSON.parse(L));if(q.id!==G.id){K=Error("Local control socket response ID mismatch");break}if(!q.ok){let A=w5(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)=>P$($.runtimeSocket,"listInbox",r9.optional().parse(X),(Y)=>m8.array().parse(Y));return{async submitRun(X){let Y=P8.parse(X);return Kp(P$($.runtimeSocket,"submitRun",Y,(Q)=>k9.parse(Q)))},async resumeRun(X){return P$($.runtimeSocket,"resumeRun",a4.parse(X),(Y)=>k9.parse(Y))},streamRun(X,Y){return uN($.runtimeSocket,"streamRun",P8.parse(X),(Q)=>E6.parse(Q),Y)},subscribeRuntimeEvents(X){return uN($.runtimeSocket,"subscribeRuntimeEvents",E7.optional().parse(X),(Y)=>Q1.parse(Y))},async sendBestEffort(X){return P$($.runtimeSocket,"sendBestEffort",Q8.parse(X),(Y)=>n4.parse(Y))},async sendDurable(X){return P$($.runtimeSocket,"sendDurable",Q8.parse(X),(Y)=>i4.parse(Y))},listInbox:J,subscribeInbox(X){return Wp(()=>J({limit:100,unreadOnly:!1}),{pollIntervalMs:Z,initialAfterCreatedAt:X?.afterCreatedAt??0})},async listPeers(){return P$($.runtimeSocket,"listPeers",void 0,(X)=>q4.array().parse(X))},async listNearbyPeers(){return P$($.runtimeSocket,"listNearbyPeers",void 0,(X)=>_6.array().parse(X))},subscribePeers(){return Wp(()=>P$($.runtimeSocket,"listPeers",void 0,(X)=>q4.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 P$($.runtimeSocket,"getRuntimeStatus",void 0,(X)=>k8.parse(X))},async getModelSnapshot(){return P$($.runtimeSocket,"getModelSnapshot",void 0,(X)=>e2.parse(X))},async refreshModelSnapshot(X){return P$($.runtimeSocket,"refreshModelSnapshot",X,(Y)=>e2.parse(Y))},async setCurrentModel(X){return P$($.runtimeSocket,"setCurrentModel",{model:X},(Y)=>e2.parse(Y))},async getSessionCredentialOverlayState(){return P$($.runtimeSocket,"getSessionCredentialOverlayState",void 0,(X)=>t2.parse(X))},async setSessionCredentialOverlay(X){return P$($.runtimeSocket,"setSessionCredentialOverlay",OG.parse(X),(Y)=>t2.parse(Y))},async clearSessionCredentialOverlay(){return P$($.runtimeSocket,"clearSessionCredentialOverlay",void 0,(X)=>t2.parse(X))},async startAutonomousLoop(X){return P$($.runtimeSocket,"startAutonomousLoop",s2.optional().parse(X),(Y)=>k8.parse(Y))},async stopAutonomousLoop(){return P$($.runtimeSocket,"stopAutonomousLoop",void 0,(X)=>k8.parse(X))},async getRuntimeBootstrap(){return P$($.runtimeSocket,"getRuntimeBootstrap",void 0,(X)=>c8.parse(X))},async listPendingPairRequests(){return P$($.runtimeSocket,"listPendingPairRequests",void 0,(X)=>M6.array().parse(X))},async respondToPairRequest(X){return P$($.runtimeSocket,"respondToPairRequest",_4.parse(X),(Y)=>P6.parse(Y))},async createInvite(X){return P$($.runtimeSocket,"createInvite",o4.parse(X),(Y)=>s4.parse(Y))},async listPendingInvites(){return P$($.runtimeSocket,"listPendingInvites",void 0,(X)=>E4.array().parse(X))},async acceptInviteToken(X){return P$($.runtimeSocket,"acceptInviteToken",t4.parse(X),(Y)=>e4.parse(Y))},async cancelInvite(X){return P$($.runtimeSocket,"cancelInvite",o6.parse(X),(Y)=>s6.parse(Y))},async invitePeer(X){return P$($.runtimeSocket,"invitePeer",r4.parse(X),(Y)=>i6.parse(Y))},async acceptInvite(X){return P$($.runtimeSocket,"acceptInvite",A4.parse(X),(Y)=>V1.parse(Y))},async directPair(X){return P$($.runtimeSocket,"directPair",z9.parse(X),(Y)=>j6.parse(Y))},async revokePeer(X){return P$($.runtimeSocket,"revokePeer",M4.parse(X),(Y)=>T6.parse(Y))},async repairPeer(X){return P$($.runtimeSocket,"repairPeer",$6.parse(X),(Y)=>r6.parse(Y))},async appendSessionMessages(X,Y){await P$($.runtimeSocket,"sessionAppendMessages",{sessionId:X,messages:Y},()=>{return})},async markSessionCompleted(X){await P$($.runtimeSocket,"sessionMarkCompleted",{sessionId:X},()=>{return})},async replaceSessionMessages(X,Y){await P$($.runtimeSocket,"sessionReplaceMessages",{sessionId:X,messages:Y},()=>{return})}}}function tK($){let Z=t6.parse($.auth);return{...rK({runtimeSocket:$.runtimeSocket,pollIntervalMs:$.pollIntervalMs}),async sendBestEffort(Y){return P$($.runtimeSocket,"sendBestEffort",Q8.parse(Y),(Q)=>n4.parse(Q),Z)},async sendDurable(Y){return P$($.runtimeSocket,"sendDurable",Q8.parse(Y),(Q)=>i4.parse(Q),Z)},async submitRun(Y){let Q=P8.parse(Y);return Kp(P$($.runtimeSocket,"submitRun",Q,(G)=>k9.parse(G),Z))},async resumeRun(Y){return P$($.runtimeSocket,"resumeRun",a4.parse(Y),(Q)=>k9.parse(Q),Z)},streamRun(Y,Q){return uN($.runtimeSocket,"streamRun",P8.parse(Y),(G)=>E6.parse(G),Q,Z)},async listAttachedClients(){return P$($.runtimeSocket,"listAttachedClients",void 0,(Y)=>kZ.array().parse(Y),Z)},listDirectClientInbox:async(Y)=>P$($.runtimeSocket,"listDirectClientInbox",r9.optional().parse(Y),(Q)=>m8.array().parse(Q),Z),subscribeDirectClientInbox(Y){return uN($.runtimeSocket,"subscribeDirectClientInbox",_7.optional().parse(Y),(Q)=>m8.parse(Q),void 0,Z)}}}var zp=E(()=>{V8()});var _G="x-aria-local-client-id",MG="x-aria-local-client-proof";import{existsSync as Up}from"fs";import{createRequire as rG0}from"module";import{join as tG0}from"path";function Fp(){return aC("bun:sqlite")}function Dp(){let $=process.env.ARIA_BUN_CUSTOM_SQLITE_PATH?.trim();if($)return Up($)?$:null;if(process.platform==="darwin"){let J=["/opt/homebrew/opt/sqlite/lib/libsqlite3.dylib","/usr/local/opt/sqlite/lib/libsqlite3.dylib"].find((X)=>Up(X));if(J)return J}return null}function nC(){let $=globalThis,Z=$[Bp];if(Z&&typeof Z==="object")return Z;let J={attempted:!1};return $[Bp]=J,J}function Op(){let $=nC();if($.attempted)return;$.attempted=!0;let Z=Dp();if(!Z)return;Fp().Database.setCustomSQLite?.(Z),$.customPath=Z}function PG(){Op()}function Np($){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 eG0($){return{run(...Z){return Np($.run(...Z))},get(...Z){let J=$.get(...Z);return J===null?void 0:J},all(...Z){return $.all(...Z)}}}function $V0(){return aC("better-sqlite3")}function ZV0($){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 JV0($){let J=new($V0())($.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 ZV0(J.prepare(X))},transaction(X){return J.transaction(X)},close(){J.close()},loadExtension:J.loadExtension?(X)=>{J.loadExtension(X)}:void 0}}function P7($){let Z;try{Z=Fp()}catch(Y){if(process.env.VITEST||process.argv.some((Q)=>Q.includes("vitest"))||process.argv.some((Q)=>Q.includes("vite")))return j7($);throw Error(`[sqlite-open] bun:sqlite failed to load under Bun runtime: ${Y instanceof Error?Y.message:String(Y)}`)}Op();let J=nC(),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 eG0(Q)},transaction(Y){return X.transaction(Y)},close(){X.close()},loadExtension:X.loadExtension?(Y)=>{X.loadExtension(Y)}:void 0}}function XV0(){return aC("node:sqlite")}function YV0($){return{run(...Z){return Np($.run(...Z))},get(...Z){return $.get(...Z)},all(...Z){return $.all(...Z)}}}function QV0($){let{DatabaseSync:Z}=XV0(),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 YV0(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 j7($){try{return JV0($)}catch{return QV0($)}}function pN(){return Dp()}function dN(){return nC().customPath}var aC,Bp="__ARIA_BUN_SQLITE_CONFIG_STATE__";var iC=E(()=>{aC=rG0(tG0(process.cwd(),"__aria_module_loader__.js"))});import Lp from"fs";import GV0 from"os";import Ap from"path";function qp($="test.db"){let Z=Lp.mkdtempSync(Ap.join(GV0.tmpdir(),"aria-sqlite-test-")),J=Ap.join(Z,$),X=j7({path:J});return{db:X,dbPath:J,tempDir:Z,cleanup(){try{X.close()}catch{}Lp.rmSync(Z,{recursive:!0,force:!0})}}}var Ep=E(()=>{iC()});var _p={};A$(_p,{openCompatSqliteDatabase:()=>j7,openBunRuntimeSqliteDatabase:()=>P7,getResolvedBunCustomSqlitePath:()=>pN,getConfiguredBunCustomSqlitePath:()=>dN,createTestDatabase:()=>qp,configureBunCustomSqlite:()=>PG});var jG=E(()=>{iC();Ep()});import{createHash as VV0}from"crypto";function t$($,Z){let J=VV0("sha256");if(typeof $==="string")if(Z)J.update($,Z);else J.update($);else J.update($);return J.digest("hex")}var Mp=()=>{};import{EventEmitter as WV0}from"events";import{randomUUID as HV0}from"crypto";var DX;var oC=E(()=>{DX=class DX extends WV0{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(`
16
16
  `))!==-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=HV0(),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($)+`
17
- `)}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 KV0}from"child_process";import{EventEmitter as zV0}from"events";import{PassThrough as UV0,Writable as BV0}from"stream";function Pp($=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 FV0="1.0.63",DV0,B1;var sC=E(()=>{oC();DV0={name:"aria-cli",version:FV0};B1=class B1 extends zV0{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 DX}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:DV0});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<B1.RECONNECT_MAX_ATTEMPTS&&!this._disconnecting){this._reconnectAttempts++;let $=Math.min(B1.RECONNECT_BASE_DELAY_MS*Math.pow(2,this._reconnectAttempts-1),B1.RECONNECT_MAX_DELAY_MS);if(this.emit("log",{level:"info",message:`Reconnect attempt ${this._reconnectAttempts}/${B1.RECONNECT_MAX_ATTEMPTS} in ${$}ms`}),await new Promise((Z)=>setTimeout(Z,$)),this._disconnecting)break;try{this.rpc.close(),this.rpc=new DX,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 ${B1.RECONNECT_MAX_ATTEMPTS} attempts`))}async initializeStdioTransport(){if(!this.config.command)throw Error("Command required for stdio transport");if(this.process=KV0(this.config.command,this.config.args||[],{env:{...Pp(),...Pp(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 BV0({write:(Y,Q,G)=>{let V=Y.toString();this.postSSEMessages(V).then(()=>G()).catch((W)=>G(W))}}),J=new UV0;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
+ `)}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 KV0}from"child_process";import{EventEmitter as zV0}from"events";import{PassThrough as UV0,Writable as BV0}from"stream";function Pp($=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 FV0="1.0.64",DV0,B1;var sC=E(()=>{oC();DV0={name:"aria-cli",version:FV0};B1=class B1 extends zV0{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 DX}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:DV0});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<B1.RECONNECT_MAX_ATTEMPTS&&!this._disconnecting){this._reconnectAttempts++;let $=Math.min(B1.RECONNECT_BASE_DELAY_MS*Math.pow(2,this._reconnectAttempts-1),B1.RECONNECT_MAX_DELAY_MS);if(this.emit("log",{level:"info",message:`Reconnect attempt ${this._reconnectAttempts}/${B1.RECONNECT_MAX_ATTEMPTS} in ${$}ms`}),await new Promise((Z)=>setTimeout(Z,$)),this._disconnecting)break;try{this.rpc.close(),this.rpc=new DX,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 ${B1.RECONNECT_MAX_ATTEMPTS} attempts`))}async initializeStdioTransport(){if(!this.config.command)throw Error("Command required for stdio transport");if(this.process=KV0(this.config.command,this.config.args||[],{env:{...Pp(),...Pp(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 BV0({write:(Y,Q,G)=>{let V=Y.toString();this.postSSEMessages(V).then(()=>G()).catch((W)=>G(W))}}),J=new UV0;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(`
18
18
  `).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(`
19
19
  `)){let W=V.trim();if(!W)continue;if(W.startsWith("{")&&W.endsWith("}"))this.sseOutput.write(`${W}
20
20
  `)}}}async consumeSSE($,Z){let J=$.getReader(),X=new TextDecoder,Y="",Q="",G=[],V=()=>{if(G.length===0){Q="";return}let W=G.join(`
@@ -4724,7 +4724,7 @@ ${$.toString("base64").match(/.{1,64}/g)?.join(`
4724
4724
  CREATE INDEX IF NOT EXISTS idx_delegation_transitions_id
4725
4725
  ON delegation_transitions(delegation_id);
4726
4726
  `)}mapRow($){if(!$)return;let Z=G0.safeParse($.remote_node_id?.trim());return{id:$.id,type:$.type,task:$.task,state:$.state,...$.arion_name?{arionName:$.arion_name}:{},...Z.success?{remoteNodeId:Z.data}:{},...$.remote_display_name_snapshot?{remoteDisplayNameSnapshot:$.remote_display_name_snapshot}:{},...$.tier?{tier:$.tier}:{},...$.result?{result:$.result}:{},...$.error?{error:$.error}:{},createdAt:$.created_at,updatedAt:$.updated_at,...$.metadata?{metadata:$.metadata}:{}}}create($){let Z=Date.now(),J=$.metadata?JSON.stringify($.metadata):null;this.db.transaction(()=>{this.stmtInsert.run($.id,$.type,$.task,"created",$.arionName??null,$.remoteNodeId??null,$.remoteDisplayNameSnapshot??null,$.tier??null,J,Z,Z),this.stmtInsertTransition.run($.id,null,"created",Z,null)})()}transition($,Z,J){let X=Date.now(),Q=this.stmtGet.get($)?.state??null;this.db.transaction(()=>{this.stmtUpdateState.run(Z,X,$),this.stmtInsertTransition.run($,Q,Z,X,J??null)})()}complete($,Z){let J=Date.now(),Y=this.stmtGet.get($)?.state??null;this.db.transaction(()=>{this.stmtUpdateResult.run("completed",Z??null,null,J,$),this.stmtInsertTransition.run($,Y,"completed",J,null)})()}fail($,Z){let J=Date.now(),Y=this.stmtGet.get($)?.state??null;this.db.transaction(()=>{this.stmtUpdateResult.run("failed",null,Z,J,$),this.stmtInsertTransition.run($,Y,"failed",J,Z)})()}get($){return this.mapRow(this.stmtGet.get($))}findRecoverable(){return this.stmtFindNonTerminal.all().map(($)=>this.mapRow($))}cleanup($=86400000){let Z=Date.now()-$;this.db.transaction(()=>{this.stmtCleanup.run(Z),this.stmtCleanupStore.run(Z)})()}record($){switch($.event){case"created":if(!this.get($.id))this.create({id:$.id,type:$.type,task:$.task,arionName:$.arionName,remoteNodeId:$.remoteNodeId,remoteDisplayNameSnapshot:$.remoteDisplayNameSnapshot,tier:$.tier});this.transition($.id,"running");break;case"completed":this.complete($.id,$.result);break;case"failed":this.fail($.id,$.error??"Unknown error");break;case"aborted":this.transition($.id,"aborted");break}}}var h90=E(()=>{V8()});var G8=E(()=>{aB();Z_();aB();aB();aB();x80();i80();GM();oy();QM();sy();b90();ry();KM();Jv();Xv();Yv();DM();Fy();Ny();Gv();Vv();y90();Nf();BM();Wv();h90();t_();K_();G_();b0();u80();hy();U90()});import{jsx as VJ,jsxs as AM}from"react/jsx-runtime";import{useState as vT0,useRef as g90}from"react";import{Box as YF,Text as kY,useInput as hT0}from"ink";function Hv({currentLevel:$,onSelect:Z,onCancel:J,isActive:X=!0}){let Y=e(),Q=iZ.indexOf($),G=Q>=0?Q:0,[V,W]=vT0(G),H=g90(G),K=g90(!1),z=(B)=>{W((F)=>{let D=B(F);return H.current=D,D})},U=process.stdin.isTTY??!1;return hT0((B,F)=>{if(K.current)return;if(F.upArrow)z((D)=>Math.max(0,D-1));else if(F.downArrow)z((D)=>Math.min(iZ.length-1,D+1));else if(F.return)K.current=!0,Z(iZ[H.current]);else if(W$(B,F))K.current=!0,J()},{isActive:X&&U}),AM(YF,{flexDirection:"column",borderStyle:"round",borderColor:Y.colors.secondary,paddingX:1,paddingY:1,width:48,children:[VJ(YF,{marginBottom:1,children:VJ(kY,{bold:!0,children:"Autonomy Level"})}),VJ(YF,{marginBottom:1,children:AM(kY,{children:["Current: ",VJ(kY,{bold:!0,children:$})]})}),iZ.map((B,F)=>{let D=F===V,O=D?"\u25CF":"\u25CB",L=B==="high"||B==="full";return AM(YF,{gap:1,children:[VJ(kY,{color:D?Y.colors.primary:void 0,children:O}),VJ(kY,{color:D?Y.colors.primary:L?Y.colors.warning:void 0,bold:D,children:B.padEnd(10)}),VJ(kY,{color:Y.colors.textMuted,children:xT0[B]})]},B)}),VJ(YF,{marginTop:1,children:AM(kY,{color:Y.colors.textMuted,children:["\u2191\u2193"," Navigate Enter Select Esc Cancel"]})})]})}var xT0;var m90=E(()=>{E0();G8();xT0={minimal:"Confirm all tool calls",balanced:"Confirm dangerous only",high:"Auto-approve everything",full:"Auto-approve everything"}});import{jsxs as qA$,jsx as EA$}from"react/jsx-runtime";import{Box as MA$,Text as PA$}from"ink";var c90=E(()=>{E0()});import{jsx as fY,jsxs as qM}from"react/jsx-runtime";import{Box as EM,Text as yY}from"ink";function cT0($){if($<1000)return`${Math.round($)}ms`;if($<60000)return`${($/1000).toFixed(1)}s`;let Z=Math.floor($/60000),J=Math.round($%60000/1000);return`${Z}m ${J}s`}function u90($,Z,J){let X=Math.round(Z*$),Y=Math.max(gT0,Math.round(J*$)),Q=Math.max(0,$-X-Y);return"\u2591".repeat(X)+"\u2588".repeat(Y)+"\u2591".repeat(Q)}function zv({spans:$,width:Z}){let J=e(),X=Z??mT0,Y=$.filter((K)=>K.endTime!==void 0||K.durationMs!==void 0);if(Y.length===0)return fY(EM,{children:fY(yY,{dimColor:!0,children:"(no completed spans)"})});let Q=Y.map((K)=>{let z=K.durationMs??K.endTime-K.startTime,U=K.endTime??K.startTime+z;return{...K,durationMs:z,endTime:U}}),G=Math.min(...Q.map((K)=>K.startTime)),W=Math.max(...Q.map((K)=>K.endTime))-G;if(W<=0)return fY(EM,{flexDirection:"column",children:Q.map((K)=>qM(yY,{dimColor:!0,children:[Kv[K.spanType]??K.spanType," ","\u2588"," 0ms (",K.name,")"]},K.spanId))});let H=Math.max(...Q.map((K)=>{let z=Kv[K.spanType]??K.spanType;return(K.parentSpanId!==void 0?2:0)+z.length}));return fY(EM,{flexDirection:"column",children:Q.map((K)=>{let z=K.parentSpanId!==void 0,U=z?" ":"",B=Kv[K.spanType]??K.spanType,F=(U+B).padEnd(H),D=(K.startTime-G)/W,O=K.durationMs/W,L=u90(X,D,O),q=cT0(K.durationMs),A=K.spanType==="tool_execution"&&K.name?` (${K.name})`:"";return qM(EM,{children:[qM(yY,{color:J.colors.textMuted,children:[" ",F]}),fY(yY,{children:" "}),fY(yY,{color:z?J.colors.info:J.colors.success,children:L}),fY(yY,{children:" "}),qM(yY,{dimColor:!0,children:[q,A]})]},K.spanId)})})}var gT0=1,mT0=20,Kv;var p90=E(()=>{E0();Kv={model_call:"model_call",tool_execution:"tool_exec",handoff:"handoff",approval:"approval",session_phase:"session",runner_phase:"runner"}});import{jsxs as eW}from"react/jsx-runtime";import{Box as d90,Text as _M}from"ink";function l90($){if($<1000)return`${Math.round($)}ms`;return`${($/1000).toFixed(2)}s`}function Uv({report:$}){let Z=e();if(!$||$.phases.length===0)return null;return eW(d90,{flexDirection:"column",marginTop:1,children:[eW(_M,{color:Z.colors.textMuted,children:[" Pipeline timing (",l90($.totalMs),")"]}),$.phases.map((J)=>eW(d90,{children:[eW(_M,{color:Z.colors.info,children:[" ",J.phase.padEnd(24)]}),eW(_M,{color:Z.colors.text,children:[" ",l90(J.durationMs)]}),eW(_M,{color:Z.colors.textMuted,children:[" (",J.pct,"%)"]})]},`${J.phase}:${J.durationMs}`))]})}var a90=E(()=>{E0()});import{jsxs as n90,jsx as uT0}from"react/jsx-runtime";import{useRef as pT0}from"react";import{Box as dT0,Text as i90}from"ink";import lT0 from"gradient-string";function s90($){if($<60)return`${$}s`;let Z=Math.floor($/60),J=$%60;return`${Z}m ${J}s`}function aT0($){if($>=1000)return`${($/1000).toFixed(1)}k tokens`;return`${$} tokens`}function Fv({state:$,elapsedSeconds:Z,totalTokens:J,thoughtForSeconds:X,currentVerb:Y}){let Q=[...o90,...[...o90].reverse()],G=Math.floor(Date.now()/120)%Q.length,V=pT0(j1().present),W=Y||V.current,H=e(),K=G%Bv.length,z=[...Bv.slice(K),...Bv.slice(0,K)],U=lT0(z),B=`${Q[G]} ${W}\u2026`,F=U(B),D=s90(Z),O=aT0(J),L;if($==="thinking")L="(thinking)";else if(X&&X>0)L=`(${D} \xB7 \u2193 ${O} \xB7 thought for ${s90(X)})`;else L=`(${D} \xB7 \u2193 ${O} \xB7 esc to cancel)`;return n90(dT0,{flexDirection:"row",marginTop:1,children:[n90(i90,{children:[F," "]}),uT0(i90,{color:H.colors.textMuted,children:L})]})}var Bv,o90;var r90=E(()=>{E0();_V();Bv=["#5f97cd","#7baed4","#97c4db","#7baed4"],o90=process.platform==="darwin"?["\xB7","\u2722","\u2733","\u2217","\u273B","\u273D"]:["\xB7","\u2722","*","\u2217","\u273B","\u273D"]});import{jsxs as e90,jsx as t90}from"react/jsx-runtime";import{Box as nT0,Text as $40}from"ink";function Dv($){return $>=70?"high":$>=30?"moderate":"low"}function iT0($){let Z=e();switch($){case"low":return{highlightColor:Z.colors.success,textColor:Z.colors.primary};case"moderate":return{highlightColor:Z.colors.warning,textColor:Z.colors.warning};case"high":return{highlightColor:Z.colors.error,textColor:Z.colors.error}}}function J5($){if($===null)return e().colors.primary;let Z=Dv($);return iT0(Z).textColor}function oT0({riskScore:$}){let Z=Dv($);return e90($40,{color:J5($),children:["Risk: ",Z]})}function c1({title:$,riskScore:Z}){return e90(nT0,{flexDirection:"column",children:[t90($40,{bold:!0,color:e().colors.primary,children:$}),Z!==null&&t90(oT0,{riskScore:Z})]})}var vY=E(()=>{E0()});function X5($,Z){}import{structuredPatch as sT0}from"diff";function MM($,Z,J,X=3){let Y=sT0($,$,Z,J,"","",{context:X}),Q=0,G=0,V=Y.hunks.map((W)=>{let H=[],K=W.oldStart,z=W.newStart;for(let U of W.lines){let B=U.slice(1);if(U.startsWith("+"))H.push({type:"added",content:B,newLineNo:z++}),Q++;else if(U.startsWith("-"))H.push({type:"removed",content:B,oldLineNo:K++}),G++;else H.push({type:"unchanged",content:B,oldLineNo:K++,newLineNo:z++})}return{oldStart:W.oldStart,oldLines:W.oldLines,newStart:W.newStart,newLines:W.newLines,lines:H}});return{filePath:$,hunks:V,additions:Q,deletions:G}}var Ov=()=>{};import{jsx as PM,jsxs as rT0}from"react/jsx-runtime";import{existsSync as tT0,readFileSync as eT0}from"fs";import{useMemo as Z40}from"react";import{Box as Nv,Text as $C0}from"ink";import{relative as ZC0}from"path";function J40({file_path:$,new_string:Z,old_string:J,verbose:X,useBorder:Y=!0,width:Q}){let G=Z40(()=>tT0($)?eT0($,"utf8"):"",[$]),V=Z40(()=>{let W=G.replace(J,Z);return MM($,G,W)},[$,G,J,Z]);return PM(Nv,{flexDirection:"column",children:rT0(Nv,{borderColor:e().colors.secondary,borderStyle:Y?"round":void 0,flexDirection:"column",paddingX:1,children:[PM(Nv,{paddingBottom:1,children:PM($C0,{bold:!0,children:X?$:ZC0(process.cwd(),$)})}),PM(hX,{diff:V,dim:!1,width:Q,showHeader:!1})]})})}var X40=E(()=>{CV();E0();Ov()});import{jsx as Lv,jsxs as JC0}from"react/jsx-runtime";import{Box as XC0,Text as Av}from"ink";function Y40({isFocused:$,isSelected:Z,smallPointer:J,children:X}){let Y=e();return JC0(XC0,{gap:1,children:[$&&Lv(Av,{color:Y.colors.primary,children:J?QC0:YC0}),Lv(Av,{color:$?Y.colors.primary:void 0,bold:Z,children:X}),Z&&Lv(Av,{color:Y.colors.success,children:GC0})]})}var YC0="\u276F",QC0="\u25BE",GC0="\u2714";var Q40=E(()=>{E0()});var jM;var G40=E(()=>{WJ();jM=class jM extends Map{first;constructor($){let Z=[],J,X,Y=0;for(let Q of $){let G={...Q,previous:X,next:void 0,index:Y};if(X)X.next=G;J||=G;let V="value"in Q?Q.value:qv(Q);Z.push([V,G]),Y++,X=G}super(Z);this.first=J}}});import{isDeepStrictEqual as VC0}from"util";import{useReducer as WC0,useCallback as Ev,useMemo as HC0,useState as KC0,useEffect as _v}from"react";var zC0=($,Z)=>{switch(Z.type){case"focus-next-option":{if(!$.focusedValue)return $;let J=$.optionMap.get($.focusedValue);if(!J)return $;let X=J.next;while(X&&!("value"in X))X=X.next;if(!X)return $;if(!(X.index>=$.visibleToIndex))return{...$,focusedValue:X.value};let Q=Math.min($.optionMap.size,$.visibleToIndex+1),G=Q-$.visibleOptionCount;return{...$,focusedValue:X.value,visibleFromIndex:G,visibleToIndex:Q}}case"focus-previous-option":{if(!$.focusedValue)return $;let J=$.optionMap.get($.focusedValue);if(!J)return $;let X=J.previous;while(X&&!("value"in X))X=X.previous;if(!X)return $;if(!(X.index<=$.visibleFromIndex))return{...$,focusedValue:X.value};let Q=Math.max(0,$.visibleFromIndex-1),G=Q+$.visibleOptionCount;return{...$,focusedValue:X.value,visibleFromIndex:Q,visibleToIndex:G}}case"select-focused-option":return{...$,previousValue:$.value,value:$.focusedValue};case"reset":return Z.state;case"set-focus":return{...$,focusedValue:Z.value}}},Mv=($)=>$.flatMap((Z)=>{if("options"in Z){let J=Mv(Z.options),X=J.flatMap((Q)=>("value"in Q)?Q.value:[]);return[...Z.header!==void 0?[{header:Z.header,optionValues:X}]:[],...J]}return Z}),V40=({visibleOptionCount:$,defaultValue:Z,options:J})=>{let X=Mv(J),Y=typeof $==="number"?Math.min($,X.length):X.length,Q=new jM(X),G=Q.first,V=G&&"value"in G?G.value:void 0;return{optionMap:Q,visibleOptionCount:Y,focusedValue:V,visibleFromIndex:0,visibleToIndex:Y,previousValue:Z,value:Z}},W40=({visibleOptionCount:$=5,options:Z,defaultValue:J,onChange:X,onFocus:Y,focusValue:Q})=>{let G=Mv(Z),[V,W]=WC0(zC0,{visibleOptionCount:$,defaultValue:J,options:Z},V40),[H,K]=KC0(G);if(G!==H&&!VC0(G,H))W({type:"reset",state:V40({visibleOptionCount:$,defaultValue:J,options:Z})}),K(G);let z=Ev(()=>{W({type:"focus-next-option"})},[]),U=Ev(()=>{W({type:"focus-previous-option"})},[]),B=Ev(()=>{W({type:"select-focused-option"})},[]),F=HC0(()=>{return G.map((D,O)=>({...D,index:O})).slice(V.visibleFromIndex,V.visibleToIndex)},[G,V.visibleFromIndex,V.visibleToIndex]);return _v(()=>{if(V.value&&V.previousValue!==V.value)X?.(V.value)},[V.previousValue,V.value,Z,X]),_v(()=>{if(V.focusedValue)Y?.(V.focusedValue)},[V.focusedValue,Y]),_v(()=>{if(Q)W({type:"set-focus",value:Q})},[Q]),{focusedValue:V.focusedValue,visibleFromIndex:V.visibleFromIndex,visibleToIndex:V.visibleToIndex,value:V.value,visibleOptions:F,focusNextOption:z,focusPreviousOption:U,selectFocusedOption:B}};var H40=E(()=>{G40()});import{useInput as UC0}from"ink";var K40=({isDisabled:$=!1,state:Z})=>{UC0((J,X)=>{if(X.downArrow)Z.focusNextOption();if(X.upArrow)Z.focusPreviousOption();if(X.return)Z.selectFocusedOption()},{isActive:!$})};var z40=()=>{};import{jsx as Pv,Fragment as BC0,jsxs as FC0}from"react/jsx-runtime";import{Box as DC0,Text as OC0}from"ink";function u1({isDisabled:$=!1,visibleOptionCount:Z=5,highlightText:J,options:X,defaultValue:Y,onChange:Q,onFocus:G,focusValue:V}){let W=W40({visibleOptionCount:Z,options:X,defaultValue:Y,onChange:Q,onFocus:G,focusValue:V});K40({isDisabled:$,state:W});let H=e();return Pv(DC0,{flexDirection:"column",children:W.visibleOptions.map((K)=>{let z="value"in K?K.value:qv(K),U=!$&&W.focusedValue!==void 0&&("value"in K?W.focusedValue===K.value:K.optionValues.includes(W.focusedValue)),B=!!W.value&&("value"in K?W.value===K.value:K.optionValues.includes(W.value)),F="header"in K,D="label"in K?K.label:K.header,O=D;if(J&&D.includes(J)){let L=D.indexOf(J);O=FC0(BC0,{children:[D.slice(0,L),Pv(OC0,{color:H.colors.primary,bold:!0,children:J}),D.slice(L+J.length)]})}return Pv(Y40,{isFocused:U,isSelected:B,smallPointer:F,children:O},z)})})}var qv=($)=>`HEADER-${$.optionValues.join(",")}`;var WJ=E(()=>{Q40();H40();z40();E0()});import{jsx as TM,jsxs as jv}from"react/jsx-runtime";import{Box as U40,Text as B40}from"ink";import{useMemo as NC0}from"react";import{basename as LC0,extname as AC0,isAbsolute as qC0,resolve as Tv}from"path";import EC0 from"chalk";function _C0($){return(qC0($)?Tv($):Tv(process.cwd(),$)).startsWith(Tv(process.cwd()))}function MC0($){let Z=_C0($)?[{label:"Yes, and don't ask again this session",value:"yes-dont-ask-again"}]:[];return[{label:"Yes",value:"yes"},...Z,{label:`No, and provide instructions (${EC0.bold.hex(e().colors.warning)("esc")})`,value:"no"}]}function F40({toolUseConfirm:$,onDone:Z,verbose:J}){let{columns:X}=X9(),{file_path:Y,new_string:Q,old_string:G}=$.input,V=NC0(()=>({completion_type:"str_replace_single",language_name:PC0(Y)}),[Y]);return X5($,V),jv(U40,{flexDirection:"column",borderStyle:"round",borderColor:J5($.riskScore),marginTop:1,paddingLeft:1,paddingRight:1,paddingBottom:1,children:[TM(c1,{title:"Edit file",riskScore:$.riskScore}),TM(J40,{file_path:Y,new_string:Q,old_string:G,verbose:J,width:X-12}),jv(U40,{flexDirection:"column",children:[jv(B40,{children:["Do you want to make this edit to ",TM(B40,{bold:!0,children:LC0(Y)}),"?"]}),TM(u1,{options:MC0(Y),onChange:(W)=>{switch(W){case"yes":$.onAllow("temporary"),Z();break;case"yes-dont-ask-again":$.onAllow("permanent"),Z();break;case"no":$.onReject(),Z();break}}})]})]})}function PC0($){let Z=AC0($);return Z?Z.slice(1):"unknown"}var D40=E(()=>{E0();vY();X40();P1();WJ()});import QF from"chalk";function jC0($){let J=$.replace(/'[^']*'/g,"").replace(/"[^"]*"/g,"");if(/&&|\|\||[;|]/.test(J))return!0;if(/`/.test(J))return!0;if(/\$\(/.test(J))return!0;return!1}function O40({toolUseConfirm:$,command:Z}){let J=!jC0(Z)&&$.commandPrefix&&!$.commandPrefix.commandInjectionDetected,X=GF($),Y=J&&X!==null,Q=[];if(Y)Q=[{label:`Yes, and don't ask again for ${QF.bold(X)} commands in ${QF.bold(process.cwd())}`,value:"yes-dont-ask-again-prefix"}];else if(J)Q=[{label:`Yes, and don't ask again for ${QF.bold(Z)} commands in ${QF.bold(process.cwd())}`,value:"yes-dont-ask-again-full"}];return[{label:"Yes",value:"yes"},...Q,{label:`No, and provide instructions (${QF.bold.hex(e().colors.warning)("esc")})`,value:"no"}]}var N40=E(()=>{VF();E0()});import{jsx as WF,jsxs as Cv}from"react/jsx-runtime";import{Box as Rv,Text as wv}from"ink";import{useMemo as TC0}from"react";function L40({toolUseConfirm:$,onDone:Z}){let J=e(),{command:X}=$.tool.inputSchema.parse($.input),Y=TC0(()=>({completion_type:"tool_use_single",language_name:"none"}),[]);return X5($,Y),Cv(Rv,{flexDirection:"column",borderStyle:"round",borderColor:J.colors.primary,marginTop:1,paddingLeft:1,paddingRight:1,paddingBottom:1,children:[WF(c1,{title:"Bash command",riskScore:$.riskScore}),Cv(Rv,{flexDirection:"column",paddingX:2,paddingY:1,children:[WF(wv,{children:$.tool.renderToolUseMessage({command:X},{verbose:!1})}),WF(wv,{color:J.colors.textMuted,children:$.description})]}),Cv(Rv,{flexDirection:"column",children:[WF(wv,{children:"Do you want to proceed?"}),WF(u1,{options:O40({toolUseConfirm:$,command:X}),onChange:(Q)=>{switch(Q){case"yes":$.onAllow("temporary"),Z();break;case"yes-dont-ask-again-prefix":{if(GF($)!==null)$.onAllow("permanent");else $.onAllow("temporary");Z();break}case"yes-dont-ask-again-full":$.onAllow("permanent"),Z();break;case"no":$.onReject(),Z();break}}})]})]})}var A40=E(()=>{E0();VF();vY();WJ();N40()});import{jsx as HF,jsxs as CM}from"react/jsx-runtime";import{Box as Sv,Text as RM}from"ink";import{useMemo as CC0}from"react";import Iv from"chalk";function wM({toolUseConfirm:$,onDone:Z,verbose:J}){let X=e(),Y=$.tool.userFacingName($.input),Q=Y.endsWith(" (MCP)")?Y.slice(0,-6):Y,G=CC0(()=>({completion_type:"tool_use_single",language_name:"none"}),[]);return X5($,G),CM(Sv,{flexDirection:"column",borderStyle:"round",borderColor:J5($.riskScore),marginTop:1,paddingLeft:1,paddingRight:1,paddingBottom:1,children:[HF(c1,{title:"Tool use",riskScore:$.riskScore}),CM(Sv,{flexDirection:"column",paddingX:2,paddingY:1,children:[CM(RM,{children:[Q,"(",$.tool.renderToolUseMessage($.input,{verbose:J}),")",Y.endsWith(" (MCP)")?HF(RM,{color:X.colors.textMuted,children:" (MCP)"}):""]}),HF(RM,{color:X.colors.textMuted,children:$.description})]}),CM(Sv,{flexDirection:"column",children:[HF(RM,{children:"Do you want to proceed?"}),HF(u1,{options:[{label:"Yes",value:"yes"},{label:`Yes, and don't ask again for ${Iv.bold(Q)} commands in ${Iv.bold(process.cwd())}`,value:"yes-dont-ask-again"},{label:`No, and provide instructions (${Iv.bold.hex(e().colors.warning)("esc")})`,value:"no"}],onChange:(V)=>{switch(V){case"yes":$.onAllow("temporary"),Z();break;case"yes-dont-ask-again":$.onAllow("permanent"),Z();break;case"no":$.onReject(),Z();break}}})]})]})}var bv=E(()=>{E0();vY();WJ()});import{jsx as SM,jsxs as RC0}from"react/jsx-runtime";import{existsSync as wC0,readFileSync as SC0}from"fs";import{useMemo as kv}from"react";import{Box as q40,Text as IC0}from"ink";import{extname as bC0,relative as kC0}from"path";function E40({file_path:$,content:Z,verbose:J,width:X}){let Y=kv(()=>wC0($),[$]),Q=kv(()=>{if(!Y)return"";return SC0($,"utf8")},[$,Y]),G=kv(()=>{if(!Y)return null;return MM($,Q,Z)},[Y,$,Q,Z]);return RC0(q40,{borderColor:e().colors.secondary,borderStyle:"round",flexDirection:"column",paddingX:1,children:[SM(q40,{paddingBottom:1,children:SM(IC0,{bold:!0,children:J?$:kC0(process.cwd(),$)})}),G?SM(hX,{diff:G,dim:!1,width:X,showHeader:!1}):SM(C1,{code:Z||"(No content)",language:bC0($).slice(1)})]})}var _40=E(()=>{CV();E0();wV();Ov()});import{jsx as KF,jsxs as fv}from"react/jsx-runtime";import{Box as yv,Text as M40}from"ink";import{useMemo as P40}from"react";import{basename as fC0,extname as yC0}from"path";import{existsSync as vC0}from"fs";import hC0 from"chalk";function j40({toolUseConfirm:$,onDone:Z,verbose:J}){let{file_path:X,content:Y}=$.input,Q=P40(()=>vC0(X),[X]),G=P40(()=>({completion_type:"write_file_single",language_name:xC0(X)}),[X]),{columns:V}=X9();return X5($,G),fv(yv,{flexDirection:"column",borderStyle:"round",borderColor:J5($.riskScore),marginTop:1,paddingLeft:1,paddingRight:1,paddingBottom:1,children:[KF(c1,{title:`${Q?"Edit":"Create"} file`,riskScore:$.riskScore}),KF(yv,{flexDirection:"column",children:KF(E40,{file_path:X,content:Y,verbose:J,width:V-12})}),fv(yv,{flexDirection:"column",children:[fv(M40,{children:["Do you want to ",Q?"make this edit to":"create"," ",KF(M40,{bold:!0,children:fC0(X)}),"?"]}),KF(u1,{options:[{label:"Yes",value:"yes"},{label:"Yes, and don't ask again this session",value:"yes-dont-ask-again"},{label:`No, and provide instructions (${hC0.bold.hex(e().colors.warning)("esc")})`,value:"no"}],onChange:(W)=>{switch(W){case"yes":$.onAllow("temporary"),Z();break;case"yes-dont-ask-again":$.onAllow("permanent"),Z();break;case"no":$.onReject(),Z();break}}})]})]})}function xC0($){let Z=yC0($);return Z?Z.slice(1):"unknown"}var T40=E(()=>{E0();vY();_40();P1();WJ()});import{jsx as $H,jsxs as vv}from"react/jsx-runtime";import{Box as hv,Text as C40}from"ink";import{useMemo as gC0}from"react";import mC0 from"chalk";import{isAbsolute as cC0,resolve as R40}from"path";function IM($){return cC0($)?R40($):R40(process.cwd(),$)}function uC0($){return IM($).startsWith(IM(process.cwd()))}function dC0(){pC0=!0}function oC0($){let Z=$.tool.name;if(lC0.has(Z))return"file_path";if(aC0.has(Z))return"path";if(nC0.has(Z))return"notebook_path";return null}function sC0($){return iC0.has($.tool.name)}function rC0($){let Z=oC0($),J=$.input;if(Z&&Z in J)if(typeof J[Z]==="string")return IM(J[Z]);else return IM(process.cwd());return null}function w40({toolUseConfirm:$,onDone:Z,verbose:J}){let X=rC0($);if(!X)return $H(wM,{toolUseConfirm:$,onDone:Z,verbose:J});return $H(eC0,{toolUseConfirm:$,path:X,onDone:Z,verbose:J})}function tC0($,Z){if($.tool.isReadOnly())return[];return uC0(Z)?[{label:"Yes, and don't ask again for file edits this session",value:"yes-dont-ask-again"}]:[]}function eC0({toolUseConfirm:$,path:Z,onDone:J,verbose:X}){let Y=$.tool.userFacingName($.input),G=`${$.tool.isReadOnly()?"Read":"Edit"} ${sC0($)?"files":"file"}`,V=gC0(()=>({completion_type:"tool_use_single",language_name:"none"}),[]);return X5($,V),vv(hv,{flexDirection:"column",borderStyle:"round",borderColor:J5($.riskScore),marginTop:1,paddingLeft:1,paddingRight:1,paddingBottom:1,children:[$H(c1,{title:G,riskScore:$.riskScore}),$H(hv,{flexDirection:"column",paddingX:2,paddingY:1,children:vv(C40,{children:[Y,"(",$.tool.renderToolUseMessage($.input,{verbose:X}),")"]})}),vv(hv,{flexDirection:"column",children:[$H(C40,{children:"Do you want to proceed?"}),$H(u1,{options:[{label:"Yes",value:"yes"},...tC0($,Z),{label:`No, and provide instructions (${mC0.bold.hex(e().colors.warning)("esc")})`,value:"no"}],onChange:(W)=>{switch(W){case"yes":$.onAllow("temporary"),J();break;case"yes-dont-ask-again":dC0(),$.onAllow("permanent"),J();break;case"no":$.onReject(),J();break}}})]})]})}var pC0=!1,lC0,aC0,nC0,iC0;var S40=E(()=>{E0();vY();bv();WJ();lC0=new Set(["Edit","file_edit","str_replace_editor","Write","file_write","create_file","Read","file_read","read_file"]),aC0=new Set(["Glob","glob","Grep","grep","LS","ls"]),nC0=new Set(["NotebookEdit","notebook_edit","NotebookRead","notebook_read"]),iC0=new Set(["Glob","glob","Grep","grep","LS","ls"])});import{jsx as $R0}from"react/jsx-runtime";import{useInput as ZR0}from"ink";import*as I40 from"react";function GR0($){if(JR0.has($))return F40;if(XR0.has($))return j40;if(YR0.has($))return L40;if(QR0.has($))return w40;return wM}function GF($){return $.commandPrefix&&!$.commandPrefix.commandInjectionDetected&&$.commandPrefix.commandPrefix||null}function xv({toolUseConfirm:$,onDone:Z,verbose:J}){let X=I40.useRef(!1);ZR0((Q,G)=>{if(X.current)return;if(G.ctrl&&Q==="c"||W$(Q,G))X.current=!0,$.onReject(),Z()});let Y=GR0($.tool.name);return $R0(Y,{toolUseConfirm:$,onDone:Z,verbose:J})}var JR0,XR0,YR0,QR0;var VF=E(()=>{D40();A40();bv();T40();S40();JR0=new Set(["Edit","file_edit","str_replace_editor"]),XR0=new Set(["Write","file_write","create_file"]),YR0=new Set(["Bash","bash","execute_command"]),QR0=new Set(["Glob","glob","Grep","grep","LS","ls","Read","file_read","read_file","NotebookRead","notebook_read","NotebookEdit","notebook_edit"])});import{jsx as bM,jsxs as ZH}from"react/jsx-runtime";import{useState as b40,useEffect as k40}from"react";import{Box as kM,Text as JH,useInput as VR0}from"ink";function gv($){return/\s/.test($.trimStart())}function WR0($){return $.trimStart().split(/\s+/,1)[0]??""}function mv({commands:$,initialFilter:Z="",onSelect:J,onHandOffInput:X,onCancel:Y}){let[Q,G]=b40(0),[V,W]=b40(Z),H=WR0(V).toLowerCase(),K=$.filter((B)=>B.name.toLowerCase().includes(H));k40(()=>{G((B)=>Math.min(B,Math.max(0,K.length-1)))},[K.length]),k40(()=>{if(!X||!gv(V))return;X(`/${V}`)},[V,X]);let z=K.length>0?Math.min(Q,K.length-1):0,U=process.stdin.isTTY??!1;return VR0((B,F)=>{if(W$(B,F)){Y();return}if(F.return&&gv(V)&&X){X(`/${V}`);return}if(F.return&&K.length>0){J(K[z]);return}if(F.upArrow){G((D)=>Math.max(0,D-1));return}if(F.downArrow){G((D)=>Math.min(K.length-1,D+1));return}if(F.backspace||F.delete){W((D)=>D.slice(0,-1));return}if(B&&!F.ctrl&&!F.meta){let D=V+B;if(X&&gv(D)){X(`/${D}`);return}W(D)}},{isActive:U}),ZH(kM,{flexDirection:"column",borderStyle:"round",borderColor:"gray",paddingX:1,children:[ZH(kM,{marginBottom:1,children:[bM(JH,{bold:!0,children:"Commands"}),V&&ZH(JH,{dimColor:!0,children:[" /",V]})]}),K.map((B,F)=>ZH(kM,{children:[ZH(JH,{inverse:F===z,children:["/",B.name]}),ZH(JH,{dimColor:!0,children:[" ",B.description]})]},B.name)),K.length===0&&bM(JH,{dimColor:!0,children:"No matching commands"}),bM(kM,{marginTop:1,children:bM(JH,{dimColor:!0,children:"\u2191\u2193 navigate \u23CE select esc cancel"})})]})}var f40=()=>{};import{jsx as zF,jsxs as XH}from"react/jsx-runtime";import{useState as y40,useEffect as HR0}from"react";import{Box as fM,Text as hY,useInput as KR0}from"ink";function cv({arions:$,initialFilter:Z="",statusFilter:J="all",onSelect:X,onCancel:Y}){let[Q,G]=y40(0),[V,W]=y40(Z),H=$.filter((U)=>{if(J==="active"&&U.isResting)return!1;if(J==="resting"&&!U.isResting)return!1;return U.name.toLowerCase().includes(V.toLowerCase())});HR0(()=>{G((U)=>Math.min(U,Math.max(0,H.length-1)))},[H.length]);let K=H.length>0?Math.min(Q,H.length-1):0,z=process.stdin.isTTY??!1;return KR0((U,B)=>{if(W$(U,B)){Y();return}if(B.return&&H.length>0){X(H[K]);return}if(B.upArrow){G((F)=>Math.max(0,F-1));return}if(B.downArrow){G((F)=>Math.min(H.length-1,F+1));return}if(B.backspace||B.delete){W((F)=>F.slice(0,-1));return}if(U&&!B.ctrl&&!B.meta)W((F)=>F+U)},{isActive:z}),XH(fM,{flexDirection:"column",borderStyle:"round",borderColor:"gray",paddingX:1,children:[XH(fM,{marginBottom:1,children:[zF(hY,{bold:!0,children:J==="active"?"Active Arions":J==="resting"?"Resting Arions":"Arions"}),V&&XH(hY,{dimColor:!0,children:[" @",V]})]}),H.length===0&&zF(hY,{dimColor:!0,children:$.length===0?"No arions available. Create one with /hatch":J==="active"?"No active arions":J==="resting"?"No resting arions":"No matching arions"}),H.map((U,B)=>{let F=ez(U.color),D=U.isActive?" (active)":U.isResting?" (resting)":"";return XH(fM,{children:[XH(hY,{inverse:B===K,children:[U.emoji," ",zF(hY,{color:F,children:U.name})]}),XH(hY,{dimColor:!0,children:[" ",U.description,D]})]},U.name)}),zF(fM,{marginTop:1,children:zF(hY,{dimColor:!0,children:"\u2191\u2193 navigate \u23CE select esc cancel"})})]})}var v40=E(()=>{BV()});import{jsx as AZ,jsxs as p1}from"react/jsx-runtime";import{useState as uv,useEffect as zR0,useMemo as UR0}from"react";import{Box as HJ,Text as y4,useInput as BR0}from"ink";function DR0($){return FR0[$]||$}function x40($){let Z=h40.indexOf($);return Z>=0?Z:h40.length}function OR0($,Z,J){let X=new Map;for(let G of $){let V=G.provider||"other",W=X.get(V)??[];W.push(G),X.set(V,W)}let Y={powerful:0,balanced:1,fast:2,ensemble:3},Q=[...X.entries()].sort(([G],[V])=>x40(G)-x40(V));for(let[G,V]of Q){Z.push({type:"header",label:DR0(G),provider:G});let W=(U)=>{if(!U)return"balanced";let B=U.toLowerCase();if(B.includes("deep"))return"powerful";if(B.includes("quick"))return"fast";return"balanced"},H=[/^claude-opus-|^opus-|^bedrock-opus-/,/^claude-sonnet-|^sonnet-|^bedrock-sonnet-/,/^claude-haiku-|^haiku-|^bedrock-haiku-/,/^claude-/,/^gpt-/,/^o[0-9]/,/^gemini-/],K=(U)=>{let B=U.toLowerCase();for(let F=0;F<H.length;F++)if(H[F].test(B))return F;return H.length},z=[...V].sort((U,B)=>{let F=K(U.name),D=K(B.name);if(F!==D)return F-D;return B.name.localeCompare(U.name)});for(let U of z)J.push(Z.length),Z.push({type:"model",model:U})}}function pv({models:$,initialFilter:Z="",effortLevel:J,onSelect:X,onCancel:Y}){let[Q,G]=uv(Z),[V,W]=uv(J??"high"),K=$.filter((A)=>A.name.toLowerCase().includes(Q.toLowerCase())),{items:z,selectableIndices:U}=UR0(()=>{if(!K.some((M)=>M.provider))return{items:K.map((M)=>({type:"model",model:M})),selectableIndices:K.map((M,T)=>T)};let N=[],_=[];return OR0(K,N,_),{items:N,selectableIndices:_}},[K]),B=U.findIndex((A)=>{let N=z[A];return N?.type==="model"&&N.model.isCurrent}),[F,D]=uv(B>=0?B:0);zR0(()=>{D((A)=>Math.min(A,Math.max(0,U.length-1)))},[U.length]);let O=U.length>0?Math.min(F,U.length-1):0,L=process.stdin.isTTY??!1;BR0((A,N)=>{if(W$(A,N)){Y();return}if(N.return&&U.length>0){let _=U[O],M=z[_];if(M.type==="model")X(M.model,V);return}if(N.leftArrow){W((_)=>{let M=UF.indexOf(_);return UF[Math.max(0,M-1)]});return}if(N.rightArrow){W((_)=>{let M=UF.indexOf(_);return UF[Math.min(UF.length-1,M+1)]});return}if(N.upArrow){D((_)=>Math.max(0,_-1));return}if(N.downArrow){D((_)=>Math.min(U.length-1,_+1));return}if(N.backspace||N.delete){G((_)=>_.slice(0,-1));return}if(A&&!N.ctrl&&!N.meta)G((_)=>_+A)},{isActive:L});let q=U.length>0?` [${O+1}/${U.length}]`:"";return p1(HJ,{flexDirection:"column",borderStyle:"round",borderColor:"gray",paddingX:1,children:[p1(HJ,{marginBottom:1,children:[AZ(y4,{bold:!0,children:"Model"}),AZ(y4,{dimColor:!0,children:q}),AZ(y4,{children:" "}),Q?AZ(y4,{color:"cyan",children:Q}):AZ(y4,{dimColor:!0,children:"Type to search..."})]}),K.length===0&&AZ(y4,{dimColor:!0,children:"No matching models"}),(()=>{let A=z.reduce((N,_)=>{if(_.type!=="model")return N;return Math.max(N,_.model.name.length)},0);return z.map((N,_)=>{if(N.type==="header"){let a=Sa(N.provider);return p1(HJ,{marginTop:_>0?1:0,children:[p1(y4,{color:a.color,children:[a.icon," "]}),AZ(y4,{bold:!0,color:a.color,children:N.label})]},`header-${N.label}-${_}`)}if(N.type==="hint")return AZ(HJ,{marginTop:1,children:AZ(y4,{dimColor:!0,italic:!0,children:N.label})},"hint");let M=U[O]===_,T=N.model.description,k=N.model.name.padEnd(A),R=KA(N.model.name);return p1(HJ,{children:[p1(y4,{inverse:M,color:M?void 0:R,dimColor:M?!1:!R,children:[N.model.isCurrent?"\u25CF":"\u25CB"," ",k]}),T&&p1(y4,{dimColor:!0,children:[" ",N.model.description]})]},N.model.value??`${N.model.provider}-${N.model.name}`)})})(),p1(HJ,{marginTop:1,flexDirection:"column",children:[p1(HJ,{children:[p1(y4,{color:g40[V],children:[NR0[V]," "]}),p1(y4,{color:g40[V],bold:!0,children:[LR0[V]," effort"]}),V==="high"&&AZ(y4,{dimColor:!0,children:" (default)"}),AZ(y4,{dimColor:!0,children:" \u2190 \u2192 to adjust"})]}),AZ(HJ,{marginTop:0,children:AZ(y4,{dimColor:!0,children:"\u2191\u2193 navigate \u2190 \u2192 effort \u23CE select esc cancel"})})]})]})}var FR0,h40,UF,NR0,LR0,g40;var m40=E(()=>{BV();FR0={anthropic:"Anthropic","openai-codex":"OpenAI Codex",google:"Google",bedrock:"AWS Bedrock","bedrock-converse":"AWS Bedrock (Converse)","github-copilot":"GitHub Copilot",openai:"OpenAI",local:"Local"},h40=["anthropic","openai-codex","google","bedrock","bedrock-converse","github-copilot","openai","local"];UF=["low","medium","high","max"],NR0={low:"\u258C",medium:"\u258C\u258C",high:"\u258C\u258C\u258C",max:"\u258C\u258C\u258C\u258C"},LR0={low:"Low",medium:"Medium",high:"High",max:"Max"},g40={low:"blue",medium:"cyan",high:"yellow",max:"magenta"}});import{jsx as KJ,jsxs as Y5}from"react/jsx-runtime";import{useState as dv,useEffect as AR0}from"react";import{Box as YH,Text as d1,useInput as qR0}from"ink";import ER0 from"ink-spinner";function lv({memories:$,mode:Z="browse",isLoading:J=!1,onSelect:X,onCancel:Y}){let[Q,G]=dv(0),[V,W]=dv(""),[H,K]=dv(0),z=8,U=$.filter((N)=>N.content.toLowerCase().includes(V.toLowerCase())),B=Math.max(1,Math.ceil(U.length/8)),F=U.slice(H*8,(H+1)*8);AR0(()=>{G((N)=>Math.min(N,Math.max(0,F.length-1)))},[F.length]);let D=F.length>0?Math.min(Q,F.length-1):0,O=process.stdin.isTTY??!1;qR0((N,_)=>{if(W$(N,_)){Y();return}if(_.return&&F.length>0&&Z==="forget"){X?.(F[D]);return}if(_.upArrow){G((M)=>Math.max(0,M-1));return}if(_.downArrow){G((M)=>Math.min(F.length-1,M+1));return}if(_.leftArrow&&H>0){K((M)=>M-1),G(0);return}if(_.rightArrow&&H<B-1){K((M)=>M+1),G(0);return}if(_.backspace||_.delete){W((M)=>M.slice(0,-1)),K(0),G(0);return}if(N&&!_.ctrl&&!_.meta)W((M)=>M+N),K(0),G(0)},{isActive:O});function L(N){let _=N instanceof Date?N:new Date(N);if(isNaN(_.getTime()))return"unknown";let T=new Date().getTime()-_.getTime(),k=Math.floor(T/86400000);if(k===0)return"today";if(k===1)return"yesterday";if(k<7)return`${k}d ago`;if(k<30)return`${Math.floor(k/7)}w ago`;return`${Math.floor(k/30)}mo ago`}function q(N,_){if(N.length<=_)return N;return N.slice(0,_-3)+"..."}return Y5(YH,{flexDirection:"column",borderStyle:"round",borderColor:Z==="forget"?"red":"cyan",paddingX:1,children:[Y5(YH,{marginBottom:1,children:[KJ(d1,{bold:!0,color:Z==="forget"?"red":"cyan",children:Z==="forget"?"Select Memory to Delete":"Memories"}),V&&Y5(d1,{dimColor:!0,children:[' (filter: "',V,'")']}),Y5(d1,{dimColor:!0,children:[" - ",U.length," memories"]})]}),J&&Y5(YH,{children:[KJ(d1,{color:"cyan",children:KJ(ER0,{type:"dots"})}),KJ(d1,{dimColor:!0,children:" Loading memories..."})]}),!J&&U.length===0&&KJ(d1,{dimColor:!0,children:$.length===0?"No memories stored yet. Use /remember to add some.":"No memories match your filter."}),!J&&F.map((N,_)=>{let M=_===D,T=L(N.createdAt),k=q(N.content,60);return Y5(YH,{flexDirection:"row",children:[Y5(d1,{inverse:M,children:[M?">":" "," ",k]}),Y5(d1,{dimColor:!0,children:[" [",T,"]"]}),N.network&&Y5(d1,{dimColor:!0,children:[" (",N.network,")"]})]},N.id)}),!J&&B>1&&KJ(YH,{marginTop:1,children:Y5(d1,{dimColor:!0,children:["Page ",H+1,"/",B]})}),KJ(YH,{marginTop:1,children:KJ(d1,{dimColor:!0,children:Z==="forget"?"type to filter arrows navigate enter delete esc cancel":"type to filter arrows navigate esc close"})})]})}var c40=()=>{};import{jsx as BF,jsxs as Q5}from"react/jsx-runtime";import{useState as av,useEffect as u40}from"react";import{Box as QH,Text as U2,useInput as _R0}from"ink";function MR0($){let J=Date.now()-$.getTime(),X=Math.floor(J/60000),Y=Math.floor(J/3600000),Q=Math.floor(J/86400000);if(X<1)return"just now";if(X<60)return`${X}m ago`;if(Y<24)return`${Y}h ago`;if(Q<7)return`${Q}d ago`;return $.toLocaleDateString()}function nv({sessions:$,onSelect:Z,onCancel:J,onSearch:X,onPageChange:Y}){let{columns:Q}=X9(),[G,V]=av(0),[W,H]=av(""),[K,z]=av(0),U=8,B=Math.max(1,Math.ceil($.length/8)),F=$.slice(K*8,(K+1)*8);u40(()=>{V((A)=>Math.min(A,Math.max(0,F.length-1)))},[F.length]),u40(()=>{z((A)=>Math.min(A,Math.max(0,B-1)))},[B]);let D=F.length>0?Math.min(G,F.length-1):0,O=process.stdin.isTTY??!1;_R0((A,N)=>{if(W$(A,N))J();else if(N.return&&F.length>0)Z(F[D].id);else if(N.upArrow)V((_)=>Math.max(0,_-1));else if(N.downArrow)V((_)=>Math.min(F.length-1,_+1));else if(N.leftArrow&&K>0)z((_)=>_-1),V(0);else if(N.leftArrow&&K===0)Y?.("prev"),V(0);else if(N.rightArrow&&K<B-1)z((_)=>_+1),V(0);else if(N.rightArrow&&K===B-1)Y?.("next"),V(0);else if(N.backspace||N.delete){let _=W.slice(0,-1);H(_),z(0),V(0),X(_)}else if(A&&!N.ctrl&&!N.meta){let _=W+A;H(_),z(0),V(0),X(_)}},{isActive:O});function L(A,N){if(A.length<=N)return A;return A.slice(0,N-3)+"..."}let q=Math.max(30,Math.min(120,Q-28));return Q5(QH,{flexDirection:"column",borderStyle:"round",borderColor:"cyan",paddingX:1,children:[Q5(QH,{marginBottom:1,children:[BF(U2,{bold:!0,color:"cyan",children:"Sessions"}),W&&Q5(U2,{dimColor:!0,children:[' (filter: "',W,'")']}),Q5(U2,{dimColor:!0,children:[" - ",$.length," sessions"]})]}),$.length===0?BF(U2,{dimColor:!0,children:W?"No sessions match your filter.":"No sessions yet."}):F.map((A,N)=>{let _=N===D,M=MR0(A.updatedAt),T=A.title??A.preview??"Untitled session",k=K*8+N;return Q5(QH,{flexDirection:"column",marginBottom:N<F.length-1?1:0,children:[Q5(QH,{flexDirection:"row",children:[Q5(U2,{inverse:_,children:[_?">":" "," ",k+1,". ",L(T,q)]}),Q5(U2,{dimColor:!0,children:[" [",M,"]"]})]}),Q5(U2,{dimColor:!0,children:[" ",A.arion," | ",A.model," | ",A.messageCount," messages"]})]},A.id)}),$.length>0&&B>1&&BF(QH,{marginTop:1,children:Q5(U2,{dimColor:!0,children:["Page ",K+1,"/",B]})}),BF(QH,{marginTop:1,children:BF(U2,{dimColor:!0,children:"type to search arrows navigate enter resume esc cancel"})})]})}var p40=E(()=>{P1()});import{jsx as FF,jsxs as xY}from"react/jsx-runtime";import{useState as iv,useEffect as yM,useMemo as PR0}from"react";import{Box as vM,Text as zJ,useInput as jR0}from"ink";function TR0($,Z){if($.length<=Z)return $;return $.slice(0,Z-3)+"\u2026"}function CR0($){switch($){case"user":return"\uD83D\uDC64";case"assistant":return"\uD83E\uDD16";case"system":return"\u2699\uFE0F";case"tool":return"\uD83D\uDD27";default:return" "}}function RR0($){switch($){case"user":return"cyan";case"assistant":return"green";case"system":return"yellow";case"tool":return"gray";default:return"white"}}function ov({messages:$,onSelect:Z,onCancel:J}){let{columns:X,rows:Y}=X9(),[Q,G]=iv(0),[V,W]=iv(""),H=PR0(()=>{if(!V)return $;let L=V.toLowerCase();return $.filter((q)=>q.text.toLowerCase().includes(L)||q.role.toLowerCase().includes(L)||q.arion&&q.arion.toLowerCase().includes(L))},[$,V]);yM(()=>{G((L)=>Math.min(L,Math.max(0,H.length-1)))},[H.length]),yM(()=>{if(!V){let L=H.reduce((q,A,N)=>A.role==="user"?N:q,0);G(L)}},[]);let K=Math.max(4,Y-10),[z,U]=iv(0);yM(()=>{if(Q<z)U(Q);else if(Q>=z+K)U(Q-K+1)},[Q,K,z]),yM(()=>{let L=H.reduce((q,A,N)=>A.role==="user"?N:q,0);U(Math.max(0,L-K+2))},[V]);let B=H.slice(z,z+K),F=H.length>0?Math.min(Q,H.length-1):0,D=process.stdin.isTTY??!1;jR0((L,q)=>{if(W$(L,q))J();else if(q.return&&H.length>0){let A=H[F];if(A&&A.role==="user")Z(A.index,A.text)}else if(q.upArrow)G((A)=>Math.max(0,A-1));else if(q.downArrow)G((A)=>Math.min(H.length-1,A+1));else if(q.backspace||q.delete){let A=V.slice(0,-1);W(A),G(0)}else if(L&&!q.ctrl&&!q.meta){let A=V+L;W(A),G(0)}},{isActive:D});let O=Math.max(30,Math.min(120,X-16));return xY(vM,{flexDirection:"column",borderStyle:"round",borderColor:"cyan",paddingX:1,children:[xY(vM,{marginBottom:1,children:[FF(zJ,{bold:!0,color:"cyan",children:"Edit Message"}),V?xY(zJ,{dimColor:!0,children:[" ",'(search: "',V,'") \u2014 ',H.length,"/",$.length," messages"]}):xY(zJ,{dimColor:!0,children:[" \u2014 ",$.length," messages \xB7 select a user message to edit"]})]}),z>0&&xY(zJ,{dimColor:!0,children:[" \u2191 ",z," more above"]}),H.length===0?FF(zJ,{dimColor:!0,children:V?`No messages match "${V}".`:"No messages."}):B.map((L,q)=>{let N=z+q===F,_=L.role==="user",M=CR0(L.role),T=RR0(L.role),k=N?"\u276F":" ",R=TR0(L.text.replace(/\n/g," ").trim()||"(empty)",O);return FF(vM,{flexDirection:"row",children:xY(zJ,{inverse:N,color:N?void 0:T,dimColor:!_&&!N,bold:_,children:[k," ",M," ",R]})},`${L.index}-${q}`)}),z+K<H.length&&xY(zJ,{dimColor:!0,children:[" \u2193 ",H.length-z-K," more below"]}),FF(vM,{marginTop:1,children:FF(zJ,{dimColor:!0,children:"type to search \xB7 \u2191\u2193 navigate \xB7 enter select user message \xB7 esc cancel"})})]})}var d40=E(()=>{P1()});import{jsx as Q$,jsxs as l9}from"react/jsx-runtime";import wR0,{useState as SR0,useMemo as sv}from"react";import{Box as d9,Text as F$,useInput as IR0}from"ink";function l40($){if($.includes("daltonized")||$.includes("accessible"))return"accessible";if($.startsWith("claude-"))return"claude";return"standard"}function fR0($){let Z=$.colors.text.replace("#",""),J=parseInt(Z.slice(0,2),16),X=parseInt(Z.slice(2,4),16),Y=parseInt(Z.slice(4,6),16);return(J*299+X*587+Y*114)/1000<128}function yR0($){return k7().map((Z)=>{let J=FA(Z);return{name:Z,displayName:J.displayName,isCurrent:Z===$,isLight:fR0(J),category:l40(Z)}})}function vR0({theme:$}){let Z=$.colors,J=Z.primary,X=Z.info,Y=Z.success,Q=Z.textMuted,G=Z.text;return l9(d9,{flexDirection:"column",children:[Q$(F$,{color:Q,children:"// fetch a user by ID"}),l9(d9,{children:[Q$(F$,{color:J,children:"async function "}),Q$(F$,{color:G,children:"fetchUser"}),Q$(F$,{color:G,children:"("}),Q$(F$,{color:G,children:"id"}),Q$(F$,{color:G,children:": "}),Q$(F$,{color:Y,children:"string"}),Q$(F$,{color:G,children:") {"})]}),l9(d9,{children:[Q$(F$,{color:G,children:" "}),Q$(F$,{color:J,children:"const "}),Q$(F$,{color:G,children:"res = "}),Q$(F$,{color:J,children:"await "}),Q$(F$,{color:G,children:"fetch("}),Q$(F$,{color:X,children:"`/api/users/${"}),Q$(F$,{color:G,children:"id"}),Q$(F$,{color:X,children:"}`"}),Q$(F$,{color:G,children:")"})]}),l9(d9,{children:[Q$(F$,{color:G,children:" "}),Q$(F$,{color:J,children:"if "}),Q$(F$,{color:G,children:"(!res.ok) "}),Q$(F$,{color:J,children:"throw new "}),Q$(F$,{color:Y,children:"Error"}),Q$(F$,{color:G,children:"("}),Q$(F$,{color:X,children:"`HTTP ${"}),Q$(F$,{color:G,children:"res.status"}),Q$(F$,{color:X,children:"}`"}),Q$(F$,{color:G,children:")"})]}),l9(d9,{children:[Q$(F$,{color:G,children:" "}),Q$(F$,{color:J,children:"return "}),Q$(F$,{color:G,children:"res.json() "}),Q$(F$,{color:J,children:"as "}),Q$(F$,{color:Y,children:"Promise"}),Q$(F$,{color:G,children:"<"}),Q$(F$,{color:Y,children:"User"}),Q$(F$,{color:G,children:">"})]}),Q$(F$,{color:G,children:"}"})]})}function hR0({theme:$}){let{colors:Z,symbols:J}=$;return l9(d9,{flexDirection:"column",borderStyle:"single",borderColor:Z.secondary,paddingX:1,children:[l9(F$,{bold:!0,color:Z.primary,children:[J.prompt," ",$.displayName]}),Q$(d9,{marginTop:1,flexDirection:"column",children:Q$(vR0,{theme:$})}),l9(d9,{marginTop:1,flexDirection:"column",children:[l9(F$,{color:Z.success,children:[J.success," Tests passed (3/3)"]}),l9(F$,{color:Z.error,children:[J.error," Error: connection refused"]}),l9(F$,{color:Z.warning,children:[J.warning," Deprecated API call"]}),Q$(d9,{children:Q$(F$,{color:Z.diffAdded,children:"+ const data = await fetch(url);"})}),Q$(d9,{children:Q$(F$,{color:Z.diffRemoved,children:"- const data = http.get(url);"})}),l9(F$,{color:Z.textMuted,children:[J.info," 1.2k tokens ",J.bullet," $0.01 ",J.bullet," 0.8s"]})]})]})}function rv({onSelect:$,onCancel:Z}){let J=sv(()=>e().name,[]),X=sv(()=>yR0(J),[J]),{items:Y,selectableIndices:Q}=sv(()=>{let D=[],O=[],L=new Map;for(let q of X){let A=L.get(q.category)??[];A.push(q),L.set(q.category,A)}for(let q of kR0){let A=L.get(q);if(!A?.length)continue;D.push({type:"header",label:bR0[q]??q});for(let N of A)O.push(D.length),D.push({type:"theme",option:N})}return{items:D,selectableIndices:O}},[X]),G=Q.findIndex((D)=>{let O=Y[D];return O?.type==="theme"&&O.option.isCurrent}),[V,W]=SR0(G>=0?G:0),H=Q.length>0?Math.min(V,Q.length-1):0,K=Y[Q[H]],z=K?.type==="theme"?K.option.name:null;if(z)b7(z);let U=wR0.useCallback(()=>{b7(J),Z()},[J,Z]),B=process.stdin.isTTY??!1;IR0((D,O)=>{if(W$(D,O)){U();return}if(O.return&&Q.length>0){let L=Q[H],q=Y[L];if(q.type==="theme")$({name:q.option.name,displayName:q.option.displayName});return}if(O.upArrow){W((L)=>Math.max(0,L-1));return}if(O.downArrow){W((L)=>Math.min(Q.length-1,L+1));return}},{isActive:B});let F=e();return l9(d9,{flexDirection:"column",borderStyle:"round",borderColor:F.colors.primary,paddingX:1,children:[l9(d9,{marginBottom:1,children:[Q$(F$,{bold:!0,color:F.colors.primary,children:"Theme"}),l9(F$,{color:F.colors.textMuted,children:[" ",F.symbols.arrow," select a color theme"]})]}),l9(d9,{children:[Q$(d9,{flexDirection:"column",width:38,children:Y.map((D,O)=>{if(D.type==="header")return Q$(d9,{marginTop:O>0?1:0,children:Q$(F$,{bold:!0,color:F.colors.textMuted,children:D.label})},`header-${D.label}`);let L=Q[H]===O,{option:q}=D;return Q$(d9,{children:l9(F$,{inverse:L,color:L?F.colors.primary:F.colors.text,children:[q.isCurrent?"\u25CF":"\u25CB"," ",q.displayName]})},q.name)})}),Q$(d9,{flexDirection:"column",flexGrow:1,marginLeft:2,children:Q$(hR0,{theme:F})})]}),Q$(d9,{marginTop:1,children:l9(F$,{color:F.colors.textMuted,children:["\u2191\u2193"," navigate ","\u23CE"," select esc cancel"]})})]})}var bR0,kR0;var a40=E(()=>{E0();bR0={standard:"Standard",claude:"Claude",accessible:"Accessible"},kR0=["standard","claude","accessible"]});import{jsxs as gY,jsx as hM}from"react/jsx-runtime";import{useState as n40,useEffect as xR0,useMemo as gR0}from"react";import{Box as tv,Text as UJ,useInput as mR0}from"ink";function cR0($,Z){let J=Z.trim().toLowerCase();if(!J)return!0;return[$.displayNameSnapshot,$.nodeId,$.host,$.port?.toString(),$.principalFingerprint,$.transport,$.status].filter((Y)=>typeof Y==="string"&&Y.length>0).map((Y)=>Y.toLowerCase()).some((Y)=>Y.includes(J))}function ev($,Z){if(Z<=0)return 0;return Math.min($,Z-1)}function $h({peers:$,sameHomeClientsAvailable:Z=!1,onSelect:J,onCancel:X}){let[Y,Q]=n40(0),[G,V]=n40(""),W=e(),H=gR0(()=>$.filter((B)=>cR0(B,G)),[$,G]);xR0(()=>{Q((B)=>ev(B,H.length))},[H.length]);let K=ev(Y,H.length),z=process.stdin.isTTY??!1;mR0((B,F)=>{if(W$(B,F)){X();return}if(F.return){if(H.length>0)J(H[K]);return}if(F.upArrow){Q((D)=>Math.max(0,D-1));return}if(F.downArrow){Q((D)=>ev(D+1,H.length));return}if(F.backspace||F.delete){V((D)=>D.slice(0,-1)),Q(0);return}if(B&&!F.ctrl&&!F.meta){V((D)=>D+B),Q(0);return}},{isActive:z});let U=(B)=>`${B.slice(0,4)} ${B.slice(4,8)} ${B.slice(8,12)} ${B.slice(12,16)}`;return gY(tv,{flexDirection:"column",borderStyle:"round",borderColor:W.colors.secondary,paddingX:1,children:[gY(UJ,{bold:!0,color:W.colors.primary,children:[" ","Nearby Peers"," "]}),G?gY(UJ,{dimColor:!0,children:[' (filter: "',G,'")']}):null,H.length===0&&hM(UJ,{dimColor:!0,children:G?"No peers match your filter.":Z?"No peer nodes. Use /clients for same-home terminals.":"Scanning... no peers found yet"}),H.map((B,F)=>gY(tv,{children:[gY(UJ,{inverse:F===K,color:F===K?W.colors.primary:void 0,children:[F===K?" \u25B8 ":" ",B.displayNameSnapshot]}),B.status==="connected"?hM(UJ,{color:"green",children:" \u2713 connected"}):gY(UJ,{dimColor:!0,children:[" ",B.host,":",B.port]}),B.principalFingerprint?gY(UJ,{color:W.colors.secondary,children:[" ",U(B.principalFingerprint)]}):null]},`${B.displayNameSnapshot}-${B.nodeId}-${F}`)),hM(tv,{marginTop:H.length>0?1:0,children:hM(UJ,{dimColor:!0,children:"type to search \u2191\u2193 navigate \u23CE connect esc cancel"})})]})}var i40=E(()=>{E0()});import{jsxs as GH,jsx as Zh}from"react/jsx-runtime";import{useEffect as uR0,useMemo as pR0,useState as o40}from"react";import{Box as Jh,Text as VH,useInput as dR0}from"ink";function lR0($,Z){let J=Z.trim().toLowerCase();if(!J)return!0;return $.displayLabel.toLowerCase().includes(J)||$.clientId.toLowerCase().includes(J)||$.clientKind.toLowerCase().includes(J)}function Xh($,Z){if(Z<=0)return 0;return Math.min($,Z-1)}function Yh({clients:$,onSelect:Z,onCancel:J}){let[X,Y]=o40(0),[Q,G]=o40(""),V=e(),W=pR0(()=>$.filter((z)=>lR0(z,Q)),[$,Q]);uR0(()=>{Y((z)=>Xh(z,W.length))},[W.length]);let H=Xh(X,W.length),K=process.stdin.isTTY??!1;return dR0((z,U)=>{if(W$(z,U)){J();return}if(U.return){if(W.length>0&&!W[H]?.self)Z(W[H]);return}if(U.upArrow){Y((B)=>Math.max(0,B-1));return}if(U.downArrow){Y((B)=>Xh(B+1,W.length));return}if(U.backspace||U.delete){G((B)=>B.slice(0,-1)),Y(0);return}if(z&&!U.ctrl&&!U.meta)G((B)=>B+z),Y(0)},{isActive:K}),GH(Jh,{flexDirection:"column",borderStyle:"round",borderColor:V.colors.secondary,paddingX:1,children:[GH(VH,{bold:!0,color:V.colors.primary,children:[" ","Same-Home Clients"," "]}),Q?GH(VH,{dimColor:!0,children:[' (filter: "',Q,'")']}):null,W.length===0&&Zh(VH,{dimColor:!0,children:"No same-home clients found."}),W.map((z,U)=>GH(Jh,{flexDirection:"column",children:[GH(VH,{inverse:U===H,color:U===H?V.colors.primary:void 0,children:[U===H?" \u25B8 ":" ",z.displayLabel]}),GH(VH,{dimColor:!0,children:[" ",z.clientId,z.self?" self \xB7 not sendable":""]})]},`${z.clientId}-${U}`)),Zh(Jh,{marginTop:W.length>0?1:0,children:Zh(VH,{dimColor:!0,children:"type to search \u2191\u2193 navigate \u23CE select esc cancel"})})]})}var s40=E(()=>{E0()});import{jsx as BJ,jsxs as DF}from"react/jsx-runtime";import{Box as xM,Text as B2,useInput as aR0}from"ink";function Qh({inviteToken:$,inviteLabel:Z,expiresAt:J,onClose:X}){let Y=e(),Q=process.stdin.isTTY??!1;return aR0((G,V)=>{if(V.return||W$(G,V))X()},{isActive:Q}),DF(xM,{flexDirection:"column",borderStyle:"round",borderColor:Y.colors.secondary,paddingX:1,paddingY:1,children:[BJ(B2,{bold:!0,color:Y.colors.primary,children:"Internet Invite"}),Z?DF(B2,{children:["Label: ",BJ(B2,{bold:!0,children:Z})]}):null,J?DF(B2,{dimColor:!0,children:["Expires: ",J]}):null,DF(xM,{marginTop:1,flexDirection:"column",children:[BJ(B2,{children:"Share this token:"}),BJ(B2,{children:$})]}),DF(xM,{marginTop:1,flexDirection:"column",children:[BJ(B2,{children:"Join with:"}),BJ(B2,{children:`aria pairing join ${$}`})]}),BJ(xM,{marginTop:1,children:BJ(B2,{dimColor:!0,children:"Press Enter or Esc to close."})})]})}var r40=E(()=>{E0()});import{jsx as FJ,jsxs as nR0}from"react/jsx-runtime";import{useState as iR0}from"react";import{Box as gM,Text as OF,useInput as oR0}from"ink";function Gh({onSubmit:$,onCancel:Z,error:J}){let[X,Y]=iR0(""),Q=e(),G=process.stdin.isTTY??!1;return oR0((V,W)=>{if(W$(V,W)){Z();return}if(W.return){let H=X.trim();if(H.length>0)$(H);return}if(W.backspace||W.delete){Y((H)=>H.slice(0,-1));return}if(V&&!W.ctrl&&!W.meta)Y((H)=>H+V)},{isActive:G}),nR0(gM,{flexDirection:"column",borderStyle:"round",borderColor:Q.colors.secondary,paddingX:1,paddingY:1,children:[FJ(OF,{bold:!0,color:Q.colors.primary,children:"Join Invite"}),FJ(OF,{children:"Paste the invite token and press Enter."}),FJ(gM,{marginTop:1,children:FJ(OF,{children:X||" "})}),J?FJ(gM,{marginTop:1,children:FJ(OF,{color:Q.colors.error,children:J})}):null,FJ(gM,{marginTop:1,children:FJ(OF,{dimColor:!0,children:"Type token, Enter to join, Esc to cancel."})})]})}var t40=E(()=>{E0()});import{jsxs as mY,jsx as NF}from"react/jsx-runtime";import{useState as sR0,useRef as rR0}from"react";import{Box as LF,Text as cY,useInput as tR0}from"ink";function Vh({request:$,onAccept:Z,onReject:J}){let[X,Y]=sR0("accept"),Q=rR0(!1),G=e(),V=process.stdin.isTTY??!1,W=(H)=>`${H.slice(0,4)} ${H.slice(4,8)} ${H.slice(8,12)} ${H.slice(12,16)}`;return tR0((H,K)=>{if(Q.current)return;if(K.return){if(Q.current=!0,X==="accept")Z();else J();return}if(W$(H,K)){Q.current=!0,J();return}if(K.leftArrow||K.rightArrow||K.tab)Y((z)=>z==="accept"?"reject":"accept")},{isActive:V}),mY(LF,{flexDirection:"column",borderStyle:"round",borderColor:G.colors.warning,paddingX:2,paddingY:1,children:[mY(cY,{bold:!0,color:G.colors.warning,children:[" ","Connection Request"," "]}),NF(LF,{marginTop:1,children:mY(cY,{children:[NF(cY,{bold:!0,children:$.displayNameSnapshot??$.nodeId})," wants to connect"]})}),NF(LF,{children:mY(cY,{dimColor:!0,children:["Fingerprint: ",W($.principalFingerprint)]})}),mY(LF,{marginTop:1,gap:2,children:[mY(cY,{inverse:X==="accept",color:X==="accept"?G.colors.success:void 0,children:[" ","Accept"," "]}),mY(cY,{inverse:X==="reject",color:X==="reject"?G.colors.error:void 0,children:[" ","Reject"," "]})]}),NF(LF,{marginTop:1,children:NF(cY,{dimColor:!0,children:"\u2190\u2192 select \u23CE confirm esc reject"})})]})}var e40=E(()=>{E0()});import{execFile as eR0}from"child_process";import{existsSync as Hh,readdirSync as X60}from"fs";import{dirname as $w0,join as mM,resolve as Zw0}from"path";import{fileURLToPath as Jw0}from"url";function Yw0(){let $=Xw0;for(let Z=0;Z<10;Z++){let J=mM($,".comms","sounds","wav");if(Hh(J))return J;let X=Zw0($,"..");if(X===$)break;$=X}return null}function U8($){if(!uY)return[];try{return X60(uY).filter((Z)=>new RegExp($).test(Z)).map((Z)=>mM(uY,Z))}catch{return[]}}function $60($){if(!uY)return[];let Z=mM(uY,"cloned");try{return X60(Z).filter((J)=>new RegExp($).test(J)).map((J)=>mM(Z,J))}catch{return[]}}function G5($){if($.length===0)return null;return $[Math.floor(Math.random()*$.length)]}function pY($){Kh=$}function Y60(){return Kh}function Q60(){if(process.platform!=="darwin")return"unsupported on this platform";return zh()?"afplay (macOS)":"afplay unavailable"}function zh(){if(Z60)return Wh;return Z60=!0,Wh=process.platform==="darwin"&&Hh("/usr/bin/afplay"),Wh}function V5($){if(!Kh||!$||!Hh($)||!zh())return!1;try{return eR0("afplay",[$],()=>{}),!0}catch{return!1}}function Gw0(){let $=Date.now();if($-J60>Qw0)AF=1;else AF++;if(J60=$,AF<=1)V5(G5(W5.acknowledge()));else if(AF===2)V5(G5(W5.annoyed()));else if(AF===3)V5(G5(W5.grumpy()));else V5(G5(W5.dark()))}function cM(){V5(G5(W5.readyToWork()))}function G60(){V5(G5(W5.fleetDown()))}function V60(){Gw0()}function W60(){V5(G5(W5.questDone()))}function H60($){switch($.type){case"error":V5(G5(W5.error()));break;case"guardrail_rejected":V5(G5(W5.defeat()));break}}function K60(){return uY!==null&&zh()}function z60(){return uY!==null}function U60(){return V5(G5(W5.readyToWork()))}var Xw0,uY,Kh=!0,Z60=!1,Wh=!1,W5,J60=0,AF=0,Qw0=15000;var Uh=E(()=>{Xw0=$w0(Jw0(import.meta.url));uY=Yw0();W5={acknowledge:()=>U8("^(peasant|orc|human|dwarf|elf|troll)_acknowledge"),annoyed:()=>U8("^(peasant|orc|goblin_sapper|human|troll|ogre)_selected"),grumpy:()=>U8("^(goblin_sapper|ogre|ogre_mage)_selected"),dark:()=>[...U8("^ogre_mage_selected"),...U8("^ogre_selected"),...U8("^troll_selected")],defeat:()=>$60("^defeat_"),error:()=>$60("^error_"),readyToWork:()=>[...U8("^peasant_selected"),...U8("^orc_selected"),...U8("^human_selected"),...U8("^dwarf_selected")],fleetUp:()=>[...U8("^orc_acknowledge"),...U8("^troll_acknowledge"),...U8("^ogre_acknowledge"),...U8("^human_acknowledge"),...U8("^knight_acknowledge")],fleetDown:()=>[...U8("^ogre_mage_acknowledge"),...U8("^ship_acknowledge"),...U8("^horde_ship_acknowledge")],questDone:()=>[...U8("^jobs_done"),...U8("^orc_work_completed"),...U8("^peasant_selected"),...U8("^orc_selected"),...U8("^human_selected"),...U8("^peasant_acknowledge"),...U8("^orc_acknowledge")]}});import{jsx as g6,jsxs as l1}from"react/jsx-runtime";import{useState as Bh,useCallback as F60}from"react";import{Box as H5,Text as D6,useInput as Vw0}from"ink";function Dh({onClose:$}){let Z=e(),J=Z.colors,[X,Y]=Bh(0),[Q,G]=Bh(Y60()),[V,W]=Bh("idle"),H=F60(()=>{let D=!Q;pY(D);let O=H$();if(O.soundEnabled=D,S$(O),G(D),D)cM()},[Q]),K=F60(()=>{let D=Q;if(!D)pY(!0);let O=U60();if(!D)pY(!1);W(O?"playing":"unavailable"),setTimeout(()=>W("idle"),1500)},[Q]),z=process.stdin.isTTY??!1;Vw0((D,O)=>{if(W$(D,O)){$();return}if(O.upArrow){Y((L)=>Math.max(0,L-1));return}if(O.downArrow){Y((L)=>Math.min(Fh.length-1,L+1));return}if(O.return){let L=Fh[X];if(L?.id==="toggle")H();else if(L?.id==="preview")K();return}},{isActive:z});let U=K60(),B=z60(),F=Q60();return l1(H5,{flexDirection:"column",borderStyle:"round",borderColor:J.primary,paddingX:1,children:[l1(H5,{marginBottom:1,children:[g6(D6,{bold:!0,color:J.primary,children:"\uD83D\uDD14 Sound"}),l1(D6,{color:J.textMuted,children:[" ",Z.symbols.arrow," notification preferences"]})]}),l1(H5,{flexDirection:"column",marginBottom:1,children:[l1(H5,{children:[g6(D6,{color:J.textMuted,children:"Status "}),B?g6(D6,{bold:!0,color:Q?J.success:J.textMuted,children:Q?"\u25CF ON":"\u25CB OFF"}):g6(D6,{color:J.warning,children:"\u26A0 Sound files not found"})]}),l1(H5,{children:[g6(D6,{color:J.textMuted,children:"Engine "}),g6(D6,{color:U?J.text:J.warning,children:F})]}),l1(H5,{children:[g6(D6,{color:J.textMuted,children:"Assets "}),g6(D6,{color:B?J.text:J.warning,children:B?"Warcraft II pack found":"missing"})]})]}),g6(H5,{marginBottom:1,children:g6(D6,{color:J.border,children:"\u2500".repeat(40)})}),g6(H5,{flexDirection:"column",children:Fh.map((D,O)=>{let L=O===X,q=D.id==="toggle";return l1(H5,{paddingX:1,children:[l1(D6,{inverse:L,color:L?J.primary:J.text,children:[D.icon," ",q?Q?"Turn off":"Turn on":D.label]}),q&&L&&l1(D6,{color:J.textMuted,children:[" ",Q?"\u2192 disable notifications":"\u2192 enable notifications"]}),D.id==="preview"&&V==="playing"&&g6(D6,{color:J.success,children:" \u266A playing..."}),D.id==="preview"&&V==="unavailable"&&g6(D6,{color:J.warning,children:" \u26A0 preview unavailable"})]},D.id)})}),g6(H5,{marginTop:1,children:l1(D6,{color:J.textMuted,children:["\u2191\u2193"," navigate ","\u23CE"," select ","esc"," close"]})})]})}var Fh;var D60=E(()=>{E0();Uh();Y4();Fh=[{id:"toggle",label:"Toggle sounds",description:"Turn sound notifications on or off",icon:"\uD83D\uDD0A"},{id:"preview",label:"Preview sound",description:"Play a sample notification sound",icon:"\u25B6"}]});import{jsx as i8,jsxs as v4,Fragment as Ww0}from"react/jsx-runtime";import{useState as Hw0}from"react";import{Box as h4,Text as C9,useInput as Kw0}from"ink";function Uw0({loopStatus:$}){let J=e().colors;if(!$)return null;let Y={running:J.success,idle:J.info,starting:J.warning,stopping:J.warning,stopped:J.textMuted,error:J.error}[$]??J.text;return i8(C9,{color:Y,children:$})}function Oh({onAction:$,onClose:Z,status:J,actionStatus:X}){let Y=e(),Q=Y.colors,G=zw0.filter((z)=>{if(z.showWhenRunning===void 0)return!0;return z.showWhenRunning===J.running}),[V,W]=Hw0(0),H=Math.min(V,G.length-1),K=process.stdin.isTTY??!1;return Kw0((z,U)=>{if(X)return;if(W$(z,U)){Z();return}if(U.upArrow){W((B)=>Math.max(0,B-1));return}if(U.downArrow){W((B)=>Math.min(G.length-1,B+1));return}if(U.return&&G.length>0){let B=G[H];if(B)$(B.id);return}},{isActive:K}),v4(h4,{flexDirection:"column",borderStyle:"round",borderColor:Q.primary,paddingX:1,children:[v4(h4,{marginBottom:1,children:[i8(C9,{bold:!0,color:Q.primary,children:"\u2699 Daemon"}),v4(C9,{color:Q.textMuted,children:[" ",Y.symbols.arrow," background service control"]})]}),v4(h4,{flexDirection:"column",marginBottom:1,children:[v4(h4,{children:[i8(C9,{color:Q.textMuted,children:"Status "}),i8(C9,{bold:!0,color:J.running?Q.success:Q.textMuted,children:J.running?"\u25CF Running":"\u25CB Stopped"})]}),J.running&&v4(Ww0,{children:[J.loopStatus&&v4(h4,{children:[i8(C9,{color:Q.textMuted,children:"Loop "}),i8(Uw0,{loopStatus:J.loopStatus})]}),J.port&&v4(h4,{children:[i8(C9,{color:Q.textMuted,children:"Port "}),i8(C9,{color:Q.text,children:J.port})]}),J.nodeId&&v4(h4,{children:[i8(C9,{color:Q.textMuted,children:"Node "}),i8(C9,{color:Q.text,children:J.nodeId.length>20?`${J.nodeId.slice(0,20)}\u2026`:J.nodeId})]}),J.runtimeId&&v4(h4,{children:[i8(C9,{color:Q.textMuted,children:"Runtime "}),i8(C9,{color:Q.text,children:J.runtimeId.length>20?`${J.runtimeId.slice(0,20)}\u2026`:J.runtimeId})]}),J.clients!==void 0&&v4(h4,{children:[i8(C9,{color:Q.textMuted,children:"Clients "}),v4(C9,{color:J.clients>0?Q.info:Q.textMuted,children:[J.clients," attached"]})]})]})]}),i8(h4,{marginBottom:1,children:i8(C9,{color:Q.border,children:"\u2500".repeat(44)})}),X&&i8(h4,{marginBottom:1,paddingX:1,children:v4(C9,{color:Q.warning,children:["\u27F3 ",X]})}),i8(h4,{flexDirection:"column",children:G.map((z,U)=>{let B=U===H;return v4(h4,{paddingX:1,flexDirection:"column",children:[i8(h4,{children:v4(C9,{inverse:B,color:B?z.id==="stop"?Q.error:Q.primary:Q.text,children:[z.icon," ",z.label]})}),B&&i8(h4,{paddingLeft:3,children:i8(C9,{color:Q.textMuted,children:z.description})})]},z.id)})}),i8(h4,{marginTop:1,children:v4(C9,{color:Q.textMuted,children:["\u2191\u2193"," navigate ","\u23CE"," select ","esc"," close"]})})]})}var zw0;var O60=E(()=>{E0();zw0=[{id:"start",label:"Start daemon",description:"Launch the shared background daemon process",icon:"\u25B6",showWhenRunning:!1},{id:"stop",label:"Stop daemon",description:"Gracefully stop the shared daemon process",icon:"\u25A0",showWhenRunning:!0},{id:"restart",label:"Restart daemon",description:"Restart the shared daemon process cleanly",icon:"\u21BB",showWhenRunning:!0}]});var N60=E(()=>{f40();v40();m40();c40();p40();d40();a40();i40();s40();r40();t40();e40();D60();O60()});var Nh=E(()=>{NS();ES();En();hn();wr();jq();tI();$b();vr();hr();xr();CV();gr();m90();$I();c90();p90();a90();JI();r90();VF();vY();WJ();N60()});import{jsxs as HH,jsx as WH}from"react/jsx-runtime";import{useEffect as Bw0,useState as Fw0,useRef as L60}from"react";import{Box as uM,Text as dY,useInput as Dw0}from"ink";function Ow0({status:$}){let Z=e();switch($){case"connected":return HH(dY,{color:Z.colors.success,children:["\u2713"," connected"]});case"expired":return HH(dY,{color:Z.colors.error,children:["\u2717"," expired"]});case"none":return HH(dY,{color:Z.colors.textMuted,children:["\xB7"," not connected"]})}}function A60({providers:$,onSelect:Z,onCancel:J,isActive:X=!0}){let Y=e(),[Q,G]=Fw0(0),V=L60(0),W=L60(!1);Bw0(()=>{W.current=!1,V.current=0,G(0)},[$]);let H=(z)=>{G((U)=>{let B=z(U);return V.current=B,B})},K=process.stdin.isTTY??!1;return Dw0((z,U)=>{if(W.current)return;if(U.upArrow)H((B)=>Math.max(0,B-1));else if(U.downArrow)H((B)=>Math.min($.length-1,B+1));else if(U.return)W.current=!0,Z($[V.current]);else if(W$(z,U))W.current=!0,J()},{isActive:X&&K}),HH(uM,{flexDirection:"column",borderStyle:"round",borderColor:Y.colors.secondary,paddingX:1,paddingY:1,width:56,children:[WH(uM,{marginBottom:1,children:WH(dY,{bold:!0,children:"Select a provider:"})}),$.map((z,U)=>{let B=U===Q,F=B?"\u25B8":" ";return HH(uM,{gap:1,children:[WH(dY,{color:B?Y.colors.primary:void 0,children:F}),WH(dY,{color:B?Y.colors.primary:void 0,bold:B,children:z.label.padEnd(28)}),WH(Ow0,{status:z.status})]},z.id)}),WH(uM,{marginTop:1,children:HH(dY,{color:Y.colors.textMuted,children:["\u2191\u2193"," Navigate Enter Select Esc Cancel"]})})]})}var q60=E(()=>{E0()});import{jsxs as F2,jsx as x4}from"react/jsx-runtime";import{useEffect as Nw0,useRef as Lh,useState as pM}from"react";import{Box as a1,Text as n1,useInput as Lw0}from"ink";function E60({provider:$,onCancel:Z,isActive:J=!0,onComplete:X,authorizeUrl:Y,expectedState:Q,onCodeSubmit:G}){let V=e(),[W,H]=pM("starting"),[K,z]=pM(""),[U,B]=pM(""),[F,D]=pM(""),O=Lh(null),L=Lh(!1),q=Lh(!1),A=process.stdin.isTTY??!1;Lw0((_,M)=>{if(W$(_,M))Z()},{isActive:J&&A}),Nw0(()=>{if(L.current)return;L.current=!0,H("waiting");let _=new Promise((T)=>{O.current=T}),M=(T)=>{z(T),H("manual")};if(Y&&G){z(Y),rL($,{authorizeUrl:Y,expectedState:Q,onManualFallback:M,manualCodePromise:_}).then(async(T)=>{if(q.current)return;H("exchanging"),await G(T),q.current=!0,H("success")},(T)=>{if(q.current)return;let k=T instanceof Error?T.message:String(T);B(k),H("error")});return}bw($,{onManualFallback:M,manualCodePromise:_}).then((T)=>{if(q.current)return;if(T.success)H("success"),q.current=!0,setTimeout(()=>{X?.({success:!0,message:T.message})},1000);else B(T.message),H("error")},(T)=>{if(q.current)return;let k=T instanceof Error?T.message:String(T);B(k),H("error")})},[Q,Y,G,X,$]);let N=(_)=>{let M=_.trim();if(!M)return;if(H("exchanging"),O.current)O.current(M),O.current=null};return F2(a1,{flexDirection:"column",borderStyle:"round",borderColor:V.colors.secondary,paddingX:1,paddingY:1,width:64,children:[x4(a1,{marginBottom:1,children:F2(n1,{bold:!0,children:["Sign in to ",$]})}),(W==="starting"||W==="waiting")&&F2(a1,{gap:1,children:[x4(JW,{}),x4(n1,{children:"Opening browser to sign in..."})]}),W==="manual"&&F2(a1,{flexDirection:"column",children:[x4(n1,{children:"Open this URL in your browser:"}),x4(a1,{marginTop:1,children:x4(n1,{color:V.colors.primary,wrap:"wrap",children:K})}),x4(a1,{marginTop:1,children:x4(n1,{children:"Paste the authorization code below:"})}),F2(a1,{marginTop:1,children:[x4(n1,{color:V.colors.textMuted,children:"> "}),x4(LV,{value:F,onChange:D,onSubmit:N,placeholder:"paste code here",focus:J,showCursor:!0})]})]}),W==="exchanging"&&F2(a1,{gap:1,children:[x4(JW,{}),x4(n1,{children:"Exchanging code for tokens..."})]}),W==="success"&&F2(n1,{color:V.colors.success,children:["\u2713"," Logged in to ",$]}),W==="error"&&F2(a1,{flexDirection:"column",children:[F2(n1,{color:V.colors.error,children:["\u2717"," ",U]}),x4(a1,{marginTop:1,children:x4(n1,{color:V.colors.textMuted,children:"Press Esc to dismiss"})})]}),W!=="success"&&W!=="error"&&x4(a1,{marginTop:1,children:x4(n1,{color:V.colors.textMuted,children:"Esc Cancel"})})]})}var _60=E(()=>{R6();E0();jq();cS()});import{jsxs as zH,jsx as D2}from"react/jsx-runtime";import{useEffect as Aw0,useRef as M60,useState as qw0}from"react";import{Box as KH,Text as DJ,useInput as Ew0}from"ink";function _w0({status:$}){let Z=e();if($==="connected")return zH(DJ,{color:Z.colors.success,children:["\u2713"," connected"]});if($==="available")return zH(DJ,{color:Z.colors.success,children:["\u2713"," available"]});return D2(DJ,{color:Z.colors.textMuted,children:"\xB7"})}function UH({options:$,onSelect:Z,onCancel:J,title:X="Select login method:",isActive:Y=!0}){let Q=e(),[G,V]=qw0(0),W=M60(0),H=M60(!1),K=process.stdin.isTTY??!1;Aw0(()=>{H.current=!1,W.current=0,V(0)},[$]);let z=(U)=>{V((B)=>{let F=U(B);return W.current=F,F})};return Ew0((U,B)=>{if(H.current)return;if(B.upArrow)z((F)=>Math.max(0,F-1));else if(B.downArrow)z((F)=>Math.min($.length-1,F+1));else if(B.return)H.current=!0,Z($[W.current]);else if(W$(U,B))H.current=!0,J()},{isActive:Y&&K}),zH(KH,{flexDirection:"column",borderStyle:"round",borderColor:Q.colors.secondary,paddingX:1,paddingY:1,width:64,children:[D2(KH,{marginBottom:1,children:D2(DJ,{bold:!0,children:X})}),$.map((U,B)=>{let F=B===G,D=F?"\u25B8":" ";return zH(KH,{flexDirection:"column",children:[zH(KH,{gap:1,children:[D2(DJ,{color:F?Q.colors.primary:void 0,children:D}),D2(DJ,{color:F?Q.colors.primary:void 0,bold:F,children:U.label}),D2(_w0,{status:U.status})]}),U.description&&D2(KH,{marginLeft:3,children:D2(DJ,{color:Q.colors.textMuted,dimColor:!0,children:U.description})})]},U.id)}),D2(KH,{marginTop:1,children:zH(DJ,{color:Q.colors.textMuted,children:["\u2191\u2193"," Navigate Enter Select Esc Cancel"]})})]})}var Ah=E(()=>{E0()});import{jsx as Mw0}from"react/jsx-runtime";function P60({options:$,onSelect:Z,onCancel:J,isActive:X=!0}){return Mw0(UH,{options:$,onSelect:Z,onCancel:J,title:"Select Anthropic login method:",isActive:X})}var j60=E(()=>{Ah()});import{jsx as OJ,jsxs as qh}from"react/jsx-runtime";import{useRef as Pw0,useState as jw0}from"react";import{Box as qF,Text as BH,useInput as Tw0}from"ink";function FH({title:$,hint:Z,onSubmit:J,onCancel:X,isActive:Y=!0}){let Q=e(),[G,V]=jw0(""),W=Pw0(!1),H=process.stdin.isTTY??!1;Tw0((z,U)=>{if(W.current)return;if(W$(z,U)){W.current=!0,X();return}if(U.return){if(G.trim().length>0)W.current=!0,J(G.trim());return}if(U.backspace||U.delete){V((B)=>B.slice(0,-1));return}if(U.upArrow||U.downArrow||U.leftArrow||U.rightArrow||U.tab)return;if(z&&!U.ctrl&&!U.meta)V((B)=>B+z)},{isActive:Y&&H});let K=G.length>0?G.slice(0,4)+"\u2022".repeat(Math.max(0,G.length-4)):"";return qh(qF,{flexDirection:"column",borderStyle:"round",borderColor:Q.colors.secondary,paddingX:1,paddingY:1,width:64,children:[OJ(qF,{marginBottom:1,children:OJ(BH,{bold:!0,children:$})}),Z&&OJ(qF,{marginBottom:1,children:OJ(BH,{color:Q.colors.textMuted,dimColor:!0,children:Z})}),qh(qF,{children:[qh(BH,{color:Q.colors.primary,children:["\u25B8"," "]}),OJ(BH,{children:K||" "}),OJ(BH,{color:Q.colors.textMuted,children:"_"})]}),OJ(qF,{marginTop:1,children:OJ(BH,{color:Q.colors.textMuted,children:"Enter Submit Esc Cancel"})})]})}var T60=E(()=>{E0()});function C60($,Z,J={}){let X=J.userName||"User",Y=[],Q=new Map;function G(V,W){for(let H of V.content)switch(H.type){case"text":{if(V.role==="user"){let K=sS(H.text);for(let z of K)if(z.type==="image"&&bA(z.dataUri))Y.push({kind:"user-image",id:`${V.id}-image-${Y.length}`,dataUri:z.dataUri,userName:X,committed:W});else if(z.type==="text"&&z.text.length>0)Y.push({kind:"user-message",id:`${V.id}-text-${Y.length}`,text:z.text,userName:X,committed:W})}else if(V.role==="system"&&H.text.length>0)Y.push({kind:"user-message",id:`${V.id}-text-${Y.length}`,text:H.text,userName:"System",committed:W});else if(V.role==="assistant"&&H.text.trim())Y.push({kind:"assistant-text",id:`${V.id}-text-${Y.length}`,text:H.text,arion:V.arion?{name:V.arion.name,emoji:V.arion.emoji||"\uD83E\uDD8B",color:V.arion.color||"cyan"}:void 0,committed:W});break}case"thinking":{if(H.content?.trim())Y.push({kind:"thinking",id:`${V.id}-thinking-${Y.length}`,content:H.content,durationSec:H.durationMs!=null?H.durationMs/1000:void 0,arion:V.arion?{name:V.arion.name,emoji:V.arion.emoji||"\uD83E\uDD8B",color:V.arion.color||"cyan"}:void 0,committed:W});break}case"tool_use":{let K={kind:"tool-execution",id:`${V.id}-tool-${H.id}`,toolName:H.name,input:H.arguments,output:void 0,status:"pending",durationMs:void 0,usage:void 0,committed:W};Q.set(H.id,K),Y.push(K);break}case"tool_result":{let K=Q.get(H.toolUseId);if(K){if(K.output=H.resultData??H.content,K.status=H.status==="error"?"error":"complete",H.status==="error")K.error=typeof H.content==="string"?H.content:"Tool error";if(H.durationMs!=null)K.durationMs=H.durationMs;if(H.usage)K.usage={inputTokens:H.usage.inputTokens??0,outputTokens:H.usage.outputTokens??0};if(!W)K.committed=!1}break}case"handoff":{Y.push({kind:"handoff",id:`${V.id}-handoff-${Y.length}`,target:H.target,direction:H.direction==="from"?"incoming":"outgoing",committed:W});break}case"error":{Y.push({kind:"error",id:`${V.id}-error-${Y.length}`,message:H.content,suggestion:H.suggestion,committed:W});break}}}for(let V of $)G(V,!0);for(let V of Z)G(V,!1);return Y}var R60=E(()=>{kA()});function S60($,Z){switch(Z.type){case"STREAM_START":return{kind:"composing",verb:Z.verb};case"THINKING_START":if($.kind!=="composing"&&$.kind!=="idle")return $;return{kind:"thinking",verb:Z.verb,startedAt:Z.startedAt};case"THINKING_END":if($.kind!=="thinking")return $;return{kind:"composing",verb:Z.verb,thoughtForSeconds:Z.durationSeconds};case"TOOL_START":{let J=new Map($.kind==="tool_running"?$.tools:[]);return J.set(Z.callId,Z.displayName),{kind:"tool_running",tools:J}}case"TOOL_END":{if($.kind!=="tool_running")return $;let J=new Map($.tools);if(J.delete(Z.callId),J.size===0)return{kind:"composing",verb:Z.verb};return{kind:"tool_running",tools:J}}case"STREAM_END":return{kind:"idle"};default:return $}}var w60;var I60=E(()=>{w60={kind:"idle"}});import{useReducer as Cw0,useEffect as Eh,useRef as b60}from"react";function k60($,Z){let[J,X]=Cw0(S60,w60),Y=b60(!1);Eh(()=>{if(Z&&!Y.current)X({type:"STREAM_START",verb:j1()});else if(!Z&&Y.current)X({type:"STREAM_END"});Y.current=Z},[Z]);let Q=b60(null);return Eh(()=>{if($!==Q.current){if(Q.current!==null)X({type:"STREAM_END"});Q.current=$}},[$]),Eh(()=>{if(!$)return;let G=()=>X({type:"THINKING_START",verb:j1(),startedAt:Date.now()}),V=(K)=>X({type:"THINKING_END",verb:j1(),durationSeconds:Math.round(K.durationMs/1000)}),W=(K)=>X({type:"TOOL_START",callId:K.id,displayName:un(K.name,!0)}),H=(K)=>X({type:"TOOL_END",callId:K.id,verb:j1()});return $.on("thinking_start",G),$.on("thinking_end",V),$.on("tool_start",W),$.on("tool_result",H),()=>{$.off("thinking_start",G),$.off("thinking_end",V),$.off("tool_start",W),$.off("tool_result",H)}},[$]),J}var f60=E(()=>{I60();_V()});function dM($){let Z=typeof $.nodeId==="string"?$.nodeId.trim():"",J=typeof $.transport==="string"?$.transport:"unknown";if(Z)return`node:${Z}`;let X=typeof $.principalFingerprint==="string"?$.principalFingerprint.trim():"";if(X)return`principal:${X}`;return`endpoint:${J}:${$.host}:${$.port}:${$.displayNameSnapshot}`}function y60($,Z){let J=new Map;for(let X of[...$,...Z]){let Y=dM(X);if(!J.has(Y))J.set(Y,X)}return[...J.values()]}import{jsx as G$,jsxs as lY,Fragment as Rw0}from"react/jsx-runtime";import{useState as NJ,useCallback as O2,useMemo as LJ,useEffect as qZ}from"react";import{Box as K5,Static as ww0,Text as N2,useApp as Sw0,useInput as Iw0}from"ink";function _h({session:$,model:Z,maxContextTokens:J,banner:X,messages:Y=[],previewMessages:Q=[],isStreaming:G=!1,queuedMessage:V,onCancelQueuedMessage:W,responseTime:H,commands:K=[],arions:z=[],models:U=[],memories:B=[],memoryBrowserMode:F="browse",isLoadingMemories:D=!1,userName:O,metrics:L,displayMode:q="standard",displayConfig:A,showThinking:N=!0,showCosts:_=!0,showTraces:M=!1,spans:T=[],pipelineTiming:k,activeArion:R,onSubmit:a,onCommand:o,onSelectArion:u,onSelectModel:w,onSelectTheme:m,onSelectMemory:I,onOpenMemoryBrowser:S,onToggleThinking:j,onToggleCosts:b,onToggleTraces:v,onCycleDisplayMode:c,sessions:C=[],onSelectSession:f,onLoadSessions:g,onSearchSessions:l,onLoadMoreSessions:$0,staticRenderEpoch:Y0,openSessionOverlaySignal:x,openThemeOverlaySignal:r,openSoundOverlaySignal:J0,openDaemonOverlaySignal:X0,daemonStatus:n,daemonActionStatus:K0,onDaemonAction:z0,connectionState:O0="connected",inputHistory:R0=[],onSaveInput:I0,obsCtx:Z0,onCancel:H0,approvalRequest:B0,onApprovalChoice:F0,effortLevel:V0,showAutonomySelector:D0,autonomyLevel:C0,onAutonomySelect:_0,onAutonomyCancel:L0,onCycleAutonomy:P0,onCycleEffort:c0,loginPickerProviders:z$,onLoginProviderSelect:A0,onLoginPickerCancel:u0,copilotSourceOptions:U$,onCopilotSourceSelect:r0,onCopilotSourceCancel:V$,oauthProvider:_$,oauthAuthorizeUrl:s8,oauthExpectedState:u$,onOAuthComplete:m$,onOAuthCodeSubmit:K9,onOAuthCancel:d4,copilotDeviceProvider:q5,copilotDeviceProfileLabel:GK,copilotDeviceVerificationUri:VK,copilotDeviceUserCode:W7,onCopilotDeviceComplete:H7,onCopilotDeviceApprove:WK,onCopilotDeviceCancel:y2,anthropicMethodOptions:HK,onAnthropicMethodSelect:JO,onAnthropicMethodCancel:cJ,anthropicKeyInputVisible:XO,onAnthropicKeySubmit:TQ,onAnthropicKeyCancel:YO,anthropicSetupTokenVisible:CQ,onAnthropicSetupTokenSubmit:QO,onAnthropicSetupTokenCancel:RQ,openaiMethodOptions:KK,onOpenAIMethodSelect:wQ,onOpenAIMethodCancel:GO,openaiKeyInputVisible:SQ,onOpenAIKeySubmit:VO,onOpenAIKeyCancel:IQ,googleMethodOptions:bQ,onGoogleMethodSelect:kQ,onGoogleMethodCancel:WO,googleKeyInputVisible:fQ,onGoogleKeySubmit:HO,onGoogleKeyCancel:yQ,authInteractionOptions:zK,authInteractionTitle:UK,onAuthInteractionSelect:KO,onAuthInteractionCancel:vQ,authInteractionInput:hQ,onAuthInteractionInputSubmit:xQ,onAuthInteractionInputCancel:zO,nearbyPeers:v2=[],localClients:UO=[],onSelectPeer:BK,onSelectClient:DT,onPeerCancel:BO,onClientsCancel:OT,openPeersOverlaySignal:gQ,openClientsOverlaySignal:FO,inviteShare:K7,onInviteShareClose:NT,openJoinInviteOverlaySignal:mQ,onJoinInviteSubmit:FK,onJoinInviteCancel:uJ,joinInviteError:LT,incomingPairRequest:h2,onAcceptPairRequest:AT,onRejectPairRequest:DO,onCancelPairing:E5,openMessageEditOverlaySignal:DK,editableMessages:x2,onEditMessage:qT,prefillInput:OK,onPrefillConsumed:ET,meshMessageCount:_T=0,runtimeSocket:Vu=null,clientId:Wu=null,clientAuthToken:Hu=null,resolveCredentials:NK}){let{exit:pJ}=Sw0(),{columns:OO,rows:MT}=X9(),[LK,A6]=NJ(""),[m0,J$]=NJ("none"),[cQ,uQ]=NJ(""),[AK,qK]=NJ(""),[i9,g2]=NJ("become"),[NO,z7]=NJ("all"),[LO,pQ]=NJ(!1),dJ=Boolean(zK||HK||KK||bQ),AO=Boolean(hQ||XO||CQ||SQ||fQ),lJ=Boolean(_$||q5||z$||U$);qZ(()=>{if(dJ)J$("login-method");else if(AO)J$("login-input");else if(lJ)J$("login");else if(m0==="login"||m0==="login-method"||m0==="login-input")J$("none")},[dJ,AO,lJ]);let EK=O2(()=>{J$("session"),setTimeout(()=>g?.(),0)},[g]);qZ(()=>{if(x===void 0)return;EK()},[x,EK]),qZ(()=>{if(r===void 0)return;J$("theme")},[r]),qZ(()=>{if(J0===void 0)return;J$("sound")},[J0]),qZ(()=>{if(X0===void 0)return;J$("daemon")},[X0]);let[dQ,lQ]=NJ([]);qZ(()=>{if(gQ===void 0)return;lQ([...v2]),J$("peers")},[gQ]),qZ(()=>{if(FO===void 0)return;J$("clients")},[FO]),qZ(()=>{if(K7)J$("invite-share");else if(m0==="invite-share")J$("none")},[K7,m0]),qZ(()=>{if(mQ===void 0)return;J$("join-invite")},[mQ]),qZ(()=>{if(DK===void 0)return;if(x2&&x2.length>0)J$("message-edit")},[DK]),qZ(()=>{if(OK!==void 0)A6(OK),ET?.()},[OK]),qZ(()=>{if(m0!=="peers")return;lQ((N0)=>{let T0=new Set(N0.map(dM)),J8=v2.filter((M5)=>!T0.has(dM(M5)));return J8.length>0?[...N0,...J8]:N0})},[m0,v2]),qZ(()=>{if(h2&&m0==="none"&&!G)J$("pair-request");else if(!h2&&m0==="pair-request")J$("none")},[h2,m0,G]);let PT=process.stdin.isTTY??!1;Iw0((N0,T0)=>{if(N0==="\x03"||T0.ctrl&&N0==="c"){if(B0)return;if(G&&H0){H0();return}pJ()}if(W$(N0,T0)){if(B0)return;if(m0!=="none"){wZ();return}if(E5){E5();return}if(G&&V&&W)W();else if(G&&H0)H0();else A6("");return}if(T0.upArrow&&G&&V&&W){W();return}if(T0.ctrl&&N0==="\x1C"&&m0==="none"){c?.();return}if(T0.ctrl&&N0==="t"&&m0==="none"){j?.();return}if(T0.ctrl&&N0==="g"&&m0==="none"){b?.();return}if(T0.ctrl&&N0==="s"&&m0==="none"){v?.();return}if(T0.tab&&N0!=="\t"&&m0==="none"){P0?.();return}if(T0.ctrl&&N0==="\x05"&&m0==="none"){c0?.();return}if(T0.ctrl&&N0==="\x1F"&&m0==="none"){pQ((J8)=>!J8);return}},{isActive:PT});let CZ=$.getPrimary(),Ku=CZ?.name||"ARIA",jT=CZ?.color||"cyan",TT=CZ?.emoji||"\uD83E\uDD8B",RZ=k60(Z0??null,G??!1),aQ=(m0==="none"&&!B0?4:0)+(!A||A.showStatusBar?1:0),qO=Math.max(MT-aQ,1),nQ=O2((N0,T0)=>{if(N0==="command")J$("command"),uQ(T0);else if(N0==="mention")J$("arion"),qK(T0),g2("mention")},[]),CT=O2((N0)=>{J$("none"),A6("");let T0=N0.requiresArgs===!0||(N0.args?.length??0)>0;if(N0.name==="become")J$("arion"),g2("become"),z7("all");else if(N0.name==="rest")J$("arion"),g2("rest"),z7("active");else if(N0.name==="wake")J$("arion"),g2("wake"),z7("resting");else if(N0.name==="model")J$("model");else if(N0.name==="theme")J$("theme");else if(N0.name==="sound")J$("sound");else if(N0.name==="daemon")o(N0.name);else if(N0.name==="memories")S?.("browse"),J$("memory");else if(N0.name==="forget")S?.("forget"),J$("memory");else if(N0.name==="resume")EK();else if(N0.name==="exit")pJ();else if(T0){A6(`/${N0.name} `);return}else o(N0.name)},[o,S,pJ]),p6=O2((N0)=>{if(J$("none"),i9==="mention"){let T0=LK.replace(/@\w*$/,"");A6(T0+"@"+N0.name+" ")}else u?.(N0.name,i9)},[i9,LK,u]),RT=O2((N0,T0)=>{J$("none"),w?.(N0.value??N0.name,T0)},[w]),wT=O2((N0)=>{J$("none"),m?.(N0)},[m]),ST=O2((N0)=>{J$("none"),I?.(N0)},[I]),wZ=O2(()=>{if(J$("none"),i9!=="mention")A6("");uQ(""),qK("")},[i9]),m2=O2((N0)=>{J$("none"),A6(N0),uQ("")},[]),EO=LJ(()=>C60(Y,Q,{userName:O}),[Y,Q,O]),d6=LJ(()=>iI(EO,q),[EO,q]),iQ=LJ(()=>d6.filter((N0)=>N0.committed),[d6]),oQ=LJ(()=>d6.filter((N0)=>!N0.committed),[d6]),E8=G&&V?V:null,SZ=E8!==null,X1=RZ.kind!=="idle",T$=Math.max(OO-4,20),c2=LJ(()=>{if(!E8)return 0;return Math.max(F9(E8,{width:T$}).split(`
4727
- `).length,1)},[T$,E8]),sQ=(SZ?4+c2:0)+(X1?2:0),IZ=Math.max(qO-sQ,1),_5=LJ(()=>{let N0=new Map,T0="";for(let J8 of d6){let M5=J8.kind==="user-message"||J8.kind==="user-image"?`user:${J8.userName}`:J8.kind==="assistant-text"?`assistant:${J8.arion?.name??"ARIA"}`:J8.kind==="thinking"?`assistant:${J8.arion?.name??"ARIA"}`:J8.kind==="tool-execution"?"tool":J8.kind,rQ=J8.kind==="user-message"||J8.kind==="user-image"||J8.kind==="assistant-text"||J8.kind==="thinking";if(N0.set(J8.id,rQ&&M5!==T0),rQ)T0=M5}return N0},[d6]),IT=LJ(()=>{let N0=new Map;for(let T0=0;T0<d6.length;T0++){let J8=d6[T0],M5=T0>0?d6[T0-1]:void 0,rQ=J8.kind==="tool-execution"&&M5?.kind==="tool-execution";N0.set(J8.id,T0>0&&!rQ)}return N0},[d6]),zu=LJ(()=>{let N0=[];if(X)N0.push({id:"header",_kind:"banner"});for(let T0 of iQ)N0.push({...T0,_kind:"item"});return N0},[X,iQ]);return lY(Rw0,{children:[G$(ww0,{items:zu,children:(N0)=>{if(N0._kind==="banner")return G$(K5,{width:"100%",justifyContent:"center",children:X},N0.id);return G$(K5,{flexDirection:"column",marginTop:IT.get(N0.id)?1:0,children:G$(Pq,{item:N0,displayMode:q,showPrefix:_5.get(N0.id)??!1})},N0.id)}},`static-${Y0}`),lY(K5,{flexDirection:"column",width:"100%",children:[lY(K5,{flexDirection:"column",maxHeight:qO,justifyContent:"flex-end",overflowY:"hidden",children:[oQ.length>0&&G$(K5,{flexDirection:"column",maxHeight:IZ,overflowY:"hidden",children:oQ.map((N0)=>G$(K5,{flexDirection:"column",marginTop:IT.get(N0.id)?1:0,children:G$(Pq,{item:N0,displayMode:q,showPrefix:_5.get(N0.id)??!1,previewTailLines:IZ})},N0.id))}),SZ&&lY(K5,{marginTop:1,flexDirection:"column",children:[G$(IA,{param:{type:"text",text:E8??""},userName:O??"User",columns:OO,showPrefix:!0,addMargin:!1}),G$(N2,{dimColor:!0,children:" \u2191 queued \u2014 press esc or \u2191 to cancel and edit"})]}),M&&T.length>0&&G$(zv,{spans:T}),A?.showPipelineTiming&&k&&k.phases.length>0&&G$(Uv,{report:k}),LO&&lY(K5,{flexDirection:"column",borderStyle:"round",borderColor:"gray",paddingX:1,marginY:1,children:[G$(N2,{bold:!0,dimColor:!0,children:"Hotkeys"}),G$(N2,{dimColor:!0,children:" Ctrl+\\ \u2014 cycle display mode"}),G$(N2,{dimColor:!0,children:" Ctrl+t \u2014 toggle thinking blocks"}),G$(N2,{dimColor:!0,children:" Ctrl+g \u2014 toggle cost display"}),G$(N2,{dimColor:!0,children:" Ctrl+e \u2014 cycle effort level"}),G$(N2,{dimColor:!0,children:" Ctrl+s \u2014 toggle trace waterfall"}),G$(N2,{dimColor:!0,children:" Escape \u2014 cancel streaming / close overlay / clear input"}),G$(N2,{dimColor:!0,children:" Ctrl+/ \u2014 toggle this help"})]}),X1&&G$(Fv,{state:RZ.kind==="thinking"?"thinking":"composing",elapsedSeconds:Math.floor(L?.wallTimeSeconds??0),totalTokens:L?.totalTokens??0,thoughtForSeconds:RZ.kind==="composing"?RZ.thoughtForSeconds:void 0,currentVerb:RZ.kind==="tool_running"?[...new Set(RZ.tools.values())].join(" \xB7 "):RZ.verb.present})]}),lY(K5,{flexDirection:"column",flexShrink:0,children:[D0&&_0&&L0&&G$(Hv,{currentLevel:C0??JJ.autonomy,onSelect:_0,onCancel:L0}),z$&&A0&&u0&&G$(A60,{providers:z$,onSelect:A0,onCancel:u0}),U$&&r0&&V$&&G$(eI,{options:U$,onSelect:r0,onCancel:V$}),m0==="login-method"&&zK&&KO&&vQ&&G$(UH,{options:zK,onSelect:(N0)=>KO(N0.id),onCancel:vQ,title:UK??"Choose an option:",isActive:m0==="login-method"}),m0==="login-method"&&HK&&JO&&cJ&&G$(P60,{options:HK,onSelect:JO,onCancel:cJ,isActive:m0==="login-method"}),m0==="login-input"&&hQ&&xQ&&zO&&G$(FH,{title:hQ.title,hint:hQ.hint,onSubmit:xQ,onCancel:zO,isActive:m0==="login-input"}),m0==="login-input"&&XO&&TQ&&YO&&G$(FH,{title:"Enter Anthropic API key",hint:"Paste your sk-ant-api03-* key",onSubmit:TQ,onCancel:YO,isActive:m0==="login-input"}),m0==="login-input"&&CQ&&QO&&RQ&&G$(FH,{title:"Enter setup token",hint:"From `claude setup-token` or admin provisioning",onSubmit:QO,onCancel:RQ,isActive:m0==="login-input"}),m0==="login-method"&&KK&&wQ&&GO&&G$(UH,{options:KK,onSelect:wQ,onCancel:GO,title:"Select OpenAI login method:",isActive:m0==="login-method"}),m0==="login-input"&&SQ&&VO&&IQ&&G$(FH,{title:"Enter OpenAI API key",hint:"Paste your sk-* key",onSubmit:VO,onCancel:IQ,isActive:m0==="login-input"}),m0==="login-method"&&bQ&&kQ&&WO&&G$(UH,{options:bQ,onSelect:kQ,onCancel:WO,title:"Select Google login method:",isActive:m0==="login-method"}),m0==="login-input"&&fQ&&HO&&yQ&&G$(FH,{title:"Enter Google API key",hint:"Paste your AIza* key",onSubmit:HO,onCancel:yQ,isActive:m0==="login-input"}),m0==="login"&&_$&&m$&&d4&&G$(E60,{provider:_$,onCancel:d4,...s8&&K9?{authorizeUrl:s8,expectedState:u$??void 0,onCodeSubmit:K9}:{onComplete:m$},isActive:m0==="login"}),m0==="login"&&q5&&H7&&y2&&G$(rI,{provider:q5,profileLabel:GK??void 0,...VK&&W7&&WK?{verificationUri:VK,userCode:W7,onApprove:WK}:{onComplete:H7},onCancel:y2}),lY(K5,{flexDirection:"column",children:[m0==="command"&&G$(mv,{commands:K,initialFilter:cQ,onSelect:CT,onHandOffInput:m2,onCancel:wZ}),m0==="arion"&&G$(cv,{arions:z,initialFilter:AK,statusFilter:NO,onSelect:p6,onCancel:wZ}),m0==="model"&&G$(pv,{models:U,effortLevel:V0,onSelect:RT,onCancel:wZ}),m0==="theme"&&G$(rv,{onSelect:wT,onCancel:wZ}),m0==="sound"&&G$(Dh,{onClose:()=>J$("none")}),m0==="daemon"&&G$(Oh,{status:n??{running:!1},actionStatus:K0,onAction:(N0)=>z0?.(N0),onClose:()=>J$("none")}),m0==="invite-share"&&K7&&G$(Qh,{inviteToken:K7.inviteToken,inviteLabel:K7.inviteLabel,expiresAt:K7.expiresAt,onClose:()=>{J$("none"),NT?.()}}),m0==="join-invite"&&G$(Gh,{error:LT,onSubmit:(N0)=>{J$("none"),FK?.(N0)},onCancel:()=>{J$("none"),uJ?.()}}),m0==="memory"&&G$(lv,{memories:B,mode:F,isLoading:D,onSelect:ST,onCancel:wZ}),m0==="peers"&&G$($h,{peers:dQ.length>0?dQ:v2,sameHomeClientsAvailable:UO.length>0,onSelect:(N0)=>{J$("none"),BK?.(N0)},onCancel:wZ}),m0==="clients"&&G$(Yh,{clients:UO,onSelect:(N0)=>{J$("none"),A6(`/send ${N0.clientId} `),DT?.(N0)},onCancel:()=>{J$("none"),OT?.()}}),m0==="pair-request"&&h2&&G$(Vh,{request:h2,onAccept:()=>{J$("none"),AT?.()},onReject:()=>{J$("none"),DO?.()}}),m0==="session"&&G$(nv,{sessions:C,onSelect:(N0)=>{J$("none"),f?.(N0)},onCancel:wZ,onSearch:(N0)=>l?.(N0),onPageChange:(N0)=>$0?.(N0)}),m0==="message-edit"&&x2&&G$(ov,{messages:x2,onSelect:(N0,T0)=>{J$("none"),qT?.(N0,T0)},onCancel:wZ}),m0==="none"&&!B0&&G$(aS,{userName:O,value:LK,onChange:A6,onSubmit:a,onTrigger:nQ,onExit:()=>pJ(),history:R0,onSaveInput:I0,focus:m0==="none",isStreaming:G,onDoubleEscape:()=>{if(x2&&x2.length>0)return J$("message-edit"),!0;return!1}})]}),(!A||A.showStatusBar)&&G$(OS,{arion:{name:Ku,emoji:TT,color:jT,traits:CZ?.personality?.traits?.slice(0,2)},model:Z,maxContextTokens:J,responseTime:H,metrics:L,displayMode:q,showCosts:_,activeArion:R,effortLevel:V0,autonomyLevel:C0,meshMessageCount:_T,connectionState:O0})]})]})]})}var v60=E(()=>{Nh();q60();$b();_60();tI();j60();Ah();T60();nI();oS();P1();R60();M1();G8();f60()});function h60($){let Z=!1,J=(X)=>{if(Z)return;Z=!0,$(X)};return{onAbort(){J(!1)},onAllow(X){J(!0)},onReject(){J(!1)},onDone(){queueMicrotask(()=>{if(!Z)J(!1)})}}}import{jsx as Mh,jsxs as bw0}from"react/jsx-runtime";import{useMemo as x60,useState as kw0}from"react";import{Box as fw0,useStdout as yw0}from"ink";function vw0($){let Z=bU[$.toLowerCase()];return{name:$,userFacingName(J){if(Z)return Z.displayName(J);return $},renderToolUseMessage(J,X){if(Z)return Z.renderInput(J,X);return JSON.stringify(J)},isReadOnly(){return!1},inputSchema:{parse(J){return J??{}}}}}function xw0($){switch($){case"low":return 0.2;case"moderate":return 0.5;case"high":return 0.9}}function g60($){let{stdout:Z}=yw0(),J=Z?.columns??80,[X]=kw0(!1),Y=x60(()=>{if(!$.approvalRequest)return null;return h60($.onApprovalChoice)},[$.approvalRequest,$.onApprovalChoice]),Q=x60(()=>{if(!$.approvalRequest||!Y)return null;let{toolName:G,input:V,riskLevel:W}=$.approvalRequest;return{assistantMessage:hw0,tool:vw0(G),description:`${G} requires approval`,input:V??{},commandPrefix:null,riskScore:xw0(W),onAbort:Y.onAbort,onAllow:Y.onAllow,onReject:Y.onReject}},[Y,$.approvalRequest]);if(Q&&Y)return bw0(fw0,{flexDirection:"column",width:"100%",children:[Mh(_h,{...$}),Mh(xv,{toolUseConfirm:Q,onDone:Y.onDone,verbose:X})]});return Mh(_h,{...$})}var hw0;var m60=E(()=>{v60();VF();Mq();Mq();hw0={message:{id:"aria-approval"}}});var Ph;var c60=E(()=>{Ph=[{name:"become",description:"Switch to another arion",usage:"/become <name>",args:["<name>"],requiresArgs:!0},{name:"arions",description:"List all arions",args:[]},{name:"hatch",description:"Create a new arion",usage:"/hatch <name> [description]",args:["<name>","[description]"],requiresArgs:!0},{name:"rest",description:"Put an arion to rest",usage:"/rest <name>",args:["<name>"],requiresArgs:!0},{name:"wake",description:"Wake a resting arion",usage:"/wake <name>",args:["<name>"],requiresArgs:!0},{name:"model",description:"Change or view current AI model",usage:"/model [name|list|refresh] [--provider <name>] [--use-env]",args:["[name|list|refresh]","[--provider <name>]","[--use-env]"]},{name:"autonomy",description:"Change permission approval policy",usage:"/autonomy [level]",args:["[level]"]},{name:"sound",description:"Open sound preferences or toggle notifications",usage:"/sound [on|off]",args:["[on|off]"]},{name:"remember",description:"Store a memory",usage:"/remember <text>",args:["<text>"],requiresArgs:!0},{name:"recall",description:"Search memories",usage:"/recall <query>",args:["<query>"],requiresArgs:!0},{name:"recall_knowledge",description:"Search learned tools (skills, procedures, techniques)",usage:"/recall_knowledge <topic>",args:["<topic>"],requiresArgs:!0},{name:"send",description:"Send a peer or same-home client message through the runtime transport",usage:"/send <peer-name|node-id|client-id> <message>",args:["<peer-name|node-id|client-id>","<message>"],requiresArgs:!0},{name:"forget",description:"Delete a memory",usage:"/forget <id>",args:["<id>"],requiresArgs:!0},{name:"memories",description:"Browse all memories",args:[]},{name:"resume",description:"Resume a previous session",args:["[session-id]"]},{name:"fork",description:"Fork the current session into a new branch",usage:"/fork [session-id] [message-count] [--stay]",args:["[session-id]","[message-count]","[--stay]"]},{name:"clear",description:"Clear the screen",args:[]},{name:"login",description:"Authenticate with provider (bedrock, anthropic, openai, google, copilot)",usage:"/login [provider] [api-key|--profile <label>|--source <gh|device>]",args:["[provider]","[api-key|flags]"]},{name:"logout",description:"Disconnect a provider or clear all credentials",usage:"/logout [provider|all]",args:["[provider|all]"]},{name:"auth",description:"Auth utilities such as importing env credentials into session scope",usage:"/auth import-env [provider ...] | /auth clear-session | /auth status-session",args:["import-env|clear-session|status-session","[provider ...]"]},{name:"help",description:"Show available commands",args:[]},{name:"daemon",description:"Open daemon control panel or run start/stop/restart",usage:"/daemon [start|stop|restart]",args:["[start|stop|restart]"]},{name:"terminal-setup",description:"Install Shift+Enter newline key binding for supported terminals",usage:"/terminal-setup",args:[]},{name:"theme",description:"View or change the color theme",usage:"/theme [name]",args:["[name]"]},{name:"invite",description:"Create an internet invite token",usage:"/invite [label]",args:["[label]"]},{name:"join",description:"Accept an internet invite token",usage:"/join [token]",args:["[token]"]},{name:"peers",description:"Show nearby peers and connect",args:[]},{name:"clients",description:"Show same-home attached clients",args:[]},{name:"exit",description:"Exit ARIA",args:[]}]});function gw0(){return"1.0.63"}var __filename="/Users/hole/aria/.bundle-stage/cli/dist/release-notes.js",lM,u60;var jh=E(()=>{lM=gw0(),u60=["\u26A1 Search millions of lines instantly with native Rust-powered code search","\uD83E\uDDE0 Jump to definitions & find references with real LSP intelligence","\u270F\uFE0F Press Esc\xD72 to edit and fork any previous message in-place","\uD83D\uDD0A Get audio cues when tasks finish \u2014 try /sound to configure","\uD83C\uDFA8 All 87 tools now render rich, beautiful output in the terminal"]});function p60($){let Z=Th.indexOf($);return Th[(Z+1)%Th.length]}function d60($,Z){let J=EF[$],X={};if(Z.showThinking!==J.showThinking)X.showThinking=Z.showThinking;if(Z.showCosts!==J.showCosts)X.showCosts=Z.showCosts;if(Z.showToolArgs!==J.showToolArgs)X.showToolArgs=Z.showToolArgs;if(Z.toolOutput!==J.toolOutput)X.toolOutput=Z.toolOutput;if(Z.showTraces!==J.showTraces)X.showTraces=Z.showTraces;if(Z.showPipelineTiming!==J.showPipelineTiming)X.showPipelineTiming=Z.showPipelineTiming;if(Z.showStatusBar!==J.showStatusBar)X.showStatusBar=Z.showStatusBar;return X}function l60($,Z){return{...EF[$],...Z??{}}}var EF,Th;var Ch=E(()=>{EF={minimal:{showThinking:!1,showCosts:!1,showToolArgs:!1,toolOutput:"hidden",showTraces:!1,showPipelineTiming:!1,showStatusBar:!1},standard:{showThinking:!0,showCosts:!0,showToolArgs:!0,toolOutput:"standard",showTraces:!1,showPipelineTiming:!1,showStatusBar:!0},debug:{showThinking:!0,showCosts:!0,showToolArgs:!0,toolOutput:"expanded",showTraces:!0,showPipelineTiming:!0,showStatusBar:!0}},Th=["minimal","standard","debug"]});function mw0($){if(!($ instanceof Error))return!1;let Z=$.message;return Z.includes("has been released")||Z.includes("aborted")}function Rh($,Z,J){if(!Z){J?.();return}Z.catch((X)=>{if(!mw0(X))P.warn(`[SessionHistoryClient] ${$} IPC failed:`,X?.message??X);if(J)try{J()}catch(Y){P.warn(`[SessionHistoryClient] ${$} local fallback also failed:`,Y?.message??Y)}})}class DH{readDb;ipc;constructor($,Z){this.readDb=$,this.ipc=Z,$.enableLowContentionMode()}withPhase($,Z){D9($);try{return Z()}finally{O9()}}listSessions(...$){return this.withPhase("session-history:listSessions",()=>this.readDb.listSessions(...$))}loadSessionMessages(...$){return this.withPhase("session-history:loadSessionMessages",()=>this.readDb.loadSessionMessages(...$))}loadSession(...$){return this.withPhase("session-history:loadSession",()=>this.readDb.loadSession(...$))}searchSessionsFts(...$){return this.withPhase("session-history:searchSessionsFts",()=>this.readDb.searchSessionsFts(...$))}searchSessionSummaries(...$){return this.withPhase("session-history:searchSessionSummaries",()=>this.readDb.searchSessionSummaries(...$))}findSessionByPrefix(...$){return this.readDb.findSessionByPrefix(...$)}getSessionRuntimeState(...$){return this.readDb.getSessionRuntimeState(...$)}getInteraction(...$){return this.readDb.getInteraction(...$)}getIncompleteSessions(...$){return this.readDb.getIncompleteSessions(...$)}getInputHistory(...$){return this.withPhase("session-history:getInputHistory",()=>this.readDb.getInputHistory(...$))}addInputHistory(...$){return this.withPhase("session-history:addInputHistory",()=>this.readDb.addInputHistory(...$))}getSessionCount(...$){return this.readDb.getSessionCount(...$)}markStaleSessionsCompleted(...$){return this.withPhase("session-history:markStaleSessionsCompleted",()=>this.readDb.markStaleSessionsCompleted(...$))}getSession(...$){return this.readDb.getSession(...$)}createSession(...$){return this.readDb.createSession(...$)}persistMessagesNonBlocking($,Z){if(Z.length===0)return;this.readDb.markSessionIncremental($),Rh("appendSessionMessages",this.ipc.appendSessionMessages?.($,Z),()=>this.readDb.addConversationMessages($,Z))}addConversationMessages($,Z){this.persistMessagesNonBlocking($,Z)}addConversationMessage($,Z){this.persistMessagesNonBlocking($,[Z])}markCompleted($){Rh("markSessionCompleted",this.ipc.markSessionCompleted?.($),()=>this.readDb.markCompleted($))}replaceConversationMessages($,Z){Rh("replaceSessionMessages",this.ipc.replaceSessionMessages?.($,Z),()=>this.readDb.replaceConversationMessages($,Z))}completeRun(...$){return this.readDb.completeRun(...$)}claimSessionForMutation(...$){return this.readDb.claimSessionForMutation(...$)}releaseSessionClaim(...$){return this.readDb.releaseSessionClaim(...$)}recordPausedRun(...$){return this.readDb.recordPausedRun(...$)}deleteSession(...$){return this.readDb.deleteSession(...$)}forkSession(...$){return this.readDb.forkSession(...$)}cancelInteraction(...$){return this.readDb.cancelInteraction(...$)}setSessionTitle(...$){return this.readDb.setSessionTitle(...$)}recordInteractionResponse(...$){return this.readDb.recordInteractionResponse(...$)}close(){this.readDb.close()}}var wh=E(()=>{S0();qV()});function cw0($){return typeof $!=="string"||$.trim().length>0}function uw0($){let{toolCalls:Z,...J}=$;return J}function pw0($,Z,J){for(let X=Z;X<$.length;X++){let Y=$[X];if(Y.role==="tool"&&Y.toolCallId===J)return!0}return!1}function aY($){let Z=[];for(let J=0;J<$.length;J++){let X=$[J];if(X.role==="assistant"&&X.toolCalls?.length){let Y=new Set(X.toolCalls.map((K)=>K.id)),Q=new Set,G=[],V=J+1;while(V<$.length&&$[V].role==="tool"){let K=$[V];if(K.toolCallId&&Y.has(K.toolCallId)&&!Q.has(K.toolCallId))Q.add(K.toolCallId),G.push(K);V++}let W=X.toolCalls.filter((K)=>{if(Q.has(K.id))return!0;return!pw0($,V,K.id)}),H=W.filter((K)=>!Q.has(K.id));if(W.length===X.toolCalls.length)Z.push(X);else if(W.length>0)Z.push({...X,toolCalls:W});else if(cw0(X.content))Z.push(uw0(X));Z.push(...G);for(let K of H)Z.push({role:"tool",content:`[Tool execution interrupted \u2014 no result for ${K.name}]`,toolCallId:K.id});J=V-1;continue}if(X.role==="tool")continue;Z.push(X)}return Z}function a60($){let Z=[];for(let J of $)for(let X of J.content)switch(X.type){case"thinking":Z.push({id:`thinking-${crypto.randomUUID()}`,role:"thinking_history",content:X.content,wordCount:X.wordCount,durationSeconds:X.durationMs!=null?X.durationMs/1000:void 0,verb:X.verb,arionName:J.arion?.name,arionEmoji:J.arion?.emoji,arionColor:J.arion?.color});break;case"tool_use":Z.push({id:`tool-${crypto.randomUUID()}`,role:"tool_history",tool:{id:X.id,name:X.name,args:X.arguments,status:"pending",startTime:void 0,endTime:void 0}});break;case"tool_result":{let Y;for(let Q=Z.length-1;Q>=0;Q--){let G=Z[Q];if(G.role==="tool_history"&&G.tool.id===X.toolUseId){Y=G;break}}if(Y){if(Y.tool.status=X.status==="error"?"error":"complete",X.status==="error")Y.tool.error=X.content;else Y.tool.result=X.content;if(X.resultData!==void 0)Y.tool.resultData=X.resultData;if(X.durationMs!==void 0)Y.tool.durationMs=X.durationMs;if(X.usage!==void 0)Y.tool.usage=X.usage}break}case"handoff":Z.push({id:`handoff-${crypto.randomUUID()}`,role:"handoff_history",target:X.target,direction:X.direction});break;case"error":Z.push({id:`error-${crypto.randomUUID()}`,role:"error",content:X.content,suggestion:X.suggestion});break;case"text":Z.push({id:`msg-${crypto.randomUUID()}`,role:J.role,content:X.text,arion:J.arion?{name:J.arion.name,emoji:J.arion.emoji,color:J.arion.color}:void 0});break}return Z}var aM=E(()=>{CR()});class AJ{textParts=[];thinkingBlocks=[];toolUseBlocks=[];handoffBlocks=[];toolResultMessages=[];seenToolIds=new Set;toolArgsAccumulator=new Map;thinkingInProgress=!1;pendingThinkingContent="";arion;verb;tokenUsage;snapshotMessages;previewAssistantId=`preview-${Date.now()}`;ingest($){switch($.type){case"text_delta":return this.textParts.push($.content),"continue";case"thinking_start":return this.thinkingInProgress=!0,this.pendingThinkingContent="","continue";case"thinking_delta":return this.pendingThinkingContent+=$.content,"continue";case"thinking_end":{this.thinkingInProgress=!1;let Z=Array.isArray($.blocks)&&$.blocks.length>0?$.blocks[0]:void 0,J=typeof Z?.thinking==="string"?Z.thinking:this.pendingThinkingContent,X=J.split(/\s+/).filter(Boolean).length,Y={type:"thinking",content:J,wordCount:X,durationMs:$.durationMs,verb:this.verb};return this.thinkingBlocks.push(Y),this.pendingThinkingContent="","continue"}case"tool_start":{if(this.seenToolIds.has($.id))return"continue";this.seenToolIds.add($.id);let Z={type:"tool_use",id:$.id,name:$.name,arguments:$.input??{}};return this.toolUseBlocks.push(Z),"continue"}case"tool_args_delta":{let J=(this.toolArgsAccumulator.get($.id)??"")+$.args;this.toolArgsAccumulator.set($.id,J);try{let X=JSON.parse(J),Y=this.toolUseBlocks.find((Q)=>Q.type==="tool_use"&&Q.id===$.id);if(Y)Y.arguments=X}catch{}return"continue"}case"tool_result":{if($.input){let Q=this.toolUseBlocks.find((G)=>G.type==="tool_use"&&G.id===$.id);if(Q){let G=typeof $.input==="object"&&!Array.isArray($.input)?$.input:{};if(Object.keys(Q.arguments).length===0)Q.arguments=G}}let Z=$.result,J="usage"in $&&$.usage&&typeof $.usage==="object"&&typeof $.usage.inputTokens==="number"&&typeof $.usage.outputTokens==="number"&&typeof $.usage.totalTokens==="number"&&typeof $.usage.estimatedCost==="number"?$.usage:void 0,X={type:"tool_result",toolUseId:$.id,content:typeof Z.message==="string"?Z.message:"",status:Z.success===!0?"success":"error",durationMs:$.durationMs,resultData:Z.data,usage:J},Y={id:crypto.randomUUID(),role:"tool",content:[X],arion:this.arion,createdAt:new Date().toISOString()};return this.toolResultMessages.push(Y),"continue"}case"handoff_start":{let Z={type:"handoff",target:$.target,direction:"to"};return this.handoffBlocks.push(Z),"continue"}case"handoff_result":{let Z={type:"handoff",target:$.target,direction:"from"};return this.handoffBlocks.push(Z),"continue"}case"turn_complete":return"flush";case"messages_snapshot":return this.snapshotMessages=$.messages,"continue";default:return"continue"}}flush(){let $=[];if(this.thinkingInProgress&&this.pendingThinkingContent){let X=this.pendingThinkingContent.trim(),Y=X.length===0?0:X.split(/\s+/).length,Q={type:"thinking",content:this.pendingThinkingContent,wordCount:Y,verb:this.verb};this.thinkingBlocks.push(Q)}let Z=[];Z.push(...this.thinkingBlocks);let J=this.textParts.join("");if(J)Z.push({type:"text",text:J});if(Z.push(...this.toolUseBlocks),Z.push(...this.handoffBlocks),Z.length>0){let X={id:crypto.randomUUID(),role:"assistant",content:Z,arion:this.arion,tokenUsage:this.tokenUsage,createdAt:new Date().toISOString()};$.push(X)}if($.push(...this.toolResultMessages),this.toolResultMessages.length>0&&this.toolUseBlocks.length>0){let X=new Set(this.toolResultMessages.flatMap((Y)=>Y.content.filter((Q)=>Q.type==="tool_result").map((Q)=>Q.toolUseId)));for(let Y of this.toolUseBlocks){let Q=Y.id;if(Q&&!X.has(Q)){let G={id:crypto.randomUUID(),role:"tool",content:[{type:"tool_result",toolUseId:Q,content:"Tool execution cancelled by user.",status:"error"}],arion:this.arion,createdAt:new Date().toISOString()};$.push(G)}}}return this.textParts=[],this.thinkingBlocks=[],this.toolUseBlocks=[],this.handoffBlocks=[],this.toolResultMessages=[],this.seenToolIds=new Set,this.toolArgsAccumulator=new Map,this.thinkingInProgress=!1,this.pendingThinkingContent="",this.tokenUsage=void 0,this.verb=void 0,this.previewAssistantId=`preview-${Date.now()}`,$}snapshot(){let $=[];if($.push(...this.thinkingBlocks.map((X)=>({...X}))),this.thinkingInProgress&&this.pendingThinkingContent){let X=this.pendingThinkingContent,Y={type:"thinking",content:X,wordCount:X.split(/\s+/).filter(Boolean).length,verb:this.verb};$.push(Y)}let Z=this.textParts.join("");if(Z){let X=Z.lastIndexOf(`
4727
+ `).length,1)},[T$,E8]),sQ=(SZ?4+c2:0)+(X1?2:0),IZ=Math.max(qO-sQ,1),_5=LJ(()=>{let N0=new Map,T0="";for(let J8 of d6){let M5=J8.kind==="user-message"||J8.kind==="user-image"?`user:${J8.userName}`:J8.kind==="assistant-text"?`assistant:${J8.arion?.name??"ARIA"}`:J8.kind==="thinking"?`assistant:${J8.arion?.name??"ARIA"}`:J8.kind==="tool-execution"?"tool":J8.kind,rQ=J8.kind==="user-message"||J8.kind==="user-image"||J8.kind==="assistant-text"||J8.kind==="thinking";if(N0.set(J8.id,rQ&&M5!==T0),rQ)T0=M5}return N0},[d6]),IT=LJ(()=>{let N0=new Map;for(let T0=0;T0<d6.length;T0++){let J8=d6[T0],M5=T0>0?d6[T0-1]:void 0,rQ=J8.kind==="tool-execution"&&M5?.kind==="tool-execution";N0.set(J8.id,T0>0&&!rQ)}return N0},[d6]),zu=LJ(()=>{let N0=[];if(X)N0.push({id:"header",_kind:"banner"});for(let T0 of iQ)N0.push({...T0,_kind:"item"});return N0},[X,iQ]);return lY(Rw0,{children:[G$(ww0,{items:zu,children:(N0)=>{if(N0._kind==="banner")return G$(K5,{width:"100%",justifyContent:"center",children:X},N0.id);return G$(K5,{flexDirection:"column",marginTop:IT.get(N0.id)?1:0,children:G$(Pq,{item:N0,displayMode:q,showPrefix:_5.get(N0.id)??!1})},N0.id)}},`static-${Y0}`),lY(K5,{flexDirection:"column",width:"100%",children:[lY(K5,{flexDirection:"column",maxHeight:qO,justifyContent:"flex-end",overflowY:"hidden",children:[oQ.length>0&&G$(K5,{flexDirection:"column",maxHeight:IZ,overflowY:"hidden",children:oQ.map((N0)=>G$(K5,{flexDirection:"column",marginTop:IT.get(N0.id)?1:0,children:G$(Pq,{item:N0,displayMode:q,showPrefix:_5.get(N0.id)??!1,previewTailLines:IZ})},N0.id))}),SZ&&lY(K5,{marginTop:1,flexDirection:"column",children:[G$(IA,{param:{type:"text",text:E8??""},userName:O??"User",columns:OO,showPrefix:!0,addMargin:!1}),G$(N2,{dimColor:!0,children:" \u2191 queued \u2014 press esc or \u2191 to cancel and edit"})]}),M&&T.length>0&&G$(zv,{spans:T}),A?.showPipelineTiming&&k&&k.phases.length>0&&G$(Uv,{report:k}),LO&&lY(K5,{flexDirection:"column",borderStyle:"round",borderColor:"gray",paddingX:1,marginY:1,children:[G$(N2,{bold:!0,dimColor:!0,children:"Hotkeys"}),G$(N2,{dimColor:!0,children:" Ctrl+\\ \u2014 cycle display mode"}),G$(N2,{dimColor:!0,children:" Ctrl+t \u2014 toggle thinking blocks"}),G$(N2,{dimColor:!0,children:" Ctrl+g \u2014 toggle cost display"}),G$(N2,{dimColor:!0,children:" Ctrl+e \u2014 cycle effort level"}),G$(N2,{dimColor:!0,children:" Ctrl+s \u2014 toggle trace waterfall"}),G$(N2,{dimColor:!0,children:" Escape \u2014 cancel streaming / close overlay / clear input"}),G$(N2,{dimColor:!0,children:" Ctrl+/ \u2014 toggle this help"})]}),X1&&G$(Fv,{state:RZ.kind==="thinking"?"thinking":"composing",elapsedSeconds:Math.floor(L?.wallTimeSeconds??0),totalTokens:L?.totalTokens??0,thoughtForSeconds:RZ.kind==="composing"?RZ.thoughtForSeconds:void 0,currentVerb:RZ.kind==="tool_running"?[...new Set(RZ.tools.values())].join(" \xB7 "):RZ.verb.present})]}),lY(K5,{flexDirection:"column",flexShrink:0,children:[D0&&_0&&L0&&G$(Hv,{currentLevel:C0??JJ.autonomy,onSelect:_0,onCancel:L0}),z$&&A0&&u0&&G$(A60,{providers:z$,onSelect:A0,onCancel:u0}),U$&&r0&&V$&&G$(eI,{options:U$,onSelect:r0,onCancel:V$}),m0==="login-method"&&zK&&KO&&vQ&&G$(UH,{options:zK,onSelect:(N0)=>KO(N0.id),onCancel:vQ,title:UK??"Choose an option:",isActive:m0==="login-method"}),m0==="login-method"&&HK&&JO&&cJ&&G$(P60,{options:HK,onSelect:JO,onCancel:cJ,isActive:m0==="login-method"}),m0==="login-input"&&hQ&&xQ&&zO&&G$(FH,{title:hQ.title,hint:hQ.hint,onSubmit:xQ,onCancel:zO,isActive:m0==="login-input"}),m0==="login-input"&&XO&&TQ&&YO&&G$(FH,{title:"Enter Anthropic API key",hint:"Paste your sk-ant-api03-* key",onSubmit:TQ,onCancel:YO,isActive:m0==="login-input"}),m0==="login-input"&&CQ&&QO&&RQ&&G$(FH,{title:"Enter setup token",hint:"From `claude setup-token` or admin provisioning",onSubmit:QO,onCancel:RQ,isActive:m0==="login-input"}),m0==="login-method"&&KK&&wQ&&GO&&G$(UH,{options:KK,onSelect:wQ,onCancel:GO,title:"Select OpenAI login method:",isActive:m0==="login-method"}),m0==="login-input"&&SQ&&VO&&IQ&&G$(FH,{title:"Enter OpenAI API key",hint:"Paste your sk-* key",onSubmit:VO,onCancel:IQ,isActive:m0==="login-input"}),m0==="login-method"&&bQ&&kQ&&WO&&G$(UH,{options:bQ,onSelect:kQ,onCancel:WO,title:"Select Google login method:",isActive:m0==="login-method"}),m0==="login-input"&&fQ&&HO&&yQ&&G$(FH,{title:"Enter Google API key",hint:"Paste your AIza* key",onSubmit:HO,onCancel:yQ,isActive:m0==="login-input"}),m0==="login"&&_$&&m$&&d4&&G$(E60,{provider:_$,onCancel:d4,...s8&&K9?{authorizeUrl:s8,expectedState:u$??void 0,onCodeSubmit:K9}:{onComplete:m$},isActive:m0==="login"}),m0==="login"&&q5&&H7&&y2&&G$(rI,{provider:q5,profileLabel:GK??void 0,...VK&&W7&&WK?{verificationUri:VK,userCode:W7,onApprove:WK}:{onComplete:H7},onCancel:y2}),lY(K5,{flexDirection:"column",children:[m0==="command"&&G$(mv,{commands:K,initialFilter:cQ,onSelect:CT,onHandOffInput:m2,onCancel:wZ}),m0==="arion"&&G$(cv,{arions:z,initialFilter:AK,statusFilter:NO,onSelect:p6,onCancel:wZ}),m0==="model"&&G$(pv,{models:U,effortLevel:V0,onSelect:RT,onCancel:wZ}),m0==="theme"&&G$(rv,{onSelect:wT,onCancel:wZ}),m0==="sound"&&G$(Dh,{onClose:()=>J$("none")}),m0==="daemon"&&G$(Oh,{status:n??{running:!1},actionStatus:K0,onAction:(N0)=>z0?.(N0),onClose:()=>J$("none")}),m0==="invite-share"&&K7&&G$(Qh,{inviteToken:K7.inviteToken,inviteLabel:K7.inviteLabel,expiresAt:K7.expiresAt,onClose:()=>{J$("none"),NT?.()}}),m0==="join-invite"&&G$(Gh,{error:LT,onSubmit:(N0)=>{J$("none"),FK?.(N0)},onCancel:()=>{J$("none"),uJ?.()}}),m0==="memory"&&G$(lv,{memories:B,mode:F,isLoading:D,onSelect:ST,onCancel:wZ}),m0==="peers"&&G$($h,{peers:dQ.length>0?dQ:v2,sameHomeClientsAvailable:UO.length>0,onSelect:(N0)=>{J$("none"),BK?.(N0)},onCancel:wZ}),m0==="clients"&&G$(Yh,{clients:UO,onSelect:(N0)=>{J$("none"),A6(`/send ${N0.clientId} `),DT?.(N0)},onCancel:()=>{J$("none"),OT?.()}}),m0==="pair-request"&&h2&&G$(Vh,{request:h2,onAccept:()=>{J$("none"),AT?.()},onReject:()=>{J$("none"),DO?.()}}),m0==="session"&&G$(nv,{sessions:C,onSelect:(N0)=>{J$("none"),f?.(N0)},onCancel:wZ,onSearch:(N0)=>l?.(N0),onPageChange:(N0)=>$0?.(N0)}),m0==="message-edit"&&x2&&G$(ov,{messages:x2,onSelect:(N0,T0)=>{J$("none"),qT?.(N0,T0)},onCancel:wZ}),m0==="none"&&!B0&&G$(aS,{userName:O,value:LK,onChange:A6,onSubmit:a,onTrigger:nQ,onExit:()=>pJ(),history:R0,onSaveInput:I0,focus:m0==="none",isStreaming:G,onDoubleEscape:()=>{if(x2&&x2.length>0)return J$("message-edit"),!0;return!1}})]}),(!A||A.showStatusBar)&&G$(OS,{arion:{name:Ku,emoji:TT,color:jT,traits:CZ?.personality?.traits?.slice(0,2)},model:Z,maxContextTokens:J,responseTime:H,metrics:L,displayMode:q,showCosts:_,activeArion:R,effortLevel:V0,autonomyLevel:C0,meshMessageCount:_T,connectionState:O0})]})]})]})}var v60=E(()=>{Nh();q60();$b();_60();tI();j60();Ah();T60();nI();oS();P1();R60();M1();G8();f60()});function h60($){let Z=!1,J=(X)=>{if(Z)return;Z=!0,$(X)};return{onAbort(){J(!1)},onAllow(X){J(!0)},onReject(){J(!1)},onDone(){queueMicrotask(()=>{if(!Z)J(!1)})}}}import{jsx as Mh,jsxs as bw0}from"react/jsx-runtime";import{useMemo as x60,useState as kw0}from"react";import{Box as fw0,useStdout as yw0}from"ink";function vw0($){let Z=bU[$.toLowerCase()];return{name:$,userFacingName(J){if(Z)return Z.displayName(J);return $},renderToolUseMessage(J,X){if(Z)return Z.renderInput(J,X);return JSON.stringify(J)},isReadOnly(){return!1},inputSchema:{parse(J){return J??{}}}}}function xw0($){switch($){case"low":return 0.2;case"moderate":return 0.5;case"high":return 0.9}}function g60($){let{stdout:Z}=yw0(),J=Z?.columns??80,[X]=kw0(!1),Y=x60(()=>{if(!$.approvalRequest)return null;return h60($.onApprovalChoice)},[$.approvalRequest,$.onApprovalChoice]),Q=x60(()=>{if(!$.approvalRequest||!Y)return null;let{toolName:G,input:V,riskLevel:W}=$.approvalRequest;return{assistantMessage:hw0,tool:vw0(G),description:`${G} requires approval`,input:V??{},commandPrefix:null,riskScore:xw0(W),onAbort:Y.onAbort,onAllow:Y.onAllow,onReject:Y.onReject}},[Y,$.approvalRequest]);if(Q&&Y)return bw0(fw0,{flexDirection:"column",width:"100%",children:[Mh(_h,{...$}),Mh(xv,{toolUseConfirm:Q,onDone:Y.onDone,verbose:X})]});return Mh(_h,{...$})}var hw0;var m60=E(()=>{v60();VF();Mq();Mq();hw0={message:{id:"aria-approval"}}});var Ph;var c60=E(()=>{Ph=[{name:"become",description:"Switch to another arion",usage:"/become <name>",args:["<name>"],requiresArgs:!0},{name:"arions",description:"List all arions",args:[]},{name:"hatch",description:"Create a new arion",usage:"/hatch <name> [description]",args:["<name>","[description]"],requiresArgs:!0},{name:"rest",description:"Put an arion to rest",usage:"/rest <name>",args:["<name>"],requiresArgs:!0},{name:"wake",description:"Wake a resting arion",usage:"/wake <name>",args:["<name>"],requiresArgs:!0},{name:"model",description:"Change or view current AI model",usage:"/model [name|list|refresh] [--provider <name>] [--use-env]",args:["[name|list|refresh]","[--provider <name>]","[--use-env]"]},{name:"autonomy",description:"Change permission approval policy",usage:"/autonomy [level]",args:["[level]"]},{name:"sound",description:"Open sound preferences or toggle notifications",usage:"/sound [on|off]",args:["[on|off]"]},{name:"remember",description:"Store a memory",usage:"/remember <text>",args:["<text>"],requiresArgs:!0},{name:"recall",description:"Search memories",usage:"/recall <query>",args:["<query>"],requiresArgs:!0},{name:"recall_knowledge",description:"Search learned tools (skills, procedures, techniques)",usage:"/recall_knowledge <topic>",args:["<topic>"],requiresArgs:!0},{name:"send",description:"Send a peer or same-home client message through the runtime transport",usage:"/send <peer-name|node-id|client-id> <message>",args:["<peer-name|node-id|client-id>","<message>"],requiresArgs:!0},{name:"forget",description:"Delete a memory",usage:"/forget <id>",args:["<id>"],requiresArgs:!0},{name:"memories",description:"Browse all memories",args:[]},{name:"resume",description:"Resume a previous session",args:["[session-id]"]},{name:"fork",description:"Fork the current session into a new branch",usage:"/fork [session-id] [message-count] [--stay]",args:["[session-id]","[message-count]","[--stay]"]},{name:"clear",description:"Clear the screen",args:[]},{name:"login",description:"Authenticate with provider (bedrock, anthropic, openai, google, copilot)",usage:"/login [provider] [api-key|--profile <label>|--source <gh|device>]",args:["[provider]","[api-key|flags]"]},{name:"logout",description:"Disconnect a provider or clear all credentials",usage:"/logout [provider|all]",args:["[provider|all]"]},{name:"auth",description:"Auth utilities such as importing env credentials into session scope",usage:"/auth import-env [provider ...] | /auth clear-session | /auth status-session",args:["import-env|clear-session|status-session","[provider ...]"]},{name:"help",description:"Show available commands",args:[]},{name:"daemon",description:"Open daemon control panel or run start/stop/restart",usage:"/daemon [start|stop|restart]",args:["[start|stop|restart]"]},{name:"terminal-setup",description:"Install Shift+Enter newline key binding for supported terminals",usage:"/terminal-setup",args:[]},{name:"theme",description:"View or change the color theme",usage:"/theme [name]",args:["[name]"]},{name:"invite",description:"Create an internet invite token",usage:"/invite [label]",args:["[label]"]},{name:"join",description:"Accept an internet invite token",usage:"/join [token]",args:["[token]"]},{name:"peers",description:"Show nearby peers and connect",args:[]},{name:"clients",description:"Show same-home attached clients",args:[]},{name:"exit",description:"Exit ARIA",args:[]}]});function gw0(){return"1.0.64"}var __filename="/Users/hole/aria/.bundle-stage/cli/dist/release-notes.js",lM,u60;var jh=E(()=>{lM=gw0(),u60=["\u26A1 Search millions of lines instantly with native Rust-powered code search","\uD83E\uDDE0 Jump to definitions & find references with real LSP intelligence","\u270F\uFE0F Press Esc\xD72 to edit and fork any previous message in-place","\uD83D\uDD0A Get audio cues when tasks finish \u2014 try /sound to configure","\uD83C\uDFA8 All 87 tools now render rich, beautiful output in the terminal"]});function p60($){let Z=Th.indexOf($);return Th[(Z+1)%Th.length]}function d60($,Z){let J=EF[$],X={};if(Z.showThinking!==J.showThinking)X.showThinking=Z.showThinking;if(Z.showCosts!==J.showCosts)X.showCosts=Z.showCosts;if(Z.showToolArgs!==J.showToolArgs)X.showToolArgs=Z.showToolArgs;if(Z.toolOutput!==J.toolOutput)X.toolOutput=Z.toolOutput;if(Z.showTraces!==J.showTraces)X.showTraces=Z.showTraces;if(Z.showPipelineTiming!==J.showPipelineTiming)X.showPipelineTiming=Z.showPipelineTiming;if(Z.showStatusBar!==J.showStatusBar)X.showStatusBar=Z.showStatusBar;return X}function l60($,Z){return{...EF[$],...Z??{}}}var EF,Th;var Ch=E(()=>{EF={minimal:{showThinking:!1,showCosts:!1,showToolArgs:!1,toolOutput:"hidden",showTraces:!1,showPipelineTiming:!1,showStatusBar:!1},standard:{showThinking:!0,showCosts:!0,showToolArgs:!0,toolOutput:"standard",showTraces:!1,showPipelineTiming:!1,showStatusBar:!0},debug:{showThinking:!0,showCosts:!0,showToolArgs:!0,toolOutput:"expanded",showTraces:!0,showPipelineTiming:!0,showStatusBar:!0}},Th=["minimal","standard","debug"]});function mw0($){if(!($ instanceof Error))return!1;let Z=$.message;return Z.includes("has been released")||Z.includes("aborted")}function Rh($,Z,J){if(!Z){J?.();return}Z.catch((X)=>{if(!mw0(X))P.warn(`[SessionHistoryClient] ${$} IPC failed:`,X?.message??X);if(J)try{J()}catch(Y){P.warn(`[SessionHistoryClient] ${$} local fallback also failed:`,Y?.message??Y)}})}class DH{readDb;ipc;constructor($,Z){this.readDb=$,this.ipc=Z,$.enableLowContentionMode()}withPhase($,Z){D9($);try{return Z()}finally{O9()}}listSessions(...$){return this.withPhase("session-history:listSessions",()=>this.readDb.listSessions(...$))}loadSessionMessages(...$){return this.withPhase("session-history:loadSessionMessages",()=>this.readDb.loadSessionMessages(...$))}loadSession(...$){return this.withPhase("session-history:loadSession",()=>this.readDb.loadSession(...$))}searchSessionsFts(...$){return this.withPhase("session-history:searchSessionsFts",()=>this.readDb.searchSessionsFts(...$))}searchSessionSummaries(...$){return this.withPhase("session-history:searchSessionSummaries",()=>this.readDb.searchSessionSummaries(...$))}findSessionByPrefix(...$){return this.readDb.findSessionByPrefix(...$)}getSessionRuntimeState(...$){return this.readDb.getSessionRuntimeState(...$)}getInteraction(...$){return this.readDb.getInteraction(...$)}getIncompleteSessions(...$){return this.readDb.getIncompleteSessions(...$)}getInputHistory(...$){return this.withPhase("session-history:getInputHistory",()=>this.readDb.getInputHistory(...$))}addInputHistory(...$){return this.withPhase("session-history:addInputHistory",()=>this.readDb.addInputHistory(...$))}getSessionCount(...$){return this.readDb.getSessionCount(...$)}markStaleSessionsCompleted(...$){return this.withPhase("session-history:markStaleSessionsCompleted",()=>this.readDb.markStaleSessionsCompleted(...$))}getSession(...$){return this.readDb.getSession(...$)}createSession(...$){return this.readDb.createSession(...$)}persistMessagesNonBlocking($,Z){if(Z.length===0)return;this.readDb.markSessionIncremental($),Rh("appendSessionMessages",this.ipc.appendSessionMessages?.($,Z),()=>this.readDb.addConversationMessages($,Z))}addConversationMessages($,Z){this.persistMessagesNonBlocking($,Z)}addConversationMessage($,Z){this.persistMessagesNonBlocking($,[Z])}markCompleted($){Rh("markSessionCompleted",this.ipc.markSessionCompleted?.($),()=>this.readDb.markCompleted($))}replaceConversationMessages($,Z){Rh("replaceSessionMessages",this.ipc.replaceSessionMessages?.($,Z),()=>this.readDb.replaceConversationMessages($,Z))}completeRun(...$){return this.readDb.completeRun(...$)}claimSessionForMutation(...$){return this.readDb.claimSessionForMutation(...$)}releaseSessionClaim(...$){return this.readDb.releaseSessionClaim(...$)}recordPausedRun(...$){return this.readDb.recordPausedRun(...$)}deleteSession(...$){return this.readDb.deleteSession(...$)}forkSession(...$){return this.readDb.forkSession(...$)}cancelInteraction(...$){return this.readDb.cancelInteraction(...$)}setSessionTitle(...$){return this.readDb.setSessionTitle(...$)}recordInteractionResponse(...$){return this.readDb.recordInteractionResponse(...$)}close(){this.readDb.close()}}var wh=E(()=>{S0();qV()});function cw0($){return typeof $!=="string"||$.trim().length>0}function uw0($){let{toolCalls:Z,...J}=$;return J}function pw0($,Z,J){for(let X=Z;X<$.length;X++){let Y=$[X];if(Y.role==="tool"&&Y.toolCallId===J)return!0}return!1}function aY($){let Z=[];for(let J=0;J<$.length;J++){let X=$[J];if(X.role==="assistant"&&X.toolCalls?.length){let Y=new Set(X.toolCalls.map((K)=>K.id)),Q=new Set,G=[],V=J+1;while(V<$.length&&$[V].role==="tool"){let K=$[V];if(K.toolCallId&&Y.has(K.toolCallId)&&!Q.has(K.toolCallId))Q.add(K.toolCallId),G.push(K);V++}let W=X.toolCalls.filter((K)=>{if(Q.has(K.id))return!0;return!pw0($,V,K.id)}),H=W.filter((K)=>!Q.has(K.id));if(W.length===X.toolCalls.length)Z.push(X);else if(W.length>0)Z.push({...X,toolCalls:W});else if(cw0(X.content))Z.push(uw0(X));Z.push(...G);for(let K of H)Z.push({role:"tool",content:`[Tool execution interrupted \u2014 no result for ${K.name}]`,toolCallId:K.id});J=V-1;continue}if(X.role==="tool")continue;Z.push(X)}return Z}function a60($){let Z=[];for(let J of $)for(let X of J.content)switch(X.type){case"thinking":Z.push({id:`thinking-${crypto.randomUUID()}`,role:"thinking_history",content:X.content,wordCount:X.wordCount,durationSeconds:X.durationMs!=null?X.durationMs/1000:void 0,verb:X.verb,arionName:J.arion?.name,arionEmoji:J.arion?.emoji,arionColor:J.arion?.color});break;case"tool_use":Z.push({id:`tool-${crypto.randomUUID()}`,role:"tool_history",tool:{id:X.id,name:X.name,args:X.arguments,status:"pending",startTime:void 0,endTime:void 0}});break;case"tool_result":{let Y;for(let Q=Z.length-1;Q>=0;Q--){let G=Z[Q];if(G.role==="tool_history"&&G.tool.id===X.toolUseId){Y=G;break}}if(Y){if(Y.tool.status=X.status==="error"?"error":"complete",X.status==="error")Y.tool.error=X.content;else Y.tool.result=X.content;if(X.resultData!==void 0)Y.tool.resultData=X.resultData;if(X.durationMs!==void 0)Y.tool.durationMs=X.durationMs;if(X.usage!==void 0)Y.tool.usage=X.usage}break}case"handoff":Z.push({id:`handoff-${crypto.randomUUID()}`,role:"handoff_history",target:X.target,direction:X.direction});break;case"error":Z.push({id:`error-${crypto.randomUUID()}`,role:"error",content:X.content,suggestion:X.suggestion});break;case"text":Z.push({id:`msg-${crypto.randomUUID()}`,role:J.role,content:X.text,arion:J.arion?{name:J.arion.name,emoji:J.arion.emoji,color:J.arion.color}:void 0});break}return Z}var aM=E(()=>{CR()});class AJ{textParts=[];thinkingBlocks=[];toolUseBlocks=[];handoffBlocks=[];toolResultMessages=[];seenToolIds=new Set;toolArgsAccumulator=new Map;thinkingInProgress=!1;pendingThinkingContent="";arion;verb;tokenUsage;snapshotMessages;previewAssistantId=`preview-${Date.now()}`;ingest($){switch($.type){case"text_delta":return this.textParts.push($.content),"continue";case"thinking_start":return this.thinkingInProgress=!0,this.pendingThinkingContent="","continue";case"thinking_delta":return this.pendingThinkingContent+=$.content,"continue";case"thinking_end":{this.thinkingInProgress=!1;let Z=Array.isArray($.blocks)&&$.blocks.length>0?$.blocks[0]:void 0,J=typeof Z?.thinking==="string"?Z.thinking:this.pendingThinkingContent,X=J.split(/\s+/).filter(Boolean).length,Y={type:"thinking",content:J,wordCount:X,durationMs:$.durationMs,verb:this.verb};return this.thinkingBlocks.push(Y),this.pendingThinkingContent="","continue"}case"tool_start":{if(this.seenToolIds.has($.id))return"continue";this.seenToolIds.add($.id);let Z={type:"tool_use",id:$.id,name:$.name,arguments:$.input??{}};return this.toolUseBlocks.push(Z),"continue"}case"tool_args_delta":{let J=(this.toolArgsAccumulator.get($.id)??"")+$.args;this.toolArgsAccumulator.set($.id,J);try{let X=JSON.parse(J),Y=this.toolUseBlocks.find((Q)=>Q.type==="tool_use"&&Q.id===$.id);if(Y)Y.arguments=X}catch{}return"continue"}case"tool_result":{if($.input){let Q=this.toolUseBlocks.find((G)=>G.type==="tool_use"&&G.id===$.id);if(Q){let G=typeof $.input==="object"&&!Array.isArray($.input)?$.input:{};if(Object.keys(Q.arguments).length===0)Q.arguments=G}}let Z=$.result,J="usage"in $&&$.usage&&typeof $.usage==="object"&&typeof $.usage.inputTokens==="number"&&typeof $.usage.outputTokens==="number"&&typeof $.usage.totalTokens==="number"&&typeof $.usage.estimatedCost==="number"?$.usage:void 0,X={type:"tool_result",toolUseId:$.id,content:typeof Z.message==="string"?Z.message:"",status:Z.success===!0?"success":"error",durationMs:$.durationMs,resultData:Z.data,usage:J},Y={id:crypto.randomUUID(),role:"tool",content:[X],arion:this.arion,createdAt:new Date().toISOString()};return this.toolResultMessages.push(Y),"continue"}case"handoff_start":{let Z={type:"handoff",target:$.target,direction:"to"};return this.handoffBlocks.push(Z),"continue"}case"handoff_result":{let Z={type:"handoff",target:$.target,direction:"from"};return this.handoffBlocks.push(Z),"continue"}case"turn_complete":return"flush";case"messages_snapshot":return this.snapshotMessages=$.messages,"continue";default:return"continue"}}flush(){let $=[];if(this.thinkingInProgress&&this.pendingThinkingContent){let X=this.pendingThinkingContent.trim(),Y=X.length===0?0:X.split(/\s+/).length,Q={type:"thinking",content:this.pendingThinkingContent,wordCount:Y,verb:this.verb};this.thinkingBlocks.push(Q)}let Z=[];Z.push(...this.thinkingBlocks);let J=this.textParts.join("");if(J)Z.push({type:"text",text:J});if(Z.push(...this.toolUseBlocks),Z.push(...this.handoffBlocks),Z.length>0){let X={id:crypto.randomUUID(),role:"assistant",content:Z,arion:this.arion,tokenUsage:this.tokenUsage,createdAt:new Date().toISOString()};$.push(X)}if($.push(...this.toolResultMessages),this.toolResultMessages.length>0&&this.toolUseBlocks.length>0){let X=new Set(this.toolResultMessages.flatMap((Y)=>Y.content.filter((Q)=>Q.type==="tool_result").map((Q)=>Q.toolUseId)));for(let Y of this.toolUseBlocks){let Q=Y.id;if(Q&&!X.has(Q)){let G={id:crypto.randomUUID(),role:"tool",content:[{type:"tool_result",toolUseId:Q,content:"Tool execution cancelled by user.",status:"error"}],arion:this.arion,createdAt:new Date().toISOString()};$.push(G)}}}return this.textParts=[],this.thinkingBlocks=[],this.toolUseBlocks=[],this.handoffBlocks=[],this.toolResultMessages=[],this.seenToolIds=new Set,this.toolArgsAccumulator=new Map,this.thinkingInProgress=!1,this.pendingThinkingContent="",this.tokenUsage=void 0,this.verb=void 0,this.previewAssistantId=`preview-${Date.now()}`,$}snapshot(){let $=[];if($.push(...this.thinkingBlocks.map((X)=>({...X}))),this.thinkingInProgress&&this.pendingThinkingContent){let X=this.pendingThinkingContent,Y={type:"thinking",content:X,wordCount:X.split(/\s+/).filter(Boolean).length,verb:this.verb};$.push(Y)}let Z=this.textParts.join("");if(Z){let X=Z.lastIndexOf(`
4728
4728
  `);if(X>=0)$.push({type:"text",text:Z.slice(0,X+1)})}for(let X of this.toolUseBlocks){let Y={...X};if(Y.type==="tool_use"&&Object.keys(Y.arguments).length===0){let Q=this.toolArgsAccumulator.get(Y.id);if(Q){let G=AJ.tryParsePartialArgs(Q);if(G)Y.arguments=G}}$.push(Y)}$.push(...this.handoffBlocks.map((X)=>({...X})));let J=[];if($.length>0)J.push({id:this.previewAssistantId,role:"assistant",content:$,arion:this.arion,createdAt:new Date().toISOString()});return J.push(...this.toolResultMessages.map((X)=>({...X,content:[...X.content]}))),J}getSnapshotMessages(){return this.snapshotMessages}hasPendingContent(){return this.textParts.length>0||this.thinkingBlocks.length>0||this.toolUseBlocks.length>0||this.handoffBlocks.length>0||this.toolResultMessages.length>0||this.thinkingInProgress}setArion($){this.arion=$}setVerb($){this.verb=$}setTokenUsage($){if(this.tokenUsage)this.tokenUsage={input:this.tokenUsage.input+$.input,output:this.tokenUsage.output+$.output};else this.tokenUsage={...$}}static tryParsePartialArgs($){let Z=$.trim();if(!Z.startsWith("{")||Z.length<4)return;try{return JSON.parse(Z)}catch{}try{let J=JSON.parse(Z+"}");if(Object.keys(J).length>0)return J}catch{}try{let J=JSON.parse(Z+'"}');if(Object.keys(J).length>0)return J}catch{}for(let J=Z.length-1;J>0;J--)if(Z[J]===",")try{let X=JSON.parse(Z.slice(0,J)+"}");if(Object.keys(X).length>0)return X}catch{}return}}import{readFileSync as dw0,existsSync as Sh}from"fs";function Ih($){if(!Sh($))return[];let J=dw0($,"utf-8").split(`
4729
4729
  `).filter((Q)=>Q.trim().length>0),X=new AJ,Y=[];for(let Q of J){let G;try{G=JSON.parse(Q)}catch{continue}if(!G.event||typeof G.event.type!=="string")continue;if(G.event.type==="user_message"){if(X.hasPendingContent())Y.push(...X.flush());let W=G.event.content??"",H=G.event.id,K=cG(W);if(H)K.id=H;Y.push(K);continue}if(X.ingest(G.event)==="flush"){let W=X.flush();Y.push(...W)}}if(X.hasPendingContent()){let Q=X.flush();Y.push(...Q)}return Y}function n60($){for(let J of $.content){if(J.type==="tool_use"&&J.id)return`tool_use:${J.id}`;if(J.type==="tool_result"&&J.toolUseId)return`tool_result:${J.toolUseId}`}let Z=$.content.filter((J)=>J.type==="text").map((J)=>J.text).join("");return`${$.role}:${Z}`}function nM($,Z){if(!Z)return{messages:$,backfillMessages:[]};let J;try{J=Ih(Z)}catch{return{messages:$,backfillMessages:[]}}if(J.length===0)return{messages:$,backfillMessages:[]};if($.length>=J.length)return{messages:$,backfillMessages:[]};let X=new Set($.map(n60)),Y=[];for(let G of J){let V=n60(G);if(!X.has(V))Y.push(G)}return{messages:[...$,...Y],backfillMessages:Y}}function iM($,Z,J){let X=`${$}/arions/${Z}/logs/${J}.jsonl`;if(Sh(X))return X;let Y=`${$}/logs/${J}.jsonl`;if(Sh(Y))return Y;return null}var i60=E(()=>{aM()});var bh={};A$(bh,{toModelMessages:()=>OL,replaySessionFromJsonl:()=>Ih,repairToolCallPairing:()=>aY,mergeWithJsonlRecovery:()=>nM,fromV1Columns:()=>pG,fromModelMessages:()=>uG,findJsonlForSession:()=>iM,extractToolCalls:()=>lG,extractToolCallId:()=>nG,extractThinking:()=>aG,extractTextContent:()=>dG,createUserMessage:()=>cG,createSystemMessage:()=>l0,createIncomingMessagePair:()=>DL,createErrorMessage:()=>Y$,conversationMessageToHistoryMessages:()=>a60,TurnAccumulator:()=>AJ,SessionHistoryClient:()=>DH,SessionHistory:()=>Z6,ConversationMessageSchema:()=>FL,ContentBlockSchema:()=>_d,ArionRefSchema:()=>Pd});var nY=E(()=>{IR();wh();aM();i60()});import{existsSync as lw0}from"fs";import{fileURLToPath as o60}from"url";function aw0(){return[o60(new URL("../main.ts",import.meta.url)),o60(new URL("../main.js",import.meta.url))]}function kh(){let $=process.env.ARIA_RUNTIME_KIND?.trim();if($==="source-bun"||$==="compiled-bun"||$==="bundled-bun")return $;let Z=process.argv[1]??"";if(!Z.endsWith(".ts")&&!Z.endsWith(".js")&&!Z.endsWith(".mjs"))return"compiled-bun";if(aw0().some((J)=>lw0(J)))return"source-bun";return"bundled-bun"}function s60(){return kh()==="compiled-bun"}var fh=()=>{};import{existsSync as yh}from"fs";import{fileURLToPath as oM}from"url";function r60(){return process.platform==="win32"?"bun.exe":"bun"}function nw0(){let $=[oM(new URL("../main.ts",import.meta.url)),oM(new URL("../main.js",import.meta.url))];for(let Z of $)if(yh(Z))return Z;throw Error("[aria] Could not resolve Bun source entrypoint for internal relaunch")}function iw0(){let $=process.argv[1]??"";if(yh($))return $;let Z=[oM(new URL("../../bin/aria.mjs",import.meta.url)),oM(new URL("../bin/aria.mjs",import.meta.url))];for(let J of Z)if(yh(J))return J;throw Error("[aria] Could not resolve bundled entrypoint for internal relaunch")}function sM($){let Z=kh(),J=$.args??[],X={...process.env,...$.env??{}},Y=$.cwd??process.cwd();switch(Z){case"source-bun":return{command:r60(),args:[nw0(),"__internal",$.mode,...J],env:X,cwd:Y};case"bundled-bun":return{command:r60(),args:[iw0(),"__internal",$.mode,...J],env:X,cwd:Y};case"compiled-bun":return{command:process.execPath,args:["__internal",$.mode,...J],env:X,cwd:Y}}}var vh=E(()=>{fh()});function rM($,Z={}){let J={},X={cwd:$.cwd,env:$.env,stdio:Z.stdio??["inherit","inherit","inherit"]};if(Z.ipc)X.ipc=(Q)=>{for(let G of J.message??[])G(Q)};let Y=Bun.spawn([$.command,...$.args],X);return Y.exited.then((Q)=>{for(let G of J.close??[])G(Q)}).catch((Q)=>{let G=Q instanceof Error?Q:Error(String(Q));for(let V of J.error??[])V(G)}),{send(Q){Y.send(Q)},on(Q,G){(J[Q]??=[]).push(G)},unref(){Y.unref()}}}import{existsSync as MF,mkdirSync as ow0,readFileSync as $Z0,writeFileSync as sw0,unlinkSync as hh,readdirSync as rw0}from"fs";import{dirname as NT$,join as gh,resolve as LT$}from"path";function ZZ0($){Zz($)}function tw0($){return $R($)}function tM($){ZR($)}function ew0($){if(!$||typeof $!=="object")return!1;let Z=$;return Z.code==="EPIPE"||Z.code==="EIO"||Z.code==="ERR_STREAM_DESTROYED"}function i1($){try{process.stderr.write($)}catch(Z){if(ew0(Z))return;throw Z}}function $S0($){if(!$||typeof $!=="object")return $ instanceof Error&&/^exit:\d+$/.test($.message);if($.__ariaProcessExit===!0)return!0;return $ instanceof Error&&/^exit:\d+$/.test($.message)}function qJ($){let Z=$?.trim()||null;if(x8=Z,Z)process.env[P4]=Z;else delete process.env[P4]}function mh(){return x8}function OH($){o1=$||"ARIA",process.env[$3]=o1}function JZ0(){return process.env[$z]==="true"}function XZ0(...$){return gh(x9(),...$)}function YZ0(){return XZ0("crash-markers")}function ch($){return gh(YZ0(),`${$}.json`)}function JS0($){let Z=ch($);if(!MF(Z))return null;try{return JSON.parse($Z0(Z,"utf-8"))}catch{return null}}function XS0($){try{let Z=YZ0();ow0(Z,{recursive:!0}),sw0(ch($.sessionId),JSON.stringify($),"utf-8")}catch{}}function xh($){try{let Z=ch($);if(MF(Z))hh(Z)}catch{}}function YS0(){return XZ0("crash-reports","latest.json")}function t60($,Z){i1(`[aria] Session ${$} exceeded crash limit (${Z}/${_F}). Starting fresh instead of resuming.
4730
4730
  `),xh($),x8=null,qJ(null)}function QS0(){let $=YS0();if(!MF($))return null;try{let Z=JSON.parse($Z0($,"utf-8"));try{hh($)}catch{}return{message:Z?.error?.message??"unknown",stack:Z?.error?.stack??void 0,heapMb:Z?.process?.heapUsedMb,rssMb:Z?.process?.rssMb}}catch{try{hh($)}catch{}return null}}async function e60($){let Z=tw0(process.pid);if(Z){if(Date.now()-new Date(Z.timestamp).getTime()<ZS0)return tM(process.pid),{sessionId:Z.sessionId,arionName:Z.arionName||$,source:"marker"};tM(process.pid)}try{let{SessionHistory:J}=await Promise.resolve().then(() => (nY(),bh)),{getAriaDir:X}=await Promise.resolve().then(() => (Y4(),MA)),Y=X(),Q=new Set([$]),G=gh(Y,"arions");if(MF(G)){for(let W of rw0(G,{withFileTypes:!0}))if(W.isDirectory()&&W.name.trim())Q.add(W.name.trim())}let V=null;for(let W of Q){let H=J.resolvePerArionPath(Y,W);if(!MF(H))continue;let K=new J(H);try{let z=K.getIncompleteSessions(1);if(z.length===0)continue;let U=z[0],B=U.updatedAt.getTime();if(!V||B>V.updatedAtMs||B===V.updatedAtMs&&W===$)V={sessionId:U.id,arionName:W,updatedAtMs:B}}finally{K.close()}}if(V)return{sessionId:V.sessionId,arionName:V.arionName,source:V.arionName===$?"history":"history-scan"}}catch(J){i1(`[aria] SessionHistory fallback failed: ${J instanceof Error?J.message:String(J)}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aria-cli/cli",
3
- "version": "1.0.63",
3
+ "version": "1.0.64",
4
4
  "description": "ARIA - Adaptive Reasoning Intelligence Agent",
5
5
  "type": "module",
6
6
  "bin": {
@@ -57,9 +57,9 @@
57
57
  "@aws-sdk/client-bedrock": "^3.997.0",
58
58
  "@aws-sdk/client-bedrock-runtime": "^3.997.0",
59
59
  "@aws-sdk/token-providers": "^3.997.0",
60
- "@aria-cli/fastripgrep": "1.0.63",
61
- "@aria-cli/wireguard": "1.0.63",
62
- "@aria-cli/search": "1.0.63"
60
+ "@aria-cli/fastripgrep": "1.0.64",
61
+ "@aria-cli/wireguard": "1.0.64",
62
+ "@aria-cli/search": "1.0.64"
63
63
  },
64
64
  "license": "MIT"
65
65
  }