openbutler-protocol 0.0.2

The wire contract between the OpenButler daemon and its clients: frame encoding, action envelopes, and the shared state types.
Documentation

openbutler-protocol

The wire contract between the OpenButler daemon and its clients: frame encoding, action envelopes, responses, and the shared session/state types. Shapes only — every rule, validation and computation lives in the daemon; this crate defines what the messages look like and nothing else.

Contract rules

  • Field names and JSON shapes are stable at the schema level: changing them is a breaking change for every consumer and needs a version bump. JSON object key order and whitespace are not part of the wire contract.
  • conformance/ holds semantic round-trip and negative vectors; tests/ proves encode → decode identity and rejects malformed variants against them.
  • Consumers pin a git revision while the wire is moving; each published crate version is cut from a tagged release of this repository.
  • The wire version and the crate's semver move together: a patch or minor release never changes the wire, and a wire change is a major bump of this crate that the owner approves before it ships. The envelope carries DAEMON_PROTOCOL_VERSION, and the host refuses a frame whose version differs from its own, so a mixed-version pair fails loudly instead of misreading a field.

Layout

  • src/ — envelope, framing, and the session/runtime/ledger types.
  • conformance/ — the wire vectors the tests decode and re-encode.
  • tests/ — conformance and action-payload suites.

Action catalog

GET /api/actions returns the ACTIONS catalog. Each entry names the action and its action-level exposure, mutates, viewOnly, and streams rules. When subcommands under one action have different exposure or mutation rules, the entry also carries commands:

{
  "name": "mcp.manage",
  "exposure": "remote",
  "mutates": true,
  "viewOnly": false,
  "streams": false,
  "commands": {
    "list": { "exposure": "remote", "mutates": false },
    "add": { "exposure": "local", "mutates": true },
    "remove": { "exposure": "local", "mutates": true }
  }
}

commands is optional and appears only for real per-command differences. schedule.manage uses it to distinguish its non-mutating capabilities, list, and log commands from its mutating commands. Entries without it retain their existing JSON shape. Action::new and Action::streaming leave it absent; Action::with_commands supplies the const metadata.

Writing your own client

Everything a client needs is published; no source reading required.

  1. Read the surface. GET /api/actions on a running host answers the full catalog — each action's exposure, mutates, viewOnly and streams rules — and GET /api/health answers readiness plus the wire and build identity. Both are unauthenticated.
  2. Pick a door. The local door (a named pipe on Windows, a unix socket elsewhere) and the WebSocket door at /ws carry the same newline-delimited JSON frames. POST /api/{action} carries one request and one envelope with Authorization: Bearer <token>; it refuses streams actions with a sentence, because their answers are followed by frames and only /ws can carry the whole stream.
  3. Authenticate. POST /api/login trades the account password for a device session token; the framed door's first frame carries that token (conformance/auth-first-frame.json is the vector).
  4. Attach before you send. attach answers bindingKey, and every session-bound action echoes the key in its payload — the host refuses a frame whose key does not match the connection's binding, so the client stores the key and returns it verbatim.
  5. Prove your codec. cargo test in this repository runs the conformance vectors under conformance/: decode → re-encode identity and the malformed rejections. Point your own encoder at the same JSON.

Build

cargo test