Repository navigation
agent: rewrite on Void; container driven through ctx.container - #10
Conversation
Stock Void app (void 1.5 on Vite 8): file routes with defineHandler, per-sandbox state in defineDurableState with a single setAlarm-driven alarm hook, and Void Sandboxes (void/sandbox) instead of @cloudflare/sandbox directly. - routes/ for GET /, repository/task POSTs, state and diff GETs; JSON errors incl. a 404/405 middleware rewrite; AGENT_TOKEN Bearer [REDACTED] - durable-objects/agent.ts ports the Pi Durable harness (SQLite storage, worker + container runtimes, brokered model calls, recovery) - sandbox/Dockerfile stays RUN-free with the shim pinned to bun.lock (test/dockerfile.test.ts fails on drift); the agent server bundle is COPYed into the image and started with node - worker.vars in void.config.ts bake Settings env at build time; no env.ts, no celld-config plugin, no dist/wrangler.json - adapters (tools/clone-deps/server-client) take injected sandbox clients; tests drive every seam with fakes (109 pass)
celld 0.6.3 cannot pass RPC stubs or streams across isolate boundaries, and Void's sandbox client returns both, so every sandbox call failed. Keep Void (routes, defineDurableState, baked vars, RUN-free image) but replace void/sandbox with a native container Durable Object that owns the ctx.container handle: exec runs to completion in-isolate and returns plain data, container HTTP crosses via stub.fetch(). - durable-objects/container.ts: AgentContainer (defineDurableObject) with plain-data exec/execDetached and a /<port>/... fetch proxy; bounded retry of the post-start 404 race, per-exec kill deadlines - src/container-adapter.ts: sandbox client over the container stub (stat/readFile/writeFile composed from exec); timeouts cross as ms - agent.ts, tools.ts, clone-deps.ts, server-client.ts: off void/sandbox, AbortSignal -> timeoutMs - void.config.ts: plain containers[] entry (image names the Dockerfile); no sandbox: section - sandbox/Dockerfile: drop the sandbox-shim (nothing consumes it), EXPOSE the agent server port - tests: new container-adapter coverage, exact-timeout assertions, Dockerfile shape without the shim pin
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 34 minutes. View limit details
|
| Layer / File(s) | Summary |
|---|---|
Void configuration and container image templates/agent/void.config.ts, templates/agent/void.lock.json, templates/agent/vite.config.ts, templates/agent/sandbox/Dockerfile, templates/agent/scripts/*, templates/agent/package.json, templates/agent/tsconfig.json, templates/agent/.gitignore, templates/agent/.oxlintrc.json, templates/agent/AGENTS.md, templates/agent/README.md, templates/agent/.dev.vars.example, templates/agent/wrangler.jsonc, templates/agent/test/build.test.ts, templates/agent/test/dockerfile.test.ts |
Void and Vite configuration replaces the custom build and Wrangler configuration. A script bundles the agent server for the container image. The example .dev.vars file and tests for the removed build script are deleted. Setup and build documentation and Dockerfile checks are updated. |
Container RPC and agent-server client templates/agent/durable-objects/container.ts, templates/agent/src/container-adapter.ts, templates/agent/src/clone-deps.ts, templates/agent/src/server-client.ts, templates/agent/src/container-pump.ts, templates/agent/src/protocol.ts, templates/agent/src/container/*, templates/agent/test/container-adapter.test.ts, templates/agent/test/clone-deps.test.ts, templates/agent/test/server-client.test.ts, templates/agent/test/container-pump.test.ts |
The container Durable Object adds command execution and HTTP proxying. Adapters provide container operations to clone and agent-server clients. The client manages server readiness, task submission, event polling, answers, and aborts. |
Agent state, tasks, and runtime pumps templates/agent/durable-objects/agent.ts, templates/agent/src/tools.ts, templates/agent/src/env.ts, templates/agent/src/errors.ts, templates/agent/src/repo-clone.ts, templates/agent/src/agent.ts, templates/agent/test/tools.test.ts |
The Agent Durable Object manages repository and task records, alarms, worker and container execution, state, diffs, transcripts, and model requests. Worker-mode tools and environment helpers support execution. The former AgentSandbox module is removed. |
Sandbox routes and management page templates/agent/routes/*, templates/agent/middleware/01.json-errors.ts, templates/agent/src/page.ts, templates/agent/src/sandbox-name.ts, templates/agent/src/index.ts, templates/agent/test/sandbox-name.test.ts |
The routes add repository and task submission, state, and diff endpoints. The management page calls these endpoints, and middleware converts non-JSON 404 and 405 responses to JSON. Sandbox-name validation accepts lowercase letters, digits, and dashes for names up to 63 characters. The former Worker entry point is removed. |
Estimated code review effort: 4 (Complex) | ~60 minutes
Change: Refactor
Sequence Diagram(s)
sequenceDiagram
participant Client
participant SandboxRoute
participant Agent
participant Container
participant AgentServer
Client->>SandboxRoute: Submit task
SandboxRoute->>Agent: startTask
Agent-->>SandboxRoute: Return task admission result
Agent->>Agent: Persist task and schedule alarm
Agent->>Container: Execute or proxy agent-server requests
Container->>AgentServer: Start server or forward HTTP request
Possibly related PRs
- ryuzcorp/noite-templates#9: Adds the authentication, asynchronous operation, confined-tool, and container-runtime behavior that this PR replaces with the Void and Durable Object architecture.
Merge Risk: 
Moderate · previous review 6d417
-
After a container recycle, task submission and diff requests can wait past the edge timeout and return a 504. The task may still be admitted, so the client cannot tell whether it succeeded. Restoring the legacy local-secret ignore rules and tightening a test and the token handling are smaller follow-ups. Resolve the request-path wait before merging, or accept it explicitly.
Pre-merge checks: 
4 · 
1
-
Failed checks: 1 warning Passed checks: 4 passedFull details: Docstring Coverage
-
Explanation
Docstring coverage is 57.78% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 45 functions across 31 files. (8 skipped: 8 unsupported.)
Resolution
Write docstrings for the functions missing them to satisfy the coverage threshold.
-
Finishing Touches
-
Generate docstrings
-
- Commit to this branch
- Create a new PR
Generate unit tests (beta)
-
- Commit to this branch
- Create a new PR
-
- Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
POST /task no longer waits on ensureCheckout (up to 90s start grace +
120s clone, past the 30s edge timeout): it records pending/starting and
answers 202, and the alarm restores before the harness submit (worker,
new pending state) or before the pump submits (container, via
prepareCheckout). A failed restore fails the task with a clear error.
GET /diff answers from the container only when the checkout exists;
when missing or cold it schedules the restore durably and answers 409
{status:restoring} at once, with short timeouts and zero start grace so
it never blocks on clone or container start.
Also: restore .dev.vars* gitignores, clear agent-token on input clear,
await the clone-deps rejects assertion.
The agent template is rewritten on stock Void (owner request: "refactor agent template and make sure it uses Void Sandboxes").
Shape
routes/(GET /,POST /sandboxes/:name/{repository,task},GET /sandboxes/:name,GET /sandboxes/:name/diff), with JSON 404/405 middleware.durable-objects/agent.ts(defineDurableState). OnesetAlarmalarm runs the clone, harness and container pumps, Pi Durable runs over the object's SQLite storage, and both runtimes and recovery are kept.durable-objects/container.tsis a plain Durable Object (defineDurableObject) that drivesctx.containerdirectly. It is declared throughvoid.config.ts→cloudflare.containerswithimage: sandbox/Dockerfile. That Dockerfile has noRUN, so the Noite runner builds it after checking it and pinning its base images by digest.worker.varsat build time. There is noenv.ts, and secrets are omitted when unset.wrangler.jsonc,scripts/build.ts,src/index.ts,src/agent.ts, the sandbox-shim.Why not
void/sandboxyetOn celld 0.6.3, Noite's runtime,
void/sandboxfails three ways (lab evidence in ryuzcorp/noite#127):ctx.container.imagesis missing.start()gets 404.So the container DO exchanges only plain data (ArrayBuffers included). It retries only the post-start 404, for at most 90 s. The README says Void Sandboxes replace it once celld supports cross-isolate RPC.
Needs
ryuzcorp/noite#127: it deploys Void's own
dist/ssr/wrangler.jsonand builds RUN-free Dockerfile images. Merge this PR after that one; it ships in the next Noite alpha.Verification
bun run checkintemplates/agent: typecheck, oxlint, build, and 115 tests pass.ready, afauxtask runsexec, and the diff answers 200.bashtool.docker rm -f), the next task recovered and finisheddone.Summary by CodeRabbit