chatroom-cli 1.4.3 → 1.4.4
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 +19 -15
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -10391,23 +10391,23 @@ var init_daemon_state = __esm(() => {
|
|
|
10391
10391
|
function agentKey2(chatroomId, role) {
|
|
10392
10392
|
return `${chatroomId}:${role.toLowerCase()}`;
|
|
10393
10393
|
}
|
|
10394
|
-
function markIntentionalStop(chatroomId, role) {
|
|
10395
|
-
|
|
10394
|
+
function markIntentionalStop(chatroomId, role, reason = "intentional_stop") {
|
|
10395
|
+
pendingStops.set(agentKey2(chatroomId, role), reason);
|
|
10396
10396
|
}
|
|
10397
10397
|
function consumeIntentionalStop(chatroomId, role) {
|
|
10398
10398
|
const key = agentKey2(chatroomId, role);
|
|
10399
|
-
|
|
10400
|
-
|
|
10401
|
-
|
|
10399
|
+
const reason = pendingStops.get(key) ?? null;
|
|
10400
|
+
if (reason !== null) {
|
|
10401
|
+
pendingStops.delete(key);
|
|
10402
10402
|
}
|
|
10403
|
-
return
|
|
10403
|
+
return reason;
|
|
10404
10404
|
}
|
|
10405
10405
|
function clearIntentionalStop(chatroomId, role) {
|
|
10406
|
-
|
|
10406
|
+
pendingStops.delete(agentKey2(chatroomId, role));
|
|
10407
10407
|
}
|
|
10408
|
-
var
|
|
10408
|
+
var pendingStops;
|
|
10409
10409
|
var init_intentional_stops = __esm(() => {
|
|
10410
|
-
|
|
10410
|
+
pendingStops = new Map;
|
|
10411
10411
|
});
|
|
10412
10412
|
|
|
10413
10413
|
// src/infrastructure/machine/index.ts
|
|
@@ -13699,7 +13699,7 @@ function formatTimestamp() {
|
|
|
13699
13699
|
async function onAgentShutdown(ctx, options) {
|
|
13700
13700
|
const { chatroomId, role, pid, skipKill } = options;
|
|
13701
13701
|
try {
|
|
13702
|
-
ctx.deps.stops.mark(chatroomId, role);
|
|
13702
|
+
ctx.deps.stops.mark(chatroomId, role, options.stopReason ?? "intentional_stop");
|
|
13703
13703
|
} catch (e) {
|
|
13704
13704
|
console.log(` ⚠️ Failed to mark intentional stop for ${role}: ${e.message}`);
|
|
13705
13705
|
}
|
|
@@ -13860,7 +13860,7 @@ async function executeStartAgent(ctx, args) {
|
|
|
13860
13860
|
const isAlive = anyService ? anyService.isAlive(pid2) : false;
|
|
13861
13861
|
if (isAlive) {
|
|
13862
13862
|
console.log(` ⚠️ Existing agent detected (PID: ${pid2}) — stopping before respawn`);
|
|
13863
|
-
await onAgentShutdown(ctx, { chatroomId, role, pid: pid2 });
|
|
13863
|
+
await onAgentShutdown(ctx, { chatroomId, role, pid: pid2, stopReason: "daemon_respawn_stop" });
|
|
13864
13864
|
console.log(` ✅ Existing agent stopped (PID: ${pid2})`);
|
|
13865
13865
|
}
|
|
13866
13866
|
}
|
|
@@ -13925,8 +13925,8 @@ async function executeStartAgent(ctx, args) {
|
|
|
13925
13925
|
model
|
|
13926
13926
|
});
|
|
13927
13927
|
spawnResult.onExit(({ code: code2, signal }) => {
|
|
13928
|
-
const
|
|
13929
|
-
const stopReason = resolveStopReason(code2, signal,
|
|
13928
|
+
const pendingReason = ctx.deps.stops.consume(chatroomId, role);
|
|
13929
|
+
const stopReason = pendingReason ?? resolveStopReason(code2, signal, false);
|
|
13930
13930
|
ctx.events.emit("agent:exited", {
|
|
13931
13931
|
chatroomId,
|
|
13932
13932
|
role,
|
|
@@ -13934,7 +13934,7 @@ async function executeStartAgent(ctx, args) {
|
|
|
13934
13934
|
code: code2,
|
|
13935
13935
|
signal,
|
|
13936
13936
|
stopReason,
|
|
13937
|
-
intentional:
|
|
13937
|
+
intentional: pendingReason !== null
|
|
13938
13938
|
});
|
|
13939
13939
|
});
|
|
13940
13940
|
if (spawnResult.onAgentEnd) {
|
|
@@ -14380,8 +14380,12 @@ function onAgentExited(ctx, payload) {
|
|
|
14380
14380
|
const { chatroomId, role, pid, code: code2, signal, stopReason, intentional } = payload;
|
|
14381
14381
|
const ts = formatTimestamp();
|
|
14382
14382
|
console.log(`[${ts}] Agent stopped: ${stopReason} (${role})`);
|
|
14383
|
-
|
|
14383
|
+
const isDaemonRespawn = stopReason === "daemon_respawn_stop";
|
|
14384
|
+
const isIntentional = intentional && !isDaemonRespawn;
|
|
14385
|
+
if (isIntentional) {
|
|
14384
14386
|
console.log(`[${ts}] ℹ️ Agent process exited after intentional stop ` + `(PID: ${pid}, role: ${role}, code: ${code2}, signal: ${signal})`);
|
|
14387
|
+
} else if (isDaemonRespawn) {
|
|
14388
|
+
console.log(`[${ts}] \uD83D\uDD04 Agent process stopped for respawn ` + `(PID: ${pid}, role: ${role}, code: ${code2}, signal: ${signal})`);
|
|
14385
14389
|
} else {
|
|
14386
14390
|
console.log(`[${ts}] ⚠️ Agent process exited ` + `(PID: ${pid}, role: ${role}, code: ${code2}, signal: ${signal})`);
|
|
14387
14391
|
}
|