run402-mcp
Version:
MCP server for Run402 — full-stack backend infrastructure for AI agents: Postgres, auth, storage, serverless functions and atomic deploys. Paid with x402/MPP. Includes $0.03 image generation.
90 lines • 3.94 kB
TypeScript
/**
* `run` — execute a TypeScript snippet against the SDK in a sandbox.
*
* The snippet sees one binding, `r` (the Node SDK client, reached through the
* chain proxy in `../sandbox-proxy.ts`), plus `console` and the ECMAScript
* builtins. It has no filesystem, no `process`, no module loader, no timers,
* and no network of its own (`../sandbox.ts`). Its chains replay on the host
* against a client built with `surface: "sandbox"`, which refuses every
* secret-returning or secret-consuming SDK method with `SECRET_REQUIRES_CLI`
* before any request, so nothing secret can reach the result store.
*
* The result is the value, the logs, and the calls, all bounded and all
* honest: the value is stored by items (`../value-paging.ts`: an array's
* elements, the rows of an object's largest array, an object's entries, or a
* string's lines) under `value_ref`; a value that does not fit inline carries
* its leading whole items as `value_window`, with `shown` / `total` counting
* items; logs likewise under `logs_ref` (50 inline); `calls[]` lists every
* SDK chain the replay ran with its outcome, including on a timeout, because
* those side effects happened. Every result names the active wallet.
*/
import { z } from "zod";
import { type ChainCall } from "../sandbox-proxy.js";
import { type SandboxLogLine } from "../sandbox.js";
import { type ToolResult } from "../structured.js";
/** At most this many runs execute at once on one server; the next is `RUN_BUSY`. */
export declare const RUN_MAX_CONCURRENT = 4;
export declare const RUN_DEFAULT_TIMEOUT_SECONDS = 60;
export declare const RUN_MAX_TIMEOUT_SECONDS = 300;
/** Source size cap, in bytes. */
export declare const RUN_MAX_SOURCE_BYTES: number;
/** A value whose pretty-printed JSON fits in this many lines is inline whole; a larger one is windowed by items within the same budget. */
export declare const RUN_VALUE_WINDOW_LINES = 200;
/** Console lines shown inline. */
export declare const RUN_LOG_WINDOW_LINES = 50;
export type RunErrorCode = "RUN_SYNTAX_ERROR" | "RUN_TIMEOUT" | "RUN_MEMORY_EXCEEDED" | "RUN_VALUE_NOT_SERIALIZABLE" | "RUN_VALUE_TOO_LARGE" | "RUN_BUSY" | "RUN_EXCEPTION" | "RUN_ARGUMENT_NOT_CLONEABLE" | "RUN_UNKNOWN_MEMBER";
export interface RunNextAction {
type: string;
why?: string;
command?: string;
[key: string]: unknown;
}
export interface RunResult {
status: "ok" | "error";
/** The value, when the whole of it fits the inline window (`shown === total`). */
value?: unknown;
value_kind?: "undefined";
/**
* For a value too large to inline: the leading whole items, where they live
* in the value (`$`, `$.<key>`, `$entries`, `$lines`), and, for `$.<key>`,
* the object's other fields. `expand_result(value_ref)` pages the rest.
*/
value_window?: {
path: string;
items: unknown[];
rest?: Record<string, unknown>;
};
value_ref: string | null;
/** Items shown: all of them when `value` is inline, else `value_window.items.length`. */
shown: number;
/** Items in the whole value. */
total: number;
logs: SandboxLogLine[];
logs_ref: string | null;
/** Console lines past the stored cap that were not retained. */
logs_dropped?: number;
calls: ChainCall[];
/** `calls[]` entries past the cap that were not retained. */
calls_dropped?: number;
duration_ms: number;
wallet: {
local_label: string;
address: string | null;
};
error?: {
code: string;
message: string;
next_actions: RunNextAction[];
line?: number;
column?: number;
};
}
export declare const runSchema: {
code: z.ZodEffects<z.ZodString, string, string>;
timeout_seconds: z.ZodOptional<z.ZodNumber>;
};
export declare function handleRun(args: {
code: string;
timeout_seconds?: number;
}): Promise<ToolResult>;
//# sourceMappingURL=run.d.ts.map