@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
@@ -432,6 +432,7 @@ __export(agent_config_exports, {
432
432
  clearAgentRuntime: () => clearAgentRuntime,
433
433
  getAgentRuntime: () => getAgentRuntime,
434
434
  loadAgentConfig: () => loadAgentConfig,
435
+ normalizeCcModelName: () => normalizeCcModelName,
435
436
  saveAgentConfig: () => saveAgentConfig,
436
437
  setAgentMcps: () => setAgentMcps,
437
438
  setAgentRuntime: () => setAgentRuntime
@@ -460,6 +461,13 @@ function getAgentRuntime(agentId) {
460
461
  if (orgDefault) return orgDefault;
461
462
  return { runtime: DEFAULT_RUNTIME, model: DEFAULT_MODELS[DEFAULT_RUNTIME] };
462
463
  }
464
+ function normalizeCcModelName(model) {
465
+ let ccModel = model.replace(/(\d+)\.(\d+)/g, "$1-$2");
466
+ if (/claude-(opus|sonnet)-4-[6-9]/.test(ccModel) && !ccModel.includes("[1m]")) {
467
+ ccModel += "[1m]";
468
+ }
469
+ return ccModel;
470
+ }
463
471
  function setAgentRuntime(agentId, runtime, model, reasoning_effort, mcps) {
464
472
  const knownModels = KNOWN_RUNTIMES[runtime];
465
473
  if (!knownModels) {
@@ -3676,7 +3684,7 @@ var init_database = __esm({
3676
3684
  });
3677
3685
 
3678
3686
  // src/lib/keychain.ts
3679
- import { readFile as readFile3, writeFile as writeFile3, unlink, mkdir as mkdir3, chmod as chmod2 } from "fs/promises";
3687
+ import { readFile as readFile3, writeFile as writeFile3, unlink, mkdir as mkdir3, chmod as chmod2, rename, copyFile } from "fs/promises";
3680
3688
  import { existsSync as existsSync8, statSync as statSync3 } from "fs";
3681
3689
  import { execSync as execSync3 } from "child_process";
3682
3690
  import path7 from "path";
@@ -3711,12 +3719,14 @@ function linuxSecretAvailable() {
3711
3719
  function isRootOnlyTrustedServerKeyFile(keyPath) {
3712
3720
  if (process.platform !== "linux") return false;
3713
3721
  try {
3714
- const uid = typeof os5.userInfo().uid === "number" ? os5.userInfo().uid : -1;
3715
3722
  const st = statSync3(keyPath);
3716
3723
  if (!st.isFile() || (st.mode & 63) !== 0) return false;
3724
+ const uid = typeof os5.userInfo().uid === "number" ? os5.userInfo().uid : -1;
3717
3725
  if (uid === 0) return true;
3718
3726
  const exeOsDir = process.env.EXE_OS_DIR;
3719
- return Boolean(exeOsDir && path7.resolve(keyPath).startsWith(path7.resolve(exeOsDir) + path7.sep));
3727
+ if (exeOsDir && path7.resolve(keyPath).startsWith(path7.resolve(exeOsDir) + path7.sep)) return true;
3728
+ if (!linuxSecretAvailable()) return true;
3729
+ return false;
3720
3730
  } catch {
3721
3731
  return false;
3722
3732
  }
@@ -3866,15 +3876,25 @@ async function writeMachineBoundFileFallback(b64) {
3866
3876
  await mkdir3(dir, { recursive: true });
3867
3877
  const keyPath = getKeyPath();
3868
3878
  const machineKey = deriveMachineKey();
3869
- if (machineKey) {
3870
- const encrypted = encryptWithMachineKey(b64, machineKey);
3871
- await writeFile3(keyPath, encrypted + "\n", "utf-8");
3872
- await chmod2(keyPath, 384);
3873
- return "encrypted";
3879
+ const content = machineKey ? encryptWithMachineKey(b64, machineKey) + "\n" : b64 + "\n";
3880
+ const result = machineKey ? "encrypted" : "plaintext";
3881
+ const tmpPath = keyPath + ".tmp";
3882
+ try {
3883
+ if (existsSync8(keyPath)) {
3884
+ await copyFile(keyPath, keyPath + ".bak").catch(() => {
3885
+ });
3886
+ }
3887
+ await writeFile3(tmpPath, content, "utf-8");
3888
+ await chmod2(tmpPath, 384);
3889
+ await rename(tmpPath, keyPath);
3890
+ } catch (err) {
3891
+ try {
3892
+ await unlink(tmpPath);
3893
+ } catch {
3894
+ }
3895
+ throw err;
3874
3896
  }
3875
- await writeFile3(keyPath, b64 + "\n", "utf-8");
3876
- await chmod2(keyPath, 384);
3877
- return "plaintext";
3897
+ return result;
3878
3898
  }
3879
3899
  async function getMasterKey() {
3880
3900
  let nativeValue = macKeychainGet() ?? linuxSecretGet();
@@ -10168,10 +10188,8 @@ function spawnEmployee(employeeName, exeSession2, projectDir, opts) {
10168
10188
  }
10169
10189
  if (!useExeAgent && !useCodex && !useOpencode && !useBinSymlink) {
10170
10190
  if (agentRtConfig.runtime === "claude" && agentRtConfig.model) {
10171
- let ccModel = agentRtConfig.model.replace(/(\d+)\.(\d+)/g, "$1-$2");
10172
- if (/claude-(opus|sonnet)-4-[6-9]/.test(ccModel) && !ccModel.includes("[1m]")) {
10173
- ccModel += "[1m]";
10174
- }
10191
+ const { normalizeCcModelName: normalizeCcModelName2 } = (init_agent_config(), __toCommonJS(agent_config_exports));
10192
+ const ccModel = normalizeCcModelName2(agentRtConfig.model);
10175
10193
  envPrefix = `${envPrefix} ANTHROPIC_MODEL=${ccModel}`;
10176
10194
  }
10177
10195
  }
@@ -432,6 +432,7 @@ __export(agent_config_exports, {
432
432
  clearAgentRuntime: () => clearAgentRuntime,
433
433
  getAgentRuntime: () => getAgentRuntime,
434
434
  loadAgentConfig: () => loadAgentConfig,
435
+ normalizeCcModelName: () => normalizeCcModelName,
435
436
  saveAgentConfig: () => saveAgentConfig,
436
437
  setAgentMcps: () => setAgentMcps,
437
438
  setAgentRuntime: () => setAgentRuntime
@@ -460,6 +461,13 @@ function getAgentRuntime(agentId) {
460
461
  if (orgDefault) return orgDefault;
461
462
  return { runtime: DEFAULT_RUNTIME, model: DEFAULT_MODELS[DEFAULT_RUNTIME] };
462
463
  }
464
+ function normalizeCcModelName(model) {
465
+ let ccModel = model.replace(/(\d+)\.(\d+)/g, "$1-$2");
466
+ if (/claude-(opus|sonnet)-4-[6-9]/.test(ccModel) && !ccModel.includes("[1m]")) {
467
+ ccModel += "[1m]";
468
+ }
469
+ return ccModel;
470
+ }
463
471
  function setAgentRuntime(agentId, runtime, model, reasoning_effort, mcps) {
464
472
  const knownModels = KNOWN_RUNTIMES[runtime];
465
473
  if (!knownModels) {
@@ -5161,7 +5169,7 @@ function readOrCreateDaemonToken(homeDir = os9.homedir()) {
5161
5169
  function buildMcpHttpHeaders(homeDir = os9.homedir(), opts = {}) {
5162
5170
  const agentId = opts.useShellPlaceholders ? "${AGENT_ID:-exe}" : opts.agentId ?? DEFAULT_MCP_HTTP_AGENT_ID;
5163
5171
  const agentRole = opts.useShellPlaceholders ? "${AGENT_ROLE:-COO}" : opts.agentRole ?? DEFAULT_MCP_HTTP_AGENT_ROLE;
5164
- const sessionName = opts.useShellPlaceholders ? "$(tmux display-message -p '#{session_name}' 2>/dev/null || echo '')" : process.env.EXE_SESSION_NAME ?? "";
5172
+ const sessionName = opts.useShellPlaceholders ? "" : process.env.EXE_SESSION_NAME ?? "";
5165
5173
  const headers = {
5166
5174
  Authorization: `Bearer ${readOrCreateDaemonToken(homeDir)}`,
5167
5175
  "X-Agent-Id": agentId,
@@ -5714,7 +5722,7 @@ init_memory();
5714
5722
  init_database();
5715
5723
 
5716
5724
  // src/lib/keychain.ts
5717
- import { readFile as readFile3, writeFile as writeFile3, unlink, mkdir as mkdir3, chmod as chmod2 } from "fs/promises";
5725
+ import { readFile as readFile3, writeFile as writeFile3, unlink, mkdir as mkdir3, chmod as chmod2, rename, copyFile } from "fs/promises";
5718
5726
  import { existsSync as existsSync8, statSync as statSync3 } from "fs";
5719
5727
  import { execSync as execSync3 } from "child_process";
5720
5728
  import path7 from "path";
@@ -5753,12 +5761,14 @@ function linuxSecretAvailable() {
5753
5761
  function isRootOnlyTrustedServerKeyFile(keyPath) {
5754
5762
  if (process.platform !== "linux") return false;
5755
5763
  try {
5756
- const uid = typeof os5.userInfo().uid === "number" ? os5.userInfo().uid : -1;
5757
5764
  const st = statSync3(keyPath);
5758
5765
  if (!st.isFile() || (st.mode & 63) !== 0) return false;
5766
+ const uid = typeof os5.userInfo().uid === "number" ? os5.userInfo().uid : -1;
5759
5767
  if (uid === 0) return true;
5760
5768
  const exeOsDir = process.env.EXE_OS_DIR;
5761
- return Boolean(exeOsDir && path7.resolve(keyPath).startsWith(path7.resolve(exeOsDir) + path7.sep));
5769
+ if (exeOsDir && path7.resolve(keyPath).startsWith(path7.resolve(exeOsDir) + path7.sep)) return true;
5770
+ if (!linuxSecretAvailable()) return true;
5771
+ return false;
5762
5772
  } catch {
5763
5773
  return false;
5764
5774
  }
@@ -5909,15 +5919,25 @@ async function writeMachineBoundFileFallback(b64) {
5909
5919
  await mkdir3(dir, { recursive: true });
5910
5920
  const keyPath = getKeyPath();
5911
5921
  const machineKey = deriveMachineKey();
5912
- if (machineKey) {
5913
- const encrypted = encryptWithMachineKey(b64, machineKey);
5914
- await writeFile3(keyPath, encrypted + "\n", "utf-8");
5915
- await chmod2(keyPath, 384);
5916
- return "encrypted";
5917
- }
5918
- await writeFile3(keyPath, b64 + "\n", "utf-8");
5919
- await chmod2(keyPath, 384);
5920
- return "plaintext";
5922
+ const content = machineKey ? encryptWithMachineKey(b64, machineKey) + "\n" : b64 + "\n";
5923
+ const result = machineKey ? "encrypted" : "plaintext";
5924
+ const tmpPath = keyPath + ".tmp";
5925
+ try {
5926
+ if (existsSync8(keyPath)) {
5927
+ await copyFile(keyPath, keyPath + ".bak").catch(() => {
5928
+ });
5929
+ }
5930
+ await writeFile3(tmpPath, content, "utf-8");
5931
+ await chmod2(tmpPath, 384);
5932
+ await rename(tmpPath, keyPath);
5933
+ } catch (err) {
5934
+ try {
5935
+ await unlink(tmpPath);
5936
+ } catch {
5937
+ }
5938
+ throw err;
5939
+ }
5940
+ return result;
5921
5941
  }
5922
5942
  async function getMasterKey() {
5923
5943
  let nativeValue = macKeychainGet() ?? linuxSecretGet();
@@ -432,6 +432,7 @@ __export(agent_config_exports, {
432
432
  clearAgentRuntime: () => clearAgentRuntime,
433
433
  getAgentRuntime: () => getAgentRuntime,
434
434
  loadAgentConfig: () => loadAgentConfig,
435
+ normalizeCcModelName: () => normalizeCcModelName,
435
436
  saveAgentConfig: () => saveAgentConfig,
436
437
  setAgentMcps: () => setAgentMcps,
437
438
  setAgentRuntime: () => setAgentRuntime
@@ -460,6 +461,13 @@ function getAgentRuntime(agentId) {
460
461
  if (orgDefault) return orgDefault;
461
462
  return { runtime: DEFAULT_RUNTIME, model: DEFAULT_MODELS[DEFAULT_RUNTIME] };
462
463
  }
464
+ function normalizeCcModelName(model) {
465
+ let ccModel = model.replace(/(\d+)\.(\d+)/g, "$1-$2");
466
+ if (/claude-(opus|sonnet)-4-[6-9]/.test(ccModel) && !ccModel.includes("[1m]")) {
467
+ ccModel += "[1m]";
468
+ }
469
+ return ccModel;
470
+ }
463
471
  function setAgentRuntime(agentId, runtime, model, reasoning_effort, mcps) {
464
472
  const knownModels = KNOWN_RUNTIMES[runtime];
465
473
  if (!knownModels) {
@@ -5151,7 +5159,7 @@ function readOrCreateDaemonToken(homeDir = os9.homedir()) {
5151
5159
  function buildMcpHttpHeaders(homeDir = os9.homedir(), opts = {}) {
5152
5160
  const agentId = opts.useShellPlaceholders ? "${AGENT_ID:-exe}" : opts.agentId ?? DEFAULT_MCP_HTTP_AGENT_ID;
5153
5161
  const agentRole = opts.useShellPlaceholders ? "${AGENT_ROLE:-COO}" : opts.agentRole ?? DEFAULT_MCP_HTTP_AGENT_ROLE;
5154
- const sessionName = opts.useShellPlaceholders ? "$(tmux display-message -p '#{session_name}' 2>/dev/null || echo '')" : process.env.EXE_SESSION_NAME ?? "";
5162
+ const sessionName = opts.useShellPlaceholders ? "" : process.env.EXE_SESSION_NAME ?? "";
5155
5163
  const headers = {
5156
5164
  Authorization: `Bearer ${readOrCreateDaemonToken(homeDir)}`,
5157
5165
  "X-Agent-Id": agentId,
@@ -5667,7 +5675,7 @@ init_memory();
5667
5675
  init_database();
5668
5676
 
5669
5677
  // src/lib/keychain.ts
5670
- import { readFile as readFile3, writeFile as writeFile3, unlink, mkdir as mkdir3, chmod as chmod2 } from "fs/promises";
5678
+ import { readFile as readFile3, writeFile as writeFile3, unlink, mkdir as mkdir3, chmod as chmod2, rename, copyFile } from "fs/promises";
5671
5679
  import { existsSync as existsSync8, statSync as statSync3 } from "fs";
5672
5680
  import { execSync as execSync3 } from "child_process";
5673
5681
  import path7 from "path";
@@ -5706,12 +5714,14 @@ function linuxSecretAvailable() {
5706
5714
  function isRootOnlyTrustedServerKeyFile(keyPath) {
5707
5715
  if (process.platform !== "linux") return false;
5708
5716
  try {
5709
- const uid = typeof os5.userInfo().uid === "number" ? os5.userInfo().uid : -1;
5710
5717
  const st = statSync3(keyPath);
5711
5718
  if (!st.isFile() || (st.mode & 63) !== 0) return false;
5719
+ const uid = typeof os5.userInfo().uid === "number" ? os5.userInfo().uid : -1;
5712
5720
  if (uid === 0) return true;
5713
5721
  const exeOsDir = process.env.EXE_OS_DIR;
5714
- return Boolean(exeOsDir && path7.resolve(keyPath).startsWith(path7.resolve(exeOsDir) + path7.sep));
5722
+ if (exeOsDir && path7.resolve(keyPath).startsWith(path7.resolve(exeOsDir) + path7.sep)) return true;
5723
+ if (!linuxSecretAvailable()) return true;
5724
+ return false;
5715
5725
  } catch {
5716
5726
  return false;
5717
5727
  }
@@ -5862,15 +5872,25 @@ async function writeMachineBoundFileFallback(b64) {
5862
5872
  await mkdir3(dir, { recursive: true });
5863
5873
  const keyPath = getKeyPath();
5864
5874
  const machineKey = deriveMachineKey();
5865
- if (machineKey) {
5866
- const encrypted = encryptWithMachineKey(b64, machineKey);
5867
- await writeFile3(keyPath, encrypted + "\n", "utf-8");
5868
- await chmod2(keyPath, 384);
5869
- return "encrypted";
5870
- }
5871
- await writeFile3(keyPath, b64 + "\n", "utf-8");
5872
- await chmod2(keyPath, 384);
5873
- return "plaintext";
5875
+ const content = machineKey ? encryptWithMachineKey(b64, machineKey) + "\n" : b64 + "\n";
5876
+ const result = machineKey ? "encrypted" : "plaintext";
5877
+ const tmpPath = keyPath + ".tmp";
5878
+ try {
5879
+ if (existsSync8(keyPath)) {
5880
+ await copyFile(keyPath, keyPath + ".bak").catch(() => {
5881
+ });
5882
+ }
5883
+ await writeFile3(tmpPath, content, "utf-8");
5884
+ await chmod2(tmpPath, 384);
5885
+ await rename(tmpPath, keyPath);
5886
+ } catch (err) {
5887
+ try {
5888
+ await unlink(tmpPath);
5889
+ } catch {
5890
+ }
5891
+ throw err;
5892
+ }
5893
+ return result;
5874
5894
  }
5875
5895
  async function getMasterKey() {
5876
5896
  let nativeValue = macKeychainGet() ?? linuxSecretGet();
@@ -3338,7 +3338,7 @@ var init_database = __esm({
3338
3338
  });
3339
3339
 
3340
3340
  // src/lib/keychain.ts
3341
- import { readFile as readFile3, writeFile as writeFile3, unlink, mkdir as mkdir3, chmod as chmod2 } from "fs/promises";
3341
+ import { readFile as readFile3, writeFile as writeFile3, unlink, mkdir as mkdir3, chmod as chmod2, rename, copyFile } from "fs/promises";
3342
3342
  import { existsSync as existsSync7, statSync as statSync3 } from "fs";
3343
3343
  import { execSync as execSync3 } from "child_process";
3344
3344
  import path6 from "path";
@@ -3373,12 +3373,14 @@ function linuxSecretAvailable() {
3373
3373
  function isRootOnlyTrustedServerKeyFile(keyPath) {
3374
3374
  if (process.platform !== "linux") return false;
3375
3375
  try {
3376
- const uid = typeof os5.userInfo().uid === "number" ? os5.userInfo().uid : -1;
3377
3376
  const st = statSync3(keyPath);
3378
3377
  if (!st.isFile() || (st.mode & 63) !== 0) return false;
3378
+ const uid = typeof os5.userInfo().uid === "number" ? os5.userInfo().uid : -1;
3379
3379
  if (uid === 0) return true;
3380
3380
  const exeOsDir = process.env.EXE_OS_DIR;
3381
- return Boolean(exeOsDir && path6.resolve(keyPath).startsWith(path6.resolve(exeOsDir) + path6.sep));
3381
+ if (exeOsDir && path6.resolve(keyPath).startsWith(path6.resolve(exeOsDir) + path6.sep)) return true;
3382
+ if (!linuxSecretAvailable()) return true;
3383
+ return false;
3382
3384
  } catch {
3383
3385
  return false;
3384
3386
  }
@@ -3528,15 +3530,25 @@ async function writeMachineBoundFileFallback(b64) {
3528
3530
  await mkdir3(dir, { recursive: true });
3529
3531
  const keyPath = getKeyPath();
3530
3532
  const machineKey = deriveMachineKey();
3531
- if (machineKey) {
3532
- const encrypted = encryptWithMachineKey(b64, machineKey);
3533
- await writeFile3(keyPath, encrypted + "\n", "utf-8");
3534
- await chmod2(keyPath, 384);
3535
- return "encrypted";
3536
- }
3537
- await writeFile3(keyPath, b64 + "\n", "utf-8");
3538
- await chmod2(keyPath, 384);
3539
- return "plaintext";
3533
+ const content = machineKey ? encryptWithMachineKey(b64, machineKey) + "\n" : b64 + "\n";
3534
+ const result = machineKey ? "encrypted" : "plaintext";
3535
+ const tmpPath = keyPath + ".tmp";
3536
+ try {
3537
+ if (existsSync7(keyPath)) {
3538
+ await copyFile(keyPath, keyPath + ".bak").catch(() => {
3539
+ });
3540
+ }
3541
+ await writeFile3(tmpPath, content, "utf-8");
3542
+ await chmod2(tmpPath, 384);
3543
+ await rename(tmpPath, keyPath);
3544
+ } catch (err) {
3545
+ try {
3546
+ await unlink(tmpPath);
3547
+ } catch {
3548
+ }
3549
+ throw err;
3550
+ }
3551
+ return result;
3540
3552
  }
3541
3553
  async function getMasterKey() {
3542
3554
  let nativeValue = macKeychainGet() ?? linuxSecretGet();
@@ -3327,7 +3327,7 @@ var init_database = __esm({
3327
3327
  });
3328
3328
 
3329
3329
  // src/lib/keychain.ts
3330
- import { readFile as readFile3, writeFile as writeFile3, unlink, mkdir as mkdir3, chmod as chmod2 } from "fs/promises";
3330
+ import { readFile as readFile3, writeFile as writeFile3, unlink, mkdir as mkdir3, chmod as chmod2, rename, copyFile } from "fs/promises";
3331
3331
  import { existsSync as existsSync7, statSync as statSync3 } from "fs";
3332
3332
  import { execSync as execSync3 } from "child_process";
3333
3333
  import path6 from "path";
@@ -3362,12 +3362,14 @@ function linuxSecretAvailable() {
3362
3362
  function isRootOnlyTrustedServerKeyFile(keyPath) {
3363
3363
  if (process.platform !== "linux") return false;
3364
3364
  try {
3365
- const uid = typeof os5.userInfo().uid === "number" ? os5.userInfo().uid : -1;
3366
3365
  const st = statSync3(keyPath);
3367
3366
  if (!st.isFile() || (st.mode & 63) !== 0) return false;
3367
+ const uid = typeof os5.userInfo().uid === "number" ? os5.userInfo().uid : -1;
3368
3368
  if (uid === 0) return true;
3369
3369
  const exeOsDir = process.env.EXE_OS_DIR;
3370
- return Boolean(exeOsDir && path6.resolve(keyPath).startsWith(path6.resolve(exeOsDir) + path6.sep));
3370
+ if (exeOsDir && path6.resolve(keyPath).startsWith(path6.resolve(exeOsDir) + path6.sep)) return true;
3371
+ if (!linuxSecretAvailable()) return true;
3372
+ return false;
3371
3373
  } catch {
3372
3374
  return false;
3373
3375
  }
@@ -3517,15 +3519,25 @@ async function writeMachineBoundFileFallback(b64) {
3517
3519
  await mkdir3(dir, { recursive: true });
3518
3520
  const keyPath = getKeyPath();
3519
3521
  const machineKey = deriveMachineKey();
3520
- if (machineKey) {
3521
- const encrypted = encryptWithMachineKey(b64, machineKey);
3522
- await writeFile3(keyPath, encrypted + "\n", "utf-8");
3523
- await chmod2(keyPath, 384);
3524
- return "encrypted";
3525
- }
3526
- await writeFile3(keyPath, b64 + "\n", "utf-8");
3527
- await chmod2(keyPath, 384);
3528
- return "plaintext";
3522
+ const content = machineKey ? encryptWithMachineKey(b64, machineKey) + "\n" : b64 + "\n";
3523
+ const result = machineKey ? "encrypted" : "plaintext";
3524
+ const tmpPath = keyPath + ".tmp";
3525
+ try {
3526
+ if (existsSync7(keyPath)) {
3527
+ await copyFile(keyPath, keyPath + ".bak").catch(() => {
3528
+ });
3529
+ }
3530
+ await writeFile3(tmpPath, content, "utf-8");
3531
+ await chmod2(tmpPath, 384);
3532
+ await rename(tmpPath, keyPath);
3533
+ } catch (err) {
3534
+ try {
3535
+ await unlink(tmpPath);
3536
+ } catch {
3537
+ }
3538
+ throw err;
3539
+ }
3540
+ return result;
3529
3541
  }
3530
3542
  async function getMasterKey() {
3531
3543
  let nativeValue = macKeychainGet() ?? linuxSecretGet();
@@ -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) {
@@ -7723,10 +7731,8 @@ function spawnEmployee(employeeName, exeSession, projectDir, opts) {
7723
7731
  }
7724
7732
  if (!useExeAgent && !useCodex && !useOpencode && !useBinSymlink) {
7725
7733
  if (agentRtConfig.runtime === "claude" && agentRtConfig.model) {
7726
- let ccModel = agentRtConfig.model.replace(/(\d+)\.(\d+)/g, "$1-$2");
7727
- if (/claude-(opus|sonnet)-4-[6-9]/.test(ccModel) && !ccModel.includes("[1m]")) {
7728
- ccModel += "[1m]";
7729
- }
7734
+ const { normalizeCcModelName: normalizeCcModelName2 } = (init_agent_config(), __toCommonJS(agent_config_exports));
7735
+ const ccModel = normalizeCcModelName2(agentRtConfig.model);
7730
7736
  envPrefix = `${envPrefix} ANTHROPIC_MODEL=${ccModel}`;
7731
7737
  }
7732
7738
  }
@@ -7891,7 +7897,7 @@ var init_task_scope = __esm({
7891
7897
  });
7892
7898
 
7893
7899
  // src/lib/keychain.ts
7894
- import { readFile as readFile4, writeFile as writeFile5, unlink, mkdir as mkdir4, chmod as chmod2 } from "fs/promises";
7900
+ import { readFile as readFile4, writeFile as writeFile5, unlink, mkdir as mkdir4, chmod as chmod2, rename, copyFile } from "fs/promises";
7895
7901
  import { existsSync as existsSync17, statSync as statSync3 } from "fs";
7896
7902
  import { execSync as execSync8 } from "child_process";
7897
7903
  import path19 from "path";
@@ -7926,12 +7932,14 @@ function linuxSecretAvailable() {
7926
7932
  function isRootOnlyTrustedServerKeyFile(keyPath) {
7927
7933
  if (process.platform !== "linux") return false;
7928
7934
  try {
7929
- const uid = typeof os12.userInfo().uid === "number" ? os12.userInfo().uid : -1;
7930
7935
  const st = statSync3(keyPath);
7931
7936
  if (!st.isFile() || (st.mode & 63) !== 0) return false;
7937
+ const uid = typeof os12.userInfo().uid === "number" ? os12.userInfo().uid : -1;
7932
7938
  if (uid === 0) return true;
7933
7939
  const exeOsDir = process.env.EXE_OS_DIR;
7934
- return Boolean(exeOsDir && path19.resolve(keyPath).startsWith(path19.resolve(exeOsDir) + path19.sep));
7940
+ if (exeOsDir && path19.resolve(keyPath).startsWith(path19.resolve(exeOsDir) + path19.sep)) return true;
7941
+ if (!linuxSecretAvailable()) return true;
7942
+ return false;
7935
7943
  } catch {
7936
7944
  return false;
7937
7945
  }
@@ -8081,15 +8089,25 @@ async function writeMachineBoundFileFallback(b64) {
8081
8089
  await mkdir4(dir, { recursive: true });
8082
8090
  const keyPath = getKeyPath();
8083
8091
  const machineKey = deriveMachineKey();
8084
- if (machineKey) {
8085
- const encrypted = encryptWithMachineKey(b64, machineKey);
8086
- await writeFile5(keyPath, encrypted + "\n", "utf-8");
8087
- await chmod2(keyPath, 384);
8088
- return "encrypted";
8089
- }
8090
- await writeFile5(keyPath, b64 + "\n", "utf-8");
8091
- await chmod2(keyPath, 384);
8092
- return "plaintext";
8092
+ const content = machineKey ? encryptWithMachineKey(b64, machineKey) + "\n" : b64 + "\n";
8093
+ const result = machineKey ? "encrypted" : "plaintext";
8094
+ const tmpPath = keyPath + ".tmp";
8095
+ try {
8096
+ if (existsSync17(keyPath)) {
8097
+ await copyFile(keyPath, keyPath + ".bak").catch(() => {
8098
+ });
8099
+ }
8100
+ await writeFile5(tmpPath, content, "utf-8");
8101
+ await chmod2(tmpPath, 384);
8102
+ await rename(tmpPath, keyPath);
8103
+ } catch (err) {
8104
+ try {
8105
+ await unlink(tmpPath);
8106
+ } catch {
8107
+ }
8108
+ throw err;
8109
+ }
8110
+ return result;
8093
8111
  }
8094
8112
  async function getMasterKey() {
8095
8113
  let nativeValue = macKeychainGet() ?? linuxSecretGet();
@@ -4385,7 +4385,7 @@ init_memory();
4385
4385
  init_database();
4386
4386
 
4387
4387
  // src/lib/keychain.ts
4388
- import { readFile as readFile3, writeFile as writeFile3, unlink, mkdir as mkdir3, chmod as chmod2 } from "fs/promises";
4388
+ import { readFile as readFile3, writeFile as writeFile3, unlink, mkdir as mkdir3, chmod as chmod2, rename, copyFile } from "fs/promises";
4389
4389
  import { existsSync as existsSync7, statSync as statSync3 } from "fs";
4390
4390
  import { execSync as execSync3 } from "child_process";
4391
4391
  import path6 from "path";
@@ -4424,12 +4424,14 @@ function linuxSecretAvailable() {
4424
4424
  function isRootOnlyTrustedServerKeyFile(keyPath) {
4425
4425
  if (process.platform !== "linux") return false;
4426
4426
  try {
4427
- const uid = typeof os5.userInfo().uid === "number" ? os5.userInfo().uid : -1;
4428
4427
  const st = statSync3(keyPath);
4429
4428
  if (!st.isFile() || (st.mode & 63) !== 0) return false;
4429
+ const uid = typeof os5.userInfo().uid === "number" ? os5.userInfo().uid : -1;
4430
4430
  if (uid === 0) return true;
4431
4431
  const exeOsDir = process.env.EXE_OS_DIR;
4432
- return Boolean(exeOsDir && path6.resolve(keyPath).startsWith(path6.resolve(exeOsDir) + path6.sep));
4432
+ if (exeOsDir && path6.resolve(keyPath).startsWith(path6.resolve(exeOsDir) + path6.sep)) return true;
4433
+ if (!linuxSecretAvailable()) return true;
4434
+ return false;
4433
4435
  } catch {
4434
4436
  return false;
4435
4437
  }
@@ -4580,15 +4582,25 @@ async function writeMachineBoundFileFallback(b64) {
4580
4582
  await mkdir3(dir, { recursive: true });
4581
4583
  const keyPath = getKeyPath();
4582
4584
  const machineKey = deriveMachineKey();
4583
- if (machineKey) {
4584
- const encrypted = encryptWithMachineKey(b64, machineKey);
4585
- await writeFile3(keyPath, encrypted + "\n", "utf-8");
4586
- await chmod2(keyPath, 384);
4587
- return "encrypted";
4588
- }
4589
- await writeFile3(keyPath, b64 + "\n", "utf-8");
4590
- await chmod2(keyPath, 384);
4591
- return "plaintext";
4585
+ const content = machineKey ? encryptWithMachineKey(b64, machineKey) + "\n" : b64 + "\n";
4586
+ const result = machineKey ? "encrypted" : "plaintext";
4587
+ const tmpPath = keyPath + ".tmp";
4588
+ try {
4589
+ if (existsSync7(keyPath)) {
4590
+ await copyFile(keyPath, keyPath + ".bak").catch(() => {
4591
+ });
4592
+ }
4593
+ await writeFile3(tmpPath, content, "utf-8");
4594
+ await chmod2(tmpPath, 384);
4595
+ await rename(tmpPath, keyPath);
4596
+ } catch (err) {
4597
+ try {
4598
+ await unlink(tmpPath);
4599
+ } catch {
4600
+ }
4601
+ throw err;
4602
+ }
4603
+ return result;
4592
4604
  }
4593
4605
  async function getMasterKey() {
4594
4606
  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();
@@ -181,6 +181,7 @@ __export(agent_config_exports, {
181
181
  clearAgentRuntime: () => clearAgentRuntime,
182
182
  getAgentRuntime: () => getAgentRuntime,
183
183
  loadAgentConfig: () => loadAgentConfig,
184
+ normalizeCcModelName: () => normalizeCcModelName,
184
185
  saveAgentConfig: () => saveAgentConfig,
185
186
  setAgentMcps: () => setAgentMcps,
186
187
  setAgentRuntime: () => setAgentRuntime
@@ -209,6 +210,13 @@ function getAgentRuntime(agentId) {
209
210
  if (orgDefault) return orgDefault;
210
211
  return { runtime: DEFAULT_RUNTIME, model: DEFAULT_MODELS[DEFAULT_RUNTIME] };
211
212
  }
213
+ function normalizeCcModelName(model) {
214
+ let ccModel = model.replace(/(\d+)\.(\d+)/g, "$1-$2");
215
+ if (/claude-(opus|sonnet)-4-[6-9]/.test(ccModel) && !ccModel.includes("[1m]")) {
216
+ ccModel += "[1m]";
217
+ }
218
+ return ccModel;
219
+ }
212
220
  function setAgentRuntime(agentId, runtime, model, reasoning_effort, mcps) {
213
221
  const knownModels = KNOWN_RUNTIMES[runtime];
214
222
  if (!knownModels) {
@@ -679,7 +687,7 @@ function readOrCreateDaemonToken(homeDir = os5.homedir()) {
679
687
  function buildMcpHttpHeaders(homeDir = os5.homedir(), opts = {}) {
680
688
  const agentId = opts.useShellPlaceholders ? "${AGENT_ID:-exe}" : opts.agentId ?? DEFAULT_MCP_HTTP_AGENT_ID;
681
689
  const agentRole = opts.useShellPlaceholders ? "${AGENT_ROLE:-COO}" : opts.agentRole ?? DEFAULT_MCP_HTTP_AGENT_ROLE;
682
- const sessionName = opts.useShellPlaceholders ? "$(tmux display-message -p '#{session_name}' 2>/dev/null || echo '')" : process.env.EXE_SESSION_NAME ?? "";
690
+ const sessionName = opts.useShellPlaceholders ? "" : process.env.EXE_SESSION_NAME ?? "";
683
691
  const headers = {
684
692
  Authorization: `Bearer ${readOrCreateDaemonToken(homeDir)}`,
685
693
  "X-Agent-Id": agentId,