very-happy-cli 0.2.94 → 0.2.96

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.
Files changed (29) hide show
  1. package/dist/{AcpBackend-Ds4mP02F.mjs → AcpBackend-B5Eh8G3W.mjs} +1 -1
  2. package/dist/{AcpBackend-DoSXb9La.cjs → AcpBackend-BaCt4_zS.cjs} +1 -1
  3. package/dist/{AcpSessionManager-DQ6j5fp4.cjs → AcpSessionManager-CvgmPlXB.cjs} +1 -1
  4. package/dist/{AcpSessionManager-B6RqjyQS.mjs → AcpSessionManager-grr_aJEI.mjs} +1 -1
  5. package/dist/{config-yrZNEia7.mjs → config-B69TZlJj.mjs} +2 -2
  6. package/dist/{config-IdMPfmwy.cjs → config-BjsUeQPA.cjs} +2 -2
  7. package/dist/{index-27948eGz.mjs → index-BMmbxCTq.mjs} +210 -47
  8. package/dist/{index-DXpQrR4U.mjs → index-C-uJXSm3.mjs} +5 -5
  9. package/dist/{index-BfCdbWQI.cjs → index-DID1FV_n.cjs} +4 -4
  10. package/dist/{index-bqUSeHWU.cjs → index-uc-dtu-3.cjs} +212 -49
  11. package/dist/index.cjs +2 -2
  12. package/dist/index.mjs +2 -2
  13. package/dist/{installTerminalHooks-dVZoe8om.mjs → installTerminalHooks-CBHjEQ-a.mjs} +2 -2
  14. package/dist/{installTerminalHooks-D0gCqzZu.cjs → installTerminalHooks-CepXxAM_.cjs} +2 -2
  15. package/dist/lib.cjs +1 -1
  16. package/dist/lib.mjs +1 -1
  17. package/dist/{mcp-BvDgylsM.mjs → mcp-BdSHqi2d.mjs} +2 -2
  18. package/dist/{mcp-CRcmpUpX.cjs → mcp-CAtbtTXF.cjs} +2 -2
  19. package/dist/{runGemini-DIAChFOe.mjs → runGemini-cMZ3_CRf.mjs} +4 -4
  20. package/dist/{runGemini-BoVDs_V6.cjs → runGemini-qStPY5fH.cjs} +4 -4
  21. package/dist/{runOpenClaw-Cdsug1sI.cjs → runOpenClaw-B8HR6GnX.cjs} +3 -3
  22. package/dist/{runOpenClaw-DcC_uOjt.mjs → runOpenClaw-BJ36wEbk.mjs} +3 -3
  23. package/dist/{send-DoFm4-OB.cjs → send-6eY55o3C.cjs} +2 -2
  24. package/dist/{send-DvDOKQ4V.mjs → send-TX13v8Xe.mjs} +2 -2
  25. package/dist/{spawn-CEWzROeD.mjs → spawn-CfCE6JAv.mjs} +2 -2
  26. package/dist/{spawn-C7QRBKkQ.cjs → spawn-vOZA0kOi.cjs} +2 -2
  27. package/dist/{types-CSOwbjq5.mjs → types-CLRl0ET3.mjs} +18 -8
  28. package/dist/{types-CcaZTXxx.cjs → types-okYCRlgl.cjs} +19 -9
  29. package/package.json +7 -7
@@ -3,7 +3,7 @@
3
3
  var chalk = require('chalk');
4
4
  var os = require('node:os');
5
5
  var node_crypto = require('node:crypto');
6
- var persistence = require('./types-CcaZTXxx.cjs');
6
+ var persistence = require('./types-okYCRlgl.cjs');
7
7
  var spawn = require('cross-spawn');
8
8
  var path = require('node:path');
9
9
  var node_readline = require('node:readline');
@@ -7233,6 +7233,144 @@ function recoverableSessionPid(metadata, liveHappyPids) {
7233
7233
  const pid = metadata?.hostPid;
7234
7234
  return typeof pid === "number" && Number.isInteger(pid) && pid > 0 && liveHappyPids.has(pid) ? pid : null;
7235
7235
  }
7236
+ function escapeRegExp(value) {
7237
+ return value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
7238
+ }
7239
+ function sessionAgentConversationId(metadata) {
7240
+ if (!metadata) return null;
7241
+ if (metadata.flavor === "codex") return metadata.codexThreadId ?? null;
7242
+ return metadata.claudeSessionId ?? metadata.codexThreadId ?? null;
7243
+ }
7244
+ function isDaemonWrapperForConversation(command, conversationId) {
7245
+ if (!command || !conversationId) return false;
7246
+ const startedByDaemon = /(?:^|\s)--started-by\s+daemon(?:\s|$)/.test(command);
7247
+ if (!startedByDaemon) return false;
7248
+ const resume = new RegExp(`(?:^|\\s)--resume(?:\\s+|=)${escapeRegExp(conversationId)}(?:\\s|$)`);
7249
+ return resume.test(command);
7250
+ }
7251
+ function findSessionWrapperPids(metadata, liveHappyProcesses, options = {}) {
7252
+ const out = [];
7253
+ const livePids = new Set(liveHappyProcesses.map((p) => p.pid));
7254
+ const lockPid = options.lockPid ?? null;
7255
+ if (lockPid !== null && lockPid !== options.excludePid && livePids.has(lockPid)) out.push(lockPid);
7256
+ const persisted = recoverableSessionPid(metadata, livePids);
7257
+ if (persisted !== null && persisted !== options.excludePid && !out.includes(persisted)) out.push(persisted);
7258
+ const conversationId = sessionAgentConversationId(metadata);
7259
+ if (conversationId) {
7260
+ for (const proc of liveHappyProcesses) {
7261
+ if (proc.pid === options.excludePid || out.includes(proc.pid)) continue;
7262
+ if (isDaemonWrapperForConversation(proc.command, conversationId)) out.push(proc.pid);
7263
+ }
7264
+ }
7265
+ return out;
7266
+ }
7267
+ function mergeRestoreMetadata(stale, reported) {
7268
+ if (!reported) return stale;
7269
+ return { ...stale, ...processIdentityFields(reported) };
7270
+ }
7271
+
7272
+ const SESSION_LOCK_DIR = "session-locks";
7273
+ const defaultRuntime = () => ({
7274
+ dir: path.join(persistence.configuration.happyHomeDir, SESSION_LOCK_DIR),
7275
+ selfPid: process.pid,
7276
+ now: () => Date.now(),
7277
+ signal: (pid, signal) => process.kill(pid, signal),
7278
+ isAlive: (pid) => {
7279
+ try {
7280
+ process.kill(pid, 0);
7281
+ return true;
7282
+ } catch {
7283
+ return false;
7284
+ }
7285
+ },
7286
+ schedule: (callback, delayMs) => {
7287
+ setTimeout(callback, delayMs);
7288
+ }
7289
+ });
7290
+ function sessionLockPath(happySessionId, dir = path.join(persistence.configuration.happyHomeDir, SESSION_LOCK_DIR)) {
7291
+ return path.join(dir, `${happySessionId}.json`);
7292
+ }
7293
+ function readSessionLock(happySessionId, dir) {
7294
+ try {
7295
+ const path = sessionLockPath(happySessionId, dir);
7296
+ if (!node_fs.existsSync(path)) return null;
7297
+ const parsed = JSON.parse(node_fs.readFileSync(path, "utf-8"));
7298
+ if (typeof parsed?.pid !== "number" || !Number.isInteger(parsed.pid) || parsed.pid <= 0) return null;
7299
+ return {
7300
+ pid: parsed.pid,
7301
+ startedAt: typeof parsed.startedAt === "number" ? parsed.startedAt : 0,
7302
+ version: typeof parsed.version === "string" ? parsed.version : "",
7303
+ ...typeof parsed.flavor === "string" ? { flavor: parsed.flavor } : {}
7304
+ };
7305
+ } catch {
7306
+ return null;
7307
+ }
7308
+ }
7309
+ function liveSessionLockHolder(happySessionId, runtime = defaultRuntime()) {
7310
+ const record = readSessionLock(happySessionId, runtime.dir);
7311
+ if (!record || record.pid === runtime.selfPid) return null;
7312
+ return runtime.isAlive(record.pid) ? record : null;
7313
+ }
7314
+ function writeSessionLock(happySessionId, record, dir) {
7315
+ node_fs.mkdirSync(dir, { recursive: true, mode: 448 });
7316
+ const path = sessionLockPath(happySessionId, dir);
7317
+ const tmp = `${path}.${record.pid}.tmp`;
7318
+ persistence.writePrivateFileSync(tmp, JSON.stringify(record));
7319
+ node_fs.renameSync(tmp, path);
7320
+ }
7321
+ function acquireSessionLock(happySessionId, options, runtime = defaultRuntime()) {
7322
+ const record = () => ({
7323
+ pid: runtime.selfPid,
7324
+ startedAt: runtime.now(),
7325
+ version: options.version,
7326
+ ...options.flavor ? { flavor: options.flavor } : {}
7327
+ });
7328
+ const holder = liveSessionLockHolder(happySessionId, runtime);
7329
+ if (!holder) {
7330
+ writeSessionLock(happySessionId, record(), runtime.dir);
7331
+ return Promise.resolve({ ok: true, replaced: null });
7332
+ }
7333
+ if (!options.takeover) {
7334
+ return Promise.resolve({ ok: false, holder });
7335
+ }
7336
+ return new Promise((resolve) => {
7337
+ const requested = terminateProcess(holder.pid, (stopped) => {
7338
+ if (!stopped) {
7339
+ resolve({ ok: false, holder });
7340
+ return;
7341
+ }
7342
+ writeSessionLock(happySessionId, record(), runtime.dir);
7343
+ resolve({ ok: true, replaced: holder });
7344
+ }, runtime, options.graceMs ?? 2e3);
7345
+ if (!requested) resolve({ ok: false, holder });
7346
+ });
7347
+ }
7348
+ function releaseSessionLock(happySessionId, runtime = defaultRuntime()) {
7349
+ try {
7350
+ const record = readSessionLock(happySessionId, runtime.dir);
7351
+ if (record && record.pid === runtime.selfPid) {
7352
+ node_fs.unlinkSync(sessionLockPath(happySessionId, runtime.dir));
7353
+ }
7354
+ } catch {
7355
+ }
7356
+ }
7357
+ async function claimSessionOrExit(happySessionId, options) {
7358
+ const result = await acquireSessionLock(happySessionId, {
7359
+ takeover: options.takeover,
7360
+ version: persistence.configuration.currentCliVersion,
7361
+ flavor: options.flavor
7362
+ });
7363
+ if (!result.ok) {
7364
+ const message = `Session ${happySessionId} is already run by very-happy pid ${result.holder.pid} (v${result.holder.version || "?"}); this process yields.`;
7365
+ persistence.logger.debug(`[SESSION LOCK] ${message}`);
7366
+ console.error(message);
7367
+ process.exit(0);
7368
+ }
7369
+ if (result.replaced) {
7370
+ persistence.logger.debug(`[SESSION LOCK] Took over session ${happySessionId} from pid ${result.replaced.pid} (v${result.replaced.version || "?"})`);
7371
+ }
7372
+ process.on("exit", () => releaseSessionLock(happySessionId));
7373
+ }
7236
7374
 
7237
7375
  function shellescape(s) {
7238
7376
  return "'" + s.replace(/'/g, "'\\''") + "'";
@@ -7324,7 +7462,7 @@ async function startDaemon() {
7324
7462
  const pidToTrackedSession = /* @__PURE__ */ new Map();
7325
7463
  const sessionIdToFinishedSession = /* @__PURE__ */ new Map();
7326
7464
  const persisted = persistence.readPersistedSessions();
7327
- const liveHappyPids = new Set((await findAllHappyProcesses()).map((entry) => entry.pid));
7465
+ const liveHappyProcesses = await findAllHappyProcesses();
7328
7466
  for (const [id, s] of Object.entries(persisted)) {
7329
7467
  const tracked = {
7330
7468
  startedBy: "persisted",
@@ -7339,12 +7477,20 @@ async function startDaemon() {
7339
7477
  },
7340
7478
  pid: 0
7341
7479
  };
7342
- const livePid = recoverableSessionPid(s.metadata, liveHappyPids);
7343
- if (livePid !== null) {
7480
+ const livePids = findSessionWrapperPids(s.metadata, liveHappyProcesses, { excludePid: process.pid, lockPid: readSessionLock(id)?.pid });
7481
+ if (livePids.length > 0) {
7482
+ const [livePid, ...duplicates] = livePids;
7344
7483
  tracked.pid = livePid;
7345
7484
  tracked.startedBy = "recovered after daemon restart";
7346
7485
  pidToTrackedSession.set(livePid, tracked);
7347
- persistence.persistSession(id, { ...s, savedAt: Date.now() });
7486
+ if (livePid !== s.metadata?.hostPid) {
7487
+ persistence.logger.debug(`[DAEMON RUN] Session ${id}: persisted hostPid ${s.metadata?.hostPid} is stale; adopted live wrapper ${livePid} by its --resume command line`);
7488
+ }
7489
+ for (const dup of duplicates) {
7490
+ persistence.logger.warn(`[DAEMON RUN] Session ${id} has a duplicate live wrapper ${dup} (kept ${livePid}); restart the session to collapse them`);
7491
+ pidToTrackedSession.set(dup, { ...tracked, pid: dup, startedBy: "recovered after daemon restart (duplicate wrapper)" });
7492
+ }
7493
+ persistence.persistSession(id, { ...s, metadata: { ...s.metadata, hostPid: livePid }, savedAt: Date.now() });
7348
7494
  } else {
7349
7495
  sessionIdToFinishedSession.set(id, tracked);
7350
7496
  }
@@ -7374,6 +7520,11 @@ async function startDaemon() {
7374
7520
  savedAt: Date.now()
7375
7521
  });
7376
7522
  }
7523
+ for (const [otherPid, other] of pidToTrackedSession.entries()) {
7524
+ if (other.happySessionId === sessionId && otherPid !== pid && isPidAlive(otherPid)) {
7525
+ persistence.logger.warn(`[DAEMON RUN] Session ${sessionId} now has two live wrappers (${otherPid} and ${pid}); restart the session to collapse them`);
7526
+ }
7527
+ }
7377
7528
  const existingSession = pidToTrackedSession.get(pid);
7378
7529
  if (existingSession && existingSession.startedBy === "daemon") {
7379
7530
  existingSession.happySessionId = sessionId;
@@ -7801,6 +7952,21 @@ async function startDaemon() {
7801
7952
  }
7802
7953
  return sessionIdToFinishedSession.get(happySessionId);
7803
7954
  };
7955
+ const persistRestoreRecord = (happySessionId, fallback, metadata) => {
7956
+ const candidates = [...pidToTrackedSession.values()].filter((s) => s.happySessionId === happySessionId && isPidAlive(s.pid));
7957
+ const live = candidates.find((s) => s.childProcess) ?? candidates[0];
7958
+ const encryption = live?.encryption ?? fallback.encryption;
7959
+ if (!encryption) return;
7960
+ persistence.persistSession(happySessionId, {
7961
+ encryptionKey: persistence.encodeBase64(encryption.encryptionKey),
7962
+ encryptionVariant: encryption.encryptionVariant,
7963
+ seq: encryption.seq,
7964
+ metadataVersion: encryption.metadataVersion,
7965
+ agentStateVersion: encryption.agentStateVersion,
7966
+ metadata: mergeRestoreMetadata(metadata, live?.happySessionMetadataFromLocalWebhook),
7967
+ savedAt: Date.now()
7968
+ });
7969
+ };
7804
7970
  const fetchServerSessionMetadata = async (sessionId, encryptionKey, encryptionVariant) => {
7805
7971
  try {
7806
7972
  const byId = await axios.get(`${persistence.configuration.serverUrl}/v1/sessions/${encodeURIComponent(sessionId)}`, {
@@ -7857,6 +8023,14 @@ async function startDaemon() {
7857
8023
  if (!tracked) {
7858
8024
  return { type: "error", errorMessage: `resume-precheck:not-tracked: Session ${happySessionId} is not tracked by this daemon. It may have been started before the daemon, more than 14 days ago, or on another machine.` };
7859
8025
  }
8026
+ const orphans = findSessionWrapperPids(tracked.happySessionMetadataFromLocalWebhook, await findAllHappyProcesses(), { excludePid: process.pid, lockPid: readSessionLock(happySessionId)?.pid }).filter((pid) => isPidAlive(pid) && !pidToTrackedSession.has(pid));
8027
+ if (orphans.length > 0) {
8028
+ for (const pid of orphans) {
8029
+ pidToTrackedSession.set(pid, { ...tracked, pid, startedBy: "adopted untracked wrapper" });
8030
+ }
8031
+ persistence.logger.debug(`[DAEMON RUN] resume ${happySessionId}: adopted untracked live wrapper(s) ${orphans.join(", ")} \u2014 idempotent success`);
8032
+ return { type: "success", sessionId: happySessionId };
8033
+ }
7860
8034
  if (!tracked.happySessionMetadataFromLocalWebhook) {
7861
8035
  return { type: "error", errorMessage: `resume-precheck:no-metadata: Session ${happySessionId} has no metadata. Cannot resume.` };
7862
8036
  }
@@ -7904,15 +8078,7 @@ async function startDaemon() {
7904
8078
  }
7905
8079
  });
7906
8080
  if (result.type === "success") {
7907
- persistence.persistSession(happySessionId, {
7908
- encryptionKey: persistence.encodeBase64(tracked.encryption.encryptionKey),
7909
- encryptionVariant: tracked.encryption.encryptionVariant,
7910
- seq: tracked.encryption.seq,
7911
- metadataVersion: tracked.encryption.metadataVersion,
7912
- agentStateVersion: tracked.encryption.agentStateVersion,
7913
- metadata,
7914
- savedAt: Date.now()
7915
- });
8081
+ persistRestoreRecord(happySessionId, tracked, metadata);
7916
8082
  }
7917
8083
  return result;
7918
8084
  } catch (error) {
@@ -7925,17 +8091,18 @@ async function startDaemon() {
7925
8091
  }
7926
8092
  };
7927
8093
  const restartCounts = /* @__PURE__ */ new Map();
7928
- const stopSessionAndWait = (happySessionId, timeoutMs = 8e3) => {
7929
- let targetPid = null;
7930
- for (const [pid2, s] of pidToTrackedSession.entries()) {
7931
- if (s.happySessionId === happySessionId && isPidAlive(pid2)) {
7932
- targetPid = pid2;
7933
- break;
7934
- }
7935
- }
7936
- if (targetPid === null) return Promise.resolve();
7937
- const pid = targetPid;
7938
- return new Promise((resolve) => {
8094
+ const stopSessionAndWait = async (happySessionId, timeoutMs = 8e3) => {
8095
+ const targets = /* @__PURE__ */ new Set();
8096
+ for (const [pid, s] of pidToTrackedSession.entries()) {
8097
+ if (s.happySessionId === happySessionId && isPidAlive(pid)) targets.add(pid);
8098
+ }
8099
+ const known = findTrackedSessionById(happySessionId)?.happySessionMetadataFromLocalWebhook;
8100
+ for (const pid of findSessionWrapperPids(known, await findAllHappyProcesses(), { excludePid: process.pid, lockPid: readSessionLock(happySessionId)?.pid })) {
8101
+ if (isPidAlive(pid)) targets.add(pid);
8102
+ }
8103
+ if (targets.size === 0) return;
8104
+ persistence.logger.debug(`[DAEMON RUN] restart ${happySessionId}: stopping live wrapper(s) ${[...targets].join(", ")}`);
8105
+ await Promise.all([...targets].map((pid) => new Promise((resolve) => {
7939
8106
  let settled = false;
7940
8107
  const done = () => {
7941
8108
  if (!settled) {
@@ -7955,7 +8122,7 @@ async function startDaemon() {
7955
8122
  });
7956
8123
  if (!requested) done();
7957
8124
  setTimeout(done, timeoutMs).unref?.();
7958
- });
8125
+ })));
7959
8126
  };
7960
8127
  const restartSession = async (happySessionId, options) => {
7961
8128
  let gate = resumeGates.get(happySessionId);
@@ -8037,15 +8204,7 @@ async function startDaemon() {
8037
8204
  }
8038
8205
  });
8039
8206
  if (result.type === "success") {
8040
- persistence.persistSession(happySessionId, {
8041
- encryptionKey: persistence.encodeBase64(tracked.encryption.encryptionKey),
8042
- encryptionVariant: tracked.encryption.encryptionVariant,
8043
- seq: tracked.encryption.seq,
8044
- metadataVersion: tracked.encryption.metadataVersion,
8045
- agentStateVersion: tracked.encryption.agentStateVersion,
8046
- metadata,
8047
- savedAt: Date.now()
8048
- });
8207
+ persistRestoreRecord(happySessionId, tracked, metadata);
8049
8208
  }
8050
8209
  return result;
8051
8210
  } catch (error) {
@@ -9277,7 +9436,7 @@ const MAX_TITLE_CHARS = 60;
9277
9436
  const GENERATION_TIMEOUT_MS = 3e4;
9278
9437
  function resolveClaudeBinary() {
9279
9438
  try {
9280
- 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-bqUSeHWU.cjs', document.baseURI).href)));
9439
+ 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-uc-dtu-3.cjs', document.baseURI).href)));
9281
9440
  const utilsPath = path.resolve(path.join(persistence.projectPath(), "scripts", "claude_version_utils.cjs"));
9282
9441
  const { getClaudeCliPath } = require$1(utilsPath);
9283
9442
  const path$1 = getClaudeCliPath();
@@ -9814,6 +9973,7 @@ async function runClaude(credentials, options = {}) {
9814
9973
  process.exit(0);
9815
9974
  }
9816
9975
  persistence.logger.debug(`Session created: ${response.id}`);
9976
+ await claimSessionOrExit(response.id, { takeover: !!reconnectSessionId, flavor: "claude" });
9817
9977
  if (reconnectSessionId && !await api.reactivateSession(response.id)) {
9818
9978
  throw new Error(`Failed to reactivate archived session ${response.id}`);
9819
9979
  }
@@ -11471,9 +11631,9 @@ function resolveLocalSignupBootstrap(configuredMode, configuredInviteCodes, gene
11471
11631
  };
11472
11632
  }
11473
11633
 
11474
- 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-bqUSeHWU.cjs', document.baseURI).href)));
11634
+ 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-uc-dtu-3.cjs', document.baseURI).href)));
11475
11635
  const __dirname$1 = path.dirname(__filename$1);
11476
- const require_ = node_module.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('index-bqUSeHWU.cjs', document.baseURI).href)));
11636
+ const require_ = node_module.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('index-uc-dtu-3.cjs', document.baseURI).href)));
11477
11637
  const PRISMA_QUERY_ENGINE_FILES = {
11478
11638
  "arm64-darwin": "libquery_engine-darwin-arm64.dylib.node",
11479
11639
  "x64-darwin": "libquery_engine-darwin.dylib.node",
@@ -13328,6 +13488,9 @@ async function runCodex(opts) {
13328
13488
  } else {
13329
13489
  response = await api.getOrCreateSession({ tag: sessionTag, metadata, state });
13330
13490
  }
13491
+ if (response) {
13492
+ await claimSessionOrExit(response.id, { takeover: !!reconnectSessionId, flavor: "codex" });
13493
+ }
13331
13494
  if (reconnectSessionId && response && !await api.reactivateSession(response.id)) {
13332
13495
  throw new Error(`Failed to reactivate archived session ${response.id}`);
13333
13496
  }
@@ -14094,7 +14257,7 @@ Conversation history is preserved on the server, but in-flight tool calls are in
14094
14257
  process.exit(0);
14095
14258
  } else if (subcommand === "install-terminal-hooks") {
14096
14259
  try {
14097
- const { installTerminalHooks, parseTerminalHooksArgs, TERMINAL_HOOKS_HELP } = await Promise.resolve().then(function () { return require('./installTerminalHooks-D0gCqzZu.cjs'); });
14260
+ const { installTerminalHooks, parseTerminalHooksArgs, TERMINAL_HOOKS_HELP } = await Promise.resolve().then(function () { return require('./installTerminalHooks-CepXxAM_.cjs'); });
14098
14261
  const command = parseTerminalHooksArgs(args.slice(1));
14099
14262
  if (command.action === "help") {
14100
14263
  console.log(TERMINAL_HOOKS_HELP);
@@ -14111,7 +14274,7 @@ Conversation history is preserved on the server, but in-flight tool calls are in
14111
14274
  }
14112
14275
  } else if (subcommand === "spawn") {
14113
14276
  try {
14114
- const { handleSpawnCommand } = await Promise.resolve().then(function () { return require('./spawn-C7QRBKkQ.cjs'); });
14277
+ const { handleSpawnCommand } = await Promise.resolve().then(function () { return require('./spawn-vOZA0kOi.cjs'); });
14115
14278
  await handleSpawnCommand(args.slice(1));
14116
14279
  } catch (error) {
14117
14280
  console.error(chalk.red("Error:"), error instanceof Error ? error.message : "Unknown error");
@@ -14123,7 +14286,7 @@ Conversation history is preserved on the server, but in-flight tool calls are in
14123
14286
  return;
14124
14287
  } else if (subcommand === "send") {
14125
14288
  try {
14126
- const { handleSendCommand } = await Promise.resolve().then(function () { return require('./send-DoFm4-OB.cjs'); });
14289
+ const { handleSendCommand } = await Promise.resolve().then(function () { return require('./send-6eY55o3C.cjs'); });
14127
14290
  await handleSendCommand(args.slice(1));
14128
14291
  } catch (error) {
14129
14292
  console.error(chalk.red("Error:"), error instanceof Error ? error.message : "Unknown error");
@@ -14229,9 +14392,9 @@ Conversation history is preserved on the server, but in-flight tool calls are in
14229
14392
  if (geminiSubcommand === "project" && args[2] === "set" && args[3]) {
14230
14393
  const projectId = args[3];
14231
14394
  try {
14232
- const { saveGoogleCloudProjectToConfig } = await Promise.resolve().then(function () { return require('./config-IdMPfmwy.cjs'); });
14233
- const { readCredentialsForConfiguredRelay: readCredentialsForConfiguredRelay2 } = await Promise.resolve().then(function () { return require('./types-CcaZTXxx.cjs'); }).then(function (n) { return n.persistence; });
14234
- const { ApiClient: ApiClient2 } = await Promise.resolve().then(function () { return require('./types-CcaZTXxx.cjs'); }).then(function (n) { return n.api; });
14395
+ const { saveGoogleCloudProjectToConfig } = await Promise.resolve().then(function () { return require('./config-BjsUeQPA.cjs'); });
14396
+ const { readCredentialsForConfiguredRelay: readCredentialsForConfiguredRelay2 } = await Promise.resolve().then(function () { return require('./types-okYCRlgl.cjs'); }).then(function (n) { return n.persistence; });
14397
+ const { ApiClient: ApiClient2 } = await Promise.resolve().then(function () { return require('./types-okYCRlgl.cjs'); }).then(function (n) { return n.api; });
14235
14398
  let userEmail = void 0;
14236
14399
  try {
14237
14400
  const credentials = await readCredentialsForConfiguredRelay2();
@@ -14262,7 +14425,7 @@ Conversation history is preserved on the server, but in-flight tool calls are in
14262
14425
  }
14263
14426
  if (geminiSubcommand === "project" && args[2] === "get") {
14264
14427
  try {
14265
- const { readGeminiLocalConfig } = await Promise.resolve().then(function () { return require('./config-IdMPfmwy.cjs'); });
14428
+ const { readGeminiLocalConfig } = await Promise.resolve().then(function () { return require('./config-BjsUeQPA.cjs'); });
14266
14429
  const config = readGeminiLocalConfig();
14267
14430
  if (config.googleCloudProject) {
14268
14431
  console.log(`Current Google Cloud Project: ${config.googleCloudProject}`);
@@ -14302,7 +14465,7 @@ Conversation history is preserved on the server, but in-flight tool calls are in
14302
14465
  process.exit(0);
14303
14466
  }
14304
14467
  try {
14305
- const { runGemini } = await Promise.resolve().then(function () { return require('./runGemini-BoVDs_V6.cjs'); });
14468
+ const { runGemini } = await Promise.resolve().then(function () { return require('./runGemini-qStPY5fH.cjs'); });
14306
14469
  let startedBy = void 0;
14307
14470
  for (let i = 1; i < args.length; i++) {
14308
14471
  if (args[i] === "--started-by") {
@@ -14324,7 +14487,7 @@ Conversation history is preserved on the server, but in-flight tool calls are in
14324
14487
  return;
14325
14488
  } else if (subcommand === "acp") {
14326
14489
  try {
14327
- const { runAcp, resolveAcpAgentConfig } = await Promise.resolve().then(function () { return require('./index-BfCdbWQI.cjs'); });
14490
+ const { runAcp, resolveAcpAgentConfig } = await Promise.resolve().then(function () { return require('./index-DID1FV_n.cjs'); });
14328
14491
  let startedBy = void 0;
14329
14492
  let verbose = false;
14330
14493
  const acpArgs = [];
@@ -14364,7 +14527,7 @@ Conversation history is preserved on the server, but in-flight tool calls are in
14364
14527
  return;
14365
14528
  } else if (subcommand === "openclaw") {
14366
14529
  try {
14367
- const { runOpenClaw } = await Promise.resolve().then(function () { return require('./runOpenClaw-Cdsug1sI.cjs'); });
14530
+ const { runOpenClaw } = await Promise.resolve().then(function () { return require('./runOpenClaw-B8HR6GnX.cjs'); });
14368
14531
  let startedBy = void 0;
14369
14532
  let verbose = false;
14370
14533
  let gatewayUrl;
@@ -14415,7 +14578,7 @@ Conversation history is preserved on the server, but in-flight tool calls are in
14415
14578
  return;
14416
14579
  } else if (subcommand === "mcp" && args.length === 1) {
14417
14580
  try {
14418
- const { handleMcpCommand } = await Promise.resolve().then(function () { return require('./mcp-CRcmpUpX.cjs'); });
14581
+ const { handleMcpCommand } = await Promise.resolve().then(function () { return require('./mcp-CAtbtTXF.cjs'); });
14419
14582
  await handleMcpCommand();
14420
14583
  } catch (error) {
14421
14584
  process.stderr.write(`[very-happy mcp] Fatal: ${error instanceof Error ? error.message : String(error)}
package/dist/index.cjs CHANGED
@@ -1,8 +1,8 @@
1
1
  'use strict';
2
2
 
3
3
  require('chalk');
4
- require('./index-bqUSeHWU.cjs');
5
- require('./types-CcaZTXxx.cjs');
4
+ require('./index-uc-dtu-3.cjs');
5
+ require('./types-okYCRlgl.cjs');
6
6
  require('zod');
7
7
  require('node:child_process');
8
8
  require('node:os');
package/dist/index.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  import 'chalk';
2
- import './index-27948eGz.mjs';
3
- import './types-CSOwbjq5.mjs';
2
+ import './index-BMmbxCTq.mjs';
3
+ import './types-CLRl0ET3.mjs';
4
4
  import 'zod';
5
5
  import 'node:child_process';
6
6
  import 'node:os';
@@ -3,8 +3,8 @@ import { join, resolve } from 'node:path';
3
3
  import { homedir } from 'node:os';
4
4
  import { spawnSync } from 'node:child_process';
5
5
  import chalk from 'chalk';
6
- import { p as projectPath } from './types-CSOwbjq5.mjs';
7
- import { t as tmuxSupportsSessionEnv } from './index-27948eGz.mjs';
6
+ import { p as projectPath } from './types-CLRl0ET3.mjs';
7
+ import { t as tmuxSupportsSessionEnv } from './index-BMmbxCTq.mjs';
8
8
  import 'axios';
9
9
  import 'node:util';
10
10
  import 'node:fs/promises';
@@ -5,8 +5,8 @@ var path = require('node:path');
5
5
  var os = require('node:os');
6
6
  var node_child_process = require('node:child_process');
7
7
  var chalk = require('chalk');
8
- var persistence = require('./types-CcaZTXxx.cjs');
9
- var index = require('./index-bqUSeHWU.cjs');
8
+ var persistence = require('./types-okYCRlgl.cjs');
9
+ var index = require('./index-uc-dtu-3.cjs');
10
10
  require('axios');
11
11
  require('node:util');
12
12
  require('node:fs/promises');
package/dist/lib.cjs CHANGED
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var persistence = require('./types-CcaZTXxx.cjs');
3
+ var persistence = require('./types-okYCRlgl.cjs');
4
4
  require('axios');
5
5
  require('chalk');
6
6
  require('node:util');
package/dist/lib.mjs CHANGED
@@ -1,4 +1,4 @@
1
- export { A as ApiClient, a as ApiSessionClient, R as RawJSONLinesSchema, c as configuration, l as logger } from './types-CSOwbjq5.mjs';
1
+ export { A as ApiClient, a as ApiSessionClient, R as RawJSONLinesSchema, c as configuration, l as logger } from './types-CLRl0ET3.mjs';
2
2
  import 'axios';
3
3
  import 'chalk';
4
4
  import 'node:util';
@@ -1,9 +1,9 @@
1
1
  import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
2
2
  import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
3
3
  import { z } from 'zod';
4
- import { p as pushClipboardViaDaemon } from './index-27948eGz.mjs';
4
+ import { p as pushClipboardViaDaemon } from './index-BMmbxCTq.mjs';
5
5
  import { C as CLIPBOARD_TOOL_NAME, a as CLIPBOARD_TOOL_TITLE, b as CLIPBOARD_TOOL_DESCRIPTION, c as CLIPBOARD_MAX_BYTES } from './limits-CwFb5S2b.mjs';
6
- import { l as logger } from './types-CSOwbjq5.mjs';
6
+ import { l as logger } from './types-CLRl0ET3.mjs';
7
7
  import 'chalk';
8
8
  import 'node:os';
9
9
  import 'node:crypto';
@@ -3,9 +3,9 @@
3
3
  var mcp_js = require('@modelcontextprotocol/sdk/server/mcp.js');
4
4
  var stdio_js = require('@modelcontextprotocol/sdk/server/stdio.js');
5
5
  var z = require('zod');
6
- var index = require('./index-bqUSeHWU.cjs');
6
+ var index = require('./index-uc-dtu-3.cjs');
7
7
  var limits = require('./limits-KdWKmwtH.cjs');
8
- var persistence = require('./types-CcaZTXxx.cjs');
8
+ var persistence = require('./types-okYCRlgl.cjs');
9
9
  require('chalk');
10
10
  require('node:os');
11
11
  require('node:crypto');
@@ -2,10 +2,10 @@ import { useStdout, useInput, Box, Text, render } from 'ink';
2
2
  import React, { useState, useRef, useEffect, useCallback } from 'react';
3
3
  import { randomUUID } from 'node:crypto';
4
4
  import { join } from 'node:path';
5
- import { l as logger, h as connectionState, A as ApiClient, i as readSettings, e as errorLogMetadata, j as encodeBase64, p as projectPath, d as contentLogMetadata } from './types-CSOwbjq5.mjs';
6
- import { g as GEMINI_API_KEY_ENV, j as GOOGLE_API_KEY_ENV, G as GEMINI_MODEL_ENV, B as BasePermissionHandler, k as BaseReasoningProcessor, i as initialMachineMetadata, d as createSessionMetadata, e as setupOfflineReconnection, n as notifyDaemonSessionStarted, M as MessageQueue2, h as hashObject, l as MessageBuffer, C as CHANGE_TITLE_INSTRUCTION, r as registerKillSessionHandler, f as startHappyServer } from './index-27948eGz.mjs';
7
- import { A as AcpBackend } from './AcpBackend-Ds4mP02F.mjs';
8
- import { readGeminiLocalConfig, determineGeminiModel, getGeminiModelSource, getInitialGeminiModel, saveGeminiModelToConfig } from './config-yrZNEia7.mjs';
5
+ import { l as logger, h as connectionState, A as ApiClient, i as readSettings, e as errorLogMetadata, j as encodeBase64, p as projectPath, d as contentLogMetadata } from './types-CLRl0ET3.mjs';
6
+ import { g as GEMINI_API_KEY_ENV, j as GOOGLE_API_KEY_ENV, G as GEMINI_MODEL_ENV, B as BasePermissionHandler, k as BaseReasoningProcessor, i as initialMachineMetadata, d as createSessionMetadata, e as setupOfflineReconnection, n as notifyDaemonSessionStarted, M as MessageQueue2, h as hashObject, l as MessageBuffer, C as CHANGE_TITLE_INSTRUCTION, r as registerKillSessionHandler, f as startHappyServer } from './index-BMmbxCTq.mjs';
7
+ import { A as AcpBackend } from './AcpBackend-B5Eh8G3W.mjs';
8
+ import { readGeminiLocalConfig, determineGeminiModel, getGeminiModelSource, getInitialGeminiModel, saveGeminiModelToConfig } from './config-B69TZlJj.mjs';
9
9
  import 'axios';
10
10
  import 'chalk';
11
11
  import 'node:util';
@@ -4,10 +4,10 @@ var ink = require('ink');
4
4
  var React = require('react');
5
5
  var node_crypto = require('node:crypto');
6
6
  var path = require('node:path');
7
- var persistence = require('./types-CcaZTXxx.cjs');
8
- var index = require('./index-bqUSeHWU.cjs');
9
- var AcpBackend = require('./AcpBackend-DoSXb9La.cjs');
10
- var config = require('./config-IdMPfmwy.cjs');
7
+ var persistence = require('./types-okYCRlgl.cjs');
8
+ var index = require('./index-uc-dtu-3.cjs');
9
+ var AcpBackend = require('./AcpBackend-BaCt4_zS.cjs');
10
+ var config = require('./config-BjsUeQPA.cjs');
11
11
  require('axios');
12
12
  require('chalk');
13
13
  require('node:util');
@@ -5,9 +5,9 @@ var node_child_process = require('node:child_process');
5
5
  var os = require('node:os');
6
6
  var node_fs = require('node:fs');
7
7
  var path = require('node:path');
8
- var persistence = require('./types-CcaZTXxx.cjs');
9
- var AcpSessionManager = require('./AcpSessionManager-DQ6j5fp4.cjs');
10
- var index = require('./index-bqUSeHWU.cjs');
8
+ var persistence = require('./types-okYCRlgl.cjs');
9
+ var AcpSessionManager = require('./AcpSessionManager-CvgmPlXB.cjs');
10
+ var index = require('./index-uc-dtu-3.cjs');
11
11
  var WebSocket = require('ws');
12
12
  var ed = require('@noble/ed25519');
13
13
  var sha2_js = require('@noble/hashes/sha2.js');
@@ -3,9 +3,9 @@ import { execFileSync } from 'node:child_process';
3
3
  import os from 'node:os';
4
4
  import { existsSync, readFileSync } from 'node:fs';
5
5
  import { join } from 'node:path';
6
- import { k as ensurePrivateDirectorySync, m as hardenPrivateFileSync, w as writePrivateFileSync, e as errorLogMetadata, d as contentLogMetadata, h as connectionState, A as ApiClient, i as readSettings, j as encodeBase64, l as logger, c as configuration } from './types-CSOwbjq5.mjs';
7
- import { A as AcpSessionManager } from './AcpSessionManager-B6RqjyQS.mjs';
8
- import { i as initialMachineMetadata, d as createSessionMetadata, e as setupOfflineReconnection, n as notifyDaemonSessionStarted, M as MessageQueue2, r as registerKillSessionHandler } from './index-27948eGz.mjs';
6
+ import { k as ensurePrivateDirectorySync, m as hardenPrivateFileSync, w as writePrivateFileSync, e as errorLogMetadata, d as contentLogMetadata, h as connectionState, A as ApiClient, i as readSettings, j as encodeBase64, l as logger, c as configuration } from './types-CLRl0ET3.mjs';
7
+ import { A as AcpSessionManager } from './AcpSessionManager-grr_aJEI.mjs';
8
+ import { i as initialMachineMetadata, d as createSessionMetadata, e as setupOfflineReconnection, n as notifyDaemonSessionStarted, M as MessageQueue2, r as registerKillSessionHandler } from './index-BMmbxCTq.mjs';
9
9
  import WebSocket from 'ws';
10
10
  import * as ed from '@noble/ed25519';
11
11
  import { sha512 } from '@noble/hashes/sha2.js';
@@ -3,8 +3,8 @@
3
3
  var chalk = require('chalk');
4
4
  var node_fs = require('node:fs');
5
5
  var path = require('node:path');
6
- var persistence = require('./types-CcaZTXxx.cjs');
7
- var index = require('./index-bqUSeHWU.cjs');
6
+ var persistence = require('./types-okYCRlgl.cjs');
7
+ var index = require('./index-uc-dtu-3.cjs');
8
8
  require('axios');
9
9
  require('node:util');
10
10
  require('node:os');
@@ -1,8 +1,8 @@
1
1
  import chalk from 'chalk';
2
2
  import { readFileSync } from 'node:fs';
3
3
  import { resolve } from 'node:path';
4
- import { r as readPersistedSessions, c as configuration } from './types-CSOwbjq5.mjs';
5
- import { b as sendUserMessage, a as sessionWebUrl } from './index-27948eGz.mjs';
4
+ import { r as readPersistedSessions, c as configuration } from './types-CLRl0ET3.mjs';
5
+ import { b as sendUserMessage, a as sessionWebUrl } from './index-BMmbxCTq.mjs';
6
6
  import 'axios';
7
7
  import 'node:util';
8
8
  import 'node:os';
@@ -1,8 +1,8 @@
1
1
  import chalk from 'chalk';
2
2
  import { readFileSync, statSync } from 'node:fs';
3
3
  import { resolve } from 'node:path';
4
- import { c as checkIfDaemonRunningAndCleanupStaleState, s as spawnDaemonSession, a as sessionWebUrl, w as waitForSessionKey, b as sendUserMessage } from './index-27948eGz.mjs';
5
- import { l as logger } from './types-CSOwbjq5.mjs';
4
+ import { c as checkIfDaemonRunningAndCleanupStaleState, s as spawnDaemonSession, a as sessionWebUrl, w as waitForSessionKey, b as sendUserMessage } from './index-BMmbxCTq.mjs';
5
+ import { l as logger } from './types-CLRl0ET3.mjs';
6
6
  import 'node:os';
7
7
  import 'node:crypto';
8
8
  import 'cross-spawn';
@@ -3,8 +3,8 @@
3
3
  var chalk = require('chalk');
4
4
  var node_fs = require('node:fs');
5
5
  var path = require('node:path');
6
- var index = require('./index-bqUSeHWU.cjs');
7
- var persistence = require('./types-CcaZTXxx.cjs');
6
+ var index = require('./index-uc-dtu-3.cjs');
7
+ var persistence = require('./types-okYCRlgl.cjs');
8
8
  require('node:os');
9
9
  require('node:crypto');
10
10
  require('cross-spawn');