API reference
Runtime
Constructor
new Runtime(root: string, options?: RuntimeOptions)
root: Absolute or relative path to the project directory.
Properties
| Name | Type | Description |
|---|
root | string | Original root passed in |
effectiveRoot | string | Working dir for runs (overlay temp or root) |
fs | FsAdapter | Filesystem API over the effective workspace |
Methods
| Method | Returns | Description |
|---|
run(lang, code, opts?) | Promise<RunResult> | Execute code in effectiveRoot |
apply() | void | Overlay only: merge temp workspace into root |
close() | void | Remove overlay temp dir |
serialize() | SerializedRuntime | Snapshot overlay state |
getRunLog() | RunLogEntry[] | Copy of session log (if enabled) |
clearRunLog() | void | Clear in-memory log |
asOpenAITool() | OpenAI tool schema | JSON schema for function tools |
executeToolCall(args) | Promise<RunResult> | args: { language, code } |
Runtime.deserialize(data) — static factory from SerializedRuntime.
Types
Language
"bash" | "python" | "javascript" | "sql"
RunResult
| Field | Type |
|---|
stdout, stderr | string |
exitCode | number |
durationMs | number |
files | FileChange[] |
truncated | boolean |
FileChange
path, type: "created" | "modified" | "deleted", size
RuntimeOptions
| Option | Type | Description |
|---|
readonly | boolean | Prevent writes through the fs adapter |
overlay | boolean | Copy project to temp dir; apply on apply() |
limits | ResourceLimits | timeoutMs, maxOutputBytes |
includeGlobs | string[] | File patterns for diff scope |
excludeGlobs | string[] | Excluded from glob matching |
runLog | boolean | Record each run() |
runLogMaxEntries | number | Ring buffer size |
onRun | callback | Called after each logged run |
RunLogEntry
id, at (epoch ms), language, code, cwd, exitCode, durationMs, stdout, stderr, truncated, files
Utilities
| Export | Purpose |
|---|
listMatchingRelPaths | List files matching globs |
truncateOutput | Same logic as engines for output capping |
exportRunLogJSON | JSON export of log entries |
exportRunLogMarkdown | Markdown for humans / LLM context |
OpenAI function-calling
const tool = rt.asOpenAITool();
// pass tool to the model, then:
const result = await rt.executeToolCall(toolCallArgs);