@aria-cli/cli 1.0.60 → 1.0.61
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.
- package/bin/aria.mjs +2 -2
- package/package.json +5 -4
package/bin/aria.mjs
CHANGED
|
@@ -14,7 +14,7 @@ var QG0=Object.create;var{getPrototypeOf:GG0,defineProperty:MK,getOwnPropertyNam
|
|
|
14
14
|
`)});let F=()=>{H=!0,V.destroy(),B()};Y?.addEventListener("abort",F,{once:!0}),V.on("data",(D)=>{W+=D;while(!0){let O=W.indexOf(`
|
|
15
15
|
`);if(O===-1)break;let L=W.slice(0,O).trim();if(W=W.slice(O+1),L.length===0)continue;try{let q=S5.parse(JSON.parse(L));if(q.id!==G.id){K=Error("Local control socket response ID mismatch");break}if(!q.ok){let A=R5(q.error,q.diagnostic);if("reason"in q&&typeof q.reason==="string")A.reason=q.reason;K=A;break}z.push(X(q.payload))}catch(q){K=q;break}}B()}),V.once("error",(D)=>{K=D,B()}),V.once("end",()=>{H=!0,B()}),V.once("close",()=>{H=!0,B()});try{while(!0){if(z.length>0){yield z.shift();continue}if(K)throw K;if(H)return;await new Promise((D)=>{U=D})}}finally{Y?.removeEventListener("abort",F),V.destroy()}}}}function rK($){let Z=$.pollIntervalMs??1000,J=async(X)=>j$($.runtimeSocket,"listInbox",r9.optional().parse(X),(Y)=>c8.array().parse(Y));return{async submitRun(X){let Y=j8.parse(X);return Vp(j$($.runtimeSocket,"submitRun",Y,(Q)=>k9.parse(Q)))},async resumeRun(X){return j$($.runtimeSocket,"resumeRun",a4.parse(X),(Y)=>k9.parse(Y))},streamRun(X,Y){return cN($.runtimeSocket,"streamRun",j8.parse(X),(Q)=>E6.parse(Q),Y)},subscribeRuntimeEvents(X){return cN($.runtimeSocket,"subscribeRuntimeEvents",q7.optional().parse(X),(Y)=>Q1.parse(Y))},async sendBestEffort(X){return j$($.runtimeSocket,"sendBestEffort",G8.parse(X),(Y)=>n4.parse(Y))},async sendDurable(X){return j$($.runtimeSocket,"sendDurable",G8.parse(X),(Y)=>i4.parse(Y))},listInbox:J,subscribeInbox(X){return Qp(()=>J({limit:100,unreadOnly:!1}),{pollIntervalMs:Z,initialAfterCreatedAt:X?.afterCreatedAt??0})},async listPeers(){return j$($.runtimeSocket,"listPeers",void 0,(X)=>q4.array().parse(X))},async listNearbyPeers(){return j$($.runtimeSocket,"listNearbyPeers",void 0,(X)=>_6.array().parse(X))},subscribePeers(){return Qp(()=>j$($.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 j$($.runtimeSocket,"getRuntimeStatus",void 0,(X)=>f8.parse(X))},async getModelSnapshot(){return j$($.runtimeSocket,"getModelSnapshot",void 0,(X)=>t2.parse(X))},async refreshModelSnapshot(X){return j$($.runtimeSocket,"refreshModelSnapshot",X,(Y)=>t2.parse(Y))},async setCurrentModel(X){return j$($.runtimeSocket,"setCurrentModel",{model:X},(Y)=>t2.parse(Y))},async getSessionCredentialOverlayState(){return j$($.runtimeSocket,"getSessionCredentialOverlayState",void 0,(X)=>r2.parse(X))},async setSessionCredentialOverlay(X){return j$($.runtimeSocket,"setSessionCredentialOverlay",DG.parse(X),(Y)=>r2.parse(Y))},async clearSessionCredentialOverlay(){return j$($.runtimeSocket,"clearSessionCredentialOverlay",void 0,(X)=>r2.parse(X))},async startAutonomousLoop(X){return j$($.runtimeSocket,"startAutonomousLoop",o2.optional().parse(X),(Y)=>f8.parse(Y))},async stopAutonomousLoop(){return j$($.runtimeSocket,"stopAutonomousLoop",void 0,(X)=>f8.parse(X))},async getRuntimeBootstrap(){return j$($.runtimeSocket,"getRuntimeBootstrap",void 0,(X)=>u8.parse(X))},async listPendingPairRequests(){return j$($.runtimeSocket,"listPendingPairRequests",void 0,(X)=>M6.array().parse(X))},async respondToPairRequest(X){return j$($.runtimeSocket,"respondToPairRequest",_4.parse(X),(Y)=>P6.parse(Y))},async createInvite(X){return j$($.runtimeSocket,"createInvite",o4.parse(X),(Y)=>s4.parse(Y))},async listPendingInvites(){return j$($.runtimeSocket,"listPendingInvites",void 0,(X)=>E4.array().parse(X))},async acceptInviteToken(X){return j$($.runtimeSocket,"acceptInviteToken",t4.parse(X),(Y)=>e4.parse(Y))},async cancelInvite(X){return j$($.runtimeSocket,"cancelInvite",i6.parse(X),(Y)=>o6.parse(Y))},async invitePeer(X){return j$($.runtimeSocket,"invitePeer",r4.parse(X),(Y)=>n6.parse(Y))},async acceptInvite(X){return j$($.runtimeSocket,"acceptInvite",A4.parse(X),(Y)=>V1.parse(Y))},async directPair(X){return j$($.runtimeSocket,"directPair",U9.parse(X),(Y)=>j6.parse(Y))},async revokePeer(X){return j$($.runtimeSocket,"revokePeer",M4.parse(X),(Y)=>T6.parse(Y))},async repairPeer(X){return j$($.runtimeSocket,"repairPeer",$6.parse(X),(Y)=>s6.parse(Y))},async appendSessionMessages(X,Y){await j$($.runtimeSocket,"sessionAppendMessages",{sessionId:X,messages:Y},()=>{return})},async markSessionCompleted(X){await j$($.runtimeSocket,"sessionMarkCompleted",{sessionId:X},()=>{return})},async replaceSessionMessages(X,Y){await j$($.runtimeSocket,"sessionReplaceMessages",{sessionId:X,messages:Y},()=>{return})}}}function tK($){let Z=r6.parse($.auth);return{...rK({runtimeSocket:$.runtimeSocket,pollIntervalMs:$.pollIntervalMs}),async sendBestEffort(Y){return j$($.runtimeSocket,"sendBestEffort",G8.parse(Y),(Q)=>n4.parse(Q),Z)},async sendDurable(Y){return j$($.runtimeSocket,"sendDurable",G8.parse(Y),(Q)=>i4.parse(Q),Z)},async submitRun(Y){let Q=j8.parse(Y);return Vp(j$($.runtimeSocket,"submitRun",Q,(G)=>k9.parse(G),Z))},async resumeRun(Y){return j$($.runtimeSocket,"resumeRun",a4.parse(Y),(Q)=>k9.parse(Q),Z)},streamRun(Y,Q){return cN($.runtimeSocket,"streamRun",j8.parse(Y),(G)=>E6.parse(G),Q,Z)},async listAttachedClients(){return j$($.runtimeSocket,"listAttachedClients",void 0,(Y)=>kZ.array().parse(Y),Z)},listDirectClientInbox:async(Y)=>j$($.runtimeSocket,"listDirectClientInbox",r9.optional().parse(Y),(Q)=>c8.array().parse(Q),Z),subscribeDirectClientInbox(Y){return cN($.runtimeSocket,"subscribeDirectClientInbox",E7.optional().parse(Y),(Q)=>c8.parse(Q),void 0,Z)}}}var Wp=E(()=>{W8()});var EG="x-aria-local-client-id",_G="x-aria-local-client-proof";import{existsSync as Hp}from"fs";import{createRequire as nG0}from"module";import{join as iG0}from"path";function zp(){return lC("bun:sqlite")}function Up(){let $=process.env.ARIA_BUN_CUSTOM_SQLITE_PATH?.trim();if($)return Hp($)?$:null;if(process.platform==="darwin"){let J=["/opt/homebrew/opt/sqlite/lib/libsqlite3.dylib","/usr/local/opt/sqlite/lib/libsqlite3.dylib"].find((X)=>Hp(X));if(J)return J}return null}function aC(){let $=globalThis,Z=$[Kp];if(Z&&typeof Z==="object")return Z;let J={attempted:!1};return $[Kp]=J,J}function Bp(){let $=aC();if($.attempted)return;$.attempted=!0;let Z=Up();if(!Z)return;zp().Database.setCustomSQLite?.(Z),$.customPath=Z}function MG(){Bp()}function Fp($){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 oG0($){return{run(...Z){return Fp($.run(...Z))},get(...Z){let J=$.get(...Z);return J===null?void 0:J},all(...Z){return $.all(...Z)}}}function sG0(){return lC("better-sqlite3")}function rG0($){return{run(...Z){let J=$.run(...Z);return{changes:J.changes,lastInsertRowid:J.lastInsertRowid}},get(...Z){return $.get(...Z)},all(...Z){return $.all(...Z)}}}function tG0($){let J=new(sG0())($.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 rG0(J.prepare(X))},transaction(X){return J.transaction(X)},close(){J.close()},loadExtension:J.loadExtension?(X)=>{J.loadExtension(X)}:void 0}}function M7($){let Z;try{Z=zp()}catch(Y){if(process.env.VITEST||process.argv.some((Q)=>Q.includes("vitest"))||process.argv.some((Q)=>Q.includes("vite")))return P7($);throw Error(`[sqlite-open] bun:sqlite failed to load under Bun runtime: ${Y instanceof Error?Y.message:String(Y)}`)}Bp();let J=aC(),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 oG0(Q)},transaction(Y){return X.transaction(Y)},close(){X.close()},loadExtension:X.loadExtension?(Y)=>{X.loadExtension(Y)}:void 0}}function eG0(){return lC("node:sqlite")}function $V0($){return{run(...Z){return Fp($.run(...Z))},get(...Z){return $.get(...Z)},all(...Z){return $.all(...Z)}}}function ZV0($){let{DatabaseSync:Z}=eG0(),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 $V0(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 P7($){try{return tG0($)}catch{return ZV0($)}}function uN(){return Up()}function pN(){return aC().customPath}var lC,Kp="__ARIA_BUN_SQLITE_CONFIG_STATE__";var nC=E(()=>{lC=nG0(iG0(process.cwd(),"__aria_module_loader__.js"))});import Dp from"fs";import JV0 from"os";import Op from"path";function Np($="test.db"){let Z=Dp.mkdtempSync(Op.join(JV0.tmpdir(),"aria-sqlite-test-")),J=Op.join(Z,$),X=P7({path:J});return{db:X,dbPath:J,tempDir:Z,cleanup(){try{X.close()}catch{}Dp.rmSync(Z,{recursive:!0,force:!0})}}}var Lp=E(()=>{nC()});var Ap={};A$(Ap,{openCompatSqliteDatabase:()=>P7,openBunRuntimeSqliteDatabase:()=>M7,getResolvedBunCustomSqlitePath:()=>uN,getConfiguredBunCustomSqlitePath:()=>pN,createTestDatabase:()=>Np,configureBunCustomSqlite:()=>MG});var PG=E(()=>{nC();Lp()});import{createHash as XV0}from"crypto";function e$($,Z){let J=XV0("sha256");if(typeof $==="string")if(Z)J.update($,Z);else J.update($);else J.update($);return J.digest("hex")}var qp=()=>{};import{EventEmitter as YV0}from"events";import{randomUUID as QV0}from"crypto";var FX;var iC=E(()=>{FX=class FX extends YV0{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=QV0(),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 GV0}from"child_process";import{EventEmitter as VV0}from"events";import{PassThrough as WV0,Writable as HV0}from"stream";function Ep($=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 KV0="1.0.
|
|
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 GV0}from"child_process";import{EventEmitter as VV0}from"events";import{PassThrough as WV0,Writable as HV0}from"stream";function Ep($=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 KV0="1.0.61",zV0,B1;var oC=E(()=>{iC();zV0={name:"aria-cli",version:KV0};B1=class B1 extends VV0{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:zV0});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=GV0(this.config.command,this.config.args||[],{env:{...Ep(),...Ep(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 HV0({write:(Y,Q,G)=>{let V=Y.toString();this.postSSEMessages(V).then(()=>G()).catch((W)=>G(W))}}),J=new WV0;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 f90=E(()=>{W8()});var V8=E(()=>{aB();$_();aB();aB();aB();y80();l80();QM();iy();YM();oy();w90();sy();HM();Zv();Jv();Xv();FM();By();Oy();Qv();Gv();b90();Of();UM();Vv();f90();r_();H_();Q_();b0();g80();vy();H90()});import{jsx as GJ,jsxs as LM}from"react/jsx-runtime";import{useState as bT0,useRef as v90}from"react";import{Box as YF,Text as bY,useInput as kT0}from"ink";function Wv({currentLevel:$,onSelect:Z,onCancel:J,isActive:X=!0}){let Y=e(),Q=iZ.indexOf($),G=Q>=0?Q:0,[V,W]=bT0(G),H=v90(G),K=v90(!1),z=(B)=>{W((F)=>{let D=B(F);return H.current=D,D})},U=process.stdin.isTTY??!1;return kT0((B,F)=>{if(K.current)return;if(F.upArrow)z((D)=>Math.max(0,D-1));else if(F.downArrow)z((D)=>Math.min(iZ.length-1,D+1));else if(F.return)K.current=!0,Z(iZ[H.current]);else if(W$(B,F))K.current=!0,J()},{isActive:X&&U}),LM(YF,{flexDirection:"column",borderStyle:"round",borderColor:Y.colors.secondary,paddingX:1,paddingY:1,width:48,children:[GJ(YF,{marginBottom:1,children:GJ(bY,{bold:!0,children:"Autonomy Level"})}),GJ(YF,{marginBottom:1,children:LM(bY,{children:["Current: ",GJ(bY,{bold:!0,children:$})]})}),iZ.map((B,F)=>{let D=F===V,O=D?"\u25CF":"\u25CB",L=B==="high"||B==="full";return LM(YF,{gap:1,children:[GJ(bY,{color:D?Y.colors.primary:void 0,children:O}),GJ(bY,{color:D?Y.colors.primary:L?Y.colors.warning:void 0,bold:D,children:B.padEnd(10)}),GJ(bY,{color:Y.colors.textMuted,children:fT0[B]})]},B)}),GJ(YF,{marginTop:1,children:LM(bY,{color:Y.colors.textMuted,children:["\u2191\u2193"," Navigate Enter Select Esc Cancel"]})})]})}var fT0;var h90=E(()=>{E0();V8();fT0={minimal:"Confirm all tool calls",balanced:"Confirm dangerous only",high:"Auto-approve everything",full:"Auto-approve everything"}});import{jsxs as OA$,jsx as NA$}from"react/jsx-runtime";import{Box as AA$,Text as qA$}from"ink";var x90=E(()=>{E0()});import{jsx as kY,jsxs as AM}from"react/jsx-runtime";import{Box as qM,Text as fY}from"ink";function hT0($){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 g90($,Z,J){let X=Math.round(Z*$),Y=Math.max(yT0,Math.round(J*$)),Q=Math.max(0,$-X-Y);return"\u2591".repeat(X)+"\u2588".repeat(Y)+"\u2591".repeat(Q)}function Kv({spans:$,width:Z}){let J=e(),X=Z??vT0,Y=$.filter((K)=>K.endTime!==void 0||K.durationMs!==void 0);if(Y.length===0)return kY(qM,{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(qM,{flexDirection:"column",children:Q.map((K)=>AM(fY,{dimColor:!0,children:[Hv[K.spanType]??K.spanType," ","\u2588"," 0ms (",K.name,")"]},K.spanId))});let H=Math.max(...Q.map((K)=>{let z=Hv[K.spanType]??K.spanType;return(K.parentSpanId!==void 0?2:0)+z.length}));return kY(qM,{flexDirection:"column",children:Q.map((K)=>{let z=K.parentSpanId!==void 0,U=z?" ":"",B=Hv[K.spanType]??K.spanType,F=(U+B).padEnd(H),D=(K.startTime-G)/W,O=K.durationMs/W,L=g90(X,D,O),q=hT0(K.durationMs),A=K.spanType==="tool_execution"&&K.name?` (${K.name})`:"";return AM(qM,{children:[AM(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:" "}),AM(fY,{dimColor:!0,children:[q,A]})]},K.spanId)})})}var yT0=1,vT0=20,Hv;var m90=E(()=>{E0();Hv={model_call:"model_call",tool_execution:"tool_exec",handoff:"handoff",approval:"approval",session_phase:"session",runner_phase:"runner"}});import{jsxs as tW}from"react/jsx-runtime";import{Box as c90,Text as EM}from"ink";function u90($){if($<1000)return`${Math.round($)}ms`;return`${($/1000).toFixed(2)}s`}function zv({report:$}){let Z=e();if(!$||$.phases.length===0)return null;return tW(c90,{flexDirection:"column",marginTop:1,children:[tW(EM,{color:Z.colors.textMuted,children:[" Pipeline timing (",u90($.totalMs),")"]}),$.phases.map((J)=>tW(c90,{children:[tW(EM,{color:Z.colors.info,children:[" ",J.phase.padEnd(24)]}),tW(EM,{color:Z.colors.text,children:[" ",u90(J.durationMs)]}),tW(EM,{color:Z.colors.textMuted,children:[" (",J.pct,"%)"]})]},`${J.phase}:${J.durationMs}`))]})}var p90=E(()=>{E0()});import{jsxs as d90,jsx as xT0}from"react/jsx-runtime";import{useRef as gT0}from"react";import{Box as mT0,Text as l90}from"ink";import cT0 from"gradient-string";function n90($){if($<60)return`${$}s`;let Z=Math.floor($/60),J=$%60;return`${Z}m ${J}s`}function uT0($){if($>=1000)return`${($/1000).toFixed(1)}k tokens`;return`${$} tokens`}function Bv({state:$,elapsedSeconds:Z,totalTokens:J,thoughtForSeconds:X,currentVerb:Y}){let Q=[...a90,...[...a90].reverse()],G=Math.floor(Date.now()/120)%Q.length,V=gT0(j1().present),W=Y||V.current,H=e(),K=G%Uv.length,z=[...Uv.slice(K),...Uv.slice(0,K)],U=cT0(z),B=`${Q[G]} ${W}\u2026`,F=U(B),D=n90(Z),O=uT0(J),L;if($==="thinking")L="(thinking)";else if(X&&X>0)L=`(${D} \xB7 \u2193 ${O} \xB7 thought for ${n90(X)})`;else L=`(${D} \xB7 \u2193 ${O} \xB7 esc to cancel)`;return d90(mT0,{flexDirection:"row",marginTop:1,children:[d90(l90,{children:[F," "]}),xT0(l90,{color:H.colors.textMuted,children:L})]})}var Uv,a90;var i90=E(()=>{E0();EV();Uv=["#5f97cd","#7baed4","#97c4db","#7baed4"],a90=process.platform==="darwin"?["\xB7","\u2722","\u2733","\u2217","\u273B","\u273D"]:["\xB7","\u2722","*","\u2217","\u273B","\u273D"]});import{jsxs as s90,jsx as o90}from"react/jsx-runtime";import{Box as pT0,Text as r90}from"ink";function Fv($){return $>=70?"high":$>=30?"moderate":"low"}function dT0($){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 Z5($){if($===null)return e().colors.primary;let Z=Fv($);return dT0(Z).textColor}function lT0({riskScore:$}){let Z=Fv($);return s90(r90,{color:Z5($),children:["Risk: ",Z]})}function c1({title:$,riskScore:Z}){return s90(pT0,{flexDirection:"column",children:[o90(r90,{bold:!0,color:e().colors.primary,children:$}),Z!==null&&o90(lT0,{riskScore:Z})]})}var yY=E(()=>{E0()});function J5($,Z){}import{structuredPatch as aT0}from"diff";function _M($,Z,J,X=3){let Y=aT0($,$,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 Dv=()=>{};import{jsx as MM,jsxs as nT0}from"react/jsx-runtime";import{existsSync as iT0,readFileSync as oT0}from"fs";import{useMemo as t90}from"react";import{Box as Ov,Text as sT0}from"ink";import{relative as rT0}from"path";function e90({file_path:$,new_string:Z,old_string:J,verbose:X,useBorder:Y=!0,width:Q}){let G=t90(()=>iT0($)?oT0($,"utf8"):"",[$]),V=t90(()=>{let W=G.replace(J,Z);return _M($,G,W)},[$,G,J,Z]);return MM(Ov,{flexDirection:"column",children:nT0(Ov,{borderColor:e().colors.secondary,borderStyle:Y?"round":void 0,flexDirection:"column",paddingX:1,children:[MM(Ov,{paddingBottom:1,children:MM(sT0,{bold:!0,children:X?$:rT0(process.cwd(),$)})}),MM(vX,{diff:V,dim:!1,width:Q,showHeader:!1})]})})}var $40=E(()=>{TV();E0();Dv()});import{jsx as Nv,jsxs as tT0}from"react/jsx-runtime";import{Box as eT0,Text as Lv}from"ink";function Z40({isFocused:$,isSelected:Z,smallPointer:J,children:X}){let Y=e();return tT0(eT0,{gap:1,children:[$&&Nv(Lv,{color:Y.colors.primary,children:J?ZC0:$C0}),Nv(Lv,{color:$?Y.colors.primary:void 0,bold:Z,children:X}),Z&&Nv(Lv,{color:Y.colors.success,children:JC0})]})}var $C0="\u276F",ZC0="\u25BE",JC0="\u2714";var J40=E(()=>{E0()});var PM;var X40=E(()=>{VJ();PM=class PM 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:Av(Q);Z.push([V,G]),Y++,X=G}super(Z);this.first=J}}});import{isDeepStrictEqual as XC0}from"util";import{useReducer as YC0,useCallback as qv,useMemo as QC0,useState as GC0,useEffect as Ev}from"react";var VC0=($,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}}},_v=($)=>$.flatMap((Z)=>{if("options"in Z){let J=_v(Z.options),X=J.flatMap((Q)=>("value"in Q)?Q.value:[]);return[...Z.header!==void 0?[{header:Z.header,optionValues:X}]:[],...J]}return Z}),Y40=({visibleOptionCount:$,defaultValue:Z,options:J})=>{let X=_v(J),Y=typeof $==="number"?Math.min($,X.length):X.length,Q=new PM(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}},Q40=({visibleOptionCount:$=5,options:Z,defaultValue:J,onChange:X,onFocus:Y,focusValue:Q})=>{let G=_v(Z),[V,W]=YC0(VC0,{visibleOptionCount:$,defaultValue:J,options:Z},Y40),[H,K]=GC0(G);if(G!==H&&!XC0(G,H))W({type:"reset",state:Y40({visibleOptionCount:$,defaultValue:J,options:Z})}),K(G);let z=qv(()=>{W({type:"focus-next-option"})},[]),U=qv(()=>{W({type:"focus-previous-option"})},[]),B=qv(()=>{W({type:"select-focused-option"})},[]),F=QC0(()=>{return G.map((D,O)=>({...D,index:O})).slice(V.visibleFromIndex,V.visibleToIndex)},[G,V.visibleFromIndex,V.visibleToIndex]);return Ev(()=>{if(V.value&&V.previousValue!==V.value)X?.(V.value)},[V.previousValue,V.value,Z,X]),Ev(()=>{if(V.focusedValue)Y?.(V.focusedValue)},[V.focusedValue,Y]),Ev(()=>{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 G40=E(()=>{X40()});import{useInput as WC0}from"ink";var V40=({isDisabled:$=!1,state:Z})=>{WC0((J,X)=>{if(X.downArrow)Z.focusNextOption();if(X.upArrow)Z.focusPreviousOption();if(X.return)Z.selectFocusedOption()},{isActive:!$})};var W40=()=>{};import{jsx as Mv,Fragment as HC0,jsxs as KC0}from"react/jsx-runtime";import{Box as zC0,Text as UC0}from"ink";function u1({isDisabled:$=!1,visibleOptionCount:Z=5,highlightText:J,options:X,defaultValue:Y,onChange:Q,onFocus:G,focusValue:V}){let W=Q40({visibleOptionCount:Z,options:X,defaultValue:Y,onChange:Q,onFocus:G,focusValue:V});V40({isDisabled:$,state:W});let H=e();return Mv(zC0,{flexDirection:"column",children:W.visibleOptions.map((K)=>{let z="value"in K?K.value:Av(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=KC0(HC0,{children:[D.slice(0,L),Mv(UC0,{color:H.colors.primary,bold:!0,children:J}),D.slice(L+J.length)]})}return Mv(Z40,{isFocused:U,isSelected:B,smallPointer:F,children:O},z)})})}var Av=($)=>`HEADER-${$.optionValues.join(",")}`;var VJ=E(()=>{J40();G40();W40();E0()});import{jsx as jM,jsxs as Pv}from"react/jsx-runtime";import{Box as H40,Text as K40}from"ink";import{useMemo as BC0}from"react";import{basename as FC0,extname as DC0,isAbsolute as OC0,resolve as jv}from"path";import NC0 from"chalk";function LC0($){return(OC0($)?jv($):jv(process.cwd(),$)).startsWith(jv(process.cwd()))}function AC0($){let Z=LC0($)?[{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 (${NC0.bold.hex(e().colors.warning)("esc")})`,value:"no"}]}function z40({toolUseConfirm:$,onDone:Z,verbose:J}){let{columns:X}=Y9(),{file_path:Y,new_string:Q,old_string:G}=$.input,V=BC0(()=>({completion_type:"str_replace_single",language_name:qC0(Y)}),[Y]);return J5($,V),Pv(H40,{flexDirection:"column",borderStyle:"round",borderColor:Z5($.riskScore),marginTop:1,paddingLeft:1,paddingRight:1,paddingBottom:1,children:[jM(c1,{title:"Edit file",riskScore:$.riskScore}),jM(e90,{file_path:Y,new_string:Q,old_string:G,verbose:J,width:X-12}),Pv(H40,{flexDirection:"column",children:[Pv(K40,{children:["Do you want to make this edit to ",jM(K40,{bold:!0,children:FC0(Y)}),"?"]}),jM(u1,{options:AC0(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 qC0($){let Z=DC0($);return Z?Z.slice(1):"unknown"}var U40=E(()=>{E0();yY();$40();P1();VJ()});import QF from"chalk";function EC0($){let J=$.replace(/'[^']*'/g,"").replace(/"[^"]*"/g,"");if(/&&|\|\||[;|]/.test(J))return!0;if(/`/.test(J))return!0;if(/\$\(/.test(J))return!0;return!1}function B40({toolUseConfirm:$,command:Z}){let J=!EC0(Z)&&$.commandPrefix&&!$.commandPrefix.commandInjectionDetected,X=GF($),Y=J&&X!==null,Q=[];if(Y)Q=[{label:`Yes, and don't ask again for ${QF.bold(X)} commands in ${QF.bold(process.cwd())}`,value:"yes-dont-ask-again-prefix"}];else if(J)Q=[{label:`Yes, and don't ask again for ${QF.bold(Z)} commands in ${QF.bold(process.cwd())}`,value:"yes-dont-ask-again-full"}];return[{label:"Yes",value:"yes"},...Q,{label:`No, and provide instructions (${QF.bold.hex(e().colors.warning)("esc")})`,value:"no"}]}var F40=E(()=>{VF();E0()});import{jsx as WF,jsxs as Tv}from"react/jsx-runtime";import{Box as Cv,Text as Rv}from"ink";import{useMemo as _C0}from"react";function D40({toolUseConfirm:$,onDone:Z}){let J=e(),{command:X}=$.tool.inputSchema.parse($.input),Y=_C0(()=>({completion_type:"tool_use_single",language_name:"none"}),[]);return J5($,Y),Tv(Cv,{flexDirection:"column",borderStyle:"round",borderColor:J.colors.primary,marginTop:1,paddingLeft:1,paddingRight:1,paddingBottom:1,children:[WF(c1,{title:"Bash command",riskScore:$.riskScore}),Tv(Cv,{flexDirection:"column",paddingX:2,paddingY:1,children:[WF(Rv,{children:$.tool.renderToolUseMessage({command:X},{verbose:!1})}),WF(Rv,{color:J.colors.textMuted,children:$.description})]}),Tv(Cv,{flexDirection:"column",children:[WF(Rv,{children:"Do you want to proceed?"}),WF(u1,{options:B40({toolUseConfirm:$,command:X}),onChange:(Q)=>{switch(Q){case"yes":$.onAllow("temporary"),Z();break;case"yes-dont-ask-again-prefix":{if(GF($)!==null)$.onAllow("permanent");else $.onAllow("temporary");Z();break}case"yes-dont-ask-again-full":$.onAllow("permanent"),Z();break;case"no":$.onReject(),Z();break}}})]})]})}var O40=E(()=>{E0();VF();yY();VJ();F40()});import{jsx as HF,jsxs as TM}from"react/jsx-runtime";import{Box as wv,Text as CM}from"ink";import{useMemo as MC0}from"react";import Sv from"chalk";function RM({toolUseConfirm:$,onDone:Z,verbose:J}){let X=e(),Y=$.tool.userFacingName($.input),Q=Y.endsWith(" (MCP)")?Y.slice(0,-6):Y,G=MC0(()=>({completion_type:"tool_use_single",language_name:"none"}),[]);return J5($,G),TM(wv,{flexDirection:"column",borderStyle:"round",borderColor:Z5($.riskScore),marginTop:1,paddingLeft:1,paddingRight:1,paddingBottom:1,children:[HF(c1,{title:"Tool use",riskScore:$.riskScore}),TM(wv,{flexDirection:"column",paddingX:2,paddingY:1,children:[TM(CM,{children:[Q,"(",$.tool.renderToolUseMessage($.input,{verbose:J}),")",Y.endsWith(" (MCP)")?HF(CM,{color:X.colors.textMuted,children:" (MCP)"}):""]}),HF(CM,{color:X.colors.textMuted,children:$.description})]}),TM(wv,{flexDirection:"column",children:[HF(CM,{children:"Do you want to proceed?"}),HF(u1,{options:[{label:"Yes",value:"yes"},{label:`Yes, and don't ask again for ${Sv.bold(Q)} commands in ${Sv.bold(process.cwd())}`,value:"yes-dont-ask-again"},{label:`No, and provide instructions (${Sv.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 Iv=E(()=>{E0();yY();VJ()});import{jsx as wM,jsxs as PC0}from"react/jsx-runtime";import{existsSync as jC0,readFileSync as TC0}from"fs";import{useMemo as bv}from"react";import{Box as N40,Text as CC0}from"ink";import{extname as RC0,relative as wC0}from"path";function L40({file_path:$,content:Z,verbose:J,width:X}){let Y=bv(()=>jC0($),[$]),Q=bv(()=>{if(!Y)return"";return TC0($,"utf8")},[$,Y]),G=bv(()=>{if(!Y)return null;return _M($,Q,Z)},[Y,$,Q,Z]);return PC0(N40,{borderColor:e().colors.secondary,borderStyle:"round",flexDirection:"column",paddingX:1,children:[wM(N40,{paddingBottom:1,children:wM(CC0,{bold:!0,children:J?$:wC0(process.cwd(),$)})}),G?wM(vX,{diff:G,dim:!1,width:X,showHeader:!1}):wM(C1,{code:Z||"(No content)",language:RC0($).slice(1)})]})}var A40=E(()=>{TV();E0();RV();Dv()});import{jsx as KF,jsxs as kv}from"react/jsx-runtime";import{Box as fv,Text as q40}from"ink";import{useMemo as E40}from"react";import{basename as SC0,extname as IC0}from"path";import{existsSync as bC0}from"fs";import kC0 from"chalk";function _40({toolUseConfirm:$,onDone:Z,verbose:J}){let{file_path:X,content:Y}=$.input,Q=E40(()=>bC0(X),[X]),G=E40(()=>({completion_type:"write_file_single",language_name:fC0(X)}),[X]),{columns:V}=Y9();return J5($,G),kv(fv,{flexDirection:"column",borderStyle:"round",borderColor:Z5($.riskScore),marginTop:1,paddingLeft:1,paddingRight:1,paddingBottom:1,children:[KF(c1,{title:`${Q?"Edit":"Create"} file`,riskScore:$.riskScore}),KF(fv,{flexDirection:"column",children:KF(L40,{file_path:X,content:Y,verbose:J,width:V-12})}),kv(fv,{flexDirection:"column",children:[kv(q40,{children:["Do you want to ",Q?"make this edit to":"create"," ",KF(q40,{bold:!0,children:SC0(X)}),"?"]}),KF(u1,{options:[{label:"Yes",value:"yes"},{label:"Yes, and don't ask again this session",value:"yes-dont-ask-again"},{label:`No, and provide instructions (${kC0.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 fC0($){let Z=IC0($);return Z?Z.slice(1):"unknown"}var M40=E(()=>{E0();yY();A40();P1();VJ()});import{jsx as eW,jsxs as yv}from"react/jsx-runtime";import{Box as vv,Text as P40}from"ink";import{useMemo as yC0}from"react";import vC0 from"chalk";import{isAbsolute as hC0,resolve as j40}from"path";function SM($){return hC0($)?j40($):j40(process.cwd(),$)}function xC0($){return SM($).startsWith(SM(process.cwd()))}function mC0(){gC0=!0}function lC0($){let Z=$.tool.name;if(cC0.has(Z))return"file_path";if(uC0.has(Z))return"path";if(pC0.has(Z))return"notebook_path";return null}function aC0($){return dC0.has($.tool.name)}function nC0($){let Z=lC0($),J=$.input;if(Z&&Z in J)if(typeof J[Z]==="string")return SM(J[Z]);else return SM(process.cwd());return null}function T40({toolUseConfirm:$,onDone:Z,verbose:J}){let X=nC0($);if(!X)return eW(RM,{toolUseConfirm:$,onDone:Z,verbose:J});return eW(oC0,{toolUseConfirm:$,path:X,onDone:Z,verbose:J})}function iC0($,Z){if($.tool.isReadOnly())return[];return xC0(Z)?[{label:"Yes, and don't ask again for file edits this session",value:"yes-dont-ask-again"}]:[]}function oC0({toolUseConfirm:$,path:Z,onDone:J,verbose:X}){let Y=$.tool.userFacingName($.input),G=`${$.tool.isReadOnly()?"Read":"Edit"} ${aC0($)?"files":"file"}`,V=yC0(()=>({completion_type:"tool_use_single",language_name:"none"}),[]);return J5($,V),yv(vv,{flexDirection:"column",borderStyle:"round",borderColor:Z5($.riskScore),marginTop:1,paddingLeft:1,paddingRight:1,paddingBottom:1,children:[eW(c1,{title:G,riskScore:$.riskScore}),eW(vv,{flexDirection:"column",paddingX:2,paddingY:1,children:yv(P40,{children:[Y,"(",$.tool.renderToolUseMessage($.input,{verbose:X}),")"]})}),yv(vv,{flexDirection:"column",children:[eW(P40,{children:"Do you want to proceed?"}),eW(u1,{options:[{label:"Yes",value:"yes"},...iC0($,Z),{label:`No, and provide instructions (${vC0.bold.hex(e().colors.warning)("esc")})`,value:"no"}],onChange:(W)=>{switch(W){case"yes":$.onAllow("temporary"),J();break;case"yes-dont-ask-again":mC0(),$.onAllow("permanent"),J();break;case"no":$.onReject(),J();break}}})]})]})}var gC0=!1,cC0,uC0,pC0,dC0;var C40=E(()=>{E0();yY();Iv();VJ();cC0=new Set(["Edit","file_edit","str_replace_editor","Write","file_write","create_file","Read","file_read","read_file"]),uC0=new Set(["Glob","glob","Grep","grep","LS","ls"]),pC0=new Set(["NotebookEdit","notebook_edit","NotebookRead","notebook_read"]),dC0=new Set(["Glob","glob","Grep","grep","LS","ls"])});import{jsx as sC0}from"react/jsx-runtime";import{useInput as rC0}from"ink";import*as R40 from"react";function JR0($){if(tC0.has($))return z40;if(eC0.has($))return _40;if($R0.has($))return D40;if(ZR0.has($))return T40;return RM}function GF($){return $.commandPrefix&&!$.commandPrefix.commandInjectionDetected&&$.commandPrefix.commandPrefix||null}function hv({toolUseConfirm:$,onDone:Z,verbose:J}){let X=R40.useRef(!1);rC0((Q,G)=>{if(X.current)return;if(G.ctrl&&Q==="c"||W$(Q,G))X.current=!0,$.onReject(),Z()});let Y=JR0($.tool.name);return sC0(Y,{toolUseConfirm:$,onDone:Z,verbose:J})}var tC0,eC0,$R0,ZR0;var VF=E(()=>{U40();O40();Iv();M40();C40();tC0=new Set(["Edit","file_edit","str_replace_editor"]),eC0=new Set(["Write","file_write","create_file"]),$R0=new Set(["Bash","bash","execute_command"]),ZR0=new Set(["Glob","glob","Grep","grep","LS","ls","Read","file_read","read_file","NotebookRead","notebook_read","NotebookEdit","notebook_edit"])});import{jsx as IM,jsxs as $H}from"react/jsx-runtime";import{useState as w40,useEffect as S40}from"react";import{Box as bM,Text as ZH,useInput as XR0}from"ink";function xv($){return/\s/.test($.trimStart())}function YR0($){return $.trimStart().split(/\s+/,1)[0]??""}function gv({commands:$,initialFilter:Z="",onSelect:J,onHandOffInput:X,onCancel:Y}){let[Q,G]=w40(0),[V,W]=w40(Z),H=YR0(V).toLowerCase(),K=$.filter((B)=>B.name.toLowerCase().includes(H));S40(()=>{G((B)=>Math.min(B,Math.max(0,K.length-1)))},[K.length]),S40(()=>{if(!X||!xv(V))return;X(`/${V}`)},[V,X]);let z=K.length>0?Math.min(Q,K.length-1):0,U=process.stdin.isTTY??!1;return XR0((B,F)=>{if(W$(B,F)){Y();return}if(F.return&&xv(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&&xv(D)){X(`/${D}`);return}W(D)}},{isActive:U}),$H(bM,{flexDirection:"column",borderStyle:"round",borderColor:"gray",paddingX:1,children:[$H(bM,{marginBottom:1,children:[IM(ZH,{bold:!0,children:"Commands"}),V&&$H(ZH,{dimColor:!0,children:[" /",V]})]}),K.map((B,F)=>$H(bM,{children:[$H(ZH,{inverse:F===z,children:["/",B.name]}),$H(ZH,{dimColor:!0,children:[" ",B.description]})]},B.name)),K.length===0&&IM(ZH,{dimColor:!0,children:"No matching commands"}),IM(bM,{marginTop:1,children:IM(ZH,{dimColor:!0,children:"\u2191\u2193 navigate \u23CE select esc cancel"})})]})}var I40=()=>{};import{jsx as zF,jsxs as JH}from"react/jsx-runtime";import{useState as b40,useEffect as QR0}from"react";import{Box as kM,Text as vY,useInput as GR0}from"ink";function mv({arions:$,initialFilter:Z="",statusFilter:J="all",onSelect:X,onCancel:Y}){let[Q,G]=b40(0),[V,W]=b40(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())});QR0(()=>{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 GR0((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}),JH(kM,{flexDirection:"column",borderStyle:"round",borderColor:"gray",paddingX:1,children:[JH(kM,{marginBottom:1,children:[zF(vY,{bold:!0,children:J==="active"?"Active Arions":J==="resting"?"Resting Arions":"Arions"}),V&&JH(vY,{dimColor:!0,children:[" @",V]})]}),H.length===0&&zF(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=ez(U.color),D=U.isActive?" (active)":U.isResting?" (resting)":"";return JH(kM,{children:[JH(vY,{inverse:B===K,children:[U.emoji," ",zF(vY,{color:F,children:U.name})]}),JH(vY,{dimColor:!0,children:[" ",U.description,D]})]},U.name)}),zF(kM,{marginTop:1,children:zF(vY,{dimColor:!0,children:"\u2191\u2193 navigate \u23CE select esc cancel"})})]})}var k40=E(()=>{UV()});import{jsx as LZ,jsxs as p1}from"react/jsx-runtime";import{useState as cv,useEffect as VR0,useMemo as WR0}from"react";import{Box as WJ,Text as y4,useInput as HR0}from"ink";function zR0($){return KR0[$]||$}function y40($){let Z=f40.indexOf($);return Z>=0?Z:f40.length}function UR0($,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])=>y40(G)-y40(V));for(let[G,V]of Q){Z.push({type:"header",label:zR0(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 uv({models:$,initialFilter:Z="",effortLevel:J,onSelect:X,onCancel:Y}){let[Q,G]=cv(Z),[V,W]=cv(J??"high"),K=$.filter((A)=>A.name.toLowerCase().includes(Q.toLowerCase())),{items:z,selectableIndices:U}=WR0(()=>{if(!K.some((M)=>M.provider))return{items:K.map((M)=>({type:"model",model:M})),selectableIndices:K.map((M,T)=>T)};let N=[],_=[];return UR0(K,N,_),{items:N,selectableIndices:_}},[K]),B=U.findIndex((A)=>{let N=z[A];return N?.type==="model"&&N.model.isCurrent}),[F,D]=cv(B>=0?B:0);VR0(()=>{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;HR0((A,N)=>{if(W$(A,N)){Y();return}if(N.return&&U.length>0){let _=U[O],M=z[_];if(M.type==="model")X(M.model,V);return}if(N.leftArrow){W((_)=>{let M=UF.indexOf(_);return UF[Math.max(0,M-1)]});return}if(N.rightArrow){W((_)=>{let M=UF.indexOf(_);return UF[Math.min(UF.length-1,M+1)]});return}if(N.upArrow){D((_)=>Math.max(0,_-1));return}if(N.downArrow){D((_)=>Math.min(U.length-1,_+1));return}if(N.backspace||N.delete){G((_)=>_.slice(0,-1));return}if(A&&!N.ctrl&&!N.meta)G((_)=>_+A)},{isActive:L});let q=U.length>0?` [${O+1}/${U.length}]`:"";return p1(WJ,{flexDirection:"column",borderStyle:"round",borderColor:"gray",paddingX:1,children:[p1(WJ,{marginBottom:1,children:[LZ(y4,{bold:!0,children:"Model"}),LZ(y4,{dimColor:!0,children:q}),LZ(y4,{children:" "}),Q?LZ(y4,{color:"cyan",children:Q}):LZ(y4,{dimColor:!0,children:"Type to search..."})]}),K.length===0&&LZ(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=Ca(N.provider);return p1(WJ,{marginTop:_>0?1:0,children:[p1(y4,{color:a.color,children:[a.icon," "]}),LZ(y4,{bold:!0,color:a.color,children:N.label})]},`header-${N.label}-${_}`)}if(N.type==="hint")return LZ(WJ,{marginTop:1,children:LZ(y4,{dimColor:!0,italic:!0,children:N.label})},"hint");let M=U[O]===_,T=N.model.description,k=N.model.name.padEnd(A),R=HA(N.model.name);return p1(WJ,{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(WJ,{marginTop:1,flexDirection:"column",children:[p1(WJ,{children:[p1(y4,{color:v40[V],children:[BR0[V]," "]}),p1(y4,{color:v40[V],bold:!0,children:[FR0[V]," effort"]}),V==="high"&&LZ(y4,{dimColor:!0,children:" (default)"}),LZ(y4,{dimColor:!0,children:" \u2190 \u2192 to adjust"})]}),LZ(WJ,{marginTop:0,children:LZ(y4,{dimColor:!0,children:"\u2191\u2193 navigate \u2190 \u2192 effort \u23CE select esc cancel"})})]})]})}var KR0,f40,UF,BR0,FR0,v40;var h40=E(()=>{UV();KR0={anthropic:"Anthropic","openai-codex":"OpenAI Codex",google:"Google",bedrock:"AWS Bedrock","bedrock-converse":"AWS Bedrock (Converse)","github-copilot":"GitHub Copilot",openai:"OpenAI",local:"Local"},f40=["anthropic","openai-codex","google","bedrock","bedrock-converse","github-copilot","openai","local"];UF=["low","medium","high","max"],BR0={low:"\u258C",medium:"\u258C\u258C",high:"\u258C\u258C\u258C",max:"\u258C\u258C\u258C\u258C"},FR0={low:"Low",medium:"Medium",high:"High",max:"Max"},v40={low:"blue",medium:"cyan",high:"yellow",max:"magenta"}});import{jsx as HJ,jsxs as X5}from"react/jsx-runtime";import{useState as pv,useEffect as DR0}from"react";import{Box as XH,Text as d1,useInput as OR0}from"ink";import NR0 from"ink-spinner";function dv({memories:$,mode:Z="browse",isLoading:J=!1,onSelect:X,onCancel:Y}){let[Q,G]=pv(0),[V,W]=pv(""),[H,K]=pv(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);DR0(()=>{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;OR0((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 X5(XH,{flexDirection:"column",borderStyle:"round",borderColor:Z==="forget"?"red":"cyan",paddingX:1,children:[X5(XH,{marginBottom:1,children:[HJ(d1,{bold:!0,color:Z==="forget"?"red":"cyan",children:Z==="forget"?"Select Memory to Delete":"Memories"}),V&&X5(d1,{dimColor:!0,children:[' (filter: "',V,'")']}),X5(d1,{dimColor:!0,children:[" - ",U.length," memories"]})]}),J&&X5(XH,{children:[HJ(d1,{color:"cyan",children:HJ(NR0,{type:"dots"})}),HJ(d1,{dimColor:!0,children:" Loading memories..."})]}),!J&&U.length===0&&HJ(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 X5(XH,{flexDirection:"row",children:[X5(d1,{inverse:M,children:[M?">":" "," ",k]}),X5(d1,{dimColor:!0,children:[" [",T,"]"]}),N.network&&X5(d1,{dimColor:!0,children:[" (",N.network,")"]})]},N.id)}),!J&&B>1&&HJ(XH,{marginTop:1,children:X5(d1,{dimColor:!0,children:["Page ",H+1,"/",B]})}),HJ(XH,{marginTop:1,children:HJ(d1,{dimColor:!0,children:Z==="forget"?"type to filter arrows navigate enter delete esc cancel":"type to filter arrows navigate esc close"})})]})}var x40=()=>{};import{jsx as BF,jsxs as Y5}from"react/jsx-runtime";import{useState as lv,useEffect as g40}from"react";import{Box as YH,Text as z2,useInput as LR0}from"ink";function AR0($){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 av({sessions:$,onSelect:Z,onCancel:J,onSearch:X,onPageChange:Y}){let{columns:Q}=Y9(),[G,V]=lv(0),[W,H]=lv(""),[K,z]=lv(0),U=8,B=Math.max(1,Math.ceil($.length/8)),F=$.slice(K*8,(K+1)*8);g40(()=>{V((A)=>Math.min(A,Math.max(0,F.length-1)))},[F.length]),g40(()=>{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;LR0((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 Y5(YH,{flexDirection:"column",borderStyle:"round",borderColor:"cyan",paddingX:1,children:[Y5(YH,{marginBottom:1,children:[BF(z2,{bold:!0,color:"cyan",children:"Sessions"}),W&&Y5(z2,{dimColor:!0,children:[' (filter: "',W,'")']}),Y5(z2,{dimColor:!0,children:[" - ",$.length," sessions"]})]}),$.length===0?BF(z2,{dimColor:!0,children:W?"No sessions match your filter.":"No sessions yet."}):F.map((A,N)=>{let _=N===D,M=AR0(A.updatedAt),T=A.title??A.preview??"Untitled session",k=K*8+N;return Y5(YH,{flexDirection:"column",marginBottom:N<F.length-1?1:0,children:[Y5(YH,{flexDirection:"row",children:[Y5(z2,{inverse:_,children:[_?">":" "," ",k+1,". ",L(T,q)]}),Y5(z2,{dimColor:!0,children:[" [",M,"]"]})]}),Y5(z2,{dimColor:!0,children:[" ",A.arion," | ",A.model," | ",A.messageCount," messages"]})]},A.id)}),$.length>0&&B>1&&BF(YH,{marginTop:1,children:Y5(z2,{dimColor:!0,children:["Page ",K+1,"/",B]})}),BF(YH,{marginTop:1,children:BF(z2,{dimColor:!0,children:"type to search arrows navigate enter resume esc cancel"})})]})}var m40=E(()=>{P1()});import{jsx as FF,jsxs as hY}from"react/jsx-runtime";import{useState as nv,useEffect as fM,useMemo as qR0}from"react";import{Box as yM,Text as KJ,useInput as ER0}from"ink";function _R0($,Z){if($.length<=Z)return $;return $.slice(0,Z-3)+"\u2026"}function MR0($){switch($){case"user":return"\uD83D\uDC64";case"assistant":return"\uD83E\uDD16";case"system":return"\u2699\uFE0F";case"tool":return"\uD83D\uDD27";default:return" "}}function PR0($){switch($){case"user":return"cyan";case"assistant":return"green";case"system":return"yellow";case"tool":return"gray";default:return"white"}}function iv({messages:$,onSelect:Z,onCancel:J}){let{columns:X,rows:Y}=Y9(),[Q,G]=nv(0),[V,W]=nv(""),H=qR0(()=>{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]);fM(()=>{G((L)=>Math.min(L,Math.max(0,H.length-1)))},[H.length]),fM(()=>{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]=nv(0);fM(()=>{if(Q<z)U(Q);else if(Q>=z+K)U(Q-K+1)},[Q,K,z]),fM(()=>{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;ER0((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(yM,{flexDirection:"column",borderStyle:"round",borderColor:"cyan",paddingX:1,children:[hY(yM,{marginBottom:1,children:[FF(KJ,{bold:!0,color:"cyan",children:"Edit Message"}),V?hY(KJ,{dimColor:!0,children:[" ",'(search: "',V,'") \u2014 ',H.length,"/",$.length," messages"]}):hY(KJ,{dimColor:!0,children:[" \u2014 ",$.length," messages \xB7 select a user message to edit"]})]}),z>0&&hY(KJ,{dimColor:!0,children:[" \u2191 ",z," more above"]}),H.length===0?FF(KJ,{dimColor:!0,children:V?`No messages match "${V}".`:"No messages."}):B.map((L,q)=>{let N=z+q===F,_=L.role==="user",M=MR0(L.role),T=PR0(L.role),k=N?"\u276F":" ",R=_R0(L.text.replace(/\n/g," ").trim()||"(empty)",O);return FF(yM,{flexDirection:"row",children:hY(KJ,{inverse:N,color:N?void 0:T,dimColor:!_&&!N,bold:_,children:[k," ",M," ",R]})},`${L.index}-${q}`)}),z+K<H.length&&hY(KJ,{dimColor:!0,children:[" \u2193 ",H.length-z-K," more below"]}),FF(yM,{marginTop:1,children:FF(KJ,{dimColor:!0,children:"type to search \xB7 \u2191\u2193 navigate \xB7 enter select user message \xB7 esc cancel"})})]})}var c40=E(()=>{P1()});import{jsx as Q$,jsxs as l9}from"react/jsx-runtime";import jR0,{useState as TR0,useMemo as ov}from"react";import{Box as d9,Text as F$,useInput as CR0}from"ink";function u40($){if($.includes("daltonized")||$.includes("accessible"))return"accessible";if($.startsWith("claude-"))return"claude";return"standard"}function SR0($){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 IR0($){return b7().map((Z)=>{let J=BA(Z);return{name:Z,displayName:J.displayName,isCurrent:Z===$,isLight:SR0(J),category:u40(Z)}})}function bR0({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 kR0({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$(bR0,{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 sv({onSelect:$,onCancel:Z}){let J=ov(()=>e().name,[]),X=ov(()=>IR0(J),[J]),{items:Y,selectableIndices:Q}=ov(()=>{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 wR0){let A=L.get(q);if(!A?.length)continue;D.push({type:"header",label:RR0[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]=TR0(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)I7(z);let U=jR0.useCallback(()=>{I7(J),Z()},[J,Z]),B=process.stdin.isTTY??!1;CR0((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$(kR0,{theme:F})})]}),Q$(d9,{marginTop:1,children:l9(F$,{color:F.colors.textMuted,children:["\u2191\u2193"," navigate ","\u23CE"," select esc cancel"]})})]})}var RR0,wR0;var p40=E(()=>{E0();RR0={standard:"Standard",claude:"Claude",accessible:"Accessible"},wR0=["standard","claude","accessible"]});import{jsxs as xY,jsx as vM}from"react/jsx-runtime";import{useState as d40,useEffect as fR0,useMemo as yR0}from"react";import{Box as rv,Text as zJ,useInput as vR0}from"ink";function hR0($,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 tv($,Z){if(Z<=0)return 0;return Math.min($,Z-1)}function ev({peers:$,sameHomeClientsAvailable:Z=!1,onSelect:J,onCancel:X}){let[Y,Q]=d40(0),[G,V]=d40(""),W=e(),H=yR0(()=>$.filter((B)=>hR0(B,G)),[$,G]);fR0(()=>{Q((B)=>tv(B,H.length))},[H.length]);let K=tv(Y,H.length),z=process.stdin.isTTY??!1;vR0((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)=>tv(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(rv,{flexDirection:"column",borderStyle:"round",borderColor:W.colors.secondary,paddingX:1,children:[xY(zJ,{bold:!0,color:W.colors.primary,children:[" ","Nearby Peers"," "]}),G?xY(zJ,{dimColor:!0,children:[' (filter: "',G,'")']}):null,H.length===0&&vM(zJ,{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(rv,{children:[xY(zJ,{inverse:F===K,color:F===K?W.colors.primary:void 0,children:[F===K?" \u25B8 ":" ",B.displayNameSnapshot]}),B.status==="connected"?vM(zJ,{color:"green",children:" \u2713 connected"}):xY(zJ,{dimColor:!0,children:[" ",B.host,":",B.port]}),B.principalFingerprint?xY(zJ,{color:W.colors.secondary,children:[" ",U(B.principalFingerprint)]}):null]},`${B.displayNameSnapshot}-${B.nodeId}-${F}`)),vM(rv,{marginTop:H.length>0?1:0,children:vM(zJ,{dimColor:!0,children:"type to search \u2191\u2193 navigate \u23CE connect esc cancel"})})]})}var l40=E(()=>{E0()});import{jsxs as QH,jsx as $h}from"react/jsx-runtime";import{useEffect as xR0,useMemo as gR0,useState as a40}from"react";import{Box as Zh,Text as GH,useInput as mR0}from"ink";function cR0($,Z){let J=Z.trim().toLowerCase();if(!J)return!0;return $.displayLabel.toLowerCase().includes(J)||$.clientId.toLowerCase().includes(J)||$.clientKind.toLowerCase().includes(J)}function Jh($,Z){if(Z<=0)return 0;return Math.min($,Z-1)}function Xh({clients:$,onSelect:Z,onCancel:J}){let[X,Y]=a40(0),[Q,G]=a40(""),V=e(),W=gR0(()=>$.filter((z)=>cR0(z,Q)),[$,Q]);xR0(()=>{Y((z)=>Jh(z,W.length))},[W.length]);let H=Jh(X,W.length),K=process.stdin.isTTY??!1;return mR0((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)=>Jh(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}),QH(Zh,{flexDirection:"column",borderStyle:"round",borderColor:V.colors.secondary,paddingX:1,children:[QH(GH,{bold:!0,color:V.colors.primary,children:[" ","Same-Home Clients"," "]}),Q?QH(GH,{dimColor:!0,children:[' (filter: "',Q,'")']}):null,W.length===0&&$h(GH,{dimColor:!0,children:"No same-home clients found."}),W.map((z,U)=>QH(Zh,{flexDirection:"column",children:[QH(GH,{inverse:U===H,color:U===H?V.colors.primary:void 0,children:[U===H?" \u25B8 ":" ",z.displayLabel]}),QH(GH,{dimColor:!0,children:[" ",z.clientId,z.self?" self \xB7 not sendable":""]})]},`${z.clientId}-${U}`)),$h(Zh,{marginTop:W.length>0?1:0,children:$h(GH,{dimColor:!0,children:"type to search \u2191\u2193 navigate \u23CE select esc cancel"})})]})}var n40=E(()=>{E0()});import{jsx as UJ,jsxs as DF}from"react/jsx-runtime";import{Box as hM,Text as U2,useInput as uR0}from"ink";function Yh({inviteToken:$,inviteLabel:Z,expiresAt:J,onClose:X}){let Y=e(),Q=process.stdin.isTTY??!1;return uR0((G,V)=>{if(V.return||W$(G,V))X()},{isActive:Q}),DF(hM,{flexDirection:"column",borderStyle:"round",borderColor:Y.colors.secondary,paddingX:1,paddingY:1,children:[UJ(U2,{bold:!0,color:Y.colors.primary,children:"Internet Invite"}),Z?DF(U2,{children:["Label: ",UJ(U2,{bold:!0,children:Z})]}):null,J?DF(U2,{dimColor:!0,children:["Expires: ",J]}):null,DF(hM,{marginTop:1,flexDirection:"column",children:[UJ(U2,{children:"Share this token:"}),UJ(U2,{children:$})]}),DF(hM,{marginTop:1,flexDirection:"column",children:[UJ(U2,{children:"Join with:"}),UJ(U2,{children:`aria pairing join ${$}`})]}),UJ(hM,{marginTop:1,children:UJ(U2,{dimColor:!0,children:"Press Enter or Esc to close."})})]})}var i40=E(()=>{E0()});import{jsx as BJ,jsxs as pR0}from"react/jsx-runtime";import{useState as dR0}from"react";import{Box as xM,Text as OF,useInput as lR0}from"ink";function Qh({onSubmit:$,onCancel:Z,error:J}){let[X,Y]=dR0(""),Q=e(),G=process.stdin.isTTY??!1;return lR0((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}),pR0(xM,{flexDirection:"column",borderStyle:"round",borderColor:Q.colors.secondary,paddingX:1,paddingY:1,children:[BJ(OF,{bold:!0,color:Q.colors.primary,children:"Join Invite"}),BJ(OF,{children:"Paste the invite token and press Enter."}),BJ(xM,{marginTop:1,children:BJ(OF,{children:X||" "})}),J?BJ(xM,{marginTop:1,children:BJ(OF,{color:Q.colors.error,children:J})}):null,BJ(xM,{marginTop:1,children:BJ(OF,{dimColor:!0,children:"Type token, Enter to join, Esc to cancel."})})]})}var o40=E(()=>{E0()});import{jsxs as gY,jsx as NF}from"react/jsx-runtime";import{useState as aR0,useRef as nR0}from"react";import{Box as LF,Text as mY,useInput as iR0}from"ink";function Gh({request:$,onAccept:Z,onReject:J}){let[X,Y]=aR0("accept"),Q=nR0(!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 iR0((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(LF,{flexDirection:"column",borderStyle:"round",borderColor:G.colors.warning,paddingX:2,paddingY:1,children:[gY(mY,{bold:!0,color:G.colors.warning,children:[" ","Connection Request"," "]}),NF(LF,{marginTop:1,children:gY(mY,{children:[NF(mY,{bold:!0,children:$.displayNameSnapshot??$.nodeId})," wants to connect"]})}),NF(LF,{children:gY(mY,{dimColor:!0,children:["Fingerprint: ",W($.principalFingerprint)]})}),gY(LF,{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"," "]})]}),NF(LF,{marginTop:1,children:NF(mY,{dimColor:!0,children:"\u2190\u2192 select \u23CE confirm esc reject"})})]})}var s40=E(()=>{E0()});import{execFile as oR0}from"child_process";import{existsSync as Wh,readdirSync as $60}from"fs";import{dirname as sR0,join as gM,resolve as rR0}from"path";import{fileURLToPath as tR0}from"url";function $w0(){let $=eR0;for(let Z=0;Z<10;Z++){let J=gM($,".comms","sounds","wav");if(Wh(J))return J;let X=rR0($,"..");if(X===$)break;$=X}return null}function B8($){if(!cY)return[];try{return $60(cY).filter((Z)=>new RegExp($).test(Z)).map((Z)=>gM(cY,Z))}catch{return[]}}function r40($){if(!cY)return[];let Z=gM(cY,"cloned");try{return $60(Z).filter((J)=>new RegExp($).test(J)).map((J)=>gM(Z,J))}catch{return[]}}function Q5($){if($.length===0)return null;return $[Math.floor(Math.random()*$.length)]}function uY($){Hh=$}function Z60(){return Hh}function J60(){if(process.platform!=="darwin")return"unsupported on this platform";return Kh()?"afplay (macOS)":"afplay unavailable"}function Kh(){if(t40)return Vh;return t40=!0,Vh=process.platform==="darwin"&&Wh("/usr/bin/afplay"),Vh}function G5($){if(!Hh||!$||!Wh($)||!Kh())return!1;try{return oR0("afplay",[$],()=>{}),!0}catch{return!1}}function Jw0(){let $=Date.now();if($-e40>Zw0)AF=1;else AF++;if(e40=$,AF<=1)G5(Q5(V5.acknowledge()));else if(AF===2)G5(Q5(V5.annoyed()));else if(AF===3)G5(Q5(V5.grumpy()));else G5(Q5(V5.dark()))}function mM(){G5(Q5(V5.readyToWork()))}function X60(){G5(Q5(V5.fleetDown()))}function Y60(){Jw0()}function Q60(){G5(Q5(V5.questDone()))}function G60($){switch($.type){case"error":G5(Q5(V5.error()));break;case"guardrail_rejected":G5(Q5(V5.defeat()));break}}function V60(){return cY!==null&&Kh()}function W60(){return cY!==null}function H60(){return G5(Q5(V5.readyToWork()))}var eR0,cY,Hh=!0,t40=!1,Vh=!1,V5,e40=0,AF=0,Zw0=15000;var zh=E(()=>{eR0=sR0(tR0(import.meta.url));cY=$w0();V5={acknowledge:()=>B8("^(peasant|orc|human|dwarf|elf|troll)_acknowledge"),annoyed:()=>B8("^(peasant|orc|goblin_sapper|human|troll|ogre)_selected"),grumpy:()=>B8("^(goblin_sapper|ogre|ogre_mage)_selected"),dark:()=>[...B8("^ogre_mage_selected"),...B8("^ogre_selected"),...B8("^troll_selected")],defeat:()=>r40("^defeat_"),error:()=>r40("^error_"),readyToWork:()=>[...B8("^peasant_selected"),...B8("^orc_selected"),...B8("^human_selected"),...B8("^dwarf_selected")],fleetUp:()=>[...B8("^orc_acknowledge"),...B8("^troll_acknowledge"),...B8("^ogre_acknowledge"),...B8("^human_acknowledge"),...B8("^knight_acknowledge")],fleetDown:()=>[...B8("^ogre_mage_acknowledge"),...B8("^ship_acknowledge"),...B8("^horde_ship_acknowledge")],questDone:()=>[...B8("^jobs_done"),...B8("^orc_work_completed"),...B8("^peasant_selected"),...B8("^orc_selected"),...B8("^human_selected"),...B8("^peasant_acknowledge"),...B8("^orc_acknowledge")]}});import{jsx as g6,jsxs as l1}from"react/jsx-runtime";import{useState as Uh,useCallback as z60}from"react";import{Box as W5,Text as D6,useInput as Xw0}from"ink";function Fh({onClose:$}){let Z=e(),J=Z.colors,[X,Y]=Uh(0),[Q,G]=Uh(Z60()),[V,W]=Uh("idle"),H=z60(()=>{let D=!Q;uY(D);let O=H$();if(O.soundEnabled=D,I$(O),G(D),D)mM()},[Q]),K=z60(()=>{let D=Q;if(!D)uY(!0);let O=H60();if(!D)uY(!1);W(O?"playing":"unavailable"),setTimeout(()=>W("idle"),1500)},[Q]),z=process.stdin.isTTY??!1;Xw0((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(Bh.length-1,L+1));return}if(O.return){let L=Bh[X];if(L?.id==="toggle")H();else if(L?.id==="preview")K();return}},{isActive:z});let U=V60(),B=W60(),F=J60();return l1(W5,{flexDirection:"column",borderStyle:"round",borderColor:J.primary,paddingX:1,children:[l1(W5,{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(W5,{flexDirection:"column",marginBottom:1,children:[l1(W5,{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(W5,{children:[g6(D6,{color:J.textMuted,children:"Engine "}),g6(D6,{color:U?J.text:J.warning,children:F})]}),l1(W5,{children:[g6(D6,{color:J.textMuted,children:"Assets "}),g6(D6,{color:B?J.text:J.warning,children:B?"Warcraft II pack found":"missing"})]})]}),g6(W5,{marginBottom:1,children:g6(D6,{color:J.border,children:"\u2500".repeat(40)})}),g6(W5,{flexDirection:"column",children:Bh.map((D,O)=>{let L=O===X,q=D.id==="toggle";return l1(W5,{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(W5,{marginTop:1,children:l1(D6,{color:J.textMuted,children:["\u2191\u2193"," navigate ","\u23CE"," select ","esc"," close"]})})]})}var Bh;var U60=E(()=>{E0();zh();Y4();Bh=[{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 o8,jsxs as v4,Fragment as Yw0}from"react/jsx-runtime";import{useState as Qw0}from"react";import{Box as h4,Text as R9,useInput as Gw0}from"ink";function Ww0({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 o8(R9,{color:Y,children:$})}function Dh({onAction:$,onClose:Z,status:J,actionStatus:X}){let Y=e(),Q=Y.colors,G=Vw0.filter((z)=>{if(z.showWhenRunning===void 0)return!0;return z.showWhenRunning===J.running}),[V,W]=Qw0(0),H=Math.min(V,G.length-1),K=process.stdin.isTTY??!1;return Gw0((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:[o8(R9,{bold:!0,color:Q.primary,children:"\u2699 Daemon"}),v4(R9,{color:Q.textMuted,children:[" ",Y.symbols.arrow," background service control"]})]}),v4(h4,{flexDirection:"column",marginBottom:1,children:[v4(h4,{children:[o8(R9,{color:Q.textMuted,children:"Status "}),o8(R9,{bold:!0,color:J.running?Q.success:Q.textMuted,children:J.running?"\u25CF Running":"\u25CB Stopped"})]}),J.running&&v4(Yw0,{children:[J.loopStatus&&v4(h4,{children:[o8(R9,{color:Q.textMuted,children:"Loop "}),o8(Ww0,{loopStatus:J.loopStatus})]}),J.port&&v4(h4,{children:[o8(R9,{color:Q.textMuted,children:"Port "}),o8(R9,{color:Q.text,children:J.port})]}),J.nodeId&&v4(h4,{children:[o8(R9,{color:Q.textMuted,children:"Node "}),o8(R9,{color:Q.text,children:J.nodeId.length>20?`${J.nodeId.slice(0,20)}\u2026`:J.nodeId})]}),J.runtimeId&&v4(h4,{children:[o8(R9,{color:Q.textMuted,children:"Runtime "}),o8(R9,{color:Q.text,children:J.runtimeId.length>20?`${J.runtimeId.slice(0,20)}\u2026`:J.runtimeId})]}),J.clients!==void 0&&v4(h4,{children:[o8(R9,{color:Q.textMuted,children:"Clients "}),v4(R9,{color:J.clients>0?Q.info:Q.textMuted,children:[J.clients," attached"]})]})]})]}),o8(h4,{marginBottom:1,children:o8(R9,{color:Q.border,children:"\u2500".repeat(44)})}),X&&o8(h4,{marginBottom:1,paddingX:1,children:v4(R9,{color:Q.warning,children:["\u27F3 ",X]})}),o8(h4,{flexDirection:"column",children:G.map((z,U)=>{let B=U===H;return v4(h4,{paddingX:1,flexDirection:"column",children:[o8(h4,{children:v4(R9,{inverse:B,color:B?z.id==="stop"?Q.error:Q.primary:Q.text,children:[z.icon," ",z.label]})}),B&&o8(h4,{paddingLeft:3,children:o8(R9,{color:Q.textMuted,children:z.description})})]},z.id)})}),o8(h4,{marginTop:1,children:v4(R9,{color:Q.textMuted,children:["\u2191\u2193"," navigate ","\u23CE"," select ","esc"," close"]})})]})}var Vw0;var B60=E(()=>{E0();Vw0=[{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 F60=E(()=>{I40();k40();h40();x40();m40();c40();p40();l40();n40();i40();o40();s40();U60();B60()});var Oh=E(()=>{OS();qS();Ln();fn();Tr();Pq();rI();eI();kr();fr();yr();TV();vr();h90();eS();x90();m90();p90();ZI();i90();VF();yY();VJ();F60()});import{jsxs as WH,jsx as VH}from"react/jsx-runtime";import{useEffect as Hw0,useState as Kw0,useRef as D60}from"react";import{Box as cM,Text as pY,useInput as zw0}from"ink";function Uw0({status:$}){let Z=e();switch($){case"connected":return WH(pY,{color:Z.colors.success,children:["\u2713"," connected"]});case"expired":return WH(pY,{color:Z.colors.error,children:["\u2717"," expired"]});case"none":return WH(pY,{color:Z.colors.textMuted,children:["\xB7"," not connected"]})}}function O60({providers:$,onSelect:Z,onCancel:J,isActive:X=!0}){let Y=e(),[Q,G]=Kw0(0),V=D60(0),W=D60(!1);Hw0(()=>{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 zw0((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}),WH(cM,{flexDirection:"column",borderStyle:"round",borderColor:Y.colors.secondary,paddingX:1,paddingY:1,width:56,children:[VH(cM,{marginBottom:1,children:VH(pY,{bold:!0,children:"Select a provider:"})}),$.map((z,U)=>{let B=U===Q,F=B?"\u25B8":" ";return WH(cM,{gap:1,children:[VH(pY,{color:B?Y.colors.primary:void 0,children:F}),VH(pY,{color:B?Y.colors.primary:void 0,bold:B,children:z.label.padEnd(28)}),VH(Uw0,{status:z.status})]},z.id)}),VH(cM,{marginTop:1,children:WH(pY,{color:Y.colors.textMuted,children:["\u2191\u2193"," Navigate Enter Select Esc Cancel"]})})]})}var N60=E(()=>{E0()});import{jsxs as B2,jsx as x4}from"react/jsx-runtime";import{useEffect as Bw0,useRef as Nh,useState as uM}from"react";import{Box as a1,Text as n1,useInput as Fw0}from"ink";function L60({provider:$,onCancel:Z,isActive:J=!0,onComplete:X,authorizeUrl:Y,expectedState:Q,onCodeSubmit:G}){let V=e(),[W,H]=uM("starting"),[K,z]=uM(""),[U,B]=uM(""),[F,D]=uM(""),O=Nh(null),L=Nh(!1),q=Nh(!1),A=process.stdin.isTTY??!1;Fw0((_,M)=>{if(W$(_,M))Z()},{isActive:J&&A}),Bw0(()=>{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),sL($,{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}Iw($,{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 B2(a1,{flexDirection:"column",borderStyle:"round",borderColor:V.colors.secondary,paddingX:1,paddingY:1,width:64,children:[x4(a1,{marginBottom:1,children:B2(n1,{bold:!0,children:["Sign in to ",$]})}),(W==="starting"||W==="waiting")&&B2(a1,{gap:1,children:[x4(ZW,{}),x4(n1,{children:"Opening browser to sign in..."})]}),W==="manual"&&B2(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:"})}),B2(a1,{marginTop:1,children:[x4(n1,{color:V.colors.textMuted,children:"> "}),x4(NV,{value:F,onChange:D,onSubmit:N,placeholder:"paste code here",focus:J,showCursor:!0})]})]}),W==="exchanging"&&B2(a1,{gap:1,children:[x4(ZW,{}),x4(n1,{children:"Exchanging code for tokens..."})]}),W==="success"&&B2(n1,{color:V.colors.success,children:["\u2713"," Logged in to ",$]}),W==="error"&&B2(a1,{flexDirection:"column",children:[B2(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 A60=E(()=>{R6();E0();Pq();mS()});import{jsxs as KH,jsx as F2}from"react/jsx-runtime";import{useEffect as Dw0,useRef as q60,useState as Ow0}from"react";import{Box as HH,Text as FJ,useInput as Nw0}from"ink";function Lw0({status:$}){let Z=e();if($==="connected")return KH(FJ,{color:Z.colors.success,children:["\u2713"," connected"]});if($==="available")return KH(FJ,{color:Z.colors.success,children:["\u2713"," available"]});return F2(FJ,{color:Z.colors.textMuted,children:"\xB7"})}function zH({options:$,onSelect:Z,onCancel:J,title:X="Select login method:",isActive:Y=!0}){let Q=e(),[G,V]=Ow0(0),W=q60(0),H=q60(!1),K=process.stdin.isTTY??!1;Dw0(()=>{H.current=!1,W.current=0,V(0)},[$]);let z=(U)=>{V((B)=>{let F=U(B);return W.current=F,F})};return Nw0((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}),KH(HH,{flexDirection:"column",borderStyle:"round",borderColor:Q.colors.secondary,paddingX:1,paddingY:1,width:64,children:[F2(HH,{marginBottom:1,children:F2(FJ,{bold:!0,children:X})}),$.map((U,B)=>{let F=B===G,D=F?"\u25B8":" ";return KH(HH,{flexDirection:"column",children:[KH(HH,{gap:1,children:[F2(FJ,{color:F?Q.colors.primary:void 0,children:D}),F2(FJ,{color:F?Q.colors.primary:void 0,bold:F,children:U.label}),F2(Lw0,{status:U.status})]}),U.description&&F2(HH,{marginLeft:3,children:F2(FJ,{color:Q.colors.textMuted,dimColor:!0,children:U.description})})]},U.id)}),F2(HH,{marginTop:1,children:KH(FJ,{color:Q.colors.textMuted,children:["\u2191\u2193"," Navigate Enter Select Esc Cancel"]})})]})}var Lh=E(()=>{E0()});import{jsx as Aw0}from"react/jsx-runtime";function E60({options:$,onSelect:Z,onCancel:J,isActive:X=!0}){return Aw0(zH,{options:$,onSelect:Z,onCancel:J,title:"Select Anthropic login method:",isActive:X})}var _60=E(()=>{Lh()});import{jsx as DJ,jsxs as Ah}from"react/jsx-runtime";import{useRef as qw0,useState as Ew0}from"react";import{Box as qF,Text as UH,useInput as _w0}from"ink";function BH({title:$,hint:Z,onSubmit:J,onCancel:X,isActive:Y=!0}){let Q=e(),[G,V]=Ew0(""),W=qw0(!1),H=process.stdin.isTTY??!1;_w0((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 Ah(qF,{flexDirection:"column",borderStyle:"round",borderColor:Q.colors.secondary,paddingX:1,paddingY:1,width:64,children:[DJ(qF,{marginBottom:1,children:DJ(UH,{bold:!0,children:$})}),Z&&DJ(qF,{marginBottom:1,children:DJ(UH,{color:Q.colors.textMuted,dimColor:!0,children:Z})}),Ah(qF,{children:[Ah(UH,{color:Q.colors.primary,children:["\u25B8"," "]}),DJ(UH,{children:K||" "}),DJ(UH,{color:Q.colors.textMuted,children:"_"})]}),DJ(qF,{marginTop:1,children:DJ(UH,{color:Q.colors.textMuted,children:"Enter Submit Esc Cancel"})})]})}var M60=E(()=>{E0()});function P60($,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=oS(H.text);for(let z of K)if(z.type==="image"&&IA(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 j60=E(()=>{bA()});function C60($,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 T60;var R60=E(()=>{T60={kind:"idle"}});import{useReducer as Mw0,useEffect as qh,useRef as w60}from"react";function S60($,Z){let[J,X]=Mw0(C60,T60),Y=w60(!1);qh(()=>{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=w60(null);return qh(()=>{if($!==Q.current){if(Q.current!==null)X({type:"STREAM_END"});Q.current=$}},[$]),qh(()=>{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:gn(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 I60=E(()=>{R60();EV()});function pM($){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 b60($,Z){let J=new Map;for(let X of[...$,...Z]){let Y=pM(X);if(!J.has(Y))J.set(Y,X)}return[...J.values()]}import{jsx as G$,jsxs as dY,Fragment as Pw0}from"react/jsx-runtime";import{useState as OJ,useCallback as D2,useMemo as NJ,useEffect as AZ}from"react";import{Box as H5,Static as jw0,Text as O2,useApp as Tw0,useInput as Cw0}from"ink";function Eh({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:s0,onCopilotSourceCancel:V$,oauthProvider:_$,oauthAuthorizeUrl:r8,oauthExpectedState:p$,onOAuthComplete:c$,onOAuthCodeSubmit:z9,onOAuthCancel:d4,copilotDeviceProvider:A5,copilotDeviceProfileLabel:GK,copilotDeviceVerificationUri:VK,copilotDeviceUserCode:V7,onCopilotDeviceComplete:W7,onCopilotDeviceApprove:WK,onCopilotDeviceCancel:f2,anthropicMethodOptions:HK,onAnthropicMethodSelect:ZO,onAnthropicMethodCancel:mJ,anthropicKeyInputVisible:JO,onAnthropicKeySubmit:jQ,onAnthropicKeyCancel:XO,anthropicSetupTokenVisible:TQ,onAnthropicSetupTokenSubmit:YO,onAnthropicSetupTokenCancel:CQ,openaiMethodOptions:KK,onOpenAIMethodSelect:RQ,onOpenAIMethodCancel:QO,openaiKeyInputVisible:wQ,onOpenAIKeySubmit:GO,onOpenAIKeyCancel:SQ,googleMethodOptions:IQ,onGoogleMethodSelect:bQ,onGoogleMethodCancel:VO,googleKeyInputVisible:kQ,onGoogleKeySubmit:WO,onGoogleKeyCancel:fQ,authInteractionOptions:zK,authInteractionTitle:UK,onAuthInteractionSelect:HO,onAuthInteractionCancel:yQ,authInteractionInput:vQ,onAuthInteractionInputSubmit:hQ,onAuthInteractionInputCancel:KO,nearbyPeers:y2=[],localClients:zO=[],onSelectPeer:BK,onSelectClient:FT,onPeerCancel:UO,onClientsCancel:DT,openPeersOverlaySignal:xQ,openClientsOverlaySignal:BO,inviteShare:H7,onInviteShareClose:OT,openJoinInviteOverlaySignal:gQ,onJoinInviteSubmit:FK,onJoinInviteCancel:cJ,joinInviteError:NT,incomingPairRequest:v2,onAcceptPairRequest:LT,onRejectPairRequest:FO,onCancelPairing:q5,openMessageEditOverlaySignal:DK,editableMessages:h2,onEditMessage:AT,prefillInput:OK,onPrefillConsumed:qT,meshMessageCount:ET=0,runtimeSocket:Yu=null,clientId:Qu=null,clientAuthToken:Gu=null,resolveCredentials:NK}){let{exit:uJ}=Tw0(),{columns:DO,rows:_T}=Y9(),[LK,A6]=OJ(""),[m0,J$]=OJ("none"),[mQ,cQ]=OJ(""),[AK,qK]=OJ(""),[i9,x2]=OJ("become"),[OO,K7]=OJ("all"),[NO,uQ]=OJ(!1),pJ=Boolean(zK||HK||KK||IQ),LO=Boolean(vQ||JO||TQ||wQ||kQ),dJ=Boolean(_$||A5||z$||U$);AZ(()=>{if(pJ)J$("login-method");else if(LO)J$("login-input");else if(dJ)J$("login");else if(m0==="login"||m0==="login-method"||m0==="login-input")J$("none")},[pJ,LO,dJ]);let EK=D2(()=>{J$("session"),setTimeout(()=>g?.(),0)},[g]);AZ(()=>{if(x===void 0)return;EK()},[x,EK]),AZ(()=>{if(r===void 0)return;J$("theme")},[r]),AZ(()=>{if(J0===void 0)return;J$("sound")},[J0]),AZ(()=>{if(X0===void 0)return;J$("daemon")},[X0]);let[pQ,dQ]=OJ([]);AZ(()=>{if(xQ===void 0)return;dQ([...y2]),J$("peers")},[xQ]),AZ(()=>{if(BO===void 0)return;J$("clients")},[BO]),AZ(()=>{if(H7)J$("invite-share");else if(m0==="invite-share")J$("none")},[H7,m0]),AZ(()=>{if(gQ===void 0)return;J$("join-invite")},[gQ]),AZ(()=>{if(DK===void 0)return;if(h2&&h2.length>0)J$("message-edit")},[DK]),AZ(()=>{if(OK!==void 0)A6(OK),qT?.()},[OK]),AZ(()=>{if(m0!=="peers")return;dQ((N0)=>{let T0=new Set(N0.map(pM)),X8=y2.filter((_5)=>!T0.has(pM(_5)));return X8.length>0?[...N0,...X8]:N0})},[m0,y2]),AZ(()=>{if(v2&&m0==="none"&&!G)J$("pair-request");else if(!v2&&m0==="pair-request")J$("none")},[v2,m0,G]);let MT=process.stdin.isTTY??!1;Cw0((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"){RZ();return}if(q5){q5();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"){uQ((X8)=>!X8);return}},{isActive:MT});let TZ=$.getPrimary(),Vu=TZ?.name||"ARIA",PT=TZ?.color||"cyan",jT=TZ?.emoji||"\uD83E\uDD8B",CZ=S60(Z0??null,G??!1),lQ=(m0==="none"&&!B0?4:0)+(!A||A.showStatusBar?1:0),AO=Math.max(_T-lQ,1),aQ=D2((N0,T0)=>{if(N0==="command")J$("command"),cQ(T0);else if(N0==="mention")J$("arion"),qK(T0),x2("mention")},[]),TT=D2((N0)=>{J$("none"),A6("");let T0=N0.requiresArgs===!0||(N0.args?.length??0)>0;if(N0.name==="become")J$("arion"),x2("become"),K7("all");else if(N0.name==="rest")J$("arion"),x2("rest"),K7("active");else if(N0.name==="wake")J$("arion"),x2("wake"),K7("resting");else if(N0.name==="model")J$("model");else if(N0.name==="theme")J$("theme");else if(N0.name==="sound")J$("sound");else if(N0.name==="daemon")o(N0.name);else if(N0.name==="memories")S?.("browse"),J$("memory");else if(N0.name==="forget")S?.("forget"),J$("memory");else if(N0.name==="resume")EK();else if(N0.name==="exit")uJ();else if(T0){A6(`/${N0.name} `);return}else o(N0.name)},[o,S,uJ]),p6=D2((N0)=>{if(J$("none"),i9==="mention"){let T0=LK.replace(/@\w*$/,"");A6(T0+"@"+N0.name+" ")}else u?.(N0.name,i9)},[i9,LK,u]),CT=D2((N0,T0)=>{J$("none"),w?.(N0.value??N0.name,T0)},[w]),RT=D2((N0)=>{J$("none"),m?.(N0)},[m]),wT=D2((N0)=>{J$("none"),I?.(N0)},[I]),RZ=D2(()=>{if(J$("none"),i9!=="mention")A6("");cQ(""),qK("")},[i9]),g2=D2((N0)=>{J$("none"),A6(N0),cQ("")},[]),qO=NJ(()=>P60(Y,Q,{userName:O}),[Y,Q,O]),d6=NJ(()=>nI(qO,q),[qO,q]),nQ=NJ(()=>d6.filter((N0)=>N0.committed),[d6]),iQ=NJ(()=>d6.filter((N0)=>!N0.committed),[d6]),_8=G&&V?V:null,wZ=_8!==null,X1=CZ.kind!=="idle",C$=Math.max(DO-4,20),m2=NJ(()=>{if(!_8)return 0;return Math.max(D9(_8,{width:C$}).split(`
|
|
4727
|
-
`).length,1)},[C$,_8]),oQ=(wZ?4+m2:0)+(X1?2:0),SZ=Math.max(AO-oQ,1),E5=NJ(()=>{let N0=new Map,T0="";for(let X8 of d6){let _5=X8.kind==="user-message"||X8.kind==="user-image"?`user:${X8.userName}`:X8.kind==="assistant-text"?`assistant:${X8.arion?.name??"ARIA"}`:X8.kind==="thinking"?`assistant:${X8.arion?.name??"ARIA"}`:X8.kind==="tool-execution"?"tool":X8.kind,sQ=X8.kind==="user-message"||X8.kind==="user-image"||X8.kind==="assistant-text"||X8.kind==="thinking";if(N0.set(X8.id,sQ&&_5!==T0),sQ)T0=_5}return N0},[d6]),ST=NJ(()=>{let N0=new Map;for(let T0=0;T0<d6.length;T0++){let X8=d6[T0],_5=T0>0?d6[T0-1]:void 0,sQ=X8.kind==="tool-execution"&&_5?.kind==="tool-execution";N0.set(X8.id,T0>0&&!sQ)}return N0},[d6]),Wu=NJ(()=>{let N0=[];if(X)N0.push({id:"header",_kind:"banner"});for(let T0 of nQ)N0.push({...T0,_kind:"item"});return N0},[X,nQ]);return dY(Pw0,{children:[G$(jw0,{items:Wu,children:(N0)=>{if(N0._kind==="banner")return G$(H5,{width:"100%",justifyContent:"center",children:X},N0.id);return G$(H5,{flexDirection:"column",marginTop:ST.get(N0.id)?1:0,children:G$(Mq,{item:N0,displayMode:q,showPrefix:E5.get(N0.id)??!1})},N0.id)}},`static-${Y0}`),dY(H5,{flexDirection:"column",width:"100%",children:[dY(H5,{flexDirection:"column",maxHeight:AO,justifyContent:"flex-end",overflowY:"hidden",children:[iQ.length>0&&G$(H5,{flexDirection:"column",maxHeight:SZ,overflowY:"hidden",children:iQ.map((N0)=>G$(H5,{flexDirection:"column",marginTop:ST.get(N0.id)?1:0,children:G$(Mq,{item:N0,displayMode:q,showPrefix:E5.get(N0.id)??!1,previewTailLines:SZ})},N0.id))}),wZ&&dY(H5,{marginTop:1,flexDirection:"column",children:[G$(SA,{param:{type:"text",text:_8??""},userName:O??"User",columns:DO,showPrefix:!0,addMargin:!1}),G$(O2,{dimColor:!0,children:" \u2191 queued \u2014 press esc or \u2191 to cancel and edit"})]}),M&&T.length>0&&G$(Kv,{spans:T}),A?.showPipelineTiming&&k&&k.phases.length>0&&G$(zv,{report:k}),NO&&dY(H5,{flexDirection:"column",borderStyle:"round",borderColor:"gray",paddingX:1,marginY:1,children:[G$(O2,{bold:!0,dimColor:!0,children:"Hotkeys"}),G$(O2,{dimColor:!0,children:" Ctrl+\\ \u2014 cycle display mode"}),G$(O2,{dimColor:!0,children:" Ctrl+t \u2014 toggle thinking blocks"}),G$(O2,{dimColor:!0,children:" Ctrl+g \u2014 toggle cost display"}),G$(O2,{dimColor:!0,children:" Ctrl+e \u2014 cycle effort level"}),G$(O2,{dimColor:!0,children:" Ctrl+s \u2014 toggle trace waterfall"}),G$(O2,{dimColor:!0,children:" Escape \u2014 cancel streaming / close overlay / clear input"}),G$(O2,{dimColor:!0,children:" Ctrl+/ \u2014 toggle this help"})]}),X1&&G$(Bv,{state:CZ.kind==="thinking"?"thinking":"composing",elapsedSeconds:Math.floor(L?.wallTimeSeconds??0),totalTokens:L?.totalTokens??0,thoughtForSeconds:CZ.kind==="composing"?CZ.thoughtForSeconds:void 0,currentVerb:CZ.kind==="tool_running"?[...new Set(CZ.tools.values())].join(" \xB7 "):CZ.verb.present})]}),dY(H5,{flexDirection:"column",flexShrink:0,children:[D0&&_0&&L0&&G$(Wv,{currentLevel:C0??ZJ.autonomy,onSelect:_0,onCancel:L0}),z$&&A0&&u0&&G$(O60,{providers:z$,onSelect:A0,onCancel:u0}),U$&&s0&&V$&&G$(tI,{options:U$,onSelect:s0,onCancel:V$}),m0==="login-method"&&zK&&HO&&yQ&&G$(zH,{options:zK,onSelect:(N0)=>HO(N0.id),onCancel:yQ,title:UK??"Choose an option:",isActive:m0==="login-method"}),m0==="login-method"&&HK&&ZO&&mJ&&G$(E60,{options:HK,onSelect:ZO,onCancel:mJ,isActive:m0==="login-method"}),m0==="login-input"&&vQ&&hQ&&KO&&G$(BH,{title:vQ.title,hint:vQ.hint,onSubmit:hQ,onCancel:KO,isActive:m0==="login-input"}),m0==="login-input"&&JO&&jQ&&XO&&G$(BH,{title:"Enter Anthropic API key",hint:"Paste your sk-ant-api03-* key",onSubmit:jQ,onCancel:XO,isActive:m0==="login-input"}),m0==="login-input"&&TQ&&YO&&CQ&&G$(BH,{title:"Enter setup token",hint:"From `claude setup-token` or admin provisioning",onSubmit:YO,onCancel:CQ,isActive:m0==="login-input"}),m0==="login-method"&&KK&&RQ&&QO&&G$(zH,{options:KK,onSelect:RQ,onCancel:QO,title:"Select OpenAI login method:",isActive:m0==="login-method"}),m0==="login-input"&&wQ&&GO&&SQ&&G$(BH,{title:"Enter OpenAI API key",hint:"Paste your sk-* key",onSubmit:GO,onCancel:SQ,isActive:m0==="login-input"}),m0==="login-method"&&IQ&&bQ&&VO&&G$(zH,{options:IQ,onSelect:bQ,onCancel:VO,title:"Select Google login method:",isActive:m0==="login-method"}),m0==="login-input"&&kQ&&WO&&fQ&&G$(BH,{title:"Enter Google API key",hint:"Paste your AIza* key",onSubmit:WO,onCancel:fQ,isActive:m0==="login-input"}),m0==="login"&&_$&&c$&&d4&&G$(L60,{provider:_$,onCancel:d4,...r8&&z9?{authorizeUrl:r8,expectedState:p$??void 0,onCodeSubmit:z9}:{onComplete:c$},isActive:m0==="login"}),m0==="login"&&A5&&W7&&f2&&G$(sI,{provider:A5,profileLabel:GK??void 0,...VK&&V7&&WK?{verificationUri:VK,userCode:V7,onApprove:WK}:{onComplete:W7},onCancel:f2}),dY(H5,{flexDirection:"column",children:[m0==="command"&&G$(gv,{commands:K,initialFilter:mQ,onSelect:TT,onHandOffInput:g2,onCancel:RZ}),m0==="arion"&&G$(mv,{arions:z,initialFilter:AK,statusFilter:OO,onSelect:p6,onCancel:RZ}),m0==="model"&&G$(uv,{models:U,effortLevel:V0,onSelect:CT,onCancel:RZ}),m0==="theme"&&G$(sv,{onSelect:RT,onCancel:RZ}),m0==="sound"&&G$(Fh,{onClose:()=>J$("none")}),m0==="daemon"&&G$(Dh,{status:n??{running:!1},actionStatus:K0,onAction:(N0)=>z0?.(N0),onClose:()=>J$("none")}),m0==="invite-share"&&H7&&G$(Yh,{inviteToken:H7.inviteToken,inviteLabel:H7.inviteLabel,expiresAt:H7.expiresAt,onClose:()=>{J$("none"),OT?.()}}),m0==="join-invite"&&G$(Qh,{error:NT,onSubmit:(N0)=>{J$("none"),FK?.(N0)},onCancel:()=>{J$("none"),cJ?.()}}),m0==="memory"&&G$(dv,{memories:B,mode:F,isLoading:D,onSelect:wT,onCancel:RZ}),m0==="peers"&&G$(ev,{peers:pQ.length>0?pQ:y2,sameHomeClientsAvailable:zO.length>0,onSelect:(N0)=>{J$("none"),BK?.(N0)},onCancel:RZ}),m0==="clients"&&G$(Xh,{clients:zO,onSelect:(N0)=>{J$("none"),A6(`/send ${N0.clientId} `),FT?.(N0)},onCancel:()=>{J$("none"),DT?.()}}),m0==="pair-request"&&v2&&G$(Gh,{request:v2,onAccept:()=>{J$("none"),LT?.()},onReject:()=>{J$("none"),FO?.()}}),m0==="session"&&G$(av,{sessions:C,onSelect:(N0)=>{J$("none"),f?.(N0)},onCancel:RZ,onSearch:(N0)=>l?.(N0),onPageChange:(N0)=>$0?.(N0)}),m0==="message-edit"&&h2&&G$(iv,{messages:h2,onSelect:(N0,T0)=>{J$("none"),AT?.(N0,T0)},onCancel:RZ}),m0==="none"&&!B0&&G$(lS,{userName:O,value:LK,onChange:A6,onSubmit:a,onTrigger:aQ,onExit:()=>uJ(),history:R0,onSaveInput:I0,focus:m0==="none",isStreaming:G,onDoubleEscape:()=>{if(h2&&h2.length>0)return J$("message-edit"),!0;return!1}})]}),(!A||A.showStatusBar)&&G$(DS,{arion:{name:Vu,emoji:jT,color:PT,traits:TZ?.personality?.traits?.slice(0,2)},model:Z,maxContextTokens:J,responseTime:H,metrics:L,displayMode:q,showCosts:_,activeArion:R,effortLevel:V0,autonomyLevel:C0,meshMessageCount:ET,connectionState:O0})]})]})]})}var k60=E(()=>{Oh();N60();eI();A60();rI();_60();Lh();M60();aI();iS();P1();j60();M1();V8();I60()});function f60($){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 _h,jsxs as Rw0}from"react/jsx-runtime";import{useMemo as y60,useState as ww0}from"react";import{Box as Sw0,useStdout as Iw0}from"ink";function bw0($){let Z=bU[$.toLowerCase()];return{name:$,userFacingName(J){if(Z)return Z.displayName(J);return $},renderToolUseMessage(J,X){if(Z)return Z.renderInput(J,X);return JSON.stringify(J)},isReadOnly(){return!1},inputSchema:{parse(J){return J??{}}}}}function fw0($){switch($){case"low":return 0.2;case"moderate":return 0.5;case"high":return 0.9}}function v60($){let{stdout:Z}=Iw0(),J=Z?.columns??80,[X]=ww0(!1),Y=y60(()=>{if(!$.approvalRequest)return null;return f60($.onApprovalChoice)},[$.approvalRequest,$.onApprovalChoice]),Q=y60(()=>{if(!$.approvalRequest||!Y)return null;let{toolName:G,input:V,riskLevel:W}=$.approvalRequest;return{assistantMessage:kw0,tool:bw0(G),description:`${G} requires approval`,input:V??{},commandPrefix:null,riskScore:fw0(W),onAbort:Y.onAbort,onAllow:Y.onAllow,onReject:Y.onReject}},[Y,$.approvalRequest]);if(Q&&Y)return Rw0(Sw0,{flexDirection:"column",width:"100%",children:[_h(Eh,{...$}),_h(hv,{toolUseConfirm:Q,onDone:Y.onDone,verbose:X})]});return _h(Eh,{...$})}var kw0;var h60=E(()=>{k60();VF();_q();_q();kw0={message:{id:"aria-approval"}}});var Mh;var x60=E(()=>{Mh=[{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 yw0(){return"1.0.60"}var __filename="/Users/hole/aria/.bundle-stage/cli/dist/release-notes.js",dM,g60;var Ph=E(()=>{dM=yw0(),g60=["\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 m60($){let Z=jh.indexOf($);return jh[(Z+1)%jh.length]}function c60($,Z){let J=EF[$],X={};if(Z.showThinking!==J.showThinking)X.showThinking=Z.showThinking;if(Z.showCosts!==J.showCosts)X.showCosts=Z.showCosts;if(Z.showToolArgs!==J.showToolArgs)X.showToolArgs=Z.showToolArgs;if(Z.toolOutput!==J.toolOutput)X.toolOutput=Z.toolOutput;if(Z.showTraces!==J.showTraces)X.showTraces=Z.showTraces;if(Z.showPipelineTiming!==J.showPipelineTiming)X.showPipelineTiming=Z.showPipelineTiming;if(Z.showStatusBar!==J.showStatusBar)X.showStatusBar=Z.showStatusBar;return X}function u60($,Z){return{...EF[$],...Z??{}}}var EF,jh;var Th=E(()=>{EF={minimal:{showThinking:!1,showCosts:!1,showToolArgs:!1,toolOutput:"hidden",showTraces:!1,showPipelineTiming:!1,showStatusBar:!1},standard:{showThinking:!0,showCosts:!0,showToolArgs:!0,toolOutput:"standard",showTraces:!1,showPipelineTiming:!1,showStatusBar:!0},debug:{showThinking:!0,showCosts:!0,showToolArgs:!0,toolOutput:"expanded",showTraces:!0,showPipelineTiming:!0,showStatusBar:!0}},jh=["minimal","standard","debug"]});function vw0($){if(!($ instanceof Error))return!1;let Z=$.message;return Z.includes("has been released")||Z.includes("aborted")}function Ch($,Z,J){if(!Z){J?.();return}Z.catch((X)=>{if(!vw0(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 FH{readDb;ipc;constructor($,Z){this.readDb=$,this.ipc=Z,$.enableLowContentionMode()}withPhase($,Z){O9($);try{return Z()}finally{N9()}}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($),Ch("appendSessionMessages",this.ipc.appendSessionMessages?.($,Z),()=>this.readDb.addConversationMessages($,Z))}addConversationMessages($,Z){this.persistMessagesNonBlocking($,Z)}addConversationMessage($,Z){this.persistMessagesNonBlocking($,[Z])}markCompleted($){Ch("markSessionCompleted",this.ipc.markSessionCompleted?.($),()=>this.readDb.markCompleted($))}replaceConversationMessages($,Z){Ch("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 Rh=E(()=>{S0();AV()});function hw0($){return typeof $!=="string"||$.trim().length>0}function xw0($){let{toolCalls:Z,...J}=$;return J}function gw0($,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!gw0($,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(hw0(X.content))Z.push(xw0(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 p60($){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 lM=E(()=>{TR()});class LJ{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)},[C$,_8]),oQ=(wZ?4+m2:0)+(X1?2:0),SZ=Math.max(AO-oQ,1),E5=NJ(()=>{let N0=new Map,T0="";for(let X8 of d6){let _5=X8.kind==="user-message"||X8.kind==="user-image"?`user:${X8.userName}`:X8.kind==="assistant-text"?`assistant:${X8.arion?.name??"ARIA"}`:X8.kind==="thinking"?`assistant:${X8.arion?.name??"ARIA"}`:X8.kind==="tool-execution"?"tool":X8.kind,sQ=X8.kind==="user-message"||X8.kind==="user-image"||X8.kind==="assistant-text"||X8.kind==="thinking";if(N0.set(X8.id,sQ&&_5!==T0),sQ)T0=_5}return N0},[d6]),ST=NJ(()=>{let N0=new Map;for(let T0=0;T0<d6.length;T0++){let X8=d6[T0],_5=T0>0?d6[T0-1]:void 0,sQ=X8.kind==="tool-execution"&&_5?.kind==="tool-execution";N0.set(X8.id,T0>0&&!sQ)}return N0},[d6]),Wu=NJ(()=>{let N0=[];if(X)N0.push({id:"header",_kind:"banner"});for(let T0 of nQ)N0.push({...T0,_kind:"item"});return N0},[X,nQ]);return dY(Pw0,{children:[G$(jw0,{items:Wu,children:(N0)=>{if(N0._kind==="banner")return G$(H5,{width:"100%",justifyContent:"center",children:X},N0.id);return G$(H5,{flexDirection:"column",marginTop:ST.get(N0.id)?1:0,children:G$(Mq,{item:N0,displayMode:q,showPrefix:E5.get(N0.id)??!1})},N0.id)}},`static-${Y0}`),dY(H5,{flexDirection:"column",width:"100%",children:[dY(H5,{flexDirection:"column",maxHeight:AO,justifyContent:"flex-end",overflowY:"hidden",children:[iQ.length>0&&G$(H5,{flexDirection:"column",maxHeight:SZ,overflowY:"hidden",children:iQ.map((N0)=>G$(H5,{flexDirection:"column",marginTop:ST.get(N0.id)?1:0,children:G$(Mq,{item:N0,displayMode:q,showPrefix:E5.get(N0.id)??!1,previewTailLines:SZ})},N0.id))}),wZ&&dY(H5,{marginTop:1,flexDirection:"column",children:[G$(SA,{param:{type:"text",text:_8??""},userName:O??"User",columns:DO,showPrefix:!0,addMargin:!1}),G$(O2,{dimColor:!0,children:" \u2191 queued \u2014 press esc or \u2191 to cancel and edit"})]}),M&&T.length>0&&G$(Kv,{spans:T}),A?.showPipelineTiming&&k&&k.phases.length>0&&G$(zv,{report:k}),NO&&dY(H5,{flexDirection:"column",borderStyle:"round",borderColor:"gray",paddingX:1,marginY:1,children:[G$(O2,{bold:!0,dimColor:!0,children:"Hotkeys"}),G$(O2,{dimColor:!0,children:" Ctrl+\\ \u2014 cycle display mode"}),G$(O2,{dimColor:!0,children:" Ctrl+t \u2014 toggle thinking blocks"}),G$(O2,{dimColor:!0,children:" Ctrl+g \u2014 toggle cost display"}),G$(O2,{dimColor:!0,children:" Ctrl+e \u2014 cycle effort level"}),G$(O2,{dimColor:!0,children:" Ctrl+s \u2014 toggle trace waterfall"}),G$(O2,{dimColor:!0,children:" Escape \u2014 cancel streaming / close overlay / clear input"}),G$(O2,{dimColor:!0,children:" Ctrl+/ \u2014 toggle this help"})]}),X1&&G$(Bv,{state:CZ.kind==="thinking"?"thinking":"composing",elapsedSeconds:Math.floor(L?.wallTimeSeconds??0),totalTokens:L?.totalTokens??0,thoughtForSeconds:CZ.kind==="composing"?CZ.thoughtForSeconds:void 0,currentVerb:CZ.kind==="tool_running"?[...new Set(CZ.tools.values())].join(" \xB7 "):CZ.verb.present})]}),dY(H5,{flexDirection:"column",flexShrink:0,children:[D0&&_0&&L0&&G$(Wv,{currentLevel:C0??ZJ.autonomy,onSelect:_0,onCancel:L0}),z$&&A0&&u0&&G$(O60,{providers:z$,onSelect:A0,onCancel:u0}),U$&&s0&&V$&&G$(tI,{options:U$,onSelect:s0,onCancel:V$}),m0==="login-method"&&zK&&HO&&yQ&&G$(zH,{options:zK,onSelect:(N0)=>HO(N0.id),onCancel:yQ,title:UK??"Choose an option:",isActive:m0==="login-method"}),m0==="login-method"&&HK&&ZO&&mJ&&G$(E60,{options:HK,onSelect:ZO,onCancel:mJ,isActive:m0==="login-method"}),m0==="login-input"&&vQ&&hQ&&KO&&G$(BH,{title:vQ.title,hint:vQ.hint,onSubmit:hQ,onCancel:KO,isActive:m0==="login-input"}),m0==="login-input"&&JO&&jQ&&XO&&G$(BH,{title:"Enter Anthropic API key",hint:"Paste your sk-ant-api03-* key",onSubmit:jQ,onCancel:XO,isActive:m0==="login-input"}),m0==="login-input"&&TQ&&YO&&CQ&&G$(BH,{title:"Enter setup token",hint:"From `claude setup-token` or admin provisioning",onSubmit:YO,onCancel:CQ,isActive:m0==="login-input"}),m0==="login-method"&&KK&&RQ&&QO&&G$(zH,{options:KK,onSelect:RQ,onCancel:QO,title:"Select OpenAI login method:",isActive:m0==="login-method"}),m0==="login-input"&&wQ&&GO&&SQ&&G$(BH,{title:"Enter OpenAI API key",hint:"Paste your sk-* key",onSubmit:GO,onCancel:SQ,isActive:m0==="login-input"}),m0==="login-method"&&IQ&&bQ&&VO&&G$(zH,{options:IQ,onSelect:bQ,onCancel:VO,title:"Select Google login method:",isActive:m0==="login-method"}),m0==="login-input"&&kQ&&WO&&fQ&&G$(BH,{title:"Enter Google API key",hint:"Paste your AIza* key",onSubmit:WO,onCancel:fQ,isActive:m0==="login-input"}),m0==="login"&&_$&&c$&&d4&&G$(L60,{provider:_$,onCancel:d4,...r8&&z9?{authorizeUrl:r8,expectedState:p$??void 0,onCodeSubmit:z9}:{onComplete:c$},isActive:m0==="login"}),m0==="login"&&A5&&W7&&f2&&G$(sI,{provider:A5,profileLabel:GK??void 0,...VK&&V7&&WK?{verificationUri:VK,userCode:V7,onApprove:WK}:{onComplete:W7},onCancel:f2}),dY(H5,{flexDirection:"column",children:[m0==="command"&&G$(gv,{commands:K,initialFilter:mQ,onSelect:TT,onHandOffInput:g2,onCancel:RZ}),m0==="arion"&&G$(mv,{arions:z,initialFilter:AK,statusFilter:OO,onSelect:p6,onCancel:RZ}),m0==="model"&&G$(uv,{models:U,effortLevel:V0,onSelect:CT,onCancel:RZ}),m0==="theme"&&G$(sv,{onSelect:RT,onCancel:RZ}),m0==="sound"&&G$(Fh,{onClose:()=>J$("none")}),m0==="daemon"&&G$(Dh,{status:n??{running:!1},actionStatus:K0,onAction:(N0)=>z0?.(N0),onClose:()=>J$("none")}),m0==="invite-share"&&H7&&G$(Yh,{inviteToken:H7.inviteToken,inviteLabel:H7.inviteLabel,expiresAt:H7.expiresAt,onClose:()=>{J$("none"),OT?.()}}),m0==="join-invite"&&G$(Qh,{error:NT,onSubmit:(N0)=>{J$("none"),FK?.(N0)},onCancel:()=>{J$("none"),cJ?.()}}),m0==="memory"&&G$(dv,{memories:B,mode:F,isLoading:D,onSelect:wT,onCancel:RZ}),m0==="peers"&&G$(ev,{peers:pQ.length>0?pQ:y2,sameHomeClientsAvailable:zO.length>0,onSelect:(N0)=>{J$("none"),BK?.(N0)},onCancel:RZ}),m0==="clients"&&G$(Xh,{clients:zO,onSelect:(N0)=>{J$("none"),A6(`/send ${N0.clientId} `),FT?.(N0)},onCancel:()=>{J$("none"),DT?.()}}),m0==="pair-request"&&v2&&G$(Gh,{request:v2,onAccept:()=>{J$("none"),LT?.()},onReject:()=>{J$("none"),FO?.()}}),m0==="session"&&G$(av,{sessions:C,onSelect:(N0)=>{J$("none"),f?.(N0)},onCancel:RZ,onSearch:(N0)=>l?.(N0),onPageChange:(N0)=>$0?.(N0)}),m0==="message-edit"&&h2&&G$(iv,{messages:h2,onSelect:(N0,T0)=>{J$("none"),AT?.(N0,T0)},onCancel:RZ}),m0==="none"&&!B0&&G$(lS,{userName:O,value:LK,onChange:A6,onSubmit:a,onTrigger:aQ,onExit:()=>uJ(),history:R0,onSaveInput:I0,focus:m0==="none",isStreaming:G,onDoubleEscape:()=>{if(h2&&h2.length>0)return J$("message-edit"),!0;return!1}})]}),(!A||A.showStatusBar)&&G$(DS,{arion:{name:Vu,emoji:jT,color:PT,traits:TZ?.personality?.traits?.slice(0,2)},model:Z,maxContextTokens:J,responseTime:H,metrics:L,displayMode:q,showCosts:_,activeArion:R,effortLevel:V0,autonomyLevel:C0,meshMessageCount:ET,connectionState:O0})]})]})]})}var k60=E(()=>{Oh();N60();eI();A60();rI();_60();Lh();M60();aI();iS();P1();j60();M1();V8();I60()});function f60($){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 _h,jsxs as Rw0}from"react/jsx-runtime";import{useMemo as y60,useState as ww0}from"react";import{Box as Sw0,useStdout as Iw0}from"ink";function bw0($){let Z=bU[$.toLowerCase()];return{name:$,userFacingName(J){if(Z)return Z.displayName(J);return $},renderToolUseMessage(J,X){if(Z)return Z.renderInput(J,X);return JSON.stringify(J)},isReadOnly(){return!1},inputSchema:{parse(J){return J??{}}}}}function fw0($){switch($){case"low":return 0.2;case"moderate":return 0.5;case"high":return 0.9}}function v60($){let{stdout:Z}=Iw0(),J=Z?.columns??80,[X]=ww0(!1),Y=y60(()=>{if(!$.approvalRequest)return null;return f60($.onApprovalChoice)},[$.approvalRequest,$.onApprovalChoice]),Q=y60(()=>{if(!$.approvalRequest||!Y)return null;let{toolName:G,input:V,riskLevel:W}=$.approvalRequest;return{assistantMessage:kw0,tool:bw0(G),description:`${G} requires approval`,input:V??{},commandPrefix:null,riskScore:fw0(W),onAbort:Y.onAbort,onAllow:Y.onAllow,onReject:Y.onReject}},[Y,$.approvalRequest]);if(Q&&Y)return Rw0(Sw0,{flexDirection:"column",width:"100%",children:[_h(Eh,{...$}),_h(hv,{toolUseConfirm:Q,onDone:Y.onDone,verbose:X})]});return _h(Eh,{...$})}var kw0;var h60=E(()=>{k60();VF();_q();_q();kw0={message:{id:"aria-approval"}}});var Mh;var x60=E(()=>{Mh=[{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 yw0(){return"1.0.61"}var __filename="/Users/hole/aria/.bundle-stage/cli/dist/release-notes.js",dM,g60;var Ph=E(()=>{dM=yw0(),g60=["\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 m60($){let Z=jh.indexOf($);return jh[(Z+1)%jh.length]}function c60($,Z){let J=EF[$],X={};if(Z.showThinking!==J.showThinking)X.showThinking=Z.showThinking;if(Z.showCosts!==J.showCosts)X.showCosts=Z.showCosts;if(Z.showToolArgs!==J.showToolArgs)X.showToolArgs=Z.showToolArgs;if(Z.toolOutput!==J.toolOutput)X.toolOutput=Z.toolOutput;if(Z.showTraces!==J.showTraces)X.showTraces=Z.showTraces;if(Z.showPipelineTiming!==J.showPipelineTiming)X.showPipelineTiming=Z.showPipelineTiming;if(Z.showStatusBar!==J.showStatusBar)X.showStatusBar=Z.showStatusBar;return X}function u60($,Z){return{...EF[$],...Z??{}}}var EF,jh;var Th=E(()=>{EF={minimal:{showThinking:!1,showCosts:!1,showToolArgs:!1,toolOutput:"hidden",showTraces:!1,showPipelineTiming:!1,showStatusBar:!1},standard:{showThinking:!0,showCosts:!0,showToolArgs:!0,toolOutput:"standard",showTraces:!1,showPipelineTiming:!1,showStatusBar:!0},debug:{showThinking:!0,showCosts:!0,showToolArgs:!0,toolOutput:"expanded",showTraces:!0,showPipelineTiming:!0,showStatusBar:!0}},jh=["minimal","standard","debug"]});function vw0($){if(!($ instanceof Error))return!1;let Z=$.message;return Z.includes("has been released")||Z.includes("aborted")}function Ch($,Z,J){if(!Z){J?.();return}Z.catch((X)=>{if(!vw0(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 FH{readDb;ipc;constructor($,Z){this.readDb=$,this.ipc=Z,$.enableLowContentionMode()}withPhase($,Z){O9($);try{return Z()}finally{N9()}}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($),Ch("appendSessionMessages",this.ipc.appendSessionMessages?.($,Z),()=>this.readDb.addConversationMessages($,Z))}addConversationMessages($,Z){this.persistMessagesNonBlocking($,Z)}addConversationMessage($,Z){this.persistMessagesNonBlocking($,[Z])}markCompleted($){Ch("markSessionCompleted",this.ipc.markSessionCompleted?.($),()=>this.readDb.markCompleted($))}replaceConversationMessages($,Z){Ch("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 Rh=E(()=>{S0();AV()});function hw0($){return typeof $!=="string"||$.trim().length>0}function xw0($){let{toolCalls:Z,...J}=$;return J}function gw0($,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!gw0($,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(hw0(X.content))Z.push(xw0(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 p60($){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 lM=E(()=>{TR()});class LJ{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=LJ.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 mw0,existsSync as wh}from"fs";function Sh($){if(!wh($))return[];let J=mw0($,"utf-8").split(`
|
|
4729
4729
|
`).filter((Q)=>Q.trim().length>0),X=new LJ,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=mG(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 d60($){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 aM($,Z){if(!Z)return{messages:$,backfillMessages:[]};let J;try{J=Sh(Z)}catch{return{messages:$,backfillMessages:[]}}if(J.length===0)return{messages:$,backfillMessages:[]};if($.length>=J.length)return{messages:$,backfillMessages:[]};let X=new Set($.map(d60)),Y=[];for(let G of J){let V=d60(G);if(!X.has(V))Y.push(G)}return{messages:[...$,...Y],backfillMessages:Y}}function nM($,Z,J){let X=`${$}/arions/${Z}/logs/${J}.jsonl`;if(wh(X))return X;let Y=`${$}/logs/${J}.jsonl`;if(wh(Y))return Y;return null}var l60=E(()=>{lM()});var Ih={};A$(Ih,{toModelMessages:()=>DL,replaySessionFromJsonl:()=>Sh,repairToolCallPairing:()=>lY,mergeWithJsonlRecovery:()=>aM,fromV1Columns:()=>uG,fromModelMessages:()=>cG,findJsonlForSession:()=>nM,extractToolCalls:()=>dG,extractToolCallId:()=>aG,extractThinking:()=>lG,extractTextContent:()=>pG,createUserMessage:()=>mG,createSystemMessage:()=>l0,createIncomingMessagePair:()=>FL,createErrorMessage:()=>Y$,conversationMessageToHistoryMessages:()=>p60,TurnAccumulator:()=>LJ,SessionHistoryClient:()=>FH,SessionHistory:()=>Z6,ConversationMessageSchema:()=>BL,ContentBlockSchema:()=>Ad,ArionRefSchema:()=>Ed});var aY=E(()=>{SR();Rh();lM();l60()});import{existsSync as cw0}from"fs";import{fileURLToPath as a60}from"url";function uw0(){return[a60(new URL("../main.ts",import.meta.url)),a60(new URL("../main.js",import.meta.url))]}function bh(){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(uw0().some((J)=>cw0(J)))return"source-bun";return"bundled-bun"}function n60(){return bh()==="compiled-bun"}var kh=()=>{};import{existsSync as fh}from"fs";import{fileURLToPath as iM}from"url";function i60(){return process.platform==="win32"?"bun.exe":"bun"}function pw0(){let $=[iM(new URL("../main.ts",import.meta.url)),iM(new URL("../main.js",import.meta.url))];for(let Z of $)if(fh(Z))return Z;throw Error("[aria] Could not resolve Bun source entrypoint for internal relaunch")}function dw0(){let $=process.argv[1]??"";if(fh($))return $;let Z=[iM(new URL("../../bin/aria.mjs",import.meta.url)),iM(new URL("../bin/aria.mjs",import.meta.url))];for(let J of Z)if(fh(J))return J;throw Error("[aria] Could not resolve bundled entrypoint for internal relaunch")}function oM($){let Z=bh(),J=$.args??[],X={...process.env,...$.env??{}},Y=$.cwd??process.cwd();switch(Z){case"source-bun":return{command:i60(),args:[pw0(),"__internal",$.mode,...J],env:X,cwd:Y};case"bundled-bun":return{command:i60(),args:[dw0(),"__internal",$.mode,...J],env:X,cwd:Y};case"compiled-bun":return{command:process.execPath,args:["__internal",$.mode,...J],env:X,cwd:Y}}}var yh=E(()=>{kh()});function sM($,Z={}){let J={},X={cwd:$.cwd,env:$.env,stdio:Z.stdio??["inherit","inherit","inherit"]};if(Z.ipc)X.ipc=(Q)=>{for(let G of J.message??[])G(Q)};let Y=Bun.spawn([$.command,...$.args],X);return Y.exited.then((Q)=>{for(let G of J.close??[])G(Q)}).catch((Q)=>{let G=Q instanceof Error?Q:Error(String(Q));for(let V of J.error??[])V(G)}),{send(Q){Y.send(Q)},on(Q,G){(J[Q]??=[]).push(G)},unref(){Y.unref()}}}import{existsSync as MF,mkdirSync as lw0,readFileSync as r60,writeFileSync as aw0,unlinkSync as vh,readdirSync as nw0}from"fs";import{dirname as BT$,join as xh,resolve as FT$}from"path";function t60($){Zz($)}function iw0($){return eC($)}function rM($){$R($)}function ow0($){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(ow0(Z))return;throw Z}}function sw0($){if(!$||typeof $!=="object")return $ instanceof Error&&/^exit:\d+$/.test($.message);if($.__ariaProcessExit===!0)return!0;return $ instanceof Error&&/^exit:\d+$/.test($.message)}function AJ($){let Z=$?.trim()||null;if(g8=Z,Z)process.env[P4]=Z;else delete process.env[P4]}function gh(){return g8}function DH($){o1=$||"ARIA",process.env[e2]=o1}function e60(){return process.env[$z]==="true"}function $Z0(...$){return xh(x9(),...$)}function ZZ0(){return $Z0("crash-markers")}function mh($){return xh(ZZ0(),`${$}.json`)}function tw0($){let Z=mh($);if(!MF(Z))return null;try{return JSON.parse(r60(Z,"utf-8"))}catch{return null}}function ew0($){try{let Z=ZZ0();lw0(Z,{recursive:!0}),aw0(mh($.sessionId),JSON.stringify($),"utf-8")}catch{}}function hh($){try{let Z=mh($);if(MF(Z))vh(Z)}catch{}}function $S0(){return $Z0("crash-reports","latest.json")}function o60($,Z){i1(`[aria] Session ${$} exceeded crash limit (${Z}/${_F}). Starting fresh instead of resuming.
|
|
4730
4730
|
`),hh($),g8=null,AJ(null)}function ZS0(){let $=$S0();if(!MF($))return null;try{let Z=JSON.parse(r60($,"utf-8"));try{vh($)}catch{}return{message:Z?.error?.message??"unknown",stack:Z?.error?.stack??void 0,heapMb:Z?.process?.heapUsedMb,rssMb:Z?.process?.rssMb}}catch{try{vh($)}catch{}return null}}async function s60($){let Z=iw0(process.pid);if(Z){if(Date.now()-new Date(Z.timestamp).getTime()<rw0)return rM(process.pid),{sessionId:Z.sessionId,arionName:Z.arionName||$,source:"marker"};rM(process.pid)}try{let{SessionHistory:J}=await Promise.resolve().then(() => (aY(),Ih)),{getAriaDir:X}=await Promise.resolve().then(() => (Y4(),_A)),Y=X(),Q=new Set([$]),G=xh(Y,"arions");if(MF(G)){for(let W of nw0(G,{withFileTypes:!0}))if(W.isDirectory()&&W.name.trim())Q.add(W.name.trim())}let V=null;for(let W of Q){let H=J.resolvePerArionPath(Y,W);if(!MF(H))continue;let K=new J(H);try{let z=K.getIncompleteSessions(1);if(z.length===0)continue;let U=z[0],B=U.updatedAt.getTime();if(!V||B>V.updatedAtMs||B===V.updatedAtMs&&W===$)V={sessionId:U.id,arionName:W,updatedAtMs:B}}finally{K.close()}}if(V)return{sessionId:V.sessionId,arionName:V.arionName,source:V.arionName===$?"history":"history-scan"}}catch(J){i1(`[aria] SessionHistory fallback failed: ${J instanceof Error?J.message:String(J)}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aria-cli/cli",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.61",
|
|
4
4
|
"description": "ARIA - Adaptive Reasoning Intelligence Agent",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -14,6 +14,7 @@
|
|
|
14
14
|
"bun": ">=1.3.11"
|
|
15
15
|
},
|
|
16
16
|
"dependencies": {
|
|
17
|
+
"sqlite-vec": "0.1.7-alpha.2",
|
|
17
18
|
"@anthropic-ai/bedrock-sdk": "^0.26.4",
|
|
18
19
|
"@anthropic-ai/sdk": "^0.78.0",
|
|
19
20
|
"@aws-sdk/credential-providers": "^3.995.0",
|
|
@@ -56,9 +57,9 @@
|
|
|
56
57
|
"@aws-sdk/client-bedrock": "^3.997.0",
|
|
57
58
|
"@aws-sdk/client-bedrock-runtime": "^3.997.0",
|
|
58
59
|
"@aws-sdk/token-providers": "^3.997.0",
|
|
59
|
-
"@aria-cli/fastripgrep": "1.0.
|
|
60
|
-
"@aria-cli/wireguard": "1.0.
|
|
61
|
-
"@aria-cli/search": "1.0.
|
|
60
|
+
"@aria-cli/fastripgrep": "1.0.61",
|
|
61
|
+
"@aria-cli/wireguard": "1.0.61",
|
|
62
|
+
"@aria-cli/search": "1.0.61"
|
|
62
63
|
},
|
|
63
64
|
"license": "MIT"
|
|
64
65
|
}
|