@raytrace-cli/cli 0.2.0 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -9,8 +9,9 @@
9
9
  Your agent finished the task. Which files did it read? What commands did it run?
10
10
  Where did the tokens and money go?
11
11
 
12
- RayTrace turns Claude Code and Codex sessions into a dashboard you can explore
13
- on your own machine: prompts, answers, tool calls, cost, and captured context.
12
+ RayTrace turns Claude Code and Codex sessions into a dashboard you can explore:
13
+ prompts, answers, tool calls, cost, and captured context. Run your agent in a
14
+ RayTrace cloud sandbox, or record the sessions you run on your own machine.
14
15
 
15
16
  ![RayTrace tool-call timeline showing commands, reported results, cost, time, and token usage](https://raw.githubusercontent.com/Godcreatebugs/raytrace-cli/main/docs/images/tool-calls.jpg)
16
17
 
@@ -21,14 +22,6 @@ on your own machine: prompts, answers, tool calls, cost, and captured context.
21
22
  - **Understand the cost.** See model, token usage, time, and cost when available.
22
23
  - **Explore the context.** Review earlier conversation and files brought into the task.
23
24
 
24
- Session capture and the dashboard work locally. Claude Code recording needs no
25
- OpenRouter key; optional AI summaries and the Codex launcher do. See [Privacy](#privacy)
26
- for what those features send outside your machine.
27
-
28
- **New: [cloud sandboxes](#cloud-sandboxes-preview) (preview).** Run your agent
29
- in an isolated sandbox on RayTrace's servers instead of your laptop, and review
30
- every session with your team at [app.raytracer.si](https://app.raytracer.si).
31
-
32
25
  ## Quick start
33
26
 
34
27
  You need **Node.js 22.13 or newer** (`node --version`). macOS and Linux are
@@ -36,24 +29,40 @@ supported.
36
29
 
37
30
  ```sh
38
31
  npm install -g @raytrace-cli/cli
39
- raytrace setup
32
+ raytrace auth login # opens your browser: sign in, or create your account
33
+ cd your-project # any Git repository
34
+ raytrace sandbox create # uploads it to a new cloud sandbox and prints its id
35
+ raytrace connect <sandbox-id> # a terminal in the sandbox: run claude or codex there
40
36
  ```
41
37
 
42
- `setup` asks two things:
38
+ `auth login` prints a short code and opens the sign-in page. New here? Create
39
+ your account on that page, approve the code, and come back to the terminal.
40
+
41
+ Then open **[app.raytracer.si](https://app.raytracer.si)** to review the
42
+ session with your team: prompts, tool calls, and the commands that actually
43
+ ran. You can also create the sandbox there, by dropping a project folder on the
44
+ Sandboxes page. RayTrace asks you for no API key. See
45
+ [Cloud sandboxes](#cloud-sandboxes-preview) for what is uploaded and the limits.
46
+
47
+ ### Record locally instead
48
+
49
+ To keep sessions on your own machine, set up local recording. It is separate
50
+ from cloud sandboxes: neither needs the other.
51
+
52
+ ```sh
53
+ raytrace setup
54
+ ```
43
55
 
44
- 1. **Record Claude Code sessions?** It adds a small hook to
45
- `~/.claude/settings.json`. Your other settings and hooks are left as they
46
- are, and the previous file is kept as `settings.json.raytrace-backup`.
47
- 2. **An OpenRouter API key** (optional, Enter to skip). It turns on one-line
48
- step summaries and `raytrace codex`.
56
+ `setup` asks one thing: **Record Claude Code sessions?** It adds a small hook to
57
+ `~/.claude/settings.json`. Your other settings and hooks are left as they are,
58
+ and the previous file is kept as `settings.json.raytrace-backup`. No API key is
59
+ needed.
49
60
 
50
61
  Then it starts RayTrace and opens the dashboard at **http://127.0.0.1:8797**.
51
62
 
52
63
  Install globally (`-g`): the Claude Code hook runs the `raytrace` command, so it
53
64
  has to stay on your PATH.
54
65
 
55
- ### See your first trace
56
-
57
66
  Use Claude Code as you normally do. Try a small task such as:
58
67
 
59
68
  > List the files in this project and explain where the main entry point is.
@@ -62,9 +71,12 @@ After the agent answers, open **Prompts** in the dashboard. Select your prompt,
62
71
  then choose **Tool calls** to follow the work or **Context** to inspect what
63
72
  was brought into the task.
64
73
 
65
- For Codex, add an OpenRouter key during setup and start it through RayTrace:
74
+ For Codex on your machine, give setup an OpenRouter key and start it through
75
+ RayTrace. Optional AI summaries in the local dashboard use the same key; see
76
+ [Privacy](#privacy) for what they send outside your machine.
66
77
 
67
78
  ```sh
79
+ raytrace setup --openrouter-key <key>
68
80
  raytrace codex # pass Codex arguments after this command
69
81
  ```
70
82
 
@@ -108,22 +120,25 @@ a terminal you open from your machine. Run Claude Code or Codex inside it: what
108
120
  the agent asked, the tool calls it made, and the commands that actually ran are
109
121
  recorded for your organization.
110
122
 
111
- ```sh
112
- raytrace auth login # sign in once; a code opens in your browser
113
- cd your-project # any Git repository
114
- raytrace sandbox create # upload it to a new sandbox
115
- raytrace sandbox shell # a terminal in the sandbox: run claude or codex there
116
- ```
123
+ The [quick start](#quick-start) has the commands. If you skip `raytrace auth
124
+ login`, `raytrace sandbox create` and `raytrace connect` start the same sign-in
125
+ first. With one sandbox, `raytrace connect` works without the id.
117
126
 
118
- Then open **[app.raytracer.si](https://app.raytracer.si)** and sign in with the
119
- same account to see your organization's prompts, sandboxes and tool calls.
127
+ At **[app.raytracer.si](https://app.raytracer.si)**, sign in with the same
128
+ account to see your organization's prompts, sandboxes and tool calls. A sandbox
129
+ created there shows the command to open it, `raytrace connect <sandbox-id>`.
130
+ Sandboxes belong to the account that made them: `raytrace auth status` says
131
+ which one the CLI is using.
120
132
 
121
133
  - **What is uploaded:** the files Git would track in the repository (including
122
134
  new files it does not ignore), without `.git`, dependencies such as
123
135
  `node_modules`, build output, `.env*` files, private keys (`.pem`, `.key`,
124
136
  `.p12`, `.pfx`) and common credential files (`.npmrc`, `.netrc`, `id_rsa`, …).
125
- The upload is limited to 256 MiB. Review your project for secrets inside other
126
- files before you upload.
137
+ Review your project for secrets inside other files before you upload.
138
+ - **Limits:** a project may be up to 200 MiB and 20,000 files, each file up to
139
+ 25 MiB (100 MiB once packed). A project over a limit is refused, with the
140
+ files named, and nothing is uploaded; add them to `.gitignore`. You can have
141
+ three sandboxes at a time.
127
142
  - **Signing in to your agent:** sign in to Claude Code inside the sandbox as
128
143
  you would on your machine. That sign-in stays in the sandbox until you
129
144
  destroy it.
@@ -136,22 +151,29 @@ Cloud sandboxes are a preview and may change; please
136
151
 
137
152
  ## Commands
138
153
 
154
+ Cloud sandboxes:
155
+
139
156
  | Command | What it does |
140
157
  |---|---|
141
- | `raytrace setup` | one-time setup; run it again to change settings |
158
+ | `raytrace sandbox create` | upload this Git repository to a new cloud sandbox; `--name <name>` |
159
+ | `raytrace connect [id]` | open a terminal in a sandbox, signing in first if needed (also `raytrace sandbox shell [id]`) |
160
+ | `raytrace sandbox list` | your cloud sandboxes |
161
+ | `raytrace sandbox start\|stop [id]` | start or stop a sandbox; stopping keeps its files |
162
+ | `raytrace sandbox destroy [id]` | delete a sandbox; its recorded sessions are kept |
163
+ | `raytrace auth login` | sign in to RayTrace; `status`, `logout` |
164
+
165
+ Local recording:
166
+
167
+ | Command | What it does |
168
+ |---|---|
169
+ | `raytrace setup` | set up local recording; run it again to change settings |
142
170
  | `raytrace start` | start recording in the background |
143
171
  | `raytrace stop` | stop it |
144
172
  | `raytrace status` | is it running, and is Claude Code being recorded |
145
- | `raytrace open` | open the dashboard |
173
+ | `raytrace open` | open the local dashboard |
146
174
  | `raytrace doctor` | check the install without changing anything |
147
175
  | `raytrace codex [args]` | run Codex through RayTrace |
148
176
  | `raytrace uninstall` | remove the Claude Code hook; `--purge` also deletes recorded data |
149
- | `raytrace auth login` | sign in to RayTrace (needed for cloud sandboxes); `status`, `logout` |
150
- | `raytrace sandbox create` | upload this Git repository to a new cloud sandbox; `--name <name>` |
151
- | `raytrace sandbox list` | your cloud sandboxes |
152
- | `raytrace sandbox shell [id]` | open a terminal in a sandbox |
153
- | `raytrace sandbox start\|stop [id]` | start or stop a sandbox; stopping keeps its files |
154
- | `raytrace sandbox destroy [id]` | delete a sandbox; its recorded sessions are kept |
155
177
 
156
178
  ## Getting the most out of it
157
179
 
@@ -168,10 +190,12 @@ RayTrace at the same sessions and the records line up run for run.
168
190
 
169
191
  ## Privacy
170
192
 
193
+ Local recording stays on your machine.
194
+
171
195
  - Recorded sessions, settings and logs live in `~/.raytrace` (move it with the
172
196
  `RAYTRACE_HOME` environment variable). The dashboard and its API listen on
173
197
  `127.0.0.1` only.
174
- - API keys you give `setup` are stored in `~/.raytrace/config.env`, readable
198
+ - An API key you give `setup` (`--openrouter-key`) is stored in `~/.raytrace/config.env`, readable
175
199
  only by you. Keys and auth headers in recorded requests are replaced with
176
200
  `[REDACTED]` before they are saved.
177
201
  - With an OpenRouter key, summaries send short excerpts of each step (and of
package/bin/raytrace.mjs CHANGED
@@ -7,28 +7,35 @@ const HELP = `RayTrace: see what your coding agent did.
7
7
 
8
8
  Usage: raytrace <command>
9
9
 
10
- setup one-time setup: Claude Code hook, API keys, then start
10
+ Get started in the cloud (preview):
11
+ 1. raytrace auth login sign in, or create your account, in the browser
12
+ 2. raytrace sandbox create from a Git repository: upload it to a new sandbox
13
+ 3. raytrace connect <sandbox-id> a terminal in it; run claude or codex there
14
+
15
+ Cloud sandboxes:
16
+ raytrace auth login|status|logout your RayTrace sign-in
17
+ raytrace sandbox create [--name <name>] upload this Git repository to a new sandbox
18
+ (up to 200 MiB, 25 MiB a file, 20,000 files)
19
+ raytrace connect [id] a terminal in it; with one sandbox the id is
20
+ optional (same as: raytrace sandbox shell [id])
21
+ raytrace sandbox list
22
+ raytrace sandbox start|stop [id]
23
+ raytrace sandbox destroy [id] [--yes] delete it; recorded evidence is kept
24
+
25
+ Local recording (not needed for cloud sandboxes):
26
+ setup set up local recording: Claude Code hook, then start
11
27
  start start RayTrace in the background (dashboard + recorder)
12
28
  stop stop it
13
29
  status is it running, and what is being recorded
14
- open open the dashboard in your browser
30
+ open open the local dashboard in your browser
15
31
  doctor check the install without changing anything
16
32
  codex [...] run Codex through RayTrace (needs an OpenRouter key)
17
33
  uninstall remove the Claude Code hook, optionally all recorded data
18
- auth ... sign in to RayTrace: login, status, logout
19
- sandbox ... cloud sandboxes: create, list, shell, start, stop, destroy
20
34
 
21
35
  Options for setup: --yes --no-claude-code --no-start --openrouter-key <key>
22
36
  Options for uninstall: --yes --purge (also delete ~/.raytrace)
23
37
 
24
- Sandboxes (preview; sign in first with raytrace auth login):
25
- raytrace sandbox create [--name <name>] upload this Git repository to a new sandbox
26
- raytrace sandbox list
27
- raytrace sandbox shell [id] a terminal in it; run claude or codex there
28
- raytrace sandbox start|stop [id]
29
- raytrace sandbox destroy [id] [--yes] delete it; recorded evidence is kept
30
-
31
- Data and settings live in ~/.raytrace (override with RAYTRACE_HOME).`;
38
+ Local data and settings live in ~/.raytrace (override with RAYTRACE_HOME).`;
32
39
 
33
40
  // node:sqlite, which the recorder stores everything in, needs 22.13.
34
41
  const [major, minor] = process.versions.node.split('.').map(Number);
@@ -60,12 +67,20 @@ if (command === 'codex') { await commands.codex(rest); process.exit(); }
60
67
  if (command === 'auth') {
61
68
  const auth = await import('../src/auth.mjs');
62
69
  const sub = rest[0];
63
- const action = { login: auth.login, status: auth.status, logout: auth.logout }[sub];
70
+ const action = { login: auth.loginCommand, status: auth.status, logout: auth.logout }[sub];
64
71
  if (!action) { console.error(`Usage: raytrace auth login | status | logout`); process.exit(2); }
65
72
  try { await action(); process.exit(0); }
66
73
  catch (error) { console.error(`raytrace auth ${sub}: ${error.message}`); process.exit(1); }
67
74
  }
68
75
 
76
+ // `raytrace connect <id>`: the sandbox's terminal, by the id the dashboard shows.
77
+ if (command === 'connect') {
78
+ if (rest.length > 1 || rest[0]?.startsWith('-')) { console.error('Usage: raytrace connect [sandbox-id]'); process.exit(2); }
79
+ const sandbox = await import('../src/sandbox.mjs');
80
+ try { await sandbox.shell(rest[0]); process.exit(0); }
81
+ catch (error) { console.error(`raytrace connect: ${error.message}`); process.exit(1); }
82
+ }
83
+
69
84
  if (command === 'sandbox') {
70
85
  const sandbox = await import('../src/sandbox.mjs');
71
86
  let parsed;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@raytrace-cli/cli",
3
- "version": "0.2.0",
3
+ "version": "0.4.0",
4
4
  "description": "See what your coding agent did: traces, tool calls, cost and step-by-step evidence for Claude Code and Codex.",
5
5
  "license": "MIT",
6
6
  "type": "module",
package/src/auth.mjs CHANGED
@@ -113,7 +113,8 @@ export async function login() {
113
113
  let interval = (start.data.interval || 5) * 1000;
114
114
  const deadline = Date.now() + (start.data.expires_in || 300) * 1000;
115
115
  say(`Your sign-in code: ${user_code}`);
116
- say(`Opening ${verification_uri} to approve it (or open it yourself on any device).`);
116
+ say(`Opening ${verification_uri}: sign in, or create your account, and approve the code`);
117
+ say('(or open it yourself on any device).');
117
118
  openUrl(verification_uri_complete || verification_uri);
118
119
  say('Waiting for approval...');
119
120
  while (Date.now() < deadline) {
@@ -136,6 +137,15 @@ export async function login() {
136
137
  throw new Error('The code expired before it was approved. Run raytrace auth login again.');
137
138
  }
138
139
 
140
+ /** `raytrace auth login`: sign in, then say what comes next. */
141
+ export async function loginCommand() {
142
+ await login();
143
+ say('\nNext, from a Git repository: raytrace sandbox create');
144
+ }
145
+
146
+ /** The signed-in account's email, for messages that need to say whose workspace this is; null when signed out. */
147
+ export function account() { return load()?.user?.email || null; }
148
+
139
149
  export async function status() {
140
150
  const session = load();
141
151
  if (!session) { say('Not signed in. Run: raytrace auth login'); return; }
package/src/commands.mjs CHANGED
@@ -6,9 +6,10 @@ import { paths } from './paths.mjs';
6
6
  import { portOf, proxyEnv, readConfig, writeConfig } from './config.mjs';
7
7
  import { healthy, portInUse, runningPid, start, status, stop } from './proxy-process.mjs';
8
8
  import { HOOK_COMMAND, hookState, setHook } from './claude-code.mjs';
9
- import { askSecret, confirm, interactive } from './prompt.mjs';
9
+ import { confirm, interactive } from './prompt.mjs';
10
10
 
11
11
  const say = (line = '') => console.log(line);
12
+ const CLOUD_URL = 'https://app.raytracer.si';
12
13
 
13
14
  /** Whether `name` resolves on PATH: the Claude Code hook calls `raytrace` by name. */
14
15
  function onPath(name) {
@@ -44,20 +45,18 @@ export async function setup(flags) {
44
45
  else say(' Claude Code: not recorded');
45
46
  if (hooks.repoHook) say(' Note: the RayTrace repo\'s own Claude Code hook is also installed; sessions will be reported by both.');
46
47
 
47
- // OpenRouter powers step summaries and `raytrace codex`.
48
- // Without it the proxy runs native: traces still record, those features are off.
49
- let openrouter = flags['openrouter-key'] ?? config.OPENROUTER_API_KEY ?? '';
50
- if (!yes && flags['openrouter-key'] === undefined) {
51
- say('\n OpenRouter key: turns on step summaries and `raytrace codex`.');
52
- const entered = await askSecret(` Paste it${openrouter ? ' (Enter keeps the current one)' : ' (Enter to skip)'}: `);
53
- if (entered) openrouter = entered;
54
- }
48
+ // Setup never asks for an OpenRouter key: recording needs none. A key passed
49
+ // with --openrouter-key (or already saved) turns on local step summaries and
50
+ // `raytrace codex`; without one the proxy runs native and those are off.
51
+ const openrouter = flags['openrouter-key'] ?? config.OPENROUTER_API_KEY ?? '';
55
52
  writeConfig({
56
53
  ...config,
57
54
  RAYTACE_PROVIDER: openrouter ? 'openrouter' : 'native',
58
55
  OPENROUTER_API_KEY: openrouter,
59
56
  });
60
57
  say(`\n Settings saved (only you can read ${paths.config}).`);
58
+ say('\n Cloud sandboxes (preview): run your agent on RayTrace\'s servers, no API key to add.');
59
+ say(` raytrace auth login, then in a Git repository: raytrace sandbox create (or on the web: ${CLOUD_URL})`);
61
60
 
62
61
  if (hookClaude && !onPath('raytrace')) {
63
62
  say(`\n Warning: \`raytrace\` is not on your PATH, and Claude Code's hook runs \`${HOOK_COMMAND}\`.`);
@@ -142,7 +141,7 @@ export async function doctor() {
142
141
 
143
142
  export async function codex(args) {
144
143
  const config = readConfig();
145
- if (!config.OPENROUTER_API_KEY) { say('`raytrace codex` routes Codex through OpenRouter. Add a key with `raytrace setup` first.'); process.exitCode = 1; return; }
144
+ if (!config.OPENROUTER_API_KEY) { say('`raytrace codex` routes Codex through OpenRouter. Add a key first: raytrace setup --openrouter-key <key>'); process.exitCode = 1; return; }
146
145
  if (!(await healthy(portOf(config)))) await startCommand();
147
146
  const child = spawn(process.execPath, [paths.codex, ...args], { stdio: 'inherit', env: proxyEnv(config) });
148
147
  await new Promise((done) => child.on('exit', (code, signal) => { process.exitCode = code ?? (signal ? 1 : 0); done(); }));
package/src/sandbox.mjs CHANGED
@@ -11,12 +11,18 @@ import { lstatSync } from 'node:fs';
11
11
  import { request as httpRequest } from 'node:http';
12
12
  import { request as httpsRequest } from 'node:https';
13
13
  import { basename, join } from 'node:path';
14
- import { accessToken } from './auth.mjs';
14
+ import { accessToken, account, login } from './auth.mjs';
15
15
  import { readConfig } from './config.mjs';
16
16
  import { ask, interactive } from './prompt.mjs';
17
17
 
18
18
  const say = (line = '') => console.log(line);
19
- const MAX_BYTES = 256 * 1024 * 1024;
19
+ // What one project upload may be. RayTrace's API holds the dashboard's folder
20
+ // upload to the same numbers and checks them again; saying so here saves the upload.
21
+ const MIB = 1024 * 1024;
22
+ const MAX_FILE = 25 * MIB; // any one file
23
+ const MAX_BYTES = 200 * MIB; // all files, before compression
24
+ const MAX_FILES = 20_000;
25
+ const MAX_ARCHIVE = 100 * MIB; // the packed upload
20
26
  const ID = /^rtp-[a-f0-9]{32}$/;
21
27
  const API = 'https://api.raytracer.si';
22
28
  const unreachable = (url) => new Error(`Cannot reach RayTrace at ${url.origin}. Check your connection; `
@@ -39,8 +45,15 @@ export function packable(path) {
39
45
  async function api() {
40
46
  const config = readConfig();
41
47
  const url = process.env.RAYTRACE_API_URL || config.RAYTRACE_API_URL || API;
42
- const key = process.env.RAYTRACE_API_KEY || config.RAYTRACE_API_KEY || await accessToken();
43
- if (!key) throw new Error('Not signed in. Run: raytrace auth login');
48
+ let key = process.env.RAYTRACE_API_KEY || config.RAYTRACE_API_KEY || await accessToken();
49
+ if (!key) {
50
+ if (!interactive()) throw new Error('Not signed in. Run: raytrace auth login');
51
+ say('You are not signed in to RayTrace yet.');
52
+ await login();
53
+ key = await accessToken();
54
+ if (!key) throw new Error('Not signed in. Run: raytrace auth login');
55
+ say();
56
+ }
44
57
  return { url: new URL(url), key };
45
58
  }
46
59
 
@@ -61,15 +74,22 @@ async function call(method, path, { body, headers = {} } = {}) {
61
74
  function projectFiles(root) {
62
75
  const listed = spawnSync('git', ['-C', root, 'ls-files', '-z', '--cached', '--others', '--exclude-standard'], { maxBuffer: 256 * 1024 * 1024 });
63
76
  if (listed.status !== 0) throw new Error(`${root} is not a Git repository. Run this from inside one.`);
64
- const files = []; const skipped = []; let total = 0;
77
+ const files = []; const skipped = []; const large = []; let total = 0;
65
78
  for (const name of [...new Set(listed.stdout.toString().split('\0').filter(Boolean))].sort()) {
66
79
  let stat;
67
80
  try { stat = lstatSync(join(root, name)); } catch { continue; } // deleted, still in the index
68
81
  if (!packable(name) || !stat.isFile()) { skipped.push(name); continue; } // symlinks too
82
+ if (stat.size > MAX_FILE) { large.push(`${name} (${Math.round(stat.size / MIB)} MiB)`); continue; }
69
83
  total += stat.size;
70
- if (total > MAX_BYTES) throw new Error('The project is over 256 MiB; add large generated files to .gitignore first.');
71
84
  files.push(name);
72
85
  }
86
+ // Refused, never trimmed: a project missing its large files would not be the project.
87
+ if (large.length) {
88
+ throw new Error(`${large.length === 1 ? 'This file is' : 'These files are'} over ${MAX_FILE / MIB} MiB, the most one file may be:\n `
89
+ + `${large.slice(0, 10).join('\n ')}${large.length > 10 ? `\n ... and ${large.length - 10} more` : ''}\nAdd ${large.length === 1 ? 'it' : 'them'} to .gitignore (or remove ${large.length === 1 ? 'it' : 'them'}), then try again.`);
90
+ }
91
+ if (files.length > MAX_FILES) throw new Error(`The project has ${files.length.toLocaleString()} files; the most is ${MAX_FILES.toLocaleString()}. Add generated files to .gitignore first.`);
92
+ if (total > MAX_BYTES) throw new Error(`The project is ${Math.round(total / MIB)} MiB; the most is ${MAX_BYTES / MIB} MiB. Add large generated files to .gitignore first.`);
73
93
  return { files, skipped, total };
74
94
  }
75
95
 
@@ -96,7 +116,8 @@ async function pickId(id) {
96
116
  }
97
117
  const live = (await call('GET', '/v1/sandboxes')).filter((box) => box.status !== 'deleted');
98
118
  if (live.length === 1) return live[0].id;
99
- throw new Error(live.length ? 'More than one sandbox; name one (raytrace sandbox list).' : 'No sandboxes yet: raytrace sandbox create');
119
+ throw new Error(live.length ? 'More than one sandbox; name one (raytrace sandbox list).'
120
+ : `No sandboxes${account() ? ` in ${account()}'s workspace` : ''} yet: raytrace sandbox create`);
100
121
  }
101
122
 
102
123
  export async function create(flags) {
@@ -109,6 +130,7 @@ export async function create(flags) {
109
130
  say(`Packing ${files.length} files (${(total / 1048576).toFixed(1)} MiB) from ${root}`);
110
131
  if (skipped.length) say(`Not uploaded (${skipped.length}): ${skipped.slice(0, 8).join(', ')}${skipped.length > 8 ? ', ...' : ''}`);
111
132
  const archive = await pack(root, files);
133
+ if (archive.length > MAX_ARCHIVE) throw new Error(`The packed project is ${Math.round(archive.length / MIB)} MiB; the most is ${MAX_ARCHIVE / MIB} MiB.`);
112
134
  say('Creating the sandbox (the first one on a host takes a little longer)...');
113
135
  const box = await call('POST', '/v1/sandboxes', {
114
136
  body: archive, headers: { 'content-type': 'application/gzip', 'x-raytrace-name': name.replace(/[^A-Za-z0-9._ -]/g, '-').slice(0, 100) },
@@ -116,7 +138,7 @@ export async function create(flags) {
116
138
  say(`\nSandbox ${box.id} is running.`);
117
139
  say(box.transcripts ? 'Claude Code sessions in it are recorded.'
118
140
  : `Claude Code transcripts are off: ${box.transcripts_off}. Commands are still recorded.`);
119
- say(`Open it: raytrace sandbox shell ${box.id}`);
141
+ say(`Open it: raytrace connect ${box.id}`);
120
142
  }
121
143
 
122
144
  export async function list() {
@@ -144,10 +166,11 @@ export async function destroy(id, flags) {
144
166
  say(`${id} destroyed.`);
145
167
  }
146
168
 
147
- /** An interactive terminal in the sandbox, carried over one upgraded HTTP request. */
169
+ /** An interactive terminal in the sandbox, carried over one upgraded HTTP request.
170
+ * `raytrace connect <id>` and `raytrace sandbox shell [id]` are the same thing. */
148
171
  export async function shell(id) {
172
+ if (!interactive()) throw new Error('Connecting to a sandbox needs a terminal.');
149
173
  id = await pickId(id);
150
- if (!interactive()) throw new Error('raytrace sandbox shell needs a terminal.');
151
174
  const { url, key } = await api();
152
175
  const { stdin, stdout } = process;
153
176
  const path = `/v1/sandboxes/${id}/shell?rows=${stdout.rows || 24}&cols=${stdout.columns || 80}`;
@@ -158,7 +181,14 @@ export async function shell(id) {
158
181
  req.on('response', (response) => {
159
182
  let text = '';
160
183
  response.on('data', (chunk) => { text += chunk; });
161
- response.on('end', () => { try { reject(new Error(JSON.parse(text).error)); } catch { reject(new Error(`HTTP ${response.statusCode}`)); } });
184
+ response.on('end', () => {
185
+ // The API does not say whether another account has this sandbox; the likely mix-up is worth naming.
186
+ if (response.statusCode === 404 && account()) {
187
+ return reject(new Error(`No sandbox ${id} in ${account()}'s workspace. If it was made under another account `
188
+ + '(for example in the dashboard), sign in as that one: raytrace auth login'));
189
+ }
190
+ try { reject(new Error(JSON.parse(text).error)); } catch { reject(new Error(`HTTP ${response.statusCode}`)); }
191
+ });
162
192
  });
163
193
  req.on('upgrade', (_response, socket, head) => {
164
194
  say(`Connected to ${id}. Run \`claude\` (or codex) here; exit to leave. The sandbox keeps running.\n`);
@@ -174,5 +204,5 @@ export async function shell(id) {
174
204
  req.on('error', () => reject(unreachable(url)));
175
205
  req.end();
176
206
  });
177
- say(`\nLeft ${id}. It is still running: raytrace sandbox stop ${id}`);
207
+ say(`\nLeft ${id}. It is still running. Back in: raytrace connect ${id} Stop it: raytrace sandbox stop ${id}`);
178
208
  }