memory-bank/components/supervisor-api.md
The Supervisor API defines the gRPC interfaces for the Supervisor service, which runs inside each workspace container and provides core functionality for workspace management, terminal handling, port forwarding, and other essential workspace operations. This API enables communication between various components and the supervisor process.
This API provides a standardized interface for:
The Supervisor API is implemented as a set of gRPC services defined in multiple Protocol Buffer files. These definitions are used to generate client and server code in various languages (Go, TypeScript, Java) for use by the supervisor and other components in the system.
Provides methods for workspace control operations:
ExposePort: Exposes a port from the workspaceCreateSSHKeyPair: Creates SSH keys for accessing the workspaceCreateDebugEnv: Creates a debug workspace environmentSendHeartBeat: Sends heartbeats to keep the workspace aliveProvides methods for retrieving workspace information:
WorkspaceInfo: Returns detailed information about the workspaceManages port forwarding and tunneling:
Tunnel: Notifies clients to install listeners on remote machinesCloseTunnel: Notifies clients to remove listeners on remote machinesEstablishTunnel: Establishes a tunnel for an incoming connectionAutoTunnel: Controls enablement of auto tunnelingRetryAutoExpose: Retries auto-exposing a portManages terminal sessions within the workspace:
Open: Opens a new terminal running the login shellShutdown: Closes a terminal, killing all child processesGet: Returns information about an opened terminalList: Lists all open terminalsListen: Streams terminal outputWrite: Writes input to a terminalSetSize: Sets the terminal's sizeSetTitle: Sets the terminal's titleUpdateAnnotations: Updates the terminal's annotationsManages workspace tasks:
ListenToOutput: Streams the output of a given taskProvides status information about the workspace:
Handles notifications within the workspace:
Manages authentication tokens:
Represents a terminal session:
Enum defining the visibility of a port tunnel:
none: Not visiblehost: Visible to the hostnetwork: Visible to the networkContains detailed information about a workspace:
Enum defining the type of debug workspace:
noDebug: Not a debug workspaceregular: Regular debug workspaceprebuild: Prebuild debug workspaceThe API uses Protocol Buffers version 3 (proto3) syntax, which provides forward and backward compatibility features. The service is designed to allow for the addition of new methods and message fields without breaking existing clients.
The Supervisor API uses Protocol Buffers and gRPC for defining interfaces. When changes are made to the .proto files, the corresponding code in various languages needs to be regenerated.
To regenerate the code:
Navigate to the supervisor-api directory:
cd components/supervisor-api
Run the generate script:
./generate.sh
This script performs the following actions:
protoc-gen-go and protoc-gen-go-grpcgenerate-java.shThe generate-java.sh script:
After regenerating the code, you may need to rebuild components that depend on the Supervisor API. This typically involves:
For Go components:
cd <component-directory>
go build ./...
For TypeScript components:
cd <component-directory>
yarn install
yarn build
For Java components:
cd <component-directory>/java
./gradlew build
Using Leeway (for CI/CD):
leeway build -D components/<component-name>:app
The Supervisor API is a critical component of the Gitpod platform, as it provides the interface through which various components interact with the workspace environment.