@adhdev/daemon-core 0.9.68 → 0.9.70
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/commands/mesh-coordinator.d.ts +25 -0
- package/dist/index.js +163 -5
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +163 -5
- package/dist/index.mjs.map +1 -1
- package/dist/providers/contracts.d.ts +34 -0
- package/dist/shared-types.d.ts +3 -1
- package/node_modules/@adhdev/session-host-core/package.json +1 -1
- package/package.json +1 -1
- package/src/commands/mesh-coordinator.ts +97 -0
- package/src/commands/router.ts +47 -7
- package/src/providers/contracts.ts +37 -0
- package/src/providers/provider-schema.ts +67 -0
- package/src/shared-types.ts +3 -1
- package/src/status/snapshot.ts +2 -0
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { ProviderModule, MeshCoordinatorMcpConfigFormat } from '../providers/contracts.js';
|
|
2
|
+
export type MeshCoordinatorSetup = {
|
|
3
|
+
kind: 'auto_import';
|
|
4
|
+
serverName: string;
|
|
5
|
+
configPath: string;
|
|
6
|
+
configFormat?: MeshCoordinatorMcpConfigFormat;
|
|
7
|
+
} | {
|
|
8
|
+
kind: 'manual';
|
|
9
|
+
serverName: string;
|
|
10
|
+
configFormat?: MeshCoordinatorMcpConfigFormat;
|
|
11
|
+
configPathCommand?: string;
|
|
12
|
+
requiresRestart: boolean;
|
|
13
|
+
instructions: string;
|
|
14
|
+
template: string;
|
|
15
|
+
} | {
|
|
16
|
+
kind: 'unsupported';
|
|
17
|
+
reason: string;
|
|
18
|
+
};
|
|
19
|
+
export interface ResolveMeshCoordinatorSetupOptions {
|
|
20
|
+
provider?: ProviderModule | null;
|
|
21
|
+
meshId: string;
|
|
22
|
+
workspace: string;
|
|
23
|
+
adhdevMcpCommand?: string;
|
|
24
|
+
}
|
|
25
|
+
export declare function resolveMeshCoordinatorSetup(options: ResolveMeshCoordinatorSetupOptions): MeshCoordinatorSetup;
|
package/dist/index.js
CHANGED
|
@@ -17531,6 +17531,8 @@ var KNOWN_PROVIDER_FIELDS = /* @__PURE__ */ new Set([
|
|
|
17531
17531
|
"type",
|
|
17532
17532
|
"name",
|
|
17533
17533
|
"category",
|
|
17534
|
+
"transcriptAuthority",
|
|
17535
|
+
"transcriptContext",
|
|
17534
17536
|
"aliases",
|
|
17535
17537
|
"cdpPorts",
|
|
17536
17538
|
"targetFilter",
|
|
@@ -17575,6 +17577,7 @@ var KNOWN_PROVIDER_FIELDS = /* @__PURE__ */ new Set([
|
|
|
17575
17577
|
"staticConfigOptions",
|
|
17576
17578
|
"spawnArgBuilder",
|
|
17577
17579
|
"auth",
|
|
17580
|
+
"meshCoordinator",
|
|
17578
17581
|
"contractVersion",
|
|
17579
17582
|
"capabilities",
|
|
17580
17583
|
"providerVersion",
|
|
@@ -17632,6 +17635,7 @@ function validateProviderDefinition(raw) {
|
|
|
17632
17635
|
}
|
|
17633
17636
|
validateCapabilities(provider, controls, errors);
|
|
17634
17637
|
validateCanonicalHistory(provider.canonicalHistory, errors);
|
|
17638
|
+
validateMeshCoordinator(provider.meshCoordinator, errors);
|
|
17635
17639
|
for (const control of controls) {
|
|
17636
17640
|
validateControl(control, errors);
|
|
17637
17641
|
}
|
|
@@ -17722,6 +17726,60 @@ function validateCanonicalHistory(raw, errors) {
|
|
|
17722
17726
|
}
|
|
17723
17727
|
}
|
|
17724
17728
|
}
|
|
17729
|
+
function validateMeshCoordinator(raw, errors) {
|
|
17730
|
+
if (raw === void 0) return;
|
|
17731
|
+
if (!raw || typeof raw !== "object" || Array.isArray(raw)) {
|
|
17732
|
+
errors.push("meshCoordinator must be an object");
|
|
17733
|
+
return;
|
|
17734
|
+
}
|
|
17735
|
+
const meshCoordinator = raw;
|
|
17736
|
+
if (typeof meshCoordinator.supported !== "boolean") {
|
|
17737
|
+
errors.push("meshCoordinator.supported must be boolean");
|
|
17738
|
+
}
|
|
17739
|
+
if (meshCoordinator.reason !== void 0 && (typeof meshCoordinator.reason !== "string" || !meshCoordinator.reason.trim())) {
|
|
17740
|
+
errors.push("meshCoordinator.reason must be a non-empty string when provided");
|
|
17741
|
+
}
|
|
17742
|
+
const mcpConfig = meshCoordinator.mcpConfig;
|
|
17743
|
+
if (mcpConfig === void 0) return;
|
|
17744
|
+
if (!mcpConfig || typeof mcpConfig !== "object" || Array.isArray(mcpConfig)) {
|
|
17745
|
+
errors.push("meshCoordinator.mcpConfig must be an object");
|
|
17746
|
+
return;
|
|
17747
|
+
}
|
|
17748
|
+
const config = mcpConfig;
|
|
17749
|
+
const mode = config.mode;
|
|
17750
|
+
if (!["auto_import", "manual", "none"].includes(String(mode))) {
|
|
17751
|
+
errors.push("meshCoordinator.mcpConfig.mode must be one of: auto_import, manual, none");
|
|
17752
|
+
}
|
|
17753
|
+
const format = config.format;
|
|
17754
|
+
if (format !== void 0 && !["claude_mcp_json", "hermes_config_yaml"].includes(String(format))) {
|
|
17755
|
+
errors.push("meshCoordinator.mcpConfig.format must be one of: claude_mcp_json, hermes_config_yaml");
|
|
17756
|
+
}
|
|
17757
|
+
for (const key of ["path", "serverName", "configPathCommand", "instructions", "template"]) {
|
|
17758
|
+
const value = config[key];
|
|
17759
|
+
if (value !== void 0 && (typeof value !== "string" || !value.trim())) {
|
|
17760
|
+
errors.push(`meshCoordinator.mcpConfig.${key} must be a non-empty string when provided`);
|
|
17761
|
+
}
|
|
17762
|
+
}
|
|
17763
|
+
if (config.requiresRestart !== void 0 && typeof config.requiresRestart !== "boolean") {
|
|
17764
|
+
errors.push("meshCoordinator.mcpConfig.requiresRestart must be boolean when provided");
|
|
17765
|
+
}
|
|
17766
|
+
if (mode === "auto_import") {
|
|
17767
|
+
if (format === void 0) {
|
|
17768
|
+
errors.push("meshCoordinator.mcpConfig.format is required for auto_import MCP setup");
|
|
17769
|
+
}
|
|
17770
|
+
if (typeof config.path !== "string" || !config.path.trim()) {
|
|
17771
|
+
errors.push("meshCoordinator.mcpConfig.path is required for auto_import MCP setup");
|
|
17772
|
+
}
|
|
17773
|
+
}
|
|
17774
|
+
if (mode === "manual") {
|
|
17775
|
+
if (typeof config.instructions !== "string" || !config.instructions.trim()) {
|
|
17776
|
+
errors.push("meshCoordinator.mcpConfig.instructions is required for manual MCP setup");
|
|
17777
|
+
}
|
|
17778
|
+
if (typeof config.template !== "string" || !config.template.trim()) {
|
|
17779
|
+
errors.push("meshCoordinator.mcpConfig.template is required for manual MCP setup");
|
|
17780
|
+
}
|
|
17781
|
+
}
|
|
17782
|
+
}
|
|
17725
17783
|
function validateControl(control, errors) {
|
|
17726
17784
|
if (!control || typeof control !== "object") {
|
|
17727
17785
|
errors.push("controls: each control must be an object");
|
|
@@ -19877,6 +19935,69 @@ cleanOldFiles();
|
|
|
19877
19935
|
// src/commands/router.ts
|
|
19878
19936
|
init_logger();
|
|
19879
19937
|
|
|
19938
|
+
// src/commands/mesh-coordinator.ts
|
|
19939
|
+
var import_path4 = require("path");
|
|
19940
|
+
var DEFAULT_SERVER_NAME = "adhdev-mesh";
|
|
19941
|
+
var DEFAULT_ADHDEV_MCP_COMMAND = "adhdev-mcp";
|
|
19942
|
+
function resolveMeshCoordinatorSetup(options) {
|
|
19943
|
+
const { provider, meshId, workspace } = options;
|
|
19944
|
+
const config = provider?.meshCoordinator;
|
|
19945
|
+
if (!config?.supported) {
|
|
19946
|
+
return {
|
|
19947
|
+
kind: "unsupported",
|
|
19948
|
+
reason: config?.reason || "Provider does not declare Repo Mesh coordinator support"
|
|
19949
|
+
};
|
|
19950
|
+
}
|
|
19951
|
+
const mcpConfig = config.mcpConfig;
|
|
19952
|
+
if (!mcpConfig || mcpConfig.mode === "none") {
|
|
19953
|
+
return {
|
|
19954
|
+
kind: "unsupported",
|
|
19955
|
+
reason: config.reason || "Provider does not declare a usable Repo Mesh MCP configuration mode"
|
|
19956
|
+
};
|
|
19957
|
+
}
|
|
19958
|
+
const serverName = mcpConfig.serverName?.trim() || DEFAULT_SERVER_NAME;
|
|
19959
|
+
if (mcpConfig.mode === "auto_import") {
|
|
19960
|
+
const path26 = mcpConfig.path?.trim();
|
|
19961
|
+
if (!path26) {
|
|
19962
|
+
return { kind: "unsupported", reason: "Provider auto-import MCP config is missing a config path" };
|
|
19963
|
+
}
|
|
19964
|
+
return {
|
|
19965
|
+
kind: "auto_import",
|
|
19966
|
+
serverName,
|
|
19967
|
+
configPath: (0, import_path4.join)(workspace, path26),
|
|
19968
|
+
configFormat: mcpConfig.format
|
|
19969
|
+
};
|
|
19970
|
+
}
|
|
19971
|
+
if (mcpConfig.mode === "manual") {
|
|
19972
|
+
const instructions = mcpConfig.instructions?.trim();
|
|
19973
|
+
const template = mcpConfig.template;
|
|
19974
|
+
if (!instructions || !template?.trim()) {
|
|
19975
|
+
return { kind: "unsupported", reason: "Provider manual MCP setup is missing instructions or template" };
|
|
19976
|
+
}
|
|
19977
|
+
return {
|
|
19978
|
+
kind: "manual",
|
|
19979
|
+
serverName,
|
|
19980
|
+
configFormat: mcpConfig.format,
|
|
19981
|
+
configPathCommand: mcpConfig.configPathCommand,
|
|
19982
|
+
requiresRestart: mcpConfig.requiresRestart === true,
|
|
19983
|
+
instructions,
|
|
19984
|
+
template: renderMeshCoordinatorTemplate(template, {
|
|
19985
|
+
meshId,
|
|
19986
|
+
workspace,
|
|
19987
|
+
serverName,
|
|
19988
|
+
adhdevMcpCommand: options.adhdevMcpCommand || DEFAULT_ADHDEV_MCP_COMMAND
|
|
19989
|
+
})
|
|
19990
|
+
};
|
|
19991
|
+
}
|
|
19992
|
+
return {
|
|
19993
|
+
kind: "unsupported",
|
|
19994
|
+
reason: `Unsupported Repo Mesh MCP configuration mode: ${String(mcpConfig.mode)}`
|
|
19995
|
+
};
|
|
19996
|
+
}
|
|
19997
|
+
function renderMeshCoordinatorTemplate(template, values) {
|
|
19998
|
+
return template.replace(/\{\{\s*(meshId|workspace|serverName|adhdevMcpCommand)\s*\}\}/g, (_, key) => values[key] || "");
|
|
19999
|
+
}
|
|
20000
|
+
|
|
19880
20001
|
// src/status/snapshot.ts
|
|
19881
20002
|
var os17 = __toESM(require("os"));
|
|
19882
20003
|
init_config();
|
|
@@ -19928,7 +20049,8 @@ function buildAvailableProviders(providerLoader) {
|
|
|
19928
20049
|
...provider.enabled !== void 0 ? { enabled: provider.enabled } : {},
|
|
19929
20050
|
...provider.machineStatus !== void 0 ? { machineStatus: provider.machineStatus } : {},
|
|
19930
20051
|
...provider.lastDetection !== void 0 ? { lastDetection: provider.lastDetection } : {},
|
|
19931
|
-
...provider.lastVerification !== void 0 ? { lastVerification: provider.lastVerification } : {}
|
|
20052
|
+
...provider.lastVerification !== void 0 ? { lastVerification: provider.lastVerification } : {},
|
|
20053
|
+
...provider.meshCoordinator !== void 0 ? { meshCoordinator: provider.meshCoordinator } : {}
|
|
19932
20054
|
}));
|
|
19933
20055
|
}
|
|
19934
20056
|
function buildMachineInfo(profile = "full") {
|
|
@@ -21337,9 +21459,45 @@ var DaemonCommandRouter = class {
|
|
|
21337
21459
|
if (!mesh) return { success: false, error: "Mesh not found" };
|
|
21338
21460
|
if (mesh.nodes.length === 0) return { success: false, error: "No nodes in mesh" };
|
|
21339
21461
|
const workspace = mesh.nodes[0].workspace;
|
|
21462
|
+
const providerMeta = this.deps.providerLoader.resolve?.(cliType) || this.deps.providerLoader.getMeta(cliType);
|
|
21463
|
+
const coordinatorSetup = resolveMeshCoordinatorSetup({
|
|
21464
|
+
provider: providerMeta,
|
|
21465
|
+
meshId,
|
|
21466
|
+
workspace
|
|
21467
|
+
});
|
|
21468
|
+
if (coordinatorSetup.kind === "unsupported") {
|
|
21469
|
+
return {
|
|
21470
|
+
success: false,
|
|
21471
|
+
code: "mesh_coordinator_unsupported",
|
|
21472
|
+
error: coordinatorSetup.reason,
|
|
21473
|
+
meshId,
|
|
21474
|
+
cliType,
|
|
21475
|
+
workspace
|
|
21476
|
+
};
|
|
21477
|
+
}
|
|
21478
|
+
if (coordinatorSetup.kind === "manual") {
|
|
21479
|
+
return {
|
|
21480
|
+
success: false,
|
|
21481
|
+
code: "mesh_coordinator_manual_mcp_setup_required",
|
|
21482
|
+
error: coordinatorSetup.instructions,
|
|
21483
|
+
meshId,
|
|
21484
|
+
cliType,
|
|
21485
|
+
workspace,
|
|
21486
|
+
meshCoordinatorSetup: coordinatorSetup
|
|
21487
|
+
};
|
|
21488
|
+
}
|
|
21489
|
+
if (coordinatorSetup.configFormat !== "claude_mcp_json") {
|
|
21490
|
+
return {
|
|
21491
|
+
success: false,
|
|
21492
|
+
code: "mesh_coordinator_unsupported",
|
|
21493
|
+
error: `Unsupported auto-import MCP config format: ${String(coordinatorSetup.configFormat)}`,
|
|
21494
|
+
meshId,
|
|
21495
|
+
cliType,
|
|
21496
|
+
workspace
|
|
21497
|
+
};
|
|
21498
|
+
}
|
|
21340
21499
|
const { existsSync: existsSync21, readFileSync: readFileSync15, writeFileSync: writeFileSync12, copyFileSync: copyFileSync3 } = await import("fs");
|
|
21341
|
-
const
|
|
21342
|
-
const mcpConfigPath = join23(workspace, ".mcp.json");
|
|
21500
|
+
const mcpConfigPath = coordinatorSetup.configPath;
|
|
21343
21501
|
const hadExistingMcpConfig = existsSync21(mcpConfigPath);
|
|
21344
21502
|
let existingMcpConfig = {};
|
|
21345
21503
|
if (hadExistingMcpConfig) {
|
|
@@ -21353,14 +21511,14 @@ var DaemonCommandRouter = class {
|
|
|
21353
21511
|
...existingMcpConfig,
|
|
21354
21512
|
mcpServers: {
|
|
21355
21513
|
...existingMcpConfig.mcpServers || {},
|
|
21356
|
-
|
|
21514
|
+
[coordinatorSetup.serverName]: {
|
|
21357
21515
|
command: "adhdev-mcp",
|
|
21358
21516
|
args: ["--repo-mesh", meshId]
|
|
21359
21517
|
}
|
|
21360
21518
|
}
|
|
21361
21519
|
};
|
|
21362
21520
|
writeFileSync12(mcpConfigPath, JSON.stringify(mcpConfig, null, 2), "utf-8");
|
|
21363
|
-
LOG.info("MeshCoordinator", `Wrote
|
|
21521
|
+
LOG.info("MeshCoordinator", `Wrote ${mcpConfigPath} with ${coordinatorSetup.serverName} server`);
|
|
21364
21522
|
let systemPrompt = "";
|
|
21365
21523
|
try {
|
|
21366
21524
|
systemPrompt = buildCoordinatorSystemPrompt2({ mesh });
|