feat(fork): agentbox fork + /agentbox for Claude/Codex/OpenCode#12
Merged
Conversation
…n into a box Add `agentbox fork`: snapshot the current host Claude Code session and resume it in a fresh box, opening the box in a new iTerm tab / tmux window (or background when no multiplexer). Thin wrapper over the existing `agentbox claude --resume` create+teleport pipeline, with a background-not-inline fallback and LLM-resilience guards (refuses inside a box via AGENTBOX_RELAY_URL, tolerates an empty --provider). Add `agentbox install` to write the host-side Claude skills (`/agentbox` fork command + the renamed `agentbox-info` reference) into ~/.claude/skills, idempotent via a managed sentinel. `agentbox claude` prints a one-time install tip. Fix iTerm new-tab/window spawning: the `create window/tab ... command "..."` AppleScript parameter is unreliable on iTerm 3.7 betas (fails and bounces the command to Terminal.app); switch all modes to create-then-`write text`.
…ent` `agentbox fork` learns `--agent claude|codex|opencode` (default claude), routing the create+teleport+attach pipeline to the matching agent command: Claude/Codex resume via teleport; OpenCode starts a fresh box (its session teleport is still a stub). `agentbox install` now also writes the fork command for Codex (~/.codex/prompts/agentbox.md → /prompts:agentbox) and OpenCode (~/.config/opencode/commands/agentbox.md → /agentbox) when those tools are set up on the host, reusing the managed-sentinel idempotence. The Codex prompt has its agent resolve the live session uuid from the newest rollout file (Codex exposes no session-id variable); the OpenCode command notes it starts a fresh session.
On cloud providers the in-box agent session starts lazily at attach time. With `--attach-in tab|window|split`, runWrappedAttach re-invokes `agentbox <agent> attach <box>` in the fresh pane, and that re-invocation carries no launch args — so a forked `claude --resume <id>` (hetzner) started a fresh session instead of resuming the teleported one. (Docker starts the session at create time; Daytona is forced to inline attach, so both dodged this.) Add a `detached` build option that produces a "create the tmux session but don't attach" command. cloudAgentAttach now pre-creates the session with the full `--resume` command before the new-terminal spawn; the re-invoked attach finds it via `tmux has-session` and attaches to the already-resumed session. Verified on a live Hetzner box: the in-box process is `claude --resume <id>` and the teleported transcript is present.
madarco
added a commit
that referenced
this pull request
May 28, 2026
…vercelTimeoutMs)
vcpus and session timeout were hardcoded (2 / 45min). Add flat config keys
box.vercelVcpus + box.vercelTimeoutMs (matching the box.defaultCheckpointVercel
convention) and thread them: config -> providerOptions (vercel-only) ->
cloud-provider resource/timeout overrides -> CloudProvisionRequest.timeoutMs +
resources.cpu -> Sandbox.create({ resources: { vcpus }, timeout }). daytona /
hetzner are untouched (they don't set the override keys). Region stays fixed
iad1 (Vercel constraint).
Verified live: vercelVcpus=4 yields sandbox.vcpus===4 (default 2).
Closes backlog #12.
3 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds
agentbox fork— snapshot the current host agent session and resume it in a fresh box, opening it in a new terminal tab (iTerm/tmux) or background. Plus a user-invocable/agentboxcommand installed into Claude, Codex, and OpenCode.agentbox fork(apps/cli/src/commands/fork.ts): thin wrapper over each agent's existing create+teleport+attach pipeline. Flags:--agent claude|codex|opencode(default claude),--session,--provider,-n,--attach-in(defaulttab),--carry-yes. Background fallback when no tmux/iTerm (never hijacks the calling terminal). LLM-resilience guards: refuses inside a box (AGENTBOX_RELAY_URL), tolerates empty--provider, rejects--sessionwith--agent opencode.agentbox install: writes the/agentboxcommand into~/.claude/skills(fork command + renamedagentbox-inforeference), and — when detected —~/.codex/prompts/agentbox.mdand~/.config/opencode/commands/agentbox.md. Idempotent via an<!-- agentbox-managed:v1 -->sentinel.agentbox claudeprints a one-time install tip.${CLAUDE_SESSION_ID}skill placeholder; Codex (no session-id variable) has its agent resolve the live uuid from the newest rollout file; OpenCode starts a fresh box (session teleport not implemented yet).Fixes folded in
terminal/host.ts): thecreate window/tab ... command "..."AppleScript parameter is broken on iTerm 3.7 betas (bounces to Terminal.app); switched all modes to create-then-write text.core/provider.ts,sandbox-cloud/cloud-provider.ts,_cloud-attach.ts): cloud sessions start lazily at attach, and the new-tab re-invocation ofagentbox <agent> attachcarried no--resume, so hetzner forks started fresh. Added adetachedbuild option and pre-create the resumed session before the new-tab spawn.Scope
v1 is host→box only; box→box fork is deferred (needs
downloadPathfrom the source box + a relay endpoint). OpenCode resume is deferred (sessions live in a multi-tenant SQLite DB).Test plan
pnpm -w build, typecheck, lint,vitest(329 pass) greenagentbox installwrites all 4 agent files; idempotent re-runfork --agent codexresumed a real Codex session in a box;fork --agent opencodestarted a fresh boxclaude --resume <id>in the box (was fresh before)/agentboxin Claude,/prompts:agentboxin Codex,/agentboxin OpenCodeNote
Medium Risk
New fork/install orchestration touches session teleport and terminal/cloud attach paths; cloud detached pre-start fixes resume correctness but adds attach complexity.
Overview
Adds
agentbox forkto teleport the current host Claude/Codex/OpenCode session into a new sandbox (default new iTerm/tmux tab, background when no splittable terminal so the caller’s session isn’t hijacked). It delegates to each agent’s existing create + session-teleport + attach flow, with guards for in-box runs (AGENTBOX_RELAY_URL), ambiguous recent Claude sessions, and no OpenCode resume yet.Adds
agentbox installto ship bundled host skills/prompts (/agentboxfork +agentbox-inforeference) into Claude, and into Codex/OpenCode when those config dirs exist, with idempotentagentbox-managedoverwrite rules.agentbox claudeshows a one-time tip to run install when the fork skill is missing.Fixes cloud resume on new-tab attach: pre-creates the tmux session detached with the full launch command (
claude --resume …) before the tab re-invokes attach without extra args. iTerm spawning now uses create-then-write textinstead of brokencommandparameters on 3.7 betas.Reviewed by Cursor Bugbot for commit 7e45062. Configure here.