@adhdev/daemon-standalone 1.0.45-rc.6 → 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 +391 -210
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
- package/public/assets/index-CH6cVfIs.js +116 -0
- package/public/assets/index-TrEtD2r5.css +1 -0
- package/public/index.html +2 -2
- package/vendor/mcp-server/index.js +14 -2
- package/vendor/mcp-server/index.js.map +1 -1
- package/public/assets/index-Bf3SwIU_.js +0 -121
- package/public/assets/index-zRNkTYHz.css +0 -1
package/dist/index.js
CHANGED
|
@@ -36227,6 +36227,7 @@ var require_dist3 = __commonJS({
|
|
|
36227
36227
|
function normalizeMeshSchedulingStrategy(value) {
|
|
36228
36228
|
if (typeof value !== "string") return DEFAULT_MESH_SCHEDULING_STRATEGY;
|
|
36229
36229
|
const trimmed = value.trim();
|
|
36230
|
+
if (trimmed === "least_loaded" || trimmed === "round_robin") return "fitness";
|
|
36230
36231
|
return MESH_SCHEDULING_STRATEGIES.includes(trimmed) ? trimmed : DEFAULT_MESH_SCHEDULING_STRATEGY;
|
|
36231
36232
|
}
|
|
36232
36233
|
function resolveNodeSchedulingPriority(nodePolicy) {
|
|
@@ -36239,12 +36240,14 @@ var require_dist3 = __commonJS({
|
|
|
36239
36240
|
function resolveQuotaRoutingPolicy(value) {
|
|
36240
36241
|
const staleAfterMs = Number(value?.staleAfterMs);
|
|
36241
36242
|
const sessionMin = Number(value?.sessionMinRemainingPercent);
|
|
36243
|
+
const sessionResetImminentMs = Number(value?.sessionResetImminentMs);
|
|
36242
36244
|
const weeklyMin = Number(value?.weeklyMinRemainingPercent);
|
|
36243
36245
|
const spreadMax = Number(value?.spreadBonusMax);
|
|
36244
36246
|
const clampPercentField = (n, fallback) => Number.isFinite(n) ? Math.min(100, Math.max(0, n)) : fallback;
|
|
36245
36247
|
return {
|
|
36246
36248
|
staleAfterMs: Number.isFinite(staleAfterMs) && staleAfterMs >= 0 ? Math.floor(staleAfterMs) : DEFAULT_QUOTA_ROUTING_POLICY.staleAfterMs,
|
|
36247
36249
|
sessionMinRemainingPercent: clampPercentField(sessionMin, DEFAULT_QUOTA_ROUTING_POLICY.sessionMinRemainingPercent),
|
|
36250
|
+
sessionResetImminentMs: Number.isFinite(sessionResetImminentMs) && sessionResetImminentMs >= 0 ? Math.floor(sessionResetImminentMs) : DEFAULT_QUOTA_ROUTING_POLICY.sessionResetImminentMs,
|
|
36248
36251
|
weeklyMinRemainingPercent: clampPercentField(weeklyMin, DEFAULT_QUOTA_ROUTING_POLICY.weeklyMinRemainingPercent),
|
|
36249
36252
|
spreadBonusMax: Number.isFinite(spreadMax) && spreadMax >= 0 ? spreadMax : DEFAULT_QUOTA_ROUTING_POLICY.spreadBonusMax
|
|
36250
36253
|
};
|
|
@@ -36260,6 +36263,9 @@ var require_dist3 = __commonJS({
|
|
|
36260
36263
|
if (record2.sessionMinRemainingPercent !== void 0 && resolved.sessionMinRemainingPercent !== DEFAULT_QUOTA_ROUTING_POLICY.sessionMinRemainingPercent) {
|
|
36261
36264
|
out.sessionMinRemainingPercent = resolved.sessionMinRemainingPercent;
|
|
36262
36265
|
}
|
|
36266
|
+
if (record2.sessionResetImminentMs !== void 0 && resolved.sessionResetImminentMs !== DEFAULT_QUOTA_ROUTING_POLICY.sessionResetImminentMs) {
|
|
36267
|
+
out.sessionResetImminentMs = resolved.sessionResetImminentMs;
|
|
36268
|
+
}
|
|
36263
36269
|
if (record2.weeklyMinRemainingPercent !== void 0 && resolved.weeklyMinRemainingPercent !== DEFAULT_QUOTA_ROUTING_POLICY.weeklyMinRemainingPercent) {
|
|
36264
36270
|
out.weeklyMinRemainingPercent = resolved.weeklyMinRemainingPercent;
|
|
36265
36271
|
}
|
|
@@ -36499,6 +36505,7 @@ var require_dist3 = __commonJS({
|
|
|
36499
36505
|
DEFAULT_QUOTA_ROUTING_POLICY = {
|
|
36500
36506
|
staleAfterMs: 30 * 60 * 1e3,
|
|
36501
36507
|
sessionMinRemainingPercent: 10,
|
|
36508
|
+
sessionResetImminentMs: 5 * 60 * 1e3,
|
|
36502
36509
|
weeklyMinRemainingPercent: 15,
|
|
36503
36510
|
spreadBonusMax: 30
|
|
36504
36511
|
};
|
|
@@ -37020,10 +37027,10 @@ var require_dist3 = __commonJS({
|
|
|
37020
37027
|
}
|
|
37021
37028
|
function getDaemonBuildInfo() {
|
|
37022
37029
|
if (cached2) return cached2;
|
|
37023
|
-
const commit = readInjected(true ? "
|
|
37024
|
-
const commitShort = readInjected(true ? "
|
|
37025
|
-
const version2 = readInjected(true ? "1.0.45-rc.
|
|
37026
|
-
const builtAt = readInjected(true ? "2026-08-
|
|
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);
|
|
37027
37034
|
cached2 = builtAt ? { commit, commitShort, version: version2, builtAt } : { commit, commitShort, version: version2 };
|
|
37028
37035
|
return cached2;
|
|
37029
37036
|
}
|
|
@@ -37795,40 +37802,38 @@ var require_dist3 = __commonJS({
|
|
|
37795
37802
|
async function getSubmoduleStatuses(repo, options) {
|
|
37796
37803
|
if (!repo.repoRoot) return { submodules: [], headOidByPath: /* @__PURE__ */ new Map() };
|
|
37797
37804
|
try {
|
|
37798
|
-
const
|
|
37799
|
-
|
|
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
|
+
);
|
|
37800
37832
|
return { submodules, headOidByPath };
|
|
37801
37833
|
} catch {
|
|
37802
37834
|
return { submodules: [], headOidByPath: /* @__PURE__ */ new Map() };
|
|
37803
37835
|
}
|
|
37804
37836
|
}
|
|
37805
|
-
async function deriveSubmoduleGitlinkStatuses(repo, options) {
|
|
37806
|
-
if (!repo.repoRoot) return { submodules: [], headOidByPath: /* @__PURE__ */ new Map() };
|
|
37807
|
-
const paths = await readSubmodulePaths(repo, options);
|
|
37808
|
-
const ignoreSet = new Set(options.submoduleIgnorePaths || []);
|
|
37809
|
-
const lastCheckedAt = Date.now();
|
|
37810
|
-
const headOidByPath = /* @__PURE__ */ new Map();
|
|
37811
|
-
const entries = await Promise.all(
|
|
37812
|
-
paths.filter((path54) => !ignoreSet.has(path54)).map(async (path54) => {
|
|
37813
|
-
const repoPath = repo.repoRoot + "/" + path54;
|
|
37814
|
-
const expected = await readGitlinkExpectedSha(repo, path54, options);
|
|
37815
|
-
const actual = await readSubmoduleHeadSha(repo, repoPath, options);
|
|
37816
|
-
if (actual) headOidByPath.set(path54, actual);
|
|
37817
|
-
const outOfSync = actual === null ? true : expected !== null && expected !== actual;
|
|
37818
|
-
return {
|
|
37819
|
-
path: path54,
|
|
37820
|
-
// Prefer the recorded gitlink SHA (matches the legacy column); fall back
|
|
37821
|
-
// to the checked-out SHA so the field is never empty when both are known.
|
|
37822
|
-
commit: expected ?? actual ?? "",
|
|
37823
|
-
repoPath,
|
|
37824
|
-
dirty: false,
|
|
37825
|
-
outOfSync,
|
|
37826
|
-
lastCheckedAt
|
|
37827
|
-
};
|
|
37828
|
-
})
|
|
37829
|
-
);
|
|
37830
|
-
return { submodules: entries, headOidByPath };
|
|
37831
|
-
}
|
|
37832
37837
|
async function readSubmodulePaths(repo, options) {
|
|
37833
37838
|
if (!repo.repoRoot) return [];
|
|
37834
37839
|
const gitmodulesPath = repo.repoRoot + "/.gitmodules";
|
|
@@ -37850,38 +37855,30 @@ var require_dist3 = __commonJS({
|
|
|
37850
37855
|
return [];
|
|
37851
37856
|
}
|
|
37852
37857
|
}
|
|
37853
|
-
async function
|
|
37858
|
+
async function readGitlinkExpectedShas(repo, submodulePaths, options) {
|
|
37859
|
+
const expectedByPath = /* @__PURE__ */ new Map();
|
|
37860
|
+
if (submodulePaths.length === 0 || !repo.repoRoot) return expectedByPath;
|
|
37854
37861
|
try {
|
|
37855
|
-
const result = await runGit(repo, ["ls-tree", "HEAD",
|
|
37856
|
-
const
|
|
37857
|
-
|
|
37858
|
-
|
|
37859
|
-
|
|
37860
|
-
} catch {
|
|
37861
|
-
return null;
|
|
37862
|
-
}
|
|
37863
|
-
}
|
|
37864
|
-
async function readSubmoduleHeadSha(repo, repoPath, options) {
|
|
37865
|
-
try {
|
|
37866
|
-
const result = await runGit(repo, ["rev-parse", "HEAD"], { ...options, cwd: repoPath });
|
|
37867
|
-
const sha = result.stdout.trim();
|
|
37868
|
-
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
|
+
}
|
|
37869
37867
|
} catch {
|
|
37870
|
-
return null;
|
|
37871
37868
|
}
|
|
37869
|
+
return expectedByPath;
|
|
37872
37870
|
}
|
|
37873
|
-
async function
|
|
37871
|
+
async function readSubmoduleWorktreeStatus(repo, repoPath, options) {
|
|
37874
37872
|
try {
|
|
37875
37873
|
const result = await runGit(repo, ["status", "--porcelain=v2", "--branch"], {
|
|
37876
37874
|
...options,
|
|
37877
|
-
cwd:
|
|
37875
|
+
cwd: repoPath
|
|
37878
37876
|
});
|
|
37879
37877
|
const parsed = parsePorcelainV2Status(result.stdout);
|
|
37880
37878
|
const dirty = parsed.staged + parsed.modified + parsed.untracked + parsed.deleted + parsed.renamed > 0 || parsed.conflictFiles.length > 0;
|
|
37881
|
-
|
|
37879
|
+
return { headOid: parsed.headOid, dirty };
|
|
37882
37880
|
} catch (error48) {
|
|
37883
|
-
|
|
37884
|
-
submodule.error = formatGitError(error48);
|
|
37881
|
+
return { headOid: null, dirty: true, error: formatGitError(error48) };
|
|
37885
37882
|
}
|
|
37886
37883
|
}
|
|
37887
37884
|
var import_node_path;
|
|
@@ -38766,8 +38763,7 @@ var require_dist3 = __commonJS({
|
|
|
38766
38763
|
}
|
|
38767
38764
|
});
|
|
38768
38765
|
function adhdevHome(env2 = process.env) {
|
|
38769
|
-
|
|
38770
|
-
return override ? override : path42.join(os6.homedir(), ".adhdev");
|
|
38766
|
+
return resolveConfigDir(env2);
|
|
38771
38767
|
}
|
|
38772
38768
|
function statuslineDir(env2 = process.env) {
|
|
38773
38769
|
return path42.join(adhdevHome(env2), "claude-statusline");
|
|
@@ -38795,10 +38791,11 @@ var require_dist3 = __commonJS({
|
|
|
38795
38791
|
"use strict";
|
|
38796
38792
|
os6 = __toESM2(require("os"));
|
|
38797
38793
|
path42 = __toESM2(require("path"));
|
|
38794
|
+
init_config_dir();
|
|
38798
38795
|
}
|
|
38799
38796
|
});
|
|
38800
38797
|
function renderWrapperScript(options) {
|
|
38801
|
-
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));
|
|
38802
38799
|
}
|
|
38803
38800
|
var WRAPPER_TEMPLATE;
|
|
38804
38801
|
var init_wrapper_source = __esm2({
|
|
@@ -38818,6 +38815,7 @@ import { mkdirSync, readFileSync, renameSync, writeFileSync } from 'node:fs';
|
|
|
38818
38815
|
import { dirname } from 'node:path';
|
|
38819
38816
|
|
|
38820
38817
|
const SNAPSHOT_PATH = __ADHDEV_SNAPSHOT_PATH__;
|
|
38818
|
+
const EXTRA_SNAPSHOT_PATHS = __ADHDEV_EXTRA_SNAPSHOT_PATHS__;
|
|
38821
38819
|
const ORIGINAL_COMMAND = __ADHDEV_ORIGINAL_COMMAND__;
|
|
38822
38820
|
const SNAPSHOT_VERSION = __ADHDEV_SNAPSHOT_VERSION__;
|
|
38823
38821
|
const MIN_WRITE_INTERVAL_MS = __ADHDEV_MIN_WRITE_INTERVAL_MS__;
|
|
@@ -38903,13 +38901,24 @@ function capture(payload) {
|
|
|
38903
38901
|
};
|
|
38904
38902
|
if (typeof payload.version === 'string') snapshot.cliVersion = payload.version;
|
|
38905
38903
|
|
|
38906
|
-
//
|
|
38907
|
-
//
|
|
38908
|
-
//
|
|
38909
|
-
|
|
38910
|
-
const
|
|
38911
|
-
|
|
38912
|
-
|
|
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
|
+
}
|
|
38913
38922
|
}
|
|
38914
38923
|
|
|
38915
38924
|
const stdinBuffer = await readStdin();
|
|
@@ -38960,6 +38969,26 @@ child.on('exit', () => process.exit(0));
|
|
|
38960
38969
|
stateDir: statuslineDir(env2)
|
|
38961
38970
|
};
|
|
38962
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
|
+
}
|
|
38963
38992
|
function isWrapperCommand(command, wrapperFile) {
|
|
38964
38993
|
if (typeof command !== "string" || command === "") {
|
|
38965
38994
|
return false;
|
|
@@ -39029,6 +39058,7 @@ child.on('exit', () => process.exit(0));
|
|
|
39029
39058
|
const originalCommand = typeof originalStatusLine?.command === "string" && originalStatusLine.command !== "" ? originalStatusLine.command : null;
|
|
39030
39059
|
const script = renderWrapperScript({
|
|
39031
39060
|
snapshotPath: paths.snapshotFile,
|
|
39061
|
+
additionalSnapshotPaths: discoverSiblingSnapshotPaths(env2),
|
|
39032
39062
|
originalCommand,
|
|
39033
39063
|
snapshotVersion: SNAPSHOT_VERSION,
|
|
39034
39064
|
minWriteIntervalMs: MIN_WRITE_INTERVAL_MS,
|
|
@@ -39132,6 +39162,7 @@ child.on('exit', () => process.exit(0));
|
|
|
39132
39162
|
};
|
|
39133
39163
|
}
|
|
39134
39164
|
var fs32;
|
|
39165
|
+
var os22;
|
|
39135
39166
|
var path52;
|
|
39136
39167
|
var WRAPPER_MARKER;
|
|
39137
39168
|
var StatuslineInstallError2;
|
|
@@ -39139,6 +39170,7 @@ child.on('exit', () => process.exit(0));
|
|
|
39139
39170
|
"src/quota/statusline/install.ts"() {
|
|
39140
39171
|
"use strict";
|
|
39141
39172
|
fs32 = __toESM2(require("fs"));
|
|
39173
|
+
os22 = __toESM2(require("os"));
|
|
39142
39174
|
path52 = __toESM2(require("path"));
|
|
39143
39175
|
init_snapshot();
|
|
39144
39176
|
init_paths();
|
|
@@ -39876,7 +39908,7 @@ child.on('exit', () => process.exit(0));
|
|
|
39876
39908
|
});
|
|
39877
39909
|
function kimiHome(env2) {
|
|
39878
39910
|
const override = env2.KIMI_CODE_HOME?.trim();
|
|
39879
|
-
return override ? override : path6.join(
|
|
39911
|
+
return override ? override : path6.join(os32.homedir(), ".kimi-code");
|
|
39880
39912
|
}
|
|
39881
39913
|
function credentialsPath(env2) {
|
|
39882
39914
|
return path6.join(kimiHome(env2), "credentials", "kimi-code.json");
|
|
@@ -40085,7 +40117,7 @@ child.on('exit', () => process.exit(0));
|
|
|
40085
40117
|
}
|
|
40086
40118
|
}
|
|
40087
40119
|
var fs5;
|
|
40088
|
-
var
|
|
40120
|
+
var os32;
|
|
40089
40121
|
var path6;
|
|
40090
40122
|
var DEFAULT_BASE_URL;
|
|
40091
40123
|
var REQUEST_TIMEOUT_MS2;
|
|
@@ -40094,7 +40126,7 @@ child.on('exit', () => process.exit(0));
|
|
|
40094
40126
|
"src/quota/fetchers/kimi.ts"() {
|
|
40095
40127
|
"use strict";
|
|
40096
40128
|
fs5 = __toESM2(require("fs"));
|
|
40097
|
-
|
|
40129
|
+
os32 = __toESM2(require("os"));
|
|
40098
40130
|
path6 = __toESM2(require("path"));
|
|
40099
40131
|
init_types();
|
|
40100
40132
|
init_deps();
|
|
@@ -40771,7 +40803,7 @@ child.on('exit', () => process.exit(0));
|
|
|
40771
40803
|
function unixExtraBinDirs() {
|
|
40772
40804
|
const dirs = [];
|
|
40773
40805
|
const fs56 = require("fs");
|
|
40774
|
-
const home =
|
|
40806
|
+
const home = os42.homedir();
|
|
40775
40807
|
const push = (dir) => {
|
|
40776
40808
|
if (!dir) return;
|
|
40777
40809
|
try {
|
|
@@ -40795,11 +40827,11 @@ child.on('exit', () => process.exit(0));
|
|
|
40795
40827
|
function findBinary(name) {
|
|
40796
40828
|
const trimmed = String(name || "").trim();
|
|
40797
40829
|
if (!trimmed) return trimmed;
|
|
40798
|
-
const expanded = trimmed.startsWith("~") ? path8.join(
|
|
40830
|
+
const expanded = trimmed.startsWith("~") ? path8.join(os42.homedir(), trimmed.slice(1)) : trimmed;
|
|
40799
40831
|
if (path8.isAbsolute(expanded) || expanded.includes("/") || expanded.includes("\\")) {
|
|
40800
40832
|
return path8.isAbsolute(expanded) ? expanded : path8.resolve(expanded);
|
|
40801
40833
|
}
|
|
40802
|
-
const isWin =
|
|
40834
|
+
const isWin = os42.platform() === "win32";
|
|
40803
40835
|
const paths = (process.env.PATH || "").split(path8.delimiter);
|
|
40804
40836
|
const extraDirs = [];
|
|
40805
40837
|
if (isWin) {
|
|
@@ -40867,7 +40899,7 @@ child.on('exit', () => process.exit(0));
|
|
|
40867
40899
|
}
|
|
40868
40900
|
function shSingleQuote(arg) {
|
|
40869
40901
|
if (/^[a-zA-Z0-9@%_+=:,./-]+$/.test(arg)) return arg;
|
|
40870
|
-
if (
|
|
40902
|
+
if (os42.platform() === "win32") {
|
|
40871
40903
|
return `"${arg.replace(/"/g, '""')}"`;
|
|
40872
40904
|
}
|
|
40873
40905
|
return `'${arg.replace(/'/g, `'\\''`)}'`;
|
|
@@ -40933,7 +40965,7 @@ child.on('exit', () => process.exit(0));
|
|
|
40933
40965
|
}
|
|
40934
40966
|
};
|
|
40935
40967
|
}
|
|
40936
|
-
var
|
|
40968
|
+
var os42;
|
|
40937
40969
|
var path8;
|
|
40938
40970
|
var import_child_process;
|
|
40939
40971
|
var TerminalTranscriptAccumulator;
|
|
@@ -40946,7 +40978,7 @@ child.on('exit', () => process.exit(0));
|
|
|
40946
40978
|
var init_provider_cli_shared = __esm2({
|
|
40947
40979
|
"src/cli-adapters/provider-cli-shared.ts"() {
|
|
40948
40980
|
"use strict";
|
|
40949
|
-
|
|
40981
|
+
os42 = __toESM2(require("os"));
|
|
40950
40982
|
path8 = __toESM2(require("path"));
|
|
40951
40983
|
import_child_process = require("child_process");
|
|
40952
40984
|
init_spawn_env();
|
|
@@ -41134,7 +41166,7 @@ child.on('exit', () => process.exit(0));
|
|
|
41134
41166
|
function expandHome(value) {
|
|
41135
41167
|
const trimmed = value.trim();
|
|
41136
41168
|
if (!trimmed.startsWith("~")) return trimmed;
|
|
41137
|
-
return path9.join(
|
|
41169
|
+
return path9.join(os52.homedir(), trimmed.slice(1));
|
|
41138
41170
|
}
|
|
41139
41171
|
function isExplicitCommandPath(command) {
|
|
41140
41172
|
const trimmed = command.trim();
|
|
@@ -41176,7 +41208,7 @@ child.on('exit', () => process.exit(0));
|
|
|
41176
41208
|
});
|
|
41177
41209
|
}
|
|
41178
41210
|
async function detectCLIs(providerLoader, options) {
|
|
41179
|
-
const platform10 =
|
|
41211
|
+
const platform10 = os52.platform();
|
|
41180
41212
|
const whichCmd = platform10 === "win32" ? "where" : "which";
|
|
41181
41213
|
const includeVersion = options?.includeVersion !== false;
|
|
41182
41214
|
const cliList = providerLoader ? providerLoader.getCliDetectionList({ includeDisabled: options?.includeDisabled }) : [];
|
|
@@ -41218,7 +41250,7 @@ child.on('exit', () => process.exit(0));
|
|
|
41218
41250
|
const cliList = providerLoader.getCliDetectionList();
|
|
41219
41251
|
const target = cliList.find((c) => c.id === resolvedId);
|
|
41220
41252
|
if (target) {
|
|
41221
|
-
const platform10 =
|
|
41253
|
+
const platform10 = os52.platform();
|
|
41222
41254
|
const whichCmd = platform10 === "win32" ? "where" : "which";
|
|
41223
41255
|
try {
|
|
41224
41256
|
const firstPath = await resolveDetectionPath(target.command, whichCmd);
|
|
@@ -41301,7 +41333,7 @@ child.on('exit', () => process.exit(0));
|
|
|
41301
41333
|
return out;
|
|
41302
41334
|
}
|
|
41303
41335
|
var import_child_process2;
|
|
41304
|
-
var
|
|
41336
|
+
var os52;
|
|
41305
41337
|
var path9;
|
|
41306
41338
|
var import_fs4;
|
|
41307
41339
|
var PROVIDER_VERSIONS_TTL_MS;
|
|
@@ -41313,7 +41345,7 @@ child.on('exit', () => process.exit(0));
|
|
|
41313
41345
|
"src/detection/cli-detector.ts"() {
|
|
41314
41346
|
"use strict";
|
|
41315
41347
|
import_child_process2 = require("child_process");
|
|
41316
|
-
|
|
41348
|
+
os52 = __toESM2(require("os"));
|
|
41317
41349
|
path9 = __toESM2(require("path"));
|
|
41318
41350
|
import_fs4 = require("fs");
|
|
41319
41351
|
init_provider_cli_shared();
|
|
@@ -41709,7 +41741,7 @@ ${error48.message || ""}`;
|
|
|
41709
41741
|
function expandPath(p) {
|
|
41710
41742
|
const t = (p || "").trim();
|
|
41711
41743
|
if (!t) return "";
|
|
41712
|
-
if (t.startsWith("~")) return path13.join(
|
|
41744
|
+
if (t.startsWith("~")) return path13.join(os7.homedir(), t.slice(1).replace(/^\//, ""));
|
|
41713
41745
|
return path13.resolve(t);
|
|
41714
41746
|
}
|
|
41715
41747
|
function validateWorkspacePath(absPath) {
|
|
@@ -41782,7 +41814,7 @@ ${error48.message || ""}`;
|
|
|
41782
41814
|
};
|
|
41783
41815
|
}
|
|
41784
41816
|
if (a.useHome === true) {
|
|
41785
|
-
return { ok: true, path:
|
|
41817
|
+
return { ok: true, path: os7.homedir(), source: "home" };
|
|
41786
41818
|
}
|
|
41787
41819
|
return {
|
|
41788
41820
|
ok: false,
|
|
@@ -41866,7 +41898,7 @@ ${error48.message || ""}`;
|
|
|
41866
41898
|
return { config: { ...config2, defaultWorkspaceId: id } };
|
|
41867
41899
|
}
|
|
41868
41900
|
var fs7;
|
|
41869
|
-
var
|
|
41901
|
+
var os7;
|
|
41870
41902
|
var path13;
|
|
41871
41903
|
var import_crypto22;
|
|
41872
41904
|
var MAX_WORKSPACES;
|
|
@@ -41874,7 +41906,7 @@ ${error48.message || ""}`;
|
|
|
41874
41906
|
"src/config/workspaces.ts"() {
|
|
41875
41907
|
"use strict";
|
|
41876
41908
|
fs7 = __toESM2(require("fs"));
|
|
41877
|
-
|
|
41909
|
+
os7 = __toESM2(require("os"));
|
|
41878
41910
|
path13 = __toESM2(require("path"));
|
|
41879
41911
|
import_crypto22 = require("crypto");
|
|
41880
41912
|
MAX_WORKSPACES = 50;
|
|
@@ -42162,6 +42194,7 @@ ${error48.message || ""}`;
|
|
|
42162
42194
|
buildSlotProposal: () => buildSlotProposal,
|
|
42163
42195
|
canonicalDaemonId: () => canonicalDaemonId,
|
|
42164
42196
|
daemonIdsEquivalent: () => daemonIdsEquivalent,
|
|
42197
|
+
deriveProviderPriorityFromSlots: () => deriveProviderPriorityFromSlots,
|
|
42165
42198
|
deriveSlotsFromLegacy: () => deriveSlotsFromLegacy,
|
|
42166
42199
|
expandDaemonIdForms: () => expandDaemonIdForms,
|
|
42167
42200
|
formatQuotaAccount: () => formatQuotaAccount,
|
|
@@ -42626,6 +42659,16 @@ ${error48.message || ""}`;
|
|
|
42626
42659
|
};
|
|
42627
42660
|
});
|
|
42628
42661
|
}
|
|
42662
|
+
function deriveProviderPriorityFromSlots(slots) {
|
|
42663
|
+
const seen = /* @__PURE__ */ new Set();
|
|
42664
|
+
const out = [];
|
|
42665
|
+
for (const slot of normalizeNodeCapabilitySlots(slots)) {
|
|
42666
|
+
if (seen.has(slot.provider)) continue;
|
|
42667
|
+
seen.add(slot.provider);
|
|
42668
|
+
out.push(slot.provider);
|
|
42669
|
+
}
|
|
42670
|
+
return out;
|
|
42671
|
+
}
|
|
42629
42672
|
function slotKey(slot) {
|
|
42630
42673
|
return [
|
|
42631
42674
|
slot.provider,
|
|
@@ -42997,6 +43040,7 @@ ${error48.message || ""}`;
|
|
|
42997
43040
|
getMagiKindPanel: () => getMagiKindPanel,
|
|
42998
43041
|
getMesh: () => getMesh,
|
|
42999
43042
|
getMeshByRepo: () => getMeshByRepo,
|
|
43043
|
+
getMeshQuotaRouting: () => getMeshQuotaRouting,
|
|
43000
43044
|
listMagiKindPanels: () => listMagiKindPanels,
|
|
43001
43045
|
listMagiKindPanelsReadOnly: () => listMagiKindPanelsReadOnly,
|
|
43002
43046
|
listMeshes: () => listMeshes,
|
|
@@ -43012,6 +43056,7 @@ ${error48.message || ""}`;
|
|
|
43012
43056
|
setDifficultyBrains: () => setDifficultyBrains,
|
|
43013
43057
|
setMagiKindPanel: () => setMagiKindPanel,
|
|
43014
43058
|
setMeshHostPin: () => setMeshHostPin,
|
|
43059
|
+
setMeshQuotaRouting: () => setMeshQuotaRouting,
|
|
43015
43060
|
tokenIdForManualPairing: () => tokenIdForManualPairing,
|
|
43016
43061
|
updateMesh: () => updateMesh,
|
|
43017
43062
|
updateNode: () => updateNode
|
|
@@ -43714,12 +43759,59 @@ ${error48.message || ""}`;
|
|
|
43714
43759
|
saveMeshConfig(stored);
|
|
43715
43760
|
return normalized;
|
|
43716
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
|
+
}
|
|
43717
43807
|
var import_fs5;
|
|
43718
43808
|
var import_path5;
|
|
43719
43809
|
var import_crypto3;
|
|
43720
43810
|
var mergeMeshPolicy;
|
|
43721
43811
|
var MAGI_KIND_PANEL_KINDS;
|
|
43722
43812
|
var MAX_MAGI_KIND_SLOTS;
|
|
43813
|
+
var QUOTA_ROUTING_PERCENT_FIELDS;
|
|
43814
|
+
var QUOTA_ROUTING_NONNEGATIVE_FIELDS;
|
|
43723
43815
|
var init_mesh_config = __esm2({
|
|
43724
43816
|
"src/config/mesh-config.ts"() {
|
|
43725
43817
|
"use strict";
|
|
@@ -43734,6 +43826,8 @@ ${error48.message || ""}`;
|
|
|
43734
43826
|
mergeMeshPolicy = mergeAndNormalizePolicy;
|
|
43735
43827
|
MAGI_KIND_PANEL_KINDS = ["claim_audit", "rca", "design", "freeform"];
|
|
43736
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"]);
|
|
43737
43831
|
}
|
|
43738
43832
|
});
|
|
43739
43833
|
function normalizeProviderPriority(policy) {
|
|
@@ -47386,11 +47480,11 @@ Next step: ${nextStep}`;
|
|
|
47386
47480
|
const pinnedProvider = typeof providerType === "string" && providerType.trim() ? providerType.trim() : void 0;
|
|
47387
47481
|
const providerTags = pinnedProvider ? [pinnedProvider] : readNodeProviderTypes(node?.policy);
|
|
47388
47482
|
const worktreeBranch = typeof node?.worktreeBranch === "string" && node.worktreeBranch.trim() ? node.worktreeBranch.trim() : null;
|
|
47389
|
-
const
|
|
47483
|
+
const os29 = readNodeOverride(node, "platform") ?? readNodeReporter(node, "platform") ?? process.platform;
|
|
47390
47484
|
const arch2 = readNodeOverride(node, "arch") ?? readNodeReporter(node, "arch") ?? process.arch;
|
|
47391
47485
|
return normalizeMeshCapabilityTags([
|
|
47392
47486
|
...Array.isArray(node?.capabilities) ? node.capabilities : [],
|
|
47393
|
-
`os=${
|
|
47487
|
+
`os=${os29}`,
|
|
47394
47488
|
`arch=${arch2}`,
|
|
47395
47489
|
...providerTags.map((p) => `provider=${p}`),
|
|
47396
47490
|
// Worktree nodes automatically expose a "worktree=<branch>" tag so that
|
|
@@ -48572,11 +48666,12 @@ Next step: ${nextStep}`;
|
|
|
48572
48666
|
ON mesh_missions(mesh_id, status, updated_at);
|
|
48573
48667
|
|
|
48574
48668
|
-- Load-balancing scheduler: per-mesh round-robin rotation cursor. When
|
|
48575
|
-
-- the schedulingStrategy
|
|
48576
|
-
-- the
|
|
48577
|
-
--
|
|
48578
|
-
-- node. Persisted (not a module
|
|
48579
|
-
-- and stays a single source of
|
|
48669
|
+
-- the schedulingStrategy spreads work ('fitness' with no task in scope),
|
|
48670
|
+
-- eligible nodes tied at the same (priority, load) are rotated by this
|
|
48671
|
+
-- cursor so the tie-break winner cycles across scheduling passes instead
|
|
48672
|
+
-- of always favouring the same array-order node. Persisted (not a module
|
|
48673
|
+
-- Map) so rotation survives daemon restarts and stays a single source of
|
|
48674
|
+
-- truth across scheduling entry points.
|
|
48580
48675
|
CREATE TABLE IF NOT EXISTS mesh_scheduler_cursor (
|
|
48581
48676
|
mesh_id TEXT PRIMARY KEY,
|
|
48582
48677
|
cursor INTEGER NOT NULL DEFAULT 0
|
|
@@ -52028,7 +52123,7 @@ Default branch: \`${mesh.defaultBranch}\`` : ""}`);
|
|
|
52028
52123
|
sections.push(TOOL_EXPOSURE_PREFLIGHT_SECTION);
|
|
52029
52124
|
sections.push(WORKFLOW_SECTION);
|
|
52030
52125
|
sections.push(ONBOARDING_SECTION);
|
|
52031
|
-
sections.push(buildRulesSection(coordinatorCliType));
|
|
52126
|
+
sections.push(buildRulesSection(coordinatorCliType, mergeAndNormalizePolicy(void 0, mesh.policy)));
|
|
52032
52127
|
return sections.join("\n\n");
|
|
52033
52128
|
}
|
|
52034
52129
|
function readUserPromptFile(cliType, suffix) {
|
|
@@ -52061,7 +52156,7 @@ Default branch: \`${mesh.defaultBranch}\`` : ""}`);
|
|
|
52061
52156
|
tools: TOOLS_SECTION,
|
|
52062
52157
|
workflow: WORKFLOW_SECTION,
|
|
52063
52158
|
onboarding: ONBOARDING_SECTION,
|
|
52064
|
-
rules: buildRulesSection(coordinatorCliType),
|
|
52159
|
+
rules: buildRulesSection(coordinatorCliType, mergeAndNormalizePolicy(void 0, mesh.policy)),
|
|
52065
52160
|
toolExposurePreflight: TOOL_EXPOSURE_PREFLIGHT_SECTION
|
|
52066
52161
|
};
|
|
52067
52162
|
return template.replace(/\{\{\s*([a-zA-Z_][a-zA-Z0-9_]*)\s*\}\}/g, (m, key2) => {
|
|
@@ -52394,12 +52489,14 @@ Default branch: \`${mesh.defaultBranch}\`` : ""}`);
|
|
|
52394
52489
|
return `## Policy
|
|
52395
52490
|
${rules.join("\n")}`;
|
|
52396
52491
|
}
|
|
52397
|
-
function buildRulesSection(coordinatorCliType) {
|
|
52492
|
+
function buildRulesSection(coordinatorCliType, policy) {
|
|
52398
52493
|
const coordinatorNote = coordinatorCliType ? `
|
|
52399
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.";
|
|
52400
52497
|
return `## Rules
|
|
52401
52498
|
|
|
52402
|
-
- **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}
|
|
52403
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.
|
|
52404
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\`.
|
|
52405
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.
|
|
@@ -53933,14 +54030,14 @@ When the user asks to **set up / configure / onboard** this repo for Repo Mesh (
|
|
|
53933
54030
|
}
|
|
53934
54031
|
function resolveHermesCoordinatorHome(meshId, workspace) {
|
|
53935
54032
|
const key2 = `${meshId || "mesh"}
|
|
53936
|
-
${(0, import_node_path3.resolve)(workspace ||
|
|
54033
|
+
${(0, import_node_path3.resolve)(workspace || os8.tmpdir())}`;
|
|
53937
54034
|
const hash2 = shortHash(key2);
|
|
53938
|
-
return (0, import_node_path3.join)(
|
|
54035
|
+
return (0, import_node_path3.join)(os8.tmpdir(), `adhdev-hermes-mesh-coordinator-${hash2}`);
|
|
53939
54036
|
}
|
|
53940
54037
|
function resolveMcpConfigPath(configPath, workspace) {
|
|
53941
54038
|
const trimmed = configPath.trim();
|
|
53942
|
-
if (trimmed === "~") return
|
|
53943
|
-
if (trimmed.startsWith("~/")) return (0, import_node_path3.join)(
|
|
54039
|
+
if (trimmed === "~") return os8.homedir();
|
|
54040
|
+
if (trimmed.startsWith("~/")) return (0, import_node_path3.join)(os8.homedir(), trimmed.slice(2));
|
|
53944
54041
|
if ((0, import_node_path3.isAbsolute)(trimmed)) return trimmed;
|
|
53945
54042
|
return (0, import_node_path3.join)(workspace, trimmed);
|
|
53946
54043
|
}
|
|
@@ -54018,7 +54115,7 @@ ${(0, import_node_path3.resolve)(workspace || os7.tmpdir())}`;
|
|
|
54018
54115
|
const template = injection.template && injection.template.includes("{prompt}") ? injection.template : "{prompt}";
|
|
54019
54116
|
const body = template.replace(/\{prompt\}/g, systemPrompt);
|
|
54020
54117
|
try {
|
|
54021
|
-
const dir = (0, import_node_fs3.mkdtempSync)((0, import_node_path3.join)(
|
|
54118
|
+
const dir = (0, import_node_fs3.mkdtempSync)((0, import_node_path3.join)(os8.tmpdir(), `adhdev-coord-${ctx.cliType}-`));
|
|
54022
54119
|
const filePath = (0, import_node_path3.join)(dir, "coordinator-agent.md");
|
|
54023
54120
|
(0, import_node_fs3.writeFileSync)(filePath, body, "utf-8");
|
|
54024
54121
|
ctx.cliArgs.push(injection.flag, filePath);
|
|
@@ -54178,7 +54275,7 @@ ${rendered}`, "utf-8");
|
|
|
54178
54275
|
});
|
|
54179
54276
|
}
|
|
54180
54277
|
var import_node_fs3;
|
|
54181
|
-
var
|
|
54278
|
+
var os8;
|
|
54182
54279
|
var import_session_host_core32;
|
|
54183
54280
|
var import_node_path3;
|
|
54184
54281
|
var DEFAULT_SERVER_NAME;
|
|
@@ -54189,7 +54286,7 @@ ${rendered}`, "utf-8");
|
|
|
54189
54286
|
"src/commands/mesh-coordinator.ts"() {
|
|
54190
54287
|
"use strict";
|
|
54191
54288
|
import_node_fs3 = require("fs");
|
|
54192
|
-
|
|
54289
|
+
os8 = __toESM2(require("os"));
|
|
54193
54290
|
import_session_host_core32 = require_dist();
|
|
54194
54291
|
import_node_path3 = require("path");
|
|
54195
54292
|
init_logger();
|
|
@@ -55243,13 +55340,16 @@ ${rendered}`, "utf-8");
|
|
|
55243
55340
|
function readProviderPriorityFromPolicy(policy) {
|
|
55244
55341
|
const record2 = policy && typeof policy === "object" && !Array.isArray(policy) ? policy : {};
|
|
55245
55342
|
const raw = record2.providerPriority;
|
|
55246
|
-
if (
|
|
55247
|
-
|
|
55248
|
-
|
|
55249
|
-
|
|
55250
|
-
|
|
55251
|
-
|
|
55252
|
-
|
|
55343
|
+
if (Array.isArray(raw)) {
|
|
55344
|
+
const seen = /* @__PURE__ */ new Set();
|
|
55345
|
+
const explicit = raw.map((type2) => typeof type2 === "string" ? type2.trim() : "").filter(Boolean).filter((type2) => {
|
|
55346
|
+
if (seen.has(type2)) return false;
|
|
55347
|
+
seen.add(type2);
|
|
55348
|
+
return true;
|
|
55349
|
+
});
|
|
55350
|
+
if (explicit.length) return explicit;
|
|
55351
|
+
}
|
|
55352
|
+
return deriveProviderPriorityFromSlots(record2.slots);
|
|
55253
55353
|
}
|
|
55254
55354
|
function normalizeProviderRoles(value) {
|
|
55255
55355
|
if (!Array.isArray(value)) return [];
|
|
@@ -60480,6 +60580,14 @@ The mesh has no work in flight. For each mission, decide its outcome: continue i
|
|
|
60480
60580
|
if (!Number.isFinite(used)) return void 0;
|
|
60481
60581
|
return Math.min(100, Math.max(0, 100 - used));
|
|
60482
60582
|
}
|
|
60583
|
+
function isSessionResetImminent(session, facts, quota, imminentMs, now) {
|
|
60584
|
+
const resetsAt = Number(session?.resetsAt);
|
|
60585
|
+
if (!Number.isFinite(resetsAt) || resetsAt <= 0) return false;
|
|
60586
|
+
const ageMs2 = quotaSnapshotAgeMs(facts, quota, now);
|
|
60587
|
+
if (!Number.isFinite(ageMs2)) return false;
|
|
60588
|
+
const reporterNowMs = Number(quota.updatedAt) + ageMs2;
|
|
60589
|
+
return resetsAt - reporterNowMs < imminentMs;
|
|
60590
|
+
}
|
|
60483
60591
|
function evaluateProviderQuotaGate(node, providerType, policy, now = Date.now()) {
|
|
60484
60592
|
const entry = quotaEntryFor(node, providerType);
|
|
60485
60593
|
if (!entry) return null;
|
|
@@ -60488,7 +60596,7 @@ The mesh has no work in flight. For each mission, decide its outcome: continue i
|
|
|
60488
60596
|
if (!isQuotaSnapshotFresh(facts, quota, policy, now)) return null;
|
|
60489
60597
|
const resolved = resolveQuotaRoutingPolicy(policy);
|
|
60490
60598
|
const session = remainingPercent(quota.session);
|
|
60491
|
-
if (session !== void 0 && session < resolved.sessionMinRemainingPercent) {
|
|
60599
|
+
if (session !== void 0 && session < resolved.sessionMinRemainingPercent && !isSessionResetImminent(quota.session, facts, quota, resolved.sessionResetImminentMs, now)) {
|
|
60492
60600
|
return {
|
|
60493
60601
|
reason: PROVIDER_QUOTA_SESSION_LOW_SKIP_REASON,
|
|
60494
60602
|
window: "session",
|
|
@@ -61228,7 +61336,7 @@ The mesh has no work in flight. For each mission, decide its outcome: continue i
|
|
|
61228
61336
|
}
|
|
61229
61337
|
const priorityOf = (n) => resolveNodeSchedulingPriority(n.node?.policy);
|
|
61230
61338
|
let rotation = 0;
|
|
61231
|
-
if (strategy === "
|
|
61339
|
+
if (strategy === "fitness") {
|
|
61232
61340
|
const cursor = opts?.bumpCursor ? MeshRuntimeStore.getInstance().bumpSchedulerCursor(meshId) : MeshRuntimeStore.getInstance().getSchedulerCursor(meshId);
|
|
61233
61341
|
rotation = (cursor % nodes.length + nodes.length) % nodes.length;
|
|
61234
61342
|
}
|
|
@@ -61236,7 +61344,7 @@ The mesh has no work in flight. For each mission, decide its outcome: continue i
|
|
|
61236
61344
|
return [...nodes].sort((a, b) => {
|
|
61237
61345
|
const prioDelta = priorityOf(b) - priorityOf(a);
|
|
61238
61346
|
if (prioDelta !== 0) return prioDelta;
|
|
61239
|
-
if (strategy === "
|
|
61347
|
+
if (strategy === "fitness") {
|
|
61240
61348
|
const loadDelta = nodeActiveLoad(meshId, a.nodeId) - nodeActiveLoad(meshId, b.nodeId);
|
|
61241
61349
|
if (loadDelta !== 0) return loadDelta;
|
|
61242
61350
|
}
|
|
@@ -61610,6 +61718,11 @@ The mesh has no work in flight. For each mission, decide its outcome: continue i
|
|
|
61610
61718
|
LOG2.info("MeshQueue", `Deferring queue claim for node ${nodeId} (${sessionId}): an auto fast-forward is mutating its workspace \u2014 task left pending, claim re-fires next tick`);
|
|
61611
61719
|
return false;
|
|
61612
61720
|
}
|
|
61721
|
+
const quotaClaimBlock = evaluateProviderQuotaGate(node, providerType, mesh?.policy?.quotaRouting ?? null);
|
|
61722
|
+
if (quotaClaimBlock) {
|
|
61723
|
+
LOG2.info("MeshQueue", `QUOTA GATE: deferring queue claim for node ${nodeId} (${sessionId}): provider '${providerType}' has ${quotaClaimBlock.remainingPercent.toFixed(1)}% ${quotaClaimBlock.window} quota remaining (< ${quotaClaimBlock.thresholdPercent}% threshold) \u2014 task left pending until the window resets`);
|
|
61724
|
+
return false;
|
|
61725
|
+
}
|
|
61613
61726
|
const inlineBootstrapNode = (() => {
|
|
61614
61727
|
try {
|
|
61615
61728
|
const inlineMesh = components.router?.getCachedInlineMesh?.(meshId);
|
|
@@ -62604,7 +62717,7 @@ The mesh has no work in flight. For each mission, decide its outcome: continue i
|
|
|
62604
62717
|
const aPrio = resolveNodeSchedulingPriority(a.node?.policy);
|
|
62605
62718
|
const bPrio = resolveNodeSchedulingPriority(b.node?.policy);
|
|
62606
62719
|
if (aPrio !== bPrio) return bPrio - aPrio;
|
|
62607
|
-
if (strategy === "
|
|
62720
|
+
if (strategy === "fitness") {
|
|
62608
62721
|
const loadDelta = nodeActiveLoad(meshId, a.nodeId) - nodeActiveLoad(meshId, b.nodeId);
|
|
62609
62722
|
if (loadDelta !== 0) return loadDelta;
|
|
62610
62723
|
}
|
|
@@ -63112,7 +63225,7 @@ The mesh has no work in flight. For each mission, decide its outcome: continue i
|
|
|
63112
63225
|
}
|
|
63113
63226
|
});
|
|
63114
63227
|
async function updateDarwinMemoryCache() {
|
|
63115
|
-
if (
|
|
63228
|
+
if (os9.platform() !== "darwin") return;
|
|
63116
63229
|
try {
|
|
63117
63230
|
const { stdout } = await execAsync2("vm_stat", {
|
|
63118
63231
|
encoding: "utf-8",
|
|
@@ -63136,26 +63249,26 @@ The mesh has no work in flight. For each mission, decide its outcome: continue i
|
|
|
63136
63249
|
const fileBacked = counts["file_backed"] ?? 0;
|
|
63137
63250
|
const availPages = free + inactive + speculative + purgeable + fileBacked;
|
|
63138
63251
|
const bytes = availPages * pageSize;
|
|
63139
|
-
cachedDarwinAvail = Number.isFinite(bytes) && bytes >= 0 ? Math.min(bytes,
|
|
63252
|
+
cachedDarwinAvail = Number.isFinite(bytes) && bytes >= 0 ? Math.min(bytes, os9.totalmem()) : null;
|
|
63140
63253
|
} catch {
|
|
63141
63254
|
}
|
|
63142
63255
|
}
|
|
63143
63256
|
function getHostMemorySnapshot() {
|
|
63144
|
-
if (
|
|
63257
|
+
if (os9.platform() === "darwin" && !darwinMemoryInterval) {
|
|
63145
63258
|
updateDarwinMemoryCache();
|
|
63146
63259
|
darwinMemoryInterval = setInterval(updateDarwinMemoryCache, 3e3);
|
|
63147
63260
|
darwinMemoryInterval.unref();
|
|
63148
63261
|
}
|
|
63149
|
-
const totalMem =
|
|
63150
|
-
const freeMem =
|
|
63151
|
-
const availableMem =
|
|
63262
|
+
const totalMem = os9.totalmem();
|
|
63263
|
+
const freeMem = os9.freemem();
|
|
63264
|
+
const availableMem = os9.platform() === "darwin" ? cachedDarwinAvail ?? freeMem : freeMem;
|
|
63152
63265
|
return {
|
|
63153
63266
|
totalMem,
|
|
63154
63267
|
freeMem,
|
|
63155
63268
|
availableMem
|
|
63156
63269
|
};
|
|
63157
63270
|
}
|
|
63158
|
-
var
|
|
63271
|
+
var os9;
|
|
63159
63272
|
var import_child_process4;
|
|
63160
63273
|
var import_util3;
|
|
63161
63274
|
var execAsync2;
|
|
@@ -63164,7 +63277,7 @@ The mesh has no work in flight. For each mission, decide its outcome: continue i
|
|
|
63164
63277
|
var init_host_memory = __esm2({
|
|
63165
63278
|
"src/system/host-memory.ts"() {
|
|
63166
63279
|
"use strict";
|
|
63167
|
-
|
|
63280
|
+
os9 = __toESM2(require("os"));
|
|
63168
63281
|
import_child_process4 = require("child_process");
|
|
63169
63282
|
import_util3 = require("util");
|
|
63170
63283
|
execAsync2 = (0, import_util3.promisify)(import_child_process4.exec);
|
|
@@ -64308,8 +64421,8 @@ ${cleanBody}`;
|
|
|
64308
64421
|
}
|
|
64309
64422
|
function buildMachineInfo2(profile = "full") {
|
|
64310
64423
|
const base = {
|
|
64311
|
-
hostname:
|
|
64312
|
-
platform:
|
|
64424
|
+
hostname: os10.hostname(),
|
|
64425
|
+
platform: os10.platform()
|
|
64313
64426
|
};
|
|
64314
64427
|
if (profile === "live") {
|
|
64315
64428
|
return base;
|
|
@@ -64318,23 +64431,23 @@ ${cleanBody}`;
|
|
|
64318
64431
|
const memSnap2 = getHostMemorySnapshot();
|
|
64319
64432
|
return {
|
|
64320
64433
|
...base,
|
|
64321
|
-
arch:
|
|
64322
|
-
cpus:
|
|
64434
|
+
arch: os10.arch(),
|
|
64435
|
+
cpus: os10.cpus().length,
|
|
64323
64436
|
totalMem: memSnap2.totalMem,
|
|
64324
|
-
release:
|
|
64437
|
+
release: os10.release()
|
|
64325
64438
|
};
|
|
64326
64439
|
}
|
|
64327
64440
|
const memSnap = getHostMemorySnapshot();
|
|
64328
64441
|
return {
|
|
64329
64442
|
...base,
|
|
64330
|
-
arch:
|
|
64331
|
-
cpus:
|
|
64443
|
+
arch: os10.arch(),
|
|
64444
|
+
cpus: os10.cpus().length,
|
|
64332
64445
|
totalMem: memSnap.totalMem,
|
|
64333
64446
|
freeMem: memSnap.freeMem,
|
|
64334
64447
|
availableMem: memSnap.availableMem,
|
|
64335
|
-
loadavg:
|
|
64336
|
-
uptime:
|
|
64337
|
-
release:
|
|
64448
|
+
loadavg: os10.loadavg(),
|
|
64449
|
+
uptime: os10.uptime(),
|
|
64450
|
+
release: os10.release()
|
|
64338
64451
|
};
|
|
64339
64452
|
}
|
|
64340
64453
|
function parseMessageTime(value) {
|
|
@@ -64571,13 +64684,13 @@ ${cleanBody}`;
|
|
|
64571
64684
|
}
|
|
64572
64685
|
};
|
|
64573
64686
|
}
|
|
64574
|
-
var
|
|
64687
|
+
var os10;
|
|
64575
64688
|
var READ_DEBUG_ENABLED;
|
|
64576
64689
|
var recentReadDebugSignatureBySession;
|
|
64577
64690
|
var init_snapshot2 = __esm2({
|
|
64578
64691
|
"src/status/snapshot.ts"() {
|
|
64579
64692
|
"use strict";
|
|
64580
|
-
|
|
64693
|
+
os10 = __toESM2(require("os"));
|
|
64581
64694
|
init_config();
|
|
64582
64695
|
init_state_store();
|
|
64583
64696
|
init_recent_activity();
|
|
@@ -70772,7 +70885,7 @@ ${cleanBody}`;
|
|
|
70772
70885
|
}
|
|
70773
70886
|
function expandTemplateRootForEnumeration(template, input) {
|
|
70774
70887
|
if (!template) return "";
|
|
70775
|
-
const posixHome = () => toPosixPath(
|
|
70888
|
+
const posixHome = () => toPosixPath(os13.homedir());
|
|
70776
70889
|
let out = template;
|
|
70777
70890
|
if (out === "~") out = posixHome();
|
|
70778
70891
|
else if (out.startsWith("~/")) out = `${posixHome()}/${out.slice(2)}`;
|
|
@@ -71385,13 +71498,13 @@ ${cleanBody}`;
|
|
|
71385
71498
|
if (!template) return null;
|
|
71386
71499
|
let out = template;
|
|
71387
71500
|
if (out.startsWith("~/") || out === "~") {
|
|
71388
|
-
out = path27.join(
|
|
71501
|
+
out = path27.join(os13.homedir(), out.slice(2));
|
|
71389
71502
|
}
|
|
71390
71503
|
out = out.replace(/\$\{([A-Z_][A-Z0-9_]*)(?::-(.*?))?\}/g, (_m, name, fallback) => {
|
|
71391
71504
|
const v = input.envOverrides?.[name] ?? process.env[name];
|
|
71392
71505
|
return v != null && v !== "" ? v : fallback ?? "";
|
|
71393
71506
|
});
|
|
71394
|
-
if (out.startsWith("~/")) out = path27.join(
|
|
71507
|
+
if (out.startsWith("~/")) out = path27.join(os13.homedir(), out.slice(2));
|
|
71395
71508
|
const now = /* @__PURE__ */ new Date();
|
|
71396
71509
|
const workspaceRaw = input.workspace ?? "";
|
|
71397
71510
|
let workspaceResolved = workspaceRaw;
|
|
@@ -71434,7 +71547,7 @@ ${cleanBody}`;
|
|
|
71434
71547
|
function scanProjectsRootForSessionFile(template, input, requestedSessionId) {
|
|
71435
71548
|
if (!requestedSessionId) return null;
|
|
71436
71549
|
let head = template;
|
|
71437
|
-
if (head.startsWith("~/") || head === "~") head = path27.join(
|
|
71550
|
+
if (head.startsWith("~/") || head === "~") head = path27.join(os13.homedir(), head.slice(2));
|
|
71438
71551
|
const base = staticTemplateBase(head);
|
|
71439
71552
|
if (!base) return null;
|
|
71440
71553
|
let baseStat = null;
|
|
@@ -71583,13 +71696,13 @@ ${cleanBody}`;
|
|
|
71583
71696
|
if (!template) return null;
|
|
71584
71697
|
let out = template;
|
|
71585
71698
|
if (out.startsWith("~/") || out === "~") {
|
|
71586
|
-
out = path27.join(
|
|
71699
|
+
out = path27.join(os13.homedir(), out.slice(2));
|
|
71587
71700
|
}
|
|
71588
71701
|
out = out.replace(/\$\{([A-Z_][A-Z0-9_]*)(?::-(.*?))?\}/g, (_m, name, fallback) => {
|
|
71589
71702
|
const v = input.envOverrides?.[name] ?? process.env[name];
|
|
71590
71703
|
return v != null && v !== "" ? v : fallback ?? "";
|
|
71591
71704
|
});
|
|
71592
|
-
if (out.startsWith("~/")) out = path27.join(
|
|
71705
|
+
if (out.startsWith("~/")) out = path27.join(os13.homedir(), out.slice(2));
|
|
71593
71706
|
const workspaceRaw = input.workspace ?? "";
|
|
71594
71707
|
let workspaceResolved = workspaceRaw;
|
|
71595
71708
|
if (workspaceRaw) {
|
|
@@ -72048,7 +72161,7 @@ ${cleanBody}`;
|
|
|
72048
72161
|
return t.negate ? !result : result;
|
|
72049
72162
|
}
|
|
72050
72163
|
var fs222;
|
|
72051
|
-
var
|
|
72164
|
+
var os13;
|
|
72052
72165
|
var path27;
|
|
72053
72166
|
var UUID_RE;
|
|
72054
72167
|
var DEFAULT_TOOL_CALL_TYPES;
|
|
@@ -72057,7 +72170,7 @@ ${cleanBody}`;
|
|
|
72057
72170
|
"src/providers/spec/native-history-executor.ts"() {
|
|
72058
72171
|
"use strict";
|
|
72059
72172
|
fs222 = __toESM2(require("fs"));
|
|
72060
|
-
|
|
72173
|
+
os13 = __toESM2(require("os"));
|
|
72061
72174
|
path27 = __toESM2(require("path"));
|
|
72062
72175
|
init_logger();
|
|
72063
72176
|
init_load_better_sqlite3();
|
|
@@ -72550,7 +72663,7 @@ ${cleanBody}`;
|
|
|
72550
72663
|
cachedPty = void 0;
|
|
72551
72664
|
requireNodePty = loader2 ?? (() => require("node-pty"));
|
|
72552
72665
|
}
|
|
72553
|
-
var
|
|
72666
|
+
var os14;
|
|
72554
72667
|
var cachedPty;
|
|
72555
72668
|
var requireNodePty;
|
|
72556
72669
|
var NodePtyRuntimeTransport;
|
|
@@ -72558,7 +72671,7 @@ ${cleanBody}`;
|
|
|
72558
72671
|
var init_pty_transport = __esm2({
|
|
72559
72672
|
"src/cli-adapters/pty-transport.ts"() {
|
|
72560
72673
|
"use strict";
|
|
72561
|
-
|
|
72674
|
+
os14 = __toESM2(require("os"));
|
|
72562
72675
|
init_spawn_env();
|
|
72563
72676
|
init_resolve_executable();
|
|
72564
72677
|
requireNodePty = () => require("node-pty");
|
|
@@ -72599,9 +72712,9 @@ ${cleanBody}`;
|
|
|
72599
72712
|
try {
|
|
72600
72713
|
const fs56 = require("fs");
|
|
72601
72714
|
const stat2 = fs56.statSync(cwd);
|
|
72602
|
-
if (!stat2.isDirectory()) cwd =
|
|
72715
|
+
if (!stat2.isDirectory()) cwd = os14.homedir();
|
|
72603
72716
|
} catch {
|
|
72604
|
-
cwd =
|
|
72717
|
+
cwd = os14.homedir();
|
|
72605
72718
|
}
|
|
72606
72719
|
}
|
|
72607
72720
|
const handle = pty.spawn(resolveWin32Executable(command), args, {
|
|
@@ -75276,7 +75389,7 @@ ${cont}` : cont;
|
|
|
75276
75389
|
function resolveCliSpawnPlanFromParts(options) {
|
|
75277
75390
|
const { command, baseArgs, shell, baseEnv, workingDir, extraArgs, extraEnv, geometry, diagnosticCliType, diagnosticProviderVersion } = options;
|
|
75278
75391
|
const binaryPath = findBinary(command);
|
|
75279
|
-
const isWin =
|
|
75392
|
+
const isWin = os15.platform() === "win32";
|
|
75280
75393
|
const allArgs = [...baseArgs ?? [], ...extraArgs ?? []].map(
|
|
75281
75394
|
(arg) => typeof arg === "string" ? arg.replace(/\{\{workingDir\}\}/g, workingDir) : arg
|
|
75282
75395
|
);
|
|
@@ -75364,13 +75477,13 @@ ${cont}` : cont;
|
|
|
75364
75477
|
}
|
|
75365
75478
|
return "";
|
|
75366
75479
|
}
|
|
75367
|
-
var
|
|
75480
|
+
var os15;
|
|
75368
75481
|
var path28;
|
|
75369
75482
|
var import_session_host_core7;
|
|
75370
75483
|
var init_provider_cli_runtime = __esm2({
|
|
75371
75484
|
"src/cli-adapters/provider-cli-runtime.ts"() {
|
|
75372
75485
|
"use strict";
|
|
75373
|
-
|
|
75486
|
+
os15 = __toESM2(require("os"));
|
|
75374
75487
|
path28 = __toESM2(require("path"));
|
|
75375
75488
|
init_logger();
|
|
75376
75489
|
import_session_host_core7 = require_dist();
|
|
@@ -75445,7 +75558,7 @@ ${cont}` : cont;
|
|
|
75445
75558
|
missingBackgroundSourceWarned.add(cliType);
|
|
75446
75559
|
LOG2.warn("CLI", `[${cliType}] background-task tracking declared but nativeHistory.source missing after provider resolve; background detection inactive`);
|
|
75447
75560
|
}
|
|
75448
|
-
var
|
|
75561
|
+
var os16;
|
|
75449
75562
|
var import_crypto11;
|
|
75450
75563
|
var import_session_host_core8;
|
|
75451
75564
|
var missingBackgroundSourceWarned;
|
|
@@ -75454,7 +75567,7 @@ ${cont}` : cont;
|
|
|
75454
75567
|
var init_provider_cli_adapter = __esm2({
|
|
75455
75568
|
"src/cli-adapters/provider-cli-adapter.ts"() {
|
|
75456
75569
|
"use strict";
|
|
75457
|
-
|
|
75570
|
+
os16 = __toESM2(require("os"));
|
|
75458
75571
|
import_crypto11 = require("crypto");
|
|
75459
75572
|
init_interactive_prompt();
|
|
75460
75573
|
init_kimi_pending_question();
|
|
@@ -75486,7 +75599,7 @@ ${cont}` : cont;
|
|
|
75486
75599
|
this.transportFactory = transportFactory;
|
|
75487
75600
|
this.cliType = provider.type;
|
|
75488
75601
|
this.cliName = provider.name;
|
|
75489
|
-
this.workingDir = workingDir.startsWith("~") ? workingDir.replace(/^~/,
|
|
75602
|
+
this.workingDir = workingDir.startsWith("~") ? workingDir.replace(/^~/, os16.homedir()) : workingDir;
|
|
75490
75603
|
const resolvedConfig = resolveCliAdapterConfig(provider);
|
|
75491
75604
|
this.timeouts = resolvedConfig.timeouts;
|
|
75492
75605
|
this.approvalKeys = resolvedConfig.approvalKeys;
|
|
@@ -80121,7 +80234,7 @@ ${lastSnapshot}`;
|
|
|
80121
80234
|
init_git_worktree();
|
|
80122
80235
|
init_config();
|
|
80123
80236
|
init_config_dir();
|
|
80124
|
-
var
|
|
80237
|
+
var os62 = __toESM2(require("os"));
|
|
80125
80238
|
var path12 = __toESM2(require("path"));
|
|
80126
80239
|
var import_session_host_core22 = require_dist();
|
|
80127
80240
|
init_config_dir();
|
|
@@ -80165,7 +80278,7 @@ ${lastSnapshot}`;
|
|
|
80165
80278
|
var cached22 = null;
|
|
80166
80279
|
function resolveInstanceContext(options = {}) {
|
|
80167
80280
|
const env2 = options.env ?? process.env;
|
|
80168
|
-
const homeDir = options.homeDir ??
|
|
80281
|
+
const homeDir = options.homeDir ?? os62.homedir();
|
|
80169
80282
|
const envDir = typeof env2.ADHDEV_CONFIG_DIR === "string" ? env2.ADHDEV_CONFIG_DIR.trim() : "";
|
|
80170
80283
|
const explicitDir = typeof options.configDir === "string" ? options.configDir.trim() : "";
|
|
80171
80284
|
if (explicitDir && envDir && (0, import_session_host_core22.canonicalizeInstancePath)(explicitDir) !== (0, import_session_host_core22.canonicalizeInstancePath)(envDir)) {
|
|
@@ -80186,7 +80299,7 @@ ${lastSnapshot}`;
|
|
|
80186
80299
|
}
|
|
80187
80300
|
function getProcessInstanceContext(options = {}) {
|
|
80188
80301
|
const envDir = typeof process.env.ADHDEV_CONFIG_DIR === "string" ? process.env.ADHDEV_CONFIG_DIR.trim() : "";
|
|
80189
|
-
const key2 = `${envDir}|${
|
|
80302
|
+
const key2 = `${envDir}|${os62.homedir()}|${options.standalone ? "standalone" : "daemon"}`;
|
|
80190
80303
|
if (!cached22 || cached22.key !== key2) {
|
|
80191
80304
|
cached22 = { key: key2, context: resolveInstanceContext({ standalone: options.standalone }) };
|
|
80192
80305
|
}
|
|
@@ -81490,17 +81603,17 @@ ${lastSnapshot}`;
|
|
|
81490
81603
|
return null;
|
|
81491
81604
|
}
|
|
81492
81605
|
async function detectIDEs(providerLoader) {
|
|
81493
|
-
const
|
|
81606
|
+
const os29 = (0, import_os3.platform)();
|
|
81494
81607
|
const results = [];
|
|
81495
81608
|
for (const def of getMergedDefinitions()) {
|
|
81496
81609
|
const cliPath = findCliCommand(providerLoader?.getIdeCliCommand(def.id, def.cli) || def.cli);
|
|
81497
|
-
const appPath = checkPathExists(providerLoader?.getIdePathCandidates(def.id, def.paths[
|
|
81610
|
+
const appPath = checkPathExists(providerLoader?.getIdePathCandidates(def.id, def.paths[os29] || []) || []);
|
|
81498
81611
|
let resolvedCli = cliPath;
|
|
81499
|
-
if (!resolvedCli && appPath &&
|
|
81612
|
+
if (!resolvedCli && appPath && os29 === "darwin") {
|
|
81500
81613
|
const bundledCli = `${appPath}/Contents/Resources/app/bin/${def.cli}`;
|
|
81501
81614
|
if ((0, import_fs17.existsSync)(bundledCli)) resolvedCli = bundledCli;
|
|
81502
81615
|
}
|
|
81503
|
-
if (!resolvedCli && appPath &&
|
|
81616
|
+
if (!resolvedCli && appPath && os29 === "win32") {
|
|
81504
81617
|
const { dirname: dirname23 } = await import("path");
|
|
81505
81618
|
const appDir = dirname23(appPath);
|
|
81506
81619
|
const candidates = [
|
|
@@ -81517,7 +81630,7 @@ ${lastSnapshot}`;
|
|
|
81517
81630
|
}
|
|
81518
81631
|
}
|
|
81519
81632
|
}
|
|
81520
|
-
const installed =
|
|
81633
|
+
const installed = os29 === "darwin" ? !!(resolvedCli || appPath) : !!resolvedCli;
|
|
81521
81634
|
const version2 = null;
|
|
81522
81635
|
results.push({
|
|
81523
81636
|
id: def.id,
|
|
@@ -88220,7 +88333,7 @@ ${effect.notification.body || ""}`.trim();
|
|
|
88220
88333
|
}
|
|
88221
88334
|
var fs15 = __toESM2(require("fs"));
|
|
88222
88335
|
var path232 = __toESM2(require("path"));
|
|
88223
|
-
var
|
|
88336
|
+
var os11 = __toESM2(require("os"));
|
|
88224
88337
|
var KEY_TO_VK = {
|
|
88225
88338
|
Backspace: 8,
|
|
88226
88339
|
Tab: 9,
|
|
@@ -88474,7 +88587,7 @@ ${effect.notification.body || ""}`.trim();
|
|
|
88474
88587
|
function resolveSafePath(requestedPath) {
|
|
88475
88588
|
const rawPath = typeof requestedPath === "string" ? requestedPath.trim() : "";
|
|
88476
88589
|
const inputPath = rawPath || ".";
|
|
88477
|
-
const home =
|
|
88590
|
+
const home = os11.homedir();
|
|
88478
88591
|
if (inputPath.startsWith("~")) {
|
|
88479
88592
|
return path232.resolve(path232.join(home, inputPath.slice(1)));
|
|
88480
88593
|
}
|
|
@@ -90879,7 +90992,7 @@ ${effect.notification.body || ""}`.trim();
|
|
|
90879
90992
|
var import_child_process8 = require("child_process");
|
|
90880
90993
|
var import_child_process9 = require("child_process");
|
|
90881
90994
|
var fs20 = __toESM2(require("fs"));
|
|
90882
|
-
var
|
|
90995
|
+
var os12 = __toESM2(require("os"));
|
|
90883
90996
|
var path26 = __toESM2(require("path"));
|
|
90884
90997
|
var import_child_process7 = require("child_process");
|
|
90885
90998
|
var fs19 = __toESM2(require("fs"));
|
|
@@ -91746,7 +91859,7 @@ exec "${portableNode}" "${cliEntry}" "$@"
|
|
|
91746
91859
|
const packageRoot = findCurrentPackageRoot(options.currentCliPath || process.argv[1], options.packageName);
|
|
91747
91860
|
const npmInvocation = resolveSiblingNpmInvocation(options.nodeExecutable || process.execPath, options.platform);
|
|
91748
91861
|
const platform10 = options.platform || process.platform;
|
|
91749
|
-
const homeDir = options.homeDir ||
|
|
91862
|
+
const homeDir = options.homeDir || os12.homedir();
|
|
91750
91863
|
const instanceDir = options.instanceDir || resolveInstanceDir();
|
|
91751
91864
|
let installPrefix = packageRoot ? resolveInstallPrefixFromPackageRoot(packageRoot, options.packageName) : null;
|
|
91752
91865
|
if (platform10 === "win32" && isPortableNode22Prefix(installPrefix, homeDir, instanceDir)) {
|
|
@@ -92158,12 +92271,12 @@ ${marker}`,
|
|
|
92158
92271
|
}
|
|
92159
92272
|
const instanceDir = resolveInstanceDir();
|
|
92160
92273
|
const windowsInstallerLayout = resolveWindowsInstallerLayout({
|
|
92161
|
-
homeDir:
|
|
92274
|
+
homeDir: os12.homedir(),
|
|
92162
92275
|
installPrefix: installCommand.surface.installPrefix,
|
|
92163
92276
|
instanceDir
|
|
92164
92277
|
});
|
|
92165
92278
|
if (windowsInstallerLayout) {
|
|
92166
|
-
const portableNode = findPortableNode22(
|
|
92279
|
+
const portableNode = findPortableNode22(os12.homedir(), process.execPath, instanceDir);
|
|
92167
92280
|
if (!portableNode) {
|
|
92168
92281
|
throw new Error("installer-managed Windows update requires the portable Node.js 22 runtime");
|
|
92169
92282
|
}
|
|
@@ -93300,7 +93413,7 @@ ${marker}`,
|
|
|
93300
93413
|
})
|
|
93301
93414
|
);
|
|
93302
93415
|
init_dist();
|
|
93303
|
-
var
|
|
93416
|
+
var os21 = __toESM2(require("os"));
|
|
93304
93417
|
var path35 = __toESM2(require("path"));
|
|
93305
93418
|
var crypto6 = __toESM2(require("crypto"));
|
|
93306
93419
|
var import_fs18 = require("fs");
|
|
@@ -93394,7 +93507,7 @@ ${marker}`,
|
|
|
93394
93507
|
}
|
|
93395
93508
|
}
|
|
93396
93509
|
init_summary_metadata();
|
|
93397
|
-
var
|
|
93510
|
+
var os20 = __toESM2(require("os"));
|
|
93398
93511
|
var crypto5 = __toESM2(require("crypto"));
|
|
93399
93512
|
var fs31 = __toESM2(require("fs"));
|
|
93400
93513
|
init_contracts2();
|
|
@@ -93534,7 +93647,7 @@ ${marker}`,
|
|
|
93534
93647
|
var path31 = __toESM2(require("path"));
|
|
93535
93648
|
init_provider_cli_adapter();
|
|
93536
93649
|
var fs25 = __toESM2(require("fs"));
|
|
93537
|
-
var
|
|
93650
|
+
var os18 = __toESM2(require("os"));
|
|
93538
93651
|
var path30 = __toESM2(require("path"));
|
|
93539
93652
|
init_terminal_screen();
|
|
93540
93653
|
var import_session_host_core9 = require_dist();
|
|
@@ -93713,12 +93826,12 @@ ${marker}`,
|
|
|
93713
93826
|
init_fsm_types();
|
|
93714
93827
|
init_fsm_loader();
|
|
93715
93828
|
var fs24 = __toESM2(require("fs"));
|
|
93716
|
-
var
|
|
93829
|
+
var os17 = __toESM2(require("os"));
|
|
93717
93830
|
var path29 = __toESM2(require("path"));
|
|
93718
93831
|
init_logger();
|
|
93719
93832
|
function expandHome2(p) {
|
|
93720
|
-
if (p === "~") return
|
|
93721
|
-
if (p.startsWith("~/")) return path29.join(
|
|
93833
|
+
if (p === "~") return os17.homedir();
|
|
93834
|
+
if (p.startsWith("~/")) return path29.join(os17.homedir(), p.slice(2));
|
|
93722
93835
|
return p;
|
|
93723
93836
|
}
|
|
93724
93837
|
function realWorkspacePath(workingDir) {
|
|
@@ -94554,7 +94667,7 @@ ${marker}`,
|
|
|
94554
94667
|
}
|
|
94555
94668
|
fireDelegate(d) {
|
|
94556
94669
|
const ev = this.currentEval;
|
|
94557
|
-
const task = d.task_template.replace(/\{node\}/g,
|
|
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));
|
|
94558
94671
|
this.emit({ kind: "delegate", id: d.id, task });
|
|
94559
94672
|
}
|
|
94560
94673
|
// ────────────────────────────────────────────────────────────────────
|
|
@@ -94948,7 +95061,7 @@ ${marker}`,
|
|
|
94948
95061
|
const ctl = (this.spec.control_bar ?? []).find((c) => c.action.type === "attach_image");
|
|
94949
95062
|
if (!ctl || ctl.action.type !== "attach_image") return;
|
|
94950
95063
|
const ext = guessExt(mime);
|
|
94951
|
-
const tmp = path30.join(
|
|
95064
|
+
const tmp = path30.join(os18.tmpdir(), `adhdev-attach-${Date.now()}${ext}`);
|
|
94952
95065
|
try {
|
|
94953
95066
|
fs25.writeFileSync(tmp, Buffer.from(blob, "base64"));
|
|
94954
95067
|
} catch {
|
|
@@ -96247,7 +96360,7 @@ ${marker}`,
|
|
|
96247
96360
|
init_transcript_claim_registry();
|
|
96248
96361
|
init_chat_message_normalization();
|
|
96249
96362
|
init_working_dir();
|
|
96250
|
-
var
|
|
96363
|
+
var os19 = __toESM2(require("os"));
|
|
96251
96364
|
var path322 = __toESM2(require("path"));
|
|
96252
96365
|
var crypto4 = __toESM2(require("crypto"));
|
|
96253
96366
|
var fs28 = __toESM2(require("fs"));
|
|
@@ -96318,7 +96431,7 @@ ${marker}`,
|
|
|
96318
96431
|
const promptParts = [];
|
|
96319
96432
|
const imageRefs = [];
|
|
96320
96433
|
const resourceRefs = [];
|
|
96321
|
-
const materializeDir = options.materializeDir || path322.join(
|
|
96434
|
+
const materializeDir = options.materializeDir || path322.join(os19.tmpdir(), "adhdev-input-media");
|
|
96322
96435
|
input.parts.forEach((part, index) => {
|
|
96323
96436
|
if (part.type === "text" && part.text.trim()) {
|
|
96324
96437
|
promptParts.push(part.text.trim());
|
|
@@ -98528,7 +98641,7 @@ ${buttons.join("\n")}`;
|
|
|
98528
98641
|
* Replaces the previously duplicated probeOpenCode/Codex/Goose functions.
|
|
98529
98642
|
*/
|
|
98530
98643
|
probeSessionIdFromConfig(probe) {
|
|
98531
|
-
const resolvedDbPath = probe.dbPath.replace(/^~/,
|
|
98644
|
+
const resolvedDbPath = probe.dbPath.replace(/^~/, os20.homedir());
|
|
98532
98645
|
const now = Date.now();
|
|
98533
98646
|
if (this.sqliteProbeCache.missingUntil > now) return null;
|
|
98534
98647
|
if (!fs31.existsSync(resolvedDbPath)) {
|
|
@@ -102091,7 +102204,7 @@ ${rawInput}` : rawInput;
|
|
|
102091
102204
|
}
|
|
102092
102205
|
function expandExecutable(command) {
|
|
102093
102206
|
const trimmed = command.trim();
|
|
102094
|
-
return trimmed.startsWith("~") ? path35.join(
|
|
102207
|
+
return trimmed.startsWith("~") ? path35.join(os21.homedir(), trimmed.slice(1)) : trimmed;
|
|
102095
102208
|
}
|
|
102096
102209
|
function commandExists(command) {
|
|
102097
102210
|
const trimmed = command.trim();
|
|
@@ -102241,9 +102354,9 @@ ${rawInput}` : rawInput;
|
|
|
102241
102354
|
return false;
|
|
102242
102355
|
}
|
|
102243
102356
|
function ensureEmptyDelegatedMcpConfig(workspace) {
|
|
102244
|
-
const baseDir = path35.join(
|
|
102357
|
+
const baseDir = path35.join(os21.tmpdir(), "adhdev-delegated-agent-empty-mcp");
|
|
102245
102358
|
(0, import_fs18.mkdirSync)(baseDir, { recursive: true });
|
|
102246
|
-
const workspaceHash = shortHash(path35.resolve(workspace ||
|
|
102359
|
+
const workspaceHash = shortHash(path35.resolve(workspace || os21.tmpdir()));
|
|
102247
102360
|
const filePath = path35.join(baseDir, `${workspaceHash}.json`);
|
|
102248
102361
|
(0, import_fs18.writeFileSync)(filePath, JSON.stringify({ mcpServers: {} }, null, 2), "utf-8");
|
|
102249
102362
|
return filePath;
|
|
@@ -102638,7 +102751,7 @@ ${rawInput}` : rawInput;
|
|
|
102638
102751
|
async startSession(cliType, workingDir, cliArgs, initialModel, options) {
|
|
102639
102752
|
const trimmed = (workingDir || "").trim();
|
|
102640
102753
|
if (!trimmed) throw new Error("working directory required");
|
|
102641
|
-
const resolvedDir = trimmed.startsWith("~") ? trimmed.replace(/^~/,
|
|
102754
|
+
const resolvedDir = trimmed.startsWith("~") ? trimmed.replace(/^~/, os21.homedir()) : path35.resolve(trimmed);
|
|
102642
102755
|
const normalizedType = this.providerLoader.resolveAlias(cliType);
|
|
102643
102756
|
const rawProvider = this.providerLoader.getByAlias(cliType);
|
|
102644
102757
|
const provider = rawProvider ? this.providerLoader.resolve(normalizedType) || rawProvider : void 0;
|
|
@@ -103665,7 +103778,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
103665
103778
|
};
|
|
103666
103779
|
var import_child_process12 = require("child_process");
|
|
103667
103780
|
var net3 = __toESM2(require("net"));
|
|
103668
|
-
var
|
|
103781
|
+
var os25 = __toESM2(require("os"));
|
|
103669
103782
|
var path46 = __toESM2(require("path"));
|
|
103670
103783
|
var fs41 = __toESM2(require("fs"));
|
|
103671
103784
|
var path45 = __toESM2(require("path"));
|
|
@@ -104135,7 +104248,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
104135
104248
|
init_config();
|
|
104136
104249
|
init_native_history_executor();
|
|
104137
104250
|
var fs36 = __toESM2(require("fs"));
|
|
104138
|
-
var
|
|
104251
|
+
var os24 = __toESM2(require("os"));
|
|
104139
104252
|
var path40 = __toESM2(require("path"));
|
|
104140
104253
|
var fs322 = __toESM2(require("fs"));
|
|
104141
104254
|
var path36 = __toESM2(require("path"));
|
|
@@ -104671,7 +104784,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
104671
104784
|
}
|
|
104672
104785
|
var fs34 = __toESM2(require("fs"));
|
|
104673
104786
|
var path38 = __toESM2(require("path"));
|
|
104674
|
-
var
|
|
104787
|
+
var os222 = __toESM2(require("os"));
|
|
104675
104788
|
init_load_better_sqlite3();
|
|
104676
104789
|
init_logger();
|
|
104677
104790
|
function extractTimestampValue3(value) {
|
|
@@ -104695,7 +104808,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
104695
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);
|
|
104696
104809
|
}
|
|
104697
104810
|
function antigravityRoot() {
|
|
104698
|
-
return path38.join(
|
|
104811
|
+
return path38.join(os222.homedir(), ".gemini", "antigravity-cli");
|
|
104699
104812
|
}
|
|
104700
104813
|
function historyJsonlPath() {
|
|
104701
104814
|
return path38.join(antigravityRoot(), "history.jsonl");
|
|
@@ -105310,11 +105423,11 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
105310
105423
|
}
|
|
105311
105424
|
var fs35 = __toESM2(require("fs"));
|
|
105312
105425
|
var path39 = __toESM2(require("path"));
|
|
105313
|
-
var
|
|
105426
|
+
var os23 = __toESM2(require("os"));
|
|
105314
105427
|
init_load_better_sqlite3();
|
|
105315
105428
|
init_usage_normalize();
|
|
105316
|
-
var HERMES_STATE_DB = path39.join(
|
|
105317
|
-
var HERMES_LEGACY_SESSIONS_DIR = path39.join(
|
|
105429
|
+
var HERMES_STATE_DB = path39.join(os23.homedir(), ".hermes", "state.db");
|
|
105430
|
+
var HERMES_LEGACY_SESSIONS_DIR = path39.join(os23.homedir(), ".hermes", "sessions");
|
|
105318
105431
|
function statMtimeMs4(p) {
|
|
105319
105432
|
try {
|
|
105320
105433
|
return Math.floor(fs35.statSync(p).mtimeMs);
|
|
@@ -105602,7 +105715,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
105602
105715
|
}
|
|
105603
105716
|
}
|
|
105604
105717
|
function resolveClaudePath(workspace, sessionId) {
|
|
105605
|
-
const dir = path40.join(
|
|
105718
|
+
const dir = path40.join(os24.homedir(), ".claude", "projects", cwdAsDashes(workspace));
|
|
105606
105719
|
if (!fs36.existsSync(dir)) return null;
|
|
105607
105720
|
if (sessionId) {
|
|
105608
105721
|
const candidate = path40.join(dir, `${sessionId}.jsonl`);
|
|
@@ -105724,7 +105837,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
105724
105837
|
}
|
|
105725
105838
|
var AGY_SPAWN_CLAIM_GRACE_MS = 2e3;
|
|
105726
105839
|
function resolveAntigravityPath(workspace, sessionId, sessionStartedAtMs, instanceId) {
|
|
105727
|
-
const agyRoot = path40.join(
|
|
105840
|
+
const agyRoot = path40.join(os24.homedir(), ".gemini", "antigravity-cli");
|
|
105728
105841
|
const owner = antigravityOwnerToken(workspace, sessionStartedAtMs, instanceId);
|
|
105729
105842
|
if (sessionId && isUuidLikeSessionId2(sessionId)) {
|
|
105730
105843
|
const dbPath = path40.join(agyRoot, "conversations", `${sessionId}.db`);
|
|
@@ -105808,9 +105921,9 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
105808
105921
|
function resolveHermesPath(workspace, sessionId) {
|
|
105809
105922
|
void workspace;
|
|
105810
105923
|
void sessionId;
|
|
105811
|
-
const dbPath = path40.join(
|
|
105924
|
+
const dbPath = path40.join(os24.homedir(), ".hermes", "state.db");
|
|
105812
105925
|
if (fs36.existsSync(dbPath)) return dbPath;
|
|
105813
|
-
const dir = path40.join(
|
|
105926
|
+
const dir = path40.join(os24.homedir(), ".hermes", "sessions");
|
|
105814
105927
|
if (!fs36.existsSync(dir)) return null;
|
|
105815
105928
|
return newestRecentFile2(dir, /^session_.*\.json$/);
|
|
105816
105929
|
}
|
|
@@ -105836,7 +105949,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
105836
105949
|
return cwd.replace(/\//g, "-");
|
|
105837
105950
|
}
|
|
105838
105951
|
function codexSessionsRoot() {
|
|
105839
|
-
return path40.join(
|
|
105952
|
+
return path40.join(os24.homedir(), ".codex", "sessions");
|
|
105840
105953
|
}
|
|
105841
105954
|
function isUuidLikeSessionId2(sessionId) {
|
|
105842
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);
|
|
@@ -108855,7 +108968,7 @@ ${formatManifestValidationIssues2(validation2.issues)}`);
|
|
|
108855
108968
|
});
|
|
108856
108969
|
}
|
|
108857
108970
|
async function killIdeProcess(ideId) {
|
|
108858
|
-
const plat =
|
|
108971
|
+
const plat = os25.platform();
|
|
108859
108972
|
const appName = getMacAppIdentifiers()[ideId];
|
|
108860
108973
|
const winProcesses = getWinProcessNames()[ideId];
|
|
108861
108974
|
try {
|
|
@@ -108916,7 +109029,7 @@ ${formatManifestValidationIssues2(validation2.issues)}`);
|
|
|
108916
109029
|
}
|
|
108917
109030
|
}
|
|
108918
109031
|
async function isIdeRunning(ideId) {
|
|
108919
|
-
const plat =
|
|
109032
|
+
const plat = os25.platform();
|
|
108920
109033
|
try {
|
|
108921
109034
|
if (plat === "darwin") {
|
|
108922
109035
|
const appName = getMacAppIdentifiers()[ideId];
|
|
@@ -108971,7 +109084,7 @@ ${formatManifestValidationIssues2(validation2.issues)}`);
|
|
|
108971
109084
|
}
|
|
108972
109085
|
}
|
|
108973
109086
|
async function detectCurrentWorkspace(ideId) {
|
|
108974
|
-
const plat =
|
|
109087
|
+
const plat = os25.platform();
|
|
108975
109088
|
if (plat === "darwin") {
|
|
108976
109089
|
try {
|
|
108977
109090
|
const appName = getMacAppIdentifiers()[ideId];
|
|
@@ -108991,7 +109104,7 @@ ${formatManifestValidationIssues2(validation2.issues)}`);
|
|
|
108991
109104
|
const appName = appNameMap[ideId];
|
|
108992
109105
|
if (appName) {
|
|
108993
109106
|
const storagePath = path46.join(
|
|
108994
|
-
process.env.APPDATA || path46.join(
|
|
109107
|
+
process.env.APPDATA || path46.join(os25.homedir(), "AppData", "Roaming"),
|
|
108995
109108
|
appName,
|
|
108996
109109
|
"storage.json"
|
|
108997
109110
|
);
|
|
@@ -109013,7 +109126,7 @@ ${formatManifestValidationIssues2(validation2.issues)}`);
|
|
|
109013
109126
|
return void 0;
|
|
109014
109127
|
}
|
|
109015
109128
|
async function launchWithCdp(options = {}) {
|
|
109016
|
-
const platform10 =
|
|
109129
|
+
const platform10 = os25.platform();
|
|
109017
109130
|
let targetIde;
|
|
109018
109131
|
const ides = await detectIDEs(getProviderLoader());
|
|
109019
109132
|
if (options.ideId) {
|
|
@@ -109304,6 +109417,7 @@ ${formatManifestValidationIssues2(validation2.issues)}`);
|
|
|
109304
109417
|
}
|
|
109305
109418
|
};
|
|
109306
109419
|
init_dist();
|
|
109420
|
+
init_repo_mesh_types();
|
|
109307
109421
|
init_mesh_host_ownership();
|
|
109308
109422
|
init_worktree_bootstrap_config();
|
|
109309
109423
|
init_mesh_events();
|
|
@@ -109324,6 +109438,10 @@ ${formatManifestValidationIssues2(validation2.issues)}`);
|
|
|
109324
109438
|
if (await isAncestor2(worktreeOssSha, sourceSha)) return "advance";
|
|
109325
109439
|
return "skip_diverged";
|
|
109326
109440
|
}
|
|
109441
|
+
function syncProviderPriorityFromSlots(policy, slots = policy.slots) {
|
|
109442
|
+
const derived = deriveProviderPriorityFromSlots(slots);
|
|
109443
|
+
if (derived.length) policy.providerPriority = derived;
|
|
109444
|
+
}
|
|
109327
109445
|
async function syncClonedWorktreeSubmodules(worktreePath, sourceWorkspace, rg) {
|
|
109328
109446
|
const submodulePaths = getRegisteredSubmodulePaths(worktreePath);
|
|
109329
109447
|
if (submodulePaths.size === 0) return;
|
|
@@ -109571,11 +109689,11 @@ ${formatManifestValidationIssues2(validation2.issues)}`);
|
|
|
109571
109689
|
MESH_JSON_CONFIG_LOCATIONS: MESH_JSON_CONFIG_LOCATIONS2
|
|
109572
109690
|
} = await Promise.resolve().then(() => (init_mesh_json_config(), mesh_json_config_exports));
|
|
109573
109691
|
const { mkdirSync: mkdirSync30, writeFileSync: writeFileSync30 } = await import("fs");
|
|
109574
|
-
const { dirname: dirname23, join:
|
|
109692
|
+
const { dirname: dirname23, join: join63 } = await import("path");
|
|
109575
109693
|
const scaffold = buildMeshJsonConfigScaffold2(mesh);
|
|
109576
109694
|
const scaffoldJson = serializeMeshJsonConfigScaffold2(scaffold);
|
|
109577
109695
|
const relativePath = MESH_JSON_CONFIG_LOCATIONS2[0];
|
|
109578
|
-
const absolutePath =
|
|
109696
|
+
const absolutePath = join63(workspace, relativePath);
|
|
109579
109697
|
const validation = normalizeRepoMeshDeclarativeConfig2(scaffold);
|
|
109580
109698
|
if (!validation.valid) {
|
|
109581
109699
|
return { success: false, meshId, error: `invalid mesh.json scaffold: ${validation.errors.join("; ")}` };
|
|
@@ -109682,14 +109800,14 @@ ${formatManifestValidationIssues2(validation2.issues)}`);
|
|
|
109682
109800
|
MESH_JSON_CONFIG_LOCATIONS: MESH_JSON_CONFIG_LOCATIONS2
|
|
109683
109801
|
} = await Promise.resolve().then(() => (init_mesh_json_config(), mesh_json_config_exports));
|
|
109684
109802
|
const { existsSync: existsSync62, readFileSync: readFileSync53, mkdirSync: mkdirSync30, writeFileSync: writeFileSync30 } = await import("fs");
|
|
109685
|
-
const { dirname: dirname23, join:
|
|
109803
|
+
const { dirname: dirname23, join: join63 } = await import("path");
|
|
109686
109804
|
const yaml6 = await Promise.resolve().then(() => (init_js_yaml(), js_yaml_exports));
|
|
109687
109805
|
const relativePath = MESH_JSON_CONFIG_LOCATIONS2[0];
|
|
109688
109806
|
let baseDoc = { version: 1 };
|
|
109689
|
-
let existingPath =
|
|
109807
|
+
let existingPath = join63(workspace, relativePath);
|
|
109690
109808
|
let existedAsYaml = false;
|
|
109691
109809
|
for (const relative8 of MESH_JSON_CONFIG_LOCATIONS2) {
|
|
109692
|
-
const candidate =
|
|
109810
|
+
const candidate = join63(workspace, relative8);
|
|
109693
109811
|
if (!existsSync62(candidate)) continue;
|
|
109694
109812
|
try {
|
|
109695
109813
|
const text = readFileSync53(candidate, "utf-8");
|
|
@@ -109875,6 +109993,59 @@ ${formatManifestValidationIssues2(validation2.issues)}`);
|
|
|
109875
109993
|
return { success: false, error: e.message };
|
|
109876
109994
|
}
|
|
109877
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
|
+
},
|
|
109878
110049
|
add_mesh_node: async (ctx, args) => {
|
|
109879
110050
|
const meshId = typeof args?.meshId === "string" ? args.meshId.trim() : "";
|
|
109880
110051
|
const workspace = typeof args?.workspace === "string" ? args.workspace.trim() : "";
|
|
@@ -109887,12 +110058,15 @@ ${formatManifestValidationIssues2(validation2.issues)}`);
|
|
|
109887
110058
|
const providerPriority = Array.isArray(args?.providerPriority) ? args.providerPriority.map((type2) => typeof type2 === "string" ? type2.trim() : "").filter(Boolean) : [];
|
|
109888
110059
|
const readOnly = args?.readOnly === true;
|
|
109889
110060
|
const providerRoles = normalizeProviderRoles(args?.providerRoles);
|
|
110061
|
+
const slots = normalizeNodeCapabilitySlots(args?.slots);
|
|
109890
110062
|
const policy = {
|
|
109891
110063
|
...readOnly ? { readOnly: true } : {},
|
|
109892
110064
|
...providerPriority.length ? { providerPriority } : {},
|
|
109893
|
-
...providerRoles.length ? { providerRoles } : {}
|
|
110065
|
+
...providerRoles.length ? { providerRoles } : {},
|
|
110066
|
+
...slots.length ? { slots } : {}
|
|
109894
110067
|
};
|
|
109895
110068
|
if (providerRoles.length) migrateProviderRolesToSlots2(policy);
|
|
110069
|
+
if (!providerPriority.length) syncProviderPriorityFromSlots(policy);
|
|
109896
110070
|
const role = normalizeMeshDaemonRole(args?.role);
|
|
109897
110071
|
const daemonId = typeof args?.daemonId === "string" && args.daemonId.trim() ? args.daemonId.trim() : void 0;
|
|
109898
110072
|
const machineId = typeof args?.machineId === "string" && args.machineId.trim() ? args.machineId.trim() : void 0;
|
|
@@ -109927,7 +110101,7 @@ ${formatManifestValidationIssues2(validation2.issues)}`);
|
|
|
109927
110101
|
const ownerFailure = await ctx.requireMeshHostMutationOwner(meshId, args?.inlineMesh, "node update");
|
|
109928
110102
|
if (ownerFailure) return ownerFailure;
|
|
109929
110103
|
try {
|
|
109930
|
-
const { updateNode: updateNode2, normalizeCapabilityTags: normalizeCapabilityTags2, migrateProviderRolesToSlots: migrateProviderRolesToSlots2 } = await Promise.resolve().then(() => (init_mesh_config(), mesh_config_exports));
|
|
110104
|
+
const { updateNode: updateNode2, normalizeCapabilityTags: normalizeCapabilityTags2, migrateProviderRolesToSlots: migrateProviderRolesToSlots2, getMesh: getMesh2 } = await Promise.resolve().then(() => (init_mesh_config(), mesh_config_exports));
|
|
109931
110105
|
const policy = args?.policy && typeof args.policy === "object" && !Array.isArray(args.policy) ? { ...args.policy } : {};
|
|
109932
110106
|
if (Array.isArray(args?.providerPriority)) {
|
|
109933
110107
|
const providerPriority = args.providerPriority.map((type2) => typeof type2 === "string" ? type2.trim() : "").filter(Boolean);
|
|
@@ -109944,6 +110118,10 @@ ${formatManifestValidationIssues2(validation2.issues)}`);
|
|
|
109944
110118
|
else delete policy.providerRoles;
|
|
109945
110119
|
}
|
|
109946
110120
|
migrateProviderRolesToSlots2(policy);
|
|
110121
|
+
if (!Array.isArray(args?.providerPriority) && !Object.prototype.hasOwnProperty.call(policy, "providerPriority")) {
|
|
110122
|
+
const finalSlots = Object.prototype.hasOwnProperty.call(policy, "slots") ? policy.slots : getMesh2(meshId)?.nodes.find((n) => n.id === nodeId)?.policy?.slots;
|
|
110123
|
+
syncProviderPriorityFromSlots(policy, finalSlots);
|
|
110124
|
+
}
|
|
109947
110125
|
const patch = { policy };
|
|
109948
110126
|
if (typeof args?.systemPrompt === "string") {
|
|
109949
110127
|
const trimmed = args.systemPrompt.trim();
|
|
@@ -109968,6 +110146,9 @@ ${formatManifestValidationIssues2(validation2.issues)}`);
|
|
|
109968
110146
|
...inlineNode.policy && typeof inlineNode.policy === "object" && !Array.isArray(inlineNode.policy) ? inlineNode.policy : {},
|
|
109969
110147
|
...patch.policy
|
|
109970
110148
|
};
|
|
110149
|
+
if (!Array.isArray(args?.providerPriority) && !Object.prototype.hasOwnProperty.call(patch.policy, "providerPriority")) {
|
|
110150
|
+
syncProviderPriorityFromSlots(inlineNode.policy);
|
|
110151
|
+
}
|
|
109971
110152
|
if (Object.prototype.hasOwnProperty.call(patch, "systemPrompt")) {
|
|
109972
110153
|
const sp = patch.systemPrompt;
|
|
109973
110154
|
if (typeof sp === "string" && sp.trim()) inlineNode.systemPrompt = sp;
|
|
@@ -120022,7 +120203,7 @@ ${e?.stderr || ""}`;
|
|
|
120022
120203
|
init_chat_message_normalization();
|
|
120023
120204
|
var fs49 = __toESM2(require("fs"));
|
|
120024
120205
|
var path48 = __toESM2(require("path"));
|
|
120025
|
-
var
|
|
120206
|
+
var os26 = __toESM2(require("os"));
|
|
120026
120207
|
var import_os6 = require("os");
|
|
120027
120208
|
init_config();
|
|
120028
120209
|
var import_child_process13 = require("child_process");
|
|
@@ -120147,7 +120328,7 @@ ${e?.stderr || ""}`;
|
|
|
120147
120328
|
function checkPathExists2(paths) {
|
|
120148
120329
|
for (const p of paths) {
|
|
120149
120330
|
if (p.includes("*")) {
|
|
120150
|
-
const home =
|
|
120331
|
+
const home = os26.homedir();
|
|
120151
120332
|
const resolved = p.replace(/\*/g, home.split(path48.sep).pop() || "");
|
|
120152
120333
|
if (fs49.existsSync(resolved)) return resolved;
|
|
120153
120334
|
} else {
|
|
@@ -122544,7 +122725,7 @@ async (params) => {
|
|
|
122544
122725
|
}
|
|
122545
122726
|
var fs52 = __toESM2(require("fs"));
|
|
122546
122727
|
var path51 = __toESM2(require("path"));
|
|
122547
|
-
var
|
|
122728
|
+
var os27 = __toESM2(require("os"));
|
|
122548
122729
|
var import_session_host_core11 = require_dist();
|
|
122549
122730
|
function getAutoImplPid(ctx) {
|
|
122550
122731
|
const pid = ctx.autoImplProcess?.pid;
|
|
@@ -122746,7 +122927,7 @@ async (params) => {
|
|
|
122746
122927
|
});
|
|
122747
122928
|
const referenceScripts = loadAutoImplReferenceScripts(ctx, resolvedReference);
|
|
122748
122929
|
const prompt = buildAutoImplPrompt(ctx, type2, provider, providerDir, functions, domContext, referenceScripts, comment, resolvedReference, verification);
|
|
122749
|
-
const tmpDir = path51.join(
|
|
122930
|
+
const tmpDir = path51.join(os27.tmpdir(), "adhdev-autoimpl");
|
|
122750
122931
|
if (!fs52.existsSync(tmpDir)) fs52.mkdirSync(tmpDir, { recursive: true });
|
|
122751
122932
|
const promptFile = path51.join(tmpDir, `prompt-${type2}-${Date.now()}.md`);
|
|
122752
122933
|
fs52.writeFileSync(promptFile, prompt, "utf-8");
|
|
@@ -122901,7 +123082,7 @@ async (params) => {
|
|
|
122901
123082
|
const interactiveFlags = ["--yolo", "--interactive", "-i"];
|
|
122902
123083
|
const baseArgs = [...spawn7.args || []].filter((a) => !interactiveFlags.includes(a));
|
|
122903
123084
|
let shellCmd;
|
|
122904
|
-
const isWin =
|
|
123085
|
+
const isWin = os27.platform() === "win32";
|
|
122905
123086
|
const escapeArg = (a) => isWin ? `"${a.replace(/"/g, '""')}"` : `'${a.replace(/'/g, "'\\''")}'`;
|
|
122906
123087
|
const promptMode = autoImpl?.promptMode ?? "stdin";
|
|
122907
123088
|
const extraArgs = autoImpl?.extraArgs ?? [];
|
|
@@ -122940,7 +123121,7 @@ async (params) => {
|
|
|
122940
123121
|
try {
|
|
122941
123122
|
const pty = require("node-pty");
|
|
122942
123123
|
ctx.log(`Auto-implement spawn (PTY): ${shellCmd}`);
|
|
122943
|
-
const isWin2 =
|
|
123124
|
+
const isWin2 = os27.platform() === "win32";
|
|
122944
123125
|
child = pty.spawn(isWin2 ? "cmd.exe" : process.env.SHELL || "/bin/zsh", [isWin2 ? "/c" : "-c", shellCmd], {
|
|
122945
123126
|
name: "xterm-256color",
|
|
122946
123127
|
cols: import_session_host_core11.DEFAULT_SESSION_HOST_COLS,
|
|
@@ -125596,7 +125777,7 @@ data: ${JSON.stringify(msg.data)}
|
|
|
125596
125777
|
}
|
|
125597
125778
|
var import_child_process14 = require("child_process");
|
|
125598
125779
|
var fs54 = __toESM2(require("fs"));
|
|
125599
|
-
var
|
|
125780
|
+
var os28 = __toESM2(require("os"));
|
|
125600
125781
|
var path53 = __toESM2(require("path"));
|
|
125601
125782
|
var import_session_host_core15 = require_dist();
|
|
125602
125783
|
init_logger();
|
|
@@ -125668,7 +125849,7 @@ data: ${JSON.stringify(msg.data)}
|
|
|
125668
125849
|
}
|
|
125669
125850
|
let portableNode = null;
|
|
125670
125851
|
try {
|
|
125671
|
-
portableNode = findPortableNode22(
|
|
125852
|
+
portableNode = findPortableNode22(os28.homedir(), process.execPath, resolveInstanceDir());
|
|
125672
125853
|
} catch (error48) {
|
|
125673
125854
|
LOG2.warn(
|
|
125674
125855
|
"SessionHost",
|