Skip to content

Class: AppKitSshPlugin

AppKit plugin for Databricks Sandbox lifecycle, SSH, service, and route operations.

The plugin registers owner-scoped REST routes, AppKit agent tools, HTTP proxy middleware, and WebSocket upgrade handling. It initializes SshRuntime with the existing service-principal Lakebase pool captured during setup and starts the expiration reaper.

new AppKitSshPlugin(config?): AppKitSshPlugin

Creates a plugin with a supplied shared runtime or a runtime from resolved config.

SshPluginConfig = {}

AppKitSshPlugin

ToolRegistryPlugin<SshPluginConfig>.constructor

protected app: AppManager

ToolRegistryPlugin.app


protected cache: CacheManager

ToolRegistryPlugin.cache


protected config: SshPluginConfig

ToolRegistryPlugin.config


protected optional context?: PluginContext

ToolRegistryPlugin.context


protected devFileReader: DevFileReader

ToolRegistryPlugin.devFileReader


protected isReady: boolean

ToolRegistryPlugin.isReady


name: string

Plugin name identifier.

ToolRegistryPlugin.name


readonly runtime: SshRuntime


protected streamManager: StreamManager

ToolRegistryPlugin.streamManager


protected telemetry: ITelemetry

ToolRegistryPlugin.telemetry


static manifest: object

config: object

schema: JSONSchema7 = SSH_CONFIG_SCHEMA

description: string = "Creates and manages Databricks Sandboxes over REST and SSH, with remote web routing and Mastra tools."

displayName: string = "Sandboxes"

name: "databricks-sandbox" = "databricks-sandbox"

resources: object

optional: never[] = []

required: never[] = []

stability: "beta" = "beta"


static phase: PluginPhase

Plugin initialization phase.

  • ‘core’: Initialized first (e.g., config plugins)
  • ‘normal’: Initialized second (most plugins)
  • ‘deferred’: Initialized last (e.g., server plugin)

ToolRegistryPlugin.phase

get protected toolRegistry(): ToolRegistry

Native AppKit tool entries exposed by this plugin.

ToolRegistry

ToolRegistryPlugin.toolRegistry

abortActiveOperations(): void

Cancel in-flight work (abort signals, SSE streams). Runs in the first phase of graceful shutdown, BEFORE any plugin’s shutdown() hook — so it must not tear down shared resources (e.g. connection pools) that other plugins’ hooks may still need. Put teardown in shutdown().

void

ToolRegistryPlugin.abortActiveOperations


addProject(userId, input): 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 Sandbox project with a persisted route.

string

Record<string, JSONType> = ...

string = ...

string = ...

string = ...

string = ...

number = ...

string = ...

boolean = ...

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

boolean = ...

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


asUser(req): this

Execute operations using the user’s identity from the request. Returns a proxy of this plugin where all method calls execute with the user’s Databricks credentials instead of the service principal.

Request

The Express request containing the user token in headers

this

A proxied plugin instance that executes as the user

AuthenticationError if user token is not available in request headers (production only). In development mode (NODE_ENV=development), skips user impersonation instead of throwing.

ToolRegistryPlugin.asUser


attachContext(deps?): void

Binds runtime dependencies (telemetry provider, cache, plugin context) to this plugin. Called by AppKit._createApp after construction and before setup(). Idempotent: safe to call if the constructor already bound them eagerly. Kept separate so factories can eagerly construct plugin instances without running this before TelemetryManager.initialize() / CacheManager.getInstance() have run.

unknown

TelemetryOptions

void

ToolRegistryPlugin.attachContext


clientConfig(): Record<string, unknown>

Returns browser-safe route defaults published through AppKit client config.

Record<string, unknown>

ToolRegistryPlugin.clientConfig


createMachine(userId, input?): 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 and assigns a managed Sandbox to one AppKit user.

string

boolean = ...

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(userId, machineId): Promise<{ deleted: boolean; }>

Deletes one assigned Sandbox.

string

string

Promise<{ deleted: boolean; }>


protected execute<T>(fn, options, userKey?): Promise<ExecutionResult<T>>

Execute a function with the plugin’s interceptor chain.

Returns an ExecutionResult discriminated union:

  • { ok: true, data: T } on success
  • { ok: false, status: number, message: string } on failure

Errors are never thrown — the method is production-safe.

T

(signal?) => Promise<T>

PluginExecutionSettings

string

Promise<ExecutionResult<T>>

ToolRegistryPlugin.execute


executeAgentTool(name, args, signal?, context?): Promise<unknown>

Executes one registered agent tool with the request resource and workspace identity.

string

unknown

AbortSignal

AgentToolExecutionContext

Promise<unknown>

ToolRegistryPlugin.executeAgentTool


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

Runs one command on an assigned Sandbox.

string

string[] = ...

string = ...

string = ...

Record<string, string> = ...

string = ...

number = ...

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


protected executeStream<T>(res, fn, options, userKey?): Promise<void>

T

IAppResponse

StreamExecuteHandler<T>

StreamExecutionSettings

string

Promise<void>

ToolRegistryPlugin.executeStream


exports(): object

Returns the typed sibling-plugin API for machine, command, service, route, and toolkit operations.

object

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

string

Record<string, JSONType> = ...

string = ...

string = ...

string = ...

string = ...

number = ...

string = ...

boolean = ...

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

boolean = ...

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

createMachine: (userId, input) => 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"; }>

string

boolean = ...

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: (userId, machineId) => Promise<{ deleted: boolean; }>

string

string

Promise<{ deleted: boolean; }>

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

string

string[] = ...

string = ...

string = ...

Record<string, string> = ...

string = ...

number = ...

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

listMachines: (userId) => Promise<{ auto: boolean; machines: object[]; supported: boolean; }>

string

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

listProjects: (userId) => Promise<{ pathPrefix: string; projects: object[]; }>

string

Promise<{ pathPrefix: string; projects: object[]; }>

openProjectTerminal: (userId, projectId) => 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"; }; }>

string

string

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"; }; }>

operations: (userId, userClient?) => object

string

WorkspaceClient$1

object

readonly add_ssh_project: AppKitOperation<ZodObject<{ config: ZodOptional<ZodRecord<ZodString, ZodJSONSchema>>; machineId: ZodString; name: ZodOptional<ZodString>; openPath: ZodOptional<ZodString>; path: ZodOptional<ZodString>; port: ZodOptional<ZodNumber>; projectId: ZodOptional<ZodString>; route: ZodOptional<ZodBoolean>; serviceDependencies: ZodOptional<ZodArray<ZodEnum<{ desktop: "desktop"; stats: "stats"; terminal: "terminal"; }>>>; stripPrefix: ZodOptional<ZodBoolean>; }, $strict>, unknown>

readonly create_ssh_machine: AppKitOperation<ZodObject<{ desktop: ZodOptional<ZodBoolean>; }, $strict>, unknown>

readonly delete_ssh_machine: AppKitOperation<ZodObject<{ machineId: ZodString; }, $strict>, unknown>

readonly execute_ssh_command: AppKitOperation<ZodObject<{ args: ZodDefault<ZodArray<ZodString>>; command: ZodString; cwd: ZodOptional<ZodString>; env: ZodOptional<ZodRecord<ZodString, ZodString>>; machineId: ZodString; timeoutMs: ZodOptional<ZodNumber>; }, $strict>, unknown>

readonly list_ssh_machines: AppKitOperation<ZodObject<{ }, $strict>, unknown>

readonly list_ssh_projects: AppKitOperation<ZodObject<{ }, $strict>, unknown>

readonly open_ssh_project_terminal: AppKitOperation<ZodObject<{ projectId: ZodString; }, $strict>, unknown>

readonly remove_ssh_project: AppKitOperation<ZodObject<{ projectId: ZodString; }, $strict>, unknown>

readonly reset_ssh_project: AppKitOperation<ZodObject<{ projectId: ZodString; }, $strict>, unknown>

readonly start_ssh_machine: AppKitOperation<ZodObject<{ machineId: ZodString; }, $strict>, unknown>

readonly start_ssh_machine_service: AppKitOperation<ZodObject<{ machineId: ZodString; service: ZodEnum<{ desktop: "desktop"; stats: "stats"; terminal: "terminal"; }>; }, $strict>, unknown>

readonly stop_ssh_machine: AppKitOperation<ZodObject<{ machineId: ZodString; }, $strict>, unknown>

removeProject: (userId, projectId) => Promise<boolean>

string

string

Promise<boolean>

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

string

string

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: (userId, machineId) => 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"; }>

string

string

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"; }>

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

string

string = ...

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

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

stopMachine: (userId, machineId) => 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"; }>

string

string

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"; }>

toolkit: (options?) => Record<string, ToolkitEntry>

ToolkitOptions

Record<string, ToolkitEntry>

ToolRegistryPlugin.exports


getAgentTools(): AgentToolDefinition[]

Tool definitions offered to an AppKit agent.

AgentToolDefinition[]

ToolRegistryPlugin.getAgentTools


getEndpoints(): PluginEndpointMap

PluginEndpointMap

ToolRegistryPlugin.getEndpoints


getSkipBodyParsingPaths(): ReadonlySet<string>

ReadonlySet<string>

ToolRegistryPlugin.getSkipBodyParsingPaths


injectRoutes(router): void

Router

void

ToolRegistryPlugin.injectRoutes


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

Lists valid assigned machines through the plugin’s active workspace identity.

string

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


listProjects(userId): Promise<{ pathPrefix: string; projects: object[]; }>

Lists persisted projects owned by one AppKit user.

string

Promise<{ pathPrefix: string; projects: object[]; }>


openProjectTerminal(userId, projectId): 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.

string

string

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"; }; }>


operations(userId?, userClient?): object

Returns the Zod-owned operation contracts used by REST, plugins, and agent tools.

string

WorkspaceClient$1

object

readonly add_ssh_project: AppKitOperation<ZodObject<{ config: ZodOptional<ZodRecord<ZodString, ZodJSONSchema>>; machineId: ZodString; name: ZodOptional<ZodString>; openPath: ZodOptional<ZodString>; path: ZodOptional<ZodString>; port: ZodOptional<ZodNumber>; projectId: ZodOptional<ZodString>; route: ZodOptional<ZodBoolean>; serviceDependencies: ZodOptional<ZodArray<ZodEnum<{ desktop: "desktop"; stats: "stats"; terminal: "terminal"; }>>>; stripPrefix: ZodOptional<ZodBoolean>; }, $strict>, unknown>

readonly create_ssh_machine: AppKitOperation<ZodObject<{ desktop: ZodOptional<ZodBoolean>; }, $strict>, unknown>

readonly delete_ssh_machine: AppKitOperation<ZodObject<{ machineId: ZodString; }, $strict>, unknown>

readonly execute_ssh_command: AppKitOperation<ZodObject<{ args: ZodDefault<ZodArray<ZodString>>; command: ZodString; cwd: ZodOptional<ZodString>; env: ZodOptional<ZodRecord<ZodString, ZodString>>; machineId: ZodString; timeoutMs: ZodOptional<ZodNumber>; }, $strict>, unknown>

readonly list_ssh_machines: AppKitOperation<ZodObject<{ }, $strict>, unknown>

readonly list_ssh_projects: AppKitOperation<ZodObject<{ }, $strict>, unknown>

readonly open_ssh_project_terminal: AppKitOperation<ZodObject<{ projectId: ZodString; }, $strict>, unknown>

readonly remove_ssh_project: AppKitOperation<ZodObject<{ projectId: ZodString; }, $strict>, unknown>

readonly reset_ssh_project: AppKitOperation<ZodObject<{ projectId: ZodString; }, $strict>, unknown>

readonly start_ssh_machine: AppKitOperation<ZodObject<{ machineId: ZodString; }, $strict>, unknown>

readonly start_ssh_machine_service: AppKitOperation<ZodObject<{ machineId: ZodString; service: ZodEnum<{ desktop: "desktop"; stats: "stats"; terminal: "terminal"; }>; }, $strict>, unknown>

readonly stop_ssh_machine: AppKitOperation<ZodObject<{ machineId: ZodString; }, $strict>, unknown>


protected registerEndpoint(name, path): void

string

string

void

ToolRegistryPlugin.registerEndpoint


removeProject(userId, projectId): Promise<boolean>

Removes one Sandbox project and its isolated directory.

string

string

Promise<boolean>


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

Wipes and recreates one persisted project from its saved configuration.

string

string

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


protected resolveUserId(req): string

Resolve the effective user ID from a request.

Returns the x-forwarded-user header when present. In development mode (NODE_ENV=development) falls back to the current context user ID so that callers outside an active runInUserContext scope still get a consistent value.

Request

string

AuthenticationError in production when no user header is present.

ToolRegistryPlugin.resolveUserId


protected route<_TResponse>(router, config): void

_TResponse

Router

RouteConfig

void

ToolRegistryPlugin.route


setup(): Promise<void>

Promise<void>

ToolRegistryPlugin.setup


shutdown(): Promise<void>

Detaches WebSocket handling and closes the shared runtime.

Promise<void>


startMachine(userId, machineId): 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.

string

string

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"; }>


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

Starts or reuses one built-in terminal or metrics service.

string

string = ...

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

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


stopMachine(userId, machineId): 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.

string

string

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"; }>


toolkit(options?): Record<string, ToolkitEntry>

Returns selected AppKit toolkit entries backed by this plugin’s agent tools.

ToolkitOptions

Record<string, ToolkitEntry>