@clearideas/agent-runtime-sandbox 0.6.0 → 0.6.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/assets/agent-fs.py
CHANGED
|
@@ -11,7 +11,7 @@ prints exactly one JSON document on stdout and exits with:
|
|
|
11
11
|
4 limit exceeded
|
|
12
12
|
5 read-only mount
|
|
13
13
|
|
|
14
|
-
Paths are relative POSIX paths whose segments match [A-Za-z0-
|
|
14
|
+
Paths are relative POSIX paths whose segments match [A-Za-z0-9_][A-Za-z0-9._-]*.
|
|
15
15
|
Symbolic links are never followed. Content is never interpreted beyond UTF-8
|
|
16
16
|
decoding for text windows and literal substring search.
|
|
17
17
|
"""
|
|
@@ -27,7 +27,7 @@ import tempfile
|
|
|
27
27
|
|
|
28
28
|
PROTOCOL_VERSION = 1
|
|
29
29
|
HELPER_VERSION = "1.0.0"
|
|
30
|
-
SEGMENT = re.compile(r"^[A-Za-z0-
|
|
30
|
+
SEGMENT = re.compile(r"^[A-Za-z0-9_][A-Za-z0-9._-]*$")
|
|
31
31
|
MAX_PATH_LENGTH = 1024
|
|
32
32
|
MAX_PATH_DEPTH = 64
|
|
33
33
|
TEXT_SNIFF_BYTES = 8192
|
package/dist/policy.js
CHANGED
|
@@ -154,7 +154,7 @@ const pathSchema = {
|
|
|
154
154
|
type: "string",
|
|
155
155
|
minLength: 1,
|
|
156
156
|
maxLength: 1024,
|
|
157
|
-
description: "
|
|
157
|
+
description: "Path relative to the workspace root, such as docs/guide.md. Use forward slashes.",
|
|
158
158
|
};
|
|
159
159
|
const BUILTIN_SCHEMAS = {
|
|
160
160
|
list_files: {
|
|
@@ -166,7 +166,8 @@ const BUILTIN_SCHEMAS = {
|
|
|
166
166
|
properties: {
|
|
167
167
|
path: {
|
|
168
168
|
...pathSchema,
|
|
169
|
-
|
|
169
|
+
minLength: 0,
|
|
170
|
+
description: "Directory to list, relative to the workspace root, such as docs. Omit it to list the root.",
|
|
170
171
|
},
|
|
171
172
|
glob: { type: "string", minLength: 1, maxLength: MAXIMUM_GLOB_LENGTH },
|
|
172
173
|
limit: { type: "integer", minimum: 1, maximum: MAXIMUM_LIST_LIMIT },
|
|
@@ -349,13 +350,31 @@ const requireBoolean = (value, label) => {
|
|
|
349
350
|
throw invalidArguments(`${label} must be a boolean.`);
|
|
350
351
|
return value;
|
|
351
352
|
};
|
|
353
|
+
/**
|
|
354
|
+
* Accept the common spellings of a relative workspace path and return its
|
|
355
|
+
* canonical form: Windows separators (`reports\q3.md`), a leading `./` or
|
|
356
|
+
* `/`, repeated or trailing slashes, and `.` segments. `.` alone (or an empty
|
|
357
|
+
* path) means the workspace root and normalizes to "". Nothing here can
|
|
358
|
+
* change which file a path names: `..`, hidden segments, drive letters, and
|
|
359
|
+
* other unsafe segments are left in place and rejected by the caller.
|
|
360
|
+
*/
|
|
361
|
+
const normalizeWorkspaceToolPath = (value) => value
|
|
362
|
+
.trim()
|
|
363
|
+
.replaceAll("\\", "/")
|
|
364
|
+
.split("/")
|
|
365
|
+
.filter((segment) => segment !== "" && segment !== ".")
|
|
366
|
+
.join("/");
|
|
352
367
|
const requirePath = (value, label, required = true) => {
|
|
353
368
|
const text = requireString(value, label, 1024, required);
|
|
354
369
|
if (text === undefined)
|
|
355
370
|
return undefined;
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
371
|
+
const normalized = normalizeWorkspaceToolPath(text);
|
|
372
|
+
// An optional directory path may name the root; a file path may not.
|
|
373
|
+
if (normalized === "" && !required)
|
|
374
|
+
return undefined;
|
|
375
|
+
if (!isSafeWorkspacePath(normalized))
|
|
376
|
+
throw invalidPath(`${label} must be a path inside the workspace, such as docs/guide.md (got ${JSON.stringify(text)}). Segments must start with a letter, digit, or underscore and may contain letters, digits, ".", "_", and "-". Dot-prefixed segments and traversal are not allowed.`);
|
|
377
|
+
return normalized;
|
|
359
378
|
};
|
|
360
379
|
const rejectUnknownKeys = (input, allowed) => {
|
|
361
380
|
for (const key of Object.keys(input)) {
|
|
@@ -2,7 +2,8 @@ import { type SandboxCommand, type SandboxFileInfo, type SandboxHandle, type San
|
|
|
2
2
|
/**
|
|
3
3
|
* TEST-ONLY provider that runs commands as ordinary host processes inside a
|
|
4
4
|
* temporary directory, rewriting `/workspace` paths in arguments and
|
|
5
|
-
* environment
|
|
5
|
+
* environment and the runtime-owned workspace index to that directory.
|
|
6
|
+
* It provides no isolation whatsoever and
|
|
6
7
|
* exists so the run sandbox can be exercised end to end (including the real
|
|
7
8
|
* helper script) on hosts without bubblewrap or Docker. It is deliberately not
|
|
8
9
|
* exported from the package entry point.
|
|
@@ -4,10 +4,12 @@ import { chmod, lstat, mkdir, mkdtemp, readdir, readFile, rm, writeFile, } from
|
|
|
4
4
|
import { tmpdir } from "node:os";
|
|
5
5
|
import path from "node:path";
|
|
6
6
|
import { assertSandboxPath, } from "../contracts.js";
|
|
7
|
+
import { SANDBOX_WORKSPACES_FILE } from "../policy.js";
|
|
7
8
|
/**
|
|
8
9
|
* TEST-ONLY provider that runs commands as ordinary host processes inside a
|
|
9
10
|
* temporary directory, rewriting `/workspace` paths in arguments and
|
|
10
|
-
* environment
|
|
11
|
+
* environment and the runtime-owned workspace index to that directory.
|
|
12
|
+
* It provides no isolation whatsoever and
|
|
11
13
|
* exists so the run sandbox can be exercised end to end (including the real
|
|
12
14
|
* helper script) on hosts without bubblewrap or Docker. It is deliberately not
|
|
13
15
|
* exported from the package entry point.
|
|
@@ -45,7 +47,20 @@ export class HostProcessTestProvider {
|
|
|
45
47
|
const existing = await lstat(target).catch(() => undefined);
|
|
46
48
|
if (existing)
|
|
47
49
|
await chmod(target, 0o600);
|
|
48
|
-
|
|
50
|
+
let content = file.content;
|
|
51
|
+
// This runtime-owned index must describe the same host paths as argv
|
|
52
|
+
// and environment. Never rewrite workspace files or arbitrary JSON.
|
|
53
|
+
if (file.path === SANDBOX_WORKSPACES_FILE) {
|
|
54
|
+
const index = JSON.parse(typeof content === "string"
|
|
55
|
+
? content
|
|
56
|
+
: new TextDecoder().decode(content));
|
|
57
|
+
for (const mount of Object.values(index.mounts)) {
|
|
58
|
+
mount.path = this.translate(handle, mount.path);
|
|
59
|
+
}
|
|
60
|
+
index.output = this.translate(handle, index.output);
|
|
61
|
+
content = JSON.stringify(index);
|
|
62
|
+
}
|
|
63
|
+
await writeFile(target, content);
|
|
49
64
|
await chmod(target, file.mode ?? 0o600);
|
|
50
65
|
}
|
|
51
66
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@clearideas/agent-runtime-sandbox",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.2",
|
|
4
4
|
"description": "Provider-neutral sandbox lifecycle and code execution adapters for Clear Ideas Agent Runtime.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"author": "Clear Ideas Incorporated",
|
|
@@ -41,8 +41,8 @@
|
|
|
41
41
|
"postpack": "node ../../scripts/cleanup-package-license.mjs"
|
|
42
42
|
},
|
|
43
43
|
"dependencies": {
|
|
44
|
-
"@clearideas/agent-runtime-contracts": "0.6.
|
|
45
|
-
"@clearideas/agent-runtime-core": "0.6.
|
|
44
|
+
"@clearideas/agent-runtime-contracts": "0.6.2",
|
|
45
|
+
"@clearideas/agent-runtime-core": "0.6.2"
|
|
46
46
|
},
|
|
47
47
|
"devDependencies": {
|
|
48
48
|
"@types/node": "^26.4.0",
|