@raytrace-cli/cli 0.17.12 → 0.17.13
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 +3 -0
- package/package.json +1 -1
- package/src/local-sandbox.mjs +10 -1
- package/src/mcp.mjs +55 -4
package/bin/raytrace.mjs
CHANGED
|
@@ -194,6 +194,9 @@ if (command === 'sandbox') {
|
|
|
194
194
|
} });
|
|
195
195
|
} catch (error) { console.error(`${error.message}\n\nRun \`raytrace help\` for usage.`); process.exit(2); }
|
|
196
196
|
const [sub, id] = parsed.positionals;
|
|
197
|
+
if (sub === 'destroy' && parsed.values['delete-logs'] && parsed.values['keep-logs']) {
|
|
198
|
+
console.error('raytrace sandbox destroy: Pick one: --delete-logs or --keep-logs.'); process.exit(2);
|
|
199
|
+
}
|
|
197
200
|
const action = {
|
|
198
201
|
create: () => sandbox.create(parsed.values),
|
|
199
202
|
list: () => sandbox.list(parsed.values),
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@raytrace-cli/cli",
|
|
3
|
-
"version": "0.17.
|
|
3
|
+
"version": "0.17.13",
|
|
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/local-sandbox.mjs
CHANGED
|
@@ -322,6 +322,15 @@ function sessionIds(id) {
|
|
|
322
322
|
return [...listed(transcripts(id)), ...listed(earlierTranscripts(id))];
|
|
323
323
|
}
|
|
324
324
|
|
|
325
|
+
/**
|
|
326
|
+
* What --delete-logs / --keep-logs ask for: true (delete), false (keep), or
|
|
327
|
+
* null (neither, so ask). Both together is a contradiction, not a choice.
|
|
328
|
+
*/
|
|
329
|
+
export function logsChoice(flags) {
|
|
330
|
+
if (flags['delete-logs'] && flags['keep-logs']) throw new Error('Pick one: --delete-logs or --keep-logs.');
|
|
331
|
+
return flags['delete-logs'] ? true : flags['keep-logs'] ? false : null;
|
|
332
|
+
}
|
|
333
|
+
|
|
325
334
|
/**
|
|
326
335
|
* Deletes a local sandbox, and asks about the logs captured in it: deleted
|
|
327
336
|
* with it, or moved to ~/.raytrace/archive/<name>-<time>/ (the Claude Code
|
|
@@ -330,6 +339,7 @@ function sessionIds(id) {
|
|
|
330
339
|
* terminal and neither flag, the logs are kept.
|
|
331
340
|
*/
|
|
332
341
|
export async function destroy(ref, flags, { ask, interactive }) {
|
|
342
|
+
let deleteLogs = logsChoice(flags);
|
|
333
343
|
const id = pickId(ref);
|
|
334
344
|
const box = registry()[id];
|
|
335
345
|
if (!flags.yes) {
|
|
@@ -344,7 +354,6 @@ export async function destroy(ref, flags, { ask, interactive }) {
|
|
|
344
354
|
const { uploadLogs } = await import('./upload.mjs');
|
|
345
355
|
await uploadLogs({ sandbox: id, yes: true });
|
|
346
356
|
}
|
|
347
|
-
let deleteLogs = flags['delete-logs'] ? true : flags['keep-logs'] ? false : null;
|
|
348
357
|
if (deleteLogs === null) {
|
|
349
358
|
deleteLogs = interactive()
|
|
350
359
|
&& /^y(es)?$/i.test((await ask('Also delete the logs captured in this sandbox? (yes/no) [no]: ')).trim());
|
package/src/mcp.mjs
CHANGED
|
@@ -620,12 +620,62 @@ const HANDLERS = {
|
|
|
620
620
|
cancel_command: (args) => cancelCommand(args),
|
|
621
621
|
};
|
|
622
622
|
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
623
|
+
// ------------------------------------------------------------- argument checks
|
|
624
|
+
|
|
625
|
+
const isPlainObject = (value) => value !== null && typeof value === 'object' && !Array.isArray(value);
|
|
626
|
+
|
|
627
|
+
/** What is wrong with `value` for `schema`, as a sentence naming `field`; null when it fits. Only the keywords TOOLS use. */
|
|
628
|
+
function checkValue(field, value, schema) {
|
|
629
|
+
if (schema.type === 'boolean' && typeof value !== 'boolean') return `${field} must be true or false.`;
|
|
630
|
+
if (schema.type === 'string') {
|
|
631
|
+
if (typeof value !== 'string') return `${field} must be a string.`;
|
|
632
|
+
if (schema.minLength !== undefined && value.length < schema.minLength) return `${field} must be at least ${schema.minLength} character${schema.minLength === 1 ? '' : 's'} long.`;
|
|
633
|
+
if (schema.maxLength !== undefined && value.length > schema.maxLength) return `${field} must be at most ${schema.maxLength} characters long.`;
|
|
634
|
+
if (schema.pattern && !new RegExp(schema.pattern).test(value)) return `${field} is not in the expected format (${schema.pattern}).`;
|
|
635
|
+
}
|
|
636
|
+
if (schema.type === 'integer') {
|
|
637
|
+
if (!Number.isInteger(value)) return `${field} must be a whole number.`;
|
|
638
|
+
const { minimum, maximum } = schema;
|
|
639
|
+
if ((minimum !== undefined && value < minimum) || (maximum !== undefined && value > maximum)) {
|
|
640
|
+
if (minimum !== undefined && maximum !== undefined) return `${field} must be a whole number from ${minimum} to ${maximum}.`;
|
|
641
|
+
return minimum !== undefined ? `${field} must be a whole number of at least ${minimum}.` : `${field} must be a whole number of at most ${maximum}.`;
|
|
642
|
+
}
|
|
643
|
+
}
|
|
644
|
+
if (schema.enum && !schema.enum.includes(value)) return `${field} must be one of: ${schema.enum.join(', ')}.`;
|
|
645
|
+
return null;
|
|
646
|
+
}
|
|
647
|
+
|
|
648
|
+
/** Every way `args` breaks the tool's inputSchema, as sentences for the agent; [] when it fits. */
|
|
649
|
+
function validateArguments(tool, args) {
|
|
650
|
+
const { properties = {}, required = [], additionalProperties } = tool.inputSchema;
|
|
651
|
+
const problems = [];
|
|
652
|
+
for (const field of required) {
|
|
653
|
+
if (!Object.hasOwn(args, field)) problems.push(`${field} is required.`);
|
|
654
|
+
}
|
|
655
|
+
for (const [field, value] of Object.entries(args)) {
|
|
656
|
+
if (!Object.hasOwn(properties, field)) {
|
|
657
|
+
if (additionalProperties === false) {
|
|
658
|
+
const accepted = Object.keys(properties);
|
|
659
|
+
problems.push(`${field} is not an argument of ${tool.name}. ${accepted.length ? `It accepts: ${accepted.join(', ')}.` : 'It takes no arguments.'}`);
|
|
660
|
+
}
|
|
661
|
+
continue;
|
|
662
|
+
}
|
|
663
|
+
const problem = checkValue(field, value, properties[field]);
|
|
664
|
+
if (problem) problems.push(problem);
|
|
665
|
+
}
|
|
666
|
+
return problems;
|
|
667
|
+
}
|
|
668
|
+
|
|
669
|
+
async function callTool({ name, arguments: args, _meta: meta } = {}) {
|
|
670
|
+
const tool = TOOLS.find((each) => each.name === name);
|
|
671
|
+
if (!tool) return null;
|
|
672
|
+
// Missing or null arguments count as none; anything else must fit the tool's inputSchema before a handler sees it.
|
|
673
|
+
const given = args ?? {};
|
|
674
|
+
const problems = isPlainObject(given) ? validateArguments(tool, given) : ['arguments must be an object.'];
|
|
675
|
+
if (problems.length) return { ...text(problems.join(' ')), isError: true };
|
|
626
676
|
try {
|
|
627
677
|
// Each tool checks the sign-in where it does cloud work: local sandboxes need none.
|
|
628
|
-
return await
|
|
678
|
+
return await HANDLERS[tool.name](given, progress(meta?.progressToken));
|
|
629
679
|
} catch (error) {
|
|
630
680
|
// Failures go back to the agent as tool results it can act on.
|
|
631
681
|
return { ...text(error.message), isError: true };
|
|
@@ -658,6 +708,7 @@ async function handle(message) {
|
|
|
658
708
|
case 'ping': return respond({});
|
|
659
709
|
case 'tools/list': return respond({ tools: TOOLS });
|
|
660
710
|
case 'tools/call': {
|
|
711
|
+
if (typeof params?.name !== 'string' || !params.name) return fail(-32602, 'Missing tool name');
|
|
661
712
|
const result = await callTool(params);
|
|
662
713
|
return result ? respond(result) : fail(-32602, `Unknown tool: ${params?.name}`);
|
|
663
714
|
}
|