dsh-desktop-kit 2.16.0 → 2.16.2

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 CHANGED
@@ -1,5 +1,17 @@
1
1
  # Changelog
2
2
 
3
+ ## 2.16.2 (2026-11-12)
4
+
5
+ - **Board lock.** `.dsh/agents/board.lock` (`wx`, 30s stale, 5s timeout) вокруг post/add/claim/done; параллельные агенты больше не теряют сообщения.
6
+ - **Concurrency test.** 4 процесса × 10 сообщений → ровно 40 в board.
7
+ - **Release workflow.** `.github/workflows/publish.yml` с `id-token: write` и `npm publish --provenance`; секрет только `NPM_TOKEN`.
8
+
9
+ ## 2.16.1 (2026-11-12)
10
+
11
+ - **Fix `/api/dsh-integrations/*` 404.** Host plugin now registers routes directly through `connection`, with `ctx.inject` only as fallback; removed the optional `/integrations` command that could abort the injection.
12
+ - **Tests.** Fake host mount asserts all four routes are registered.
13
+ - **UI.** No visual changes; 2.16.0 screenshot remains valid.
14
+
3
15
  ## 2.16.0 (2026-11-12)
4
16
 
5
17
  - **`dsh-integrations`.** 17-й плагин: Marketplace, IDE bridge, sandbox audit.
package/README.md CHANGED
@@ -4,17 +4,17 @@
4
4
 
5
5
  Набор из **17 плагинов и 30 навыков** для DeepSeek Harness 0.2.x: MCP tools/resources/prompts + OAuth 2.1, sampling, elicitation; проектные агенты, worktrees, фон и read-only рой с общей доской; русский интерфейс, автопилот навыков, токен-лаборатория, студия навыков, память проектов, guardrails, карта репозитория, чекпоинты, plan mode, browser QA, GitHub review, hooks/commands и резервные копии профиля.
6
6
 
7
- ![DSH Desktop Kit 2.7](https://unpkg.com/dsh-desktop-kit@2.16.0/docs/images/hero.png)
7
+ ![DSH Desktop Kit 2.7](https://unpkg.com/dsh-desktop-kit@2.16.2/docs/images/hero.png)
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**, **sampling** идёт через approval-карточку DSH, а **elicitation** — через глобальную форму с Accept/Decline.
12
12
 
13
- ![MCP Settings](https://unpkg.com/dsh-desktop-kit@2.16.0/plugins/dsh-mcp-manager/screenshots/settings-1440.png)
13
+ ![MCP Settings](https://unpkg.com/dsh-desktop-kit@2.16.2/plugins/dsh-mcp-manager/screenshots/settings-1440.png)
14
14
 
15
- ![MCP на 390px](https://unpkg.com/dsh-desktop-kit@2.16.0/plugins/dsh-mcp-manager/screenshots/settings-390.png)
15
+ ![MCP на 390px](https://unpkg.com/dsh-desktop-kit@2.16.2/plugins/dsh-mcp-manager/screenshots/settings-390.png)
16
16
 
17
- ![Добавление MCP-сервера](https://unpkg.com/dsh-desktop-kit@2.16.0/plugins/dsh-mcp-manager/screenshots/modal-390.png)
17
+ ![Добавление MCP-сервера](https://unpkg.com/dsh-desktop-kit@2.16.2/plugins/dsh-mcp-manager/screenshots/modal-390.png)
18
18
 
19
19
  ## Агенты, worktrees и рой
20
20
 
@@ -26,17 +26,17 @@
26
26
  - **Живые сообщения** — `team_message` отправляет текст лиду (`to="parent"`) или участнику по run id; копия каждого сообщения остаётся в board.
27
27
  - **Инструкции проекта** — `AGENTS.md`/`CLAUDE.md` иерархически (root → вложенные папки → `.dsh`) с `@import`; MCP roots сообщает корень проекта.
28
28
 
29
- ![Доска команды](https://unpkg.com/dsh-desktop-kit@2.16.0/plugins/dsh-agent-extensions/screenshots/board-1440.png)
29
+ ![Доска команды](https://unpkg.com/dsh-desktop-kit@2.16.2/plugins/dsh-agent-extensions/screenshots/board-1440.png)
30
30
 
31
- ![Доска команды на 390px](https://unpkg.com/dsh-desktop-kit@2.16.0/plugins/dsh-agent-extensions/screenshots/board-390.png)
31
+ ![Доска команды на 390px](https://unpkg.com/dsh-desktop-kit@2.16.2/plugins/dsh-agent-extensions/screenshots/board-390.png)
32
32
 
33
- ![Транскрипт фонового агента](https://unpkg.com/dsh-desktop-kit@2.16.0/plugins/dsh-agent-extensions/screenshots/transcript-1440.png)
33
+ ![Транскрипт фонового агента](https://unpkg.com/dsh-desktop-kit@2.16.2/plugins/dsh-agent-extensions/screenshots/transcript-1440.png)
34
34
 
35
- Транскрипт сохраняется в `.dsh/agents/transcripts/<run>.json` (0600) и доступен после restart.\n\n![Транскрипт на 390px](https://unpkg.com/dsh-desktop-kit@2.16.0/plugins/dsh-agent-extensions/screenshots/transcript-390.png)
35
+ Транскрипт сохраняется в `.dsh/agents/transcripts/<run>.json` (0600) и доступен после restart.\n\n![Транскрипт на 390px](https://unpkg.com/dsh-desktop-kit@2.16.2/plugins/dsh-agent-extensions/screenshots/transcript-390.png)
36
36
 
37
- ![MCP sampling](https://unpkg.com/dsh-desktop-kit@2.16.0/plugins/dsh-mcp-manager/screenshots/sampling-1440.png)
37
+ ![MCP sampling](https://unpkg.com/dsh-desktop-kit@2.16.2/plugins/dsh-mcp-manager/screenshots/sampling-1440.png)
38
38
 
39
- ![MCP elicitation](https://unpkg.com/dsh-desktop-kit@2.16.0/plugins/dsh-mcp-manager/screenshots/elicitation-1440.png)
39
+ ![MCP elicitation](https://unpkg.com/dsh-desktop-kit@2.16.2/plugins/dsh-mcp-manager/screenshots/elicitation-1440.png)
40
40
 
41
41
  ## Интеграции
42
42
 
@@ -46,9 +46,9 @@ Marketplace, IDE bridge и sandbox-аудит — в одном экране **
46
46
  - **IDE bridge** — localhost JSON API (`/health`, `/context`) с bearer-токеном; расширение редактора — отдельный проект.
47
47
  - **Sandbox** — честный аудит: DSH preset + kit guardrails — это политика, не OS sandbox.
48
48
 
49
- ![Интеграции](https://unpkg.com/dsh-desktop-kit@2.16.0/plugins/dsh-integrations/screenshots/integrations-1440.png)
49
+ ![Интеграции](https://unpkg.com/dsh-desktop-kit@2.16.2/plugins/dsh-integrations/screenshots/integrations-1440.png)
50
50
 
51
- ![Интеграции на 390px](https://unpkg.com/dsh-desktop-kit@2.16.0/plugins/dsh-integrations/screenshots/integrations-390.png)
51
+ ![Интеграции на 390px](https://unpkg.com/dsh-desktop-kit@2.16.2/plugins/dsh-integrations/screenshots/integrations-390.png)
52
52
 
53
53
  ## Права и субагенты
54
54
 
@@ -59,11 +59,11 @@ Marketplace, IDE bridge и sandbox-аудит — в одном экране **
59
59
  - **Worktrees и фоновые агенты.** `project_worktree` создаёт ветку `dsh/<slug>` и отдельную папку `.dsh/worktrees/<slug>`; `project_agent ... worktree=auto background=true` запускает агента в изоляции, а страница **Агенты** показывает worktrees и очередь запусков с кнопкой «Остановить».
60
60
  - **Инструкции проекта.** `AGENTS.md` и `CLAUDE.md` читаются иерархически (root → вложенные папки → `.dsh`) с `@import`; MCP roots сообщает серверу корень проекта.
61
61
 
62
- ![Агенты проекта](https://unpkg.com/dsh-desktop-kit@2.16.0/plugins/dsh-agent-extensions/screenshots/agents-1440.png)
62
+ ![Агенты проекта](https://unpkg.com/dsh-desktop-kit@2.16.2/plugins/dsh-agent-extensions/screenshots/agents-1440.png)
63
63
 
64
- ![Права и ограничения](https://unpkg.com/dsh-desktop-kit@2.16.0/plugins/dsh-guardrails/screenshots/permissions-1440.png)
64
+ ![Права и ограничения](https://unpkg.com/dsh-desktop-kit@2.16.2/plugins/dsh-guardrails/screenshots/permissions-1440.png)
65
65
 
66
- **v2.16.0** · MIT · проверено на DSH `0.2.1-rc.5` и `0.2.2-rc.1` (Windows 11) · без внешних зависимостей и телеметрии
66
+ **v2.16.2** · MIT · проверено на DSH `0.2.1-rc.5` и `0.2.2-rc.1` (Windows 11) · без внешних зависимостей и телеметрии
67
67
 
68
68
  **План развития:** [docs/ROADMAP-3.0.md](docs/ROADMAP-3.0.md) — Memory Fabric, семантическое
69
69
  слияние, локальный индекс памяти, шифрованные переносы, Memory Hub и npm trusted publishing.
@@ -158,27 +158,27 @@ Marketplace, IDE bridge и sandbox-аудит — в одном экране **
158
158
  - перед каждой синхронизацией проверяется, что репозиторий всё ещё приватный;
159
159
  - секреты и PII вычищаются, домашние пути заменяются токеном `%DSH_HOME%`; LLM не вызывается — **0 токенов**.
160
160
 
161
- ![Настройки памяти проектов](https://unpkg.com/dsh-desktop-kit@2.16.0/plugins/dsh-memory-bridge/docs/images/settings-light.png)
161
+ ![Настройки памяти проектов](https://unpkg.com/dsh-desktop-kit@2.16.2/plugins/dsh-memory-bridge/docs/images/settings-light.png)
162
162
 
163
- ![Конфликты досье](https://unpkg.com/dsh-desktop-kit@2.16.0/plugins/dsh-memory-bridge/docs/images/conflicts.png)
163
+ ![Конфликты досье](https://unpkg.com/dsh-desktop-kit@2.16.2/plugins/dsh-memory-bridge/docs/images/conflicts.png)
164
164
 
165
165
  ## Скриншоты
166
166
 
167
167
  ### Skills Studio: каталог, стоимость и редактор
168
168
 
169
- ![Каталог навыков](https://unpkg.com/dsh-desktop-kit@2.16.0/plugins/dsh-gkb-ru-ui/screenshots/02-skills-1440-light.png)
169
+ ![Каталог навыков](https://unpkg.com/dsh-desktop-kit@2.16.2/plugins/dsh-gkb-ru-ui/screenshots/02-skills-1440-light.png)
170
170
 
171
- ![Редактор навыка](https://unpkg.com/dsh-desktop-kit@2.16.0/plugins/dsh-gkb-ru-ui/screenshots/03-skills-editor-1440-light.png)
171
+ ![Редактор навыка](https://unpkg.com/dsh-desktop-kit@2.16.2/plugins/dsh-gkb-ru-ui/screenshots/03-skills-editor-1440-light.png)
172
172
 
173
173
  ### Token Lab: куда уходит контекст
174
174
 
175
- ![Токен-лаборатория](https://unpkg.com/dsh-desktop-kit@2.16.0/plugins/dsh-token-lab/screenshots/01-token-lab-1440-light.png)
175
+ ![Токен-лаборатория](https://unpkg.com/dsh-desktop-kit@2.16.2/plugins/dsh-token-lab/screenshots/01-token-lab-1440-light.png)
176
176
 
177
177
  ### Тёмная тема и мобильный
178
178
 
179
- ![Тёмная тема](https://unpkg.com/dsh-desktop-kit@2.16.0/plugins/dsh-gkb-ru-ui/screenshots/04-skills-1440-dark.png)
179
+ ![Тёмная тема](https://unpkg.com/dsh-desktop-kit@2.16.2/plugins/dsh-gkb-ru-ui/screenshots/04-skills-1440-dark.png)
180
180
 
181
- ![Каталог навыков на 390 px](https://unpkg.com/dsh-desktop-kit@2.16.0/plugins/dsh-gkb-ru-ui/screenshots/05-skills-390-light.png)
181
+ ![Каталог навыков на 390 px](https://unpkg.com/dsh-desktop-kit@2.16.2/plugins/dsh-gkb-ru-ui/screenshots/05-skills-390-light.png)
182
182
 
183
183
  ## Окно-напоминание: пиковый тариф
184
184
 
@@ -188,11 +188,11 @@ DeepSeek включает двойной тариф в пиковые часы (
188
188
  - **в окне** — красная карточка: причина, границы окна в местном времени и UTC, живой отсчёт до конца и рекомендация, когда вернуться;
189
189
  - **после окна** — карточка исчезает; состояние всегда доступно через `window.__DSH_PEAK_GUARD__.state()`.
190
190
 
191
- ![Окно-напоминание: светлая тема](https://unpkg.com/dsh-desktop-kit@2.16.0/plugins/dsh-peak-guard/screenshots/03-peak-card-1440-light.png)
191
+ ![Окно-напоминание: светлая тема](https://unpkg.com/dsh-desktop-kit@2.16.2/plugins/dsh-peak-guard/screenshots/03-peak-card-1440-light.png)
192
192
 
193
- ![Окно-напоминание: тёмная тема](https://unpkg.com/dsh-desktop-kit@2.16.0/plugins/dsh-peak-guard/screenshots/04-peak-card-1440-dark.png)
193
+ ![Окно-напоминание: тёмная тема](https://unpkg.com/dsh-desktop-kit@2.16.2/plugins/dsh-peak-guard/screenshots/04-peak-card-1440-dark.png)
194
194
 
195
- ![Окно-напоминание на 390 px](https://unpkg.com/dsh-desktop-kit@2.16.0/plugins/dsh-peak-guard/screenshots/05-peak-card-390-light.png)
195
+ ![Окно-напоминание на 390 px](https://unpkg.com/dsh-desktop-kit@2.16.2/plugins/dsh-peak-guard/screenshots/05-peak-card-390-light.png)
196
196
 
197
197
  Подробности и настройки — [plugins/dsh-peak-guard/README.md](plugins/dsh-peak-guard/README.md).
198
198
 
package/client.js CHANGED
@@ -8253,7 +8253,7 @@ var(--dsw-alias-bg-layer-1,#fff);box-shadow:inset 0 1px 0 color-mix(in srgb,#fff
8253
8253
  if (__kitErrors.length <= 5) console.error("[dsh-desktop-kit] registration failed:", label, message);
8254
8254
  };
8255
8255
  try {
8256
- window.__DSH_DESKTOP_KIT__ = { version: "2.16.0", parts: __partNames, errors: __kitErrors, ready: false };
8256
+ window.__DSH_DESKTOP_KIT__ = { version: "2.16.2", parts: __partNames, errors: __kitErrors, ready: false };
8257
8257
  } catch {}
8258
8258
  const __inject = [];
8259
8259
  for (const __part of __parts) {
@@ -0,0 +1,16 @@
1
+ # DSH Desktop Kit 2.16.1 — тест
2
+
3
+ Дата: 2026-11-12.
4
+
5
+ ## Fix
6
+
7
+ - `/api/dsh-integrations/status|install|bridge-start|bridge-stop` 404.
8
+ - Причина: API регистрировался только через `ctx.inject(["connection"])`; хост-плагин мог не дойти до колбэка.
9
+ - Теперь: прямой `ctx.get("connection")` + fallback `inject`.
10
+ - Удалена необязательная `/integrations` команда, которая могла прервать inject.
11
+
12
+ ## Проверки
13
+
14
+ - `integrations-tests` — marketplace, bridge, fake mount routes — OK.
15
+ - `npm test` — exit 0.
16
+ - build/check — OK.
@@ -0,0 +1,21 @@
1
+ # DSH Desktop Kit 2.16.2 — тест
2
+
3
+ Дата: 2026-11-12.
4
+
5
+ ## Board lock
6
+
7
+ - `board.lock` через `open(..., "wx")`.
8
+ - Stale lock старше 30 с удаляется.
9
+ - Таймаут ожидания 5 с.
10
+ - `postMessage`, `addTask`, `updateTask` — под lock.
11
+ - 4 параллельных процесса × 10 сообщений = 40, без потерь.
12
+
13
+ ## Release
14
+
15
+ - GitHub Actions `publish.yml`, provenance, `NPM_TOKEN`.
16
+
17
+ ## Проверки
18
+
19
+ - `team-board-tests` — OK, включая concurrency.
20
+ - `npm test` — exit 0.
21
+ - build/check — OK.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "dsh-desktop-kit",
3
- "version": "2.16.0",
4
- "description": "DeepSeek Harness desktop kit 2.16.0: 16 plugins and 30 skills — MCP tools/resources/prompts with OAuth 2.1, sampling and elicitation, project agents, git worktrees, background runs and a read-only/writer swarm with a shared board, plus self-applying skills, token lab, Skills Studio, project memory, guardrails, repo map, checkpoints, plan mode, browser QA, GitHub review, hooks/commands, Russian UI and profile transfer. Includes local marketplace, localhost IDE bridge and an honest sandbox audit.",
3
+ "version": "2.16.2",
4
+ "description": "DeepSeek Harness desktop kit 2.16.2: 16 plugins and 30 skills — MCP tools/resources/prompts with OAuth 2.1, sampling and elicitation, project agents, git worktrees, background runs and a read-only/writer swarm with a shared board, plus self-applying skills, token lab, Skills Studio, project memory, guardrails, repo map, checkpoints, plan mode, browser QA, GitHub review, hooks/commands, Russian UI and profile transfer. Includes local marketplace, localhost IDE bridge and an honest sandbox audit.",
5
5
  "keywords": [
6
6
  "deepseek-harness",
7
7
  "dsh",
@@ -51,12 +51,39 @@ function projectRoot(cwd) {
51
51
  return projectFor(cwd || process.cwd()).root;
52
52
  }
53
53
 
54
+ function withLock(root, operation) {
55
+ const dir = path.join(root, ".dsh", "agents");
56
+ fs.mkdirSync(dir, { recursive: true });
57
+ const lock = path.join(dir, "board.lock");
58
+ const started = Date.now();
59
+ const sleeper = new Int32Array(new SharedArrayBuffer(4));
60
+ while (true) {
61
+ try {
62
+ const fd = fs.openSync(lock, "wx");
63
+ try {
64
+ fs.writeFileSync(fd, `${process.pid}\n`, "utf8");
65
+ return operation();
66
+ } finally {
67
+ try { fs.closeSync(fd); } catch { /* best effort */ }
68
+ try { fs.unlinkSync(lock); } catch { /* best effort */ }
69
+ }
70
+ } catch (error) {
71
+ if (error?.code !== "EEXIST") throw error;
72
+ try {
73
+ const age = Date.now() - fs.statSync(lock).mtimeMs;
74
+ if (age > 30_000) fs.unlinkSync(lock);
75
+ } catch { /* lock vanished */ }
76
+ if (Date.now() - started > 5_000) throw new Error("board is busy; lock timeout");
77
+ Atomics.wait(sleeper, 0, 0, 25);
78
+ }
79
+ }
80
+ }
81
+
54
82
  export function postMessage(cwd, { teamId = "", from = "", to = "", text = "" } = {}) {
55
83
  const clean = redact(text).trim();
56
84
  if (!clean) throw new Error("board message text is required");
57
85
  if (clean.length > MAX_TEXT) throw new Error("board message is too long");
58
86
  const root = projectRoot(cwd);
59
- const board = read(root);
60
87
  const message = {
61
88
  id: crypto.randomUUID(),
62
89
  teamId: String(teamId),
@@ -65,9 +92,12 @@ export function postMessage(cwd, { teamId = "", from = "", to = "", text = "" }
65
92
  text: clean,
66
93
  createdAt: new Date().toISOString(),
67
94
  };
68
- board.messages.push(message);
69
- board.messages = board.messages.slice(-MAX_MESSAGES);
70
- write(root, board);
95
+ withLock(root, () => {
96
+ const board = read(root);
97
+ board.messages.push(message);
98
+ board.messages = board.messages.slice(-MAX_MESSAGES);
99
+ write(root, board);
100
+ });
71
101
  return { root, message };
72
102
  }
73
103
 
@@ -105,9 +135,7 @@ export function addTask(cwd, { teamId = "", title = "", owner = "", dependsOn =
105
135
  const clean = redact(title).trim();
106
136
  if (!clean) throw new Error("board task title is required");
107
137
  const root = projectRoot(cwd);
108
- const board = read(root);
109
138
  const id = crypto.randomUUID();
110
- const dependencies = validateDependencies(board.tasks, id, Array.isArray(dependsOn) ? dependsOn : []);
111
139
  const task = {
112
140
  id,
113
141
  teamId: String(teamId),
@@ -115,36 +143,45 @@ export function addTask(cwd, { teamId = "", title = "", owner = "", dependsOn =
115
143
  owner: String(owner),
116
144
  status: "open",
117
145
  priority: ["low", "normal", "high"].includes(priority) ? priority : "normal",
118
- dependsOn: dependencies,
146
+ dependsOn: [],
119
147
  createdAt: new Date().toISOString(),
120
148
  updatedAt: new Date().toISOString(),
121
149
  };
122
- board.tasks.push(task);
123
- board.tasks = board.tasks.slice(-MAX_TASKS);
124
- write(root, board);
125
- return { root, task: { ...task, ...taskState(board.tasks, task) } };
150
+ withLock(root, () => {
151
+ const board = read(root);
152
+ task.dependsOn = validateDependencies(board.tasks, id, Array.isArray(dependsOn) ? dependsOn : []);
153
+ board.tasks.push(task);
154
+ board.tasks = board.tasks.slice(-MAX_TASKS);
155
+ write(root, board);
156
+ task.state = taskState(board.tasks, task);
157
+ });
158
+ return { root, task: { ...task, ...(task.state ?? {}) } };
126
159
  }
127
160
 
128
161
  export function updateTask(cwd, { id = "", status = "", owner = "" } = {}) {
129
162
  if (!["open", "claimed", "done"].includes(status)) throw new Error("board task status must be open, claimed or done");
130
163
  const root = projectRoot(cwd);
131
- const board = read(root);
132
- const task = board.tasks.find((item) => item.id === String(id));
133
- if (!task) throw new Error(`board task not found: ${id}`);
134
- const state = taskState(board.tasks, task);
135
- if (status === "claimed") {
136
- if (task.status === "claimed" && task.owner && owner && task.owner !== owner) throw new Error(`board task already claimed by ${task.owner}`);
137
- if (!state.ready) throw new Error(`board task is blocked by: ${state.blockedBy.join(", ")}`);
138
- task.status = "claimed";
139
- task.owner = owner || task.owner;
140
- } else if (status === "done") {
141
- if (task.owner && owner && task.owner !== owner) throw new Error(`board task is owned by ${task.owner}`);
142
- if (!state.ready) throw new Error(`board task cannot be done before: ${state.blockedBy.join(", ")}`);
143
- task.status = "done";
144
- } else {
145
- task.status = "open";
146
- }
147
- task.updatedAt = new Date().toISOString();
148
- write(root, board);
149
- return { root, task: { ...task, ...taskState(board.tasks, task) } };
164
+ let result;
165
+ withLock(root, () => {
166
+ const board = read(root);
167
+ const task = board.tasks.find((item) => item.id === String(id));
168
+ if (!task) throw new Error(`board task not found: ${id}`);
169
+ const state = taskState(board.tasks, task);
170
+ if (status === "claimed") {
171
+ if (task.status === "claimed" && task.owner && owner && task.owner !== owner) throw new Error(`board task already claimed by ${task.owner}`);
172
+ if (!state.ready) throw new Error(`board task is blocked by: ${state.blockedBy.join(", ")}`);
173
+ task.status = "claimed";
174
+ task.owner = owner || task.owner;
175
+ } else if (status === "done") {
176
+ if (task.owner && owner && task.owner !== owner) throw new Error(`board task is owned by ${task.owner}`);
177
+ if (!state.ready) throw new Error(`board task cannot be done before: ${state.blockedBy.join(", ")}`);
178
+ task.status = "done";
179
+ } else {
180
+ task.status = "open";
181
+ }
182
+ task.updatedAt = new Date().toISOString();
183
+ write(root, board);
184
+ result = { ...task, ...taskState(board.tasks, task) };
185
+ });
186
+ return { root, task: result };
150
187
  }
@@ -38,28 +38,26 @@ function toolDefinition(ctx, bridge) {
38
38
 
39
39
  export function apply(ctx) {
40
40
  const bridge = new IdeBridge();
41
- const disposers = [];
42
- ctx.effect(() => () => { for (const dispose of disposers) { try { dispose(); } catch { /* best effort */ } } void bridge.stop(); }, "integrations: cleanup");
41
+ ctx.effect(() => () => { void bridge.stop(); }, "integrations: cleanup");
43
42
  try {
44
43
  ctx.effect(() => ctx.tools.register(toolDefinition(ctx, bridge)), "integrations: status tool");
45
44
  } catch (error) {
46
45
  ctx.logger?.warn?.(`[integrations] tool registration failed: ${error instanceof Error ? error.message : String(error)}`);
47
46
  }
48
47
  try {
49
- ctx.inject(["connection"], (child) => registerIntegrationApi(child, bridge));
48
+ registerIntegrationApi(ctx, bridge);
50
49
  } catch (error) {
51
- ctx.logger?.warn?.(`[integrations] api skipped: ${error instanceof Error ? error.message : String(error)}`);
52
- }
53
- try {
54
- ctx.inject(["commands"], (child) => {
55
- const dispose = child.commands.register({
56
- name: "integrations",
57
- description: "Marketplace, IDE bridge and sandbox audit",
58
- async execute() {
59
- return inspectCatalog(projectFrom()).map((entry) => `${entry.installed ? "✓" : "○"} ${entry.id} ${entry.version}`).join("\n") || "Marketplace catalog is empty.";
60
- },
50
+ ctx.logger?.warn?.(`[integrations] direct api registration failed, retrying with connection injection: ${error instanceof Error ? error.message : String(error)}`);
51
+ try {
52
+ ctx.inject(["connection"], (child) => {
53
+ try {
54
+ registerIntegrationApi(child, bridge);
55
+ } catch (cause) {
56
+ child.logger?.warn?.(`[integrations] api registration failed: ${cause instanceof Error ? cause.message : String(cause)}`);
57
+ }
61
58
  });
62
- if (typeof dispose === "function") disposers.push(dispose);
63
- });
64
- } catch { /* commands are optional */ }
59
+ } catch (cause) {
60
+ ctx.logger?.warn?.(`[integrations] api skipped: ${cause instanceof Error ? cause.message : String(cause)}`);
61
+ }
62
+ }
65
63
  }
@@ -18,6 +18,8 @@ async function envelope(request) {
18
18
  }
19
19
 
20
20
  export function registerIntegrationApi(ctx, bridge) {
21
+ const connection = ctx.connection ?? ctx.get?.("connection");
22
+ if (!connection?.rpc?.register) throw new Error("connection service is unavailable");
21
23
  const projectRoot = (payload) => payload?.cwd || ctx.get?.("sessions")?.list?.().at(-1)?.header?.cwd || process.cwd();
22
24
  const sandbox = () => ({
23
25
  enforcement: false,
@@ -47,5 +49,5 @@ export function registerIntegrationApi(ctx, bridge) {
47
49
  operation("bridge-start", async (payload, root) => bridge.start(async () => ({ project: root, pid: process.pid, time: new Date().toISOString() }))),
48
50
  operation("bridge-stop", () => bridge.stop()),
49
51
  ];
50
- return routes.map((route) => ctx.connection.rpc.register(route));
52
+ return routes.map((route) => connection.rpc.register(route));
51
53
  }
@@ -121,6 +121,77 @@ class HttpTransport {
121
121
  this.config = config;
122
122
  this.sessionId = "";
123
123
  this.pending = new Map();
124
+ this.requestHandler = null;
125
+ }
126
+
127
+ setRequestHandler(handler) {
128
+ this.requestHandler = handler;
129
+ }
130
+
131
+ async respond(id, payload) {
132
+ const token = typeof this.config.tokenProvider === "function" ? await this.config.tokenProvider() : "";
133
+ await fetch(this.config.url, {
134
+ method: "POST",
135
+ headers: {
136
+ "content-type": "application/json",
137
+ accept: "application/json, text/event-stream",
138
+ ...(this.sessionId ? { "mcp-session-id": this.sessionId } : {}),
139
+ ...(token ? { authorization: `Bearer ${token}` } : {}),
140
+ ...this.config.headers,
141
+ },
142
+ body: JSON.stringify({ jsonrpc: "2.0", id, ...payload }),
143
+ }).catch(() => {});
144
+ }
145
+
146
+ async handleServerRequest(message) {
147
+ try {
148
+ const handler = this.requestHandler;
149
+ const result = handler ? await handler(message) : await Promise.reject(Object.assign(new Error("method not supported"), { code: -32601 }));
150
+ await this.respond(message.id, { result: result ?? {} });
151
+ } catch (error) {
152
+ await this.respond(message.id, { error: { code: error?.code ?? -32603, message: error instanceof Error ? error.message : String(error) } });
153
+ }
154
+ }
155
+
156
+ async readSse(response) {
157
+ const reader = response.body.getReader();
158
+ const decoder = new TextDecoder();
159
+ let buffer = "";
160
+ const consume = async (event) => {
161
+ for (const line of event.split(/\r?\n/u)) {
162
+ if (!line.startsWith("data:")) continue;
163
+ const message = parseJsonRpc(line.slice(5).trim());
164
+ if (!message) continue;
165
+ if (message.method !== undefined && message.id !== undefined) {
166
+ void this.handleServerRequest(message);
167
+ continue;
168
+ }
169
+ if (message.id === undefined) continue;
170
+ if (message.error) throw new Error(message.error.message || "MCP error");
171
+ if (message.result !== undefined) return { found: true, value: message.result };
172
+ }
173
+ return { found: false };
174
+ };
175
+ while (true) {
176
+ const { done, value } = await reader.read();
177
+ if (done) break;
178
+ buffer += decoder.decode(value, { stream: true });
179
+ let boundary;
180
+ while ((boundary = buffer.search(/\r?\n\r?\n/u)) >= 0) {
181
+ const event = buffer.slice(0, boundary);
182
+ buffer = buffer.slice(boundary).replace(/^\r?\n\r?\n/u, "");
183
+ const result = await consume(event);
184
+ if (result.found) {
185
+ try { await reader.cancel(); } catch { /* best effort */ }
186
+ return result.value;
187
+ }
188
+ }
189
+ }
190
+ if (buffer.trim()) {
191
+ const result = await consume(buffer);
192
+ if (result.found) return result.value;
193
+ }
194
+ throw new Error("MCP HTTP: no JSON-RPC response in event stream");
124
195
  }
125
196
 
126
197
  async request(method, params, timeoutMs) {
@@ -143,21 +214,16 @@ class HttpTransport {
143
214
  const sessionId = response.headers.get("mcp-session-id");
144
215
  if (sessionId) this.sessionId = sessionId;
145
216
  if (!response.ok) throw new Error(`MCP HTTP ${response.status}: ${(await response.text()).slice(0, 500)}`);
217
+ const contentType = response.headers.get("content-type") || "";
218
+ if (contentType.includes("text/event-stream")) return await this.readSse(response);
146
219
  const text = await response.text();
147
220
  if (text.trim() === "") return undefined;
148
- const contentType = response.headers.get("content-type") || "";
149
- if (contentType.includes("text/event-stream")) {
150
- for (const line of text.split(/\r?\n/u)) {
151
- if (!line.startsWith("data:")) continue;
152
- const message = parseJsonRpc(line.slice(5).trim());
153
- if (!message || message.id === undefined) continue;
154
- if (message.error) throw new Error(message.error.message || "MCP error");
155
- if (message.result !== undefined) return message.result;
156
- }
157
- throw new Error("MCP HTTP: no JSON-RPC response in event stream");
158
- }
159
221
  const message = parseJsonRpc(text);
160
222
  if (!message) throw new Error("MCP HTTP: invalid JSON response");
223
+ if (message.method !== undefined && message.id !== undefined) {
224
+ void this.handleServerRequest(message);
225
+ throw new Error("MCP HTTP: server request without a tool result");
226
+ }
161
227
  if (message.error) throw new Error(message.error.message || "MCP error");
162
228
  return message.result;
163
229
  } finally {