@tcb-sandbox/cli 0.3.9 → 0.4.0
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 +8 -2
- package/dist/cli.js +13 -19
- package/dist/serve.js +14 -3
- package/dist/trw-embedded.js +657 -657
- package/docs/local-mode.md +33 -6
- package/docs/quick-start.md +1 -1
- package/docs/thin-client.md +4 -13
- package/package.json +1 -1
package/docs/local-mode.md
CHANGED
|
@@ -3,21 +3,35 @@
|
|
|
3
3
|
在本机进程里跑 **内置的 TRW**(和远端沙箱同一套 HTTP / MCP 面),**不需要**单独发布一个叫 TRW 的 npm 包。
|
|
4
4
|
|
|
5
5
|
```bash
|
|
6
|
-
tcb-sandbox serve
|
|
7
|
-
tcb-sandbox
|
|
6
|
+
tcb-sandbox serve # 单工作空间模式(默认)
|
|
7
|
+
tcb-sandbox serve --multi-session # 多会话模式
|
|
8
|
+
tcb-sandbox local # 与 serve 完全等价,别名
|
|
8
9
|
```
|
|
9
10
|
|
|
11
|
+
## 两种工作空间模式
|
|
12
|
+
|
|
13
|
+
| 模式 | 启动方式 | Session Header | 工作目录 | 默认路径 |
|
|
14
|
+
|------|----------|---------------|----------|----------|
|
|
15
|
+
| **单工作空间**(默认) | `tcb-sandbox serve` | 不需要 | `--workspace-root` 本身 | `~/.tcb-sandbox/workspace` |
|
|
16
|
+
| **多会话** | `tcb-sandbox serve --multi-session` | `X-Cloudbase-Session-Id` | `workspace-root/<session-id>/` | `~/.tcb-sandbox/workspaces` |
|
|
17
|
+
|
|
18
|
+
**单工作空间模式**最适合本地开发:不需要 session header,直接对着工作目录操作。
|
|
19
|
+
|
|
20
|
+
**多会话模式**行为与远端 SCF 完全一致,适合需要多租户隔离的测试场景。
|
|
21
|
+
|
|
10
22
|
## 常用参数
|
|
11
23
|
|
|
12
24
|
| 选项 | 默认 | 说明 |
|
|
13
25
|
|------|------|------|
|
|
14
26
|
| `--port` | `9000` | 监听端口 |
|
|
15
27
|
| `--host` | `127.0.0.1` | 绑定地址;`0.0.0.0` 会暴露到局域网,仅在你清楚风险时用 |
|
|
16
|
-
| `--workspace-root` |
|
|
28
|
+
| `--workspace-root` | 见上表 | 工作目录(单模式)或会话父目录(多会话) |
|
|
29
|
+
| `--multi-session` | `false` | 启用多会话模式 |
|
|
17
30
|
|
|
18
31
|
## 会话与安全
|
|
19
32
|
|
|
20
|
-
-
|
|
33
|
+
- **单工作空间模式**:无需 session header;内部使用固定 session ID `"default"`。
|
|
34
|
+
- **多会话模式**:客户端带 **`X-Cloudbase-Session-Id`**(CLI 用 **`--session-id`**)。
|
|
21
35
|
- 默认 **不做登录鉴权**;需要时应在 TRW 前面加网关。
|
|
22
36
|
- **不是**云函数容器:没有冻结 / TTL / 唤醒语义;**Ctrl+C** 即停进程。
|
|
23
37
|
|
|
@@ -27,7 +41,7 @@ tcb-sandbox local # 与 serve 完全等价,别名
|
|
|
27
41
|
|
|
28
42
|
| 可写路径 | 说明 |
|
|
29
43
|
|----------|------|
|
|
30
|
-
| `<workspace-root>/` |
|
|
44
|
+
| `<workspace-root>/` | 会话工作区 |
|
|
31
45
|
| `/tmp`、`/private/tmp` | 系统临时目录 |
|
|
32
46
|
| `/dev` | 设备文件(tty、null 等) |
|
|
33
47
|
| `/private/var/folders` | macOS 用户缓存 |
|
|
@@ -70,7 +84,19 @@ pnpm --filter @tcb-sandbox/cli run build
|
|
|
70
84
|
|
|
71
85
|
## 启动之后
|
|
72
86
|
|
|
73
|
-
TRW **七大门面**与探活/文档/预览见 **[quick-start.md](./quick-start.md)
|
|
87
|
+
TRW **七大门面**与探活/文档/预览见 **[quick-start.md](./quick-start.md)**。
|
|
88
|
+
|
|
89
|
+
单工作空间模式自测:
|
|
90
|
+
|
|
91
|
+
```bash
|
|
92
|
+
# 不需要 --session-id
|
|
93
|
+
tcb-sandbox --endpoint http://127.0.0.1:9000 health
|
|
94
|
+
curl -X POST http://localhost:9000/api/tools/bash \
|
|
95
|
+
-H 'Content-Type: application/json' \
|
|
96
|
+
-d '{"command": "echo hello"}'
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
多会话模式自测:
|
|
74
100
|
|
|
75
101
|
```bash
|
|
76
102
|
tcb-sandbox --endpoint http://127.0.0.1:9000 --session-id my-local-session health
|
|
@@ -88,6 +114,7 @@ tcb-sandbox --endpoint http://127.0.0.1:9000 --session-id my-local-session healt
|
|
|
88
114
|
|
|
89
115
|
| 点 | 说明 |
|
|
90
116
|
|----|------|
|
|
117
|
+
| 工作空间模式 | 本地默认单工作空间(无 session);远端始终多会话(SCF 网关注入 session) |
|
|
91
118
|
| 符号链接相关用例 | 线上常有 **`WORKSPACE_SYMLINKS`**;随手 `serve` 没配可能和 trw-example 本地阶段表现不一致 |
|
|
92
119
|
| 快照 / S3 | 本地常未配 S3;只要错误信息里提到配置即可视为预期 |
|
|
93
120
|
| 预览里 `npm install` | TRW 进程要能访问外网 |
|
package/docs/quick-start.md
CHANGED
|
@@ -57,7 +57,7 @@ tcb-sandbox --endpoint http://127.0.0.1:9000 --session-id demo-1 read hello.txt
|
|
|
57
57
|
|
|
58
58
|
## 6. E2B 兼容
|
|
59
59
|
|
|
60
|
-
|
|
60
|
+
**根路径数据面:** E2B 兼容路由挂在**网关根**(`/files`、`/process.*` 等),使用 **E2B SDK `sandboxUrl` + `X-Cloudbase-Session-Id` 直连**即可,无需本地代理。见 **[docs/e2b-usage.md](../../docs/e2b-usage.md)**。
|
|
61
61
|
|
|
62
62
|
## 7. SDK
|
|
63
63
|
|
package/docs/thin-client.md
CHANGED
|
@@ -83,18 +83,9 @@ tcb-sandbox pty kill <ptyId> --signal SIGTERM
|
|
|
83
83
|
|
|
84
84
|
把 `<ptyId>` 换成上一步 `create` 返回的 id。
|
|
85
85
|
|
|
86
|
-
##
|
|
86
|
+
## 旧文档兼容说明
|
|
87
87
|
|
|
88
|
-
|
|
88
|
+
旧文档里可能出现 `tools call ...` 写法,但当前 CLI 已移除该入口。
|
|
89
89
|
|
|
90
|
-
|
|
91
|
-
tcb-sandbox
|
|
92
|
-
|
|
93
|
-
tcb-sandbox tools call write --data '{"path":"hello.txt","content":"hello"}'
|
|
94
|
-
|
|
95
|
-
tcb-sandbox tools call bash --param command='echo hello' --param mode=dry_run
|
|
96
|
-
```
|
|
97
|
-
|
|
98
|
-
`bash`:**不写 `mode` 为执行**;`mode=dry_run` / `dryrun` 为干跑(带风险摘要与 `changeSet`)。
|
|
99
|
-
|
|
100
|
-
其余如 `capability_list`、`list_mcp_servers`、`add_mcp_servers` 等,把工具名和 `--data` / `--param` 换成 `/api/docs` 中的定义即可,不再逐条罗列。
|
|
90
|
+
- ✅ 请直接使用对应顶级子命令(`read` / `write` / `bash` / `capability-*` / `add-mcp-servers` 等)
|
|
91
|
+
- ✅ 具体参数以 `tcb-sandbox --help` 与 `GET /api/docs` 为准
|