@adhdev/daemon-core 0.9.82-rc.446 → 0.9.82-rc.448
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/config/mesh-config.d.ts +9 -0
- package/dist/git/git-commands.d.ts +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +868 -685
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +873 -688
- package/dist/index.mjs.map +1 -1
- package/dist/mesh/mesh-node-identity.d.ts +2 -0
- package/dist/repo-mesh-types.d.ts +10 -0
- package/dist/session-host/managed-host.d.ts +64 -0
- package/package.json +2 -2
- package/src/commands/high-family/mesh-status.ts +15 -0
- package/src/config/mesh-config.ts +26 -1
- package/src/git/git-commands.ts +21 -2
- package/src/index.ts +2 -0
- package/src/mesh/mesh-node-identity.ts +16 -6
- package/src/repo-mesh-types.ts +10 -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 ? "7636b9d4fc6c456ebfe178b9b0a7b81664b02257" : void 0) ?? "unknown";
|
|
408
|
+
const commitShort = readInjected(true ? "7636b9d4" : void 0) ?? (commit !== "unknown" ? commit.slice(0, 7) : "unknown");
|
|
409
|
+
const version = readInjected(true ? "0.9.82-rc.448" : void 0) ?? readInjected(typeof process !== "undefined" ? process.env?.ADHDEV_PKG_VERSION : void 0) ?? "unknown";
|
|
410
|
+
const builtAt = readInjected(true ? "2026-07-02T00:30:54.215Z" : 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 ?? "",
|
|
@@ -1497,6 +1497,255 @@ var init_git_diff = __esm({
|
|
|
1497
1497
|
}
|
|
1498
1498
|
});
|
|
1499
1499
|
|
|
1500
|
+
// src/config/config.ts
|
|
1501
|
+
var config_exports = {};
|
|
1502
|
+
__export(config_exports, {
|
|
1503
|
+
generateMachineId: () => generateMachineId,
|
|
1504
|
+
getConfigDir: () => getConfigDir,
|
|
1505
|
+
getDaemonDataDir: () => getDaemonDataDir,
|
|
1506
|
+
isSetupComplete: () => isSetupComplete,
|
|
1507
|
+
isStableMachineId: () => isStableMachineId,
|
|
1508
|
+
loadConfig: () => loadConfig,
|
|
1509
|
+
markSetupComplete: () => markSetupComplete,
|
|
1510
|
+
resetConfig: () => resetConfig,
|
|
1511
|
+
resolveProviderSourceMode: () => resolveProviderSourceMode,
|
|
1512
|
+
saveConfig: () => saveConfig,
|
|
1513
|
+
updateConfig: () => updateConfig
|
|
1514
|
+
});
|
|
1515
|
+
import { homedir } from "os";
|
|
1516
|
+
import { join as join2 } from "path";
|
|
1517
|
+
import { existsSync as existsSync2, mkdirSync, readFileSync as readFileSync2, writeFileSync, chmodSync } from "fs";
|
|
1518
|
+
import { randomUUID } from "crypto";
|
|
1519
|
+
function resolveProviderSourceMode(providerSourceMode, legacyDisableUpstream) {
|
|
1520
|
+
if (providerSourceMode === "normal" || providerSourceMode === "no-upstream") {
|
|
1521
|
+
return providerSourceMode;
|
|
1522
|
+
}
|
|
1523
|
+
return legacyDisableUpstream === true ? "no-upstream" : "normal";
|
|
1524
|
+
}
|
|
1525
|
+
function isPlainObject(value) {
|
|
1526
|
+
return !!value && typeof value === "object" && !Array.isArray(value);
|
|
1527
|
+
}
|
|
1528
|
+
function asStringArray(value) {
|
|
1529
|
+
if (!Array.isArray(value)) return [];
|
|
1530
|
+
return value.filter((item) => typeof item === "string");
|
|
1531
|
+
}
|
|
1532
|
+
function asNullableString(value) {
|
|
1533
|
+
return typeof value === "string" ? value : null;
|
|
1534
|
+
}
|
|
1535
|
+
function asOptionalString(value) {
|
|
1536
|
+
return typeof value === "string" && value.trim() ? value : void 0;
|
|
1537
|
+
}
|
|
1538
|
+
function asBoolean(value, fallback) {
|
|
1539
|
+
return typeof value === "boolean" ? value : fallback;
|
|
1540
|
+
}
|
|
1541
|
+
function normalizeMachineProviders(value) {
|
|
1542
|
+
if (!isPlainObject(value)) return {};
|
|
1543
|
+
const result = {};
|
|
1544
|
+
for (const [providerType, raw] of Object.entries(value)) {
|
|
1545
|
+
if (!isPlainObject(raw)) continue;
|
|
1546
|
+
const entry = {};
|
|
1547
|
+
if (raw.enabled === true) entry.enabled = true;
|
|
1548
|
+
if (typeof raw.executable === "string" && raw.executable.trim()) {
|
|
1549
|
+
entry.executable = raw.executable.trim();
|
|
1550
|
+
}
|
|
1551
|
+
if (Array.isArray(raw.args)) {
|
|
1552
|
+
entry.args = raw.args.filter((arg) => typeof arg === "string");
|
|
1553
|
+
}
|
|
1554
|
+
if (isPlainObject(raw.lastDetection)) {
|
|
1555
|
+
entry.lastDetection = raw.lastDetection;
|
|
1556
|
+
}
|
|
1557
|
+
if (isPlainObject(raw.lastVerification)) {
|
|
1558
|
+
entry.lastVerification = raw.lastVerification;
|
|
1559
|
+
}
|
|
1560
|
+
result[providerType] = entry;
|
|
1561
|
+
}
|
|
1562
|
+
return result;
|
|
1563
|
+
}
|
|
1564
|
+
function normalizeConfig(raw) {
|
|
1565
|
+
const parsed = isPlainObject(raw) ? raw : {};
|
|
1566
|
+
return {
|
|
1567
|
+
serverUrl: typeof parsed.serverUrl === "string" && parsed.serverUrl.trim() ? parsed.serverUrl : DEFAULT_CONFIG.serverUrl,
|
|
1568
|
+
allowServerApiProxy: asBoolean(parsed.allowServerApiProxy, DEFAULT_CONFIG.allowServerApiProxy ?? false),
|
|
1569
|
+
selectedIde: asNullableString(parsed.selectedIde),
|
|
1570
|
+
configuredIdes: asStringArray(parsed.configuredIdes),
|
|
1571
|
+
installedExtensions: asStringArray(parsed.installedExtensions),
|
|
1572
|
+
userEmail: asNullableString(parsed.userEmail),
|
|
1573
|
+
userName: asNullableString(parsed.userName),
|
|
1574
|
+
setupCompleted: asBoolean(parsed.setupCompleted, DEFAULT_CONFIG.setupCompleted),
|
|
1575
|
+
setupDate: asNullableString(parsed.setupDate),
|
|
1576
|
+
enabledIdes: asStringArray(parsed.enabledIdes),
|
|
1577
|
+
workspaces: Array.isArray(parsed.workspaces) ? parsed.workspaces : [],
|
|
1578
|
+
defaultWorkspaceId: asNullableString(parsed.defaultWorkspaceId) ?? asNullableString(parsed.activeWorkspaceId),
|
|
1579
|
+
machineNickname: asNullableString(parsed.machineNickname),
|
|
1580
|
+
machineId: asOptionalString(parsed.machineId),
|
|
1581
|
+
machineSecret: parsed.machineSecret === null ? null : asOptionalString(parsed.machineSecret),
|
|
1582
|
+
registeredMachineId: asOptionalString(parsed.registeredMachineId),
|
|
1583
|
+
providerSettings: isPlainObject(parsed.providerSettings) ? parsed.providerSettings : {},
|
|
1584
|
+
machineProviders: normalizeMachineProviders(parsed.machineProviders),
|
|
1585
|
+
ideSettings: isPlainObject(parsed.ideSettings) ? parsed.ideSettings : {},
|
|
1586
|
+
providerSourceMode: resolveProviderSourceMode(parsed.providerSourceMode, parsed.disableUpstream),
|
|
1587
|
+
providerDir: asOptionalString(parsed.providerDir),
|
|
1588
|
+
updateChannel: parsed.updateChannel === "preview" ? "preview" : "stable",
|
|
1589
|
+
terminalSizingMode: parsed.terminalSizingMode === "fit" ? "fit" : "measured"
|
|
1590
|
+
};
|
|
1591
|
+
}
|
|
1592
|
+
function generateMachineId() {
|
|
1593
|
+
return `${MACHINE_ID_PREFIX}${randomUUID().replace(/-/g, "")}`;
|
|
1594
|
+
}
|
|
1595
|
+
function isStableMachineId(machineId) {
|
|
1596
|
+
return typeof machineId === "string" && machineId.startsWith(MACHINE_ID_PREFIX);
|
|
1597
|
+
}
|
|
1598
|
+
function ensureMachineId(config) {
|
|
1599
|
+
if (isStableMachineId(config.machineId)) {
|
|
1600
|
+
return { config, changed: false };
|
|
1601
|
+
}
|
|
1602
|
+
return {
|
|
1603
|
+
config: {
|
|
1604
|
+
...config,
|
|
1605
|
+
machineId: generateMachineId()
|
|
1606
|
+
},
|
|
1607
|
+
changed: true
|
|
1608
|
+
};
|
|
1609
|
+
}
|
|
1610
|
+
function getConfigDir() {
|
|
1611
|
+
const override = process.env.ADHDEV_CONFIG_DIR;
|
|
1612
|
+
const dir = override && override.trim() ? override.trim() : join2(homedir(), ".adhdev");
|
|
1613
|
+
if (!existsSync2(dir)) {
|
|
1614
|
+
mkdirSync(dir, { recursive: true });
|
|
1615
|
+
}
|
|
1616
|
+
return dir;
|
|
1617
|
+
}
|
|
1618
|
+
function getDaemonDataDir() {
|
|
1619
|
+
const dir = join2(getConfigDir(), "daemon");
|
|
1620
|
+
if (!existsSync2(dir)) {
|
|
1621
|
+
mkdirSync(dir, { recursive: true });
|
|
1622
|
+
}
|
|
1623
|
+
return dir;
|
|
1624
|
+
}
|
|
1625
|
+
function getConfigPath() {
|
|
1626
|
+
return join2(getConfigDir(), "config.json");
|
|
1627
|
+
}
|
|
1628
|
+
function migrateStateToStateFile(raw) {
|
|
1629
|
+
const statePath = join2(getConfigDir(), "state.json");
|
|
1630
|
+
if (existsSync2(statePath)) return;
|
|
1631
|
+
const recentActivity = Array.isArray(raw.recentActivity) ? raw.recentActivity : [];
|
|
1632
|
+
const savedProviderSessions = Array.isArray(raw.savedProviderSessions) ? raw.savedProviderSessions : [];
|
|
1633
|
+
const legacySessionReads = isPlainObject(raw.recentSessionReads) ? raw.recentSessionReads : {};
|
|
1634
|
+
const sessionReads = isPlainObject(raw.sessionReads) ? raw.sessionReads : {};
|
|
1635
|
+
const sessionReadMarkers = isPlainObject(raw.sessionReadMarkers) ? raw.sessionReadMarkers : {};
|
|
1636
|
+
const hasData = recentActivity.length > 0 || savedProviderSessions.length > 0 || Object.keys(sessionReads).length > 0 || Object.keys(legacySessionReads).length > 0 || Object.keys(sessionReadMarkers).length > 0;
|
|
1637
|
+
if (!hasData) return;
|
|
1638
|
+
const mergedReads = Object.fromEntries(
|
|
1639
|
+
Object.entries({ ...legacySessionReads, ...sessionReads }).filter(([, v]) => typeof v === "number" && Number.isFinite(v))
|
|
1640
|
+
);
|
|
1641
|
+
const cleanedMarkers = Object.fromEntries(
|
|
1642
|
+
Object.entries(sessionReadMarkers).filter(([, v]) => typeof v === "string")
|
|
1643
|
+
);
|
|
1644
|
+
const state = {
|
|
1645
|
+
recentActivity,
|
|
1646
|
+
savedProviderSessions,
|
|
1647
|
+
sessionReads: mergedReads,
|
|
1648
|
+
sessionReadMarkers: cleanedMarkers
|
|
1649
|
+
};
|
|
1650
|
+
writeFileSync(statePath, JSON.stringify(state, null, 2), { encoding: "utf-8", mode: 384 });
|
|
1651
|
+
}
|
|
1652
|
+
function loadConfig() {
|
|
1653
|
+
const configPath = getConfigPath();
|
|
1654
|
+
if (!existsSync2(configPath)) {
|
|
1655
|
+
const initialized = ensureMachineId({ ...DEFAULT_CONFIG });
|
|
1656
|
+
try {
|
|
1657
|
+
saveConfig(initialized.config);
|
|
1658
|
+
} catch {
|
|
1659
|
+
}
|
|
1660
|
+
return initialized.config;
|
|
1661
|
+
}
|
|
1662
|
+
try {
|
|
1663
|
+
const raw = readFileSync2(configPath, "utf-8");
|
|
1664
|
+
const parsed = JSON.parse(raw);
|
|
1665
|
+
migrateStateToStateFile(parsed);
|
|
1666
|
+
const normalizedInput = normalizeConfig(parsed);
|
|
1667
|
+
const ensured = ensureMachineId(normalizedInput);
|
|
1668
|
+
const normalized = ensured.config;
|
|
1669
|
+
if (ensured.changed || JSON.stringify(parsed) !== JSON.stringify(normalized)) {
|
|
1670
|
+
try {
|
|
1671
|
+
saveConfig(normalized);
|
|
1672
|
+
} catch {
|
|
1673
|
+
}
|
|
1674
|
+
}
|
|
1675
|
+
return normalized;
|
|
1676
|
+
} catch {
|
|
1677
|
+
const initialized = ensureMachineId({ ...DEFAULT_CONFIG });
|
|
1678
|
+
return initialized.config;
|
|
1679
|
+
}
|
|
1680
|
+
}
|
|
1681
|
+
function saveConfig(config) {
|
|
1682
|
+
const configPath = getConfigPath();
|
|
1683
|
+
const dir = getConfigDir();
|
|
1684
|
+
const normalized = normalizeConfig(config);
|
|
1685
|
+
if (!existsSync2(dir)) {
|
|
1686
|
+
mkdirSync(dir, { recursive: true, mode: 448 });
|
|
1687
|
+
}
|
|
1688
|
+
writeFileSync(configPath, JSON.stringify(normalized, null, 2), { encoding: "utf-8", mode: 384 });
|
|
1689
|
+
try {
|
|
1690
|
+
chmodSync(configPath, 384);
|
|
1691
|
+
} catch {
|
|
1692
|
+
}
|
|
1693
|
+
}
|
|
1694
|
+
function updateConfig(updates) {
|
|
1695
|
+
const config = loadConfig();
|
|
1696
|
+
const updated = { ...config, ...updates };
|
|
1697
|
+
saveConfig(updated);
|
|
1698
|
+
return updated;
|
|
1699
|
+
}
|
|
1700
|
+
function markSetupComplete(ideId, extensions) {
|
|
1701
|
+
const ideIds = Array.isArray(ideId) ? ideId : [ideId];
|
|
1702
|
+
return updateConfig({
|
|
1703
|
+
selectedIde: ideIds[0],
|
|
1704
|
+
configuredIdes: ideIds,
|
|
1705
|
+
installedExtensions: extensions,
|
|
1706
|
+
setupCompleted: true,
|
|
1707
|
+
setupDate: (/* @__PURE__ */ new Date()).toISOString()
|
|
1708
|
+
});
|
|
1709
|
+
}
|
|
1710
|
+
function isSetupComplete() {
|
|
1711
|
+
const config = loadConfig();
|
|
1712
|
+
return config.setupCompleted;
|
|
1713
|
+
}
|
|
1714
|
+
function resetConfig() {
|
|
1715
|
+
saveConfig({ ...DEFAULT_CONFIG });
|
|
1716
|
+
}
|
|
1717
|
+
var DEFAULT_CONFIG, MACHINE_ID_PREFIX;
|
|
1718
|
+
var init_config = __esm({
|
|
1719
|
+
"src/config/config.ts"() {
|
|
1720
|
+
"use strict";
|
|
1721
|
+
DEFAULT_CONFIG = {
|
|
1722
|
+
serverUrl: "https://api.adhf.dev",
|
|
1723
|
+
allowServerApiProxy: false,
|
|
1724
|
+
selectedIde: null,
|
|
1725
|
+
configuredIdes: [],
|
|
1726
|
+
installedExtensions: [],
|
|
1727
|
+
userEmail: null,
|
|
1728
|
+
userName: null,
|
|
1729
|
+
setupCompleted: false,
|
|
1730
|
+
setupDate: null,
|
|
1731
|
+
enabledIdes: [],
|
|
1732
|
+
workspaces: [],
|
|
1733
|
+
defaultWorkspaceId: null,
|
|
1734
|
+
machineNickname: null,
|
|
1735
|
+
machineId: void 0,
|
|
1736
|
+
machineSecret: null,
|
|
1737
|
+
registeredMachineId: void 0,
|
|
1738
|
+
providerSettings: {},
|
|
1739
|
+
machineProviders: {},
|
|
1740
|
+
ideSettings: {},
|
|
1741
|
+
providerSourceMode: "normal",
|
|
1742
|
+
updateChannel: "stable",
|
|
1743
|
+
terminalSizingMode: "measured"
|
|
1744
|
+
};
|
|
1745
|
+
MACHINE_ID_PREFIX = "mach_";
|
|
1746
|
+
}
|
|
1747
|
+
});
|
|
1748
|
+
|
|
1500
1749
|
// src/git/git-worktree.ts
|
|
1501
1750
|
var git_worktree_exports = {};
|
|
1502
1751
|
__export(git_worktree_exports, {
|
|
@@ -1509,7 +1758,7 @@ __export(git_worktree_exports, {
|
|
|
1509
1758
|
});
|
|
1510
1759
|
import * as path4 from "path";
|
|
1511
1760
|
import { mkdir } from "fs/promises";
|
|
1512
|
-
import { existsSync as
|
|
1761
|
+
import { existsSync as existsSync3 } from "fs";
|
|
1513
1762
|
import { execFile as execFile2 } from "child_process";
|
|
1514
1763
|
import { promisify as promisify2 } from "util";
|
|
1515
1764
|
function resolveWorktreePath(repoRoot, meshName, branch) {
|
|
@@ -1602,7 +1851,7 @@ async function createWorktree(opts) {
|
|
|
1602
1851
|
const { repoRoot, branch, baseBranch, meshName } = opts;
|
|
1603
1852
|
const remote = (opts.remote || "origin").trim() || "origin";
|
|
1604
1853
|
const targetDir = opts.targetDir || resolveWorktreePath(repoRoot, meshName, branch);
|
|
1605
|
-
if (
|
|
1854
|
+
if (existsSync3(targetDir)) {
|
|
1606
1855
|
throw new Error(`Worktree target directory already exists: ${targetDir}`);
|
|
1607
1856
|
}
|
|
1608
1857
|
await mkdir(path4.dirname(targetDir), { recursive: true });
|
|
@@ -1627,7 +1876,7 @@ async function createWorktree(opts) {
|
|
|
1627
1876
|
} catch (error) {
|
|
1628
1877
|
const stderr = typeof error.stderr === "string" ? error.stderr : "";
|
|
1629
1878
|
if (/already exists/i.test(stderr)) {
|
|
1630
|
-
if (
|
|
1879
|
+
if (existsSync3(targetDir)) {
|
|
1631
1880
|
throw new Error(`Worktree target directory was created concurrently: ${targetDir}`);
|
|
1632
1881
|
}
|
|
1633
1882
|
throw new Error(`Branch '${branch}' already exists or is checked out in another worktree`);
|
|
@@ -1642,7 +1891,7 @@ async function createWorktree(opts) {
|
|
|
1642
1891
|
};
|
|
1643
1892
|
}
|
|
1644
1893
|
async function removeWorktree(repoRoot, worktreePath, opts = {}) {
|
|
1645
|
-
if (!
|
|
1894
|
+
if (!existsSync3(worktreePath)) {
|
|
1646
1895
|
await pruneWorktrees(repoRoot);
|
|
1647
1896
|
return { success: true, removedPath: worktreePath };
|
|
1648
1897
|
}
|
|
@@ -1807,255 +2056,6 @@ var init_git_worktree = __esm({
|
|
|
1807
2056
|
}
|
|
1808
2057
|
});
|
|
1809
2058
|
|
|
1810
|
-
// src/config/config.ts
|
|
1811
|
-
var config_exports = {};
|
|
1812
|
-
__export(config_exports, {
|
|
1813
|
-
generateMachineId: () => generateMachineId,
|
|
1814
|
-
getConfigDir: () => getConfigDir,
|
|
1815
|
-
getDaemonDataDir: () => getDaemonDataDir,
|
|
1816
|
-
isSetupComplete: () => isSetupComplete,
|
|
1817
|
-
isStableMachineId: () => isStableMachineId,
|
|
1818
|
-
loadConfig: () => loadConfig,
|
|
1819
|
-
markSetupComplete: () => markSetupComplete,
|
|
1820
|
-
resetConfig: () => resetConfig,
|
|
1821
|
-
resolveProviderSourceMode: () => resolveProviderSourceMode,
|
|
1822
|
-
saveConfig: () => saveConfig,
|
|
1823
|
-
updateConfig: () => updateConfig
|
|
1824
|
-
});
|
|
1825
|
-
import { homedir } from "os";
|
|
1826
|
-
import { join as join3 } from "path";
|
|
1827
|
-
import { existsSync as existsSync3, mkdirSync, readFileSync as readFileSync2, writeFileSync, chmodSync } from "fs";
|
|
1828
|
-
import { randomUUID } from "crypto";
|
|
1829
|
-
function resolveProviderSourceMode(providerSourceMode, legacyDisableUpstream) {
|
|
1830
|
-
if (providerSourceMode === "normal" || providerSourceMode === "no-upstream") {
|
|
1831
|
-
return providerSourceMode;
|
|
1832
|
-
}
|
|
1833
|
-
return legacyDisableUpstream === true ? "no-upstream" : "normal";
|
|
1834
|
-
}
|
|
1835
|
-
function isPlainObject(value) {
|
|
1836
|
-
return !!value && typeof value === "object" && !Array.isArray(value);
|
|
1837
|
-
}
|
|
1838
|
-
function asStringArray(value) {
|
|
1839
|
-
if (!Array.isArray(value)) return [];
|
|
1840
|
-
return value.filter((item) => typeof item === "string");
|
|
1841
|
-
}
|
|
1842
|
-
function asNullableString(value) {
|
|
1843
|
-
return typeof value === "string" ? value : null;
|
|
1844
|
-
}
|
|
1845
|
-
function asOptionalString(value) {
|
|
1846
|
-
return typeof value === "string" && value.trim() ? value : void 0;
|
|
1847
|
-
}
|
|
1848
|
-
function asBoolean(value, fallback) {
|
|
1849
|
-
return typeof value === "boolean" ? value : fallback;
|
|
1850
|
-
}
|
|
1851
|
-
function normalizeMachineProviders(value) {
|
|
1852
|
-
if (!isPlainObject(value)) return {};
|
|
1853
|
-
const result = {};
|
|
1854
|
-
for (const [providerType, raw] of Object.entries(value)) {
|
|
1855
|
-
if (!isPlainObject(raw)) continue;
|
|
1856
|
-
const entry = {};
|
|
1857
|
-
if (raw.enabled === true) entry.enabled = true;
|
|
1858
|
-
if (typeof raw.executable === "string" && raw.executable.trim()) {
|
|
1859
|
-
entry.executable = raw.executable.trim();
|
|
1860
|
-
}
|
|
1861
|
-
if (Array.isArray(raw.args)) {
|
|
1862
|
-
entry.args = raw.args.filter((arg) => typeof arg === "string");
|
|
1863
|
-
}
|
|
1864
|
-
if (isPlainObject(raw.lastDetection)) {
|
|
1865
|
-
entry.lastDetection = raw.lastDetection;
|
|
1866
|
-
}
|
|
1867
|
-
if (isPlainObject(raw.lastVerification)) {
|
|
1868
|
-
entry.lastVerification = raw.lastVerification;
|
|
1869
|
-
}
|
|
1870
|
-
result[providerType] = entry;
|
|
1871
|
-
}
|
|
1872
|
-
return result;
|
|
1873
|
-
}
|
|
1874
|
-
function normalizeConfig(raw) {
|
|
1875
|
-
const parsed = isPlainObject(raw) ? raw : {};
|
|
1876
|
-
return {
|
|
1877
|
-
serverUrl: typeof parsed.serverUrl === "string" && parsed.serverUrl.trim() ? parsed.serverUrl : DEFAULT_CONFIG.serverUrl,
|
|
1878
|
-
allowServerApiProxy: asBoolean(parsed.allowServerApiProxy, DEFAULT_CONFIG.allowServerApiProxy ?? false),
|
|
1879
|
-
selectedIde: asNullableString(parsed.selectedIde),
|
|
1880
|
-
configuredIdes: asStringArray(parsed.configuredIdes),
|
|
1881
|
-
installedExtensions: asStringArray(parsed.installedExtensions),
|
|
1882
|
-
userEmail: asNullableString(parsed.userEmail),
|
|
1883
|
-
userName: asNullableString(parsed.userName),
|
|
1884
|
-
setupCompleted: asBoolean(parsed.setupCompleted, DEFAULT_CONFIG.setupCompleted),
|
|
1885
|
-
setupDate: asNullableString(parsed.setupDate),
|
|
1886
|
-
enabledIdes: asStringArray(parsed.enabledIdes),
|
|
1887
|
-
workspaces: Array.isArray(parsed.workspaces) ? parsed.workspaces : [],
|
|
1888
|
-
defaultWorkspaceId: asNullableString(parsed.defaultWorkspaceId) ?? asNullableString(parsed.activeWorkspaceId),
|
|
1889
|
-
machineNickname: asNullableString(parsed.machineNickname),
|
|
1890
|
-
machineId: asOptionalString(parsed.machineId),
|
|
1891
|
-
machineSecret: parsed.machineSecret === null ? null : asOptionalString(parsed.machineSecret),
|
|
1892
|
-
registeredMachineId: asOptionalString(parsed.registeredMachineId),
|
|
1893
|
-
providerSettings: isPlainObject(parsed.providerSettings) ? parsed.providerSettings : {},
|
|
1894
|
-
machineProviders: normalizeMachineProviders(parsed.machineProviders),
|
|
1895
|
-
ideSettings: isPlainObject(parsed.ideSettings) ? parsed.ideSettings : {},
|
|
1896
|
-
providerSourceMode: resolveProviderSourceMode(parsed.providerSourceMode, parsed.disableUpstream),
|
|
1897
|
-
providerDir: asOptionalString(parsed.providerDir),
|
|
1898
|
-
updateChannel: parsed.updateChannel === "preview" ? "preview" : "stable",
|
|
1899
|
-
terminalSizingMode: parsed.terminalSizingMode === "fit" ? "fit" : "measured"
|
|
1900
|
-
};
|
|
1901
|
-
}
|
|
1902
|
-
function generateMachineId() {
|
|
1903
|
-
return `${MACHINE_ID_PREFIX}${randomUUID().replace(/-/g, "")}`;
|
|
1904
|
-
}
|
|
1905
|
-
function isStableMachineId(machineId) {
|
|
1906
|
-
return typeof machineId === "string" && machineId.startsWith(MACHINE_ID_PREFIX);
|
|
1907
|
-
}
|
|
1908
|
-
function ensureMachineId(config) {
|
|
1909
|
-
if (isStableMachineId(config.machineId)) {
|
|
1910
|
-
return { config, changed: false };
|
|
1911
|
-
}
|
|
1912
|
-
return {
|
|
1913
|
-
config: {
|
|
1914
|
-
...config,
|
|
1915
|
-
machineId: generateMachineId()
|
|
1916
|
-
},
|
|
1917
|
-
changed: true
|
|
1918
|
-
};
|
|
1919
|
-
}
|
|
1920
|
-
function getConfigDir() {
|
|
1921
|
-
const override = process.env.ADHDEV_CONFIG_DIR;
|
|
1922
|
-
const dir = override && override.trim() ? override.trim() : join3(homedir(), ".adhdev");
|
|
1923
|
-
if (!existsSync3(dir)) {
|
|
1924
|
-
mkdirSync(dir, { recursive: true });
|
|
1925
|
-
}
|
|
1926
|
-
return dir;
|
|
1927
|
-
}
|
|
1928
|
-
function getDaemonDataDir() {
|
|
1929
|
-
const dir = join3(getConfigDir(), "daemon");
|
|
1930
|
-
if (!existsSync3(dir)) {
|
|
1931
|
-
mkdirSync(dir, { recursive: true });
|
|
1932
|
-
}
|
|
1933
|
-
return dir;
|
|
1934
|
-
}
|
|
1935
|
-
function getConfigPath() {
|
|
1936
|
-
return join3(getConfigDir(), "config.json");
|
|
1937
|
-
}
|
|
1938
|
-
function migrateStateToStateFile(raw) {
|
|
1939
|
-
const statePath = join3(getConfigDir(), "state.json");
|
|
1940
|
-
if (existsSync3(statePath)) return;
|
|
1941
|
-
const recentActivity = Array.isArray(raw.recentActivity) ? raw.recentActivity : [];
|
|
1942
|
-
const savedProviderSessions = Array.isArray(raw.savedProviderSessions) ? raw.savedProviderSessions : [];
|
|
1943
|
-
const legacySessionReads = isPlainObject(raw.recentSessionReads) ? raw.recentSessionReads : {};
|
|
1944
|
-
const sessionReads = isPlainObject(raw.sessionReads) ? raw.sessionReads : {};
|
|
1945
|
-
const sessionReadMarkers = isPlainObject(raw.sessionReadMarkers) ? raw.sessionReadMarkers : {};
|
|
1946
|
-
const hasData = recentActivity.length > 0 || savedProviderSessions.length > 0 || Object.keys(sessionReads).length > 0 || Object.keys(legacySessionReads).length > 0 || Object.keys(sessionReadMarkers).length > 0;
|
|
1947
|
-
if (!hasData) return;
|
|
1948
|
-
const mergedReads = Object.fromEntries(
|
|
1949
|
-
Object.entries({ ...legacySessionReads, ...sessionReads }).filter(([, v]) => typeof v === "number" && Number.isFinite(v))
|
|
1950
|
-
);
|
|
1951
|
-
const cleanedMarkers = Object.fromEntries(
|
|
1952
|
-
Object.entries(sessionReadMarkers).filter(([, v]) => typeof v === "string")
|
|
1953
|
-
);
|
|
1954
|
-
const state = {
|
|
1955
|
-
recentActivity,
|
|
1956
|
-
savedProviderSessions,
|
|
1957
|
-
sessionReads: mergedReads,
|
|
1958
|
-
sessionReadMarkers: cleanedMarkers
|
|
1959
|
-
};
|
|
1960
|
-
writeFileSync(statePath, JSON.stringify(state, null, 2), { encoding: "utf-8", mode: 384 });
|
|
1961
|
-
}
|
|
1962
|
-
function loadConfig() {
|
|
1963
|
-
const configPath = getConfigPath();
|
|
1964
|
-
if (!existsSync3(configPath)) {
|
|
1965
|
-
const initialized = ensureMachineId({ ...DEFAULT_CONFIG });
|
|
1966
|
-
try {
|
|
1967
|
-
saveConfig(initialized.config);
|
|
1968
|
-
} catch {
|
|
1969
|
-
}
|
|
1970
|
-
return initialized.config;
|
|
1971
|
-
}
|
|
1972
|
-
try {
|
|
1973
|
-
const raw = readFileSync2(configPath, "utf-8");
|
|
1974
|
-
const parsed = JSON.parse(raw);
|
|
1975
|
-
migrateStateToStateFile(parsed);
|
|
1976
|
-
const normalizedInput = normalizeConfig(parsed);
|
|
1977
|
-
const ensured = ensureMachineId(normalizedInput);
|
|
1978
|
-
const normalized = ensured.config;
|
|
1979
|
-
if (ensured.changed || JSON.stringify(parsed) !== JSON.stringify(normalized)) {
|
|
1980
|
-
try {
|
|
1981
|
-
saveConfig(normalized);
|
|
1982
|
-
} catch {
|
|
1983
|
-
}
|
|
1984
|
-
}
|
|
1985
|
-
return normalized;
|
|
1986
|
-
} catch {
|
|
1987
|
-
const initialized = ensureMachineId({ ...DEFAULT_CONFIG });
|
|
1988
|
-
return initialized.config;
|
|
1989
|
-
}
|
|
1990
|
-
}
|
|
1991
|
-
function saveConfig(config) {
|
|
1992
|
-
const configPath = getConfigPath();
|
|
1993
|
-
const dir = getConfigDir();
|
|
1994
|
-
const normalized = normalizeConfig(config);
|
|
1995
|
-
if (!existsSync3(dir)) {
|
|
1996
|
-
mkdirSync(dir, { recursive: true, mode: 448 });
|
|
1997
|
-
}
|
|
1998
|
-
writeFileSync(configPath, JSON.stringify(normalized, null, 2), { encoding: "utf-8", mode: 384 });
|
|
1999
|
-
try {
|
|
2000
|
-
chmodSync(configPath, 384);
|
|
2001
|
-
} catch {
|
|
2002
|
-
}
|
|
2003
|
-
}
|
|
2004
|
-
function updateConfig(updates) {
|
|
2005
|
-
const config = loadConfig();
|
|
2006
|
-
const updated = { ...config, ...updates };
|
|
2007
|
-
saveConfig(updated);
|
|
2008
|
-
return updated;
|
|
2009
|
-
}
|
|
2010
|
-
function markSetupComplete(ideId, extensions) {
|
|
2011
|
-
const ideIds = Array.isArray(ideId) ? ideId : [ideId];
|
|
2012
|
-
return updateConfig({
|
|
2013
|
-
selectedIde: ideIds[0],
|
|
2014
|
-
configuredIdes: ideIds,
|
|
2015
|
-
installedExtensions: extensions,
|
|
2016
|
-
setupCompleted: true,
|
|
2017
|
-
setupDate: (/* @__PURE__ */ new Date()).toISOString()
|
|
2018
|
-
});
|
|
2019
|
-
}
|
|
2020
|
-
function isSetupComplete() {
|
|
2021
|
-
const config = loadConfig();
|
|
2022
|
-
return config.setupCompleted;
|
|
2023
|
-
}
|
|
2024
|
-
function resetConfig() {
|
|
2025
|
-
saveConfig({ ...DEFAULT_CONFIG });
|
|
2026
|
-
}
|
|
2027
|
-
var DEFAULT_CONFIG, MACHINE_ID_PREFIX;
|
|
2028
|
-
var init_config = __esm({
|
|
2029
|
-
"src/config/config.ts"() {
|
|
2030
|
-
"use strict";
|
|
2031
|
-
DEFAULT_CONFIG = {
|
|
2032
|
-
serverUrl: "https://api.adhf.dev",
|
|
2033
|
-
allowServerApiProxy: false,
|
|
2034
|
-
selectedIde: null,
|
|
2035
|
-
configuredIdes: [],
|
|
2036
|
-
installedExtensions: [],
|
|
2037
|
-
userEmail: null,
|
|
2038
|
-
userName: null,
|
|
2039
|
-
setupCompleted: false,
|
|
2040
|
-
setupDate: null,
|
|
2041
|
-
enabledIdes: [],
|
|
2042
|
-
workspaces: [],
|
|
2043
|
-
defaultWorkspaceId: null,
|
|
2044
|
-
machineNickname: null,
|
|
2045
|
-
machineId: void 0,
|
|
2046
|
-
machineSecret: null,
|
|
2047
|
-
registeredMachineId: void 0,
|
|
2048
|
-
providerSettings: {},
|
|
2049
|
-
machineProviders: {},
|
|
2050
|
-
ideSettings: {},
|
|
2051
|
-
providerSourceMode: "normal",
|
|
2052
|
-
updateChannel: "stable",
|
|
2053
|
-
terminalSizingMode: "measured"
|
|
2054
|
-
};
|
|
2055
|
-
MACHINE_ID_PREFIX = "mach_";
|
|
2056
|
-
}
|
|
2057
|
-
});
|
|
2058
|
-
|
|
2059
2059
|
// src/config/workspaces.ts
|
|
2060
2060
|
import * as fs from "fs";
|
|
2061
2061
|
import * as os from "os";
|
|
@@ -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
|
}
|
|
@@ -3198,12 +3198,23 @@ function addNode(meshId, opts) {
|
|
|
3198
3198
|
if (mesh.nodes.some((n) => n.workspace === opts.workspace)) {
|
|
3199
3199
|
throw new Error("This workspace is already in the mesh");
|
|
3200
3200
|
}
|
|
3201
|
+
const machineNickname = (() => {
|
|
3202
|
+
const explicit = typeof opts.machineNickname === "string" ? opts.machineNickname.trim() : "";
|
|
3203
|
+
if (explicit) return explicit;
|
|
3204
|
+
try {
|
|
3205
|
+
const local = loadConfig().machineNickname;
|
|
3206
|
+
return typeof local === "string" && local.trim() ? local.trim() : void 0;
|
|
3207
|
+
} catch {
|
|
3208
|
+
return void 0;
|
|
3209
|
+
}
|
|
3210
|
+
})();
|
|
3201
3211
|
const node = {
|
|
3202
3212
|
id: `node_${randomUUID3().replace(/-/g, "")}`,
|
|
3203
3213
|
workspace: opts.workspace.trim(),
|
|
3204
3214
|
repoRoot: opts.repoRoot,
|
|
3205
3215
|
daemonId: opts.daemonId,
|
|
3206
3216
|
machineId: opts.machineId,
|
|
3217
|
+
...machineNickname ? { machineNickname } : {},
|
|
3207
3218
|
capabilities: normalizeCapabilityTags(opts.capabilities),
|
|
3208
3219
|
userOverrides: opts.userOverrides || {},
|
|
3209
3220
|
policy: opts.policy || {},
|
|
@@ -3238,6 +3249,7 @@ function updateNode(meshId, nodeId, opts) {
|
|
|
3238
3249
|
if (opts.userOverrides) node.userOverrides = { ...node.userOverrides, ...opts.userOverrides };
|
|
3239
3250
|
if (opts.reportedPlatform && opts.reportedPlatform.trim()) node.reportedPlatform = opts.reportedPlatform.trim();
|
|
3240
3251
|
if (opts.reportedArch && opts.reportedArch.trim()) node.reportedArch = opts.reportedArch.trim();
|
|
3252
|
+
if (opts.reportedMachineNickname && opts.reportedMachineNickname.trim()) node.machineNickname = opts.reportedMachineNickname.trim();
|
|
3241
3253
|
if (opts.policy) node.policy = { ...node.policy, ...opts.policy };
|
|
3242
3254
|
if (opts.worktreeBootstrap) node.worktreeBootstrap = opts.worktreeBootstrap;
|
|
3243
3255
|
if (Object.prototype.hasOwnProperty.call(opts, "systemPrompt")) {
|
|
@@ -4172,10 +4184,10 @@ function rotateArchiveFile(meshId, archivePath) {
|
|
|
4172
4184
|
}
|
|
4173
4185
|
}
|
|
4174
4186
|
function readArchivedCounts(meshId) {
|
|
4175
|
-
const
|
|
4176
|
-
if (!existsSync7(
|
|
4187
|
+
const path44 = getArchivedCountsPath(meshId);
|
|
4188
|
+
if (!existsSync7(path44)) return { taskCompleted: 0, taskFailed: 0, taskStalled: 0, recoveryAttempted: 0, totalArchived: 0, lastArchivedAt: "" };
|
|
4177
4189
|
try {
|
|
4178
|
-
return JSON.parse(readFileSync5(
|
|
4190
|
+
return JSON.parse(readFileSync5(path44, "utf-8"));
|
|
4179
4191
|
} catch {
|
|
4180
4192
|
return { taskCompleted: 0, taskFailed: 0, taskStalled: 0, recoveryAttempted: 0, totalArchived: 0, lastArchivedAt: "" };
|
|
4181
4193
|
}
|
|
@@ -5382,11 +5394,11 @@ function readNodeReporter(node, key2) {
|
|
|
5382
5394
|
function buildMeshNodeCapabilityTags(node, providerType) {
|
|
5383
5395
|
const provider = typeof providerType === "string" && providerType.trim() ? providerType.trim() : firstProviderPriority(node?.policy);
|
|
5384
5396
|
const worktreeBranch = typeof node?.worktreeBranch === "string" && node.worktreeBranch.trim() ? node.worktreeBranch.trim() : null;
|
|
5385
|
-
const
|
|
5397
|
+
const os31 = readNodeOverride(node, "platform") ?? readNodeReporter(node, "platform") ?? process.platform;
|
|
5386
5398
|
const arch2 = readNodeOverride(node, "arch") ?? readNodeReporter(node, "arch") ?? process.arch;
|
|
5387
5399
|
return normalizeMeshCapabilityTags([
|
|
5388
5400
|
...Array.isArray(node?.capabilities) ? node.capabilities : [],
|
|
5389
|
-
`os=${
|
|
5401
|
+
`os=${os31}`,
|
|
5390
5402
|
`arch=${arch2}`,
|
|
5391
5403
|
...provider ? [`provider=${provider}`] : [],
|
|
5392
5404
|
// Worktree nodes automatically expose a "worktree=<branch>" tag so that
|
|
@@ -6279,10 +6291,10 @@ var init_mesh_runtime_store = __esm({
|
|
|
6279
6291
|
this.migratedMeshIds.add(meshId);
|
|
6280
6292
|
const count = this.db.prepare("SELECT COUNT(*) AS count FROM mesh_queue WHERE mesh_id = ?").get(meshId);
|
|
6281
6293
|
if (count.count > 0) return;
|
|
6282
|
-
const
|
|
6283
|
-
if (!existsSync8(
|
|
6294
|
+
const path44 = legacyQueuePath(meshId);
|
|
6295
|
+
if (!existsSync8(path44)) return;
|
|
6284
6296
|
try {
|
|
6285
|
-
const entries = JSON.parse(readFileSync6(
|
|
6297
|
+
const entries = JSON.parse(readFileSync6(path44, "utf-8"));
|
|
6286
6298
|
if (!Array.isArray(entries)) return;
|
|
6287
6299
|
const insert = this.db.prepare(`
|
|
6288
6300
|
INSERT OR REPLACE INTO mesh_queue (
|
|
@@ -8110,8 +8122,8 @@ function resolveMeshCoordinatorSetup(options) {
|
|
|
8110
8122
|
}
|
|
8111
8123
|
const serverName = mcpConfig.serverName?.trim() || DEFAULT_SERVER_NAME;
|
|
8112
8124
|
if (mcpConfig.mode === "auto_import") {
|
|
8113
|
-
const
|
|
8114
|
-
if (!
|
|
8125
|
+
const path44 = mcpConfig.path?.trim();
|
|
8126
|
+
if (!path44) {
|
|
8115
8127
|
return { kind: "unsupported", reason: "Provider auto-import MCP config is missing a config path" };
|
|
8116
8128
|
}
|
|
8117
8129
|
const mcpServer = resolveAdhdevMcpServerLaunch({
|
|
@@ -8131,7 +8143,7 @@ function resolveMeshCoordinatorSetup(options) {
|
|
|
8131
8143
|
return {
|
|
8132
8144
|
kind: "auto_import",
|
|
8133
8145
|
serverName,
|
|
8134
|
-
configPath: resolveMcpConfigPath(
|
|
8146
|
+
configPath: resolveMcpConfigPath(path44, workspace),
|
|
8135
8147
|
configFormat: mcpConfig.format,
|
|
8136
8148
|
mcpServer
|
|
8137
8149
|
};
|
|
@@ -8332,8 +8344,8 @@ function stripCoordinatorWrapperFile(filePath) {
|
|
|
8332
8344
|
const remaining = (existing.slice(0, openIdx) + existing.slice(closeIdx + CLOSE.length)).replace(/^\s*\n+/, "").replace(/\n+\s*$/, "");
|
|
8333
8345
|
if (!remaining.trim()) {
|
|
8334
8346
|
try {
|
|
8335
|
-
const
|
|
8336
|
-
|
|
8347
|
+
const fs39 = __require("fs");
|
|
8348
|
+
fs39.unlinkSync(filePath);
|
|
8337
8349
|
} catch {
|
|
8338
8350
|
}
|
|
8339
8351
|
} else {
|
|
@@ -8433,10 +8445,10 @@ function getRegistryPath() {
|
|
|
8433
8445
|
return join11(getDaemonDataDir(), "mesh-coordinators.json");
|
|
8434
8446
|
}
|
|
8435
8447
|
function loadMeshCoordinatorRegistry() {
|
|
8436
|
-
const
|
|
8437
|
-
if (!existsSync10(
|
|
8448
|
+
const path44 = getRegistryPath();
|
|
8449
|
+
if (!existsSync10(path44)) return;
|
|
8438
8450
|
try {
|
|
8439
|
-
const raw = JSON.parse(readFileSync8(
|
|
8451
|
+
const raw = JSON.parse(readFileSync8(path44, "utf-8"));
|
|
8440
8452
|
if (!Array.isArray(raw)) return;
|
|
8441
8453
|
_registry.clear();
|
|
8442
8454
|
for (const entry of raw) {
|
|
@@ -8608,8 +8620,8 @@ function validateMeshRefineConfig(config, source = "inline") {
|
|
|
8608
8620
|
if (rejectedCommands.length) errors.push("one or more validation commands are invalid");
|
|
8609
8621
|
return { valid: errors.length === 0, errors, bootstrapCommands, commands, rejectedCommands, bootstrapMode, deprecationWarnings };
|
|
8610
8622
|
}
|
|
8611
|
-
function parseConfigText2(
|
|
8612
|
-
if (/\.json$/i.test(
|
|
8623
|
+
function parseConfigText2(path44, text) {
|
|
8624
|
+
if (/\.json$/i.test(path44)) return JSON.parse(text);
|
|
8613
8625
|
return yaml2.load(text);
|
|
8614
8626
|
}
|
|
8615
8627
|
function loadMeshRefineConfig(mesh, workspace) {
|
|
@@ -8939,8 +8951,8 @@ function isCleanIgnoringSubmoduleGitlinks(porcelain, submodulePaths) {
|
|
|
8939
8951
|
const lines = porcelain.split(/\r?\n/).filter((line) => line.length > 0);
|
|
8940
8952
|
for (const line of lines) {
|
|
8941
8953
|
const status = line.slice(0, 2);
|
|
8942
|
-
const
|
|
8943
|
-
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);
|
|
8944
8956
|
if (!isGitlinkPointerMove) return false;
|
|
8945
8957
|
}
|
|
8946
8958
|
return true;
|
|
@@ -8971,8 +8983,8 @@ function isWorktreeBootstrapStaleRunning(node, nowMs = Date.now()) {
|
|
|
8971
8983
|
return false;
|
|
8972
8984
|
}
|
|
8973
8985
|
}
|
|
8974
|
-
function parseConfigText3(
|
|
8975
|
-
if (/\.json$/i.test(
|
|
8986
|
+
function parseConfigText3(path44, text) {
|
|
8987
|
+
if (/\.json$/i.test(path44)) return JSON.parse(text);
|
|
8976
8988
|
return yaml3.load(text);
|
|
8977
8989
|
}
|
|
8978
8990
|
function truncateOutput(value) {
|
|
@@ -9117,16 +9129,16 @@ async function runMeshWorktreeBootstrap(mesh, workspace) {
|
|
|
9117
9129
|
const startedAt = Date.now();
|
|
9118
9130
|
state.lastCommand = command.displayCommand;
|
|
9119
9131
|
const resolvedCommand = resolveWin32Executable(command.command);
|
|
9120
|
-
const
|
|
9132
|
+
const spawn5 = buildWin32ExecFileSpawn(resolvedCommand, command.args);
|
|
9121
9133
|
try {
|
|
9122
|
-
const result = await execFileAsync4(
|
|
9134
|
+
const result = await execFileAsync4(spawn5.file, spawn5.args, {
|
|
9123
9135
|
cwd,
|
|
9124
9136
|
encoding: "utf8",
|
|
9125
9137
|
timeout: command.timeoutMs || DEFAULT_TIMEOUT_MS2,
|
|
9126
9138
|
maxBuffer: command.outputLimitBytes || DEFAULT_OUTPUT_LIMIT_BYTES,
|
|
9127
9139
|
env: { ...process.env, CI: process.env.CI || "1", ...command.env || {} },
|
|
9128
9140
|
windowsHide: true,
|
|
9129
|
-
...
|
|
9141
|
+
...spawn5.windowsVerbatimArguments ? { windowsVerbatimArguments: true } : {}
|
|
9130
9142
|
});
|
|
9131
9143
|
state.commandsRun?.push({
|
|
9132
9144
|
command: command.command,
|
|
@@ -9246,8 +9258,8 @@ import * as yaml4 from "js-yaml";
|
|
|
9246
9258
|
function isRecord3(value) {
|
|
9247
9259
|
return !!value && typeof value === "object" && !Array.isArray(value);
|
|
9248
9260
|
}
|
|
9249
|
-
function parseConfigText4(
|
|
9250
|
-
if (/\.json$/i.test(
|
|
9261
|
+
function parseConfigText4(path44, text) {
|
|
9262
|
+
if (/\.json$/i.test(path44)) return JSON.parse(text);
|
|
9251
9263
|
return yaml4.load(text);
|
|
9252
9264
|
}
|
|
9253
9265
|
function normalizeOperatingNote(value) {
|
|
@@ -11053,10 +11065,10 @@ function readPendingMeshCoordinatorEventsFromDisk(meshId, coordinatorDaemonId) {
|
|
|
11053
11065
|
const primaryDaemonId = daemonIds[0];
|
|
11054
11066
|
const paths = primaryDaemonId ? [getPendingEventsPath(meshId, primaryDaemonId), getPendingEventsPath(meshId)] : [getPendingEventsPath(meshId)];
|
|
11055
11067
|
const events = [];
|
|
11056
|
-
for (const
|
|
11057
|
-
if (!existsSync15(
|
|
11068
|
+
for (const path44 of paths) {
|
|
11069
|
+
if (!existsSync15(path44)) continue;
|
|
11058
11070
|
try {
|
|
11059
|
-
const raw = readFileSync12(
|
|
11071
|
+
const raw = readFileSync12(path44, "utf-8");
|
|
11060
11072
|
const parsed = raw.split("\n").filter(Boolean).flatMap((line) => {
|
|
11061
11073
|
try {
|
|
11062
11074
|
return [JSON.parse(line)];
|
|
@@ -11064,7 +11076,7 @@ function readPendingMeshCoordinatorEventsFromDisk(meshId, coordinatorDaemonId) {
|
|
|
11064
11076
|
return [];
|
|
11065
11077
|
}
|
|
11066
11078
|
});
|
|
11067
|
-
const filtered = primaryDaemonId &&
|
|
11079
|
+
const filtered = primaryDaemonId && path44 === getPendingEventsPath(meshId) ? parsed.filter((e) => !e.targetCoordinatorDaemonId || daemonIds.includes(e.targetCoordinatorDaemonId)) : parsed;
|
|
11068
11080
|
events.push(...filtered);
|
|
11069
11081
|
} catch {
|
|
11070
11082
|
}
|
|
@@ -11129,11 +11141,11 @@ function reconcilePendingMeshCoordinatorEvents(meshId, events) {
|
|
|
11129
11141
|
const reconciled = terminalJobIds.size === 0 ? events : events.filter((event) => !(event.event === "refine:accepted" && terminalJobIds.has(readRefineJobId2(event))));
|
|
11130
11142
|
return backfilled.length === 0 ? reconciled : [...reconciled, ...backfilled];
|
|
11131
11143
|
}
|
|
11132
|
-
function trimPendingEventsIfNeeded(
|
|
11144
|
+
function trimPendingEventsIfNeeded(path44) {
|
|
11133
11145
|
try {
|
|
11134
|
-
if (!existsSync15(
|
|
11135
|
-
if (statSync6(
|
|
11136
|
-
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);
|
|
11137
11149
|
if (lines.length <= MAX_PENDING_EVENTS_KEEP) return;
|
|
11138
11150
|
const dropped = lines.slice(0, lines.length - MAX_PENDING_EVENTS_KEEP);
|
|
11139
11151
|
for (const line of dropped) {
|
|
@@ -11166,7 +11178,7 @@ function trimPendingEventsIfNeeded(path43) {
|
|
|
11166
11178
|
LOG.warn("MeshEvents", `Failed to ledger-record trim-dropped ${event.event} for mesh ${event.meshId}: ${e?.message || e}`);
|
|
11167
11179
|
}
|
|
11168
11180
|
}
|
|
11169
|
-
writeFileSync6(
|
|
11181
|
+
writeFileSync6(path44, lines.slice(-MAX_PENDING_EVENTS_KEEP).join("\n") + "\n", "utf-8");
|
|
11170
11182
|
} catch {
|
|
11171
11183
|
}
|
|
11172
11184
|
}
|
|
@@ -11196,9 +11208,9 @@ function queuePendingMeshCoordinatorEvent(event) {
|
|
|
11196
11208
|
} catch {
|
|
11197
11209
|
}
|
|
11198
11210
|
try {
|
|
11199
|
-
const
|
|
11200
|
-
trimPendingEventsIfNeeded(
|
|
11201
|
-
appendFileSync2(
|
|
11211
|
+
const path44 = getPendingEventsPath(event.meshId, event.targetCoordinatorDaemonId);
|
|
11212
|
+
trimPendingEventsIfNeeded(path44);
|
|
11213
|
+
appendFileSync2(path44, JSON.stringify(event) + "\n", "utf-8");
|
|
11202
11214
|
} catch (e) {
|
|
11203
11215
|
if (!sqliteOk) throw e;
|
|
11204
11216
|
LOG.warn("MeshEvents", `JSONL append failed for mesh ${event.meshId}; SQLite holds the event: ${e?.message || e}`);
|
|
@@ -11209,10 +11221,10 @@ function queuePendingMeshCoordinatorEvent(event) {
|
|
|
11209
11221
|
return false;
|
|
11210
11222
|
}
|
|
11211
11223
|
}
|
|
11212
|
-
function atomicDrainFile(
|
|
11213
|
-
const tmpPath = `${
|
|
11224
|
+
function atomicDrainFile(path44) {
|
|
11225
|
+
const tmpPath = `${path44}.draining`;
|
|
11214
11226
|
try {
|
|
11215
|
-
renameSync4(
|
|
11227
|
+
renameSync4(path44, tmpPath);
|
|
11216
11228
|
} catch {
|
|
11217
11229
|
return null;
|
|
11218
11230
|
}
|
|
@@ -11231,10 +11243,10 @@ function atomicDrainFile(path43) {
|
|
|
11231
11243
|
return null;
|
|
11232
11244
|
}
|
|
11233
11245
|
}
|
|
11234
|
-
function selectiveDrainFile(
|
|
11235
|
-
const tmpPath = `${
|
|
11246
|
+
function selectiveDrainFile(path44, predicate) {
|
|
11247
|
+
const tmpPath = `${path44}.draining`;
|
|
11236
11248
|
try {
|
|
11237
|
-
renameSync4(
|
|
11249
|
+
renameSync4(path44, tmpPath);
|
|
11238
11250
|
} catch {
|
|
11239
11251
|
return [];
|
|
11240
11252
|
}
|
|
@@ -11266,12 +11278,12 @@ function selectiveDrainFile(path43, predicate) {
|
|
|
11266
11278
|
}
|
|
11267
11279
|
try {
|
|
11268
11280
|
if (keptLines.length > 0) {
|
|
11269
|
-
writeFileSync6(
|
|
11281
|
+
writeFileSync6(path44, keptLines.join("\n") + "\n", "utf-8");
|
|
11270
11282
|
}
|
|
11271
11283
|
unlinkSync2(tmpPath);
|
|
11272
11284
|
} catch {
|
|
11273
11285
|
try {
|
|
11274
|
-
if (existsSync15(tmpPath) && !existsSync15(
|
|
11286
|
+
if (existsSync15(tmpPath) && !existsSync15(path44)) renameSync4(tmpPath, path44);
|
|
11275
11287
|
} catch {
|
|
11276
11288
|
}
|
|
11277
11289
|
return [];
|
|
@@ -11306,16 +11318,16 @@ function drainPendingMeshCoordinatorEvents(meshId, coordinatorDaemonId, opts) {
|
|
|
11306
11318
|
LOG.warn("MeshEvents", `SQLite pending-event drain failed for mesh ${meshId}; JSONL fallback only: ${e?.message || e}`);
|
|
11307
11319
|
}
|
|
11308
11320
|
const paths = primaryDaemonId ? [getPendingEventsPath(meshId, primaryDaemonId), getPendingEventsPath(meshId)] : [getPendingEventsPath(meshId)];
|
|
11309
|
-
for (const
|
|
11310
|
-
const isSharedFile = !!primaryDaemonId &&
|
|
11321
|
+
for (const path44 of paths) {
|
|
11322
|
+
const isSharedFile = !!primaryDaemonId && path44 === getPendingEventsPath(meshId);
|
|
11311
11323
|
const targets = (e) => !isSharedFile || !e.targetCoordinatorDaemonId || daemonIds.includes(e.targetCoordinatorDaemonId);
|
|
11312
11324
|
if (onlyEvents) {
|
|
11313
|
-
for (const event of selectiveDrainFile(
|
|
11325
|
+
for (const event of selectiveDrainFile(path44, (e) => targets(e) && matchesFilter(e.event))) {
|
|
11314
11326
|
pushUnique(event);
|
|
11315
11327
|
}
|
|
11316
11328
|
continue;
|
|
11317
11329
|
}
|
|
11318
|
-
const content = atomicDrainFile(
|
|
11330
|
+
const content = atomicDrainFile(path44);
|
|
11319
11331
|
if (!content) continue;
|
|
11320
11332
|
const parsed = content.split("\n").filter(Boolean).flatMap((line) => {
|
|
11321
11333
|
try {
|
|
@@ -11351,9 +11363,9 @@ function retractPendingDispatchBlockedEvent(meshId, taskId, coordinatorDaemonId)
|
|
|
11351
11363
|
const daemonIds = normalizeCoordinatorDaemonIds(coordinatorDaemonId);
|
|
11352
11364
|
const primaryDaemonId = daemonIds[0];
|
|
11353
11365
|
const paths = primaryDaemonId ? [getPendingEventsPath(meshId, primaryDaemonId), getPendingEventsPath(meshId)] : [getPendingEventsPath(meshId)];
|
|
11354
|
-
for (const
|
|
11366
|
+
for (const path44 of paths) {
|
|
11355
11367
|
try {
|
|
11356
|
-
removed += selectiveDrainFile(
|
|
11368
|
+
removed += selectiveDrainFile(path44, matchesTask).length;
|
|
11357
11369
|
} catch {
|
|
11358
11370
|
}
|
|
11359
11371
|
}
|
|
@@ -11394,9 +11406,9 @@ function clearPendingMeshCoordinatorEvents(meshId, coordinatorDaemonId) {
|
|
|
11394
11406
|
} catch {
|
|
11395
11407
|
}
|
|
11396
11408
|
const paths = coordinatorDaemonId ? [getPendingEventsPath(meshId, coordinatorDaemonId), getPendingEventsPath(meshId)] : [getPendingEventsPath(meshId)];
|
|
11397
|
-
for (const
|
|
11398
|
-
if (existsSync15(
|
|
11399
|
-
unlinkSync2(
|
|
11409
|
+
for (const path44 of paths) {
|
|
11410
|
+
if (existsSync15(path44)) try {
|
|
11411
|
+
unlinkSync2(path44);
|
|
11400
11412
|
} catch {
|
|
11401
11413
|
}
|
|
11402
11414
|
}
|
|
@@ -11870,9 +11882,9 @@ function findBinary(name) {
|
|
|
11870
11882
|
for (const ext of exes) {
|
|
11871
11883
|
const fullPath = path11.join(p, trimmed + ext);
|
|
11872
11884
|
try {
|
|
11873
|
-
const
|
|
11874
|
-
if (
|
|
11875
|
-
const stat2 =
|
|
11885
|
+
const fs39 = __require("fs");
|
|
11886
|
+
if (fs39.existsSync(fullPath)) {
|
|
11887
|
+
const stat2 = fs39.statSync(fullPath);
|
|
11876
11888
|
if (stat2.isFile() && (isWin || stat2.mode & 73)) {
|
|
11877
11889
|
return fullPath;
|
|
11878
11890
|
}
|
|
@@ -11886,12 +11898,12 @@ function findBinary(name) {
|
|
|
11886
11898
|
function isScriptBinary(binaryPath) {
|
|
11887
11899
|
if (!path11.isAbsolute(binaryPath)) return false;
|
|
11888
11900
|
try {
|
|
11889
|
-
const
|
|
11890
|
-
const resolved =
|
|
11901
|
+
const fs39 = __require("fs");
|
|
11902
|
+
const resolved = fs39.realpathSync(binaryPath);
|
|
11891
11903
|
const head = Buffer.alloc(8);
|
|
11892
|
-
const fd =
|
|
11893
|
-
|
|
11894
|
-
|
|
11904
|
+
const fd = fs39.openSync(resolved, "r");
|
|
11905
|
+
fs39.readSync(fd, head, 0, 8, 0);
|
|
11906
|
+
fs39.closeSync(fd);
|
|
11895
11907
|
let i = 0;
|
|
11896
11908
|
if (head[0] === 239 && head[1] === 187 && head[2] === 191) i = 3;
|
|
11897
11909
|
return head[i] === 35 && head[i + 1] === 33;
|
|
@@ -11902,12 +11914,12 @@ function isScriptBinary(binaryPath) {
|
|
|
11902
11914
|
function looksLikeMachOOrElf(filePath) {
|
|
11903
11915
|
if (!path11.isAbsolute(filePath)) return false;
|
|
11904
11916
|
try {
|
|
11905
|
-
const
|
|
11906
|
-
const resolved =
|
|
11917
|
+
const fs39 = __require("fs");
|
|
11918
|
+
const resolved = fs39.realpathSync(filePath);
|
|
11907
11919
|
const buf = Buffer.alloc(8);
|
|
11908
|
-
const fd =
|
|
11909
|
-
|
|
11910
|
-
|
|
11920
|
+
const fd = fs39.openSync(resolved, "r");
|
|
11921
|
+
fs39.readSync(fd, buf, 0, 8, 0);
|
|
11922
|
+
fs39.closeSync(fd);
|
|
11911
11923
|
let i = 0;
|
|
11912
11924
|
if (buf[0] === 239 && buf[1] === 187 && buf[2] === 191) i = 3;
|
|
11913
11925
|
const b = buf.subarray(i);
|
|
@@ -12196,19 +12208,19 @@ async function resolveDetectionPath(command, whichCmd) {
|
|
|
12196
12208
|
return null;
|
|
12197
12209
|
}
|
|
12198
12210
|
function execAsync(cmd, timeoutMs = 5e3) {
|
|
12199
|
-
return new Promise((
|
|
12211
|
+
return new Promise((resolve25) => {
|
|
12200
12212
|
const child = exec(cmd, {
|
|
12201
12213
|
encoding: "utf-8",
|
|
12202
12214
|
timeout: timeoutMs,
|
|
12203
12215
|
...process.platform === "win32" ? { windowsHide: true } : {}
|
|
12204
12216
|
}, (err, stdout) => {
|
|
12205
12217
|
if (err || !stdout?.trim()) {
|
|
12206
|
-
|
|
12218
|
+
resolve25(null);
|
|
12207
12219
|
} else {
|
|
12208
|
-
|
|
12220
|
+
resolve25(stdout.trim());
|
|
12209
12221
|
}
|
|
12210
12222
|
});
|
|
12211
|
-
child.on("error", () =>
|
|
12223
|
+
child.on("error", () => resolve25(null));
|
|
12212
12224
|
});
|
|
12213
12225
|
}
|
|
12214
12226
|
async function detectCLIs(providerLoader, options) {
|
|
@@ -12329,7 +12341,7 @@ var init_mesh_event_trace = __esm({
|
|
|
12329
12341
|
// src/mesh/mesh-warmup-deadline.ts
|
|
12330
12342
|
function awaitWithWarmupDeadline(work, opts) {
|
|
12331
12343
|
const pollMs = Math.max(1, Math.min(opts.pollIntervalMs ?? 200, opts.connectTimeoutMs));
|
|
12332
|
-
return new Promise((
|
|
12344
|
+
return new Promise((resolve25, reject) => {
|
|
12333
12345
|
let done = false;
|
|
12334
12346
|
let poll;
|
|
12335
12347
|
let responseTimer;
|
|
@@ -12379,7 +12391,7 @@ function awaitWithWarmupDeadline(work, opts) {
|
|
|
12379
12391
|
if (typeof poll.unref === "function") poll.unref();
|
|
12380
12392
|
}
|
|
12381
12393
|
work.then(
|
|
12382
|
-
(val) => settle(() =>
|
|
12394
|
+
(val) => settle(() => resolve25(val)),
|
|
12383
12395
|
(err) => settle(() => reject(err))
|
|
12384
12396
|
);
|
|
12385
12397
|
});
|
|
@@ -12483,7 +12495,7 @@ async function waitForLocalSessionReady(components, sessionId) {
|
|
|
12483
12495
|
const deadline = Date.now() + LOCAL_LAUNCH_READY_TIMEOUT_MS;
|
|
12484
12496
|
while (Date.now() < deadline) {
|
|
12485
12497
|
if (adapter.isReady() || adapter.currentStatus === "idle") return;
|
|
12486
|
-
await new Promise((
|
|
12498
|
+
await new Promise((resolve25) => setTimeout(resolve25, LOCAL_LAUNCH_READY_POLL_MS));
|
|
12487
12499
|
}
|
|
12488
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)`);
|
|
12489
12501
|
}
|
|
@@ -18915,7 +18927,7 @@ function getCliValidator() {
|
|
|
18915
18927
|
return _cliValidator;
|
|
18916
18928
|
}
|
|
18917
18929
|
function formatIssue(err) {
|
|
18918
|
-
const
|
|
18930
|
+
const path44 = err.instancePath || "";
|
|
18919
18931
|
const params = err.params;
|
|
18920
18932
|
let message = err.message || "validation failed";
|
|
18921
18933
|
let allowed;
|
|
@@ -18933,7 +18945,7 @@ function formatIssue(err) {
|
|
|
18933
18945
|
} else if (err.keyword === "type") {
|
|
18934
18946
|
message = `must be ${params.type}`;
|
|
18935
18947
|
}
|
|
18936
|
-
return { path:
|
|
18948
|
+
return { path: path44, keyword: err.keyword, message, ...allowed !== void 0 ? { allowed } : {} };
|
|
18937
18949
|
}
|
|
18938
18950
|
function validateCliProviderManifest(manifest) {
|
|
18939
18951
|
const validator = getCliValidator();
|
|
@@ -19228,40 +19240,40 @@ function validateFsmSpec(raw) {
|
|
|
19228
19240
|
}
|
|
19229
19241
|
return errs;
|
|
19230
19242
|
}
|
|
19231
|
-
function validateCondition(c, sectionIds,
|
|
19243
|
+
function validateCondition(c, sectionIds, path44) {
|
|
19232
19244
|
const errs = [];
|
|
19233
19245
|
const w = c;
|
|
19234
19246
|
if ("all" in w) {
|
|
19235
|
-
w.all.forEach((x, i) => errs.push(...validateCondition(x, sectionIds, `${
|
|
19247
|
+
w.all.forEach((x, i) => errs.push(...validateCondition(x, sectionIds, `${path44}.all[${i}]`)));
|
|
19236
19248
|
return errs;
|
|
19237
19249
|
}
|
|
19238
19250
|
if ("any" in w) {
|
|
19239
|
-
w.any.forEach((x, i) => errs.push(...validateCondition(x, sectionIds, `${
|
|
19251
|
+
w.any.forEach((x, i) => errs.push(...validateCondition(x, sectionIds, `${path44}.any[${i}]`)));
|
|
19240
19252
|
return errs;
|
|
19241
19253
|
}
|
|
19242
19254
|
if ("not" in w) {
|
|
19243
|
-
errs.push(...validateCondition(w.not, sectionIds, `${
|
|
19255
|
+
errs.push(...validateCondition(w.not, sectionIds, `${path44}.not`));
|
|
19244
19256
|
return errs;
|
|
19245
19257
|
}
|
|
19246
19258
|
if ("matches" in w) {
|
|
19247
|
-
if (w.section && !sectionIds.has(w.section)) errs.push(`${
|
|
19259
|
+
if (w.section && !sectionIds.has(w.section)) errs.push(`${path44}.section "${w.section}" unknown`);
|
|
19248
19260
|
try {
|
|
19249
19261
|
new RegExp(w.matches, w.flags ?? "i");
|
|
19250
19262
|
} catch (e) {
|
|
19251
|
-
errs.push(`${
|
|
19263
|
+
errs.push(`${path44}.matches invalid regex: ${e.message}`);
|
|
19252
19264
|
}
|
|
19253
19265
|
return errs;
|
|
19254
19266
|
}
|
|
19255
19267
|
if ("cursor_above" in w && "changed" in w) return errs;
|
|
19256
19268
|
if ("elapsed_ms" in w) {
|
|
19257
|
-
if (typeof w.elapsed_ms !== "number") errs.push(`${
|
|
19269
|
+
if (typeof w.elapsed_ms !== "number") errs.push(`${path44}.elapsed_ms must be a number`);
|
|
19258
19270
|
return errs;
|
|
19259
19271
|
}
|
|
19260
19272
|
if ("stable_ms" in w) {
|
|
19261
|
-
if (typeof w.stable_ms !== "number") errs.push(`${
|
|
19273
|
+
if (typeof w.stable_ms !== "number") errs.push(`${path44}.stable_ms must be a number`);
|
|
19262
19274
|
return errs;
|
|
19263
19275
|
}
|
|
19264
|
-
errs.push(`${
|
|
19276
|
+
errs.push(`${path44} is not a recognized condition`);
|
|
19265
19277
|
return errs;
|
|
19266
19278
|
}
|
|
19267
19279
|
var init_fsm_loader = __esm({
|
|
@@ -19754,8 +19766,8 @@ var init_pty_transport = __esm({
|
|
|
19754
19766
|
let cwd = options.cwd;
|
|
19755
19767
|
if (cwd) {
|
|
19756
19768
|
try {
|
|
19757
|
-
const
|
|
19758
|
-
const stat2 =
|
|
19769
|
+
const fs39 = __require("fs");
|
|
19770
|
+
const stat2 = fs39.statSync(cwd);
|
|
19759
19771
|
if (!stat2.isDirectory()) cwd = os14.homedir();
|
|
19760
19772
|
} catch {
|
|
19761
19773
|
cwd = os14.homedir();
|
|
@@ -22302,7 +22314,7 @@ ${lastSnapshot}`;
|
|
|
22302
22314
|
`[${this.cliType}] Waiting for interactive prompt: status=${status} stableMs=${stableMs} recentOutputMs=${recentlyOutput} screen=${JSON.stringify(summarizeCliTraceText(screenText, 220)).slice(0, 260)}`
|
|
22303
22315
|
);
|
|
22304
22316
|
}
|
|
22305
|
-
await new Promise((
|
|
22317
|
+
await new Promise((resolve25) => setTimeout(resolve25, 50));
|
|
22306
22318
|
}
|
|
22307
22319
|
const finalScreenText = this.terminalScreen.getText() || "";
|
|
22308
22320
|
LOG.warn(
|
|
@@ -22597,7 +22609,7 @@ ${lastSnapshot}`;
|
|
|
22597
22609
|
if (!this.ptyProcess) throw new Error(`${this.cliName} is not running`);
|
|
22598
22610
|
await this.ptyProcess.write(chunks[i]);
|
|
22599
22611
|
if (i + 1 < chunks.length) {
|
|
22600
|
-
await new Promise((
|
|
22612
|
+
await new Promise((resolve25) => setTimeout(resolve25, WIN32_PTY_WRITE_CHUNK_GAP_MS));
|
|
22601
22613
|
}
|
|
22602
22614
|
}
|
|
22603
22615
|
}
|
|
@@ -22765,7 +22777,7 @@ ${lastSnapshot}`;
|
|
|
22765
22777
|
this.onStatusChange?.();
|
|
22766
22778
|
}
|
|
22767
22779
|
async waitForForceSubmitSettle() {
|
|
22768
|
-
await new Promise((
|
|
22780
|
+
await new Promise((resolve25) => setTimeout(resolve25, FORCE_SUBMIT_SETTLE_MS));
|
|
22769
22781
|
}
|
|
22770
22782
|
enqueuePendingOutboundMessage(text, reason, meshTaskId) {
|
|
22771
22783
|
const content = String(text || "");
|
|
@@ -22844,7 +22856,7 @@ ${lastSnapshot}`;
|
|
|
22844
22856
|
const deadline = Date.now() + 1e4;
|
|
22845
22857
|
while (this.startupParseGate && Date.now() < deadline) {
|
|
22846
22858
|
this.resolveStartupState("send_wait");
|
|
22847
|
-
await new Promise((
|
|
22859
|
+
await new Promise((resolve25) => setTimeout(resolve25, 50));
|
|
22848
22860
|
}
|
|
22849
22861
|
}
|
|
22850
22862
|
const parsedStatusBeforeSend = !allowInputDuringGeneration ? (() => {
|
|
@@ -22937,13 +22949,13 @@ ${lastSnapshot}`;
|
|
|
22937
22949
|
isFirstTurn: !this.firstTurnSent
|
|
22938
22950
|
};
|
|
22939
22951
|
this.engine.responseSettleIgnoreUntil = Date.now() + submitDelayMs + this.timeouts.outputSettle + 250;
|
|
22940
|
-
await new Promise((
|
|
22952
|
+
await new Promise((resolve25, reject) => {
|
|
22941
22953
|
let resolved = false;
|
|
22942
22954
|
const completion = {
|
|
22943
22955
|
resolveOnce: () => {
|
|
22944
22956
|
if (resolved) return;
|
|
22945
22957
|
resolved = true;
|
|
22946
|
-
|
|
22958
|
+
resolve25();
|
|
22947
22959
|
},
|
|
22948
22960
|
rejectOnce: (error) => {
|
|
22949
22961
|
if (resolved) return;
|
|
@@ -23131,17 +23143,17 @@ ${lastSnapshot}`;
|
|
|
23131
23143
|
}
|
|
23132
23144
|
}
|
|
23133
23145
|
waitForStopped(timeoutMs) {
|
|
23134
|
-
return new Promise((
|
|
23146
|
+
return new Promise((resolve25) => {
|
|
23135
23147
|
const startedAt = Date.now();
|
|
23136
23148
|
const timer = setInterval(() => {
|
|
23137
23149
|
if (!this.ptyProcess || this.engine.currentStatus === "stopped") {
|
|
23138
23150
|
clearInterval(timer);
|
|
23139
|
-
|
|
23151
|
+
resolve25(true);
|
|
23140
23152
|
return;
|
|
23141
23153
|
}
|
|
23142
23154
|
if (Date.now() - startedAt >= timeoutMs) {
|
|
23143
23155
|
clearInterval(timer);
|
|
23144
|
-
|
|
23156
|
+
resolve25(false);
|
|
23145
23157
|
}
|
|
23146
23158
|
}, 100);
|
|
23147
23159
|
});
|
|
@@ -24534,6 +24546,7 @@ init_git_diff();
|
|
|
24534
24546
|
init_git_executor();
|
|
24535
24547
|
import * as path3 from "path";
|
|
24536
24548
|
init_git_status();
|
|
24549
|
+
init_config();
|
|
24537
24550
|
var GIT_COMMAND_NAMES = /* @__PURE__ */ new Set([
|
|
24538
24551
|
"git_status",
|
|
24539
24552
|
"git_diff_summary",
|
|
@@ -24673,7 +24686,21 @@ async function handleGitCommand(command, args, services = defaultGitCommandServi
|
|
|
24673
24686
|
if (submoduleIgnorePaths && submoduleIgnorePaths.length > 0) statusParams.submoduleIgnorePaths = submoduleIgnorePaths;
|
|
24674
24687
|
const status = await runService(() => services.getStatus(statusParams));
|
|
24675
24688
|
if ("success" in status) return status;
|
|
24676
|
-
|
|
24689
|
+
const reporterMachineNickname = (() => {
|
|
24690
|
+
try {
|
|
24691
|
+
const nick = loadConfig().machineNickname;
|
|
24692
|
+
return typeof nick === "string" && nick.trim() ? nick.trim() : void 0;
|
|
24693
|
+
} catch {
|
|
24694
|
+
return void 0;
|
|
24695
|
+
}
|
|
24696
|
+
})();
|
|
24697
|
+
return {
|
|
24698
|
+
success: true,
|
|
24699
|
+
status,
|
|
24700
|
+
reporterPlatform: process.platform,
|
|
24701
|
+
reporterArch: process.arch,
|
|
24702
|
+
...reporterMachineNickname ? { reporterMachineNickname } : {}
|
|
24703
|
+
};
|
|
24677
24704
|
}
|
|
24678
24705
|
case "git_diff_summary": {
|
|
24679
24706
|
if (!services.getDiffSummary) return serviceNotImplemented(command);
|
|
@@ -25429,17 +25456,17 @@ function checkPathExists(paths) {
|
|
|
25429
25456
|
return null;
|
|
25430
25457
|
}
|
|
25431
25458
|
async function detectIDEs(providerLoader) {
|
|
25432
|
-
const
|
|
25459
|
+
const os31 = platform5();
|
|
25433
25460
|
const results = [];
|
|
25434
25461
|
for (const def of getMergedDefinitions()) {
|
|
25435
25462
|
const cliPath = findCliCommand(providerLoader?.getIdeCliCommand(def.id, def.cli) || def.cli);
|
|
25436
|
-
const appPath = checkPathExists(providerLoader?.getIdePathCandidates(def.id, def.paths[
|
|
25463
|
+
const appPath = checkPathExists(providerLoader?.getIdePathCandidates(def.id, def.paths[os31] || []) || []);
|
|
25437
25464
|
let resolvedCli = cliPath;
|
|
25438
|
-
if (!resolvedCli && appPath &&
|
|
25465
|
+
if (!resolvedCli && appPath && os31 === "darwin") {
|
|
25439
25466
|
const bundledCli = `${appPath}/Contents/Resources/app/bin/${def.cli}`;
|
|
25440
25467
|
if (existsSync20(bundledCli)) resolvedCli = bundledCli;
|
|
25441
25468
|
}
|
|
25442
|
-
if (!resolvedCli && appPath &&
|
|
25469
|
+
if (!resolvedCli && appPath && os31 === "win32") {
|
|
25443
25470
|
const { dirname: dirname17 } = await import("path");
|
|
25444
25471
|
const appDir = dirname17(appPath);
|
|
25445
25472
|
const candidates = [
|
|
@@ -25456,7 +25483,7 @@ async function detectIDEs(providerLoader) {
|
|
|
25456
25483
|
}
|
|
25457
25484
|
}
|
|
25458
25485
|
}
|
|
25459
|
-
const installed =
|
|
25486
|
+
const installed = os31 === "darwin" ? !!(resolvedCli || appPath) : !!resolvedCli;
|
|
25460
25487
|
const version = null;
|
|
25461
25488
|
results.push({
|
|
25462
25489
|
id: def.id,
|
|
@@ -25715,7 +25742,7 @@ var DaemonCdpManager = class {
|
|
|
25715
25742
|
* Returns multiple entries if multiple IDE windows are open on same port
|
|
25716
25743
|
*/
|
|
25717
25744
|
static listAllTargets(port) {
|
|
25718
|
-
return new Promise((
|
|
25745
|
+
return new Promise((resolve25) => {
|
|
25719
25746
|
const req = http.get(`http://127.0.0.1:${port}/json`, (res) => {
|
|
25720
25747
|
let data = "";
|
|
25721
25748
|
res.on("data", (chunk) => data += chunk.toString());
|
|
@@ -25731,16 +25758,16 @@ var DaemonCdpManager = class {
|
|
|
25731
25758
|
(t) => !isNonMain(t.title || "") && t.url?.includes("workbench.html") && !t.url?.includes("agent")
|
|
25732
25759
|
);
|
|
25733
25760
|
const fallbackPages = pages.filter((t) => !isNonMain(t.title || ""));
|
|
25734
|
-
|
|
25761
|
+
resolve25(mainPages.length > 0 ? mainPages : fallbackPages);
|
|
25735
25762
|
} catch {
|
|
25736
|
-
|
|
25763
|
+
resolve25([]);
|
|
25737
25764
|
}
|
|
25738
25765
|
});
|
|
25739
25766
|
});
|
|
25740
|
-
req.on("error", () =>
|
|
25767
|
+
req.on("error", () => resolve25([]));
|
|
25741
25768
|
req.setTimeout(2e3, () => {
|
|
25742
25769
|
req.destroy();
|
|
25743
|
-
|
|
25770
|
+
resolve25([]);
|
|
25744
25771
|
});
|
|
25745
25772
|
});
|
|
25746
25773
|
}
|
|
@@ -25780,7 +25807,7 @@ var DaemonCdpManager = class {
|
|
|
25780
25807
|
}
|
|
25781
25808
|
}
|
|
25782
25809
|
findTargetOnPort(port) {
|
|
25783
|
-
return new Promise((
|
|
25810
|
+
return new Promise((resolve25) => {
|
|
25784
25811
|
const req = http.get(`http://127.0.0.1:${port}/json`, (res) => {
|
|
25785
25812
|
let data = "";
|
|
25786
25813
|
res.on("data", (chunk) => data += chunk.toString());
|
|
@@ -25791,7 +25818,7 @@ var DaemonCdpManager = class {
|
|
|
25791
25818
|
(t) => (t.type === "page" || t.type === "browser" || t.type === "Page") && t.webSocketDebuggerUrl
|
|
25792
25819
|
);
|
|
25793
25820
|
if (pages.length === 0) {
|
|
25794
|
-
|
|
25821
|
+
resolve25(targets.find((t) => t.webSocketDebuggerUrl) || null);
|
|
25795
25822
|
return;
|
|
25796
25823
|
}
|
|
25797
25824
|
const titleFilteredPages = pages.filter((t) => !this.isNonMainTitle(t.title || ""));
|
|
@@ -25810,25 +25837,25 @@ var DaemonCdpManager = class {
|
|
|
25810
25837
|
this._targetId = selected.target.id;
|
|
25811
25838
|
}
|
|
25812
25839
|
this._pageTitle = selected.target.title || "";
|
|
25813
|
-
|
|
25840
|
+
resolve25(selected.target);
|
|
25814
25841
|
return;
|
|
25815
25842
|
}
|
|
25816
25843
|
if (previousTargetId) {
|
|
25817
25844
|
this.log(`[CDP] Target ${previousTargetId} not found in page list`);
|
|
25818
|
-
|
|
25845
|
+
resolve25(null);
|
|
25819
25846
|
return;
|
|
25820
25847
|
}
|
|
25821
25848
|
this._pageTitle = list[0]?.title || "";
|
|
25822
|
-
|
|
25849
|
+
resolve25(list[0]);
|
|
25823
25850
|
} catch {
|
|
25824
|
-
|
|
25851
|
+
resolve25(null);
|
|
25825
25852
|
}
|
|
25826
25853
|
});
|
|
25827
25854
|
});
|
|
25828
|
-
req.on("error", () =>
|
|
25855
|
+
req.on("error", () => resolve25(null));
|
|
25829
25856
|
req.setTimeout(2e3, () => {
|
|
25830
25857
|
req.destroy();
|
|
25831
|
-
|
|
25858
|
+
resolve25(null);
|
|
25832
25859
|
});
|
|
25833
25860
|
});
|
|
25834
25861
|
}
|
|
@@ -25839,7 +25866,7 @@ var DaemonCdpManager = class {
|
|
|
25839
25866
|
this.extensionProviders = providers;
|
|
25840
25867
|
}
|
|
25841
25868
|
connectToTarget(wsUrl) {
|
|
25842
|
-
return new Promise((
|
|
25869
|
+
return new Promise((resolve25) => {
|
|
25843
25870
|
this.ws = new WebSocket(wsUrl);
|
|
25844
25871
|
this.ws.on("open", async () => {
|
|
25845
25872
|
this._connected = true;
|
|
@@ -25849,17 +25876,17 @@ var DaemonCdpManager = class {
|
|
|
25849
25876
|
}
|
|
25850
25877
|
this.connectBrowserWs().catch(() => {
|
|
25851
25878
|
});
|
|
25852
|
-
|
|
25879
|
+
resolve25(true);
|
|
25853
25880
|
});
|
|
25854
25881
|
this.ws.on("message", (data) => {
|
|
25855
25882
|
try {
|
|
25856
25883
|
const msg = JSON.parse(data.toString());
|
|
25857
25884
|
if (msg.id && this.pending.has(msg.id)) {
|
|
25858
|
-
const { resolve:
|
|
25885
|
+
const { resolve: resolve26, reject } = this.pending.get(msg.id);
|
|
25859
25886
|
this.pending.delete(msg.id);
|
|
25860
25887
|
this.failureCount = 0;
|
|
25861
25888
|
if (msg.error) reject(new Error(msg.error.message));
|
|
25862
|
-
else
|
|
25889
|
+
else resolve26(msg.result);
|
|
25863
25890
|
} else if (msg.method === "Runtime.executionContextCreated") {
|
|
25864
25891
|
this.contexts.add(msg.params.context.id);
|
|
25865
25892
|
} else if (msg.method === "Runtime.executionContextDestroyed") {
|
|
@@ -25882,7 +25909,7 @@ var DaemonCdpManager = class {
|
|
|
25882
25909
|
this.ws.on("error", (err) => {
|
|
25883
25910
|
this.log(`[CDP] WebSocket error: ${err.message}`);
|
|
25884
25911
|
this._connected = false;
|
|
25885
|
-
|
|
25912
|
+
resolve25(false);
|
|
25886
25913
|
});
|
|
25887
25914
|
});
|
|
25888
25915
|
}
|
|
@@ -25896,7 +25923,7 @@ var DaemonCdpManager = class {
|
|
|
25896
25923
|
return;
|
|
25897
25924
|
}
|
|
25898
25925
|
this.log(`[CDP] Connecting browser WS for target discovery...`);
|
|
25899
|
-
await new Promise((
|
|
25926
|
+
await new Promise((resolve25, reject) => {
|
|
25900
25927
|
this.browserWs = new WebSocket(browserWsUrl);
|
|
25901
25928
|
this.browserWs.on("open", async () => {
|
|
25902
25929
|
this._browserConnected = true;
|
|
@@ -25906,16 +25933,16 @@ var DaemonCdpManager = class {
|
|
|
25906
25933
|
} catch (e) {
|
|
25907
25934
|
this.log(`[CDP] setDiscoverTargets failed: ${e.message}`);
|
|
25908
25935
|
}
|
|
25909
|
-
|
|
25936
|
+
resolve25();
|
|
25910
25937
|
});
|
|
25911
25938
|
this.browserWs.on("message", (data) => {
|
|
25912
25939
|
try {
|
|
25913
25940
|
const msg = JSON.parse(data.toString());
|
|
25914
25941
|
if (msg.id && this.browserPending.has(msg.id)) {
|
|
25915
|
-
const { resolve:
|
|
25942
|
+
const { resolve: resolve26, reject: reject2 } = this.browserPending.get(msg.id);
|
|
25916
25943
|
this.browserPending.delete(msg.id);
|
|
25917
25944
|
if (msg.error) reject2(new Error(msg.error.message));
|
|
25918
|
-
else
|
|
25945
|
+
else resolve26(msg.result);
|
|
25919
25946
|
}
|
|
25920
25947
|
} catch {
|
|
25921
25948
|
}
|
|
@@ -25935,31 +25962,31 @@ var DaemonCdpManager = class {
|
|
|
25935
25962
|
}
|
|
25936
25963
|
}
|
|
25937
25964
|
getBrowserWsUrl() {
|
|
25938
|
-
return new Promise((
|
|
25965
|
+
return new Promise((resolve25) => {
|
|
25939
25966
|
const req = http.get(`http://127.0.0.1:${this.port}/json/version`, (res) => {
|
|
25940
25967
|
let data = "";
|
|
25941
25968
|
res.on("data", (chunk) => data += chunk.toString());
|
|
25942
25969
|
res.on("end", () => {
|
|
25943
25970
|
try {
|
|
25944
25971
|
const info = JSON.parse(data);
|
|
25945
|
-
|
|
25972
|
+
resolve25(info.webSocketDebuggerUrl || null);
|
|
25946
25973
|
} catch {
|
|
25947
|
-
|
|
25974
|
+
resolve25(null);
|
|
25948
25975
|
}
|
|
25949
25976
|
});
|
|
25950
25977
|
});
|
|
25951
|
-
req.on("error", () =>
|
|
25978
|
+
req.on("error", () => resolve25(null));
|
|
25952
25979
|
req.setTimeout(3e3, () => {
|
|
25953
25980
|
req.destroy();
|
|
25954
|
-
|
|
25981
|
+
resolve25(null);
|
|
25955
25982
|
});
|
|
25956
25983
|
});
|
|
25957
25984
|
}
|
|
25958
25985
|
sendBrowser(method, params = {}, timeoutMs = 15e3) {
|
|
25959
|
-
return new Promise((
|
|
25986
|
+
return new Promise((resolve25, reject) => {
|
|
25960
25987
|
if (!this.browserWs || !this._browserConnected) return reject(new Error("Browser WS not connected"));
|
|
25961
25988
|
const id = this.browserMsgId++;
|
|
25962
|
-
this.browserPending.set(id, { resolve:
|
|
25989
|
+
this.browserPending.set(id, { resolve: resolve25, reject });
|
|
25963
25990
|
this.browserWs.send(JSON.stringify({ id, method, params }));
|
|
25964
25991
|
setTimeout(() => {
|
|
25965
25992
|
if (this.browserPending.has(id)) {
|
|
@@ -25999,11 +26026,11 @@ var DaemonCdpManager = class {
|
|
|
25999
26026
|
}
|
|
26000
26027
|
// ─── CDP Protocol ────────────────────────────────────────
|
|
26001
26028
|
sendInternal(method, params = {}, timeoutMs = 15e3) {
|
|
26002
|
-
return new Promise((
|
|
26029
|
+
return new Promise((resolve25, reject) => {
|
|
26003
26030
|
if (!this.ws || !this._connected) return reject(new Error("CDP not connected"));
|
|
26004
26031
|
if (this.ws.readyState !== WebSocket.OPEN) return reject(new Error("WebSocket not open"));
|
|
26005
26032
|
const id = this.msgId++;
|
|
26006
|
-
this.pending.set(id, { resolve:
|
|
26033
|
+
this.pending.set(id, { resolve: resolve25, reject });
|
|
26007
26034
|
this.ws.send(JSON.stringify({ id, method, params }));
|
|
26008
26035
|
setTimeout(() => {
|
|
26009
26036
|
if (this.pending.has(id)) {
|
|
@@ -26252,7 +26279,7 @@ var DaemonCdpManager = class {
|
|
|
26252
26279
|
const browserWs = this.browserWs;
|
|
26253
26280
|
let msgId = this.browserMsgId;
|
|
26254
26281
|
const sendWs = (method, params = {}, sessionId) => {
|
|
26255
|
-
return new Promise((
|
|
26282
|
+
return new Promise((resolve25, reject) => {
|
|
26256
26283
|
const mid = msgId++;
|
|
26257
26284
|
this.browserMsgId = msgId;
|
|
26258
26285
|
const handler = (raw) => {
|
|
@@ -26261,7 +26288,7 @@ var DaemonCdpManager = class {
|
|
|
26261
26288
|
if (msg.id === mid) {
|
|
26262
26289
|
browserWs.removeListener("message", handler);
|
|
26263
26290
|
if (msg.error) reject(new Error(msg.error.message || JSON.stringify(msg.error)));
|
|
26264
|
-
else
|
|
26291
|
+
else resolve25(msg.result);
|
|
26265
26292
|
}
|
|
26266
26293
|
} catch {
|
|
26267
26294
|
}
|
|
@@ -26462,14 +26489,14 @@ var DaemonCdpManager = class {
|
|
|
26462
26489
|
if (!ws || ws.readyState !== WebSocket.OPEN) {
|
|
26463
26490
|
throw new Error("CDP not connected");
|
|
26464
26491
|
}
|
|
26465
|
-
return new Promise((
|
|
26492
|
+
return new Promise((resolve25, reject) => {
|
|
26466
26493
|
const id = getNextId();
|
|
26467
26494
|
pendingMap.set(id, {
|
|
26468
26495
|
resolve: (result) => {
|
|
26469
26496
|
if (result?.result?.subtype === "error") {
|
|
26470
26497
|
reject(new Error(result.result.description));
|
|
26471
26498
|
} else {
|
|
26472
|
-
|
|
26499
|
+
resolve25(result?.result?.value);
|
|
26473
26500
|
}
|
|
26474
26501
|
},
|
|
26475
26502
|
reject
|
|
@@ -26501,10 +26528,10 @@ var DaemonCdpManager = class {
|
|
|
26501
26528
|
throw new Error("CDP not connected");
|
|
26502
26529
|
}
|
|
26503
26530
|
const sendViaSession = (method, params = {}) => {
|
|
26504
|
-
return new Promise((
|
|
26531
|
+
return new Promise((resolve25, reject) => {
|
|
26505
26532
|
const pendingMap = this._browserConnected ? this.browserPending : this.pending;
|
|
26506
26533
|
const id = this._browserConnected ? this.browserMsgId++ : this.msgId++;
|
|
26507
|
-
pendingMap.set(id, { resolve:
|
|
26534
|
+
pendingMap.set(id, { resolve: resolve25, reject });
|
|
26508
26535
|
ws.send(JSON.stringify({ id, sessionId, method, params }));
|
|
26509
26536
|
setTimeout(() => {
|
|
26510
26537
|
if (pendingMap.has(id)) {
|
|
@@ -32734,7 +32761,7 @@ function getSendChatInputEnvelope(args) {
|
|
|
32734
32761
|
return normalizeInputEnvelope(args?.input ? { input: args.input } : args);
|
|
32735
32762
|
}
|
|
32736
32763
|
function sleep(ms) {
|
|
32737
|
-
return new Promise((
|
|
32764
|
+
return new Promise((resolve25) => setTimeout(resolve25, ms));
|
|
32738
32765
|
}
|
|
32739
32766
|
async function waitOnceForFreshHermesCliStart(adapter, log) {
|
|
32740
32767
|
if (adapter.cliType !== "hermes-cli") return;
|
|
@@ -32789,7 +32816,7 @@ function getStateLastSignature(state) {
|
|
|
32789
32816
|
async function getStableExtensionBaseline(h) {
|
|
32790
32817
|
const first = await readExtensionChatState(h);
|
|
32791
32818
|
if (getStateMessageCount(first) > 0 || getStateLastSignature(first)) return first;
|
|
32792
|
-
await new Promise((
|
|
32819
|
+
await new Promise((resolve25) => setTimeout(resolve25, 150));
|
|
32793
32820
|
const second = await readExtensionChatState(h);
|
|
32794
32821
|
return getStateMessageCount(second) >= getStateMessageCount(first) ? second : first;
|
|
32795
32822
|
}
|
|
@@ -32797,7 +32824,7 @@ async function verifyExtensionSendObserved(h, before) {
|
|
|
32797
32824
|
const beforeCount = getStateMessageCount(before);
|
|
32798
32825
|
const beforeSignature = getStateLastSignature(before);
|
|
32799
32826
|
for (let attempt = 0; attempt < 12; attempt += 1) {
|
|
32800
|
-
await new Promise((
|
|
32827
|
+
await new Promise((resolve25) => setTimeout(resolve25, 250));
|
|
32801
32828
|
const state = await readExtensionChatState(h);
|
|
32802
32829
|
if (state?.status === "waiting_approval") return true;
|
|
32803
32830
|
const afterCount = getStateMessageCount(state);
|
|
@@ -34199,7 +34226,7 @@ async function executeProviderScript(h, args, scriptName) {
|
|
|
34199
34226
|
const enterCount = cliCommand.enterCount || 1;
|
|
34200
34227
|
await adapter.writeRaw(cliCommand.text + "\r");
|
|
34201
34228
|
for (let i = 1; i < enterCount; i += 1) {
|
|
34202
|
-
await new Promise((
|
|
34229
|
+
await new Promise((resolve25) => setTimeout(resolve25, 50));
|
|
34203
34230
|
await adapter.writeRaw("\r");
|
|
34204
34231
|
}
|
|
34205
34232
|
}
|
|
@@ -34976,9 +35003,9 @@ var DaemonCommandHandler = class {
|
|
|
34976
35003
|
* point at a sibling git checkout.
|
|
34977
35004
|
*/
|
|
34978
35005
|
getUpstreamInstallRoot() {
|
|
34979
|
-
const
|
|
34980
|
-
const
|
|
34981
|
-
return
|
|
35006
|
+
const os31 = __require("os");
|
|
35007
|
+
const path44 = __require("path");
|
|
35008
|
+
return path44.join(os31.homedir(), ".adhdev", "providers", ".upstream");
|
|
34982
35009
|
}
|
|
34983
35010
|
/**
|
|
34984
35011
|
* Download a single provider manifest from the registry and write it to
|
|
@@ -35002,11 +35029,11 @@ var DaemonCommandHandler = class {
|
|
|
35002
35029
|
return { success: false, error: "invalid type" };
|
|
35003
35030
|
}
|
|
35004
35031
|
const https = __require("https");
|
|
35005
|
-
const
|
|
35006
|
-
const
|
|
35032
|
+
const fs39 = __require("fs");
|
|
35033
|
+
const path44 = __require("path");
|
|
35007
35034
|
const REGISTRY = "https://api.adhf.dev/api/v1/registry";
|
|
35008
35035
|
function fetchText(url, timeoutMs) {
|
|
35009
|
-
return new Promise((
|
|
35036
|
+
return new Promise((resolve25, reject) => {
|
|
35010
35037
|
const req = https.get(url, { headers: { "User-Agent": "adhdev-daemon", "Accept": "application/json" }, timeout: timeoutMs }, (res) => {
|
|
35011
35038
|
if (res.statusCode !== 200) {
|
|
35012
35039
|
reject(new Error(`HTTP ${res.statusCode}`));
|
|
@@ -35014,7 +35041,7 @@ var DaemonCommandHandler = class {
|
|
|
35014
35041
|
}
|
|
35015
35042
|
const chunks = [];
|
|
35016
35043
|
res.on("data", (c) => chunks.push(c));
|
|
35017
|
-
res.on("end", () =>
|
|
35044
|
+
res.on("end", () => resolve25(Buffer.concat(chunks).toString("utf-8")));
|
|
35018
35045
|
});
|
|
35019
35046
|
req.on("error", reject);
|
|
35020
35047
|
req.on("timeout", () => {
|
|
@@ -35040,12 +35067,12 @@ var DaemonCommandHandler = class {
|
|
|
35040
35067
|
return { success: false, error: `checksum mismatch: expected ${meta.checksum}, got ${actualChecksum}` };
|
|
35041
35068
|
}
|
|
35042
35069
|
const installRoot = this.getUpstreamInstallRoot();
|
|
35043
|
-
const installRootResolved =
|
|
35044
|
-
const targetDir =
|
|
35045
|
-
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)) {
|
|
35046
35073
|
return { success: false, error: "install path escaped upstream root" };
|
|
35047
35074
|
}
|
|
35048
|
-
|
|
35075
|
+
fs39.mkdirSync(targetDir, { recursive: true });
|
|
35049
35076
|
let manifestProbe = {};
|
|
35050
35077
|
try {
|
|
35051
35078
|
manifestProbe = JSON.parse(manifestBody);
|
|
@@ -35069,8 +35096,8 @@ ${formatManifestValidationIssues2(validation.issues)}`,
|
|
|
35069
35096
|
}
|
|
35070
35097
|
}
|
|
35071
35098
|
const targetFile = isV1 ? "provider.v1.json" : "provider.json";
|
|
35072
|
-
const targetPath =
|
|
35073
|
-
|
|
35099
|
+
const targetPath = path44.join(targetDir, targetFile);
|
|
35100
|
+
fs39.writeFileSync(targetPath, manifestBody, "utf-8");
|
|
35074
35101
|
const manifestJson = JSON.parse(manifestBody);
|
|
35075
35102
|
const scriptFetch = await this.fetchProviderSources(
|
|
35076
35103
|
manifestJson,
|
|
@@ -35140,10 +35167,10 @@ ${formatManifestValidationIssues2(validation.issues)}`,
|
|
|
35140
35167
|
const repo = source.repo;
|
|
35141
35168
|
const ref = source.ref;
|
|
35142
35169
|
const https = __require("https");
|
|
35143
|
-
const
|
|
35144
|
-
const
|
|
35170
|
+
const fs39 = __require("fs");
|
|
35171
|
+
const path44 = __require("path");
|
|
35145
35172
|
function fetchJson(url, timeoutMs) {
|
|
35146
|
-
return new Promise((
|
|
35173
|
+
return new Promise((resolve25, reject) => {
|
|
35147
35174
|
const req = https.get(url, {
|
|
35148
35175
|
headers: { "User-Agent": "adhdev-daemon", "Accept": "application/vnd.github+json" },
|
|
35149
35176
|
timeout: timeoutMs
|
|
@@ -35156,7 +35183,7 @@ ${formatManifestValidationIssues2(validation.issues)}`,
|
|
|
35156
35183
|
res.on("data", (c) => chunks.push(c));
|
|
35157
35184
|
res.on("end", () => {
|
|
35158
35185
|
try {
|
|
35159
|
-
|
|
35186
|
+
resolve25(JSON.parse(Buffer.concat(chunks).toString("utf-8")));
|
|
35160
35187
|
} catch (e) {
|
|
35161
35188
|
reject(e);
|
|
35162
35189
|
}
|
|
@@ -35170,14 +35197,14 @@ ${formatManifestValidationIssues2(validation.issues)}`,
|
|
|
35170
35197
|
});
|
|
35171
35198
|
}
|
|
35172
35199
|
function fetchBinary(url, timeoutMs) {
|
|
35173
|
-
return new Promise((
|
|
35200
|
+
return new Promise((resolve25, reject) => {
|
|
35174
35201
|
const req = https.get(url, {
|
|
35175
35202
|
headers: { "User-Agent": "adhdev-daemon" },
|
|
35176
35203
|
timeout: timeoutMs
|
|
35177
35204
|
}, (res) => {
|
|
35178
35205
|
if (res.statusCode === 301 || res.statusCode === 302) {
|
|
35179
35206
|
if (res.headers.location) {
|
|
35180
|
-
return fetchBinary(res.headers.location, timeoutMs).then(
|
|
35207
|
+
return fetchBinary(res.headers.location, timeoutMs).then(resolve25, reject);
|
|
35181
35208
|
}
|
|
35182
35209
|
}
|
|
35183
35210
|
if (res.statusCode !== 200) {
|
|
@@ -35186,7 +35213,7 @@ ${formatManifestValidationIssues2(validation.issues)}`,
|
|
|
35186
35213
|
}
|
|
35187
35214
|
const chunks = [];
|
|
35188
35215
|
res.on("data", (c) => chunks.push(c));
|
|
35189
|
-
res.on("end", () =>
|
|
35216
|
+
res.on("end", () => resolve25(Buffer.concat(chunks)));
|
|
35190
35217
|
});
|
|
35191
35218
|
req.on("error", reject);
|
|
35192
35219
|
req.on("timeout", () => {
|
|
@@ -35197,9 +35224,9 @@ ${formatManifestValidationIssues2(validation.issues)}`,
|
|
|
35197
35224
|
}
|
|
35198
35225
|
let fetchedCount = 0;
|
|
35199
35226
|
const sharedDirRel = `${category}/_shared`;
|
|
35200
|
-
const sharedTargetDir =
|
|
35201
|
-
const installRootResolved =
|
|
35202
|
-
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)) {
|
|
35203
35230
|
const sharedStack = [sharedDirRel];
|
|
35204
35231
|
while (sharedStack.length) {
|
|
35205
35232
|
const relDir = sharedStack.pop();
|
|
@@ -35222,10 +35249,10 @@ ${formatManifestValidationIssues2(validation.issues)}`,
|
|
|
35222
35249
|
try {
|
|
35223
35250
|
const body = await fetchBinary(entry.download_url, 3e4);
|
|
35224
35251
|
const relInside = entry.path.startsWith(sharedDirRel + "/") ? entry.path.slice(sharedDirRel.length + 1) : entry.path;
|
|
35225
|
-
const outPath =
|
|
35226
|
-
if (!outPath.startsWith(
|
|
35227
|
-
|
|
35228
|
-
|
|
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);
|
|
35229
35256
|
fetchedCount++;
|
|
35230
35257
|
} catch (e) {
|
|
35231
35258
|
errors.push(`fetch shared ${entry.path}: ${e?.message ?? e}`);
|
|
@@ -35258,13 +35285,13 @@ ${formatManifestValidationIssues2(validation.issues)}`,
|
|
|
35258
35285
|
try {
|
|
35259
35286
|
const body = await fetchBinary(entry.download_url, 3e4);
|
|
35260
35287
|
const relInsideProvider = entry.path.startsWith(subdir + "/") ? entry.path.slice(subdir.length + 1) : entry.path;
|
|
35261
|
-
const outPath =
|
|
35262
|
-
if (!outPath.startsWith(
|
|
35288
|
+
const outPath = path44.resolve(path44.join(targetDir, relInsideProvider));
|
|
35289
|
+
if (!outPath.startsWith(path44.resolve(targetDir) + path44.sep)) {
|
|
35263
35290
|
errors.push(`refusing to write outside targetDir: ${entry.path}`);
|
|
35264
35291
|
continue;
|
|
35265
35292
|
}
|
|
35266
|
-
|
|
35267
|
-
|
|
35293
|
+
fs39.mkdirSync(path44.dirname(outPath), { recursive: true });
|
|
35294
|
+
fs39.writeFileSync(outPath, body);
|
|
35268
35295
|
fetchedCount++;
|
|
35269
35296
|
} catch (e) {
|
|
35270
35297
|
errors.push(`fetch ${entry.path}: ${e?.message ?? e}`);
|
|
@@ -35292,19 +35319,19 @@ ${formatManifestValidationIssues2(validation.issues)}`,
|
|
|
35292
35319
|
if (!["cli", "ide", "extension", "acp"].includes(category)) {
|
|
35293
35320
|
return { success: false, error: `unknown category: ${category}` };
|
|
35294
35321
|
}
|
|
35295
|
-
const
|
|
35296
|
-
const
|
|
35322
|
+
const fs39 = __require("fs");
|
|
35323
|
+
const path44 = __require("path");
|
|
35297
35324
|
try {
|
|
35298
35325
|
const installRoot = this.getUpstreamInstallRoot();
|
|
35299
|
-
const installRootResolved =
|
|
35300
|
-
const targetDir =
|
|
35301
|
-
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)) {
|
|
35302
35329
|
return { success: false, error: "refusing to delete outside upstream root" };
|
|
35303
35330
|
}
|
|
35304
|
-
if (!
|
|
35331
|
+
if (!fs39.existsSync(targetDir)) {
|
|
35305
35332
|
return { success: false, error: "not installed" };
|
|
35306
35333
|
}
|
|
35307
|
-
|
|
35334
|
+
fs39.rmSync(targetDir, { recursive: true, force: true });
|
|
35308
35335
|
if (this._ctx.providerLoader) {
|
|
35309
35336
|
this._ctx.providerLoader.reload();
|
|
35310
35337
|
this._ctx.providerLoader.registerToDetector();
|
|
@@ -35320,28 +35347,28 @@ ${formatManifestValidationIssues2(validation.issues)}`,
|
|
|
35320
35347
|
* the UI and by the update checker.
|
|
35321
35348
|
*/
|
|
35322
35349
|
handleListInstalledProviders(_args) {
|
|
35323
|
-
const
|
|
35324
|
-
const
|
|
35350
|
+
const fs39 = __require("fs");
|
|
35351
|
+
const path44 = __require("path");
|
|
35325
35352
|
const installRoot = this.getUpstreamInstallRoot();
|
|
35326
|
-
if (!
|
|
35353
|
+
if (!fs39.existsSync(installRoot)) return { success: true, providers: [] };
|
|
35327
35354
|
const CATEGORIES = ["cli", "ide", "extension", "acp"];
|
|
35328
35355
|
const items = [];
|
|
35329
35356
|
for (const category of CATEGORIES) {
|
|
35330
|
-
const categoryDir =
|
|
35331
|
-
if (!
|
|
35357
|
+
const categoryDir = path44.join(installRoot, category);
|
|
35358
|
+
if (!fs39.existsSync(categoryDir)) continue;
|
|
35332
35359
|
let entries;
|
|
35333
35360
|
try {
|
|
35334
|
-
entries =
|
|
35361
|
+
entries = fs39.readdirSync(categoryDir);
|
|
35335
35362
|
} catch {
|
|
35336
35363
|
continue;
|
|
35337
35364
|
}
|
|
35338
35365
|
for (const type of entries) {
|
|
35339
|
-
const v1Path =
|
|
35340
|
-
const v0Path =
|
|
35341
|
-
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;
|
|
35342
35369
|
if (!manifestPath) continue;
|
|
35343
35370
|
try {
|
|
35344
|
-
const m = JSON.parse(
|
|
35371
|
+
const m = JSON.parse(fs39.readFileSync(manifestPath, "utf-8"));
|
|
35345
35372
|
items.push({
|
|
35346
35373
|
type,
|
|
35347
35374
|
category,
|
|
@@ -35368,7 +35395,7 @@ ${formatManifestValidationIssues2(validation.issues)}`,
|
|
|
35368
35395
|
const https = __require("https");
|
|
35369
35396
|
const REGISTRY = "https://api.adhf.dev/api/v1/registry";
|
|
35370
35397
|
function fetchJson(url) {
|
|
35371
|
-
return new Promise((
|
|
35398
|
+
return new Promise((resolve25, reject) => {
|
|
35372
35399
|
const req = https.get(url, { headers: { "User-Agent": "adhdev-daemon", "Accept": "application/json" }, timeout: 1e4 }, (res) => {
|
|
35373
35400
|
if (res.statusCode !== 200) {
|
|
35374
35401
|
reject(new Error(`HTTP ${res.statusCode}`));
|
|
@@ -35378,7 +35405,7 @@ ${formatManifestValidationIssues2(validation.issues)}`,
|
|
|
35378
35405
|
res.on("data", (c) => chunks.push(c));
|
|
35379
35406
|
res.on("end", () => {
|
|
35380
35407
|
try {
|
|
35381
|
-
|
|
35408
|
+
resolve25(JSON.parse(Buffer.concat(chunks).toString("utf-8")));
|
|
35382
35409
|
} catch (e) {
|
|
35383
35410
|
reject(e);
|
|
35384
35411
|
}
|
|
@@ -35452,8 +35479,8 @@ ${formatManifestValidationIssues2(validation.issues)}`,
|
|
|
35452
35479
|
if (!/^@[a-z0-9_-]+$/i.test(requestedName)) {
|
|
35453
35480
|
return { success: false, error: "name must match @[a-z0-9_-]+" };
|
|
35454
35481
|
}
|
|
35455
|
-
const
|
|
35456
|
-
const
|
|
35482
|
+
const fs39 = __require("fs");
|
|
35483
|
+
const path44 = __require("path");
|
|
35457
35484
|
const { spawnSync: spawnSync2 } = __require("child_process");
|
|
35458
35485
|
const file = ext.loadExternalSources();
|
|
35459
35486
|
if (file.sources.some((s2) => s2.name === requestedName)) {
|
|
@@ -35462,9 +35489,9 @@ ${formatManifestValidationIssues2(validation.issues)}`,
|
|
|
35462
35489
|
if (file.sources.some((s2) => s2.url === url && s2.ref === ref)) {
|
|
35463
35490
|
return { success: false, error: `source url+ref already registered (use a different name to track another ref)` };
|
|
35464
35491
|
}
|
|
35465
|
-
const sourceDir =
|
|
35466
|
-
if (!
|
|
35467
|
-
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)) {
|
|
35468
35495
|
return { success: false, error: `directory already exists: ${sourceDir} (rename or remove first)` };
|
|
35469
35496
|
}
|
|
35470
35497
|
const clone = spawnSync2("git", ["clone", "--depth=1", "--branch", ref, "--", url, sourceDir], {
|
|
@@ -35474,7 +35501,7 @@ ${formatManifestValidationIssues2(validation.issues)}`,
|
|
|
35474
35501
|
});
|
|
35475
35502
|
if (clone.status !== 0) {
|
|
35476
35503
|
try {
|
|
35477
|
-
|
|
35504
|
+
fs39.rmSync(sourceDir, { recursive: true, force: true });
|
|
35478
35505
|
} catch {
|
|
35479
35506
|
}
|
|
35480
35507
|
return { success: false, error: `git clone failed: ${(clone.stderr || clone.stdout || "").trim() || "unknown error"}` };
|
|
@@ -35518,15 +35545,15 @@ ${formatManifestValidationIssues2(validation.issues)}`,
|
|
|
35518
35545
|
const name = typeof args?.name === "string" ? args.name.trim() : "";
|
|
35519
35546
|
if (!name) return { success: false, error: "name is required" };
|
|
35520
35547
|
const ext = (init_external_sources(), __toCommonJS(external_sources_exports));
|
|
35521
|
-
const
|
|
35522
|
-
const
|
|
35548
|
+
const fs39 = __require("fs");
|
|
35549
|
+
const path44 = __require("path");
|
|
35523
35550
|
const file = ext.loadExternalSources();
|
|
35524
35551
|
const match = file.sources.find((s2) => s2.name === name);
|
|
35525
35552
|
if (!match) return { success: false, error: `source "${name}" not registered` };
|
|
35526
|
-
const sourceDir =
|
|
35527
|
-
if (
|
|
35553
|
+
const sourceDir = path44.join(ext.externalRoot(), name);
|
|
35554
|
+
if (fs39.existsSync(sourceDir)) {
|
|
35528
35555
|
try {
|
|
35529
|
-
|
|
35556
|
+
fs39.rmSync(sourceDir, { recursive: true, force: true });
|
|
35530
35557
|
} catch (e) {
|
|
35531
35558
|
return { success: false, error: `failed to delete ${sourceDir}: ${e?.message || e}` };
|
|
35532
35559
|
}
|
|
@@ -35616,7 +35643,7 @@ ${formatManifestValidationIssues2(validation.issues)}`,
|
|
|
35616
35643
|
try {
|
|
35617
35644
|
const http3 = await import("http");
|
|
35618
35645
|
const postData = JSON.stringify(body);
|
|
35619
|
-
const result = await new Promise((
|
|
35646
|
+
const result = await new Promise((resolve25, reject) => {
|
|
35620
35647
|
const req = http3.request({
|
|
35621
35648
|
hostname: "127.0.0.1",
|
|
35622
35649
|
port: 19280,
|
|
@@ -35628,9 +35655,9 @@ ${formatManifestValidationIssues2(validation.issues)}`,
|
|
|
35628
35655
|
res.on("data", (chunk) => data += chunk);
|
|
35629
35656
|
res.on("end", () => {
|
|
35630
35657
|
try {
|
|
35631
|
-
|
|
35658
|
+
resolve25(JSON.parse(data));
|
|
35632
35659
|
} catch {
|
|
35633
|
-
|
|
35660
|
+
resolve25({ raw: data });
|
|
35634
35661
|
}
|
|
35635
35662
|
});
|
|
35636
35663
|
});
|
|
@@ -35648,15 +35675,15 @@ ${formatManifestValidationIssues2(validation.issues)}`,
|
|
|
35648
35675
|
if (!providerType) return { success: false, error: "providerType required" };
|
|
35649
35676
|
try {
|
|
35650
35677
|
const http3 = await import("http");
|
|
35651
|
-
const result = await new Promise((
|
|
35678
|
+
const result = await new Promise((resolve25, reject) => {
|
|
35652
35679
|
http3.get(`http://127.0.0.1:19280/api/providers/${providerType}/${endpoint}`, (res) => {
|
|
35653
35680
|
let data = "";
|
|
35654
35681
|
res.on("data", (chunk) => data += chunk);
|
|
35655
35682
|
res.on("end", () => {
|
|
35656
35683
|
try {
|
|
35657
|
-
|
|
35684
|
+
resolve25(JSON.parse(data));
|
|
35658
35685
|
} catch {
|
|
35659
|
-
|
|
35686
|
+
resolve25({ raw: data });
|
|
35660
35687
|
}
|
|
35661
35688
|
});
|
|
35662
35689
|
}).on("error", reject);
|
|
@@ -35670,7 +35697,7 @@ ${formatManifestValidationIssues2(validation.issues)}`,
|
|
|
35670
35697
|
try {
|
|
35671
35698
|
const http3 = await import("http");
|
|
35672
35699
|
const postData = JSON.stringify(args || {});
|
|
35673
|
-
const result = await new Promise((
|
|
35700
|
+
const result = await new Promise((resolve25, reject) => {
|
|
35674
35701
|
const req = http3.request({
|
|
35675
35702
|
hostname: "127.0.0.1",
|
|
35676
35703
|
port: 19280,
|
|
@@ -35682,9 +35709,9 @@ ${formatManifestValidationIssues2(validation.issues)}`,
|
|
|
35682
35709
|
res.on("data", (chunk) => data += chunk);
|
|
35683
35710
|
res.on("end", () => {
|
|
35684
35711
|
try {
|
|
35685
|
-
|
|
35712
|
+
resolve25(JSON.parse(data));
|
|
35686
35713
|
} catch {
|
|
35687
|
-
|
|
35714
|
+
resolve25({ raw: data });
|
|
35688
35715
|
}
|
|
35689
35716
|
});
|
|
35690
35717
|
});
|
|
@@ -36309,24 +36336,24 @@ var statusMetaHandlers = {
|
|
|
36309
36336
|
// src/commands/low-family/coordinator-prompt.ts
|
|
36310
36337
|
var coordinatorPromptHandlers = {
|
|
36311
36338
|
list_coordinator_prompts: async (_ctx, _args) => {
|
|
36312
|
-
const
|
|
36313
|
-
const
|
|
36314
|
-
const
|
|
36315
|
-
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");
|
|
36316
36343
|
const entries = {};
|
|
36317
36344
|
try {
|
|
36318
|
-
if (
|
|
36319
|
-
for (const name of
|
|
36345
|
+
if (fs39.existsSync(dir)) {
|
|
36346
|
+
for (const name of fs39.readdirSync(dir)) {
|
|
36320
36347
|
const matchOverride = name.match(/^([a-zA-Z0-9_.-]+)\.md$/);
|
|
36321
36348
|
const matchAppend = name.match(/^([a-zA-Z0-9_.-]+)\.append\.md$/);
|
|
36322
36349
|
const m = matchAppend || matchOverride;
|
|
36323
36350
|
if (!m) continue;
|
|
36324
36351
|
const isAppend = !!matchAppend;
|
|
36325
36352
|
const key2 = m[1];
|
|
36326
|
-
const full =
|
|
36353
|
+
const full = path44.join(dir, name);
|
|
36327
36354
|
let content = "";
|
|
36328
36355
|
try {
|
|
36329
|
-
content =
|
|
36356
|
+
content = fs39.readFileSync(full, "utf8");
|
|
36330
36357
|
} catch {
|
|
36331
36358
|
}
|
|
36332
36359
|
if (!entries[key2]) entries[key2] = { override: "", append: "" };
|
|
@@ -36340,24 +36367,24 @@ var coordinatorPromptHandlers = {
|
|
|
36340
36367
|
return { success: true, dir, entries };
|
|
36341
36368
|
},
|
|
36342
36369
|
write_coordinator_prompt: async (_ctx, args) => {
|
|
36343
|
-
const
|
|
36344
|
-
const
|
|
36345
|
-
const
|
|
36370
|
+
const fs39 = await import("fs");
|
|
36371
|
+
const path44 = await import("path");
|
|
36372
|
+
const os31 = await import("os");
|
|
36346
36373
|
const key2 = typeof args?.key === "string" ? args.key.trim() : "";
|
|
36347
36374
|
const kind = args?.kind === "append" ? "append" : "override";
|
|
36348
36375
|
const content = typeof args?.content === "string" ? args.content : "";
|
|
36349
36376
|
if (!key2 || !/^[a-zA-Z0-9_.-]+$/.test(key2)) {
|
|
36350
36377
|
return { success: false, error: "key must match [a-zA-Z0-9_.-]+" };
|
|
36351
36378
|
}
|
|
36352
|
-
const dir =
|
|
36379
|
+
const dir = path44.join(os31.homedir(), ".adhdev", "coordinator-prompts");
|
|
36353
36380
|
const filename = kind === "append" ? `${key2}.append.md` : `${key2}.md`;
|
|
36354
|
-
const full =
|
|
36381
|
+
const full = path44.join(dir, filename);
|
|
36355
36382
|
try {
|
|
36356
|
-
|
|
36383
|
+
fs39.mkdirSync(dir, { recursive: true });
|
|
36357
36384
|
if (content.trim()) {
|
|
36358
|
-
|
|
36359
|
-
} else if (
|
|
36360
|
-
|
|
36385
|
+
fs39.writeFileSync(full, content, { encoding: "utf8", mode: 384 });
|
|
36386
|
+
} else if (fs39.existsSync(full)) {
|
|
36387
|
+
fs39.unlinkSync(full);
|
|
36361
36388
|
}
|
|
36362
36389
|
return { success: true, path: full, kind, key: key2 };
|
|
36363
36390
|
} catch (error) {
|
|
@@ -36674,7 +36701,7 @@ async function waitForPidExit(pid, timeoutMs) {
|
|
|
36674
36701
|
while (Date.now() - start < timeoutMs) {
|
|
36675
36702
|
try {
|
|
36676
36703
|
process.kill(pid, 0);
|
|
36677
|
-
await new Promise((
|
|
36704
|
+
await new Promise((resolve25) => setTimeout(resolve25, 250));
|
|
36678
36705
|
} catch {
|
|
36679
36706
|
return;
|
|
36680
36707
|
}
|
|
@@ -36900,7 +36927,7 @@ async function runDaemonUpgradeHelper(payload) {
|
|
|
36900
36927
|
appendUpgradeLog(`Install attempt ${attempt} hit a file lock (${error?.code || "lock"}); clearing holders + staging and retrying after backoff`);
|
|
36901
36928
|
await stopForeignNativeAddonHolders(installCommand.surface.packageRoot, { parentPid: payload.parentPid });
|
|
36902
36929
|
cleanupStaleGlobalInstallDirs(payload.packageName, installCommand.surface);
|
|
36903
|
-
await new Promise((
|
|
36930
|
+
await new Promise((resolve25) => setTimeout(resolve25, attempt * 1500));
|
|
36904
36931
|
continue;
|
|
36905
36932
|
}
|
|
36906
36933
|
if (isRetriableInstallLockError(error)) {
|
|
@@ -36928,7 +36955,7 @@ async function runDaemonUpgradeHelper(payload) {
|
|
|
36928
36955
|
appendUpgradeLog(installOutput.trim());
|
|
36929
36956
|
}
|
|
36930
36957
|
if (process.platform === "win32") {
|
|
36931
|
-
await new Promise((
|
|
36958
|
+
await new Promise((resolve25) => setTimeout(resolve25, 500));
|
|
36932
36959
|
cleanupStaleGlobalInstallDirs(payload.packageName, installCommand.surface);
|
|
36933
36960
|
appendUpgradeLog("Post-install staging cleanup complete");
|
|
36934
36961
|
}
|
|
@@ -39576,7 +39603,7 @@ function stripAnsi3(text) {
|
|
|
39576
39603
|
return String(text || "").replace(/\x1B\][^\x07]*(?:\x07|\x1B\\)/g, "").replace(/\x1B[P^_X][\s\S]*?(?:\x07|\x1B\\)/g, "").replace(/\x1B(?:[@-Z\\-_]|\[[0-?]*[ -/]*[@-~])/g, "");
|
|
39577
39604
|
}
|
|
39578
39605
|
function delay(ms) {
|
|
39579
|
-
return new Promise((
|
|
39606
|
+
return new Promise((resolve25) => setTimeout(resolve25, ms));
|
|
39580
39607
|
}
|
|
39581
39608
|
var SpecCliAdapter = class _SpecCliAdapter {
|
|
39582
39609
|
cliType;
|
|
@@ -39775,7 +39802,7 @@ var SpecCliAdapter = class _SpecCliAdapter {
|
|
|
39775
39802
|
const steps = buildClaudeInteractiveTuiAnswerSteps(prompt, response);
|
|
39776
39803
|
for (const step of steps) {
|
|
39777
39804
|
this.driver.dispatch({ kind: "pty_write", data: step });
|
|
39778
|
-
await new Promise((
|
|
39805
|
+
await new Promise((resolve25) => setTimeout(resolve25, 180));
|
|
39779
39806
|
}
|
|
39780
39807
|
} else {
|
|
39781
39808
|
this.driver.dispatch({ kind: "pty_write", data: `${buildClaudeInteractiveToolResult(response)}
|
|
@@ -40326,7 +40353,7 @@ var SpecCliAdapter = class _SpecCliAdapter {
|
|
|
40326
40353
|
let screenText = this.driver.snapshot();
|
|
40327
40354
|
const deadline = Date.now() + _SpecCliAdapter.CLAUDE_TUI_PAGE_SETTLE_TIMEOUT_MS;
|
|
40328
40355
|
while (!detectClaudeTuiMultiSelect(screenText) && Date.now() < deadline) {
|
|
40329
|
-
await new Promise((
|
|
40356
|
+
await new Promise((resolve25) => setTimeout(resolve25, _SpecCliAdapter.CLAUDE_TUI_PAGE_POLL_INTERVAL_MS));
|
|
40330
40357
|
screenText = this.driver.snapshot();
|
|
40331
40358
|
}
|
|
40332
40359
|
return screenText;
|
|
@@ -40335,12 +40362,12 @@ var SpecCliAdapter = class _SpecCliAdapter {
|
|
|
40335
40362
|
const pages = [{ screenText: firstScreen, header: headers[0] }];
|
|
40336
40363
|
for (let index = 1; index < headers.length; index += 1) {
|
|
40337
40364
|
this.driver.dispatch({ kind: "pty_write", data: " " });
|
|
40338
|
-
await new Promise((
|
|
40365
|
+
await new Promise((resolve25) => setTimeout(resolve25, _SpecCliAdapter.CLAUDE_TUI_PAGE_POLL_INTERVAL_MS));
|
|
40339
40366
|
pages.push({ screenText: await this.snapshotSettledClaudeTuiPage(), header: headers[index] });
|
|
40340
40367
|
}
|
|
40341
40368
|
for (let index = headers.length - 1; index > 0; index -= 1) {
|
|
40342
40369
|
this.driver.dispatch({ kind: "pty_write", data: "\x1B[Z" });
|
|
40343
|
-
await new Promise((
|
|
40370
|
+
await new Promise((resolve25) => setTimeout(resolve25, _SpecCliAdapter.CLAUDE_TUI_PAGE_POLL_INTERVAL_MS));
|
|
40344
40371
|
const reread = await this.snapshotSettledClaudeTuiPage();
|
|
40345
40372
|
const landed = pages[index - 1];
|
|
40346
40373
|
if (landed && !detectClaudeTuiMultiSelect(landed.screenText) && detectClaudeTuiMultiSelect(reread)) {
|
|
@@ -40695,7 +40722,7 @@ async function waitForCliAdapterReady(adapter, options) {
|
|
|
40695
40722
|
if (status === "stopped") {
|
|
40696
40723
|
throw new Error("CLI runtime stopped before it became ready");
|
|
40697
40724
|
}
|
|
40698
|
-
await new Promise((
|
|
40725
|
+
await new Promise((resolve25) => setTimeout(resolve25, pollMs));
|
|
40699
40726
|
}
|
|
40700
40727
|
throw new Error(`CLI runtime did not become ready within ${timeoutMs}ms`);
|
|
40701
40728
|
}
|
|
@@ -41444,7 +41471,7 @@ var CliProviderInstance = class _CliProviderInstance {
|
|
|
41444
41471
|
const enterCount = cliCommand.enterCount || 1;
|
|
41445
41472
|
await this.adapter.writeRaw(cliCommand.text + "\r");
|
|
41446
41473
|
for (let i = 1; i < enterCount; i += 1) {
|
|
41447
|
-
await new Promise((
|
|
41474
|
+
await new Promise((resolve25) => setTimeout(resolve25, 50));
|
|
41448
41475
|
await this.adapter.writeRaw("\r");
|
|
41449
41476
|
}
|
|
41450
41477
|
}
|
|
@@ -43523,13 +43550,13 @@ var AcpProviderInstance = class {
|
|
|
43523
43550
|
}
|
|
43524
43551
|
this.currentStatus = "waiting_approval";
|
|
43525
43552
|
this.detectStatusTransition();
|
|
43526
|
-
const approved = await new Promise((
|
|
43527
|
-
this.permissionResolvers.push(
|
|
43553
|
+
const approved = await new Promise((resolve25) => {
|
|
43554
|
+
this.permissionResolvers.push(resolve25);
|
|
43528
43555
|
setTimeout(() => {
|
|
43529
|
-
const idx = this.permissionResolvers.indexOf(
|
|
43556
|
+
const idx = this.permissionResolvers.indexOf(resolve25);
|
|
43530
43557
|
if (idx >= 0) {
|
|
43531
43558
|
this.permissionResolvers.splice(idx, 1);
|
|
43532
|
-
|
|
43559
|
+
resolve25(false);
|
|
43533
43560
|
}
|
|
43534
43561
|
}, 3e5);
|
|
43535
43562
|
});
|
|
@@ -44265,7 +44292,7 @@ async function waitForZeroMessageStartingLaunch(adapter) {
|
|
|
44265
44292
|
} catch {
|
|
44266
44293
|
return false;
|
|
44267
44294
|
}
|
|
44268
|
-
await new Promise((
|
|
44295
|
+
await new Promise((resolve25) => setTimeout(resolve25, ZERO_MESSAGE_STARTING_SEND_WAIT_MS));
|
|
44269
44296
|
try {
|
|
44270
44297
|
return hasZeroMessageStartingLaunch(adapter);
|
|
44271
44298
|
} catch {
|
|
@@ -45606,9 +45633,9 @@ function validateProviderDefinition(raw) {
|
|
|
45606
45633
|
const typedProvider = provider;
|
|
45607
45634
|
const controls = Array.isArray(provider.controls) ? provider.controls : [];
|
|
45608
45635
|
if (category === "cli" || category === "acp") {
|
|
45609
|
-
const
|
|
45610
|
-
const command =
|
|
45611
|
-
if (!
|
|
45636
|
+
const spawn5 = provider.spawn;
|
|
45637
|
+
const command = spawn5 && typeof spawn5 === "object" ? spawn5.command : void 0;
|
|
45638
|
+
if (!spawn5 || typeof spawn5 !== "object") {
|
|
45612
45639
|
errors.push(`${String(category).toUpperCase()}/CLI providers must have spawn config`);
|
|
45613
45640
|
} else if (typeof command !== "string" || !command.trim()) {
|
|
45614
45641
|
errors.push("spawn.command is required");
|
|
@@ -48129,25 +48156,25 @@ var ProviderLoader = class _ProviderLoader {
|
|
|
48129
48156
|
}
|
|
48130
48157
|
if (providerDir) {
|
|
48131
48158
|
try {
|
|
48132
|
-
const
|
|
48133
|
-
const
|
|
48159
|
+
const fs39 = __require("fs");
|
|
48160
|
+
const path44 = __require("path");
|
|
48134
48161
|
const candidates = [];
|
|
48135
48162
|
if (Array.isArray(base.compatibility)) {
|
|
48136
48163
|
for (const entry of base.compatibility) {
|
|
48137
48164
|
if (typeof entry?.spec !== "string") continue;
|
|
48138
48165
|
const matches = !entry.ideVersion || currentVersion && this.matchesVersion(currentVersion, entry.ideVersion) || !currentVersion;
|
|
48139
|
-
if (matches) candidates.push(
|
|
48166
|
+
if (matches) candidates.push(path44.join(providerDir, entry.spec));
|
|
48140
48167
|
}
|
|
48141
48168
|
}
|
|
48142
|
-
candidates.push(
|
|
48143
|
-
candidates.push(
|
|
48144
|
-
const specPath = candidates.find((p) =>
|
|
48169
|
+
candidates.push(path44.join(providerDir, "specs", "default.json"));
|
|
48170
|
+
candidates.push(path44.join(providerDir, "spec.json"));
|
|
48171
|
+
const specPath = candidates.find((p) => fs39.existsSync(p));
|
|
48145
48172
|
if (specPath) {
|
|
48146
48173
|
resolved._resolvedSpecPath = specPath;
|
|
48147
48174
|
let specControls;
|
|
48148
48175
|
let nh;
|
|
48149
48176
|
try {
|
|
48150
|
-
const rawSpec = JSON.parse(
|
|
48177
|
+
const rawSpec = JSON.parse(fs39.readFileSync(specPath, "utf8"));
|
|
48151
48178
|
specControls = rawSpec.control_bar;
|
|
48152
48179
|
nh = rawSpec.native_history;
|
|
48153
48180
|
} catch {
|
|
@@ -48178,10 +48205,10 @@ var ProviderLoader = class _ProviderLoader {
|
|
|
48178
48205
|
format = `spec-${nh.source.kind}`;
|
|
48179
48206
|
reader = (input) => executeNativeHistory(nh, input);
|
|
48180
48207
|
} else if (nh.override_path) {
|
|
48181
|
-
const overrideFile =
|
|
48182
|
-
if (
|
|
48208
|
+
const overrideFile = path44.resolve(providerDir, nh.override_path);
|
|
48209
|
+
if (fs39.existsSync(overrideFile)) {
|
|
48183
48210
|
try {
|
|
48184
|
-
registerProviderScriptRootSafely(
|
|
48211
|
+
registerProviderScriptRootSafely(path44.dirname(path44.dirname(providerDir)));
|
|
48185
48212
|
delete __require.cache[__require.resolve(overrideFile)];
|
|
48186
48213
|
const mod = __require(overrideFile);
|
|
48187
48214
|
const fn = typeof mod === "function" ? mod : mod && typeof mod.default === "function" ? mod.default : null;
|
|
@@ -48355,7 +48382,7 @@ var ProviderLoader = class _ProviderLoader {
|
|
|
48355
48382
|
}
|
|
48356
48383
|
try {
|
|
48357
48384
|
const listUrl = `${_ProviderLoader.REGISTRY_BASE_URL}/providers`;
|
|
48358
|
-
const listBody = await new Promise((
|
|
48385
|
+
const listBody = await new Promise((resolve25, reject) => {
|
|
48359
48386
|
const req = https.get(listUrl, { headers: { "User-Agent": "adhdev-daemon", "Accept": "application/json" }, timeout: 1e4 }, (res) => {
|
|
48360
48387
|
if (res.statusCode !== 200) {
|
|
48361
48388
|
reject(new Error(`registry list HTTP ${res.statusCode}`));
|
|
@@ -48363,7 +48390,7 @@ var ProviderLoader = class _ProviderLoader {
|
|
|
48363
48390
|
}
|
|
48364
48391
|
const chunks = [];
|
|
48365
48392
|
res.on("data", (c) => chunks.push(c));
|
|
48366
|
-
res.on("end", () =>
|
|
48393
|
+
res.on("end", () => resolve25(Buffer.concat(chunks).toString("utf-8")));
|
|
48367
48394
|
});
|
|
48368
48395
|
req.on("error", reject);
|
|
48369
48396
|
req.on("timeout", () => {
|
|
@@ -48379,7 +48406,7 @@ var ProviderLoader = class _ProviderLoader {
|
|
|
48379
48406
|
const cacheKey = `${category}/${type}`;
|
|
48380
48407
|
if (cachedChecksums[cacheKey] === checksum) continue;
|
|
48381
48408
|
const dlUrl = `${_ProviderLoader.REGISTRY_BASE_URL}/providers/${type}/${version}/download`;
|
|
48382
|
-
const manifestBody = await new Promise((
|
|
48409
|
+
const manifestBody = await new Promise((resolve25, reject) => {
|
|
48383
48410
|
const req = https.get(dlUrl, { headers: { "User-Agent": "adhdev-daemon", "Accept": "application/json" }, timeout: 3e4 }, (res) => {
|
|
48384
48411
|
if (res.statusCode !== 200) {
|
|
48385
48412
|
reject(new Error(`registry download HTTP ${res.statusCode} for ${type}@${version}`));
|
|
@@ -48387,7 +48414,7 @@ var ProviderLoader = class _ProviderLoader {
|
|
|
48387
48414
|
}
|
|
48388
48415
|
const chunks = [];
|
|
48389
48416
|
res.on("data", (c) => chunks.push(c));
|
|
48390
|
-
res.on("end", () =>
|
|
48417
|
+
res.on("end", () => resolve25(Buffer.concat(chunks).toString("utf-8")));
|
|
48391
48418
|
});
|
|
48392
48419
|
req.on("error", reject);
|
|
48393
48420
|
req.on("timeout", () => {
|
|
@@ -48446,7 +48473,7 @@ var ProviderLoader = class _ProviderLoader {
|
|
|
48446
48473
|
return { updated: false };
|
|
48447
48474
|
}
|
|
48448
48475
|
try {
|
|
48449
|
-
const etag = await new Promise((
|
|
48476
|
+
const etag = await new Promise((resolve25, reject) => {
|
|
48450
48477
|
const options = {
|
|
48451
48478
|
method: "HEAD",
|
|
48452
48479
|
hostname: "github.com",
|
|
@@ -48464,7 +48491,7 @@ var ProviderLoader = class _ProviderLoader {
|
|
|
48464
48491
|
headers: { "User-Agent": "adhdev-launcher" },
|
|
48465
48492
|
timeout: 1e4
|
|
48466
48493
|
}, (res2) => {
|
|
48467
|
-
|
|
48494
|
+
resolve25(res2.headers.etag || res2.headers["last-modified"] || "");
|
|
48468
48495
|
});
|
|
48469
48496
|
req2.on("error", reject);
|
|
48470
48497
|
req2.on("timeout", () => {
|
|
@@ -48473,7 +48500,7 @@ var ProviderLoader = class _ProviderLoader {
|
|
|
48473
48500
|
});
|
|
48474
48501
|
req2.end();
|
|
48475
48502
|
} else {
|
|
48476
|
-
|
|
48503
|
+
resolve25(res.headers.etag || res.headers["last-modified"] || "");
|
|
48477
48504
|
}
|
|
48478
48505
|
});
|
|
48479
48506
|
req.on("error", reject);
|
|
@@ -48537,7 +48564,7 @@ var ProviderLoader = class _ProviderLoader {
|
|
|
48537
48564
|
downloadFile(url, destPath) {
|
|
48538
48565
|
const https = __require("https");
|
|
48539
48566
|
const http3 = __require("http");
|
|
48540
|
-
return new Promise((
|
|
48567
|
+
return new Promise((resolve25, reject) => {
|
|
48541
48568
|
const doRequest = (reqUrl, redirectCount = 0) => {
|
|
48542
48569
|
if (redirectCount > 5) {
|
|
48543
48570
|
reject(new Error("Too many redirects"));
|
|
@@ -48557,7 +48584,7 @@ var ProviderLoader = class _ProviderLoader {
|
|
|
48557
48584
|
res.pipe(ws);
|
|
48558
48585
|
ws.on("finish", () => {
|
|
48559
48586
|
ws.close();
|
|
48560
|
-
|
|
48587
|
+
resolve25();
|
|
48561
48588
|
});
|
|
48562
48589
|
ws.on("error", reject);
|
|
48563
48590
|
});
|
|
@@ -49113,10 +49140,10 @@ function findMacAppProcessPids(psOutput, appPaths) {
|
|
|
49113
49140
|
|
|
49114
49141
|
// src/launch.ts
|
|
49115
49142
|
async function execQuiet(command, options = {}) {
|
|
49116
|
-
return new Promise((
|
|
49143
|
+
return new Promise((resolve25) => {
|
|
49117
49144
|
exec4(command, options, (error, stdout) => {
|
|
49118
|
-
if (error) return
|
|
49119
|
-
|
|
49145
|
+
if (error) return resolve25("");
|
|
49146
|
+
resolve25(stdout.toString());
|
|
49120
49147
|
});
|
|
49121
49148
|
});
|
|
49122
49149
|
}
|
|
@@ -49197,17 +49224,17 @@ async function findFreePort(ports) {
|
|
|
49197
49224
|
throw new Error("No free port found");
|
|
49198
49225
|
}
|
|
49199
49226
|
function checkPortFree(port) {
|
|
49200
|
-
return new Promise((
|
|
49227
|
+
return new Promise((resolve25) => {
|
|
49201
49228
|
const server = net.createServer();
|
|
49202
49229
|
server.unref();
|
|
49203
|
-
server.on("error", () =>
|
|
49230
|
+
server.on("error", () => resolve25(false));
|
|
49204
49231
|
server.listen(port, "127.0.0.1", () => {
|
|
49205
|
-
server.close(() =>
|
|
49232
|
+
server.close(() => resolve25(true));
|
|
49206
49233
|
});
|
|
49207
49234
|
});
|
|
49208
49235
|
}
|
|
49209
49236
|
async function isCdpActive(port) {
|
|
49210
|
-
return new Promise((
|
|
49237
|
+
return new Promise((resolve25) => {
|
|
49211
49238
|
const req = __require("http").get(`http://127.0.0.1:${port}/json/version`, {
|
|
49212
49239
|
timeout: 2e3
|
|
49213
49240
|
}, (res) => {
|
|
@@ -49216,16 +49243,16 @@ async function isCdpActive(port) {
|
|
|
49216
49243
|
res.on("end", () => {
|
|
49217
49244
|
try {
|
|
49218
49245
|
const info = JSON.parse(data);
|
|
49219
|
-
|
|
49246
|
+
resolve25(!!info["WebKit-Version"] || !!info["Browser"]);
|
|
49220
49247
|
} catch {
|
|
49221
|
-
|
|
49248
|
+
resolve25(false);
|
|
49222
49249
|
}
|
|
49223
49250
|
});
|
|
49224
49251
|
});
|
|
49225
|
-
req.on("error", () =>
|
|
49252
|
+
req.on("error", () => resolve25(false));
|
|
49226
49253
|
req.on("timeout", () => {
|
|
49227
49254
|
req.destroy();
|
|
49228
|
-
|
|
49255
|
+
resolve25(false);
|
|
49229
49256
|
});
|
|
49230
49257
|
});
|
|
49231
49258
|
}
|
|
@@ -49361,7 +49388,7 @@ async function detectCurrentWorkspace(ideId) {
|
|
|
49361
49388
|
}
|
|
49362
49389
|
} else if (plat === "win32") {
|
|
49363
49390
|
try {
|
|
49364
|
-
const
|
|
49391
|
+
const fs39 = __require("fs");
|
|
49365
49392
|
const appNameMap = getMacAppIdentifiers();
|
|
49366
49393
|
const appName = appNameMap[ideId];
|
|
49367
49394
|
if (appName) {
|
|
@@ -49370,8 +49397,8 @@ async function detectCurrentWorkspace(ideId) {
|
|
|
49370
49397
|
appName,
|
|
49371
49398
|
"storage.json"
|
|
49372
49399
|
);
|
|
49373
|
-
if (
|
|
49374
|
-
const data = JSON.parse(
|
|
49400
|
+
if (fs39.existsSync(storagePath)) {
|
|
49401
|
+
const data = JSON.parse(fs39.readFileSync(storagePath, "utf-8"));
|
|
49375
49402
|
const workspaces = data?.openedPathsList?.workspaces3 || data?.openedPathsList?.entries || [];
|
|
49376
49403
|
if (workspaces.length > 0) {
|
|
49377
49404
|
const recent = workspaces[0];
|
|
@@ -49849,12 +49876,12 @@ var meshCrudHandlers = {
|
|
|
49849
49876
|
normalizeRepoMeshDeclarativeConfig: normalizeRepoMeshDeclarativeConfig2,
|
|
49850
49877
|
MESH_JSON_CONFIG_LOCATIONS: MESH_JSON_CONFIG_LOCATIONS2
|
|
49851
49878
|
} = await Promise.resolve().then(() => (init_mesh_json_config(), mesh_json_config_exports));
|
|
49852
|
-
const { mkdirSync:
|
|
49853
|
-
const { dirname: dirname17, join:
|
|
49879
|
+
const { mkdirSync: mkdirSync22, writeFileSync: writeFileSync24 } = await import("fs");
|
|
49880
|
+
const { dirname: dirname17, join: join50 } = await import("path");
|
|
49854
49881
|
const scaffold = buildMeshJsonConfigScaffold2(mesh);
|
|
49855
49882
|
const scaffoldJson = serializeMeshJsonConfigScaffold2(scaffold);
|
|
49856
49883
|
const relativePath = MESH_JSON_CONFIG_LOCATIONS2[0];
|
|
49857
|
-
const absolutePath =
|
|
49884
|
+
const absolutePath = join50(workspace, relativePath);
|
|
49858
49885
|
const validation = normalizeRepoMeshDeclarativeConfig2(scaffold);
|
|
49859
49886
|
if (!validation.valid) {
|
|
49860
49887
|
return { success: false, meshId, error: `invalid mesh.json scaffold: ${validation.errors.join("; ")}` };
|
|
@@ -49890,7 +49917,7 @@ var meshCrudHandlers = {
|
|
|
49890
49917
|
note: "Dry-run: nothing written. Re-run with write=true to persist to the repo (commit target). meshes.json is untouched."
|
|
49891
49918
|
};
|
|
49892
49919
|
}
|
|
49893
|
-
|
|
49920
|
+
mkdirSync22(dirname17(absolutePath), { recursive: true });
|
|
49894
49921
|
writeFileSync24(absolutePath, `${scaffoldJson}
|
|
49895
49922
|
`, "utf-8");
|
|
49896
49923
|
return {
|
|
@@ -50454,7 +50481,7 @@ var meshCrudHandlers = {
|
|
|
50454
50481
|
const setupPromise = finishWorktreeSetup();
|
|
50455
50482
|
const setupResult = await Promise.race([
|
|
50456
50483
|
setupPromise.then((value) => ({ completed: true, value })),
|
|
50457
|
-
new Promise((
|
|
50484
|
+
new Promise((resolve25) => setTimeout(() => resolve25({ completed: false }), setupWaitMs))
|
|
50458
50485
|
]);
|
|
50459
50486
|
const emitBootstrapEvent = (eventStatus2, bootstrapState2, startedAtMs, extraPayload) => {
|
|
50460
50487
|
try {
|
|
@@ -51691,7 +51718,7 @@ ${ptyResult.output.slice(-2e3)}`);
|
|
|
51691
51718
|
workspace
|
|
51692
51719
|
};
|
|
51693
51720
|
}
|
|
51694
|
-
const { existsSync:
|
|
51721
|
+
const { existsSync: existsSync54, readFileSync: readFileSync42, writeFileSync: writeFileSync24, copyFileSync: copyFileSync4, mkdirSync: mkdirSync22 } = await import("fs");
|
|
51695
51722
|
const { dirname: dirname17 } = await import("path");
|
|
51696
51723
|
const mcpConfigPath = coordinatorSetup.configPath;
|
|
51697
51724
|
const hermesManualFallback = cliType === "hermes-cli" && configFormat === "hermes_config_yaml" ? createHermesManualMeshCoordinatorSetup(meshId, workspace) : null;
|
|
@@ -51727,21 +51754,21 @@ ${ptyResult.output.slice(-2e3)}`);
|
|
|
51727
51754
|
};
|
|
51728
51755
|
}
|
|
51729
51756
|
try {
|
|
51730
|
-
|
|
51757
|
+
mkdirSync22(dirname17(mcpConfigPath), { recursive: true });
|
|
51731
51758
|
} catch (error) {
|
|
51732
51759
|
const message = `Could not prepare MCP config path for automatic setup: ${error?.message || error}`;
|
|
51733
51760
|
LOG.error("MeshCoordinator", message);
|
|
51734
51761
|
if (hermesManualFallback) return returnManualFallback(message);
|
|
51735
51762
|
return { success: false, code: "mesh_coordinator_config_write_failed", error: message, meshId, cliType, workspace };
|
|
51736
51763
|
}
|
|
51737
|
-
const hadExistingMcpConfig =
|
|
51764
|
+
const hadExistingMcpConfig = existsSync54(mcpConfigPath);
|
|
51738
51765
|
let existingMcpConfig = hermesBaseConfig?.config || {};
|
|
51739
51766
|
if (hermesBaseConfig) {
|
|
51740
51767
|
copyHermesCoordinatorCredentialFiles(hermesBaseConfig.sourceHome, dirname17(mcpConfigPath));
|
|
51741
51768
|
}
|
|
51742
51769
|
if (hadExistingMcpConfig) {
|
|
51743
51770
|
try {
|
|
51744
|
-
const parsedExistingMcpConfig = parseMeshCoordinatorMcpConfig(
|
|
51771
|
+
const parsedExistingMcpConfig = parseMeshCoordinatorMcpConfig(readFileSync42(mcpConfigPath, "utf-8"), configFormat);
|
|
51745
51772
|
const existingCoordinatorConfig = hermesManualFallback ? stripHermesCoordinatorTempModelProviderOverrides(parsedExistingMcpConfig) : parsedExistingMcpConfig;
|
|
51746
51773
|
existingMcpConfig = { ...existingMcpConfig, ...existingCoordinatorConfig };
|
|
51747
51774
|
copyFileSync4(mcpConfigPath, mcpConfigPath + ".backup");
|
|
@@ -51885,10 +51912,10 @@ function runGit2(repoRoot, args) {
|
|
|
51885
51912
|
}
|
|
51886
51913
|
}
|
|
51887
51914
|
function readRecord6(repoRoot) {
|
|
51888
|
-
const
|
|
51889
|
-
if (!existsSync40(
|
|
51915
|
+
const path44 = resolve19(repoRoot, PREVIEW_DEPLOY_RECORD);
|
|
51916
|
+
if (!existsSync40(path44)) return null;
|
|
51890
51917
|
try {
|
|
51891
|
-
const parsed = JSON.parse(readFileSync31(
|
|
51918
|
+
const parsed = JSON.parse(readFileSync31(path44, "utf8"));
|
|
51892
51919
|
return parsed && typeof parsed === "object" && !Array.isArray(parsed) ? parsed : null;
|
|
51893
51920
|
} catch {
|
|
51894
51921
|
return null;
|
|
@@ -52020,6 +52047,10 @@ var meshStatusHandlers = {
|
|
|
52020
52047
|
const sessionHostRecords = ctx.deps.sessionHostControl?.listSessions ? await ctx.deps.sessionHostControl.listSessions().catch(() => []) : [];
|
|
52021
52048
|
const liveMeshSessions = partitionSessionHostRecords(Array.isArray(sessionHostRecords) ? sessionHostRecords : []).liveRuntimes;
|
|
52022
52049
|
const localMachineId = loadConfig().machineId || "";
|
|
52050
|
+
const localMachineNickname = (() => {
|
|
52051
|
+
const nick = loadConfig().machineNickname;
|
|
52052
|
+
return typeof nick === "string" && nick.trim() ? nick.trim() : "";
|
|
52053
|
+
})();
|
|
52023
52054
|
const requireDirectPeerTruth = args?.requireDirectPeerTruth === true;
|
|
52024
52055
|
const meshGitProbeCache = ctx.meshGitProbeCache;
|
|
52025
52056
|
const directTruth = requireDirectPeerTruth ? await hydrateInlineMeshDirectTruth({
|
|
@@ -52100,6 +52131,9 @@ var meshStatusHandlers = {
|
|
|
52100
52131
|
) || Boolean(
|
|
52101
52132
|
daemonId && (daemonIdsEquivalent(daemonId, localMachineId) || daemonIdsEquivalent(daemonId, ctx.deps.statusInstanceId))
|
|
52102
52133
|
) || Boolean(meshRecord?.inline && nodeIndex === 0) || sparseConfiguredCoordinatorNode;
|
|
52134
|
+
if (isSelfNode && localMachineNickname && !readStringValue(node.machineNickname, node.machine_nickname)) {
|
|
52135
|
+
node.machineNickname = localMachineNickname;
|
|
52136
|
+
}
|
|
52103
52137
|
const machineIdentity = buildMeshNodeMachineIdentity(node, {
|
|
52104
52138
|
localMachineId,
|
|
52105
52139
|
localDaemonId: ctx.deps.statusInstanceId,
|
|
@@ -52436,7 +52470,7 @@ var meshStatusHandlers = {
|
|
|
52436
52470
|
const { deriveMeshReviewInboxItems: deriveMeshReviewInboxItems2 } = await Promise.resolve().then(() => (init_mesh_review_inbox(), mesh_review_inbox_exports));
|
|
52437
52471
|
const { readLedgerEntries: readLedgerEntries2 } = await Promise.resolve().then(() => (init_mesh_ledger(), mesh_ledger_exports));
|
|
52438
52472
|
const { getGitDiffSummary: getGitDiffSummary2 } = await Promise.resolve().then(() => (init_git_diff(), git_diff_exports));
|
|
52439
|
-
const { existsSync:
|
|
52473
|
+
const { existsSync: existsSync54 } = await import("fs");
|
|
52440
52474
|
const meshRecord = await ctx.getMeshForCommand(meshId, args?.inlineMesh, { preferInline: true });
|
|
52441
52475
|
const mesh = meshRecord?.mesh;
|
|
52442
52476
|
if (!mesh) return { success: false, error: "Mesh not found" };
|
|
@@ -52455,7 +52489,7 @@ var meshStatusHandlers = {
|
|
|
52455
52489
|
const derivation = deriveMeshReviewInboxItems2({ nodes: nodeStatuses, ledgerEntries });
|
|
52456
52490
|
for (const item of derivation.items) {
|
|
52457
52491
|
const workspace = item.workspace;
|
|
52458
|
-
if (!workspace || !
|
|
52492
|
+
if (!workspace || !existsSync54(workspace)) continue;
|
|
52459
52493
|
const baseRef = item.defaultBranch ? `origin/${item.defaultBranch}` : "origin/main";
|
|
52460
52494
|
try {
|
|
52461
52495
|
const diffResult = await getGitDiffSummary2(workspace, { baseRef, maxFiles: 100 });
|
|
@@ -52663,9 +52697,9 @@ import { promisify as promisify6 } from "util";
|
|
|
52663
52697
|
var execFileAsync3 = promisify6(execFile4);
|
|
52664
52698
|
var GIT = process.platform === "win32" ? resolveWin32Executable("git") : "git";
|
|
52665
52699
|
var MAX_CHANGED_FILES2 = 500;
|
|
52666
|
-
function topLevel(
|
|
52667
|
-
const slash =
|
|
52668
|
-
return slash === -1 ?
|
|
52700
|
+
function topLevel(path44) {
|
|
52701
|
+
const slash = path44.indexOf("/");
|
|
52702
|
+
return slash === -1 ? path44 : path44.slice(0, slash);
|
|
52669
52703
|
}
|
|
52670
52704
|
async function analyzeMeshRefineNodeChangeArea(args) {
|
|
52671
52705
|
const { nodeId, workspace, branch, baseRef, branchRef, diffCwd, submodulePaths } = args;
|
|
@@ -52988,7 +53022,7 @@ function buildLivePeerGitConnection(connection, timestamp = (/* @__PURE__ */ new
|
|
|
52988
53022
|
}
|
|
52989
53023
|
function recordInlineMeshDirectGitTruth(node, git, source) {
|
|
52990
53024
|
if (!node || typeof node !== "object" || Array.isArray(node)) {
|
|
52991
|
-
return { reporterPlatform: null, reporterArch: null };
|
|
53025
|
+
return { reporterPlatform: null, reporterArch: null, reporterMachineNickname: null };
|
|
52992
53026
|
}
|
|
52993
53027
|
const checkedAt = readNumberValue(git.lastCheckedAt) ?? Date.now();
|
|
52994
53028
|
const updatedAt = new Date(checkedAt).toISOString();
|
|
@@ -53013,7 +53047,9 @@ function recordInlineMeshDirectGitTruth(node, git, source) {
|
|
|
53013
53047
|
stampNodeReporterPlatform(node, reporterPlatform, reporterArch);
|
|
53014
53048
|
if (reporterPlatform) node.reportedPlatform = reporterPlatform;
|
|
53015
53049
|
if (reporterArch) node.reportedArch = reporterArch;
|
|
53016
|
-
|
|
53050
|
+
const reporterMachineNickname = readStringValue(git.reporterMachineNickname) ?? null;
|
|
53051
|
+
if (reporterMachineNickname) node.machineNickname = reporterMachineNickname;
|
|
53052
|
+
return { reporterPlatform, reporterArch, reporterMachineNickname };
|
|
53017
53053
|
}
|
|
53018
53054
|
function stampNodeReporterPlatform(node, platform10, arch2) {
|
|
53019
53055
|
if (!node || typeof node !== "object" || Array.isArray(node)) return;
|
|
@@ -53036,8 +53072,9 @@ function persistNodeReporterPlatform(meshSource, mesh, nodeId, reporter) {
|
|
|
53036
53072
|
if (!meshId || !nodeId) return;
|
|
53037
53073
|
const reportedPlatform = reporter.reporterPlatform ?? void 0;
|
|
53038
53074
|
const reportedArch = reporter.reporterArch ?? void 0;
|
|
53039
|
-
|
|
53040
|
-
|
|
53075
|
+
const reportedMachineNickname = reporter.reporterMachineNickname ?? void 0;
|
|
53076
|
+
if (!reportedPlatform && !reportedArch && !reportedMachineNickname) return;
|
|
53077
|
+
void Promise.resolve().then(() => (init_mesh_config(), mesh_config_exports)).then(({ updateNode: updateNode2 }) => updateNode2(meshId, nodeId, { reportedPlatform, reportedArch, reportedMachineNickname })).catch(() => {
|
|
53041
53078
|
});
|
|
53042
53079
|
}
|
|
53043
53080
|
function buildCachedInlineMeshGitStatus(node) {
|
|
@@ -53689,9 +53726,11 @@ async function probeRemoteMeshGitStatus(args) {
|
|
|
53689
53726
|
if (!remoteGit || typeof remoteGit !== "object" || typeof remoteGit.isGitRepo !== "boolean") return null;
|
|
53690
53727
|
const reporterPlatform = readStringValue(remoteResult?.reporterPlatform);
|
|
53691
53728
|
const reporterArch = readStringValue(remoteResult?.reporterArch);
|
|
53729
|
+
const reporterMachineNickname = readStringValue(remoteResult?.reporterMachineNickname);
|
|
53692
53730
|
const git = remoteGit;
|
|
53693
53731
|
if (reporterPlatform) git.reporterPlatform = reporterPlatform;
|
|
53694
53732
|
if (reporterArch) git.reporterArch = reporterArch;
|
|
53733
|
+
if (reporterMachineNickname) git.reporterMachineNickname = reporterMachineNickname;
|
|
53695
53734
|
return git;
|
|
53696
53735
|
}
|
|
53697
53736
|
var MESH_DIRECT_PROBE_MAX_RETRIES = 2;
|
|
@@ -53718,7 +53757,7 @@ async function probeRemoteMeshGitStatusWithRetry(args) {
|
|
|
53718
53757
|
const connection = args.getConnection?.(args.daemonId);
|
|
53719
53758
|
if (args.getConnection && readMeshConnectionState(connection) !== "connected") break;
|
|
53720
53759
|
if (connection) args.onConnection?.(connection);
|
|
53721
|
-
await new Promise((
|
|
53760
|
+
await new Promise((resolve25) => setTimeout(resolve25, 250 * 2 ** (attempt - 1)));
|
|
53722
53761
|
}
|
|
53723
53762
|
try {
|
|
53724
53763
|
const remoteGit = await probeRemoteMeshGitStatus({
|
|
@@ -54095,18 +54134,18 @@ function resolveRefineryAutoPublishSubmoduleMainCommits(mesh, workspace) {
|
|
|
54095
54134
|
return { enabled: false };
|
|
54096
54135
|
}
|
|
54097
54136
|
async function computeGitPatchId(cwd, fromRef, toRef, excludePaths = []) {
|
|
54098
|
-
const { execFileSync:
|
|
54137
|
+
const { execFileSync: execFileSync10 } = await import("child_process");
|
|
54099
54138
|
const diffArgs = ["diff", "--patch", "--full-index", fromRef, toRef];
|
|
54100
54139
|
if (excludePaths.length > 0) {
|
|
54101
|
-
diffArgs.push("--", ".", ...excludePaths.map((
|
|
54140
|
+
diffArgs.push("--", ".", ...excludePaths.map((path44) => `:(exclude)${path44}`));
|
|
54102
54141
|
}
|
|
54103
|
-
const diff =
|
|
54142
|
+
const diff = execFileSync10(GIT2, diffArgs, {
|
|
54104
54143
|
cwd,
|
|
54105
54144
|
encoding: "utf8",
|
|
54106
54145
|
maxBuffer: REFINE_PATCH_EQUIVALENCE_OUTPUT_LIMIT_BYTES
|
|
54107
54146
|
});
|
|
54108
54147
|
if (!diff.trim()) return "";
|
|
54109
|
-
const patchId =
|
|
54148
|
+
const patchId = execFileSync10(GIT2, ["patch-id", "--stable"], {
|
|
54110
54149
|
cwd,
|
|
54111
54150
|
input: diff,
|
|
54112
54151
|
encoding: "utf8",
|
|
@@ -54117,8 +54156,8 @@ async function computeGitPatchId(cwd, fromRef, toRef, excludePaths = []) {
|
|
|
54117
54156
|
async function runMeshRefinePatchEquivalenceGate(repoRoot, baseHead, branchHead) {
|
|
54118
54157
|
const startedAt = Date.now();
|
|
54119
54158
|
try {
|
|
54120
|
-
const { execFileSync:
|
|
54121
|
-
const git = (args) =>
|
|
54159
|
+
const { execFileSync: execFileSync10 } = await import("child_process");
|
|
54160
|
+
const git = (args) => execFileSync10(GIT2, args, {
|
|
54122
54161
|
cwd: repoRoot,
|
|
54123
54162
|
encoding: "utf8",
|
|
54124
54163
|
maxBuffer: REFINE_PATCH_EQUIVALENCE_OUTPUT_LIMIT_BYTES
|
|
@@ -54209,8 +54248,8 @@ ${e?.stderr || ""}`
|
|
|
54209
54248
|
async function checkWorktreeChangesPatchEquivalentInRef(repoRoot, ref, worktreeHead) {
|
|
54210
54249
|
const startedAt = Date.now();
|
|
54211
54250
|
try {
|
|
54212
|
-
const { execFileSync:
|
|
54213
|
-
const git = (gitArgs) =>
|
|
54251
|
+
const { execFileSync: execFileSync10 } = await import("child_process");
|
|
54252
|
+
const git = (gitArgs) => execFileSync10(GIT2, gitArgs, {
|
|
54214
54253
|
cwd: repoRoot,
|
|
54215
54254
|
encoding: "utf8",
|
|
54216
54255
|
maxBuffer: REFINE_PATCH_EQUIVALENCE_OUTPUT_LIMIT_BYTES
|
|
@@ -54273,8 +54312,8 @@ ${mergeTreeErr?.stderr || ""}`;
|
|
|
54273
54312
|
async function runMeshRefineEffectiveDiffGate(repoRoot, baseHead, branchHead) {
|
|
54274
54313
|
const startedAt = Date.now();
|
|
54275
54314
|
try {
|
|
54276
|
-
const { execFileSync:
|
|
54277
|
-
const git = (args, opts) =>
|
|
54315
|
+
const { execFileSync: execFileSync10 } = await import("child_process");
|
|
54316
|
+
const git = (args, opts) => execFileSync10(GIT2, args, {
|
|
54278
54317
|
cwd: opts?.cwd || repoRoot,
|
|
54279
54318
|
encoding: "utf8",
|
|
54280
54319
|
maxBuffer: REFINE_PATCH_EQUIVALENCE_OUTPUT_LIMIT_BYTES
|
|
@@ -54299,9 +54338,9 @@ async function runMeshRefineEffectiveDiffGate(repoRoot, baseHead, branchHead) {
|
|
|
54299
54338
|
if (!trimmed) continue;
|
|
54300
54339
|
if (trimmed.startsWith("+")) {
|
|
54301
54340
|
const parts = trimmed.slice(1).trim().split(/\s+/);
|
|
54302
|
-
const
|
|
54341
|
+
const path44 = parts[1] || parts[0] || "(unknown)";
|
|
54303
54342
|
submoduleHints.push({
|
|
54304
|
-
path:
|
|
54343
|
+
path: path44,
|
|
54305
54344
|
reason: "submodule checked-out commit differs from the committed gitlink (pointer bump not committed on the root branch)"
|
|
54306
54345
|
});
|
|
54307
54346
|
}
|
|
@@ -54331,10 +54370,10 @@ async function runMeshRefineEffectiveDiffGate(repoRoot, baseHead, branchHead) {
|
|
|
54331
54370
|
}
|
|
54332
54371
|
function buildPatchEquivalenceSubmoduleConflictHint(repoRoot, baseHead, branchHead, output) {
|
|
54333
54372
|
if (!/(submodule|160000)/i.test(output) || !/(conflict|failed to merge)/i.test(output)) return void 0;
|
|
54334
|
-
const conflicts = readChangedGitlinkPaths(repoRoot, baseHead, branchHead).map((
|
|
54335
|
-
path:
|
|
54336
|
-
baseCommit: readTreeObject(repoRoot, baseHead,
|
|
54337
|
-
branchCommit: readTreeObject(repoRoot, branchHead,
|
|
54373
|
+
const conflicts = readChangedGitlinkPaths(repoRoot, baseHead, branchHead).map((path44) => ({
|
|
54374
|
+
path: path44,
|
|
54375
|
+
baseCommit: readTreeObject(repoRoot, baseHead, path44),
|
|
54376
|
+
branchCommit: readTreeObject(repoRoot, branchHead, path44)
|
|
54338
54377
|
}));
|
|
54339
54378
|
if (conflicts.length === 0) return void 0;
|
|
54340
54379
|
return {
|
|
@@ -54360,11 +54399,11 @@ function readChangedGitlinkPaths(repoRoot, fromRef, toRef) {
|
|
|
54360
54399
|
if (!line.trim()) continue;
|
|
54361
54400
|
const metaAndPath = line.split(" ");
|
|
54362
54401
|
const meta = metaAndPath[0] || "";
|
|
54363
|
-
const
|
|
54364
|
-
if (!
|
|
54402
|
+
const path44 = metaAndPath[metaAndPath.length - 1]?.trim();
|
|
54403
|
+
if (!path44) continue;
|
|
54365
54404
|
const parts = meta.split(/\s+/);
|
|
54366
54405
|
if (parts[0]?.includes("160000") || parts[1]?.includes("160000")) {
|
|
54367
|
-
paths.add(
|
|
54406
|
+
paths.add(path44);
|
|
54368
54407
|
}
|
|
54369
54408
|
}
|
|
54370
54409
|
return [...paths].sort();
|
|
@@ -54372,9 +54411,9 @@ function readChangedGitlinkPaths(repoRoot, fromRef, toRef) {
|
|
|
54372
54411
|
return [];
|
|
54373
54412
|
}
|
|
54374
54413
|
}
|
|
54375
|
-
function readTreeObject(repoRoot, ref,
|
|
54414
|
+
function readTreeObject(repoRoot, ref, path44) {
|
|
54376
54415
|
try {
|
|
54377
|
-
const output = execFileSync7(GIT2, ["ls-tree", ref, "--",
|
|
54416
|
+
const output = execFileSync7(GIT2, ["ls-tree", ref, "--", path44], {
|
|
54378
54417
|
cwd: repoRoot,
|
|
54379
54418
|
encoding: "utf8",
|
|
54380
54419
|
maxBuffer: 1024 * 1024
|
|
@@ -54419,12 +54458,12 @@ function readChangedPathKinds(repoRoot, fromRef, toRef) {
|
|
|
54419
54458
|
if (!line.trim()) continue;
|
|
54420
54459
|
const metaAndPath = line.split(" ");
|
|
54421
54460
|
const meta = metaAndPath[0] || "";
|
|
54422
|
-
const
|
|
54423
|
-
if (!
|
|
54424
|
-
seen.add(
|
|
54461
|
+
const path44 = metaAndPath[metaAndPath.length - 1]?.trim();
|
|
54462
|
+
if (!path44 || seen.has(path44)) continue;
|
|
54463
|
+
seen.add(path44);
|
|
54425
54464
|
const parts = meta.split(/\s+/);
|
|
54426
54465
|
const isGitlink = !!(parts[0]?.includes("160000") || parts[1]?.includes("160000"));
|
|
54427
|
-
result.push({ path:
|
|
54466
|
+
result.push({ path: path44, isGitlink });
|
|
54428
54467
|
}
|
|
54429
54468
|
return result;
|
|
54430
54469
|
} catch {
|
|
@@ -54432,20 +54471,20 @@ function readChangedPathKinds(repoRoot, fromRef, toRef) {
|
|
|
54432
54471
|
}
|
|
54433
54472
|
}
|
|
54434
54473
|
function collectFastForwardGitlinkPaths(repoRoot, baseHead, branchHead) {
|
|
54435
|
-
return readChangedGitlinkPaths(repoRoot, baseHead, branchHead).filter((
|
|
54436
|
-
const baseCommit = readTreeObject(repoRoot, baseHead,
|
|
54437
|
-
const branchCommit = readTreeObject(repoRoot, branchHead,
|
|
54474
|
+
return readChangedGitlinkPaths(repoRoot, baseHead, branchHead).filter((path44) => {
|
|
54475
|
+
const baseCommit = readTreeObject(repoRoot, baseHead, path44);
|
|
54476
|
+
const branchCommit = readTreeObject(repoRoot, branchHead, path44);
|
|
54438
54477
|
if (!baseCommit || !branchCommit) return false;
|
|
54439
|
-
return isSubmoduleFastForward(pathResolve2(repoRoot,
|
|
54478
|
+
return isSubmoduleFastForward(pathResolve2(repoRoot, path44), baseCommit, branchCommit);
|
|
54440
54479
|
});
|
|
54441
54480
|
}
|
|
54442
54481
|
function evaluateGitlinkTrivialFastForward(repoRoot, baseHead, branchHead) {
|
|
54443
|
-
const changedGitlinks = readChangedGitlinkPaths(repoRoot, baseHead, branchHead).map((
|
|
54444
|
-
const baseCommit = readTreeObject(repoRoot, baseHead,
|
|
54445
|
-
const branchCommit = readTreeObject(repoRoot, branchHead,
|
|
54446
|
-
const submoduleRepoPath = pathResolve2(repoRoot,
|
|
54482
|
+
const changedGitlinks = readChangedGitlinkPaths(repoRoot, baseHead, branchHead).map((path44) => {
|
|
54483
|
+
const baseCommit = readTreeObject(repoRoot, baseHead, path44);
|
|
54484
|
+
const branchCommit = readTreeObject(repoRoot, branchHead, path44);
|
|
54485
|
+
const submoduleRepoPath = pathResolve2(repoRoot, path44);
|
|
54447
54486
|
const fastForward = !!baseCommit && !!branchCommit && isSubmoduleFastForward(submoduleRepoPath, baseCommit, branchCommit);
|
|
54448
|
-
return { path:
|
|
54487
|
+
return { path: path44, baseCommit, branchCommit, fastForward };
|
|
54449
54488
|
});
|
|
54450
54489
|
if (changedGitlinks.length === 0) {
|
|
54451
54490
|
return { trivial: false, reason: "no_changed_gitlinks", gitlinks: changedGitlinks };
|
|
@@ -54496,7 +54535,7 @@ function buildTreeWithGitlinksEqualized(repoRoot, commitish, paths, placeholderC
|
|
|
54496
54535
|
maxBuffer: 1024 * 1024
|
|
54497
54536
|
}).trim();
|
|
54498
54537
|
if (!tree) return void 0;
|
|
54499
|
-
const updates = paths.map((
|
|
54538
|
+
const updates = paths.map((path44) => `160000 commit ${placeholderCommit} ${path44}`).join("\n");
|
|
54500
54539
|
if (!updates) return tree;
|
|
54501
54540
|
const tmpIndex = pathJoin2(resolveGitDir(repoRoot), `adhdev-refine-eq-${commitish.slice(0, 12)}.index`);
|
|
54502
54541
|
const env = { ...process.env, GIT_INDEX_FILE: tmpIndex };
|
|
@@ -54599,7 +54638,7 @@ function synthesizeTrivialFastForwardMergeTree(repoRoot, baseHead, branchHead, g
|
|
|
54599
54638
|
}
|
|
54600
54639
|
async function alignRefinerySubmodulesAfterMerge(repoRoot, previousBaseHead, currentHead, options = {}) {
|
|
54601
54640
|
const startedAt = Date.now();
|
|
54602
|
-
const changedGitlinkPaths = readChangedGitlinkPaths(repoRoot, previousBaseHead, currentHead).filter((
|
|
54641
|
+
const changedGitlinkPaths = readChangedGitlinkPaths(repoRoot, previousBaseHead, currentHead).filter((path44) => !(options.submoduleIgnorePaths || []).includes(path44));
|
|
54603
54642
|
const preStatus = await getGitRepoStatus(repoRoot, {
|
|
54604
54643
|
includeSubmodules: true,
|
|
54605
54644
|
submoduleIgnorePaths: options.submoduleIgnorePaths,
|
|
@@ -54646,7 +54685,7 @@ async function alignRefinerySubmodulesAfterMerge(repoRoot, previousBaseHead, cur
|
|
|
54646
54685
|
changedGitlinkPaths,
|
|
54647
54686
|
outOfSyncPaths,
|
|
54648
54687
|
updatedPaths: updatePaths,
|
|
54649
|
-
verifiedPaths: updatePaths.filter((
|
|
54688
|
+
verifiedPaths: updatePaths.filter((path44) => !remaining.some((submodule) => submodule.path === path44)),
|
|
54650
54689
|
durationMs: Date.now() - startedAt,
|
|
54651
54690
|
command: `git ${commandArgs.join(" ")}`,
|
|
54652
54691
|
stdout: truncateValidationOutput(result.stdout),
|
|
@@ -54972,15 +55011,15 @@ async function runMeshRefineValidationGate(mesh, workspace, opts) {
|
|
|
54972
55011
|
const cwd = candidate.cwd ? pathResolve2(workspace, candidate.cwd) : workspace;
|
|
54973
55012
|
const timeout = candidate.timeoutMs || REFINE_VALIDATION_TIMEOUT_MS;
|
|
54974
55013
|
const resolvedCommand = resolveWin32Executable(candidate.command);
|
|
54975
|
-
const
|
|
55014
|
+
const spawn5 = buildWin32ExecFileSpawn(resolvedCommand, candidate.args);
|
|
54976
55015
|
try {
|
|
54977
|
-
const result = await execFileAsync4(
|
|
55016
|
+
const result = await execFileAsync4(spawn5.file, spawn5.args, {
|
|
54978
55017
|
cwd,
|
|
54979
55018
|
encoding: "utf8",
|
|
54980
55019
|
timeout,
|
|
54981
55020
|
maxBuffer: candidate.outputLimitBytes || REFINE_VALIDATION_OUTPUT_LIMIT_BYTES,
|
|
54982
55021
|
env: { ...process.env, CI: process.env.CI || "1", ...candidate.env || {} },
|
|
54983
|
-
...
|
|
55022
|
+
...spawn5.windowsVerbatimArguments ? { windowsVerbatimArguments: true } : {}
|
|
54984
55023
|
});
|
|
54985
55024
|
summary.bootstrapCommandsRun.push(commandRecord(candidate, cwd, startedAt, result, true, { exitCode: 0 }));
|
|
54986
55025
|
} catch (error) {
|
|
@@ -55018,15 +55057,15 @@ async function runMeshRefineValidationGate(mesh, workspace, opts) {
|
|
|
55018
55057
|
return summary;
|
|
55019
55058
|
}
|
|
55020
55059
|
const resolvedCommand = resolveWin32Executable(candidate.command);
|
|
55021
|
-
const
|
|
55060
|
+
const spawn5 = buildWin32ExecFileSpawn(resolvedCommand, candidate.args);
|
|
55022
55061
|
try {
|
|
55023
|
-
const result = await execFileAsync4(
|
|
55062
|
+
const result = await execFileAsync4(spawn5.file, spawn5.args, {
|
|
55024
55063
|
cwd,
|
|
55025
55064
|
encoding: "utf8",
|
|
55026
55065
|
timeout,
|
|
55027
55066
|
maxBuffer: candidate.outputLimitBytes || REFINE_VALIDATION_OUTPUT_LIMIT_BYTES,
|
|
55028
55067
|
env: { ...process.env, CI: process.env.CI || "1", ...candidate.env || {} },
|
|
55029
|
-
...
|
|
55068
|
+
...spawn5.windowsVerbatimArguments ? { windowsVerbatimArguments: true } : {}
|
|
55030
55069
|
});
|
|
55031
55070
|
summary.commandsRun.push(commandRecord(candidate, cwd, startedAt, result, true, { exitCode: 0 }));
|
|
55032
55071
|
} catch (error) {
|
|
@@ -55735,7 +55774,7 @@ var DaemonCommandRouter = class {
|
|
|
55735
55774
|
*/
|
|
55736
55775
|
async bestEffortRemoveWorktreeDir(dir) {
|
|
55737
55776
|
if (!dir || !fs32.existsSync(dir)) return { removed: true, residue: false };
|
|
55738
|
-
const sleep3 = (ms) => new Promise((
|
|
55777
|
+
const sleep3 = (ms) => new Promise((resolve25) => setTimeout(resolve25, ms));
|
|
55739
55778
|
const ABSORB = /* @__PURE__ */ new Set(["EINVAL", "EPERM", "EBUSY", "ENOTEMPTY", "EACCES", "EMFILE", "ENFILE"]);
|
|
55740
55779
|
let lastErr;
|
|
55741
55780
|
for (let attempt = 0; attempt < 4; attempt++) {
|
|
@@ -58493,7 +58532,7 @@ var ProviderStreamAdapter = class {
|
|
|
58493
58532
|
const beforeCount = this.messageCount(before);
|
|
58494
58533
|
const beforeSignature = this.lastMessageSignature(before);
|
|
58495
58534
|
for (let attempt = 0; attempt < 12; attempt += 1) {
|
|
58496
|
-
await new Promise((
|
|
58535
|
+
await new Promise((resolve25) => setTimeout(resolve25, 250));
|
|
58497
58536
|
let state;
|
|
58498
58537
|
try {
|
|
58499
58538
|
state = await this.readChat(evaluate);
|
|
@@ -58515,7 +58554,7 @@ var ProviderStreamAdapter = class {
|
|
|
58515
58554
|
if (this.messageCount(first) > 0 || this.lastMessageSignature(first)) {
|
|
58516
58555
|
return first;
|
|
58517
58556
|
}
|
|
58518
|
-
await new Promise((
|
|
58557
|
+
await new Promise((resolve25) => setTimeout(resolve25, 150));
|
|
58519
58558
|
const second = await this.readChat(evaluate);
|
|
58520
58559
|
return this.messageCount(second) >= this.messageCount(first) ? second : first;
|
|
58521
58560
|
}
|
|
@@ -58666,7 +58705,7 @@ var ProviderStreamAdapter = class {
|
|
|
58666
58705
|
if (typeof data.error === "string" && data.error.trim()) return false;
|
|
58667
58706
|
}
|
|
58668
58707
|
for (let attempt = 0; attempt < 6; attempt += 1) {
|
|
58669
|
-
await new Promise((
|
|
58708
|
+
await new Promise((resolve25) => setTimeout(resolve25, 250));
|
|
58670
58709
|
const state = await this.readChat(evaluate);
|
|
58671
58710
|
const title = this.getStateTitle(state);
|
|
58672
58711
|
if (this.titlesMatch(title, sessionId)) return true;
|
|
@@ -59658,13 +59697,13 @@ var VersionArchive = class {
|
|
|
59658
59697
|
}
|
|
59659
59698
|
};
|
|
59660
59699
|
async function runCommand(cmd, timeout = 1e4) {
|
|
59661
|
-
return new Promise((
|
|
59700
|
+
return new Promise((resolve25) => {
|
|
59662
59701
|
exec5(cmd, {
|
|
59663
59702
|
encoding: "utf-8",
|
|
59664
59703
|
timeout
|
|
59665
59704
|
}, (error, stdout) => {
|
|
59666
|
-
if (error) return
|
|
59667
|
-
|
|
59705
|
+
if (error) return resolve25(null);
|
|
59706
|
+
resolve25(stdout.trim());
|
|
59668
59707
|
});
|
|
59669
59708
|
});
|
|
59670
59709
|
}
|
|
@@ -61364,7 +61403,7 @@ function getCliTargetBundle(ctx, type, instanceId) {
|
|
|
61364
61403
|
return { target, instance, adapter };
|
|
61365
61404
|
}
|
|
61366
61405
|
function sleep2(ms) {
|
|
61367
|
-
return new Promise((
|
|
61406
|
+
return new Promise((resolve25) => setTimeout(resolve25, ms));
|
|
61368
61407
|
}
|
|
61369
61408
|
async function waitForCliReady(ctx, type, instanceId, timeoutMs) {
|
|
61370
61409
|
const startedAt = Date.now();
|
|
@@ -62340,8 +62379,8 @@ async function handleAutoImplement(ctx, type, req, res) {
|
|
|
62340
62379
|
fs36.writeFileSync(promptFile, prompt, "utf-8");
|
|
62341
62380
|
ctx.log(`Auto-implement prompt written to ${promptFile} (${prompt.length} chars)`);
|
|
62342
62381
|
const agentProvider = ctx.providerLoader.resolve(agent) || ctx.providerLoader.getMeta(agent);
|
|
62343
|
-
const
|
|
62344
|
-
if (!
|
|
62382
|
+
const spawn5 = agentProvider?.spawn;
|
|
62383
|
+
if (!spawn5?.command) {
|
|
62345
62384
|
try {
|
|
62346
62385
|
fs36.unlinkSync(promptFile);
|
|
62347
62386
|
} catch {
|
|
@@ -62351,22 +62390,22 @@ async function handleAutoImplement(ctx, type, req, res) {
|
|
|
62351
62390
|
}
|
|
62352
62391
|
const agentCategory = agentProvider?.category;
|
|
62353
62392
|
if (agentCategory === "acp") {
|
|
62354
|
-
sendAutoImplSSE(ctx, { event: "progress", data: { function: "_init", status: "spawning", message: `Spawning ACP agent: ${
|
|
62393
|
+
sendAutoImplSSE(ctx, { event: "progress", data: { function: "_init", status: "spawning", message: `Spawning ACP agent: ${spawn5.command} ${(spawn5.args || []).join(" ")}` } });
|
|
62355
62394
|
ctx.autoImplStatus.running = true;
|
|
62356
62395
|
ctx.autoImplStatus.type = type;
|
|
62357
62396
|
const { ClientSideConnection: ClientSideConnection2, ndJsonStream: ndJsonStream2, PROTOCOL_VERSION: PROTOCOL_VERSION2 } = await import("@agentclientprotocol/sdk");
|
|
62358
62397
|
const { Readable: Readable2, Writable: Writable2 } = await import("stream");
|
|
62359
62398
|
const { spawn: spawnFn2 } = await import("child_process");
|
|
62360
|
-
const acpArgs = [...
|
|
62399
|
+
const acpArgs = [...spawn5.args || []];
|
|
62361
62400
|
if (model) {
|
|
62362
62401
|
acpArgs.push("--model", model);
|
|
62363
62402
|
ctx.log(`Auto-implement ACP using model: ${model}`);
|
|
62364
62403
|
}
|
|
62365
|
-
const child2 = spawnFn2(
|
|
62404
|
+
const child2 = spawnFn2(spawn5.command, acpArgs, {
|
|
62366
62405
|
cwd: providerDir,
|
|
62367
62406
|
stdio: ["pipe", "pipe", "pipe"],
|
|
62368
|
-
shell:
|
|
62369
|
-
env: { ...process.env, ...
|
|
62407
|
+
shell: spawn5.shell ?? false,
|
|
62408
|
+
env: { ...process.env, ...spawn5.env || {} }
|
|
62370
62409
|
});
|
|
62371
62410
|
ctx.autoImplProcess = child2;
|
|
62372
62411
|
child2.stderr?.on("data", (d) => {
|
|
@@ -62476,7 +62515,7 @@ async function handleAutoImplement(ctx, type, req, res) {
|
|
|
62476
62515
|
ctx.json(res, 202, {
|
|
62477
62516
|
started: true,
|
|
62478
62517
|
type,
|
|
62479
|
-
agent:
|
|
62518
|
+
agent: spawn5.command,
|
|
62480
62519
|
functions,
|
|
62481
62520
|
providerDir,
|
|
62482
62521
|
message: "ACP Auto-implement started. Connect to SSE for progress.",
|
|
@@ -62484,10 +62523,10 @@ async function handleAutoImplement(ctx, type, req, res) {
|
|
|
62484
62523
|
});
|
|
62485
62524
|
return;
|
|
62486
62525
|
}
|
|
62487
|
-
const command =
|
|
62488
|
-
const autoImpl =
|
|
62526
|
+
const command = spawn5.command;
|
|
62527
|
+
const autoImpl = spawn5.autoImpl;
|
|
62489
62528
|
const interactiveFlags = ["--yolo", "--interactive", "-i"];
|
|
62490
|
-
const baseArgs = [...
|
|
62529
|
+
const baseArgs = [...spawn5.args || []].filter((a) => !interactiveFlags.includes(a));
|
|
62491
62530
|
let shellCmd;
|
|
62492
62531
|
const isWin = os29.platform() === "win32";
|
|
62493
62532
|
const escapeArg = (a) => isWin ? `"${a.replace(/"/g, '""')}"` : `'${a.replace(/'/g, "'\\''")}'`;
|
|
@@ -62534,7 +62573,7 @@ async function handleAutoImplement(ctx, type, req, res) {
|
|
|
62534
62573
|
cols: DEFAULT_SESSION_HOST_COLS7,
|
|
62535
62574
|
rows: DEFAULT_SESSION_HOST_ROWS7,
|
|
62536
62575
|
cwd: providerDir,
|
|
62537
|
-
env: { ...process.env, ...
|
|
62576
|
+
env: { ...process.env, ...spawn5.env || {} }
|
|
62538
62577
|
});
|
|
62539
62578
|
isPty = true;
|
|
62540
62579
|
} catch (err) {
|
|
@@ -62546,7 +62585,7 @@ async function handleAutoImplement(ctx, type, req, res) {
|
|
|
62546
62585
|
stdio: ["pipe", "pipe", "pipe"],
|
|
62547
62586
|
env: {
|
|
62548
62587
|
...process.env,
|
|
62549
|
-
...
|
|
62588
|
+
...spawn5.env || {}
|
|
62550
62589
|
}
|
|
62551
62590
|
});
|
|
62552
62591
|
child.on("error", (err2) => {
|
|
@@ -63588,8 +63627,8 @@ var DevServer = class _DevServer {
|
|
|
63588
63627
|
}
|
|
63589
63628
|
getEndpointList() {
|
|
63590
63629
|
return this.routes.map((r) => {
|
|
63591
|
-
const
|
|
63592
|
-
return `${r.method.padEnd(5)} ${
|
|
63630
|
+
const path44 = typeof r.pattern === "string" ? r.pattern : r.pattern.source.replace(/\\\//g, "/").replace(/\(\[.*?\]\+\)/g, ":type").replace(/[\^$]/g, "");
|
|
63631
|
+
return `${r.method.padEnd(5)} ${path44}`;
|
|
63593
63632
|
});
|
|
63594
63633
|
}
|
|
63595
63634
|
async start(port = DEV_SERVER_PORT) {
|
|
@@ -63620,15 +63659,15 @@ var DevServer = class _DevServer {
|
|
|
63620
63659
|
this.json(res, 500, { error: e.message });
|
|
63621
63660
|
}
|
|
63622
63661
|
});
|
|
63623
|
-
return new Promise((
|
|
63662
|
+
return new Promise((resolve25, reject) => {
|
|
63624
63663
|
this.server.listen(port, "127.0.0.1", () => {
|
|
63625
63664
|
this.log(`Dev server listening on http://127.0.0.1:${port}`);
|
|
63626
|
-
|
|
63665
|
+
resolve25();
|
|
63627
63666
|
});
|
|
63628
63667
|
this.server.on("error", (e) => {
|
|
63629
63668
|
if (e.code === "EADDRINUSE") {
|
|
63630
63669
|
this.log(`Port ${port} in use, skipping dev server`);
|
|
63631
|
-
|
|
63670
|
+
resolve25();
|
|
63632
63671
|
} else {
|
|
63633
63672
|
reject(e);
|
|
63634
63673
|
}
|
|
@@ -63689,16 +63728,16 @@ var DevServer = class _DevServer {
|
|
|
63689
63728
|
this.json(res, 404, { error: `Provider not found: ${type}` });
|
|
63690
63729
|
return;
|
|
63691
63730
|
}
|
|
63692
|
-
const
|
|
63693
|
-
if (!
|
|
63731
|
+
const spawn5 = provider.spawn;
|
|
63732
|
+
if (!spawn5) {
|
|
63694
63733
|
this.json(res, 400, { error: `Provider ${type} has no spawn config` });
|
|
63695
63734
|
return;
|
|
63696
63735
|
}
|
|
63697
63736
|
const { spawn: spawnFn } = await import("child_process");
|
|
63698
63737
|
const start = Date.now();
|
|
63699
63738
|
try {
|
|
63700
|
-
const child = spawnFn(
|
|
63701
|
-
shell:
|
|
63739
|
+
const child = spawnFn(spawn5.command, [...spawn5.args || []], {
|
|
63740
|
+
shell: spawn5.shell ?? false,
|
|
63702
63741
|
timeout: 5e3,
|
|
63703
63742
|
stdio: ["pipe", "pipe", "pipe"]
|
|
63704
63743
|
});
|
|
@@ -63710,27 +63749,27 @@ var DevServer = class _DevServer {
|
|
|
63710
63749
|
child.stderr?.on("data", (d) => {
|
|
63711
63750
|
stderr += d.toString().slice(0, 2e3);
|
|
63712
63751
|
});
|
|
63713
|
-
await new Promise((
|
|
63752
|
+
await new Promise((resolve25) => {
|
|
63714
63753
|
const timer = setTimeout(() => {
|
|
63715
63754
|
child.kill();
|
|
63716
|
-
|
|
63755
|
+
resolve25();
|
|
63717
63756
|
}, 3e3);
|
|
63718
63757
|
child.on("exit", () => {
|
|
63719
63758
|
clearTimeout(timer);
|
|
63720
|
-
|
|
63759
|
+
resolve25();
|
|
63721
63760
|
});
|
|
63722
63761
|
child.stdout?.once("data", () => {
|
|
63723
63762
|
setTimeout(() => {
|
|
63724
63763
|
child.kill();
|
|
63725
63764
|
clearTimeout(timer);
|
|
63726
|
-
|
|
63765
|
+
resolve25();
|
|
63727
63766
|
}, 500);
|
|
63728
63767
|
});
|
|
63729
63768
|
});
|
|
63730
63769
|
const elapsed = Date.now() - start;
|
|
63731
63770
|
this.json(res, 200, {
|
|
63732
63771
|
success: true,
|
|
63733
|
-
command: `${
|
|
63772
|
+
command: `${spawn5.command} ${(spawn5.args || []).join(" ")}`,
|
|
63734
63773
|
elapsed,
|
|
63735
63774
|
stdout: stdout.trim(),
|
|
63736
63775
|
stderr: stderr.trim(),
|
|
@@ -63740,7 +63779,7 @@ var DevServer = class _DevServer {
|
|
|
63740
63779
|
const elapsed = Date.now() - start;
|
|
63741
63780
|
this.json(res, 200, {
|
|
63742
63781
|
success: false,
|
|
63743
|
-
command: `${
|
|
63782
|
+
command: `${spawn5.command} ${(spawn5.args || []).join(" ")}`,
|
|
63744
63783
|
elapsed,
|
|
63745
63784
|
error: e.message
|
|
63746
63785
|
});
|
|
@@ -64203,20 +64242,20 @@ var DevServer = class _DevServer {
|
|
|
64203
64242
|
this.json(res, 404, { error: `Provider not found: ${type}` });
|
|
64204
64243
|
return;
|
|
64205
64244
|
}
|
|
64206
|
-
const
|
|
64207
|
-
if (!
|
|
64245
|
+
const spawn5 = provider.spawn;
|
|
64246
|
+
if (!spawn5) {
|
|
64208
64247
|
this.json(res, 400, { error: `Provider ${type} has no spawn config` });
|
|
64209
64248
|
return;
|
|
64210
64249
|
}
|
|
64211
64250
|
const { spawn: spawnFn } = await import("child_process");
|
|
64212
64251
|
const start = Date.now();
|
|
64213
64252
|
try {
|
|
64214
|
-
const args = [...
|
|
64215
|
-
const child = spawnFn(
|
|
64216
|
-
shell:
|
|
64253
|
+
const args = [...spawn5.args || [], message];
|
|
64254
|
+
const child = spawnFn(spawn5.command, args, {
|
|
64255
|
+
shell: spawn5.shell ?? false,
|
|
64217
64256
|
timeout,
|
|
64218
64257
|
stdio: ["pipe", "pipe", "pipe"],
|
|
64219
|
-
env: { ...process.env, ...
|
|
64258
|
+
env: { ...process.env, ...spawn5.env || {} }
|
|
64220
64259
|
});
|
|
64221
64260
|
let stdout = "";
|
|
64222
64261
|
let stderr = "";
|
|
@@ -64226,14 +64265,14 @@ var DevServer = class _DevServer {
|
|
|
64226
64265
|
child.stderr?.on("data", (d) => {
|
|
64227
64266
|
stderr += d.toString();
|
|
64228
64267
|
});
|
|
64229
|
-
await new Promise((
|
|
64268
|
+
await new Promise((resolve25) => {
|
|
64230
64269
|
const timer = setTimeout(() => {
|
|
64231
64270
|
child.kill();
|
|
64232
|
-
|
|
64271
|
+
resolve25();
|
|
64233
64272
|
}, timeout);
|
|
64234
64273
|
child.on("exit", () => {
|
|
64235
64274
|
clearTimeout(timer);
|
|
64236
|
-
|
|
64275
|
+
resolve25();
|
|
64237
64276
|
});
|
|
64238
64277
|
});
|
|
64239
64278
|
const elapsed = Date.now() - start;
|
|
@@ -64432,14 +64471,14 @@ data: ${JSON.stringify(msg.data)}
|
|
|
64432
64471
|
res.end(JSON.stringify(data, null, 2));
|
|
64433
64472
|
}
|
|
64434
64473
|
async readBody(req) {
|
|
64435
|
-
return new Promise((
|
|
64474
|
+
return new Promise((resolve25) => {
|
|
64436
64475
|
let body = "";
|
|
64437
64476
|
req.on("data", (chunk) => body += chunk);
|
|
64438
64477
|
req.on("end", () => {
|
|
64439
64478
|
try {
|
|
64440
|
-
|
|
64479
|
+
resolve25(JSON.parse(body));
|
|
64441
64480
|
} catch {
|
|
64442
|
-
|
|
64481
|
+
resolve25({});
|
|
64443
64482
|
}
|
|
64444
64483
|
});
|
|
64445
64484
|
});
|
|
@@ -65181,7 +65220,7 @@ async function waitForReady(endpoint, timeoutMs = STARTUP_TIMEOUT_MS, requiredRe
|
|
|
65181
65220
|
const deadline = Date.now() + timeoutMs;
|
|
65182
65221
|
while (Date.now() < deadline) {
|
|
65183
65222
|
if (await canConnect(endpoint, requiredRequestTypes)) return;
|
|
65184
|
-
await new Promise((
|
|
65223
|
+
await new Promise((resolve25) => setTimeout(resolve25, STARTUP_POLL_MS));
|
|
65185
65224
|
}
|
|
65186
65225
|
throw new Error(`Session host did not become ready within ${timeoutMs}ms`);
|
|
65187
65226
|
}
|
|
@@ -65222,6 +65261,151 @@ async function listHostedCliRuntimes(endpoint) {
|
|
|
65222
65261
|
}
|
|
65223
65262
|
}
|
|
65224
65263
|
|
|
65264
|
+
// src/session-host/managed-host.ts
|
|
65265
|
+
import { execFileSync as execFileSync9, spawn as spawn4 } from "child_process";
|
|
65266
|
+
import * as fs38 from "fs";
|
|
65267
|
+
import * as os30 from "os";
|
|
65268
|
+
import * as path43 from "path";
|
|
65269
|
+
import {
|
|
65270
|
+
getDefaultSessionHostEndpoint as getDefaultSessionHostEndpoint2,
|
|
65271
|
+
sanitizeSpawnEnv as sanitizeSpawnEnv2
|
|
65272
|
+
} from "@adhdev/session-host-core";
|
|
65273
|
+
init_runtime_defaults();
|
|
65274
|
+
function createManagedSessionHost(options) {
|
|
65275
|
+
const appName = options.appName;
|
|
65276
|
+
const timeoutMs = options.timeoutMs ?? DEFAULT_SESSION_HOST_READY_TIMEOUT_MS;
|
|
65277
|
+
const endpoint = getDefaultSessionHostEndpoint2(appName);
|
|
65278
|
+
const isManagedPid = options.isManagedPid ?? (() => true);
|
|
65279
|
+
function buildEnv(baseEnv) {
|
|
65280
|
+
const env = sanitizeSpawnEnv2(baseEnv);
|
|
65281
|
+
env.ADHDEV_SESSION_HOST_NAME = appName;
|
|
65282
|
+
return env;
|
|
65283
|
+
}
|
|
65284
|
+
function resolveEntry() {
|
|
65285
|
+
const packagedCandidates = [
|
|
65286
|
+
path43.resolve(__dirname, "../vendor/session-host-daemon/index.js"),
|
|
65287
|
+
path43.resolve(__dirname, "../../vendor/session-host-daemon/index.js")
|
|
65288
|
+
];
|
|
65289
|
+
for (const candidate of packagedCandidates) {
|
|
65290
|
+
if (fs38.existsSync(candidate)) {
|
|
65291
|
+
return candidate;
|
|
65292
|
+
}
|
|
65293
|
+
}
|
|
65294
|
+
return __require.resolve("@adhdev/session-host-daemon");
|
|
65295
|
+
}
|
|
65296
|
+
function getPidFile() {
|
|
65297
|
+
return path43.join(os30.homedir(), ".adhdev", `${appName}-session-host.pid`);
|
|
65298
|
+
}
|
|
65299
|
+
function getPid() {
|
|
65300
|
+
try {
|
|
65301
|
+
const pidFile = getPidFile();
|
|
65302
|
+
if (!fs38.existsSync(pidFile)) return null;
|
|
65303
|
+
const pid = Number.parseInt(fs38.readFileSync(pidFile, "utf8").trim(), 10);
|
|
65304
|
+
return Number.isFinite(pid) ? pid : null;
|
|
65305
|
+
} catch {
|
|
65306
|
+
return null;
|
|
65307
|
+
}
|
|
65308
|
+
}
|
|
65309
|
+
function killPid2(pid) {
|
|
65310
|
+
try {
|
|
65311
|
+
if (process.platform === "win32") {
|
|
65312
|
+
const spawnOpts = { stdio: "ignore" };
|
|
65313
|
+
if (options.killWindowsHide) spawnOpts.windowsHide = true;
|
|
65314
|
+
execFileSync9("taskkill", ["/PID", String(pid), "/T", "/F"], spawnOpts);
|
|
65315
|
+
} else {
|
|
65316
|
+
process.kill(pid, "SIGTERM");
|
|
65317
|
+
}
|
|
65318
|
+
return true;
|
|
65319
|
+
} catch {
|
|
65320
|
+
return false;
|
|
65321
|
+
}
|
|
65322
|
+
}
|
|
65323
|
+
function spawnHost() {
|
|
65324
|
+
const entry = resolveEntry();
|
|
65325
|
+
let stdio = "ignore";
|
|
65326
|
+
let logFd = null;
|
|
65327
|
+
if (options.spawnStdio === "logfile") {
|
|
65328
|
+
const logDir = path43.join(os30.homedir(), ".adhdev", "logs");
|
|
65329
|
+
fs38.mkdirSync(logDir, { recursive: true });
|
|
65330
|
+
logFd = fs38.openSync(path43.join(logDir, "session-host.log"), "a");
|
|
65331
|
+
stdio = ["ignore", logFd, logFd];
|
|
65332
|
+
}
|
|
65333
|
+
const child = spawn4(process.execPath, [entry], {
|
|
65334
|
+
detached: true,
|
|
65335
|
+
stdio,
|
|
65336
|
+
windowsHide: true,
|
|
65337
|
+
env: buildEnv(process.env)
|
|
65338
|
+
});
|
|
65339
|
+
child.unref();
|
|
65340
|
+
if (logFd !== null) {
|
|
65341
|
+
try {
|
|
65342
|
+
fs38.closeSync(logFd);
|
|
65343
|
+
} catch {
|
|
65344
|
+
}
|
|
65345
|
+
}
|
|
65346
|
+
}
|
|
65347
|
+
function stopManagedSessionHostProcess() {
|
|
65348
|
+
let stopped = false;
|
|
65349
|
+
const pidFile = getPidFile();
|
|
65350
|
+
try {
|
|
65351
|
+
if (fs38.existsSync(pidFile)) {
|
|
65352
|
+
const pid = Number.parseInt(fs38.readFileSync(pidFile, "utf8").trim(), 10);
|
|
65353
|
+
if (Number.isFinite(pid) && pid !== process.pid && isManagedPid(pid)) {
|
|
65354
|
+
stopped = killPid2(pid) || stopped;
|
|
65355
|
+
}
|
|
65356
|
+
}
|
|
65357
|
+
} catch {
|
|
65358
|
+
} finally {
|
|
65359
|
+
try {
|
|
65360
|
+
fs38.unlinkSync(pidFile);
|
|
65361
|
+
} catch {
|
|
65362
|
+
}
|
|
65363
|
+
}
|
|
65364
|
+
if (options.extraStop) {
|
|
65365
|
+
stopped = options.extraStop(endpoint) || stopped;
|
|
65366
|
+
}
|
|
65367
|
+
return stopped;
|
|
65368
|
+
}
|
|
65369
|
+
async function ensureReady() {
|
|
65370
|
+
options.beforeEnsureReady?.();
|
|
65371
|
+
try {
|
|
65372
|
+
return await ensureSessionHostReady({
|
|
65373
|
+
appName,
|
|
65374
|
+
spawnHost,
|
|
65375
|
+
timeoutMs,
|
|
65376
|
+
requiredRequestTypes: options.requiredRequestTypes
|
|
65377
|
+
});
|
|
65378
|
+
} catch (error) {
|
|
65379
|
+
stopManagedSessionHostProcess();
|
|
65380
|
+
return ensureSessionHostReady({
|
|
65381
|
+
appName,
|
|
65382
|
+
spawnHost,
|
|
65383
|
+
timeoutMs,
|
|
65384
|
+
requiredRequestTypes: options.requiredRequestTypes
|
|
65385
|
+
}).catch((retryError) => {
|
|
65386
|
+
const initialMessage = error instanceof Error ? error.message : String(error);
|
|
65387
|
+
const retryMessage = retryError instanceof Error ? retryError.message : String(retryError);
|
|
65388
|
+
throw new Error(`Session host failed to start after retry (${initialMessage}; retry: ${retryMessage})`);
|
|
65389
|
+
});
|
|
65390
|
+
}
|
|
65391
|
+
}
|
|
65392
|
+
return {
|
|
65393
|
+
appName,
|
|
65394
|
+
endpoint,
|
|
65395
|
+
getPidFile,
|
|
65396
|
+
getPid,
|
|
65397
|
+
buildEnv,
|
|
65398
|
+
resolveEntry,
|
|
65399
|
+
killPid: killPid2,
|
|
65400
|
+
spawnHost,
|
|
65401
|
+
stopManagedSessionHostProcess,
|
|
65402
|
+
ensureReady,
|
|
65403
|
+
getStatusPaths() {
|
|
65404
|
+
return { pidFile: getPidFile(), endpoint };
|
|
65405
|
+
}
|
|
65406
|
+
};
|
|
65407
|
+
}
|
|
65408
|
+
|
|
65225
65409
|
// src/session-host/startup-restore-policy.js
|
|
65226
65410
|
function shouldAutoRestoreHostedSessionsOnStartup(env = process.env) {
|
|
65227
65411
|
const raw = typeof env.ADHDEV_RESTORE_HOSTED_SESSIONS_ON_STARTUP === "string" ? env.ADHDEV_RESTORE_HOSTED_SESSIONS_ON_STARTUP.trim().toLowerCase() : "";
|
|
@@ -65359,12 +65543,12 @@ async function installExtension(ide, extension) {
|
|
|
65359
65543
|
const res = await fetch(extension.vsixUrl);
|
|
65360
65544
|
if (res.ok) {
|
|
65361
65545
|
const buffer = Buffer.from(await res.arrayBuffer());
|
|
65362
|
-
const
|
|
65363
|
-
|
|
65364
|
-
return new Promise((
|
|
65546
|
+
const fs39 = await import("fs");
|
|
65547
|
+
fs39.writeFileSync(vsixPath, buffer);
|
|
65548
|
+
return new Promise((resolve25) => {
|
|
65365
65549
|
const cmd = `"${ide.cliCommand}" --install-extension "${vsixPath}" --force`;
|
|
65366
65550
|
exec6(cmd, { timeout: 6e4 }, (error, _stdout, stderr) => {
|
|
65367
|
-
|
|
65551
|
+
resolve25({
|
|
65368
65552
|
extensionId: extension.id,
|
|
65369
65553
|
marketplaceId: extension.marketplaceId,
|
|
65370
65554
|
success: !error,
|
|
@@ -65377,11 +65561,11 @@ async function installExtension(ide, extension) {
|
|
|
65377
65561
|
} catch (e) {
|
|
65378
65562
|
}
|
|
65379
65563
|
}
|
|
65380
|
-
return new Promise((
|
|
65564
|
+
return new Promise((resolve25) => {
|
|
65381
65565
|
const cmd = `"${ide.cliCommand}" --install-extension ${extension.marketplaceId} --force`;
|
|
65382
65566
|
exec6(cmd, { timeout: 6e4 }, (error, stdout, stderr) => {
|
|
65383
65567
|
if (error) {
|
|
65384
|
-
|
|
65568
|
+
resolve25({
|
|
65385
65569
|
extensionId: extension.id,
|
|
65386
65570
|
marketplaceId: extension.marketplaceId,
|
|
65387
65571
|
success: false,
|
|
@@ -65389,7 +65573,7 @@ async function installExtension(ide, extension) {
|
|
|
65389
65573
|
error: stderr || error.message
|
|
65390
65574
|
});
|
|
65391
65575
|
} else {
|
|
65392
|
-
|
|
65576
|
+
resolve25({
|
|
65393
65577
|
extensionId: extension.id,
|
|
65394
65578
|
marketplaceId: extension.marketplaceId,
|
|
65395
65579
|
success: true,
|
|
@@ -65878,7 +66062,7 @@ async function startLocalIpcServer(opts) {
|
|
|
65878
66062
|
}));
|
|
65879
66063
|
}
|
|
65880
66064
|
}
|
|
65881
|
-
await new Promise((
|
|
66065
|
+
await new Promise((resolve25, reject) => {
|
|
65882
66066
|
const onError = (error) => {
|
|
65883
66067
|
httpServer?.off("listening", onListening);
|
|
65884
66068
|
reject(error);
|
|
@@ -65886,7 +66070,7 @@ async function startLocalIpcServer(opts) {
|
|
|
65886
66070
|
const onListening = () => {
|
|
65887
66071
|
httpServer?.off("error", onError);
|
|
65888
66072
|
listening = true;
|
|
65889
|
-
|
|
66073
|
+
resolve25();
|
|
65890
66074
|
};
|
|
65891
66075
|
httpServer.once("error", onError);
|
|
65892
66076
|
httpServer.once("listening", onListening);
|
|
@@ -65913,12 +66097,12 @@ async function startLocalIpcServer(opts) {
|
|
|
65913
66097
|
}
|
|
65914
66098
|
}
|
|
65915
66099
|
clients.clear();
|
|
65916
|
-
await new Promise((
|
|
66100
|
+
await new Promise((resolve25) => {
|
|
65917
66101
|
if (!httpServer) {
|
|
65918
|
-
|
|
66102
|
+
resolve25();
|
|
65919
66103
|
return;
|
|
65920
66104
|
}
|
|
65921
|
-
httpServer.close(() =>
|
|
66105
|
+
httpServer.close(() => resolve25());
|
|
65922
66106
|
});
|
|
65923
66107
|
httpServer = null;
|
|
65924
66108
|
wss = null;
|
|
@@ -65939,12 +66123,12 @@ init_parse_session();
|
|
|
65939
66123
|
|
|
65940
66124
|
// src/providers/sdk/v1/fixture-tooling/replay.ts
|
|
65941
66125
|
init_provider_cli_shared();
|
|
65942
|
-
import { readFileSync as
|
|
65943
|
-
import { dirname as dirname15, resolve as
|
|
66126
|
+
import { readFileSync as readFileSync40 } from "fs";
|
|
66127
|
+
import { dirname as dirname15, resolve as resolve23 } from "path";
|
|
65944
66128
|
|
|
65945
66129
|
// src/providers/sdk/v1/validators/taint.ts
|
|
65946
|
-
import { readFileSync as
|
|
65947
|
-
import { resolve as
|
|
66130
|
+
import { readFileSync as readFileSync41, existsSync as existsSync53 } from "fs";
|
|
66131
|
+
import { resolve as resolve24, dirname as dirname16, join as join49 } from "path";
|
|
65948
66132
|
|
|
65949
66133
|
// src/providers/sdk/v1/validators/index.ts
|
|
65950
66134
|
init_manifest();
|
|
@@ -66169,6 +66353,7 @@ export {
|
|
|
66169
66353
|
createGitSnapshotStore,
|
|
66170
66354
|
createGitWorkspaceMonitor,
|
|
66171
66355
|
createInteractionId,
|
|
66356
|
+
createManagedSessionHost,
|
|
66172
66357
|
createMesh,
|
|
66173
66358
|
createNativeHistoryDispatcher,
|
|
66174
66359
|
createSessionDelivery,
|