@adhdev/daemon-core 0.9.82-rc.447 → 0.9.82-rc.449
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/commands/cli-manager.d.ts +10 -0
- package/dist/commands/med-family/types.d.ts +10 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +635 -447
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +636 -446
- package/dist/index.mjs.map +1 -1
- package/dist/providers/spec/adapter.d.ts +7 -0
- package/dist/providers/spec/fsm-driver.d.ts +6 -0
- package/dist/session-host/managed-host.d.ts +64 -0
- package/package.json +2 -2
- package/src/commands/cli-manager.ts +41 -17
- package/src/commands/med-family/mesh-crud.ts +12 -1
- package/src/commands/med-family/types.ts +10 -0
- package/src/commands/router.ts +46 -1
- package/src/index.ts +2 -0
- package/src/providers/spec/adapter.ts +11 -0
- package/src/providers/spec/cli-adapter.ts +9 -1
- package/src/providers/spec/fsm-driver.ts +9 -0
- package/src/session-host/managed-host.ts +218 -0
package/dist/index.mjs
CHANGED
|
@@ -404,10 +404,10 @@ function readInjected(value) {
|
|
|
404
404
|
}
|
|
405
405
|
function getDaemonBuildInfo() {
|
|
406
406
|
if (cached) return cached;
|
|
407
|
-
const commit = readInjected(true ? "
|
|
408
|
-
const commitShort = readInjected(true ? "
|
|
409
|
-
const version = readInjected(true ? "0.9.82-rc.
|
|
410
|
-
const builtAt = readInjected(true ? "2026-07-
|
|
407
|
+
const commit = readInjected(true ? "fe0e4d2aa03aea2793c2379e5ffc89abef5143d6" : void 0) ?? "unknown";
|
|
408
|
+
const commitShort = readInjected(true ? "fe0e4d2a" : void 0) ?? (commit !== "unknown" ? commit.slice(0, 7) : "unknown");
|
|
409
|
+
const version = readInjected(true ? "0.9.82-rc.449" : void 0) ?? readInjected(typeof process !== "undefined" ? process.env?.ADHDEV_PKG_VERSION : void 0) ?? "unknown";
|
|
410
|
+
const builtAt = readInjected(true ? "2026-07-03T01:58:07.610Z" : void 0);
|
|
411
411
|
cached = builtAt ? { commit, commitShort, version, builtAt } : { commit, commitShort, version };
|
|
412
412
|
return cached;
|
|
413
413
|
}
|
|
@@ -484,8 +484,8 @@ function validateChangeImpactConfig(raw, source = "inline") {
|
|
|
484
484
|
}
|
|
485
485
|
return { valid: errors.length === 0, errors, config: errors.length === 0 ? config : void 0 };
|
|
486
486
|
}
|
|
487
|
-
function parseConfigText(
|
|
488
|
-
if (/\.json$/i.test(
|
|
487
|
+
function parseConfigText(path44, text) {
|
|
488
|
+
if (/\.json$/i.test(path44)) return JSON.parse(text);
|
|
489
489
|
return yaml.load(text);
|
|
490
490
|
}
|
|
491
491
|
function loadChangeImpactConfig(repoRoot) {
|
|
@@ -1099,14 +1099,14 @@ async function deriveSubmoduleGitlinkStatuses(repo, options) {
|
|
|
1099
1099
|
const lastCheckedAt = Date.now();
|
|
1100
1100
|
const headOidByPath = /* @__PURE__ */ new Map();
|
|
1101
1101
|
const entries = await Promise.all(
|
|
1102
|
-
paths.filter((
|
|
1103
|
-
const repoPath = repo.repoRoot + "/" +
|
|
1104
|
-
const expected = await readGitlinkExpectedSha(repo,
|
|
1102
|
+
paths.filter((path44) => !ignoreSet.has(path44)).map(async (path44) => {
|
|
1103
|
+
const repoPath = repo.repoRoot + "/" + path44;
|
|
1104
|
+
const expected = await readGitlinkExpectedSha(repo, path44, options);
|
|
1105
1105
|
const actual = await readSubmoduleHeadSha(repo, repoPath, options);
|
|
1106
|
-
if (actual) headOidByPath.set(
|
|
1106
|
+
if (actual) headOidByPath.set(path44, actual);
|
|
1107
1107
|
const outOfSync = actual === null ? true : expected !== null && expected !== actual;
|
|
1108
1108
|
return {
|
|
1109
|
-
path:
|
|
1109
|
+
path: path44,
|
|
1110
1110
|
// Prefer the recorded gitlink SHA (matches the legacy column); fall back
|
|
1111
1111
|
// to the checked-out SHA so the field is never empty when both are known.
|
|
1112
1112
|
commit: expected ?? actual ?? "",
|
|
@@ -2551,12 +2551,12 @@ function readGitSubmodules(value, parentRepoRoot) {
|
|
|
2551
2551
|
if (!Array.isArray(value)) return void 0;
|
|
2552
2552
|
const submodules = value.map((entry) => {
|
|
2553
2553
|
const submodule = readRecord(entry);
|
|
2554
|
-
const
|
|
2554
|
+
const path44 = readString2(submodule.path);
|
|
2555
2555
|
const commit = readString2(submodule.commit);
|
|
2556
|
-
const repoPath = readString2(submodule.repoPath, submodule.repo_root) ?? joinRepoPath(parentRepoRoot,
|
|
2557
|
-
if (!
|
|
2556
|
+
const repoPath = readString2(submodule.repoPath, submodule.repo_root) ?? joinRepoPath(parentRepoRoot, path44);
|
|
2557
|
+
if (!path44 || !commit) return null;
|
|
2558
2558
|
const result = {
|
|
2559
|
-
path:
|
|
2559
|
+
path: path44,
|
|
2560
2560
|
commit,
|
|
2561
2561
|
dirty: readBoolean(submodule.dirty) ?? false,
|
|
2562
2562
|
outOfSync: readBoolean(submodule.outOfSync, submodule.out_of_sync) ?? false,
|
|
@@ -2884,10 +2884,10 @@ function getMeshConfigPath() {
|
|
|
2884
2884
|
return join5(getConfigDir(), "meshes.json");
|
|
2885
2885
|
}
|
|
2886
2886
|
function loadMeshConfig() {
|
|
2887
|
-
const
|
|
2888
|
-
if (!existsSync5(
|
|
2887
|
+
const path44 = getMeshConfigPath();
|
|
2888
|
+
if (!existsSync5(path44)) return { meshes: [] };
|
|
2889
2889
|
try {
|
|
2890
|
-
const raw = JSON.parse(readFileSync3(
|
|
2890
|
+
const raw = JSON.parse(readFileSync3(path44, "utf-8"));
|
|
2891
2891
|
if (!raw || !Array.isArray(raw.meshes)) return { meshes: [] };
|
|
2892
2892
|
const config = raw;
|
|
2893
2893
|
const migrated = migrateLoadedMeshConfig(config);
|
|
@@ -2936,16 +2936,16 @@ function normalizeCapabilityTags(value) {
|
|
|
2936
2936
|
return tags.length ? tags : void 0;
|
|
2937
2937
|
}
|
|
2938
2938
|
function saveMeshConfig(config) {
|
|
2939
|
-
const
|
|
2940
|
-
writeFileSync2(
|
|
2939
|
+
const path44 = getMeshConfigPath();
|
|
2940
|
+
writeFileSync2(path44, JSON.stringify(config, null, 2), { encoding: "utf-8", mode: 384 });
|
|
2941
2941
|
}
|
|
2942
2942
|
function normalizeRepoIdentity(remoteUrl) {
|
|
2943
2943
|
let identity = remoteUrl.trim();
|
|
2944
2944
|
if (identity.startsWith("http://") || identity.startsWith("https://")) {
|
|
2945
2945
|
try {
|
|
2946
2946
|
const url = new URL(identity);
|
|
2947
|
-
const
|
|
2948
|
-
return `${url.hostname}/${
|
|
2947
|
+
const path44 = url.pathname.replace(/^\//, "").replace(/\.git$/, "");
|
|
2948
|
+
return `${url.hostname}/${path44}`;
|
|
2949
2949
|
} catch {
|
|
2950
2950
|
}
|
|
2951
2951
|
}
|
|
@@ -4184,10 +4184,10 @@ function rotateArchiveFile(meshId, archivePath) {
|
|
|
4184
4184
|
}
|
|
4185
4185
|
}
|
|
4186
4186
|
function readArchivedCounts(meshId) {
|
|
4187
|
-
const
|
|
4188
|
-
if (!existsSync7(
|
|
4187
|
+
const path44 = getArchivedCountsPath(meshId);
|
|
4188
|
+
if (!existsSync7(path44)) return { taskCompleted: 0, taskFailed: 0, taskStalled: 0, recoveryAttempted: 0, totalArchived: 0, lastArchivedAt: "" };
|
|
4189
4189
|
try {
|
|
4190
|
-
return JSON.parse(readFileSync5(
|
|
4190
|
+
return JSON.parse(readFileSync5(path44, "utf-8"));
|
|
4191
4191
|
} catch {
|
|
4192
4192
|
return { taskCompleted: 0, taskFailed: 0, taskStalled: 0, recoveryAttempted: 0, totalArchived: 0, lastArchivedAt: "" };
|
|
4193
4193
|
}
|
|
@@ -5394,11 +5394,11 @@ function readNodeReporter(node, key2) {
|
|
|
5394
5394
|
function buildMeshNodeCapabilityTags(node, providerType) {
|
|
5395
5395
|
const provider = typeof providerType === "string" && providerType.trim() ? providerType.trim() : firstProviderPriority(node?.policy);
|
|
5396
5396
|
const worktreeBranch = typeof node?.worktreeBranch === "string" && node.worktreeBranch.trim() ? node.worktreeBranch.trim() : null;
|
|
5397
|
-
const
|
|
5397
|
+
const os31 = readNodeOverride(node, "platform") ?? readNodeReporter(node, "platform") ?? process.platform;
|
|
5398
5398
|
const arch2 = readNodeOverride(node, "arch") ?? readNodeReporter(node, "arch") ?? process.arch;
|
|
5399
5399
|
return normalizeMeshCapabilityTags([
|
|
5400
5400
|
...Array.isArray(node?.capabilities) ? node.capabilities : [],
|
|
5401
|
-
`os=${
|
|
5401
|
+
`os=${os31}`,
|
|
5402
5402
|
`arch=${arch2}`,
|
|
5403
5403
|
...provider ? [`provider=${provider}`] : [],
|
|
5404
5404
|
// Worktree nodes automatically expose a "worktree=<branch>" tag so that
|
|
@@ -6291,10 +6291,10 @@ var init_mesh_runtime_store = __esm({
|
|
|
6291
6291
|
this.migratedMeshIds.add(meshId);
|
|
6292
6292
|
const count = this.db.prepare("SELECT COUNT(*) AS count FROM mesh_queue WHERE mesh_id = ?").get(meshId);
|
|
6293
6293
|
if (count.count > 0) return;
|
|
6294
|
-
const
|
|
6295
|
-
if (!existsSync8(
|
|
6294
|
+
const path44 = legacyQueuePath(meshId);
|
|
6295
|
+
if (!existsSync8(path44)) return;
|
|
6296
6296
|
try {
|
|
6297
|
-
const entries = JSON.parse(readFileSync6(
|
|
6297
|
+
const entries = JSON.parse(readFileSync6(path44, "utf-8"));
|
|
6298
6298
|
if (!Array.isArray(entries)) return;
|
|
6299
6299
|
const insert = this.db.prepare(`
|
|
6300
6300
|
INSERT OR REPLACE INTO mesh_queue (
|
|
@@ -8122,8 +8122,8 @@ function resolveMeshCoordinatorSetup(options) {
|
|
|
8122
8122
|
}
|
|
8123
8123
|
const serverName = mcpConfig.serverName?.trim() || DEFAULT_SERVER_NAME;
|
|
8124
8124
|
if (mcpConfig.mode === "auto_import") {
|
|
8125
|
-
const
|
|
8126
|
-
if (!
|
|
8125
|
+
const path44 = mcpConfig.path?.trim();
|
|
8126
|
+
if (!path44) {
|
|
8127
8127
|
return { kind: "unsupported", reason: "Provider auto-import MCP config is missing a config path" };
|
|
8128
8128
|
}
|
|
8129
8129
|
const mcpServer = resolveAdhdevMcpServerLaunch({
|
|
@@ -8143,7 +8143,7 @@ function resolveMeshCoordinatorSetup(options) {
|
|
|
8143
8143
|
return {
|
|
8144
8144
|
kind: "auto_import",
|
|
8145
8145
|
serverName,
|
|
8146
|
-
configPath: resolveMcpConfigPath(
|
|
8146
|
+
configPath: resolveMcpConfigPath(path44, workspace),
|
|
8147
8147
|
configFormat: mcpConfig.format,
|
|
8148
8148
|
mcpServer
|
|
8149
8149
|
};
|
|
@@ -8344,8 +8344,8 @@ function stripCoordinatorWrapperFile(filePath) {
|
|
|
8344
8344
|
const remaining = (existing.slice(0, openIdx) + existing.slice(closeIdx + CLOSE.length)).replace(/^\s*\n+/, "").replace(/\n+\s*$/, "");
|
|
8345
8345
|
if (!remaining.trim()) {
|
|
8346
8346
|
try {
|
|
8347
|
-
const
|
|
8348
|
-
|
|
8347
|
+
const fs39 = __require("fs");
|
|
8348
|
+
fs39.unlinkSync(filePath);
|
|
8349
8349
|
} catch {
|
|
8350
8350
|
}
|
|
8351
8351
|
} else {
|
|
@@ -8445,10 +8445,10 @@ function getRegistryPath() {
|
|
|
8445
8445
|
return join11(getDaemonDataDir(), "mesh-coordinators.json");
|
|
8446
8446
|
}
|
|
8447
8447
|
function loadMeshCoordinatorRegistry() {
|
|
8448
|
-
const
|
|
8449
|
-
if (!existsSync10(
|
|
8448
|
+
const path44 = getRegistryPath();
|
|
8449
|
+
if (!existsSync10(path44)) return;
|
|
8450
8450
|
try {
|
|
8451
|
-
const raw = JSON.parse(readFileSync8(
|
|
8451
|
+
const raw = JSON.parse(readFileSync8(path44, "utf-8"));
|
|
8452
8452
|
if (!Array.isArray(raw)) return;
|
|
8453
8453
|
_registry.clear();
|
|
8454
8454
|
for (const entry of raw) {
|
|
@@ -8620,8 +8620,8 @@ function validateMeshRefineConfig(config, source = "inline") {
|
|
|
8620
8620
|
if (rejectedCommands.length) errors.push("one or more validation commands are invalid");
|
|
8621
8621
|
return { valid: errors.length === 0, errors, bootstrapCommands, commands, rejectedCommands, bootstrapMode, deprecationWarnings };
|
|
8622
8622
|
}
|
|
8623
|
-
function parseConfigText2(
|
|
8624
|
-
if (/\.json$/i.test(
|
|
8623
|
+
function parseConfigText2(path44, text) {
|
|
8624
|
+
if (/\.json$/i.test(path44)) return JSON.parse(text);
|
|
8625
8625
|
return yaml2.load(text);
|
|
8626
8626
|
}
|
|
8627
8627
|
function loadMeshRefineConfig(mesh, workspace) {
|
|
@@ -8951,8 +8951,8 @@ function isCleanIgnoringSubmoduleGitlinks(porcelain, submodulePaths) {
|
|
|
8951
8951
|
const lines = porcelain.split(/\r?\n/).filter((line) => line.length > 0);
|
|
8952
8952
|
for (const line of lines) {
|
|
8953
8953
|
const status = line.slice(0, 2);
|
|
8954
|
-
const
|
|
8955
|
-
const isGitlinkPointerMove = (status === " M" || status === "M ") && submodulePaths.has(
|
|
8954
|
+
const path44 = line.slice(3).trim().replace(/\\/g, "/").replace(/\/+$/, "");
|
|
8955
|
+
const isGitlinkPointerMove = (status === " M" || status === "M ") && submodulePaths.has(path44);
|
|
8956
8956
|
if (!isGitlinkPointerMove) return false;
|
|
8957
8957
|
}
|
|
8958
8958
|
return true;
|
|
@@ -8983,8 +8983,8 @@ function isWorktreeBootstrapStaleRunning(node, nowMs = Date.now()) {
|
|
|
8983
8983
|
return false;
|
|
8984
8984
|
}
|
|
8985
8985
|
}
|
|
8986
|
-
function parseConfigText3(
|
|
8987
|
-
if (/\.json$/i.test(
|
|
8986
|
+
function parseConfigText3(path44, text) {
|
|
8987
|
+
if (/\.json$/i.test(path44)) return JSON.parse(text);
|
|
8988
8988
|
return yaml3.load(text);
|
|
8989
8989
|
}
|
|
8990
8990
|
function truncateOutput(value) {
|
|
@@ -9129,16 +9129,16 @@ async function runMeshWorktreeBootstrap(mesh, workspace) {
|
|
|
9129
9129
|
const startedAt = Date.now();
|
|
9130
9130
|
state.lastCommand = command.displayCommand;
|
|
9131
9131
|
const resolvedCommand = resolveWin32Executable(command.command);
|
|
9132
|
-
const
|
|
9132
|
+
const spawn5 = buildWin32ExecFileSpawn(resolvedCommand, command.args);
|
|
9133
9133
|
try {
|
|
9134
|
-
const result = await execFileAsync4(
|
|
9134
|
+
const result = await execFileAsync4(spawn5.file, spawn5.args, {
|
|
9135
9135
|
cwd,
|
|
9136
9136
|
encoding: "utf8",
|
|
9137
9137
|
timeout: command.timeoutMs || DEFAULT_TIMEOUT_MS2,
|
|
9138
9138
|
maxBuffer: command.outputLimitBytes || DEFAULT_OUTPUT_LIMIT_BYTES,
|
|
9139
9139
|
env: { ...process.env, CI: process.env.CI || "1", ...command.env || {} },
|
|
9140
9140
|
windowsHide: true,
|
|
9141
|
-
...
|
|
9141
|
+
...spawn5.windowsVerbatimArguments ? { windowsVerbatimArguments: true } : {}
|
|
9142
9142
|
});
|
|
9143
9143
|
state.commandsRun?.push({
|
|
9144
9144
|
command: command.command,
|
|
@@ -9258,8 +9258,8 @@ import * as yaml4 from "js-yaml";
|
|
|
9258
9258
|
function isRecord3(value) {
|
|
9259
9259
|
return !!value && typeof value === "object" && !Array.isArray(value);
|
|
9260
9260
|
}
|
|
9261
|
-
function parseConfigText4(
|
|
9262
|
-
if (/\.json$/i.test(
|
|
9261
|
+
function parseConfigText4(path44, text) {
|
|
9262
|
+
if (/\.json$/i.test(path44)) return JSON.parse(text);
|
|
9263
9263
|
return yaml4.load(text);
|
|
9264
9264
|
}
|
|
9265
9265
|
function normalizeOperatingNote(value) {
|
|
@@ -11065,10 +11065,10 @@ function readPendingMeshCoordinatorEventsFromDisk(meshId, coordinatorDaemonId) {
|
|
|
11065
11065
|
const primaryDaemonId = daemonIds[0];
|
|
11066
11066
|
const paths = primaryDaemonId ? [getPendingEventsPath(meshId, primaryDaemonId), getPendingEventsPath(meshId)] : [getPendingEventsPath(meshId)];
|
|
11067
11067
|
const events = [];
|
|
11068
|
-
for (const
|
|
11069
|
-
if (!existsSync15(
|
|
11068
|
+
for (const path44 of paths) {
|
|
11069
|
+
if (!existsSync15(path44)) continue;
|
|
11070
11070
|
try {
|
|
11071
|
-
const raw = readFileSync12(
|
|
11071
|
+
const raw = readFileSync12(path44, "utf-8");
|
|
11072
11072
|
const parsed = raw.split("\n").filter(Boolean).flatMap((line) => {
|
|
11073
11073
|
try {
|
|
11074
11074
|
return [JSON.parse(line)];
|
|
@@ -11076,7 +11076,7 @@ function readPendingMeshCoordinatorEventsFromDisk(meshId, coordinatorDaemonId) {
|
|
|
11076
11076
|
return [];
|
|
11077
11077
|
}
|
|
11078
11078
|
});
|
|
11079
|
-
const filtered = primaryDaemonId &&
|
|
11079
|
+
const filtered = primaryDaemonId && path44 === getPendingEventsPath(meshId) ? parsed.filter((e) => !e.targetCoordinatorDaemonId || daemonIds.includes(e.targetCoordinatorDaemonId)) : parsed;
|
|
11080
11080
|
events.push(...filtered);
|
|
11081
11081
|
} catch {
|
|
11082
11082
|
}
|
|
@@ -11141,11 +11141,11 @@ function reconcilePendingMeshCoordinatorEvents(meshId, events) {
|
|
|
11141
11141
|
const reconciled = terminalJobIds.size === 0 ? events : events.filter((event) => !(event.event === "refine:accepted" && terminalJobIds.has(readRefineJobId2(event))));
|
|
11142
11142
|
return backfilled.length === 0 ? reconciled : [...reconciled, ...backfilled];
|
|
11143
11143
|
}
|
|
11144
|
-
function trimPendingEventsIfNeeded(
|
|
11144
|
+
function trimPendingEventsIfNeeded(path44) {
|
|
11145
11145
|
try {
|
|
11146
|
-
if (!existsSync15(
|
|
11147
|
-
if (statSync6(
|
|
11148
|
-
const lines = readFileSync12(
|
|
11146
|
+
if (!existsSync15(path44)) return;
|
|
11147
|
+
if (statSync6(path44).size <= MAX_PENDING_EVENTS_BYTES) return;
|
|
11148
|
+
const lines = readFileSync12(path44, "utf-8").split("\n").filter(Boolean);
|
|
11149
11149
|
if (lines.length <= MAX_PENDING_EVENTS_KEEP) return;
|
|
11150
11150
|
const dropped = lines.slice(0, lines.length - MAX_PENDING_EVENTS_KEEP);
|
|
11151
11151
|
for (const line of dropped) {
|
|
@@ -11178,7 +11178,7 @@ function trimPendingEventsIfNeeded(path43) {
|
|
|
11178
11178
|
LOG.warn("MeshEvents", `Failed to ledger-record trim-dropped ${event.event} for mesh ${event.meshId}: ${e?.message || e}`);
|
|
11179
11179
|
}
|
|
11180
11180
|
}
|
|
11181
|
-
writeFileSync6(
|
|
11181
|
+
writeFileSync6(path44, lines.slice(-MAX_PENDING_EVENTS_KEEP).join("\n") + "\n", "utf-8");
|
|
11182
11182
|
} catch {
|
|
11183
11183
|
}
|
|
11184
11184
|
}
|
|
@@ -11208,9 +11208,9 @@ function queuePendingMeshCoordinatorEvent(event) {
|
|
|
11208
11208
|
} catch {
|
|
11209
11209
|
}
|
|
11210
11210
|
try {
|
|
11211
|
-
const
|
|
11212
|
-
trimPendingEventsIfNeeded(
|
|
11213
|
-
appendFileSync2(
|
|
11211
|
+
const path44 = getPendingEventsPath(event.meshId, event.targetCoordinatorDaemonId);
|
|
11212
|
+
trimPendingEventsIfNeeded(path44);
|
|
11213
|
+
appendFileSync2(path44, JSON.stringify(event) + "\n", "utf-8");
|
|
11214
11214
|
} catch (e) {
|
|
11215
11215
|
if (!sqliteOk) throw e;
|
|
11216
11216
|
LOG.warn("MeshEvents", `JSONL append failed for mesh ${event.meshId}; SQLite holds the event: ${e?.message || e}`);
|
|
@@ -11221,10 +11221,10 @@ function queuePendingMeshCoordinatorEvent(event) {
|
|
|
11221
11221
|
return false;
|
|
11222
11222
|
}
|
|
11223
11223
|
}
|
|
11224
|
-
function atomicDrainFile(
|
|
11225
|
-
const tmpPath = `${
|
|
11224
|
+
function atomicDrainFile(path44) {
|
|
11225
|
+
const tmpPath = `${path44}.draining`;
|
|
11226
11226
|
try {
|
|
11227
|
-
renameSync4(
|
|
11227
|
+
renameSync4(path44, tmpPath);
|
|
11228
11228
|
} catch {
|
|
11229
11229
|
return null;
|
|
11230
11230
|
}
|
|
@@ -11243,10 +11243,10 @@ function atomicDrainFile(path43) {
|
|
|
11243
11243
|
return null;
|
|
11244
11244
|
}
|
|
11245
11245
|
}
|
|
11246
|
-
function selectiveDrainFile(
|
|
11247
|
-
const tmpPath = `${
|
|
11246
|
+
function selectiveDrainFile(path44, predicate) {
|
|
11247
|
+
const tmpPath = `${path44}.draining`;
|
|
11248
11248
|
try {
|
|
11249
|
-
renameSync4(
|
|
11249
|
+
renameSync4(path44, tmpPath);
|
|
11250
11250
|
} catch {
|
|
11251
11251
|
return [];
|
|
11252
11252
|
}
|
|
@@ -11278,12 +11278,12 @@ function selectiveDrainFile(path43, predicate) {
|
|
|
11278
11278
|
}
|
|
11279
11279
|
try {
|
|
11280
11280
|
if (keptLines.length > 0) {
|
|
11281
|
-
writeFileSync6(
|
|
11281
|
+
writeFileSync6(path44, keptLines.join("\n") + "\n", "utf-8");
|
|
11282
11282
|
}
|
|
11283
11283
|
unlinkSync2(tmpPath);
|
|
11284
11284
|
} catch {
|
|
11285
11285
|
try {
|
|
11286
|
-
if (existsSync15(tmpPath) && !existsSync15(
|
|
11286
|
+
if (existsSync15(tmpPath) && !existsSync15(path44)) renameSync4(tmpPath, path44);
|
|
11287
11287
|
} catch {
|
|
11288
11288
|
}
|
|
11289
11289
|
return [];
|
|
@@ -11318,16 +11318,16 @@ function drainPendingMeshCoordinatorEvents(meshId, coordinatorDaemonId, opts) {
|
|
|
11318
11318
|
LOG.warn("MeshEvents", `SQLite pending-event drain failed for mesh ${meshId}; JSONL fallback only: ${e?.message || e}`);
|
|
11319
11319
|
}
|
|
11320
11320
|
const paths = primaryDaemonId ? [getPendingEventsPath(meshId, primaryDaemonId), getPendingEventsPath(meshId)] : [getPendingEventsPath(meshId)];
|
|
11321
|
-
for (const
|
|
11322
|
-
const isSharedFile = !!primaryDaemonId &&
|
|
11321
|
+
for (const path44 of paths) {
|
|
11322
|
+
const isSharedFile = !!primaryDaemonId && path44 === getPendingEventsPath(meshId);
|
|
11323
11323
|
const targets = (e) => !isSharedFile || !e.targetCoordinatorDaemonId || daemonIds.includes(e.targetCoordinatorDaemonId);
|
|
11324
11324
|
if (onlyEvents) {
|
|
11325
|
-
for (const event of selectiveDrainFile(
|
|
11325
|
+
for (const event of selectiveDrainFile(path44, (e) => targets(e) && matchesFilter(e.event))) {
|
|
11326
11326
|
pushUnique(event);
|
|
11327
11327
|
}
|
|
11328
11328
|
continue;
|
|
11329
11329
|
}
|
|
11330
|
-
const content = atomicDrainFile(
|
|
11330
|
+
const content = atomicDrainFile(path44);
|
|
11331
11331
|
if (!content) continue;
|
|
11332
11332
|
const parsed = content.split("\n").filter(Boolean).flatMap((line) => {
|
|
11333
11333
|
try {
|
|
@@ -11363,9 +11363,9 @@ function retractPendingDispatchBlockedEvent(meshId, taskId, coordinatorDaemonId)
|
|
|
11363
11363
|
const daemonIds = normalizeCoordinatorDaemonIds(coordinatorDaemonId);
|
|
11364
11364
|
const primaryDaemonId = daemonIds[0];
|
|
11365
11365
|
const paths = primaryDaemonId ? [getPendingEventsPath(meshId, primaryDaemonId), getPendingEventsPath(meshId)] : [getPendingEventsPath(meshId)];
|
|
11366
|
-
for (const
|
|
11366
|
+
for (const path44 of paths) {
|
|
11367
11367
|
try {
|
|
11368
|
-
removed += selectiveDrainFile(
|
|
11368
|
+
removed += selectiveDrainFile(path44, matchesTask).length;
|
|
11369
11369
|
} catch {
|
|
11370
11370
|
}
|
|
11371
11371
|
}
|
|
@@ -11406,9 +11406,9 @@ function clearPendingMeshCoordinatorEvents(meshId, coordinatorDaemonId) {
|
|
|
11406
11406
|
} catch {
|
|
11407
11407
|
}
|
|
11408
11408
|
const paths = coordinatorDaemonId ? [getPendingEventsPath(meshId, coordinatorDaemonId), getPendingEventsPath(meshId)] : [getPendingEventsPath(meshId)];
|
|
11409
|
-
for (const
|
|
11410
|
-
if (existsSync15(
|
|
11411
|
-
unlinkSync2(
|
|
11409
|
+
for (const path44 of paths) {
|
|
11410
|
+
if (existsSync15(path44)) try {
|
|
11411
|
+
unlinkSync2(path44);
|
|
11412
11412
|
} catch {
|
|
11413
11413
|
}
|
|
11414
11414
|
}
|
|
@@ -11882,9 +11882,9 @@ function findBinary(name) {
|
|
|
11882
11882
|
for (const ext of exes) {
|
|
11883
11883
|
const fullPath = path11.join(p, trimmed + ext);
|
|
11884
11884
|
try {
|
|
11885
|
-
const
|
|
11886
|
-
if (
|
|
11887
|
-
const stat2 =
|
|
11885
|
+
const fs39 = __require("fs");
|
|
11886
|
+
if (fs39.existsSync(fullPath)) {
|
|
11887
|
+
const stat2 = fs39.statSync(fullPath);
|
|
11888
11888
|
if (stat2.isFile() && (isWin || stat2.mode & 73)) {
|
|
11889
11889
|
return fullPath;
|
|
11890
11890
|
}
|
|
@@ -11898,12 +11898,12 @@ function findBinary(name) {
|
|
|
11898
11898
|
function isScriptBinary(binaryPath) {
|
|
11899
11899
|
if (!path11.isAbsolute(binaryPath)) return false;
|
|
11900
11900
|
try {
|
|
11901
|
-
const
|
|
11902
|
-
const resolved =
|
|
11901
|
+
const fs39 = __require("fs");
|
|
11902
|
+
const resolved = fs39.realpathSync(binaryPath);
|
|
11903
11903
|
const head = Buffer.alloc(8);
|
|
11904
|
-
const fd =
|
|
11905
|
-
|
|
11906
|
-
|
|
11904
|
+
const fd = fs39.openSync(resolved, "r");
|
|
11905
|
+
fs39.readSync(fd, head, 0, 8, 0);
|
|
11906
|
+
fs39.closeSync(fd);
|
|
11907
11907
|
let i = 0;
|
|
11908
11908
|
if (head[0] === 239 && head[1] === 187 && head[2] === 191) i = 3;
|
|
11909
11909
|
return head[i] === 35 && head[i + 1] === 33;
|
|
@@ -11914,12 +11914,12 @@ function isScriptBinary(binaryPath) {
|
|
|
11914
11914
|
function looksLikeMachOOrElf(filePath) {
|
|
11915
11915
|
if (!path11.isAbsolute(filePath)) return false;
|
|
11916
11916
|
try {
|
|
11917
|
-
const
|
|
11918
|
-
const resolved =
|
|
11917
|
+
const fs39 = __require("fs");
|
|
11918
|
+
const resolved = fs39.realpathSync(filePath);
|
|
11919
11919
|
const buf = Buffer.alloc(8);
|
|
11920
|
-
const fd =
|
|
11921
|
-
|
|
11922
|
-
|
|
11920
|
+
const fd = fs39.openSync(resolved, "r");
|
|
11921
|
+
fs39.readSync(fd, buf, 0, 8, 0);
|
|
11922
|
+
fs39.closeSync(fd);
|
|
11923
11923
|
let i = 0;
|
|
11924
11924
|
if (buf[0] === 239 && buf[1] === 187 && buf[2] === 191) i = 3;
|
|
11925
11925
|
const b = buf.subarray(i);
|
|
@@ -12208,19 +12208,19 @@ async function resolveDetectionPath(command, whichCmd) {
|
|
|
12208
12208
|
return null;
|
|
12209
12209
|
}
|
|
12210
12210
|
function execAsync(cmd, timeoutMs = 5e3) {
|
|
12211
|
-
return new Promise((
|
|
12211
|
+
return new Promise((resolve25) => {
|
|
12212
12212
|
const child = exec(cmd, {
|
|
12213
12213
|
encoding: "utf-8",
|
|
12214
12214
|
timeout: timeoutMs,
|
|
12215
12215
|
...process.platform === "win32" ? { windowsHide: true } : {}
|
|
12216
12216
|
}, (err, stdout) => {
|
|
12217
12217
|
if (err || !stdout?.trim()) {
|
|
12218
|
-
|
|
12218
|
+
resolve25(null);
|
|
12219
12219
|
} else {
|
|
12220
|
-
|
|
12220
|
+
resolve25(stdout.trim());
|
|
12221
12221
|
}
|
|
12222
12222
|
});
|
|
12223
|
-
child.on("error", () =>
|
|
12223
|
+
child.on("error", () => resolve25(null));
|
|
12224
12224
|
});
|
|
12225
12225
|
}
|
|
12226
12226
|
async function detectCLIs(providerLoader, options) {
|
|
@@ -12341,7 +12341,7 @@ var init_mesh_event_trace = __esm({
|
|
|
12341
12341
|
// src/mesh/mesh-warmup-deadline.ts
|
|
12342
12342
|
function awaitWithWarmupDeadline(work, opts) {
|
|
12343
12343
|
const pollMs = Math.max(1, Math.min(opts.pollIntervalMs ?? 200, opts.connectTimeoutMs));
|
|
12344
|
-
return new Promise((
|
|
12344
|
+
return new Promise((resolve25, reject) => {
|
|
12345
12345
|
let done = false;
|
|
12346
12346
|
let poll;
|
|
12347
12347
|
let responseTimer;
|
|
@@ -12391,7 +12391,7 @@ function awaitWithWarmupDeadline(work, opts) {
|
|
|
12391
12391
|
if (typeof poll.unref === "function") poll.unref();
|
|
12392
12392
|
}
|
|
12393
12393
|
work.then(
|
|
12394
|
-
(val) => settle(() =>
|
|
12394
|
+
(val) => settle(() => resolve25(val)),
|
|
12395
12395
|
(err) => settle(() => reject(err))
|
|
12396
12396
|
);
|
|
12397
12397
|
});
|
|
@@ -12495,7 +12495,7 @@ async function waitForLocalSessionReady(components, sessionId) {
|
|
|
12495
12495
|
const deadline = Date.now() + LOCAL_LAUNCH_READY_TIMEOUT_MS;
|
|
12496
12496
|
while (Date.now() < deadline) {
|
|
12497
12497
|
if (adapter.isReady() || adapter.currentStatus === "idle") return;
|
|
12498
|
-
await new Promise((
|
|
12498
|
+
await new Promise((resolve25) => setTimeout(resolve25, LOCAL_LAUNCH_READY_POLL_MS));
|
|
12499
12499
|
}
|
|
12500
12500
|
LOG.warn("MeshQueue", `Auto-launched session ${sessionId} not interactive after ${LOCAL_LAUNCH_READY_TIMEOUT_MS}ms; dispatching anyway (adapter queue-until-ready will buffer)`);
|
|
12501
12501
|
}
|
|
@@ -18927,7 +18927,7 @@ function getCliValidator() {
|
|
|
18927
18927
|
return _cliValidator;
|
|
18928
18928
|
}
|
|
18929
18929
|
function formatIssue(err) {
|
|
18930
|
-
const
|
|
18930
|
+
const path44 = err.instancePath || "";
|
|
18931
18931
|
const params = err.params;
|
|
18932
18932
|
let message = err.message || "validation failed";
|
|
18933
18933
|
let allowed;
|
|
@@ -18945,7 +18945,7 @@ function formatIssue(err) {
|
|
|
18945
18945
|
} else if (err.keyword === "type") {
|
|
18946
18946
|
message = `must be ${params.type}`;
|
|
18947
18947
|
}
|
|
18948
|
-
return { path:
|
|
18948
|
+
return { path: path44, keyword: err.keyword, message, ...allowed !== void 0 ? { allowed } : {} };
|
|
18949
18949
|
}
|
|
18950
18950
|
function validateCliProviderManifest(manifest) {
|
|
18951
18951
|
const validator = getCliValidator();
|
|
@@ -19240,40 +19240,40 @@ function validateFsmSpec(raw) {
|
|
|
19240
19240
|
}
|
|
19241
19241
|
return errs;
|
|
19242
19242
|
}
|
|
19243
|
-
function validateCondition(c, sectionIds,
|
|
19243
|
+
function validateCondition(c, sectionIds, path44) {
|
|
19244
19244
|
const errs = [];
|
|
19245
19245
|
const w = c;
|
|
19246
19246
|
if ("all" in w) {
|
|
19247
|
-
w.all.forEach((x, i) => errs.push(...validateCondition(x, sectionIds, `${
|
|
19247
|
+
w.all.forEach((x, i) => errs.push(...validateCondition(x, sectionIds, `${path44}.all[${i}]`)));
|
|
19248
19248
|
return errs;
|
|
19249
19249
|
}
|
|
19250
19250
|
if ("any" in w) {
|
|
19251
|
-
w.any.forEach((x, i) => errs.push(...validateCondition(x, sectionIds, `${
|
|
19251
|
+
w.any.forEach((x, i) => errs.push(...validateCondition(x, sectionIds, `${path44}.any[${i}]`)));
|
|
19252
19252
|
return errs;
|
|
19253
19253
|
}
|
|
19254
19254
|
if ("not" in w) {
|
|
19255
|
-
errs.push(...validateCondition(w.not, sectionIds, `${
|
|
19255
|
+
errs.push(...validateCondition(w.not, sectionIds, `${path44}.not`));
|
|
19256
19256
|
return errs;
|
|
19257
19257
|
}
|
|
19258
19258
|
if ("matches" in w) {
|
|
19259
|
-
if (w.section && !sectionIds.has(w.section)) errs.push(`${
|
|
19259
|
+
if (w.section && !sectionIds.has(w.section)) errs.push(`${path44}.section "${w.section}" unknown`);
|
|
19260
19260
|
try {
|
|
19261
19261
|
new RegExp(w.matches, w.flags ?? "i");
|
|
19262
19262
|
} catch (e) {
|
|
19263
|
-
errs.push(`${
|
|
19263
|
+
errs.push(`${path44}.matches invalid regex: ${e.message}`);
|
|
19264
19264
|
}
|
|
19265
19265
|
return errs;
|
|
19266
19266
|
}
|
|
19267
19267
|
if ("cursor_above" in w && "changed" in w) return errs;
|
|
19268
19268
|
if ("elapsed_ms" in w) {
|
|
19269
|
-
if (typeof w.elapsed_ms !== "number") errs.push(`${
|
|
19269
|
+
if (typeof w.elapsed_ms !== "number") errs.push(`${path44}.elapsed_ms must be a number`);
|
|
19270
19270
|
return errs;
|
|
19271
19271
|
}
|
|
19272
19272
|
if ("stable_ms" in w) {
|
|
19273
|
-
if (typeof w.stable_ms !== "number") errs.push(`${
|
|
19273
|
+
if (typeof w.stable_ms !== "number") errs.push(`${path44}.stable_ms must be a number`);
|
|
19274
19274
|
return errs;
|
|
19275
19275
|
}
|
|
19276
|
-
errs.push(`${
|
|
19276
|
+
errs.push(`${path44} is not a recognized condition`);
|
|
19277
19277
|
return errs;
|
|
19278
19278
|
}
|
|
19279
19279
|
var init_fsm_loader = __esm({
|
|
@@ -19766,8 +19766,8 @@ var init_pty_transport = __esm({
|
|
|
19766
19766
|
let cwd = options.cwd;
|
|
19767
19767
|
if (cwd) {
|
|
19768
19768
|
try {
|
|
19769
|
-
const
|
|
19770
|
-
const stat2 =
|
|
19769
|
+
const fs39 = __require("fs");
|
|
19770
|
+
const stat2 = fs39.statSync(cwd);
|
|
19771
19771
|
if (!stat2.isDirectory()) cwd = os14.homedir();
|
|
19772
19772
|
} catch {
|
|
19773
19773
|
cwd = os14.homedir();
|
|
@@ -22314,7 +22314,7 @@ ${lastSnapshot}`;
|
|
|
22314
22314
|
`[${this.cliType}] Waiting for interactive prompt: status=${status} stableMs=${stableMs} recentOutputMs=${recentlyOutput} screen=${JSON.stringify(summarizeCliTraceText(screenText, 220)).slice(0, 260)}`
|
|
22315
22315
|
);
|
|
22316
22316
|
}
|
|
22317
|
-
await new Promise((
|
|
22317
|
+
await new Promise((resolve25) => setTimeout(resolve25, 50));
|
|
22318
22318
|
}
|
|
22319
22319
|
const finalScreenText = this.terminalScreen.getText() || "";
|
|
22320
22320
|
LOG.warn(
|
|
@@ -22609,7 +22609,7 @@ ${lastSnapshot}`;
|
|
|
22609
22609
|
if (!this.ptyProcess) throw new Error(`${this.cliName} is not running`);
|
|
22610
22610
|
await this.ptyProcess.write(chunks[i]);
|
|
22611
22611
|
if (i + 1 < chunks.length) {
|
|
22612
|
-
await new Promise((
|
|
22612
|
+
await new Promise((resolve25) => setTimeout(resolve25, WIN32_PTY_WRITE_CHUNK_GAP_MS));
|
|
22613
22613
|
}
|
|
22614
22614
|
}
|
|
22615
22615
|
}
|
|
@@ -22777,7 +22777,7 @@ ${lastSnapshot}`;
|
|
|
22777
22777
|
this.onStatusChange?.();
|
|
22778
22778
|
}
|
|
22779
22779
|
async waitForForceSubmitSettle() {
|
|
22780
|
-
await new Promise((
|
|
22780
|
+
await new Promise((resolve25) => setTimeout(resolve25, FORCE_SUBMIT_SETTLE_MS));
|
|
22781
22781
|
}
|
|
22782
22782
|
enqueuePendingOutboundMessage(text, reason, meshTaskId) {
|
|
22783
22783
|
const content = String(text || "");
|
|
@@ -22856,7 +22856,7 @@ ${lastSnapshot}`;
|
|
|
22856
22856
|
const deadline = Date.now() + 1e4;
|
|
22857
22857
|
while (this.startupParseGate && Date.now() < deadline) {
|
|
22858
22858
|
this.resolveStartupState("send_wait");
|
|
22859
|
-
await new Promise((
|
|
22859
|
+
await new Promise((resolve25) => setTimeout(resolve25, 50));
|
|
22860
22860
|
}
|
|
22861
22861
|
}
|
|
22862
22862
|
const parsedStatusBeforeSend = !allowInputDuringGeneration ? (() => {
|
|
@@ -22949,13 +22949,13 @@ ${lastSnapshot}`;
|
|
|
22949
22949
|
isFirstTurn: !this.firstTurnSent
|
|
22950
22950
|
};
|
|
22951
22951
|
this.engine.responseSettleIgnoreUntil = Date.now() + submitDelayMs + this.timeouts.outputSettle + 250;
|
|
22952
|
-
await new Promise((
|
|
22952
|
+
await new Promise((resolve25, reject) => {
|
|
22953
22953
|
let resolved = false;
|
|
22954
22954
|
const completion = {
|
|
22955
22955
|
resolveOnce: () => {
|
|
22956
22956
|
if (resolved) return;
|
|
22957
22957
|
resolved = true;
|
|
22958
|
-
|
|
22958
|
+
resolve25();
|
|
22959
22959
|
},
|
|
22960
22960
|
rejectOnce: (error) => {
|
|
22961
22961
|
if (resolved) return;
|
|
@@ -23143,17 +23143,17 @@ ${lastSnapshot}`;
|
|
|
23143
23143
|
}
|
|
23144
23144
|
}
|
|
23145
23145
|
waitForStopped(timeoutMs) {
|
|
23146
|
-
return new Promise((
|
|
23146
|
+
return new Promise((resolve25) => {
|
|
23147
23147
|
const startedAt = Date.now();
|
|
23148
23148
|
const timer = setInterval(() => {
|
|
23149
23149
|
if (!this.ptyProcess || this.engine.currentStatus === "stopped") {
|
|
23150
23150
|
clearInterval(timer);
|
|
23151
|
-
|
|
23151
|
+
resolve25(true);
|
|
23152
23152
|
return;
|
|
23153
23153
|
}
|
|
23154
23154
|
if (Date.now() - startedAt >= timeoutMs) {
|
|
23155
23155
|
clearInterval(timer);
|
|
23156
|
-
|
|
23156
|
+
resolve25(false);
|
|
23157
23157
|
}
|
|
23158
23158
|
}, 100);
|
|
23159
23159
|
});
|
|
@@ -25456,17 +25456,17 @@ function checkPathExists(paths) {
|
|
|
25456
25456
|
return null;
|
|
25457
25457
|
}
|
|
25458
25458
|
async function detectIDEs(providerLoader) {
|
|
25459
|
-
const
|
|
25459
|
+
const os31 = platform5();
|
|
25460
25460
|
const results = [];
|
|
25461
25461
|
for (const def of getMergedDefinitions()) {
|
|
25462
25462
|
const cliPath = findCliCommand(providerLoader?.getIdeCliCommand(def.id, def.cli) || def.cli);
|
|
25463
|
-
const appPath = checkPathExists(providerLoader?.getIdePathCandidates(def.id, def.paths[
|
|
25463
|
+
const appPath = checkPathExists(providerLoader?.getIdePathCandidates(def.id, def.paths[os31] || []) || []);
|
|
25464
25464
|
let resolvedCli = cliPath;
|
|
25465
|
-
if (!resolvedCli && appPath &&
|
|
25465
|
+
if (!resolvedCli && appPath && os31 === "darwin") {
|
|
25466
25466
|
const bundledCli = `${appPath}/Contents/Resources/app/bin/${def.cli}`;
|
|
25467
25467
|
if (existsSync20(bundledCli)) resolvedCli = bundledCli;
|
|
25468
25468
|
}
|
|
25469
|
-
if (!resolvedCli && appPath &&
|
|
25469
|
+
if (!resolvedCli && appPath && os31 === "win32") {
|
|
25470
25470
|
const { dirname: dirname17 } = await import("path");
|
|
25471
25471
|
const appDir = dirname17(appPath);
|
|
25472
25472
|
const candidates = [
|
|
@@ -25483,7 +25483,7 @@ async function detectIDEs(providerLoader) {
|
|
|
25483
25483
|
}
|
|
25484
25484
|
}
|
|
25485
25485
|
}
|
|
25486
|
-
const installed =
|
|
25486
|
+
const installed = os31 === "darwin" ? !!(resolvedCli || appPath) : !!resolvedCli;
|
|
25487
25487
|
const version = null;
|
|
25488
25488
|
results.push({
|
|
25489
25489
|
id: def.id,
|
|
@@ -25742,7 +25742,7 @@ var DaemonCdpManager = class {
|
|
|
25742
25742
|
* Returns multiple entries if multiple IDE windows are open on same port
|
|
25743
25743
|
*/
|
|
25744
25744
|
static listAllTargets(port) {
|
|
25745
|
-
return new Promise((
|
|
25745
|
+
return new Promise((resolve25) => {
|
|
25746
25746
|
const req = http.get(`http://127.0.0.1:${port}/json`, (res) => {
|
|
25747
25747
|
let data = "";
|
|
25748
25748
|
res.on("data", (chunk) => data += chunk.toString());
|
|
@@ -25758,16 +25758,16 @@ var DaemonCdpManager = class {
|
|
|
25758
25758
|
(t) => !isNonMain(t.title || "") && t.url?.includes("workbench.html") && !t.url?.includes("agent")
|
|
25759
25759
|
);
|
|
25760
25760
|
const fallbackPages = pages.filter((t) => !isNonMain(t.title || ""));
|
|
25761
|
-
|
|
25761
|
+
resolve25(mainPages.length > 0 ? mainPages : fallbackPages);
|
|
25762
25762
|
} catch {
|
|
25763
|
-
|
|
25763
|
+
resolve25([]);
|
|
25764
25764
|
}
|
|
25765
25765
|
});
|
|
25766
25766
|
});
|
|
25767
|
-
req.on("error", () =>
|
|
25767
|
+
req.on("error", () => resolve25([]));
|
|
25768
25768
|
req.setTimeout(2e3, () => {
|
|
25769
25769
|
req.destroy();
|
|
25770
|
-
|
|
25770
|
+
resolve25([]);
|
|
25771
25771
|
});
|
|
25772
25772
|
});
|
|
25773
25773
|
}
|
|
@@ -25807,7 +25807,7 @@ var DaemonCdpManager = class {
|
|
|
25807
25807
|
}
|
|
25808
25808
|
}
|
|
25809
25809
|
findTargetOnPort(port) {
|
|
25810
|
-
return new Promise((
|
|
25810
|
+
return new Promise((resolve25) => {
|
|
25811
25811
|
const req = http.get(`http://127.0.0.1:${port}/json`, (res) => {
|
|
25812
25812
|
let data = "";
|
|
25813
25813
|
res.on("data", (chunk) => data += chunk.toString());
|
|
@@ -25818,7 +25818,7 @@ var DaemonCdpManager = class {
|
|
|
25818
25818
|
(t) => (t.type === "page" || t.type === "browser" || t.type === "Page") && t.webSocketDebuggerUrl
|
|
25819
25819
|
);
|
|
25820
25820
|
if (pages.length === 0) {
|
|
25821
|
-
|
|
25821
|
+
resolve25(targets.find((t) => t.webSocketDebuggerUrl) || null);
|
|
25822
25822
|
return;
|
|
25823
25823
|
}
|
|
25824
25824
|
const titleFilteredPages = pages.filter((t) => !this.isNonMainTitle(t.title || ""));
|
|
@@ -25837,25 +25837,25 @@ var DaemonCdpManager = class {
|
|
|
25837
25837
|
this._targetId = selected.target.id;
|
|
25838
25838
|
}
|
|
25839
25839
|
this._pageTitle = selected.target.title || "";
|
|
25840
|
-
|
|
25840
|
+
resolve25(selected.target);
|
|
25841
25841
|
return;
|
|
25842
25842
|
}
|
|
25843
25843
|
if (previousTargetId) {
|
|
25844
25844
|
this.log(`[CDP] Target ${previousTargetId} not found in page list`);
|
|
25845
|
-
|
|
25845
|
+
resolve25(null);
|
|
25846
25846
|
return;
|
|
25847
25847
|
}
|
|
25848
25848
|
this._pageTitle = list[0]?.title || "";
|
|
25849
|
-
|
|
25849
|
+
resolve25(list[0]);
|
|
25850
25850
|
} catch {
|
|
25851
|
-
|
|
25851
|
+
resolve25(null);
|
|
25852
25852
|
}
|
|
25853
25853
|
});
|
|
25854
25854
|
});
|
|
25855
|
-
req.on("error", () =>
|
|
25855
|
+
req.on("error", () => resolve25(null));
|
|
25856
25856
|
req.setTimeout(2e3, () => {
|
|
25857
25857
|
req.destroy();
|
|
25858
|
-
|
|
25858
|
+
resolve25(null);
|
|
25859
25859
|
});
|
|
25860
25860
|
});
|
|
25861
25861
|
}
|
|
@@ -25866,7 +25866,7 @@ var DaemonCdpManager = class {
|
|
|
25866
25866
|
this.extensionProviders = providers;
|
|
25867
25867
|
}
|
|
25868
25868
|
connectToTarget(wsUrl) {
|
|
25869
|
-
return new Promise((
|
|
25869
|
+
return new Promise((resolve25) => {
|
|
25870
25870
|
this.ws = new WebSocket(wsUrl);
|
|
25871
25871
|
this.ws.on("open", async () => {
|
|
25872
25872
|
this._connected = true;
|
|
@@ -25876,17 +25876,17 @@ var DaemonCdpManager = class {
|
|
|
25876
25876
|
}
|
|
25877
25877
|
this.connectBrowserWs().catch(() => {
|
|
25878
25878
|
});
|
|
25879
|
-
|
|
25879
|
+
resolve25(true);
|
|
25880
25880
|
});
|
|
25881
25881
|
this.ws.on("message", (data) => {
|
|
25882
25882
|
try {
|
|
25883
25883
|
const msg = JSON.parse(data.toString());
|
|
25884
25884
|
if (msg.id && this.pending.has(msg.id)) {
|
|
25885
|
-
const { resolve:
|
|
25885
|
+
const { resolve: resolve26, reject } = this.pending.get(msg.id);
|
|
25886
25886
|
this.pending.delete(msg.id);
|
|
25887
25887
|
this.failureCount = 0;
|
|
25888
25888
|
if (msg.error) reject(new Error(msg.error.message));
|
|
25889
|
-
else
|
|
25889
|
+
else resolve26(msg.result);
|
|
25890
25890
|
} else if (msg.method === "Runtime.executionContextCreated") {
|
|
25891
25891
|
this.contexts.add(msg.params.context.id);
|
|
25892
25892
|
} else if (msg.method === "Runtime.executionContextDestroyed") {
|
|
@@ -25909,7 +25909,7 @@ var DaemonCdpManager = class {
|
|
|
25909
25909
|
this.ws.on("error", (err) => {
|
|
25910
25910
|
this.log(`[CDP] WebSocket error: ${err.message}`);
|
|
25911
25911
|
this._connected = false;
|
|
25912
|
-
|
|
25912
|
+
resolve25(false);
|
|
25913
25913
|
});
|
|
25914
25914
|
});
|
|
25915
25915
|
}
|
|
@@ -25923,7 +25923,7 @@ var DaemonCdpManager = class {
|
|
|
25923
25923
|
return;
|
|
25924
25924
|
}
|
|
25925
25925
|
this.log(`[CDP] Connecting browser WS for target discovery...`);
|
|
25926
|
-
await new Promise((
|
|
25926
|
+
await new Promise((resolve25, reject) => {
|
|
25927
25927
|
this.browserWs = new WebSocket(browserWsUrl);
|
|
25928
25928
|
this.browserWs.on("open", async () => {
|
|
25929
25929
|
this._browserConnected = true;
|
|
@@ -25933,16 +25933,16 @@ var DaemonCdpManager = class {
|
|
|
25933
25933
|
} catch (e) {
|
|
25934
25934
|
this.log(`[CDP] setDiscoverTargets failed: ${e.message}`);
|
|
25935
25935
|
}
|
|
25936
|
-
|
|
25936
|
+
resolve25();
|
|
25937
25937
|
});
|
|
25938
25938
|
this.browserWs.on("message", (data) => {
|
|
25939
25939
|
try {
|
|
25940
25940
|
const msg = JSON.parse(data.toString());
|
|
25941
25941
|
if (msg.id && this.browserPending.has(msg.id)) {
|
|
25942
|
-
const { resolve:
|
|
25942
|
+
const { resolve: resolve26, reject: reject2 } = this.browserPending.get(msg.id);
|
|
25943
25943
|
this.browserPending.delete(msg.id);
|
|
25944
25944
|
if (msg.error) reject2(new Error(msg.error.message));
|
|
25945
|
-
else
|
|
25945
|
+
else resolve26(msg.result);
|
|
25946
25946
|
}
|
|
25947
25947
|
} catch {
|
|
25948
25948
|
}
|
|
@@ -25962,31 +25962,31 @@ var DaemonCdpManager = class {
|
|
|
25962
25962
|
}
|
|
25963
25963
|
}
|
|
25964
25964
|
getBrowserWsUrl() {
|
|
25965
|
-
return new Promise((
|
|
25965
|
+
return new Promise((resolve25) => {
|
|
25966
25966
|
const req = http.get(`http://127.0.0.1:${this.port}/json/version`, (res) => {
|
|
25967
25967
|
let data = "";
|
|
25968
25968
|
res.on("data", (chunk) => data += chunk.toString());
|
|
25969
25969
|
res.on("end", () => {
|
|
25970
25970
|
try {
|
|
25971
25971
|
const info = JSON.parse(data);
|
|
25972
|
-
|
|
25972
|
+
resolve25(info.webSocketDebuggerUrl || null);
|
|
25973
25973
|
} catch {
|
|
25974
|
-
|
|
25974
|
+
resolve25(null);
|
|
25975
25975
|
}
|
|
25976
25976
|
});
|
|
25977
25977
|
});
|
|
25978
|
-
req.on("error", () =>
|
|
25978
|
+
req.on("error", () => resolve25(null));
|
|
25979
25979
|
req.setTimeout(3e3, () => {
|
|
25980
25980
|
req.destroy();
|
|
25981
|
-
|
|
25981
|
+
resolve25(null);
|
|
25982
25982
|
});
|
|
25983
25983
|
});
|
|
25984
25984
|
}
|
|
25985
25985
|
sendBrowser(method, params = {}, timeoutMs = 15e3) {
|
|
25986
|
-
return new Promise((
|
|
25986
|
+
return new Promise((resolve25, reject) => {
|
|
25987
25987
|
if (!this.browserWs || !this._browserConnected) return reject(new Error("Browser WS not connected"));
|
|
25988
25988
|
const id = this.browserMsgId++;
|
|
25989
|
-
this.browserPending.set(id, { resolve:
|
|
25989
|
+
this.browserPending.set(id, { resolve: resolve25, reject });
|
|
25990
25990
|
this.browserWs.send(JSON.stringify({ id, method, params }));
|
|
25991
25991
|
setTimeout(() => {
|
|
25992
25992
|
if (this.browserPending.has(id)) {
|
|
@@ -26026,11 +26026,11 @@ var DaemonCdpManager = class {
|
|
|
26026
26026
|
}
|
|
26027
26027
|
// ─── CDP Protocol ────────────────────────────────────────
|
|
26028
26028
|
sendInternal(method, params = {}, timeoutMs = 15e3) {
|
|
26029
|
-
return new Promise((
|
|
26029
|
+
return new Promise((resolve25, reject) => {
|
|
26030
26030
|
if (!this.ws || !this._connected) return reject(new Error("CDP not connected"));
|
|
26031
26031
|
if (this.ws.readyState !== WebSocket.OPEN) return reject(new Error("WebSocket not open"));
|
|
26032
26032
|
const id = this.msgId++;
|
|
26033
|
-
this.pending.set(id, { resolve:
|
|
26033
|
+
this.pending.set(id, { resolve: resolve25, reject });
|
|
26034
26034
|
this.ws.send(JSON.stringify({ id, method, params }));
|
|
26035
26035
|
setTimeout(() => {
|
|
26036
26036
|
if (this.pending.has(id)) {
|
|
@@ -26279,7 +26279,7 @@ var DaemonCdpManager = class {
|
|
|
26279
26279
|
const browserWs = this.browserWs;
|
|
26280
26280
|
let msgId = this.browserMsgId;
|
|
26281
26281
|
const sendWs = (method, params = {}, sessionId) => {
|
|
26282
|
-
return new Promise((
|
|
26282
|
+
return new Promise((resolve25, reject) => {
|
|
26283
26283
|
const mid = msgId++;
|
|
26284
26284
|
this.browserMsgId = msgId;
|
|
26285
26285
|
const handler = (raw) => {
|
|
@@ -26288,7 +26288,7 @@ var DaemonCdpManager = class {
|
|
|
26288
26288
|
if (msg.id === mid) {
|
|
26289
26289
|
browserWs.removeListener("message", handler);
|
|
26290
26290
|
if (msg.error) reject(new Error(msg.error.message || JSON.stringify(msg.error)));
|
|
26291
|
-
else
|
|
26291
|
+
else resolve25(msg.result);
|
|
26292
26292
|
}
|
|
26293
26293
|
} catch {
|
|
26294
26294
|
}
|
|
@@ -26489,14 +26489,14 @@ var DaemonCdpManager = class {
|
|
|
26489
26489
|
if (!ws || ws.readyState !== WebSocket.OPEN) {
|
|
26490
26490
|
throw new Error("CDP not connected");
|
|
26491
26491
|
}
|
|
26492
|
-
return new Promise((
|
|
26492
|
+
return new Promise((resolve25, reject) => {
|
|
26493
26493
|
const id = getNextId();
|
|
26494
26494
|
pendingMap.set(id, {
|
|
26495
26495
|
resolve: (result) => {
|
|
26496
26496
|
if (result?.result?.subtype === "error") {
|
|
26497
26497
|
reject(new Error(result.result.description));
|
|
26498
26498
|
} else {
|
|
26499
|
-
|
|
26499
|
+
resolve25(result?.result?.value);
|
|
26500
26500
|
}
|
|
26501
26501
|
},
|
|
26502
26502
|
reject
|
|
@@ -26528,10 +26528,10 @@ var DaemonCdpManager = class {
|
|
|
26528
26528
|
throw new Error("CDP not connected");
|
|
26529
26529
|
}
|
|
26530
26530
|
const sendViaSession = (method, params = {}) => {
|
|
26531
|
-
return new Promise((
|
|
26531
|
+
return new Promise((resolve25, reject) => {
|
|
26532
26532
|
const pendingMap = this._browserConnected ? this.browserPending : this.pending;
|
|
26533
26533
|
const id = this._browserConnected ? this.browserMsgId++ : this.msgId++;
|
|
26534
|
-
pendingMap.set(id, { resolve:
|
|
26534
|
+
pendingMap.set(id, { resolve: resolve25, reject });
|
|
26535
26535
|
ws.send(JSON.stringify({ id, sessionId, method, params }));
|
|
26536
26536
|
setTimeout(() => {
|
|
26537
26537
|
if (pendingMap.has(id)) {
|
|
@@ -32761,7 +32761,7 @@ function getSendChatInputEnvelope(args) {
|
|
|
32761
32761
|
return normalizeInputEnvelope(args?.input ? { input: args.input } : args);
|
|
32762
32762
|
}
|
|
32763
32763
|
function sleep(ms) {
|
|
32764
|
-
return new Promise((
|
|
32764
|
+
return new Promise((resolve25) => setTimeout(resolve25, ms));
|
|
32765
32765
|
}
|
|
32766
32766
|
async function waitOnceForFreshHermesCliStart(adapter, log) {
|
|
32767
32767
|
if (adapter.cliType !== "hermes-cli") return;
|
|
@@ -32816,7 +32816,7 @@ function getStateLastSignature(state) {
|
|
|
32816
32816
|
async function getStableExtensionBaseline(h) {
|
|
32817
32817
|
const first = await readExtensionChatState(h);
|
|
32818
32818
|
if (getStateMessageCount(first) > 0 || getStateLastSignature(first)) return first;
|
|
32819
|
-
await new Promise((
|
|
32819
|
+
await new Promise((resolve25) => setTimeout(resolve25, 150));
|
|
32820
32820
|
const second = await readExtensionChatState(h);
|
|
32821
32821
|
return getStateMessageCount(second) >= getStateMessageCount(first) ? second : first;
|
|
32822
32822
|
}
|
|
@@ -32824,7 +32824,7 @@ async function verifyExtensionSendObserved(h, before) {
|
|
|
32824
32824
|
const beforeCount = getStateMessageCount(before);
|
|
32825
32825
|
const beforeSignature = getStateLastSignature(before);
|
|
32826
32826
|
for (let attempt = 0; attempt < 12; attempt += 1) {
|
|
32827
|
-
await new Promise((
|
|
32827
|
+
await new Promise((resolve25) => setTimeout(resolve25, 250));
|
|
32828
32828
|
const state = await readExtensionChatState(h);
|
|
32829
32829
|
if (state?.status === "waiting_approval") return true;
|
|
32830
32830
|
const afterCount = getStateMessageCount(state);
|
|
@@ -34226,7 +34226,7 @@ async function executeProviderScript(h, args, scriptName) {
|
|
|
34226
34226
|
const enterCount = cliCommand.enterCount || 1;
|
|
34227
34227
|
await adapter.writeRaw(cliCommand.text + "\r");
|
|
34228
34228
|
for (let i = 1; i < enterCount; i += 1) {
|
|
34229
|
-
await new Promise((
|
|
34229
|
+
await new Promise((resolve25) => setTimeout(resolve25, 50));
|
|
34230
34230
|
await adapter.writeRaw("\r");
|
|
34231
34231
|
}
|
|
34232
34232
|
}
|
|
@@ -35003,9 +35003,9 @@ var DaemonCommandHandler = class {
|
|
|
35003
35003
|
* point at a sibling git checkout.
|
|
35004
35004
|
*/
|
|
35005
35005
|
getUpstreamInstallRoot() {
|
|
35006
|
-
const
|
|
35007
|
-
const
|
|
35008
|
-
return
|
|
35006
|
+
const os31 = __require("os");
|
|
35007
|
+
const path44 = __require("path");
|
|
35008
|
+
return path44.join(os31.homedir(), ".adhdev", "providers", ".upstream");
|
|
35009
35009
|
}
|
|
35010
35010
|
/**
|
|
35011
35011
|
* Download a single provider manifest from the registry and write it to
|
|
@@ -35029,11 +35029,11 @@ var DaemonCommandHandler = class {
|
|
|
35029
35029
|
return { success: false, error: "invalid type" };
|
|
35030
35030
|
}
|
|
35031
35031
|
const https = __require("https");
|
|
35032
|
-
const
|
|
35033
|
-
const
|
|
35032
|
+
const fs39 = __require("fs");
|
|
35033
|
+
const path44 = __require("path");
|
|
35034
35034
|
const REGISTRY = "https://api.adhf.dev/api/v1/registry";
|
|
35035
35035
|
function fetchText(url, timeoutMs) {
|
|
35036
|
-
return new Promise((
|
|
35036
|
+
return new Promise((resolve25, reject) => {
|
|
35037
35037
|
const req = https.get(url, { headers: { "User-Agent": "adhdev-daemon", "Accept": "application/json" }, timeout: timeoutMs }, (res) => {
|
|
35038
35038
|
if (res.statusCode !== 200) {
|
|
35039
35039
|
reject(new Error(`HTTP ${res.statusCode}`));
|
|
@@ -35041,7 +35041,7 @@ var DaemonCommandHandler = class {
|
|
|
35041
35041
|
}
|
|
35042
35042
|
const chunks = [];
|
|
35043
35043
|
res.on("data", (c) => chunks.push(c));
|
|
35044
|
-
res.on("end", () =>
|
|
35044
|
+
res.on("end", () => resolve25(Buffer.concat(chunks).toString("utf-8")));
|
|
35045
35045
|
});
|
|
35046
35046
|
req.on("error", reject);
|
|
35047
35047
|
req.on("timeout", () => {
|
|
@@ -35067,12 +35067,12 @@ var DaemonCommandHandler = class {
|
|
|
35067
35067
|
return { success: false, error: `checksum mismatch: expected ${meta.checksum}, got ${actualChecksum}` };
|
|
35068
35068
|
}
|
|
35069
35069
|
const installRoot = this.getUpstreamInstallRoot();
|
|
35070
|
-
const installRootResolved =
|
|
35071
|
-
const targetDir =
|
|
35072
|
-
if (!targetDir.startsWith(installRootResolved +
|
|
35070
|
+
const installRootResolved = path44.resolve(installRoot);
|
|
35071
|
+
const targetDir = path44.resolve(path44.join(installRoot, category, type));
|
|
35072
|
+
if (!targetDir.startsWith(installRootResolved + path44.sep)) {
|
|
35073
35073
|
return { success: false, error: "install path escaped upstream root" };
|
|
35074
35074
|
}
|
|
35075
|
-
|
|
35075
|
+
fs39.mkdirSync(targetDir, { recursive: true });
|
|
35076
35076
|
let manifestProbe = {};
|
|
35077
35077
|
try {
|
|
35078
35078
|
manifestProbe = JSON.parse(manifestBody);
|
|
@@ -35096,8 +35096,8 @@ ${formatManifestValidationIssues2(validation.issues)}`,
|
|
|
35096
35096
|
}
|
|
35097
35097
|
}
|
|
35098
35098
|
const targetFile = isV1 ? "provider.v1.json" : "provider.json";
|
|
35099
|
-
const targetPath =
|
|
35100
|
-
|
|
35099
|
+
const targetPath = path44.join(targetDir, targetFile);
|
|
35100
|
+
fs39.writeFileSync(targetPath, manifestBody, "utf-8");
|
|
35101
35101
|
const manifestJson = JSON.parse(manifestBody);
|
|
35102
35102
|
const scriptFetch = await this.fetchProviderSources(
|
|
35103
35103
|
manifestJson,
|
|
@@ -35167,10 +35167,10 @@ ${formatManifestValidationIssues2(validation.issues)}`,
|
|
|
35167
35167
|
const repo = source.repo;
|
|
35168
35168
|
const ref = source.ref;
|
|
35169
35169
|
const https = __require("https");
|
|
35170
|
-
const
|
|
35171
|
-
const
|
|
35170
|
+
const fs39 = __require("fs");
|
|
35171
|
+
const path44 = __require("path");
|
|
35172
35172
|
function fetchJson(url, timeoutMs) {
|
|
35173
|
-
return new Promise((
|
|
35173
|
+
return new Promise((resolve25, reject) => {
|
|
35174
35174
|
const req = https.get(url, {
|
|
35175
35175
|
headers: { "User-Agent": "adhdev-daemon", "Accept": "application/vnd.github+json" },
|
|
35176
35176
|
timeout: timeoutMs
|
|
@@ -35183,7 +35183,7 @@ ${formatManifestValidationIssues2(validation.issues)}`,
|
|
|
35183
35183
|
res.on("data", (c) => chunks.push(c));
|
|
35184
35184
|
res.on("end", () => {
|
|
35185
35185
|
try {
|
|
35186
|
-
|
|
35186
|
+
resolve25(JSON.parse(Buffer.concat(chunks).toString("utf-8")));
|
|
35187
35187
|
} catch (e) {
|
|
35188
35188
|
reject(e);
|
|
35189
35189
|
}
|
|
@@ -35197,14 +35197,14 @@ ${formatManifestValidationIssues2(validation.issues)}`,
|
|
|
35197
35197
|
});
|
|
35198
35198
|
}
|
|
35199
35199
|
function fetchBinary(url, timeoutMs) {
|
|
35200
|
-
return new Promise((
|
|
35200
|
+
return new Promise((resolve25, reject) => {
|
|
35201
35201
|
const req = https.get(url, {
|
|
35202
35202
|
headers: { "User-Agent": "adhdev-daemon" },
|
|
35203
35203
|
timeout: timeoutMs
|
|
35204
35204
|
}, (res) => {
|
|
35205
35205
|
if (res.statusCode === 301 || res.statusCode === 302) {
|
|
35206
35206
|
if (res.headers.location) {
|
|
35207
|
-
return fetchBinary(res.headers.location, timeoutMs).then(
|
|
35207
|
+
return fetchBinary(res.headers.location, timeoutMs).then(resolve25, reject);
|
|
35208
35208
|
}
|
|
35209
35209
|
}
|
|
35210
35210
|
if (res.statusCode !== 200) {
|
|
@@ -35213,7 +35213,7 @@ ${formatManifestValidationIssues2(validation.issues)}`,
|
|
|
35213
35213
|
}
|
|
35214
35214
|
const chunks = [];
|
|
35215
35215
|
res.on("data", (c) => chunks.push(c));
|
|
35216
|
-
res.on("end", () =>
|
|
35216
|
+
res.on("end", () => resolve25(Buffer.concat(chunks)));
|
|
35217
35217
|
});
|
|
35218
35218
|
req.on("error", reject);
|
|
35219
35219
|
req.on("timeout", () => {
|
|
@@ -35224,9 +35224,9 @@ ${formatManifestValidationIssues2(validation.issues)}`,
|
|
|
35224
35224
|
}
|
|
35225
35225
|
let fetchedCount = 0;
|
|
35226
35226
|
const sharedDirRel = `${category}/_shared`;
|
|
35227
|
-
const sharedTargetDir =
|
|
35228
|
-
const installRootResolved =
|
|
35229
|
-
if (sharedTargetDir.startsWith(installRootResolved +
|
|
35227
|
+
const sharedTargetDir = path44.resolve(path44.join(targetDir, "../_shared"));
|
|
35228
|
+
const installRootResolved = path44.resolve(path44.join(targetDir, "../.."));
|
|
35229
|
+
if (sharedTargetDir.startsWith(installRootResolved + path44.sep)) {
|
|
35230
35230
|
const sharedStack = [sharedDirRel];
|
|
35231
35231
|
while (sharedStack.length) {
|
|
35232
35232
|
const relDir = sharedStack.pop();
|
|
@@ -35249,10 +35249,10 @@ ${formatManifestValidationIssues2(validation.issues)}`,
|
|
|
35249
35249
|
try {
|
|
35250
35250
|
const body = await fetchBinary(entry.download_url, 3e4);
|
|
35251
35251
|
const relInside = entry.path.startsWith(sharedDirRel + "/") ? entry.path.slice(sharedDirRel.length + 1) : entry.path;
|
|
35252
|
-
const outPath =
|
|
35253
|
-
if (!outPath.startsWith(
|
|
35254
|
-
|
|
35255
|
-
|
|
35252
|
+
const outPath = path44.resolve(path44.join(sharedTargetDir, relInside));
|
|
35253
|
+
if (!outPath.startsWith(path44.resolve(sharedTargetDir) + path44.sep)) continue;
|
|
35254
|
+
fs39.mkdirSync(path44.dirname(outPath), { recursive: true });
|
|
35255
|
+
fs39.writeFileSync(outPath, body);
|
|
35256
35256
|
fetchedCount++;
|
|
35257
35257
|
} catch (e) {
|
|
35258
35258
|
errors.push(`fetch shared ${entry.path}: ${e?.message ?? e}`);
|
|
@@ -35285,13 +35285,13 @@ ${formatManifestValidationIssues2(validation.issues)}`,
|
|
|
35285
35285
|
try {
|
|
35286
35286
|
const body = await fetchBinary(entry.download_url, 3e4);
|
|
35287
35287
|
const relInsideProvider = entry.path.startsWith(subdir + "/") ? entry.path.slice(subdir.length + 1) : entry.path;
|
|
35288
|
-
const outPath =
|
|
35289
|
-
if (!outPath.startsWith(
|
|
35288
|
+
const outPath = path44.resolve(path44.join(targetDir, relInsideProvider));
|
|
35289
|
+
if (!outPath.startsWith(path44.resolve(targetDir) + path44.sep)) {
|
|
35290
35290
|
errors.push(`refusing to write outside targetDir: ${entry.path}`);
|
|
35291
35291
|
continue;
|
|
35292
35292
|
}
|
|
35293
|
-
|
|
35294
|
-
|
|
35293
|
+
fs39.mkdirSync(path44.dirname(outPath), { recursive: true });
|
|
35294
|
+
fs39.writeFileSync(outPath, body);
|
|
35295
35295
|
fetchedCount++;
|
|
35296
35296
|
} catch (e) {
|
|
35297
35297
|
errors.push(`fetch ${entry.path}: ${e?.message ?? e}`);
|
|
@@ -35319,19 +35319,19 @@ ${formatManifestValidationIssues2(validation.issues)}`,
|
|
|
35319
35319
|
if (!["cli", "ide", "extension", "acp"].includes(category)) {
|
|
35320
35320
|
return { success: false, error: `unknown category: ${category}` };
|
|
35321
35321
|
}
|
|
35322
|
-
const
|
|
35323
|
-
const
|
|
35322
|
+
const fs39 = __require("fs");
|
|
35323
|
+
const path44 = __require("path");
|
|
35324
35324
|
try {
|
|
35325
35325
|
const installRoot = this.getUpstreamInstallRoot();
|
|
35326
|
-
const installRootResolved =
|
|
35327
|
-
const targetDir =
|
|
35328
|
-
if (!targetDir.startsWith(installRootResolved +
|
|
35326
|
+
const installRootResolved = path44.resolve(installRoot);
|
|
35327
|
+
const targetDir = path44.resolve(path44.join(installRoot, category, type));
|
|
35328
|
+
if (!targetDir.startsWith(installRootResolved + path44.sep)) {
|
|
35329
35329
|
return { success: false, error: "refusing to delete outside upstream root" };
|
|
35330
35330
|
}
|
|
35331
|
-
if (!
|
|
35331
|
+
if (!fs39.existsSync(targetDir)) {
|
|
35332
35332
|
return { success: false, error: "not installed" };
|
|
35333
35333
|
}
|
|
35334
|
-
|
|
35334
|
+
fs39.rmSync(targetDir, { recursive: true, force: true });
|
|
35335
35335
|
if (this._ctx.providerLoader) {
|
|
35336
35336
|
this._ctx.providerLoader.reload();
|
|
35337
35337
|
this._ctx.providerLoader.registerToDetector();
|
|
@@ -35347,28 +35347,28 @@ ${formatManifestValidationIssues2(validation.issues)}`,
|
|
|
35347
35347
|
* the UI and by the update checker.
|
|
35348
35348
|
*/
|
|
35349
35349
|
handleListInstalledProviders(_args) {
|
|
35350
|
-
const
|
|
35351
|
-
const
|
|
35350
|
+
const fs39 = __require("fs");
|
|
35351
|
+
const path44 = __require("path");
|
|
35352
35352
|
const installRoot = this.getUpstreamInstallRoot();
|
|
35353
|
-
if (!
|
|
35353
|
+
if (!fs39.existsSync(installRoot)) return { success: true, providers: [] };
|
|
35354
35354
|
const CATEGORIES = ["cli", "ide", "extension", "acp"];
|
|
35355
35355
|
const items = [];
|
|
35356
35356
|
for (const category of CATEGORIES) {
|
|
35357
|
-
const categoryDir =
|
|
35358
|
-
if (!
|
|
35357
|
+
const categoryDir = path44.join(installRoot, category);
|
|
35358
|
+
if (!fs39.existsSync(categoryDir)) continue;
|
|
35359
35359
|
let entries;
|
|
35360
35360
|
try {
|
|
35361
|
-
entries =
|
|
35361
|
+
entries = fs39.readdirSync(categoryDir);
|
|
35362
35362
|
} catch {
|
|
35363
35363
|
continue;
|
|
35364
35364
|
}
|
|
35365
35365
|
for (const type of entries) {
|
|
35366
|
-
const v1Path =
|
|
35367
|
-
const v0Path =
|
|
35368
|
-
const manifestPath =
|
|
35366
|
+
const v1Path = path44.join(categoryDir, type, "provider.v1.json");
|
|
35367
|
+
const v0Path = path44.join(categoryDir, type, "provider.json");
|
|
35368
|
+
const manifestPath = fs39.existsSync(v1Path) ? v1Path : fs39.existsSync(v0Path) ? v0Path : null;
|
|
35369
35369
|
if (!manifestPath) continue;
|
|
35370
35370
|
try {
|
|
35371
|
-
const m = JSON.parse(
|
|
35371
|
+
const m = JSON.parse(fs39.readFileSync(manifestPath, "utf-8"));
|
|
35372
35372
|
items.push({
|
|
35373
35373
|
type,
|
|
35374
35374
|
category,
|
|
@@ -35395,7 +35395,7 @@ ${formatManifestValidationIssues2(validation.issues)}`,
|
|
|
35395
35395
|
const https = __require("https");
|
|
35396
35396
|
const REGISTRY = "https://api.adhf.dev/api/v1/registry";
|
|
35397
35397
|
function fetchJson(url) {
|
|
35398
|
-
return new Promise((
|
|
35398
|
+
return new Promise((resolve25, reject) => {
|
|
35399
35399
|
const req = https.get(url, { headers: { "User-Agent": "adhdev-daemon", "Accept": "application/json" }, timeout: 1e4 }, (res) => {
|
|
35400
35400
|
if (res.statusCode !== 200) {
|
|
35401
35401
|
reject(new Error(`HTTP ${res.statusCode}`));
|
|
@@ -35405,7 +35405,7 @@ ${formatManifestValidationIssues2(validation.issues)}`,
|
|
|
35405
35405
|
res.on("data", (c) => chunks.push(c));
|
|
35406
35406
|
res.on("end", () => {
|
|
35407
35407
|
try {
|
|
35408
|
-
|
|
35408
|
+
resolve25(JSON.parse(Buffer.concat(chunks).toString("utf-8")));
|
|
35409
35409
|
} catch (e) {
|
|
35410
35410
|
reject(e);
|
|
35411
35411
|
}
|
|
@@ -35479,8 +35479,8 @@ ${formatManifestValidationIssues2(validation.issues)}`,
|
|
|
35479
35479
|
if (!/^@[a-z0-9_-]+$/i.test(requestedName)) {
|
|
35480
35480
|
return { success: false, error: "name must match @[a-z0-9_-]+" };
|
|
35481
35481
|
}
|
|
35482
|
-
const
|
|
35483
|
-
const
|
|
35482
|
+
const fs39 = __require("fs");
|
|
35483
|
+
const path44 = __require("path");
|
|
35484
35484
|
const { spawnSync: spawnSync2 } = __require("child_process");
|
|
35485
35485
|
const file = ext.loadExternalSources();
|
|
35486
35486
|
if (file.sources.some((s2) => s2.name === requestedName)) {
|
|
@@ -35489,9 +35489,9 @@ ${formatManifestValidationIssues2(validation.issues)}`,
|
|
|
35489
35489
|
if (file.sources.some((s2) => s2.url === url && s2.ref === ref)) {
|
|
35490
35490
|
return { success: false, error: `source url+ref already registered (use a different name to track another ref)` };
|
|
35491
35491
|
}
|
|
35492
|
-
const sourceDir =
|
|
35493
|
-
if (!
|
|
35494
|
-
if (
|
|
35492
|
+
const sourceDir = path44.join(ext.externalRoot(), requestedName);
|
|
35493
|
+
if (!fs39.existsSync(ext.externalRoot())) fs39.mkdirSync(ext.externalRoot(), { recursive: true });
|
|
35494
|
+
if (fs39.existsSync(sourceDir)) {
|
|
35495
35495
|
return { success: false, error: `directory already exists: ${sourceDir} (rename or remove first)` };
|
|
35496
35496
|
}
|
|
35497
35497
|
const clone = spawnSync2("git", ["clone", "--depth=1", "--branch", ref, "--", url, sourceDir], {
|
|
@@ -35501,7 +35501,7 @@ ${formatManifestValidationIssues2(validation.issues)}`,
|
|
|
35501
35501
|
});
|
|
35502
35502
|
if (clone.status !== 0) {
|
|
35503
35503
|
try {
|
|
35504
|
-
|
|
35504
|
+
fs39.rmSync(sourceDir, { recursive: true, force: true });
|
|
35505
35505
|
} catch {
|
|
35506
35506
|
}
|
|
35507
35507
|
return { success: false, error: `git clone failed: ${(clone.stderr || clone.stdout || "").trim() || "unknown error"}` };
|
|
@@ -35545,15 +35545,15 @@ ${formatManifestValidationIssues2(validation.issues)}`,
|
|
|
35545
35545
|
const name = typeof args?.name === "string" ? args.name.trim() : "";
|
|
35546
35546
|
if (!name) return { success: false, error: "name is required" };
|
|
35547
35547
|
const ext = (init_external_sources(), __toCommonJS(external_sources_exports));
|
|
35548
|
-
const
|
|
35549
|
-
const
|
|
35548
|
+
const fs39 = __require("fs");
|
|
35549
|
+
const path44 = __require("path");
|
|
35550
35550
|
const file = ext.loadExternalSources();
|
|
35551
35551
|
const match = file.sources.find((s2) => s2.name === name);
|
|
35552
35552
|
if (!match) return { success: false, error: `source "${name}" not registered` };
|
|
35553
|
-
const sourceDir =
|
|
35554
|
-
if (
|
|
35553
|
+
const sourceDir = path44.join(ext.externalRoot(), name);
|
|
35554
|
+
if (fs39.existsSync(sourceDir)) {
|
|
35555
35555
|
try {
|
|
35556
|
-
|
|
35556
|
+
fs39.rmSync(sourceDir, { recursive: true, force: true });
|
|
35557
35557
|
} catch (e) {
|
|
35558
35558
|
return { success: false, error: `failed to delete ${sourceDir}: ${e?.message || e}` };
|
|
35559
35559
|
}
|
|
@@ -35643,7 +35643,7 @@ ${formatManifestValidationIssues2(validation.issues)}`,
|
|
|
35643
35643
|
try {
|
|
35644
35644
|
const http3 = await import("http");
|
|
35645
35645
|
const postData = JSON.stringify(body);
|
|
35646
|
-
const result = await new Promise((
|
|
35646
|
+
const result = await new Promise((resolve25, reject) => {
|
|
35647
35647
|
const req = http3.request({
|
|
35648
35648
|
hostname: "127.0.0.1",
|
|
35649
35649
|
port: 19280,
|
|
@@ -35655,9 +35655,9 @@ ${formatManifestValidationIssues2(validation.issues)}`,
|
|
|
35655
35655
|
res.on("data", (chunk) => data += chunk);
|
|
35656
35656
|
res.on("end", () => {
|
|
35657
35657
|
try {
|
|
35658
|
-
|
|
35658
|
+
resolve25(JSON.parse(data));
|
|
35659
35659
|
} catch {
|
|
35660
|
-
|
|
35660
|
+
resolve25({ raw: data });
|
|
35661
35661
|
}
|
|
35662
35662
|
});
|
|
35663
35663
|
});
|
|
@@ -35675,15 +35675,15 @@ ${formatManifestValidationIssues2(validation.issues)}`,
|
|
|
35675
35675
|
if (!providerType) return { success: false, error: "providerType required" };
|
|
35676
35676
|
try {
|
|
35677
35677
|
const http3 = await import("http");
|
|
35678
|
-
const result = await new Promise((
|
|
35678
|
+
const result = await new Promise((resolve25, reject) => {
|
|
35679
35679
|
http3.get(`http://127.0.0.1:19280/api/providers/${providerType}/${endpoint}`, (res) => {
|
|
35680
35680
|
let data = "";
|
|
35681
35681
|
res.on("data", (chunk) => data += chunk);
|
|
35682
35682
|
res.on("end", () => {
|
|
35683
35683
|
try {
|
|
35684
|
-
|
|
35684
|
+
resolve25(JSON.parse(data));
|
|
35685
35685
|
} catch {
|
|
35686
|
-
|
|
35686
|
+
resolve25({ raw: data });
|
|
35687
35687
|
}
|
|
35688
35688
|
});
|
|
35689
35689
|
}).on("error", reject);
|
|
@@ -35697,7 +35697,7 @@ ${formatManifestValidationIssues2(validation.issues)}`,
|
|
|
35697
35697
|
try {
|
|
35698
35698
|
const http3 = await import("http");
|
|
35699
35699
|
const postData = JSON.stringify(args || {});
|
|
35700
|
-
const result = await new Promise((
|
|
35700
|
+
const result = await new Promise((resolve25, reject) => {
|
|
35701
35701
|
const req = http3.request({
|
|
35702
35702
|
hostname: "127.0.0.1",
|
|
35703
35703
|
port: 19280,
|
|
@@ -35709,9 +35709,9 @@ ${formatManifestValidationIssues2(validation.issues)}`,
|
|
|
35709
35709
|
res.on("data", (chunk) => data += chunk);
|
|
35710
35710
|
res.on("end", () => {
|
|
35711
35711
|
try {
|
|
35712
|
-
|
|
35712
|
+
resolve25(JSON.parse(data));
|
|
35713
35713
|
} catch {
|
|
35714
|
-
|
|
35714
|
+
resolve25({ raw: data });
|
|
35715
35715
|
}
|
|
35716
35716
|
});
|
|
35717
35717
|
});
|
|
@@ -36336,24 +36336,24 @@ var statusMetaHandlers = {
|
|
|
36336
36336
|
// src/commands/low-family/coordinator-prompt.ts
|
|
36337
36337
|
var coordinatorPromptHandlers = {
|
|
36338
36338
|
list_coordinator_prompts: async (_ctx, _args) => {
|
|
36339
|
-
const
|
|
36340
|
-
const
|
|
36341
|
-
const
|
|
36342
|
-
const dir =
|
|
36339
|
+
const fs39 = await import("fs");
|
|
36340
|
+
const path44 = await import("path");
|
|
36341
|
+
const os31 = await import("os");
|
|
36342
|
+
const dir = path44.join(os31.homedir(), ".adhdev", "coordinator-prompts");
|
|
36343
36343
|
const entries = {};
|
|
36344
36344
|
try {
|
|
36345
|
-
if (
|
|
36346
|
-
for (const name of
|
|
36345
|
+
if (fs39.existsSync(dir)) {
|
|
36346
|
+
for (const name of fs39.readdirSync(dir)) {
|
|
36347
36347
|
const matchOverride = name.match(/^([a-zA-Z0-9_.-]+)\.md$/);
|
|
36348
36348
|
const matchAppend = name.match(/^([a-zA-Z0-9_.-]+)\.append\.md$/);
|
|
36349
36349
|
const m = matchAppend || matchOverride;
|
|
36350
36350
|
if (!m) continue;
|
|
36351
36351
|
const isAppend = !!matchAppend;
|
|
36352
36352
|
const key2 = m[1];
|
|
36353
|
-
const full =
|
|
36353
|
+
const full = path44.join(dir, name);
|
|
36354
36354
|
let content = "";
|
|
36355
36355
|
try {
|
|
36356
|
-
content =
|
|
36356
|
+
content = fs39.readFileSync(full, "utf8");
|
|
36357
36357
|
} catch {
|
|
36358
36358
|
}
|
|
36359
36359
|
if (!entries[key2]) entries[key2] = { override: "", append: "" };
|
|
@@ -36367,24 +36367,24 @@ var coordinatorPromptHandlers = {
|
|
|
36367
36367
|
return { success: true, dir, entries };
|
|
36368
36368
|
},
|
|
36369
36369
|
write_coordinator_prompt: async (_ctx, args) => {
|
|
36370
|
-
const
|
|
36371
|
-
const
|
|
36372
|
-
const
|
|
36370
|
+
const fs39 = await import("fs");
|
|
36371
|
+
const path44 = await import("path");
|
|
36372
|
+
const os31 = await import("os");
|
|
36373
36373
|
const key2 = typeof args?.key === "string" ? args.key.trim() : "";
|
|
36374
36374
|
const kind = args?.kind === "append" ? "append" : "override";
|
|
36375
36375
|
const content = typeof args?.content === "string" ? args.content : "";
|
|
36376
36376
|
if (!key2 || !/^[a-zA-Z0-9_.-]+$/.test(key2)) {
|
|
36377
36377
|
return { success: false, error: "key must match [a-zA-Z0-9_.-]+" };
|
|
36378
36378
|
}
|
|
36379
|
-
const dir =
|
|
36379
|
+
const dir = path44.join(os31.homedir(), ".adhdev", "coordinator-prompts");
|
|
36380
36380
|
const filename = kind === "append" ? `${key2}.append.md` : `${key2}.md`;
|
|
36381
|
-
const full =
|
|
36381
|
+
const full = path44.join(dir, filename);
|
|
36382
36382
|
try {
|
|
36383
|
-
|
|
36383
|
+
fs39.mkdirSync(dir, { recursive: true });
|
|
36384
36384
|
if (content.trim()) {
|
|
36385
|
-
|
|
36386
|
-
} else if (
|
|
36387
|
-
|
|
36385
|
+
fs39.writeFileSync(full, content, { encoding: "utf8", mode: 384 });
|
|
36386
|
+
} else if (fs39.existsSync(full)) {
|
|
36387
|
+
fs39.unlinkSync(full);
|
|
36388
36388
|
}
|
|
36389
36389
|
return { success: true, path: full, kind, key: key2 };
|
|
36390
36390
|
} catch (error) {
|
|
@@ -36701,7 +36701,7 @@ async function waitForPidExit(pid, timeoutMs) {
|
|
|
36701
36701
|
while (Date.now() - start < timeoutMs) {
|
|
36702
36702
|
try {
|
|
36703
36703
|
process.kill(pid, 0);
|
|
36704
|
-
await new Promise((
|
|
36704
|
+
await new Promise((resolve25) => setTimeout(resolve25, 250));
|
|
36705
36705
|
} catch {
|
|
36706
36706
|
return;
|
|
36707
36707
|
}
|
|
@@ -36927,7 +36927,7 @@ async function runDaemonUpgradeHelper(payload) {
|
|
|
36927
36927
|
appendUpgradeLog(`Install attempt ${attempt} hit a file lock (${error?.code || "lock"}); clearing holders + staging and retrying after backoff`);
|
|
36928
36928
|
await stopForeignNativeAddonHolders(installCommand.surface.packageRoot, { parentPid: payload.parentPid });
|
|
36929
36929
|
cleanupStaleGlobalInstallDirs(payload.packageName, installCommand.surface);
|
|
36930
|
-
await new Promise((
|
|
36930
|
+
await new Promise((resolve25) => setTimeout(resolve25, attempt * 1500));
|
|
36931
36931
|
continue;
|
|
36932
36932
|
}
|
|
36933
36933
|
if (isRetriableInstallLockError(error)) {
|
|
@@ -36955,7 +36955,7 @@ async function runDaemonUpgradeHelper(payload) {
|
|
|
36955
36955
|
appendUpgradeLog(installOutput.trim());
|
|
36956
36956
|
}
|
|
36957
36957
|
if (process.platform === "win32") {
|
|
36958
|
-
await new Promise((
|
|
36958
|
+
await new Promise((resolve25) => setTimeout(resolve25, 500));
|
|
36959
36959
|
cleanupStaleGlobalInstallDirs(payload.packageName, installCommand.surface);
|
|
36960
36960
|
appendUpgradeLog("Post-install staging cleanup complete");
|
|
36961
36961
|
}
|
|
@@ -37593,6 +37593,16 @@ var TerminalAdapter = class {
|
|
|
37593
37593
|
this.recordEvent("input", capPreview(escapeControl(text)), text.length);
|
|
37594
37594
|
this.pty?.write(text);
|
|
37595
37595
|
}
|
|
37596
|
+
/** Forward runtime metadata (meshNodeId, workspaceLabel, lifecycle, …) to
|
|
37597
|
+
* the underlying transport so it reaches the session registry. The spec
|
|
37598
|
+
* path previously dropped everything but providerSessionId here, which
|
|
37599
|
+
* left autoLaunch's meshNodeId stamp unbound on the record (see
|
|
37600
|
+
* SESSION-ACCUMULATION-LEAK). No-op when the transport does not support
|
|
37601
|
+
* metadata updates (e.g. plain node-pty). */
|
|
37602
|
+
updateMeta(meta, replace = false) {
|
|
37603
|
+
if (!this.pty || typeof this.pty.updateMeta !== "function") return;
|
|
37604
|
+
this.pty.updateMeta(meta, replace);
|
|
37605
|
+
}
|
|
37596
37606
|
/** Debug-only: most-recent PTY input/output/resize/cursor events, oldest
|
|
37597
37607
|
* first. Pure observation — never consulted by the FSM. */
|
|
37598
37608
|
getEventTimeline(limit = MAX_PTY_EVENTS) {
|
|
@@ -37892,6 +37902,13 @@ var FsmDriver = class {
|
|
|
37892
37902
|
return;
|
|
37893
37903
|
}
|
|
37894
37904
|
}
|
|
37905
|
+
/** Forward runtime metadata to the terminal transport so mesh binding
|
|
37906
|
+
* fields (meshNodeId / meshNodeFor / workspaceLabel / lifecycle) reach
|
|
37907
|
+
* the session registry. Not a DashboardCommand — this is a control-plane
|
|
37908
|
+
* update, not user input. */
|
|
37909
|
+
updateMeta(meta, replace = false) {
|
|
37910
|
+
this.adapter.updateMeta(meta, replace);
|
|
37911
|
+
}
|
|
37895
37912
|
snapshot() {
|
|
37896
37913
|
return this.adapter.snapshot();
|
|
37897
37914
|
}
|
|
@@ -39603,7 +39620,7 @@ function stripAnsi3(text) {
|
|
|
39603
39620
|
return String(text || "").replace(/\x1B\][^\x07]*(?:\x07|\x1B\\)/g, "").replace(/\x1B[P^_X][\s\S]*?(?:\x07|\x1B\\)/g, "").replace(/\x1B(?:[@-Z\\-_]|\[[0-?]*[ -/]*[@-~])/g, "");
|
|
39604
39621
|
}
|
|
39605
39622
|
function delay(ms) {
|
|
39606
|
-
return new Promise((
|
|
39623
|
+
return new Promise((resolve25) => setTimeout(resolve25, ms));
|
|
39607
39624
|
}
|
|
39608
39625
|
var SpecCliAdapter = class _SpecCliAdapter {
|
|
39609
39626
|
cliType;
|
|
@@ -39802,7 +39819,7 @@ var SpecCliAdapter = class _SpecCliAdapter {
|
|
|
39802
39819
|
const steps = buildClaudeInteractiveTuiAnswerSteps(prompt, response);
|
|
39803
39820
|
for (const step of steps) {
|
|
39804
39821
|
this.driver.dispatch({ kind: "pty_write", data: step });
|
|
39805
|
-
await new Promise((
|
|
39822
|
+
await new Promise((resolve25) => setTimeout(resolve25, 180));
|
|
39806
39823
|
}
|
|
39807
39824
|
} else {
|
|
39808
39825
|
this.driver.dispatch({ kind: "pty_write", data: `${buildClaudeInteractiveToolResult(response)}
|
|
@@ -40096,9 +40113,14 @@ var SpecCliAdapter = class _SpecCliAdapter {
|
|
|
40096
40113
|
};
|
|
40097
40114
|
}
|
|
40098
40115
|
updateRuntimeMeta(meta) {
|
|
40099
|
-
if (meta
|
|
40116
|
+
if (!meta) return;
|
|
40117
|
+
if (typeof meta.providerSessionId === "string") {
|
|
40100
40118
|
this.providerSessionId = meta.providerSessionId;
|
|
40101
40119
|
}
|
|
40120
|
+
try {
|
|
40121
|
+
this.driver.updateMeta(meta);
|
|
40122
|
+
} catch {
|
|
40123
|
+
}
|
|
40102
40124
|
}
|
|
40103
40125
|
refreshProviderDefinition() {
|
|
40104
40126
|
}
|
|
@@ -40353,7 +40375,7 @@ var SpecCliAdapter = class _SpecCliAdapter {
|
|
|
40353
40375
|
let screenText = this.driver.snapshot();
|
|
40354
40376
|
const deadline = Date.now() + _SpecCliAdapter.CLAUDE_TUI_PAGE_SETTLE_TIMEOUT_MS;
|
|
40355
40377
|
while (!detectClaudeTuiMultiSelect(screenText) && Date.now() < deadline) {
|
|
40356
|
-
await new Promise((
|
|
40378
|
+
await new Promise((resolve25) => setTimeout(resolve25, _SpecCliAdapter.CLAUDE_TUI_PAGE_POLL_INTERVAL_MS));
|
|
40357
40379
|
screenText = this.driver.snapshot();
|
|
40358
40380
|
}
|
|
40359
40381
|
return screenText;
|
|
@@ -40362,12 +40384,12 @@ var SpecCliAdapter = class _SpecCliAdapter {
|
|
|
40362
40384
|
const pages = [{ screenText: firstScreen, header: headers[0] }];
|
|
40363
40385
|
for (let index = 1; index < headers.length; index += 1) {
|
|
40364
40386
|
this.driver.dispatch({ kind: "pty_write", data: " " });
|
|
40365
|
-
await new Promise((
|
|
40387
|
+
await new Promise((resolve25) => setTimeout(resolve25, _SpecCliAdapter.CLAUDE_TUI_PAGE_POLL_INTERVAL_MS));
|
|
40366
40388
|
pages.push({ screenText: await this.snapshotSettledClaudeTuiPage(), header: headers[index] });
|
|
40367
40389
|
}
|
|
40368
40390
|
for (let index = headers.length - 1; index > 0; index -= 1) {
|
|
40369
40391
|
this.driver.dispatch({ kind: "pty_write", data: "\x1B[Z" });
|
|
40370
|
-
await new Promise((
|
|
40392
|
+
await new Promise((resolve25) => setTimeout(resolve25, _SpecCliAdapter.CLAUDE_TUI_PAGE_POLL_INTERVAL_MS));
|
|
40371
40393
|
const reread = await this.snapshotSettledClaudeTuiPage();
|
|
40372
40394
|
const landed = pages[index - 1];
|
|
40373
40395
|
if (landed && !detectClaudeTuiMultiSelect(landed.screenText) && detectClaudeTuiMultiSelect(reread)) {
|
|
@@ -40722,7 +40744,7 @@ async function waitForCliAdapterReady(adapter, options) {
|
|
|
40722
40744
|
if (status === "stopped") {
|
|
40723
40745
|
throw new Error("CLI runtime stopped before it became ready");
|
|
40724
40746
|
}
|
|
40725
|
-
await new Promise((
|
|
40747
|
+
await new Promise((resolve25) => setTimeout(resolve25, pollMs));
|
|
40726
40748
|
}
|
|
40727
40749
|
throw new Error(`CLI runtime did not become ready within ${timeoutMs}ms`);
|
|
40728
40750
|
}
|
|
@@ -41471,7 +41493,7 @@ var CliProviderInstance = class _CliProviderInstance {
|
|
|
41471
41493
|
const enterCount = cliCommand.enterCount || 1;
|
|
41472
41494
|
await this.adapter.writeRaw(cliCommand.text + "\r");
|
|
41473
41495
|
for (let i = 1; i < enterCount; i += 1) {
|
|
41474
|
-
await new Promise((
|
|
41496
|
+
await new Promise((resolve25) => setTimeout(resolve25, 50));
|
|
41475
41497
|
await this.adapter.writeRaw("\r");
|
|
41476
41498
|
}
|
|
41477
41499
|
}
|
|
@@ -43550,13 +43572,13 @@ var AcpProviderInstance = class {
|
|
|
43550
43572
|
}
|
|
43551
43573
|
this.currentStatus = "waiting_approval";
|
|
43552
43574
|
this.detectStatusTransition();
|
|
43553
|
-
const approved = await new Promise((
|
|
43554
|
-
this.permissionResolvers.push(
|
|
43575
|
+
const approved = await new Promise((resolve25) => {
|
|
43576
|
+
this.permissionResolvers.push(resolve25);
|
|
43555
43577
|
setTimeout(() => {
|
|
43556
|
-
const idx = this.permissionResolvers.indexOf(
|
|
43578
|
+
const idx = this.permissionResolvers.indexOf(resolve25);
|
|
43557
43579
|
if (idx >= 0) {
|
|
43558
43580
|
this.permissionResolvers.splice(idx, 1);
|
|
43559
|
-
|
|
43581
|
+
resolve25(false);
|
|
43560
43582
|
}
|
|
43561
43583
|
}, 3e5);
|
|
43562
43584
|
});
|
|
@@ -44292,7 +44314,7 @@ async function waitForZeroMessageStartingLaunch(adapter) {
|
|
|
44292
44314
|
} catch {
|
|
44293
44315
|
return false;
|
|
44294
44316
|
}
|
|
44295
|
-
await new Promise((
|
|
44317
|
+
await new Promise((resolve25) => setTimeout(resolve25, ZERO_MESSAGE_STARTING_SEND_WAIT_MS));
|
|
44296
44318
|
try {
|
|
44297
44319
|
return hasZeroMessageStartingLaunch(adapter);
|
|
44298
44320
|
} catch {
|
|
@@ -44539,14 +44561,15 @@ var DaemonCliManager = class {
|
|
|
44539
44561
|
console.error(colorize("red", ` \u2717 Failed to save recent activity: ${e}`));
|
|
44540
44562
|
}
|
|
44541
44563
|
}
|
|
44542
|
-
getTransportFactory(runtimeId, providerType, workspace, cliArgs, providerSessionId, attachExisting = false) {
|
|
44564
|
+
getTransportFactory(runtimeId, providerType, workspace, cliArgs, providerSessionId, attachExisting = false, initialMeta) {
|
|
44543
44565
|
return this.deps.createPtyTransportFactory?.({
|
|
44544
44566
|
runtimeId,
|
|
44545
44567
|
providerType,
|
|
44546
44568
|
workspace,
|
|
44547
44569
|
cliArgs,
|
|
44548
44570
|
providerSessionId,
|
|
44549
|
-
attachExisting
|
|
44571
|
+
attachExisting,
|
|
44572
|
+
...initialMeta && Object.keys(initialMeta).length ? { initialMeta } : {}
|
|
44550
44573
|
}) || void 0;
|
|
44551
44574
|
}
|
|
44552
44575
|
createAdapter(cliType, workingDir, cliArgs, runtimeId, providerSessionId, attachExisting = false, extraEnv) {
|
|
@@ -44602,13 +44625,25 @@ var DaemonCliManager = class {
|
|
|
44602
44625
|
const instanceManager = this.deps.getInstanceManager();
|
|
44603
44626
|
const sessionRegistry = this.deps.getSessionRegistry?.() || null;
|
|
44604
44627
|
if (!instanceManager) throw new Error("InstanceManager not available");
|
|
44628
|
+
const launchMeshNodeId = typeof settings?.meshNodeId === "string" ? settings.meshNodeId.trim() : "";
|
|
44629
|
+
const launchMeshNodeFor = typeof settings?.meshNodeFor === "string" ? settings.meshNodeFor.trim() : "";
|
|
44630
|
+
const launchAutoLaunchedForQueueTaskId = typeof settings?.autoLaunchedForQueueTaskId === "string" ? settings.autoLaunchedForQueueTaskId.trim() : "";
|
|
44631
|
+
const launchRecordMeta = {
|
|
44632
|
+
...launchMeshNodeId ? { meshNodeId: launchMeshNodeId } : {},
|
|
44633
|
+
...launchMeshNodeFor ? { meshNodeFor: launchMeshNodeFor } : {},
|
|
44634
|
+
...settings?.launchedByCoordinator === true ? { launchedByCoordinator: true } : {},
|
|
44635
|
+
...launchAutoLaunchedForQueueTaskId ? { autoLaunchedForQueueTaskId: launchAutoLaunchedForQueueTaskId } : {}
|
|
44636
|
+
};
|
|
44605
44637
|
const transportFactory = this.getTransportFactory(
|
|
44606
44638
|
key2,
|
|
44607
44639
|
normalizedType,
|
|
44608
44640
|
resolvedDir,
|
|
44609
44641
|
cliArgs,
|
|
44610
44642
|
options?.providerSessionId,
|
|
44611
|
-
attachExisting
|
|
44643
|
+
attachExisting,
|
|
44644
|
+
// Only seed at create time for fresh launches — an attach restores an
|
|
44645
|
+
// existing record whose meta is already stamped; re-seeding could clobber.
|
|
44646
|
+
attachExisting ? void 0 : launchRecordMeta
|
|
44612
44647
|
);
|
|
44613
44648
|
const cliInstance = new CliProviderInstance(provider, resolvedDir, cliArgs, key2, transportFactory, options);
|
|
44614
44649
|
try {
|
|
@@ -44645,17 +44680,9 @@ var DaemonCliManager = class {
|
|
|
44645
44680
|
throw new Error(`Failed to start ${provider.displayName || provider.name || cliType}: ${spawnErr?.message}`);
|
|
44646
44681
|
}
|
|
44647
44682
|
this.adapters.set(key2, cliInstance.getAdapter());
|
|
44648
|
-
|
|
44649
|
-
const launchMeshNodeFor = typeof settings?.meshNodeFor === "string" ? settings.meshNodeFor.trim() : "";
|
|
44650
|
-
const launchAutoLaunchedForQueueTaskId = typeof settings?.autoLaunchedForQueueTaskId === "string" ? settings.autoLaunchedForQueueTaskId.trim() : "";
|
|
44651
|
-
if (launchMeshNodeId || launchMeshNodeFor || launchAutoLaunchedForQueueTaskId) {
|
|
44683
|
+
if (Object.keys(launchRecordMeta).length) {
|
|
44652
44684
|
try {
|
|
44653
|
-
cliInstance.getAdapter().updateRuntimeMeta?.({
|
|
44654
|
-
...launchMeshNodeId ? { meshNodeId: launchMeshNodeId } : {},
|
|
44655
|
-
...launchMeshNodeFor ? { meshNodeFor: launchMeshNodeFor } : {},
|
|
44656
|
-
...settings?.launchedByCoordinator === true ? { launchedByCoordinator: true } : {},
|
|
44657
|
-
...launchAutoLaunchedForQueueTaskId ? { autoLaunchedForQueueTaskId: launchAutoLaunchedForQueueTaskId } : {}
|
|
44658
|
-
});
|
|
44685
|
+
cliInstance.getAdapter().updateRuntimeMeta?.({ ...launchRecordMeta });
|
|
44659
44686
|
} catch {
|
|
44660
44687
|
}
|
|
44661
44688
|
}
|
|
@@ -45633,9 +45660,9 @@ function validateProviderDefinition(raw) {
|
|
|
45633
45660
|
const typedProvider = provider;
|
|
45634
45661
|
const controls = Array.isArray(provider.controls) ? provider.controls : [];
|
|
45635
45662
|
if (category === "cli" || category === "acp") {
|
|
45636
|
-
const
|
|
45637
|
-
const command =
|
|
45638
|
-
if (!
|
|
45663
|
+
const spawn5 = provider.spawn;
|
|
45664
|
+
const command = spawn5 && typeof spawn5 === "object" ? spawn5.command : void 0;
|
|
45665
|
+
if (!spawn5 || typeof spawn5 !== "object") {
|
|
45639
45666
|
errors.push(`${String(category).toUpperCase()}/CLI providers must have spawn config`);
|
|
45640
45667
|
} else if (typeof command !== "string" || !command.trim()) {
|
|
45641
45668
|
errors.push("spawn.command is required");
|
|
@@ -48156,25 +48183,25 @@ var ProviderLoader = class _ProviderLoader {
|
|
|
48156
48183
|
}
|
|
48157
48184
|
if (providerDir) {
|
|
48158
48185
|
try {
|
|
48159
|
-
const
|
|
48160
|
-
const
|
|
48186
|
+
const fs39 = __require("fs");
|
|
48187
|
+
const path44 = __require("path");
|
|
48161
48188
|
const candidates = [];
|
|
48162
48189
|
if (Array.isArray(base.compatibility)) {
|
|
48163
48190
|
for (const entry of base.compatibility) {
|
|
48164
48191
|
if (typeof entry?.spec !== "string") continue;
|
|
48165
48192
|
const matches = !entry.ideVersion || currentVersion && this.matchesVersion(currentVersion, entry.ideVersion) || !currentVersion;
|
|
48166
|
-
if (matches) candidates.push(
|
|
48193
|
+
if (matches) candidates.push(path44.join(providerDir, entry.spec));
|
|
48167
48194
|
}
|
|
48168
48195
|
}
|
|
48169
|
-
candidates.push(
|
|
48170
|
-
candidates.push(
|
|
48171
|
-
const specPath = candidates.find((p) =>
|
|
48196
|
+
candidates.push(path44.join(providerDir, "specs", "default.json"));
|
|
48197
|
+
candidates.push(path44.join(providerDir, "spec.json"));
|
|
48198
|
+
const specPath = candidates.find((p) => fs39.existsSync(p));
|
|
48172
48199
|
if (specPath) {
|
|
48173
48200
|
resolved._resolvedSpecPath = specPath;
|
|
48174
48201
|
let specControls;
|
|
48175
48202
|
let nh;
|
|
48176
48203
|
try {
|
|
48177
|
-
const rawSpec = JSON.parse(
|
|
48204
|
+
const rawSpec = JSON.parse(fs39.readFileSync(specPath, "utf8"));
|
|
48178
48205
|
specControls = rawSpec.control_bar;
|
|
48179
48206
|
nh = rawSpec.native_history;
|
|
48180
48207
|
} catch {
|
|
@@ -48205,10 +48232,10 @@ var ProviderLoader = class _ProviderLoader {
|
|
|
48205
48232
|
format = `spec-${nh.source.kind}`;
|
|
48206
48233
|
reader = (input) => executeNativeHistory(nh, input);
|
|
48207
48234
|
} else if (nh.override_path) {
|
|
48208
|
-
const overrideFile =
|
|
48209
|
-
if (
|
|
48235
|
+
const overrideFile = path44.resolve(providerDir, nh.override_path);
|
|
48236
|
+
if (fs39.existsSync(overrideFile)) {
|
|
48210
48237
|
try {
|
|
48211
|
-
registerProviderScriptRootSafely(
|
|
48238
|
+
registerProviderScriptRootSafely(path44.dirname(path44.dirname(providerDir)));
|
|
48212
48239
|
delete __require.cache[__require.resolve(overrideFile)];
|
|
48213
48240
|
const mod = __require(overrideFile);
|
|
48214
48241
|
const fn = typeof mod === "function" ? mod : mod && typeof mod.default === "function" ? mod.default : null;
|
|
@@ -48382,7 +48409,7 @@ var ProviderLoader = class _ProviderLoader {
|
|
|
48382
48409
|
}
|
|
48383
48410
|
try {
|
|
48384
48411
|
const listUrl = `${_ProviderLoader.REGISTRY_BASE_URL}/providers`;
|
|
48385
|
-
const listBody = await new Promise((
|
|
48412
|
+
const listBody = await new Promise((resolve25, reject) => {
|
|
48386
48413
|
const req = https.get(listUrl, { headers: { "User-Agent": "adhdev-daemon", "Accept": "application/json" }, timeout: 1e4 }, (res) => {
|
|
48387
48414
|
if (res.statusCode !== 200) {
|
|
48388
48415
|
reject(new Error(`registry list HTTP ${res.statusCode}`));
|
|
@@ -48390,7 +48417,7 @@ var ProviderLoader = class _ProviderLoader {
|
|
|
48390
48417
|
}
|
|
48391
48418
|
const chunks = [];
|
|
48392
48419
|
res.on("data", (c) => chunks.push(c));
|
|
48393
|
-
res.on("end", () =>
|
|
48420
|
+
res.on("end", () => resolve25(Buffer.concat(chunks).toString("utf-8")));
|
|
48394
48421
|
});
|
|
48395
48422
|
req.on("error", reject);
|
|
48396
48423
|
req.on("timeout", () => {
|
|
@@ -48406,7 +48433,7 @@ var ProviderLoader = class _ProviderLoader {
|
|
|
48406
48433
|
const cacheKey = `${category}/${type}`;
|
|
48407
48434
|
if (cachedChecksums[cacheKey] === checksum) continue;
|
|
48408
48435
|
const dlUrl = `${_ProviderLoader.REGISTRY_BASE_URL}/providers/${type}/${version}/download`;
|
|
48409
|
-
const manifestBody = await new Promise((
|
|
48436
|
+
const manifestBody = await new Promise((resolve25, reject) => {
|
|
48410
48437
|
const req = https.get(dlUrl, { headers: { "User-Agent": "adhdev-daemon", "Accept": "application/json" }, timeout: 3e4 }, (res) => {
|
|
48411
48438
|
if (res.statusCode !== 200) {
|
|
48412
48439
|
reject(new Error(`registry download HTTP ${res.statusCode} for ${type}@${version}`));
|
|
@@ -48414,7 +48441,7 @@ var ProviderLoader = class _ProviderLoader {
|
|
|
48414
48441
|
}
|
|
48415
48442
|
const chunks = [];
|
|
48416
48443
|
res.on("data", (c) => chunks.push(c));
|
|
48417
|
-
res.on("end", () =>
|
|
48444
|
+
res.on("end", () => resolve25(Buffer.concat(chunks).toString("utf-8")));
|
|
48418
48445
|
});
|
|
48419
48446
|
req.on("error", reject);
|
|
48420
48447
|
req.on("timeout", () => {
|
|
@@ -48473,7 +48500,7 @@ var ProviderLoader = class _ProviderLoader {
|
|
|
48473
48500
|
return { updated: false };
|
|
48474
48501
|
}
|
|
48475
48502
|
try {
|
|
48476
|
-
const etag = await new Promise((
|
|
48503
|
+
const etag = await new Promise((resolve25, reject) => {
|
|
48477
48504
|
const options = {
|
|
48478
48505
|
method: "HEAD",
|
|
48479
48506
|
hostname: "github.com",
|
|
@@ -48491,7 +48518,7 @@ var ProviderLoader = class _ProviderLoader {
|
|
|
48491
48518
|
headers: { "User-Agent": "adhdev-launcher" },
|
|
48492
48519
|
timeout: 1e4
|
|
48493
48520
|
}, (res2) => {
|
|
48494
|
-
|
|
48521
|
+
resolve25(res2.headers.etag || res2.headers["last-modified"] || "");
|
|
48495
48522
|
});
|
|
48496
48523
|
req2.on("error", reject);
|
|
48497
48524
|
req2.on("timeout", () => {
|
|
@@ -48500,7 +48527,7 @@ var ProviderLoader = class _ProviderLoader {
|
|
|
48500
48527
|
});
|
|
48501
48528
|
req2.end();
|
|
48502
48529
|
} else {
|
|
48503
|
-
|
|
48530
|
+
resolve25(res.headers.etag || res.headers["last-modified"] || "");
|
|
48504
48531
|
}
|
|
48505
48532
|
});
|
|
48506
48533
|
req.on("error", reject);
|
|
@@ -48564,7 +48591,7 @@ var ProviderLoader = class _ProviderLoader {
|
|
|
48564
48591
|
downloadFile(url, destPath) {
|
|
48565
48592
|
const https = __require("https");
|
|
48566
48593
|
const http3 = __require("http");
|
|
48567
|
-
return new Promise((
|
|
48594
|
+
return new Promise((resolve25, reject) => {
|
|
48568
48595
|
const doRequest = (reqUrl, redirectCount = 0) => {
|
|
48569
48596
|
if (redirectCount > 5) {
|
|
48570
48597
|
reject(new Error("Too many redirects"));
|
|
@@ -48584,7 +48611,7 @@ var ProviderLoader = class _ProviderLoader {
|
|
|
48584
48611
|
res.pipe(ws);
|
|
48585
48612
|
ws.on("finish", () => {
|
|
48586
48613
|
ws.close();
|
|
48587
|
-
|
|
48614
|
+
resolve25();
|
|
48588
48615
|
});
|
|
48589
48616
|
ws.on("error", reject);
|
|
48590
48617
|
});
|
|
@@ -49140,10 +49167,10 @@ function findMacAppProcessPids(psOutput, appPaths) {
|
|
|
49140
49167
|
|
|
49141
49168
|
// src/launch.ts
|
|
49142
49169
|
async function execQuiet(command, options = {}) {
|
|
49143
|
-
return new Promise((
|
|
49170
|
+
return new Promise((resolve25) => {
|
|
49144
49171
|
exec4(command, options, (error, stdout) => {
|
|
49145
|
-
if (error) return
|
|
49146
|
-
|
|
49172
|
+
if (error) return resolve25("");
|
|
49173
|
+
resolve25(stdout.toString());
|
|
49147
49174
|
});
|
|
49148
49175
|
});
|
|
49149
49176
|
}
|
|
@@ -49224,17 +49251,17 @@ async function findFreePort(ports) {
|
|
|
49224
49251
|
throw new Error("No free port found");
|
|
49225
49252
|
}
|
|
49226
49253
|
function checkPortFree(port) {
|
|
49227
|
-
return new Promise((
|
|
49254
|
+
return new Promise((resolve25) => {
|
|
49228
49255
|
const server = net.createServer();
|
|
49229
49256
|
server.unref();
|
|
49230
|
-
server.on("error", () =>
|
|
49257
|
+
server.on("error", () => resolve25(false));
|
|
49231
49258
|
server.listen(port, "127.0.0.1", () => {
|
|
49232
|
-
server.close(() =>
|
|
49259
|
+
server.close(() => resolve25(true));
|
|
49233
49260
|
});
|
|
49234
49261
|
});
|
|
49235
49262
|
}
|
|
49236
49263
|
async function isCdpActive(port) {
|
|
49237
|
-
return new Promise((
|
|
49264
|
+
return new Promise((resolve25) => {
|
|
49238
49265
|
const req = __require("http").get(`http://127.0.0.1:${port}/json/version`, {
|
|
49239
49266
|
timeout: 2e3
|
|
49240
49267
|
}, (res) => {
|
|
@@ -49243,16 +49270,16 @@ async function isCdpActive(port) {
|
|
|
49243
49270
|
res.on("end", () => {
|
|
49244
49271
|
try {
|
|
49245
49272
|
const info = JSON.parse(data);
|
|
49246
|
-
|
|
49273
|
+
resolve25(!!info["WebKit-Version"] || !!info["Browser"]);
|
|
49247
49274
|
} catch {
|
|
49248
|
-
|
|
49275
|
+
resolve25(false);
|
|
49249
49276
|
}
|
|
49250
49277
|
});
|
|
49251
49278
|
});
|
|
49252
|
-
req.on("error", () =>
|
|
49279
|
+
req.on("error", () => resolve25(false));
|
|
49253
49280
|
req.on("timeout", () => {
|
|
49254
49281
|
req.destroy();
|
|
49255
|
-
|
|
49282
|
+
resolve25(false);
|
|
49256
49283
|
});
|
|
49257
49284
|
});
|
|
49258
49285
|
}
|
|
@@ -49388,7 +49415,7 @@ async function detectCurrentWorkspace(ideId) {
|
|
|
49388
49415
|
}
|
|
49389
49416
|
} else if (plat === "win32") {
|
|
49390
49417
|
try {
|
|
49391
|
-
const
|
|
49418
|
+
const fs39 = __require("fs");
|
|
49392
49419
|
const appNameMap = getMacAppIdentifiers();
|
|
49393
49420
|
const appName = appNameMap[ideId];
|
|
49394
49421
|
if (appName) {
|
|
@@ -49397,8 +49424,8 @@ async function detectCurrentWorkspace(ideId) {
|
|
|
49397
49424
|
appName,
|
|
49398
49425
|
"storage.json"
|
|
49399
49426
|
);
|
|
49400
|
-
if (
|
|
49401
|
-
const data = JSON.parse(
|
|
49427
|
+
if (fs39.existsSync(storagePath)) {
|
|
49428
|
+
const data = JSON.parse(fs39.readFileSync(storagePath, "utf-8"));
|
|
49402
49429
|
const workspaces = data?.openedPathsList?.workspaces3 || data?.openedPathsList?.entries || [];
|
|
49403
49430
|
if (workspaces.length > 0) {
|
|
49404
49431
|
const recent = workspaces[0];
|
|
@@ -49876,12 +49903,12 @@ var meshCrudHandlers = {
|
|
|
49876
49903
|
normalizeRepoMeshDeclarativeConfig: normalizeRepoMeshDeclarativeConfig2,
|
|
49877
49904
|
MESH_JSON_CONFIG_LOCATIONS: MESH_JSON_CONFIG_LOCATIONS2
|
|
49878
49905
|
} = await Promise.resolve().then(() => (init_mesh_json_config(), mesh_json_config_exports));
|
|
49879
|
-
const { mkdirSync:
|
|
49880
|
-
const { dirname: dirname17, join:
|
|
49906
|
+
const { mkdirSync: mkdirSync22, writeFileSync: writeFileSync24 } = await import("fs");
|
|
49907
|
+
const { dirname: dirname17, join: join50 } = await import("path");
|
|
49881
49908
|
const scaffold = buildMeshJsonConfigScaffold2(mesh);
|
|
49882
49909
|
const scaffoldJson = serializeMeshJsonConfigScaffold2(scaffold);
|
|
49883
49910
|
const relativePath = MESH_JSON_CONFIG_LOCATIONS2[0];
|
|
49884
|
-
const absolutePath =
|
|
49911
|
+
const absolutePath = join50(workspace, relativePath);
|
|
49885
49912
|
const validation = normalizeRepoMeshDeclarativeConfig2(scaffold);
|
|
49886
49913
|
if (!validation.valid) {
|
|
49887
49914
|
return { success: false, meshId, error: `invalid mesh.json scaffold: ${validation.errors.join("; ")}` };
|
|
@@ -49917,7 +49944,7 @@ var meshCrudHandlers = {
|
|
|
49917
49944
|
note: "Dry-run: nothing written. Re-run with write=true to persist to the repo (commit target). meshes.json is untouched."
|
|
49918
49945
|
};
|
|
49919
49946
|
}
|
|
49920
|
-
|
|
49947
|
+
mkdirSync22(dirname17(absolutePath), { recursive: true });
|
|
49921
49948
|
writeFileSync24(absolutePath, `${scaffoldJson}
|
|
49922
49949
|
`, "utf-8");
|
|
49923
49950
|
return {
|
|
@@ -50125,6 +50152,8 @@ var meshCrudHandlers = {
|
|
|
50125
50152
|
const sessionIds = Array.isArray(args?.sessionIds) ? args.sessionIds.map((id) => typeof id === "string" ? id.trim() : "").filter(Boolean) : void 0;
|
|
50126
50153
|
const source = args?.source === "magi_session_cleanup" ? "magi_session_cleanup" : "mesh_cleanup_sessions";
|
|
50127
50154
|
const requireAutoLaunchedForTaskIds = args?.requireAutoLaunchedForTaskIds && typeof args.requireAutoLaunchedForTaskIds === "object" && !Array.isArray(args.requireAutoLaunchedForTaskIds) ? args.requireAutoLaunchedForTaskIds : void 0;
|
|
50155
|
+
const reclaimOrphans = args?.reclaimOrphans === true;
|
|
50156
|
+
const liveMeshNodeIds = Array.isArray(mesh?.nodes) ? mesh.nodes.map((n) => normalizeMeshNodeId(n)).filter(Boolean) : [];
|
|
50128
50157
|
const result = await ctx.cleanupMeshSessions({
|
|
50129
50158
|
meshId,
|
|
50130
50159
|
nodeId,
|
|
@@ -50133,7 +50162,9 @@ var meshCrudHandlers = {
|
|
|
50133
50162
|
sessionIds,
|
|
50134
50163
|
dryRun: args?.dryRun === true,
|
|
50135
50164
|
source,
|
|
50136
|
-
requireAutoLaunchedForTaskIds
|
|
50165
|
+
requireAutoLaunchedForTaskIds,
|
|
50166
|
+
reclaimOrphans,
|
|
50167
|
+
liveMeshNodeIds
|
|
50137
50168
|
});
|
|
50138
50169
|
return result;
|
|
50139
50170
|
} catch (e) {
|
|
@@ -50481,7 +50512,7 @@ var meshCrudHandlers = {
|
|
|
50481
50512
|
const setupPromise = finishWorktreeSetup();
|
|
50482
50513
|
const setupResult = await Promise.race([
|
|
50483
50514
|
setupPromise.then((value) => ({ completed: true, value })),
|
|
50484
|
-
new Promise((
|
|
50515
|
+
new Promise((resolve25) => setTimeout(() => resolve25({ completed: false }), setupWaitMs))
|
|
50485
50516
|
]);
|
|
50486
50517
|
const emitBootstrapEvent = (eventStatus2, bootstrapState2, startedAtMs, extraPayload) => {
|
|
50487
50518
|
try {
|
|
@@ -51718,7 +51749,7 @@ ${ptyResult.output.slice(-2e3)}`);
|
|
|
51718
51749
|
workspace
|
|
51719
51750
|
};
|
|
51720
51751
|
}
|
|
51721
|
-
const { existsSync:
|
|
51752
|
+
const { existsSync: existsSync54, readFileSync: readFileSync42, writeFileSync: writeFileSync24, copyFileSync: copyFileSync4, mkdirSync: mkdirSync22 } = await import("fs");
|
|
51722
51753
|
const { dirname: dirname17 } = await import("path");
|
|
51723
51754
|
const mcpConfigPath = coordinatorSetup.configPath;
|
|
51724
51755
|
const hermesManualFallback = cliType === "hermes-cli" && configFormat === "hermes_config_yaml" ? createHermesManualMeshCoordinatorSetup(meshId, workspace) : null;
|
|
@@ -51754,21 +51785,21 @@ ${ptyResult.output.slice(-2e3)}`);
|
|
|
51754
51785
|
};
|
|
51755
51786
|
}
|
|
51756
51787
|
try {
|
|
51757
|
-
|
|
51788
|
+
mkdirSync22(dirname17(mcpConfigPath), { recursive: true });
|
|
51758
51789
|
} catch (error) {
|
|
51759
51790
|
const message = `Could not prepare MCP config path for automatic setup: ${error?.message || error}`;
|
|
51760
51791
|
LOG.error("MeshCoordinator", message);
|
|
51761
51792
|
if (hermesManualFallback) return returnManualFallback(message);
|
|
51762
51793
|
return { success: false, code: "mesh_coordinator_config_write_failed", error: message, meshId, cliType, workspace };
|
|
51763
51794
|
}
|
|
51764
|
-
const hadExistingMcpConfig =
|
|
51795
|
+
const hadExistingMcpConfig = existsSync54(mcpConfigPath);
|
|
51765
51796
|
let existingMcpConfig = hermesBaseConfig?.config || {};
|
|
51766
51797
|
if (hermesBaseConfig) {
|
|
51767
51798
|
copyHermesCoordinatorCredentialFiles(hermesBaseConfig.sourceHome, dirname17(mcpConfigPath));
|
|
51768
51799
|
}
|
|
51769
51800
|
if (hadExistingMcpConfig) {
|
|
51770
51801
|
try {
|
|
51771
|
-
const parsedExistingMcpConfig = parseMeshCoordinatorMcpConfig(
|
|
51802
|
+
const parsedExistingMcpConfig = parseMeshCoordinatorMcpConfig(readFileSync42(mcpConfigPath, "utf-8"), configFormat);
|
|
51772
51803
|
const existingCoordinatorConfig = hermesManualFallback ? stripHermesCoordinatorTempModelProviderOverrides(parsedExistingMcpConfig) : parsedExistingMcpConfig;
|
|
51773
51804
|
existingMcpConfig = { ...existingMcpConfig, ...existingCoordinatorConfig };
|
|
51774
51805
|
copyFileSync4(mcpConfigPath, mcpConfigPath + ".backup");
|
|
@@ -51912,10 +51943,10 @@ function runGit2(repoRoot, args) {
|
|
|
51912
51943
|
}
|
|
51913
51944
|
}
|
|
51914
51945
|
function readRecord6(repoRoot) {
|
|
51915
|
-
const
|
|
51916
|
-
if (!existsSync40(
|
|
51946
|
+
const path44 = resolve19(repoRoot, PREVIEW_DEPLOY_RECORD);
|
|
51947
|
+
if (!existsSync40(path44)) return null;
|
|
51917
51948
|
try {
|
|
51918
|
-
const parsed = JSON.parse(readFileSync31(
|
|
51949
|
+
const parsed = JSON.parse(readFileSync31(path44, "utf8"));
|
|
51919
51950
|
return parsed && typeof parsed === "object" && !Array.isArray(parsed) ? parsed : null;
|
|
51920
51951
|
} catch {
|
|
51921
51952
|
return null;
|
|
@@ -52470,7 +52501,7 @@ var meshStatusHandlers = {
|
|
|
52470
52501
|
const { deriveMeshReviewInboxItems: deriveMeshReviewInboxItems2 } = await Promise.resolve().then(() => (init_mesh_review_inbox(), mesh_review_inbox_exports));
|
|
52471
52502
|
const { readLedgerEntries: readLedgerEntries2 } = await Promise.resolve().then(() => (init_mesh_ledger(), mesh_ledger_exports));
|
|
52472
52503
|
const { getGitDiffSummary: getGitDiffSummary2 } = await Promise.resolve().then(() => (init_git_diff(), git_diff_exports));
|
|
52473
|
-
const { existsSync:
|
|
52504
|
+
const { existsSync: existsSync54 } = await import("fs");
|
|
52474
52505
|
const meshRecord = await ctx.getMeshForCommand(meshId, args?.inlineMesh, { preferInline: true });
|
|
52475
52506
|
const mesh = meshRecord?.mesh;
|
|
52476
52507
|
if (!mesh) return { success: false, error: "Mesh not found" };
|
|
@@ -52489,7 +52520,7 @@ var meshStatusHandlers = {
|
|
|
52489
52520
|
const derivation = deriveMeshReviewInboxItems2({ nodes: nodeStatuses, ledgerEntries });
|
|
52490
52521
|
for (const item of derivation.items) {
|
|
52491
52522
|
const workspace = item.workspace;
|
|
52492
|
-
if (!workspace || !
|
|
52523
|
+
if (!workspace || !existsSync54(workspace)) continue;
|
|
52493
52524
|
const baseRef = item.defaultBranch ? `origin/${item.defaultBranch}` : "origin/main";
|
|
52494
52525
|
try {
|
|
52495
52526
|
const diffResult = await getGitDiffSummary2(workspace, { baseRef, maxFiles: 100 });
|
|
@@ -52697,9 +52728,9 @@ import { promisify as promisify6 } from "util";
|
|
|
52697
52728
|
var execFileAsync3 = promisify6(execFile4);
|
|
52698
52729
|
var GIT = process.platform === "win32" ? resolveWin32Executable("git") : "git";
|
|
52699
52730
|
var MAX_CHANGED_FILES2 = 500;
|
|
52700
|
-
function topLevel(
|
|
52701
|
-
const slash =
|
|
52702
|
-
return slash === -1 ?
|
|
52731
|
+
function topLevel(path44) {
|
|
52732
|
+
const slash = path44.indexOf("/");
|
|
52733
|
+
return slash === -1 ? path44 : path44.slice(0, slash);
|
|
52703
52734
|
}
|
|
52704
52735
|
async function analyzeMeshRefineNodeChangeArea(args) {
|
|
52705
52736
|
const { nodeId, workspace, branch, baseRef, branchRef, diffCwd, submodulePaths } = args;
|
|
@@ -53757,7 +53788,7 @@ async function probeRemoteMeshGitStatusWithRetry(args) {
|
|
|
53757
53788
|
const connection = args.getConnection?.(args.daemonId);
|
|
53758
53789
|
if (args.getConnection && readMeshConnectionState(connection) !== "connected") break;
|
|
53759
53790
|
if (connection) args.onConnection?.(connection);
|
|
53760
|
-
await new Promise((
|
|
53791
|
+
await new Promise((resolve25) => setTimeout(resolve25, 250 * 2 ** (attempt - 1)));
|
|
53761
53792
|
}
|
|
53762
53793
|
try {
|
|
53763
53794
|
const remoteGit = await probeRemoteMeshGitStatus({
|
|
@@ -54134,18 +54165,18 @@ function resolveRefineryAutoPublishSubmoduleMainCommits(mesh, workspace) {
|
|
|
54134
54165
|
return { enabled: false };
|
|
54135
54166
|
}
|
|
54136
54167
|
async function computeGitPatchId(cwd, fromRef, toRef, excludePaths = []) {
|
|
54137
|
-
const { execFileSync:
|
|
54168
|
+
const { execFileSync: execFileSync10 } = await import("child_process");
|
|
54138
54169
|
const diffArgs = ["diff", "--patch", "--full-index", fromRef, toRef];
|
|
54139
54170
|
if (excludePaths.length > 0) {
|
|
54140
|
-
diffArgs.push("--", ".", ...excludePaths.map((
|
|
54171
|
+
diffArgs.push("--", ".", ...excludePaths.map((path44) => `:(exclude)${path44}`));
|
|
54141
54172
|
}
|
|
54142
|
-
const diff =
|
|
54173
|
+
const diff = execFileSync10(GIT2, diffArgs, {
|
|
54143
54174
|
cwd,
|
|
54144
54175
|
encoding: "utf8",
|
|
54145
54176
|
maxBuffer: REFINE_PATCH_EQUIVALENCE_OUTPUT_LIMIT_BYTES
|
|
54146
54177
|
});
|
|
54147
54178
|
if (!diff.trim()) return "";
|
|
54148
|
-
const patchId =
|
|
54179
|
+
const patchId = execFileSync10(GIT2, ["patch-id", "--stable"], {
|
|
54149
54180
|
cwd,
|
|
54150
54181
|
input: diff,
|
|
54151
54182
|
encoding: "utf8",
|
|
@@ -54156,8 +54187,8 @@ async function computeGitPatchId(cwd, fromRef, toRef, excludePaths = []) {
|
|
|
54156
54187
|
async function runMeshRefinePatchEquivalenceGate(repoRoot, baseHead, branchHead) {
|
|
54157
54188
|
const startedAt = Date.now();
|
|
54158
54189
|
try {
|
|
54159
|
-
const { execFileSync:
|
|
54160
|
-
const git = (args) =>
|
|
54190
|
+
const { execFileSync: execFileSync10 } = await import("child_process");
|
|
54191
|
+
const git = (args) => execFileSync10(GIT2, args, {
|
|
54161
54192
|
cwd: repoRoot,
|
|
54162
54193
|
encoding: "utf8",
|
|
54163
54194
|
maxBuffer: REFINE_PATCH_EQUIVALENCE_OUTPUT_LIMIT_BYTES
|
|
@@ -54248,8 +54279,8 @@ ${e?.stderr || ""}`
|
|
|
54248
54279
|
async function checkWorktreeChangesPatchEquivalentInRef(repoRoot, ref, worktreeHead) {
|
|
54249
54280
|
const startedAt = Date.now();
|
|
54250
54281
|
try {
|
|
54251
|
-
const { execFileSync:
|
|
54252
|
-
const git = (gitArgs) =>
|
|
54282
|
+
const { execFileSync: execFileSync10 } = await import("child_process");
|
|
54283
|
+
const git = (gitArgs) => execFileSync10(GIT2, gitArgs, {
|
|
54253
54284
|
cwd: repoRoot,
|
|
54254
54285
|
encoding: "utf8",
|
|
54255
54286
|
maxBuffer: REFINE_PATCH_EQUIVALENCE_OUTPUT_LIMIT_BYTES
|
|
@@ -54312,8 +54343,8 @@ ${mergeTreeErr?.stderr || ""}`;
|
|
|
54312
54343
|
async function runMeshRefineEffectiveDiffGate(repoRoot, baseHead, branchHead) {
|
|
54313
54344
|
const startedAt = Date.now();
|
|
54314
54345
|
try {
|
|
54315
|
-
const { execFileSync:
|
|
54316
|
-
const git = (args, opts) =>
|
|
54346
|
+
const { execFileSync: execFileSync10 } = await import("child_process");
|
|
54347
|
+
const git = (args, opts) => execFileSync10(GIT2, args, {
|
|
54317
54348
|
cwd: opts?.cwd || repoRoot,
|
|
54318
54349
|
encoding: "utf8",
|
|
54319
54350
|
maxBuffer: REFINE_PATCH_EQUIVALENCE_OUTPUT_LIMIT_BYTES
|
|
@@ -54338,9 +54369,9 @@ async function runMeshRefineEffectiveDiffGate(repoRoot, baseHead, branchHead) {
|
|
|
54338
54369
|
if (!trimmed) continue;
|
|
54339
54370
|
if (trimmed.startsWith("+")) {
|
|
54340
54371
|
const parts = trimmed.slice(1).trim().split(/\s+/);
|
|
54341
|
-
const
|
|
54372
|
+
const path44 = parts[1] || parts[0] || "(unknown)";
|
|
54342
54373
|
submoduleHints.push({
|
|
54343
|
-
path:
|
|
54374
|
+
path: path44,
|
|
54344
54375
|
reason: "submodule checked-out commit differs from the committed gitlink (pointer bump not committed on the root branch)"
|
|
54345
54376
|
});
|
|
54346
54377
|
}
|
|
@@ -54370,10 +54401,10 @@ async function runMeshRefineEffectiveDiffGate(repoRoot, baseHead, branchHead) {
|
|
|
54370
54401
|
}
|
|
54371
54402
|
function buildPatchEquivalenceSubmoduleConflictHint(repoRoot, baseHead, branchHead, output) {
|
|
54372
54403
|
if (!/(submodule|160000)/i.test(output) || !/(conflict|failed to merge)/i.test(output)) return void 0;
|
|
54373
|
-
const conflicts = readChangedGitlinkPaths(repoRoot, baseHead, branchHead).map((
|
|
54374
|
-
path:
|
|
54375
|
-
baseCommit: readTreeObject(repoRoot, baseHead,
|
|
54376
|
-
branchCommit: readTreeObject(repoRoot, branchHead,
|
|
54404
|
+
const conflicts = readChangedGitlinkPaths(repoRoot, baseHead, branchHead).map((path44) => ({
|
|
54405
|
+
path: path44,
|
|
54406
|
+
baseCommit: readTreeObject(repoRoot, baseHead, path44),
|
|
54407
|
+
branchCommit: readTreeObject(repoRoot, branchHead, path44)
|
|
54377
54408
|
}));
|
|
54378
54409
|
if (conflicts.length === 0) return void 0;
|
|
54379
54410
|
return {
|
|
@@ -54399,11 +54430,11 @@ function readChangedGitlinkPaths(repoRoot, fromRef, toRef) {
|
|
|
54399
54430
|
if (!line.trim()) continue;
|
|
54400
54431
|
const metaAndPath = line.split(" ");
|
|
54401
54432
|
const meta = metaAndPath[0] || "";
|
|
54402
|
-
const
|
|
54403
|
-
if (!
|
|
54433
|
+
const path44 = metaAndPath[metaAndPath.length - 1]?.trim();
|
|
54434
|
+
if (!path44) continue;
|
|
54404
54435
|
const parts = meta.split(/\s+/);
|
|
54405
54436
|
if (parts[0]?.includes("160000") || parts[1]?.includes("160000")) {
|
|
54406
|
-
paths.add(
|
|
54437
|
+
paths.add(path44);
|
|
54407
54438
|
}
|
|
54408
54439
|
}
|
|
54409
54440
|
return [...paths].sort();
|
|
@@ -54411,9 +54442,9 @@ function readChangedGitlinkPaths(repoRoot, fromRef, toRef) {
|
|
|
54411
54442
|
return [];
|
|
54412
54443
|
}
|
|
54413
54444
|
}
|
|
54414
|
-
function readTreeObject(repoRoot, ref,
|
|
54445
|
+
function readTreeObject(repoRoot, ref, path44) {
|
|
54415
54446
|
try {
|
|
54416
|
-
const output = execFileSync7(GIT2, ["ls-tree", ref, "--",
|
|
54447
|
+
const output = execFileSync7(GIT2, ["ls-tree", ref, "--", path44], {
|
|
54417
54448
|
cwd: repoRoot,
|
|
54418
54449
|
encoding: "utf8",
|
|
54419
54450
|
maxBuffer: 1024 * 1024
|
|
@@ -54458,12 +54489,12 @@ function readChangedPathKinds(repoRoot, fromRef, toRef) {
|
|
|
54458
54489
|
if (!line.trim()) continue;
|
|
54459
54490
|
const metaAndPath = line.split(" ");
|
|
54460
54491
|
const meta = metaAndPath[0] || "";
|
|
54461
|
-
const
|
|
54462
|
-
if (!
|
|
54463
|
-
seen.add(
|
|
54492
|
+
const path44 = metaAndPath[metaAndPath.length - 1]?.trim();
|
|
54493
|
+
if (!path44 || seen.has(path44)) continue;
|
|
54494
|
+
seen.add(path44);
|
|
54464
54495
|
const parts = meta.split(/\s+/);
|
|
54465
54496
|
const isGitlink = !!(parts[0]?.includes("160000") || parts[1]?.includes("160000"));
|
|
54466
|
-
result.push({ path:
|
|
54497
|
+
result.push({ path: path44, isGitlink });
|
|
54467
54498
|
}
|
|
54468
54499
|
return result;
|
|
54469
54500
|
} catch {
|
|
@@ -54471,20 +54502,20 @@ function readChangedPathKinds(repoRoot, fromRef, toRef) {
|
|
|
54471
54502
|
}
|
|
54472
54503
|
}
|
|
54473
54504
|
function collectFastForwardGitlinkPaths(repoRoot, baseHead, branchHead) {
|
|
54474
|
-
return readChangedGitlinkPaths(repoRoot, baseHead, branchHead).filter((
|
|
54475
|
-
const baseCommit = readTreeObject(repoRoot, baseHead,
|
|
54476
|
-
const branchCommit = readTreeObject(repoRoot, branchHead,
|
|
54505
|
+
return readChangedGitlinkPaths(repoRoot, baseHead, branchHead).filter((path44) => {
|
|
54506
|
+
const baseCommit = readTreeObject(repoRoot, baseHead, path44);
|
|
54507
|
+
const branchCommit = readTreeObject(repoRoot, branchHead, path44);
|
|
54477
54508
|
if (!baseCommit || !branchCommit) return false;
|
|
54478
|
-
return isSubmoduleFastForward(pathResolve2(repoRoot,
|
|
54509
|
+
return isSubmoduleFastForward(pathResolve2(repoRoot, path44), baseCommit, branchCommit);
|
|
54479
54510
|
});
|
|
54480
54511
|
}
|
|
54481
54512
|
function evaluateGitlinkTrivialFastForward(repoRoot, baseHead, branchHead) {
|
|
54482
|
-
const changedGitlinks = readChangedGitlinkPaths(repoRoot, baseHead, branchHead).map((
|
|
54483
|
-
const baseCommit = readTreeObject(repoRoot, baseHead,
|
|
54484
|
-
const branchCommit = readTreeObject(repoRoot, branchHead,
|
|
54485
|
-
const submoduleRepoPath = pathResolve2(repoRoot,
|
|
54513
|
+
const changedGitlinks = readChangedGitlinkPaths(repoRoot, baseHead, branchHead).map((path44) => {
|
|
54514
|
+
const baseCommit = readTreeObject(repoRoot, baseHead, path44);
|
|
54515
|
+
const branchCommit = readTreeObject(repoRoot, branchHead, path44);
|
|
54516
|
+
const submoduleRepoPath = pathResolve2(repoRoot, path44);
|
|
54486
54517
|
const fastForward = !!baseCommit && !!branchCommit && isSubmoduleFastForward(submoduleRepoPath, baseCommit, branchCommit);
|
|
54487
|
-
return { path:
|
|
54518
|
+
return { path: path44, baseCommit, branchCommit, fastForward };
|
|
54488
54519
|
});
|
|
54489
54520
|
if (changedGitlinks.length === 0) {
|
|
54490
54521
|
return { trivial: false, reason: "no_changed_gitlinks", gitlinks: changedGitlinks };
|
|
@@ -54535,7 +54566,7 @@ function buildTreeWithGitlinksEqualized(repoRoot, commitish, paths, placeholderC
|
|
|
54535
54566
|
maxBuffer: 1024 * 1024
|
|
54536
54567
|
}).trim();
|
|
54537
54568
|
if (!tree) return void 0;
|
|
54538
|
-
const updates = paths.map((
|
|
54569
|
+
const updates = paths.map((path44) => `160000 commit ${placeholderCommit} ${path44}`).join("\n");
|
|
54539
54570
|
if (!updates) return tree;
|
|
54540
54571
|
const tmpIndex = pathJoin2(resolveGitDir(repoRoot), `adhdev-refine-eq-${commitish.slice(0, 12)}.index`);
|
|
54541
54572
|
const env = { ...process.env, GIT_INDEX_FILE: tmpIndex };
|
|
@@ -54638,7 +54669,7 @@ function synthesizeTrivialFastForwardMergeTree(repoRoot, baseHead, branchHead, g
|
|
|
54638
54669
|
}
|
|
54639
54670
|
async function alignRefinerySubmodulesAfterMerge(repoRoot, previousBaseHead, currentHead, options = {}) {
|
|
54640
54671
|
const startedAt = Date.now();
|
|
54641
|
-
const changedGitlinkPaths = readChangedGitlinkPaths(repoRoot, previousBaseHead, currentHead).filter((
|
|
54672
|
+
const changedGitlinkPaths = readChangedGitlinkPaths(repoRoot, previousBaseHead, currentHead).filter((path44) => !(options.submoduleIgnorePaths || []).includes(path44));
|
|
54642
54673
|
const preStatus = await getGitRepoStatus(repoRoot, {
|
|
54643
54674
|
includeSubmodules: true,
|
|
54644
54675
|
submoduleIgnorePaths: options.submoduleIgnorePaths,
|
|
@@ -54685,7 +54716,7 @@ async function alignRefinerySubmodulesAfterMerge(repoRoot, previousBaseHead, cur
|
|
|
54685
54716
|
changedGitlinkPaths,
|
|
54686
54717
|
outOfSyncPaths,
|
|
54687
54718
|
updatedPaths: updatePaths,
|
|
54688
|
-
verifiedPaths: updatePaths.filter((
|
|
54719
|
+
verifiedPaths: updatePaths.filter((path44) => !remaining.some((submodule) => submodule.path === path44)),
|
|
54689
54720
|
durationMs: Date.now() - startedAt,
|
|
54690
54721
|
command: `git ${commandArgs.join(" ")}`,
|
|
54691
54722
|
stdout: truncateValidationOutput(result.stdout),
|
|
@@ -55011,15 +55042,15 @@ async function runMeshRefineValidationGate(mesh, workspace, opts) {
|
|
|
55011
55042
|
const cwd = candidate.cwd ? pathResolve2(workspace, candidate.cwd) : workspace;
|
|
55012
55043
|
const timeout = candidate.timeoutMs || REFINE_VALIDATION_TIMEOUT_MS;
|
|
55013
55044
|
const resolvedCommand = resolveWin32Executable(candidate.command);
|
|
55014
|
-
const
|
|
55045
|
+
const spawn5 = buildWin32ExecFileSpawn(resolvedCommand, candidate.args);
|
|
55015
55046
|
try {
|
|
55016
|
-
const result = await execFileAsync4(
|
|
55047
|
+
const result = await execFileAsync4(spawn5.file, spawn5.args, {
|
|
55017
55048
|
cwd,
|
|
55018
55049
|
encoding: "utf8",
|
|
55019
55050
|
timeout,
|
|
55020
55051
|
maxBuffer: candidate.outputLimitBytes || REFINE_VALIDATION_OUTPUT_LIMIT_BYTES,
|
|
55021
55052
|
env: { ...process.env, CI: process.env.CI || "1", ...candidate.env || {} },
|
|
55022
|
-
...
|
|
55053
|
+
...spawn5.windowsVerbatimArguments ? { windowsVerbatimArguments: true } : {}
|
|
55023
55054
|
});
|
|
55024
55055
|
summary.bootstrapCommandsRun.push(commandRecord(candidate, cwd, startedAt, result, true, { exitCode: 0 }));
|
|
55025
55056
|
} catch (error) {
|
|
@@ -55057,15 +55088,15 @@ async function runMeshRefineValidationGate(mesh, workspace, opts) {
|
|
|
55057
55088
|
return summary;
|
|
55058
55089
|
}
|
|
55059
55090
|
const resolvedCommand = resolveWin32Executable(candidate.command);
|
|
55060
|
-
const
|
|
55091
|
+
const spawn5 = buildWin32ExecFileSpawn(resolvedCommand, candidate.args);
|
|
55061
55092
|
try {
|
|
55062
|
-
const result = await execFileAsync4(
|
|
55093
|
+
const result = await execFileAsync4(spawn5.file, spawn5.args, {
|
|
55063
55094
|
cwd,
|
|
55064
55095
|
encoding: "utf8",
|
|
55065
55096
|
timeout,
|
|
55066
55097
|
maxBuffer: candidate.outputLimitBytes || REFINE_VALIDATION_OUTPUT_LIMIT_BYTES,
|
|
55067
55098
|
env: { ...process.env, CI: process.env.CI || "1", ...candidate.env || {} },
|
|
55068
|
-
...
|
|
55099
|
+
...spawn5.windowsVerbatimArguments ? { windowsVerbatimArguments: true } : {}
|
|
55069
55100
|
});
|
|
55070
55101
|
summary.commandsRun.push(commandRecord(candidate, cwd, startedAt, result, true, { exitCode: 0 }));
|
|
55071
55102
|
} catch (error) {
|
|
@@ -55774,7 +55805,7 @@ var DaemonCommandRouter = class {
|
|
|
55774
55805
|
*/
|
|
55775
55806
|
async bestEffortRemoveWorktreeDir(dir) {
|
|
55776
55807
|
if (!dir || !fs32.existsSync(dir)) return { removed: true, residue: false };
|
|
55777
|
-
const sleep3 = (ms) => new Promise((
|
|
55808
|
+
const sleep3 = (ms) => new Promise((resolve25) => setTimeout(resolve25, ms));
|
|
55778
55809
|
const ABSORB = /* @__PURE__ */ new Set(["EINVAL", "EPERM", "EBUSY", "ENOTEMPTY", "EACCES", "EMFILE", "ENFILE"]);
|
|
55779
55810
|
let lastErr;
|
|
55780
55811
|
for (let attempt = 0; attempt < 4; attempt++) {
|
|
@@ -56218,6 +56249,13 @@ var DaemonCommandRouter = class {
|
|
|
56218
56249
|
}
|
|
56219
56250
|
if (!this.deps.sessionHostControl) return { success: false, error: "Session host control unavailable" };
|
|
56220
56251
|
const requestedSessionIds = Array.isArray(args.sessionIds) ? new Set(args.sessionIds.map((id) => typeof id === "string" ? id.trim() : "").filter(Boolean)) : void 0;
|
|
56252
|
+
const reclaimOrphans = args.reclaimOrphans === true;
|
|
56253
|
+
const liveMeshNodeIds = Array.isArray(args.liveMeshNodeIds) ? args.liveMeshNodeIds.map((id) => typeof id === "string" ? id.trim() : "").filter(Boolean) : [];
|
|
56254
|
+
const isNodeStillLive = (candidateNodeId) => {
|
|
56255
|
+
if (!candidateNodeId) return false;
|
|
56256
|
+
return liveMeshNodeIds.some((liveId) => liveId === candidateNodeId || meshNodeIdMatches({ id: liveId }, candidateNodeId) || daemonIdsEquivalent(liveId, candidateNodeId));
|
|
56257
|
+
};
|
|
56258
|
+
const reclaimedOrphanSessionIds = [];
|
|
56221
56259
|
const sessions = await this.deps.sessionHostControl.listSessions();
|
|
56222
56260
|
const matched = sessions.filter((record) => this.sessionMatchesMeshNode(record, args.node, args.nodeId, requestedSessionIds));
|
|
56223
56261
|
const hasExplicitSessionIds = !!requestedSessionIds?.size;
|
|
@@ -56286,7 +56324,8 @@ var DaemonCommandRouter = class {
|
|
|
56286
56324
|
const matchedByWorkspaceOnly = !recordNodeId;
|
|
56287
56325
|
const isWorktreeNodeRemoval = cleanupSource === "mesh_remove_node" && args.node?.isLocalWorktree === true;
|
|
56288
56326
|
const cleanWorkspaceOnlyForWorktree = isWorktreeNodeRemoval && matchedByWorkspaceOnly;
|
|
56289
|
-
|
|
56327
|
+
const reclaimableOrphan = reclaimOrphans && liveRuntime && !delegateBoundToThisNode && (matchedByWorkspaceOnly || !isNodeStillLive(recordNodeId));
|
|
56328
|
+
if (!hasExplicitSessionIds && liveRuntime && !delegateBoundToThisNode && !cleanWorkspaceOnlyForWorktree && !reclaimableOrphan) {
|
|
56290
56329
|
skippedSessionIds.push(sessionId);
|
|
56291
56330
|
skippedLiveSessionIds.push(sessionId);
|
|
56292
56331
|
const reason = recordNodeId && recordNodeId !== args.nodeId ? `live_delegate_bound_to_other_node:${recordNodeId}` : matchedByWorkspaceOnly ? "live_session_matched_by_workspace_only_no_node_binding" : "live_session_not_bound_to_this_node";
|
|
@@ -56296,6 +56335,10 @@ var DaemonCommandRouter = class {
|
|
|
56296
56335
|
if (cleanWorkspaceOnlyForWorktree && !delegateBoundToThisNode) {
|
|
56297
56336
|
actedLiveDelegateSessionIds.push(sessionId);
|
|
56298
56337
|
}
|
|
56338
|
+
if (reclaimableOrphan && !cleanWorkspaceOnlyForWorktree && !delegateBoundToThisNode) {
|
|
56339
|
+
reclaimedOrphanSessionIds.push(sessionId);
|
|
56340
|
+
actedLiveDelegateSessionIds.push(sessionId);
|
|
56341
|
+
}
|
|
56299
56342
|
if (!hasExplicitSessionIds && liveRuntime && delegateBoundToThisNode && args.mode === "delete_stopped") {
|
|
56300
56343
|
skippedSessionIds.push(sessionId);
|
|
56301
56344
|
skippedLiveSessionIds.push(sessionId);
|
|
@@ -56368,6 +56411,7 @@ var DaemonCommandRouter = class {
|
|
|
56368
56411
|
skippedCoordinatorSessionIds,
|
|
56369
56412
|
...skippedMarkerMismatchSessionIds.length ? { skippedMarkerMismatchSessionIds } : {},
|
|
56370
56413
|
...actedLiveDelegateSessionIds.length ? { actedLiveDelegateSessionIds } : {},
|
|
56414
|
+
...reclaimedOrphanSessionIds.length ? { reclaimedOrphanSessionIds } : {},
|
|
56371
56415
|
...skippedLiveSessionReasons.length ? { skippedLiveSessionReasons } : {},
|
|
56372
56416
|
...deleteUnsupported ? {
|
|
56373
56417
|
deleteUnsupported: true,
|
|
@@ -58532,7 +58576,7 @@ var ProviderStreamAdapter = class {
|
|
|
58532
58576
|
const beforeCount = this.messageCount(before);
|
|
58533
58577
|
const beforeSignature = this.lastMessageSignature(before);
|
|
58534
58578
|
for (let attempt = 0; attempt < 12; attempt += 1) {
|
|
58535
|
-
await new Promise((
|
|
58579
|
+
await new Promise((resolve25) => setTimeout(resolve25, 250));
|
|
58536
58580
|
let state;
|
|
58537
58581
|
try {
|
|
58538
58582
|
state = await this.readChat(evaluate);
|
|
@@ -58554,7 +58598,7 @@ var ProviderStreamAdapter = class {
|
|
|
58554
58598
|
if (this.messageCount(first) > 0 || this.lastMessageSignature(first)) {
|
|
58555
58599
|
return first;
|
|
58556
58600
|
}
|
|
58557
|
-
await new Promise((
|
|
58601
|
+
await new Promise((resolve25) => setTimeout(resolve25, 150));
|
|
58558
58602
|
const second = await this.readChat(evaluate);
|
|
58559
58603
|
return this.messageCount(second) >= this.messageCount(first) ? second : first;
|
|
58560
58604
|
}
|
|
@@ -58705,7 +58749,7 @@ var ProviderStreamAdapter = class {
|
|
|
58705
58749
|
if (typeof data.error === "string" && data.error.trim()) return false;
|
|
58706
58750
|
}
|
|
58707
58751
|
for (let attempt = 0; attempt < 6; attempt += 1) {
|
|
58708
|
-
await new Promise((
|
|
58752
|
+
await new Promise((resolve25) => setTimeout(resolve25, 250));
|
|
58709
58753
|
const state = await this.readChat(evaluate);
|
|
58710
58754
|
const title = this.getStateTitle(state);
|
|
58711
58755
|
if (this.titlesMatch(title, sessionId)) return true;
|
|
@@ -59697,13 +59741,13 @@ var VersionArchive = class {
|
|
|
59697
59741
|
}
|
|
59698
59742
|
};
|
|
59699
59743
|
async function runCommand(cmd, timeout = 1e4) {
|
|
59700
|
-
return new Promise((
|
|
59744
|
+
return new Promise((resolve25) => {
|
|
59701
59745
|
exec5(cmd, {
|
|
59702
59746
|
encoding: "utf-8",
|
|
59703
59747
|
timeout
|
|
59704
59748
|
}, (error, stdout) => {
|
|
59705
|
-
if (error) return
|
|
59706
|
-
|
|
59749
|
+
if (error) return resolve25(null);
|
|
59750
|
+
resolve25(stdout.trim());
|
|
59707
59751
|
});
|
|
59708
59752
|
});
|
|
59709
59753
|
}
|
|
@@ -61403,7 +61447,7 @@ function getCliTargetBundle(ctx, type, instanceId) {
|
|
|
61403
61447
|
return { target, instance, adapter };
|
|
61404
61448
|
}
|
|
61405
61449
|
function sleep2(ms) {
|
|
61406
|
-
return new Promise((
|
|
61450
|
+
return new Promise((resolve25) => setTimeout(resolve25, ms));
|
|
61407
61451
|
}
|
|
61408
61452
|
async function waitForCliReady(ctx, type, instanceId, timeoutMs) {
|
|
61409
61453
|
const startedAt = Date.now();
|
|
@@ -62379,8 +62423,8 @@ async function handleAutoImplement(ctx, type, req, res) {
|
|
|
62379
62423
|
fs36.writeFileSync(promptFile, prompt, "utf-8");
|
|
62380
62424
|
ctx.log(`Auto-implement prompt written to ${promptFile} (${prompt.length} chars)`);
|
|
62381
62425
|
const agentProvider = ctx.providerLoader.resolve(agent) || ctx.providerLoader.getMeta(agent);
|
|
62382
|
-
const
|
|
62383
|
-
if (!
|
|
62426
|
+
const spawn5 = agentProvider?.spawn;
|
|
62427
|
+
if (!spawn5?.command) {
|
|
62384
62428
|
try {
|
|
62385
62429
|
fs36.unlinkSync(promptFile);
|
|
62386
62430
|
} catch {
|
|
@@ -62390,22 +62434,22 @@ async function handleAutoImplement(ctx, type, req, res) {
|
|
|
62390
62434
|
}
|
|
62391
62435
|
const agentCategory = agentProvider?.category;
|
|
62392
62436
|
if (agentCategory === "acp") {
|
|
62393
|
-
sendAutoImplSSE(ctx, { event: "progress", data: { function: "_init", status: "spawning", message: `Spawning ACP agent: ${
|
|
62437
|
+
sendAutoImplSSE(ctx, { event: "progress", data: { function: "_init", status: "spawning", message: `Spawning ACP agent: ${spawn5.command} ${(spawn5.args || []).join(" ")}` } });
|
|
62394
62438
|
ctx.autoImplStatus.running = true;
|
|
62395
62439
|
ctx.autoImplStatus.type = type;
|
|
62396
62440
|
const { ClientSideConnection: ClientSideConnection2, ndJsonStream: ndJsonStream2, PROTOCOL_VERSION: PROTOCOL_VERSION2 } = await import("@agentclientprotocol/sdk");
|
|
62397
62441
|
const { Readable: Readable2, Writable: Writable2 } = await import("stream");
|
|
62398
62442
|
const { spawn: spawnFn2 } = await import("child_process");
|
|
62399
|
-
const acpArgs = [...
|
|
62443
|
+
const acpArgs = [...spawn5.args || []];
|
|
62400
62444
|
if (model) {
|
|
62401
62445
|
acpArgs.push("--model", model);
|
|
62402
62446
|
ctx.log(`Auto-implement ACP using model: ${model}`);
|
|
62403
62447
|
}
|
|
62404
|
-
const child2 = spawnFn2(
|
|
62448
|
+
const child2 = spawnFn2(spawn5.command, acpArgs, {
|
|
62405
62449
|
cwd: providerDir,
|
|
62406
62450
|
stdio: ["pipe", "pipe", "pipe"],
|
|
62407
|
-
shell:
|
|
62408
|
-
env: { ...process.env, ...
|
|
62451
|
+
shell: spawn5.shell ?? false,
|
|
62452
|
+
env: { ...process.env, ...spawn5.env || {} }
|
|
62409
62453
|
});
|
|
62410
62454
|
ctx.autoImplProcess = child2;
|
|
62411
62455
|
child2.stderr?.on("data", (d) => {
|
|
@@ -62515,7 +62559,7 @@ async function handleAutoImplement(ctx, type, req, res) {
|
|
|
62515
62559
|
ctx.json(res, 202, {
|
|
62516
62560
|
started: true,
|
|
62517
62561
|
type,
|
|
62518
|
-
agent:
|
|
62562
|
+
agent: spawn5.command,
|
|
62519
62563
|
functions,
|
|
62520
62564
|
providerDir,
|
|
62521
62565
|
message: "ACP Auto-implement started. Connect to SSE for progress.",
|
|
@@ -62523,10 +62567,10 @@ async function handleAutoImplement(ctx, type, req, res) {
|
|
|
62523
62567
|
});
|
|
62524
62568
|
return;
|
|
62525
62569
|
}
|
|
62526
|
-
const command =
|
|
62527
|
-
const autoImpl =
|
|
62570
|
+
const command = spawn5.command;
|
|
62571
|
+
const autoImpl = spawn5.autoImpl;
|
|
62528
62572
|
const interactiveFlags = ["--yolo", "--interactive", "-i"];
|
|
62529
|
-
const baseArgs = [...
|
|
62573
|
+
const baseArgs = [...spawn5.args || []].filter((a) => !interactiveFlags.includes(a));
|
|
62530
62574
|
let shellCmd;
|
|
62531
62575
|
const isWin = os29.platform() === "win32";
|
|
62532
62576
|
const escapeArg = (a) => isWin ? `"${a.replace(/"/g, '""')}"` : `'${a.replace(/'/g, "'\\''")}'`;
|
|
@@ -62573,7 +62617,7 @@ async function handleAutoImplement(ctx, type, req, res) {
|
|
|
62573
62617
|
cols: DEFAULT_SESSION_HOST_COLS7,
|
|
62574
62618
|
rows: DEFAULT_SESSION_HOST_ROWS7,
|
|
62575
62619
|
cwd: providerDir,
|
|
62576
|
-
env: { ...process.env, ...
|
|
62620
|
+
env: { ...process.env, ...spawn5.env || {} }
|
|
62577
62621
|
});
|
|
62578
62622
|
isPty = true;
|
|
62579
62623
|
} catch (err) {
|
|
@@ -62585,7 +62629,7 @@ async function handleAutoImplement(ctx, type, req, res) {
|
|
|
62585
62629
|
stdio: ["pipe", "pipe", "pipe"],
|
|
62586
62630
|
env: {
|
|
62587
62631
|
...process.env,
|
|
62588
|
-
...
|
|
62632
|
+
...spawn5.env || {}
|
|
62589
62633
|
}
|
|
62590
62634
|
});
|
|
62591
62635
|
child.on("error", (err2) => {
|
|
@@ -63627,8 +63671,8 @@ var DevServer = class _DevServer {
|
|
|
63627
63671
|
}
|
|
63628
63672
|
getEndpointList() {
|
|
63629
63673
|
return this.routes.map((r) => {
|
|
63630
|
-
const
|
|
63631
|
-
return `${r.method.padEnd(5)} ${
|
|
63674
|
+
const path44 = typeof r.pattern === "string" ? r.pattern : r.pattern.source.replace(/\\\//g, "/").replace(/\(\[.*?\]\+\)/g, ":type").replace(/[\^$]/g, "");
|
|
63675
|
+
return `${r.method.padEnd(5)} ${path44}`;
|
|
63632
63676
|
});
|
|
63633
63677
|
}
|
|
63634
63678
|
async start(port = DEV_SERVER_PORT) {
|
|
@@ -63659,15 +63703,15 @@ var DevServer = class _DevServer {
|
|
|
63659
63703
|
this.json(res, 500, { error: e.message });
|
|
63660
63704
|
}
|
|
63661
63705
|
});
|
|
63662
|
-
return new Promise((
|
|
63706
|
+
return new Promise((resolve25, reject) => {
|
|
63663
63707
|
this.server.listen(port, "127.0.0.1", () => {
|
|
63664
63708
|
this.log(`Dev server listening on http://127.0.0.1:${port}`);
|
|
63665
|
-
|
|
63709
|
+
resolve25();
|
|
63666
63710
|
});
|
|
63667
63711
|
this.server.on("error", (e) => {
|
|
63668
63712
|
if (e.code === "EADDRINUSE") {
|
|
63669
63713
|
this.log(`Port ${port} in use, skipping dev server`);
|
|
63670
|
-
|
|
63714
|
+
resolve25();
|
|
63671
63715
|
} else {
|
|
63672
63716
|
reject(e);
|
|
63673
63717
|
}
|
|
@@ -63728,16 +63772,16 @@ var DevServer = class _DevServer {
|
|
|
63728
63772
|
this.json(res, 404, { error: `Provider not found: ${type}` });
|
|
63729
63773
|
return;
|
|
63730
63774
|
}
|
|
63731
|
-
const
|
|
63732
|
-
if (!
|
|
63775
|
+
const spawn5 = provider.spawn;
|
|
63776
|
+
if (!spawn5) {
|
|
63733
63777
|
this.json(res, 400, { error: `Provider ${type} has no spawn config` });
|
|
63734
63778
|
return;
|
|
63735
63779
|
}
|
|
63736
63780
|
const { spawn: spawnFn } = await import("child_process");
|
|
63737
63781
|
const start = Date.now();
|
|
63738
63782
|
try {
|
|
63739
|
-
const child = spawnFn(
|
|
63740
|
-
shell:
|
|
63783
|
+
const child = spawnFn(spawn5.command, [...spawn5.args || []], {
|
|
63784
|
+
shell: spawn5.shell ?? false,
|
|
63741
63785
|
timeout: 5e3,
|
|
63742
63786
|
stdio: ["pipe", "pipe", "pipe"]
|
|
63743
63787
|
});
|
|
@@ -63749,27 +63793,27 @@ var DevServer = class _DevServer {
|
|
|
63749
63793
|
child.stderr?.on("data", (d) => {
|
|
63750
63794
|
stderr += d.toString().slice(0, 2e3);
|
|
63751
63795
|
});
|
|
63752
|
-
await new Promise((
|
|
63796
|
+
await new Promise((resolve25) => {
|
|
63753
63797
|
const timer = setTimeout(() => {
|
|
63754
63798
|
child.kill();
|
|
63755
|
-
|
|
63799
|
+
resolve25();
|
|
63756
63800
|
}, 3e3);
|
|
63757
63801
|
child.on("exit", () => {
|
|
63758
63802
|
clearTimeout(timer);
|
|
63759
|
-
|
|
63803
|
+
resolve25();
|
|
63760
63804
|
});
|
|
63761
63805
|
child.stdout?.once("data", () => {
|
|
63762
63806
|
setTimeout(() => {
|
|
63763
63807
|
child.kill();
|
|
63764
63808
|
clearTimeout(timer);
|
|
63765
|
-
|
|
63809
|
+
resolve25();
|
|
63766
63810
|
}, 500);
|
|
63767
63811
|
});
|
|
63768
63812
|
});
|
|
63769
63813
|
const elapsed = Date.now() - start;
|
|
63770
63814
|
this.json(res, 200, {
|
|
63771
63815
|
success: true,
|
|
63772
|
-
command: `${
|
|
63816
|
+
command: `${spawn5.command} ${(spawn5.args || []).join(" ")}`,
|
|
63773
63817
|
elapsed,
|
|
63774
63818
|
stdout: stdout.trim(),
|
|
63775
63819
|
stderr: stderr.trim(),
|
|
@@ -63779,7 +63823,7 @@ var DevServer = class _DevServer {
|
|
|
63779
63823
|
const elapsed = Date.now() - start;
|
|
63780
63824
|
this.json(res, 200, {
|
|
63781
63825
|
success: false,
|
|
63782
|
-
command: `${
|
|
63826
|
+
command: `${spawn5.command} ${(spawn5.args || []).join(" ")}`,
|
|
63783
63827
|
elapsed,
|
|
63784
63828
|
error: e.message
|
|
63785
63829
|
});
|
|
@@ -64242,20 +64286,20 @@ var DevServer = class _DevServer {
|
|
|
64242
64286
|
this.json(res, 404, { error: `Provider not found: ${type}` });
|
|
64243
64287
|
return;
|
|
64244
64288
|
}
|
|
64245
|
-
const
|
|
64246
|
-
if (!
|
|
64289
|
+
const spawn5 = provider.spawn;
|
|
64290
|
+
if (!spawn5) {
|
|
64247
64291
|
this.json(res, 400, { error: `Provider ${type} has no spawn config` });
|
|
64248
64292
|
return;
|
|
64249
64293
|
}
|
|
64250
64294
|
const { spawn: spawnFn } = await import("child_process");
|
|
64251
64295
|
const start = Date.now();
|
|
64252
64296
|
try {
|
|
64253
|
-
const args = [...
|
|
64254
|
-
const child = spawnFn(
|
|
64255
|
-
shell:
|
|
64297
|
+
const args = [...spawn5.args || [], message];
|
|
64298
|
+
const child = spawnFn(spawn5.command, args, {
|
|
64299
|
+
shell: spawn5.shell ?? false,
|
|
64256
64300
|
timeout,
|
|
64257
64301
|
stdio: ["pipe", "pipe", "pipe"],
|
|
64258
|
-
env: { ...process.env, ...
|
|
64302
|
+
env: { ...process.env, ...spawn5.env || {} }
|
|
64259
64303
|
});
|
|
64260
64304
|
let stdout = "";
|
|
64261
64305
|
let stderr = "";
|
|
@@ -64265,14 +64309,14 @@ var DevServer = class _DevServer {
|
|
|
64265
64309
|
child.stderr?.on("data", (d) => {
|
|
64266
64310
|
stderr += d.toString();
|
|
64267
64311
|
});
|
|
64268
|
-
await new Promise((
|
|
64312
|
+
await new Promise((resolve25) => {
|
|
64269
64313
|
const timer = setTimeout(() => {
|
|
64270
64314
|
child.kill();
|
|
64271
|
-
|
|
64315
|
+
resolve25();
|
|
64272
64316
|
}, timeout);
|
|
64273
64317
|
child.on("exit", () => {
|
|
64274
64318
|
clearTimeout(timer);
|
|
64275
|
-
|
|
64319
|
+
resolve25();
|
|
64276
64320
|
});
|
|
64277
64321
|
});
|
|
64278
64322
|
const elapsed = Date.now() - start;
|
|
@@ -64471,14 +64515,14 @@ data: ${JSON.stringify(msg.data)}
|
|
|
64471
64515
|
res.end(JSON.stringify(data, null, 2));
|
|
64472
64516
|
}
|
|
64473
64517
|
async readBody(req) {
|
|
64474
|
-
return new Promise((
|
|
64518
|
+
return new Promise((resolve25) => {
|
|
64475
64519
|
let body = "";
|
|
64476
64520
|
req.on("data", (chunk) => body += chunk);
|
|
64477
64521
|
req.on("end", () => {
|
|
64478
64522
|
try {
|
|
64479
|
-
|
|
64523
|
+
resolve25(JSON.parse(body));
|
|
64480
64524
|
} catch {
|
|
64481
|
-
|
|
64525
|
+
resolve25({});
|
|
64482
64526
|
}
|
|
64483
64527
|
});
|
|
64484
64528
|
});
|
|
@@ -65220,7 +65264,7 @@ async function waitForReady(endpoint, timeoutMs = STARTUP_TIMEOUT_MS, requiredRe
|
|
|
65220
65264
|
const deadline = Date.now() + timeoutMs;
|
|
65221
65265
|
while (Date.now() < deadline) {
|
|
65222
65266
|
if (await canConnect(endpoint, requiredRequestTypes)) return;
|
|
65223
|
-
await new Promise((
|
|
65267
|
+
await new Promise((resolve25) => setTimeout(resolve25, STARTUP_POLL_MS));
|
|
65224
65268
|
}
|
|
65225
65269
|
throw new Error(`Session host did not become ready within ${timeoutMs}ms`);
|
|
65226
65270
|
}
|
|
@@ -65261,6 +65305,151 @@ async function listHostedCliRuntimes(endpoint) {
|
|
|
65261
65305
|
}
|
|
65262
65306
|
}
|
|
65263
65307
|
|
|
65308
|
+
// src/session-host/managed-host.ts
|
|
65309
|
+
import { execFileSync as execFileSync9, spawn as spawn4 } from "child_process";
|
|
65310
|
+
import * as fs38 from "fs";
|
|
65311
|
+
import * as os30 from "os";
|
|
65312
|
+
import * as path43 from "path";
|
|
65313
|
+
import {
|
|
65314
|
+
getDefaultSessionHostEndpoint as getDefaultSessionHostEndpoint2,
|
|
65315
|
+
sanitizeSpawnEnv as sanitizeSpawnEnv2
|
|
65316
|
+
} from "@adhdev/session-host-core";
|
|
65317
|
+
init_runtime_defaults();
|
|
65318
|
+
function createManagedSessionHost(options) {
|
|
65319
|
+
const appName = options.appName;
|
|
65320
|
+
const timeoutMs = options.timeoutMs ?? DEFAULT_SESSION_HOST_READY_TIMEOUT_MS;
|
|
65321
|
+
const endpoint = getDefaultSessionHostEndpoint2(appName);
|
|
65322
|
+
const isManagedPid = options.isManagedPid ?? (() => true);
|
|
65323
|
+
function buildEnv(baseEnv) {
|
|
65324
|
+
const env = sanitizeSpawnEnv2(baseEnv);
|
|
65325
|
+
env.ADHDEV_SESSION_HOST_NAME = appName;
|
|
65326
|
+
return env;
|
|
65327
|
+
}
|
|
65328
|
+
function resolveEntry() {
|
|
65329
|
+
const packagedCandidates = [
|
|
65330
|
+
path43.resolve(__dirname, "../vendor/session-host-daemon/index.js"),
|
|
65331
|
+
path43.resolve(__dirname, "../../vendor/session-host-daemon/index.js")
|
|
65332
|
+
];
|
|
65333
|
+
for (const candidate of packagedCandidates) {
|
|
65334
|
+
if (fs38.existsSync(candidate)) {
|
|
65335
|
+
return candidate;
|
|
65336
|
+
}
|
|
65337
|
+
}
|
|
65338
|
+
return __require.resolve("@adhdev/session-host-daemon");
|
|
65339
|
+
}
|
|
65340
|
+
function getPidFile() {
|
|
65341
|
+
return path43.join(os30.homedir(), ".adhdev", `${appName}-session-host.pid`);
|
|
65342
|
+
}
|
|
65343
|
+
function getPid() {
|
|
65344
|
+
try {
|
|
65345
|
+
const pidFile = getPidFile();
|
|
65346
|
+
if (!fs38.existsSync(pidFile)) return null;
|
|
65347
|
+
const pid = Number.parseInt(fs38.readFileSync(pidFile, "utf8").trim(), 10);
|
|
65348
|
+
return Number.isFinite(pid) ? pid : null;
|
|
65349
|
+
} catch {
|
|
65350
|
+
return null;
|
|
65351
|
+
}
|
|
65352
|
+
}
|
|
65353
|
+
function killPid2(pid) {
|
|
65354
|
+
try {
|
|
65355
|
+
if (process.platform === "win32") {
|
|
65356
|
+
const spawnOpts = { stdio: "ignore" };
|
|
65357
|
+
if (options.killWindowsHide) spawnOpts.windowsHide = true;
|
|
65358
|
+
execFileSync9("taskkill", ["/PID", String(pid), "/T", "/F"], spawnOpts);
|
|
65359
|
+
} else {
|
|
65360
|
+
process.kill(pid, "SIGTERM");
|
|
65361
|
+
}
|
|
65362
|
+
return true;
|
|
65363
|
+
} catch {
|
|
65364
|
+
return false;
|
|
65365
|
+
}
|
|
65366
|
+
}
|
|
65367
|
+
function spawnHost() {
|
|
65368
|
+
const entry = resolveEntry();
|
|
65369
|
+
let stdio = "ignore";
|
|
65370
|
+
let logFd = null;
|
|
65371
|
+
if (options.spawnStdio === "logfile") {
|
|
65372
|
+
const logDir = path43.join(os30.homedir(), ".adhdev", "logs");
|
|
65373
|
+
fs38.mkdirSync(logDir, { recursive: true });
|
|
65374
|
+
logFd = fs38.openSync(path43.join(logDir, "session-host.log"), "a");
|
|
65375
|
+
stdio = ["ignore", logFd, logFd];
|
|
65376
|
+
}
|
|
65377
|
+
const child = spawn4(process.execPath, [entry], {
|
|
65378
|
+
detached: true,
|
|
65379
|
+
stdio,
|
|
65380
|
+
windowsHide: true,
|
|
65381
|
+
env: buildEnv(process.env)
|
|
65382
|
+
});
|
|
65383
|
+
child.unref();
|
|
65384
|
+
if (logFd !== null) {
|
|
65385
|
+
try {
|
|
65386
|
+
fs38.closeSync(logFd);
|
|
65387
|
+
} catch {
|
|
65388
|
+
}
|
|
65389
|
+
}
|
|
65390
|
+
}
|
|
65391
|
+
function stopManagedSessionHostProcess() {
|
|
65392
|
+
let stopped = false;
|
|
65393
|
+
const pidFile = getPidFile();
|
|
65394
|
+
try {
|
|
65395
|
+
if (fs38.existsSync(pidFile)) {
|
|
65396
|
+
const pid = Number.parseInt(fs38.readFileSync(pidFile, "utf8").trim(), 10);
|
|
65397
|
+
if (Number.isFinite(pid) && pid !== process.pid && isManagedPid(pid)) {
|
|
65398
|
+
stopped = killPid2(pid) || stopped;
|
|
65399
|
+
}
|
|
65400
|
+
}
|
|
65401
|
+
} catch {
|
|
65402
|
+
} finally {
|
|
65403
|
+
try {
|
|
65404
|
+
fs38.unlinkSync(pidFile);
|
|
65405
|
+
} catch {
|
|
65406
|
+
}
|
|
65407
|
+
}
|
|
65408
|
+
if (options.extraStop) {
|
|
65409
|
+
stopped = options.extraStop(endpoint) || stopped;
|
|
65410
|
+
}
|
|
65411
|
+
return stopped;
|
|
65412
|
+
}
|
|
65413
|
+
async function ensureReady() {
|
|
65414
|
+
options.beforeEnsureReady?.();
|
|
65415
|
+
try {
|
|
65416
|
+
return await ensureSessionHostReady({
|
|
65417
|
+
appName,
|
|
65418
|
+
spawnHost,
|
|
65419
|
+
timeoutMs,
|
|
65420
|
+
requiredRequestTypes: options.requiredRequestTypes
|
|
65421
|
+
});
|
|
65422
|
+
} catch (error) {
|
|
65423
|
+
stopManagedSessionHostProcess();
|
|
65424
|
+
return ensureSessionHostReady({
|
|
65425
|
+
appName,
|
|
65426
|
+
spawnHost,
|
|
65427
|
+
timeoutMs,
|
|
65428
|
+
requiredRequestTypes: options.requiredRequestTypes
|
|
65429
|
+
}).catch((retryError) => {
|
|
65430
|
+
const initialMessage = error instanceof Error ? error.message : String(error);
|
|
65431
|
+
const retryMessage = retryError instanceof Error ? retryError.message : String(retryError);
|
|
65432
|
+
throw new Error(`Session host failed to start after retry (${initialMessage}; retry: ${retryMessage})`);
|
|
65433
|
+
});
|
|
65434
|
+
}
|
|
65435
|
+
}
|
|
65436
|
+
return {
|
|
65437
|
+
appName,
|
|
65438
|
+
endpoint,
|
|
65439
|
+
getPidFile,
|
|
65440
|
+
getPid,
|
|
65441
|
+
buildEnv,
|
|
65442
|
+
resolveEntry,
|
|
65443
|
+
killPid: killPid2,
|
|
65444
|
+
spawnHost,
|
|
65445
|
+
stopManagedSessionHostProcess,
|
|
65446
|
+
ensureReady,
|
|
65447
|
+
getStatusPaths() {
|
|
65448
|
+
return { pidFile: getPidFile(), endpoint };
|
|
65449
|
+
}
|
|
65450
|
+
};
|
|
65451
|
+
}
|
|
65452
|
+
|
|
65264
65453
|
// src/session-host/startup-restore-policy.js
|
|
65265
65454
|
function shouldAutoRestoreHostedSessionsOnStartup(env = process.env) {
|
|
65266
65455
|
const raw = typeof env.ADHDEV_RESTORE_HOSTED_SESSIONS_ON_STARTUP === "string" ? env.ADHDEV_RESTORE_HOSTED_SESSIONS_ON_STARTUP.trim().toLowerCase() : "";
|
|
@@ -65398,12 +65587,12 @@ async function installExtension(ide, extension) {
|
|
|
65398
65587
|
const res = await fetch(extension.vsixUrl);
|
|
65399
65588
|
if (res.ok) {
|
|
65400
65589
|
const buffer = Buffer.from(await res.arrayBuffer());
|
|
65401
|
-
const
|
|
65402
|
-
|
|
65403
|
-
return new Promise((
|
|
65590
|
+
const fs39 = await import("fs");
|
|
65591
|
+
fs39.writeFileSync(vsixPath, buffer);
|
|
65592
|
+
return new Promise((resolve25) => {
|
|
65404
65593
|
const cmd = `"${ide.cliCommand}" --install-extension "${vsixPath}" --force`;
|
|
65405
65594
|
exec6(cmd, { timeout: 6e4 }, (error, _stdout, stderr) => {
|
|
65406
|
-
|
|
65595
|
+
resolve25({
|
|
65407
65596
|
extensionId: extension.id,
|
|
65408
65597
|
marketplaceId: extension.marketplaceId,
|
|
65409
65598
|
success: !error,
|
|
@@ -65416,11 +65605,11 @@ async function installExtension(ide, extension) {
|
|
|
65416
65605
|
} catch (e) {
|
|
65417
65606
|
}
|
|
65418
65607
|
}
|
|
65419
|
-
return new Promise((
|
|
65608
|
+
return new Promise((resolve25) => {
|
|
65420
65609
|
const cmd = `"${ide.cliCommand}" --install-extension ${extension.marketplaceId} --force`;
|
|
65421
65610
|
exec6(cmd, { timeout: 6e4 }, (error, stdout, stderr) => {
|
|
65422
65611
|
if (error) {
|
|
65423
|
-
|
|
65612
|
+
resolve25({
|
|
65424
65613
|
extensionId: extension.id,
|
|
65425
65614
|
marketplaceId: extension.marketplaceId,
|
|
65426
65615
|
success: false,
|
|
@@ -65428,7 +65617,7 @@ async function installExtension(ide, extension) {
|
|
|
65428
65617
|
error: stderr || error.message
|
|
65429
65618
|
});
|
|
65430
65619
|
} else {
|
|
65431
|
-
|
|
65620
|
+
resolve25({
|
|
65432
65621
|
extensionId: extension.id,
|
|
65433
65622
|
marketplaceId: extension.marketplaceId,
|
|
65434
65623
|
success: true,
|
|
@@ -65917,7 +66106,7 @@ async function startLocalIpcServer(opts) {
|
|
|
65917
66106
|
}));
|
|
65918
66107
|
}
|
|
65919
66108
|
}
|
|
65920
|
-
await new Promise((
|
|
66109
|
+
await new Promise((resolve25, reject) => {
|
|
65921
66110
|
const onError = (error) => {
|
|
65922
66111
|
httpServer?.off("listening", onListening);
|
|
65923
66112
|
reject(error);
|
|
@@ -65925,7 +66114,7 @@ async function startLocalIpcServer(opts) {
|
|
|
65925
66114
|
const onListening = () => {
|
|
65926
66115
|
httpServer?.off("error", onError);
|
|
65927
66116
|
listening = true;
|
|
65928
|
-
|
|
66117
|
+
resolve25();
|
|
65929
66118
|
};
|
|
65930
66119
|
httpServer.once("error", onError);
|
|
65931
66120
|
httpServer.once("listening", onListening);
|
|
@@ -65952,12 +66141,12 @@ async function startLocalIpcServer(opts) {
|
|
|
65952
66141
|
}
|
|
65953
66142
|
}
|
|
65954
66143
|
clients.clear();
|
|
65955
|
-
await new Promise((
|
|
66144
|
+
await new Promise((resolve25) => {
|
|
65956
66145
|
if (!httpServer) {
|
|
65957
|
-
|
|
66146
|
+
resolve25();
|
|
65958
66147
|
return;
|
|
65959
66148
|
}
|
|
65960
|
-
httpServer.close(() =>
|
|
66149
|
+
httpServer.close(() => resolve25());
|
|
65961
66150
|
});
|
|
65962
66151
|
httpServer = null;
|
|
65963
66152
|
wss = null;
|
|
@@ -65978,12 +66167,12 @@ init_parse_session();
|
|
|
65978
66167
|
|
|
65979
66168
|
// src/providers/sdk/v1/fixture-tooling/replay.ts
|
|
65980
66169
|
init_provider_cli_shared();
|
|
65981
|
-
import { readFileSync as
|
|
65982
|
-
import { dirname as dirname15, resolve as
|
|
66170
|
+
import { readFileSync as readFileSync40 } from "fs";
|
|
66171
|
+
import { dirname as dirname15, resolve as resolve23 } from "path";
|
|
65983
66172
|
|
|
65984
66173
|
// src/providers/sdk/v1/validators/taint.ts
|
|
65985
|
-
import { readFileSync as
|
|
65986
|
-
import { resolve as
|
|
66174
|
+
import { readFileSync as readFileSync41, existsSync as existsSync53 } from "fs";
|
|
66175
|
+
import { resolve as resolve24, dirname as dirname16, join as join49 } from "path";
|
|
65987
66176
|
|
|
65988
66177
|
// src/providers/sdk/v1/validators/index.ts
|
|
65989
66178
|
init_manifest();
|
|
@@ -66208,6 +66397,7 @@ export {
|
|
|
66208
66397
|
createGitSnapshotStore,
|
|
66209
66398
|
createGitWorkspaceMonitor,
|
|
66210
66399
|
createInteractionId,
|
|
66400
|
+
createManagedSessionHost,
|
|
66211
66401
|
createMesh,
|
|
66212
66402
|
createNativeHistoryDispatcher,
|
|
66213
66403
|
createSessionDelivery,
|