User interfaces and automation
Surfpool provides several operational entrypoints for one local Solana environment. The command line configures and starts a Surfnet, HTTP services expose browser and machine access, the terminal UI shows live activity, and runbooks support repeatable actions and automation.
Operational model
The operational model separates environment startup from the ways a user controls or observes it. A Surfnet is Surfpool's local Solana-compatible network. The CLI creates it and selects its data source, while the other entrypoints use its services and events.
The CLI starts the core network early, then waits for the network to report that it can accept startup work. It plans project actions after that point and sends progress to the selected observation surface. This ordering lets users stop the process during startup and keeps HTTP, terminal, and headless operation on one lifecycle.
This diagram shows how a start request becomes a running local network and how each interface connects to that shared session.
flowchart LR
A[CLI start options] --> B[Surfnet and service startup]
B --> C[Startup readiness]
C --> D[Project setup plan]
D --> E[Running local network]
E --> F[HTTP and Studio access]
E --> G[Terminal UI or logs]
E --> H[Runbook actions and outputs]
H --> E
E --> I[Signal or RPC shutdown]
References: crates/…/mod.rs• L999-1057 crates/…/mod.rs• L45-177 crates/…/mod.rs• L201-305 crates/…/shutdown.rs• L191-218
Operational entrypoints
Each entrypoint supports a different operating style. They share the same running Surfnet, so a user can start with a command and then inspect or automate the result through another surface.
| Entry point | Main purpose | Best fit |
|---|---|---|
| CLI and HTTP server | Configure, start, stop, and serve Surfpool | Local development, scripts, and service hosting |
| Interactive terminal UI | Watch network activity and control the running environment | Hands-on local work |
| Runbook automation | Execute repeatable project actions with selected inputs and outputs | Setup, deployment, seeding, and CI workflows |
| Studio UI | Use the browser dashboard and scenario services | Browser-based inspection and control |
Command line entrypoint
The surfpool command is the main operational entrypoint. Its commands start or stop a local environment, list or execute runbooks, generate shell completions, update Surfpool, and start the MCP server for model-context clients. The start command groups settings for network access, project setup, accounts and state, runtime and UI, SVM behavior, and observability.
The start command can use a predefined Solana network, a custom RPC data source, or offline mode. It can also load snapshots, require strict snapshot loading, fund accounts, deploy programs through runbooks, watch program artifacts, persist state, select terminal, log-only, background, or CI operation, and lock selected cheatcodes for the life of the Surfnet.
References: crates/…/mod.rs• L116-184 crates/…/mod.rs• L232-573 crates/…/mod.rs• L739-783 crates/…/mod.rs• L999-1057
HTTP entrypoint
Surfpool serves HTTP access beside the local network. This surface gives clients access to service configuration, scenario resources, Studio when enabled, and a streamable HTTP MCP endpoint. It supports browser clients and machine clients without requiring them to drive the terminal UI.
Scenario resources use stable IDs. Repeating an identical create is safe, a different value under an existing ID is a conflict, and updates use the path ID as the record identity. Partial updates preserve fields that the request omits, while unknown fields and invalid values are rejected before the stored scenario changes. Unknown /v1 paths return JSON 404 responses instead of being mistaken for Studio routes.
The CLI also uses the Surfpool RPC endpoint for controlled shutdown. A stop request targets either an explicit RPC URL or a host and port, then expects a valid JSON-RPC response before it reports success. Process signals provide the other shutdown path and coordinate the local network with all HTTP services, including during startup.
References: crates/…/mod.rs• L44-112 crates/…/mod.rs• L134-399 crates/…/mod.rs• L195-230 crates/…/mod.rs• L1060-1120 crates/…/shutdown.rs• L191-218
Terminal entrypoint
The terminal UI is a live observation and control surface for a local Surfnet. It presents slot and epoch progress, logs, transaction results, service URLs, and runbook activity while allowing supported runtime controls.
The main view separates logs from transactions. Users can scroll the event stream, switch tabs, pause or resume the simulated clock, advance a slot, change block production mode, trigger a small transaction, and request a graceful exit. The UI sends these controls to the running Surfnet, while incoming network and runbook events update the display. Transaction rows include a Studio link when Studio is enabled; otherwise they show the transaction signature.
The terminal adapts its colors for limited-color environments. When a terminal is not suitable, the same operational path can use plain logs. Daemon mode and --no-tui use the headless event path, while CI mode also disables Studio, instruction profiling, and log output so scripts can rely on process status and machine outputs.
References: crates/…/simnet.rs• L39-69 crates/…/simnet.rs• L84-187 crates/…/simnet.rs• L252-339 crates/…/simnet.rs• L458-781 crates/…/simnet.rs• L954-1170 crates/…/mod.rs• L327-375
Studio entrypoint
Studio is the browser-facing dashboard for a running Surfpool session. It gives a user a visual way to inspect the local environment and work with scenario data through the HTTP services that Surfpool exposes.
Studio is optional. Disabling it does not prevent the local network or its HTTP API from starting, so the CLI, RPC services, terminal UI, and logs remain available as alternate surfaces. If Studio is disabled, the terminal shows the datasource URL instead of a Studio URL.
References: crates/…/mod.rs• L404-435 crates/…/mod.rs• L141-177 crates/…/mod.rs• L341-345 crates/…/mod.rs• L78-112
Runbook entrypoint
A runbook is a repeatable set of project actions declared in a workspace manifest or a runbook file. The CLI can list runbooks and execute one with chosen inputs and an environment.
Execution can be unsupervised or supervised through a browser or terminal console. It can report named outputs as JSON and retain execution state so later automation can distinguish completed work from new or changed work.
References: crates/…/mod.rs• L806-918 crates/…/mod.rs• L930-961 crates/…/mod.rs• L219-251
Configuration boundaries
The CLI collects the settings that shape a Surfpool session and passes the resulting service addresses to the observation surfaces. This keeps the choice of network, project actions, state, and display mode in one place.
| Configuration area | Operational choice |
|---|---|
| Network | Choose a known Solana network, a custom RPC data source, or offline mode. Set RPC and WebSocket bindings. |
| Project setup | Select a workspace manifest, startup runbooks, program deployment, and artifact watching. |
| Accounts and state | Set startup airdrops, account snapshots, strict snapshot loading, a storage namespace, and optional persistent state. |
| Runtime and display | Enable Studio, choose the terminal UI or logs, and run in the background or in CI. |
| SVM behavior | Set simulated slot timing, block production, feature overrides, validation behavior, and cheatcode access. |
| Observation | Select log detail, log location, transaction profile limits, plugins, and optional metrics. |
Listener addresses and advertised client URLs have different roles. This allows Surfpool to bind services on one interface while clients receive an address supplied for a proxy, container, or other public access path.
References: crates/…/mod.rs• L232-573 crates/…/mod.rs• L644-783 crates/…/endpoints.rs• L10-107
Startup and control flow
Startup makes the local services available and then prepares project setup. The CLI resolves the session settings, starts the local network, waits for its initial core event, selects the project actions, and sends progress to the chosen observation surface.
The startup plan can use an existing manifest runbook, create a runbook from detected project metadata, or build a plan in memory when runtime inputs require it. After startup, artifact watching can repeat the selected setup actions when deploy artifacts change. If a startup snapshot is strict and an account cannot be loaded, startup fails before the RPC service becomes usable.
This sequence shows the readiness boundary and the shared shutdown paths.
sequenceDiagram
participant U as User or script
participant C as CLI
participant H as HTTP services
participant S as Surfnet
participant R as Project runbooks
participant O as UI, logs, or HTTP client
U->>C: Choose start mode and settings
C->>H: Start service endpoints
C->>S: Start local network
S-->>C: Report core startup and readiness
C->>R: Select and dispatch project setup
R-->>C: Send progress and completion events
C-->>O: Expose status, logs, URLs, and results
O->>S: Send supported control actions
U->>C: Request stop or send a signal
C->>S: Coordinate termination
C->>H: Stop HTTP services
References: crates/…/mod.rs• L78-177 crates/…/mod.rs• L201-305 crates/…/mod.rs• L327-375 crates/…/mod.rs• L78-112 crates/…/strict_snapshot.rs• L18-97 crates/…/shutdown.rs• L191-218
Automation and observation choices
The right interface depends on whether a person needs to watch the session or a process needs a stable contract. Interactive surfaces favor immediate feedback. Headless and runbook surfaces favor logs, exit status, saved state, and JSON outputs.
| Need | Recommended surface | Result |
|---|---|---|
| Start a local network for development | surfpool start with the terminal UI | Live network activity and service URLs |
| Start without an interactive terminal | --no-tui, --daemon, or --ci | Process-oriented operation through logs and status |
| Inspect or manage the browser dashboard | Studio and HTTP services | Browser access to the running session |
| Repeat project setup or deployment | surfpool run or startup runbooks | Progress, saved state, and optional JSON outputs |
| Drive Surfpool from an agent client | MCP CLI or HTTP endpoint | Tool-based access to Surfpool actions |
| Reapply setup after local program builds | Artifact watching during start | Runbook progress after artifact changes |
The command tree also supports generated shell completions. This keeps shell discovery aligned with the public subcommands and grouped start options.
References: crates/…/mod.rs• L116-138 crates/…/mod.rs• L806-918 crates/…/mod.rs• L1122-1170 crates/…/mod.rs• L1278-1412
Change checklist
When these files or sections are changed, remember to consider these:
- Keep the CLI start groups aligned with the interfaces that consume their settings. A new runtime mode must define its behavior for the terminal UI, Studio, logs, and CI.
- Keep listener settings separate from client-facing URLs. A service can bind to a private interface while clients use a proxy URL.
- Preserve the shared lifecycle and progress events used by the terminal UI, headless logging, Studio, and runbook supervision.
- Keep startup shutdown safe before readiness and after readiness. Signals must stop the Surfnet and every HTTP listener without leaving ports open.
- Keep strict snapshot behavior aligned with the readiness boundary. A required account that cannot load must fail startup before clients can use RPC.
- Keep scenario API identity and patch rules aligned with browser and machine clients. The path ID must remain authoritative and invalid fields must not mutate stored data.
- Keep runbook execution modes mutually clear. Unsupervised, browser-supervised, and terminal-supervised runs must continue to produce the expected progress and output behavior.
- Keep stop targeting aligned with the JSON-RPC endpoint contract. Host and port targeting must remain exclusive with a full RPC URL.
- Keep cheatcode locking aligned with shutdown behavior. A locked Surfnet must have a documented process or signal path because RPC stop can be refused.
- Keep generated completion scripts aligned with the command tree and grouped start options.
- Keep terminal controls aligned with the commands sent to the Surfnet. Changes to pause, slot advance, block production, transaction triggering, or exit behavior must update the user-facing controls and their lifecycle effects.
- Keep terminal color output safe for both interactive terminals and redirected output. Color compatibility must not obscure event meaning on limited-color terminals.
Important failure modes
| Trigger | Consequence | Guard |
|---|---|---|
--rpc-url and --network are used together | Startup is rejected because the data source is ambiguous. | Choose one data source. |
| A strict snapshot contains an account that cannot be loaded | Startup fails before the RPC service becomes available. | Use valid snapshot data or remove strict loading when missing accounts are expected. |
| CI mode is used when visual inspection is expected | Studio and the terminal UI are disabled. | Use an interactive start mode for visual supervision. |
| A service binds to an unreachable interface or advertises the bind address behind a proxy | Clients cannot reach the advertised RPC, WebSocket, or Studio endpoint. | Set listener and advertised endpoint values for the deployment environment. |
surfpool stop has no port or RPC URL, or mixes a full URL with host and port | The stop request cannot identify one target. | Provide a port with an optional host, or provide one full RPC URL. |
| The stop RPC returns an invalid response or an RPC error | The CLI does not report a successful stop. | Keep the target online and allow the exit RPC method, or stop the process directly. |
| Cheatcodes are locked before shutdown | surfpool stop cannot use the exit RPC method. | Stop with Ctrl-C, a supported signal, or another process supervisor. |
| A runbook selects more than one execution mode | CLI argument parsing rejects the request. | Select unsupervised, browser, or terminal supervision. |
| Studio is disabled or fails to start | Browser access is unavailable, but the local network can still operate through other surfaces. | Use RPC, logs, or the terminal UI and inspect the Studio error. |
| The terminal is unavailable for an interactive start | The terminal UI cannot provide observation or control. | Use --no-tui or --ci and consume logs or machine outputs. |
| A scenario update contains an unknown field or invalid value | The request is rejected and the stored scenario remains unchanged. | Send a schema-valid scenario or patch. |
| A terminal control cannot send its Surfnet command | The requested pause, slot advance, block production change, transaction trigger, or exit does not affect the running session. | Keep the command channel available and use logs or RPC to confirm the resulting state. |
| A limited-color terminal receives the full color palette | Status and event levels can become hard to distinguish. | Use the terminal capability checks and safe color palette. |
Key files
| File | Why to read it |
|---|---|
| crates/…/mod.rs | Defines the public command tree, start configuration groups, runbook modes, snapshot strictness, shutdown behavior, and shell completion entrypoint. |
| crates/…/mod.rs | Shows how CLI settings become a running Surfnet, how readiness gates startup work, and how UI or headless operation is selected. |
| crates/…/endpoints.rs | Shows how service listeners and client-facing endpoints are resolved. |
| crates/…/startup.rs | Shows how project setup plans are selected and how startup progress and artifact watching affect operation. |
| crates/…/mod.rs | Defines the shared HTTP service, scenario resource contract, Studio serving, and machine-facing entrypoints. |
| crates/…/simnet.rs | Shows the live terminal observation, runtime controls, transaction view, graceful exit path, and terminal color behavior. |
| crates/…/macros.rs | Defines the CLI's shared colored status, warning, note, and error formatting while preserving plain output when stdout is not a terminal. |
| crates/…/mod.rs | Shows runbook execution modes, progress, saved state, and JSON outputs. |
| crates/…/lib.rs | Defines the embedded Studio browser surface. |
| crates/…/shutdown.rs | Verifies signal shutdown during startup and after readiness, including closure of all service ports. |
| crates/…/strict_snapshot.rs | Verifies that strict snapshot loading fails before RPC readiness when a required account is missing. |
| crates/…/Cargo.toml | Shows the CLI capabilities and optional features that enable interfaces such as Studio, supervisor UI, metrics, and MCP transport. |