dsh-desktop-kit 2.23.17 → 2.23.19

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,3 +1,18 @@
1
+ ## 2.23.19 (2026-11-13)
2
+
3
+ - **Flash по умолчанию.** Все роли стартуют на `deepseek-flash` с high effort; pro не подставляется автоматически.
4
+ - **Pro только вручную.** `model: deepseek-v4-pro` в роли или `project_agent ... model=deepseek-v4-pro`; если провайдер отклоняет pro, запуск повторяется на flash.
5
+ - **Reason.** DSH-аккаунт с одним flash не мог запускать дочерних агентов с pro-default.
6
+ - **Tests.** default flash, explicit pro, fallback classifier.
7
+
8
+ ## 2.23.18 (2026-11-13)
9
+
10
+ - **Russian routing:** чистые regex для research/critical/simple в `swarm.js`; русские задачи снова попадают в auto-swarm и effort routing.
11
+ - **Auto-swarm:** lead исключается до `maxAgents`; preset выбирается по research/audit, fallback не оставляет одного участника.
12
+ - **SSRF:** research-ledger блокирует private IPv6, CGNAT, IPv4-mapped и redirect на приватный адрес; DNS-проверка перед fetch.
13
+ - **MCP defaults:** `mcpBootstrap.trusted` по умолчанию `false`; trust только явно.
14
+ - **Tests:** русский routing, research preset, SSRF ranges, MCP default.
15
+
1
16
  - **2.23.17 (2026-11-12):** MCP trust UI now updates optimistically; button becomes «Доверено» when trusted, and `kit.settings.json` mcpBootstrap is kept in sync with the host bootstrap state. README полностью переписан и приведён к 2.23.17.
2
17
  - **2.23.16 (2026-11-12):** fix Settings → Agents save path — `settings.update` now has its own RPC route (HTTP 404 resolved); toggles in Kit controls persist.
3
18
  - **2.23.15 (2026-11-12):** Worktrees UI no longer shows a red error for non-git workspaces; it explains that agents/swarm work without worktrees and suggests opening a specific git repository for worktree mode.
package/README.md CHANGED
@@ -1,19 +1,19 @@
1
- # DSH Desktop Kit 2.23.17
1
+ # DSH Desktop Kit 2.23.19
2
2
 
3
3
  **Агенты, рой и MCP для DeepSeek Harness — с доказательствами, а не с обещаниями.**
4
4
 
5
5
  18 плагинов и 30 навыков в одном npm-пакете: проектные роли, read-only рой с общей доской, research-ledger с проверкой источников, MCP с OAuth/sampling/elicitation, локальный marketplace, IDE bridge, guardrails, память, checkpoints, browser QA и русский интерфейс.
6
6
 
7
- ![DSH Desktop Kit](https://unpkg.com/dsh-desktop-kit@2.23.17/docs/images/hero.png)
7
+ ![DSH Desktop Kit](https://unpkg.com/dsh-desktop-kit@2.23.19/docs/images/hero.png)
8
8
 
9
9
  ---
10
10
 
11
11
  ## Быстрый старт
12
12
 
13
13
  ```powershell
14
- # в DSH: Плагины → Add plugin → dsh-desktop-kit@2.23.17
14
+ # в DSH: Плагины → Add plugin → dsh-desktop-kit@2.23.19
15
15
  # или из терминала:
16
- dsh plugin --profile desktop add dsh-desktop-kit@2.23.17
16
+ dsh plugin --profile desktop add dsh-desktop-kit@2.23.19
17
17
  ```
18
18
 
19
19
  После установки перезапустите окно DSH (`Ctrl+R`).
@@ -30,10 +30,12 @@ node tools/e2e-http.mjs # живой web + API
30
30
 
31
31
  ---
32
32
 
33
- ## Что нового в 2.23.17
33
+ ## Что нового в 2.23.18
34
34
 
35
35
  | Версия | Изменение |
36
36
  |---|---|
37
+ | **2.23.19** | Flash по умолчанию; pro только при ручном выборе |
38
+ | **2.23.18** | Русский routing, SSRF-защита, MCP trust default `false` |
37
39
  | **2.23.17** | MCP trust UI обновляется оптимистично; `kit.settings.json` синхронизирован с bootstrap |
38
40
  | **2.23.16** | `settings.update` RPC — сохранение Kit controls без 404 |
39
41
  | **2.23.15** | Worktrees UI объясняет non-git проект вместо красной ошибки |
@@ -58,13 +60,13 @@ node tools/e2e-http.mjs # живой web + API
58
60
 
59
61
  | Роль | Права | Модель по умолчанию | Задача |
60
62
  |---|---|---|---|
61
- | `coordinator` | read-only | pro / high | lead, план, распределение задач |
62
- | `researcher` | read-only | pro / high | поиск, источники, факты |
63
- | `reviewer` | read-only | pro / high | дифф, риски, findings |
64
- | `verifier` | read-only | pro / high | проверка evidence и PASS/FAIL |
65
- | `synthesizer` | read-only | pro / high | сборка результата |
66
- | `security` | read-only | pro / high | OWASP, секреты, доступ |
67
- | `performance` | read-only | pro / high | узкие места, стоимость |
63
+ | `coordinator` | read-only | flash / high | lead, план, распределение задач |
64
+ | `researcher` | read-only | flash / high | поиск, источники, факты |
65
+ | `reviewer` | read-only | flash / high | дифф, риски, findings |
66
+ | `verifier` | read-only | flash / high | проверка evidence и PASS/FAIL |
67
+ | `synthesizer` | read-only | flash / high | сборка результата |
68
+ | `security` | read-only | flash / high | OWASP, секреты, доступ |
69
+ | `performance` | read-only | flash / high | узкие места, стоимость |
68
70
  | `tester` | workspace-write | flash / low | тесты, воспроизведение, проверки |
69
71
 
70
72
  Роль — это Markdown с frontmatter:
@@ -75,13 +77,13 @@ name: reviewer
75
77
  description: Ревью диффа и рисков
76
78
  tools: read, grep, glob, team_board, team_message
77
79
  permission: read-only
78
- model: deepseek-v4-pro
80
+ model: deepseek-flash # pro — только вручную
79
81
  effort: high
80
82
  ---
81
83
  Ты ревьюер. Возвращай только findings с путями и приоритетом.
82
84
  ```
83
85
 
84
- `tools`, `permission` и `model` **реально ограничивают** дочернего агента.
86
+ `tools`, `permission` и `model` **реально ограничивают** дочернего агента. По умолчанию все роли идут на `deepseek-flash` + high effort; `deepseek-v4-pro` включается только вручную через `model:` или `project_agent ... model=deepseek-v4-pro`.
85
87
 
86
88
  ### Команды
87
89
 
@@ -187,9 +189,9 @@ research_ledger action=summary
187
189
 
188
190
  Кнопка **«Проверить и доверять»** показывает команду/URL и требует подтверждения. После trust сервер получает доступ к tools; это осознанное действие, не «по умолчанию».
189
191
 
190
- ![MCP Settings](https://unpkg.com/dsh-desktop-kit@2.23.17/plugins/dsh-mcp-manager/screenshots/settings-1440.png)
192
+ ![MCP Settings](https://unpkg.com/dsh-desktop-kit@2.23.19/plugins/dsh-mcp-manager/screenshots/settings-1440.png)
191
193
 
192
- ![MCP на 390px](https://unpkg.com/dsh-desktop-kit@2.23.17/plugins/dsh-mcp-manager/screenshots/settings-390.png)
194
+ ![MCP на 390px](https://unpkg.com/dsh-desktop-kit@2.23.19/plugins/dsh-mcp-manager/screenshots/settings-390.png)
193
195
 
194
196
  ---
195
197
 
@@ -218,11 +220,11 @@ research_ledger action=summary
218
220
  - **Настройки → Память проектов** — досье, синхронизация;
219
221
  - **Настройки → Перенос и резервные копии** — профиль, навыки, сессии.
220
222
 
221
- ![Агенты](https://unpkg.com/dsh-desktop-kit@2.23.17/plugins/dsh-agent-extensions/screenshots/agents-1440.png)
223
+ ![Агенты](https://unpkg.com/dsh-desktop-kit@2.23.19/plugins/dsh-agent-extensions/screenshots/agents-1440.png)
222
224
 
223
- ![Доска команды](https://unpkg.com/dsh-desktop-kit@2.23.17/plugins/dsh-agent-extensions/screenshots/board-1440.png)
225
+ ![Доска команды](https://unpkg.com/dsh-desktop-kit@2.23.19/plugins/dsh-agent-extensions/screenshots/board-1440.png)
224
226
 
225
- ![Транскрипт](https://unpkg.com/dsh-desktop-kit@2.23.17/plugins/dsh-agent-extensions/screenshots/transcript-1440.png)
227
+ ![Транскрипт](https://unpkg.com/dsh-desktop-kit@2.23.19/plugins/dsh-agent-extensions/screenshots/transcript-1440.png)
226
228
 
227
229
  ---
228
230
 
@@ -236,7 +238,7 @@ research_ledger action=summary
236
238
  - **sandbox_run** — Windows Job Objects: memory/process/time limits, kill-on-close. **Process containment, не filesystem/network isolation.**
237
239
  - **HTTP API** — `/api/dsh-integrations/*`, проверен живым web-профилем: auth-cookie → `POST status` → 200.
238
240
 
239
- ![Интеграции](https://unpkg.com/dsh-desktop-kit@2.23.17/plugins/dsh-integrations/screenshots/integrations-1440.png)
241
+ ![Интеграции](https://unpkg.com/dsh-desktop-kit@2.23.19/plugins/dsh-integrations/screenshots/integrations-1440.png)
240
242
 
241
243
  ---
242
244
 
@@ -256,7 +258,7 @@ research_ledger action=summary
256
258
  ### Из npm
257
259
 
258
260
  ```powershell
259
- dsh plugin --profile desktop add dsh-desktop-kit@2.23.17
261
+ dsh plugin --profile desktop add dsh-desktop-kit@2.23.19
260
262
  ```
261
263
 
262
264
  ### Из локальной папки
@@ -312,7 +314,7 @@ node tools/e2e-smoke.mjs # профиль
312
314
  node tools/e2e-http.mjs # живой API
313
315
  node tools/sandbox-tests.mjs # Job Objects
314
316
  node tools/marketplace-remote-tests.mjs
315
- npm run verify:release -- 2.23.17
317
+ npm run verify:release -- 2.23.19
316
318
  ```
317
319
 
318
320
  UI: `browser_qa audit` на 390/768/1440, overflow/console/markup.
@@ -363,4 +365,4 @@ DevTools Console: `window.__DSH_DESKTOP_KIT__` → `version`, `parts`, `errors`.
363
365
 
364
366
  MIT. Сделано для DeepSeek Harness; без внешних зависимостей и телеметрии.
365
367
 
366
- **2.23.17** · 18 плагинов · 30 навыков · Windows 11 · DSH 0.2.x
368
+ **2.23.18** · 18 плагинов · 30 навыков · Windows 11 · DSH 0.2.x
package/client.js CHANGED
@@ -8381,7 +8381,7 @@ var(--dsw-alias-bg-layer-1,#fff);box-shadow:inset 0 1px 0 color-mix(in srgb,#fff
8381
8381
  if (__kitErrors.length <= 5) console.error("[dsh-desktop-kit] registration failed:", label, message);
8382
8382
  };
8383
8383
  try {
8384
- window.__DSH_DESKTOP_KIT__ = { version: "2.23.17", parts: __partNames, errors: __kitErrors, ready: false };
8384
+ window.__DSH_DESKTOP_KIT__ = { version: "2.23.19", parts: __partNames, errors: __kitErrors, ready: false };
8385
8385
  } catch {}
8386
8386
  const __inject = [];
8387
8387
  for (const __part of __parts) {
@@ -0,0 +1,28 @@
1
+ # DSH Desktop Kit 2.23.18 — аудит и исправления
2
+
3
+ Дата: 2026-11-13.
4
+
5
+ ## Найдено
6
+
7
+ - русские regex в auto-swarm были записаны как mojibake → русские задачи не получали research/critical score;
8
+ - fallback auto-swarm мог включить lead в members и после фильтра оставить одного участника;
9
+ - preset выбирался первый, а не research/audit;
10
+ - research-ledger не блокировал private IPv6, CGNAT, IPv4-mapped и redirect на приватный адрес;
11
+ - `mcpBootstrap.trusted` по умолчанию был `true`, хотя bootstrap ставит `false`.
12
+
13
+ ## Исправлено
14
+
15
+ - чистые русские regex: `провер`, `безопас`, `архитект`, `последн`, `актуальн`, `документац`, `опечат` и т.д.;
16
+ - lead исключается до slice; preset по research/audit; fallback требует 2 не-lead роли;
17
+ - SSRF: private IPv6 (`fc/fd/fe8…`), CGNAT `100.64/10`, IPv4-mapped, DNS lookup и redirect validation;
18
+ - MCP trusted default `false`.
19
+
20
+ ## Проверки
21
+
22
+ - `npm test` — exit 0.
23
+ - `agent-extensions-tests` — routing, preset, MCP default.
24
+ - `swarm-tests` — русская задача и research preset.
25
+ - `research-eval` — 6/6.
26
+ - `citation-eval` — 3/3.
27
+ - `e2e-http` — живой DSH, 200.
28
+ - build/check — OK.
@@ -0,0 +1,24 @@
1
+ # DSH Desktop Kit 2.23.19 — pro/flash
2
+
3
+ Дата: 2026-11-13.
4
+
5
+ ## Проблема
6
+
7
+ В аккаунте доступна только `deepseek-flash`, а routing ставил
8
+ `deepseek-v4-pro` большинству ролей. `startActivation` отклонял модель,
9
+ поэтому агенты и рой не стартовали.
10
+
11
+ ## Решение
12
+
13
+ - По умолчанию **`deepseek-flash` + high effort** для quality-ролей.
14
+ - Pro **не подставляется автоматически**.
15
+ - Pro включается вручную: `model: deepseek-v4-pro` в роли или `project_agent ... model=deepseek-v4-pro`.
16
+ - Если провайдер отклоняет явно выбранный pro, запуск повторяется на flash.
17
+
18
+ ## Проверки
19
+
20
+ - `agent-extensions-tests` — OK, включая classifier.
21
+ - `swarm-tests` — OK.
22
+ - `npm test` — exit 0.
23
+ - build/check — OK.
24
+ - e2e-http — OK.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "dsh-desktop-kit",
3
- "version": "2.23.17",
4
- "description": "DeepSeek Harness desktop kit 2.23.17: 18 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.23.19",
4
+ "description": "DeepSeek Harness desktop kit 2.23.19: 18 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",
@@ -13,7 +13,12 @@ import { saveTranscript } from "./transcripts.js";
13
13
  import { findingsPrompt, parseFindings, validateFindings } from "./findings.js";
14
14
  import { agentOptionsFor, chooseAgentRoute } from "./routing.js";
15
15
 
16
- const background = new Map();
16
+ const MODEL_ERROR = /(?:model|provider).*(?:not found|unknown|unsupported|unavailable|not available|invalid|no such|does not exist)/iu;
17
+
18
+ export function isModelFallback(error) {
19
+ const message = error instanceof Error ? error.message : String(error);
20
+ return /(?:model|provider).*(?:not found|unknown|unsupported|unavailable|not available|invalid|no such|does not exist)|(?:not found|no such|unknown|unsupported|unavailable|invalid).*(?:model|provider)/iu.test(message);
21
+ }
17
22
 
18
23
  function textFromOutput(output) {
19
24
  if (!Array.isArray(output)) return "";
@@ -50,6 +55,7 @@ export async function runProjectAgent(ctx, exec, definition, task, options = {})
50
55
  const reservedId = crypto.randomUUID();
51
56
  let activeId = reservedId;
52
57
  const route = chooseAgentRoute(definition, task, options.route);
58
+ let routeUsed = route;
53
59
  setChildPolicy(reservedId, definition);
54
60
  let activation;
55
61
  try {
@@ -65,7 +71,7 @@ export async function runProjectAgent(ctx, exec, definition, task, options = {})
65
71
  "Task:",
66
72
  String(task ?? ""),
67
73
  ].filter((line) => line !== "").join("\n");
68
- activation = await subagents.startActivation({
74
+ const start = (selectedRoute) => subagents.startActivation({
69
75
  provider,
70
76
  label: `agent:${definition.name}`,
71
77
  childId: reservedId,
@@ -74,11 +80,22 @@ export async function runProjectAgent(ctx, exec, definition, task, options = {})
74
80
  parent: exec.agent,
75
81
  signal: controller.signal,
76
82
  cwd,
77
- ...(route.model || route.reasoningEffort ? { agentOptions: agentOptionsFor(route) } : {}),
83
+ ...(selectedRoute.model || selectedRoute.reasoningEffort ? { agentOptions: agentOptionsFor(selectedRoute) } : {}),
78
84
  },
79
85
  signal: controller.signal,
80
86
  delivery: "caller",
81
87
  });
88
+ try {
89
+ activation = await start(route);
90
+ } catch (error) {
91
+ if (route.model === "deepseek-flash" || !isModelFallback(error)) throw error;
92
+ routeUsed = {
93
+ ...route,
94
+ model: "deepseek-flash",
95
+ reasons: [...route.reasons, "model unavailable -> deepseek-flash"],
96
+ };
97
+ activation = await start(routeUsed);
98
+ }
82
99
  if (activation.childId && activation.childId !== reservedId) {
83
100
  activeId = String(activation.childId);
84
101
  setChildPolicy(activeId, definition);
@@ -165,7 +182,7 @@ export async function runProjectAgent(ctx, exec, definition, task, options = {})
165
182
  stopReason: result?.stopReason ?? "completed",
166
183
  worktree: options.worktree ?? null,
167
184
  ...(definition.output === "findings" ? { findings, findingsValid: Boolean(findings), findingsError } : {}),
168
- route,
185
+ route: routeUsed,
169
186
  };
170
187
  } catch (error) {
171
188
  clearChildPolicy(activeId);
@@ -10,14 +10,20 @@ const PRO = "deepseek-v4-pro";
10
10
  const FLASH = "deepseek-flash";
11
11
  const EFFORTS = new Set(["off", "low", "high", "max"]);
12
12
 
13
+ /*
14
+ * Default is intentionally flash: it exists on every DSH account. Quality is
15
+ * raised with effort, not with an implicit paid model. A manual `model:` in
16
+ * agent frontmatter or `model=deepseek-v4-pro` in project_agent opts into pro.
17
+ * If a manually selected pro is rejected, runProjectAgent retries flash.
18
+ */
13
19
  const ROLE_DEFAULTS = {
14
- coordinator: { model: PRO, effort: "high" },
15
- synthesizer: { model: PRO, effort: "high" },
16
- verifier: { model: PRO, effort: "high" },
17
- reviewer: { model: PRO, effort: "high" },
18
- researcher: { model: PRO, effort: "high" },
19
- security: { model: PRO, effort: "high" },
20
- performance: { model: PRO, effort: "high" },
20
+ coordinator: { model: FLASH, effort: "high" },
21
+ synthesizer: { model: FLASH, effort: "high" },
22
+ verifier: { model: FLASH, effort: "high" },
23
+ reviewer: { model: FLASH, effort: "high" },
24
+ researcher: { model: FLASH, effort: "high" },
25
+ security: { model: FLASH, effort: "high" },
26
+ performance: { model: FLASH, effort: "high" },
21
27
  tester: { model: FLASH, effort: "low" },
22
28
  };
23
29
 
@@ -44,7 +50,6 @@ export function chooseAgentRoute(definition = {}, task = "", override = {}) {
44
50
  if (explicitEffort) reasons.push("agent effort");
45
51
 
46
52
  if (CRITICAL.test(text)) {
47
- if (!explicitModel && model === FLASH) { model = PRO; reasons.push("critical -> pro"); }
48
53
  if (!explicitEffort && effort !== "high" && effort !== "max") { effort = "high"; reasons.push("critical -> high"); }
49
54
  }
50
55
  if (MAX_QUALITY.test(text)) {
@@ -10,7 +10,7 @@ export const DEFAULTS = {
10
10
  researchFirst: true,
11
11
  autoScaffold: true,
12
12
  swarm: { enabled: true, threshold: 3, maxAgents: 4 },
13
- mcpBootstrap: { enabled: true, trusted: true },
13
+ mcpBootstrap: { enabled: true, trusted: false },
14
14
  };
15
15
 
16
16
  function home() {
@@ -12,7 +12,7 @@ import { readSettings } from "./settings.js";
12
12
 
13
13
  const BROAD = [
14
14
  /(?:audit|review|architecture|security|migration|refactor|research|compare|analy[sz]e|investigate)/iu,
15
- /(?:провер|ревью|архитект|безопас|миграц|рефактор|исслед|сравн|проанализ|разбер)/iu,
15
+ /(?:провер|ревью|архитектур|безопас|миграц|рефактор|исслед|сравн|проанализ|разбер)/iu,
16
16
  ];
17
17
  const EXTERNAL = [
18
18
  /(?:latest|current|price|pricing|version|release|docs?|documentation|rfc|standard|benchmark|cve)/iu,
@@ -48,20 +48,30 @@ export function chooseSwarm(task, teams = [], agents = [], options = {}) {
48
48
 
49
49
  const maxAgents = Math.max(2, Math.min(6, Number(options.maxAgents) || 4));
50
50
  const research = EXTERNAL.some((pattern) => pattern.test(text));
51
- /* Auto-swarm is read-only by design. A preset that contains a writer is
52
- * explicit-only (`project_agent action=team worktrees=true`); never route a
53
- * background auto-swarm into writable agents. */
54
51
  const readOnlyNames = new Set(readOnly.map((agent) => agent.name));
55
- const preset = teams.find((team) => team.members.length >= 2 && team.members.every((name) => readOnlyNames.has(name))) ?? null;
56
- if (preset) {
57
- return { swarm: true, score, reasons, research, maxAgents, preset: preset.id, members: preset.members.slice(0, maxAgents), lead: preset.lead || "" };
52
+ const lead = readOnly.find((agent) => /^(?:lead|coordinator|orchestrator)$/iu.test(agent.name))?.name ?? "";
53
+ const candidates = readOnly.filter((agent) => agent.name !== lead);
54
+
55
+ const preferredPresets = research ? ["research", "audit"] : ["review", "security", "audit"];
56
+ const presets = teams
57
+ .filter((team) => Array.isArray(team.members) && team.members.length >= 2)
58
+ .map((team) => ({ team, score: preferredPresets.indexOf(team.id) }))
59
+ .filter((item) => item.team.members.every((name) => readOnlyNames.has(name)))
60
+ .sort((a, b) => (a.score < 0 ? 99 : a.score) - (b.score < 0 ? 99 : b.score));
61
+ const chosen = presets[0]?.team ?? null;
62
+ if (chosen) {
63
+ const members = chosen.members.filter((name) => name !== lead).slice(0, maxAgents);
64
+ if (members.length >= 2) {
65
+ return { swarm: true, score, reasons, research, maxAgents, preset: chosen.id, members, lead: chosen.lead || lead };
66
+ }
58
67
  }
59
- const preferred = ["reviewer", "researcher", "tester"];
60
- const members = readOnly
68
+
69
+ const preferred = ["reviewer", "researcher", "verifier", "security", "performance"];
70
+ const members = candidates
61
71
  .slice()
62
72
  .sort((a, b) => (preferred.indexOf(a.name) + 1 || 99) - (preferred.indexOf(b.name) + 1 || 99))
63
73
  .slice(0, maxAgents)
64
74
  .map((agent) => agent.name);
65
- const lead = readOnly.find((agent) => /^(?:lead|coordinator|orchestrator)$/iu.test(agent.name))?.name ?? "";
75
+ if (members.length < 2) return { swarm: false, score, reasons, reason: "not enough non-lead read-only agents" };
66
76
  return { swarm: true, score, reasons, research, maxAgents, preset: "", members, lead };
67
77
  }
@@ -5,6 +5,7 @@
5
5
  * evidence before the final answer.
6
6
  */
7
7
  import crypto from "node:crypto";
8
+ import dns from "node:dns/promises";
8
9
  import fs from "node:fs";
9
10
  import path from "node:path";
10
11
 
@@ -65,14 +66,20 @@ export function isPublicHttpUrl(value) {
65
66
  }
66
67
  if (url.protocol !== "http:" && url.protocol !== "https:") return false;
67
68
  if (url.username || url.password) return false;
68
- const host = url.hostname.toLowerCase();
69
+ const host = url.hostname.toLowerCase().replace(/^\[|\]$/gu, "");
69
70
  if (host === "localhost" || host.endsWith(".localhost") || host.endsWith(".local")) return false;
70
- if (host === "0.0.0.0" || host === "::1" || host === "[::1]") return false;
71
+ if (host === "0.0.0.0" || host === "::1" || host === "::") return false;
72
+ if (host.includes(":")) {
73
+ if (/^(?:fc|fd|fe8|fe9|fea|feb)/u.test(host)) return false;
74
+ if (host.startsWith("::ffff:") || host.startsWith("::")) return false;
75
+ return true;
76
+ }
71
77
  if (/^\d{1,3}(?:\.\d{1,3}){3}$/u.test(host)) {
72
78
  const octets = host.split(".").map(Number);
73
79
  if (octets[0] === 10 || octets[0] === 127 || (octets[0] === 169 && octets[1] === 254)) return false;
74
80
  if (octets[0] === 172 && octets[1] >= 16 && octets[1] <= 31) return false;
75
81
  if (octets[0] === 192 && octets[1] === 168) return false;
82
+ if (octets[0] === 100 && octets[1] >= 64 && octets[1] <= 127) return false;
76
83
  }
77
84
  return true;
78
85
  }
@@ -122,6 +129,34 @@ export function addClaim(root, input) {
122
129
  return { ledger: writeLedger(root, ledger), claim, duplicate: false };
123
130
  }
124
131
 
132
+ function privateAddress(address) {
133
+ const value = String(address || "").toLowerCase();
134
+ if (value.startsWith("::ffff:")) return true;
135
+ if (value.includes(":")) {
136
+ return value === "::1" || value === "::" || /^(?:fc|fd|fe8|fe9|fea|feb)/u.test(value);
137
+ }
138
+ const octets = value.split(".").map(Number);
139
+ if (octets.length !== 4 || octets.some((octet) => !Number.isInteger(octet))) return true;
140
+ return octets[0] === 10
141
+ || octets[0] === 127
142
+ || (octets[0] === 169 && octets[1] === 254)
143
+ || (octets[0] === 172 && octets[1] >= 16 && octets[1] <= 31)
144
+ || (octets[0] === 192 && octets[1] === 168)
145
+ || (octets[0] === 100 && octets[1] >= 64 && octets[1] <= 127)
146
+ || octets[0] === 0;
147
+ }
148
+
149
+ async function resolvesPublic(current) {
150
+ try {
151
+ const host = new URL(current).hostname.replace(/^\[|\]$/gu, "");
152
+ if (/^\d{1,3}(?:\.\d{1,3}){3}$/u.test(host) || host.includes(":")) return !privateAddress(host);
153
+ const addresses = await dns.lookup(host, { all: true });
154
+ return addresses.length > 0 && addresses.every((entry) => !privateAddress(entry.address));
155
+ } catch {
156
+ return false;
157
+ }
158
+ }
159
+
125
160
  export async function verifyClaim(claim, timeoutMs = 8000) {
126
161
  if (!isPublicHttpUrl(claim.url)) {
127
162
  return { ok: false, status: 0, finalUrl: "", error: "unsafe or invalid URL", checkedAt: new Date().toISOString() };
@@ -129,20 +164,36 @@ export async function verifyClaim(claim, timeoutMs = 8000) {
129
164
  const controller = new AbortController();
130
165
  const timer = setTimeout(() => controller.abort(), timeoutMs);
131
166
  try {
132
- const response = await fetch(claim.url, {
133
- method: "GET",
134
- redirect: "follow",
135
- signal: controller.signal,
136
- headers: { "user-agent": "dsh-research-ledger/1.0", accept: "text/html,application/xhtml+xml,application/json;q=0.8,*/*;q=0.5" },
137
- });
138
- try { await response.body?.cancel(); } catch { /* body already consumed */ }
139
- return {
140
- ok: response.ok,
141
- status: response.status,
142
- finalUrl: response.url || claim.url,
143
- error: response.ok ? "" : `HTTP ${response.status}`,
144
- checkedAt: new Date().toISOString(),
145
- };
167
+ let current = claim.url;
168
+ for (let redirects = 0; redirects <= 3; redirects += 1) {
169
+ if (!(await resolvesPublic(current))) {
170
+ return { ok: false, status: 0, finalUrl: current, error: "host resolves to a private address", checkedAt: new Date().toISOString() };
171
+ }
172
+ const response = await fetch(current, {
173
+ method: "GET",
174
+ redirect: "manual",
175
+ signal: controller.signal,
176
+ headers: { "user-agent": "dsh-research-ledger/1.0", accept: "text/html,application/xhtml+xml,application/json;q=0.8,*/*;q=0.5" },
177
+ });
178
+ if (response.status >= 300 && response.status < 400) {
179
+ const location = response.headers.get("location");
180
+ try { await response.body?.cancel(); } catch { /* best effort */ }
181
+ if (!location) return { ok: false, status: response.status, finalUrl: current, error: "redirect without Location", checkedAt: new Date().toISOString() };
182
+ const next = new URL(location, current).toString();
183
+ if (!isPublicHttpUrl(next)) return { ok: false, status: 0, finalUrl: next, error: "unsafe redirect target", checkedAt: new Date().toISOString() };
184
+ current = next;
185
+ continue;
186
+ }
187
+ try { await response.body?.cancel(); } catch { /* body already consumed */ }
188
+ return {
189
+ ok: response.ok,
190
+ status: response.status,
191
+ finalUrl: response.url || current,
192
+ error: response.ok ? "" : `HTTP ${response.status}`,
193
+ checkedAt: new Date().toISOString(),
194
+ };
195
+ }
196
+ return { ok: false, status: 0, finalUrl: current, error: "too many redirects", checkedAt: new Date().toISOString() };
146
197
  } catch (error) {
147
198
  return {
148
199
  ok: false,