@adhdev/daemon-standalone 1.0.49-rc.10 → 1.0.49-rc.12
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 +1250 -765
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
- package/public/assets/index-BfczC7ZW.css +1 -0
- package/public/assets/index-CQBRKKei.js +119 -0
- package/public/index.html +2 -2
- package/vendor/mcp-server/index.js +401 -78
- package/vendor/mcp-server/index.js.map +1 -1
- package/public/assets/index-BeC2kIKA.js +0 -116
- package/public/assets/index-CqyS0XiL.css +0 -1
package/dist/index.js
CHANGED
|
@@ -36552,8 +36552,8 @@ var require_dist3 = __commonJS({
|
|
|
36552
36552
|
function isRecord(value) {
|
|
36553
36553
|
return !!value && typeof value === "object" && !Array.isArray(value);
|
|
36554
36554
|
}
|
|
36555
|
-
function parseConfigText(
|
|
36556
|
-
if (/\.json$/i.test(
|
|
36555
|
+
function parseConfigText(path56, text) {
|
|
36556
|
+
if (/\.json$/i.test(path56)) return JSON.parse(text);
|
|
36557
36557
|
return yaml.load(text);
|
|
36558
36558
|
}
|
|
36559
36559
|
function normalizeOperatingNote(value) {
|
|
@@ -37056,10 +37056,10 @@ var require_dist3 = __commonJS({
|
|
|
37056
37056
|
}
|
|
37057
37057
|
function getDaemonBuildInfo() {
|
|
37058
37058
|
if (cached2) return cached2;
|
|
37059
|
-
const commit = readInjected(true ? "
|
|
37060
|
-
const commitShort = readInjected(true ? "
|
|
37061
|
-
const version2 = readInjected(true ? "1.0.49-rc.
|
|
37062
|
-
const builtAt = readInjected(true ? "2026-08-
|
|
37059
|
+
const commit = readInjected(true ? "d20b4ad708551ef7198efd44a123bcb981b62fb1" : void 0) ?? "unknown";
|
|
37060
|
+
const commitShort = readInjected(true ? "d20b4ad7" : void 0) ?? (commit !== "unknown" ? commit.slice(0, 7) : "unknown");
|
|
37061
|
+
const version2 = readInjected(true ? "1.0.49-rc.12" : void 0) ?? readInjected(typeof process !== "undefined" ? process.env?.ADHDEV_PKG_VERSION : void 0) ?? "unknown";
|
|
37062
|
+
const builtAt = readInjected(true ? "2026-08-15T07:08:42.502Z" : void 0);
|
|
37063
37063
|
cached2 = builtAt ? { commit, commitShort, version: version2, builtAt } : { commit, commitShort, version: version2 };
|
|
37064
37064
|
return cached2;
|
|
37065
37065
|
}
|
|
@@ -37131,8 +37131,8 @@ var require_dist3 = __commonJS({
|
|
|
37131
37131
|
}
|
|
37132
37132
|
return { valid: errors.length === 0, errors, config: errors.length === 0 ? config2 : void 0 };
|
|
37133
37133
|
}
|
|
37134
|
-
function parseConfigText2(
|
|
37135
|
-
if (/\.json$/i.test(
|
|
37134
|
+
function parseConfigText2(path56, text) {
|
|
37135
|
+
if (/\.json$/i.test(path56)) return JSON.parse(text);
|
|
37136
37136
|
return yaml2.load(text);
|
|
37137
37137
|
}
|
|
37138
37138
|
function loadChangeImpactConfig(repoRoot) {
|
|
@@ -37833,20 +37833,20 @@ var require_dist3 = __commonJS({
|
|
|
37833
37833
|
try {
|
|
37834
37834
|
const paths = await readSubmodulePaths(repo, options);
|
|
37835
37835
|
const ignoreSet = new Set(options.submoduleIgnorePaths || []);
|
|
37836
|
-
const visiblePaths = paths.filter((
|
|
37836
|
+
const visiblePaths = paths.filter((path56) => !ignoreSet.has(path56));
|
|
37837
37837
|
const expectedByPath = await readGitlinkExpectedShas(repo, visiblePaths, options);
|
|
37838
37838
|
const lastCheckedAt = Date.now();
|
|
37839
37839
|
const headOidByPath = /* @__PURE__ */ new Map();
|
|
37840
37840
|
const submodules = await Promise.all(
|
|
37841
|
-
visiblePaths.map(async (
|
|
37842
|
-
const repoPath = repo.repoRoot + "/" +
|
|
37843
|
-
const expected = expectedByPath.get(
|
|
37841
|
+
visiblePaths.map(async (path56) => {
|
|
37842
|
+
const repoPath = repo.repoRoot + "/" + path56;
|
|
37843
|
+
const expected = expectedByPath.get(path56) ?? null;
|
|
37844
37844
|
const worktree = await readSubmoduleWorktreeStatus(repo, repoPath, options);
|
|
37845
37845
|
const actual = worktree.headOid;
|
|
37846
|
-
if (actual) headOidByPath.set(
|
|
37846
|
+
if (actual) headOidByPath.set(path56, actual);
|
|
37847
37847
|
const outOfSync = actual === null ? true : expected !== null && expected !== actual;
|
|
37848
37848
|
return {
|
|
37849
|
-
path:
|
|
37849
|
+
path: path56,
|
|
37850
37850
|
// Prefer the recorded gitlink SHA (matches the legacy column); fall back
|
|
37851
37851
|
// to the checked-out SHA so the field is never empty when both are known.
|
|
37852
37852
|
commit: expected ?? actual ?? "",
|
|
@@ -40501,6 +40501,13 @@ child.on('exit', () => process.exit(0));
|
|
|
40501
40501
|
if (typeof retryAtMs !== "number" || retryAtMs > now) return false;
|
|
40502
40502
|
return (failureRetries.get(provider)?.failures ?? 0) <= QUOTA_FAILURE_MAX_RETRIES;
|
|
40503
40503
|
}
|
|
40504
|
+
function isSnapshotStaleForRouting(provider, now = Date.now()) {
|
|
40505
|
+
const entry = cache.get(provider);
|
|
40506
|
+
if (!entry) return false;
|
|
40507
|
+
const updatedAt = Number(entry.updatedAt);
|
|
40508
|
+
if (!Number.isFinite(updatedAt) || updatedAt <= 0) return true;
|
|
40509
|
+
return now - updatedAt >= QUOTA_ROUTABLE_MAX_AGE_MS;
|
|
40510
|
+
}
|
|
40504
40511
|
function updateFailureRetry(provider, fetch2, isEnabled) {
|
|
40505
40512
|
const entry = cache.get(provider);
|
|
40506
40513
|
const retryAtMs = entry && entry.status !== "ok" ? entry.metadata?.retryAtMs : void 0;
|
|
@@ -40551,7 +40558,7 @@ child.on('exit', () => process.exit(0));
|
|
|
40551
40558
|
} catch {
|
|
40552
40559
|
active = false;
|
|
40553
40560
|
}
|
|
40554
|
-
const needsBackfill = options.isEnabled ? fetchers.some(({ provider }) => options.isEnabled(provider) && (!cache.has(provider) || isFailureRetryDue(provider))) : false;
|
|
40561
|
+
const needsBackfill = options.isEnabled ? fetchers.some(({ provider }) => options.isEnabled(provider) && (!cache.has(provider) || isFailureRetryDue(provider) || isSnapshotStaleForRouting(provider))) : false;
|
|
40555
40562
|
if (!active && !needsBackfill) return;
|
|
40556
40563
|
running = true;
|
|
40557
40564
|
void refreshQuotaCacheOnce(fetchers, options.isEnabled).catch((e) => LOG2.warn("Quota", `Quota refresh tick error: ${e?.message || e}`)).finally(() => {
|
|
@@ -40613,6 +40620,7 @@ child.on('exit', () => process.exit(0));
|
|
|
40613
40620
|
var hydrated;
|
|
40614
40621
|
var QUOTA_FAILURE_MAX_RETRIES;
|
|
40615
40622
|
var failureRetries;
|
|
40623
|
+
var QUOTA_ROUTABLE_MAX_AGE_MS;
|
|
40616
40624
|
var WORKING_STATUSES;
|
|
40617
40625
|
var bootRefreshInFlight;
|
|
40618
40626
|
var QUOTA_EVENT_REFRESH_DEBOUNCE_MS;
|
|
@@ -40639,6 +40647,7 @@ child.on('exit', () => process.exit(0));
|
|
|
40639
40647
|
hydrated = false;
|
|
40640
40648
|
QUOTA_FAILURE_MAX_RETRIES = 4;
|
|
40641
40649
|
failureRetries = /* @__PURE__ */ new Map();
|
|
40650
|
+
QUOTA_ROUTABLE_MAX_AGE_MS = 30 * 60 * 1e3;
|
|
40642
40651
|
WORKING_STATUSES = /* @__PURE__ */ new Set([
|
|
40643
40652
|
"generating",
|
|
40644
40653
|
"waiting_approval",
|
|
@@ -40839,11 +40848,11 @@ child.on('exit', () => process.exit(0));
|
|
|
40839
40848
|
}
|
|
40840
40849
|
function windowsExtraBinDirs() {
|
|
40841
40850
|
const dirs = [];
|
|
40842
|
-
const
|
|
40851
|
+
const fs58 = require("fs");
|
|
40843
40852
|
const push = (dir) => {
|
|
40844
40853
|
if (!dir) return;
|
|
40845
40854
|
try {
|
|
40846
|
-
if (
|
|
40855
|
+
if (fs58.existsSync(dir)) dirs.push(dir);
|
|
40847
40856
|
} catch {
|
|
40848
40857
|
}
|
|
40849
40858
|
};
|
|
@@ -40859,12 +40868,12 @@ child.on('exit', () => process.exit(0));
|
|
|
40859
40868
|
}
|
|
40860
40869
|
function unixExtraBinDirs() {
|
|
40861
40870
|
const dirs = [];
|
|
40862
|
-
const
|
|
40871
|
+
const fs58 = require("fs");
|
|
40863
40872
|
const home = os42.homedir();
|
|
40864
40873
|
const push = (dir) => {
|
|
40865
40874
|
if (!dir) return;
|
|
40866
40875
|
try {
|
|
40867
|
-
if (
|
|
40876
|
+
if (fs58.existsSync(dir)) dirs.push(dir);
|
|
40868
40877
|
} catch {
|
|
40869
40878
|
}
|
|
40870
40879
|
};
|
|
@@ -40903,9 +40912,9 @@ child.on('exit', () => process.exit(0));
|
|
|
40903
40912
|
for (const ext of exes) {
|
|
40904
40913
|
const fullPath = path8.join(p, trimmed + ext);
|
|
40905
40914
|
try {
|
|
40906
|
-
const
|
|
40907
|
-
if (
|
|
40908
|
-
const stat2 =
|
|
40915
|
+
const fs58 = require("fs");
|
|
40916
|
+
if (fs58.existsSync(fullPath)) {
|
|
40917
|
+
const stat2 = fs58.statSync(fullPath);
|
|
40909
40918
|
if (stat2.isFile() && (isWin || stat2.mode & 73)) {
|
|
40910
40919
|
return fullPath;
|
|
40911
40920
|
}
|
|
@@ -40919,12 +40928,12 @@ child.on('exit', () => process.exit(0));
|
|
|
40919
40928
|
function isScriptBinary(binaryPath) {
|
|
40920
40929
|
if (!path8.isAbsolute(binaryPath)) return false;
|
|
40921
40930
|
try {
|
|
40922
|
-
const
|
|
40923
|
-
const resolved =
|
|
40931
|
+
const fs58 = require("fs");
|
|
40932
|
+
const resolved = fs58.realpathSync(binaryPath);
|
|
40924
40933
|
const head = Buffer.alloc(8);
|
|
40925
|
-
const fd =
|
|
40926
|
-
|
|
40927
|
-
|
|
40934
|
+
const fd = fs58.openSync(resolved, "r");
|
|
40935
|
+
fs58.readSync(fd, head, 0, 8, 0);
|
|
40936
|
+
fs58.closeSync(fd);
|
|
40928
40937
|
let i = 0;
|
|
40929
40938
|
if (head[0] === 239 && head[1] === 187 && head[2] === 191) i = 3;
|
|
40930
40939
|
return head[i] === 35 && head[i + 1] === 33;
|
|
@@ -40935,12 +40944,12 @@ child.on('exit', () => process.exit(0));
|
|
|
40935
40944
|
function looksLikeMachOOrElf(filePath) {
|
|
40936
40945
|
if (!path8.isAbsolute(filePath)) return false;
|
|
40937
40946
|
try {
|
|
40938
|
-
const
|
|
40939
|
-
const resolved =
|
|
40947
|
+
const fs58 = require("fs");
|
|
40948
|
+
const resolved = fs58.realpathSync(filePath);
|
|
40940
40949
|
const buf = Buffer.alloc(8);
|
|
40941
|
-
const fd =
|
|
40942
|
-
|
|
40943
|
-
|
|
40950
|
+
const fd = fs58.openSync(resolved, "r");
|
|
40951
|
+
fs58.readSync(fd, buf, 0, 8, 0);
|
|
40952
|
+
fs58.closeSync(fd);
|
|
40944
40953
|
let i = 0;
|
|
40945
40954
|
if (buf[0] === 239 && buf[1] === 187 && buf[2] === 191) i = 3;
|
|
40946
40955
|
const b = buf.subarray(i);
|
|
@@ -42369,12 +42378,12 @@ ${error48.message || ""}`;
|
|
|
42369
42378
|
if (!Array.isArray(value)) return void 0;
|
|
42370
42379
|
const submodules = value.map((entry) => {
|
|
42371
42380
|
const submodule = readRecord(entry);
|
|
42372
|
-
const
|
|
42381
|
+
const path56 = readString2(submodule.path);
|
|
42373
42382
|
const commit = readString2(submodule.commit);
|
|
42374
|
-
const repoPath = readString2(submodule.repoPath, submodule.repo_root) ?? joinRepoPath(parentRepoRoot,
|
|
42375
|
-
if (!
|
|
42383
|
+
const repoPath = readString2(submodule.repoPath, submodule.repo_root) ?? joinRepoPath(parentRepoRoot, path56);
|
|
42384
|
+
if (!path56 || !commit) return null;
|
|
42376
42385
|
const result = {
|
|
42377
|
-
path:
|
|
42386
|
+
path: path56,
|
|
42378
42387
|
commit,
|
|
42379
42388
|
dirty: readBoolean(submodule.dirty) ?? false,
|
|
42380
42389
|
outOfSync: readBoolean(submodule.outOfSync, submodule.out_of_sync) ?? false,
|
|
@@ -42956,6 +42965,7 @@ ${error48.message || ""}`;
|
|
|
42956
42965
|
"mesh_status",
|
|
42957
42966
|
"mesh_list_nodes",
|
|
42958
42967
|
"mesh_enqueue_task",
|
|
42968
|
+
"mesh_enqueue_batch",
|
|
42959
42969
|
"mesh_view_queue",
|
|
42960
42970
|
"mesh_queue_cancel",
|
|
42961
42971
|
"mesh_queue_requeue",
|
|
@@ -43149,10 +43159,10 @@ ${error48.message || ""}`;
|
|
|
43149
43159
|
return (0, import_path5.join)(getConfigDir2(), "meshes.json");
|
|
43150
43160
|
}
|
|
43151
43161
|
function loadMeshConfig(options = {}) {
|
|
43152
|
-
const
|
|
43153
|
-
if (!(0, import_fs5.existsSync)(
|
|
43162
|
+
const path56 = getMeshConfigPath();
|
|
43163
|
+
if (!(0, import_fs5.existsSync)(path56)) return { meshes: [] };
|
|
43154
43164
|
try {
|
|
43155
|
-
const raw = JSON.parse((0, import_fs5.readFileSync)(
|
|
43165
|
+
const raw = JSON.parse((0, import_fs5.readFileSync)(path56, "utf-8"));
|
|
43156
43166
|
if (!raw || !Array.isArray(raw.meshes)) return { meshes: [] };
|
|
43157
43167
|
const config2 = raw;
|
|
43158
43168
|
const migrated = migrateLoadedMeshConfig(config2);
|
|
@@ -43250,8 +43260,8 @@ ${error48.message || ""}`;
|
|
|
43250
43260
|
return tags.length ? tags : void 0;
|
|
43251
43261
|
}
|
|
43252
43262
|
function saveMeshConfig(config2) {
|
|
43253
|
-
const
|
|
43254
|
-
(0, import_fs5.writeFileSync)(
|
|
43263
|
+
const path56 = getMeshConfigPath();
|
|
43264
|
+
(0, import_fs5.writeFileSync)(path56, JSON.stringify(config2, null, 2), { encoding: "utf-8", mode: 384 });
|
|
43255
43265
|
}
|
|
43256
43266
|
function normalizeRepoIdentity(remoteUrl) {
|
|
43257
43267
|
let identity = remoteUrl.trim().replace(/[?#].*$/, "").replace(/\/+$/, "");
|
|
@@ -43259,8 +43269,8 @@ ${error48.message || ""}`;
|
|
|
43259
43269
|
if (/^[a-z][a-z0-9+.-]*:\/\//i.test(identity)) {
|
|
43260
43270
|
try {
|
|
43261
43271
|
const url2 = new URL(identity);
|
|
43262
|
-
const
|
|
43263
|
-
if (url2.hostname &&
|
|
43272
|
+
const path56 = decodeURIComponent(url2.pathname).replace(/^\/+|\/+$/g, "").replace(/\.git$/i, "");
|
|
43273
|
+
if (url2.hostname && path56) return `${url2.hostname.toLowerCase()}/${path56}`;
|
|
43264
43274
|
} catch {
|
|
43265
43275
|
}
|
|
43266
43276
|
}
|
|
@@ -45918,59 +45928,59 @@ Next step: ${nextStep}`;
|
|
|
45918
45928
|
function isNonEmptyString(value) {
|
|
45919
45929
|
return typeof value === "string" && value.length > 0;
|
|
45920
45930
|
}
|
|
45921
|
-
function assertCoordinatorIdentity(raw,
|
|
45931
|
+
function assertCoordinatorIdentity(raw, path56) {
|
|
45922
45932
|
if (!raw || typeof raw !== "object" || Array.isArray(raw)) {
|
|
45923
|
-
throw new MeshContractViolationError(MESH_PROTOCOL_VERSION_V2,
|
|
45933
|
+
throw new MeshContractViolationError(MESH_PROTOCOL_VERSION_V2, path56, "must be an object");
|
|
45924
45934
|
}
|
|
45925
45935
|
const obj = raw;
|
|
45926
45936
|
if (!isNonEmptyString(obj.daemonId)) {
|
|
45927
|
-
throw new MeshContractViolationError(MESH_PROTOCOL_VERSION_V2, `${
|
|
45937
|
+
throw new MeshContractViolationError(MESH_PROTOCOL_VERSION_V2, `${path56}.daemonId`, "must be a non-empty string");
|
|
45928
45938
|
}
|
|
45929
45939
|
if (!isNonEmptyString(obj.coordinatorRunId)) {
|
|
45930
|
-
throw new MeshContractViolationError(MESH_PROTOCOL_VERSION_V2, `${
|
|
45940
|
+
throw new MeshContractViolationError(MESH_PROTOCOL_VERSION_V2, `${path56}.coordinatorRunId`, "must be a non-empty string");
|
|
45931
45941
|
}
|
|
45932
45942
|
const sessionId = obj.sessionId;
|
|
45933
45943
|
if (sessionId !== void 0 && !isNonEmptyString(sessionId)) {
|
|
45934
|
-
throw new MeshContractViolationError(MESH_PROTOCOL_VERSION_V2, `${
|
|
45944
|
+
throw new MeshContractViolationError(MESH_PROTOCOL_VERSION_V2, `${path56}.sessionId`, "must be a non-empty string when provided");
|
|
45935
45945
|
}
|
|
45936
45946
|
return sessionId !== void 0 ? { daemonId: obj.daemonId, coordinatorRunId: obj.coordinatorRunId, sessionId } : { daemonId: obj.daemonId, coordinatorRunId: obj.coordinatorRunId };
|
|
45937
45947
|
}
|
|
45938
|
-
function assertPendingMeshCoordinatorEventV2(raw,
|
|
45948
|
+
function assertPendingMeshCoordinatorEventV2(raw, path56 = "$") {
|
|
45939
45949
|
if (!raw || typeof raw !== "object" || Array.isArray(raw)) {
|
|
45940
|
-
throw new MeshContractViolationError(MESH_PROTOCOL_VERSION_V2,
|
|
45950
|
+
throw new MeshContractViolationError(MESH_PROTOCOL_VERSION_V2, path56, "must be an object");
|
|
45941
45951
|
}
|
|
45942
45952
|
const obj = raw;
|
|
45943
45953
|
if (!isSupportedMeshProtocolVersion(obj.protocolVersion)) {
|
|
45944
|
-
throw new MeshContractViolationError(MESH_PROTOCOL_VERSION_V2, `${
|
|
45954
|
+
throw new MeshContractViolationError(MESH_PROTOCOL_VERSION_V2, `${path56}.protocolVersion`, `must be one of ${SUPPORTED_MESH_PROTOCOL_VERSIONS.join(", ")}`);
|
|
45945
45955
|
}
|
|
45946
45956
|
if (!isNonEmptyString(obj.eventId)) {
|
|
45947
|
-
throw new MeshContractViolationError(MESH_PROTOCOL_VERSION_V2, `${
|
|
45957
|
+
throw new MeshContractViolationError(MESH_PROTOCOL_VERSION_V2, `${path56}.eventId`, "must be a non-empty string");
|
|
45948
45958
|
}
|
|
45949
45959
|
if (!isMeshEventScope(obj.scope)) {
|
|
45950
|
-
throw new MeshContractViolationError(MESH_PROTOCOL_VERSION_V2, `${
|
|
45960
|
+
throw new MeshContractViolationError(MESH_PROTOCOL_VERSION_V2, `${path56}.scope`, `must be one of ${MESH_EVENT_SCOPES.join(", ")}`);
|
|
45951
45961
|
}
|
|
45952
45962
|
if (!isNonEmptyString(obj.event)) {
|
|
45953
|
-
throw new MeshContractViolationError(MESH_PROTOCOL_VERSION_V2, `${
|
|
45963
|
+
throw new MeshContractViolationError(MESH_PROTOCOL_VERSION_V2, `${path56}.event`, "must be a non-empty string");
|
|
45954
45964
|
}
|
|
45955
45965
|
if (!isNonEmptyString(obj.meshId)) {
|
|
45956
|
-
throw new MeshContractViolationError(MESH_PROTOCOL_VERSION_V2, `${
|
|
45966
|
+
throw new MeshContractViolationError(MESH_PROTOCOL_VERSION_V2, `${path56}.meshId`, "must be a non-empty string");
|
|
45957
45967
|
}
|
|
45958
|
-
const dispatchedBy = assertCoordinatorIdentity(obj.dispatchedBy, `${
|
|
45968
|
+
const dispatchedBy = assertCoordinatorIdentity(obj.dispatchedBy, `${path56}.dispatchedBy`);
|
|
45959
45969
|
if (obj.scope === "unicast") {
|
|
45960
45970
|
if (!obj.intendedFor) {
|
|
45961
|
-
throw new MeshContractViolationError(MESH_PROTOCOL_VERSION_V2, `${
|
|
45971
|
+
throw new MeshContractViolationError(MESH_PROTOCOL_VERSION_V2, `${path56}.intendedFor`, "unicast scope requires intendedFor");
|
|
45962
45972
|
}
|
|
45963
45973
|
} else if (obj.intendedFor !== void 0) {
|
|
45964
|
-
throw new MeshContractViolationError(MESH_PROTOCOL_VERSION_V2, `${
|
|
45974
|
+
throw new MeshContractViolationError(MESH_PROTOCOL_VERSION_V2, `${path56}.intendedFor`, "only unicast scope may set intendedFor");
|
|
45965
45975
|
}
|
|
45966
|
-
const intendedFor = obj.intendedFor ? assertCoordinatorIdentity(obj.intendedFor, `${
|
|
45976
|
+
const intendedFor = obj.intendedFor ? assertCoordinatorIdentity(obj.intendedFor, `${path56}.intendedFor`) : void 0;
|
|
45967
45977
|
const metadata = obj.metadataEvent && typeof obj.metadataEvent === "object" && !Array.isArray(obj.metadataEvent) ? obj.metadataEvent : null;
|
|
45968
45978
|
if (!metadata) {
|
|
45969
|
-
throw new MeshContractViolationError(MESH_PROTOCOL_VERSION_V2, `${
|
|
45979
|
+
throw new MeshContractViolationError(MESH_PROTOCOL_VERSION_V2, `${path56}.metadataEvent`, "must be an object");
|
|
45970
45980
|
}
|
|
45971
45981
|
const queuedAt = typeof obj.queuedAt === "number" && Number.isFinite(obj.queuedAt) ? obj.queuedAt : null;
|
|
45972
45982
|
if (queuedAt === null) {
|
|
45973
|
-
throw new MeshContractViolationError(MESH_PROTOCOL_VERSION_V2, `${
|
|
45983
|
+
throw new MeshContractViolationError(MESH_PROTOCOL_VERSION_V2, `${path56}.queuedAt`, "must be a finite number");
|
|
45974
45984
|
}
|
|
45975
45985
|
return {
|
|
45976
45986
|
event: obj.event,
|
|
@@ -47159,6 +47169,7 @@ Next step: ${nextStep}`;
|
|
|
47159
47169
|
__export2(mesh_work_queue_exports, {
|
|
47160
47170
|
ACTIVE_MESH_QUEUE_STATUSES: () => ACTIVE_MESH_QUEUE_STATUSES,
|
|
47161
47171
|
HISTORICAL_MESH_QUEUE_STATUSES: () => HISTORICAL_MESH_QUEUE_STATUSES,
|
|
47172
|
+
MESH_TASK_GRAPH_MAX_TASKS: () => MESH_TASK_GRAPH_MAX_TASKS,
|
|
47162
47173
|
MESH_TASK_MODES: () => MESH_TASK_MODES,
|
|
47163
47174
|
MESH_TASK_PRIORITIES: () => MESH_TASK_PRIORITIES,
|
|
47164
47175
|
NOT_BEFORE_RELATIVE_THRESHOLD_MS: () => NOT_BEFORE_RELATIVE_THRESHOLD_MS,
|
|
@@ -47177,6 +47188,7 @@ Next step: ${nextStep}`;
|
|
|
47177
47188
|
deleteDirectDispatchesByTaskId: () => deleteDirectDispatchesByTaskId,
|
|
47178
47189
|
describeTaskDependencyState: () => describeTaskDependencyState,
|
|
47179
47190
|
enqueueTask: () => enqueueTask,
|
|
47191
|
+
enqueueTaskGraph: () => enqueueTaskGraph,
|
|
47180
47192
|
expireTaskTargetPin: () => expireTaskTargetPin,
|
|
47181
47193
|
formatMeshTaskModeViolations: () => formatMeshTaskModeViolations,
|
|
47182
47194
|
getActiveDirectDispatches: () => getActiveDirectDispatches,
|
|
@@ -47564,11 +47576,11 @@ Next step: ${nextStep}`;
|
|
|
47564
47576
|
const pinnedProvider = typeof providerType === "string" && providerType.trim() ? providerType.trim() : void 0;
|
|
47565
47577
|
const providerTags = pinnedProvider ? [pinnedProvider] : readNodeProviderTypes(node?.policy);
|
|
47566
47578
|
const worktreeBranch = typeof node?.worktreeBranch === "string" && node.worktreeBranch.trim() ? node.worktreeBranch.trim() : null;
|
|
47567
|
-
const
|
|
47579
|
+
const os31 = readNodeOverride(node, "platform") ?? readNodeReporter(node, "platform") ?? process.platform;
|
|
47568
47580
|
const arch2 = readNodeOverride(node, "arch") ?? readNodeReporter(node, "arch") ?? process.arch;
|
|
47569
47581
|
return normalizeMeshCapabilityTags([
|
|
47570
47582
|
...Array.isArray(node?.capabilities) ? node.capabilities : [],
|
|
47571
|
-
`os=${
|
|
47583
|
+
`os=${os31}`,
|
|
47572
47584
|
`arch=${arch2}`,
|
|
47573
47585
|
...providerTags.map((p) => `provider=${p}`),
|
|
47574
47586
|
// Worktree nodes automatically expose a "worktree=<branch>" tag so that
|
|
@@ -47735,6 +47747,48 @@ Next step: ${nextStep}`;
|
|
|
47735
47747
|
scheduleMissionCloseCandidateCheck(meshId, [result]);
|
|
47736
47748
|
return result;
|
|
47737
47749
|
}
|
|
47750
|
+
function enqueueTaskGraph(meshId, specs, opts) {
|
|
47751
|
+
requireMeshHostQueueOwner(opts);
|
|
47752
|
+
if (!Array.isArray(specs) || specs.length === 0) {
|
|
47753
|
+
throw new Error("empty_task_graph: enqueueTaskGraph requires at least one task spec");
|
|
47754
|
+
}
|
|
47755
|
+
if (specs.length > MESH_TASK_GRAPH_MAX_TASKS) {
|
|
47756
|
+
throw new Error(`task_graph_too_large: ${specs.length} tasks exceeds the ${MESH_TASK_GRAPH_MAX_TASKS}-task cap for one atomic enqueue`);
|
|
47757
|
+
}
|
|
47758
|
+
const ids = specs.map(() => (0, import_crypto8.randomUUID)());
|
|
47759
|
+
const idByRef = /* @__PURE__ */ new Map();
|
|
47760
|
+
specs.forEach((spec, i) => {
|
|
47761
|
+
const ref = typeof spec.ref === "string" ? spec.ref.trim() : "";
|
|
47762
|
+
if (!ref) return;
|
|
47763
|
+
if (idByRef.has(ref)) {
|
|
47764
|
+
throw new Error(`duplicate_task_ref: ref '${ref}' is used by more than one task in this batch`);
|
|
47765
|
+
}
|
|
47766
|
+
idByRef.set(ref, ids[i]);
|
|
47767
|
+
});
|
|
47768
|
+
const store = MeshRuntimeStore.getInstance();
|
|
47769
|
+
return withQueueLock(meshId, () => {
|
|
47770
|
+
const inserted = [];
|
|
47771
|
+
specs.forEach((spec, i) => {
|
|
47772
|
+
const { ref, message, ...taskOpts } = spec;
|
|
47773
|
+
const label = ref ? `'${ref}'` : `#${i}`;
|
|
47774
|
+
const dependsOn = normalizeDependsOn(spec.dependsOn).map((dep) => {
|
|
47775
|
+
const mapped = idByRef.get(dep);
|
|
47776
|
+
if (mapped) return mapped;
|
|
47777
|
+
if (store.findQueueEntryById(meshId, dep)) return dep;
|
|
47778
|
+
throw new Error(
|
|
47779
|
+
`unknown_dependency: task ${label} depends on '${dep}', which is neither a ref in this batch nor an existing task id` + (idByRef.size ? ` (batch refs: ${[...idByRef.keys()].join(", ")})` : "")
|
|
47780
|
+
);
|
|
47781
|
+
});
|
|
47782
|
+
inserted.push(enqueueTask(meshId, message, {
|
|
47783
|
+
...taskOpts,
|
|
47784
|
+
dependsOn,
|
|
47785
|
+
id: ids[i],
|
|
47786
|
+
...opts?.ownerRole ? { ownerRole: opts.ownerRole } : {}
|
|
47787
|
+
}));
|
|
47788
|
+
});
|
|
47789
|
+
return inserted;
|
|
47790
|
+
});
|
|
47791
|
+
}
|
|
47738
47792
|
function recordDirectDispatchTask(meshId, message, opts) {
|
|
47739
47793
|
const missionId = typeof opts.missionId === "string" ? opts.missionId.trim() : "";
|
|
47740
47794
|
const taskId = typeof opts.id === "string" ? opts.id.trim() : "";
|
|
@@ -48186,6 +48240,7 @@ Next step: ${nextStep}`;
|
|
|
48186
48240
|
var EVIDENCE_ONLY_WRAPPERS;
|
|
48187
48241
|
var GIT_MUTATION_SUBCOMMANDS;
|
|
48188
48242
|
var GIT_STASH_READONLY_SUBCOMMANDS;
|
|
48243
|
+
var MESH_TASK_GRAPH_MAX_TASKS;
|
|
48189
48244
|
var DEPENDENCY_FAILURE_TERMINALS;
|
|
48190
48245
|
var TERMINAL_TASK_STATUSES;
|
|
48191
48246
|
var lastCancelledTaskAssignment;
|
|
@@ -48262,6 +48317,7 @@ Next step: ${nextStep}`;
|
|
|
48262
48317
|
"prune"
|
|
48263
48318
|
]);
|
|
48264
48319
|
GIT_STASH_READONLY_SUBCOMMANDS = /* @__PURE__ */ new Set(["list", "show"]);
|
|
48320
|
+
MESH_TASK_GRAPH_MAX_TASKS = 50;
|
|
48265
48321
|
DEPENDENCY_FAILURE_TERMINALS = /* @__PURE__ */ new Set(["failed", "cancelled"]);
|
|
48266
48322
|
TERMINAL_TASK_STATUSES = /* @__PURE__ */ new Set(["completed", "failed", "cancelled"]);
|
|
48267
48323
|
lastCancelledTaskAssignment = /* @__PURE__ */ new Map();
|
|
@@ -49041,10 +49097,10 @@ Next step: ${nextStep}`;
|
|
|
49041
49097
|
this.migratedMeshIds.add(meshId);
|
|
49042
49098
|
const count = this.db.prepare("SELECT COUNT(*) AS count FROM mesh_queue WHERE mesh_id = ?").get(meshId);
|
|
49043
49099
|
if (count.count > 0) return;
|
|
49044
|
-
const
|
|
49045
|
-
if (!(0, import_fs6.existsSync)(
|
|
49100
|
+
const path56 = legacyQueuePath(meshId);
|
|
49101
|
+
if (!(0, import_fs6.existsSync)(path56)) return;
|
|
49046
49102
|
try {
|
|
49047
|
-
const entries = JSON.parse((0, import_fs6.readFileSync)(
|
|
49103
|
+
const entries = JSON.parse((0, import_fs6.readFileSync)(path56, "utf-8"));
|
|
49048
49104
|
if (!Array.isArray(entries)) return;
|
|
49049
49105
|
const insert = this.db.prepare(`
|
|
49050
49106
|
INSERT OR REPLACE INTO mesh_queue (
|
|
@@ -51176,10 +51232,10 @@ Next step: ${nextStep}`;
|
|
|
51176
51232
|
}
|
|
51177
51233
|
}
|
|
51178
51234
|
function readArchivedCounts(meshId) {
|
|
51179
|
-
const
|
|
51180
|
-
if (!(0, import_fs7.existsSync)(
|
|
51235
|
+
const path56 = getArchivedCountsPath(meshId);
|
|
51236
|
+
if (!(0, import_fs7.existsSync)(path56)) return { taskCompleted: 0, taskFailed: 0, taskStalled: 0, recoveryAttempted: 0, totalArchived: 0, lastArchivedAt: "" };
|
|
51181
51237
|
try {
|
|
51182
|
-
return JSON.parse((0, import_fs7.readFileSync)(
|
|
51238
|
+
return JSON.parse((0, import_fs7.readFileSync)(path56, "utf-8"));
|
|
51183
51239
|
} catch {
|
|
51184
51240
|
return { taskCompleted: 0, taskFailed: 0, taskStalled: 0, recoveryAttempted: 0, totalArchived: 0, lastArchivedAt: "" };
|
|
51185
51241
|
}
|
|
@@ -52629,7 +52685,7 @@ ${rules.join("\n")}`;
|
|
|
52629
52685
|
- **Match concurrency to task kind.** Read-only investigation (\`live_debug_readonly\`) carries no isolation or merge cost and is exempt from the one-write-per-node limit: dispatch every independent read-only task at once, up to the read-only cap shown in Policy \u2014 they need neither a free node nor a worktree. Write tasks (\`code_change\`) are limited to ONE active task per node and each needs its OWN branch workspace, so clone a worktree per write task rather than queueing them onto one node \u2014 **or spreading them across base nodes, which is NOT a substitute**: a mesh with four base nodes still has zero branch isolation, because each base node is one shared checkout of the same branch. Ramp up cautiously only when tasks share a base branch or a submodule pointer, where landing order actually matters. Never launch a second session onto work already in flight for the same issue, and never duplicate a session because \`mesh_read_chat\` shows no final message while tool/terminal activity is ongoing. All of this is about *unrelated* work running side by side; it does not mean splitting one line of work across sessions \u2014 successive stages of the same investigation belong in the session that already has the context (see Workflow 3f).
|
|
52630
52686
|
- **Check history first.** Call \`mesh_task_history\` at session start to avoid duplicate work and inform recovery. On failure, read task history before retrying.
|
|
52631
52687
|
- **Don't reopen already-done work after a resume.** Before reopening a reported issue after context compaction or session resume, check current git state and recent session context. If another session has already completed the work, continue from the existing diff/commit instead of starting a duplicate investigation.
|
|
52632
|
-
- **Sequence shared-base-moving merges
|
|
52688
|
+
- **Sequence shared-base-moving merges \u2014 use \`mesh_refine_batch\` for two or more.** Merging one worktree advances another in-flight worktree's base \u2014 especially a shared submodule pointer \u2014 turning a clean fast-forward into a diverged rebase. When you have 2+ sibling worktrees to land, pass them to \`mesh_refine_batch\` (dry-run first) instead of calling \`mesh_refine_node\` once per node: it picks a conflict-aware order (non-submodule first, submodule-touching serialized last), and because each node re-resolves the base and auto-rebases before its own gates, siblings that fall behind are rebased for you rather than by hand. It also avoids the \`base_locked\` contention that concurrent single-node refines cause. It is not a conflict solver \u2014 a real content or submodule conflict still lands that node in \`blocked_review\` for manual resolution while the rest of the batch proceeds. Only drop to per-node \`mesh_refine_node\` for a single branch, or to hand-resolve a node the batch reported blocked.
|
|
52633
52689
|
- **Converge branches.** After worktree tasks: refine/fast-forward, or classify as \`pushed_feature_branch_needs_merge\` / \`blocked_review\` / \`cleanup_candidate\` / \`not_mergeable\`. Clean up with \`mesh_remove_node\`.
|
|
52634
52690
|
- **Refinery is config-driven.** \`mesh_refine_node\` must run validation from \`.adhdev/refine.{json,yaml,yml}\` or \`repo-mesh.refine.*\`. Heuristics are scaffolding only.
|
|
52635
52691
|
- **Submodule reachability = publish-needed.** \`submodule_reachability_failed\` \u2192 classify as \`blocked_review\`, request user approval to push to submodule main, then rerun \`mesh_refine_node\`.
|
|
@@ -52679,6 +52735,7 @@ When you compose the task message you dispatch to a node, include this requireme
|
|
|
52679
52735
|
| \`mesh_status\` | Check all nodes' health, git state, active sessions, and branch convergence |
|
|
52680
52736
|
| \`mesh_list_nodes\` | List nodes with workspace paths |
|
|
52681
52737
|
| \`mesh_enqueue_task\` | Add a task to the pull-based work queue; idle nodes auto-claim |
|
|
52738
|
+
| \`mesh_enqueue_batch\` | Atomically enqueue a dependency-wired SET of tasks (all-or-nothing \u2014 a mid-batch error rolls the whole batch back); \`depends_on\` may name batch-local \`ref\` labels, forward references allowed |
|
|
52682
52739
|
| \`mesh_view_queue\` | View queue status \u2014 pending, assigned, completed, failed, cancelled tasks |
|
|
52683
52740
|
| \`mesh_queue_cancel\` | Cancel a queue task without deleting audit history |
|
|
52684
52741
|
| \`mesh_queue_requeue\` | Return a task to pending for retry; clears stale session targets |
|
|
@@ -52736,7 +52793,7 @@ Before doing any coordinator work, confirm that the actual callable tool list in
|
|
|
52736
52793
|
WORKFLOW_SECTION = `## Orchestration Workflow
|
|
52737
52794
|
|
|
52738
52795
|
1. **Assess** \u2014 Call \`mesh_status\` to see which nodes are healthy and available. Check \`mesh_task_history\` to understand what has already been done in this mesh \u2014 previous delegations, completions, and failures.
|
|
52739
|
-
2. **Plan** \u2014 Decompose the user's request into independent tasks for parallel execution, or sequential tasks when dependencies exist. If \`mesh_task_history\` shows a recent failure for a task, decide whether to retry or reassign. **For multi-task work, create a mission first**: call \`mesh_mission_upsert\` with a title and goal, then attach every enqueued task with \`mission_id\`. Express "B after A" ordering with \`depends_on\` on the queue task instead of waiting and polling \u2014 the system claims dependents automatically when their dependencies complete. When the mission's outcome is decided, update its status (\`completed\`/\`abandoned\`) via \`mesh_mission_upsert\`. If the prompt already shows an **Active Mission**, continue it from its current task state \u2014 do not re-enqueue tasks that already exist.
|
|
52796
|
+
2. **Plan** \u2014 Decompose the user's request into independent tasks for parallel execution, or sequential tasks when dependencies exist. If \`mesh_task_history\` shows a recent failure for a task, decide whether to retry or reassign. **For multi-task work, create a mission first**: call \`mesh_mission_upsert\` with a title and goal, then attach every enqueued task with \`mission_id\`. Express "B after A" ordering with \`depends_on\` on the queue task instead of waiting and polling \u2014 the system claims dependents automatically when their dependencies complete. When the plan is a multi-task graph, submit it with ONE \`mesh_enqueue_batch\` call instead of N sequential enqueues: the batch inserts atomically (a mid-batch error such as a cycle or bad difficulty rolls the whole set back, so no half-registered chain), and each task's \`depends_on\` may name sibling tasks by their batch-local \`ref\` label, forward references included. When the mission's outcome is decided, update its status (\`completed\`/\`abandoned\`) via \`mesh_mission_upsert\`. If the prompt already shows an **Active Mission**, continue it from its current task state \u2014 do not re-enqueue tasks that already exist.
|
|
52740
52797
|
3. **Queue / Delegate** \u2014 The Mesh uses an autonomous pull-based Work Queue:
|
|
52741
52798
|
a. **General Tasks**: Enqueue tasks using \`mesh_enqueue_task\`. Idle node agents will automatically pull tasks from the queue and begin working.
|
|
52742
52799
|
b. **Node Preparation**: Reuse an existing idle session on the correct node/provider before launching a new chat/session. Call \`mesh_launch_session\` only when no suitable session exists, when the user explicitly asks for a fresh provider/session, or when branch/worktree isolation requires it. **A node is not limited to one live session for read-only work** \u2014 \`readonly\`/\`live_debug_readonly\` tasks are exempt from the one-active-per-node invariant, so the SAME node can auto-launch multiple concurrent read-only sessions with no worktree needed. Cloning a worktree costs roughly 10 seconds, so it is cheap enough to create one whenever write work needs a free node; use it for branch isolation, for parallel write tasks (one active write per node), or when a node's read-only queue is deep enough that a second node would clearly finish faster \u2014 call \`mesh_clone_node\` to create the worktree node first.
|
|
@@ -52753,7 +52810,7 @@ Before doing any coordinator work, confirm that the actual callable tool list in
|
|
|
52753
52810
|
4. **Monitor** \u2014 Prefer event-driven completion/status notifications. Do **not** poll \`mesh_read_chat\` repeatedly. Do **not** repeatedly call \`mesh_status\` or \`mesh_view_queue\` just to wait for assigned/generating work. After dispatching a direct or queued task, send one progress update with the task/session handle, then stop. Wait for \`pendingCoordinatorEvents\` or another completion/approval/status signal, an explicit user status request, or a real timeout/stall signal before reading status/chat/queue again. Use at most one compact \`mesh_read_chat\` check after a terminal signal. Handle approvals via \`mesh_approve\`. **Proactively parallelize new work.** When the user reports a new bug or asks for new work, start it immediately if it is independent of in-flight tasks and there is headroom under \`maxParallelTasks\` \u2014 do not wait for a current task to finish or for the user to prompt you to parallelize. Read-only diagnosis (\`live_debug_readonly\`) has no isolation or merge cost, so dispatch it in parallel right away. The no-polling / concurrency-limit rules constrain *re-checking or duplicating already-dispatched work*; they are **not** a reason to defer starting a new, independent task.
|
|
52754
52811
|
5. **Verify** \u2014 When a task reports completion or git work is visible, call \`mesh_git_status\` to verify changes were made.
|
|
52755
52812
|
6. **Checkpoint** \u2014 Call \`mesh_checkpoint\` to save the work.
|
|
52756
|
-
7. **Converge branches** \u2014 Before marking any task complete, classify every touched node/branch into exactly one final state: \`merged_to_main\`, \`pushed_feature_branch_needs_merge\`, \`blocked_review\`, \`cleanup_candidate\`, or \`not_mergeable\`. Use \`mesh_status\` branchConvergenceSummary. For obvious clean branch catch-up (ahead 0, behind > 0, upstream fresh, no dirty/stash/submodule issues), use \`mesh_fast_forward_node\` dry-run first and execute only when explicitly safe/approved; this avoids consuming an agent session. Use \`mesh_refine_node\` for clean worktree branches when safe. Before/refine merging root commits that contain submodule gitlink changes, require each submodule commit to be reachable from the configured submodule remote main branch, not merely present on a feature ref or local checkout. If \`mesh_refine_node\` returns \`submodule_reachability_failed\` or publish-required evidence, keep the public convergence bucket as \`blocked_review\`; unless \`allowAutoPublishSubmoduleMainCommits\` is explicitly enabled and Refinery reports successful non-force publish plus post-publish verification, ask the user for explicit approval to push/publish the unreachable submodule commit(s) to submodule main, then rerun \`mesh_refine_node\`. Do not merge the root branch until the submodule commit(s) are reachable from submodule origin/main. A task that remains on a non-main branch is not fully complete unless the final report names the follow-up state and next step.
|
|
52813
|
+
7. **Converge branches** \u2014 Before marking any task complete, classify every touched node/branch into exactly one final state: \`merged_to_main\`, \`pushed_feature_branch_needs_merge\`, \`blocked_review\`, \`cleanup_candidate\`, or \`not_mergeable\`. Use \`mesh_status\` branchConvergenceSummary. For obvious clean branch catch-up (ahead 0, behind > 0, upstream fresh, no dirty/stash/submodule issues), use \`mesh_fast_forward_node\` dry-run first and execute only when explicitly safe/approved; this avoids consuming an agent session. Use \`mesh_refine_node\` for clean worktree branches when safe \u2014 but when 2+ sibling worktrees share a base, converge them with \`mesh_refine_batch\` rather than repeated single-node calls (see the sequencing rule in Rules). Before/refine merging root commits that contain submodule gitlink changes, require each submodule commit to be reachable from the configured submodule remote main branch, not merely present on a feature ref or local checkout. If \`mesh_refine_node\` returns \`submodule_reachability_failed\` or publish-required evidence, keep the public convergence bucket as \`blocked_review\`; unless \`allowAutoPublishSubmoduleMainCommits\` is explicitly enabled and Refinery reports successful non-force publish plus post-publish verification, ask the user for explicit approval to push/publish the unreachable submodule commit(s) to submodule main, then rerun \`mesh_refine_node\`. Do not merge the root branch until the submodule commit(s) are reachable from submodule origin/main. A task that remains on a non-main branch is not fully complete unless the final report names the follow-up state and next step.
|
|
52757
52814
|
8. **Clean up** \u2014 Remove worktree nodes via \`mesh_remove_node\` after their work is merged or no longer needed.
|
|
52758
52815
|
9. **Report** \u2014 Summarize what was done, what changed, any issues, and the branch convergence state.
|
|
52759
52816
|
|
|
@@ -53238,8 +53295,8 @@ When the user asks to **set up / configure / onboard** this repo for Repo Mesh (
|
|
|
53238
53295
|
if (rejectedCommands.length) errors.push("one or more validation commands are invalid");
|
|
53239
53296
|
return { valid: errors.length === 0, errors, bootstrapCommands, commands, rejectedCommands, bootstrapMode, deprecationWarnings };
|
|
53240
53297
|
}
|
|
53241
|
-
function parseConfigText3(
|
|
53242
|
-
if (/\.json$/i.test(
|
|
53298
|
+
function parseConfigText3(path56, text) {
|
|
53299
|
+
if (/\.json$/i.test(path56)) return JSON.parse(text);
|
|
53243
53300
|
return yaml3.load(text);
|
|
53244
53301
|
}
|
|
53245
53302
|
function loadMeshRefineConfig(mesh, workspace) {
|
|
@@ -53665,8 +53722,8 @@ When the user asks to **set up / configure / onboard** this repo for Repo Mesh (
|
|
|
53665
53722
|
const lines = porcelain.split(/\r?\n/).filter((line) => line.length > 0);
|
|
53666
53723
|
for (const line of lines) {
|
|
53667
53724
|
const status = line.slice(0, 2);
|
|
53668
|
-
const
|
|
53669
|
-
const isGitlinkPointerMove = (status === " M" || status === "M ") && submodulePaths.has(
|
|
53725
|
+
const path56 = line.slice(3).trim().replace(/\\/g, "/").replace(/\/+$/, "");
|
|
53726
|
+
const isGitlinkPointerMove = (status === " M" || status === "M ") && submodulePaths.has(path56);
|
|
53670
53727
|
if (!isGitlinkPointerMove) return false;
|
|
53671
53728
|
}
|
|
53672
53729
|
return true;
|
|
@@ -53701,8 +53758,8 @@ When the user asks to **set up / configure / onboard** this repo for Repo Mesh (
|
|
|
53701
53758
|
if (node?.worktreeBootstrap?.status !== "running") return false;
|
|
53702
53759
|
return !isWorktreeBootstrapStaleRunning(node, nowMs);
|
|
53703
53760
|
}
|
|
53704
|
-
function parseConfigText4(
|
|
53705
|
-
if (/\.json$/i.test(
|
|
53761
|
+
function parseConfigText4(path56, text) {
|
|
53762
|
+
if (/\.json$/i.test(path56)) return JSON.parse(text);
|
|
53706
53763
|
return yaml4.load(text);
|
|
53707
53764
|
}
|
|
53708
53765
|
function truncateOutput(value) {
|
|
@@ -54056,8 +54113,8 @@ When the user asks to **set up / configure / onboard** this repo for Repo Mesh (
|
|
|
54056
54113
|
}
|
|
54057
54114
|
const serverName = mcpConfig.serverName?.trim() || DEFAULT_SERVER_NAME;
|
|
54058
54115
|
if (mcpConfig.mode === "auto_import") {
|
|
54059
|
-
const
|
|
54060
|
-
if (!
|
|
54116
|
+
const path56 = mcpConfig.path?.trim();
|
|
54117
|
+
if (!path56) {
|
|
54061
54118
|
return { kind: "unsupported", reason: "Provider auto-import MCP config is missing a config path" };
|
|
54062
54119
|
}
|
|
54063
54120
|
const mcpServer = resolveAdhdevMcpServerLaunch({
|
|
@@ -54077,7 +54134,7 @@ When the user asks to **set up / configure / onboard** this repo for Repo Mesh (
|
|
|
54077
54134
|
return {
|
|
54078
54135
|
kind: "auto_import",
|
|
54079
54136
|
serverName,
|
|
54080
|
-
configPath: resolveMcpConfigPath(
|
|
54137
|
+
configPath: resolveMcpConfigPath(path56, workspace),
|
|
54081
54138
|
configFormat: mcpConfig.format,
|
|
54082
54139
|
mcpServer
|
|
54083
54140
|
};
|
|
@@ -54291,8 +54348,8 @@ ${rendered}`, "utf-8");
|
|
|
54291
54348
|
if (!(0, import_node_fs3.existsSync)(filePath)) return;
|
|
54292
54349
|
if (owned) {
|
|
54293
54350
|
try {
|
|
54294
|
-
const
|
|
54295
|
-
|
|
54351
|
+
const fs58 = require("fs");
|
|
54352
|
+
fs58.unlinkSync(filePath);
|
|
54296
54353
|
} catch {
|
|
54297
54354
|
}
|
|
54298
54355
|
return;
|
|
@@ -54305,8 +54362,8 @@ ${rendered}`, "utf-8");
|
|
|
54305
54362
|
const remaining = (existing.slice(0, openIdx) + existing.slice(closeIdx + CLOSE.length)).replace(/^\s*\n+/, "").replace(/\n+\s*$/, "");
|
|
54306
54363
|
if (!remaining.trim()) {
|
|
54307
54364
|
try {
|
|
54308
|
-
const
|
|
54309
|
-
|
|
54365
|
+
const fs58 = require("fs");
|
|
54366
|
+
fs58.unlinkSync(filePath);
|
|
54310
54367
|
} catch {
|
|
54311
54368
|
}
|
|
54312
54369
|
} else {
|
|
@@ -54421,10 +54478,10 @@ ${rendered}`, "utf-8");
|
|
|
54421
54478
|
return (0, import_path11.join)(getDaemonDataDir(), "mesh-coordinators.json");
|
|
54422
54479
|
}
|
|
54423
54480
|
function loadMeshCoordinatorRegistry() {
|
|
54424
|
-
const
|
|
54425
|
-
if (!(0, import_fs12.existsSync)(
|
|
54481
|
+
const path56 = getRegistryPath();
|
|
54482
|
+
if (!(0, import_fs12.existsSync)(path56)) return;
|
|
54426
54483
|
try {
|
|
54427
|
-
const raw = JSON.parse((0, import_fs12.readFileSync)(
|
|
54484
|
+
const raw = JSON.parse((0, import_fs12.readFileSync)(path56, "utf-8"));
|
|
54428
54485
|
if (!Array.isArray(raw)) return;
|
|
54429
54486
|
_registry.clear();
|
|
54430
54487
|
for (const entry of raw) {
|
|
@@ -61264,6 +61321,102 @@ The mesh has no work in flight. For each mission, decide its outcome: continue i
|
|
|
61264
61321
|
MAX_TRACKED_CLONED_NODES = 512;
|
|
61265
61322
|
}
|
|
61266
61323
|
});
|
|
61324
|
+
function quotaClaimBlockKey(meshId, observation) {
|
|
61325
|
+
return `${meshId}:${observation.nodeId}:${observation.sessionId}:${observation.providerType}`;
|
|
61326
|
+
}
|
|
61327
|
+
function quotaClaimBlockDescription(providerType, block2) {
|
|
61328
|
+
if (block2.reason === PROVIDER_QUOTA_EXHAUSTED_SKIP_REASON) {
|
|
61329
|
+
return `provider '${providerType}' reported quota exhausted`;
|
|
61330
|
+
}
|
|
61331
|
+
return `provider '${providerType}' had ${block2.remainingPercent.toFixed(1)}% ${block2.window} quota remaining (< ${block2.thresholdPercent}% threshold)`;
|
|
61332
|
+
}
|
|
61333
|
+
function rememberBounded(map3, key2, value) {
|
|
61334
|
+
map3.set(key2, value);
|
|
61335
|
+
if (map3.size > AUTO_LAUNCH_LEDGER_DEDUP_MAX) {
|
|
61336
|
+
const oldest = map3.keys().next().value;
|
|
61337
|
+
if (oldest !== void 0) map3.delete(oldest);
|
|
61338
|
+
}
|
|
61339
|
+
}
|
|
61340
|
+
function logQuotaClaimBlockTransition(meshId, observation) {
|
|
61341
|
+
const key2 = quotaClaimBlockKey(meshId, observation);
|
|
61342
|
+
const fingerprint = `${observation.block.reason}:${observation.block.window}:${observation.block.remainingPercent}:${observation.block.thresholdPercent}`;
|
|
61343
|
+
if (lastQuotaClaimBlockLog.get(key2) === fingerprint) return;
|
|
61344
|
+
rememberBounded(lastQuotaClaimBlockLog, key2, fingerprint);
|
|
61345
|
+
LOG2.info("MeshQueue", `QUOTA GATE: deferring queue claim for node ${observation.nodeId} (${observation.sessionId}): ${quotaClaimBlockDescription(observation.providerType, observation.block)} \u2014 trying remaining provider candidates; the task stays pending only if none can claim`);
|
|
61346
|
+
}
|
|
61347
|
+
function clearQuotaClaimBlockState(meshId, nodeId, sessionId, providerType) {
|
|
61348
|
+
lastQuotaClaimBlockLog.delete(quotaClaimBlockKey(meshId, { nodeId, sessionId, providerType }));
|
|
61349
|
+
}
|
|
61350
|
+
function logQuotaClaimFallbackSuccess(blocked, taskId, winner) {
|
|
61351
|
+
if (!blocked.length) return;
|
|
61352
|
+
const detail = blocked.map((item) => quotaClaimBlockDescription(item.providerType, item.block)).join("; ");
|
|
61353
|
+
LOG2.info("MeshQueue", `QUOTA GATE: queue claim fallback succeeded for task ${taskId}: ${detail} \u2192 provider '${winner.providerType}' claimed on node ${winner.nodeId} (${winner.sessionId})`);
|
|
61354
|
+
}
|
|
61355
|
+
function logAllQuotaClaimCandidatesBlocked(meshId, trace, pendingTaskIds) {
|
|
61356
|
+
if (!trace.blocked.length || trace.clear > 0 || trace.blocked.length !== trace.evaluated) return;
|
|
61357
|
+
const detail = trace.blocked.map((item) => `${item.nodeId}/${quotaClaimBlockDescription(item.providerType, item.block)}`).join("; ");
|
|
61358
|
+
const fingerprint = `${pendingTaskIds.slice().sort().join(",")}|${detail}`;
|
|
61359
|
+
if (lastAllQuotaClaimBlockedLog.get(meshId) === fingerprint) return;
|
|
61360
|
+
rememberBounded(lastAllQuotaClaimBlockedLog, meshId, fingerprint);
|
|
61361
|
+
LOG2.info("MeshQueue", `QUOTA GATE: every idle provider candidate was quota-gated for mesh ${meshId} (${detail}); task(s) ${pendingTaskIds.join(", ") || "pending"} remain queued until a quota window resets`);
|
|
61362
|
+
}
|
|
61363
|
+
function clearAllQuotaClaimCandidatesBlockedState(meshId) {
|
|
61364
|
+
lastAllQuotaClaimBlockedLog.delete(meshId);
|
|
61365
|
+
}
|
|
61366
|
+
function logAutoLaunchQuotaFallbackSuccess(resolved, taskId, nodeId, sessionId) {
|
|
61367
|
+
if (!resolved.providerType || !resolved.quotaGated?.length) return;
|
|
61368
|
+
const detail = resolved.quotaGated.map((item) => quotaClaimBlockDescription(item.providerType, item.block)).join("; ");
|
|
61369
|
+
LOG2.info("MeshQueue", `QUOTA GATE: auto-launch fallback succeeded for task ${taskId} on node ${nodeId}: ${detail} \u2192 spawned provider '${resolved.providerType}'${sessionId ? ` (${sessionId})` : ""}`);
|
|
61370
|
+
}
|
|
61371
|
+
function recordAutoLaunchEvent(meshId, args) {
|
|
61372
|
+
const dedupKey = `${meshId}:${args.taskId}`;
|
|
61373
|
+
const currentSig = `${args.phase}|${args.reason || ""}`;
|
|
61374
|
+
if (args.phase === "skipped" && lastAutoLaunchLedgerKey.get(dedupKey) === currentSig) {
|
|
61375
|
+
return;
|
|
61376
|
+
}
|
|
61377
|
+
lastAutoLaunchLedgerKey.set(dedupKey, currentSig);
|
|
61378
|
+
if (lastAutoLaunchLedgerKey.size > AUTO_LAUNCH_LEDGER_DEDUP_MAX) {
|
|
61379
|
+
const oldest = lastAutoLaunchLedgerKey.keys().next().value;
|
|
61380
|
+
if (oldest !== void 0) lastAutoLaunchLedgerKey.delete(oldest);
|
|
61381
|
+
}
|
|
61382
|
+
try {
|
|
61383
|
+
appendLedgerEntry(meshId, {
|
|
61384
|
+
kind: "session_auto_launch",
|
|
61385
|
+
nodeId: args.nodeId,
|
|
61386
|
+
sessionId: args.sessionId,
|
|
61387
|
+
providerType: args.providerType,
|
|
61388
|
+
// (B) promote taskId so this entry joins the task lifecycle timeline.
|
|
61389
|
+
...args.taskId ? { taskId: args.taskId } : {},
|
|
61390
|
+
payload: {
|
|
61391
|
+
phase: args.phase,
|
|
61392
|
+
taskId: args.taskId,
|
|
61393
|
+
reason: args.reason,
|
|
61394
|
+
error: args.error,
|
|
61395
|
+
// (D) resolved execution profile for the spawned worker.
|
|
61396
|
+
...args.model ? { resolvedModel: args.model } : {},
|
|
61397
|
+
...args.thinkingLevel ? { resolvedThinkingLevel: args.thinkingLevel } : {}
|
|
61398
|
+
}
|
|
61399
|
+
});
|
|
61400
|
+
} catch (e) {
|
|
61401
|
+
LOG2.warn("MeshQueue", `Failed to record auto-launch ledger event: ${e?.message || e}`);
|
|
61402
|
+
}
|
|
61403
|
+
}
|
|
61404
|
+
var lastQuotaClaimBlockLog;
|
|
61405
|
+
var lastAllQuotaClaimBlockedLog;
|
|
61406
|
+
var lastAutoLaunchLedgerKey;
|
|
61407
|
+
var AUTO_LAUNCH_LEDGER_DEDUP_MAX;
|
|
61408
|
+
var init_mesh_queue_observability = __esm2({
|
|
61409
|
+
"src/mesh/mesh-queue-observability.ts"() {
|
|
61410
|
+
"use strict";
|
|
61411
|
+
init_logger();
|
|
61412
|
+
init_mesh_ledger();
|
|
61413
|
+
init_mesh_quota_routing();
|
|
61414
|
+
lastQuotaClaimBlockLog = /* @__PURE__ */ new Map();
|
|
61415
|
+
lastAllQuotaClaimBlockedLog = /* @__PURE__ */ new Map();
|
|
61416
|
+
lastAutoLaunchLedgerKey = /* @__PURE__ */ new Map();
|
|
61417
|
+
AUTO_LAUNCH_LEDGER_DEDUP_MAX = 2e3;
|
|
61418
|
+
}
|
|
61419
|
+
});
|
|
61267
61420
|
function isActionableSkipReason(reason) {
|
|
61268
61421
|
if (!reason) return false;
|
|
61269
61422
|
return ACTIONABLE_SKIP_REASON_PREFIXES.some((prefix) => reason === prefix || reason.startsWith(prefix));
|
|
@@ -61349,8 +61502,8 @@ The mesh has no work in flight. For each mission, decide its outcome: continue i
|
|
|
61349
61502
|
nextAction: "Launch a session on that node yourself with mesh_launch_session, or ensure the remote daemon is connected over P2P."
|
|
61350
61503
|
};
|
|
61351
61504
|
if (reason.startsWith("provider") || reason === "missing_provider_priority") return {
|
|
61352
|
-
summary:
|
|
61353
|
-
nextAction: "Check the node's providerPriority policy and that the required CLI/ACP provider is installed and enabled on that machine."
|
|
61505
|
+
summary: `the current provider scan found no usable provider for this task (provider priority missing/unusable, or the provider loader is unavailable; ${reason})`,
|
|
61506
|
+
nextAction: "Check the node's providerPriority policy and that the required CLI/ACP provider is installed and enabled on that machine. Quota-gated candidates use a separate, self-resolving reason and are not proof of this configuration blocker."
|
|
61354
61507
|
};
|
|
61355
61508
|
if (reason === "dirty_workspace") return {
|
|
61356
61509
|
summary: "the node's workspace is dirty, so auto-launch is blocked to avoid clobbering uncommitted changes",
|
|
@@ -61399,7 +61552,8 @@ The mesh has no work in flight. For each mission, decide its outcome: continue i
|
|
|
61399
61552
|
const nodeLabel = readNonEmptyString(nodeId) || readNonEmptyString(task?.targetNodeId);
|
|
61400
61553
|
const evidence = reason === "target_session_pin_expired" ? resolveTaskDeliveryEvidence(meshId, taskId) : void 0;
|
|
61401
61554
|
const { summary, nextAction } = actionableSkipGuidance(reason, evidence);
|
|
61402
|
-
const
|
|
61555
|
+
const providerAvailabilityResult = reason.startsWith("provider") || reason === "missing_provider_priority";
|
|
61556
|
+
const closing = reason === "target_session_pin_expired" ? "The stale pin has already been cleared, so the task is now claimable by any compatible session \u2014 the action above is about the session it was originally addressed to." : providerAvailabilityResult ? "This result needs action if it persists: a later provider-status refresh or an already-starting usable session can clear it, but a genuinely missing, disabled, or misconfigured provider will keep the task pending until you fix that configuration." : "This is an actionable blocker \u2014 it will NOT clear on its own; the task stays pending until you resolve it.";
|
|
61403
61557
|
const coordinatorMessage = `[System] A queued mesh task${nodeLabel ? ` for node ${nodeLabel}` : ""} is not being dispatched because ${summary}. ${nextAction} ${closing}`;
|
|
61404
61558
|
try {
|
|
61405
61559
|
queuePendingMeshCoordinatorEvent({
|
|
@@ -61442,6 +61596,7 @@ The mesh has no work in flight. For each mission, decide its outcome: continue i
|
|
|
61442
61596
|
init_config();
|
|
61443
61597
|
init_slot_model_enforcement();
|
|
61444
61598
|
init_mesh_queue_assignment();
|
|
61599
|
+
init_mesh_queue_observability();
|
|
61445
61600
|
ACTIONABLE_SKIP_REASON_PREFIXES = [
|
|
61446
61601
|
"target_node_id_unmatched",
|
|
61447
61602
|
"no_node_satisfies_required_tags",
|
|
@@ -61972,7 +62127,7 @@ The mesh has no work in flight. For each mission, decide its outcome: continue i
|
|
|
61972
62127
|
return void 0;
|
|
61973
62128
|
}
|
|
61974
62129
|
}
|
|
61975
|
-
function tryAssignQueueTask(components, meshId, nodeId, sessionId, providerType, routingDecision) {
|
|
62130
|
+
function tryAssignQueueTask(components, meshId, nodeId, sessionId, providerType, routingDecision, quotaClaimTrace) {
|
|
61976
62131
|
const mesh = getMeshWithCache(components, meshId);
|
|
61977
62132
|
const node = mesh?.nodes.find((n) => meshNodeIdMatches(n, nodeId));
|
|
61978
62133
|
if (routingDecision?.source !== "autoLaunch") {
|
|
@@ -61983,14 +62138,15 @@ The mesh has no work in flight. For each mission, decide its outcome: continue i
|
|
|
61983
62138
|
return false;
|
|
61984
62139
|
}
|
|
61985
62140
|
const quotaClaimBlock = evaluateProviderQuotaGate(node, providerType, mesh?.policy?.quotaRouting ?? null, Date.now(), mesh);
|
|
62141
|
+
if (quotaClaimTrace) quotaClaimTrace.evaluated += 1;
|
|
61986
62142
|
if (quotaClaimBlock) {
|
|
61987
|
-
|
|
61988
|
-
|
|
61989
|
-
|
|
61990
|
-
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`);
|
|
61991
|
-
}
|
|
62143
|
+
const observation = { nodeId, sessionId, providerType, block: quotaClaimBlock };
|
|
62144
|
+
logQuotaClaimBlockTransition(meshId, observation);
|
|
62145
|
+
quotaClaimTrace?.blocked.push(observation);
|
|
61992
62146
|
return false;
|
|
61993
62147
|
}
|
|
62148
|
+
clearQuotaClaimBlockState(meshId, nodeId, sessionId, providerType);
|
|
62149
|
+
if (quotaClaimTrace) quotaClaimTrace.clear += 1;
|
|
61994
62150
|
const inlineBootstrapNode = (() => {
|
|
61995
62151
|
try {
|
|
61996
62152
|
const inlineMesh = components.router?.getCachedInlineMesh?.(meshId);
|
|
@@ -62049,6 +62205,12 @@ The mesh has no work in flight. For each mission, decide its outcome: continue i
|
|
|
62049
62205
|
if (!task) {
|
|
62050
62206
|
return false;
|
|
62051
62207
|
}
|
|
62208
|
+
if (quotaClaimTrace?.blocked.length) {
|
|
62209
|
+
logQuotaClaimFallbackSuccess(quotaClaimTrace.blocked, task.id, { nodeId, sessionId, providerType });
|
|
62210
|
+
quotaClaimTrace.blocked = [];
|
|
62211
|
+
quotaClaimTrace.evaluated = 0;
|
|
62212
|
+
quotaClaimTrace.clear = 0;
|
|
62213
|
+
}
|
|
62052
62214
|
const terminal = findTerminalLedgerEvidenceForTask({
|
|
62053
62215
|
meshId,
|
|
62054
62216
|
taskId: task.id
|
|
@@ -62397,39 +62559,6 @@ The mesh has no work in flight. For each mission, decide its outcome: continue i
|
|
|
62397
62559
|
return true;
|
|
62398
62560
|
});
|
|
62399
62561
|
}
|
|
62400
|
-
function recordAutoLaunchEvent(meshId, args) {
|
|
62401
|
-
const dedupKey = `${meshId}:${args.taskId}`;
|
|
62402
|
-
const currentSig = `${args.phase}|${args.reason || ""}`;
|
|
62403
|
-
if (args.phase === "skipped" && lastAutoLaunchLedgerKey.get(dedupKey) === currentSig) {
|
|
62404
|
-
return;
|
|
62405
|
-
}
|
|
62406
|
-
lastAutoLaunchLedgerKey.set(dedupKey, currentSig);
|
|
62407
|
-
if (lastAutoLaunchLedgerKey.size > AUTO_LAUNCH_LEDGER_DEDUP_MAX) {
|
|
62408
|
-
const oldest = lastAutoLaunchLedgerKey.keys().next().value;
|
|
62409
|
-
if (oldest !== void 0) lastAutoLaunchLedgerKey.delete(oldest);
|
|
62410
|
-
}
|
|
62411
|
-
try {
|
|
62412
|
-
appendLedgerEntry(meshId, {
|
|
62413
|
-
kind: "session_auto_launch",
|
|
62414
|
-
nodeId: args.nodeId,
|
|
62415
|
-
sessionId: args.sessionId,
|
|
62416
|
-
providerType: args.providerType,
|
|
62417
|
-
// (B) promote taskId so this entry joins the task lifecycle timeline.
|
|
62418
|
-
...args.taskId ? { taskId: args.taskId } : {},
|
|
62419
|
-
payload: {
|
|
62420
|
-
phase: args.phase,
|
|
62421
|
-
taskId: args.taskId,
|
|
62422
|
-
reason: args.reason,
|
|
62423
|
-
error: args.error,
|
|
62424
|
-
// (D) resolved execution profile for the spawned worker.
|
|
62425
|
-
...args.model ? { resolvedModel: args.model } : {},
|
|
62426
|
-
...args.thinkingLevel ? { resolvedThinkingLevel: args.thinkingLevel } : {}
|
|
62427
|
-
}
|
|
62428
|
-
});
|
|
62429
|
-
} catch (e) {
|
|
62430
|
-
LOG2.warn("MeshQueue", `Failed to record auto-launch ledger event: ${e?.message || e}`);
|
|
62431
|
-
}
|
|
62432
|
-
}
|
|
62433
62562
|
function markAutoLaunch(meshId, taskId, args) {
|
|
62434
62563
|
recordTaskAutoLaunch(meshId, taskId, {
|
|
62435
62564
|
status: args.status,
|
|
@@ -62529,6 +62658,7 @@ The mesh has no work in flight. For each mission, decide its outcome: continue i
|
|
|
62529
62658
|
});
|
|
62530
62659
|
return {
|
|
62531
62660
|
providerType: winner.providerType,
|
|
62661
|
+
...ranked.gated.length ? { quotaGated: ranked.gated } : {},
|
|
62532
62662
|
...winner.slot.model ? { model: winner.slot.model } : {},
|
|
62533
62663
|
...winner.slot.thinkingLevel ? { thinkingLevel: winner.slot.thinkingLevel } : {},
|
|
62534
62664
|
// The slot that won selection. Returned so the caller can enforce
|
|
@@ -62848,6 +62978,7 @@ The mesh has no work in flight. For each mission, decide its outcome: continue i
|
|
|
62848
62978
|
}
|
|
62849
62979
|
const remoteSessionId = readNonEmptyString(payload.sessionId) || readNonEmptyString(payload.id) || readNonEmptyString(payload.runtimeSessionId);
|
|
62850
62980
|
markAutoLaunch(meshId, task.id, { status: "completed", nodeId, providerType: resolved.providerType, sessionId: remoteSessionId || void 0, ...effectiveModel ? { model: effectiveModel } : {}, ...effectiveThinkingLevel ? { thinkingLevel: effectiveThinkingLevel } : {} });
|
|
62981
|
+
logAutoLaunchQuotaFallbackSuccess(resolved, task.id, nodeId, remoteSessionId || void 0);
|
|
62851
62982
|
autoLaunchCooldownUntil.set(launchKey, Date.now() + AUTO_LAUNCH_COOLDOWN_MS);
|
|
62852
62983
|
sweepExpiredCooldowns();
|
|
62853
62984
|
return true;
|
|
@@ -62878,6 +63009,7 @@ The mesh has no work in flight. For each mission, decide its outcome: continue i
|
|
|
62878
63009
|
return false;
|
|
62879
63010
|
}
|
|
62880
63011
|
markAutoLaunch(meshId, task.id, { status: "completed", nodeId, providerType: resolved.providerType, sessionId, ...effectiveModel ? { model: effectiveModel } : {}, ...effectiveThinkingLevel ? { thinkingLevel: effectiveThinkingLevel } : {} });
|
|
63012
|
+
logAutoLaunchQuotaFallbackSuccess(resolved, task.id, nodeId, sessionId);
|
|
62881
63013
|
await waitForLocalSessionReady(components, sessionId);
|
|
62882
63014
|
const requiredTags = Array.isArray(task.requiredTags) ? task.requiredTags.filter((t) => !!t) : [];
|
|
62883
63015
|
const routingDecision = {
|
|
@@ -62986,8 +63118,9 @@ The mesh has no work in flight. For each mission, decide its outcome: continue i
|
|
|
62986
63118
|
remoteCandidates.push({ nodeId: idle.nodeId, sessionId: idle.sessionId, providerType: idle.providerType, origin: "remote", node });
|
|
62987
63119
|
}
|
|
62988
63120
|
}
|
|
63121
|
+
const quotaClaimTrace = { blocked: [], evaluated: 0, clear: 0 };
|
|
62989
63122
|
const assignIdleCandidate = (candidate) => {
|
|
62990
|
-
const assigned = tryAssignQueueTask(components, meshId, candidate.nodeId, candidate.sessionId, candidate.providerType);
|
|
63123
|
+
const assigned = tryAssignQueueTask(components, meshId, candidate.nodeId, candidate.sessionId, candidate.providerType, void 0, quotaClaimTrace);
|
|
62991
63124
|
if (assigned && candidate.origin === "remote") {
|
|
62992
63125
|
try {
|
|
62993
63126
|
MeshRuntimeStore.getInstance().deleteRemoteIdleSession(meshId, candidate.nodeId, candidate.sessionId);
|
|
@@ -63030,6 +63163,11 @@ The mesh has no work in flight. For each mission, decide its outcome: continue i
|
|
|
63030
63163
|
nodeId: task.assignedNodeId,
|
|
63031
63164
|
sessionId: task.assignedSessionId
|
|
63032
63165
|
}));
|
|
63166
|
+
if (newlyAssignedTasks.length === 0 && !autoLaunchStarted) {
|
|
63167
|
+
logAllQuotaClaimCandidatesBlocked(meshId, quotaClaimTrace, afterQueue.filter((task) => task.status === "pending").map((task) => task.id));
|
|
63168
|
+
} else {
|
|
63169
|
+
clearAllQuotaClaimCandidatesBlockedState(meshId);
|
|
63170
|
+
}
|
|
63033
63171
|
const autoLaunchPending = autoLaunchStarted || afterQueue.some((task) => {
|
|
63034
63172
|
if (task.status !== "pending") return false;
|
|
63035
63173
|
const al = task.autoLaunch;
|
|
@@ -63081,8 +63219,6 @@ The mesh has no work in flight. For each mission, decide its outcome: continue i
|
|
|
63081
63219
|
var AUTO_LAUNCH_AWAIT_CLAIM_BACKOFF_CAP_CYCLES;
|
|
63082
63220
|
var AUTO_LAUNCH_REMOTE_IDLE_TTL_MS;
|
|
63083
63221
|
var autoLaunchAwaitClaimBackoff;
|
|
63084
|
-
var lastAutoLaunchLedgerKey;
|
|
63085
|
-
var AUTO_LAUNCH_LEDGER_DEDUP_MAX;
|
|
63086
63222
|
var init_mesh_queue_assignment = __esm2({
|
|
63087
63223
|
"src/mesh/mesh-queue-assignment.ts"() {
|
|
63088
63224
|
"use strict";
|
|
@@ -63115,6 +63251,7 @@ The mesh has no work in flight. For each mission, decide its outcome: continue i
|
|
|
63115
63251
|
init_mesh_auto_fast_forward();
|
|
63116
63252
|
init_mesh_skip_notify();
|
|
63117
63253
|
init_mesh_scheduling_fitness();
|
|
63254
|
+
init_mesh_queue_observability();
|
|
63118
63255
|
init_mesh_auto_fast_forward();
|
|
63119
63256
|
init_mesh_skip_notify();
|
|
63120
63257
|
init_mesh_scheduling_fitness();
|
|
@@ -63131,8 +63268,6 @@ The mesh has no work in flight. For each mission, decide its outcome: continue i
|
|
|
63131
63268
|
AUTO_LAUNCH_AWAIT_CLAIM_BACKOFF_CAP_CYCLES = 2;
|
|
63132
63269
|
AUTO_LAUNCH_REMOTE_IDLE_TTL_MS = 5 * 60 * 1e3;
|
|
63133
63270
|
autoLaunchAwaitClaimBackoff = /* @__PURE__ */ new Map();
|
|
63134
|
-
lastAutoLaunchLedgerKey = /* @__PURE__ */ new Map();
|
|
63135
|
-
AUTO_LAUNCH_LEDGER_DEDUP_MAX = 2e3;
|
|
63136
63271
|
}
|
|
63137
63272
|
});
|
|
63138
63273
|
function readSettings(state) {
|
|
@@ -67351,12 +67486,12 @@ ${cleanBody}`;
|
|
|
67351
67486
|
return !liveePaths.has(norm);
|
|
67352
67487
|
});
|
|
67353
67488
|
}
|
|
67354
|
-
function safeUnlink(
|
|
67489
|
+
function safeUnlink(path56) {
|
|
67355
67490
|
try {
|
|
67356
|
-
(0, import_fs16.unlinkSync)(
|
|
67491
|
+
(0, import_fs16.unlinkSync)(path56);
|
|
67357
67492
|
return true;
|
|
67358
67493
|
} catch (e) {
|
|
67359
|
-
LOG2.warn("DiskRetention", `Failed to delete ${
|
|
67494
|
+
LOG2.warn("DiskRetention", `Failed to delete ${path56}: ${e?.message || e}`);
|
|
67360
67495
|
return false;
|
|
67361
67496
|
}
|
|
67362
67497
|
}
|
|
@@ -67370,10 +67505,10 @@ ${cleanBody}`;
|
|
|
67370
67505
|
return [];
|
|
67371
67506
|
}
|
|
67372
67507
|
for (const name of names) {
|
|
67373
|
-
const
|
|
67508
|
+
const path56 = (0, import_path14.join)(dir, name);
|
|
67374
67509
|
try {
|
|
67375
|
-
const st = (0, import_fs16.statSync)(
|
|
67376
|
-
if (st.isFile()) out.push({ path:
|
|
67510
|
+
const st = (0, import_fs16.statSync)(path56);
|
|
67511
|
+
if (st.isFile()) out.push({ path: path56, mtimeMs: st.mtimeMs });
|
|
67377
67512
|
} catch {
|
|
67378
67513
|
}
|
|
67379
67514
|
}
|
|
@@ -70559,54 +70694,54 @@ ${cleanBody}`;
|
|
|
70559
70694
|
}
|
|
70560
70695
|
return errs;
|
|
70561
70696
|
}
|
|
70562
|
-
function validateCondition(c, sectionIds,
|
|
70697
|
+
function validateCondition(c, sectionIds, path56) {
|
|
70563
70698
|
const errs = [];
|
|
70564
70699
|
const w = c;
|
|
70565
70700
|
if ("all" in w) {
|
|
70566
|
-
w.all.forEach((x, i) => errs.push(...validateCondition(x, sectionIds, `${
|
|
70701
|
+
w.all.forEach((x, i) => errs.push(...validateCondition(x, sectionIds, `${path56}.all[${i}]`)));
|
|
70567
70702
|
return errs;
|
|
70568
70703
|
}
|
|
70569
70704
|
if ("any" in w) {
|
|
70570
|
-
w.any.forEach((x, i) => errs.push(...validateCondition(x, sectionIds, `${
|
|
70705
|
+
w.any.forEach((x, i) => errs.push(...validateCondition(x, sectionIds, `${path56}.any[${i}]`)));
|
|
70571
70706
|
return errs;
|
|
70572
70707
|
}
|
|
70573
70708
|
if ("not" in w) {
|
|
70574
|
-
errs.push(...validateCondition(w.not, sectionIds, `${
|
|
70709
|
+
errs.push(...validateCondition(w.not, sectionIds, `${path56}.not`));
|
|
70575
70710
|
return errs;
|
|
70576
70711
|
}
|
|
70577
70712
|
if ("matches" in w) {
|
|
70578
|
-
if (w.section && !sectionIds.has(w.section)) errs.push(`${
|
|
70713
|
+
if (w.section && !sectionIds.has(w.section)) errs.push(`${path56}.section "${w.section}" unknown`);
|
|
70579
70714
|
try {
|
|
70580
70715
|
new RegExp(w.matches, w.flags ?? "i");
|
|
70581
70716
|
} catch (e) {
|
|
70582
|
-
errs.push(`${
|
|
70717
|
+
errs.push(`${path56}.matches invalid regex: ${e.message}`);
|
|
70583
70718
|
}
|
|
70584
70719
|
return errs;
|
|
70585
70720
|
}
|
|
70586
70721
|
if ("cursor_above" in w && "changed" in w) return errs;
|
|
70587
70722
|
if ("signal" in w) {
|
|
70588
|
-
if (typeof w.signal !== "string" || !w.signal.trim()) errs.push(`${
|
|
70589
|
-
if (w.equals !== void 0 && typeof w.equals !== "boolean") errs.push(`${
|
|
70723
|
+
if (typeof w.signal !== "string" || !w.signal.trim()) errs.push(`${path56}.signal must be a non-empty string`);
|
|
70724
|
+
if (w.equals !== void 0 && typeof w.equals !== "boolean") errs.push(`${path56}.equals must be a boolean`);
|
|
70590
70725
|
return errs;
|
|
70591
70726
|
}
|
|
70592
70727
|
if ("elapsed_ms" in w) {
|
|
70593
|
-
if (typeof w.elapsed_ms !== "number") errs.push(`${
|
|
70728
|
+
if (typeof w.elapsed_ms !== "number") errs.push(`${path56}.elapsed_ms must be a number`);
|
|
70594
70729
|
return errs;
|
|
70595
70730
|
}
|
|
70596
70731
|
if ("stable_ms" in w) {
|
|
70597
|
-
if (typeof w.stable_ms !== "number") errs.push(`${
|
|
70598
|
-
if (w.section && !sectionIds.has(w.section)) errs.push(`${
|
|
70732
|
+
if (typeof w.stable_ms !== "number") errs.push(`${path56}.stable_ms must be a number`);
|
|
70733
|
+
if (w.section && !sectionIds.has(w.section)) errs.push(`${path56}.section "${w.section}" unknown`);
|
|
70599
70734
|
if (w.ignore_lines !== void 0) {
|
|
70600
|
-
if (typeof w.ignore_lines !== "string") errs.push(`${
|
|
70735
|
+
if (typeof w.ignore_lines !== "string") errs.push(`${path56}.ignore_lines must be a string`);
|
|
70601
70736
|
else try {
|
|
70602
70737
|
new RegExp(w.ignore_lines, "m");
|
|
70603
70738
|
} catch (e) {
|
|
70604
|
-
errs.push(`${
|
|
70739
|
+
errs.push(`${path56}.ignore_lines invalid regex: ${e.message}`);
|
|
70605
70740
|
}
|
|
70606
70741
|
}
|
|
70607
70742
|
return errs;
|
|
70608
70743
|
}
|
|
70609
|
-
errs.push(`${
|
|
70744
|
+
errs.push(`${path56} is not a recognized condition`);
|
|
70610
70745
|
return errs;
|
|
70611
70746
|
}
|
|
70612
70747
|
var fs17;
|
|
@@ -73168,8 +73303,8 @@ ${cleanBody}`;
|
|
|
73168
73303
|
let cwd = options.cwd;
|
|
73169
73304
|
if (cwd) {
|
|
73170
73305
|
try {
|
|
73171
|
-
const
|
|
73172
|
-
const stat2 =
|
|
73306
|
+
const fs58 = require("fs");
|
|
73307
|
+
const stat2 = fs58.statSync(cwd);
|
|
73173
73308
|
if (!stat2.isDirectory()) cwd = os15.homedir();
|
|
73174
73309
|
} catch {
|
|
73175
73310
|
cwd = os15.homedir();
|
|
@@ -78497,7 +78632,7 @@ ${lastSnapshot}`;
|
|
|
78497
78632
|
}
|
|
78498
78633
|
function canonicalize(p) {
|
|
78499
78634
|
try {
|
|
78500
|
-
const resolved =
|
|
78635
|
+
const resolved = path46.resolve(p);
|
|
78501
78636
|
try {
|
|
78502
78637
|
return nodeFs.realpathSync.native ? nodeFs.realpathSync.native(resolved) : nodeFs.realpathSync(resolved);
|
|
78503
78638
|
} catch {
|
|
@@ -78517,7 +78652,7 @@ ${lastSnapshot}`;
|
|
|
78517
78652
|
}
|
|
78518
78653
|
for (const root of _gatedRoots) {
|
|
78519
78654
|
if (normalized === root.rootPath) return root;
|
|
78520
|
-
if (normalized.startsWith(root.rootPath +
|
|
78655
|
+
if (normalized.startsWith(root.rootPath + path46.sep)) return root;
|
|
78521
78656
|
}
|
|
78522
78657
|
return null;
|
|
78523
78658
|
}
|
|
@@ -78536,16 +78671,16 @@ ${lastSnapshot}`;
|
|
|
78536
78671
|
};
|
|
78537
78672
|
}
|
|
78538
78673
|
function gatedRequire(request, parent, isMain, gated, originalLoad) {
|
|
78539
|
-
if (request.startsWith("./") || request.startsWith("../") ||
|
|
78674
|
+
if (request.startsWith("./") || request.startsWith("../") || path46.isAbsolute(request)) {
|
|
78540
78675
|
let resolved;
|
|
78541
78676
|
try {
|
|
78542
|
-
const callerRequire = parent?.filename ? (0, import_node_module2.createRequire)(parent.filename) : (0, import_node_module2.createRequire)(
|
|
78677
|
+
const callerRequire = parent?.filename ? (0, import_node_module2.createRequire)(parent.filename) : (0, import_node_module2.createRequire)(path46.join(gated.rootPath, "__entry__.js"));
|
|
78543
78678
|
resolved = callerRequire.resolve(request);
|
|
78544
78679
|
} catch {
|
|
78545
78680
|
return originalLoad.call(this, request, parent, isMain);
|
|
78546
78681
|
}
|
|
78547
78682
|
const resolvedCanon = canonicalize(resolved) || resolved;
|
|
78548
|
-
if (!(resolvedCanon === gated.rootPath || resolvedCanon.startsWith(gated.rootPath +
|
|
78683
|
+
if (!(resolvedCanon === gated.rootPath || resolvedCanon.startsWith(gated.rootPath + path46.sep))) {
|
|
78549
78684
|
denyRequire(request, parent, `relative path escapes provider root (resolved to ${resolvedCanon})`);
|
|
78550
78685
|
}
|
|
78551
78686
|
return originalLoad.call(this, request, parent, isMain);
|
|
@@ -78569,7 +78704,7 @@ ${lastSnapshot}`;
|
|
|
78569
78704
|
err.callerFilename = caller;
|
|
78570
78705
|
throw err;
|
|
78571
78706
|
}
|
|
78572
|
-
var
|
|
78707
|
+
var path46;
|
|
78573
78708
|
var import_node_module2;
|
|
78574
78709
|
var nodeFs;
|
|
78575
78710
|
var nodeChildProcess;
|
|
@@ -78590,7 +78725,7 @@ ${lastSnapshot}`;
|
|
|
78590
78725
|
var init_require_whitelist = __esm2({
|
|
78591
78726
|
"src/providers/sdk/v1/sandbox/require-whitelist.ts"() {
|
|
78592
78727
|
"use strict";
|
|
78593
|
-
|
|
78728
|
+
path46 = __toESM2(require("path"));
|
|
78594
78729
|
import_node_module2 = require("module");
|
|
78595
78730
|
nodeFs = __toESM2(require("fs"));
|
|
78596
78731
|
nodeChildProcess = __toESM2(require("child_process"));
|
|
@@ -79316,7 +79451,7 @@ ${lastSnapshot}`;
|
|
|
79316
79451
|
return _cliValidator;
|
|
79317
79452
|
}
|
|
79318
79453
|
function formatIssue(err) {
|
|
79319
|
-
const
|
|
79454
|
+
const path56 = err.instancePath || "";
|
|
79320
79455
|
const params = err.params;
|
|
79321
79456
|
let message = err.message || "validation failed";
|
|
79322
79457
|
let allowed;
|
|
@@ -79334,7 +79469,7 @@ ${lastSnapshot}`;
|
|
|
79334
79469
|
} else if (err.keyword === "type") {
|
|
79335
79470
|
message = `must be ${params.type}`;
|
|
79336
79471
|
}
|
|
79337
|
-
return { path:
|
|
79472
|
+
return { path: path56, keyword: err.keyword, message, ...allowed !== void 0 ? { allowed } : {} };
|
|
79338
79473
|
}
|
|
79339
79474
|
function validateCliProviderManifest(manifest) {
|
|
79340
79475
|
const validator = getCliValidator();
|
|
@@ -79445,6 +79580,7 @@ ${lastSnapshot}`;
|
|
|
79445
79580
|
MESH_REFINE_CONFIG_LOCATIONS: () => MESH_REFINE_CONFIG_LOCATIONS,
|
|
79446
79581
|
MESH_REFINE_CONFIG_SCHEMA: () => MESH_REFINE_CONFIG_SCHEMA,
|
|
79447
79582
|
MESH_SCHEDULING_STRATEGIES: () => MESH_SCHEDULING_STRATEGIES,
|
|
79583
|
+
MESH_TASK_GRAPH_MAX_TASKS: () => MESH_TASK_GRAPH_MAX_TASKS,
|
|
79448
79584
|
MESH_TASK_PRIORITIES: () => MESH_TASK_PRIORITIES,
|
|
79449
79585
|
MESH_WORKTREE_BOOTSTRAP_CONFIG_LOCATIONS: () => MESH_WORKTREE_BOOTSTRAP_CONFIG_LOCATIONS,
|
|
79450
79586
|
MESH_WORKTREE_BOOTSTRAP_CONFIG_SCHEMA: () => MESH_WORKTREE_BOOTSTRAP_CONFIG_SCHEMA,
|
|
@@ -79579,6 +79715,7 @@ ${lastSnapshot}`;
|
|
|
79579
79715
|
drainPendingMeshCoordinatorEvents: () => drainPendingMeshCoordinatorEvents,
|
|
79580
79716
|
encodeDuplicateMeshDispatchCode: () => encodeDuplicateMeshDispatchCode,
|
|
79581
79717
|
enqueueTask: () => enqueueTask,
|
|
79718
|
+
enqueueTaskGraph: () => enqueueTaskGraph,
|
|
79582
79719
|
ensureSessionHostReady: () => ensureSessionHostReady2,
|
|
79583
79720
|
evaluateFsm: () => evaluateFsm,
|
|
79584
79721
|
evaluateProviderQuotaGate: () => evaluateProviderQuotaGate,
|
|
@@ -81062,8 +81199,8 @@ ${lastSnapshot}`;
|
|
|
81062
81199
|
throw new Error(stderr || error48?.message || `git ${args[0]} failed`);
|
|
81063
81200
|
}
|
|
81064
81201
|
}
|
|
81065
|
-
async function canonicalPath(
|
|
81066
|
-
const absolute = (0, import_node_path2.resolve)(
|
|
81202
|
+
async function canonicalPath(path56) {
|
|
81203
|
+
const absolute = (0, import_node_path2.resolve)(path56);
|
|
81067
81204
|
try {
|
|
81068
81205
|
return await (0, import_promises4.realpath)(absolute);
|
|
81069
81206
|
} catch {
|
|
@@ -81586,51 +81723,51 @@ ${lastSnapshot}`;
|
|
|
81586
81723
|
}
|
|
81587
81724
|
var usageFileCache = /* @__PURE__ */ new Map();
|
|
81588
81725
|
function readUsageFile(meshId) {
|
|
81589
|
-
const
|
|
81726
|
+
const path56 = getUsagePath(meshId);
|
|
81590
81727
|
let stat2;
|
|
81591
81728
|
try {
|
|
81592
|
-
const s2 = (0, import_fs13.statSync)(
|
|
81729
|
+
const s2 = (0, import_fs13.statSync)(path56);
|
|
81593
81730
|
stat2 = { mtimeMs: s2.mtimeMs, size: s2.size };
|
|
81594
81731
|
} catch {
|
|
81595
|
-
usageFileCache.delete(
|
|
81732
|
+
usageFileCache.delete(path56);
|
|
81596
81733
|
return emptyFile(meshId);
|
|
81597
81734
|
}
|
|
81598
|
-
const cached5 = usageFileCache.get(
|
|
81735
|
+
const cached5 = usageFileCache.get(path56);
|
|
81599
81736
|
if (cached5 && cached5.mtimeMs === stat2.mtimeMs && cached5.size === stat2.size) {
|
|
81600
81737
|
return cached5.file;
|
|
81601
81738
|
}
|
|
81602
81739
|
try {
|
|
81603
|
-
const parsed = JSON.parse((0, import_fs13.readFileSync)(
|
|
81740
|
+
const parsed = JSON.parse((0, import_fs13.readFileSync)(path56, "utf-8"));
|
|
81604
81741
|
if (!parsed || typeof parsed !== "object" || !parsed.sessions) {
|
|
81605
|
-
usageFileCache.delete(
|
|
81742
|
+
usageFileCache.delete(path56);
|
|
81606
81743
|
return emptyFile(meshId);
|
|
81607
81744
|
}
|
|
81608
|
-
usageFileCache.set(
|
|
81745
|
+
usageFileCache.set(path56, { file: parsed, mtimeMs: stat2.mtimeMs, size: stat2.size });
|
|
81609
81746
|
return parsed;
|
|
81610
81747
|
} catch {
|
|
81611
|
-
usageFileCache.delete(
|
|
81748
|
+
usageFileCache.delete(path56);
|
|
81612
81749
|
return emptyFile(meshId);
|
|
81613
81750
|
}
|
|
81614
81751
|
}
|
|
81615
81752
|
function writeUsageFile(meshId, file2) {
|
|
81616
|
-
const
|
|
81617
|
-
const tmp = `${
|
|
81753
|
+
const path56 = getUsagePath(meshId);
|
|
81754
|
+
const tmp = `${path56}.tmp`;
|
|
81618
81755
|
(0, import_fs13.writeFileSync)(tmp, JSON.stringify(file2), { encoding: "utf-8", mode: 384 });
|
|
81619
81756
|
try {
|
|
81620
|
-
(0, import_fs13.renameSync)(tmp,
|
|
81757
|
+
(0, import_fs13.renameSync)(tmp, path56);
|
|
81621
81758
|
} catch (e) {
|
|
81622
81759
|
try {
|
|
81623
81760
|
(0, import_fs13.unlinkSync)(tmp);
|
|
81624
81761
|
} catch {
|
|
81625
81762
|
}
|
|
81626
|
-
usageFileCache.delete(
|
|
81763
|
+
usageFileCache.delete(path56);
|
|
81627
81764
|
throw e;
|
|
81628
81765
|
}
|
|
81629
81766
|
try {
|
|
81630
|
-
const s2 = (0, import_fs13.statSync)(
|
|
81631
|
-
usageFileCache.set(
|
|
81767
|
+
const s2 = (0, import_fs13.statSync)(path56);
|
|
81768
|
+
usageFileCache.set(path56, { file: file2, mtimeMs: s2.mtimeMs, size: s2.size });
|
|
81632
81769
|
} catch {
|
|
81633
|
-
usageFileCache.delete(
|
|
81770
|
+
usageFileCache.delete(path56);
|
|
81634
81771
|
}
|
|
81635
81772
|
}
|
|
81636
81773
|
function foldIntoRollup(rollup, entry) {
|
|
@@ -82124,19 +82261,19 @@ ${lastSnapshot}`;
|
|
|
82124
82261
|
return null;
|
|
82125
82262
|
}
|
|
82126
82263
|
async function detectIDEs(providerLoader) {
|
|
82127
|
-
const
|
|
82264
|
+
const os31 = (0, import_os3.platform)();
|
|
82128
82265
|
const results = [];
|
|
82129
82266
|
for (const def of getMergedDefinitions()) {
|
|
82130
82267
|
const cliPath = findCliCommand(providerLoader?.getIdeCliCommand(def.id, def.cli) || def.cli);
|
|
82131
|
-
const appPath = checkPathExists(providerLoader?.getIdePathCandidates(def.id, def.paths[
|
|
82268
|
+
const appPath = checkPathExists(providerLoader?.getIdePathCandidates(def.id, def.paths[os31] || []) || []);
|
|
82132
82269
|
let resolvedCli = cliPath;
|
|
82133
|
-
if (!resolvedCli && appPath &&
|
|
82270
|
+
if (!resolvedCli && appPath && os31 === "darwin") {
|
|
82134
82271
|
const bundledCli = `${appPath}/Contents/Resources/app/bin/${def.cli}`;
|
|
82135
82272
|
if ((0, import_fs17.existsSync)(bundledCli)) resolvedCli = bundledCli;
|
|
82136
82273
|
}
|
|
82137
|
-
if (!resolvedCli && appPath &&
|
|
82138
|
-
const { dirname:
|
|
82139
|
-
const appDir =
|
|
82274
|
+
if (!resolvedCli && appPath && os31 === "win32") {
|
|
82275
|
+
const { dirname: dirname24 } = await import("path");
|
|
82276
|
+
const appDir = dirname24(appPath);
|
|
82140
82277
|
const candidates = [
|
|
82141
82278
|
`${appDir}\\\\bin\\\\${def.cli}.cmd`,
|
|
82142
82279
|
`${appDir}\\\\bin\\\\${def.cli}`,
|
|
@@ -82151,7 +82288,7 @@ ${lastSnapshot}`;
|
|
|
82151
82288
|
}
|
|
82152
82289
|
}
|
|
82153
82290
|
}
|
|
82154
|
-
const installed =
|
|
82291
|
+
const installed = os31 === "darwin" ? !!(resolvedCli || appPath) : !!resolvedCli;
|
|
82155
82292
|
const version2 = null;
|
|
82156
82293
|
results.push({
|
|
82157
82294
|
id: def.id,
|
|
@@ -90374,8 +90511,8 @@ ${effect.notification.body || ""}`.trim();
|
|
|
90374
90511
|
* own upstream cache and never writes into another instance's store.
|
|
90375
90512
|
*/
|
|
90376
90513
|
getUpstreamInstallRoot() {
|
|
90377
|
-
const
|
|
90378
|
-
return
|
|
90514
|
+
const path56 = require("path");
|
|
90515
|
+
return path56.join(getConfigDir2(), "providers", ".upstream");
|
|
90379
90516
|
}
|
|
90380
90517
|
/**
|
|
90381
90518
|
* Install (activate) a provider from the VERIFIED CHANNEL.
|
|
@@ -90458,19 +90595,19 @@ ${effect.notification.body || ""}`.trim();
|
|
|
90458
90595
|
if (!["cli", "ide", "extension", "acp"].includes(category)) {
|
|
90459
90596
|
return { success: false, error: `unknown category: ${category}` };
|
|
90460
90597
|
}
|
|
90461
|
-
const
|
|
90462
|
-
const
|
|
90598
|
+
const fs58 = require("fs");
|
|
90599
|
+
const path56 = require("path");
|
|
90463
90600
|
try {
|
|
90464
90601
|
const installRoot = this.getUpstreamInstallRoot();
|
|
90465
|
-
const installRootResolved =
|
|
90466
|
-
const targetDir =
|
|
90467
|
-
if (!targetDir.startsWith(installRootResolved +
|
|
90602
|
+
const installRootResolved = path56.resolve(installRoot);
|
|
90603
|
+
const targetDir = path56.resolve(path56.join(installRoot, category, type2));
|
|
90604
|
+
if (!targetDir.startsWith(installRootResolved + path56.sep)) {
|
|
90468
90605
|
return { success: false, error: "refusing to delete outside upstream root" };
|
|
90469
90606
|
}
|
|
90470
|
-
if (!
|
|
90607
|
+
if (!fs58.existsSync(targetDir)) {
|
|
90471
90608
|
return { success: false, error: "not installed" };
|
|
90472
90609
|
}
|
|
90473
|
-
|
|
90610
|
+
fs58.rmSync(targetDir, { recursive: true, force: true });
|
|
90474
90611
|
try {
|
|
90475
90612
|
this._ctx.providerLoader?.deactivateVerifiedChannel?.(type2);
|
|
90476
90613
|
} catch {
|
|
@@ -90490,28 +90627,28 @@ ${effect.notification.body || ""}`.trim();
|
|
|
90490
90627
|
* the UI and by the update checker.
|
|
90491
90628
|
*/
|
|
90492
90629
|
handleListInstalledProviders(_args) {
|
|
90493
|
-
const
|
|
90494
|
-
const
|
|
90630
|
+
const fs58 = require("fs");
|
|
90631
|
+
const path56 = require("path");
|
|
90495
90632
|
const installRoot = this.getUpstreamInstallRoot();
|
|
90496
|
-
if (!
|
|
90633
|
+
if (!fs58.existsSync(installRoot)) return { success: true, providers: [] };
|
|
90497
90634
|
const CATEGORIES = ["cli", "ide", "extension", "acp"];
|
|
90498
90635
|
const items = [];
|
|
90499
90636
|
for (const category of CATEGORIES) {
|
|
90500
|
-
const categoryDir =
|
|
90501
|
-
if (!
|
|
90637
|
+
const categoryDir = path56.join(installRoot, category);
|
|
90638
|
+
if (!fs58.existsSync(categoryDir)) continue;
|
|
90502
90639
|
let entries;
|
|
90503
90640
|
try {
|
|
90504
|
-
entries =
|
|
90641
|
+
entries = fs58.readdirSync(categoryDir);
|
|
90505
90642
|
} catch {
|
|
90506
90643
|
continue;
|
|
90507
90644
|
}
|
|
90508
90645
|
for (const type2 of entries) {
|
|
90509
|
-
const v1Path =
|
|
90510
|
-
const v0Path =
|
|
90511
|
-
const manifestPath =
|
|
90646
|
+
const v1Path = path56.join(categoryDir, type2, "provider.v1.json");
|
|
90647
|
+
const v0Path = path56.join(categoryDir, type2, "provider.json");
|
|
90648
|
+
const manifestPath = fs58.existsSync(v1Path) ? v1Path : fs58.existsSync(v0Path) ? v0Path : null;
|
|
90512
90649
|
if (!manifestPath) continue;
|
|
90513
90650
|
try {
|
|
90514
|
-
const m = JSON.parse(
|
|
90651
|
+
const m = JSON.parse(fs58.readFileSync(manifestPath, "utf-8"));
|
|
90515
90652
|
const modelOptions = Array.isArray(m.modelOptions) ? m.modelOptions.filter((x) => typeof x === "string" && !!x.trim()) : [];
|
|
90516
90653
|
const thinkingLevelOptions = Array.isArray(m.thinkingLevelOptions) ? m.thinkingLevelOptions.filter((x) => typeof x === "string" && !!x.trim()) : [];
|
|
90517
90654
|
items.push({
|
|
@@ -90732,8 +90869,8 @@ ${effect.notification.body || ""}`.trim();
|
|
|
90732
90869
|
if (!/^@[a-z0-9_-]+$/i.test(requestedName)) {
|
|
90733
90870
|
return { success: false, error: "name must match @[a-z0-9_-]+" };
|
|
90734
90871
|
}
|
|
90735
|
-
const
|
|
90736
|
-
const
|
|
90872
|
+
const fs58 = require("fs");
|
|
90873
|
+
const path56 = require("path");
|
|
90737
90874
|
const { spawnSync: spawnSync3 } = require("child_process");
|
|
90738
90875
|
const file2 = ext.loadExternalSources();
|
|
90739
90876
|
if (file2.sources.some((s2) => s2.name === requestedName)) {
|
|
@@ -90742,9 +90879,9 @@ ${effect.notification.body || ""}`.trim();
|
|
|
90742
90879
|
if (file2.sources.some((s2) => s2.url === url2 && s2.ref === ref)) {
|
|
90743
90880
|
return { success: false, error: `source url+ref already registered (use a different name to track another ref)` };
|
|
90744
90881
|
}
|
|
90745
|
-
const sourceDir =
|
|
90746
|
-
if (!
|
|
90747
|
-
if (
|
|
90882
|
+
const sourceDir = path56.join(ext.externalRoot(), requestedName);
|
|
90883
|
+
if (!fs58.existsSync(ext.externalRoot())) fs58.mkdirSync(ext.externalRoot(), { recursive: true });
|
|
90884
|
+
if (fs58.existsSync(sourceDir)) {
|
|
90748
90885
|
return { success: false, error: `directory already exists: ${sourceDir} (rename or remove first)` };
|
|
90749
90886
|
}
|
|
90750
90887
|
const clone2 = spawnSync3("git", ["clone", "--depth=1", "--branch", ref, "--", url2, sourceDir], {
|
|
@@ -90754,7 +90891,7 @@ ${effect.notification.body || ""}`.trim();
|
|
|
90754
90891
|
});
|
|
90755
90892
|
if (clone2.status !== 0) {
|
|
90756
90893
|
try {
|
|
90757
|
-
|
|
90894
|
+
fs58.rmSync(sourceDir, { recursive: true, force: true });
|
|
90758
90895
|
} catch {
|
|
90759
90896
|
}
|
|
90760
90897
|
return { success: false, error: `git clone failed: ${(clone2.stderr || clone2.stdout || "").trim() || "unknown error"}` };
|
|
@@ -90798,15 +90935,15 @@ ${effect.notification.body || ""}`.trim();
|
|
|
90798
90935
|
const name = typeof args?.name === "string" ? args.name.trim() : "";
|
|
90799
90936
|
if (!name) return { success: false, error: "name is required" };
|
|
90800
90937
|
const ext = (init_external_sources(), __toCommonJS2(external_sources_exports));
|
|
90801
|
-
const
|
|
90802
|
-
const
|
|
90938
|
+
const fs58 = require("fs");
|
|
90939
|
+
const path56 = require("path");
|
|
90803
90940
|
const file2 = ext.loadExternalSources();
|
|
90804
90941
|
const match = file2.sources.find((s2) => s2.name === name);
|
|
90805
90942
|
if (!match) return { success: false, error: `source "${name}" not registered` };
|
|
90806
|
-
const sourceDir =
|
|
90807
|
-
if (
|
|
90943
|
+
const sourceDir = path56.join(ext.externalRoot(), name);
|
|
90944
|
+
if (fs58.existsSync(sourceDir)) {
|
|
90808
90945
|
try {
|
|
90809
|
-
|
|
90946
|
+
fs58.rmSync(sourceDir, { recursive: true, force: true });
|
|
90810
90947
|
} catch (e) {
|
|
90811
90948
|
return { success: false, error: `failed to delete ${sourceDir}: ${e?.message || e}` };
|
|
90812
90949
|
}
|
|
@@ -92973,6 +93110,7 @@ ${marker}`,
|
|
|
92973
93110
|
}
|
|
92974
93111
|
init_snapshot2();
|
|
92975
93112
|
init_build_info();
|
|
93113
|
+
init_track_identity();
|
|
92976
93114
|
init_coordinator_registry();
|
|
92977
93115
|
init_types();
|
|
92978
93116
|
init_deps();
|
|
@@ -93002,7 +93140,11 @@ ${marker}`,
|
|
|
93002
93140
|
return {
|
|
93003
93141
|
success: true,
|
|
93004
93142
|
status: snapshot,
|
|
93005
|
-
|
|
93143
|
+
// `track` is reported by the daemon that answered this command. It
|
|
93144
|
+
// must travel explicitly: version strings do not identify a release
|
|
93145
|
+
// track (stable can legitimately publish an rc), and an older daemon
|
|
93146
|
+
// that omits this field must remain "unknown" to remote consumers.
|
|
93147
|
+
daemonBuild: { ...getDaemonBuildInfo(), track: TRACK },
|
|
93006
93148
|
upgradeFailure: readUpgradeFailureNotice(),
|
|
93007
93149
|
providerChannelStaleness: ctx.deps.providerLoader?.getChannelStalenessSnapshot?.() ?? null
|
|
93008
93150
|
};
|
|
@@ -93126,24 +93268,24 @@ ${marker}`,
|
|
|
93126
93268
|
}
|
|
93127
93269
|
},
|
|
93128
93270
|
list_coordinator_prompts: async (_ctx, _args) => {
|
|
93129
|
-
const
|
|
93130
|
-
const
|
|
93271
|
+
const fs58 = await import("fs");
|
|
93272
|
+
const path56 = await import("path");
|
|
93131
93273
|
const { getConfigDir: getConfigDir22 } = await Promise.resolve().then(() => (init_config(), config_exports));
|
|
93132
|
-
const dir =
|
|
93274
|
+
const dir = path56.join(getConfigDir22(), "coordinator-prompts");
|
|
93133
93275
|
const entries = {};
|
|
93134
93276
|
try {
|
|
93135
|
-
if (
|
|
93136
|
-
for (const name of
|
|
93277
|
+
if (fs58.existsSync(dir)) {
|
|
93278
|
+
for (const name of fs58.readdirSync(dir)) {
|
|
93137
93279
|
const matchOverride = name.match(/^([a-zA-Z0-9_.-]+)\.md$/);
|
|
93138
93280
|
const matchAppend = name.match(/^([a-zA-Z0-9_.-]+)\.append\.md$/);
|
|
93139
93281
|
const m = matchAppend || matchOverride;
|
|
93140
93282
|
if (!m) continue;
|
|
93141
93283
|
const isAppend = !!matchAppend;
|
|
93142
93284
|
const key2 = m[1];
|
|
93143
|
-
const full =
|
|
93285
|
+
const full = path56.join(dir, name);
|
|
93144
93286
|
let content = "";
|
|
93145
93287
|
try {
|
|
93146
|
-
content =
|
|
93288
|
+
content = fs58.readFileSync(full, "utf8");
|
|
93147
93289
|
} catch {
|
|
93148
93290
|
}
|
|
93149
93291
|
if (!entries[key2]) entries[key2] = { override: "", append: "" };
|
|
@@ -93157,8 +93299,8 @@ ${marker}`,
|
|
|
93157
93299
|
return { success: true, dir, entries };
|
|
93158
93300
|
},
|
|
93159
93301
|
write_coordinator_prompt: async (_ctx, args) => {
|
|
93160
|
-
const
|
|
93161
|
-
const
|
|
93302
|
+
const fs58 = await import("fs");
|
|
93303
|
+
const path56 = await import("path");
|
|
93162
93304
|
const { getConfigDir: getConfigDir22 } = await Promise.resolve().then(() => (init_config(), config_exports));
|
|
93163
93305
|
const key2 = typeof args?.key === "string" ? args.key.trim() : "";
|
|
93164
93306
|
const kind = args?.kind === "append" ? "append" : "override";
|
|
@@ -93166,15 +93308,15 @@ ${marker}`,
|
|
|
93166
93308
|
if (!key2 || !/^[a-zA-Z0-9_.-]+$/.test(key2)) {
|
|
93167
93309
|
return { success: false, error: "key must match [a-zA-Z0-9_.-]+" };
|
|
93168
93310
|
}
|
|
93169
|
-
const dir =
|
|
93311
|
+
const dir = path56.join(getConfigDir22(), "coordinator-prompts");
|
|
93170
93312
|
const filename = kind === "append" ? `${key2}.append.md` : `${key2}.md`;
|
|
93171
|
-
const full =
|
|
93313
|
+
const full = path56.join(dir, filename);
|
|
93172
93314
|
try {
|
|
93173
|
-
|
|
93315
|
+
fs58.mkdirSync(dir, { recursive: true });
|
|
93174
93316
|
if (content.trim()) {
|
|
93175
|
-
|
|
93176
|
-
} else if (
|
|
93177
|
-
|
|
93317
|
+
fs58.writeFileSync(full, content, { encoding: "utf8", mode: 384 });
|
|
93318
|
+
} else if (fs58.existsSync(full)) {
|
|
93319
|
+
fs58.unlinkSync(full);
|
|
93178
93320
|
}
|
|
93179
93321
|
return { success: true, path: full, kind, key: key2 };
|
|
93180
93322
|
} catch (error48) {
|
|
@@ -104520,10 +104662,10 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
104520
104662
|
};
|
|
104521
104663
|
var import_child_process12 = require("child_process");
|
|
104522
104664
|
var net3 = __toESM2(require("net"));
|
|
104523
|
-
var
|
|
104665
|
+
var os27 = __toESM2(require("os"));
|
|
104666
|
+
var path48 = __toESM2(require("path"));
|
|
104667
|
+
var fs43 = __toESM2(require("fs"));
|
|
104524
104668
|
var path47 = __toESM2(require("path"));
|
|
104525
|
-
var fs422 = __toESM2(require("fs"));
|
|
104526
|
-
var path46 = __toESM2(require("path"));
|
|
104527
104669
|
var chokidar = __toESM2(require_chokidar());
|
|
104528
104670
|
init_logger();
|
|
104529
104671
|
init_auto_approve_modes();
|
|
@@ -104989,9 +105131,9 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
104989
105131
|
init_external_sources();
|
|
104990
105132
|
init_config();
|
|
104991
105133
|
init_native_history_executor();
|
|
104992
|
-
var
|
|
104993
|
-
var
|
|
104994
|
-
var
|
|
105134
|
+
var fs38 = __toESM2(require("fs"));
|
|
105135
|
+
var os26 = __toESM2(require("os"));
|
|
105136
|
+
var path422 = __toESM2(require("path"));
|
|
104995
105137
|
var fs33 = __toESM2(require("fs"));
|
|
104996
105138
|
var path37 = __toESM2(require("path"));
|
|
104997
105139
|
init_usage_normalize();
|
|
@@ -105174,17 +105316,17 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
105174
105316
|
}
|
|
105175
105317
|
function readSession(sessionPath) {
|
|
105176
105318
|
if (!sessionPath || !path37.isAbsolute(sessionPath)) return null;
|
|
105177
|
-
const
|
|
105178
|
-
if (!isSafeSessionId(
|
|
105319
|
+
const basename20 = path37.basename(sessionPath, ".jsonl");
|
|
105320
|
+
if (!isSafeSessionId(basename20)) return null;
|
|
105179
105321
|
if (!fs33.existsSync(sessionPath)) return null;
|
|
105180
105322
|
const sourceMtimeMs = statMtimeMs(sessionPath);
|
|
105181
|
-
const { messages, usageRecords } = parseTranscriptFile(sessionPath,
|
|
105323
|
+
const { messages, usageRecords } = parseTranscriptFile(sessionPath, basename20);
|
|
105182
105324
|
if (messages.length === 0) return null;
|
|
105183
105325
|
const firstSystem = messages.find((m) => m.kind === "session_start");
|
|
105184
105326
|
const workspace = firstSystem?.workspace || firstSystem?.content || void 0;
|
|
105185
105327
|
const session = {
|
|
105186
105328
|
messages,
|
|
105187
|
-
providerSessionId:
|
|
105329
|
+
providerSessionId: basename20,
|
|
105188
105330
|
source: "provider-native",
|
|
105189
105331
|
sourcePath: sessionPath,
|
|
105190
105332
|
sourceMtimeMs,
|
|
@@ -105193,7 +105335,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
105193
105335
|
};
|
|
105194
105336
|
if (usageRecords.length > 0) {
|
|
105195
105337
|
session.usage = foldUsageRecords(usageRecords, {
|
|
105196
|
-
providerSessionId:
|
|
105338
|
+
providerSessionId: basename20,
|
|
105197
105339
|
agent: "claude-cli"
|
|
105198
105340
|
});
|
|
105199
105341
|
}
|
|
@@ -105488,8 +105630,8 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
105488
105630
|
if (!fs34.existsSync(sessionPath)) return null;
|
|
105489
105631
|
const meta3 = readSessionMeta(sessionPath);
|
|
105490
105632
|
const metaId = String(meta3?.id ?? "").trim();
|
|
105491
|
-
const
|
|
105492
|
-
const uuidMatch =
|
|
105633
|
+
const basename20 = path38.basename(sessionPath, ".jsonl");
|
|
105634
|
+
const uuidMatch = basename20.match(/([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})/i);
|
|
105493
105635
|
const filenameUuid2 = uuidMatch ? uuidMatch[1] : "";
|
|
105494
105636
|
if (metaId && filenameUuid2 && metaId !== filenameUuid2) return null;
|
|
105495
105637
|
const sessionId = metaId || filenameUuid2;
|
|
@@ -106389,6 +106531,240 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
106389
106531
|
if (s2 === "tool" || s2 === "tool_result" || s2 === "function") return "assistant";
|
|
106390
106532
|
return "system";
|
|
106391
106533
|
}
|
|
106534
|
+
var fs37 = __toESM2(require("fs"));
|
|
106535
|
+
var path41 = __toESM2(require("path"));
|
|
106536
|
+
var os25 = __toESM2(require("os"));
|
|
106537
|
+
function grokSessionsRoot() {
|
|
106538
|
+
const home = process.env.GROK_HOME && process.env.GROK_HOME.trim() ? process.env.GROK_HOME.trim() : path41.join(os25.homedir(), ".grok");
|
|
106539
|
+
return path41.join(home, "sessions");
|
|
106540
|
+
}
|
|
106541
|
+
function encodeWorkspaceDir(workspace) {
|
|
106542
|
+
return encodeURIComponent(workspace);
|
|
106543
|
+
}
|
|
106544
|
+
function statMtimeMs5(filePath) {
|
|
106545
|
+
try {
|
|
106546
|
+
return fs37.statSync(filePath).mtimeMs;
|
|
106547
|
+
} catch {
|
|
106548
|
+
return 0;
|
|
106549
|
+
}
|
|
106550
|
+
}
|
|
106551
|
+
function isUuidLike2(value) {
|
|
106552
|
+
return /^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$/.test(value);
|
|
106553
|
+
}
|
|
106554
|
+
function workspaceCandidates(workspace) {
|
|
106555
|
+
const out = [workspace];
|
|
106556
|
+
try {
|
|
106557
|
+
const real = fs37.realpathSync(workspace);
|
|
106558
|
+
if (real && real !== workspace) out.push(real);
|
|
106559
|
+
} catch {
|
|
106560
|
+
}
|
|
106561
|
+
return out;
|
|
106562
|
+
}
|
|
106563
|
+
function resolveGrokPath(workspace, sessionId) {
|
|
106564
|
+
if (!sessionId || !isUuidLike2(sessionId)) return null;
|
|
106565
|
+
const root = grokSessionsRoot();
|
|
106566
|
+
if (!fs37.existsSync(root)) return null;
|
|
106567
|
+
for (const candidate of workspaceCandidates(workspace || "")) {
|
|
106568
|
+
if (!candidate) continue;
|
|
106569
|
+
const file2 = path41.join(root, encodeWorkspaceDir(candidate), sessionId, "chat_history.jsonl");
|
|
106570
|
+
if (fs37.existsSync(file2)) return file2;
|
|
106571
|
+
}
|
|
106572
|
+
let entries = [];
|
|
106573
|
+
try {
|
|
106574
|
+
entries = fs37.readdirSync(root, { withFileTypes: true });
|
|
106575
|
+
} catch {
|
|
106576
|
+
return null;
|
|
106577
|
+
}
|
|
106578
|
+
for (const entry of entries) {
|
|
106579
|
+
if (!entry.isDirectory()) continue;
|
|
106580
|
+
const file2 = path41.join(root, entry.name, sessionId, "chat_history.jsonl");
|
|
106581
|
+
if (fs37.existsSync(file2)) return file2;
|
|
106582
|
+
}
|
|
106583
|
+
return null;
|
|
106584
|
+
}
|
|
106585
|
+
var USER_QUERY_RE = /<user_query>\s*([\s\S]*?)\s*<\/user_query>/;
|
|
106586
|
+
function unwrapUserQuery(text) {
|
|
106587
|
+
const match = USER_QUERY_RE.exec(text);
|
|
106588
|
+
if (match) return match[1].trim();
|
|
106589
|
+
return text.trim();
|
|
106590
|
+
}
|
|
106591
|
+
function blocksToText(content) {
|
|
106592
|
+
if (typeof content === "string") return content;
|
|
106593
|
+
if (!Array.isArray(content)) return "";
|
|
106594
|
+
const parts = [];
|
|
106595
|
+
for (const block2 of content) {
|
|
106596
|
+
if (!block2 || typeof block2 !== "object") continue;
|
|
106597
|
+
const record2 = block2;
|
|
106598
|
+
if (typeof record2.text === "string") parts.push(record2.text);
|
|
106599
|
+
else if (record2.type === "image") parts.push("[image]");
|
|
106600
|
+
}
|
|
106601
|
+
return parts.join("\n");
|
|
106602
|
+
}
|
|
106603
|
+
function parseGrokRecord(raw) {
|
|
106604
|
+
if (!raw || typeof raw !== "object") return null;
|
|
106605
|
+
const record2 = raw;
|
|
106606
|
+
const type2 = typeof record2.type === "string" ? record2.type : "";
|
|
106607
|
+
if (type2 === "system") return null;
|
|
106608
|
+
if (type2 === "reasoning") return null;
|
|
106609
|
+
if (type2 === "user") {
|
|
106610
|
+
if (typeof record2.synthetic_reason === "string" && record2.synthetic_reason) return null;
|
|
106611
|
+
const text = unwrapUserQuery(blocksToText(record2.content));
|
|
106612
|
+
if (!text) return null;
|
|
106613
|
+
return { role: "user", content: text, kind: "standard" };
|
|
106614
|
+
}
|
|
106615
|
+
if (type2 === "assistant") {
|
|
106616
|
+
const text = blocksToText(record2.content).trim();
|
|
106617
|
+
const toolCalls = Array.isArray(record2.tool_calls) ? record2.tool_calls : [];
|
|
106618
|
+
if (!text) {
|
|
106619
|
+
if (toolCalls.length === 0) return null;
|
|
106620
|
+
const names = toolCalls.map((call) => call && typeof call === "object" ? call.name : null).filter((name) => typeof name === "string" && name.length > 0);
|
|
106621
|
+
const label = names.length > 0 ? names.join(", ") : "tool";
|
|
106622
|
+
return { role: "assistant", content: `[tool: ${label}]`, kind: "tool" };
|
|
106623
|
+
}
|
|
106624
|
+
return { role: "assistant", content: text, kind: "standard" };
|
|
106625
|
+
}
|
|
106626
|
+
if (type2 === "tool_result") {
|
|
106627
|
+
const text = blocksToText(record2.content).trim();
|
|
106628
|
+
if (!text) return null;
|
|
106629
|
+
return { role: "assistant", content: text, kind: "tool" };
|
|
106630
|
+
}
|
|
106631
|
+
return null;
|
|
106632
|
+
}
|
|
106633
|
+
function readSessionCreatedAtMs(sessionDir) {
|
|
106634
|
+
try {
|
|
106635
|
+
const summary = JSON.parse(fs37.readFileSync(path41.join(sessionDir, "summary.json"), "utf8"));
|
|
106636
|
+
const created = summary?.created_at;
|
|
106637
|
+
if (typeof created === "string") {
|
|
106638
|
+
const parsed = Date.parse(created);
|
|
106639
|
+
if (Number.isFinite(parsed) && parsed > 0) return parsed;
|
|
106640
|
+
}
|
|
106641
|
+
} catch {
|
|
106642
|
+
}
|
|
106643
|
+
return 0;
|
|
106644
|
+
}
|
|
106645
|
+
function readSession5(sourcePath, sessionId, workspace) {
|
|
106646
|
+
let text;
|
|
106647
|
+
try {
|
|
106648
|
+
text = fs37.readFileSync(sourcePath, "utf8");
|
|
106649
|
+
} catch {
|
|
106650
|
+
return null;
|
|
106651
|
+
}
|
|
106652
|
+
const sessionDir = path41.dirname(sourcePath);
|
|
106653
|
+
const providerSessionId = path41.basename(sessionDir);
|
|
106654
|
+
const sourceMtimeMs = statMtimeMs5(sourcePath);
|
|
106655
|
+
const parsed = [];
|
|
106656
|
+
for (const line of text.split("\n")) {
|
|
106657
|
+
const trimmed = line.trim();
|
|
106658
|
+
if (!trimmed) continue;
|
|
106659
|
+
let record2;
|
|
106660
|
+
try {
|
|
106661
|
+
record2 = JSON.parse(trimmed);
|
|
106662
|
+
} catch {
|
|
106663
|
+
continue;
|
|
106664
|
+
}
|
|
106665
|
+
const message = parseGrokRecord(record2);
|
|
106666
|
+
if (message) parsed.push(message);
|
|
106667
|
+
}
|
|
106668
|
+
const startMs = readSessionCreatedAtMs(sessionDir) || sourceMtimeMs;
|
|
106669
|
+
const endMs = Math.max(sourceMtimeMs, startMs);
|
|
106670
|
+
const span = endMs - startMs;
|
|
106671
|
+
const step = parsed.length > 1 ? Math.floor(span / (parsed.length - 1)) : 0;
|
|
106672
|
+
const messages = parsed.map((message, index) => {
|
|
106673
|
+
const receivedAt = parsed.length > 1 ? startMs + step * index : endMs;
|
|
106674
|
+
return {
|
|
106675
|
+
ts: new Date(receivedAt).toISOString(),
|
|
106676
|
+
receivedAt,
|
|
106677
|
+
role: message.role,
|
|
106678
|
+
content: message.content,
|
|
106679
|
+
kind: message.kind,
|
|
106680
|
+
agent: "grok-cli",
|
|
106681
|
+
historySessionId: sessionId || providerSessionId,
|
|
106682
|
+
...workspace ? { workspace } : {},
|
|
106683
|
+
providerUnitKey: `${providerSessionId}:${index}`
|
|
106684
|
+
};
|
|
106685
|
+
});
|
|
106686
|
+
return {
|
|
106687
|
+
messages,
|
|
106688
|
+
providerSessionId,
|
|
106689
|
+
source: "provider-native",
|
|
106690
|
+
sourcePath,
|
|
106691
|
+
sourceMtimeMs,
|
|
106692
|
+
nativeHistoryCoverage: "full",
|
|
106693
|
+
...workspace ? { workspace } : {}
|
|
106694
|
+
};
|
|
106695
|
+
}
|
|
106696
|
+
function listSessions(workspace, limit = 50) {
|
|
106697
|
+
const root = grokSessionsRoot();
|
|
106698
|
+
if (!fs37.existsSync(root)) return [];
|
|
106699
|
+
const dirs = [];
|
|
106700
|
+
for (const candidate of workspaceCandidates(workspace || "")) {
|
|
106701
|
+
if (!candidate) continue;
|
|
106702
|
+
const dir = path41.join(root, encodeWorkspaceDir(candidate));
|
|
106703
|
+
if (fs37.existsSync(dir)) dirs.push(dir);
|
|
106704
|
+
}
|
|
106705
|
+
if (dirs.length === 0) return [];
|
|
106706
|
+
const out = [];
|
|
106707
|
+
for (const dir of dirs) {
|
|
106708
|
+
let entries = [];
|
|
106709
|
+
try {
|
|
106710
|
+
entries = fs37.readdirSync(dir, { withFileTypes: true });
|
|
106711
|
+
} catch {
|
|
106712
|
+
continue;
|
|
106713
|
+
}
|
|
106714
|
+
for (const entry of entries) {
|
|
106715
|
+
if (!entry.isDirectory() || !isUuidLike2(entry.name)) continue;
|
|
106716
|
+
const sourcePath = path41.join(dir, entry.name, "chat_history.jsonl");
|
|
106717
|
+
if (!fs37.existsSync(sourcePath)) continue;
|
|
106718
|
+
const session = readSession5(sourcePath, entry.name, workspace);
|
|
106719
|
+
if (!session || session.messages.length === 0) continue;
|
|
106720
|
+
const first = session.messages[0];
|
|
106721
|
+
const last = session.messages[session.messages.length - 1];
|
|
106722
|
+
const firstUser = session.messages.find(
|
|
106723
|
+
(m) => m.role === "user" && !m.content.startsWith("<user_info>")
|
|
106724
|
+
) ?? session.messages.find((m) => m.role === "user");
|
|
106725
|
+
out.push({
|
|
106726
|
+
historySessionId: entry.name,
|
|
106727
|
+
sessionId: entry.name,
|
|
106728
|
+
sourcePath,
|
|
106729
|
+
sourceMtimeMs: session.sourceMtimeMs,
|
|
106730
|
+
messageCount: session.messages.length,
|
|
106731
|
+
firstMessageAt: first.receivedAt,
|
|
106732
|
+
lastMessageAt: last.receivedAt,
|
|
106733
|
+
...firstUser ? { sessionTitle: firstUser.content.slice(0, 80) } : {},
|
|
106734
|
+
...firstUser ? { preview: firstUser.content.slice(0, 200) } : {},
|
|
106735
|
+
...workspace ? { workspace } : {},
|
|
106736
|
+
agent: "grok-cli",
|
|
106737
|
+
source: "provider-native",
|
|
106738
|
+
nativeHistoryCoverage: "full"
|
|
106739
|
+
});
|
|
106740
|
+
}
|
|
106741
|
+
}
|
|
106742
|
+
out.sort((a, b) => b.sourceMtimeMs - a.sourceMtimeMs);
|
|
106743
|
+
return out.slice(0, limit);
|
|
106744
|
+
}
|
|
106745
|
+
function listSessionsAllWorkspaces(limit = 50) {
|
|
106746
|
+
const root = grokSessionsRoot();
|
|
106747
|
+
if (!fs37.existsSync(root)) return [];
|
|
106748
|
+
let dirs = [];
|
|
106749
|
+
try {
|
|
106750
|
+
dirs = fs37.readdirSync(root, { withFileTypes: true });
|
|
106751
|
+
} catch {
|
|
106752
|
+
return [];
|
|
106753
|
+
}
|
|
106754
|
+
const out = [];
|
|
106755
|
+
for (const dir of dirs) {
|
|
106756
|
+
if (!dir.isDirectory()) continue;
|
|
106757
|
+
let workspace = "";
|
|
106758
|
+
try {
|
|
106759
|
+
workspace = decodeURIComponent(dir.name);
|
|
106760
|
+
} catch {
|
|
106761
|
+
continue;
|
|
106762
|
+
}
|
|
106763
|
+
out.push(...listSessions(workspace, limit));
|
|
106764
|
+
}
|
|
106765
|
+
out.sort((a, b) => b.sourceMtimeMs - a.sourceMtimeMs);
|
|
106766
|
+
return out.slice(0, limit);
|
|
106767
|
+
}
|
|
106392
106768
|
init_constants();
|
|
106393
106769
|
function createNativeHistoryDispatcher(reader) {
|
|
106394
106770
|
return (input) => {
|
|
@@ -106403,7 +106779,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
106403
106779
|
const ownerConfirmed = reader === "antigravity-cli" ? resolved?.ownerConfirmed === true : void 0;
|
|
106404
106780
|
if (input.forceRefresh === true || input.args?.forceRefresh === true) {
|
|
106405
106781
|
try {
|
|
106406
|
-
|
|
106782
|
+
fs38.statSync(sourcePath);
|
|
106407
106783
|
} catch {
|
|
106408
106784
|
}
|
|
106409
106785
|
}
|
|
@@ -106454,14 +106830,21 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
106454
106830
|
const p = resolveHermesPath(workspace, sessionId);
|
|
106455
106831
|
return p ? { path: p } : null;
|
|
106456
106832
|
}
|
|
106833
|
+
// grok stores per-cwd like claude, but keyed by the url-encoded cwd and
|
|
106834
|
+
// with the uuid as a DIRECTORY (…/<uuid>/chat_history.jsonl) rather than
|
|
106835
|
+
// the filename, so resolution lives in the reader module.
|
|
106836
|
+
case "grok-cli": {
|
|
106837
|
+
const p = resolveGrokPath(workspace, sessionId);
|
|
106838
|
+
return p ? { path: p } : null;
|
|
106839
|
+
}
|
|
106457
106840
|
}
|
|
106458
106841
|
}
|
|
106459
106842
|
function resolveClaudePath(workspace, sessionId) {
|
|
106460
|
-
const dir =
|
|
106461
|
-
if (!
|
|
106843
|
+
const dir = path422.join(os26.homedir(), ".claude", "projects", cwdAsDashes(workspace));
|
|
106844
|
+
if (!fs38.existsSync(dir)) return null;
|
|
106462
106845
|
if (sessionId) {
|
|
106463
|
-
const candidate =
|
|
106464
|
-
if (
|
|
106846
|
+
const candidate = path422.join(dir, `${sessionId}.jsonl`);
|
|
106847
|
+
if (fs38.existsSync(candidate)) return candidate;
|
|
106465
106848
|
}
|
|
106466
106849
|
return null;
|
|
106467
106850
|
}
|
|
@@ -106473,7 +106856,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
106473
106856
|
return findCodexPathByRuntime(root, workspace, sessionStartedAtMs);
|
|
106474
106857
|
}
|
|
106475
106858
|
function findCodexPathBySessionId(root, sessionId) {
|
|
106476
|
-
if (!
|
|
106859
|
+
if (!fs38.existsSync(root)) return null;
|
|
106477
106860
|
const needle = sessionId.toLowerCase();
|
|
106478
106861
|
const matches = [];
|
|
106479
106862
|
const stack = [root];
|
|
@@ -106481,12 +106864,12 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
106481
106864
|
const current = stack.pop();
|
|
106482
106865
|
let entries = [];
|
|
106483
106866
|
try {
|
|
106484
|
-
entries =
|
|
106867
|
+
entries = fs38.readdirSync(current, { withFileTypes: true });
|
|
106485
106868
|
} catch {
|
|
106486
106869
|
continue;
|
|
106487
106870
|
}
|
|
106488
106871
|
for (const entry of entries) {
|
|
106489
|
-
const entryPath =
|
|
106872
|
+
const entryPath = path422.join(current, entry.name);
|
|
106490
106873
|
if (entry.isDirectory()) {
|
|
106491
106874
|
stack.push(entryPath);
|
|
106492
106875
|
continue;
|
|
@@ -106501,7 +106884,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
106501
106884
|
return matches[0]?.p ?? null;
|
|
106502
106885
|
}
|
|
106503
106886
|
function findCodexPathByRuntime(root, workspace, sessionStartedAtMs) {
|
|
106504
|
-
if (!
|
|
106887
|
+
if (!fs38.existsSync(root) || !workspace) return null;
|
|
106505
106888
|
const workspaceResolved = resolveRealPath(workspace);
|
|
106506
106889
|
const cutoff = Date.now() - RECENT_WINDOW_MS;
|
|
106507
106890
|
const matches = [];
|
|
@@ -106510,12 +106893,12 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
106510
106893
|
const current = stack.pop();
|
|
106511
106894
|
let entries = [];
|
|
106512
106895
|
try {
|
|
106513
|
-
entries =
|
|
106896
|
+
entries = fs38.readdirSync(current, { withFileTypes: true });
|
|
106514
106897
|
} catch {
|
|
106515
106898
|
continue;
|
|
106516
106899
|
}
|
|
106517
106900
|
for (const entry of entries) {
|
|
106518
|
-
const entryPath =
|
|
106901
|
+
const entryPath = path422.join(current, entry.name);
|
|
106519
106902
|
if (entry.isDirectory()) {
|
|
106520
106903
|
stack.push(entryPath);
|
|
106521
106904
|
continue;
|
|
@@ -106535,10 +106918,10 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
106535
106918
|
}
|
|
106536
106919
|
function readCodexSessionMeta(filePath) {
|
|
106537
106920
|
try {
|
|
106538
|
-
const fd =
|
|
106921
|
+
const fd = fs38.openSync(filePath, "r");
|
|
106539
106922
|
try {
|
|
106540
106923
|
const buffer = Buffer.alloc(8192);
|
|
106541
|
-
const bytes =
|
|
106924
|
+
const bytes = fs38.readSync(fd, buffer, 0, buffer.length, 0);
|
|
106542
106925
|
if (bytes <= 0) return null;
|
|
106543
106926
|
const text = buffer.subarray(0, bytes).toString("utf8");
|
|
106544
106927
|
const firstLine = text.slice(0, text.indexOf("\n") >= 0 ? text.indexOf("\n") : text.length).trim();
|
|
@@ -106553,7 +106936,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
106553
106936
|
timestampMs: Number.isFinite(timestampMs) ? timestampMs : void 0
|
|
106554
106937
|
};
|
|
106555
106938
|
} finally {
|
|
106556
|
-
|
|
106939
|
+
fs38.closeSync(fd);
|
|
106557
106940
|
}
|
|
106558
106941
|
} catch {
|
|
106559
106942
|
return null;
|
|
@@ -106561,7 +106944,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
106561
106944
|
}
|
|
106562
106945
|
function resolveRealPath(value) {
|
|
106563
106946
|
try {
|
|
106564
|
-
return
|
|
106947
|
+
return fs38.realpathSync(value);
|
|
106565
106948
|
} catch {
|
|
106566
106949
|
return value;
|
|
106567
106950
|
}
|
|
@@ -106579,24 +106962,24 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
106579
106962
|
}
|
|
106580
106963
|
var AGY_SPAWN_CLAIM_GRACE_MS = 2e3;
|
|
106581
106964
|
function resolveAntigravityPath(workspace, sessionId, sessionStartedAtMs, instanceId) {
|
|
106582
|
-
const agyRoot =
|
|
106965
|
+
const agyRoot = path422.join(os26.homedir(), ".gemini", "antigravity-cli");
|
|
106583
106966
|
const owner = antigravityOwnerToken(workspace, sessionStartedAtMs, instanceId);
|
|
106584
106967
|
if (sessionId && isUuidLikeSessionId2(sessionId)) {
|
|
106585
|
-
const dbPath =
|
|
106586
|
-
if (
|
|
106968
|
+
const dbPath = path422.join(agyRoot, "conversations", `${sessionId}.db`);
|
|
106969
|
+
if (fs38.existsSync(dbPath)) {
|
|
106587
106970
|
if (owner) claimAntigravityConversation(sessionId, owner);
|
|
106588
106971
|
return { path: dbPath, ownerConfirmed: true };
|
|
106589
106972
|
}
|
|
106590
106973
|
}
|
|
106591
|
-
const brainRoot2 =
|
|
106592
|
-
if (
|
|
106974
|
+
const brainRoot2 = path422.join(agyRoot, "brain");
|
|
106975
|
+
if (fs38.existsSync(brainRoot2)) {
|
|
106593
106976
|
const cutoff = spawnAwareCutoff(sessionStartedAtMs);
|
|
106594
106977
|
const nonEmptyBrain = (uuid3, p) => {
|
|
106595
|
-
const t =
|
|
106596
|
-
return
|
|
106978
|
+
const t = path422.join(p, ".system_generated", "logs", "transcript.jsonl");
|
|
106979
|
+
return fs38.existsSync(t) && safeSize(t) > 0 ? t : null;
|
|
106597
106980
|
};
|
|
106598
|
-
const all =
|
|
106599
|
-
const p =
|
|
106981
|
+
const all = fs38.readdirSync(brainRoot2, { withFileTypes: true }).filter((e) => e.isDirectory() && isUuidLikeSessionId2(e.name)).filter((e) => !isAntigravityConversationClaimedByOther(e.name, owner)).map((e) => {
|
|
106982
|
+
const p = path422.join(brainRoot2, e.name);
|
|
106600
106983
|
return { uuid: e.name, p, mtime: safeMtime(p), birth: safeBirthtime(p) };
|
|
106601
106984
|
}).filter((e) => e.mtime >= cutoff);
|
|
106602
106985
|
let ordered = [];
|
|
@@ -106615,7 +106998,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
106615
106998
|
}
|
|
106616
106999
|
}
|
|
106617
107000
|
}
|
|
106618
|
-
const convRoot =
|
|
107001
|
+
const convRoot = path422.join(agyRoot, "conversations");
|
|
106619
107002
|
const picked = pickUnboundConversationDb(convRoot, sessionStartedAtMs, owner);
|
|
106620
107003
|
if (picked) {
|
|
106621
107004
|
if (owner) claimAntigravityConversation(picked.uuid, owner);
|
|
@@ -106626,7 +107009,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
106626
107009
|
function pickUnboundConversationDb(convRoot, sessionFloorMs, owner) {
|
|
106627
107010
|
let entries = [];
|
|
106628
107011
|
try {
|
|
106629
|
-
entries =
|
|
107012
|
+
entries = fs38.readdirSync(convRoot, { withFileTypes: true });
|
|
106630
107013
|
} catch {
|
|
106631
107014
|
return null;
|
|
106632
107015
|
}
|
|
@@ -106639,7 +107022,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
106639
107022
|
if (!match || !isUuidLikeSessionId2(match[1])) continue;
|
|
106640
107023
|
const uuid3 = match[1];
|
|
106641
107024
|
if (isAntigravityConversationClaimedByOther(uuid3, owner)) continue;
|
|
106642
|
-
const p =
|
|
107025
|
+
const p = path422.join(convRoot, entry.name);
|
|
106643
107026
|
const mtime = safeMtime(p);
|
|
106644
107027
|
if (applyRecencyCutoff && mtime < recencyCutoff) continue;
|
|
106645
107028
|
candidates.push({ path: p, uuid: uuid3, mtime, birth: safeBirthtime(p) });
|
|
@@ -106663,10 +107046,10 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
106663
107046
|
function resolveHermesPath(workspace, sessionId) {
|
|
106664
107047
|
void workspace;
|
|
106665
107048
|
void sessionId;
|
|
106666
|
-
const dbPath =
|
|
106667
|
-
if (
|
|
106668
|
-
const dir =
|
|
106669
|
-
if (!
|
|
107049
|
+
const dbPath = path422.join(os26.homedir(), ".hermes", "state.db");
|
|
107050
|
+
if (fs38.existsSync(dbPath)) return dbPath;
|
|
107051
|
+
const dir = path422.join(os26.homedir(), ".hermes", "sessions");
|
|
107052
|
+
if (!fs38.existsSync(dir)) return null;
|
|
106670
107053
|
return newestRecentFile2(dir, /^session_.*\.json$/);
|
|
106671
107054
|
}
|
|
106672
107055
|
function readByReader(reader, sourcePath, sessionId, workspace, requestedProviderSid) {
|
|
@@ -106684,6 +107067,8 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
106684
107067
|
// per-session file upstream, so they need no equivalent pin here.
|
|
106685
107068
|
case "hermes-cli":
|
|
106686
107069
|
return readSession4(sourcePath, requestedProviderSid || void 0);
|
|
107070
|
+
case "grok-cli":
|
|
107071
|
+
return readSession5(sourcePath, sessionId, workspace || void 0);
|
|
106687
107072
|
}
|
|
106688
107073
|
}
|
|
106689
107074
|
function cwdAsDashes(cwd) {
|
|
@@ -106691,7 +107076,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
106691
107076
|
return cwd.replace(/\//g, "-");
|
|
106692
107077
|
}
|
|
106693
107078
|
function codexSessionsRoot() {
|
|
106694
|
-
return
|
|
107079
|
+
return path422.join(os26.homedir(), ".codex", "sessions");
|
|
106695
107080
|
}
|
|
106696
107081
|
function isUuidLikeSessionId2(sessionId) {
|
|
106697
107082
|
return /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(sessionId);
|
|
@@ -106703,7 +107088,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
106703
107088
|
function newestRecentFile2(dir, pattern) {
|
|
106704
107089
|
try {
|
|
106705
107090
|
const cutoff = Date.now() - RECENT_WINDOW_MS;
|
|
106706
|
-
const entries =
|
|
107091
|
+
const entries = fs38.readdirSync(dir, { withFileTypes: true }).filter((e) => e.isFile() && pattern.test(e.name)).map((e) => ({ p: path422.join(dir, e.name), mtime: safeMtime(path422.join(dir, e.name)) })).filter((e) => e.mtime >= cutoff).sort((a, b) => b.mtime - a.mtime);
|
|
106707
107092
|
return entries[0]?.p ?? null;
|
|
106708
107093
|
} catch {
|
|
106709
107094
|
return null;
|
|
@@ -106711,14 +107096,14 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
106711
107096
|
}
|
|
106712
107097
|
function safeMtime(p) {
|
|
106713
107098
|
try {
|
|
106714
|
-
return Math.floor(
|
|
107099
|
+
return Math.floor(fs38.statSync(p).mtimeMs);
|
|
106715
107100
|
} catch {
|
|
106716
107101
|
return 0;
|
|
106717
107102
|
}
|
|
106718
107103
|
}
|
|
106719
107104
|
function safeBirthtime(p) {
|
|
106720
107105
|
try {
|
|
106721
|
-
const st =
|
|
107106
|
+
const st = fs38.statSync(p);
|
|
106722
107107
|
const birth = Math.floor(st.birthtimeMs);
|
|
106723
107108
|
return birth > 0 ? birth : Math.floor(st.mtimeMs);
|
|
106724
107109
|
} catch {
|
|
@@ -106727,11 +107112,20 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
106727
107112
|
}
|
|
106728
107113
|
function safeSize(p) {
|
|
106729
107114
|
try {
|
|
106730
|
-
return
|
|
107115
|
+
return fs38.statSync(p).size;
|
|
106731
107116
|
} catch {
|
|
106732
107117
|
return 0;
|
|
106733
107118
|
}
|
|
106734
107119
|
}
|
|
107120
|
+
function createNativeHistoryListDispatcher(reader) {
|
|
107121
|
+
if (reader !== "grok-cli") return null;
|
|
107122
|
+
return (input) => {
|
|
107123
|
+
const limitRaw = input.args?.limit;
|
|
107124
|
+
const limit = typeof limitRaw === "number" && limitRaw > 0 ? Math.floor(limitRaw) : 50;
|
|
107125
|
+
const sessions = input.workspace ? listSessions(input.workspace, limit) : listSessionsAllWorkspaces(limit);
|
|
107126
|
+
return { sessions };
|
|
107127
|
+
};
|
|
107128
|
+
}
|
|
106735
107129
|
function normalizeRole2(r) {
|
|
106736
107130
|
const s2 = String(r ?? "").toLowerCase();
|
|
106737
107131
|
if (s2 === "user" || s2 === "human") return "user";
|
|
@@ -106801,8 +107195,8 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
106801
107195
|
}
|
|
106802
107196
|
return { activatable, skipped };
|
|
106803
107197
|
}
|
|
106804
|
-
var
|
|
106805
|
-
var
|
|
107198
|
+
var fs39 = __toESM2(require("fs"));
|
|
107199
|
+
var path43 = __toESM2(require("path"));
|
|
106806
107200
|
var crypto8 = __toESM2(require("crypto"));
|
|
106807
107201
|
init_config();
|
|
106808
107202
|
var ProviderChannelStore = class _ProviderChannelStore {
|
|
@@ -106815,19 +107209,19 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
106815
107209
|
}
|
|
106816
107210
|
/** Default store root, resolved through the config-dir abstraction. */
|
|
106817
107211
|
static defaultRoot() {
|
|
106818
|
-
return
|
|
107212
|
+
return path43.join(getConfigDir2(), "providers", ".store");
|
|
106819
107213
|
}
|
|
106820
107214
|
get objectsDir() {
|
|
106821
|
-
return
|
|
107215
|
+
return path43.join(this.rootDir, "objects");
|
|
106822
107216
|
}
|
|
106823
107217
|
get stagingDir() {
|
|
106824
|
-
return
|
|
107218
|
+
return path43.join(this.rootDir, "staging");
|
|
106825
107219
|
}
|
|
106826
107220
|
activeDir(channel) {
|
|
106827
|
-
return
|
|
107221
|
+
return path43.join(this.rootDir, "active", channel);
|
|
106828
107222
|
}
|
|
106829
107223
|
pointerPath(channel, providerType) {
|
|
106830
|
-
return
|
|
107224
|
+
return path43.join(this.activeDir(channel), `${providerType}.json`);
|
|
106831
107225
|
}
|
|
106832
107226
|
log(msg) {
|
|
106833
107227
|
this.logFn(`[ProviderChannelStore] ${msg}`);
|
|
@@ -106835,14 +107229,14 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
106835
107229
|
// ─── Staging ─────────────────────────────────────────────
|
|
106836
107230
|
/** Create a fresh staging directory. Caller must clean it up (or gc will). */
|
|
106837
107231
|
createStagingDir(kind) {
|
|
106838
|
-
const dir =
|
|
106839
|
-
|
|
107232
|
+
const dir = path43.join(this.stagingDir, `${kind}-${process.pid}-${crypto8.randomBytes(6).toString("hex")}`);
|
|
107233
|
+
fs39.mkdirSync(dir, { recursive: true });
|
|
106840
107234
|
return dir;
|
|
106841
107235
|
}
|
|
106842
107236
|
removeStagingDir(dir) {
|
|
106843
|
-
if (!dir.startsWith(this.stagingDir +
|
|
107237
|
+
if (!dir.startsWith(this.stagingDir + path43.sep)) return;
|
|
106844
107238
|
try {
|
|
106845
|
-
|
|
107239
|
+
fs39.rmSync(dir, { recursive: true, force: true });
|
|
106846
107240
|
} catch {
|
|
106847
107241
|
}
|
|
106848
107242
|
}
|
|
@@ -106854,11 +107248,11 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
106854
107248
|
return digest.slice("sha256:".length);
|
|
106855
107249
|
}
|
|
106856
107250
|
getObjectDir(digest) {
|
|
106857
|
-
return
|
|
107251
|
+
return path43.join(this.objectsDir, _ProviderChannelStore.objectName(digest));
|
|
106858
107252
|
}
|
|
106859
107253
|
hasObject(digest) {
|
|
106860
107254
|
try {
|
|
106861
|
-
return
|
|
107255
|
+
return fs39.statSync(this.getObjectDir(digest)).isDirectory();
|
|
106862
107256
|
} catch {
|
|
106863
107257
|
return false;
|
|
106864
107258
|
}
|
|
@@ -106876,8 +107270,8 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
106876
107270
|
this.removeStagingDir(stagedObjectDir);
|
|
106877
107271
|
return objectDir;
|
|
106878
107272
|
}
|
|
106879
|
-
|
|
106880
|
-
|
|
107273
|
+
fs39.mkdirSync(this.objectsDir, { recursive: true });
|
|
107274
|
+
fs39.renameSync(stagedObjectDir, objectDir);
|
|
106881
107275
|
return objectDir;
|
|
106882
107276
|
}
|
|
106883
107277
|
// ─── Pointers ────────────────────────────────────────────
|
|
@@ -106889,10 +107283,10 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
106889
107283
|
*/
|
|
106890
107284
|
getPointer(channel, providerType) {
|
|
106891
107285
|
const file2 = this.pointerPath(channel, providerType);
|
|
106892
|
-
if (!
|
|
107286
|
+
if (!fs39.existsSync(file2)) return null;
|
|
106893
107287
|
let parsed;
|
|
106894
107288
|
try {
|
|
106895
|
-
parsed = JSON.parse(
|
|
107289
|
+
parsed = JSON.parse(fs39.readFileSync(file2, "utf-8"));
|
|
106896
107290
|
} catch (e) {
|
|
106897
107291
|
throw new ProviderChannelError(
|
|
106898
107292
|
"STORE_CORRUPT",
|
|
@@ -106920,7 +107314,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
106920
107314
|
const dir = this.activeDir(channel);
|
|
106921
107315
|
let files = [];
|
|
106922
107316
|
try {
|
|
106923
|
-
files =
|
|
107317
|
+
files = fs39.readdirSync(dir).filter((f) => f.endsWith(".json"));
|
|
106924
107318
|
} catch {
|
|
106925
107319
|
return { pointers, errors };
|
|
106926
107320
|
}
|
|
@@ -106941,7 +107335,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
106941
107335
|
const activations = [];
|
|
106942
107336
|
for (const pointer of pointers.values()) {
|
|
106943
107337
|
const objectDir = this.getObjectDir(pointer.active.digest);
|
|
106944
|
-
if (!
|
|
107338
|
+
if (!fs39.existsSync(objectDir)) {
|
|
106945
107339
|
errors.push(new ProviderChannelError(
|
|
106946
107340
|
"STORE_CORRUPT",
|
|
106947
107341
|
`active object ${pointer.active.digest} for "${pointer.active.providerType}" is missing \u2014 skipping (fail closed)`,
|
|
@@ -107010,9 +107404,9 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
107010
107404
|
/** Remove an activation pointer (e.g. provider uninstalled). */
|
|
107011
107405
|
removePointer(channel, providerType) {
|
|
107012
107406
|
const file2 = this.pointerPath(channel, providerType);
|
|
107013
|
-
if (!
|
|
107407
|
+
if (!fs39.existsSync(file2)) return false;
|
|
107014
107408
|
try {
|
|
107015
|
-
|
|
107409
|
+
fs39.rmSync(file2, { force: true });
|
|
107016
107410
|
return true;
|
|
107017
107411
|
} catch {
|
|
107018
107412
|
return false;
|
|
@@ -107020,11 +107414,11 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
107020
107414
|
}
|
|
107021
107415
|
writePointerAtomic(channel, providerType, pointer) {
|
|
107022
107416
|
const dir = this.activeDir(channel);
|
|
107023
|
-
|
|
107417
|
+
fs39.mkdirSync(dir, { recursive: true });
|
|
107024
107418
|
const file2 = this.pointerPath(channel, providerType);
|
|
107025
|
-
const tmp =
|
|
107026
|
-
|
|
107027
|
-
|
|
107419
|
+
const tmp = path43.join(dir, `.${providerType}.${process.pid}.${crypto8.randomBytes(4).toString("hex")}.tmp`);
|
|
107420
|
+
fs39.writeFileSync(tmp, JSON.stringify(pointer, null, 2), "utf-8");
|
|
107421
|
+
fs39.renameSync(tmp, file2);
|
|
107028
107422
|
}
|
|
107029
107423
|
// ─── GC (N=2 retention) ──────────────────────────────────
|
|
107030
107424
|
/**
|
|
@@ -107040,13 +107434,13 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
107040
107434
|
const dir = this.activeDir(channel);
|
|
107041
107435
|
let files = [];
|
|
107042
107436
|
try {
|
|
107043
|
-
files =
|
|
107437
|
+
files = fs39.readdirSync(dir).filter((f) => f.endsWith(".json"));
|
|
107044
107438
|
} catch {
|
|
107045
107439
|
continue;
|
|
107046
107440
|
}
|
|
107047
107441
|
for (const file2 of files) {
|
|
107048
107442
|
try {
|
|
107049
|
-
const parsed = JSON.parse(
|
|
107443
|
+
const parsed = JSON.parse(fs39.readFileSync(path43.join(dir, file2), "utf-8"));
|
|
107050
107444
|
if (typeof parsed?.active?.digest === "string") referenced.add(parsed.active.digest);
|
|
107051
107445
|
if (typeof parsed?.previous?.digest === "string") referenced.add(parsed.previous.digest);
|
|
107052
107446
|
} catch {
|
|
@@ -107056,7 +107450,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
107056
107450
|
const removedObjects = [];
|
|
107057
107451
|
let objectNames = [];
|
|
107058
107452
|
try {
|
|
107059
|
-
objectNames =
|
|
107453
|
+
objectNames = fs39.readdirSync(this.objectsDir);
|
|
107060
107454
|
} catch {
|
|
107061
107455
|
objectNames = [];
|
|
107062
107456
|
}
|
|
@@ -107064,7 +107458,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
107064
107458
|
const digest = `sha256:${name}`;
|
|
107065
107459
|
if (referenced.has(digest)) continue;
|
|
107066
107460
|
try {
|
|
107067
|
-
|
|
107461
|
+
fs39.rmSync(path43.join(this.objectsDir, name), { recursive: true, force: true });
|
|
107068
107462
|
removedObjects.push(digest);
|
|
107069
107463
|
} catch {
|
|
107070
107464
|
}
|
|
@@ -107072,13 +107466,13 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
107072
107466
|
let removedStaging = 0;
|
|
107073
107467
|
let stagingEntries = [];
|
|
107074
107468
|
try {
|
|
107075
|
-
stagingEntries =
|
|
107469
|
+
stagingEntries = fs39.readdirSync(this.stagingDir);
|
|
107076
107470
|
} catch {
|
|
107077
107471
|
stagingEntries = [];
|
|
107078
107472
|
}
|
|
107079
107473
|
for (const name of stagingEntries) {
|
|
107080
107474
|
try {
|
|
107081
|
-
|
|
107475
|
+
fs39.rmSync(path43.join(this.stagingDir, name), { recursive: true, force: true });
|
|
107082
107476
|
removedStaging++;
|
|
107083
107477
|
} catch {
|
|
107084
107478
|
}
|
|
@@ -107089,10 +107483,10 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
107089
107483
|
return { removedObjects, removedStaging };
|
|
107090
107484
|
}
|
|
107091
107485
|
};
|
|
107092
|
-
var
|
|
107486
|
+
var fs422 = __toESM2(require("fs"));
|
|
107487
|
+
var path45 = __toESM2(require("path"));
|
|
107488
|
+
var fs40 = __toESM2(require("fs"));
|
|
107093
107489
|
var path44 = __toESM2(require("path"));
|
|
107094
|
-
var fs39 = __toESM2(require("fs"));
|
|
107095
|
-
var path43 = __toESM2(require("path"));
|
|
107096
107490
|
var import_crypto12 = require("crypto");
|
|
107097
107491
|
var TREE_DIGEST_ALGORITHM = "adhdev-provider-tree-sha256-v1";
|
|
107098
107492
|
function computeProviderTreeDigest(rootDir, providerType) {
|
|
@@ -107108,8 +107502,8 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
107108
107502
|
relPaths.sort();
|
|
107109
107503
|
const hash2 = (0, import_crypto12.createHash)("sha256");
|
|
107110
107504
|
for (const relPath of relPaths) {
|
|
107111
|
-
const absPath =
|
|
107112
|
-
const bytes =
|
|
107505
|
+
const absPath = path44.join(rootDir, ...relPath.split("/"));
|
|
107506
|
+
const bytes = fs40.readFileSync(absPath);
|
|
107113
107507
|
hash2.update(relPath, "utf8");
|
|
107114
107508
|
hash2.update("\0");
|
|
107115
107509
|
hash2.update(String(bytes.length), "utf8");
|
|
@@ -107121,7 +107515,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
107121
107515
|
function collectRegularFiles(rootDir, dir, out, providerType) {
|
|
107122
107516
|
let entries;
|
|
107123
107517
|
try {
|
|
107124
|
-
entries =
|
|
107518
|
+
entries = fs40.readdirSync(dir, { withFileTypes: true });
|
|
107125
107519
|
} catch (e) {
|
|
107126
107520
|
throw new ProviderChannelError(
|
|
107127
107521
|
"ENTRY_TREE_INVALID",
|
|
@@ -107130,7 +107524,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
107130
107524
|
);
|
|
107131
107525
|
}
|
|
107132
107526
|
for (const entry of entries) {
|
|
107133
|
-
const abs =
|
|
107527
|
+
const abs = path44.join(dir, entry.name);
|
|
107134
107528
|
if (entry.isDirectory()) {
|
|
107135
107529
|
collectRegularFiles(rootDir, abs, out, providerType);
|
|
107136
107530
|
continue;
|
|
@@ -107142,16 +107536,16 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
107142
107536
|
providerType
|
|
107143
107537
|
);
|
|
107144
107538
|
}
|
|
107145
|
-
const rel =
|
|
107539
|
+
const rel = path44.relative(rootDir, abs).split(path44.sep).join("/");
|
|
107146
107540
|
out.push(rel);
|
|
107147
107541
|
}
|
|
107148
107542
|
}
|
|
107149
|
-
var
|
|
107543
|
+
var fs41 = __toESM2(require("fs"));
|
|
107150
107544
|
var zlib = __toESM2(require("zlib"));
|
|
107151
107545
|
var import_promises5 = require("stream/promises");
|
|
107152
107546
|
async function extractTarballGz(tarPath, destDir) {
|
|
107153
107547
|
const tarFs = require_tar_fs();
|
|
107154
|
-
await (0, import_promises5.pipeline)(
|
|
107548
|
+
await (0, import_promises5.pipeline)(fs41.createReadStream(tarPath), zlib.createGunzip(), tarFs.extract(destDir));
|
|
107155
107549
|
}
|
|
107156
107550
|
var REGISTRY_LIST_LIMIT = 100;
|
|
107157
107551
|
var ProviderChannelRuntime = class {
|
|
@@ -107272,9 +107666,9 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
107272
107666
|
}
|
|
107273
107667
|
const stagingRoot = this.store.createStagingDir("sync");
|
|
107274
107668
|
try {
|
|
107275
|
-
const tarPath =
|
|
107276
|
-
const extractDir =
|
|
107277
|
-
|
|
107669
|
+
const tarPath = path45.join(stagingRoot, "providers.tar.gz");
|
|
107670
|
+
const extractDir = path45.join(stagingRoot, "repo");
|
|
107671
|
+
fs422.mkdirSync(extractDir, { recursive: true });
|
|
107278
107672
|
try {
|
|
107279
107673
|
await this.downloadFile(this.providerTarballUrl, tarPath);
|
|
107280
107674
|
await this.extractTarball(tarPath, extractDir);
|
|
@@ -107331,9 +107725,9 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
107331
107725
|
const objStaging = this.store.createStagingDir(`obj-${entry.providerType}`);
|
|
107332
107726
|
let relDir;
|
|
107333
107727
|
try {
|
|
107334
|
-
relDir =
|
|
107335
|
-
|
|
107336
|
-
|
|
107728
|
+
relDir = path45.relative(repoRoot, artifactDir).split(path45.sep).join("/");
|
|
107729
|
+
fs422.mkdirSync(path45.join(objStaging, entry.category), { recursive: true });
|
|
107730
|
+
fs422.renameSync(artifactDir, path45.join(objStaging, entry.category, path45.basename(artifactDir)));
|
|
107337
107731
|
} catch (e) {
|
|
107338
107732
|
this.store.removeStagingDir(objStaging);
|
|
107339
107733
|
return { code: "TRANSPORT_FAILED", message: `failed to stage artifact tree: ${e?.message || e}`, providerType: entry.providerType };
|
|
@@ -107372,31 +107766,31 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
107372
107766
|
function findTarballRepoRoot(extractDir) {
|
|
107373
107767
|
let entries;
|
|
107374
107768
|
try {
|
|
107375
|
-
entries =
|
|
107769
|
+
entries = fs422.readdirSync(extractDir, { withFileTypes: true });
|
|
107376
107770
|
} catch {
|
|
107377
107771
|
return null;
|
|
107378
107772
|
}
|
|
107379
107773
|
const dirs = entries.filter((e) => e.isDirectory());
|
|
107380
107774
|
if (dirs.length !== 1) return null;
|
|
107381
|
-
return
|
|
107775
|
+
return path45.join(extractDir, dirs[0].name);
|
|
107382
107776
|
}
|
|
107383
107777
|
function locateArtifactDir(repoRoot, entry) {
|
|
107384
|
-
const categoryDir =
|
|
107778
|
+
const categoryDir = path45.join(repoRoot, entry.category);
|
|
107385
107779
|
let candidates;
|
|
107386
107780
|
try {
|
|
107387
|
-
candidates =
|
|
107781
|
+
candidates = fs422.readdirSync(categoryDir, { withFileTypes: true });
|
|
107388
107782
|
} catch {
|
|
107389
107783
|
return null;
|
|
107390
107784
|
}
|
|
107391
107785
|
for (const candidate of candidates) {
|
|
107392
107786
|
if (!candidate.isDirectory()) continue;
|
|
107393
107787
|
if (candidate.name.startsWith("_") || candidate.name.startsWith(".")) continue;
|
|
107394
|
-
const dir =
|
|
107788
|
+
const dir = path45.join(categoryDir, candidate.name);
|
|
107395
107789
|
for (const manifestName of ["provider.v1.json", "provider.json"]) {
|
|
107396
|
-
const manifestPath =
|
|
107790
|
+
const manifestPath = path45.join(dir, manifestName);
|
|
107397
107791
|
try {
|
|
107398
|
-
if (!
|
|
107399
|
-
const manifest = JSON.parse(
|
|
107792
|
+
if (!fs422.existsSync(manifestPath)) continue;
|
|
107793
|
+
const manifest = JSON.parse(fs422.readFileSync(manifestPath, "utf-8"));
|
|
107400
107794
|
if (manifest?.type === entry.providerType) return dir;
|
|
107401
107795
|
break;
|
|
107402
107796
|
} catch {
|
|
@@ -107413,14 +107807,14 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
107413
107807
|
const scan = (dir) => {
|
|
107414
107808
|
let entries;
|
|
107415
107809
|
try {
|
|
107416
|
-
entries =
|
|
107810
|
+
entries = fs422.readdirSync(dir, { withFileTypes: true });
|
|
107417
107811
|
} catch {
|
|
107418
107812
|
return;
|
|
107419
107813
|
}
|
|
107420
107814
|
const manifest = entries.find((e) => e.isFile() && (e.name === "provider.v1.json" || e.name === "provider.json"));
|
|
107421
107815
|
if (manifest) {
|
|
107422
107816
|
try {
|
|
107423
|
-
const parsed = JSON.parse(
|
|
107817
|
+
const parsed = JSON.parse(fs422.readFileSync(path45.join(dir, manifest.name), "utf-8"));
|
|
107424
107818
|
if (typeof parsed?.type === "string" && parsed.type.trim()) targets.add(parsed.type);
|
|
107425
107819
|
} catch {
|
|
107426
107820
|
}
|
|
@@ -107429,7 +107823,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
107429
107823
|
for (const entry of entries) {
|
|
107430
107824
|
if (!entry.isDirectory()) continue;
|
|
107431
107825
|
if (entry.name.startsWith("_") || entry.name.startsWith(".")) continue;
|
|
107432
|
-
scan(
|
|
107826
|
+
scan(path45.join(dir, entry.name));
|
|
107433
107827
|
}
|
|
107434
107828
|
};
|
|
107435
107829
|
scan(upstreamDir);
|
|
@@ -107437,7 +107831,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
107437
107831
|
}
|
|
107438
107832
|
function pathEnvDiagnostic() {
|
|
107439
107833
|
const raw = process.env.PATH ?? "";
|
|
107440
|
-
const entries = raw.split(
|
|
107834
|
+
const entries = raw.split(path45.delimiter).filter((e) => e.length > 0);
|
|
107441
107835
|
const hasSystem32 = entries.some((e) => /system32$/i.test(e.replace(/[\\/]+$/, "")));
|
|
107442
107836
|
return `platform=${process.platform} pathEntries=${entries.length} system32InPath=${hasSystem32}`;
|
|
107443
107837
|
}
|
|
@@ -107485,7 +107879,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
107485
107879
|
reject(new Error(`HTTP ${res.statusCode}`));
|
|
107486
107880
|
return;
|
|
107487
107881
|
}
|
|
107488
|
-
const ws =
|
|
107882
|
+
const ws = fs422.createWriteStream(destPath);
|
|
107489
107883
|
res.pipe(ws);
|
|
107490
107884
|
ws.on("finish", () => {
|
|
107491
107885
|
ws.close();
|
|
@@ -107628,9 +108022,9 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
107628
108022
|
static siblingRefusalLogged = /* @__PURE__ */ new Set();
|
|
107629
108023
|
static looksLikeProviderRoot(candidate) {
|
|
107630
108024
|
try {
|
|
107631
|
-
if (!
|
|
108025
|
+
if (!fs43.existsSync(candidate) || !fs43.statSync(candidate).isDirectory()) return false;
|
|
107632
108026
|
return ["ide", "extension", "cli", "acp"].some(
|
|
107633
|
-
(category) =>
|
|
108027
|
+
(category) => fs43.existsSync(path47.join(candidate, category))
|
|
107634
108028
|
);
|
|
107635
108029
|
} catch {
|
|
107636
108030
|
return false;
|
|
@@ -107638,20 +108032,20 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
107638
108032
|
}
|
|
107639
108033
|
static hasProviderRootMarker(candidate) {
|
|
107640
108034
|
try {
|
|
107641
|
-
return
|
|
108035
|
+
return fs43.existsSync(path47.join(candidate, _ProviderLoader.SIBLING_MARKER_FILE));
|
|
107642
108036
|
} catch {
|
|
107643
108037
|
return false;
|
|
107644
108038
|
}
|
|
107645
108039
|
}
|
|
107646
108040
|
detectDefaultUserDir() {
|
|
107647
|
-
const fallback =
|
|
108041
|
+
const fallback = path47.join(getConfigDir2(), "providers");
|
|
107648
108042
|
const envOptIn = process.env[_ProviderLoader.SIBLING_ENV_VAR] === "1";
|
|
107649
108043
|
const visited = /* @__PURE__ */ new Set();
|
|
107650
108044
|
for (const start of this.probeStarts) {
|
|
107651
|
-
let current =
|
|
108045
|
+
let current = path47.resolve(start);
|
|
107652
108046
|
while (!visited.has(current)) {
|
|
107653
108047
|
visited.add(current);
|
|
107654
|
-
const siblingCandidate =
|
|
108048
|
+
const siblingCandidate = path47.join(path47.dirname(current), _ProviderLoader.REPO_PROVIDER_DIRNAME);
|
|
107655
108049
|
if (_ProviderLoader.looksLikeProviderRoot(siblingCandidate)) {
|
|
107656
108050
|
const hasMarker = _ProviderLoader.hasProviderRootMarker(siblingCandidate);
|
|
107657
108051
|
if (envOptIn || hasMarker) {
|
|
@@ -107688,7 +108082,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
107688
108082
|
}
|
|
107689
108083
|
}
|
|
107690
108084
|
}
|
|
107691
|
-
const parent =
|
|
108085
|
+
const parent = path47.dirname(current);
|
|
107692
108086
|
if (parent === current) break;
|
|
107693
108087
|
current = parent;
|
|
107694
108088
|
}
|
|
@@ -107704,11 +108098,11 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
107704
108098
|
this.channelStore = options?.channelStore === null ? null : options?.channelStore ?? new ProviderChannelStore(ProviderChannelStore.defaultRoot(), this.logFn);
|
|
107705
108099
|
this.channelSyncIO = options?.channelSyncIO;
|
|
107706
108100
|
this.daemonVersion = (options?.daemonVersion || "").trim().replace(/^v/, "");
|
|
107707
|
-
this.defaultProvidersDir =
|
|
108101
|
+
this.defaultProvidersDir = path47.join(getConfigDir2(), "providers");
|
|
107708
108102
|
const detected = this.detectDefaultUserDir();
|
|
107709
108103
|
this.userDir = detected.path;
|
|
107710
108104
|
this.userDirSource = detected.source;
|
|
107711
|
-
this.upstreamDir =
|
|
108105
|
+
this.upstreamDir = path47.join(this.defaultProvidersDir, ".upstream");
|
|
107712
108106
|
this.disableUpstream = false;
|
|
107713
108107
|
this.applySourceConfig({
|
|
107714
108108
|
userDir: options?.userDir,
|
|
@@ -107720,14 +108114,14 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
107720
108114
|
migrateMarketplaceDirToExternal() {
|
|
107721
108115
|
try {
|
|
107722
108116
|
const configDir = getConfigDir2();
|
|
107723
|
-
const oldDir =
|
|
107724
|
-
const newDir =
|
|
107725
|
-
if (!
|
|
107726
|
-
if (
|
|
108117
|
+
const oldDir = path47.join(configDir, "marketplace");
|
|
108118
|
+
const newDir = path47.join(configDir, "external");
|
|
108119
|
+
if (!fs43.existsSync(oldDir)) return;
|
|
108120
|
+
if (fs43.existsSync(newDir)) {
|
|
107727
108121
|
this.log(`Migration skipped: both ~/.adhdev/marketplace and ~/.adhdev/external exist (marketplace dir is now inert and can be removed manually).`);
|
|
107728
108122
|
return;
|
|
107729
108123
|
}
|
|
107730
|
-
|
|
108124
|
+
fs43.renameSync(oldDir, newDir);
|
|
107731
108125
|
this.log(`Migrated ~/.adhdev/marketplace \u2192 ~/.adhdev/external (one-time rename after provider source-layer cleanup).`);
|
|
107732
108126
|
} catch (e) {
|
|
107733
108127
|
this.log(`Marketplace\u2192external migration failed: ${e?.message || e}`);
|
|
@@ -107757,7 +108151,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
107757
108151
|
* Highest-priority editable overrides come first.
|
|
107758
108152
|
*/
|
|
107759
108153
|
getProviderRoots() {
|
|
107760
|
-
const externalDir =
|
|
108154
|
+
const externalDir = path47.join(getConfigDir2(), "external");
|
|
107761
108155
|
return [this.userDir, externalDir, ...this.channelObjectRoots, this.upstreamDir];
|
|
107762
108156
|
}
|
|
107763
108157
|
getSourceConfig() {
|
|
@@ -107785,7 +108179,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
107785
108179
|
this.userDir = detected.path;
|
|
107786
108180
|
this.userDirSource = detected.source;
|
|
107787
108181
|
}
|
|
107788
|
-
this.upstreamDir =
|
|
108182
|
+
this.upstreamDir = path47.join(this.defaultProvidersDir, ".upstream");
|
|
107789
108183
|
this.disableUpstream = this.sourceMode === "no-upstream";
|
|
107790
108184
|
if (this.explicitProviderDir) {
|
|
107791
108185
|
this.log(`Config 'providerDir' applied: ${this.userDir}`);
|
|
@@ -107799,7 +108193,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
107799
108193
|
* Canonical provider directory shape for a given root.
|
|
107800
108194
|
*/
|
|
107801
108195
|
getProviderDir(root, category, type2) {
|
|
107802
|
-
return
|
|
108196
|
+
return path47.join(root, category, type2);
|
|
107803
108197
|
}
|
|
107804
108198
|
/**
|
|
107805
108199
|
* Canonical user override directory for a provider.
|
|
@@ -107826,7 +108220,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
107826
108220
|
resolveProviderFile(type2, ...segments) {
|
|
107827
108221
|
const dir = this.findProviderDirInternal(type2);
|
|
107828
108222
|
if (!dir) return null;
|
|
107829
|
-
return
|
|
108223
|
+
return path47.join(dir, ...segments);
|
|
107830
108224
|
}
|
|
107831
108225
|
/**
|
|
107832
108226
|
* Load all providers (3-tier priority)
|
|
@@ -107847,7 +108241,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
107847
108241
|
this.providers.clear();
|
|
107848
108242
|
this.providerAvailability.clear();
|
|
107849
108243
|
let upstreamCount = 0;
|
|
107850
|
-
if (!this.disableUpstream &&
|
|
108244
|
+
if (!this.disableUpstream && fs43.existsSync(this.upstreamDir)) {
|
|
107851
108245
|
upstreamCount = this.loadDir(this.upstreamDir);
|
|
107852
108246
|
if (upstreamCount > 0) {
|
|
107853
108247
|
this.log(`Loaded ${upstreamCount} upstream providers (auto-updated)`);
|
|
@@ -107856,11 +108250,11 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
107856
108250
|
this.log("Upstream loading disabled (sourceMode=no-upstream)");
|
|
107857
108251
|
}
|
|
107858
108252
|
this.loadVerifiedChannelActivations();
|
|
107859
|
-
const externalDir =
|
|
107860
|
-
if (
|
|
108253
|
+
const externalDir = path47.join(getConfigDir2(), "external");
|
|
108254
|
+
if (fs43.existsSync(externalDir)) {
|
|
107861
108255
|
const rootEntries = (() => {
|
|
107862
108256
|
try {
|
|
107863
|
-
return
|
|
108257
|
+
return fs43.readdirSync(externalDir, { withFileTypes: true });
|
|
107864
108258
|
} catch {
|
|
107865
108259
|
return [];
|
|
107866
108260
|
}
|
|
@@ -107878,7 +108272,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
107878
108272
|
const ambiguousTypes = [];
|
|
107879
108273
|
for (const sourceEntry of rootEntries) {
|
|
107880
108274
|
if (!sourceEntry.isDirectory()) continue;
|
|
107881
|
-
const sourceDir =
|
|
108275
|
+
const sourceDir = path47.join(externalDir, sourceEntry.name);
|
|
107882
108276
|
const sourceLoaded = this.loadDir(sourceDir);
|
|
107883
108277
|
if (sourceLoaded > 0) {
|
|
107884
108278
|
totalLoaded += sourceLoaded;
|
|
@@ -107894,7 +108288,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
107894
108288
|
ambiguousTypes.push({ type: type2, chosen: resolved.source ?? "?", candidates: resolved.candidates });
|
|
107895
108289
|
}
|
|
107896
108290
|
if (resolved.source && resolved.source !== "?") {
|
|
107897
|
-
const sourceDir =
|
|
108291
|
+
const sourceDir = path47.join(externalDir, resolved.source);
|
|
107898
108292
|
const reloadCount = this.loadDir(sourceDir);
|
|
107899
108293
|
if (reloadCount === 0) {
|
|
107900
108294
|
this.log(`Active source "${resolved.source}" no longer provides ${type2}`);
|
|
@@ -107909,7 +108303,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
107909
108303
|
}
|
|
107910
108304
|
}
|
|
107911
108305
|
}
|
|
107912
|
-
if (
|
|
108306
|
+
if (fs43.existsSync(this.userDir)) {
|
|
107913
108307
|
const userCount = this.loadDir(this.userDir, [".upstream"]);
|
|
107914
108308
|
if (userCount > 0) {
|
|
107915
108309
|
this.log(`Loaded ${userCount} user custom providers (never auto-updated)`);
|
|
@@ -108047,18 +108441,18 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
108047
108441
|
if (this.countVerifiedChannelPointers() > 0) return null;
|
|
108048
108442
|
if (this.hasUpstream()) return this.syncVerifiedChannel();
|
|
108049
108443
|
try {
|
|
108050
|
-
|
|
108444
|
+
fs43.mkdirSync(this.defaultProvidersDir, { recursive: true });
|
|
108051
108445
|
} catch {
|
|
108052
108446
|
}
|
|
108053
108447
|
return this.syncVerifiedChannel({ bootstrapAll: true });
|
|
108054
108448
|
}
|
|
108055
108449
|
/** Stamp path recording which daemon version last ran a successful verified sync. */
|
|
108056
108450
|
channelActivationStampPath() {
|
|
108057
|
-
return
|
|
108451
|
+
return path47.join(this.defaultProvidersDir, ".channel-activation-stamp.json");
|
|
108058
108452
|
}
|
|
108059
108453
|
readChannelActivationStamp() {
|
|
108060
108454
|
try {
|
|
108061
|
-
return JSON.parse(
|
|
108455
|
+
return JSON.parse(fs43.readFileSync(this.channelActivationStampPath(), "utf-8"));
|
|
108062
108456
|
} catch {
|
|
108063
108457
|
return null;
|
|
108064
108458
|
}
|
|
@@ -108066,8 +108460,8 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
108066
108460
|
writeChannelActivationStamp() {
|
|
108067
108461
|
if (!this.daemonVersion) return;
|
|
108068
108462
|
try {
|
|
108069
|
-
|
|
108070
|
-
|
|
108463
|
+
fs43.mkdirSync(this.defaultProvidersDir, { recursive: true });
|
|
108464
|
+
fs43.writeFileSync(this.channelActivationStampPath(), JSON.stringify({
|
|
108071
108465
|
daemonVersion: this.daemonVersion,
|
|
108072
108466
|
channel: this.channel,
|
|
108073
108467
|
syncedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
@@ -108211,10 +108605,10 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
108211
108605
|
* Check if upstream directory exists and has providers.
|
|
108212
108606
|
*/
|
|
108213
108607
|
hasUpstream() {
|
|
108214
|
-
if (!
|
|
108608
|
+
if (!fs43.existsSync(this.upstreamDir)) return false;
|
|
108215
108609
|
try {
|
|
108216
|
-
return
|
|
108217
|
-
(d) =>
|
|
108610
|
+
return fs43.readdirSync(this.upstreamDir).some(
|
|
108611
|
+
(d) => fs43.statSync(path47.join(this.upstreamDir, d)).isDirectory()
|
|
108218
108612
|
);
|
|
108219
108613
|
} catch {
|
|
108220
108614
|
return false;
|
|
@@ -108762,8 +109156,8 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
108762
109156
|
resolved._resolvedScriptDir = entry.scriptDir;
|
|
108763
109157
|
resolved._resolvedScriptsSource = `compatibility:${entry.ideVersion}`;
|
|
108764
109158
|
if (providerDir) {
|
|
108765
|
-
const fullDir =
|
|
108766
|
-
resolved._resolvedScriptsPath =
|
|
109159
|
+
const fullDir = path47.join(providerDir, entry.scriptDir);
|
|
109160
|
+
resolved._resolvedScriptsPath = fs43.existsSync(path47.join(fullDir, "scripts.js")) ? path47.join(fullDir, "scripts.js") : fullDir;
|
|
108767
109161
|
}
|
|
108768
109162
|
matched = true;
|
|
108769
109163
|
}
|
|
@@ -108781,8 +109175,8 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
108781
109175
|
resolved._resolvedScriptDir = base.defaultScriptDir;
|
|
108782
109176
|
resolved._resolvedScriptsSource = "defaultScriptDir:version_miss";
|
|
108783
109177
|
if (providerDir) {
|
|
108784
|
-
const fullDir =
|
|
108785
|
-
resolved._resolvedScriptsPath =
|
|
109178
|
+
const fullDir = path47.join(providerDir, base.defaultScriptDir);
|
|
109179
|
+
resolved._resolvedScriptsPath = fs43.existsSync(path47.join(fullDir, "scripts.js")) ? path47.join(fullDir, "scripts.js") : fullDir;
|
|
108786
109180
|
}
|
|
108787
109181
|
}
|
|
108788
109182
|
resolved._versionWarning = `Version ${currentVersion} not in compatibility matrix. Using default scripts.`;
|
|
@@ -108799,8 +109193,8 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
108799
109193
|
resolved._resolvedScriptDir = dirOverride;
|
|
108800
109194
|
resolved._resolvedScriptsSource = `versions:${range}`;
|
|
108801
109195
|
if (providerDir) {
|
|
108802
|
-
const fullDir =
|
|
108803
|
-
resolved._resolvedScriptsPath =
|
|
109196
|
+
const fullDir = path47.join(providerDir, dirOverride);
|
|
109197
|
+
resolved._resolvedScriptsPath = fs43.existsSync(path47.join(fullDir, "scripts.js")) ? path47.join(fullDir, "scripts.js") : fullDir;
|
|
108804
109198
|
}
|
|
108805
109199
|
}
|
|
108806
109200
|
} else if (override.scripts) {
|
|
@@ -108816,8 +109210,8 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
108816
109210
|
resolved._resolvedScriptDir = base.defaultScriptDir;
|
|
108817
109211
|
resolved._resolvedScriptsSource = "defaultScriptDir:no_version";
|
|
108818
109212
|
if (providerDir) {
|
|
108819
|
-
const fullDir =
|
|
108820
|
-
resolved._resolvedScriptsPath =
|
|
109213
|
+
const fullDir = path47.join(providerDir, base.defaultScriptDir);
|
|
109214
|
+
resolved._resolvedScriptsPath = fs43.existsSync(path47.join(fullDir, "scripts.js")) ? path47.join(fullDir, "scripts.js") : fullDir;
|
|
108821
109215
|
}
|
|
108822
109216
|
}
|
|
108823
109217
|
}
|
|
@@ -108834,13 +109228,13 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
108834
109228
|
if (providerDir2) {
|
|
108835
109229
|
for (const [scriptName, override] of Object.entries(base.overrides)) {
|
|
108836
109230
|
if (!override || typeof override.path !== "string") continue;
|
|
108837
|
-
const fullPath =
|
|
108838
|
-
if (!
|
|
109231
|
+
const fullPath = path47.join(providerDir2, override.path);
|
|
109232
|
+
if (!fs43.existsSync(fullPath)) {
|
|
108839
109233
|
this.log(` [overrides] ${base.type}: ${scriptName} path not found: ${fullPath}`);
|
|
108840
109234
|
continue;
|
|
108841
109235
|
}
|
|
108842
109236
|
try {
|
|
108843
|
-
registerProviderScriptRootSafely(
|
|
109237
|
+
registerProviderScriptRootSafely(path47.dirname(path47.dirname(providerDir2)));
|
|
108844
109238
|
delete require.cache[require.resolve(fullPath)];
|
|
108845
109239
|
const fn = require(fullPath);
|
|
108846
109240
|
const target = typeof fn === "function" ? fn : fn && fn[scriptName];
|
|
@@ -108865,25 +109259,25 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
108865
109259
|
}
|
|
108866
109260
|
if (providerDir) {
|
|
108867
109261
|
try {
|
|
108868
|
-
const
|
|
108869
|
-
const
|
|
109262
|
+
const fs58 = require("fs");
|
|
109263
|
+
const path56 = require("path");
|
|
108870
109264
|
const candidates = [];
|
|
108871
109265
|
if (Array.isArray(base.compatibility)) {
|
|
108872
109266
|
for (const entry of base.compatibility) {
|
|
108873
109267
|
if (typeof entry?.spec !== "string") continue;
|
|
108874
109268
|
const matches = !entry.ideVersion || currentVersion && this.matchesVersion(currentVersion, entry.ideVersion) || !currentVersion;
|
|
108875
|
-
if (matches) candidates.push(
|
|
109269
|
+
if (matches) candidates.push(path56.join(providerDir, entry.spec));
|
|
108876
109270
|
}
|
|
108877
109271
|
}
|
|
108878
|
-
candidates.push(
|
|
108879
|
-
candidates.push(
|
|
108880
|
-
const specPath = candidates.find((p) =>
|
|
109272
|
+
candidates.push(path56.join(providerDir, "specs", "default.json"));
|
|
109273
|
+
candidates.push(path56.join(providerDir, "spec.json"));
|
|
109274
|
+
const specPath = candidates.find((p) => fs58.existsSync(p));
|
|
108881
109275
|
let nh;
|
|
108882
109276
|
if (specPath) {
|
|
108883
109277
|
resolved._resolvedSpecPath = specPath;
|
|
108884
109278
|
let specControls;
|
|
108885
109279
|
try {
|
|
108886
|
-
const rawSpec = JSON.parse(
|
|
109280
|
+
const rawSpec = JSON.parse(fs58.readFileSync(specPath, "utf8"));
|
|
108887
109281
|
specControls = rawSpec.control_bar;
|
|
108888
109282
|
nh = rawSpec.native_history;
|
|
108889
109283
|
} catch {
|
|
@@ -108925,10 +109319,10 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
108925
109319
|
lister = (input) => executeNativeHistoryList(nh, input);
|
|
108926
109320
|
}
|
|
108927
109321
|
} else if (nh.override_path) {
|
|
108928
|
-
const overrideFile =
|
|
108929
|
-
if (
|
|
109322
|
+
const overrideFile = path56.resolve(providerDir, nh.override_path);
|
|
109323
|
+
if (fs58.existsSync(overrideFile)) {
|
|
108930
109324
|
try {
|
|
108931
|
-
registerProviderScriptRootSafely(
|
|
109325
|
+
registerProviderScriptRootSafely(path56.dirname(path56.dirname(providerDir)));
|
|
108932
109326
|
delete require.cache[require.resolve(overrideFile)];
|
|
108933
109327
|
const mod = require(overrideFile);
|
|
108934
109328
|
const fn = typeof mod === "function" ? mod : mod && typeof mod.default === "function" ? mod.default : null;
|
|
@@ -108943,6 +109337,8 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
108943
109337
|
const dispatch = createNativeHistoryDispatcher(nh.reader);
|
|
108944
109338
|
format = nh.reader;
|
|
108945
109339
|
reader = (input) => dispatch(input);
|
|
109340
|
+
const listDispatch = createNativeHistoryListDispatcher(nh.reader);
|
|
109341
|
+
if (listDispatch) lister = (input) => listDispatch(input);
|
|
108946
109342
|
}
|
|
108947
109343
|
if (reader) {
|
|
108948
109344
|
resolved.scripts = { ...resolved.scripts || {} };
|
|
@@ -108976,16 +109372,16 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
108976
109372
|
this.debugLog(`[loadScriptsFromDir] ${type2}: providerDir not found`);
|
|
108977
109373
|
return null;
|
|
108978
109374
|
}
|
|
108979
|
-
const dir =
|
|
108980
|
-
if (!
|
|
109375
|
+
const dir = path47.join(providerDir, scriptDir);
|
|
109376
|
+
if (!fs43.existsSync(dir)) {
|
|
108981
109377
|
this.debugLog(`[loadScriptsFromDir] ${type2}: dir not found: ${dir}`);
|
|
108982
109378
|
return null;
|
|
108983
109379
|
}
|
|
108984
|
-
registerProviderScriptRootSafely(
|
|
109380
|
+
registerProviderScriptRootSafely(path47.dirname(path47.dirname(providerDir)));
|
|
108985
109381
|
const cached5 = this.scriptsCache.get(dir);
|
|
108986
109382
|
if (cached5) return cached5;
|
|
108987
|
-
const scriptsJs =
|
|
108988
|
-
if (
|
|
109383
|
+
const scriptsJs = path47.join(dir, "scripts.js");
|
|
109384
|
+
if (fs43.existsSync(scriptsJs)) {
|
|
108989
109385
|
try {
|
|
108990
109386
|
delete require.cache[require.resolve(scriptsJs)];
|
|
108991
109387
|
const loaded = require(scriptsJs);
|
|
@@ -109006,9 +109402,9 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
109006
109402
|
watch() {
|
|
109007
109403
|
this.stopWatch();
|
|
109008
109404
|
const watchDir = (dir) => {
|
|
109009
|
-
if (!
|
|
109405
|
+
if (!fs43.existsSync(dir)) {
|
|
109010
109406
|
try {
|
|
109011
|
-
|
|
109407
|
+
fs43.mkdirSync(dir, { recursive: true });
|
|
109012
109408
|
} catch {
|
|
109013
109409
|
return;
|
|
109014
109410
|
}
|
|
@@ -109029,7 +109425,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
109029
109425
|
if (filePath.endsWith(".js") || filePath.endsWith(".json")) {
|
|
109030
109426
|
if (reloadTimer) clearTimeout(reloadTimer);
|
|
109031
109427
|
reloadTimer = setTimeout(() => {
|
|
109032
|
-
this.log(`File changed: ${
|
|
109428
|
+
this.log(`File changed: ${path47.basename(filePath)}, reloading...`);
|
|
109033
109429
|
this.reload();
|
|
109034
109430
|
}, 300);
|
|
109035
109431
|
}
|
|
@@ -109071,15 +109467,15 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
109071
109467
|
}
|
|
109072
109468
|
/** Count provider files (provider.v1.json or provider.json — at most one per dir). */
|
|
109073
109469
|
countProviders(dir) {
|
|
109074
|
-
if (!
|
|
109470
|
+
if (!fs43.existsSync(dir)) return 0;
|
|
109075
109471
|
let count = 0;
|
|
109076
109472
|
const scan = (d) => {
|
|
109077
109473
|
try {
|
|
109078
|
-
const entries =
|
|
109474
|
+
const entries = fs43.readdirSync(d, { withFileTypes: true });
|
|
109079
109475
|
const hasManifest = entries.some((e) => e.name === "provider.v1.json" || e.name === "provider.json");
|
|
109080
109476
|
if (hasManifest) count++;
|
|
109081
109477
|
for (const entry of entries) {
|
|
109082
|
-
if (entry.isDirectory()) scan(
|
|
109478
|
+
if (entry.isDirectory()) scan(path47.join(d, entry.name));
|
|
109083
109479
|
}
|
|
109084
109480
|
} catch {
|
|
109085
109481
|
}
|
|
@@ -109305,13 +109701,13 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
109305
109701
|
if (!provider) return null;
|
|
109306
109702
|
const cat = provider.category;
|
|
109307
109703
|
const searchRoots = this.getProviderRoots();
|
|
109308
|
-
const hasManifest = (dir) =>
|
|
109704
|
+
const hasManifest = (dir) => fs43.existsSync(path47.join(dir, "provider.v1.json")) || fs43.existsSync(path47.join(dir, "provider.json"));
|
|
109309
109705
|
const readManifestType = (dir) => {
|
|
109310
109706
|
for (const file2 of ["provider.v1.json", "provider.json"]) {
|
|
109311
|
-
const p =
|
|
109312
|
-
if (!
|
|
109707
|
+
const p = path47.join(dir, file2);
|
|
109708
|
+
if (!fs43.existsSync(p)) continue;
|
|
109313
109709
|
try {
|
|
109314
|
-
const data = JSON.parse(
|
|
109710
|
+
const data = JSON.parse(fs43.readFileSync(p, "utf-8"));
|
|
109315
109711
|
if (typeof data?.type === "string") return data.type;
|
|
109316
109712
|
} catch {
|
|
109317
109713
|
}
|
|
@@ -109319,15 +109715,15 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
109319
109715
|
return null;
|
|
109320
109716
|
};
|
|
109321
109717
|
for (const root of searchRoots) {
|
|
109322
|
-
if (!
|
|
109718
|
+
if (!fs43.existsSync(root)) continue;
|
|
109323
109719
|
const candidate = this.getProviderDir(root, cat, type2);
|
|
109324
109720
|
if (hasManifest(candidate)) return candidate;
|
|
109325
|
-
const catDir =
|
|
109326
|
-
if (
|
|
109721
|
+
const catDir = path47.join(root, cat);
|
|
109722
|
+
if (fs43.existsSync(catDir)) {
|
|
109327
109723
|
try {
|
|
109328
|
-
for (const entry of
|
|
109724
|
+
for (const entry of fs43.readdirSync(catDir, { withFileTypes: true })) {
|
|
109329
109725
|
if (!entry.isDirectory()) continue;
|
|
109330
|
-
const entryDir =
|
|
109726
|
+
const entryDir = path47.join(catDir, entry.name);
|
|
109331
109727
|
const manifestType = readManifestType(entryDir);
|
|
109332
109728
|
if (manifestType === type2) return entryDir;
|
|
109333
109729
|
}
|
|
@@ -109343,8 +109739,8 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
109343
109739
|
* (template substitution is NOT applied here — scripts.js handles that)
|
|
109344
109740
|
*/
|
|
109345
109741
|
buildScriptWrappersFromDir(dir) {
|
|
109346
|
-
const scriptsJs =
|
|
109347
|
-
if (
|
|
109742
|
+
const scriptsJs = path47.join(dir, "scripts.js");
|
|
109743
|
+
if (fs43.existsSync(scriptsJs)) {
|
|
109348
109744
|
try {
|
|
109349
109745
|
delete require.cache[require.resolve(scriptsJs)];
|
|
109350
109746
|
return require(scriptsJs);
|
|
@@ -109354,13 +109750,13 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
109354
109750
|
const toCamel = (name) => name.replace(/_([a-z])/g, (_, c) => c.toUpperCase());
|
|
109355
109751
|
const result = {};
|
|
109356
109752
|
try {
|
|
109357
|
-
for (const file2 of
|
|
109753
|
+
for (const file2 of fs43.readdirSync(dir)) {
|
|
109358
109754
|
if (!file2.endsWith(".js")) continue;
|
|
109359
109755
|
const scriptName = toCamel(file2.replace(".js", ""));
|
|
109360
|
-
const filePath =
|
|
109756
|
+
const filePath = path47.join(dir, file2);
|
|
109361
109757
|
result[scriptName] = (...args) => {
|
|
109362
109758
|
try {
|
|
109363
|
-
let content =
|
|
109759
|
+
let content = fs43.readFileSync(filePath, "utf-8");
|
|
109364
109760
|
if (args[0] && typeof args[0] === "object") {
|
|
109365
109761
|
for (const [key2, val] of Object.entries(args[0])) {
|
|
109366
109762
|
let v = val;
|
|
@@ -109406,12 +109802,12 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
109406
109802
|
* Structure: dir/category/agent-name/provider.{json,js}
|
|
109407
109803
|
*/
|
|
109408
109804
|
loadDir(dir, excludeDirs) {
|
|
109409
|
-
if (!
|
|
109805
|
+
if (!fs43.existsSync(dir)) return 0;
|
|
109410
109806
|
let count = 0;
|
|
109411
109807
|
const scan = (d) => {
|
|
109412
109808
|
let entries;
|
|
109413
109809
|
try {
|
|
109414
|
-
entries =
|
|
109810
|
+
entries = fs43.readdirSync(d, { withFileTypes: true });
|
|
109415
109811
|
} catch {
|
|
109416
109812
|
return;
|
|
109417
109813
|
}
|
|
@@ -109419,9 +109815,9 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
109419
109815
|
const hasJson = entries.some((e) => e.name === "provider.json");
|
|
109420
109816
|
if (hasV1 || hasJson) {
|
|
109421
109817
|
const manifestFile = hasV1 ? "provider.v1.json" : "provider.json";
|
|
109422
|
-
const jsonPath =
|
|
109818
|
+
const jsonPath = path47.join(d, manifestFile);
|
|
109423
109819
|
try {
|
|
109424
|
-
const raw =
|
|
109820
|
+
const raw = fs43.readFileSync(jsonPath, "utf-8");
|
|
109425
109821
|
const mod = JSON.parse(raw);
|
|
109426
109822
|
if (hasV1 && mod?.category === "cli") {
|
|
109427
109823
|
try {
|
|
@@ -109459,10 +109855,10 @@ ${formatManifestValidationIssues2(validation2.issues)}`);
|
|
|
109459
109855
|
this.log(`\u26A0 Invalid provider at ${jsonPath}: ${validation.errors.join("; ")}`);
|
|
109460
109856
|
} else {
|
|
109461
109857
|
const hasCompatibility = Array.isArray(normalizedProvider.compatibility);
|
|
109462
|
-
const scriptsPath =
|
|
109463
|
-
if (!hasCompatibility &&
|
|
109858
|
+
const scriptsPath = path47.join(d, "scripts.js");
|
|
109859
|
+
if (!hasCompatibility && fs43.existsSync(scriptsPath)) {
|
|
109464
109860
|
try {
|
|
109465
|
-
registerProviderScriptRootSafely(
|
|
109861
|
+
registerProviderScriptRootSafely(path47.dirname(path47.dirname(d)));
|
|
109466
109862
|
delete require.cache[require.resolve(scriptsPath)];
|
|
109467
109863
|
const scripts = require(scriptsPath);
|
|
109468
109864
|
normalizedProvider.scripts = scripts;
|
|
@@ -109470,8 +109866,8 @@ ${formatManifestValidationIssues2(validation2.issues)}`);
|
|
|
109470
109866
|
this.log(`\u26A0 Failed to load scripts: ${scriptsPath}: ${e.message}`);
|
|
109471
109867
|
}
|
|
109472
109868
|
}
|
|
109473
|
-
const externalDirAbs =
|
|
109474
|
-
const isChannelStoreObject = d.includes(`${
|
|
109869
|
+
const externalDirAbs = path47.join(getConfigDir2(), "external");
|
|
109870
|
+
const isChannelStoreObject = d.includes(`${path47.sep}.store${path47.sep}`);
|
|
109475
109871
|
const layer = d.startsWith(externalDirAbs) ? "external" : d.startsWith(this.userDir) && !d.includes(".upstream") && !isChannelStoreObject ? "user" : "upstream";
|
|
109476
109872
|
try {
|
|
109477
109873
|
const { inspectManifestShape: inspectManifestShape2, classifyTrust: classifyTrust2 } = (init_provider_trust(), __toCommonJS2(provider_trust_exports));
|
|
@@ -109481,8 +109877,8 @@ ${formatManifestValidationIssues2(validation2.issues)}`);
|
|
|
109481
109877
|
normalizedProvider._sourceTrust = trust;
|
|
109482
109878
|
normalizedProvider._manifestShape = shape;
|
|
109483
109879
|
if (layer === "external") {
|
|
109484
|
-
const rel =
|
|
109485
|
-
const firstSeg = rel.split(
|
|
109880
|
+
const rel = path47.relative(externalDirAbs, d);
|
|
109881
|
+
const firstSeg = rel.split(path47.sep)[0];
|
|
109486
109882
|
if (firstSeg && firstSeg !== "..") normalizedProvider._sourceName = firstSeg;
|
|
109487
109883
|
}
|
|
109488
109884
|
} catch {
|
|
@@ -109507,7 +109903,7 @@ ${formatManifestValidationIssues2(validation2.issues)}`);
|
|
|
109507
109903
|
if (entry.name.startsWith("_") || entry.name.startsWith(".")) continue;
|
|
109508
109904
|
if (d === dir && entry.name === "examples") continue;
|
|
109509
109905
|
if (excludeDirs && d === dir && excludeDirs.includes(entry.name)) continue;
|
|
109510
|
-
scan(
|
|
109906
|
+
scan(path47.join(d, entry.name));
|
|
109511
109907
|
}
|
|
109512
109908
|
}
|
|
109513
109909
|
};
|
|
@@ -109710,7 +110106,7 @@ ${formatManifestValidationIssues2(validation2.issues)}`);
|
|
|
109710
110106
|
});
|
|
109711
110107
|
}
|
|
109712
110108
|
async function killIdeProcess(ideId) {
|
|
109713
|
-
const plat =
|
|
110109
|
+
const plat = os27.platform();
|
|
109714
110110
|
const appName = getMacAppIdentifiers()[ideId];
|
|
109715
110111
|
const winProcesses = getWinProcessNames()[ideId];
|
|
109716
110112
|
try {
|
|
@@ -109771,7 +110167,7 @@ ${formatManifestValidationIssues2(validation2.issues)}`);
|
|
|
109771
110167
|
}
|
|
109772
110168
|
}
|
|
109773
110169
|
async function isIdeRunning(ideId) {
|
|
109774
|
-
const plat =
|
|
110170
|
+
const plat = os27.platform();
|
|
109775
110171
|
try {
|
|
109776
110172
|
if (plat === "darwin") {
|
|
109777
110173
|
const appName = getMacAppIdentifiers()[ideId];
|
|
@@ -109826,7 +110222,7 @@ ${formatManifestValidationIssues2(validation2.issues)}`);
|
|
|
109826
110222
|
}
|
|
109827
110223
|
}
|
|
109828
110224
|
async function detectCurrentWorkspace(ideId) {
|
|
109829
|
-
const plat =
|
|
110225
|
+
const plat = os27.platform();
|
|
109830
110226
|
if (plat === "darwin") {
|
|
109831
110227
|
try {
|
|
109832
110228
|
const appName = getMacAppIdentifiers()[ideId];
|
|
@@ -109841,17 +110237,17 @@ ${formatManifestValidationIssues2(validation2.issues)}`);
|
|
|
109841
110237
|
}
|
|
109842
110238
|
} else if (plat === "win32") {
|
|
109843
110239
|
try {
|
|
109844
|
-
const
|
|
110240
|
+
const fs58 = require("fs");
|
|
109845
110241
|
const appNameMap = getMacAppIdentifiers();
|
|
109846
110242
|
const appName = appNameMap[ideId];
|
|
109847
110243
|
if (appName) {
|
|
109848
|
-
const storagePath =
|
|
109849
|
-
process.env.APPDATA ||
|
|
110244
|
+
const storagePath = path48.join(
|
|
110245
|
+
process.env.APPDATA || path48.join(os27.homedir(), "AppData", "Roaming"),
|
|
109850
110246
|
appName,
|
|
109851
110247
|
"storage.json"
|
|
109852
110248
|
);
|
|
109853
|
-
if (
|
|
109854
|
-
const data = JSON.parse(
|
|
110249
|
+
if (fs58.existsSync(storagePath)) {
|
|
110250
|
+
const data = JSON.parse(fs58.readFileSync(storagePath, "utf-8"));
|
|
109855
110251
|
const workspaces = data?.openedPathsList?.workspaces3 || data?.openedPathsList?.entries || [];
|
|
109856
110252
|
if (workspaces.length > 0) {
|
|
109857
110253
|
const recent = workspaces[0];
|
|
@@ -109868,7 +110264,7 @@ ${formatManifestValidationIssues2(validation2.issues)}`);
|
|
|
109868
110264
|
return void 0;
|
|
109869
110265
|
}
|
|
109870
110266
|
async function launchWithCdp(options = {}) {
|
|
109871
|
-
const platform10 =
|
|
110267
|
+
const platform10 = os27.platform();
|
|
109872
110268
|
let targetIde;
|
|
109873
110269
|
const ides = await detectIDEs(getProviderLoader());
|
|
109874
110270
|
if (options.ideId) {
|
|
@@ -110431,11 +110827,11 @@ ${formatManifestValidationIssues2(validation2.issues)}`);
|
|
|
110431
110827
|
MESH_JSON_CONFIG_LOCATIONS: MESH_JSON_CONFIG_LOCATIONS2
|
|
110432
110828
|
} = await Promise.resolve().then(() => (init_mesh_json_config(), mesh_json_config_exports));
|
|
110433
110829
|
const { mkdirSync: mkdirSync31, writeFileSync: writeFileSync31 } = await import("fs");
|
|
110434
|
-
const { dirname:
|
|
110830
|
+
const { dirname: dirname24, join: join65 } = await import("path");
|
|
110435
110831
|
const scaffold = buildMeshJsonConfigScaffold2(mesh);
|
|
110436
110832
|
const scaffoldJson = serializeMeshJsonConfigScaffold2(scaffold);
|
|
110437
110833
|
const relativePath = MESH_JSON_CONFIG_LOCATIONS2[0];
|
|
110438
|
-
const absolutePath =
|
|
110834
|
+
const absolutePath = join65(workspace, relativePath);
|
|
110439
110835
|
const validation = normalizeRepoMeshDeclarativeConfig2(scaffold);
|
|
110440
110836
|
if (!validation.valid) {
|
|
110441
110837
|
return { success: false, meshId, error: `invalid mesh.json scaffold: ${validation.errors.join("; ")}` };
|
|
@@ -110471,7 +110867,7 @@ ${formatManifestValidationIssues2(validation2.issues)}`);
|
|
|
110471
110867
|
note: "Dry-run: nothing written. Re-run with write=true to persist to the repo (commit target). meshes.json is untouched."
|
|
110472
110868
|
};
|
|
110473
110869
|
}
|
|
110474
|
-
mkdirSync31(
|
|
110870
|
+
mkdirSync31(dirname24(absolutePath), { recursive: true });
|
|
110475
110871
|
writeFileSync31(absolutePath, `${scaffoldJson}
|
|
110476
110872
|
`, "utf-8");
|
|
110477
110873
|
return {
|
|
@@ -110541,18 +110937,18 @@ ${formatManifestValidationIssues2(validation2.issues)}`);
|
|
|
110541
110937
|
normalizeRepoMeshDeclarativeConfig: normalizeRepoMeshDeclarativeConfig2,
|
|
110542
110938
|
MESH_JSON_CONFIG_LOCATIONS: MESH_JSON_CONFIG_LOCATIONS2
|
|
110543
110939
|
} = await Promise.resolve().then(() => (init_mesh_json_config(), mesh_json_config_exports));
|
|
110544
|
-
const { existsSync:
|
|
110545
|
-
const { dirname:
|
|
110940
|
+
const { existsSync: existsSync65, readFileSync: readFileSync54, mkdirSync: mkdirSync31, writeFileSync: writeFileSync31 } = await import("fs");
|
|
110941
|
+
const { dirname: dirname24, join: join65 } = await import("path");
|
|
110546
110942
|
const yaml6 = await Promise.resolve().then(() => (init_js_yaml(), js_yaml_exports));
|
|
110547
110943
|
const relativePath = MESH_JSON_CONFIG_LOCATIONS2[0];
|
|
110548
110944
|
let baseDoc = { version: 1 };
|
|
110549
|
-
let existingPath =
|
|
110945
|
+
let existingPath = join65(workspace, relativePath);
|
|
110550
110946
|
let existedAsYaml = false;
|
|
110551
110947
|
for (const relative8 of MESH_JSON_CONFIG_LOCATIONS2) {
|
|
110552
|
-
const candidate =
|
|
110553
|
-
if (!
|
|
110948
|
+
const candidate = join65(workspace, relative8);
|
|
110949
|
+
if (!existsSync65(candidate)) continue;
|
|
110554
110950
|
try {
|
|
110555
|
-
const text =
|
|
110951
|
+
const text = readFileSync54(candidate, "utf-8");
|
|
110556
110952
|
const parsed = /\.json$/i.test(candidate) ? JSON.parse(text) : yaml6.load(text);
|
|
110557
110953
|
if (parsed && typeof parsed === "object" && !Array.isArray(parsed)) {
|
|
110558
110954
|
baseDoc = parsed;
|
|
@@ -110606,7 +111002,7 @@ ${formatManifestValidationIssues2(validation2.issues)}`);
|
|
|
110606
111002
|
note: "Dry-run: nothing written. Re-run with write=true to persist. Only the providerDefaults zone is merged; other repo zones are preserved."
|
|
110607
111003
|
};
|
|
110608
111004
|
}
|
|
110609
|
-
mkdirSync31(
|
|
111005
|
+
mkdirSync31(dirname24(absolutePath), { recursive: true });
|
|
110610
111006
|
writeFileSync31(absolutePath, serialized, "utf-8");
|
|
110611
111007
|
return {
|
|
110612
111008
|
success: true,
|
|
@@ -111968,6 +112364,7 @@ ${formatManifestValidationIssues2(validation2.issues)}`);
|
|
|
111968
112364
|
};
|
|
111969
112365
|
init_dist();
|
|
111970
112366
|
init_logger();
|
|
112367
|
+
init_track_identity();
|
|
111971
112368
|
init_mesh_turn_presentation();
|
|
111972
112369
|
init_state_store();
|
|
111973
112370
|
var RESTART_BLOCKING_STATES = /* @__PURE__ */ new Set(["generating", "waiting_approval", "waiting_choice", "finalizing", "starting"]);
|
|
@@ -112031,6 +112428,16 @@ ${formatManifestValidationIssues2(validation2.issues)}`);
|
|
|
112031
112428
|
function normalizeRestartMode(value) {
|
|
112032
112429
|
return value === "restart" ? "restart" : "upgrade";
|
|
112033
112430
|
}
|
|
112431
|
+
function withRestartTargetDaemon(result, selfDaemonId) {
|
|
112432
|
+
return {
|
|
112433
|
+
...result,
|
|
112434
|
+
restartTargetDaemon: {
|
|
112435
|
+
daemonId: selfDaemonId || "unknown",
|
|
112436
|
+
track: TRACK,
|
|
112437
|
+
npmTag: IDENTITY.npmTag
|
|
112438
|
+
}
|
|
112439
|
+
};
|
|
112440
|
+
}
|
|
112034
112441
|
function restartWarnings(args) {
|
|
112035
112442
|
const warnings = [];
|
|
112036
112443
|
if (args.forced) {
|
|
@@ -112172,6 +112579,7 @@ ${formatManifestValidationIssues2(validation2.issues)}`);
|
|
|
112172
112579
|
nodeDaemonId = typeof node?.daemonId === "string" ? node.daemonId.trim() : void 0;
|
|
112173
112580
|
}
|
|
112174
112581
|
const selfDaemonId = ctx.deps.statusInstanceId;
|
|
112582
|
+
const finishHere = (result) => withRestartTargetDaemon(result, selfDaemonId);
|
|
112175
112583
|
const isRemote = nodeDaemonId && selfDaemonId && !daemonIdsEquivalent(nodeDaemonId, selfDaemonId);
|
|
112176
112584
|
if (isRemote && ctx.deps.dispatchMeshCommand && !args?._meshDirectDispatch) {
|
|
112177
112585
|
const forwarded = await ctx.deps.dispatchMeshCommand(nodeDaemonId, "restart_daemon_node", {
|
|
@@ -112184,26 +112592,26 @@ ${formatManifestValidationIssues2(validation2.issues)}`);
|
|
|
112184
112592
|
if (args?.cancelWhenIdle === true) {
|
|
112185
112593
|
const had = pendingDeferredRestarts.has(scheduleKey);
|
|
112186
112594
|
clearPendingDeferredRestart(scheduleKey);
|
|
112187
|
-
return { success: true, restarted: false, cancelled: had, deferredRestart: null };
|
|
112595
|
+
return finishHere({ success: true, restarted: false, cancelled: had, deferredRestart: null });
|
|
112188
112596
|
}
|
|
112189
112597
|
if (args?.whenIdleStatus === true) {
|
|
112190
|
-
return { success: true, restarted: false, deferredRestart: deferredRestartInfo(scheduleKey) };
|
|
112598
|
+
return finishHere({ success: true, restarted: false, deferredRestart: deferredRestartInfo(scheduleKey) });
|
|
112191
112599
|
}
|
|
112192
112600
|
const blocking = collectBlockingSessions(ctx.deps, meshId);
|
|
112193
112601
|
if (blocking.length > 0) {
|
|
112194
112602
|
if (args?.force === true) {
|
|
112195
112603
|
LOG2.warn("MeshRestart", `force restart over ${blocking.length} blocking session(s): ${blocking.map((b) => `${b.instanceId || "?"}(${b.status})`).join(", ")} \u2014 pendingOutboundQueue will be lost`);
|
|
112196
|
-
return executeRestart(ctx.deps, args, { forced: true });
|
|
112604
|
+
return finishHere(await executeRestart(ctx.deps, args, { forced: true }));
|
|
112197
112605
|
}
|
|
112198
112606
|
const foreignBlocking = blocking.filter((b) => !b.selfCoordinator || b.pendingOutbound);
|
|
112199
112607
|
if (args?.selfOnly === true && foreignBlocking.length === 0) {
|
|
112200
112608
|
LOG2.info("MeshRestart", `selfOnly restart: waiving ${blocking.length} self-coordinator session(s) for mesh ${meshId}`);
|
|
112201
|
-
return executeRestart(ctx.deps, args, { forced: false });
|
|
112609
|
+
return finishHere(await executeRestart(ctx.deps, args, { forced: false }));
|
|
112202
112610
|
}
|
|
112203
112611
|
if (args?.whenIdle === true) {
|
|
112204
|
-
return scheduleDeferredRestart(ctx.deps, args, meshId, nodeId);
|
|
112612
|
+
return finishHere(scheduleDeferredRestart(ctx.deps, args, meshId, nodeId));
|
|
112205
112613
|
}
|
|
112206
|
-
return {
|
|
112614
|
+
return finishHere({
|
|
112207
112615
|
success: false,
|
|
112208
112616
|
restarted: false,
|
|
112209
112617
|
code: "blocking_sessions",
|
|
@@ -112215,9 +112623,9 @@ ${formatManifestValidationIssues2(validation2.issues)}`);
|
|
|
112215
112623
|
whenIdle: "schedule the restart to run automatically once the daemon goes idle (safest)"
|
|
112216
112624
|
},
|
|
112217
112625
|
deferredRestart: deferredRestartInfo(scheduleKey)
|
|
112218
|
-
};
|
|
112626
|
+
});
|
|
112219
112627
|
}
|
|
112220
|
-
return executeRestart(ctx.deps, args, { forced: false });
|
|
112628
|
+
return finishHere(await executeRestart(ctx.deps, args, { forced: false }));
|
|
112221
112629
|
}
|
|
112222
112630
|
};
|
|
112223
112631
|
init_cli_detector();
|
|
@@ -112370,7 +112778,7 @@ ${formatManifestValidationIssues2(validation2.issues)}`);
|
|
|
112370
112778
|
}
|
|
112371
112779
|
};
|
|
112372
112780
|
var import_path16 = require("path");
|
|
112373
|
-
var
|
|
112781
|
+
var fs44 = __toESM2(require("fs"));
|
|
112374
112782
|
init_logger();
|
|
112375
112783
|
init_mesh_host_ownership();
|
|
112376
112784
|
init_coordinator_registry();
|
|
@@ -112651,15 +113059,15 @@ ${ptyResult.output.slice(-2e3)}`);
|
|
|
112651
113059
|
}
|
|
112652
113060
|
if (cliType === "codex-cli") {
|
|
112653
113061
|
const repoMcpConfigPath = (0, import_path16.join)(workspace, ".mcp.json");
|
|
112654
|
-
if (
|
|
113062
|
+
if (fs44.existsSync(repoMcpConfigPath)) {
|
|
112655
113063
|
try {
|
|
112656
113064
|
const repoMcpConfig = parseMeshCoordinatorMcpConfig(
|
|
112657
|
-
|
|
113065
|
+
fs44.readFileSync(repoMcpConfigPath, "utf-8"),
|
|
112658
113066
|
"claude_mcp_json"
|
|
112659
113067
|
);
|
|
112660
113068
|
const existingServers2 = repoMcpConfig.mcpServers;
|
|
112661
113069
|
if (existingServers2 && typeof existingServers2 === "object" && !Array.isArray(existingServers2) && existingServers2[coordinatorSetup.serverName]) {
|
|
112662
|
-
|
|
113070
|
+
fs44.writeFileSync(repoMcpConfigPath, serializeMeshCoordinatorMcpConfig({
|
|
112663
113071
|
...repoMcpConfig,
|
|
112664
113072
|
mcpServers: {
|
|
112665
113073
|
...existingServers2,
|
|
@@ -112822,8 +113230,8 @@ ${ptyResult.output.slice(-2e3)}`);
|
|
|
112822
113230
|
workspace
|
|
112823
113231
|
};
|
|
112824
113232
|
}
|
|
112825
|
-
const { existsSync:
|
|
112826
|
-
const { dirname:
|
|
113233
|
+
const { existsSync: existsSync65, readFileSync: readFileSync54, writeFileSync: writeFileSync31, copyFileSync: copyFileSync3, mkdirSync: mkdirSync31 } = await import("fs");
|
|
113234
|
+
const { dirname: dirname24 } = await import("path");
|
|
112827
113235
|
const mcpConfigPath = coordinatorSetup.configPath;
|
|
112828
113236
|
const hermesManualFallback = cliType === "hermes-cli" && configFormat === "hermes_config_yaml" ? createHermesManualMeshCoordinatorSetup(meshId, workspace) : null;
|
|
112829
113237
|
let hermesBaseConfig = null;
|
|
@@ -112860,21 +113268,21 @@ ${ptyResult.output.slice(-2e3)}`);
|
|
|
112860
113268
|
...mcpServerEnv ? { env: mcpServerEnv } : {}
|
|
112861
113269
|
});
|
|
112862
113270
|
try {
|
|
112863
|
-
mkdirSync31(
|
|
113271
|
+
mkdirSync31(dirname24(mcpConfigPath), { recursive: true });
|
|
112864
113272
|
} catch (error48) {
|
|
112865
113273
|
const message = `Could not prepare MCP config path for automatic setup: ${error48?.message || error48}`;
|
|
112866
113274
|
LOG2.error("MeshCoordinator", message);
|
|
112867
113275
|
if (hermesManualFallback) return returnManualFallback(message);
|
|
112868
113276
|
return { success: false, code: "mesh_coordinator_config_write_failed", error: message, meshId, cliType, workspace };
|
|
112869
113277
|
}
|
|
112870
|
-
const hadExistingMcpConfig =
|
|
113278
|
+
const hadExistingMcpConfig = existsSync65(mcpConfigPath);
|
|
112871
113279
|
let existingMcpConfig = hermesBaseConfig?.config || {};
|
|
112872
113280
|
if (hermesBaseConfig) {
|
|
112873
|
-
copyHermesCoordinatorCredentialFiles(hermesBaseConfig.sourceHome,
|
|
113281
|
+
copyHermesCoordinatorCredentialFiles(hermesBaseConfig.sourceHome, dirname24(mcpConfigPath));
|
|
112874
113282
|
}
|
|
112875
113283
|
if (hadExistingMcpConfig) {
|
|
112876
113284
|
try {
|
|
112877
|
-
const parsedExistingMcpConfig = parseMeshCoordinatorMcpConfig(
|
|
113285
|
+
const parsedExistingMcpConfig = parseMeshCoordinatorMcpConfig(readFileSync54(mcpConfigPath, "utf-8"), configFormat);
|
|
112878
113286
|
const existingCoordinatorConfig = hermesManualFallback ? stripHermesCoordinatorTempModelProviderOverrides(parsedExistingMcpConfig) : parsedExistingMcpConfig;
|
|
112879
113287
|
existingMcpConfig = { ...existingMcpConfig, ...existingCoordinatorConfig };
|
|
112880
113288
|
copyFileSync3(mcpConfigPath, mcpConfigPath + ".backup");
|
|
@@ -112908,7 +113316,7 @@ ${ptyResult.output.slice(-2e3)}`);
|
|
|
112908
113316
|
const cliArgs = [];
|
|
112909
113317
|
const launchEnv = {};
|
|
112910
113318
|
if (configFormat === "hermes_config_yaml") {
|
|
112911
|
-
launchEnv.HERMES_HOME =
|
|
113319
|
+
launchEnv.HERMES_HOME = dirname24(mcpConfigPath);
|
|
112912
113320
|
launchEnv.HERMES_IGNORE_USER_CONFIG = "";
|
|
112913
113321
|
}
|
|
112914
113322
|
let autoImportContextFilePath;
|
|
@@ -113028,7 +113436,7 @@ ${ptyResult.output.slice(-2e3)}`);
|
|
|
113028
113436
|
}
|
|
113029
113437
|
}
|
|
113030
113438
|
};
|
|
113031
|
-
var
|
|
113439
|
+
var fs45 = __toESM2(require("fs"));
|
|
113032
113440
|
var import_os4 = require("os");
|
|
113033
113441
|
init_config();
|
|
113034
113442
|
init_git_status();
|
|
@@ -113076,10 +113484,10 @@ ${ptyResult.output.slice(-2e3)}`);
|
|
|
113076
113484
|
}
|
|
113077
113485
|
}
|
|
113078
113486
|
function readRecord7(repoRoot) {
|
|
113079
|
-
const
|
|
113080
|
-
if (!(0, import_node_fs4.existsSync)(
|
|
113487
|
+
const path56 = (0, import_node_path4.resolve)(repoRoot, PREVIEW_DEPLOY_RECORD);
|
|
113488
|
+
if (!(0, import_node_fs4.existsSync)(path56)) return null;
|
|
113081
113489
|
try {
|
|
113082
|
-
const parsed = JSON.parse((0, import_node_fs4.readFileSync)(
|
|
113490
|
+
const parsed = JSON.parse((0, import_node_fs4.readFileSync)(path56, "utf8"));
|
|
113083
113491
|
return parsed && typeof parsed === "object" && !Array.isArray(parsed) ? parsed : null;
|
|
113084
113492
|
} catch {
|
|
113085
113493
|
return null;
|
|
@@ -113397,7 +113805,7 @@ ${ptyResult.output.slice(-2e3)}`);
|
|
|
113397
113805
|
}
|
|
113398
113806
|
}
|
|
113399
113807
|
if (workspace) {
|
|
113400
|
-
if (!
|
|
113808
|
+
if (!fs45.existsSync(workspace)) {
|
|
113401
113809
|
const inlineTransitGit = buildInlineMeshTransitGitStatus(node);
|
|
113402
113810
|
let remoteProbeApplied = false;
|
|
113403
113811
|
if (inlineTransitGit) {
|
|
@@ -113536,7 +113944,7 @@ ${ptyResult.output.slice(-2e3)}`);
|
|
|
113536
113944
|
const pendingRetentionCounters2 = { ...getPendingRetentionCounters() };
|
|
113537
113945
|
const turnPresentationCounters = getTurnPresentationMetrics();
|
|
113538
113946
|
const previewFreshness = (() => {
|
|
113539
|
-
const localRepoRoot = nodeStatuses.map((node) => readStringValue(node?.git?.repoRoot, node?.repoRoot, node?.workspace)).find((candidate) => !!candidate &&
|
|
113947
|
+
const localRepoRoot = nodeStatuses.map((node) => readStringValue(node?.git?.repoRoot, node?.repoRoot, node?.workspace)).find((candidate) => !!candidate && fs45.existsSync(candidate));
|
|
113540
113948
|
return localRepoRoot ? buildPreviewFreshness(localRepoRoot) : void 0;
|
|
113541
113949
|
})();
|
|
113542
113950
|
const asyncRefineJobs = buildMeshAsyncRefineJobs({
|
|
@@ -113668,7 +114076,7 @@ ${ptyResult.output.slice(-2e3)}`);
|
|
|
113668
114076
|
const { deriveMeshReviewInboxItems: deriveMeshReviewInboxItems2 } = await Promise.resolve().then(() => (init_mesh_review_inbox(), mesh_review_inbox_exports));
|
|
113669
114077
|
const { readLedgerEntries: readLedgerEntries2 } = await Promise.resolve().then(() => (init_mesh_ledger(), mesh_ledger_exports));
|
|
113670
114078
|
const { getGitDiffSummary: getGitDiffSummary2 } = await Promise.resolve().then(() => (init_git_diff(), git_diff_exports));
|
|
113671
|
-
const { existsSync:
|
|
114079
|
+
const { existsSync: existsSync65 } = await import("fs");
|
|
113672
114080
|
const meshRecord = await ctx.getMeshForCommand(meshId, args?.inlineMesh, { preferInline: true });
|
|
113673
114081
|
const mesh = meshRecord?.mesh;
|
|
113674
114082
|
if (!mesh) return { success: false, error: "Mesh not found" };
|
|
@@ -113687,7 +114095,7 @@ ${ptyResult.output.slice(-2e3)}`);
|
|
|
113687
114095
|
const derivation = deriveMeshReviewInboxItems2({ nodes: nodeStatuses, ledgerEntries });
|
|
113688
114096
|
for (const item of derivation.items) {
|
|
113689
114097
|
const workspace = item.workspace;
|
|
113690
|
-
if (!workspace || !
|
|
114098
|
+
if (!workspace || !existsSync65(workspace)) continue;
|
|
113691
114099
|
const baseRef = item.defaultBranch ? `origin/${item.defaultBranch}` : "origin/main";
|
|
113692
114100
|
try {
|
|
113693
114101
|
const diffResult = await getGitDiffSummary2(workspace, { baseRef, maxFiles: 100 });
|
|
@@ -113734,8 +114142,8 @@ ${ptyResult.output.slice(-2e3)}`);
|
|
|
113734
114142
|
);
|
|
113735
114143
|
init_dist();
|
|
113736
114144
|
init_logger();
|
|
113737
|
-
var
|
|
113738
|
-
var
|
|
114145
|
+
var fs46 = __toESM2(require("fs"));
|
|
114146
|
+
var path49 = __toESM2(require("path"));
|
|
113739
114147
|
init_config_dir();
|
|
113740
114148
|
var MAX_FILE_SIZE = 5 * 1024 * 1024;
|
|
113741
114149
|
var MAX_DAYS = 7;
|
|
@@ -113780,10 +114188,10 @@ ${ptyResult.output.slice(-2e3)}`);
|
|
|
113780
114188
|
const dirChanged = dir !== currentDir;
|
|
113781
114189
|
currentDate2 = today;
|
|
113782
114190
|
currentDir = dir;
|
|
113783
|
-
currentFile =
|
|
114191
|
+
currentFile = path49.join(dir, `commands-${today}.jsonl`);
|
|
113784
114192
|
if (dirChanged) {
|
|
113785
114193
|
try {
|
|
113786
|
-
|
|
114194
|
+
fs46.mkdirSync(dir, { recursive: true });
|
|
113787
114195
|
} catch {
|
|
113788
114196
|
}
|
|
113789
114197
|
cleanOldFiles();
|
|
@@ -113791,7 +114199,7 @@ ${ptyResult.output.slice(-2e3)}`);
|
|
|
113791
114199
|
}
|
|
113792
114200
|
function cleanOldFiles() {
|
|
113793
114201
|
try {
|
|
113794
|
-
const files =
|
|
114202
|
+
const files = fs46.readdirSync(currentDir).filter((f) => f.startsWith("commands-") && f.endsWith(".jsonl"));
|
|
113795
114203
|
const cutoff = /* @__PURE__ */ new Date();
|
|
113796
114204
|
cutoff.setDate(cutoff.getDate() - MAX_DAYS);
|
|
113797
114205
|
const cutoffStr = cutoff.toISOString().slice(0, 10);
|
|
@@ -113799,7 +114207,7 @@ ${ptyResult.output.slice(-2e3)}`);
|
|
|
113799
114207
|
const dateMatch = file2.match(/commands-(\d{4}-\d{2}-\d{2})/);
|
|
113800
114208
|
if (dateMatch && dateMatch[1] < cutoffStr) {
|
|
113801
114209
|
try {
|
|
113802
|
-
|
|
114210
|
+
fs46.unlinkSync(path49.join(currentDir, file2));
|
|
113803
114211
|
} catch {
|
|
113804
114212
|
}
|
|
113805
114213
|
}
|
|
@@ -113809,14 +114217,14 @@ ${ptyResult.output.slice(-2e3)}`);
|
|
|
113809
114217
|
}
|
|
113810
114218
|
function checkSize() {
|
|
113811
114219
|
try {
|
|
113812
|
-
const stat2 =
|
|
114220
|
+
const stat2 = fs46.statSync(currentFile);
|
|
113813
114221
|
if (stat2.size > MAX_FILE_SIZE) {
|
|
113814
114222
|
const backup = currentFile.replace(".jsonl", ".1.jsonl");
|
|
113815
114223
|
try {
|
|
113816
|
-
|
|
114224
|
+
fs46.unlinkSync(backup);
|
|
113817
114225
|
} catch {
|
|
113818
114226
|
}
|
|
113819
|
-
|
|
114227
|
+
fs46.renameSync(currentFile, backup);
|
|
113820
114228
|
}
|
|
113821
114229
|
} catch {
|
|
113822
114230
|
}
|
|
@@ -113849,15 +114257,15 @@ ${ptyResult.output.slice(-2e3)}`);
|
|
|
113849
114257
|
...entry.error ? { err: entry.error } : {},
|
|
113850
114258
|
...entry.durationMs !== void 0 ? { ms: entry.durationMs } : {}
|
|
113851
114259
|
});
|
|
113852
|
-
|
|
114260
|
+
fs46.appendFileSync(currentFile, line + "\n");
|
|
113853
114261
|
} catch {
|
|
113854
114262
|
}
|
|
113855
114263
|
}
|
|
113856
114264
|
function getRecentCommands(count = 50) {
|
|
113857
114265
|
try {
|
|
113858
114266
|
refreshCurrentFile();
|
|
113859
|
-
if (!
|
|
113860
|
-
const content =
|
|
114267
|
+
if (!fs46.existsSync(currentFile)) return [];
|
|
114268
|
+
const content = fs46.readFileSync(currentFile, "utf-8");
|
|
113861
114269
|
const lines = content.trim().split("\n").filter(Boolean);
|
|
113862
114270
|
return lines.slice(-count).map((line) => {
|
|
113863
114271
|
try {
|
|
@@ -113882,9 +114290,10 @@ ${ptyResult.output.slice(-2e3)}`);
|
|
|
113882
114290
|
}
|
|
113883
114291
|
init_debug_trace();
|
|
113884
114292
|
init_mesh_host_ownership();
|
|
113885
|
-
var
|
|
114293
|
+
var fs50 = __toESM2(require("fs"));
|
|
113886
114294
|
init_mesh_node_identity();
|
|
113887
114295
|
var import_node_child_process10 = require("child_process");
|
|
114296
|
+
var import_node_fs6 = require("fs");
|
|
113888
114297
|
init_logger();
|
|
113889
114298
|
init_debug_trace();
|
|
113890
114299
|
init_dist();
|
|
@@ -113898,9 +114307,9 @@ ${ptyResult.output.slice(-2e3)}`);
|
|
|
113898
114307
|
var execFileAsync4 = (0, import_node_util5.promisify)(import_node_child_process7.execFile);
|
|
113899
114308
|
var GIT = process.platform === "win32" ? resolveWin32Executable("git") : "git";
|
|
113900
114309
|
var MAX_CHANGED_FILES2 = 500;
|
|
113901
|
-
function topLevel(
|
|
113902
|
-
const slash =
|
|
113903
|
-
return slash === -1 ?
|
|
114310
|
+
function topLevel(path56) {
|
|
114311
|
+
const slash = path56.indexOf("/");
|
|
114312
|
+
return slash === -1 ? path56 : path56.slice(0, slash);
|
|
113904
114313
|
}
|
|
113905
114314
|
async function analyzeMeshRefineNodeChangeArea(args) {
|
|
113906
114315
|
const { nodeId, workspace, branch, baseRef, branchRef, diffCwd, submodulePaths } = args;
|
|
@@ -114003,27 +114412,27 @@ ${ptyResult.output.slice(-2e3)}`);
|
|
|
114003
114412
|
return false;
|
|
114004
114413
|
}
|
|
114005
114414
|
}
|
|
114006
|
-
async function assessScope(cwd,
|
|
114415
|
+
async function assessScope(cwd, path56, baseRef, branchRef) {
|
|
114007
114416
|
try {
|
|
114008
|
-
if (!(0, import_node_fs5.existsSync)(cwd)) return { path:
|
|
114417
|
+
if (!(0, import_node_fs5.existsSync)(cwd)) return { path: path56, verdict: "unknown", error: `path does not exist: ${cwd}` };
|
|
114009
114418
|
const liveBaseHead = await git2(cwd, ["rev-parse", baseRef]);
|
|
114010
114419
|
const branchHead = await git2(cwd, ["rev-parse", branchRef]);
|
|
114011
114420
|
if (!liveBaseHead || !branchHead) {
|
|
114012
|
-
return { path:
|
|
114421
|
+
return { path: path56, verdict: "unknown", error: "could not resolve base or branch head" };
|
|
114013
114422
|
}
|
|
114014
114423
|
if (await isAncestor(cwd, liveBaseHead, branchHead)) {
|
|
114015
|
-
return { path:
|
|
114424
|
+
return { path: path56, verdict: "clear", liveBaseHead };
|
|
114016
114425
|
}
|
|
114017
114426
|
let mergeBase;
|
|
114018
114427
|
try {
|
|
114019
114428
|
mergeBase = await git2(cwd, ["merge-base", liveBaseHead, branchHead]);
|
|
114020
114429
|
} catch {
|
|
114021
|
-
return { path:
|
|
114430
|
+
return { path: path56, verdict: "unknown", liveBaseHead, error: "no common merge base" };
|
|
114022
114431
|
}
|
|
114023
|
-
if (!mergeBase) return { path:
|
|
114024
|
-
return { path:
|
|
114432
|
+
if (!mergeBase) return { path: path56, verdict: "unknown", liveBaseHead, error: "empty merge base" };
|
|
114433
|
+
return { path: path56, verdict: "diverged", liveBaseHead, mergeBase };
|
|
114025
114434
|
} catch (e) {
|
|
114026
|
-
return { path:
|
|
114435
|
+
return { path: path56, verdict: "unknown", error: e?.message || String(e) };
|
|
114027
114436
|
}
|
|
114028
114437
|
}
|
|
114029
114438
|
async function resolveSubmodulePaths(repoRoot) {
|
|
@@ -114095,6 +114504,58 @@ ${ptyResult.output.slice(-2e3)}`);
|
|
|
114095
114504
|
const verdict = scopes.some((s2) => s2.verdict === "diverged") ? "diverged" : scopes.some((s2) => s2.verdict === "unknown") ? "unknown" : "clear";
|
|
114096
114505
|
return { verdict, scopes, touchedSubmodulePaths, durationMs: Date.now() - started };
|
|
114097
114506
|
}
|
|
114507
|
+
function classifyRefineTerminal(result) {
|
|
114508
|
+
const refineCode = typeof result.code === "string" ? result.code : "";
|
|
114509
|
+
const landing = extractRefineMergeLanding(result);
|
|
114510
|
+
const isPostMergeWarning = result.success !== true && landing.merged && landing.pushed;
|
|
114511
|
+
const kind = result.success === true ? "completed" : isPostMergeWarning ? "completed_with_warnings" : refineCode === "blocked_review" || refineCode === "worktree_missing" ? "blocked_review" : refineCode === "validation_failed" || refineCode === "validation_dependencies_missing" || refineCode === "missing_dependencies" || refineCode === "dependency_bootstrap_failed" || refineCode === "spawn_resolution_failed" || refineCode === "validation_unavailable" || refineCode === "output_limit_exceeded" ? "validation_failed" : refineCode === "submodule_reachability_failed" ? "submodule_reachability_failed" : refineCode === "merge_failed" || refineCode === "patch_equivalence_failed" || refineCode === "needs_rebase" || refineCode === "needs_rebase_with_conflicts" ? "merge_failed" : refineCode === "cleanup_failed" ? "cleanup_failed" : "merge_failed";
|
|
114512
|
+
const clean = kind === "completed";
|
|
114513
|
+
return { kind, landing, isPostMergeWarning, converged: clean || isPostMergeWarning, clean };
|
|
114514
|
+
}
|
|
114515
|
+
function refineTerminalNextStep(kind) {
|
|
114516
|
+
switch (kind) {
|
|
114517
|
+
case "blocked_review":
|
|
114518
|
+
return "Request user review/approval before attempting to merge again.";
|
|
114519
|
+
case "validation_failed":
|
|
114520
|
+
return "Fix failing tests or configure validation.bootstrapCommands and retry mesh_refine_node.";
|
|
114521
|
+
case "submodule_reachability_failed":
|
|
114522
|
+
return "Push unreachable submodule commits to origin/main, then retry mesh_refine_node.";
|
|
114523
|
+
case "merge_failed":
|
|
114524
|
+
return "Resolve merge conflicts or patch equivalence issues, then retry mesh_refine_node.";
|
|
114525
|
+
case "cleanup_failed":
|
|
114526
|
+
return "Manually remove the worktree and retry or use mesh_remove_node.";
|
|
114527
|
+
case "completed_with_warnings":
|
|
114528
|
+
return "The merge IS on origin \u2014 do NOT re-run mesh_refine_node. Only the post-merge step below needs attention (worktree cleanup / submodule alignment); treat the branch as merged_to_main.";
|
|
114529
|
+
default:
|
|
114530
|
+
return "Inspect refineStages for the failing stage and retry.";
|
|
114531
|
+
}
|
|
114532
|
+
}
|
|
114533
|
+
function buildRefineWorktreeMissingResult(nodeId, workspace, refineStages) {
|
|
114534
|
+
return {
|
|
114535
|
+
success: false,
|
|
114536
|
+
code: "worktree_missing",
|
|
114537
|
+
convergenceStatus: "blocked_review",
|
|
114538
|
+
// Never auto-retried: re-running cannot recreate the worktree, and the node has
|
|
114539
|
+
// most likely already converged.
|
|
114540
|
+
retryable: false,
|
|
114541
|
+
workspaceMissing: true,
|
|
114542
|
+
error: `The worktree directory for node '${nodeId}' no longer exists (${workspace}); nothing was merged by this run. Worktree removal is the final step of a SUCCESSFUL refine, so this node was most likely already merged and cleaned up by an earlier job \u2014 verify with 'git -C <repoRoot> log --oneline' before acting. Do NOT re-run refine to "fix" this.`,
|
|
114543
|
+
nextStep: "Verify whether the branch already merged into the base (it most likely did). If so, treat the node as merged_to_main and remove it from the mesh; only re-clone if the work is genuinely missing.",
|
|
114544
|
+
refineStages,
|
|
114545
|
+
finalBranchConvergenceState: {
|
|
114546
|
+
baseBranch: void 0,
|
|
114547
|
+
merged: false,
|
|
114548
|
+
removed: true,
|
|
114549
|
+
status: "blocked_review"
|
|
114550
|
+
}
|
|
114551
|
+
};
|
|
114552
|
+
}
|
|
114553
|
+
function extractRefineMergeLanding(result) {
|
|
114554
|
+
const fbcs = result.finalBranchConvergenceState && typeof result.finalBranchConvergenceState === "object" ? result.finalBranchConvergenceState : void 0;
|
|
114555
|
+
const merged = result.merged === true || result.mergedLocal === true || fbcs?.merged === true;
|
|
114556
|
+
const pushed = result.pushed === true || fbcs?.pushed === true;
|
|
114557
|
+
return { merged: !!merged, pushed: !!pushed && !!merged };
|
|
114558
|
+
}
|
|
114098
114559
|
init_repo_mesh_types();
|
|
114099
114560
|
init_git_status();
|
|
114100
114561
|
init_git_locale();
|
|
@@ -114103,7 +114564,7 @@ ${ptyResult.output.slice(-2e3)}`);
|
|
|
114103
114564
|
init_refine_config();
|
|
114104
114565
|
init_worktree_bootstrap_config();
|
|
114105
114566
|
var import_path17 = require("path");
|
|
114106
|
-
var
|
|
114567
|
+
var fs47 = __toESM2(require("fs"));
|
|
114107
114568
|
var import_node_child_process9 = require("child_process");
|
|
114108
114569
|
init_resolve_executable();
|
|
114109
114570
|
var GIT3 = process.platform === "win32" ? resolveWin32Executable("git") : "git";
|
|
@@ -114132,12 +114593,12 @@ ${tail}`;
|
|
|
114132
114593
|
function writeValidationFailureLog(workspace, index, candidate, streams, now = () => /* @__PURE__ */ new Date()) {
|
|
114133
114594
|
try {
|
|
114134
114595
|
const dir = (0, import_path17.join)(workspace, REFINE_VALIDATION_LOG_DIR);
|
|
114135
|
-
|
|
114596
|
+
fs47.mkdirSync(dir, { recursive: true });
|
|
114136
114597
|
const stamp = now().toISOString().replace(/[:.]/g, "-");
|
|
114137
114598
|
const file2 = (0, import_path17.join)(dir, `refine-${stamp}-${index}.log`);
|
|
114138
114599
|
const asText = (v) => typeof v === "string" ? v : v == null ? "" : String(v);
|
|
114139
114600
|
const shown = candidate.displayCommand || [candidate.command, ...candidate.args || []].join(" ");
|
|
114140
|
-
|
|
114601
|
+
fs47.writeFileSync(
|
|
114141
114602
|
file2,
|
|
114142
114603
|
`# refine validation failure
|
|
114143
114604
|
# command: ${shown}
|
|
@@ -114214,7 +114675,7 @@ ${asText(streams.stderr)}
|
|
|
114214
114675
|
const { execFileSync: execFileSync12 } = await import("child_process");
|
|
114215
114676
|
const diffArgs = ["diff", "--patch", "--full-index", fromRef, toRef];
|
|
114216
114677
|
if (excludePaths.length > 0) {
|
|
114217
|
-
diffArgs.push("--", ".", ...excludePaths.map((
|
|
114678
|
+
diffArgs.push("--", ".", ...excludePaths.map((path56) => `:(exclude)${path56}`));
|
|
114218
114679
|
}
|
|
114219
114680
|
const diff = execFileSync12(GIT3, diffArgs, {
|
|
114220
114681
|
cwd,
|
|
@@ -114559,9 +115020,9 @@ ${mergeTreeErr?.stderr || ""}`;
|
|
|
114559
115020
|
if (!trimmed) continue;
|
|
114560
115021
|
if (trimmed.startsWith("+")) {
|
|
114561
115022
|
const parts = trimmed.slice(1).trim().split(/\s+/);
|
|
114562
|
-
const
|
|
115023
|
+
const path56 = parts[1] || parts[0] || "(unknown)";
|
|
114563
115024
|
submoduleHints.push({
|
|
114564
|
-
path:
|
|
115025
|
+
path: path56,
|
|
114565
115026
|
reason: "submodule checked-out commit differs from the committed gitlink (pointer bump not committed on the root branch)"
|
|
114566
115027
|
});
|
|
114567
115028
|
}
|
|
@@ -114591,10 +115052,10 @@ ${mergeTreeErr?.stderr || ""}`;
|
|
|
114591
115052
|
}
|
|
114592
115053
|
function buildPatchEquivalenceSubmoduleConflictHint(repoRoot, baseHead, branchHead, output) {
|
|
114593
115054
|
if (!/(submodule|160000)/i.test(output) || !/(conflict|failed to merge)/i.test(output)) return void 0;
|
|
114594
|
-
const conflicts = readChangedGitlinkPaths(repoRoot, baseHead, branchHead).map((
|
|
114595
|
-
path:
|
|
114596
|
-
baseCommit: readTreeObject(repoRoot, baseHead,
|
|
114597
|
-
branchCommit: readTreeObject(repoRoot, branchHead,
|
|
115055
|
+
const conflicts = readChangedGitlinkPaths(repoRoot, baseHead, branchHead).map((path56) => ({
|
|
115056
|
+
path: path56,
|
|
115057
|
+
baseCommit: readTreeObject(repoRoot, baseHead, path56),
|
|
115058
|
+
branchCommit: readTreeObject(repoRoot, branchHead, path56)
|
|
114598
115059
|
}));
|
|
114599
115060
|
if (conflicts.length === 0) return void 0;
|
|
114600
115061
|
return {
|
|
@@ -114620,11 +115081,11 @@ ${mergeTreeErr?.stderr || ""}`;
|
|
|
114620
115081
|
if (!line.trim()) continue;
|
|
114621
115082
|
const metaAndPath = line.split(" ");
|
|
114622
115083
|
const meta3 = metaAndPath[0] || "";
|
|
114623
|
-
const
|
|
114624
|
-
if (!
|
|
115084
|
+
const path56 = metaAndPath[metaAndPath.length - 1]?.trim();
|
|
115085
|
+
if (!path56) continue;
|
|
114625
115086
|
const parts = meta3.split(/\s+/);
|
|
114626
115087
|
if (parts[0]?.includes("160000") || parts[1]?.includes("160000")) {
|
|
114627
|
-
paths.add(
|
|
115088
|
+
paths.add(path56);
|
|
114628
115089
|
}
|
|
114629
115090
|
}
|
|
114630
115091
|
return [...paths].sort();
|
|
@@ -114632,9 +115093,9 @@ ${mergeTreeErr?.stderr || ""}`;
|
|
|
114632
115093
|
return [];
|
|
114633
115094
|
}
|
|
114634
115095
|
}
|
|
114635
|
-
function readTreeObject(repoRoot, ref,
|
|
115096
|
+
function readTreeObject(repoRoot, ref, path56) {
|
|
114636
115097
|
try {
|
|
114637
|
-
const output = (0, import_node_child_process9.execFileSync)(GIT3, ["ls-tree", ref, "--",
|
|
115098
|
+
const output = (0, import_node_child_process9.execFileSync)(GIT3, ["ls-tree", ref, "--", path56], {
|
|
114638
115099
|
cwd: repoRoot,
|
|
114639
115100
|
encoding: "utf8",
|
|
114640
115101
|
maxBuffer: 1024 * 1024
|
|
@@ -114657,7 +115118,7 @@ ${mergeTreeErr?.stderr || ""}`;
|
|
|
114657
115118
|
if (!baseCommit || !branchCommit) return false;
|
|
114658
115119
|
if (baseCommit === branchCommit) return true;
|
|
114659
115120
|
try {
|
|
114660
|
-
if (!
|
|
115121
|
+
if (!fs47.existsSync(submoduleRepoPath)) return false;
|
|
114661
115122
|
(0, import_node_child_process9.execFileSync)(GIT3, ["cat-file", "-e", `${baseCommit}^{commit}`], { cwd: submoduleRepoPath, stdio: "ignore" });
|
|
114662
115123
|
(0, import_node_child_process9.execFileSync)(GIT3, ["cat-file", "-e", `${branchCommit}^{commit}`], { cwd: submoduleRepoPath, stdio: "ignore" });
|
|
114663
115124
|
(0, import_node_child_process9.execFileSync)(GIT3, ["merge-base", "--is-ancestor", baseCommit, branchCommit], { cwd: submoduleRepoPath, stdio: "ignore" });
|
|
@@ -114679,12 +115140,12 @@ ${mergeTreeErr?.stderr || ""}`;
|
|
|
114679
115140
|
if (!line.trim()) continue;
|
|
114680
115141
|
const metaAndPath = line.split(" ");
|
|
114681
115142
|
const meta3 = metaAndPath[0] || "";
|
|
114682
|
-
const
|
|
114683
|
-
if (!
|
|
114684
|
-
seen.add(
|
|
115143
|
+
const path56 = metaAndPath[metaAndPath.length - 1]?.trim();
|
|
115144
|
+
if (!path56 || seen.has(path56)) continue;
|
|
115145
|
+
seen.add(path56);
|
|
114685
115146
|
const parts = meta3.split(/\s+/);
|
|
114686
115147
|
const isGitlink = !!(parts[0]?.includes("160000") || parts[1]?.includes("160000"));
|
|
114687
|
-
result.push({ path:
|
|
115148
|
+
result.push({ path: path56, isGitlink });
|
|
114688
115149
|
}
|
|
114689
115150
|
return result;
|
|
114690
115151
|
} catch {
|
|
@@ -114692,28 +115153,28 @@ ${mergeTreeErr?.stderr || ""}`;
|
|
|
114692
115153
|
}
|
|
114693
115154
|
}
|
|
114694
115155
|
function collectFastForwardGitlinkPaths(repoRoot, baseHead, branchHead) {
|
|
114695
|
-
return readChangedGitlinkPaths(repoRoot, baseHead, branchHead).filter((
|
|
114696
|
-
const baseCommit = readTreeObject(repoRoot, baseHead,
|
|
114697
|
-
const branchCommit = readTreeObject(repoRoot, branchHead,
|
|
115156
|
+
return readChangedGitlinkPaths(repoRoot, baseHead, branchHead).filter((path56) => {
|
|
115157
|
+
const baseCommit = readTreeObject(repoRoot, baseHead, path56);
|
|
115158
|
+
const branchCommit = readTreeObject(repoRoot, branchHead, path56);
|
|
114698
115159
|
if (!baseCommit || !branchCommit) return false;
|
|
114699
|
-
return isSubmoduleFastForward((0, import_path17.resolve)(repoRoot,
|
|
115160
|
+
return isSubmoduleFastForward((0, import_path17.resolve)(repoRoot, path56), baseCommit, branchCommit);
|
|
114700
115161
|
});
|
|
114701
115162
|
}
|
|
114702
115163
|
function collectTrivialFastForwardGitlinkResolutions(worktreeRoot, baseRepoRoot, baseHead, branchHead) {
|
|
114703
115164
|
const resolutions = [];
|
|
114704
|
-
for (const
|
|
114705
|
-
const baseCommit = readTreeObject(baseRepoRoot, baseHead,
|
|
114706
|
-
const branchCommit = readTreeObject(worktreeRoot, branchHead,
|
|
115165
|
+
for (const path56 of readChangedGitlinkPaths(worktreeRoot, baseHead, branchHead)) {
|
|
115166
|
+
const baseCommit = readTreeObject(baseRepoRoot, baseHead, path56);
|
|
115167
|
+
const branchCommit = readTreeObject(worktreeRoot, branchHead, path56);
|
|
114707
115168
|
if (!baseCommit || !branchCommit) continue;
|
|
114708
|
-
const submoduleRepoPath = (0, import_path17.resolve)(worktreeRoot,
|
|
114709
|
-
ensureSubmoduleCommitLocal(submoduleRepoPath, (0, import_path17.resolve)(baseRepoRoot,
|
|
115169
|
+
const submoduleRepoPath = (0, import_path17.resolve)(worktreeRoot, path56);
|
|
115170
|
+
ensureSubmoduleCommitLocal(submoduleRepoPath, (0, import_path17.resolve)(baseRepoRoot, path56), baseCommit);
|
|
114710
115171
|
if (baseCommit === branchCommit) {
|
|
114711
115172
|
continue;
|
|
114712
115173
|
}
|
|
114713
115174
|
if (isSubmoduleFastForward(submoduleRepoPath, baseCommit, branchCommit)) {
|
|
114714
|
-
resolutions.push({ path:
|
|
115175
|
+
resolutions.push({ path: path56, rebasedCommit: branchCommit });
|
|
114715
115176
|
} else if (isSubmoduleFastForward(submoduleRepoPath, branchCommit, baseCommit)) {
|
|
114716
|
-
resolutions.push({ path:
|
|
115177
|
+
resolutions.push({ path: path56, rebasedCommit: baseCommit });
|
|
114717
115178
|
}
|
|
114718
115179
|
}
|
|
114719
115180
|
return resolutions;
|
|
@@ -114721,7 +115182,7 @@ ${mergeTreeErr?.stderr || ""}`;
|
|
|
114721
115182
|
function isSubmoduleDivergedSibling(submoduleRepoPath, baseCommit, branchCommit) {
|
|
114722
115183
|
if (!baseCommit || !branchCommit || baseCommit === branchCommit) return false;
|
|
114723
115184
|
try {
|
|
114724
|
-
if (!
|
|
115185
|
+
if (!fs47.existsSync(submoduleRepoPath)) return false;
|
|
114725
115186
|
(0, import_node_child_process9.execFileSync)(GIT3, ["cat-file", "-e", `${baseCommit}^{commit}`], { cwd: submoduleRepoPath, stdio: "ignore" });
|
|
114726
115187
|
(0, import_node_child_process9.execFileSync)(GIT3, ["cat-file", "-e", `${branchCommit}^{commit}`], { cwd: submoduleRepoPath, stdio: "ignore" });
|
|
114727
115188
|
} catch {
|
|
@@ -114793,7 +115254,7 @@ ${mergeTreeErr?.stderr || ""}`;
|
|
|
114793
115254
|
} catch {
|
|
114794
115255
|
}
|
|
114795
115256
|
try {
|
|
114796
|
-
if (!
|
|
115257
|
+
if (!fs47.existsSync(submoduleRepoPath) || !fs47.existsSync(baseSubmoduleRepoPath)) return;
|
|
114797
115258
|
(0, import_node_child_process9.execFileSync)(GIT3, ["-c", "protocol.file.allow=always", "fetch", "-q", baseSubmoduleRepoPath, "+refs/heads/*:refs/adhdev-refine-base/*"], {
|
|
114798
115259
|
cwd: submoduleRepoPath,
|
|
114799
115260
|
stdio: ["ignore", "ignore", "pipe"]
|
|
@@ -114809,15 +115270,15 @@ ${mergeTreeErr?.stderr || ""}`;
|
|
|
114809
115270
|
const gitlinks = [];
|
|
114810
115271
|
const resolutions = [];
|
|
114811
115272
|
let sawDiverged = false;
|
|
114812
|
-
for (const
|
|
114813
|
-
const baseCommit = readTreeObject(baseRepoRoot, baseHead,
|
|
114814
|
-
const branchCommit = readTreeObject(worktreeRoot, branchHead,
|
|
114815
|
-
const submoduleRepoPath = (0, import_path17.resolve)(worktreeRoot,
|
|
115273
|
+
for (const path56 of changed) {
|
|
115274
|
+
const baseCommit = readTreeObject(baseRepoRoot, baseHead, path56);
|
|
115275
|
+
const branchCommit = readTreeObject(worktreeRoot, branchHead, path56);
|
|
115276
|
+
const submoduleRepoPath = (0, import_path17.resolve)(worktreeRoot, path56);
|
|
114816
115277
|
if (baseCommit) {
|
|
114817
|
-
ensureSubmoduleCommitLocal(submoduleRepoPath, (0, import_path17.resolve)(baseRepoRoot,
|
|
115278
|
+
ensureSubmoduleCommitLocal(submoduleRepoPath, (0, import_path17.resolve)(baseRepoRoot, path56), baseCommit);
|
|
114818
115279
|
}
|
|
114819
115280
|
if (!baseCommit || !branchCommit || !isSubmoduleDivergedSibling(submoduleRepoPath, baseCommit, branchCommit)) {
|
|
114820
|
-
gitlinks.push({ path:
|
|
115281
|
+
gitlinks.push({ path: path56, baseCommit, branchCommit, action: "skipped_not_diverged" });
|
|
114821
115282
|
continue;
|
|
114822
115283
|
}
|
|
114823
115284
|
sawDiverged = true;
|
|
@@ -114832,8 +115293,8 @@ ${mergeTreeErr?.stderr || ""}`;
|
|
|
114832
115293
|
(0, import_node_child_process9.execFileSync)(GIT3, ["checkout", "-q", "--detach", publishedEquivalent], { cwd: submoduleRepoPath, stdio: ["ignore", "ignore", "pipe"] });
|
|
114833
115294
|
} catch {
|
|
114834
115295
|
}
|
|
114835
|
-
gitlinks.push({ path:
|
|
114836
|
-
resolutions.push({ path:
|
|
115296
|
+
gitlinks.push({ path: path56, baseCommit, branchCommit, rebasedCommit: publishedEquivalent, action: "converged_to_published" });
|
|
115297
|
+
resolutions.push({ path: path56, baseCommit, branchCommit, rebasedCommit: publishedEquivalent });
|
|
114837
115298
|
continue;
|
|
114838
115299
|
}
|
|
114839
115300
|
let rebasedCommit;
|
|
@@ -114850,7 +115311,7 @@ ${mergeTreeErr?.stderr || ""}`;
|
|
|
114850
115311
|
(0, import_node_child_process9.execFileSync)(GIT3, ["checkout", "-q", "--detach", branchCommit], { cwd: submoduleRepoPath, stdio: "ignore" });
|
|
114851
115312
|
} catch {
|
|
114852
115313
|
}
|
|
114853
|
-
gitlinks.push({ path:
|
|
115314
|
+
gitlinks.push({ path: path56, baseCommit, branchCommit, action: "rebase_conflict" });
|
|
114854
115315
|
return { converged: false, reason: "rebase_conflict", resolutions: [], gitlinks };
|
|
114855
115316
|
}
|
|
114856
115317
|
const branchWorkSurvived = (() => {
|
|
@@ -114872,11 +115333,11 @@ ${mergeTreeErr?.stderr || ""}`;
|
|
|
114872
115333
|
(0, import_node_child_process9.execFileSync)(GIT3, ["checkout", "-q", "--detach", branchCommit], { cwd: submoduleRepoPath, stdio: "ignore" });
|
|
114873
115334
|
} catch {
|
|
114874
115335
|
}
|
|
114875
|
-
gitlinks.push({ path:
|
|
115336
|
+
gitlinks.push({ path: path56, baseCommit, branchCommit, rebasedCommit, action: "rebase_dropped_branch_commits" });
|
|
114876
115337
|
return { converged: false, reason: "rebase_dropped_branch_commits", resolutions: [], gitlinks };
|
|
114877
115338
|
}
|
|
114878
|
-
gitlinks.push({ path:
|
|
114879
|
-
resolutions.push({ path:
|
|
115339
|
+
gitlinks.push({ path: path56, baseCommit, branchCommit, rebasedCommit, action: "rebased" });
|
|
115340
|
+
resolutions.push({ path: path56, baseCommit, branchCommit, rebasedCommit });
|
|
114880
115341
|
}
|
|
114881
115342
|
if (!sawDiverged) {
|
|
114882
115343
|
return { converged: false, reason: "not_diverged", resolutions: [], gitlinks };
|
|
@@ -114962,12 +115423,12 @@ ${mergeTreeErr?.stderr || ""}`;
|
|
|
114962
115423
|
return { ok: true, branchHead };
|
|
114963
115424
|
}
|
|
114964
115425
|
function evaluateGitlinkTrivialFastForward(repoRoot, baseHead, branchHead) {
|
|
114965
|
-
const changedGitlinks = readChangedGitlinkPaths(repoRoot, baseHead, branchHead).map((
|
|
114966
|
-
const baseCommit = readTreeObject(repoRoot, baseHead,
|
|
114967
|
-
const branchCommit = readTreeObject(repoRoot, branchHead,
|
|
114968
|
-
const submoduleRepoPath = (0, import_path17.resolve)(repoRoot,
|
|
115426
|
+
const changedGitlinks = readChangedGitlinkPaths(repoRoot, baseHead, branchHead).map((path56) => {
|
|
115427
|
+
const baseCommit = readTreeObject(repoRoot, baseHead, path56);
|
|
115428
|
+
const branchCommit = readTreeObject(repoRoot, branchHead, path56);
|
|
115429
|
+
const submoduleRepoPath = (0, import_path17.resolve)(repoRoot, path56);
|
|
114969
115430
|
const fastForward = !!baseCommit && !!branchCommit && isSubmoduleFastForward(submoduleRepoPath, baseCommit, branchCommit);
|
|
114970
|
-
return { path:
|
|
115431
|
+
return { path: path56, baseCommit, branchCommit, fastForward };
|
|
114971
115432
|
});
|
|
114972
115433
|
if (changedGitlinks.length === 0) {
|
|
114973
115434
|
return { trivial: false, reason: "no_changed_gitlinks", gitlinks: changedGitlinks };
|
|
@@ -115018,7 +115479,7 @@ ${mergeTreeErr?.stderr || ""}`;
|
|
|
115018
115479
|
maxBuffer: 1024 * 1024
|
|
115019
115480
|
}).trim();
|
|
115020
115481
|
if (!tree) return void 0;
|
|
115021
|
-
const updates = paths.map((
|
|
115482
|
+
const updates = paths.map((path56) => `160000 commit ${placeholderCommit} ${path56}`).join("\n");
|
|
115022
115483
|
if (!updates) return tree;
|
|
115023
115484
|
const tmpIndex = (0, import_path17.join)(resolveGitDir(repoRoot), `adhdev-refine-eq-${commitish.slice(0, 12)}.index`);
|
|
115024
115485
|
const env2 = { ...process.env, GIT_INDEX_FILE: tmpIndex };
|
|
@@ -115036,7 +115497,7 @@ ${mergeTreeErr?.stderr || ""}`;
|
|
|
115036
115497
|
return newTree || void 0;
|
|
115037
115498
|
} finally {
|
|
115038
115499
|
try {
|
|
115039
|
-
|
|
115500
|
+
fs47.rmSync(tmpIndex, { force: true });
|
|
115040
115501
|
} catch {
|
|
115041
115502
|
}
|
|
115042
115503
|
}
|
|
@@ -115111,7 +115572,7 @@ ${mergeTreeErr?.stderr || ""}`;
|
|
|
115111
115572
|
return newTree || void 0;
|
|
115112
115573
|
} finally {
|
|
115113
115574
|
try {
|
|
115114
|
-
|
|
115575
|
+
fs47.rmSync(tmpIndex, { force: true });
|
|
115115
115576
|
} catch {
|
|
115116
115577
|
}
|
|
115117
115578
|
}
|
|
@@ -115121,7 +115582,7 @@ ${mergeTreeErr?.stderr || ""}`;
|
|
|
115121
115582
|
}
|
|
115122
115583
|
async function alignRefinerySubmodulesAfterMerge(repoRoot, previousBaseHead, currentHead, options = {}) {
|
|
115123
115584
|
const startedAt = Date.now();
|
|
115124
|
-
const changedGitlinkPaths = readChangedGitlinkPaths(repoRoot, previousBaseHead, currentHead).filter((
|
|
115585
|
+
const changedGitlinkPaths = readChangedGitlinkPaths(repoRoot, previousBaseHead, currentHead).filter((path56) => !(options.submoduleIgnorePaths || []).includes(path56));
|
|
115125
115586
|
const preStatus = await getGitRepoStatus(repoRoot, {
|
|
115126
115587
|
includeSubmodules: true,
|
|
115127
115588
|
submoduleIgnorePaths: options.submoduleIgnorePaths,
|
|
@@ -115168,7 +115629,7 @@ ${mergeTreeErr?.stderr || ""}`;
|
|
|
115168
115629
|
changedGitlinkPaths,
|
|
115169
115630
|
outOfSyncPaths,
|
|
115170
115631
|
updatedPaths: updatePaths,
|
|
115171
|
-
verifiedPaths: updatePaths.filter((
|
|
115632
|
+
verifiedPaths: updatePaths.filter((path56) => !remaining.some((submodule) => submodule.path === path56)),
|
|
115172
115633
|
durationMs: Date.now() - startedAt,
|
|
115173
115634
|
command: `git ${commandArgs.join(" ")}`,
|
|
115174
115635
|
stdout: truncateValidationOutput(result.stdout),
|
|
@@ -115223,7 +115684,7 @@ ${mergeTreeErr?.stderr || ""}`;
|
|
|
115223
115684
|
return { stdout: String(stdout || ""), stderr: String(stderr || ""), refspec };
|
|
115224
115685
|
};
|
|
115225
115686
|
const importCommitFromWorktreeSubmodule = async (submodulePath, worktreeSubmodulePath, commit) => {
|
|
115226
|
-
if (!
|
|
115687
|
+
if (!fs47.existsSync(worktreeSubmodulePath)) return false;
|
|
115227
115688
|
try {
|
|
115228
115689
|
await runGit3(worktreeSubmodulePath, ["cat-file", "-e", `${commit}^{commit}`]);
|
|
115229
115690
|
} catch {
|
|
@@ -115260,7 +115721,7 @@ ${mergeTreeErr?.stderr || ""}`;
|
|
|
115260
115721
|
};
|
|
115261
115722
|
let submoduleDefaultBranch = "main";
|
|
115262
115723
|
try {
|
|
115263
|
-
if (!
|
|
115724
|
+
if (!fs47.existsSync(submodulePath)) {
|
|
115264
115725
|
entry.error = `Submodule checkout missing at ${gitlink.path}`;
|
|
115265
115726
|
entry.publishRequired = true;
|
|
115266
115727
|
if (options.allowAutoPublishSubmoduleMainCommits === true) {
|
|
@@ -115513,9 +115974,9 @@ ${mergeTreeErr?.stderr || ""}`;
|
|
|
115513
115974
|
return ["npm", "pnpm", "yarn", "bun"].includes(command) && candidate.args.some((arg) => arg === "run" || arg === "test" || arg === "exec");
|
|
115514
115975
|
};
|
|
115515
115976
|
const dependenciesLikelyMissing = (cwd) => {
|
|
115516
|
-
if (!
|
|
115517
|
-
if (
|
|
115518
|
-
return ["package-lock.json", "npm-shrinkwrap.json", "pnpm-lock.yaml", "yarn.lock", "bun.lockb", "bun.lock"].some((lock) =>
|
|
115977
|
+
if (!fs47.existsSync((0, import_path17.join)(cwd, "package.json"))) return false;
|
|
115978
|
+
if (fs47.existsSync((0, import_path17.join)(cwd, "node_modules"))) return false;
|
|
115979
|
+
return ["package-lock.json", "npm-shrinkwrap.json", "pnpm-lock.yaml", "yarn.lock", "bun.lockb", "bun.lock"].some((lock) => fs47.existsSync((0, import_path17.join)(cwd, lock)));
|
|
115519
115980
|
};
|
|
115520
115981
|
const needsNodeModules = (candidate, cwd) => isPackageManagerValidation(candidate) && dependenciesLikelyMissing(cwd);
|
|
115521
115982
|
const isDaemonScopedCommand = (candidate) => {
|
|
@@ -115745,7 +116206,16 @@ ${mergeTreeErr?.stderr || ""}`;
|
|
|
115745
116206
|
"conflictPaths",
|
|
115746
116207
|
"branchRefWarning",
|
|
115747
116208
|
"residueWarning",
|
|
115748
|
-
"branchRefDeleted"
|
|
116209
|
+
"branchRefDeleted",
|
|
116210
|
+
// GHOST-FAILURE: merge-landing facts. The coordinator sees ONLY this slim
|
|
116211
|
+
// result; without these it cannot tell a pre-merge failure (nothing landed)
|
|
116212
|
+
// from a post-merge one (the change IS on origin) without a manual git check.
|
|
116213
|
+
"merged",
|
|
116214
|
+
"mergedLocal",
|
|
116215
|
+
"pushed",
|
|
116216
|
+
"mergedSha",
|
|
116217
|
+
"postMergeWarning",
|
|
116218
|
+
"refineLanding"
|
|
115749
116219
|
]) {
|
|
115750
116220
|
if (result[key2] !== void 0) slim[key2] = result[key2];
|
|
115751
116221
|
}
|
|
@@ -116030,6 +116500,13 @@ ${mergeTreeErr?.stderr || ""}`;
|
|
|
116030
116500
|
if (!node.isLocalWorktree || !node.workspace) {
|
|
116031
116501
|
return { kind: "terminal", result: { success: false, error: `Refinery requires a local worktree node`, refineStages } };
|
|
116032
116502
|
}
|
|
116503
|
+
if (!(0, import_node_fs6.existsSync)(node.workspace)) {
|
|
116504
|
+
recordMeshRefineStage(refineStages, "resolve_refs", "failed", Date.now(), {
|
|
116505
|
+
workspace: node.workspace,
|
|
116506
|
+
workspaceMissing: true
|
|
116507
|
+
});
|
|
116508
|
+
return { kind: "terminal", result: buildRefineWorktreeMissingResult(nodeId, node.workspace, refineStages) };
|
|
116509
|
+
}
|
|
116033
116510
|
const sourceNode = node.clonedFromNodeId ? mesh?.nodes.find((n) => meshNodeIdMatches(n, node.clonedFromNodeId)) : mesh?.nodes.find((n) => !n.isLocalWorktree);
|
|
116034
116511
|
const repoRoot = sourceNode?.repoRoot || sourceNode?.workspace;
|
|
116035
116512
|
if (!repoRoot) return { kind: "terminal", result: { success: false, error: "Source node repoRoot not found", refineStages } };
|
|
@@ -117567,11 +118044,10 @@ ${e?.stderr || ""}`;
|
|
|
117567
118044
|
}
|
|
117568
118045
|
const completedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
117569
118046
|
const refineCode = typeof result.code === "string" ? result.code : "";
|
|
117570
|
-
const
|
|
117571
|
-
const
|
|
117572
|
-
const blockerContext = isTerminalSuccess ? void 0 : (() => {
|
|
118047
|
+
const { kind: refineTerminalKind, landing, isPostMergeWarning, converged: isTerminalConverged, clean: isTerminalClean } = classifyRefineTerminal(result);
|
|
118048
|
+
const blockerContext = isTerminalClean ? void 0 : (() => {
|
|
117573
118049
|
const code = typeof result.code === "string" ? result.code : refineTerminalKind;
|
|
117574
|
-
const stage = refineTerminalKind === "validation_failed" ? "validation" : refineTerminalKind === "submodule_reachability_failed" ? "submodule_reachability" : refineCode === "patch_equivalence_failed" ? "patch_equivalence" : refineCode === "needs_rebase" || refineCode === "needs_rebase_with_conflicts" ? "patch_equivalence" : refineTerminalKind === "merge_failed" ? "merge" : refineTerminalKind === "cleanup_failed" ? "cleanup" : "unknown";
|
|
118050
|
+
const stage = refineTerminalKind === "validation_failed" ? "validation" : refineTerminalKind === "submodule_reachability_failed" ? "submodule_reachability" : refineCode === "patch_equivalence_failed" ? "patch_equivalence" : refineCode === "needs_rebase" || refineCode === "needs_rebase_with_conflicts" ? "patch_equivalence" : refineTerminalKind === "merge_failed" ? "merge" : refineTerminalKind === "cleanup_failed" ? "cleanup" : refineTerminalKind === "completed_with_warnings" ? refineCode === "post_merge_submodule_alignment_failed" ? "submodule_alignment" : "cleanup" : "unknown";
|
|
117575
118051
|
const ctx = {
|
|
117576
118052
|
stage,
|
|
117577
118053
|
reason: code,
|
|
@@ -117619,14 +118095,23 @@ ${e?.stderr || ""}`;
|
|
|
117619
118095
|
...result,
|
|
117620
118096
|
terminalKind: refineTerminalKind,
|
|
117621
118097
|
...blockerContext ? { blockerContext } : {},
|
|
117622
|
-
...result.nextStep === void 0 && !
|
|
117623
|
-
|
|
118098
|
+
...result.nextStep === void 0 && !isTerminalClean ? { nextStep: refineTerminalNextStep(refineTerminalKind) } : {},
|
|
118099
|
+
// GHOST-FAILURE: explicit machine-readable landing verdict, present on EVERY
|
|
118100
|
+
// terminal result (plain failures read merged:false) so a coordinator never
|
|
118101
|
+
// has to run `git log` to tell whether the work landed.
|
|
118102
|
+
refineLanding: {
|
|
118103
|
+
merged: landing.merged,
|
|
118104
|
+
pushed: landing.pushed,
|
|
118105
|
+
converged: isTerminalConverged
|
|
118106
|
+
},
|
|
118107
|
+
...isPostMergeWarning ? {
|
|
118108
|
+
postMergeWarning: `Merge landed and was pushed to origin/${typeof result.into === "string" ? result.into : "base"}, but a post-merge step failed (${refineCode || "unknown"}). This node is CONVERGED \u2014 do not re-refine it.`
|
|
117624
118109
|
} : {}
|
|
117625
118110
|
};
|
|
117626
118111
|
const terminalHandle = buildRefineJobHandle(self, {
|
|
117627
118112
|
meshId: handle.meshId,
|
|
117628
118113
|
nodeId: handle.targetNodeId,
|
|
117629
|
-
status:
|
|
118114
|
+
status: isTerminalConverged ? "completed" : "failed",
|
|
117630
118115
|
startedAt: handle.startedAt,
|
|
117631
118116
|
completedAt,
|
|
117632
118117
|
jobId: handle.jobId,
|
|
@@ -117644,8 +118129,8 @@ ${e?.stderr || ""}`;
|
|
|
117644
118129
|
self.terminalRefineJobs.set(key2, terminal);
|
|
117645
118130
|
self.runningRefineJobs.delete(key2);
|
|
117646
118131
|
self.invalidateAggregateMeshStatus(handle.meshId);
|
|
117647
|
-
await appendRefineJobLedger(self,
|
|
117648
|
-
queueRefineJobEvent(self,
|
|
118132
|
+
await appendRefineJobLedger(self, isTerminalConverged ? "task_completed" : "task_failed", terminalHandle, normalizedResult);
|
|
118133
|
+
queueRefineJobEvent(self, isTerminalConverged ? "refine:completed" : "refine:failed", terminalHandle, normalizedResult);
|
|
117649
118134
|
}
|
|
117650
118135
|
async function recordRefineAcceptBaseDivergence(self, handle, node) {
|
|
117651
118136
|
try {
|
|
@@ -117712,7 +118197,7 @@ ${e?.stderr || ""}`;
|
|
|
117712
118197
|
});
|
|
117713
118198
|
return handle;
|
|
117714
118199
|
}
|
|
117715
|
-
var
|
|
118200
|
+
var fs48 = __toESM2(require("fs"));
|
|
117716
118201
|
var import_node_os2 = require("os");
|
|
117717
118202
|
var import_path18 = require("path");
|
|
117718
118203
|
init_logger();
|
|
@@ -117768,14 +118253,14 @@ ${e?.stderr || ""}`;
|
|
|
117768
118253
|
return false;
|
|
117769
118254
|
}
|
|
117770
118255
|
async function bestEffortRemoveWorktreeDir(self, dir) {
|
|
117771
|
-
if (!dir || !
|
|
118256
|
+
if (!dir || !fs48.existsSync(dir)) return { removed: true, residue: false };
|
|
117772
118257
|
const sleep3 = (ms) => new Promise((resolve30) => setTimeout(resolve30, ms));
|
|
117773
118258
|
const ABSORB = /* @__PURE__ */ new Set(["EINVAL", "EPERM", "EBUSY", "ENOTEMPTY", "EACCES", "EMFILE", "ENFILE"]);
|
|
117774
118259
|
let lastErr;
|
|
117775
118260
|
for (let attempt = 0; attempt < 4; attempt++) {
|
|
117776
118261
|
try {
|
|
117777
|
-
|
|
117778
|
-
if (!
|
|
118262
|
+
fs48.rmSync(dir, { recursive: true, force: true, maxRetries: 3, retryDelay: 100 });
|
|
118263
|
+
if (!fs48.existsSync(dir)) return { removed: true, residue: false };
|
|
117779
118264
|
lastErr = new Error("directory still present after rmSync");
|
|
117780
118265
|
} catch (e) {
|
|
117781
118266
|
lastErr = e;
|
|
@@ -117786,7 +118271,7 @@ ${e?.stderr || ""}`;
|
|
|
117786
118271
|
}
|
|
117787
118272
|
await sleep3(150 * (attempt + 1));
|
|
117788
118273
|
}
|
|
117789
|
-
return
|
|
118274
|
+
return fs48.existsSync(dir) ? { removed: false, residue: true, error: String(lastErr?.message || lastErr || "unknown rm error") } : { removed: true, residue: false };
|
|
117790
118275
|
}
|
|
117791
118276
|
async function precheckLocalWorktreeRemovable(self, args) {
|
|
117792
118277
|
const sessionPreservedNote = " The delegated session was left running (not stopped) \u2014 resolve the issue and retry mesh_remove_node.";
|
|
@@ -117799,10 +118284,10 @@ ${e?.stderr || ""}`;
|
|
|
117799
118284
|
recoveryHint: "Inspect the mesh node record before removing it, or remove stale metadata manually only after confirming no managed worktree remains." + sessionPreservedNote
|
|
117800
118285
|
};
|
|
117801
118286
|
}
|
|
117802
|
-
if (!
|
|
118287
|
+
if (!fs48.existsSync(workspace)) return { ok: true };
|
|
117803
118288
|
const sourceNode = args.node?.clonedFromNodeId ? args.mesh?.nodes?.find((n) => meshNodeIdMatches(n, args.node.clonedFromNodeId)) : args.mesh?.nodes?.find((n) => !n.isLocalWorktree);
|
|
117804
118289
|
const repoRoot = typeof sourceNode?.repoRoot === "string" && sourceNode.repoRoot.trim() ? sourceNode.repoRoot.trim() : typeof sourceNode?.workspace === "string" && sourceNode.workspace.trim() ? sourceNode.workspace.trim() : "";
|
|
117805
|
-
if (!repoRoot || !
|
|
118290
|
+
if (!repoRoot || !fs48.existsSync(repoRoot)) {
|
|
117806
118291
|
return {
|
|
117807
118292
|
ok: false,
|
|
117808
118293
|
code: "mesh_worktree_cleanup_missing_source_repo",
|
|
@@ -117822,7 +118307,7 @@ ${e?.stderr || ""}`;
|
|
|
117822
118307
|
const normalizePath2 = (value) => {
|
|
117823
118308
|
const resolved = (0, import_path18.resolve)(value);
|
|
117824
118309
|
try {
|
|
117825
|
-
return
|
|
118310
|
+
return fs48.realpathSync(resolved);
|
|
117826
118311
|
} catch {
|
|
117827
118312
|
return resolved;
|
|
117828
118313
|
}
|
|
@@ -117893,13 +118378,13 @@ ${e?.stderr || ""}`;
|
|
|
117893
118378
|
recoveryHint: "Inspect the mesh node record before removing it, or remove stale metadata manually only after confirming no managed worktree remains."
|
|
117894
118379
|
};
|
|
117895
118380
|
}
|
|
117896
|
-
const worktreeExists =
|
|
118381
|
+
const worktreeExists = fs48.existsSync(workspace);
|
|
117897
118382
|
const sourceNode = args.node?.clonedFromNodeId ? args.mesh?.nodes?.find((n) => meshNodeIdMatches(n, args.node.clonedFromNodeId)) : args.mesh?.nodes?.find((n) => !n.isLocalWorktree);
|
|
117898
118383
|
const repoRoot = typeof sourceNode?.repoRoot === "string" && sourceNode.repoRoot.trim() ? sourceNode.repoRoot.trim() : typeof sourceNode?.workspace === "string" && sourceNode.workspace.trim() ? sourceNode.workspace.trim() : "";
|
|
117899
118384
|
if (!worktreeExists) {
|
|
117900
118385
|
return { success: true, skipped: true, removedPath: workspace, repoRoot: repoRoot || void 0, reason: "worktree_path_missing" };
|
|
117901
118386
|
}
|
|
117902
|
-
if (!repoRoot || !
|
|
118387
|
+
if (!repoRoot || !fs48.existsSync(repoRoot)) {
|
|
117903
118388
|
return {
|
|
117904
118389
|
success: false,
|
|
117905
118390
|
code: "mesh_worktree_cleanup_missing_source_repo",
|
|
@@ -117919,7 +118404,7 @@ ${e?.stderr || ""}`;
|
|
|
117919
118404
|
const normalizePath2 = (value) => {
|
|
117920
118405
|
const resolved = (0, import_path18.resolve)(value);
|
|
117921
118406
|
try {
|
|
117922
|
-
return
|
|
118407
|
+
return fs48.realpathSync(resolved);
|
|
117923
118408
|
} catch {
|
|
117924
118409
|
return resolved;
|
|
117925
118410
|
}
|
|
@@ -118566,7 +119051,7 @@ ${e?.stderr || ""}`;
|
|
|
118566
119051
|
var yaml5 = __toESM2(require_js_yaml());
|
|
118567
119052
|
var import_os5 = require("os");
|
|
118568
119053
|
var import_path19 = require("path");
|
|
118569
|
-
var
|
|
119054
|
+
var fs49 = __toESM2(require("fs"));
|
|
118570
119055
|
var MESH_COORDINATOR_AUTO_IMPORT_FORMATS = ["claude_mcp_json", "hermes_config_yaml", "opencode_json"];
|
|
118571
119056
|
function isSupportedMeshCoordinatorConfigFormat(format) {
|
|
118572
119057
|
return MESH_COORDINATOR_AUTO_IMPORT_FORMATS.includes(format);
|
|
@@ -118611,9 +119096,9 @@ ${e?.stderr || ""}`;
|
|
|
118611
119096
|
function loadHermesCoordinatorBaseConfig(targetConfigPath) {
|
|
118612
119097
|
const sourceHome = resolveHermesUserHome();
|
|
118613
119098
|
const sourceConfigPath = (0, import_path19.join)(sourceHome, "config.yaml");
|
|
118614
|
-
if (!
|
|
119099
|
+
if (!fs49.existsSync(sourceConfigPath)) return { config: {}, sourceHome, sourceConfigPath };
|
|
118615
119100
|
if ((0, import_path19.resolve)(sourceConfigPath) === (0, import_path19.resolve)(targetConfigPath)) return { config: {}, sourceHome, sourceConfigPath };
|
|
118616
|
-
const parsed = parseMeshCoordinatorMcpConfig(
|
|
119101
|
+
const parsed = parseMeshCoordinatorMcpConfig(fs49.readFileSync(sourceConfigPath, "utf-8"), "hermes_config_yaml");
|
|
118617
119102
|
const { mcp_servers: _mcpServers, ...baseConfig } = parsed;
|
|
118618
119103
|
return { config: baseConfig, sourceHome, sourceConfigPath };
|
|
118619
119104
|
}
|
|
@@ -118650,9 +119135,9 @@ ${e?.stderr || ""}`;
|
|
|
118650
119135
|
for (const fileName of [".env", "auth.json"]) {
|
|
118651
119136
|
const sourcePath = (0, import_path19.join)(sourceHome, fileName);
|
|
118652
119137
|
const targetPath = (0, import_path19.join)(targetHome, fileName);
|
|
118653
|
-
if (!
|
|
119138
|
+
if (!fs49.existsSync(sourcePath)) continue;
|
|
118654
119139
|
try {
|
|
118655
|
-
|
|
119140
|
+
fs49.copyFileSync(sourcePath, targetPath);
|
|
118656
119141
|
} catch (error48) {
|
|
118657
119142
|
LOG2.warn("MeshCoordinator", `Could not copy Hermes ${fileName} into isolated coordinator home: ${error48?.message || error48}`);
|
|
118658
119143
|
}
|
|
@@ -119167,7 +119652,7 @@ ${e?.stderr || ""}`;
|
|
|
119167
119652
|
const nodeId = readInlineMeshNodeId(node);
|
|
119168
119653
|
if (!nodeId || !tombstones.has(nodeId)) return true;
|
|
119169
119654
|
const workspace = readStringValue(node?.workspace);
|
|
119170
|
-
if (workspace &&
|
|
119655
|
+
if (workspace && fs50.existsSync(workspace)) {
|
|
119171
119656
|
tombstones.delete(nodeId);
|
|
119172
119657
|
return true;
|
|
119173
119658
|
}
|
|
@@ -121187,14 +121672,14 @@ ${e?.stderr || ""}`;
|
|
|
121187
121672
|
};
|
|
121188
121673
|
init_io_contracts();
|
|
121189
121674
|
init_chat_message_normalization();
|
|
121190
|
-
var
|
|
121191
|
-
var
|
|
121192
|
-
var
|
|
121675
|
+
var fs51 = __toESM2(require("fs"));
|
|
121676
|
+
var path50 = __toESM2(require("path"));
|
|
121677
|
+
var os28 = __toESM2(require("os"));
|
|
121193
121678
|
var import_os6 = require("os");
|
|
121194
121679
|
init_config();
|
|
121195
121680
|
var import_child_process13 = require("child_process");
|
|
121196
121681
|
function getArchivePath2() {
|
|
121197
|
-
return
|
|
121682
|
+
return path50.join(getConfigDir2(), "version-history.json");
|
|
121198
121683
|
}
|
|
121199
121684
|
var MAX_ENTRIES_PER_PROVIDER = 20;
|
|
121200
121685
|
var VersionArchive = class {
|
|
@@ -121204,8 +121689,8 @@ ${e?.stderr || ""}`;
|
|
|
121204
121689
|
}
|
|
121205
121690
|
load() {
|
|
121206
121691
|
try {
|
|
121207
|
-
if (
|
|
121208
|
-
this.history = JSON.parse(
|
|
121692
|
+
if (fs51.existsSync(getArchivePath2())) {
|
|
121693
|
+
this.history = JSON.parse(fs51.readFileSync(getArchivePath2(), "utf-8"));
|
|
121209
121694
|
}
|
|
121210
121695
|
} catch {
|
|
121211
121696
|
this.history = {};
|
|
@@ -121242,8 +121727,8 @@ ${e?.stderr || ""}`;
|
|
|
121242
121727
|
}
|
|
121243
121728
|
save() {
|
|
121244
121729
|
try {
|
|
121245
|
-
|
|
121246
|
-
|
|
121730
|
+
fs51.mkdirSync(path50.dirname(getArchivePath2()), { recursive: true });
|
|
121731
|
+
fs51.writeFileSync(getArchivePath2(), JSON.stringify(this.history, null, 2));
|
|
121247
121732
|
} catch {
|
|
121248
121733
|
}
|
|
121249
121734
|
}
|
|
@@ -121266,10 +121751,10 @@ ${e?.stderr || ""}`;
|
|
|
121266
121751
|
for (const p of paths) {
|
|
121267
121752
|
if (!p) continue;
|
|
121268
121753
|
for (const ext of exes) {
|
|
121269
|
-
const fullPath =
|
|
121754
|
+
const fullPath = path50.join(p, name + ext);
|
|
121270
121755
|
try {
|
|
121271
|
-
if (
|
|
121272
|
-
const stat2 =
|
|
121756
|
+
if (fs51.existsSync(fullPath)) {
|
|
121757
|
+
const stat2 = fs51.statSync(fullPath);
|
|
121273
121758
|
if (stat2.isFile() && (isWin || stat2.mode & 73)) {
|
|
121274
121759
|
return fullPath;
|
|
121275
121760
|
}
|
|
@@ -121314,19 +121799,19 @@ ${e?.stderr || ""}`;
|
|
|
121314
121799
|
function checkPathExists2(paths) {
|
|
121315
121800
|
for (const p of paths) {
|
|
121316
121801
|
if (p.includes("*")) {
|
|
121317
|
-
const home =
|
|
121318
|
-
const resolved = p.replace(/\*/g, home.split(
|
|
121319
|
-
if (
|
|
121802
|
+
const home = os28.homedir();
|
|
121803
|
+
const resolved = p.replace(/\*/g, home.split(path50.sep).pop() || "");
|
|
121804
|
+
if (fs51.existsSync(resolved)) return resolved;
|
|
121320
121805
|
} else {
|
|
121321
|
-
if (
|
|
121806
|
+
if (fs51.existsSync(p)) return p;
|
|
121322
121807
|
}
|
|
121323
121808
|
}
|
|
121324
121809
|
return null;
|
|
121325
121810
|
}
|
|
121326
121811
|
async function getMacAppVersion(appPath) {
|
|
121327
121812
|
if ((0, import_os6.platform)() !== "darwin" || !appPath.endsWith(".app")) return null;
|
|
121328
|
-
const plistPath =
|
|
121329
|
-
if (!
|
|
121813
|
+
const plistPath = path50.join(appPath, "Contents", "Info.plist");
|
|
121814
|
+
if (!fs51.existsSync(plistPath)) return null;
|
|
121330
121815
|
const raw = await runCommand(`/usr/libexec/PlistBuddy -c "Print CFBundleShortVersionString" "${plistPath}"`);
|
|
121331
121816
|
return raw || null;
|
|
121332
121817
|
}
|
|
@@ -121352,8 +121837,8 @@ ${e?.stderr || ""}`;
|
|
|
121352
121837
|
const cliBin = provider.cli ? findBinary2(provider.cli) : null;
|
|
121353
121838
|
let resolvedBin = cliBin;
|
|
121354
121839
|
if (!resolvedBin && appPath && currentOs === "darwin") {
|
|
121355
|
-
const bundled =
|
|
121356
|
-
if (provider.cli &&
|
|
121840
|
+
const bundled = path50.join(appPath, "Contents", "Resources", "app", "bin", provider.cli || "");
|
|
121841
|
+
if (provider.cli && fs51.existsSync(bundled)) resolvedBin = bundled;
|
|
121357
121842
|
}
|
|
121358
121843
|
info.installed = !!(appPath || resolvedBin);
|
|
121359
121844
|
info.path = appPath || null;
|
|
@@ -121399,8 +121884,8 @@ ${e?.stderr || ""}`;
|
|
|
121399
121884
|
return results;
|
|
121400
121885
|
}
|
|
121401
121886
|
var http3 = __toESM2(require("http"));
|
|
121402
|
-
var
|
|
121403
|
-
var
|
|
121887
|
+
var fs55 = __toESM2(require("fs"));
|
|
121888
|
+
var path54 = __toESM2(require("path"));
|
|
121404
121889
|
init_config();
|
|
121405
121890
|
function generateFiles(type2, name, category, opts = {}) {
|
|
121406
121891
|
const { cdpPorts, cli, processName, installPath, binary: binary2, extensionId, version: version2 = "0.1" } = opts;
|
|
@@ -121745,8 +122230,8 @@ async (params) => {
|
|
|
121745
122230
|
}
|
|
121746
122231
|
init_logger();
|
|
121747
122232
|
init_builders();
|
|
121748
|
-
var
|
|
121749
|
-
var
|
|
122233
|
+
var fs52 = __toESM2(require("fs"));
|
|
122234
|
+
var path51 = __toESM2(require("path"));
|
|
121750
122235
|
init_logger();
|
|
121751
122236
|
async function handleCdpEvaluate(ctx, req, res) {
|
|
121752
122237
|
const body = await ctx.readBody(req);
|
|
@@ -121925,18 +122410,18 @@ async (params) => {
|
|
|
121925
122410
|
return;
|
|
121926
122411
|
}
|
|
121927
122412
|
let scriptsPath = "";
|
|
121928
|
-
const directScripts =
|
|
121929
|
-
if (
|
|
122413
|
+
const directScripts = path51.join(dir, "scripts.js");
|
|
122414
|
+
if (fs52.existsSync(directScripts)) {
|
|
121930
122415
|
scriptsPath = directScripts;
|
|
121931
122416
|
} else {
|
|
121932
|
-
const scriptsDir =
|
|
121933
|
-
if (
|
|
121934
|
-
const versions =
|
|
121935
|
-
return
|
|
122417
|
+
const scriptsDir = path51.join(dir, "scripts");
|
|
122418
|
+
if (fs52.existsSync(scriptsDir)) {
|
|
122419
|
+
const versions = fs52.readdirSync(scriptsDir).filter((d) => {
|
|
122420
|
+
return fs52.statSync(path51.join(scriptsDir, d)).isDirectory();
|
|
121936
122421
|
}).sort().reverse();
|
|
121937
122422
|
for (const ver of versions) {
|
|
121938
|
-
const p =
|
|
121939
|
-
if (
|
|
122423
|
+
const p = path51.join(scriptsDir, ver, "scripts.js");
|
|
122424
|
+
if (fs52.existsSync(p)) {
|
|
121940
122425
|
scriptsPath = p;
|
|
121941
122426
|
break;
|
|
121942
122427
|
}
|
|
@@ -121948,7 +122433,7 @@ async (params) => {
|
|
|
121948
122433
|
return;
|
|
121949
122434
|
}
|
|
121950
122435
|
try {
|
|
121951
|
-
const source =
|
|
122436
|
+
const source = fs52.readFileSync(scriptsPath, "utf-8");
|
|
121952
122437
|
const hints = {};
|
|
121953
122438
|
const funcRegex = /module\.exports\.(\w+)\s*=\s*function\s+\w+\s*\(params\)/g;
|
|
121954
122439
|
let match;
|
|
@@ -122761,8 +123246,8 @@ async (params) => {
|
|
|
122761
123246
|
ctx.json(res, 500, { error: `DOM context collection failed: ${e.message}` });
|
|
122762
123247
|
}
|
|
122763
123248
|
}
|
|
122764
|
-
var
|
|
122765
|
-
var
|
|
123249
|
+
var fs53 = __toESM2(require("fs"));
|
|
123250
|
+
var path522 = __toESM2(require("path"));
|
|
122766
123251
|
function slugifyFixtureName(value) {
|
|
122767
123252
|
const normalized = String(value || "").trim().toLowerCase().replace(/[^a-z0-9._-]+/g, "-").replace(/^-+|-+$/g, "");
|
|
122768
123253
|
return normalized || `fixture-${Date.now()}`;
|
|
@@ -122772,15 +123257,15 @@ async (params) => {
|
|
|
122772
123257
|
if (!providerDir) {
|
|
122773
123258
|
throw new Error(`Provider directory not found for '${type2}'`);
|
|
122774
123259
|
}
|
|
122775
|
-
return
|
|
123260
|
+
return path522.join(providerDir, "fixtures");
|
|
122776
123261
|
}
|
|
122777
123262
|
function readCliFixture(ctx, type2, name) {
|
|
122778
123263
|
const fixtureDir = getCliFixtureDir(ctx, type2);
|
|
122779
|
-
const filePath =
|
|
122780
|
-
if (!
|
|
123264
|
+
const filePath = path522.join(fixtureDir, `${name}.json`);
|
|
123265
|
+
if (!fs53.existsSync(filePath)) {
|
|
122781
123266
|
throw new Error(`Fixture not found: ${filePath}`);
|
|
122782
123267
|
}
|
|
122783
|
-
return JSON.parse(
|
|
123268
|
+
return JSON.parse(fs53.readFileSync(filePath, "utf-8"));
|
|
122784
123269
|
}
|
|
122785
123270
|
function getExerciseTranscriptText(result) {
|
|
122786
123271
|
const parts = [];
|
|
@@ -123525,7 +124010,7 @@ async (params) => {
|
|
|
123525
124010
|
return;
|
|
123526
124011
|
}
|
|
123527
124012
|
const fixtureDir = getCliFixtureDir(ctx, type2);
|
|
123528
|
-
|
|
124013
|
+
fs53.mkdirSync(fixtureDir, { recursive: true });
|
|
123529
124014
|
const name = slugifyFixtureName(String(body?.name || `${type2}-${Date.now()}`));
|
|
123530
124015
|
const result = await runCliExerciseInternal(ctx, { ...request, type: type2 });
|
|
123531
124016
|
const fixture = {
|
|
@@ -123552,8 +124037,8 @@ async (params) => {
|
|
|
123552
124037
|
},
|
|
123553
124038
|
notes: typeof body?.notes === "string" ? body.notes : void 0
|
|
123554
124039
|
};
|
|
123555
|
-
const filePath =
|
|
123556
|
-
|
|
124040
|
+
const filePath = path522.join(fixtureDir, `${name}.json`);
|
|
124041
|
+
fs53.writeFileSync(filePath, JSON.stringify(fixture, null, 2));
|
|
123557
124042
|
ctx.json(res, 200, {
|
|
123558
124043
|
saved: true,
|
|
123559
124044
|
name,
|
|
@@ -123571,14 +124056,14 @@ async (params) => {
|
|
|
123571
124056
|
async function handleCliFixtureList(ctx, type2, _req, res) {
|
|
123572
124057
|
try {
|
|
123573
124058
|
const fixtureDir = getCliFixtureDir(ctx, type2);
|
|
123574
|
-
if (!
|
|
124059
|
+
if (!fs53.existsSync(fixtureDir)) {
|
|
123575
124060
|
ctx.json(res, 200, { fixtures: [], count: 0 });
|
|
123576
124061
|
return;
|
|
123577
124062
|
}
|
|
123578
|
-
const fixtures =
|
|
123579
|
-
const fullPath =
|
|
124063
|
+
const fixtures = fs53.readdirSync(fixtureDir).filter((file2) => file2.endsWith(".json")).sort((a, b) => b.localeCompare(a, void 0, { numeric: true, sensitivity: "base" })).map((file2) => {
|
|
124064
|
+
const fullPath = path522.join(fixtureDir, file2);
|
|
123580
124065
|
try {
|
|
123581
|
-
const raw = JSON.parse(
|
|
124066
|
+
const raw = JSON.parse(fs53.readFileSync(fullPath, "utf-8"));
|
|
123582
124067
|
return {
|
|
123583
124068
|
name: raw.name || file2.replace(/\.json$/i, ""),
|
|
123584
124069
|
path: fullPath,
|
|
@@ -123709,9 +124194,9 @@ async (params) => {
|
|
|
123709
124194
|
ctx.json(res, 500, { error: `Raw send failed: ${e.message}` });
|
|
123710
124195
|
}
|
|
123711
124196
|
}
|
|
123712
|
-
var
|
|
123713
|
-
var
|
|
123714
|
-
var
|
|
124197
|
+
var fs54 = __toESM2(require("fs"));
|
|
124198
|
+
var path53 = __toESM2(require("path"));
|
|
124199
|
+
var os29 = __toESM2(require("os"));
|
|
123715
124200
|
var import_session_host_core11 = require_dist();
|
|
123716
124201
|
function getAutoImplPid(ctx) {
|
|
123717
124202
|
const pid = ctx.autoImplProcess?.pid;
|
|
@@ -123758,38 +124243,38 @@ async (params) => {
|
|
|
123758
124243
|
return fallback?.type || null;
|
|
123759
124244
|
}
|
|
123760
124245
|
function getLatestScriptVersionDir(scriptsDir) {
|
|
123761
|
-
if (!
|
|
123762
|
-
const versions =
|
|
124246
|
+
if (!fs54.existsSync(scriptsDir)) return null;
|
|
124247
|
+
const versions = fs54.readdirSync(scriptsDir).filter((d) => {
|
|
123763
124248
|
try {
|
|
123764
|
-
return
|
|
124249
|
+
return fs54.statSync(path53.join(scriptsDir, d)).isDirectory();
|
|
123765
124250
|
} catch {
|
|
123766
124251
|
return false;
|
|
123767
124252
|
}
|
|
123768
124253
|
}).sort((a, b) => b.localeCompare(a, void 0, { numeric: true, sensitivity: "base" }));
|
|
123769
124254
|
if (versions.length === 0) return null;
|
|
123770
|
-
return
|
|
124255
|
+
return path53.join(scriptsDir, versions[0]);
|
|
123771
124256
|
}
|
|
123772
124257
|
function resolveAutoImplWritableProviderDir(ctx, category, type2, requestedDir) {
|
|
123773
|
-
const canonicalUserDir =
|
|
123774
|
-
const desiredDir = requestedDir ?
|
|
123775
|
-
const upstreamRoot =
|
|
123776
|
-
if (desiredDir === upstreamRoot || desiredDir.startsWith(`${upstreamRoot}${
|
|
124258
|
+
const canonicalUserDir = path53.resolve(ctx.providerLoader.getUserProviderDir(category, type2));
|
|
124259
|
+
const desiredDir = requestedDir ? path53.resolve(requestedDir) : canonicalUserDir;
|
|
124260
|
+
const upstreamRoot = path53.resolve(ctx.providerLoader.getUpstreamDir());
|
|
124261
|
+
if (desiredDir === upstreamRoot || desiredDir.startsWith(`${upstreamRoot}${path53.sep}`)) {
|
|
123777
124262
|
return { dir: null, reason: `Refusing to write into upstream provider directory: ${desiredDir}` };
|
|
123778
124263
|
}
|
|
123779
|
-
if (
|
|
124264
|
+
if (path53.basename(desiredDir) !== type2) {
|
|
123780
124265
|
return { dir: null, reason: `Requested writable provider directory must end with '${type2}': ${desiredDir}` };
|
|
123781
124266
|
}
|
|
123782
124267
|
const sourceDir = ctx.findProviderDir(type2);
|
|
123783
124268
|
if (!sourceDir) {
|
|
123784
124269
|
return { dir: null, reason: `Provider source directory not found for '${type2}'` };
|
|
123785
124270
|
}
|
|
123786
|
-
if (!
|
|
123787
|
-
|
|
123788
|
-
|
|
124271
|
+
if (!fs54.existsSync(desiredDir)) {
|
|
124272
|
+
fs54.mkdirSync(path53.dirname(desiredDir), { recursive: true });
|
|
124273
|
+
fs54.cpSync(sourceDir, desiredDir, { recursive: true });
|
|
123789
124274
|
ctx.log(`Auto-implement writable copy created: ${desiredDir}`);
|
|
123790
124275
|
}
|
|
123791
|
-
const providerJson =
|
|
123792
|
-
if (!
|
|
124276
|
+
const providerJson = path53.join(desiredDir, "provider.json");
|
|
124277
|
+
if (!fs54.existsSync(providerJson)) {
|
|
123793
124278
|
return { dir: null, reason: `provider.json not found in writable provider directory: ${desiredDir}` };
|
|
123794
124279
|
}
|
|
123795
124280
|
return { dir: desiredDir };
|
|
@@ -123797,15 +124282,15 @@ async (params) => {
|
|
|
123797
124282
|
function loadAutoImplReferenceScripts(ctx, referenceType) {
|
|
123798
124283
|
if (!referenceType) return {};
|
|
123799
124284
|
const refDir = ctx.findProviderDir(referenceType);
|
|
123800
|
-
if (!refDir || !
|
|
124285
|
+
if (!refDir || !fs54.existsSync(refDir)) return {};
|
|
123801
124286
|
const referenceScripts = {};
|
|
123802
|
-
const scriptsDir =
|
|
124287
|
+
const scriptsDir = path53.join(refDir, "scripts");
|
|
123803
124288
|
const latestDir = getLatestScriptVersionDir(scriptsDir);
|
|
123804
124289
|
if (!latestDir) return referenceScripts;
|
|
123805
|
-
for (const file2 of
|
|
124290
|
+
for (const file2 of fs54.readdirSync(latestDir)) {
|
|
123806
124291
|
if (!file2.endsWith(".js")) continue;
|
|
123807
124292
|
try {
|
|
123808
|
-
referenceScripts[file2] =
|
|
124293
|
+
referenceScripts[file2] = fs54.readFileSync(path53.join(latestDir, file2), "utf-8");
|
|
123809
124294
|
} catch {
|
|
123810
124295
|
}
|
|
123811
124296
|
}
|
|
@@ -123913,16 +124398,16 @@ async (params) => {
|
|
|
123913
124398
|
});
|
|
123914
124399
|
const referenceScripts = loadAutoImplReferenceScripts(ctx, resolvedReference);
|
|
123915
124400
|
const prompt = buildAutoImplPrompt(ctx, type2, provider, providerDir, functions, domContext, referenceScripts, comment, resolvedReference, verification);
|
|
123916
|
-
const tmpDir =
|
|
123917
|
-
if (!
|
|
123918
|
-
const promptFile =
|
|
123919
|
-
|
|
124401
|
+
const tmpDir = path53.join(os29.tmpdir(), "adhdev-autoimpl");
|
|
124402
|
+
if (!fs54.existsSync(tmpDir)) fs54.mkdirSync(tmpDir, { recursive: true });
|
|
124403
|
+
const promptFile = path53.join(tmpDir, `prompt-${type2}-${Date.now()}.md`);
|
|
124404
|
+
fs54.writeFileSync(promptFile, prompt, "utf-8");
|
|
123920
124405
|
ctx.log(`Auto-implement prompt written to ${promptFile} (${prompt.length} chars)`);
|
|
123921
124406
|
const agentProvider = ctx.providerLoader.resolve(agent) || ctx.providerLoader.getMeta(agent);
|
|
123922
124407
|
const spawn7 = agentProvider?.spawn;
|
|
123923
124408
|
if (!spawn7?.command) {
|
|
123924
124409
|
try {
|
|
123925
|
-
|
|
124410
|
+
fs54.unlinkSync(promptFile);
|
|
123926
124411
|
} catch {
|
|
123927
124412
|
}
|
|
123928
124413
|
ctx.json(res, 400, { error: `Agent '${agent}' has no spawn config. Select a CLI provider with a spawn configuration.` });
|
|
@@ -124024,7 +124509,7 @@ async (params) => {
|
|
|
124024
124509
|
} catch {
|
|
124025
124510
|
}
|
|
124026
124511
|
try {
|
|
124027
|
-
|
|
124512
|
+
fs54.unlinkSync(promptFile);
|
|
124028
124513
|
} catch {
|
|
124029
124514
|
}
|
|
124030
124515
|
ctx.log(`Auto-implement (ACP) ${success2 ? "completed" : "failed"}: ${type2} (exit: ${code})`);
|
|
@@ -124068,7 +124553,7 @@ async (params) => {
|
|
|
124068
124553
|
const interactiveFlags = ["--yolo", "--interactive", "-i"];
|
|
124069
124554
|
const baseArgs = [...spawn7.args || []].filter((a) => !interactiveFlags.includes(a));
|
|
124070
124555
|
let shellCmd;
|
|
124071
|
-
const isWin =
|
|
124556
|
+
const isWin = os29.platform() === "win32";
|
|
124072
124557
|
const escapeArg = (a) => isWin ? `"${a.replace(/"/g, '""')}"` : `'${a.replace(/'/g, "'\\''")}'`;
|
|
124073
124558
|
const promptMode = autoImpl?.promptMode ?? "stdin";
|
|
124074
124559
|
const extraArgs = autoImpl?.extraArgs ?? [];
|
|
@@ -124107,7 +124592,7 @@ async (params) => {
|
|
|
124107
124592
|
try {
|
|
124108
124593
|
const pty = require("node-pty");
|
|
124109
124594
|
ctx.log(`Auto-implement spawn (PTY): ${shellCmd}`);
|
|
124110
|
-
const isWin2 =
|
|
124595
|
+
const isWin2 = os29.platform() === "win32";
|
|
124111
124596
|
child = pty.spawn(isWin2 ? "cmd.exe" : process.env.SHELL || "/bin/zsh", [isWin2 ? "/c" : "-c", shellCmd], {
|
|
124112
124597
|
name: "xterm-256color",
|
|
124113
124598
|
cols: import_session_host_core11.DEFAULT_SESSION_HOST_COLS,
|
|
@@ -124250,7 +124735,7 @@ async (params) => {
|
|
|
124250
124735
|
}
|
|
124251
124736
|
});
|
|
124252
124737
|
try {
|
|
124253
|
-
|
|
124738
|
+
fs54.unlinkSync(promptFile);
|
|
124254
124739
|
} catch {
|
|
124255
124740
|
}
|
|
124256
124741
|
ctx.log(`Auto-implement ${success2 ? "completed" : "failed"}: ${type2} (exit: ${code})${verificationSummary ? ` verify=${verificationSummary.pass ? "pass" : "fail"}` : ""}`);
|
|
@@ -124347,7 +124832,7 @@ async (params) => {
|
|
|
124347
124832
|
setMode: "set_mode.js"
|
|
124348
124833
|
};
|
|
124349
124834
|
const targetFileNames = new Set(functions.map((fn) => funcToFile[fn]).filter(Boolean));
|
|
124350
|
-
const scriptsDir =
|
|
124835
|
+
const scriptsDir = path53.join(providerDir, "scripts");
|
|
124351
124836
|
const latestScriptsDir = getLatestScriptVersionDir(scriptsDir);
|
|
124352
124837
|
if (latestScriptsDir) {
|
|
124353
124838
|
lines.push(`Scripts version directory: \`${latestScriptsDir}\``);
|
|
@@ -124355,10 +124840,10 @@ async (params) => {
|
|
|
124355
124840
|
lines.push("## \u270F\uFE0F Target Files (EDIT THESE)");
|
|
124356
124841
|
lines.push("These are the ONLY files you are allowed to modify. Replace the TODO stubs with working implementations.");
|
|
124357
124842
|
lines.push("");
|
|
124358
|
-
for (const file2 of
|
|
124843
|
+
for (const file2 of fs54.readdirSync(latestScriptsDir)) {
|
|
124359
124844
|
if (file2.endsWith(".js") && targetFileNames.has(file2)) {
|
|
124360
124845
|
try {
|
|
124361
|
-
const content =
|
|
124846
|
+
const content = fs54.readFileSync(path53.join(latestScriptsDir, file2), "utf-8");
|
|
124362
124847
|
lines.push(`### \`${file2}\` \u270F\uFE0F EDIT`);
|
|
124363
124848
|
lines.push("```javascript");
|
|
124364
124849
|
lines.push(content);
|
|
@@ -124368,14 +124853,14 @@ async (params) => {
|
|
|
124368
124853
|
}
|
|
124369
124854
|
}
|
|
124370
124855
|
}
|
|
124371
|
-
const refFiles =
|
|
124856
|
+
const refFiles = fs54.readdirSync(latestScriptsDir).filter((f) => f.endsWith(".js") && !targetFileNames.has(f));
|
|
124372
124857
|
if (refFiles.length > 0) {
|
|
124373
124858
|
lines.push("## \u{1F512} Other Scripts (REFERENCE ONLY \u2014 DO NOT EDIT)");
|
|
124374
124859
|
lines.push("These files are shown for context only. Do NOT modify them under any circumstances.");
|
|
124375
124860
|
lines.push("");
|
|
124376
124861
|
for (const file2 of refFiles) {
|
|
124377
124862
|
try {
|
|
124378
|
-
const content =
|
|
124863
|
+
const content = fs54.readFileSync(path53.join(latestScriptsDir, file2), "utf-8");
|
|
124379
124864
|
lines.push(`### \`${file2}\` \u{1F512}`);
|
|
124380
124865
|
lines.push("```javascript");
|
|
124381
124866
|
lines.push(content);
|
|
@@ -124416,11 +124901,11 @@ async (params) => {
|
|
|
124416
124901
|
lines.push("");
|
|
124417
124902
|
}
|
|
124418
124903
|
}
|
|
124419
|
-
const docsDir =
|
|
124904
|
+
const docsDir = path53.join(providerDir, "../../docs");
|
|
124420
124905
|
const loadGuide = (name) => {
|
|
124421
124906
|
try {
|
|
124422
|
-
const p =
|
|
124423
|
-
if (
|
|
124907
|
+
const p = path53.join(docsDir, name);
|
|
124908
|
+
if (fs54.existsSync(p)) return fs54.readFileSync(p, "utf-8");
|
|
124424
124909
|
} catch {
|
|
124425
124910
|
}
|
|
124426
124911
|
return null;
|
|
@@ -124656,7 +125141,7 @@ async (params) => {
|
|
|
124656
125141
|
parseApproval: "parse_approval.js"
|
|
124657
125142
|
};
|
|
124658
125143
|
const targetFileNames = new Set(functions.map((fn) => funcToFile[fn]).filter(Boolean));
|
|
124659
|
-
const scriptsDir =
|
|
125144
|
+
const scriptsDir = path53.join(providerDir, "scripts");
|
|
124660
125145
|
const latestScriptsDir = getLatestScriptVersionDir(scriptsDir);
|
|
124661
125146
|
if (latestScriptsDir) {
|
|
124662
125147
|
lines.push(`Scripts version directory: \`${latestScriptsDir}\``);
|
|
@@ -124664,11 +125149,11 @@ async (params) => {
|
|
|
124664
125149
|
lines.push("## \u270F\uFE0F Target Files (EDIT THESE)");
|
|
124665
125150
|
lines.push("These are the ONLY files you are allowed to modify. Replace TODO or heuristic-only logic with working PTY-aware implementations.");
|
|
124666
125151
|
lines.push("");
|
|
124667
|
-
for (const file2 of
|
|
125152
|
+
for (const file2 of fs54.readdirSync(latestScriptsDir)) {
|
|
124668
125153
|
if (!file2.endsWith(".js")) continue;
|
|
124669
125154
|
if (!targetFileNames.has(file2)) continue;
|
|
124670
125155
|
try {
|
|
124671
|
-
const content =
|
|
125156
|
+
const content = fs54.readFileSync(path53.join(latestScriptsDir, file2), "utf-8");
|
|
124672
125157
|
lines.push(`### \`${file2}\` \u270F\uFE0F EDIT`);
|
|
124673
125158
|
lines.push("```javascript");
|
|
124674
125159
|
lines.push(content);
|
|
@@ -124677,14 +125162,14 @@ async (params) => {
|
|
|
124677
125162
|
} catch {
|
|
124678
125163
|
}
|
|
124679
125164
|
}
|
|
124680
|
-
const refFiles =
|
|
125165
|
+
const refFiles = fs54.readdirSync(latestScriptsDir).filter((f) => f.endsWith(".js") && !targetFileNames.has(f));
|
|
124681
125166
|
if (refFiles.length > 0) {
|
|
124682
125167
|
lines.push("## \u{1F512} Other Scripts (REFERENCE ONLY \u2014 DO NOT EDIT)");
|
|
124683
125168
|
lines.push("These files are shown for context only. Do NOT modify them under any circumstances.");
|
|
124684
125169
|
lines.push("");
|
|
124685
125170
|
for (const file2 of refFiles) {
|
|
124686
125171
|
try {
|
|
124687
|
-
const content =
|
|
125172
|
+
const content = fs54.readFileSync(path53.join(latestScriptsDir, file2), "utf-8");
|
|
124688
125173
|
lines.push(`### \`${file2}\` \u{1F512}`);
|
|
124689
125174
|
lines.push("```javascript");
|
|
124690
125175
|
lines.push(content);
|
|
@@ -124717,11 +125202,11 @@ async (params) => {
|
|
|
124717
125202
|
lines.push("");
|
|
124718
125203
|
}
|
|
124719
125204
|
}
|
|
124720
|
-
const docsDir =
|
|
125205
|
+
const docsDir = path53.join(providerDir, "../../docs");
|
|
124721
125206
|
const loadGuide = (name) => {
|
|
124722
125207
|
try {
|
|
124723
|
-
const p =
|
|
124724
|
-
if (
|
|
125208
|
+
const p = path53.join(docsDir, name);
|
|
125209
|
+
if (fs54.existsSync(p)) return fs54.readFileSync(p, "utf-8");
|
|
124725
125210
|
} catch {
|
|
124726
125211
|
}
|
|
124727
125212
|
return null;
|
|
@@ -125165,8 +125650,8 @@ data: ${JSON.stringify(msg.data)}
|
|
|
125165
125650
|
}
|
|
125166
125651
|
getEndpointList() {
|
|
125167
125652
|
return this.routes.map((r) => {
|
|
125168
|
-
const
|
|
125169
|
-
return `${r.method.padEnd(5)} ${
|
|
125653
|
+
const path56 = typeof r.pattern === "string" ? r.pattern : r.pattern.source.replace(/\\\//g, "/").replace(/\(\[.*?\]\+\)/g, ":type").replace(/[\^$]/g, "");
|
|
125654
|
+
return `${r.method.padEnd(5)} ${path56}`;
|
|
125170
125655
|
});
|
|
125171
125656
|
}
|
|
125172
125657
|
async start(port = DEV_SERVER_PORT) {
|
|
@@ -125454,12 +125939,12 @@ data: ${JSON.stringify(msg.data)}
|
|
|
125454
125939
|
// ─── DevConsole SPA ───
|
|
125455
125940
|
getConsoleDistDir() {
|
|
125456
125941
|
const candidates = [
|
|
125457
|
-
|
|
125458
|
-
|
|
125459
|
-
|
|
125942
|
+
path54.resolve(__dirname, "../../web-devconsole/dist"),
|
|
125943
|
+
path54.resolve(__dirname, "../../../web-devconsole/dist"),
|
|
125944
|
+
path54.join(process.cwd(), "packages/web-devconsole/dist")
|
|
125460
125945
|
];
|
|
125461
125946
|
for (const dir of candidates) {
|
|
125462
|
-
if (
|
|
125947
|
+
if (fs55.existsSync(path54.join(dir, "index.html"))) return dir;
|
|
125463
125948
|
}
|
|
125464
125949
|
return null;
|
|
125465
125950
|
}
|
|
@@ -125469,9 +125954,9 @@ data: ${JSON.stringify(msg.data)}
|
|
|
125469
125954
|
this.json(res, 500, { error: "DevConsole not found. Run: npm run build -w packages/web-devconsole" });
|
|
125470
125955
|
return;
|
|
125471
125956
|
}
|
|
125472
|
-
const htmlPath =
|
|
125957
|
+
const htmlPath = path54.join(distDir, "index.html");
|
|
125473
125958
|
try {
|
|
125474
|
-
const html =
|
|
125959
|
+
const html = fs55.readFileSync(htmlPath, "utf-8");
|
|
125475
125960
|
res.writeHead(200, { "Content-Type": "text/html; charset=utf-8" });
|
|
125476
125961
|
res.end(html);
|
|
125477
125962
|
} catch (e) {
|
|
@@ -125494,15 +125979,15 @@ data: ${JSON.stringify(msg.data)}
|
|
|
125494
125979
|
this.json(res, 404, { error: "Not found" });
|
|
125495
125980
|
return;
|
|
125496
125981
|
}
|
|
125497
|
-
const safePath =
|
|
125498
|
-
const filePath =
|
|
125982
|
+
const safePath = path54.normalize(pathname).replace(/^\.\.\//, "");
|
|
125983
|
+
const filePath = path54.join(distDir, safePath);
|
|
125499
125984
|
if (!filePath.startsWith(distDir)) {
|
|
125500
125985
|
this.json(res, 403, { error: "Forbidden" });
|
|
125501
125986
|
return;
|
|
125502
125987
|
}
|
|
125503
125988
|
try {
|
|
125504
|
-
const content =
|
|
125505
|
-
const ext =
|
|
125989
|
+
const content = fs55.readFileSync(filePath);
|
|
125990
|
+
const ext = path54.extname(filePath);
|
|
125506
125991
|
const contentType = _DevServer.MIME_MAP[ext] || "application/octet-stream";
|
|
125507
125992
|
res.writeHead(200, { "Content-Type": contentType, "Cache-Control": "public, max-age=31536000, immutable" });
|
|
125508
125993
|
res.end(content);
|
|
@@ -125610,14 +126095,14 @@ data: ${JSON.stringify(msg.data)}
|
|
|
125610
126095
|
const files = [];
|
|
125611
126096
|
const scan = (d, prefix) => {
|
|
125612
126097
|
try {
|
|
125613
|
-
for (const entry of
|
|
126098
|
+
for (const entry of fs55.readdirSync(d, { withFileTypes: true })) {
|
|
125614
126099
|
if (entry.name.startsWith(".") || entry.name.endsWith(".bak")) continue;
|
|
125615
126100
|
const rel = prefix ? `${prefix}/${entry.name}` : entry.name;
|
|
125616
126101
|
if (entry.isDirectory()) {
|
|
125617
126102
|
files.push({ path: rel, size: 0, type: "dir" });
|
|
125618
|
-
scan(
|
|
126103
|
+
scan(path54.join(d, entry.name), rel);
|
|
125619
126104
|
} else {
|
|
125620
|
-
const stat2 =
|
|
126105
|
+
const stat2 = fs55.statSync(path54.join(d, entry.name));
|
|
125621
126106
|
files.push({ path: rel, size: stat2.size, type: "file" });
|
|
125622
126107
|
}
|
|
125623
126108
|
}
|
|
@@ -125640,16 +126125,16 @@ data: ${JSON.stringify(msg.data)}
|
|
|
125640
126125
|
this.json(res, 404, { error: `Provider directory not found: ${type2}` });
|
|
125641
126126
|
return;
|
|
125642
126127
|
}
|
|
125643
|
-
const fullPath =
|
|
126128
|
+
const fullPath = path54.resolve(dir, path54.normalize(filePath));
|
|
125644
126129
|
if (!fullPath.startsWith(dir)) {
|
|
125645
126130
|
this.json(res, 403, { error: "Forbidden" });
|
|
125646
126131
|
return;
|
|
125647
126132
|
}
|
|
125648
|
-
if (!
|
|
126133
|
+
if (!fs55.existsSync(fullPath) || fs55.statSync(fullPath).isDirectory()) {
|
|
125649
126134
|
this.json(res, 404, { error: `File not found: ${filePath}` });
|
|
125650
126135
|
return;
|
|
125651
126136
|
}
|
|
125652
|
-
const content =
|
|
126137
|
+
const content = fs55.readFileSync(fullPath, "utf-8");
|
|
125653
126138
|
this.json(res, 200, { type: type2, path: filePath, content, lines: content.split("\n").length });
|
|
125654
126139
|
}
|
|
125655
126140
|
/** POST /api/providers/:type/file — write a file { path, content } */
|
|
@@ -125665,15 +126150,15 @@ data: ${JSON.stringify(msg.data)}
|
|
|
125665
126150
|
this.json(res, 404, { error: `Provider directory not found: ${type2}` });
|
|
125666
126151
|
return;
|
|
125667
126152
|
}
|
|
125668
|
-
const fullPath =
|
|
126153
|
+
const fullPath = path54.resolve(dir, path54.normalize(filePath));
|
|
125669
126154
|
if (!fullPath.startsWith(dir)) {
|
|
125670
126155
|
this.json(res, 403, { error: "Forbidden" });
|
|
125671
126156
|
return;
|
|
125672
126157
|
}
|
|
125673
126158
|
try {
|
|
125674
|
-
if (
|
|
125675
|
-
|
|
125676
|
-
|
|
126159
|
+
if (fs55.existsSync(fullPath)) fs55.copyFileSync(fullPath, fullPath + ".bak");
|
|
126160
|
+
fs55.mkdirSync(path54.dirname(fullPath), { recursive: true });
|
|
126161
|
+
fs55.writeFileSync(fullPath, content, "utf-8");
|
|
125677
126162
|
this.log(`File saved: ${fullPath} (${content.length} chars)`);
|
|
125678
126163
|
this.providerLoader.reload();
|
|
125679
126164
|
this.json(res, 200, { saved: true, path: filePath, chars: content.length });
|
|
@@ -125689,9 +126174,9 @@ data: ${JSON.stringify(msg.data)}
|
|
|
125689
126174
|
return;
|
|
125690
126175
|
}
|
|
125691
126176
|
for (const name of ["scripts.js", "provider.json"]) {
|
|
125692
|
-
const p =
|
|
125693
|
-
if (
|
|
125694
|
-
const source =
|
|
126177
|
+
const p = path54.join(dir, name);
|
|
126178
|
+
if (fs55.existsSync(p)) {
|
|
126179
|
+
const source = fs55.readFileSync(p, "utf-8");
|
|
125695
126180
|
this.json(res, 200, { type: type2, path: p, source, lines: source.split("\n").length });
|
|
125696
126181
|
return;
|
|
125697
126182
|
}
|
|
@@ -125710,11 +126195,11 @@ data: ${JSON.stringify(msg.data)}
|
|
|
125710
126195
|
this.json(res, 404, { error: `Provider not found: ${type2}` });
|
|
125711
126196
|
return;
|
|
125712
126197
|
}
|
|
125713
|
-
const target =
|
|
125714
|
-
const targetPath =
|
|
126198
|
+
const target = fs55.existsSync(path54.join(dir, "scripts.js")) ? "scripts.js" : "provider.json";
|
|
126199
|
+
const targetPath = path54.join(dir, target);
|
|
125715
126200
|
try {
|
|
125716
|
-
if (
|
|
125717
|
-
|
|
126201
|
+
if (fs55.existsSync(targetPath)) fs55.copyFileSync(targetPath, targetPath + ".bak");
|
|
126202
|
+
fs55.writeFileSync(targetPath, source, "utf-8");
|
|
125718
126203
|
this.log(`Saved provider: ${targetPath} (${source.length} chars)`);
|
|
125719
126204
|
this.providerLoader.reload();
|
|
125720
126205
|
this.json(res, 200, { saved: true, path: targetPath, chars: source.length });
|
|
@@ -125858,21 +126343,21 @@ data: ${JSON.stringify(msg.data)}
|
|
|
125858
126343
|
}
|
|
125859
126344
|
let targetDir;
|
|
125860
126345
|
targetDir = this.providerLoader.getUserProviderDir(category, type2);
|
|
125861
|
-
const jsonPath =
|
|
125862
|
-
if (
|
|
126346
|
+
const jsonPath = path54.join(targetDir, "provider.json");
|
|
126347
|
+
if (fs55.existsSync(jsonPath)) {
|
|
125863
126348
|
this.json(res, 409, { error: `Provider already exists at ${targetDir}`, path: targetDir });
|
|
125864
126349
|
return;
|
|
125865
126350
|
}
|
|
125866
126351
|
try {
|
|
125867
126352
|
const result = generateFiles(type2, name, category, { cdpPorts, cli, processName, installPath, binary: binary2, extensionId, version: version2, osPaths, processNames });
|
|
125868
|
-
|
|
125869
|
-
|
|
126353
|
+
fs55.mkdirSync(targetDir, { recursive: true });
|
|
126354
|
+
fs55.writeFileSync(jsonPath, result["provider.json"], "utf-8");
|
|
125870
126355
|
const createdFiles = ["provider.json"];
|
|
125871
126356
|
if (result.files) {
|
|
125872
126357
|
for (const [relPath, content] of Object.entries(result.files)) {
|
|
125873
|
-
const fullPath =
|
|
125874
|
-
|
|
125875
|
-
|
|
126358
|
+
const fullPath = path54.join(targetDir, relPath);
|
|
126359
|
+
fs55.mkdirSync(path54.dirname(fullPath), { recursive: true });
|
|
126360
|
+
fs55.writeFileSync(fullPath, content, "utf-8");
|
|
125876
126361
|
createdFiles.push(relPath);
|
|
125877
126362
|
}
|
|
125878
126363
|
}
|
|
@@ -125921,38 +126406,38 @@ data: ${JSON.stringify(msg.data)}
|
|
|
125921
126406
|
}
|
|
125922
126407
|
// ─── Phase 2: Auto-Implement Backend ───
|
|
125923
126408
|
getLatestScriptVersionDir(scriptsDir) {
|
|
125924
|
-
if (!
|
|
125925
|
-
const versions =
|
|
126409
|
+
if (!fs55.existsSync(scriptsDir)) return null;
|
|
126410
|
+
const versions = fs55.readdirSync(scriptsDir).filter((d) => {
|
|
125926
126411
|
try {
|
|
125927
|
-
return
|
|
126412
|
+
return fs55.statSync(path54.join(scriptsDir, d)).isDirectory();
|
|
125928
126413
|
} catch {
|
|
125929
126414
|
return false;
|
|
125930
126415
|
}
|
|
125931
126416
|
}).sort((a, b) => b.localeCompare(a, void 0, { numeric: true, sensitivity: "base" }));
|
|
125932
126417
|
if (versions.length === 0) return null;
|
|
125933
|
-
return
|
|
126418
|
+
return path54.join(scriptsDir, versions[0]);
|
|
125934
126419
|
}
|
|
125935
126420
|
resolveAutoImplWritableProviderDir(category, type2, requestedDir) {
|
|
125936
|
-
const canonicalUserDir =
|
|
125937
|
-
const desiredDir = requestedDir ?
|
|
125938
|
-
const upstreamRoot =
|
|
125939
|
-
if (desiredDir === upstreamRoot || desiredDir.startsWith(`${upstreamRoot}${
|
|
126421
|
+
const canonicalUserDir = path54.resolve(this.providerLoader.getUserProviderDir(category, type2));
|
|
126422
|
+
const desiredDir = requestedDir ? path54.resolve(requestedDir) : canonicalUserDir;
|
|
126423
|
+
const upstreamRoot = path54.resolve(this.providerLoader.getUpstreamDir());
|
|
126424
|
+
if (desiredDir === upstreamRoot || desiredDir.startsWith(`${upstreamRoot}${path54.sep}`)) {
|
|
125940
126425
|
return { dir: null, reason: `Refusing to write into upstream provider directory: ${desiredDir}` };
|
|
125941
126426
|
}
|
|
125942
|
-
if (
|
|
126427
|
+
if (path54.basename(desiredDir) !== type2) {
|
|
125943
126428
|
return { dir: null, reason: `Requested writable provider directory must end with '${type2}': ${desiredDir}` };
|
|
125944
126429
|
}
|
|
125945
126430
|
const sourceDir = this.findProviderDir(type2);
|
|
125946
126431
|
if (!sourceDir) {
|
|
125947
126432
|
return { dir: null, reason: `Provider source directory not found for '${type2}'` };
|
|
125948
126433
|
}
|
|
125949
|
-
if (!
|
|
125950
|
-
|
|
125951
|
-
|
|
126434
|
+
if (!fs55.existsSync(desiredDir)) {
|
|
126435
|
+
fs55.mkdirSync(path54.dirname(desiredDir), { recursive: true });
|
|
126436
|
+
fs55.cpSync(sourceDir, desiredDir, { recursive: true });
|
|
125952
126437
|
this.log(`Auto-implement writable copy created: ${desiredDir}`);
|
|
125953
126438
|
}
|
|
125954
|
-
const providerJson =
|
|
125955
|
-
if (!
|
|
126439
|
+
const providerJson = path54.join(desiredDir, "provider.json");
|
|
126440
|
+
if (!fs55.existsSync(providerJson)) {
|
|
125956
126441
|
return { dir: null, reason: `provider.json not found in writable provider directory: ${desiredDir}` };
|
|
125957
126442
|
}
|
|
125958
126443
|
return { dir: desiredDir };
|
|
@@ -126762,9 +127247,9 @@ data: ${JSON.stringify(msg.data)}
|
|
|
126762
127247
|
}
|
|
126763
127248
|
}
|
|
126764
127249
|
var import_child_process14 = require("child_process");
|
|
126765
|
-
var
|
|
126766
|
-
var
|
|
126767
|
-
var
|
|
127250
|
+
var fs56 = __toESM2(require("fs"));
|
|
127251
|
+
var os30 = __toESM2(require("os"));
|
|
127252
|
+
var path55 = __toESM2(require("path"));
|
|
126768
127253
|
var import_session_host_core15 = require_dist();
|
|
126769
127254
|
init_logger();
|
|
126770
127255
|
init_runtime_defaults();
|
|
@@ -126784,18 +127269,18 @@ data: ${JSON.stringify(msg.data)}
|
|
|
126784
127269
|
function resolveEntry() {
|
|
126785
127270
|
if (options.resolveEntryOverride) return options.resolveEntryOverride();
|
|
126786
127271
|
const packagedCandidates = [
|
|
126787
|
-
|
|
126788
|
-
|
|
127272
|
+
path55.resolve(__dirname, "../vendor/session-host-daemon/index.js"),
|
|
127273
|
+
path55.resolve(__dirname, "../../vendor/session-host-daemon/index.js")
|
|
126789
127274
|
];
|
|
126790
127275
|
for (const candidate of packagedCandidates) {
|
|
126791
|
-
if (
|
|
127276
|
+
if (fs56.existsSync(candidate)) {
|
|
126792
127277
|
return candidate;
|
|
126793
127278
|
}
|
|
126794
127279
|
}
|
|
126795
127280
|
return require.resolve("@adhdev/session-host-daemon");
|
|
126796
127281
|
}
|
|
126797
127282
|
function pathsEquivalent(left, right) {
|
|
126798
|
-
return
|
|
127283
|
+
return path55.resolve(left).toLowerCase() === path55.resolve(right).toLowerCase();
|
|
126799
127284
|
}
|
|
126800
127285
|
function getRunningSessionHostScriptPath(pid) {
|
|
126801
127286
|
const commandLine = getProcessCommandLine(pid);
|
|
@@ -126803,13 +127288,13 @@ data: ${JSON.stringify(msg.data)}
|
|
|
126803
127288
|
return parseNodeScriptPath(commandLine);
|
|
126804
127289
|
}
|
|
126805
127290
|
function getPidFile() {
|
|
126806
|
-
return
|
|
127291
|
+
return path55.join(instance().configDir, `${appName}-session-host.pid`);
|
|
126807
127292
|
}
|
|
126808
127293
|
function getPid() {
|
|
126809
127294
|
try {
|
|
126810
127295
|
const pidFile = getPidFile();
|
|
126811
|
-
if (!
|
|
126812
|
-
const pid = Number.parseInt(
|
|
127296
|
+
if (!fs56.existsSync(pidFile)) return null;
|
|
127297
|
+
const pid = Number.parseInt(fs56.readFileSync(pidFile, "utf8").trim(), 10);
|
|
126813
127298
|
return Number.isFinite(pid) ? pid : null;
|
|
126814
127299
|
} catch {
|
|
126815
127300
|
return null;
|
|
@@ -126835,7 +127320,7 @@ data: ${JSON.stringify(msg.data)}
|
|
|
126835
127320
|
}
|
|
126836
127321
|
let portableNode = null;
|
|
126837
127322
|
try {
|
|
126838
|
-
portableNode = findPortableNode22(
|
|
127323
|
+
portableNode = findPortableNode22(os30.homedir(), process.execPath, resolveInstanceDir());
|
|
126839
127324
|
} catch (error48) {
|
|
126840
127325
|
LOG2.warn(
|
|
126841
127326
|
"SessionHost",
|
|
@@ -126859,7 +127344,7 @@ data: ${JSON.stringify(msg.data)}
|
|
|
126859
127344
|
if (markerIndex === -1) return;
|
|
126860
127345
|
const activePrefix = entry.slice(0, markerIndex);
|
|
126861
127346
|
const candidates = resolveConptyPrebuildCandidates(activePrefix);
|
|
126862
|
-
const found = candidates.find((candidate) =>
|
|
127347
|
+
const found = candidates.find((candidate) => fs56.existsSync(candidate));
|
|
126863
127348
|
if (!found) {
|
|
126864
127349
|
throw new Error(
|
|
126865
127350
|
`conpty.node missing at boot despite passing the install-time gate \u2014 likely deleted post-install (checked: ${candidates.join(", ")}). Every session-host spawn would crash requiring node-pty; refusing to spawn.`
|
|
@@ -126874,9 +127359,9 @@ data: ${JSON.stringify(msg.data)}
|
|
|
126874
127359
|
let stdio = "ignore";
|
|
126875
127360
|
let logFd = null;
|
|
126876
127361
|
if (options.spawnStdio === "logfile") {
|
|
126877
|
-
const logDir =
|
|
126878
|
-
|
|
126879
|
-
logFd =
|
|
127362
|
+
const logDir = path55.join(instance().configDir, "logs");
|
|
127363
|
+
fs56.mkdirSync(logDir, { recursive: true });
|
|
127364
|
+
logFd = fs56.openSync(path55.join(logDir, "session-host.log"), "a");
|
|
126880
127365
|
stdio = ["ignore", logFd, logFd];
|
|
126881
127366
|
}
|
|
126882
127367
|
const child = (0, import_child_process14.spawn)(nodeExecutable, [entry], {
|
|
@@ -126888,7 +127373,7 @@ data: ${JSON.stringify(msg.data)}
|
|
|
126888
127373
|
child.unref();
|
|
126889
127374
|
if (logFd !== null) {
|
|
126890
127375
|
try {
|
|
126891
|
-
|
|
127376
|
+
fs56.closeSync(logFd);
|
|
126892
127377
|
} catch {
|
|
126893
127378
|
}
|
|
126894
127379
|
}
|
|
@@ -126906,8 +127391,8 @@ data: ${JSON.stringify(msg.data)}
|
|
|
126906
127391
|
const pidFile = getPidFile();
|
|
126907
127392
|
let keepPidFile = false;
|
|
126908
127393
|
try {
|
|
126909
|
-
if (
|
|
126910
|
-
const pid = Number.parseInt(
|
|
127394
|
+
if (fs56.existsSync(pidFile)) {
|
|
127395
|
+
const pid = Number.parseInt(fs56.readFileSync(pidFile, "utf8").trim(), 10);
|
|
126911
127396
|
if (Number.isFinite(pid) && pid !== process.pid) {
|
|
126912
127397
|
const managed = isManagedPid(pid);
|
|
126913
127398
|
if (managed) {
|
|
@@ -126927,7 +127412,7 @@ data: ${JSON.stringify(msg.data)}
|
|
|
126927
127412
|
} finally {
|
|
126928
127413
|
if (!keepPidFile) {
|
|
126929
127414
|
try {
|
|
126930
|
-
|
|
127415
|
+
fs56.unlinkSync(pidFile);
|
|
126931
127416
|
} catch {
|
|
126932
127417
|
}
|
|
126933
127418
|
}
|
|
@@ -126963,7 +127448,7 @@ data: ${JSON.stringify(msg.data)}
|
|
|
126963
127448
|
}
|
|
126964
127449
|
if (!reported) return;
|
|
126965
127450
|
if (pathsEquivalent(reported, currentEntry)) return;
|
|
126966
|
-
const reportedExists =
|
|
127451
|
+
const reportedExists = fs56.existsSync(reported);
|
|
126967
127452
|
LOG2.warn(
|
|
126968
127453
|
"SessionHost",
|
|
126969
127454
|
`Reachable session-host reports it is running from ${reported}${reportedExists ? "" : " (which no longer exists)"}, but this install runs from ${currentEntry}. That host would fail every create_session loading node-pty from its own prefix; stopping it so a current one is spawned in its place.`
|
|
@@ -127190,8 +127675,8 @@ data: ${JSON.stringify(msg.data)}
|
|
|
127190
127675
|
const res = await fetch(extension.vsixUrl);
|
|
127191
127676
|
if (res.ok) {
|
|
127192
127677
|
const buffer = Buffer.from(await res.arrayBuffer());
|
|
127193
|
-
const
|
|
127194
|
-
|
|
127678
|
+
const fs58 = await import("fs");
|
|
127679
|
+
fs58.writeFileSync(vsixPath, buffer);
|
|
127195
127680
|
return new Promise((resolve30) => {
|
|
127196
127681
|
const cmd = `"${ide.cliCommand}" --install-extension "${vsixPath}" --force`;
|
|
127197
127682
|
(0, import_child_process15.exec)(cmd, { timeout: 6e4 }, (error48, _stdout, stderr) => {
|
|
@@ -127415,11 +127900,11 @@ data: ${JSON.stringify(msg.data)}
|
|
|
127415
127900
|
}
|
|
127416
127901
|
for (const name of names) {
|
|
127417
127902
|
if (!isPendingEventsFile(name)) continue;
|
|
127418
|
-
const
|
|
127903
|
+
const path56 = (0, import_path20.join)(dir, name);
|
|
127419
127904
|
result.filesScanned++;
|
|
127420
|
-
const claimed = `${
|
|
127905
|
+
const claimed = `${path56}.migrating`;
|
|
127421
127906
|
try {
|
|
127422
|
-
(0, import_fs19.renameSync)(
|
|
127907
|
+
(0, import_fs19.renameSync)(path56, claimed);
|
|
127423
127908
|
} catch {
|
|
127424
127909
|
continue;
|
|
127425
127910
|
}
|
|
@@ -127429,7 +127914,7 @@ data: ${JSON.stringify(msg.data)}
|
|
|
127429
127914
|
} catch (e) {
|
|
127430
127915
|
LOG2.warn("MeshEvents", `Pending-events migration: cannot read ${name}; leaving it for the next boot: ${e?.message || e}`);
|
|
127431
127916
|
try {
|
|
127432
|
-
(0, import_fs19.renameSync)(claimed,
|
|
127917
|
+
(0, import_fs19.renameSync)(claimed, path56);
|
|
127433
127918
|
} catch {
|
|
127434
127919
|
}
|
|
127435
127920
|
result.filesRetained++;
|
|
@@ -127444,7 +127929,7 @@ data: ${JSON.stringify(msg.data)}
|
|
|
127444
127929
|
}
|
|
127445
127930
|
if (!allImported) {
|
|
127446
127931
|
try {
|
|
127447
|
-
(0, import_fs19.renameSync)(claimed,
|
|
127932
|
+
(0, import_fs19.renameSync)(claimed, path56);
|
|
127448
127933
|
} catch {
|
|
127449
127934
|
}
|
|
127450
127935
|
result.filesRetained++;
|
|
@@ -128040,10 +128525,10 @@ ${upgradeFailureNotice.notice}${supersededHint}`);
|
|
|
128040
128525
|
init_parse_approval();
|
|
128041
128526
|
init_visible_region();
|
|
128042
128527
|
init_parse_session();
|
|
128043
|
-
var
|
|
128528
|
+
var import_node_fs7 = require("fs");
|
|
128044
128529
|
var import_node_path6 = require("path");
|
|
128045
128530
|
init_provider_cli_shared();
|
|
128046
|
-
var
|
|
128531
|
+
var import_node_fs8 = require("fs");
|
|
128047
128532
|
var import_node_path7 = require("path");
|
|
128048
128533
|
init_manifest();
|
|
128049
128534
|
var V1_PRIMITIVE_CATALOG = Object.freeze({
|
|
@@ -128116,7 +128601,7 @@ ${upgradeFailureNotice.notice}${supersededHint}`);
|
|
|
128116
128601
|
Object.values(V1_PRIMITIVE_CATALOG).flat()
|
|
128117
128602
|
);
|
|
128118
128603
|
var V1_CONTRACT_VERSION = "1.0.0";
|
|
128119
|
-
var
|
|
128604
|
+
var fs57 = __toESM2(require("fs"));
|
|
128120
128605
|
var import_chalk2 = __toESM2((init_source(), __toCommonJS(source_exports)));
|
|
128121
128606
|
init_dist();
|
|
128122
128607
|
var CLAUDE_NO_API_LINE = "Claude has no quota API \u2014 adhdev borrows your statusLine to read it.";
|
|
@@ -128227,7 +128712,7 @@ ${upgradeFailureNotice.notice}${supersededHint}`);
|
|
|
128227
128712
|
console.log(import_chalk2.default.gray(` Backup: ${status.paths.backupFile}`));
|
|
128228
128713
|
let snapshotMtimeMs = null;
|
|
128229
128714
|
try {
|
|
128230
|
-
snapshotMtimeMs =
|
|
128715
|
+
snapshotMtimeMs = fs57.statSync(status.paths.snapshotFile).mtimeMs;
|
|
128231
128716
|
} catch {
|
|
128232
128717
|
}
|
|
128233
128718
|
console.log(import_chalk2.default.gray(
|