@adhdev/daemon-core 0.9.73 → 0.9.75
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/cli-adapters/provider-cli-adapter.d.ts +1 -0
- package/dist/commands/router.d.ts +4 -0
- package/dist/config/config.d.ts +3 -0
- package/dist/index.js +56 -18
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +56 -18
- package/dist/index.mjs.map +1 -1
- package/node_modules/@adhdev/session-host-core/package.json +1 -1
- package/package.json +1 -1
- package/src/cli-adapters/provider-cli-adapter.ts +17 -4
- package/src/commands/mesh-coordinator.ts +5 -0
- package/src/commands/router.ts +52 -16
- package/src/config/config.ts +6 -0
package/dist/index.mjs
CHANGED
|
@@ -128,6 +128,7 @@ function normalizeConfig(raw) {
|
|
|
128
128
|
ideSettings: isPlainObject(parsed.ideSettings) ? parsed.ideSettings : {},
|
|
129
129
|
providerSourceMode: resolveProviderSourceMode(parsed.providerSourceMode, parsed.disableUpstream),
|
|
130
130
|
providerDir: asOptionalString(parsed.providerDir),
|
|
131
|
+
updateChannel: parsed.updateChannel === "preview" ? "preview" : "stable",
|
|
131
132
|
terminalSizingMode: parsed.terminalSizingMode === "fit" ? "fit" : "measured"
|
|
132
133
|
};
|
|
133
134
|
}
|
|
@@ -273,6 +274,7 @@ var init_config = __esm({
|
|
|
273
274
|
machineProviders: {},
|
|
274
275
|
ideSettings: {},
|
|
275
276
|
providerSourceMode: "normal",
|
|
277
|
+
updateChannel: "stable",
|
|
276
278
|
terminalSizingMode: "measured"
|
|
277
279
|
};
|
|
278
280
|
MACHINE_ID_PREFIX = "mach_";
|
|
@@ -1754,6 +1756,13 @@ var init_provider_cli_adapter = __esm({
|
|
|
1754
1756
|
this.lastScreenSnapshotReadAt = now;
|
|
1755
1757
|
return screenText;
|
|
1756
1758
|
}
|
|
1759
|
+
getParseScreenText(screenText) {
|
|
1760
|
+
const currentSnapshot = normalizeScreenSnapshot(screenText);
|
|
1761
|
+
const lastSnapshot = this.lastScreenSnapshot;
|
|
1762
|
+
if (!lastSnapshot || lastSnapshot === currentSnapshot) return screenText;
|
|
1763
|
+
return `${screenText}
|
|
1764
|
+
${lastSnapshot}`;
|
|
1765
|
+
}
|
|
1757
1766
|
shouldReadTerminalScreenSnapshot(now) {
|
|
1758
1767
|
if (!this.lastScreenText) return true;
|
|
1759
1768
|
return now - this.lastScreenSnapshotReadAt >= _ProviderCliAdapter.SCREEN_SNAPSHOT_MIN_INTERVAL_MS;
|
|
@@ -2744,12 +2753,13 @@ var init_provider_cli_adapter = __esm({
|
|
|
2744
2753
|
}
|
|
2745
2754
|
try {
|
|
2746
2755
|
const screenText = this.terminalScreen.getText();
|
|
2756
|
+
const parseScreenText = this.getParseScreenText(screenText);
|
|
2747
2757
|
const tail = this.recentOutputBuffer.slice(-500);
|
|
2748
2758
|
const input = buildCliParseInput({
|
|
2749
2759
|
accumulatedBuffer: this.accumulatedBuffer,
|
|
2750
2760
|
accumulatedRawBuffer: this.accumulatedRawBuffer,
|
|
2751
2761
|
recentOutputBuffer: this.recentOutputBuffer,
|
|
2752
|
-
terminalScreenText:
|
|
2762
|
+
terminalScreenText: parseScreenText,
|
|
2753
2763
|
baseMessages: [],
|
|
2754
2764
|
partialResponse: this.responseBuffer,
|
|
2755
2765
|
isWaitingForResponse: this.isWaitingForResponse,
|
|
@@ -2843,8 +2853,9 @@ var init_provider_cli_adapter = __esm({
|
|
|
2843
2853
|
*/
|
|
2844
2854
|
getScriptParsedStatus() {
|
|
2845
2855
|
const screenText = this.readTerminalScreenText();
|
|
2856
|
+
const parseScreenText = this.getParseScreenText(screenText);
|
|
2846
2857
|
const cached = this.parsedStatusCache;
|
|
2847
|
-
if (cached && cached.responseBuffer === this.responseBuffer && cached.currentTurnScope === this.currentTurnScope && cached.recentOutputBuffer === this.recentOutputBuffer && cached.accumulatedBuffer === this.accumulatedBuffer && cached.screenText ===
|
|
2858
|
+
if (cached && cached.responseBuffer === this.responseBuffer && cached.currentTurnScope === this.currentTurnScope && cached.recentOutputBuffer === this.recentOutputBuffer && cached.accumulatedBuffer === this.accumulatedBuffer && cached.screenText === parseScreenText && cached.currentStatus === this.currentStatus && cached.activeModal === this.activeModal && cached.cliName === this.cliName) {
|
|
2848
2859
|
return cached.result;
|
|
2849
2860
|
}
|
|
2850
2861
|
const parsed = this.runParseSession();
|
|
@@ -2872,7 +2883,7 @@ var init_provider_cli_adapter = __esm({
|
|
|
2872
2883
|
currentTurnScope: this.currentTurnScope,
|
|
2873
2884
|
recentOutputBuffer: this.recentOutputBuffer,
|
|
2874
2885
|
accumulatedBuffer: this.accumulatedBuffer,
|
|
2875
|
-
screenText,
|
|
2886
|
+
screenText: parseScreenText,
|
|
2876
2887
|
currentStatus: this.currentStatus,
|
|
2877
2888
|
activeModal: this.activeModal,
|
|
2878
2889
|
cliName: this.cliName,
|
|
@@ -2889,7 +2900,7 @@ var init_provider_cli_adapter = __esm({
|
|
|
2889
2900
|
accumulatedBuffer: this.accumulatedBuffer,
|
|
2890
2901
|
accumulatedRawBuffer: this.accumulatedRawBuffer,
|
|
2891
2902
|
recentOutputBuffer: this.recentOutputBuffer,
|
|
2892
|
-
terminalScreenText: this.terminalScreen.getText(),
|
|
2903
|
+
terminalScreenText: this.getParseScreenText(this.terminalScreen.getText()),
|
|
2893
2904
|
baseMessages: [],
|
|
2894
2905
|
partialResponse: this.responseBuffer,
|
|
2895
2906
|
isWaitingForResponse: this.isWaitingForResponse,
|
|
@@ -19905,6 +19916,8 @@ function resolveAdhdevMcpEntryPath(explicitPath) {
|
|
|
19905
19916
|
addCandidate(resolve13(dir, "../vendor/mcp-server/index.js"));
|
|
19906
19917
|
addCandidate(resolve13(dir, "../../vendor/mcp-server/index.js"));
|
|
19907
19918
|
addCandidate(resolve13(dir, "../../../vendor/mcp-server/index.js"));
|
|
19919
|
+
addCandidate(resolve13(dir, "../../mcp-server/dist/index.js"));
|
|
19920
|
+
addCandidate(resolve13(dir, "../../../mcp-server/dist/index.js"));
|
|
19908
19921
|
};
|
|
19909
19922
|
addPackagedCandidates(process.argv[1]);
|
|
19910
19923
|
for (const candidate of candidates) {
|
|
@@ -20582,6 +20595,17 @@ async function maybeRunDaemonUpgradeHelperFromEnv() {
|
|
|
20582
20595
|
|
|
20583
20596
|
// src/commands/router.ts
|
|
20584
20597
|
import * as fs10 from "fs";
|
|
20598
|
+
var CHANNEL_NPM_TAG = { stable: "latest", preview: "next" };
|
|
20599
|
+
function normalizeReleaseChannel(value) {
|
|
20600
|
+
if (typeof value !== "string") return null;
|
|
20601
|
+
const normalized = value.trim().toLowerCase();
|
|
20602
|
+
if (normalized === "stable" || normalized === "latest") return "stable";
|
|
20603
|
+
if (normalized === "preview" || normalized === "next") return "preview";
|
|
20604
|
+
return null;
|
|
20605
|
+
}
|
|
20606
|
+
function resolveUpgradeChannel(args) {
|
|
20607
|
+
return normalizeReleaseChannel(args?.channel) || normalizeReleaseChannel(args?.updatePolicy?.channel) || normalizeReleaseChannel(args?.npmTag) || normalizeReleaseChannel(loadConfig().updateChannel) || "stable";
|
|
20608
|
+
}
|
|
20585
20609
|
var CHAT_COMMANDS = [
|
|
20586
20610
|
"send_chat",
|
|
20587
20611
|
"new_chat",
|
|
@@ -20673,6 +20697,10 @@ function summarizeSessionHostPruneResult(result) {
|
|
|
20673
20697
|
}
|
|
20674
20698
|
var DaemonCommandRouter = class {
|
|
20675
20699
|
deps;
|
|
20700
|
+
/** In-memory cache for cloud-originating meshes passed via inlineMesh.
|
|
20701
|
+
* Allows the MCP server to query mesh data via get_mesh even when
|
|
20702
|
+
* the mesh doesn't exist in the local meshes.json file. */
|
|
20703
|
+
inlineMeshCache = /* @__PURE__ */ new Map();
|
|
20676
20704
|
constructor(deps) {
|
|
20677
20705
|
this.deps = deps;
|
|
20678
20706
|
}
|
|
@@ -21260,8 +21288,10 @@ var DaemonCommandRouter = class {
|
|
|
21260
21288
|
const isStandalone = this.deps.packageName === "@adhdev/daemon-standalone" || process.argv[1]?.includes("daemon-standalone");
|
|
21261
21289
|
const pkgName = isStandalone ? "@adhdev/daemon-standalone" : "adhdev";
|
|
21262
21290
|
const npmSurface = resolveCurrentGlobalInstallSurface({ packageName: pkgName });
|
|
21263
|
-
const
|
|
21264
|
-
|
|
21291
|
+
const channel = resolveUpgradeChannel(args);
|
|
21292
|
+
const npmTag = CHANNEL_NPM_TAG[channel];
|
|
21293
|
+
const latest = String(execNpmCommandSync(["view", `${pkgName}@${npmTag}`, "version"], { encoding: "utf-8", timeout: 1e4 }, npmSurface)).trim();
|
|
21294
|
+
LOG.info("Upgrade", `Latest ${pkgName}@${npmTag}: v${latest}`);
|
|
21265
21295
|
let currentInstalled = null;
|
|
21266
21296
|
try {
|
|
21267
21297
|
const currentJson = String(execNpmCommandSync(["ls", "-g", pkgName, "--depth=0", "--json"], {
|
|
@@ -21275,8 +21305,8 @@ var DaemonCommandRouter = class {
|
|
|
21275
21305
|
}
|
|
21276
21306
|
const runningVersion = typeof this.deps.statusVersion === "string" ? this.deps.statusVersion.trim().replace(/^v/, "") : null;
|
|
21277
21307
|
if (currentInstalled === latest && runningVersion === latest) {
|
|
21278
|
-
LOG.info("Upgrade", `Already on
|
|
21279
|
-
return { success: true, upgraded: false, alreadyLatest: true, version: latest };
|
|
21308
|
+
LOG.info("Upgrade", `Already on ${channel} channel version v${latest}; skipping install`);
|
|
21309
|
+
return { success: true, upgraded: false, alreadyLatest: true, version: latest, channel, npmTag };
|
|
21280
21310
|
}
|
|
21281
21311
|
if (currentInstalled === latest && runningVersion && runningVersion !== latest) {
|
|
21282
21312
|
LOG.info("Upgrade", `Installed package is v${latest}, but running daemon is v${runningVersion}; scheduling restart`);
|
|
@@ -21289,12 +21319,12 @@ var DaemonCommandRouter = class {
|
|
|
21289
21319
|
cwd: process.cwd(),
|
|
21290
21320
|
sessionHostAppName: process.env.ADHDEV_SESSION_HOST_NAME || "adhdev"
|
|
21291
21321
|
});
|
|
21292
|
-
LOG.info("Upgrade", `Scheduled detached upgrade to v${latest}`);
|
|
21322
|
+
LOG.info("Upgrade", `Scheduled detached ${channel} upgrade to v${latest}`);
|
|
21293
21323
|
setTimeout(() => {
|
|
21294
21324
|
LOG.info("Upgrade", "Exiting daemon so detached upgrader can continue...");
|
|
21295
21325
|
process.exit(0);
|
|
21296
21326
|
}, 3e3);
|
|
21297
|
-
return { success: true, upgraded: true, version: latest, restarting: true };
|
|
21327
|
+
return { success: true, upgraded: true, version: latest, restarting: true, channel, npmTag };
|
|
21298
21328
|
} catch (e) {
|
|
21299
21329
|
LOG.error("Upgrade", `Failed: ${e.message}`);
|
|
21300
21330
|
return { success: false, error: e.message };
|
|
@@ -21321,11 +21351,12 @@ var DaemonCommandRouter = class {
|
|
|
21321
21351
|
try {
|
|
21322
21352
|
const { getMesh: getMesh3 } = await Promise.resolve().then(() => (init_mesh_config(), mesh_config_exports));
|
|
21323
21353
|
const mesh = getMesh3(meshId);
|
|
21324
|
-
if (
|
|
21325
|
-
|
|
21326
|
-
} catch (e) {
|
|
21327
|
-
return { success: false, error: e.message };
|
|
21354
|
+
if (mesh) return { success: true, mesh };
|
|
21355
|
+
} catch {
|
|
21328
21356
|
}
|
|
21357
|
+
const cached = this.inlineMeshCache.get(meshId);
|
|
21358
|
+
if (cached) return { success: true, mesh: cached };
|
|
21359
|
+
return { success: false, error: "Mesh not found" };
|
|
21329
21360
|
}
|
|
21330
21361
|
case "create_mesh": {
|
|
21331
21362
|
const name = typeof args?.name === "string" ? args.name.trim() : "";
|
|
@@ -21388,6 +21419,7 @@ var DaemonCommandRouter = class {
|
|
|
21388
21419
|
let mesh;
|
|
21389
21420
|
if (args?.inlineMesh && typeof args.inlineMesh === "object") {
|
|
21390
21421
|
mesh = args.inlineMesh;
|
|
21422
|
+
this.inlineMeshCache.set(meshId, mesh);
|
|
21391
21423
|
} else {
|
|
21392
21424
|
const { getMesh: getMesh3 } = await Promise.resolve().then(() => (init_mesh_config(), mesh_config_exports));
|
|
21393
21425
|
mesh = getMesh3(meshId);
|
|
@@ -21456,14 +21488,20 @@ var DaemonCommandRouter = class {
|
|
|
21456
21488
|
} catch {
|
|
21457
21489
|
}
|
|
21458
21490
|
}
|
|
21491
|
+
const mcpServerEntry = {
|
|
21492
|
+
command: coordinatorSetup.mcpServer.command,
|
|
21493
|
+
args: coordinatorSetup.mcpServer.args
|
|
21494
|
+
};
|
|
21495
|
+
if (args?.inlineMesh) {
|
|
21496
|
+
mcpServerEntry.env = {
|
|
21497
|
+
ADHDEV_INLINE_MESH: JSON.stringify(mesh)
|
|
21498
|
+
};
|
|
21499
|
+
}
|
|
21459
21500
|
const mcpConfig = {
|
|
21460
21501
|
...existingMcpConfig,
|
|
21461
21502
|
mcpServers: {
|
|
21462
21503
|
...existingMcpConfig.mcpServers || {},
|
|
21463
|
-
[coordinatorSetup.serverName]:
|
|
21464
|
-
command: coordinatorSetup.mcpServer.command,
|
|
21465
|
-
args: coordinatorSetup.mcpServer.args
|
|
21466
|
-
}
|
|
21504
|
+
[coordinatorSetup.serverName]: mcpServerEntry
|
|
21467
21505
|
}
|
|
21468
21506
|
};
|
|
21469
21507
|
writeFileSync12(mcpConfigPath, JSON.stringify(mcpConfig, null, 2), "utf-8");
|