@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,3 +1,6 @@
1
+ import { isDeepStrictEqual } from "node:util";
2
+ import { normalizeModelRouteJson } from "./route-json.js";
3
+ import { modelRouteFromHeader } from "./role-llm.js";
1
4
  const REQUEST_HEADER_REASONS = new Set(["initial", "resume", "change", "series"]);
2
5
  const TODO_STATUSES = new Set(["pending", "in_progress", "completed"]);
3
6
  const GOAL_OPERATIONS = new Set(["create", "edit", "pause", "resume", "complete", "block"]);
@@ -106,9 +109,6 @@ export function selectFallbackRoute({ failedRoute, attemptedRoutes, fallbackRout
106
109
  function isRecord(value) {
107
110
  return typeof value === "object" && value !== null && !Array.isArray(value);
108
111
  }
109
- function isNonEmptyString(value) {
110
- return typeof value === "string" && value.trim() !== "";
111
- }
112
112
  function isNormalizedNonEmptyString(value) {
113
113
  return typeof value === "string" && value !== "" && value === value.trim();
114
114
  }
@@ -123,12 +123,15 @@ function hasExactKeys(value, expectedKeys) {
123
123
  return keys.length === expectedKeys.length && keys.every((key) => expectedKeys.includes(key));
124
124
  }
125
125
  function readRoute(value) {
126
- if (!isRecord(value) || !isNonEmptyString(value.provider) || !isNonEmptyString(value.model))
126
+ try {
127
+ return normalizeModelRouteJson(value, false, true);
128
+ }
129
+ catch {
127
130
  return undefined;
128
- return { provider: value.provider, model: value.model, ...(isNonEmptyString(value.reasoningEffort) ? { reasoningEffort: value.reasoningEffort } : {}) };
131
+ }
129
132
  }
130
133
  function sameRoute(left, right) {
131
- return left.provider === right.provider && left.model === right.model;
134
+ return isDeepStrictEqual(readRoute(left), readRoute(right));
132
135
  }
133
136
  function appendUniqueRoute(routes, route) {
134
137
  if (!routes.some((candidate) => sameRoute(candidate, route)))
@@ -168,7 +171,17 @@ function readHeaderRoute(event) {
168
171
  return undefined;
169
172
  if (!isRecord(data.header) || !isRecord(data.header.config))
170
173
  return undefined;
171
- return readRoute(data.header.config);
174
+ try {
175
+ const provider = data.header.config.provider;
176
+ if (typeof provider !== "string")
177
+ return undefined;
178
+ // Decode native envelopes with valid grammar, then retain the exact durable identity.
179
+ const route = modelRouteFromHeader({ ...data.header, config: { ...data.header.config, provider: provider.trim() } });
180
+ return readRoute({ ...route, provider });
181
+ }
182
+ catch {
183
+ return undefined;
184
+ }
172
185
  }
173
186
  function endsTargetScope(event) {
174
187
  const type = eventType(event);
@@ -0,0 +1,38 @@
1
+ import type { RemoteResult, TypertRemoteContribution } from "@deepseek-ai/dsh-typert-protocol";
2
+ import type { TypertContribution } from "@deepseek-ai/dsh-typert-registry";
3
+ import type { BackgroundTransitionResult, ChildSessionSnapshot, RoleControlBackgroundRequest, RoleControlCapabilities, RoleControlDescendantsSnapshot, RoleControlErrorInfo, RoleControlInterruptRequest, SubagentInterruptReceipt, SubagentPromptReceipt, SubagentPromptRequest } from "./role-control-types.js";
4
+ export interface DsmmChildrenRemote {
5
+ describe(sessionId: string): Promise<RemoteResult<ChildSessionSnapshot>>;
6
+ descendants(sessionId: string): Promise<RemoteResult<RoleControlDescendantsSnapshot>>;
7
+ background(sessionId: string, request: RoleControlBackgroundRequest): Promise<RemoteResult<BackgroundTransitionResult>>;
8
+ prompt(sessionId: string, request: SubagentPromptRequest): Promise<RemoteResult<SubagentPromptReceipt>>;
9
+ interrupt(sessionId: string, request: RoleControlInterruptRequest): Promise<RemoteResult<SubagentInterruptReceipt>>;
10
+ }
11
+ declare module "@deepseek-ai/dsh-typert-protocol/types" {
12
+ interface TypertRemoteMap {
13
+ "dsmmChildren/describe": DsmmChildrenRemote["describe"];
14
+ "dsmmChildren/descendants": DsmmChildrenRemote["descendants"];
15
+ "dsmmChildren/background": DsmmChildrenRemote["background"];
16
+ "dsmmChildren/prompt": DsmmChildrenRemote["prompt"];
17
+ "dsmmChildren/interrupt": DsmmChildrenRemote["interrupt"];
18
+ }
19
+ interface TypertRemoteNamespaceMap {
20
+ dsmmChildren: DsmmChildrenRemote;
21
+ }
22
+ interface RemoteErrorDetailsMap {
23
+ "dsmm-children/refused": RoleControlErrorInfo;
24
+ }
25
+ }
26
+ export declare const parseRoleControlErrorInfo: (value: unknown) => RoleControlErrorInfo;
27
+ export declare const parseChildSessionSnapshot: (value: unknown) => ChildSessionSnapshot;
28
+ export declare const parseRoleControlDescendants: (value: unknown) => RoleControlDescendantsSnapshot;
29
+ export declare const parseRoleControlBackgroundRequest: (value: unknown) => RoleControlBackgroundRequest;
30
+ export declare const parseRoleControlPromptRequest: (value: unknown) => SubagentPromptRequest;
31
+ export declare const parseRoleControlInterruptRequest: (value: unknown) => RoleControlInterruptRequest;
32
+ export declare const parseRoleControlCapabilities: (value: unknown) => RoleControlCapabilities;
33
+ export declare const parseRoleControlSessionId: (value: unknown) => string;
34
+ /** Separate package identity prevents replacing the Profiles contribution. */
35
+ export declare const ROLE_CONTROL_REMOTE: TypertRemoteContribution;
36
+ export declare const ROLE_CONTROL_HOST: TypertContribution;
37
+ export default ROLE_CONTROL_REMOTE;
38
+ //# sourceMappingURL=role-control-remote.d.ts.map
@@ -0,0 +1,211 @@
1
+ import { parseDsmmInvocationView, parseDsmmRoleRouteComparison, parseSubagentRuntimeAdmissionView, isNativeSessionId } from "./profile-remote.js";
2
+ import { parseChildAdmissionEvidenceView } from "./child-evidence.js";
3
+ import { ROLE_CONTROL_DISABLED_REASONS, ROLE_CONTROL_ERROR_CODES, ROLE_CONTROL_ERROR_FIELDS } from "./role-control-types.js";
4
+ function fail() { throw new TypeError("Invalid Deepwork child control DTO."); }
5
+ /** Reject executable/non-JSON shapes before accessing any properties. */
6
+ function json(value, depth = 0, active = new Set()) {
7
+ if (depth > 24)
8
+ fail();
9
+ if (value === null || typeof value === "boolean" || typeof value === "string")
10
+ return value;
11
+ if (typeof value === "number" && Number.isFinite(value))
12
+ return value;
13
+ if (typeof value !== "object" || value === null || active.has(value))
14
+ fail();
15
+ const isArray = Array.isArray(value);
16
+ if (Object.getPrototypeOf(value) !== (isArray ? Array.prototype : Object.prototype) && (isArray || Object.getPrototypeOf(value) !== null))
17
+ fail();
18
+ if (Object.getOwnPropertySymbols(value).length)
19
+ fail();
20
+ for (const [key, property] of Object.entries(Object.getOwnPropertyDescriptors(value))) {
21
+ if (isArray && key === "length")
22
+ continue;
23
+ if (!Object.hasOwn(property, "value") || !property.enumerable || ["__proto__", "prototype", "constructor"].includes(key)
24
+ || isArray && !/^(0|[1-9][0-9]*)$/u.test(key))
25
+ fail();
26
+ }
27
+ if (isArray && Object.keys(value).length !== value.length)
28
+ fail();
29
+ active.add(value);
30
+ const result = isArray ? value.map(child => json(child, depth + 1, active)) : Object.fromEntries(Object.entries(value).map(([key, child]) => [key, json(child, depth + 1, active)]));
31
+ active.delete(value);
32
+ return result;
33
+ }
34
+ function object(value, required, optional = []) {
35
+ if (typeof value !== "object" || value === null || Array.isArray(value))
36
+ fail();
37
+ const row = value;
38
+ if (required.some(key => !Object.hasOwn(row, key)) || Object.keys(row).some(key => !required.includes(key) && !optional.includes(key)))
39
+ fail();
40
+ return row;
41
+ }
42
+ function choice(value, choices) { if (!choices.includes(value))
43
+ fail(); return value; }
44
+ function text(value, max) {
45
+ if (typeof value !== "string" || value.length > max || /[\u0000-\u001f\u007f]/u.test(value)
46
+ || new TextDecoder("utf-8", { fatal: true, ignoreBOM: true }).decode(new TextEncoder().encode(value)) !== value)
47
+ fail();
48
+ return value;
49
+ }
50
+ function identity(value) { if (!isNativeSessionId(value))
51
+ fail(); return value; }
52
+ function epoch(value) { if (typeof value !== "string" || !/^[a-f0-9]{64}$/u.test(value))
53
+ fail(); return value; }
54
+ function array(value, max = 4096) { if (!Array.isArray(value) || value.length > max)
55
+ fail(); return value; }
56
+ function bool(value) { if (typeof value !== "boolean")
57
+ fail(); return value; }
58
+ function depth(value) { if (typeof value !== "number" || !Number.isSafeInteger(value) || value < 1 || value > 4096)
59
+ fail(); return value; }
60
+ function availability(value) {
61
+ const row = object(value, ["enabled"], ["reason"]);
62
+ if (row.enabled === true && !Object.hasOwn(row, "reason"))
63
+ return { enabled: true };
64
+ if (row.enabled !== false)
65
+ fail();
66
+ return { enabled: false, reason: choice(row.reason, ROLE_CONTROL_DISABLED_REASONS) };
67
+ }
68
+ function capabilities(value) {
69
+ const row = object(value, ["background", "prompt", "interrupt", "images", "runtime"]);
70
+ return { background: availability(row.background), prompt: availability(row.prompt), interrupt: availability(row.interrupt), images: availability(row.images), runtime: parseSubagentRuntimeAdmissionView(row.runtime) };
71
+ }
72
+ function run(value) {
73
+ const row = object(value, ["sessionId", "toolCallId", "state", "background"], ["invocation"]);
74
+ const state = choice(row.state, ["starting", "running", "background", "settled", "cancelled"]);
75
+ const invocation = Object.hasOwn(row, "invocation") ? parseDsmmInvocationView(row.invocation) : undefined;
76
+ if (state === "starting" && invocation !== undefined || invocation !== undefined && (invocation.mode !== "one-shot" || invocation.runId === undefined)
77
+ || ["running", "background", "settled"].includes(state) && invocation === undefined)
78
+ fail();
79
+ return { sessionId: identity(row.sessionId), toolCallId: identity(row.toolCallId), state, background: availability(row.background), ...(invocation === undefined ? {} : { invocation }) };
80
+ }
81
+ function child(value) {
82
+ const row = object(value, ["id", "parentSessionId", "mode", "activity", "readonly", "controls"], ["label", "invocation", "routeComparison", "evidence"]);
83
+ const controls = object(row.controls, ["prompt", "interrupt"]);
84
+ const mode = choice(row.mode, ["one-shot", "continuable", "unknown"]);
85
+ const prompt = availability(controls.prompt), interrupt = availability(controls.interrupt);
86
+ const readonly = bool(row.readonly);
87
+ if (readonly !== (!prompt.enabled && !interrupt.enabled) || mode !== "continuable" && (prompt.enabled || interrupt.enabled))
88
+ fail();
89
+ const invocation = Object.hasOwn(row, "invocation") ? parseDsmmInvocationView(row.invocation) : undefined;
90
+ const routeComparison = Object.hasOwn(row, "routeComparison") ? parseDsmmRoleRouteComparison(row.routeComparison) : undefined;
91
+ const evidence = Object.hasOwn(row, "evidence") ? parseChildAdmissionEvidenceView(row.evidence) : undefined;
92
+ const id = identity(row.id);
93
+ if (invocation !== undefined && (invocation.childId !== id || invocation.mode !== mode))
94
+ fail();
95
+ if (routeComparison !== undefined && routeComparison.childId !== id)
96
+ fail();
97
+ if (evidence?.mode === "legacy-conservative" && invocation !== undefined)
98
+ fail();
99
+ return { id, parentSessionId: identity(row.parentSessionId), mode, activity: choice(row.activity, ["running", "inactive"]), readonly,
100
+ controls: { prompt, interrupt }, ...(Object.hasOwn(row, "label") ? { label: text(row.label, 120) } : {}),
101
+ ...(invocation === undefined ? {} : { invocation }), ...(routeComparison === undefined ? {} : { routeComparison }), ...(evidence === undefined ? {} : { evidence }) };
102
+ }
103
+ function snapshot(value) {
104
+ const row = object(value, ["sessionId", "admissionEpoch", "runs", "children", "capabilities"]);
105
+ const sessionId = identity(row.sessionId), admissionEpoch = epoch(row.admissionEpoch), runs = array(row.runs).map(run), children = array(row.children).map(child);
106
+ if (runs.some(run => run.sessionId !== sessionId) || children.some(child => child.parentSessionId !== sessionId || child.evidence !== undefined && child.evidence.parentAdmissionEpoch !== admissionEpoch))
107
+ fail();
108
+ return { sessionId, admissionEpoch, runs, children, capabilities: capabilities(row.capabilities) };
109
+ }
110
+ function descendants(value) {
111
+ const row = object(value, ["sessionId", "admissionEpoch", "descendants"]);
112
+ const sessionId = identity(row.sessionId), admissionEpoch = epoch(row.admissionEpoch);
113
+ const entries = array(row.descendants).map(value => {
114
+ const entry = object(value, ["kind", "depth"], ["child", "hasChildren", "id", "parentSessionId", "reason"]);
115
+ if (entry.kind === "child") {
116
+ object(entry, ["kind", "depth", "child", "hasChildren"]);
117
+ const projected = child(entry.child);
118
+ if (entry.depth !== 1 && (projected.controls.prompt.enabled || projected.controls.interrupt.enabled))
119
+ fail();
120
+ return { kind: "child", depth: depth(entry.depth), child: projected, hasChildren: bool(entry.hasChildren) };
121
+ }
122
+ object(entry, ["kind", "depth", "id", "parentSessionId", "reason"]);
123
+ if (entry.kind !== "diagnostic")
124
+ fail();
125
+ return { kind: "diagnostic", depth: depth(entry.depth), id: identity(entry.id), parentSessionId: identity(entry.parentSessionId), reason: choice(entry.reason, ["corrupt", "unsupported", "unavailable"]) };
126
+ });
127
+ for (const entry of entries) {
128
+ const parent = entry.kind === "child" ? entry.child.parentSessionId : entry.parentSessionId;
129
+ if ((entry.depth === 1) !== (parent === sessionId))
130
+ fail();
131
+ if (entry.kind === "child" && entry.child.evidence !== undefined && entry.child.evidence.parentAdmissionEpoch !== admissionEpoch)
132
+ fail();
133
+ }
134
+ return { sessionId, admissionEpoch, descendants: entries };
135
+ }
136
+ function backgroundRequest(value) {
137
+ const row = object(value, ["sessionId", "toolCallId", "runId", "expectedAdmissionEpoch"]);
138
+ return { sessionId: identity(row.sessionId), toolCallId: identity(row.toolCallId), runId: identity(row.runId), expectedAdmissionEpoch: epoch(row.expectedAdmissionEpoch) };
139
+ }
140
+ function transition(value) {
141
+ const row = object(value, ["status", "runId"], ["jobId"]);
142
+ const status = choice(row.status, ["background", "already-background", "already-settled", "cancelled"]);
143
+ if (["background", "already-background"].includes(status) !== Object.hasOwn(row, "jobId"))
144
+ fail();
145
+ return { status, runId: identity(row.runId), ...(Object.hasOwn(row, "jobId") ? { jobId: identity(row.jobId) } : {}) };
146
+ }
147
+ function promptRequest(value) {
148
+ const row = object(value, ["requestId", "parentSessionId", "childSessionId", "mode", "delivery", "content"], ["clientTimeZone"]);
149
+ if (row.mode !== "continuable")
150
+ fail();
151
+ const content = array(row.content, Number.MAX_SAFE_INTEGER).map(value => {
152
+ const part = object(value, ["type"], ["text", "mediaType", "data", "name"]);
153
+ if (part.type === "text") {
154
+ object(part, ["type", "text"]);
155
+ if (typeof part.text !== "string")
156
+ fail();
157
+ return { type: "text", text: part.text };
158
+ }
159
+ object(part, ["type", "mediaType", "data"], ["name"]);
160
+ if (part.type !== "image" || typeof part.data !== "string")
161
+ fail();
162
+ return { type: "image", mediaType: choice(part.mediaType, ["image/png", "image/jpeg", "image/webp", "image/gif"]), data: part.data,
163
+ ...(Object.hasOwn(part, "name") ? { name: text(part.name, 256) } : {}) };
164
+ });
165
+ if (content.length === 0)
166
+ fail();
167
+ return { requestId: identity(row.requestId), parentSessionId: identity(row.parentSessionId),
168
+ childSessionId: identity(row.childSessionId), mode: "continuable", delivery: choice(row.delivery, ["queue", "steer"]), content,
169
+ ...(Object.hasOwn(row, "clientTimeZone") ? { clientTimeZone: text(row.clientTimeZone, 128) } : {}) };
170
+ }
171
+ function interruptRequest(value) {
172
+ const row = object(value, ["parentSessionId", "childSessionId", "mode"]);
173
+ if (row.mode !== "continuable")
174
+ fail();
175
+ return { parentSessionId: identity(row.parentSessionId), childSessionId: identity(row.childSessionId), mode: "continuable" };
176
+ }
177
+ function promptReceipt(value) { const row = object(value, ["messageId"]); return { messageId: identity(row.messageId) }; }
178
+ function interruptReceipt(value) { const row = object(value, ["accepted"]); if (row.accepted !== true)
179
+ fail(); return { accepted: true }; }
180
+ function errorInfo(value) {
181
+ const row = object(value, ["code"], ["field", "reason"]);
182
+ return { code: choice(row.code, ROLE_CONTROL_ERROR_CODES), ...(Object.hasOwn(row, "field") ? { field: choice(row.field, ROLE_CONTROL_ERROR_FIELDS) } : {}),
183
+ ...(Object.hasOwn(row, "reason") ? { reason: choice(row.reason, ROLE_CONTROL_DISABLED_REASONS) } : {}) };
184
+ }
185
+ export const parseRoleControlErrorInfo = (value) => errorInfo(json(value));
186
+ export const parseChildSessionSnapshot = (value) => snapshot(json(value));
187
+ export const parseRoleControlDescendants = (value) => descendants(json(value));
188
+ export const parseRoleControlBackgroundRequest = (value) => backgroundRequest(json(value));
189
+ export const parseRoleControlPromptRequest = (value) => promptRequest(json(value));
190
+ export const parseRoleControlInterruptRequest = (value) => interruptRequest(json(value));
191
+ export const parseRoleControlCapabilities = (value) => capabilities(json(value));
192
+ export const parseRoleControlSessionId = (value) => identity(value);
193
+ function codec(symbol, parse) {
194
+ return { mode: "strict", typeSymbol: `@dsmm/dsmm#${symbol}`, create: () => ({ parse: value => parse(json(value)) }) };
195
+ }
196
+ function descriptor(method, result, request) {
197
+ return { id: `@dsmm/dsmm-children#dsmmChildren/${method}`, service: "dsmmChildren", namespace: "dsmmChildren", method, invocation: { kind: "direct" },
198
+ parameters: [{ name: "sessionId", wire: "sessionId", source: "json", codec: codec("ChildControlSessionId", identity) },
199
+ ...(request === undefined ? [] : [{ name: "request", wire: "request", source: "json", codec: request }])], result };
200
+ }
201
+ /** Separate package identity prevents replacing the Profiles contribution. */
202
+ export const ROLE_CONTROL_REMOTE = { package: "@dsmm/dsmm-children", descriptors: [
203
+ descriptor("describe", codec("ChildSessionSnapshot", snapshot)),
204
+ descriptor("descendants", codec("RoleControlDescendantsSnapshot", descendants)),
205
+ descriptor("background", codec("BackgroundTransitionResult", transition), codec("RoleControlBackgroundRequest", backgroundRequest)),
206
+ descriptor("prompt", codec("SubagentPromptReceipt", promptReceipt), codec("SubagentPromptRequest", promptRequest)),
207
+ descriptor("interrupt", codec("SubagentInterruptReceipt", interruptReceipt), codec("RoleControlInterruptRequest", interruptRequest)),
208
+ ] };
209
+ export const ROLE_CONTROL_HOST = { package: ROLE_CONTROL_REMOTE.package, face: "host", schemas: [], model: { services: [], events: [], objects: [] }, invocations: ROLE_CONTROL_REMOTE.descriptors };
210
+ export default ROLE_CONTROL_REMOTE;
211
+ //# sourceMappingURL=role-control-remote.js.map
@@ -0,0 +1,51 @@
1
+ import type { Context } from "@deepseek-ai/cordis";
2
+ import type { SubagentCatalogEntry } from "@deepseek-ai/dsh-subagent";
3
+ import { TypertRemoteService } from "@deepseek-ai/dsh-typert-protocol";
4
+ import type { DeliveryAdmission, ParentAdmissionTicket } from "./delivery-authority.js";
5
+ import type { DsmmSubagentRuntime } from "./subagent-runtime.js";
6
+ import type { RoleRunInvocation, RoleRunRegistry } from "./role-runs.js";
7
+ import type { BackgroundTransitionResult, ChildAdmissionEvidenceView, ChildSessionSnapshot, DsmmInvocationView, DsmmRoleRouteComparison, RoleControlAvailability, RoleControlBackgroundRequest, RoleControlCapabilities, RoleControlDescendantsSnapshot, RoleControlInterruptRequest, SubagentInterruptReceipt, SubagentPromptReceipt, SubagentPromptRequest } from "./role-control-types.js";
8
+ export interface RoleControlChildObservation {
9
+ readonly invocation?: DsmmInvocationView;
10
+ readonly routeComparison?: DsmmRoleRouteComparison;
11
+ readonly evidence?: ChildAdmissionEvidenceView;
12
+ readonly prompt: RoleControlAvailability;
13
+ readonly interrupt: RoleControlAvailability;
14
+ }
15
+ /** Trusted Host adapters borrow captured B/C2b state, never wire claims or new settings. */
16
+ export interface RoleControlCollaborators<A extends DeliveryAdmission, E, C, P> {
17
+ readonly runtime: DsmmSubagentRuntime<A, E>;
18
+ readonly runs: RoleRunRegistry<C, P>;
19
+ capabilities(ticket: ParentAdmissionTicket<A>): RoleControlCapabilities;
20
+ projectRun(invocation: RoleRunInvocation<C, P>): DsmmInvocationView;
21
+ backgroundAvailability(ticket: ParentAdmissionTicket<A>, invocation: RoleRunInvocation<C, P>, signal: AbortSignal): Promise<RoleControlAvailability>;
22
+ /** Read-only evidence fold; must not resume/materialize a child. */
23
+ observeChild(ticket: ParentAdmissionTicket<A>, child: SubagentCatalogEntry, signal: AbortSignal): Promise<RoleControlChildObservation>;
24
+ }
25
+ /** Separate namespace: native inbox/jobs remain the sole execution owners. */
26
+ export declare class DsmmChildrenHost<A extends DeliveryAdmission, E, C, P> extends TypertRemoteService {
27
+ private readonly lifetime;
28
+ private readonly backgroundJobs;
29
+ private readonly collaborators;
30
+ constructor(ctx: Context, collaborators: RoleControlCollaborators<A, E, C, P>);
31
+ private invoke;
32
+ private decode;
33
+ private scoped;
34
+ private capabilities;
35
+ private childView;
36
+ private runView;
37
+ describe(sessionId: string): Promise<ChildSessionSnapshot>;
38
+ descendants(sessionId: string): Promise<RoleControlDescendantsSnapshot>;
39
+ background(sessionId: string, input: RoleControlBackgroundRequest): Promise<BackgroundTransitionResult>;
40
+ private directChild;
41
+ prompt(sessionId: string, input: SubagentPromptRequest): Promise<SubagentPromptReceipt>;
42
+ interrupt(sessionId: string, input: RoleControlInterruptRequest): Promise<SubagentInterruptReceipt>;
43
+ }
44
+ declare module "@deepseek-ai/cordis" {
45
+ interface Context {
46
+ dsmmChildren: DsmmChildrenHost<DeliveryAdmission, unknown, unknown, unknown>;
47
+ }
48
+ }
49
+ /** Caller supplies an owned Host injection fiber; no replacement or auto-mount. */
50
+ export declare function registerRoleControlRpc<A extends DeliveryAdmission, E, C, P>(ctx: Context, collaborators: RoleControlCollaborators<A, E, C, P>): DsmmChildrenHost<A, E, C, P>;
51
+ //# sourceMappingURL=role-control-rpc.d.ts.map