feat: support -i background queue on cloud providers#34
Merged
Conversation
The -i / --initial-prompt background queue was docker-only: the worker
hardcoded createBox + startXxxSession and the agent commands rejected
cloud providers up front. The rejection was a v1 shortcut, not a real
limitation -- buildAttach({ detached: true }) already pre-starts a
seeded tmux session without attaching (used for new-tab attaches).
- Remove the isCloud rejection in claude/codex/opencode -i branches.
- Extract cloudAgentStartDetached (+ shared startDetachedSession) in
_cloud-attach.ts; reuse at the existing new-tab pre-start call site.
- Route the queue worker on job.providerName: docker keeps runDockerJob;
cloud gets runCloudJob, mirroring the foreground cloud-create path and
pre-starting the prompt-seeded session detached.
- Seed prompt + post-`--` args (e.g. --permission-mode=plan) forward
through buildPromptArgs -> the cloud launcher unchanged.
Verified live on Vercel: queued job creates the box, pre-starts the
detached session with the seeded prompt, and honors forwarded args
(claude launched in plan mode).
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
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.
What
The
-i/--initial-promptbackground queue was docker-only:agentbox claude -i "<prompt>"(andcodex/opencode) on a cloud provider was hard-rejected with "-i / --initial-prompt is currently docker-only (cloud sessions only start on attach)."That rejection was a v1 scoping shortcut, not a real limitation. The mechanism to seed a prompt without an interactive attach already shipped:
provider.buildAttach(box, 'agent', { command, detached: true })creates + configures the agent's tmux session running the full launch command without attaching (already used for new-tab attach pre-starts). This PR wires the queue worker to use it, so cloud-ireaches parity with docker.Changes
-ibranch ofclaude.ts/codex.ts/opencode.ts(the provider-neutral credential pre-check stays).cloudAgentStartDetached(+ sharedstartDetachedSession) in_cloud-attach.ts; refactor the existing new-tab pre-start call site to reuse it (one implementation).job.providerNamein_run-queued-job.ts: docker keepsrunDockerJob; cloud getsrunCloudJob, mirroring the foreground cloud-create path (provider.createdoes credential volumes / git-bundle seed / ctl daemon) and pre-starting the prompt-seeded session detached.--args (e.g.--permission-mode=plan) forward throughbuildPromptArgs→ the cloud launcher unchanged.skills/agentbox/SKILL.md(cross-provider + arg-forwarding example); added a unit test for the prompt+args → launcher contract.The concurrency gate and
queue listUX already work cross-provider — no queue-loop changes.Verification
pnpm build/typecheck/lintclean; full suite 368 tests pass (cloud-attach +1).--provider vercel):-ijobs → two boxes, bothdone.QUEUE_TEST.mdwith the exact requested content (verified viasbx exec).-- --permission-mode=plan→ claude launched in plan mode.claude:waiting/claude:idle) — the input the working-agent gate consumes.1+Enter to the pre-started session's plan prompt advanced claude (approved → executed → switched to auto mode), proving the queue-pre-started detached session is a fully-functional interactive session.Notes (pre-existing, not introduced here)
--max-running(running-box gate) can over-start when box-create lags the scheduler tick:defaultCountRunningBoxesreadsstate.jsonand doesn't count in-flight queue jobs whose box isn't created yet. Affects docker identically; the working-agent gate (--max-working) is the one that counts in-flight creates. Tracked separately.agentbox <agent> attachdefaults to a new-terminal split; use--inlineto attach in the current terminal.Note
Medium Risk
Adds a new cloud create + detached-session path in the hidden queue worker; failures may leave boxes without a usable session until attach, but reuses existing attach/detached plumbing rather than new auth or data handling.
Overview
-i/--initial-promptbackground queue now works on cloud providers (Daytona, Hetzner, Vercel), not only Docker. The CLI no longer rejects cloud when-iis set onagentbox claude,codex, oropencode.The internal queue worker (
_run-queued-job) branches onjob.providerName: Docker keeps baking the prompt intotmux new-session; cloud runsrunCloudJob(create box viaprovider.create, thencloudAgentStartDetached) so a detached tmux session is seeded before any attach—reusing the samebuildAttach({ detached: true })path already used for new-tab attach pre-starts.startDetachedSessionis shared between that path and the queue worker.Docs (
skills/agentbox/SKILL.md) and a unit test onbuildPromptArgs→buildCloudAttachInnerCommanddocument that the seed prompt and post---args reach the in-box agent in order.Reviewed by Cursor Bugbot for commit f081fbf. Configure here.