@yiln-dsh/dsh-plugin-sandbox-guidance 0.1.0 → 0.1.1
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 +10 -4
- package/index.js +7 -8
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -11,9 +11,10 @@ command remains unexecuted.
|
|
|
11
11
|
## Behavior
|
|
12
12
|
|
|
13
13
|
The plugin adds a `systemPrompt` section that tells the model to omit
|
|
14
|
-
`sandbox_permissions` during ordinary calls and to explain
|
|
15
|
-
of repeating it blindly. It also listens to
|
|
16
|
-
only the matching bash failure text with a
|
|
14
|
+
`sandbox_permissions` and `justification` during ordinary calls, and to explain
|
|
15
|
+
this failure instead of repeating it blindly. It also listens to
|
|
16
|
+
`tools/post-execute` and replaces only the matching bash failure text with a
|
|
17
|
+
diagnostic containing:
|
|
17
18
|
|
|
18
19
|
- the fact that bash did not run;
|
|
19
20
|
- the requested sandbox mode;
|
|
@@ -22,9 +23,14 @@ only the matching bash failure text with a diagnostic containing:
|
|
|
22
23
|
|
|
23
24
|
Other bash failures pass through unchanged.
|
|
24
25
|
|
|
26
|
+
When a sandbox denial genuinely requires more access, the injected guidance
|
|
27
|
+
instructs the model to retry the exact command once with the narrowest wider mode
|
|
28
|
+
and a non-empty justification, allowing DSH's native approval flow to ask the
|
|
29
|
+
user. It does not ask for approval in chat first.
|
|
30
|
+
|
|
25
31
|
## Install
|
|
26
32
|
|
|
27
|
-
The published package is `@yiln-dsh/dsh-plugin-sandbox-guidance@0.1.
|
|
33
|
+
The published package is `@yiln-dsh/dsh-plugin-sandbox-guidance@0.1.1`.
|
|
28
34
|
|
|
29
35
|
```bash
|
|
30
36
|
dsh plugin --profile web add @yiln-dsh/dsh-plugin-sandbox-guidance@latest
|
package/index.js
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
export const name = "sandbox-guidance";
|
|
8
8
|
export const inject = ["tools", "systemPrompt"];
|
|
9
9
|
|
|
10
|
-
const NON_WIDENING_ERROR =
|
|
10
|
+
const NON_WIDENING_ERROR = /sandbox escalation to "([^"]+)"\s+is not strictly wider than (?:this call's )?current "([^"]+)"\s+mode/iu;
|
|
11
11
|
|
|
12
12
|
/**
|
|
13
13
|
* Turn the native sandbox error into a model-facing diagnostic that says what
|
|
@@ -24,8 +24,8 @@ export function explainSandboxFailure(message) {
|
|
|
24
24
|
"Bash was not executed; this failure happened before the command ran.",
|
|
25
25
|
`Cause: sandbox_permissions requested \"${requested}\", but the current effective sandbox mode is \"${effective}\".`,
|
|
26
26
|
sameMode
|
|
27
|
-
? "The requested mode is already active, so sandbox_permissions
|
|
28
|
-
: "
|
|
27
|
+
? "The requested mode is already active, so omit both sandbox_permissions and justification for the retry."
|
|
28
|
+
: "The requested mode is not wider than the current mode, so omit both sandbox_permissions and justification when the current mode is sufficient.",
|
|
29
29
|
"Explain this cause to the user instead of silently repeating the same bash call.",
|
|
30
30
|
].join(" ");
|
|
31
31
|
}
|
|
@@ -33,15 +33,14 @@ export function explainSandboxFailure(message) {
|
|
|
33
33
|
const SYSTEM_PROMPT = [
|
|
34
34
|
"Sandbox escalation recovery:",
|
|
35
35
|
"- Do not include sandbox_permissions in an ordinary bash call.",
|
|
36
|
-
"-
|
|
36
|
+
"- Never send justification by itself. When the current effective mode is sufficient, omit both sandbox_permissions and justification.",
|
|
37
|
+
"- Only include sandbox_permissions and a non-empty justification when retrying a call that was actually denied by the sandbox and the requested mode is strictly wider than the effective mode.",
|
|
37
38
|
"- If a bash result says the requested mode is not strictly wider than the current mode, state that the command did not run, explain the requested and effective modes, and retry without sandbox_permissions when the current mode is sufficient.",
|
|
38
|
-
"- If a wider mode
|
|
39
|
+
"- If a denied command genuinely needs a wider mode, retry the exact same command once with the narrowest wider sandbox_permissions value and a non-empty justification. This retry triggers the approval flow; do not ask for approval in chat first.",
|
|
39
40
|
].join("\n");
|
|
40
41
|
|
|
41
42
|
export function apply(ctx) {
|
|
42
|
-
const order =
|
|
43
|
-
? ctx.systemPrompt.getSectionOrder("TOOL_BASH") + 1
|
|
44
|
-
: 105;
|
|
43
|
+
const order = ctx.systemPrompt.getSectionOrder("TOOL_BASH") + 1;
|
|
45
44
|
ctx.systemPrompt.section({
|
|
46
45
|
name: "tool:sandbox-guidance",
|
|
47
46
|
order,
|