@raytrace-cli/cli 0.7.0 → 0.9.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
@@ -4,6 +4,7 @@
4
4
 
5
5
  [ npm package ](https://www.npmjs.com/package/@raytrace-cli/cli) ·
6
6
  [ Quick start ](#quick-start) · [ Cloud sandboxes ](#cloud-sandboxes-preview) ·
7
+ [ Editor (MCP) ](#use-from-your-editor-mcp) ·
7
8
  [ Local sandboxes ](#local-sandboxes) ·
8
9
  [ Privacy ](#privacy) · [ Report an issue ](https://github.com/Godcreatebugs/raytrace-cli/issues)
9
10
 
@@ -82,6 +83,74 @@ which one the CLI is using.
82
83
  Cloud sandboxes are a preview and may change; please
83
84
  [report issues](https://github.com/Godcreatebugs/raytrace-cli/issues) you run into.
84
85
 
86
+ ## Use from your editor (MCP)
87
+
88
+ `raytrace mcp` is an [MCP](https://modelcontextprotocol.io) server, so the agent
89
+ in VS Code, Cursor, Claude Code or any MCP client can create and manage
90
+ sandboxes for you, in the cloud or on your machine: "put this project in a
91
+ sandbox", "connect this repo to a local sandbox", "stop my sandbox". Nothing to
92
+ install first; `npx` fetches the CLI.
93
+
94
+ - **Claude Code:** `claude mcp add raytrace -- npx -y @raytrace-cli/cli mcp`
95
+ - **VS Code** (`.vscode/mcp.json`):
96
+ ```json
97
+ { "servers": { "raytrace": { "command": "npx", "args": ["-y", "@raytrace-cli/cli", "mcp"] } } }
98
+ ```
99
+ - **Cursor** (`~/.cursor/mcp.json`) and most other clients:
100
+ ```json
101
+ { "mcpServers": { "raytrace": { "command": "npx", "args": ["-y", "@raytrace-cli/cli", "mcp"] } } }
102
+ ```
103
+
104
+ Tools: `login`, `create_sandbox`, `list_sandboxes`, `sandbox_status`,
105
+ `start_sandbox`, `stop_sandbox`, `destroy_sandbox`, `run_command`,
106
+ `get_command_result`, `cancel_command`. The first time, the agent
107
+ calls `login` and shows you a code to approve in the browser; it is the same
108
+ sign-in as `raytrace auth login`. `create_sandbox` uploads the Git project open
109
+ in your editor, with the same rules and limits as `raytrace sandbox create`.
110
+ `destroy_sandbox` deletes the sandbox's traces too unless the agent passes
111
+ `keep_traces` (paid plans), as `raytrace sandbox destroy --yes` does.
112
+
113
+ **Working in the sandbox with Claude Code.** After `create_sandbox`, a new
114
+ terminal opens connected to the sandbox with Claude Code starting in it, and the
115
+ session you have there is recorded (`connect: false` skips this).
116
+ `connect_sandbox` does the same for a sandbox you already have: "open my sandbox
117
+ with Claude". The terminal opens where your agent runs when it can: a new tmux
118
+ window inside tmux, a new iTerm window or WezTerm tab; otherwise a new Terminal
119
+ window on macOS (also from VS Code, whose built-in terminal cannot be opened from
120
+ outside), the desktop's terminal on Linux, or Windows Terminal. macOS asks once
121
+ whether your terminal may be controlled. If no terminal can be opened, the agent
122
+ gives you the command: `raytrace connect <id or name> --claude`. Claude Code runs
123
+ there with `--dangerously-skip-permissions`: it does not stop to ask before each
124
+ command, because the sandbox is what contains it, and everything it does is
125
+ recorded. Files the project's owner restricted stay locked. The first time in
126
+ each sandbox, Claude Code asks you to sign in and to accept that mode.
127
+
128
+ **Running commands from the chat.** `run_command` starts a shell command in the
129
+ sandbox's `/workspace` (up to 4 at a time, 120 s by default, at most 1,800 s) and
130
+ returns at once with a command id. `get_command_result` gives its state, the real
131
+ exit code (*unknown* is never reported as success) and the last 20,000 characters
132
+ of stdout and stderr; `wait_seconds` (up to 30) waits for a running command, so
133
+ the agent does not have to poll. `cancel_command` stops it and everything it
134
+ started. What a command prints comes from your project, so the agent is told to
135
+ treat it as data, not as instructions. This needs a RayTrace server with the
136
+ command API; on one without it the tools say so, and you can still run
137
+ `raytrace connect <id>` yourself in a terminal (it needs a real terminal, which
138
+ an agent's own shell does not have). Running commands works on cloud sandboxes
139
+ only.
140
+
141
+ **Local sandboxes from the chat.** Ask for a local sandbox and the agent calls
142
+ `create_sandbox` with `local: true`: the same as `raytrace sandbox create --local`
143
+ in the project, so nothing is uploaded and no RayTrace sign-in is needed. If Lima
144
+ is not installed, the agent asks you before downloading it (`install_lima`). The
145
+ first local sandbox sets up the Linux VM, which takes several minutes: the agent
146
+ gets an answer after about a minute and follows the rest with `sandbox_status`,
147
+ and the setup carries on even if the chat ends. `list_sandboxes` shows local and
148
+ cloud sandboxes together; `start_sandbox`, `stop_sandbox`, `sandbox_status` and
149
+ `destroy_sandbox` and `connect_sandbox` take a local sandbox's name. Destroying one archives its
150
+ captured logs to `~/.raytrace/archive` unless the agent passes `delete_logs`
151
+ (`upload_first` uploads its evidences to the cloud before). To work in it, run
152
+ `raytrace connect <name> --claude` in a terminal, or ask for `connect_sandbox`.
153
+
85
154
  ## Local sandboxes
86
155
 
87
156
  Prefer to keep your project on your own machine? Run the same sandbox locally.
@@ -180,11 +249,12 @@ raytrace key # which keys are set
180
249
  | Command | What it does |
181
250
  |---|---|
182
251
  | `raytrace sandbox create` | upload this Git repository to a new cloud sandbox; `--name <name>` |
183
- | `raytrace connect [id]` | open a terminal in a sandbox, signing in first if needed (also `raytrace sandbox shell [id]`) |
252
+ | `raytrace connect [id] [--claude]` | open a terminal in a sandbox, signing in first if needed (also `raytrace sandbox shell [id]`); `--claude` starts Claude Code in it |
184
253
  | `raytrace sandbox list` | your cloud sandboxes |
185
254
  | `raytrace sandbox start\|stop [id]` | start or stop a sandbox; stopping keeps its files |
186
255
  | `raytrace sandbox destroy [id]` | delete a sandbox; its recorded sessions are kept |
187
256
  | `raytrace auth login` | sign in to RayTrace; `status`, `logout` |
257
+ | `raytrace mcp` | MCP server on stdio for your editor's agent; see [Use from your editor](#use-from-your-editor-mcp) |
188
258
  | `raytrace --code <code>` | beta invite: redeem a code RayTrace gave you (signed in first) for one $10-credit sandbox; codes are single-use, are deleted on redemption, and expire after 3 days, as does the credit |
189
259
  | `raytrace sandbox create --local [--name <name>]` | the same sandbox in a Linux VM on this machine; offers to download Lima if needed (`--yes` skips the question) |
190
260
  | `raytrace sandbox list --local` | your local sandboxes; their names work with `connect`, `start`, `stop` and `destroy` |
package/bin/raytrace.mjs CHANGED
@@ -16,8 +16,9 @@ Cloud sandboxes:
16
16
  raytrace auth login|status|logout your RayTrace sign-in
17
17
  raytrace sandbox create [--name <name>] upload this Git repository to a new sandbox
18
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])
19
+ raytrace connect [id] [--claude] a terminal in it; with one sandbox the id is
20
+ optional (same as: raytrace sandbox shell [id]);
21
+ --claude starts Claude Code in it at once
21
22
  raytrace --code <code> beta invite: redeem a code RayTrace gave you for one
22
23
  $10-credit sandbox (signed in first; also: raytrace code <code>)
23
24
  raytrace sandbox list
@@ -25,6 +26,11 @@ Cloud sandboxes:
25
26
  raytrace sandbox destroy [id] [--yes] [--keep-traces]
26
27
  delete it; traces go too unless --keep-traces (paid plans)
27
28
 
29
+ Use from your editor's agent (VS Code, Cursor, Claude Code, any MCP client):
30
+ raytrace mcp MCP server on stdio: sign in, create, list, start,
31
+ stop and destroy cloud sandboxes. Add it to your
32
+ editor as the command: npx -y @raytrace-cli/cli mcp
33
+
28
34
  Local sandboxes (your project stays on this machine):
29
35
  raytrace sandbox create --local [--name <name>] [--yes]
30
36
  a copy of this Git repository in a gVisor sandbox
@@ -51,6 +57,11 @@ Export recorded traces:
51
57
  raytrace export <trace-id> --output <file>
52
58
  save export to file with owner-only permissions
53
59
 
60
+ Share recorded traces (time-limited cloud link):
61
+ raytrace share <trace-id> [--fork] create a share link for peers
62
+ raytrace share --list list your active share links
63
+ raytrace share --revoke <share-id> revoke an active share link
64
+
54
65
  AI features in the dashboard (summaries, recaps, Chain of thought), on your own key:
55
66
  raytrace key which keys are set
56
67
  raytrace key openrouter add your OpenRouter key (asked for, not echoed)
@@ -79,6 +90,14 @@ if (command === '--version' || command === '-v') {
79
90
  console.log(JSON.parse(readFileSync(new URL('../package.json', import.meta.url), 'utf8')).version);
80
91
  process.exit(0);
81
92
  }
93
+ // `raytrace mcp`: stdout belongs to the MCP protocol, so nothing else may run first.
94
+ if (command === 'mcp') {
95
+ if (rest.length) { console.error('Usage: raytrace mcp'); process.exit(2); }
96
+ const { serve } = await import('../src/mcp.mjs');
97
+ await serve();
98
+ process.exit(0);
99
+ }
100
+
82
101
  if (!command || command === 'help' || command === '--help' || command === '-h') { console.log(HELP); process.exit(0); }
83
102
 
84
103
  // `raytrace --code <code>` (also `raytrace code <code>`): redeem a beta code.
@@ -107,9 +126,9 @@ if (command === 'auth') {
107
126
 
108
127
  // `raytrace connect <id>`: the sandbox's terminal, by the id the dashboard shows.
109
128
  if (command === 'connect') {
110
- const flags = { local: rest.includes('--local') };
111
- const args = rest.filter((arg) => arg !== '--local');
112
- if (args.length > 1 || args[0]?.startsWith('-')) { console.error('Usage: raytrace connect [sandbox-id or local name] [--local]'); process.exit(2); }
129
+ const flags = { local: rest.includes('--local'), claude: rest.includes('--claude') };
130
+ const args = rest.filter((arg) => arg !== '--local' && arg !== '--claude');
131
+ if (args.length > 1 || args[0]?.startsWith('-')) { console.error('Usage: raytrace connect [sandbox-id or local name] [--local] [--claude]'); process.exit(2); }
113
132
  const sandbox = await import('../src/sandbox.mjs');
114
133
  try { await sandbox.shell(args[0], flags); process.exit(0); }
115
134
  catch (error) { console.error(`raytrace connect: ${error.message}`); process.exit(1); }
@@ -204,6 +223,47 @@ if (command === 'export') {
204
223
  }
205
224
  }
206
225
 
226
+ if (command === 'share') {
227
+ let parsed;
228
+ try {
229
+ parsed = parseArgs({ args: rest, strict: true, allowPositionals: true, options: {
230
+ list: { type: 'boolean', short: 'l' },
231
+ revoke: { type: 'string' },
232
+ sandbox: { type: 'string' },
233
+ fork: { type: 'boolean' },
234
+ } });
235
+ } catch (error) {
236
+ console.error(`${error.message}\n\nUsage: raytrace share <trace-id> [--sandbox <id>] [--fork] | raytrace share --list | raytrace share --revoke <id>`);
237
+ process.exit(2);
238
+ }
239
+ const [sub, ...extra] = parsed.positionals;
240
+ const share = await import('../src/share.mjs');
241
+ try {
242
+ if (parsed.values.list || sub === 'list') {
243
+ await share.listShares();
244
+ process.exit(0);
245
+ }
246
+ if (parsed.values.revoke || sub === 'revoke') {
247
+ const shareId = parsed.values.revoke || extra[0];
248
+ if (!shareId) {
249
+ console.error('Usage: raytrace share --revoke <id> (or raytrace share revoke <id>)');
250
+ process.exit(2);
251
+ }
252
+ await share.revokeShare(shareId);
253
+ process.exit(0);
254
+ }
255
+ if (!sub || extra.length > 0) {
256
+ console.error('Usage: raytrace share <trace-id> [--sandbox <id>] [--fork] | raytrace share --list | raytrace share --revoke <id>');
257
+ process.exit(2);
258
+ }
259
+ await share.sharePrompt(sub, { sandboxId: parsed.values.sandbox, allowFork: parsed.values.fork });
260
+ process.exit(0);
261
+ } catch (error) {
262
+ console.error(`raytrace share: ${error.message}`);
263
+ process.exit(1);
264
+ }
265
+ }
266
+
207
267
  let flags;
208
268
  try {
209
269
  ({ values: flags } = parseArgs({ args: rest, strict: true, options: {