Lines 6459-6499javascript
6461 stdout_truncated: out.truncated,
6462 stderr_truncated: err.truncated,
6467 const execOutputShape = {
6468 sandbox_id: external_exports.string(),
6469 exit_code: external_exports.number().int().nullable(),
6470 timed_out: external_exports.boolean(),
6471 stdout: external_exports.string(),
6472 stderr: external_exports.string(),
6473 stdout_truncated: external_exports.boolean(),
6474 stderr_truncated: external_exports.boolean(),
6475 notes: external_exports.array(external_exports.string())
6477 const timedOutRe = /time[d\s-]*out/i;
6478 if (enabled("exec")) server.registerTool("run_command", {
6479 title: "Run shell command",
6480 description: "Run a shell command in a Platinum sandbox microVM (executed via sh -c). sandbox_id is OPTIONAL: when omitted, a small ephemeral default sandbox is reused or auto-created (auto-stops after ~15 min idle, later self-deletes; auto-resumed on the next command). Every result names the sandbox it ran on. Background processes are killed when the command returns \u2014 daemonize with setsid if something must keep running. On timeout you get PARTIAL output back. stdout/stderr are capped at 50 KB each with the cut clearly marked. The default pt-base template is busybox-based (sh, nc, wg ...
6482 sandbox_id: external_exports.string().optional().describe("Sandbox id, as returned by sandbox_create, sandbox_list, or echoed in every run_command result. Omit to reuse the tagged default sandbox (auto-created on first use)."),
6483 command: external_exports.string().min(1).describe("Shell command line, run via sh -c."),
6484 timeout_ms: external_exports.number().int().min(100).max(3e5).default(3e4),
6485 max_bytes: external_exports.number().int().min(1e3).max(MAX_TEXT_BYTES).optional().describe(`Optional LOWER cap on returned stdout/stderr bytes (default and ceiling: ${MAX_TEXT_BYTES}). Use to save context on chatty commands.`)
6487 outputSchema: execOutputShape,
6488 annotations: { destructiveHint: true, openWorldHint: true }
6489 }, async ({ sandbox_id, command, timeout_ms, max_bytes }) => {
6492 const id = await resolveExecTarget(sandbox_id, notes);
6493 const { id: ranOn, value } = await withRecovery(
6495 isExplicit(sandbox_id),
6497 (sbx) => toExecLike(sbx.sh(command, { timeoutMs: timeout_ms }))
6499 const timedOut = !!value.error && timedOutRe.test(value.error);
Long lines were clipped for display.