@raytrace-cli/cli 0.5.0 → 0.6.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 (56) hide show
  1. package/README.md +27 -1
  2. package/bin/raytrace.mjs +69 -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/claude-code.mjs +38 -1
  44. package/src/commands.mjs +69 -25
  45. package/src/config.mjs +16 -7
  46. package/src/export.mjs +200 -0
  47. package/src/lima.mjs +42 -1
  48. package/src/local-sandbox.mjs +19 -4
  49. package/src/paths.mjs +8 -8
  50. package/src/proxy-process.mjs +26 -3
  51. package/src/sandbox.mjs +13 -3
  52. package/src/upload.mjs +198 -0
  53. package/worker/sandbox/claude-hook.mjs +50 -17
  54. package/worker/sandbox/projects.py +3 -2
  55. package/worker/sandbox/transcript-delivery.test.mjs +153 -0
  56. 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
@@ -187,9 +188,27 @@ raytrace key # which keys are set
187
188
  | `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
189
  | `raytrace sandbox list --local` | your local sandboxes; their names work with `connect`, `start`, `stop` and `destroy` |
189
190
  | `raytrace sandbox destroy <name> [--delete-logs \| --keep-logs]` | delete a local sandbox; asks whether its captured logs go too, or move to `~/.raytrace/archive` |
191
+ | `raytrace export <trace-id> [--format json\|markdown] [--output <file>]` | export a recorded trace to terminal or owner-only file without running the proxy |
190
192
  | `raytrace doctor` | what this machine has and lacks, local sandboxes included |
191
193
  | `raytrace key [openrouter\|typesafe] [--remove]` | your keys for the dashboard's AI features; asked for, never taken as an argument |
192
194
 
195
+ ## Exporting traces
196
+
197
+ Export a recorded session directly from local evidence, even when RayTrace and the VM are stopped:
198
+
199
+ ```sh
200
+ # View trace in terminal as Markdown
201
+ raytrace export <trace-id>
202
+
203
+ # Export structured JSON
204
+ raytrace export <trace-id> --format json
205
+
206
+ # Save report to a file with owner-only (0600) permissions
207
+ raytrace export <trace-id> --format markdown --output trace.md
208
+ ```
209
+
210
+ 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.
211
+
193
212
  ## Privacy
194
213
 
195
214
  Local sandboxes keep everything on your machine. Cloud sandboxes run on
@@ -204,6 +223,10 @@ RayTrace's servers.
204
223
  - `raytrace auth login` keeps your sign-in in the macOS Keychain or the Linux
205
224
  secret service (a file readable only by you where neither is available), and
206
225
  `raytrace auth logout` removes it.
226
+ - What RayTrace records locally stays in `~/.raytrace`, readable only by you.
227
+ Its local API takes the token in `~/.raytrace/api-token`, so another account
228
+ on the machine cannot read your traces or spend your OpenRouter key through
229
+ it. `raytrace open` signs your browser in with a one-time link.
207
230
 
208
231
  ## Uninstall
209
232
 
@@ -237,6 +260,9 @@ with a hook that points at a missing command.
237
260
  - **A local sandbox's Claude Code sessions do not show in the dashboard:**
238
261
  RayTrace's proxy may be from before local sandboxes. Restart it:
239
262
  `raytrace stop && raytrace start`. `sandbox create --local` warns about this.
263
+ - **The dashboard says this browser is not signed in:** run `raytrace open`.
264
+ Each browser signs in once, for 30 days; a bookmark to the dashboard then
265
+ keeps working.
240
266
  - **`sandbox create --local` says the machine is not ready:** each line names
241
267
  what is missing and how to fix it; `raytrace doctor` shows the same. Port
242
268
  8798 in use usually means another Lima VM is running (`limactl list`).
package/bin/raytrace.mjs CHANGED
@@ -20,7 +20,8 @@ Cloud sandboxes:
20
20
  optional (same as: raytrace sandbox shell [id])
21
21
  raytrace sandbox list
22
22
  raytrace sandbox start|stop [id]
23
- raytrace sandbox destroy [id] [--yes] delete it; recorded evidence is kept
23
+ raytrace sandbox destroy [id] [--yes] [--keep-traces]
24
+ delete it; traces go too unless --keep-traces (paid plans)
24
25
 
25
26
  Local sandboxes (your project stays on this machine):
26
27
  raytrace sandbox create --local [--name <name>] [--yes]
@@ -33,9 +34,21 @@ Local sandboxes (your project stays on this machine):
33
34
  raytrace sandbox destroy <name> [--delete-logs | --keep-logs]
34
35
  asks whether to delete its captured logs too;
35
36
  kept logs move to ~/.raytrace/archive
36
- Recorded commands, files and connections: http://localhost:8798.
37
+ Recorded commands, files and connections: raytrace open, then Sandbox evidence.
37
38
  macOS and Linux; Windows is experimental. raytrace doctor shows what is missing.
38
39
 
40
+ Upload local evidences to RayTrace cloud (needs sign-in):
41
+ raytrace upload logs [--sandbox <name>] [--dry-run] [--yes]
42
+ gzip and upload a local sandbox's evidences;
43
+ they appear at https://app.raytracer.si
44
+ raytrace upload status your plan's evidences storage
45
+
46
+ Export recorded traces:
47
+ raytrace export <trace-id> view trace details in terminal as Markdown
48
+ raytrace export <trace-id> --format json export trace structured as JSON
49
+ raytrace export <trace-id> --output <file>
50
+ save export to file with owner-only permissions
51
+
39
52
  AI features in the dashboard (summaries, recaps, Chain of thought), on your own key:
40
53
  raytrace key which keys are set
41
54
  raytrace key openrouter add your OpenRouter key (asked for, not echoed)
@@ -109,6 +122,7 @@ if (command === 'sandbox') {
109
122
  local: { type: 'boolean' },
110
123
  'delete-logs': { type: 'boolean' },
111
124
  'keep-logs': { type: 'boolean' },
125
+ 'keep-traces': { type: 'boolean' },
112
126
  } });
113
127
  } catch (error) { console.error(`${error.message}\n\nRun \`raytrace help\` for usage.`); process.exit(2); }
114
128
  const [sub, id] = parsed.positionals;
@@ -125,6 +139,59 @@ if (command === 'sandbox') {
125
139
  catch (error) { console.error(`raytrace sandbox ${sub}: ${error.message}`); process.exit(1); }
126
140
  }
127
141
 
142
+ if (command === 'upload') {
143
+ let parsed;
144
+ try {
145
+ parsed = parseArgs({ args: rest, strict: true, allowPositionals: true, options: {
146
+ yes: { type: 'boolean', short: 'y' },
147
+ sandbox: { type: 'string' },
148
+ 'dry-run': { type: 'boolean' },
149
+ } });
150
+ } catch (error) { console.error(`${error.message}\n\nUsage: raytrace upload logs [--sandbox <name>] [--dry-run] [--yes] | raytrace upload status`); process.exit(2); }
151
+ const [sub, ...extra] = parsed.positionals;
152
+ if (extra.length || (sub !== 'logs' && sub !== 'status')) {
153
+ console.error('Usage: raytrace upload logs [--sandbox <name>] [--dry-run] [--yes] | raytrace upload status');
154
+ process.exit(2);
155
+ }
156
+ const upload = await import('../src/upload.mjs');
157
+ try {
158
+ if (sub === 'status') await upload.uploadStatus();
159
+ else await upload.uploadLogs({ sandbox: parsed.values.sandbox, yes: parsed.values.yes, dryRun: parsed.values['dry-run'] });
160
+ process.exit(0);
161
+ } catch (error) { console.error(`raytrace upload ${sub}: ${error.message}`); process.exit(1); }
162
+ }
163
+
164
+ if (command === 'export') {
165
+ let parsed;
166
+ try {
167
+ parsed = parseArgs({ args: rest, strict: true, allowPositionals: true, options: {
168
+ format: { type: 'string' },
169
+ output: { type: 'string' },
170
+ } });
171
+ } catch (error) {
172
+ console.error(`${error.message}\n\nUsage: raytrace export <trace-id> [--format json|markdown] [--output <file>]`);
173
+ process.exit(2);
174
+ }
175
+ const [traceId, ...extra] = parsed.positionals;
176
+ if (!traceId || extra.length > 0) {
177
+ console.error('Usage: raytrace export <trace-id> [--format json|markdown] [--output <file>]');
178
+ process.exit(2);
179
+ }
180
+ const format = parsed.values.format ?? 'markdown';
181
+ if (format !== 'markdown' && format !== 'json') {
182
+ console.error(`Invalid format: ${format}. Expected 'markdown' or 'json'.`);
183
+ process.exit(2);
184
+ }
185
+ const { exportCommand } = await import('../src/export.mjs');
186
+ try {
187
+ await exportCommand(traceId, { format, output: parsed.values.output });
188
+ process.exit(0);
189
+ } catch (error) {
190
+ console.error(`raytrace export: ${error.message}`);
191
+ process.exit(1);
192
+ }
193
+ }
194
+
128
195
  let flags;
129
196
  try {
130
197
  ({ values: flags } = parseArgs({ args: rest, strict: true, options: {