dsh-desktop-kit 2.8.0 → 2.9.0
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/CHANGELOG.md +7 -0
- package/README.md +18 -17
- package/client.js +1 -1
- package/docs/TEST-2.9.0.md +28 -0
- package/package.json +2 -2
- package/plugins/dsh-agent-extensions/index.js +19 -0
- package/plugins/dsh-agent-extensions/lib/instructions.js +104 -0
- package/plugins/dsh-mcp-manager/lib/client.js +20 -1
- package/plugins/dsh-mcp-manager/lib/manager.js +17 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 2.9.0 (2026-11-12)
|
|
4
|
+
|
|
5
|
+
- **Project instructions.** `AGENTS.md` и `CLAUDE.md` читаются иерархически: root → вложенные папки до cwd → `.dsh/AGENTS.md`; поддержан `@import`, лимиты глубины/размера/файлов, защита от выхода за проект и symlink-escape.
|
|
6
|
+
- **MCP roots.** HTTP/stdio MCP-сервер получает capability `roots` и ответ `roots/list` с корнем проекта; `ping` поддержан. Sampling/elicitation возвращают явный `-32601`, а не тихо игнорируются.
|
|
7
|
+
- **Тесты.** `instructions-tests`, обновлённый `mcp-manager-tests` (roots request/response).
|
|
8
|
+
- **Ограничение.** Sampling, elicitation, agent teams, marketplace, IDE bridge и OS sandbox в этот релиз не входят.
|
|
9
|
+
|
|
3
10
|
## 2.8.0 (2026-11-12)
|
|
4
11
|
|
|
5
12
|
- **MCP OAuth 2.1.** HTTP-серверы: protected-resource discovery (RFC 9728), AS metadata (RFC 8414/OIDC), dynamic client registration (RFC 7591), authorization code + PKCE S256, `state`, loopback callback, `resource`/audience binding, refresh, logout.
|
package/README.md
CHANGED
|
@@ -4,17 +4,17 @@
|
|
|
4
4
|
|
|
5
5
|
Набор из **16 плагинов и 30 навыков** для DeepSeek Harness 0.2.x: русский интерфейс, автопилот навыков, токен-лаборатория, студия навыков, память проектов, обмен памятью между машинами (GitHub и USB), guardrails, карта репозитория, чекпоинты, plan mode, browser QA, GitHub review, Claude Code-подобные hooks/agents/commands, перенос чатов и резервные копии профиля.
|
|
6
6
|
|
|
7
|
-

|
|
8
8
|
|
|
9
9
|
## MCP: подключения без JSON
|
|
10
10
|
|
|
11
11
|
Настройки → **MCP**: пресеты GitHub, PostgreSQL и Filesystem, живые статусы, health, список tools и безопасное хранение токенов в `~/.dsh/mcp.secrets.json`. Промпты сервера открываются кнопкой **Prompts**: аргументы, запуск и копирование результата. HTTP-серверы подключаются через **OAuth 2.1 + PKCE** — токен хранится отдельно в `~/.dsh/mcp.oauth.json`.
|
|
12
12
|
|
|
13
|
-

|
|
14
14
|
|
|
15
|
-

|
|
16
16
|
|
|
17
|
-

|
|
18
18
|
|
|
19
19
|
## Права и субагенты
|
|
20
20
|
|
|
@@ -23,12 +23,13 @@
|
|
|
23
23
|
- **Approval** — штатная карточка DSH: Allow once / Always allow / Reject.
|
|
24
24
|
- **`.dsh/`** создаётся автоматически: agents, commands, rules, hooks, verify, mcp, PROJECT.md.
|
|
25
25
|
- **Worktrees и фоновые агенты.** `project_worktree` создаёт ветку `dsh/<slug>` и отдельную папку `.dsh/worktrees/<slug>`; `project_agent ... worktree=auto background=true` запускает агента в изоляции, а страница **Агенты** показывает worktrees и очередь запусков с кнопкой «Остановить».
|
|
26
|
+
- **Инструкции проекта.** `AGENTS.md` и `CLAUDE.md` читаются иерархически (root → вложенные папки → `.dsh`) с `@import`; MCP roots сообщает серверу корень проекта.
|
|
26
27
|
|
|
27
|
-

|
|
28
29
|
|
|
29
|
-

|
|
30
31
|
|
|
31
|
-
**v2.
|
|
32
|
+
**v2.9.0** · MIT · проверено на DSH `0.2.1-rc.5` и `0.2.2-rc.1` (Windows 11) · без внешних зависимостей и телеметрии
|
|
32
33
|
|
|
33
34
|
**План развития:** [docs/ROADMAP-3.0.md](docs/ROADMAP-3.0.md) — Memory Fabric, семантическое
|
|
34
35
|
слияние, локальный индекс памяти, шифрованные переносы, Memory Hub и npm trusted publishing.
|
|
@@ -116,27 +117,27 @@
|
|
|
116
117
|
- перед каждой синхронизацией проверяется, что репозиторий всё ещё приватный;
|
|
117
118
|
- секреты и PII вычищаются, домашние пути заменяются токеном `%DSH_HOME%`; LLM не вызывается — **0 токенов**.
|
|
118
119
|
|
|
119
|
-

|
|
120
121
|
|
|
121
|
-

|
|
122
123
|
|
|
123
124
|
## Скриншоты
|
|
124
125
|
|
|
125
126
|
### Skills Studio: каталог, стоимость и редактор
|
|
126
127
|
|
|
127
|
-

|
|
128
129
|
|
|
129
|
-

|
|
130
131
|
|
|
131
132
|
### Token Lab: куда уходит контекст
|
|
132
133
|
|
|
133
|
-

|
|
134
135
|
|
|
135
136
|
### Тёмная тема и мобильный
|
|
136
137
|
|
|
137
|
-

|
|
138
139
|
|
|
139
|
-

|
|
140
141
|
|
|
141
142
|
## Окно-напоминание: пиковый тариф
|
|
142
143
|
|
|
@@ -146,11 +147,11 @@ DeepSeek включает двойной тариф в пиковые часы (
|
|
|
146
147
|
- **в окне** — красная карточка: причина, границы окна в местном времени и UTC, живой отсчёт до конца и рекомендация, когда вернуться;
|
|
147
148
|
- **после окна** — карточка исчезает; состояние всегда доступно через `window.__DSH_PEAK_GUARD__.state()`.
|
|
148
149
|
|
|
149
|
-

|
|
150
151
|
|
|
151
|
-

|
|
152
153
|
|
|
153
|
-

|
|
154
155
|
|
|
155
156
|
Подробности и настройки — [plugins/dsh-peak-guard/README.md](plugins/dsh-peak-guard/README.md).
|
|
156
157
|
|
package/client.js
CHANGED
|
@@ -7870,7 +7870,7 @@ var(--dsw-alias-bg-layer-1,#fff);box-shadow:inset 0 1px 0 color-mix(in srgb,#fff
|
|
|
7870
7870
|
if (__kitErrors.length <= 5) console.error("[dsh-desktop-kit] registration failed:", label, message);
|
|
7871
7871
|
};
|
|
7872
7872
|
try {
|
|
7873
|
-
window.__DSH_DESKTOP_KIT__ = { version: "2.
|
|
7873
|
+
window.__DSH_DESKTOP_KIT__ = { version: "2.9.0", parts: __partNames, errors: __kitErrors, ready: false };
|
|
7874
7874
|
} catch {}
|
|
7875
7875
|
const __inject = [];
|
|
7876
7876
|
for (const __part of __parts) {
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
# DSH Desktop Kit 2.9.0 — тест
|
|
2
|
+
|
|
3
|
+
Дата: 2026-11-12.
|
|
4
|
+
|
|
5
|
+
## Project instructions
|
|
6
|
+
|
|
7
|
+
- `AGENTS.md` / `CLAUDE.md` в root, вложенных папках до cwd и `.dsh/`.
|
|
8
|
+
- `@path` imports: внутри проекта, глубина ≤ 5, ≤ 20 файлов, ≤ 32 КБ.
|
|
9
|
+
- Symlink за пределы проекта игнорируется с пометкой.
|
|
10
|
+
- Рендер в `<project-instructions>` с source-атрибутом.
|
|
11
|
+
|
|
12
|
+
## MCP roots
|
|
13
|
+
|
|
14
|
+
- Клиент объявляет `roots` capability для stdio.
|
|
15
|
+
- `roots/list` → корень проекта (file URL + basename).
|
|
16
|
+
- `ping` → `{}`.
|
|
17
|
+
- `sampling/createMessage` и `elicitation/create` → `-32601` с понятным текстом.
|
|
18
|
+
|
|
19
|
+
## Проверки
|
|
20
|
+
|
|
21
|
+
- `tools/instructions-tests.mjs` — OK.
|
|
22
|
+
- `tools/mcp-manager-tests.mjs` — OK, включая roots request.
|
|
23
|
+
- `npm test` — exit 0.
|
|
24
|
+
- `build:client` / `check:client` — OK.
|
|
25
|
+
|
|
26
|
+
## Не входит
|
|
27
|
+
|
|
28
|
+
Sampling, elicitation UI, agent teams, marketplace, IDE bridge, OS sandbox.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-desktop-kit",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.9.0",
|
|
4
4
|
"description": "DeepSeek Harness desktop kit 2.7: 16 plugins and 30 skills — self-applying skills, token lab, Skills Studio, project memory, GitHub and USB memory transfer, guardrails, repo map, checkpoints, plan mode, browser QA, GitHub review, Claude Code-like hooks/agents/commands, Russian UI, peak guard, chat move and profile transfer.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"deepseek-harness",
|
|
@@ -74,7 +74,7 @@
|
|
|
74
74
|
"build:client": "node tools/build-client.mjs",
|
|
75
75
|
"build:skills": "node tools/build-skill-manifest.mjs",
|
|
76
76
|
"check:client": "node tools/check-client.mjs client.js",
|
|
77
|
-
"test": "node tools/smoke-tests.mjs && node tools/memory-tests.mjs && node tools/skills-sync-tests.mjs && node tools/kit-upgrade-tests.mjs && node plugins/dsh-profile-transfer/test/transfer.test.mjs && node --test plugins/dsh-memory-bridge/test/bridge.test.mjs plugins/dsh-memory-bridge/test/github.test.mjs plugins/dsh-memory-bridge/test/merge.test.mjs plugins/dsh-memory-bridge/test/user-specific.test.mjs && node tools/repo-map-tests.mjs && node tools/checkpoints-tests.mjs && node tools/plan-mode-tests.mjs && node tools/browser-qa-tests.mjs && node tools/ui-gate-tests.mjs && node tools/agent-extensions-tests.mjs && node tools/mcp-manager-tests.mjs && node tools/github-review-tests.mjs && node tools/mcp-oauth-tests.mjs && node tools/worktrees-tests.mjs && node tools/background-agents-tests.mjs && node tools/permissions-ui-tests.mjs && node plugins/dsh-guardrails/tools/guardrails-tests.mjs",
|
|
77
|
+
"test": "node tools/smoke-tests.mjs && node tools/memory-tests.mjs && node tools/skills-sync-tests.mjs && node tools/kit-upgrade-tests.mjs && node plugins/dsh-profile-transfer/test/transfer.test.mjs && node --test plugins/dsh-memory-bridge/test/bridge.test.mjs plugins/dsh-memory-bridge/test/github.test.mjs plugins/dsh-memory-bridge/test/merge.test.mjs plugins/dsh-memory-bridge/test/user-specific.test.mjs && node tools/repo-map-tests.mjs && node tools/checkpoints-tests.mjs && node tools/plan-mode-tests.mjs && node tools/browser-qa-tests.mjs && node tools/ui-gate-tests.mjs && node tools/agent-extensions-tests.mjs && node tools/mcp-manager-tests.mjs && node tools/github-review-tests.mjs && node tools/instructions-tests.mjs && node tools/mcp-oauth-tests.mjs && node tools/worktrees-tests.mjs && node tools/background-agents-tests.mjs && node tools/permissions-ui-tests.mjs && node plugins/dsh-guardrails/tools/guardrails-tests.mjs",
|
|
78
78
|
"skills:cost": "node tools/skill-cost.mjs",
|
|
79
79
|
"skills:check": "node tools/skill-cost.mjs --check",
|
|
80
80
|
"release": "node tools/release.mjs"
|
|
@@ -17,6 +17,7 @@ import { createWorktree, removeWorktree, worktreeSummary } from "./lib/worktrees
|
|
|
17
17
|
import { registerChildPolicyHook } from "./lib/policy.js";
|
|
18
18
|
import { registerCommands } from "./lib/commands.js";
|
|
19
19
|
import { registerAgentApi } from "./lib/api.js";
|
|
20
|
+
import { renderProjectInstructions } from "./lib/instructions.js";
|
|
20
21
|
import { ensureGlobalScaffold, ensureProjectScaffold } from "./lib/scaffold.js";
|
|
21
22
|
import { findDshDir, loadAgents, projectFor } from "./lib/project.js";
|
|
22
23
|
|
|
@@ -219,6 +220,24 @@ export function apply(ctx) {
|
|
|
219
220
|
ctx.logger?.warn?.(`[agent-extensions] system prompt registration failed: ${error instanceof Error ? error.message : String(error)}`);
|
|
220
221
|
}
|
|
221
222
|
|
|
223
|
+
try {
|
|
224
|
+
ctx.systemPrompt.context({
|
|
225
|
+
name: "dsh-agent-extensions: project instructions",
|
|
226
|
+
order: 135,
|
|
227
|
+
interpolate: false,
|
|
228
|
+
required: false,
|
|
229
|
+
text: (assemblyContext) => {
|
|
230
|
+
try {
|
|
231
|
+
return renderProjectInstructions(assemblyContext?.agent?.session?.header?.cwd);
|
|
232
|
+
} catch {
|
|
233
|
+
return "";
|
|
234
|
+
}
|
|
235
|
+
},
|
|
236
|
+
});
|
|
237
|
+
} catch (error) {
|
|
238
|
+
ctx.logger?.warn?.(`[agent-extensions] instruction prompt skipped: ${error instanceof Error ? error.message : String(error)}`);
|
|
239
|
+
}
|
|
240
|
+
|
|
222
241
|
try {
|
|
223
242
|
ctx.inject(["commands"], (child) => registerCommands(child));
|
|
224
243
|
} catch (error) {
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Claude Code-style project instructions.
|
|
3
|
+
*
|
|
4
|
+
* Order (lowest → highest priority):
|
|
5
|
+
* <root>/AGENTS.md, <root>/CLAUDE.md,
|
|
6
|
+
* <root>/.dsh/AGENTS.md,
|
|
7
|
+
* nested AGENTS.md/CLAUDE.md from root to session cwd.
|
|
8
|
+
*
|
|
9
|
+
* `@path` lines import another file. Imports stay inside the project root,
|
|
10
|
+
* are depth-limited and total-size limited.
|
|
11
|
+
*/
|
|
12
|
+
import fs from "node:fs";
|
|
13
|
+
import path from "node:path";
|
|
14
|
+
import { projectFor } from "./project.js";
|
|
15
|
+
|
|
16
|
+
const MAX_DEPTH = 5;
|
|
17
|
+
const MAX_BYTES = 32_000;
|
|
18
|
+
const MAX_FILES = 20;
|
|
19
|
+
const IMPORT = /^\s*@([^\s#]+)\s*$/u;
|
|
20
|
+
|
|
21
|
+
function inside(root, file) {
|
|
22
|
+
const relative = path.relative(root, path.resolve(file));
|
|
23
|
+
return relative === "" || (!relative.startsWith("..") && !path.isAbsolute(relative));
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
function readBounded(file, remaining) {
|
|
27
|
+
const stat = fs.statSync(file);
|
|
28
|
+
if (!stat.isFile()) return "";
|
|
29
|
+
if (stat.size > remaining) throw new Error(`instructions: file too large: ${file}`);
|
|
30
|
+
return fs.readFileSync(file, "utf8");
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
function expand(file, root, state, depth = 0, realRoot = root) {
|
|
34
|
+
if (depth > MAX_DEPTH) return `[import depth limit: ${file}]`;
|
|
35
|
+
if (state.files.size >= MAX_FILES) return `[import file limit reached: ${file}]`;
|
|
36
|
+
const resolved = path.resolve(file);
|
|
37
|
+
if (!inside(root, resolved)) return `[import outside project ignored: ${file}]`;
|
|
38
|
+
let real;
|
|
39
|
+
try {
|
|
40
|
+
real = fs.realpathSync(resolved);
|
|
41
|
+
} catch {
|
|
42
|
+
return `[unreadable import: ${path.relative(root, resolved)}]`;
|
|
43
|
+
}
|
|
44
|
+
if (!inside(realRoot, real)) return `[import symlink outside project ignored: ${file}]`;
|
|
45
|
+
if (state.files.has(real)) return `[already imported: ${path.relative(root, real)}]`;
|
|
46
|
+
state.files.add(real);
|
|
47
|
+
let text;
|
|
48
|
+
try {
|
|
49
|
+
text = readBounded(real, MAX_BYTES - state.bytes);
|
|
50
|
+
} catch (error) {
|
|
51
|
+
return `[unreadable import: ${path.relative(root, real)} — ${error instanceof Error ? error.message : String(error)}]`;
|
|
52
|
+
}
|
|
53
|
+
state.bytes += Buffer.byteLength(text, "utf8");
|
|
54
|
+
return text.split(/\r?\n/u).map((line) => {
|
|
55
|
+
const match = IMPORT.exec(line);
|
|
56
|
+
if (!match) return line;
|
|
57
|
+
const next = path.resolve(path.dirname(real), match[1]);
|
|
58
|
+
if (!inside(root, next)) return `[import outside project ignored: ${match[1]}]`;
|
|
59
|
+
return expand(next, root, state, depth + 1, realRoot);
|
|
60
|
+
}).join("\n");
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export function loadProjectInstructions(cwd) {
|
|
64
|
+
const project = projectFor(cwd);
|
|
65
|
+
const root = project.root;
|
|
66
|
+
const candidates = [];
|
|
67
|
+
const seen = new Set();
|
|
68
|
+
const add = (file, scope) => {
|
|
69
|
+
const resolved = path.resolve(file);
|
|
70
|
+
if (seen.has(resolved) || !fs.existsSync(resolved)) return;
|
|
71
|
+
seen.add(resolved);
|
|
72
|
+
candidates.push({ file: resolved, scope });
|
|
73
|
+
};
|
|
74
|
+
const dirs = [];
|
|
75
|
+
let current = path.resolve(cwd || root);
|
|
76
|
+
while (inside(root, current)) {
|
|
77
|
+
dirs.unshift(current);
|
|
78
|
+
if (current === path.resolve(root)) break;
|
|
79
|
+
const parent = path.dirname(current);
|
|
80
|
+
if (parent === current) break;
|
|
81
|
+
current = parent;
|
|
82
|
+
}
|
|
83
|
+
for (const dir of dirs) {
|
|
84
|
+
for (const name of ["AGENTS.md", "CLAUDE.md"]) add(path.join(dir, name), dir === path.resolve(root) ? "project" : "nested");
|
|
85
|
+
}
|
|
86
|
+
for (const name of ["AGENTS.md", "CLAUDE.md"]) {
|
|
87
|
+
add(path.join(project.dsh ?? path.join(root, ".dsh"), name), "dsh");
|
|
88
|
+
}
|
|
89
|
+
const state = { files: new Set(), bytes: 0 };
|
|
90
|
+
const sections = [];
|
|
91
|
+
const realRoot = (() => { try { return fs.realpathSync(root); } catch { return root; } })();
|
|
92
|
+
for (const item of candidates) {
|
|
93
|
+
const text = expand(item.file, root, state, 0, realRoot);
|
|
94
|
+
if (text.trim().length > 0) sections.push({ ...item, text: text.trim() });
|
|
95
|
+
}
|
|
96
|
+
return { root, sections };
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
export function renderProjectInstructions(cwd) {
|
|
100
|
+
const result = loadProjectInstructions(cwd);
|
|
101
|
+
if (result.sections.length === 0) return "";
|
|
102
|
+
const body = result.sections.map((section) => `<instructions source="${section.scope}:${path.relative(result.root, section.file).split(path.sep).join("/")}">\n${section.text}\n</instructions>`).join("\n");
|
|
103
|
+
return `<project-instructions>\n${body}\n</project-instructions>`;
|
|
104
|
+
}
|
|
@@ -29,6 +29,11 @@ class StdioTransport {
|
|
|
29
29
|
this.child = null;
|
|
30
30
|
this.closed = false;
|
|
31
31
|
this.stderr = "";
|
|
32
|
+
this.requestHandler = null;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
setRequestHandler(handler) {
|
|
36
|
+
this.requestHandler = handler;
|
|
32
37
|
}
|
|
33
38
|
|
|
34
39
|
async start() {
|
|
@@ -42,6 +47,18 @@ class StdioTransport {
|
|
|
42
47
|
reader.on("line", (line) => {
|
|
43
48
|
const message = parseJsonRpc(line);
|
|
44
49
|
if (!message) return;
|
|
50
|
+
if (message.method !== undefined && message.id !== undefined) {
|
|
51
|
+
const handler = this.requestHandler;
|
|
52
|
+
Promise.resolve()
|
|
53
|
+
.then(() => handler ? handler(message) : Promise.reject(Object.assign(new Error("method not supported"), { code: -32601 })))
|
|
54
|
+
.then((result) => {
|
|
55
|
+
this.child?.stdin?.write(`${JSON.stringify({ jsonrpc: "2.0", id: message.id, result: result ?? {} })}\n`);
|
|
56
|
+
})
|
|
57
|
+
.catch((error) => {
|
|
58
|
+
this.child?.stdin?.write(`${JSON.stringify({ jsonrpc: "2.0", id: message.id, error: { code: error?.code ?? -32603, message: error instanceof Error ? error.message : String(error) } })}\n`);
|
|
59
|
+
});
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
45
62
|
if (message.id !== undefined && this.pending.has(String(message.id))) {
|
|
46
63
|
const waiter = this.pending.get(String(message.id));
|
|
47
64
|
this.pending.delete(String(message.id));
|
|
@@ -172,11 +189,13 @@ export class McpClient {
|
|
|
172
189
|
|
|
173
190
|
async connect() {
|
|
174
191
|
await this.transport.start?.();
|
|
192
|
+
const canHandle = typeof this.transport.setRequestHandler === "function" && typeof this.config.onServerRequest === "function";
|
|
193
|
+
if (canHandle) this.transport.setRequestHandler(this.config.onServerRequest);
|
|
175
194
|
const result = await this.transport.request(
|
|
176
195
|
"initialize",
|
|
177
196
|
{
|
|
178
197
|
protocolVersion: PROTOCOL_VERSION,
|
|
179
|
-
capabilities: {},
|
|
198
|
+
capabilities: canHandle ? { roots: { listChanged: false } } : {},
|
|
180
199
|
clientInfo: { name: "dsh-mcp-manager", version: "1.0.0" },
|
|
181
200
|
},
|
|
182
201
|
this.config.timeoutMs,
|
|
@@ -3,6 +3,8 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import { McpClient } from "./client.js";
|
|
5
5
|
import { getAccessToken } from "./oauth.js";
|
|
6
|
+
import path from "node:path";
|
|
7
|
+
import { pathToFileURL } from "node:url";
|
|
6
8
|
|
|
7
9
|
function sanitize(value) {
|
|
8
10
|
return String(value ?? "").replace(/[^A-Za-z0-9_-]+/gu, "_").replace(/^_+|_+$/gu, "").slice(0, 48);
|
|
@@ -46,9 +48,24 @@ export class McpManager {
|
|
|
46
48
|
if (this.closed) throw new Error("MCP manager is closed");
|
|
47
49
|
const existing = this.clients.get(server.id);
|
|
48
50
|
if (existing?.client?.connected) return existing;
|
|
51
|
+
const root = path.resolve(server.cwd || process.cwd());
|
|
49
52
|
const client = new McpClient({
|
|
50
53
|
...server,
|
|
51
54
|
tokenProvider: server.url ? () => getAccessToken(server.id, { resource: server.url }).catch(() => null) : undefined,
|
|
55
|
+
onServerRequest: (message) => {
|
|
56
|
+
if (message.method === "roots/list") {
|
|
57
|
+
return {
|
|
58
|
+
roots: [{
|
|
59
|
+
uri: pathToFileURL(root).href,
|
|
60
|
+
name: path.basename(root) || "workspace",
|
|
61
|
+
}],
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
if (message.method === "ping") return {};
|
|
65
|
+
const error = new Error(`${message.method}: not supported by DSH; sampling and elicitation require explicit approval`);
|
|
66
|
+
error.code = -32601;
|
|
67
|
+
throw error;
|
|
68
|
+
},
|
|
52
69
|
}, this.ctx.logger);
|
|
53
70
|
try {
|
|
54
71
|
await client.connect();
|