-
Notifications
You must be signed in to change notification settings - Fork 25
Expand file tree
/
Copy pathagentbox.yaml
More file actions
221 lines (216 loc) · 9.85 KB
/
Copy pathagentbox.yaml
File metadata and controls
221 lines (216 loc) · 9.85 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
# yaml-language-server: $schema=https://agent-box.sh/schema/agentbox.schema.json
#
# AgentBox monorepo (this very project) — TypeScript + pnpm + turbo.
#
# This package is a CLI (`agentbox`) plus a handful of supporting libraries.
# There is no web app, no database, no port to expose. The in-box workflow
# is: edit code → `pnpm test` / `pnpm typecheck` / `pnpm build` →
# `node apps/cli/dist/index.js …` (per CLAUDE.md). So this file only
# declares two tasks — install deps and produce a populated `dist/` — and
# no services.
#
# Notes / quirks encountered while generating this file:
# - pnpm monorepo (`pnpm-workspace.yaml`, `pnpm@9.15.0` pinned via
# `packageManager`). `corepack enable` is needed for that pin.
# - The host's `node_modules` is never copied in (macOS-native binaries),
# so the first install in a fresh box is real. Subsequent restarts hit
# the `.agentbox-installed` marker fast-path.
# - A `pnpm dev` service was tried first (turbo's parallel `tsup --watch`
# per package) and abandoned: the CLI bundles `@agentbox/*` libs via
# `noExternal` and the 10 parallel watchers all `clean: true` their
# `dist/`, so the CLI's first build races and tsup exits on failure.
# Plus, the watcher isn't actually needed — verification runs
# `pnpm build` explicitly. If you ever need it back, run
# `pnpm exec turbo run dev --concurrency=12` by hand (default
# concurrency is 10 but there are 10 dev tasks, so turbo refuses to
# start without the bump).
# Dogfood: ship the host user's agent OAuth tokens into the dev box so the
# in-box claude / codex / opencode are authenticated against the same
# account as the host — no in-box re-login needed when developing AgentBox.
#
# All entries `optional: true` — first-time users without a given agent
# (e.g. only Claude installed) get a working box; the missing entries
# show as `optional` in the carry prompt and are skipped silently.
#
# Source-path choices:
# - Claude: ~/.agentbox/claude-credentials.json is the host backup
# extracted from the box's claude-config volume via
# `syncClaudeCredentials` (handles the macOS-keychain case
# where ~/.claude/.credentials.json doesn't exist on disk).
# Dest is the file path in-box claude actually reads.
# - Codex: ~/.codex/auth.json — same path host + box.
# - OpenCode: ~/.local/share/opencode/auth.json — same path host + box.
# OpenCode may keep auth in the macOS keychain instead; the
# entry is `optional` so a missing file is a no-op.
#
# On Docker this overlaps with the shared agent-config volumes (which
# rsync ~/.claude etc. on every create) — harmless overwrite of identical
# bytes, but makes the credential flow visible + declarative. On Hetzner
# carry: actively helps: the existing scp-at-create-time is marker-gated
# and won't re-copy a rotated token, while carry: refreshes on every
# create.
#
# Cloud-provider creds (~/.agentbox/secrets.env): carry the host's
# DAYTONA_* / HCLOUD_* tokens into the box so the in-box agentbox can
# provision daytona / hetzner boxes when dogfooding cloud paths. The
# provider env-loaders read this exact path. `optional` so docker-only
# users without the file still get a working box.
#
# Vercel CLI-login store: in CLI-login mode (`agentbox vercel login` →
# "Sign in with Vercel"), the OAuth access token is NOT in secrets.env —
# secrets.env only carries the `VERCEL_AUTH_SOURCE=cli` marker + team/project,
# and the live token is read from the Vercel CLI's own store. Carry that store
# too, or the in-box agentbox can't use `--provider vercel`. Two src candidates
# cover a macOS host (`~/Library/Application Support/...`) and a Linux host
# (`~/.local/share/...`); both write the box's Linux path and the absent one is
# skipped (optional). The box has no `sbx`, so it reads the token but never
# refreshes it (a refresh there would rotate the host's token) — the token is
# short-lived (~8h); re-create the box after a host re-login once it expires.
# Harmless on the PAT/OIDC modes (these files simply won't exist).
carry:
- src: ~/.agentbox/secrets.env
dest: ~/.agentbox/secrets.env
mode: 0o600
optional: true
- src: ~/Library/Application Support/com.vercel.cli/auth.json
dest: ~/.local/share/com.vercel.cli/auth.json
mode: 0o600
optional: true
- src: ~/Library/Application Support/com.vercel.cli/config.json
dest: ~/.local/share/com.vercel.cli/config.json
mode: 0o600
optional: true
- src: ~/.local/share/com.vercel.cli/auth.json
dest: ~/.local/share/com.vercel.cli/auth.json
mode: 0o600
optional: true
- src: ~/.local/share/com.vercel.cli/config.json
dest: ~/.local/share/com.vercel.cli/config.json
mode: 0o600
optional: true
- src: ~/.agentbox/claude-credentials.json
dest: ~/.agentbox/claude-credentials.json
mode: 0o600
optional: true
- src: ~/.codex/auth.json
dest: ~/.codex/auth.json
mode: 0o600
optional: true
- src: ~/.local/share/opencode/auth.json
dest: ~/.local/share/opencode/auth.json
mode: 0o600
optional: true
# The codex / opencode counterparts of ~/.agentbox/claude-credentials.json:
# newest-wins backups maintained by the relay's credential fan-out. A nested
# box's `stageCodexCredentialsForUpload` / `stageOpencodeCredentialsForUpload`
# PREFER these over the real paths above, so without them the nested box
# bootstraps from whatever token the real path happens to hold — possibly
# older than the fan-out's copy. Optional: absent before the first fan-out.
- src: ~/.agentbox/codex-credentials.json
dest: ~/.agentbox/codex-credentials.json
mode: 0o600
optional: true
- src: ~/.agentbox/opencode-credentials.json
dest: ~/.agentbox/opencode-credentials.json
mode: 0o600
optional: true
# Notion CLI (`ntn`) file-based auth — INTERNAL AGENTBOX DEV ONLY, so a box
# that creates NESTED boxes can act as their relay host and shell out to `ntn`.
# Normal boxes never need this: they reach `ntn` through the host relay and
# carry no token. macOS `ntn` keeps its token in the keychain (uncarryable);
# the box is Linux, so for the nested path bootstrap the host once with
# `NOTION_KEYRING=0 ntn login` (writes ~/.config/notion/auth.json) and see
# docs/development.md for how the in-box `ntn` reads it (the connector no
# longer forces NOTION_KEYRING=0). All optional: a host without the file-auth
# still gets a working box (top-level boxes test through the host's own `ntn`).
- src: ~/.config/notion/auth.json
dest: ~/.config/notion/auth.json
mode: 0o600
optional: true
- src: ~/.config/notion/config.json
dest: ~/.config/notion/config.json
mode: 0o600
optional: true
- src: ~/.config/notion/workspaces.json
dest: ~/.config/notion/workspaces.json
mode: 0o600
optional: true
# Linear CLI (`@schpet/linear-cli`, the `linear` binary) auth, so a box that
# creates NESTED boxes can act as their relay host and shell out to `linear`
# for the integration's e2e test. The CLI stores a plaintext API token at
# ~/.config/linear/credentials.toml by default (keyring migration is opt-in
# and not used here), so the file carries directly — no keyring env toggle
# needed (unlike `ntn`). All optional: a host without the file still gets a
# working box (top-level boxes test through the host's own authed `linear`).
- src: ~/.config/linear/credentials.toml
dest: ~/.config/linear/credentials.toml
mode: 0o600
optional: true
- src: ~/.config/linear/linear.toml
dest: ~/.config/linear/linear.toml
mode: 0o600
optional: true
# Per-provider base-snapshot pointers. With these, `agentbox prepare`
# inside the box can skip-fast (existing snapshot detected) and just
# exercise the post-prepare config write + migration — no bake needed.
- src: ~/.agentbox/hetzner-prepared.json
dest: ~/.agentbox/hetzner-prepared.json
mode: 0o600
optional: true
- src: ~/.agentbox/vercel-prepared.json
dest: ~/.agentbox/vercel-prepared.json
mode: 0o600
optional: true
- src: ~/.agentbox/daytona-prepared.json
dest: ~/.agentbox/daytona-prepared.json
mode: 0o600
optional: true
- src: ~/.agentbox/docker-prepared.json
dest: ~/.agentbox/docker-prepared.json
mode: 0o600
optional: true
- src: ~/.agentbox/e2b-prepared.json
dest: ~/.agentbox/e2b-prepared.json
mode: 0o600
optional: true
tasks:
# Idempotent dep install. Re-runs on every supervisor restart, so guard
# the slow path with a marker inside node_modules (kept across
# pause/stop/start, captured by `agentbox-ctl checkpoint`).
install:
command: |
set -e
MARKER=node_modules/.agentbox-installed
if [ -f "$MARKER" ]; then
echo "deps already installed (marker present) — skipping"
exit 0
fi
corepack enable >/dev/null 2>&1 || true
pnpm install --frozen-lockfile || pnpm install
touch "$MARKER"
# One-shot build so every package has a populated `dist/` for the
# `node apps/cli/dist/index.js …` verification path documented in
# CLAUDE.md. Idempotent: turbo skips unchanged inputs on rerun.
build:
command: pnpm build
needs: [install]
# Drop a tiny `agentbox` wrapper into ~/.local/bin (already in PATH via
# Ubuntu's default .profile, no sudo needed) so `agentbox …` works in
# any shell, not just `node apps/cli/dist/index.js …`. Idempotent:
# heredoc rewrites the wrapper on every run so a `pnpm build` rebuild
# is picked up immediately (the wrapper itself just execs node against
# the dist path).
link:
command: |
set -e
mkdir -p ~/.local/bin
cat > ~/.local/bin/agentbox <<'WRAPPER'
#!/bin/sh
exec node /workspace/apps/cli/dist/index.js "$@"
WRAPPER
chmod +x ~/.local/bin/agentbox
~/.local/bin/agentbox --version
needs: [build]
portless:
command: portless proxy start --no-tls -p 1355
needs: [install]