@raytrace-cli/cli 0.19.9 → 0.19.11

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@raytrace-cli/cli",
3
- "version": "0.19.9",
3
+ "version": "0.19.11",
4
4
  "mcpName": "io.github.Godcreatebugs/raytrace",
5
5
  "description": "See what your coding agent did: traces, tool calls, cost and step-by-step evidence for Claude Code and Codex.",
6
6
  "license": "MIT",
package/src/export.mjs CHANGED
@@ -12,7 +12,7 @@ function escapeHtml(str) {
12
12
  }
13
13
 
14
14
  function safeCodeBlock(content, lang = '') {
15
- const text = String(content ?? '');
15
+ const text = content !== null && typeof content === 'object' ? JSON.stringify(content, null, 2) : String(content ?? '');
16
16
  const matches = text.match(/`+/g) || [];
17
17
  let maxBackticks = 3;
18
18
  for (const m of matches) {
@@ -56,7 +56,7 @@ export function formatTraceJson(trace) {
56
56
  kind: e.kind,
57
57
  title: e.title,
58
58
  status: e.status,
59
- timestamp: e.timestamp,
59
+ timestamp: e.time ?? e.timestamp,
60
60
  raw,
61
61
  };
62
62
  }),
@@ -118,7 +118,7 @@ export function formatTraceMarkdown(trace) {
118
118
  lines.push(`### ${escapeHtml(ev.title)}`);
119
119
  lines.push(`- **Kind:** \`${ev.kind}\``);
120
120
  lines.push(`- **Status:** \`${ev.status || 'unknown'}\``);
121
- lines.push(`- **Timestamp:** ${ev.timestamp || 'unknown'}`);
121
+ lines.push(`- **Timestamp:** ${ev.time ?? ev.timestamp ?? 'unknown'}`);
122
122
 
123
123
  let rawObj = null;
124
124
  if (ev.raw) {
package/src/share.mjs CHANGED
@@ -34,11 +34,12 @@ export async function sharePrompt(traceId, { sandboxId, allowFork = false } = {}
34
34
  }
35
35
 
36
36
  const result = await call('POST', '/v1/shares', {
37
- body: {
37
+ headers: { 'content-type': 'application/json' },
38
+ body: JSON.stringify({
38
39
  trace_id: cleanTrace,
39
40
  sandbox_id: targetSandbox,
40
41
  allow_fork: Boolean(allowFork),
41
- },
42
+ }),
42
43
  });
43
44
 
44
45
  const fullUrl = `${DASHBOARD}${result.url}`;
package/src/upload.mjs CHANGED
@@ -45,9 +45,15 @@ export function snapshotEvidences(database = paths.database) {
45
45
  if (!existsSync(database)) throw new Error(`No evidences recorded yet (${database} does not exist). Run an agent in a local sandbox first.`);
46
46
  const dir = mkdtempSync(join(tmpdir(), 'raytrace-upload-'));
47
47
  const plain = join(dir, 'evidence.db');
48
- const source = new DatabaseSync(database, { readOnly: true });
49
- try { source.exec(`VACUUM INTO '${plain.replaceAll("'", "''")}'`); } finally { source.close(); }
50
- return { dir, plain };
48
+ try {
49
+ const source = new DatabaseSync(database, { readOnly: true });
50
+ try { source.exec(`VACUUM INTO '${plain.replaceAll("'", "''")}'`); } finally { source.close(); }
51
+ return { dir, plain };
52
+ } catch (error) {
53
+ // The caller can only clean up a snapshot after this function returns it.
54
+ rmSync(dir, { recursive: true, force: true });
55
+ throw error;
56
+ }
51
57
  }
52
58
 
53
59
  /** Trims the snapshot to one sandbox, so nothing of any other sandbox or
@@ -94,17 +100,21 @@ export async function sendChunks({ url, key, sandbox, name, file, size, sha256,
94
100
  const { bytesRead } = await handle.read(buffer, 0, Math.min(CHUNK, size - offset), offset);
95
101
  const query = new URLSearchParams({ sandbox, name, sha256, size: String(size), offset: String(offset) });
96
102
  let response;
103
+ let data;
97
104
  try {
98
105
  response = await send(new URL(`/v1/evidence/import?${query}`, url), {
99
106
  method: 'POST', body: buffer.subarray(0, bytesRead),
100
107
  headers: { authorization: `Bearer ${key}`, 'content-type': 'application/gzip' },
101
108
  });
109
+ data = await response.json().catch((error) => {
110
+ if (response.ok) throw error;
111
+ return {};
112
+ });
102
113
  } catch (error) {
103
114
  if (++failures > RETRIES) throw new Error(`Upload interrupted: ${error.message}. Run it again to continue where it stopped.`);
104
115
  await new Promise((resolve) => { setTimeout(resolve, 500 * 2 ** failures); });
105
116
  continue;
106
117
  }
107
- const data = await response.json().catch(() => ({}));
108
118
  if (response.status === 409 && data.code === 'upload_offset') { offset = data.offset; onProgress(offset); continue; }
109
119
  if (response.status >= 500 && ++failures <= RETRIES) {
110
120
  await new Promise((resolve) => { setTimeout(resolve, 500 * 2 ** failures); });