Generated flows
Every node below is read out of the source the flow runs through — the route groups under packages/web/src/server/ that routes.ts reads and the EnsoObservation union in packages/core/src/observation.ts. Nothing here is drawn by hand, so a route or a kind that moves changes this page or fails the docs gate.
Control plane
Section titled “Control plane”The 32 control routes: what the browser can ask the runtime to do. Observation routes are the next diagram’s first stage rather than a second copy of it.
flowchart LR Browser["Browser"] Browser -->|PUT /api/models/settings| R_PUT_api_models_settings["respondToSectionWrite → writeSection"] Browser -->|PUT /api/permissions| R_PUT_api_permissions["respondToPolicyWrite → writePermissionPolicy"] Browser -->|POST /api/permissions/reset| R_POST_api_permissions_reset["respondToPolicyReset → resetPermissionPolicy"] Browser -->|POST /api/projects| R_POST_api_projects["respondToProjectRegistration → ProjectRegistry.register"] Browser -->|DELETE /api/projects/:projectId| R_DELETE_api_projects_projectId["respondToProjectRemoval → ProjectRegistry.remove"] Browser -->|PUT /api/projects/:projectId/config-approval| R_PUT_api_projects_projectId_config_approval["respondToProjectConfigApproval → createProjectSettingsRoute.approve → approveProjectTier"] Browser -->|PUT /api/projects/:projectId/settings| R_PUT_api_projects_projectId_settings["respondToProjectSettingsWrite → createProjectSettingsRoute.write → writeProjectThreadSettings"] Browser -->|PUT /api/projects/:projectId/title| R_PUT_api_projects_projectId_title["respondToProjectRetitle → ProjectRegistry.retitle"] Browser -->|PUT /api/projects/:projectId/trust| R_PUT_api_projects_projectId_trust["createProjectTrustRoute.write → saveProjectTrust"] Browser -->|DELETE /api/prompts/:id| R_DELETE_api_prompts_id["respondToPromptRemoval → PromptLibrary.remove"] Browser -->|PUT /api/prompts/:id| R_PUT_api_prompts_id["respondToPromptWrite → PromptLibrary.write"] Browser -->|POST /api/providers/login| R_POST_api_providers_login["respondToLogin → HostProviders.logIn"] Browser -->|POST /api/providers/login/answer| R_POST_api_providers_login_answer["respondToAnswer"] Browser -->|POST /api/providers/login/cancel| R_POST_api_providers_login_cancel["dispatchModelsRoute"] Browser -->|POST /api/providers/logout| R_POST_api_providers_logout["respondToLogout → HostProviders.logOut"] Browser -->|PUT /api/settings/projects| R_PUT_api_settings_projects["respondToConfigSection → writeProjectsSettings"] Browser -->|PUT /api/settings/projects/trust| R_PUT_api_settings_projects_trust["respondToSideWrite → writeDefaultProjectTrust"] Browser -->|PUT /api/settings/security| R_PUT_api_settings_security["respondToConfigSection → writeSecuritySettings"] Browser -->|PUT /api/settings/security/judge-key| R_PUT_api_settings_security_judge_key["respondToSideWrite → writeJudgeKey"] Browser -->|DELETE /api/threads/:threadId| R_DELETE_api_threads_threadId["respondToDelete → deleteThreadAt → AgentHost.deleteThread"] R_DELETE_api_threads_threadId --> H_respondToDelete_deleteThreadAt_AgentHost_deleteThread["deleteThreadAt()"] H_respondToDelete_deleteThreadAt_AgentHost_deleteThread --> Storage Browser -->|POST /api/threads/:threadId/abort| R_POST_api_threads_threadId_abort["respondToAbort → abortThread"] R_POST_api_threads_threadId_abort --> H_respondToAbort_abortThread["abortThread()"] H_respondToAbort_abortThread --> Runtime Browser -->|POST /api/threads/:threadId/command| R_POST_api_threads_threadId_command["respondToHostCommand → runHostCommand"] Browser -->|POST /api/threads/:threadId/configure| R_POST_api_threads_threadId_configure["respondToConfigure → configureThread"] Browser -->|POST /api/threads/:threadId/continue| R_POST_api_threads_threadId_continue["respondToContinue → continueThread → ThreadRuntime.continueRun"] R_POST_api_threads_threadId_continue --> H_respondToContinue_continueThread_ThreadRuntime_continueRun["continueThread()"] H_respondToContinue_continueThread_ThreadRuntime_continueRun --> Runtime Browser -->|POST /api/threads/:threadId/dialog| R_POST_api_threads_threadId_dialog["respondToDialog → answerThreadDialog"] R_POST_api_threads_threadId_dialog --> H_respondToDialog_answerThreadDialog["answerThreadDialog()"] H_respondToDialog_answerThreadDialog --> Runtime Browser -->|POST /api/threads/:threadId/fork| R_POST_api_threads_threadId_fork["respondToFork → forkThreadAt → AgentHost.forkThread"] R_POST_api_threads_threadId_fork --> H_respondToFork_forkThreadAt_AgentHost_forkThread["forkThreadAt()"] H_respondToFork_forkThreadAt_AgentHost_forkThread --> Storage Browser -->|POST /api/threads/:threadId/incidents/:incidentId/resolve| R_POST_api_threads_threadId_incidents_incidentId_resolve["respondToIncidentResolution → resolveThreadIncident → ThreadRuntime.resolveIncident"] R_POST_api_threads_threadId_incidents_incidentId_resolve --> H_respondToIncidentResolution_resolveThreadIncident_ThreadRuntime_resolveIncident["resolveThreadIncident()"] H_respondToIncidentResolution_resolveThreadIncident_ThreadRuntime_resolveIncident --> Runtime Browser -->|POST /api/threads/:threadId/mode| R_POST_api_threads_threadId_mode["respondToModeChange → changeThreadMode"] R_POST_api_threads_threadId_mode --> H_respondToModeChange_changeThreadMode["changeThreadMode()"] H_respondToModeChange_changeThreadMode --> Runtime Browser -->|POST /api/threads/:threadId/name| R_POST_api_threads_threadId_name["respondToRename → renameThreadAt → AgentHost.renameThread"] R_POST_api_threads_threadId_name --> H_respondToRename_renameThreadAt_AgentHost_renameThread["renameThreadAt()"] H_respondToRename_renameThreadAt_AgentHost_renameThread --> Runtime Browser -->|POST /api/threads/:threadId/prompt| R_POST_api_threads_threadId_prompt["respondToPrompt → promptThread"] R_POST_api_threads_threadId_prompt --> H_respondToPrompt_promptThread["promptThread()"] H_respondToPrompt_promptThread --> Runtime Browser -->|POST /api/threads/:threadId/restore| R_POST_api_threads_threadId_restore["respondToRestore → restoreThreadAt → AgentHost.restoreThreadAt"] R_POST_api_threads_threadId_restore --> H_respondToRestore_restoreThreadAt_AgentHost_restoreThreadAt["restoreThreadAt()"] H_respondToRestore_restoreThreadAt_AgentHost_restoreThreadAt --> Runtime Browser -->|POST /api/threads/:threadId/restore/undo| R_POST_api_threads_threadId_restore_undo["respondToRestoreUndo → undoLastRestore → AgentHost.undoLastRestore"] R_POST_api_threads_threadId_restore_undo --> H_respondToRestoreUndo_undoLastRestore_AgentHost_undoLastRestore["undoLastRestore()"] H_respondToRestoreUndo_undoLastRestore_AgentHost_undoLastRestore --> Runtime Storage["AgentHost (storage)"] Runtime["ThreadRuntime"] --> Observations["EnsoObservation stream"]
| Node | Contract | Input | Source |
|---|---|---|---|
respondToSectionWrite → writeSection |
PUT /api/models/settings |
body: EnsoModelsConfig — the whole section |
packages/web/src/server/models-routes.ts:495 |
respondToPolicyWrite → writePermissionPolicy |
PUT /api/permissions |
headers: exactly one precondition — If-Match: <ETag> (the version read), If-Match: * (whatever is there) or If-None-Match: * (no file); body: EnsoPermissionPolicyWrite — { file }, the whole file |
packages/web/src/server/permission-routes.ts:145 |
respondToPolicyReset → resetPermissionPolicy |
POST /api/permissions/reset |
header: If-Match: <ETag> or If-Match: *, or If-None-Match: * when there is no file; no body |
packages/web/src/server/permission-routes.ts:149 |
respondToProjectRegistration → ProjectRegistry.register |
POST /api/projects |
body: EnsoProjectRegistration — an absolute path strictly under a root the ENSO_HOME config declares (projects.roots), optional title (the name the rail and the project page show) |
packages/web/src/server/project-routes.ts:249 |
respondToProjectRemoval → ProjectRegistry.remove |
DELETE /api/projects/:projectId |
path: projectId (sixteen hex digits) |
packages/web/src/server/project-routes.ts:31 |
respondToProjectConfigApproval → createProjectSettingsRoute.approve → approveProjectTier |
PUT /api/projects/:projectId/config-approval |
path: projectId; body: EnsoProjectConfigApproval — the tier and the file’s SHA-256 as reviewed, null approving its removal |
packages/web/src/server/project-routes.ts:58 |
respondToProjectSettingsWrite → createProjectSettingsRoute.write → writeProjectThreadSettings |
PUT /api/projects/:projectId/settings |
path: projectId; body: EnsoProjectSettingsUpdate — the tier (shared, the project’s committed .enso/config.json, or local, its gitignored .enso/config.local.json) and the threads keys to set, null removing one |
packages/web/src/server/project-routes.ts:37 |
respondToProjectRetitle → ProjectRegistry.retitle |
PUT /api/projects/:projectId/title |
path: projectId (sixteen hex digits); body: EnsoProjectTitleUpdate — { "title": "…" }, not blank |
packages/web/src/server/project-routes.ts:45 |
createProjectTrustRoute.write → saveProjectTrust |
PUT /api/projects/:projectId/trust |
path: projectId; body: EnsoProjectTrustUpdate — { "trusted": true } trusts, false revokes |
packages/web/src/server/project-routes.ts:43 |
respondToPromptRemoval → PromptLibrary.remove |
DELETE /api/prompts/:id |
path: id; header: If-Match: <ETag> (the version read) or If-Match: * |
packages/web/src/server/prompt-routes.ts:49 |
respondToPromptWrite → PromptLibrary.write |
PUT /api/prompts/:id |
path: id; headers: exactly one precondition — If-None-Match: * (create: no file of that name), If-Match: <ETag> (replace the version read), If-Match: * (replace whatever is there); body: EnsoLibraryPromptWrite — name, description, category (system, append or session) and the markdown body |
packages/web/src/server/prompt-routes.ts:48 |
respondToLogin → HostProviders.logIn |
POST /api/providers/login |
body: EnsoProviderLoginRequest — provider, authType, and for an API key the apiKey, said once |
packages/web/src/server/models-routes.ts:507 |
respondToAnswer |
POST /api/providers/login/answer |
body: EnsoProviderLoginAnswer — questionId, value |
packages/web/src/server/models-routes.ts:511 |
dispatchModelsRoute |
POST /api/providers/login/cancel |
none | packages/web/src/server/models-routes.ts:513 |
respondToLogout → HostProviders.logOut |
POST /api/providers/logout |
body: EnsoProviderLogoutRequest — provider |
packages/web/src/server/models-routes.ts:499 |
respondToConfigSection → writeProjectsSettings |
PUT /api/settings/projects |
headers: exactly one precondition — If-Match: <ETag>, If-Match: * or If-None-Match: * (no file); body: EnsoProjectsSettingsWrite — { projects?, threads }, each section whole (no projects: no roots fence) |
packages/web/src/server/settings-routes.ts:193 |
respondToSideWrite → writeDefaultProjectTrust |
PUT /api/settings/projects/trust |
body: EnsoDefaultProjectTrustState — { defaultProjectTrust }: ask, always or never |
packages/web/src/server/settings-routes.ts:194 |
respondToConfigSection → writeSecuritySettings |
PUT /api/settings/security |
headers: exactly one precondition — If-Match: <ETag>, If-Match: * or If-None-Match: * (no file); body: EnsoSecuritySettingsWrite — { security }, the whole section |
packages/web/src/server/settings-routes.ts:177 |
respondToSideWrite → writeJudgeKey |
PUT /api/settings/security/judge-key |
body: EnsoJudgeKeyWrite — { value }, the key, or null to remove it |
packages/web/src/server/settings-routes.ts:178 |
respondToDelete → deleteThreadAt → AgentHost.deleteThread |
DELETE /api/threads/:threadId |
path: threadId; query: ?force=1 or none — no other; header: If-Match: "<sha256 hex of the work's words>" with ?force=1, the work the page showed (PR #572 review); no body. Deletes the thread (#571): the project’s pre-#573 snapshot stores migrated first, then its tree through the inventory, its snapshot store, and the project’s object store collected — what only this thread’s snapshots reached goes, its forks’ histories stay (#573) — then every session file under the id. The live session is retired only once the inventory has passed, and the id is refused for the server’s lifetime after |
packages/web/src/server/thread-routes.ts:41packages/web/src/server/follow.ts:1153 |
respondToAbort → abortThread |
POST /api/threads/:threadId/abort |
path: threadId; no body |
packages/web/src/server/thread-routes.ts:96packages/web/src/server/follow.ts:1224 |
respondToHostCommand → runHostCommand |
POST /api/threads/:threadId/command |
path: threadId; body: EnsoHostCommandRun — model with provider/id, thinking with a level, login with provider/authType, logout with a provider, compact with nothing; a view row (context, fork) is the page’s to do, never run |
packages/web/src/server/thread-routes.ts:100 |
respondToConfigure → configureThread |
POST /api/threads/:threadId/configure |
path: threadId; body: EnsoSessionConfiguration — optional systemPrompt (a prompt reference — a user prompt’s id, or project:<id> for the project’s own, #470 — system or append, or null for pi’s default; absent leaves the session’s as it is), model (provider/id), thinking (a level that model supports) and mode; or role (#904) in place of model and thinking — resolved from the user’s models section against the models on offer, applied as the model step, then recorded as an enso-model-role entry; applied in that order under one lease, a value equal to the current one left alone |
packages/web/src/server/thread-routes.ts:102 |
respondToContinue → continueThread → ThreadRuntime.continueRun |
POST /api/threads/:threadId/continue |
path: threadId; no body |
packages/web/src/server/thread-routes.ts:137packages/web/src/server/follow.ts:458 |
respondToDialog → answerThreadDialog |
POST /api/threads/:threadId/dialog |
path: threadId; body: DialogAnswer |
packages/web/src/server/thread-routes.ts:95packages/web/src/server/follow.ts:536 |
respondToFork → forkThreadAt → AgentHost.forkThread |
POST /api/threads/:threadId/fork |
path: threadId; body: EnsoForkRequest — entryId, the pi entry id of one of the thread’s user messages; the fork is pi’s /fork at position before, taken from the session file |
packages/web/src/server/thread-routes.ts:131packages/web/src/server/follow.ts:1022 |
respondToIncidentResolution → resolveThreadIncident → ThreadRuntime.resolveIncident |
POST /api/threads/:threadId/incidents/:incidentId/resolve |
path: threadId, incidentId (a UUID); body: EnsoIncidentResolution — classification, outcome, and restricted families only for resume-with-restrictions |
packages/web/src/server/thread-routes.ts:145packages/web/src/server/follow.ts:650 |
respondToModeChange → changeThreadMode |
POST /api/threads/:threadId/mode |
path: threadId; body: EnsoPermissionModeChange |
packages/web/src/server/thread-routes.ts:98packages/web/src/server/follow.ts:575 |
respondToRename → renameThreadAt → AgentHost.renameThread |
POST /api/threads/:threadId/name |
path: threadId; body: EnsoThreadRenameRequest — name, not blank, at most 120 characters, trimmed. Names the thread (#670) with pi’s own session_info entry — what pi’s /name writes — appended to the live session or the stored file; the stored listing and the history carry it as name, and the first prompt stays the title of a thread with none. Held as a restore is, so a name never lands between a run’s messages |
packages/web/src/server/thread-routes.ts:139packages/web/src/server/follow.ts:1127 |
respondToPrompt → promptThread |
POST /api/threads/:threadId/prompt |
path: threadId; body: EnsoPromptBody |
packages/web/src/server/thread-routes.ts:94packages/web/src/server/follow.ts:358 |
respondToRestore → restoreThreadAt → AgentHost.restoreThreadAt |
POST /api/threads/:threadId/restore |
path: threadId; body: EnsoRestoreRequest — entryId, a user message on the thread’s branch; the thread’s tree is put back to the snapshot its run began with (#551), the conversation untouched. The thread is held for the whole restore, as a run holds it, and the host admits no run meanwhile |
packages/web/src/server/thread-routes.ts:133packages/web/src/server/follow.ts:1096 |
respondToRestoreUndo → undoLastRestore → AgentHost.undoLastRestore |
POST /api/threads/:threadId/restore/undo |
path: threadId; body: EnsoRestoreUndoRequest — safety, the snapshot the restore kept. The thread’s tree back to its newest enso-tree-restored record’s safety (#565), only when it is that one — itself a restore, recorded with a safety of its own, so a second undo puts the first restore back. Held as a restore is |
packages/web/src/server/thread-routes.ts:135packages/web/src/server/follow.ts:1111 |
Observation pipeline
Section titled “Observation pipeline”One pi event becomes one observation and crosses six stages to reach the browser store. The union declares 26 kinds; the mapper produces 24 of them, and the rest are produced by the prompt route (see Observations for the per-kind producer, carrier and consumer).
flowchart LR Pi["pi runtime event"] Pi --> Mapper["mapPiEvent (24 kinds)"] Mapper --> Schema["EnsoObservation"] Schema --> Frame["observation frame"] Frame --> Connection["follow connection"] Connection --> Adapter["to-agui chunk"] Adapter --> Router["custom event router"] Router --> Store["browser store"]
| Stage | Contract | Source |
|---|---|---|
mapPiEvent (24 kinds) |
Observations | packages/web/src/host/map-events.ts:401 |
EnsoObservation |
Core exports | packages/core/src/observation.ts:681 |
observation frame |
Observations | packages/web/src/server/follow.ts:223 |
follow connection |
Routes | packages/web/src/follow-connection.ts:911 |
to-agui chunk |
Observations | packages/web/src/to-agui.ts:76 |
custom event router |
Observations | packages/web/src/custom-event-router.ts:275 |
Kinds, in the union’s order of declaration: text-delta, thinking-delta, tool-call, tool-result, custom-entry, permission-mode, permission-mode-rejected, model, message-start, message-end, session-usage, branch-compacted, login, turn-start, turn-end, provider-refused, provider-retry, provider-retry-ended, queue, prompt-rejected, extension-error, extension-ui-request, dialog-settled, run-ended, settled, unmapped.
