Skip to main content

Crate basis_acp

Crate basis_acp 

Source
Expand description

basis-acp — the ACP adapter: basis’s explicit protocol surface.

ACP is JSON-RPC 2.0 over stdio, LSP-style — the standard editors and web UIs already speak. Serving it is what makes basis embeddable without basis shipping a client: Zed, JetBrains, and acp-ui drive it as-is (PROPOSAL.md Bet 2, ADR-0002).

This is an adapter over basis and nothing else: the run lifecycle, the event stream and the seams are all the core’s, and what is here is the translation at one edge. Opt-in by dependency, so a host embedding the harness in-process never compiles a JSON-RPC server it does not run (ADR-0011). The binary exposes this adapter through the explicit basis serve --acp command on stdin/stdout; a bare basis invocation is reserved for usage and prompt shorthand (ADR-0017).

§Shape

  • session_update maps basis’s Event onto session/update. That mapping is the whole reason Event is basis’s own type rather than a re-export of mentra’s: one normalization, many surfaces.
  • AcpApprover answers mentra’s permission requests by asking the client, turning basis’s existing Approver seam into session/request_permission with no new plumbing.
  • SessionModes is the client’s permission switch: ACP session modes over basis’s Approver seam, applied in front of the approver so the answer can still change mid-session. The three modes are ApprovalMode, which is basis-acp’s own because an enumerable mode list is a protocol concept — the core has the trait and nothing else.
  • history replays a resumed conversation, which is what separates session/load from session/resume.
  • SessionRegistry holds the open conversations, keyed by mentra’s persisted agent id so that session/load is just Workspace::resume.
  • serve wires the handlers onto a connection, over one Runtime for the process and one Workspace per directory a client names (ADR-0018).
  • serve_stdio is the stdin/stdout transport, and the one place basis looks at what a peer sent before serving it.
  • available_commands and from_acp are the two mappings between a core convention and the wire: templates become the commands a client offers, and a client’s mcpServers become servers basis can register.

Structs§

AcpApprover
Puts approval requests to the ACP client.
AcpSession
One open conversation.
ModedApprover
Applies the session’s mode to each approval request, asking inner only when the mode says to ask.
ServeConfig
How a served connection is configured.
SessionModes
One session’s mode, and what the client has already answered under it.
SessionRegistry
Every conversation this connection is holding.

Enums§

ApprovalMode
What a session does about a call that changes state outside the process.
ModeError
Why a session/set_mode was refused.
StdioError
Why serving stdio ended.

Traits§

SessionSource
Where an ACP session’s PreparedRun comes from.

Functions§

available_commands
Maps discovered templates to the commands an ACP client can offer.
from_acp
Translates a client’s mcpServers into servers basis can register.
serve
Serves ACP over any transport, which is what makes the server testable in-process — see tests/acp/, which drives it over Channel::duplex().
serve_stdio
Serves ACP on stdin/stdout until the client disconnects.
session_update
Maps one basis event to an ACP session update.