@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/index.mjs CHANGED
@@ -17344,6 +17344,8 @@ var KNOWN_PROVIDER_FIELDS = /* @__PURE__ */ new Set([
17344
17344
  "type",
17345
17345
  "name",
17346
17346
  "category",
17347
+ "transcriptAuthority",
17348
+ "transcriptContext",
17347
17349
  "aliases",
17348
17350
  "cdpPorts",
17349
17351
  "targetFilter",
@@ -17388,6 +17390,7 @@ var KNOWN_PROVIDER_FIELDS = /* @__PURE__ */ new Set([
17388
17390
  "staticConfigOptions",
17389
17391
  "spawnArgBuilder",
17390
17392
  "auth",
17393
+ "meshCoordinator",
17391
17394
  "contractVersion",
17392
17395
  "capabilities",
17393
17396
  "providerVersion",
@@ -17445,6 +17448,7 @@ function validateProviderDefinition(raw) {
17445
17448
  }
17446
17449
  validateCapabilities(provider, controls, errors);
17447
17450
  validateCanonicalHistory(provider.canonicalHistory, errors);
17451
+ validateMeshCoordinator(provider.meshCoordinator, errors);
17448
17452
  for (const control of controls) {
17449
17453
  validateControl(control, errors);
17450
17454
  }
@@ -17535,6 +17539,60 @@ function validateCanonicalHistory(raw, errors) {
17535
17539
  }
17536
17540
  }
17537
17541
  }
17542
+ function validateMeshCoordinator(raw, errors) {
17543
+ if (raw === void 0) return;
17544
+ if (!raw || typeof raw !== "object" || Array.isArray(raw)) {
17545
+ errors.push("meshCoordinator must be an object");
17546
+ return;
17547
+ }
17548
+ const meshCoordinator = raw;
17549
+ if (typeof meshCoordinator.supported !== "boolean") {
17550
+ errors.push("meshCoordinator.supported must be boolean");
17551
+ }
17552
+ if (meshCoordinator.reason !== void 0 && (typeof meshCoordinator.reason !== "string" || !meshCoordinator.reason.trim())) {
17553
+ errors.push("meshCoordinator.reason must be a non-empty string when provided");
17554
+ }
17555
+ const mcpConfig = meshCoordinator.mcpConfig;
17556
+ if (mcpConfig === void 0) return;
17557
+ if (!mcpConfig || typeof mcpConfig !== "object" || Array.isArray(mcpConfig)) {
17558
+ errors.push("meshCoordinator.mcpConfig must be an object");
17559
+ return;
17560
+ }
17561
+ const config = mcpConfig;
17562
+ const mode = config.mode;
17563
+ if (!["auto_import", "manual", "none"].includes(String(mode))) {
17564
+ errors.push("meshCoordinator.mcpConfig.mode must be one of: auto_import, manual, none");
17565
+ }
17566
+ const format = config.format;
17567
+ if (format !== void 0 && !["claude_mcp_json", "hermes_config_yaml"].includes(String(format))) {
17568
+ errors.push("meshCoordinator.mcpConfig.format must be one of: claude_mcp_json, hermes_config_yaml");
17569
+ }
17570
+ for (const key of ["path", "serverName", "configPathCommand", "instructions", "template"]) {
17571
+ const value = config[key];
17572
+ if (value !== void 0 && (typeof value !== "string" || !value.trim())) {
17573
+ errors.push(`meshCoordinator.mcpConfig.${key} must be a non-empty string when provided`);
17574
+ }
17575
+ }
17576
+ if (config.requiresRestart !== void 0 && typeof config.requiresRestart !== "boolean") {
17577
+ errors.push("meshCoordinator.mcpConfig.requiresRestart must be boolean when provided");
17578
+ }
17579
+ if (mode === "auto_import") {
17580
+ if (format === void 0) {
17581
+ errors.push("meshCoordinator.mcpConfig.format is required for auto_import MCP setup");
17582
+ }
17583
+ if (typeof config.path !== "string" || !config.path.trim()) {
17584
+ errors.push("meshCoordinator.mcpConfig.path is required for auto_import MCP setup");
17585
+ }
17586
+ }
17587
+ if (mode === "manual") {
17588
+ if (typeof config.instructions !== "string" || !config.instructions.trim()) {
17589
+ errors.push("meshCoordinator.mcpConfig.instructions is required for manual MCP setup");
17590
+ }
17591
+ if (typeof config.template !== "string" || !config.template.trim()) {
17592
+ errors.push("meshCoordinator.mcpConfig.template is required for manual MCP setup");
17593
+ }
17594
+ }
17595
+ }
17538
17596
  function validateControl(control, errors) {
17539
17597
  if (!control || typeof control !== "object") {
17540
17598
  errors.push("controls: each control must be an object");
@@ -19690,6 +19748,69 @@ cleanOldFiles();
19690
19748
  // src/commands/router.ts
19691
19749
  init_logger();
19692
19750
 
19751
+ // src/commands/mesh-coordinator.ts
19752
+ import { join as join17 } from "path";
19753
+ var DEFAULT_SERVER_NAME = "adhdev-mesh";
19754
+ var DEFAULT_ADHDEV_MCP_COMMAND = "adhdev-mcp";
19755
+ function resolveMeshCoordinatorSetup(options) {
19756
+ const { provider, meshId, workspace } = options;
19757
+ const config = provider?.meshCoordinator;
19758
+ if (!config?.supported) {
19759
+ return {
19760
+ kind: "unsupported",
19761
+ reason: config?.reason || "Provider does not declare Repo Mesh coordinator support"
19762
+ };
19763
+ }
19764
+ const mcpConfig = config.mcpConfig;
19765
+ if (!mcpConfig || mcpConfig.mode === "none") {
19766
+ return {
19767
+ kind: "unsupported",
19768
+ reason: config.reason || "Provider does not declare a usable Repo Mesh MCP configuration mode"
19769
+ };
19770
+ }
19771
+ const serverName = mcpConfig.serverName?.trim() || DEFAULT_SERVER_NAME;
19772
+ if (mcpConfig.mode === "auto_import") {
19773
+ const path26 = mcpConfig.path?.trim();
19774
+ if (!path26) {
19775
+ return { kind: "unsupported", reason: "Provider auto-import MCP config is missing a config path" };
19776
+ }
19777
+ return {
19778
+ kind: "auto_import",
19779
+ serverName,
19780
+ configPath: join17(workspace, path26),
19781
+ configFormat: mcpConfig.format
19782
+ };
19783
+ }
19784
+ if (mcpConfig.mode === "manual") {
19785
+ const instructions = mcpConfig.instructions?.trim();
19786
+ const template = mcpConfig.template;
19787
+ if (!instructions || !template?.trim()) {
19788
+ return { kind: "unsupported", reason: "Provider manual MCP setup is missing instructions or template" };
19789
+ }
19790
+ return {
19791
+ kind: "manual",
19792
+ serverName,
19793
+ configFormat: mcpConfig.format,
19794
+ configPathCommand: mcpConfig.configPathCommand,
19795
+ requiresRestart: mcpConfig.requiresRestart === true,
19796
+ instructions,
19797
+ template: renderMeshCoordinatorTemplate(template, {
19798
+ meshId,
19799
+ workspace,
19800
+ serverName,
19801
+ adhdevMcpCommand: options.adhdevMcpCommand || DEFAULT_ADHDEV_MCP_COMMAND
19802
+ })
19803
+ };
19804
+ }
19805
+ return {
19806
+ kind: "unsupported",
19807
+ reason: `Unsupported Repo Mesh MCP configuration mode: ${String(mcpConfig.mode)}`
19808
+ };
19809
+ }
19810
+ function renderMeshCoordinatorTemplate(template, values) {
19811
+ return template.replace(/\{\{\s*(meshId|workspace|serverName|adhdevMcpCommand)\s*\}\}/g, (_, key) => values[key] || "");
19812
+ }
19813
+
19693
19814
  // src/status/snapshot.ts
19694
19815
  init_config();
19695
19816
  import * as os17 from "os";
@@ -19741,7 +19862,8 @@ function buildAvailableProviders(providerLoader) {
19741
19862
  ...provider.enabled !== void 0 ? { enabled: provider.enabled } : {},
19742
19863
  ...provider.machineStatus !== void 0 ? { machineStatus: provider.machineStatus } : {},
19743
19864
  ...provider.lastDetection !== void 0 ? { lastDetection: provider.lastDetection } : {},
19744
- ...provider.lastVerification !== void 0 ? { lastVerification: provider.lastVerification } : {}
19865
+ ...provider.lastVerification !== void 0 ? { lastVerification: provider.lastVerification } : {},
19866
+ ...provider.meshCoordinator !== void 0 ? { meshCoordinator: provider.meshCoordinator } : {}
19745
19867
  }));
19746
19868
  }
19747
19869
  function buildMachineInfo(profile = "full") {
@@ -21150,9 +21272,45 @@ var DaemonCommandRouter = class {
21150
21272
  if (!mesh) return { success: false, error: "Mesh not found" };
21151
21273
  if (mesh.nodes.length === 0) return { success: false, error: "No nodes in mesh" };
21152
21274
  const workspace = mesh.nodes[0].workspace;
21275
+ const providerMeta = this.deps.providerLoader.resolve?.(cliType) || this.deps.providerLoader.getMeta(cliType);
21276
+ const coordinatorSetup = resolveMeshCoordinatorSetup({
21277
+ provider: providerMeta,
21278
+ meshId,
21279
+ workspace
21280
+ });
21281
+ if (coordinatorSetup.kind === "unsupported") {
21282
+ return {
21283
+ success: false,
21284
+ code: "mesh_coordinator_unsupported",
21285
+ error: coordinatorSetup.reason,
21286
+ meshId,
21287
+ cliType,
21288
+ workspace
21289
+ };
21290
+ }
21291
+ if (coordinatorSetup.kind === "manual") {
21292
+ return {
21293
+ success: false,
21294
+ code: "mesh_coordinator_manual_mcp_setup_required",
21295
+ error: coordinatorSetup.instructions,
21296
+ meshId,
21297
+ cliType,
21298
+ workspace,
21299
+ meshCoordinatorSetup: coordinatorSetup
21300
+ };
21301
+ }
21302
+ if (coordinatorSetup.configFormat !== "claude_mcp_json") {
21303
+ return {
21304
+ success: false,
21305
+ code: "mesh_coordinator_unsupported",
21306
+ error: `Unsupported auto-import MCP config format: ${String(coordinatorSetup.configFormat)}`,
21307
+ meshId,
21308
+ cliType,
21309
+ workspace
21310
+ };
21311
+ }
21153
21312
  const { existsSync: existsSync21, readFileSync: readFileSync15, writeFileSync: writeFileSync12, copyFileSync: copyFileSync3 } = await import("fs");
21154
- const { join: join23 } = await import("path");
21155
- const mcpConfigPath = join23(workspace, ".mcp.json");
21313
+ const mcpConfigPath = coordinatorSetup.configPath;
21156
21314
  const hadExistingMcpConfig = existsSync21(mcpConfigPath);
21157
21315
  let existingMcpConfig = {};
21158
21316
  if (hadExistingMcpConfig) {
@@ -21166,14 +21324,14 @@ var DaemonCommandRouter = class {
21166
21324
  ...existingMcpConfig,
21167
21325
  mcpServers: {
21168
21326
  ...existingMcpConfig.mcpServers || {},
21169
- "adhdev-mesh": {
21327
+ [coordinatorSetup.serverName]: {
21170
21328
  command: "adhdev-mcp",
21171
21329
  args: ["--repo-mesh", meshId]
21172
21330
  }
21173
21331
  }
21174
21332
  };
21175
21333
  writeFileSync12(mcpConfigPath, JSON.stringify(mcpConfig, null, 2), "utf-8");
21176
- LOG.info("MeshCoordinator", `Wrote .mcp.json to ${workspace} with adhdev-mesh server`);
21334
+ LOG.info("MeshCoordinator", `Wrote ${mcpConfigPath} with ${coordinatorSetup.serverName} server`);
21177
21335
  let systemPrompt = "";
21178
21336
  try {
21179
21337
  systemPrompt = buildCoordinatorSystemPrompt2({ mesh });