agentOS API Reference - v0.2.0-rc.3
    Preparing search index...

    Interface VmActions

    The vm.* action surface as the SERVER defines it. Each handler receives the RivetKit action context (c) as its first argument; RivetKit strips that context when projecting these onto the client handle, so callers invoke e.g. handle.createSession("claude", { env: { ANTHROPIC_API_KEY } }).

    The string index signature satisfies RivetKit's Actions constraint.

    interface VmActions {
        cancelCronJob(c: any, id: string): Promise<void>;
        cancelPrompt(c: any, sessionId: string): Promise<JsonRpcResponse>;
        cancelSession(c: any, sessionId: string): Promise<JsonRpcResponse>;
        closeProcessStdin(c: any, pid: number): Promise<void>;
        closeSession(c: any, sessionId: string): Promise<void>;
        closeShell(c: any, shellId: string): Promise<void>;
        connectTerminal(c: any, options?: ConnectTerminalOptions): Promise<number>;
        createSession(
            c: any,
            agentType: string,
            options?: CreateSessionOptions,
        ): Promise<SessionRecord>;
        createSignedPreviewUrl(
            c: any,
            port: number,
            expiresInSeconds?: number,
        ): Promise<PreviewUrl>;
        delete(
            c: any,
            path: string,
            options?: { recursive?: boolean },
        ): Promise<void>;
        destroySession(c: any, sessionId: string): Promise<void>;
        exec(c: any, command: string, options?: ExecOptions): Promise<ExecResult>;
        execArgv(
            c: any,
            command: string,
            args?: readonly string[],
            options?: ExecOptions,
        ): Promise<ExecResult>;
        exists(c: any, path: string): Promise<boolean>;
        getConfigOptions(c: any, sessionId: string): Promise<SessionConfigOption[]>;
        getModes(c: any, sessionId: string): Promise<SessionModeState | null>;
        getProcess(c: any, pid: number): Promise<SpawnedProcessInfo>;
        getSequencedEvents(
            c: any,
            sessionId: string,
            options?: GetSequencedEventsOptions,
        ): Promise<SequencedSessionEvent[]>;
        getSessionEvents(
            c: any,
            sessionId: string,
        ): Promise<PersistedSessionEvent[]>;
        killProcess(c: any, pid: number): Promise<void>;
        listCronJobs(c: any): Promise<CronJobInfo[]>;
        listPersistedSessions(c: any): Promise<PersistedSessionRecord[]>;
        listProcesses(c: any): Promise<SpawnedProcessInfo[]>;
        listSessions(c: any): Promise<SessionRecord[]>;
        mkdir(
            c: any,
            path: string,
            options?: { recursive?: boolean },
        ): Promise<void>;
        move(c: any, from: string, to: string): Promise<void>;
        openShell(c: any, options?: OpenShellOptions): Promise<{ shellId: string }>;
        prompt(c: any, sessionId: string, text: string): Promise<PromptResult>;
        readdir(c: any, path: string): Promise<string[]>;
        readdirRecursive(
            c: any,
            path: string,
            options?: ReaddirRecursiveOptions,
        ): Promise<DirEntry[]>;
        readFile(c: any, path: string): Promise<Uint8Array<ArrayBufferLike>>;
        readFiles(c: any, paths: string[]): Promise<BatchReadResult[]>;
        resizeShell(
            c: any,
            shellId: string,
            cols: number,
            rows: number,
        ): Promise<void>;
        respondPermission(
            c: any,
            sessionId: string,
            permissionId: string,
            reply: PermissionReply,
        ): Promise<JsonRpcResponse>;
        scheduleCron(
            c: any,
            options: SerializableCronJobOptions,
        ): Promise<ScheduledCronJob>;
        sendPrompt(
            c: any,
            sessionId: string,
            prompt: string,
        ): Promise<PromptResult>;
        setMode(
            c: any,
            sessionId: string,
            modeId: string,
        ): Promise<JsonRpcResponse>;
        setModel(
            c: any,
            sessionId: string,
            model: string,
        ): Promise<JsonRpcResponse>;
        setThoughtLevel(
            c: any,
            sessionId: string,
            level: string,
        ): Promise<JsonRpcResponse>;
        snapshotRootFilesystem(c: any): Promise<RootSnapshotExport>;
        spawn(
            c: any,
            command: string,
            args?: string[],
            options?: SpawnOptions,
        ): Promise<{ pid: number }>;
        spawnProcess(c: any, command: string, args?: string[]): Promise<number>;
        stat(c: any, path: string): Promise<VirtualStat>;
        stopProcess(c: any, pid: number): Promise<void>;
        vmFetch(
            c: any,
            port: number,
            path: string,
            options?: VmFetchOptions,
        ): Promise<VmFetchResponse>;
        waitProcess(c: any, pid: number): Promise<number>;
        writeFile(
            c: any,
            path: string,
            content: string | Uint8Array<ArrayBufferLike>,
        ): Promise<void>;
        writeFiles(c: any, entries: BatchWriteEntry[]): Promise<BatchWriteResult[]>;
        writeProcessStdin(
            c: any,
            pid: number,
            data: string | Uint8Array<ArrayBufferLike>,
        ): Promise<void>;
        writeShell(
            c: any,
            shellId: string,
            data: string | Uint8Array<ArrayBufferLike>,
        ): Promise<void>;
        [action: string]: (c: any, ...args: any[]) => any;
    }

    Indexable

    • [action: string]: (c: any, ...args: any[]) => any

      Index signature required by RivetKit's Actions constraint.

    Index

    Methods

    • Cancel a registered cron job by id.

      Parameters

      • c: any
      • id: string

      Returns Promise<void>

    • Cancel the in-flight prompt for a session (leaves the session open).

      Parameters

      • c: any
      • sessionId: string

      Returns Promise<JsonRpcResponse>

    • Cancel ongoing agent work for a session.

      Parameters

      • c: any
      • sessionId: string

      Returns Promise<JsonRpcResponse>

    • Close a spawned process's stdin stream.

      Parameters

      • c: any
      • pid: number

      Returns Promise<void>

    • Tear down an ACP session abruptly.

      Parameters

      • c: any
      • sessionId: string

      Returns Promise<void>

    • Close a shell and free its PTY.

      Parameters

      • c: any
      • shellId: string

      Returns Promise<void>

    • Connect a terminal (PTY) to the VM and return its pid.

      Parameters

      Returns Promise<number>

    • Create a time-limited, token-based preview URL for a VM port.

      Parameters

      • c: any
      • port: number
      • OptionalexpiresInSeconds: number

      Returns Promise<PreviewUrl>

    • Delete a path (optionally recursive).

      Parameters

      • c: any
      • path: string
      • Optionaloptions: { recursive?: boolean }

      Returns Promise<void>

    • Gracefully destroy a session (cancel pending work, then close).

      Parameters

      • c: any
      • sessionId: string

      Returns Promise<void>

    • Run a command line to completion and capture its output.

      Parameters

      Returns Promise<ExecResult>

    • Run a command (argv form, no shell) to completion and capture output.

      Parameters

      • c: any
      • command: string
      • Optionalargs: readonly string[]
      • Optionaloptions: ExecOptions

      Returns Promise<ExecResult>

    • Check whether a path exists.

      Parameters

      • c: any
      • path: string

      Returns Promise<boolean>

    • Get the configurable options (model, thought level, ...) for a session.

      Parameters

      • c: any
      • sessionId: string

      Returns Promise<SessionConfigOption[]>

    • Get the available + current modes for a session.

      Parameters

      • c: any
      • sessionId: string

      Returns Promise<SessionModeState | null>

    • Get info about a single spawned process.

      Parameters

      • c: any
      • pid: number

      Returns Promise<SpawnedProcessInfo>

    • Replay persisted session events from durable storage (transcript history).

      Parameters

      • c: any
      • sessionId: string

      Returns Promise<PersistedSessionEvent[]>

    • Force-kill a running process by pid (SIGKILL).

      Parameters

      • c: any
      • pid: number

      Returns Promise<void>

    • List the cron jobs registered on this VM.

      Parameters

      • c: any

      Returns Promise<CronJobInfo[]>

    • List the sessions currently tracked by this VM.

      Parameters

      • c: any

      Returns Promise<SessionRecord[]>

    • Create a directory (optionally recursive).

      Parameters

      • c: any
      • path: string
      • Optionaloptions: { recursive?: boolean }

      Returns Promise<void>

    • Move/rename a path.

      Parameters

      • c: any
      • from: string
      • to: string

      Returns Promise<void>

    • Open an interactive shell (PTY) and return its id.

      Parameters

      Returns Promise<{ shellId: string }>

    • Alias of sendPrompt: send a prompt and accumulate the agent's reply.

      Parameters

      • c: any
      • sessionId: string
      • text: string

      Returns Promise<PromptResult>

    • List the immediate entries of a directory.

      Parameters

      • c: any
      • path: string

      Returns Promise<string[]>

    • Read a file from the VM filesystem.

      Parameters

      • c: any
      • path: string

      Returns Promise<Uint8Array<ArrayBufferLike>>

    • Read several files in one call, reporting per-file content/errors.

      Parameters

      • c: any
      • paths: string[]

      Returns Promise<BatchReadResult[]>

    • Resize a shell's PTY.

      Parameters

      • c: any
      • shellId: string
      • cols: number
      • rows: number

      Returns Promise<void>

    • Reply to a pending permission request raised by the agent.

      Parameters

      Returns Promise<JsonRpcResponse>

    • Send a prompt to an existing session and accumulate the agent's reply.

      Parameters

      • c: any
      • sessionId: string
      • prompt: string

      Returns Promise<PromptResult>

    • Switch the active mode (e.g. "plan", "auto") for a session.

      Parameters

      • c: any
      • sessionId: string
      • modeId: string

      Returns Promise<JsonRpcResponse>

    • Switch the active model for a session.

      Parameters

      • c: any
      • sessionId: string
      • model: string

      Returns Promise<JsonRpcResponse>

    • Switch the thought/reasoning level for a session.

      Parameters

      • c: any
      • sessionId: string
      • level: string

      Returns Promise<JsonRpcResponse>

    • Export a serializable snapshot of the VM root filesystem.

      Parameters

      • c: any

      Returns Promise<RootSnapshotExport>

    • Spawn a long-running process and return its pid.

      Parameters

      • c: any
      • command: string
      • Optionalargs: string[]
      • Optionaloptions: SpawnOptions

      Returns Promise<{ pid: number }>

    • Spawn a process inside the VM and return its pid.

      Parameters

      • c: any
      • command: string
      • Optionalargs: string[]

      Returns Promise<number>

    • Stat a path.

      Parameters

      • c: any
      • path: string

      Returns Promise<VirtualStat>

    • Gracefully stop a process (SIGTERM).

      Parameters

      • c: any
      • pid: number

      Returns Promise<void>

    • Proxy an HTTP request to a port inside the VM and return the response.

      Parameters

      Returns Promise<VmFetchResponse>

    • Wait for a process to exit and return its exit code.

      Parameters

      • c: any
      • pid: number

      Returns Promise<number>

    • Write a file into the VM filesystem.

      Parameters

      • c: any
      • path: string
      • content: string | Uint8Array<ArrayBufferLike>

      Returns Promise<void>

    • Write data to a spawned process's stdin.

      Parameters

      • c: any
      • pid: number
      • data: string | Uint8Array<ArrayBufferLike>

      Returns Promise<void>

    • Write input to a shell's PTY.

      Parameters

      • c: any
      • shellId: string
      • data: string | Uint8Array<ArrayBufferLike>

      Returns Promise<void>