@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.
- package/README.md +46 -58
- package/agent-presets/dsmm-builder/agent.cordis.yml +91 -186
- package/agent-presets/dsmm-builder/preset.yml +1 -1
- package/agent-presets/dsmm-clarifier/agent.cordis.yml +120 -17
- package/agent-presets/dsmm-clarifier/preset.yml +1 -1
- package/agent-presets/dsmm-code-search/agent.cordis.yml +72 -17
- package/agent-presets/dsmm-code-search/preset.yml +1 -1
- package/agent-presets/dsmm-coding/agent.cordis.yml +169 -0
- package/agent-presets/dsmm-coding/preset.yml +3 -0
- package/agent-presets/dsmm-complex/agent.cordis.yml +154 -0
- package/agent-presets/dsmm-complex/preset.yml +3 -0
- package/agent-presets/dsmm-creative/agent.cordis.yml +122 -15
- package/agent-presets/dsmm-creative/preset.yml +1 -1
- package/agent-presets/dsmm-cross-cutting/agent.cordis.yml +179 -0
- package/agent-presets/dsmm-cross-cutting/preset.yml +3 -0
- package/agent-presets/dsmm-deep/agent.cordis.yml +189 -0
- package/agent-presets/dsmm-deep/preset.yml +3 -0
- package/agent-presets/dsmm-doc-search/agent.cordis.yml +72 -17
- package/agent-presets/dsmm-doc-search/preset.yml +1 -1
- package/agent-presets/dsmm-documenting/agent.cordis.yml +168 -0
- package/agent-presets/dsmm-documenting/preset.yml +3 -0
- package/agent-presets/dsmm-frontend/agent.cordis.yml +161 -0
- package/agent-presets/dsmm-frontend/preset.yml +3 -0
- package/agent-presets/dsmm-hard-reasoning/agent.cordis.yml +153 -0
- package/agent-presets/dsmm-hard-reasoning/preset.yml +3 -0
- package/agent-presets/dsmm-media-reader/agent.cordis.yml +72 -17
- package/agent-presets/dsmm-media-reader/preset.yml +1 -1
- package/agent-presets/dsmm-normal-task/agent.cordis.yml +127 -0
- package/agent-presets/dsmm-normal-task/preset.yml +3 -0
- package/agent-presets/dsmm-oracle/agent.cordis.yml +109 -15
- package/agent-presets/dsmm-oracle/preset.yml +1 -1
- package/agent-presets/dsmm-oracle-2nd/agent.cordis.yml +109 -15
- package/agent-presets/dsmm-oracle-2nd/preset.yml +1 -1
- package/agent-presets/dsmm-orchestrator/agent.cordis.yml +174 -190
- package/agent-presets/dsmm-orchestrator/preset.yml +1 -1
- package/agent-presets/dsmm-plan-critic/agent.cordis.yml +102 -16
- package/agent-presets/dsmm-plan-critic/preset.yml +1 -1
- package/agent-presets/dsmm-planner/agent.cordis.yml +134 -15
- package/agent-presets/dsmm-planner/preset.yml +1 -1
- package/agent-presets/dsmm-quick/agent.cordis.yml +132 -0
- package/agent-presets/dsmm-quick/preset.yml +3 -0
- package/agent-presets/dsmm-research/agent.cordis.yml +156 -0
- package/agent-presets/dsmm-research/preset.yml +3 -0
- package/agent-presets/dsmm-reviewer/agent.cordis.yml +108 -16
- package/agent-presets/dsmm-reviewer/preset.yml +1 -1
- package/cordis.patch.yml +1 -5
- package/docs/agent-presets.md +48 -15
- package/docs/compatibility.md +58 -68
- package/docs/deferred-native-approval-risk.md +19 -0
- package/docs/design.md +43 -2
- package/docs/lsp.md +12 -12
- package/docs/migration-from-ocmm.md +10 -2
- package/docs/model-routing.md +84 -59
- package/docs/native-permissions.md +35 -0
- package/docs/profiles.md +43 -64
- package/docs/releasing.md +159 -8
- package/docs/roadmap.md +77 -17
- package/docs/runtime-recovery.md +12 -0
- package/docs/safety-guards.md +7 -3
- package/docs/settings-status.md +46 -40
- package/docs/skill-sync.md +89 -14
- package/lib/child-admission-contract.d.ts +37 -0
- package/lib/child-admission-contract.js +2 -0
- package/lib/child-admission.d.ts +42 -0
- package/lib/child-admission.js +162 -0
- package/lib/child-capture.d.ts +81 -0
- package/lib/child-capture.js +203 -0
- package/lib/child-evidence.d.ts +17 -0
- package/lib/child-evidence.js +43 -0
- package/lib/client/ChildrenPanel.d.ts +43 -0
- package/lib/client/ChildrenPanel.js +82 -0
- package/lib/client/DeploymentPage.d.ts +18 -0
- package/lib/client/DeploymentPage.js +127 -0
- package/lib/client/EditableChoice.d.ts +17 -0
- package/lib/client/EditableChoice.js +49 -0
- package/lib/client/PermissionsPanel.d.ts +14 -0
- package/lib/client/PermissionsPanel.js +46 -0
- package/lib/client/ProfilesSection.js +32 -15
- package/lib/client/RoleAvailability.d.ts +7 -0
- package/lib/client/RoleAvailability.js +19 -0
- package/lib/client/SessionProfiles.js +27 -9
- package/lib/client/StructuredEditor.js +15 -7
- package/lib/client/children-controller.d.ts +98 -0
- package/lib/client/children-controller.js +296 -0
- package/lib/client/children-locales.d.ts +367 -0
- package/lib/client/children-locales.js +69 -0
- package/lib/client/controller.d.ts +6 -1
- package/lib/client/controller.js +14 -8
- package/lib/client/deployment-controller.d.ts +50 -0
- package/lib/client/deployment-controller.js +193 -0
- package/lib/client/deployment-data.d.ts +17 -0
- package/lib/client/deployment-data.js +138 -0
- package/lib/client/deployment-locales.d.ts +70 -0
- package/lib/client/deployment-locales.js +81 -0
- package/lib/client/diagnostics.d.ts +14 -0
- package/lib/client/diagnostics.js +53 -0
- package/lib/client/index.d.ts +4 -0
- package/lib/client/index.js +145 -1
- package/lib/client/locales.d.ts +58 -0
- package/lib/client/locales.js +38 -18
- package/lib/client/permission-client.d.ts +16 -0
- package/lib/client/permission-client.js +38 -0
- package/lib/client/permission-controller.d.ts +62 -0
- package/lib/client/permission-controller.js +149 -0
- package/lib/client/permission-locales.d.ts +114 -0
- package/lib/client/permission-locales.js +75 -0
- package/lib/client/plugins-contract.d.ts +27 -0
- package/lib/client/plugins-contract.js +2 -0
- package/lib/client/session-labels.js +4 -4
- package/lib/client/structured.js +19 -5
- package/lib/client/styles.d.ts +1 -1
- package/lib/client/styles.js +36 -0
- package/lib/client.js +6724 -1604
- package/lib/commands.js +3 -0
- package/lib/config-file-store.d.ts +23 -0
- package/lib/config-file-store.js +67 -0
- package/lib/core-permission-authority.d.ts +18 -0
- package/lib/core-permission-authority.js +255 -0
- package/lib/core-permissions.d.ts +8 -0
- package/lib/core-permissions.js +33 -0
- package/lib/delivery-authority.d.ts +68 -0
- package/lib/delivery-authority.js +260 -0
- package/lib/deployment-config.d.ts +60 -0
- package/lib/deployment-config.js +205 -0
- package/lib/deployment-permission-rules.d.ts +55 -0
- package/lib/deployment-permission-rules.js +306 -0
- package/lib/dsh-home.d.ts +3 -0
- package/lib/dsh-home.js +10 -0
- package/lib/dsh-types.d.ts +22 -69
- package/lib/guards.d.ts +3 -2
- package/lib/guards.js +44 -6
- package/lib/host-llm-startup.d.ts +41 -0
- package/lib/host-llm-startup.js +65 -0
- package/lib/host-llm.d.ts +92 -0
- package/lib/host-llm.js +325 -0
- package/lib/index.d.ts +23 -5
- package/lib/index.js +383 -40
- package/lib/legacy-child-policy.d.ts +51 -0
- package/lib/legacy-child-policy.js +123 -0
- package/lib/legacy-read-composition.d.ts +20 -0
- package/lib/legacy-read-composition.js +144 -0
- package/lib/legacy-read-contracts.d.ts +157 -0
- package/lib/legacy-read-contracts.js +39 -0
- package/lib/legacy-read-host.d.ts +19 -0
- package/lib/legacy-read-host.js +67 -0
- package/lib/legacy-read-integration.d.ts +121 -0
- package/lib/legacy-read-integration.js +522 -0
- package/lib/legacy-read-proxy.d.ts +26 -0
- package/lib/legacy-read-proxy.js +237 -0
- package/lib/live-pi-ai-owner.d.ts +18 -0
- package/lib/live-pi-ai-owner.js +144 -0
- package/lib/llm-runtime.d.ts +11 -0
- package/lib/llm-runtime.js +21 -0
- package/lib/lsp.d.ts +13 -0
- package/lib/lsp.js +60 -0
- package/lib/managed-settings.d.ts +5 -0
- package/lib/managed-settings.js +14 -0
- package/lib/mode.js +42 -47
- package/lib/model-parameter-policy.d.ts +11 -0
- package/lib/model-parameter-policy.js +27 -0
- package/lib/model-routing.js +33 -19
- package/lib/modules.d.ts +35 -0
- package/lib/modules.js +37 -0
- package/lib/native-child-evidence.d.ts +42 -0
- package/lib/native-child-evidence.js +133 -0
- package/lib/native-pi-ai-wire.d.ts +37 -0
- package/lib/native-pi-ai-wire.js +261 -0
- package/lib/native-scope.d.ts +9 -0
- package/lib/native-scope.js +20 -0
- package/lib/permission-bash.d.ts +6 -0
- package/lib/permission-bash.js +7 -0
- package/lib/permission-control.d.ts +73 -0
- package/lib/permission-control.js +205 -0
- package/lib/permission-controller.d.ts +68 -0
- package/lib/permission-controller.js +317 -0
- package/lib/permission-errors.d.ts +7 -0
- package/lib/permission-errors.js +21 -0
- package/lib/permission-fs-search.d.ts +5 -0
- package/lib/permission-fs-search.js +7 -0
- package/lib/permission-fs.d.ts +5 -0
- package/lib/permission-fs.js +7 -0
- package/lib/permission-native-access.d.ts +11 -0
- package/lib/permission-native-access.js +6 -0
- package/lib/permission-native-command.d.ts +10 -0
- package/lib/permission-native-command.js +93 -0
- package/lib/permission-native-rules.d.ts +75 -0
- package/lib/permission-native-rules.js +278 -0
- package/lib/permission-pwsh.d.ts +6 -0
- package/lib/permission-pwsh.js +7 -0
- package/lib/permission-remote.d.ts +26 -0
- package/lib/permission-remote.js +53 -0
- package/lib/permission-rpc.d.ts +29 -0
- package/lib/permission-rpc.js +152 -0
- package/lib/permission-rules.d.ts +115 -0
- package/lib/permission-rules.js +256 -0
- package/lib/permission-settings.d.ts +45 -0
- package/lib/permission-settings.js +48 -0
- package/lib/permission-shell.d.ts +38 -0
- package/lib/permission-shell.js +150 -0
- package/lib/permission-web.d.ts +5 -0
- package/lib/permission-web.js +7 -0
- package/lib/plan-validation.js +6 -44
- package/lib/preset-materializer.js +2 -0
- package/lib/preset-registry.d.ts +1 -1
- package/lib/preset-registry.js +38 -24
- package/lib/preset-skills.d.ts +4 -1
- package/lib/preset-skills.js +60 -19
- package/lib/profile-diagnostics.d.ts +45 -0
- package/lib/profile-diagnostics.js +148 -0
- package/lib/profile-locale.d.ts +3 -0
- package/lib/profile-locale.js +2 -0
- package/lib/profile-remote.d.ts +22 -0
- package/lib/profile-remote.js +344 -27
- package/lib/profile-rpc.d.ts +25 -1
- package/lib/profile-rpc.js +143 -3
- package/lib/profile-runtime.d.ts +63 -0
- package/lib/profile-runtime.js +496 -77
- package/lib/profile-store.d.ts +56 -1
- package/lib/profile-store.js +377 -111
- package/lib/profile-types.d.ts +125 -1
- package/lib/profile-types.js +1 -0
- package/lib/profiles.d.ts +16 -2
- package/lib/profiles.js +156 -79
- package/lib/prompt-content.d.ts +25 -0
- package/lib/prompt-content.js +27 -0
- package/lib/prompts.d.ts +45 -4
- package/lib/prompts.js +157 -43
- package/lib/recovery-policy.js +20 -7
- package/lib/role-control-remote.d.ts +38 -0
- package/lib/role-control-remote.js +211 -0
- package/lib/role-control-rpc.d.ts +51 -0
- package/lib/role-control-rpc.js +377 -0
- package/lib/role-control-types.d.ts +92 -0
- package/lib/role-control-types.js +8 -0
- package/lib/role-invocation.d.ts +47 -0
- package/lib/role-invocation.js +135 -0
- package/lib/role-llm-runtime.d.ts +17 -0
- package/lib/role-llm-runtime.js +62 -0
- package/lib/role-llm.d.ts +31 -0
- package/lib/role-llm.js +66 -0
- package/lib/role-policy.d.ts +92 -0
- package/lib/role-policy.js +601 -0
- package/lib/role-providers.d.ts +7 -3
- package/lib/role-providers.js +74 -46
- package/lib/role-routing.d.ts +11 -2
- package/lib/role-routing.js +42 -25
- package/lib/role-runs.d.ts +135 -0
- package/lib/role-runs.js +304 -0
- package/lib/role-subagents.d.ts +63 -4
- package/lib/role-subagents.js +299 -47
- package/lib/roles.d.ts +20 -9
- package/lib/roles.js +87 -216
- package/lib/route-json.d.ts +19 -0
- package/lib/route-json.js +129 -0
- package/lib/routing-policy.d.ts +2 -0
- package/lib/routing-policy.js +12 -2
- package/lib/runtime-integration.d.ts +112 -0
- package/lib/runtime-integration.js +784 -0
- package/lib/runtime-recovery.js +34 -13
- package/lib/session-scope.js +2 -0
- package/lib/settings.d.ts +116 -14
- package/lib/settings.js +455 -149
- package/lib/skills.d.ts +24 -9
- package/lib/skills.js +114 -35
- package/lib/state.d.ts +10 -6
- package/lib/state.js +48 -49
- package/lib/status.d.ts +35 -1
- package/lib/status.js +58 -17
- package/lib/subagent-runtime.d.ts +45 -0
- package/lib/subagent-runtime.js +131 -0
- package/locale/en.json +2 -2
- package/locale/zh.json +2 -2
- package/package.json +112 -45
- package/patches/subagent-runtime.yml +15 -0
- package/prompts/deepseek-flash.md +1 -1
- package/prompts/deepseek-v4-pro.md +2 -2
- package/prompts/deepwork.md +153 -20
- package/prompts/source/agents/clarifier.md +47 -0
- package/prompts/source/agents/orchestrator.md +72 -0
- package/prompts/source/agents/plan-critic.md +29 -0
- package/prompts/source/agents/planner.md +21 -0
- package/prompts/source/agents/reviewer.md +23 -0
- package/prompts/source/catalog.json +548 -0
- package/prompts/source/category/coding.md +46 -0
- package/prompts/source/category/complex.md +29 -0
- package/prompts/source/category/creative.md +40 -0
- package/prompts/source/category/cross-cutting.md +54 -0
- package/prompts/source/category/deep.md +64 -0
- package/prompts/source/category/documenting.md +68 -0
- package/prompts/source/category/frontend.md +38 -0
- package/prompts/source/category/hard-reasoning.md +53 -0
- package/prompts/source/category/normal-task.md +27 -0
- package/prompts/source/category/quick.md +34 -0
- package/prompts/source/category/research.md +58 -0
- package/prompts/source/deepwork/claude-opus-5.md +28 -0
- package/prompts/source/deepwork/codex.md +9 -0
- package/prompts/source/deepwork/default.md +136 -0
- package/prompts/source/deepwork/gemini.md +191 -0
- package/prompts/source/deepwork/glm.md +263 -0
- package/prompts/source/deepwork/gpt.md +49 -0
- package/prompts/source/deepwork/kimi-k27.md +13 -0
- package/prompts/source/deepwork/planner.md +44 -0
- package/prompts/source/deepwork/swe-2.md +13 -0
- package/prompts/source/manifest.json +3233 -0
- package/prompts/source/shared/dsh-host-contract.md +8 -0
- package/prompts/source/shared/locale.md +8 -0
- package/prompts/source/shared/shell-safety.md +7 -0
- package/prompts/source/terminal/builder.md +13 -0
- package/prompts/source/terminal/clarifier.md +41 -0
- package/prompts/source/terminal/code-search.md +39 -0
- package/prompts/source/terminal/coding.md +41 -0
- package/prompts/source/terminal/complex.md +43 -0
- package/prompts/source/terminal/creative.md +41 -0
- package/prompts/source/terminal/cross-cutting.md +43 -0
- package/prompts/source/terminal/deep.md +43 -0
- package/prompts/source/terminal/doc-search.md +39 -0
- package/prompts/source/terminal/documenting.md +41 -0
- package/prompts/source/terminal/frontend.md +41 -0
- package/prompts/source/terminal/hard-reasoning.md +41 -0
- package/prompts/source/terminal/media-reader.md +39 -0
- package/prompts/source/terminal/normal-task.md +41 -0
- package/prompts/source/terminal/oracle-2nd.md +53 -0
- package/prompts/source/terminal/oracle.md +53 -0
- package/prompts/source/terminal/orchestrator.md +26 -0
- package/prompts/source/terminal/plan-critic.md +41 -0
- package/prompts/source/terminal/planner.md +42 -0
- package/prompts/source/terminal/quick.md +39 -0
- package/prompts/source/terminal/research.md +39 -0
- package/prompts/source/terminal/reviewer.md +53 -0
- package/scripts/cold-profile-composition.mjs +329 -0
- package/scripts/cold-profile-sources.mjs +238 -0
- package/scripts/migrate-cold-profile.mjs +315 -0
- package/skills/ast-grep/LICENSE +21 -0
- package/skills/ast-grep/README.md +138 -0
- package/skills/ast-grep/SKILL.md +287 -0
- package/skills/ast-grep/SOURCE +1 -0
- package/skills/ast-grep/install.ps1 +235 -0
- package/skills/ast-grep/install.sh +286 -0
- package/skills/ast-grep/references/cli.md +233 -0
- package/skills/ast-grep/references/install.md +168 -0
- package/skills/ast-grep/references/patterns.md +149 -0
- package/skills/ast-grep/references/pitfalls.md +305 -0
- package/skills/ast-grep/references/recipes.md +404 -0
- package/skills/ast-grep/references/sgconfig.md +250 -0
- package/skills/ast-grep/references/yaml-rules.md +511 -0
- package/skills/ast-grep/scripts/ast_grep_helper.py +760 -0
- package/skills/ast-grep/tests/smoke.ps1 +129 -0
- package/skills/ast-grep/tests/smoke.sh +212 -0
- package/skills/ast-grep/tests/test_resolver.py +154 -0
- package/skills/brainstorming/SKILL.md +123 -9
- package/skills/coding-agent-sessions/LICENSE-UPSTREAM.md +82 -0
- package/skills/coding-agent-sessions/NOTICE.md +24 -0
- package/skills/coding-agent-sessions/SKILL.md +147 -0
- package/skills/coding-agent-sessions/agents/openai.yaml +4 -0
- package/skills/coding-agent-sessions/pyrightconfig.json +5 -0
- package/skills/coding-agent-sessions/references/all-platforms.md +77 -0
- package/skills/coding-agent-sessions/references/claude.md +34 -0
- package/skills/coding-agent-sessions/references/codex.md +32 -0
- package/skills/coding-agent-sessions/references/opencode.md +45 -0
- package/skills/coding-agent-sessions/references/senpi.md +29 -0
- package/skills/coding-agent-sessions/scripts/agent_sessions/__init__.py +1 -0
- package/skills/coding-agent-sessions/scripts/agent_sessions/aside_scanner.py +140 -0
- package/skills/coding-agent-sessions/scripts/agent_sessions/claude.py +66 -0
- package/skills/coding-agent-sessions/scripts/agent_sessions/cli.py +283 -0
- package/skills/coding-agent-sessions/scripts/agent_sessions/codex.py +105 -0
- package/skills/coding-agent-sessions/scripts/agent_sessions/file_scanners.py +275 -0
- package/skills/coding-agent-sessions/scripts/agent_sessions/jsonio.py +55 -0
- package/skills/coding-agent-sessions/scripts/agent_sessions/kiro_scanner.py +91 -0
- package/skills/coding-agent-sessions/scripts/agent_sessions/opencode.py +289 -0
- package/skills/coding-agent-sessions/scripts/agent_sessions/pi_family.py +46 -0
- package/skills/coding-agent-sessions/scripts/agent_sessions/scanners.py +104 -0
- package/skills/coding-agent-sessions/scripts/agent_sessions/sqlite_optional_scanners.py +203 -0
- package/skills/coding-agent-sessions/scripts/agent_sessions/sqlite_scanners.py +177 -0
- package/skills/coding-agent-sessions/scripts/agent_sessions/timeparse.py +51 -0
- package/skills/coding-agent-sessions/scripts/agent_sessions/transcript.py +149 -0
- package/skills/coding-agent-sessions/scripts/agent_sessions/types.py +57 -0
- package/skills/coding-agent-sessions/scripts/find-agent-sessions.py +19 -0
- package/skills/coding-agent-sessions/scripts/tests/test_agent_sessions.py +322 -0
- package/skills/coding-agent-sessions/scripts/tests/test_aside_scanner.py +131 -0
- package/skills/coding-agent-sessions/scripts/tests/test_cli_contract.py +126 -0
- package/skills/coding-agent-sessions/scripts/tests/test_extended_scanners.py +262 -0
- package/skills/coding-agent-sessions/scripts/tests/test_optional_sqlite_scanners.py +79 -0
- package/skills/coding-agent-sessions/scripts/tests/test_pi_family_scanners.py +130 -0
- package/skills/debugging/SKILL.md +130 -4
- package/skills/debugging/references/logging.md +2 -0
- package/skills/debugging/references/methodology/00-setup.md +16 -62
- package/skills/debugging/references/methodology/02-investigate.md +11 -5
- package/skills/debugging/references/methodology/03-flaky-triage.md +6 -4
- package/skills/debugging/references/methodology/04-hard-reasoning-escalation.md +6 -16
- package/skills/debugging/references/methodology/05-escalate.md +2 -0
- package/skills/debugging/references/methodology/06-fix.md +8 -6
- package/skills/debugging/references/methodology/08-qa.md +7 -5
- package/skills/debugging/references/methodology/09-cleanup.md +16 -152
- package/skills/debugging/references/methodology/partial-runtime-evidence.md +7 -18
- package/skills/debugging/references/runtimes/bundled-js-binary.md +3 -16
- package/skills/debugging/references/runtimes/go.md +2 -0
- package/skills/debugging/references/runtimes/native-binary.md +11 -54
- package/skills/debugging/references/runtimes/node.md +6 -15
- package/skills/debugging/references/runtimes/python.md +5 -15
- package/skills/debugging/references/runtimes/rust.md +4 -18
- package/skills/debugging/references/scripts/dap.test.mjs +539 -0
- package/skills/debugging/references/scripts/fixture-adapter.mjs +164 -0
- package/skills/debugging/references/tools/dap.md +4 -2
- package/skills/debugging/references/tools/ghidra.md +6 -15
- package/skills/debugging/references/tools/playwright-cli.md +5 -15
- package/skills/debugging/references/tools/pwndbg.md +2 -0
- package/skills/debugging/references/tools/pwntools.md +6 -16
- package/skills/dispatching-parallel-agents/SKILL.md +96 -7
- package/skills/frontend/.frontend-materialized.json +856 -0
- package/skills/frontend/ATTRIBUTION.md +37 -0
- package/skills/frontend/LICENSE-Apache-2.0.txt +201 -0
- package/skills/frontend/LICENSE-taste-skill.txt +21 -0
- package/skills/frontend/LICENSE-ui-ux-pro-max.txt +21 -0
- package/skills/frontend/SKILL.md +145 -0
- package/skills/frontend/references/design/README.md +256 -0
- package/skills/frontend/references/design/_INDEX.md +206 -0
- package/skills/frontend/references/design/airbnb.md +393 -0
- package/skills/frontend/references/design/airtable.md +92 -0
- package/skills/frontend/references/design/apple.md +250 -0
- package/skills/frontend/references/design/aside.md +211 -0
- package/skills/frontend/references/design/binance.md +348 -0
- package/skills/frontend/references/design/bmw.md +183 -0
- package/skills/frontend/references/design/brutalist-skill.md +92 -0
- package/skills/frontend/references/design/bugatti.md +271 -0
- package/skills/frontend/references/design/cal.md +262 -0
- package/skills/frontend/references/design/claude.md +315 -0
- package/skills/frontend/references/design/clay.md +307 -0
- package/skills/frontend/references/design/clickhouse.md +284 -0
- package/skills/frontend/references/design/clone-from-url.md +69 -0
- package/skills/frontend/references/design/cohere.md +269 -0
- package/skills/frontend/references/design/coinbase.md +132 -0
- package/skills/frontend/references/design/composio.md +310 -0
- package/skills/frontend/references/design/cursor.md +312 -0
- package/skills/frontend/references/design/design-system-architecture.md +250 -0
- package/skills/frontend/references/design/elevenlabs.md +268 -0
- package/skills/frontend/references/design/expo.md +284 -0
- package/skills/frontend/references/design/ferrari.md +317 -0
- package/skills/frontend/references/design/figma.md +223 -0
- package/skills/frontend/references/design/framer.md +249 -0
- package/skills/frontend/references/design/gpt-tasteskill.md +74 -0
- package/skills/frontend/references/design/hashicorp.md +281 -0
- package/skills/frontend/references/design/ibm.md +335 -0
- package/skills/frontend/references/design/image-to-code-skill.md +1228 -0
- package/skills/frontend/references/design/imagegen-brandkit.md +798 -0
- package/skills/frontend/references/design/imagegen-frontend-mobile.md +1465 -0
- package/skills/frontend/references/design/imagegen-frontend-web.md +987 -0
- package/skills/frontend/references/design/interaction-skill.md +52 -0
- package/skills/frontend/references/design/intercom.md +149 -0
- package/skills/frontend/references/design/kraken.md +128 -0
- package/skills/frontend/references/design/lamborghini.md +291 -0
- package/skills/frontend/references/design/linear.app.md +370 -0
- package/skills/frontend/references/design/lovable.md +301 -0
- package/skills/frontend/references/design/mastercard.md +368 -0
- package/skills/frontend/references/design/meta.md +369 -0
- package/skills/frontend/references/design/minimalist-skill.md +85 -0
- package/skills/frontend/references/design/minimax.md +260 -0
- package/skills/frontend/references/design/mintlify.md +329 -0
- package/skills/frontend/references/design/miro.md +111 -0
- package/skills/frontend/references/design/mistral.ai.md +264 -0
- package/skills/frontend/references/design/mongodb.md +269 -0
- package/skills/frontend/references/design/nike.md +366 -0
- package/skills/frontend/references/design/notion.md +312 -0
- package/skills/frontend/references/design/nvidia.md +296 -0
- package/skills/frontend/references/design/ollama.md +270 -0
- package/skills/frontend/references/design/opencode.ai.md +284 -0
- package/skills/frontend/references/design/output-skill.md +49 -0
- package/skills/frontend/references/design/pinterest.md +233 -0
- package/skills/frontend/references/design/playstation.md +367 -0
- package/skills/frontend/references/design/posthog.md +259 -0
- package/skills/frontend/references/design/raycast.md +271 -0
- package/skills/frontend/references/design/react-dev-tooling-skill.md +232 -0
- package/skills/frontend/references/design/redesign-skill.md +178 -0
- package/skills/frontend/references/design/renault.md +314 -0
- package/skills/frontend/references/design/replicate.md +264 -0
- package/skills/frontend/references/design/resend.md +306 -0
- package/skills/frontend/references/design/revolut.md +188 -0
- package/skills/frontend/references/design/runwayml.md +247 -0
- package/skills/frontend/references/design/sanity.md +360 -0
- package/skills/frontend/references/design/sentry.md +265 -0
- package/skills/frontend/references/design/shopify.md +353 -0
- package/skills/frontend/references/design/soft-skill.md +98 -0
- package/skills/frontend/references/design/spacex.md +197 -0
- package/skills/frontend/references/design/spotify.md +249 -0
- package/skills/frontend/references/design/starbucks.md +583 -0
- package/skills/frontend/references/design/stitch-design-example.md +121 -0
- package/skills/frontend/references/design/stitch-skill.md +184 -0
- package/skills/frontend/references/design/stripe.md +325 -0
- package/skills/frontend/references/design/supabase.md +258 -0
- package/skills/frontend/references/design/superhuman.md +255 -0
- package/skills/frontend/references/design/taste-skill.md +1206 -0
- package/skills/frontend/references/design/tesla.md +289 -0
- package/skills/frontend/references/design/theverge.md +342 -0
- package/skills/frontend/references/design/together.ai.md +266 -0
- package/skills/frontend/references/design/uber.md +298 -0
- package/skills/frontend/references/design/vercel.md +313 -0
- package/skills/frontend/references/design/vodafone.md +426 -0
- package/skills/frontend/references/design/voltagent.md +326 -0
- package/skills/frontend/references/design/warp.md +256 -0
- package/skills/frontend/references/design/webflow.md +95 -0
- package/skills/frontend/references/design/wired.md +281 -0
- package/skills/frontend/references/design/wise.md +176 -0
- package/skills/frontend/references/design/x.ai.md +260 -0
- package/skills/frontend/references/design/zapier.md +331 -0
- package/skills/frontend/references/perfection/README.md +264 -0
- package/skills/frontend/references/perfection/react-perf-tooling.md +234 -0
- package/skills/frontend/references/ui-ux-db/README.md +659 -0
- package/skills/frontend/references/ui-ux-db/data/app-interface.csv +31 -0
- package/skills/frontend/references/ui-ux-db/data/charts.csv +26 -0
- package/skills/frontend/references/ui-ux-db/data/colors.csv +162 -0
- package/skills/frontend/references/ui-ux-db/data/google-fonts.csv +1924 -0
- package/skills/frontend/references/ui-ux-db/data/icons.csv +106 -0
- package/skills/frontend/references/ui-ux-db/data/landing.csv +35 -0
- package/skills/frontend/references/ui-ux-db/data/products.csv +162 -0
- package/skills/frontend/references/ui-ux-db/data/react-performance.csv +45 -0
- package/skills/frontend/references/ui-ux-db/data/stacks/angular.csv +51 -0
- package/skills/frontend/references/ui-ux-db/data/stacks/astro.csv +54 -0
- package/skills/frontend/references/ui-ux-db/data/stacks/flutter.csv +53 -0
- package/skills/frontend/references/ui-ux-db/data/stacks/html-tailwind.csv +56 -0
- package/skills/frontend/references/ui-ux-db/data/stacks/jetpack-compose.csv +53 -0
- package/skills/frontend/references/ui-ux-db/data/stacks/laravel.csv +51 -0
- package/skills/frontend/references/ui-ux-db/data/stacks/nextjs.csv +53 -0
- package/skills/frontend/references/ui-ux-db/data/stacks/nuxt-ui.csv +51 -0
- package/skills/frontend/references/ui-ux-db/data/stacks/nuxtjs.csv +59 -0
- package/skills/frontend/references/ui-ux-db/data/stacks/react-native.csv +52 -0
- package/skills/frontend/references/ui-ux-db/data/stacks/react.csv +54 -0
- package/skills/frontend/references/ui-ux-db/data/stacks/shadcn.csv +61 -0
- package/skills/frontend/references/ui-ux-db/data/stacks/svelte.csv +54 -0
- package/skills/frontend/references/ui-ux-db/data/stacks/swiftui.csv +51 -0
- package/skills/frontend/references/ui-ux-db/data/stacks/threejs.csv +54 -0
- package/skills/frontend/references/ui-ux-db/data/stacks/vue.csv +50 -0
- package/skills/frontend/references/ui-ux-db/data/styles.csv +85 -0
- package/skills/frontend/references/ui-ux-db/data/typography.csv +74 -0
- package/skills/frontend/references/ui-ux-db/data/ui-reasoning.csv +162 -0
- package/skills/frontend/references/ui-ux-db/data/ux-guidelines.csv +100 -0
- package/skills/frontend/references/ui-ux-db/data/web-interface.csv +31 -0
- package/skills/frontend/references/ui-ux-db/scripts/core.py +262 -0
- package/skills/frontend/references/ui-ux-db/scripts/design_system.py +1148 -0
- package/skills/frontend/references/ui-ux-db/scripts/search.py +114 -0
- package/skills/frontend/scripts/perfection/lighthouse-audit.py +201 -0
- package/skills/git-master/SKILL.md +115 -0
- package/skills/git-master/agents/openai.yaml +13 -0
- package/skills/init-deep/SKILL.md +282 -0
- package/skills/receiving-code-review/SKILL.md +117 -7
- package/skills/remove-ai-slops/SKILL.md +160 -8
- package/skills/requesting-code-review/SKILL.md +98 -3
- package/skills/requesting-code-review/code-reviewer.md +59 -0
- package/skills/subagent-driven-development/SKILL.md +179 -6
- package/skills/subagent-driven-development/code-quality-reviewer-prompt.md +23 -0
- package/skills/subagent-driven-development/implementer-prompt.md +87 -0
- package/skills/subagent-driven-development/spec-reviewer-prompt.md +37 -0
- package/skills/using-git-worktrees/SKILL.md +144 -0
- package/skills/writing-plans/SKILL.md +126 -7
- package/skills/writing-plans/plan-document-reviewer-prompt.md +47 -0
package/lib/profile-runtime.js
CHANGED
|
@@ -1,36 +1,47 @@
|
|
|
1
1
|
import { join } from "node:path";
|
|
2
2
|
import { createHash, randomUUID } from "node:crypto";
|
|
3
3
|
import { ProfileStore, validateSessionProfileId } from "./profile-store.js";
|
|
4
|
-
import { DsmmProfileError, resolveProfileSettings } from "./profiles.js";
|
|
5
|
-
import { DSMM_ROLES,
|
|
6
|
-
import { roleRouteRuntimeState
|
|
7
|
-
import {
|
|
4
|
+
import { DsmmProfileError, profileDocumentWarnings, requiredReason, resolveProfileSettings } from "./profiles.js";
|
|
5
|
+
import { DSMM_ROLES, isDsmmRoleId } from "./roles.js";
|
|
6
|
+
import { roleRouteRuntimeState } from "./role-routing.js";
|
|
7
|
+
import { sessionEvents } from "./session-scope.js";
|
|
8
|
+
import { resolveAdmittedDsmmRole as resolveEffectiveDsmmRole } from "./role-policy.js";
|
|
8
9
|
import { DeepworkModeController, hasOpenTurn } from "./state.js";
|
|
9
|
-
import {
|
|
10
|
+
import { freezeSettings, isRootRoleEnabled } from "./settings.js";
|
|
11
|
+
import { resolveDshHome } from "./dsh-home.js";
|
|
12
|
+
import { lstatSync } from "node:fs";
|
|
13
|
+
import { projectDsmmModules } from "./modules.js";
|
|
14
|
+
import { Context } from "@deepseek-ai/cordis";
|
|
15
|
+
import { readOnlySettings, readOnlySettingSources } from "./status.js";
|
|
16
|
+
import { resolveSelectedAgentPreset } from "./session-scope.js";
|
|
17
|
+
import { admissionFromChildCapture, parseChildAdmissionCapture, parseLegacyChildEvidence } from "./child-capture.js";
|
|
18
|
+
import { normalizeModelRouteJson } from "./route-json.js";
|
|
19
|
+
import { resolvedModelParameterPolicy } from "./model-parameter-policy.js";
|
|
20
|
+
import { scopeLifetime } from "./delivery-authority.js";
|
|
21
|
+
function deploymentAdmissionView(admission) {
|
|
22
|
+
return { modelParameterPolicy: resolvedModelParameterPolicy(admission), settings: { ...readOnlySettings(admission.settings) }, sources: readOnlySettingSources(admission.sources ?? {}),
|
|
23
|
+
captures: readOnlySettingSources(admission.sourceCaptures?.fields ?? {}), restartRequired: [...admission.restartRequired ?? []], named: admission.profile === null ? null : { ...admission.profile } };
|
|
24
|
+
}
|
|
25
|
+
// Exact live native children retain their capture across DSMM runtime replacement.
|
|
26
|
+
const childAdmissions = new WeakMap();
|
|
10
27
|
function immutableSettings(settings) {
|
|
11
|
-
|
|
12
|
-
const freeze = (value) => {
|
|
13
|
-
if (typeof value !== "object" || value === null || Object.isFrozen(value))
|
|
14
|
-
return;
|
|
15
|
-
for (const entry of Object.values(value))
|
|
16
|
-
freeze(entry);
|
|
17
|
-
Object.freeze(value);
|
|
18
|
-
};
|
|
19
|
-
freeze(copy);
|
|
20
|
-
return copy;
|
|
28
|
+
return freezeSettings(settings);
|
|
21
29
|
}
|
|
22
30
|
/** Global defaults admit new roots; scoped idle switches replace one root's epoch. */
|
|
23
31
|
export class DsmmProfileRuntime {
|
|
24
32
|
ctx;
|
|
25
33
|
store;
|
|
26
34
|
options;
|
|
35
|
+
childCaptureStore;
|
|
27
36
|
getSettings = (agent) => agent === undefined ? this.current.settings : this.bind(agent).settings;
|
|
28
37
|
current;
|
|
38
|
+
currentDocument = null;
|
|
29
39
|
baseline;
|
|
30
40
|
bound = new WeakMap();
|
|
31
41
|
admitting = new WeakSet();
|
|
32
42
|
disposedAgents = new WeakSet();
|
|
33
43
|
switching = new WeakSet();
|
|
44
|
+
admissionObservers = new Set();
|
|
34
45
|
disposed = false;
|
|
35
46
|
selectionQueue = Promise.resolve();
|
|
36
47
|
mode;
|
|
@@ -38,27 +49,71 @@ export class DsmmProfileRuntime {
|
|
|
38
49
|
this.ctx = ctx;
|
|
39
50
|
this.store = store;
|
|
40
51
|
this.options = options;
|
|
52
|
+
this.childCaptureStore = options.childCaptureStore ?? store;
|
|
41
53
|
this.baseline = immutableSettings(baseline);
|
|
42
|
-
this.mode = options.modeController ?? new DeepworkModeController({ get: (name) => ctx.get?.(name) });
|
|
54
|
+
this.mode = options.modeController ?? new DeepworkModeController({ get: (name) => ctx.get?.(name) }, (agent) => this.getSettings(agent).modules.deepwork.enabled);
|
|
43
55
|
this.current = this.prepare(null, { selectedId: null, appliedRevision: null, selectionRevision: "absent" });
|
|
44
56
|
this.getSettings.admission = (agent) => this.admission(agent);
|
|
57
|
+
this.getSettings.moduleStates = (agent) => { const admission = this.admission(agent); return projectDsmmModules(this.baseline, admission.deployment, admission, false, this.options.getMountedPermission); };
|
|
58
|
+
this.getSettings.subagentRuntime = () => this.subagentRuntimeView();
|
|
45
59
|
}
|
|
46
60
|
async initialize() {
|
|
61
|
+
const retire = () => { this.disposed = true; this.admissionObservers.clear(); for (const agent of this.agents()?.list() ?? [])
|
|
62
|
+
if (this.bound.has(agent))
|
|
63
|
+
this.options.childAuthority?.revokeParent(agent, "runtime-disposed"); };
|
|
64
|
+
if (this.ctx instanceof Context)
|
|
65
|
+
scopeLifetime(this.ctx, "dsmm.profiles: retire admission lifecycle", retire);
|
|
66
|
+
else
|
|
67
|
+
this.ctx.effect?.(() => retire);
|
|
47
68
|
const selection = await this.store.loadSelection();
|
|
69
|
+
if (this.disposed)
|
|
70
|
+
throw new DsmmProfileError("disposed", "Profile initialization was disposed.");
|
|
71
|
+
this.currentDocument = selection.document === null ? null : freezeSettings(selection.document);
|
|
48
72
|
this.current = this.prepare(selection.document, selection);
|
|
49
73
|
this.ctx.on?.("agent/created", async ({ agent, signal }) => {
|
|
50
74
|
// Factory initialization already owns native maintenance: never whenIdle
|
|
51
75
|
// or reserve maintenance from inside this serial creation listener.
|
|
52
|
-
await this.
|
|
76
|
+
await this.completeAdmission(agent, signal);
|
|
53
77
|
}, { global: true, prepend: true });
|
|
54
|
-
this.ctx.on?.("agent/disposed", ({ agent }) => { this.disposedAgents.add(agent); }, { global: true });
|
|
55
|
-
|
|
78
|
+
this.ctx.on?.("agent/disposed", ({ agent }) => { this.options.childAuthority?.revokeParent(agent, "agent-disposed"); this.disposedAgents.add(agent); childAdmissions.delete(agent); }, { global: true });
|
|
79
|
+
if (this.options.onAdmissionGuardsInstalled !== undefined)
|
|
80
|
+
await this.options.onAdmissionGuardsInstalled(this);
|
|
56
81
|
// Installation into an already-running host treats those Agents as admitted
|
|
57
82
|
// now, while all later profile switches continue to preserve their snapshot.
|
|
83
|
+
const visited = new Set(), visiting = new Set();
|
|
84
|
+
const admitExisting = async (agent) => {
|
|
85
|
+
if (visited.has(agent))
|
|
86
|
+
return;
|
|
87
|
+
if (visiting.has(agent))
|
|
88
|
+
throw new DsmmProfileError("not-owned", "Existing Agent ownership has a cycle; no child authority was inferred.");
|
|
89
|
+
visiting.add(agent);
|
|
90
|
+
const parent = this.owner(agent);
|
|
91
|
+
if (parent !== undefined && this.options.deferRetainedChildren) {
|
|
92
|
+
visiting.delete(agent);
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
95
|
+
if (parent !== undefined)
|
|
96
|
+
await admitExisting(parent);
|
|
97
|
+
await this.completeAdmission(agent, undefined, this.options.startup);
|
|
98
|
+
visiting.delete(agent);
|
|
99
|
+
visited.add(agent);
|
|
100
|
+
};
|
|
58
101
|
for (const agent of this.agents()?.list() ?? [])
|
|
59
|
-
await
|
|
102
|
+
await admitExisting(agent);
|
|
60
103
|
}
|
|
61
104
|
admission(agent) { return agent === undefined ? this.current : this.bind(agent); }
|
|
105
|
+
/** Host enrollment observes completed exact admissions, never an entered but unpublished policy. */
|
|
106
|
+
hasAdmission(agent) { return !this.disposed && !this.disposedAgents.has(agent) && this.bound.has(agent) && this.agents()?.get?.(agent.id) === agent; }
|
|
107
|
+
observeAdmissions(observer) {
|
|
108
|
+
if (this.disposed)
|
|
109
|
+
throw new DsmmProfileError("disposed", "Profile admission observation was disposed.");
|
|
110
|
+
this.admissionObservers.add(observer);
|
|
111
|
+
return () => { this.admissionObservers.delete(observer); };
|
|
112
|
+
}
|
|
113
|
+
async announceAdmission(agent) {
|
|
114
|
+
for (const observer of this.admissionObservers)
|
|
115
|
+
await observer(agent);
|
|
116
|
+
}
|
|
62
117
|
async getSession(agent) {
|
|
63
118
|
this.assertRoot(agent);
|
|
64
119
|
const admitted = this.bind(agent);
|
|
@@ -69,11 +124,14 @@ export class DsmmProfileRuntime {
|
|
|
69
124
|
if ((disk.admissionEpoch === null && admitted.scope !== "global-default") || (disk.admissionEpoch !== null && (disk.admissionEpoch !== admitted.epoch || disk.selectedId !== admitted.selectedId || disk.appliedRevision !== admitted.appliedRevision))) {
|
|
70
125
|
throw new DsmmProfileError("conflict", "The session choice changed outside this Host. Its admitted policy was retained; refresh or resume explicitly.");
|
|
71
126
|
}
|
|
72
|
-
const reason = this.switching.has(agent) ? "maintenance" : agent.status === "running" ? "busy" : agent.runMaintenance === undefined ? "unavailable" : undefined;
|
|
127
|
+
const reason = this.store.readOnly ? "unavailable" : this.switching.has(agent) ? "maintenance" : agent.status === "running" ? "busy" : agent.runMaintenance === undefined ? "unavailable" : undefined;
|
|
73
128
|
const role = resolveEffectiveDsmmRole(agent, admitted.settings, this.mode.active(agent, admitted.settings.defaultActive));
|
|
74
129
|
const profileModel = this.declaredProfileModel(admitted.settings, role);
|
|
75
130
|
return { sessionId: agent.id, globalDefault: selectionState(this.current), selection: selectionState(disk), admittedSelection: selectionState(admitted), scope: admitted.scope,
|
|
76
131
|
rolePolicy: roleRouteRuntimeState(agent, admitted.settings, role, admitted.epoch), deepwork: this.mode.describe(agent, admitted.settings.defaultActive),
|
|
132
|
+
modules: projectDsmmModules(this.baseline, admitted.deployment, admitted, false, this.options.getMountedPermission),
|
|
133
|
+
configuration: deploymentAdmissionView(admitted),
|
|
134
|
+
warnings: structuredClone(admitted.warnings ?? []), roles: structuredClone(admitted.roleAvailability ?? []), subagentRuntime: this.subagentRuntimeView(),
|
|
77
135
|
...(profileModel === undefined ? {} : { profileModel }),
|
|
78
136
|
admissionEpoch: admitted.epoch, switchAllowed: reason === undefined, ...(reason === undefined ? {} : { switchUnavailableReason: reason }) };
|
|
79
137
|
}
|
|
@@ -91,11 +149,11 @@ export class DsmmProfileRuntime {
|
|
|
91
149
|
if (this.bind(agent) !== admitted || admitted.epoch !== request.expectedAdmissionEpoch || mode.revision !== request.expectedModeRevision) {
|
|
92
150
|
throw new DsmmProfileError("conflict", "The session profile, preset or mode changed. Refresh before retrying.");
|
|
93
151
|
}
|
|
94
|
-
if (mode.locked)
|
|
95
|
-
throw new DsmmProfileError("validation", "A DW preset owns its Deepwork composition.");
|
|
96
152
|
assertAuthority?.();
|
|
97
153
|
};
|
|
98
154
|
assertCurrent();
|
|
155
|
+
if (request.active && !admitted.settings.modules.deepwork.enabled)
|
|
156
|
+
throw new DsmmProfileError("unavailable", "Deepwork module is not admitted in this session; changing mode cannot enable it.", "modules.deepwork.enabled");
|
|
99
157
|
if (agent.status === "running")
|
|
100
158
|
throw new DsmmProfileError("busy", "Wait for the session to become idle.");
|
|
101
159
|
if (agent.runMaintenance === undefined)
|
|
@@ -138,12 +196,27 @@ export class DsmmProfileRuntime {
|
|
|
138
196
|
if (request.sessionId !== agent.id)
|
|
139
197
|
throw new DsmmProfileError("not-owned", "The native session does not match the captured Agent.");
|
|
140
198
|
const admitted = this.bind(agent);
|
|
199
|
+
const modeRevision = this.mode.describe(agent, admitted.settings.defaultActive).revision;
|
|
200
|
+
const coreOnly = () => resolveEffectiveDsmmRole(agent, admitted.settings, this.mode.active(agent, admitted.settings.defaultActive)) === undefined;
|
|
201
|
+
let requiresDelivery = this.options.childAuthority !== undefined && !coreOnly();
|
|
141
202
|
const assertCurrent = (maintenanceSignal) => {
|
|
142
203
|
this.assertRoot(agent);
|
|
143
204
|
if (signal?.aborted || maintenanceSignal?.aborted)
|
|
144
205
|
throw new DsmmProfileError("cancelled", "Session profile selection was cancelled; the previous admission was retained.");
|
|
145
|
-
if (this.bind(agent) !== admitted || admitted.epoch !== request.expectedAdmissionEpoch)
|
|
206
|
+
if (this.bind(agent) !== admitted || admitted.epoch !== request.expectedAdmissionEpoch || this.mode.describe(agent, admitted.settings.defaultActive).revision !== modeRevision)
|
|
146
207
|
throw new DsmmProfileError("conflict", "The session admission changed. Refresh before selecting again.");
|
|
208
|
+
if (this.options.childAuthority !== undefined) {
|
|
209
|
+
if (requiresDelivery)
|
|
210
|
+
this.assertDeliveryFence();
|
|
211
|
+
if (!requiresDelivery && this.options.childAuthority.assertCoreParentAdmission !== undefined) {
|
|
212
|
+
this.options.childAuthority.assertCoreParentAdmission(agent, this.options.childAuthorityOwner ?? this, admitted);
|
|
213
|
+
}
|
|
214
|
+
else {
|
|
215
|
+
const ticket = this.options.childAuthority.acquireParentTicket(agent);
|
|
216
|
+
if (ticket.admission !== admitted || ticket.owner !== (this.options.childAuthorityOwner ?? this))
|
|
217
|
+
throw new DsmmProfileError("not-owned", "The stable Host authority does not own this exact admission.");
|
|
218
|
+
}
|
|
219
|
+
}
|
|
147
220
|
assertAuthority?.();
|
|
148
221
|
};
|
|
149
222
|
assertCurrent();
|
|
@@ -159,23 +232,57 @@ export class DsmmProfileRuntime {
|
|
|
159
232
|
assertCurrent(maintenanceSignal);
|
|
160
233
|
const epoch = newEpoch();
|
|
161
234
|
let profileModel;
|
|
235
|
+
let committed;
|
|
236
|
+
let next;
|
|
162
237
|
const result = await this.store.selectSession(request, epoch, async (document) => {
|
|
163
|
-
const prepared = immutableSettings(resolveProfileSettings(
|
|
164
|
-
|
|
238
|
+
const prepared = immutableSettings(resolveProfileSettings(admitted.baseline, document?.settings ?? {}));
|
|
239
|
+
const candidate = { settings: prepared, epoch, scope: request.id === null ? "deployment-baseline" : "session-override",
|
|
240
|
+
profile: document === null ? null : { id: document.id, revision: request.expectedRevision } };
|
|
241
|
+
this.assertRootRole(agent, prepared);
|
|
242
|
+
this.validateRootRole(agent, candidate);
|
|
243
|
+
const controlled = !coreOnly() || resolveEffectiveDsmmRole(agent, prepared, this.mode.active(agent, prepared.defaultActive)) !== undefined;
|
|
244
|
+
requiresDelivery ||= controlled && (this.options.childAuthority !== undefined
|
|
245
|
+
|| ["roles", "guards", "subagents"].some(key => JSON.stringify(Reflect.get(prepared, key)) !== JSON.stringify(Reflect.get(admitted.settings, key))));
|
|
246
|
+
if (requiresDelivery)
|
|
247
|
+
this.assertDeliveryFence();
|
|
248
|
+
await this.validate(prepared, requiresDelivery);
|
|
249
|
+
assertCurrent(maintenanceSignal);
|
|
250
|
+
this.assertRootRole(agent, prepared);
|
|
251
|
+
this.validateRootRole(agent, candidate);
|
|
165
252
|
const role = resolveEffectiveDsmmRole(agent, prepared, this.mode.active(agent, prepared.defaultActive));
|
|
166
253
|
profileModel = this.declaredProfileModel(prepared, role);
|
|
167
|
-
assertCurrent(maintenanceSignal);
|
|
168
254
|
return prepared;
|
|
169
255
|
}, {
|
|
170
256
|
assertCurrent: () => assertCurrent(maintenanceSignal),
|
|
257
|
+
prepare: (selection, settings) => {
|
|
258
|
+
next = this.profileAdmission(selection, settings, epoch, request.id === null ? "deployment-baseline" : "session-override", admitted.baseline, admitted.deployment, admitted.restartRequired, selection.document, selection.warnings);
|
|
259
|
+
this.validateRootRole(agent, next);
|
|
260
|
+
if (!requiresDelivery && this.options.childAuthority?.prepareCoreParentAdmission !== undefined) {
|
|
261
|
+
this.options.childAuthority.prepareCoreParentAdmission(agent, this.options.childAuthorityOwner ?? this, admitted, next);
|
|
262
|
+
}
|
|
263
|
+
else
|
|
264
|
+
this.options.childAuthority?.prepareParentAdmission(agent, admitted.epoch, next);
|
|
265
|
+
},
|
|
171
266
|
committed: (selection, settings) => {
|
|
172
|
-
this.bound.set(agent,
|
|
267
|
+
const install = () => { this.bound.set(agent, next); };
|
|
268
|
+
if (this.options.childAuthority !== undefined)
|
|
269
|
+
this.options.childAuthority.publishParentAdmission(agent, admitted.epoch, next, install);
|
|
270
|
+
else
|
|
271
|
+
install();
|
|
272
|
+
committed = next;
|
|
173
273
|
}
|
|
174
274
|
});
|
|
275
|
+
try {
|
|
276
|
+
this.mode.changed(agent);
|
|
277
|
+
}
|
|
278
|
+
catch { /* Observers cannot undo a successful durable admission publication. */ }
|
|
175
279
|
// A committed selection remains a successful transaction even if a
|
|
176
280
|
// queued wake or disposal wins immediately when maintenance releases.
|
|
177
281
|
return { sessionId: request.sessionId, globalDefault: selectionState(this.current), selection: selectionState(result.selection), admittedSelection: selectionState(result.selection),
|
|
178
282
|
deepwork: this.mode.describe(agent, result.prepared.defaultActive),
|
|
283
|
+
modules: projectDsmmModules(this.baseline, committed.deployment, committed, false, this.options.getMountedPermission),
|
|
284
|
+
configuration: deploymentAdmissionView(committed),
|
|
285
|
+
warnings: structuredClone(committed.warnings ?? []), roles: structuredClone(committed.roleAvailability ?? []), subagentRuntime: this.subagentRuntimeView(),
|
|
179
286
|
...(profileModel === undefined ? {} : { profileModel }),
|
|
180
287
|
scope: request.id === null ? "deployment-baseline" : "session-override", admissionEpoch: epoch, switchAllowed: true };
|
|
181
288
|
}
|
|
@@ -199,11 +306,12 @@ export class DsmmProfileRuntime {
|
|
|
199
306
|
|| persisted.selectionRevision !== current.selectionRevision;
|
|
200
307
|
return {
|
|
201
308
|
...persisted,
|
|
309
|
+
selectedWarnings: structuredClone(current.warnings ?? []),
|
|
202
310
|
roles: DSMM_ROLES.map((role) => {
|
|
203
311
|
const configured = this.baseline.roleRouting[role.id];
|
|
204
312
|
const runtimePolicy = { ...(configured?.strategy === undefined ? {} : { strategy: configured.strategy }),
|
|
205
313
|
...(configured?.rateLimit === undefined ? {} : { rateLimit: structuredClone(configured.rateLimit) }) };
|
|
206
|
-
return { id: role.id, label: role.name, enabled: this.
|
|
314
|
+
return { id: role.id, label: role.name, enabled: this.current.settings.roles[role.id], availability: this.current.roleAvailability?.find(state => state.id === role.id),
|
|
207
315
|
...(Object.keys(runtimePolicy).length === 0 ? {} : { runtimePolicy }) };
|
|
208
316
|
}),
|
|
209
317
|
editorDefaults: structuredClone(this.baseline.runtimePolicy),
|
|
@@ -221,31 +329,128 @@ export class DsmmProfileRuntime {
|
|
|
221
329
|
}
|
|
222
330
|
read(id) { return this.store.read(id); }
|
|
223
331
|
save(request) { return this.store.save(request); }
|
|
332
|
+
getStartupSettings() { return this.baseline; }
|
|
333
|
+
/** Preview uses the admission path but neither binds nor creates an Agent. */
|
|
334
|
+
previewDeployment(desired) {
|
|
335
|
+
return deploymentAdmissionView(this.prepare(this.currentDocument, this.current, this.current.epoch, "global-default", desired));
|
|
336
|
+
}
|
|
337
|
+
async describeDeployment(agent) {
|
|
338
|
+
const desired = await this.options.readDesired?.();
|
|
339
|
+
return { startup: this.options.startup ?? null, desired: desired ?? null, admission: this.admission(agent) };
|
|
340
|
+
}
|
|
224
341
|
select(request) {
|
|
225
342
|
const operation = this.selectionQueue.then(async () => {
|
|
343
|
+
let selectedDocument = null;
|
|
344
|
+
const baseline = this.current.baseline;
|
|
226
345
|
const result = await this.store.select(request, async (document) => {
|
|
227
|
-
|
|
346
|
+
selectedDocument = document === null ? null : freezeSettings(document);
|
|
347
|
+
const prepared = immutableSettings(resolveProfileSettings(baseline, document?.settings ?? {}));
|
|
228
348
|
await this.validate(prepared);
|
|
229
349
|
return prepared;
|
|
230
350
|
});
|
|
231
351
|
// There is no await between successful durable commit and publication of
|
|
232
352
|
// the complete settings value. Draft saves never reach this assignment.
|
|
233
|
-
this.current = this.profileAdmission(result.selection, result.prepared, newEpoch(), "global-default");
|
|
353
|
+
this.current = this.profileAdmission(result.selection, result.prepared, newEpoch(), "global-default", baseline, this.options.startup, this.current.restartRequired, selectedDocument, result.selection.warnings);
|
|
354
|
+
this.currentDocument = selectedDocument;
|
|
234
355
|
return this.describe();
|
|
235
356
|
});
|
|
236
357
|
this.selectionQueue = operation.catch(() => undefined);
|
|
237
358
|
return operation;
|
|
238
359
|
}
|
|
239
|
-
prepare(document, selection, epoch = newEpoch(), scope = "global-default") {
|
|
240
|
-
|
|
360
|
+
prepare(document, selection, epoch = newEpoch(), scope = "global-default", deployment = this.options.startup) {
|
|
361
|
+
const desired = deployment?.settings ?? this.baseline;
|
|
362
|
+
const effective = structuredClone(desired);
|
|
363
|
+
const restartRequired = [];
|
|
364
|
+
effective.modules.deepwork.enabled = desired.modules.deepwork.enabled && this.baseline.modules.deepwork.enabled;
|
|
365
|
+
effective.subagents.allowRouteOverride = desired.subagents.allowRouteOverride && this.baseline.subagents.allowRouteOverride;
|
|
366
|
+
if (desired.subagents.allowRouteOverride && !this.baseline.subagents.allowRouteOverride)
|
|
367
|
+
restartRequired.push("subagents.allowRouteOverride");
|
|
368
|
+
if (this.baseline.subagents.maxDepth !== undefined && (desired.subagents.maxDepth === undefined || desired.subagents.maxDepth > this.baseline.subagents.maxDepth)) {
|
|
369
|
+
effective.subagents.maxDepth = this.baseline.subagents.maxDepth;
|
|
370
|
+
restartRequired.push("subagents.maxDepth");
|
|
371
|
+
}
|
|
372
|
+
if (desired.modules.deepwork.enabled && !this.baseline.modules.deepwork.enabled)
|
|
373
|
+
restartRequired.push("modules.deepwork.enabled");
|
|
374
|
+
for (const role of DSMM_ROLES) {
|
|
375
|
+
if (desired.roles[role.id] && !this.baseline.roles[role.id])
|
|
376
|
+
restartRequired.push(`roles.${role.id}`);
|
|
377
|
+
effective.roles[role.id] = desired.roles[role.id] && this.baseline.roles[role.id];
|
|
378
|
+
}
|
|
379
|
+
const capability = desired.subagents.backgroundMode === "continuable" ? this.options.subagentCapabilities?.continuable : this.options.subagentCapabilities?.backgroundJobs;
|
|
380
|
+
if (desired.subagents.enableRunInBackground && capability === false) {
|
|
381
|
+
effective.subagents.enableRunInBackground = false;
|
|
382
|
+
restartRequired.push("subagents");
|
|
383
|
+
}
|
|
384
|
+
if (desired.permissionControl.enabled !== this.baseline.permissionControl.enabled)
|
|
385
|
+
restartRequired.push("permissionControl.enabled");
|
|
386
|
+
effective.permissionControl = { ...desired.permissionControl, enabled: this.baseline.permissionControl.enabled };
|
|
387
|
+
for (const key of ["modeName", "promptOrder", "presets", "lsp"]) {
|
|
388
|
+
if (JSON.stringify(desired[key]) !== JSON.stringify(this.baseline[key]))
|
|
389
|
+
restartRequired.push(key);
|
|
390
|
+
Object.assign(effective, { [key]: this.baseline[key] });
|
|
391
|
+
}
|
|
392
|
+
if (deployment !== undefined && this.options.startup !== undefined
|
|
393
|
+
&& (deployment.profile.section ?? deployment.global.section) !== (this.options.startup.profile.section ?? this.options.startup.global.section))
|
|
394
|
+
restartRequired.push("section");
|
|
395
|
+
const baseline = immutableSettings(effective);
|
|
396
|
+
return this.profileAdmission(selection, immutableSettings(resolveProfileSettings(baseline, document?.settings ?? {})), epoch, scope, baseline, deployment, restartRequired, document, selection.warnings);
|
|
241
397
|
}
|
|
242
|
-
profileAdmission(selection, settings, epoch, scope) {
|
|
243
|
-
|
|
398
|
+
profileAdmission(selection, settings, epoch, scope, baseline = this.baseline, deployment = this.options.startup, restartRequired = [], document = null, warnings = profileDocumentWarnings(document)) {
|
|
399
|
+
const sources = { ...deployment?.sources };
|
|
400
|
+
const fields = Object.fromEntries(Object.keys(sources).map((path) => [path, "deployment"]));
|
|
401
|
+
const pinStartup = (prefix) => {
|
|
402
|
+
const matches = (path) => path === prefix || path.startsWith(`${prefix}.`);
|
|
403
|
+
for (const path of Object.keys(sources).filter(matches)) {
|
|
404
|
+
delete sources[path];
|
|
405
|
+
delete fields[path];
|
|
406
|
+
}
|
|
407
|
+
for (const [path, source] of Object.entries(this.options.startup?.sources ?? {}).filter(([path]) => matches(path))) {
|
|
408
|
+
sources[path] = source;
|
|
409
|
+
fields[path] = "startup";
|
|
410
|
+
}
|
|
411
|
+
};
|
|
412
|
+
for (const key of ["modeName", "promptOrder", "presets", "lsp", "permissionControl.enabled"])
|
|
413
|
+
pinStartup(key);
|
|
414
|
+
if (deployment?.settings.modules.deepwork.enabled && !baseline.modules.deepwork.enabled)
|
|
415
|
+
pinStartup("modules.deepwork.enabled");
|
|
416
|
+
if (deployment?.settings.subagents.allowRouteOverride && !baseline.subagents.allowRouteOverride)
|
|
417
|
+
pinStartup("subagents.allowRouteOverride");
|
|
418
|
+
if (deployment !== undefined && deployment.settings.subagents.maxDepth !== baseline.subagents.maxDepth)
|
|
419
|
+
pinStartup("subagents.maxDepth");
|
|
420
|
+
for (const role of DSMM_ROLES) {
|
|
421
|
+
if (deployment?.settings.roles[role.id] && !baseline.roles[role.id])
|
|
422
|
+
pinStartup(`roles.${role.id}`);
|
|
423
|
+
}
|
|
424
|
+
const mark = (value, path) => {
|
|
425
|
+
if (value !== null && typeof value === "object" && !Array.isArray(value)) {
|
|
426
|
+
for (const [key, child] of Object.entries(value))
|
|
427
|
+
mark(child, [...path, key]);
|
|
428
|
+
}
|
|
429
|
+
else {
|
|
430
|
+
sources[path.join(".")] = "named-session";
|
|
431
|
+
fields[path.join(".")] = "named-session";
|
|
432
|
+
}
|
|
433
|
+
};
|
|
434
|
+
for (const [role, policy] of Object.entries(document?.settings.roleRouting ?? {})) {
|
|
435
|
+
const prefixes = [...policy?.primary === undefined ? [] : [`roleRouting.${role}.primary.`], ...Object.keys(policy?.levels ?? {}).map(level => `roleRouting.${role}.levels.${level}.`)];
|
|
436
|
+
for (const prefix of prefixes)
|
|
437
|
+
for (const path of Object.keys(sources).filter((path) => path.startsWith(prefix))) {
|
|
438
|
+
delete sources[path];
|
|
439
|
+
delete fields[path];
|
|
440
|
+
}
|
|
441
|
+
}
|
|
442
|
+
mark(document?.settings ?? {}, []);
|
|
443
|
+
return Object.freeze({ ...selectionState(selection), settings, baseline, epoch, scope, ...(deployment === undefined ? {} : { deployment }),
|
|
444
|
+
warnings: freezeSettings(warnings), roleAvailability: freezeSettings(this.roleAvailability(settings, baseline, deployment, document)), subagentRuntime: freezeSettings(this.subagentRuntimeView()),
|
|
445
|
+
...(this.store.origin === undefined ? {} : { store: Object.freeze({ origin: this.store.origin, readOnly: this.store.readOnly === true,
|
|
446
|
+
...(this.store.writeRestriction === undefined ? {} : { writeRestriction: this.store.writeRestriction }) }) }),
|
|
447
|
+
sources: Object.freeze(sources), sourceCaptures: Object.freeze({ fields: Object.freeze(fields), ...(this.options.startup === undefined ? {} : { startup: Object.freeze({
|
|
448
|
+
globalRevision: this.options.startup.globalRevision, nativeRevision: this.options.startup.nativeRevision
|
|
449
|
+
}) }) }), restartRequired: Object.freeze([...restartRequired]), profile: selection.selectedId === null || selection.appliedRevision === null ? null : Object.freeze({ id: selection.selectedId, revision: selection.appliedRevision }) });
|
|
244
450
|
}
|
|
245
451
|
declaredProfileModel(settings, role) {
|
|
246
452
|
const primary = role === undefined ? undefined : settings.roleRouting[role]?.primary;
|
|
247
|
-
return primary === undefined ? undefined :
|
|
248
|
-
...(primary.reasoningEffort === undefined ? {} : { reasoningEffort: primary.reasoningEffort }) };
|
|
453
|
+
return primary === undefined ? undefined : normalizeModelRouteJson(primary);
|
|
249
454
|
}
|
|
250
455
|
agents() { return this.ctx.get?.("agents"); }
|
|
251
456
|
bind(agent) {
|
|
@@ -263,8 +468,21 @@ export class DsmmProfileRuntime {
|
|
|
263
468
|
// The native factory enters the exact child/owner pair before announcing
|
|
264
469
|
// creation. Durable lineage and inherited persona never establish ownership.
|
|
265
470
|
const parent = this.owner(agent);
|
|
266
|
-
|
|
471
|
+
if (parent === undefined && agent.session.header?.origin === "subagent")
|
|
472
|
+
throw new DsmmProfileError("not-owned", "A child requires exact direct-parent admission, not current root defaults.");
|
|
473
|
+
if (parent !== undefined)
|
|
474
|
+
throw new DsmmProfileError("activation", "A retained child must complete role validation and authority registration before its settings are published.");
|
|
475
|
+
const admitted = this.current;
|
|
476
|
+
this.assertRootRole(agent, admitted.settings);
|
|
477
|
+
this.validateRootRole(agent, admitted);
|
|
267
478
|
this.bound.set(agent, admitted);
|
|
479
|
+
try {
|
|
480
|
+
this.options.childAuthority?.registerParent(agent, admitted, this.options.childAuthorityOwner ?? this);
|
|
481
|
+
}
|
|
482
|
+
catch (error) {
|
|
483
|
+
this.bound.delete(agent);
|
|
484
|
+
throw error;
|
|
485
|
+
}
|
|
268
486
|
return admitted;
|
|
269
487
|
}
|
|
270
488
|
owner(agent) {
|
|
@@ -282,20 +500,37 @@ export class DsmmProfileRuntime {
|
|
|
282
500
|
throw new DsmmProfileError("not-owned", "Session profile selection requires the exact live ordinary root Agent.");
|
|
283
501
|
}
|
|
284
502
|
}
|
|
285
|
-
|
|
503
|
+
/** Host-only awaited completion for fresh, retained and cold exact Agents; no execution occurs here. */
|
|
504
|
+
async completeAdmission(agent, signal, startup) {
|
|
505
|
+
await this.admit(agent, signal, startup);
|
|
506
|
+
return this.bound.get(agent);
|
|
507
|
+
}
|
|
508
|
+
async admit(agent, signal, startup) {
|
|
286
509
|
if (this.bound.has(agent))
|
|
287
510
|
return;
|
|
288
511
|
const parent = this.owner(agent);
|
|
289
512
|
if (parent !== undefined) {
|
|
290
|
-
this.
|
|
513
|
+
this.assertDeliveryFence();
|
|
514
|
+
if (this.options.childAdmission === undefined)
|
|
515
|
+
throw new DsmmProfileError("unavailable", "Child admission completion is not installed; no child policy was inferred from its current parent.");
|
|
516
|
+
const ticket = this.options.childAuthority.acquireParentTicket(parent);
|
|
517
|
+
this.assertOwnedParentTicket(ticket);
|
|
518
|
+
const merged = AbortSignal.any([ticket.signal, ...signal === undefined ? [] : [signal]]);
|
|
519
|
+
const prepared = await this.options.childAdmission.prepare(agent, parent, ticket, merged);
|
|
520
|
+
merged.throwIfAborted();
|
|
521
|
+
await this.completeChildAdmission(agent, parent, prepared, merged);
|
|
291
522
|
return;
|
|
292
523
|
}
|
|
524
|
+
if (agent.session.header?.origin === "subagent")
|
|
525
|
+
throw new DsmmProfileError("not-owned", "A child cannot be admitted as a new root without its exact live direct parent.");
|
|
293
526
|
if (agent.id === undefined) {
|
|
294
527
|
this.bind(agent);
|
|
295
528
|
return;
|
|
296
529
|
}
|
|
297
530
|
this.admitting.add(agent);
|
|
298
531
|
try {
|
|
532
|
+
signal?.throwIfAborted();
|
|
533
|
+
const deployment = startup ?? await this.options.readDesired?.();
|
|
299
534
|
signal?.throwIfAborted();
|
|
300
535
|
const selection = await this.store.loadSessionSelection(agent.id);
|
|
301
536
|
signal?.throwIfAborted();
|
|
@@ -304,20 +539,222 @@ export class DsmmProfileRuntime {
|
|
|
304
539
|
const registry = this.agents();
|
|
305
540
|
if (registry?.get !== undefined && registry.get(agent.id) !== agent)
|
|
306
541
|
throw new DsmmProfileError("not-owned", "The live session changed during profile admission.");
|
|
307
|
-
|
|
542
|
+
const candidate = selection.admissionEpoch === null
|
|
543
|
+
? this.options.readDesired === undefined ? this.current : this.prepare(this.currentDocument, this.current, newEpoch(), "global-default", deployment)
|
|
544
|
+
: this.prepare(selection.document, selection, selection.admissionEpoch, selection.selectedId === null ? "deployment-baseline" : "session-override", deployment);
|
|
545
|
+
this.assertRootRole(agent, candidate.settings);
|
|
546
|
+
this.validateRootRole(agent, candidate);
|
|
547
|
+
if (this.options.readDesired !== undefined)
|
|
548
|
+
await this.validate(candidate.settings);
|
|
549
|
+
signal?.throwIfAborted();
|
|
550
|
+
if (this.disposed || this.disposedAgents.has(agent))
|
|
551
|
+
throw new DsmmProfileError("disposed", "The session was disposed during deployment admission.");
|
|
552
|
+
if (registry?.get !== undefined && registry.get(agent.id) !== agent)
|
|
553
|
+
throw new DsmmProfileError("not-owned", "The live session changed during deployment admission.");
|
|
554
|
+
this.assertRootRole(agent, candidate.settings);
|
|
555
|
+
this.validateRootRole(agent, candidate);
|
|
556
|
+
this.bound.set(agent, candidate);
|
|
557
|
+
try {
|
|
558
|
+
this.options.childAuthority?.registerParent(agent, candidate, this.options.childAuthorityOwner ?? this);
|
|
559
|
+
}
|
|
560
|
+
catch (error) {
|
|
561
|
+
this.bound.delete(agent);
|
|
562
|
+
throw error;
|
|
563
|
+
}
|
|
564
|
+
await this.announceAdmission(agent);
|
|
565
|
+
signal?.throwIfAborted();
|
|
566
|
+
if (this.disposed || this.disposedAgents.has(agent))
|
|
567
|
+
throw new DsmmProfileError("disposed", "Root enrollment lost its live admission.");
|
|
568
|
+
if (registry?.get !== undefined && registry.get(agent.id) !== agent)
|
|
569
|
+
throw new DsmmProfileError("not-owned", "Root enrollment lost its exact residency.");
|
|
308
570
|
}
|
|
309
571
|
finally {
|
|
310
572
|
this.admitting.delete(agent);
|
|
311
573
|
}
|
|
312
574
|
}
|
|
313
|
-
|
|
575
|
+
/** Awaited native creation completion: evidence + persistence + role identity + exact-parent authority. */
|
|
576
|
+
async completeChildAdmission(agent, parent, prepared, signal) {
|
|
577
|
+
this.assertDeliveryFence();
|
|
578
|
+
if (this.options.childAdmission === undefined)
|
|
579
|
+
throw new DsmmProfileError("unavailable", "Child role validation is unavailable.");
|
|
580
|
+
const ticket = this.options.childAuthority.acquireParentTicket(parent);
|
|
581
|
+
this.assertOwnedParentTicket(ticket);
|
|
582
|
+
const merged = AbortSignal.any([ticket.signal, ...signal === undefined ? [] : [signal]]);
|
|
583
|
+
const evidence = "mode" in prepared.evidence ? parseLegacyChildEvidence(prepared.evidence) : parseChildAdmissionCapture(prepared.evidence);
|
|
584
|
+
const check = () => {
|
|
585
|
+
merged.throwIfAborted();
|
|
586
|
+
if (this.disposed || this.disposedAgents.has(agent) || this.owner(agent) !== parent || this.agents()?.get?.(agent.id) !== agent || this.agents()?.get?.(parent.id) !== parent || evidence.childSessionId !== agent.id || evidence.parentSessionId !== parent.id)
|
|
587
|
+
throw new DsmmProfileError("not-owned", "The exact child or its direct parent changed during admission.");
|
|
588
|
+
const current = this.options.childAuthority.acquireParentTicket(parent);
|
|
589
|
+
this.assertOwnedParentTicket(current);
|
|
590
|
+
if (current.admission !== ticket.admission || current.owner !== ticket.owner)
|
|
591
|
+
throw new DsmmProfileError("conflict", "The child creation parent ticket changed.");
|
|
592
|
+
};
|
|
593
|
+
check();
|
|
594
|
+
if (prepared.creation && "mode" in evidence)
|
|
595
|
+
throw new DsmmProfileError("validation", "New children require a full original capture, not legacy evidence.");
|
|
596
|
+
const original = "mode" in evidence ? prepared.admission : admissionFromChildCapture(evidence, this.baseline);
|
|
597
|
+
const retained = childAdmissions.get(agent);
|
|
598
|
+
if (retained !== undefined && retained.parent !== parent)
|
|
599
|
+
throw new DsmmProfileError("not-owned", "The retained child's exact direct parent changed.");
|
|
600
|
+
if (retained !== undefined && prepared.creation)
|
|
601
|
+
throw new DsmmProfileError("validation", "A retained child cannot be admitted as a new creation.");
|
|
602
|
+
if (retained !== undefined && JSON.stringify(retained.evidence) !== JSON.stringify(evidence))
|
|
603
|
+
throw new DsmmProfileError("corrupt-selection", "Retained child evidence cannot be replaced by a new parent policy.");
|
|
604
|
+
const admission = retained?.admission ?? freezeSettings({ ...original, baseline: original.settings,
|
|
605
|
+
selectedId: original.profile?.id ?? null, appliedRevision: original.profile?.revision ?? null, selectionRevision: "absent" });
|
|
606
|
+
if (!("mode" in evidence)) {
|
|
607
|
+
if (prepared.creation && evidence.originalAdmissionEpoch !== ticket.parentEpoch)
|
|
608
|
+
throw new DsmmProfileError("conflict", "The child creation invocation epoch changed.");
|
|
609
|
+
if (prepared.admission.epoch !== evidence.originalAdmissionEpoch || JSON.stringify(prepared.admission.profile) !== JSON.stringify(evidence.profilePin))
|
|
610
|
+
throw new DsmmProfileError("validation", "Child admission identity does not match its original capture.");
|
|
611
|
+
if (this.options.childCapturePersistence === "resident") {
|
|
612
|
+
if (!prepared.creation && retained === undefined)
|
|
613
|
+
throw new DsmmProfileError("unavailable", "Resident-only child capture has no cold restart guarantee.");
|
|
614
|
+
}
|
|
615
|
+
else {
|
|
616
|
+
if (this.childCaptureStore.readChildAdmission === undefined || this.childCaptureStore.createChildAdmission === undefined)
|
|
617
|
+
throw new DsmmProfileError("unavailable", "Durable child capture storage is unavailable.");
|
|
618
|
+
if (prepared.creation)
|
|
619
|
+
await this.childCaptureStore.createChildAdmission(evidence, check);
|
|
620
|
+
else {
|
|
621
|
+
const stored = await this.childCaptureStore.readChildAdmission(evidence.childSessionId, evidence.parentSessionId);
|
|
622
|
+
if (JSON.stringify(stored) !== JSON.stringify(evidence))
|
|
623
|
+
throw new DsmmProfileError("corrupt-selection", "The child evidence does not match its immutable stored capture.");
|
|
624
|
+
}
|
|
625
|
+
}
|
|
626
|
+
}
|
|
627
|
+
else {
|
|
628
|
+
if (prepared.admission.profile !== null)
|
|
629
|
+
throw new DsmmProfileError("validation", "Legacy admission cannot synthesize an original profile pin.");
|
|
630
|
+
if (this.childCaptureStore.readChildAdmission === undefined)
|
|
631
|
+
throw new DsmmProfileError("unavailable", "Legacy admission requires a safe capture-absence check.");
|
|
632
|
+
if (await this.childCaptureStore.readChildAdmission(evidence.childSessionId, evidence.parentSessionId) !== null)
|
|
633
|
+
throw new DsmmProfileError("corrupt-selection", "A captured child cannot be downgraded to legacy recovery.");
|
|
634
|
+
}
|
|
635
|
+
check();
|
|
636
|
+
this.options.childAdmission.validateRole(agent, parent, { ...prepared, evidence, admission, retained: retained !== undefined });
|
|
637
|
+
check();
|
|
638
|
+
this.bound.set(agent, admission);
|
|
639
|
+
try {
|
|
640
|
+
this.options.childAuthority.registerParent(agent, admission, this.options.childAuthorityOwner ?? this);
|
|
641
|
+
}
|
|
642
|
+
catch (error) {
|
|
643
|
+
this.bound.delete(agent);
|
|
644
|
+
throw error;
|
|
645
|
+
}
|
|
646
|
+
childAdmissions.set(agent, { parent, admission, evidence });
|
|
647
|
+
await this.announceAdmission(agent);
|
|
648
|
+
check();
|
|
649
|
+
}
|
|
650
|
+
/** C's scoped resolver callback: original resident/durable evidence, then explicit trusted legacy folds. */
|
|
651
|
+
async resolveOriginalChildEvidence(ticket, childId, signal, readLegacy) {
|
|
652
|
+
validateSessionProfileId(childId);
|
|
653
|
+
const merged = AbortSignal.any([ticket.signal, signal]);
|
|
654
|
+
const check = () => {
|
|
655
|
+
merged.throwIfAborted();
|
|
656
|
+
this.assertDeliveryFence();
|
|
657
|
+
if (this.disposed || this.disposedAgents.has(ticket.parent) || this.agents()?.get?.(ticket.parent.id) !== ticket.parent)
|
|
658
|
+
throw new DsmmProfileError("not-owned", "Original child evidence requires its exact live direct parent.");
|
|
659
|
+
const current = this.options.childAuthority.acquireParentTicket(ticket.parent);
|
|
660
|
+
this.assertOwnedParentTicket(current);
|
|
661
|
+
if (current.owner !== ticket.owner || current.admission !== ticket.admission || current.parentEpoch !== ticket.parentEpoch)
|
|
662
|
+
throw new DsmmProfileError("conflict", "The original child evidence ticket changed.");
|
|
663
|
+
};
|
|
664
|
+
check();
|
|
665
|
+
const child = this.agents().get(childId);
|
|
666
|
+
if (child !== undefined && this.owner(child) !== ticket.parent)
|
|
667
|
+
throw new DsmmProfileError("not-owned", "Original evidence is scoped to the actual direct child, not an ancestor.");
|
|
668
|
+
const retained = child === undefined ? undefined : childAdmissions.get(child);
|
|
669
|
+
if (retained !== undefined && retained.parent !== ticket.parent)
|
|
670
|
+
throw new DsmmProfileError("not-owned", "The retained evidence has a different exact parent.");
|
|
671
|
+
const checkChild = () => {
|
|
672
|
+
const current = this.agents().get(childId);
|
|
673
|
+
if (current !== undefined && this.owner(current) !== ticket.parent)
|
|
674
|
+
throw new DsmmProfileError("not-owned", "The addressed child's direct owner changed during evidence reading.");
|
|
675
|
+
if (retained !== undefined && (current !== child || childAdmissions.get(child) !== retained))
|
|
676
|
+
throw new DsmmProfileError("conflict", "The retained child residency changed during evidence reading.");
|
|
677
|
+
};
|
|
678
|
+
const stored = await this.childCaptureStore.readChildAdmission?.(childId, ticket.parent.id);
|
|
679
|
+
check();
|
|
680
|
+
checkChild();
|
|
681
|
+
if (stored !== undefined && stored !== null) {
|
|
682
|
+
const capture = parseChildAdmissionCapture(stored);
|
|
683
|
+
if (capture.childSessionId !== childId || capture.parentSessionId !== ticket.parent.id || retained !== undefined && JSON.stringify(retained.evidence) !== JSON.stringify(capture))
|
|
684
|
+
throw new DsmmProfileError("corrupt-selection", "Original child capture identity does not match its scoped residency.");
|
|
685
|
+
return capture;
|
|
686
|
+
}
|
|
687
|
+
if (retained !== undefined) {
|
|
688
|
+
if (!("mode" in retained.evidence)) {
|
|
689
|
+
if (this.options.childCapturePersistence !== "resident")
|
|
690
|
+
throw new DsmmProfileError("corrupt-selection", "The durable original child capture is missing; legacy recovery is not allowed.");
|
|
691
|
+
return retained.evidence;
|
|
692
|
+
}
|
|
693
|
+
if (stored === undefined)
|
|
694
|
+
throw new DsmmProfileError("unavailable", "Legacy evidence requires a safe capture-absence check.");
|
|
695
|
+
return retained.evidence;
|
|
696
|
+
}
|
|
697
|
+
if (stored === undefined || readLegacy === undefined)
|
|
698
|
+
throw new DsmmProfileError("unavailable", "Original capture is unavailable; only an explicit trusted legacy evidence reader can recover a captureless child.");
|
|
699
|
+
const evidence = parseLegacyChildEvidence(await readLegacy(ticket, childId, merged));
|
|
700
|
+
check();
|
|
701
|
+
checkChild();
|
|
702
|
+
if (evidence.childSessionId !== childId || evidence.parentSessionId !== ticket.parent.id)
|
|
703
|
+
throw new DsmmProfileError("not-owned", "Legacy evidence does not identify the addressed direct child.");
|
|
704
|
+
return evidence;
|
|
705
|
+
}
|
|
706
|
+
assertOwnedParentTicket(ticket) {
|
|
707
|
+
if (ticket.owner !== (this.options.childAuthorityOwner ?? this) || this.bound.get(ticket.parent) !== ticket.admission || ticket.parentEpoch !== ticket.admission.epoch)
|
|
708
|
+
throw new DsmmProfileError("not-owned", "Child admission requires this entry's exact completed parent admission and owner.");
|
|
709
|
+
}
|
|
710
|
+
subagentRuntimeView() {
|
|
711
|
+
const view = this.options.childAuthority?.view() ?? { binding: "unavailable", deliveryFenceReady: false, restartRequired: true, reason: "explicit-composition-required" };
|
|
712
|
+
if (view.binding === "dsmm" && view.deliveryFenceReady && (this.options.childAdmission === undefined || this.options.validateRootRole === undefined))
|
|
713
|
+
return { ...view, deliveryFenceReady: false, restartRequired: true, reason: "authority-not-ready" };
|
|
714
|
+
return view;
|
|
715
|
+
}
|
|
716
|
+
assertDeliveryFence() {
|
|
717
|
+
const view = this.subagentRuntimeView();
|
|
718
|
+
if (view.binding !== "dsmm" || !view.deliveryFenceReady || this.options.childAuthority === undefined)
|
|
719
|
+
throw new DsmmProfileError("unavailable", "This operation requires the explicit DSMM SubagentRuntime composition and ready Host admission authority; configure and restart before retrying.");
|
|
720
|
+
}
|
|
721
|
+
assertRootRole(agent, settings) {
|
|
722
|
+
const role = resolveSelectedAgentPreset(agent.session);
|
|
723
|
+
if (isDsmmRoleId(role) && (!settings.modules.deepwork.enabled || !settings.roles[role]))
|
|
724
|
+
throw new DsmmProfileError("activation", "The selected root role is disabled by the candidate admission.", `settings.roles.${role}`, "deployment-ceiling");
|
|
725
|
+
if (role === "dsmm-planner" && !settings.presets.plannerRootEnabled)
|
|
726
|
+
throw new DsmmProfileError("activation", "The Planner root preset is disabled in the startup admission.", "settings.presets.plannerRootEnabled", "deployment-ceiling");
|
|
727
|
+
}
|
|
728
|
+
validateRootRole(agent, admission) {
|
|
729
|
+
if (this.options.childAuthority !== undefined && this.options.validateRootRole === undefined)
|
|
730
|
+
throw new DsmmProfileError("unavailable", "Root role admission completion is unavailable; no direct-parent authority was registered.");
|
|
731
|
+
this.options.validateRootRole?.(agent, admission);
|
|
732
|
+
}
|
|
733
|
+
roleAvailability(settings, baseline, deployment, document) {
|
|
734
|
+
return DSMM_ROLES.map(role => {
|
|
735
|
+
const required = requiredReason(settings, role.id), named = document?.settings.roles?.[role.id];
|
|
736
|
+
const startup = this.baseline.roles[role.id], desired = deployment?.settings.roles[role.id] ?? baseline.roles[role.id];
|
|
737
|
+
const admitted = settings.modules.deepwork.enabled && settings.roles[role.id];
|
|
738
|
+
const reason = !settings.modules.deepwork.enabled ? "module-off" : !desired ? "deployment-disabled" : !startup ? "startup-unavailable" : named === false ? "profile-disabled" : undefined;
|
|
739
|
+
const startupCeiling = !startup && desired;
|
|
740
|
+
const source = named !== undefined ? "named-session" : startupCeiling ? this.options.startup?.sources[`roles.${role.id}`] ?? "defaults" : deployment?.sources[`roles.${role.id}`] ?? "defaults";
|
|
741
|
+
const capture = named !== undefined ? "named-session" : startupCeiling ? "startup" : "deployment";
|
|
742
|
+
return { id: role.id, required: required !== undefined, ...(required === undefined ? {} : { requiredReason: required }), startupAvailable: startup, deploymentEnabled: desired,
|
|
743
|
+
...(named === undefined ? {} : { namedEnabled: named }), admitted, ...(reason === undefined ? {} : { reason }), source, capture };
|
|
744
|
+
});
|
|
745
|
+
}
|
|
746
|
+
async validate(settings, auditPresets = true) {
|
|
747
|
+
if (!settings.modules.deepwork.enabled)
|
|
748
|
+
return;
|
|
314
749
|
if (this.options.validateCandidate !== undefined) {
|
|
315
750
|
await this.options.validateCandidate(settings);
|
|
316
751
|
return;
|
|
317
752
|
}
|
|
753
|
+
if (!auditPresets)
|
|
754
|
+
return;
|
|
318
755
|
const registry = this.ctx.get?.("agentPresets");
|
|
319
756
|
if (registry !== undefined) {
|
|
320
|
-
for (const role of DSMM_ROLES.filter((role) =>
|
|
757
|
+
for (const role of DSMM_ROLES.filter((role) => isRootRoleEnabled(settings, role.id))) {
|
|
321
758
|
try {
|
|
322
759
|
const preset = await registry.resolve(role.id);
|
|
323
760
|
if (preset.broken !== undefined)
|
|
@@ -328,39 +765,6 @@ export class DsmmProfileRuntime {
|
|
|
328
765
|
}
|
|
329
766
|
}
|
|
330
767
|
}
|
|
331
|
-
const nativeAgent = agent ?? (this.agents()?.list() ?? []).find((candidate) => candidate.ctx?.get?.("llm")?.resolveCallConfig !== undefined);
|
|
332
|
-
const inherited = nativeAgent?.options;
|
|
333
|
-
const inheritedRoute = inherited?.provider === undefined || inherited.model === undefined ? undefined
|
|
334
|
-
: { provider: inherited.provider, model: inherited.model, ...(inherited.reasoningEffort === undefined ? {} : { reasoningEffort: inherited.reasoningEffort }) };
|
|
335
|
-
const chains = [];
|
|
336
|
-
for (const role of DSMM_ROLES) {
|
|
337
|
-
if (!settings.roles[role.id])
|
|
338
|
-
continue;
|
|
339
|
-
const policy = resolveRoleRuntimePolicy(settings, role.id);
|
|
340
|
-
// No explicit primary inherits native routing. Dormant fallbacks alone
|
|
341
|
-
// cannot make a usable inherited route fail profile Apply. If that exact
|
|
342
|
-
// route is unavailable here, native request preflight remains authority.
|
|
343
|
-
if (policy.primary === undefined && inheritedRoute === undefined)
|
|
344
|
-
continue;
|
|
345
|
-
const routes = [policy.primary ?? inheritedRoute, ...policy.fallbackRoutes];
|
|
346
|
-
if (routes.length > 0)
|
|
347
|
-
chains.push({ routes, field: `settings.roleRouting.${role.id}.${policy.primary === undefined ? "fallbackRoutes" : "primary"}` });
|
|
348
|
-
}
|
|
349
|
-
if (chains.length === 0)
|
|
350
|
-
return;
|
|
351
|
-
const llm = nativeAgent?.ctx?.get?.("llm")
|
|
352
|
-
?? this.ctx.get?.("llm") ?? (this.ctx.get === undefined ? this.ctx.llm : undefined);
|
|
353
|
-
if (llm?.resolveCallConfig === undefined) {
|
|
354
|
-
throw new DsmmProfileError("activation", "Open a chat so its native model service can validate configured routes before applying this profile.");
|
|
355
|
-
}
|
|
356
|
-
for (const { routes, field } of chains) {
|
|
357
|
-
try {
|
|
358
|
-
await selectInitialModelRoute(llm, routes, signal);
|
|
359
|
-
}
|
|
360
|
-
catch {
|
|
361
|
-
throw new DsmmProfileError("activation", "The configured provider, model or exact reasoning effort is unavailable in the native model catalog.", field);
|
|
362
|
-
}
|
|
363
|
-
}
|
|
364
768
|
}
|
|
365
769
|
}
|
|
366
770
|
function newEpoch() { return createHash("sha256").update(randomUUID()).digest("hex"); }
|
|
@@ -372,7 +776,22 @@ export async function createProfileRuntime(ctx, baseline, options = {}) {
|
|
|
372
776
|
const profile = ctx.get?.("profileContext");
|
|
373
777
|
if (typeof profile?.dir !== "string" || profile.dir.trim() === "")
|
|
374
778
|
throw new DsmmProfileError("activation", "Deepwork profiles require the native deployment profile directory.");
|
|
375
|
-
const
|
|
779
|
+
const legacy = join(profile.dir, "dsmm-profiles");
|
|
780
|
+
let exists = false;
|
|
781
|
+
try {
|
|
782
|
+
lstatSync(legacy);
|
|
783
|
+
exists = true;
|
|
784
|
+
}
|
|
785
|
+
catch (error) {
|
|
786
|
+
if (!(error !== null && typeof error === "object" && "code" in error && error.code === "ENOENT"))
|
|
787
|
+
throw new DsmmProfileError("unsafe-path", "The current profile's legacy store could not be safely checked.");
|
|
788
|
+
}
|
|
789
|
+
// Loader callers use its actual public entry key. The old trusted non-Loader
|
|
790
|
+
// constructor path has one compatibility namespace, not a guessed entry.
|
|
791
|
+
const entry = options.startup?.entryId ?? (ctx instanceof Context ? ctx.fiber.entry?.id : undefined) ?? "trusted-direct";
|
|
792
|
+
const store = exists ? ProfileStore.fromLegacy(legacy) : ProfileStore.fromCentral(resolveDshHome(profile.home), profile.dir, entry);
|
|
793
|
+
const childCaptureStore = options.childCaptureStore ?? (exists ? ProfileStore.fromCentral(resolveDshHome(profile.home), profile.dir, entry) : store);
|
|
794
|
+
const runtime = new DsmmProfileRuntime(ctx, baseline, store, { ...options, childCaptureStore });
|
|
376
795
|
await runtime.initialize();
|
|
377
796
|
return runtime;
|
|
378
797
|
}
|