Skip to content

feat: add agent sandbox variable commands#7

Merged
hbrooks merged 4 commits into
mainfrom
feat/sandbox-variables
Jun 27, 2026
Merged

feat: add agent sandbox variable commands#7
hbrooks merged 4 commits into
mainfrom
feat/sandbox-variables

Conversation

@hbrooks

@hbrooks hbrooks commented Jun 27, 2026

Copy link
Copy Markdown
Member

What

Adds agent sandbox variable commands that drive the public /v1 sandbox environment variable endpoints (GET/PUT/DELETE /v1/sandboxes/variables) shipped on the backend.

agent sandbox variable list                  # GET  — names + timestamps
agent sandbox variable set KEY VALUE         # PUT  — single upsert
agent sandbox variable set --from-file .env  # PUT  — batch from a .env file
agent sandbox variable rm KEY                # DELETE

Why

These are customer-scoped variables an agent pulls into its sandbox when its config names them (sandbox.variables) — the way a config brings in the credentials/config a custom CLI needs. Until now they could only be managed from the dashboard; this exposes them to scripts and the CLI.

Notes

  • Values are write-only. The API accepts them but never returns them, so list (and the echo after a mutation) shows only NAME / CREATED / UPDATED. The set confirmation says (values hidden).
  • Name validation is left to the server (single source of truth — ^[A-Za-z_][A-Za-z0-9_]*$, 500-var cap). The CLI surfaces the server's detail message via the existing ApiError path.
  • --from-file parses a .env-style file (KEY=VALUE, # comments, optional export , quote stripping, split on first =).
  • New ApiClient methods + typed request/response mirrors of the backend models; .env parser unit-tested; README usage updated.

Test plan

  • bun run typecheck
  • bun run test — 62 passing (3 new API-client cases, 6 parseEnvFile cases) ✓
  • bun run build
  • Bun compile smoke + agent --version
  • agent sandbox variable --help renders the command tree

🤖 Generated with Claude Code

hbrooks and others added 4 commits June 27, 2026 10:17
Wire up the public /v1 sandbox environment variable endpoints added on the
backend (GET/PUT/DELETE /v1/sandboxes/variables):

  agent sandbox variable list        # GET — names + timestamps (values write-only)
  agent sandbox variable set K V     # PUT — single upsert
  agent sandbox variable set --from-file .env   # PUT — batch from a .env file
  agent sandbox variable rm K        # DELETE

These are customer-scoped variables an agent pulls into its sandbox when its
config names them. Values are write-only — the API never returns them, so list
output shows only names + timestamps. Name validation is left to the server
(one source of truth). Adds ApiClient methods, typed request/response mirrors,
a .env parser with tests, and README usage.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Change `sandbox variable set` to take variadic `KEY=VALUE` arguments
(`set A=1 B=2`) instead of a single space-separated name/value pair, and allow
combining inline pairs with `--from-file` (file first, inline overrides). Factor
the shared `KEY=VALUE` parsing into `parseAssignment`, reused by both the inline
args and the .env file parser.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
`--from-file` now picks the format by extension: a `.json` file is parsed as a
flat object of name → value, anything else stays .env-style KEY=VALUE. JSON
values must be strings — a nested object, array, or non-string value is rejected
rather than silently coerced.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
# Conflicts:
#	src/cli.tsx
#	src/lib/api.ts
#	test/api.test.ts
@hbrooks hbrooks merged commit 8fd446b into main Jun 27, 2026
1 check passed
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.

1 participant