@dsmm/dsmm 0.2.0 → 0.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +38 -66
- package/agent-presets/dsmm-builder/agent.cordis.yml +10 -2015
- package/agent-presets/dsmm-clarifier/agent.cordis.yml +24 -343
- package/agent-presets/dsmm-code-search/agent.cordis.yml +19 -6
- package/agent-presets/dsmm-coding/agent.cordis.yml +19 -438
- package/agent-presets/dsmm-complex/agent.cordis.yml +23 -1009
- package/agent-presets/dsmm-creative/agent.cordis.yml +25 -442
- package/agent-presets/dsmm-cross-cutting/agent.cordis.yml +29 -1013
- package/agent-presets/dsmm-deep/agent.cordis.yml +24 -1008
- package/agent-presets/dsmm-doc-search/agent.cordis.yml +19 -6
- package/agent-presets/dsmm-documenting/agent.cordis.yml +26 -439
- package/agent-presets/dsmm-frontend/agent.cordis.yml +21 -440
- package/agent-presets/dsmm-hard-reasoning/agent.cordis.yml +22 -441
- package/agent-presets/dsmm-media-reader/agent.cordis.yml +19 -6
- package/agent-presets/dsmm-normal-task/agent.cordis.yml +19 -438
- package/agent-presets/dsmm-oracle/agent.cordis.yml +25 -340
- package/agent-presets/dsmm-oracle-2nd/agent.cordis.yml +25 -340
- package/agent-presets/dsmm-orchestrator/agent.cordis.yml +29 -2025
- package/agent-presets/dsmm-plan-critic/agent.cordis.yml +24 -341
- package/agent-presets/dsmm-planner/agent.cordis.yml +14 -344
- package/agent-presets/dsmm-quick/agent.cordis.yml +19 -6
- package/agent-presets/dsmm-research/agent.cordis.yml +23 -8
- package/agent-presets/dsmm-reviewer/agent.cordis.yml +25 -340
- package/docs/agent-presets.md +36 -52
- package/docs/compatibility.md +50 -108
- package/docs/deferred-native-approval-risk.md +19 -0
- package/docs/design.md +2 -2
- package/docs/lsp.md +11 -21
- package/docs/migration-from-ocmm.md +2 -2
- package/docs/model-routing.md +84 -59
- package/docs/native-permissions.md +35 -0
- package/docs/profiles.md +40 -87
- package/docs/releasing.md +83 -2
- package/docs/roadmap.md +71 -17
- package/docs/settings-status.md +34 -169
- package/docs/skill-sync.md +52 -15
- package/lib/child-admission-contract.d.ts +37 -0
- package/lib/child-admission-contract.js +2 -0
- package/lib/child-admission.d.ts +42 -0
- package/lib/child-admission.js +162 -0
- package/lib/child-capture.d.ts +81 -0
- package/lib/child-capture.js +203 -0
- package/lib/child-evidence.d.ts +17 -0
- package/lib/child-evidence.js +43 -0
- package/lib/client/ChildrenPanel.d.ts +43 -0
- package/lib/client/ChildrenPanel.js +82 -0
- package/lib/client/DeploymentPage.js +15 -8
- package/lib/client/EditableChoice.d.ts +17 -0
- package/lib/client/EditableChoice.js +49 -0
- package/lib/client/PermissionsPanel.d.ts +14 -0
- package/lib/client/PermissionsPanel.js +46 -0
- package/lib/client/ProfilesSection.js +30 -15
- package/lib/client/RoleAvailability.d.ts +7 -0
- package/lib/client/RoleAvailability.js +19 -0
- package/lib/client/SessionProfiles.js +27 -9
- package/lib/client/StructuredEditor.js +15 -7
- package/lib/client/children-controller.d.ts +98 -0
- package/lib/client/children-controller.js +296 -0
- package/lib/client/children-locales.d.ts +367 -0
- package/lib/client/children-locales.js +69 -0
- package/lib/client/controller.d.ts +6 -1
- package/lib/client/controller.js +14 -8
- package/lib/client/deployment-data.d.ts +2 -1
- package/lib/client/deployment-data.js +34 -5
- package/lib/client/deployment-locales.d.ts +4 -0
- package/lib/client/deployment-locales.js +11 -2
- package/lib/client/diagnostics.d.ts +14 -0
- package/lib/client/diagnostics.js +53 -0
- package/lib/client/index.d.ts +4 -0
- package/lib/client/index.js +96 -2
- package/lib/client/locales.d.ts +54 -0
- package/lib/client/locales.js +34 -16
- package/lib/client/permission-client.d.ts +16 -0
- package/lib/client/permission-client.js +38 -0
- package/lib/client/permission-controller.d.ts +62 -0
- package/lib/client/permission-controller.js +149 -0
- package/lib/client/permission-locales.d.ts +114 -0
- package/lib/client/permission-locales.js +75 -0
- package/lib/client/session-labels.js +4 -4
- package/lib/client/structured.js +19 -5
- package/lib/client/styles.d.ts +1 -1
- package/lib/client/styles.js +20 -0
- package/lib/client.js +5780 -1679
- package/lib/core-permission-authority.d.ts +18 -0
- package/lib/core-permission-authority.js +255 -0
- package/lib/core-permissions.d.ts +8 -0
- package/lib/core-permissions.js +33 -0
- package/lib/delivery-authority.d.ts +68 -0
- package/lib/delivery-authority.js +260 -0
- package/lib/deployment-config.d.ts +23 -0
- package/lib/deployment-config.js +61 -40
- package/lib/deployment-permission-rules.d.ts +55 -0
- package/lib/deployment-permission-rules.js +306 -0
- package/lib/dsh-types.d.ts +10 -4
- package/lib/guards.d.ts +1 -1
- package/lib/guards.js +29 -8
- package/lib/host-llm-startup.d.ts +41 -0
- package/lib/host-llm-startup.js +65 -0
- package/lib/host-llm.d.ts +92 -0
- package/lib/host-llm.js +325 -0
- package/lib/index.d.ts +15 -4
- package/lib/index.js +300 -47
- package/lib/legacy-child-policy.d.ts +51 -0
- package/lib/legacy-child-policy.js +123 -0
- package/lib/legacy-read-composition.d.ts +20 -0
- package/lib/legacy-read-composition.js +144 -0
- package/lib/legacy-read-contracts.d.ts +157 -0
- package/lib/legacy-read-contracts.js +39 -0
- package/lib/legacy-read-host.d.ts +19 -0
- package/lib/legacy-read-host.js +67 -0
- package/lib/legacy-read-integration.d.ts +121 -0
- package/lib/legacy-read-integration.js +522 -0
- package/lib/legacy-read-proxy.d.ts +26 -0
- package/lib/legacy-read-proxy.js +237 -0
- package/lib/live-pi-ai-owner.d.ts +18 -0
- package/lib/live-pi-ai-owner.js +144 -0
- package/lib/llm-runtime.d.ts +11 -0
- package/lib/llm-runtime.js +21 -0
- package/lib/managed-settings.d.ts +5 -0
- package/lib/managed-settings.js +14 -0
- package/lib/model-parameter-policy.d.ts +11 -0
- package/lib/model-parameter-policy.js +27 -0
- package/lib/model-routing.js +28 -17
- package/lib/modules.d.ts +13 -5
- package/lib/modules.js +17 -1
- package/lib/native-child-evidence.d.ts +42 -0
- package/lib/native-child-evidence.js +133 -0
- package/lib/native-pi-ai-wire.d.ts +37 -0
- package/lib/native-pi-ai-wire.js +261 -0
- package/lib/native-scope.js +1 -1
- package/lib/permission-bash.d.ts +6 -0
- package/lib/permission-bash.js +7 -0
- package/lib/permission-control.d.ts +73 -0
- package/lib/permission-control.js +205 -0
- package/lib/permission-controller.d.ts +68 -0
- package/lib/permission-controller.js +317 -0
- package/lib/permission-errors.d.ts +7 -0
- package/lib/permission-errors.js +21 -0
- package/lib/permission-fs-search.d.ts +5 -0
- package/lib/permission-fs-search.js +7 -0
- package/lib/permission-fs.d.ts +5 -0
- package/lib/permission-fs.js +7 -0
- package/lib/permission-native-access.d.ts +11 -0
- package/lib/permission-native-access.js +6 -0
- package/lib/permission-native-command.d.ts +10 -0
- package/lib/permission-native-command.js +93 -0
- package/lib/permission-native-rules.d.ts +75 -0
- package/lib/permission-native-rules.js +278 -0
- package/lib/permission-pwsh.d.ts +6 -0
- package/lib/permission-pwsh.js +7 -0
- package/lib/permission-remote.d.ts +26 -0
- package/lib/permission-remote.js +53 -0
- package/lib/permission-rpc.d.ts +29 -0
- package/lib/permission-rpc.js +152 -0
- package/lib/permission-rules.d.ts +115 -0
- package/lib/permission-rules.js +256 -0
- package/lib/permission-settings.d.ts +45 -0
- package/lib/permission-settings.js +48 -0
- package/lib/permission-shell.d.ts +38 -0
- package/lib/permission-shell.js +150 -0
- package/lib/permission-web.d.ts +5 -0
- package/lib/permission-web.js +7 -0
- package/lib/preset-registry.js +36 -25
- package/lib/profile-diagnostics.d.ts +45 -0
- package/lib/profile-diagnostics.js +148 -0
- package/lib/profile-locale.d.ts +3 -0
- package/lib/profile-locale.js +2 -0
- package/lib/profile-remote.d.ts +8 -0
- package/lib/profile-remote.js +163 -39
- package/lib/profile-rpc.d.ts +4 -3
- package/lib/profile-rpc.js +14 -12
- package/lib/profile-runtime.d.ts +40 -1
- package/lib/profile-runtime.js +368 -93
- package/lib/profile-store.d.ts +11 -0
- package/lib/profile-store.js +143 -11
- package/lib/profile-types.d.ts +70 -1
- package/lib/profile-types.js +1 -0
- package/lib/profiles.d.ts +16 -2
- package/lib/profiles.js +156 -79
- package/lib/prompt-content.js +1 -1
- package/lib/prompts.d.ts +37 -2
- package/lib/prompts.js +111 -9
- package/lib/recovery-policy.js +20 -7
- package/lib/role-control-remote.d.ts +38 -0
- package/lib/role-control-remote.js +211 -0
- package/lib/role-control-rpc.d.ts +51 -0
- package/lib/role-control-rpc.js +377 -0
- package/lib/role-control-types.d.ts +92 -0
- package/lib/role-control-types.js +8 -0
- package/lib/role-invocation.d.ts +47 -0
- package/lib/role-invocation.js +135 -0
- package/lib/role-llm-runtime.d.ts +17 -0
- package/lib/role-llm-runtime.js +62 -0
- package/lib/role-llm.d.ts +31 -0
- package/lib/role-llm.js +66 -0
- package/lib/role-policy.d.ts +49 -8
- package/lib/role-policy.js +437 -60
- package/lib/role-providers.d.ts +1 -1
- package/lib/role-providers.js +30 -35
- package/lib/role-routing.d.ts +11 -2
- package/lib/role-routing.js +42 -25
- package/lib/role-runs.d.ts +135 -0
- package/lib/role-runs.js +304 -0
- package/lib/role-subagents.d.ts +58 -3
- package/lib/role-subagents.js +169 -56
- package/lib/roles.d.ts +5 -6
- package/lib/roles.js +10 -39
- package/lib/route-json.d.ts +19 -0
- package/lib/route-json.js +129 -0
- package/lib/routing-policy.d.ts +2 -0
- package/lib/routing-policy.js +12 -2
- package/lib/runtime-integration.d.ts +112 -0
- package/lib/runtime-integration.js +784 -0
- package/lib/runtime-recovery.js +18 -8
- package/lib/settings.d.ts +47 -13
- package/lib/settings.js +217 -82
- package/lib/skills.js +2 -2
- package/lib/status.d.ts +10 -1
- package/lib/status.js +11 -8
- package/lib/subagent-runtime.d.ts +45 -0
- package/lib/subagent-runtime.js +131 -0
- package/package.json +106 -56
- package/patches/subagent-runtime.yml +15 -0
- package/prompts/deepseek-flash.md +1 -1
- package/prompts/deepseek-v4-pro.md +2 -2
- package/prompts/deepwork.md +27 -18
- package/prompts/source/agents/clarifier.md +5 -3
- package/prompts/source/agents/orchestrator.md +18 -9
- package/prompts/source/agents/plan-critic.md +5 -1
- package/prompts/source/agents/planner.md +4 -2
- package/prompts/source/agents/reviewer.md +6 -0
- package/prompts/source/category/complex.md +4 -4
- package/prompts/source/category/creative.md +6 -4
- package/prompts/source/category/cross-cutting.md +10 -8
- package/prompts/source/category/deep.md +5 -3
- package/prompts/source/category/documenting.md +7 -1
- package/prompts/source/category/frontend.md +2 -2
- package/prompts/source/category/hard-reasoning.md +3 -3
- package/prompts/source/category/research.md +4 -2
- package/prompts/source/deepwork/claude-opus-5.md +2 -2
- package/prompts/source/deepwork/codex.md +1 -1
- package/prompts/source/deepwork/default.md +22 -15
- package/prompts/source/deepwork/gemini.md +23 -16
- package/prompts/source/deepwork/glm.md +21 -14
- package/prompts/source/deepwork/gpt.md +12 -6
- package/prompts/source/deepwork/planner.md +8 -5
- package/prompts/source/manifest.json +178 -63
- package/prompts/source/shared/dsh-host-contract.md +5 -3
- package/prompts/source/shared/locale.md +2 -2
- package/prompts/source/terminal/orchestrator.md +1 -1
- package/scripts/cold-profile-composition.mjs +329 -0
- package/scripts/cold-profile-sources.mjs +238 -0
- package/scripts/migrate-cold-profile.mjs +315 -0
- package/skills/ast-grep/SKILL.md +7 -4
- package/skills/brainstorming/SKILL.md +43 -22
- package/skills/coding-agent-sessions/SKILL.md +7 -4
- package/skills/coding-agent-sessions/scripts/agent_sessions/pi_family.py +46 -46
- package/skills/coding-agent-sessions/scripts/tests/test_pi_family_scanners.py +130 -130
- package/skills/debugging/SKILL.md +14 -9
- package/skills/debugging/references/methodology/00-setup.md +14 -62
- package/skills/debugging/references/methodology/02-investigate.md +4 -4
- package/skills/debugging/references/methodology/03-flaky-triage.md +3 -3
- package/skills/debugging/references/methodology/04-hard-reasoning-escalation.md +2 -14
- package/skills/debugging/references/methodology/06-fix.md +6 -6
- package/skills/debugging/references/methodology/08-qa.md +5 -5
- package/skills/debugging/references/methodology/09-cleanup.md +15 -153
- package/skills/debugging/references/methodology/partial-runtime-evidence.md +3 -16
- package/skills/debugging/references/runtimes/bundled-js-binary.md +1 -16
- package/skills/debugging/references/runtimes/native-binary.md +9 -54
- package/skills/debugging/references/runtimes/node.md +4 -15
- package/skills/debugging/references/runtimes/python.md +3 -15
- package/skills/debugging/references/runtimes/rust.md +2 -18
- package/skills/debugging/references/tools/dap.md +1 -1
- package/skills/debugging/references/tools/ghidra.md +4 -15
- package/skills/debugging/references/tools/playwright-cli.md +3 -15
- package/skills/debugging/references/tools/pwntools.md +4 -16
- package/skills/dispatching-parallel-agents/SKILL.md +18 -16
- package/skills/frontend/SKILL.md +7 -4
- package/skills/frontend/references/design/react-dev-tooling-skill.md +1 -1
- package/skills/git-master/SKILL.md +7 -4
- package/skills/init-deep/SKILL.md +7 -4
- package/skills/receiving-code-review/SKILL.md +17 -12
- package/skills/remove-ai-slops/SKILL.md +39 -38
- package/skills/requesting-code-review/SKILL.md +19 -17
- package/skills/requesting-code-review/code-reviewer.md +13 -1
- package/skills/subagent-driven-development/SKILL.md +29 -26
- package/skills/subagent-driven-development/implementer-prompt.md +29 -11
- package/skills/subagent-driven-development/spec-reviewer-prompt.md +6 -1
- package/skills/using-git-worktrees/SKILL.md +7 -4
- package/skills/writing-plans/SKILL.md +29 -24
- package/skills/writing-plans/plan-document-reviewer-prompt.md +10 -1
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Context } from "@deepseek-ai/cordis";
|
|
2
|
+
import type { Agent } from "@deepseek-ai/dsh-agent";
|
|
3
|
+
export type NativePermissionMode = "workspace-write" | "danger-full-access";
|
|
4
|
+
export interface NativePermissionAccess {
|
|
5
|
+
readonly standingFullAccess: boolean;
|
|
6
|
+
/** An execution-local target authorized by a fulfilled original native request. */
|
|
7
|
+
readonly approvedSandboxMode?: NativePermissionMode;
|
|
8
|
+
}
|
|
9
|
+
/** Public effective native policy only; requested tool arguments are never authority. */
|
|
10
|
+
export declare function nativeStandingFullAccess(ctx: Context, agent?: Agent): boolean;
|
|
11
|
+
//# sourceMappingURL=permission-native-access.d.ts.map
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/** Public effective native policy only; requested tool arguments are never authority. */
|
|
2
|
+
export function nativeStandingFullAccess(ctx, agent) {
|
|
3
|
+
const sandbox = (agent?.ctx ?? ctx).get("sandboxPolicy");
|
|
4
|
+
return sandbox?.resolve(agent === undefined ? {} : { session: agent.session }).mode === "danger-full-access";
|
|
5
|
+
}
|
|
6
|
+
//# sourceMappingURL=permission-native-access.js.map
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { NativeCommandEntry, NativeCommandsSettings } from "./permission-settings.js";
|
|
2
|
+
import type { PermissionShellIdentity } from "./permission-shell.js";
|
|
3
|
+
/** Host-only validation: Windows drive-relative roots never authorize an enhancement. */
|
|
4
|
+
export declare function parseHostNativeCommands(input?: unknown): NativeCommandsSettings;
|
|
5
|
+
/** Finite literal grammar: ASCII blanks, bare literal tokens, and static quotes.
|
|
6
|
+
* POSIX quote fragments concatenate; PowerShell quotes must enclose a whole operand.
|
|
7
|
+
* Unsupported syntax retains the ordinary native path. */
|
|
8
|
+
export declare function literalCommand(command: string, dialect: PermissionShellIdentity["dialect"]): readonly string[] | undefined;
|
|
9
|
+
export declare function nativeCommandMatch(settings: NativeCommandsSettings, tool: "bash" | "pwsh", identity: PermissionShellIdentity, args: unknown, workspace: string): NativeCommandEntry | "ambiguous" | undefined;
|
|
10
|
+
//# sourceMappingURL=permission-native-command.d.ts.map
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import { isAbsolute, normalize, parse, resolve } from "node:path";
|
|
2
|
+
import { parseNativeCommands } from "./permission-settings.js";
|
|
3
|
+
import { PermissionRefusal } from "./permission-errors.js";
|
|
4
|
+
/** Host-only validation: Windows drive-relative roots never authorize an enhancement. */
|
|
5
|
+
export function parseHostNativeCommands(input = {}) {
|
|
6
|
+
const settings = parseNativeCommands(input);
|
|
7
|
+
return Object.freeze({ enabled: settings.enabled, entries: Object.freeze(settings.entries.map(entry => {
|
|
8
|
+
const cwd = entry.match.workingDirectory;
|
|
9
|
+
if (!isAbsolute(cwd) || process.platform === "win32" && parse(normalize(cwd)).root.length === 1)
|
|
10
|
+
throw new PermissionRefusal("validation");
|
|
11
|
+
return Object.freeze({ ...entry, match: Object.freeze({ ...entry.match, workingDirectory: normalize(cwd) }) });
|
|
12
|
+
})) });
|
|
13
|
+
}
|
|
14
|
+
/** Finite literal grammar: ASCII blanks, bare literal tokens, and static quotes.
|
|
15
|
+
* POSIX quote fragments concatenate; PowerShell quotes must enclose a whole operand.
|
|
16
|
+
* Unsupported syntax retains the ordinary native path. */
|
|
17
|
+
export function literalCommand(command, dialect) {
|
|
18
|
+
if (/[\u0000-\u0008\u000a-\u001f\u007f-\u009f\u2018-\u201f]/u.test(command) || command.includes("--%"))
|
|
19
|
+
return undefined;
|
|
20
|
+
const words = [];
|
|
21
|
+
let word = "", quote = "", started = false;
|
|
22
|
+
for (let index = 0; index < command.length; index++) {
|
|
23
|
+
const char = command[index];
|
|
24
|
+
if (quote !== "") {
|
|
25
|
+
if (char === quote) {
|
|
26
|
+
if (dialect === "powershell" && quote === "'" && command[index + 1] === "'") {
|
|
27
|
+
word += "'";
|
|
28
|
+
index++;
|
|
29
|
+
}
|
|
30
|
+
else {
|
|
31
|
+
// Adjacent PowerShell double quotes encode an embedded quote, not concatenation.
|
|
32
|
+
if (dialect === "powershell" && index + 1 < command.length && command[index + 1] !== " " && command[index + 1] !== "\t")
|
|
33
|
+
return undefined;
|
|
34
|
+
quote = "";
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
else if ((dialect === "powershell" && char === '"') || (quote === '"' && (char === "$" || char === "`")))
|
|
38
|
+
return undefined;
|
|
39
|
+
else if (char === "\\" && dialect === "posix" && quote === '"' && /[\\$`"]/u.test(command[index + 1] ?? ""))
|
|
40
|
+
return undefined;
|
|
41
|
+
else
|
|
42
|
+
word += char;
|
|
43
|
+
}
|
|
44
|
+
else if (char === "'" || char === '"') {
|
|
45
|
+
// A quoted PowerShell command name is an expression without a call operator.
|
|
46
|
+
if (dialect === "powershell" && (started || words.length === 0))
|
|
47
|
+
return undefined;
|
|
48
|
+
quote = char;
|
|
49
|
+
started = true;
|
|
50
|
+
}
|
|
51
|
+
else if (char === " " || char === "\t") {
|
|
52
|
+
if (started) {
|
|
53
|
+
words.push(word);
|
|
54
|
+
word = "";
|
|
55
|
+
started = false;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
else if (!/[\p{L}\p{M}\p{N}_./:=+%\-]/u.test(char) && !(char === "\\" && dialect === "powershell"))
|
|
59
|
+
return undefined;
|
|
60
|
+
else {
|
|
61
|
+
word += char;
|
|
62
|
+
started = true;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
if (quote !== "")
|
|
66
|
+
return undefined;
|
|
67
|
+
if (started)
|
|
68
|
+
words.push(word);
|
|
69
|
+
if (!words.length || words[0] === "" || words[0].includes("=") || dialect === "powershell" && /^(?:[\d+\-]|\.\d)/u.test(words[0])
|
|
70
|
+
|| /^(?:\.|eval|exec|invoke-expression|iex|cmd(?:\.exe)?|pwsh(?:\.exe)?|powershell(?:\.exe)?|bash|sh|zsh|env|sudo|node(?:\.exe)?|python[\d.]*(?:\.exe)?|command|builtin|time|if|then|elif|elseif|else|fi|for|foreach|while|until|do|done|case|esac|in|function|select|coproc|return|throw|exit|break|continue|trap|switch|try|catch|finally|class|enum|using|param|dynamicparam|filter|data|begin|process|end|configuration|workflow|parallel|sequence|default|define|from|var)$/iu.test(words[0].replace(/^.*[\\/]/u, "")))
|
|
71
|
+
return undefined;
|
|
72
|
+
return Object.freeze(words);
|
|
73
|
+
}
|
|
74
|
+
export function nativeCommandMatch(settings, tool, identity, args, workspace) {
|
|
75
|
+
if (!settings.enabled || args === null || typeof args !== "object")
|
|
76
|
+
return undefined;
|
|
77
|
+
const command = Reflect.get(args, identity.commandField), modelCwd = identity.cwdField === undefined ? undefined : Reflect.get(args, identity.cwdField);
|
|
78
|
+
if (typeof command !== "string" || !isAbsolute(workspace) || modelCwd !== undefined && typeof modelCwd !== "string")
|
|
79
|
+
return undefined;
|
|
80
|
+
const cwd = normalize(modelCwd === undefined ? workspace : resolve(workspace, modelCwd));
|
|
81
|
+
const words = literalCommand(command, identity.dialect);
|
|
82
|
+
if (words === undefined)
|
|
83
|
+
return undefined;
|
|
84
|
+
const matches = parseHostNativeCommands(settings).entries.filter(entry => {
|
|
85
|
+
const match = entry.match, argv = match.subcommand === undefined ? words.slice(1) : words.slice(2);
|
|
86
|
+
return match.tool === tool && match.executable === words[0] && normalize(match.workingDirectory) === cwd
|
|
87
|
+
&& (match.subcommand === undefined || match.subcommand === words[1]) && argv.length === match.args.length && argv.every((value, index) => value === match.args[index]);
|
|
88
|
+
});
|
|
89
|
+
if (new Set(matches.map(entry => entry.sandboxMode)).size > 1)
|
|
90
|
+
return "ambiguous";
|
|
91
|
+
return matches.find(entry => entry.mode === "ask") ?? matches[0];
|
|
92
|
+
}
|
|
93
|
+
//# sourceMappingURL=permission-native-command.js.map
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import type { Context } from "@deepseek-ai/cordis";
|
|
2
|
+
import type { PreToolDecision, ToolDefinition, ToolExecution } from "@deepseek-ai/dsh-tools";
|
|
3
|
+
import type { PermissionExecutionIntegrity } from "./permission-control.js";
|
|
4
|
+
import type { PermissionShellIdentity } from "./permission-shell.js";
|
|
5
|
+
import type { PermissionRulesRuntimeSync } from "./permission-rules.js";
|
|
6
|
+
import type { PermissionRulesStatus } from "./permission-rules.js";
|
|
7
|
+
import type { PermissionRuleAction } from "./permission-settings.js";
|
|
8
|
+
export interface NativePermissionFsTarget {
|
|
9
|
+
readonly targetKey: unknown;
|
|
10
|
+
readonly displayPath: string;
|
|
11
|
+
}
|
|
12
|
+
/** Structural public FS capability; keys are never parsed as paths. */
|
|
13
|
+
export interface NativePermissionFileSystem {
|
|
14
|
+
resolve(path: string, options?: {
|
|
15
|
+
cwd?: string;
|
|
16
|
+
signal?: AbortSignal;
|
|
17
|
+
}): Promise<NativePermissionFsTarget>;
|
|
18
|
+
contains(parent: NativePermissionFsTarget, child: NativePermissionFsTarget): boolean;
|
|
19
|
+
}
|
|
20
|
+
type FileSystem = NativePermissionFileSystem;
|
|
21
|
+
/** Supplied only by the owner of the actual registered definition/native execution context. */
|
|
22
|
+
export interface NativePermissionToolIdentity {
|
|
23
|
+
readonly kind: "read" | "glob" | "grep" | "shell" | "webSearch" | "webFetch";
|
|
24
|
+
readonly context: Context;
|
|
25
|
+
readonly signal?: AbortSignal;
|
|
26
|
+
readonly shell?: PermissionShellIdentity;
|
|
27
|
+
/** Live proof FS and direct rg/Shell executor share path and workspace semantics. No name/cwd inference. */
|
|
28
|
+
coLocated?(execution: Readonly<ToolExecution>, fs: FileSystem): boolean;
|
|
29
|
+
assertCurrent(execution: Readonly<ToolExecution>): void;
|
|
30
|
+
assertIntegrity?(execution: Readonly<ToolExecution>): void;
|
|
31
|
+
}
|
|
32
|
+
interface NativePermissionAuthority {
|
|
33
|
+
readonly signal: AbortSignal;
|
|
34
|
+
assertCurrent(): void;
|
|
35
|
+
}
|
|
36
|
+
export interface NativePermissionRulesOptions {
|
|
37
|
+
readonly runtime: PermissionRulesRuntimeSync;
|
|
38
|
+
captureIntegrity?(execution: Readonly<ToolExecution>): PermissionExecutionIntegrity;
|
|
39
|
+
/** Exact registration identity, never trust a matching tool name alone. */
|
|
40
|
+
identify(definition: ToolDefinition, execution: Readonly<ToolExecution>): NativePermissionToolIdentity | undefined;
|
|
41
|
+
/** Capture the invocation's original Core epoch after rule refresh. */
|
|
42
|
+
captureAuthority?(execution: Readonly<ToolExecution>): NativePermissionAuthority;
|
|
43
|
+
/** Pure restriction fallback for standalone consumers without an authority capture. */
|
|
44
|
+
assertCurrent(execution: Readonly<ToolExecution>): void;
|
|
45
|
+
/** Compose this exact registration's native request; never creates an independent approval UI. */
|
|
46
|
+
managedShellDecision?(execution: Readonly<ToolExecution>, action: Exclude<PermissionRuleAction, "deny">, downstream: () => Promise<PreToolDecision>): Promise<PreToolDecision>;
|
|
47
|
+
}
|
|
48
|
+
/** The public native search tools accept pattern/path/include only; no model-controlled rg flags. */
|
|
49
|
+
export declare function parseNativePermissionReadPaths(kind: "read" | "glob" | "grep", input: unknown): readonly string[];
|
|
50
|
+
/** Tool-call-boundary rules only. No body fence, scoped memory, socket isolation or final-inode guarantee. */
|
|
51
|
+
export declare function registerNativePermissionRules(ctx: Context, options: NativePermissionRulesOptions): () => void;
|
|
52
|
+
export interface NativePermissionCapabilities {
|
|
53
|
+
readonly outsideReads: "tool-call-boundary";
|
|
54
|
+
readonly finalInode: false;
|
|
55
|
+
readonly scopedMemory: "not-provided-by-native-rules";
|
|
56
|
+
readonly webFetch: "native-public-only";
|
|
57
|
+
readonly webSearchDestinations: "unsupported";
|
|
58
|
+
readonly proxyAddressBinding: "native-proxy-dependent";
|
|
59
|
+
readonly shellSockets: "native-executor-dependent";
|
|
60
|
+
readonly providerAuthMcp: "not-covered";
|
|
61
|
+
}
|
|
62
|
+
export declare const NATIVE_PERMISSION_CAPABILITIES: NativePermissionCapabilities;
|
|
63
|
+
export interface NativePermissionCapabilityView {
|
|
64
|
+
readonly limits: NativePermissionCapabilities;
|
|
65
|
+
readonly runtime: PermissionRulesStatus;
|
|
66
|
+
/** Registry presence, not executor readiness, network reachability or final-body ownership. */
|
|
67
|
+
readonly tools: readonly {
|
|
68
|
+
readonly name: string;
|
|
69
|
+
readonly kind: NativePermissionToolIdentity["kind"];
|
|
70
|
+
readonly approval: "native-once";
|
|
71
|
+
readonly scopedMemory: false;
|
|
72
|
+
}[];
|
|
73
|
+
}
|
|
74
|
+
export {};
|
|
75
|
+
//# sourceMappingURL=permission-native-rules.d.ts.map
|
|
@@ -0,0 +1,278 @@
|
|
|
1
|
+
import { isAbsolute, resolve } from "node:path";
|
|
2
|
+
import { PermissionRefusal } from "./permission-control.js";
|
|
3
|
+
import { permissionOutcome } from "./permission-errors.js";
|
|
4
|
+
import { classifyPermissionShell, parsePermissionShellReadPaths } from "./permission-shell.js";
|
|
5
|
+
import { intersectPermissionActions } from "./permission-rules.js";
|
|
6
|
+
import { nativeStandingFullAccess } from "./permission-native-access.js";
|
|
7
|
+
function unresolvedOutside(policy) {
|
|
8
|
+
const rules = policy.rules.filter(rule => !rule.revoked && rule.match.kind === "outside-read");
|
|
9
|
+
if (policy.outsideReads === "deny" || rules.some(rule => rule.action === "deny"))
|
|
10
|
+
return "deny";
|
|
11
|
+
return policy.outsideReads === "inherit" && rules.length === 0 ? "inherit" : "ask";
|
|
12
|
+
}
|
|
13
|
+
function text(input) {
|
|
14
|
+
if (typeof input !== "string" || input.trim().length === 0 || input.includes("\0"))
|
|
15
|
+
throw new PermissionRefusal("validation");
|
|
16
|
+
return input;
|
|
17
|
+
}
|
|
18
|
+
function args(exec) {
|
|
19
|
+
if (exec.arguments === null || typeof exec.arguments !== "object" || Array.isArray(exec.arguments))
|
|
20
|
+
throw new PermissionRefusal("validation");
|
|
21
|
+
return exec.arguments;
|
|
22
|
+
}
|
|
23
|
+
/** The public native search tools accept pattern/path/include only; no model-controlled rg flags. */
|
|
24
|
+
export function parseNativePermissionReadPaths(kind, input) {
|
|
25
|
+
if (input === null || typeof input !== "object" || Array.isArray(input))
|
|
26
|
+
throw new PermissionRefusal("validation");
|
|
27
|
+
const row = input;
|
|
28
|
+
if (kind === "read")
|
|
29
|
+
return [text(row.file_path)];
|
|
30
|
+
if (kind === "glob")
|
|
31
|
+
text(row.pattern);
|
|
32
|
+
else {
|
|
33
|
+
if (typeof row.pattern !== "string" || row.pattern.length === 0)
|
|
34
|
+
throw new PermissionRefusal("validation");
|
|
35
|
+
if (row.include !== undefined) {
|
|
36
|
+
const include = text(row.include);
|
|
37
|
+
let depth = 0;
|
|
38
|
+
if (include.startsWith("!"))
|
|
39
|
+
throw new PermissionRefusal("validation");
|
|
40
|
+
for (const char of include) {
|
|
41
|
+
if (char === "{")
|
|
42
|
+
depth++;
|
|
43
|
+
else if (char === "}")
|
|
44
|
+
depth = Math.max(0, depth - 1);
|
|
45
|
+
else if (char === "," && depth === 0)
|
|
46
|
+
throw new PermissionRefusal("validation");
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
return [row.path === undefined ? "." : text(row.path)];
|
|
51
|
+
}
|
|
52
|
+
/** Tool-call-boundary rules only. No body fence, scoped memory, socket isolation or final-inode guarantee. */
|
|
53
|
+
export function registerNativePermissionRules(ctx, options) {
|
|
54
|
+
if (!options.runtime.status().mounted)
|
|
55
|
+
return () => { };
|
|
56
|
+
const bindings = new Map();
|
|
57
|
+
const asks = new WeakMap();
|
|
58
|
+
const lifetime = new AbortController();
|
|
59
|
+
const tools = ctx.tools;
|
|
60
|
+
const checkIntegrity = (exec, binding) => {
|
|
61
|
+
if (exec.signal.aborted || binding.signal.aborted)
|
|
62
|
+
throw new PermissionRefusal("cancelled");
|
|
63
|
+
if (exec.arguments !== binding.args || exec.agent !== binding.agent || exec.callId !== binding.callId || exec.name !== binding.name
|
|
64
|
+
|| tools.get(binding.name, binding.agent) !== binding.definition || binding.definition.execute !== binding.body)
|
|
65
|
+
throw new PermissionRefusal("stale");
|
|
66
|
+
if (exec.agent !== undefined && ctx.agents.get(exec.agent.id) !== exec.agent)
|
|
67
|
+
throw new PermissionRefusal("not-owned");
|
|
68
|
+
binding.identity.assertIntegrity?.(exec);
|
|
69
|
+
binding.integrity?.assertCurrent();
|
|
70
|
+
};
|
|
71
|
+
const check = (exec, binding) => {
|
|
72
|
+
checkIntegrity(exec, binding);
|
|
73
|
+
if (binding.nativeOnly)
|
|
74
|
+
return;
|
|
75
|
+
if (options.runtime.getPolicy() !== binding.snapshot)
|
|
76
|
+
throw new PermissionRefusal("stale");
|
|
77
|
+
if (binding.provenCoLocation && (binding.fs === undefined || binding.identity.coLocated?.(exec, binding.fs) !== true))
|
|
78
|
+
throw new PermissionRefusal("stale");
|
|
79
|
+
if ((exec.agent?.session.header.cwd ?? "") !== binding.workspaceRoot)
|
|
80
|
+
throw new PermissionRefusal("stale");
|
|
81
|
+
binding.identity.assertCurrent(exec);
|
|
82
|
+
if (binding.authority === undefined)
|
|
83
|
+
options.assertCurrent(exec);
|
|
84
|
+
else
|
|
85
|
+
binding.authority.assertCurrent();
|
|
86
|
+
};
|
|
87
|
+
const outside = async (exec, binding, paths, cwd, direct, full = false) => {
|
|
88
|
+
if (paths.length === 0)
|
|
89
|
+
return "inherit";
|
|
90
|
+
const fs = binding.fs;
|
|
91
|
+
const configured = binding.snapshot.policy.outsideReads;
|
|
92
|
+
if (fs === undefined || !isAbsolute(binding.workspaceRoot) || !isAbsolute(cwd) || direct && binding.identity.coLocated?.(exec, fs) !== true) {
|
|
93
|
+
// Unknown backends cannot satisfy inside or a path-specific allow.
|
|
94
|
+
return full ? "inherit" : unresolvedOutside(binding.snapshot.policy);
|
|
95
|
+
}
|
|
96
|
+
if (direct)
|
|
97
|
+
binding.provenCoLocation = true;
|
|
98
|
+
const root = await fs.resolve(binding.workspaceRoot, { signal: binding.signal });
|
|
99
|
+
check(exec, binding);
|
|
100
|
+
const decisions = [];
|
|
101
|
+
for (const path of paths) {
|
|
102
|
+
let target, inside;
|
|
103
|
+
try {
|
|
104
|
+
target = await fs.resolve(path, { cwd, signal: binding.signal });
|
|
105
|
+
inside = fs.contains(root, target);
|
|
106
|
+
}
|
|
107
|
+
catch (error) {
|
|
108
|
+
if (!full)
|
|
109
|
+
throw error;
|
|
110
|
+
checkIntegrity(exec, binding);
|
|
111
|
+
continue;
|
|
112
|
+
}
|
|
113
|
+
check(exec, binding);
|
|
114
|
+
if (inside)
|
|
115
|
+
continue;
|
|
116
|
+
const matched = [];
|
|
117
|
+
for (const rule of binding.snapshot.policy.rules) {
|
|
118
|
+
if (rule.revoked || rule.match.kind !== "outside-read")
|
|
119
|
+
continue;
|
|
120
|
+
let matches;
|
|
121
|
+
try {
|
|
122
|
+
const ruleTarget = await fs.resolve(rule.match.path, { cwd: binding.workspaceRoot, signal: binding.signal });
|
|
123
|
+
matches = rule.match.scope === "tree" ? fs.contains(ruleTarget, target) : ruleTarget.targetKey === target.targetKey;
|
|
124
|
+
}
|
|
125
|
+
catch (error) {
|
|
126
|
+
if (!full)
|
|
127
|
+
throw error;
|
|
128
|
+
checkIntegrity(exec, binding);
|
|
129
|
+
continue;
|
|
130
|
+
}
|
|
131
|
+
check(exec, binding);
|
|
132
|
+
if (matches) {
|
|
133
|
+
if (full && rule.action === "deny")
|
|
134
|
+
return "deny";
|
|
135
|
+
matched.push(rule.action);
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
const action = matched.length === 0 ? configured : intersectPermissionActions(matched);
|
|
139
|
+
if (full && action === "deny")
|
|
140
|
+
return "deny";
|
|
141
|
+
decisions.push(action);
|
|
142
|
+
}
|
|
143
|
+
return intersectPermissionActions(decisions);
|
|
144
|
+
};
|
|
145
|
+
const evaluate = async (exec, binding) => {
|
|
146
|
+
const { kind, shell } = binding.identity, policy = binding.snapshot.policy;
|
|
147
|
+
const full = binding.nativeOnly;
|
|
148
|
+
if (kind === "webSearch" || kind === "webFetch") {
|
|
149
|
+
if (!policy[kind].enabled)
|
|
150
|
+
return "deny";
|
|
151
|
+
const action = intersectPermissionActions([policy[kind].rule, ...policy.rules.filter(rule => !rule.revoked && rule.match.kind === kind).map(rule => rule.action)]);
|
|
152
|
+
return full && action !== "deny" ? "inherit" : action;
|
|
153
|
+
}
|
|
154
|
+
const cwd = binding.workspaceRoot;
|
|
155
|
+
if (full) {
|
|
156
|
+
const row = args(exec), explicitCwd = shell?.cwdField === undefined ? undefined : row[shell.cwdField];
|
|
157
|
+
const workingDirectory = typeof explicitCwd !== "string" ? cwd : isAbsolute(explicitCwd) ? explicitCwd : resolve(cwd, explicitCwd);
|
|
158
|
+
if (kind === "shell" && shell !== undefined && policy.rules.some(rule => !rule.revoked && rule.action === "deny"
|
|
159
|
+
&& rule.match.kind === "shell" && rule.match.executable === shell.executable && rule.match.command === row[shell.commandField]
|
|
160
|
+
&& rule.match.workingDirectory === workingDirectory))
|
|
161
|
+
return "deny";
|
|
162
|
+
if (policy.outsideReads !== "deny" && !policy.rules.some(rule => !rule.revoked && rule.action === "deny" && rule.match.kind === "outside-read"))
|
|
163
|
+
return "inherit";
|
|
164
|
+
// Unavailable path facts are not an explicit blacklist match in full access.
|
|
165
|
+
const parsed = kind === "shell" ? shell === undefined ? undefined : parsePermissionShellReadPaths(shell, exec.arguments, cwd, exec)
|
|
166
|
+
: { paths: parseNativePermissionReadPaths(kind, exec.arguments), workingDirectory: cwd };
|
|
167
|
+
if (parsed === undefined)
|
|
168
|
+
return "inherit";
|
|
169
|
+
const action = await outside(exec, binding, parsed.paths, parsed.workingDirectory, kind !== "read", true);
|
|
170
|
+
return action === "deny" ? "deny" : "inherit";
|
|
171
|
+
}
|
|
172
|
+
if (kind !== "shell")
|
|
173
|
+
return outside(exec, binding, parseNativePermissionReadPaths(kind, exec.arguments), cwd, kind !== "read");
|
|
174
|
+
if (shell === undefined)
|
|
175
|
+
return policy.rules.some(rule => !rule.revoked && rule.match.kind === "shell" && rule.action === "deny") ? "deny" : "inherit";
|
|
176
|
+
const operation = classifyPermissionShell(shell, exec.arguments, cwd, exec);
|
|
177
|
+
shell.readCapability?.assertCurrent(exec);
|
|
178
|
+
const rules = policy.rules.filter(rule => !rule.revoked && rule.match.kind === "shell" && rule.match.executable === operation.executable
|
|
179
|
+
&& rule.match.command === operation.command && rule.match.workingDirectory === operation.workingDirectory).map(rule => rule.action);
|
|
180
|
+
if (operation.effect !== "read") {
|
|
181
|
+
// Unknown reads cannot bypass a configured hard outside-read boundary.
|
|
182
|
+
const hardRead = operation.effect === "unknown" && (policy.outsideReads === "deny" || policy.rules.some(rule => !rule.revoked && rule.match.kind === "outside-read" && rule.action === "deny"));
|
|
183
|
+
return intersectPermissionActions([...rules, ...hardRead ? ["deny"] : []]);
|
|
184
|
+
}
|
|
185
|
+
const parsed = parsePermissionShellReadPaths(shell, exec.arguments, cwd, exec);
|
|
186
|
+
const access = parsed === undefined ? unresolvedOutside(policy)
|
|
187
|
+
: await outside(exec, binding, parsed.paths, parsed.workingDirectory, true);
|
|
188
|
+
return intersectPermissionActions([access, ...rules]);
|
|
189
|
+
};
|
|
190
|
+
const unhook = ctx.on("tools/pre-execute", async (exec, next) => {
|
|
191
|
+
const definition = tools.get(exec.name, exec.agent);
|
|
192
|
+
if (definition === undefined)
|
|
193
|
+
return next();
|
|
194
|
+
const identity = options.identify(definition, exec);
|
|
195
|
+
if (identity === undefined)
|
|
196
|
+
return next();
|
|
197
|
+
const nativeOnly = nativeStandingFullAccess(identity.context, exec.agent);
|
|
198
|
+
let snapshot;
|
|
199
|
+
try {
|
|
200
|
+
snapshot = await options.runtime.refresh();
|
|
201
|
+
}
|
|
202
|
+
catch (error) {
|
|
203
|
+
if (!nativeOnly)
|
|
204
|
+
throw error;
|
|
205
|
+
}
|
|
206
|
+
const authority = nativeOnly ? undefined : options.captureAuthority?.(exec);
|
|
207
|
+
const integrity = options.captureIntegrity?.(exec);
|
|
208
|
+
const binding = { definition, body: definition.execute, identity, snapshot, nativeOnly, authority, integrity,
|
|
209
|
+
args: exec.arguments, agent: exec.agent, name: exec.name, callId: exec.callId,
|
|
210
|
+
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"),
|
|
211
|
+
workspaceRoot: exec.agent?.session.header.cwd ?? "" };
|
|
212
|
+
bindings.set(exec.token, binding);
|
|
213
|
+
check(exec, binding);
|
|
214
|
+
let action = "inherit";
|
|
215
|
+
if (snapshot !== undefined) {
|
|
216
|
+
try {
|
|
217
|
+
action = await evaluate(exec, binding);
|
|
218
|
+
}
|
|
219
|
+
catch (error) {
|
|
220
|
+
if (!nativeOnly)
|
|
221
|
+
throw error;
|
|
222
|
+
checkIntegrity(exec, binding);
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
check(exec, binding);
|
|
226
|
+
if (action === "deny")
|
|
227
|
+
return { kind: "deny", reason: "DSMM native permission rule denied this tool call." };
|
|
228
|
+
if (identity.kind === "shell" && options.managedShellDecision !== undefined)
|
|
229
|
+
return options.managedShellDecision(exec, action, next);
|
|
230
|
+
const downstream = await next();
|
|
231
|
+
if (exec.signal.aborted)
|
|
232
|
+
return { kind: "cancel" };
|
|
233
|
+
checkIntegrity(exec, binding);
|
|
234
|
+
if (downstream.kind === "deny" || downstream.kind === "cancel")
|
|
235
|
+
return downstream;
|
|
236
|
+
if (nativeOnly) {
|
|
237
|
+
if (downstream.kind !== "ask")
|
|
238
|
+
return downstream;
|
|
239
|
+
const displayReason = downstream.displayReason ?? Object.freeze({ en: downstream.reason ?? "" });
|
|
240
|
+
asks.set(displayReason, { exec, binding });
|
|
241
|
+
return { ...downstream, displayReason };
|
|
242
|
+
}
|
|
243
|
+
if (action === "ask") {
|
|
244
|
+
const reason = `DSMM exact tool-call rule: ${exec.name} ${JSON.stringify(args(exec))}`;
|
|
245
|
+
const combined = [downstream.kind === "ask" ? downstream.reason : undefined, reason].filter(Boolean).join("\n");
|
|
246
|
+
const displayReason = Object.freeze({ en: combined, ...downstream.kind === "ask" && downstream.displayReason !== undefined ? Object.fromEntries(Object.entries(downstream.displayReason).map(([locale, text]) => [locale, `${text}\n${reason}`])) : {} });
|
|
247
|
+
asks.set(displayReason, { exec, binding });
|
|
248
|
+
return { kind: "ask", reason: combined, displayReason };
|
|
249
|
+
}
|
|
250
|
+
return downstream;
|
|
251
|
+
}, { prepend: true, global: true });
|
|
252
|
+
const unapproval = ctx.on("approval/request", async (request, next) => {
|
|
253
|
+
const ask = request.displayReason === undefined ? undefined : asks.get(request.displayReason);
|
|
254
|
+
if (ask === undefined || request.agent !== ask.exec.agent || request.signal !== ask.exec.signal || request.callId !== ask.exec.callId || request.toolName !== ask.exec.name)
|
|
255
|
+
return next();
|
|
256
|
+
checkIntegrity(ask.exec, ask.binding);
|
|
257
|
+
return permissionOutcome(next, ask.binding.signal, "cancelled");
|
|
258
|
+
}, { prepend: true, global: true });
|
|
259
|
+
const unguard = tools.guard(exec => {
|
|
260
|
+
const binding = bindings.get(exec.token);
|
|
261
|
+
if (binding === undefined)
|
|
262
|
+
return undefined;
|
|
263
|
+
try {
|
|
264
|
+
checkIntegrity(exec, binding);
|
|
265
|
+
return undefined;
|
|
266
|
+
}
|
|
267
|
+
catch {
|
|
268
|
+
return "Native tool execution identity is no longer current.";
|
|
269
|
+
}
|
|
270
|
+
});
|
|
271
|
+
const unresult = ctx.on("tools/result", exec => { bindings.delete(exec.token); }, { global: true });
|
|
272
|
+
const dispose = () => { lifetime.abort(); unhook(); unguard(); unresult(); unapproval(); bindings.clear(); };
|
|
273
|
+
return ctx.effect(() => dispose);
|
|
274
|
+
}
|
|
275
|
+
export const NATIVE_PERMISSION_CAPABILITIES = Object.freeze({ outsideReads: "tool-call-boundary", finalInode: false,
|
|
276
|
+
scopedMemory: "not-provided-by-native-rules", webFetch: "native-public-only", webSearchDestinations: "unsupported", proxyAddressBinding: "native-proxy-dependent",
|
|
277
|
+
shellSockets: "native-executor-dependent", providerAuthMcp: "not-covered" });
|
|
278
|
+
//# sourceMappingURL=permission-native-rules.js.map
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { Context } from "@deepseek-ai/cordis";
|
|
2
|
+
import * as Native from "@deepseek-ai/dsh-tool-pwsh";
|
|
3
|
+
export { Config, name } from "@deepseek-ai/dsh-tool-pwsh";
|
|
4
|
+
export declare const inject: string[];
|
|
5
|
+
export declare function apply(ctx: Context, config: Native.Config): void;
|
|
6
|
+
//# sourceMappingURL=permission-pwsh.d.ts.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import * as Native from "@deepseek-ai/dsh-tool-pwsh";
|
|
2
|
+
export { Config, name } from "@deepseek-ai/dsh-tool-pwsh";
|
|
3
|
+
export const inject = [...Native.inject, "dsmmPermissionController"];
|
|
4
|
+
export function apply(ctx, config) {
|
|
5
|
+
Native.apply(ctx.dsmmPermissionController.shellScope(ctx, "pwsh"), config);
|
|
6
|
+
}
|
|
7
|
+
//# sourceMappingURL=permission-pwsh.js.map
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { RemoteResult, TypertRemoteContribution } from "@deepseek-ai/dsh-typert-protocol";
|
|
2
|
+
import type { TypertContribution } from "@deepseek-ai/dsh-typert-registry";
|
|
3
|
+
import type { PermissionRulesSaveRequest, PermissionRulesSaveResult } from "./permission-rules.js";
|
|
4
|
+
export interface PermissionRemote {
|
|
5
|
+
describeRules(sessionId: string): Promise<RemoteResult<PermissionRulesSaveResult>>;
|
|
6
|
+
saveRules(sessionId: string, request: PermissionRulesSaveRequest): Promise<RemoteResult<PermissionRulesSaveResult>>;
|
|
7
|
+
}
|
|
8
|
+
declare module "@deepseek-ai/dsh-typert-protocol/types" {
|
|
9
|
+
interface TypertRemoteMap {
|
|
10
|
+
"dsmmPermissions/describeRules": PermissionRemote["describeRules"];
|
|
11
|
+
"dsmmPermissions/saveRules": PermissionRemote["saveRules"];
|
|
12
|
+
}
|
|
13
|
+
interface TypertRemoteNamespaceMap {
|
|
14
|
+
dsmmPermissions: PermissionRemote;
|
|
15
|
+
}
|
|
16
|
+
interface RemoteErrorDetailsMap {
|
|
17
|
+
"dsmm-permissions/refused": {
|
|
18
|
+
code: string;
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
export declare function parsePermissionSessionId(value: unknown): string;
|
|
23
|
+
export declare function parsePermissionRulesResult(value: unknown): PermissionRulesSaveResult;
|
|
24
|
+
export declare const PERMISSION_REMOTE: TypertRemoteContribution;
|
|
25
|
+
export declare const PERMISSION_HOST: TypertContribution;
|
|
26
|
+
//# sourceMappingURL=permission-remote.d.ts.map
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { parsePermissionRulesSave, permissionRevision, permissionRuleRow } from "./permission-rules.js";
|
|
2
|
+
import { resolvePermissionControl } from "./permission-settings.js";
|
|
3
|
+
function fail() { throw new TypeError("Invalid permission DTO."); }
|
|
4
|
+
function text(value, max = 512) {
|
|
5
|
+
if (typeof value !== "string" || value.length === 0 || value.length > max || /[\u0000-\u001f\u007f]/u.test(value))
|
|
6
|
+
fail();
|
|
7
|
+
return value;
|
|
8
|
+
}
|
|
9
|
+
export function parsePermissionSessionId(value) { return text(value, 256); }
|
|
10
|
+
function parseRuntime(value) {
|
|
11
|
+
const runtime = permissionRuleRow(value, ["savedRevision", "runtimeRevision", "state", "mounted", "restartRequired"]);
|
|
12
|
+
if (!["synced", "updating", "unsynced"].includes(runtime.state) || typeof runtime.mounted !== "boolean" || typeof runtime.restartRequired !== "boolean")
|
|
13
|
+
fail();
|
|
14
|
+
return { savedRevision: permissionRevision(runtime.savedRevision), runtimeRevision: permissionRevision(runtime.runtimeRevision), state: runtime.state, mounted: runtime.mounted, restartRequired: runtime.restartRequired };
|
|
15
|
+
}
|
|
16
|
+
function parseCapabilities(value) {
|
|
17
|
+
const input = permissionRuleRow(value, ["limits", "runtime", "tools"]);
|
|
18
|
+
const limits = permissionRuleRow(input.limits, ["outsideReads", "finalInode", "scopedMemory", "webFetch", "webSearchDestinations", "proxyAddressBinding", "shellSockets", "providerAuthMcp"]);
|
|
19
|
+
if (limits.outsideReads !== "tool-call-boundary" || limits.finalInode !== false || limits.scopedMemory !== "not-provided-by-native-rules"
|
|
20
|
+
|| limits.webFetch !== "native-public-only" || limits.webSearchDestinations !== "unsupported" || limits.proxyAddressBinding !== "native-proxy-dependent"
|
|
21
|
+
|| limits.shellSockets !== "native-executor-dependent" || limits.providerAuthMcp !== "not-covered")
|
|
22
|
+
fail();
|
|
23
|
+
if (!Array.isArray(input.tools) || input.tools.length > 1024)
|
|
24
|
+
fail();
|
|
25
|
+
const tools = [];
|
|
26
|
+
const names = new Set();
|
|
27
|
+
for (const value of input.tools) {
|
|
28
|
+
const tool = permissionRuleRow(value, ["name", "kind", "approval", "scopedMemory"]), name = text(tool.name);
|
|
29
|
+
if (!["read", "glob", "grep", "shell", "webSearch", "webFetch"].includes(tool.kind) || tool.approval !== "native-once" || tool.scopedMemory !== false || names.has(name))
|
|
30
|
+
fail();
|
|
31
|
+
names.add(name);
|
|
32
|
+
tools.push({ name, kind: tool.kind, approval: "native-once", scopedMemory: false });
|
|
33
|
+
}
|
|
34
|
+
return { limits: { outsideReads: "tool-call-boundary", finalInode: false, scopedMemory: "not-provided-by-native-rules", webFetch: "native-public-only",
|
|
35
|
+
webSearchDestinations: "unsupported", proxyAddressBinding: "native-proxy-dependent", shellSockets: "native-executor-dependent", providerAuthMcp: "not-covered" }, runtime: parseRuntime(input.runtime), tools };
|
|
36
|
+
}
|
|
37
|
+
export function parsePermissionRulesResult(value) {
|
|
38
|
+
const input = permissionRuleRow(value, ["snapshot", "runtime"], ["capabilities"]), snapshot = permissionRuleRow(input.snapshot, ["revision", "policy"]);
|
|
39
|
+
return { snapshot: { revision: permissionRevision(snapshot.revision), policy: resolvePermissionControl(snapshot.policy) }, runtime: parseRuntime(input.runtime),
|
|
40
|
+
...Object.hasOwn(input, "capabilities") ? { capabilities: parseCapabilities(input.capabilities) } : {} };
|
|
41
|
+
}
|
|
42
|
+
const codec = (name, parse) => ({ mode: "strict", typeSymbol: `@dsmm/dsmm#${name}`, create: () => ({ parse }) });
|
|
43
|
+
function descriptor(method, result, request) {
|
|
44
|
+
return { id: `@dsmm/dsmm-permissions#dsmmPermissions/${method}`, service: "dsmmPermissions", namespace: "dsmmPermissions", method, invocation: { kind: "direct" },
|
|
45
|
+
parameters: [{ name: "sessionId", wire: "sessionId", source: "json", codec: codec("PermissionSessionId", parsePermissionSessionId) },
|
|
46
|
+
...request === undefined ? [] : [{ name: "request", wire: "request", source: "json", codec: request }]], result };
|
|
47
|
+
}
|
|
48
|
+
export const PERMISSION_REMOTE = { package: "@dsmm/dsmm-permissions", descriptors: [
|
|
49
|
+
descriptor("describeRules", codec("PermissionRulesResult", parsePermissionRulesResult)),
|
|
50
|
+
descriptor("saveRules", codec("PermissionRulesResult", parsePermissionRulesResult), codec("PermissionRulesSaveRequest", parsePermissionRulesSave)),
|
|
51
|
+
] };
|
|
52
|
+
export const PERMISSION_HOST = { package: PERMISSION_REMOTE.package, face: "host", schemas: [], model: { services: [], events: [], objects: [] }, invocations: PERMISSION_REMOTE.descriptors };
|
|
53
|
+
//# sourceMappingURL=permission-remote.js.map
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { Context } from "@deepseek-ai/cordis";
|
|
2
|
+
import { TypertRemoteService } from "@deepseek-ai/dsh-typert-protocol";
|
|
3
|
+
import type { PermissionRulesBackend, PermissionRulesRuntimeSync, PermissionRulesSaveRequest, PermissionRulesSaveResult } from "./permission-rules.js";
|
|
4
|
+
/** Root controls are ordinary Core controls; no DW delivery fence/ticket is consulted. */
|
|
5
|
+
export declare class DsmmPermissionsHost extends TypertRemoteService {
|
|
6
|
+
private readonly rules;
|
|
7
|
+
private readonly lifetime;
|
|
8
|
+
constructor(ctx: Context, rules: {
|
|
9
|
+
readonly backend: PermissionRulesBackend;
|
|
10
|
+
readonly runtime: PermissionRulesRuntimeSync;
|
|
11
|
+
});
|
|
12
|
+
private invoke;
|
|
13
|
+
private rulesAuthority;
|
|
14
|
+
private withCapabilities;
|
|
15
|
+
describeRules(sessionId: string): Promise<PermissionRulesSaveResult>;
|
|
16
|
+
saveRules(sessionId: string, request: PermissionRulesSaveRequest): Promise<PermissionRulesSaveResult>;
|
|
17
|
+
}
|
|
18
|
+
declare module "@deepseek-ai/cordis" {
|
|
19
|
+
interface Context {
|
|
20
|
+
dsmmPermissions: DsmmPermissionsHost;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
export declare function registerPermissionControlRpc(ctx: Context, rules: {
|
|
24
|
+
readonly backend: PermissionRulesBackend;
|
|
25
|
+
readonly runtime: PermissionRulesRuntimeSync;
|
|
26
|
+
}): DsmmPermissionsHost;
|
|
27
|
+
/** Native-only mount does not construct a substitute Root ToolRuntime or scoped-memory authority. */
|
|
28
|
+
export declare function registerNativePermissionRulesRpc(ctx: Context, backend: PermissionRulesBackend, runtime: PermissionRulesRuntimeSync): DsmmPermissionsHost;
|
|
29
|
+
//# sourceMappingURL=permission-rpc.d.ts.map
|