Shell Access

Back to API Overview

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:

High-Level Flow

  1. Call createShellAccessTokenV1.
  2. Open wss://.../ws using the returned gatewayUrl.
  3. Send the initial connect payload with sessionId, accessToken, and jwt.
  4. Let the gateway consume the token, synchronize shell storage readiness, and create the shell pod.
  5. Exchange terminal traffic over WebSocket.
  6. Extend inactivity deadlines by calling extendShellAccessTokenV1 and then sending the returned extension token over WebSocket.

Token Creation

The create-token operation returns:

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:

The browser must periodically:

  1. Call extendShellAccessTokenV1
  2. Send the returned extension token through WebSocket
  3. 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

Next Step

Read Shell WebSocket Interaction before implementing the browser terminal client.