@aria-cli/cli 1.0.67 → 1.0.68

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:PK,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 tK($){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 zp(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 pN($.runtimeSocket,"streamRun",P8.parse(X),(Q)=>E6.parse(Q),Y)},subscribeRuntimeEvents(X){return pN($.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 Hp(()=>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 Hp(()=>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",s6.parse(X),(Y)=>r6.parse(Y))},async invitePeer(X){return P$($.runtimeSocket,"invitePeer",r4.parse(X),(Y)=>o6.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)=>t6.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 eK($){let Z=e6.parse($.auth);return{...tK({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 zp(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 pN($.runtimeSocket,"streamRun",P8.parse(Y),(G)=>E6.parse(G),Q,Z)},async listAttachedClients(){return P$($.runtimeSocket,"listAttachedClients",void 0,(Y)=>fZ.array().parse(Y),Z)},listDirectClientInbox:async(Y)=>P$($.runtimeSocket,"listDirectClientInbox",r9.optional().parse(Y),(Q)=>m8.array().parse(Q),Z),subscribeDirectClientInbox(Y){return pN($.runtimeSocket,"subscribeDirectClientInbox",_7.optional().parse(Y),(Q)=>m8.parse(Q),void 0,Z)}}}var Up=E(()=>{V8()});var _G="x-aria-local-client-id",MG="x-aria-local-client-proof";import{existsSync as Bp}from"fs";import{createRequire as rG0}from"module";import{join as tG0}from"path";function Dp(){return aC("bun:sqlite")}function Op(){let $=process.env.ARIA_BUN_CUSTOM_SQLITE_PATH?.trim();if($)return Bp($)?$:null;if(process.platform==="darwin"){let J=["/opt/homebrew/opt/sqlite/lib/libsqlite3.dylib","/usr/local/opt/sqlite/lib/libsqlite3.dylib"].find((X)=>Bp(X));if(J)return J}return null}function nC(){let $=globalThis,Z=$[Fp];if(Z&&typeof Z==="object")return Z;let J={attempted:!1};return $[Fp]=J,J}function Np(){let $=nC();if($.attempted)return;$.attempted=!0;let Z=Op();if(!Z)return;Dp().Database.setCustomSQLite?.(Z),$.customPath=Z}function PG(){Np()}function Lp($){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 Lp($.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=Dp()}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)}`)}Np();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 Lp($.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 dN(){return Op()}function lN(){return nC().customPath}var aC,Fp="__ARIA_BUN_SQLITE_CONFIG_STATE__";var iC=E(()=>{aC=rG0(tG0(process.cwd(),"__aria_module_loader__.js"))});import Ap from"fs";import GV0 from"os";import qp from"path";function Ep($="test.db"){let Z=Ap.mkdtempSync(qp.join(GV0.tmpdir(),"aria-sqlite-test-")),J=qp.join(Z,$),X=j7({path:J});return{db:X,dbPath:J,tempDir:Z,cleanup(){try{X.close()}catch{}Ap.rmSync(Z,{recursive:!0,force:!0})}}}var _p=E(()=>{iC()});var Mp={};A$(Mp,{openCompatSqliteDatabase:()=>j7,openBunRuntimeSqliteDatabase:()=>P7,getResolvedBunCustomSqlitePath:()=>dN,getConfiguredBunCustomSqlitePath:()=>lN,createTestDatabase:()=>Ep,configureBunCustomSqlite:()=>PG});var jG=E(()=>{iC();_p()});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 Pp=()=>{};import{EventEmitter as WV0}from"events";import{randomUUID as HV0}from"crypto";var FX;var oC=E(()=>{FX=class FX 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 jp($=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.67",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 FX}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 FX,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:{...jp(),...jp(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 jp($=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.68",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 FX}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 FX,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:{...jp(),...jp(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 x90=E(()=>{V8()});var G8=E(()=>{nB();J_();nB();nB();nB();g80();o80();VM();oy();GM();sy();k90();ry();zM();Jv();Xv();Yv();OM();Fy();Ny();Gv();Vv();v90();Nf();FM();Wv();x90();e_();z_();V_();b0();p80();hy();B90()});import{jsx as VJ,jsxs as qM}from"react/jsx-runtime";import{useState as vT0,useRef as m90}from"react";import{Box as QF,Text as bY,useInput as hT0}from"ink";function Hv({currentLevel:$,onSelect:Z,onCancel:J,isActive:X=!0}){let Y=e(),Q=oZ.indexOf($),G=Q>=0?Q:0,[V,W]=vT0(G),H=m90(G),K=m90(!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(oZ.length-1,D+1));else if(F.return)K.current=!0,Z(oZ[H.current]);else if(W$(B,F))K.current=!0,J()},{isActive:X&&U}),qM(QF,{flexDirection:"column",borderStyle:"round",borderColor:Y.colors.secondary,paddingX:1,paddingY:1,width:48,children:[VJ(QF,{marginBottom:1,children:VJ(bY,{bold:!0,children:"Autonomy Level"})}),VJ(QF,{marginBottom:1,children:qM(bY,{children:["Current: ",VJ(bY,{bold:!0,children:$})]})}),oZ.map((B,F)=>{let D=F===V,O=D?"\u25CF":"\u25CB",L=B==="high"||B==="full";return qM(QF,{gap:1,children:[VJ(bY,{color:D?Y.colors.primary:void 0,children:O}),VJ(bY,{color:D?Y.colors.primary:L?Y.colors.warning:void 0,bold:D,children:B.padEnd(10)}),VJ(bY,{color:Y.colors.textMuted,children:xT0[B]})]},B)}),VJ(QF,{marginTop:1,children:qM(bY,{color:Y.colors.textMuted,children:["\u2191\u2193"," Navigate Enter Select Esc Cancel"]})})]})}var xT0;var c90=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 u90=E(()=>{E0()});import{jsx as kY,jsxs as EM}from"react/jsx-runtime";import{Box as _M,Text as fY}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 p90($,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 kY(_M,{children:kY(fY,{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 kY(_M,{flexDirection:"column",children:Q.map((K)=>EM(fY,{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 kY(_M,{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=p90(X,D,O),q=cT0(K.durationMs),A=K.spanType==="tool_execution"&&K.name?` (${K.name})`:"";return EM(_M,{children:[EM(fY,{color:J.colors.textMuted,children:[" ",F]}),kY(fY,{children:" "}),kY(fY,{color:z?J.colors.info:J.colors.success,children:L}),kY(fY,{children:" "}),EM(fY,{dimColor:!0,children:[q,A]})]},K.spanId)})})}var gT0=1,mT0=20,Kv;var d90=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 l90,Text as MM}from"ink";function a90($){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(l90,{flexDirection:"column",marginTop:1,children:[eW(MM,{color:Z.colors.textMuted,children:[" Pipeline timing (",a90($.totalMs),")"]}),$.phases.map((J)=>eW(l90,{children:[eW(MM,{color:Z.colors.info,children:[" ",J.phase.padEnd(24)]}),eW(MM,{color:Z.colors.text,children:[" ",a90(J.durationMs)]}),eW(MM,{color:Z.colors.textMuted,children:[" (",J.pct,"%)"]})]},`${J.phase}:${J.durationMs}`))]})}var n90=E(()=>{E0()});import{jsxs as i90,jsx as uT0}from"react/jsx-runtime";import{useRef as pT0}from"react";import{Box as dT0,Text as o90}from"ink";import lT0 from"gradient-string";function r90($){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=[...s90,...[...s90].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=r90(Z),O=aT0(J),L;if($==="thinking")L="(thinking)";else if(X&&X>0)L=`(${D} \xB7 \u2193 ${O} \xB7 thought for ${r90(X)})`;else L=`(${D} \xB7 \u2193 ${O} \xB7 esc to cancel)`;return i90(dT0,{flexDirection:"row",marginTop:1,children:[i90(o90,{children:[F," "]}),uT0(o90,{color:H.colors.textMuted,children:L})]})}var Bv,s90;var t90=E(()=>{E0();_V();Bv=["#5f97cd","#7baed4","#97c4db","#7baed4"],s90=process.platform==="darwin"?["\xB7","\u2722","\u2733","\u2217","\u273B","\u273D"]:["\xB7","\u2722","*","\u2217","\u273B","\u273D"]});import{jsxs as $40,jsx as e90}from"react/jsx-runtime";import{Box as nT0,Text as Z40}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 $40(Z40,{color:J5($),children:["Risk: ",Z]})}function c1({title:$,riskScore:Z}){return $40(nT0,{flexDirection:"column",children:[e90(Z40,{bold:!0,color:e().colors.primary,children:$}),Z!==null&&e90(oT0,{riskScore:Z})]})}var yY=E(()=>{E0()});function X5($,Z){}import{structuredPatch as sT0}from"diff";function PM($,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 jM,jsxs as rT0}from"react/jsx-runtime";import{existsSync as tT0,readFileSync as eT0}from"fs";import{useMemo as J40}from"react";import{Box as Nv,Text as $C0}from"ink";import{relative as ZC0}from"path";function X40({file_path:$,new_string:Z,old_string:J,verbose:X,useBorder:Y=!0,width:Q}){let G=J40(()=>tT0($)?eT0($,"utf8"):"",[$]),V=J40(()=>{let W=G.replace(J,Z);return PM($,G,W)},[$,G,J,Z]);return jM(Nv,{flexDirection:"column",children:rT0(Nv,{borderColor:e().colors.secondary,borderStyle:Y?"round":void 0,flexDirection:"column",paddingX:1,children:[jM(Nv,{paddingBottom:1,children:jM($C0,{bold:!0,children:X?$:ZC0(process.cwd(),$)})}),jM(vX,{diff:V,dim:!1,width:Q,showHeader:!1})]})})}var Y40=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 Q40({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 G40=E(()=>{E0()});var TM;var V40=E(()=>{WJ();TM=class TM 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}),W40=({visibleOptionCount:$,defaultValue:Z,options:J})=>{let X=Mv(J),Y=typeof $==="number"?Math.min($,X.length):X.length,Q=new TM(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}},H40=({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},W40),[H,K]=KC0(G);if(G!==H&&!VC0(G,H))W({type:"reset",state:W40({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 K40=E(()=>{V40()});import{useInput as UC0}from"ink";var z40=({isDisabled:$=!1,state:Z})=>{UC0((J,X)=>{if(X.downArrow)Z.focusNextOption();if(X.upArrow)Z.focusPreviousOption();if(X.return)Z.selectFocusedOption()},{isActive:!$})};var U40=()=>{};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=H40({visibleOptionCount:Z,options:X,defaultValue:Y,onChange:Q,onFocus:G,focusValue:V});z40({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(Q40,{isFocused:U,isSelected:B,smallPointer:F,children:O},z)})})}var qv=($)=>`HEADER-${$.optionValues.join(",")}`;var WJ=E(()=>{G40();K40();U40();E0()});import{jsx as CM,jsxs as jv}from"react/jsx-runtime";import{Box as B40,Text as F40}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 D40({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(B40,{flexDirection:"column",borderStyle:"round",borderColor:J5($.riskScore),marginTop:1,paddingLeft:1,paddingRight:1,paddingBottom:1,children:[CM(c1,{title:"Edit file",riskScore:$.riskScore}),CM(X40,{file_path:Y,new_string:Q,old_string:G,verbose:J,width:X-12}),jv(B40,{flexDirection:"column",children:[jv(F40,{children:["Do you want to make this edit to ",CM(F40,{bold:!0,children:LC0(Y)}),"?"]}),CM(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 O40=E(()=>{E0();yY();Y40();P1();WJ()});import GF 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 N40({toolUseConfirm:$,command:Z}){let J=!jC0(Z)&&$.commandPrefix&&!$.commandPrefix.commandInjectionDetected,X=VF($),Y=J&&X!==null,Q=[];if(Y)Q=[{label:`Yes, and don't ask again for ${GF.bold(X)} commands in ${GF.bold(process.cwd())}`,value:"yes-dont-ask-again-prefix"}];else if(J)Q=[{label:`Yes, and don't ask again for ${GF.bold(Z)} commands in ${GF.bold(process.cwd())}`,value:"yes-dont-ask-again-full"}];return[{label:"Yes",value:"yes"},...Q,{label:`No, and provide instructions (${GF.bold.hex(e().colors.warning)("esc")})`,value:"no"}]}var L40=E(()=>{WF();E0()});import{jsx as HF,jsxs as Cv}from"react/jsx-runtime";import{Box as Rv,Text as wv}from"ink";import{useMemo as TC0}from"react";function A40({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:[HF(c1,{title:"Bash command",riskScore:$.riskScore}),Cv(Rv,{flexDirection:"column",paddingX:2,paddingY:1,children:[HF(wv,{children:$.tool.renderToolUseMessage({command:X},{verbose:!1})}),HF(wv,{color:J.colors.textMuted,children:$.description})]}),Cv(Rv,{flexDirection:"column",children:[HF(wv,{children:"Do you want to proceed?"}),HF(u1,{options:N40({toolUseConfirm:$,command:X}),onChange:(Q)=>{switch(Q){case"yes":$.onAllow("temporary"),Z();break;case"yes-dont-ask-again-prefix":{if(VF($)!==null)$.onAllow("permanent");else $.onAllow("temporary");Z();break}case"yes-dont-ask-again-full":$.onAllow("permanent"),Z();break;case"no":$.onReject(),Z();break}}})]})]})}var q40=E(()=>{E0();WF();yY();WJ();L40()});import{jsx as KF,jsxs as RM}from"react/jsx-runtime";import{Box as Sv,Text as wM}from"ink";import{useMemo as CC0}from"react";import Iv from"chalk";function SM({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),RM(Sv,{flexDirection:"column",borderStyle:"round",borderColor:J5($.riskScore),marginTop:1,paddingLeft:1,paddingRight:1,paddingBottom:1,children:[KF(c1,{title:"Tool use",riskScore:$.riskScore}),RM(Sv,{flexDirection:"column",paddingX:2,paddingY:1,children:[RM(wM,{children:[Q,"(",$.tool.renderToolUseMessage($.input,{verbose:J}),")",Y.endsWith(" (MCP)")?KF(wM,{color:X.colors.textMuted,children:" (MCP)"}):""]}),KF(wM,{color:X.colors.textMuted,children:$.description})]}),RM(Sv,{flexDirection:"column",children:[KF(wM,{children:"Do you want to proceed?"}),KF(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();yY();WJ()});import{jsx as IM,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 E40,Text as IC0}from"ink";import{extname as bC0,relative as kC0}from"path";function _40({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 PM($,Q,Z)},[Y,$,Q,Z]);return RC0(E40,{borderColor:e().colors.secondary,borderStyle:"round",flexDirection:"column",paddingX:1,children:[IM(E40,{paddingBottom:1,children:IM(IC0,{bold:!0,children:J?$:kC0(process.cwd(),$)})}),G?IM(vX,{diff:G,dim:!1,width:X,showHeader:!1}):IM(C1,{code:Z||"(No content)",language:bC0($).slice(1)})]})}var M40=E(()=>{CV();E0();wV();Ov()});import{jsx as zF,jsxs as fv}from"react/jsx-runtime";import{Box as yv,Text as P40}from"ink";import{useMemo as j40}from"react";import{basename as fC0,extname as yC0}from"path";import{existsSync as vC0}from"fs";import hC0 from"chalk";function T40({toolUseConfirm:$,onDone:Z,verbose:J}){let{file_path:X,content:Y}=$.input,Q=j40(()=>vC0(X),[X]),G=j40(()=>({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:[zF(c1,{title:`${Q?"Edit":"Create"} file`,riskScore:$.riskScore}),zF(yv,{flexDirection:"column",children:zF(_40,{file_path:X,content:Y,verbose:J,width:V-12})}),fv(yv,{flexDirection:"column",children:[fv(P40,{children:["Do you want to ",Q?"make this edit to":"create"," ",zF(P40,{bold:!0,children:fC0(X)}),"?"]}),zF(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 C40=E(()=>{E0();yY();M40();P1();WJ()});import{jsx as $H,jsxs as vv}from"react/jsx-runtime";import{Box as hv,Text as R40}from"ink";import{useMemo as gC0}from"react";import mC0 from"chalk";import{isAbsolute as cC0,resolve as w40}from"path";function bM($){return cC0($)?w40($):w40(process.cwd(),$)}function uC0($){return bM($).startsWith(bM(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 bM(J[Z]);else return bM(process.cwd());return null}function S40({toolUseConfirm:$,onDone:Z,verbose:J}){let X=rC0($);if(!X)return $H(SM,{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(R40,{children:[Y,"(",$.tool.renderToolUseMessage($.input,{verbose:X}),")"]})}),vv(hv,{flexDirection:"column",children:[$H(R40,{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 I40=E(()=>{E0();yY();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 b40 from"react";function GR0($){if(JR0.has($))return D40;if(XR0.has($))return T40;if(YR0.has($))return A40;if(QR0.has($))return S40;return SM}function VF($){return $.commandPrefix&&!$.commandPrefix.commandInjectionDetected&&$.commandPrefix.commandPrefix||null}function xv({toolUseConfirm:$,onDone:Z,verbose:J}){let X=b40.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 WF=E(()=>{O40();q40();bv();C40();I40();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 kM,jsxs as ZH}from"react/jsx-runtime";import{useState as k40,useEffect as f40}from"react";import{Box as fM,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]=k40(0),[V,W]=k40(Z),H=WR0(V).toLowerCase(),K=$.filter((B)=>B.name.toLowerCase().includes(H));f40(()=>{G((B)=>Math.min(B,Math.max(0,K.length-1)))},[K.length]),f40(()=>{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(fM,{flexDirection:"column",borderStyle:"round",borderColor:"gray",paddingX:1,children:[ZH(fM,{marginBottom:1,children:[kM(JH,{bold:!0,children:"Commands"}),V&&ZH(JH,{dimColor:!0,children:[" /",V]})]}),K.map((B,F)=>ZH(fM,{children:[ZH(JH,{inverse:F===z,children:["/",B.name]}),ZH(JH,{dimColor:!0,children:[" ",B.description]})]},B.name)),K.length===0&&kM(JH,{dimColor:!0,children:"No matching commands"}),kM(fM,{marginTop:1,children:kM(JH,{dimColor:!0,children:"\u2191\u2193 navigate \u23CE select esc cancel"})})]})}var y40=()=>{};import{jsx as UF,jsxs as XH}from"react/jsx-runtime";import{useState as v40,useEffect as HR0}from"react";import{Box as yM,Text as vY,useInput as KR0}from"ink";function cv({arions:$,initialFilter:Z="",statusFilter:J="all",onSelect:X,onCancel:Y}){let[Q,G]=v40(0),[V,W]=v40(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(yM,{flexDirection:"column",borderStyle:"round",borderColor:"gray",paddingX:1,children:[XH(yM,{marginBottom:1,children:[UF(vY,{bold:!0,children:J==="active"?"Active Arions":J==="resting"?"Resting Arions":"Arions"}),V&&XH(vY,{dimColor:!0,children:[" @",V]})]}),H.length===0&&UF(vY,{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=$U(U.color),D=U.isActive?" (active)":U.isResting?" (resting)":"";return XH(yM,{children:[XH(vY,{inverse:B===K,children:[U.emoji," ",UF(vY,{color:F,children:U.name})]}),XH(vY,{dimColor:!0,children:[" ",U.description,D]})]},U.name)}),UF(yM,{marginTop:1,children:UF(vY,{dimColor:!0,children:"\u2191\u2193 navigate \u23CE select esc cancel"})})]})}var h40=E(()=>{BV()});import{jsx as qZ,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 g40($){let Z=x40.indexOf($);return Z>=0?Z:x40.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])=>g40(G)-g40(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=BF.indexOf(_);return BF[Math.max(0,M-1)]});return}if(N.rightArrow){W((_)=>{let M=BF.indexOf(_);return BF[Math.min(BF.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:[qZ(y4,{bold:!0,children:"Model"}),qZ(y4,{dimColor:!0,children:q}),qZ(y4,{children:" "}),Q?qZ(y4,{color:"cyan",children:Q}):qZ(y4,{dimColor:!0,children:"Type to search..."})]}),K.length===0&&qZ(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=Ia(N.provider);return p1(HJ,{marginTop:_>0?1:0,children:[p1(y4,{color:a.color,children:[a.icon," "]}),qZ(y4,{bold:!0,color:a.color,children:N.label})]},`header-${N.label}-${_}`)}if(N.type==="hint")return qZ(HJ,{marginTop:1,children:qZ(y4,{dimColor:!0,italic:!0,children:N.label})},"hint");let M=U[O]===_,T=N.model.description,k=N.model.name.padEnd(A),R=zA(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:m40[V],children:[NR0[V]," "]}),p1(y4,{color:m40[V],bold:!0,children:[LR0[V]," effort"]}),V==="high"&&qZ(y4,{dimColor:!0,children:" (default)"}),qZ(y4,{dimColor:!0,children:" \u2190 \u2192 to adjust"})]}),qZ(HJ,{marginTop:0,children:qZ(y4,{dimColor:!0,children:"\u2191\u2193 navigate \u2190 \u2192 effort \u23CE select esc cancel"})})]})]})}var FR0,x40,BF,NR0,LR0,m40;var c40=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"},x40=["anthropic","openai-codex","google","bedrock","bedrock-converse","github-copilot","openai","local"];BF=["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"},m40={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 u40=()=>{};import{jsx as FF,jsxs as Q5}from"react/jsx-runtime";import{useState as av,useEffect as p40}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);p40(()=>{V((A)=>Math.min(A,Math.max(0,F.length-1)))},[F.length]),p40(()=>{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:[FF(U2,{bold:!0,color:"cyan",children:"Sessions"}),W&&Q5(U2,{dimColor:!0,children:[' (filter: "',W,'")']}),Q5(U2,{dimColor:!0,children:[" - ",$.length," sessions"]})]}),$.length===0?FF(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&&FF(QH,{marginTop:1,children:Q5(U2,{dimColor:!0,children:["Page ",K+1,"/",B]})}),FF(QH,{marginTop:1,children:FF(U2,{dimColor:!0,children:"type to search arrows navigate enter resume esc cancel"})})]})}var d40=E(()=>{P1()});import{jsx as DF,jsxs as hY}from"react/jsx-runtime";import{useState as iv,useEffect as vM,useMemo as PR0}from"react";import{Box as hM,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]);vM(()=>{G((L)=>Math.min(L,Math.max(0,H.length-1)))},[H.length]),vM(()=>{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);vM(()=>{if(Q<z)U(Q);else if(Q>=z+K)U(Q-K+1)},[Q,K,z]),vM(()=>{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 hY(hM,{flexDirection:"column",borderStyle:"round",borderColor:"cyan",paddingX:1,children:[hY(hM,{marginBottom:1,children:[DF(zJ,{bold:!0,color:"cyan",children:"Edit Message"}),V?hY(zJ,{dimColor:!0,children:[" ",'(search: "',V,'") \u2014 ',H.length,"/",$.length," messages"]}):hY(zJ,{dimColor:!0,children:[" \u2014 ",$.length," messages \xB7 select a user message to edit"]})]}),z>0&&hY(zJ,{dimColor:!0,children:[" \u2191 ",z," more above"]}),H.length===0?DF(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 DF(hM,{flexDirection:"row",children:hY(zJ,{inverse:N,color:N?void 0:T,dimColor:!_&&!N,bold:_,children:[k," ",M," ",R]})},`${L.index}-${q}`)}),z+K<H.length&&hY(zJ,{dimColor:!0,children:[" \u2193 ",H.length-z-K," more below"]}),DF(hM,{marginTop:1,children:DF(zJ,{dimColor:!0,children:"type to search \xB7 \u2191\u2193 navigate \xB7 enter select user message \xB7 esc cancel"})})]})}var l40=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 a40($){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=DA(Z);return{name:Z,displayName:J.displayName,isCurrent:Z===$,isLight:fR0(J),category:a40(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 n40=E(()=>{E0();bR0={standard:"Standard",claude:"Claude",accessible:"Accessible"},kR0=["standard","claude","accessible"]});import{jsxs as xY,jsx as xM}from"react/jsx-runtime";import{useState as i40,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]=i40(0),[G,V]=i40(""),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 xY(tv,{flexDirection:"column",borderStyle:"round",borderColor:W.colors.secondary,paddingX:1,children:[xY(UJ,{bold:!0,color:W.colors.primary,children:[" ","Nearby Peers"," "]}),G?xY(UJ,{dimColor:!0,children:[' (filter: "',G,'")']}):null,H.length===0&&xM(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)=>xY(tv,{children:[xY(UJ,{inverse:F===K,color:F===K?W.colors.primary:void 0,children:[F===K?" \u25B8 ":" ",B.displayNameSnapshot]}),B.status==="connected"?xM(UJ,{color:"green",children:" \u2713 connected"}):xY(UJ,{dimColor:!0,children:[" ",B.host,":",B.port]}),B.principalFingerprint?xY(UJ,{color:W.colors.secondary,children:[" ",U(B.principalFingerprint)]}):null]},`${B.displayNameSnapshot}-${B.nodeId}-${F}`)),xM(tv,{marginTop:H.length>0?1:0,children:xM(UJ,{dimColor:!0,children:"type to search \u2191\u2193 navigate \u23CE connect esc cancel"})})]})}var o40=E(()=>{E0()});import{jsxs as GH,jsx as Zh}from"react/jsx-runtime";import{useEffect as uR0,useMemo as pR0,useState as s40}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]=s40(0),[Q,G]=s40(""),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 r40=E(()=>{E0()});import{jsx as BJ,jsxs as OF}from"react/jsx-runtime";import{Box as gM,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}),OF(gM,{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?OF(B2,{children:["Label: ",BJ(B2,{bold:!0,children:Z})]}):null,J?OF(B2,{dimColor:!0,children:["Expires: ",J]}):null,OF(gM,{marginTop:1,flexDirection:"column",children:[BJ(B2,{children:"Share this token:"}),BJ(B2,{children:$})]}),OF(gM,{marginTop:1,flexDirection:"column",children:[BJ(B2,{children:"Join with:"}),BJ(B2,{children:`aria pairing join ${$}`})]}),BJ(gM,{marginTop:1,children:BJ(B2,{dimColor:!0,children:"Press Enter or Esc to close."})})]})}var t40=E(()=>{E0()});import{jsx as FJ,jsxs as nR0}from"react/jsx-runtime";import{useState as iR0}from"react";import{Box as mM,Text as NF,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(mM,{flexDirection:"column",borderStyle:"round",borderColor:Q.colors.secondary,paddingX:1,paddingY:1,children:[FJ(NF,{bold:!0,color:Q.colors.primary,children:"Join Invite"}),FJ(NF,{children:"Paste the invite token and press Enter."}),FJ(mM,{marginTop:1,children:FJ(NF,{children:X||" "})}),J?FJ(mM,{marginTop:1,children:FJ(NF,{color:Q.colors.error,children:J})}):null,FJ(mM,{marginTop:1,children:FJ(NF,{dimColor:!0,children:"Type token, Enter to join, Esc to cancel."})})]})}var e40=E(()=>{E0()});import{jsxs as gY,jsx as LF}from"react/jsx-runtime";import{useState as sR0,useRef as rR0}from"react";import{Box as AF,Text as mY,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}),gY(AF,{flexDirection:"column",borderStyle:"round",borderColor:G.colors.warning,paddingX:2,paddingY:1,children:[gY(mY,{bold:!0,color:G.colors.warning,children:[" ","Connection Request"," "]}),LF(AF,{marginTop:1,children:gY(mY,{children:[LF(mY,{bold:!0,children:$.displayNameSnapshot??$.nodeId})," wants to connect"]})}),LF(AF,{children:gY(mY,{dimColor:!0,children:["Fingerprint: ",W($.principalFingerprint)]})}),gY(AF,{marginTop:1,gap:2,children:[gY(mY,{inverse:X==="accept",color:X==="accept"?G.colors.success:void 0,children:[" ","Accept"," "]}),gY(mY,{inverse:X==="reject",color:X==="reject"?G.colors.error:void 0,children:[" ","Reject"," "]})]}),LF(AF,{marginTop:1,children:LF(mY,{dimColor:!0,children:"\u2190\u2192 select \u23CE confirm esc reject"})})]})}var $60=E(()=>{E0()});import{execFile as eR0}from"child_process";import{existsSync as Hh,readdirSync as Y60}from"fs";import{dirname as $w0,join as cM,resolve as Zw0}from"path";import{fileURLToPath as Jw0}from"url";function Yw0(){let $=Xw0;for(let Z=0;Z<10;Z++){let J=cM($,".comms","sounds","wav");if(Hh(J))return J;let X=Zw0($,"..");if(X===$)break;$=X}return null}function U8($){if(!cY)return[];try{return Y60(cY).filter((Z)=>new RegExp($).test(Z)).map((Z)=>cM(cY,Z))}catch{return[]}}function Z60($){if(!cY)return[];let Z=cM(cY,"cloned");try{return Y60(Z).filter((J)=>new RegExp($).test(J)).map((J)=>cM(Z,J))}catch{return[]}}function G5($){if($.length===0)return null;return $[Math.floor(Math.random()*$.length)]}function uY($){Kh=$}function Q60(){return Kh}function G60(){if(process.platform!=="darwin")return"unsupported on this platform";return zh()?"afplay (macOS)":"afplay unavailable"}function zh(){if(J60)return Wh;return J60=!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($-X60>Qw0)qF=1;else qF++;if(X60=$,qF<=1)V5(G5(W5.acknowledge()));else if(qF===2)V5(G5(W5.annoyed()));else if(qF===3)V5(G5(W5.grumpy()));else V5(G5(W5.dark()))}function uM(){V5(G5(W5.readyToWork()))}function V60(){V5(G5(W5.fleetDown()))}function W60(){Gw0()}function H60(){V5(G5(W5.questDone()))}function K60($){switch($.type){case"error":V5(G5(W5.error()));break;case"guardrail_rejected":V5(G5(W5.defeat()));break}}function z60(){return cY!==null&&zh()}function U60(){return cY!==null}function B60(){return V5(G5(W5.readyToWork()))}var Xw0,cY,Kh=!0,J60=!1,Wh=!1,W5,X60=0,qF=0,Qw0=15000;var Uh=E(()=>{Xw0=$w0(Jw0(import.meta.url));cY=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:()=>Z60("^defeat_"),error:()=>Z60("^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 D60}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(Q60()),[V,W]=Bh("idle"),H=D60(()=>{let D=!Q;uY(D);let O=H$();if(O.soundEnabled=D,S$(O),G(D),D)uM()},[Q]),K=D60(()=>{let D=Q;if(!D)uY(!0);let O=B60();if(!D)uY(!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=z60(),B=U60(),F=G60();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 O60=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 N60=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 L60=E(()=>{y40();h40();c40();u40();d40();l40();n40();o40();r40();t40();e40();$60();O60();N60()});var Nh=E(()=>{NS();ES();_n();xn();Sr();Tq();tI();$b();hr();xr();gr();CV();mr();c90();$I();u90();d90();n90();JI();t90();WF();yY();WJ();L60()});import{jsxs as HH,jsx as WH}from"react/jsx-runtime";import{useEffect as Bw0,useState as Fw0,useRef as A60}from"react";import{Box as pM,Text as pY,useInput as Dw0}from"ink";function Ow0({status:$}){let Z=e();switch($){case"connected":return HH(pY,{color:Z.colors.success,children:["\u2713"," connected"]});case"expired":return HH(pY,{color:Z.colors.error,children:["\u2717"," expired"]});case"none":return HH(pY,{color:Z.colors.textMuted,children:["\xB7"," not connected"]})}}function q60({providers:$,onSelect:Z,onCancel:J,isActive:X=!0}){let Y=e(),[Q,G]=Fw0(0),V=A60(0),W=A60(!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(pM,{flexDirection:"column",borderStyle:"round",borderColor:Y.colors.secondary,paddingX:1,paddingY:1,width:56,children:[WH(pM,{marginBottom:1,children:WH(pY,{bold:!0,children:"Select a provider:"})}),$.map((z,U)=>{let B=U===Q,F=B?"\u25B8":" ";return HH(pM,{gap:1,children:[WH(pY,{color:B?Y.colors.primary:void 0,children:F}),WH(pY,{color:B?Y.colors.primary:void 0,bold:B,children:z.label.padEnd(28)}),WH(Ow0,{status:z.status})]},z.id)}),WH(pM,{marginTop:1,children:HH(pY,{color:Y.colors.textMuted,children:["\u2191\u2193"," Navigate Enter Select Esc Cancel"]})})]})}var E60=E(()=>{E0()});import{jsxs as F2,jsx as x4}from"react/jsx-runtime";import{useEffect as Nw0,useRef as Lh,useState as dM}from"react";import{Box as a1,Text as n1,useInput as Lw0}from"ink";function _60({provider:$,onCancel:Z,isActive:J=!0,onComplete:X,authorizeUrl:Y,expectedState:Q,onCodeSubmit:G}){let V=e(),[W,H]=dM("starting"),[K,z]=dM(""),[U,B]=dM(""),[F,D]=dM(""),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),tL($,{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 M60=E(()=>{R6();E0();Tq();cS()});import{jsxs as zH,jsx as D2}from"react/jsx-runtime";import{useEffect as Aw0,useRef as P60,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=P60(0),H=P60(!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 j60({options:$,onSelect:Z,onCancel:J,isActive:X=!0}){return Mw0(UH,{options:$,onSelect:Z,onCancel:J,title:"Select Anthropic login method:",isActive:X})}var T60=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 EF,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(EF,{flexDirection:"column",borderStyle:"round",borderColor:Q.colors.secondary,paddingX:1,paddingY:1,width:64,children:[OJ(EF,{marginBottom:1,children:OJ(BH,{bold:!0,children:$})}),Z&&OJ(EF,{marginBottom:1,children:OJ(BH,{color:Q.colors.textMuted,dimColor:!0,children:Z})}),qh(EF,{children:[qh(BH,{color:Q.colors.primary,children:["\u25B8"," "]}),OJ(BH,{children:K||" "}),OJ(BH,{color:Q.colors.textMuted,children:"_"})]}),OJ(EF,{marginTop:1,children:OJ(BH,{color:Q.colors.textMuted,children:"Enter Submit Esc Cancel"})})]})}var C60=E(()=>{E0()});function R60($,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"&&kA(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 w60=E(()=>{fA()});function I60($,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 S60;var b60=E(()=>{S60={kind:"idle"}});import{useReducer as Cw0,useEffect as Eh,useRef as k60}from"react";function f60($,Z){let[J,X]=Cw0(I60,S60),Y=k60(!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=k60(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:pn(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 y60=E(()=>{b60();_V()});function lM($){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 v60($,Z){let J=new Map;for(let X of[...$,...Z]){let Y=lM(X);if(!J.has(Y))J.set(Y,X)}return[...J.values()]}import{jsx as G$,jsxs as dY,Fragment as Rw0}from"react/jsx-runtime";import{useState as NJ,useCallback as O2,useMemo as LJ,useEffect as EZ}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:VK,copilotDeviceVerificationUri:WK,copilotDeviceUserCode:W7,onCopilotDeviceComplete:H7,onCopilotDeviceApprove:HK,onCopilotDeviceCancel:y2,anthropicMethodOptions:KK,onAnthropicMethodSelect:XO,onAnthropicMethodCancel:mJ,anthropicKeyInputVisible:YO,onAnthropicKeySubmit:TQ,onAnthropicKeyCancel:QO,anthropicSetupTokenVisible:CQ,onAnthropicSetupTokenSubmit:GO,onAnthropicSetupTokenCancel:RQ,openaiMethodOptions:zK,onOpenAIMethodSelect:wQ,onOpenAIMethodCancel:VO,openaiKeyInputVisible:SQ,onOpenAIKeySubmit:WO,onOpenAIKeyCancel:IQ,googleMethodOptions:bQ,onGoogleMethodSelect:kQ,onGoogleMethodCancel:HO,googleKeyInputVisible:fQ,onGoogleKeySubmit:KO,onGoogleKeyCancel:yQ,authInteractionOptions:UK,authInteractionTitle:BK,onAuthInteractionSelect:zO,onAuthInteractionCancel:vQ,authInteractionInput:hQ,onAuthInteractionInputSubmit:xQ,onAuthInteractionInputCancel:UO,nearbyPeers:v2=[],localClients:BO=[],onSelectPeer:FK,onSelectClient:DT,onPeerCancel:FO,onClientsCancel:OT,openPeersOverlaySignal:gQ,openClientsOverlaySignal:DO,inviteShare:K7,onInviteShareClose:NT,openJoinInviteOverlaySignal:mQ,onJoinInviteSubmit:DK,onJoinInviteCancel:cJ,joinInviteError:LT,incomingPairRequest:h2,onAcceptPairRequest:AT,onRejectPairRequest:OO,onCancelPairing:E5,openMessageEditOverlaySignal:OK,editableMessages:x2,onEditMessage:qT,prefillInput:NK,onPrefillConsumed:ET,meshMessageCount:_T=0,runtimeSocket:Wu=null,clientId:Hu=null,clientAuthToken:Ku=null,resolveCredentials:LK}){let{exit:uJ}=Sw0(),{columns:NO,rows:MT}=X9(),[AK,A6]=NJ(""),[m0,J$]=NJ("none"),[cQ,uQ]=NJ(""),[qK,EK]=NJ(""),[i9,g2]=NJ("become"),[LO,z7]=NJ("all"),[AO,pQ]=NJ(!1),pJ=Boolean(UK||KK||zK||bQ),qO=Boolean(hQ||YO||CQ||SQ||fQ),dJ=Boolean(_$||q5||z$||U$);EZ(()=>{if(pJ)J$("login-method");else if(qO)J$("login-input");else if(dJ)J$("login");else if(m0==="login"||m0==="login-method"||m0==="login-input")J$("none")},[pJ,qO,dJ]);let _K=O2(()=>{J$("session"),setTimeout(()=>g?.(),0)},[g]);EZ(()=>{if(x===void 0)return;_K()},[x,_K]),EZ(()=>{if(r===void 0)return;J$("theme")},[r]),EZ(()=>{if(J0===void 0)return;J$("sound")},[J0]),EZ(()=>{if(X0===void 0)return;J$("daemon")},[X0]);let[dQ,lQ]=NJ([]);EZ(()=>{if(gQ===void 0)return;lQ([...v2]),J$("peers")},[gQ]),EZ(()=>{if(DO===void 0)return;J$("clients")},[DO]),EZ(()=>{if(K7)J$("invite-share");else if(m0==="invite-share")J$("none")},[K7,m0]),EZ(()=>{if(mQ===void 0)return;J$("join-invite")},[mQ]),EZ(()=>{if(OK===void 0)return;if(x2&&x2.length>0)J$("message-edit")},[OK]),EZ(()=>{if(NK!==void 0)A6(NK),ET?.()},[NK]),EZ(()=>{if(m0!=="peers")return;lQ((N0)=>{let T0=new Set(N0.map(lM)),J8=v2.filter((M5)=>!T0.has(lM(M5)));return J8.length>0?[...N0,...J8]:N0})},[m0,v2]),EZ(()=>{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}uJ()}if(W$(N0,T0)){if(B0)return;if(m0!=="none"){SZ();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 RZ=$.getPrimary(),zu=RZ?.name||"ARIA",jT=RZ?.color||"cyan",TT=RZ?.emoji||"\uD83E\uDD8B",wZ=f60(Z0??null,G??!1),aQ=(m0==="none"&&!B0?4:0)+(!A||A.showStatusBar?1:0),EO=Math.max(MT-aQ,1),nQ=O2((N0,T0)=>{if(N0==="command")J$("command"),uQ(T0);else if(N0==="mention")J$("arion"),EK(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")_K();else if(N0.name==="exit")uJ();else if(T0){A6(`/${N0.name} `);return}else o(N0.name)},[o,S,uJ]),d6=O2((N0)=>{if(J$("none"),i9==="mention"){let T0=AK.replace(/@\w*$/,"");A6(T0+"@"+N0.name+" ")}else u?.(N0.name,i9)},[i9,AK,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]),SZ=O2(()=>{if(J$("none"),i9!=="mention")A6("");uQ(""),EK("")},[i9]),m2=O2((N0)=>{J$("none"),A6(N0),uQ("")},[]),_O=LJ(()=>R60(Y,Q,{userName:O}),[Y,Q,O]),l6=LJ(()=>iI(_O,q),[_O,q]),iQ=LJ(()=>l6.filter((N0)=>N0.committed),[l6]),oQ=LJ(()=>l6.filter((N0)=>!N0.committed),[l6]),E8=G&&V?V:null,IZ=E8!==null,X1=wZ.kind!=="idle",T$=Math.max(NO-4,20),c2=LJ(()=>{if(!E8)return 0;return Math.max(F9(E8,{width:T$}).split(`
4727
- `).length,1)},[T$,E8]),sQ=(IZ?4+c2:0)+(X1?2:0),bZ=Math.max(EO-sQ,1),_5=LJ(()=>{let N0=new Map,T0="";for(let J8 of l6){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},[l6]),IT=LJ(()=>{let N0=new Map;for(let T0=0;T0<l6.length;T0++){let J8=l6[T0],M5=T0>0?l6[T0-1]:void 0,rQ=J8.kind==="tool-execution"&&M5?.kind==="tool-execution";N0.set(J8.id,T0>0&&!rQ)}return N0},[l6]),Uu=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 dY(Rw0,{children:[G$(ww0,{items:Uu,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$(jq,{item:N0,displayMode:q,showPrefix:_5.get(N0.id)??!1})},N0.id)}},`static-${Y0}`),dY(K5,{flexDirection:"column",width:"100%",children:[dY(K5,{flexDirection:"column",maxHeight:EO,justifyContent:"flex-end",overflowY:"hidden",children:[oQ.length>0&&G$(K5,{flexDirection:"column",maxHeight:bZ,overflowY:"hidden",children:oQ.map((N0)=>G$(K5,{flexDirection:"column",marginTop:IT.get(N0.id)?1:0,children:G$(jq,{item:N0,displayMode:q,showPrefix:_5.get(N0.id)??!1,previewTailLines:bZ})},N0.id))}),IZ&&dY(K5,{marginTop:1,flexDirection:"column",children:[G$(bA,{param:{type:"text",text:E8??""},userName:O??"User",columns:NO,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}),AO&&dY(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:wZ.kind==="thinking"?"thinking":"composing",elapsedSeconds:Math.floor(L?.wallTimeSeconds??0),totalTokens:L?.totalTokens??0,thoughtForSeconds:wZ.kind==="composing"?wZ.thoughtForSeconds:void 0,currentVerb:wZ.kind==="tool_running"?[...new Set(wZ.tools.values())].join(" \xB7 "):wZ.verb.present})]}),dY(K5,{flexDirection:"column",flexShrink:0,children:[D0&&_0&&L0&&G$(Hv,{currentLevel:C0??JJ.autonomy,onSelect:_0,onCancel:L0}),z$&&A0&&u0&&G$(q60,{providers:z$,onSelect:A0,onCancel:u0}),U$&&r0&&V$&&G$(eI,{options:U$,onSelect:r0,onCancel:V$}),m0==="login-method"&&UK&&zO&&vQ&&G$(UH,{options:UK,onSelect:(N0)=>zO(N0.id),onCancel:vQ,title:BK??"Choose an option:",isActive:m0==="login-method"}),m0==="login-method"&&KK&&XO&&mJ&&G$(j60,{options:KK,onSelect:XO,onCancel:mJ,isActive:m0==="login-method"}),m0==="login-input"&&hQ&&xQ&&UO&&G$(FH,{title:hQ.title,hint:hQ.hint,onSubmit:xQ,onCancel:UO,isActive:m0==="login-input"}),m0==="login-input"&&YO&&TQ&&QO&&G$(FH,{title:"Enter Anthropic API key",hint:"Paste your sk-ant-api03-* key",onSubmit:TQ,onCancel:QO,isActive:m0==="login-input"}),m0==="login-input"&&CQ&&GO&&RQ&&G$(FH,{title:"Enter setup token",hint:"From `claude setup-token` or admin provisioning",onSubmit:GO,onCancel:RQ,isActive:m0==="login-input"}),m0==="login-method"&&zK&&wQ&&VO&&G$(UH,{options:zK,onSelect:wQ,onCancel:VO,title:"Select OpenAI login method:",isActive:m0==="login-method"}),m0==="login-input"&&SQ&&WO&&IQ&&G$(FH,{title:"Enter OpenAI API key",hint:"Paste your sk-* key",onSubmit:WO,onCancel:IQ,isActive:m0==="login-input"}),m0==="login-method"&&bQ&&kQ&&HO&&G$(UH,{options:bQ,onSelect:kQ,onCancel:HO,title:"Select Google login method:",isActive:m0==="login-method"}),m0==="login-input"&&fQ&&KO&&yQ&&G$(FH,{title:"Enter Google API key",hint:"Paste your AIza* key",onSubmit:KO,onCancel:yQ,isActive:m0==="login-input"}),m0==="login"&&_$&&m$&&d4&&G$(_60,{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:VK??void 0,...WK&&W7&&HK?{verificationUri:WK,userCode:W7,onApprove:HK}:{onComplete:H7},onCancel:y2}),dY(K5,{flexDirection:"column",children:[m0==="command"&&G$(mv,{commands:K,initialFilter:cQ,onSelect:CT,onHandOffInput:m2,onCancel:SZ}),m0==="arion"&&G$(cv,{arions:z,initialFilter:qK,statusFilter:LO,onSelect:d6,onCancel:SZ}),m0==="model"&&G$(pv,{models:U,effortLevel:V0,onSelect:RT,onCancel:SZ}),m0==="theme"&&G$(rv,{onSelect:wT,onCancel:SZ}),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"),DK?.(N0)},onCancel:()=>{J$("none"),cJ?.()}}),m0==="memory"&&G$(lv,{memories:B,mode:F,isLoading:D,onSelect:ST,onCancel:SZ}),m0==="peers"&&G$($h,{peers:dQ.length>0?dQ:v2,sameHomeClientsAvailable:BO.length>0,onSelect:(N0)=>{J$("none"),FK?.(N0)},onCancel:SZ}),m0==="clients"&&G$(Yh,{clients:BO,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"),OO?.()}}),m0==="session"&&G$(nv,{sessions:C,onSelect:(N0)=>{J$("none"),f?.(N0)},onCancel:SZ,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:SZ}),m0==="none"&&!B0&&G$(aS,{userName:O,value:AK,onChange:A6,onSubmit:a,onTrigger:nQ,onExit:()=>uJ(),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:zu,emoji:TT,color:jT,traits:RZ?.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 h60=E(()=>{Nh();E60();$b();M60();tI();T60();Ah();C60();nI();oS();P1();w60();M1();G8();y60()});function x60($){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 g60,useState as kw0}from"react";import{Box as fw0,useStdout as yw0}from"ink";function vw0($){let Z=kU[$.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 m60($){let{stdout:Z}=yw0(),J=Z?.columns??80,[X]=kw0(!1),Y=g60(()=>{if(!$.approvalRequest)return null;return x60($.onApprovalChoice)},[$.approvalRequest,$.onApprovalChoice]),Q=g60(()=>{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 c60=E(()=>{h60();WF();Pq();Pq();hw0={message:{id:"aria-approval"}}});var Ph;var u60=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.67"}var __filename="/Users/hole/aria/.bundle-stage/cli/dist/release-notes.js",aM,p60;var jh=E(()=>{aM=gw0(),p60=["\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 d60($){let Z=Th.indexOf($);return Th[(Z+1)%Th.length]}function l60($,Z){let J=_F[$],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 a60($,Z){return{..._F[$],...Z??{}}}var _F,Th;var Ch=E(()=>{_F={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 lY($){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 n60($){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 nM=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=(IZ?4+c2:0)+(X1?2:0),bZ=Math.max(EO-sQ,1),_5=LJ(()=>{let N0=new Map,T0="";for(let J8 of l6){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},[l6]),IT=LJ(()=>{let N0=new Map;for(let T0=0;T0<l6.length;T0++){let J8=l6[T0],M5=T0>0?l6[T0-1]:void 0,rQ=J8.kind==="tool-execution"&&M5?.kind==="tool-execution";N0.set(J8.id,T0>0&&!rQ)}return N0},[l6]),Uu=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 dY(Rw0,{children:[G$(ww0,{items:Uu,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$(jq,{item:N0,displayMode:q,showPrefix:_5.get(N0.id)??!1})},N0.id)}},`static-${Y0}`),dY(K5,{flexDirection:"column",width:"100%",children:[dY(K5,{flexDirection:"column",maxHeight:EO,justifyContent:"flex-end",overflowY:"hidden",children:[oQ.length>0&&G$(K5,{flexDirection:"column",maxHeight:bZ,overflowY:"hidden",children:oQ.map((N0)=>G$(K5,{flexDirection:"column",marginTop:IT.get(N0.id)?1:0,children:G$(jq,{item:N0,displayMode:q,showPrefix:_5.get(N0.id)??!1,previewTailLines:bZ})},N0.id))}),IZ&&dY(K5,{marginTop:1,flexDirection:"column",children:[G$(bA,{param:{type:"text",text:E8??""},userName:O??"User",columns:NO,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}),AO&&dY(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:wZ.kind==="thinking"?"thinking":"composing",elapsedSeconds:Math.floor(L?.wallTimeSeconds??0),totalTokens:L?.totalTokens??0,thoughtForSeconds:wZ.kind==="composing"?wZ.thoughtForSeconds:void 0,currentVerb:wZ.kind==="tool_running"?[...new Set(wZ.tools.values())].join(" \xB7 "):wZ.verb.present})]}),dY(K5,{flexDirection:"column",flexShrink:0,children:[D0&&_0&&L0&&G$(Hv,{currentLevel:C0??JJ.autonomy,onSelect:_0,onCancel:L0}),z$&&A0&&u0&&G$(q60,{providers:z$,onSelect:A0,onCancel:u0}),U$&&r0&&V$&&G$(eI,{options:U$,onSelect:r0,onCancel:V$}),m0==="login-method"&&UK&&zO&&vQ&&G$(UH,{options:UK,onSelect:(N0)=>zO(N0.id),onCancel:vQ,title:BK??"Choose an option:",isActive:m0==="login-method"}),m0==="login-method"&&KK&&XO&&mJ&&G$(j60,{options:KK,onSelect:XO,onCancel:mJ,isActive:m0==="login-method"}),m0==="login-input"&&hQ&&xQ&&UO&&G$(FH,{title:hQ.title,hint:hQ.hint,onSubmit:xQ,onCancel:UO,isActive:m0==="login-input"}),m0==="login-input"&&YO&&TQ&&QO&&G$(FH,{title:"Enter Anthropic API key",hint:"Paste your sk-ant-api03-* key",onSubmit:TQ,onCancel:QO,isActive:m0==="login-input"}),m0==="login-input"&&CQ&&GO&&RQ&&G$(FH,{title:"Enter setup token",hint:"From `claude setup-token` or admin provisioning",onSubmit:GO,onCancel:RQ,isActive:m0==="login-input"}),m0==="login-method"&&zK&&wQ&&VO&&G$(UH,{options:zK,onSelect:wQ,onCancel:VO,title:"Select OpenAI login method:",isActive:m0==="login-method"}),m0==="login-input"&&SQ&&WO&&IQ&&G$(FH,{title:"Enter OpenAI API key",hint:"Paste your sk-* key",onSubmit:WO,onCancel:IQ,isActive:m0==="login-input"}),m0==="login-method"&&bQ&&kQ&&HO&&G$(UH,{options:bQ,onSelect:kQ,onCancel:HO,title:"Select Google login method:",isActive:m0==="login-method"}),m0==="login-input"&&fQ&&KO&&yQ&&G$(FH,{title:"Enter Google API key",hint:"Paste your AIza* key",onSubmit:KO,onCancel:yQ,isActive:m0==="login-input"}),m0==="login"&&_$&&m$&&d4&&G$(_60,{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:VK??void 0,...WK&&W7&&HK?{verificationUri:WK,userCode:W7,onApprove:HK}:{onComplete:H7},onCancel:y2}),dY(K5,{flexDirection:"column",children:[m0==="command"&&G$(mv,{commands:K,initialFilter:cQ,onSelect:CT,onHandOffInput:m2,onCancel:SZ}),m0==="arion"&&G$(cv,{arions:z,initialFilter:qK,statusFilter:LO,onSelect:d6,onCancel:SZ}),m0==="model"&&G$(pv,{models:U,effortLevel:V0,onSelect:RT,onCancel:SZ}),m0==="theme"&&G$(rv,{onSelect:wT,onCancel:SZ}),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"),DK?.(N0)},onCancel:()=>{J$("none"),cJ?.()}}),m0==="memory"&&G$(lv,{memories:B,mode:F,isLoading:D,onSelect:ST,onCancel:SZ}),m0==="peers"&&G$($h,{peers:dQ.length>0?dQ:v2,sameHomeClientsAvailable:BO.length>0,onSelect:(N0)=>{J$("none"),FK?.(N0)},onCancel:SZ}),m0==="clients"&&G$(Yh,{clients:BO,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"),OO?.()}}),m0==="session"&&G$(nv,{sessions:C,onSelect:(N0)=>{J$("none"),f?.(N0)},onCancel:SZ,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:SZ}),m0==="none"&&!B0&&G$(aS,{userName:O,value:AK,onChange:A6,onSubmit:a,onTrigger:nQ,onExit:()=>uJ(),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:zu,emoji:TT,color:jT,traits:RZ?.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 h60=E(()=>{Nh();E60();$b();M60();tI();T60();Ah();C60();nI();oS();P1();w60();M1();G8();y60()});function x60($){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 g60,useState as kw0}from"react";import{Box as fw0,useStdout as yw0}from"ink";function vw0($){let Z=kU[$.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 m60($){let{stdout:Z}=yw0(),J=Z?.columns??80,[X]=kw0(!1),Y=g60(()=>{if(!$.approvalRequest)return null;return x60($.onApprovalChoice)},[$.approvalRequest,$.onApprovalChoice]),Q=g60(()=>{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 c60=E(()=>{h60();WF();Pq();Pq();hw0={message:{id:"aria-approval"}}});var Ph;var u60=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.68"}var __filename="/Users/hole/aria/.bundle-stage/cli/dist/release-notes.js",aM,p60;var jh=E(()=>{aM=gw0(),p60=["\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 d60($){let Z=Th.indexOf($);return Th[(Z+1)%Th.length]}function l60($,Z){let J=_F[$],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 a60($,Z){return{..._F[$],...Z??{}}}var _F,Th;var Ch=E(()=>{_F={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 lY($){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 n60($){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 nM=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 i60($){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 iM($,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(i60)),Y=[];for(let G of J){let V=i60(G);if(!X.has(V))Y.push(G)}return{messages:[...$,...Y],backfillMessages:Y}}function oM($,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 o60=E(()=>{nM()});var bh={};A$(bh,{toModelMessages:()=>NL,replaySessionFromJsonl:()=>Ih,repairToolCallPairing:()=>lY,mergeWithJsonlRecovery:()=>iM,fromV1Columns:()=>pG,fromModelMessages:()=>uG,findJsonlForSession:()=>oM,extractToolCalls:()=>lG,extractToolCallId:()=>nG,extractThinking:()=>aG,extractTextContent:()=>dG,createUserMessage:()=>cG,createSystemMessage:()=>l0,createIncomingMessagePair:()=>OL,createErrorMessage:()=>Y$,conversationMessageToHistoryMessages:()=>n60,TurnAccumulator:()=>AJ,SessionHistoryClient:()=>DH,SessionHistory:()=>Z6,ConversationMessageSchema:()=>DL,ContentBlockSchema:()=>Md,ArionRefSchema:()=>jd});var aY=E(()=>{IR();wh();nM();o60()});import{existsSync as lw0}from"fs";import{fileURLToPath as s60}from"url";function aw0(){return[s60(new URL("../main.ts",import.meta.url)),s60(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 r60(){return kh()==="compiled-bun"}var fh=()=>{};import{existsSync as yh}from"fs";import{fileURLToPath as sM}from"url";function t60(){return process.platform==="win32"?"bun.exe":"bun"}function nw0(){let $=[sM(new URL("../main.ts",import.meta.url)),sM(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=[sM(new URL("../../bin/aria.mjs",import.meta.url)),sM(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 rM($){let Z=kh(),J=$.args??[],X={...process.env,...$.env??{}},Y=$.cwd??process.cwd();switch(Z){case"source-bun":return{command:t60(),args:[nw0(),"__internal",$.mode,...J],env:X,cwd:Y};case"bundled-bun":return{command:t60(),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 tM($,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 PF,mkdirSync as ow0,readFileSync as ZZ0,writeFileSync as sw0,unlinkSync as hh,readdirSync as rw0}from"fs";import{dirname as NT$,join as gh,resolve as LT$}from"path";function JZ0($){Jz($)}function tw0($){return $R($)}function eM($){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 XZ0(){return process.env[Zz]==="true"}function YZ0(...$){return gh(x9(),...$)}function QZ0(){return YZ0("crash-markers")}function ch($){return gh(QZ0(),`${$}.json`)}function JS0($){let Z=ch($);if(!PF(Z))return null;try{return JSON.parse(ZZ0(Z,"utf-8"))}catch{return null}}function XS0($){try{let Z=QZ0();ow0(Z,{recursive:!0}),sw0(ch($.sessionId),JSON.stringify($),"utf-8")}catch{}}function xh($){try{let Z=ch($);if(PF(Z))hh(Z)}catch{}}function YS0(){return YZ0("crash-reports","latest.json")}function e60($,Z){i1(`[aria] Session ${$} exceeded crash limit (${Z}/${MF}). Starting fresh instead of resuming.
4730
4730
  `),xh($),x8=null,qJ(null)}function QS0(){let $=YS0();if(!PF($))return null;try{let Z=JSON.parse(ZZ0($,"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 $Z0($){let Z=tw0(process.pid);if(Z){if(Date.now()-new Date(Z.timestamp).getTime()<ZS0)return eM(process.pid),{sessionId:Z.sessionId,arionName:Z.arionName||$,source:"marker"};eM(process.pid)}try{let{SessionHistory:J}=await Promise.resolve().then(() => (aY(),bh)),{getAriaDir:X}=await Promise.resolve().then(() => (Y4(),PA)),Y=X(),Q=new Set([$]),G=gh(Y,"arions");if(PF(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(!PF(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.67",
3
+ "version": "1.0.68",
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.67",
61
- "@aria-cli/wireguard": "1.0.67",
62
- "@aria-cli/search": "1.0.67"
60
+ "@aria-cli/fastripgrep": "1.0.68",
61
+ "@aria-cli/wireguard": "1.0.68",
62
+ "@aria-cli/search": "1.0.68"
63
63
  },
64
64
  "license": "MIT"
65
65
  }