@adhdev/daemon-standalone 1.0.45-rc.7 → 1.0.45-rc.9
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 +617 -257
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
- package/public/assets/index-TrEtD2r5.css +1 -0
- package/public/assets/index-digx-PVW.js +116 -0
- package/public/index.html +2 -2
- package/public/assets/index-DU3ukph2.js +0 -121
- package/public/assets/index-zRNkTYHz.css +0 -1
package/dist/index.js
CHANGED
|
@@ -37027,10 +37027,10 @@ var require_dist3 = __commonJS({
|
|
|
37027
37027
|
}
|
|
37028
37028
|
function getDaemonBuildInfo() {
|
|
37029
37029
|
if (cached2) return cached2;
|
|
37030
|
-
const commit = readInjected(true ? "
|
|
37031
|
-
const commitShort = readInjected(true ? "
|
|
37032
|
-
const version2 = readInjected(true ? "1.0.45-rc.
|
|
37033
|
-
const builtAt = readInjected(true ? "2026-08-
|
|
37030
|
+
const commit = readInjected(true ? "6a45bfebc577345264d61b02a71a657bbc313033" : void 0) ?? "unknown";
|
|
37031
|
+
const commitShort = readInjected(true ? "6a45bfeb" : void 0) ?? (commit !== "unknown" ? commit.slice(0, 7) : "unknown");
|
|
37032
|
+
const version2 = readInjected(true ? "1.0.45-rc.9" : void 0) ?? readInjected(typeof process !== "undefined" ? process.env?.ADHDEV_PKG_VERSION : void 0) ?? "unknown";
|
|
37033
|
+
const builtAt = readInjected(true ? "2026-08-13T03:05:02.343Z" : void 0);
|
|
37034
37034
|
cached2 = builtAt ? { commit, commitShort, version: version2, builtAt } : { commit, commitShort, version: version2 };
|
|
37035
37035
|
return cached2;
|
|
37036
37036
|
}
|
|
@@ -37802,40 +37802,38 @@ var require_dist3 = __commonJS({
|
|
|
37802
37802
|
async function getSubmoduleStatuses(repo, options) {
|
|
37803
37803
|
if (!repo.repoRoot) return { submodules: [], headOidByPath: /* @__PURE__ */ new Map() };
|
|
37804
37804
|
try {
|
|
37805
|
-
const
|
|
37806
|
-
|
|
37805
|
+
const paths = await readSubmodulePaths(repo, options);
|
|
37806
|
+
const ignoreSet = new Set(options.submoduleIgnorePaths || []);
|
|
37807
|
+
const visiblePaths = paths.filter((path54) => !ignoreSet.has(path54));
|
|
37808
|
+
const expectedByPath = await readGitlinkExpectedShas(repo, visiblePaths, options);
|
|
37809
|
+
const lastCheckedAt = Date.now();
|
|
37810
|
+
const headOidByPath = /* @__PURE__ */ new Map();
|
|
37811
|
+
const submodules = await Promise.all(
|
|
37812
|
+
visiblePaths.map(async (path54) => {
|
|
37813
|
+
const repoPath = repo.repoRoot + "/" + path54;
|
|
37814
|
+
const expected = expectedByPath.get(path54) ?? null;
|
|
37815
|
+
const worktree = await readSubmoduleWorktreeStatus(repo, repoPath, options);
|
|
37816
|
+
const actual = worktree.headOid;
|
|
37817
|
+
if (actual) headOidByPath.set(path54, actual);
|
|
37818
|
+
const outOfSync = actual === null ? true : expected !== null && expected !== actual;
|
|
37819
|
+
return {
|
|
37820
|
+
path: path54,
|
|
37821
|
+
// Prefer the recorded gitlink SHA (matches the legacy column); fall back
|
|
37822
|
+
// to the checked-out SHA so the field is never empty when both are known.
|
|
37823
|
+
commit: expected ?? actual ?? "",
|
|
37824
|
+
repoPath,
|
|
37825
|
+
dirty: worktree.dirty,
|
|
37826
|
+
outOfSync,
|
|
37827
|
+
lastCheckedAt,
|
|
37828
|
+
...worktree.error ? { error: worktree.error } : {}
|
|
37829
|
+
};
|
|
37830
|
+
})
|
|
37831
|
+
);
|
|
37807
37832
|
return { submodules, headOidByPath };
|
|
37808
37833
|
} catch {
|
|
37809
37834
|
return { submodules: [], headOidByPath: /* @__PURE__ */ new Map() };
|
|
37810
37835
|
}
|
|
37811
37836
|
}
|
|
37812
|
-
async function deriveSubmoduleGitlinkStatuses(repo, options) {
|
|
37813
|
-
if (!repo.repoRoot) return { submodules: [], headOidByPath: /* @__PURE__ */ new Map() };
|
|
37814
|
-
const paths = await readSubmodulePaths(repo, options);
|
|
37815
|
-
const ignoreSet = new Set(options.submoduleIgnorePaths || []);
|
|
37816
|
-
const lastCheckedAt = Date.now();
|
|
37817
|
-
const headOidByPath = /* @__PURE__ */ new Map();
|
|
37818
|
-
const entries = await Promise.all(
|
|
37819
|
-
paths.filter((path54) => !ignoreSet.has(path54)).map(async (path54) => {
|
|
37820
|
-
const repoPath = repo.repoRoot + "/" + path54;
|
|
37821
|
-
const expected = await readGitlinkExpectedSha(repo, path54, options);
|
|
37822
|
-
const actual = await readSubmoduleHeadSha(repo, repoPath, options);
|
|
37823
|
-
if (actual) headOidByPath.set(path54, actual);
|
|
37824
|
-
const outOfSync = actual === null ? true : expected !== null && expected !== actual;
|
|
37825
|
-
return {
|
|
37826
|
-
path: path54,
|
|
37827
|
-
// Prefer the recorded gitlink SHA (matches the legacy column); fall back
|
|
37828
|
-
// to the checked-out SHA so the field is never empty when both are known.
|
|
37829
|
-
commit: expected ?? actual ?? "",
|
|
37830
|
-
repoPath,
|
|
37831
|
-
dirty: false,
|
|
37832
|
-
outOfSync,
|
|
37833
|
-
lastCheckedAt
|
|
37834
|
-
};
|
|
37835
|
-
})
|
|
37836
|
-
);
|
|
37837
|
-
return { submodules: entries, headOidByPath };
|
|
37838
|
-
}
|
|
37839
37837
|
async function readSubmodulePaths(repo, options) {
|
|
37840
37838
|
if (!repo.repoRoot) return [];
|
|
37841
37839
|
const gitmodulesPath = repo.repoRoot + "/.gitmodules";
|
|
@@ -37857,38 +37855,30 @@ var require_dist3 = __commonJS({
|
|
|
37857
37855
|
return [];
|
|
37858
37856
|
}
|
|
37859
37857
|
}
|
|
37860
|
-
async function
|
|
37861
|
-
|
|
37862
|
-
|
|
37863
|
-
const line = result.stdout.split("\n").find((l) => l.trim().length > 0);
|
|
37864
|
-
if (!line) return null;
|
|
37865
|
-
const match = line.match(/^\s*\d+\s+commit\s+([0-9a-f]{40})\b/);
|
|
37866
|
-
return match ? match[1] : null;
|
|
37867
|
-
} catch {
|
|
37868
|
-
return null;
|
|
37869
|
-
}
|
|
37870
|
-
}
|
|
37871
|
-
async function readSubmoduleHeadSha(repo, repoPath, options) {
|
|
37858
|
+
async function readGitlinkExpectedShas(repo, submodulePaths, options) {
|
|
37859
|
+
const expectedByPath = /* @__PURE__ */ new Map();
|
|
37860
|
+
if (submodulePaths.length === 0 || !repo.repoRoot) return expectedByPath;
|
|
37872
37861
|
try {
|
|
37873
|
-
const result = await runGit(repo, ["
|
|
37874
|
-
const
|
|
37875
|
-
|
|
37862
|
+
const result = await runGit(repo, ["ls-tree", "-z", "HEAD", "--", ...submodulePaths], options);
|
|
37863
|
+
for (const entry of result.stdout.split("\0")) {
|
|
37864
|
+
const match = entry.match(/^\d{6} commit ([0-9a-f]{40,64})\t(.+)$/s);
|
|
37865
|
+
if (match) expectedByPath.set(match[2], match[1]);
|
|
37866
|
+
}
|
|
37876
37867
|
} catch {
|
|
37877
|
-
return null;
|
|
37878
37868
|
}
|
|
37869
|
+
return expectedByPath;
|
|
37879
37870
|
}
|
|
37880
|
-
async function
|
|
37871
|
+
async function readSubmoduleWorktreeStatus(repo, repoPath, options) {
|
|
37881
37872
|
try {
|
|
37882
37873
|
const result = await runGit(repo, ["status", "--porcelain=v2", "--branch"], {
|
|
37883
37874
|
...options,
|
|
37884
|
-
cwd:
|
|
37875
|
+
cwd: repoPath
|
|
37885
37876
|
});
|
|
37886
37877
|
const parsed = parsePorcelainV2Status(result.stdout);
|
|
37887
37878
|
const dirty = parsed.staged + parsed.modified + parsed.untracked + parsed.deleted + parsed.renamed > 0 || parsed.conflictFiles.length > 0;
|
|
37888
|
-
|
|
37879
|
+
return { headOid: parsed.headOid, dirty };
|
|
37889
37880
|
} catch (error48) {
|
|
37890
|
-
|
|
37891
|
-
submodule.error = formatGitError(error48);
|
|
37881
|
+
return { headOid: null, dirty: true, error: formatGitError(error48) };
|
|
37892
37882
|
}
|
|
37893
37883
|
}
|
|
37894
37884
|
var import_node_path;
|
|
@@ -38773,8 +38763,7 @@ var require_dist3 = __commonJS({
|
|
|
38773
38763
|
}
|
|
38774
38764
|
});
|
|
38775
38765
|
function adhdevHome(env2 = process.env) {
|
|
38776
|
-
|
|
38777
|
-
return override ? override : path42.join(os6.homedir(), ".adhdev");
|
|
38766
|
+
return resolveConfigDir(env2);
|
|
38778
38767
|
}
|
|
38779
38768
|
function statuslineDir(env2 = process.env) {
|
|
38780
38769
|
return path42.join(adhdevHome(env2), "claude-statusline");
|
|
@@ -38802,10 +38791,11 @@ var require_dist3 = __commonJS({
|
|
|
38802
38791
|
"use strict";
|
|
38803
38792
|
os6 = __toESM2(require("os"));
|
|
38804
38793
|
path42 = __toESM2(require("path"));
|
|
38794
|
+
init_config_dir();
|
|
38805
38795
|
}
|
|
38806
38796
|
});
|
|
38807
38797
|
function renderWrapperScript(options) {
|
|
38808
|
-
return WRAPPER_TEMPLATE.replace("__ADHDEV_SNAPSHOT_PATH__", JSON.stringify(options.snapshotPath)).replace("__ADHDEV_ORIGINAL_COMMAND__", JSON.stringify(options.originalCommand)).replace("__ADHDEV_SNAPSHOT_VERSION__", JSON.stringify(options.snapshotVersion)).replace("__ADHDEV_MIN_WRITE_INTERVAL_MS__", JSON.stringify(options.minWriteIntervalMs)).replace("__ADHDEV_MAX_WRITE_INTERVAL_MS__", JSON.stringify(options.maxWriteIntervalMs));
|
|
38798
|
+
return WRAPPER_TEMPLATE.replace("__ADHDEV_SNAPSHOT_PATH__", JSON.stringify(options.snapshotPath)).replace("__ADHDEV_EXTRA_SNAPSHOT_PATHS__", JSON.stringify(options.additionalSnapshotPaths ?? [])).replace("__ADHDEV_ORIGINAL_COMMAND__", JSON.stringify(options.originalCommand)).replace("__ADHDEV_SNAPSHOT_VERSION__", JSON.stringify(options.snapshotVersion)).replace("__ADHDEV_MIN_WRITE_INTERVAL_MS__", JSON.stringify(options.minWriteIntervalMs)).replace("__ADHDEV_MAX_WRITE_INTERVAL_MS__", JSON.stringify(options.maxWriteIntervalMs));
|
|
38809
38799
|
}
|
|
38810
38800
|
var WRAPPER_TEMPLATE;
|
|
38811
38801
|
var init_wrapper_source = __esm2({
|
|
@@ -38825,6 +38815,7 @@ import { mkdirSync, readFileSync, renameSync, writeFileSync } from 'node:fs';
|
|
|
38825
38815
|
import { dirname } from 'node:path';
|
|
38826
38816
|
|
|
38827
38817
|
const SNAPSHOT_PATH = __ADHDEV_SNAPSHOT_PATH__;
|
|
38818
|
+
const EXTRA_SNAPSHOT_PATHS = __ADHDEV_EXTRA_SNAPSHOT_PATHS__;
|
|
38828
38819
|
const ORIGINAL_COMMAND = __ADHDEV_ORIGINAL_COMMAND__;
|
|
38829
38820
|
const SNAPSHOT_VERSION = __ADHDEV_SNAPSHOT_VERSION__;
|
|
38830
38821
|
const MIN_WRITE_INTERVAL_MS = __ADHDEV_MIN_WRITE_INTERVAL_MS__;
|
|
@@ -38910,13 +38901,24 @@ function capture(payload) {
|
|
|
38910
38901
|
};
|
|
38911
38902
|
if (typeof payload.version === 'string') snapshot.cliVersion = payload.version;
|
|
38912
38903
|
|
|
38913
|
-
//
|
|
38914
|
-
//
|
|
38915
|
-
//
|
|
38916
|
-
|
|
38917
|
-
const
|
|
38918
|
-
|
|
38919
|
-
|
|
38904
|
+
// Fan out to every track's snapshot path (the primary plus the sibling
|
|
38905
|
+
// tracks discovered at install time). Claude Code's statusLine slot is
|
|
38906
|
+
// machine-global, so this one reading belongs to every adhdev track on the
|
|
38907
|
+
// box; each track's daemon reads only its own directory.
|
|
38908
|
+
for (const target of [SNAPSHOT_PATH, ...EXTRA_SNAPSHOT_PATHS]) {
|
|
38909
|
+
try {
|
|
38910
|
+
// Write via a temp file + rename so a reader never sees a half-written
|
|
38911
|
+
// file, and so a killed invocation cannot truncate a good snapshot.
|
|
38912
|
+
// Claude Code cancels in-flight statusline scripts, so that is a real case.
|
|
38913
|
+
mkdirSync(dirname(target), { recursive: true });
|
|
38914
|
+
const temp = target + '.' + process.pid + '.tmp';
|
|
38915
|
+
writeFileSync(temp, JSON.stringify(snapshot), 'utf-8');
|
|
38916
|
+
renameSync(temp, target);
|
|
38917
|
+
} catch {
|
|
38918
|
+
// One unwritable track dir must not starve the others — and none
|
|
38919
|
+
// of this may reach the user's prompt (see the header note).
|
|
38920
|
+
}
|
|
38921
|
+
}
|
|
38920
38922
|
}
|
|
38921
38923
|
|
|
38922
38924
|
const stdinBuffer = await readStdin();
|
|
@@ -38967,6 +38969,26 @@ child.on('exit', () => process.exit(0));
|
|
|
38967
38969
|
stateDir: statuslineDir(env2)
|
|
38968
38970
|
};
|
|
38969
38971
|
}
|
|
38972
|
+
function discoverSiblingSnapshotPaths(env2 = process.env, homeDir = os22.homedir()) {
|
|
38973
|
+
const own = snapshotPath(env2);
|
|
38974
|
+
let entries;
|
|
38975
|
+
try {
|
|
38976
|
+
entries = fs32.readdirSync(homeDir, { withFileTypes: true });
|
|
38977
|
+
} catch {
|
|
38978
|
+
return [];
|
|
38979
|
+
}
|
|
38980
|
+
const targets = /* @__PURE__ */ new Set();
|
|
38981
|
+
for (const entry of entries) {
|
|
38982
|
+
if (!entry.isDirectory() || !entry.name.startsWith(".adhdev")) {
|
|
38983
|
+
continue;
|
|
38984
|
+
}
|
|
38985
|
+
const candidate = path52.join(homeDir, entry.name, "claude-statusline", "quota.json");
|
|
38986
|
+
if (candidate !== own) {
|
|
38987
|
+
targets.add(candidate);
|
|
38988
|
+
}
|
|
38989
|
+
}
|
|
38990
|
+
return [...targets].sort();
|
|
38991
|
+
}
|
|
38970
38992
|
function isWrapperCommand(command, wrapperFile) {
|
|
38971
38993
|
if (typeof command !== "string" || command === "") {
|
|
38972
38994
|
return false;
|
|
@@ -39036,6 +39058,7 @@ child.on('exit', () => process.exit(0));
|
|
|
39036
39058
|
const originalCommand = typeof originalStatusLine?.command === "string" && originalStatusLine.command !== "" ? originalStatusLine.command : null;
|
|
39037
39059
|
const script = renderWrapperScript({
|
|
39038
39060
|
snapshotPath: paths.snapshotFile,
|
|
39061
|
+
additionalSnapshotPaths: discoverSiblingSnapshotPaths(env2),
|
|
39039
39062
|
originalCommand,
|
|
39040
39063
|
snapshotVersion: SNAPSHOT_VERSION,
|
|
39041
39064
|
minWriteIntervalMs: MIN_WRITE_INTERVAL_MS,
|
|
@@ -39139,6 +39162,7 @@ child.on('exit', () => process.exit(0));
|
|
|
39139
39162
|
};
|
|
39140
39163
|
}
|
|
39141
39164
|
var fs32;
|
|
39165
|
+
var os22;
|
|
39142
39166
|
var path52;
|
|
39143
39167
|
var WRAPPER_MARKER;
|
|
39144
39168
|
var StatuslineInstallError2;
|
|
@@ -39146,6 +39170,7 @@ child.on('exit', () => process.exit(0));
|
|
|
39146
39170
|
"src/quota/statusline/install.ts"() {
|
|
39147
39171
|
"use strict";
|
|
39148
39172
|
fs32 = __toESM2(require("fs"));
|
|
39173
|
+
os22 = __toESM2(require("os"));
|
|
39149
39174
|
path52 = __toESM2(require("path"));
|
|
39150
39175
|
init_snapshot();
|
|
39151
39176
|
init_paths();
|
|
@@ -39883,7 +39908,7 @@ child.on('exit', () => process.exit(0));
|
|
|
39883
39908
|
});
|
|
39884
39909
|
function kimiHome(env2) {
|
|
39885
39910
|
const override = env2.KIMI_CODE_HOME?.trim();
|
|
39886
|
-
return override ? override : path6.join(
|
|
39911
|
+
return override ? override : path6.join(os32.homedir(), ".kimi-code");
|
|
39887
39912
|
}
|
|
39888
39913
|
function credentialsPath(env2) {
|
|
39889
39914
|
return path6.join(kimiHome(env2), "credentials", "kimi-code.json");
|
|
@@ -40016,6 +40041,13 @@ child.on('exit', () => process.exit(0));
|
|
|
40016
40041
|
metadata: { source: "oauth" }
|
|
40017
40042
|
};
|
|
40018
40043
|
}
|
|
40044
|
+
async function readErrorBody(response) {
|
|
40045
|
+
try {
|
|
40046
|
+
return await response.text?.() ?? "";
|
|
40047
|
+
} catch {
|
|
40048
|
+
return "";
|
|
40049
|
+
}
|
|
40050
|
+
}
|
|
40019
40051
|
function retryAfterMs(header, nowMs) {
|
|
40020
40052
|
if (!header) {
|
|
40021
40053
|
return void 0;
|
|
@@ -40059,11 +40091,28 @@ child.on('exit', () => process.exit(0));
|
|
|
40059
40091
|
},
|
|
40060
40092
|
signal: AbortSignal.timeout(REQUEST_TIMEOUT_MS2)
|
|
40061
40093
|
});
|
|
40062
|
-
if (response.status === 401
|
|
40094
|
+
if (response.status === 401) {
|
|
40063
40095
|
return quotaFailure(
|
|
40064
40096
|
"kimi",
|
|
40065
40097
|
"error",
|
|
40066
|
-
|
|
40098
|
+
"Kimi usage request was rejected (HTTP 401)",
|
|
40099
|
+
{ source: "oauth", failureKind: "unauthorized" }
|
|
40100
|
+
);
|
|
40101
|
+
}
|
|
40102
|
+
if (response.status === 403) {
|
|
40103
|
+
const body = await readErrorBody(response);
|
|
40104
|
+
if (USAGE_LIMIT_BODY_PATTERN.test(body)) {
|
|
40105
|
+
return quotaFailure(
|
|
40106
|
+
"kimi",
|
|
40107
|
+
"error",
|
|
40108
|
+
"Kimi usage limit reached (HTTP 403) \u2014 quota refreshes at the next reset/billing cycle",
|
|
40109
|
+
{ source: "oauth", failureKind: "quota-exhausted" }
|
|
40110
|
+
);
|
|
40111
|
+
}
|
|
40112
|
+
return quotaFailure(
|
|
40113
|
+
"kimi",
|
|
40114
|
+
"error",
|
|
40115
|
+
"Kimi usage request was rejected (HTTP 403)",
|
|
40067
40116
|
{ source: "oauth", failureKind: "unauthorized" }
|
|
40068
40117
|
);
|
|
40069
40118
|
}
|
|
@@ -40092,22 +40141,24 @@ child.on('exit', () => process.exit(0));
|
|
|
40092
40141
|
}
|
|
40093
40142
|
}
|
|
40094
40143
|
var fs5;
|
|
40095
|
-
var
|
|
40144
|
+
var os32;
|
|
40096
40145
|
var path6;
|
|
40097
40146
|
var DEFAULT_BASE_URL;
|
|
40098
40147
|
var REQUEST_TIMEOUT_MS2;
|
|
40099
40148
|
var EXPIRY_SKEW_SECONDS;
|
|
40149
|
+
var USAGE_LIMIT_BODY_PATTERN;
|
|
40100
40150
|
var init_kimi = __esm2({
|
|
40101
40151
|
"src/quota/fetchers/kimi.ts"() {
|
|
40102
40152
|
"use strict";
|
|
40103
40153
|
fs5 = __toESM2(require("fs"));
|
|
40104
|
-
|
|
40154
|
+
os32 = __toESM2(require("os"));
|
|
40105
40155
|
path6 = __toESM2(require("path"));
|
|
40106
40156
|
init_types();
|
|
40107
40157
|
init_deps();
|
|
40108
40158
|
DEFAULT_BASE_URL = "https://api.kimi.com/coding/v1";
|
|
40109
40159
|
REQUEST_TIMEOUT_MS2 = 1e4;
|
|
40110
40160
|
EXPIRY_SKEW_SECONDS = 5;
|
|
40161
|
+
USAGE_LIMIT_BODY_PATTERN = /usage limit|quota\s*(exhausted|refresh)|billing cycle/i;
|
|
40111
40162
|
}
|
|
40112
40163
|
});
|
|
40113
40164
|
function opencodeCommand(env2) {
|
|
@@ -40778,7 +40829,7 @@ child.on('exit', () => process.exit(0));
|
|
|
40778
40829
|
function unixExtraBinDirs() {
|
|
40779
40830
|
const dirs = [];
|
|
40780
40831
|
const fs56 = require("fs");
|
|
40781
|
-
const home =
|
|
40832
|
+
const home = os42.homedir();
|
|
40782
40833
|
const push = (dir) => {
|
|
40783
40834
|
if (!dir) return;
|
|
40784
40835
|
try {
|
|
@@ -40802,11 +40853,11 @@ child.on('exit', () => process.exit(0));
|
|
|
40802
40853
|
function findBinary(name) {
|
|
40803
40854
|
const trimmed = String(name || "").trim();
|
|
40804
40855
|
if (!trimmed) return trimmed;
|
|
40805
|
-
const expanded = trimmed.startsWith("~") ? path8.join(
|
|
40856
|
+
const expanded = trimmed.startsWith("~") ? path8.join(os42.homedir(), trimmed.slice(1)) : trimmed;
|
|
40806
40857
|
if (path8.isAbsolute(expanded) || expanded.includes("/") || expanded.includes("\\")) {
|
|
40807
40858
|
return path8.isAbsolute(expanded) ? expanded : path8.resolve(expanded);
|
|
40808
40859
|
}
|
|
40809
|
-
const isWin =
|
|
40860
|
+
const isWin = os42.platform() === "win32";
|
|
40810
40861
|
const paths = (process.env.PATH || "").split(path8.delimiter);
|
|
40811
40862
|
const extraDirs = [];
|
|
40812
40863
|
if (isWin) {
|
|
@@ -40874,7 +40925,7 @@ child.on('exit', () => process.exit(0));
|
|
|
40874
40925
|
}
|
|
40875
40926
|
function shSingleQuote(arg) {
|
|
40876
40927
|
if (/^[a-zA-Z0-9@%_+=:,./-]+$/.test(arg)) return arg;
|
|
40877
|
-
if (
|
|
40928
|
+
if (os42.platform() === "win32") {
|
|
40878
40929
|
return `"${arg.replace(/"/g, '""')}"`;
|
|
40879
40930
|
}
|
|
40880
40931
|
return `'${arg.replace(/'/g, `'\\''`)}'`;
|
|
@@ -40940,7 +40991,7 @@ child.on('exit', () => process.exit(0));
|
|
|
40940
40991
|
}
|
|
40941
40992
|
};
|
|
40942
40993
|
}
|
|
40943
|
-
var
|
|
40994
|
+
var os42;
|
|
40944
40995
|
var path8;
|
|
40945
40996
|
var import_child_process;
|
|
40946
40997
|
var TerminalTranscriptAccumulator;
|
|
@@ -40953,7 +41004,7 @@ child.on('exit', () => process.exit(0));
|
|
|
40953
41004
|
var init_provider_cli_shared = __esm2({
|
|
40954
41005
|
"src/cli-adapters/provider-cli-shared.ts"() {
|
|
40955
41006
|
"use strict";
|
|
40956
|
-
|
|
41007
|
+
os42 = __toESM2(require("os"));
|
|
40957
41008
|
path8 = __toESM2(require("path"));
|
|
40958
41009
|
import_child_process = require("child_process");
|
|
40959
41010
|
init_spawn_env();
|
|
@@ -41141,7 +41192,7 @@ child.on('exit', () => process.exit(0));
|
|
|
41141
41192
|
function expandHome(value) {
|
|
41142
41193
|
const trimmed = value.trim();
|
|
41143
41194
|
if (!trimmed.startsWith("~")) return trimmed;
|
|
41144
|
-
return path9.join(
|
|
41195
|
+
return path9.join(os52.homedir(), trimmed.slice(1));
|
|
41145
41196
|
}
|
|
41146
41197
|
function isExplicitCommandPath(command) {
|
|
41147
41198
|
const trimmed = command.trim();
|
|
@@ -41183,7 +41234,7 @@ child.on('exit', () => process.exit(0));
|
|
|
41183
41234
|
});
|
|
41184
41235
|
}
|
|
41185
41236
|
async function detectCLIs(providerLoader, options) {
|
|
41186
|
-
const platform10 =
|
|
41237
|
+
const platform10 = os52.platform();
|
|
41187
41238
|
const whichCmd = platform10 === "win32" ? "where" : "which";
|
|
41188
41239
|
const includeVersion = options?.includeVersion !== false;
|
|
41189
41240
|
const cliList = providerLoader ? providerLoader.getCliDetectionList({ includeDisabled: options?.includeDisabled }) : [];
|
|
@@ -41225,7 +41276,7 @@ child.on('exit', () => process.exit(0));
|
|
|
41225
41276
|
const cliList = providerLoader.getCliDetectionList();
|
|
41226
41277
|
const target = cliList.find((c) => c.id === resolvedId);
|
|
41227
41278
|
if (target) {
|
|
41228
|
-
const platform10 =
|
|
41279
|
+
const platform10 = os52.platform();
|
|
41229
41280
|
const whichCmd = platform10 === "win32" ? "where" : "which";
|
|
41230
41281
|
try {
|
|
41231
41282
|
const firstPath = await resolveDetectionPath(target.command, whichCmd);
|
|
@@ -41308,7 +41359,7 @@ child.on('exit', () => process.exit(0));
|
|
|
41308
41359
|
return out;
|
|
41309
41360
|
}
|
|
41310
41361
|
var import_child_process2;
|
|
41311
|
-
var
|
|
41362
|
+
var os52;
|
|
41312
41363
|
var path9;
|
|
41313
41364
|
var import_fs4;
|
|
41314
41365
|
var PROVIDER_VERSIONS_TTL_MS;
|
|
@@ -41320,7 +41371,7 @@ child.on('exit', () => process.exit(0));
|
|
|
41320
41371
|
"src/detection/cli-detector.ts"() {
|
|
41321
41372
|
"use strict";
|
|
41322
41373
|
import_child_process2 = require("child_process");
|
|
41323
|
-
|
|
41374
|
+
os52 = __toESM2(require("os"));
|
|
41324
41375
|
path9 = __toESM2(require("path"));
|
|
41325
41376
|
import_fs4 = require("fs");
|
|
41326
41377
|
init_provider_cli_shared();
|
|
@@ -41716,7 +41767,7 @@ ${error48.message || ""}`;
|
|
|
41716
41767
|
function expandPath(p) {
|
|
41717
41768
|
const t = (p || "").trim();
|
|
41718
41769
|
if (!t) return "";
|
|
41719
|
-
if (t.startsWith("~")) return path13.join(
|
|
41770
|
+
if (t.startsWith("~")) return path13.join(os7.homedir(), t.slice(1).replace(/^\//, ""));
|
|
41720
41771
|
return path13.resolve(t);
|
|
41721
41772
|
}
|
|
41722
41773
|
function validateWorkspacePath(absPath) {
|
|
@@ -41789,7 +41840,7 @@ ${error48.message || ""}`;
|
|
|
41789
41840
|
};
|
|
41790
41841
|
}
|
|
41791
41842
|
if (a.useHome === true) {
|
|
41792
|
-
return { ok: true, path:
|
|
41843
|
+
return { ok: true, path: os7.homedir(), source: "home" };
|
|
41793
41844
|
}
|
|
41794
41845
|
return {
|
|
41795
41846
|
ok: false,
|
|
@@ -41873,7 +41924,7 @@ ${error48.message || ""}`;
|
|
|
41873
41924
|
return { config: { ...config2, defaultWorkspaceId: id } };
|
|
41874
41925
|
}
|
|
41875
41926
|
var fs7;
|
|
41876
|
-
var
|
|
41927
|
+
var os7;
|
|
41877
41928
|
var path13;
|
|
41878
41929
|
var import_crypto22;
|
|
41879
41930
|
var MAX_WORKSPACES;
|
|
@@ -41881,7 +41932,7 @@ ${error48.message || ""}`;
|
|
|
41881
41932
|
"src/config/workspaces.ts"() {
|
|
41882
41933
|
"use strict";
|
|
41883
41934
|
fs7 = __toESM2(require("fs"));
|
|
41884
|
-
|
|
41935
|
+
os7 = __toESM2(require("os"));
|
|
41885
41936
|
path13 = __toESM2(require("path"));
|
|
41886
41937
|
import_crypto22 = require("crypto");
|
|
41887
41938
|
MAX_WORKSPACES = 50;
|
|
@@ -43015,6 +43066,7 @@ ${error48.message || ""}`;
|
|
|
43015
43066
|
getMagiKindPanel: () => getMagiKindPanel,
|
|
43016
43067
|
getMesh: () => getMesh,
|
|
43017
43068
|
getMeshByRepo: () => getMeshByRepo,
|
|
43069
|
+
getMeshQuotaRouting: () => getMeshQuotaRouting,
|
|
43018
43070
|
listMagiKindPanels: () => listMagiKindPanels,
|
|
43019
43071
|
listMagiKindPanelsReadOnly: () => listMagiKindPanelsReadOnly,
|
|
43020
43072
|
listMeshes: () => listMeshes,
|
|
@@ -43030,6 +43082,7 @@ ${error48.message || ""}`;
|
|
|
43030
43082
|
setDifficultyBrains: () => setDifficultyBrains,
|
|
43031
43083
|
setMagiKindPanel: () => setMagiKindPanel,
|
|
43032
43084
|
setMeshHostPin: () => setMeshHostPin,
|
|
43085
|
+
setMeshQuotaRouting: () => setMeshQuotaRouting,
|
|
43033
43086
|
tokenIdForManualPairing: () => tokenIdForManualPairing,
|
|
43034
43087
|
updateMesh: () => updateMesh,
|
|
43035
43088
|
updateNode: () => updateNode
|
|
@@ -43732,12 +43785,59 @@ ${error48.message || ""}`;
|
|
|
43732
43785
|
saveMeshConfig(stored);
|
|
43733
43786
|
return normalized;
|
|
43734
43787
|
}
|
|
43788
|
+
function validateQuotaRoutingOverrides(input) {
|
|
43789
|
+
if (input === void 0 || input === null) return {};
|
|
43790
|
+
if (typeof input !== "object" || Array.isArray(input)) {
|
|
43791
|
+
throw new Error("invalid_quota_routing: quotaRouting must be an object of threshold overrides");
|
|
43792
|
+
}
|
|
43793
|
+
const out = {};
|
|
43794
|
+
for (const [key2, raw] of Object.entries(input)) {
|
|
43795
|
+
const isPercent = QUOTA_ROUTING_PERCENT_FIELDS.has(key2);
|
|
43796
|
+
if (!isPercent && !QUOTA_ROUTING_NONNEGATIVE_FIELDS.has(key2)) {
|
|
43797
|
+
throw new Error(
|
|
43798
|
+
`invalid_quota_routing: unknown field '${key2}' (known fields: ` + [...QUOTA_ROUTING_PERCENT_FIELDS, ...QUOTA_ROUTING_NONNEGATIVE_FIELDS].join(", ") + ")"
|
|
43799
|
+
);
|
|
43800
|
+
}
|
|
43801
|
+
if (typeof raw !== "number" || !Number.isFinite(raw)) {
|
|
43802
|
+
throw new Error(`invalid_quota_routing: ${key2} must be a finite number (got ${JSON.stringify(raw)})`);
|
|
43803
|
+
}
|
|
43804
|
+
if (isPercent && (raw < 0 || raw > 100)) {
|
|
43805
|
+
throw new Error(`invalid_quota_routing: ${key2} must be between 0 and 100 (got ${raw})`);
|
|
43806
|
+
}
|
|
43807
|
+
if (!isPercent && raw < 0) {
|
|
43808
|
+
throw new Error(`invalid_quota_routing: ${key2} must be >= 0 (got ${raw})`);
|
|
43809
|
+
}
|
|
43810
|
+
out[key2] = raw;
|
|
43811
|
+
}
|
|
43812
|
+
return out;
|
|
43813
|
+
}
|
|
43814
|
+
function getMeshQuotaRouting(meshId) {
|
|
43815
|
+
const config2 = loadMeshConfig();
|
|
43816
|
+
const stored = resolveScopedMesh(config2, meshId)?.policy?.quotaRouting;
|
|
43817
|
+
return normalizeQuotaRoutingPolicy(stored) ?? {};
|
|
43818
|
+
}
|
|
43819
|
+
function setMeshQuotaRouting(input, meshId) {
|
|
43820
|
+
const overrides = validateQuotaRoutingOverrides(input);
|
|
43821
|
+
const stored = loadMeshConfig();
|
|
43822
|
+
const mesh = resolveScopedMesh(stored, meshId);
|
|
43823
|
+
if (!mesh) {
|
|
43824
|
+
throw new Error(
|
|
43825
|
+
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.`
|
|
43826
|
+
);
|
|
43827
|
+
}
|
|
43828
|
+
mesh.policy = mergeAndNormalizePolicy(mesh.policy, { quotaRouting: overrides });
|
|
43829
|
+
mesh.updatedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
43830
|
+
saveMeshConfig(stored);
|
|
43831
|
+
return normalizeQuotaRoutingPolicy(overrides) ?? {};
|
|
43832
|
+
}
|
|
43735
43833
|
var import_fs5;
|
|
43736
43834
|
var import_path5;
|
|
43737
43835
|
var import_crypto3;
|
|
43738
43836
|
var mergeMeshPolicy;
|
|
43739
43837
|
var MAGI_KIND_PANEL_KINDS;
|
|
43740
43838
|
var MAX_MAGI_KIND_SLOTS;
|
|
43839
|
+
var QUOTA_ROUTING_PERCENT_FIELDS;
|
|
43840
|
+
var QUOTA_ROUTING_NONNEGATIVE_FIELDS;
|
|
43741
43841
|
var init_mesh_config = __esm2({
|
|
43742
43842
|
"src/config/mesh-config.ts"() {
|
|
43743
43843
|
"use strict";
|
|
@@ -43752,6 +43852,8 @@ ${error48.message || ""}`;
|
|
|
43752
43852
|
mergeMeshPolicy = mergeAndNormalizePolicy;
|
|
43753
43853
|
MAGI_KIND_PANEL_KINDS = ["claim_audit", "rca", "design", "freeform"];
|
|
43754
43854
|
MAX_MAGI_KIND_SLOTS = 24;
|
|
43855
|
+
QUOTA_ROUTING_PERCENT_FIELDS = /* @__PURE__ */ new Set(["sessionMinRemainingPercent", "weeklyMinRemainingPercent"]);
|
|
43856
|
+
QUOTA_ROUTING_NONNEGATIVE_FIELDS = /* @__PURE__ */ new Set(["staleAfterMs", "sessionResetImminentMs", "spreadBonusMax"]);
|
|
43755
43857
|
}
|
|
43756
43858
|
});
|
|
43757
43859
|
function normalizeProviderPriority(policy) {
|
|
@@ -47404,11 +47506,11 @@ Next step: ${nextStep}`;
|
|
|
47404
47506
|
const pinnedProvider = typeof providerType === "string" && providerType.trim() ? providerType.trim() : void 0;
|
|
47405
47507
|
const providerTags = pinnedProvider ? [pinnedProvider] : readNodeProviderTypes(node?.policy);
|
|
47406
47508
|
const worktreeBranch = typeof node?.worktreeBranch === "string" && node.worktreeBranch.trim() ? node.worktreeBranch.trim() : null;
|
|
47407
|
-
const
|
|
47509
|
+
const os29 = readNodeOverride(node, "platform") ?? readNodeReporter(node, "platform") ?? process.platform;
|
|
47408
47510
|
const arch2 = readNodeOverride(node, "arch") ?? readNodeReporter(node, "arch") ?? process.arch;
|
|
47409
47511
|
return normalizeMeshCapabilityTags([
|
|
47410
47512
|
...Array.isArray(node?.capabilities) ? node.capabilities : [],
|
|
47411
|
-
`os=${
|
|
47513
|
+
`os=${os29}`,
|
|
47412
47514
|
`arch=${arch2}`,
|
|
47413
47515
|
...providerTags.map((p) => `provider=${p}`),
|
|
47414
47516
|
// Worktree nodes automatically expose a "worktree=<branch>" tag so that
|
|
@@ -52047,7 +52149,7 @@ Default branch: \`${mesh.defaultBranch}\`` : ""}`);
|
|
|
52047
52149
|
sections.push(TOOL_EXPOSURE_PREFLIGHT_SECTION);
|
|
52048
52150
|
sections.push(WORKFLOW_SECTION);
|
|
52049
52151
|
sections.push(ONBOARDING_SECTION);
|
|
52050
|
-
sections.push(buildRulesSection(coordinatorCliType));
|
|
52152
|
+
sections.push(buildRulesSection(coordinatorCliType, mergeAndNormalizePolicy(void 0, mesh.policy)));
|
|
52051
52153
|
return sections.join("\n\n");
|
|
52052
52154
|
}
|
|
52053
52155
|
function readUserPromptFile(cliType, suffix) {
|
|
@@ -52080,7 +52182,7 @@ Default branch: \`${mesh.defaultBranch}\`` : ""}`);
|
|
|
52080
52182
|
tools: TOOLS_SECTION,
|
|
52081
52183
|
workflow: WORKFLOW_SECTION,
|
|
52082
52184
|
onboarding: ONBOARDING_SECTION,
|
|
52083
|
-
rules: buildRulesSection(coordinatorCliType),
|
|
52185
|
+
rules: buildRulesSection(coordinatorCliType, mergeAndNormalizePolicy(void 0, mesh.policy)),
|
|
52084
52186
|
toolExposurePreflight: TOOL_EXPOSURE_PREFLIGHT_SECTION
|
|
52085
52187
|
};
|
|
52086
52188
|
return template.replace(/\{\{\s*([a-zA-Z_][a-zA-Z0-9_]*)\s*\}\}/g, (m, key2) => {
|
|
@@ -52413,12 +52515,14 @@ Default branch: \`${mesh.defaultBranch}\`` : ""}`);
|
|
|
52413
52515
|
return `## Policy
|
|
52414
52516
|
${rules.join("\n")}`;
|
|
52415
52517
|
}
|
|
52416
|
-
function buildRulesSection(coordinatorCliType) {
|
|
52518
|
+
function buildRulesSection(coordinatorCliType, policy) {
|
|
52417
52519
|
const coordinatorNote = coordinatorCliType ? `
|
|
52418
52520
|
- **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.` : "";
|
|
52521
|
+
const destructiveGitRequiresApproval = policy ? policy.requireApprovalForDestructiveGit : true;
|
|
52522
|
+
const destructiveGitRule = destructiveGitRequiresApproval ? "\n- **Never run destructive git operations without explicit user approval.** Force push (`push --force`/`--force-with-lease`), `git reset --hard`, and any history rewrite (`rebase`, `filter-branch`, `commit --amend` on already-pushed work) can destroy work that is not recoverable from the mesh ledger. This mesh's policy currently requires approval for these (see Policy above). Ask first and wait for a yes \u2014 there is no code-level gate backing this up, so skipping the ask is the only thing that can lose the user's work." : "\n- **This mesh's policy does not require approval for destructive git operations** (`requireApprovalForDestructiveGit` is off). Still treat force push, `git reset --hard`, and history rewrites as high-risk: prefer a non-destructive alternative when one exists, and mention what you did in your summary so the user can catch a mistake quickly.";
|
|
52419
52523
|
return `## Rules
|
|
52420
52524
|
|
|
52421
|
-
- **Route, don't implement.** Delegate all code reading, analysis, and execution to node agents. Never read source files or run commands in the coordinator \u2014 keep context lean. See also: **Never use local sub-agents** below
|
|
52525
|
+
- **Route, don't implement.** Delegate all code reading, analysis, and execution to node agents. Never read source files or run commands in the coordinator \u2014 keep context lean. See also: **Never use local sub-agents** below.${destructiveGitRule}
|
|
52422
52526
|
- **Never use local sub-agents.** Do NOT spawn your runtime's own sub-agents (e.g. Claude Code's Task/Explore/Agent tools, or any equivalent in-process agent-spawning tool) to read code, investigate, run RCA, or implement. Such sub-agents execute on the coordinator's machine, outside the mesh \u2014 they escape mesh parallelism, the ledger/audit trail, node capability profiles, and worktree isolation, and leave no \`mesh_task_history\` record. ALL code reading, analysis, RCA, and implementation must be delegated to mesh nodes via \`mesh_enqueue_task\` / \`mesh_send_task\` (use \`task_mode: "live_debug_readonly"\` for read-only investigation), or cross-verified via \`mesh_magi_review\` for read-only fan-out. The coordinator's own actions are limited to \`mesh_*\` tool orchestration and synthesizing results.
|
|
52423
52527
|
- **Front-load task messages.** Include everything the agent needs (files, problem, expected fix) in \`mesh_enqueue_task\` / \`mesh_send_task\`. Append a structured result request at the end: ask the worker to conclude with a JSON block containing \`status\`, \`changedFiles\`, \`gitStatus\`, \`validationResults\`, \`errors\`, \`nextAction\`. The daemon parses this automatically; you can read it from \`mesh_task_history\`.
|
|
52424
52528
|
- **Reuse idle sessions.** For follow-up, retry, commit/push, or cleanup on the same issue, send only the delta to the existing idle session. Start a fresh session only when: (a) branch/worktree isolation is required, (b) the existing session had a dispatch failure or provider mismatch, (c) the transcript/runtime is contaminated or interrupted, (d) the user explicitly asks for a different provider/session, or (e) **the delta is a genuinely NEW subject rather than a continuation** \u2014 a new topic appended to an existing session can be dropped or re-run as the previous task, so give it its own task even when a session sits idle. Continuation of the same issue in an already-idle session is allowed and preferred \u2014 this rule blocks concurrent unrelated work interleaved into a live (still-generating) session, not sequential same-issue follow-ups. The test is subject continuity, not timing: carrying an investigation forward into its own fix is the SAME subject and belongs in that session (Workflow 3f), while an unrelated bug is a new subject even if the same session just went idle.
|
|
@@ -53952,14 +54056,14 @@ When the user asks to **set up / configure / onboard** this repo for Repo Mesh (
|
|
|
53952
54056
|
}
|
|
53953
54057
|
function resolveHermesCoordinatorHome(meshId, workspace) {
|
|
53954
54058
|
const key2 = `${meshId || "mesh"}
|
|
53955
|
-
${(0, import_node_path3.resolve)(workspace ||
|
|
54059
|
+
${(0, import_node_path3.resolve)(workspace || os8.tmpdir())}`;
|
|
53956
54060
|
const hash2 = shortHash(key2);
|
|
53957
|
-
return (0, import_node_path3.join)(
|
|
54061
|
+
return (0, import_node_path3.join)(os8.tmpdir(), `adhdev-hermes-mesh-coordinator-${hash2}`);
|
|
53958
54062
|
}
|
|
53959
54063
|
function resolveMcpConfigPath(configPath, workspace) {
|
|
53960
54064
|
const trimmed = configPath.trim();
|
|
53961
|
-
if (trimmed === "~") return
|
|
53962
|
-
if (trimmed.startsWith("~/")) return (0, import_node_path3.join)(
|
|
54065
|
+
if (trimmed === "~") return os8.homedir();
|
|
54066
|
+
if (trimmed.startsWith("~/")) return (0, import_node_path3.join)(os8.homedir(), trimmed.slice(2));
|
|
53963
54067
|
if ((0, import_node_path3.isAbsolute)(trimmed)) return trimmed;
|
|
53964
54068
|
return (0, import_node_path3.join)(workspace, trimmed);
|
|
53965
54069
|
}
|
|
@@ -54037,7 +54141,7 @@ ${(0, import_node_path3.resolve)(workspace || os7.tmpdir())}`;
|
|
|
54037
54141
|
const template = injection.template && injection.template.includes("{prompt}") ? injection.template : "{prompt}";
|
|
54038
54142
|
const body = template.replace(/\{prompt\}/g, systemPrompt);
|
|
54039
54143
|
try {
|
|
54040
|
-
const dir = (0, import_node_fs3.mkdtempSync)((0, import_node_path3.join)(
|
|
54144
|
+
const dir = (0, import_node_fs3.mkdtempSync)((0, import_node_path3.join)(os8.tmpdir(), `adhdev-coord-${ctx.cliType}-`));
|
|
54041
54145
|
const filePath = (0, import_node_path3.join)(dir, "coordinator-agent.md");
|
|
54042
54146
|
(0, import_node_fs3.writeFileSync)(filePath, body, "utf-8");
|
|
54043
54147
|
ctx.cliArgs.push(injection.flag, filePath);
|
|
@@ -54197,7 +54301,7 @@ ${rendered}`, "utf-8");
|
|
|
54197
54301
|
});
|
|
54198
54302
|
}
|
|
54199
54303
|
var import_node_fs3;
|
|
54200
|
-
var
|
|
54304
|
+
var os8;
|
|
54201
54305
|
var import_session_host_core32;
|
|
54202
54306
|
var import_node_path3;
|
|
54203
54307
|
var DEFAULT_SERVER_NAME;
|
|
@@ -54208,7 +54312,7 @@ ${rendered}`, "utf-8");
|
|
|
54208
54312
|
"src/commands/mesh-coordinator.ts"() {
|
|
54209
54313
|
"use strict";
|
|
54210
54314
|
import_node_fs3 = require("fs");
|
|
54211
|
-
|
|
54315
|
+
os8 = __toESM2(require("os"));
|
|
54212
54316
|
import_session_host_core32 = require_dist();
|
|
54213
54317
|
import_node_path3 = require("path");
|
|
54214
54318
|
init_logger();
|
|
@@ -60514,7 +60618,17 @@ The mesh has no work in flight. For each mission, decide its outcome: continue i
|
|
|
60514
60618
|
const entry = quotaEntryFor(node, providerType);
|
|
60515
60619
|
if (!entry) return null;
|
|
60516
60620
|
const { facts, quota } = entry;
|
|
60517
|
-
if (quota.status !== "ok")
|
|
60621
|
+
if (quota.status !== "ok") {
|
|
60622
|
+
if (quota.status === "error" && quota.metadata?.failureKind === "quota-exhausted" && isQuotaSnapshotFresh(facts, quota, policy, now)) {
|
|
60623
|
+
return {
|
|
60624
|
+
reason: PROVIDER_QUOTA_EXHAUSTED_SKIP_REASON,
|
|
60625
|
+
window: "unknown",
|
|
60626
|
+
remainingPercent: 0,
|
|
60627
|
+
thresholdPercent: 0
|
|
60628
|
+
};
|
|
60629
|
+
}
|
|
60630
|
+
return null;
|
|
60631
|
+
}
|
|
60518
60632
|
if (!isQuotaSnapshotFresh(facts, quota, policy, now)) return null;
|
|
60519
60633
|
const resolved = resolveQuotaRoutingPolicy(policy);
|
|
60520
60634
|
const session = remainingPercent(quota.session);
|
|
@@ -60559,12 +60673,14 @@ The mesh has no work in flight. For each mission, decide its outcome: continue i
|
|
|
60559
60673
|
}
|
|
60560
60674
|
var PROVIDER_QUOTA_SESSION_LOW_SKIP_REASON;
|
|
60561
60675
|
var PROVIDER_QUOTA_WEEKLY_LOW_SKIP_REASON;
|
|
60676
|
+
var PROVIDER_QUOTA_EXHAUSTED_SKIP_REASON;
|
|
60562
60677
|
var init_mesh_quota_routing = __esm2({
|
|
60563
60678
|
"src/mesh/mesh-quota-routing.ts"() {
|
|
60564
60679
|
"use strict";
|
|
60565
60680
|
init_repo_mesh_types();
|
|
60566
60681
|
PROVIDER_QUOTA_SESSION_LOW_SKIP_REASON = "provider_quota_session_low";
|
|
60567
60682
|
PROVIDER_QUOTA_WEEKLY_LOW_SKIP_REASON = "provider_quota_weekly_low";
|
|
60683
|
+
PROVIDER_QUOTA_EXHAUSTED_SKIP_REASON = "provider_quota_exhausted";
|
|
60568
60684
|
}
|
|
60569
60685
|
});
|
|
60570
60686
|
function isAnthropicProvider(providerType) {
|
|
@@ -61134,10 +61250,11 @@ The mesh has no work in flight. For each mission, decide its outcome: continue i
|
|
|
61134
61250
|
// busy counterpart SLOT_MODEL_BUSY_SKIP_REASON is deliberately NOT listed:
|
|
61135
61251
|
// that one clears on its own when the slot goes idle.
|
|
61136
61252
|
SLOT_MODEL_ABSENT_SKIP_REASON
|
|
61137
|
-
// QUOTA GATE: 'provider_quota_session_low' / 'provider_quota_weekly_low'
|
|
61138
|
-
// deliberately NOT listed either — an
|
|
61139
|
-
//
|
|
61140
|
-
// queue and the coordinator is
|
|
61253
|
+
// QUOTA GATE: 'provider_quota_session_low' / 'provider_quota_weekly_low' /
|
|
61254
|
+
// 'provider_quota_exhausted' are deliberately NOT listed either — an
|
|
61255
|
+
// exhausted quota window RESETS, so the block self-resolves exactly like
|
|
61256
|
+
// the slot-busy case; the task waits in the queue and the coordinator is
|
|
61257
|
+
// not paged (mesh-quota-routing.ts).
|
|
61141
61258
|
];
|
|
61142
61259
|
TRANSIENT_TARGET_NODE_BOOTSTRAP_PENDING_REASON = "target_node_bootstrap_pending";
|
|
61143
61260
|
lastActionableSkipNotified = /* @__PURE__ */ new Map();
|
|
@@ -61642,7 +61759,11 @@ The mesh has no work in flight. For each mission, decide its outcome: continue i
|
|
|
61642
61759
|
}
|
|
61643
61760
|
const quotaClaimBlock = evaluateProviderQuotaGate(node, providerType, mesh?.policy?.quotaRouting ?? null);
|
|
61644
61761
|
if (quotaClaimBlock) {
|
|
61645
|
-
|
|
61762
|
+
if (quotaClaimBlock.reason === PROVIDER_QUOTA_EXHAUSTED_SKIP_REASON) {
|
|
61763
|
+
LOG2.info("MeshQueue", `QUOTA GATE: deferring queue claim for node ${nodeId} (${sessionId}): provider '${providerType}' reported its quota EXHAUSTED \u2014 task left pending until the quota resets`);
|
|
61764
|
+
} else {
|
|
61765
|
+
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`);
|
|
61766
|
+
}
|
|
61646
61767
|
return false;
|
|
61647
61768
|
}
|
|
61648
61769
|
const inlineBootstrapNode = (() => {
|
|
@@ -62387,7 +62508,11 @@ The mesh has no work in flight. For each mission, decide its outcome: continue i
|
|
|
62387
62508
|
}
|
|
62388
62509
|
const quotaBlock = evaluateProviderQuotaGate(node, resolved.providerType, mesh?.policy?.quotaRouting ?? null);
|
|
62389
62510
|
if (quotaBlock) {
|
|
62390
|
-
|
|
62511
|
+
if (quotaBlock.reason === PROVIDER_QUOTA_EXHAUSTED_SKIP_REASON) {
|
|
62512
|
+
LOG2.info("MeshQueue", `QUOTA GATE: provider '${resolved.providerType}' on node ${nodeId} reported its quota EXHAUSTED (task ${task.id}); leaving the task queued until the quota resets`);
|
|
62513
|
+
} else {
|
|
62514
|
+
LOG2.info("MeshQueue", `QUOTA GATE: provider '${resolved.providerType}' on node ${nodeId} has ${quotaBlock.remainingPercent.toFixed(1)}% ${quotaBlock.window} quota remaining (< ${quotaBlock.thresholdPercent}% threshold, task ${task.id}); leaving the task queued until the window resets`);
|
|
62515
|
+
}
|
|
62391
62516
|
markSkip(nodeId, quotaBlock.reason, { providerType: resolved.providerType });
|
|
62392
62517
|
continue;
|
|
62393
62518
|
}
|
|
@@ -63147,7 +63272,7 @@ The mesh has no work in flight. For each mission, decide its outcome: continue i
|
|
|
63147
63272
|
}
|
|
63148
63273
|
});
|
|
63149
63274
|
async function updateDarwinMemoryCache() {
|
|
63150
|
-
if (
|
|
63275
|
+
if (os9.platform() !== "darwin") return;
|
|
63151
63276
|
try {
|
|
63152
63277
|
const { stdout } = await execAsync2("vm_stat", {
|
|
63153
63278
|
encoding: "utf-8",
|
|
@@ -63171,26 +63296,26 @@ The mesh has no work in flight. For each mission, decide its outcome: continue i
|
|
|
63171
63296
|
const fileBacked = counts["file_backed"] ?? 0;
|
|
63172
63297
|
const availPages = free + inactive + speculative + purgeable + fileBacked;
|
|
63173
63298
|
const bytes = availPages * pageSize;
|
|
63174
|
-
cachedDarwinAvail = Number.isFinite(bytes) && bytes >= 0 ? Math.min(bytes,
|
|
63299
|
+
cachedDarwinAvail = Number.isFinite(bytes) && bytes >= 0 ? Math.min(bytes, os9.totalmem()) : null;
|
|
63175
63300
|
} catch {
|
|
63176
63301
|
}
|
|
63177
63302
|
}
|
|
63178
63303
|
function getHostMemorySnapshot() {
|
|
63179
|
-
if (
|
|
63304
|
+
if (os9.platform() === "darwin" && !darwinMemoryInterval) {
|
|
63180
63305
|
updateDarwinMemoryCache();
|
|
63181
63306
|
darwinMemoryInterval = setInterval(updateDarwinMemoryCache, 3e3);
|
|
63182
63307
|
darwinMemoryInterval.unref();
|
|
63183
63308
|
}
|
|
63184
|
-
const totalMem =
|
|
63185
|
-
const freeMem =
|
|
63186
|
-
const availableMem =
|
|
63309
|
+
const totalMem = os9.totalmem();
|
|
63310
|
+
const freeMem = os9.freemem();
|
|
63311
|
+
const availableMem = os9.platform() === "darwin" ? cachedDarwinAvail ?? freeMem : freeMem;
|
|
63187
63312
|
return {
|
|
63188
63313
|
totalMem,
|
|
63189
63314
|
freeMem,
|
|
63190
63315
|
availableMem
|
|
63191
63316
|
};
|
|
63192
63317
|
}
|
|
63193
|
-
var
|
|
63318
|
+
var os9;
|
|
63194
63319
|
var import_child_process4;
|
|
63195
63320
|
var import_util3;
|
|
63196
63321
|
var execAsync2;
|
|
@@ -63199,7 +63324,7 @@ The mesh has no work in flight. For each mission, decide its outcome: continue i
|
|
|
63199
63324
|
var init_host_memory = __esm2({
|
|
63200
63325
|
"src/system/host-memory.ts"() {
|
|
63201
63326
|
"use strict";
|
|
63202
|
-
|
|
63327
|
+
os9 = __toESM2(require("os"));
|
|
63203
63328
|
import_child_process4 = require("child_process");
|
|
63204
63329
|
import_util3 = require("util");
|
|
63205
63330
|
execAsync2 = (0, import_util3.promisify)(import_child_process4.exec);
|
|
@@ -64343,8 +64468,8 @@ ${cleanBody}`;
|
|
|
64343
64468
|
}
|
|
64344
64469
|
function buildMachineInfo2(profile = "full") {
|
|
64345
64470
|
const base = {
|
|
64346
|
-
hostname:
|
|
64347
|
-
platform:
|
|
64471
|
+
hostname: os10.hostname(),
|
|
64472
|
+
platform: os10.platform()
|
|
64348
64473
|
};
|
|
64349
64474
|
if (profile === "live") {
|
|
64350
64475
|
return base;
|
|
@@ -64353,23 +64478,23 @@ ${cleanBody}`;
|
|
|
64353
64478
|
const memSnap2 = getHostMemorySnapshot();
|
|
64354
64479
|
return {
|
|
64355
64480
|
...base,
|
|
64356
|
-
arch:
|
|
64357
|
-
cpus:
|
|
64481
|
+
arch: os10.arch(),
|
|
64482
|
+
cpus: os10.cpus().length,
|
|
64358
64483
|
totalMem: memSnap2.totalMem,
|
|
64359
|
-
release:
|
|
64484
|
+
release: os10.release()
|
|
64360
64485
|
};
|
|
64361
64486
|
}
|
|
64362
64487
|
const memSnap = getHostMemorySnapshot();
|
|
64363
64488
|
return {
|
|
64364
64489
|
...base,
|
|
64365
|
-
arch:
|
|
64366
|
-
cpus:
|
|
64490
|
+
arch: os10.arch(),
|
|
64491
|
+
cpus: os10.cpus().length,
|
|
64367
64492
|
totalMem: memSnap.totalMem,
|
|
64368
64493
|
freeMem: memSnap.freeMem,
|
|
64369
64494
|
availableMem: memSnap.availableMem,
|
|
64370
|
-
loadavg:
|
|
64371
|
-
uptime:
|
|
64372
|
-
release:
|
|
64495
|
+
loadavg: os10.loadavg(),
|
|
64496
|
+
uptime: os10.uptime(),
|
|
64497
|
+
release: os10.release()
|
|
64373
64498
|
};
|
|
64374
64499
|
}
|
|
64375
64500
|
function parseMessageTime(value) {
|
|
@@ -64606,13 +64731,13 @@ ${cleanBody}`;
|
|
|
64606
64731
|
}
|
|
64607
64732
|
};
|
|
64608
64733
|
}
|
|
64609
|
-
var
|
|
64734
|
+
var os10;
|
|
64610
64735
|
var READ_DEBUG_ENABLED;
|
|
64611
64736
|
var recentReadDebugSignatureBySession;
|
|
64612
64737
|
var init_snapshot2 = __esm2({
|
|
64613
64738
|
"src/status/snapshot.ts"() {
|
|
64614
64739
|
"use strict";
|
|
64615
|
-
|
|
64740
|
+
os10 = __toESM2(require("os"));
|
|
64616
64741
|
init_config();
|
|
64617
64742
|
init_state_store();
|
|
64618
64743
|
init_recent_activity();
|
|
@@ -70807,7 +70932,7 @@ ${cleanBody}`;
|
|
|
70807
70932
|
}
|
|
70808
70933
|
function expandTemplateRootForEnumeration(template, input) {
|
|
70809
70934
|
if (!template) return "";
|
|
70810
|
-
const posixHome = () => toPosixPath(
|
|
70935
|
+
const posixHome = () => toPosixPath(os13.homedir());
|
|
70811
70936
|
let out = template;
|
|
70812
70937
|
if (out === "~") out = posixHome();
|
|
70813
70938
|
else if (out.startsWith("~/")) out = `${posixHome()}/${out.slice(2)}`;
|
|
@@ -71420,13 +71545,13 @@ ${cleanBody}`;
|
|
|
71420
71545
|
if (!template) return null;
|
|
71421
71546
|
let out = template;
|
|
71422
71547
|
if (out.startsWith("~/") || out === "~") {
|
|
71423
|
-
out = path27.join(
|
|
71548
|
+
out = path27.join(os13.homedir(), out.slice(2));
|
|
71424
71549
|
}
|
|
71425
71550
|
out = out.replace(/\$\{([A-Z_][A-Z0-9_]*)(?::-(.*?))?\}/g, (_m, name, fallback) => {
|
|
71426
71551
|
const v = input.envOverrides?.[name] ?? process.env[name];
|
|
71427
71552
|
return v != null && v !== "" ? v : fallback ?? "";
|
|
71428
71553
|
});
|
|
71429
|
-
if (out.startsWith("~/")) out = path27.join(
|
|
71554
|
+
if (out.startsWith("~/")) out = path27.join(os13.homedir(), out.slice(2));
|
|
71430
71555
|
const now = /* @__PURE__ */ new Date();
|
|
71431
71556
|
const workspaceRaw = input.workspace ?? "";
|
|
71432
71557
|
let workspaceResolved = workspaceRaw;
|
|
@@ -71469,7 +71594,7 @@ ${cleanBody}`;
|
|
|
71469
71594
|
function scanProjectsRootForSessionFile(template, input, requestedSessionId) {
|
|
71470
71595
|
if (!requestedSessionId) return null;
|
|
71471
71596
|
let head = template;
|
|
71472
|
-
if (head.startsWith("~/") || head === "~") head = path27.join(
|
|
71597
|
+
if (head.startsWith("~/") || head === "~") head = path27.join(os13.homedir(), head.slice(2));
|
|
71473
71598
|
const base = staticTemplateBase(head);
|
|
71474
71599
|
if (!base) return null;
|
|
71475
71600
|
let baseStat = null;
|
|
@@ -71618,13 +71743,13 @@ ${cleanBody}`;
|
|
|
71618
71743
|
if (!template) return null;
|
|
71619
71744
|
let out = template;
|
|
71620
71745
|
if (out.startsWith("~/") || out === "~") {
|
|
71621
|
-
out = path27.join(
|
|
71746
|
+
out = path27.join(os13.homedir(), out.slice(2));
|
|
71622
71747
|
}
|
|
71623
71748
|
out = out.replace(/\$\{([A-Z_][A-Z0-9_]*)(?::-(.*?))?\}/g, (_m, name, fallback) => {
|
|
71624
71749
|
const v = input.envOverrides?.[name] ?? process.env[name];
|
|
71625
71750
|
return v != null && v !== "" ? v : fallback ?? "";
|
|
71626
71751
|
});
|
|
71627
|
-
if (out.startsWith("~/")) out = path27.join(
|
|
71752
|
+
if (out.startsWith("~/")) out = path27.join(os13.homedir(), out.slice(2));
|
|
71628
71753
|
const workspaceRaw = input.workspace ?? "";
|
|
71629
71754
|
let workspaceResolved = workspaceRaw;
|
|
71630
71755
|
if (workspaceRaw) {
|
|
@@ -72083,7 +72208,7 @@ ${cleanBody}`;
|
|
|
72083
72208
|
return t.negate ? !result : result;
|
|
72084
72209
|
}
|
|
72085
72210
|
var fs222;
|
|
72086
|
-
var
|
|
72211
|
+
var os13;
|
|
72087
72212
|
var path27;
|
|
72088
72213
|
var UUID_RE;
|
|
72089
72214
|
var DEFAULT_TOOL_CALL_TYPES;
|
|
@@ -72092,7 +72217,7 @@ ${cleanBody}`;
|
|
|
72092
72217
|
"src/providers/spec/native-history-executor.ts"() {
|
|
72093
72218
|
"use strict";
|
|
72094
72219
|
fs222 = __toESM2(require("fs"));
|
|
72095
|
-
|
|
72220
|
+
os13 = __toESM2(require("os"));
|
|
72096
72221
|
path27 = __toESM2(require("path"));
|
|
72097
72222
|
init_logger();
|
|
72098
72223
|
init_load_better_sqlite3();
|
|
@@ -72585,7 +72710,7 @@ ${cleanBody}`;
|
|
|
72585
72710
|
cachedPty = void 0;
|
|
72586
72711
|
requireNodePty = loader2 ?? (() => require("node-pty"));
|
|
72587
72712
|
}
|
|
72588
|
-
var
|
|
72713
|
+
var os14;
|
|
72589
72714
|
var cachedPty;
|
|
72590
72715
|
var requireNodePty;
|
|
72591
72716
|
var NodePtyRuntimeTransport;
|
|
@@ -72593,7 +72718,7 @@ ${cleanBody}`;
|
|
|
72593
72718
|
var init_pty_transport = __esm2({
|
|
72594
72719
|
"src/cli-adapters/pty-transport.ts"() {
|
|
72595
72720
|
"use strict";
|
|
72596
|
-
|
|
72721
|
+
os14 = __toESM2(require("os"));
|
|
72597
72722
|
init_spawn_env();
|
|
72598
72723
|
init_resolve_executable();
|
|
72599
72724
|
requireNodePty = () => require("node-pty");
|
|
@@ -72634,9 +72759,9 @@ ${cleanBody}`;
|
|
|
72634
72759
|
try {
|
|
72635
72760
|
const fs56 = require("fs");
|
|
72636
72761
|
const stat2 = fs56.statSync(cwd);
|
|
72637
|
-
if (!stat2.isDirectory()) cwd =
|
|
72762
|
+
if (!stat2.isDirectory()) cwd = os14.homedir();
|
|
72638
72763
|
} catch {
|
|
72639
|
-
cwd =
|
|
72764
|
+
cwd = os14.homedir();
|
|
72640
72765
|
}
|
|
72641
72766
|
}
|
|
72642
72767
|
const handle = pty.spawn(resolveWin32Executable(command), args, {
|
|
@@ -75311,7 +75436,7 @@ ${cont}` : cont;
|
|
|
75311
75436
|
function resolveCliSpawnPlanFromParts(options) {
|
|
75312
75437
|
const { command, baseArgs, shell, baseEnv, workingDir, extraArgs, extraEnv, geometry, diagnosticCliType, diagnosticProviderVersion } = options;
|
|
75313
75438
|
const binaryPath = findBinary(command);
|
|
75314
|
-
const isWin =
|
|
75439
|
+
const isWin = os15.platform() === "win32";
|
|
75315
75440
|
const allArgs = [...baseArgs ?? [], ...extraArgs ?? []].map(
|
|
75316
75441
|
(arg) => typeof arg === "string" ? arg.replace(/\{\{workingDir\}\}/g, workingDir) : arg
|
|
75317
75442
|
);
|
|
@@ -75399,13 +75524,13 @@ ${cont}` : cont;
|
|
|
75399
75524
|
}
|
|
75400
75525
|
return "";
|
|
75401
75526
|
}
|
|
75402
|
-
var
|
|
75527
|
+
var os15;
|
|
75403
75528
|
var path28;
|
|
75404
75529
|
var import_session_host_core7;
|
|
75405
75530
|
var init_provider_cli_runtime = __esm2({
|
|
75406
75531
|
"src/cli-adapters/provider-cli-runtime.ts"() {
|
|
75407
75532
|
"use strict";
|
|
75408
|
-
|
|
75533
|
+
os15 = __toESM2(require("os"));
|
|
75409
75534
|
path28 = __toESM2(require("path"));
|
|
75410
75535
|
init_logger();
|
|
75411
75536
|
import_session_host_core7 = require_dist();
|
|
@@ -75480,16 +75605,19 @@ ${cont}` : cont;
|
|
|
75480
75605
|
missingBackgroundSourceWarned.add(cliType);
|
|
75481
75606
|
LOG2.warn("CLI", `[${cliType}] background-task tracking declared but nativeHistory.source missing after provider resolve; background detection inactive`);
|
|
75482
75607
|
}
|
|
75483
|
-
var
|
|
75608
|
+
var os16;
|
|
75484
75609
|
var import_crypto11;
|
|
75485
75610
|
var import_session_host_core8;
|
|
75486
75611
|
var missingBackgroundSourceWarned;
|
|
75487
75612
|
var FORCE_SUBMIT_SETTLE_MS;
|
|
75613
|
+
var WIN32_INJECT_ENTER_MAX_RETRIES;
|
|
75614
|
+
var WIN32_INJECT_ENTER_RETRY_DELAY_MS;
|
|
75615
|
+
var WIN32_INJECT_COMPOSER_TAIL_LINES;
|
|
75488
75616
|
var ProviderCliAdapter;
|
|
75489
75617
|
var init_provider_cli_adapter = __esm2({
|
|
75490
75618
|
"src/cli-adapters/provider-cli-adapter.ts"() {
|
|
75491
75619
|
"use strict";
|
|
75492
|
-
|
|
75620
|
+
os16 = __toESM2(require("os"));
|
|
75493
75621
|
import_crypto11 = require("crypto");
|
|
75494
75622
|
init_interactive_prompt();
|
|
75495
75623
|
init_kimi_pending_question();
|
|
@@ -75511,6 +75639,9 @@ ${cont}` : cont;
|
|
|
75511
75639
|
init_provider_cli_shared();
|
|
75512
75640
|
missingBackgroundSourceWarned = /* @__PURE__ */ new Set();
|
|
75513
75641
|
FORCE_SUBMIT_SETTLE_MS = 150;
|
|
75642
|
+
WIN32_INJECT_ENTER_MAX_RETRIES = 2;
|
|
75643
|
+
WIN32_INJECT_ENTER_RETRY_DELAY_MS = 300;
|
|
75644
|
+
WIN32_INJECT_COMPOSER_TAIL_LINES = 8;
|
|
75514
75645
|
ProviderCliAdapter = class _ProviderCliAdapter {
|
|
75515
75646
|
constructor(provider, workingDir, extraArgs = [], extraEnv = {}, transportFactory = new NodePtyTransportFactory(), owningSessionId) {
|
|
75516
75647
|
this.extraArgs = extraArgs;
|
|
@@ -75521,7 +75652,7 @@ ${cont}` : cont;
|
|
|
75521
75652
|
this.transportFactory = transportFactory;
|
|
75522
75653
|
this.cliType = provider.type;
|
|
75523
75654
|
this.cliName = provider.name;
|
|
75524
|
-
this.workingDir = workingDir.startsWith("~") ? workingDir.replace(/^~/,
|
|
75655
|
+
this.workingDir = workingDir.startsWith("~") ? workingDir.replace(/^~/, os16.homedir()) : workingDir;
|
|
75525
75656
|
const resolvedConfig = resolveCliAdapterConfig(provider);
|
|
75526
75657
|
this.timeouts = resolvedConfig.timeouts;
|
|
75527
75658
|
this.approvalKeys = resolvedConfig.approvalKeys;
|
|
@@ -75658,6 +75789,9 @@ ${cont}` : cont;
|
|
|
75658
75789
|
pendingOutboundStaleTimer = null;
|
|
75659
75790
|
// Submit retry timer — PTY-level, not state machine
|
|
75660
75791
|
submitRetryTimer = null;
|
|
75792
|
+
// WIN32-INJECT-ENTER-RETRY: pending bare-ENTER resend for a mesh_send_keys
|
|
75793
|
+
// injection whose submit may have been swallowed by win32 ConPTY.
|
|
75794
|
+
injectEnterRetryTimer = null;
|
|
75661
75795
|
// PTY-WRITE-SERIALIZE: a single per-session tail promise that serializes every
|
|
75662
75796
|
// PTY write. Each writeToPty() call chains its actual write after the previous
|
|
75663
75797
|
// one and returns a promise that resolves only after ITS write completes, so
|
|
@@ -76217,6 +76351,10 @@ ${lastSnapshot}`;
|
|
|
76217
76351
|
clearTimeout(this.submitRetryTimer);
|
|
76218
76352
|
this.submitRetryTimer = null;
|
|
76219
76353
|
}
|
|
76354
|
+
if (this.injectEnterRetryTimer) {
|
|
76355
|
+
clearTimeout(this.injectEnterRetryTimer);
|
|
76356
|
+
this.injectEnterRetryTimer = null;
|
|
76357
|
+
}
|
|
76220
76358
|
if (this.pendingOutputParseTimer) {
|
|
76221
76359
|
clearTimeout(this.pendingOutputParseTimer);
|
|
76222
76360
|
this.pendingOutputParseTimer = null;
|
|
@@ -77031,6 +77169,10 @@ ${lastSnapshot}`;
|
|
|
77031
77169
|
clearTimeout(this.submitRetryTimer);
|
|
77032
77170
|
this.submitRetryTimer = null;
|
|
77033
77171
|
}
|
|
77172
|
+
if (this.injectEnterRetryTimer) {
|
|
77173
|
+
clearTimeout(this.injectEnterRetryTimer);
|
|
77174
|
+
this.injectEnterRetryTimer = null;
|
|
77175
|
+
}
|
|
77034
77176
|
this.engine.onTurnStarted(turnScope);
|
|
77035
77177
|
this.engine.submitRetryPromptSnippet = extractPromptRetrySnippet(text);
|
|
77036
77178
|
const normalizedPromptSnippet = normalizePromptText(this.engine.submitRetryPromptSnippet);
|
|
@@ -77594,7 +77736,17 @@ ${lastSnapshot}`;
|
|
|
77594
77736
|
LOG2.warn("CLI", `[${this.cliType}] send_keys refused (actionable_modal): keys=${encoded.keys.join(",")} \u2014 use mesh_approve`);
|
|
77595
77737
|
return { ok: false, refused: "actionable_modal", keys: encoded.keys, hasDestructive: encoded.hasDestructive };
|
|
77596
77738
|
}
|
|
77739
|
+
if (this.injectEnterRetryTimer) {
|
|
77740
|
+
clearTimeout(this.injectEnterRetryTimer);
|
|
77741
|
+
this.injectEnterRetryTimer = null;
|
|
77742
|
+
}
|
|
77597
77743
|
await this.writeToPty(encoded.sequence);
|
|
77744
|
+
if (process.platform === "win32" && encoded.submits) {
|
|
77745
|
+
const snippet2 = extractPromptRetrySnippet(
|
|
77746
|
+
items.map((it) => "text" in it ? it.text : "").join("\n")
|
|
77747
|
+
);
|
|
77748
|
+
if (snippet2) this.scheduleWin32InjectEnterRetry(snippet2, 1);
|
|
77749
|
+
}
|
|
77598
77750
|
LOG2.info("CLI", `[${this.cliType}] send_keys injected keys=${encoded.keys.join(",") || "(text-only)"} bytes=${Buffer.byteLength(encoded.sequence, "utf8")} destructive=${encoded.hasDestructive}`);
|
|
77599
77751
|
return {
|
|
77600
77752
|
ok: true,
|
|
@@ -77611,6 +77763,30 @@ ${lastSnapshot}`;
|
|
|
77611
77763
|
const str2 = Buffer.isBuffer(data) ? data.toString("utf8") : data;
|
|
77612
77764
|
await this.writeToPty(str2);
|
|
77613
77765
|
}
|
|
77766
|
+
/**
|
|
77767
|
+
* WIN32-INJECT-ENTER-RETRY: resend the bare submit key while the injected
|
|
77768
|
+
* text still stands in the composer (bottom viewport lines). Stops the
|
|
77769
|
+
* instant the text leaves that region — proof the submit was consumed —
|
|
77770
|
+
* so a delayed (not lost) original ENTER is never doubled. Bounded by
|
|
77771
|
+
* WIN32_INJECT_ENTER_MAX_RETRIES; see the constants' comment for the
|
|
77772
|
+
* rationale. Never logs the snippet (it is user text).
|
|
77773
|
+
*/
|
|
77774
|
+
scheduleWin32InjectEnterRetry(snippet2, attempt) {
|
|
77775
|
+
this.injectEnterRetryTimer = setTimeout(() => {
|
|
77776
|
+
this.injectEnterRetryTimer = null;
|
|
77777
|
+
if (!this.ptyProcess) return;
|
|
77778
|
+
const screenLines = this.terminalScreen.getText().split("\n");
|
|
77779
|
+
const composerRegion = screenLines.slice(-WIN32_INJECT_COMPOSER_TAIL_LINES).join("\n");
|
|
77780
|
+
if (!promptLikelyVisible(composerRegion, snippet2)) return;
|
|
77781
|
+
LOG2.info("CLI", `[${this.cliType}] send_keys ENTER retry (attempt ${attempt}/${WIN32_INJECT_ENTER_MAX_RETRIES}): injected text still in composer`);
|
|
77782
|
+
void this.writeToPty(MESH_SEND_KEY_ENCODING.ENTER).catch((error48) => {
|
|
77783
|
+
LOG2.warn("CLI", `[${this.cliType}] send_keys ENTER retry write failed: ${error48?.message || error48}`);
|
|
77784
|
+
});
|
|
77785
|
+
if (attempt < WIN32_INJECT_ENTER_MAX_RETRIES) {
|
|
77786
|
+
this.scheduleWin32InjectEnterRetry(snippet2, attempt + 1);
|
|
77787
|
+
}
|
|
77788
|
+
}, WIN32_INJECT_ENTER_RETRY_DELAY_MS);
|
|
77789
|
+
}
|
|
77614
77790
|
resolveModal(buttonIndex) {
|
|
77615
77791
|
this.engine.resolveModal(buttonIndex);
|
|
77616
77792
|
}
|
|
@@ -80156,7 +80332,7 @@ ${lastSnapshot}`;
|
|
|
80156
80332
|
init_git_worktree();
|
|
80157
80333
|
init_config();
|
|
80158
80334
|
init_config_dir();
|
|
80159
|
-
var
|
|
80335
|
+
var os62 = __toESM2(require("os"));
|
|
80160
80336
|
var path12 = __toESM2(require("path"));
|
|
80161
80337
|
var import_session_host_core22 = require_dist();
|
|
80162
80338
|
init_config_dir();
|
|
@@ -80200,7 +80376,7 @@ ${lastSnapshot}`;
|
|
|
80200
80376
|
var cached22 = null;
|
|
80201
80377
|
function resolveInstanceContext(options = {}) {
|
|
80202
80378
|
const env2 = options.env ?? process.env;
|
|
80203
|
-
const homeDir = options.homeDir ??
|
|
80379
|
+
const homeDir = options.homeDir ?? os62.homedir();
|
|
80204
80380
|
const envDir = typeof env2.ADHDEV_CONFIG_DIR === "string" ? env2.ADHDEV_CONFIG_DIR.trim() : "";
|
|
80205
80381
|
const explicitDir = typeof options.configDir === "string" ? options.configDir.trim() : "";
|
|
80206
80382
|
if (explicitDir && envDir && (0, import_session_host_core22.canonicalizeInstancePath)(explicitDir) !== (0, import_session_host_core22.canonicalizeInstancePath)(envDir)) {
|
|
@@ -80221,7 +80397,7 @@ ${lastSnapshot}`;
|
|
|
80221
80397
|
}
|
|
80222
80398
|
function getProcessInstanceContext(options = {}) {
|
|
80223
80399
|
const envDir = typeof process.env.ADHDEV_CONFIG_DIR === "string" ? process.env.ADHDEV_CONFIG_DIR.trim() : "";
|
|
80224
|
-
const key2 = `${envDir}|${
|
|
80400
|
+
const key2 = `${envDir}|${os62.homedir()}|${options.standalone ? "standalone" : "daemon"}`;
|
|
80225
80401
|
if (!cached22 || cached22.key !== key2) {
|
|
80226
80402
|
cached22 = { key: key2, context: resolveInstanceContext({ standalone: options.standalone }) };
|
|
80227
80403
|
}
|
|
@@ -81525,17 +81701,17 @@ ${lastSnapshot}`;
|
|
|
81525
81701
|
return null;
|
|
81526
81702
|
}
|
|
81527
81703
|
async function detectIDEs(providerLoader) {
|
|
81528
|
-
const
|
|
81704
|
+
const os29 = (0, import_os3.platform)();
|
|
81529
81705
|
const results = [];
|
|
81530
81706
|
for (const def of getMergedDefinitions()) {
|
|
81531
81707
|
const cliPath = findCliCommand(providerLoader?.getIdeCliCommand(def.id, def.cli) || def.cli);
|
|
81532
|
-
const appPath = checkPathExists(providerLoader?.getIdePathCandidates(def.id, def.paths[
|
|
81708
|
+
const appPath = checkPathExists(providerLoader?.getIdePathCandidates(def.id, def.paths[os29] || []) || []);
|
|
81533
81709
|
let resolvedCli = cliPath;
|
|
81534
|
-
if (!resolvedCli && appPath &&
|
|
81710
|
+
if (!resolvedCli && appPath && os29 === "darwin") {
|
|
81535
81711
|
const bundledCli = `${appPath}/Contents/Resources/app/bin/${def.cli}`;
|
|
81536
81712
|
if ((0, import_fs17.existsSync)(bundledCli)) resolvedCli = bundledCli;
|
|
81537
81713
|
}
|
|
81538
|
-
if (!resolvedCli && appPath &&
|
|
81714
|
+
if (!resolvedCli && appPath && os29 === "win32") {
|
|
81539
81715
|
const { dirname: dirname23 } = await import("path");
|
|
81540
81716
|
const appDir = dirname23(appPath);
|
|
81541
81717
|
const candidates = [
|
|
@@ -81552,7 +81728,7 @@ ${lastSnapshot}`;
|
|
|
81552
81728
|
}
|
|
81553
81729
|
}
|
|
81554
81730
|
}
|
|
81555
|
-
const installed =
|
|
81731
|
+
const installed = os29 === "darwin" ? !!(resolvedCli || appPath) : !!resolvedCli;
|
|
81556
81732
|
const version2 = null;
|
|
81557
81733
|
results.push({
|
|
81558
81734
|
id: def.id,
|
|
@@ -88255,7 +88431,7 @@ ${effect.notification.body || ""}`.trim();
|
|
|
88255
88431
|
}
|
|
88256
88432
|
var fs15 = __toESM2(require("fs"));
|
|
88257
88433
|
var path232 = __toESM2(require("path"));
|
|
88258
|
-
var
|
|
88434
|
+
var os11 = __toESM2(require("os"));
|
|
88259
88435
|
var KEY_TO_VK = {
|
|
88260
88436
|
Backspace: 8,
|
|
88261
88437
|
Tab: 9,
|
|
@@ -88509,7 +88685,7 @@ ${effect.notification.body || ""}`.trim();
|
|
|
88509
88685
|
function resolveSafePath(requestedPath) {
|
|
88510
88686
|
const rawPath = typeof requestedPath === "string" ? requestedPath.trim() : "";
|
|
88511
88687
|
const inputPath = rawPath || ".";
|
|
88512
|
-
const home =
|
|
88688
|
+
const home = os11.homedir();
|
|
88513
88689
|
if (inputPath.startsWith("~")) {
|
|
88514
88690
|
return path232.resolve(path232.join(home, inputPath.slice(1)));
|
|
88515
88691
|
}
|
|
@@ -90914,7 +91090,7 @@ ${effect.notification.body || ""}`.trim();
|
|
|
90914
91090
|
var import_child_process8 = require("child_process");
|
|
90915
91091
|
var import_child_process9 = require("child_process");
|
|
90916
91092
|
var fs20 = __toESM2(require("fs"));
|
|
90917
|
-
var
|
|
91093
|
+
var os12 = __toESM2(require("os"));
|
|
90918
91094
|
var path26 = __toESM2(require("path"));
|
|
90919
91095
|
var import_child_process7 = require("child_process");
|
|
90920
91096
|
var fs19 = __toESM2(require("fs"));
|
|
@@ -91781,7 +91957,7 @@ exec "${portableNode}" "${cliEntry}" "$@"
|
|
|
91781
91957
|
const packageRoot = findCurrentPackageRoot(options.currentCliPath || process.argv[1], options.packageName);
|
|
91782
91958
|
const npmInvocation = resolveSiblingNpmInvocation(options.nodeExecutable || process.execPath, options.platform);
|
|
91783
91959
|
const platform10 = options.platform || process.platform;
|
|
91784
|
-
const homeDir = options.homeDir ||
|
|
91960
|
+
const homeDir = options.homeDir || os12.homedir();
|
|
91785
91961
|
const instanceDir = options.instanceDir || resolveInstanceDir();
|
|
91786
91962
|
let installPrefix = packageRoot ? resolveInstallPrefixFromPackageRoot(packageRoot, options.packageName) : null;
|
|
91787
91963
|
if (platform10 === "win32" && isPortableNode22Prefix(installPrefix, homeDir, instanceDir)) {
|
|
@@ -92193,12 +92369,12 @@ ${marker}`,
|
|
|
92193
92369
|
}
|
|
92194
92370
|
const instanceDir = resolveInstanceDir();
|
|
92195
92371
|
const windowsInstallerLayout = resolveWindowsInstallerLayout({
|
|
92196
|
-
homeDir:
|
|
92372
|
+
homeDir: os12.homedir(),
|
|
92197
92373
|
installPrefix: installCommand.surface.installPrefix,
|
|
92198
92374
|
instanceDir
|
|
92199
92375
|
});
|
|
92200
92376
|
if (windowsInstallerLayout) {
|
|
92201
|
-
const portableNode = findPortableNode22(
|
|
92377
|
+
const portableNode = findPortableNode22(os12.homedir(), process.execPath, instanceDir);
|
|
92202
92378
|
if (!portableNode) {
|
|
92203
92379
|
throw new Error("installer-managed Windows update requires the portable Node.js 22 runtime");
|
|
92204
92380
|
}
|
|
@@ -93335,7 +93511,7 @@ ${marker}`,
|
|
|
93335
93511
|
})
|
|
93336
93512
|
);
|
|
93337
93513
|
init_dist();
|
|
93338
|
-
var
|
|
93514
|
+
var os21 = __toESM2(require("os"));
|
|
93339
93515
|
var path35 = __toESM2(require("path"));
|
|
93340
93516
|
var crypto6 = __toESM2(require("crypto"));
|
|
93341
93517
|
var import_fs18 = require("fs");
|
|
@@ -93429,7 +93605,7 @@ ${marker}`,
|
|
|
93429
93605
|
}
|
|
93430
93606
|
}
|
|
93431
93607
|
init_summary_metadata();
|
|
93432
|
-
var
|
|
93608
|
+
var os20 = __toESM2(require("os"));
|
|
93433
93609
|
var crypto5 = __toESM2(require("crypto"));
|
|
93434
93610
|
var fs31 = __toESM2(require("fs"));
|
|
93435
93611
|
init_contracts2();
|
|
@@ -93569,7 +93745,7 @@ ${marker}`,
|
|
|
93569
93745
|
var path31 = __toESM2(require("path"));
|
|
93570
93746
|
init_provider_cli_adapter();
|
|
93571
93747
|
var fs25 = __toESM2(require("fs"));
|
|
93572
|
-
var
|
|
93748
|
+
var os18 = __toESM2(require("os"));
|
|
93573
93749
|
var path30 = __toESM2(require("path"));
|
|
93574
93750
|
init_terminal_screen();
|
|
93575
93751
|
var import_session_host_core9 = require_dist();
|
|
@@ -93748,12 +93924,12 @@ ${marker}`,
|
|
|
93748
93924
|
init_fsm_types();
|
|
93749
93925
|
init_fsm_loader();
|
|
93750
93926
|
var fs24 = __toESM2(require("fs"));
|
|
93751
|
-
var
|
|
93927
|
+
var os17 = __toESM2(require("os"));
|
|
93752
93928
|
var path29 = __toESM2(require("path"));
|
|
93753
93929
|
init_logger();
|
|
93754
93930
|
function expandHome2(p) {
|
|
93755
|
-
if (p === "~") return
|
|
93756
|
-
if (p.startsWith("~/")) return path29.join(
|
|
93931
|
+
if (p === "~") return os17.homedir();
|
|
93932
|
+
if (p.startsWith("~/")) return path29.join(os17.homedir(), p.slice(2));
|
|
93757
93933
|
return p;
|
|
93758
93934
|
}
|
|
93759
93935
|
function realWorkspacePath(workingDir) {
|
|
@@ -94589,7 +94765,7 @@ ${marker}`,
|
|
|
94589
94765
|
}
|
|
94590
94766
|
fireDelegate(d) {
|
|
94591
94767
|
const ev = this.currentEval;
|
|
94592
|
-
const task = d.task_template.replace(/\{node\}/g,
|
|
94768
|
+
const task = d.task_template.replace(/\{node\}/g, os18.hostname()).replace(/\{state\.label\}/g, ev?.state.label ?? "").replace(/\{state\.title\}/g, ev?.state.title ?? "").replace(/\{duration_ms\}/g, String(d.after_duration_ms ?? 0));
|
|
94593
94769
|
this.emit({ kind: "delegate", id: d.id, task });
|
|
94594
94770
|
}
|
|
94595
94771
|
// ────────────────────────────────────────────────────────────────────
|
|
@@ -94983,7 +95159,7 @@ ${marker}`,
|
|
|
94983
95159
|
const ctl = (this.spec.control_bar ?? []).find((c) => c.action.type === "attach_image");
|
|
94984
95160
|
if (!ctl || ctl.action.type !== "attach_image") return;
|
|
94985
95161
|
const ext = guessExt(mime);
|
|
94986
|
-
const tmp = path30.join(
|
|
95162
|
+
const tmp = path30.join(os18.tmpdir(), `adhdev-attach-${Date.now()}${ext}`);
|
|
94987
95163
|
try {
|
|
94988
95164
|
fs25.writeFileSync(tmp, Buffer.from(blob, "base64"));
|
|
94989
95165
|
} catch {
|
|
@@ -96282,7 +96458,7 @@ ${marker}`,
|
|
|
96282
96458
|
init_transcript_claim_registry();
|
|
96283
96459
|
init_chat_message_normalization();
|
|
96284
96460
|
init_working_dir();
|
|
96285
|
-
var
|
|
96461
|
+
var os19 = __toESM2(require("os"));
|
|
96286
96462
|
var path322 = __toESM2(require("path"));
|
|
96287
96463
|
var crypto4 = __toESM2(require("crypto"));
|
|
96288
96464
|
var fs28 = __toESM2(require("fs"));
|
|
@@ -96353,7 +96529,7 @@ ${marker}`,
|
|
|
96353
96529
|
const promptParts = [];
|
|
96354
96530
|
const imageRefs = [];
|
|
96355
96531
|
const resourceRefs = [];
|
|
96356
|
-
const materializeDir = options.materializeDir || path322.join(
|
|
96532
|
+
const materializeDir = options.materializeDir || path322.join(os19.tmpdir(), "adhdev-input-media");
|
|
96357
96533
|
input.parts.forEach((part, index) => {
|
|
96358
96534
|
if (part.type === "text" && part.text.trim()) {
|
|
96359
96535
|
promptParts.push(part.text.trim());
|
|
@@ -98563,7 +98739,7 @@ ${buttons.join("\n")}`;
|
|
|
98563
98739
|
* Replaces the previously duplicated probeOpenCode/Codex/Goose functions.
|
|
98564
98740
|
*/
|
|
98565
98741
|
probeSessionIdFromConfig(probe) {
|
|
98566
|
-
const resolvedDbPath = probe.dbPath.replace(/^~/,
|
|
98742
|
+
const resolvedDbPath = probe.dbPath.replace(/^~/, os20.homedir());
|
|
98567
98743
|
const now = Date.now();
|
|
98568
98744
|
if (this.sqliteProbeCache.missingUntil > now) return null;
|
|
98569
98745
|
if (!fs31.existsSync(resolvedDbPath)) {
|
|
@@ -102126,7 +102302,7 @@ ${rawInput}` : rawInput;
|
|
|
102126
102302
|
}
|
|
102127
102303
|
function expandExecutable(command) {
|
|
102128
102304
|
const trimmed = command.trim();
|
|
102129
|
-
return trimmed.startsWith("~") ? path35.join(
|
|
102305
|
+
return trimmed.startsWith("~") ? path35.join(os21.homedir(), trimmed.slice(1)) : trimmed;
|
|
102130
102306
|
}
|
|
102131
102307
|
function commandExists(command) {
|
|
102132
102308
|
const trimmed = command.trim();
|
|
@@ -102276,9 +102452,9 @@ ${rawInput}` : rawInput;
|
|
|
102276
102452
|
return false;
|
|
102277
102453
|
}
|
|
102278
102454
|
function ensureEmptyDelegatedMcpConfig(workspace) {
|
|
102279
|
-
const baseDir = path35.join(
|
|
102455
|
+
const baseDir = path35.join(os21.tmpdir(), "adhdev-delegated-agent-empty-mcp");
|
|
102280
102456
|
(0, import_fs18.mkdirSync)(baseDir, { recursive: true });
|
|
102281
|
-
const workspaceHash = shortHash(path35.resolve(workspace ||
|
|
102457
|
+
const workspaceHash = shortHash(path35.resolve(workspace || os21.tmpdir()));
|
|
102282
102458
|
const filePath = path35.join(baseDir, `${workspaceHash}.json`);
|
|
102283
102459
|
(0, import_fs18.writeFileSync)(filePath, JSON.stringify({ mcpServers: {} }, null, 2), "utf-8");
|
|
102284
102460
|
return filePath;
|
|
@@ -102673,7 +102849,7 @@ ${rawInput}` : rawInput;
|
|
|
102673
102849
|
async startSession(cliType, workingDir, cliArgs, initialModel, options) {
|
|
102674
102850
|
const trimmed = (workingDir || "").trim();
|
|
102675
102851
|
if (!trimmed) throw new Error("working directory required");
|
|
102676
|
-
const resolvedDir = trimmed.startsWith("~") ? trimmed.replace(/^~/,
|
|
102852
|
+
const resolvedDir = trimmed.startsWith("~") ? trimmed.replace(/^~/, os21.homedir()) : path35.resolve(trimmed);
|
|
102677
102853
|
const normalizedType = this.providerLoader.resolveAlias(cliType);
|
|
102678
102854
|
const rawProvider = this.providerLoader.getByAlias(cliType);
|
|
102679
102855
|
const provider = rawProvider ? this.providerLoader.resolve(normalizedType) || rawProvider : void 0;
|
|
@@ -103700,7 +103876,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
103700
103876
|
};
|
|
103701
103877
|
var import_child_process12 = require("child_process");
|
|
103702
103878
|
var net3 = __toESM2(require("net"));
|
|
103703
|
-
var
|
|
103879
|
+
var os25 = __toESM2(require("os"));
|
|
103704
103880
|
var path46 = __toESM2(require("path"));
|
|
103705
103881
|
var fs41 = __toESM2(require("fs"));
|
|
103706
103882
|
var path45 = __toESM2(require("path"));
|
|
@@ -104170,7 +104346,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
104170
104346
|
init_config();
|
|
104171
104347
|
init_native_history_executor();
|
|
104172
104348
|
var fs36 = __toESM2(require("fs"));
|
|
104173
|
-
var
|
|
104349
|
+
var os24 = __toESM2(require("os"));
|
|
104174
104350
|
var path40 = __toESM2(require("path"));
|
|
104175
104351
|
var fs322 = __toESM2(require("fs"));
|
|
104176
104352
|
var path36 = __toESM2(require("path"));
|
|
@@ -104706,7 +104882,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
104706
104882
|
}
|
|
104707
104883
|
var fs34 = __toESM2(require("fs"));
|
|
104708
104884
|
var path38 = __toESM2(require("path"));
|
|
104709
|
-
var
|
|
104885
|
+
var os222 = __toESM2(require("os"));
|
|
104710
104886
|
init_load_better_sqlite3();
|
|
104711
104887
|
init_logger();
|
|
104712
104888
|
function extractTimestampValue3(value) {
|
|
@@ -104730,7 +104906,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
104730
104906
|
return /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(value);
|
|
104731
104907
|
}
|
|
104732
104908
|
function antigravityRoot() {
|
|
104733
|
-
return path38.join(
|
|
104909
|
+
return path38.join(os222.homedir(), ".gemini", "antigravity-cli");
|
|
104734
104910
|
}
|
|
104735
104911
|
function historyJsonlPath() {
|
|
104736
104912
|
return path38.join(antigravityRoot(), "history.jsonl");
|
|
@@ -105345,11 +105521,11 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
105345
105521
|
}
|
|
105346
105522
|
var fs35 = __toESM2(require("fs"));
|
|
105347
105523
|
var path39 = __toESM2(require("path"));
|
|
105348
|
-
var
|
|
105524
|
+
var os23 = __toESM2(require("os"));
|
|
105349
105525
|
init_load_better_sqlite3();
|
|
105350
105526
|
init_usage_normalize();
|
|
105351
|
-
var HERMES_STATE_DB = path39.join(
|
|
105352
|
-
var HERMES_LEGACY_SESSIONS_DIR = path39.join(
|
|
105527
|
+
var HERMES_STATE_DB = path39.join(os23.homedir(), ".hermes", "state.db");
|
|
105528
|
+
var HERMES_LEGACY_SESSIONS_DIR = path39.join(os23.homedir(), ".hermes", "sessions");
|
|
105353
105529
|
function statMtimeMs4(p) {
|
|
105354
105530
|
try {
|
|
105355
105531
|
return Math.floor(fs35.statSync(p).mtimeMs);
|
|
@@ -105637,7 +105813,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
105637
105813
|
}
|
|
105638
105814
|
}
|
|
105639
105815
|
function resolveClaudePath(workspace, sessionId) {
|
|
105640
|
-
const dir = path40.join(
|
|
105816
|
+
const dir = path40.join(os24.homedir(), ".claude", "projects", cwdAsDashes(workspace));
|
|
105641
105817
|
if (!fs36.existsSync(dir)) return null;
|
|
105642
105818
|
if (sessionId) {
|
|
105643
105819
|
const candidate = path40.join(dir, `${sessionId}.jsonl`);
|
|
@@ -105759,7 +105935,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
105759
105935
|
}
|
|
105760
105936
|
var AGY_SPAWN_CLAIM_GRACE_MS = 2e3;
|
|
105761
105937
|
function resolveAntigravityPath(workspace, sessionId, sessionStartedAtMs, instanceId) {
|
|
105762
|
-
const agyRoot = path40.join(
|
|
105938
|
+
const agyRoot = path40.join(os24.homedir(), ".gemini", "antigravity-cli");
|
|
105763
105939
|
const owner = antigravityOwnerToken(workspace, sessionStartedAtMs, instanceId);
|
|
105764
105940
|
if (sessionId && isUuidLikeSessionId2(sessionId)) {
|
|
105765
105941
|
const dbPath = path40.join(agyRoot, "conversations", `${sessionId}.db`);
|
|
@@ -105843,9 +106019,9 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
105843
106019
|
function resolveHermesPath(workspace, sessionId) {
|
|
105844
106020
|
void workspace;
|
|
105845
106021
|
void sessionId;
|
|
105846
|
-
const dbPath = path40.join(
|
|
106022
|
+
const dbPath = path40.join(os24.homedir(), ".hermes", "state.db");
|
|
105847
106023
|
if (fs36.existsSync(dbPath)) return dbPath;
|
|
105848
|
-
const dir = path40.join(
|
|
106024
|
+
const dir = path40.join(os24.homedir(), ".hermes", "sessions");
|
|
105849
106025
|
if (!fs36.existsSync(dir)) return null;
|
|
105850
106026
|
return newestRecentFile2(dir, /^session_.*\.json$/);
|
|
105851
106027
|
}
|
|
@@ -105871,7 +106047,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
105871
106047
|
return cwd.replace(/\//g, "-");
|
|
105872
106048
|
}
|
|
105873
106049
|
function codexSessionsRoot() {
|
|
105874
|
-
return path40.join(
|
|
106050
|
+
return path40.join(os24.homedir(), ".codex", "sessions");
|
|
105875
106051
|
}
|
|
105876
106052
|
function isUuidLikeSessionId2(sessionId) {
|
|
105877
106053
|
return /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(sessionId);
|
|
@@ -108890,7 +109066,7 @@ ${formatManifestValidationIssues2(validation2.issues)}`);
|
|
|
108890
109066
|
});
|
|
108891
109067
|
}
|
|
108892
109068
|
async function killIdeProcess(ideId) {
|
|
108893
|
-
const plat =
|
|
109069
|
+
const plat = os25.platform();
|
|
108894
109070
|
const appName = getMacAppIdentifiers()[ideId];
|
|
108895
109071
|
const winProcesses = getWinProcessNames()[ideId];
|
|
108896
109072
|
try {
|
|
@@ -108951,7 +109127,7 @@ ${formatManifestValidationIssues2(validation2.issues)}`);
|
|
|
108951
109127
|
}
|
|
108952
109128
|
}
|
|
108953
109129
|
async function isIdeRunning(ideId) {
|
|
108954
|
-
const plat =
|
|
109130
|
+
const plat = os25.platform();
|
|
108955
109131
|
try {
|
|
108956
109132
|
if (plat === "darwin") {
|
|
108957
109133
|
const appName = getMacAppIdentifiers()[ideId];
|
|
@@ -109006,7 +109182,7 @@ ${formatManifestValidationIssues2(validation2.issues)}`);
|
|
|
109006
109182
|
}
|
|
109007
109183
|
}
|
|
109008
109184
|
async function detectCurrentWorkspace(ideId) {
|
|
109009
|
-
const plat =
|
|
109185
|
+
const plat = os25.platform();
|
|
109010
109186
|
if (plat === "darwin") {
|
|
109011
109187
|
try {
|
|
109012
109188
|
const appName = getMacAppIdentifiers()[ideId];
|
|
@@ -109026,7 +109202,7 @@ ${formatManifestValidationIssues2(validation2.issues)}`);
|
|
|
109026
109202
|
const appName = appNameMap[ideId];
|
|
109027
109203
|
if (appName) {
|
|
109028
109204
|
const storagePath = path46.join(
|
|
109029
|
-
process.env.APPDATA || path46.join(
|
|
109205
|
+
process.env.APPDATA || path46.join(os25.homedir(), "AppData", "Roaming"),
|
|
109030
109206
|
appName,
|
|
109031
109207
|
"storage.json"
|
|
109032
109208
|
);
|
|
@@ -109048,7 +109224,7 @@ ${formatManifestValidationIssues2(validation2.issues)}`);
|
|
|
109048
109224
|
return void 0;
|
|
109049
109225
|
}
|
|
109050
109226
|
async function launchWithCdp(options = {}) {
|
|
109051
|
-
const platform10 =
|
|
109227
|
+
const platform10 = os25.platform();
|
|
109052
109228
|
let targetIde;
|
|
109053
109229
|
const ides = await detectIDEs(getProviderLoader());
|
|
109054
109230
|
if (options.ideId) {
|
|
@@ -109339,6 +109515,7 @@ ${formatManifestValidationIssues2(validation2.issues)}`);
|
|
|
109339
109515
|
}
|
|
109340
109516
|
};
|
|
109341
109517
|
init_dist();
|
|
109518
|
+
init_repo_mesh_types();
|
|
109342
109519
|
init_mesh_host_ownership();
|
|
109343
109520
|
init_worktree_bootstrap_config();
|
|
109344
109521
|
init_mesh_events();
|
|
@@ -109610,11 +109787,11 @@ ${formatManifestValidationIssues2(validation2.issues)}`);
|
|
|
109610
109787
|
MESH_JSON_CONFIG_LOCATIONS: MESH_JSON_CONFIG_LOCATIONS2
|
|
109611
109788
|
} = await Promise.resolve().then(() => (init_mesh_json_config(), mesh_json_config_exports));
|
|
109612
109789
|
const { mkdirSync: mkdirSync30, writeFileSync: writeFileSync30 } = await import("fs");
|
|
109613
|
-
const { dirname: dirname23, join:
|
|
109790
|
+
const { dirname: dirname23, join: join63 } = await import("path");
|
|
109614
109791
|
const scaffold = buildMeshJsonConfigScaffold2(mesh);
|
|
109615
109792
|
const scaffoldJson = serializeMeshJsonConfigScaffold2(scaffold);
|
|
109616
109793
|
const relativePath = MESH_JSON_CONFIG_LOCATIONS2[0];
|
|
109617
|
-
const absolutePath =
|
|
109794
|
+
const absolutePath = join63(workspace, relativePath);
|
|
109618
109795
|
const validation = normalizeRepoMeshDeclarativeConfig2(scaffold);
|
|
109619
109796
|
if (!validation.valid) {
|
|
109620
109797
|
return { success: false, meshId, error: `invalid mesh.json scaffold: ${validation.errors.join("; ")}` };
|
|
@@ -109721,14 +109898,14 @@ ${formatManifestValidationIssues2(validation2.issues)}`);
|
|
|
109721
109898
|
MESH_JSON_CONFIG_LOCATIONS: MESH_JSON_CONFIG_LOCATIONS2
|
|
109722
109899
|
} = await Promise.resolve().then(() => (init_mesh_json_config(), mesh_json_config_exports));
|
|
109723
109900
|
const { existsSync: existsSync62, readFileSync: readFileSync53, mkdirSync: mkdirSync30, writeFileSync: writeFileSync30 } = await import("fs");
|
|
109724
|
-
const { dirname: dirname23, join:
|
|
109901
|
+
const { dirname: dirname23, join: join63 } = await import("path");
|
|
109725
109902
|
const yaml6 = await Promise.resolve().then(() => (init_js_yaml(), js_yaml_exports));
|
|
109726
109903
|
const relativePath = MESH_JSON_CONFIG_LOCATIONS2[0];
|
|
109727
109904
|
let baseDoc = { version: 1 };
|
|
109728
|
-
let existingPath =
|
|
109905
|
+
let existingPath = join63(workspace, relativePath);
|
|
109729
109906
|
let existedAsYaml = false;
|
|
109730
109907
|
for (const relative8 of MESH_JSON_CONFIG_LOCATIONS2) {
|
|
109731
|
-
const candidate =
|
|
109908
|
+
const candidate = join63(workspace, relative8);
|
|
109732
109909
|
if (!existsSync62(candidate)) continue;
|
|
109733
109910
|
try {
|
|
109734
109911
|
const text = readFileSync53(candidate, "utf-8");
|
|
@@ -109914,6 +110091,59 @@ ${formatManifestValidationIssues2(validation2.issues)}`);
|
|
|
109914
110091
|
return { success: false, error: e.message };
|
|
109915
110092
|
}
|
|
109916
110093
|
},
|
|
110094
|
+
// ─── Quota-aware routing thresholds (PER MESH, machine-local) ───
|
|
110095
|
+
// The dedicated write path for RepoMeshPolicy.quotaRouting — previously only
|
|
110096
|
+
// reachable as a raw JSON patch through update_mesh's general `policy`
|
|
110097
|
+
// passthrough. The launch gate / fitness spread read the EFFECTIVE thresholds
|
|
110098
|
+
// through resolveQuotaRoutingPolicy, so `resolved` below is exactly what the
|
|
110099
|
+
// gate will apply; `quotaRouting` is the persisted overrides-only view
|
|
110100
|
+
// (fields equal to the defaults are never persisted — persistence economy).
|
|
110101
|
+
mesh_quota_routing_get: async (_ctx, args) => {
|
|
110102
|
+
const requestedMeshId = typeof args?.meshId === "string" ? args.meshId.trim() : "";
|
|
110103
|
+
try {
|
|
110104
|
+
const { getMeshQuotaRouting: getMeshQuotaRouting2, resolveScopedMeshId: resolveScopedMeshId2 } = await Promise.resolve().then(() => (init_mesh_config(), mesh_config_exports));
|
|
110105
|
+
const overrides = getMeshQuotaRouting2(requestedMeshId || void 0);
|
|
110106
|
+
const meshId = requestedMeshId || resolveScopedMeshId2();
|
|
110107
|
+
return {
|
|
110108
|
+
success: true,
|
|
110109
|
+
quotaRouting: overrides,
|
|
110110
|
+
resolved: resolveQuotaRoutingPolicy(overrides),
|
|
110111
|
+
defaults: DEFAULT_QUOTA_ROUTING_POLICY,
|
|
110112
|
+
scope: {
|
|
110113
|
+
kind: "mesh",
|
|
110114
|
+
storage: "machine_local",
|
|
110115
|
+
meshId: meshId ?? null,
|
|
110116
|
+
resolvedFrom: requestedMeshId ? "explicit" : meshId ? "sole_mesh" : "ambiguous",
|
|
110117
|
+
...requestedMeshId || meshId ? {} : {
|
|
110118
|
+
note: "Several meshes are configured and no meshId was given, so these are the shipped defaults, not any mesh's saved thresholds. Pass meshId."
|
|
110119
|
+
}
|
|
110120
|
+
}
|
|
110121
|
+
};
|
|
110122
|
+
} catch (e) {
|
|
110123
|
+
return { success: false, error: e.message };
|
|
110124
|
+
}
|
|
110125
|
+
},
|
|
110126
|
+
mesh_quota_routing_set: async (ctx, args) => {
|
|
110127
|
+
const requestedMeshId = typeof args?.meshId === "string" ? args.meshId.trim() : "";
|
|
110128
|
+
try {
|
|
110129
|
+
const { setMeshQuotaRouting: setMeshQuotaRouting2, getMesh: getMesh2, resolveScopedMeshId: resolveScopedMeshId2 } = await Promise.resolve().then(() => (init_mesh_config(), mesh_config_exports));
|
|
110130
|
+
const quotaRouting = setMeshQuotaRouting2(args?.quotaRouting, requestedMeshId || void 0);
|
|
110131
|
+
const meshId = requestedMeshId || resolveScopedMeshId2();
|
|
110132
|
+
if (meshId) {
|
|
110133
|
+
const fresh = getMesh2(meshId);
|
|
110134
|
+
if (fresh && ctx.getCachedInlineMesh(meshId)) ctx.inlineMeshCache.set(meshId, fresh);
|
|
110135
|
+
ctx.invalidateAggregateMeshStatus(meshId);
|
|
110136
|
+
}
|
|
110137
|
+
return {
|
|
110138
|
+
success: true,
|
|
110139
|
+
quotaRouting,
|
|
110140
|
+
resolved: resolveQuotaRoutingPolicy(quotaRouting),
|
|
110141
|
+
meshId: meshId ?? null
|
|
110142
|
+
};
|
|
110143
|
+
} catch (e) {
|
|
110144
|
+
return { success: false, error: e.message };
|
|
110145
|
+
}
|
|
110146
|
+
},
|
|
109917
110147
|
add_mesh_node: async (ctx, args) => {
|
|
109918
110148
|
const meshId = typeof args?.meshId === "string" ? args.meshId.trim() : "";
|
|
109919
110149
|
const workspace = typeof args?.workspace === "string" ? args.workspace.trim() : "";
|
|
@@ -113302,8 +113532,19 @@ ${asText(streams.stderr)}
|
|
|
113302
113532
|
});
|
|
113303
113533
|
}
|
|
113304
113534
|
function buildSubmodulePublishRequiredNextStep(entries) {
|
|
113305
|
-
const
|
|
113306
|
-
|
|
113535
|
+
const convergeable = entries.filter((entry) => entry.equivalentPublishedCommit);
|
|
113536
|
+
const publishable = entries.filter((entry) => !entry.equivalentPublishedCommit);
|
|
113537
|
+
const parts = [];
|
|
113538
|
+
if (convergeable.length > 0) {
|
|
113539
|
+
const refs = convergeable.map((entry) => `${entry.path}: ${entry.commit} \u2192 ${entry.equivalentPublishedCommit}`).join(", ");
|
|
113540
|
+
parts.push(`Converge the submodule gitlink(s) to the already-published equivalent commit(s) (${refs}): a commit with an identical tree already exists on the submodule remote main branch, so publishing the local same-content twin is wrong. Retarget the gitlink to the published commit, commit the root pointer update, then rerun mesh_refine_node.`);
|
|
113541
|
+
}
|
|
113542
|
+
if (publishable.length > 0) {
|
|
113543
|
+
const refs = publishable.map((entry) => `${entry.path}@${entry.commit}`).join(", ");
|
|
113544
|
+
parts.push(`Ask the user for explicit approval to push/publish the unreachable submodule commit(s) (${refs}) to the configured submodule remote main branch, then rerun mesh_refine_node.`);
|
|
113545
|
+
}
|
|
113546
|
+
parts.push("Do not merge the root branch until every submodule gitlink commit is reachable from submodule origin/main.");
|
|
113547
|
+
return parts.join(" ");
|
|
113307
113548
|
}
|
|
113308
113549
|
function resolveRefineryAutoPublishSubmoduleMainCommits(mesh, workspace) {
|
|
113309
113550
|
if (mesh?.policy?.allowAutoPublishSubmoduleMainCommits === true) {
|
|
@@ -113857,6 +114098,47 @@ ${mergeTreeErr?.stderr || ""}`;
|
|
|
113857
114098
|
return false;
|
|
113858
114099
|
}
|
|
113859
114100
|
}
|
|
114101
|
+
function resolveSubmoduleRemoteMainRef(submoduleRepoPath) {
|
|
114102
|
+
try {
|
|
114103
|
+
const sym = (0, import_node_child_process9.execFileSync)(GIT3, ["symbolic-ref", "-q", "refs/remotes/origin/HEAD"], { cwd: submoduleRepoPath, encoding: "utf8" }).trim();
|
|
114104
|
+
if (sym) return sym;
|
|
114105
|
+
} catch {
|
|
114106
|
+
}
|
|
114107
|
+
for (const branch of ["main", "master"]) {
|
|
114108
|
+
try {
|
|
114109
|
+
(0, import_node_child_process9.execFileSync)(GIT3, ["rev-parse", "--verify", "-q", `refs/remotes/origin/${branch}`], { cwd: submoduleRepoPath, stdio: ["ignore", "pipe", "pipe"] });
|
|
114110
|
+
return `refs/remotes/origin/${branch}`;
|
|
114111
|
+
} catch {
|
|
114112
|
+
}
|
|
114113
|
+
}
|
|
114114
|
+
return void 0;
|
|
114115
|
+
}
|
|
114116
|
+
function findEquivalentPublishedSubmoduleCommit(submoduleRepoPath, baseCommit, branchCommit, remoteRef) {
|
|
114117
|
+
try {
|
|
114118
|
+
const mergeTreeOut = (0, import_node_child_process9.execFileSync)(GIT3, ["merge-tree", "--write-tree", baseCommit, branchCommit], {
|
|
114119
|
+
cwd: submoduleRepoPath,
|
|
114120
|
+
encoding: "utf8",
|
|
114121
|
+
stdio: ["ignore", "pipe", "pipe"]
|
|
114122
|
+
});
|
|
114123
|
+
const mergedTree = mergeTreeOut.trim().split(/\s+/)[0] || "";
|
|
114124
|
+
if (!mergedTree) return void 0;
|
|
114125
|
+
const candidates = (0, import_node_child_process9.execFileSync)(GIT3, ["rev-list", "--max-count=100", remoteRef, "--not", baseCommit], {
|
|
114126
|
+
cwd: submoduleRepoPath,
|
|
114127
|
+
encoding: "utf8"
|
|
114128
|
+
}).split("\n").map((s2) => s2.trim()).filter(Boolean);
|
|
114129
|
+
for (const candidate of candidates) {
|
|
114130
|
+
try {
|
|
114131
|
+
(0, import_node_child_process9.execFileSync)(GIT3, ["merge-base", "--is-ancestor", baseCommit, candidate], { cwd: submoduleRepoPath, stdio: "ignore" });
|
|
114132
|
+
} catch {
|
|
114133
|
+
continue;
|
|
114134
|
+
}
|
|
114135
|
+
const tree = (0, import_node_child_process9.execFileSync)(GIT3, ["rev-parse", `${candidate}^{tree}`], { cwd: submoduleRepoPath, encoding: "utf8" }).trim();
|
|
114136
|
+
if (tree === mergedTree) return candidate;
|
|
114137
|
+
}
|
|
114138
|
+
} catch {
|
|
114139
|
+
}
|
|
114140
|
+
return void 0;
|
|
114141
|
+
}
|
|
113860
114142
|
function ensureSubmoduleCommitLocal(submoduleRepoPath, baseSubmoduleRepoPath, commit) {
|
|
113861
114143
|
if (!commit) return;
|
|
113862
114144
|
try {
|
|
@@ -113893,6 +114175,21 @@ ${mergeTreeErr?.stderr || ""}`;
|
|
|
113893
114175
|
continue;
|
|
113894
114176
|
}
|
|
113895
114177
|
sawDiverged = true;
|
|
114178
|
+
try {
|
|
114179
|
+
(0, import_node_child_process9.execFileSync)(GIT3, ["-c", "protocol.file.allow=always", "fetch", "-q", "origin"], { cwd: submoduleRepoPath, stdio: ["ignore", "ignore", "pipe"] });
|
|
114180
|
+
} catch {
|
|
114181
|
+
}
|
|
114182
|
+
const remoteMainRef = resolveSubmoduleRemoteMainRef(submoduleRepoPath);
|
|
114183
|
+
const publishedEquivalent = remoteMainRef ? findEquivalentPublishedSubmoduleCommit(submoduleRepoPath, baseCommit, branchCommit, remoteMainRef) : void 0;
|
|
114184
|
+
if (publishedEquivalent) {
|
|
114185
|
+
try {
|
|
114186
|
+
(0, import_node_child_process9.execFileSync)(GIT3, ["checkout", "-q", "--detach", publishedEquivalent], { cwd: submoduleRepoPath, stdio: ["ignore", "ignore", "pipe"] });
|
|
114187
|
+
} catch {
|
|
114188
|
+
}
|
|
114189
|
+
gitlinks.push({ path: path54, baseCommit, branchCommit, rebasedCommit: publishedEquivalent, action: "converged_to_published" });
|
|
114190
|
+
resolutions.push({ path: path54, baseCommit, branchCommit, rebasedCommit: publishedEquivalent });
|
|
114191
|
+
continue;
|
|
114192
|
+
}
|
|
113896
114193
|
let rebasedCommit;
|
|
113897
114194
|
try {
|
|
113898
114195
|
(0, import_node_child_process9.execFileSync)(GIT3, ["checkout", "-q", "--detach", branchCommit], { cwd: submoduleRepoPath, stdio: ["ignore", "ignore", "pipe"] });
|
|
@@ -114290,6 +114587,19 @@ ${mergeTreeErr?.stderr || ""}`;
|
|
|
114290
114587
|
await runGit3(submodulePath, ["cat-file", "-e", `${commit}^{commit}`]);
|
|
114291
114588
|
return true;
|
|
114292
114589
|
};
|
|
114590
|
+
const findEquivalentPublishedCommit = async (submodulePath, commit, remoteRef) => {
|
|
114591
|
+
try {
|
|
114592
|
+
const targetTree = (await runGit3(submodulePath, ["rev-parse", `${commit}^{tree}`])).trim();
|
|
114593
|
+
if (!targetTree) return void 0;
|
|
114594
|
+
const candidates = (await runGit3(submodulePath, ["rev-list", "--max-count=100", remoteRef])).split("\n").map((s2) => s2.trim()).filter(Boolean);
|
|
114595
|
+
for (const candidate of candidates) {
|
|
114596
|
+
const tree = (await runGit3(submodulePath, ["rev-parse", `${candidate}^{tree}`])).trim();
|
|
114597
|
+
if (tree === targetTree) return candidate;
|
|
114598
|
+
}
|
|
114599
|
+
} catch {
|
|
114600
|
+
}
|
|
114601
|
+
return void 0;
|
|
114602
|
+
};
|
|
114293
114603
|
const treeOutput = await runGit3(repoRoot, ["ls-tree", "-r", "-z", mergedTree]);
|
|
114294
114604
|
const gitlinks = treeOutput.split("\0").filter(Boolean).map((record2) => {
|
|
114295
114605
|
const match = /^160000\s+commit\s+([0-9a-f]{40})\t(.+)$/.exec(record2);
|
|
@@ -114323,11 +114633,7 @@ ${mergeTreeErr?.stderr || ""}`;
|
|
|
114323
114633
|
entry.localReachable = false;
|
|
114324
114634
|
if (options.allowAutoPublishSubmoduleMainCommits === true && options.worktreeRoot) {
|
|
114325
114635
|
try {
|
|
114326
|
-
const imported = await importCommitFromWorktreeSubmodule(
|
|
114327
|
-
submodulePath,
|
|
114328
|
-
(0, import_path17.resolve)(options.worktreeRoot, gitlink.path),
|
|
114329
|
-
gitlink.commit
|
|
114330
|
-
);
|
|
114636
|
+
const imported = await importCommitFromWorktreeSubmodule(submodulePath, (0, import_path17.resolve)(options.worktreeRoot, gitlink.path), gitlink.commit);
|
|
114331
114637
|
if (imported) {
|
|
114332
114638
|
entry.localReachable = true;
|
|
114333
114639
|
entry.importedFromWorktree = true;
|
|
@@ -114370,36 +114676,48 @@ ${mergeTreeErr?.stderr || ""}`;
|
|
|
114370
114676
|
} catch (e) {
|
|
114371
114677
|
entry.remoteReachable = false;
|
|
114372
114678
|
entry.remoteMainReachable = false;
|
|
114373
|
-
|
|
114374
|
-
|
|
114375
|
-
|
|
114376
|
-
|
|
114377
|
-
entry.
|
|
114378
|
-
|
|
114379
|
-
|
|
114380
|
-
|
|
114381
|
-
entry.
|
|
114382
|
-
|
|
114383
|
-
|
|
114384
|
-
|
|
114385
|
-
|
|
114386
|
-
|
|
114387
|
-
|
|
114388
|
-
entry.
|
|
114389
|
-
entry.
|
|
114390
|
-
|
|
114391
|
-
|
|
114392
|
-
|
|
114393
|
-
|
|
114394
|
-
|
|
114395
|
-
|
|
114396
|
-
|
|
114397
|
-
|
|
114679
|
+
const equivalentPublished = await findEquivalentPublishedCommit(submodulePath, gitlink.commit, `refs/remotes/origin/${submoduleDefaultBranch}`);
|
|
114680
|
+
if (equivalentPublished) {
|
|
114681
|
+
entry.equivalentPublishedCommit = equivalentPublished;
|
|
114682
|
+
entry.publishRequired = false;
|
|
114683
|
+
entry.error = `Submodule commit ${gitlink.commit} is not reachable from origin/${submoduleDefaultBranch}, but an equivalent commit ${equivalentPublished} (identical tree) is already published there; converge the gitlink to the published commit instead of publishing a same-content twin.`;
|
|
114684
|
+
if (options.allowAutoPublishSubmoduleMainCommits === true) {
|
|
114685
|
+
entry.autoPublishAllowed = true;
|
|
114686
|
+
entry.autoPublishAttempted = false;
|
|
114687
|
+
entry.autoPublishSkippedReason = `an equivalent commit (${equivalentPublished}) is already published on origin/${submoduleDefaultBranch}; publishing a same-content twin is wrong \u2014 converge the gitlink to the published commit instead`;
|
|
114688
|
+
}
|
|
114689
|
+
} else {
|
|
114690
|
+
entry.publishRequired = true;
|
|
114691
|
+
const details = truncateValidationOutput(e?.stderr || e?.message || String(e));
|
|
114692
|
+
entry.error = `Submodule remote main reachability check failed for origin/${submoduleDefaultBranch}: ${details}`;
|
|
114693
|
+
if (options.allowAutoPublishSubmoduleMainCommits === true && entry.localReachable === true) {
|
|
114694
|
+
entry.autoPublishAllowed = true;
|
|
114695
|
+
entry.autoPublishAttempted = true;
|
|
114696
|
+
try {
|
|
114697
|
+
const publish = await publishCommitToRemoteMain(submodulePath, gitlink.commit, submoduleDefaultBranch);
|
|
114698
|
+
entry.autoPublishRefspec = publish.refspec;
|
|
114699
|
+
entry.publishStdout = truncateValidationOutput(publish.stdout);
|
|
114700
|
+
entry.publishStderr = truncateValidationOutput(publish.stderr);
|
|
114701
|
+
entry.autoPublishSucceeded = true;
|
|
114702
|
+
await verifyRemoteMainContainsCommit(submodulePath, gitlink.commit, submoduleDefaultBranch);
|
|
114703
|
+
entry.fetchedFromOrigin = true;
|
|
114704
|
+
entry.remoteReachable = true;
|
|
114705
|
+
entry.remoteMainReachable = true;
|
|
114706
|
+
entry.autoPublishVerified = true;
|
|
114707
|
+
entry.publishRequired = false;
|
|
114708
|
+
entry.reachable = true;
|
|
114709
|
+
entry.error = void 0;
|
|
114710
|
+
} catch (publishError) {
|
|
114711
|
+
entry.autoPublishSucceeded = false;
|
|
114712
|
+
entry.autoPublishVerified = false;
|
|
114713
|
+
const publishDetails = truncateValidationOutput(publishError?.stderr || publishError?.message || String(publishError));
|
|
114714
|
+
entry.error = `Submodule auto-publish to origin/${submoduleDefaultBranch} failed or could not be verified: ${publishDetails}`;
|
|
114715
|
+
}
|
|
114716
|
+
} else if (options.allowAutoPublishSubmoduleMainCommits === true) {
|
|
114717
|
+
entry.autoPublishAllowed = true;
|
|
114718
|
+
entry.autoPublishAttempted = false;
|
|
114719
|
+
entry.autoPublishSkippedReason = entry.autoPublishSkippedReason || `candidate commit is not reachable in the source checkout or worktree submodule, so Refinery cannot push it to origin/${submoduleDefaultBranch}`;
|
|
114398
114720
|
}
|
|
114399
|
-
} else if (options.allowAutoPublishSubmoduleMainCommits === true) {
|
|
114400
|
-
entry.autoPublishAllowed = true;
|
|
114401
|
-
entry.autoPublishAttempted = false;
|
|
114402
|
-
entry.autoPublishSkippedReason = entry.autoPublishSkippedReason || `candidate commit is not reachable in the source checkout or worktree submodule, so Refinery cannot push it to origin/${submoduleDefaultBranch}`;
|
|
114403
114721
|
}
|
|
114404
114722
|
}
|
|
114405
114723
|
} catch (e) {
|
|
@@ -114968,18 +115286,49 @@ ${mergeTreeErr?.stderr || ""}`;
|
|
|
114968
115286
|
const resolved = await refineResolveRefsStage(self, meshId, nodeId, args, refineStages);
|
|
114969
115287
|
if (resolved.kind === "terminal") return resolved.result;
|
|
114970
115288
|
const ctx = resolved.ctx;
|
|
114971
|
-
const
|
|
114972
|
-
|
|
114973
|
-
|
|
114974
|
-
|
|
114975
|
-
|
|
114976
|
-
|
|
114977
|
-
|
|
114978
|
-
|
|
114979
|
-
|
|
114980
|
-
|
|
114981
|
-
|
|
114982
|
-
|
|
115289
|
+
const leaseKey = `${ctx.repoRoot}::${ctx.baseBranch}`;
|
|
115290
|
+
const leaseHolder = buildRefineJobKey(self, meshId, nodeId);
|
|
115291
|
+
if (self.refineBaseLeases.has(leaseKey) && self.refineBaseLeases.get(leaseKey) !== leaseHolder) {
|
|
115292
|
+
recordMeshRefineStage(refineStages, "base_lease", "skipped", Date.now(), {
|
|
115293
|
+
leaseKey,
|
|
115294
|
+
heldBy: self.refineBaseLeases.get(leaseKey),
|
|
115295
|
+
retryable: true
|
|
115296
|
+
});
|
|
115297
|
+
return {
|
|
115298
|
+
success: false,
|
|
115299
|
+
code: "base_locked",
|
|
115300
|
+
convergenceStatus: "blocked_review",
|
|
115301
|
+
retryable: true,
|
|
115302
|
+
error: `Another refine holds the base lease for ${ctx.baseBranch} in this repo; retry after it completes.`,
|
|
115303
|
+
branch: ctx.branch,
|
|
115304
|
+
into: ctx.baseBranch,
|
|
115305
|
+
refineStages,
|
|
115306
|
+
finalBranchConvergenceState: {
|
|
115307
|
+
branch: ctx.branch,
|
|
115308
|
+
baseBranch: ctx.baseBranch,
|
|
115309
|
+
merged: false,
|
|
115310
|
+
removed: false,
|
|
115311
|
+
status: "blocked_review"
|
|
115312
|
+
}
|
|
115313
|
+
};
|
|
115314
|
+
}
|
|
115315
|
+
self.refineBaseLeases.set(leaseKey, leaseHolder);
|
|
115316
|
+
try {
|
|
115317
|
+
const syncBase = await refineSyncBaseStage(self, ctx);
|
|
115318
|
+
if (syncBase.kind === "terminal") return syncBase.result;
|
|
115319
|
+
const validation = await refineValidationStage(self, ctx);
|
|
115320
|
+
if (validation.kind === "terminal") return validation.result;
|
|
115321
|
+
const patchEquivalence = await refinePatchEquivalenceStage(self, ctx);
|
|
115322
|
+
if (patchEquivalence.kind === "terminal") return patchEquivalence.result;
|
|
115323
|
+
const submoduleReachability = await refineSubmoduleReachabilityStage(self, ctx);
|
|
115324
|
+
if (submoduleReachability.kind === "terminal") return submoduleReachability.result;
|
|
115325
|
+
const effectiveDiff = await refineEffectiveDiffStage(self, ctx);
|
|
115326
|
+
if (effectiveDiff.kind === "terminal") return effectiveDiff.result;
|
|
115327
|
+
const merge3 = await refineMergeAndFinalizeStage(self, ctx);
|
|
115328
|
+
return merge3.result;
|
|
115329
|
+
} finally {
|
|
115330
|
+
if (self.refineBaseLeases.get(leaseKey) === leaseHolder) self.refineBaseLeases.delete(leaseKey);
|
|
115331
|
+
}
|
|
114983
115332
|
} catch (e) {
|
|
114984
115333
|
return { success: false, error: e.message, refineStages };
|
|
114985
115334
|
}
|
|
@@ -115499,6 +115848,7 @@ ${tail}` : ""
|
|
|
115499
115848
|
unreachable: submoduleReachability.unreachable.map((entry) => ({
|
|
115500
115849
|
path: entry.path,
|
|
115501
115850
|
commit: entry.commit,
|
|
115851
|
+
equivalentPublishedCommit: entry.equivalentPublishedCommit,
|
|
115502
115852
|
publishRequired: entry.publishRequired === true,
|
|
115503
115853
|
autoPublishAllowed: entry.autoPublishAllowed,
|
|
115504
115854
|
autoPublishAttempted: entry.autoPublishAttempted,
|
|
@@ -115517,15 +115867,23 @@ ${tail}` : ""
|
|
|
115517
115867
|
});
|
|
115518
115868
|
if (submoduleReachability.status === "failed") {
|
|
115519
115869
|
const nextStep = buildSubmodulePublishRequiredNextStep(submoduleReachability.unreachable);
|
|
115870
|
+
const convergeToPublished = submoduleReachability.unreachable.length > 0 && submoduleReachability.unreachable.every((entry) => !!entry.equivalentPublishedCommit);
|
|
115871
|
+
const blockedReason = convergeToPublished ? "submodule_converge_to_published" : "submodule_publish_required";
|
|
115520
115872
|
return { kind: "terminal", result: {
|
|
115521
115873
|
success: false,
|
|
115522
115874
|
code: "submodule_reachability_failed",
|
|
115523
115875
|
convergenceStatus: "blocked_review",
|
|
115524
|
-
publishRequired:
|
|
115525
|
-
|
|
115526
|
-
|
|
115876
|
+
publishRequired: !convergeToPublished,
|
|
115877
|
+
...convergeToPublished ? { convergeToPublished: true } : {},
|
|
115878
|
+
blockedReason,
|
|
115879
|
+
error: convergeToPublished ? "Refinery submodule reachability preflight found submodule gitlink commit(s) that are not reachable from their configured remote main branch, but each has an equivalent commit (identical tree) already published there; converge the gitlink(s) to the published commit(s) instead of publishing same-content twins. Merge/refine cleanup was not attempted." : "Refinery submodule reachability preflight failed because one or more submodule gitlink commits are not reachable from their configured remote main branch; merge/refine cleanup was not attempted.",
|
|
115527
115880
|
nextStep,
|
|
115528
|
-
nextSteps: [
|
|
115881
|
+
nextSteps: convergeToPublished ? [
|
|
115882
|
+
"Do NOT publish the local submodule commit(s): an equivalent commit (identical tree) is already published on the submodule remote main branch for every unreachable gitlink.",
|
|
115883
|
+
"Retarget each submodule gitlink to the already-published equivalent commit shown in the evidence (equivalentPublishedCommit), commit the root pointer update, and push the submodule checkout to that commit.",
|
|
115884
|
+
"Rerun mesh_refine_node after the gitlink points at the published commit.",
|
|
115885
|
+
"Do not merge the root branch until every submodule gitlink commit is reachable from submodule origin/main."
|
|
115886
|
+
] : [
|
|
115529
115887
|
"Ask the user for explicit approval before pushing or publishing any submodule commit.",
|
|
115530
115888
|
"Push/publish each unreachable submodule commit to the configured submodule remote main branch shown in the evidence.",
|
|
115531
115889
|
"Rerun mesh_refine_node after remote reachability is confirmed.",
|
|
@@ -115534,6 +115892,7 @@ ${tail}` : ""
|
|
|
115534
115892
|
unreachableSubmoduleCommits: submoduleReachability.unreachable.map((entry) => ({
|
|
115535
115893
|
path: entry.path,
|
|
115536
115894
|
commit: entry.commit,
|
|
115895
|
+
equivalentPublishedCommit: entry.equivalentPublishedCommit,
|
|
115537
115896
|
remote: entry.remote,
|
|
115538
115897
|
remoteUrl: entry.remoteUrl,
|
|
115539
115898
|
remoteReachable: entry.remoteReachable,
|
|
@@ -115562,7 +115921,7 @@ ${tail}` : ""
|
|
|
115562
115921
|
patchEquivalence: "passed",
|
|
115563
115922
|
submoduleReachability: "failed",
|
|
115564
115923
|
status: "blocked_review",
|
|
115565
|
-
reason:
|
|
115924
|
+
reason: blockedReason,
|
|
115566
115925
|
nextStep
|
|
115567
115926
|
}
|
|
115568
115927
|
} };
|
|
@@ -115679,7 +116038,8 @@ ${hintLines.join("\n")}` : "",
|
|
|
115679
116038
|
const { meshId, nodeId, args, repoRoot, baseHead, node, branch, baseBranch, sourceNode, validationSummary, patchEquivalence, submoduleReachability, mesh, refineStages, execFileAsync: execFileAsync6 } = ctx;
|
|
115680
116039
|
const leaseKey = `${repoRoot}::${baseBranch}`;
|
|
115681
116040
|
const leaseHolder = buildRefineJobKey(self, meshId, nodeId);
|
|
115682
|
-
|
|
116041
|
+
const alreadyHeld = self.refineBaseLeases.get(leaseKey) === leaseHolder;
|
|
116042
|
+
if (!alreadyHeld && self.refineBaseLeases.has(leaseKey)) {
|
|
115683
116043
|
recordMeshRefineStage(refineStages, "base_lease", "skipped", Date.now(), {
|
|
115684
116044
|
leaseKey,
|
|
115685
116045
|
heldBy: self.refineBaseLeases.get(leaseKey),
|
|
@@ -115706,11 +116066,11 @@ ${hintLines.join("\n")}` : "",
|
|
|
115706
116066
|
}
|
|
115707
116067
|
} };
|
|
115708
116068
|
}
|
|
115709
|
-
self.refineBaseLeases.set(leaseKey, leaseHolder);
|
|
116069
|
+
if (!alreadyHeld) self.refineBaseLeases.set(leaseKey, leaseHolder);
|
|
115710
116070
|
try {
|
|
115711
116071
|
return await runRefineMergeAndFinalizeLocked(self, ctx);
|
|
115712
116072
|
} finally {
|
|
115713
|
-
if (self.refineBaseLeases.get(leaseKey) === leaseHolder) self.refineBaseLeases.delete(leaseKey);
|
|
116073
|
+
if (!alreadyHeld && self.refineBaseLeases.get(leaseKey) === leaseHolder) self.refineBaseLeases.delete(leaseKey);
|
|
115714
116074
|
}
|
|
115715
116075
|
}
|
|
115716
116076
|
async function runRefineMergeAndFinalizeLocked(self, ctx) {
|
|
@@ -120071,7 +120431,7 @@ ${e?.stderr || ""}`;
|
|
|
120071
120431
|
init_chat_message_normalization();
|
|
120072
120432
|
var fs49 = __toESM2(require("fs"));
|
|
120073
120433
|
var path48 = __toESM2(require("path"));
|
|
120074
|
-
var
|
|
120434
|
+
var os26 = __toESM2(require("os"));
|
|
120075
120435
|
var import_os6 = require("os");
|
|
120076
120436
|
init_config();
|
|
120077
120437
|
var import_child_process13 = require("child_process");
|
|
@@ -120196,7 +120556,7 @@ ${e?.stderr || ""}`;
|
|
|
120196
120556
|
function checkPathExists2(paths) {
|
|
120197
120557
|
for (const p of paths) {
|
|
120198
120558
|
if (p.includes("*")) {
|
|
120199
|
-
const home =
|
|
120559
|
+
const home = os26.homedir();
|
|
120200
120560
|
const resolved = p.replace(/\*/g, home.split(path48.sep).pop() || "");
|
|
120201
120561
|
if (fs49.existsSync(resolved)) return resolved;
|
|
120202
120562
|
} else {
|
|
@@ -122593,7 +122953,7 @@ async (params) => {
|
|
|
122593
122953
|
}
|
|
122594
122954
|
var fs52 = __toESM2(require("fs"));
|
|
122595
122955
|
var path51 = __toESM2(require("path"));
|
|
122596
|
-
var
|
|
122956
|
+
var os27 = __toESM2(require("os"));
|
|
122597
122957
|
var import_session_host_core11 = require_dist();
|
|
122598
122958
|
function getAutoImplPid(ctx) {
|
|
122599
122959
|
const pid = ctx.autoImplProcess?.pid;
|
|
@@ -122795,7 +123155,7 @@ async (params) => {
|
|
|
122795
123155
|
});
|
|
122796
123156
|
const referenceScripts = loadAutoImplReferenceScripts(ctx, resolvedReference);
|
|
122797
123157
|
const prompt = buildAutoImplPrompt(ctx, type2, provider, providerDir, functions, domContext, referenceScripts, comment, resolvedReference, verification);
|
|
122798
|
-
const tmpDir = path51.join(
|
|
123158
|
+
const tmpDir = path51.join(os27.tmpdir(), "adhdev-autoimpl");
|
|
122799
123159
|
if (!fs52.existsSync(tmpDir)) fs52.mkdirSync(tmpDir, { recursive: true });
|
|
122800
123160
|
const promptFile = path51.join(tmpDir, `prompt-${type2}-${Date.now()}.md`);
|
|
122801
123161
|
fs52.writeFileSync(promptFile, prompt, "utf-8");
|
|
@@ -122950,7 +123310,7 @@ async (params) => {
|
|
|
122950
123310
|
const interactiveFlags = ["--yolo", "--interactive", "-i"];
|
|
122951
123311
|
const baseArgs = [...spawn7.args || []].filter((a) => !interactiveFlags.includes(a));
|
|
122952
123312
|
let shellCmd;
|
|
122953
|
-
const isWin =
|
|
123313
|
+
const isWin = os27.platform() === "win32";
|
|
122954
123314
|
const escapeArg = (a) => isWin ? `"${a.replace(/"/g, '""')}"` : `'${a.replace(/'/g, "'\\''")}'`;
|
|
122955
123315
|
const promptMode = autoImpl?.promptMode ?? "stdin";
|
|
122956
123316
|
const extraArgs = autoImpl?.extraArgs ?? [];
|
|
@@ -122989,7 +123349,7 @@ async (params) => {
|
|
|
122989
123349
|
try {
|
|
122990
123350
|
const pty = require("node-pty");
|
|
122991
123351
|
ctx.log(`Auto-implement spawn (PTY): ${shellCmd}`);
|
|
122992
|
-
const isWin2 =
|
|
123352
|
+
const isWin2 = os27.platform() === "win32";
|
|
122993
123353
|
child = pty.spawn(isWin2 ? "cmd.exe" : process.env.SHELL || "/bin/zsh", [isWin2 ? "/c" : "-c", shellCmd], {
|
|
122994
123354
|
name: "xterm-256color",
|
|
122995
123355
|
cols: import_session_host_core11.DEFAULT_SESSION_HOST_COLS,
|
|
@@ -125645,7 +126005,7 @@ data: ${JSON.stringify(msg.data)}
|
|
|
125645
126005
|
}
|
|
125646
126006
|
var import_child_process14 = require("child_process");
|
|
125647
126007
|
var fs54 = __toESM2(require("fs"));
|
|
125648
|
-
var
|
|
126008
|
+
var os28 = __toESM2(require("os"));
|
|
125649
126009
|
var path53 = __toESM2(require("path"));
|
|
125650
126010
|
var import_session_host_core15 = require_dist();
|
|
125651
126011
|
init_logger();
|
|
@@ -125717,7 +126077,7 @@ data: ${JSON.stringify(msg.data)}
|
|
|
125717
126077
|
}
|
|
125718
126078
|
let portableNode = null;
|
|
125719
126079
|
try {
|
|
125720
|
-
portableNode = findPortableNode22(
|
|
126080
|
+
portableNode = findPortableNode22(os28.homedir(), process.execPath, resolveInstanceDir());
|
|
125721
126081
|
} catch (error48) {
|
|
125722
126082
|
LOG2.warn(
|
|
125723
126083
|
"SessionHost",
|