API reference

Runtime

Constructor

new Runtime(root: string, options?: RuntimeOptions)
  • root: Absolute or relative path to the project directory.

Properties

NameTypeDescription
rootstringOriginal root passed in
effectiveRootstringWorking dir for runs (overlay temp or root)
fsFsAdapterFilesystem API over the effective workspace

Methods

MethodReturnsDescription
run(lang, code, opts?)Promise<RunResult>Execute code in effectiveRoot
apply()voidOverlay only: merge temp workspace into root
close()voidRemove overlay temp dir
serialize()SerializedRuntimeSnapshot overlay state
getRunLog()RunLogEntry[]Copy of session log (if enabled)
clearRunLog()voidClear in-memory log
asOpenAITool()OpenAI tool schemaJSON 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

FieldType
stdout, stderrstring
exitCodenumber
durationMsnumber
filesFileChange[]
truncatedboolean

FileChange

path, type: "created" | "modified" | "deleted", size

RuntimeOptions

OptionTypeDescription
readonlybooleanPrevent writes through the fs adapter
overlaybooleanCopy project to temp dir; apply on apply()
limitsResourceLimitstimeoutMs, maxOutputBytes
includeGlobsstring[]File patterns for diff scope
excludeGlobsstring[]Excluded from glob matching
runLogbooleanRecord each run()
runLogMaxEntriesnumberRing buffer size
onRuncallbackCalled after each logged run

RunLogEntry

id, at (epoch ms), language, code, cwd, exitCode, durationMs, stdout, stderr, truncated, files

Utilities

ExportPurpose
listMatchingRelPathsList files matching globs
truncateOutputSame logic as engines for output capping
exportRunLogJSONJSON export of log entries
exportRunLogMarkdownMarkdown for humans / LLM context

OpenAI function-calling

const tool = rt.asOpenAITool();
// pass tool to the model, then:
const result = await rt.executeToolCall(toolCallArgs);