@askexenow/exe-os 0.9.113 → 0.9.114

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 (79) hide show
  1. package/dist/bin/agentic-ontology-backfill.js +24 -12
  2. package/dist/bin/agentic-reflection-backfill.js +24 -12
  3. package/dist/bin/agentic-semantic-label.js +24 -12
  4. package/dist/bin/backfill-conversations.js +24 -12
  5. package/dist/bin/backfill-responses.js +24 -12
  6. package/dist/bin/backfill-vectors.js +24 -12
  7. package/dist/bin/bulk-sync-postgres.js +24 -12
  8. package/dist/bin/cleanup-stale-review-tasks.js +24 -12
  9. package/dist/bin/cli.js +96 -22
  10. package/dist/bin/exe-agent.js +27 -0
  11. package/dist/bin/exe-assign.js +24 -12
  12. package/dist/bin/exe-boot.js +44 -15
  13. package/dist/bin/exe-call.js +8 -0
  14. package/dist/bin/exe-cloud.js +34 -11
  15. package/dist/bin/exe-dispatch.js +34 -16
  16. package/dist/bin/exe-doctor.js +24 -12
  17. package/dist/bin/exe-export-behaviors.js +24 -12
  18. package/dist/bin/exe-forget.js +24 -12
  19. package/dist/bin/exe-gateway.js +33 -15
  20. package/dist/bin/exe-heartbeat.js +24 -12
  21. package/dist/bin/exe-kill.js +24 -12
  22. package/dist/bin/exe-launch-agent.js +103 -17
  23. package/dist/bin/exe-new-employee.js +9 -1
  24. package/dist/bin/exe-pending-messages.js +24 -12
  25. package/dist/bin/exe-pending-notifications.js +24 -12
  26. package/dist/bin/exe-pending-reviews.js +24 -12
  27. package/dist/bin/exe-rename.js +24 -12
  28. package/dist/bin/exe-review.js +24 -12
  29. package/dist/bin/exe-search.js +24 -12
  30. package/dist/bin/exe-session-cleanup.js +33 -15
  31. package/dist/bin/exe-start-codex.js +33 -13
  32. package/dist/bin/exe-start-opencode.js +33 -13
  33. package/dist/bin/exe-status.js +24 -12
  34. package/dist/bin/exe-team.js +24 -12
  35. package/dist/bin/git-sweep.js +34 -16
  36. package/dist/bin/graph-backfill.js +24 -12
  37. package/dist/bin/graph-export.js +24 -12
  38. package/dist/bin/install.js +9 -1
  39. package/dist/bin/intercom-check.js +33 -15
  40. package/dist/bin/scan-tasks.js +34 -16
  41. package/dist/bin/setup.js +60 -11
  42. package/dist/bin/shard-migrate.js +24 -12
  43. package/dist/gateway/index.js +33 -15
  44. package/dist/hooks/bug-report-worker.js +33 -15
  45. package/dist/hooks/codex-stop-task-finalizer.js +32 -12
  46. package/dist/hooks/commit-complete.js +34 -16
  47. package/dist/hooks/error-recall.js +24 -12
  48. package/dist/hooks/ingest.js +33 -15
  49. package/dist/hooks/instructions-loaded.js +24 -12
  50. package/dist/hooks/notification.js +24 -12
  51. package/dist/hooks/post-compact.js +24 -12
  52. package/dist/hooks/post-tool-combined.js +24 -12
  53. package/dist/hooks/pre-compact.js +34 -16
  54. package/dist/hooks/pre-tool-use.js +58 -11
  55. package/dist/hooks/prompt-submit.js +33 -15
  56. package/dist/hooks/session-end.js +34 -16
  57. package/dist/hooks/session-start.js +32 -12
  58. package/dist/hooks/stop.js +24 -12
  59. package/dist/hooks/subagent-stop.js +24 -12
  60. package/dist/hooks/summary-worker.js +34 -11
  61. package/dist/index.js +60 -15
  62. package/dist/lib/agent-config.js +8 -0
  63. package/dist/lib/cloud-sync.js +34 -11
  64. package/dist/lib/consolidation.js +9 -1
  65. package/dist/lib/employees.js +8 -0
  66. package/dist/lib/exe-daemon.js +174 -17
  67. package/dist/lib/hybrid-search.js +24 -12
  68. package/dist/lib/keychain.js +24 -12
  69. package/dist/lib/schedules.js +24 -12
  70. package/dist/lib/skill-learning.js +8 -0
  71. package/dist/lib/store.js +24 -12
  72. package/dist/lib/tasks.js +10 -4
  73. package/dist/lib/tmux-routing.js +10 -4
  74. package/dist/mcp/server.js +44 -15
  75. package/dist/mcp/tools/create-task.js +10 -4
  76. package/dist/mcp/tools/update-task.js +10 -4
  77. package/dist/runtime/index.js +60 -15
  78. package/dist/tui/App.js +61 -16
  79. package/package.json +1 -1
@@ -660,6 +660,7 @@ __export(agent_config_exports, {
660
660
  clearAgentRuntime: () => clearAgentRuntime,
661
661
  getAgentRuntime: () => getAgentRuntime,
662
662
  loadAgentConfig: () => loadAgentConfig,
663
+ normalizeCcModelName: () => normalizeCcModelName,
663
664
  saveAgentConfig: () => saveAgentConfig,
664
665
  setAgentMcps: () => setAgentMcps,
665
666
  setAgentRuntime: () => setAgentRuntime
@@ -688,6 +689,13 @@ function getAgentRuntime(agentId) {
688
689
  if (orgDefault) return orgDefault;
689
690
  return { runtime: DEFAULT_RUNTIME, model: DEFAULT_MODELS[DEFAULT_RUNTIME] };
690
691
  }
692
+ function normalizeCcModelName(model) {
693
+ let ccModel = model.replace(/(\d+)\.(\d+)/g, "$1-$2");
694
+ if (/claude-(opus|sonnet)-4-[6-9]/.test(ccModel) && !ccModel.includes("[1m]")) {
695
+ ccModel += "[1m]";
696
+ }
697
+ return ccModel;
698
+ }
691
699
  function setAgentRuntime(agentId, runtime, model, reasoning_effort, mcps) {
692
700
  const knownModels = KNOWN_RUNTIMES[runtime];
693
701
  if (!knownModels) {
@@ -7806,10 +7814,8 @@ function spawnEmployee(employeeName2, exeSession2, projectDir2, opts) {
7806
7814
  }
7807
7815
  if (!useExeAgent && !useCodex && !useOpencode && !useBinSymlink) {
7808
7816
  if (agentRtConfig.runtime === "claude" && agentRtConfig.model) {
7809
- let ccModel = agentRtConfig.model.replace(/(\d+)\.(\d+)/g, "$1-$2");
7810
- if (/claude-(opus|sonnet)-4-[6-9]/.test(ccModel) && !ccModel.includes("[1m]")) {
7811
- ccModel += "[1m]";
7812
- }
7817
+ const { normalizeCcModelName: normalizeCcModelName2 } = (init_agent_config(), __toCommonJS(agent_config_exports));
7818
+ const ccModel = normalizeCcModelName2(agentRtConfig.model);
7813
7819
  envPrefix = `${envPrefix} ANTHROPIC_MODEL=${ccModel}`;
7814
7820
  }
7815
7821
  }
@@ -7941,7 +7947,7 @@ var init_tmux_routing = __esm({
7941
7947
  });
7942
7948
 
7943
7949
  // src/lib/keychain.ts
7944
- import { readFile as readFile4, writeFile as writeFile5, unlink, mkdir as mkdir4, chmod as chmod2 } from "fs/promises";
7950
+ import { readFile as readFile4, writeFile as writeFile5, unlink, mkdir as mkdir4, chmod as chmod2, rename, copyFile } from "fs/promises";
7945
7951
  import { existsSync as existsSync17, statSync as statSync3 } from "fs";
7946
7952
  import { execSync as execSync8 } from "child_process";
7947
7953
  import path19 from "path";
@@ -7976,12 +7982,14 @@ function linuxSecretAvailable() {
7976
7982
  function isRootOnlyTrustedServerKeyFile(keyPath) {
7977
7983
  if (process.platform !== "linux") return false;
7978
7984
  try {
7979
- const uid = typeof os12.userInfo().uid === "number" ? os12.userInfo().uid : -1;
7980
7985
  const st = statSync3(keyPath);
7981
7986
  if (!st.isFile() || (st.mode & 63) !== 0) return false;
7987
+ const uid = typeof os12.userInfo().uid === "number" ? os12.userInfo().uid : -1;
7982
7988
  if (uid === 0) return true;
7983
7989
  const exeOsDir = process.env.EXE_OS_DIR;
7984
- return Boolean(exeOsDir && path19.resolve(keyPath).startsWith(path19.resolve(exeOsDir) + path19.sep));
7990
+ if (exeOsDir && path19.resolve(keyPath).startsWith(path19.resolve(exeOsDir) + path19.sep)) return true;
7991
+ if (!linuxSecretAvailable()) return true;
7992
+ return false;
7985
7993
  } catch {
7986
7994
  return false;
7987
7995
  }
@@ -8131,15 +8139,25 @@ async function writeMachineBoundFileFallback(b64) {
8131
8139
  await mkdir4(dir, { recursive: true });
8132
8140
  const keyPath = getKeyPath();
8133
8141
  const machineKey = deriveMachineKey();
8134
- if (machineKey) {
8135
- const encrypted = encryptWithMachineKey(b64, machineKey);
8136
- await writeFile5(keyPath, encrypted + "\n", "utf-8");
8137
- await chmod2(keyPath, 384);
8138
- return "encrypted";
8139
- }
8140
- await writeFile5(keyPath, b64 + "\n", "utf-8");
8141
- await chmod2(keyPath, 384);
8142
- return "plaintext";
8142
+ const content = machineKey ? encryptWithMachineKey(b64, machineKey) + "\n" : b64 + "\n";
8143
+ const result2 = machineKey ? "encrypted" : "plaintext";
8144
+ const tmpPath = keyPath + ".tmp";
8145
+ try {
8146
+ if (existsSync17(keyPath)) {
8147
+ await copyFile(keyPath, keyPath + ".bak").catch(() => {
8148
+ });
8149
+ }
8150
+ await writeFile5(tmpPath, content, "utf-8");
8151
+ await chmod2(tmpPath, 384);
8152
+ await rename(tmpPath, keyPath);
8153
+ } catch (err) {
8154
+ try {
8155
+ await unlink(tmpPath);
8156
+ } catch {
8157
+ }
8158
+ throw err;
8159
+ }
8160
+ return result2;
8143
8161
  }
8144
8162
  async function getMasterKey() {
8145
8163
  let nativeValue = macKeychainGet() ?? linuxSecretGet();
@@ -729,7 +729,7 @@ __export(keychain_exports, {
729
729
  importMnemonic: () => importMnemonic,
730
730
  setMasterKey: () => setMasterKey
731
731
  });
732
- import { readFile as readFile2, writeFile as writeFile2, unlink, mkdir as mkdir2, chmod as chmod2 } from "fs/promises";
732
+ import { readFile as readFile2, writeFile as writeFile2, unlink, mkdir as mkdir2, chmod as chmod2, rename, copyFile } from "fs/promises";
733
733
  import { existsSync as existsSync4, statSync as statSync2 } from "fs";
734
734
  import { execSync } from "child_process";
735
735
  import path3 from "path";
@@ -764,12 +764,14 @@ function linuxSecretAvailable() {
764
764
  function isRootOnlyTrustedServerKeyFile(keyPath) {
765
765
  if (process.platform !== "linux") return false;
766
766
  try {
767
- const uid = typeof os2.userInfo().uid === "number" ? os2.userInfo().uid : -1;
768
767
  const st = statSync2(keyPath);
769
768
  if (!st.isFile() || (st.mode & 63) !== 0) return false;
769
+ const uid = typeof os2.userInfo().uid === "number" ? os2.userInfo().uid : -1;
770
770
  if (uid === 0) return true;
771
771
  const exeOsDir = process.env.EXE_OS_DIR;
772
- return Boolean(exeOsDir && path3.resolve(keyPath).startsWith(path3.resolve(exeOsDir) + path3.sep));
772
+ if (exeOsDir && path3.resolve(keyPath).startsWith(path3.resolve(exeOsDir) + path3.sep)) return true;
773
+ if (!linuxSecretAvailable()) return true;
774
+ return false;
773
775
  } catch {
774
776
  return false;
775
777
  }
@@ -919,15 +921,25 @@ async function writeMachineBoundFileFallback(b64) {
919
921
  await mkdir2(dir, { recursive: true });
920
922
  const keyPath = getKeyPath();
921
923
  const machineKey = deriveMachineKey();
922
- if (machineKey) {
923
- const encrypted = encryptWithMachineKey(b64, machineKey);
924
- await writeFile2(keyPath, encrypted + "\n", "utf-8");
925
- await chmod2(keyPath, 384);
926
- return "encrypted";
927
- }
928
- await writeFile2(keyPath, b64 + "\n", "utf-8");
929
- await chmod2(keyPath, 384);
930
- return "plaintext";
924
+ const content = machineKey ? encryptWithMachineKey(b64, machineKey) + "\n" : b64 + "\n";
925
+ const result = machineKey ? "encrypted" : "plaintext";
926
+ const tmpPath = keyPath + ".tmp";
927
+ try {
928
+ if (existsSync4(keyPath)) {
929
+ await copyFile(keyPath, keyPath + ".bak").catch(() => {
930
+ });
931
+ }
932
+ await writeFile2(tmpPath, content, "utf-8");
933
+ await chmod2(tmpPath, 384);
934
+ await rename(tmpPath, keyPath);
935
+ } catch (err) {
936
+ try {
937
+ await unlink(tmpPath);
938
+ } catch {
939
+ }
940
+ throw err;
941
+ }
942
+ return result;
931
943
  }
932
944
  async function getMasterKey() {
933
945
  let nativeValue = macKeychainGet() ?? linuxSecretGet();
@@ -3392,7 +3392,7 @@ var init_database = __esm({
3392
3392
  });
3393
3393
 
3394
3394
  // src/lib/keychain.ts
3395
- import { readFile as readFile3, writeFile as writeFile3, unlink, mkdir as mkdir3, chmod as chmod2 } from "fs/promises";
3395
+ import { readFile as readFile3, writeFile as writeFile3, unlink, mkdir as mkdir3, chmod as chmod2, rename, copyFile } from "fs/promises";
3396
3396
  import { existsSync as existsSync7, statSync as statSync3 } from "fs";
3397
3397
  import { execSync as execSync3 } from "child_process";
3398
3398
  import path6 from "path";
@@ -3427,12 +3427,14 @@ function linuxSecretAvailable() {
3427
3427
  function isRootOnlyTrustedServerKeyFile(keyPath) {
3428
3428
  if (process.platform !== "linux") return false;
3429
3429
  try {
3430
- const uid = typeof os5.userInfo().uid === "number" ? os5.userInfo().uid : -1;
3431
3430
  const st = statSync3(keyPath);
3432
3431
  if (!st.isFile() || (st.mode & 63) !== 0) return false;
3432
+ const uid = typeof os5.userInfo().uid === "number" ? os5.userInfo().uid : -1;
3433
3433
  if (uid === 0) return true;
3434
3434
  const exeOsDir = process.env.EXE_OS_DIR;
3435
- return Boolean(exeOsDir && path6.resolve(keyPath).startsWith(path6.resolve(exeOsDir) + path6.sep));
3435
+ if (exeOsDir && path6.resolve(keyPath).startsWith(path6.resolve(exeOsDir) + path6.sep)) return true;
3436
+ if (!linuxSecretAvailable()) return true;
3437
+ return false;
3436
3438
  } catch {
3437
3439
  return false;
3438
3440
  }
@@ -3582,15 +3584,25 @@ async function writeMachineBoundFileFallback(b64) {
3582
3584
  await mkdir3(dir, { recursive: true });
3583
3585
  const keyPath = getKeyPath();
3584
3586
  const machineKey = deriveMachineKey();
3585
- if (machineKey) {
3586
- const encrypted = encryptWithMachineKey(b64, machineKey);
3587
- await writeFile3(keyPath, encrypted + "\n", "utf-8");
3588
- await chmod2(keyPath, 384);
3589
- return "encrypted";
3590
- }
3591
- await writeFile3(keyPath, b64 + "\n", "utf-8");
3592
- await chmod2(keyPath, 384);
3593
- return "plaintext";
3587
+ const content = machineKey ? encryptWithMachineKey(b64, machineKey) + "\n" : b64 + "\n";
3588
+ const result = machineKey ? "encrypted" : "plaintext";
3589
+ const tmpPath = keyPath + ".tmp";
3590
+ try {
3591
+ if (existsSync7(keyPath)) {
3592
+ await copyFile(keyPath, keyPath + ".bak").catch(() => {
3593
+ });
3594
+ }
3595
+ await writeFile3(tmpPath, content, "utf-8");
3596
+ await chmod2(tmpPath, 384);
3597
+ await rename(tmpPath, keyPath);
3598
+ } catch (err) {
3599
+ try {
3600
+ await unlink(tmpPath);
3601
+ } catch {
3602
+ }
3603
+ throw err;
3604
+ }
3605
+ return result;
3594
3606
  }
3595
3607
  async function getMasterKey() {
3596
3608
  let nativeValue = macKeychainGet() ?? linuxSecretGet();
@@ -3316,7 +3316,7 @@ var init_database = __esm({
3316
3316
  });
3317
3317
 
3318
3318
  // src/lib/keychain.ts
3319
- import { readFile as readFile3, writeFile as writeFile3, unlink, mkdir as mkdir3, chmod as chmod2 } from "fs/promises";
3319
+ import { readFile as readFile3, writeFile as writeFile3, unlink, mkdir as mkdir3, chmod as chmod2, rename, copyFile } from "fs/promises";
3320
3320
  import { existsSync as existsSync7, statSync as statSync3 } from "fs";
3321
3321
  import { execSync as execSync3 } from "child_process";
3322
3322
  import path6 from "path";
@@ -3351,12 +3351,14 @@ function linuxSecretAvailable() {
3351
3351
  function isRootOnlyTrustedServerKeyFile(keyPath) {
3352
3352
  if (process.platform !== "linux") return false;
3353
3353
  try {
3354
- const uid = typeof os5.userInfo().uid === "number" ? os5.userInfo().uid : -1;
3355
3354
  const st = statSync3(keyPath);
3356
3355
  if (!st.isFile() || (st.mode & 63) !== 0) return false;
3356
+ const uid = typeof os5.userInfo().uid === "number" ? os5.userInfo().uid : -1;
3357
3357
  if (uid === 0) return true;
3358
3358
  const exeOsDir = process.env.EXE_OS_DIR;
3359
- return Boolean(exeOsDir && path6.resolve(keyPath).startsWith(path6.resolve(exeOsDir) + path6.sep));
3359
+ if (exeOsDir && path6.resolve(keyPath).startsWith(path6.resolve(exeOsDir) + path6.sep)) return true;
3360
+ if (!linuxSecretAvailable()) return true;
3361
+ return false;
3360
3362
  } catch {
3361
3363
  return false;
3362
3364
  }
@@ -3506,15 +3508,25 @@ async function writeMachineBoundFileFallback(b64) {
3506
3508
  await mkdir3(dir, { recursive: true });
3507
3509
  const keyPath = getKeyPath();
3508
3510
  const machineKey = deriveMachineKey();
3509
- if (machineKey) {
3510
- const encrypted = encryptWithMachineKey(b64, machineKey);
3511
- await writeFile3(keyPath, encrypted + "\n", "utf-8");
3512
- await chmod2(keyPath, 384);
3513
- return "encrypted";
3514
- }
3515
- await writeFile3(keyPath, b64 + "\n", "utf-8");
3516
- await chmod2(keyPath, 384);
3517
- return "plaintext";
3511
+ const content = machineKey ? encryptWithMachineKey(b64, machineKey) + "\n" : b64 + "\n";
3512
+ const result = machineKey ? "encrypted" : "plaintext";
3513
+ const tmpPath = keyPath + ".tmp";
3514
+ try {
3515
+ if (existsSync7(keyPath)) {
3516
+ await copyFile(keyPath, keyPath + ".bak").catch(() => {
3517
+ });
3518
+ }
3519
+ await writeFile3(tmpPath, content, "utf-8");
3520
+ await chmod2(tmpPath, 384);
3521
+ await rename(tmpPath, keyPath);
3522
+ } catch (err) {
3523
+ try {
3524
+ await unlink(tmpPath);
3525
+ } catch {
3526
+ }
3527
+ throw err;
3528
+ }
3529
+ return result;
3518
3530
  }
3519
3531
  async function getMasterKey() {
3520
3532
  let nativeValue = macKeychainGet() ?? linuxSecretGet();
@@ -749,6 +749,7 @@ __export(agent_config_exports, {
749
749
  clearAgentRuntime: () => clearAgentRuntime,
750
750
  getAgentRuntime: () => getAgentRuntime,
751
751
  loadAgentConfig: () => loadAgentConfig,
752
+ normalizeCcModelName: () => normalizeCcModelName,
752
753
  saveAgentConfig: () => saveAgentConfig,
753
754
  setAgentMcps: () => setAgentMcps,
754
755
  setAgentRuntime: () => setAgentRuntime
@@ -777,6 +778,13 @@ function getAgentRuntime(agentId) {
777
778
  if (orgDefault) return orgDefault;
778
779
  return { runtime: DEFAULT_RUNTIME, model: DEFAULT_MODELS[DEFAULT_RUNTIME] };
779
780
  }
781
+ function normalizeCcModelName(model) {
782
+ let ccModel = model.replace(/(\d+)\.(\d+)/g, "$1-$2");
783
+ if (/claude-(opus|sonnet)-4-[6-9]/.test(ccModel) && !ccModel.includes("[1m]")) {
784
+ ccModel += "[1m]";
785
+ }
786
+ return ccModel;
787
+ }
780
788
  function setAgentRuntime(agentId, runtime, model, reasoning_effort, mcps) {
781
789
  const knownModels = KNOWN_RUNTIMES[runtime];
782
790
  if (!knownModels) {
@@ -4070,7 +4078,7 @@ var init_embedder = __esm({
4070
4078
  });
4071
4079
 
4072
4080
  // src/lib/keychain.ts
4073
- import { readFile as readFile3, writeFile as writeFile3, unlink, mkdir as mkdir3, chmod as chmod2 } from "fs/promises";
4081
+ import { readFile as readFile3, writeFile as writeFile3, unlink, mkdir as mkdir3, chmod as chmod2, rename, copyFile } from "fs/promises";
4074
4082
  import { existsSync as existsSync8, statSync as statSync3 } from "fs";
4075
4083
  import { execSync as execSync3 } from "child_process";
4076
4084
  import path8 from "path";
@@ -4105,12 +4113,14 @@ function linuxSecretAvailable() {
4105
4113
  function isRootOnlyTrustedServerKeyFile(keyPath) {
4106
4114
  if (process.platform !== "linux") return false;
4107
4115
  try {
4108
- const uid = typeof os6.userInfo().uid === "number" ? os6.userInfo().uid : -1;
4109
4116
  const st = statSync3(keyPath);
4110
4117
  if (!st.isFile() || (st.mode & 63) !== 0) return false;
4118
+ const uid = typeof os6.userInfo().uid === "number" ? os6.userInfo().uid : -1;
4111
4119
  if (uid === 0) return true;
4112
4120
  const exeOsDir = process.env.EXE_OS_DIR;
4113
- return Boolean(exeOsDir && path8.resolve(keyPath).startsWith(path8.resolve(exeOsDir) + path8.sep));
4121
+ if (exeOsDir && path8.resolve(keyPath).startsWith(path8.resolve(exeOsDir) + path8.sep)) return true;
4122
+ if (!linuxSecretAvailable()) return true;
4123
+ return false;
4114
4124
  } catch {
4115
4125
  return false;
4116
4126
  }
@@ -4260,15 +4270,25 @@ async function writeMachineBoundFileFallback(b64) {
4260
4270
  await mkdir3(dir, { recursive: true });
4261
4271
  const keyPath = getKeyPath();
4262
4272
  const machineKey = deriveMachineKey();
4263
- if (machineKey) {
4264
- const encrypted = encryptWithMachineKey(b64, machineKey);
4265
- await writeFile3(keyPath, encrypted + "\n", "utf-8");
4266
- await chmod2(keyPath, 384);
4267
- return "encrypted";
4273
+ const content = machineKey ? encryptWithMachineKey(b64, machineKey) + "\n" : b64 + "\n";
4274
+ const result = machineKey ? "encrypted" : "plaintext";
4275
+ const tmpPath = keyPath + ".tmp";
4276
+ try {
4277
+ if (existsSync8(keyPath)) {
4278
+ await copyFile(keyPath, keyPath + ".bak").catch(() => {
4279
+ });
4280
+ }
4281
+ await writeFile3(tmpPath, content, "utf-8");
4282
+ await chmod2(tmpPath, 384);
4283
+ await rename(tmpPath, keyPath);
4284
+ } catch (err) {
4285
+ try {
4286
+ await unlink(tmpPath);
4287
+ } catch {
4288
+ }
4289
+ throw err;
4268
4290
  }
4269
- await writeFile3(keyPath, b64 + "\n", "utf-8");
4270
- await chmod2(keyPath, 384);
4271
- return "plaintext";
4291
+ return result;
4272
4292
  }
4273
4293
  async function getMasterKey() {
4274
4294
  let nativeValue = macKeychainGet() ?? linuxSecretGet();
@@ -13316,10 +13336,8 @@ function spawnEmployee(employeeName, exeSession, projectDir, opts) {
13316
13336
  }
13317
13337
  if (!useExeAgent && !useCodex && !useOpencode && !useBinSymlink) {
13318
13338
  if (agentRtConfig.runtime === "claude" && agentRtConfig.model) {
13319
- let ccModel = agentRtConfig.model.replace(/(\d+)\.(\d+)/g, "$1-$2");
13320
- if (/claude-(opus|sonnet)-4-[6-9]/.test(ccModel) && !ccModel.includes("[1m]")) {
13321
- ccModel += "[1m]";
13322
- }
13339
+ const { normalizeCcModelName: normalizeCcModelName2 } = (init_agent_config(), __toCommonJS(agent_config_exports));
13340
+ const ccModel = normalizeCcModelName2(agentRtConfig.model);
13323
13341
  envPrefix = `${envPrefix} ANTHROPIC_MODEL=${ccModel}`;
13324
13342
  }
13325
13343
  }
@@ -3355,7 +3355,7 @@ var init_database = __esm({
3355
3355
  });
3356
3356
 
3357
3357
  // src/lib/keychain.ts
3358
- import { readFile as readFile3, writeFile as writeFile3, unlink, mkdir as mkdir3, chmod as chmod2 } from "fs/promises";
3358
+ import { readFile as readFile3, writeFile as writeFile3, unlink, mkdir as mkdir3, chmod as chmod2, rename, copyFile } from "fs/promises";
3359
3359
  import { existsSync as existsSync7, statSync as statSync3 } from "fs";
3360
3360
  import { execSync as execSync3 } from "child_process";
3361
3361
  import path6 from "path";
@@ -3390,12 +3390,14 @@ function linuxSecretAvailable() {
3390
3390
  function isRootOnlyTrustedServerKeyFile(keyPath) {
3391
3391
  if (process.platform !== "linux") return false;
3392
3392
  try {
3393
- const uid = typeof os5.userInfo().uid === "number" ? os5.userInfo().uid : -1;
3394
3393
  const st = statSync3(keyPath);
3395
3394
  if (!st.isFile() || (st.mode & 63) !== 0) return false;
3395
+ const uid = typeof os5.userInfo().uid === "number" ? os5.userInfo().uid : -1;
3396
3396
  if (uid === 0) return true;
3397
3397
  const exeOsDir = process.env.EXE_OS_DIR;
3398
- return Boolean(exeOsDir && path6.resolve(keyPath).startsWith(path6.resolve(exeOsDir) + path6.sep));
3398
+ if (exeOsDir && path6.resolve(keyPath).startsWith(path6.resolve(exeOsDir) + path6.sep)) return true;
3399
+ if (!linuxSecretAvailable()) return true;
3400
+ return false;
3399
3401
  } catch {
3400
3402
  return false;
3401
3403
  }
@@ -3545,15 +3547,25 @@ async function writeMachineBoundFileFallback(b64) {
3545
3547
  await mkdir3(dir, { recursive: true });
3546
3548
  const keyPath = getKeyPath();
3547
3549
  const machineKey = deriveMachineKey();
3548
- if (machineKey) {
3549
- const encrypted = encryptWithMachineKey(b64, machineKey);
3550
- await writeFile3(keyPath, encrypted + "\n", "utf-8");
3551
- await chmod2(keyPath, 384);
3552
- return "encrypted";
3553
- }
3554
- await writeFile3(keyPath, b64 + "\n", "utf-8");
3555
- await chmod2(keyPath, 384);
3556
- return "plaintext";
3550
+ const content = machineKey ? encryptWithMachineKey(b64, machineKey) + "\n" : b64 + "\n";
3551
+ const result = machineKey ? "encrypted" : "plaintext";
3552
+ const tmpPath = keyPath + ".tmp";
3553
+ try {
3554
+ if (existsSync7(keyPath)) {
3555
+ await copyFile(keyPath, keyPath + ".bak").catch(() => {
3556
+ });
3557
+ }
3558
+ await writeFile3(tmpPath, content, "utf-8");
3559
+ await chmod2(tmpPath, 384);
3560
+ await rename(tmpPath, keyPath);
3561
+ } catch (err) {
3562
+ try {
3563
+ await unlink(tmpPath);
3564
+ } catch {
3565
+ }
3566
+ throw err;
3567
+ }
3568
+ return result;
3557
3569
  }
3558
3570
  async function getMasterKey() {
3559
3571
  let nativeValue = macKeychainGet() ?? linuxSecretGet();
@@ -3316,7 +3316,7 @@ var init_database = __esm({
3316
3316
  });
3317
3317
 
3318
3318
  // src/lib/keychain.ts
3319
- import { readFile as readFile3, writeFile as writeFile3, unlink, mkdir as mkdir3, chmod as chmod2 } from "fs/promises";
3319
+ import { readFile as readFile3, writeFile as writeFile3, unlink, mkdir as mkdir3, chmod as chmod2, rename, copyFile } from "fs/promises";
3320
3320
  import { existsSync as existsSync7, statSync as statSync3 } from "fs";
3321
3321
  import { execSync as execSync3 } from "child_process";
3322
3322
  import path6 from "path";
@@ -3351,12 +3351,14 @@ function linuxSecretAvailable() {
3351
3351
  function isRootOnlyTrustedServerKeyFile(keyPath) {
3352
3352
  if (process.platform !== "linux") return false;
3353
3353
  try {
3354
- const uid = typeof os5.userInfo().uid === "number" ? os5.userInfo().uid : -1;
3355
3354
  const st = statSync3(keyPath);
3356
3355
  if (!st.isFile() || (st.mode & 63) !== 0) return false;
3356
+ const uid = typeof os5.userInfo().uid === "number" ? os5.userInfo().uid : -1;
3357
3357
  if (uid === 0) return true;
3358
3358
  const exeOsDir = process.env.EXE_OS_DIR;
3359
- return Boolean(exeOsDir && path6.resolve(keyPath).startsWith(path6.resolve(exeOsDir) + path6.sep));
3359
+ if (exeOsDir && path6.resolve(keyPath).startsWith(path6.resolve(exeOsDir) + path6.sep)) return true;
3360
+ if (!linuxSecretAvailable()) return true;
3361
+ return false;
3360
3362
  } catch {
3361
3363
  return false;
3362
3364
  }
@@ -3506,15 +3508,25 @@ async function writeMachineBoundFileFallback(b64) {
3506
3508
  await mkdir3(dir, { recursive: true });
3507
3509
  const keyPath = getKeyPath();
3508
3510
  const machineKey = deriveMachineKey();
3509
- if (machineKey) {
3510
- const encrypted = encryptWithMachineKey(b64, machineKey);
3511
- await writeFile3(keyPath, encrypted + "\n", "utf-8");
3512
- await chmod2(keyPath, 384);
3513
- return "encrypted";
3514
- }
3515
- await writeFile3(keyPath, b64 + "\n", "utf-8");
3516
- await chmod2(keyPath, 384);
3517
- return "plaintext";
3511
+ const content = machineKey ? encryptWithMachineKey(b64, machineKey) + "\n" : b64 + "\n";
3512
+ const result = machineKey ? "encrypted" : "plaintext";
3513
+ const tmpPath = keyPath + ".tmp";
3514
+ try {
3515
+ if (existsSync7(keyPath)) {
3516
+ await copyFile(keyPath, keyPath + ".bak").catch(() => {
3517
+ });
3518
+ }
3519
+ await writeFile3(tmpPath, content, "utf-8");
3520
+ await chmod2(tmpPath, 384);
3521
+ await rename(tmpPath, keyPath);
3522
+ } catch (err) {
3523
+ try {
3524
+ await unlink(tmpPath);
3525
+ } catch {
3526
+ }
3527
+ throw err;
3528
+ }
3529
+ return result;
3518
3530
  }
3519
3531
  async function getMasterKey() {
3520
3532
  let nativeValue = macKeychainGet() ?? linuxSecretGet();