@botbuddy/cli 1.56.0 → 1.56.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/agent-session.mjs +2 -1
- package/src/commands.mjs +24 -3
- package/src/session-bootstrap.mjs +4 -0
package/package.json
CHANGED
package/src/agent-session.mjs
CHANGED
|
@@ -158,7 +158,7 @@ export async function hasAgentSessionRuntime({
|
|
|
158
158
|
/** Resolve without touching the network when an explicit source or fresh cache exists. */
|
|
159
159
|
export async function resolveAgentSessionCredential({
|
|
160
160
|
argv = [], env = process.env, cwd = process.cwd(), readState = readAgentState,
|
|
161
|
-
isFresh = isAgentStateFresh, selfHeal = selfHealAgentSession,
|
|
161
|
+
isFresh = isAgentStateFresh, selfHeal = selfHealAgentSession, allowSelfHeal = true,
|
|
162
162
|
// BOT-1682 (Codex R13): callers that have ALREADY parsed the session id from
|
|
163
163
|
// their own LEADING options (bb pw's runPwInner) pass it here, so this resolver
|
|
164
164
|
// never re-scans raw argv — where a target-flag VALUE such as
|
|
@@ -190,6 +190,7 @@ export async function resolveAgentSessionCredential({
|
|
|
190
190
|
warnLegacyResolvedToken(cached.agent_session_token, warn);
|
|
191
191
|
return withIdentity({ token: cached.agent_session_token, sessionId: explicitSessionId ?? cached.session_id, agentId: cached.agent_id, source: "cache" }, cached);
|
|
192
192
|
}
|
|
193
|
+
if (!allowSelfHeal) return null;
|
|
193
194
|
const healed = await selfHeal({ cwd, env, sessionId: explicitSessionId });
|
|
194
195
|
warnLegacyResolvedToken(healed?.token, warn);
|
|
195
196
|
return healed;
|
package/src/commands.mjs
CHANGED
|
@@ -31,7 +31,7 @@ import { deliverExecutionEvent } from "./telemetry-delivery.mjs";
|
|
|
31
31
|
import { doctorAgentAuth, doctorHelp, parseDoctorArgs, readClientKeyStrict, repairFailureRecovery } from "./agent-doctor.mjs";
|
|
32
32
|
import { formatPublishIp, isLoopbackIp, probeEnginePublishIp, publishIpFix } from "./docker-publish-ip.mjs";
|
|
33
33
|
import { cmdHost, fixHelperWorkers, formatHelperWorkersLines, inspectHelperWorkers } from "./helper-host.mjs";
|
|
34
|
-
import { clearAgentState, selfHealAgentSession } from "./agent-session.mjs";
|
|
34
|
+
import { clearAgentState, resolveAgentSessionCredential, selfHealAgentSession } from "./agent-session.mjs";
|
|
35
35
|
import { readAgentState } from "./agent-state.mjs";
|
|
36
36
|
import { runUsage, usageStatus } from "./usage/sync.mjs";
|
|
37
37
|
import { cmdTestIngest, doctorTestIngest, formatTestIngestLine } from "./test-ingest.mjs";
|
|
@@ -931,6 +931,10 @@ export async function cmdBootstrap(args, {
|
|
|
931
931
|
let harnessSessionId = null;
|
|
932
932
|
let type = "custom";
|
|
933
933
|
let codexThreadId = null;
|
|
934
|
+
// Claude Desktop injects this only for a desktop-hosted agent session. The
|
|
935
|
+
// CLI deliberately treats every other environment as absent, so terminal and
|
|
936
|
+
// cloud Claude sessions never manufacture a deep link.
|
|
937
|
+
const claudeDesktopSessionId = process.env.CLAUDE_CODE_HOST_SESSION_ID || null;
|
|
934
938
|
let branch = null;
|
|
935
939
|
let ticketId = null;
|
|
936
940
|
let ticketUrl = null;
|
|
@@ -969,6 +973,7 @@ export async function cmdBootstrap(args, {
|
|
|
969
973
|
type,
|
|
970
974
|
harnessSessionId,
|
|
971
975
|
codexThreadId,
|
|
976
|
+
claudeDesktopSessionId,
|
|
972
977
|
branch,
|
|
973
978
|
ticketId,
|
|
974
979
|
ticketUrl,
|
|
@@ -1163,8 +1168,24 @@ export async function cmdLogout({ cwd = process.cwd(), clearState = clearAgentSt
|
|
|
1163
1168
|
console.log(`${green("✓")} Logged out. Credentials removed.`);
|
|
1164
1169
|
}
|
|
1165
1170
|
|
|
1166
|
-
function cmdHeartbeat(args
|
|
1167
|
-
|
|
1171
|
+
export async function cmdHeartbeat(args, {
|
|
1172
|
+
resolveSession = resolveAgentSessionCredential,
|
|
1173
|
+
callTool: call = callTool,
|
|
1174
|
+
} = {}) {
|
|
1175
|
+
// A Desktop identity belongs to the work-graph session that is currently
|
|
1176
|
+
// running. Supply the cached session id with the host-provided value so the
|
|
1177
|
+
// server refreshes that exact session rather than only mutable agent state.
|
|
1178
|
+
const session = await resolveSession({
|
|
1179
|
+
sessionId: process.env.BOTBUDDY_SESSION_ID || null,
|
|
1180
|
+
allowSelfHeal: false,
|
|
1181
|
+
});
|
|
1182
|
+
const claudeDesktopSessionId = process.env.CLAUDE_CODE_HOST_SESSION_ID || null;
|
|
1183
|
+
const heartbeat = {
|
|
1184
|
+
...(args[0] ? { current_task: args[0] } : {}),
|
|
1185
|
+
...(typeof session?.sessionId === "string" && session.sessionId ? { session_id: session.sessionId } : {}),
|
|
1186
|
+
...(claudeDesktopSessionId ? { claude_desktop_session_id: claudeDesktopSessionId } : {}),
|
|
1187
|
+
};
|
|
1188
|
+
return call("heartbeat", heartbeat, session?.token ? { auth: { "x-agent-api-key": session.token } } : undefined);
|
|
1168
1189
|
}
|
|
1169
1190
|
|
|
1170
1191
|
// ─── BOT-1607: `botbuddy mcp` — the tier-2 bb_mcp_ config key ────────────────
|
|
@@ -130,6 +130,7 @@ async function recordOrphanAndFail({ session, cwd, retirementError, primaryError
|
|
|
130
130
|
export async function heartbeatHarnessSession({
|
|
131
131
|
session,
|
|
132
132
|
codexThreadId = null,
|
|
133
|
+
claudeDesktopSessionId = null,
|
|
133
134
|
model = null,
|
|
134
135
|
call = callToolJson,
|
|
135
136
|
cwd = process.cwd(),
|
|
@@ -141,6 +142,7 @@ export async function heartbeatHarnessSession({
|
|
|
141
142
|
const response = await call("heartbeat", {
|
|
142
143
|
session_id: session.session_id,
|
|
143
144
|
...(codexThreadId ? { codex_thread_id: codexThreadId } : {}),
|
|
145
|
+
...(claudeDesktopSessionId ? { claude_desktop_session_id: claudeDesktopSessionId } : {}),
|
|
144
146
|
...(model ? { model } : {}),
|
|
145
147
|
}, { auth: { "x-agent-api-key": session.session_token } });
|
|
146
148
|
if (!response?.ok || response.isError) {
|
|
@@ -212,6 +214,7 @@ export async function bootstrapHarnessSession({
|
|
|
212
214
|
type = "codex",
|
|
213
215
|
harnessSessionId,
|
|
214
216
|
codexThreadId = null,
|
|
217
|
+
claudeDesktopSessionId = null,
|
|
215
218
|
cwd = process.cwd(),
|
|
216
219
|
branch = null,
|
|
217
220
|
ticketId = null,
|
|
@@ -273,6 +276,7 @@ export async function bootstrapHarnessSession({
|
|
|
273
276
|
...(prNumber != null ? { pr_number: prNumber } : {}),
|
|
274
277
|
...(prUrl ? { pr_url: prUrl } : {}),
|
|
275
278
|
...(codexThreadId ? { codex_thread_id: codexThreadId } : {}),
|
|
279
|
+
...(claudeDesktopSessionId ? { claude_desktop_session_id: claudeDesktopSessionId } : {}),
|
|
276
280
|
...(model ? { model } : {}),
|
|
277
281
|
...(effort ? { effort } : {}),
|
|
278
282
|
harness,
|