Repository navigation
feat(sandbox): run shell commands in the vendored jiuwenbox engine - #223
alanhungyl wants to merge 16 commits into
Conversation
Shell is the only tool that can enter the sandbox. The jiuwenbox package is copied unchanged into third_party/jiuwenbox and installed as an editable path dependency (jiuwenbox==0.1.0). iCode does not import it at startup. When sandbox.enabled is set, ShellTools._run returns before the host PTY or pipe and calls run_shell. An empty sandbox.url starts python -m jiuwenbox.server.launcher on 127.0.0.1; a filled URL connects to that server and does not start another. The client uses the existing HTTP API (health, create, start, exec). The workspace directory is appended as a read-write bind mount. Approval and the command filter still run first. A dead server, a timeout, or a non-Linux host returns a tool error and does not run the command on the host. The default is off, so the previous host path is unchanged. Project YAML cannot override the three settings. The settings panel does not show them yet. Swarm handlers, SysOperation, and the openjiuwen providers are not ported. Filesystem tools, background jobs, and live PTY output are not wired. etcd, Conch, the inference proxy, MCP routes, and the jiuwenbox CLI are copied with the engine and left unused. Tests cover the mocked client, backend, and supervisor, the shell bypass, and the setting defaults. Co-authored-by: Cursor <cursoragent@cursor.com>
Resolve the three conflicts with current main: pass sandbox settings through packs._create_shell, drop the tracked zh-Hans MO, and keep the catalog oracle without a pinned message count. Point the shell sandbox tests at the pack assembly and the renamed execute parameters. Co-authored-by: Cursor <cursoragent@cursor.com>
|
Hi @alanhungyl, thanks for your contribution! This pull request is currently waiting for the CLA Assistant check to pass before the CI process can continue. Please follow the signing link shown by CLA Assistant on this PR. If you have already signed the CLA but the check is still failing, please make sure that all email addresses used in your commits are added to and verified on your GitHub account. After updating your email settings or signing the CLA, please click Recheck in the CLA Assistant comment/check so the status can be refreshed. Once the CLA Assistant check passes, CI will continue automatically. |
|
head_sha: 🤖 正在生成合并请求摘要,请稍候… |
|
head_sha: 🤖 AI 代码检视正在进行中,请稍候… |
|
head_sha: |
1 similar comment
|
head_sha: |
The bundled server now authenticates with a token the sandbox cannot see, the launcher cannot be shadowed by a project package, and the wheel ships the engine instead of depending on a missing release. Co-authored-by: Cursor <cursoragent@cursor.com>
The writable mount is the workspace, and the bundled server no longer leaves its token, listen URL, or control socket where the sandbox can use them. Co-authored-by: Cursor <cursoragent@cursor.com>
bubblewrap could not mkdir /run after --remount-ro, so the daemon exited before any command ran. Co-authored-by: Cursor <cursoragent@cursor.com>
- Stop a cancelled exec on the server: bearer auth is plain ASGI middleware, so the exec route sees the client disconnect again. - Clean up every process an exec started, including setsid descendants, when no cgroup exists: each command runs under a per-command subreaper shim, and the process group is always killed. - Apply sandbox.network on reload like the other sandbox settings; a replaced server is stopped only after its last running command. - Key the workspace sandbox by its full mount set, keep a replaced read-only sandbox until its running execs finish, and send the physical workdir. - Narrow the jiuwenswarm scan to real dependencies and register sandbox.network in DEFERRED_KEYS. Co-authored-by: Cursor <cursoragent@cursor.com>
…isk cleanup - Sweep processes a dead shim or fastpath worker left in the sandbox PID namespace. The sweep runs only when bwrap marks a private PID namespace (JIUWENBOX_PRIVATE_PID_NAMESPACE, set only with --unshare-pid). - Retire a cancelled read-only sandbox so the last in-flight exec deletes it. - Without a cgroup, stop the whole sandbox once when its writable binds drop below the disk floor. Co-authored-by: Cursor <cursoragent@cursor.com>
|
head_sha:
|
A command cwd outside the workspace is no longer mounted, account control directories stay read-only, and each command joins its cgroup through a passed file descriptor. Co-authored-by: Cursor <cursoragent@cursor.com>
Starting in the home directory was rejected because the read-only engine-directory cover is a reserved path. Successful commands were run twice when stderr looked like an IPC failure, a kept proxy connection answered the next site with the first, and a half-close cut slow responses at two seconds. Cancelled creates stayed READY, and closing one shared manager deleted the other's files and signaled a server that still had a lease. Co-authored-by: Cursor <cursoragent@cursor.com>
…oses The in-sandbox forwarder stopped the response direction two seconds after the client shut its write side, so a slow download came back empty. Co-authored-by: Cursor <cursoragent@cursor.com>
…lid points - Process exit no longer orphans the bundled server. The last live runtime's release (an explicit RuntimeHold each engine acquires when it takes events, injected by assembly) stops every bundled server: a leased one gets a bounded wait for its lease, then is stopped anyway, and each server is closed exactly once. A network change still waits for leases. - A lease release runs on its own task, so a cancel while the gate is busy no longer skips the decrement and strands the retired server. - On Linux the launcher gets SIGTERM when iCode dies, even by SIGKILL (PR_SET_PDEATHSIG, armed only when iCode passes JIUWENBOX_PARENT_PID). - SandboxManager forgets state and policy files it deleted, so reusing an id in another manager no longer has the old manager unlink them. - Compliance: copyright headers on the three proxy modules; LICENSE, README.OpenSource and README.md for third_party/jiuwenbox; uvicorn without [standard] (drops uvloop, httptools, watchfiles, websockets); fastapi and annotated-doc in NOTICE. - fastapi and uvicorn are lazy-only base distributions; Smart Test maps the sandbox tests that import the vendored engine. Co-authored-by: Michael Ling <michael.ling.se@gmail.com>
|
复查了 #341 的 f9ed0dc。上一轮“取消冷启动后遗留多余 READY 沙箱”的 P1 可以关闭了。相同操作连续跑了三轮,每轮都只剩客户端持有的 1 个 READY。当前建议合并前优先处理前 5 项,其余 8 项按触发范围列在后面。
|
Paired: GitHub #223 ↔ GitCode !160
Summary
sandbox.enableddoes not fall back to the host.-Pfrom the interpreter prefix so a project package cannot shadow it.jiuwenboxrelease from PyPI.Test plan
/stop, anderror_messageon a sandbox that does not become readysandbox.enabledreturns an errortest_wait_manifest_matches_source