@adhdev/daemon-core 0.9.71 → 0.9.72
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 +7 -0
- package/dist/index.js +174 -113
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +173 -112
- 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/commands/mesh-coordinator.ts +82 -1
- package/src/commands/router.ts +2 -2
package/package.json
CHANGED
|
@@ -1,12 +1,20 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { existsSync, realpathSync } from 'node:fs'
|
|
2
|
+
import { createRequire } from 'node:module'
|
|
3
|
+
import { dirname, join, resolve } from 'node:path'
|
|
2
4
|
import type { ProviderModule, MeshCoordinatorMcpConfigFormat } from '../providers/contracts.js'
|
|
3
5
|
|
|
6
|
+
export interface MeshCoordinatorMcpServerLaunch {
|
|
7
|
+
command: string
|
|
8
|
+
args: string[]
|
|
9
|
+
}
|
|
10
|
+
|
|
4
11
|
export type MeshCoordinatorSetup =
|
|
5
12
|
| {
|
|
6
13
|
kind: 'auto_import'
|
|
7
14
|
serverName: string
|
|
8
15
|
configPath: string
|
|
9
16
|
configFormat?: MeshCoordinatorMcpConfigFormat
|
|
17
|
+
mcpServer: MeshCoordinatorMcpServerLaunch
|
|
10
18
|
}
|
|
11
19
|
| {
|
|
12
20
|
kind: 'manual'
|
|
@@ -27,6 +35,8 @@ export interface ResolveMeshCoordinatorSetupOptions {
|
|
|
27
35
|
meshId: string
|
|
28
36
|
workspace: string
|
|
29
37
|
adhdevMcpCommand?: string
|
|
38
|
+
adhdevMcpEntryPath?: string
|
|
39
|
+
nodeExecutable?: string
|
|
30
40
|
}
|
|
31
41
|
|
|
32
42
|
const DEFAULT_SERVER_NAME = 'adhdev-mesh'
|
|
@@ -56,11 +66,23 @@ export function resolveMeshCoordinatorSetup(options: ResolveMeshCoordinatorSetup
|
|
|
56
66
|
if (!path) {
|
|
57
67
|
return { kind: 'unsupported', reason: 'Provider auto-import MCP config is missing a config path' }
|
|
58
68
|
}
|
|
69
|
+
const mcpServer = resolveAdhdevMcpServerLaunch({
|
|
70
|
+
meshId,
|
|
71
|
+
nodeExecutable: options.nodeExecutable,
|
|
72
|
+
adhdevMcpEntryPath: options.adhdevMcpEntryPath,
|
|
73
|
+
})
|
|
74
|
+
if (!mcpServer) {
|
|
75
|
+
return {
|
|
76
|
+
kind: 'unsupported',
|
|
77
|
+
reason: 'Could not resolve the ADHDev MCP server entrypoint without relying on a PATH bin shim',
|
|
78
|
+
}
|
|
79
|
+
}
|
|
59
80
|
return {
|
|
60
81
|
kind: 'auto_import',
|
|
61
82
|
serverName,
|
|
62
83
|
configPath: join(workspace, path),
|
|
63
84
|
configFormat: mcpConfig.format,
|
|
85
|
+
mcpServer,
|
|
64
86
|
}
|
|
65
87
|
}
|
|
66
88
|
|
|
@@ -95,3 +117,62 @@ export function resolveMeshCoordinatorSetup(options: ResolveMeshCoordinatorSetup
|
|
|
95
117
|
function renderMeshCoordinatorTemplate(template: string, values: Record<string, string>): string {
|
|
96
118
|
return template.replace(/\{\{\s*(meshId|workspace|serverName|adhdevMcpCommand)\s*\}\}/g, (_, key: string) => values[key] || '')
|
|
97
119
|
}
|
|
120
|
+
|
|
121
|
+
function resolveAdhdevMcpServerLaunch(options: {
|
|
122
|
+
meshId: string
|
|
123
|
+
nodeExecutable?: string
|
|
124
|
+
adhdevMcpEntryPath?: string
|
|
125
|
+
}): MeshCoordinatorMcpServerLaunch | null {
|
|
126
|
+
const entryPath = resolveAdhdevMcpEntryPath(options.adhdevMcpEntryPath)
|
|
127
|
+
if (!entryPath) return null
|
|
128
|
+
return {
|
|
129
|
+
command: options.nodeExecutable?.trim() || process.execPath,
|
|
130
|
+
args: [entryPath, '--repo-mesh', options.meshId],
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
function resolveAdhdevMcpEntryPath(explicitPath?: string): string | null {
|
|
135
|
+
const explicit = explicitPath?.trim()
|
|
136
|
+
if (explicit) return normalizeExistingPath(explicit) || explicit
|
|
137
|
+
|
|
138
|
+
const envPath = process.env.ADHDEV_MCP_SERVER_PATH?.trim()
|
|
139
|
+
if (envPath) return normalizeExistingPath(envPath) || envPath
|
|
140
|
+
|
|
141
|
+
const candidates: string[] = []
|
|
142
|
+
const addCandidate = (candidate: string) => {
|
|
143
|
+
if (!candidates.includes(candidate)) candidates.push(candidate)
|
|
144
|
+
}
|
|
145
|
+
const addPackagedCandidates = (baseFile?: string) => {
|
|
146
|
+
if (!baseFile) return
|
|
147
|
+
const realBase = normalizeExistingPath(baseFile) || baseFile
|
|
148
|
+
const dir = dirname(realBase)
|
|
149
|
+
addCandidate(resolve(dir, '../vendor/mcp-server/index.js'))
|
|
150
|
+
addCandidate(resolve(dir, '../../vendor/mcp-server/index.js'))
|
|
151
|
+
addCandidate(resolve(dir, '../../../vendor/mcp-server/index.js'))
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
addPackagedCandidates(process.argv[1])
|
|
155
|
+
|
|
156
|
+
for (const candidate of candidates) {
|
|
157
|
+
const normalized = normalizeExistingPath(candidate)
|
|
158
|
+
if (normalized) return normalized
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
try {
|
|
162
|
+
const requireBase = process.argv[1] ? (normalizeExistingPath(process.argv[1]) || process.argv[1]) : join(process.cwd(), 'adhdev-daemon.js')
|
|
163
|
+
const req = createRequire(requireBase)
|
|
164
|
+
const resolvedModule = req.resolve('@adhdev/mcp-server')
|
|
165
|
+
return normalizeExistingPath(resolvedModule) || resolvedModule
|
|
166
|
+
} catch {
|
|
167
|
+
return null
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
function normalizeExistingPath(filePath: string): string | null {
|
|
172
|
+
try {
|
|
173
|
+
if (!existsSync(filePath)) return null
|
|
174
|
+
return realpathSync.native(filePath)
|
|
175
|
+
} catch {
|
|
176
|
+
return null
|
|
177
|
+
}
|
|
178
|
+
}
|
package/src/commands/router.ts
CHANGED
|
@@ -1081,8 +1081,8 @@ export class DaemonCommandRouter {
|
|
|
1081
1081
|
mcpServers: {
|
|
1082
1082
|
...(existingMcpConfig.mcpServers || {}),
|
|
1083
1083
|
[coordinatorSetup.serverName]: {
|
|
1084
|
-
command:
|
|
1085
|
-
args:
|
|
1084
|
+
command: coordinatorSetup.mcpServer.command,
|
|
1085
|
+
args: coordinatorSetup.mcpServer.args,
|
|
1086
1086
|
},
|
|
1087
1087
|
},
|
|
1088
1088
|
};
|