Databricks App Terminal is a multi-session web terminal for Databricks Apps.
When running inside a Databricks App, terminal commands execute under the app's service principal identity. Databricks CLI is available in the runtime and works with app M2M auth out of the box.
- Browser terminal UI with tabs (
xterm.js) - In-memory PTY sessions (
node-pty, no tmux dependency) - Session lifecycle APIs (list/create/attach/input/resize/kill)
- Dynamic terminal type registry (filesystem-driven
terminal-types/*) - WebSocket terminal streaming
- Health/readiness/runtime diagnostics endpoints
- Structured API errors and structured logs
- Runtime-safe
npm install -gbehavior (redirected to writable app paths)
- If no sessions exist, a centered in-terminal TUI launcher opens first; backend session starts only after you choose a type.
- Tabs are always visible.
+opens the same in-terminal TUI launcher in the active tab.Cmd+T(macOS) /Ctrl+T(Windows/Linux) opens the same launcher.- Launcher controls:
↑/↓orj/k,Enter,Esc,1..9, plus?(help) anda(about). - Each tab shows a tiny auth badge (
m2m/user); click it to toggle auth mode for that session.- Some session types can pin auth mode via
authPolicy(user-only orm2m-only); pinned tabs show a locked auth badge and cannot be toggled.
- Some session types can pin auth mode via
- Tab titles follow terminal title escape sequences from the running shell/app.
Session types are discovered dynamically from terminal-types/* at startup.
- Built-in fallback default:
terminal(base shell, no extra launch script) - Custom type folder contract:
terminal-types/<type-id>/type.jsonterminal-types/<type-id>/launch.sh
type.jsoncan include optionalicon(unicode/custom glyph string) for CLI-style picker display.type.jsoncan include optionalauthPolicy(bothdefault, or pinneduser/m2m).type.jsoncan include optionaldefault: trueto make that type the default session type.type.jsoncan include optional integerorderto control picker/tab ordering (lower first).- Included profiles in this repo:
claude,codex,pi(plus built-interminal). - Bundled logo font assets live under
public/assets/terminal-icons(source SVGs inassets/terminal-icons/src). - Type launch scripts run on top of the base terminal runtime/auth model.
- Type-specific launcher behavior and shared helper conventions are documented in
terminal-types/README.md.
Inside Databricks Apps:
- commands run as the app service principal by default
- Databricks CLI is preinstalled in the runtime
- default CLI authentication uses app M2M context
Optional per-session user mode:
- create with
authMode: "user"(or toggle per-tab badge) - backend reads the forwarded user token header (
x-forwarded-access-tokenby default) - shell is seeded with
DATABRICKS_HOST+DATABRICKS_TOKENfor Databricks CLI calls as that user - built-in
dbx-authcommand supports switching in-shell (dbx-auth m2m,dbx-auth user) and prints current mode with no args
This keeps M2M as the safe default while allowing explicit user-delegated CLI sessions.
app.yaml and databricks.yml are included.
npm run build
databricks apps deploy --profile <PROFILE>Example:
databricks apps deploy --profile SHAREDGET /healthGET /readyGET /api/runtime/diagnostics
GET /api/session-types
GET /api/sessionsPOST /api/sessions(optional body:{ cwd?, cols?, rows?, authMode?: "m2m" | "user", typeId?: string })POST /api/sessions/:sessionId/attachPOST /api/sessions/:sessionId/inputPOST /api/sessions/:sessionId/resizePOST /api/sessions/:sessionId/auth-mode(body:{ mode: "m2m" | "user" })DELETE /api/sessions/:sessionId
Notes:
- auth mode is constrained by terminal type
authPolicyboth: mode can switch betweenm2manduseruser/m2m: mode is pinned and disallowed switches returnAUTH_MODE_NOT_ALLOWED_FOR_SESSION_TYPE
GET /ws/terminal?sessionId=<uuidv7>&cols=<n>&rows=<n>
Core runtime env vars:
APP_NAME(defaultdatabricks-app-terminal)HOST(default0.0.0.0)PORT(default8080)SHELL(default/bin/bash)WEB_ROOT(default./public)TERMINAL_TYPES_ROOT(default./terminal-types)STRICT_RUNTIME_CHECKS(defaulttrue)LOG_LEVEL(debug|info|warn|error, defaultinfo)LOG_PATH(default./logs/databricks-app-terminal.jsonl)
Session defaults:
SESSION_DEFAULT_CWD(default/app/pythonon Databricks, else current directory)
User mode (Databricks CLI delegation):
DATABRICKS_HOST(preferred) orDATABRICKS_SERVER_HOSTNAME(fallback)USER_ACCESS_TOKEN_HEADER(defaultx-forwarded-access-token)ALLOW_USER_TOKEN_AUTH(defaulttrue)
Writable tool paths (for global npm installs in sessions):
DBX_APP_TERMINAL_RUNTIME_ROOTDBX_APP_TERMINAL_TOOLS_ROOTDBX_APP_TERMINAL_NPM_PREFIXDBX_APP_TERMINAL_NPM_CACHE
Guardrails:
MAX_SESSIONSMAX_HISTORY_CHARSMAX_INPUT_BYTESMAX_WS_MESSAGE_BYTESWS_BACKPRESSURE_BYTESDEFAULT_COLS,DEFAULT_ROWS,MAX_COLS,MAX_ROWSSESSION_ENV_HOOK_TIMEOUT_MSDIAGNOSTICS_TTL_MS
npm install
npm run devQuality gates:
npm run check
npm test
npm run buildSee AGENTS.md for implementation details, architecture boundaries, and contributor/automation rules.
See RUNBOOK.md for deploy/run/troubleshooting procedures.
