@dsmm/dsmm 0.2.0 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (285) hide show
  1. package/README.md +37 -67
  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/cordis.patch.yml +14 -0
  25. package/docs/agent-presets.md +36 -52
  26. package/docs/compatibility.md +47 -110
  27. package/docs/deferred-native-approval-risk.md +19 -0
  28. package/docs/design.md +2 -2
  29. package/docs/lsp.md +11 -21
  30. package/docs/migration-from-ocmm.md +2 -2
  31. package/docs/model-routing.md +84 -59
  32. package/docs/native-permissions.md +35 -0
  33. package/docs/profiles.md +40 -87
  34. package/docs/releasing.md +123 -2
  35. package/docs/roadmap.md +71 -17
  36. package/docs/settings-status.md +34 -169
  37. package/docs/skill-sync.md +52 -15
  38. package/lib/agent-registry.d.ts +36 -0
  39. package/lib/agent-registry.js +75 -0
  40. package/lib/child-admission-contract.d.ts +37 -0
  41. package/lib/child-admission-contract.js +2 -0
  42. package/lib/child-admission.d.ts +40 -0
  43. package/lib/child-admission.js +151 -0
  44. package/lib/child-capture.d.ts +85 -0
  45. package/lib/child-capture.js +205 -0
  46. package/lib/child-evidence.d.ts +17 -0
  47. package/lib/child-evidence.js +43 -0
  48. package/lib/client/ChildrenPanel.d.ts +43 -0
  49. package/lib/client/ChildrenPanel.js +82 -0
  50. package/lib/client/DeploymentPage.js +15 -8
  51. package/lib/client/EditableChoice.d.ts +17 -0
  52. package/lib/client/EditableChoice.js +49 -0
  53. package/lib/client/PermissionsPanel.d.ts +14 -0
  54. package/lib/client/PermissionsPanel.js +46 -0
  55. package/lib/client/ProfilesSection.js +30 -15
  56. package/lib/client/RoleAvailability.d.ts +7 -0
  57. package/lib/client/RoleAvailability.js +19 -0
  58. package/lib/client/SessionProfiles.js +27 -9
  59. package/lib/client/StructuredEditor.js +15 -7
  60. package/lib/client/children-controller.d.ts +98 -0
  61. package/lib/client/children-controller.js +296 -0
  62. package/lib/client/children-locales.d.ts +367 -0
  63. package/lib/client/children-locales.js +69 -0
  64. package/lib/client/controller.d.ts +6 -1
  65. package/lib/client/controller.js +14 -8
  66. package/lib/client/deployment-controller.js +1 -1
  67. package/lib/client/deployment-data.d.ts +2 -1
  68. package/lib/client/deployment-data.js +34 -5
  69. package/lib/client/deployment-locales.d.ts +4 -0
  70. package/lib/client/deployment-locales.js +11 -2
  71. package/lib/client/diagnostics.d.ts +14 -0
  72. package/lib/client/diagnostics.js +53 -0
  73. package/lib/client/index.d.ts +4 -0
  74. package/lib/client/index.js +96 -2
  75. package/lib/client/locales.d.ts +54 -0
  76. package/lib/client/locales.js +34 -16
  77. package/lib/client/permission-client.d.ts +16 -0
  78. package/lib/client/permission-client.js +38 -0
  79. package/lib/client/permission-controller.d.ts +62 -0
  80. package/lib/client/permission-controller.js +149 -0
  81. package/lib/client/permission-locales.d.ts +114 -0
  82. package/lib/client/permission-locales.js +75 -0
  83. package/lib/client/session-labels.js +4 -4
  84. package/lib/client/structured.js +19 -5
  85. package/lib/client/styles.d.ts +1 -1
  86. package/lib/client/styles.js +20 -0
  87. package/lib/client.js +5780 -1679
  88. package/lib/core-permission-authority.d.ts +18 -0
  89. package/lib/core-permission-authority.js +255 -0
  90. package/lib/core-permissions.d.ts +8 -0
  91. package/lib/core-permissions.js +33 -0
  92. package/lib/delivery-authority.d.ts +83 -0
  93. package/lib/delivery-authority.js +397 -0
  94. package/lib/deployment-config.d.ts +23 -0
  95. package/lib/deployment-config.js +61 -40
  96. package/lib/deployment-permission-rules.d.ts +55 -0
  97. package/lib/deployment-permission-rules.js +306 -0
  98. package/lib/dsh-types.d.ts +10 -4
  99. package/lib/guards.d.ts +1 -1
  100. package/lib/guards.js +29 -8
  101. package/lib/host-llm-startup.d.ts +41 -0
  102. package/lib/host-llm-startup.js +65 -0
  103. package/lib/host-llm.d.ts +92 -0
  104. package/lib/host-llm.js +325 -0
  105. package/lib/index.d.ts +15 -4
  106. package/lib/index.js +288 -48
  107. package/lib/live-pi-ai-owner.d.ts +18 -0
  108. package/lib/live-pi-ai-owner.js +144 -0
  109. package/lib/llm-runtime.d.ts +11 -0
  110. package/lib/llm-runtime.js +21 -0
  111. package/lib/managed-settings.d.ts +5 -0
  112. package/lib/managed-settings.js +14 -0
  113. package/lib/model-parameter-policy.d.ts +11 -0
  114. package/lib/model-parameter-policy.js +27 -0
  115. package/lib/model-routing.js +28 -17
  116. package/lib/modules.d.ts +13 -5
  117. package/lib/modules.js +17 -1
  118. package/lib/native-child-evidence.d.ts +40 -0
  119. package/lib/native-child-evidence.js +104 -0
  120. package/lib/native-pi-ai-wire.d.ts +37 -0
  121. package/lib/native-pi-ai-wire.js +261 -0
  122. package/lib/native-scope.js +1 -1
  123. package/lib/permission-bash.d.ts +6 -0
  124. package/lib/permission-bash.js +7 -0
  125. package/lib/permission-control.d.ts +73 -0
  126. package/lib/permission-control.js +205 -0
  127. package/lib/permission-controller.d.ts +68 -0
  128. package/lib/permission-controller.js +317 -0
  129. package/lib/permission-errors.d.ts +7 -0
  130. package/lib/permission-errors.js +21 -0
  131. package/lib/permission-fs-search.d.ts +5 -0
  132. package/lib/permission-fs-search.js +7 -0
  133. package/lib/permission-fs.d.ts +5 -0
  134. package/lib/permission-fs.js +7 -0
  135. package/lib/permission-native-access.d.ts +11 -0
  136. package/lib/permission-native-access.js +6 -0
  137. package/lib/permission-native-command.d.ts +10 -0
  138. package/lib/permission-native-command.js +93 -0
  139. package/lib/permission-native-rules.d.ts +75 -0
  140. package/lib/permission-native-rules.js +278 -0
  141. package/lib/permission-pwsh.d.ts +6 -0
  142. package/lib/permission-pwsh.js +7 -0
  143. package/lib/permission-remote.d.ts +26 -0
  144. package/lib/permission-remote.js +53 -0
  145. package/lib/permission-rpc.d.ts +29 -0
  146. package/lib/permission-rpc.js +152 -0
  147. package/lib/permission-rules.d.ts +115 -0
  148. package/lib/permission-rules.js +256 -0
  149. package/lib/permission-settings.d.ts +45 -0
  150. package/lib/permission-settings.js +48 -0
  151. package/lib/permission-shell.d.ts +38 -0
  152. package/lib/permission-shell.js +150 -0
  153. package/lib/permission-web.d.ts +5 -0
  154. package/lib/permission-web.js +7 -0
  155. package/lib/preset-registry.js +36 -25
  156. package/lib/profile-diagnostics.d.ts +45 -0
  157. package/lib/profile-diagnostics.js +148 -0
  158. package/lib/profile-locale.d.ts +3 -0
  159. package/lib/profile-locale.js +2 -0
  160. package/lib/profile-remote.d.ts +8 -0
  161. package/lib/profile-remote.js +163 -39
  162. package/lib/profile-rpc.d.ts +4 -3
  163. package/lib/profile-rpc.js +20 -16
  164. package/lib/profile-runtime.d.ts +40 -1
  165. package/lib/profile-runtime.js +368 -93
  166. package/lib/profile-store.d.ts +11 -0
  167. package/lib/profile-store.js +143 -11
  168. package/lib/profile-types.d.ts +70 -1
  169. package/lib/profile-types.js +1 -0
  170. package/lib/profiles.d.ts +16 -2
  171. package/lib/profiles.js +156 -79
  172. package/lib/prompt-content.js +1 -1
  173. package/lib/prompts.d.ts +37 -2
  174. package/lib/prompts.js +111 -9
  175. package/lib/recovery-policy.js +20 -7
  176. package/lib/role-control-remote.d.ts +38 -0
  177. package/lib/role-control-remote.js +211 -0
  178. package/lib/role-control-rpc.d.ts +51 -0
  179. package/lib/role-control-rpc.js +381 -0
  180. package/lib/role-control-types.d.ts +92 -0
  181. package/lib/role-control-types.js +8 -0
  182. package/lib/role-invocation.d.ts +47 -0
  183. package/lib/role-invocation.js +135 -0
  184. package/lib/role-llm-runtime.d.ts +17 -0
  185. package/lib/role-llm-runtime.js +62 -0
  186. package/lib/role-llm.d.ts +31 -0
  187. package/lib/role-llm.js +66 -0
  188. package/lib/role-policy.d.ts +46 -8
  189. package/lib/role-policy.js +421 -61
  190. package/lib/role-providers.d.ts +2 -2
  191. package/lib/role-providers.js +27 -72
  192. package/lib/role-routing.d.ts +11 -2
  193. package/lib/role-routing.js +42 -25
  194. package/lib/role-runs.d.ts +138 -0
  195. package/lib/role-runs.js +335 -0
  196. package/lib/role-subagents.d.ts +58 -3
  197. package/lib/role-subagents.js +179 -56
  198. package/lib/roles.d.ts +5 -6
  199. package/lib/roles.js +10 -39
  200. package/lib/route-json.d.ts +19 -0
  201. package/lib/route-json.js +129 -0
  202. package/lib/routing-policy.d.ts +2 -0
  203. package/lib/routing-policy.js +12 -2
  204. package/lib/runtime-integration.d.ts +81 -0
  205. package/lib/runtime-integration.js +702 -0
  206. package/lib/runtime-recovery.js +18 -8
  207. package/lib/session-persistence.d.ts +2 -1
  208. package/lib/session-persistence.js +1 -1
  209. package/lib/session-scope.js +4 -1
  210. package/lib/settings.d.ts +47 -13
  211. package/lib/settings.js +217 -82
  212. package/lib/skills.js +2 -2
  213. package/lib/status.d.ts +10 -1
  214. package/lib/status.js +11 -8
  215. package/lib/subagent-runtime.d.ts +57 -0
  216. package/lib/subagent-runtime.js +257 -0
  217. package/package.json +149 -89
  218. package/patches/subagent-runtime.yml +15 -0
  219. package/prompts/deepseek-flash.md +1 -1
  220. package/prompts/deepseek-v4-pro.md +2 -2
  221. package/prompts/deepwork.md +27 -18
  222. package/prompts/source/agents/clarifier.md +5 -3
  223. package/prompts/source/agents/orchestrator.md +18 -9
  224. package/prompts/source/agents/plan-critic.md +5 -1
  225. package/prompts/source/agents/planner.md +4 -2
  226. package/prompts/source/agents/reviewer.md +6 -0
  227. package/prompts/source/category/complex.md +4 -4
  228. package/prompts/source/category/creative.md +6 -4
  229. package/prompts/source/category/cross-cutting.md +10 -8
  230. package/prompts/source/category/deep.md +5 -3
  231. package/prompts/source/category/documenting.md +7 -1
  232. package/prompts/source/category/frontend.md +2 -2
  233. package/prompts/source/category/hard-reasoning.md +3 -3
  234. package/prompts/source/category/research.md +4 -2
  235. package/prompts/source/deepwork/claude-opus-5.md +2 -2
  236. package/prompts/source/deepwork/codex.md +1 -1
  237. package/prompts/source/deepwork/default.md +22 -15
  238. package/prompts/source/deepwork/gemini.md +23 -16
  239. package/prompts/source/deepwork/glm.md +21 -14
  240. package/prompts/source/deepwork/gpt.md +12 -6
  241. package/prompts/source/deepwork/planner.md +8 -5
  242. package/prompts/source/manifest.json +178 -63
  243. package/prompts/source/shared/dsh-host-contract.md +5 -3
  244. package/prompts/source/shared/locale.md +2 -2
  245. package/prompts/source/terminal/orchestrator.md +1 -1
  246. package/skills/ast-grep/SKILL.md +7 -4
  247. package/skills/brainstorming/SKILL.md +43 -22
  248. package/skills/coding-agent-sessions/SKILL.md +7 -4
  249. package/skills/coding-agent-sessions/scripts/agent_sessions/pi_family.py +46 -46
  250. package/skills/coding-agent-sessions/scripts/tests/test_pi_family_scanners.py +130 -130
  251. package/skills/debugging/SKILL.md +14 -9
  252. package/skills/debugging/references/methodology/00-setup.md +14 -62
  253. package/skills/debugging/references/methodology/02-investigate.md +4 -4
  254. package/skills/debugging/references/methodology/03-flaky-triage.md +3 -3
  255. package/skills/debugging/references/methodology/04-hard-reasoning-escalation.md +2 -14
  256. package/skills/debugging/references/methodology/06-fix.md +6 -6
  257. package/skills/debugging/references/methodology/08-qa.md +5 -5
  258. package/skills/debugging/references/methodology/09-cleanup.md +15 -153
  259. package/skills/debugging/references/methodology/partial-runtime-evidence.md +3 -16
  260. package/skills/debugging/references/runtimes/bundled-js-binary.md +1 -16
  261. package/skills/debugging/references/runtimes/native-binary.md +9 -54
  262. package/skills/debugging/references/runtimes/node.md +4 -15
  263. package/skills/debugging/references/runtimes/python.md +3 -15
  264. package/skills/debugging/references/runtimes/rust.md +2 -18
  265. package/skills/debugging/references/tools/dap.md +1 -1
  266. package/skills/debugging/references/tools/ghidra.md +4 -15
  267. package/skills/debugging/references/tools/playwright-cli.md +3 -15
  268. package/skills/debugging/references/tools/pwntools.md +4 -16
  269. package/skills/dispatching-parallel-agents/SKILL.md +18 -16
  270. package/skills/frontend/SKILL.md +7 -4
  271. package/skills/frontend/references/design/react-dev-tooling-skill.md +1 -1
  272. package/skills/git-master/SKILL.md +7 -4
  273. package/skills/init-deep/SKILL.md +7 -4
  274. package/skills/receiving-code-review/SKILL.md +17 -12
  275. package/skills/remove-ai-slops/SKILL.md +39 -38
  276. package/skills/requesting-code-review/SKILL.md +19 -17
  277. package/skills/requesting-code-review/code-reviewer.md +13 -1
  278. package/skills/subagent-driven-development/SKILL.md +29 -26
  279. package/skills/subagent-driven-development/implementer-prompt.md +29 -11
  280. package/skills/subagent-driven-development/spec-reviewer-prompt.md +6 -1
  281. package/skills/using-git-worktrees/SKILL.md +7 -4
  282. package/skills/writing-plans/SKILL.md +29 -24
  283. package/skills/writing-plans/plan-document-reviewer-prompt.md +10 -1
  284. package/scripts/repair-session-log.mjs +0 -476
  285. package/scripts/session-repair-native-verifier.mjs +0 -367
@@ -0,0 +1,21 @@
1
+ import { DsmmAwareLlmRuntime } from "./host-llm.js";
2
+ import { LivePiAiOwner } from "./live-pi-ai-owner.js";
3
+ import { createDsmmRoleLlmOwner } from "./role-llm-runtime.js";
4
+ /** The selected profile's sole native LLM registry, installed by cold source migration. */
5
+ export class DsmmNativeLlmRuntime extends DsmmAwareLlmRuntime {
6
+ providerOwner;
7
+ constructor(ctx) {
8
+ let owner;
9
+ super(ctx, undefined, { preflight: (frame, proposal) => owner.preflight(frame, proposal) });
10
+ this.providerOwner = new LivePiAiOwner(ctx, this);
11
+ owner = createDsmmRoleLlmOwner(ctx, this.providerOwner);
12
+ ctx.provide("dsmmLlmRoutes", this.providerOwner);
13
+ ctx.inject(["dsmmCoreLlmOwner"], scope => this.bindRequestOwner(scope));
14
+ }
15
+ registerAdapter(...args) {
16
+ const handle = super.registerAdapter(...args);
17
+ return this.providerOwner.register(this.ctx, args[0], args[1], handle);
18
+ }
19
+ }
20
+ export default DsmmNativeLlmRuntime;
21
+ //# sourceMappingURL=llm-runtime.js.map
@@ -0,0 +1,5 @@
1
+ import type { Context } from "@deepseek-ai/cordis";
2
+ export declare const inject: string[];
3
+ /** Ordinary native settings service, with the caller-scoped editor transaction boundary. */
4
+ export declare function apply(ctx: Context): void;
5
+ //# sourceMappingURL=managed-settings.d.ts.map
@@ -0,0 +1,14 @@
1
+ import { SettingsForms } from "@deepseek-ai/dsh-settings";
2
+ import { permissionConfigEditorFacade } from "./deployment-permission-rules.js";
3
+ export const inject = SettingsForms.inject;
4
+ function isEditor(value) {
5
+ return value !== null && typeof value === "object" && "edit" in value && typeof value.edit === "function";
6
+ }
7
+ /** Ordinary native settings service, with the caller-scoped editor transaction boundary. */
8
+ export function apply(ctx) {
9
+ const editor = Reflect.get(ctx, "configEditor");
10
+ if (!isEditor(editor))
11
+ throw new Error("The native configuration editor is unavailable.");
12
+ new SettingsForms(ctx.extend({ configEditor: permissionConfigEditorFacade(editor) }));
13
+ }
14
+ //# sourceMappingURL=managed-settings.js.map
@@ -0,0 +1,11 @@
1
+ import type { DsmmProfileAdmission, DsmmSettings } from "./settings.js";
2
+ /** Execution semantics, not an admission or executor capability. */
3
+ export type ResolvedModelParameterPolicy = Readonly<{
4
+ mode: "passthrough" | "native-defaults" | "legacy-native-v1";
5
+ }>;
6
+ /** Call with the exact immutable Agent admission; never substitute current parent settings. */
7
+ export declare function resolvedModelParameterPolicy(admission: DsmmProfileAdmission): ResolvedModelParameterPolicy;
8
+ /** Cold Core composition may resolve its startup snapshot without waiting for DW. */
9
+ export declare function configuredModelParameterPolicy(settings: DsmmSettings): ResolvedModelParameterPolicy;
10
+ export declare function parseModelParameterPolicy(value: unknown): ResolvedModelParameterPolicy;
11
+ //# sourceMappingURL=model-parameter-policy.d.ts.map
@@ -0,0 +1,27 @@
1
+ const passthrough = Object.freeze({ mode: "passthrough" });
2
+ const nativeDefaults = Object.freeze({ mode: "native-defaults" });
3
+ const legacy = Object.freeze({ mode: "legacy-native-v1" });
4
+ /** Call with the exact immutable Agent admission; never substitute current parent settings. */
5
+ export function resolvedModelParameterPolicy(admission) {
6
+ const capture = admission.childCapture;
7
+ if (capture !== undefined)
8
+ return capture.version === 1 ? legacy : capture.modelParameterPolicy;
9
+ if (admission.childEvidence?.mode === "legacy-conservative")
10
+ return legacy;
11
+ return configuredModelParameterPolicy(admission.settings);
12
+ }
13
+ /** Cold Core composition may resolve its startup snapshot without waiting for DW. */
14
+ export function configuredModelParameterPolicy(settings) {
15
+ return settings.modelParameters.passthrough ? passthrough : nativeDefaults;
16
+ }
17
+ export function parseModelParameterPolicy(value) {
18
+ if (value === null || typeof value !== "object" || Array.isArray(value) || Object.keys(value).length !== 1 || !("mode" in value))
19
+ throw new TypeError("Invalid model parameter policy");
20
+ switch (value.mode) {
21
+ case "passthrough": return passthrough;
22
+ case "native-defaults": return nativeDefaults;
23
+ case "legacy-native-v1": return legacy;
24
+ default: throw new TypeError("Invalid model parameter policy");
25
+ }
26
+ }
27
+ //# sourceMappingURL=model-parameter-policy.js.map
@@ -4,6 +4,9 @@ import { resolveSelectedAgentPreset } from "./session-scope.js";
4
4
  import { resolveAdmittedDsmmRole as resolveEffectiveDsmmRole } from "./role-policy.js";
5
5
  import { childOwnedSessionEvents, sessionEvents } from "./session-scope.js";
6
6
  import { isCurrentRecoveryStep } from "./recovery-policy.js";
7
+ import { capturedRoleInvocation } from "./role-invocation.js";
8
+ import { modelRouteFromCall } from "./role-llm.js";
9
+ import { configuredModelParameterPolicy, resolvedModelParameterPolicy } from "./model-parameter-policy.js";
7
10
  export function isDeepseekV4ProRoute(config) {
8
11
  return config.provider.toLowerCase() === "deepseek-official" && config.model.toLowerCase() === "deepseek-v4-pro";
9
12
  }
@@ -12,10 +15,7 @@ export function isDeepseekFlashRoute(config) {
12
15
  && config.model.toLowerCase() === "deepseek-flash";
13
16
  }
14
17
  export function desiredDeepseekEffort(settings, preset, route = "v4-pro") {
15
- const maxPresets = route === "flash" ? settings.deepseekFlashMaxReasoningPresets : settings.deepseekV4ProMaxReasoningPresets;
16
- return preset !== undefined && maxPresets.some((configuredPreset) => configuredPreset === preset)
17
- ? "max"
18
- : route === "flash" ? settings.deepseekFlashDefaultReasoningEffort : settings.deepseekV4ProDefaultReasoningEffort;
18
+ return route === "flash" ? settings.deepseekFlashDefaultReasoningEffort : settings.deepseekV4ProDefaultReasoningEffort;
19
19
  }
20
20
  export function selectAdvertisedEffort(desired, reasoning) {
21
21
  if (!reasoning)
@@ -59,6 +59,8 @@ export function registerModelRouting(ctx, controller, getSettings) {
59
59
  if (frame.signal.aborted)
60
60
  return downstream;
61
61
  const settings = getSettings(frame.agent);
62
+ const admission = getSettings.admission?.(frame.agent);
63
+ const parameterPolicy = admission === undefined ? configuredModelParameterPolicy(settings) : resolvedModelParameterPolicy(admission);
62
64
  if (!settings.modules.deepwork.enabled)
63
65
  return downstream;
64
66
  const ordinaryRoot = frame.agent.session.header?.origin !== "subagent";
@@ -66,7 +68,8 @@ export function registerModelRouting(ctx, controller, getSettings) {
66
68
  const active = controller.active(frame.agent, settings.defaultActive);
67
69
  const role = resolveEffectiveDsmmRole(frame.agent, settings, active);
68
70
  const policy = role === undefined ? undefined : settings.roleRouting[role];
69
- const primary = policy?.primary;
71
+ const invocation = capturedRoleInvocation(frame.agent);
72
+ const primary = invocation?.initialRoute ?? policy?.primary;
70
73
  const epoch = getSettings.admission?.(frame.agent).epoch;
71
74
  const identity = await establishRolePolicy(frame, settings, role, readyCtx, epoch);
72
75
  const fallbacks = effectiveRoleFallbackRoutes(settings, role);
@@ -76,12 +79,15 @@ export function registerModelRouting(ctx, controller, getSettings) {
76
79
  const currentStep = isCurrentRecoveryStep(frame.agent.session.header?.origin === "subagent" ? childOwnedSessionEvents(frame.agent.session) : sessionEvents(frame.agent.session), frame.turn, frame.step);
77
80
  if (role !== undefined && identity !== undefined && currentStep) {
78
81
  let lock = roleRouteLock(frame.agent, identity);
79
- const exactPolicy = primary !== undefined || policy?.fallbackRoutes !== undefined || fallbacks.length > 0;
82
+ const exactPolicy = invocation === undefined ? primary !== undefined || policy?.fallbackRoutes !== undefined || fallbacks.length > 0
83
+ : invocation.routeSource !== "inherited" || invocation.exactEffort || fallbacks.length > 0;
80
84
  const captured = assembledSelections.get(frame.agent);
81
85
  const manual = captured?.signal === frame.signal ? captured.intent : undefined;
82
86
  if (ordinaryRoot) {
83
- const selected = { provider: downstream.provider, model: downstream.model,
84
- ...(downstream.reasoningEffort === undefined ? {} : { reasoningEffort: downstream.reasoningEffort }) };
87
+ if (manual !== undefined && lock?.manualSelectionSeq !== manual.seq
88
+ && !nativeModelSelectionWasAccepted(frame.agent, manual))
89
+ downstream = applyModelRoute(downstream, manual.route);
90
+ const selected = modelRouteFromCall(downstream);
85
91
  if (lock === undefined || !sameExactModelRoute(lock.route, selected) || lock.manualSelectionSeq !== manual?.seq) {
86
92
  const generation = (lock?.generation ?? -1) + 1;
87
93
  lock = pinRoleRoute(frame.agent, identity, selected, [selected]);
@@ -92,7 +98,7 @@ export function registerModelRouting(ctx, controller, getSettings) {
92
98
  return downstream;
93
99
  }
94
100
  if (manual !== undefined && lock?.manualSelectionSeq !== manual.seq
95
- && (sameExactModelRoute(downstream, manual.route) || nativeModelSelectionWasAccepted(frame.agent, manual))) {
101
+ && (sameModelRoute(downstream, manual.route) && downstream.reasoningEffort === manual.route.reasoningEffort || nativeModelSelectionWasAccepted(frame.agent, manual))) {
96
102
  const llm = frame.agent.ctx?.get?.("llm")
97
103
  ?? (readyCtx.get !== undefined ? readyCtx.get("llm") : readyCtx.llm);
98
104
  if (llm?.resolveCallConfig === undefined)
@@ -100,7 +106,7 @@ export function registerModelRouting(ctx, controller, getSettings) {
100
106
  await llm.resolveCallConfig(applyModelRoute(downstream, manual.route), frame.signal);
101
107
  frame.signal.throwIfAborted();
102
108
  const generation = (lock?.generation ?? -1) + 1;
103
- lock = pinRoleRoute(frame.agent, identity, manual.route, [manual.route, ...fallbacks]);
109
+ lock = pinRoleRoute(frame.agent, identity, manual.route, [manual.route, ...fallbacks], { preserveCandidates: parameterPolicy.mode === "native-defaults" });
104
110
  lock.manualSelectionSeq = manual.seq;
105
111
  lock.generation = generation;
106
112
  lockedAgents.add(frame.agent);
@@ -113,36 +119,41 @@ export function registerModelRouting(ctx, controller, getSettings) {
113
119
  if (admitted !== undefined)
114
120
  return applyModelRoute(downstream, admitted);
115
121
  const accepted = persistedRoleRoute(frame, liveAlias ? undefined : primary, fallbacks, identity);
116
- if (lock !== undefined && accepted !== undefined && !sameModelRoute(accepted, lock.route)) {
122
+ if (lock !== undefined && accepted !== undefined && !sameExactModelRoute(accepted, lock.route)) {
117
123
  // An explicit already-committed native route change remains host-owned;
118
124
  // DSMM's pending current-frame route still has precedence above.
119
125
  lock.route = { ...accepted };
126
+ lock.candidateIndex = lock.candidates.findIndex(candidate => sameExactModelRoute(candidate, accepted));
120
127
  lock.generation += 1;
121
128
  lock.startupSettled = true;
122
129
  lock.retries = 0;
123
130
  lock.rateLimits = 0;
124
131
  }
125
132
  if (lock === undefined) {
126
- const inherited = { provider: downstream.provider, model: downstream.model,
127
- ...(downstream.reasoningEffort === undefined ? {} : { reasoningEffort: downstream.reasoningEffort }) };
128
- const candidates = orderedModelRoutes([liveAlias ? inherited : primary ?? inherited, ...fallbacks]);
133
+ const inherited = modelRouteFromCall(downstream);
134
+ const candidates = invocation?.candidates ?? orderedModelRoutes([liveAlias ? inherited : primary ?? inherited, ...fallbacks]);
129
135
  const persisted = accepted;
130
136
  const llm = frame.agent.ctx?.get?.("llm")
131
137
  ?? (readyCtx.get !== undefined ? readyCtx.get("llm") : readyCtx.llm);
132
- const selected = persisted ?? (exactPolicy ? await selectInitialModelRoute(llm ?? {}, candidates, frame.signal) : inherited);
138
+ const selected = persisted ?? invocation?.initialRoute ?? (exactPolicy ? await selectInitialModelRoute(llm ?? {}, candidates, frame.signal, parameterPolicy.mode === "passthrough" ? readyCtx.get?.("dsmmLlmRoutes") : undefined) : inherited);
133
139
  frame.signal.throwIfAborted();
134
- lock = pinRoleRoute(frame.agent, identity, selected, candidates);
140
+ lock = pinRoleRoute(frame.agent, identity, selected, candidates, { preserveCandidates: parameterPolicy.mode === "native-defaults",
141
+ initialCandidate: persisted ?? invocation?.selectedCandidate });
135
142
  if (persisted !== undefined)
136
143
  lock.startupSettled = true;
137
144
  lockedAgents.add(frame.agent);
138
145
  }
139
146
  downstream = applyModelRoute(downstream, lock.route);
140
- if (exactPolicy || lock.attempts > 0)
147
+ const newRouteWithoutEffort = invocation !== undefined && !invocation.exactEffort
148
+ && (invocation.routeSource === "level" || invocation.routeSource === "invocation-route");
149
+ if ((exactPolicy || lock.attempts > 0) && !newRouteWithoutEffort)
141
150
  return downstream;
142
151
  }
143
152
  // Ordinary roots belong to the native model tab, including its exact effort.
144
153
  if (ordinaryRoot)
145
154
  return downstream;
155
+ if (parameterPolicy.mode === "native-defaults")
156
+ return downstream;
146
157
  // Named fallback efforts are native policy IDs, never legacy calibration inputs.
147
158
  if (fallbacks.some((fallback) => fallback.reasoningEffort !== undefined
148
159
  && sameModelRoute(fallback, downstream) && fallback.reasoningEffort === downstream.reasoningEffort))
package/lib/modules.d.ts CHANGED
@@ -1,27 +1,35 @@
1
1
  import type { DsmmDeploymentSnapshot, DsmmProfileAdmission, DsmmSettings } from "./settings.js";
2
2
  /** Static first-party inventory, not a plugin/provider installation interface. */
3
- export declare const DSMM_MODULE_DESCRIPTORS: readonly Readonly<{
3
+ export declare const DSMM_MODULE_DESCRIPTORS: readonly (Readonly<{
4
4
  id: "deepwork";
5
5
  label: "Deepwork";
6
6
  key: "modules.deepwork.enabled";
7
- }>[];
7
+ }> | Readonly<{
8
+ id: "permission-control";
9
+ label: "Permission control";
10
+ key: "permissionControl.enabled";
11
+ }>)[];
8
12
  export interface DsmmModuleState {
9
13
  descriptor: typeof DSMM_MODULE_DESCRIPTORS[number];
10
14
  hostBundleEnabled: "unknown";
11
15
  desired: {
12
16
  enabled: boolean;
13
- source: "defaults" | "global";
17
+ source: "defaults" | "global" | "profile";
14
18
  capture: "current-global" | "admission" | "startup";
15
19
  };
16
- startupMounted: boolean;
20
+ startupMounted: boolean | null;
17
21
  admitted: boolean | null;
18
22
  nextRoot: {
19
- admitted: boolean;
23
+ admitted: boolean | null;
20
24
  reason: "global-disabled" | "restart-required" | null;
21
25
  };
22
26
  reason: "global-disabled" | "restart-required" | "captured-off" | null;
23
27
  pending: boolean;
24
28
  }
29
+ /** Trusted Host lifecycle observation; missing or retired owners return null, not readiness. */
30
+ export type DsmmMountedPermissionGetter = () => boolean | null;
25
31
  export declare function deepworkEnabled(settings: DsmmSettings): boolean;
26
32
  export declare function projectDeepworkModule(startup: DsmmSettings, desired?: DsmmDeploymentSnapshot, admission?: DsmmProfileAdmission, currentGlobal?: boolean): DsmmModuleState;
33
+ /** Both projections share the same captured deployment/admission; module state grants no authority. */
34
+ export declare function projectDsmmModules(startup: DsmmSettings, desired?: DsmmDeploymentSnapshot, admission?: DsmmProfileAdmission, currentGlobal?: boolean, getMountedPermission?: DsmmMountedPermissionGetter): DsmmModuleState[];
27
35
  //# sourceMappingURL=modules.d.ts.map
package/lib/modules.js CHANGED
@@ -1,6 +1,7 @@
1
1
  /** Static first-party inventory, not a plugin/provider installation interface. */
2
2
  export const DSMM_MODULE_DESCRIPTORS = Object.freeze([
3
- Object.freeze({ id: "deepwork", label: "Deepwork", key: "modules.deepwork.enabled" })
3
+ Object.freeze({ id: "deepwork", label: "Deepwork", key: "modules.deepwork.enabled" }),
4
+ Object.freeze({ id: "permission-control", label: "Permission control", key: "permissionControl.enabled" })
4
5
  ]);
5
6
  export function deepworkEnabled(settings) { return settings.modules.deepwork.enabled; }
6
7
  export function projectDeepworkModule(startup, desired, admission, currentGlobal = false) {
@@ -18,4 +19,19 @@ export function projectDeepworkModule(startup, desired, admission, currentGlobal
18
19
  pending: enabled !== mounted || admitted !== null && admitted !== next
19
20
  };
20
21
  }
22
+ /** Both projections share the same captured deployment/admission; module state grants no authority. */
23
+ export function projectDsmmModules(startup, desired, admission, currentGlobal = false, getMountedPermission) {
24
+ const enabled = desired?.settings.permissionControl.enabled ?? startup.permissionControl.enabled;
25
+ const mounted = getMountedPermission?.() ?? null;
26
+ const admitted = admission?.settings.permissionControl.enabled ?? null;
27
+ const restartRequired = enabled !== startup.permissionControl.enabled;
28
+ const reason = restartRequired ? "restart-required" : null;
29
+ return [projectDeepworkModule(startup, desired, admission, currentGlobal), {
30
+ descriptor: { ...DSMM_MODULE_DESCRIPTORS[1] }, hostBundleEnabled: "unknown",
31
+ desired: { enabled, source: desired?.sources["permissionControl.enabled"] ?? "defaults",
32
+ capture: currentGlobal ? "current-global" : admission === undefined ? "startup" : "admission" },
33
+ startupMounted: mounted, admitted, nextRoot: { admitted: mounted, reason }, reason,
34
+ pending: restartRequired || admitted !== null && mounted !== null && admitted !== mounted
35
+ }];
36
+ }
21
37
  //# sourceMappingURL=modules.js.map
@@ -0,0 +1,40 @@
1
+ import type { Context } from "@deepseek-ai/cordis";
2
+ import type { SessionEvent, SessionHeader, SessionId as NativeSessionId } from "@deepseek-ai/dsh-session";
3
+ import type { ContinuableSubagentDescriptorData } from "@deepseek-ai/dsh-subagent";
4
+ import type { ParentAdmissionTicket } from "./delivery-authority.js";
5
+ import type { ChildAdmissionCapture } from "./child-capture.js";
6
+ import type { DsmmProfileAdmission } from "./settings.js";
7
+ import type { DsmmRoleId } from "./roles.js";
8
+ /** Host-only borrowed cut returned by the PUBLIC SessionQueryEngine.observeSession service. */
9
+ export interface NativeChildObservation extends Disposable {
10
+ readonly header: SessionHeader;
11
+ readonly inheritedEventCount: number;
12
+ readonly events: readonly SessionEvent[];
13
+ }
14
+ /** Injection avoids making the optional query provider a new DSMM package dependency. No wire caller supplies history. */
15
+ export interface NativeChildHistory {
16
+ observeSession(id: NativeSessionId, options: {
17
+ signal: AbortSignal;
18
+ projectionMode: "none";
19
+ }): Promise<NativeChildObservation>;
20
+ }
21
+ export interface NativeChildFacts {
22
+ readonly childSessionId: string;
23
+ readonly parentSessionId: string;
24
+ readonly depth: number;
25
+ readonly role: DsmmRoleId;
26
+ readonly descriptor: ContinuableSubagentDescriptorData;
27
+ readonly active?: boolean;
28
+ readonly requestBudgetObserved: boolean;
29
+ }
30
+ /** Exact public catalog and replay-validated physical cuts; never resumes an Agent. */
31
+ export declare class NativeChildEvidenceReader {
32
+ private readonly ctx;
33
+ private readonly assertTicket;
34
+ private readonly history;
35
+ constructor(ctx: Context, assertTicket: (ticket: ParentAdmissionTicket<DsmmProfileAdmission>) => void, history: NativeChildHistory);
36
+ read(ticket: ParentAdmissionTicket<DsmmProfileAdmission>, childId: string, callerSignal: AbortSignal): Promise<NativeChildFacts>;
37
+ }
38
+ /** Capture evidence must agree with the child's establishing descriptor, not current parent routing. */
39
+ export declare function assertNativeChildCapture(capture: ChildAdmissionCapture, facts: NativeChildFacts): void;
40
+ //# sourceMappingURL=native-child-evidence.d.ts.map
@@ -0,0 +1,104 @@
1
+ import { symbols } from "@deepseek-ai/cordis";
2
+ import { SessionId } from "@deepseek-ai/dsh-session";
3
+ import { foldSubagentDescriptor, SubagentError } from "@deepseek-ai/dsh-subagent";
4
+ import { freezeSettings } from "./settings.js";
5
+ import { isDsmmRoleId } from "./roles.js";
6
+ function unauthorized() { throw new SubagentError("Child history does not prove its direct native identity", "UNAUTHORIZED"); }
7
+ /** Exact public catalog and replay-validated physical cuts; never resumes an Agent. */
8
+ export class NativeChildEvidenceReader {
9
+ ctx;
10
+ assertTicket;
11
+ history;
12
+ constructor(ctx, assertTicket, history) {
13
+ this.ctx = ctx;
14
+ this.assertTicket = assertTicket;
15
+ this.history = history;
16
+ }
17
+ async read(ticket, childId, callerSignal) {
18
+ const signal = AbortSignal.any([ticket.signal, callerSignal]);
19
+ const check = () => {
20
+ signal.throwIfAborted();
21
+ this.assertTicket(ticket);
22
+ const current = this.ctx.get("sessionQuery");
23
+ if (current === undefined || (Reflect.get(current, symbols.original) ?? current) !== (Reflect.get(this.history, symbols.original) ?? this.history))
24
+ unauthorized();
25
+ };
26
+ check();
27
+ if (this.ctx.agents.get(ticket.parent.id) !== ticket.parent || childId === ticket.parent.id)
28
+ unauthorized();
29
+ const rows = await this.ctx.subagents.listChildren(ticket.parent.id, signal);
30
+ check();
31
+ const matches = rows.filter(row => row.id === childId);
32
+ if (matches.length !== 1 || matches[0].mode !== "continuable")
33
+ unauthorized();
34
+ const observation = await this.history.observeSession(SessionId(childId), { signal, projectionMode: "none" });
35
+ try {
36
+ check();
37
+ const facts = readFacts(ticket.parent, childId, observation);
38
+ const catalog = matches[0];
39
+ if (catalog.createdAt !== observation.header.createdAt || catalog.mode !== facts.descriptor.mode || catalog.label !== facts.descriptor.label)
40
+ unauthorized();
41
+ check();
42
+ return facts;
43
+ }
44
+ finally {
45
+ observation[Symbol.dispose]();
46
+ }
47
+ }
48
+ }
49
+ function readFacts(parent, childId, observation) {
50
+ const header = observation.header;
51
+ if (header.version !== 4 || header.id !== childId || header.parentSession !== parent.id || header.origin !== "subagent"
52
+ || !Number.isSafeInteger(header.delegationDepth) || header.delegationDepth <= (parent.session.header.delegationDepth ?? 0)
53
+ || typeof header.cwd !== "string")
54
+ unauthorized();
55
+ const inherited = observation.inheritedEventCount;
56
+ if (!Number.isSafeInteger(inherited) || inherited < 0 || inherited > observation.events.length)
57
+ unauthorized();
58
+ const own = observation.events.slice(inherited);
59
+ // The catalog projection is display data; a second descriptor cannot replace the establishing composition.
60
+ if (own.filter(event => event.type === "subagent/descriptor").length !== 1)
61
+ unauthorized();
62
+ const descriptor = foldSubagentDescriptor(own);
63
+ if (descriptor?.mode !== "continuable" || !descriptor.provider.startsWith("dsmm-role-"))
64
+ unauthorized();
65
+ const role = `dsmm-${descriptor.provider.slice("dsmm-role-".length)}`;
66
+ if (!isDsmmRoleId(role) || role === "dsmm-orchestrator" || descriptor.agentProvider === undefined || descriptor.agentModel === undefined)
67
+ unauthorized();
68
+ let active;
69
+ for (const event of own) {
70
+ if (event.type === "dsmm/role-policy") {
71
+ const data = event.data;
72
+ if (data === null || typeof data !== "object" || Array.isArray(data) || Object.keys(data).length !== 3
73
+ || data.version !== 1 || data.role !== role || data.policy !== null && (typeof data.policy !== "string" || !/^[a-f0-9]{64}$/u.test(data.policy)))
74
+ unauthorized();
75
+ }
76
+ else if (event.type === "deepwork/mode") {
77
+ const data = event.data;
78
+ if (data === null || typeof data !== "object" || Array.isArray(data) || Object.keys(data).length !== 1 || typeof data.active !== "boolean")
79
+ unauthorized();
80
+ active = data.active;
81
+ }
82
+ }
83
+ return freezeSettings({ childSessionId: childId, parentSessionId: parent.id, depth: header.delegationDepth, role, descriptor,
84
+ ...(active === undefined ? {} : { active }), requestBudgetObserved: own.some(hasRequestBudget) });
85
+ }
86
+ function hasRequestBudget(event) {
87
+ if (event.type !== "request/header")
88
+ return false;
89
+ return event.data.header.config.maxTokens !== undefined;
90
+ }
91
+ /** Capture evidence must agree with the child's establishing descriptor, not current parent routing. */
92
+ export function assertNativeChildCapture(capture, facts) {
93
+ const route = capture.invocation.initialRoute, descriptor = facts.descriptor;
94
+ if (capture.childSessionId !== facts.childSessionId || capture.parentSessionId !== facts.parentSessionId || capture.role !== facts.role
95
+ || facts.depth > capture.authorityCeiling.maxDepth || descriptor.agentProvider !== route.provider || descriptor.agentModel !== route.model
96
+ || descriptor.agentReasoningEffort !== route.reasoningEffort)
97
+ unauthorized();
98
+ const ceiling = capture.authorityCeiling.toolFilter, native = descriptor.toolFilter;
99
+ if (native?.allow !== undefined && (ceiling?.allow === undefined || ceiling.allow.some(name => !native.allow.includes(name))))
100
+ unauthorized();
101
+ if (native?.deny?.some(name => ceiling?.allow?.includes(name) || ceiling?.allow === undefined && !ceiling?.deny?.includes(name)))
102
+ unauthorized();
103
+ }
104
+ //# sourceMappingURL=native-child-evidence.js.map
@@ -0,0 +1,37 @@
1
+ import type { Context } from "@deepseek-ai/cordis";
2
+ import { PiAiAdapter, Config } from "@deepseek-ai/dsh-llm-pi-ai";
3
+ import type { Options, PiAiAdapterOptions } from "@deepseek-ai/dsh-llm-pi-ai";
4
+ import type { LlmAdapter } from "@deepseek-ai/dsh-llm";
5
+ import type { DsmmLlmGeneration } from "./host-llm.js";
6
+ import type { DsmmLlmRouteResolver } from "./role-llm.js";
7
+ export interface DsmmPiAiOwnerOptions {
8
+ readonly config: Options;
9
+ readonly settingsNamespace: string;
10
+ readonly auth: PiAiAdapterOptions["auth"];
11
+ /** Called only at dispatch. An absent named credential fails; no ambient lookup is used. */
12
+ readonly resolveApiKey: (provider: string, reference: string, signal?: AbortSignal) => Promise<string | undefined>;
13
+ }
14
+ export interface DsmmPiAiProviderOwner extends DsmmLlmRouteResolver {
15
+ readonly stockAdapter: PiAiAdapter;
16
+ readonly providers: readonly string[];
17
+ generation(provider: string): DsmmLlmGeneration;
18
+ }
19
+ declare module "@deepseek-ai/cordis" {
20
+ interface Context {
21
+ dsmmLlmProviderOwner: DsmmPiAiProviderOwner;
22
+ }
23
+ }
24
+ export interface DsmmPiAiProviderPlugin {
25
+ readonly name: "dsmm-llm-provider-owner";
26
+ readonly inject: string[];
27
+ readonly Config: typeof Config;
28
+ apply(ctx: Context, config: ReturnType<typeof Config>): void;
29
+ }
30
+ export declare function createDsmmPiAiProviderPlugin(options: DsmmPiAiOwnerOptions, ready: (owner: DsmmPiAiProviderOwner) => void): DsmmPiAiProviderPlugin;
31
+ /** Build the raw executor from declared profiles; borrowed registrations remain native-owned. */
32
+ export declare function createDsmmPiAiProviderOwner(ctx: Context, options: DsmmPiAiOwnerOptions, borrowed?: {
33
+ readonly signal: AbortSignal;
34
+ readonly adapter: LlmAdapter;
35
+ assertCurrent(): void;
36
+ }): DsmmPiAiProviderOwner;
37
+ //# sourceMappingURL=native-pi-ai-wire.d.ts.map