@downcity/agent 1.1.119 → 1.1.120
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@downcity/agent",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.120",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Downcity Agent 运行时 — 单 Agent 执行壳与本机 RPC 能力",
|
|
6
6
|
"main": "./bin/index.js",
|
|
@@ -17,8 +17,8 @@
|
|
|
17
17
|
},
|
|
18
18
|
"dependencies": {
|
|
19
19
|
"@ai-sdk/openai-compatible": "^2.0.48",
|
|
20
|
-
"@downcity/shell": "^0.1.
|
|
21
|
-
"@downcity/type": "0.1.
|
|
20
|
+
"@downcity/shell": "^0.1.8",
|
|
21
|
+
"@downcity/type": "0.1.45",
|
|
22
22
|
"@larksuiteoapi/node-sdk": "^1.66.0",
|
|
23
23
|
"ai": "^6.0.193",
|
|
24
24
|
"commander": "^15.0.0",
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file 验证 shell safe sandbox 注入的临时目录环境变量。
|
|
3
|
+
*
|
|
4
|
+
* 关键点(中文)
|
|
5
|
+
* - 测试编译后的 shell 包导出,确保最终 package 产物包含一致行为。
|
|
6
|
+
* - zsh heredoc 会读取 `TMPPREFIX` 创建临时文件,因此必须指向 sandbox tmp。
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import test from "node:test";
|
|
10
|
+
import assert from "node:assert/strict";
|
|
11
|
+
import path from "node:path";
|
|
12
|
+
|
|
13
|
+
import { buildMacOsSeatbeltSandboxEnv } from "@downcity/shell/sandbox/MacOsSeatbeltSandbox.js";
|
|
14
|
+
import { buildLinuxBubblewrapSandboxEnv } from "@downcity/shell/sandbox/LinuxBubblewrapSandbox.js";
|
|
15
|
+
|
|
16
|
+
function createParams() {
|
|
17
|
+
const rootPath = "/tmp/downcity-shell-env/project";
|
|
18
|
+
const sandboxDir = path.join(rootPath, ".downcity", "sandbox");
|
|
19
|
+
const tmpDir = path.join(sandboxDir, "tmp");
|
|
20
|
+
const cacheDir = path.join(sandboxDir, ".cache");
|
|
21
|
+
|
|
22
|
+
return {
|
|
23
|
+
executionId: "sh_test",
|
|
24
|
+
executionDir: path.join(rootPath, ".downcity", "shell", "sh_test"),
|
|
25
|
+
cmd: "printf hello",
|
|
26
|
+
cwd: rootPath,
|
|
27
|
+
shellPath: "/bin/zsh",
|
|
28
|
+
login: true,
|
|
29
|
+
baseEnv: {
|
|
30
|
+
PATH: "/usr/bin:/bin",
|
|
31
|
+
LANG: "C.UTF-8",
|
|
32
|
+
DC_SESSION_ID: "session_test",
|
|
33
|
+
},
|
|
34
|
+
config: {
|
|
35
|
+
backend: "macos-seatbelt",
|
|
36
|
+
rootPath,
|
|
37
|
+
sandboxDir,
|
|
38
|
+
homeDir: sandboxDir,
|
|
39
|
+
tmpDir,
|
|
40
|
+
cacheDir,
|
|
41
|
+
envAllowlist: ["PATH", "LANG"],
|
|
42
|
+
writablePaths: [rootPath, sandboxDir],
|
|
43
|
+
networkMode: "full",
|
|
44
|
+
},
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
function assertSandboxTmpEnv(env, tmpDir) {
|
|
49
|
+
assert.equal(env.TMPDIR, tmpDir);
|
|
50
|
+
assert.equal(env.TMP, tmpDir);
|
|
51
|
+
assert.equal(env.TEMP, tmpDir);
|
|
52
|
+
assert.equal(env.TEMPDIR, tmpDir);
|
|
53
|
+
assert.equal(env.TMPPREFIX, path.join(tmpDir, "zsh"));
|
|
54
|
+
assert.equal(env.DC_SANDBOX_TMP, tmpDir);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
test("macOS seatbelt sandbox env points zsh TMPPREFIX at sandbox tmp", () => {
|
|
58
|
+
const params = createParams();
|
|
59
|
+
const env = buildMacOsSeatbeltSandboxEnv(params);
|
|
60
|
+
|
|
61
|
+
assertSandboxTmpEnv(env, params.config.tmpDir);
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
test("Linux bubblewrap sandbox env points zsh TMPPREFIX at sandbox tmp", () => {
|
|
65
|
+
const params = createParams();
|
|
66
|
+
const env = buildLinuxBubblewrapSandboxEnv({
|
|
67
|
+
...params,
|
|
68
|
+
config: {
|
|
69
|
+
...params.config,
|
|
70
|
+
backend: "linux-bubblewrap",
|
|
71
|
+
},
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
assertSandboxTmpEnv(env, params.config.tmpDir);
|
|
75
|
+
});
|