ragent-cli 1.6.0 → 1.6.2
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/index.js +55 -21
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -31,7 +31,7 @@ var require_package = __commonJS({
|
|
|
31
31
|
"package.json"(exports2, module2) {
|
|
32
32
|
module2.exports = {
|
|
33
33
|
name: "ragent-cli",
|
|
34
|
-
version: "1.6.
|
|
34
|
+
version: "1.6.2",
|
|
35
35
|
description: "CLI agent for rAgent Live \u2014 browser-first terminal control plane for AI coding agents",
|
|
36
36
|
main: "dist/index.js",
|
|
37
37
|
bin: {
|
|
@@ -262,7 +262,7 @@ var os9 = __toESM(require("os"));
|
|
|
262
262
|
// src/agent.ts
|
|
263
263
|
var fs4 = __toESM(require("fs"));
|
|
264
264
|
var os8 = __toESM(require("os"));
|
|
265
|
-
var
|
|
265
|
+
var path4 = __toESM(require("path"));
|
|
266
266
|
var import_ws5 = __toESM(require("ws"));
|
|
267
267
|
|
|
268
268
|
// src/auth.ts
|
|
@@ -2030,6 +2030,7 @@ var import_ws4 = __toESM(require("ws"));
|
|
|
2030
2030
|
var import_child_process2 = require("child_process");
|
|
2031
2031
|
var fs2 = __toESM(require("fs"));
|
|
2032
2032
|
var os6 = __toESM(require("os"));
|
|
2033
|
+
var path2 = __toESM(require("path"));
|
|
2033
2034
|
function assertConfiguredAgentToken() {
|
|
2034
2035
|
const config = loadConfig();
|
|
2035
2036
|
if (!config.agentToken) {
|
|
@@ -2216,8 +2217,32 @@ async function stopService() {
|
|
|
2216
2217
|
}
|
|
2217
2218
|
await stopPidfileService();
|
|
2218
2219
|
}
|
|
2220
|
+
function killStaleAgentProcesses() {
|
|
2221
|
+
try {
|
|
2222
|
+
const entries = fs2.readdirSync(CONFIG_DIR);
|
|
2223
|
+
for (const entry of entries) {
|
|
2224
|
+
if (!entry.startsWith("agent-") || !entry.endsWith(".pid")) continue;
|
|
2225
|
+
const pidPath = path2.join(CONFIG_DIR, entry);
|
|
2226
|
+
try {
|
|
2227
|
+
const raw = fs2.readFileSync(pidPath, "utf8").trim();
|
|
2228
|
+
const pid = Number.parseInt(raw, 10);
|
|
2229
|
+
if (!Number.isInteger(pid) || pid <= 0) continue;
|
|
2230
|
+
try {
|
|
2231
|
+
process.kill(pid, 0);
|
|
2232
|
+
process.kill(pid, "SIGTERM");
|
|
2233
|
+
console.log(`[rAgent] Stopped stale agent process (pid ${pid})`);
|
|
2234
|
+
} catch {
|
|
2235
|
+
}
|
|
2236
|
+
fs2.unlinkSync(pidPath);
|
|
2237
|
+
} catch {
|
|
2238
|
+
}
|
|
2239
|
+
}
|
|
2240
|
+
} catch {
|
|
2241
|
+
}
|
|
2242
|
+
}
|
|
2219
2243
|
async function restartService() {
|
|
2220
2244
|
const backend = getConfiguredServiceBackend();
|
|
2245
|
+
killStaleAgentProcesses();
|
|
2221
2246
|
if (backend === "systemd") {
|
|
2222
2247
|
await runSystemctlUser(["restart", SERVICE_NAME]);
|
|
2223
2248
|
console.log("[rAgent] Restarted service via systemd.");
|
|
@@ -2231,13 +2256,12 @@ async function printServiceStatus() {
|
|
|
2231
2256
|
if (backend === "systemd") {
|
|
2232
2257
|
const status = await execAsync(
|
|
2233
2258
|
`systemctl --user status ${shellQuote(SERVICE_NAME)} --no-pager --lines=20`,
|
|
2234
|
-
{ timeout: 1e4 }
|
|
2235
|
-
)
|
|
2236
|
-
console.log(error.message);
|
|
2237
|
-
return "";
|
|
2238
|
-
});
|
|
2259
|
+
{ timeout: 1e4, allowNonZeroExit: true }
|
|
2260
|
+
);
|
|
2239
2261
|
if (status) {
|
|
2240
2262
|
process.stdout.write(status);
|
|
2263
|
+
} else {
|
|
2264
|
+
console.log("[rAgent] systemd service is not installed or has no status.");
|
|
2241
2265
|
}
|
|
2242
2266
|
return;
|
|
2243
2267
|
}
|
|
@@ -2842,7 +2866,7 @@ var ControlDispatcher = class {
|
|
|
2842
2866
|
|
|
2843
2867
|
// src/transcript-watcher.ts
|
|
2844
2868
|
var fs3 = __toESM(require("fs"));
|
|
2845
|
-
var
|
|
2869
|
+
var path3 = __toESM(require("path"));
|
|
2846
2870
|
var os7 = __toESM(require("os"));
|
|
2847
2871
|
var import_child_process5 = require("child_process");
|
|
2848
2872
|
var ClaudeCodeParser = class {
|
|
@@ -2978,7 +3002,7 @@ function discoverViaProc(panePid) {
|
|
|
2978
3002
|
const fds = fs3.readdirSync(fdDir);
|
|
2979
3003
|
for (const fd of fds) {
|
|
2980
3004
|
try {
|
|
2981
|
-
const target = fs3.readlinkSync(
|
|
3005
|
+
const target = fs3.readlinkSync(path3.join(fdDir, fd));
|
|
2982
3006
|
if (target.endsWith(".jsonl") && target.includes("/.claude/")) {
|
|
2983
3007
|
return target;
|
|
2984
3008
|
}
|
|
@@ -2998,7 +3022,7 @@ function discoverViaProc(panePid) {
|
|
|
2998
3022
|
const fds = fs3.readdirSync(gcFdDir);
|
|
2999
3023
|
for (const fd of fds) {
|
|
3000
3024
|
try {
|
|
3001
|
-
const target = fs3.readlinkSync(
|
|
3025
|
+
const target = fs3.readlinkSync(path3.join(gcFdDir, fd));
|
|
3002
3026
|
if (target.endsWith(".jsonl") && target.includes("/.claude/")) {
|
|
3003
3027
|
return target;
|
|
3004
3028
|
}
|
|
@@ -3016,15 +3040,15 @@ function discoverViaProc(panePid) {
|
|
|
3016
3040
|
return null;
|
|
3017
3041
|
}
|
|
3018
3042
|
function discoverViaCwd(paneCwd) {
|
|
3019
|
-
const claudeProjectsDir =
|
|
3043
|
+
const claudeProjectsDir = path3.join(os7.homedir(), ".claude", "projects");
|
|
3020
3044
|
if (!fs3.existsSync(claudeProjectsDir)) return null;
|
|
3021
3045
|
const resolvedCwd = fs3.realpathSync(paneCwd);
|
|
3022
3046
|
const expectedDirName = resolvedCwd.replace(/\//g, "-");
|
|
3023
|
-
const projectDir =
|
|
3047
|
+
const projectDir = path3.join(claudeProjectsDir, expectedDirName);
|
|
3024
3048
|
if (!fs3.existsSync(projectDir)) return null;
|
|
3025
3049
|
try {
|
|
3026
3050
|
const jsonlFiles = fs3.readdirSync(projectDir).filter((f) => f.endsWith(".jsonl")).map((f) => {
|
|
3027
|
-
const fullPath =
|
|
3051
|
+
const fullPath = path3.join(projectDir, f);
|
|
3028
3052
|
const stat = fs3.statSync(fullPath);
|
|
3029
3053
|
return { path: fullPath, mtime: stat.mtimeMs };
|
|
3030
3054
|
}).sort((a, b) => b.mtime - a.mtime);
|
|
@@ -3034,14 +3058,14 @@ function discoverViaCwd(paneCwd) {
|
|
|
3034
3058
|
}
|
|
3035
3059
|
}
|
|
3036
3060
|
function discoverCodexTranscript() {
|
|
3037
|
-
const codexSessionsDir =
|
|
3061
|
+
const codexSessionsDir = path3.join(os7.homedir(), ".codex", "sessions");
|
|
3038
3062
|
if (!fs3.existsSync(codexSessionsDir)) return null;
|
|
3039
3063
|
try {
|
|
3040
3064
|
const dateDirs = fs3.readdirSync(codexSessionsDir).filter((d) => /^\d{4}-\d{2}-\d{2}/.test(d)).sort().reverse();
|
|
3041
3065
|
for (const dateDir of dateDirs.slice(0, 3)) {
|
|
3042
|
-
const fullDir =
|
|
3066
|
+
const fullDir = path3.join(codexSessionsDir, dateDir);
|
|
3043
3067
|
const jsonlFiles = fs3.readdirSync(fullDir).filter((f) => f.startsWith("rollout-") && f.endsWith(".jsonl")).map((f) => {
|
|
3044
|
-
const fp =
|
|
3068
|
+
const fp = path3.join(fullDir, f);
|
|
3045
3069
|
const stat = fs3.statSync(fp);
|
|
3046
3070
|
return { path: fp, mtime: stat.mtimeMs };
|
|
3047
3071
|
}).sort((a, b) => b.mtime - a.mtime);
|
|
@@ -3377,7 +3401,7 @@ var TranscriptWatcherManager = class {
|
|
|
3377
3401
|
|
|
3378
3402
|
// src/agent.ts
|
|
3379
3403
|
function pidFilePath(hostId) {
|
|
3380
|
-
return
|
|
3404
|
+
return path4.join(CONFIG_DIR, `agent-${hostId}.pid`);
|
|
3381
3405
|
}
|
|
3382
3406
|
function readPidFile(filePath) {
|
|
3383
3407
|
try {
|
|
@@ -3907,7 +3931,7 @@ function registerDoctorCommand(program2) {
|
|
|
3907
3931
|
|
|
3908
3932
|
// src/commands/update.ts
|
|
3909
3933
|
function registerUpdateCommand(program2) {
|
|
3910
|
-
program2.command("update").description("Update ragent CLI from npm").option("--check", "Check for updates only; do not install").action(async (opts) => {
|
|
3934
|
+
program2.command("update").description("Update ragent CLI from npm").option("--check", "Check for updates only; do not install").option("--no-restart", "Do not restart the service after updating").action(async (opts) => {
|
|
3911
3935
|
printCommandArt("Update", "checking npm registry for newer ragent-cli versions");
|
|
3912
3936
|
const latestVersion = await checkForUpdate({ force: true });
|
|
3913
3937
|
if (!latestVersion) {
|
|
@@ -3920,9 +3944,19 @@ function registerUpdateCommand(program2) {
|
|
|
3920
3944
|
timeout: 5 * 60 * 1e3,
|
|
3921
3945
|
maxBuffer: 10 * 1024 * 1024
|
|
3922
3946
|
});
|
|
3923
|
-
console.log(
|
|
3924
|
-
|
|
3925
|
-
)
|
|
3947
|
+
console.log(`[rAgent] Updated to ${latestVersion}.`);
|
|
3948
|
+
const backend = getConfiguredServiceBackend();
|
|
3949
|
+
if (backend && opts.restart) {
|
|
3950
|
+
console.log(`[rAgent] Restarting ${backend} service...`);
|
|
3951
|
+
try {
|
|
3952
|
+
await restartService();
|
|
3953
|
+
} catch (err) {
|
|
3954
|
+
console.error(`[rAgent] Failed to restart service: ${err instanceof Error ? err.message : err}`);
|
|
3955
|
+
console.log("[rAgent] Please restart manually: ragent service restart");
|
|
3956
|
+
}
|
|
3957
|
+
} else if (!backend) {
|
|
3958
|
+
console.log("[rAgent] No service backend detected. If ragent is running manually, restart it to use the new version.");
|
|
3959
|
+
}
|
|
3926
3960
|
});
|
|
3927
3961
|
}
|
|
3928
3962
|
|