Skip to content

Add Tenki Sandbox as a cloud provider (#4)#244

Open
francoluxor wants to merge 1 commit into
madarco:mainfrom
francoluxor:main
Open

Add Tenki Sandbox as a cloud provider (#4)#244
francoluxor wants to merge 1 commit into
madarco:mainfrom
francoluxor:main

Conversation

@francoluxor

Copy link
Copy Markdown

What this changes

Add Tenki Sandbox as a cloud provider

Adds --provider tenki: each box runs in a Tenki (tenki.cloud) Firecracker microVM driven over the official @tenkicloud/sandbox TypeScript SDK — a ConnectRPC control plane plus a per-session data plane for exec/file transfer, and session.ssh() for interactive attach.

How it was tested

Full workspace gate — all green:

pnpm lint
pnpm build
pnpm typecheck
pnpm test

Unit tests (@agentbox/sandbox-tenki): state mapping (incl. USER_SHUTDOWN), retry classification (ConnectRPC + socket codes), preview-slug/name helpers, env parsing, isUnderWorkdir boundary cases, and parseTenkiSize.

@agentbox/config includes the providers/schema drift tests, so the PROVIDERS table ↔ ProviderKind/KEY_REGISTRY/JSON-schema stay consistent, plus a KEY_REGISTRY duplicate-key guard.

Live end-to-end against a real Tenki workspace (api.tenki.cloud), driving the built provider (tenkiBackend) directly — one session at a time, self-cleaned, 0 leaked sessions/snapshots afterward.

Checklist

  • pnpm lint && pnpm build && pnpm typecheck && pnpm test passes
  • Public docs updated if a command, flag, config key, or default changed (apps/web/content/docs/)
  • I have read and agree to the Contributor License Agreement

* Add Tenki Sandbox as a cloud provider

Adds `--provider tenki`: each box runs in a Tenki (tenki.cloud) Firecracker
microVM driven over the official @tenkicloud/sandbox TypeScript SDK — a
ConnectRPC control plane plus a per-session data plane for exec/file transfer,
and session.ssh() for interactive attach.

New packages/sandbox-tenki implements the CloudBackend contract and exports a
uniform providerModule (provider/backend/ensureCredentials/readCredStatus/
currentBaseFingerprintLive/doctorChecks). Tenki is registered in the PROVIDERS
single-source-of-truth table and both provider IMPORTERS maps (CLI + hub);
config keys (box.imageTenki / sizeTenki / defaultCheckpointTenki /
tenkiTimeoutMs), schema, and docs follow the existing cloud-provider pattern.

Validated end-to-end against a live Tenki workspace: provision, exec, file
seed (workdir-bridged for /tmp + /workspace), download round-trip, preview +
signed preview URLs, pause/resume, keepalive extend, snapshots, and destroy.

* Address review on the Tenki provider

- Drop the duplicate manual KEY_REGISTRY entries for box.defaultCheckpointTenki
  / sizeTenki / imageTenki (the perProvider*Keys() generators already emit them
  from the PROVIDERS table); add a KEY_REGISTRY uniqueness guard and fix the
  tenki sizeDesc to match actual create-time sizing.
- Add setCredentials to the tenki providerModule so the hub credential form
  works (was a dead end); delegate persistence to the shared writeManagedSecrets
  instead of a private copy.
- Docs: drop the duplicate box.tenkiTimeoutMs row (kept under provider tuning)
  and fix the tenki-backlog link to point at the file.

* Address second review pass on the Tenki provider

- Wire create-time sizing: `--size` / `box.sizeTenki` (a `cpu-memory[-disk]` GB
  spec) now parses via parseTenkiSize and overrides the box's create resources
  (Tenki applies cpuCores/memoryMb/diskSizeGb at createAndWait), so the flag
  actually changes the box; invalid specs fall back to defaults with a log.
  Fix the box.sizeTenki description to match and add unit tests.
- Drop the stale `box.tenkiTimeoutMs` "Deferred" item from tenki-backlog.md
  (the key is fully implemented).

Not applied: recordBox('paused') after checkpoint — Tenki's createSnapshotAndWait
takes a live snapshot and leaves the source RUNNING (verified against a live
workspace), so marking the box paused would be incorrect.

* Prevent orphaned Tenki sessions on provision timeout

provision used createAndWait, which throws without surfacing the session id
on a readiness timeout — a VM that provisioned but never became ready would
leak (its id lost, no retry). Split create from wait: create({ waitReady:
false }) returns the id as soon as the session exists, then wait separately;
if the wait times out or the boot fails, terminate the box (we still hold the
id) before surfacing the error. No idempotency key / AbortController: the SDK
exposes neither on create, and provision already never retries.
@vercel

vercel Bot commented Jul 22, 2026

Copy link
Copy Markdown

@francoluxor is attempting to deploy a commit to the madarco's projects Team on Vercel.

A member of the Team first needs to authorize it.

@github-actions

Copy link
Copy Markdown

Thanks for your pull request. Before it can be merged, please read our Contributor License Agreement and sign it by posting the comment below. You only ever have to do this once.


I have read the CLA Document and I hereby sign the CLA


You can retrigger this bot by commenting recheck in this Pull Request. Posted by the CLA Assistant Lite bot.

@francoluxor
francoluxor marked this pull request as ready for review July 22, 2026 14:36
@francoluxor
francoluxor requested a review from madarco as a code owner July 22, 2026 14:36
@madarco

madarco commented Jul 22, 2026

Copy link
Copy Markdown
Owner

Thanks, but the official method to add a provider is through a plugin: https://agent-box.sh/docs/build-a-provider

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants