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.
Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new SshRuntime(
config,ownership?):SshRuntime
Creates a runtime with optional preinitialized ownership storage.
Parameters
Section titled “Parameters”config
Section titled “config”boolean = ...
commandTimeoutMs
Section titled “commandTimeoutMs”number = ...
connectTimeoutMs
Section titled “connectTimeoutMs”number = ...
fallbackToServicePrincipal
Section titled “fallbackToServicePrincipal”boolean = ...
gatewayPort
Section titled “gatewayPort”number = ...
keyDirectory?
Section titled “keyDirectory?”string = ...
machineSoftware
Section titled “machineSoftware”object[] = ...
reaperIntervalSeconds
Section titled “reaperIntervalSeconds”number = ...
routePrefix
Section titled “routePrefix”string = ...
sandboxLifetimeSeconds
Section titled “sandboxLifetimeSeconds”number = ...
ownership?
Section titled “ownership?”Returns
Section titled “Returns”SshRuntime
Properties
Section titled “Properties”config
Section titled “config”
readonlyconfig:object
auto:
boolean
commandTimeoutMs
Section titled “commandTimeoutMs”commandTimeoutMs:
number
connectTimeoutMs
Section titled “connectTimeoutMs”connectTimeoutMs:
number
fallbackToServicePrincipal
Section titled “fallbackToServicePrincipal”fallbackToServicePrincipal:
boolean
gatewayPort
Section titled “gatewayPort”gatewayPort:
number
keyDirectory?
Section titled “keyDirectory?”
optionalkeyDirectory?:string
machineSoftware
Section titled “machineSoftware”machineSoftware:
object[]
reaperIntervalSeconds
Section titled “reaperIntervalSeconds”reaperIntervalSeconds:
number
routePrefix
Section titled “routePrefix”routePrefix:
string
sandboxLifetimeSeconds
Section titled “sandboxLifetimeSeconds”sandboxLifetimeSeconds:
number
routes
Section titled “routes”
readonlyroutes:SshRouteRegistry
Methods
Section titled “Methods”addProject()
Section titled “addProject()”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.
Parameters
Section titled “Parameters”client
Section titled “client”WorkspaceClient$1
userId
Section titled “userId”string
config?
Section titled “config?”Record<string, JSONType> = ...
machineId
Section titled “machineId”string = ...
string = ...
openPath?
Section titled “openPath?”string = ...
string = ...
number = ...
projectId?
Section titled “projectId?”string = ...
route?
Section titled “route?”boolean = ...
serviceDependencies?
Section titled “serviceDependencies?”("terminal" | "desktop" | "stats")[] = ...
stripPrefix?
Section titled “stripPrefix?”boolean = ...
signal?
Section titled “signal?”AbortSignal
Returns
Section titled “Returns”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()
Section titled “close()”close():
Promise<void>
Stops the reaper and closes sessions, routes, service state, and ownership resources.
Returns
Section titled “Returns”Promise<void>
createMachine()
Section titled “createMachine()”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.
Parameters
Section titled “Parameters”client
Section titled “client”WorkspaceClient$1
userId
Section titled “userId”string
input?
Section titled “input?”desktop?
Section titled “desktop?”boolean = ...
signal?
Section titled “signal?”AbortSignal
Returns
Section titled “Returns”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()
Section titled “deleteMachine()”deleteMachine(
client,userId,machineId,signal?):Promise<{deleted:boolean; }>
Deletes one assigned Sandbox, removes all assignments, and clears local runtime state.
Parameters
Section titled “Parameters”client
Section titled “client”WorkspaceClient$1
userId
Section titled “userId”string
machineId
Section titled “machineId”string
signal?
Section titled “signal?”AbortSignal
Returns
Section titled “Returns”Promise<{ deleted: boolean; }>
disconnect()
Section titled “disconnect()”disconnect(
workspaceScope,userId,machineId):void
Invalidates and closes one cached SSH session without changing the remote Sandbox.
Parameters
Section titled “Parameters”workspaceScope
Section titled “workspaceScope”string
userId
Section titled “userId”string
machineId
Section titled “machineId”string
Returns
Section titled “Returns”void
execute()
Section titled “execute()”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.
Parameters
Section titled “Parameters”client
Section titled “client”WorkspaceClient$1
userId
Section titled “userId”string
string[] = ...
command
Section titled “command”string = ...
string = ...
Record<string, string> = ...
machineId
Section titled “machineId”string = ...
timeoutMs?
Section titled “timeoutMs?”number = ...
signal?
Section titled “signal?”AbortSignal
Returns
Section titled “Returns”Promise<{ args: string[]; command: string; executionTimeMs: number; exitCode: number; stderr: string; stdout: string; success: boolean; timedOut?: boolean; }>
initializeOwnership()
Section titled “initializeOwnership()”initializeOwnership(
pool?):Promise<void>
Initializes the Lakebase ownership and expiration store.
Parameters
Section titled “Parameters”LakebasePool
Returns
Section titled “Returns”Promise<void>
Throws
Section titled “Throws”When the AppKit Lakebase plugin did not provide a pool.
listMachines()
Section titled “listMachines()”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.
Parameters
Section titled “Parameters”client
Section titled “client”WorkspaceClient$1
userId
Section titled “userId”string
signal?
Section titled “signal?”AbortSignal
Returns
Section titled “Returns”Promise<{ auto: boolean; machines: object[]; supported: boolean; }>
openProjectTerminal()
Section titled “openProjectTerminal()”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.
Parameters
Section titled “Parameters”client
Section titled “client”WorkspaceClient$1
userId
Section titled “userId”string
projectId
Section titled “projectId”string
signal?
Section titled “signal?”AbortSignal
Returns
Section titled “Returns”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()
Section titled “projectList()”projectList(
client,userId):Promise<object[]>
Lists persisted projects for one AppKit user.
Parameters
Section titled “Parameters”client
Section titled “client”WorkspaceClient$1
userId
Section titled “userId”string
Returns
Section titled “Returns”Promise<object[]>
projectPathPrefix()
Section titled “projectPathPrefix()”projectPathPrefix(
userId):string
Returns the user-scoped project path prefix beneath the configured root path.
Parameters
Section titled “Parameters”userId
Section titled “userId”string
Returns
Section titled “Returns”string
reapMachines()
Section titled “reapMachines()”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.
Parameters
Section titled “Parameters”client
Section titled “client”WorkspaceClient$1
signal?
Section titled “signal?”AbortSignal
Returns
Section titled “Returns”Promise<SandboxReaperResult>
removeProject()
Section titled “removeProject()”removeProject(
client,userId,projectId,signal?):Promise<boolean>
Removes one project, runs optional mise stop and uninstall, then deletes its directory and route.
Parameters
Section titled “Parameters”client
Section titled “client”WorkspaceClient$1
userId
Section titled “userId”string
projectId
Section titled “projectId”string
signal?
Section titled “signal?”AbortSignal
Returns
Section titled “Returns”Promise<boolean>
resetProject()
Section titled “resetProject()”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.
Parameters
Section titled “Parameters”client
Section titled “client”WorkspaceClient$1
userId
Section titled “userId”string
projectId
Section titled “projectId”string
signal?
Section titled “signal?”AbortSignal
Returns
Section titled “Returns”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()
Section titled “startMachine()”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.
Parameters
Section titled “Parameters”client
Section titled “client”WorkspaceClient$1
userId
Section titled “userId”string
machineId
Section titled “machineId”string
signal?
Section titled “signal?”AbortSignal
Returns
Section titled “Returns”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()
Section titled “startReaper()”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.
Parameters
Section titled “Parameters”client
Section titled “client”WorkspaceClient$1
Returns
Section titled “Returns”Promise<SandboxReaperResult>
startService()
Section titled “startService()”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.
Parameters
Section titled “Parameters”client
Section titled “client”WorkspaceClient$1
userId
Section titled “userId”string
machineId
Section titled “machineId”string = ...
service
Section titled “service”"terminal" | "desktop" | "stats" = ...
signal?
Section titled “signal?”AbortSignal
Returns
Section titled “Returns”Promise<{ error?: string; kind: "terminal" | "desktop" | "stats"; openUrl: string; path: string; state: "error" | "starting" | "stopped" | "ready"; }>
stopMachine()
Section titled “stopMachine()”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.
Parameters
Section titled “Parameters”client
Section titled “client”WorkspaceClient$1
userId
Section titled “userId”string
machineId
Section titled “machineId”string
signal?
Section titled “signal?”AbortSignal
Returns
Section titled “Returns”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()
Section titled “withAuthFallback()”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.
Type Parameters
Section titled “Type Parameters”T
Parameters
Section titled “Parameters”operation
Section titled “operation”WorkspaceAuthOperation
attempt
Section titled “attempt”WorkspaceAuthAttempt<T>
Returns
Section titled “Returns”Promise<T>