@yuandc/aica 0.1.27 → 0.1.28

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 @@
1
- import{spawn as s}from"node:child_process";import{acpChildEnvironment as u}from"../../core/process-identity.js";function a(e,t,n,r={}){const i=s(e,t,{cwd:n,stdio:["pipe","pipe","pipe"],env:u(e,t,r)});return{command:e,args:t,child:i}}async function f(e){e.exitCode!==null||e.signalCode!==null||(e.stdin.end(),!await o(e,2e3)&&(e.kill("SIGTERM"),!await o(e,1e3)&&(e.kill("SIGKILL"),await o(e,1e3))))}function o(e,t){return e.exitCode!==null||e.signalCode!==null?Promise.resolve(!0):new Promise(n=>{const r=setTimeout(()=>n(!1),t);r.unref(),e.once("close",()=>{clearTimeout(r),n(!0)})})}export{f as closeAcpProcess,a as startAcpProcess};
1
+ import{spawn as s}from"node:child_process";import{acpChildEnvironment as u}from"../../core/process-identity.js";function a(e,t,n,r={}){const i=s(e,t,{cwd:n,stdio:["pipe","pipe","pipe"],env:u(e,t,r),windowsHide:!0});return{command:e,args:t,child:i}}async function f(e){e.exitCode!==null||e.signalCode!==null||(e.stdin.end(),!await o(e,2e3)&&(e.kill("SIGTERM"),!await o(e,1e3)&&(e.kill("SIGKILL"),await o(e,1e3))))}function o(e,t){return e.exitCode!==null||e.signalCode!==null?Promise.resolve(!0):new Promise(n=>{const r=setTimeout(()=>n(!1),t);r.unref(),e.once("close",()=>{clearTimeout(r),n(!0)})})}export{f as closeAcpProcess,a as startAcpProcess};
@@ -1 +1 @@
1
- import{spawn as s}from"node:child_process";import{acpChildEnvironment as t}from"../../../core/process-identity.js";import{resolveCodexPath as n}from"./codex-path.js";import{resolveCodexPath as v}from"./codex-path.js";function m(e,o=null){const r=n(),a=d(o),p=s(r,a,{cwd:e,env:t(r,a,{CODEX_PATH:r,...o?{ACA_CODEX_PROVIDER_KEY:o.apiKey}:{}}),stdio:["pipe","pipe","pipe"]});return p.stdout.setEncoding("utf8"),p.stderr.setEncoding("utf8"),{command:r,args:a,child:p}}function d(e){return e?["-c",'model_provider="aca_managed"',"-c",'model_providers.aca_managed.name="ACA Managed"',"-c",`model_providers.aca_managed.base_url=${JSON.stringify(e.baseUrl)}`,"-c",'model_providers.aca_managed.env_key="ACA_CODEX_PROVIDER_KEY"',"-c",'model_providers.aca_managed.wire_api="responses"',"-c","model_providers.aca_managed.requires_openai_auth=false","app-server","--stdio"]:["app-server","--stdio"]}export{d as codexAppServerArgs,v as resolveCodexPath,m as startCodexAppServer};
1
+ import{spawn as s}from"node:child_process";import{acpChildEnvironment as t}from"../../../core/process-identity.js";import{resolveCodexPath as n}from"./codex-path.js";import{resolveCodexPath as v}from"./codex-path.js";function m(e,o=null){const r=n(),a=d(o),p=s(r,a,{cwd:e,env:t(r,a,{CODEX_PATH:r,...o?{ACA_CODEX_PROVIDER_KEY:o.apiKey}:{}}),stdio:["pipe","pipe","pipe"],windowsHide:!0});return p.stdout.setEncoding("utf8"),p.stderr.setEncoding("utf8"),{command:r,args:a,child:p}}function d(e){return e?["-c",'model_provider="aca_managed"',"-c",'model_providers.aca_managed.name="ACA Managed"',"-c",`model_providers.aca_managed.base_url=${JSON.stringify(e.baseUrl)}`,"-c",'model_providers.aca_managed.env_key="ACA_CODEX_PROVIDER_KEY"',"-c",'model_providers.aca_managed.wire_api="responses"',"-c","model_providers.aca_managed.requires_openai_auth=false","app-server","--stdio"]:["app-server","--stdio"]}export{d as codexAppServerArgs,v as resolveCodexPath,m as startCodexAppServer};
@@ -1,3 +1,3 @@
1
- import{Command as i}from"commander";import s from"chalk";import m from"node:fs";import p from"node:path";import{spawn as S}from"node:child_process";import{randomUUID as $}from"node:crypto";import{getLogDir as c,getRuntimeStatePath as y}from"../core/paths.js";import{ensureDir as g,readJsonFile as C}from"../core/fs.js";import{isProcessAlive as r,readPidFile as u,removePidFile as f}from"../core/process.js";import{ACA_WORKER_INSTANCE_ENV as x}from"../core/process-identity.js";import{applyRuntimePathOptions as l}from"../core/runtime-options.js";const h=3e4;function G(){return new i("daemon").description("Run aca as a background daemon service").addCommand(d(new i("start").description("Start aca daemon in the background")).allowUnknownOption(!0).action(e=>{l(e);const o=u();if(o&&r(o)){console.log(`Daemon is already running (PID ${o}).`),process.exitCode=1;return}const n=D(w("start"));n.unref(),console.log(`Daemon started (PID ${n.pid})`),I()})).addCommand(d(new i("stop").description("Stop the running aca daemon")).action(async e=>{l(e);const o=u();if(!o){console.log("No daemon PID file found. Daemon is not running.");return}if(!r(o)){console.log(`Daemon process (PID ${o}) is not running. Cleaning up PID file.`),f();return}await P(o)?(f(),console.log(`Daemon stopped successfully (PID ${o}).`)):(console.log(`Daemon (PID ${o}) is still running. You may need to kill it manually: ${s.yellow(`kill -9 ${o}`)}`),process.exitCode=1)})).addCommand(d(new i("status").description("Show daemon status")).action(e=>{l(e);const o=C(y()),n=u();if(n&&r(n)){console.log(s.green("● Daemon is running")),console.log(` PID: ${n}`),o?.phase&&console.log(` Phase: ${o.phase}`),o?.startupStage&&console.log(` Stage: ${o.startupStage}`);return}n?(console.log(s.red("● Daemon is not running (stale PID file)")),f()):console.log(s.red("● Daemon is not running")),process.exitCode=1})).addCommand(d(new i("logs").description("Show daemon logs")).option("-n, --lines <count>","number of lines to show","50").action(e=>{l(e);const o=Number.parseInt(e.lines,10)||50,n=E();if(!n){console.log(`No log files found in ${c()}`),process.exitCode=1;return}const t=m.readFileSync(n,"utf8").trimEnd().split(`
1
+ import{Command as a}from"commander";import s from"chalk";import m from"node:fs";import p from"node:path";import{spawn as S}from"node:child_process";import{randomUUID as $}from"node:crypto";import{getLogDir as c,getRuntimeStatePath as y}from"../core/paths.js";import{ensureDir as g,readJsonFile as C}from"../core/fs.js";import{isProcessAlive as r,readPidFile as u,removePidFile as f}from"../core/process.js";import{ACA_WORKER_INSTANCE_ENV as x}from"../core/process-identity.js";import{applyRuntimePathOptions as l}from"../core/runtime-options.js";const w=3e4;function G(){return new a("daemon").description("Run aca as a background daemon service").addCommand(d(new a("start").description("Start aca daemon in the background")).allowUnknownOption(!0).action(e=>{l(e);const o=u();if(o&&r(o)){console.log(`Daemon is already running (PID ${o}).`),process.exitCode=1;return}const n=D(h("start"));n.unref(),console.log(`Daemon started (PID ${n.pid})`),I()})).addCommand(d(new a("stop").description("Stop the running aca daemon")).action(async e=>{l(e);const o=u();if(!o){console.log("No daemon PID file found. Daemon is not running.");return}if(!r(o)){console.log(`Daemon process (PID ${o}) is not running. Cleaning up PID file.`),f();return}await P(o)?(f(),console.log(`Daemon stopped successfully (PID ${o}).`)):(console.log(`Daemon (PID ${o}) is still running. You may need to kill it manually: ${s.yellow(`kill -9 ${o}`)}`),process.exitCode=1)})).addCommand(d(new a("status").description("Show daemon status")).action(e=>{l(e);const o=C(y()),n=u();if(n&&r(n)){console.log(s.green("● Daemon is running")),console.log(` PID: ${n}`),o?.phase&&console.log(` Phase: ${o.phase}`),o?.startupStage&&console.log(` Stage: ${o.startupStage}`);return}n?(console.log(s.red("● Daemon is not running (stale PID file)")),f()):console.log(s.red("● Daemon is not running")),process.exitCode=1})).addCommand(d(new a("logs").description("Show daemon logs")).option("-n, --lines <count>","number of lines to show","50").action(e=>{l(e);const o=Number.parseInt(e.lines,10)||50,n=E();if(!n){console.log(`No log files found in ${c()}`),process.exitCode=1;return}const t=m.readFileSync(n,"utf8").trimEnd().split(`
2
2
  `);console.log(s.dim(`--- ${n} (last ${o} lines) ---`)),console.log(t.slice(-o).join(`
3
- `))})).addCommand(d(new i("restart").description("Restart the aca daemon")).allowUnknownOption(!0).action(async e=>{l(e);const o=u();if(o&&r(o)&&!await P(o)){console.error(`Daemon restart aborted because PID ${o} did not stop within ${h}ms.`),process.exitCode=1;return}f();const n=D(w("restart"));n.unref(),console.log(`Daemon started (PID ${n.pid})`),I()}))}function d(e){return e.option("--aica-home <path>","Runtime home directory (defaults to ~/.aica)").option("--aica-config <path>","Config file path").option("--aca-home <path>","Deprecated alias for --aica-home").option("--aca-config <path>","Deprecated alias for --aica-config")}function w(e){const o=process.argv.findIndex((t,a)=>a>=2&&t==="daemon"),n=process.argv.findIndex((t,a)=>a>o&&t===e);return n>=0?process.argv.slice(n+1):[]}function D(e){const o=v();g(c());const n=new Date().toISOString().slice(0,10),t=p.join(c(),`daemon-stderr-${n}.log`),a=m.openSync(t,"a");try{return S(o.command,[...o.prefixArgs,"start",...e],{detached:!0,stdio:["ignore","ignore",a],env:{...process.env,[x]:$()}})}finally{m.closeSync(a)}}function v(){if(process.env.ACA_SINGLE_FILE_WORKER==="1")return{command:process.execPath,prefixArgs:[]};const e=process.argv[1];if(!e)throw new Error("Unable to resolve the current ACA CLI entrypoint");return{command:process.execPath,prefixArgs:[p.resolve(e)]}}function I(){const e=A();console.log(`Use ${s.yellow(`${e} daemon status`)} to check status`),console.log(`Use ${s.yellow(`${e} daemon stop`)} to stop`),console.log(`Use ${s.yellow(`${e} daemon logs`)} to view logs`)}function A(){if(process.env.ACA_SINGLE_FILE_WORKER==="1")return process.execPath;const e=p.basename(process.argv[1]||"");return/worker-cli|aica/i.test(e)?"aica":"aca"}function E(){return g(c()),m.readdirSync(c()).filter(o=>/^\d{4}-\d{2}-\d{2}\.log$/.test(o)).map(o=>p.join(c(),o)).sort().at(-1)??null}async function R(e,o){const n=Date.now();for(;Date.now()-n<o;){if(!r(e))return!0;await new Promise(t=>setTimeout(t,100))}return!r(e)}async function P(e,o=h){return r(e)?(process.kill(e,"SIGTERM"),R(e,o)):!0}export{G as createDaemonCommand,I as printStartTips,D as spawnDaemon,P as stopDaemonProcess};
3
+ `))})).addCommand(d(new a("restart").description("Restart the aca daemon")).allowUnknownOption(!0).action(async e=>{l(e);const o=u();if(o&&r(o)&&!await P(o)){console.error(`Daemon restart aborted because PID ${o} did not stop within ${w}ms.`),process.exitCode=1;return}f();const n=D(h("restart"));n.unref(),console.log(`Daemon started (PID ${n.pid})`),I()}))}function d(e){return e.option("--aica-home <path>","Runtime home directory (defaults to ~/.aica)").option("--aica-config <path>","Config file path").option("--aca-home <path>","Deprecated alias for --aica-home").option("--aca-config <path>","Deprecated alias for --aica-config")}function h(e){const o=process.argv.findIndex((t,i)=>i>=2&&t==="daemon"),n=process.argv.findIndex((t,i)=>i>o&&t===e);return n>=0?process.argv.slice(n+1):[]}function D(e){const o=v();g(c());const n=new Date().toISOString().slice(0,10),t=p.join(c(),`daemon-stderr-${n}.log`),i=m.openSync(t,"a");try{return S(o.command,[...o.prefixArgs,"start",...e],{detached:!0,stdio:["ignore","ignore",i],windowsHide:!0,env:{...process.env,[x]:$()}})}finally{m.closeSync(i)}}function v(){if(process.env.ACA_SINGLE_FILE_WORKER==="1")return{command:process.execPath,prefixArgs:[]};const e=process.argv[1];if(!e)throw new Error("Unable to resolve the current ACA CLI entrypoint");return{command:process.execPath,prefixArgs:[p.resolve(e)]}}function I(){const e=A();console.log(`Use ${s.yellow(`${e} daemon status`)} to check status`),console.log(`Use ${s.yellow(`${e} daemon stop`)} to stop`),console.log(`Use ${s.yellow(`${e} daemon logs`)} to view logs`)}function A(){if(process.env.ACA_SINGLE_FILE_WORKER==="1")return process.execPath;const e=p.basename(process.argv[1]||"");return/worker-cli|aica/i.test(e)?"aica":"aca"}function E(){return g(c()),m.readdirSync(c()).filter(o=>/^\d{4}-\d{2}-\d{2}\.log$/.test(o)).map(o=>p.join(c(),o)).sort().at(-1)??null}async function R(e,o){const n=Date.now();for(;Date.now()-n<o;){if(!r(e))return!0;await new Promise(t=>setTimeout(t,100))}return!r(e)}async function P(e,o=w){return r(e)?(process.kill(e,"SIGTERM"),R(e,o)):!0}export{G as createDaemonCommand,I as printStartTips,D as spawnDaemon,P as stopDaemonProcess};
package/dist/version.js CHANGED
@@ -1 +1 @@
1
- const o="0.1.27";export{o as AICA_VERSION};
1
+ const o="0.1.28";export{o as AICA_VERSION};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yuandc/aica",
3
- "version": "0.1.27",
3
+ "version": "0.1.28",
4
4
  "description": "AICA remote Agent worker",
5
5
  "author": "yuandc",
6
6
  "type": "module",