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.
108 lines • 5.09 kB
TypeScript
/**
* `run` — execute a TypeScript snippet against the SDK in a sandbox.
*
* Before anything runs, the snippet is type-checked against the SDK's
* declarations (`../snippet-check.ts`). A snippet that cannot type-check makes
* no call: it is refused with TypeScript's own diagnostics, as
* `RUN_UNKNOWN_MEMBER` when the first is a member an SDK object does not have,
* else `RUN_TYPE_ERROR`. A checker that cannot answer is skipped, never fatal.
*
* 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 { type ChainCall } from "../sandbox-proxy.js";
import { type SandboxLogLine } from "../sandbox.js";
import { type SnippetDiagnostic } from "../snippet-check.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;
/** Type-check diagnostics shown inline; all of them are stored behind `diagnostics_ref`. */
export declare const RUN_DIAGNOSTICS_WINDOW = 10;
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" | "RUN_TYPE_ERROR";
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;
};
/** Present only when the type check could not run: the snippet ran unchecked. */
type_check?: {
status: "skipped";
reason: string;
};
error?: {
code: string;
message: string;
next_actions: RunNextAction[];
line?: number;
column?: number;
/** The type check's diagnostics, in the snippet's coordinates (a refused snippet): the first `RUN_DIAGNOSTICS_WINDOW`. */
diagnostics?: SnippetDiagnostic[];
/** When more diagnostics exist than are shown: how many in all, and the ref `expand_result` pages them from. */
diagnostics_total?: number;
diagnostics_ref?: string;
};
}
export declare const runSchema: {
code: import("../schema.js").RefinedSchema<string>;
timeout_seconds: import("../schema.js").OptionalSchema<import("../schema.js").NumberSchema>;
};
export declare function handleRun(args: {
code: string;
timeout_seconds?: number;
}): Promise<ToolResult>;
//# sourceMappingURL=run.d.ts.map