@dsmm/dsmm 0.1.9 → 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 (553) hide show
  1. package/README.md +46 -58
  2. package/agent-presets/dsmm-builder/agent.cordis.yml +91 -186
  3. package/agent-presets/dsmm-builder/preset.yml +1 -1
  4. package/agent-presets/dsmm-clarifier/agent.cordis.yml +120 -17
  5. package/agent-presets/dsmm-clarifier/preset.yml +1 -1
  6. package/agent-presets/dsmm-code-search/agent.cordis.yml +72 -17
  7. package/agent-presets/dsmm-code-search/preset.yml +1 -1
  8. package/agent-presets/dsmm-coding/agent.cordis.yml +169 -0
  9. package/agent-presets/dsmm-coding/preset.yml +3 -0
  10. package/agent-presets/dsmm-complex/agent.cordis.yml +154 -0
  11. package/agent-presets/dsmm-complex/preset.yml +3 -0
  12. package/agent-presets/dsmm-creative/agent.cordis.yml +122 -15
  13. package/agent-presets/dsmm-creative/preset.yml +1 -1
  14. package/agent-presets/dsmm-cross-cutting/agent.cordis.yml +179 -0
  15. package/agent-presets/dsmm-cross-cutting/preset.yml +3 -0
  16. package/agent-presets/dsmm-deep/agent.cordis.yml +189 -0
  17. package/agent-presets/dsmm-deep/preset.yml +3 -0
  18. package/agent-presets/dsmm-doc-search/agent.cordis.yml +72 -17
  19. package/agent-presets/dsmm-doc-search/preset.yml +1 -1
  20. package/agent-presets/dsmm-documenting/agent.cordis.yml +168 -0
  21. package/agent-presets/dsmm-documenting/preset.yml +3 -0
  22. package/agent-presets/dsmm-frontend/agent.cordis.yml +161 -0
  23. package/agent-presets/dsmm-frontend/preset.yml +3 -0
  24. package/agent-presets/dsmm-hard-reasoning/agent.cordis.yml +153 -0
  25. package/agent-presets/dsmm-hard-reasoning/preset.yml +3 -0
  26. package/agent-presets/dsmm-media-reader/agent.cordis.yml +72 -17
  27. package/agent-presets/dsmm-media-reader/preset.yml +1 -1
  28. package/agent-presets/dsmm-normal-task/agent.cordis.yml +127 -0
  29. package/agent-presets/dsmm-normal-task/preset.yml +3 -0
  30. package/agent-presets/dsmm-oracle/agent.cordis.yml +109 -15
  31. package/agent-presets/dsmm-oracle/preset.yml +1 -1
  32. package/agent-presets/dsmm-oracle-2nd/agent.cordis.yml +109 -15
  33. package/agent-presets/dsmm-oracle-2nd/preset.yml +1 -1
  34. package/agent-presets/dsmm-orchestrator/agent.cordis.yml +174 -190
  35. package/agent-presets/dsmm-orchestrator/preset.yml +1 -1
  36. package/agent-presets/dsmm-plan-critic/agent.cordis.yml +102 -16
  37. package/agent-presets/dsmm-plan-critic/preset.yml +1 -1
  38. package/agent-presets/dsmm-planner/agent.cordis.yml +134 -15
  39. package/agent-presets/dsmm-planner/preset.yml +1 -1
  40. package/agent-presets/dsmm-quick/agent.cordis.yml +132 -0
  41. package/agent-presets/dsmm-quick/preset.yml +3 -0
  42. package/agent-presets/dsmm-research/agent.cordis.yml +156 -0
  43. package/agent-presets/dsmm-research/preset.yml +3 -0
  44. package/agent-presets/dsmm-reviewer/agent.cordis.yml +108 -16
  45. package/agent-presets/dsmm-reviewer/preset.yml +1 -1
  46. package/cordis.patch.yml +1 -5
  47. package/docs/agent-presets.md +48 -15
  48. package/docs/compatibility.md +58 -68
  49. package/docs/deferred-native-approval-risk.md +19 -0
  50. package/docs/design.md +43 -2
  51. package/docs/lsp.md +12 -12
  52. package/docs/migration-from-ocmm.md +10 -2
  53. package/docs/model-routing.md +84 -59
  54. package/docs/native-permissions.md +35 -0
  55. package/docs/profiles.md +43 -64
  56. package/docs/releasing.md +159 -8
  57. package/docs/roadmap.md +77 -17
  58. package/docs/runtime-recovery.md +12 -0
  59. package/docs/safety-guards.md +7 -3
  60. package/docs/settings-status.md +46 -40
  61. package/docs/skill-sync.md +89 -14
  62. package/lib/child-admission-contract.d.ts +37 -0
  63. package/lib/child-admission-contract.js +2 -0
  64. package/lib/child-admission.d.ts +42 -0
  65. package/lib/child-admission.js +162 -0
  66. package/lib/child-capture.d.ts +81 -0
  67. package/lib/child-capture.js +203 -0
  68. package/lib/child-evidence.d.ts +17 -0
  69. package/lib/child-evidence.js +43 -0
  70. package/lib/client/ChildrenPanel.d.ts +43 -0
  71. package/lib/client/ChildrenPanel.js +82 -0
  72. package/lib/client/DeploymentPage.d.ts +18 -0
  73. package/lib/client/DeploymentPage.js +127 -0
  74. package/lib/client/EditableChoice.d.ts +17 -0
  75. package/lib/client/EditableChoice.js +49 -0
  76. package/lib/client/PermissionsPanel.d.ts +14 -0
  77. package/lib/client/PermissionsPanel.js +46 -0
  78. package/lib/client/ProfilesSection.js +32 -15
  79. package/lib/client/RoleAvailability.d.ts +7 -0
  80. package/lib/client/RoleAvailability.js +19 -0
  81. package/lib/client/SessionProfiles.js +27 -9
  82. package/lib/client/StructuredEditor.js +15 -7
  83. package/lib/client/children-controller.d.ts +98 -0
  84. package/lib/client/children-controller.js +296 -0
  85. package/lib/client/children-locales.d.ts +367 -0
  86. package/lib/client/children-locales.js +69 -0
  87. package/lib/client/controller.d.ts +6 -1
  88. package/lib/client/controller.js +14 -8
  89. package/lib/client/deployment-controller.d.ts +50 -0
  90. package/lib/client/deployment-controller.js +193 -0
  91. package/lib/client/deployment-data.d.ts +17 -0
  92. package/lib/client/deployment-data.js +138 -0
  93. package/lib/client/deployment-locales.d.ts +70 -0
  94. package/lib/client/deployment-locales.js +81 -0
  95. package/lib/client/diagnostics.d.ts +14 -0
  96. package/lib/client/diagnostics.js +53 -0
  97. package/lib/client/index.d.ts +4 -0
  98. package/lib/client/index.js +145 -1
  99. package/lib/client/locales.d.ts +58 -0
  100. package/lib/client/locales.js +38 -18
  101. package/lib/client/permission-client.d.ts +16 -0
  102. package/lib/client/permission-client.js +38 -0
  103. package/lib/client/permission-controller.d.ts +62 -0
  104. package/lib/client/permission-controller.js +149 -0
  105. package/lib/client/permission-locales.d.ts +114 -0
  106. package/lib/client/permission-locales.js +75 -0
  107. package/lib/client/plugins-contract.d.ts +27 -0
  108. package/lib/client/plugins-contract.js +2 -0
  109. package/lib/client/session-labels.js +4 -4
  110. package/lib/client/structured.js +19 -5
  111. package/lib/client/styles.d.ts +1 -1
  112. package/lib/client/styles.js +36 -0
  113. package/lib/client.js +6724 -1604
  114. package/lib/commands.js +3 -0
  115. package/lib/config-file-store.d.ts +23 -0
  116. package/lib/config-file-store.js +67 -0
  117. package/lib/core-permission-authority.d.ts +18 -0
  118. package/lib/core-permission-authority.js +255 -0
  119. package/lib/core-permissions.d.ts +8 -0
  120. package/lib/core-permissions.js +33 -0
  121. package/lib/delivery-authority.d.ts +68 -0
  122. package/lib/delivery-authority.js +260 -0
  123. package/lib/deployment-config.d.ts +60 -0
  124. package/lib/deployment-config.js +205 -0
  125. package/lib/deployment-permission-rules.d.ts +55 -0
  126. package/lib/deployment-permission-rules.js +306 -0
  127. package/lib/dsh-home.d.ts +3 -0
  128. package/lib/dsh-home.js +10 -0
  129. package/lib/dsh-types.d.ts +22 -69
  130. package/lib/guards.d.ts +3 -2
  131. package/lib/guards.js +44 -6
  132. package/lib/host-llm-startup.d.ts +41 -0
  133. package/lib/host-llm-startup.js +65 -0
  134. package/lib/host-llm.d.ts +92 -0
  135. package/lib/host-llm.js +325 -0
  136. package/lib/index.d.ts +23 -5
  137. package/lib/index.js +383 -40
  138. package/lib/legacy-child-policy.d.ts +51 -0
  139. package/lib/legacy-child-policy.js +123 -0
  140. package/lib/legacy-read-composition.d.ts +20 -0
  141. package/lib/legacy-read-composition.js +144 -0
  142. package/lib/legacy-read-contracts.d.ts +157 -0
  143. package/lib/legacy-read-contracts.js +39 -0
  144. package/lib/legacy-read-host.d.ts +19 -0
  145. package/lib/legacy-read-host.js +67 -0
  146. package/lib/legacy-read-integration.d.ts +121 -0
  147. package/lib/legacy-read-integration.js +522 -0
  148. package/lib/legacy-read-proxy.d.ts +26 -0
  149. package/lib/legacy-read-proxy.js +237 -0
  150. package/lib/live-pi-ai-owner.d.ts +18 -0
  151. package/lib/live-pi-ai-owner.js +144 -0
  152. package/lib/llm-runtime.d.ts +11 -0
  153. package/lib/llm-runtime.js +21 -0
  154. package/lib/lsp.d.ts +13 -0
  155. package/lib/lsp.js +60 -0
  156. package/lib/managed-settings.d.ts +5 -0
  157. package/lib/managed-settings.js +14 -0
  158. package/lib/mode.js +42 -47
  159. package/lib/model-parameter-policy.d.ts +11 -0
  160. package/lib/model-parameter-policy.js +27 -0
  161. package/lib/model-routing.js +33 -19
  162. package/lib/modules.d.ts +35 -0
  163. package/lib/modules.js +37 -0
  164. package/lib/native-child-evidence.d.ts +42 -0
  165. package/lib/native-child-evidence.js +133 -0
  166. package/lib/native-pi-ai-wire.d.ts +37 -0
  167. package/lib/native-pi-ai-wire.js +261 -0
  168. package/lib/native-scope.d.ts +9 -0
  169. package/lib/native-scope.js +20 -0
  170. package/lib/permission-bash.d.ts +6 -0
  171. package/lib/permission-bash.js +7 -0
  172. package/lib/permission-control.d.ts +73 -0
  173. package/lib/permission-control.js +205 -0
  174. package/lib/permission-controller.d.ts +68 -0
  175. package/lib/permission-controller.js +317 -0
  176. package/lib/permission-errors.d.ts +7 -0
  177. package/lib/permission-errors.js +21 -0
  178. package/lib/permission-fs-search.d.ts +5 -0
  179. package/lib/permission-fs-search.js +7 -0
  180. package/lib/permission-fs.d.ts +5 -0
  181. package/lib/permission-fs.js +7 -0
  182. package/lib/permission-native-access.d.ts +11 -0
  183. package/lib/permission-native-access.js +6 -0
  184. package/lib/permission-native-command.d.ts +10 -0
  185. package/lib/permission-native-command.js +93 -0
  186. package/lib/permission-native-rules.d.ts +75 -0
  187. package/lib/permission-native-rules.js +278 -0
  188. package/lib/permission-pwsh.d.ts +6 -0
  189. package/lib/permission-pwsh.js +7 -0
  190. package/lib/permission-remote.d.ts +26 -0
  191. package/lib/permission-remote.js +53 -0
  192. package/lib/permission-rpc.d.ts +29 -0
  193. package/lib/permission-rpc.js +152 -0
  194. package/lib/permission-rules.d.ts +115 -0
  195. package/lib/permission-rules.js +256 -0
  196. package/lib/permission-settings.d.ts +45 -0
  197. package/lib/permission-settings.js +48 -0
  198. package/lib/permission-shell.d.ts +38 -0
  199. package/lib/permission-shell.js +150 -0
  200. package/lib/permission-web.d.ts +5 -0
  201. package/lib/permission-web.js +7 -0
  202. package/lib/plan-validation.js +6 -44
  203. package/lib/preset-materializer.js +2 -0
  204. package/lib/preset-registry.d.ts +1 -1
  205. package/lib/preset-registry.js +38 -24
  206. package/lib/preset-skills.d.ts +4 -1
  207. package/lib/preset-skills.js +60 -19
  208. package/lib/profile-diagnostics.d.ts +45 -0
  209. package/lib/profile-diagnostics.js +148 -0
  210. package/lib/profile-locale.d.ts +3 -0
  211. package/lib/profile-locale.js +2 -0
  212. package/lib/profile-remote.d.ts +22 -0
  213. package/lib/profile-remote.js +344 -27
  214. package/lib/profile-rpc.d.ts +25 -1
  215. package/lib/profile-rpc.js +143 -3
  216. package/lib/profile-runtime.d.ts +63 -0
  217. package/lib/profile-runtime.js +496 -77
  218. package/lib/profile-store.d.ts +56 -1
  219. package/lib/profile-store.js +377 -111
  220. package/lib/profile-types.d.ts +125 -1
  221. package/lib/profile-types.js +1 -0
  222. package/lib/profiles.d.ts +16 -2
  223. package/lib/profiles.js +156 -79
  224. package/lib/prompt-content.d.ts +25 -0
  225. package/lib/prompt-content.js +27 -0
  226. package/lib/prompts.d.ts +45 -4
  227. package/lib/prompts.js +157 -43
  228. package/lib/recovery-policy.js +20 -7
  229. package/lib/role-control-remote.d.ts +38 -0
  230. package/lib/role-control-remote.js +211 -0
  231. package/lib/role-control-rpc.d.ts +51 -0
  232. package/lib/role-control-rpc.js +377 -0
  233. package/lib/role-control-types.d.ts +92 -0
  234. package/lib/role-control-types.js +8 -0
  235. package/lib/role-invocation.d.ts +47 -0
  236. package/lib/role-invocation.js +135 -0
  237. package/lib/role-llm-runtime.d.ts +17 -0
  238. package/lib/role-llm-runtime.js +62 -0
  239. package/lib/role-llm.d.ts +31 -0
  240. package/lib/role-llm.js +66 -0
  241. package/lib/role-policy.d.ts +92 -0
  242. package/lib/role-policy.js +601 -0
  243. package/lib/role-providers.d.ts +7 -3
  244. package/lib/role-providers.js +74 -46
  245. package/lib/role-routing.d.ts +11 -2
  246. package/lib/role-routing.js +42 -25
  247. package/lib/role-runs.d.ts +135 -0
  248. package/lib/role-runs.js +304 -0
  249. package/lib/role-subagents.d.ts +63 -4
  250. package/lib/role-subagents.js +299 -47
  251. package/lib/roles.d.ts +20 -9
  252. package/lib/roles.js +87 -216
  253. package/lib/route-json.d.ts +19 -0
  254. package/lib/route-json.js +129 -0
  255. package/lib/routing-policy.d.ts +2 -0
  256. package/lib/routing-policy.js +12 -2
  257. package/lib/runtime-integration.d.ts +112 -0
  258. package/lib/runtime-integration.js +784 -0
  259. package/lib/runtime-recovery.js +34 -13
  260. package/lib/session-scope.js +2 -0
  261. package/lib/settings.d.ts +116 -14
  262. package/lib/settings.js +455 -149
  263. package/lib/skills.d.ts +24 -9
  264. package/lib/skills.js +114 -35
  265. package/lib/state.d.ts +10 -6
  266. package/lib/state.js +48 -49
  267. package/lib/status.d.ts +35 -1
  268. package/lib/status.js +58 -17
  269. package/lib/subagent-runtime.d.ts +45 -0
  270. package/lib/subagent-runtime.js +131 -0
  271. package/locale/en.json +2 -2
  272. package/locale/zh.json +2 -2
  273. package/package.json +112 -45
  274. package/patches/subagent-runtime.yml +15 -0
  275. package/prompts/deepseek-flash.md +1 -1
  276. package/prompts/deepseek-v4-pro.md +2 -2
  277. package/prompts/deepwork.md +153 -20
  278. package/prompts/source/agents/clarifier.md +47 -0
  279. package/prompts/source/agents/orchestrator.md +72 -0
  280. package/prompts/source/agents/plan-critic.md +29 -0
  281. package/prompts/source/agents/planner.md +21 -0
  282. package/prompts/source/agents/reviewer.md +23 -0
  283. package/prompts/source/catalog.json +548 -0
  284. package/prompts/source/category/coding.md +46 -0
  285. package/prompts/source/category/complex.md +29 -0
  286. package/prompts/source/category/creative.md +40 -0
  287. package/prompts/source/category/cross-cutting.md +54 -0
  288. package/prompts/source/category/deep.md +64 -0
  289. package/prompts/source/category/documenting.md +68 -0
  290. package/prompts/source/category/frontend.md +38 -0
  291. package/prompts/source/category/hard-reasoning.md +53 -0
  292. package/prompts/source/category/normal-task.md +27 -0
  293. package/prompts/source/category/quick.md +34 -0
  294. package/prompts/source/category/research.md +58 -0
  295. package/prompts/source/deepwork/claude-opus-5.md +28 -0
  296. package/prompts/source/deepwork/codex.md +9 -0
  297. package/prompts/source/deepwork/default.md +136 -0
  298. package/prompts/source/deepwork/gemini.md +191 -0
  299. package/prompts/source/deepwork/glm.md +263 -0
  300. package/prompts/source/deepwork/gpt.md +49 -0
  301. package/prompts/source/deepwork/kimi-k27.md +13 -0
  302. package/prompts/source/deepwork/planner.md +44 -0
  303. package/prompts/source/deepwork/swe-2.md +13 -0
  304. package/prompts/source/manifest.json +3233 -0
  305. package/prompts/source/shared/dsh-host-contract.md +8 -0
  306. package/prompts/source/shared/locale.md +8 -0
  307. package/prompts/source/shared/shell-safety.md +7 -0
  308. package/prompts/source/terminal/builder.md +13 -0
  309. package/prompts/source/terminal/clarifier.md +41 -0
  310. package/prompts/source/terminal/code-search.md +39 -0
  311. package/prompts/source/terminal/coding.md +41 -0
  312. package/prompts/source/terminal/complex.md +43 -0
  313. package/prompts/source/terminal/creative.md +41 -0
  314. package/prompts/source/terminal/cross-cutting.md +43 -0
  315. package/prompts/source/terminal/deep.md +43 -0
  316. package/prompts/source/terminal/doc-search.md +39 -0
  317. package/prompts/source/terminal/documenting.md +41 -0
  318. package/prompts/source/terminal/frontend.md +41 -0
  319. package/prompts/source/terminal/hard-reasoning.md +41 -0
  320. package/prompts/source/terminal/media-reader.md +39 -0
  321. package/prompts/source/terminal/normal-task.md +41 -0
  322. package/prompts/source/terminal/oracle-2nd.md +53 -0
  323. package/prompts/source/terminal/oracle.md +53 -0
  324. package/prompts/source/terminal/orchestrator.md +26 -0
  325. package/prompts/source/terminal/plan-critic.md +41 -0
  326. package/prompts/source/terminal/planner.md +42 -0
  327. package/prompts/source/terminal/quick.md +39 -0
  328. package/prompts/source/terminal/research.md +39 -0
  329. package/prompts/source/terminal/reviewer.md +53 -0
  330. package/scripts/cold-profile-composition.mjs +329 -0
  331. package/scripts/cold-profile-sources.mjs +238 -0
  332. package/scripts/migrate-cold-profile.mjs +315 -0
  333. package/skills/ast-grep/LICENSE +21 -0
  334. package/skills/ast-grep/README.md +138 -0
  335. package/skills/ast-grep/SKILL.md +287 -0
  336. package/skills/ast-grep/SOURCE +1 -0
  337. package/skills/ast-grep/install.ps1 +235 -0
  338. package/skills/ast-grep/install.sh +286 -0
  339. package/skills/ast-grep/references/cli.md +233 -0
  340. package/skills/ast-grep/references/install.md +168 -0
  341. package/skills/ast-grep/references/patterns.md +149 -0
  342. package/skills/ast-grep/references/pitfalls.md +305 -0
  343. package/skills/ast-grep/references/recipes.md +404 -0
  344. package/skills/ast-grep/references/sgconfig.md +250 -0
  345. package/skills/ast-grep/references/yaml-rules.md +511 -0
  346. package/skills/ast-grep/scripts/ast_grep_helper.py +760 -0
  347. package/skills/ast-grep/tests/smoke.ps1 +129 -0
  348. package/skills/ast-grep/tests/smoke.sh +212 -0
  349. package/skills/ast-grep/tests/test_resolver.py +154 -0
  350. package/skills/brainstorming/SKILL.md +123 -9
  351. package/skills/coding-agent-sessions/LICENSE-UPSTREAM.md +82 -0
  352. package/skills/coding-agent-sessions/NOTICE.md +24 -0
  353. package/skills/coding-agent-sessions/SKILL.md +147 -0
  354. package/skills/coding-agent-sessions/agents/openai.yaml +4 -0
  355. package/skills/coding-agent-sessions/pyrightconfig.json +5 -0
  356. package/skills/coding-agent-sessions/references/all-platforms.md +77 -0
  357. package/skills/coding-agent-sessions/references/claude.md +34 -0
  358. package/skills/coding-agent-sessions/references/codex.md +32 -0
  359. package/skills/coding-agent-sessions/references/opencode.md +45 -0
  360. package/skills/coding-agent-sessions/references/senpi.md +29 -0
  361. package/skills/coding-agent-sessions/scripts/agent_sessions/__init__.py +1 -0
  362. package/skills/coding-agent-sessions/scripts/agent_sessions/aside_scanner.py +140 -0
  363. package/skills/coding-agent-sessions/scripts/agent_sessions/claude.py +66 -0
  364. package/skills/coding-agent-sessions/scripts/agent_sessions/cli.py +283 -0
  365. package/skills/coding-agent-sessions/scripts/agent_sessions/codex.py +105 -0
  366. package/skills/coding-agent-sessions/scripts/agent_sessions/file_scanners.py +275 -0
  367. package/skills/coding-agent-sessions/scripts/agent_sessions/jsonio.py +55 -0
  368. package/skills/coding-agent-sessions/scripts/agent_sessions/kiro_scanner.py +91 -0
  369. package/skills/coding-agent-sessions/scripts/agent_sessions/opencode.py +289 -0
  370. package/skills/coding-agent-sessions/scripts/agent_sessions/pi_family.py +46 -0
  371. package/skills/coding-agent-sessions/scripts/agent_sessions/scanners.py +104 -0
  372. package/skills/coding-agent-sessions/scripts/agent_sessions/sqlite_optional_scanners.py +203 -0
  373. package/skills/coding-agent-sessions/scripts/agent_sessions/sqlite_scanners.py +177 -0
  374. package/skills/coding-agent-sessions/scripts/agent_sessions/timeparse.py +51 -0
  375. package/skills/coding-agent-sessions/scripts/agent_sessions/transcript.py +149 -0
  376. package/skills/coding-agent-sessions/scripts/agent_sessions/types.py +57 -0
  377. package/skills/coding-agent-sessions/scripts/find-agent-sessions.py +19 -0
  378. package/skills/coding-agent-sessions/scripts/tests/test_agent_sessions.py +322 -0
  379. package/skills/coding-agent-sessions/scripts/tests/test_aside_scanner.py +131 -0
  380. package/skills/coding-agent-sessions/scripts/tests/test_cli_contract.py +126 -0
  381. package/skills/coding-agent-sessions/scripts/tests/test_extended_scanners.py +262 -0
  382. package/skills/coding-agent-sessions/scripts/tests/test_optional_sqlite_scanners.py +79 -0
  383. package/skills/coding-agent-sessions/scripts/tests/test_pi_family_scanners.py +130 -0
  384. package/skills/debugging/SKILL.md +130 -4
  385. package/skills/debugging/references/logging.md +2 -0
  386. package/skills/debugging/references/methodology/00-setup.md +16 -62
  387. package/skills/debugging/references/methodology/02-investigate.md +11 -5
  388. package/skills/debugging/references/methodology/03-flaky-triage.md +6 -4
  389. package/skills/debugging/references/methodology/04-hard-reasoning-escalation.md +6 -16
  390. package/skills/debugging/references/methodology/05-escalate.md +2 -0
  391. package/skills/debugging/references/methodology/06-fix.md +8 -6
  392. package/skills/debugging/references/methodology/08-qa.md +7 -5
  393. package/skills/debugging/references/methodology/09-cleanup.md +16 -152
  394. package/skills/debugging/references/methodology/partial-runtime-evidence.md +7 -18
  395. package/skills/debugging/references/runtimes/bundled-js-binary.md +3 -16
  396. package/skills/debugging/references/runtimes/go.md +2 -0
  397. package/skills/debugging/references/runtimes/native-binary.md +11 -54
  398. package/skills/debugging/references/runtimes/node.md +6 -15
  399. package/skills/debugging/references/runtimes/python.md +5 -15
  400. package/skills/debugging/references/runtimes/rust.md +4 -18
  401. package/skills/debugging/references/scripts/dap.test.mjs +539 -0
  402. package/skills/debugging/references/scripts/fixture-adapter.mjs +164 -0
  403. package/skills/debugging/references/tools/dap.md +4 -2
  404. package/skills/debugging/references/tools/ghidra.md +6 -15
  405. package/skills/debugging/references/tools/playwright-cli.md +5 -15
  406. package/skills/debugging/references/tools/pwndbg.md +2 -0
  407. package/skills/debugging/references/tools/pwntools.md +6 -16
  408. package/skills/dispatching-parallel-agents/SKILL.md +96 -7
  409. package/skills/frontend/.frontend-materialized.json +856 -0
  410. package/skills/frontend/ATTRIBUTION.md +37 -0
  411. package/skills/frontend/LICENSE-Apache-2.0.txt +201 -0
  412. package/skills/frontend/LICENSE-taste-skill.txt +21 -0
  413. package/skills/frontend/LICENSE-ui-ux-pro-max.txt +21 -0
  414. package/skills/frontend/SKILL.md +145 -0
  415. package/skills/frontend/references/design/README.md +256 -0
  416. package/skills/frontend/references/design/_INDEX.md +206 -0
  417. package/skills/frontend/references/design/airbnb.md +393 -0
  418. package/skills/frontend/references/design/airtable.md +92 -0
  419. package/skills/frontend/references/design/apple.md +250 -0
  420. package/skills/frontend/references/design/aside.md +211 -0
  421. package/skills/frontend/references/design/binance.md +348 -0
  422. package/skills/frontend/references/design/bmw.md +183 -0
  423. package/skills/frontend/references/design/brutalist-skill.md +92 -0
  424. package/skills/frontend/references/design/bugatti.md +271 -0
  425. package/skills/frontend/references/design/cal.md +262 -0
  426. package/skills/frontend/references/design/claude.md +315 -0
  427. package/skills/frontend/references/design/clay.md +307 -0
  428. package/skills/frontend/references/design/clickhouse.md +284 -0
  429. package/skills/frontend/references/design/clone-from-url.md +69 -0
  430. package/skills/frontend/references/design/cohere.md +269 -0
  431. package/skills/frontend/references/design/coinbase.md +132 -0
  432. package/skills/frontend/references/design/composio.md +310 -0
  433. package/skills/frontend/references/design/cursor.md +312 -0
  434. package/skills/frontend/references/design/design-system-architecture.md +250 -0
  435. package/skills/frontend/references/design/elevenlabs.md +268 -0
  436. package/skills/frontend/references/design/expo.md +284 -0
  437. package/skills/frontend/references/design/ferrari.md +317 -0
  438. package/skills/frontend/references/design/figma.md +223 -0
  439. package/skills/frontend/references/design/framer.md +249 -0
  440. package/skills/frontend/references/design/gpt-tasteskill.md +74 -0
  441. package/skills/frontend/references/design/hashicorp.md +281 -0
  442. package/skills/frontend/references/design/ibm.md +335 -0
  443. package/skills/frontend/references/design/image-to-code-skill.md +1228 -0
  444. package/skills/frontend/references/design/imagegen-brandkit.md +798 -0
  445. package/skills/frontend/references/design/imagegen-frontend-mobile.md +1465 -0
  446. package/skills/frontend/references/design/imagegen-frontend-web.md +987 -0
  447. package/skills/frontend/references/design/interaction-skill.md +52 -0
  448. package/skills/frontend/references/design/intercom.md +149 -0
  449. package/skills/frontend/references/design/kraken.md +128 -0
  450. package/skills/frontend/references/design/lamborghini.md +291 -0
  451. package/skills/frontend/references/design/linear.app.md +370 -0
  452. package/skills/frontend/references/design/lovable.md +301 -0
  453. package/skills/frontend/references/design/mastercard.md +368 -0
  454. package/skills/frontend/references/design/meta.md +369 -0
  455. package/skills/frontend/references/design/minimalist-skill.md +85 -0
  456. package/skills/frontend/references/design/minimax.md +260 -0
  457. package/skills/frontend/references/design/mintlify.md +329 -0
  458. package/skills/frontend/references/design/miro.md +111 -0
  459. package/skills/frontend/references/design/mistral.ai.md +264 -0
  460. package/skills/frontend/references/design/mongodb.md +269 -0
  461. package/skills/frontend/references/design/nike.md +366 -0
  462. package/skills/frontend/references/design/notion.md +312 -0
  463. package/skills/frontend/references/design/nvidia.md +296 -0
  464. package/skills/frontend/references/design/ollama.md +270 -0
  465. package/skills/frontend/references/design/opencode.ai.md +284 -0
  466. package/skills/frontend/references/design/output-skill.md +49 -0
  467. package/skills/frontend/references/design/pinterest.md +233 -0
  468. package/skills/frontend/references/design/playstation.md +367 -0
  469. package/skills/frontend/references/design/posthog.md +259 -0
  470. package/skills/frontend/references/design/raycast.md +271 -0
  471. package/skills/frontend/references/design/react-dev-tooling-skill.md +232 -0
  472. package/skills/frontend/references/design/redesign-skill.md +178 -0
  473. package/skills/frontend/references/design/renault.md +314 -0
  474. package/skills/frontend/references/design/replicate.md +264 -0
  475. package/skills/frontend/references/design/resend.md +306 -0
  476. package/skills/frontend/references/design/revolut.md +188 -0
  477. package/skills/frontend/references/design/runwayml.md +247 -0
  478. package/skills/frontend/references/design/sanity.md +360 -0
  479. package/skills/frontend/references/design/sentry.md +265 -0
  480. package/skills/frontend/references/design/shopify.md +353 -0
  481. package/skills/frontend/references/design/soft-skill.md +98 -0
  482. package/skills/frontend/references/design/spacex.md +197 -0
  483. package/skills/frontend/references/design/spotify.md +249 -0
  484. package/skills/frontend/references/design/starbucks.md +583 -0
  485. package/skills/frontend/references/design/stitch-design-example.md +121 -0
  486. package/skills/frontend/references/design/stitch-skill.md +184 -0
  487. package/skills/frontend/references/design/stripe.md +325 -0
  488. package/skills/frontend/references/design/supabase.md +258 -0
  489. package/skills/frontend/references/design/superhuman.md +255 -0
  490. package/skills/frontend/references/design/taste-skill.md +1206 -0
  491. package/skills/frontend/references/design/tesla.md +289 -0
  492. package/skills/frontend/references/design/theverge.md +342 -0
  493. package/skills/frontend/references/design/together.ai.md +266 -0
  494. package/skills/frontend/references/design/uber.md +298 -0
  495. package/skills/frontend/references/design/vercel.md +313 -0
  496. package/skills/frontend/references/design/vodafone.md +426 -0
  497. package/skills/frontend/references/design/voltagent.md +326 -0
  498. package/skills/frontend/references/design/warp.md +256 -0
  499. package/skills/frontend/references/design/webflow.md +95 -0
  500. package/skills/frontend/references/design/wired.md +281 -0
  501. package/skills/frontend/references/design/wise.md +176 -0
  502. package/skills/frontend/references/design/x.ai.md +260 -0
  503. package/skills/frontend/references/design/zapier.md +331 -0
  504. package/skills/frontend/references/perfection/README.md +264 -0
  505. package/skills/frontend/references/perfection/react-perf-tooling.md +234 -0
  506. package/skills/frontend/references/ui-ux-db/README.md +659 -0
  507. package/skills/frontend/references/ui-ux-db/data/app-interface.csv +31 -0
  508. package/skills/frontend/references/ui-ux-db/data/charts.csv +26 -0
  509. package/skills/frontend/references/ui-ux-db/data/colors.csv +162 -0
  510. package/skills/frontend/references/ui-ux-db/data/google-fonts.csv +1924 -0
  511. package/skills/frontend/references/ui-ux-db/data/icons.csv +106 -0
  512. package/skills/frontend/references/ui-ux-db/data/landing.csv +35 -0
  513. package/skills/frontend/references/ui-ux-db/data/products.csv +162 -0
  514. package/skills/frontend/references/ui-ux-db/data/react-performance.csv +45 -0
  515. package/skills/frontend/references/ui-ux-db/data/stacks/angular.csv +51 -0
  516. package/skills/frontend/references/ui-ux-db/data/stacks/astro.csv +54 -0
  517. package/skills/frontend/references/ui-ux-db/data/stacks/flutter.csv +53 -0
  518. package/skills/frontend/references/ui-ux-db/data/stacks/html-tailwind.csv +56 -0
  519. package/skills/frontend/references/ui-ux-db/data/stacks/jetpack-compose.csv +53 -0
  520. package/skills/frontend/references/ui-ux-db/data/stacks/laravel.csv +51 -0
  521. package/skills/frontend/references/ui-ux-db/data/stacks/nextjs.csv +53 -0
  522. package/skills/frontend/references/ui-ux-db/data/stacks/nuxt-ui.csv +51 -0
  523. package/skills/frontend/references/ui-ux-db/data/stacks/nuxtjs.csv +59 -0
  524. package/skills/frontend/references/ui-ux-db/data/stacks/react-native.csv +52 -0
  525. package/skills/frontend/references/ui-ux-db/data/stacks/react.csv +54 -0
  526. package/skills/frontend/references/ui-ux-db/data/stacks/shadcn.csv +61 -0
  527. package/skills/frontend/references/ui-ux-db/data/stacks/svelte.csv +54 -0
  528. package/skills/frontend/references/ui-ux-db/data/stacks/swiftui.csv +51 -0
  529. package/skills/frontend/references/ui-ux-db/data/stacks/threejs.csv +54 -0
  530. package/skills/frontend/references/ui-ux-db/data/stacks/vue.csv +50 -0
  531. package/skills/frontend/references/ui-ux-db/data/styles.csv +85 -0
  532. package/skills/frontend/references/ui-ux-db/data/typography.csv +74 -0
  533. package/skills/frontend/references/ui-ux-db/data/ui-reasoning.csv +162 -0
  534. package/skills/frontend/references/ui-ux-db/data/ux-guidelines.csv +100 -0
  535. package/skills/frontend/references/ui-ux-db/data/web-interface.csv +31 -0
  536. package/skills/frontend/references/ui-ux-db/scripts/core.py +262 -0
  537. package/skills/frontend/references/ui-ux-db/scripts/design_system.py +1148 -0
  538. package/skills/frontend/references/ui-ux-db/scripts/search.py +114 -0
  539. package/skills/frontend/scripts/perfection/lighthouse-audit.py +201 -0
  540. package/skills/git-master/SKILL.md +115 -0
  541. package/skills/git-master/agents/openai.yaml +13 -0
  542. package/skills/init-deep/SKILL.md +282 -0
  543. package/skills/receiving-code-review/SKILL.md +117 -7
  544. package/skills/remove-ai-slops/SKILL.md +160 -8
  545. package/skills/requesting-code-review/SKILL.md +98 -3
  546. package/skills/requesting-code-review/code-reviewer.md +59 -0
  547. package/skills/subagent-driven-development/SKILL.md +179 -6
  548. package/skills/subagent-driven-development/code-quality-reviewer-prompt.md +23 -0
  549. package/skills/subagent-driven-development/implementer-prompt.md +87 -0
  550. package/skills/subagent-driven-development/spec-reviewer-prompt.md +37 -0
  551. package/skills/using-git-worktrees/SKILL.md +144 -0
  552. package/skills/writing-plans/SKILL.md +126 -7
  553. package/skills/writing-plans/plan-document-reviewer-prompt.md +47 -0
@@ -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
@@ -0,0 +1,377 @@
1
+ var __runInitializers = (this && this.__runInitializers) || function (thisArg, initializers, value) {
2
+ var useValue = arguments.length > 2;
3
+ for (var i = 0; i < initializers.length; i++) {
4
+ value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);
5
+ }
6
+ return useValue ? value : void 0;
7
+ };
8
+ var __esDecorate = (this && this.__esDecorate) || function (ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {
9
+ function accept(f) { if (f !== void 0 && typeof f !== "function") throw new TypeError("Function expected"); return f; }
10
+ var kind = contextIn.kind, key = kind === "getter" ? "get" : kind === "setter" ? "set" : "value";
11
+ var target = !descriptorIn && ctor ? contextIn["static"] ? ctor : ctor.prototype : null;
12
+ var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {});
13
+ var _, done = false;
14
+ for (var i = decorators.length - 1; i >= 0; i--) {
15
+ var context = {};
16
+ for (var p in contextIn) context[p] = p === "access" ? {} : contextIn[p];
17
+ for (var p in contextIn.access) context.access[p] = contextIn.access[p];
18
+ context.addInitializer = function (f) { if (done) throw new TypeError("Cannot add initializers after decoration has completed"); extraInitializers.push(accept(f || null)); };
19
+ var result = (0, decorators[i])(kind === "accessor" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context);
20
+ if (kind === "accessor") {
21
+ if (result === void 0) continue;
22
+ if (result === null || typeof result !== "object") throw new TypeError("Object expected");
23
+ if (_ = accept(result.get)) descriptor.get = _;
24
+ if (_ = accept(result.set)) descriptor.set = _;
25
+ if (_ = accept(result.init)) initializers.unshift(_);
26
+ }
27
+ else if (_ = accept(result)) {
28
+ if (kind === "field") initializers.unshift(_);
29
+ else descriptor[key] = _;
30
+ }
31
+ }
32
+ if (target) Object.defineProperty(target, contextIn.name, descriptor);
33
+ done = true;
34
+ };
35
+ import { symbols } from "@deepseek-ai/cordis";
36
+ import { SessionId } from "@deepseek-ai/dsh-session";
37
+ import { SubagentError } from "@deepseek-ai/dsh-subagent";
38
+ import { Remote, RemoteError, TypertRemoteService, remoteErrorOf } from "@deepseek-ai/dsh-typert-protocol";
39
+ import { scopeLifetime } from "./delivery-authority.js";
40
+ import { ROLE_CONTROL_HOST, parseChildSessionSnapshot, parseRoleControlBackgroundRequest, parseRoleControlCapabilities, parseRoleControlDescendants, parseRoleControlErrorInfo, parseRoleControlInterruptRequest, parseRoleControlPromptRequest, parseRoleControlSessionId } from "./role-control-remote.js";
41
+ import { parseDsmmInvocationView, parseDsmmRoleRouteComparison } from "./profile-remote.js";
42
+ class ControlRefusal extends Error {
43
+ info;
44
+ constructor(code, field, reason) {
45
+ super("The Host refused the child control operation.");
46
+ this.info = { code, ...(field === undefined ? {} : { field }), ...(reason === undefined ? {} : { reason }) };
47
+ }
48
+ }
49
+ const disabled = (reason) => ({ enabled: false, reason });
50
+ function requireEnabled(value) { if (!value.enabled)
51
+ throw new ControlRefusal("disabled", undefined, value.reason); }
52
+ function original(value) { return Reflect.get(value, symbols.original) ?? value; }
53
+ function terminalTransition(state, runId) {
54
+ return state === "settled" ? { status: "already-settled", runId } : state === "cancelled" ? { status: "cancelled", runId } : undefined;
55
+ }
56
+ function boundedChildLabel(label) {
57
+ const high = label.charCodeAt(119), low = label.charCodeAt(120);
58
+ // Preserve the UTF-16 wire bound without splitting a valid native code point.
59
+ const end = high >= 0xd800 && high <= 0xdbff && low >= 0xdc00 && low <= 0xdfff ? 119 : 120;
60
+ return label.slice(0, end).replace(/[\u0000-\u001f\u007f]/gu, " ");
61
+ }
62
+ /** Separate namespace: native inbox/jobs remain the sole execution owners. */
63
+ let DsmmChildrenHost = (() => {
64
+ let _classSuper = TypertRemoteService;
65
+ let _instanceExtraInitializers = [];
66
+ let _describe_decorators;
67
+ let _descendants_decorators;
68
+ let _background_decorators;
69
+ let _prompt_decorators;
70
+ let _interrupt_decorators;
71
+ return class DsmmChildrenHost extends _classSuper {
72
+ static {
73
+ const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
74
+ _describe_decorators = [Remote];
75
+ _descendants_decorators = [Remote];
76
+ _background_decorators = [Remote];
77
+ _prompt_decorators = [Remote];
78
+ _interrupt_decorators = [Remote];
79
+ __esDecorate(this, null, _describe_decorators, { kind: "method", name: "describe", static: false, private: false, access: { has: obj => "describe" in obj, get: obj => obj.describe }, metadata: _metadata }, null, _instanceExtraInitializers);
80
+ __esDecorate(this, null, _descendants_decorators, { kind: "method", name: "descendants", static: false, private: false, access: { has: obj => "descendants" in obj, get: obj => obj.descendants }, metadata: _metadata }, null, _instanceExtraInitializers);
81
+ __esDecorate(this, null, _background_decorators, { kind: "method", name: "background", static: false, private: false, access: { has: obj => "background" in obj, get: obj => obj.background }, metadata: _metadata }, null, _instanceExtraInitializers);
82
+ __esDecorate(this, null, _prompt_decorators, { kind: "method", name: "prompt", static: false, private: false, access: { has: obj => "prompt" in obj, get: obj => obj.prompt }, metadata: _metadata }, null, _instanceExtraInitializers);
83
+ __esDecorate(this, null, _interrupt_decorators, { kind: "method", name: "interrupt", static: false, private: false, access: { has: obj => "interrupt" in obj, get: obj => obj.interrupt }, metadata: _metadata }, null, _instanceExtraInitializers);
84
+ if (_metadata) Object.defineProperty(this, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
85
+ }
86
+ lifetime = (__runInitializers(this, _instanceExtraInitializers), new AbortController());
87
+ backgroundJobs = new WeakMap();
88
+ collaborators;
89
+ constructor(ctx, collaborators) {
90
+ super(ctx, "dsmmChildren");
91
+ this.collaborators = collaborators;
92
+ scopeLifetime(ctx, "dsmm.children: close scoped controls", () => this.lifetime.abort());
93
+ }
94
+ async invoke(operation) {
95
+ try {
96
+ return await operation();
97
+ }
98
+ catch (error) {
99
+ let info;
100
+ if (error instanceof ControlRefusal)
101
+ info = error.info;
102
+ else {
103
+ const code = String(remoteErrorOf(error)?.code ?? (error instanceof SubagentError ? error.code : ""));
104
+ if (["gateway/cancelled", "ABORTED"].includes(code) || error instanceof Error && error.name === "AbortError")
105
+ info = { code: "cancelled" };
106
+ else if (["subagent/unauthorized", "UNAUTHORIZED"].includes(code))
107
+ info = { code: "not-owned" };
108
+ else if (["subagent/not-resumable", "NOT_RESUMABLE"].includes(code))
109
+ info = { code: "not-resumable", field: "childSessionId" };
110
+ else if (code === "subagent/attachment-invalid" || code === "gateway/bad-request")
111
+ info = { code: "invalid-content", field: "content" };
112
+ else if (code === "subagent/invalid-time-zone")
113
+ info = { code: "invalid-time-zone", field: "clientTimeZone" };
114
+ else
115
+ info = { code: "unavailable" };
116
+ }
117
+ // Do not forward SDK messages, details, causes, paths, content or secrets.
118
+ throw new RemoteError("dsmm-children/refused", "The Host refused the child control operation.", parseRoleControlErrorInfo(info));
119
+ }
120
+ }
121
+ decode(parse, value) {
122
+ try {
123
+ return parse(value);
124
+ }
125
+ catch {
126
+ throw new ControlRefusal("validation", "request");
127
+ }
128
+ }
129
+ async scoped(sessionId, readOnly, operation) {
130
+ const invocation = this.ctx.invocation;
131
+ const connection = this.ctx.get("connection");
132
+ if (invocation?.peer === undefined || connection === undefined || connection.operator !== invocation.peer)
133
+ throw new ControlRefusal("not-owned");
134
+ const connectionOwner = original(connection);
135
+ const runtime = this.collaborators.runtime;
136
+ if (!runtime.authority.view().deliveryFenceReady)
137
+ throw new ControlRefusal("unavailable", undefined, "delivery-fence-unavailable");
138
+ const browserSignal = runtime.authority.acquireBrowserSignal(this.ctx);
139
+ const initialSignal = AbortSignal.any([invocation.signal, browserSignal, this.lifetime.signal]);
140
+ const checkConnection = () => {
141
+ if (initialSignal.aborted)
142
+ throw new ControlRefusal("cancelled");
143
+ const current = this.ctx.get("connection");
144
+ if (current === undefined || original(current) !== connectionOwner || current.operator !== invocation.peer)
145
+ throw new ControlRefusal("not-owned");
146
+ const bound = this.ctx.get("subagents");
147
+ if (bound === undefined || original(bound) !== original(runtime))
148
+ throw new ControlRefusal("unavailable", undefined, "delivery-fence-unavailable");
149
+ };
150
+ checkConnection();
151
+ const agents = this.ctx.get("agents");
152
+ if (agents === undefined)
153
+ throw new ControlRefusal("unavailable");
154
+ let parent = agents.get(SessionId(sessionId));
155
+ if (parent === undefined) {
156
+ // Actions never wake an ordinary parent. Only an authenticated, decoded
157
+ // read may use the public controller; Gateway parameter lookup cannot.
158
+ if (!readOnly)
159
+ throw new ControlRefusal("unavailable", "sessionId");
160
+ const controller = this.ctx.get("sessionController");
161
+ if (controller === undefined)
162
+ throw new ControlRefusal("unavailable", "sessionId");
163
+ const found = await controller.resolveAgent(SessionId(sessionId));
164
+ checkConnection();
165
+ if ("error" in found)
166
+ throw new ControlRefusal("unavailable", "sessionId");
167
+ parent = found.agent;
168
+ }
169
+ const exactParent = parent;
170
+ const checkRoot = () => {
171
+ checkConnection();
172
+ const current = this.ctx.get("agents");
173
+ if (current === undefined || current.get(SessionId(sessionId)) !== exactParent || exactParent.id !== sessionId || exactParent.session.id !== sessionId
174
+ || exactParent.session.header.origin === "subagent" || !current.roots().includes(exactParent)
175
+ || current.list().some(owner => owner !== exactParent && current.isOwnedBy(SessionId(sessionId), owner)))
176
+ throw new ControlRefusal("not-owned", "sessionId");
177
+ };
178
+ checkRoot();
179
+ const ticket = runtime.authority.acquireParentTicket(exactParent);
180
+ const signal = AbortSignal.any([initialSignal, ticket.signal]);
181
+ const scope = { parent: exactParent, ticket, signal, check() {
182
+ if (signal.aborted)
183
+ throw new ControlRefusal("cancelled");
184
+ checkRoot();
185
+ runtime.authority.assertTicket(ticket);
186
+ } };
187
+ scope.check();
188
+ let result;
189
+ try {
190
+ result = await operation(scope);
191
+ }
192
+ catch (error) {
193
+ if (signal.aborted)
194
+ throw new ControlRefusal("cancelled");
195
+ throw error;
196
+ }
197
+ // Native acceptance/handoff owns the write cutoff. Never turn a committed
198
+ // receipt into a failure, rollback accepted work or automatically retry.
199
+ if (readOnly)
200
+ scope.check();
201
+ return result;
202
+ }
203
+ capabilities(scope) {
204
+ scope.check();
205
+ const view = parseRoleControlCapabilities(this.collaborators.capabilities(scope.ticket));
206
+ const runtime = this.collaborators.runtime.authority.view();
207
+ scope.check();
208
+ return { ...view, runtime };
209
+ }
210
+ async childView(scope, entry, parentSessionId = scope.parent.id) {
211
+ scope.check();
212
+ const direct = parentSessionId === scope.parent.id;
213
+ const inactive = this.ctx.get("agents")?.get(entry.id)?.status !== "running";
214
+ const observation = direct ? await this.collaborators.observeChild(scope.ticket, entry, scope.signal) : undefined;
215
+ scope.check();
216
+ const reason = !direct ? "not-direct-child" : entry.mode === "one-shot" ? "one-shot" : "unknown-mode";
217
+ const global = this.capabilities(scope);
218
+ const controls = entry.mode === "continuable" && observation !== undefined
219
+ ? { prompt: global.prompt.enabled ? observation.prompt : global.prompt, interrupt: global.interrupt.enabled ? observation.interrupt : global.interrupt }
220
+ : { prompt: disabled(reason), interrupt: disabled(reason) };
221
+ const projected = observation?.invocation === undefined ? undefined : parseDsmmInvocationView(observation.invocation);
222
+ const routeComparison = observation?.routeComparison === undefined ? undefined : parseDsmmRoleRouteComparison(observation.routeComparison);
223
+ if (projected?.childId !== undefined && projected.childId !== entry.id)
224
+ throw new ControlRefusal("unavailable", "childSessionId");
225
+ if (routeComparison !== undefined && routeComparison.childId !== entry.id)
226
+ throw new ControlRefusal("unavailable", "childSessionId");
227
+ return { id: entry.id, parentSessionId, mode: entry.mode, activity: inactive ? "inactive" : "running", readonly: !controls.prompt.enabled && !controls.interrupt.enabled,
228
+ ...(entry.label === undefined ? {} : { label: boundedChildLabel(entry.label) }), controls,
229
+ ...(projected === undefined ? {} : { invocation: { ...projected, childId: entry.id } }),
230
+ ...(routeComparison === undefined ? {} : { routeComparison }),
231
+ ...(observation?.evidence === undefined ? {} : { evidence: observation.evidence }) };
232
+ }
233
+ async runView(scope, holder) {
234
+ scope.check();
235
+ const identity = holder.invocation;
236
+ const background = identity === undefined ? disabled(holder.state === "cancelled" ? "cancelled" : "starting")
237
+ : await this.collaborators.backgroundAvailability(scope.ticket, identity, scope.signal);
238
+ scope.check();
239
+ const current = holder.invocation;
240
+ let invocation;
241
+ if (current !== undefined) {
242
+ const { runId: _run, childId: _child, jobId: _job, ...projected } = parseDsmmInvocationView(this.collaborators.projectRun(current));
243
+ const jobId = this.backgroundJobs.get(holder);
244
+ invocation = parseDsmmInvocationView({ ...projected, mode: "one-shot", runId: current.runId,
245
+ ...(current.childId === undefined ? {} : { childId: current.childId }), ...(jobId === undefined ? {} : { jobId }) });
246
+ }
247
+ const globalBackground = this.capabilities(scope).background;
248
+ return { sessionId: holder.sessionId, toolCallId: holder.toolCallId, state: holder.state, ...(invocation === undefined ? {} : { invocation }),
249
+ background: holder.state === "starting" ? disabled("starting") : holder.state === "settled" ? disabled("already-settled") : holder.state === "cancelled" ? disabled("cancelled")
250
+ : holder.state === "background" ? disabled("already-background") : globalBackground.enabled ? background : globalBackground };
251
+ }
252
+ describe(sessionId) {
253
+ return this.invoke(() => this.scoped(this.decode(parseRoleControlSessionId, sessionId), true, async (scope) => {
254
+ const catalog = await this.collaborators.runtime.listChildren(scope.parent.id, scope.signal);
255
+ scope.check();
256
+ const children = [], runs = [];
257
+ for (const child of catalog)
258
+ children.push(await this.childView(scope, child));
259
+ scope.check();
260
+ for (const holder of this.collaborators.runs.list(scope.parent, scope.ticket.owner))
261
+ runs.push(await this.runView(scope, holder));
262
+ scope.check();
263
+ return parseChildSessionSnapshot({ sessionId: scope.parent.id, admissionEpoch: scope.ticket.parentEpoch, children, runs, capabilities: this.capabilities(scope) });
264
+ }));
265
+ }
266
+ descendants(sessionId) {
267
+ return this.invoke(() => this.scoped(this.decode(parseRoleControlSessionId, sessionId), true, async (scope) => {
268
+ const catalog = await this.collaborators.runtime.listDescendants(scope.parent.id, scope.signal);
269
+ scope.check();
270
+ const descendants = [];
271
+ for (const entry of catalog) {
272
+ scope.check();
273
+ if (entry.kind === "diagnostic")
274
+ descendants.push({ kind: "diagnostic", id: entry.id, parentSessionId: entry.parentId, depth: entry.depth, reason: entry.reason });
275
+ else {
276
+ const child = await this.childView(scope, { id: entry.id, mode: entry.mode, createdAt: 0, ...("label" in entry ? { label: entry.label } : {}) }, entry.parentId);
277
+ descendants.push({ kind: "child", depth: entry.depth, hasChildren: entry.hasChildren, child: { ...child, activity: entry.activity } });
278
+ }
279
+ }
280
+ return parseRoleControlDescendants({ sessionId: scope.parent.id, admissionEpoch: scope.ticket.parentEpoch, descendants });
281
+ }));
282
+ }
283
+ background(sessionId, input) {
284
+ return this.invoke(async () => {
285
+ const request = this.decode(parseRoleControlBackgroundRequest, input);
286
+ if (request.sessionId !== this.decode(parseRoleControlSessionId, sessionId))
287
+ throw new ControlRefusal("validation", "sessionId");
288
+ return this.scoped(sessionId, false, async (scope) => {
289
+ if (request.expectedAdmissionEpoch !== scope.ticket.parentEpoch)
290
+ throw new ControlRefusal("conflict", "expectedAdmissionEpoch");
291
+ const holder = this.collaborators.runs.get(scope.parent, scope.ticket.owner, { sessionId: scope.parent.id,
292
+ toolCallId: request.toolCallId, runId: request.runId });
293
+ if (holder?.invocation === undefined)
294
+ throw new ControlRefusal("not-found", "runId");
295
+ const terminal = terminalTransition(holder.state, holder.invocation.runId);
296
+ if (terminal !== undefined) {
297
+ scope.check();
298
+ return terminal;
299
+ }
300
+ requireEnabled(this.capabilities(scope).background);
301
+ const permitted = await this.collaborators.backgroundAvailability(scope.ticket, holder.invocation, scope.signal);
302
+ scope.check();
303
+ // Result/cancellation may win while asynchronous capability preparation
304
+ // is pending. Observing that terminal state never creates a new job.
305
+ const observed = terminalTransition(holder.state, holder.invocation.runId);
306
+ if (observed !== undefined)
307
+ return observed;
308
+ requireEnabled(permitted);
309
+ // All async preparation is fenced before the holder's native synchronous
310
+ // jobs.start critical section, which rechecks its own exact authority.
311
+ const result = holder.background({ parent: scope.parent, owner: scope.ticket.owner, sessionId: scope.parent.id,
312
+ toolCallId: holder.toolCallId, runId: holder.invocation.runId, expectedAdmissionEpoch: request.expectedAdmissionEpoch });
313
+ if ("receipt" in result) {
314
+ this.backgroundJobs.set(holder, result.receipt.jobId);
315
+ return { status: result.status, runId: result.receipt.invocation.runId, jobId: result.receipt.jobId };
316
+ }
317
+ if (result.status === "starting")
318
+ throw new ControlRefusal("disabled", undefined, "starting");
319
+ return { status: result.status, runId: request.runId };
320
+ });
321
+ });
322
+ }
323
+ async directChild(scope, childId) {
324
+ scope.check();
325
+ const catalog = await this.collaborators.runtime.listChildren(scope.parent.id, scope.signal);
326
+ scope.check();
327
+ const child = catalog.find(child => child.id === childId);
328
+ if (child === undefined)
329
+ throw new ControlRefusal("not-owned", "childSessionId");
330
+ if (child.mode !== "continuable")
331
+ throw new ControlRefusal("not-resumable", "childSessionId");
332
+ return this.childView(scope, child);
333
+ }
334
+ prompt(sessionId, input) {
335
+ return this.invoke(async () => {
336
+ const request = this.decode(parseRoleControlPromptRequest, input);
337
+ if (request.parentSessionId !== this.decode(parseRoleControlSessionId, sessionId))
338
+ throw new ControlRefusal("validation", "parentSessionId");
339
+ return this.scoped(sessionId, false, async (scope) => {
340
+ requireEnabled(this.capabilities(scope).prompt);
341
+ const child = await this.directChild(scope, request.childSessionId);
342
+ scope.check();
343
+ requireEnabled(child.controls.prompt);
344
+ if (request.content.some(part => part.type === "image"))
345
+ requireEnabled(this.capabilities(scope).images);
346
+ scope.check();
347
+ // Original browser request identity, content, images, zone and delivery
348
+ // enter the unique C1 public override, then native pre-inbox cutoff.
349
+ return this.ctx.subagents.prompt(request, scope.signal);
350
+ });
351
+ });
352
+ }
353
+ interrupt(sessionId, input) {
354
+ return this.invoke(async () => {
355
+ const request = this.decode(parseRoleControlInterruptRequest, input);
356
+ if (request.parentSessionId !== this.decode(parseRoleControlSessionId, sessionId))
357
+ throw new ControlRefusal("validation", "parentSessionId");
358
+ return this.scoped(sessionId, false, async (scope) => {
359
+ requireEnabled(this.capabilities(scope).interrupt);
360
+ const child = await this.directChild(scope, request.childSessionId);
361
+ scope.check();
362
+ requireEnabled(child.controls.interrupt);
363
+ scope.check();
364
+ return this.ctx.subagents.interruptByParent(SessionId(request.childSessionId), scope.parent.id, "continuable");
365
+ });
366
+ });
367
+ }
368
+ };
369
+ })();
370
+ export { DsmmChildrenHost };
371
+ /** Caller supplies an owned Host injection fiber; no replacement or auto-mount. */
372
+ export function registerRoleControlRpc(ctx, collaborators) {
373
+ const host = new DsmmChildrenHost(ctx, collaborators);
374
+ ctx.typert.register(ROLE_CONTROL_HOST);
375
+ return host;
376
+ }
377
+ //# sourceMappingURL=role-control-rpc.js.map