Skip to content

Class: SshRuntime

Coordinates Sandbox REST operations, Lakebase assignments, SSH sessions, command execution, built-in services, and web routes.

Every machine operation verifies an unexpired Lakebase assignment for the workspace, AppKit user, and Sandbox ID. Runtime epochs invalidate pending session, service, and route work after stop, delete, or reconciliation.

new SshRuntime(config, ownership?): SshRuntime

Creates a runtime with optional preinitialized ownership storage.

boolean = ...

number = ...

number = ...

boolean = ...

number = ...

string = ...

object[] = ...

number = ...

string = ...

number = ...

LakebaseMachineOwnershipStore

SshRuntime

readonly config: object

auto: boolean

commandTimeoutMs: number

connectTimeoutMs: number

fallbackToServicePrincipal: boolean

gatewayPort: number

optional keyDirectory?: string

machineSoftware: object[]

reaperIntervalSeconds: number

routePrefix: string

sandboxLifetimeSeconds: number


readonly routes: SshRouteRegistry

addProject(client, userId, input, signal?): Promise<{ directory: string; error?: string; id: string; machineId: string; name: string; openUrl?: string; path: string; port: number; state: "error" | "starting" | "stopped" | "ready"; stripPrefix: boolean; }>

Creates or updates one isolated, persisted Sandbox project and route.

WorkspaceClient$1

string

Record<string, JSONType> = ...

string = ...

string = ...

string = ...

string = ...

number = ...

string = ...

boolean = ...

("terminal" | "desktop" | "stats")[] = ...

boolean = ...

AbortSignal

Promise<{ directory: string; error?: string; id: string; machineId: string; name: string; openUrl?: string; path: string; port: number; state: "error" | "starting" | "stopped" | "ready"; stripPrefix: boolean; }>


close(): Promise<void>

Stops the reaper and closes sessions, routes, service state, and ownership resources.

Promise<void>


createMachine(client, userId, input?, signal?): Promise<{ autoStopSeconds?: number; canConnect: boolean; canStart: boolean; canStop: boolean; createdAt?: string; expiresAt: string; gatewayHost?: string; id: string; lastStartedAt?: string; name: string; projects: object[]; provider: "databricks-sandbox"; services: object[]; status: "error" | "unknown" | "starting" | "running" | "stopping" | "stopped"; }>

Creates a managed Sandbox and persists its assignment before returning it. If the Lakebase write fails, the newly created Sandbox is deleted.

WorkspaceClient$1

string

boolean = ...

AbortSignal

Promise<{ autoStopSeconds?: number; canConnect: boolean; canStart: boolean; canStop: boolean; createdAt?: string; expiresAt: string; gatewayHost?: string; id: string; lastStartedAt?: string; name: string; projects: object[]; provider: "databricks-sandbox"; services: object[]; status: "error" | "unknown" | "starting" | "running" | "stopping" | "stopped"; }>


deleteMachine(client, userId, machineId, signal?): Promise<{ deleted: boolean; }>

Deletes one assigned Sandbox, removes all assignments, and clears local runtime state.

WorkspaceClient$1

string

string

AbortSignal

Promise<{ deleted: boolean; }>


disconnect(workspaceScope, userId, machineId): void

Invalidates and closes one cached SSH session without changing the remote Sandbox.

string

string

string

void


execute(client, userId, input, signal?): Promise<{ args: string[]; command: string; executionTimeMs: number; exitCode: number; stderr: string; stdout: string; success: boolean; timedOut?: boolean; }>

Executes a command on an assigned Sandbox, starting the machine first when auto is enabled and rejecting stale work after ownership changes.

WorkspaceClient$1

string

string[] = ...

string = ...

string = ...

Record<string, string> = ...

string = ...

number = ...

AbortSignal

Promise<{ args: string[]; command: string; executionTimeMs: number; exitCode: number; stderr: string; stdout: string; success: boolean; timedOut?: boolean; }>


initializeOwnership(pool?): Promise<void>

Initializes the Lakebase ownership and expiration store.

LakebasePool

Promise<void>

When the AppKit Lakebase plugin did not provide a pool.


listMachines(client, userId, signal?): Promise<{ auto: boolean; machines: object[]; supported: boolean; }>

Lists only valid, unexpired Sandboxes assigned to one AppKit user. Returns supported: false when the workspace or region does not expose the Sandbox API.

WorkspaceClient$1

string

AbortSignal

Promise<{ auto: boolean; machines: object[]; supported: boolean; }>


openProjectTerminal(client, userId, projectId, signal?): Promise<{ project: { directory: string; error?: string; id: string; machineId: string; name: string; openUrl?: string; path: string; port: number; state: "error" | "starting" | "stopped" | "ready"; stripPrefix: boolean; }; service: { error?: string; kind: "terminal" | "desktop" | "stats"; openUrl: string; path: string; state: "error" | "starting" | "stopped" | "ready"; }; }>

Opens ttyd rooted at one persisted project directory.

WorkspaceClient$1

string

string

AbortSignal

Promise<{ project: { directory: string; error?: string; id: string; machineId: string; name: string; openUrl?: string; path: string; port: number; state: "error" | "starting" | "stopped" | "ready"; stripPrefix: boolean; }; service: { error?: string; kind: "terminal" | "desktop" | "stats"; openUrl: string; path: string; state: "error" | "starting" | "stopped" | "ready"; }; }>


projectList(client, userId): Promise<object[]>

Lists persisted projects for one AppKit user.

WorkspaceClient$1

string

Promise<object[]>


projectPathPrefix(userId): string

Returns the user-scoped project path prefix beneath the configured root path.

string

string


reapMachines(client, signal?): Promise<SandboxReaperResult>

Reconciles Lakebase assignments with managed Sandbox names and expirations. Concurrent calls share one in-flight pass, and replicas serialize through the workspace-scoped Lakebase advisory lock.

WorkspaceClient$1

AbortSignal

Promise<SandboxReaperResult>


removeProject(client, userId, projectId, signal?): Promise<boolean>

Removes one project, runs optional mise stop and uninstall, then deletes its directory and route.

WorkspaceClient$1

string

string

AbortSignal

Promise<boolean>


resetProject(client, userId, projectId, signal?): Promise<{ directory: string; error?: string; id: string; machineId: string; name: string; openUrl?: string; path: string; port: number; state: "error" | "starting" | "stopped" | "ready"; stripPrefix: boolean; }>

Recreates one persisted project’s directory from its saved mise configuration.

WorkspaceClient$1

string

string

AbortSignal

Promise<{ directory: string; error?: string; id: string; machineId: string; name: string; openUrl?: string; path: string; port: number; state: "error" | "starting" | "stopped" | "ready"; stripPrefix: boolean; }>


startMachine(client, userId, machineId, signal?): Promise<{ autoStopSeconds?: number; canConnect: boolean; canStart: boolean; canStop: boolean; createdAt?: string; expiresAt: string; gatewayHost?: string; id: string; lastStartedAt?: string; name: string; projects: object[]; provider: "databricks-sandbox"; services: object[]; status: "error" | "unknown" | "starting" | "running" | "stopping" | "stopped"; }>

Starts one assigned Sandbox, waits for the running state, and attempts to provision its terminal and metrics services.

WorkspaceClient$1

string

string

AbortSignal

Promise<{ autoStopSeconds?: number; canConnect: boolean; canStart: boolean; canStop: boolean; createdAt?: string; expiresAt: string; gatewayHost?: string; id: string; lastStartedAt?: string; name: string; projects: object[]; provider: "databricks-sandbox"; services: object[]; status: "error" | "unknown" | "starting" | "running" | "stopping" | "stopped"; }>


startReaper(client): Promise<SandboxReaperResult>

Runs an immediate reconciliation pass and starts the periodic reaper when ResolvedSshPluginConfig.reaperIntervalSeconds is greater than zero. Initial failures are logged and returned as one failure instead of preventing AppKit startup.

WorkspaceClient$1

Promise<SandboxReaperResult>


startService(client, userId, input, signal?): Promise<{ error?: string; kind: "terminal" | "desktop" | "stats"; openUrl: string; path: string; state: "error" | "starting" | "stopped" | "ready"; }>

Starts or reuses one built-in browser service and its owner-scoped AppKit route. Concurrent requests for the same service share one operation.

WorkspaceClient$1

string

string = ...

"terminal" | "desktop" | "stats" = ...

AbortSignal

Promise<{ error?: string; kind: "terminal" | "desktop" | "stats"; openUrl: string; path: string; state: "error" | "starting" | "stopped" | "ready"; }>


stopMachine(client, userId, machineId, signal?): Promise<{ autoStopSeconds?: number; canConnect: boolean; canStart: boolean; canStop: boolean; createdAt?: string; expiresAt: string; gatewayHost?: string; id: string; lastStartedAt?: string; name: string; projects: object[]; provider: "databricks-sandbox"; services: object[]; status: "error" | "unknown" | "starting" | "running" | "stopping" | "stopped"; }>

Stops one assigned Sandbox, waits for it to stop, and clears local runtime state.

WorkspaceClient$1

string

string

AbortSignal

Promise<{ autoStopSeconds?: number; canConnect: boolean; canStart: boolean; canStop: boolean; createdAt?: string; expiresAt: string; gatewayHost?: string; id: string; lastStartedAt?: string; name: string; projects: object[]; provider: "databricks-sandbox"; services: object[]; status: "error" | "unknown" | "starting" | "running" | "stopping" | "stopped"; }>


withAuthFallback<T>(operation, attempt): Promise<T>

Runs a workspace operation with OBO credentials first and optionally retries it with the app service principal.

Service-principal retry occurs only when ResolvedSshPluginConfig.fallbackToServicePrincipal is enabled. Both attempts emit sanitized diagnostics.

T

WorkspaceAuthOperation

WorkspaceAuthAttempt<T>

Promise<T>