@botbuddy/cli 1.50.0 → 1.50.1
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/package.json +1 -1
- package/src/commands.mjs +17 -5
package/package.json
CHANGED
package/src/commands.mjs
CHANGED
|
@@ -32,6 +32,7 @@ import { doctorAgentAuth, doctorHelp, parseDoctorArgs, readClientKeyStrict, repa
|
|
|
32
32
|
import { formatPublishIp, isLoopbackIp, probeEnginePublishIp, publishIpFix } from "./docker-publish-ip.mjs";
|
|
33
33
|
import { cmdHost, fixHelperWorkers, formatHelperWorkersLines, inspectHelperWorkers } from "./helper-host.mjs";
|
|
34
34
|
import { clearAgentState, selfHealAgentSession } from "./agent-session.mjs";
|
|
35
|
+
import { readAgentState } from "./agent-state.mjs";
|
|
35
36
|
import { runUsage, usageStatus } from "./usage/sync.mjs";
|
|
36
37
|
import { cmdTestIngest, doctorTestIngest, formatTestIngestLine } from "./test-ingest.mjs";
|
|
37
38
|
import { installUsageAgent, usageAgentStatus } from "./usage/launchd.mjs";
|
|
@@ -580,6 +581,7 @@ export async function cmdSetup(args, {
|
|
|
580
581
|
now = () => Date.now(),
|
|
581
582
|
binding = readAgentBinding,
|
|
582
583
|
clearState = clearAgentState,
|
|
584
|
+
readState = readAgentState,
|
|
583
585
|
selfHeal = selfHealAgentSession,
|
|
584
586
|
callerResolver = resolveCaller,
|
|
585
587
|
usageAgent = installUsageAgent,
|
|
@@ -654,12 +656,22 @@ export async function cmdSetup(args, {
|
|
|
654
656
|
signedIn = true;
|
|
655
657
|
}
|
|
656
658
|
}
|
|
657
|
-
// Setup is an explicit session bootstrap/repair command
|
|
658
|
-
//
|
|
659
|
-
|
|
659
|
+
// Setup is an explicit session bootstrap/repair command: it always mints a
|
|
660
|
+
// fresh session so it cannot merely report an old cache as ready.
|
|
661
|
+
// BOT-2171: but it keeps the worktree's AGENT. Deleting the cache first made
|
|
662
|
+
// the mint carry no agent_id, so the server fell back to a hostname-bearing
|
|
663
|
+
// name lookup and, after a hostname drift, inserted a new agent — every stack
|
|
664
|
+
// lease this worktree held then answered NOT_LEASE_OWNER. A cache bound to this
|
|
665
|
+
// tenant is re-minted in place (`force` re-registers with its agent_id); one
|
|
666
|
+
// bound elsewhere, or a legacy cache with no tenant to verify, is still
|
|
667
|
+
// discarded, since its agent may not serve this tenant (Codex #1180 R1).
|
|
668
|
+
const cached = await readState(cwd).catch(() => null);
|
|
669
|
+
const keepAgent = Boolean(cached?.agent_id) && cached.tenant === tenant;
|
|
670
|
+
if (!keepAgent) await clearState(cwd);
|
|
671
|
+
const mint = () => selfHeal({ cwd, env, ...(keepAgent ? { force: true } : {}) });
|
|
660
672
|
let session;
|
|
661
673
|
try {
|
|
662
|
-
session = await
|
|
674
|
+
session = await mint();
|
|
663
675
|
} catch (error) {
|
|
664
676
|
// A locally-valid key the server rejects (revoked, rotated) needs exactly
|
|
665
677
|
// one fresh sign-in and one retried mint. Never loop, and never re-sign a
|
|
@@ -667,7 +679,7 @@ export async function cmdSetup(args, {
|
|
|
667
679
|
if (signedIn || !SIGN_IN_REJECTED.has(error?.code) || error?.mintedWith === "mcp_key") throw error;
|
|
668
680
|
errorLog(`bb setup: this machine's saved sign-in was rejected (${error.code}); signing in again.`);
|
|
669
681
|
await signIn();
|
|
670
|
-
session = await
|
|
682
|
+
session = await mint();
|
|
671
683
|
}
|
|
672
684
|
// BOT-2058: register_agent reports any OTHER live session already holding
|
|
673
685
|
// this ticket (heartbeat < 15m) in `ticket_signals`. This is advisory: a
|