@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
@@ -659,6 +659,7 @@ __export(agent_config_exports, {
659
659
  clearAgentRuntime: () => clearAgentRuntime,
660
660
  getAgentRuntime: () => getAgentRuntime,
661
661
  loadAgentConfig: () => loadAgentConfig,
662
+ normalizeCcModelName: () => normalizeCcModelName,
662
663
  saveAgentConfig: () => saveAgentConfig,
663
664
  setAgentMcps: () => setAgentMcps,
664
665
  setAgentRuntime: () => setAgentRuntime
@@ -687,6 +688,13 @@ function getAgentRuntime(agentId) {
687
688
  if (orgDefault) return orgDefault;
688
689
  return { runtime: DEFAULT_RUNTIME, model: DEFAULT_MODELS[DEFAULT_RUNTIME] };
689
690
  }
691
+ function normalizeCcModelName(model) {
692
+ let ccModel = model.replace(/(\d+)\.(\d+)/g, "$1-$2");
693
+ if (/claude-(opus|sonnet)-4-[6-9]/.test(ccModel) && !ccModel.includes("[1m]")) {
694
+ ccModel += "[1m]";
695
+ }
696
+ return ccModel;
697
+ }
690
698
  function setAgentRuntime(agentId, runtime, model, reasoning_effort, mcps) {
691
699
  const knownModels = KNOWN_RUNTIMES[runtime];
692
700
  if (!knownModels) {
@@ -7788,10 +7796,8 @@ function spawnEmployee(employeeName, exeSession, projectDir, opts) {
7788
7796
  }
7789
7797
  if (!useExeAgent && !useCodex && !useOpencode && !useBinSymlink) {
7790
7798
  if (agentRtConfig.runtime === "claude" && agentRtConfig.model) {
7791
- let ccModel = agentRtConfig.model.replace(/(\d+)\.(\d+)/g, "$1-$2");
7792
- if (/claude-(opus|sonnet)-4-[6-9]/.test(ccModel) && !ccModel.includes("[1m]")) {
7793
- ccModel += "[1m]";
7794
- }
7799
+ const { normalizeCcModelName: normalizeCcModelName2 } = (init_agent_config(), __toCommonJS(agent_config_exports));
7800
+ const ccModel = normalizeCcModelName2(agentRtConfig.model);
7795
7801
  envPrefix = `${envPrefix} ANTHROPIC_MODEL=${ccModel}`;
7796
7802
  }
7797
7803
  }
@@ -7956,7 +7962,7 @@ var init_task_scope = __esm({
7956
7962
  });
7957
7963
 
7958
7964
  // src/lib/keychain.ts
7959
- import { readFile as readFile4, writeFile as writeFile5, unlink, mkdir as mkdir4, chmod as chmod2 } from "fs/promises";
7965
+ import { readFile as readFile4, writeFile as writeFile5, unlink, mkdir as mkdir4, chmod as chmod2, rename, copyFile } from "fs/promises";
7960
7966
  import { existsSync as existsSync17, statSync as statSync3 } from "fs";
7961
7967
  import { execSync as execSync9 } from "child_process";
7962
7968
  import path19 from "path";
@@ -7991,12 +7997,14 @@ function linuxSecretAvailable() {
7991
7997
  function isRootOnlyTrustedServerKeyFile(keyPath) {
7992
7998
  if (process.platform !== "linux") return false;
7993
7999
  try {
7994
- const uid = typeof os12.userInfo().uid === "number" ? os12.userInfo().uid : -1;
7995
8000
  const st = statSync3(keyPath);
7996
8001
  if (!st.isFile() || (st.mode & 63) !== 0) return false;
8002
+ const uid = typeof os12.userInfo().uid === "number" ? os12.userInfo().uid : -1;
7997
8003
  if (uid === 0) return true;
7998
8004
  const exeOsDir = process.env.EXE_OS_DIR;
7999
- return Boolean(exeOsDir && path19.resolve(keyPath).startsWith(path19.resolve(exeOsDir) + path19.sep));
8005
+ if (exeOsDir && path19.resolve(keyPath).startsWith(path19.resolve(exeOsDir) + path19.sep)) return true;
8006
+ if (!linuxSecretAvailable()) return true;
8007
+ return false;
8000
8008
  } catch {
8001
8009
  return false;
8002
8010
  }
@@ -8146,15 +8154,25 @@ async function writeMachineBoundFileFallback(b64) {
8146
8154
  await mkdir4(dir, { recursive: true });
8147
8155
  const keyPath = getKeyPath();
8148
8156
  const machineKey = deriveMachineKey();
8149
- if (machineKey) {
8150
- const encrypted = encryptWithMachineKey(b64, machineKey);
8151
- await writeFile5(keyPath, encrypted + "\n", "utf-8");
8152
- await chmod2(keyPath, 384);
8153
- return "encrypted";
8154
- }
8155
- await writeFile5(keyPath, b64 + "\n", "utf-8");
8156
- await chmod2(keyPath, 384);
8157
- return "plaintext";
8157
+ const content = machineKey ? encryptWithMachineKey(b64, machineKey) + "\n" : b64 + "\n";
8158
+ const result = machineKey ? "encrypted" : "plaintext";
8159
+ const tmpPath = keyPath + ".tmp";
8160
+ try {
8161
+ if (existsSync17(keyPath)) {
8162
+ await copyFile(keyPath, keyPath + ".bak").catch(() => {
8163
+ });
8164
+ }
8165
+ await writeFile5(tmpPath, content, "utf-8");
8166
+ await chmod2(tmpPath, 384);
8167
+ await rename(tmpPath, keyPath);
8168
+ } catch (err) {
8169
+ try {
8170
+ await unlink(tmpPath);
8171
+ } catch {
8172
+ }
8173
+ throw err;
8174
+ }
8175
+ return result;
8158
8176
  }
8159
8177
  async function getMasterKey() {
8160
8178
  let nativeValue = macKeychainGet() ?? linuxSecretGet();
@@ -3317,7 +3317,7 @@ var init_database = __esm({
3317
3317
  });
3318
3318
 
3319
3319
  // src/lib/keychain.ts
3320
- import { readFile as readFile3, writeFile as writeFile3, unlink, mkdir as mkdir3, chmod as chmod2 } from "fs/promises";
3320
+ import { readFile as readFile3, writeFile as writeFile3, unlink, mkdir as mkdir3, chmod as chmod2, rename, copyFile } from "fs/promises";
3321
3321
  import { existsSync as existsSync7, statSync as statSync3 } from "fs";
3322
3322
  import { execSync as execSync3 } from "child_process";
3323
3323
  import path6 from "path";
@@ -3352,12 +3352,14 @@ function linuxSecretAvailable() {
3352
3352
  function isRootOnlyTrustedServerKeyFile(keyPath) {
3353
3353
  if (process.platform !== "linux") return false;
3354
3354
  try {
3355
- const uid = typeof os5.userInfo().uid === "number" ? os5.userInfo().uid : -1;
3356
3355
  const st = statSync3(keyPath);
3357
3356
  if (!st.isFile() || (st.mode & 63) !== 0) return false;
3357
+ const uid = typeof os5.userInfo().uid === "number" ? os5.userInfo().uid : -1;
3358
3358
  if (uid === 0) return true;
3359
3359
  const exeOsDir = process.env.EXE_OS_DIR;
3360
- return Boolean(exeOsDir && path6.resolve(keyPath).startsWith(path6.resolve(exeOsDir) + path6.sep));
3360
+ if (exeOsDir && path6.resolve(keyPath).startsWith(path6.resolve(exeOsDir) + path6.sep)) return true;
3361
+ if (!linuxSecretAvailable()) return true;
3362
+ return false;
3361
3363
  } catch {
3362
3364
  return false;
3363
3365
  }
@@ -3507,15 +3509,25 @@ async function writeMachineBoundFileFallback(b64) {
3507
3509
  await mkdir3(dir, { recursive: true });
3508
3510
  const keyPath = getKeyPath();
3509
3511
  const machineKey = deriveMachineKey();
3510
- if (machineKey) {
3511
- const encrypted = encryptWithMachineKey(b64, machineKey);
3512
- await writeFile3(keyPath, encrypted + "\n", "utf-8");
3513
- await chmod2(keyPath, 384);
3514
- return "encrypted";
3515
- }
3516
- await writeFile3(keyPath, b64 + "\n", "utf-8");
3517
- await chmod2(keyPath, 384);
3518
- return "plaintext";
3512
+ const content = machineKey ? encryptWithMachineKey(b64, machineKey) + "\n" : b64 + "\n";
3513
+ const result = machineKey ? "encrypted" : "plaintext";
3514
+ const tmpPath = keyPath + ".tmp";
3515
+ try {
3516
+ if (existsSync7(keyPath)) {
3517
+ await copyFile(keyPath, keyPath + ".bak").catch(() => {
3518
+ });
3519
+ }
3520
+ await writeFile3(tmpPath, content, "utf-8");
3521
+ await chmod2(tmpPath, 384);
3522
+ await rename(tmpPath, keyPath);
3523
+ } catch (err) {
3524
+ try {
3525
+ await unlink(tmpPath);
3526
+ } catch {
3527
+ }
3528
+ throw err;
3529
+ }
3530
+ return result;
3519
3531
  }
3520
3532
  async function getMasterKey() {
3521
3533
  let nativeValue = macKeychainGet() ?? linuxSecretGet();
@@ -435,6 +435,7 @@ __export(agent_config_exports, {
435
435
  clearAgentRuntime: () => clearAgentRuntime,
436
436
  getAgentRuntime: () => getAgentRuntime,
437
437
  loadAgentConfig: () => loadAgentConfig,
438
+ normalizeCcModelName: () => normalizeCcModelName,
438
439
  saveAgentConfig: () => saveAgentConfig,
439
440
  setAgentMcps: () => setAgentMcps,
440
441
  setAgentRuntime: () => setAgentRuntime
@@ -463,6 +464,13 @@ function getAgentRuntime(agentId) {
463
464
  if (orgDefault) return orgDefault;
464
465
  return { runtime: DEFAULT_RUNTIME, model: DEFAULT_MODELS[DEFAULT_RUNTIME] };
465
466
  }
467
+ function normalizeCcModelName(model) {
468
+ let ccModel = model.replace(/(\d+)\.(\d+)/g, "$1-$2");
469
+ if (/claude-(opus|sonnet)-4-[6-9]/.test(ccModel) && !ccModel.includes("[1m]")) {
470
+ ccModel += "[1m]";
471
+ }
472
+ return ccModel;
473
+ }
466
474
  function setAgentRuntime(agentId, runtime, model, reasoning_effort, mcps) {
467
475
  const knownModels = KNOWN_RUNTIMES[runtime];
468
476
  if (!knownModels) {
@@ -3782,7 +3790,7 @@ var init_database = __esm({
3782
3790
  });
3783
3791
 
3784
3792
  // src/lib/keychain.ts
3785
- import { readFile as readFile3, writeFile as writeFile3, unlink, mkdir as mkdir3, chmod as chmod2 } from "fs/promises";
3793
+ import { readFile as readFile3, writeFile as writeFile3, unlink, mkdir as mkdir3, chmod as chmod2, rename, copyFile } from "fs/promises";
3786
3794
  import { existsSync as existsSync10, statSync as statSync3 } from "fs";
3787
3795
  import { execSync as execSync5 } from "child_process";
3788
3796
  import path10 from "path";
@@ -3817,12 +3825,14 @@ function linuxSecretAvailable() {
3817
3825
  function isRootOnlyTrustedServerKeyFile(keyPath) {
3818
3826
  if (process.platform !== "linux") return false;
3819
3827
  try {
3820
- const uid = typeof os6.userInfo().uid === "number" ? os6.userInfo().uid : -1;
3821
3828
  const st = statSync3(keyPath);
3822
3829
  if (!st.isFile() || (st.mode & 63) !== 0) return false;
3830
+ const uid = typeof os6.userInfo().uid === "number" ? os6.userInfo().uid : -1;
3823
3831
  if (uid === 0) return true;
3824
3832
  const exeOsDir = process.env.EXE_OS_DIR;
3825
- return Boolean(exeOsDir && path10.resolve(keyPath).startsWith(path10.resolve(exeOsDir) + path10.sep));
3833
+ if (exeOsDir && path10.resolve(keyPath).startsWith(path10.resolve(exeOsDir) + path10.sep)) return true;
3834
+ if (!linuxSecretAvailable()) return true;
3835
+ return false;
3826
3836
  } catch {
3827
3837
  return false;
3828
3838
  }
@@ -3972,15 +3982,25 @@ async function writeMachineBoundFileFallback(b64) {
3972
3982
  await mkdir3(dir, { recursive: true });
3973
3983
  const keyPath = getKeyPath();
3974
3984
  const machineKey = deriveMachineKey();
3975
- if (machineKey) {
3976
- const encrypted = encryptWithMachineKey(b64, machineKey);
3977
- await writeFile3(keyPath, encrypted + "\n", "utf-8");
3978
- await chmod2(keyPath, 384);
3979
- return "encrypted";
3985
+ const content = machineKey ? encryptWithMachineKey(b64, machineKey) + "\n" : b64 + "\n";
3986
+ const result = machineKey ? "encrypted" : "plaintext";
3987
+ const tmpPath = keyPath + ".tmp";
3988
+ try {
3989
+ if (existsSync10(keyPath)) {
3990
+ await copyFile(keyPath, keyPath + ".bak").catch(() => {
3991
+ });
3992
+ }
3993
+ await writeFile3(tmpPath, content, "utf-8");
3994
+ await chmod2(tmpPath, 384);
3995
+ await rename(tmpPath, keyPath);
3996
+ } catch (err) {
3997
+ try {
3998
+ await unlink(tmpPath);
3999
+ } catch {
4000
+ }
4001
+ throw err;
3980
4002
  }
3981
- await writeFile3(keyPath, b64 + "\n", "utf-8");
3982
- await chmod2(keyPath, 384);
3983
- return "plaintext";
4003
+ return result;
3984
4004
  }
3985
4005
  async function getMasterKey() {
3986
4006
  let nativeValue = macKeychainGet() ?? linuxSecretGet();
@@ -9653,10 +9673,8 @@ function spawnEmployee(employeeName, exeSession, projectDir, opts) {
9653
9673
  }
9654
9674
  if (!useExeAgent && !useCodex && !useOpencode && !useBinSymlink) {
9655
9675
  if (agentRtConfig.runtime === "claude" && agentRtConfig.model) {
9656
- let ccModel = agentRtConfig.model.replace(/(\d+)\.(\d+)/g, "$1-$2");
9657
- if (/claude-(opus|sonnet)-4-[6-9]/.test(ccModel) && !ccModel.includes("[1m]")) {
9658
- ccModel += "[1m]";
9659
- }
9676
+ const { normalizeCcModelName: normalizeCcModelName2 } = (init_agent_config(), __toCommonJS(agent_config_exports));
9677
+ const ccModel = normalizeCcModelName2(agentRtConfig.model);
9660
9678
  envPrefix = `${envPrefix} ANTHROPIC_MODEL=${ccModel}`;
9661
9679
  }
9662
9680
  }
@@ -3318,7 +3318,7 @@ var init_database = __esm({
3318
3318
  });
3319
3319
 
3320
3320
  // src/lib/keychain.ts
3321
- import { readFile as readFile3, writeFile as writeFile3, unlink, mkdir as mkdir3, chmod as chmod2 } from "fs/promises";
3321
+ import { readFile as readFile3, writeFile as writeFile3, unlink, mkdir as mkdir3, chmod as chmod2, rename, copyFile } from "fs/promises";
3322
3322
  import { existsSync as existsSync8, statSync as statSync3 } from "fs";
3323
3323
  import { execSync as execSync5 } from "child_process";
3324
3324
  import path8 from "path";
@@ -3353,12 +3353,14 @@ function linuxSecretAvailable() {
3353
3353
  function isRootOnlyTrustedServerKeyFile(keyPath) {
3354
3354
  if (process.platform !== "linux") return false;
3355
3355
  try {
3356
- const uid = typeof os5.userInfo().uid === "number" ? os5.userInfo().uid : -1;
3357
3356
  const st = statSync3(keyPath);
3358
3357
  if (!st.isFile() || (st.mode & 63) !== 0) return false;
3358
+ const uid = typeof os5.userInfo().uid === "number" ? os5.userInfo().uid : -1;
3359
3359
  if (uid === 0) return true;
3360
3360
  const exeOsDir = process.env.EXE_OS_DIR;
3361
- return Boolean(exeOsDir && path8.resolve(keyPath).startsWith(path8.resolve(exeOsDir) + path8.sep));
3361
+ if (exeOsDir && path8.resolve(keyPath).startsWith(path8.resolve(exeOsDir) + path8.sep)) return true;
3362
+ if (!linuxSecretAvailable()) return true;
3363
+ return false;
3362
3364
  } catch {
3363
3365
  return false;
3364
3366
  }
@@ -3508,15 +3510,25 @@ async function writeMachineBoundFileFallback(b64) {
3508
3510
  await mkdir3(dir, { recursive: true });
3509
3511
  const keyPath = getKeyPath();
3510
3512
  const machineKey = deriveMachineKey();
3511
- if (machineKey) {
3512
- const encrypted = encryptWithMachineKey(b64, machineKey);
3513
- await writeFile3(keyPath, encrypted + "\n", "utf-8");
3514
- await chmod2(keyPath, 384);
3515
- return "encrypted";
3516
- }
3517
- await writeFile3(keyPath, b64 + "\n", "utf-8");
3518
- await chmod2(keyPath, 384);
3519
- return "plaintext";
3513
+ const content = machineKey ? encryptWithMachineKey(b64, machineKey) + "\n" : b64 + "\n";
3514
+ const result = machineKey ? "encrypted" : "plaintext";
3515
+ const tmpPath = keyPath + ".tmp";
3516
+ try {
3517
+ if (existsSync8(keyPath)) {
3518
+ await copyFile(keyPath, keyPath + ".bak").catch(() => {
3519
+ });
3520
+ }
3521
+ await writeFile3(tmpPath, content, "utf-8");
3522
+ await chmod2(tmpPath, 384);
3523
+ await rename(tmpPath, keyPath);
3524
+ } catch (err) {
3525
+ try {
3526
+ await unlink(tmpPath);
3527
+ } catch {
3528
+ }
3529
+ throw err;
3530
+ }
3531
+ return result;
3520
3532
  }
3521
3533
  async function getMasterKey() {
3522
3534
  let nativeValue = macKeychainGet() ?? linuxSecretGet();
@@ -3318,7 +3318,7 @@ var init_database = __esm({
3318
3318
  });
3319
3319
 
3320
3320
  // src/lib/keychain.ts
3321
- import { readFile as readFile3, writeFile as writeFile3, unlink, mkdir as mkdir3, chmod as chmod2 } from "fs/promises";
3321
+ import { readFile as readFile3, writeFile as writeFile3, unlink, mkdir as mkdir3, chmod as chmod2, rename, copyFile } from "fs/promises";
3322
3322
  import { existsSync as existsSync7, statSync as statSync3 } from "fs";
3323
3323
  import { execSync as execSync5 } from "child_process";
3324
3324
  import path7 from "path";
@@ -3353,12 +3353,14 @@ function linuxSecretAvailable() {
3353
3353
  function isRootOnlyTrustedServerKeyFile(keyPath) {
3354
3354
  if (process.platform !== "linux") return false;
3355
3355
  try {
3356
- const uid = typeof os5.userInfo().uid === "number" ? os5.userInfo().uid : -1;
3357
3356
  const st = statSync3(keyPath);
3358
3357
  if (!st.isFile() || (st.mode & 63) !== 0) return false;
3358
+ const uid = typeof os5.userInfo().uid === "number" ? os5.userInfo().uid : -1;
3359
3359
  if (uid === 0) return true;
3360
3360
  const exeOsDir = process.env.EXE_OS_DIR;
3361
- return Boolean(exeOsDir && path7.resolve(keyPath).startsWith(path7.resolve(exeOsDir) + path7.sep));
3361
+ if (exeOsDir && path7.resolve(keyPath).startsWith(path7.resolve(exeOsDir) + path7.sep)) return true;
3362
+ if (!linuxSecretAvailable()) return true;
3363
+ return false;
3362
3364
  } catch {
3363
3365
  return false;
3364
3366
  }
@@ -3508,15 +3510,25 @@ async function writeMachineBoundFileFallback(b64) {
3508
3510
  await mkdir3(dir, { recursive: true });
3509
3511
  const keyPath = getKeyPath();
3510
3512
  const machineKey = deriveMachineKey();
3511
- if (machineKey) {
3512
- const encrypted = encryptWithMachineKey(b64, machineKey);
3513
- await writeFile3(keyPath, encrypted + "\n", "utf-8");
3514
- await chmod2(keyPath, 384);
3515
- return "encrypted";
3516
- }
3517
- await writeFile3(keyPath, b64 + "\n", "utf-8");
3518
- await chmod2(keyPath, 384);
3519
- return "plaintext";
3513
+ const content = machineKey ? encryptWithMachineKey(b64, machineKey) + "\n" : b64 + "\n";
3514
+ const result = machineKey ? "encrypted" : "plaintext";
3515
+ const tmpPath = keyPath + ".tmp";
3516
+ try {
3517
+ if (existsSync7(keyPath)) {
3518
+ await copyFile(keyPath, keyPath + ".bak").catch(() => {
3519
+ });
3520
+ }
3521
+ await writeFile3(tmpPath, content, "utf-8");
3522
+ await chmod2(tmpPath, 384);
3523
+ await rename(tmpPath, keyPath);
3524
+ } catch (err) {
3525
+ try {
3526
+ await unlink(tmpPath);
3527
+ } catch {
3528
+ }
3529
+ throw err;
3530
+ }
3531
+ return result;
3520
3532
  }
3521
3533
  async function getMasterKey() {
3522
3534
  let nativeValue = macKeychainGet() ?? linuxSecretGet();
@@ -3957,7 +3957,7 @@ var init_identity = __esm({
3957
3957
  });
3958
3958
 
3959
3959
  // src/lib/keychain.ts
3960
- import { readFile as readFile3, writeFile as writeFile3, unlink, mkdir as mkdir3, chmod as chmod2 } from "fs/promises";
3960
+ import { readFile as readFile3, writeFile as writeFile3, unlink, mkdir as mkdir3, chmod as chmod2, rename, copyFile } from "fs/promises";
3961
3961
  import { existsSync as existsSync14, statSync as statSync3 } from "fs";
3962
3962
  import { execSync as execSync6 } from "child_process";
3963
3963
  import path15 from "path";
@@ -3992,12 +3992,14 @@ function linuxSecretAvailable() {
3992
3992
  function isRootOnlyTrustedServerKeyFile(keyPath) {
3993
3993
  if (process.platform !== "linux") return false;
3994
3994
  try {
3995
- const uid = typeof os10.userInfo().uid === "number" ? os10.userInfo().uid : -1;
3996
3995
  const st = statSync3(keyPath);
3997
3996
  if (!st.isFile() || (st.mode & 63) !== 0) return false;
3997
+ const uid = typeof os10.userInfo().uid === "number" ? os10.userInfo().uid : -1;
3998
3998
  if (uid === 0) return true;
3999
3999
  const exeOsDir = process.env.EXE_OS_DIR;
4000
- return Boolean(exeOsDir && path15.resolve(keyPath).startsWith(path15.resolve(exeOsDir) + path15.sep));
4000
+ if (exeOsDir && path15.resolve(keyPath).startsWith(path15.resolve(exeOsDir) + path15.sep)) return true;
4001
+ if (!linuxSecretAvailable()) return true;
4002
+ return false;
4001
4003
  } catch {
4002
4004
  return false;
4003
4005
  }
@@ -4147,15 +4149,25 @@ async function writeMachineBoundFileFallback(b64) {
4147
4149
  await mkdir3(dir, { recursive: true });
4148
4150
  const keyPath = getKeyPath();
4149
4151
  const machineKey = deriveMachineKey();
4150
- if (machineKey) {
4151
- const encrypted = encryptWithMachineKey(b64, machineKey);
4152
- await writeFile3(keyPath, encrypted + "\n", "utf-8");
4153
- await chmod2(keyPath, 384);
4154
- return "encrypted";
4155
- }
4156
- await writeFile3(keyPath, b64 + "\n", "utf-8");
4157
- await chmod2(keyPath, 384);
4158
- return "plaintext";
4152
+ const content = machineKey ? encryptWithMachineKey(b64, machineKey) + "\n" : b64 + "\n";
4153
+ const result = machineKey ? "encrypted" : "plaintext";
4154
+ const tmpPath = keyPath + ".tmp";
4155
+ try {
4156
+ if (existsSync14(keyPath)) {
4157
+ await copyFile(keyPath, keyPath + ".bak").catch(() => {
4158
+ });
4159
+ }
4160
+ await writeFile3(tmpPath, content, "utf-8");
4161
+ await chmod2(tmpPath, 384);
4162
+ await rename(tmpPath, keyPath);
4163
+ } catch (err) {
4164
+ try {
4165
+ await unlink(tmpPath);
4166
+ } catch {
4167
+ }
4168
+ throw err;
4169
+ }
4170
+ return result;
4159
4171
  }
4160
4172
  async function getMasterKey() {
4161
4173
  let nativeValue = macKeychainGet() ?? linuxSecretGet();
@@ -3569,7 +3569,7 @@ var init_database = __esm({
3569
3569
  });
3570
3570
 
3571
3571
  // src/lib/keychain.ts
3572
- import { readFile as readFile3, writeFile as writeFile3, unlink, mkdir as mkdir3, chmod as chmod2 } from "fs/promises";
3572
+ import { readFile as readFile3, writeFile as writeFile3, unlink, mkdir as mkdir3, chmod as chmod2, rename, copyFile } from "fs/promises";
3573
3573
  import { existsSync as existsSync7, statSync as statSync3 } from "fs";
3574
3574
  import { execSync as execSync3 } from "child_process";
3575
3575
  import path6 from "path";
@@ -3604,12 +3604,14 @@ function linuxSecretAvailable() {
3604
3604
  function isRootOnlyTrustedServerKeyFile(keyPath) {
3605
3605
  if (process.platform !== "linux") return false;
3606
3606
  try {
3607
- const uid = typeof os5.userInfo().uid === "number" ? os5.userInfo().uid : -1;
3608
3607
  const st = statSync3(keyPath);
3609
3608
  if (!st.isFile() || (st.mode & 63) !== 0) return false;
3609
+ const uid = typeof os5.userInfo().uid === "number" ? os5.userInfo().uid : -1;
3610
3610
  if (uid === 0) return true;
3611
3611
  const exeOsDir = process.env.EXE_OS_DIR;
3612
- return Boolean(exeOsDir && path6.resolve(keyPath).startsWith(path6.resolve(exeOsDir) + path6.sep));
3612
+ if (exeOsDir && path6.resolve(keyPath).startsWith(path6.resolve(exeOsDir) + path6.sep)) return true;
3613
+ if (!linuxSecretAvailable()) return true;
3614
+ return false;
3613
3615
  } catch {
3614
3616
  return false;
3615
3617
  }
@@ -3759,15 +3761,25 @@ async function writeMachineBoundFileFallback(b64) {
3759
3761
  await mkdir3(dir, { recursive: true });
3760
3762
  const keyPath = getKeyPath();
3761
3763
  const machineKey = deriveMachineKey();
3762
- if (machineKey) {
3763
- const encrypted = encryptWithMachineKey(b64, machineKey);
3764
- await writeFile3(keyPath, encrypted + "\n", "utf-8");
3765
- await chmod2(keyPath, 384);
3766
- return "encrypted";
3767
- }
3768
- await writeFile3(keyPath, b64 + "\n", "utf-8");
3769
- await chmod2(keyPath, 384);
3770
- return "plaintext";
3764
+ const content = machineKey ? encryptWithMachineKey(b64, machineKey) + "\n" : b64 + "\n";
3765
+ const result = machineKey ? "encrypted" : "plaintext";
3766
+ const tmpPath = keyPath + ".tmp";
3767
+ try {
3768
+ if (existsSync7(keyPath)) {
3769
+ await copyFile(keyPath, keyPath + ".bak").catch(() => {
3770
+ });
3771
+ }
3772
+ await writeFile3(tmpPath, content, "utf-8");
3773
+ await chmod2(tmpPath, 384);
3774
+ await rename(tmpPath, keyPath);
3775
+ } catch (err) {
3776
+ try {
3777
+ await unlink(tmpPath);
3778
+ } catch {
3779
+ }
3780
+ throw err;
3781
+ }
3782
+ return result;
3771
3783
  }
3772
3784
  async function getMasterKey() {
3773
3785
  let nativeValue = macKeychainGet() ?? linuxSecretGet();
@@ -435,6 +435,7 @@ __export(agent_config_exports, {
435
435
  clearAgentRuntime: () => clearAgentRuntime,
436
436
  getAgentRuntime: () => getAgentRuntime,
437
437
  loadAgentConfig: () => loadAgentConfig,
438
+ normalizeCcModelName: () => normalizeCcModelName,
438
439
  saveAgentConfig: () => saveAgentConfig,
439
440
  setAgentMcps: () => setAgentMcps,
440
441
  setAgentRuntime: () => setAgentRuntime
@@ -463,6 +464,13 @@ function getAgentRuntime(agentId) {
463
464
  if (orgDefault) return orgDefault;
464
465
  return { runtime: DEFAULT_RUNTIME, model: DEFAULT_MODELS[DEFAULT_RUNTIME] };
465
466
  }
467
+ function normalizeCcModelName(model) {
468
+ let ccModel = model.replace(/(\d+)\.(\d+)/g, "$1-$2");
469
+ if (/claude-(opus|sonnet)-4-[6-9]/.test(ccModel) && !ccModel.includes("[1m]")) {
470
+ ccModel += "[1m]";
471
+ }
472
+ return ccModel;
473
+ }
466
474
  function setAgentRuntime(agentId, runtime, model, reasoning_effort, mcps) {
467
475
  const knownModels = KNOWN_RUNTIMES[runtime];
468
476
  if (!knownModels) {
@@ -7772,10 +7780,8 @@ function spawnEmployee(employeeName, exeSession, projectDir, opts) {
7772
7780
  }
7773
7781
  if (!useExeAgent && !useCodex && !useOpencode && !useBinSymlink) {
7774
7782
  if (agentRtConfig.runtime === "claude" && agentRtConfig.model) {
7775
- let ccModel = agentRtConfig.model.replace(/(\d+)\.(\d+)/g, "$1-$2");
7776
- if (/claude-(opus|sonnet)-4-[6-9]/.test(ccModel) && !ccModel.includes("[1m]")) {
7777
- ccModel += "[1m]";
7778
- }
7783
+ const { normalizeCcModelName: normalizeCcModelName2 } = (init_agent_config(), __toCommonJS(agent_config_exports));
7784
+ const ccModel = normalizeCcModelName2(agentRtConfig.model);
7779
7785
  envPrefix = `${envPrefix} ANTHROPIC_MODEL=${ccModel}`;
7780
7786
  }
7781
7787
  }
@@ -7940,7 +7946,7 @@ var init_task_scope = __esm({
7940
7946
  });
7941
7947
 
7942
7948
  // src/lib/keychain.ts
7943
- import { readFile as readFile4, writeFile as writeFile5, unlink, mkdir as mkdir4, chmod as chmod2 } from "fs/promises";
7949
+ import { readFile as readFile4, writeFile as writeFile5, unlink, mkdir as mkdir4, chmod as chmod2, rename, copyFile } from "fs/promises";
7944
7950
  import { existsSync as existsSync18, statSync as statSync4 } from "fs";
7945
7951
  import { execSync as execSync9 } from "child_process";
7946
7952
  import path21 from "path";
@@ -7975,12 +7981,14 @@ function linuxSecretAvailable() {
7975
7981
  function isRootOnlyTrustedServerKeyFile(keyPath) {
7976
7982
  if (process.platform !== "linux") return false;
7977
7983
  try {
7978
- const uid = typeof os12.userInfo().uid === "number" ? os12.userInfo().uid : -1;
7979
7984
  const st = statSync4(keyPath);
7980
7985
  if (!st.isFile() || (st.mode & 63) !== 0) return false;
7986
+ const uid = typeof os12.userInfo().uid === "number" ? os12.userInfo().uid : -1;
7981
7987
  if (uid === 0) return true;
7982
7988
  const exeOsDir = process.env.EXE_OS_DIR;
7983
- return Boolean(exeOsDir && path21.resolve(keyPath).startsWith(path21.resolve(exeOsDir) + path21.sep));
7989
+ if (exeOsDir && path21.resolve(keyPath).startsWith(path21.resolve(exeOsDir) + path21.sep)) return true;
7990
+ if (!linuxSecretAvailable()) return true;
7991
+ return false;
7984
7992
  } catch {
7985
7993
  return false;
7986
7994
  }
@@ -8130,15 +8138,25 @@ async function writeMachineBoundFileFallback(b64) {
8130
8138
  await mkdir4(dir, { recursive: true });
8131
8139
  const keyPath = getKeyPath();
8132
8140
  const machineKey = deriveMachineKey();
8133
- if (machineKey) {
8134
- const encrypted = encryptWithMachineKey(b64, machineKey);
8135
- await writeFile5(keyPath, encrypted + "\n", "utf-8");
8136
- await chmod2(keyPath, 384);
8137
- return "encrypted";
8138
- }
8139
- await writeFile5(keyPath, b64 + "\n", "utf-8");
8140
- await chmod2(keyPath, 384);
8141
- return "plaintext";
8141
+ const content = machineKey ? encryptWithMachineKey(b64, machineKey) + "\n" : b64 + "\n";
8142
+ const result = machineKey ? "encrypted" : "plaintext";
8143
+ const tmpPath = keyPath + ".tmp";
8144
+ try {
8145
+ if (existsSync18(keyPath)) {
8146
+ await copyFile(keyPath, keyPath + ".bak").catch(() => {
8147
+ });
8148
+ }
8149
+ await writeFile5(tmpPath, content, "utf-8");
8150
+ await chmod2(tmpPath, 384);
8151
+ await rename(tmpPath, keyPath);
8152
+ } catch (err) {
8153
+ try {
8154
+ await unlink(tmpPath);
8155
+ } catch {
8156
+ }
8157
+ throw err;
8158
+ }
8159
+ return result;
8142
8160
  }
8143
8161
  async function getMasterKey() {
8144
8162
  let nativeValue = macKeychainGet() ?? linuxSecretGet();