@dsmm/dsmm 0.2.0 → 0.2.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.
Files changed (291) hide show
  1. package/README.md +38 -66
  2. package/agent-presets/dsmm-builder/agent.cordis.yml +10 -2015
  3. package/agent-presets/dsmm-clarifier/agent.cordis.yml +24 -343
  4. package/agent-presets/dsmm-code-search/agent.cordis.yml +19 -6
  5. package/agent-presets/dsmm-coding/agent.cordis.yml +19 -438
  6. package/agent-presets/dsmm-complex/agent.cordis.yml +23 -1009
  7. package/agent-presets/dsmm-creative/agent.cordis.yml +25 -442
  8. package/agent-presets/dsmm-cross-cutting/agent.cordis.yml +29 -1013
  9. package/agent-presets/dsmm-deep/agent.cordis.yml +24 -1008
  10. package/agent-presets/dsmm-doc-search/agent.cordis.yml +19 -6
  11. package/agent-presets/dsmm-documenting/agent.cordis.yml +26 -439
  12. package/agent-presets/dsmm-frontend/agent.cordis.yml +21 -440
  13. package/agent-presets/dsmm-hard-reasoning/agent.cordis.yml +22 -441
  14. package/agent-presets/dsmm-media-reader/agent.cordis.yml +19 -6
  15. package/agent-presets/dsmm-normal-task/agent.cordis.yml +19 -438
  16. package/agent-presets/dsmm-oracle/agent.cordis.yml +25 -340
  17. package/agent-presets/dsmm-oracle-2nd/agent.cordis.yml +25 -340
  18. package/agent-presets/dsmm-orchestrator/agent.cordis.yml +29 -2025
  19. package/agent-presets/dsmm-plan-critic/agent.cordis.yml +24 -341
  20. package/agent-presets/dsmm-planner/agent.cordis.yml +14 -344
  21. package/agent-presets/dsmm-quick/agent.cordis.yml +19 -6
  22. package/agent-presets/dsmm-research/agent.cordis.yml +23 -8
  23. package/agent-presets/dsmm-reviewer/agent.cordis.yml +25 -340
  24. package/docs/agent-presets.md +36 -52
  25. package/docs/compatibility.md +50 -108
  26. package/docs/deferred-native-approval-risk.md +19 -0
  27. package/docs/design.md +2 -2
  28. package/docs/lsp.md +11 -21
  29. package/docs/migration-from-ocmm.md +2 -2
  30. package/docs/model-routing.md +84 -59
  31. package/docs/native-permissions.md +35 -0
  32. package/docs/profiles.md +40 -87
  33. package/docs/releasing.md +83 -2
  34. package/docs/roadmap.md +71 -17
  35. package/docs/settings-status.md +34 -169
  36. package/docs/skill-sync.md +52 -15
  37. package/lib/child-admission-contract.d.ts +37 -0
  38. package/lib/child-admission-contract.js +2 -0
  39. package/lib/child-admission.d.ts +42 -0
  40. package/lib/child-admission.js +162 -0
  41. package/lib/child-capture.d.ts +81 -0
  42. package/lib/child-capture.js +203 -0
  43. package/lib/child-evidence.d.ts +17 -0
  44. package/lib/child-evidence.js +43 -0
  45. package/lib/client/ChildrenPanel.d.ts +43 -0
  46. package/lib/client/ChildrenPanel.js +82 -0
  47. package/lib/client/DeploymentPage.js +15 -8
  48. package/lib/client/EditableChoice.d.ts +17 -0
  49. package/lib/client/EditableChoice.js +49 -0
  50. package/lib/client/PermissionsPanel.d.ts +14 -0
  51. package/lib/client/PermissionsPanel.js +46 -0
  52. package/lib/client/ProfilesSection.js +30 -15
  53. package/lib/client/RoleAvailability.d.ts +7 -0
  54. package/lib/client/RoleAvailability.js +19 -0
  55. package/lib/client/SessionProfiles.js +27 -9
  56. package/lib/client/StructuredEditor.js +15 -7
  57. package/lib/client/children-controller.d.ts +98 -0
  58. package/lib/client/children-controller.js +296 -0
  59. package/lib/client/children-locales.d.ts +367 -0
  60. package/lib/client/children-locales.js +69 -0
  61. package/lib/client/controller.d.ts +6 -1
  62. package/lib/client/controller.js +14 -8
  63. package/lib/client/deployment-data.d.ts +2 -1
  64. package/lib/client/deployment-data.js +34 -5
  65. package/lib/client/deployment-locales.d.ts +4 -0
  66. package/lib/client/deployment-locales.js +11 -2
  67. package/lib/client/diagnostics.d.ts +14 -0
  68. package/lib/client/diagnostics.js +53 -0
  69. package/lib/client/index.d.ts +4 -0
  70. package/lib/client/index.js +96 -2
  71. package/lib/client/locales.d.ts +54 -0
  72. package/lib/client/locales.js +34 -16
  73. package/lib/client/permission-client.d.ts +16 -0
  74. package/lib/client/permission-client.js +38 -0
  75. package/lib/client/permission-controller.d.ts +62 -0
  76. package/lib/client/permission-controller.js +149 -0
  77. package/lib/client/permission-locales.d.ts +114 -0
  78. package/lib/client/permission-locales.js +75 -0
  79. package/lib/client/session-labels.js +4 -4
  80. package/lib/client/structured.js +19 -5
  81. package/lib/client/styles.d.ts +1 -1
  82. package/lib/client/styles.js +20 -0
  83. package/lib/client.js +5780 -1679
  84. package/lib/core-permission-authority.d.ts +18 -0
  85. package/lib/core-permission-authority.js +255 -0
  86. package/lib/core-permissions.d.ts +8 -0
  87. package/lib/core-permissions.js +33 -0
  88. package/lib/delivery-authority.d.ts +68 -0
  89. package/lib/delivery-authority.js +260 -0
  90. package/lib/deployment-config.d.ts +23 -0
  91. package/lib/deployment-config.js +61 -40
  92. package/lib/deployment-permission-rules.d.ts +55 -0
  93. package/lib/deployment-permission-rules.js +306 -0
  94. package/lib/dsh-types.d.ts +10 -4
  95. package/lib/guards.d.ts +1 -1
  96. package/lib/guards.js +29 -8
  97. package/lib/host-llm-startup.d.ts +41 -0
  98. package/lib/host-llm-startup.js +65 -0
  99. package/lib/host-llm.d.ts +92 -0
  100. package/lib/host-llm.js +325 -0
  101. package/lib/index.d.ts +15 -4
  102. package/lib/index.js +300 -47
  103. package/lib/legacy-child-policy.d.ts +51 -0
  104. package/lib/legacy-child-policy.js +123 -0
  105. package/lib/legacy-read-composition.d.ts +20 -0
  106. package/lib/legacy-read-composition.js +144 -0
  107. package/lib/legacy-read-contracts.d.ts +157 -0
  108. package/lib/legacy-read-contracts.js +39 -0
  109. package/lib/legacy-read-host.d.ts +19 -0
  110. package/lib/legacy-read-host.js +67 -0
  111. package/lib/legacy-read-integration.d.ts +121 -0
  112. package/lib/legacy-read-integration.js +522 -0
  113. package/lib/legacy-read-proxy.d.ts +26 -0
  114. package/lib/legacy-read-proxy.js +237 -0
  115. package/lib/live-pi-ai-owner.d.ts +18 -0
  116. package/lib/live-pi-ai-owner.js +144 -0
  117. package/lib/llm-runtime.d.ts +11 -0
  118. package/lib/llm-runtime.js +21 -0
  119. package/lib/managed-settings.d.ts +5 -0
  120. package/lib/managed-settings.js +14 -0
  121. package/lib/model-parameter-policy.d.ts +11 -0
  122. package/lib/model-parameter-policy.js +27 -0
  123. package/lib/model-routing.js +28 -17
  124. package/lib/modules.d.ts +13 -5
  125. package/lib/modules.js +17 -1
  126. package/lib/native-child-evidence.d.ts +42 -0
  127. package/lib/native-child-evidence.js +133 -0
  128. package/lib/native-pi-ai-wire.d.ts +37 -0
  129. package/lib/native-pi-ai-wire.js +261 -0
  130. package/lib/native-scope.js +1 -1
  131. package/lib/permission-bash.d.ts +6 -0
  132. package/lib/permission-bash.js +7 -0
  133. package/lib/permission-control.d.ts +73 -0
  134. package/lib/permission-control.js +205 -0
  135. package/lib/permission-controller.d.ts +68 -0
  136. package/lib/permission-controller.js +317 -0
  137. package/lib/permission-errors.d.ts +7 -0
  138. package/lib/permission-errors.js +21 -0
  139. package/lib/permission-fs-search.d.ts +5 -0
  140. package/lib/permission-fs-search.js +7 -0
  141. package/lib/permission-fs.d.ts +5 -0
  142. package/lib/permission-fs.js +7 -0
  143. package/lib/permission-native-access.d.ts +11 -0
  144. package/lib/permission-native-access.js +6 -0
  145. package/lib/permission-native-command.d.ts +10 -0
  146. package/lib/permission-native-command.js +93 -0
  147. package/lib/permission-native-rules.d.ts +75 -0
  148. package/lib/permission-native-rules.js +278 -0
  149. package/lib/permission-pwsh.d.ts +6 -0
  150. package/lib/permission-pwsh.js +7 -0
  151. package/lib/permission-remote.d.ts +26 -0
  152. package/lib/permission-remote.js +53 -0
  153. package/lib/permission-rpc.d.ts +29 -0
  154. package/lib/permission-rpc.js +152 -0
  155. package/lib/permission-rules.d.ts +115 -0
  156. package/lib/permission-rules.js +256 -0
  157. package/lib/permission-settings.d.ts +45 -0
  158. package/lib/permission-settings.js +48 -0
  159. package/lib/permission-shell.d.ts +38 -0
  160. package/lib/permission-shell.js +150 -0
  161. package/lib/permission-web.d.ts +5 -0
  162. package/lib/permission-web.js +7 -0
  163. package/lib/preset-registry.js +36 -25
  164. package/lib/profile-diagnostics.d.ts +45 -0
  165. package/lib/profile-diagnostics.js +148 -0
  166. package/lib/profile-locale.d.ts +3 -0
  167. package/lib/profile-locale.js +2 -0
  168. package/lib/profile-remote.d.ts +8 -0
  169. package/lib/profile-remote.js +163 -39
  170. package/lib/profile-rpc.d.ts +4 -3
  171. package/lib/profile-rpc.js +14 -12
  172. package/lib/profile-runtime.d.ts +40 -1
  173. package/lib/profile-runtime.js +368 -93
  174. package/lib/profile-store.d.ts +11 -0
  175. package/lib/profile-store.js +143 -11
  176. package/lib/profile-types.d.ts +70 -1
  177. package/lib/profile-types.js +1 -0
  178. package/lib/profiles.d.ts +16 -2
  179. package/lib/profiles.js +156 -79
  180. package/lib/prompt-content.js +1 -1
  181. package/lib/prompts.d.ts +37 -2
  182. package/lib/prompts.js +111 -9
  183. package/lib/recovery-policy.js +20 -7
  184. package/lib/role-control-remote.d.ts +38 -0
  185. package/lib/role-control-remote.js +211 -0
  186. package/lib/role-control-rpc.d.ts +51 -0
  187. package/lib/role-control-rpc.js +377 -0
  188. package/lib/role-control-types.d.ts +92 -0
  189. package/lib/role-control-types.js +8 -0
  190. package/lib/role-invocation.d.ts +47 -0
  191. package/lib/role-invocation.js +135 -0
  192. package/lib/role-llm-runtime.d.ts +17 -0
  193. package/lib/role-llm-runtime.js +62 -0
  194. package/lib/role-llm.d.ts +31 -0
  195. package/lib/role-llm.js +66 -0
  196. package/lib/role-policy.d.ts +49 -8
  197. package/lib/role-policy.js +437 -60
  198. package/lib/role-providers.d.ts +1 -1
  199. package/lib/role-providers.js +30 -35
  200. package/lib/role-routing.d.ts +11 -2
  201. package/lib/role-routing.js +42 -25
  202. package/lib/role-runs.d.ts +135 -0
  203. package/lib/role-runs.js +304 -0
  204. package/lib/role-subagents.d.ts +58 -3
  205. package/lib/role-subagents.js +169 -56
  206. package/lib/roles.d.ts +5 -6
  207. package/lib/roles.js +10 -39
  208. package/lib/route-json.d.ts +19 -0
  209. package/lib/route-json.js +129 -0
  210. package/lib/routing-policy.d.ts +2 -0
  211. package/lib/routing-policy.js +12 -2
  212. package/lib/runtime-integration.d.ts +112 -0
  213. package/lib/runtime-integration.js +784 -0
  214. package/lib/runtime-recovery.js +18 -8
  215. package/lib/settings.d.ts +47 -13
  216. package/lib/settings.js +217 -82
  217. package/lib/skills.js +2 -2
  218. package/lib/status.d.ts +10 -1
  219. package/lib/status.js +11 -8
  220. package/lib/subagent-runtime.d.ts +45 -0
  221. package/lib/subagent-runtime.js +131 -0
  222. package/package.json +106 -56
  223. package/patches/subagent-runtime.yml +15 -0
  224. package/prompts/deepseek-flash.md +1 -1
  225. package/prompts/deepseek-v4-pro.md +2 -2
  226. package/prompts/deepwork.md +27 -18
  227. package/prompts/source/agents/clarifier.md +5 -3
  228. package/prompts/source/agents/orchestrator.md +18 -9
  229. package/prompts/source/agents/plan-critic.md +5 -1
  230. package/prompts/source/agents/planner.md +4 -2
  231. package/prompts/source/agents/reviewer.md +6 -0
  232. package/prompts/source/category/complex.md +4 -4
  233. package/prompts/source/category/creative.md +6 -4
  234. package/prompts/source/category/cross-cutting.md +10 -8
  235. package/prompts/source/category/deep.md +5 -3
  236. package/prompts/source/category/documenting.md +7 -1
  237. package/prompts/source/category/frontend.md +2 -2
  238. package/prompts/source/category/hard-reasoning.md +3 -3
  239. package/prompts/source/category/research.md +4 -2
  240. package/prompts/source/deepwork/claude-opus-5.md +2 -2
  241. package/prompts/source/deepwork/codex.md +1 -1
  242. package/prompts/source/deepwork/default.md +22 -15
  243. package/prompts/source/deepwork/gemini.md +23 -16
  244. package/prompts/source/deepwork/glm.md +21 -14
  245. package/prompts/source/deepwork/gpt.md +12 -6
  246. package/prompts/source/deepwork/planner.md +8 -5
  247. package/prompts/source/manifest.json +178 -63
  248. package/prompts/source/shared/dsh-host-contract.md +5 -3
  249. package/prompts/source/shared/locale.md +2 -2
  250. package/prompts/source/terminal/orchestrator.md +1 -1
  251. package/scripts/cold-profile-composition.mjs +329 -0
  252. package/scripts/cold-profile-sources.mjs +238 -0
  253. package/scripts/migrate-cold-profile.mjs +315 -0
  254. package/skills/ast-grep/SKILL.md +7 -4
  255. package/skills/brainstorming/SKILL.md +43 -22
  256. package/skills/coding-agent-sessions/SKILL.md +7 -4
  257. package/skills/coding-agent-sessions/scripts/agent_sessions/pi_family.py +46 -46
  258. package/skills/coding-agent-sessions/scripts/tests/test_pi_family_scanners.py +130 -130
  259. package/skills/debugging/SKILL.md +14 -9
  260. package/skills/debugging/references/methodology/00-setup.md +14 -62
  261. package/skills/debugging/references/methodology/02-investigate.md +4 -4
  262. package/skills/debugging/references/methodology/03-flaky-triage.md +3 -3
  263. package/skills/debugging/references/methodology/04-hard-reasoning-escalation.md +2 -14
  264. package/skills/debugging/references/methodology/06-fix.md +6 -6
  265. package/skills/debugging/references/methodology/08-qa.md +5 -5
  266. package/skills/debugging/references/methodology/09-cleanup.md +15 -153
  267. package/skills/debugging/references/methodology/partial-runtime-evidence.md +3 -16
  268. package/skills/debugging/references/runtimes/bundled-js-binary.md +1 -16
  269. package/skills/debugging/references/runtimes/native-binary.md +9 -54
  270. package/skills/debugging/references/runtimes/node.md +4 -15
  271. package/skills/debugging/references/runtimes/python.md +3 -15
  272. package/skills/debugging/references/runtimes/rust.md +2 -18
  273. package/skills/debugging/references/tools/dap.md +1 -1
  274. package/skills/debugging/references/tools/ghidra.md +4 -15
  275. package/skills/debugging/references/tools/playwright-cli.md +3 -15
  276. package/skills/debugging/references/tools/pwntools.md +4 -16
  277. package/skills/dispatching-parallel-agents/SKILL.md +18 -16
  278. package/skills/frontend/SKILL.md +7 -4
  279. package/skills/frontend/references/design/react-dev-tooling-skill.md +1 -1
  280. package/skills/git-master/SKILL.md +7 -4
  281. package/skills/init-deep/SKILL.md +7 -4
  282. package/skills/receiving-code-review/SKILL.md +17 -12
  283. package/skills/remove-ai-slops/SKILL.md +39 -38
  284. package/skills/requesting-code-review/SKILL.md +19 -17
  285. package/skills/requesting-code-review/code-reviewer.md +13 -1
  286. package/skills/subagent-driven-development/SKILL.md +29 -26
  287. package/skills/subagent-driven-development/implementer-prompt.md +29 -11
  288. package/skills/subagent-driven-development/spec-reviewer-prompt.md +6 -1
  289. package/skills/using-git-worktrees/SKILL.md +7 -4
  290. package/skills/writing-plans/SKILL.md +29 -24
  291. package/skills/writing-plans/plan-document-reviewer-prompt.md +10 -1
package/lib/settings.js CHANGED
@@ -1,30 +1,36 @@
1
1
  import Schema from "@deepseek-ai/schemastery";
2
2
  import { DEFAULT_DSMM_LSP_SETTINGS, resolveLspSettings } from "./lsp.js";
3
- import { DSMM_ROLES, DSMM_ROLE_IDS } from "./roles.js";
3
+ import { DSMM_ROLES, DSMM_ROLE_IDS, isRootRole } from "./roles.js";
4
4
  import { DSMM_SKILL_NAMES } from "./skills.js";
5
5
  import { DEFAULT_DSMM_RUNTIME_POLICY, DSMM_RATE_LIMIT_BOUNDS, normalizeRateLimitOverrides, normalizeRoutingStrategy, normalizeRuntimePolicy, resolveRoleRuntimePolicy } from "./routing-policy.js";
6
+ import { DEPRECATED_DSMM_FIELDS, DsmmConfigValidationError, safeDiagnosticField } from "./profile-diagnostics.js";
7
+ import { DSMM_LOCALES } from "./profile-locale.js";
8
+ import { normalizeModelRouteJson, validateModelRouteFieldName } from "./route-json.js";
9
+ import { DEFAULT_PERMISSION_CONTROL, permissionControlSchema, resolvePermissionControl } from "./permission-settings.js";
10
+ export { DSMM_LOCALES } from "./profile-locale.js";
6
11
  export { resolveRoleRuntimePolicy } from "./routing-policy.js";
7
12
  export { DSMM_SKILL_NAMES, MVP_SKILL_NAMES } from "./skills.js";
8
13
  export const DSMM_STATUS_COMMAND = "dsmm-status";
9
14
  export const DEFAULT_DSMM_SETTINGS = {
15
+ permissionControl: DEFAULT_PERMISSION_CONTROL,
16
+ modelParameters: { passthrough: true },
10
17
  modules: { deepwork: { enabled: true } },
11
18
  modeName: "deepwork",
12
19
  defaultActive: false,
13
20
  promptOrder: 50,
14
21
  deepseekV4ProCalibration: "auto",
15
22
  deepseekV4ProDefaultReasoningEffort: "high",
16
- deepseekV4ProMaxReasoningPresets: ["dsmm-plan-critic", "dsmm-reviewer"],
17
23
  deepseekFlashCalibration: "auto",
18
24
  deepseekFlashDefaultReasoningEffort: "high",
19
- deepseekFlashMaxReasoningPresets: ["dsmm-plan-critic", "dsmm-reviewer"],
20
25
  skills: createDefaultSkillSettings(),
21
26
  roles: createDefaultRoleSettings(),
22
27
  roleRouting: {},
23
28
  runtimePolicy: DEFAULT_DSMM_RUNTIME_POLICY,
24
29
  presets: {
25
- materialize: false
30
+ materialize: false,
31
+ plannerRootEnabled: false
26
32
  },
27
- subagents: { enableRunInBackground: false, backgroundMode: "one-shot" },
33
+ subagents: { enableRunInBackground: false, backgroundMode: "one-shot", toolTopology: "per-role", allowRouteOverride: false },
28
34
  workflow: {
29
35
  policy: "risk-based",
30
36
  strictGates: true,
@@ -71,11 +77,18 @@ function createDefaultRoleSettings() {
71
77
  }
72
78
  const SKILLS_SCHEMA = Schema.object(Object.fromEntries(DSMM_SKILL_NAMES.map((name) => [name, Schema.boolean().default(DEFAULT_DSMM_SETTINGS.skills[name])])));
73
79
  const ROLES_SCHEMA = Schema.object(Object.fromEntries(DSMM_ROLE_IDS.map((id) => [id, Schema.boolean().default(DEFAULT_DSMM_SETTINGS.roles[id])])));
74
- const MODEL_ROUTE_SCHEMA = Schema.object({
80
+ const MODEL_ROUTE_FIELDS_SCHEMA = Schema.object({
75
81
  provider: Schema.string().required(),
76
82
  model: Schema.string().required(),
77
- reasoningEffort: Schema.string()
83
+ reasoningEffort: Schema.string(),
84
+ temperature: Schema.number(),
85
+ maxTokens: Schema.number().step(1).min(1),
86
+ stop: Schema.array(Schema.string())
78
87
  });
88
+ const MODEL_ROUTE_SCHEMA = Schema.transform(Schema.any(), (input) => normalizeModelRouteJson(input, true, true));
89
+ const LEVEL_OVERRIDE_SCHEMA = Schema.union([MODEL_ROUTE_SCHEMA, Schema.object({ reasoningEffort: Schema.string().required() })]);
90
+ const LEVELS_SCHEMA = Schema.object({ low: LEVEL_OVERRIDE_SCHEMA, high: LEVEL_OVERRIDE_SCHEMA, max: LEVEL_OVERRIDE_SCHEMA });
91
+ const LOCALE_SCHEMA = Schema.union(DSMM_LOCALES.map(locale => Schema.const(locale)));
79
92
  const RATE_LIMIT_CONFIG_SCHEMA = Schema.object(Object.fromEntries(Object.keys(DEFAULT_DSMM_RUNTIME_POLICY.rateLimit).map((key) => [key, Schema.number()])));
80
93
  const ROUTING_STRATEGY_CONFIG_SCHEMA = Schema.union([Schema.const("startup-lock"), Schema.const("rate-limit-fallback")]);
81
94
  const RUNTIME_POLICY_CONFIG_SCHEMA = Schema.object({ strategy: ROUTING_STRATEGY_CONFIG_SCHEMA, rateLimit: RATE_LIMIT_CONFIG_SCHEMA });
@@ -83,6 +96,7 @@ const ROLE_FALLBACK_ROUTE_LIMIT = 32;
83
96
  const ROLE_FALLBACK_ROUTES_SCHEMA = Schema.array(MODEL_ROUTE_SCHEMA);
84
97
  // A dictionary retains unknown keys for fail-closed validation by the resolver.
85
98
  const ROLE_ROUTING_SCHEMA = Schema.dict(Schema.object({
99
+ levels: LEVELS_SCHEMA,
86
100
  primary: Schema.union([Schema.const(undefined), MODEL_ROUTE_SCHEMA]),
87
101
  fallbackRoutes: Schema.union([Schema.const(undefined), ROLE_FALLBACK_ROUTES_SCHEMA]),
88
102
  strategy: ROUTING_STRATEGY_CONFIG_SCHEMA,
@@ -93,10 +107,12 @@ const ROLE_ROUTING_SCHEMA = Schema.dict(Schema.object({
93
107
  const ROLE_ROUTING_VALIDATION_SCHEMA = Schema.transform(Schema.any(), (input) => {
94
108
  if (!isRoutingRecord(input))
95
109
  return input;
110
+ rejectDeprecatedFields(input);
111
+ if (Object.hasOwn(input, "locale"))
112
+ validateLocale(input.locale);
96
113
  if (isRoutingRecord(input.runtimeRecovery) && Array.isArray(input.runtimeRecovery.fallbackRoutes)) {
97
114
  for (const route of input.runtimeRecovery.fallbackRoutes) {
98
- if (isRoutingRecord(route))
99
- normalizeRecoveryEffort(route);
115
+ normalizeExplicitRoute(route);
100
116
  }
101
117
  }
102
118
  const roleRouting = resolveRoleRouting(input.roleRouting);
@@ -105,9 +121,12 @@ const ROLE_ROUTING_VALIDATION_SCHEMA = Schema.transform(Schema.any(), (input) =>
105
121
  });
106
122
  const PRESETS_SCHEMA = Schema.object({
107
123
  materialize: Schema.boolean().default(DEFAULT_DSMM_SETTINGS.presets.materialize),
124
+ plannerRootEnabled: Schema.boolean().default(DEFAULT_DSMM_SETTINGS.presets.plannerRootEnabled),
108
125
  root: Schema.string()
109
126
  });
110
127
  const SUBAGENTS_SCHEMA = Schema.object({
128
+ toolTopology: Schema.union([Schema.const("per-role"), Schema.const("parameterized")]).default("per-role"),
129
+ allowRouteOverride: Schema.boolean().default(false),
111
130
  enableRunInBackground: Schema.boolean().default(false),
112
131
  backgroundMode: Schema.union([Schema.const("one-shot"), Schema.const("continuable")]).default("one-shot"),
113
132
  maxDepth: Schema.number().step(1).min(0).max(Number.MAX_SAFE_INTEGER)
@@ -167,11 +186,7 @@ const RUNTIME_RECOVERY_SCHEMA = Schema.object({
167
186
  enabled: Schema.boolean().default(DEFAULT_DSMM_SETTINGS.runtimeRecovery.enabled),
168
187
  retryOnStatusCodes: Schema.array(Number).default([...DEFAULT_DSMM_SETTINGS.runtimeRecovery.retryOnStatusCodes]),
169
188
  retryOnCodes: Schema.array(String).default([...DEFAULT_DSMM_SETTINGS.runtimeRecovery.retryOnCodes]),
170
- fallbackRoutes: Schema.array(Schema.object({
171
- provider: Schema.string(),
172
- model: Schema.string(),
173
- reasoningEffort: Schema.string()
174
- })).default(DEFAULT_DSMM_SETTINGS.runtimeRecovery.fallbackRoutes.map((route) => ({ ...route }))),
189
+ fallbackRoutes: Schema.array(MODEL_ROUTE_SCHEMA).max(ROLE_FALLBACK_ROUTE_LIMIT).default(DEFAULT_DSMM_SETTINGS.runtimeRecovery.fallbackRoutes.map((route) => ({ ...route }))),
175
190
  maxFallbackAttempts: Schema.number().default(DEFAULT_DSMM_SETTINGS.runtimeRecovery.maxFallbackAttempts),
176
191
  idleContinuation: RUNTIME_RECOVERY_IDLE_CONTINUATION_SCHEMA
177
192
  });
@@ -185,8 +200,6 @@ const DEEPSEEK_DEFAULT_REASONING_EFFORT_SCHEMA = Schema.union([
185
200
  Schema.const("low"),
186
201
  Schema.const("high")
187
202
  ]).default(DEFAULT_DSMM_SETTINGS.deepseekV4ProDefaultReasoningEffort);
188
- const DEEPSEEK_MAX_REASONING_PRESETS_SCHEMA = Schema.array(String)
189
- .default([...DEFAULT_DSMM_SETTINGS.deepseekV4ProMaxReasoningPresets]);
190
203
  const LSP_SCHEMA = Schema.object({
191
204
  enabled: Schema.boolean().default(DEFAULT_DSMM_SETTINGS.lsp.enabled),
192
205
  serverName: Schema.string().default(DEFAULT_DSMM_SETTINGS.lsp.serverName),
@@ -198,6 +211,9 @@ const LSP_SCHEMA = Schema.object({
198
211
  failOnStartupError: Schema.boolean().default(DEFAULT_DSMM_SETTINGS.lsp.failOnStartupError)
199
212
  });
200
213
  const CONFIG_FIELDS_SCHEMA = Schema.object({
214
+ permissionControl: permissionControlSchema,
215
+ modelParameters: Schema.object({ passthrough: Schema.boolean().default(DEFAULT_DSMM_SETTINGS.modelParameters.passthrough) }),
216
+ locale: LOCALE_SCHEMA,
201
217
  sessionPersistence: Schema.union([Schema.const(undefined), Schema.object({
202
218
  root: Schema.string().required(),
203
219
  compression: Schema.union([Schema.const("zstd"), Schema.const("none")])
@@ -208,10 +224,8 @@ const CONFIG_FIELDS_SCHEMA = Schema.object({
208
224
  promptOrder: Schema.number().default(DEFAULT_DSMM_SETTINGS.promptOrder),
209
225
  deepseekV4ProCalibration: DEEPSEEK_CALIBRATION_SCHEMA,
210
226
  deepseekV4ProDefaultReasoningEffort: DEEPSEEK_DEFAULT_REASONING_EFFORT_SCHEMA,
211
- deepseekV4ProMaxReasoningPresets: DEEPSEEK_MAX_REASONING_PRESETS_SCHEMA,
212
227
  deepseekFlashCalibration: DEEPSEEK_CALIBRATION_SCHEMA,
213
228
  deepseekFlashDefaultReasoningEffort: DEEPSEEK_DEFAULT_REASONING_EFFORT_SCHEMA,
214
- deepseekFlashMaxReasoningPresets: DEEPSEEK_MAX_REASONING_PRESETS_SCHEMA,
215
229
  skills: SKILLS_SCHEMA,
216
230
  roles: ROLES_SCHEMA,
217
231
  roleRouting: ROLE_ROUTING_SCHEMA,
@@ -227,11 +241,14 @@ const MODULES_SCHEMA = Schema.object({ deepwork: Schema.object({ enabled: Schema
227
241
  const GLOBAL_FIELDS_SCHEMA = Schema.object({ ...CONFIG_FIELDS_SCHEMA.dict, modules: MODULES_SCHEMA });
228
242
  /** Only data is transported. Defaults remain resolved by the existing authority. */
229
243
  export function deploymentEditorSchema() {
230
- const project = (schema) => ({
244
+ const project = (schema) => schema === permissionControlSchema && schema.type === "transform"
245
+ ? project(schema.inner) : schema === permissionControlSchema.inner.dict.rules
246
+ ? { type: "array", inner: { type: "object", fields: {}, additionalProperties: "json" } } : schema === MODEL_ROUTE_SCHEMA
247
+ ? { ...project(MODEL_ROUTE_FIELDS_SCHEMA), additionalProperties: "json" } : ({
231
248
  type: schema.type,
232
249
  ...(schema.dict === undefined ? {} : { fields: Object.fromEntries(Object.entries(schema.dict).filter(([key]) => key !== "sessionPersistence").map(([key, child]) => {
233
250
  const node = project(child);
234
- if (schema === MODEL_ROUTE_SCHEMA)
251
+ if (schema === MODEL_ROUTE_FIELDS_SCHEMA && ["provider", "model", "reasoningEffort"].includes(key))
235
252
  node.nonempty = true;
236
253
  if (schema === RATE_LIMIT_CONFIG_SCHEMA) {
237
254
  const [min, max] = DSMM_RATE_LIMIT_BOUNDS[key];
@@ -253,6 +270,8 @@ export function deploymentEditorSchema() {
253
270
  }
254
271
  /** Transport nodes carry no business defaults. Only deployment input is volatile. */
255
272
  function sparseSchema(schema) {
273
+ if (schema === permissionControlSchema && schema.type === "transform")
274
+ return sparseSchema(schema.inner);
256
275
  const { default: _default, required: _required, ...meta } = schema.meta;
257
276
  return new Schema({ ...schema, meta,
258
277
  ...(schema.dict === undefined ? {} : { dict: Object.fromEntries(Object.entries(schema.dict).map(([key, child]) => [key, sparseSchema(child)])) }),
@@ -285,16 +304,17 @@ export const DSMM_NATIVE_CONFIG_SCHEMA = new Proxy(TRANSPORT_FIELDS_SCHEMA.defau
285
304
  }
286
305
  });
287
306
  export const DSMM_SETTINGS_SCHEMA = Schema.intersect([ROLE_ROUTING_VALIDATION_SCHEMA, Schema.object({
307
+ permissionControl: permissionControlSchema,
308
+ modelParameters: Schema.object({ passthrough: Schema.boolean().default(DEFAULT_DSMM_SETTINGS.modelParameters.passthrough) }),
309
+ locale: LOCALE_SCHEMA,
288
310
  modules: Schema.object({ deepwork: Schema.object({ enabled: Schema.boolean().default(true) }) }),
289
311
  modeName: Schema.string().default(DEFAULT_DSMM_SETTINGS.modeName),
290
312
  defaultActive: Schema.boolean().default(DEFAULT_DSMM_SETTINGS.defaultActive),
291
313
  promptOrder: Schema.number().default(DEFAULT_DSMM_SETTINGS.promptOrder),
292
314
  deepseekV4ProCalibration: DEEPSEEK_CALIBRATION_SCHEMA,
293
315
  deepseekV4ProDefaultReasoningEffort: DEEPSEEK_DEFAULT_REASONING_EFFORT_SCHEMA,
294
- deepseekV4ProMaxReasoningPresets: DEEPSEEK_MAX_REASONING_PRESETS_SCHEMA,
295
316
  deepseekFlashCalibration: DEEPSEEK_CALIBRATION_SCHEMA,
296
317
  deepseekFlashDefaultReasoningEffort: DEEPSEEK_DEFAULT_REASONING_EFFORT_SCHEMA,
297
- deepseekFlashMaxReasoningPresets: DEEPSEEK_MAX_REASONING_PRESETS_SCHEMA,
298
318
  skills: SKILLS_SCHEMA,
299
319
  roles: ROLES_SCHEMA,
300
320
  roleRouting: ROLE_ROUTING_SCHEMA,
@@ -307,17 +327,27 @@ export const DSMM_SETTINGS_SCHEMA = Schema.intersect([ROLE_ROUTING_VALIDATION_SC
307
327
  lsp: LSP_SCHEMA
308
328
  })]).default({});
309
329
  export function resolveConfig(config = {}) {
330
+ rejectDeprecatedFields(config);
331
+ if (Object.hasOwn(config, "locale"))
332
+ validateLocale(config.locale);
333
+ if (config.subagents !== undefined)
334
+ validateShape(config.subagents, SUBAGENTS_SCHEMA, ["subagents"]);
335
+ if (config.modelParameters !== undefined)
336
+ validateShape(config.modelParameters, CONFIG_FIELDS_SCHEMA.dict.modelParameters, ["modelParameters"]);
337
+ if (config.permissionControl !== undefined)
338
+ validateShape(config.permissionControl, permissionControlSchema, ["permissionControl"]);
310
339
  const settings = {
340
+ permissionControl: resolvePermissionControl(config.permissionControl),
341
+ modelParameters: { passthrough: config.modelParameters?.passthrough ?? DEFAULT_DSMM_SETTINGS.modelParameters.passthrough },
342
+ ...(config.locale === undefined ? {} : { locale: config.locale }),
311
343
  modules: { deepwork: { enabled: config.modules?.deepwork?.enabled ?? DEFAULT_DSMM_SETTINGS.modules.deepwork.enabled } },
312
344
  modeName: normalizeModeName(config.modeName),
313
345
  defaultActive: config.defaultActive ?? DEFAULT_DSMM_SETTINGS.defaultActive,
314
346
  promptOrder: config.promptOrder ?? DEFAULT_DSMM_SETTINGS.promptOrder,
315
347
  deepseekV4ProCalibration: config.deepseekV4ProCalibration ?? DEFAULT_DSMM_SETTINGS.deepseekV4ProCalibration,
316
348
  deepseekV4ProDefaultReasoningEffort: config.deepseekV4ProDefaultReasoningEffort ?? DEFAULT_DSMM_SETTINGS.deepseekV4ProDefaultReasoningEffort,
317
- deepseekV4ProMaxReasoningPresets: resolveMaxReasoningPresets(config.deepseekV4ProMaxReasoningPresets, DEFAULT_DSMM_SETTINGS.deepseekV4ProMaxReasoningPresets),
318
349
  deepseekFlashCalibration: config.deepseekFlashCalibration ?? DEFAULT_DSMM_SETTINGS.deepseekFlashCalibration,
319
350
  deepseekFlashDefaultReasoningEffort: config.deepseekFlashDefaultReasoningEffort ?? DEFAULT_DSMM_SETTINGS.deepseekFlashDefaultReasoningEffort,
320
- deepseekFlashMaxReasoningPresets: resolveMaxReasoningPresets(config.deepseekFlashMaxReasoningPresets, DEFAULT_DSMM_SETTINGS.deepseekFlashMaxReasoningPresets),
321
351
  skills: { ...DEFAULT_DSMM_SETTINGS.skills, ...config.skills },
322
352
  roles: { ...DEFAULT_DSMM_SETTINGS.roles, ...config.roles },
323
353
  roleRouting: resolveRoleRouting(config.roleRouting),
@@ -380,48 +410,84 @@ export function freezeSettings(input) {
380
410
  freeze(result);
381
411
  return result;
382
412
  }
383
- function validateShape(value, schema) {
413
+ function validateShape(value, schema, path = []) {
414
+ const fail = (code = "invalid-type") => { throw new DsmmConfigValidationError(code, path); };
415
+ if (schema === MODEL_ROUTE_SCHEMA) {
416
+ try {
417
+ normalizeModelRouteJson(value, true, true);
418
+ }
419
+ catch {
420
+ fail("invalid-route");
421
+ }
422
+ return;
423
+ }
384
424
  if (value === null || value === undefined)
385
- throw new TypeError("Deepwork explicit configuration must not be null or undefined");
386
- if (schema.type === "object") {
425
+ fail();
426
+ if (schema.type === "transform") {
427
+ validateShape(value, schema.inner, path);
428
+ }
429
+ else if (schema.type === "object") {
387
430
  if (typeof value !== "object" || Array.isArray(value))
388
- throw new TypeError("Deepwork configuration field must be an object");
431
+ fail();
389
432
  for (const [key, child] of Object.entries(value)) {
390
433
  const field = schema.dict !== undefined && Object.hasOwn(schema.dict, key) ? schema.dict[key] : undefined;
391
434
  if (field === undefined)
392
- throw new TypeError("Deepwork configuration contains an unknown field");
393
- validateShape(child, field);
435
+ throw new DsmmConfigValidationError("unknown-field", [...path, key]);
436
+ validateShape(child, field, [...path, key]);
394
437
  }
395
438
  }
396
439
  else if (schema.type === "dict") {
397
440
  if (typeof value !== "object" || Array.isArray(value))
398
441
  throw new TypeError("Deepwork configuration field must be an object");
399
- for (const child of Object.values(value))
400
- validateShape(child, schema.inner);
442
+ for (const [key, child] of Object.entries(value))
443
+ validateShape(child, schema.inner, [...path, key]);
401
444
  }
402
445
  else if (schema.type === "array") {
403
446
  if (!Array.isArray(value))
404
447
  throw new TypeError("Deepwork configuration field must be an array");
405
- for (const child of value)
406
- validateShape(child, schema.inner);
448
+ value.forEach((child, index) => validateShape(child, schema.inner, [...path, index]));
407
449
  }
408
450
  else if (schema.type === "union") {
409
451
  for (const child of schema.list ?? []) {
410
452
  try {
411
- validateShape(value, child);
453
+ validateShape(value, child, path);
412
454
  return;
413
455
  }
414
456
  catch { /* Try the other declared alternatives. */ }
415
457
  }
416
- throw new TypeError("Deepwork configuration field does not match its declared type");
458
+ fail("unsupported-value");
417
459
  }
418
460
  else {
419
- schema(value);
461
+ try {
462
+ schema(value);
463
+ }
464
+ catch {
465
+ fail();
466
+ }
420
467
  }
421
468
  }
422
469
  /** Sparse grammar and full semantic validation are separate from native refs. */
423
470
  export function validateSparseConfig(input, global = false) {
471
+ if (isRoutingRecord(input))
472
+ rejectDeprecatedFields(input);
424
473
  const config = copyJson(input);
474
+ if (isRoutingRecord(config.roleRouting)) {
475
+ for (const [role, policy] of Object.entries(config.roleRouting))
476
+ if (isRoutingRecord(policy) && Object.hasOwn(policy, "levels")) {
477
+ if (!DSMM_ROLE_IDS.includes(role))
478
+ throw new DsmmConfigValidationError("unknown-field", ["roleRouting", role]);
479
+ if (role === "dsmm-orchestrator")
480
+ throw new DsmmConfigValidationError("unsupported-value", `roleRouting.${role}.levels`);
481
+ if (!isRoutingRecord(policy.levels))
482
+ throw new DsmmConfigValidationError("invalid-type", `roleRouting.${role}.levels`);
483
+ for (const [level, value] of Object.entries(policy.levels)) {
484
+ const field = safeDiagnosticField(["roleRouting", role, "levels", level]);
485
+ if (!["low", "high", "max"].includes(level))
486
+ throw new DsmmConfigValidationError("unsupported-value", ["roleRouting", role, "levels", level]);
487
+ normalizeLevelOverride(value, field);
488
+ }
489
+ }
490
+ }
425
491
  validateShape(config, global ? GLOBAL_FIELDS_SCHEMA : CONFIG_FIELDS_SCHEMA);
426
492
  if (global && Object.hasOwn(config, "sessionPersistence"))
427
493
  throw new TypeError("Native session storage is not a global deployment field");
@@ -438,26 +504,47 @@ export function validateSparseConfig(input, global = false) {
438
504
  return config;
439
505
  }
440
506
  export function validateDeploymentPath(path) {
507
+ const deprecated = path.find(key => DEPRECATED_DSMM_FIELDS.includes(key));
508
+ if (deprecated !== undefined)
509
+ throw new DsmmConfigValidationError("deprecated-field", path);
441
510
  let schema = GLOBAL_FIELDS_SCHEMA;
442
511
  if (path.length === 0 || path[0] === "sessionPersistence")
443
512
  throw new TypeError("Not an editable deployment field");
444
513
  for (const key of path) {
445
514
  if (schema.type === "union")
446
- schema = schema.list?.find((node) => node.type === "object") ?? schema;
515
+ schema = schema.list?.find((node) => node === MODEL_ROUTE_SCHEMA || node.type === "object") ?? schema;
516
+ if (schema === MODEL_ROUTE_SCHEMA) {
517
+ if (path.some(part => ["__proto__", "prototype", "constructor"].includes(part)))
518
+ throw new DsmmConfigValidationError("invalid-route", path);
519
+ try {
520
+ validateModelRouteFieldName(key);
521
+ }
522
+ catch {
523
+ throw new DsmmConfigValidationError("invalid-route", path);
524
+ }
525
+ const field = MODEL_ROUTE_FIELDS_SCHEMA.dict[key];
526
+ if (Object.hasOwn(MODEL_ROUTE_FIELDS_SCHEMA.dict, key)) {
527
+ schema = field;
528
+ continue;
529
+ }
530
+ return;
531
+ }
532
+ while (schema.type === "transform")
533
+ schema = schema.inner;
447
534
  const child = schema.type === "object" ? schema.dict !== undefined && Object.hasOwn(schema.dict, key) ? schema.dict[key] : undefined : schema.type === "dict" ? schema.inner : undefined;
448
535
  if (child === undefined)
449
- throw new TypeError("Unknown deployment field path");
536
+ throw new DsmmConfigValidationError("unknown-field", path);
450
537
  schema = child;
451
538
  }
452
539
  }
453
540
  export function mergeConfigLayers(...layers) {
454
- const merge = (base, overlay) => {
541
+ const merge = (base, overlay, path = []) => {
455
542
  const result = copyJson(base);
456
543
  for (const [key, value] of Object.entries(overlay)) {
457
544
  const previous = result[key];
458
- result[key] = value !== null && typeof value === "object" && !Array.isArray(value)
545
+ result[key] = path.at(-1) !== "levels" && value !== null && typeof value === "object" && !Array.isArray(value)
459
546
  && previous !== null && typeof previous === "object" && !Array.isArray(previous)
460
- ? merge(previous, value) : copyJson(value);
547
+ ? merge(previous, value, [...path, key]) : copyJson(value);
461
548
  }
462
549
  return result;
463
550
  };
@@ -480,37 +567,96 @@ function validatePresentRuntimePolicy(value) {
480
567
  throw new TypeError("dsmm runtimePolicy must be an object when present");
481
568
  return value;
482
569
  }
483
- function resolveMaxReasoningPresets(input, defaults) {
484
- const requested = new Set(input ?? defaults);
485
- return DSMM_ROLE_IDS.filter((id) => requested.has(id));
570
+ export function rejectDeprecatedFields(input, prefix = "") {
571
+ for (const key of DEPRECATED_DSMM_FIELDS)
572
+ if (Object.hasOwn(input, key))
573
+ throw new DsmmConfigValidationError("deprecated-field", `${prefix}${key}`);
574
+ }
575
+ export function validateLocale(value, field = "locale") {
576
+ if (typeof value !== "string" || !DSMM_LOCALES.includes(value))
577
+ throw new DsmmConfigValidationError("unsupported-value", field);
578
+ }
579
+ export function normalizeLevelOverride(value, field = "route") {
580
+ try {
581
+ value = copyJson(value);
582
+ }
583
+ catch {
584
+ throw new DsmmConfigValidationError("invalid-route", field);
585
+ }
586
+ if (!isRoutingRecord(value))
587
+ throw new DsmmConfigValidationError("invalid-route", field);
588
+ if (Object.hasOwn(value, "provider") || Object.hasOwn(value, "model")) {
589
+ try {
590
+ const route = normalizeExplicitRoute(value);
591
+ if (!/^[a-zA-Z0-9][a-zA-Z0-9_.:-]{0,127}$/u.test(route.provider) || route.model.length > 512 || route.model.includes("://") || /[\u0000-\u001f\u007f]/u.test(route.model) || route.reasoningEffort !== undefined && (route.reasoningEffort.length > 64 || /[\u0000-\u001f\u007f]/u.test(route.reasoningEffort)))
592
+ throw new Error("Invalid bounded route");
593
+ return route;
594
+ }
595
+ catch {
596
+ throw new DsmmConfigValidationError("invalid-route", field);
597
+ }
598
+ }
599
+ for (const key of Object.keys(value))
600
+ if (key !== "reasoningEffort")
601
+ throw new DsmmConfigValidationError("unknown-field", [...field.split("."), key]);
602
+ if (typeof value.reasoningEffort !== "string" || value.reasoningEffort.trim() === "" || value.reasoningEffort.length > 64 || /[\u0000-\u001f\u007f]/u.test(value.reasoningEffort))
603
+ throw new DsmmConfigValidationError("invalid-route", `${field}.reasoningEffort`);
604
+ return { reasoningEffort: value.reasoningEffort };
486
605
  }
487
606
  export function resolveRoleRouting(input) {
488
607
  if (input === undefined)
489
608
  return {};
609
+ input = copyJson(input);
490
610
  if (!isRoutingRecord(input))
491
611
  throw new TypeError("dsmm roleRouting must be an object");
492
612
  const result = {};
493
613
  for (const [key, value] of Object.entries(input)) {
494
614
  if (!DSMM_ROLE_IDS.includes(key))
495
- throw new TypeError("dsmm roleRouting contains an unknown role");
496
- if (!isRoutingRecord(value) || Object.keys(value).some((field) => !["primary", "fallbackRoutes", "strategy", "rateLimit"].includes(field))) {
497
- throw new TypeError("dsmm roleRouting role policy must contain only primary, fallbackRoutes, strategy and rateLimit");
615
+ throw new DsmmConfigValidationError("unknown-field", ["roleRouting", key]);
616
+ if (!isRoutingRecord(value) || Object.keys(value).some((field) => !["primary", "fallbackRoutes", "strategy", "rateLimit", "levels"].includes(field))) {
617
+ if (!isRoutingRecord(value))
618
+ throw new DsmmConfigValidationError("invalid-type", `roleRouting.${key}`);
619
+ throw new DsmmConfigValidationError("unknown-field", ["roleRouting", key, Object.keys(value).find(field => !["primary", "fallbackRoutes", "strategy", "rateLimit", "levels"].includes(field))]);
498
620
  }
499
621
  const policy = {};
622
+ if (Object.hasOwn(value, "levels")) {
623
+ const field = `roleRouting.${key}.levels`;
624
+ if (key === "dsmm-orchestrator")
625
+ throw new DsmmConfigValidationError("unsupported-value", field);
626
+ if (!isRoutingRecord(value.levels))
627
+ throw new DsmmConfigValidationError("invalid-type", field);
628
+ policy.levels = {};
629
+ for (const [level, override] of Object.entries(value.levels)) {
630
+ if (!["low", "high", "max"].includes(level))
631
+ throw new DsmmConfigValidationError("unsupported-value", `${field}.${level}`);
632
+ policy.levels[level] = normalizeLevelOverride(override, `${field}.${level}`);
633
+ }
634
+ }
500
635
  if (Object.hasOwn(value, "strategy"))
501
636
  policy.strategy = normalizeRoutingStrategy(value.strategy);
502
637
  if (Object.hasOwn(value, "rateLimit"))
503
638
  policy.rateLimit = normalizeRateLimitOverrides(value.rateLimit);
504
- if (Object.hasOwn(value, "primary"))
505
- policy.primary = normalizeExplicitRoute(value.primary);
639
+ if (Object.hasOwn(value, "primary")) {
640
+ try {
641
+ policy.primary = normalizeExplicitRoute(value.primary);
642
+ }
643
+ catch {
644
+ throw new DsmmConfigValidationError("invalid-route", `roleRouting.${key}.primary`);
645
+ }
646
+ }
506
647
  if (Object.hasOwn(value, "fallbackRoutes")) {
507
648
  if (!Array.isArray(value.fallbackRoutes) || value.fallbackRoutes.length > ROLE_FALLBACK_ROUTE_LIMIT)
508
649
  throw new TypeError("dsmm roleRouting fallbackRoutes must be an array with at most 32 entries");
509
650
  policy.fallbackRoutes = [];
510
- for (const entry of value.fallbackRoutes) {
511
- const route = normalizeExplicitRoute(entry);
512
- if (!policy.fallbackRoutes.some((existing) => existing.provider === route.provider && existing.model === route.model))
513
- policy.fallbackRoutes.push(route);
651
+ for (const [index, entry] of value.fallbackRoutes.entries()) {
652
+ let route;
653
+ try {
654
+ route = normalizeExplicitRoute(entry);
655
+ }
656
+ catch {
657
+ throw new DsmmConfigValidationError("invalid-route", `roleRouting.${key}.fallbackRoutes[${index}]`);
658
+ }
659
+ policy.fallbackRoutes.push(route);
514
660
  }
515
661
  }
516
662
  result[key] = policy;
@@ -521,26 +667,24 @@ function isRoutingRecord(value) {
521
667
  return typeof value === "object" && value !== null && !Array.isArray(value);
522
668
  }
523
669
  function normalizeExplicitRoute(value) {
524
- if (!isRoutingRecord(value) || Object.keys(value).some((field) => !["provider", "model", "reasoningEffort"].includes(field))) {
525
- throw new TypeError("dsmm explicit model route must contain provider, model and optional reasoningEffort");
526
- }
527
- if (typeof value.provider !== "string" || value.provider.trim() === "" || typeof value.model !== "string" || value.model.trim() === "") {
528
- throw new TypeError("dsmm explicit model route requires nonempty provider and model");
529
- }
530
- if (Object.hasOwn(value, "reasoningEffort") && (typeof value.reasoningEffort !== "string" || value.reasoningEffort.trim() === "")) {
531
- throw new TypeError("dsmm explicit model route reasoningEffort must be nonempty");
532
- }
533
- return {
534
- provider: value.provider.trim(), model: value.model.trim(),
535
- ...(typeof value.reasoningEffort === "string" ? { reasoningEffort: value.reasoningEffort.trim() } : {})
536
- };
670
+ const route = normalizeModelRouteJson(value, false, true);
671
+ return { ...route, provider: route.provider.trim(), model: route.model.trim() };
537
672
  }
538
673
  export function isRoleEnabled(settings, role) {
539
674
  return settings.roles[role];
540
675
  }
676
+ /** Native standing-root availability is independent of child role enablement. */
677
+ export function isRootRoleEnabled(settings, id) {
678
+ const role = DSMM_ROLES.find(role => role.id === id);
679
+ return settings.modules.deepwork.enabled && settings.roles[id] && isRootRole(role)
680
+ && (id !== "dsmm-planner" || settings.presets.plannerRootEnabled);
681
+ }
541
682
  function resolvePresetSettings(config) {
683
+ if (config !== undefined)
684
+ validateShape(config, PRESETS_SCHEMA, ["presets"]);
542
685
  return {
543
686
  materialize: config?.materialize ?? DEFAULT_DSMM_SETTINGS.presets.materialize,
687
+ plannerRootEnabled: config?.plannerRootEnabled ?? DEFAULT_DSMM_SETTINGS.presets.plannerRootEnabled,
544
688
  ...(config?.root === undefined ? {} : { root: config.root })
545
689
  };
546
690
  }
@@ -603,24 +747,15 @@ function normalizeRetryCodes(input, defaults) {
603
747
  }
604
748
  function normalizeRecoveryRoutes(input, defaults) {
605
749
  const normalized = [];
606
- for (const route of input ?? defaults) {
607
- const reasoningEffort = normalizeRecoveryEffort(route);
608
- const provider = route.provider?.trim() ?? "";
609
- const model = route.model?.trim() ?? "";
610
- if (provider === "" || model === "" || normalized.some((candidate) => candidate.provider === provider && candidate.model === model))
611
- continue;
612
- normalized.push({ provider, model, ...(reasoningEffort ? { reasoningEffort } : {}) });
750
+ const routes = copyJson(input ?? defaults);
751
+ if (!Array.isArray(routes) || routes.length > ROLE_FALLBACK_ROUTE_LIMIT)
752
+ throw new TypeError("dsmm recovery fallbackRoutes must contain at most 32 routes");
753
+ for (const route of routes) {
754
+ const candidate = normalizeExplicitRoute(route);
755
+ normalized.push(candidate);
613
756
  }
614
757
  return normalized;
615
758
  }
616
- function normalizeRecoveryEffort(route) {
617
- if (!Object.hasOwn(route, "reasoningEffort"))
618
- return undefined;
619
- const value = route.reasoningEffort;
620
- if (typeof value !== "string" || value.trim() === "")
621
- throw new TypeError("dsmm recovery route reasoningEffort must be nonempty");
622
- return value.trim();
623
- }
624
759
  function normalizeBoundedInteger(value, defaultValue) {
625
760
  if (value === undefined || !Number.isFinite(value))
626
761
  return defaultValue;
package/lib/skills.js CHANGED
@@ -24,12 +24,12 @@ const packageRoot = dirname(dirname(fileURLToPath(import.meta.url)));
24
24
  // BEGIN SOURCE SKILL METADATA
25
25
  export const DSMM_SKILL_DESCRIPTIONS = {
26
26
  "brainstorming": "Use before creative or materially ambiguous work to clarify outcomes, constraints, risks, and an appropriate implementation direction.",
27
- "writing-plans": "Use when you have a spec or requirements for a multi-step task, before touching code",
27
+ "writing-plans": "Use before complex product behavior implementation, or when an explicit planning request or concrete major risk requires a plan; not for routine non-product multi-step work",
28
28
  "requesting-code-review": "Use when an implemented change benefits from independent review before delivery or merge",
29
29
  "receiving-code-review": "Use when receiving code review feedback, before implementing suggestions, especially if feedback seems unclear or technically questionable - requires technical rigor and verification, not performative agreement or blind implementation",
30
30
  "subagent-driven-development": "Use when executing implementation plans with independent tasks in the current session",
31
31
  "dispatching-parallel-agents": "Use when facing 2+ independent tasks that can be worked on without shared state or sequential dependencies",
32
- "remove-ai-slops": "Remove AI-generated code slop from branch changes or an explicit file list. Locks behavior with regression tests FIRST, then runs categorized cleanup with bounded permitted work, then verifies with quality gates. Covers 10 slop categories. MUST USE when the user asks to \"remove slop\", \"clean AI code\", \"deslop\", \"clean up AI-generated code\", \"remove AI slop\", or wants to clean up AI-generated patterns.",
32
+ "remove-ai-slops": "Remove AI-generated code slop from branch changes or an explicit file list. Establishes regression coverage for final valid requirements, then runs categorized cleanup with bounded permitted work and verifies with quality gates. Covers 10 slop categories. MUST USE when the user asks to \"remove slop\", \"clean AI code\", \"deslop\", \"clean up AI-generated code\", \"remove AI slop\", or wants to clean up AI-generated patterns.",
33
33
  "debugging": "MUST USE for any real runtime debugging across ANY language or binary — crashes, silent failures, wrong responses, stuck processes, memory leaks, async misbehavior, unexplained timing, flaky tests, intermittent failures, passes in isolation, different test fails, order-dependent behavior, CI-only failures, reverse engineering. Runs a hypothesis-driven loop: form ≥3 hypotheses, investigate in parallel, after 2 failed evidence rounds allow one hard-reasoning escalation only when the task is genuinely difficult, confirm root cause, capture a failing reproduction before the fix and verify the same case after, fix minimally, QA by actually USING the system, scrub artifacts. The actual HOW lives in `references/` — READ THEM. Triggers: 'debug this', 'why is X not working', 'hanging', 'attach a debugger', 'reverse engineer', 'pwndbg', 'gdb', 'lldb', 'node inspect', 'tsx debug', 'pdb', 'dlv', 'delve', 'rust-gdb', 'set a breakpoint', 'context window exploded', 'why is the response empty', 'attach the debugger', 'debug it', 'why is this happening', 'trace this bug', 'reproduce and fix', 'silent failure', 'HTTP 200 but empty', 'why did it stop', 'inspect the binary', 'reverse engineering', 'playwright', 'flaky test', 'intermittent failure', 'passes in isolation', 'different test fails', 'order-dependent', 'CI-only failure'.",
34
34
  "frontend": "MUST USE for ANY frontend, web UI, UX, or visual work — building, styling, or redesigning pages/components, React project setup, performance audits, design QA. Routes three rulesets: design (anti-slop taste router over 12 taste skills + 70 brand DESIGN.md refs — Apple, Stripe, Linear, Notion, Vercel, Claude, Nike, Aside — plus composable interaction mechanics and the React dev tooling gate: react-grab, react-scan, react-doctor), perfection (Lighthouse 100 in every category via real Playwright Chromium audits, NEVER the lighthouse CLI, never by weakening UX), ui-ux-db (searchable 50+ styles, 97 palettes, 57 font pairings, 99 UX guidelines). Triggers: frontend, UI, UX, design, redesign, styling, layout, animation, motion, interaction, interaction mechanics, state, reduced-motion, taste, premium, luxury, minimal, brutalist, Awwwards, anti-slop, polish, DESIGN.md, mockup, react setup, react-scan, react-doctor, lighthouse, performance, Core Web Vitals, LCP, CLS, INP, SEO, accessibility, a11y, WCAG, audit my site, make this faster, color palette, font pairing, looks generic, make it pretty, like X brand, clone site, clone from url.",
35
35
  "git-master": "MUST USE whenever a task needs a commit or git-history investigation. Covers atomic commits, staging, commit-message style, rebase, squash, fixup/autosquash, blame, bisect, reflog, git log -S/-G, and questions like who wrote this or when was this added. Do not use for ordinary code edits unless the user asks for git work.",
package/lib/status.d.ts CHANGED
@@ -3,11 +3,19 @@ import type { DsmmModelFamily } from "./model-family.js";
3
3
  import type { DsmmRoleId } from "./roles.js";
4
4
  import type { DeepseekCalibration, DsmmModelRoute, DsmmProfileAdmission, DsmmSettings } from "./settings.js";
5
5
  import type { DsmmRateLimitPolicy, DsmmRoutingStrategy } from "./routing-policy.js";
6
- import type { DsmmRoleRuntimeState } from "./profile-types.js";
6
+ import type { DsmmRoleAvailabilityState, DsmmRoleRuntimeState, SubagentRuntimeAdmissionView, ProfileDiagnostic } from "./profile-types.js";
7
7
  import type { DsmmLspRuntimeState } from "./lsp.js";
8
8
  import type { DsmmModuleState } from "./modules.js";
9
9
  export declare const DSMM_STATUS_VERSION: 1;
10
10
  export interface DsmmStatusSnapshot {
11
+ roles?: DsmmRoleAvailabilityState[];
12
+ warnings?: ProfileDiagnostic[];
13
+ subagentRuntime?: SubagentRuntimeAdmissionView;
14
+ locale?: {
15
+ value: NonNullable<DsmmSettings["locale"]>;
16
+ source: string;
17
+ capture: string;
18
+ };
11
19
  version: typeof DSMM_STATUS_VERSION;
12
20
  modules?: DsmmModuleState[];
13
21
  admission?: Pick<DsmmProfileAdmission, "profile" | "epoch" | "scope">;
@@ -77,6 +85,7 @@ export declare function createDsmmStatusSnapshot(input: {
77
85
  settings: DsmmSettings;
78
86
  modeActive: boolean;
79
87
  admission?: DsmmProfileAdmission;
88
+ subagentRuntime?: SubagentRuntimeAdmissionView;
80
89
  roleRuntimeState?: DsmmRoleRuntimeState;
81
90
  modules?: DsmmModuleState[];
82
91
  }): DsmmStatusSnapshot;