@raytrace-cli/cli 0.5.0 → 0.7.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.
Files changed (59) hide show
  1. package/README.md +54 -2
  2. package/bin/raytrace.mjs +81 -2
  3. package/dist/dashboard/assets/{index-jyV5iYHJ.js → index-Dc3LTk8b.js} +4 -4
  4. package/dist/dashboard/index.html +1 -1
  5. package/package.json +2 -1
  6. package/proxy/agent-intent-schema.test.mjs +142 -0
  7. package/proxy/call-assessment.test.mjs +167 -0
  8. package/proxy/capture.mjs +11 -4
  9. package/proxy/capture.test.mjs +49 -0
  10. package/proxy/claude-code-adapter.mjs +19 -0
  11. package/proxy/claude-code-hook.mjs +3 -1
  12. package/proxy/codex-config.mjs +5 -0
  13. package/proxy/codex.mjs +3 -2
  14. package/proxy/evidence-schema.test.mjs +233 -0
  15. package/proxy/evidence-store.mjs +91 -22
  16. package/proxy/evidence-store.test.mjs +304 -0
  17. package/proxy/exec-narrative.test.mjs +262 -0
  18. package/proxy/execution-correlation.test.mjs +146 -0
  19. package/proxy/execution-runner.test.mjs +38 -0
  20. package/proxy/experiment-engine.test.mjs +93 -0
  21. package/proxy/explanations.test.mjs +20 -0
  22. package/proxy/gvisor-forwarder.test.mjs +368 -0
  23. package/proxy/init-evidence-db.mjs +30 -0
  24. package/proxy/local-token.mjs +30 -0
  25. package/proxy/playground-recovery.test.mjs +130 -0
  26. package/proxy/playground.mjs +31 -3
  27. package/proxy/prompt-traces.test.mjs +32 -0
  28. package/proxy/providers.test.mjs +76 -0
  29. package/proxy/proxy.integration.test.mjs +135 -0
  30. package/proxy/raytace-proxy.mjs +58 -18
  31. package/proxy/request-metrics.test.mjs +19 -0
  32. package/proxy/request-policy.mjs +45 -0
  33. package/proxy/request-policy.test.mjs +47 -0
  34. package/proxy/sandbox-bridge.mjs +3 -0
  35. package/proxy/search.test.mjs +161 -0
  36. package/proxy/smoke.test.mjs +93 -0
  37. package/proxy/step-lab.test.mjs +38 -0
  38. package/proxy/summaries.test.mjs +69 -0
  39. package/proxy/tool-metadata.test.mjs +38 -0
  40. package/proxy/trace-view.mjs +50 -18
  41. package/proxy/trace-view.test.mjs +72 -0
  42. package/proxy/typesafe.test.mjs +39 -0
  43. package/src/api.mjs +57 -0
  44. package/src/auth.mjs +35 -1
  45. package/src/beta.mjs +96 -0
  46. package/src/claude-code.mjs +38 -1
  47. package/src/commands.mjs +69 -25
  48. package/src/config.mjs +16 -7
  49. package/src/export.mjs +200 -0
  50. package/src/lima.mjs +42 -1
  51. package/src/local-sandbox.mjs +19 -4
  52. package/src/paths.mjs +8 -8
  53. package/src/proxy-process.mjs +26 -3
  54. package/src/sandbox.mjs +73 -40
  55. package/src/upload.mjs +198 -0
  56. package/worker/sandbox/claude-hook.mjs +50 -17
  57. package/worker/sandbox/projects.py +3 -2
  58. package/worker/sandbox/transcript-delivery.test.mjs +153 -0
  59. package/worker/sandbox/viewer.py +21 -2
package/README.md CHANGED
@@ -105,7 +105,8 @@ raytrace sandbox destroy my-box # asks whether to delete its log
105
105
  (`raytrace open`): **Sandboxes** lists each sandbox with its prompts, and
106
106
  **Sandbox evidence** shows, for one prompt, every command that actually ran,
107
107
  its exit code and what it reached on the network, each joined to the tool
108
- call that ran it. The raw collector feed is at http://localhost:8798.
108
+ call that ran it. The raw collector feed is at `/raytace/viewer/` on the
109
+ dashboard's address.
109
110
  Nothing leaves your machine.
110
111
  - **Changes:** the sandbox's Claude Code hook snapshots the project after
111
112
  every edit, so **Changes** shows what each prompt left different, file by
@@ -184,12 +185,54 @@ raytrace key # which keys are set
184
185
  | `raytrace sandbox start\|stop [id]` | start or stop a sandbox; stopping keeps its files |
185
186
  | `raytrace sandbox destroy [id]` | delete a sandbox; its recorded sessions are kept |
186
187
  | `raytrace auth login` | sign in to RayTrace; `status`, `logout` |
188
+ | `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 |
187
189
  | `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) |
188
190
  | `raytrace sandbox list --local` | your local sandboxes; their names work with `connect`, `start`, `stop` and `destroy` |
189
191
  | `raytrace sandbox destroy <name> [--delete-logs \| --keep-logs]` | delete a local sandbox; asks whether its captured logs go too, or move to `~/.raytrace/archive` |
192
+ | `raytrace export <trace-id> [--format json\|markdown] [--output <file>]` | export a recorded trace to terminal or owner-only file without running the proxy |
190
193
  | `raytrace doctor` | what this machine has and lacks, local sandboxes included |
191
194
  | `raytrace key [openrouter\|typesafe] [--remove]` | your keys for the dashboard's AI features; asked for, never taken as an argument |
192
195
 
196
+ ## Beta invites
197
+
198
+ If RayTrace gave you a beta code, sign in first, redeem it, then create your
199
+ sandbox — in that order:
200
+
201
+ ```sh
202
+ raytrace auth login
203
+ raytrace --code <code> # also: raytrace code <code>
204
+ raytrace sandbox create
205
+ ```
206
+
207
+ Redeeming deletes the code on RayTrace's servers; it can never be used
208
+ again, by anyone. Codes expire 3 days after they are issued, and the $10 of
209
+ OpenRouter credit expires 3 days after you redeem it, so do not sit on
210
+ either. Your account shows as **Beta** in the cloud dashboard until the
211
+ credit ends, and the credited sandbox is tagged Beta there too. Connecting
212
+ to a credited sandbox after its 3 days are up warns you that model calls
213
+ will be refused; the sandbox itself still opens.
214
+
215
+ Codes are minted only from the backend repo (`raytrace`:
216
+ `python3 worker/gvisor/mint_beta_codes.py`, 10 at a time); this CLI never
217
+ generates them.
218
+
219
+ ## Exporting traces
220
+
221
+ Export a recorded session directly from local evidence, even when RayTrace and the VM are stopped:
222
+
223
+ ```sh
224
+ # View trace in terminal as Markdown
225
+ raytrace export <trace-id>
226
+
227
+ # Export structured JSON
228
+ raytrace export <trace-id> --format json
229
+
230
+ # Save report to a file with owner-only (0600) permissions
231
+ raytrace export <trace-id> --format markdown --output trace.md
232
+ ```
233
+
234
+ Exported traces contain the full turn prompt, answer, tool calls, exit codes, and observed sandbox execution. Output files refuse to overwrite existing files to prevent accidental data loss.
235
+
193
236
  ## Privacy
194
237
 
195
238
  Local sandboxes keep everything on your machine. Cloud sandboxes run on
@@ -203,7 +246,13 @@ RayTrace's servers.
203
246
  organizations cannot.
204
247
  - `raytrace auth login` keeps your sign-in in the macOS Keychain or the Linux
205
248
  secret service (a file readable only by you where neither is available), and
206
- `raytrace auth logout` removes it.
249
+ `raytrace auth logout` removes it. Cloud commands ask you to sign in again
250
+ after 2 days with no cloud use (any cloud command resets that clock); the
251
+ command then continues where it left off. Local recording never asks.
252
+ - What RayTrace records locally stays in `~/.raytrace`, readable only by you.
253
+ Its local API takes the token in `~/.raytrace/api-token`, so another account
254
+ on the machine cannot read your traces or spend your OpenRouter key through
255
+ it. `raytrace open` signs your browser in with a one-time link.
207
256
 
208
257
  ## Uninstall
209
258
 
@@ -237,6 +286,9 @@ with a hook that points at a missing command.
237
286
  - **A local sandbox's Claude Code sessions do not show in the dashboard:**
238
287
  RayTrace's proxy may be from before local sandboxes. Restart it:
239
288
  `raytrace stop && raytrace start`. `sandbox create --local` warns about this.
289
+ - **The dashboard says this browser is not signed in:** run `raytrace open`.
290
+ Each browser signs in once, for 30 days; a bookmark to the dashboard then
291
+ keeps working.
240
292
  - **`sandbox create --local` says the machine is not ready:** each line names
241
293
  what is missing and how to fix it; `raytrace doctor` shows the same. Port
242
294
  8798 in use usually means another Lima VM is running (`limactl list`).
package/bin/raytrace.mjs CHANGED
@@ -18,9 +18,12 @@ Cloud sandboxes:
18
18
  (up to 200 MiB, 25 MiB a file, 20,000 files)
19
19
  raytrace connect [id] a terminal in it; with one sandbox the id is
20
20
  optional (same as: raytrace sandbox shell [id])
21
+ raytrace --code <code> beta invite: redeem a code RayTrace gave you for one
22
+ $10-credit sandbox (signed in first; also: raytrace code <code>)
21
23
  raytrace sandbox list
22
24
  raytrace sandbox start|stop [id]
23
- raytrace sandbox destroy [id] [--yes] delete it; recorded evidence is kept
25
+ raytrace sandbox destroy [id] [--yes] [--keep-traces]
26
+ delete it; traces go too unless --keep-traces (paid plans)
24
27
 
25
28
  Local sandboxes (your project stays on this machine):
26
29
  raytrace sandbox create --local [--name <name>] [--yes]
@@ -33,9 +36,21 @@ Local sandboxes (your project stays on this machine):
33
36
  raytrace sandbox destroy <name> [--delete-logs | --keep-logs]
34
37
  asks whether to delete its captured logs too;
35
38
  kept logs move to ~/.raytrace/archive
36
- Recorded commands, files and connections: http://localhost:8798.
39
+ Recorded commands, files and connections: raytrace open, then Sandbox evidence.
37
40
  macOS and Linux; Windows is experimental. raytrace doctor shows what is missing.
38
41
 
42
+ Upload local evidences to RayTrace cloud (needs sign-in):
43
+ raytrace upload logs [--sandbox <name>] [--dry-run] [--yes]
44
+ gzip and upload a local sandbox's evidences;
45
+ they appear at https://app.raytracer.si
46
+ raytrace upload status your plan's evidences storage
47
+
48
+ Export recorded traces:
49
+ raytrace export <trace-id> view trace details in terminal as Markdown
50
+ raytrace export <trace-id> --format json export trace structured as JSON
51
+ raytrace export <trace-id> --output <file>
52
+ save export to file with owner-only permissions
53
+
39
54
  AI features in the dashboard (summaries, recaps, Chain of thought), on your own key:
40
55
  raytrace key which keys are set
41
56
  raytrace key openrouter add your OpenRouter key (asked for, not echoed)
@@ -66,6 +81,16 @@ if (command === '--version' || command === '-v') {
66
81
  }
67
82
  if (!command || command === 'help' || command === '--help' || command === '-h') { console.log(HELP); process.exit(0); }
68
83
 
84
+ // `raytrace --code <code>` (also `raytrace code <code>`): redeem a beta code.
85
+ if (command === '--code' || command.startsWith('--code=') || command === 'code') {
86
+ const beta = await import('../src/beta.mjs');
87
+ const code = command.startsWith('--code=') ? command.slice('--code='.length) : rest[0];
88
+ const extra = command.startsWith('--code=') ? rest.length : rest.length - 1;
89
+ if (!code || extra !== 0) { console.error('Usage: raytrace --code <code>'); process.exit(2); }
90
+ try { await beta.redeemBetaCode(code); process.exit(0); }
91
+ catch (error) { console.error(`raytrace --code: ${error.message}`); process.exit(1); }
92
+ }
93
+
69
94
  const commands = await import('../src/commands.mjs');
70
95
 
71
96
  // `codex` passes everything after it straight to Codex.
@@ -109,6 +134,7 @@ if (command === 'sandbox') {
109
134
  local: { type: 'boolean' },
110
135
  'delete-logs': { type: 'boolean' },
111
136
  'keep-logs': { type: 'boolean' },
137
+ 'keep-traces': { type: 'boolean' },
112
138
  } });
113
139
  } catch (error) { console.error(`${error.message}\n\nRun \`raytrace help\` for usage.`); process.exit(2); }
114
140
  const [sub, id] = parsed.positionals;
@@ -125,6 +151,59 @@ if (command === 'sandbox') {
125
151
  catch (error) { console.error(`raytrace sandbox ${sub}: ${error.message}`); process.exit(1); }
126
152
  }
127
153
 
154
+ if (command === 'upload') {
155
+ let parsed;
156
+ try {
157
+ parsed = parseArgs({ args: rest, strict: true, allowPositionals: true, options: {
158
+ yes: { type: 'boolean', short: 'y' },
159
+ sandbox: { type: 'string' },
160
+ 'dry-run': { type: 'boolean' },
161
+ } });
162
+ } catch (error) { console.error(`${error.message}\n\nUsage: raytrace upload logs [--sandbox <name>] [--dry-run] [--yes] | raytrace upload status`); process.exit(2); }
163
+ const [sub, ...extra] = parsed.positionals;
164
+ if (extra.length || (sub !== 'logs' && sub !== 'status')) {
165
+ console.error('Usage: raytrace upload logs [--sandbox <name>] [--dry-run] [--yes] | raytrace upload status');
166
+ process.exit(2);
167
+ }
168
+ const upload = await import('../src/upload.mjs');
169
+ try {
170
+ if (sub === 'status') await upload.uploadStatus();
171
+ else await upload.uploadLogs({ sandbox: parsed.values.sandbox, yes: parsed.values.yes, dryRun: parsed.values['dry-run'] });
172
+ process.exit(0);
173
+ } catch (error) { console.error(`raytrace upload ${sub}: ${error.message}`); process.exit(1); }
174
+ }
175
+
176
+ if (command === 'export') {
177
+ let parsed;
178
+ try {
179
+ parsed = parseArgs({ args: rest, strict: true, allowPositionals: true, options: {
180
+ format: { type: 'string' },
181
+ output: { type: 'string' },
182
+ } });
183
+ } catch (error) {
184
+ console.error(`${error.message}\n\nUsage: raytrace export <trace-id> [--format json|markdown] [--output <file>]`);
185
+ process.exit(2);
186
+ }
187
+ const [traceId, ...extra] = parsed.positionals;
188
+ if (!traceId || extra.length > 0) {
189
+ console.error('Usage: raytrace export <trace-id> [--format json|markdown] [--output <file>]');
190
+ process.exit(2);
191
+ }
192
+ const format = parsed.values.format ?? 'markdown';
193
+ if (format !== 'markdown' && format !== 'json') {
194
+ console.error(`Invalid format: ${format}. Expected 'markdown' or 'json'.`);
195
+ process.exit(2);
196
+ }
197
+ const { exportCommand } = await import('../src/export.mjs');
198
+ try {
199
+ await exportCommand(traceId, { format, output: parsed.values.output });
200
+ process.exit(0);
201
+ } catch (error) {
202
+ console.error(`raytrace export: ${error.message}`);
203
+ process.exit(1);
204
+ }
205
+ }
206
+
128
207
  let flags;
129
208
  try {
130
209
  ({ values: flags } = parseArgs({ args: rest, strict: true, options: {