dsh-desktop-kit 2.23.2 → 2.23.17

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.
Files changed (31) hide show
  1. package/CHANGELOG.md +30 -0
  2. package/README.md +255 -245
  3. package/client.js +119 -2
  4. package/docs/AGENT-HARNESS.md +9 -0
  5. package/index.js +2 -0
  6. package/package.json +3 -3
  7. package/plugins/dsh-agent-extensions/README.md +5 -0
  8. package/plugins/dsh-agent-extensions/client.js +118 -1
  9. package/plugins/dsh-agent-extensions/index.js +24 -5
  10. package/plugins/dsh-agent-extensions/lib/agents.js +26 -3
  11. package/plugins/dsh-agent-extensions/lib/api.js +55 -1
  12. package/plugins/dsh-agent-extensions/lib/board.js +8 -2
  13. package/plugins/dsh-agent-extensions/lib/findings.js +67 -0
  14. package/plugins/dsh-agent-extensions/lib/project.js +2 -0
  15. package/plugins/dsh-agent-extensions/lib/routing.js +72 -0
  16. package/plugins/dsh-agent-extensions/lib/scaffold.js +120 -21
  17. package/plugins/dsh-agent-extensions/lib/settings.js +94 -0
  18. package/plugins/dsh-agent-extensions/lib/swarm.js +10 -5
  19. package/plugins/dsh-mcp-manager/README.md +10 -0
  20. package/plugins/dsh-mcp-manager/index.js +62 -2
  21. package/plugins/dsh-mcp-manager/lib/bootstrap.js +94 -0
  22. package/plugins/dsh-mcp-manager/lib/catalog.js +128 -0
  23. package/plugins/dsh-research-ledger/README.md +48 -0
  24. package/plugins/dsh-research-ledger/cordis.patch.yml +3 -0
  25. package/plugins/dsh-research-ledger/index.js +145 -0
  26. package/plugins/dsh-research-ledger/lib/ledger.js +346 -0
  27. package/plugins/dsh-research-ledger/package.json +25 -0
  28. package/plugins/dsh-skill-autopilot/index.js +65 -13
  29. package/skills/manifest.json +8 -8
  30. package/skills/research-first/SKILL.md +1 -0
  31. package/skills-baseline.json +480 -0
package/client.js CHANGED
@@ -7636,6 +7636,24 @@ var(--dsw-alias-bg-layer-1,#fff);box-shadow:inset 0 1px 0 color-mix(in srgb,#fff
7636
7636
  .ag-status-failed,.ag-status-canceled{color:#9f1239;border-color:rgba(159,18,57,.18);background:rgba(159,18,57,.05)}
7637
7637
  .ag-mini-empty{padding:12px;border:1px dashed var(--ag-line);border-radius:10px;color:var(--ag-muted);font-size:11.5px;line-height:1.45;background:linear-gradient(160deg,var(--ag-soft),transparent 80%)}
7638
7638
  .ag-actions{display:flex;gap:6px;flex-wrap:wrap;align-items:center;margin-top:2px}
7639
+ .ag-kit{display:flex;flex-direction:column;gap:12px;padding:16px;border:1px solid color-mix(in srgb,var(--ag-accent) 22%,var(--ag-line));border-radius:16px;background:radial-gradient(120% 160% at 100% 0%,color-mix(in srgb,var(--ag-accent) 7%,transparent) 0%,transparent 55%),var(--ag-panel)}
7640
+ .ag-kit-head{display:flex;justify-content:space-between;align-items:flex-start;gap:12px;flex-wrap:wrap}
7641
+ .ag-kit-eyebrow{margin:0 0 3px;font-size:10px;font-weight:750;letter-spacing:.14em;text-transform:uppercase;color:var(--ag-accent)}
7642
+ .ag-kit-title{margin:0;font-size:16px;font-weight:680;letter-spacing:-.02em}
7643
+ .ag-kit-sub{margin:3px 0 0;font-size:11.5px;line-height:1.5;color:var(--ag-muted);max-width:640px}
7644
+ .ag-kit-grid{display:grid;grid-template-columns:repeat(auto-fit,minmax(230px,1fr));gap:10px}
7645
+ .ag-kit-card{display:flex;flex-direction:column;gap:7px;padding:12px;border:1px solid var(--ag-line);border-radius:12px;background:var(--ag-panel);min-width:0}
7646
+ .ag-kit-row{display:flex;align-items:flex-start;justify-content:space-between;gap:10px}
7647
+ .ag-kit-name{font-size:12.5px;font-weight:650;line-height:1.3}
7648
+ .ag-kit-hint{margin:0;font-size:10.5px;line-height:1.45;color:var(--ag-muted)}
7649
+ .ag-kit-ctl{display:flex;align-items:center;gap:8px;flex-wrap:wrap;margin-top:2px}
7650
+ .ag-kit-select{font:inherit;font-size:11px;padding:4px 6px;border:1px solid var(--ag-line);border-radius:8px;background:var(--ag-panel);color:var(--ag-text);min-height:28px}
7651
+ .ag-switch{display:inline-flex;align-items:center;gap:7px;font-size:11px;color:var(--ag-text);cursor:pointer;user-select:none}
7652
+ .ag-switch input{width:14px;height:14px;accent-color:var(--ag-accent);margin:0}
7653
+ .ag-kit-status{font-size:10.5px;font-weight:650;color:var(--ag-accent)}
7654
+ .ag-kit-foot{display:flex;align-items:center;justify-content:space-between;gap:10px;flex-wrap:wrap}
7655
+ .ag-kit-saved{font-size:10.5px;color:var(--ag-muted)}
7656
+ @media(max-width:640px){.ag-kit{padding:13px}.ag-kit-grid{grid-template-columns:1fr}.ag-kit-row{align-items:flex-start}}
7639
7657
  @media(max-width:860px){.ag-grid{grid-template-columns:1fr}.ag-stats{grid-template-columns:1fr 1fr}.ag-items{grid-template-columns:1fr}}
7640
7658
  @media(max-width:520px){.ag-stats{grid-template-columns:repeat(3,minmax(0,1fr));gap:8px}.ag-stat{padding:10px 12px}.ag-stat b{font-size:20px}.ag-stat span{font-size:9px;letter-spacing:.04em}.ag-root{gap:16px}}
7641
7659
  @media(prefers-reduced-motion:reduce){.ag-card{transition:none}}
@@ -7682,8 +7700,67 @@ var(--dsw-alias-bg-layer-1,#fff);box-shadow:inset 0 1px 0 color-mix(in srgb,#fff
7682
7700
  } catch { return undefined; }
7683
7701
  }
7684
7702
 
7703
+ function KitPanel({ kit, busy, onSave, onMcp }) {
7704
+ if (!kit) return null;
7705
+ const settings = kit.settings ?? {};
7706
+ const mcp = kit.mcpBootstrap ?? {};
7707
+ const swarm = settings.swarm ?? {};
7708
+ return h("section", { className: "ag-kit", "aria-label": "Глобальные настройки Kit" },
7709
+ h("div", { className: "ag-kit-head" },
7710
+ h("div", null,
7711
+ h("p", { className: "ag-kit-eyebrow" }, "Kit · global controls"),
7712
+ h("h3", { className: "ag-kit-title" }, "Автоматизация Kit"),
7713
+ h("p", { className: "ag-kit-sub" }, "Глобальные переключатели профиля. Действуют на новые чаты и проекты; проектные агенты и board остаются в `.dsh`."),
7714
+ ),
7715
+ busy ? h("span", { className: "ag-kit-status" }, "Сохраняем…") : null,
7716
+ ),
7717
+ h("div", { className: "ag-kit-grid" },
7718
+ h("div", { className: "ag-kit-card" },
7719
+ h("div", { className: "ag-kit-row" },
7720
+ h("div", null, h("div", { className: "ag-kit-name" }, "Research-first"), h("p", { className: "ag-kit-hint" }, "Перед каждой задачей — поиск лучших мировых практик, 2+ источника, 2–3 референса.")),
7721
+ h("label", { className: "ag-switch" }, h("input", { type: "checkbox", checked: settings.researchFirst !== false, disabled: busy, onChange: (event) => onSave({ researchFirst: event.target.checked }) }), settings.researchFirst !== false ? "вкл" : "выкл"),
7722
+ ),
7723
+ ),
7724
+ h("div", { className: "ag-kit-card" },
7725
+ h("div", { className: "ag-kit-row" },
7726
+ h("div", null, h("div", { className: "ag-kit-name" }, "Авто-инициализация проектов"), h("p", { className: "ag-kit-hint" }, "Первый чат в проекте создаёт `.dsh`, агентов, teams, verify и PROJECT.md.")),
7727
+ h("label", { className: "ag-switch" }, h("input", { type: "checkbox", checked: settings.autoScaffold !== false, disabled: busy, onChange: (event) => onSave({ autoScaffold: event.target.checked }) }), settings.autoScaffold !== false ? "вкл" : "выкл"),
7728
+ ),
7729
+ ),
7730
+ h("div", { className: "ag-kit-card" },
7731
+ h("div", { className: "ag-kit-row" },
7732
+ h("div", null, h("div", { className: "ag-kit-name" }, "Авто-рой"), h("p", { className: "ag-kit-hint" }, "`project_agent action=auto` сам решает, нужен ли read-only рой. Порог сложности и лимит агентов.")),
7733
+ h("label", { className: "ag-switch" }, h("input", { type: "checkbox", checked: swarm.enabled !== false, disabled: busy, onChange: (event) => onSave({ swarm: { enabled: event.target.checked } }) }), swarm.enabled !== false ? "вкл" : "выкл"),
7734
+ ),
7735
+ h("div", { className: "ag-kit-ctl" },
7736
+ h("label", { className: "ag-kit-hint" }, "Порог",
7737
+ h("select", { className: "ag-kit-select", value: swarm.threshold ?? 3, disabled: busy || swarm.enabled === false, onChange: (event) => onSave({ swarm: { threshold: Number(event.target.value) } }) }, [1, 2, 3, 4, 5].map((value) => h("option", { key: value, value }, String(value))))),
7738
+ h("label", { className: "ag-kit-hint" }, "Агентов",
7739
+ h("select", { className: "ag-kit-select", value: swarm.maxAgents ?? 4, disabled: busy || swarm.enabled === false, onChange: (event) => onSave({ swarm: { maxAgents: Number(event.target.value) } }) }, [2, 3, 4, 5, 6].map((value) => h("option", { key: value, value }, String(value))))),
7740
+ ),
7741
+ ),
7742
+ h("div", { className: "ag-kit-card" },
7743
+ h("div", { className: "ag-kit-row" },
7744
+ h("div", null, h("div", { className: "ag-kit-name" }, "MCP bootstrap"), h("p", { className: "ag-kit-hint" }, "Добавляет memory, sequential-thinking и github с trusted=false. Trust — только явно, серверы не запускаются сами.")),
7745
+ h("label", { className: "ag-switch" }, h("input", { type: "checkbox", checked: mcp.enabled === true, disabled: busy, onChange: (event) => onMcp(event.target.checked, mcp.trusted === true) }), mcp.enabled ? "вкл" : "выкл"),
7746
+ ),
7747
+ h("div", { className: "ag-kit-ctl" },
7748
+ h("label", { className: "ag-switch" }, h("input", { type: "checkbox", checked: mcp.trusted === true, disabled: busy, onChange: (event) => onMcp(mcp.enabled === true, event.target.checked) }), "Доверять подключённым"),
7749
+ h("button", { className: "ag-btn", type: "button", disabled: busy || mcp.trusted === true, onClick: () => onMcp(mcp.enabled === true, true) }, mcp.trusted ? "Доверено" : "Доверять все"),
7750
+ ),
7751
+ ),
7752
+ ),
7753
+ h("div", { className: "ag-kit-foot" },
7754
+ h("p", { className: "ag-kit-hint" }, "Trusted-серверы запускаются при старте DSH; настройки MCP — в разделе MCP."),
7755
+ h("span", { className: "ag-kit-saved" }, kit.mcpBootstrap?.trusted ? "MCP trusted" : "MCP untrusted"),
7756
+ ),
7757
+ );
7758
+ }
7759
+
7685
7760
  function AgentsSection(props) {
7686
7761
  const [state, setState] = useState({ loading: true, error: null, data: null });
7762
+ const [kit, setKit] = useState(null);
7763
+ const [kitBusy, setKitBusy] = useState(false);
7687
7764
  const [canceling, setCanceling] = useState("");
7688
7765
  const [transcript, setTranscript] = useState(null);
7689
7766
  const useSessions = props && props.useSessions;
@@ -7719,6 +7796,42 @@ var(--dsw-alias-bg-layer-1,#fff);box-shadow:inset 0 1px 0 color-mix(in srgb,#fff
7719
7796
  return () => { cancelled = true; };
7720
7797
  }, [sessionId, cwd]);
7721
7798
 
7799
+ useEffect(() => {
7800
+ let cancelled = false;
7801
+ (async () => {
7802
+ try {
7803
+ const data = await call(window.__DSH_AGENTS_CTX__, "settings", {});
7804
+ if (!cancelled) setKit(data);
7805
+ } catch { /* controls stay hidden if host API is unavailable */ }
7806
+ })();
7807
+ return () => { cancelled = true; };
7808
+ }, []);
7809
+
7810
+ const saveKit = async (patch) => {
7811
+ setKitBusy(true);
7812
+ try {
7813
+ const data = await call(window.__DSH_AGENTS_CTX__, "settings.update", { settings: patch });
7814
+ setKit(data);
7815
+ } catch (error) {
7816
+ setState((current) => ({ ...current, error: fallbackError(error) }));
7817
+ } finally {
7818
+ setKitBusy(false);
7819
+ }
7820
+ };
7821
+
7822
+ const saveMcp = async (enabled, trusted) => {
7823
+ setKitBusy(true);
7824
+ setKit((current) => ({ ...(current ?? {}), mcpBootstrap: { enabled, trusted } }));
7825
+ try {
7826
+ const data = await call(window.__DSH_AGENTS_CTX__, "settings.update", { mcpBootstrap: { enabled, trusted } });
7827
+ setKit(data);
7828
+ } catch (error) {
7829
+ setState((current) => ({ ...current, error: fallbackError(error) }));
7830
+ } finally {
7831
+ setKitBusy(false);
7832
+ }
7833
+ };
7834
+
7722
7835
  const cancel = async (id) => {
7723
7836
  setCanceling(id);
7724
7837
  try {
@@ -7743,6 +7856,8 @@ var(--dsw-alias-bg-layer-1,#fff);box-shadow:inset 0 1px 0 color-mix(in srgb,#fff
7743
7856
 
7744
7857
  const agents = Array.isArray(state.data?.agents) ? state.data.agents : [];
7745
7858
  const worktrees = Array.isArray(state.data?.worktrees) ? state.data.worktrees : [];
7859
+ const worktreeError = typeof state.data?.worktreeError === "string" ? state.data.worktreeError : "";
7860
+ const noGitWorktree = /not a git repository|not a git repo/iu.test(worktreeError);
7746
7861
  const runs = Array.isArray(state.data?.runs) ? state.data.runs : [];
7747
7862
  const rawBoard = state.data?.board ?? {};
7748
7863
  const board = {
@@ -7761,6 +7876,7 @@ var(--dsw-alias-bg-layer-1,#fff);box-shadow:inset 0 1px 0 color-mix(in srgb,#fff
7761
7876
  h("button", { className: "ag-btn", type: "button", onClick: () => void load() }, "Обновить"),
7762
7877
  ),
7763
7878
  state.error ? h("div", { className: "ag-error", role: "alert" }, state.error) : null,
7879
+ h(KitPanel, { kit, busy: kitBusy, onSave: saveKit, onMcp: saveMcp }),
7764
7880
  h("div", { className: "ag-stats" },
7765
7881
  h("div", { className: "ag-stat" }, h("b", null, agents.length), h("span", null, "агентов")),
7766
7882
  h("div", { className: "ag-stat" }, h("b", null, readOnly), h("span", null, "read-only")),
@@ -7802,7 +7918,8 @@ var(--dsw-alias-bg-layer-1,#fff);box-shadow:inset 0 1px 0 color-mix(in srgb,#fff
7802
7918
  h("div", { className: "ag-section" },
7803
7919
  h("h3", null, "Worktrees"),
7804
7920
  h("p", { className: "ag-hint" }, "Изолированные рабочие копии: `project_worktree create` или `project_agent` с `worktree=auto`."),
7805
- state.data?.worktreeError ? h("div", { className: "ag-error", role: "alert" }, state.data.worktreeError) : null,
7921
+ state.data?.worktreeError && !noGitWorktree ? h("div", { className: "ag-error", role: "alert" }, state.data.worktreeError) : null,
7922
+ noGitWorktree ? h("div", { className: "ag-note" }, "Этот workspace не git-репозиторий, поэтому worktrees недоступны. Открой конкретный git-репозиторий (например, `dsh-desktop-kit`) — тогда `project_worktree` и `worktree=auto` заработают. Текущие агенты и рой работают без worktrees.") : null,
7806
7923
  worktrees.length > 0 ? h("div", { className: "ag-items" }, worktrees.map((tree) => h("article", { className: "ag-item", key: tree.id },
7807
7924
  h("div", { className: "ag-item-top" },
7808
7925
  h("code", { title: tree.branch || tree.id }, tree.branch || tree.id),
@@ -8264,7 +8381,7 @@ var(--dsw-alias-bg-layer-1,#fff);box-shadow:inset 0 1px 0 color-mix(in srgb,#fff
8264
8381
  if (__kitErrors.length <= 5) console.error("[dsh-desktop-kit] registration failed:", label, message);
8265
8382
  };
8266
8383
  try {
8267
- window.__DSH_DESKTOP_KIT__ = { version: "2.23.2", parts: __partNames, errors: __kitErrors, ready: false };
8384
+ window.__DSH_DESKTOP_KIT__ = { version: "2.23.17", parts: __partNames, errors: __kitErrors, ready: false };
8268
8385
  } catch {}
8269
8386
  const __inject = [];
8270
8387
  for (const __part of __parts) {
@@ -136,9 +136,18 @@ node tools/eval-run.mjs --full
136
136
  browser QA, GitHub review, bridge. Отчёт `eval/latest.json`; baseline
137
137
  `eval/baseline.json` показывает дельту.
138
138
 
139
+ ## Research Ledger (`research_ledger`)
140
+
141
+ Внешние claim(s) хранятся в `.dsh/research/ledger.json`: URL, дата, цитата, проверка ссылки, stale/single-source/contested. Перед финальным ответом вызывай `research_ledger action=summary`; `verify` проверяет доступность ссылок.
142
+
143
+ ## Verifier и findings
144
+
145
+ Агенты с `output: findings` возвращают JSON-контракт: verdict PASS/FAIL/UNKNOWN, findings с severity/location/evidence/impact/fix, tests и unknowns. В scaffold добавлены `verifier` и `synthesizer`, team `audit` — read-only.
146
+
139
147
  ## Следующие шаги
140
148
 
141
149
  - file-aware rules: `paths:` + реальный список изменяемых файлов;
142
150
  - inline diff accept/reject UI;
143
151
  - model/effort routing;
144
152
  - MCP-рецепты и маркетплейс.
153
+
package/index.js CHANGED
@@ -37,6 +37,7 @@ import * as planMode from "./plugins/dsh-plan-mode/index.js";
37
37
  import * as browserQa from "./plugins/dsh-browser-qa/index.js";
38
38
  import * as githubReview from "./plugins/dsh-github-review/index.js";
39
39
  import * as guardrails from "./plugins/dsh-guardrails/index.js";
40
+ import * as researchLedger from "./plugins/dsh-research-ledger/index.js";
40
41
  import * as agentExtensions from "./plugins/dsh-agent-extensions/index.js";
41
42
  import * as mcpManager from "./plugins/dsh-mcp-manager/index.js";
42
43
  import * as integrations from "./plugins/dsh-integrations/index.js";
@@ -65,6 +66,7 @@ const parts = [
65
66
  ["dsh-browser-qa", browserQa],
66
67
  ["dsh-github-review", githubReview],
67
68
  ["dsh-guardrails", guardrails],
69
+ ["dsh-research-ledger", researchLedger],
68
70
  ["dsh-agent-extensions", agentExtensions],
69
71
  ["dsh-mcp-manager", mcpManager],
70
72
  ["dsh-integrations", integrations],
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "dsh-desktop-kit",
3
- "version": "2.23.2",
4
- "description": "DeepSeek Harness desktop kit 2.23.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.",
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.",
5
5
  "keywords": [
6
6
  "deepseek-harness",
7
7
  "dsh",
@@ -83,7 +83,7 @@
83
83
  "build:client": "node tools/build-client.mjs",
84
84
  "build:skills": "node tools/build-skill-manifest.mjs",
85
85
  "check:client": "node tools/check-client.mjs client.js",
86
- "test": "node tools/integrations-tests.mjs && 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-elicitation-tests.mjs && node tools/mcp-sampling-tests.mjs && node tools/mcp-oauth-tests.mjs && node tools/worktrees-tests.mjs && node tools/transcripts-tests.mjs && node tools/team-messages-tests.mjs && node tools/swarm-tests.mjs && node tools/team-presets-tests.mjs && node tools/team-board-tests.mjs && node tools/team-agents-tests.mjs && node tools/background-agents-tests.mjs && node tools/permissions-ui-tests.mjs && node plugins/dsh-guardrails/tools/guardrails-tests.mjs",
86
+ "test": "node tools/integrations-tests.mjs && 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/research-ledger-tests.mjs && node tools/research-eval.mjs && node tools/citation-eval.mjs && node tools/mcp-manager-tests.mjs && node tools/github-review-tests.mjs && node tools/mcp-catalog-tests.mjs && node tools/mcp-bootstrap-tests.mjs && node tools/instructions-tests.mjs && node tools/mcp-elicitation-tests.mjs && node tools/mcp-sampling-tests.mjs && node tools/mcp-oauth-tests.mjs && node tools/worktrees-tests.mjs && node tools/transcripts-tests.mjs && node tools/team-messages-tests.mjs && node tools/swarm-tests.mjs && node tools/team-presets-tests.mjs && node tools/team-board-tests.mjs && node tools/team-agents-tests.mjs && node tools/background-agents-tests.mjs && node tools/permissions-ui-tests.mjs && node plugins/dsh-guardrails/tools/guardrails-tests.mjs",
87
87
  "skills:cost": "node tools/skill-cost.mjs",
88
88
  "skills:check": "node tools/skill-cost.mjs --check",
89
89
  "release": "node tools/release.mjs",
@@ -101,6 +101,10 @@ the branch is kept for review.
101
101
  Enforcement is a global `tools/pre-execute` gate keyed by the reserved child
102
102
  session id, so the child cannot escape it by calling another tool name.
103
103
 
104
+ ## Model/effort routing
105
+
106
+ Frontmatter `model:` и `effort:` задают маршрут. Без них: coordinator/reviewer/researcher/verifier/security/performance → `deepseek-v4-pro/high`, tester → `deepseek-flash/low`; critical-задачи повышают effort, `project_agent run` принимает `model`/`effort` override.
107
+
104
108
  ## Commands
105
109
 
106
110
  Built in:
@@ -128,3 +132,4 @@ Auto-checkpoint runs before the first write in a session, at most once per 10 mi
128
132
  - Hooks are arbitrary process execution: trust only repositories you control.
129
133
  - Subagent model/tool restrictions depend on the DSH provider; `tools` is not enforced here.
130
134
  - MCP manager is not included: the current profile has no MCP service/package to attach it to. Add it when an MCP host plugin is installed.
135
+
@@ -74,6 +74,24 @@ window.__ModuleLoader__.load({
74
74
  .ag-status-failed,.ag-status-canceled{color:#9f1239;border-color:rgba(159,18,57,.18);background:rgba(159,18,57,.05)}
75
75
  .ag-mini-empty{padding:12px;border:1px dashed var(--ag-line);border-radius:10px;color:var(--ag-muted);font-size:11.5px;line-height:1.45;background:linear-gradient(160deg,var(--ag-soft),transparent 80%)}
76
76
  .ag-actions{display:flex;gap:6px;flex-wrap:wrap;align-items:center;margin-top:2px}
77
+ .ag-kit{display:flex;flex-direction:column;gap:12px;padding:16px;border:1px solid color-mix(in srgb,var(--ag-accent) 22%,var(--ag-line));border-radius:16px;background:radial-gradient(120% 160% at 100% 0%,color-mix(in srgb,var(--ag-accent) 7%,transparent) 0%,transparent 55%),var(--ag-panel)}
78
+ .ag-kit-head{display:flex;justify-content:space-between;align-items:flex-start;gap:12px;flex-wrap:wrap}
79
+ .ag-kit-eyebrow{margin:0 0 3px;font-size:10px;font-weight:750;letter-spacing:.14em;text-transform:uppercase;color:var(--ag-accent)}
80
+ .ag-kit-title{margin:0;font-size:16px;font-weight:680;letter-spacing:-.02em}
81
+ .ag-kit-sub{margin:3px 0 0;font-size:11.5px;line-height:1.5;color:var(--ag-muted);max-width:640px}
82
+ .ag-kit-grid{display:grid;grid-template-columns:repeat(auto-fit,minmax(230px,1fr));gap:10px}
83
+ .ag-kit-card{display:flex;flex-direction:column;gap:7px;padding:12px;border:1px solid var(--ag-line);border-radius:12px;background:var(--ag-panel);min-width:0}
84
+ .ag-kit-row{display:flex;align-items:flex-start;justify-content:space-between;gap:10px}
85
+ .ag-kit-name{font-size:12.5px;font-weight:650;line-height:1.3}
86
+ .ag-kit-hint{margin:0;font-size:10.5px;line-height:1.45;color:var(--ag-muted)}
87
+ .ag-kit-ctl{display:flex;align-items:center;gap:8px;flex-wrap:wrap;margin-top:2px}
88
+ .ag-kit-select{font:inherit;font-size:11px;padding:4px 6px;border:1px solid var(--ag-line);border-radius:8px;background:var(--ag-panel);color:var(--ag-text);min-height:28px}
89
+ .ag-switch{display:inline-flex;align-items:center;gap:7px;font-size:11px;color:var(--ag-text);cursor:pointer;user-select:none}
90
+ .ag-switch input{width:14px;height:14px;accent-color:var(--ag-accent);margin:0}
91
+ .ag-kit-status{font-size:10.5px;font-weight:650;color:var(--ag-accent)}
92
+ .ag-kit-foot{display:flex;align-items:center;justify-content:space-between;gap:10px;flex-wrap:wrap}
93
+ .ag-kit-saved{font-size:10.5px;color:var(--ag-muted)}
94
+ @media(max-width:640px){.ag-kit{padding:13px}.ag-kit-grid{grid-template-columns:1fr}.ag-kit-row{align-items:flex-start}}
77
95
  @media(max-width:860px){.ag-grid{grid-template-columns:1fr}.ag-stats{grid-template-columns:1fr 1fr}.ag-items{grid-template-columns:1fr}}
78
96
  @media(max-width:520px){.ag-stats{grid-template-columns:repeat(3,minmax(0,1fr));gap:8px}.ag-stat{padding:10px 12px}.ag-stat b{font-size:20px}.ag-stat span{font-size:9px;letter-spacing:.04em}.ag-root{gap:16px}}
79
97
  @media(prefers-reduced-motion:reduce){.ag-card{transition:none}}
@@ -120,8 +138,67 @@ window.__ModuleLoader__.load({
120
138
  } catch { return undefined; }
121
139
  }
122
140
 
141
+ function KitPanel({ kit, busy, onSave, onMcp }) {
142
+ if (!kit) return null;
143
+ const settings = kit.settings ?? {};
144
+ const mcp = kit.mcpBootstrap ?? {};
145
+ const swarm = settings.swarm ?? {};
146
+ return h("section", { className: "ag-kit", "aria-label": "Глобальные настройки Kit" },
147
+ h("div", { className: "ag-kit-head" },
148
+ h("div", null,
149
+ h("p", { className: "ag-kit-eyebrow" }, "Kit · global controls"),
150
+ h("h3", { className: "ag-kit-title" }, "Автоматизация Kit"),
151
+ h("p", { className: "ag-kit-sub" }, "Глобальные переключатели профиля. Действуют на новые чаты и проекты; проектные агенты и board остаются в `.dsh`."),
152
+ ),
153
+ busy ? h("span", { className: "ag-kit-status" }, "Сохраняем…") : null,
154
+ ),
155
+ h("div", { className: "ag-kit-grid" },
156
+ h("div", { className: "ag-kit-card" },
157
+ h("div", { className: "ag-kit-row" },
158
+ h("div", null, h("div", { className: "ag-kit-name" }, "Research-first"), h("p", { className: "ag-kit-hint" }, "Перед каждой задачей — поиск лучших мировых практик, 2+ источника, 2–3 референса.")),
159
+ h("label", { className: "ag-switch" }, h("input", { type: "checkbox", checked: settings.researchFirst !== false, disabled: busy, onChange: (event) => onSave({ researchFirst: event.target.checked }) }), settings.researchFirst !== false ? "вкл" : "выкл"),
160
+ ),
161
+ ),
162
+ h("div", { className: "ag-kit-card" },
163
+ h("div", { className: "ag-kit-row" },
164
+ h("div", null, h("div", { className: "ag-kit-name" }, "Авто-инициализация проектов"), h("p", { className: "ag-kit-hint" }, "Первый чат в проекте создаёт `.dsh`, агентов, teams, verify и PROJECT.md.")),
165
+ h("label", { className: "ag-switch" }, h("input", { type: "checkbox", checked: settings.autoScaffold !== false, disabled: busy, onChange: (event) => onSave({ autoScaffold: event.target.checked }) }), settings.autoScaffold !== false ? "вкл" : "выкл"),
166
+ ),
167
+ ),
168
+ h("div", { className: "ag-kit-card" },
169
+ h("div", { className: "ag-kit-row" },
170
+ h("div", null, h("div", { className: "ag-kit-name" }, "Авто-рой"), h("p", { className: "ag-kit-hint" }, "`project_agent action=auto` сам решает, нужен ли read-only рой. Порог сложности и лимит агентов.")),
171
+ h("label", { className: "ag-switch" }, h("input", { type: "checkbox", checked: swarm.enabled !== false, disabled: busy, onChange: (event) => onSave({ swarm: { enabled: event.target.checked } }) }), swarm.enabled !== false ? "вкл" : "выкл"),
172
+ ),
173
+ h("div", { className: "ag-kit-ctl" },
174
+ h("label", { className: "ag-kit-hint" }, "Порог",
175
+ h("select", { className: "ag-kit-select", value: swarm.threshold ?? 3, disabled: busy || swarm.enabled === false, onChange: (event) => onSave({ swarm: { threshold: Number(event.target.value) } }) }, [1, 2, 3, 4, 5].map((value) => h("option", { key: value, value }, String(value))))),
176
+ h("label", { className: "ag-kit-hint" }, "Агентов",
177
+ h("select", { className: "ag-kit-select", value: swarm.maxAgents ?? 4, disabled: busy || swarm.enabled === false, onChange: (event) => onSave({ swarm: { maxAgents: Number(event.target.value) } }) }, [2, 3, 4, 5, 6].map((value) => h("option", { key: value, value }, String(value))))),
178
+ ),
179
+ ),
180
+ h("div", { className: "ag-kit-card" },
181
+ h("div", { className: "ag-kit-row" },
182
+ h("div", null, h("div", { className: "ag-kit-name" }, "MCP bootstrap"), h("p", { className: "ag-kit-hint" }, "Добавляет memory, sequential-thinking и github с trusted=false. Trust — только явно, серверы не запускаются сами.")),
183
+ h("label", { className: "ag-switch" }, h("input", { type: "checkbox", checked: mcp.enabled === true, disabled: busy, onChange: (event) => onMcp(event.target.checked, mcp.trusted === true) }), mcp.enabled ? "вкл" : "выкл"),
184
+ ),
185
+ h("div", { className: "ag-kit-ctl" },
186
+ h("label", { className: "ag-switch" }, h("input", { type: "checkbox", checked: mcp.trusted === true, disabled: busy, onChange: (event) => onMcp(mcp.enabled === true, event.target.checked) }), "Доверять подключённым"),
187
+ h("button", { className: "ag-btn", type: "button", disabled: busy || mcp.trusted === true, onClick: () => onMcp(mcp.enabled === true, true) }, mcp.trusted ? "Доверено" : "Доверять все"),
188
+ ),
189
+ ),
190
+ ),
191
+ h("div", { className: "ag-kit-foot" },
192
+ h("p", { className: "ag-kit-hint" }, "Trusted-серверы запускаются при старте DSH; настройки MCP — в разделе MCP."),
193
+ h("span", { className: "ag-kit-saved" }, kit.mcpBootstrap?.trusted ? "MCP trusted" : "MCP untrusted"),
194
+ ),
195
+ );
196
+ }
197
+
123
198
  function AgentsSection(props) {
124
199
  const [state, setState] = useState({ loading: true, error: null, data: null });
200
+ const [kit, setKit] = useState(null);
201
+ const [kitBusy, setKitBusy] = useState(false);
125
202
  const [canceling, setCanceling] = useState("");
126
203
  const [transcript, setTranscript] = useState(null);
127
204
  const useSessions = props && props.useSessions;
@@ -157,6 +234,42 @@ window.__ModuleLoader__.load({
157
234
  return () => { cancelled = true; };
158
235
  }, [sessionId, cwd]);
159
236
 
237
+ useEffect(() => {
238
+ let cancelled = false;
239
+ (async () => {
240
+ try {
241
+ const data = await call(window.__DSH_AGENTS_CTX__, "settings", {});
242
+ if (!cancelled) setKit(data);
243
+ } catch { /* controls stay hidden if host API is unavailable */ }
244
+ })();
245
+ return () => { cancelled = true; };
246
+ }, []);
247
+
248
+ const saveKit = async (patch) => {
249
+ setKitBusy(true);
250
+ try {
251
+ const data = await call(window.__DSH_AGENTS_CTX__, "settings.update", { settings: patch });
252
+ setKit(data);
253
+ } catch (error) {
254
+ setState((current) => ({ ...current, error: fallbackError(error) }));
255
+ } finally {
256
+ setKitBusy(false);
257
+ }
258
+ };
259
+
260
+ const saveMcp = async (enabled, trusted) => {
261
+ setKitBusy(true);
262
+ setKit((current) => ({ ...(current ?? {}), mcpBootstrap: { enabled, trusted } }));
263
+ try {
264
+ const data = await call(window.__DSH_AGENTS_CTX__, "settings.update", { mcpBootstrap: { enabled, trusted } });
265
+ setKit(data);
266
+ } catch (error) {
267
+ setState((current) => ({ ...current, error: fallbackError(error) }));
268
+ } finally {
269
+ setKitBusy(false);
270
+ }
271
+ };
272
+
160
273
  const cancel = async (id) => {
161
274
  setCanceling(id);
162
275
  try {
@@ -181,6 +294,8 @@ window.__ModuleLoader__.load({
181
294
 
182
295
  const agents = Array.isArray(state.data?.agents) ? state.data.agents : [];
183
296
  const worktrees = Array.isArray(state.data?.worktrees) ? state.data.worktrees : [];
297
+ const worktreeError = typeof state.data?.worktreeError === "string" ? state.data.worktreeError : "";
298
+ const noGitWorktree = /not a git repository|not a git repo/iu.test(worktreeError);
184
299
  const runs = Array.isArray(state.data?.runs) ? state.data.runs : [];
185
300
  const rawBoard = state.data?.board ?? {};
186
301
  const board = {
@@ -199,6 +314,7 @@ window.__ModuleLoader__.load({
199
314
  h("button", { className: "ag-btn", type: "button", onClick: () => void load() }, "Обновить"),
200
315
  ),
201
316
  state.error ? h("div", { className: "ag-error", role: "alert" }, state.error) : null,
317
+ h(KitPanel, { kit, busy: kitBusy, onSave: saveKit, onMcp: saveMcp }),
202
318
  h("div", { className: "ag-stats" },
203
319
  h("div", { className: "ag-stat" }, h("b", null, agents.length), h("span", null, "агентов")),
204
320
  h("div", { className: "ag-stat" }, h("b", null, readOnly), h("span", null, "read-only")),
@@ -240,7 +356,8 @@ window.__ModuleLoader__.load({
240
356
  h("div", { className: "ag-section" },
241
357
  h("h3", null, "Worktrees"),
242
358
  h("p", { className: "ag-hint" }, "Изолированные рабочие копии: `project_worktree create` или `project_agent` с `worktree=auto`."),
243
- state.data?.worktreeError ? h("div", { className: "ag-error", role: "alert" }, state.data.worktreeError) : null,
359
+ state.data?.worktreeError && !noGitWorktree ? h("div", { className: "ag-error", role: "alert" }, state.data.worktreeError) : null,
360
+ noGitWorktree ? h("div", { className: "ag-note" }, "Этот workspace не git-репозиторий, поэтому worktrees недоступны. Открой конкретный git-репозиторий (например, `dsh-desktop-kit`) — тогда `project_worktree` и `worktree=auto` заработают. Текущие агенты и рой работают без worktrees.") : null,
244
361
  worktrees.length > 0 ? h("div", { className: "ag-items" }, worktrees.map((tree) => h("article", { className: "ag-item", key: tree.id },
245
362
  h("div", { className: "ag-item-top" },
246
363
  h("code", { title: tree.branch || tree.id }, tree.branch || tree.id),
@@ -31,6 +31,16 @@ const TOOL = "project_agent";
31
31
  const WORKTREE_TOOL = "project_worktree";
32
32
  const AUTO_CHECKPOINT_MS = 10 * 60_000;
33
33
 
34
+ function toolOutput() {
35
+ return {
36
+ schema: { type: "object", additionalProperties: true },
37
+ render(_args, value) {
38
+ const text = typeof value?.text === "string" ? value.text : JSON.stringify(value);
39
+ return [{ type: "text", text: String(text).slice(0, 40_000) }];
40
+ },
41
+ };
42
+ }
43
+
34
44
  function safeSlug(name) {
35
45
  return String(name ?? "agent").toLowerCase().replace(/[^a-z0-9-]+/gu, "-").replace(/^-+|-+$/gu, "").slice(0, 30) || "agent";
36
46
  }
@@ -55,6 +65,8 @@ function toolDefinition(ctx) {
55
65
  lead: { type: "string", description: "Optional read-only coordinator agent; receives member run ids and can message them" },
56
66
  preset: { type: "string", description: "Team preset from `.dsh/teams/<name>.json` (members + lead)" },
57
67
  task: { type: "string", description: "Task/prompt for the child agent (required for run)" },
68
+ model: { type: "string", description: "Optional model override for run (for example deepseek-v4-pro or deepseek-flash)" },
69
+ effort: { type: "string", enum: ["off", "low", "high", "max"], description: "Optional reasoning effort override for run" },
58
70
  background: { type: "boolean", description: "Return immediately with a durable run id instead of waiting for the child" },
59
71
  worktree: { type: "string", description: "Run in a git worktree: `auto` picks a name, or pass a lowercase slug" },
60
72
  worktrees: { type: "boolean", description: "For team: give every writer its own worktree/branch (required for non-read-only agents)" },
@@ -62,12 +74,13 @@ function toolDefinition(ctx) {
62
74
  },
63
75
  required: ["action"],
64
76
  },
77
+ output: toolOutput(),
65
78
  async execute(input, exec) {
66
79
  const project = projectFromAgent(exec?.agent);
67
80
  const agents = loadAgents(project.root, project.dsh ?? path.join(project.root, ".dsh"));
68
81
  if (input?.action === "list") {
69
82
  const text = agents.length
70
- ? agents.map((agent) => `- ${agent.name}${agent.model ? ` · ${agent.model}` : ""}${agent.description ? ` — ${agent.description}` : ""}`).join("\n")
83
+ ? agents.map((agent) => `- ${agent.name}${agent.model ? ` · ${agent.model}` : ""}${agent.effort ? `/${agent.effort}` : ""}${agent.description ? ` — ${agent.description}` : ""}`).join("\n")
71
84
  : "Нет проектных агентов. Создайте `.dsh/agents/<name>.md`.";
72
85
  return { ok: true, text: `project_agent list:\n${text}` };
73
86
  }
@@ -171,13 +184,14 @@ function toolDefinition(ctx) {
171
184
  background: input?.background === true,
172
185
  worktree,
173
186
  cwd: worktree?.path,
187
+ route: { model: input?.model, effort: input?.effort },
174
188
  });
175
189
  if (result.background) {
176
190
  if (result.error) return { ok: false, text: result.text, background: true, id: result.id };
177
191
  return { ok: true, text: result.text, background: true, id: result.id, worktree };
178
192
  }
179
193
  const suffix = worktree ? `\nworktree: ${worktree.branch} → ${worktree.path}` : "";
180
- return { ok: true, text: `project_agent ${name} (${result.stopReason}):\n${result.text}${suffix}`, worktree };
194
+ return { ok: true, text: `project_agent ${name} (${result.stopReason}) · ${result.route?.model ?? "default"}/${result.route?.reasoningEffort ?? "default"}:\n${result.text}${suffix}`, worktree, route: result.route };
181
195
  } catch (error) {
182
196
  const suffix = worktree ? ` (worktree ${worktree.branch} сохранён для разбора)` : "";
183
197
  return { ok: false, text: `project_agent ${name}: ${error instanceof Error ? error.message : String(error)}${suffix}` };
@@ -202,6 +216,7 @@ function worktreeToolDefinition() {
202
216
  },
203
217
  required: ["action"],
204
218
  },
219
+ output: toolOutput(),
205
220
  async execute(input, exec) {
206
221
  const project = projectFromAgent(exec?.agent);
207
222
  try {
@@ -252,9 +267,12 @@ function boardToolDefinition() {
252
267
  title: { type: "string", description: "task title for add-task" },
253
268
  id: { type: "string", description: "task id for claim-task/done-task" },
254
269
  dependsOn: { type: "array", items: { type: "string" }, description: "task ids that must be done first" },
270
+ acceptance: { type: "string", description: "acceptance criteria for add-task; enables evidence gate" },
271
+ evidence: { type: "string", description: "evidence for done-task (file:line, command/result or URL/date)" },
255
272
  },
256
273
  required: ["action"],
257
274
  },
275
+ output: toolOutput(),
258
276
  async execute(input, exec) {
259
277
  const cwd = exec?.agent?.session?.header?.cwd;
260
278
  const teamId = String(input?.teamId ?? "");
@@ -271,11 +289,11 @@ function boardToolDefinition() {
271
289
  return { ok: true, text: `team_board ${teamId || "all"}:\n${messages.join("\n") || "messages: none"}\n${tasks.join("\n") || "tasks: none"}`, messages: board.messages, tasks: board.tasks };
272
290
  }
273
291
  if (input?.action === "add-task") {
274
- const result = addTask(cwd, { teamId, title: input?.title, owner: from, dependsOn: input?.dependsOn, priority: input?.priority });
275
- return { ok: true, text: `team_board task: ${result.task.id} · ${result.task.title}`, task: result.task };
292
+ const result = addTask(cwd, { teamId, title: input?.title, owner: from, dependsOn: input?.dependsOn, priority: input?.priority, acceptance: input?.acceptance });
293
+ return { ok: true, text: `team_board task: ${result.task.id} · ${result.task.title}${result.task.requiresEvidence ? " · evidence required" : ""}`, task: result.task };
276
294
  }
277
295
  if (input?.action === "claim-task" || input?.action === "done-task") {
278
- const result = updateTask(cwd, { id: input?.id, status: input.action === "claim-task" ? "claimed" : "done", owner: from });
296
+ const result = updateTask(cwd, { id: input?.id, status: input.action === "claim-task" ? "claimed" : "done", owner: from, evidence: input?.evidence });
279
297
  return { ok: true, text: `team_board task: ${result.task.id} · ${result.task.status}`, task: result.task };
280
298
  }
281
299
  return { ok: false, text: "team_board: unsupported action" };
@@ -302,6 +320,7 @@ function teamMessageToolDefinition() {
302
320
  },
303
321
  required: ["action", "to", "text"],
304
322
  },
323
+ output: toolOutput(),
305
324
  async execute(input, exec) {
306
325
  try {
307
326
  const result = await sendTeamMessage(ctx, exec, { to: input?.to, text: input?.text, teamId: input?.teamId });
@@ -10,6 +10,8 @@ import { loadAgents, projectFor } from "./project.js";
10
10
  import { clearChildPolicy, setChildPolicy } from "./policy.js";
11
11
  import { loadRuns, runPreview, updateRun, upsertRun } from "./runs.js";
12
12
  import { saveTranscript } from "./transcripts.js";
13
+ import { findingsPrompt, parseFindings, validateFindings } from "./findings.js";
14
+ import { agentOptionsFor, chooseAgentRoute } from "./routing.js";
13
15
 
14
16
  const background = new Map();
15
17
 
@@ -47,6 +49,7 @@ export async function runProjectAgent(ctx, exec, definition, task, options = {})
47
49
  else signal?.addEventListener?.("abort", abort, { once: true });
48
50
  const reservedId = crypto.randomUUID();
49
51
  let activeId = reservedId;
52
+ const route = chooseAgentRoute(definition, task, options.route);
50
53
  setChildPolicy(reservedId, definition);
51
54
  let activation;
52
55
  try {
@@ -55,7 +58,9 @@ export async function runProjectAgent(ctx, exec, definition, task, options = {})
55
58
  definition.body,
56
59
  "</project-agent>",
57
60
  options.teamId ? `<team id="${options.teamId}">Use team_board action=post/read with teamId=${options.teamId} to share findings; use add-task/claim/done for work items. Use team_message to=\"parent\" for a live message to the lead; sibling live messaging is not available — the board is the shared channel.</team>` : "",
58
- options.leadContext ? `<team-lead>You coordinate this team. Members: ${options.leadContext}. Read the board first; assign/claim tasks; use team_message to=<run-id> for live directions and team_message to=\"parent\" to report to the parent.</team-lead>` : "",
61
+ options.leadContext ? `<team-lead>You coordinate this team. Members: ${options.leadContext}. Read the board first; assign/claim tasks with acceptance criteria and non-overlapping scopes; use team_message to=<run-id> for live directions and team_message to=\"parent\" to report to the parent. Finish with a PASS/FAIL synthesis, blockers and unresolved risks.</team-lead>` : "",
62
+ "<quality>Evidence over confidence: for code claims cite file:line; for test claims quote the command and result; separate facts from assumptions; never invent a test, source or passing result. Findings: severity · location · evidence · impact · fix. If evidence is missing, say unknown. Final report: PASS/FAIL, blockers, uncertain items.</quality>",
63
+ definition.output === "findings" ? findingsPrompt() : "",
59
64
  "",
60
65
  "Task:",
61
66
  String(task ?? ""),
@@ -69,7 +74,7 @@ export async function runProjectAgent(ctx, exec, definition, task, options = {})
69
74
  parent: exec.agent,
70
75
  signal: controller.signal,
71
76
  cwd,
72
- ...(definition.model ? { agentOptions: { model: definition.model } } : {}),
77
+ ...(route.model || route.reasoningEffort ? { agentOptions: agentOptionsFor(route) } : {}),
73
78
  },
74
79
  signal: controller.signal,
75
80
  delivery: "caller",
@@ -143,7 +148,25 @@ export async function runProjectAgent(ctx, exec, definition, task, options = {})
143
148
  const text = textFromOutput(result?.output);
144
149
  await activation.dispose?.();
145
150
  if (!text) throw new Error(`project agent ${definition.name} returned no text`);
146
- return { text, stopReason: result?.stopReason ?? "completed", worktree: options.worktree ?? null };
151
+ let findings = null;
152
+ let findingsError = "";
153
+ if (definition.output === "findings") {
154
+ const parsed = parseFindings(text);
155
+ if (!parsed.ok) findingsError = parsed.error;
156
+ else {
157
+ const validated = validateFindings(parsed.value);
158
+ if (validated.ok) findings = validated.value;
159
+ else findingsError = validated.errors.join("; ");
160
+ }
161
+ if (!findings) findingsError = `findings contract violated: ${findingsError}`;
162
+ }
163
+ return {
164
+ text: findingsError ? `${text}\n\n[findings-format] ${findingsError}` : text,
165
+ stopReason: result?.stopReason ?? "completed",
166
+ worktree: options.worktree ?? null,
167
+ ...(definition.output === "findings" ? { findings, findingsValid: Boolean(findings), findingsError } : {}),
168
+ route,
169
+ };
147
170
  } catch (error) {
148
171
  clearChildPolicy(activeId);
149
172
  if (isBackground) {