@leviyuan/lodestar 0.17.3 → 0.17.5
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/dist/lodestar-agent.js +125 -10
- package/dist/lodestar-setup.js +131 -16
- package/dist/lodestar-stop.js +2 -2
- package/dist/lodestar-update.js +125 -10
- package/dist/lodestar-version.js +59 -1
- package/dist/lodestar.js +226 -181
- package/docs/configuration.md +12 -0
- package/docs/usage.md +26 -0
- package/package.json +8 -2
package/dist/lodestar-stop.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import{execSync as f}from"node:child_process";import{existsSync as U,readFileSync as y}from"node:fs";import{homedir as W}from"node:os";import{join as q}from"node:path";var X=W(),B=process.platform==="win32";function b(K,Q,Y){if(K)return K;if(Q)return q(Q,"lodestar");return Y}function H(){if(B)return q(process.env.APPDATA??q(X,"AppData","Roaming"),"Lodestar");return q(X,".config","lodestar")}function V(){if(B)return q(process.env.LOCALAPPDATA??q(X,"AppData","Local"),"Lodestar");return q(X,".local","share","lodestar")}var w=b(process.env.LODESTAR_CONFIG_DIR,process.env.XDG_CONFIG_HOME,H()),
|
|
3
|
-
`),Q=parseInt((K[0]??"").trim(),10),Y=(K[1]??"").trim();if(!Number.isFinite(Q)||Q<=0)console.error(`${
|
|
2
|
+
import{execSync as f}from"node:child_process";import{existsSync as U,readFileSync as y}from"node:fs";import{homedir as W}from"node:os";import{join as q}from"node:path";var X=W(),B=process.platform==="win32";function b(K,Q,Y){if(K)return K;if(Q)return q(Q,"lodestar");return Y}function H(){if(B)return q(process.env.APPDATA??q(X,"AppData","Roaming"),"Lodestar");return q(X,".config","lodestar")}function V(){if(B)return q(process.env.LOCALAPPDATA??q(X,"AppData","Local"),"Lodestar");return q(X,".local","share","lodestar")}var w=b(process.env.LODESTAR_CONFIG_DIR,process.env.XDG_CONFIG_HOME,H()),z=b(process.env.LODESTAR_DATA_DIR,process.env.XDG_DATA_HOME,V()),x=process.env.LODESTAR_CONFIG??q(w,"config.toml"),Z=q(z,"daemon.pid"),S=q(z,"daemon.log"),E=q(z,"session-chat-map.json"),v=q(z,"session-resume-map.json"),h=q(z,"session-turns-map.json"),k=q(z,"session-model-map.json"),F=q(z,"temp-session-leases.json"),R=q(z,"tasklist-map.json"),m=q(z,"agent-runs"),T=q(z,"agent-session-ids.json"),C=q(z,"managed-claude-plugin"),l=q(z,"dsh"),c=q(z,"codex-accounts"),j=q(z,"codex-accounts.json"),t=q(z,"codex-quota-blocks.json"),_=q(z,"agent-runtimes"),p=q(z,"context-window-cache.json"),A=q(z,"notify-callbacks.json"),I=q(z,"alive-on-shutdown.json"),s=q(z,"inbox"),a=q(z,"debug.sock"),o=q(z,"debug-context.json");import{execSync as G}from"node:child_process";import{readFileSync as L,writeFileSync as d}from"node:fs";function M(K){try{if(process.platform==="linux")return L(`/proc/${K}/cmdline`,"utf8").replace(/\0/g," ").trim();if(process.platform==="darwin")return G(`ps -p ${K} -o args=`,{encoding:"utf8",timeout:2000}).trim();if(process.platform==="win32")return G(`powershell -NoProfile -Command "(Get-CimInstance Win32_Process -Filter 'ProcessId=${K}').CommandLine"`,{encoding:"utf8",timeout:5000}).trim()||null;return null}catch{return null}}function N(K,Q){if(!Number.isFinite(K)||K<=0||!Q)return!1;let Y=M(K);if(!Y)return!1;if(process.platform==="win32")return Y.toLowerCase().includes(Q.toLowerCase());return Y.includes(Q)}var J={reset:"\x1B[0m",bold:"\x1B[1m",green:"\x1B[32m",yellow:"\x1B[33m",red:"\x1B[31m",dim:"\x1B[2m"};function P(K){return new Promise((Q)=>setTimeout(Q,K))}async function u(){if(!U(Z)){console.log(`${J.yellow}Lodestar daemon 未运行${J.reset} ${J.dim}(${Z} 不存在)${J.reset}`);return}let K=y(Z,"utf8").split(`
|
|
3
|
+
`),Q=parseInt((K[0]??"").trim(),10),Y=(K[1]??"").trim();if(!Number.isFinite(Q)||Q<=0)console.error(`${J.red}PID 文件格式坏:${J.reset} ${Z}`),process.exit(1);if(Y&&!N(Q,Y)){console.log(`${J.yellow}PID ${Q} 上没有 daemon (stale 文件)${J.reset}`),console.log(`${J.dim}手删 ${Z} 后再试${J.reset}`);return}console.log(`${J.bold}停止 daemon${J.reset} (pid ${Q})...`);try{if(process.platform==="win32")f(`taskkill /PID ${Q} /T /F`,{stdio:"ignore"});else process.kill(Q,"SIGTERM")}catch($){console.error(`${J.red}发信号失败:${J.reset} ${$?.message??$}`),process.exit(1)}for(let $=0;$<50;$++){if(!U(Z)){console.log(`${J.green}✓ daemon 已停${J.reset}`);return}await P(100)}console.log(`${J.yellow}已发 SIGTERM, 但 5s 内 daemon 没清掉 ${Z}${J.reset}`),console.log(`${J.dim}它可能还在收尾 (落盘 alive marker / 关 WS); 下次启动 pid-guard 会自动判别。${J.reset}`)}u().catch((K)=>{console.error(`${J.red}lodestar-stop:${J.reset} ${K?.message??K}`),process.exit(1)});
|