@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
|
@@ -106,6 +106,7 @@ export declare class ProviderCliAdapter implements CliAdapter {
|
|
|
106
106
|
private getBufferState;
|
|
107
107
|
private recordBoundedAppendDrop;
|
|
108
108
|
private readTerminalScreenText;
|
|
109
|
+
private getParseScreenText;
|
|
109
110
|
private shouldReadTerminalScreenSnapshot;
|
|
110
111
|
private resetTerminalScreen;
|
|
111
112
|
private getFreshParsedStatusCache;
|
|
@@ -76,6 +76,10 @@ export interface CommandRouterResult {
|
|
|
76
76
|
}
|
|
77
77
|
export declare class DaemonCommandRouter {
|
|
78
78
|
private deps;
|
|
79
|
+
/** In-memory cache for cloud-originating meshes passed via inlineMesh.
|
|
80
|
+
* Allows the MCP server to query mesh data via get_mesh even when
|
|
81
|
+
* the mesh doesn't exist in the local meshes.json file. */
|
|
82
|
+
private inlineMeshCache;
|
|
79
83
|
constructor(deps: CommandRouterDeps);
|
|
80
84
|
private traceSessionHostAction;
|
|
81
85
|
/**
|
package/dist/config/config.d.ts
CHANGED
|
@@ -9,6 +9,7 @@ export type { RecentActivityEntry } from './recent-activity.js';
|
|
|
9
9
|
export type { SavedProviderSessionEntry } from './saved-sessions.js';
|
|
10
10
|
export type { DaemonState } from './state-store.js';
|
|
11
11
|
export type ProviderSourceMode = 'normal' | 'no-upstream';
|
|
12
|
+
export type ReleaseChannel = 'stable' | 'preview';
|
|
12
13
|
export declare function resolveProviderSourceMode(providerSourceMode: unknown, legacyDisableUpstream: unknown): ProviderSourceMode;
|
|
13
14
|
export interface MachineProviderCheckResult {
|
|
14
15
|
ok: boolean;
|
|
@@ -70,6 +71,8 @@ export interface ADHDevConfig {
|
|
|
70
71
|
disableUpstream?: boolean;
|
|
71
72
|
providerSourceMode?: ProviderSourceMode;
|
|
72
73
|
providerDir?: string;
|
|
74
|
+
/** Preferred daemon update channel. Defaults to stable/latest. */
|
|
75
|
+
updateChannel?: ReleaseChannel;
|
|
73
76
|
/**
|
|
74
77
|
* Browser terminal sizing behavior for dashboard CLI panes.
|
|
75
78
|
* Default `measured` keeps terminal size daemon-authoritative.
|
package/dist/index.js
CHANGED
|
@@ -129,6 +129,7 @@ function normalizeConfig(raw) {
|
|
|
129
129
|
ideSettings: isPlainObject(parsed.ideSettings) ? parsed.ideSettings : {},
|
|
130
130
|
providerSourceMode: resolveProviderSourceMode(parsed.providerSourceMode, parsed.disableUpstream),
|
|
131
131
|
providerDir: asOptionalString(parsed.providerDir),
|
|
132
|
+
updateChannel: parsed.updateChannel === "preview" ? "preview" : "stable",
|
|
132
133
|
terminalSizingMode: parsed.terminalSizingMode === "fit" ? "fit" : "measured"
|
|
133
134
|
};
|
|
134
135
|
}
|
|
@@ -278,6 +279,7 @@ var init_config = __esm({
|
|
|
278
279
|
machineProviders: {},
|
|
279
280
|
ideSettings: {},
|
|
280
281
|
providerSourceMode: "normal",
|
|
282
|
+
updateChannel: "stable",
|
|
281
283
|
terminalSizingMode: "measured"
|
|
282
284
|
};
|
|
283
285
|
MACHINE_ID_PREFIX = "mach_";
|
|
@@ -1758,6 +1760,13 @@ var init_provider_cli_adapter = __esm({
|
|
|
1758
1760
|
this.lastScreenSnapshotReadAt = now;
|
|
1759
1761
|
return screenText;
|
|
1760
1762
|
}
|
|
1763
|
+
getParseScreenText(screenText) {
|
|
1764
|
+
const currentSnapshot = normalizeScreenSnapshot(screenText);
|
|
1765
|
+
const lastSnapshot = this.lastScreenSnapshot;
|
|
1766
|
+
if (!lastSnapshot || lastSnapshot === currentSnapshot) return screenText;
|
|
1767
|
+
return `${screenText}
|
|
1768
|
+
${lastSnapshot}`;
|
|
1769
|
+
}
|
|
1761
1770
|
shouldReadTerminalScreenSnapshot(now) {
|
|
1762
1771
|
if (!this.lastScreenText) return true;
|
|
1763
1772
|
return now - this.lastScreenSnapshotReadAt >= _ProviderCliAdapter.SCREEN_SNAPSHOT_MIN_INTERVAL_MS;
|
|
@@ -2748,12 +2757,13 @@ var init_provider_cli_adapter = __esm({
|
|
|
2748
2757
|
}
|
|
2749
2758
|
try {
|
|
2750
2759
|
const screenText = this.terminalScreen.getText();
|
|
2760
|
+
const parseScreenText = this.getParseScreenText(screenText);
|
|
2751
2761
|
const tail = this.recentOutputBuffer.slice(-500);
|
|
2752
2762
|
const input = buildCliParseInput({
|
|
2753
2763
|
accumulatedBuffer: this.accumulatedBuffer,
|
|
2754
2764
|
accumulatedRawBuffer: this.accumulatedRawBuffer,
|
|
2755
2765
|
recentOutputBuffer: this.recentOutputBuffer,
|
|
2756
|
-
terminalScreenText:
|
|
2766
|
+
terminalScreenText: parseScreenText,
|
|
2757
2767
|
baseMessages: [],
|
|
2758
2768
|
partialResponse: this.responseBuffer,
|
|
2759
2769
|
isWaitingForResponse: this.isWaitingForResponse,
|
|
@@ -2847,8 +2857,9 @@ var init_provider_cli_adapter = __esm({
|
|
|
2847
2857
|
*/
|
|
2848
2858
|
getScriptParsedStatus() {
|
|
2849
2859
|
const screenText = this.readTerminalScreenText();
|
|
2860
|
+
const parseScreenText = this.getParseScreenText(screenText);
|
|
2850
2861
|
const cached = this.parsedStatusCache;
|
|
2851
|
-
if (cached && cached.responseBuffer === this.responseBuffer && cached.currentTurnScope === this.currentTurnScope && cached.recentOutputBuffer === this.recentOutputBuffer && cached.accumulatedBuffer === this.accumulatedBuffer && cached.screenText ===
|
|
2862
|
+
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) {
|
|
2852
2863
|
return cached.result;
|
|
2853
2864
|
}
|
|
2854
2865
|
const parsed = this.runParseSession();
|
|
@@ -2876,7 +2887,7 @@ var init_provider_cli_adapter = __esm({
|
|
|
2876
2887
|
currentTurnScope: this.currentTurnScope,
|
|
2877
2888
|
recentOutputBuffer: this.recentOutputBuffer,
|
|
2878
2889
|
accumulatedBuffer: this.accumulatedBuffer,
|
|
2879
|
-
screenText,
|
|
2890
|
+
screenText: parseScreenText,
|
|
2880
2891
|
currentStatus: this.currentStatus,
|
|
2881
2892
|
activeModal: this.activeModal,
|
|
2882
2893
|
cliName: this.cliName,
|
|
@@ -2893,7 +2904,7 @@ var init_provider_cli_adapter = __esm({
|
|
|
2893
2904
|
accumulatedBuffer: this.accumulatedBuffer,
|
|
2894
2905
|
accumulatedRawBuffer: this.accumulatedRawBuffer,
|
|
2895
2906
|
recentOutputBuffer: this.recentOutputBuffer,
|
|
2896
|
-
terminalScreenText: this.terminalScreen.getText(),
|
|
2907
|
+
terminalScreenText: this.getParseScreenText(this.terminalScreen.getText()),
|
|
2897
2908
|
baseMessages: [],
|
|
2898
2909
|
partialResponse: this.responseBuffer,
|
|
2899
2910
|
isWaitingForResponse: this.isWaitingForResponse,
|
|
@@ -20092,6 +20103,8 @@ function resolveAdhdevMcpEntryPath(explicitPath) {
|
|
|
20092
20103
|
addCandidate((0, import_node_path.resolve)(dir, "../vendor/mcp-server/index.js"));
|
|
20093
20104
|
addCandidate((0, import_node_path.resolve)(dir, "../../vendor/mcp-server/index.js"));
|
|
20094
20105
|
addCandidate((0, import_node_path.resolve)(dir, "../../../vendor/mcp-server/index.js"));
|
|
20106
|
+
addCandidate((0, import_node_path.resolve)(dir, "../../mcp-server/dist/index.js"));
|
|
20107
|
+
addCandidate((0, import_node_path.resolve)(dir, "../../../mcp-server/dist/index.js"));
|
|
20095
20108
|
};
|
|
20096
20109
|
addPackagedCandidates(process.argv[1]);
|
|
20097
20110
|
for (const candidate of candidates) {
|
|
@@ -20769,6 +20782,17 @@ async function maybeRunDaemonUpgradeHelperFromEnv() {
|
|
|
20769
20782
|
|
|
20770
20783
|
// src/commands/router.ts
|
|
20771
20784
|
var fs10 = __toESM(require("fs"));
|
|
20785
|
+
var CHANNEL_NPM_TAG = { stable: "latest", preview: "next" };
|
|
20786
|
+
function normalizeReleaseChannel(value) {
|
|
20787
|
+
if (typeof value !== "string") return null;
|
|
20788
|
+
const normalized = value.trim().toLowerCase();
|
|
20789
|
+
if (normalized === "stable" || normalized === "latest") return "stable";
|
|
20790
|
+
if (normalized === "preview" || normalized === "next") return "preview";
|
|
20791
|
+
return null;
|
|
20792
|
+
}
|
|
20793
|
+
function resolveUpgradeChannel(args) {
|
|
20794
|
+
return normalizeReleaseChannel(args?.channel) || normalizeReleaseChannel(args?.updatePolicy?.channel) || normalizeReleaseChannel(args?.npmTag) || normalizeReleaseChannel(loadConfig().updateChannel) || "stable";
|
|
20795
|
+
}
|
|
20772
20796
|
var CHAT_COMMANDS = [
|
|
20773
20797
|
"send_chat",
|
|
20774
20798
|
"new_chat",
|
|
@@ -20860,6 +20884,10 @@ function summarizeSessionHostPruneResult(result) {
|
|
|
20860
20884
|
}
|
|
20861
20885
|
var DaemonCommandRouter = class {
|
|
20862
20886
|
deps;
|
|
20887
|
+
/** In-memory cache for cloud-originating meshes passed via inlineMesh.
|
|
20888
|
+
* Allows the MCP server to query mesh data via get_mesh even when
|
|
20889
|
+
* the mesh doesn't exist in the local meshes.json file. */
|
|
20890
|
+
inlineMeshCache = /* @__PURE__ */ new Map();
|
|
20863
20891
|
constructor(deps) {
|
|
20864
20892
|
this.deps = deps;
|
|
20865
20893
|
}
|
|
@@ -21447,8 +21475,10 @@ var DaemonCommandRouter = class {
|
|
|
21447
21475
|
const isStandalone = this.deps.packageName === "@adhdev/daemon-standalone" || process.argv[1]?.includes("daemon-standalone");
|
|
21448
21476
|
const pkgName = isStandalone ? "@adhdev/daemon-standalone" : "adhdev";
|
|
21449
21477
|
const npmSurface = resolveCurrentGlobalInstallSurface({ packageName: pkgName });
|
|
21450
|
-
const
|
|
21451
|
-
|
|
21478
|
+
const channel = resolveUpgradeChannel(args);
|
|
21479
|
+
const npmTag = CHANNEL_NPM_TAG[channel];
|
|
21480
|
+
const latest = String(execNpmCommandSync(["view", `${pkgName}@${npmTag}`, "version"], { encoding: "utf-8", timeout: 1e4 }, npmSurface)).trim();
|
|
21481
|
+
LOG.info("Upgrade", `Latest ${pkgName}@${npmTag}: v${latest}`);
|
|
21452
21482
|
let currentInstalled = null;
|
|
21453
21483
|
try {
|
|
21454
21484
|
const currentJson = String(execNpmCommandSync(["ls", "-g", pkgName, "--depth=0", "--json"], {
|
|
@@ -21462,8 +21492,8 @@ var DaemonCommandRouter = class {
|
|
|
21462
21492
|
}
|
|
21463
21493
|
const runningVersion = typeof this.deps.statusVersion === "string" ? this.deps.statusVersion.trim().replace(/^v/, "") : null;
|
|
21464
21494
|
if (currentInstalled === latest && runningVersion === latest) {
|
|
21465
|
-
LOG.info("Upgrade", `Already on
|
|
21466
|
-
return { success: true, upgraded: false, alreadyLatest: true, version: latest };
|
|
21495
|
+
LOG.info("Upgrade", `Already on ${channel} channel version v${latest}; skipping install`);
|
|
21496
|
+
return { success: true, upgraded: false, alreadyLatest: true, version: latest, channel, npmTag };
|
|
21467
21497
|
}
|
|
21468
21498
|
if (currentInstalled === latest && runningVersion && runningVersion !== latest) {
|
|
21469
21499
|
LOG.info("Upgrade", `Installed package is v${latest}, but running daemon is v${runningVersion}; scheduling restart`);
|
|
@@ -21476,12 +21506,12 @@ var DaemonCommandRouter = class {
|
|
|
21476
21506
|
cwd: process.cwd(),
|
|
21477
21507
|
sessionHostAppName: process.env.ADHDEV_SESSION_HOST_NAME || "adhdev"
|
|
21478
21508
|
});
|
|
21479
|
-
LOG.info("Upgrade", `Scheduled detached upgrade to v${latest}`);
|
|
21509
|
+
LOG.info("Upgrade", `Scheduled detached ${channel} upgrade to v${latest}`);
|
|
21480
21510
|
setTimeout(() => {
|
|
21481
21511
|
LOG.info("Upgrade", "Exiting daemon so detached upgrader can continue...");
|
|
21482
21512
|
process.exit(0);
|
|
21483
21513
|
}, 3e3);
|
|
21484
|
-
return { success: true, upgraded: true, version: latest, restarting: true };
|
|
21514
|
+
return { success: true, upgraded: true, version: latest, restarting: true, channel, npmTag };
|
|
21485
21515
|
} catch (e) {
|
|
21486
21516
|
LOG.error("Upgrade", `Failed: ${e.message}`);
|
|
21487
21517
|
return { success: false, error: e.message };
|
|
@@ -21508,11 +21538,12 @@ var DaemonCommandRouter = class {
|
|
|
21508
21538
|
try {
|
|
21509
21539
|
const { getMesh: getMesh3 } = await Promise.resolve().then(() => (init_mesh_config(), mesh_config_exports));
|
|
21510
21540
|
const mesh = getMesh3(meshId);
|
|
21511
|
-
if (
|
|
21512
|
-
|
|
21513
|
-
} catch (e) {
|
|
21514
|
-
return { success: false, error: e.message };
|
|
21541
|
+
if (mesh) return { success: true, mesh };
|
|
21542
|
+
} catch {
|
|
21515
21543
|
}
|
|
21544
|
+
const cached = this.inlineMeshCache.get(meshId);
|
|
21545
|
+
if (cached) return { success: true, mesh: cached };
|
|
21546
|
+
return { success: false, error: "Mesh not found" };
|
|
21516
21547
|
}
|
|
21517
21548
|
case "create_mesh": {
|
|
21518
21549
|
const name = typeof args?.name === "string" ? args.name.trim() : "";
|
|
@@ -21575,6 +21606,7 @@ var DaemonCommandRouter = class {
|
|
|
21575
21606
|
let mesh;
|
|
21576
21607
|
if (args?.inlineMesh && typeof args.inlineMesh === "object") {
|
|
21577
21608
|
mesh = args.inlineMesh;
|
|
21609
|
+
this.inlineMeshCache.set(meshId, mesh);
|
|
21578
21610
|
} else {
|
|
21579
21611
|
const { getMesh: getMesh3 } = await Promise.resolve().then(() => (init_mesh_config(), mesh_config_exports));
|
|
21580
21612
|
mesh = getMesh3(meshId);
|
|
@@ -21643,14 +21675,20 @@ var DaemonCommandRouter = class {
|
|
|
21643
21675
|
} catch {
|
|
21644
21676
|
}
|
|
21645
21677
|
}
|
|
21678
|
+
const mcpServerEntry = {
|
|
21679
|
+
command: coordinatorSetup.mcpServer.command,
|
|
21680
|
+
args: coordinatorSetup.mcpServer.args
|
|
21681
|
+
};
|
|
21682
|
+
if (args?.inlineMesh) {
|
|
21683
|
+
mcpServerEntry.env = {
|
|
21684
|
+
ADHDEV_INLINE_MESH: JSON.stringify(mesh)
|
|
21685
|
+
};
|
|
21686
|
+
}
|
|
21646
21687
|
const mcpConfig = {
|
|
21647
21688
|
...existingMcpConfig,
|
|
21648
21689
|
mcpServers: {
|
|
21649
21690
|
...existingMcpConfig.mcpServers || {},
|
|
21650
|
-
[coordinatorSetup.serverName]:
|
|
21651
|
-
command: coordinatorSetup.mcpServer.command,
|
|
21652
|
-
args: coordinatorSetup.mcpServer.args
|
|
21653
|
-
}
|
|
21691
|
+
[coordinatorSetup.serverName]: mcpServerEntry
|
|
21654
21692
|
}
|
|
21655
21693
|
};
|
|
21656
21694
|
writeFileSync12(mcpConfigPath, JSON.stringify(mcpConfig, null, 2), "utf-8");
|