@aria-cli/cli 1.0.15 → 1.0.19

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.
@@ -1 +1,4 @@
1
- import"./index-g5devafm.js";import{oa as a,pa as b,qa as c,ra as d,sa as e,ta as f}from"./index-sx36201d.js";import"./index-nnqfqvqh.js";import"./index-9j6r3gr8.js";export{e as resolveLocalControlClientSync,d as resolveLocalControlClient,a as requestRuntimeSocketLease,f as createResilientAttachedClient,c as attachLocalControlClient,b as attachExistingLocalControlClient};
1
+ import{createRequire as QR}from"node:module";var _R=Object.defineProperty;var wR=(R)=>R;function zR(R,B){this[R]=wR.bind(null,B)}var E=(R,B)=>{for(var $ in B)_R(R,$,{get:B[$],enumerable:!0,configurable:!0,set:zR.bind(B,$)})};var A=(R,B)=>()=>(R&&(B=R(R=0)),B);var M=QR(import.meta.url);var ZR={};E(ZR,{saveConfig:()=>j,loadConfig:()=>YR,loadAndMigrateConfig:()=>g,getConfigPath:()=>I,getAriaDir:()=>D});import*as V from"fs";import*as m from"os";import{getModelById as UR,getModelByShortName as XR,isValidTier as C}from"@aria-cli/models";import{log as T}from"@aria-cli/types";function D(){if(process.env.ARIA_HOME)return process.env.ARIA_HOME;return`${process.env.HOME||m.homedir()}/.aria`}function I(){return`${D()}/config.json`}function g(){try{let R=I();if(V.existsSync(R)){let B=JSON.parse(V.readFileSync(R,"utf-8"));try{if(B.defaultModel&&!B.preferredTier){let U=UR(B.defaultModel)||XR(B.defaultModel);if(!U)T.warn(`Unknown model "${B.defaultModel}" migrated to balanced tier (Sonnet 4.5)`);let X=U?.tier||"balanced";B.preferredTier=C(X)?X:"balanced",delete B.defaultModel,j(B)}if(B.preferredTier!==void 0&&!C(B.preferredTier))T.warn(`Invalid tier "${B.preferredTier}" corrected to balanced tier`),B.preferredTier="balanced",j(B);let $=!1;if(!B.awsRegion&&process.env.AWS_REGION)B.awsRegion=process.env.AWS_REGION,$=!0;if(!B.awsProfile&&process.env.AWS_PROFILE)B.awsProfile=process.env.AWS_PROFILE,$=!0;if($)j(B)}catch($){T.warn("Config migration failed, using config as-is:",$ instanceof Error?$.message:$)}return B}}catch(R){T.warn("[Config] Failed to load config file:",R)}return{}}function j(R){let B=D();if(!V.existsSync(B))V.mkdirSync(B,{recursive:!0});V.writeFileSync(I(),JSON.stringify(R,null,2),"utf-8")}var YR;var d=A(()=>{YR=g});import{RuntimeBootstrapRecordSchema as vR}from"@aria-cli/tools";function yR(R){return R==="control_ready"||R==="network_ready"||R==="mesh_ready"}function c(R,B){if(B.nodeId!==R)throw Error(`[local-control-client] Runtime bootstrap node mismatch for ${R}: received ${B.nodeId}`);if(!yR(B.phase))throw Error(`[local-control-client] Runtime bootstrap for ${R} is not attachable (phase=${B.phase})`);return B}var a=()=>{};async function FR(){let R=D();if(u?.ariaDir===R)return u.handler;let{CentralErrorHandler:B}=await import("@aria-cli/aria/error-handler"),$=new B({ariaDir:R});return u={ariaDir:R,handler:$},$}async function l(R,B){await(await FR()).report(R,{workingDir:process.cwd(),providerState:{lastProvider:"trusted-local-control",lastModel:B.endpoint,...typeof B.responseStatus==="number"?{lastStatusCode:B.responseStatus}:{}},configSnapshot:{transport:B.transport,endpoint:B.endpoint,...typeof B.responseStatus==="number"?{responseStatus:B.responseStatus}:{},payload:B.payload}})}var u;var p=A(()=>{d()});var SR={};E(SR,{resolveLocalControlClientSync:()=>f,resolveLocalControlClient:()=>v,requestRuntimeSocketLease:()=>L,createResilientAttachedClient:()=>S,attachLocalControlClient:()=>k,attachExistingLocalControlClient:()=>h});import*as t from"node:net";import{appendFileSync as GR,mkdirSync as bR}from"node:fs";import{join as o}from"node:path";import{randomUUID as JR}from"node:crypto";import{createRuntimeSocketAttachedLocalControlClient as e,createRuntimeSocketLocalControlClient as VR,createTrustedRuntimeError as WR,AttachedClientLeaseGrantSchema as qR,LocalControlSocketAttachClientRequestSchema as OR,LocalControlSocketAttachClientResponseSchema as PR,LocalControlSocketRequestSchema as AR,LocalControlSocketResponseSchema as DR}from"@aria-cli/tools";async function RR(R){await new Promise((B)=>setTimeout(B,Math.max(R,0)))}function TR(){return i??=import("@aria-cli/server/runtime/host-supervisor"),i}function jR(){return s??=import("@aria-cli/server/runtime/node-metadata"),s}function HR(){return n??=import("@aria-cli/server/runtime/node-store"),n}async function BR(R){let{resolveOrCreateNode:B}=await jR();return B({ariaHome:R})}async function H(R,B){let{NodeStore:$}=await HR(),U=new $({ariaHome:R});try{return U.readRuntimeOwnerRecord(B)}finally{U.close()}}function x(R){if(!(R instanceof Error))return!1;let B=R.message;return B.includes("connect ENOENT")||B.includes("ECONNREFUSED")||B.includes("Missing runtime owner record")||B.includes("not attachable")||B.includes("not control-ready")}async function K(R){let B=await H(R.ariaHome,R.nodeId);if(!B)throw Error(`[local-control-client] Missing runtime owner record for node ${R.nodeId}`);let $=LR({runtimeSocket:B.runtimeSocket,pollIntervalMs:R.pollIntervalMs}),U=c(R.nodeId,await $.getRuntimeBootstrap()),X,Q,_;if(R.clientKind)_=await S({runtimeSocket:B.runtimeSocket,clientKind:R.clientKind,logDir:o(R.ariaHome,"logs")}),X=_.getClientId(),Q=_.getClientAuthToken();let z=null;return{nodeId:R.nodeId,runtimeId:U.runtimeId,port:U.controlEndpoint.port,ownership:R.ownership,...X?{attachedClientId:X}:{},...Q?{attachedClientAuthToken:Q}:{},control:_?_.api:$,release:async(Z)=>{if(z)return z;return z=(async()=>{let b=_;_=void 0,X=void 0,Q=void 0,await b?.release().catch(()=>{}),await R.release(Z)})(),z}}}async function L(R,B){let $=AR.parse({id:JR(),method:"attachClient",payload:B});return new Promise((U,X)=>{let Q=t.createConnection(R),_="",z=!1,Z=!1,b,q=new Promise((O)=>{b=O}),J=()=>{if(Z)return;if(Z=!0,b?.(),!z)z=!0,X(Error("Local control socket closed before establishing an attached-client lease"))};Q.setEncoding("utf8"),Q.once("connect",()=>{Q.write(`${JSON.stringify($)}
2
+ `)}),Q.once("error",(O)=>{if(!z){z=!0,X(O);return}J()}),Q.once("end",J),Q.once("close",J),Q.on("data",async(O)=>{_+=O;let N=_.indexOf(`
3
+ `);if(N===-1||z)return;try{let w=DR.parse(JSON.parse(_.slice(0,N)));if(w.id!==$.id){z=!0,Q.destroy(),X(Error("Local control socket response ID mismatch"));return}if(!w.ok){let F=WR(w.error,w.diagnostic);await l(F,{endpoint:"attachClient",responseStatus:null,payload:w,transport:"runtime_socket_attach"}),z=!0,Q.destroy(),X(F);return}let y=qR.parse(PR.parse(w.payload));z=!0,U({clientId:y.clientId,clientAuthToken:y.clientAuthToken,release:async()=>{if(!Z)Q.destroy();await q}})}catch(w){z=!0,Q.destroy(),X(w)}})})}async function h(R){let B=await BR(R.ariaHome);if(!await H(R.ariaHome,B.nodeId))return null;let $=Date.now()+KR;while(Date.now()<$)try{return await K({ariaHome:R.ariaHome,nodeId:B.nodeId,ownership:"reattached",release:async()=>{},pollIntervalMs:R.pollIntervalMs,clientKind:R.clientKind})}catch(U){if(!x(U))throw U;if(!await H(R.ariaHome,B.nodeId))return null;await RR(MR)}return null}function LR(R){if(R.auth)return e({runtimeSocket:R.runtimeSocket,pollIntervalMs:R.pollIntervalMs,auth:R.auth});return VR(R)}async function k(R){let B=async(_,z)=>{let Z=R.pollIntervalMs??100,b=Date.now()+Math.max(Z*20,2000),q=null;while(Date.now()<b){if(R.signal?.aborted)throw Error(`[local-control-client] Attach-only client ${z} aborted while waiting for a live runtime owner on node ${_}`);try{if(!await H(R.ariaHome,_))q=Error(`[local-control-client] No live runtime owner available for attach-only client ${z} on node ${_}`);else return await K({ariaHome:R.ariaHome,nodeId:_,ownership:"reattached",release:async()=>{},pollIntervalMs:R.pollIntervalMs,clientKind:z})}catch(J){if(!x(J))throw J;q=J}await RR(Z)}throw q??Error(`[local-control-client] No live runtime owner available for attach-only client ${z} on node ${_}`)},{getHostSupervisor:$,HostSupervisorSplitBrainError:U}=await TR(),X=$(),Q;try{Q=await X.attach({ariaHome:R.ariaHome,arionName:R.arionName,clientKind:R.clientKind,memoriaFactory:R.memoriaFactory,router:R.router,authResolver:R.authResolver,runSessionConfig:R.runSessionConfig,mcpServers:R.mcpServers,daemonSafetyPolicy:R.daemonSafetyPolicy,autonomousIntervalMs:R.autonomousIntervalMs,signal:R.signal,silent:R.silent,runtimeLifecycle:R.runtimeLifecycle,port:R.port})}catch(_){if(_ instanceof U)return K({ariaHome:R.ariaHome,nodeId:_.nodeId,ownership:"reattached",release:async()=>{},pollIntervalMs:R.pollIntervalMs,clientKind:R.clientKind});throw _}try{return await Q.runtime.waitForInitialDiscovery(),await K({ariaHome:R.ariaHome,nodeId:Q.nodeId,ownership:Q.ownership,pollIntervalMs:R.pollIntervalMs,clientKind:R.clientKind,release:(_)=>Q.release(_)})}catch(_){throw await Q.release(),_}}async function v(R){let B=await BR(R.ariaHome);try{return(await K({ariaHome:R.ariaHome,nodeId:B.nodeId,ownership:"reattached",release:async()=>{},pollIntervalMs:R.pollIntervalMs})).control}catch($){if(x($))return null;throw $}}function f(R){return null}function P(R){if(!(R instanceof Error))return!1;let B=R.message;if(B.includes("attached-local-client-only"))return!0;if(B.includes("ECONNRESET"))return!0;if(B.includes("ECONNREFUSED"))return!0;if(B.includes("EPIPE"))return!0;if(B.includes("connect ENOENT"))return!0;if(B.includes("socket hang up"))return!0;if(B.includes("closed before"))return!0;return!1}function r(R){if(R<=0)return Promise.resolve();return new Promise((B)=>{setTimeout(B,R).unref?.()})}async function S(R){let{runtimeSocket:B,clientKind:$="local-api"}=R,U=!1,X,Q,_=null,z=null,Z=(w)=>{if(!R.logDir)return;try{bR(R.logDir,{recursive:!0}),GR(o(R.logDir,"reattach.jsonl"),JSON.stringify({ts:new Date().toISOString(),pid:process.pid,...w})+`
4
+ `)}catch{}};async function b(){if(z)await z().catch(()=>{}),z=null;let w=await L(B,OR.parse({clientKind:$,lease:!0,pid:process.pid,displayName:R.displayName}));X=w.clientId,Q=w.clientAuthToken,z=()=>w.release(),_=e({runtimeSocket:B,auth:{clientId:w.clientId,clientAuthToken:w.clientAuthToken}}),Z({event:"lease_acquired",clientId:w.clientId})}await b();async function q(w,y){if(U)throw Error("ResilientAttachedClient has been released");try{return await y(_)}catch(F){if(!P(F))throw F;Z({event:"reattach_start",method:w,error:F.message});for(let Y=0;Y<W.length;Y++){if(U)throw Error("ResilientAttachedClient has been released");await r(W[Y]??0);try{await b();let G=await y(_);return Z({event:"reattach_success",method:w,attempt:Y}),G}catch(G){if(Z({event:"reattach_retry_failed",method:w,attempt:Y,error:G.message,willRetry:P(G)&&Y<W.length-1}),!P(G)||Y===W.length-1)throw G}}throw F}}async function*J(w,y){if(U)throw Error("ResilientAttachedClient has been released");try{yield*y(_);return}catch(F){if(!P(F))throw F;Z({event:"reattach_stream_start",method:w,error:F.message});for(let Y=0;Y<W.length;Y++){if(U)throw Error("ResilientAttachedClient has been released");await r(W[Y]??0);try{await b(),yield*y(_),Z({event:"reattach_stream_success",method:w,attempt:Y});return}catch(G){if(Z({event:"reattach_stream_retry_failed",method:w,attempt:Y,error:G.message,willRetry:P(G)&&Y<W.length-1}),!P(G)||Y===W.length-1)throw G}}}}let O=new Set(["streamRun","subscribeRuntimeEvents","subscribeInbox","subscribePeers","subscribeDirectClientInbox"]);return{api:new Proxy({},{get(w,y){if(y==="then"||y==="catch"||y==="finally")return;if(O.has(y))return(...F)=>J(y,(Y)=>Y[y](...F));return(...F)=>q(y,(Y)=>Y[y](...F))}}),getClientId:()=>X,getClientAuthToken:()=>Q,release:async()=>{U=!0;let w=Error("release() caller").stack;if(z)await z().catch(()=>{}),z=null;Z({event:"released",clientId:X,releaseStack:w})}}}var KR=1e4,MR=250,i,s,n,W;var $R=A(()=>{a();p();W=[0,250,500,1000]});var NR={};E(NR,{resolveLocalControlClientSync:()=>f,resolveLocalControlClient:()=>v,requestRuntimeSocketLease:()=>L,createResilientAttachedClient:()=>S,attachLocalControlClient:()=>k,attachExistingLocalControlClient:()=>h});var ER=A(()=>{$R()});ER();export{f as resolveLocalControlClientSync,v as resolveLocalControlClient,L as requestRuntimeSocketLease,S as createResilientAttachedClient,k as attachLocalControlClient,h as attachExistingLocalControlClient};
@@ -7,5 +7,5 @@
7
7
  * - Lead with the verb / action the user can take
8
8
  * - Keep it to 4-5 items max
9
9
  */
10
- export declare const CLI_VERSION: string;
10
+ export declare const CLI_VERSION = "1.0.19";
11
11
  export declare const WHATS_NEW: string[];
@@ -1 +1 @@
1
- import"./index-9j6r3gr8.js";function G(j){console.warn(j)}function z(j){return j instanceof Error?j.message:String(j)}async function I(j,A){try{return await j()}finally{let{release:B,sessionHistory:C,pool:D,aria:F,warn:v=G}=A();try{await B?.()}catch(q){v(`[aria] Local-control cleanup failed: ${z(q)}`)}try{C?.close?.()}catch(q){v(`[aria] SessionHistory cleanup failed: ${z(q)}`)}try{await D?.closeAll?.()}catch(q){v(`[aria] Memoria pool cleanup failed: ${z(q)}`)}try{await F?.shutdown?.()}catch(q){v(`[aria] Fallback aria shutdown failed: ${z(q)}`)}}}export{I as withReplCleanup};
1
+ import{createRequire as K}from"node:module";var G=Object.defineProperty;var I=(j)=>j;function J(j,q){this[j]=I.bind(null,q)}var M=(j,q)=>{for(var z in q)G(j,z,{get:q[z],enumerable:!0,configurable:!0,set:J.bind(q,z)})};var N=(j,q)=>()=>(j&&(q=j(j=0)),q);var P=K(import.meta.url);function L(j){console.warn(j)}function B(j){return j instanceof Error?j.message:String(j)}async function S(j,q){try{return await j()}finally{let{release:z,sessionHistory:C,pool:D,aria:F,warn:A=L}=q();try{await z?.()}catch(v){A(`[aria] Local-control cleanup failed: ${B(v)}`)}try{C?.close?.()}catch(v){A(`[aria] SessionHistory cleanup failed: ${B(v)}`)}try{await D?.closeAll?.()}catch(v){A(`[aria] Memoria pool cleanup failed: ${B(v)}`)}try{await F?.shutdown?.()}catch(v){A(`[aria] Fallback aria shutdown failed: ${B(v)}`)}}}export{S as withReplCleanup};
package/dist/session.js CHANGED
@@ -1 +1 @@
1
- import"./index-9j6r3gr8.js";import{log as J}from"@aria-cli/types";import{Room as K,parseMessage as L,ContributionGate as O}from"@aria-cli/aria";class P{room;history=[];manager;router;memoria;contributionGate;initialized=!1;constructor(j){this.manager=j.manager,this.router=j.router,this.memoria=j.memoria,this.contributionGate=new O(j.router),this.room=new K({onRest:async(q)=>{if(await this.manager.rest(q.name),j.onArionRest)await j.onArionRest(q)}})}async initialize(j){if(this.initialized)return;let q=await this.manager.list(),z=j?q.find((x)=>x.name.toLowerCase()===j.toLowerCase()):q.find((x)=>x.isDefault);if(z)if(z.status==="resting"){await this.manager.wake(z.name);let x=await this.manager.get(z.name);if(x)this.room.setPrimary(x)}else this.room.setPrimary(z);this.initialized=!0}async become(j){let q=await this.manager.get(j);if(!q)throw Error(`Arion not found: ${j}`);if(q.status==="retired")throw Error(`Cannot become retired arion: ${j}`);if(q.status==="resting"){if(await this.manager.wake(j),q=await this.manager.get(j),!q)throw Error(`Arion not found after wake: ${j}`)}return this.room.setPrimary(q),q}async activate(j){let q=await this.manager.get(j);if(!q)throw Error(`Arion not found: ${j}`);if(q.status==="resting"){if(await this.manager.wake(j),q=await this.manager.get(j),!q)throw Error(`Arion not found after wake: ${j}`)}return this.room.enter(q),q}async dismiss(j){let q=this.room.get(j);if(q&&q!==this.room.getPrimary())await this.room.exit(q)}getPrimary(){return this.room.getPrimary()}getRoom(){return this.room}getActiveArions(){return this.room.getActive()}isActive(j){return this.room.isInRoom(j)}addToHistory(j){this.history.push(j)}getHistory(){return[...this.history]}clearHistory(){this.history=[]}parseMessage(j){return L(j)}async getRespondingArions(j,q,z){let x=Date.now(),F=q.map((D)=>({arion:D,isAddressed:!0})),E=this.room.getActive().filter((D)=>!q.some((B)=>B.name===D.name));if(E.length>0){let D=await this.contributionGate.evaluateAll(E,{message:j,previousResponses:z,conversationHistory:this.history.map((B)=>({role:B.role,content:B.content}))},{maxVolunteers:2});for(let{arion:B,assessment:I}of D)F.push({arion:B,isAddressed:!1,assessment:{confidence:I.confidence,contributionType:I.contributionType||"addition"}})}let H=Date.now()-x;if(H>100||E.length>0)J.debug(`[cli.responding_arions] ${H}ms — evaluated ${E.length} non-addressed arions, ${F.length-q.length} volunteered`);return F}async getArionMemoria(j){return this.manager.getMemoria(j)}}export{P as ArionSession};
1
+ import{createRequire as O}from"node:module";var J=Object.defineProperty;var K=(j)=>j;function L(j,q){this[j]=K.bind(null,q)}var V=(j,q)=>{for(var x in q)J(j,x,{get:q[x],enumerable:!0,configurable:!0,set:L.bind(q,x)})};var W=(j,q)=>()=>(j&&(q=j(j=0)),q);var Y=O(import.meta.url);import{log as P}from"@aria-cli/types";import{Room as Q,parseMessage as S,ContributionGate as T}from"@aria-cli/aria";class U{room;history=[];manager;router;memoria;contributionGate;initialized=!1;constructor(j){this.manager=j.manager,this.router=j.router,this.memoria=j.memoria,this.contributionGate=new T(j.router),this.room=new Q({onRest:async(q)=>{if(await this.manager.rest(q.name),j.onArionRest)await j.onArionRest(q)}})}async initialize(j){if(this.initialized)return;let q=await this.manager.list(),x=j?q.find((z)=>z.name.toLowerCase()===j.toLowerCase()):q.find((z)=>z.isDefault);if(x)if(x.status==="resting"){await this.manager.wake(x.name);let z=await this.manager.get(x.name);if(z)this.room.setPrimary(z)}else this.room.setPrimary(x);this.initialized=!0}async become(j){let q=await this.manager.get(j);if(!q)throw Error(`Arion not found: ${j}`);if(q.status==="retired")throw Error(`Cannot become retired arion: ${j}`);if(q.status==="resting"){if(await this.manager.wake(j),q=await this.manager.get(j),!q)throw Error(`Arion not found after wake: ${j}`)}return this.room.setPrimary(q),q}async activate(j){let q=await this.manager.get(j);if(!q)throw Error(`Arion not found: ${j}`);if(q.status==="resting"){if(await this.manager.wake(j),q=await this.manager.get(j),!q)throw Error(`Arion not found after wake: ${j}`)}return this.room.enter(q),q}async dismiss(j){let q=this.room.get(j);if(q&&q!==this.room.getPrimary())await this.room.exit(q)}getPrimary(){return this.room.getPrimary()}getRoom(){return this.room}getActiveArions(){return this.room.getActive()}isActive(j){return this.room.isInRoom(j)}addToHistory(j){this.history.push(j)}getHistory(){return[...this.history]}clearHistory(){this.history=[]}parseMessage(j){return S(j)}async getRespondingArions(j,q,x){let z=Date.now(),F=q.map((D)=>({arion:D,isAddressed:!0})),E=this.room.getActive().filter((D)=>!q.some((B)=>B.name===D.name));if(E.length>0){let D=await this.contributionGate.evaluateAll(E,{message:j,previousResponses:x,conversationHistory:this.history.map((B)=>({role:B.role,content:B.content}))},{maxVolunteers:2});for(let{arion:B,assessment:I}of D)F.push({arion:B,isAddressed:!1,assessment:{confidence:I.confidence,contributionType:I.contributionType||"addition"}})}let H=Date.now()-z;if(H>100||E.length>0)P.debug(`[cli.responding_arions] ${H}ms — evaluated ${E.length} non-addressed arions, ${F.length-q.length} volunteered`);return F}async getArionMemoria(j){return this.manager.getMemoria(j)}}export{U as ArionSession};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aria-cli/cli",
3
- "version": "1.0.15",
3
+ "version": "1.0.19",
4
4
  "type": "module",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -13,14 +13,38 @@
13
13
  "import": "./dist/index.js"
14
14
  }
15
15
  },
16
+ "scripts": {
17
+ "test": "vitest run --config vitest.config.ts",
18
+ "test:list": "tsx tests/print-default-test-lane.ts",
19
+ "test:watch": "vitest --config vitest.config.ts",
20
+ "test:integration": "vitest run --config vitest.integration.config.ts",
21
+ "test:native": "vitest run --config vitest.native.config.ts",
22
+ "test:e2e": "vitest run --config vitest.e2e.config.ts",
23
+ "test:e2e:watch": "vitest --config vitest.e2e.config.ts",
24
+ "test:e2e:mocked": "vitest run --config vitest.e2e.config.ts --testNamePattern='mocked|error|rejects|handles|prevents'",
25
+ "test:real": "vitest run --config vitest.real.config.ts",
26
+ "test:lanes": "tsx tests/print-test-lane-manifest.ts",
27
+ "test:parity": "node ../../scripts/run-cli-parity-tests.mjs",
28
+ "start": "node dist/index.js",
29
+ "dev": "node --import tsx bin/aria-dev.js",
30
+ "dev:repl": "node --import tsx bin/aria-dev.js"
31
+ },
16
32
  "dependencies": {
33
+ "@aria-cli/aria": "1.0.19",
34
+ "@aria-cli/auth": "1.0.19",
35
+ "@aria-cli/memoria": "1.0.19",
36
+ "@aria-cli/memoria-bridge": "1.0.19",
37
+ "@aria-cli/models": "1.0.19",
38
+ "@aria-cli/server": "1.0.19",
39
+ "@aria-cli/tools": "1.0.19",
40
+ "@aria-cli/types": "1.0.19",
41
+ "@aria-cli/wireguard": "1.0.19",
17
42
  "better-sqlite3": "^12.6.2",
18
43
  "chalk": "^5.6.2",
19
44
  "cli-highlight": "^2.1.11",
20
45
  "color-name": "^2.1.0",
21
46
  "commander": "^14.0.3",
22
47
  "diff": "^8.0.3",
23
- "figures": "^6.1.0",
24
48
  "gradient-string": "^3.0.0",
25
49
  "ink": "npm:@jrichman/ink@^6.4.11",
26
50
  "ink-spinner": "^5.0.0",
@@ -31,16 +55,7 @@
31
55
  "string-width": "^8.2.0",
32
56
  "wrap-ansi": "^10.0.0",
33
57
  "yaml": "^2.8.2",
34
- "zod": "^4.3.6",
35
- "@aria-cli/memoria": "1.0.15",
36
- "@aria-cli/aria": "1.0.15",
37
- "@aria-cli/memoria-bridge": "1.0.15",
38
- "@aria-cli/auth": "1.0.15",
39
- "@aria-cli/tools": "1.0.15",
40
- "@aria-cli/types": "1.0.15",
41
- "@aria-cli/models": "1.0.15",
42
- "@aria-cli/server": "1.0.15",
43
- "@aria-cli/wireguard": "1.0.15"
58
+ "zod": "^4.3.6"
44
59
  },
45
60
  "devDependencies": {
46
61
  "@testing-library/react": "^16.3.2",
@@ -57,20 +72,7 @@
57
72
  "!**/*.map",
58
73
  "!**/*.tsbuildinfo"
59
74
  ],
60
- "scripts": {
61
- "test": "vitest run --config vitest.config.ts",
62
- "test:list": "tsx tests/print-default-test-lane.ts",
63
- "test:watch": "vitest --config vitest.config.ts",
64
- "test:integration": "vitest run --config vitest.integration.config.ts",
65
- "test:native": "vitest run --config vitest.native.config.ts",
66
- "test:e2e": "vitest run --config vitest.e2e.config.ts",
67
- "test:e2e:watch": "vitest --config vitest.e2e.config.ts",
68
- "test:e2e:mocked": "vitest run --config vitest.e2e.config.ts --testNamePattern='mocked|error|rejects|handles|prevents'",
69
- "test:real": "vitest run --config vitest.real.config.ts",
70
- "test:lanes": "tsx tests/print-test-lane-manifest.ts",
71
- "test:parity": "node ../../scripts/run-cli-parity-tests.mjs",
72
- "start": "node dist/index.js",
73
- "dev": "node --import tsx bin/aria-dev.js",
74
- "dev:repl": "node --import tsx bin/aria-dev.js"
75
+ "engines": {
76
+ "node": ">=20.0.0"
75
77
  }
76
- }
78
+ }
@@ -1 +0,0 @@
1
- import{oa as a,pa as b,qa as c,ra as d,sa as e,ta as f}from"./index-sx36201d.js";import"./index-nnqfqvqh.js";import"./index-9j6r3gr8.js";export{e as resolveLocalControlClientSync,d as resolveLocalControlClient,a as requestRuntimeSocketLease,f as createResilientAttachedClient,c as attachLocalControlClient,b as attachExistingLocalControlClient};
@@ -1 +0,0 @@
1
- import{aa as a}from"./index-5v7br509.js";import"./index-g5devafm.js";import"./index-sx36201d.js";import"./index-nnqfqvqh.js";import"./index-9j6r3gr8.js";export{a as createDaemonService};
@@ -1,2 +0,0 @@
1
- import{createRequire as e}from"node:module";var t=e(import.meta.url),i=t("../package.json"),s=i.version,r=["⚡ Search millions of lines instantly with native Rust-powered code search","\uD83E\uDDE0 Jump to definitions & find references with real LSP intelligence","✏️ Press Esc×2 to edit and fork any previous message in-place","\uD83D\uDD0A Get audio cues when tasks finish — try /sound to configure","\uD83C\uDFA8 All 87 tools now render rich, beautiful output in the terminal"];
2
- export{s as n,r as o};
@@ -1,2 +0,0 @@
1
- import{ra as x}from"./index-sx36201d.js";import{spawn as H}from"node:child_process";import{existsSync as j,mkdirSync as Y,openSync as k,closeSync as F}from"node:fs";import I from"node:path";import{fileURLToPath as Z}from"node:url";var b=15000,q=250;function U(z){return new Promise((G)=>setTimeout(G,Math.max(z,0)))}function M(){let z=Z(new URL("../../../server/dist/daemon-launcher.js",import.meta.url));if(j(z))return{command:process.execPath,args:[z]};try{let B=Z(import.meta.resolve("@aria-cli/server/daemon-launcher"));if(j(B))return{command:process.execPath,args:[B]}}catch{}let G=Z(new URL("../../../server/src/daemon-launcher.ts",import.meta.url));return{command:process.execPath,args:["--import","tsx",G]}}function N(z,G,B){return(typeof B.arion==="string"?B.arion.trim():"")||G||z.config.activeArion?.trim()||"ARIA"}function P(z){return{...typeof z.intervalMs==="number"?{intervalMs:z.intervalMs}:{},...z.allowedToolCategories||z.allowedShellCommands||typeof z.maxWriteOpsPerMinute==="number"||typeof z.maxGitPushesPerHour==="number"?{safetyPolicy:{...Array.isArray(z.allowedToolCategories)?{allowedToolCategories:z.allowedToolCategories}:{},...Array.isArray(z.allowedShellCommands)?{allowedShellCommands:z.allowedShellCommands}:{},...typeof z.maxWriteOpsPerMinute==="number"?{maxWriteOpsPerMinute:z.maxWriteOpsPerMinute}:{},...typeof z.maxGitPushesPerHour==="number"?{maxGitPushesPerHour:z.maxGitPushesPerHour}:{}}}:{}}}async function R(z){let G=Date.now()+b,B=null;while(Date.now()<G){try{let K=await x({ariaHome:z.ariaHome});if(K){let V=await K.getRuntimeStatus();if(!z.requireRunning||V.autonomousLoop.status==="running")return V}}catch(K){B=K instanceof Error?K:Error(String(K))}await U(q)}throw Error(B?.message??"Timed out waiting for the daemon runtime to become reachable")}function y(z){let G=M(),B=[...G.args,"--arion",z.arionName];if(typeof z.input.port==="number")B.push("--port",String(z.input.port));if(typeof z.input.intervalMs==="number")B.push("--interval-ms",String(z.input.intervalMs));if(Array.isArray(z.input.allowedToolCategories)&&z.input.allowedToolCategories.length>0)B.push("--allowed-tool-categories",z.input.allowedToolCategories.join(","));if(Array.isArray(z.input.allowedShellCommands)&&z.input.allowedShellCommands.length>0)B.push("--allowed-shell-commands",z.input.allowedShellCommands.join(","));if(typeof z.input.maxWriteOpsPerMinute==="number")B.push("--max-write-ops-per-minute",String(z.input.maxWriteOpsPerMinute));if(typeof z.input.maxGitPushesPerHour==="number")B.push("--max-git-pushes-per-hour",String(z.input.maxGitPushesPerHour));let K=I.join(z.ariaHome,"logs");Y(K,{recursive:!0});let V=k(I.join(K,"daemon-stderr.log"),"a");H(G.command,B,{cwd:z.cwd,env:{...process.env,ARIA_HOME:z.ariaHome},detached:!0,stdio:["ignore","ignore",V]}).unref(),F(V)}function D(z){let G=z.cli.ariaDir,B=!1,K=()=>z.getArionName?.()??z.arionName??"ARIA",V=(Q)=>{let J=typeof Q.arion==="string"?Q.arion.trim():"",W=K();if(J&&J!==W)throw Error(`daemon operations are scoped to ${W}; switch scope with arion.become before targeting ${J}`);return J||W},X=async()=>{if(!z.localControl)return null;try{return await z.localControl.getRuntimeStatus(),z.localControl}catch{return null}};return{async start(Q){let J=N(z.cli,V(Q),Q),W=await X();if(!W)return B=!0,y({ariaHome:G,cwd:z.cwd,arionName:J,input:Q}),R({ariaHome:G,requireRunning:!0});let $=await W.getRuntimeStatus();if($.autonomousLoop.status==="running")return B=!1,$;if(!W.startAutonomousLoop)throw Error("Live runtime does not expose autonomous-loop start control");return B=!0,W.startAutonomousLoop(P(Q))},async status(Q={}){V(Q);let J=await X();if(!J)throw Error("No live runtime is available for daemon.status");return J.getRuntimeStatus()},async stop(Q={}){V(Q);let J=await X();if(!J)throw Error("No live runtime is available for daemon.stop");if(!J.stopAutonomousLoop)throw Error("Live runtime does not expose autonomous-loop stop control");return B=!1,J.stopAutonomousLoop()},shouldStopOnShutdown(){return B},async releaseAll(){}}}
2
- export{D as aa};
@@ -1,12 +0,0 @@
1
- import{k as g}from"./index-j035n0mr.js";import{n as X$}from"./index-00jaxgt2.js";import{B as U$}from"./index-wbm34jf5.js";import{aa as e}from"./index-5v7br509.js";import{na as L}from"./index-sxga6d5s.js";import{ua as t,xa as H,ya as C}from"./index-nnqfqvqh.js";import{za as B}from"./index-9j6r3gr8.js";import{Command as e$}from"commander";import{Command as y$}from"commander";import{ArionManager as _$,ArionStorage as x$,MemoriaPool as B$}from"@aria-cli/aria";async function O(){let $=t(),J=new x$($),G=new B$($).toFactory(),Q=new _$(J,G);return await Q.initialize(),Q}function P(){let $=new y$("arions").description("Manage Arion personas");return $.command("list").description("List all Arions with status").option("--status <status>","Filter by status (active, resting, retired)").action(async(J)=>{try{let G=await(await O()).list(),Q=J.status?G.filter((U)=>U.status===J.status):G;if(Q.length===0){console.log("No Arions found.");return}console.log(`
2
- Arions:`),console.log("─".repeat(60));for(let U of Q){let X=U.status==="active"?"●":U.status==="resting"?"○":"×";if(console.log(`${X} ${U.name} [${U.status}]`),console.log(` Style: ${U.personality.style}`),console.log(` Traits: ${U.personality.traits.join(", ")}`),U.skills.length>0)console.log(` Skills: ${U.skills.map((Z)=>Z.name).join(", ")}`);console.log()}}catch(z){console.error("Error listing Arions:",z.message),process.exit(1)}}),$.command("hatch").description("Create a new Arion").argument("<name>","Name for the new Arion").option("-t, --traits <traits>","Comma-separated personality traits").option("-s, --style <style>","Communication style (formal, casual, technical, friendly)").option("--skills <skills>","Comma-separated skills").action(async(J,z)=>{try{let G=await O(),Q=z.traits?z.traits.split(",").map((j)=>j.trim()):["helpful","curious"],U=z.style||"friendly",X=z.skills?z.skills.split(",").map((j)=>({name:j.trim(),level:"intermediate"})):[],Z=await G.hatch({name:J,personality:{traits:Q,style:U},skills:X,createdBy:"cli"});if(console.log(`
3
- Hatched new Arion: ${Z.name}`),console.log(` ID: ${Z.id}`),console.log(` Status: ${Z.status}`),console.log(` Style: ${Z.personality.style}`),console.log(` Traits: ${Z.personality.traits.join(", ")}`),Z.skills.length>0)console.log(` Skills: ${Z.skills.map((j)=>j.name).join(", ")}`)}catch(G){console.error("Error hatching Arion:",G.message),process.exit(1)}}),$.command("become").description("Switch to an Arion").argument("<name>","Name of the Arion to switch to").action(async(J)=>{try{let z=await O(),G=await z.get(J);if(!G)console.error(`Arion not found: ${J}`),process.exit(1);if(G.status==="retired")console.error(`Cannot become retired Arion: ${J}`),process.exit(1);if(G.status==="resting")await z.wake(J);let Q=H();Q.activeArion=G.name,C(Q),console.log(`
4
- Switched to Arion: ${G.name}`),console.log(` Style: ${G.personality.style}`),console.log(` Traits: ${G.personality.traits.join(", ")}`)}catch(z){console.error("Error switching Arion:",z.message),process.exit(1)}}),$.command("retire").description("Retire an Arion (permanent)").argument("<name>","Name of the Arion to retire").option("--confirm","Confirm retirement (required)").action(async(J,z)=>{try{if(!z.confirm)console.error("Retirement is permanent. Use --confirm to proceed."),process.exit(1);await(await O()).retire(J,{confirm:!0});let Q=H();if(Q.activeArion?.toLowerCase()===J.toLowerCase())delete Q.activeArion,C(Q);console.log(`
5
- Retired Arion: ${J}`),console.log("The Arion can no longer be used but its memories are preserved.")}catch(G){console.error("Error retiring Arion:",G.message),process.exit(1)}}),$}import{Command as L$}from"commander";import{createInterface as k$}from"node:readline";import{ensureAuthProfileStore as H$,syncExternalCliCredentials as E$,isProfileInCooldown as O$,upsertAuthProfile as q$,updateAuthProfileStoreWithLockSync as o}from"@aria-cli/auth";var D$=["COPILOT_GITHUB_TOKEN","GH_TOKEN","GITHUB_TOKEN"];function C$($=process.env){for(let J of D$){let z=$[J];if(z&&z.length>8)return J}return null}async function P$(){let $=o({updater:(z)=>E$(z)})??H$(),J=Object.entries($.profiles);if(J.length===0){console.log("No auth profiles configured."),console.log("Add one with: aria auth add --provider <name>");return}for(let[z,G]of J){let U=O$($,z)?"cooldown":"active",X=G.type.padEnd(7);if(console.log(` ${z.padEnd(30)} [${X}] ${U}`),G.email)console.log(` email: ${G.email}`);if((G.type==="oauth"||G.type==="token")&&"expires"in G){let Z=G.expires;if(Z){let j=Z-Date.now(),b=j>0?`expires in ${Math.round(j/60000)}min`:"EXPIRED";console.log(` ${b}`)}}if(G.provider==="github-copilot"){let Z=C$();if(Z)console.log(` env override: ${Z}`)}}}async function v$($){let J=$.provider.toLowerCase().trim(),z=`${J}:manual`,G=k$({input:process.stdin,output:process.stdout}),Q=await new Promise((U)=>{G.question(`Paste API key for ${J}: `,(X)=>{G.close(),U(X.trim())})});if(!Q||Q.length<8)console.error("API key too short (minimum 8 characters)."),process.exit(1);q$({profileId:z,credential:{type:"api_key",provider:J,key:Q}}),console.log(`Saved auth profile: ${z}`)}async function A$($){let J=!1,z=o({updater:(G)=>{if(!G.profiles[$])return!1;return delete G.profiles[$],J=!0,!0}});if(!J||!z)console.error(`Profile not found: ${$}`),process.exit(1);console.log(`Removed auth profile: ${$}`)}function v(){let $=new L$("auth").description("Manage auth profiles");return $.command("status").description("Show all auth profiles and their health").action(P$),$.command("add").description("Add an API key for a provider").requiredOption("--provider <name>","Provider name (anthropic, openai, google)").action(v$),$.command("remove").description("Remove an auth profile").argument("<profile-id>","Profile ID to remove").action(A$),$}function A($,J,z){if($===void 0||$.trim()==="")return z;let G=Number.parseInt($,10);if(!Number.isFinite(G)||G<=0)throw Error(`${J} must be a positive integer`);return G}function a($){if(!$)return;let J=$.split(",").map((z)=>z.trim()).filter((z)=>z.length>0);return J.length>0?J:void 0}function F$($,J){if($===void 0||$.trim()==="")return J;let z=Number.parseInt($,10);if(!Number.isFinite(z)||z<0)throw Error("port must be a non-negative integer (0 = OS-assigned)");return z}function I$($){return{arion:$.arion,port:F$($.port,0),intervalMs:A($.intervalMs,"intervalMs",60000),allowedToolCategories:a($.allowedToolCategories),allowedShellCommands:a($.allowedShellCommands),maxWriteOpsPerMinute:$.maxWriteOpsPerMinute!==void 0?A($.maxWriteOpsPerMinute,"maxWriteOpsPerMinute",30):void 0,maxGitPushesPerHour:$.maxGitPushesPerHour!==void 0?A($.maxGitPushesPerHour,"maxGitPushesPerHour",5):void 0}}function R$($){if($.aborted)return Promise.resolve();return new Promise((J)=>{$.addEventListener("abort",()=>J(),{once:!0})})}function r($){return{...$.arion?{arion:$.arion}:{},...$.port>=0?{port:$.port}:{},intervalMs:$.intervalMs,...$.allowedToolCategories?{allowedToolCategories:$.allowedToolCategories}:{},...$.allowedShellCommands?{allowedShellCommands:$.allowedShellCommands}:{},...typeof $.maxWriteOpsPerMinute==="number"?{maxWriteOpsPerMinute:$.maxWriteOpsPerMinute}:{},...typeof $.maxGitPushesPerHour==="number"?{maxGitPushesPerHour:$.maxGitPushesPerHour}:{}}}async function F($={}){let J=I$($);await w$(J)}async function I(){let{resolveRuntimeRootDirectory:$,findRuntimeOwnerRecordByAriaHome:J,removeRuntimeOwnerRecord:z}=await import("@aria-cli/server"),{getAriaDir:G}=await import("./config.js"),Q=G(),U=$(),X=J(U,Q);if(!X){console.log("[daemon] no running daemon found");return}try{process.kill(X.runtimePid,"SIGINT"),console.log(`[daemon] sent SIGINT to pid ${X.runtimePid}`);let Z=Date.now()+5000;while(Date.now()<Z)try{process.kill(X.runtimePid,0),await new Promise((j)=>setTimeout(j,200))}catch{break}try{process.kill(X.runtimePid,0),process.kill(X.runtimePid,"SIGKILL"),console.log(`[daemon] force-killed pid ${X.runtimePid}`)}catch{}}catch{}z(U,X.nodeId),console.log("[daemon] stopped")}async function $$($={}){await I(),await new Promise((U)=>setTimeout(U,500));let{ensureDaemon:J}=await import("./ensure-daemon.js"),z=await L(),Q=await(await J(z)).control.listPeers();console.log(`[daemon] restarted (${Q.length} peers connected)`),await z.pool?.closeAll?.()}async function w$($){let J=new AbortController,z=()=>J.abort(),G=()=>J.abort(),Q=()=>{};process.on("SIGINT",z),process.on("SIGTERM",G),process.on("SIGHUP",Q);let U=H(),X=$.arion?.trim()||U.activeArion?.trim()||"ARIA",Z=await L({startupMode:"daemon"}),j=e({cli:Z,cwd:process.cwd(),arionName:X}),b=null;try{let M=await j.start(r($));console.log(`[daemon] runtime node ${String(M.nodeId??"unknown")}`),console.log(`[daemon] runtime ${String(M.runtimeId??"unknown")} listening on port ${String(M.port??"unknown")}`),console.log(`[daemon] running arion "${X}" (interval ${$.intervalMs}ms)`),b=setInterval(()=>{j.status({}).catch(()=>{})},Math.min(Math.max($.intervalMs,1000),5000)),await R$(J.signal)}catch(M){console.error(`[daemon] Runtime startup failed: ${M instanceof Error?M.message:String(M)}`),process.exitCode=1}finally{if(b)clearInterval(b),b=null;try{if(J.signal.aborted&&j.shouldStopOnShutdown?.())await j.stop?.(r($))}catch{}await j.releaseAll?.(),await Z.pool.closeAll().catch(()=>{}),process.removeListener("SIGINT",z),process.removeListener("SIGTERM",G),process.removeListener("SIGHUP",Q),console.log("[daemon] stopped")}}import{Command as g$}from"commander";import{existsSync as c$,readFileSync as R}from"node:fs";import{homedir as S$}from"node:os";import J$ from"node:path";function h$($){if(!$||$==="-"){let J=R(0,"utf8").trim();return J?JSON.parse(J):{}}return JSON.parse(R($,"utf8"))}function u$($,J){if($==="interaction.respond")return{kind:"interaction.respond",requestId:"call-1",...J};return{kind:"request",requestId:"call-1",op:$,input:J}}function T$(){if(process.env.ARIA_HOME)return process.env.ARIA_HOME;return J$.join(process.env.HOME||S$(),".aria")}function d$($){if(typeof $.arion==="string"&&$.arion.trim().length>0)return $.arion.trim();let J=J$.join(T$(),"config.json");if(!c$(J))return"ARIA";try{let z=JSON.parse(R(J,"utf8"));if(typeof z.activeArion==="string"&&z.activeArion.trim().length>0)return z.activeArion.trim()}catch{}return"ARIA"}function z$($){return{kind:"result",requestId:"call-1",op:$,ok:!1,error:{code:"NO_RESULT",message:`Operation ${$} produced no result frame`}}}async function f$($,J,z){let[{SessionHistory:G},{createSessionOperationHandlers:Q}]=await Promise.all([import("./history/index.js"),import("./session-ybzq2j2n.js")]),U=new G(G.resolvePerArionPath(T$(),d$(z)));try{let X=Q({sessionLedger:U}),Z=null;for await(let j of X[$]("call-1",J))if(j.kind==="result")Z=j;return Z??z$($)}finally{U.close()}}async function p$($,J,z){switch($){case"session.list":case"session.read":case"session.load":return f$($,J,z);default:return null}}async function l$($,J){try{let z=h$(J.inputJson),G=await p$($,z,J);if(G)return process.stdout.write(`${JSON.stringify(G)}
6
- `),G.ok?0:1;let{createHeadlessKernelRuntime:Q}=await import("./kernel-0tytvcv0.js"),U=await Q({cwd:process.cwd(),arionName:J.arion});try{let X=null;for await(let Z of U.kernel.dispatch(u$($,z)))if(Z.kind==="result")X=Z;if(!X)return process.stdout.write(`${JSON.stringify(z$($))}
7
- `),1;return process.stdout.write(`${JSON.stringify(X)}
8
- `),X.ok?0:1}finally{await U.release()}}catch(z){return process.stderr.write(`${z instanceof Error?z.message:String(z)}
9
- `),2}}function w(){return new g$("call").description("Execute one headless operation and print exactly one JSON result").argument("<operation>","Headless operation name").option("--input-json <path|->","Read JSON input from a file path or stdin","-").option("--arion <name>","Arion name for per-Arion session context").action(async($,J)=>{process.exitCode=await l$($,J)})}import{Command as m$}from"commander";function i$($){let J=Number.parseInt($,10);if(!Number.isFinite(J)||J<0)throw Error(`Invalid --duration-ms value: ${$}`);return J}function c(){let $=new m$("pairing").description("Invite and join peers over the internet");return $.command("invite").description("Create an end-user internet pairing invite").argument("[label]","Optional local label for the invite").option("--duration-ms <ms>","Invite lifetime in milliseconds",i$).action(async(J,z)=>{let G=await L();try{let{control:Q}=await g(G),U=await Q.createInvite({...J?.trim()?{inviteLabel:J.trim()}:{},...typeof z?.durationMs==="number"?{durationMs:z.durationMs}:{}});console.log("Invite token:"),console.log(U.inviteToken),console.log(""),console.log(`Join with: aria pairing join ${U.inviteToken}`)}catch(Q){console.error(`Failed to create invite: ${Q.message}`),process.exit(1)}finally{await G.pool?.closeAll?.()}}),$.command("join").description("Accept an internet pairing invite token").argument("<token>","Invite token to accept").action(async(J)=>{let z=await L();try{let{control:G}=await g(z),Q=await G.acceptInviteToken({inviteToken:J.trim()});console.log(`Paired with ${Q.displayNameSnapshot??Q.nodeId}`)}catch(G){console.error(`Failed to accept invite: ${G.message}`),process.exit(1)}finally{await z.pool?.closeAll?.()}}),$}import{Command as s$}from"commander";function S(){return new s$("runtime-cutover-reset").description("Destructively clear stale runtime state while preserving local node identity by default").option("--full-reset","Also remove local node identity material").option("--json","Emit the reset report as JSON").action(async($)=>{let{runtimeCutoverResetCommand:J}=await import("./runtime-cutover-reset-0nywfrh6.js");await J($)})}import{HEADLESS_OPERATION_SCHEMAS as G$,HeadlessInteractionResponseSchema as n$,HeadlessRequestIdSchema as Q$}from"@aria-cli/tools";var t$=200,o$=500;function a$($=process.stdout){let J=!1,z=()=>{J=!0};$.on?.("error",z);let G=(Q)=>{if(J)return!1;try{return $.write(`${JSON.stringify(Q)}
10
- `),!0}catch{return J=!0,!1}};return G.close=()=>{$.off?.("error",z)},G}function r$($,J,z){let G;try{G=JSON.parse($)}catch{return z({kind:"result",requestId:`parse-error-${J}`,op:"unknown",ok:!1,error:{code:"PARSE_ERROR",message:"Malformed JSON input"}}),null}if(!G||typeof G!=="object")return z({kind:"result",requestId:`parse-error-${J}`,op:"unknown",ok:!1,error:{code:"PARSE_ERROR",message:"Input must be a JSON object"}}),null;let Q=G;if(Q.kind==="interaction.respond"&&Q$.safeParse(Q.requestId).success&&typeof Q.interactionId==="string")return Q;if(Q.kind==="request"&&Q$.safeParse(Q.requestId).success&&typeof Q.op==="string")return Q;return z({kind:"result",requestId:`parse-error-${J}`,op:"unknown",ok:!1,error:{code:"PARSE_ERROR",message:"Missing required kind/requestId/op fields"}}),null}async function h($){let J=a$(),z=null,G=null,Q=null,U=new Set,X=new Set,Z=new Set,j=new Map,b=0,M=null,x="",d=!1,f=!1,q=null,Z$=new Promise((T)=>{q=()=>{if(f)return;f=!0,T()}}),j$=()=>{return z??=U$($).then((T)=>{return G=T,T}),z},Y$=()=>{return Q??=(async()=>{if(G){await G.release();return}if(!z)return;try{let T=await z;G=T,await T.release()}catch{}})(),Q},N$=(T)=>Object.prototype.hasOwnProperty.call(G$,T),p=async(T,Y)=>{if(T.aborted)return{kind:"aborted"};return new Promise((y,V)=>{let K=!1,N=()=>{if(K)return;K=!0,T.removeEventListener("abort",N),y({kind:"aborted"})};T.addEventListener("abort",N),Y.then((W)=>{if(K)return;K=!0,T.removeEventListener("abort",N),y({kind:"value",value:W})},(W)=>{if(K)return;K=!0,T.removeEventListener("abort",N),V(W)})})},V$=async(T)=>{if(typeof T.return!=="function")return!0;try{let y=T.return().then(()=>{return},()=>{return}).finally(()=>{Z.delete(y)}),V=await Promise.race([y.then(()=>!0),new Promise((K)=>setTimeout(()=>K(!1),t$))]);if(!V)Z.add(y);return V}catch{return!1}},K$=(T,Y)=>J({kind:"result",requestId:T,op:Y,ok:!1,error:{code:"CONNECTION_CLOSED",message:"Connection closed before request completed"}}),l=()=>{return M??=(async()=>{for(let[T,Y]of j){if(Y.controller.abort(),Y.completed||Y.connectionClosedEmitted)continue;Y.connectionClosedEmitted=!0,K$(T,Y.op)}if(await Promise.allSettled([...j.values()].map((T)=>T.promise)),Z.size>0)await Promise.race([Promise.allSettled([...Z]),new Promise((T)=>setTimeout(()=>T(),o$))]);await Y$(),J.close(),process.stdin.removeListener("data",s),process.stdin.removeListener("end",E),process.stdin.removeListener("close",E),process.removeListener("SIGTERM",m)})(),M},m=()=>{process.stdin.pause(),l().finally(()=>q?.())};process.once("SIGTERM",m);let i=(T)=>{b+=1;let Y=r$(T,b,J);if(Y)W$(Y)},M$=()=>{while(!0){let T=x.indexOf(`
11
- `);if(T<0)return;let Y=x.slice(0,T);if(Y.endsWith("\r"))Y=Y.slice(0,-1);x=x.slice(T+1),i(Y)}},s=(T)=>{x+=typeof T==="string"?T:T.toString("utf8"),M$()},E=()=>{if(d)return;d=!0;let T=x;if(T.endsWith("\r"))T=T.slice(0,-1);if(x="",T.trim().length>0)i(T);l().finally(()=>q?.())},W$=(T)=>{let Y=T.kind==="request"?T.op:"interaction.respond",y=[...j.values()].some((N)=>N.op==="arion.become");if(T.kind==="request"&&(T.op==="arion.become"&&U.size>0||T.op!=="arion.become"&&y)){J({kind:"result",requestId:T.requestId,op:Y,ok:!1,error:{code:"ARION_SCOPE_BUSY",message:T.op==="arion.become"?"arion.become requires an idle headless connection":"Headless scope is switching arions; wait for arion.become to finish"}}),X.add(T.requestId);return}if(U.has(T.requestId)){J({kind:"result",requestId:T.requestId,op:Y,ok:!1,error:{code:"DUPLICATE_REQUEST_ID",message:`Request ${T.requestId} is already in flight`}});return}if(X.has(T.requestId)){J({kind:"result",requestId:T.requestId,op:T.kind==="request"?T.op:"interaction.respond",ok:!1,error:{code:"DUPLICATE_REQUEST_ID",message:`Request ${T.requestId} has already been used on this connection`}});return}if(T.kind==="request"){if(!N$(T.op)){J({kind:"result",requestId:T.requestId,op:T.op,ok:!1,error:{code:"UNKNOWN_OPERATION",message:`Unknown operation ${T.op}`}}),X.add(T.requestId);return}if(!G$[T.op].input.safeParse(T.input).success){J({kind:"result",requestId:T.requestId,op:T.op,ok:!1,error:{code:"INVALID_INPUT",message:`Invalid input for ${T.op}`}}),X.add(T.requestId);return}}else if(!n$.safeParse(T).success){J({kind:"result",requestId:T.requestId,op:"interaction.respond",ok:!1,error:{code:"INVALID_INPUT",message:"Invalid input for interaction.respond"}}),X.add(T.requestId);return}U.add(T.requestId),X.add(T.requestId);let V=new AbortController,K=null;K=(async()=>{try{let N=await p(V.signal,j$().then((k)=>({runtime:k})));if(N.kind!=="value")return;let W=N.value.runtime.kernel.dispatch(T,{signal:V.signal})[Symbol.asyncIterator]();while(!0){let k=await p(V.signal,W.next().then((b$)=>({result:b$})));if(k.kind==="aborted"){await V$(W);return}if(k.value.result.done)return;let n=k.value.result.value,D=j.get(T.requestId);if(V.signal.aborted||D?.connectionClosedEmitted)continue;if(J(n),n.kind==="result"){if(D)D.completed=!0}}}catch(N){let W=j.get(T.requestId);if(V.signal.aborted||W?.connectionClosedEmitted)return;if(J({kind:"result",requestId:T.requestId,op:Y,ok:!1,error:{code:"INTERNAL_ERROR",message:N instanceof Error?N.message:String(N)}}),W)W.completed=!0}finally{U.delete(T.requestId),j.delete(T.requestId)}})(),j.set(T.requestId,{op:Y,controller:V,completed:!1,connectionClosedEmitted:!1,promise:K})};process.stdin.setEncoding("utf8"),process.stdin.on("data",s),process.stdin.once("end",E),process.stdin.once("close",E),await Z$}var _=new e$;_.name("aria").description("ARIA - Adaptive Reasoning Intelligence Agent").version(X$);_.addCommand(P());_.addCommand(v());_.addCommand(c());_.command("headless").description("Run the persistent headless stdio control server").option("--arion <name>","Arion name for per-Arion session context").action(async($)=>{await h({cwd:process.cwd(),arionName:$.arion})});_.addCommand(w());var u=_.command("daemon").description("Manage the ARIA daemon");u.command("start",{isDefault:!0}).description("Start the daemon (default)").option("--arion <name>","Run daemon for a specific Arion").option("--port <port>","Server port (default: 0 = OS-assigned)").option("--interval-ms <ms>","Wake loop interval in milliseconds (default: 60000)").option("--allowed-tool-categories <list>","Comma-separated tool category allowlist").option("--allowed-shell-commands <list>","Comma-separated shell command prefix allowlist").option("--max-write-ops-per-minute <count>","Rate limit for write operations per minute").option("--max-git-pushes-per-hour <count>","Rate limit for git pushes per hour").action(async($)=>{await F($)});u.command("stop").description("Stop the running daemon").action(async()=>{await I()});u.command("restart").description("Stop the daemon and start a fresh one").action(async()=>{await $$()});_.addCommand(S());
12
- export{P as a,v as b,F as c,w as d,c as e,S as f,h as g,_ as h};