@raytrace-cli/cli 0.18.0 → 0.19.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/bin/raytrace.mjs +1 -1
- package/package.json +1 -1
- package/src/auth.mjs +3 -3
- package/src/beta.mjs +12 -10
- package/src/mcp.mjs +11 -12
- package/src/sandbox.mjs +19 -20
package/bin/raytrace.mjs
CHANGED
|
@@ -37,7 +37,7 @@ Cloud sandboxes:
|
|
|
37
37
|
--claude or --codex starts that agent in it at
|
|
38
38
|
once, without approval prompts
|
|
39
39
|
raytrace --code <code> beta invite: redeem a code RayTrace gave you for one
|
|
40
|
-
|
|
40
|
+
free 3-day sandbox (signed in first; also: raytrace code <code>)
|
|
41
41
|
raytrace sandbox list
|
|
42
42
|
raytrace sandbox start|stop [id]
|
|
43
43
|
raytrace sandbox destroy [id] [--yes] [--keep-traces]
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@raytrace-cli/cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.19.0",
|
|
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/auth.mjs
CHANGED
|
@@ -191,10 +191,10 @@ export async function status() {
|
|
|
191
191
|
say(left > 0 ? `Access token valid for ${left} more min; renewed automatically.` : 'Access token expired; it is renewed on the next command.');
|
|
192
192
|
// Beta is a cloud entitlement, separate from any local licence tier.
|
|
193
193
|
try {
|
|
194
|
-
const { betaStatus, formatCreditDeadline } = await import('./beta.mjs');
|
|
194
|
+
const { betaEnds, betaStatus, formatCreditDeadline } = await import('./beta.mjs');
|
|
195
195
|
const beta = await betaStatus();
|
|
196
|
-
if (beta?.sandbox_consumed) say(`Beta:
|
|
197
|
-
else if (beta?.entitled) say(`Beta:
|
|
196
|
+
if (beta?.sandbox_consumed) say(`Beta: free sandbox created${beta.credited_sandbox_id ? ` (${beta.credited_sandbox_id})` : ''}${betaEnds(beta) ? `, until ${formatCreditDeadline(betaEnds(beta))}` : ''}.`);
|
|
197
|
+
else if (beta?.entitled) say(`Beta: one free sandbox available${betaEnds(beta) ? ` until ${formatCreditDeadline(betaEnds(beta))}` : ''} (raytrace sandbox create).`);
|
|
198
198
|
} catch { /* no beta entitlement, old backend, or offline: nothing to add */ }
|
|
199
199
|
}
|
|
200
200
|
|
package/src/beta.mjs
CHANGED
|
@@ -2,14 +2,18 @@
|
|
|
2
2
|
// RayTrace. Sign-in (`raytrace auth login`) is a prerequisite — this command
|
|
3
3
|
// never starts a sign-in flow and never sends the code anywhere until a
|
|
4
4
|
// signed-in account is known. The backend is the source of truth: on a
|
|
5
|
-
// successful redeem it deletes the code irreversibly and
|
|
6
|
-
//
|
|
5
|
+
// successful redeem it deletes the code irreversibly and grants the signed-in
|
|
6
|
+
// account one free cloud sandbox for 3 days. The agents in it run on the user's
|
|
7
|
+
// own Claude Code or Codex sign-in, made inside the sandbox. Nothing
|
|
7
8
|
// about the code or entitlement is stored on this machine.
|
|
8
9
|
import { accessToken, consumeIdleNotice } from './auth.mjs';
|
|
9
10
|
import { call, hasApiKeyOverride } from './api.mjs';
|
|
10
11
|
|
|
11
12
|
const say = (line = '') => console.log(line);
|
|
12
13
|
|
|
14
|
+
/** When a free beta sandbox ends: beta_ends_at, or credit_expires_at from a backend before it. */
|
|
15
|
+
export const betaEnds = (status) => status?.beta_ends_at ?? status?.credit_expires_at ?? null;
|
|
16
|
+
|
|
13
17
|
export const normalizeBetaCode = (code) => String(code ?? '').trim().toUpperCase().replace(/\s+/g, '');
|
|
14
18
|
|
|
15
19
|
// Codes are minted only in the backend repo (raytrace:
|
|
@@ -49,7 +53,7 @@ function redeemError(error) {
|
|
|
49
53
|
case 401: return new Error('Not signed in. Run: raytrace auth login, then re-run: raytrace --code <your-code>');
|
|
50
54
|
case 422: return new Error("That code isn't valid. Check it and try again, or ask RayTrace for a new one.");
|
|
51
55
|
case 410: return new Error('That code has expired (codes must be redeemed within 3 days). Ask RayTrace for a new one.');
|
|
52
|
-
case 409: return new Error('This account already has beta
|
|
56
|
+
case 409: return new Error('This account already has a free beta sandbox, so this code was not used. '
|
|
53
57
|
+ 'It can still be given to someone else until it expires.');
|
|
54
58
|
case 429: return new Error('Too many code attempts. Wait a while and try again.');
|
|
55
59
|
default: return null;
|
|
@@ -78,19 +82,17 @@ export async function redeemBetaCode(rawCode, { ensure = ensureSignedIn, apiCall
|
|
|
78
82
|
try {
|
|
79
83
|
const status = await betaStatus(apiCall);
|
|
80
84
|
if (status?.entitled) {
|
|
81
|
-
log("You're already good for beta testing: this account has its beta
|
|
82
|
-
if (status
|
|
85
|
+
log("You're already good for beta testing: this account has its free beta sandbox.");
|
|
86
|
+
if (betaEnds(status)) log(`Create it by ${formatCreditDeadline(betaEnds(status))}: raytrace sandbox create`);
|
|
83
87
|
return status;
|
|
84
88
|
}
|
|
85
89
|
} catch { /* fall through to the original error */ }
|
|
86
90
|
throw error;
|
|
87
91
|
}
|
|
88
|
-
|
|
89
|
-
log(
|
|
92
|
+
log("You're good for beta testing: one free cloud sandbox for 3 days is on this account.");
|
|
93
|
+
log('In it, sign in to Claude Code or Codex with your own account; RayTrace records the session.');
|
|
90
94
|
log('Your account now shows as Beta in the RayTrace dashboard.');
|
|
91
|
-
if (data
|
|
92
|
-
log(`Hard limit: create your sandbox and use the credit by ${formatCreditDeadline(data.credit_expires_at)}. Unused credit expires.`);
|
|
93
|
-
}
|
|
95
|
+
if (betaEnds(data)) log(`It ends ${formatCreditDeadline(betaEnds(data))}.`);
|
|
94
96
|
log('Next, from a Git repository: raytrace sandbox create');
|
|
95
97
|
return data;
|
|
96
98
|
}
|
package/src/mcp.mjs
CHANGED
|
@@ -20,7 +20,7 @@ import { fileURLToPath } from 'node:url';
|
|
|
20
20
|
import { createInterface } from 'node:readline';
|
|
21
21
|
import { accessToken, account, openUrl, startDeviceLogin } from './auth.mjs';
|
|
22
22
|
import { call, hasApiKeyOverride } from './api.mjs';
|
|
23
|
-
import { formatCreditDeadline } from './beta.mjs';
|
|
23
|
+
import { betaEnds, formatCreditDeadline } from './beta.mjs';
|
|
24
24
|
import { findLima, LIMA_VERSION } from './lima.mjs';
|
|
25
25
|
import { isLocal, localSandboxes, promptsLink, registry, sandboxName } from './local-sandbox.mjs';
|
|
26
26
|
import { install, paths } from './paths.mjs';
|
|
@@ -59,7 +59,7 @@ const TOOLS = [
|
|
|
59
59
|
{
|
|
60
60
|
name: 'list_sandboxes',
|
|
61
61
|
title: 'List sandboxes',
|
|
62
|
-
description: "This machine's local sandboxes, and the signed-in workspace's cloud sandboxes: id, name, status, age and beta
|
|
62
|
+
description: "This machine's local sandboxes, and the signed-in workspace's cloud sandboxes: id, name, status, age, and when a free beta sandbox ends.",
|
|
63
63
|
inputSchema: { type: 'object', properties: {}, additionalProperties: false },
|
|
64
64
|
annotations: { readOnlyHint: true, openWorldHint: true },
|
|
65
65
|
},
|
|
@@ -83,7 +83,7 @@ const TOOLS = [
|
|
|
83
83
|
install_lima: { type: 'boolean', description: `With local: download Lima ${LIMA_VERSION} (open source, about 25-40 MB, no admin rights) when it is not installed. Only after the user agrees.` },
|
|
84
84
|
connect: { type: 'boolean', description: 'Open a terminal connected to the new sandbox with a coding agent running in it, once it is ready. Defaults to true.' },
|
|
85
85
|
agent: agentSchema,
|
|
86
|
-
without_beta_credit: { type: 'boolean', description: "Create a
|
|
86
|
+
without_beta_credit: { type: 'boolean', description: "Create a regular sandbox, not the user's free beta sandbox. Only after the user agrees, when create_sandbox reported their free beta sandbox expired or already created." },
|
|
87
87
|
},
|
|
88
88
|
additionalProperties: false,
|
|
89
89
|
},
|
|
@@ -240,9 +240,7 @@ function describe(box) {
|
|
|
240
240
|
const created = typeof box.created === 'number' ? box.created * 1000 : Date.parse(box.created);
|
|
241
241
|
const minutes = Number.isFinite(created) ? Math.round((Date.now() - created) / 60000) : null;
|
|
242
242
|
const age = minutes === null ? '' : `, ${minutes < 120 ? `${minutes} min` : `${Math.round(minutes / 60)} h`} old`;
|
|
243
|
-
const beta = box.beta
|
|
244
|
-
? `, beta credit $${Math.max(0, box.credit_usd - (box.credit_spent_usd ?? 0)).toFixed(2)} of $${box.credit_usd} left${box.credit_expires_at ? ` (ends ${formatCreditDeadline(box.credit_expires_at)})` : ''}`
|
|
245
|
-
: '';
|
|
243
|
+
const beta = box.beta ? `, free beta sandbox${betaEnds(box) ? ` until ${formatCreditDeadline(betaEnds(box))}` : ''}` : '';
|
|
246
244
|
return `${box.id} ${box.status} ${box.name}${age}${beta}`;
|
|
247
245
|
}
|
|
248
246
|
|
|
@@ -332,10 +330,10 @@ async function createSandbox({ path, name, local = false, install_lima: installL
|
|
|
332
330
|
const root = await projectRoot(path);
|
|
333
331
|
if (local) return createLocal(root, name, installLima, connect && agent, step);
|
|
334
332
|
await requireSignIn();
|
|
335
|
-
const { plan
|
|
333
|
+
const { plan } = plain ? { plan: 'none' } : await creditPlan();
|
|
336
334
|
if (plan === 'expired') {
|
|
337
|
-
throw new ToolError('No sandbox was created: the user\'s
|
|
338
|
-
+ 'Ask the user whether to create a
|
|
335
|
+
throw new ToolError('No sandbox was created: the user\'s free beta sandbox expired (its 3 days ran out). '
|
|
336
|
+
+ 'Ask the user whether to create a regular sandbox instead; if they agree, call create_sandbox again with without_beta_credit: true.');
|
|
339
337
|
}
|
|
340
338
|
const useCredit = plan === 'use';
|
|
341
339
|
const { files, skipped, total } = listProject(root);
|
|
@@ -349,13 +347,14 @@ async function createSandbox({ path, name, local = false, install_lima: installL
|
|
|
349
347
|
box = await upload(archive, name || basename(root), useCredit);
|
|
350
348
|
} catch (error) {
|
|
351
349
|
if (!useCredit || !isCreditRefusal(error)) throw error;
|
|
352
|
-
throw new ToolError(`No sandbox was created: the user's beta
|
|
353
|
-
+ 'Ask the user whether to create a
|
|
350
|
+
throw new ToolError(`No sandbox was created: the user's free beta sandbox ${error.status === 410 ? 'expired before it was created' : 'was already created'}. `
|
|
351
|
+
+ 'Ask the user whether to create a regular sandbox instead; if they agree, call create_sandbox again with without_beta_credit: true.');
|
|
354
352
|
}
|
|
355
353
|
const lines = [
|
|
356
354
|
`Sandbox ${box.id} is running.`,
|
|
357
355
|
listed,
|
|
358
|
-
box.credit_applied ? `
|
|
356
|
+
box.credit_applied ? `This is the user's free beta sandbox${betaEnds(box) ? `, until ${formatCreditDeadline(betaEnds(box))}` : ''}.` : '',
|
|
357
|
+
'The first time, Claude Code (or Codex) asks the user to sign in inside the sandbox with their own account.',
|
|
359
358
|
box.transcripts ? 'Claude Code sessions in it are recorded.' : `Claude Code transcripts are off: ${box.transcripts_off}. Commands are still recorded.`,
|
|
360
359
|
connect ? openSandbox(box.id, { agent }).message : `To work in it: connect_sandbox, or in a terminal: raytrace connect ${box.id} --${agent}. To run commands in it from here: run_command.`,
|
|
361
360
|
`Recorded sessions: ${DASHBOARD}`,
|
package/src/sandbox.mjs
CHANGED
|
@@ -15,7 +15,7 @@ import { request as httpsRequest } from 'node:https';
|
|
|
15
15
|
import { basename, join } from 'node:path';
|
|
16
16
|
import { account } from './auth.mjs';
|
|
17
17
|
import { api, call, ApiError, unreachable } from './api.mjs';
|
|
18
|
-
import { betaStatus, formatCreditDeadline } from './beta.mjs';
|
|
18
|
+
import { betaEnds, betaStatus, formatCreditDeadline } from './beta.mjs';
|
|
19
19
|
import { ask, confirm, interactive } from './prompt.mjs';
|
|
20
20
|
import * as local from './local-sandbox.mjs';
|
|
21
21
|
import { AGENTS } from './agents.mjs';
|
|
@@ -136,7 +136,7 @@ export async function packArchive(root, files) {
|
|
|
136
136
|
export async function creditPlan() {
|
|
137
137
|
let beta;
|
|
138
138
|
try { beta = await betaStatus(); } catch { return { plan: 'none', beta: null }; }
|
|
139
|
-
const deadlinePassed = beta
|
|
139
|
+
const deadlinePassed = betaEnds(beta) && Date.parse(betaEnds(beta)) <= Date.now();
|
|
140
140
|
if (beta && !beta.sandbox_consumed && deadlinePassed && (beta.entitled || beta.credit_usd)) return { plan: 'expired', beta };
|
|
141
141
|
if (beta?.entitled && !beta.sandbox_consumed) return { plan: 'use', beta };
|
|
142
142
|
return { plan: 'none', beta };
|
|
@@ -163,15 +163,14 @@ export async function create(flags) {
|
|
|
163
163
|
// The same files, packed the same way, as a cloud sandbox gets: only the copy stays here.
|
|
164
164
|
if (flags.local) return local.create(localName, { root, files, skipped, total, archive: await pack(root, files) });
|
|
165
165
|
|
|
166
|
-
// A local sandbox never uses beta
|
|
166
|
+
// A local sandbox never uses the beta grant.
|
|
167
167
|
const { plan, beta } = await creditPlan();
|
|
168
168
|
if (plan === 'expired') {
|
|
169
|
-
say('Your
|
|
170
|
-
if (!interactive()) throw new Error('
|
|
171
|
-
if (!(await confirm('Create a
|
|
169
|
+
say('Your free beta sandbox has expired: its 3 days ran out.');
|
|
170
|
+
if (!interactive()) throw new Error('Free beta sandbox expired; no sandbox was created. Ask RayTrace for a new code to try again.');
|
|
171
|
+
if (!(await confirm('Create a regular sandbox instead?', false))) { say('Not created.'); return; }
|
|
172
172
|
} else if (plan === 'use') {
|
|
173
|
-
say(`
|
|
174
|
-
+ `${beta.credit_expires_at ? ` — credit ends ${formatCreditDeadline(beta.credit_expires_at)}` : ''}.`);
|
|
173
|
+
say(`This is your free beta sandbox${betaEnds(beta) ? `, until ${formatCreditDeadline(betaEnds(beta))}` : ''}.`);
|
|
175
174
|
}
|
|
176
175
|
const useCredit = plan === 'use';
|
|
177
176
|
say(`Packing ${files.length} files (${(total / 1048576).toFixed(1)} MiB) from ${root}`);
|
|
@@ -183,19 +182,20 @@ export async function create(flags) {
|
|
|
183
182
|
box = await upload(archive, name, useCredit);
|
|
184
183
|
} catch (error) {
|
|
185
184
|
if (!useCredit || !isCreditRefusal(error)) throw error;
|
|
186
|
-
say(error.status === 410 ? 'Your beta
|
|
187
|
-
: 'Your beta
|
|
188
|
-
if (!interactive() || !(await confirm('Create a
|
|
189
|
-
throw new Error('
|
|
185
|
+
say(error.status === 410 ? 'Your free beta sandbox expired before it was created.'
|
|
186
|
+
: 'Your free beta sandbox was already created.');
|
|
187
|
+
if (!interactive() || !(await confirm('Create a regular sandbox instead?', false))) {
|
|
188
|
+
throw new Error('Not created as your free beta sandbox; no sandbox was created.');
|
|
190
189
|
}
|
|
191
190
|
box = await upload(archive, name, false);
|
|
192
191
|
}
|
|
193
192
|
say(`\nSandbox ${box.id} is running.`);
|
|
194
193
|
if (box.credit_applied) {
|
|
195
|
-
say(`
|
|
194
|
+
say(`Your free beta sandbox${betaEnds(box) ? `, until ${formatCreditDeadline(betaEnds(box))}` : ''}. It shows as Beta in the dashboard.`);
|
|
196
195
|
}
|
|
197
196
|
say(box.transcripts ? 'Claude Code sessions in it are recorded.'
|
|
198
197
|
: `Claude Code transcripts are off: ${box.transcripts_off}. Commands are still recorded.`);
|
|
198
|
+
say('The first time, Claude Code (or Codex) asks you to sign in inside the sandbox: use your own account.');
|
|
199
199
|
say(`Open it: raytrace connect ${box.id}`);
|
|
200
200
|
}
|
|
201
201
|
|
|
@@ -207,7 +207,7 @@ export async function list(flags = {}) {
|
|
|
207
207
|
// The sandbox's creation time (seconds), or its container's once that is known.
|
|
208
208
|
const created = typeof box.created === 'number' ? box.created * 1000 : Date.parse(box.created);
|
|
209
209
|
const age = Math.round((Date.now() - created) / 60000);
|
|
210
|
-
const beta = box.beta ? ` Beta${
|
|
210
|
+
const beta = box.beta ? ` Beta${betaEnds(box) ? ` (until ${formatCreditDeadline(betaEnds(box))})` : ''}` : '';
|
|
211
211
|
say(`${box.id} ${String(box.status).padEnd(8)} ${box.name}${beta} (${age < 120 ? `${age} min` : `${Math.round(age / 60)} h`} old)`);
|
|
212
212
|
}
|
|
213
213
|
}
|
|
@@ -250,15 +250,14 @@ export async function destroy(id, flags) {
|
|
|
250
250
|
else if (result.traces_deleted === false) say('Note: its traces could not be deleted; they may still show on the dashboard.');
|
|
251
251
|
}
|
|
252
252
|
|
|
253
|
-
/** Exported for tests: the warning shown when connecting to a beta
|
|
254
|
-
* whose 3 days are up, or null.
|
|
255
|
-
* backend; the sandbox itself still opens. */
|
|
253
|
+
/** Exported for tests: the warning shown when connecting to a free beta
|
|
254
|
+
* sandbox whose 3 days are up, or null. The backend stops it; its files stay. */
|
|
256
255
|
export function betaExpiryWarning(beta, id, now = Date.now()) {
|
|
257
256
|
if (!beta || beta.credited_sandbox_id !== id) return null;
|
|
258
|
-
const deadline = beta
|
|
257
|
+
const deadline = betaEnds(beta) ? Date.parse(betaEnds(beta)) : NaN;
|
|
259
258
|
if (!beta.expired && !(deadline <= now)) return null;
|
|
260
|
-
return `Warning: your beta
|
|
261
|
-
+ '
|
|
259
|
+
return `Warning: your free beta sandbox expired${betaEnds(beta) ? ` (${formatCreditDeadline(betaEnds(beta), now)})` : ''}; `
|
|
260
|
+
+ 'RayTrace stops it. Its files are kept.';
|
|
262
261
|
}
|
|
263
262
|
|
|
264
263
|
/** An interactive terminal in the sandbox, carried over one upgraded HTTP request.
|