@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
@@ -423,6 +423,7 @@ __export(agent_config_exports, {
423
423
  clearAgentRuntime: () => clearAgentRuntime,
424
424
  getAgentRuntime: () => getAgentRuntime,
425
425
  loadAgentConfig: () => loadAgentConfig,
426
+ normalizeCcModelName: () => normalizeCcModelName,
426
427
  saveAgentConfig: () => saveAgentConfig,
427
428
  setAgentMcps: () => setAgentMcps,
428
429
  setAgentRuntime: () => setAgentRuntime
@@ -451,6 +452,13 @@ function getAgentRuntime(agentId) {
451
452
  if (orgDefault) return orgDefault;
452
453
  return { runtime: DEFAULT_RUNTIME, model: DEFAULT_MODELS[DEFAULT_RUNTIME] };
453
454
  }
455
+ function normalizeCcModelName(model) {
456
+ let ccModel = model.replace(/(\d+)\.(\d+)/g, "$1-$2");
457
+ if (/claude-(opus|sonnet)-4-[6-9]/.test(ccModel) && !ccModel.includes("[1m]")) {
458
+ ccModel += "[1m]";
459
+ }
460
+ return ccModel;
461
+ }
454
462
  function setAgentRuntime(agentId, runtime, model, reasoning_effort, mcps) {
455
463
  const knownModels = KNOWN_RUNTIMES[runtime];
456
464
  if (!knownModels) {
@@ -3742,7 +3750,7 @@ var init_database = __esm({
3742
3750
  });
3743
3751
 
3744
3752
  // src/lib/keychain.ts
3745
- import { readFile as readFile3, writeFile as writeFile3, unlink, mkdir as mkdir3, chmod as chmod2 } from "fs/promises";
3753
+ import { readFile as readFile3, writeFile as writeFile3, unlink, mkdir as mkdir3, chmod as chmod2, rename, copyFile } from "fs/promises";
3746
3754
  import { existsSync as existsSync8, statSync as statSync3 } from "fs";
3747
3755
  import { execSync as execSync3 } from "child_process";
3748
3756
  import path7 from "path";
@@ -3777,12 +3785,14 @@ function linuxSecretAvailable() {
3777
3785
  function isRootOnlyTrustedServerKeyFile(keyPath) {
3778
3786
  if (process.platform !== "linux") return false;
3779
3787
  try {
3780
- const uid = typeof os5.userInfo().uid === "number" ? os5.userInfo().uid : -1;
3781
3788
  const st = statSync3(keyPath);
3782
3789
  if (!st.isFile() || (st.mode & 63) !== 0) return false;
3790
+ const uid = typeof os5.userInfo().uid === "number" ? os5.userInfo().uid : -1;
3783
3791
  if (uid === 0) return true;
3784
3792
  const exeOsDir = process.env.EXE_OS_DIR;
3785
- return Boolean(exeOsDir && path7.resolve(keyPath).startsWith(path7.resolve(exeOsDir) + path7.sep));
3793
+ if (exeOsDir && path7.resolve(keyPath).startsWith(path7.resolve(exeOsDir) + path7.sep)) return true;
3794
+ if (!linuxSecretAvailable()) return true;
3795
+ return false;
3786
3796
  } catch {
3787
3797
  return false;
3788
3798
  }
@@ -3932,15 +3942,25 @@ async function writeMachineBoundFileFallback(b64) {
3932
3942
  await mkdir3(dir, { recursive: true });
3933
3943
  const keyPath = getKeyPath();
3934
3944
  const machineKey = deriveMachineKey();
3935
- if (machineKey) {
3936
- const encrypted = encryptWithMachineKey(b64, machineKey);
3937
- await writeFile3(keyPath, encrypted + "\n", "utf-8");
3938
- await chmod2(keyPath, 384);
3939
- return "encrypted";
3945
+ const content = machineKey ? encryptWithMachineKey(b64, machineKey) + "\n" : b64 + "\n";
3946
+ const result = machineKey ? "encrypted" : "plaintext";
3947
+ const tmpPath = keyPath + ".tmp";
3948
+ try {
3949
+ if (existsSync8(keyPath)) {
3950
+ await copyFile(keyPath, keyPath + ".bak").catch(() => {
3951
+ });
3952
+ }
3953
+ await writeFile3(tmpPath, content, "utf-8");
3954
+ await chmod2(tmpPath, 384);
3955
+ await rename(tmpPath, keyPath);
3956
+ } catch (err) {
3957
+ try {
3958
+ await unlink(tmpPath);
3959
+ } catch {
3960
+ }
3961
+ throw err;
3940
3962
  }
3941
- await writeFile3(keyPath, b64 + "\n", "utf-8");
3942
- await chmod2(keyPath, 384);
3943
- return "plaintext";
3963
+ return result;
3944
3964
  }
3945
3965
  async function getMasterKey() {
3946
3966
  let nativeValue = macKeychainGet() ?? linuxSecretGet();
@@ -9946,10 +9966,8 @@ function spawnEmployee(employeeName, exeSession, projectDir, opts) {
9946
9966
  }
9947
9967
  if (!useExeAgent && !useCodex && !useOpencode && !useBinSymlink) {
9948
9968
  if (agentRtConfig.runtime === "claude" && agentRtConfig.model) {
9949
- let ccModel = agentRtConfig.model.replace(/(\d+)\.(\d+)/g, "$1-$2");
9950
- if (/claude-(opus|sonnet)-4-[6-9]/.test(ccModel) && !ccModel.includes("[1m]")) {
9951
- ccModel += "[1m]";
9952
- }
9969
+ const { normalizeCcModelName: normalizeCcModelName2 } = (init_agent_config(), __toCommonJS(agent_config_exports));
9970
+ const ccModel = normalizeCcModelName2(agentRtConfig.model);
9953
9971
  envPrefix = `${envPrefix} ANTHROPIC_MODEL=${ccModel}`;
9954
9972
  }
9955
9973
  }
@@ -672,6 +672,7 @@ __export(agent_config_exports, {
672
672
  clearAgentRuntime: () => clearAgentRuntime,
673
673
  getAgentRuntime: () => getAgentRuntime,
674
674
  loadAgentConfig: () => loadAgentConfig,
675
+ normalizeCcModelName: () => normalizeCcModelName,
675
676
  saveAgentConfig: () => saveAgentConfig,
676
677
  setAgentMcps: () => setAgentMcps,
677
678
  setAgentRuntime: () => setAgentRuntime
@@ -700,6 +701,13 @@ function getAgentRuntime(agentId) {
700
701
  if (orgDefault) return orgDefault;
701
702
  return { runtime: DEFAULT_RUNTIME, model: DEFAULT_MODELS[DEFAULT_RUNTIME] };
702
703
  }
704
+ function normalizeCcModelName(model) {
705
+ let ccModel = model.replace(/(\d+)\.(\d+)/g, "$1-$2");
706
+ if (/claude-(opus|sonnet)-4-[6-9]/.test(ccModel) && !ccModel.includes("[1m]")) {
707
+ ccModel += "[1m]";
708
+ }
709
+ return ccModel;
710
+ }
703
711
  function setAgentRuntime(agentId, runtime, model, reasoning_effort, mcps) {
704
712
  const knownModels = KNOWN_RUNTIMES[runtime];
705
713
  if (!knownModels) {
@@ -7794,10 +7802,8 @@ function spawnEmployee(employeeName, exeSession, projectDir, opts) {
7794
7802
  }
7795
7803
  if (!useExeAgent && !useCodex && !useOpencode && !useBinSymlink) {
7796
7804
  if (agentRtConfig.runtime === "claude" && agentRtConfig.model) {
7797
- let ccModel = agentRtConfig.model.replace(/(\d+)\.(\d+)/g, "$1-$2");
7798
- if (/claude-(opus|sonnet)-4-[6-9]/.test(ccModel) && !ccModel.includes("[1m]")) {
7799
- ccModel += "[1m]";
7800
- }
7805
+ const { normalizeCcModelName: normalizeCcModelName2 } = (init_agent_config(), __toCommonJS(agent_config_exports));
7806
+ const ccModel = normalizeCcModelName2(agentRtConfig.model);
7801
7807
  envPrefix = `${envPrefix} ANTHROPIC_MODEL=${ccModel}`;
7802
7808
  }
7803
7809
  }
@@ -7962,7 +7968,7 @@ var init_task_scope = __esm({
7962
7968
  });
7963
7969
 
7964
7970
  // src/lib/keychain.ts
7965
- import { readFile as readFile4, writeFile as writeFile5, unlink, mkdir as mkdir4, chmod as chmod2 } from "fs/promises";
7971
+ import { readFile as readFile4, writeFile as writeFile5, unlink, mkdir as mkdir4, chmod as chmod2, rename, copyFile } from "fs/promises";
7966
7972
  import { existsSync as existsSync17, statSync as statSync3 } from "fs";
7967
7973
  import { execSync as execSync8 } from "child_process";
7968
7974
  import path19 from "path";
@@ -7997,12 +8003,14 @@ function linuxSecretAvailable() {
7997
8003
  function isRootOnlyTrustedServerKeyFile(keyPath) {
7998
8004
  if (process.platform !== "linux") return false;
7999
8005
  try {
8000
- const uid = typeof os12.userInfo().uid === "number" ? os12.userInfo().uid : -1;
8001
8006
  const st = statSync3(keyPath);
8002
8007
  if (!st.isFile() || (st.mode & 63) !== 0) return false;
8008
+ const uid = typeof os12.userInfo().uid === "number" ? os12.userInfo().uid : -1;
8003
8009
  if (uid === 0) return true;
8004
8010
  const exeOsDir = process.env.EXE_OS_DIR;
8005
- return Boolean(exeOsDir && path19.resolve(keyPath).startsWith(path19.resolve(exeOsDir) + path19.sep));
8011
+ if (exeOsDir && path19.resolve(keyPath).startsWith(path19.resolve(exeOsDir) + path19.sep)) return true;
8012
+ if (!linuxSecretAvailable()) return true;
8013
+ return false;
8006
8014
  } catch {
8007
8015
  return false;
8008
8016
  }
@@ -8152,15 +8160,25 @@ async function writeMachineBoundFileFallback(b64) {
8152
8160
  await mkdir4(dir, { recursive: true });
8153
8161
  const keyPath = getKeyPath();
8154
8162
  const machineKey = deriveMachineKey();
8155
- if (machineKey) {
8156
- const encrypted = encryptWithMachineKey(b64, machineKey);
8157
- await writeFile5(keyPath, encrypted + "\n", "utf-8");
8158
- await chmod2(keyPath, 384);
8159
- return "encrypted";
8160
- }
8161
- await writeFile5(keyPath, b64 + "\n", "utf-8");
8162
- await chmod2(keyPath, 384);
8163
- return "plaintext";
8163
+ const content = machineKey ? encryptWithMachineKey(b64, machineKey) + "\n" : b64 + "\n";
8164
+ const result = machineKey ? "encrypted" : "plaintext";
8165
+ const tmpPath = keyPath + ".tmp";
8166
+ try {
8167
+ if (existsSync17(keyPath)) {
8168
+ await copyFile(keyPath, keyPath + ".bak").catch(() => {
8169
+ });
8170
+ }
8171
+ await writeFile5(tmpPath, content, "utf-8");
8172
+ await chmod2(tmpPath, 384);
8173
+ await rename(tmpPath, keyPath);
8174
+ } catch (err) {
8175
+ try {
8176
+ await unlink(tmpPath);
8177
+ } catch {
8178
+ }
8179
+ throw err;
8180
+ }
8181
+ return result;
8164
8182
  }
8165
8183
  async function getMasterKey() {
8166
8184
  let nativeValue = macKeychainGet() ?? linuxSecretGet();
package/dist/bin/setup.js CHANGED
@@ -330,7 +330,7 @@ __export(keychain_exports, {
330
330
  importMnemonic: () => importMnemonic,
331
331
  setMasterKey: () => setMasterKey
332
332
  });
333
- import { readFile as readFile2, writeFile as writeFile2, unlink, mkdir as mkdir2, chmod as chmod2 } from "fs/promises";
333
+ import { readFile as readFile2, writeFile as writeFile2, unlink, mkdir as mkdir2, chmod as chmod2, rename, copyFile } from "fs/promises";
334
334
  import { existsSync as existsSync3, statSync } from "fs";
335
335
  import { execSync } from "child_process";
336
336
  import path2 from "path";
@@ -365,12 +365,14 @@ function linuxSecretAvailable() {
365
365
  function isRootOnlyTrustedServerKeyFile(keyPath) {
366
366
  if (process.platform !== "linux") return false;
367
367
  try {
368
- const uid = typeof os2.userInfo().uid === "number" ? os2.userInfo().uid : -1;
369
368
  const st = statSync(keyPath);
370
369
  if (!st.isFile() || (st.mode & 63) !== 0) return false;
370
+ const uid = typeof os2.userInfo().uid === "number" ? os2.userInfo().uid : -1;
371
371
  if (uid === 0) return true;
372
372
  const exeOsDir = process.env.EXE_OS_DIR;
373
- return Boolean(exeOsDir && path2.resolve(keyPath).startsWith(path2.resolve(exeOsDir) + path2.sep));
373
+ if (exeOsDir && path2.resolve(keyPath).startsWith(path2.resolve(exeOsDir) + path2.sep)) return true;
374
+ if (!linuxSecretAvailable()) return true;
375
+ return false;
374
376
  } catch {
375
377
  return false;
376
378
  }
@@ -520,15 +522,25 @@ async function writeMachineBoundFileFallback(b64) {
520
522
  await mkdir2(dir, { recursive: true });
521
523
  const keyPath = getKeyPath();
522
524
  const machineKey = deriveMachineKey();
523
- if (machineKey) {
524
- const encrypted = encryptWithMachineKey(b64, machineKey);
525
- await writeFile2(keyPath, encrypted + "\n", "utf-8");
526
- await chmod2(keyPath, 384);
527
- return "encrypted";
525
+ const content = machineKey ? encryptWithMachineKey(b64, machineKey) + "\n" : b64 + "\n";
526
+ const result = machineKey ? "encrypted" : "plaintext";
527
+ const tmpPath = keyPath + ".tmp";
528
+ try {
529
+ if (existsSync3(keyPath)) {
530
+ await copyFile(keyPath, keyPath + ".bak").catch(() => {
531
+ });
532
+ }
533
+ await writeFile2(tmpPath, content, "utf-8");
534
+ await chmod2(tmpPath, 384);
535
+ await rename(tmpPath, keyPath);
536
+ } catch (err) {
537
+ try {
538
+ await unlink(tmpPath);
539
+ } catch {
540
+ }
541
+ throw err;
528
542
  }
529
- await writeFile2(keyPath, b64 + "\n", "utf-8");
530
- await chmod2(keyPath, 384);
531
- return "plaintext";
543
+ return result;
532
544
  }
533
545
  async function getMasterKey() {
534
546
  let nativeValue = macKeychainGet() ?? linuxSecretGet();
@@ -1963,6 +1975,7 @@ __export(agent_config_exports, {
1963
1975
  clearAgentRuntime: () => clearAgentRuntime,
1964
1976
  getAgentRuntime: () => getAgentRuntime,
1965
1977
  loadAgentConfig: () => loadAgentConfig,
1978
+ normalizeCcModelName: () => normalizeCcModelName,
1966
1979
  saveAgentConfig: () => saveAgentConfig,
1967
1980
  setAgentMcps: () => setAgentMcps,
1968
1981
  setAgentRuntime: () => setAgentRuntime
@@ -1991,6 +2004,13 @@ function getAgentRuntime(agentId) {
1991
2004
  if (orgDefault) return orgDefault;
1992
2005
  return { runtime: DEFAULT_RUNTIME, model: DEFAULT_MODELS[DEFAULT_RUNTIME] };
1993
2006
  }
2007
+ function normalizeCcModelName(model) {
2008
+ let ccModel = model.replace(/(\d+)\.(\d+)/g, "$1-$2");
2009
+ if (/claude-(opus|sonnet)-4-[6-9]/.test(ccModel) && !ccModel.includes("[1m]")) {
2010
+ ccModel += "[1m]";
2011
+ }
2012
+ return ccModel;
2013
+ }
1994
2014
  function setAgentRuntime(agentId, runtime, model, reasoning_effort, mcps) {
1995
2015
  const knownModels = KNOWN_RUNTIMES[runtime];
1996
2016
  if (!knownModels) {
@@ -5151,6 +5171,7 @@ __export(cloud_sync_exports, {
5151
5171
  markCloudReuploadRequired: () => markCloudReuploadRequired,
5152
5172
  mergeConfig: () => mergeConfig,
5153
5173
  mergeRosterFromRemote: () => mergeRosterFromRemote,
5174
+ migrateEndpoint: () => migrateEndpoint,
5154
5175
  pushToPostgres: () => pushToPostgres,
5155
5176
  recordRosterDeletion: () => recordRosterDeletion
5156
5177
  });
@@ -5321,6 +5342,15 @@ async function fetchWithRetry(url, init) {
5321
5342
  }
5322
5343
  throw lastError;
5323
5344
  }
5345
+ function migrateEndpoint(endpoint) {
5346
+ if (endpoint === "https://askexe.com/cloud" || endpoint === "https://askexe.com/cloud/") {
5347
+ process.stderr.write(
5348
+ "[cloud-sync] Auto-migrating endpoint from askexe.com/cloud to cloud.askexe.com (bypasses Cloudflare WAF for datacenter IPs)\n"
5349
+ );
5350
+ return "https://cloud.askexe.com";
5351
+ }
5352
+ return endpoint;
5353
+ }
5324
5354
  function assertSecureEndpoint(endpoint) {
5325
5355
  if (endpoint.startsWith("https://")) return;
5326
5356
  if (endpoint.startsWith("http://")) {
@@ -5458,6 +5488,7 @@ async function markCloudReuploadRequired(client = getClient()) {
5458
5488
  await client.execute("INSERT OR REPLACE INTO sync_meta (key, value) VALUES ('cloud_reupload_required', '1')");
5459
5489
  }
5460
5490
  async function cloudSync(config) {
5491
+ config = { ...config, endpoint: migrateEndpoint(config.endpoint) };
5461
5492
  if (!isSyncCryptoInitialized()) {
5462
5493
  try {
5463
5494
  const { getMasterKey: getMasterKey2 } = await Promise.resolve().then(() => (init_keychain(), keychain_exports));
@@ -8796,6 +8827,24 @@ async function runSetupWizard(opts = {}) {
8796
8827
  log("");
8797
8828
  log("=== exe-os Setup ===");
8798
8829
  log("");
8830
+ if (process.platform === "darwin") {
8831
+ const currentShell = process.env.SHELL ?? "";
8832
+ if (currentShell.includes("bash")) {
8833
+ log(" \u26A0 Your default shell is bash.");
8834
+ log(" macOS uses zsh by default since Catalina (2019).");
8835
+ log(" exe-os works with bash, but switching to zsh is recommended:");
8836
+ log(" chsh -s /bin/zsh");
8837
+ log(" Then restart your terminal.");
8838
+ log("");
8839
+ const cont = await ask(rl, " Continue with bash? (y/n, default: y): ");
8840
+ if (cont.toLowerCase() === "n") {
8841
+ log(" Run `chsh -s /bin/zsh`, restart your terminal, then run setup again.");
8842
+ rl.close();
8843
+ return;
8844
+ }
8845
+ log("");
8846
+ }
8847
+ }
8799
8848
  log("What are you setting up?");
8800
8849
  log("");
8801
8850
  log(" [1] First device / brand new Exe OS memory");
@@ -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();
@@ -733,6 +733,7 @@ __export(agent_config_exports, {
733
733
  clearAgentRuntime: () => clearAgentRuntime,
734
734
  getAgentRuntime: () => getAgentRuntime,
735
735
  loadAgentConfig: () => loadAgentConfig,
736
+ normalizeCcModelName: () => normalizeCcModelName,
736
737
  saveAgentConfig: () => saveAgentConfig,
737
738
  setAgentMcps: () => setAgentMcps,
738
739
  setAgentRuntime: () => setAgentRuntime
@@ -761,6 +762,13 @@ function getAgentRuntime(agentId) {
761
762
  if (orgDefault) return orgDefault;
762
763
  return { runtime: DEFAULT_RUNTIME, model: DEFAULT_MODELS[DEFAULT_RUNTIME] };
763
764
  }
765
+ function normalizeCcModelName(model) {
766
+ let ccModel = model.replace(/(\d+)\.(\d+)/g, "$1-$2");
767
+ if (/claude-(opus|sonnet)-4-[6-9]/.test(ccModel) && !ccModel.includes("[1m]")) {
768
+ ccModel += "[1m]";
769
+ }
770
+ return ccModel;
771
+ }
764
772
  function setAgentRuntime(agentId, runtime, model, reasoning_effort, mcps) {
765
773
  const knownModels = KNOWN_RUNTIMES[runtime];
766
774
  if (!knownModels) {
@@ -4054,7 +4062,7 @@ var init_embedder = __esm({
4054
4062
  });
4055
4063
 
4056
4064
  // src/lib/keychain.ts
4057
- import { readFile as readFile3, writeFile as writeFile3, unlink, mkdir as mkdir3, chmod as chmod2 } from "fs/promises";
4065
+ import { readFile as readFile3, writeFile as writeFile3, unlink, mkdir as mkdir3, chmod as chmod2, rename, copyFile } from "fs/promises";
4058
4066
  import { existsSync as existsSync8, statSync as statSync3 } from "fs";
4059
4067
  import { execSync as execSync3 } from "child_process";
4060
4068
  import path7 from "path";
@@ -4089,12 +4097,14 @@ function linuxSecretAvailable() {
4089
4097
  function isRootOnlyTrustedServerKeyFile(keyPath) {
4090
4098
  if (process.platform !== "linux") return false;
4091
4099
  try {
4092
- const uid = typeof os5.userInfo().uid === "number" ? os5.userInfo().uid : -1;
4093
4100
  const st = statSync3(keyPath);
4094
4101
  if (!st.isFile() || (st.mode & 63) !== 0) return false;
4102
+ const uid = typeof os5.userInfo().uid === "number" ? os5.userInfo().uid : -1;
4095
4103
  if (uid === 0) return true;
4096
4104
  const exeOsDir = process.env.EXE_OS_DIR;
4097
- return Boolean(exeOsDir && path7.resolve(keyPath).startsWith(path7.resolve(exeOsDir) + path7.sep));
4105
+ if (exeOsDir && path7.resolve(keyPath).startsWith(path7.resolve(exeOsDir) + path7.sep)) return true;
4106
+ if (!linuxSecretAvailable()) return true;
4107
+ return false;
4098
4108
  } catch {
4099
4109
  return false;
4100
4110
  }
@@ -4244,15 +4254,25 @@ async function writeMachineBoundFileFallback(b64) {
4244
4254
  await mkdir3(dir, { recursive: true });
4245
4255
  const keyPath = getKeyPath();
4246
4256
  const machineKey = deriveMachineKey();
4247
- if (machineKey) {
4248
- const encrypted = encryptWithMachineKey(b64, machineKey);
4249
- await writeFile3(keyPath, encrypted + "\n", "utf-8");
4250
- await chmod2(keyPath, 384);
4251
- return "encrypted";
4257
+ const content = machineKey ? encryptWithMachineKey(b64, machineKey) + "\n" : b64 + "\n";
4258
+ const result = machineKey ? "encrypted" : "plaintext";
4259
+ const tmpPath = keyPath + ".tmp";
4260
+ try {
4261
+ if (existsSync8(keyPath)) {
4262
+ await copyFile(keyPath, keyPath + ".bak").catch(() => {
4263
+ });
4264
+ }
4265
+ await writeFile3(tmpPath, content, "utf-8");
4266
+ await chmod2(tmpPath, 384);
4267
+ await rename(tmpPath, keyPath);
4268
+ } catch (err) {
4269
+ try {
4270
+ await unlink(tmpPath);
4271
+ } catch {
4272
+ }
4273
+ throw err;
4252
4274
  }
4253
- await writeFile3(keyPath, b64 + "\n", "utf-8");
4254
- await chmod2(keyPath, 384);
4255
- return "plaintext";
4275
+ return result;
4256
4276
  }
4257
4277
  async function getMasterKey() {
4258
4278
  let nativeValue = macKeychainGet() ?? linuxSecretGet();
@@ -11636,10 +11656,8 @@ function spawnEmployee(employeeName, exeSession, projectDir, opts) {
11636
11656
  }
11637
11657
  if (!useExeAgent && !useCodex && !useOpencode && !useBinSymlink) {
11638
11658
  if (agentRtConfig.runtime === "claude" && agentRtConfig.model) {
11639
- let ccModel = agentRtConfig.model.replace(/(\d+)\.(\d+)/g, "$1-$2");
11640
- if (/claude-(opus|sonnet)-4-[6-9]/.test(ccModel) && !ccModel.includes("[1m]")) {
11641
- ccModel += "[1m]";
11642
- }
11659
+ const { normalizeCcModelName: normalizeCcModelName2 } = (init_agent_config(), __toCommonJS(agent_config_exports));
11660
+ const ccModel = normalizeCcModelName2(agentRtConfig.model);
11643
11661
  envPrefix = `${envPrefix} ANTHROPIC_MODEL=${ccModel}`;
11644
11662
  }
11645
11663
  }
@@ -422,6 +422,7 @@ __export(agent_config_exports, {
422
422
  clearAgentRuntime: () => clearAgentRuntime,
423
423
  getAgentRuntime: () => getAgentRuntime,
424
424
  loadAgentConfig: () => loadAgentConfig,
425
+ normalizeCcModelName: () => normalizeCcModelName,
425
426
  saveAgentConfig: () => saveAgentConfig,
426
427
  setAgentMcps: () => setAgentMcps,
427
428
  setAgentRuntime: () => setAgentRuntime
@@ -450,6 +451,13 @@ function getAgentRuntime(agentId) {
450
451
  if (orgDefault) return orgDefault;
451
452
  return { runtime: DEFAULT_RUNTIME, model: DEFAULT_MODELS[DEFAULT_RUNTIME] };
452
453
  }
454
+ function normalizeCcModelName(model) {
455
+ let ccModel = model.replace(/(\d+)\.(\d+)/g, "$1-$2");
456
+ if (/claude-(opus|sonnet)-4-[6-9]/.test(ccModel) && !ccModel.includes("[1m]")) {
457
+ ccModel += "[1m]";
458
+ }
459
+ return ccModel;
460
+ }
453
461
  function setAgentRuntime(agentId, runtime, model, reasoning_effort, mcps) {
454
462
  const knownModels = KNOWN_RUNTIMES[runtime];
455
463
  if (!knownModels) {
@@ -3741,7 +3749,7 @@ var init_database = __esm({
3741
3749
  });
3742
3750
 
3743
3751
  // src/lib/keychain.ts
3744
- import { readFile as readFile3, writeFile as writeFile3, unlink, mkdir as mkdir3, chmod as chmod2 } from "fs/promises";
3752
+ import { readFile as readFile3, writeFile as writeFile3, unlink, mkdir as mkdir3, chmod as chmod2, rename, copyFile } from "fs/promises";
3745
3753
  import { existsSync as existsSync8, statSync as statSync3 } from "fs";
3746
3754
  import { execSync as execSync3 } from "child_process";
3747
3755
  import path7 from "path";
@@ -3776,12 +3784,14 @@ function linuxSecretAvailable() {
3776
3784
  function isRootOnlyTrustedServerKeyFile(keyPath) {
3777
3785
  if (process.platform !== "linux") return false;
3778
3786
  try {
3779
- const uid = typeof os5.userInfo().uid === "number" ? os5.userInfo().uid : -1;
3780
3787
  const st = statSync3(keyPath);
3781
3788
  if (!st.isFile() || (st.mode & 63) !== 0) return false;
3789
+ const uid = typeof os5.userInfo().uid === "number" ? os5.userInfo().uid : -1;
3782
3790
  if (uid === 0) return true;
3783
3791
  const exeOsDir = process.env.EXE_OS_DIR;
3784
- return Boolean(exeOsDir && path7.resolve(keyPath).startsWith(path7.resolve(exeOsDir) + path7.sep));
3792
+ if (exeOsDir && path7.resolve(keyPath).startsWith(path7.resolve(exeOsDir) + path7.sep)) return true;
3793
+ if (!linuxSecretAvailable()) return true;
3794
+ return false;
3785
3795
  } catch {
3786
3796
  return false;
3787
3797
  }
@@ -3931,15 +3941,25 @@ async function writeMachineBoundFileFallback(b64) {
3931
3941
  await mkdir3(dir, { recursive: true });
3932
3942
  const keyPath = getKeyPath();
3933
3943
  const machineKey = deriveMachineKey();
3934
- if (machineKey) {
3935
- const encrypted = encryptWithMachineKey(b64, machineKey);
3936
- await writeFile3(keyPath, encrypted + "\n", "utf-8");
3937
- await chmod2(keyPath, 384);
3938
- return "encrypted";
3944
+ const content = machineKey ? encryptWithMachineKey(b64, machineKey) + "\n" : b64 + "\n";
3945
+ const result = machineKey ? "encrypted" : "plaintext";
3946
+ const tmpPath = keyPath + ".tmp";
3947
+ try {
3948
+ if (existsSync8(keyPath)) {
3949
+ await copyFile(keyPath, keyPath + ".bak").catch(() => {
3950
+ });
3951
+ }
3952
+ await writeFile3(tmpPath, content, "utf-8");
3953
+ await chmod2(tmpPath, 384);
3954
+ await rename(tmpPath, keyPath);
3955
+ } catch (err) {
3956
+ try {
3957
+ await unlink(tmpPath);
3958
+ } catch {
3959
+ }
3960
+ throw err;
3939
3961
  }
3940
- await writeFile3(keyPath, b64 + "\n", "utf-8");
3941
- await chmod2(keyPath, 384);
3942
- return "plaintext";
3962
+ return result;
3943
3963
  }
3944
3964
  async function getMasterKey() {
3945
3965
  let nativeValue = macKeychainGet() ?? linuxSecretGet();
@@ -8632,10 +8652,8 @@ function spawnEmployee(employeeName, exeSession, projectDir, opts) {
8632
8652
  }
8633
8653
  if (!useExeAgent && !useCodex && !useOpencode && !useBinSymlink) {
8634
8654
  if (agentRtConfig.runtime === "claude" && agentRtConfig.model) {
8635
- let ccModel = agentRtConfig.model.replace(/(\d+)\.(\d+)/g, "$1-$2");
8636
- if (/claude-(opus|sonnet)-4-[6-9]/.test(ccModel) && !ccModel.includes("[1m]")) {
8637
- ccModel += "[1m]";
8638
- }
8655
+ const { normalizeCcModelName: normalizeCcModelName2 } = (init_agent_config(), __toCommonJS(agent_config_exports));
8656
+ const ccModel = normalizeCcModelName2(agentRtConfig.model);
8639
8657
  envPrefix = `${envPrefix} ANTHROPIC_MODEL=${ccModel}`;
8640
8658
  }
8641
8659
  }
@@ -367,6 +367,7 @@ __export(agent_config_exports, {
367
367
  clearAgentRuntime: () => clearAgentRuntime,
368
368
  getAgentRuntime: () => getAgentRuntime,
369
369
  loadAgentConfig: () => loadAgentConfig,
370
+ normalizeCcModelName: () => normalizeCcModelName,
370
371
  saveAgentConfig: () => saveAgentConfig,
371
372
  setAgentMcps: () => setAgentMcps,
372
373
  setAgentRuntime: () => setAgentRuntime
@@ -395,6 +396,13 @@ function getAgentRuntime(agentId) {
395
396
  if (orgDefault) return orgDefault;
396
397
  return { runtime: DEFAULT_RUNTIME, model: DEFAULT_MODELS[DEFAULT_RUNTIME] };
397
398
  }
399
+ function normalizeCcModelName(model) {
400
+ let ccModel = model.replace(/(\d+)\.(\d+)/g, "$1-$2");
401
+ if (/claude-(opus|sonnet)-4-[6-9]/.test(ccModel) && !ccModel.includes("[1m]")) {
402
+ ccModel += "[1m]";
403
+ }
404
+ return ccModel;
405
+ }
398
406
  function setAgentRuntime(agentId, runtime, model, reasoning_effort, mcps) {
399
407
  const knownModels = KNOWN_RUNTIMES[runtime];
400
408
  if (!knownModels) {
@@ -3741,7 +3749,7 @@ var init_database = __esm({
3741
3749
  });
3742
3750
 
3743
3751
  // src/lib/keychain.ts
3744
- import { readFile as readFile3, writeFile as writeFile3, unlink, mkdir as mkdir3, chmod as chmod2 } from "fs/promises";
3752
+ import { readFile as readFile3, writeFile as writeFile3, unlink, mkdir as mkdir3, chmod as chmod2, rename, copyFile } from "fs/promises";
3745
3753
  import { existsSync as existsSync8, statSync as statSync3 } from "fs";
3746
3754
  import { execSync as execSync3 } from "child_process";
3747
3755
  import path7 from "path";
@@ -3776,12 +3784,14 @@ function linuxSecretAvailable() {
3776
3784
  function isRootOnlyTrustedServerKeyFile(keyPath) {
3777
3785
  if (process.platform !== "linux") return false;
3778
3786
  try {
3779
- const uid = typeof os5.userInfo().uid === "number" ? os5.userInfo().uid : -1;
3780
3787
  const st = statSync3(keyPath);
3781
3788
  if (!st.isFile() || (st.mode & 63) !== 0) return false;
3789
+ const uid = typeof os5.userInfo().uid === "number" ? os5.userInfo().uid : -1;
3782
3790
  if (uid === 0) return true;
3783
3791
  const exeOsDir = process.env.EXE_OS_DIR;
3784
- return Boolean(exeOsDir && path7.resolve(keyPath).startsWith(path7.resolve(exeOsDir) + path7.sep));
3792
+ if (exeOsDir && path7.resolve(keyPath).startsWith(path7.resolve(exeOsDir) + path7.sep)) return true;
3793
+ if (!linuxSecretAvailable()) return true;
3794
+ return false;
3785
3795
  } catch {
3786
3796
  return false;
3787
3797
  }
@@ -3931,15 +3941,25 @@ async function writeMachineBoundFileFallback(b64) {
3931
3941
  await mkdir3(dir, { recursive: true });
3932
3942
  const keyPath = getKeyPath();
3933
3943
  const machineKey = deriveMachineKey();
3934
- if (machineKey) {
3935
- const encrypted = encryptWithMachineKey(b64, machineKey);
3936
- await writeFile3(keyPath, encrypted + "\n", "utf-8");
3937
- await chmod2(keyPath, 384);
3938
- return "encrypted";
3939
- }
3940
- await writeFile3(keyPath, b64 + "\n", "utf-8");
3941
- await chmod2(keyPath, 384);
3942
- return "plaintext";
3944
+ const content = machineKey ? encryptWithMachineKey(b64, machineKey) + "\n" : b64 + "\n";
3945
+ const result = machineKey ? "encrypted" : "plaintext";
3946
+ const tmpPath = keyPath + ".tmp";
3947
+ try {
3948
+ if (existsSync8(keyPath)) {
3949
+ await copyFile(keyPath, keyPath + ".bak").catch(() => {
3950
+ });
3951
+ }
3952
+ await writeFile3(tmpPath, content, "utf-8");
3953
+ await chmod2(tmpPath, 384);
3954
+ await rename(tmpPath, keyPath);
3955
+ } catch (err) {
3956
+ try {
3957
+ await unlink(tmpPath);
3958
+ } catch {
3959
+ }
3960
+ throw err;
3961
+ }
3962
+ return result;
3943
3963
  }
3944
3964
  async function getMasterKey() {
3945
3965
  let nativeValue = macKeychainGet() ?? linuxSecretGet();