Expand description
the server lib: axum Router + handler set. Split out as a library so it can
be used from both main.rs (CLI) and integration tests.
§Endpoints
GET /v1/healthzPOST /v1/sessions/DELETE /v1/sessions(= operator attach / detach, Bearer sid)POST /v1/tasks(= unified Flow-form entry, Operator inject supported;operator_sidexplicitly pins the task to a registered Operator session, S2). Also creates aTaskRecord+RunRecord(issue #13 ID-hierarchy persistence) and echoes their ids in the response; see thetasksmodule doc. Always synchronous, guarded against hanging (GH #33) by a readiness precheck (503when the launch resolves to an operator-delegate path with zero attached operators) and atokio::time::timeoutceiling around the dispatch await (504on expiry) — seerun_flow_form’s doc comment.GET /v1/tasks— list every persistedTaskRecord(newest first).GET /v1/tasks/:id— aTaskRecordplus everyRunRecordkicked from it.POST /v1/tasks/:id/runs— re-kick an existing Task (newRunId, sameblueprint_ref/input_ctx).GET /v1/tasks/:id/runs/:run/steps/.../steps/:step/.../steps/:step/content— the metadata + content debug plane over a Run’s step OUTPUT (:runacceptslatestor an explicitR-<hex>,projection::McpQueryAdapter); see theprojectionmodule doc. This is the operator / human-debug counterpart to the Worker axis’scontext.stepspointer list onGET /v1/worker/prompt(projection-adapterST5 — replaces the ST2/ST4 single-valueGET /v1/tasks/:id/ctx).GET /v1/runs/:id— a singleRunRecord(itsstep_entriestrace included).POST /v1/operators/GET /v1/operators/:sid/DELETE /v1/operators/:sid/GET /v1/operators/:sid/ws(WS upgrade) — REST-like Operator login flow, Bearer-mandatory; the sole WS Operator session route. Seeoperator_ws::loginmodule doc.
The Enhance issue axis (/issues) lives in the issues module; callers merge
build_issues_router to integrate it into the same server.
§The 3 faces of the Operator role (= registered directly on the engine SoT)
The engine stateless-executor refactor removed the three
AppState registries (former HookRegistry / BridgeRegistry / OperatorRegistry);
all registration now goes directly to the engine SoT via
engine.register_spawn_hook / register_senior_bridge / register_operator.
WSOperatorSession (in the operator_ws module) registers all three traits
simultaneously under a single sid — one WS connection covers all 3 faces of
the Operator role, the canonical pattern.
§build_* family
build_router— minimal entry (=default_registry())build_router_with— caller provides aSpawnerRegistryand optionalBlueprintStore
The engine should be started with default_layer_registry (= Engine::new_with_layers);
otherwise Blueprint.spawner_hints is ignored.
Re-exports§
pub use blueprints::build_blueprints_router;pub use blueprints::build_blueprints_router_with_refs;pub use enhance_log::build_enhance_log_router;pub use enhance_settings::build_enhance_settings_router;pub use issues::build_issues_router;pub use issues::GetIssueResponse;pub use issues::PostIssueRequest;pub use issues::PostIssueResponse;pub use operator_ws::operators_create;pub use operator_ws::operators_delete;pub use operator_ws::operators_info;pub use operator_ws::operators_ws_connect;pub use operator_ws::ClientMsg;pub use operator_ws::OperatorSessionEntry;pub use operator_ws::ServerMsg;pub use operator_ws::WSOperatorSession;pub use projection::McpQueryAdapter;pub use projection::ProjectionSource;pub use projection::StepList;pub use projection::StepPathQuery;pub use projection::StepSummary;pub use tasks::RunKickRequest;pub use tasks::RunKickResponse;pub use tasks::TaskDetailResponse;pub use worker::worker_artifact;pub use worker::worker_prompt;pub use worker::worker_result;pub use worker::ArtifactQuery;pub use worker::PromptQuery;pub use worker::WorkerResultReq;
Modules§
- blueprints
- HTTP surface for inspecting/registering Blueprint state (
/v1/blueprints/*). HTTP surface for inspecting Blueprint state (= for debug / animation verification)./v1/blueprints/:id/headreturns the head Blueprint JSON;/v1/blueprints/:id/historyreturns the commit-version list. Callers pass a sharedStoreviaArcand mount the router. - config
- Server config file support (
~/.mse/config.toml, CLI > file > default merge). Server config file support (~/.mse/config.tomlby default). - data
/v1/data/*endpoints (v9 Big Response handling, Store-owner direct path). HTTP/v1/data/*endpoints (v9 Data path, for Big Response handling).- doctor
GET /v1/doctor— read-only startup config / Store snapshot.GET /v1/doctor— server-side infra info snapshot.- enhance_
log - HTTP surface for the
/v1/enhance/logaxis. HTTP surface for the/v1/enhance/logaxis. - enhance_
settings EnhanceSettingHTTP CRUD (/v1/enhance-settings*).EnhanceSettingHTTP CRUD (= K-V store entry +BPStorecommit orchestration).- issues
- HTTP surface for the Enhance issue axis (
/v1/issues*). HTTP surface for the Enhance issue axis (current design). - operator_
ws - WebSocket Operator Callback IF (
/v1/operators*). - projection
GET /v1/tasks/:id/runs/:run/steps*(the metadata + content debug plane over a Run’s step OUTPUT —McpQueryAdapter, a server-sidemlua_swarm::core::projection::ProjectionAdapterimpl reading through the Data-planeOutputStorewith a persistedRunRecord.result_reffallback). See the module doc for how this relates tooperator_ws::session’s in-flightFileProjectionAdapterhook andworker’s Worker-axiscontext.stepspointer assembly.McpQueryAdapter— server-side [ProjectionAdapter], and the REST hierarchy that serves a Run’s step OUTPUT as metadata + content (projection-adapterST5’s HTTP debug plane — replaces the ST2/ST4GET /v1/tasks/:id/ctxsingle-value endpoint /ProjectionResponse).- tasks
- HTTP surface for the Task/Run persistence axis (issue #13 ID hierarchy;
GET /v1/tasks,GET /v1/tasks/:id,POST /v1/tasks/:id/runs,GET /v1/runs/:id).POST /v1/tasksitself stays in this module (it is the entry pointtasks_startshares with the flow-eval path) — see thetasksmodule doc for the split rationale. HTTP surface for the Task/Run persistence axis (issue #13 ID-hierarchy reconciliation: Blueprint → Task → Run → Step → Attempt). - worker
/v1/worker/*endpoints (SubAgent self-fetch path). HTTP/v1/worker/*endpoints (SubAgent self-fetch path).
Structs§
- ApiError
- Uniform error response type for the handlers in this module. Converts to
a JSON
{"error": message}body with the given status viaIntoResponse. - AppState
- Shared axum handler state for the whole router. Cloned per-request (all
fields are
Arc/cheap-clone), constructed once inbuild_router_with_ws_factory. - Operator
Req - Operator inject sub-schema of
TaskLaunchRequest(kind/id/spawn_hook_id/senior_bridge_id/operator_backend_id/per_agent_kinds).pubfor the same cross-crate schema-generation reason asTaskLaunchRequest. - Session
Store - In-memory session map backing
/v1/sessionsattach/detach. - Status
Response - Response body for
GET /v1/status(issue #35 ST4 — lifecycle occupancy guard). Cheap-to-poll summary of “is it safe to kill this server right now”. - Task
Launch Reply tasks_start’s reply — aTaskLaunchResponseplus the HTTP status it rides out on (200 OKfor the synchronous path,202 Acceptedfor a detached launch, GH #37). A tuple struct with the body first so handler-level tests keep their established.0access to the response body regardless of which path produced it.- Task
Launch Request /v1/tasksPOST schema. Uses the flow-eval path and supports Operator inject (kind / spawn_hook / senior_bridge). Expressing a one-shot task as a 1-Step Blueprint is the only correct model.- Task
Launch Response /v1/tasksPOST response body.pubfor the same cross-crate schema-generation reason asTaskLaunchRequest.
Enums§
- TtlSource
- Which layer of the TTL cascade (request body → BP metadata → server
default) resolved
TaskLaunchResponse::effective_ttl_secs.pubfor the same cross-crate schema-generation reason asTaskLaunchRequest.
Functions§
- build_
router - Minimal entry point: builds a router with
default_registryand noBlueprintStore(Inline-only mode) orws_operator_factory. - build_
router_ full - 8-argument variant of
build_router_with_ws_factory_and_output. Passingbase_url = Some(...)(e.g."http://127.0.0.1:7777") makesWSOperatorSessionrender the actual server bind into the Spawn directive’sbase_urlline, so the receiving operator can copy the frame straight into a SubAgent prompt (issue #8).Nonepreserves the historical fallback (<check with mse_doctor>placeholder).task_store/run_storeswap the defaultInMemoryTaskStore/InMemoryRunStore(issue #13 ID-hierarchy persistence) for a caller-supplied backend (SqliteTaskStore/SqliteRunStore, for instance);Nonepreserves the process-volatile default.sync_timeout_secsis the server-wide fallback ceiling for thePOST /v1/taskssynchronous launch await (GH #33 Guard 2) — seeAppState::sync_timeout_secs/run_flow_form’s doc comment. - build_
router_ with - Build form where the caller supplies a registry and an optional
BlueprintStore. The Operator callback path (= external HTTP / WS callers acting as an Operator) must be pre-registered viaengine.register_*(= the engine is the SoT). See theoperator_wsmodule doc andOperatorInfo(engine-sidectx.rs) for details. - build_
router_ with_ ws_ factory - 4-argument variant of
build_router_with. Passingws_operator_factory = Some(arc)causes each WS connect to auto-register a newWSOperatorSessionunder its sid name with the factory (= akind=operatorAgentDef withoperator_ref: <sid>can then bind to the WS client backend). Callers are expected to also install the sameArcinto theSpawnerRegistryviareg.register::<OperatorSpawnerFactory>(arc.clone()). - build_
router_ with_ ws_ factory_ and_ output - 5-argument variant of
build_router_with_ws_factory. Passingoutput_store = Some(arc)swaps the defaultInMemoryOutputStorefor a caller-supplied backend (aSqliteOutputStore, for instance).Nonepreserves the historical behaviour (fresh in-memory store per call). - default_
layer_ registry - Default
LayerRegistryfor the server. Hint keys: - default_
registry - Default registry = Subprocess + RustFn (baseline
identityworker pre-baked) + empty Operator factory. - default_
registry_ with_ enhance_ flow - Opt-in registry that merges
default_registrywith the enhance flow (Lua factory + AgentBlock factory).