Skip to main content
Sign In
General

Core API

Full API reference for @rivet-dev/agent-os-core — VM lifecycle, filesystem, processes, networking, shells, and agent sessions.

Lifecycle

MethodSignatureDescription
createstatic create(options?: AgentOsOptions): Promise<AgentOs>Create and boot a new VM
disposedispose(): Promise<void>Shut down the VM and all sessions

Filesystem

MethodSignatureDescription
readFilereadFile(path: string): Promise<Uint8Array>Read a file
writeFilewriteFile(path: string, content: string | Uint8Array): Promise<void>Write a file
readFilesreadFiles(paths: string[]): Promise<BatchReadResult[]>Batch read multiple files
writeFileswriteFiles(entries: BatchWriteEntry[]): Promise<BatchWriteResult[]>Batch write multiple files (creates parent dirs)
mkdirmkdir(path: string): Promise<void>Create a directory
readdirreaddir(path: string): Promise<string[]>List directory entries
readdirRecursivereaddirRecursive(path: string, options?: ReaddirRecursiveOptions): Promise<DirEntry[]>Recursively list directory contents with metadata
statstat(path: string): Promise<VirtualStat>Get file/directory metadata
existsexists(path: string): Promise<boolean>Check if a path exists
movemove(from: string, to: string): Promise<void>Rename/move a file or directory
deletedelete(path: string, options?: { recursive?: boolean }): Promise<void>Delete a file or directory
mountFsmountFs(path: string, config: MountConfig): voidMount a filesystem at the given path
unmountFsunmountFs(path: string): voidUnmount a filesystem

Process Management

MethodSignatureDescription
execexec(command: string, options?: ExecOptions): Promise<ExecResult>Execute a shell command and wait for completion
spawnspawn(command: string, args: string[], options?: SpawnOptions): ManagedProcessSpawn a long-running process
listProcesseslistProcesses(): SpawnedProcessInfo[]List processes started via spawn()
allProcessesallProcesses(): ProcessInfo[]List all kernel processes across all runtimes
processTreeprocessTree(): ProcessTreeNode[]Get processes organized as a parent-child tree
getProcessgetProcess(pid: number): SpawnedProcessInfoGet info about a specific spawned process
stopProcessstopProcess(pid: number): voidSend SIGTERM to a process
killProcesskillProcess(pid: number): voidSend SIGKILL to a process

Network

MethodSignatureDescription
fetchfetch(port: number, request: Request): Promise<Response>Send an HTTP request to a service running inside the VM

Shell

MethodSignatureDescription
openShellopenShell(options?: OpenShellOptions): ShellHandleOpen an interactive shell with PTY support

Agent Sessions

MethodSignatureDescription
createSessioncreateSession(agentType: AgentType, options?: CreateSessionOptions): Promise<Session>Launch an agent and return a session
listSessionslistSessions(): SessionInfo[]List active sessions
getSessiongetSession(sessionId: string): SessionGet a session by ID
resumeSessionresumeSession(sessionId: string): SessionRetrieve an active session by ID
destroySessiondestroySession(sessionId: string): Promise<void>Gracefully cancel and close a session

Agent Registry

MethodSignatureDescription
listAgentslistAgents(): AgentRegistryEntry[]List registered agents with installation status

Session

MethodSignatureDescription
promptprompt(text: string): Promise<JsonRpcResponse>Send a prompt and wait for the response
cancelcancel(): Promise<JsonRpcResponse>Cancel ongoing agent work
closeclose(): voidKill the agent process and clean up
onSessionEventonSessionEvent(handler: SessionEventHandler): voidSubscribe to session update notifications
onPermissionRequestonPermissionRequest(handler: PermissionRequestHandler): voidSubscribe to permission requests
respondPermissionrespondPermission(permissionId: string, reply: PermissionReply): Promise<JsonRpcResponse>Reply to a permission request
setModesetMode(modeId: string): Promise<JsonRpcResponse>Set the session mode (e.g., “plan”)
getModesgetModes(): SessionModeState | nullGet available modes
setModelsetModel(model: string): Promise<JsonRpcResponse>Set the model
setThoughtLevelsetThoughtLevel(level: string): Promise<JsonRpcResponse>Set reasoning level
getConfigOptionsgetConfigOptions(): SessionConfigOption[]Get available config options
getEventsgetEvents(options?: GetEventsOptions): JsonRpcNotification[]Get event history
getSequencedEventsgetSequencedEvents(options?: GetEventsOptions): SequencedEvent[]Get event history with sequence numbers
rawSendrawSend(method: string, params?: Record<string, unknown>): Promise<JsonRpcResponse>Send an arbitrary ACP request

Session properties: sessionId, agentType, capabilities, agentInfo, closed

Types

VM & Options

  • AgentOsOptions — VM creation options (commandDirs, loopbackExemptPorts, moduleAccessCwd, mounts, additionalInstructions)
  • CreateSessionOptions — Session options (cwd, env, mcpServers, skipOsInstructions, additionalInstructions)

Mount Configurations

  • MountConfig — Union of all mount types
  • MountConfigMemory — In-memory filesystem
  • MountConfigCustom — Caller-provided VirtualFileSystem
  • MountConfigHostDir — Host directory with symlink escape prevention
  • MountConfigS3 — S3-compatible object storage
  • MountConfigOverlay — Copy-on-write overlay (lower + upper layers)

MCP Servers

  • McpServerConfig — Union of local and remote MCP configs
  • McpServerConfigLocal — Local MCP server (command, args, env)
  • McpServerConfigRemote — Remote MCP server (url, headers)

Process

  • ProcessInfo — Kernel process info (pid, ppid, pgid, sid, driver, command, args, cwd, status, exitCode, startTime, exitTime)
  • SpawnedProcessInfo — Info for processes created via spawn() (pid, command, args, running, exitCode)
  • ProcessTreeNode — ProcessInfo with children: ProcessTreeNode[]

Filesystem

  • DirEntry — Directory entry (path, type, size)
  • ReaddirRecursiveOptions — Options for recursive listing (maxDepth, exclude)
  • BatchWriteEntry — Entry for batch writes (path, content)
  • BatchWriteResult — Result of a batch write (path, success, error?)
  • BatchReadResult — Result of a batch read (path, content, error?)

Agent

  • AgentType"pi" | "opencode"
  • AgentConfig — Agent configuration (acpAdapter, agentPackage, prepareInstructions)
  • AgentRegistryEntry — Registry entry (id, acpAdapter, agentPackage, installed)

Session

  • SessionInfo — Session summary (sessionId, agentType)
  • SessionInitData — Data from ACP initialize response
  • SessionMode — A mode the agent supports
  • SessionModeState — Current mode and available modes
  • SessionConfigOption — A configuration option the agent supports
  • AgentCapabilities — Boolean capability flags from the agent
  • AgentInfo — Agent identity (name, version)
  • PermissionRequest — Permission request from an agent
  • PermissionReply"once" | "always" | "reject"
  • PermissionRequestHandler — Handler for permission requests
  • SessionEventHandler — Handler for session update events
  • SequencedEvent — Notification with sequence number
  • GetEventsOptions — Filter options for event history (since, method)

Protocol

  • JsonRpcRequest, JsonRpcResponse, JsonRpcNotification, JsonRpcError

Backends

  • HostDirBackendOptions, OverlayBackendOptions, S3BackendOptions