@dsmm/dsmm 0.2.0 → 0.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +38 -66
- package/agent-presets/dsmm-builder/agent.cordis.yml +10 -2015
- package/agent-presets/dsmm-clarifier/agent.cordis.yml +24 -343
- package/agent-presets/dsmm-code-search/agent.cordis.yml +19 -6
- package/agent-presets/dsmm-coding/agent.cordis.yml +19 -438
- package/agent-presets/dsmm-complex/agent.cordis.yml +23 -1009
- package/agent-presets/dsmm-creative/agent.cordis.yml +25 -442
- package/agent-presets/dsmm-cross-cutting/agent.cordis.yml +29 -1013
- package/agent-presets/dsmm-deep/agent.cordis.yml +24 -1008
- package/agent-presets/dsmm-doc-search/agent.cordis.yml +19 -6
- package/agent-presets/dsmm-documenting/agent.cordis.yml +26 -439
- package/agent-presets/dsmm-frontend/agent.cordis.yml +21 -440
- package/agent-presets/dsmm-hard-reasoning/agent.cordis.yml +22 -441
- package/agent-presets/dsmm-media-reader/agent.cordis.yml +19 -6
- package/agent-presets/dsmm-normal-task/agent.cordis.yml +19 -438
- package/agent-presets/dsmm-oracle/agent.cordis.yml +25 -340
- package/agent-presets/dsmm-oracle-2nd/agent.cordis.yml +25 -340
- package/agent-presets/dsmm-orchestrator/agent.cordis.yml +29 -2025
- package/agent-presets/dsmm-plan-critic/agent.cordis.yml +24 -341
- package/agent-presets/dsmm-planner/agent.cordis.yml +14 -344
- package/agent-presets/dsmm-quick/agent.cordis.yml +19 -6
- package/agent-presets/dsmm-research/agent.cordis.yml +23 -8
- package/agent-presets/dsmm-reviewer/agent.cordis.yml +25 -340
- package/docs/agent-presets.md +36 -52
- package/docs/compatibility.md +50 -108
- package/docs/deferred-native-approval-risk.md +19 -0
- package/docs/design.md +2 -2
- package/docs/lsp.md +11 -21
- package/docs/migration-from-ocmm.md +2 -2
- package/docs/model-routing.md +84 -59
- package/docs/native-permissions.md +35 -0
- package/docs/profiles.md +40 -87
- package/docs/releasing.md +83 -2
- package/docs/roadmap.md +71 -17
- package/docs/settings-status.md +34 -169
- package/docs/skill-sync.md +52 -15
- 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.js +15 -8
- 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 +30 -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-data.d.ts +2 -1
- package/lib/client/deployment-data.js +34 -5
- package/lib/client/deployment-locales.d.ts +4 -0
- package/lib/client/deployment-locales.js +11 -2
- 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 +96 -2
- package/lib/client/locales.d.ts +54 -0
- package/lib/client/locales.js +34 -16
- 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/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 +20 -0
- package/lib/client.js +5780 -1679
- 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 +23 -0
- package/lib/deployment-config.js +61 -40
- package/lib/deployment-permission-rules.d.ts +55 -0
- package/lib/deployment-permission-rules.js +306 -0
- package/lib/dsh-types.d.ts +10 -4
- package/lib/guards.d.ts +1 -1
- package/lib/guards.js +29 -8
- 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 +15 -4
- package/lib/index.js +300 -47
- 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/managed-settings.d.ts +5 -0
- package/lib/managed-settings.js +14 -0
- package/lib/model-parameter-policy.d.ts +11 -0
- package/lib/model-parameter-policy.js +27 -0
- package/lib/model-routing.js +28 -17
- package/lib/modules.d.ts +13 -5
- package/lib/modules.js +17 -1
- 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.js +1 -1
- 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/preset-registry.js +36 -25
- 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 +8 -0
- package/lib/profile-remote.js +163 -39
- package/lib/profile-rpc.d.ts +4 -3
- package/lib/profile-rpc.js +14 -12
- package/lib/profile-runtime.d.ts +40 -1
- package/lib/profile-runtime.js +368 -93
- package/lib/profile-store.d.ts +11 -0
- package/lib/profile-store.js +143 -11
- package/lib/profile-types.d.ts +70 -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.js +1 -1
- package/lib/prompts.d.ts +37 -2
- package/lib/prompts.js +111 -9
- 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 +49 -8
- package/lib/role-policy.js +437 -60
- package/lib/role-providers.d.ts +1 -1
- package/lib/role-providers.js +30 -35
- 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 +58 -3
- package/lib/role-subagents.js +169 -56
- package/lib/roles.d.ts +5 -6
- package/lib/roles.js +10 -39
- 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 +18 -8
- package/lib/settings.d.ts +47 -13
- package/lib/settings.js +217 -82
- package/lib/skills.js +2 -2
- package/lib/status.d.ts +10 -1
- package/lib/status.js +11 -8
- package/lib/subagent-runtime.d.ts +45 -0
- package/lib/subagent-runtime.js +131 -0
- package/package.json +106 -56
- 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 +27 -18
- package/prompts/source/agents/clarifier.md +5 -3
- package/prompts/source/agents/orchestrator.md +18 -9
- package/prompts/source/agents/plan-critic.md +5 -1
- package/prompts/source/agents/planner.md +4 -2
- package/prompts/source/agents/reviewer.md +6 -0
- package/prompts/source/category/complex.md +4 -4
- package/prompts/source/category/creative.md +6 -4
- package/prompts/source/category/cross-cutting.md +10 -8
- package/prompts/source/category/deep.md +5 -3
- package/prompts/source/category/documenting.md +7 -1
- package/prompts/source/category/frontend.md +2 -2
- package/prompts/source/category/hard-reasoning.md +3 -3
- package/prompts/source/category/research.md +4 -2
- package/prompts/source/deepwork/claude-opus-5.md +2 -2
- package/prompts/source/deepwork/codex.md +1 -1
- package/prompts/source/deepwork/default.md +22 -15
- package/prompts/source/deepwork/gemini.md +23 -16
- package/prompts/source/deepwork/glm.md +21 -14
- package/prompts/source/deepwork/gpt.md +12 -6
- package/prompts/source/deepwork/planner.md +8 -5
- package/prompts/source/manifest.json +178 -63
- package/prompts/source/shared/dsh-host-contract.md +5 -3
- package/prompts/source/shared/locale.md +2 -2
- package/prompts/source/terminal/orchestrator.md +1 -1
- 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/SKILL.md +7 -4
- package/skills/brainstorming/SKILL.md +43 -22
- package/skills/coding-agent-sessions/SKILL.md +7 -4
- package/skills/coding-agent-sessions/scripts/agent_sessions/pi_family.py +46 -46
- package/skills/coding-agent-sessions/scripts/tests/test_pi_family_scanners.py +130 -130
- package/skills/debugging/SKILL.md +14 -9
- package/skills/debugging/references/methodology/00-setup.md +14 -62
- package/skills/debugging/references/methodology/02-investigate.md +4 -4
- package/skills/debugging/references/methodology/03-flaky-triage.md +3 -3
- package/skills/debugging/references/methodology/04-hard-reasoning-escalation.md +2 -14
- package/skills/debugging/references/methodology/06-fix.md +6 -6
- package/skills/debugging/references/methodology/08-qa.md +5 -5
- package/skills/debugging/references/methodology/09-cleanup.md +15 -153
- package/skills/debugging/references/methodology/partial-runtime-evidence.md +3 -16
- package/skills/debugging/references/runtimes/bundled-js-binary.md +1 -16
- package/skills/debugging/references/runtimes/native-binary.md +9 -54
- package/skills/debugging/references/runtimes/node.md +4 -15
- package/skills/debugging/references/runtimes/python.md +3 -15
- package/skills/debugging/references/runtimes/rust.md +2 -18
- package/skills/debugging/references/tools/dap.md +1 -1
- package/skills/debugging/references/tools/ghidra.md +4 -15
- package/skills/debugging/references/tools/playwright-cli.md +3 -15
- package/skills/debugging/references/tools/pwntools.md +4 -16
- package/skills/dispatching-parallel-agents/SKILL.md +18 -16
- package/skills/frontend/SKILL.md +7 -4
- package/skills/frontend/references/design/react-dev-tooling-skill.md +1 -1
- package/skills/git-master/SKILL.md +7 -4
- package/skills/init-deep/SKILL.md +7 -4
- package/skills/receiving-code-review/SKILL.md +17 -12
- package/skills/remove-ai-slops/SKILL.md +39 -38
- package/skills/requesting-code-review/SKILL.md +19 -17
- package/skills/requesting-code-review/code-reviewer.md +13 -1
- package/skills/subagent-driven-development/SKILL.md +29 -26
- package/skills/subagent-driven-development/implementer-prompt.md +29 -11
- package/skills/subagent-driven-development/spec-reviewer-prompt.md +6 -1
- package/skills/using-git-worktrees/SKILL.md +7 -4
- package/skills/writing-plans/SKILL.md +29 -24
- package/skills/writing-plans/plan-document-reviewer-prompt.md +10 -1
package/lib/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Context } from "@deepseek-ai/cordis";
|
|
1
|
+
import { Context, symbols } from "@deepseek-ai/cordis";
|
|
2
2
|
import { registerDeepworkCommand, registerDsmmStatusCommand } from "./commands.js";
|
|
3
3
|
import { registerSafetyGuards } from "./guards.js";
|
|
4
4
|
import { registerDeepworkPrompt } from "./mode.js";
|
|
@@ -14,16 +14,23 @@ import { registerLspRuntime } from "./lsp.js";
|
|
|
14
14
|
import { createProfileRuntime } from "./profile-runtime.js";
|
|
15
15
|
import { DsmmProfilesHost, registerConfigRpc } from "./profile-rpc.js";
|
|
16
16
|
import { DSMM_CONFIG_SCHEMA, DSMM_NATIVE_CONFIG_SCHEMA, registerSettings } from "./settings.js";
|
|
17
|
-
import { DeepworkModeController } from "./state.js";
|
|
17
|
+
import { DeepworkModeController, isDeepworkActive } from "./state.js";
|
|
18
18
|
import DsmmSessionPersistence from "./session-persistence.js";
|
|
19
19
|
import { isAbsolute } from "node:path";
|
|
20
20
|
import { createHash, randomUUID } from "node:crypto";
|
|
21
21
|
import { DsmmProfileError } from "./profiles.js";
|
|
22
22
|
import { DsmmDeploymentConfig } from "./deployment-config.js";
|
|
23
23
|
import { agentForScope } from "./native-scope.js";
|
|
24
|
-
import {
|
|
24
|
+
import { resolveSelectedAgentPreset, sessionEvents } from "./session-scope.js";
|
|
25
|
+
import { projectDsmmModules } from "./modules.js";
|
|
26
|
+
import { scopeLifetime } from "./delivery-authority.js";
|
|
27
|
+
import { admittedAgentContext, classifyDsmmAgent, integrateSubagentRuntime, managedAgentContext, publicProfileRuntime, registerRoleControlContribution, registerRuntimeGuidance, runtimeAdmissionView } from "./runtime-integration.js";
|
|
28
|
+
import { LegacyReadUnavailable } from "./legacy-read-contracts.js";
|
|
29
|
+
import { createCorePermissionAuthority } from "./core-permission-authority.js";
|
|
30
|
+
import { nativeStandingFullAccess } from "./permission-native-access.js";
|
|
31
|
+
import { installCorePermissions } from "./core-permissions.js";
|
|
25
32
|
export const name = "dsmm";
|
|
26
|
-
export const inject = ["profileContext"];
|
|
33
|
+
export const inject = ["profileContext", "agents"];
|
|
27
34
|
// Direct public Config calls keep the complete plain flat ABI. Native Cordis
|
|
28
35
|
// consumes the same object's Standard Schema protocol for sparse volatile refs.
|
|
29
36
|
export const Config = new Proxy(DSMM_NATIVE_CONFIG_SCHEMA, {
|
|
@@ -48,16 +55,33 @@ export { resolveDshHome } from "./dsh-home.js";
|
|
|
48
55
|
export { DsmmDeploymentConfig, parseGlobalConfig, editGlobalConfig } from "./deployment-config.js";
|
|
49
56
|
export { DSMM_MODULE_DESCRIPTORS, deepworkEnabled, projectDeepworkModule } from "./modules.js";
|
|
50
57
|
export { DEEPWORK_MODE_EVENT, DeepworkModeController, hasOpenTurn, isDeepworkActive } from "./state.js";
|
|
51
|
-
export
|
|
52
|
-
|
|
53
|
-
|
|
58
|
+
export { DsmmNativeLlmRuntime } from "./llm-runtime.js";
|
|
59
|
+
/** Experimental Host collaborators are programmatic only; serialized settings cannot authenticate them. */
|
|
60
|
+
export function createDsmmHostPlugin(startup) {
|
|
61
|
+
if (startup.experimentalLegacyRead !== undefined) {
|
|
62
|
+
const host = startup.experimentalLegacyRead.startup;
|
|
63
|
+
if (host === null || typeof host !== "object" || [host.captureClosedComposition, host.resolveReadBindings, host.acquireCallContext,
|
|
64
|
+
host.reportAuditFault, host.reportRetirementFault, host.revoke].some(callback => typeof callback !== "function"))
|
|
65
|
+
throw new DsmmProfileError("unavailable", "Legacy read startup requires actual Host composition, FS, turn and audit collaborators.");
|
|
66
|
+
}
|
|
67
|
+
return { name, Config, inject: startup.experimentalLegacyRead === undefined ? inject : [...inject, "subagents"],
|
|
68
|
+
apply(ctx, config = {}) { return apply(ctx, config, startup); } };
|
|
69
|
+
}
|
|
70
|
+
export function apply(ctx, config = {}, hostStartup = {}) {
|
|
71
|
+
if (!Context.is(ctx)) {
|
|
72
|
+
if (hostStartup.experimentalLegacyRead !== undefined)
|
|
73
|
+
throw new DsmmProfileError("unavailable", "Legacy read requires a real cold native Host.");
|
|
74
|
+
return applyConfigured(ctx, config, undefined, undefined, hostStartup);
|
|
75
|
+
}
|
|
76
|
+
if (hostStartup.experimentalLegacyRead !== undefined && (ctx.get("dsmmProfileRuntime") !== undefined || runtimeAdmissionView(ctx).deliveryFenceReady))
|
|
77
|
+
throw new LegacyReadUnavailable("lifetime-unavailable");
|
|
54
78
|
const deployment = new DsmmDeploymentConfig(ctx, config);
|
|
55
|
-
return deployment.readDesired().then((startup) => applyConfigured(ctx, config, deployment, startup));
|
|
79
|
+
return deployment.readDesired().then((startup) => applyConfigured(ctx, config, deployment, startup, hostStartup));
|
|
56
80
|
}
|
|
57
|
-
function applyConfigured(ctx, config, deployment, startup) {
|
|
81
|
+
function applyConfigured(ctx, config, deployment, startup, hostStartup = {}) {
|
|
58
82
|
// Volatile desired saves retain live realms. An ordinary Loader remount must
|
|
59
83
|
// not replace already-admitted Agent policy/skill realms, including busy Agents.
|
|
60
|
-
if (ctx
|
|
84
|
+
if (Context.is(ctx) && ctx.fiber.entry !== undefined) {
|
|
61
85
|
const native = ctx;
|
|
62
86
|
const owner = ctx.fiber.entry;
|
|
63
87
|
native.on("loader/patch-context", (entry, next) => {
|
|
@@ -74,33 +98,64 @@ function applyConfigured(ctx, config, deployment, startup) {
|
|
|
74
98
|
|| storage.compression !== undefined && !["zstd", "none"].includes(storage.compression)) {
|
|
75
99
|
throw new Error("Deepwork sessionPersistence must preserve an explicit absolute native root and compression");
|
|
76
100
|
}
|
|
77
|
-
if (!(ctx
|
|
101
|
+
if (!Context.is(ctx))
|
|
78
102
|
throw new Error("Deepwork sessionPersistence requires a native Cordis Context");
|
|
79
103
|
const native = ctx;
|
|
80
104
|
if (native.get("sessionPersistence") !== undefined)
|
|
81
105
|
throw new Error("Disable the exact existing JSONL entry at startup before enabling Deepwork sessionPersistence; live replacement is refused");
|
|
82
106
|
const fiber = native.plugin(DsmmSessionPersistence, storage);
|
|
83
|
-
return fiber.await().then(() => applyRuntime(ctx, config, deployment, startup));
|
|
107
|
+
return fiber.await().then(() => applyRuntime(ctx, config, deployment, startup, hostStartup));
|
|
84
108
|
}
|
|
85
|
-
return applyRuntime(ctx, config, deployment, startup);
|
|
109
|
+
return applyRuntime(ctx, config, deployment, startup, hostStartup);
|
|
86
110
|
}
|
|
87
|
-
function applyRuntime(ctx, config, deployment, startup) {
|
|
88
|
-
const
|
|
111
|
+
function applyRuntime(ctx, config, deployment, startup, hostStartup = {}) {
|
|
112
|
+
const native = Context.is(ctx) ? ctx : undefined;
|
|
113
|
+
const lifetime = new AbortController();
|
|
114
|
+
if (native !== undefined)
|
|
115
|
+
scopeLifetime(native, "dsmm: revoke Core startup and admission", () => lifetime.abort());
|
|
116
|
+
let permissionOwner;
|
|
117
|
+
const getMountedPermission = () => {
|
|
118
|
+
if (native === undefined || lifetime.signal.aborted)
|
|
119
|
+
return null;
|
|
120
|
+
const current = native.get("dsmmPermissionController");
|
|
121
|
+
if (current === undefined || (Reflect.get(current, symbols.original) ?? current) !== permissionOwner)
|
|
122
|
+
return null;
|
|
123
|
+
return current?.rules.status().mounted ?? null;
|
|
124
|
+
};
|
|
125
|
+
let rootAdmissionsInitialized = false;
|
|
126
|
+
const completedRootAdmissions = new WeakSet();
|
|
127
|
+
let rolePolicy;
|
|
128
|
+
const controlledParent = (agent) => {
|
|
129
|
+
if (classifyDsmmAgent(agent) === "dsmm")
|
|
130
|
+
return true;
|
|
131
|
+
if (agent.session.header?.origin === "subagent")
|
|
132
|
+
return false;
|
|
133
|
+
// A pending parent admission cannot establish native-child eligibility.
|
|
134
|
+
if (!rootAdmissionsInitialized && !completedRootAdmissions.has(agent))
|
|
135
|
+
return true;
|
|
136
|
+
const settings = getBoundSettings(agent);
|
|
137
|
+
return settings.modules.deepwork.enabled && isDeepworkActive(sessionEvents(agent.session), settings.defaultActive, resolveSelectedAgentPreset(agent.session));
|
|
138
|
+
};
|
|
139
|
+
if (native !== undefined) {
|
|
140
|
+
ctx = managedAgentContext(native, controlledParent);
|
|
141
|
+
}
|
|
142
|
+
const validatingRootModule = new WeakMap();
|
|
143
|
+
const controller = new DeepworkModeController(ctx, (agent) => validatingRootModule.get(agent) ?? getBoundSettings(agent).modules.deepwork.enabled);
|
|
89
144
|
let runtime;
|
|
90
145
|
let profileInitialization;
|
|
91
146
|
let requiresNativeProfiles = ctx.get !== undefined;
|
|
92
|
-
const requireProfileAdmission = () => {
|
|
93
|
-
if (requiresNativeProfiles && runtime === undefined) {
|
|
147
|
+
const requireProfileAdmission = (agent) => {
|
|
148
|
+
if (agent !== undefined && requiresNativeProfiles && runtime === undefined) {
|
|
94
149
|
throw new DsmmProfileError("unavailable", "Native Deepwork profile admission is not ready. No provider request or tool work is allowed.");
|
|
95
150
|
}
|
|
96
151
|
};
|
|
97
152
|
const getBoundSettings = (agent) => {
|
|
98
|
-
requireProfileAdmission();
|
|
153
|
+
requireProfileAdmission(agent);
|
|
99
154
|
return runtime?.getSettings(agent) ?? getSettings();
|
|
100
155
|
};
|
|
101
156
|
const deploymentAdmissions = new WeakMap();
|
|
102
157
|
getBoundSettings.admission = (agent) => {
|
|
103
|
-
requireProfileAdmission();
|
|
158
|
+
requireProfileAdmission(agent);
|
|
104
159
|
const nativeAdmission = runtime?.getSettings.admission?.(agent);
|
|
105
160
|
if (nativeAdmission !== undefined)
|
|
106
161
|
return nativeAdmission;
|
|
@@ -113,10 +168,21 @@ function applyRuntime(ctx, config, deployment, startup) {
|
|
|
113
168
|
return admission;
|
|
114
169
|
};
|
|
115
170
|
getBoundSettings.moduleStates = (agent) => {
|
|
116
|
-
requireProfileAdmission();
|
|
117
|
-
return runtime?.getSettings.moduleStates?.(agent) ??
|
|
171
|
+
requireProfileAdmission(agent);
|
|
172
|
+
return runtime?.getSettings.moduleStates?.(agent) ?? projectDsmmModules(getSettings(), startup, getBoundSettings.admission(agent), false, getMountedPermission);
|
|
173
|
+
};
|
|
174
|
+
getBoundSettings.subagentRuntime = () => native === undefined
|
|
175
|
+
? { binding: "unavailable", deliveryFenceReady: false, restartRequired: true, reason: "explicit-composition-required" }
|
|
176
|
+
: runtimeAdmissionView(native);
|
|
177
|
+
rolePolicy = new DsmmRolePolicy(ctx, getBoundSettings, controller);
|
|
178
|
+
const assertDwDelivery = (agent) => {
|
|
179
|
+
if (rolePolicy.identity(agent).role === undefined)
|
|
180
|
+
return;
|
|
181
|
+
const integration = native?.get("dsmmRuntimeIntegration");
|
|
182
|
+
if (integration === undefined || !integration.runtime.authority.view().deliveryFenceReady)
|
|
183
|
+
throw new DsmmProfileError("unavailable", "Deepwork execution requires its live delivery fence.");
|
|
184
|
+
return integration.bridge.authority.acquireParentTicket(agent);
|
|
118
185
|
};
|
|
119
|
-
const rolePolicy = new DsmmRolePolicy(ctx, getBoundSettings, controller);
|
|
120
186
|
const getSettings = registerSettings(ctx, config, {
|
|
121
187
|
...(startup === undefined ? {} : { resolved: startup.settings }),
|
|
122
188
|
install(readyCtx, getReadySettings) {
|
|
@@ -125,7 +191,7 @@ function applyRuntime(ctx, config, deployment, startup) {
|
|
|
125
191
|
if (deployment !== undefined) {
|
|
126
192
|
readyCtx.provide?.("dsmmDeploymentConfig", deployment);
|
|
127
193
|
readyCtx.inject?.(["typert"], (rpcCtx) => {
|
|
128
|
-
registerConfigRpc(rpcCtx, deployment, getReadySettings(), () => runtime, startup?.sources);
|
|
194
|
+
registerConfigRpc(rpcCtx, deployment, getReadySettings(), () => runtime, startup?.sources, getMountedPermission);
|
|
129
195
|
});
|
|
130
196
|
}
|
|
131
197
|
const install = (installCtx, settingsGetter) => {
|
|
@@ -136,7 +202,11 @@ function applyRuntime(ctx, config, deployment, startup) {
|
|
|
136
202
|
const installCommands = (commandCtx) => {
|
|
137
203
|
if (startupMounted)
|
|
138
204
|
registerDeepworkCommand(commandCtx, controller, settingsGetter);
|
|
139
|
-
|
|
205
|
+
// Status projects live substrate readiness without replacing the exact
|
|
206
|
+
// immutable admission reference used by authority and providers.
|
|
207
|
+
const statusSettings = Object.assign(((agent) => settingsGetter(agent)), settingsGetter);
|
|
208
|
+
statusSettings.admission = agent => ({ ...getBoundSettings.admission(agent), subagentRuntime: getBoundSettings.subagentRuntime() });
|
|
209
|
+
registerDsmmStatusCommand(commandCtx, controller, statusSettings);
|
|
140
210
|
};
|
|
141
211
|
if (installCtx.get !== undefined && installCtx.inject !== undefined)
|
|
142
212
|
installCtx.inject(["commands"], installCommands);
|
|
@@ -144,7 +214,6 @@ function applyRuntime(ctx, config, deployment, startup) {
|
|
|
144
214
|
installCommands(installCtx);
|
|
145
215
|
if (!startupMounted)
|
|
146
216
|
return;
|
|
147
|
-
registerRoleProviders(installCtx, settingsGetter, getReadySettings, rolePolicy);
|
|
148
217
|
// Standing compositions are deployment-only and never replaced on a
|
|
149
218
|
// runtime profile selection. All routes are read from Agent bindings.
|
|
150
219
|
const settings = getReadySettings();
|
|
@@ -155,13 +224,18 @@ function applyRuntime(ctx, config, deployment, startup) {
|
|
|
155
224
|
if (readyCtx.get === undefined) {
|
|
156
225
|
registerRolePresets(readyCtx, getReadySettings);
|
|
157
226
|
install(readyCtx, getReadySettings);
|
|
227
|
+
if (startupMounted)
|
|
228
|
+
registerRoleProviders(readyCtx, getReadySettings, getReadySettings, rolePolicy);
|
|
158
229
|
return;
|
|
159
230
|
}
|
|
160
231
|
requiresNativeProfiles = true;
|
|
161
232
|
const installProfiles = async (profileCtx) => {
|
|
233
|
+
if (native === undefined)
|
|
234
|
+
throw new Error("dsmm native profiles require the actual Cordis Host scope");
|
|
235
|
+
const hostCtx = profileCtx;
|
|
236
|
+
profileCtx = managedAgentContext(hostCtx, controlledParent);
|
|
162
237
|
if (startupMounted) {
|
|
163
|
-
await registerLspRuntime(profileCtx, getReadySettings().lsp, getBoundSettings);
|
|
164
|
-
await registerNativeSubagentControls(profileCtx);
|
|
238
|
+
await registerLspRuntime(profileCtx, { ...getReadySettings().lsp, enabled: false }, getBoundSettings);
|
|
165
239
|
}
|
|
166
240
|
// Standing definitions must exist before initialize audits retained
|
|
167
241
|
// Agents. A missing optional registry still installs later from this
|
|
@@ -169,33 +243,118 @@ function applyRuntime(ctx, config, deployment, startup) {
|
|
|
169
243
|
const presets = registerRolePresets(profileCtx, getReadySettings);
|
|
170
244
|
if (profileCtx.get?.("agentPresets") !== undefined)
|
|
171
245
|
await presets;
|
|
172
|
-
|
|
246
|
+
const integration = await integrateSubagentRuntime(hostCtx, getReadySettings(), rolePolicy, () => runtime, hostStartup);
|
|
247
|
+
lifetime.signal.throwIfAborted();
|
|
248
|
+
if (hostStartup.experimentalLegacyRead !== undefined && integration === undefined)
|
|
249
|
+
throw new DsmmProfileError("unavailable", "Legacy read requires the explicit cold DSMM runtime composition.");
|
|
250
|
+
if (startupMounted && hostCtx.get("subagents") !== undefined) {
|
|
251
|
+
// The actual registry exists now. Alias registration is synchronous and
|
|
252
|
+
// does not wait on a policy-ready provider, avoiding a startup cycle.
|
|
253
|
+
registerRoleProviders({ get: hostCtx.get.bind(hostCtx), effect: callback => hostCtx.effect(() => callback() ?? (() => { })) }, getBoundSettings, getReadySettings, rolePolicy);
|
|
254
|
+
}
|
|
255
|
+
const retainedChildren = profileCtx.get("agents").list().filter(agent => agent.session.header?.origin === "subagent");
|
|
256
|
+
const manager = await createProfileRuntime(profileCtx, getReadySettings(), { modeController: controller,
|
|
257
|
+
getMountedPermission, deferRetainedChildren: integration !== undefined,
|
|
173
258
|
...(startup === undefined ? {} : { startup }), ...(deployment === undefined ? {} : { readDesired: () => deployment.readDesired() }),
|
|
259
|
+
...(integration === undefined ? {} : { childAuthority: integration.bridge.authority, childAuthorityOwner: integration.owner,
|
|
260
|
+
childAdmission: integration.bridge.childAdmission, childCapturePersistence: hostCtx.get("sessionPersistence") === undefined ? "resident" : "durable" }),
|
|
261
|
+
validateRootRole: (agent, admission) => {
|
|
262
|
+
// Candidate identity validation precedes publication. Its mode check
|
|
263
|
+
// must not recursively demand the not-yet-bound live admission.
|
|
264
|
+
validatingRootModule.set(agent, admission.settings.modules.deepwork.enabled);
|
|
265
|
+
try {
|
|
266
|
+
rolePolicy.validateRootRole(agent, admission);
|
|
267
|
+
}
|
|
268
|
+
finally {
|
|
269
|
+
validatingRootModule.delete(agent);
|
|
270
|
+
}
|
|
271
|
+
},
|
|
272
|
+
onAdmissionGuardsInstalled: async (initializing) => {
|
|
273
|
+
runtime = initializing;
|
|
274
|
+
integration?.onAdmissionGuardsInstalled();
|
|
275
|
+
// Native descendants are filtered from their direct parent's actual
|
|
276
|
+
// admission, including a preselected named profile, not startup mode.
|
|
277
|
+
for (const root of hostCtx.agents.roots()) {
|
|
278
|
+
const agent = root;
|
|
279
|
+
await initializing.completeAdmission(agent, undefined, startup);
|
|
280
|
+
completedRootAdmissions.add(agent);
|
|
281
|
+
}
|
|
282
|
+
rootAdmissionsInitialized = true;
|
|
283
|
+
if (integration?.legacyRead !== undefined) {
|
|
284
|
+
profileCtx.on?.("agent/created", async ({ agent, signal }) => {
|
|
285
|
+
await integration.afterChildAdmission(agent, signal);
|
|
286
|
+
}, { global: true });
|
|
287
|
+
}
|
|
288
|
+
},
|
|
174
289
|
subagentCapabilities: {
|
|
175
|
-
backgroundJobs: profileCtx.get?.("jobs") !== undefined
|
|
290
|
+
backgroundJobs: profileCtx.get?.("jobs") !== undefined,
|
|
176
291
|
continuable: profileCtx.get?.("sessionPersistence") !== undefined && profileCtx.get?.("sessionQuery") !== undefined
|
|
177
292
|
&& profileCtx.get?.("subagents")?.getProvider("spawn")?.prepareContinuable !== undefined
|
|
178
|
-
&& profileCtx.get?.("tools")?.get("send_message") !== undefined
|
|
179
293
|
} });
|
|
180
|
-
|
|
181
|
-
|
|
294
|
+
runtime = manager;
|
|
295
|
+
lifetime.signal.throwIfAborted();
|
|
296
|
+
// Retained controlled children enroll only after their awaited admission
|
|
297
|
+
// in the Core-dependent continuation; ordinary Core startup stays independent.
|
|
298
|
+
const admittedCtx = admittedAgentContext(profileCtx, manager);
|
|
299
|
+
install(admittedCtx, getBoundSettings);
|
|
300
|
+
registerRuntimeGuidance(admittedCtx, getBoundSettings, rolePolicy);
|
|
301
|
+
const published = publicProfileRuntime(manager, hostCtx, integration?.legacyRead === undefined ? undefined : integration);
|
|
302
|
+
profileCtx.provide?.("dsmmProfileRuntime", published);
|
|
303
|
+
if (integration !== undefined) {
|
|
304
|
+
hostCtx.provide("dsmmRuntimeIntegration", integration);
|
|
305
|
+
hostCtx.inject(["dsmmCoreLlmOwner"], async (continuationCtx) => {
|
|
306
|
+
const continuation = new AbortController();
|
|
307
|
+
scopeLifetime(continuationCtx, "dsmm: cancel DW startup continuation", () => continuation.abort());
|
|
308
|
+
return integration.continueStartup(async (signal) => {
|
|
309
|
+
const visited = new Set();
|
|
310
|
+
const admit = async (agent) => {
|
|
311
|
+
signal.throwIfAborted();
|
|
312
|
+
lifetime.signal.throwIfAborted();
|
|
313
|
+
if (visited.has(agent))
|
|
314
|
+
return;
|
|
315
|
+
visited.add(agent);
|
|
316
|
+
const parent = hostCtx.agents.list().find(parent => parent !== agent && hostCtx.agents.isOwnedBy(agent.id, parent));
|
|
317
|
+
if (parent !== undefined)
|
|
318
|
+
await admit(parent);
|
|
319
|
+
if (parent !== undefined && classifyDsmmAgent(agent) === "native" && !controlledParent(parent))
|
|
320
|
+
return;
|
|
321
|
+
await manager.completeAdmission(agent, signal, startup);
|
|
322
|
+
await integration.afterChildAdmission(agent, signal);
|
|
323
|
+
};
|
|
324
|
+
for (const agent of retainedChildren)
|
|
325
|
+
if (hostCtx.agents.get(agent.id) === agent)
|
|
326
|
+
await admit(agent);
|
|
327
|
+
signal.throwIfAborted();
|
|
328
|
+
lifetime.signal.throwIfAborted();
|
|
329
|
+
await registerNativeSubagentControls(profileCtx);
|
|
330
|
+
signal.throwIfAborted();
|
|
331
|
+
lifetime.signal.throwIfAborted();
|
|
332
|
+
await registerHeadlessRoleTools(admittedAgentContext(profileCtx, manager), controller, getBoundSettings, rolePolicy, integration);
|
|
333
|
+
signal.throwIfAborted();
|
|
334
|
+
lifetime.signal.throwIfAborted();
|
|
335
|
+
hostCtx.inject(["typert"], scope => integration.registerControls(scope));
|
|
336
|
+
}, AbortSignal.any([lifetime.signal, continuation.signal]));
|
|
337
|
+
});
|
|
338
|
+
}
|
|
339
|
+
else
|
|
340
|
+
registerRoleControlContribution(hostCtx);
|
|
182
341
|
profileCtx.inject?.(["typert"], (rpcCtx) => {
|
|
183
|
-
new DsmmProfilesHost(rpcCtx,
|
|
342
|
+
new DsmmProfilesHost(rpcCtx, published);
|
|
184
343
|
});
|
|
185
|
-
install(profileCtx, runtime.getSettings);
|
|
186
|
-
const admitIdentity = (agent) => {
|
|
187
|
-
rolePolicy.assertModuleAdmission(agent);
|
|
188
|
-
rolePolicy.admit(agent);
|
|
189
|
-
};
|
|
190
|
-
profileCtx.on?.("agent/created", ({ agent }) => { admitIdentity(agent); }, { global: true });
|
|
191
|
-
for (const agent of profileCtx.get?.("agents")?.list() ?? [])
|
|
192
|
-
admitIdentity(agent);
|
|
193
|
-
if (startupMounted)
|
|
194
|
-
await registerHeadlessRoleTools(profileCtx, controller, runtime.getSettings, rolePolicy);
|
|
195
344
|
};
|
|
196
345
|
if (readyCtx.inject !== undefined) {
|
|
197
|
-
|
|
198
|
-
|
|
346
|
+
profileInitialization = new Promise((resolve, reject) => {
|
|
347
|
+
const fiber = readyCtx.inject(["profileContext"], async (profileCtx) => {
|
|
348
|
+
try {
|
|
349
|
+
await installProfiles(profileCtx);
|
|
350
|
+
resolve();
|
|
351
|
+
}
|
|
352
|
+
catch (error) {
|
|
353
|
+
reject(error);
|
|
354
|
+
}
|
|
355
|
+
});
|
|
356
|
+
scopeLifetime(fiber.ctx, "dsmm: cancel Core profile initialization", () => reject(new DsmmProfileError("unavailable", "Core profile initialization was disposed.")));
|
|
357
|
+
});
|
|
199
358
|
}
|
|
200
359
|
else
|
|
201
360
|
throw new Error("dsmm native profiles require asynchronous profileContext injection");
|
|
@@ -214,13 +373,107 @@ function applyRuntime(ctx, config, deployment, startup) {
|
|
|
214
373
|
}, { prepend: true, global: true });
|
|
215
374
|
ctx.on?.("agent/request", async (frame, next) => {
|
|
216
375
|
rolePolicy.assertModuleAdmission(frame.agent);
|
|
376
|
+
assertDwDelivery(frame.agent);
|
|
217
377
|
return next();
|
|
218
378
|
}, { prepend: true, global: true });
|
|
379
|
+
ctx.on?.("tools/execute", async (exec, next) => {
|
|
380
|
+
if (exec.agent === undefined)
|
|
381
|
+
return next();
|
|
382
|
+
return rolePolicy.duringToolExecution(exec, next);
|
|
383
|
+
}, { global: true });
|
|
219
384
|
}
|
|
220
385
|
registerSafetyGuards(ctx, controller, getBoundSettings, ctx.get === undefined ? undefined : rolePolicy);
|
|
221
|
-
|
|
386
|
+
if (native === undefined)
|
|
387
|
+
return profileInitialization;
|
|
388
|
+
native.inject(["tools"], scope => {
|
|
389
|
+
managedAgentContext(scope, controlledParent).on("tools/pre-execute", (exec, next) => rolePolicy.beforeToolDecision(async () => {
|
|
390
|
+
if (exec.agent !== undefined && !nativeStandingFullAccess(scope, exec.agent)) {
|
|
391
|
+
rolePolicy.assertModuleAdmission(exec.agent);
|
|
392
|
+
assertDwDelivery(exec.agent);
|
|
393
|
+
}
|
|
394
|
+
return next();
|
|
395
|
+
}), { prepend: true, global: true });
|
|
396
|
+
managedAgentContext(scope, controlledParent).get("tools").guard(exec => {
|
|
397
|
+
rolePolicy.assertToolExecution(exec);
|
|
398
|
+
});
|
|
399
|
+
});
|
|
400
|
+
if (deployment !== undefined) {
|
|
401
|
+
const permissions = createCorePermissionAuthority(native, { getSettings: getBoundSettings, rolePolicy, signal: lifetime.signal });
|
|
402
|
+
native.inject(["tools"], scope => {
|
|
403
|
+
const installed = installCorePermissions(scope, deployment, permissions.authority, permissions.assertWritable);
|
|
404
|
+
const identity = Reflect.get(installed, symbols.original) ?? installed;
|
|
405
|
+
scopeLifetime(scope, "dsmm: release mounted permission projection", () => { if (permissionOwner === identity)
|
|
406
|
+
permissionOwner = undefined; }, () => { permissionOwner = identity; });
|
|
407
|
+
});
|
|
408
|
+
}
|
|
409
|
+
return Promise.resolve(profileInitialization).then(() => {
|
|
410
|
+
lifetime.signal.throwIfAborted();
|
|
411
|
+
const owner = { async admit(frame) {
|
|
412
|
+
const agent = frame.agent;
|
|
413
|
+
frame.signal.throwIfAborted();
|
|
414
|
+
lifetime.signal.throwIfAborted();
|
|
415
|
+
if (frame.agent.session.header.origin === "subagent" && classifyDsmmAgent(frame.agent) === "native") {
|
|
416
|
+
const registry = native.agents;
|
|
417
|
+
const parents = registry.list().filter(parent => parent !== frame.agent && registry.isOwnedBy(frame.agent.id, parent));
|
|
418
|
+
if (registry.get(frame.agent.id) !== frame.agent || parents.length !== 1
|
|
419
|
+
|| frame.agent.session.header.parentSession !== parents[0].id)
|
|
420
|
+
throw new DsmmProfileError("not-owned", "The native child lost its physical owner.");
|
|
421
|
+
if (!controlledParent(parents[0]))
|
|
422
|
+
return undefined;
|
|
423
|
+
}
|
|
424
|
+
rolePolicy.assertModuleAdmission(agent);
|
|
425
|
+
const admission = getBoundSettings.admission(agent);
|
|
426
|
+
const permissions = native.get("dsmmPermissionController");
|
|
427
|
+
const full = nativeStandingFullAccess(native, frame.agent);
|
|
428
|
+
if (!full && admission.settings.permissionControl.enabled && permissions === undefined)
|
|
429
|
+
throw new DsmmProfileError("unavailable", "Core permission authority is not ready.");
|
|
430
|
+
if (!full)
|
|
431
|
+
await permissions?.rules.refresh();
|
|
432
|
+
frame.signal.throwIfAborted();
|
|
433
|
+
lifetime.signal.throwIfAborted();
|
|
434
|
+
const permissionIdentity = permissions === undefined ? undefined : Reflect.get(permissions, symbols.original) ?? permissions;
|
|
435
|
+
const permissionRevision = full ? undefined : permissions?.rules.getPolicy().revision;
|
|
436
|
+
const permissionSignal = full ? undefined : permissions?.rules.signal;
|
|
437
|
+
const bindPermission = (captured) => {
|
|
438
|
+
if (full)
|
|
439
|
+
return captured;
|
|
440
|
+
const signal = AbortSignal.any([captured.signal, ...permissionSignal === undefined ? [] : [permissionSignal]]);
|
|
441
|
+
const assertCurrent = () => {
|
|
442
|
+
signal.throwIfAborted();
|
|
443
|
+
captured.assertCurrent();
|
|
444
|
+
const current = native.get("dsmmPermissionController");
|
|
445
|
+
if ((current === undefined ? undefined : Reflect.get(current, symbols.original) ?? current) !== permissionIdentity
|
|
446
|
+
|| current?.rules.getPolicy().revision !== permissionRevision
|
|
447
|
+
|| current?.rules.signal !== permissionSignal)
|
|
448
|
+
throw new DsmmProfileError("not-owned", "LLM permission revision changed.");
|
|
449
|
+
};
|
|
450
|
+
assertCurrent();
|
|
451
|
+
return Object.freeze({ ...captured, signal, assertCurrent });
|
|
452
|
+
};
|
|
453
|
+
if (rolePolicy.identity(agent).role !== undefined) {
|
|
454
|
+
const integration = native.get("dsmmRuntimeIntegration");
|
|
455
|
+
if (integration?.runtime.authority.view().deliveryFenceReady !== true)
|
|
456
|
+
throw new DsmmProfileError("unavailable", "Deepwork requests require the live delivery fence.");
|
|
457
|
+
const admitted = await integration.admitLlmRequest(frame.agent, frame.signal);
|
|
458
|
+
if (admitted === undefined)
|
|
459
|
+
throw new DsmmProfileError("not-owned", "Deepwork request lost its role admission.");
|
|
460
|
+
return bindPermission(admitted);
|
|
461
|
+
}
|
|
462
|
+
const signal = AbortSignal.any([frame.signal, lifetime.signal]);
|
|
463
|
+
const assertCurrent = () => {
|
|
464
|
+
signal.throwIfAborted();
|
|
465
|
+
rolePolicy.assertModuleAdmission(agent);
|
|
466
|
+
if (native.get("dsmmCoreLlmOwner") !== owner || getBoundSettings.admission(agent) !== admission)
|
|
467
|
+
throw new DsmmProfileError("not-owned", "Core LLM admission changed.");
|
|
468
|
+
};
|
|
469
|
+
assertCurrent();
|
|
470
|
+
return bindPermission(Object.freeze({ agent: frame.agent, admission, capture: admission, epoch: admission.epoch, signal, assertCurrent }));
|
|
471
|
+
} };
|
|
472
|
+
native.provide("dsmmCoreLlmOwner", owner);
|
|
473
|
+
});
|
|
222
474
|
}
|
|
223
475
|
// Cordis Loader introspects this object's Config/inject; a bare function loses
|
|
224
476
|
// the exported schema and may pass null where required DSMM defaults belong.
|
|
225
|
-
|
|
477
|
+
// Method-form apply keeps Cordis on its awaited callback, not constructor, path.
|
|
478
|
+
export default { name, inject, Config, apply(ctx, config = {}) { return apply(ctx, config); } };
|
|
226
479
|
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import type { Agent } from "@deepseek-ai/dsh-agent";
|
|
2
|
+
import type { ToolDefinition, ToolExecution, ToolGuard, ToolRuntime } from "@deepseek-ai/dsh-tools";
|
|
3
|
+
import type { ChildAdmissionLimitation, ChildEvidenceField, LegacyChildEvidence } from "./child-capture.js";
|
|
4
|
+
import type { DsmmProfileAdmission, DsmmSettings } from "./settings.js";
|
|
5
|
+
import type { LegacyReadCompositionLease } from "./legacy-read-contracts.js";
|
|
6
|
+
import type { LegacyReadProxy } from "./legacy-read-proxy.js";
|
|
7
|
+
export interface LegacyToolCapability {
|
|
8
|
+
readonly kind: "read" | "child-report" | "write" | "shell" | "delegation" | "other";
|
|
9
|
+
/** Stable native definition identity; name alone does not prove parameter permissions. */
|
|
10
|
+
readonly definition: ToolDefinition;
|
|
11
|
+
/** Exact schema/argument contract is audited by the Host/B collaborator, never inferred from a name. */
|
|
12
|
+
assertArguments(arguments_: unknown): void;
|
|
13
|
+
/** A read is admitted only inside the real registered proxy's leased native invocation. */
|
|
14
|
+
readonly operation?: LegacyReadOperationCapability;
|
|
15
|
+
}
|
|
16
|
+
export interface LegacyReadOperationCapability {
|
|
17
|
+
readonly parent: Agent;
|
|
18
|
+
readonly child: Agent;
|
|
19
|
+
readonly definition: ToolDefinition;
|
|
20
|
+
assertLeasedOperation(exec: Readonly<ToolExecution>): void;
|
|
21
|
+
}
|
|
22
|
+
/** Process-local glue for the trusted startup adapter, never a permission-query or wire grant. */
|
|
23
|
+
export declare function createLegacyReadOperationCapability(proxy: LegacyReadProxy, leaseFor: (exec: Readonly<ToolExecution>) => LegacyReadCompositionLease | undefined): LegacyReadOperationCapability;
|
|
24
|
+
export interface LegacyCapabilityCollaborators {
|
|
25
|
+
classifyTool(name: string, tools: ToolRuntime, child: Agent): LegacyToolCapability | undefined;
|
|
26
|
+
/** Exact direct-parent reporting authority only; read permission is decided by the real parent pipeline. */
|
|
27
|
+
assertParentReport?(parent: Agent, child: Agent, arguments_: unknown, definition: ToolDefinition, evidence: LegacyChildEvidence): void;
|
|
28
|
+
/** Older report collaborators may use this spelling. It is NEVER consulted for read. */
|
|
29
|
+
assertParentTool?(parent: Agent, name: string, arguments_: unknown, definition: ToolDefinition): void;
|
|
30
|
+
/** Trusted cold Host inventory of the actual registered child guard; never a permission grant. */
|
|
31
|
+
onGuardInstalled?(child: Agent, guard: ToolGuard): void;
|
|
32
|
+
}
|
|
33
|
+
export interface LegacyToolDenial {
|
|
34
|
+
readonly field: ChildEvidenceField;
|
|
35
|
+
readonly code: ChildAdmissionLimitation["code"];
|
|
36
|
+
}
|
|
37
|
+
/** A restrictive current admission, explicitly NOT a reconstruction of the original settings or epoch. */
|
|
38
|
+
export declare function createConservativeLegacyAdmission(raw: LegacyChildEvidence, parent: DsmmProfileAdmission, nativeSubstrate: DsmmSettings): DsmmProfileAdmission;
|
|
39
|
+
/** Body-before guard for the proven read subset and the native child -> direct-parent report path. */
|
|
40
|
+
export declare class LegacyChildToolPolicy {
|
|
41
|
+
private readonly evidence;
|
|
42
|
+
private readonly parent;
|
|
43
|
+
private readonly child;
|
|
44
|
+
private readonly collaborators;
|
|
45
|
+
constructor(evidence: LegacyChildEvidence, parent: Agent, child: Agent, collaborators: LegacyCapabilityCollaborators);
|
|
46
|
+
denial(name: string, arguments_: unknown, tools: ToolRuntime, exec?: Readonly<ToolExecution>): LegacyToolDenial | undefined;
|
|
47
|
+
assertTool(name: string, arguments_: unknown, tools: ToolRuntime, exec?: Readonly<ToolExecution>): void;
|
|
48
|
+
}
|
|
49
|
+
/** Scoped monotonic native guard; denied bodies never execute, including locally registered tools. */
|
|
50
|
+
export declare function installLegacyChildToolPolicy(evidence: LegacyChildEvidence, parent: Agent, child: Agent, collaborators: LegacyCapabilityCollaborators): () => void;
|
|
51
|
+
//# sourceMappingURL=legacy-child-policy.d.ts.map
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import { randomBytes } from "node:crypto";
|
|
2
|
+
import { SubagentError } from "@deepseek-ai/dsh-subagent";
|
|
3
|
+
import { parseLegacyChildEvidence } from "./child-capture.js";
|
|
4
|
+
import { DSMM_ROLE_IDS } from "./roles.js";
|
|
5
|
+
import { copyJson, freezeSettings, resolveConfig } from "./settings.js";
|
|
6
|
+
const readOperations = new WeakSet();
|
|
7
|
+
/** Process-local glue for the trusted startup adapter, never a permission-query or wire grant. */
|
|
8
|
+
export function createLegacyReadOperationCapability(proxy, leaseFor) {
|
|
9
|
+
const { parent, child, definition } = proxy;
|
|
10
|
+
const capability = Object.freeze({ parent, child, definition, assertLeasedOperation(exec) {
|
|
11
|
+
const lease = leaseFor(exec);
|
|
12
|
+
if (lease === undefined || definition === proxy.nativeDefinition || exec.agent !== child || exec.name !== "read"
|
|
13
|
+
|| child.ctx.tools.get("read", child) !== definition || parent.ctx.tools.get("read", parent) !== proxy.nativeDefinition
|
|
14
|
+
|| lease.bindings.parent !== parent || lease.bindings.child !== child || lease.bindings.definition !== proxy.nativeDefinition
|
|
15
|
+
|| lease.ticket.parent !== parent)
|
|
16
|
+
throw new SubagentError("Legacy read requires the real proxy's leased invocation", "UNAUTHORIZED");
|
|
17
|
+
lease.assertActive();
|
|
18
|
+
} });
|
|
19
|
+
readOperations.add(capability);
|
|
20
|
+
return capability;
|
|
21
|
+
}
|
|
22
|
+
/** A restrictive current admission, explicitly NOT a reconstruction of the original settings or epoch. */
|
|
23
|
+
export function createConservativeLegacyAdmission(raw, parent, nativeSubstrate) {
|
|
24
|
+
const evidence = parseLegacyChildEvidence(raw);
|
|
25
|
+
if (!parent.settings.modules.deepwork.enabled || !parent.settings.roles[evidence.role])
|
|
26
|
+
throw new SubagentError("Current parent denies the legacy role", "UNAUTHORIZED");
|
|
27
|
+
const { locale: _locale, ...substrate } = copyJson(nativeSubstrate);
|
|
28
|
+
const settings = resolveConfig({ ...substrate,
|
|
29
|
+
modules: { deepwork: { enabled: true } },
|
|
30
|
+
roles: Object.fromEntries(DSMM_ROLE_IDS.map(role => [role, role === evidence.role])),
|
|
31
|
+
roleRouting: { [evidence.role]: { primary: evidence.route, fallbackRoutes: [] } },
|
|
32
|
+
defaultActive: evidence.active ?? false,
|
|
33
|
+
skills: Object.fromEntries(Object.keys(substrate.skills).map(skill => [skill, false])),
|
|
34
|
+
deepseekV4ProCalibration: "off", deepseekV4ProDefaultReasoningEffort: "off", deepseekFlashCalibration: "off", deepseekFlashDefaultReasoningEffort: "off",
|
|
35
|
+
workflow: { policy: "risk-based", strictGates: true, reviewCap: 0, finalReviewPolicy: "off" },
|
|
36
|
+
guards: { scope: "always", shellCommandSafety: true, gitWriteGuard: "deny" },
|
|
37
|
+
runtimeRecovery: { enabled: false, fallbackRoutes: [], idleContinuation: { enabled: false } },
|
|
38
|
+
subagents: { toolTopology: "per-role", allowRouteOverride: false, enableRunInBackground: false, backgroundMode: "continuable", maxDepth: evidence.depth },
|
|
39
|
+
});
|
|
40
|
+
return freezeSettings({ settings, profile: null, epoch: randomBytes(32).toString("hex"), scope: "deployment-baseline", childEvidence: {
|
|
41
|
+
mode: "legacy-conservative", parentAdmissionEpoch: parent.epoch, provenFields: evidence.provenFields, limitations: evidence.limitations
|
|
42
|
+
} });
|
|
43
|
+
}
|
|
44
|
+
/** Body-before guard for the proven read subset and the native child -> direct-parent report path. */
|
|
45
|
+
export class LegacyChildToolPolicy {
|
|
46
|
+
evidence;
|
|
47
|
+
parent;
|
|
48
|
+
child;
|
|
49
|
+
collaborators;
|
|
50
|
+
constructor(evidence, parent, child, collaborators) {
|
|
51
|
+
this.evidence = parseLegacyChildEvidence(evidence);
|
|
52
|
+
if (child.id !== evidence.childSessionId || parent.id !== evidence.parentSessionId || child.session.header.parentSession !== parent.id) {
|
|
53
|
+
throw new SubagentError("Legacy tools require exact child/direct-parent identity", "UNAUTHORIZED");
|
|
54
|
+
}
|
|
55
|
+
this.parent = parent;
|
|
56
|
+
this.child = child;
|
|
57
|
+
this.collaborators = collaborators;
|
|
58
|
+
}
|
|
59
|
+
denial(name, arguments_, tools, exec) {
|
|
60
|
+
const capability = this.collaborators.classifyTool(name, tools, this.child);
|
|
61
|
+
if (capability?.kind === "write")
|
|
62
|
+
return { field: "runtime-policy", code: "missing-evidence" };
|
|
63
|
+
if (capability?.kind === "shell")
|
|
64
|
+
return { field: "shell", code: "missing-evidence" };
|
|
65
|
+
if (capability?.kind === "delegation")
|
|
66
|
+
return { field: "delegation", code: "missing-evidence" };
|
|
67
|
+
if (capability === undefined || capability.kind === "other" || tools.get(name, this.child) !== capability.definition)
|
|
68
|
+
return { field: "tool-filter", code: "missing-evidence" };
|
|
69
|
+
if (capability.kind === "read" && (this.evidence.toolFilter?.allow === undefined || !this.evidence.toolFilter.allow.includes(name)
|
|
70
|
+
|| this.evidence.toolFilter.deny?.includes(name)))
|
|
71
|
+
return { field: "tool-filter", code: "missing-evidence" };
|
|
72
|
+
// The report collaborator must check the explicit destination against the exact direct parent.
|
|
73
|
+
try {
|
|
74
|
+
capability.assertArguments(arguments_);
|
|
75
|
+
}
|
|
76
|
+
catch {
|
|
77
|
+
return { field: "tool-filter", code: "missing-evidence" };
|
|
78
|
+
}
|
|
79
|
+
if (capability.kind === "read") {
|
|
80
|
+
const operation = capability.operation;
|
|
81
|
+
if (operation === undefined || !readOperations.has(operation) || operation.parent !== this.parent || operation.child !== this.child
|
|
82
|
+
|| operation.definition !== capability.definition || exec === undefined || exec.agent !== this.child || exec.name !== name
|
|
83
|
+
|| exec.arguments !== arguments_)
|
|
84
|
+
return { field: "tool-filter", code: "unverified" };
|
|
85
|
+
try {
|
|
86
|
+
operation.assertLeasedOperation(exec);
|
|
87
|
+
}
|
|
88
|
+
catch {
|
|
89
|
+
return { field: "tool-filter", code: "unverified" };
|
|
90
|
+
}
|
|
91
|
+
return undefined;
|
|
92
|
+
}
|
|
93
|
+
try {
|
|
94
|
+
if (this.collaborators.assertParentReport !== undefined)
|
|
95
|
+
this.collaborators.assertParentReport(this.parent, this.child, arguments_, capability.definition, this.evidence);
|
|
96
|
+
else if (this.collaborators.assertParentTool !== undefined)
|
|
97
|
+
this.collaborators.assertParentTool(this.parent, name, arguments_, capability.definition);
|
|
98
|
+
else
|
|
99
|
+
throw new SubagentError("Legacy report requires exact parent authority", "UNAUTHORIZED");
|
|
100
|
+
}
|
|
101
|
+
catch {
|
|
102
|
+
return { field: "tool-filter", code: "parent-denied" };
|
|
103
|
+
}
|
|
104
|
+
return undefined;
|
|
105
|
+
}
|
|
106
|
+
assertTool(name, arguments_, tools, exec) {
|
|
107
|
+
if (this.denial(name, arguments_, tools, exec) !== undefined)
|
|
108
|
+
throw new SubagentError("Legacy evidence does not authorize this tool capability", "UNAUTHORIZED");
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
/** Scoped monotonic native guard; denied bodies never execute, including locally registered tools. */
|
|
112
|
+
export function installLegacyChildToolPolicy(evidence, parent, child, collaborators) {
|
|
113
|
+
const tools = child.ctx.get("tools");
|
|
114
|
+
if (tools === undefined)
|
|
115
|
+
throw new SubagentError("Legacy execution requires a native tool guard", "UNAUTHORIZED");
|
|
116
|
+
const policy = new LegacyChildToolPolicy(evidence, parent, child, collaborators);
|
|
117
|
+
const guard = exec => exec.agent !== child || policy.denial(exec.name, exec.arguments, tools, exec) !== undefined
|
|
118
|
+
? "Legacy child capability is not proven by its durable evidence" : undefined;
|
|
119
|
+
const release = tools.guard(guard);
|
|
120
|
+
collaborators.onGuardInstalled?.(child, guard);
|
|
121
|
+
return release;
|
|
122
|
+
}
|
|
123
|
+
//# sourceMappingURL=legacy-child-policy.js.map
|