very-happy-cli 0.2.143 → 0.2.144
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/{AcpBackend-LEgn9vol.mjs → AcpBackend-DLsPpWnc.mjs} +2 -2
- package/dist/{AcpBackend-B8oehrfU.cjs → AcpBackend-DssrjZDS.cjs} +30 -30
- package/dist/{AcpSessionManager-Yfbs5bi2.mjs → AcpSessionManager-1pAH8SdV.mjs} +1 -1
- package/dist/{AcpSessionManager-BomdfyhZ.cjs → AcpSessionManager-DkBV80Rr.cjs} +9 -9
- package/dist/{agentGuidance-BU4hxm8M.mjs → agentGuidance-CupQ9Lve.mjs} +1 -1
- package/dist/{agentGuidance-CJSl54ua.cjs → agentGuidance-D1PDVswF.cjs} +1 -1
- package/dist/agentHome-BaSxP7lQ.mjs +107 -0
- package/dist/agentHome-uf1zs2Fi.cjs +113 -0
- package/dist/codex/happyMcpStdioBridge.cjs +2 -2
- package/dist/codex/happyMcpStdioBridge.mjs +2 -2
- package/dist/{config-euZ_K5Lo.mjs → config-CxHoQo52.mjs} +4 -4
- package/dist/{config-CfqWoHmO.cjs → config-kx4y9oAI.cjs} +4 -4
- package/dist/{index-BREtikhm.cjs → index-DIoSNgtt.cjs} +4 -4
- package/dist/{index-DoiG88oX.mjs → index-Diu81aSC.mjs} +69 -24
- package/dist/{index-C510dSUn.cjs → index-Dn0JMM8l.cjs} +242 -197
- package/dist/{index-Bj68y6ee.cjs → index-Dox9iD5R.cjs} +31 -31
- package/dist/{index-PM_SsRpw.mjs → index-DxEaiVzX.mjs} +4 -4
- package/dist/{index-ZOMC8Gzn.mjs → index-J6a8OHS6.mjs} +8 -8
- package/dist/index.cjs +4 -4
- package/dist/index.mjs +4 -4
- package/dist/{installTerminalHooks-BGVQqbgq.mjs → installTerminalHooks-BBMGk3q5.mjs} +4 -4
- package/dist/{installTerminalHooks-C_jraM1j.cjs → installTerminalHooks-De7_iOOC.cjs} +4 -4
- package/dist/lib.cjs +5 -5
- package/dist/lib.mjs +2 -2
- package/dist/{limits-B3oVgqBJ.cjs → limits-C_Sklt--.cjs} +7 -7
- package/dist/{limits-uABU-yq3.mjs → limits-DxArdmkZ.mjs} +8 -8
- package/dist/{mcp-CfbTQXyh.mjs → mcp-C1oNnlw5.mjs} +4 -4
- package/dist/{mcp-G-3lL_KH.cjs → mcp-xyb8dYIQ.cjs} +9 -9
- package/dist/{piRuntime-CWE-1W-y.cjs → piRuntime-3Vbdgv6X.cjs} +2 -2
- package/dist/{piRuntime-BE6iYQwU.mjs → piRuntime-CzJdE4z4.mjs} +2 -2
- package/dist/{piTerminal-Dyc_9pGP.cjs → piTerminal-BFpwVGWr.cjs} +6 -6
- package/dist/{piTerminal-rqKn1_Zy.mjs → piTerminal-Do2GiKMN.mjs} +6 -6
- package/dist/{runGemini-C6qMFzcn.cjs → runGemini-CCdGxTF2.cjs} +24 -24
- package/dist/{runGemini-BMlXIaTL.mjs → runGemini-De5NRMT9.mjs} +6 -6
- package/dist/{runOpenClaw-CoO5Vp3S.mjs → runOpenClaw-C2t4DRyi.mjs} +5 -5
- package/dist/{runOpenClaw-C2_aCP7v.cjs → runOpenClaw-CRMUfrWk.cjs} +26 -26
- package/dist/{send-DGVwmB-p.cjs → send-BA1Dgpgn.cjs} +4 -4
- package/dist/{send-CBrJylJc.mjs → send-l6Rj09c0.mjs} +4 -4
- package/dist/{sessions-DyQXMN-8.cjs → sessions-CtVcoXvG.cjs} +5 -5
- package/dist/{sessions-DbLubh2N.mjs → sessions-MWLDqQk-.mjs} +4 -4
- package/dist/{spawn-DIyFOn3W.cjs → spawn-Be4nsNuQ.cjs} +6 -6
- package/dist/{spawn-wkkxEGdF.mjs → spawn-DKWR-6Qc.mjs} +4 -4
- package/dist/{teams-QOkGFjkJ.cjs → teams-CcjjNLi8.cjs} +4 -4
- package/dist/{teams-BTyVFK3P.mjs → teams-DMf9GNGE.mjs} +4 -4
- package/dist/{todo-DoLkqdBe.mjs → todo-BEXZRm1A.mjs} +3 -3
- package/dist/{todo-Du6pjwx_.cjs → todo-EffYAnre.cjs} +5 -5
- package/dist/{types-BG4gFjLL.mjs → types-D6YKR7wo.mjs} +321 -11
- package/dist/{types-6__wqmmP.cjs → types-DZ5c-9f3.cjs} +328 -9
- package/package.json +7 -7
|
@@ -3,14 +3,14 @@
|
|
|
3
3
|
var chalk = require('chalk');
|
|
4
4
|
var os = require('node:os');
|
|
5
5
|
var node_crypto = require('node:crypto');
|
|
6
|
-
var
|
|
7
|
-
var persistence = require('./limits-
|
|
6
|
+
var index = require('./types-DZ5c-9f3.cjs');
|
|
7
|
+
var persistence = require('./limits-C_Sklt--.cjs');
|
|
8
8
|
var spawn = require('cross-spawn');
|
|
9
9
|
var path = require('node:path');
|
|
10
10
|
var node_readline = require('node:readline');
|
|
11
11
|
var node_fs = require('node:fs');
|
|
12
12
|
var projectPath = require('./projectPath-ChLhdOyt.cjs');
|
|
13
|
-
var agentGuidance = require('./agentGuidance-
|
|
13
|
+
var agentGuidance = require('./agentGuidance-D1PDVswF.cjs');
|
|
14
14
|
var promises = require('node:fs/promises');
|
|
15
15
|
var fs = require('fs/promises');
|
|
16
16
|
var ink = require('ink');
|
|
@@ -288,7 +288,7 @@ class Session {
|
|
|
288
288
|
reportEventToDaemon = (event) => {
|
|
289
289
|
const spawnedBy = process.env.HAPPY_SPAWNED_BY;
|
|
290
290
|
if (!spawnedBy) return;
|
|
291
|
-
void
|
|
291
|
+
void index.notifyDaemonSessionEvent(this.client.sessionId, event, spawnedBy).catch((error) => persistence.logger.debug("[Session] Failed to report session event to daemon:", error));
|
|
292
292
|
};
|
|
293
293
|
/** Produce an `error` notification for an unexpected session failure. */
|
|
294
294
|
onSessionError = (message) => {
|
|
@@ -398,7 +398,7 @@ function pinSmallFastModel(env) {
|
|
|
398
398
|
}
|
|
399
399
|
|
|
400
400
|
function claudeCheckSession(sessionId, path$1) {
|
|
401
|
-
const projectDir =
|
|
401
|
+
const projectDir = index.getProjectPath(path$1);
|
|
402
402
|
const sessionFile = path.join(projectDir, `${sessionId}.jsonl`);
|
|
403
403
|
const sessionExists = node_fs.existsSync(sessionFile);
|
|
404
404
|
if (!sessionExists) {
|
|
@@ -424,7 +424,7 @@ function claudeCheckSession(sessionId, path$1) {
|
|
|
424
424
|
|
|
425
425
|
function claudeFindLastSession(workingDirectory) {
|
|
426
426
|
try {
|
|
427
|
-
const projectDir =
|
|
427
|
+
const projectDir = index.getProjectPath(workingDirectory);
|
|
428
428
|
const uuidPattern = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
|
429
429
|
const files = node_fs.readdirSync(projectDir).filter((f) => f.endsWith(".jsonl")).map((f) => {
|
|
430
430
|
const sessionId = f.replace(".jsonl", "");
|
|
@@ -478,7 +478,7 @@ function shouldIncludeCoAuthoredBy() {
|
|
|
478
478
|
|
|
479
479
|
const BASE_SYSTEM_PROMPT = (() => agentGuidance.trimIdent(`
|
|
480
480
|
ALWAYS when you start a new chat - you must call a tool "mcp__happy__change_title" to set a chat title. When you think chat title is not relevant anymore - call the tool again to change it. When chat name is too generic and you have a change to make it more specific - call the tool again to change it. This title is needed to easily find the chat in the future. Help human.
|
|
481
|
-
`))() + "\n\n" + agentGuidance.AGENT_GUIDANCE + "\n\n" +
|
|
481
|
+
`))() + "\n\n" + agentGuidance.AGENT_GUIDANCE + "\n\n" + index.BUILTIN_TODO_DISCOVERY;
|
|
482
482
|
const CO_AUTHORED_CREDITS = (() => agentGuidance.trimIdent(`
|
|
483
483
|
When making commit messages, instead of just giving co-credit to Claude, also give credit to Happy like so:
|
|
484
484
|
|
|
@@ -511,7 +511,7 @@ function quoteShellArg(value) {
|
|
|
511
511
|
return `'${value.replace(/'/g, `'\\''`)}'`;
|
|
512
512
|
}
|
|
513
513
|
async function claudeLocal(opts) {
|
|
514
|
-
const projectDir =
|
|
514
|
+
const projectDir = index.getProjectPath(opts.path);
|
|
515
515
|
node_fs.mkdirSync(projectDir, { recursive: true });
|
|
516
516
|
const hasContinueFlag = opts.claudeArgs?.includes("--continue");
|
|
517
517
|
const hasResumeFlag = opts.claudeArgs?.includes("--resume");
|
|
@@ -667,7 +667,7 @@ async function claudeLocal(opts) {
|
|
|
667
667
|
persistence.logger.warn("[ClaudeLocal] Sandbox is not supported on Windows; continuing without sandbox.");
|
|
668
668
|
} else {
|
|
669
669
|
try {
|
|
670
|
-
cleanupSandbox = await
|
|
670
|
+
cleanupSandbox = await index.initializeSandbox(opts.sandboxConfig, opts.path);
|
|
671
671
|
if (!spawnArgs.includes("--dangerously-skip-permissions")) {
|
|
672
672
|
spawnArgs = [...spawnArgs, "--dangerously-skip-permissions"];
|
|
673
673
|
}
|
|
@@ -675,7 +675,7 @@ async function claudeLocal(opts) {
|
|
|
675
675
|
"node",
|
|
676
676
|
...spawnArgs.map((arg) => quoteShellArg(arg))
|
|
677
677
|
].join(" ");
|
|
678
|
-
spawnCommand = await
|
|
678
|
+
spawnCommand = await index.wrapCommand(fullCommand);
|
|
679
679
|
spawnWithShell = true;
|
|
680
680
|
persistence.logger.info(
|
|
681
681
|
`[ClaudeLocal] Sandbox enabled: workspace=${opts.sandboxConfig.workspaceRoot ?? opts.path}, network=${opts.sandboxConfig.networkMode}`
|
|
@@ -738,7 +738,7 @@ async function claudeLocal(opts) {
|
|
|
738
738
|
persistence.logger.debug(`[ClaudeLocal] Unknown message type: ${message.type}`);
|
|
739
739
|
}
|
|
740
740
|
} catch (e) {
|
|
741
|
-
persistence.logger.debug("[ClaudeLocal] Non-JSON line from fd3:",
|
|
741
|
+
persistence.logger.debug("[ClaudeLocal] Non-JSON line from fd3:", index.contentLogMetadata(line));
|
|
742
742
|
}
|
|
743
743
|
});
|
|
744
744
|
rl.on("error", (err) => {
|
|
@@ -876,7 +876,7 @@ const INTERNAL_CLAUDE_EVENT_TYPES$1 = /* @__PURE__ */ new Set([
|
|
|
876
876
|
"queue-operation"
|
|
877
877
|
]);
|
|
878
878
|
async function createSessionScanner(opts) {
|
|
879
|
-
const projectDir =
|
|
879
|
+
const projectDir = index.getProjectPath(opts.workingDirectory);
|
|
880
880
|
let finishedSessions = /* @__PURE__ */ new Set();
|
|
881
881
|
let pendingSessions = /* @__PURE__ */ new Set();
|
|
882
882
|
let currentSessionId = null;
|
|
@@ -891,7 +891,7 @@ async function createSessionScanner(opts) {
|
|
|
891
891
|
}
|
|
892
892
|
currentSessionId = opts.sessionId;
|
|
893
893
|
}
|
|
894
|
-
const sync = new
|
|
894
|
+
const sync = new index.InvalidateSync(async () => {
|
|
895
895
|
let sessions = [];
|
|
896
896
|
for (let p of pendingSessions) {
|
|
897
897
|
if (!deadSessions.has(p)) {
|
|
@@ -1033,7 +1033,7 @@ async function readSessionLog(projectDir, sessionId) {
|
|
|
1033
1033
|
if (message.type && INTERNAL_CLAUDE_EVENT_TYPES$1.has(message.type)) {
|
|
1034
1034
|
continue;
|
|
1035
1035
|
}
|
|
1036
|
-
let parsed =
|
|
1036
|
+
let parsed = index.RawJSONLinesSchema.safeParse(message);
|
|
1037
1037
|
if (!parsed.success) {
|
|
1038
1038
|
continue;
|
|
1039
1039
|
}
|
|
@@ -1912,7 +1912,7 @@ async function awaitFileExist(file, timeout = 1e4) {
|
|
|
1912
1912
|
await fs.access(file);
|
|
1913
1913
|
return true;
|
|
1914
1914
|
} catch (e) {
|
|
1915
|
-
await
|
|
1915
|
+
await index.delay(1e3);
|
|
1916
1916
|
}
|
|
1917
1917
|
}
|
|
1918
1918
|
return false;
|
|
@@ -2107,7 +2107,7 @@ async function claudeRemote(opts) {
|
|
|
2107
2107
|
}
|
|
2108
2108
|
continue;
|
|
2109
2109
|
}
|
|
2110
|
-
persistence.logger.debug(`[claudeRemote] Message ${message.type}`,
|
|
2110
|
+
persistence.logger.debug(`[claudeRemote] Message ${message.type}`, index.contentLogMetadata(message));
|
|
2111
2111
|
if (message.type === "assistant" && message.error) {
|
|
2112
2112
|
lastAssistantError = message.error;
|
|
2113
2113
|
}
|
|
@@ -2147,7 +2147,7 @@ async function claudeRemote(opts) {
|
|
|
2147
2147
|
}
|
|
2148
2148
|
if (systemInit.session_id) {
|
|
2149
2149
|
persistence.logger.debug(`[claudeRemote] Waiting for session file to be written to disk: ${systemInit.session_id}`);
|
|
2150
|
-
const projectDir =
|
|
2150
|
+
const projectDir = index.getProjectPath(opts.path);
|
|
2151
2151
|
const found = await awaitFileExist(path.join(projectDir, `${systemInit.session_id}.jsonl`), 3e4);
|
|
2152
2152
|
persistence.logger.debug(`[claudeRemote] Session file found: ${systemInit.session_id} ${found}`);
|
|
2153
2153
|
if (!found) {
|
|
@@ -2378,9 +2378,9 @@ class PermissionHandler {
|
|
|
2378
2378
|
persistence.logger.debug("Plan mode result received", {
|
|
2379
2379
|
approved: response.approved,
|
|
2380
2380
|
mode: response.mode,
|
|
2381
|
-
reason:
|
|
2381
|
+
reason: index.contentLogMetadata(response.reason),
|
|
2382
2382
|
allowToolCount: response.allowTools?.length ?? 0,
|
|
2383
|
-
updatedInput:
|
|
2383
|
+
updatedInput: index.contentLogMetadata(response.updatedInput)
|
|
2384
2384
|
});
|
|
2385
2385
|
if (response.approved) {
|
|
2386
2386
|
const newMode = response.mode && ["default", "acceptEdits", "bypassPermissions"].includes(response.mode) ? response.mode : "bypassPermissions";
|
|
@@ -2704,9 +2704,9 @@ class PermissionHandler {
|
|
|
2704
2704
|
id: message.id,
|
|
2705
2705
|
approved: message.approved,
|
|
2706
2706
|
mode: message.mode,
|
|
2707
|
-
reason:
|
|
2707
|
+
reason: index.contentLogMetadata(message.reason),
|
|
2708
2708
|
allowToolCount: message.allowTools?.length ?? 0,
|
|
2709
|
-
updatedInput:
|
|
2709
|
+
updatedInput: index.contentLogMetadata(message.updatedInput)
|
|
2710
2710
|
});
|
|
2711
2711
|
const id = message.id;
|
|
2712
2712
|
const pending = this.pendingRequests.get(id);
|
|
@@ -3191,7 +3191,7 @@ class OutgoingMessageQueue {
|
|
|
3191
3191
|
}
|
|
3192
3192
|
queue = [];
|
|
3193
3193
|
nextId = 1;
|
|
3194
|
-
lock = new
|
|
3194
|
+
lock = new index.AsyncLock();
|
|
3195
3195
|
processTimer;
|
|
3196
3196
|
delayTimers = /* @__PURE__ */ new Map();
|
|
3197
3197
|
/**
|
|
@@ -3483,7 +3483,7 @@ class StreamRelay {
|
|
|
3483
3483
|
}
|
|
3484
3484
|
this.pending.text += text;
|
|
3485
3485
|
this.pending.bytes += Buffer.byteLength(text, "utf8");
|
|
3486
|
-
if (this.pending.bytes >= STREAM_FLUSH_MAX_BYTES || this.pending.text.length >=
|
|
3486
|
+
if (this.pending.bytes >= STREAM_FLUSH_MAX_BYTES || this.pending.text.length >= index.STREAM_DELTA_MAX_CHARS) {
|
|
3487
3487
|
this.flushPending();
|
|
3488
3488
|
return;
|
|
3489
3489
|
}
|
|
@@ -3663,8 +3663,8 @@ async function stageClaudeAttachments(attachments, options) {
|
|
|
3663
3663
|
await persistence.ensurePrivateDirectory(sessionDir);
|
|
3664
3664
|
const staged = [];
|
|
3665
3665
|
for (const attachment of attachments) {
|
|
3666
|
-
if (attachment.data.length >
|
|
3667
|
-
throw new Error(`Attachment exceeds the ${
|
|
3666
|
+
if (attachment.data.length > index.MAX_CHAT_ATTACHMENT_SOURCE_BYTES) {
|
|
3667
|
+
throw new Error(`Attachment exceeds the ${index.MAX_CHAT_ATTACHMENT_SOURCE_BYTES / 1024 / 1024} MB limit`);
|
|
3668
3668
|
}
|
|
3669
3669
|
const name = safeFileName(attachment.name || "file");
|
|
3670
3670
|
const targetPath = path.join(sessionDir, uniqueFileName(name));
|
|
@@ -4265,12 +4265,12 @@ async function claudeRemoteLauncher(session, onPermissionModeChange, onEffective
|
|
|
4265
4265
|
claudeArgs: session.claudeArgs,
|
|
4266
4266
|
onMessage,
|
|
4267
4267
|
onCompletionEvent: (message) => {
|
|
4268
|
-
persistence.logger.debug("[remote]: Completion event received:",
|
|
4268
|
+
persistence.logger.debug("[remote]: Completion event received:", index.contentLogMetadata(message));
|
|
4269
4269
|
session.client.sendSessionEvent({ type: "message", message });
|
|
4270
4270
|
},
|
|
4271
4271
|
onAuthFailure: (reason) => {
|
|
4272
4272
|
session.client.sendSessionEvent({ type: "message", message: `Claude Code auth: ${reason}`, kind: "claude-auth-failed" });
|
|
4273
|
-
void
|
|
4273
|
+
void index.notifyDaemonClaudeAuthFailed(session.client.sessionId).catch((error) => persistence.logger.debug("[remote]: auth_failed report to daemon failed:", error));
|
|
4274
4274
|
},
|
|
4275
4275
|
onSessionReset: () => {
|
|
4276
4276
|
persistence.logger.debug("[remote]: Session reset");
|
|
@@ -5062,7 +5062,7 @@ function daemonReadiness(authenticated, running, hasState) {
|
|
|
5062
5062
|
message: "\u26A0\uFE0F Daemon is not running \u2014 run `very-happy daemon start`"
|
|
5063
5063
|
};
|
|
5064
5064
|
}
|
|
5065
|
-
function collectRuntimeReadiness(run = node_child_process.spawnSync, currentNodeVersion = process.version, onPath =
|
|
5065
|
+
function collectRuntimeReadiness(run = node_child_process.spawnSync, currentNodeVersion = process.version, onPath = index.commandOnPath) {
|
|
5066
5066
|
const tmux = probe("tmux", run);
|
|
5067
5067
|
return {
|
|
5068
5068
|
node: {
|
|
@@ -5111,7 +5111,7 @@ function shareSafeEnvironmentInfo(env = process.env, runtime = process) {
|
|
|
5111
5111
|
function printCliUpdateStatus(state) {
|
|
5112
5112
|
const installed = persistence.configuration.currentCliVersion;
|
|
5113
5113
|
const running = state?.startedWithCliVersion ?? null;
|
|
5114
|
-
const summary =
|
|
5114
|
+
const summary = index.deriveLocalCliUpdateSummary(installed, running, state?.cliUpdate);
|
|
5115
5115
|
console.log(` Installed CLI: ${installed}`);
|
|
5116
5116
|
console.log(` Running daemon: ${running ?? "not running"}`);
|
|
5117
5117
|
if (state?.cliUpdate?.recommendedVersion) console.log(` Recommended: ${state.cliUpdate.recommendedVersion}`);
|
|
@@ -5146,7 +5146,7 @@ function getLogFiles(logDir) {
|
|
|
5146
5146
|
async function runDoctorDaemon() {
|
|
5147
5147
|
console.log(chalk.bold("\n\u{1F916} Daemon Status"));
|
|
5148
5148
|
try {
|
|
5149
|
-
const isRunning = await
|
|
5149
|
+
const isRunning = await index.checkIfDaemonRunningAndCleanupStaleState();
|
|
5150
5150
|
const state = await persistence.readDaemonState();
|
|
5151
5151
|
if (isRunning && state) {
|
|
5152
5152
|
console.log(chalk.green("\u2713 Daemon is running"));
|
|
@@ -5316,6 +5316,16 @@ ${typeLabels[type] || type}:`));
|
|
|
5316
5316
|
console.log(chalk.gray(" OS-keychain credentials cannot be verified here; see /docs/configuration#claude-credentials."));
|
|
5317
5317
|
}
|
|
5318
5318
|
console.log(chalk.gray(" An external claude command is only needed for native terminal/mirror use."));
|
|
5319
|
+
try {
|
|
5320
|
+
const { resolveAgentHomesForCli } = await Promise.resolve().then(function () { return require('./agentHome-uf1zs2Fi.cjs'); });
|
|
5321
|
+
const { describeAgentHome } = await Promise.resolve().then(function () { return require('./types-DZ5c-9f3.cjs'); }).then(function (n) { return n.index; });
|
|
5322
|
+
const homes = await resolveAgentHomesForCli();
|
|
5323
|
+
console.log(chalk.green(`\u2713 Claude config dir: ${describeAgentHome(homes.claudeConfigDir)}`));
|
|
5324
|
+
console.log(chalk.green(`\u2713 Codex home: ${describeAgentHome(homes.codexHome)}`));
|
|
5325
|
+
console.log(chalk.gray(" Resolved from settings.json, then your login shell, then the daemon environment; pin with `very-happy agent-home`."));
|
|
5326
|
+
} catch {
|
|
5327
|
+
console.log(chalk.yellow("\u25CB Could not resolve the Claude/Codex home directories"));
|
|
5328
|
+
}
|
|
5319
5329
|
if (availableAgents.length === 0) {
|
|
5320
5330
|
console.log(chalk.yellow("\u25CB No external agent command found on this daemon PATH"));
|
|
5321
5331
|
console.log(chalk.gray(" Codex, Gemini, OpenCode, OpenClaw, and native Claude terminal paths need their local command or gateway."));
|
|
@@ -5349,7 +5359,7 @@ ${typeLabels[type] || type}:`));
|
|
|
5349
5359
|
}
|
|
5350
5360
|
console.log(chalk.bold("\n\u{1F916} Daemon Status"));
|
|
5351
5361
|
try {
|
|
5352
|
-
const isRunning = await
|
|
5362
|
+
const isRunning = await index.checkIfDaemonRunningAndCleanupStaleState();
|
|
5353
5363
|
const state = await persistence.readDaemonState();
|
|
5354
5364
|
const summary = daemonReadiness(authenticated, isRunning, Boolean(state));
|
|
5355
5365
|
if (summary.level === "ready" && state) {
|
|
@@ -5419,7 +5429,7 @@ async function registryVersion(name) {
|
|
|
5419
5429
|
return typeof data.version === "string" ? stableVersion(data.version) : null;
|
|
5420
5430
|
}
|
|
5421
5431
|
async function detectAgentVersions(deps = { probe: probeAgentVersion, registryVersion }, now = Date.now()) {
|
|
5422
|
-
const agents = await Promise.all(
|
|
5432
|
+
const agents = await Promise.all(index.AGENT_VERSION_SOURCES.map(async (source) => {
|
|
5423
5433
|
const local = source.command ? await deps.probe(source.command).catch(() => ({ version: null, missing: false })) : { version: stableVersion(persistence.packageJson.dependencies["@anthropic-ai/claude-agent-sdk"]), missing: false };
|
|
5424
5434
|
if (local.missing) return { id: source.id, installed: null, latest: null, status: "not-installed" };
|
|
5425
5435
|
const latest = await deps.registryVersion(source.package).catch(() => null);
|
|
@@ -5678,7 +5688,7 @@ async function waitForAuthentication(keypair, claimSecret) {
|
|
|
5678
5688
|
}
|
|
5679
5689
|
process.stdout.write("\rWaiting for authentication" + ".".repeat(dots % 3 + 1) + " ");
|
|
5680
5690
|
dots++;
|
|
5681
|
-
await
|
|
5691
|
+
await index.delay(1e3);
|
|
5682
5692
|
}
|
|
5683
5693
|
} finally {
|
|
5684
5694
|
process.off("SIGINT", handleInterrupt);
|
|
@@ -6003,7 +6013,7 @@ async function waitForSessionKey(sessionId, timeoutMs) {
|
|
|
6003
6013
|
`Session ${sessionId} has no encryption key in ${persistence.configuration.sessionsFile}. Either it was not spawned by this machine's daemon, or the daemon is too old to persist session keys.`
|
|
6004
6014
|
);
|
|
6005
6015
|
}
|
|
6006
|
-
await
|
|
6016
|
+
await index.delay(200);
|
|
6007
6017
|
}
|
|
6008
6018
|
}
|
|
6009
6019
|
async function sendUserMessage(sessionId, persisted, text, client, options = {}) {
|
|
@@ -6065,7 +6075,7 @@ function resumePrecheck(metadata, fs) {
|
|
|
6065
6075
|
if (!metadata.codexThreadId) return { ok: false, reason: "no-backend-id", detail: "session has no Codex thread id" };
|
|
6066
6076
|
return { ok: true };
|
|
6067
6077
|
}
|
|
6068
|
-
if (!
|
|
6078
|
+
if (!index.isClaudeSessionId(metadata.claudeSessionId)) {
|
|
6069
6079
|
return { ok: false, reason: "no-backend-id", detail: "session has no Claude session id" };
|
|
6070
6080
|
}
|
|
6071
6081
|
if (!fs.conversationExists(metadata.path, metadata.claudeSessionId)) {
|
|
@@ -7377,8 +7387,8 @@ function decryptBoxBundle(bundle, recipientSecretKey) {
|
|
|
7377
7387
|
return decrypted ? new Uint8Array(decrypted) : null;
|
|
7378
7388
|
}
|
|
7379
7389
|
function readAgentCredentials() {
|
|
7380
|
-
const credentialPath =
|
|
7381
|
-
const credentials =
|
|
7390
|
+
const credentialPath = index.getLocalHappyAgentCredentialPath();
|
|
7391
|
+
const credentials = index.readLocalHappyAgentCredentials();
|
|
7382
7392
|
if (!credentials) {
|
|
7383
7393
|
throw new Error(
|
|
7384
7394
|
`Cannot use the legacy CLI resume path without ${credentialPath}. This credential is produced only by the source-only internal control-plane prototype; do not install the unrelated npm package named happy-agent. Use the Web session controls instead.`
|
|
@@ -7678,7 +7688,7 @@ function ownedCliLink(link, target, packageDir) {
|
|
|
7678
7688
|
return resolved.startsWith(path.join(packageDir, "bin") + path.sep);
|
|
7679
7689
|
}
|
|
7680
7690
|
async function installCliSafely(version, deps = defaults) {
|
|
7681
|
-
const parsed =
|
|
7691
|
+
const parsed = index.parseExactVersion(version);
|
|
7682
7692
|
if (!parsed) throw new Error("Invalid exact CLI version");
|
|
7683
7693
|
const args = autoUpdateInstallArgs(parsed.exact);
|
|
7684
7694
|
if (deps.platform === "win32") {
|
|
@@ -7769,7 +7779,7 @@ function createUpdateController(deps) {
|
|
|
7769
7779
|
let lastPublished = "";
|
|
7770
7780
|
const now = deps.now ?? Date.now;
|
|
7771
7781
|
function validManualTarget(next, version) {
|
|
7772
|
-
return version === next.recommendedVersion && Number.isFinite(next.checkedAt) && now() - next.checkedAt <= 65 * 6e4 && next.checkedAt <= now() + 6e4 &&
|
|
7782
|
+
return version === next.recommendedVersion && Number.isFinite(next.checkedAt) && now() - next.checkedAt <= 65 * 6e4 && next.checkedAt <= now() + 6e4 && index.compareExactVersions(next.currentVersion, version) === -1 && (!next.minimumVersion || [0, 1].includes(index.compareExactVersions(version, next.minimumVersion) ?? -1));
|
|
7773
7783
|
}
|
|
7774
7784
|
function publish(state, version, detail) {
|
|
7775
7785
|
if (!policy) return;
|
|
@@ -7807,7 +7817,7 @@ function createUpdateController(deps) {
|
|
|
7807
7817
|
publish("unapproved", null);
|
|
7808
7818
|
return;
|
|
7809
7819
|
}
|
|
7810
|
-
const order =
|
|
7820
|
+
const order = index.compareExactVersions(policy.currentVersion, target);
|
|
7811
7821
|
if (order !== -1) {
|
|
7812
7822
|
publish(order === null ? "policy_stale" : "current", target);
|
|
7813
7823
|
return;
|
|
@@ -7988,7 +7998,7 @@ function parseJsonObject(text) {
|
|
|
7988
7998
|
return null;
|
|
7989
7999
|
}
|
|
7990
8000
|
}
|
|
7991
|
-
function resolveSdkClaudeBinary(platform = process.platform, arch = process.arch, resolver = (s) => node_module.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('index-
|
|
8001
|
+
function resolveSdkClaudeBinary(platform = process.platform, arch = process.arch, resolver = (s) => node_module.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('index-Dn0JMM8l.cjs', document.baseURI).href))).resolve(s)) {
|
|
7992
8002
|
const platformArch = `${platform}-${arch}`;
|
|
7993
8003
|
const candidates = [
|
|
7994
8004
|
`@anthropic-ai/claude-agent-sdk-${platformArch}/claude`,
|
|
@@ -8378,7 +8388,7 @@ function parseLines(lines) {
|
|
|
8378
8388
|
try {
|
|
8379
8389
|
const parsed = JSON.parse(line);
|
|
8380
8390
|
if (parsed?.type && INTERNAL_CLAUDE_EVENT_TYPES.has(parsed.type)) continue;
|
|
8381
|
-
const result =
|
|
8391
|
+
const result = index.RawJSONLinesSchema.safeParse(parsed);
|
|
8382
8392
|
if (!result.success) continue;
|
|
8383
8393
|
out.push(result.data);
|
|
8384
8394
|
} catch {
|
|
@@ -8422,19 +8432,19 @@ function createMirrorScanner(opts) {
|
|
|
8422
8432
|
} finally {
|
|
8423
8433
|
await handle.close();
|
|
8424
8434
|
}
|
|
8425
|
-
const { lines, consumedBytes } =
|
|
8435
|
+
const { lines, consumedBytes } = index.extractCompleteLines(buf);
|
|
8426
8436
|
tail.offset += consumedBytes;
|
|
8427
8437
|
if (lines.length === 0) return;
|
|
8428
8438
|
let messages = parseLines(lines);
|
|
8429
8439
|
if (isFirstBackfillRead) {
|
|
8430
|
-
const decision =
|
|
8440
|
+
const decision = index.decideBackfill(messages, opts.backfillLines);
|
|
8431
8441
|
messages = decision.replay;
|
|
8432
8442
|
if (decision.truncated) opts.events.onBackfillTruncated?.();
|
|
8433
8443
|
tail.mode = "from-eof";
|
|
8434
8444
|
}
|
|
8435
8445
|
if (messages.length > 0) opts.events.onMessages(messages);
|
|
8436
8446
|
};
|
|
8437
|
-
const sync = new
|
|
8447
|
+
const sync = new index.InvalidateSync(async () => {
|
|
8438
8448
|
for (const tail of files.values()) {
|
|
8439
8449
|
try {
|
|
8440
8450
|
await readTail(tail);
|
|
@@ -8518,7 +8528,7 @@ function pendingCreateSupersededBy(pending, event) {
|
|
|
8518
8528
|
const TERMINAL_MIRROR_FLAVOR = "terminal-mirror";
|
|
8519
8529
|
const RECONCILE_HYSTERESIS_MS = 2e4;
|
|
8520
8530
|
function createMirrorManager(deps) {
|
|
8521
|
-
const backfillLines = deps.backfillLines ??
|
|
8531
|
+
const backfillLines = deps.backfillLines ?? index.MIRROR_BACKFILL_LINES_DEFAULT;
|
|
8522
8532
|
const bindings = /* @__PURE__ */ new Map();
|
|
8523
8533
|
const lastEndedAt = /* @__PURE__ */ new Map();
|
|
8524
8534
|
const pendingCreates = /* @__PURE__ */ new Map();
|
|
@@ -8533,7 +8543,7 @@ function createMirrorManager(deps) {
|
|
|
8533
8543
|
};
|
|
8534
8544
|
const isTerminalAlive = deps.isTerminalAlive ?? ((terminalId) => {
|
|
8535
8545
|
try {
|
|
8536
|
-
return node_child_process.spawnSync("tmux",
|
|
8546
|
+
return node_child_process.spawnSync("tmux", index.tmuxArgs(["has-session", "-t", `=vh-${terminalId}:`]), { stdio: "ignore", timeout: 3e3, env: index.scrubTmuxClientEnv({ ...process.env }) }).status === 0;
|
|
8537
8547
|
} catch {
|
|
8538
8548
|
return false;
|
|
8539
8549
|
}
|
|
@@ -8541,7 +8551,7 @@ function createMirrorManager(deps) {
|
|
|
8541
8551
|
const transcriptPathFor = (event) => {
|
|
8542
8552
|
if (event.transcriptPath) return event.transcriptPath;
|
|
8543
8553
|
if (!event.cwd) return null;
|
|
8544
|
-
return path.join(
|
|
8554
|
+
return path.join(index.getProjectPath(event.cwd), `${event.claudeSessionId}.jsonl`);
|
|
8545
8555
|
};
|
|
8546
8556
|
const persistBinding = (binding) => {
|
|
8547
8557
|
persistence.persistSession(binding.happySessionId, {
|
|
@@ -8557,8 +8567,8 @@ function createMirrorManager(deps) {
|
|
|
8557
8567
|
};
|
|
8558
8568
|
const sendMessages = (binding, messages) => {
|
|
8559
8569
|
for (const message of messages) {
|
|
8560
|
-
const key =
|
|
8561
|
-
binding.client.sendClaudeSessionMessage(message, key ? { localIdFor: (envelopeIndex) =>
|
|
8570
|
+
const key = index.mirrorLineKey(message);
|
|
8571
|
+
binding.client.sendClaudeSessionMessage(message, key ? { localIdFor: (envelopeIndex) => index.mirrorLocalId(key, envelopeIndex) } : void 0);
|
|
8562
8572
|
}
|
|
8563
8573
|
};
|
|
8564
8574
|
const attachScanner = (binding, opts) => {
|
|
@@ -8662,7 +8672,7 @@ function createMirrorManager(deps) {
|
|
|
8662
8672
|
archiveReason: void 0
|
|
8663
8673
|
});
|
|
8664
8674
|
const scanner = attachScanner(binding, { withTruncationNotice: false });
|
|
8665
|
-
scanner.addFile(path.join(
|
|
8675
|
+
scanner.addFile(path.join(index.getProjectPath(meta.path), `${meta.claudeSessionId}.jsonl`), "backfill-tail");
|
|
8666
8676
|
persistence.logger.debug(`[MIRROR] reconcile adopted terminal ${terminalId} \u2192 ${sessionId}`);
|
|
8667
8677
|
deps.onBindingsChanged?.();
|
|
8668
8678
|
};
|
|
@@ -8677,7 +8687,7 @@ function createMirrorManager(deps) {
|
|
|
8677
8687
|
archiveReason: void 0
|
|
8678
8688
|
});
|
|
8679
8689
|
const scanner = binding.scanner ?? attachScanner(binding, { withTruncationNotice: false });
|
|
8680
|
-
scanner.addFile(path.join(
|
|
8690
|
+
scanner.addFile(path.join(index.getProjectPath(binding.metadata.path), `${binding.claudeSessionId}.jsonl`), "backfill-tail");
|
|
8681
8691
|
persistence.logger.debug(`[MIRROR] reconcile reactivated (in place) terminal ${binding.terminalId}`);
|
|
8682
8692
|
deps.onBindingsChanged?.();
|
|
8683
8693
|
};
|
|
@@ -8780,7 +8790,7 @@ function createMirrorManager(deps) {
|
|
|
8780
8790
|
const parked = pendingCreates.get(event.terminalId);
|
|
8781
8791
|
if (parked && pendingCreateSupersededBy(parked, event)) pendingCreates.delete(event.terminalId);
|
|
8782
8792
|
const binding = bindings.get(event.terminalId) ?? null;
|
|
8783
|
-
const decision =
|
|
8793
|
+
const decision = index.decideMirrorBinding(
|
|
8784
8794
|
event,
|
|
8785
8795
|
binding ? { status: binding.status, claudeSessionId: binding.claudeSessionId } : null
|
|
8786
8796
|
);
|
|
@@ -8801,7 +8811,7 @@ function createMirrorManager(deps) {
|
|
|
8801
8811
|
};
|
|
8802
8812
|
return {
|
|
8803
8813
|
handleHookPayload(body) {
|
|
8804
|
-
const event =
|
|
8814
|
+
const event = index.parseTerminalHookPayload(body);
|
|
8805
8815
|
if (!event) {
|
|
8806
8816
|
persistence.logger.debug("[MIRROR] unparseable /terminal-hook payload dropped");
|
|
8807
8817
|
return;
|
|
@@ -8929,7 +8939,7 @@ function createMirrorManager(deps) {
|
|
|
8929
8939
|
};
|
|
8930
8940
|
bindings.set(terminalId, binding);
|
|
8931
8941
|
const scanner = attachScanner(binding, { withTruncationNotice: false });
|
|
8932
|
-
scanner.addFile(path.join(
|
|
8942
|
+
scanner.addFile(path.join(index.getProjectPath(meta.path), `${meta.claudeSessionId}.jsonl`), "backfill-tail");
|
|
8933
8943
|
persistence.logger.debug(`[MIRROR] restored binding terminal ${terminalId} \u2192 ${sessionId}`);
|
|
8934
8944
|
deps.onBindingsChanged?.();
|
|
8935
8945
|
}
|
|
@@ -9608,7 +9618,7 @@ function toSummary(id, persisted, extra) {
|
|
|
9608
9618
|
};
|
|
9609
9619
|
}
|
|
9610
9620
|
async function listSessions(options = {}) {
|
|
9611
|
-
const live = await
|
|
9621
|
+
const live = await index.listDaemonSessions();
|
|
9612
9622
|
return mergeSessionSummaries(live, persistence.readPersistedSessions(), options);
|
|
9613
9623
|
}
|
|
9614
9624
|
function summarizeAccountSession(row, persisted, liveIds, now) {
|
|
@@ -9678,7 +9688,7 @@ async function listAccountSessions(options = {}) {
|
|
|
9678
9688
|
});
|
|
9679
9689
|
const rows = Array.isArray(response.data?.sessions) ? response.data.sessions : [];
|
|
9680
9690
|
const persisted = persistence.readPersistedSessions();
|
|
9681
|
-
const live = await
|
|
9691
|
+
const live = await index.listDaemonSessions();
|
|
9682
9692
|
const liveIds = new Set(live.map((child) => child.happySessionId).filter((id) => typeof id === "string"));
|
|
9683
9693
|
const now = Date.now();
|
|
9684
9694
|
const summaries = rows.filter((row) => typeof row?.id === "string").map((row) => summarizeAccountSession(row, persisted[row.id], liveIds, now)).filter((summary) => options.includeArchived || !summary.archived);
|
|
@@ -9712,7 +9722,7 @@ async function readSessionTranscript(sessionId, limit) {
|
|
|
9712
9722
|
const messages = Array.isArray(response.data?.messages) ? response.data.messages : [];
|
|
9713
9723
|
messages.reverse();
|
|
9714
9724
|
const key = persistence.decodeBase64(persisted.encryptionKey);
|
|
9715
|
-
const live = await
|
|
9725
|
+
const live = await index.listDaemonSessions();
|
|
9716
9726
|
const bodies = messages.map((message) => {
|
|
9717
9727
|
if (message.content?.t !== "encrypted") return null;
|
|
9718
9728
|
try {
|
|
@@ -9728,7 +9738,7 @@ async function readSessionTranscript(sessionId, limit) {
|
|
|
9728
9738
|
};
|
|
9729
9739
|
}
|
|
9730
9740
|
async function stopSession(sessionId) {
|
|
9731
|
-
return await
|
|
9741
|
+
return await index.stopDaemonSession(sessionId);
|
|
9732
9742
|
}
|
|
9733
9743
|
async function archiveSession(sessionId) {
|
|
9734
9744
|
const token = await bearerToken();
|
|
@@ -10050,7 +10060,7 @@ function sanitizeImportTitle(value) {
|
|
|
10050
10060
|
return collapsed.length > 200 ? `${collapsed.slice(0, 199)}\u2026` : collapsed;
|
|
10051
10061
|
}
|
|
10052
10062
|
const hostSuffix = process.env.HAPPY_VARIANT === "dev" ? "-dev" : "";
|
|
10053
|
-
const startupCliAvailability =
|
|
10063
|
+
const startupCliAvailability = index.detectCLIAvailability();
|
|
10054
10064
|
const initialMachineMetadata = {
|
|
10055
10065
|
teamsVersion: 1,
|
|
10056
10066
|
teamLaunchVersion: 1,
|
|
@@ -10061,7 +10071,7 @@ const initialMachineMetadata = {
|
|
|
10061
10071
|
happyHomeDir: persistence.configuration.happyHomeDir,
|
|
10062
10072
|
happyLibDir: projectPath.projectPath(),
|
|
10063
10073
|
cliAvailability: startupCliAvailability,
|
|
10064
|
-
resumeSupport: { ...
|
|
10074
|
+
resumeSupport: { ...index.detectResumeSupport(), rpcAvailable: true }
|
|
10065
10075
|
};
|
|
10066
10076
|
async function preflightNewBundle(bundlePath) {
|
|
10067
10077
|
const home = fs$1.mkdtempSync(path$1.join(os.tmpdir(), "vh-preflight-"));
|
|
@@ -10116,6 +10126,12 @@ async function startDaemon() {
|
|
|
10116
10126
|
let cliUpdateStateRef = null;
|
|
10117
10127
|
let lastHandoverHold = null;
|
|
10118
10128
|
let claudeCredentialStoreSetting = (await persistence.readSettings()).claudeCredentialStore === "file" ? "file" : "auto";
|
|
10129
|
+
try {
|
|
10130
|
+
const homes = await index.refreshAgentHomes();
|
|
10131
|
+
persistence.logger.debug(`[DAEMON RUN] Claude config dir: ${index.describeAgentHome(homes.claudeConfigDir)}; Codex home: ${index.describeAgentHome(homes.codexHome)}`);
|
|
10132
|
+
} catch (error) {
|
|
10133
|
+
persistence.logger.debug("[DAEMON RUN] agent home resolution failed; using the daemon environment as-is", error);
|
|
10134
|
+
}
|
|
10119
10135
|
let requestShutdown;
|
|
10120
10136
|
let resolvesWhenShutdownRequested = new Promise((resolve) => {
|
|
10121
10137
|
requestShutdown = (source, errorMessage) => {
|
|
@@ -10160,7 +10176,7 @@ async function startDaemon() {
|
|
|
10160
10176
|
});
|
|
10161
10177
|
persistence.logger.debug("[DAEMON RUN] Starting daemon process...");
|
|
10162
10178
|
persistence.logger.debugLargeJson("[DAEMON RUN] Environment", getEnvironmentInfo());
|
|
10163
|
-
const runningDaemonVersionMatches = await
|
|
10179
|
+
const runningDaemonVersionMatches = await index.isDaemonRunningCurrentlyInstalledHappyVersion();
|
|
10164
10180
|
const runningDaemonState = await persistence.readDaemonState();
|
|
10165
10181
|
const runningDaemonEndpointsMatch = Boolean(runningDaemonState) && daemonEndpointsMatch(
|
|
10166
10182
|
runningDaemonState?.serverUrl,
|
|
@@ -10170,7 +10186,7 @@ async function startDaemon() {
|
|
|
10170
10186
|
);
|
|
10171
10187
|
if (!runningDaemonVersionMatches || !runningDaemonEndpointsMatch) {
|
|
10172
10188
|
persistence.logger.debug("[DAEMON RUN] Daemon version or endpoint mismatch detected, restarting daemon");
|
|
10173
|
-
await
|
|
10189
|
+
await index.stopDaemon();
|
|
10174
10190
|
} else {
|
|
10175
10191
|
persistence.logger.debug("[DAEMON RUN] Daemon version matches, keeping existing daemon");
|
|
10176
10192
|
console.log("Daemon already running with matching version");
|
|
@@ -10189,7 +10205,7 @@ async function startDaemon() {
|
|
|
10189
10205
|
const { credentials, machineId } = await authAndSetupMachineIfNeeded();
|
|
10190
10206
|
persistence.logger.debug("[DAEMON RUN] Auth and machine setup complete");
|
|
10191
10207
|
const pidToTrackedSession = /* @__PURE__ */ new Map();
|
|
10192
|
-
const turnActivity = new
|
|
10208
|
+
const turnActivity = new index.TurnActivityTracker();
|
|
10193
10209
|
const sessionIdToFinishedSession = /* @__PURE__ */ new Map();
|
|
10194
10210
|
let teamWorker;
|
|
10195
10211
|
const persisted = persistence.readPersistedSessions();
|
|
@@ -10281,7 +10297,8 @@ async function startDaemon() {
|
|
|
10281
10297
|
}
|
|
10282
10298
|
};
|
|
10283
10299
|
const assistantSpawnGate = createSpawnGate();
|
|
10284
|
-
const spawnSession = (options) => {
|
|
10300
|
+
const spawnSession = async (options) => {
|
|
10301
|
+
await index.refreshAgentHomes();
|
|
10285
10302
|
if (assistantSpawnMode(options) !== "claude-singleton") {
|
|
10286
10303
|
return spawnSessionImpl(options);
|
|
10287
10304
|
}
|
|
@@ -10289,7 +10306,7 @@ async function startDaemon() {
|
|
|
10289
10306
|
};
|
|
10290
10307
|
const currentCliAvailability = () => apiMachineRef?.getCLIAvailability() ?? startupCliAvailability;
|
|
10291
10308
|
const spawnSessionImpl = async (options) => {
|
|
10292
|
-
persistence.logger.debugLargeJson("[DAEMON RUN] Spawning session",
|
|
10309
|
+
persistence.logger.debugLargeJson("[DAEMON RUN] Spawning session", index.summarizeSpawnSessionForLog(options));
|
|
10293
10310
|
const spawnModel = options.agent === "pi" ? sanitizeSpawnModel(options.model) : null;
|
|
10294
10311
|
const spawnPermissionMode = sanitizeSpawnPermissionMode(options.permissionMode);
|
|
10295
10312
|
if (options.permissionMode !== void 0 && spawnPermissionMode === null) {
|
|
@@ -10354,7 +10371,7 @@ async function startDaemon() {
|
|
|
10354
10371
|
s.encryptionVariant
|
|
10355
10372
|
);
|
|
10356
10373
|
const claudeSessionId = resolveAssistantClaudeSessionId(s.metadata, serverMetadata);
|
|
10357
|
-
const canResumeClaude = !!claudeSessionId &&
|
|
10374
|
+
const canResumeClaude = !!claudeSessionId && index.locateClaudeConversation(assistantHome(), claudeSessionId) !== null;
|
|
10358
10375
|
return spawnTrackedHappyProcess({
|
|
10359
10376
|
args: [
|
|
10360
10377
|
"claude",
|
|
@@ -10373,6 +10390,8 @@ async function startDaemon() {
|
|
|
10373
10390
|
// B-297: see the resume/restart paths — every spawn carries the
|
|
10374
10391
|
// credentialStore=file shim, not just fresh sessions (B-276 D8).
|
|
10375
10392
|
...claudeAuthServiceRef?.claudeProcessEnvOverrides() ?? {},
|
|
10393
|
+
// B-478: point Claude at the directory the transcript was found in.
|
|
10394
|
+
...canResumeClaude ? index.agentHomeSpawnEnv({ workingDirectory: assistantHome(), claudeSessionId }) : {},
|
|
10376
10395
|
HAPPY_SESSION_VARIANT: "assistant",
|
|
10377
10396
|
HAPPY_RECONNECT_SESSION_ID: assistantSessionId,
|
|
10378
10397
|
HAPPY_RECONNECT_ENCRYPTION_KEY: s.encryptionKey,
|
|
@@ -10516,9 +10535,9 @@ async function startDaemon() {
|
|
|
10516
10535
|
};
|
|
10517
10536
|
}
|
|
10518
10537
|
const resumeId = agent === "claude" ? options.resumeClaudeSessionId : agent === "codex" ? options.resumeCodexThreadId : void 0;
|
|
10519
|
-
const resumeFragment = resumeId ? ` --resume ${
|
|
10520
|
-
const permissionModeFragment = spawnPermissionMode ? ` --permission-mode ${
|
|
10521
|
-
const modelFragment = spawnModel ? ` --model ${
|
|
10538
|
+
const resumeFragment = resumeId ? ` --resume ${index.shellescape(resumeId)}` : "";
|
|
10539
|
+
const permissionModeFragment = spawnPermissionMode ? ` --permission-mode ${index.shellescape(spawnPermissionMode)}` : "";
|
|
10540
|
+
const modelFragment = spawnModel ? ` --model ${index.shellescape(spawnModel)}` : "";
|
|
10522
10541
|
const fullCommand = `node --no-warnings --no-deprecation ${cliPath} ${agent} --happy-starting-mode remote --started-by daemon${resumeFragment}${permissionModeFragment}${modelFragment}`;
|
|
10523
10542
|
const windowName = `happy-${Date.now()}-${agent}`;
|
|
10524
10543
|
const tmuxEnv = {};
|
|
@@ -10527,6 +10546,7 @@ async function startDaemon() {
|
|
|
10527
10546
|
tmuxEnv[key] = value;
|
|
10528
10547
|
}
|
|
10529
10548
|
}
|
|
10549
|
+
Object.assign(tmuxEnv, index.agentHomeSpawnEnv({ workingDirectory: directory, claudeSessionId: options.resumeClaudeSessionId, codexThreadId: options.resumeCodexThreadId }));
|
|
10530
10550
|
Object.assign(tmuxEnv, extraEnv);
|
|
10531
10551
|
const tmuxResult = await tmux.spawnInTmux([fullCommand], {
|
|
10532
10552
|
sessionName: tmuxSessionName,
|
|
@@ -10621,6 +10641,9 @@ async function startDaemon() {
|
|
|
10621
10641
|
cwd: directory,
|
|
10622
10642
|
env: {
|
|
10623
10643
|
...process.env,
|
|
10644
|
+
// B-478: a fork/duplicate resumes a transcript that may live in
|
|
10645
|
+
// a moved config dir. Explicit environmentVariables still win.
|
|
10646
|
+
...index.agentHomeSpawnEnv({ workingDirectory: directory, claudeSessionId: options.resumeClaudeSessionId, codexThreadId: options.resumeCodexThreadId }),
|
|
10624
10647
|
...extraEnv
|
|
10625
10648
|
},
|
|
10626
10649
|
directoryCreated,
|
|
@@ -10771,6 +10794,7 @@ async function startDaemon() {
|
|
|
10771
10794
|
gate = createSpawnGate();
|
|
10772
10795
|
resumeGates.set(happySessionId, gate);
|
|
10773
10796
|
}
|
|
10797
|
+
await index.refreshAgentHomes();
|
|
10774
10798
|
try {
|
|
10775
10799
|
return await gate.join(() => resumeSessionImpl(happySessionId, options));
|
|
10776
10800
|
} finally {
|
|
@@ -10817,7 +10841,9 @@ async function startDaemon() {
|
|
|
10817
10841
|
}
|
|
10818
10842
|
const precheck = resumePrecheck(metadata, {
|
|
10819
10843
|
cwdExists: (p) => fs$1.existsSync(p),
|
|
10820
|
-
|
|
10844
|
+
// B-478: also looks in every other Claude config dir the user's shell
|
|
10845
|
+
// or settings point at, not just the one the daemon was started with.
|
|
10846
|
+
conversationExists: (cwd, claudeSessionId) => index.locateClaudeConversation(cwd, claudeSessionId) !== null
|
|
10821
10847
|
});
|
|
10822
10848
|
let freshConversation = false;
|
|
10823
10849
|
if (!precheck.ok) {
|
|
@@ -10848,6 +10874,9 @@ async function startDaemon() {
|
|
|
10848
10874
|
// fell back to `auto` reads a different credential store than the
|
|
10849
10875
|
// fresh one next to it (B-276 D8).
|
|
10850
10876
|
...claudeAuthServiceRef?.claudeProcessEnvOverrides() ?? {},
|
|
10877
|
+
// B-478: if the transcript lives in a Claude/Codex home other than
|
|
10878
|
+
// the resolved one, this spawn is pointed there.
|
|
10879
|
+
...freshConversation ? {} : index.agentHomeSpawnEnv({ workingDirectory: launch.cwd, claudeSessionId: metadata.claudeSessionId, codexThreadId: metadata.codexThreadId }),
|
|
10851
10880
|
HAPPY_RECONNECT_SESSION_ID: happySessionId,
|
|
10852
10881
|
HAPPY_RECONNECT_ENCRYPTION_KEY: persistence.encodeBase64(tracked.encryption.encryptionKey),
|
|
10853
10882
|
HAPPY_RECONNECT_ENCRYPTION_VARIANT: tracked.encryption.encryptionVariant,
|
|
@@ -10909,6 +10938,7 @@ async function startDaemon() {
|
|
|
10909
10938
|
gate = createSpawnGate();
|
|
10910
10939
|
resumeGates.set(happySessionId, gate);
|
|
10911
10940
|
}
|
|
10941
|
+
await index.refreshAgentHomes();
|
|
10912
10942
|
try {
|
|
10913
10943
|
return await gate.replace(() => restartSessionImpl(happySessionId, options));
|
|
10914
10944
|
} finally {
|
|
@@ -10944,7 +10974,9 @@ async function startDaemon() {
|
|
|
10944
10974
|
}
|
|
10945
10975
|
const precheck = resumePrecheck(metadata, {
|
|
10946
10976
|
cwdExists: (p) => fs$1.existsSync(p),
|
|
10947
|
-
|
|
10977
|
+
// B-478: also looks in every other Claude config dir the user's shell
|
|
10978
|
+
// or settings point at, not just the one the daemon was started with.
|
|
10979
|
+
conversationExists: (cwd2, claudeSessionId) => index.locateClaudeConversation(cwd2, claudeSessionId) !== null
|
|
10948
10980
|
});
|
|
10949
10981
|
let args;
|
|
10950
10982
|
let cwd;
|
|
@@ -10979,6 +11011,8 @@ async function startDaemon() {
|
|
|
10979
11011
|
// fell back to `auto` reads a different credential store than the
|
|
10980
11012
|
// fresh one next to it (B-276 D8).
|
|
10981
11013
|
...claudeAuthServiceRef?.claudeProcessEnvOverrides() ?? {},
|
|
11014
|
+
// B-478: see resumeSession.
|
|
11015
|
+
...precheck.ok ? index.agentHomeSpawnEnv({ workingDirectory: cwd, claudeSessionId: metadata.claudeSessionId, codexThreadId: metadata.codexThreadId }) : {},
|
|
10982
11016
|
HAPPY_RECONNECT_SESSION_ID: happySessionId,
|
|
10983
11017
|
HAPPY_RECONNECT_ENCRYPTION_KEY: persistence.encodeBase64(tracked.encryption.encryptionKey),
|
|
10984
11018
|
HAPPY_RECONNECT_ENCRYPTION_VARIANT: tracked.encryption.encryptionVariant,
|
|
@@ -11156,8 +11190,8 @@ async function startDaemon() {
|
|
|
11156
11190
|
httpPort: controlPort,
|
|
11157
11191
|
startedAt: Date.now()
|
|
11158
11192
|
};
|
|
11159
|
-
const api
|
|
11160
|
-
const machine = await api
|
|
11193
|
+
const api = await index.ApiClient.create(credentials);
|
|
11194
|
+
const machine = await api.getOrCreateMachine({
|
|
11161
11195
|
machineId,
|
|
11162
11196
|
metadata: initialMachineMetadata,
|
|
11163
11197
|
daemonState: initialDaemonState
|
|
@@ -11171,10 +11205,10 @@ async function startDaemon() {
|
|
|
11171
11205
|
if (identityConflict) {
|
|
11172
11206
|
persistence.logger.warn(`[DAEMON RUN] machine identity conflict (${identityConflict.confidence}): ${describeMachineIdentityConflict(identityConflict)}`);
|
|
11173
11207
|
}
|
|
11174
|
-
const apiMachine = api
|
|
11208
|
+
const apiMachine = api.machineSyncClient(machine);
|
|
11175
11209
|
apiMachineRef = apiMachine;
|
|
11176
11210
|
const mirrorManager = createMirrorManager({
|
|
11177
|
-
api
|
|
11211
|
+
api,
|
|
11178
11212
|
machineId,
|
|
11179
11213
|
onBindingsChanged: () => apiMachine.requestTerminalListRefresh()
|
|
11180
11214
|
});
|
|
@@ -11225,7 +11259,7 @@ async function startDaemon() {
|
|
|
11225
11259
|
}
|
|
11226
11260
|
let lastUpdateLog = "";
|
|
11227
11261
|
const updateController = createUpdateController({
|
|
11228
|
-
policy: () =>
|
|
11262
|
+
policy: () => index.fetchCliUpdateState(persistence.configuration.serverUrl, persistence.packageJson.version),
|
|
11229
11263
|
enabled: async () => ((await persistence.readSettings()).cliAutoUpdate ?? "idle") !== "off",
|
|
11230
11264
|
// B-466: "idle" = no agent turn in flight. Idle wrappers survive a
|
|
11231
11265
|
// handover (they talk to the server themselves) and web terminals live
|
|
@@ -11252,9 +11286,9 @@ async function startDaemon() {
|
|
|
11252
11286
|
persistence.logger.debug("[DAEMON RUN] CLI update policy check failed:", error);
|
|
11253
11287
|
});
|
|
11254
11288
|
void refreshCliUpdate();
|
|
11255
|
-
const cliUpdateIntervalMs =
|
|
11256
|
-
if (process.env.HAPPY_CLI_UPDATE_CHECK_INTERVAL && cliUpdateIntervalMs ===
|
|
11257
|
-
persistence.logger.warn(`[DAEMON RUN] Ignoring invalid HAPPY_CLI_UPDATE_CHECK_INTERVAL; using ${
|
|
11289
|
+
const cliUpdateIntervalMs = index.resolveCliUpdateCheckInterval(process.env.HAPPY_CLI_UPDATE_CHECK_INTERVAL);
|
|
11290
|
+
if (process.env.HAPPY_CLI_UPDATE_CHECK_INTERVAL && cliUpdateIntervalMs === index.DEFAULT_CLI_UPDATE_CHECK_INTERVAL_MS && process.env.HAPPY_CLI_UPDATE_CHECK_INTERVAL.trim() !== String(index.DEFAULT_CLI_UPDATE_CHECK_INTERVAL_MS)) {
|
|
11291
|
+
persistence.logger.warn(`[DAEMON RUN] Ignoring invalid HAPPY_CLI_UPDATE_CHECK_INTERVAL; using ${index.DEFAULT_CLI_UPDATE_CHECK_INTERVAL_MS}ms`);
|
|
11258
11292
|
}
|
|
11259
11293
|
const cliUpdateInterval = setInterval(() => void refreshCliUpdate(), cliUpdateIntervalMs);
|
|
11260
11294
|
const stopAgentVersionChecks = startAgentVersionChecks(
|
|
@@ -11305,7 +11339,7 @@ async function startDaemon() {
|
|
|
11305
11339
|
claudeAuthService.stop();
|
|
11306
11340
|
apiMachine.shutdown();
|
|
11307
11341
|
await stopControlServer();
|
|
11308
|
-
await
|
|
11342
|
+
await index.cleanupDaemonState();
|
|
11309
11343
|
await persistence.releaseDaemonLock(daemonLockHandle);
|
|
11310
11344
|
await stopCaffeinate();
|
|
11311
11345
|
try {
|
|
@@ -11378,7 +11412,7 @@ async function startDaemon() {
|
|
|
11378
11412
|
}
|
|
11379
11413
|
apiMachine.shutdown();
|
|
11380
11414
|
await stopControlServer();
|
|
11381
|
-
await
|
|
11415
|
+
await index.cleanupDaemonState();
|
|
11382
11416
|
await stopCaffeinate();
|
|
11383
11417
|
await persistence.releaseDaemonLock(daemonLockHandle);
|
|
11384
11418
|
persistence.logger.debug(`[DAEMON RUN] Cleanup completed, exiting process with code ${daemonExitCode(source)}`);
|
|
@@ -11645,7 +11679,7 @@ ${sessions.map(describeSummary).join("\n")}`);
|
|
|
11645
11679
|
limit: z.z.number().optional().describe("How many recent messages to fetch (default 20, max 100)")
|
|
11646
11680
|
}
|
|
11647
11681
|
}, async (args) => {
|
|
11648
|
-
if (!
|
|
11682
|
+
if (!index.isValidSessionId(args.sessionId)) return fail("Invalid sessionId");
|
|
11649
11683
|
try {
|
|
11650
11684
|
const result = await readSessionTranscript(args.sessionId, args.limit ?? 20);
|
|
11651
11685
|
const body = result.transcript.length > 0 ? result.transcript : "(no readable conversation content in this range)";
|
|
@@ -11664,7 +11698,7 @@ ${body}`);
|
|
|
11664
11698
|
text: z.z.string().describe("The message text to send")
|
|
11665
11699
|
}
|
|
11666
11700
|
}, async (args) => {
|
|
11667
|
-
if (!
|
|
11701
|
+
if (!index.isValidSessionId(args.sessionId)) return fail("Invalid sessionId");
|
|
11668
11702
|
if (typeof args.text !== "string" || args.text.trim().length === 0) return fail("text must be non-empty");
|
|
11669
11703
|
try {
|
|
11670
11704
|
const persisted = await waitForSessionKey(args.sessionId, 0);
|
|
@@ -11686,7 +11720,7 @@ ${body}`);
|
|
|
11686
11720
|
if (!normalized.ok) return fail(normalized.error);
|
|
11687
11721
|
const directory = normalized.directory;
|
|
11688
11722
|
try {
|
|
11689
|
-
const result = await
|
|
11723
|
+
const result = await index.spawnDaemonSession(directory, void 0, { spawnedBy: "assistant" });
|
|
11690
11724
|
if (result?.error || !result?.sessionId) {
|
|
11691
11725
|
return fail(`Failed to spawn session: ${result?.error ?? "daemon returned no session id"}`);
|
|
11692
11726
|
}
|
|
@@ -11713,7 +11747,7 @@ ${body}`);
|
|
|
11713
11747
|
sessionId: z.z.string().describe("The Happy session id to stop")
|
|
11714
11748
|
}
|
|
11715
11749
|
}, async (args) => {
|
|
11716
|
-
if (!
|
|
11750
|
+
if (!index.isValidSessionId(args.sessionId)) return fail("Invalid sessionId");
|
|
11717
11751
|
try {
|
|
11718
11752
|
const persisted = persistence.readPersistedSessions()[args.sessionId];
|
|
11719
11753
|
const success = await stopSession(args.sessionId);
|
|
@@ -11730,7 +11764,7 @@ ${body}`);
|
|
|
11730
11764
|
sessionId: z.z.string().describe("The Happy session id to archive")
|
|
11731
11765
|
}
|
|
11732
11766
|
}, async (args) => {
|
|
11733
|
-
if (!
|
|
11767
|
+
if (!index.isValidSessionId(args.sessionId)) return fail("Invalid sessionId");
|
|
11734
11768
|
try {
|
|
11735
11769
|
await archiveSession(args.sessionId);
|
|
11736
11770
|
const persisted = persistence.readPersistedSessions()[args.sessionId];
|
|
@@ -11746,7 +11780,7 @@ function registerAssistantMachineTools(mcp) {
|
|
|
11746
11780
|
title: "List Terminals",
|
|
11747
11781
|
inputSchema: {}
|
|
11748
11782
|
}, async () => {
|
|
11749
|
-
const r =
|
|
11783
|
+
const r = index.listVhTerminals();
|
|
11750
11784
|
if (!r.ok) return fail(`Failed to list terminals: ${r.error}`);
|
|
11751
11785
|
if (r.terminals.length === 0) return ok("No web terminals are open on this machine.");
|
|
11752
11786
|
const lines = r.terminals.map((t) => {
|
|
@@ -11766,8 +11800,8 @@ ${lines.join("\n")}`);
|
|
|
11766
11800
|
lines: z.z.number().optional().describe("How many history lines to read (default 80, max 2000)")
|
|
11767
11801
|
}
|
|
11768
11802
|
}, async (args) => {
|
|
11769
|
-
if (!
|
|
11770
|
-
const r =
|
|
11803
|
+
if (!index.isValidTerminalId(args.terminalId)) return fail("Invalid terminalId");
|
|
11804
|
+
const r = index.readVhTerminal(args.terminalId, args.lines ?? 80);
|
|
11771
11805
|
if (!r.ok) return fail(`Failed to read terminal ${args.terminalId}: ${r.error}`);
|
|
11772
11806
|
return ok(`terminal ${args.terminalId} \u2014 last output:
|
|
11773
11807
|
${r.text}`);
|
|
@@ -11781,10 +11815,10 @@ ${r.text}`);
|
|
|
11781
11815
|
submit: z.z.boolean().optional().describe("Also press Enter after pasting (default false)")
|
|
11782
11816
|
}
|
|
11783
11817
|
}, async (args) => {
|
|
11784
|
-
if (!
|
|
11818
|
+
if (!index.isValidTerminalId(args.terminalId)) return fail("Invalid terminalId");
|
|
11785
11819
|
if (typeof args.text !== "string" || args.text.length === 0) return fail("text must be non-empty");
|
|
11786
11820
|
const submit = args.submit === true;
|
|
11787
|
-
const r =
|
|
11821
|
+
const r = index.sendToVhTerminal(args.terminalId, args.text, submit);
|
|
11788
11822
|
if (!r.ok) return fail(`Failed to send to terminal ${args.terminalId}: ${r.error}`);
|
|
11789
11823
|
return ok(submit ? `Pasted and submitted (Enter sent) in terminal ${args.terminalId}.` : `Pasted into terminal ${args.terminalId} WITHOUT pressing Enter \u2014 the user (or a follow-up terminal_send with submit=true) decides whether it runs.`);
|
|
11790
11824
|
});
|
|
@@ -12056,7 +12090,7 @@ async function startHappyServer(client, options) {
|
|
|
12056
12090
|
return;
|
|
12057
12091
|
}
|
|
12058
12092
|
}
|
|
12059
|
-
const usage =
|
|
12093
|
+
const usage = index.ContextUsageSchema.parse({ ...JSON.parse(body), updatedAt: Date.now() });
|
|
12060
12094
|
options.onContextUsage(usage);
|
|
12061
12095
|
res.writeHead(204).end();
|
|
12062
12096
|
} catch {
|
|
@@ -12376,7 +12410,7 @@ function registerSideQuestionHandler(rpc, deps) {
|
|
|
12376
12410
|
const retainMs = deps.retainMs ?? SIDE_QUESTION_RETAIN_MS;
|
|
12377
12411
|
const maxRunMs = deps.maxRunMs ?? SIDE_QUESTION_MAX_RUN_MS;
|
|
12378
12412
|
const run = deps.run ?? (async (input) => {
|
|
12379
|
-
const { query } = await Promise.resolve().then(function () { return require('./index-
|
|
12413
|
+
const { query } = await Promise.resolve().then(function () { return require('./index-DIoSNgtt.cjs'); });
|
|
12380
12414
|
return runSideQuestion(query, input);
|
|
12381
12415
|
});
|
|
12382
12416
|
const slots = /* @__PURE__ */ new Map();
|
|
@@ -12478,7 +12512,7 @@ const MAX_TITLE_CHARS = 60;
|
|
|
12478
12512
|
const GENERATION_TIMEOUT_MS = 3e4;
|
|
12479
12513
|
function resolveClaudeBinary() {
|
|
12480
12514
|
try {
|
|
12481
|
-
const require$1 = node_module.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('index-
|
|
12515
|
+
const require$1 = node_module.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('index-Dn0JMM8l.cjs', document.baseURI).href)));
|
|
12482
12516
|
const utilsPath = path.resolve(path.join(projectPath.projectPath(), "scripts", "claude_version_utils.cjs"));
|
|
12483
12517
|
const { getClaudeCliPath } = require$1(utilsPath);
|
|
12484
12518
|
const path$1 = getClaudeCliPath();
|
|
@@ -12490,7 +12524,7 @@ function resolveClaudeBinary() {
|
|
|
12490
12524
|
}
|
|
12491
12525
|
function buildPrompt(firstUserMessage) {
|
|
12492
12526
|
const sample = firstUserMessage.slice(0, MAX_PROMPT_SAMPLE_CHARS);
|
|
12493
|
-
return `${
|
|
12527
|
+
return `${index.TITLE_PROMPT_PREFIX} (match the message's language). Be concrete \u2014 name the actual task/subject. Do NOT output generic placeholders like "\u65B0\u5BF9\u8BDD"/"New chat"/"Conversation"/"Untitled". No quotes, no trailing punctuation. Reply with ONLY the title.
|
|
12494
12528
|
|
|
12495
12529
|
Message: "${sample}"`;
|
|
12496
12530
|
}
|
|
@@ -12686,7 +12720,7 @@ function buildBoardPrompt(input) {
|
|
|
12686
12720
|
const taskLines = tasks.length > 0 ? tasks.map((t) => `- ${t.id}: ${t.title}`).join("\n") : "(no tasks defined)";
|
|
12687
12721
|
const todoBlock = input.todos.length > 0 ? input.todos.join("\n") : "(none)";
|
|
12688
12722
|
return [
|
|
12689
|
-
`${
|
|
12723
|
+
`${index.BOARD_ANALYZER_PROMPT_PREFIX} Analyze this session snapshot and reply with ONLY a strict JSON object, no markdown, no explanations:`,
|
|
12690
12724
|
'{"taskId": string|null, "attention": "none"|"review"|"blocked", "progress": string}',
|
|
12691
12725
|
"",
|
|
12692
12726
|
"Rules:",
|
|
@@ -12890,8 +12924,8 @@ async function runClaude(credentials, options = {}) {
|
|
|
12890
12924
|
if (options.startedBy === "daemon" && options.startingMode === "local") {
|
|
12891
12925
|
throw new Error("Daemon-spawned sessions cannot use local/interactive mode. Use --happy-starting-mode remote or spawn sessions directly from terminal.");
|
|
12892
12926
|
}
|
|
12893
|
-
|
|
12894
|
-
const api
|
|
12927
|
+
index.connectionState.setBackend("Claude");
|
|
12928
|
+
const api = await index.ApiClient.create(credentials);
|
|
12895
12929
|
let state = {};
|
|
12896
12930
|
const settings = await persistence.readSettings();
|
|
12897
12931
|
let machineId = settings?.machineId;
|
|
@@ -12908,7 +12942,7 @@ async function runClaude(credentials, options = {}) {
|
|
|
12908
12942
|
}
|
|
12909
12943
|
persistence.logger.debug(`Using machineId: ${machineId}`);
|
|
12910
12944
|
const sessionTag = node_crypto.randomUUID();
|
|
12911
|
-
await api
|
|
12945
|
+
await api.getOrCreateMachine({
|
|
12912
12946
|
machineId,
|
|
12913
12947
|
metadata: initialMachineMetadata
|
|
12914
12948
|
});
|
|
@@ -12978,16 +13012,16 @@ async function runClaude(credentials, options = {}) {
|
|
|
12978
13012
|
agentStateVersion: parseInt(reconnectAgentStateVersion || "0", 10)
|
|
12979
13013
|
};
|
|
12980
13014
|
} else {
|
|
12981
|
-
response = await api
|
|
13015
|
+
response = await api.getOrCreateSession({ tag: sessionTag, metadata, state });
|
|
12982
13016
|
}
|
|
12983
13017
|
if (!response) {
|
|
12984
13018
|
let offlineSessionId = null;
|
|
12985
|
-
const reconnection =
|
|
13019
|
+
const reconnection = index.startOfflineReconnection({
|
|
12986
13020
|
serverUrl: persistence.configuration.serverUrl,
|
|
12987
13021
|
onReconnected: async () => {
|
|
12988
|
-
const resp = await api
|
|
13022
|
+
const resp = await api.getOrCreateSession({ tag: node_crypto.randomUUID(), metadata, state });
|
|
12989
13023
|
if (!resp) throw new Error("Server unavailable");
|
|
12990
|
-
const session2 = api
|
|
13024
|
+
const session2 = api.sessionSyncClient(resp);
|
|
12991
13025
|
const scanner = await createSessionScanner({
|
|
12992
13026
|
sessionId: null,
|
|
12993
13027
|
workingDirectory,
|
|
@@ -13023,12 +13057,12 @@ async function runClaude(credentials, options = {}) {
|
|
|
13023
13057
|
}
|
|
13024
13058
|
persistence.logger.debug(`Session created: ${response.id}`);
|
|
13025
13059
|
await claimSessionOrExit(response.id, { takeover: !!reconnectSessionId, flavor: "claude" });
|
|
13026
|
-
if (reconnectSessionId && !await api
|
|
13060
|
+
if (reconnectSessionId && !await api.reactivateSession(response.id)) {
|
|
13027
13061
|
throw new Error(`Failed to reactivate archived session ${response.id}`);
|
|
13028
13062
|
}
|
|
13029
13063
|
let reconnectSeeded = false;
|
|
13030
13064
|
if (reconnectSessionId) {
|
|
13031
|
-
const snapshot = await api
|
|
13065
|
+
const snapshot = await api.getSession(response.id, response.encryptionKey, response.encryptionVariant);
|
|
13032
13066
|
if (snapshot.ok) {
|
|
13033
13067
|
response = applyServerSnapshot(response, snapshot.session);
|
|
13034
13068
|
reconnectSeeded = true;
|
|
@@ -13040,7 +13074,7 @@ async function runClaude(credentials, options = {}) {
|
|
|
13040
13074
|
}
|
|
13041
13075
|
try {
|
|
13042
13076
|
persistence.logger.debug(`[START] Reporting session ${response.id} to daemon`);
|
|
13043
|
-
const result = await
|
|
13077
|
+
const result = await index.notifyDaemonSessionStarted(response.id, metadata, {
|
|
13044
13078
|
encryptionKey: persistence.encodeBase64(response.encryptionKey),
|
|
13045
13079
|
encryptionVariant: response.encryptionVariant,
|
|
13046
13080
|
seq: response.seq,
|
|
@@ -13055,7 +13089,7 @@ async function runClaude(credentials, options = {}) {
|
|
|
13055
13089
|
} catch (error) {
|
|
13056
13090
|
persistence.logger.debug("[START] Failed to report to daemon (may not be running):", error);
|
|
13057
13091
|
}
|
|
13058
|
-
const session = api
|
|
13092
|
+
const session = api.sessionSyncClient(response, reconnectSeeded ? { initialSeq: response.seq } : void 0);
|
|
13059
13093
|
if (reconnectSessionId) {
|
|
13060
13094
|
session.suppressNextArchiveSignal();
|
|
13061
13095
|
if (!reconnectSeeded) session.skipExistingMessages();
|
|
@@ -13071,7 +13105,7 @@ async function runClaude(credentials, options = {}) {
|
|
|
13071
13105
|
}
|
|
13072
13106
|
const forkClaudeSessionId = process.env.HAPPY_FORK_CLAUDE_SESSION_ID;
|
|
13073
13107
|
if (!reconnectSessionId && forkClaudeSessionId) {
|
|
13074
|
-
const jsonlPath = path.join(
|
|
13108
|
+
const jsonlPath = path.join(index.getProjectPath(workingDirectory), `${forkClaudeSessionId}.jsonl`);
|
|
13075
13109
|
try {
|
|
13076
13110
|
const file = await promises.readFile(jsonlPath, "utf-8");
|
|
13077
13111
|
const lines = file.split("\n");
|
|
@@ -13084,7 +13118,7 @@ async function runClaude(credentials, options = {}) {
|
|
|
13084
13118
|
} catch {
|
|
13085
13119
|
continue;
|
|
13086
13120
|
}
|
|
13087
|
-
const result =
|
|
13121
|
+
const result = index.RawJSONLinesSchema.safeParse(parsed);
|
|
13088
13122
|
if (!result.success) continue;
|
|
13089
13123
|
session.sendClaudeSessionMessage(result.data);
|
|
13090
13124
|
backfilled += 1;
|
|
@@ -13126,7 +13160,7 @@ async function runClaude(credentials, options = {}) {
|
|
|
13126
13160
|
enabled: settings?.boardLlm === true,
|
|
13127
13161
|
selfReportState: boardSelfReport,
|
|
13128
13162
|
fetchTasks: async () => {
|
|
13129
|
-
const item = await api
|
|
13163
|
+
const item = await api.kvGet("vh.board-tasks.v1");
|
|
13130
13164
|
if (!item) return null;
|
|
13131
13165
|
try {
|
|
13132
13166
|
const parsed = JSON.parse(Buffer.from(item.value, "base64").toString("utf8"));
|
|
@@ -13162,7 +13196,7 @@ async function runClaude(credentials, options = {}) {
|
|
|
13162
13196
|
let currentSession = null;
|
|
13163
13197
|
const hookServer = await startHookServer({
|
|
13164
13198
|
onSessionHook: (sessionId, data) => {
|
|
13165
|
-
persistence.logger.debug(`[START] Session hook received: ${sessionId}`,
|
|
13199
|
+
persistence.logger.debug(`[START] Session hook received: ${sessionId}`, index.contentLogMetadata(data));
|
|
13166
13200
|
remoteScanner.onNewSession(sessionId, { treatExistingAsProcessed: true });
|
|
13167
13201
|
if (currentSession) {
|
|
13168
13202
|
const previousSessionId = currentSession.sessionId;
|
|
@@ -13380,7 +13414,7 @@ async function runClaude(credentials, options = {}) {
|
|
|
13380
13414
|
};
|
|
13381
13415
|
messageQueue.pushIsolateAndClear(specialCommand.originalMessage || message.content.text, enhancedMode2, attachmentsForThisMessage, message.localKey);
|
|
13382
13416
|
persistence.logger.debug("[start] /compact command pushed to queue:", {
|
|
13383
|
-
...
|
|
13417
|
+
...index.contentLogMetadata(message.content.text),
|
|
13384
13418
|
attachmentCount: attachmentsForThisMessage?.length ?? 0,
|
|
13385
13419
|
hasMetadata: Boolean(message.meta)
|
|
13386
13420
|
});
|
|
@@ -13400,7 +13434,7 @@ async function runClaude(credentials, options = {}) {
|
|
|
13400
13434
|
};
|
|
13401
13435
|
messageQueue.pushIsolateAndClear(specialCommand.originalMessage || message.content.text, enhancedMode2, attachmentsForThisMessage, message.localKey);
|
|
13402
13436
|
persistence.logger.debug("[start] /clear command pushed to queue:", {
|
|
13403
|
-
...
|
|
13437
|
+
...index.contentLogMetadata(message.content.text),
|
|
13404
13438
|
attachmentCount: attachmentsForThisMessage?.length ?? 0,
|
|
13405
13439
|
hasMetadata: Boolean(message.meta)
|
|
13406
13440
|
});
|
|
@@ -13462,7 +13496,7 @@ async function runClaude(credentials, options = {}) {
|
|
|
13462
13496
|
}) === true;
|
|
13463
13497
|
if (accepted) {
|
|
13464
13498
|
persistence.logger.debug("User message steered into current turn:", {
|
|
13465
|
-
...
|
|
13499
|
+
...index.contentLogMetadata(message.content.text),
|
|
13466
13500
|
attachmentCount: attachmentsForThisMessage?.length ?? 0
|
|
13467
13501
|
});
|
|
13468
13502
|
return;
|
|
@@ -13471,7 +13505,7 @@ async function runClaude(credentials, options = {}) {
|
|
|
13471
13505
|
}
|
|
13472
13506
|
messageQueue.push(message.content.text, enhancedMode, attachmentsForThisMessage, message.localKey);
|
|
13473
13507
|
persistence.logger.debug("User message pushed to queue:", {
|
|
13474
|
-
...
|
|
13508
|
+
...index.contentLogMetadata(message.content.text),
|
|
13475
13509
|
attachmentCount: attachmentsForThisMessage?.length ?? 0,
|
|
13476
13510
|
hasMetadata: Boolean(message.meta)
|
|
13477
13511
|
});
|
|
@@ -13492,7 +13526,7 @@ async function runClaude(credentials, options = {}) {
|
|
|
13492
13526
|
currentSession?.cleanup();
|
|
13493
13527
|
session.sendSessionDeath();
|
|
13494
13528
|
try {
|
|
13495
|
-
await api
|
|
13529
|
+
await api.deactivateSession(session.sessionId);
|
|
13496
13530
|
} catch (err) {
|
|
13497
13531
|
persistence.logger.debug("[START] deactivateSession during cleanup failed:", err);
|
|
13498
13532
|
}
|
|
@@ -13539,7 +13573,7 @@ async function runClaude(credentials, options = {}) {
|
|
|
13539
13573
|
permissionMode: initialPermissionMode,
|
|
13540
13574
|
startingMode: options.startingMode,
|
|
13541
13575
|
messageQueue,
|
|
13542
|
-
api
|
|
13576
|
+
api,
|
|
13543
13577
|
allowedTools: happyServer.toolNames.map((toolName) => `mcp__happy__${toolName}`),
|
|
13544
13578
|
onModeChange: (newMode) => {
|
|
13545
13579
|
currentRunMode = newMode;
|
|
@@ -13768,7 +13802,7 @@ async function handleAuthLogin(args) {
|
|
|
13768
13802
|
console.log(chalk.gray(" \u2022 Re-authenticate and register machine\n"));
|
|
13769
13803
|
try {
|
|
13770
13804
|
persistence.logger.debug("Stopping daemon for force auth...");
|
|
13771
|
-
await
|
|
13805
|
+
await index.stopDaemon();
|
|
13772
13806
|
console.log(chalk.gray("\u2713 Stopped daemon"));
|
|
13773
13807
|
} catch (error) {
|
|
13774
13808
|
persistence.logger.debug("Daemon was not running or failed to stop:", error);
|
|
@@ -13833,7 +13867,7 @@ async function handleAuthLogout() {
|
|
|
13833
13867
|
if (answer.toLowerCase() === "y" || answer.toLowerCase() === "yes") {
|
|
13834
13868
|
try {
|
|
13835
13869
|
try {
|
|
13836
|
-
await
|
|
13870
|
+
await index.stopDaemon();
|
|
13837
13871
|
console.log(chalk.gray("Stopped daemon"));
|
|
13838
13872
|
} catch {
|
|
13839
13873
|
}
|
|
@@ -13878,7 +13912,7 @@ async function handleAuthStatus() {
|
|
|
13878
13912
|
console.log(chalk.gray(`
|
|
13879
13913
|
Data directory: ${persistence.configuration.happyHomeDir}`));
|
|
13880
13914
|
try {
|
|
13881
|
-
const running = await
|
|
13915
|
+
const running = await index.checkIfDaemonRunningAndCleanupStaleState();
|
|
13882
13916
|
if (running) {
|
|
13883
13917
|
console.log(chalk.green("\u2713 Daemon running"));
|
|
13884
13918
|
} else {
|
|
@@ -14440,23 +14474,23 @@ async function handleConnectVendor(vendor, displayName) {
|
|
|
14440
14474
|
console.log(chalk.gray(' Please run "very-happy auth login" first'));
|
|
14441
14475
|
process.exit(1);
|
|
14442
14476
|
}
|
|
14443
|
-
const api
|
|
14477
|
+
const api = await index.ApiClient.create(credentials);
|
|
14444
14478
|
if (vendor === "codex") {
|
|
14445
14479
|
console.log("\u{1F680} Registering Codex token with server");
|
|
14446
14480
|
const codexAuthTokens = await authenticateCodex();
|
|
14447
|
-
await api
|
|
14481
|
+
await api.registerVendorToken("openai", { oauth: codexAuthTokens });
|
|
14448
14482
|
console.log("\u2705 Codex token registered with server");
|
|
14449
14483
|
process.exit(0);
|
|
14450
14484
|
} else if (vendor === "claude") {
|
|
14451
14485
|
console.log("\u{1F680} Registering Anthropic token with server");
|
|
14452
14486
|
const anthropicAuthTokens = await authenticateClaude();
|
|
14453
|
-
await api
|
|
14487
|
+
await api.registerVendorToken("anthropic", { oauth: anthropicAuthTokens });
|
|
14454
14488
|
console.log("\u2705 Anthropic token registered with server");
|
|
14455
14489
|
process.exit(0);
|
|
14456
14490
|
} else if (vendor === "gemini") {
|
|
14457
14491
|
console.log("\u{1F680} Registering Gemini token with server");
|
|
14458
14492
|
const geminiAuthTokens = await authenticateGemini();
|
|
14459
|
-
await api
|
|
14493
|
+
await api.registerVendorToken("gemini", { oauth: geminiAuthTokens });
|
|
14460
14494
|
console.log("\u2705 Gemini token registered with server");
|
|
14461
14495
|
updateLocalGeminiCredentials(geminiAuthTokens);
|
|
14462
14496
|
process.exit(0);
|
|
@@ -14472,7 +14506,7 @@ async function handleConnectStatus() {
|
|
|
14472
14506
|
console.log(chalk.gray(' Please run "very-happy auth login" first'));
|
|
14473
14507
|
process.exit(1);
|
|
14474
14508
|
}
|
|
14475
|
-
const api
|
|
14509
|
+
const api = await index.ApiClient.create(credentials);
|
|
14476
14510
|
const vendors = [
|
|
14477
14511
|
{ key: "gemini", name: "Gemini", display: "Google Gemini" },
|
|
14478
14512
|
{ key: "openai", name: "Codex", display: "OpenAI Codex" },
|
|
@@ -14480,7 +14514,7 @@ async function handleConnectStatus() {
|
|
|
14480
14514
|
];
|
|
14481
14515
|
for (const vendor of vendors) {
|
|
14482
14516
|
try {
|
|
14483
|
-
const token = await api
|
|
14517
|
+
const token = await api.getVendorToken(vendor.key);
|
|
14484
14518
|
if (token?.oauth) {
|
|
14485
14519
|
let userInfo = "";
|
|
14486
14520
|
if (token.oauth.id_token) {
|
|
@@ -14704,9 +14738,9 @@ function resolveLocalSignupBootstrap(configuredMode, configuredInviteCodes, gene
|
|
|
14704
14738
|
};
|
|
14705
14739
|
}
|
|
14706
14740
|
|
|
14707
|
-
const __filename$1 = node_url.fileURLToPath((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('index-
|
|
14741
|
+
const __filename$1 = node_url.fileURLToPath((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('index-Dn0JMM8l.cjs', document.baseURI).href)));
|
|
14708
14742
|
const __dirname$1 = path.dirname(__filename$1);
|
|
14709
|
-
const require_ = node_module.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('index-
|
|
14743
|
+
const require_ = node_module.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('index-Dn0JMM8l.cjs', document.baseURI).href)));
|
|
14710
14744
|
const PRISMA_QUERY_ENGINE_FILES = {
|
|
14711
14745
|
"arm64-darwin": "libquery_engine-darwin-arm64.dylib.node",
|
|
14712
14746
|
"x64-darwin": "libquery_engine-darwin.dylib.node",
|
|
@@ -15095,7 +15129,7 @@ const DAEMON_READY_TIMEOUT_MS = 5e3;
|
|
|
15095
15129
|
const DAEMON_READY_POLL_INTERVAL_MS = 100;
|
|
15096
15130
|
async function ensureDaemonRunning() {
|
|
15097
15131
|
persistence.logger.debug("Ensuring Happy background service is running & matches our version...");
|
|
15098
|
-
const versionMatches = await
|
|
15132
|
+
const versionMatches = await index.isDaemonRunningCurrentlyInstalledHappyVersion();
|
|
15099
15133
|
const state = await persistence.readDaemonState();
|
|
15100
15134
|
const endpointsMatch = Boolean(state) && daemonEndpointsMatch(
|
|
15101
15135
|
state?.serverUrl,
|
|
@@ -15106,9 +15140,9 @@ async function ensureDaemonRunning() {
|
|
|
15106
15140
|
if (versionMatches && endpointsMatch) {
|
|
15107
15141
|
return;
|
|
15108
15142
|
}
|
|
15109
|
-
if (await
|
|
15143
|
+
if (await index.checkIfDaemonRunningAndCleanupStaleState()) {
|
|
15110
15144
|
persistence.logger.debug("Stopping daemon whose version or configured relay no longer matches...");
|
|
15111
|
-
await
|
|
15145
|
+
await index.stopDaemon();
|
|
15112
15146
|
}
|
|
15113
15147
|
persistence.logger.debug("Starting Happy background service...");
|
|
15114
15148
|
const daemonProcess = spawnHappyCLI(["daemon", "start-sync"], {
|
|
@@ -15119,7 +15153,7 @@ async function ensureDaemonRunning() {
|
|
|
15119
15153
|
daemonProcess.unref();
|
|
15120
15154
|
const deadline = Date.now() + DAEMON_READY_TIMEOUT_MS;
|
|
15121
15155
|
while (Date.now() < deadline) {
|
|
15122
|
-
if (await
|
|
15156
|
+
if (await index.checkIfDaemonRunningAndCleanupStaleState()) {
|
|
15123
15157
|
persistence.logger.debug("Happy background service is ready");
|
|
15124
15158
|
return;
|
|
15125
15159
|
}
|
|
@@ -15141,14 +15175,14 @@ function maybeEmitSubagentStart(subagent, opts, startedSubagents, activeSubagent
|
|
|
15141
15175
|
if (!subagent || startedSubagents.has(subagent)) {
|
|
15142
15176
|
return;
|
|
15143
15177
|
}
|
|
15144
|
-
envelopes.push(
|
|
15178
|
+
envelopes.push(index.createEnvelope("agent", { t: "start" }, { ...opts, subagent }));
|
|
15145
15179
|
startedSubagents.add(subagent);
|
|
15146
15180
|
activeSubagents.add(subagent);
|
|
15147
15181
|
}
|
|
15148
15182
|
function emitSubagentStops(opts, startedSubagents, activeSubagents) {
|
|
15149
15183
|
const envelopes = [];
|
|
15150
15184
|
for (const subagent of activeSubagents) {
|
|
15151
|
-
envelopes.push(
|
|
15185
|
+
envelopes.push(index.createEnvelope("agent", { t: "stop" }, { ...opts, subagent }));
|
|
15152
15186
|
}
|
|
15153
15187
|
activeSubagents.clear();
|
|
15154
15188
|
startedSubagents.clear();
|
|
@@ -15244,7 +15278,7 @@ function turnStatus(turn) {
|
|
|
15244
15278
|
function emitHistoricalToolCall(envelopes, turn, item, name, title, args, output) {
|
|
15245
15279
|
const time = turnTimestampMs(turn);
|
|
15246
15280
|
const opts = { turn: turn.id, time, codexItemId: item.id };
|
|
15247
|
-
envelopes.push(
|
|
15281
|
+
envelopes.push(index.createEnvelope("agent", {
|
|
15248
15282
|
t: "tool-call-start",
|
|
15249
15283
|
call: item.id,
|
|
15250
15284
|
name,
|
|
@@ -15256,7 +15290,7 @@ function emitHistoricalToolCall(envelopes, turn, item, name, title, args, output
|
|
|
15256
15290
|
id: `${item.id}:start`
|
|
15257
15291
|
}));
|
|
15258
15292
|
if (output && output.trim().length > 0) {
|
|
15259
|
-
envelopes.push(
|
|
15293
|
+
envelopes.push(index.createEnvelope("agent", {
|
|
15260
15294
|
t: "text",
|
|
15261
15295
|
text: output,
|
|
15262
15296
|
thinking: true
|
|
@@ -15266,7 +15300,7 @@ function emitHistoricalToolCall(envelopes, turn, item, name, title, args, output
|
|
|
15266
15300
|
}));
|
|
15267
15301
|
}
|
|
15268
15302
|
if ("status" in item && (item.status === "inProgress" || item.status === "running")) return;
|
|
15269
|
-
envelopes.push(
|
|
15303
|
+
envelopes.push(index.createEnvelope("agent", {
|
|
15270
15304
|
t: "tool-call-end",
|
|
15271
15305
|
call: item.id
|
|
15272
15306
|
}, {
|
|
@@ -15288,7 +15322,7 @@ function mapCodexCollaborationItem(item, opts = {}, source = "history") {
|
|
|
15288
15322
|
agentsStates: item.agentsStates ?? {}
|
|
15289
15323
|
};
|
|
15290
15324
|
const startId = source === "live" ? `${item.id}:${item.status ?? "unknown"}:start` : `${item.id}:start`;
|
|
15291
|
-
const envelopes = [
|
|
15325
|
+
const envelopes = [index.createEnvelope("agent", {
|
|
15292
15326
|
t: "tool-call-start",
|
|
15293
15327
|
call: item.id,
|
|
15294
15328
|
name: "CodexCollaboration",
|
|
@@ -15297,7 +15331,7 @@ function mapCodexCollaborationItem(item, opts = {}, source = "history") {
|
|
|
15297
15331
|
args
|
|
15298
15332
|
}, { ...opts, id: startId })];
|
|
15299
15333
|
if (item.status === "completed" || item.status === "failed" || item.status === "interrupted") {
|
|
15300
|
-
envelopes.push(
|
|
15334
|
+
envelopes.push(index.createEnvelope("agent", {
|
|
15301
15335
|
t: "tool-call-end",
|
|
15302
15336
|
call: item.id,
|
|
15303
15337
|
result: { text: JSON.stringify(args, null, 2), isError: item.status !== "completed" }
|
|
@@ -15310,7 +15344,7 @@ function mapCodexThreadToSessionEnvelopes(thread) {
|
|
|
15310
15344
|
for (const turn of thread.turns ?? []) {
|
|
15311
15345
|
const startedAt = turnTimestampMs(turn);
|
|
15312
15346
|
const completedAt = completedTimestampMs(turn);
|
|
15313
|
-
envelopes.push(
|
|
15347
|
+
envelopes.push(index.createEnvelope("agent", { t: "turn-start" }, {
|
|
15314
15348
|
id: `${turn.id}:start`,
|
|
15315
15349
|
turn: turn.id,
|
|
15316
15350
|
time: startedAt
|
|
@@ -15325,7 +15359,7 @@ function mapCodexThreadToSessionEnvelopes(thread) {
|
|
|
15325
15359
|
case "userMessage": {
|
|
15326
15360
|
const text = textFromInputItems(item.content);
|
|
15327
15361
|
if (text) {
|
|
15328
|
-
envelopes.push(
|
|
15362
|
+
envelopes.push(index.createEnvelope("user", { t: "text", text }, {
|
|
15329
15363
|
id: item.id,
|
|
15330
15364
|
time: startedAt,
|
|
15331
15365
|
codexItemId: item.id
|
|
@@ -15336,7 +15370,7 @@ function mapCodexThreadToSessionEnvelopes(thread) {
|
|
|
15336
15370
|
case "agentMessage": {
|
|
15337
15371
|
const text = typeof item.text === "string" ? item.text.trim() : "";
|
|
15338
15372
|
if (text.length > 0) {
|
|
15339
|
-
envelopes.push(
|
|
15373
|
+
envelopes.push(index.createEnvelope("agent", { t: "text", text }, {
|
|
15340
15374
|
id: item.id,
|
|
15341
15375
|
turn: turn.id,
|
|
15342
15376
|
time: completedAt,
|
|
@@ -15348,7 +15382,7 @@ function mapCodexThreadToSessionEnvelopes(thread) {
|
|
|
15348
15382
|
case "reasoning": {
|
|
15349
15383
|
const text = reasoningText(item);
|
|
15350
15384
|
if (text) {
|
|
15351
|
-
envelopes.push(
|
|
15385
|
+
envelopes.push(index.createEnvelope("agent", { t: "text", text, thinking: true }, {
|
|
15352
15386
|
id: item.id,
|
|
15353
15387
|
turn: turn.id,
|
|
15354
15388
|
time: startedAt,
|
|
@@ -15403,7 +15437,7 @@ function mapCodexThreadToSessionEnvelopes(thread) {
|
|
|
15403
15437
|
}
|
|
15404
15438
|
}
|
|
15405
15439
|
}
|
|
15406
|
-
envelopes.push(
|
|
15440
|
+
envelopes.push(index.createEnvelope("agent", { t: "turn-end", status: turnStatus(turn) }, {
|
|
15407
15441
|
id: `${turn.id}:end`,
|
|
15408
15442
|
turn: turn.id,
|
|
15409
15443
|
time: completedAt
|
|
@@ -15458,7 +15492,7 @@ function mapCodexMcpMessageToSessionEnvelopes(message, state) {
|
|
|
15458
15492
|
}
|
|
15459
15493
|
if (type === "task_started") {
|
|
15460
15494
|
const turnId = cuid2.createId();
|
|
15461
|
-
const turnStart =
|
|
15495
|
+
const turnStart = index.createEnvelope("agent", { t: "turn-start" }, { turn: turnId });
|
|
15462
15496
|
startedSubagents.clear();
|
|
15463
15497
|
activeSubagents.clear();
|
|
15464
15498
|
providerSubagentToSessionSubagent.clear();
|
|
@@ -15489,7 +15523,7 @@ function mapCodexMcpMessageToSessionEnvelopes(message, state) {
|
|
|
15489
15523
|
providerSubagentToSessionSubagent,
|
|
15490
15524
|
envelopes: [
|
|
15491
15525
|
...emitSubagentStops(lifecycleOpts, startedSubagents, activeSubagents),
|
|
15492
|
-
|
|
15526
|
+
index.createEnvelope("agent", {
|
|
15493
15527
|
t: "turn-end",
|
|
15494
15528
|
status: pickTurnEndStatus(message, type)
|
|
15495
15529
|
}, lifecycleOpts)
|
|
@@ -15519,7 +15553,7 @@ function mapCodexMcpMessageToSessionEnvelopes(message, state) {
|
|
|
15519
15553
|
}
|
|
15520
15554
|
const envelopes = [];
|
|
15521
15555
|
maybeEmitSubagentStart(subagent, opts, startedSubagents, activeSubagents, envelopes);
|
|
15522
|
-
envelopes.push(
|
|
15556
|
+
envelopes.push(index.createEnvelope("agent", { t: "text", text: message.message }, opts));
|
|
15523
15557
|
return {
|
|
15524
15558
|
currentTurnId: state.currentTurnId,
|
|
15525
15559
|
startedSubagents,
|
|
@@ -15541,7 +15575,7 @@ function mapCodexMcpMessageToSessionEnvelopes(message, state) {
|
|
|
15541
15575
|
}
|
|
15542
15576
|
const envelopes = [];
|
|
15543
15577
|
maybeEmitSubagentStart(subagent, opts, startedSubagents, activeSubagents, envelopes);
|
|
15544
|
-
envelopes.push(
|
|
15578
|
+
envelopes.push(index.createEnvelope("agent", { t: "text", text, thinking: true }, opts));
|
|
15545
15579
|
return {
|
|
15546
15580
|
currentTurnId: state.currentTurnId,
|
|
15547
15581
|
startedSubagents,
|
|
@@ -15558,7 +15592,7 @@ function mapCodexMcpMessageToSessionEnvelopes(message, state) {
|
|
|
15558
15592
|
const envelopes = [];
|
|
15559
15593
|
maybeEmitSubagentStart(subagent, opts, startedSubagents, activeSubagents, envelopes);
|
|
15560
15594
|
envelopes.push(
|
|
15561
|
-
|
|
15595
|
+
index.createEnvelope("agent", {
|
|
15562
15596
|
t: "tool-call-start",
|
|
15563
15597
|
call,
|
|
15564
15598
|
name: "CodexBash",
|
|
@@ -15579,7 +15613,7 @@ function mapCodexMcpMessageToSessionEnvelopes(message, state) {
|
|
|
15579
15613
|
const call = pickCallId(message);
|
|
15580
15614
|
const envelopes = [];
|
|
15581
15615
|
maybeEmitSubagentStart(subagent, opts, startedSubagents, activeSubagents, envelopes);
|
|
15582
|
-
envelopes.push(
|
|
15616
|
+
envelopes.push(index.createEnvelope("agent", { t: "tool-call-end", call }, opts));
|
|
15583
15617
|
return {
|
|
15584
15618
|
currentTurnId: state.currentTurnId,
|
|
15585
15619
|
startedSubagents,
|
|
@@ -15595,7 +15629,7 @@ function mapCodexMcpMessageToSessionEnvelopes(message, state) {
|
|
|
15595
15629
|
const envelopes = [];
|
|
15596
15630
|
maybeEmitSubagentStart(subagent, opts, startedSubagents, activeSubagents, envelopes);
|
|
15597
15631
|
envelopes.push(
|
|
15598
|
-
|
|
15632
|
+
index.createEnvelope("agent", {
|
|
15599
15633
|
t: "tool-call-start",
|
|
15600
15634
|
call,
|
|
15601
15635
|
name: "CodexPatch",
|
|
@@ -15619,7 +15653,7 @@ function mapCodexMcpMessageToSessionEnvelopes(message, state) {
|
|
|
15619
15653
|
const call = pickCallId(message);
|
|
15620
15654
|
const envelopes = [];
|
|
15621
15655
|
maybeEmitSubagentStart(subagent, opts, startedSubagents, activeSubagents, envelopes);
|
|
15622
|
-
envelopes.push(
|
|
15656
|
+
envelopes.push(index.createEnvelope("agent", { t: "tool-call-end", call }, opts));
|
|
15623
15657
|
return {
|
|
15624
15658
|
currentTurnId: state.currentTurnId,
|
|
15625
15659
|
startedSubagents,
|
|
@@ -15640,7 +15674,7 @@ function mapCodexProcessorMessageToSessionEnvelopes(message, state) {
|
|
|
15640
15674
|
const toolLikeMessage = message;
|
|
15641
15675
|
const opts = buildEnvelopeOptions(state.currentTurnId);
|
|
15642
15676
|
if (message.type === "reasoning") {
|
|
15643
|
-
return [
|
|
15677
|
+
return [index.createEnvelope("agent", {
|
|
15644
15678
|
t: "text",
|
|
15645
15679
|
text: message.message,
|
|
15646
15680
|
thinking: true
|
|
@@ -15648,7 +15682,7 @@ function mapCodexProcessorMessageToSessionEnvelopes(message, state) {
|
|
|
15648
15682
|
}
|
|
15649
15683
|
if (message.type === "tool-call") {
|
|
15650
15684
|
const title = typeof toolLikeMessage.input?.title === "string" ? toolLikeMessage.input.title : `${toolLikeMessage.name || "Tool"} call`;
|
|
15651
|
-
return [
|
|
15685
|
+
return [index.createEnvelope("agent", {
|
|
15652
15686
|
t: "tool-call-start",
|
|
15653
15687
|
call: toolLikeMessage.callId,
|
|
15654
15688
|
name: toolLikeMessage.name || "unknown",
|
|
@@ -15661,13 +15695,13 @@ function mapCodexProcessorMessageToSessionEnvelopes(message, state) {
|
|
|
15661
15695
|
const envelopes = [];
|
|
15662
15696
|
const content = toolLikeMessage.output?.content;
|
|
15663
15697
|
if (typeof content === "string" && content.trim().length > 0) {
|
|
15664
|
-
envelopes.push(
|
|
15698
|
+
envelopes.push(index.createEnvelope("agent", {
|
|
15665
15699
|
t: "text",
|
|
15666
15700
|
text: content,
|
|
15667
15701
|
thinking: true
|
|
15668
15702
|
}, opts));
|
|
15669
15703
|
}
|
|
15670
|
-
envelopes.push(
|
|
15704
|
+
envelopes.push(index.createEnvelope("agent", {
|
|
15671
15705
|
t: "tool-call-end",
|
|
15672
15706
|
call: toolLikeMessage.callId
|
|
15673
15707
|
}, opts));
|
|
@@ -16356,17 +16390,17 @@ function createOfflineSessionStub(sessionTag) {
|
|
|
16356
16390
|
}
|
|
16357
16391
|
|
|
16358
16392
|
function setupOfflineReconnection(opts) {
|
|
16359
|
-
const { api
|
|
16393
|
+
const { api, sessionTag, metadata, state, response, onSessionSwap } = opts;
|
|
16360
16394
|
let session;
|
|
16361
16395
|
let reconnectionHandle = null;
|
|
16362
16396
|
if (!response) {
|
|
16363
16397
|
session = createOfflineSessionStub(sessionTag);
|
|
16364
|
-
reconnectionHandle =
|
|
16398
|
+
reconnectionHandle = index.startOfflineReconnection({
|
|
16365
16399
|
serverUrl: persistence.configuration.serverUrl,
|
|
16366
16400
|
onReconnected: async () => {
|
|
16367
|
-
const resp = await api
|
|
16401
|
+
const resp = await api.getOrCreateSession({ tag: sessionTag, metadata, state });
|
|
16368
16402
|
if (!resp) throw new Error("Server unavailable");
|
|
16369
|
-
const realSession = api
|
|
16403
|
+
const realSession = api.sessionSyncClient(resp);
|
|
16370
16404
|
onSessionSwap(realSession);
|
|
16371
16405
|
return realSession;
|
|
16372
16406
|
},
|
|
@@ -16376,7 +16410,7 @@ function setupOfflineReconnection(opts) {
|
|
|
16376
16410
|
});
|
|
16377
16411
|
return { session, reconnectionHandle, isOffline: true };
|
|
16378
16412
|
} else {
|
|
16379
|
-
session = api
|
|
16413
|
+
session = api.sessionSyncClient(response, opts.sessionClientOptions);
|
|
16380
16414
|
return { session, reconnectionHandle: null, isOffline: false };
|
|
16381
16415
|
}
|
|
16382
16416
|
}
|
|
@@ -16626,7 +16660,7 @@ function buildCodexTurnPrompt(opts) {
|
|
|
16626
16660
|
parts.push(opts.message);
|
|
16627
16661
|
if (opts.includeTitleInstruction) {
|
|
16628
16662
|
parts.push(CHANGE_TITLE_INSTRUCTION);
|
|
16629
|
-
parts.push(
|
|
16663
|
+
parts.push(index.BUILTIN_TODO_DISCOVERY);
|
|
16630
16664
|
}
|
|
16631
16665
|
return parts.join("\n\n");
|
|
16632
16666
|
}
|
|
@@ -16694,8 +16728,8 @@ async function runCodex(opts) {
|
|
|
16694
16728
|
process.exit(1);
|
|
16695
16729
|
}
|
|
16696
16730
|
const sessionTag = node_crypto.randomUUID();
|
|
16697
|
-
|
|
16698
|
-
const api
|
|
16731
|
+
index.connectionState.setBackend("Codex");
|
|
16732
|
+
const api = await index.ApiClient.create(opts.credentials);
|
|
16699
16733
|
persistence.logger.debug(`[codex] Starting with options: startedBy=${opts.startedBy || "terminal"}`);
|
|
16700
16734
|
const settings = await persistence.readSettings();
|
|
16701
16735
|
let machineId = settings?.machineId;
|
|
@@ -16705,7 +16739,7 @@ async function runCodex(opts) {
|
|
|
16705
16739
|
process.exit(1);
|
|
16706
16740
|
}
|
|
16707
16741
|
persistence.logger.debug(`Using machineId: ${machineId}`);
|
|
16708
|
-
await api
|
|
16742
|
+
await api.getOrCreateMachine({
|
|
16709
16743
|
machineId,
|
|
16710
16744
|
metadata: initialMachineMetadata
|
|
16711
16745
|
});
|
|
@@ -16749,17 +16783,17 @@ async function runCodex(opts) {
|
|
|
16749
16783
|
agentStateVersion: parseInt(reconnectAgentStateVersion || "0", 10)
|
|
16750
16784
|
};
|
|
16751
16785
|
} else {
|
|
16752
|
-
response = await api
|
|
16786
|
+
response = await api.getOrCreateSession({ tag: sessionTag, metadata, state });
|
|
16753
16787
|
}
|
|
16754
16788
|
if (response) {
|
|
16755
16789
|
await claimSessionOrExit(response.id, { takeover: !!reconnectSessionId, flavor: "codex" });
|
|
16756
16790
|
}
|
|
16757
|
-
if (reconnectSessionId && response && !await api
|
|
16791
|
+
if (reconnectSessionId && response && !await api.reactivateSession(response.id)) {
|
|
16758
16792
|
throw new Error(`Failed to reactivate archived session ${response.id}`);
|
|
16759
16793
|
}
|
|
16760
16794
|
let reconnectSeeded = false;
|
|
16761
16795
|
if (reconnectSessionId && response) {
|
|
16762
|
-
const snapshot = await api
|
|
16796
|
+
const snapshot = await api.getSession(response.id, response.encryptionKey, response.encryptionVariant);
|
|
16763
16797
|
if (snapshot.ok) {
|
|
16764
16798
|
response = applyServerSnapshot(response, snapshot.session);
|
|
16765
16799
|
reconnectSeeded = true;
|
|
@@ -16776,7 +16810,7 @@ async function runCodex(opts) {
|
|
|
16776
16810
|
let abortInProgress = null;
|
|
16777
16811
|
let turnActive = false;
|
|
16778
16812
|
const { session: initialSession, reconnectionHandle } = setupOfflineReconnection({
|
|
16779
|
-
api
|
|
16813
|
+
api,
|
|
16780
16814
|
sessionTag,
|
|
16781
16815
|
metadata,
|
|
16782
16816
|
state,
|
|
@@ -16799,7 +16833,7 @@ async function runCodex(opts) {
|
|
|
16799
16833
|
if (response) {
|
|
16800
16834
|
try {
|
|
16801
16835
|
persistence.logger.debug(`[START] Reporting session ${response.id} to daemon`);
|
|
16802
|
-
const result = await
|
|
16836
|
+
const result = await index.notifyDaemonSessionStarted(response.id, metadata, {
|
|
16803
16837
|
encryptionKey: persistence.encodeBase64(response.encryptionKey),
|
|
16804
16838
|
encryptionVariant: response.encryptionVariant,
|
|
16805
16839
|
seq: response.seq,
|
|
@@ -16932,7 +16966,7 @@ async function runCodex(opts) {
|
|
|
16932
16966
|
const sendReady = () => {
|
|
16933
16967
|
session.sendSessionEvent({ type: "ready" });
|
|
16934
16968
|
try {
|
|
16935
|
-
api
|
|
16969
|
+
api.push().sendSessionNotification({
|
|
16936
16970
|
kind: "done",
|
|
16937
16971
|
metadata: session.getMetadata(),
|
|
16938
16972
|
data: {
|
|
@@ -17062,7 +17096,7 @@ async function runCodex(opts) {
|
|
|
17062
17096
|
}
|
|
17063
17097
|
process.stdin.setEncoding("utf8");
|
|
17064
17098
|
}
|
|
17065
|
-
client = new
|
|
17099
|
+
client = new index.CodexAppServerClient(sandboxConfig);
|
|
17066
17100
|
const idleRelease = new CodexIdleReleaseTimer({
|
|
17067
17101
|
delayMs: resolveCodexIdleReleaseMs(process.env[CODEX_IDLE_RELEASE_ENV]),
|
|
17068
17102
|
isIdle: () => shouldReleaseIdleCodex({
|
|
@@ -17621,7 +17655,7 @@ Conversation history is preserved on the server, but in-flight tool calls are in
|
|
|
17621
17655
|
return;
|
|
17622
17656
|
} else if (subcommand === "install-terminal-hooks") {
|
|
17623
17657
|
try {
|
|
17624
|
-
const { installTerminalHooks, parseTerminalHooksArgs, TERMINAL_HOOKS_HELP } = await Promise.resolve().then(function () { return require('./installTerminalHooks-
|
|
17658
|
+
const { installTerminalHooks, parseTerminalHooksArgs, TERMINAL_HOOKS_HELP } = await Promise.resolve().then(function () { return require('./installTerminalHooks-De7_iOOC.cjs'); });
|
|
17625
17659
|
const command = parseTerminalHooksArgs(args.slice(1));
|
|
17626
17660
|
if (command.action === "help") {
|
|
17627
17661
|
console.log(TERMINAL_HOOKS_HELP);
|
|
@@ -17636,9 +17670,18 @@ Conversation history is preserved on the server, but in-flight tool calls are in
|
|
|
17636
17670
|
}
|
|
17637
17671
|
process.exit(1);
|
|
17638
17672
|
}
|
|
17673
|
+
} else if (subcommand === "agent-home") {
|
|
17674
|
+
try {
|
|
17675
|
+
const { parseAgentHomeArgs, runAgentHomeCommand } = await Promise.resolve().then(function () { return require('./agentHome-uf1zs2Fi.cjs'); });
|
|
17676
|
+
await runAgentHomeCommand(parseAgentHomeArgs(args.slice(1)));
|
|
17677
|
+
process.exit(0);
|
|
17678
|
+
} catch (error) {
|
|
17679
|
+
console.error(chalk.red("Error:"), error instanceof Error ? error.message : "Unknown error");
|
|
17680
|
+
process.exit(1);
|
|
17681
|
+
}
|
|
17639
17682
|
} else if (subcommand === "spawn") {
|
|
17640
17683
|
try {
|
|
17641
|
-
const { handleSpawnCommand } = await Promise.resolve().then(function () { return require('./spawn-
|
|
17684
|
+
const { handleSpawnCommand } = await Promise.resolve().then(function () { return require('./spawn-Be4nsNuQ.cjs'); });
|
|
17642
17685
|
await handleSpawnCommand(args.slice(1));
|
|
17643
17686
|
} catch (error) {
|
|
17644
17687
|
console.error(chalk.red("Error:"), error instanceof Error ? error.message : "Unknown error");
|
|
@@ -17650,7 +17693,7 @@ Conversation history is preserved on the server, but in-flight tool calls are in
|
|
|
17650
17693
|
return;
|
|
17651
17694
|
} else if (subcommand === "sessions") {
|
|
17652
17695
|
try {
|
|
17653
|
-
const { handleSessionsCommand } = await Promise.resolve().then(function () { return require('./sessions-
|
|
17696
|
+
const { handleSessionsCommand } = await Promise.resolve().then(function () { return require('./sessions-CtVcoXvG.cjs'); });
|
|
17654
17697
|
await handleSessionsCommand(args.slice(1));
|
|
17655
17698
|
} catch (error) {
|
|
17656
17699
|
console.error(chalk.red("Error:"), error instanceof Error ? error.message : "Unknown error");
|
|
@@ -17662,7 +17705,7 @@ Conversation history is preserved on the server, but in-flight tool calls are in
|
|
|
17662
17705
|
return;
|
|
17663
17706
|
} else if (subcommand === "send") {
|
|
17664
17707
|
try {
|
|
17665
|
-
const { handleSendCommand } = await Promise.resolve().then(function () { return require('./send-
|
|
17708
|
+
const { handleSendCommand } = await Promise.resolve().then(function () { return require('./send-BA1Dgpgn.cjs'); });
|
|
17666
17709
|
await handleSendCommand(args.slice(1));
|
|
17667
17710
|
} catch (error) {
|
|
17668
17711
|
console.error(chalk.red("Error:"), error instanceof Error ? error.message : "Unknown error");
|
|
@@ -17768,9 +17811,9 @@ Conversation history is preserved on the server, but in-flight tool calls are in
|
|
|
17768
17811
|
if (geminiSubcommand === "project" && args[2] === "set" && args[3]) {
|
|
17769
17812
|
const projectId = args[3];
|
|
17770
17813
|
try {
|
|
17771
|
-
const { saveGoogleCloudProjectToConfig } = await Promise.resolve().then(function () { return require('./config-
|
|
17772
|
-
const { readCredentialsForConfiguredRelay: readCredentialsForConfiguredRelay2 } = await Promise.resolve().then(function () { return require('./limits-
|
|
17773
|
-
const { ApiClient: ApiClient2 } = await Promise.resolve().then(function () { return require('./types-
|
|
17814
|
+
const { saveGoogleCloudProjectToConfig } = await Promise.resolve().then(function () { return require('./config-kx4y9oAI.cjs'); });
|
|
17815
|
+
const { readCredentialsForConfiguredRelay: readCredentialsForConfiguredRelay2 } = await Promise.resolve().then(function () { return require('./limits-C_Sklt--.cjs'); }).then(function (n) { return n.persistence; });
|
|
17816
|
+
const { ApiClient: ApiClient2 } = await Promise.resolve().then(function () { return require('./types-DZ5c-9f3.cjs'); }).then(function (n) { return n.api; });
|
|
17774
17817
|
let userEmail = void 0;
|
|
17775
17818
|
try {
|
|
17776
17819
|
const credentials = await readCredentialsForConfiguredRelay2();
|
|
@@ -17801,7 +17844,7 @@ Conversation history is preserved on the server, but in-flight tool calls are in
|
|
|
17801
17844
|
}
|
|
17802
17845
|
if (geminiSubcommand === "project" && args[2] === "get") {
|
|
17803
17846
|
try {
|
|
17804
|
-
const { readGeminiLocalConfig } = await Promise.resolve().then(function () { return require('./config-
|
|
17847
|
+
const { readGeminiLocalConfig } = await Promise.resolve().then(function () { return require('./config-kx4y9oAI.cjs'); });
|
|
17805
17848
|
const config = readGeminiLocalConfig();
|
|
17806
17849
|
if (config.googleCloudProject) {
|
|
17807
17850
|
console.log(`Current Google Cloud Project: ${config.googleCloudProject}`);
|
|
@@ -17841,7 +17884,7 @@ Conversation history is preserved on the server, but in-flight tool calls are in
|
|
|
17841
17884
|
process.exit(0);
|
|
17842
17885
|
}
|
|
17843
17886
|
try {
|
|
17844
|
-
const { runGemini } = await Promise.resolve().then(function () { return require('./runGemini-
|
|
17887
|
+
const { runGemini } = await Promise.resolve().then(function () { return require('./runGemini-CCdGxTF2.cjs'); });
|
|
17845
17888
|
let startedBy = void 0;
|
|
17846
17889
|
for (let i = 1; i < args.length; i++) {
|
|
17847
17890
|
if (args[i] === "--started-by") {
|
|
@@ -17864,7 +17907,7 @@ Conversation history is preserved on the server, but in-flight tool calls are in
|
|
|
17864
17907
|
} else if (subcommand === "pi") {
|
|
17865
17908
|
if (args[1] === "--terminal") {
|
|
17866
17909
|
try {
|
|
17867
|
-
const { runPiTerminal } = await Promise.resolve().then(function () { return require('./piTerminal-
|
|
17910
|
+
const { runPiTerminal } = await Promise.resolve().then(function () { return require('./piTerminal-BFpwVGWr.cjs'); });
|
|
17868
17911
|
process.exitCode = await runPiTerminal(args.slice(2));
|
|
17869
17912
|
} catch (error) {
|
|
17870
17913
|
console.error(chalk.red("Error:"), error instanceof Error ? error.message : "Unknown error");
|
|
@@ -17881,7 +17924,7 @@ Conversation history is preserved on the server, but in-flight tool calls are in
|
|
|
17881
17924
|
}
|
|
17882
17925
|
};
|
|
17883
17926
|
try {
|
|
17884
|
-
const { runAcp, resolveAcpAgentConfig } = await Promise.resolve().then(function () { return require('./index-
|
|
17927
|
+
const { runAcp, resolveAcpAgentConfig } = await Promise.resolve().then(function () { return require('./index-Dox9iD5R.cjs'); });
|
|
17885
17928
|
const parsed = parsePiRunnerArgs(args.slice(1));
|
|
17886
17929
|
const resolved = resolveAcpAgentConfig(["pi", ...parsed.passthrough]);
|
|
17887
17930
|
const { credentials } = await authAndSetupMachineIfNeeded();
|
|
@@ -17909,7 +17952,7 @@ Conversation history is preserved on the server, but in-flight tool calls are in
|
|
|
17909
17952
|
return;
|
|
17910
17953
|
} else if (subcommand === "acp") {
|
|
17911
17954
|
try {
|
|
17912
|
-
const { runAcp, resolveAcpAgentConfig } = await Promise.resolve().then(function () { return require('./index-
|
|
17955
|
+
const { runAcp, resolveAcpAgentConfig } = await Promise.resolve().then(function () { return require('./index-Dox9iD5R.cjs'); });
|
|
17913
17956
|
let startedBy = void 0;
|
|
17914
17957
|
let verbose = false;
|
|
17915
17958
|
const acpArgs = [];
|
|
@@ -17949,7 +17992,7 @@ Conversation history is preserved on the server, but in-flight tool calls are in
|
|
|
17949
17992
|
return;
|
|
17950
17993
|
} else if (subcommand === "openclaw") {
|
|
17951
17994
|
try {
|
|
17952
|
-
const { runOpenClaw } = await Promise.resolve().then(function () { return require('./runOpenClaw-
|
|
17995
|
+
const { runOpenClaw } = await Promise.resolve().then(function () { return require('./runOpenClaw-CRMUfrWk.cjs'); });
|
|
17953
17996
|
let startedBy = void 0;
|
|
17954
17997
|
let verbose = false;
|
|
17955
17998
|
let gatewayUrl;
|
|
@@ -18000,7 +18043,7 @@ Conversation history is preserved on the server, but in-flight tool calls are in
|
|
|
18000
18043
|
return;
|
|
18001
18044
|
} else if (subcommand === "todo") {
|
|
18002
18045
|
try {
|
|
18003
|
-
const { handleTodoCommand } = await Promise.resolve().then(function () { return require('./todo-
|
|
18046
|
+
const { handleTodoCommand } = await Promise.resolve().then(function () { return require('./todo-EffYAnre.cjs'); });
|
|
18004
18047
|
await handleTodoCommand(args.slice(1));
|
|
18005
18048
|
} catch (error) {
|
|
18006
18049
|
console.error(JSON.stringify({ error: error instanceof Error ? error.message : "Todo command failed" }));
|
|
@@ -18009,7 +18052,7 @@ Conversation history is preserved on the server, but in-flight tool calls are in
|
|
|
18009
18052
|
return;
|
|
18010
18053
|
} else if (subcommand === "teams") {
|
|
18011
18054
|
try {
|
|
18012
|
-
const { handleTeamsCommand } = await Promise.resolve().then(function () { return require('./teams-
|
|
18055
|
+
const { handleTeamsCommand } = await Promise.resolve().then(function () { return require('./teams-CcjjNLi8.cjs'); });
|
|
18013
18056
|
await handleTeamsCommand(args.slice(1));
|
|
18014
18057
|
} catch (error) {
|
|
18015
18058
|
console.error(error instanceof Error ? error.message : "Teams command failed");
|
|
@@ -18018,7 +18061,7 @@ Conversation history is preserved on the server, but in-flight tool calls are in
|
|
|
18018
18061
|
return;
|
|
18019
18062
|
} else if (subcommand === "mcp" && (args.length === 1 || args.length === 2 && args[1] === "--terminal-tools")) {
|
|
18020
18063
|
try {
|
|
18021
|
-
const { handleMcpCommand } = await Promise.resolve().then(function () { return require('./mcp-
|
|
18064
|
+
const { handleMcpCommand } = await Promise.resolve().then(function () { return require('./mcp-xyb8dYIQ.cjs'); });
|
|
18022
18065
|
await handleMcpCommand(args[1] === "--terminal-tools");
|
|
18023
18066
|
} catch (error) {
|
|
18024
18067
|
process.stderr.write(`[very-happy mcp] Fatal: ${error instanceof Error ? error.message : String(error)}
|
|
@@ -18041,7 +18084,7 @@ Conversation history is preserved on the server, but in-flight tool calls are in
|
|
|
18041
18084
|
const daemonSubcommand = args[1];
|
|
18042
18085
|
if (daemonSubcommand === "list") {
|
|
18043
18086
|
try {
|
|
18044
|
-
const sessions = await
|
|
18087
|
+
const sessions = await index.listDaemonSessions();
|
|
18045
18088
|
if (sessions.length === 0) {
|
|
18046
18089
|
console.log("No active sessions this daemon is aware of (they might have been started by a previous version of the daemon)");
|
|
18047
18090
|
} else {
|
|
@@ -18059,7 +18102,7 @@ Conversation history is preserved on the server, but in-flight tool calls are in
|
|
|
18059
18102
|
process.exit(1);
|
|
18060
18103
|
}
|
|
18061
18104
|
try {
|
|
18062
|
-
const success = await
|
|
18105
|
+
const success = await index.stopDaemonSession(sessionId);
|
|
18063
18106
|
console.log(success ? "Session stopped" : "Failed to stop session");
|
|
18064
18107
|
} catch (error) {
|
|
18065
18108
|
console.log("No daemon running");
|
|
@@ -18067,7 +18110,7 @@ Conversation history is preserved on the server, but in-flight tool calls are in
|
|
|
18067
18110
|
return;
|
|
18068
18111
|
} else if (daemonSubcommand === "start") {
|
|
18069
18112
|
const currentState = await persistence.readDaemonState();
|
|
18070
|
-
const running = await
|
|
18113
|
+
const running = await index.checkIfDaemonRunningAndCleanupStaleState();
|
|
18071
18114
|
const currentDaemonMatches = currentState && currentState.startedWithCliVersion === persistence.configuration.currentCliVersion && daemonEndpointsMatch(
|
|
18072
18115
|
currentState.serverUrl,
|
|
18073
18116
|
currentState.webappUrl,
|
|
@@ -18076,7 +18119,7 @@ Conversation history is preserved on the server, but in-flight tool calls are in
|
|
|
18076
18119
|
);
|
|
18077
18120
|
if (running && !currentDaemonMatches) {
|
|
18078
18121
|
console.log("Configured relay or CLI version changed; restarting the existing daemon");
|
|
18079
|
-
await
|
|
18122
|
+
await index.stopDaemon();
|
|
18080
18123
|
}
|
|
18081
18124
|
const child = spawnHappyCLI(["daemon", "start-sync"], {
|
|
18082
18125
|
detached: true,
|
|
@@ -18086,7 +18129,7 @@ Conversation history is preserved on the server, but in-flight tool calls are in
|
|
|
18086
18129
|
child.unref();
|
|
18087
18130
|
let started = false;
|
|
18088
18131
|
for (let i = 0; i < 50; i++) {
|
|
18089
|
-
if (await
|
|
18132
|
+
if (await index.checkIfDaemonRunningAndCleanupStaleState()) {
|
|
18090
18133
|
started = true;
|
|
18091
18134
|
break;
|
|
18092
18135
|
}
|
|
@@ -18103,7 +18146,7 @@ Conversation history is preserved on the server, but in-flight tool calls are in
|
|
|
18103
18146
|
await startDaemon();
|
|
18104
18147
|
process.exit(0);
|
|
18105
18148
|
} else if (daemonSubcommand === "stop") {
|
|
18106
|
-
await
|
|
18149
|
+
await index.stopDaemon();
|
|
18107
18150
|
process.exit(0);
|
|
18108
18151
|
} else if (daemonSubcommand === "status") {
|
|
18109
18152
|
await runDoctorDaemon();
|
|
@@ -18248,6 +18291,8 @@ ${chalk.bold("Usage:")}
|
|
|
18248
18291
|
very-happy install-terminal-hooks
|
|
18249
18292
|
Install optional Claude terminal mirror hooks
|
|
18250
18293
|
(add --remove to uninstall them)
|
|
18294
|
+
very-happy agent-home Show or pin where Claude Code / Codex keep their
|
|
18295
|
+
conversations on this machine (agent-home --help)
|
|
18251
18296
|
very-happy connect Connect AI vendor API keys
|
|
18252
18297
|
very-happy todo Built-in Todos and official agent skill (todo --help)
|
|
18253
18298
|
very-happy sandbox Configure and manage OS-level sandboxing
|
|
@@ -18363,9 +18408,9 @@ ${chalk.bold("Examples:")}
|
|
|
18363
18408
|
}
|
|
18364
18409
|
console.log(chalk.blue("\u{1F4F1} Sending push notification..."));
|
|
18365
18410
|
try {
|
|
18366
|
-
const api
|
|
18411
|
+
const api = await index.ApiClient.create(credentials);
|
|
18367
18412
|
const notificationTitle = title || "Happy";
|
|
18368
|
-
api
|
|
18413
|
+
api.push().sendToAllDevices(
|
|
18369
18414
|
notificationTitle,
|
|
18370
18415
|
message,
|
|
18371
18416
|
{
|