@dsmm/dsmm 0.3.2 → 0.3.4
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 +2 -2
- package/agent-presets/dsmm-builder/agent.cordis.yml +1 -1
- package/agent-presets/dsmm-clarifier/agent.cordis.yml +1 -1
- package/agent-presets/dsmm-code-search/agent.cordis.yml +1 -1
- package/agent-presets/dsmm-coding/agent.cordis.yml +3 -2
- package/agent-presets/dsmm-complex/agent.cordis.yml +2 -1
- package/agent-presets/dsmm-creative/agent.cordis.yml +1 -1
- package/agent-presets/dsmm-cross-cutting/agent.cordis.yml +1 -1
- package/agent-presets/dsmm-deep/agent.cordis.yml +2 -1
- package/agent-presets/dsmm-doc-search/agent.cordis.yml +1 -1
- package/agent-presets/dsmm-documenting/agent.cordis.yml +1 -1
- package/agent-presets/dsmm-frontend/agent.cordis.yml +4 -2
- package/agent-presets/dsmm-hard-reasoning/agent.cordis.yml +1 -1
- package/agent-presets/dsmm-media-reader/agent.cordis.yml +1 -1
- package/agent-presets/dsmm-normal-task/agent.cordis.yml +3 -2
- package/agent-presets/dsmm-oracle/agent.cordis.yml +1 -1
- package/agent-presets/dsmm-oracle-2nd/agent.cordis.yml +1 -1
- package/agent-presets/dsmm-orchestrator/agent.cordis.yml +11 -1
- package/agent-presets/dsmm-plan-critic/agent.cordis.yml +1 -1
- package/agent-presets/dsmm-planner/agent.cordis.yml +1 -1
- package/agent-presets/dsmm-quick/agent.cordis.yml +2 -1
- package/agent-presets/dsmm-research/agent.cordis.yml +1 -1
- package/agent-presets/dsmm-reviewer/agent.cordis.yml +1 -1
- package/cordis.patch.yml +0 -9
- package/docs/agent-presets.md +5 -5
- package/docs/compatibility.md +2 -6
- package/docs/migration-from-ocmm.md +1 -1
- package/docs/native-permissions.md +11 -3
- package/docs/roadmap.md +31 -11
- package/docs/runtime-recovery.md +30 -2
- package/docs/settings-status.md +7 -5
- package/docs/skill-sync.md +13 -14
- package/lib/client/ChildrenPanel.d.ts +1 -4
- package/lib/client/ChildrenPanel.js +3 -3
- package/lib/client/DeploymentFields.js +12 -1
- package/lib/client/DeploymentPage.d.ts +1 -3
- package/lib/client/DeploymentPage.js +30 -18
- package/lib/client/NativeCommandEntries.js +47 -37
- package/lib/client/PermissionRuleEntries.d.ts +17 -0
- package/lib/client/PermissionRuleEntries.js +70 -0
- package/lib/client/PermissionsPanel.d.ts +1 -3
- package/lib/client/PermissionsPanel.js +5 -4
- package/lib/client/children-locales.d.ts +4 -4
- package/lib/client/controller.js +4 -1
- package/lib/client/deployment-locales.d.ts +2 -2
- package/lib/client/deployment-locales.js +8 -9
- package/lib/client/deployment-modules.d.ts +5 -3
- package/lib/client/deployment-modules.js +4 -4
- package/lib/client/deployment-workspace.d.ts +4 -0
- package/lib/client/deployment-workspace.js +37 -11
- package/lib/client/index.js +2 -7
- package/lib/client/locales.js +131 -119
- package/lib/client/permission-controller.d.ts +13 -0
- package/lib/client/permission-controller.js +50 -23
- package/lib/client/permission-locales.d.ts +28 -30
- package/lib/client/permission-locales.js +38 -38
- package/lib/client/styles.d.ts +1 -1
- package/lib/client/styles.js +8 -8
- package/lib/client.js +2272 -3773
- package/lib/core-permission-authority.js +28 -16
- package/lib/index.d.ts +0 -2
- package/lib/index.js +11 -31
- package/lib/native-admission.d.ts +3 -3
- package/lib/native-admission.js +67 -66
- package/lib/permission-controller.js +1 -1
- package/lib/permission-fs-search.js +1 -2
- package/lib/permission-fs.js +1 -2
- package/lib/permission-native-command.js +6 -4
- package/lib/permission-settings.d.ts +21 -7
- package/lib/permission-settings.js +21 -9
- package/lib/permission-web.js +1 -2
- package/lib/preset-materializer.js +3 -3
- package/lib/preset-registry.d.ts +20 -2
- package/lib/preset-registry.js +46 -17
- package/lib/profile-diagnostics.js +1 -1
- package/lib/profile-remote.js +1 -3
- package/lib/role-identity.d.ts +1 -1
- package/lib/role-identity.js +16 -4
- package/lib/role-policy.d.ts +3 -0
- package/lib/role-policy.js +30 -6
- package/lib/role-subagents.js +6 -4
- package/lib/roles.d.ts +2 -0
- package/lib/roles.js +2 -0
- package/lib/runtime-integration.js +4 -4
- package/lib/settings.d.ts +1 -3
- package/lib/settings.js +8 -10
- package/lib/state.d.ts +4 -1
- package/lib/state.js +37 -6
- package/package.json +1 -5
- package/prompts/deepwork.md +13 -1
- package/prompts/source/agents/orchestrator.md +10 -0
- package/prompts/source/category/coding.md +2 -1
- package/prompts/source/category/complex.md +1 -0
- package/prompts/source/category/deep.md +1 -0
- package/prompts/source/category/frontend.md +3 -1
- package/prompts/source/category/normal-task.md +2 -1
- package/prompts/source/category/quick.md +1 -0
- package/prompts/source/deepwork/claude-opus-5.md +2 -0
- package/prompts/source/deepwork/default.md +12 -0
- package/prompts/source/deepwork/gemini.md +6 -1
- package/prompts/source/deepwork/glm.md +5 -1
- package/prompts/source/deepwork/gpt.md +22 -2
- package/prompts/source/deepwork/kimi-k27.md +2 -0
- package/prompts/source/deepwork/planner.md +3 -1
- package/prompts/source/deepwork/swe-2.md +2 -0
- package/prompts/source/manifest.json +3 -68
- package/prompts/source/shared/dsh-host-contract.md +1 -1
- package/skills/ast-grep/SKILL.md +1 -1
- package/skills/brainstorming/SKILL.md +1 -1
- package/skills/coding-agent-sessions/SKILL.md +1 -1
- package/skills/debugging/SKILL.md +1 -1
- package/skills/dispatching-parallel-agents/SKILL.md +1 -1
- package/skills/frontend/SKILL.md +1 -1
- package/skills/git-master/SKILL.md +1 -1
- package/skills/init-deep/SKILL.md +1 -1
- package/skills/receiving-code-review/SKILL.md +1 -1
- package/skills/remove-ai-slops/SKILL.md +1 -1
- package/skills/requesting-code-review/SKILL.md +1 -1
- package/skills/subagent-driven-development/SKILL.md +1 -1
- package/skills/using-git-worktrees/SKILL.md +1 -1
- package/skills/writing-plans/SKILL.md +1 -1
- package/lib/client/ChildPermissions.d.ts +0 -43
- package/lib/client/ChildPermissions.js +0 -100
- package/lib/client/HistoryContinuation.d.ts +0 -7
- package/lib/client/HistoryContinuation.js +0 -22
- package/lib/client/PermissionPanelEntry.d.ts +0 -8
- package/lib/client/PermissionPanelEntry.js +0 -11
- package/lib/client/TemporaryPermissions.d.ts +0 -21
- package/lib/client/TemporaryPermissions.js +0 -94
- package/lib/client/history-controller.d.ts +0 -29
- package/lib/client/history-controller.js +0 -111
- package/lib/client/history-entry.d.ts +0 -11
- package/lib/client/history-entry.js +0 -106
- package/lib/client/history-locales.d.ts +0 -95
- package/lib/client/history-locales.js +0 -41
- package/lib/client/temporary-permission-client.d.ts +0 -20
- package/lib/client/temporary-permission-client.js +0 -52
- package/lib/client/temporary-permission-entry.d.ts +0 -6
- package/lib/client/temporary-permission-entry.js +0 -56
- package/lib/history-candidates.d.ts +0 -30
- package/lib/history-candidates.js +0 -176
- package/lib/history-codec.d.ts +0 -11
- package/lib/history-codec.js +0 -102
- package/lib/history-contract.d.ts +0 -44
- package/lib/history-contract.js +0 -2
- package/lib/history-controller.d.ts +0 -42
- package/lib/history-controller.js +0 -329
- package/lib/history-policy.d.ts +0 -4
- package/lib/history-policy.js +0 -8
- package/lib/history-remote.d.ts +0 -28
- package/lib/history-remote.js +0 -17
- package/lib/history-rpc.d.ts +0 -24
- package/lib/history-rpc.js +0 -136
- package/lib/history-support.d.ts +0 -15
- package/lib/history-support.js +0 -21
- package/lib/history-types.d.ts +0 -67
- package/lib/history-types.js +0 -2
- package/lib/permission-child-control.d.ts +0 -36
- package/lib/permission-child-control.js +0 -164
- package/lib/permission-exec-argv.d.ts +0 -32
- package/lib/permission-exec-argv.js +0 -171
- package/lib/permission-temporary-files.d.ts +0 -19
- package/lib/permission-temporary-files.js +0 -248
- package/lib/permission-temporary-grants.d.ts +0 -106
- package/lib/permission-temporary-grants.js +0 -198
- package/lib/permission-temporary-install.d.ts +0 -25
- package/lib/permission-temporary-install.js +0 -86
- package/lib/permission-temporary-remote.d.ts +0 -19
- package/lib/permission-temporary-remote.js +0 -75
- package/lib/permission-temporary-rpc.d.ts +0 -37
- package/lib/permission-temporary-rpc.js +0 -154
- package/lib/permission-temporary-types.d.ts +0 -47
- package/lib/permission-temporary-types.js +0 -2
- package/lib/permission-temporary-web.d.ts +0 -11
- package/lib/permission-temporary-web.js +0 -154
- package/patches/dsh-approval-settlement/@deepseek-ai__dsh-api-gateway@0.2.1-rc.2.patch +0 -13291
- package/patches/dsh-approval-settlement/@deepseek-ai__dsh-api-remotes@0.2.1-rc.2.patch +0 -9133
- package/patches/dsh-approval-settlement/@deepseek-ai__dsh-client-ui-approval@0.2.1-rc.2.patch +0 -156
- package/patches/dsh-approval-settlement/@deepseek-ai__dsh-subagent@0.2.1-rc.2.patch +0 -3546
- package/patches/dsh-approval-settlement/@deepseek-ai__dsh-user-approval@0.2.1-rc.2.patch +0 -431
- package/patches/dsh-approval-settlement/@deepseek-ai__dsh-web@0.2.1-rc.2.patch +0 -119
- package/patches/dsh-approval-settlement/README.md +0 -41
- package/patches/dsh-approval-settlement/metadata.json +0 -10
- package/patches/dsh-session-activation/@deepseek-ai__dsh-agent-loop@0.2.1-rc.2.patch +0 -383
- package/patches/dsh-session-activation/@deepseek-ai__dsh-agent-preset-registry@0.2.1-rc.2.patch +0 -55
- package/patches/dsh-session-activation/@deepseek-ai__dsh-api-session-controller@0.2.1-rc.2.patch +0 -16673
- package/patches/dsh-session-activation/@deepseek-ai__dsh-client-ui-subagent@0.2.1-rc.2.patch +0 -29
- package/patches/dsh-session-activation/@deepseek-ai__dsh-client-ui-workspace@0.2.1-rc.2.patch +0 -196
- package/patches/dsh-session-activation/@deepseek-ai__dsh-session-persistence-jsonl@0.2.1-rc.2.patch +0 -35
- package/patches/dsh-session-activation/@deepseek-ai__dsh-session-persistence@0.2.1-rc.2.patch +0 -40
|
@@ -2,7 +2,7 @@ import { randomUUID } from "node:crypto";
|
|
|
2
2
|
import { scopeLifetime } from "./lifetime.js";
|
|
3
3
|
import { PermissionRefusal, permissionOriginal } from "./permission-control.js";
|
|
4
4
|
import { DSMM_ROLES } from "./roles.js";
|
|
5
|
-
import {
|
|
5
|
+
import { capturedRoleInvocation } from "./role-invocation.js";
|
|
6
6
|
function sameFacts(a, b) {
|
|
7
7
|
return a.length === b.length && a.every((value, index) => value === b[index]);
|
|
8
8
|
}
|
|
@@ -48,13 +48,16 @@ export function createCorePermissionAuthority(ctx, options) {
|
|
|
48
48
|
current = owners[0];
|
|
49
49
|
}
|
|
50
50
|
};
|
|
51
|
-
const
|
|
51
|
+
const coreDomain = (agent) => {
|
|
52
52
|
const core = ctx.get("dsmmCoreLlmOwner"), profiles = ctx.get("dsmmProfileRuntime");
|
|
53
53
|
const ownerCore = coreOwner.get("dsmmCoreLlmOwner"), realmCore = agent.ctx.get("dsmmCoreLlmOwner");
|
|
54
54
|
if (core === undefined || ownerCore === undefined || realmCore === undefined || profiles === undefined
|
|
55
55
|
|| permissionOriginal(core) !== permissionOriginal(ownerCore) || permissionOriginal(core) !== permissionOriginal(realmCore))
|
|
56
56
|
throw new PermissionRefusal("unavailable");
|
|
57
|
-
|
|
57
|
+
return profiles;
|
|
58
|
+
};
|
|
59
|
+
const coreAdmission = (agent) => {
|
|
60
|
+
const profiles = coreDomain(agent), structural = agent, admission = getSettings.admission?.(structural);
|
|
58
61
|
if (admission === undefined || profiles.admission(structural) !== admission || getSettings(structural) !== admission.settings)
|
|
59
62
|
throw new PermissionRefusal("stale");
|
|
60
63
|
return admission;
|
|
@@ -63,21 +66,29 @@ export function createCorePermissionAuthority(ctx, options) {
|
|
|
63
66
|
const previous = generations.get(agent);
|
|
64
67
|
try {
|
|
65
68
|
const structural = agent;
|
|
66
|
-
const
|
|
67
|
-
|
|
69
|
+
const profiles = coreDomain(agent);
|
|
70
|
+
const captured = host?.owns(agent) === true || capturedRoleInvocation(structural) !== undefined;
|
|
71
|
+
const native = !captured && !profiles.hasAdmission(structural);
|
|
72
|
+
if (native && parent?.controlled)
|
|
73
|
+
throw new PermissionRefusal("not-owned");
|
|
74
|
+
if (captured) {
|
|
75
|
+
if (host === undefined)
|
|
76
|
+
throw new PermissionRefusal("unavailable");
|
|
77
|
+
host.assert(agent);
|
|
78
|
+
}
|
|
79
|
+
if (!native)
|
|
68
80
|
rolePolicy.assertModuleAdmission(structural);
|
|
69
|
-
//
|
|
70
|
-
|
|
71
|
-
const
|
|
72
|
-
const identity = nativeChild ? undefined : rolePolicy.identity(structural);
|
|
81
|
+
// Unadmitted native calls retain physical authority, never DSMM role rights.
|
|
82
|
+
const admission = native ? parent?.admission : coreAdmission(agent);
|
|
83
|
+
const identity = native ? undefined : rolePolicy.identity(structural);
|
|
73
84
|
const tools = agent.ctx.get("tools"), approval = agent.ctx.get("approval");
|
|
74
|
-
if (tools === undefined || !
|
|
85
|
+
if (tools === undefined || !native && (identity?.epoch !== admission.epoch
|
|
75
86
|
|| (parent === undefined ? agent !== root || identity.child : identity.parent !== parent.authority.agent || !identity.child)))
|
|
76
87
|
throw new PermissionRefusal("not-owned");
|
|
77
88
|
const nativePolicy = approval === undefined ? undefined : approval.overrideOf(agent.session) ?? approval.config.policy;
|
|
78
89
|
if (approval !== undefined && nativePolicy !== "ask" && nativePolicy !== "never")
|
|
79
90
|
throw new PermissionRefusal("unavailable");
|
|
80
|
-
const managed = parent !== undefined &&
|
|
91
|
+
const managed = parent !== undefined && identity?.role !== undefined;
|
|
81
92
|
if (managed && host === undefined)
|
|
82
93
|
throw new PermissionRefusal("unavailable");
|
|
83
94
|
const entry = managed ? permissionOriginal(host) : undefined;
|
|
@@ -85,7 +96,7 @@ export function createCorePermissionAuthority(ctx, options) {
|
|
|
85
96
|
const facts = [root, agent.ctx, parent?.authority.signal, permissionOriginal(ctx.get("dsmmCoreLlmOwner")),
|
|
86
97
|
permissionOriginal(ctx.get("dsmmProfileRuntime")), permissionOriginal(tools),
|
|
87
98
|
approval === undefined ? undefined : permissionOriginal(approval),
|
|
88
|
-
admission
|
|
99
|
+
admission?.settings, native, captured, identity?.role, identity?.child, identity?.parent, identity?.epoch, identity?.readOnly,
|
|
89
100
|
JSON.stringify(identity?.toolFilter)];
|
|
90
101
|
if (previous !== undefined && !previous.authority.signal.aborted && previous.integration === entry
|
|
91
102
|
&& previous.authority.owner === owner && previous.admission === admission && sameFacts(previous.facts, facts)) {
|
|
@@ -96,13 +107,14 @@ export function createCorePermissionAuthority(ctx, options) {
|
|
|
96
107
|
previous?.revoke();
|
|
97
108
|
if (managed && host.assert(agent) !== admission)
|
|
98
109
|
throw new PermissionRefusal("not-owned");
|
|
110
|
+
const revision = admission?.epoch ?? randomUUID();
|
|
99
111
|
const controller = new AbortController();
|
|
100
112
|
const signal = AbortSignal.any([controller.signal, lifetimeSignal, ...parent === undefined ? [] : [parent.authority.signal]]);
|
|
101
113
|
const detach = [];
|
|
102
114
|
let revoked = false;
|
|
103
|
-
const generation = {
|
|
104
|
-
authority: Object.freeze({ agent, root, realm: agent.ctx, owner, ownerGeneration:
|
|
105
|
-
admissionRevision:
|
|
115
|
+
const generation = { native, controlled: managed || identity?.role !== undefined, integration: entry, admission, facts,
|
|
116
|
+
authority: Object.freeze({ agent, root, realm: agent.ctx, owner, ownerGeneration: revision,
|
|
117
|
+
admissionRevision: revision, permissionRevision: randomUUID(), signal }),
|
|
106
118
|
revoke() {
|
|
107
119
|
if (revoked)
|
|
108
120
|
return;
|
|
@@ -186,7 +198,7 @@ export function createCorePermissionAuthority(ctx, options) {
|
|
|
186
198
|
throw new PermissionRefusal("stale");
|
|
187
199
|
const tools = live.agent.ctx.get("tools");
|
|
188
200
|
if (tools?.get(exec.name, live.agent) === undefined
|
|
189
|
-
|| !generations.get(live.agent)?.
|
|
201
|
+
|| !generations.get(live.agent)?.native && rolePolicy.toolDenial(live.agent, exec.name, tools, exec) !== undefined)
|
|
190
202
|
throw new PermissionRefusal("denied");
|
|
191
203
|
},
|
|
192
204
|
};
|
package/lib/index.d.ts
CHANGED
|
@@ -38,8 +38,6 @@ export type { DsmmLlmAdmission, DsmmLlmCallConfig, DsmmLlmHostOwner, DsmmLlmGene
|
|
|
38
38
|
export { registerRuntimeRecovery } from "./runtime-recovery.js";
|
|
39
39
|
export { classifyRecoveryFailure, foldAttemptedRecoveryRoutes, foldDurableRecoveryWork, selectFallbackRoute } from "./recovery-policy.js";
|
|
40
40
|
export type { DurableRecoveryWork, RecoveryFailureDecision } from "./recovery-policy.js";
|
|
41
|
-
export { DSMM_HISTORY_HOST_CONFIG } from "./history-support.js";
|
|
42
|
-
export { HISTORY_REMOTE } from "./history-remote.js";
|
|
43
41
|
export declare function createDsmmHostPlugin(startup: DsmmHostStartupOptions): {
|
|
44
42
|
name: string;
|
|
45
43
|
Config: import("@deepseek-ai/schemastery").default<import("./settings.js").DsmmPluginConfig>;
|
package/lib/index.js
CHANGED
|
@@ -22,10 +22,6 @@ import { registerRoleControlRpc } from "./role-control-rpc.js";
|
|
|
22
22
|
import { nativeStandingFullAccess } from "./permission-native-access.js";
|
|
23
23
|
import { DsmmProfileError } from "./profiles.js";
|
|
24
24
|
import { registerLspRuntime } from "./lsp.js";
|
|
25
|
-
import { DsmmHistoryCandidates } from "./history-candidates.js";
|
|
26
|
-
import { registerHistoryContinuationRpc } from "./history-rpc.js";
|
|
27
|
-
import { requireHistoryAdmission } from "./history-support.js";
|
|
28
|
-
import { installTemporaryPermissions } from "./permission-temporary-install.js";
|
|
29
25
|
export const name = "dsmm";
|
|
30
26
|
export const inject = ["profileContext", "agents"];
|
|
31
27
|
export const Config = new Proxy(DSMM_NATIVE_CONFIG_SCHEMA, { apply(_target, _receiver, args) { return DSMM_CONFIG_SCHEMA(args[0] ?? {}); } });
|
|
@@ -49,8 +45,6 @@ export { DEEPWORK_MODE_EVENT, DeepworkModeController, hasOpenTurn, isDeepworkAct
|
|
|
49
45
|
export { DsmmNativeLlmRuntime } from "./llm-runtime.js";
|
|
50
46
|
export { registerRuntimeRecovery } from "./runtime-recovery.js";
|
|
51
47
|
export { classifyRecoveryFailure, foldAttemptedRecoveryRoutes, foldDurableRecoveryWork, selectFallbackRoute } from "./recovery-policy.js";
|
|
52
|
-
export { DSMM_HISTORY_HOST_CONFIG } from "./history-support.js";
|
|
53
|
-
export { HISTORY_REMOTE } from "./history-remote.js";
|
|
54
48
|
export function createDsmmHostPlugin(startup) {
|
|
55
49
|
assertSupportedHostStartup(startup);
|
|
56
50
|
return { name, Config, inject, apply(ctx, config = {}) { return apply(ctx, config, startup); } };
|
|
@@ -60,22 +54,12 @@ export async function apply(input, config = {}, startupOptions = {}) {
|
|
|
60
54
|
if (!Context.is(input))
|
|
61
55
|
throw new Error("DSMM requires the native Cordis Host");
|
|
62
56
|
const ctx = input;
|
|
63
|
-
requireHistoryAdmission(ctx);
|
|
64
57
|
const deployment = new DsmmDeploymentConfig(ctx, config);
|
|
65
58
|
const lifetime = new AbortController();
|
|
66
59
|
scopeLifetime(ctx, "dsmm: retire Core", () => lifetime.abort());
|
|
67
|
-
// Install a startup execution fence before asynchronous configuration reads.
|
|
68
60
|
let admission;
|
|
69
61
|
const assert = (agent) => { lifetime.signal.throwIfAborted(); if (!admission)
|
|
70
62
|
throw new Error("DSMM initialization is incomplete"); return admission.assert(agent); };
|
|
71
|
-
ctx.on("agent/created", () => { lifetime.signal.throwIfAborted(); if (!admission?.isReady)
|
|
72
|
-
throw new Error("DSMM initialization is incomplete"); }, { global: true, prepend: true });
|
|
73
|
-
ctx.on("agent/pre-step", async (frame, next) => { await admission?.ensure(frame.agent); assert(frame.agent); return next(); }, { global: true, prepend: true });
|
|
74
|
-
ctx.on("agent/request", async (frame, next) => { await admission?.ensure(frame.agent); assert(frame.agent); return next(); }, { global: true, prepend: true });
|
|
75
|
-
ctx.on("tools/pre-execute", async (exec, next) => { if (exec.agent) {
|
|
76
|
-
await admission?.ensure(exec.agent);
|
|
77
|
-
assert(exec.agent);
|
|
78
|
-
} return next(); }, { global: true, prepend: true });
|
|
79
63
|
const startup = await deployment.readDesired();
|
|
80
64
|
lifetime.signal.throwIfAborted();
|
|
81
65
|
const getSettings = agent => agent === undefined ? startup.settings : admission.configuration(agent).settings;
|
|
@@ -98,6 +82,8 @@ export async function apply(input, config = {}, startupOptions = {}) {
|
|
|
98
82
|
ctx.provide("dsmmProfileRuntime", profiles);
|
|
99
83
|
ctx.provide("dsmmDeploymentConfig", deployment);
|
|
100
84
|
ctx.provide("dsmmCoreLlmOwner", { async admit(frame) {
|
|
85
|
+
if (!admission.owns(frame.agent))
|
|
86
|
+
return undefined;
|
|
101
87
|
const captured = assert(frame.agent), full = nativeStandingFullAccess(ctx, frame.agent);
|
|
102
88
|
const permissions = ctx.get("dsmmPermissionController");
|
|
103
89
|
if (!full && captured.settings.permissionControl.enabled && permissions === undefined)
|
|
@@ -126,7 +112,12 @@ export async function apply(input, config = {}, startupOptions = {}) {
|
|
|
126
112
|
const nativeAdmission = admission;
|
|
127
113
|
if (startup.settings.modules.deepwork.enabled) {
|
|
128
114
|
const presets = ctx.inject(["agentPresets"], async (scope) => {
|
|
129
|
-
await registerRolePresets(scope, () => startup.settings
|
|
115
|
+
await registerRolePresets(scope, () => startup.settings, agent => { try {
|
|
116
|
+
return policy.identity(agent).role;
|
|
117
|
+
}
|
|
118
|
+
catch {
|
|
119
|
+
return undefined;
|
|
120
|
+
} });
|
|
130
121
|
const providers = scope.inject(["subagents"], async (runtimeScope) => {
|
|
131
122
|
registerRoleProviders(runtimeScope, () => startup.settings, nativeAdmission);
|
|
132
123
|
await registerNativeSubagentControls(runtimeScope);
|
|
@@ -141,7 +132,7 @@ export async function apply(input, config = {}, startupOptions = {}) {
|
|
|
141
132
|
await registerLspRuntime(ctx, startup.settings.lsp, getSettings);
|
|
142
133
|
lifetime.signal.throwIfAborted();
|
|
143
134
|
const installed = new WeakSet();
|
|
144
|
-
admission.activate(async (agent, candidate
|
|
135
|
+
admission.activate(async (agent, candidate) => {
|
|
145
136
|
candidate.subagentRuntime = () => runtimeAdmissionView(ctx);
|
|
146
137
|
const scope = agent.ctx;
|
|
147
138
|
if (startup.settings.modules.deepwork.enabled) {
|
|
@@ -149,14 +140,14 @@ export async function apply(input, config = {}, startupOptions = {}) {
|
|
|
149
140
|
registerDeepworkPrompt(scope, controller, candidate, { section: startup.profile.section ?? startup.global.section }, agent, admission.lifetime.signal);
|
|
150
141
|
}
|
|
151
142
|
if (installed.has(agent)) {
|
|
152
|
-
if (
|
|
143
|
+
if (startup.settings.modules.deepwork.enabled && ctx.get("subagents") !== undefined)
|
|
153
144
|
await registerHeadlessRoleTools(scope, controller, candidate, policy, nativeAdmission, agent);
|
|
154
145
|
return;
|
|
155
146
|
}
|
|
156
147
|
registerModelRouting(scope, controller, candidate);
|
|
157
148
|
registerSafetyGuards(scope, controller, candidate, policy);
|
|
158
149
|
if (startup.settings.modules.deepwork.enabled) {
|
|
159
|
-
if (
|
|
150
|
+
if (ctx.get("subagents") !== undefined)
|
|
160
151
|
await registerHeadlessRoleTools(scope, controller, candidate, policy, nativeAdmission, agent);
|
|
161
152
|
}
|
|
162
153
|
installed.add(agent);
|
|
@@ -168,19 +159,8 @@ export async function apply(input, config = {}, startupOptions = {}) {
|
|
|
168
159
|
});
|
|
169
160
|
ctx.inject(["typert"], scope => { registerConfigRpc(scope, deployment, startup.settings, () => profiles, startup.sources, mountedPermission); new DsmmProfilesHost(scope, profiles); registerRoleControlRpc(scope, nativeAdmission); });
|
|
170
161
|
const permissions = createCorePermissionAuthority(ctx, { getSettings, rolePolicy: policy, signal: lifetime.signal });
|
|
171
|
-
const history = ctx.inject(["typert", "agentLoop", "sessionController", "sessionPersistence", "agentPresets"], function mountHistoryContinuation(scope) {
|
|
172
|
-
registerHistoryContinuationRpc(scope, new DsmmHistoryCandidates(scope, profiles, deployment, nativeAdmission), nativeAdmission);
|
|
173
|
-
});
|
|
174
|
-
if (["typert", "agentLoop", "sessionController", "sessionPersistence", "agentPresets"].every(key => ctx.get(key)))
|
|
175
|
-
await history.await();
|
|
176
162
|
const installPermissions = () => ctx.inject(["tools", ...(ctx.fiber.entry === undefined ? [] : ["settings"])], scope => {
|
|
177
163
|
const installed = installCorePermissions(scope, deployment, permissions.authority, permissions.assertWritable);
|
|
178
|
-
scope.inject(["approval", "typertGateway", "typert", "subagents"], temporaryScope => {
|
|
179
|
-
if (typeof temporaryScope.approval.settlement !== "function" || typeof temporaryScope.typertGateway.registerApprovalPermits !== "function")
|
|
180
|
-
return;
|
|
181
|
-
const temporary = installTemporaryPermissions(temporaryScope, { core: permissions, roles: policy, rules: installed.rules });
|
|
182
|
-
temporaryScope.effect(() => () => temporary.dispose(), "dsmm: temporary permissions");
|
|
183
|
-
});
|
|
184
164
|
const identity = Reflect.get(installed, symbols.original) ?? installed;
|
|
185
165
|
scopeLifetime(scope, "dsmm: release permission projection", () => { if (permissionOwner === identity)
|
|
186
166
|
permissionOwner = undefined; }, () => { permissionOwner = identity; });
|
|
@@ -22,7 +22,6 @@ export declare class NativeAdmission {
|
|
|
22
22
|
private readonly pending;
|
|
23
23
|
private readonly live;
|
|
24
24
|
private readonly candidates;
|
|
25
|
-
private readonly historyPrepared;
|
|
26
25
|
private readonly agents;
|
|
27
26
|
private readonly activations;
|
|
28
27
|
private readonly activities;
|
|
@@ -42,8 +41,9 @@ export declare class NativeAdmission {
|
|
|
42
41
|
constructor(ctx: Context, profiles: DsmmProfileRuntime, policy: DsmmRolePolicy);
|
|
43
42
|
activate(install: NonNullable<NativeAdmission["install"]>): void;
|
|
44
43
|
get isReady(): boolean;
|
|
45
|
-
/**
|
|
46
|
-
|
|
44
|
+
/** Exact process-local capture, retained after retirement so stale objects never become native. */
|
|
45
|
+
owns(agent: Agent): boolean;
|
|
46
|
+
guardExecution(agent: Agent): Promise<"native" | "dsmm">;
|
|
47
47
|
isSelecting(agent: Agent): boolean;
|
|
48
48
|
get(agent: Agent): DsmmProfileAdmission | undefined;
|
|
49
49
|
configuration(agent: Agent): DsmmProfileAdmission;
|
package/lib/native-admission.js
CHANGED
|
@@ -20,7 +20,6 @@ export class NativeAdmission {
|
|
|
20
20
|
pending = new Map();
|
|
21
21
|
live = new WeakMap();
|
|
22
22
|
candidates = new WeakMap();
|
|
23
|
-
historyPrepared = new WeakMap();
|
|
24
23
|
agents = new Set();
|
|
25
24
|
activations = new Set();
|
|
26
25
|
activities = new Map();
|
|
@@ -66,17 +65,21 @@ export class NativeAdmission {
|
|
|
66
65
|
profiles.release(agent);
|
|
67
66
|
policy.release(agent);
|
|
68
67
|
}, { global: true });
|
|
69
|
-
//
|
|
70
|
-
ctx.on("agent/pre-step", async (frame, next) => { await this.
|
|
71
|
-
ctx.on("agent/request", async (frame, next) => { await this.
|
|
72
|
-
ctx.on("tools/execute", async (exec, next) => {
|
|
73
|
-
|
|
68
|
+
// Only exact DSMM captures are guarded; native reconstruction is not an admission request.
|
|
69
|
+
ctx.on("agent/pre-step", async (frame, next) => { await this.guardExecution(frame.agent); return next(); }, { global: true, prepend: true });
|
|
70
|
+
ctx.on("agent/request", async (frame, next) => { await this.guardExecution(frame.agent); return next(); }, { global: true, prepend: true });
|
|
71
|
+
ctx.on("tools/execute", async (exec, next) => {
|
|
72
|
+
if (exec.agent && await this.guardExecution(exec.agent) === "native")
|
|
73
|
+
return next();
|
|
74
|
+
return policy.duringToolExecution(exec, next);
|
|
75
|
+
}, { global: true, prepend: true });
|
|
74
76
|
ctx.on("tools/pre-execute", async (exec, next) => {
|
|
75
77
|
if (exec.agent) {
|
|
78
|
+
if (await this.guardExecution(exec.agent) === "native")
|
|
79
|
+
return next();
|
|
76
80
|
const active = this.executions.get(exec.agent) ?? new Set();
|
|
77
81
|
active.add(exec.token);
|
|
78
82
|
this.executions.set(exec.agent, active);
|
|
79
|
-
await this.ensure(exec.agent);
|
|
80
83
|
}
|
|
81
84
|
return next();
|
|
82
85
|
}, { global: true, prepend: true });
|
|
@@ -91,29 +94,22 @@ export class NativeAdmission {
|
|
|
91
94
|
void binding.catch(() => { });
|
|
92
95
|
}, { global: true });
|
|
93
96
|
}
|
|
94
|
-
activate(install) {
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
scopeLifetime(agent.ctx, "dsmm: release unpublished history configuration", () => { this.historyPrepared.delete(agent); this.candidates.delete(agent); });
|
|
111
|
-
this.guardTools(agent);
|
|
112
|
-
await this.install(agent, this.getter(agent), "history-setup");
|
|
113
|
-
check();
|
|
114
|
-
if (prepared.dependencies.some((value, index) => value !== this.dependencies(agent)[index]) || prepared.scopeParent !== scopeParentOf(agent))
|
|
115
|
-
throw new SubagentError("History composition changed during setup", "UNAUTHORIZED");
|
|
116
|
-
this.historyPrepared.set(agent, prepared);
|
|
97
|
+
activate(install) {
|
|
98
|
+
this.lifetime.signal.throwIfAborted();
|
|
99
|
+
this.install = install;
|
|
100
|
+
this.ready = true;
|
|
101
|
+
}
|
|
102
|
+
get isReady() {
|
|
103
|
+
const current = this.ctx.get("dsmmNativeAdmission");
|
|
104
|
+
return this.ready && !this.lifetime.signal.aborted && current !== undefined && original(current) === original(this);
|
|
105
|
+
}
|
|
106
|
+
/** Exact process-local capture, retained after retirement so stale objects never become native. */
|
|
107
|
+
owns(agent) { return this.agentLifetimes.has(agent); }
|
|
108
|
+
async guardExecution(agent) {
|
|
109
|
+
if (!this.owns(agent))
|
|
110
|
+
return "native";
|
|
111
|
+
await this.ensure(agent);
|
|
112
|
+
return "dsmm";
|
|
117
113
|
}
|
|
118
114
|
isSelecting(agent) { return this.selecting.has(agent); }
|
|
119
115
|
get(agent) { return this.live.get(agent)?.admission; }
|
|
@@ -150,14 +146,14 @@ export class NativeAdmission {
|
|
|
150
146
|
throw new SubagentError("Session configuration restoration failed; create a new session", "UNAUTHORIZED");
|
|
151
147
|
if (this.selecting.has(agent))
|
|
152
148
|
throw new SubagentError("Session configuration maintenance is in progress", "UNAUTHORIZED");
|
|
153
|
-
if (!this.
|
|
149
|
+
if (!this.isReady || !live || this.ctx.agents.get(agent.id) !== agent)
|
|
154
150
|
throw new SubagentError("No trusted live admission; create a new session", "UNAUTHORIZED");
|
|
155
151
|
if (live.preset !== agent.ctx.get("agentPresets")?.composedPreset(agent.ctx) || live.scopeParent !== scopeParentOf(agent))
|
|
156
152
|
throw new SubagentError("Preset composition changed; create a new session", "UNAUTHORIZED");
|
|
157
153
|
if (live.parent && (this.ctx.agents.get(live.parent.id) !== live.parent || !this.ctx.agents.isOwnedBy(agent.id, live.parent)))
|
|
158
154
|
throw new SubagentError("Parent residency changed", "UNAUTHORIZED");
|
|
159
155
|
if (live.parent)
|
|
160
|
-
this.
|
|
156
|
+
this.assert(live.parent);
|
|
161
157
|
this.policy.assertModuleAdmission(agent);
|
|
162
158
|
return live.admission;
|
|
163
159
|
}
|
|
@@ -224,10 +220,6 @@ export class NativeAdmission {
|
|
|
224
220
|
return [name, provider];
|
|
225
221
|
}));
|
|
226
222
|
for (const role of targets) {
|
|
227
|
-
const preset = await agent.ctx.get("agentPresets").resolve(role);
|
|
228
|
-
assertCurrent();
|
|
229
|
-
if (preset.broken !== undefined)
|
|
230
|
-
throw new DsmmProfileError("activation", "An enabled role preset is unavailable.", role);
|
|
231
223
|
const routing = admission.settings.roleRouting[role];
|
|
232
224
|
if (routing?.primary !== undefined || routing?.fallbackRoutes !== undefined) {
|
|
233
225
|
await resolveRoleInvocation(agent, role, admission.settings, preparationSignal, {}, undefined, resolvedModelParameterPolicy(admission));
|
|
@@ -277,7 +269,10 @@ export class NativeAdmission {
|
|
|
277
269
|
const presets = this.ctx.get("agentPresets");
|
|
278
270
|
if (!presets)
|
|
279
271
|
throw new SubagentError("Native preset registry unavailable", "UNSUPPORTED_CAPABILITY");
|
|
280
|
-
|
|
272
|
+
// The child shares the parent's standing composition; its role is carried
|
|
273
|
+
// by the admitted invocation, not by an own registered preset.
|
|
274
|
+
const expectedPreset = presets.composedPreset(parent.ctx);
|
|
275
|
+
const lease = await presets.acquireScope(expectedPreset);
|
|
281
276
|
try {
|
|
282
277
|
exec.signal.throwIfAborted();
|
|
283
278
|
this.assert(parent);
|
|
@@ -286,7 +281,7 @@ export class NativeAdmission {
|
|
|
286
281
|
throw new SubagentError("Creation dependencies changed", "UNAUTHORIZED");
|
|
287
282
|
const childId = SessionId(randomUUID()), signal = AbortSignal.any([exec.signal, this.lifetime.signal, this.agentLifetimes.get(parent).signal]);
|
|
288
283
|
const admission = freezeSettings({ ...parentAdmission, settings: structuredClone(parentAdmission.settings) });
|
|
289
|
-
const pending = Object.freeze({ childId, parent, parentAdmission, callId: exec.callId, invocation, admission, provider, presetScope: lease.key, signal, maxDepth, toolFilter });
|
|
284
|
+
const pending = Object.freeze({ childId, parent, parentAdmission, callId: exec.callId, invocation, admission, provider, expectedPreset, presetScope: lease.key, signal, maxDepth, toolFilter });
|
|
290
285
|
this.pending.set(childId, pending);
|
|
291
286
|
const revoke = () => { if (this.pending.get(childId) === pending)
|
|
292
287
|
this.pending.delete(childId); };
|
|
@@ -378,6 +373,8 @@ export class NativeAdmission {
|
|
|
378
373
|
async rebindBlank(agent) {
|
|
379
374
|
await this.blankUpdates.get(agent);
|
|
380
375
|
this.lifetime.signal.throwIfAborted();
|
|
376
|
+
if (!this.isReady)
|
|
377
|
+
throw new SubagentError("DSMM owner is no longer current", "UNAUTHORIZED");
|
|
381
378
|
const previous = this.live.get(agent);
|
|
382
379
|
if (previous === undefined)
|
|
383
380
|
throw new SubagentError("The blank Agent owner was retired", "UNAUTHORIZED");
|
|
@@ -394,23 +391,31 @@ export class NativeAdmission {
|
|
|
394
391
|
await this.install(agent, this.getter(agent));
|
|
395
392
|
this.lifetime.signal.throwIfAborted();
|
|
396
393
|
this.agentLifetimes.get(agent).signal.throwIfAborted();
|
|
397
|
-
if (this.ctx.agents.get(agent.id) !== agent || this.live.get(agent) !== previous || scopeParentOf(agent) !== scopeParent)
|
|
394
|
+
if (!this.isReady || this.ctx.agents.get(agent.id) !== agent || this.live.get(agent) !== previous || scopeParentOf(agent) !== scopeParent)
|
|
398
395
|
throw new SubagentError("Composition changed during blank admission", "UNAUTHORIZED");
|
|
399
396
|
this.live.set(agent, Object.freeze({ ...previous, preset, scopeParent }));
|
|
400
397
|
}
|
|
401
398
|
async created(agent, source, creationSignal) {
|
|
402
|
-
if (this.
|
|
399
|
+
if (this.owns(agent)) {
|
|
403
400
|
this.assert(agent);
|
|
404
401
|
return;
|
|
405
402
|
}
|
|
406
|
-
|
|
403
|
+
const pending = this.pending.get(agent.id);
|
|
404
|
+
// Native resume, promotion and durable provider recovery do not restore a DSMM role grant.
|
|
405
|
+
if (source === "resume" && pending === undefined)
|
|
406
|
+
return;
|
|
407
|
+
if (pending && source !== "startup")
|
|
408
|
+
throw new SubagentError("Role creation requires its first pending call", "UNAUTHORIZED");
|
|
409
|
+
if (!this.isReady || !this.install)
|
|
407
410
|
throw new SubagentError("DSMM admission is initializing", "UNAUTHORIZED");
|
|
408
411
|
const signal = AbortSignal.any([...creationSignal ? [creationSignal] : [], this.lifetime.signal]);
|
|
409
412
|
signal.throwIfAborted();
|
|
410
413
|
const parents = this.ctx.agents.list().filter(parent => parent !== agent && this.ctx.agents.isOwnedBy(agent.id, parent));
|
|
411
|
-
const parent = parents[0], preset = agent.ctx.get("agentPresets")?.composedPreset(agent.ctx), presetScope = scopeParentOf(agent)
|
|
414
|
+
const parent = parents[0], preset = agent.ctx.get("agentPresets")?.composedPreset(agent.ctx), presetScope = scopeParentOf(agent);
|
|
412
415
|
if (parents.length > 1 || this.ctx.agents.get(agent.id) !== agent)
|
|
413
416
|
throw new SubagentError("Invalid native ownership", "UNAUTHORIZED");
|
|
417
|
+
if (!pending && (parent && !this.owns(parent) || !parent && agent.session.header.origin === "subagent"))
|
|
418
|
+
return;
|
|
414
419
|
let admission;
|
|
415
420
|
if (parent) {
|
|
416
421
|
const parentAdmission = this.assert(parent), controlled = this.policy.identity(parent).role !== undefined;
|
|
@@ -418,7 +423,7 @@ export class NativeAdmission {
|
|
|
418
423
|
throw new SubagentError("Invalid native child header", "UNAUTHORIZED");
|
|
419
424
|
if (pending) {
|
|
420
425
|
this.check(pending);
|
|
421
|
-
if (pending.parent !== parent || pending.parentAdmission !== parentAdmission || preset !== pending.
|
|
426
|
+
if (pending.parent !== parent || pending.parentAdmission !== parentAdmission || preset !== pending.expectedPreset || agent.session.header.isSeeded
|
|
422
427
|
|| scopeParentOf(agent) !== pending.presetScope)
|
|
423
428
|
throw new SubagentError("Child does not match the pending invocation", "UNAUTHORIZED");
|
|
424
429
|
if (pending.maxDepth !== undefined && delegationDepthOf(agent) > pending.maxDepth)
|
|
@@ -427,35 +432,30 @@ export class NativeAdmission {
|
|
|
427
432
|
}
|
|
428
433
|
else {
|
|
429
434
|
if (controlled || preset?.startsWith("dsmm-"))
|
|
430
|
-
throw new SubagentError("Use an admitted DSMM role tool
|
|
435
|
+
throw new SubagentError("Use an admitted DSMM role tool", "UNAUTHORIZED");
|
|
431
436
|
admission = parentAdmission;
|
|
432
437
|
}
|
|
433
438
|
}
|
|
434
439
|
else {
|
|
435
|
-
if (
|
|
440
|
+
if (pending)
|
|
436
441
|
throw new SubagentError("Missing exact parent", "UNAUTHORIZED");
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
const prepared = this.historyPrepared.get(agent);
|
|
440
|
-
if (!history || prepared?.admission !== history || prepared.preset !== preset || prepared.scopeParent !== presetScope
|
|
441
|
-
|| prepared.dependencies.some((value, index) => value !== this.dependencies(agent)[index]))
|
|
442
|
-
throw new SubagentError("History resume requires its exact prepared candidate", "UNAUTHORIZED");
|
|
443
|
-
admission = history;
|
|
444
|
-
this.policy.validateRootRole(agent, admission);
|
|
445
|
-
}
|
|
446
|
-
else {
|
|
447
|
-
// A resume may have opened the native log, but cannot recover DSMM authorization.
|
|
448
|
-
if ((source !== "startup" || agent.session.header.isSeeded) && (preset?.startsWith("dsmm-") || sessionEvents(agent.session).some(event => ["deepwork/mode", "dsmm/role-policy"].includes(event.type))))
|
|
449
|
-
throw new SubagentError("DSMM cold recovery is unavailable", "UNAUTHORIZED");
|
|
450
|
-
admission = await this.profiles.prepareRoot(agent, signal);
|
|
451
|
-
this.policy.validateRootRole(agent, admission);
|
|
452
|
-
if ((source !== "startup" || agent.session.header.isSeeded) && admission.settings.defaultActive)
|
|
453
|
-
throw new SubagentError("Historical sessions are not automatically admitted to Deepwork", "UNAUTHORIZED");
|
|
454
|
-
}
|
|
442
|
+
admission = await this.profiles.prepareRoot(agent, signal);
|
|
443
|
+
this.policy.validateRootRole(agent, admission);
|
|
455
444
|
}
|
|
456
445
|
this.agentLifetimes.set(agent, new AbortController());
|
|
457
446
|
scopeLifetime(agent.ctx, "dsmm: retire exact Agent work", () => { void this.retireAgent(agent).catch(() => { }); });
|
|
458
|
-
agent.ctx.effect(() => () =>
|
|
447
|
+
agent.ctx.effect(() => async () => {
|
|
448
|
+
try {
|
|
449
|
+
await this.retireAgent(agent);
|
|
450
|
+
}
|
|
451
|
+
finally {
|
|
452
|
+
this.live.delete(agent);
|
|
453
|
+
this.candidates.delete(agent);
|
|
454
|
+
this.agents.delete(agent);
|
|
455
|
+
this.profiles.release(agent);
|
|
456
|
+
this.policy.release(agent);
|
|
457
|
+
}
|
|
458
|
+
});
|
|
459
459
|
this.candidates.set(agent, admission);
|
|
460
460
|
this.agents.add(agent);
|
|
461
461
|
// These registrations belong to the Agent, not the plugin owner. Revocation remains effective after unload.
|
|
@@ -473,6 +473,8 @@ export class NativeAdmission {
|
|
|
473
473
|
try {
|
|
474
474
|
if (pending)
|
|
475
475
|
this.policy.bindChild(agent, parent, admission, pending.invocation, pending.maxDepth, pending.toolFilter);
|
|
476
|
+
else if (parent)
|
|
477
|
+
this.policy.bindInheritedChild(agent, parent, admission);
|
|
476
478
|
await this.install(agent, this.getter(agent));
|
|
477
479
|
signal.throwIfAborted();
|
|
478
480
|
this.agentLifetimes.get(agent).signal.throwIfAborted();
|
|
@@ -480,7 +482,7 @@ export class NativeAdmission {
|
|
|
480
482
|
this.check(pending);
|
|
481
483
|
if (parent)
|
|
482
484
|
this.assert(parent);
|
|
483
|
-
if (this.ctx.agents.get(agent.id) !== agent || preset !== agent.ctx.get("agentPresets")?.composedPreset(agent.ctx)
|
|
485
|
+
if (!this.isReady || this.ctx.agents.get(agent.id) !== agent || preset !== agent.ctx.get("agentPresets")?.composedPreset(agent.ctx)
|
|
484
486
|
|| presetScope !== scopeParentOf(agent) || parent && !this.ctx.agents.isOwnedBy(agent.id, parent))
|
|
485
487
|
throw new SubagentError("Agent changed during initialization", "UNAUTHORIZED");
|
|
486
488
|
this.profiles.publish(agent, admission);
|
|
@@ -495,7 +497,6 @@ export class NativeAdmission {
|
|
|
495
497
|
}
|
|
496
498
|
finally {
|
|
497
499
|
this.candidates.delete(agent);
|
|
498
|
-
this.historyPrepared.delete(agent);
|
|
499
500
|
}
|
|
500
501
|
}
|
|
501
502
|
}
|
|
@@ -56,7 +56,7 @@ export class DsmmPermissionController extends Service {
|
|
|
56
56
|
captureIntegrity: options.authority.captureIntegrity === undefined ? undefined : exec => options.authority.captureIntegrity(exec),
|
|
57
57
|
current: exec => options.authority.current(exec),
|
|
58
58
|
assertCurrent: (current, exec) => {
|
|
59
|
-
options.authority.assertCurrent(
|
|
59
|
+
options.authority.assertCurrent(current, exec);
|
|
60
60
|
if (current.agent !== exec.agent || this.lifetime.signal.aborted)
|
|
61
61
|
throw new PermissionRefusal("stale");
|
|
62
62
|
},
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import * as Native from "@deepseek-ai/dsh-tool-fs-search";
|
|
2
2
|
import { DsmmPermissionController } from "./permission-controller.js";
|
|
3
|
-
import { temporaryFileToolScope } from "./permission-temporary-files.js";
|
|
4
3
|
export { Config, inject, name } from "@deepseek-ai/dsh-tool-fs-search";
|
|
5
4
|
export function apply(ctx, config) {
|
|
6
|
-
return Native.apply(
|
|
5
|
+
return Native.apply(DsmmPermissionController.toolScope(ctx, "fs-search"), config);
|
|
7
6
|
}
|
|
8
7
|
//# sourceMappingURL=permission-fs-search.js.map
|
package/lib/permission-fs.js
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import * as Native from "@deepseek-ai/dsh-tool-fs";
|
|
2
2
|
import { DsmmPermissionController } from "./permission-controller.js";
|
|
3
|
-
import { temporaryFileToolScope } from "./permission-temporary-files.js";
|
|
4
3
|
export { Config, inject, name } from "@deepseek-ai/dsh-tool-fs";
|
|
5
4
|
export function apply(ctx, config) {
|
|
6
|
-
return Native.apply(
|
|
5
|
+
return Native.apply(DsmmPermissionController.toolScope(ctx, "fs"), config);
|
|
7
6
|
}
|
|
8
7
|
//# sourceMappingURL=permission-fs.js.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { isAbsolute, normalize, parse, resolve } from "node:path";
|
|
2
|
-
import { parseNativeCommands } from "./permission-settings.js";
|
|
2
|
+
import { parseNativeCommandPattern, parseNativeCommands } from "./permission-settings.js";
|
|
3
3
|
import { PermissionRefusal } from "./permission-errors.js";
|
|
4
4
|
/** Host-only validation: Windows drive-relative roots never authorize an enhancement. */
|
|
5
5
|
export function parseHostNativeCommands(input = {}) {
|
|
@@ -82,9 +82,11 @@ export function nativeCommandMatch(settings, tool, identity, args, workspace) {
|
|
|
82
82
|
if (words === undefined)
|
|
83
83
|
return undefined;
|
|
84
84
|
const matches = parseHostNativeCommands(settings).entries.filter(entry => {
|
|
85
|
-
const match = entry.match
|
|
86
|
-
|
|
87
|
-
|
|
85
|
+
const match = entry.match;
|
|
86
|
+
if (match.tool !== tool || normalize(match.workingDirectory) !== cwd)
|
|
87
|
+
return false;
|
|
88
|
+
const pattern = parseNativeCommandPattern(match.commandPattern);
|
|
89
|
+
return pattern.executable === words[0] && pattern.subcommands.includes(words[1]);
|
|
88
90
|
});
|
|
89
91
|
if (new Set(matches.map(entry => entry.sandboxMode)).size > 1)
|
|
90
92
|
return "ambiguous";
|
|
@@ -5,16 +5,15 @@ export interface PermissionWebPolicy {
|
|
|
5
5
|
readonly enabled: boolean;
|
|
6
6
|
readonly rule: PermissionRuleAction;
|
|
7
7
|
}
|
|
8
|
+
export interface NativeCommandMatch {
|
|
9
|
+
readonly tool: "bash" | "pwsh";
|
|
10
|
+
readonly workingDirectory: string;
|
|
11
|
+
readonly commandPattern: string;
|
|
12
|
+
}
|
|
8
13
|
export interface NativeCommandEntry {
|
|
9
14
|
readonly id: string;
|
|
10
15
|
readonly mode: "ask" | "allow";
|
|
11
|
-
readonly match:
|
|
12
|
-
readonly tool: "bash" | "pwsh";
|
|
13
|
-
readonly executable: string;
|
|
14
|
-
readonly subcommand?: string;
|
|
15
|
-
readonly args: readonly string[];
|
|
16
|
-
readonly workingDirectory: string;
|
|
17
|
-
};
|
|
16
|
+
readonly match: NativeCommandMatch;
|
|
18
17
|
readonly sandboxMode: "workspace-write" | "danger-full-access";
|
|
19
18
|
}
|
|
20
19
|
export interface NativeCommandsSettings {
|
|
@@ -38,7 +37,22 @@ export interface PermissionControlSchemaInput {
|
|
|
38
37
|
readonly rules?: readonly PermissionRule[];
|
|
39
38
|
readonly nativeCommands?: Partial<NativeCommandsSettings>;
|
|
40
39
|
}
|
|
40
|
+
export interface NativeCommandPattern {
|
|
41
|
+
readonly executable: string;
|
|
42
|
+
readonly subcommands: readonly string[];
|
|
43
|
+
}
|
|
44
|
+
/** Bounded static prefix grammar; the optional final star always denotes the whole argv tail. */
|
|
45
|
+
export declare function parseNativeCommandPattern(input: unknown): NativeCommandPattern;
|
|
41
46
|
export declare function parseNativeCommands(input?: unknown): NativeCommandsSettings;
|
|
47
|
+
export declare const nativeCommandMatchSchema: z<Schemastery.ObjectS<NoInfer<{
|
|
48
|
+
tool: z<"bash" | "pwsh", "bash" | "pwsh", "defined">;
|
|
49
|
+
workingDirectory: z<string, string, "defined">;
|
|
50
|
+
commandPattern: z<string, string, "defined">;
|
|
51
|
+
}>>, Schemastery.ObjectT<NoInfer<{
|
|
52
|
+
tool: z<"bash" | "pwsh", "bash" | "pwsh", "defined">;
|
|
53
|
+
workingDirectory: z<string, string, "defined">;
|
|
54
|
+
commandPattern: z<string, string, "defined">;
|
|
55
|
+
}>>, "defined">;
|
|
42
56
|
export declare const DEFAULT_PERMISSION_CONTROL: PermissionControlSettings;
|
|
43
57
|
export declare const permissionControlSchema: z<PermissionControlSettings>;
|
|
44
58
|
export declare function resolvePermissionControl(input?: PermissionControlSchemaInput): PermissionControlSettings;
|