Shell Access
This page covers access to the server-side shell environment and its infrastructure. The terminal is the client-side interface that displays shell output and accepts learner input. For the terminal-to-shell gateway message contract, read Shell WebSocket Interaction. For constructing exercises, read Merlin Terminal Challenges.
Overview
The shell access system provides authenticated browser users with temporary interactive shell sessions in isolated shell pods.
Main components:
- Shell access token APIs
- Shell storage readiness API
- Shell gateway WebSocket service
- Shell extension token APIs
- Shell pods with per-user startup credentials
High-Level Flow
- Call
createShellAccessTokenV1. - Open
wss://.../wsusing the returnedgatewayUrl. - Send the initial connect payload with
sessionId,accessToken, andjwt. - Let the gateway consume the token, synchronize shell storage readiness, and create the shell pod.
- Exchange terminal traffic over WebSocket.
- Extend inactivity deadlines by calling
extendShellAccessTokenV1and then sending the returned extension token over WebSocket.
Token Creation
The create-token operation returns:
- a short-lived single-use
accessToken sessionIdtokenEIDexpiresAtgatewayUrl
If a startupScript is requested, the gateway resolves that pinned script and
sources it before the shell becomes interactive.
Storage Readiness
Before shell admission, the gateway ensures shell storage and quota state are ready for the session. This readiness step seeds missing quota records, reconciles limits, captures current usage, and returns the data the gateway needs to render startup quota notices.
Extensions
Shell sessions use two deadlines:
- Hard deadline: absolute maximum lifetime
- Soft deadline: inactivity deadline extended by the browser
The browser must periodically:
- Call
extendShellAccessTokenV1 - Send the returned extension token through WebSocket
- Update local deadline tracking from the returned
extend_ack
Available Shell Functionality
The shell image exposes a curated toolset suitable for learning and guided platform workflows. Clients should treat the session as ephemeral and avoid assuming desktop-like persistence beyond the documented storage behavior.
Shell Services
A shell session can host a separate, user-specific service such as a database, FTP server, or web application. A platform-vetted service definition pins the program, launch command, port, and content contract. An operator-created content registration pins challenge-specific data and a definition version. Instructors select existing registrations; registration writes require the operator’s content-write privilege.
The program and content are verified snapshots delivered to a separate service container whose files are not mounted into the interactive shell. The service’s network exposure depends on the selected definition; filesystem isolation alone does not establish network isolation. See Merlin Terminal Challenges for service contracts and the browser static-site definition’s exposure limits.
Supply contentRegistrationEID to
createShellAccessTokenV1
to request a service. The registration must belong to the session’s asserted
realm, and the user needs /shell-service/use in addition to /shell/access.
The registration may pin a definition from the Public catalog; service sessions
and content registrations use the teaching realm, not Public.
Terminal-only services are accessed from the shell using their documented
address and port. Browser access additionally requires the pinned definition
version’s browser-attachment capability. The token response includes
serviceBaseUrl, serviceAuthUrl, and serviceBrowserAttachable; the existence
of a URL alone does not establish browser eligibility.
Wait for the gateway’s service-status to report ready before browser
authorization. For a browser-attachable service, POST {serviceAuthUrl} with the
required session credentials obtains a one-time redeemUrl; opening it sets a
scoped, host-only cookie for serviceBaseUrl. The Merlin Terminal component
handles this flow when the author explicitly sets :service-browser-button: true.
See the protocol guide
for readiness messages and the authoring guide
for registration, embedding, and reset behavior.
Shell-Specific Entry Points
createShellAccessTokenV1consumeShellAccessTokenV1extendShellAccessTokenV1consumeShellExtensionTokenV1disconnectShellAccessTokenV1closeShellAccessTokenV1ensureShellStorageReadyV1createShellServiceDefinitionV1listShellServiceDefinitionsV2readShellServiceDefinitionV2updateShellServiceDefinitionV1deleteShellServiceDefinitionV1createShellServiceContentRegistrationV1listShellServiceContentRegistrationsV2readShellServiceContentRegistrationV2updateShellServiceContentRegistrationV1deleteShellServiceContentRegistrationV1readShellServiceBundleFileV1
Next Step
Read Shell WebSocket Interaction before implementing the browser terminal client.