• English
  • Architecture

    Soma separates execution, presentation, and the data exchanged between them.

    Runtime layers

    soma-launcher → soma-cli → soma-core → soma-protocol
                                  ├────→ soma-rmcp-client → RMCP
                                  ├────→ soma-hooks → Node plugin host
                                  ├────→ soma-thread-store → soma-rollout
                                  └────→ soma-rollout → soma-protocol
    LayerResponsibility
    LauncherProvide the Rust executable and supply the browser asset directory
    CLIHost the local server, serve browser assets, and own terminal output
    CoreManage conversations, run model steps, and execute tools
    ProtocolDefine serializable snapshots and events

    Core performs no terminal output. The server exposes only explicit-ID thread and turn routes; the former implicit /api/thread and /api/turns routes are removed. Browser requests carry explicit thread IDs, so switching the selected conversation never redirects an in-flight request. The packages/cli launcher owns the executable entry point. Its @soma-ai/harness npm distribution selects a native package and supplies the bundled browser assets; local builds stage the same assets beside the launcher. The crates/cli library owns command routing and the local HTTP server. See npm distribution for packaging and release steps.

    The packages/desktop Electron host bundles that same executable and Web UI. Its main process owns the server lifecycle and updater; a sandboxed renderer uses the existing HTTP API and a narrow, sender-validated update IPC bridge. See Desktop application for packaging and update behavior.

    The MCP client crate owns stdio/HTTP transports and cancellable protocol requests. Core owns server configuration, per-runner connections, filtered catalogs, and model-facing handlers. See MCP servers.

    Core owns the persisted plugin catalog and activation flags. The browser owns disposable conversation views, including the built-in Trajectory plugin. Built-in UI plugins live in plugins/* workspace packages and depend on the shared packages/plugin-sdk and packages/ui packages, never Web app source. The hooks crate owns each session's Node process and callback IPC. Core supplies event snapshots and applies hook decisions at tool and turn boundaries. See JavaScript plugins.

    Ownership

    ThreadManager → Project → SomaThread
                                 ├─ Session → Thread → Turns → Steps
                                 ├─ StepRunner
                                 └─ Inbox and pending input

    The manager registers projects and conversation handles. Each SomaThread owns its session and runner behind an execution lock. One turn runs per thread; different threads can run concurrently.

    Main and workers are independent roots. Their role-specific system prompts and captured developer context agree: main delegates through create_thread and ends its turn for automatic reports; workers coordinate their child-agent trees. Configured permissions determine available tools.

    Opening projects

    The directory picker browses folders on the server host through POST /api/fs/read-directory, then opens the selected canonical path through the existing project registration API. It lists directories without uploading files or changing tool permissions. Host/Origin checks apply to directory reads.

    History and presentation

    Core retains execution history and model context. Session::snapshot() projects that state into the browser's Chat and Trajectory views. Provider-private replay data stays out of frontend contracts. Canonical JSONL history survives server restart; SQLite provides rebuildable catalogs. Core defines checkpoint ordering and reconstruction, the thread-store crate owns disk I/O and writer ownership, and rollout defines storage records. See Sessions.

    Soma follows Codex's manager, thread, session, and tool boundaries. The retained ADRs explain approved differences and inspected upstream revisions.

    Implementation: thread_manager.rs.