@adhdev/daemon-standalone 1.0.45-rc.7 → 1.0.45-rc.8

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.
package/dist/index.js CHANGED
@@ -37027,10 +37027,10 @@ var require_dist3 = __commonJS({
37027
37027
  }
37028
37028
  function getDaemonBuildInfo() {
37029
37029
  if (cached2) return cached2;
37030
- const commit = readInjected(true ? "c935da6be0da24d1e046a4ecb5139e8490dba7b4" : void 0) ?? "unknown";
37031
- const commitShort = readInjected(true ? "c935da6b" : void 0) ?? (commit !== "unknown" ? commit.slice(0, 7) : "unknown");
37032
- const version2 = readInjected(true ? "1.0.45-rc.7" : void 0) ?? readInjected(typeof process !== "undefined" ? process.env?.ADHDEV_PKG_VERSION : void 0) ?? "unknown";
37033
- const builtAt = readInjected(true ? "2026-08-12T10:49:30.678Z" : void 0);
37030
+ const commit = readInjected(true ? "d95b1439eb1b062960654db2dd2d523a0831d1eb" : void 0) ?? "unknown";
37031
+ const commitShort = readInjected(true ? "d95b1439" : void 0) ?? (commit !== "unknown" ? commit.slice(0, 7) : "unknown");
37032
+ const version2 = readInjected(true ? "1.0.45-rc.8" : void 0) ?? readInjected(typeof process !== "undefined" ? process.env?.ADHDEV_PKG_VERSION : void 0) ?? "unknown";
37033
+ const builtAt = readInjected(true ? "2026-08-12T15:27:41.488Z" : void 0);
37034
37034
  cached2 = builtAt ? { commit, commitShort, version: version2, builtAt } : { commit, commitShort, version: version2 };
37035
37035
  return cached2;
37036
37036
  }
@@ -37802,40 +37802,38 @@ var require_dist3 = __commonJS({
37802
37802
  async function getSubmoduleStatuses(repo, options) {
37803
37803
  if (!repo.repoRoot) return { submodules: [], headOidByPath: /* @__PURE__ */ new Map() };
37804
37804
  try {
37805
- const { submodules, headOidByPath } = await deriveSubmoduleGitlinkStatuses(repo, options);
37806
- await Promise.all(submodules.map((submodule) => enrichSubmoduleWorktreeStatus(repo, submodule, options)));
37805
+ const paths = await readSubmodulePaths(repo, options);
37806
+ const ignoreSet = new Set(options.submoduleIgnorePaths || []);
37807
+ const visiblePaths = paths.filter((path54) => !ignoreSet.has(path54));
37808
+ const expectedByPath = await readGitlinkExpectedShas(repo, visiblePaths, options);
37809
+ const lastCheckedAt = Date.now();
37810
+ const headOidByPath = /* @__PURE__ */ new Map();
37811
+ const submodules = await Promise.all(
37812
+ visiblePaths.map(async (path54) => {
37813
+ const repoPath = repo.repoRoot + "/" + path54;
37814
+ const expected = expectedByPath.get(path54) ?? null;
37815
+ const worktree = await readSubmoduleWorktreeStatus(repo, repoPath, options);
37816
+ const actual = worktree.headOid;
37817
+ if (actual) headOidByPath.set(path54, actual);
37818
+ const outOfSync = actual === null ? true : expected !== null && expected !== actual;
37819
+ return {
37820
+ path: path54,
37821
+ // Prefer the recorded gitlink SHA (matches the legacy column); fall back
37822
+ // to the checked-out SHA so the field is never empty when both are known.
37823
+ commit: expected ?? actual ?? "",
37824
+ repoPath,
37825
+ dirty: worktree.dirty,
37826
+ outOfSync,
37827
+ lastCheckedAt,
37828
+ ...worktree.error ? { error: worktree.error } : {}
37829
+ };
37830
+ })
37831
+ );
37807
37832
  return { submodules, headOidByPath };
37808
37833
  } catch {
37809
37834
  return { submodules: [], headOidByPath: /* @__PURE__ */ new Map() };
37810
37835
  }
37811
37836
  }
37812
- async function deriveSubmoduleGitlinkStatuses(repo, options) {
37813
- if (!repo.repoRoot) return { submodules: [], headOidByPath: /* @__PURE__ */ new Map() };
37814
- const paths = await readSubmodulePaths(repo, options);
37815
- const ignoreSet = new Set(options.submoduleIgnorePaths || []);
37816
- const lastCheckedAt = Date.now();
37817
- const headOidByPath = /* @__PURE__ */ new Map();
37818
- const entries = await Promise.all(
37819
- paths.filter((path54) => !ignoreSet.has(path54)).map(async (path54) => {
37820
- const repoPath = repo.repoRoot + "/" + path54;
37821
- const expected = await readGitlinkExpectedSha(repo, path54, options);
37822
- const actual = await readSubmoduleHeadSha(repo, repoPath, options);
37823
- if (actual) headOidByPath.set(path54, actual);
37824
- const outOfSync = actual === null ? true : expected !== null && expected !== actual;
37825
- return {
37826
- path: path54,
37827
- // Prefer the recorded gitlink SHA (matches the legacy column); fall back
37828
- // to the checked-out SHA so the field is never empty when both are known.
37829
- commit: expected ?? actual ?? "",
37830
- repoPath,
37831
- dirty: false,
37832
- outOfSync,
37833
- lastCheckedAt
37834
- };
37835
- })
37836
- );
37837
- return { submodules: entries, headOidByPath };
37838
- }
37839
37837
  async function readSubmodulePaths(repo, options) {
37840
37838
  if (!repo.repoRoot) return [];
37841
37839
  const gitmodulesPath = repo.repoRoot + "/.gitmodules";
@@ -37857,38 +37855,30 @@ var require_dist3 = __commonJS({
37857
37855
  return [];
37858
37856
  }
37859
37857
  }
37860
- async function readGitlinkExpectedSha(repo, submodulePath, options) {
37858
+ async function readGitlinkExpectedShas(repo, submodulePaths, options) {
37859
+ const expectedByPath = /* @__PURE__ */ new Map();
37860
+ if (submodulePaths.length === 0 || !repo.repoRoot) return expectedByPath;
37861
37861
  try {
37862
- const result = await runGit(repo, ["ls-tree", "HEAD", submodulePath], options);
37863
- const line = result.stdout.split("\n").find((l) => l.trim().length > 0);
37864
- if (!line) return null;
37865
- const match = line.match(/^\s*\d+\s+commit\s+([0-9a-f]{40})\b/);
37866
- return match ? match[1] : null;
37867
- } catch {
37868
- return null;
37869
- }
37870
- }
37871
- async function readSubmoduleHeadSha(repo, repoPath, options) {
37872
- try {
37873
- const result = await runGit(repo, ["rev-parse", "HEAD"], { ...options, cwd: repoPath });
37874
- const sha = result.stdout.trim();
37875
- return /^[0-9a-f]{40}$/.test(sha) ? sha : null;
37862
+ const result = await runGit(repo, ["ls-tree", "-z", "HEAD", "--", ...submodulePaths], options);
37863
+ for (const entry of result.stdout.split("\0")) {
37864
+ const match = entry.match(/^\d{6} commit ([0-9a-f]{40,64})\t(.+)$/s);
37865
+ if (match) expectedByPath.set(match[2], match[1]);
37866
+ }
37876
37867
  } catch {
37877
- return null;
37878
37868
  }
37869
+ return expectedByPath;
37879
37870
  }
37880
- async function enrichSubmoduleWorktreeStatus(repo, submodule, options) {
37871
+ async function readSubmoduleWorktreeStatus(repo, repoPath, options) {
37881
37872
  try {
37882
37873
  const result = await runGit(repo, ["status", "--porcelain=v2", "--branch"], {
37883
37874
  ...options,
37884
- cwd: submodule.repoPath
37875
+ cwd: repoPath
37885
37876
  });
37886
37877
  const parsed = parsePorcelainV2Status(result.stdout);
37887
37878
  const dirty = parsed.staged + parsed.modified + parsed.untracked + parsed.deleted + parsed.renamed > 0 || parsed.conflictFiles.length > 0;
37888
- submodule.dirty = submodule.dirty || dirty;
37879
+ return { headOid: parsed.headOid, dirty };
37889
37880
  } catch (error48) {
37890
- submodule.dirty = true;
37891
- submodule.error = formatGitError(error48);
37881
+ return { headOid: null, dirty: true, error: formatGitError(error48) };
37892
37882
  }
37893
37883
  }
37894
37884
  var import_node_path;
@@ -38773,8 +38763,7 @@ var require_dist3 = __commonJS({
38773
38763
  }
38774
38764
  });
38775
38765
  function adhdevHome(env2 = process.env) {
38776
- const override = env2.ADHDEV_HOME?.trim();
38777
- return override ? override : path42.join(os6.homedir(), ".adhdev");
38766
+ return resolveConfigDir(env2);
38778
38767
  }
38779
38768
  function statuslineDir(env2 = process.env) {
38780
38769
  return path42.join(adhdevHome(env2), "claude-statusline");
@@ -38802,10 +38791,11 @@ var require_dist3 = __commonJS({
38802
38791
  "use strict";
38803
38792
  os6 = __toESM2(require("os"));
38804
38793
  path42 = __toESM2(require("path"));
38794
+ init_config_dir();
38805
38795
  }
38806
38796
  });
38807
38797
  function renderWrapperScript(options) {
38808
- return WRAPPER_TEMPLATE.replace("__ADHDEV_SNAPSHOT_PATH__", JSON.stringify(options.snapshotPath)).replace("__ADHDEV_ORIGINAL_COMMAND__", JSON.stringify(options.originalCommand)).replace("__ADHDEV_SNAPSHOT_VERSION__", JSON.stringify(options.snapshotVersion)).replace("__ADHDEV_MIN_WRITE_INTERVAL_MS__", JSON.stringify(options.minWriteIntervalMs)).replace("__ADHDEV_MAX_WRITE_INTERVAL_MS__", JSON.stringify(options.maxWriteIntervalMs));
38798
+ return WRAPPER_TEMPLATE.replace("__ADHDEV_SNAPSHOT_PATH__", JSON.stringify(options.snapshotPath)).replace("__ADHDEV_EXTRA_SNAPSHOT_PATHS__", JSON.stringify(options.additionalSnapshotPaths ?? [])).replace("__ADHDEV_ORIGINAL_COMMAND__", JSON.stringify(options.originalCommand)).replace("__ADHDEV_SNAPSHOT_VERSION__", JSON.stringify(options.snapshotVersion)).replace("__ADHDEV_MIN_WRITE_INTERVAL_MS__", JSON.stringify(options.minWriteIntervalMs)).replace("__ADHDEV_MAX_WRITE_INTERVAL_MS__", JSON.stringify(options.maxWriteIntervalMs));
38809
38799
  }
38810
38800
  var WRAPPER_TEMPLATE;
38811
38801
  var init_wrapper_source = __esm2({
@@ -38825,6 +38815,7 @@ import { mkdirSync, readFileSync, renameSync, writeFileSync } from 'node:fs';
38825
38815
  import { dirname } from 'node:path';
38826
38816
 
38827
38817
  const SNAPSHOT_PATH = __ADHDEV_SNAPSHOT_PATH__;
38818
+ const EXTRA_SNAPSHOT_PATHS = __ADHDEV_EXTRA_SNAPSHOT_PATHS__;
38828
38819
  const ORIGINAL_COMMAND = __ADHDEV_ORIGINAL_COMMAND__;
38829
38820
  const SNAPSHOT_VERSION = __ADHDEV_SNAPSHOT_VERSION__;
38830
38821
  const MIN_WRITE_INTERVAL_MS = __ADHDEV_MIN_WRITE_INTERVAL_MS__;
@@ -38910,13 +38901,24 @@ function capture(payload) {
38910
38901
  };
38911
38902
  if (typeof payload.version === 'string') snapshot.cliVersion = payload.version;
38912
38903
 
38913
- // Write via a temp file + rename so a reader never sees a half-written
38914
- // file, and so a killed invocation cannot truncate a good snapshot.
38915
- // Claude Code cancels in-flight statusline scripts, so that is a real case.
38916
- mkdirSync(dirname(SNAPSHOT_PATH), { recursive: true });
38917
- const temp = SNAPSHOT_PATH + '.' + process.pid + '.tmp';
38918
- writeFileSync(temp, JSON.stringify(snapshot), 'utf-8');
38919
- renameSync(temp, SNAPSHOT_PATH);
38904
+ // Fan out to every track's snapshot path (the primary plus the sibling
38905
+ // tracks discovered at install time). Claude Code's statusLine slot is
38906
+ // machine-global, so this one reading belongs to every adhdev track on the
38907
+ // box; each track's daemon reads only its own directory.
38908
+ for (const target of [SNAPSHOT_PATH, ...EXTRA_SNAPSHOT_PATHS]) {
38909
+ try {
38910
+ // Write via a temp file + rename so a reader never sees a half-written
38911
+ // file, and so a killed invocation cannot truncate a good snapshot.
38912
+ // Claude Code cancels in-flight statusline scripts, so that is a real case.
38913
+ mkdirSync(dirname(target), { recursive: true });
38914
+ const temp = target + '.' + process.pid + '.tmp';
38915
+ writeFileSync(temp, JSON.stringify(snapshot), 'utf-8');
38916
+ renameSync(temp, target);
38917
+ } catch {
38918
+ // One unwritable track dir must not starve the others — and none
38919
+ // of this may reach the user's prompt (see the header note).
38920
+ }
38921
+ }
38920
38922
  }
38921
38923
 
38922
38924
  const stdinBuffer = await readStdin();
@@ -38967,6 +38969,26 @@ child.on('exit', () => process.exit(0));
38967
38969
  stateDir: statuslineDir(env2)
38968
38970
  };
38969
38971
  }
38972
+ function discoverSiblingSnapshotPaths(env2 = process.env, homeDir = os22.homedir()) {
38973
+ const own = snapshotPath(env2);
38974
+ let entries;
38975
+ try {
38976
+ entries = fs32.readdirSync(homeDir, { withFileTypes: true });
38977
+ } catch {
38978
+ return [];
38979
+ }
38980
+ const targets = /* @__PURE__ */ new Set();
38981
+ for (const entry of entries) {
38982
+ if (!entry.isDirectory() || !entry.name.startsWith(".adhdev")) {
38983
+ continue;
38984
+ }
38985
+ const candidate = path52.join(homeDir, entry.name, "claude-statusline", "quota.json");
38986
+ if (candidate !== own) {
38987
+ targets.add(candidate);
38988
+ }
38989
+ }
38990
+ return [...targets].sort();
38991
+ }
38970
38992
  function isWrapperCommand(command, wrapperFile) {
38971
38993
  if (typeof command !== "string" || command === "") {
38972
38994
  return false;
@@ -39036,6 +39058,7 @@ child.on('exit', () => process.exit(0));
39036
39058
  const originalCommand = typeof originalStatusLine?.command === "string" && originalStatusLine.command !== "" ? originalStatusLine.command : null;
39037
39059
  const script = renderWrapperScript({
39038
39060
  snapshotPath: paths.snapshotFile,
39061
+ additionalSnapshotPaths: discoverSiblingSnapshotPaths(env2),
39039
39062
  originalCommand,
39040
39063
  snapshotVersion: SNAPSHOT_VERSION,
39041
39064
  minWriteIntervalMs: MIN_WRITE_INTERVAL_MS,
@@ -39139,6 +39162,7 @@ child.on('exit', () => process.exit(0));
39139
39162
  };
39140
39163
  }
39141
39164
  var fs32;
39165
+ var os22;
39142
39166
  var path52;
39143
39167
  var WRAPPER_MARKER;
39144
39168
  var StatuslineInstallError2;
@@ -39146,6 +39170,7 @@ child.on('exit', () => process.exit(0));
39146
39170
  "src/quota/statusline/install.ts"() {
39147
39171
  "use strict";
39148
39172
  fs32 = __toESM2(require("fs"));
39173
+ os22 = __toESM2(require("os"));
39149
39174
  path52 = __toESM2(require("path"));
39150
39175
  init_snapshot();
39151
39176
  init_paths();
@@ -39883,7 +39908,7 @@ child.on('exit', () => process.exit(0));
39883
39908
  });
39884
39909
  function kimiHome(env2) {
39885
39910
  const override = env2.KIMI_CODE_HOME?.trim();
39886
- return override ? override : path6.join(os22.homedir(), ".kimi-code");
39911
+ return override ? override : path6.join(os32.homedir(), ".kimi-code");
39887
39912
  }
39888
39913
  function credentialsPath(env2) {
39889
39914
  return path6.join(kimiHome(env2), "credentials", "kimi-code.json");
@@ -40092,7 +40117,7 @@ child.on('exit', () => process.exit(0));
40092
40117
  }
40093
40118
  }
40094
40119
  var fs5;
40095
- var os22;
40120
+ var os32;
40096
40121
  var path6;
40097
40122
  var DEFAULT_BASE_URL;
40098
40123
  var REQUEST_TIMEOUT_MS2;
@@ -40101,7 +40126,7 @@ child.on('exit', () => process.exit(0));
40101
40126
  "src/quota/fetchers/kimi.ts"() {
40102
40127
  "use strict";
40103
40128
  fs5 = __toESM2(require("fs"));
40104
- os22 = __toESM2(require("os"));
40129
+ os32 = __toESM2(require("os"));
40105
40130
  path6 = __toESM2(require("path"));
40106
40131
  init_types();
40107
40132
  init_deps();
@@ -40778,7 +40803,7 @@ child.on('exit', () => process.exit(0));
40778
40803
  function unixExtraBinDirs() {
40779
40804
  const dirs = [];
40780
40805
  const fs56 = require("fs");
40781
- const home = os32.homedir();
40806
+ const home = os42.homedir();
40782
40807
  const push = (dir) => {
40783
40808
  if (!dir) return;
40784
40809
  try {
@@ -40802,11 +40827,11 @@ child.on('exit', () => process.exit(0));
40802
40827
  function findBinary(name) {
40803
40828
  const trimmed = String(name || "").trim();
40804
40829
  if (!trimmed) return trimmed;
40805
- const expanded = trimmed.startsWith("~") ? path8.join(os32.homedir(), trimmed.slice(1)) : trimmed;
40830
+ const expanded = trimmed.startsWith("~") ? path8.join(os42.homedir(), trimmed.slice(1)) : trimmed;
40806
40831
  if (path8.isAbsolute(expanded) || expanded.includes("/") || expanded.includes("\\")) {
40807
40832
  return path8.isAbsolute(expanded) ? expanded : path8.resolve(expanded);
40808
40833
  }
40809
- const isWin = os32.platform() === "win32";
40834
+ const isWin = os42.platform() === "win32";
40810
40835
  const paths = (process.env.PATH || "").split(path8.delimiter);
40811
40836
  const extraDirs = [];
40812
40837
  if (isWin) {
@@ -40874,7 +40899,7 @@ child.on('exit', () => process.exit(0));
40874
40899
  }
40875
40900
  function shSingleQuote(arg) {
40876
40901
  if (/^[a-zA-Z0-9@%_+=:,./-]+$/.test(arg)) return arg;
40877
- if (os32.platform() === "win32") {
40902
+ if (os42.platform() === "win32") {
40878
40903
  return `"${arg.replace(/"/g, '""')}"`;
40879
40904
  }
40880
40905
  return `'${arg.replace(/'/g, `'\\''`)}'`;
@@ -40940,7 +40965,7 @@ child.on('exit', () => process.exit(0));
40940
40965
  }
40941
40966
  };
40942
40967
  }
40943
- var os32;
40968
+ var os42;
40944
40969
  var path8;
40945
40970
  var import_child_process;
40946
40971
  var TerminalTranscriptAccumulator;
@@ -40953,7 +40978,7 @@ child.on('exit', () => process.exit(0));
40953
40978
  var init_provider_cli_shared = __esm2({
40954
40979
  "src/cli-adapters/provider-cli-shared.ts"() {
40955
40980
  "use strict";
40956
- os32 = __toESM2(require("os"));
40981
+ os42 = __toESM2(require("os"));
40957
40982
  path8 = __toESM2(require("path"));
40958
40983
  import_child_process = require("child_process");
40959
40984
  init_spawn_env();
@@ -41141,7 +41166,7 @@ child.on('exit', () => process.exit(0));
41141
41166
  function expandHome(value) {
41142
41167
  const trimmed = value.trim();
41143
41168
  if (!trimmed.startsWith("~")) return trimmed;
41144
- return path9.join(os42.homedir(), trimmed.slice(1));
41169
+ return path9.join(os52.homedir(), trimmed.slice(1));
41145
41170
  }
41146
41171
  function isExplicitCommandPath(command) {
41147
41172
  const trimmed = command.trim();
@@ -41183,7 +41208,7 @@ child.on('exit', () => process.exit(0));
41183
41208
  });
41184
41209
  }
41185
41210
  async function detectCLIs(providerLoader, options) {
41186
- const platform10 = os42.platform();
41211
+ const platform10 = os52.platform();
41187
41212
  const whichCmd = platform10 === "win32" ? "where" : "which";
41188
41213
  const includeVersion = options?.includeVersion !== false;
41189
41214
  const cliList = providerLoader ? providerLoader.getCliDetectionList({ includeDisabled: options?.includeDisabled }) : [];
@@ -41225,7 +41250,7 @@ child.on('exit', () => process.exit(0));
41225
41250
  const cliList = providerLoader.getCliDetectionList();
41226
41251
  const target = cliList.find((c) => c.id === resolvedId);
41227
41252
  if (target) {
41228
- const platform10 = os42.platform();
41253
+ const platform10 = os52.platform();
41229
41254
  const whichCmd = platform10 === "win32" ? "where" : "which";
41230
41255
  try {
41231
41256
  const firstPath = await resolveDetectionPath(target.command, whichCmd);
@@ -41308,7 +41333,7 @@ child.on('exit', () => process.exit(0));
41308
41333
  return out;
41309
41334
  }
41310
41335
  var import_child_process2;
41311
- var os42;
41336
+ var os52;
41312
41337
  var path9;
41313
41338
  var import_fs4;
41314
41339
  var PROVIDER_VERSIONS_TTL_MS;
@@ -41320,7 +41345,7 @@ child.on('exit', () => process.exit(0));
41320
41345
  "src/detection/cli-detector.ts"() {
41321
41346
  "use strict";
41322
41347
  import_child_process2 = require("child_process");
41323
- os42 = __toESM2(require("os"));
41348
+ os52 = __toESM2(require("os"));
41324
41349
  path9 = __toESM2(require("path"));
41325
41350
  import_fs4 = require("fs");
41326
41351
  init_provider_cli_shared();
@@ -41716,7 +41741,7 @@ ${error48.message || ""}`;
41716
41741
  function expandPath(p) {
41717
41742
  const t = (p || "").trim();
41718
41743
  if (!t) return "";
41719
- if (t.startsWith("~")) return path13.join(os62.homedir(), t.slice(1).replace(/^\//, ""));
41744
+ if (t.startsWith("~")) return path13.join(os7.homedir(), t.slice(1).replace(/^\//, ""));
41720
41745
  return path13.resolve(t);
41721
41746
  }
41722
41747
  function validateWorkspacePath(absPath) {
@@ -41789,7 +41814,7 @@ ${error48.message || ""}`;
41789
41814
  };
41790
41815
  }
41791
41816
  if (a.useHome === true) {
41792
- return { ok: true, path: os62.homedir(), source: "home" };
41817
+ return { ok: true, path: os7.homedir(), source: "home" };
41793
41818
  }
41794
41819
  return {
41795
41820
  ok: false,
@@ -41873,7 +41898,7 @@ ${error48.message || ""}`;
41873
41898
  return { config: { ...config2, defaultWorkspaceId: id } };
41874
41899
  }
41875
41900
  var fs7;
41876
- var os62;
41901
+ var os7;
41877
41902
  var path13;
41878
41903
  var import_crypto22;
41879
41904
  var MAX_WORKSPACES;
@@ -41881,7 +41906,7 @@ ${error48.message || ""}`;
41881
41906
  "src/config/workspaces.ts"() {
41882
41907
  "use strict";
41883
41908
  fs7 = __toESM2(require("fs"));
41884
- os62 = __toESM2(require("os"));
41909
+ os7 = __toESM2(require("os"));
41885
41910
  path13 = __toESM2(require("path"));
41886
41911
  import_crypto22 = require("crypto");
41887
41912
  MAX_WORKSPACES = 50;
@@ -43015,6 +43040,7 @@ ${error48.message || ""}`;
43015
43040
  getMagiKindPanel: () => getMagiKindPanel,
43016
43041
  getMesh: () => getMesh,
43017
43042
  getMeshByRepo: () => getMeshByRepo,
43043
+ getMeshQuotaRouting: () => getMeshQuotaRouting,
43018
43044
  listMagiKindPanels: () => listMagiKindPanels,
43019
43045
  listMagiKindPanelsReadOnly: () => listMagiKindPanelsReadOnly,
43020
43046
  listMeshes: () => listMeshes,
@@ -43030,6 +43056,7 @@ ${error48.message || ""}`;
43030
43056
  setDifficultyBrains: () => setDifficultyBrains,
43031
43057
  setMagiKindPanel: () => setMagiKindPanel,
43032
43058
  setMeshHostPin: () => setMeshHostPin,
43059
+ setMeshQuotaRouting: () => setMeshQuotaRouting,
43033
43060
  tokenIdForManualPairing: () => tokenIdForManualPairing,
43034
43061
  updateMesh: () => updateMesh,
43035
43062
  updateNode: () => updateNode
@@ -43732,12 +43759,59 @@ ${error48.message || ""}`;
43732
43759
  saveMeshConfig(stored);
43733
43760
  return normalized;
43734
43761
  }
43762
+ function validateQuotaRoutingOverrides(input) {
43763
+ if (input === void 0 || input === null) return {};
43764
+ if (typeof input !== "object" || Array.isArray(input)) {
43765
+ throw new Error("invalid_quota_routing: quotaRouting must be an object of threshold overrides");
43766
+ }
43767
+ const out = {};
43768
+ for (const [key2, raw] of Object.entries(input)) {
43769
+ const isPercent = QUOTA_ROUTING_PERCENT_FIELDS.has(key2);
43770
+ if (!isPercent && !QUOTA_ROUTING_NONNEGATIVE_FIELDS.has(key2)) {
43771
+ throw new Error(
43772
+ `invalid_quota_routing: unknown field '${key2}' (known fields: ` + [...QUOTA_ROUTING_PERCENT_FIELDS, ...QUOTA_ROUTING_NONNEGATIVE_FIELDS].join(", ") + ")"
43773
+ );
43774
+ }
43775
+ if (typeof raw !== "number" || !Number.isFinite(raw)) {
43776
+ throw new Error(`invalid_quota_routing: ${key2} must be a finite number (got ${JSON.stringify(raw)})`);
43777
+ }
43778
+ if (isPercent && (raw < 0 || raw > 100)) {
43779
+ throw new Error(`invalid_quota_routing: ${key2} must be between 0 and 100 (got ${raw})`);
43780
+ }
43781
+ if (!isPercent && raw < 0) {
43782
+ throw new Error(`invalid_quota_routing: ${key2} must be >= 0 (got ${raw})`);
43783
+ }
43784
+ out[key2] = raw;
43785
+ }
43786
+ return out;
43787
+ }
43788
+ function getMeshQuotaRouting(meshId) {
43789
+ const config2 = loadMeshConfig();
43790
+ const stored = resolveScopedMesh(config2, meshId)?.policy?.quotaRouting;
43791
+ return normalizeQuotaRoutingPolicy(stored) ?? {};
43792
+ }
43793
+ function setMeshQuotaRouting(input, meshId) {
43794
+ const overrides = validateQuotaRoutingOverrides(input);
43795
+ const stored = loadMeshConfig();
43796
+ const mesh = resolveScopedMesh(stored, meshId);
43797
+ if (!mesh) {
43798
+ throw new Error(
43799
+ meshId?.trim() ? `invalid_quota_routing: mesh '${meshId.trim()}' not found` : `quota_routing_mesh_ambiguous: this machine hosts ${stored.meshes.length} meshes, so a quota-routing write must name its mesh explicitly (meshId). Thresholds are per mesh \u2014 they decide which (node, provider) pairs the launch gate skips, so writing to the wrong mesh changes what work that mesh refuses.`
43800
+ );
43801
+ }
43802
+ mesh.policy = mergeAndNormalizePolicy(mesh.policy, { quotaRouting: overrides });
43803
+ mesh.updatedAt = (/* @__PURE__ */ new Date()).toISOString();
43804
+ saveMeshConfig(stored);
43805
+ return normalizeQuotaRoutingPolicy(overrides) ?? {};
43806
+ }
43735
43807
  var import_fs5;
43736
43808
  var import_path5;
43737
43809
  var import_crypto3;
43738
43810
  var mergeMeshPolicy;
43739
43811
  var MAGI_KIND_PANEL_KINDS;
43740
43812
  var MAX_MAGI_KIND_SLOTS;
43813
+ var QUOTA_ROUTING_PERCENT_FIELDS;
43814
+ var QUOTA_ROUTING_NONNEGATIVE_FIELDS;
43741
43815
  var init_mesh_config = __esm2({
43742
43816
  "src/config/mesh-config.ts"() {
43743
43817
  "use strict";
@@ -43752,6 +43826,8 @@ ${error48.message || ""}`;
43752
43826
  mergeMeshPolicy = mergeAndNormalizePolicy;
43753
43827
  MAGI_KIND_PANEL_KINDS = ["claim_audit", "rca", "design", "freeform"];
43754
43828
  MAX_MAGI_KIND_SLOTS = 24;
43829
+ QUOTA_ROUTING_PERCENT_FIELDS = /* @__PURE__ */ new Set(["sessionMinRemainingPercent", "weeklyMinRemainingPercent"]);
43830
+ QUOTA_ROUTING_NONNEGATIVE_FIELDS = /* @__PURE__ */ new Set(["staleAfterMs", "sessionResetImminentMs", "spreadBonusMax"]);
43755
43831
  }
43756
43832
  });
43757
43833
  function normalizeProviderPriority(policy) {
@@ -47404,11 +47480,11 @@ Next step: ${nextStep}`;
47404
47480
  const pinnedProvider = typeof providerType === "string" && providerType.trim() ? providerType.trim() : void 0;
47405
47481
  const providerTags = pinnedProvider ? [pinnedProvider] : readNodeProviderTypes(node?.policy);
47406
47482
  const worktreeBranch = typeof node?.worktreeBranch === "string" && node.worktreeBranch.trim() ? node.worktreeBranch.trim() : null;
47407
- const os28 = readNodeOverride(node, "platform") ?? readNodeReporter(node, "platform") ?? process.platform;
47483
+ const os29 = readNodeOverride(node, "platform") ?? readNodeReporter(node, "platform") ?? process.platform;
47408
47484
  const arch2 = readNodeOverride(node, "arch") ?? readNodeReporter(node, "arch") ?? process.arch;
47409
47485
  return normalizeMeshCapabilityTags([
47410
47486
  ...Array.isArray(node?.capabilities) ? node.capabilities : [],
47411
- `os=${os28}`,
47487
+ `os=${os29}`,
47412
47488
  `arch=${arch2}`,
47413
47489
  ...providerTags.map((p) => `provider=${p}`),
47414
47490
  // Worktree nodes automatically expose a "worktree=<branch>" tag so that
@@ -52047,7 +52123,7 @@ Default branch: \`${mesh.defaultBranch}\`` : ""}`);
52047
52123
  sections.push(TOOL_EXPOSURE_PREFLIGHT_SECTION);
52048
52124
  sections.push(WORKFLOW_SECTION);
52049
52125
  sections.push(ONBOARDING_SECTION);
52050
- sections.push(buildRulesSection(coordinatorCliType));
52126
+ sections.push(buildRulesSection(coordinatorCliType, mergeAndNormalizePolicy(void 0, mesh.policy)));
52051
52127
  return sections.join("\n\n");
52052
52128
  }
52053
52129
  function readUserPromptFile(cliType, suffix) {
@@ -52080,7 +52156,7 @@ Default branch: \`${mesh.defaultBranch}\`` : ""}`);
52080
52156
  tools: TOOLS_SECTION,
52081
52157
  workflow: WORKFLOW_SECTION,
52082
52158
  onboarding: ONBOARDING_SECTION,
52083
- rules: buildRulesSection(coordinatorCliType),
52159
+ rules: buildRulesSection(coordinatorCliType, mergeAndNormalizePolicy(void 0, mesh.policy)),
52084
52160
  toolExposurePreflight: TOOL_EXPOSURE_PREFLIGHT_SECTION
52085
52161
  };
52086
52162
  return template.replace(/\{\{\s*([a-zA-Z_][a-zA-Z0-9_]*)\s*\}\}/g, (m, key2) => {
@@ -52413,12 +52489,14 @@ Default branch: \`${mesh.defaultBranch}\`` : ""}`);
52413
52489
  return `## Policy
52414
52490
  ${rules.join("\n")}`;
52415
52491
  }
52416
- function buildRulesSection(coordinatorCliType) {
52492
+ function buildRulesSection(coordinatorCliType, policy) {
52417
52493
  const coordinatorNote = coordinatorCliType ? `
52418
52494
  - **Coordinator runtime is not a delegation default.** This coordinator is running as \`${coordinatorCliType}\`, but delegated node sessions must follow the user's requested provider, not the coordinator's own runtime.` : "";
52495
+ const destructiveGitRequiresApproval = policy ? policy.requireApprovalForDestructiveGit : true;
52496
+ const destructiveGitRule = destructiveGitRequiresApproval ? "\n- **Never run destructive git operations without explicit user approval.** Force push (`push --force`/`--force-with-lease`), `git reset --hard`, and any history rewrite (`rebase`, `filter-branch`, `commit --amend` on already-pushed work) can destroy work that is not recoverable from the mesh ledger. This mesh's policy currently requires approval for these (see Policy above). Ask first and wait for a yes \u2014 there is no code-level gate backing this up, so skipping the ask is the only thing that can lose the user's work." : "\n- **This mesh's policy does not require approval for destructive git operations** (`requireApprovalForDestructiveGit` is off). Still treat force push, `git reset --hard`, and history rewrites as high-risk: prefer a non-destructive alternative when one exists, and mention what you did in your summary so the user can catch a mistake quickly.";
52419
52497
  return `## Rules
52420
52498
 
52421
- - **Route, don't implement.** Delegate all code reading, analysis, and execution to node agents. Never read source files or run commands in the coordinator \u2014 keep context lean. See also: **Never use local sub-agents** below.
52499
+ - **Route, don't implement.** Delegate all code reading, analysis, and execution to node agents. Never read source files or run commands in the coordinator \u2014 keep context lean. See also: **Never use local sub-agents** below.${destructiveGitRule}
52422
52500
  - **Never use local sub-agents.** Do NOT spawn your runtime's own sub-agents (e.g. Claude Code's Task/Explore/Agent tools, or any equivalent in-process agent-spawning tool) to read code, investigate, run RCA, or implement. Such sub-agents execute on the coordinator's machine, outside the mesh \u2014 they escape mesh parallelism, the ledger/audit trail, node capability profiles, and worktree isolation, and leave no \`mesh_task_history\` record. ALL code reading, analysis, RCA, and implementation must be delegated to mesh nodes via \`mesh_enqueue_task\` / \`mesh_send_task\` (use \`task_mode: "live_debug_readonly"\` for read-only investigation), or cross-verified via \`mesh_magi_review\` for read-only fan-out. The coordinator's own actions are limited to \`mesh_*\` tool orchestration and synthesizing results.
52423
52501
  - **Front-load task messages.** Include everything the agent needs (files, problem, expected fix) in \`mesh_enqueue_task\` / \`mesh_send_task\`. Append a structured result request at the end: ask the worker to conclude with a JSON block containing \`status\`, \`changedFiles\`, \`gitStatus\`, \`validationResults\`, \`errors\`, \`nextAction\`. The daemon parses this automatically; you can read it from \`mesh_task_history\`.
52424
52502
  - **Reuse idle sessions.** For follow-up, retry, commit/push, or cleanup on the same issue, send only the delta to the existing idle session. Start a fresh session only when: (a) branch/worktree isolation is required, (b) the existing session had a dispatch failure or provider mismatch, (c) the transcript/runtime is contaminated or interrupted, (d) the user explicitly asks for a different provider/session, or (e) **the delta is a genuinely NEW subject rather than a continuation** \u2014 a new topic appended to an existing session can be dropped or re-run as the previous task, so give it its own task even when a session sits idle. Continuation of the same issue in an already-idle session is allowed and preferred \u2014 this rule blocks concurrent unrelated work interleaved into a live (still-generating) session, not sequential same-issue follow-ups. The test is subject continuity, not timing: carrying an investigation forward into its own fix is the SAME subject and belongs in that session (Workflow 3f), while an unrelated bug is a new subject even if the same session just went idle.
@@ -53952,14 +54030,14 @@ When the user asks to **set up / configure / onboard** this repo for Repo Mesh (
53952
54030
  }
53953
54031
  function resolveHermesCoordinatorHome(meshId, workspace) {
53954
54032
  const key2 = `${meshId || "mesh"}
53955
- ${(0, import_node_path3.resolve)(workspace || os7.tmpdir())}`;
54033
+ ${(0, import_node_path3.resolve)(workspace || os8.tmpdir())}`;
53956
54034
  const hash2 = shortHash(key2);
53957
- return (0, import_node_path3.join)(os7.tmpdir(), `adhdev-hermes-mesh-coordinator-${hash2}`);
54035
+ return (0, import_node_path3.join)(os8.tmpdir(), `adhdev-hermes-mesh-coordinator-${hash2}`);
53958
54036
  }
53959
54037
  function resolveMcpConfigPath(configPath, workspace) {
53960
54038
  const trimmed = configPath.trim();
53961
- if (trimmed === "~") return os7.homedir();
53962
- if (trimmed.startsWith("~/")) return (0, import_node_path3.join)(os7.homedir(), trimmed.slice(2));
54039
+ if (trimmed === "~") return os8.homedir();
54040
+ if (trimmed.startsWith("~/")) return (0, import_node_path3.join)(os8.homedir(), trimmed.slice(2));
53963
54041
  if ((0, import_node_path3.isAbsolute)(trimmed)) return trimmed;
53964
54042
  return (0, import_node_path3.join)(workspace, trimmed);
53965
54043
  }
@@ -54037,7 +54115,7 @@ ${(0, import_node_path3.resolve)(workspace || os7.tmpdir())}`;
54037
54115
  const template = injection.template && injection.template.includes("{prompt}") ? injection.template : "{prompt}";
54038
54116
  const body = template.replace(/\{prompt\}/g, systemPrompt);
54039
54117
  try {
54040
- const dir = (0, import_node_fs3.mkdtempSync)((0, import_node_path3.join)(os7.tmpdir(), `adhdev-coord-${ctx.cliType}-`));
54118
+ const dir = (0, import_node_fs3.mkdtempSync)((0, import_node_path3.join)(os8.tmpdir(), `adhdev-coord-${ctx.cliType}-`));
54041
54119
  const filePath = (0, import_node_path3.join)(dir, "coordinator-agent.md");
54042
54120
  (0, import_node_fs3.writeFileSync)(filePath, body, "utf-8");
54043
54121
  ctx.cliArgs.push(injection.flag, filePath);
@@ -54197,7 +54275,7 @@ ${rendered}`, "utf-8");
54197
54275
  });
54198
54276
  }
54199
54277
  var import_node_fs3;
54200
- var os7;
54278
+ var os8;
54201
54279
  var import_session_host_core32;
54202
54280
  var import_node_path3;
54203
54281
  var DEFAULT_SERVER_NAME;
@@ -54208,7 +54286,7 @@ ${rendered}`, "utf-8");
54208
54286
  "src/commands/mesh-coordinator.ts"() {
54209
54287
  "use strict";
54210
54288
  import_node_fs3 = require("fs");
54211
- os7 = __toESM2(require("os"));
54289
+ os8 = __toESM2(require("os"));
54212
54290
  import_session_host_core32 = require_dist();
54213
54291
  import_node_path3 = require("path");
54214
54292
  init_logger();
@@ -63147,7 +63225,7 @@ The mesh has no work in flight. For each mission, decide its outcome: continue i
63147
63225
  }
63148
63226
  });
63149
63227
  async function updateDarwinMemoryCache() {
63150
- if (os8.platform() !== "darwin") return;
63228
+ if (os9.platform() !== "darwin") return;
63151
63229
  try {
63152
63230
  const { stdout } = await execAsync2("vm_stat", {
63153
63231
  encoding: "utf-8",
@@ -63171,26 +63249,26 @@ The mesh has no work in flight. For each mission, decide its outcome: continue i
63171
63249
  const fileBacked = counts["file_backed"] ?? 0;
63172
63250
  const availPages = free + inactive + speculative + purgeable + fileBacked;
63173
63251
  const bytes = availPages * pageSize;
63174
- cachedDarwinAvail = Number.isFinite(bytes) && bytes >= 0 ? Math.min(bytes, os8.totalmem()) : null;
63252
+ cachedDarwinAvail = Number.isFinite(bytes) && bytes >= 0 ? Math.min(bytes, os9.totalmem()) : null;
63175
63253
  } catch {
63176
63254
  }
63177
63255
  }
63178
63256
  function getHostMemorySnapshot() {
63179
- if (os8.platform() === "darwin" && !darwinMemoryInterval) {
63257
+ if (os9.platform() === "darwin" && !darwinMemoryInterval) {
63180
63258
  updateDarwinMemoryCache();
63181
63259
  darwinMemoryInterval = setInterval(updateDarwinMemoryCache, 3e3);
63182
63260
  darwinMemoryInterval.unref();
63183
63261
  }
63184
- const totalMem = os8.totalmem();
63185
- const freeMem = os8.freemem();
63186
- const availableMem = os8.platform() === "darwin" ? cachedDarwinAvail ?? freeMem : freeMem;
63262
+ const totalMem = os9.totalmem();
63263
+ const freeMem = os9.freemem();
63264
+ const availableMem = os9.platform() === "darwin" ? cachedDarwinAvail ?? freeMem : freeMem;
63187
63265
  return {
63188
63266
  totalMem,
63189
63267
  freeMem,
63190
63268
  availableMem
63191
63269
  };
63192
63270
  }
63193
- var os8;
63271
+ var os9;
63194
63272
  var import_child_process4;
63195
63273
  var import_util3;
63196
63274
  var execAsync2;
@@ -63199,7 +63277,7 @@ The mesh has no work in flight. For each mission, decide its outcome: continue i
63199
63277
  var init_host_memory = __esm2({
63200
63278
  "src/system/host-memory.ts"() {
63201
63279
  "use strict";
63202
- os8 = __toESM2(require("os"));
63280
+ os9 = __toESM2(require("os"));
63203
63281
  import_child_process4 = require("child_process");
63204
63282
  import_util3 = require("util");
63205
63283
  execAsync2 = (0, import_util3.promisify)(import_child_process4.exec);
@@ -64343,8 +64421,8 @@ ${cleanBody}`;
64343
64421
  }
64344
64422
  function buildMachineInfo2(profile = "full") {
64345
64423
  const base = {
64346
- hostname: os9.hostname(),
64347
- platform: os9.platform()
64424
+ hostname: os10.hostname(),
64425
+ platform: os10.platform()
64348
64426
  };
64349
64427
  if (profile === "live") {
64350
64428
  return base;
@@ -64353,23 +64431,23 @@ ${cleanBody}`;
64353
64431
  const memSnap2 = getHostMemorySnapshot();
64354
64432
  return {
64355
64433
  ...base,
64356
- arch: os9.arch(),
64357
- cpus: os9.cpus().length,
64434
+ arch: os10.arch(),
64435
+ cpus: os10.cpus().length,
64358
64436
  totalMem: memSnap2.totalMem,
64359
- release: os9.release()
64437
+ release: os10.release()
64360
64438
  };
64361
64439
  }
64362
64440
  const memSnap = getHostMemorySnapshot();
64363
64441
  return {
64364
64442
  ...base,
64365
- arch: os9.arch(),
64366
- cpus: os9.cpus().length,
64443
+ arch: os10.arch(),
64444
+ cpus: os10.cpus().length,
64367
64445
  totalMem: memSnap.totalMem,
64368
64446
  freeMem: memSnap.freeMem,
64369
64447
  availableMem: memSnap.availableMem,
64370
- loadavg: os9.loadavg(),
64371
- uptime: os9.uptime(),
64372
- release: os9.release()
64448
+ loadavg: os10.loadavg(),
64449
+ uptime: os10.uptime(),
64450
+ release: os10.release()
64373
64451
  };
64374
64452
  }
64375
64453
  function parseMessageTime(value) {
@@ -64606,13 +64684,13 @@ ${cleanBody}`;
64606
64684
  }
64607
64685
  };
64608
64686
  }
64609
- var os9;
64687
+ var os10;
64610
64688
  var READ_DEBUG_ENABLED;
64611
64689
  var recentReadDebugSignatureBySession;
64612
64690
  var init_snapshot2 = __esm2({
64613
64691
  "src/status/snapshot.ts"() {
64614
64692
  "use strict";
64615
- os9 = __toESM2(require("os"));
64693
+ os10 = __toESM2(require("os"));
64616
64694
  init_config();
64617
64695
  init_state_store();
64618
64696
  init_recent_activity();
@@ -70807,7 +70885,7 @@ ${cleanBody}`;
70807
70885
  }
70808
70886
  function expandTemplateRootForEnumeration(template, input) {
70809
70887
  if (!template) return "";
70810
- const posixHome = () => toPosixPath(os12.homedir());
70888
+ const posixHome = () => toPosixPath(os13.homedir());
70811
70889
  let out = template;
70812
70890
  if (out === "~") out = posixHome();
70813
70891
  else if (out.startsWith("~/")) out = `${posixHome()}/${out.slice(2)}`;
@@ -71420,13 +71498,13 @@ ${cleanBody}`;
71420
71498
  if (!template) return null;
71421
71499
  let out = template;
71422
71500
  if (out.startsWith("~/") || out === "~") {
71423
- out = path27.join(os12.homedir(), out.slice(2));
71501
+ out = path27.join(os13.homedir(), out.slice(2));
71424
71502
  }
71425
71503
  out = out.replace(/\$\{([A-Z_][A-Z0-9_]*)(?::-(.*?))?\}/g, (_m, name, fallback) => {
71426
71504
  const v = input.envOverrides?.[name] ?? process.env[name];
71427
71505
  return v != null && v !== "" ? v : fallback ?? "";
71428
71506
  });
71429
- if (out.startsWith("~/")) out = path27.join(os12.homedir(), out.slice(2));
71507
+ if (out.startsWith("~/")) out = path27.join(os13.homedir(), out.slice(2));
71430
71508
  const now = /* @__PURE__ */ new Date();
71431
71509
  const workspaceRaw = input.workspace ?? "";
71432
71510
  let workspaceResolved = workspaceRaw;
@@ -71469,7 +71547,7 @@ ${cleanBody}`;
71469
71547
  function scanProjectsRootForSessionFile(template, input, requestedSessionId) {
71470
71548
  if (!requestedSessionId) return null;
71471
71549
  let head = template;
71472
- if (head.startsWith("~/") || head === "~") head = path27.join(os12.homedir(), head.slice(2));
71550
+ if (head.startsWith("~/") || head === "~") head = path27.join(os13.homedir(), head.slice(2));
71473
71551
  const base = staticTemplateBase(head);
71474
71552
  if (!base) return null;
71475
71553
  let baseStat = null;
@@ -71618,13 +71696,13 @@ ${cleanBody}`;
71618
71696
  if (!template) return null;
71619
71697
  let out = template;
71620
71698
  if (out.startsWith("~/") || out === "~") {
71621
- out = path27.join(os12.homedir(), out.slice(2));
71699
+ out = path27.join(os13.homedir(), out.slice(2));
71622
71700
  }
71623
71701
  out = out.replace(/\$\{([A-Z_][A-Z0-9_]*)(?::-(.*?))?\}/g, (_m, name, fallback) => {
71624
71702
  const v = input.envOverrides?.[name] ?? process.env[name];
71625
71703
  return v != null && v !== "" ? v : fallback ?? "";
71626
71704
  });
71627
- if (out.startsWith("~/")) out = path27.join(os12.homedir(), out.slice(2));
71705
+ if (out.startsWith("~/")) out = path27.join(os13.homedir(), out.slice(2));
71628
71706
  const workspaceRaw = input.workspace ?? "";
71629
71707
  let workspaceResolved = workspaceRaw;
71630
71708
  if (workspaceRaw) {
@@ -72083,7 +72161,7 @@ ${cleanBody}`;
72083
72161
  return t.negate ? !result : result;
72084
72162
  }
72085
72163
  var fs222;
72086
- var os12;
72164
+ var os13;
72087
72165
  var path27;
72088
72166
  var UUID_RE;
72089
72167
  var DEFAULT_TOOL_CALL_TYPES;
@@ -72092,7 +72170,7 @@ ${cleanBody}`;
72092
72170
  "src/providers/spec/native-history-executor.ts"() {
72093
72171
  "use strict";
72094
72172
  fs222 = __toESM2(require("fs"));
72095
- os12 = __toESM2(require("os"));
72173
+ os13 = __toESM2(require("os"));
72096
72174
  path27 = __toESM2(require("path"));
72097
72175
  init_logger();
72098
72176
  init_load_better_sqlite3();
@@ -72585,7 +72663,7 @@ ${cleanBody}`;
72585
72663
  cachedPty = void 0;
72586
72664
  requireNodePty = loader2 ?? (() => require("node-pty"));
72587
72665
  }
72588
- var os13;
72666
+ var os14;
72589
72667
  var cachedPty;
72590
72668
  var requireNodePty;
72591
72669
  var NodePtyRuntimeTransport;
@@ -72593,7 +72671,7 @@ ${cleanBody}`;
72593
72671
  var init_pty_transport = __esm2({
72594
72672
  "src/cli-adapters/pty-transport.ts"() {
72595
72673
  "use strict";
72596
- os13 = __toESM2(require("os"));
72674
+ os14 = __toESM2(require("os"));
72597
72675
  init_spawn_env();
72598
72676
  init_resolve_executable();
72599
72677
  requireNodePty = () => require("node-pty");
@@ -72634,9 +72712,9 @@ ${cleanBody}`;
72634
72712
  try {
72635
72713
  const fs56 = require("fs");
72636
72714
  const stat2 = fs56.statSync(cwd);
72637
- if (!stat2.isDirectory()) cwd = os13.homedir();
72715
+ if (!stat2.isDirectory()) cwd = os14.homedir();
72638
72716
  } catch {
72639
- cwd = os13.homedir();
72717
+ cwd = os14.homedir();
72640
72718
  }
72641
72719
  }
72642
72720
  const handle = pty.spawn(resolveWin32Executable(command), args, {
@@ -75311,7 +75389,7 @@ ${cont}` : cont;
75311
75389
  function resolveCliSpawnPlanFromParts(options) {
75312
75390
  const { command, baseArgs, shell, baseEnv, workingDir, extraArgs, extraEnv, geometry, diagnosticCliType, diagnosticProviderVersion } = options;
75313
75391
  const binaryPath = findBinary(command);
75314
- const isWin = os14.platform() === "win32";
75392
+ const isWin = os15.platform() === "win32";
75315
75393
  const allArgs = [...baseArgs ?? [], ...extraArgs ?? []].map(
75316
75394
  (arg) => typeof arg === "string" ? arg.replace(/\{\{workingDir\}\}/g, workingDir) : arg
75317
75395
  );
@@ -75399,13 +75477,13 @@ ${cont}` : cont;
75399
75477
  }
75400
75478
  return "";
75401
75479
  }
75402
- var os14;
75480
+ var os15;
75403
75481
  var path28;
75404
75482
  var import_session_host_core7;
75405
75483
  var init_provider_cli_runtime = __esm2({
75406
75484
  "src/cli-adapters/provider-cli-runtime.ts"() {
75407
75485
  "use strict";
75408
- os14 = __toESM2(require("os"));
75486
+ os15 = __toESM2(require("os"));
75409
75487
  path28 = __toESM2(require("path"));
75410
75488
  init_logger();
75411
75489
  import_session_host_core7 = require_dist();
@@ -75480,7 +75558,7 @@ ${cont}` : cont;
75480
75558
  missingBackgroundSourceWarned.add(cliType);
75481
75559
  LOG2.warn("CLI", `[${cliType}] background-task tracking declared but nativeHistory.source missing after provider resolve; background detection inactive`);
75482
75560
  }
75483
- var os15;
75561
+ var os16;
75484
75562
  var import_crypto11;
75485
75563
  var import_session_host_core8;
75486
75564
  var missingBackgroundSourceWarned;
@@ -75489,7 +75567,7 @@ ${cont}` : cont;
75489
75567
  var init_provider_cli_adapter = __esm2({
75490
75568
  "src/cli-adapters/provider-cli-adapter.ts"() {
75491
75569
  "use strict";
75492
- os15 = __toESM2(require("os"));
75570
+ os16 = __toESM2(require("os"));
75493
75571
  import_crypto11 = require("crypto");
75494
75572
  init_interactive_prompt();
75495
75573
  init_kimi_pending_question();
@@ -75521,7 +75599,7 @@ ${cont}` : cont;
75521
75599
  this.transportFactory = transportFactory;
75522
75600
  this.cliType = provider.type;
75523
75601
  this.cliName = provider.name;
75524
- this.workingDir = workingDir.startsWith("~") ? workingDir.replace(/^~/, os15.homedir()) : workingDir;
75602
+ this.workingDir = workingDir.startsWith("~") ? workingDir.replace(/^~/, os16.homedir()) : workingDir;
75525
75603
  const resolvedConfig = resolveCliAdapterConfig(provider);
75526
75604
  this.timeouts = resolvedConfig.timeouts;
75527
75605
  this.approvalKeys = resolvedConfig.approvalKeys;
@@ -80156,7 +80234,7 @@ ${lastSnapshot}`;
80156
80234
  init_git_worktree();
80157
80235
  init_config();
80158
80236
  init_config_dir();
80159
- var os52 = __toESM2(require("os"));
80237
+ var os62 = __toESM2(require("os"));
80160
80238
  var path12 = __toESM2(require("path"));
80161
80239
  var import_session_host_core22 = require_dist();
80162
80240
  init_config_dir();
@@ -80200,7 +80278,7 @@ ${lastSnapshot}`;
80200
80278
  var cached22 = null;
80201
80279
  function resolveInstanceContext(options = {}) {
80202
80280
  const env2 = options.env ?? process.env;
80203
- const homeDir = options.homeDir ?? os52.homedir();
80281
+ const homeDir = options.homeDir ?? os62.homedir();
80204
80282
  const envDir = typeof env2.ADHDEV_CONFIG_DIR === "string" ? env2.ADHDEV_CONFIG_DIR.trim() : "";
80205
80283
  const explicitDir = typeof options.configDir === "string" ? options.configDir.trim() : "";
80206
80284
  if (explicitDir && envDir && (0, import_session_host_core22.canonicalizeInstancePath)(explicitDir) !== (0, import_session_host_core22.canonicalizeInstancePath)(envDir)) {
@@ -80221,7 +80299,7 @@ ${lastSnapshot}`;
80221
80299
  }
80222
80300
  function getProcessInstanceContext(options = {}) {
80223
80301
  const envDir = typeof process.env.ADHDEV_CONFIG_DIR === "string" ? process.env.ADHDEV_CONFIG_DIR.trim() : "";
80224
- const key2 = `${envDir}|${os52.homedir()}|${options.standalone ? "standalone" : "daemon"}`;
80302
+ const key2 = `${envDir}|${os62.homedir()}|${options.standalone ? "standalone" : "daemon"}`;
80225
80303
  if (!cached22 || cached22.key !== key2) {
80226
80304
  cached22 = { key: key2, context: resolveInstanceContext({ standalone: options.standalone }) };
80227
80305
  }
@@ -81525,17 +81603,17 @@ ${lastSnapshot}`;
81525
81603
  return null;
81526
81604
  }
81527
81605
  async function detectIDEs(providerLoader) {
81528
- const os28 = (0, import_os3.platform)();
81606
+ const os29 = (0, import_os3.platform)();
81529
81607
  const results = [];
81530
81608
  for (const def of getMergedDefinitions()) {
81531
81609
  const cliPath = findCliCommand(providerLoader?.getIdeCliCommand(def.id, def.cli) || def.cli);
81532
- const appPath = checkPathExists(providerLoader?.getIdePathCandidates(def.id, def.paths[os28] || []) || []);
81610
+ const appPath = checkPathExists(providerLoader?.getIdePathCandidates(def.id, def.paths[os29] || []) || []);
81533
81611
  let resolvedCli = cliPath;
81534
- if (!resolvedCli && appPath && os28 === "darwin") {
81612
+ if (!resolvedCli && appPath && os29 === "darwin") {
81535
81613
  const bundledCli = `${appPath}/Contents/Resources/app/bin/${def.cli}`;
81536
81614
  if ((0, import_fs17.existsSync)(bundledCli)) resolvedCli = bundledCli;
81537
81615
  }
81538
- if (!resolvedCli && appPath && os28 === "win32") {
81616
+ if (!resolvedCli && appPath && os29 === "win32") {
81539
81617
  const { dirname: dirname23 } = await import("path");
81540
81618
  const appDir = dirname23(appPath);
81541
81619
  const candidates = [
@@ -81552,7 +81630,7 @@ ${lastSnapshot}`;
81552
81630
  }
81553
81631
  }
81554
81632
  }
81555
- const installed = os28 === "darwin" ? !!(resolvedCli || appPath) : !!resolvedCli;
81633
+ const installed = os29 === "darwin" ? !!(resolvedCli || appPath) : !!resolvedCli;
81556
81634
  const version2 = null;
81557
81635
  results.push({
81558
81636
  id: def.id,
@@ -88255,7 +88333,7 @@ ${effect.notification.body || ""}`.trim();
88255
88333
  }
88256
88334
  var fs15 = __toESM2(require("fs"));
88257
88335
  var path232 = __toESM2(require("path"));
88258
- var os10 = __toESM2(require("os"));
88336
+ var os11 = __toESM2(require("os"));
88259
88337
  var KEY_TO_VK = {
88260
88338
  Backspace: 8,
88261
88339
  Tab: 9,
@@ -88509,7 +88587,7 @@ ${effect.notification.body || ""}`.trim();
88509
88587
  function resolveSafePath(requestedPath) {
88510
88588
  const rawPath = typeof requestedPath === "string" ? requestedPath.trim() : "";
88511
88589
  const inputPath = rawPath || ".";
88512
- const home = os10.homedir();
88590
+ const home = os11.homedir();
88513
88591
  if (inputPath.startsWith("~")) {
88514
88592
  return path232.resolve(path232.join(home, inputPath.slice(1)));
88515
88593
  }
@@ -90914,7 +90992,7 @@ ${effect.notification.body || ""}`.trim();
90914
90992
  var import_child_process8 = require("child_process");
90915
90993
  var import_child_process9 = require("child_process");
90916
90994
  var fs20 = __toESM2(require("fs"));
90917
- var os11 = __toESM2(require("os"));
90995
+ var os12 = __toESM2(require("os"));
90918
90996
  var path26 = __toESM2(require("path"));
90919
90997
  var import_child_process7 = require("child_process");
90920
90998
  var fs19 = __toESM2(require("fs"));
@@ -91781,7 +91859,7 @@ exec "${portableNode}" "${cliEntry}" "$@"
91781
91859
  const packageRoot = findCurrentPackageRoot(options.currentCliPath || process.argv[1], options.packageName);
91782
91860
  const npmInvocation = resolveSiblingNpmInvocation(options.nodeExecutable || process.execPath, options.platform);
91783
91861
  const platform10 = options.platform || process.platform;
91784
- const homeDir = options.homeDir || os11.homedir();
91862
+ const homeDir = options.homeDir || os12.homedir();
91785
91863
  const instanceDir = options.instanceDir || resolveInstanceDir();
91786
91864
  let installPrefix = packageRoot ? resolveInstallPrefixFromPackageRoot(packageRoot, options.packageName) : null;
91787
91865
  if (platform10 === "win32" && isPortableNode22Prefix(installPrefix, homeDir, instanceDir)) {
@@ -92193,12 +92271,12 @@ ${marker}`,
92193
92271
  }
92194
92272
  const instanceDir = resolveInstanceDir();
92195
92273
  const windowsInstallerLayout = resolveWindowsInstallerLayout({
92196
- homeDir: os11.homedir(),
92274
+ homeDir: os12.homedir(),
92197
92275
  installPrefix: installCommand.surface.installPrefix,
92198
92276
  instanceDir
92199
92277
  });
92200
92278
  if (windowsInstallerLayout) {
92201
- const portableNode = findPortableNode22(os11.homedir(), process.execPath, instanceDir);
92279
+ const portableNode = findPortableNode22(os12.homedir(), process.execPath, instanceDir);
92202
92280
  if (!portableNode) {
92203
92281
  throw new Error("installer-managed Windows update requires the portable Node.js 22 runtime");
92204
92282
  }
@@ -93335,7 +93413,7 @@ ${marker}`,
93335
93413
  })
93336
93414
  );
93337
93415
  init_dist();
93338
- var os20 = __toESM2(require("os"));
93416
+ var os21 = __toESM2(require("os"));
93339
93417
  var path35 = __toESM2(require("path"));
93340
93418
  var crypto6 = __toESM2(require("crypto"));
93341
93419
  var import_fs18 = require("fs");
@@ -93429,7 +93507,7 @@ ${marker}`,
93429
93507
  }
93430
93508
  }
93431
93509
  init_summary_metadata();
93432
- var os19 = __toESM2(require("os"));
93510
+ var os20 = __toESM2(require("os"));
93433
93511
  var crypto5 = __toESM2(require("crypto"));
93434
93512
  var fs31 = __toESM2(require("fs"));
93435
93513
  init_contracts2();
@@ -93569,7 +93647,7 @@ ${marker}`,
93569
93647
  var path31 = __toESM2(require("path"));
93570
93648
  init_provider_cli_adapter();
93571
93649
  var fs25 = __toESM2(require("fs"));
93572
- var os17 = __toESM2(require("os"));
93650
+ var os18 = __toESM2(require("os"));
93573
93651
  var path30 = __toESM2(require("path"));
93574
93652
  init_terminal_screen();
93575
93653
  var import_session_host_core9 = require_dist();
@@ -93748,12 +93826,12 @@ ${marker}`,
93748
93826
  init_fsm_types();
93749
93827
  init_fsm_loader();
93750
93828
  var fs24 = __toESM2(require("fs"));
93751
- var os16 = __toESM2(require("os"));
93829
+ var os17 = __toESM2(require("os"));
93752
93830
  var path29 = __toESM2(require("path"));
93753
93831
  init_logger();
93754
93832
  function expandHome2(p) {
93755
- if (p === "~") return os16.homedir();
93756
- if (p.startsWith("~/")) return path29.join(os16.homedir(), p.slice(2));
93833
+ if (p === "~") return os17.homedir();
93834
+ if (p.startsWith("~/")) return path29.join(os17.homedir(), p.slice(2));
93757
93835
  return p;
93758
93836
  }
93759
93837
  function realWorkspacePath(workingDir) {
@@ -94589,7 +94667,7 @@ ${marker}`,
94589
94667
  }
94590
94668
  fireDelegate(d) {
94591
94669
  const ev = this.currentEval;
94592
- const task = d.task_template.replace(/\{node\}/g, os17.hostname()).replace(/\{state\.label\}/g, ev?.state.label ?? "").replace(/\{state\.title\}/g, ev?.state.title ?? "").replace(/\{duration_ms\}/g, String(d.after_duration_ms ?? 0));
94670
+ const task = d.task_template.replace(/\{node\}/g, os18.hostname()).replace(/\{state\.label\}/g, ev?.state.label ?? "").replace(/\{state\.title\}/g, ev?.state.title ?? "").replace(/\{duration_ms\}/g, String(d.after_duration_ms ?? 0));
94593
94671
  this.emit({ kind: "delegate", id: d.id, task });
94594
94672
  }
94595
94673
  // ────────────────────────────────────────────────────────────────────
@@ -94983,7 +95061,7 @@ ${marker}`,
94983
95061
  const ctl = (this.spec.control_bar ?? []).find((c) => c.action.type === "attach_image");
94984
95062
  if (!ctl || ctl.action.type !== "attach_image") return;
94985
95063
  const ext = guessExt(mime);
94986
- const tmp = path30.join(os17.tmpdir(), `adhdev-attach-${Date.now()}${ext}`);
95064
+ const tmp = path30.join(os18.tmpdir(), `adhdev-attach-${Date.now()}${ext}`);
94987
95065
  try {
94988
95066
  fs25.writeFileSync(tmp, Buffer.from(blob, "base64"));
94989
95067
  } catch {
@@ -96282,7 +96360,7 @@ ${marker}`,
96282
96360
  init_transcript_claim_registry();
96283
96361
  init_chat_message_normalization();
96284
96362
  init_working_dir();
96285
- var os18 = __toESM2(require("os"));
96363
+ var os19 = __toESM2(require("os"));
96286
96364
  var path322 = __toESM2(require("path"));
96287
96365
  var crypto4 = __toESM2(require("crypto"));
96288
96366
  var fs28 = __toESM2(require("fs"));
@@ -96353,7 +96431,7 @@ ${marker}`,
96353
96431
  const promptParts = [];
96354
96432
  const imageRefs = [];
96355
96433
  const resourceRefs = [];
96356
- const materializeDir = options.materializeDir || path322.join(os18.tmpdir(), "adhdev-input-media");
96434
+ const materializeDir = options.materializeDir || path322.join(os19.tmpdir(), "adhdev-input-media");
96357
96435
  input.parts.forEach((part, index) => {
96358
96436
  if (part.type === "text" && part.text.trim()) {
96359
96437
  promptParts.push(part.text.trim());
@@ -98563,7 +98641,7 @@ ${buttons.join("\n")}`;
98563
98641
  * Replaces the previously duplicated probeOpenCode/Codex/Goose functions.
98564
98642
  */
98565
98643
  probeSessionIdFromConfig(probe) {
98566
- const resolvedDbPath = probe.dbPath.replace(/^~/, os19.homedir());
98644
+ const resolvedDbPath = probe.dbPath.replace(/^~/, os20.homedir());
98567
98645
  const now = Date.now();
98568
98646
  if (this.sqliteProbeCache.missingUntil > now) return null;
98569
98647
  if (!fs31.existsSync(resolvedDbPath)) {
@@ -102126,7 +102204,7 @@ ${rawInput}` : rawInput;
102126
102204
  }
102127
102205
  function expandExecutable(command) {
102128
102206
  const trimmed = command.trim();
102129
- return trimmed.startsWith("~") ? path35.join(os20.homedir(), trimmed.slice(1)) : trimmed;
102207
+ return trimmed.startsWith("~") ? path35.join(os21.homedir(), trimmed.slice(1)) : trimmed;
102130
102208
  }
102131
102209
  function commandExists(command) {
102132
102210
  const trimmed = command.trim();
@@ -102276,9 +102354,9 @@ ${rawInput}` : rawInput;
102276
102354
  return false;
102277
102355
  }
102278
102356
  function ensureEmptyDelegatedMcpConfig(workspace) {
102279
- const baseDir = path35.join(os20.tmpdir(), "adhdev-delegated-agent-empty-mcp");
102357
+ const baseDir = path35.join(os21.tmpdir(), "adhdev-delegated-agent-empty-mcp");
102280
102358
  (0, import_fs18.mkdirSync)(baseDir, { recursive: true });
102281
- const workspaceHash = shortHash(path35.resolve(workspace || os20.tmpdir()));
102359
+ const workspaceHash = shortHash(path35.resolve(workspace || os21.tmpdir()));
102282
102360
  const filePath = path35.join(baseDir, `${workspaceHash}.json`);
102283
102361
  (0, import_fs18.writeFileSync)(filePath, JSON.stringify({ mcpServers: {} }, null, 2), "utf-8");
102284
102362
  return filePath;
@@ -102673,7 +102751,7 @@ ${rawInput}` : rawInput;
102673
102751
  async startSession(cliType, workingDir, cliArgs, initialModel, options) {
102674
102752
  const trimmed = (workingDir || "").trim();
102675
102753
  if (!trimmed) throw new Error("working directory required");
102676
- const resolvedDir = trimmed.startsWith("~") ? trimmed.replace(/^~/, os20.homedir()) : path35.resolve(trimmed);
102754
+ const resolvedDir = trimmed.startsWith("~") ? trimmed.replace(/^~/, os21.homedir()) : path35.resolve(trimmed);
102677
102755
  const normalizedType = this.providerLoader.resolveAlias(cliType);
102678
102756
  const rawProvider = this.providerLoader.getByAlias(cliType);
102679
102757
  const provider = rawProvider ? this.providerLoader.resolve(normalizedType) || rawProvider : void 0;
@@ -103700,7 +103778,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
103700
103778
  };
103701
103779
  var import_child_process12 = require("child_process");
103702
103780
  var net3 = __toESM2(require("net"));
103703
- var os24 = __toESM2(require("os"));
103781
+ var os25 = __toESM2(require("os"));
103704
103782
  var path46 = __toESM2(require("path"));
103705
103783
  var fs41 = __toESM2(require("fs"));
103706
103784
  var path45 = __toESM2(require("path"));
@@ -104170,7 +104248,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
104170
104248
  init_config();
104171
104249
  init_native_history_executor();
104172
104250
  var fs36 = __toESM2(require("fs"));
104173
- var os23 = __toESM2(require("os"));
104251
+ var os24 = __toESM2(require("os"));
104174
104252
  var path40 = __toESM2(require("path"));
104175
104253
  var fs322 = __toESM2(require("fs"));
104176
104254
  var path36 = __toESM2(require("path"));
@@ -104706,7 +104784,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
104706
104784
  }
104707
104785
  var fs34 = __toESM2(require("fs"));
104708
104786
  var path38 = __toESM2(require("path"));
104709
- var os21 = __toESM2(require("os"));
104787
+ var os222 = __toESM2(require("os"));
104710
104788
  init_load_better_sqlite3();
104711
104789
  init_logger();
104712
104790
  function extractTimestampValue3(value) {
@@ -104730,7 +104808,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
104730
104808
  return /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(value);
104731
104809
  }
104732
104810
  function antigravityRoot() {
104733
- return path38.join(os21.homedir(), ".gemini", "antigravity-cli");
104811
+ return path38.join(os222.homedir(), ".gemini", "antigravity-cli");
104734
104812
  }
104735
104813
  function historyJsonlPath() {
104736
104814
  return path38.join(antigravityRoot(), "history.jsonl");
@@ -105345,11 +105423,11 @@ Run 'adhdev doctor' for detailed diagnostics.`
105345
105423
  }
105346
105424
  var fs35 = __toESM2(require("fs"));
105347
105425
  var path39 = __toESM2(require("path"));
105348
- var os222 = __toESM2(require("os"));
105426
+ var os23 = __toESM2(require("os"));
105349
105427
  init_load_better_sqlite3();
105350
105428
  init_usage_normalize();
105351
- var HERMES_STATE_DB = path39.join(os222.homedir(), ".hermes", "state.db");
105352
- var HERMES_LEGACY_SESSIONS_DIR = path39.join(os222.homedir(), ".hermes", "sessions");
105429
+ var HERMES_STATE_DB = path39.join(os23.homedir(), ".hermes", "state.db");
105430
+ var HERMES_LEGACY_SESSIONS_DIR = path39.join(os23.homedir(), ".hermes", "sessions");
105353
105431
  function statMtimeMs4(p) {
105354
105432
  try {
105355
105433
  return Math.floor(fs35.statSync(p).mtimeMs);
@@ -105637,7 +105715,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
105637
105715
  }
105638
105716
  }
105639
105717
  function resolveClaudePath(workspace, sessionId) {
105640
- const dir = path40.join(os23.homedir(), ".claude", "projects", cwdAsDashes(workspace));
105718
+ const dir = path40.join(os24.homedir(), ".claude", "projects", cwdAsDashes(workspace));
105641
105719
  if (!fs36.existsSync(dir)) return null;
105642
105720
  if (sessionId) {
105643
105721
  const candidate = path40.join(dir, `${sessionId}.jsonl`);
@@ -105759,7 +105837,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
105759
105837
  }
105760
105838
  var AGY_SPAWN_CLAIM_GRACE_MS = 2e3;
105761
105839
  function resolveAntigravityPath(workspace, sessionId, sessionStartedAtMs, instanceId) {
105762
- const agyRoot = path40.join(os23.homedir(), ".gemini", "antigravity-cli");
105840
+ const agyRoot = path40.join(os24.homedir(), ".gemini", "antigravity-cli");
105763
105841
  const owner = antigravityOwnerToken(workspace, sessionStartedAtMs, instanceId);
105764
105842
  if (sessionId && isUuidLikeSessionId2(sessionId)) {
105765
105843
  const dbPath = path40.join(agyRoot, "conversations", `${sessionId}.db`);
@@ -105843,9 +105921,9 @@ Run 'adhdev doctor' for detailed diagnostics.`
105843
105921
  function resolveHermesPath(workspace, sessionId) {
105844
105922
  void workspace;
105845
105923
  void sessionId;
105846
- const dbPath = path40.join(os23.homedir(), ".hermes", "state.db");
105924
+ const dbPath = path40.join(os24.homedir(), ".hermes", "state.db");
105847
105925
  if (fs36.existsSync(dbPath)) return dbPath;
105848
- const dir = path40.join(os23.homedir(), ".hermes", "sessions");
105926
+ const dir = path40.join(os24.homedir(), ".hermes", "sessions");
105849
105927
  if (!fs36.existsSync(dir)) return null;
105850
105928
  return newestRecentFile2(dir, /^session_.*\.json$/);
105851
105929
  }
@@ -105871,7 +105949,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
105871
105949
  return cwd.replace(/\//g, "-");
105872
105950
  }
105873
105951
  function codexSessionsRoot() {
105874
- return path40.join(os23.homedir(), ".codex", "sessions");
105952
+ return path40.join(os24.homedir(), ".codex", "sessions");
105875
105953
  }
105876
105954
  function isUuidLikeSessionId2(sessionId) {
105877
105955
  return /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(sessionId);
@@ -108890,7 +108968,7 @@ ${formatManifestValidationIssues2(validation2.issues)}`);
108890
108968
  });
108891
108969
  }
108892
108970
  async function killIdeProcess(ideId) {
108893
- const plat = os24.platform();
108971
+ const plat = os25.platform();
108894
108972
  const appName = getMacAppIdentifiers()[ideId];
108895
108973
  const winProcesses = getWinProcessNames()[ideId];
108896
108974
  try {
@@ -108951,7 +109029,7 @@ ${formatManifestValidationIssues2(validation2.issues)}`);
108951
109029
  }
108952
109030
  }
108953
109031
  async function isIdeRunning(ideId) {
108954
- const plat = os24.platform();
109032
+ const plat = os25.platform();
108955
109033
  try {
108956
109034
  if (plat === "darwin") {
108957
109035
  const appName = getMacAppIdentifiers()[ideId];
@@ -109006,7 +109084,7 @@ ${formatManifestValidationIssues2(validation2.issues)}`);
109006
109084
  }
109007
109085
  }
109008
109086
  async function detectCurrentWorkspace(ideId) {
109009
- const plat = os24.platform();
109087
+ const plat = os25.platform();
109010
109088
  if (plat === "darwin") {
109011
109089
  try {
109012
109090
  const appName = getMacAppIdentifiers()[ideId];
@@ -109026,7 +109104,7 @@ ${formatManifestValidationIssues2(validation2.issues)}`);
109026
109104
  const appName = appNameMap[ideId];
109027
109105
  if (appName) {
109028
109106
  const storagePath = path46.join(
109029
- process.env.APPDATA || path46.join(os24.homedir(), "AppData", "Roaming"),
109107
+ process.env.APPDATA || path46.join(os25.homedir(), "AppData", "Roaming"),
109030
109108
  appName,
109031
109109
  "storage.json"
109032
109110
  );
@@ -109048,7 +109126,7 @@ ${formatManifestValidationIssues2(validation2.issues)}`);
109048
109126
  return void 0;
109049
109127
  }
109050
109128
  async function launchWithCdp(options = {}) {
109051
- const platform10 = os24.platform();
109129
+ const platform10 = os25.platform();
109052
109130
  let targetIde;
109053
109131
  const ides = await detectIDEs(getProviderLoader());
109054
109132
  if (options.ideId) {
@@ -109339,6 +109417,7 @@ ${formatManifestValidationIssues2(validation2.issues)}`);
109339
109417
  }
109340
109418
  };
109341
109419
  init_dist();
109420
+ init_repo_mesh_types();
109342
109421
  init_mesh_host_ownership();
109343
109422
  init_worktree_bootstrap_config();
109344
109423
  init_mesh_events();
@@ -109610,11 +109689,11 @@ ${formatManifestValidationIssues2(validation2.issues)}`);
109610
109689
  MESH_JSON_CONFIG_LOCATIONS: MESH_JSON_CONFIG_LOCATIONS2
109611
109690
  } = await Promise.resolve().then(() => (init_mesh_json_config(), mesh_json_config_exports));
109612
109691
  const { mkdirSync: mkdirSync30, writeFileSync: writeFileSync30 } = await import("fs");
109613
- const { dirname: dirname23, join: join62 } = await import("path");
109692
+ const { dirname: dirname23, join: join63 } = await import("path");
109614
109693
  const scaffold = buildMeshJsonConfigScaffold2(mesh);
109615
109694
  const scaffoldJson = serializeMeshJsonConfigScaffold2(scaffold);
109616
109695
  const relativePath = MESH_JSON_CONFIG_LOCATIONS2[0];
109617
- const absolutePath = join62(workspace, relativePath);
109696
+ const absolutePath = join63(workspace, relativePath);
109618
109697
  const validation = normalizeRepoMeshDeclarativeConfig2(scaffold);
109619
109698
  if (!validation.valid) {
109620
109699
  return { success: false, meshId, error: `invalid mesh.json scaffold: ${validation.errors.join("; ")}` };
@@ -109721,14 +109800,14 @@ ${formatManifestValidationIssues2(validation2.issues)}`);
109721
109800
  MESH_JSON_CONFIG_LOCATIONS: MESH_JSON_CONFIG_LOCATIONS2
109722
109801
  } = await Promise.resolve().then(() => (init_mesh_json_config(), mesh_json_config_exports));
109723
109802
  const { existsSync: existsSync62, readFileSync: readFileSync53, mkdirSync: mkdirSync30, writeFileSync: writeFileSync30 } = await import("fs");
109724
- const { dirname: dirname23, join: join62 } = await import("path");
109803
+ const { dirname: dirname23, join: join63 } = await import("path");
109725
109804
  const yaml6 = await Promise.resolve().then(() => (init_js_yaml(), js_yaml_exports));
109726
109805
  const relativePath = MESH_JSON_CONFIG_LOCATIONS2[0];
109727
109806
  let baseDoc = { version: 1 };
109728
- let existingPath = join62(workspace, relativePath);
109807
+ let existingPath = join63(workspace, relativePath);
109729
109808
  let existedAsYaml = false;
109730
109809
  for (const relative8 of MESH_JSON_CONFIG_LOCATIONS2) {
109731
- const candidate = join62(workspace, relative8);
109810
+ const candidate = join63(workspace, relative8);
109732
109811
  if (!existsSync62(candidate)) continue;
109733
109812
  try {
109734
109813
  const text = readFileSync53(candidate, "utf-8");
@@ -109914,6 +109993,59 @@ ${formatManifestValidationIssues2(validation2.issues)}`);
109914
109993
  return { success: false, error: e.message };
109915
109994
  }
109916
109995
  },
109996
+ // ─── Quota-aware routing thresholds (PER MESH, machine-local) ───
109997
+ // The dedicated write path for RepoMeshPolicy.quotaRouting — previously only
109998
+ // reachable as a raw JSON patch through update_mesh's general `policy`
109999
+ // passthrough. The launch gate / fitness spread read the EFFECTIVE thresholds
110000
+ // through resolveQuotaRoutingPolicy, so `resolved` below is exactly what the
110001
+ // gate will apply; `quotaRouting` is the persisted overrides-only view
110002
+ // (fields equal to the defaults are never persisted — persistence economy).
110003
+ mesh_quota_routing_get: async (_ctx, args) => {
110004
+ const requestedMeshId = typeof args?.meshId === "string" ? args.meshId.trim() : "";
110005
+ try {
110006
+ const { getMeshQuotaRouting: getMeshQuotaRouting2, resolveScopedMeshId: resolveScopedMeshId2 } = await Promise.resolve().then(() => (init_mesh_config(), mesh_config_exports));
110007
+ const overrides = getMeshQuotaRouting2(requestedMeshId || void 0);
110008
+ const meshId = requestedMeshId || resolveScopedMeshId2();
110009
+ return {
110010
+ success: true,
110011
+ quotaRouting: overrides,
110012
+ resolved: resolveQuotaRoutingPolicy(overrides),
110013
+ defaults: DEFAULT_QUOTA_ROUTING_POLICY,
110014
+ scope: {
110015
+ kind: "mesh",
110016
+ storage: "machine_local",
110017
+ meshId: meshId ?? null,
110018
+ resolvedFrom: requestedMeshId ? "explicit" : meshId ? "sole_mesh" : "ambiguous",
110019
+ ...requestedMeshId || meshId ? {} : {
110020
+ note: "Several meshes are configured and no meshId was given, so these are the shipped defaults, not any mesh's saved thresholds. Pass meshId."
110021
+ }
110022
+ }
110023
+ };
110024
+ } catch (e) {
110025
+ return { success: false, error: e.message };
110026
+ }
110027
+ },
110028
+ mesh_quota_routing_set: async (ctx, args) => {
110029
+ const requestedMeshId = typeof args?.meshId === "string" ? args.meshId.trim() : "";
110030
+ try {
110031
+ const { setMeshQuotaRouting: setMeshQuotaRouting2, getMesh: getMesh2, resolveScopedMeshId: resolveScopedMeshId2 } = await Promise.resolve().then(() => (init_mesh_config(), mesh_config_exports));
110032
+ const quotaRouting = setMeshQuotaRouting2(args?.quotaRouting, requestedMeshId || void 0);
110033
+ const meshId = requestedMeshId || resolveScopedMeshId2();
110034
+ if (meshId) {
110035
+ const fresh = getMesh2(meshId);
110036
+ if (fresh && ctx.getCachedInlineMesh(meshId)) ctx.inlineMeshCache.set(meshId, fresh);
110037
+ ctx.invalidateAggregateMeshStatus(meshId);
110038
+ }
110039
+ return {
110040
+ success: true,
110041
+ quotaRouting,
110042
+ resolved: resolveQuotaRoutingPolicy(quotaRouting),
110043
+ meshId: meshId ?? null
110044
+ };
110045
+ } catch (e) {
110046
+ return { success: false, error: e.message };
110047
+ }
110048
+ },
109917
110049
  add_mesh_node: async (ctx, args) => {
109918
110050
  const meshId = typeof args?.meshId === "string" ? args.meshId.trim() : "";
109919
110051
  const workspace = typeof args?.workspace === "string" ? args.workspace.trim() : "";
@@ -120071,7 +120203,7 @@ ${e?.stderr || ""}`;
120071
120203
  init_chat_message_normalization();
120072
120204
  var fs49 = __toESM2(require("fs"));
120073
120205
  var path48 = __toESM2(require("path"));
120074
- var os25 = __toESM2(require("os"));
120206
+ var os26 = __toESM2(require("os"));
120075
120207
  var import_os6 = require("os");
120076
120208
  init_config();
120077
120209
  var import_child_process13 = require("child_process");
@@ -120196,7 +120328,7 @@ ${e?.stderr || ""}`;
120196
120328
  function checkPathExists2(paths) {
120197
120329
  for (const p of paths) {
120198
120330
  if (p.includes("*")) {
120199
- const home = os25.homedir();
120331
+ const home = os26.homedir();
120200
120332
  const resolved = p.replace(/\*/g, home.split(path48.sep).pop() || "");
120201
120333
  if (fs49.existsSync(resolved)) return resolved;
120202
120334
  } else {
@@ -122593,7 +122725,7 @@ async (params) => {
122593
122725
  }
122594
122726
  var fs52 = __toESM2(require("fs"));
122595
122727
  var path51 = __toESM2(require("path"));
122596
- var os26 = __toESM2(require("os"));
122728
+ var os27 = __toESM2(require("os"));
122597
122729
  var import_session_host_core11 = require_dist();
122598
122730
  function getAutoImplPid(ctx) {
122599
122731
  const pid = ctx.autoImplProcess?.pid;
@@ -122795,7 +122927,7 @@ async (params) => {
122795
122927
  });
122796
122928
  const referenceScripts = loadAutoImplReferenceScripts(ctx, resolvedReference);
122797
122929
  const prompt = buildAutoImplPrompt(ctx, type2, provider, providerDir, functions, domContext, referenceScripts, comment, resolvedReference, verification);
122798
- const tmpDir = path51.join(os26.tmpdir(), "adhdev-autoimpl");
122930
+ const tmpDir = path51.join(os27.tmpdir(), "adhdev-autoimpl");
122799
122931
  if (!fs52.existsSync(tmpDir)) fs52.mkdirSync(tmpDir, { recursive: true });
122800
122932
  const promptFile = path51.join(tmpDir, `prompt-${type2}-${Date.now()}.md`);
122801
122933
  fs52.writeFileSync(promptFile, prompt, "utf-8");
@@ -122950,7 +123082,7 @@ async (params) => {
122950
123082
  const interactiveFlags = ["--yolo", "--interactive", "-i"];
122951
123083
  const baseArgs = [...spawn7.args || []].filter((a) => !interactiveFlags.includes(a));
122952
123084
  let shellCmd;
122953
- const isWin = os26.platform() === "win32";
123085
+ const isWin = os27.platform() === "win32";
122954
123086
  const escapeArg = (a) => isWin ? `"${a.replace(/"/g, '""')}"` : `'${a.replace(/'/g, "'\\''")}'`;
122955
123087
  const promptMode = autoImpl?.promptMode ?? "stdin";
122956
123088
  const extraArgs = autoImpl?.extraArgs ?? [];
@@ -122989,7 +123121,7 @@ async (params) => {
122989
123121
  try {
122990
123122
  const pty = require("node-pty");
122991
123123
  ctx.log(`Auto-implement spawn (PTY): ${shellCmd}`);
122992
- const isWin2 = os26.platform() === "win32";
123124
+ const isWin2 = os27.platform() === "win32";
122993
123125
  child = pty.spawn(isWin2 ? "cmd.exe" : process.env.SHELL || "/bin/zsh", [isWin2 ? "/c" : "-c", shellCmd], {
122994
123126
  name: "xterm-256color",
122995
123127
  cols: import_session_host_core11.DEFAULT_SESSION_HOST_COLS,
@@ -125645,7 +125777,7 @@ data: ${JSON.stringify(msg.data)}
125645
125777
  }
125646
125778
  var import_child_process14 = require("child_process");
125647
125779
  var fs54 = __toESM2(require("fs"));
125648
- var os27 = __toESM2(require("os"));
125780
+ var os28 = __toESM2(require("os"));
125649
125781
  var path53 = __toESM2(require("path"));
125650
125782
  var import_session_host_core15 = require_dist();
125651
125783
  init_logger();
@@ -125717,7 +125849,7 @@ data: ${JSON.stringify(msg.data)}
125717
125849
  }
125718
125850
  let portableNode = null;
125719
125851
  try {
125720
- portableNode = findPortableNode22(os27.homedir(), process.execPath, resolveInstanceDir());
125852
+ portableNode = findPortableNode22(os28.homedir(), process.execPath, resolveInstanceDir());
125721
125853
  } catch (error48) {
125722
125854
  LOG2.warn(
125723
125855
  "SessionHost",