@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
@@ -1,9 +1,12 @@
1
1
  import type { Stats } from "node:fs";
2
2
  import type { ProfileReadResult, ProfileSaveRequest, ProfileSelectRequest, ProfileSelectionState, ProfileSnapshot, SessionProfileSelectRequest } from "./profile-types.js";
3
3
  import type { DsmmProfileDocument } from "./profiles.js";
4
+ import type { ProfileDiagnostic } from "./profile-diagnostics.js";
5
+ import type { ChildAdmissionCapture } from "./child-capture.js";
4
6
  export type SaveProfileRequest = ProfileSaveRequest;
5
7
  export type SelectProfileRequest = ProfileSelectRequest;
6
8
  export interface LoadedProfileSelection extends ProfileSelectionState {
9
+ warnings?: ProfileDiagnostic[];
7
10
  document: DsmmProfileDocument | null;
8
11
  content: string | null;
9
12
  }
@@ -13,6 +16,8 @@ export interface LoadedSessionProfileSelection extends LoadedProfileSelection {
13
16
  }
14
17
  export declare const MAX_SESSION_PROFILE_CHOICES = 1024;
15
18
  export interface SessionProfileCommit<T> {
19
+ /** Fallible synchronous preparation before the final fence/rename; never publication. */
20
+ prepare?(selection: LoadedSessionProfileSelection, prepared: T): void;
16
21
  /** Trusted native liveness/cancellation fence; invoked immediately before rename. */
17
22
  assertCurrent(): void;
18
23
  /** Synchronous publication after durable commit. Must not throw or await. */
@@ -77,6 +82,12 @@ export declare class ProfileStore {
77
82
  get readOnly(): boolean;
78
83
  get writeRestriction(): string | undefined;
79
84
  private assertWritable;
85
+ /** Host-only immutable state. No RPC exposes this writer or a filesystem path. */
86
+ createChildAdmission(input: ChildAdmissionCapture, assertCurrent?: () => void): Promise<ChildAdmissionCapture>;
87
+ readChildAdmission(childId: string, parentId: string): Promise<ChildAdmissionCapture | null>;
88
+ /** Only a trusted native session-deleted handler may call this; drain never does. */
89
+ deleteChildAdmission(childId: string, parentId: string): Promise<void>;
90
+ private childAdmission;
80
91
  private readOperation;
81
92
  private locked;
82
93
  }
@@ -3,7 +3,9 @@ import { createHash, randomUUID } from "node:crypto";
3
3
  import { basename, dirname, isAbsolute, join, parse, resolve } from "node:path";
4
4
  import { parseTree } from "jsonc-parser";
5
5
  import { ABSENT_PROFILE_SELECTION_REVISION } from "./profile-types.js";
6
- import { DsmmProfileError, MAX_PROFILE_BYTES, MAX_PROFILE_COUNT, MAX_PROFILE_DIRECTORY_ENTRIES, MAX_PROFILE_REVISIONS, parseProfileDocument, profileErrorInfo, validateProfileId, validateProfileRevision } from "./profiles.js";
6
+ import { DsmmProfileError, MAX_PROFILE_BYTES, MAX_PROFILE_COUNT, MAX_PROFILE_DIRECTORY_ENTRIES, MAX_PROFILE_REVISIONS, parseProfileDocument, validateProfileDocument, profileErrorInfo, validateProfileId, validateProfileRevision } from "./profiles.js";
7
+ import { inspectJsonDocument } from "./profile-diagnostics.js";
8
+ import { parseChildAdmissionCapture } from "./child-capture.js";
7
9
  export const MAX_SESSION_PROFILE_CHOICES = 1024;
8
10
  const trustedLayout = Symbol("trusted profile storage layout");
9
11
  const LEGACY_WRITE_RESTRICTION = "Legacy profiles are read-only. Explicitly import them before saving or changing selections.";
@@ -70,7 +72,7 @@ export class ProfileStore {
70
72
  if (name !== `${id}.jsonc`)
71
73
  throw new DsmmProfileError("unsafe-path", "Profile filename must use lowercase .jsonc and match its ID.");
72
74
  const draft = this.draft(id, entries);
73
- return { id, ...(draft.document.label === undefined ? {} : { label: draft.document.label }), revision: draft.revision };
75
+ return { id, ...(draft.document.label === undefined ? {} : { label: draft.document.label.trim() === "" ? id : draft.document.label }), revision: draft.revision, ...warningFields(draft) };
74
76
  }
75
77
  catch (error) {
76
78
  return { id: safeInventoryId(id), revision: null, error: profileErrorInfo(error) };
@@ -78,7 +80,7 @@ export class ProfileStore {
78
80
  });
79
81
  try {
80
82
  const selected = this.selection();
81
- return { ...this.metadata(), profiles, selectedId: selected.selectedId, appliedRevision: selected.appliedRevision, selectionRevision: selected.selectionRevision };
83
+ return { ...this.metadata(), profiles, selectedId: selected.selectedId, appliedRevision: selected.appliedRevision, selectionRevision: selected.selectionRevision, ...(selected.warnings === undefined ? {} : { selectedWarnings: selected.warnings }) };
82
84
  }
83
85
  catch (error) {
84
86
  // An error is not a successful fallback to the baseline.
@@ -94,6 +96,7 @@ export class ProfileStore {
94
96
  this.assertWritable();
95
97
  validateProfileId(request.id);
96
98
  const document = parseProfileDocument(request.content, request.id);
99
+ const warnings = validateProfileDocument(request.content, request.id).diagnostics;
97
100
  if (request.expectedRevision !== null)
98
101
  validateProfileRevision(request.expectedRevision);
99
102
  return this.locked((assertLock) => {
@@ -112,7 +115,7 @@ export class ProfileStore {
112
115
  if (latest !== request.expectedRevision)
113
116
  conflict("The profile was edited externally during save. Reload it before saving.");
114
117
  }, assertLock);
115
- return this.readResult({ bytes, content: request.content, revision: digest(bytes), document });
118
+ return this.readResult({ bytes, content: request.content, revision: digest(bytes), document, ...(warnings.length ? { warnings } : {}) });
116
119
  });
117
120
  }
118
121
  async loadSelection() {
@@ -167,7 +170,8 @@ export class ProfileStore {
167
170
  const pointer = { version: 1, sessionId: request.sessionId, id: request.id, revision: draft?.revision ?? null, epoch };
168
171
  const bytes = Buffer.from(`${JSON.stringify(pointer)}\n`, "utf8");
169
172
  const selection = { sessionId: request.sessionId, admissionEpoch: epoch,
170
- selectedId: request.id, appliedRevision: draft?.revision ?? null, selectionRevision: digest(bytes), document: draft?.document ?? null, content: draft?.content ?? null };
173
+ selectedId: request.id, appliedRevision: draft?.revision ?? null, selectionRevision: digest(bytes), document: draft?.document ?? null, content: draft?.content ?? null, ...warningFields(draft) };
174
+ commit.prepare?.(selection, prepared);
171
175
  this.atomicReplace(target, bytes, fence, assertLock);
172
176
  commit.committed(selection, prepared);
173
177
  return { selection, prepared };
@@ -208,13 +212,13 @@ export class ProfileStore {
208
212
  conflict("The draft changed during selection. Reload and select again.");
209
213
  }, assertLock);
210
214
  return {
211
- selection: { selectedId: request.id, appliedRevision: draft?.revision ?? null, selectionRevision: digest(bytes), document: draft?.document ?? null, content: draft?.content ?? null },
215
+ selection: { selectedId: request.id, appliedRevision: draft?.revision ?? null, selectionRevision: digest(bytes), document: draft?.document ?? null, content: draft?.content ?? null, ...warningFields(draft) },
212
216
  prepared
213
217
  };
214
218
  });
215
219
  }
216
220
  readResult(draft) {
217
- return { id: draft.document.id, ...(draft.document.label === undefined ? {} : { label: draft.document.label }), revision: draft.revision, content: draft.content };
221
+ return { id: draft.document.id, ...(draft.document.label === undefined ? {} : { label: draft.document.label }), revision: draft.revision, content: draft.content, ...warningFields(draft) };
218
222
  }
219
223
  inventory() {
220
224
  if (!this.validateRoot(false))
@@ -244,7 +248,7 @@ export class ProfileStore {
244
248
  if (name === undefined)
245
249
  throw new DsmmProfileError("not-found", "The requested Deepwork profile does not exist.");
246
250
  const file = regularFile(join(this.profileDir, name), MAX_PROFILE_BYTES);
247
- return { ...file, document: parseProfileDocument(file.content, id) };
251
+ return { ...file, ...validatedProfile(file.content, id) };
248
252
  }
249
253
  selection() {
250
254
  this.validateRoot(false);
@@ -264,12 +268,13 @@ export class ProfileStore {
264
268
  const immutable = regularFile(join(this.profileDir, ".revisions", `${pointer.revision}.jsonc`), MAX_PROFILE_BYTES);
265
269
  if (immutable.revision !== pointer.revision)
266
270
  throw new DsmmProfileError("corrupt-selection", "The selected immutable profile revision failed its SHA256 verification.");
267
- const document = parseProfileDocument(immutable.content, pointer.id);
268
- return { selectedId: pointer.id, appliedRevision: pointer.revision, selectionRevision: file.revision, document, content: immutable.content };
271
+ return { selectedId: pointer.id, appliedRevision: pointer.revision, selectionRevision: file.revision, ...validatedProfile(immutable.content, pointer.id), content: immutable.content };
269
272
  }
270
273
  catch (error) {
271
274
  if (error instanceof DsmmProfileError && error.code === "unsafe-path")
272
275
  throw error;
276
+ if (error instanceof DsmmProfileError && error.reason !== undefined)
277
+ throw new DsmmProfileError("corrupt-selection", error.message, error.field, error.reason, error.location);
273
278
  throw new DsmmProfileError("corrupt-selection", "The selected profile pointer or immutable revision is missing or invalid. Repair it explicitly; the baseline was not silently selected.");
274
279
  }
275
280
  }
@@ -299,11 +304,13 @@ export class ProfileStore {
299
304
  if (immutable.revision !== pointer.revision)
300
305
  throw new DsmmProfileError("corrupt-selection", "The session's immutable profile revision failed SHA256 verification.");
301
306
  return { sessionId, admissionEpoch: pointer.epoch, selectedId: pointer.id, appliedRevision: pointer.revision,
302
- selectionRevision: file.revision, document: parseProfileDocument(immutable.content, pointer.id), content: immutable.content };
307
+ selectionRevision: file.revision, ...validatedProfile(immutable.content, pointer.id), content: immutable.content };
303
308
  }
304
309
  catch (error) {
305
310
  if (error instanceof DsmmProfileError && error.code === "unsafe-path")
306
311
  throw error;
312
+ if (error instanceof DsmmProfileError && error.reason !== undefined)
313
+ throw new DsmmProfileError("corrupt-selection", error.message, error.field, error.reason, error.location);
307
314
  throw new DsmmProfileError("corrupt-selection", "The session profile choice or immutable revision is missing or invalid. Repair it explicitly; no global or baseline fallback was admitted.");
308
315
  }
309
316
  }
@@ -373,6 +380,122 @@ export class ProfileStore {
373
380
  if (this.origin === "legacy")
374
381
  throw new DsmmProfileError("unavailable", LEGACY_WRITE_RESTRICTION);
375
382
  }
383
+ /** Host-only immutable state. No RPC exposes this writer or a filesystem path. */
384
+ async createChildAdmission(input, assertCurrent) {
385
+ this.assertWritable();
386
+ const capture = parseChildAdmissionCapture(input);
387
+ if (capture.version !== 2)
388
+ throw new DsmmProfileError("validation", "New child admissions require capture v2.");
389
+ const revision = digest(Buffer.from(JSON.stringify(capture), "utf8"));
390
+ const bytes = Buffer.from(`${JSON.stringify({ version: 1, revision, capture })}\n`, "utf8");
391
+ if (bytes.length > MAX_PROFILE_BYTES)
392
+ throw new DsmmProfileError("limit", "Child admission exceeds the supported size.");
393
+ return this.locked(assertLock => {
394
+ // The Host's synchronous admission fence runs after lock acquisition and
395
+ // before any child namespace or record write; this operation never awaits.
396
+ assertLock();
397
+ assertCurrent?.();
398
+ const directory = join(this.stateDir, ".children", "v1");
399
+ this.validateState(true);
400
+ validateDirectories(directory, true, false, this.identities);
401
+ const path = join(directory, `${sessionChoiceKey(capture.childSessionId)}.json`);
402
+ const existing = this.childAdmission(capture.childSessionId, capture.parentSessionId);
403
+ if (existing !== null) {
404
+ if (JSON.stringify(existing) !== JSON.stringify(capture))
405
+ conflict("An immutable child admission already exists; it cannot be overwritten.");
406
+ return existing;
407
+ }
408
+ if (boundedEntries(directory, MAX_SESSION_PROFILE_CHOICES).length >= MAX_SESSION_PROFILE_CHOICES)
409
+ throw new DsmmProfileError("limit", "The child admission inventory is full.");
410
+ assertLock();
411
+ let fd, owned;
412
+ try {
413
+ fd = openSync(path, constants.O_WRONLY | constants.O_CREAT | constants.O_EXCL | (constants.O_NOFOLLOW ?? 0), 0o600);
414
+ owned = fstatSync(fd);
415
+ assertRegular(owned);
416
+ writeAll(fd, bytes);
417
+ fsyncSync(fd);
418
+ assertLock();
419
+ validateDirectories(directory, false, false, this.identities);
420
+ const named = status(path);
421
+ if (named === undefined || !sameFile(owned, named))
422
+ conflict("Child admission identity changed during creation.");
423
+ return capture;
424
+ }
425
+ catch (error) {
426
+ if (owned !== undefined) {
427
+ try {
428
+ assertLock();
429
+ const named = status(path);
430
+ if (named !== undefined && sameFile(owned, named))
431
+ unlinkSync(path);
432
+ }
433
+ catch { /* Preserve a replacement or an invalidated root. */ }
434
+ }
435
+ throw error;
436
+ }
437
+ finally {
438
+ if (fd !== undefined)
439
+ closeSync(fd);
440
+ }
441
+ });
442
+ }
443
+ async readChildAdmission(childId, parentId) {
444
+ validateSessionProfileId(childId);
445
+ validateSessionProfileId(parentId);
446
+ return this.readOperation(() => this.childAdmission(childId, parentId));
447
+ }
448
+ /** Only a trusted native session-deleted handler may call this; drain never does. */
449
+ async deleteChildAdmission(childId, parentId) {
450
+ this.assertWritable();
451
+ validateSessionProfileId(childId);
452
+ validateSessionProfileId(parentId);
453
+ await this.locked(assertLock => {
454
+ const capture = this.childAdmission(childId, parentId);
455
+ if (capture === null)
456
+ return;
457
+ const path = join(this.stateDir, ".children", "v1", `${sessionChoiceKey(childId)}.json`);
458
+ const file = regularFile(path, MAX_PROFILE_BYTES), owned = lstatSync(path);
459
+ assertLock();
460
+ if (!sameFile(owned, lstatSync(path)) || !regularFile(path, MAX_PROFILE_BYTES).bytes.equals(file.bytes))
461
+ conflict("Child capture changed before native deletion cleanup.");
462
+ unlinkSync(path);
463
+ });
464
+ }
465
+ childAdmission(childId, parentId) {
466
+ this.validateRoot(false);
467
+ this.validateState(false);
468
+ const directory = join(this.stateDir, ".children", "v1");
469
+ // Validate an existing parent sidecar directory even if the version path is absent.
470
+ if (!validateDirectories(join(this.stateDir, ".children"), false, true, this.identities))
471
+ return null;
472
+ if (boundedEntries(join(this.stateDir, ".children"), 16).some(name => name !== "v1"))
473
+ throw new DsmmProfileError("corrupt-selection", "The child capture namespace has an unsupported version; legacy recovery is not allowed.");
474
+ if (!validateDirectories(directory, false, true, this.identities))
475
+ return null;
476
+ const path = join(directory, `${sessionChoiceKey(childId)}.json`);
477
+ if (status(path) === undefined)
478
+ return null;
479
+ const file = regularFile(path, MAX_PROFILE_BYTES);
480
+ try {
481
+ const inspected = inspectJsonDocument(file.content, false);
482
+ if (inspected.diagnostics.length)
483
+ throw new Error("Invalid child JSON");
484
+ const envelope = JSON.parse(file.content);
485
+ if (envelope === null || typeof envelope !== "object" || Array.isArray(envelope) || Object.keys(envelope).length !== 3 || envelope.version !== 1 || !Object.hasOwn(envelope, "revision") || !Object.hasOwn(envelope, "capture"))
486
+ throw new Error("Invalid capture envelope");
487
+ validateProfileRevision(envelope.revision, "revision");
488
+ if (digest(Buffer.from(JSON.stringify(envelope.capture), "utf8")) !== envelope.revision)
489
+ throw new Error("Capture integrity mismatch");
490
+ const capture = parseChildAdmissionCapture(envelope.capture);
491
+ if (capture.childSessionId !== childId || capture.parentSessionId !== parentId)
492
+ throw new Error("Child capture identity mismatch");
493
+ return capture;
494
+ }
495
+ catch {
496
+ throw new DsmmProfileError("corrupt-selection", "The existing child admission is invalid; legacy recovery is not allowed.");
497
+ }
498
+ }
376
499
  async readOperation(operation) {
377
500
  if (this.origin === "explicit")
378
501
  return this.locked(operation);
@@ -719,4 +842,13 @@ function conflict(message) {
719
842
  function safeInventoryId(id) {
720
843
  return /^[a-zA-Z0-9_-]{1,64}$/u.test(id) ? id : "invalid-profile";
721
844
  }
845
+ function warningFields(value) {
846
+ return value?.warnings === undefined ? {} : { warnings: value.warnings };
847
+ }
848
+ function validatedProfile(content, id) {
849
+ const result = validateProfileDocument(content, id);
850
+ if (result.document === undefined)
851
+ parseProfileDocument(content, id);
852
+ return { document: result.document, ...(result.diagnostics.length ? { warnings: result.diagnostics } : {}) };
853
+ }
722
854
  //# sourceMappingURL=profile-store.js.map
@@ -1,7 +1,64 @@
1
1
  /** Wire-only profile data: safe to import from the native browser client. */
2
2
  import type { DsmmRoleId } from "./roles.js";
3
3
  import type { DsmmModuleState } from "./modules.js";
4
- import type { DsmmModelRoute, DsmmProfileScope } from "./settings.js";
4
+ import type { DsmmInvocationLevel, DsmmModelRoute, DsmmProfileScope } from "./settings.js";
5
+ import type { ProfileDiagnostic, ProfileDiagnosticCode, ProfileDiagnosticLocation } from "./profile-diagnostics.js";
6
+ export type { ProfileDiagnostic, ProfileDiagnosticCode, ProfileDiagnosticLocation } from "./profile-diagnostics.js";
7
+ export declare const DSMM_ROUTE_SOURCES: readonly ["inherited", "primary", "level", "invocation-route"];
8
+ export type DsmmRouteSource = typeof DSMM_ROUTE_SOURCES[number];
9
+ export type DsmmInitialRoleRoute = {
10
+ readonly status: "known";
11
+ readonly source: "invocation-capture";
12
+ readonly route: Readonly<DsmmModelRoute>;
13
+ } | {
14
+ readonly status: "unknown";
15
+ readonly reason: "missing-invocation-capture";
16
+ };
17
+ export type DsmmLiveRoleRoute = {
18
+ readonly status: "known";
19
+ readonly source: "own-native-request-header";
20
+ readonly route: Readonly<DsmmModelRoute>;
21
+ } | {
22
+ readonly status: "unknown";
23
+ readonly reason: "no-own-request-header" | "invalid-own-request-header" | "not-observed";
24
+ };
25
+ /** Exact child capture and own request observation; neither substitutes for the other. */
26
+ export type DsmmRoleRouteComparison = {
27
+ readonly childId: string;
28
+ readonly initialRoute: DsmmInitialRoleRoute;
29
+ readonly liveRoute: DsmmLiveRoleRoute;
30
+ };
31
+ export interface DsmmInvocationView {
32
+ role: DsmmRoleId;
33
+ label: string;
34
+ level: DsmmInvocationLevel;
35
+ routeSource: DsmmRouteSource;
36
+ /** Preflighted/actual native route, never inferred from raw wire arguments. */
37
+ route?: DsmmModelRoute;
38
+ mode: "one-shot" | "continuable";
39
+ runId?: string;
40
+ childId?: string;
41
+ jobId?: string;
42
+ routeComparison?: DsmmRoleRouteComparison;
43
+ }
44
+ export interface SubagentRuntimeAdmissionView {
45
+ binding: "stock" | "dsmm" | "unavailable";
46
+ deliveryFenceReady: boolean;
47
+ restartRequired: boolean;
48
+ reason?: "explicit-composition-required" | "duplicate-provider" | "authority-not-ready";
49
+ }
50
+ export interface DsmmRoleAvailabilityState {
51
+ id: DsmmRoleId;
52
+ required: boolean;
53
+ requiredReason?: "deepwork-planning" | "legacy-review";
54
+ startupAvailable: boolean;
55
+ deploymentEnabled: boolean;
56
+ namedEnabled?: boolean;
57
+ admitted: boolean;
58
+ reason?: "module-off" | "deployment-disabled" | "startup-unavailable" | "profile-disabled" | "required-role" | "current-root-disabled";
59
+ source: "defaults" | "global" | "profile" | "named-session";
60
+ capture: "startup" | "deployment" | "named-session";
61
+ }
5
62
  /** Non-executable schema projection for the native deployment editor. */
6
63
  export interface DeploymentSchemaNode {
7
64
  type: string;
@@ -15,8 +72,11 @@ export interface DeploymentSchemaNode {
15
72
  required?: boolean;
16
73
  keys?: readonly string[];
17
74
  nonempty?: boolean;
75
+ additionalProperties?: "json";
18
76
  }
19
77
  export interface DeploymentAdmissionView {
78
+ /** Captured execution semantics, not proof of a ready raw executor. */
79
+ modelParameterPolicy?: import("./model-parameter-policy.js").ResolvedModelParameterPolicy;
20
80
  /** Host-redacted read-only view, never raw editor input or actual runtime settings. */
21
81
  settings: Record<string, unknown>;
22
82
  sources: Record<string, string>;
@@ -53,11 +113,14 @@ export interface DeploymentEditorSnapshot {
53
113
  import type { DsmmRateLimitPolicy, DsmmRoutingStrategy, DsmmRuntimePolicyConfig, DsmmRuntimePolicySettings } from "./routing-policy.js";
54
114
  export type ProfileErrorCode = "validation" | "conflict" | "not-found" | "lock-timeout" | "unsafe-path" | "io" | "activation" | "corrupt-selection" | "limit" | "busy" | "maintenance" | "disposed" | "not-owned" | "unavailable" | "cancelled";
55
115
  export interface ProfileErrorInfo {
116
+ reason?: ProfileDiagnosticCode;
117
+ location?: ProfileDiagnosticLocation;
56
118
  code: ProfileErrorCode;
57
119
  message: string;
58
120
  field?: string;
59
121
  }
60
122
  export interface ProfileSummary {
123
+ warnings?: ProfileDiagnostic[];
61
124
  id: string;
62
125
  label?: string;
63
126
  revision: string | null;
@@ -69,6 +132,7 @@ export interface ProfileSelectionState {
69
132
  selectionRevision: string;
70
133
  }
71
134
  export interface ProfileSnapshot extends ProfileSelectionState {
135
+ selectedWarnings?: ProfileDiagnostic[];
72
136
  profiles: ProfileSummary[];
73
137
  selectionError?: ProfileErrorInfo;
74
138
  /** Native deployment role inventory; excludes provider accounts and auth data. */
@@ -79,6 +143,7 @@ export interface ProfileSnapshot extends ProfileSelectionState {
79
143
  writeRestriction?: string;
80
144
  }
81
145
  export interface ProfileReadResult {
146
+ warnings?: ProfileDiagnostic[];
82
147
  id: string;
83
148
  label?: string;
84
149
  revision: string;
@@ -95,6 +160,7 @@ export interface ProfileSelectRequest {
95
160
  expectedSelectionRevision: string;
96
161
  }
97
162
  export interface ProfileRoleMetadata {
163
+ availability?: DsmmRoleAvailabilityState;
98
164
  id: DsmmRoleId;
99
165
  label: string;
100
166
  enabled: boolean;
@@ -112,6 +178,9 @@ export interface DsmmRoleRuntimeState {
112
178
  totalDelayMs: number;
113
179
  }
114
180
  export interface SessionProfileSnapshot {
181
+ warnings?: ProfileDiagnostic[];
182
+ roles?: DsmmRoleAvailabilityState[];
183
+ subagentRuntime?: SubagentRuntimeAdmissionView;
115
184
  sessionId: string;
116
185
  globalDefault: ProfileSelectionState;
117
186
  /** Current sidecar state: the authority for session-selection CAS. */
@@ -1,2 +1,3 @@
1
+ export const DSMM_ROUTE_SOURCES = ["inherited", "primary", "level", "invocation-route"];
1
2
  export const ABSENT_PROFILE_SELECTION_REVISION = "absent";
2
3
  //# sourceMappingURL=profile-types.js.map
package/lib/profiles.d.ts CHANGED
@@ -1,10 +1,14 @@
1
1
  import type { DsmmPluginConfig, DsmmSettings } from "./settings.js";
2
2
  import type { ProfileErrorCode, ProfileErrorInfo } from "./profile-types.js";
3
+ import type { ProfileDiagnostic, ProfileDiagnosticCode, ProfileDiagnosticLocation } from "./profile-diagnostics.js";
4
+ import type { DsmmRoleId } from "./roles.js";
3
5
  export declare const MAX_PROFILE_BYTES: number;
4
6
  export declare const MAX_PROFILE_COUNT = 128;
5
7
  export declare const MAX_PROFILE_DIRECTORY_ENTRIES = 1024;
6
8
  export declare const MAX_PROFILE_REVISIONS = 1024;
7
- export type DsmmProfileOverlay = Pick<DsmmPluginConfig, "defaultActive" | "roleRouting" | "runtimePolicy" | "workflow" | "guards" | "runtimeRecovery" | "deepseekV4ProCalibration" | "deepseekV4ProDefaultReasoningEffort" | "deepseekV4ProMaxReasoningPresets" | "deepseekFlashCalibration" | "deepseekFlashDefaultReasoningEffort" | "deepseekFlashMaxReasoningPresets">;
9
+ export type DsmmProfileOverlay = Pick<DsmmPluginConfig, "modelParameters" | "defaultActive" | "roleRouting" | "runtimePolicy" | "workflow" | "guards" | "runtimeRecovery" | "roles" | "locale" | "deepseekV4ProCalibration" | "deepseekV4ProDefaultReasoningEffort" | "deepseekFlashCalibration" | "deepseekFlashDefaultReasoningEffort"> & {
10
+ subagents?: Pick<NonNullable<DsmmPluginConfig["subagents"]>, "toolTopology">;
11
+ };
8
12
  export interface DsmmProfileDocument {
9
13
  version: 1;
10
14
  id: string;
@@ -14,13 +18,23 @@ export interface DsmmProfileDocument {
14
18
  export declare class DsmmProfileError extends Error {
15
19
  readonly code: ProfileErrorCode;
16
20
  readonly field?: string;
17
- constructor(code: ProfileErrorCode, message: string, field?: string);
21
+ readonly reason?: ProfileDiagnosticCode;
22
+ readonly location?: ProfileDiagnosticLocation;
23
+ constructor(code: ProfileErrorCode, message: string, field?: string, reason?: ProfileDiagnosticCode, location?: ProfileDiagnosticLocation);
18
24
  toInfo(): ProfileErrorInfo;
19
25
  }
20
26
  export declare function profileErrorInfo(error: unknown, fallback?: ProfileErrorCode): ProfileErrorInfo;
21
27
  export declare function validateProfileId(id: unknown): asserts id is string;
22
28
  export declare function validateProfileRevision(revision: unknown, field?: string): asserts revision is string;
23
29
  export declare function parseProfileDocument(content: string, expectedId?: string): DsmmProfileDocument;
30
+ export declare function validateProfileDocument(content: string, expectedId?: string): {
31
+ document?: DsmmProfileDocument;
32
+ diagnostics: ProfileDiagnostic[];
33
+ };
34
+ export declare function profileDocumentWarnings(document: DsmmProfileDocument | null): ProfileDiagnostic[];
35
+ export declare function validateProfileOverlay(input: unknown): asserts input is DsmmProfileOverlay;
24
36
  export declare function mergeProfileConfig(baseline: DsmmPluginConfig, overlay: DsmmProfileOverlay): DsmmPluginConfig;
25
37
  export declare function resolveProfileSettings(baseline: DsmmPluginConfig, overlay: DsmmProfileOverlay): DsmmSettings;
38
+ export declare function requiredDeepworkRoles(settings: Pick<DsmmSettings, "workflow">): DsmmRoleId[];
39
+ export declare function requiredReason(settings: Pick<DsmmSettings, "workflow">, role: DsmmRoleId): "deepwork-planning" | "legacy-review" | undefined;
26
40
  //# sourceMappingURL=profiles.d.ts.map