@fabric-harness/sdk 6.9.0 → 6.9.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/dist/experimental.d.ts +6 -5
- package/dist/experimental.d.ts.map +1 -1
- package/dist/experimental.js +5 -3
- package/dist/experimental.js.map +1 -1
- package/dist/policied-sandbox.d.ts +9 -3
- package/dist/policied-sandbox.d.ts.map +1 -1
- package/dist/policied-sandbox.js +276 -53
- package/dist/policied-sandbox.js.map +1 -1
- package/dist/policy.d.ts +3 -3
- package/dist/policy.d.ts.map +1 -1
- package/dist/policy.js +115 -64
- package/dist/policy.js.map +1 -1
- package/dist/sandbox-ref.d.ts +2 -2
- package/dist/sandbox-ref.d.ts.map +1 -1
- package/dist/sandbox-ref.js +143 -70
- package/dist/sandbox-ref.js.map +1 -1
- package/dist/sandbox.d.ts +8 -0
- package/dist/sandbox.d.ts.map +1 -1
- package/dist/sandbox.js +22 -1
- package/dist/sandbox.js.map +1 -1
- package/dist/session.d.ts +17 -3
- package/dist/session.d.ts.map +1 -1
- package/dist/session.js +294 -146
- package/dist/session.js.map +1 -1
- package/dist/suspending-sandbox.d.ts +2 -2
- package/dist/suspending-sandbox.d.ts.map +1 -1
- package/dist/suspending-sandbox.js +65 -26
- package/dist/suspending-sandbox.js.map +1 -1
- package/dist/tools.d.ts +15 -3
- package/dist/tools.d.ts.map +1 -1
- package/dist/tools.js +94 -46
- package/dist/tools.js.map +1 -1
- package/package.json +1 -1
package/dist/experimental.d.ts
CHANGED
|
@@ -6,9 +6,10 @@
|
|
|
6
6
|
* Stable equivalents (covered by v1.0 SemVer) live in the default
|
|
7
7
|
* `@fabric-harness/sdk` barrel.
|
|
8
8
|
*/
|
|
9
|
-
export { PiAgentLoopRuntime, createPiAgentLoopRuntime, isDynamicModel } from
|
|
10
|
-
export type { PiAgentLoopRuntimeOptions, PiCustomModel, PiModelDescription } from
|
|
11
|
-
export { policiedSandboxEnv } from
|
|
12
|
-
export {
|
|
13
|
-
export
|
|
9
|
+
export { PiAgentLoopRuntime, createPiAgentLoopRuntime, isDynamicModel } from "./pi-loop-runtime.js";
|
|
10
|
+
export type { PiAgentLoopRuntimeOptions, PiCustomModel, PiModelDescription, } from "./pi-loop-runtime.js";
|
|
11
|
+
export { evaluateToolCallPolicyInSandbox, policiedSandboxEnv } from "./policied-sandbox.js";
|
|
12
|
+
export { hasScopedCommandRenderer, renderScopedCommand } from "./tools.js";
|
|
13
|
+
export { SuspendingSandboxEnv, withIdleSuspend } from "./suspending-sandbox.js";
|
|
14
|
+
export type { SuspendingSandboxOptions } from "./suspending-sandbox.js";
|
|
14
15
|
//# sourceMappingURL=experimental.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"experimental.d.ts","sourceRoot":"","sources":["../src/experimental.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAGH,OAAO,EAAE,kBAAkB,EAAE,wBAAwB,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACpG,YAAY,
|
|
1
|
+
{"version":3,"file":"experimental.d.ts","sourceRoot":"","sources":["../src/experimental.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAGH,OAAO,EAAE,kBAAkB,EAAE,wBAAwB,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACpG,YAAY,EACV,yBAAyB,EACzB,aAAa,EACb,kBAAkB,GACnB,MAAM,sBAAsB,CAAC;AAG9B,OAAO,EAAE,+BAA+B,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAE5F,OAAO,EAAE,wBAAwB,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAC3E,OAAO,EAAE,oBAAoB,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAChF,YAAY,EAAE,wBAAwB,EAAE,MAAM,yBAAyB,CAAC"}
|
package/dist/experimental.js
CHANGED
|
@@ -7,8 +7,10 @@
|
|
|
7
7
|
* `@fabric-harness/sdk` barrel.
|
|
8
8
|
*/
|
|
9
9
|
// Pi-agent-core loop runtime: third-party-named, name will likely change before v1.0.
|
|
10
|
-
export { PiAgentLoopRuntime, createPiAgentLoopRuntime, isDynamicModel } from
|
|
10
|
+
export { PiAgentLoopRuntime, createPiAgentLoopRuntime, isDynamicModel } from "./pi-loop-runtime.js";
|
|
11
11
|
// Sandbox decorators: naming-churny ("policied" is a coined word).
|
|
12
|
-
export { policiedSandboxEnv } from
|
|
13
|
-
|
|
12
|
+
export { evaluateToolCallPolicyInSandbox, policiedSandboxEnv } from "./policied-sandbox.js";
|
|
13
|
+
// Runtime-package plumbing: binds a sandbox approval to a scoped command tool's exact command.
|
|
14
|
+
export { hasScopedCommandRenderer, renderScopedCommand } from "./tools.js";
|
|
15
|
+
export { SuspendingSandboxEnv, withIdleSuspend } from "./suspending-sandbox.js";
|
|
14
16
|
//# sourceMappingURL=experimental.js.map
|
package/dist/experimental.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"experimental.js","sourceRoot":"","sources":["../src/experimental.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,sFAAsF;AACtF,OAAO,EAAE,kBAAkB,EAAE,wBAAwB,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"experimental.js","sourceRoot":"","sources":["../src/experimental.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,sFAAsF;AACtF,OAAO,EAAE,kBAAkB,EAAE,wBAAwB,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAOpG,mEAAmE;AACnE,OAAO,EAAE,+BAA+B,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAC5F,+FAA+F;AAC/F,OAAO,EAAE,wBAAwB,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAC3E,OAAO,EAAE,oBAAoB,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type { CapabilityPolicy } from
|
|
2
|
-
import type { SandboxEnv } from
|
|
3
|
-
import type { ToolCall } from
|
|
1
|
+
import type { CapabilityPolicy, PolicyDecision } from "./policy.js";
|
|
2
|
+
import type { SandboxEnv } from "./sandbox.js";
|
|
3
|
+
import type { ToolCall } from "./tools.js";
|
|
4
4
|
/**
|
|
5
5
|
* Wrap a `SandboxEnv` with `CapabilityPolicy` enforcement at the sandbox layer.
|
|
6
6
|
*
|
|
@@ -22,6 +22,12 @@ import type { ToolCall } from './tools.js';
|
|
|
22
22
|
* Pass-through: `snapshot`, `restore`, `fork`, `suspend`, `resume`, `cleanup`.
|
|
23
23
|
*/
|
|
24
24
|
export declare function policiedSandboxEnv(inner: SandboxEnv, policy: CapabilityPolicy | undefined): SandboxEnv;
|
|
25
|
+
/**
|
|
26
|
+
* @internal A tool call's policy decision with file paths checked in every
|
|
27
|
+
* form `sandbox` would reach, as its sandbox layer checks them, so dispatch
|
|
28
|
+
* and the sandbox agree (and an approval is asked for when one is needed).
|
|
29
|
+
*/
|
|
30
|
+
export declare function evaluateToolCallPolicyInSandbox(requestedCall: ToolCall, policy: CapabilityPolicy | undefined, sandbox: SandboxEnv): PolicyDecision;
|
|
25
31
|
/** @internal Run one approved tool operation through the sandbox policy layer. */
|
|
26
32
|
export declare function runWithSandboxPolicyApproval<T>(sandbox: SandboxEnv, call: ToolCall, operation: () => Promise<T>): Promise<T>;
|
|
27
33
|
//# sourceMappingURL=policied-sandbox.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"policied-sandbox.d.ts","sourceRoot":"","sources":["../src/policied-sandbox.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"policied-sandbox.d.ts","sourceRoot":"","sources":["../src/policied-sandbox.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AACpE,OAAO,KAAK,EAGV,UAAU,EAGX,MAAM,cAAc,CAAC;AAEtB,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAG3C;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,kBAAkB,CAChC,KAAK,EAAE,UAAU,EACjB,MAAM,EAAE,gBAAgB,GAAG,SAAS,GACnC,UAAU,CAGZ;AA0VD;;;;GAIG;AACH,wBAAgB,+BAA+B,CAC7C,aAAa,EAAE,QAAQ,EACvB,MAAM,EAAE,gBAAgB,GAAG,SAAS,EACpC,OAAO,EAAE,UAAU,GAClB,cAAc,CA6BhB;AA2BD,kFAAkF;AAClF,wBAAgB,4BAA4B,CAAC,CAAC,EAC5C,OAAO,EAAE,UAAU,EACnB,IAAI,EAAE,QAAQ,EACd,SAAS,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,GAC1B,OAAO,CAAC,CAAC,CAAC,CAIZ"}
|
package/dist/policied-sandbox.js
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { AsyncLocalStorage } from "node:async_hooks";
|
|
2
|
+
import { posix } from "node:path";
|
|
3
|
+
import { FabricError } from "./error.js";
|
|
4
|
+
import { canonicalizeToolCall, evaluateCommandPolicy, evaluateToolCallPolicy } from "./policy.js";
|
|
5
|
+
import { registerSandboxWrapper } from "./sandbox.js";
|
|
3
6
|
/**
|
|
4
7
|
* Wrap a `SandboxEnv` with `CapabilityPolicy` enforcement at the sandbox layer.
|
|
5
8
|
*
|
|
@@ -26,24 +29,26 @@ export function policiedSandboxEnv(inner, policy) {
|
|
|
26
29
|
return new PoliciedSandboxEnv(inner, policy);
|
|
27
30
|
}
|
|
28
31
|
class PoliciedSandboxEnv {
|
|
29
|
-
inner;
|
|
30
|
-
policy;
|
|
31
32
|
cwd;
|
|
32
33
|
capabilities;
|
|
33
|
-
|
|
34
|
+
#inner;
|
|
35
|
+
#policy;
|
|
34
36
|
constructor(inner, policy) {
|
|
35
|
-
this
|
|
36
|
-
this
|
|
37
|
+
this.#inner = inner;
|
|
38
|
+
this.#policy = policy;
|
|
37
39
|
this.cwd = inner.cwd;
|
|
38
40
|
if (inner.capabilities)
|
|
39
41
|
this.capabilities = inner.capabilities;
|
|
42
|
+
registerSandboxWrapper(this, inner);
|
|
43
|
+
}
|
|
44
|
+
resolvePath(filePath) {
|
|
45
|
+
return this.#inner.resolvePath(filePath);
|
|
40
46
|
}
|
|
41
|
-
resolvePath(filePath) { return this.inner.resolvePath(filePath); }
|
|
42
47
|
async exec(command, options) {
|
|
43
|
-
const decision = evaluateCommandPolicy(command, this
|
|
44
|
-
if (!decision.allowed && (!decision.approvalRequired || !this.isApproved(
|
|
48
|
+
const decision = evaluateCommandPolicy(command, this.#policy);
|
|
49
|
+
if (!decision.allowed && (!decision.approvalRequired || !this.isApproved("bash", [command]))) {
|
|
45
50
|
throw new FabricError({
|
|
46
|
-
code:
|
|
51
|
+
code: "COMMAND_DENIED",
|
|
47
52
|
message: decision.reason ?? `Command denied by policy: ${command}`,
|
|
48
53
|
details: {
|
|
49
54
|
command,
|
|
@@ -51,73 +56,140 @@ class PoliciedSandboxEnv {
|
|
|
51
56
|
},
|
|
52
57
|
});
|
|
53
58
|
}
|
|
54
|
-
return this
|
|
55
|
-
}
|
|
56
|
-
readFile(path) {
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
59
|
+
return this.#inner.exec(command, options);
|
|
60
|
+
}
|
|
61
|
+
readFile(path) {
|
|
62
|
+
return this.gateRead(path, () => this.#inner.readFile(path));
|
|
63
|
+
}
|
|
64
|
+
readFileBuffer(path) {
|
|
65
|
+
return this.gateRead(path, () => this.#inner.readFileBuffer(path));
|
|
66
|
+
}
|
|
67
|
+
stat(path) {
|
|
68
|
+
return this.gateRead(path, () => this.#inner.stat(path));
|
|
69
|
+
}
|
|
70
|
+
readdir(path) {
|
|
71
|
+
return this.gateRead(path, () => this.#inner.readdir(path));
|
|
72
|
+
}
|
|
73
|
+
exists(path) {
|
|
74
|
+
return this.gateRead(path, () => this.#inner.exists(path));
|
|
75
|
+
}
|
|
76
|
+
writeFile(path, content) {
|
|
77
|
+
return this.gateWrite(path, () => this.#inner.writeFile(path, content));
|
|
78
|
+
}
|
|
79
|
+
mkdir(path, options) {
|
|
80
|
+
return this.gateWrite(path, () => this.#inner.mkdir(path, options));
|
|
81
|
+
}
|
|
82
|
+
rm(path, options) {
|
|
83
|
+
return this.gateWrite(path, () => this.#inner.rm(path, options));
|
|
84
|
+
}
|
|
64
85
|
async snapshot() {
|
|
65
|
-
if (!this
|
|
66
|
-
throw new Error(
|
|
67
|
-
return this
|
|
86
|
+
if (!this.#inner.snapshot)
|
|
87
|
+
throw new Error("Sandbox does not support snapshot. Guard with sandbox.capabilities before calling, or use a sandbox backend that implements snapshot (e.g. local or docker).");
|
|
88
|
+
return this.#inner.snapshot();
|
|
68
89
|
}
|
|
69
90
|
async restore(snapshot) {
|
|
70
|
-
if (!this
|
|
71
|
-
throw new Error(
|
|
72
|
-
await this
|
|
91
|
+
if (!this.#inner.restore)
|
|
92
|
+
throw new Error("Sandbox does not support restore. Guard with sandbox.capabilities before calling, or use a sandbox backend that implements restore (e.g. local or docker).");
|
|
93
|
+
await this.#inner.restore(snapshot);
|
|
73
94
|
}
|
|
74
95
|
async fork(snapshot) {
|
|
75
|
-
if (!this
|
|
76
|
-
throw new Error(
|
|
96
|
+
if (!this.#inner.fork)
|
|
97
|
+
throw new Error("Sandbox does not support fork. Guard with sandbox.capabilities before calling, or use a sandbox backend that implements fork (e.g. local or docker).");
|
|
77
98
|
// Wrap the forked env with the same policy so branches inherit enforcement.
|
|
78
|
-
return policiedSandboxEnv(await this
|
|
99
|
+
return policiedSandboxEnv(await this.#inner.fork(snapshot), this.#policy);
|
|
79
100
|
}
|
|
80
101
|
async suspend() {
|
|
81
|
-
if (!this
|
|
82
|
-
throw new Error(
|
|
83
|
-
await this
|
|
102
|
+
if (!this.#inner.suspend)
|
|
103
|
+
throw new Error("Sandbox does not support suspend. Guard with sandbox.capabilities before calling, or use a sandbox backend that implements suspend (e.g. local or docker).");
|
|
104
|
+
await this.#inner.suspend();
|
|
84
105
|
}
|
|
85
106
|
async resume() {
|
|
86
|
-
if (!this
|
|
87
|
-
throw new Error(
|
|
88
|
-
await this
|
|
107
|
+
if (!this.#inner.resume)
|
|
108
|
+
throw new Error("Sandbox does not support resume. Guard with sandbox.capabilities before calling, or use a sandbox backend that implements resume (e.g. local or docker).");
|
|
109
|
+
await this.#inner.resume();
|
|
89
110
|
}
|
|
90
111
|
encodeRef() {
|
|
91
|
-
return this
|
|
112
|
+
return this.#inner.encodeRef?.();
|
|
113
|
+
}
|
|
114
|
+
cleanup() {
|
|
115
|
+
return this.#inner.cleanup();
|
|
92
116
|
}
|
|
93
|
-
cleanup() { return this.inner.cleanup(); }
|
|
94
117
|
async __runWithPolicyApproval(call, operation) {
|
|
95
|
-
this
|
|
118
|
+
// A grant belongs to this layer, lives only in the approved call's async
|
|
119
|
+
// scope and only until the call settles. It is forwarded to the layers
|
|
120
|
+
// beneath (a call's effective policy is layered over the session's) with
|
|
121
|
+
// its path made absolute here, against this layer's cwd, so every layer
|
|
122
|
+
// approves the same target.
|
|
123
|
+
const approved = this.approvalFor(call);
|
|
124
|
+
const grant = { owner: this, ...approved, active: true };
|
|
125
|
+
const forwarded = approved.sandboxPath !== undefined && typeof call.input === "object" && call.input !== null
|
|
126
|
+
? {
|
|
127
|
+
...call,
|
|
128
|
+
input: {
|
|
129
|
+
...call.input,
|
|
130
|
+
[approvalPathKey(call.tool)]: approved.sandboxPath,
|
|
131
|
+
},
|
|
132
|
+
}
|
|
133
|
+
: call;
|
|
96
134
|
try {
|
|
97
|
-
return await
|
|
135
|
+
return await approvalScope.run([...(approvalScope.getStore() ?? []), grant], () => runWithSandboxPolicyApproval(this.#inner, forwarded, operation));
|
|
98
136
|
}
|
|
99
137
|
finally {
|
|
100
|
-
|
|
138
|
+
grant.active = false;
|
|
101
139
|
}
|
|
102
140
|
}
|
|
141
|
+
approvalFor(requestedCall) {
|
|
142
|
+
const call = canonicalizeToolCall(requestedCall);
|
|
143
|
+
// Commands are approved per call: a bash or scoped command tool runs the
|
|
144
|
+
// one command its gate evaluated, quoted as the tool builds it.
|
|
145
|
+
// A command approval covers exactly the approved command: a bash call's
|
|
146
|
+
// `command`, or the rendered command a scoped command tool runs.
|
|
147
|
+
if (call.tool === "bash") {
|
|
148
|
+
const command = stringProperty(call.input, "command");
|
|
149
|
+
return {
|
|
150
|
+
kinds: command === undefined ? [] : ["bash"],
|
|
151
|
+
paths: command === undefined ? [] : [command],
|
|
152
|
+
tree: false,
|
|
153
|
+
};
|
|
154
|
+
}
|
|
155
|
+
const kinds = fileToolKinds(call.tool) ?? [];
|
|
156
|
+
// grep and glob walk a tree: the approval covers their root and below it.
|
|
157
|
+
const tree = TREE_TOOLS.has(call.tool);
|
|
158
|
+
const raw = stringProperty(call.input, approvalPathKey(call.tool));
|
|
159
|
+
const path = tree ? (raw ?? ".") : raw;
|
|
160
|
+
if (kinds.length === 0 || path === undefined)
|
|
161
|
+
return { kinds: [], paths: [], tree: false };
|
|
162
|
+
const sandboxPath = sandboxPathIn(this.#inner, path);
|
|
163
|
+
// Only absolute forms identify the approved file; an unresolvable path
|
|
164
|
+
// approves nothing.
|
|
165
|
+
const paths = pathFormsIn(this.#inner, path).filter((form) => form.startsWith("/") && !hasParentSegment(form));
|
|
166
|
+
return { kinds, paths, tree, ...(sandboxPath !== undefined ? { sandboxPath } : {}) };
|
|
167
|
+
}
|
|
168
|
+
pathForms(path) {
|
|
169
|
+
return pathFormsIn(this.#inner, path);
|
|
170
|
+
}
|
|
171
|
+
decidePath(kind, forms) {
|
|
172
|
+
return evaluateFileOperation(kind, forms, this.#policy);
|
|
173
|
+
}
|
|
103
174
|
async gateRead(path, op) {
|
|
104
|
-
|
|
105
|
-
this.throwIfDenied(decision.allowed, decision.approvalRequired, decision.reason, path, 'read', decision.matchedPattern);
|
|
175
|
+
this.gatePath("read", path);
|
|
106
176
|
return op();
|
|
107
177
|
}
|
|
108
178
|
async gateWrite(path, op) {
|
|
109
|
-
|
|
110
|
-
this.throwIfDenied(decision.allowed, decision.approvalRequired, decision.reason, path, 'write', decision.matchedPattern);
|
|
179
|
+
this.gatePath("write", path);
|
|
111
180
|
return op();
|
|
112
181
|
}
|
|
113
|
-
|
|
114
|
-
|
|
182
|
+
gatePath(kind, path) {
|
|
183
|
+
const forms = this.pathForms(path);
|
|
184
|
+
const decision = this.decidePath(kind, forms);
|
|
185
|
+
if (decision.allowed)
|
|
115
186
|
return;
|
|
116
|
-
if (approvalRequired && this.isApproved(
|
|
187
|
+
if (decision.approvalRequired && this.isApproved(kind, forms))
|
|
117
188
|
return;
|
|
189
|
+
const { reason, matchedPattern } = decision;
|
|
118
190
|
throw new FabricError({
|
|
119
|
-
code:
|
|
120
|
-
message: reason ?? `${kind ===
|
|
191
|
+
code: "POLICY_DENIED",
|
|
192
|
+
message: reason ?? `${kind === "read" ? "Read" : "Write"} denied by policy: ${path}`,
|
|
121
193
|
details: {
|
|
122
194
|
path,
|
|
123
195
|
kind,
|
|
@@ -125,12 +197,163 @@ class PoliciedSandboxEnv {
|
|
|
125
197
|
},
|
|
126
198
|
});
|
|
127
199
|
}
|
|
128
|
-
isApproved(
|
|
129
|
-
return
|
|
200
|
+
isApproved(kind, forms = []) {
|
|
201
|
+
return (approvalScope.getStore() ?? []).some((grant) => grant.active &&
|
|
202
|
+
grant.owner === this &&
|
|
203
|
+
grant.kinds.includes(kind) &&
|
|
204
|
+
(kind === "bash"
|
|
205
|
+
? grant.paths.some((approvedCommand) => forms.includes(approvedCommand))
|
|
206
|
+
: // A form with a `..` segment never matches: it is not the path
|
|
207
|
+
// it names, and could climb out of an approved tree.
|
|
208
|
+
grant.paths.some((approvedPath) => forms.some((form) => !hasParentSegment(form) &&
|
|
209
|
+
(form === approvedPath ||
|
|
210
|
+
(grant.tree &&
|
|
211
|
+
form.startsWith(approvedPath === "/" ? "/" : `${approvedPath}/`)))))));
|
|
130
212
|
}
|
|
131
213
|
}
|
|
214
|
+
/** The sandbox operations an approved file tool performs on its path. */
|
|
215
|
+
function fileToolKinds(tool) {
|
|
216
|
+
// An own-property lookup: a tool named `constructor` is not a file tool.
|
|
217
|
+
return Object.hasOwn(FILE_TOOL_KINDS, tool) ? FILE_TOOL_KINDS[tool] : undefined;
|
|
218
|
+
}
|
|
219
|
+
const FILE_TOOL_KINDS = {
|
|
220
|
+
read: ["read"],
|
|
221
|
+
read_buffer: ["read"],
|
|
222
|
+
stat: ["read"],
|
|
223
|
+
readdir: ["read"],
|
|
224
|
+
exists: ["read"],
|
|
225
|
+
grep: ["read"],
|
|
226
|
+
glob: ["read"],
|
|
227
|
+
write: ["write"],
|
|
228
|
+
mkdir: ["write"],
|
|
229
|
+
rm: ["write"],
|
|
230
|
+
edit: ["read", "write"],
|
|
231
|
+
};
|
|
232
|
+
/** The input key naming the path a file tool's approval covers. */
|
|
233
|
+
function approvalPathKey(tool) {
|
|
234
|
+
return tool === "glob" ? "cwd" : "path";
|
|
235
|
+
}
|
|
236
|
+
/** `path` as an absolute sandbox path against `sandbox`'s cwd, when that cwd is absolute. */
|
|
237
|
+
function sandboxPathIn(sandbox, path) {
|
|
238
|
+
if (path.startsWith("/"))
|
|
239
|
+
return posix.normalize(path);
|
|
240
|
+
return sandbox.cwd.startsWith("/") ? posix.resolve(sandbox.cwd, path) : undefined;
|
|
241
|
+
}
|
|
242
|
+
/**
|
|
243
|
+
* The forms of `path` a policy is evaluated against: as given (normalised, so
|
|
244
|
+
* `a/../b` cannot slip past a pattern), as an absolute sandbox path, and as the
|
|
245
|
+
* backend resolves it, so a relative path or a traversal alias cannot reach a
|
|
246
|
+
* path denied by name.
|
|
247
|
+
*/
|
|
248
|
+
function pathFormsIn(sandbox, path) {
|
|
249
|
+
// The path as written stays a form, so patterns written the same way (such
|
|
250
|
+
// as `./secret.txt`) still match; normalisation only adds forms.
|
|
251
|
+
const forms = [path, posix.normalize(path)];
|
|
252
|
+
const absolute = sandboxPathIn(sandbox, path);
|
|
253
|
+
if (absolute !== undefined)
|
|
254
|
+
forms.push(absolute);
|
|
255
|
+
try {
|
|
256
|
+
forms.push(sandbox.resolvePath(path));
|
|
257
|
+
}
|
|
258
|
+
catch {
|
|
259
|
+
// The backend refuses the path; the operation itself will fail.
|
|
260
|
+
}
|
|
261
|
+
return [...new Set(forms)];
|
|
262
|
+
}
|
|
263
|
+
/**
|
|
264
|
+
* Fail closed across forms of one operation: a deny or an approval
|
|
265
|
+
* requirement on any form wins; an allowlist is satisfied by any form.
|
|
266
|
+
*/
|
|
267
|
+
function strictestDecision(decisions) {
|
|
268
|
+
return (decisions.find((decision) => !decision.allowed && !decision.approvalRequired && decision.matchedPattern !== undefined) ??
|
|
269
|
+
decisions.find((decision) => !decision.allowed && decision.approvalRequired) ??
|
|
270
|
+
decisions.find((decision) => decision.allowed) ??
|
|
271
|
+
decisions[0] ?? { allowed: false });
|
|
272
|
+
}
|
|
273
|
+
/**
|
|
274
|
+
* A sandbox file operation on a path's forms: its filesystem rules, judged
|
|
275
|
+
* apart from the tool policy, and the tool policy's
|
|
276
|
+
* denials and approval rules for the operation's name (`read` / `write`);
|
|
277
|
+
* all must pass. A tool allowlist that does not name `read` or `write` does
|
|
278
|
+
* not block the operations of the tools it does allow.
|
|
279
|
+
*/
|
|
280
|
+
function evaluateFileOperation(kind, forms, policy) {
|
|
281
|
+
const { toolPolicy, ...filesystemOnly } = policy;
|
|
282
|
+
const { allow: _allow, ...toolRules } = toolPolicy ?? {};
|
|
283
|
+
return allMustPass([
|
|
284
|
+
toolPolicy
|
|
285
|
+
? evaluateToolCallPolicy({ tool: kind, input: {} }, { toolPolicy: toolRules })
|
|
286
|
+
: { allowed: true },
|
|
287
|
+
strictestPathDecision(forms, (form) => evaluateToolCallPolicy({ tool: kind, input: { path: form } }, filesystemOnly)),
|
|
288
|
+
]);
|
|
289
|
+
}
|
|
290
|
+
/** Independent checks on one call: any denial wins, then any approval requirement. */
|
|
291
|
+
function allMustPass(decisions) {
|
|
292
|
+
return (decisions.find((decision) => !decision.allowed && !decision.approvalRequired) ??
|
|
293
|
+
decisions.find((decision) => !decision.allowed) ??
|
|
294
|
+
decisions[0] ?? { allowed: true });
|
|
295
|
+
}
|
|
296
|
+
/**
|
|
297
|
+
* {@link strictestDecision} over a path's forms, except that a form with a
|
|
298
|
+
* `..` segment can deny or require approval but never satisfy an allowlist:
|
|
299
|
+
* `src/../../etc/passwd` must not pass as `src/**`.
|
|
300
|
+
*/
|
|
301
|
+
function strictestPathDecision(forms, evaluate) {
|
|
302
|
+
const decisions = forms.map((form) => ({ form, decision: evaluate(form) }));
|
|
303
|
+
return strictestDecision(decisions
|
|
304
|
+
.filter(({ form, decision }) => !decision.allowed || !hasParentSegment(form))
|
|
305
|
+
.map(({ decision }) => decision));
|
|
306
|
+
}
|
|
307
|
+
function hasParentSegment(path) {
|
|
308
|
+
return path.split("/").includes("..");
|
|
309
|
+
}
|
|
310
|
+
/**
|
|
311
|
+
* @internal A tool call's policy decision with file paths checked in every
|
|
312
|
+
* form `sandbox` would reach, as its sandbox layer checks them, so dispatch
|
|
313
|
+
* and the sandbox agree (and an approval is asked for when one is needed).
|
|
314
|
+
*/
|
|
315
|
+
export function evaluateToolCallPolicyInSandbox(requestedCall, policy, sandbox) {
|
|
316
|
+
const call = canonicalizeToolCall(requestedCall);
|
|
317
|
+
const kinds = fileToolKinds(call.tool);
|
|
318
|
+
if (!policy || !kinds)
|
|
319
|
+
return evaluateToolCallPolicy(call, policy);
|
|
320
|
+
const input = typeof call.input === "object" && call.input !== null
|
|
321
|
+
? call.input
|
|
322
|
+
: {};
|
|
323
|
+
// Use the exact input field the tool and approval grant inspect (`cwd` for
|
|
324
|
+
// `glob`, `path` for every other file tool) so a decoy `path` on `glob`
|
|
325
|
+
// cannot select a different approval rule than the tree `glob` walks.
|
|
326
|
+
const key = approvalPathKey(call.tool);
|
|
327
|
+
const raw = stringProperty(input, key) ?? ".";
|
|
328
|
+
// The call itself (its tool policy and its own kind), plus every sandbox
|
|
329
|
+
// operation it performs on the path: `edit` reads as well as writes.
|
|
330
|
+
// Independent checks must all pass: the call's own decision, and the
|
|
331
|
+
// filesystem rules of every operation it performs on the path, judged
|
|
332
|
+
// apart from the tool policy (an allowed tool name never waives them).
|
|
333
|
+
// Only alternate forms of one path may satisfy an allowlist together.
|
|
334
|
+
const forms = pathFormsIn(sandbox, raw);
|
|
335
|
+
return allMustPass([
|
|
336
|
+
strictestPathDecision(forms, (form) => evaluateToolCallPolicy({ ...call, input: { ...input, [key]: form } }, policy)),
|
|
337
|
+
// Its operations are judged as the sandbox judges them: filesystem rules,
|
|
338
|
+
// and the tool policy's denies and approval rules for `read` / `write`
|
|
339
|
+
// (not its allowlist, so `toolPolicy.allow: ['stat']` admits stat).
|
|
340
|
+
...kinds.map((kind) => evaluateFileOperation(kind, forms, policy)),
|
|
341
|
+
]);
|
|
342
|
+
}
|
|
343
|
+
/** Tools whose approval covers a directory tree rather than one path. */
|
|
344
|
+
const TREE_TOOLS = new Set(["grep", "glob"]);
|
|
345
|
+
/** Operations approved for the current async scope (one approved tool call). */
|
|
346
|
+
const approvalScope = new AsyncLocalStorage();
|
|
347
|
+
function stringProperty(input, key) {
|
|
348
|
+
if (typeof input !== "object" || input === null)
|
|
349
|
+
return undefined;
|
|
350
|
+
const value = input[key];
|
|
351
|
+
return typeof value === "string" ? value : undefined;
|
|
352
|
+
}
|
|
132
353
|
/** @internal Run one approved tool operation through the sandbox policy layer. */
|
|
133
354
|
export function runWithSandboxPolicyApproval(sandbox, call, operation) {
|
|
134
|
-
return sandbox.__runWithPolicyApproval
|
|
355
|
+
return sandbox.__runWithPolicyApproval
|
|
356
|
+
? sandbox.__runWithPolicyApproval(call, operation)
|
|
357
|
+
: operation();
|
|
135
358
|
}
|
|
136
359
|
//# sourceMappingURL=policied-sandbox.js.map
|
|
@@ -1 +1 @@
|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UAAU,4BAA4B,CAC1C,OAAmB,EACnB,IAAc,EACd,SAA2B;IAE3B,OAAO,OAAO,CAAC,uBAAuB;QACpC,CAAC,CAAC,OAAO,CAAC,uBAAuB,CAAC,IAAI,EAAE,SAAS,CAAC;QAClD,CAAC,CAAC,SAAS,EAAE,CAAC;AAClB,CAAC"}
|
package/dist/policy.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ToolCall } from
|
|
1
|
+
import type { ToolCall } from "./tools.js";
|
|
2
2
|
/**
|
|
3
3
|
* Per-pattern approval metadata. Lets policy authors route specific
|
|
4
4
|
* tools/commands to a named audience (e.g. `'reviewer'`,
|
|
@@ -30,7 +30,7 @@ export interface ToolPolicy {
|
|
|
30
30
|
/** Declarative per-pattern approval routing. Evaluated before requireApproval. */
|
|
31
31
|
approvalRules?: ApprovalPolicyRule[];
|
|
32
32
|
}
|
|
33
|
-
export type ApprovalRisk =
|
|
33
|
+
export type ApprovalRisk = "low" | "medium" | "high";
|
|
34
34
|
export interface ApprovalEscalationPolicy {
|
|
35
35
|
afterMs: number;
|
|
36
36
|
notify?: string[];
|
|
@@ -52,7 +52,7 @@ export interface NetworkPolicy {
|
|
|
52
52
|
* `'denylist'` — listed hosts blocked, everything else allowed.
|
|
53
53
|
* `'none'` — block all outbound network. Useful for sandboxed analysis agents.
|
|
54
54
|
*/
|
|
55
|
-
mode?:
|
|
55
|
+
mode?: "allowlist" | "denylist" | "none";
|
|
56
56
|
/**
|
|
57
57
|
* Host patterns. Matched as glob against `URL.host`. Supports `*` for
|
|
58
58
|
* single-segment wildcard and `**` for any (e.g. `*.api.example.com`,
|
package/dist/policy.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"policy.d.ts","sourceRoot":"","sources":["../src/policy.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"policy.d.ts","sourceRoot":"","sources":["../src/policy.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,E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