@dsmm/dsmm 0.3.9 → 0.3.11
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 +9 -5
- package/agent-presets/dsmm-builder/agent.cordis.yml +6 -10
- package/agent-presets/dsmm-clarifier/agent.cordis.yml +10 -14
- package/agent-presets/dsmm-code-search/agent.cordis.yml +10 -14
- package/agent-presets/dsmm-coding/agent.cordis.yml +10 -14
- package/agent-presets/dsmm-complex/agent.cordis.yml +10 -14
- package/agent-presets/dsmm-creative/agent.cordis.yml +10 -14
- package/agent-presets/dsmm-cross-cutting/agent.cordis.yml +10 -14
- package/agent-presets/dsmm-deep/agent.cordis.yml +10 -14
- package/agent-presets/dsmm-doc-search/agent.cordis.yml +10 -14
- package/agent-presets/dsmm-documenting/agent.cordis.yml +10 -14
- package/agent-presets/dsmm-frontend/agent.cordis.yml +10 -14
- package/agent-presets/dsmm-hard-reasoning/agent.cordis.yml +10 -14
- package/agent-presets/dsmm-media-reader/agent.cordis.yml +10 -14
- package/agent-presets/dsmm-normal-task/agent.cordis.yml +10 -14
- package/agent-presets/dsmm-oracle/agent.cordis.yml +10 -14
- package/agent-presets/dsmm-oracle-2nd/agent.cordis.yml +10 -14
- package/agent-presets/dsmm-orchestrator/agent.cordis.yml +8 -12
- package/agent-presets/dsmm-plan-critic/agent.cordis.yml +10 -14
- package/agent-presets/dsmm-planner/agent.cordis.yml +10 -14
- package/agent-presets/dsmm-quick/agent.cordis.yml +10 -14
- package/agent-presets/dsmm-research/agent.cordis.yml +10 -14
- package/agent-presets/dsmm-reviewer/agent.cordis.yml +10 -14
- package/docs/agent-presets.md +3 -3
- package/docs/compatibility.md +2 -2
- package/docs/deferred-native-approval-risk.md +11 -1
- package/docs/design.md +1 -1
- package/docs/lsp.md +6 -2
- package/docs/maintenance.md +65 -0
- package/docs/model-routing.md +1 -1
- package/docs/native-permissions.md +23 -1
- package/docs/profiles.md +1 -1
- package/docs/releasing.md +51 -32
- package/docs/roadmap.md +3 -3
- package/docs/runtime-recovery.md +1 -1
- package/docs/safety-guards.md +23 -5
- package/docs/settings-status.md +1 -1
- package/lib/child-capture.js +5 -1
- package/lib/client/deployment-locales.js +1 -0
- package/lib/client/permission-locales.js +8 -8
- package/lib/client.js +18 -17
- package/lib/command-approval.d.ts +50 -0
- package/lib/command-approval.js +148 -0
- package/lib/core-permissions.d.ts +2 -1
- package/lib/core-permissions.js +6 -3
- package/lib/guards.d.ts +2 -1
- package/lib/guards.js +45 -8
- package/lib/index.d.ts +1 -1
- package/lib/index.js +4 -2
- package/lib/lsp.js +1 -1
- package/lib/permission-control.d.ts +5 -2
- package/lib/permission-control.js +46 -24
- package/lib/permission-controller.d.ts +2 -0
- package/lib/permission-controller.js +13 -8
- package/lib/permission-native-command.d.ts +2 -0
- package/lib/permission-native-command.js +9 -4
- package/lib/permission-native-rules.d.ts +2 -2
- package/lib/permission-native-rules.js +18 -13
- package/lib/permission-shell.d.ts +1 -1
- package/lib/permission-shell.js +2 -2
- package/lib/profile-diagnostics.js +1 -1
- package/lib/profiles.js +2 -1
- package/lib/prompt-content.js +2 -2
- package/lib/roles.js +2 -2
- package/lib/settings.d.ts +2 -0
- package/lib/settings.js +10 -0
- package/lib/shell-command.d.ts +16 -0
- package/lib/shell-command.js +443 -119
- package/package.json +38 -38
- package/patches/ocmm-lsp-mcp.example.cordis.patch.yml +1 -1
- package/prompts/deepwork.md +2 -2
- package/prompts/source/shared/dsh-host-contract.md +2 -2
- package/prompts/source/shared/locale.md +2 -2
- package/prompts/source/terminal/builder.md +2 -2
- package/prompts/source/terminal/clarifier.md +6 -6
- package/prompts/source/terminal/code-search.md +6 -6
- package/prompts/source/terminal/coding.md +6 -6
- package/prompts/source/terminal/complex.md +6 -6
- package/prompts/source/terminal/creative.md +6 -6
- package/prompts/source/terminal/cross-cutting.md +6 -6
- package/prompts/source/terminal/deep.md +6 -6
- package/prompts/source/terminal/doc-search.md +6 -6
- package/prompts/source/terminal/documenting.md +6 -6
- package/prompts/source/terminal/frontend.md +6 -6
- package/prompts/source/terminal/hard-reasoning.md +6 -6
- package/prompts/source/terminal/media-reader.md +6 -6
- package/prompts/source/terminal/normal-task.md +6 -6
- package/prompts/source/terminal/oracle-2nd.md +6 -6
- package/prompts/source/terminal/oracle.md +6 -6
- package/prompts/source/terminal/orchestrator.md +4 -4
- package/prompts/source/terminal/plan-critic.md +6 -6
- package/prompts/source/terminal/planner.md +6 -6
- package/prompts/source/terminal/quick.md +6 -6
- package/prompts/source/terminal/research.md +6 -6
- package/prompts/source/terminal/reviewer.md +6 -6
- package/skills/ast-grep/SKILL.md +3 -3
- package/skills/ast-grep/SOURCE +1 -1
- package/skills/ast-grep/install.ps1 +1 -1
- package/skills/ast-grep/install.sh +1 -1
- package/skills/ast-grep/scripts/ast_grep_helper.py +10 -10
- package/skills/ast-grep/tests/smoke.sh +11 -11
- package/skills/ast-grep/tests/test_resolver.py +4 -23
- package/skills/brainstorming/SKILL.md +3 -3
- package/skills/coding-agent-sessions/NOTICE.md +2 -2
- package/skills/coding-agent-sessions/SKILL.md +3 -3
- package/skills/debugging/SKILL.md +3 -3
- package/skills/debugging/references/methodology/03-flaky-triage.md +1 -1
- package/skills/debugging/references/scripts/dap.mjs +3 -3
- package/skills/debugging/references/tools/playwright-cli.md +3 -3
- package/skills/dispatching-parallel-agents/SKILL.md +3 -3
- package/skills/frontend/ATTRIBUTION.md +4 -4
- package/skills/frontend/SKILL.md +3 -3
- package/skills/frontend/references/perfection/README.md +4 -4
- package/skills/frontend/references/perfection/react-perf-tooling.md +4 -4
- package/skills/git-master/SKILL.md +3 -3
- package/skills/git-master/agents/openai.yaml +1 -1
- package/skills/init-deep/SKILL.md +3 -3
- package/skills/receiving-code-review/SKILL.md +3 -3
- package/skills/remove-ai-slops/SKILL.md +3 -3
- package/skills/requesting-code-review/SKILL.md +3 -3
- package/skills/subagent-driven-development/SKILL.md +3 -3
- package/skills/using-git-worktrees/SKILL.md +4 -4
- package/skills/writing-plans/SKILL.md +3 -3
- package/docs/migration-from-ocmm.md +0 -57
- package/docs/skill-sync.md +0 -94
- package/prompts/source/manifest.json +0 -3168
|
@@ -4,6 +4,7 @@ import { HarnessError } from "@deepseek-ai/dsh-llm";
|
|
|
4
4
|
import { TOOL_ABORTED } from "@deepseek-ai/dsh-tools";
|
|
5
5
|
import { PermissionRefusal, permissionOutcome } from "./permission-errors.js";
|
|
6
6
|
import { nativeStandingFullAccess } from "./permission-native-access.js";
|
|
7
|
+
import { CommandApprovals } from "./command-approval.js";
|
|
7
8
|
export { PermissionRefusal } from "./permission-errors.js";
|
|
8
9
|
export function permissionOriginal(value) { return Reflect.get(value, symbols.original) ?? value; }
|
|
9
10
|
/** Explicitly audited DSMM approval adapters retain identity through the patched dispatcher. */
|
|
@@ -24,12 +25,14 @@ export class PermissionControl {
|
|
|
24
25
|
bindings = new Map();
|
|
25
26
|
requests = new WeakMap();
|
|
26
27
|
execution = new AsyncLocalStorage();
|
|
27
|
-
|
|
28
|
+
commandApprovals;
|
|
29
|
+
constructor(ctx, collaborators, approvals) {
|
|
28
30
|
this.ctx = ctx;
|
|
29
31
|
this.collaborators = collaborators;
|
|
32
|
+
this.commandApprovals = approvals ?? new CommandApprovals(ctx);
|
|
30
33
|
}
|
|
31
|
-
async compose(exec, registration, entry, action, next, cwd, simple = false) {
|
|
32
|
-
const previous = this.bindings.get(exec
|
|
34
|
+
async compose(exec, registration, entry, action, next, cwd, simple = false, contributions = [], source = {}) {
|
|
35
|
+
const previous = this.bindings.get(exec);
|
|
33
36
|
if (simple && previous?.simple) {
|
|
34
37
|
this.checkIntegrity(previous);
|
|
35
38
|
return this.composeDecision(previous, next, false);
|
|
@@ -54,22 +57,30 @@ export class PermissionControl {
|
|
|
54
57
|
const args = exec.arguments;
|
|
55
58
|
const officialMode = !nativeOnly && (args.sandbox_permissions === "workspace-write" || args.sandbox_permissions === "danger-full-access") ? args.sandbox_permissions : undefined;
|
|
56
59
|
const standing = registration.standingMode(exec);
|
|
57
|
-
const target = simple ? "danger-full-access" : officialMode ?? (entry === undefined ? undefined : isSandboxWidening(entry.sandboxMode, standing) ? entry.sandboxMode : standing ?? entry.sandboxMode);
|
|
58
|
-
const
|
|
60
|
+
const target = simple ? "danger-full-access" : officialMode ?? (entry === undefined ? undefined : isSandboxWidening(entry.sandboxMode, standing) ? entry.sandboxMode : entry.mode === "allow" ? standing ?? entry.sandboxMode : undefined);
|
|
61
|
+
const rules = simple || nativeOnly || contributions.length === 0 ? undefined : this.commandApprovals.capture(exec, contributions, {
|
|
62
|
+
...source, deferredCommit: true, owner: authority?.owner, ownerGeneration: authority?.ownerGeneration, realm: authority?.realm, assertCurrent: () => integrity.assertCurrent(),
|
|
63
|
+
});
|
|
64
|
+
const ask = !simple && (rules === undefined ? action === "ask" || entry?.mode === "ask" : rules.missing.length > 0);
|
|
65
|
+
const ruleNames = (rules?.missing ?? contributions).map(rule => {
|
|
66
|
+
const semantics = rule.semantics;
|
|
67
|
+
return semantics !== null && typeof semantics === "object" && "id" in semantics ? `${rule.kind}:${String(semantics.id)}` : rule.kind;
|
|
68
|
+
});
|
|
69
|
+
const reason = `DSMM command: ${String(args.command)}\nWorking directory: ${cwd}\n${ruleNames.length === 0 ? "" : `Command rules: ${ruleNames.join(", ")}\n`}Sandbox mode: ${target ?? "native standing policy"}. ${target === "danger-full-access" ? "Command execution may write outside the workspace to any OS-permitted location; this is not a cache-only or path-whitelist grant." : "Exact native tool invocation under the stated native sandbox policy."}`;
|
|
59
70
|
const lifetime = new AbortController();
|
|
60
|
-
const binding = { exec, args: exec.arguments, agent: exec.agent, callId: exec.callId, name: exec.name,
|
|
71
|
+
const binding = { exec, token: exec.token, session: exec.agent?.session, args: exec.arguments, agent: exec.agent, callId: exec.callId, name: exec.name,
|
|
61
72
|
registration, root: authority?.root, integrity, entry, officialMode, simple,
|
|
62
73
|
target: target === "workspace-write" || target === "danger-full-access" ? target : undefined,
|
|
63
|
-
reason, ask
|
|
74
|
+
reason, ask, rules, lifetime,
|
|
64
75
|
signal: AbortSignal.any([exec.signal, lifetime.signal, this.lifetime.signal,
|
|
65
76
|
...integrity.signal === undefined ? [] : [integrity.signal], ...registration.signal === undefined ? [] : [registration.signal]]),
|
|
66
|
-
entered: false, nativeRequest: false };
|
|
77
|
+
entered: false, nativeRequest: false, askSatisfied: !ask };
|
|
67
78
|
this.checkIntegrity(binding);
|
|
68
|
-
this.bindings.set(exec
|
|
79
|
+
this.bindings.set(exec, binding);
|
|
69
80
|
return this.composeDecision(binding, next, nativeOnly);
|
|
70
81
|
}
|
|
71
82
|
async composeDecision(binding, next, nativeOnly) {
|
|
72
|
-
const { exec, registration,
|
|
83
|
+
const { exec, registration, reason } = binding;
|
|
73
84
|
const downstream = await next();
|
|
74
85
|
if (exec.signal.aborted)
|
|
75
86
|
return { kind: "cancel" };
|
|
@@ -78,13 +89,13 @@ export class PermissionControl {
|
|
|
78
89
|
return downstream;
|
|
79
90
|
if (nativeOnly)
|
|
80
91
|
return downstream;
|
|
81
|
-
const needsAsk = downstream.kind === "ask" || binding.ask && (entry === undefined || officialMode !== undefined);
|
|
92
|
+
const needsAsk = downstream.kind === "ask" || binding.ask && (binding.entry === undefined || binding.officialMode !== undefined);
|
|
82
93
|
if (!needsAsk)
|
|
83
94
|
return downstream;
|
|
84
95
|
const reasons = [downstream.kind === "ask" ? downstream.reason : undefined, reason].filter(Boolean).join("\n");
|
|
85
96
|
const displayReason = Object.freeze({ en: reasons, zh: reasons,
|
|
86
97
|
...downstream.kind === "ask" && downstream.displayReason !== undefined ? Object.fromEntries(Object.entries(downstream.displayReason).map(([locale, text]) => [locale, `${text}\n${reason}`])) : {} });
|
|
87
|
-
if (binding.target === undefined)
|
|
98
|
+
if (binding.target === undefined && !binding.ask)
|
|
88
99
|
return { kind: "ask", reason: reasons, displayReason };
|
|
89
100
|
const approval = registration.approval();
|
|
90
101
|
if (approval === undefined || exec.agent === undefined)
|
|
@@ -96,6 +107,8 @@ export class PermissionControl {
|
|
|
96
107
|
this.checkIntegrity(binding);
|
|
97
108
|
if (outcome !== "allowed-once")
|
|
98
109
|
return { kind: "deny", reason: `Native command approval ${outcome}.` };
|
|
110
|
+
binding.rules?.resolved(outcome);
|
|
111
|
+
binding.askSatisfied = true;
|
|
99
112
|
binding.approvedTarget = binding.target;
|
|
100
113
|
return { kind: "allow" };
|
|
101
114
|
}
|
|
@@ -103,15 +116,16 @@ export class PermissionControl {
|
|
|
103
116
|
if (binding.signal.aborted || binding.exec.signal.aborted)
|
|
104
117
|
throw new HarnessError("Permission-controlled call cancelled.", TOOL_ABORTED);
|
|
105
118
|
const { exec, registration } = binding;
|
|
106
|
-
if (exec.arguments !== binding.args || exec.agent !== binding.agent || exec.callId !== binding.callId || exec.name !== binding.name
|
|
119
|
+
if (exec.token !== binding.token || exec.agent?.session !== binding.session || exec.arguments !== binding.args || exec.agent !== binding.agent || exec.callId !== binding.callId || exec.name !== binding.name
|
|
107
120
|
|| !registration.active || !registration.unchanged() || registration.definition.execute !== (registration.wrapper ?? registration.body)
|
|
108
121
|
|| this.ctx.tools.get(binding.name, binding.agent) !== registration.registered)
|
|
109
122
|
throw new PermissionRefusal("stale");
|
|
110
123
|
binding.integrity.assertCurrent();
|
|
111
124
|
registration.assertIntegrity?.(exec);
|
|
125
|
+
binding.rules?.assertCurrent();
|
|
112
126
|
}
|
|
113
127
|
guard(exec) {
|
|
114
|
-
const binding = this.bindings.get(exec
|
|
128
|
+
const binding = this.bindings.get(exec);
|
|
115
129
|
if (binding === undefined)
|
|
116
130
|
return undefined;
|
|
117
131
|
try {
|
|
@@ -138,7 +152,7 @@ export class PermissionControl {
|
|
|
138
152
|
return owned.allow ? "allowed-once" : permissionOutcome(next, owned.binding.signal, "cancelled");
|
|
139
153
|
}
|
|
140
154
|
isSimple(exec) {
|
|
141
|
-
const binding = this.bindings.get(exec
|
|
155
|
+
const binding = this.bindings.get(exec);
|
|
142
156
|
if (binding?.simple !== true)
|
|
143
157
|
return false;
|
|
144
158
|
this.checkIntegrity(binding);
|
|
@@ -146,7 +160,7 @@ export class PermissionControl {
|
|
|
146
160
|
}
|
|
147
161
|
pending(registration) { return [...this.bindings.values()].some(binding => binding.registration === registration); }
|
|
148
162
|
async run(exec, args, registration, body) {
|
|
149
|
-
const binding = this.bindings.get(exec
|
|
163
|
+
const binding = this.bindings.get(exec);
|
|
150
164
|
if (binding === undefined && registration.simpleOnly)
|
|
151
165
|
return body(exec.signal, args);
|
|
152
166
|
if (binding === undefined || binding.registration !== registration || binding.entered || args !== binding.args)
|
|
@@ -155,7 +169,7 @@ export class PermissionControl {
|
|
|
155
169
|
this.checkIntegrity(binding);
|
|
156
170
|
binding.entered = true;
|
|
157
171
|
try {
|
|
158
|
-
if (binding.entry !== undefined && binding.officialMode === undefined && !nativeStandingFullAccess(this.ctx, exec.agent)) {
|
|
172
|
+
if (binding.entry !== undefined && (binding.target !== undefined || !binding.askSatisfied) && binding.officialMode === undefined && !nativeStandingFullAccess(this.ctx, exec.agent)) {
|
|
159
173
|
if (binding.approvedTarget === undefined) {
|
|
160
174
|
const approval = registration.approval();
|
|
161
175
|
if (approval === undefined || exec.agent === undefined)
|
|
@@ -166,10 +180,13 @@ export class PermissionControl {
|
|
|
166
180
|
throw new HarnessError("Native permission request cancelled.", TOOL_ABORTED);
|
|
167
181
|
if (outcome !== "allowed-once")
|
|
168
182
|
throw new PermissionRefusal(outcome === "unavailable" ? "unavailable" : "denied");
|
|
183
|
+
binding.rules?.resolved(outcome);
|
|
184
|
+
binding.askSatisfied = true;
|
|
169
185
|
binding.approvedTarget = binding.target;
|
|
170
186
|
}
|
|
171
187
|
binding.mode = binding.approvedTarget;
|
|
172
188
|
}
|
|
189
|
+
this.commandApprovals.commit(binding.exec);
|
|
173
190
|
return await this.execution.run(binding, () => body(binding.signal, binding.simple ? Object.freeze({ ...args,
|
|
174
191
|
sandbox_permissions: "danger-full-access", justification: binding.reason }) : args));
|
|
175
192
|
}
|
|
@@ -204,10 +221,14 @@ export class PermissionControl {
|
|
|
204
221
|
}
|
|
205
222
|
const actual = { ...request, reason: [request.reason, binding.reason].filter(Boolean).join("\n") };
|
|
206
223
|
const covers = binding.entry !== undefined && (binding.entry.sandboxMode === "danger-full-access" || binding.officialMode === "workspace-write");
|
|
207
|
-
|
|
224
|
+
const outcome = await this.request(binding, actual, service, covers && binding.entry.mode === "allow" && !binding.ask);
|
|
225
|
+
binding.rules?.resolved(outcome);
|
|
226
|
+
if (outcome === "allowed-once")
|
|
227
|
+
this.commandApprovals.commit(binding.exec);
|
|
228
|
+
return outcome;
|
|
208
229
|
}
|
|
209
230
|
approvedTarget(exec) {
|
|
210
|
-
const binding = this.bindings.get(exec
|
|
231
|
+
const binding = this.bindings.get(exec);
|
|
211
232
|
if (binding === undefined)
|
|
212
233
|
return undefined;
|
|
213
234
|
this.checkIntegrity(binding);
|
|
@@ -224,20 +245,21 @@ export class PermissionControl {
|
|
|
224
245
|
return mode;
|
|
225
246
|
}
|
|
226
247
|
finish(exec) {
|
|
227
|
-
const binding = this.bindings.get(exec
|
|
248
|
+
const binding = this.bindings.get(exec);
|
|
228
249
|
if (binding !== undefined) {
|
|
229
250
|
binding.mode = undefined;
|
|
230
251
|
binding.approvedTarget = undefined;
|
|
231
252
|
binding.lifetime.abort();
|
|
232
253
|
}
|
|
233
|
-
this.bindings.delete(exec
|
|
254
|
+
this.bindings.delete(exec);
|
|
255
|
+
this.commandApprovals.finish(exec);
|
|
234
256
|
}
|
|
235
|
-
revokePolicy() { }
|
|
257
|
+
revokePolicy() { this.commandApprovals.invalidate(); }
|
|
236
258
|
revokeRegistration(registration) { registration.active = false; }
|
|
237
|
-
revokeAgent(agent) { for (const binding of this.bindings.values())
|
|
259
|
+
revokeAgent(agent) { this.commandApprovals.revokeAgent(agent); for (const binding of this.bindings.values())
|
|
238
260
|
if (binding.agent === agent || binding.root === agent)
|
|
239
261
|
this.finish(binding.exec); }
|
|
240
|
-
retire() { this.lifetime.abort(); for (const binding of this.bindings.values()) {
|
|
262
|
+
retire() { this.lifetime.abort(); this.commandApprovals.invalidate(); for (const binding of this.bindings.values()) {
|
|
241
263
|
binding.lifetime.abort();
|
|
242
264
|
binding.mode = undefined;
|
|
243
265
|
binding.approvedTarget = undefined;
|
|
@@ -4,6 +4,7 @@ import type { ToolExecution } from "@deepseek-ai/dsh-tools";
|
|
|
4
4
|
import type { Agent } from "@deepseek-ai/dsh-agent";
|
|
5
5
|
import { PermissionControl } from "./permission-control.js";
|
|
6
6
|
import type { PermissionControlCollaborators } from "./permission-control.js";
|
|
7
|
+
import type { CommandApprovals } from "./command-approval.js";
|
|
7
8
|
import type { PermissionShellIdentity } from "./permission-shell.js";
|
|
8
9
|
import type { NativePermissionCapabilityView, NativePermissionFileSystem, NativePermissionToolIdentity } from "./permission-native-rules.js";
|
|
9
10
|
import type { PermissionRulesRuntimeSync } from "./permission-rules.js";
|
|
@@ -13,6 +14,7 @@ export type ManagedPermissionTool = "fs" | "fs-search" | "web";
|
|
|
13
14
|
type NativeToolKind = Exclude<NativePermissionToolIdentity["kind"], "shell">;
|
|
14
15
|
export declare const PERMISSION_CONTROLLER_INJECT: readonly ["tools", "agents"];
|
|
15
16
|
export interface PermissionControllerOptions {
|
|
17
|
+
readonly commandApprovals?: CommandApprovals;
|
|
16
18
|
/** The existing live Core owner/admission/Root/realm/run facts, not serialized settings or a ready boolean. */
|
|
17
19
|
readonly authority: PermissionControlCollaborators;
|
|
18
20
|
readonly rules: PermissionRulesRuntimeSync;
|
|
@@ -3,7 +3,7 @@ import { HarnessError } from "@deepseek-ai/dsh-llm";
|
|
|
3
3
|
import { TOOL_ABORTED } from "@deepseek-ai/dsh-tools";
|
|
4
4
|
import { isSandboxWidening, PermissionControl, PermissionRefusal, permissionApprovalAdapter, permissionOriginal } from "./permission-control.js";
|
|
5
5
|
import { classifyPermissionShell } from "./permission-shell.js";
|
|
6
|
-
import {
|
|
6
|
+
import { nativeCommandMatches, simpleCommandMatch, simpleShellCommand, simpleShellDialect } from "./permission-native-command.js";
|
|
7
7
|
import { NATIVE_PERMISSION_CAPABILITIES, registerNativePermissionRules } from "./permission-native-rules.js";
|
|
8
8
|
import { nativeStandingFullAccess } from "./permission-native-access.js";
|
|
9
9
|
export const PERMISSION_CONTROLLER_INJECT = ["tools", "agents"];
|
|
@@ -62,7 +62,7 @@ export class DsmmPermissionController extends Service {
|
|
|
62
62
|
throw new PermissionRefusal("stale");
|
|
63
63
|
},
|
|
64
64
|
};
|
|
65
|
-
this.permissions = new PermissionControl(ctx, authority);
|
|
65
|
+
this.permissions = new PermissionControl(ctx, authority, options.commandApprovals);
|
|
66
66
|
if (this.rules.status().mounted) {
|
|
67
67
|
registerNativePermissionRules(ctx, {
|
|
68
68
|
runtime: this.rules,
|
|
@@ -92,7 +92,7 @@ export class DsmmPermissionController extends Service {
|
|
|
92
92
|
return { signal: current.signal, assertCurrent: () => options.authority.assertCurrent(current, exec) };
|
|
93
93
|
},
|
|
94
94
|
assertCurrent: exec => authority.assertCurrent(authority.current(exec), exec),
|
|
95
|
-
managedShellDecision: async (exec, action, downstream, snapshot) => {
|
|
95
|
+
managedShellDecision: async (exec, action, downstream, snapshot, asks) => {
|
|
96
96
|
const definition = ctx.tools.get(exec.name, exec.agent), managed = definition === undefined ? undefined : this.registrations.get(definition);
|
|
97
97
|
if (managed === undefined)
|
|
98
98
|
throw new PermissionRefusal("stale");
|
|
@@ -100,14 +100,19 @@ export class DsmmPermissionController extends Service {
|
|
|
100
100
|
const full = nativeStandingFullAccess(ctx, exec.agent);
|
|
101
101
|
if (full)
|
|
102
102
|
return this.permissions.compose(exec, managed.registration, undefined, "inherit", downstream, workspace);
|
|
103
|
-
const
|
|
104
|
-
const
|
|
105
|
-
if (
|
|
103
|
+
const source = snapshot ?? this.rules.getPolicy(), policy = source.policy;
|
|
104
|
+
const entries = nativeCommandMatches(policy.nativeCommands, managed.kind, managed.shell, exec.arguments, workspace);
|
|
105
|
+
if (entries === "ambiguous")
|
|
106
106
|
managed.scope.logger.warn("Ambiguous native command sandbox modes; retaining native execution policy.");
|
|
107
|
-
|
|
107
|
+
const entry = entries === "ambiguous" ? undefined : entries.find(entry => entry.mode === "ask") ?? entries[0];
|
|
108
|
+
if (entry !== undefined && managed.scope.get("shell")?.sandboxMode === undefined)
|
|
108
109
|
return { kind: "deny", reason: "Native command sandbox enhancement is unavailable in this executor." };
|
|
109
110
|
const operation = classifyPermissionShell(managed.shell, exec.arguments, workspace, exec);
|
|
110
|
-
|
|
111
|
+
const contributions = [
|
|
112
|
+
...asks.map(rule => ({ kind: "shell", semantics: rule })),
|
|
113
|
+
...entries === "ambiguous" ? [] : entries.filter(entry => entry.mode === "ask").map(entry => ({ kind: "native-command", semantics: entry })),
|
|
114
|
+
];
|
|
115
|
+
return this.permissions.compose(exec, managed.registration, entry, action, downstream, operation.workingDirectory, false, contributions, { source, sourceCurrent: () => this.rules.getPolicy() });
|
|
111
116
|
},
|
|
112
117
|
});
|
|
113
118
|
ctx.on("tools/pre-execute", async (exec, next) => {
|
|
@@ -7,6 +7,8 @@ export declare function parseHostNativeCommands(input?: unknown): NativeCommands
|
|
|
7
7
|
* Unsupported syntax retains the ordinary native path. */
|
|
8
8
|
export declare function literalCommand(command: string, dialect: PermissionShellIdentity["dialect"], mode?: "legacy" | "simple"): readonly string[] | undefined;
|
|
9
9
|
export declare function nativeCommandMatch(settings: NativeCommandsSettings, tool: "bash" | "pwsh", identity: PermissionShellIdentity, args: unknown, workspace: string): NativeCommandEntry | "ambiguous" | undefined;
|
|
10
|
+
/** All matching entries retain provenance; mode ambiguity is resolved before any memory lookup. */
|
|
11
|
+
export declare function nativeCommandMatches(settings: NativeCommandsSettings, tool: "bash" | "pwsh", identity: PermissionShellIdentity, args: unknown, workspace: string): readonly NativeCommandEntry[] | "ambiguous";
|
|
10
12
|
export declare function simpleShellDialect(name: string): PermissionShellIdentity["dialect"] | undefined;
|
|
11
13
|
export declare function simpleShellCommand(args: unknown): string | undefined;
|
|
12
14
|
/** A simple hit carries no legacy entry, cwd grant, read trust or sandbox target. */
|
|
@@ -76,15 +76,20 @@ export function literalCommand(command, dialect, mode = "legacy") {
|
|
|
76
76
|
return Object.freeze(words);
|
|
77
77
|
}
|
|
78
78
|
export function nativeCommandMatch(settings, tool, identity, args, workspace) {
|
|
79
|
+
const matches = nativeCommandMatches(settings, tool, identity, args, workspace);
|
|
80
|
+
return matches === "ambiguous" ? matches : matches.find(entry => entry.mode === "ask") ?? matches[0];
|
|
81
|
+
}
|
|
82
|
+
/** All matching entries retain provenance; mode ambiguity is resolved before any memory lookup. */
|
|
83
|
+
export function nativeCommandMatches(settings, tool, identity, args, workspace) {
|
|
79
84
|
if (!settings.enabled || args === null || typeof args !== "object")
|
|
80
|
-
return
|
|
85
|
+
return [];
|
|
81
86
|
const command = Reflect.get(args, identity.commandField), modelCwd = identity.cwdField === undefined ? undefined : Reflect.get(args, identity.cwdField);
|
|
82
87
|
if (typeof command !== "string" || !isAbsolute(workspace) || modelCwd !== undefined && typeof modelCwd !== "string")
|
|
83
|
-
return
|
|
88
|
+
return [];
|
|
84
89
|
const cwd = normalize(modelCwd === undefined ? workspace : resolve(workspace, modelCwd));
|
|
85
90
|
const words = literalCommand(command, identity.dialect);
|
|
86
91
|
if (words === undefined)
|
|
87
|
-
return
|
|
92
|
+
return [];
|
|
88
93
|
const matches = parseHostNativeCommands(settings).entries.filter((entry) => {
|
|
89
94
|
if (typeof entry === "string")
|
|
90
95
|
return false;
|
|
@@ -96,7 +101,7 @@ export function nativeCommandMatch(settings, tool, identity, args, workspace) {
|
|
|
96
101
|
});
|
|
97
102
|
if (new Set(matches.map(entry => entry.sandboxMode)).size > 1)
|
|
98
103
|
return "ambiguous";
|
|
99
|
-
return matches
|
|
104
|
+
return matches;
|
|
100
105
|
}
|
|
101
106
|
export function simpleShellDialect(name) {
|
|
102
107
|
const lower = name.toLowerCase();
|
|
@@ -2,7 +2,7 @@ import type { Context } from "@deepseek-ai/cordis";
|
|
|
2
2
|
import type { PreToolDecision, ToolDefinition, ToolExecution } from "@deepseek-ai/dsh-tools";
|
|
3
3
|
import type { PermissionExecutionIntegrity } from "./permission-control.js";
|
|
4
4
|
import type { PermissionShellIdentity } from "./permission-shell.js";
|
|
5
|
-
import type { PermissionRuleSnapshot, PermissionRulesRuntimeSync } from "./permission-rules.js";
|
|
5
|
+
import type { PermissionRule, PermissionRuleSnapshot, PermissionRulesRuntimeSync } from "./permission-rules.js";
|
|
6
6
|
import type { PermissionRulesStatus } from "./permission-rules.js";
|
|
7
7
|
import type { PermissionRuleAction } from "./permission-settings.js";
|
|
8
8
|
export interface NativePermissionFsTarget {
|
|
@@ -44,7 +44,7 @@ export interface NativePermissionRulesOptions {
|
|
|
44
44
|
/** Pure restriction fallback for standalone consumers without an authority capture. */
|
|
45
45
|
assertCurrent(execution: Readonly<ToolExecution>): void;
|
|
46
46
|
/** Compose this exact registration's native request; never creates an independent approval UI. */
|
|
47
|
-
managedShellDecision?(execution: Readonly<ToolExecution>, action: Exclude<PermissionRuleAction, "deny">, downstream: () => Promise<PreToolDecision>, snapshot: PermissionRuleSnapshot | undefined): Promise<PreToolDecision>;
|
|
47
|
+
managedShellDecision?(execution: Readonly<ToolExecution>, action: Exclude<PermissionRuleAction, "deny">, downstream: () => Promise<PreToolDecision>, snapshot: PermissionRuleSnapshot | undefined, asks: readonly PermissionRule[]): Promise<PreToolDecision>;
|
|
48
48
|
}
|
|
49
49
|
/** The public native search tools accept pattern/path/include only; no model-controlled rg flags. */
|
|
50
50
|
export declare function parseNativePermissionReadPaths(kind: "read" | "glob" | "grep", input: unknown): readonly string[];
|
|
@@ -8,7 +8,7 @@ function unresolvedOutside(policy) {
|
|
|
8
8
|
const rules = policy.rules.filter(rule => !rule.revoked && rule.match.kind === "outside-read");
|
|
9
9
|
if (policy.outsideReads === "deny" || rules.some(rule => rule.action === "deny"))
|
|
10
10
|
return "deny";
|
|
11
|
-
return
|
|
11
|
+
return "inherit";
|
|
12
12
|
}
|
|
13
13
|
function text(input) {
|
|
14
14
|
if (typeof input !== "string" || input.trim().length === 0 || input.includes("\0"))
|
|
@@ -53,14 +53,14 @@ export function parseNativePermissionReadPaths(kind, input) {
|
|
|
53
53
|
export function registerNativePermissionRules(ctx, options) {
|
|
54
54
|
if (!options.runtime.status().mounted)
|
|
55
55
|
return () => { };
|
|
56
|
-
const bindings = new
|
|
56
|
+
const bindings = new WeakMap();
|
|
57
57
|
const asks = new WeakMap();
|
|
58
58
|
const lifetime = new AbortController();
|
|
59
59
|
const tools = ctx.tools;
|
|
60
60
|
const checkIntegrity = (exec, binding) => {
|
|
61
61
|
if (exec.signal.aborted || binding.signal.aborted)
|
|
62
62
|
throw new PermissionRefusal("cancelled");
|
|
63
|
-
if (exec.arguments !== binding.args || exec.agent !== binding.agent || exec.callId !== binding.callId || exec.name !== binding.name
|
|
63
|
+
if (exec !== binding.exec || exec.token !== binding.token || exec.arguments !== binding.args || exec.agent !== binding.agent || exec.callId !== binding.callId || exec.name !== binding.name
|
|
64
64
|
|| tools.get(binding.name, binding.agent) !== binding.definition || binding.definition.execute !== binding.body)
|
|
65
65
|
throw new PermissionRefusal("stale");
|
|
66
66
|
if (exec.agent !== undefined && ctx.agents.get(exec.agent.id) !== exec.agent)
|
|
@@ -89,6 +89,9 @@ export function registerNativePermissionRules(ctx, options) {
|
|
|
89
89
|
return "inherit";
|
|
90
90
|
const fs = binding.fs;
|
|
91
91
|
const configured = binding.snapshot.policy.outsideReads;
|
|
92
|
+
// Trusted reads impose only the existing deny boundary, never an outside-read ask.
|
|
93
|
+
if (unresolvedOutside(binding.snapshot.policy) !== "deny")
|
|
94
|
+
return "inherit";
|
|
92
95
|
if (fs === undefined || !isAbsolute(binding.workspaceRoot) || !isAbsolute(cwd) || direct && binding.identity.coLocated?.(exec, fs) !== true) {
|
|
93
96
|
// Unknown backends cannot satisfy inside or a path-specific allow.
|
|
94
97
|
return full ? "inherit" : unresolvedOutside(binding.snapshot.policy);
|
|
@@ -140,7 +143,7 @@ export function registerNativePermissionRules(ctx, options) {
|
|
|
140
143
|
return "deny";
|
|
141
144
|
decisions.push(action);
|
|
142
145
|
}
|
|
143
|
-
return intersectPermissionActions(decisions);
|
|
146
|
+
return intersectPermissionActions(decisions) === "deny" ? "deny" : "inherit";
|
|
144
147
|
};
|
|
145
148
|
const evaluate = async (exec, binding) => {
|
|
146
149
|
const { kind, shell } = binding.identity, policy = binding.snapshot.policy;
|
|
@@ -175,8 +178,10 @@ export function registerNativePermissionRules(ctx, options) {
|
|
|
175
178
|
return policy.rules.some(rule => !rule.revoked && rule.match.kind === "shell" && rule.action === "deny") ? "deny" : "inherit";
|
|
176
179
|
const operation = classifyPermissionShell(shell, exec.arguments, cwd, exec);
|
|
177
180
|
shell.readCapability?.assertCurrent(exec);
|
|
178
|
-
const
|
|
179
|
-
&& rule.match.command === operation.command && rule.match.workingDirectory === operation.workingDirectory)
|
|
181
|
+
const matched = policy.rules.filter(rule => !rule.revoked && rule.match.kind === "shell" && rule.match.executable === operation.executable
|
|
182
|
+
&& rule.match.command === operation.command && rule.match.workingDirectory === operation.workingDirectory);
|
|
183
|
+
binding.asks.push(...matched.filter(rule => rule.action === "ask"));
|
|
184
|
+
const rules = matched.map(rule => rule.action);
|
|
180
185
|
if (operation.effect !== "read") {
|
|
181
186
|
// Unknown reads cannot bypass a configured hard outside-read boundary.
|
|
182
187
|
const hardRead = operation.effect === "unknown" && (policy.outsideReads === "deny" || policy.rules.some(rule => !rule.revoked && rule.match.kind === "outside-read" && rule.action === "deny"));
|
|
@@ -207,11 +212,11 @@ export function registerNativePermissionRules(ctx, options) {
|
|
|
207
212
|
}
|
|
208
213
|
const authority = nativeOnly ? undefined : options.captureAuthority?.(exec);
|
|
209
214
|
const integrity = options.captureIntegrity?.(exec);
|
|
210
|
-
const binding = { definition, body: definition.execute, identity, snapshot, nativeOnly, authority, integrity,
|
|
215
|
+
const binding = { exec, token: exec.token, asks: [], definition, body: definition.execute, identity, snapshot, nativeOnly, authority, integrity,
|
|
211
216
|
args: exec.arguments, agent: exec.agent, name: exec.name, callId: exec.callId,
|
|
212
217
|
signal: AbortSignal.any([exec.signal, lifetime.signal, ...identity.signal === undefined ? [] : [identity.signal], ...integrity?.signal === undefined ? [] : [integrity.signal]]), approval: ctx.get("approval"), fs: identity.context.get("fs"),
|
|
213
218
|
workspaceRoot: exec.agent?.session.header.cwd ?? "" };
|
|
214
|
-
bindings.set(exec
|
|
219
|
+
bindings.set(exec, binding);
|
|
215
220
|
check(exec, binding);
|
|
216
221
|
let action = "inherit";
|
|
217
222
|
if (snapshot !== undefined) {
|
|
@@ -228,14 +233,14 @@ export function registerNativePermissionRules(ctx, options) {
|
|
|
228
233
|
if (action === "deny")
|
|
229
234
|
return { kind: "deny", reason: "DSMM native permission rule denied this tool call." };
|
|
230
235
|
if (identity.kind === "shell" && options.managedShellDecision !== undefined)
|
|
231
|
-
return options.managedShellDecision(exec, action, next, snapshot);
|
|
236
|
+
return options.managedShellDecision(exec, action, next, snapshot, binding.asks);
|
|
232
237
|
const downstream = await next();
|
|
233
238
|
if (exec.signal.aborted)
|
|
234
239
|
return { kind: "cancel" };
|
|
235
240
|
checkIntegrity(exec, binding);
|
|
236
241
|
if (downstream.kind === "deny" || downstream.kind === "cancel")
|
|
237
242
|
return downstream;
|
|
238
|
-
if (nativeOnly) {
|
|
243
|
+
if (nativeOnly || action !== "ask") {
|
|
239
244
|
if (downstream.kind !== "ask")
|
|
240
245
|
return downstream;
|
|
241
246
|
const displayReason = downstream.displayReason ?? Object.freeze({ en: downstream.reason ?? "" });
|
|
@@ -259,7 +264,7 @@ export function registerNativePermissionRules(ctx, options) {
|
|
|
259
264
|
return permissionOutcome(next, ask.binding.signal, "cancelled");
|
|
260
265
|
}), { prepend: true, global: true });
|
|
261
266
|
const unguard = tools.guard(exec => {
|
|
262
|
-
const binding = bindings.get(exec
|
|
267
|
+
const binding = bindings.get(exec);
|
|
263
268
|
if (binding === undefined)
|
|
264
269
|
return undefined;
|
|
265
270
|
try {
|
|
@@ -270,8 +275,8 @@ export function registerNativePermissionRules(ctx, options) {
|
|
|
270
275
|
return "Native tool execution identity is no longer current.";
|
|
271
276
|
}
|
|
272
277
|
});
|
|
273
|
-
const unresult = ctx.on("tools/result", exec => { bindings.delete(exec
|
|
274
|
-
const dispose = () => { lifetime.abort(); unhook(); unguard(); unresult(); unapproval();
|
|
278
|
+
const unresult = ctx.on("tools/result", exec => { bindings.delete(exec); }, { global: true });
|
|
279
|
+
const dispose = () => { lifetime.abort(); unhook(); unguard(); unresult(); unapproval(); };
|
|
275
280
|
return ctx.effect(() => dispose);
|
|
276
281
|
}
|
|
277
282
|
export const NATIVE_PERMISSION_CAPABILITIES = Object.freeze({ outsideReads: "tool-call-boundary", finalInode: false,
|
|
@@ -33,6 +33,6 @@ export interface PermissionShellReadPaths {
|
|
|
33
33
|
readonly workingDirectory: string;
|
|
34
34
|
readonly paths: readonly string[];
|
|
35
35
|
}
|
|
36
|
-
/** Typed DSMM extraction, not an SDK operand field. Undefined
|
|
36
|
+
/** Typed DSMM extraction, not an SDK operand field. Undefined leaves path facts unknown; deny and independent rules still apply. */
|
|
37
37
|
export declare function parsePermissionShellReadPaths(identity: PermissionShellIdentity, args: unknown, cwd: string, execution?: Readonly<ToolExecution>): PermissionShellReadPaths | undefined;
|
|
38
38
|
//# sourceMappingURL=permission-shell.d.ts.map
|
package/lib/permission-shell.js
CHANGED
|
@@ -99,7 +99,7 @@ export function classifyPermissionShell(identity, args, cwd, execution) {
|
|
|
99
99
|
effect = "unknown";
|
|
100
100
|
return Object.freeze({ effect, operations: Object.freeze(operations), rememberable: effect !== "unknown" && workingDirectory !== "", executable: identity.executable, command, workingDirectory });
|
|
101
101
|
}
|
|
102
|
-
/** Typed DSMM extraction, not an SDK operand field. Undefined
|
|
102
|
+
/** Typed DSMM extraction, not an SDK operand field. Undefined leaves path facts unknown; deny and independent rules still apply. */
|
|
103
103
|
export function parsePermissionShellReadPaths(identity, args, cwd, execution) {
|
|
104
104
|
const operation = classifyPermissionShell(identity, args, cwd, execution);
|
|
105
105
|
if (operation.effect !== "read" || operation.workingDirectory === "" || identity.readCapability === undefined)
|
|
@@ -108,7 +108,7 @@ export function parsePermissionShellReadPaths(identity, args, cwd, execution) {
|
|
|
108
108
|
return undefined;
|
|
109
109
|
const paths = [];
|
|
110
110
|
for (const segment of parseShellCommand(operation.command, identity.dialect)) {
|
|
111
|
-
// Redirects, pipelines
|
|
111
|
+
// Redirects, pipelines and Git object/pathspec semantics do not prove filesystem operands.
|
|
112
112
|
if (segment.tokens.some(token => token.kind === "operator" && ![";", "&&"].includes(token.value)))
|
|
113
113
|
return undefined;
|
|
114
114
|
const command = identity.readCapability.resolveExecutable(segment.words[0], operation.workingDirectory, execution);
|
|
@@ -40,7 +40,7 @@ const configFields = {
|
|
|
40
40
|
skills: "skills", roles: "roles", roleRouting: "role-routing", runtimePolicy: { strategy: null, rateLimit },
|
|
41
41
|
presets: { materialize: null, root: null }, subagents: { toolTopology: null, allowRouteOverride: null, enableRunInBackground: null, backgroundMode: null, maxDepth: null },
|
|
42
42
|
workflow: { policy: null, strictGates: null, reviewCap: null, finalReviewPolicy: null },
|
|
43
|
-
guards: { scope: null, shellCommandSafety: null, gitWriteGuard: null, toolOutputTruncation: { enabled: null, maxInlineBytes: null }, planFormatValidation: null, questionLabelHelper: { enabled: null, maxLabelChars: null }, todoDisciplineHelper: null },
|
|
43
|
+
guards: { scope: null, shellCommandSafety: null, gitWriteGuard: null, gitWriteScope: null, toolOutputTruncation: { enabled: null, maxInlineBytes: null }, planFormatValidation: null, questionLabelHelper: { enabled: null, maxLabelChars: null }, todoDisciplineHelper: null },
|
|
44
44
|
runtimeRecovery: { enabled: null, retryOnStatusCodes: [null], retryOnCodes: [null], fallbackRoutes: [route], maxFallbackAttempts: null, idleContinuation: { enabled: null, maxContinuations: null, prompt: null } },
|
|
45
45
|
lsp: { enabled: null, serverName: null, command: null, args: [null], cwd: null, env: {}, toolCallTimeoutMs: null, failOnStartupError: null }
|
|
46
46
|
};
|
package/lib/profiles.js
CHANGED
|
@@ -308,9 +308,10 @@ function workflow(value, field) {
|
|
|
308
308
|
}
|
|
309
309
|
function guards(value, field) {
|
|
310
310
|
const item = record(value, field);
|
|
311
|
-
keys(item, ["scope", "shellCommandSafety", "gitWriteGuard", "toolOutputTruncation", "planFormatValidation", "questionLabelHelper", "todoDisciplineHelper"], field);
|
|
311
|
+
keys(item, ["scope", "shellCommandSafety", "gitWriteGuard", "gitWriteScope", "toolOutputTruncation", "planFormatValidation", "questionLabelHelper", "todoDisciplineHelper"], field);
|
|
312
312
|
optional(item, "scope", (scope, path) => enumeration(scope, ["deepwork-or-dsmm-agent", "always", "off"], path), field);
|
|
313
313
|
optional(item, "gitWriteGuard", (policy, path) => enumeration(policy, ["ask", "deny", "off"], path), field);
|
|
314
|
+
optional(item, "gitWriteScope", (scope, path) => enumeration(scope, ["all-writes", "high-risk"], path), field);
|
|
314
315
|
for (const key of ["shellCommandSafety", "planFormatValidation", "todoDisciplineHelper"])
|
|
315
316
|
optional(item, key, bool, field);
|
|
316
317
|
optional(item, "toolOutputTruncation", (raw, path) => {
|
package/lib/prompt-content.js
CHANGED
|
@@ -15,7 +15,7 @@ export function readPromptAsset(path) {
|
|
|
15
15
|
}
|
|
16
16
|
export const SOURCE_ROLE_CATALOG = JSON.parse(readPromptAsset("catalog.json"));
|
|
17
17
|
export function buildRoleIdentity(role) {
|
|
18
|
-
return `You are ${role.name}
|
|
18
|
+
return `You are ${role.name}.`;
|
|
19
19
|
}
|
|
20
20
|
export function splitCategory(text) {
|
|
21
21
|
const calibrations = new Map();
|
|
@@ -25,6 +25,6 @@ export function splitCategory(text) {
|
|
|
25
25
|
export function buildRolePersona(role) {
|
|
26
26
|
const source = role.promptArtifact === null ? role.description : readPromptAsset(role.promptArtifact.replace("prompts/source/", ""));
|
|
27
27
|
const body = role.kind === "category" ? splitCategory(source).base : source;
|
|
28
|
-
return [
|
|
28
|
+
return [readPromptAsset("shared/locale.md"), body, readPromptAsset("shared/dsh-host-contract.md"), readPromptAsset(role.terminalArtifact.replace("prompts/source/", ""))].filter(Boolean).join("\n\n---\n\n");
|
|
29
29
|
}
|
|
30
30
|
//# sourceMappingURL=prompt-content.js.map
|
package/lib/roles.js
CHANGED
|
@@ -10,8 +10,8 @@ export const DSMM_ROLE_IDS = [
|
|
|
10
10
|
];
|
|
11
11
|
/** The one user-selectable composition; every other role is an internal delegation target. */
|
|
12
12
|
export const DSMM_DISPATCHER_ROLE = "dsmm-orchestrator";
|
|
13
|
-
//
|
|
14
|
-
// It carries no
|
|
13
|
+
// The maintained source catalog is checked against the exact literal ID inventory.
|
|
14
|
+
// It carries no provider/model default and requires only package assets.
|
|
15
15
|
export const DSMM_ROLES = SOURCE_ROLE_CATALOG.map((row) => ({
|
|
16
16
|
...row,
|
|
17
17
|
id: row.id,
|
package/lib/settings.d.ts
CHANGED
|
@@ -17,6 +17,7 @@ export type { DsmmSkillName, MvpSkillName } from "./skills.js";
|
|
|
17
17
|
export type DsmmFinalReviewPolicy = "simple-oracle-complex-reviewer" | "reviewer-only" | "off";
|
|
18
18
|
export type DsmmGuardScope = "deepwork-or-dsmm-agent" | "always" | "off";
|
|
19
19
|
export type DsmmGitWritePolicy = "ask" | "deny" | "off";
|
|
20
|
+
export type DsmmGitWriteScope = "all-writes" | "high-risk";
|
|
20
21
|
export type DsmmInvocationLevel = "normal" | "low" | "high" | "max";
|
|
21
22
|
export type DsmmLevelOverride = {
|
|
22
23
|
reasoningEffort: string;
|
|
@@ -50,6 +51,7 @@ export interface DsmmGuardSettings {
|
|
|
50
51
|
scope: DsmmGuardScope;
|
|
51
52
|
shellCommandSafety: boolean;
|
|
52
53
|
gitWriteGuard: DsmmGitWritePolicy;
|
|
54
|
+
gitWriteScope: DsmmGitWriteScope;
|
|
53
55
|
toolOutputTruncation: {
|
|
54
56
|
enabled: boolean;
|
|
55
57
|
maxInlineBytes: number;
|
package/lib/settings.js
CHANGED
|
@@ -36,6 +36,7 @@ export const DEFAULT_DSMM_SETTINGS = {
|
|
|
36
36
|
scope: "deepwork-or-dsmm-agent",
|
|
37
37
|
shellCommandSafety: true,
|
|
38
38
|
gitWriteGuard: "ask",
|
|
39
|
+
gitWriteScope: "all-writes",
|
|
39
40
|
toolOutputTruncation: {
|
|
40
41
|
enabled: true,
|
|
41
42
|
maxInlineBytes: 12000
|
|
@@ -105,6 +106,8 @@ const ROLE_ROUTING_VALIDATION_SCHEMA = Schema.transform(Schema.any(), (input) =>
|
|
|
105
106
|
rejectDeprecatedFields(input);
|
|
106
107
|
if (Object.hasOwn(input, "locale"))
|
|
107
108
|
validateLocale(input.locale);
|
|
109
|
+
if (isRoutingRecord(input.guards) && Object.hasOwn(input.guards, "gitWriteScope"))
|
|
110
|
+
validateShape(input.guards.gitWriteScope, GIT_WRITE_SCOPE_SCHEMA, ["guards", "gitWriteScope"]);
|
|
108
111
|
if (isRoutingRecord(input.runtimeRecovery) && Array.isArray(input.runtimeRecovery.fallbackRoutes)) {
|
|
109
112
|
for (const route of input.runtimeRecovery.fallbackRoutes) {
|
|
110
113
|
normalizeExplicitRoute(route);
|
|
@@ -154,6 +157,10 @@ const GIT_WRITE_POLICY_SCHEMA = Schema.union([
|
|
|
154
157
|
Schema.const("deny"),
|
|
155
158
|
Schema.const("off")
|
|
156
159
|
]).default(DEFAULT_DSMM_SETTINGS.guards.gitWriteGuard);
|
|
160
|
+
const GIT_WRITE_SCOPE_SCHEMA = Schema.union([
|
|
161
|
+
Schema.const("all-writes"),
|
|
162
|
+
Schema.const("high-risk")
|
|
163
|
+
]).default(DEFAULT_DSMM_SETTINGS.guards.gitWriteScope);
|
|
157
164
|
const TOOL_OUTPUT_TRUNCATION_SCHEMA = Schema.object({
|
|
158
165
|
enabled: Schema.boolean().default(DEFAULT_DSMM_SETTINGS.guards.toolOutputTruncation.enabled),
|
|
159
166
|
maxInlineBytes: Schema.number().default(DEFAULT_DSMM_SETTINGS.guards.toolOutputTruncation.maxInlineBytes)
|
|
@@ -166,6 +173,7 @@ const GUARDS_SCHEMA = Schema.object({
|
|
|
166
173
|
scope: GUARD_SCOPE_SCHEMA,
|
|
167
174
|
shellCommandSafety: Schema.boolean().default(DEFAULT_DSMM_SETTINGS.guards.shellCommandSafety),
|
|
168
175
|
gitWriteGuard: GIT_WRITE_POLICY_SCHEMA,
|
|
176
|
+
gitWriteScope: GIT_WRITE_SCOPE_SCHEMA,
|
|
169
177
|
toolOutputTruncation: TOOL_OUTPUT_TRUNCATION_SCHEMA,
|
|
170
178
|
planFormatValidation: Schema.boolean().default(DEFAULT_DSMM_SETTINGS.guards.planFormatValidation),
|
|
171
179
|
questionLabelHelper: QUESTION_LABEL_HELPER_SCHEMA,
|
|
@@ -672,6 +680,8 @@ function resolveWorkflowSettings(config) {
|
|
|
672
680
|
}
|
|
673
681
|
export function resolveGuardSettings(config) {
|
|
674
682
|
const defaults = DEFAULT_DSMM_SETTINGS.guards;
|
|
683
|
+
if (config !== undefined && Object.hasOwn(config, "gitWriteScope"))
|
|
684
|
+
validateShape(config.gitWriteScope, GIT_WRITE_SCOPE_SCHEMA, ["guards", "gitWriteScope"]);
|
|
675
685
|
return {
|
|
676
686
|
...defaults,
|
|
677
687
|
...config,
|
package/lib/shell-command.d.ts
CHANGED
|
@@ -12,6 +12,22 @@ export interface ParsedShellSegment {
|
|
|
12
12
|
words: readonly string[];
|
|
13
13
|
}
|
|
14
14
|
export declare function parseShellCommand(input: string, dialect: ShellDialect): readonly ParsedShellSegment[];
|
|
15
|
+
export interface GitStaticContext {
|
|
16
|
+
/** Literal spelling, not a claim about executable identity or repository confinement. */
|
|
17
|
+
readonly executable: string;
|
|
18
|
+
readonly globalOptions: readonly string[];
|
|
19
|
+
readonly environment: readonly string[];
|
|
20
|
+
}
|
|
21
|
+
export interface GitCommandAction {
|
|
22
|
+
readonly ruleId: `git.${string}`;
|
|
23
|
+
readonly action: string;
|
|
24
|
+
readonly risk: "write" | "high-risk";
|
|
25
|
+
/** Callers must also bind actual cwd, dialect, Agent and tool registration. */
|
|
26
|
+
readonly reusable: boolean;
|
|
27
|
+
readonly context: GitStaticContext;
|
|
28
|
+
}
|
|
29
|
+
/** Pure, finite Git classification; this is not a shell AST or an authorization grant. */
|
|
30
|
+
export declare function evaluateGitCommand(input: string, dialect: ShellDialect): readonly GitCommandAction[];
|
|
15
31
|
export declare function classifyKnownGitWrite(input: string, dialect: ShellDialect): string | undefined;
|
|
16
32
|
export type ShellDialectViolation = "powershell-export" | "powershell-source" | "powershell-dev-null" | "posix-powershell-env";
|
|
17
33
|
export declare function classifyShellDialectViolation(input: string, dialect: ShellDialect): ShellDialectViolation | undefined;
|