openapi: 3.1.0
info:
  title: another-agentic-system chat API
  version: 0.1.0
  description: |
    The only interface between the chat surface (web/) and the orchestrator
    (ADR 0009: the UI is swappable). Everything a user sees in a thread is derived
    from the thread's append-only event log (an Event, below); the UI renders it,
    it never invents state.

    Authentication ([ADR 0033](../decisions/0033-the-orchestrator-is-an-oauth2-resource-server.md)):
    the orchestrator is an OAuth2 resource server behind oauth2-proxy. With `auth.mode: jwt` the
    identity is the `Authorization: Bearer <JWT>` the proxy forwards (or a client's own token),
    validated against the issuer's keys; a request without a valid token gets 401 with
    `WWW-Authenticate: Bearer`, and 503 (`Retry-After`) while the keys cannot be fetched (fail
    closed, and `/readyz` with it). With the default `auth.mode: proxy_header` the orchestrator
    trusts `X-Auth-Request-Email` set by the proxy and rejects requests without it with 401.
    Local development may set `AUTH_DEV_USER` to inject a fixed identity (`proxy_header` only);
    it must be refused when unset.

    DPoP ([ADR 0054](../decisions/0054-the-web-holds-its-own-tokens-dpop-bound-in-indexeddb.md), RFC 9449):
    when `auth.dpop` is configured a request may carry `Authorization: DPoP <token>` and exactly one
    `DPoP` proof instead, for a token bound to the client's key (`cnf.jkt`). The proof is `typ` `dpop+jwt`,
    `ES256` or `EdDSA`, signed by the public `jwk` of its header, with `htm` the method, `htu` the public URL
    without query and fragment (one of `auth.dpop.publicOrigins` and the request's path), `iat` within 60
    seconds past and 5 ahead, a `jti` not seen within that window, and `ath` the hash of the token. A token
    that is bound to a key is **refused as a `Bearer`**. A refusal is 401 with
    `WWW-Authenticate: DPoP error="invalid_dpop_proof", algs="ES256 EdDSA"` (the proof) or
    `DPoP error="invalid_token", algs="ES256 EdDSA"` (the token, its binding, or a bound token sent as a
    bearer); a request with no credential gets both `Bearer realm="orchestrator"` and `DPoP algs="ES256 EdDSA"`.
    Without `auth.dpop` the `DPoP` scheme is refused and nothing else changes. `getPublicAuth` says where a
    browser signs in.

    Authorization ([ADR 0033](../decisions/0033-the-orchestrator-is-an-oauth2-resource-server.md),
    [`config.md`](config.md#roles-and-permissions)): who a person is says what they may do. The
    roles of the credential (the token's roles claim) map, by `auth.roles`, to the permissions
    `agent.read`, `agent.invoke`, `thread.read`, `thread.write`, `thread.share`, `thread.delete`, `artifact.read`, `admin`, `tools.user.add` and `prompts.share` (the last two granted to no role by default); a role
    the configuration does not define grants nothing, and a person with no defined role gets
    `auth.defaultRole`. `getMe` says what the caller's roles grant. **Nobody reads another person's
    thread** ([ADR 0039](../decisions/0039-nobody-reads-another-persons-thread.md)): every permission
    over threads is over the caller's own, for every role, `admin` included, which is operational and
    gives no access to what people wrote. The answers, everywhere below: **404** for a thread that is
    not the caller's (it is the answer for one that does not exist, so existence never leaks);
    **403** for a permission their roles lack (`code: forbidden`, whatever is asked for, so it says
    nothing of what exists), for an agent their roles do not name, and, for a person whose roles
    grant nothing at all, for every operation but `getMe` (`code: no_access`). A `Thread` carries its
    `owner`, the caller's own address.

    Sharing ([ADR 0040](../decisions/0040-thread-sharing-by-revocable-link.md)): the one way a person
    reads another person's thread is a link its owner made. `shareThread`, `rotateThreadShare` and
    `unshareThread` are the owner's (`thread.share`, except taking a link down, which needs only
    ownership); `getSharedThread` and `getSharedArtifact` are for a signed-in reader of `internal` (or
    `public`) links, `getPublicSharedThread` and `getPublicSharedArtifact` for **anybody**, outside
    the identity layer, for `public` links only, with `Authorization` ignored, rate limited (429 with
    `Retry-After`), `Cache-Control: no-store` and `X-Robots-Tag: noindex, nofollow`. **Every way a link can
    fail to be a readable one is the same 404, with the same body**: an unknown token, a bad MAC, a
    private or revoked thread, a cap that was lowered, a file that is not the thread's. A reader is
    read-only and never sees the owner's address (the owner is "the owner").

    Deleting ([ADR 0043](../decisions/0043-deleting-a-thread-erases-it.md)): `deleteThread` erases the
    caller's own thread, the threads made from it by an edit, their files and their links. It needs
    `thread.delete`, which **is not `thread.write`** (a person who may only read may still erase their own
    data), and is refused with a 409 `thread_active` while the thread works.

    People's own MCP servers ([ADR 0046](../decisions/0046-people-add-their-own-mcp-servers-secrets-in-a-credential-broker.md)):
    `createUserToolServer` and `updateUserToolServer` need `tools.user.add`, which **no role holds by default**;
    `listUserToolServers`, `listToolServers` and `deleteUserToolServer` do not, so a person whose permission was taken
    away still sees what they added and can remove it. **Another person's server is a 404**, whatever the caller's roles,
    and every route is a 404 in a deployment that has the feature off (`userToolServers.enabled`).
    **A request body that carries a secret is write-only**: the `secret` of `createUserToolServer` and
    `updateUserToolServer` is the token or the key of a server, and is in no response, error, log line or event; a
    response says only whether a credential is kept (`hasCredential`). These bodies are read without echoing a value, so
    even a malformed one never quotes what it held. The URL of a server is the person's own and is shown back to them (so
    that they can edit it); it can hold a secret in its path, so these answers are never cached.

    A person's prompt library ([ADR 0070](../decisions/0070-a-persons-prompt-library.md), [`prompts-v1.md`](prompts-v1.md)):
    `listPrompts`, `createPrompt`, `getPrompt`, `updatePrompt`, `deletePrompt` and `renderPrompt`. A prompt is its owner's;
    **a write that leaves it shared with a role needs `prompts.share`**, which no role holds by default and `admin` does
    not imply; unsharing and deleting need nothing. Another person's prompt, and a shared prompt the caller's roles are outside
    of, are a **404**, the answer for an id that never existed; an audience member reads and renders a shared prompt and
    never learns its author. A prompt is in no thread, fork or export.

    Interaction (start a thread, send a message, answer a question, follow a
    thread live) is AG-UI ([ADR 0012](../decisions/0012-ag-ui-user-facing-protocol.md)):
    the `/agui/*` operations below, with the mapping, the connect binding and
    the `vymalo.*` schemas in [`agui.md`](agui.md). Their request and event
    schemas are the vendored AG-UI 1.0 JSON Schema, referenced by file. The
    thread list, thread details, cancel, the agent list and health stay REST.

    Removed: the legacy REST interaction operations (`createThread`, `postMessage`,
    `listEvents`, `streamEvents`) were deprecated on 2026-09-29 and removed on 2026-09-30
    ([ADR 0012](../decisions/0012-ag-ui-user-facing-protocol.md)). `ORCH_SURFACES=chat-api` is
    now a startup error. No operation returns an `Event` any more; the `Event` schemas below
    describe the append-only log that AG-UI projects, which the goldens under
    [`examples/`](examples/README.md) pin.
servers:
  - url: /
security:
  - bearerToken: []
  - dpopToken: []
  - proxyIdentity: []
paths:
  /healthz:
    get:
      operationId: getHealth
      security: []
      summary: Liveness
      responses:
        "200": { description: Process is up }
        "503": { description: Shutting down }
  /readyz:
    get:
      operationId: getReady
      security: []
      summary: Readiness (database reachable, migrations applied)
      responses:
        "200": { description: Ready }
        "503": { description: Not ready }
  /api/me:
    get:
      operationId: getMe
      summary: Who the caller is, and what their roles let them do
      description: |
        The caller's identity (`user` is the key of what they own: the e-mail, lower-cased), the roles
        that count (the roles of the credential that `auth.roles` defines, or `auth.defaultRole` when
        none is), what those roles grant (`permissions`, each with its `scope` where it has one) and
        the agents `agent.read` and `agent.invoke` are about (`["*"]` for every agent; these are the patterns of the
        roles' `agents`, and **do not say the audience of an agent the platform's registry lists**, which `listAgents` does: it
        is filtered by it). A client uses it
        to show what its person may do and to hide what they may not; **it is never a check**: the
        orchestrator enforces every request whatever a client shows. It is the one operation that
        answers a person whose roles grant nothing (`roles` and `permissions` are then empty), so that
        a client can say why every other operation is a 403. Never cached.
      responses:
        "401": { $ref: "#/components/responses/Problem" }
        "200":
          description: The caller
          headers: { Cache-Control: { description: "`no-store`", schema: { type: string } } }
          content:
            application/json:
              schema: { $ref: "#/components/schemas/Me" }
  /api/me/usage:
    get:
      operationId: getMyUsage
      summary: What the caller used in a month, priced
      description: |
        The caller's own usage in one UTC calendar month, from the **usage ledger of the people**
        ([ADR 0065](../decisions/0065-a-usage-ledger-per-person.md)): the tokens their threads used, per provider and
        model, and the time the commands of their runs used in a sandbox, per shape of the sandbox, with a price on each
        line and a priced total. **There is no `owner` or `user` parameter and none will be**: the route answers for the
        authenticated person and for nobody else, whatever their roles (as `getMe` does; a person whose roles grant
        nothing reads their own usage too). Another key in the query is a 400. The answer is never cached.

        **What is counted.** A task (an agent's A2A task in a thread) counts once: its latest `model_usage_total` replaces
        its counts, and while it has none its `model_usage` calls add up (`usage-v1.md`). A task is counted in the UTC month
        of the **latest event that changed it**, whole, so a task that crosses a month end moves into the later month when
        its next event arrives and **the figure of a month that has ended is not final** while a task of it is open. The
        usage of a thread outlives the thread: erasing a thread does not remove it. Months older than
        `usage.retentionMonths` (24 by default, the current month one of them) are removed by a sweep and read as empty.

        **How it is priced** (`usage.prices` of the configuration, in integers, no floating point: money is millionths of
        the currency unit, written with exactly six decimals). The table is the **current** one: changing it re-prices every
        month, and `prices` says which table priced this answer (`sha256:` and 16 hex digits of its canonical form; `null`
        with no table). A model line costs `(inputTokens - cachedInputTokens) * input + cachedInputTokens * cachedInput +
        outputTokens * output` per million tokens, divided **once** by 1 000 000 and rounded half up; cached tokens are a
        part of the input (capped at it), tokens written to a cache are input tokens, and reasoning tokens are output
        tokens: none is a charge of its own. A line matches the table's entry for the same `provider` (a line with none
        matches an entry with none) and the same `model`, exactly. A sandbox line costs `hours * (cores * cpuCoreHour +
        gib * gibHour)` with `hours = milliseconds / 3 600 000`, `cores = cpuMillis / 1000` and `gib = memoryBytes / 2^30`,
        one exact fraction rounded half up; a shape that lacks `cpuMillis` or `memoryBytes` (the pod asked for none) has no
        price.

        **A line with no price is said so and is never counted as free.** `price` is `null` for a model the table does not
        price (or any model, when there is no table), for a sandbox shape the table does not price or that has no CPU or
        memory request, and for a line whose arithmetic would overflow; `unmeasured` lists the tasks whose commands ran where
        the sandbox is not measured (`local`, `devcontainer`), which are never priced. `total.amount` is the **sum of the
        priced lines**, and `total.complete` is `true` only when no line is unpriced and nothing is unmeasured (a month with
        no usage at all is complete, at `0.000000`); `total.unpriced` says what is missing. A client that shows the total
        shows it as "at least" when `complete` is `false`.
      parameters:
        - name: month
          in: query
          required: false
          description: "The UTC calendar month, `YYYY-MM` (a year from 0001 and a month from 01 to 12). The current UTC month by default. A month the ledger holds nothing for (in the future, or older than the retention) is an empty, complete answer, not an error"
          schema: { type: string, pattern: "^[0-9]{4}-(0[1-9]|1[0-2])$", example: "2026-10" }
      responses:
        "400": { description: "`month` is not `YYYY-MM` (or is given more than once), or the query has another key, `owner` included", $ref: "#/components/responses/Problem" }
        "401": { $ref: "#/components/responses/Problem" }
        "200":
          description: The caller's month
          headers: { Cache-Control: { description: "`no-store`", schema: { type: string } } }
          content:
            application/json:
              schema: { $ref: "#/components/schemas/MyUsage" }
  /api/agents:
    get:
      operationId: listAgents
      summary: Agents the user can target
      description: |
        Only the agents the caller may read: a role of theirs grants `agent.read` over the agent (`auth.roles`)
        **and**, for an agent the platform's registry lists, its **audience** lets them in
        ([ADR 0045](../decisions/0045-admin-dashboard-in-the-web-and-agent-access-from-the-registry.md)): the registry item's `audience`
        holds `"*"`, or one of the values of the caller's roles claim, or a role of theirs holds `admin`. A registry agent with no
        audience is therefore for administrators only; the deployment's own agents (`source: static`) have no audience. So this list,
        and not the patterns of `getMe`'s `agents` (which cannot say an audience), is what a client offers.

        The agents the deployment lists (`AGENTS_FILE`, `source: static`) and, when it reads one,
        the agents of the platform's registry (`source: registry`, [ADR 0022](../decisions/0022-platform-provisions-agents-system-discovers-them.md)).
        The list is read now, on every request: an agent added to the registry shows on the next
        request, and one it removed is gone. For each, the orchestrator reads the live agent card;
        `releases` is present only when the card advertises the release-channels extension (ADR 0008).
        Listed in display order, the static agents first; the first is the default target, which
        clients preselect. An agent whose card cannot be read stays in its place. A registry that
        cannot be read lists none of its agents (fail closed) and the static agents stay.
      responses:
        "401": { $ref: "#/components/responses/Problem" }
        "403": { description: "No role of the caller holds `agent.read` (`code: forbidden`), or their roles grant nothing (`code: no_access`)", $ref: "#/components/responses/Problem" }
        "200":
          description: Agent list
          content:
            application/json:
              schema: { type: array, items: { $ref: "#/components/schemas/Agent" } }
  /api/registry:
    get:
      operationId: getRegistry
      summary: Whether each source of agents could be read
      description: |
        How each source of the agent list answered on a read made now
        ([ADR 0022](../decisions/0022-platform-provisions-agents-system-discovers-them.md)): the
        deployment's own list (`static`, always `ok`) and, when the deployment reads one, the
        platform's registry (`platform`). A client reads it beside `listAgents` to say that the
        list is incomplete: a registry that cannot be read lists none of its agents (fail closed),
        and `listAgents` alone cannot tell "the platform has none" from "the platform cannot be
        reached". No agent card is read, and neither a URL nor a credential is in the answer.
        Never cached. It is about the agent list, so it takes `agent.read`.
      responses:
        "401": { $ref: "#/components/responses/Problem" }
        "403": { description: "No role of the caller holds `agent.read` (`code: forbidden`), or their roles grant nothing (`code: no_access`)", $ref: "#/components/responses/Problem" }
        "200":
          description: One status per source, in the order the sources are read
          headers: { Cache-Control: { description: "`no-store`", schema: { type: string } } }
          content:
            application/json:
              schema: { $ref: "#/components/schemas/Registry" }
  /api/config:
    get:
      operationId: getConfig
      summary: The public subset of the orchestrator's configuration, for the web
      description: |
        The `ui` section of the configuration file ([`config.md`](config.md#get-apiconfig),
        [ADR 0034](../decisions/0034-one-yaml-configuration-secrets-by-reference.md)): every key
        with its effective value, defaults filled in, and nothing else of the file. Behind the
        identity layer like every `/api/*` route (401 without an identity). It changes only when
        the process restarts. A client treats a missing key as its default and ignores a key it
        does not know, so the section grows additively.
      responses:
        "401": { $ref: "#/components/responses/Problem" }
        "403": { description: "The caller's roles grant nothing (`code: no_access`)", $ref: "#/components/responses/Problem" }
        "200":
          description: The public configuration
          content:
            application/json:
              schema: { $ref: "#/components/schemas/PublicConfig" }
  /api/tool-servers:
    get:
      operationId: listToolServers
      summary: The MCP servers a person may attach to a conversation
      description: |
        The servers the deployment offers for attaching ([ADR 0024](../decisions/0024-mcp-tools-attached-per-conversation.md),
        the `toolServers` section of [`config.md`](config.md)), in the order the deployment lists them, **then the person's
        own** ([ADR 0046](../decisions/0046-people-add-their-own-mcp-servers-secrets-in-a-credential-broker.md)), sorted by
        name: what the picker shows. **Neither a URL nor a header nor a credential is in it**, nor the allow-list of a
        server's tools, nor its timeout: the orchestrator calls the server for the agent and holds what it needs. `icon` is a
        `data:` URI the screen draws as it is; an icon at a URL is never offered, and a client never fetches one (open
        question 38). `agents` says which agents the server may be attached for, and is absent when it may be attached for
        every agent: a thread whose agent is not listed is refused (`putThreadTools`, 422). An empty list is a deployment
        with nothing to attach. Never cached. It takes `thread.write`, as attaching does.

        A server of the person's own has `own: true`, a `status` and, unless it is `ready`, a `reason`; a deployment's
        has none of the three, and in a deployment with the feature off the answer is exactly what it was. `ready` is a
        connected server; `needs_auth` is one that wants a key or an authorization from the person (a call to action, not
        an error); `unavailable` is one that is not offered for now, for a reason that clears with its cause. The status
        is the definition's state and the deployment's rules and **asks the credential broker for nothing**: a grant that
        ended is marked by the broker when it learns it, and by the relay when the broker says the credential ended or the
        server answers 401 or 403, so a server whose token ran out is `ready` here until then. A `ready` server of the
        person's own is attached with `putThreadTools` (a `u-` id); one that is not is refused there with a 422 whose
        `code` says which kind of reason it is. When a definition of the person's does not read back
        their own servers are left out of this list, the deployment's stay, and `listUserToolServers` says why. The same when the
        store of definitions cannot be read now (it is down): **the picker does not fail for it**, because it is how the
        deployment's servers are attached too and they do not depend on the person's definitions; the person's own are
        missing until the store is back, and `listUserToolServers` answers 503.
      responses:
        "401": { $ref: "#/components/responses/Problem" }
        "403": { description: "No role of the caller holds `thread.write` (`code: forbidden`), or their roles grant nothing (`code: no_access`)", $ref: "#/components/responses/Problem" }
        "200":
          description: The servers, the deployment's in its order and then the person's own
          headers: { Cache-Control: { description: "`no-store`", schema: { type: string } } }
          content:
            application/json:
              schema:
                type: array
                items: { $ref: "#/components/schemas/ToolServer" }
  /api/user-tool-servers:
    get:
      operationId: listUserToolServers
      summary: The person's own MCP servers, with what each is to them now
      description: |
        The caller's own servers ([ADR 0046](../decisions/0046-people-add-their-own-mcp-servers-secrets-in-a-credential-broker.md)),
        sorted by name, each with the URL they typed, the shape of its authentication (never a secret), its `state`, the
        `status` and `reason` the picker shows and the `revision` an edit sends back. Needs no permission of its own
        (`tools.user.add` gates changes, not reading what one added); another person's servers are not here, for any role.
        `limit` is the most one person holds (8) and `kinds` the kinds of authentication this deployment accepts: all four
        (`none`, `bearer`, `api_key`, `oauth2`) where it keeps credentials, and **only `none`** where it keeps none (it has no
        `secrets` section) (`orch_app::user_tool_kinds`, `orchestrator/crates/app/src/user_tools.rs`).

        **`status`** is the definition's state and the deployment's rules, with the first of these that holds:
        `unavailable` / `not_permitted` when the caller's roles lack `tools.user.add`; `unavailable` / `egress_refused`
        when today's egress lists refuse the server's address; `unavailable` / `broker_down` when the server wants a
        credential and this deployment keeps none; otherwise `ready` for `connected`, and `needs_auth` for `added`
        (`not_connected`), `needs_reauth` (`reauthorize`) and `revoked` (`disconnected`). It **asks the broker for
        nothing**: no token is refreshed for a listing.

        When a definition of the caller's does not read back, the store fails the listing as a whole: the answer is
        **200 with no servers and an `error`** (`unreadable`), because the other servers are not lost and none of the
        deployment's depends on this. Each server can still be deleted by its id (`deleteUserToolServer` reads nothing of
        the row); the answer cannot name the damaged one, and the orchestrator's log does (one warning per damaged row, by
        its id). A store that is down is a 503. Never cached. 404 when the feature is off.

        **Client recipe: the person's own servers** (what the web's "My tool servers" page does; a client needs nothing
        else, and the server enforces every step, so a client only offers what the server would accept).
        1. **Whether to offer the screen.** `getMe` lists `tools.user.add` for a person whose roles hold it. It does not say
           whether the deployment has the feature on: a holder in a deployment with it off gets a 404 from this route,
           which the screen says in words ("this deployment does not let people add servers") and offers nothing under.
           A person without the permission still reads their servers here and deletes them (`deleteUserToolServer` needs
           none); the screen says that their roles do not let them add or change one, and offers only Delete.
        2. **Add.** Offer the `kinds` of this answer and no others (a deployment that keeps no credentials lists only
           `none`). `POST` `{name, url, auth}` and, for `bearer` or `api_key`, `secret`; an `api_key` also names
           its `auth.header`, an `oauth2` its optional `scopes` and `clientId`. The answer is the server as listed: show its
           `status`, and for `oauth2` (`needs_auth`, `not_connected`) the **Connect** step below. Hold at most `limit`
           servers: when the list is that long the client does not offer Add, and the server's 409 `too_many_servers` is
           the race only. The `secret` is typed once, kept nowhere (not in storage, a URL or a log), cleared when the
           request is sent, and never filled in from an answer: no answer holds one.
        3. **Change.** `PATCH` takes any non-empty combination of `name`, `url`, `auth` and `secret`, and the `revision` of the row as
           listed (`orchestrator/crates/app/src/user_tools.rs`, `edit_user_tool_server`; an edit that names none of the first four is
           a 400). A client sends **only what differs** from the row the person opened the form on, with **that row's** `revision`
           (a form that is open while the list is read again keeps its own revision, so a stale edit is a 409 and never overwrites a
           newer change). What each does: `name`, or the `header` of an `api_key`, is written and the credential kept; `secret`
           alone (the kind must be `bearer` or `api_key`, else a 400) re-keys it and the server is `connected`, which also brings a
           `needs_reauth` or `revoked` one back; a new `url`, a new `auth.kind`, other `scopes` or another `clientId` forgets the
           credential first (the server is `added`, or `connected` if the kind is `none`), and a `secret` in the same request (kind
           `bearer` or `api_key`) is then kept for the new definition and the server is `connected`; any other combination is those
           effects together. A client says before it sends that a move forgets the credential. **Delete**: `DELETE` the id; it takes no
           revision, and a 404 answering it means the server is already gone, which is what was asked. A 409 `stale_revision` is not
           to be retried: read the list again and let the person decide again.
        4. **Connect** (an `oauth2` server that is `needs_auth`; and an `oauth2` server that is not, to authorize it again with
           another account or a wider scope, which the server allows): `POST` `.../authorize` with no body. Show the person where
           they are being sent, **before** anything opens, and open `authorizeUrl` **only when** it parses, is `https:` (or `http:`
           on a loopback host, for a development authorization server) and has no user information; `javascript:`, `data:`, a
           relative or a malformed link is never opened, and the client says the server gave a link that cannot be opened. The
           orchestrator takes the authorization endpoint from the authorization server's own RFC 8414 metadata and judges its shape
           (`https`, a public host, no fragment: `orchestrator/crates/credential-broker/src/discovery.rs`, `found_in`), **not** that
           it is on the issuer's host, so the client shows **the host of `authorizeUrl` itself** as the destination and, when it
           differs from the `issuer`'s, names both. Open it in a browser the client cannot lose control of: a link the person
           clicks (`target="_blank"`, no opener, no referrer) on the web, the system browser on the desktop, an in-app tab on mobile.
           A client cannot know that a window it opened stayed open (a pop-up blocker returns the same as success), so it says
           "waiting for you to finish signing in", never that a window opened, and offers **Check now** and **Open the sign-in page
           again** (`authorizeUserToolServer` again: a later call ends the earlier flow). It never logs or keeps the URL. The browser
           comes back to `finishUserToolAuthorization`, which no client calls. The client learns the outcome by reading this list
           again: when the person returns to the app (the window regains focus; the web reads at most once in a quarter second, so
           a focus and a visibility change together are one read) and on the person's request. `ready` is done; anything else after
           `expiresAt` is "not finished; connect again". A 429 `rate_limited` carries `Retry-After`.
        5. **Attach.** The picker is `listToolServers`: the person's own servers have `own: true`. Offer a `ready` one
           like any other and send the whole set with `putThreadTools`. One that is not `ready` is not offered for
           attaching: `needs_auth` says what to do (give a key, or Connect, on the screen above: `ToolServer` does not
           say which, so a client takes the kind from this list's `auth.kind` by id), `unavailable` says its `reason`.
           A 422 `tool_server_needs_auth` or `tool_server_unavailable` from `putThreadTools` is the race only.
        6. **Errors, by `code`** (a client chooses its words from the status and the `code`, and shows `detail` only where
           it is a person's own words: a 400's, which never quotes a value): 400 `url_refused` (the address is refused:
           `detail` says why for a person); 403 `forbidden` (the permission is gone) or `no_access`; 404 (the server is
           gone, or the feature is off: read the list); 409 `too_many_servers`, `stale_revision`; 422
           `credentials_not_kept` (add, change and authorize), `egress_refused` and `oauth_not_configured` (**`authorizeUserToolServer` only**: add and
           change answer a refused address as the 400 `url_refused`, `orchestrator/crates/app/src/user_tools/authorize.rs`); 429 `rate_limited`; 503 `broker_down`,
           `authorization_unavailable`, or no `code` (the server is being changed: wait `Retry-After` and try again).
           After **any** failed write whose outcome is unknown (a 500, a 503, a lost connection) the client reads this list
           again: a write runs to its end on the server whether or not the client waits.
      responses:
        "401": { $ref: "#/components/responses/Problem" }
        "403": { description: "The caller's roles grant nothing (`code: no_access`)", $ref: "#/components/responses/Problem" }
        "404": { description: "The deployment has people's own MCP servers off", $ref: "#/components/responses/Problem" }
        "503": { description: "Storage is unavailable (`Retry-After`)", $ref: "#/components/responses/Problem" }
        "200":
          description: The person's servers
          headers: { Cache-Control: { description: "`no-store`", schema: { type: string } } }
          content:
            application/json:
              schema: { $ref: "#/components/schemas/UserToolServers" }
    post:
      operationId: createUserToolServer
      summary: Add an MCP server of one's own
      description: |
        Adds a server for the caller ([ADR 0046](../decisions/0046-people-add-their-own-mcp-servers-secrets-in-a-credential-broker.md)).
        Needs `tools.user.add`, which no role holds by default. **Everything is checked before anything is written**: the
        name (1 to 80 characters, one line), the URL (`https`, a host, no user information, query or fragment, at most
        2 KiB, and the deployment's egress lists: a refusal is a 400 `url_refused` whose `detail` is the guard's reason for a
        person, never the precise rule and never an address), the header of an `api_key` (not one the orchestrator owns:
        `Authorization`, `Host`, `Content-Type`, `Mcp-*`, ...), the scopes and the client id of an `oauth2`, and the secret
        (8 to 4096 printable ASCII characters, none at either end a space; **8 is the shortest the relay can take out of
        what a server says back** without redacting ordinary words, so a shorter secret is a 400, ADR 0046 slice 5a review).

        * `none`: no `secret`. The server is `connected` at once.
        * `bearer` and `api_key`: the `secret` is required, the token or the key. The definition is written `added`, the
          secret goes to the credential broker, and the definition is replaced `connected` with the reference it gave.
          **If the broker cannot keep the secret the definition is taken back**: the answer is a 503 `broker_down`, the
          server is gone and no place of the eight is spent. **The add runs to its end on the server whether or not the
          client waits**: a client that hangs up, or the API's own timeout (30 s, which answers 503 and stops waiting),
          ends the response and not the add. Two things still leave a server behind: the take-back itself failing (the
          definitions' store is down at that moment), and the process stopping in the middle. The server is then `added`
          (`needs_auth`, `not_connected`), holds its place, and its owner gives it a key or deletes it.
        * `oauth2`: no `secret`. The server is stored `added` and has `status: needs_auth`, `reason: not_connected`; the
          person authorizes it with `authorizeUserToolServer`, and the browser comes back to
          `finishUserToolAuthorization`, which makes it `connected`.

        A deployment with no `secrets` section keeps no credentials: only `none` can be added (422
        `credentials_not_kept`). At most 8 servers per person: the ninth is a 409 `too_many_servers`.

        **`secret` is write-only**: it is in no response, error or log line (see the description of this API).
      requestBody:
        required: true
        content:
          application/json:
            schema: { $ref: "#/components/schemas/CreateUserToolServerRequest" }
      responses:
        "401": { $ref: "#/components/responses/Problem" }
        "201":
          description: The server, as the listing shows it
          headers: { Cache-Control: { description: "`no-store`", schema: { type: string } } }
          content:
            application/json:
              schema: { $ref: "#/components/schemas/UserToolServer" }
        "400": { description: "The body is not JSON or not an object of the members above, a value cannot be used (name, header, scope, secret), or the URL is refused (`code: url_refused`, the guard's public reason in `detail`)", $ref: "#/components/responses/Problem" }
        "403": { description: "No role of the caller holds `tools.user.add` (`code: forbidden`), or their roles grant nothing (`code: no_access`)", $ref: "#/components/responses/Problem" }
        "404": { description: "The deployment has people's own MCP servers off", $ref: "#/components/responses/Problem" }
        "409": { description: "`code: too_many_servers`: the caller holds 8 already", $ref: "#/components/responses/Problem" }
        "422": { description: "`code: credentials_not_kept`: the server wants a credential and this deployment keeps none", $ref: "#/components/responses/Problem" }
        "503": { description: "`code: broker_down` (`Retry-After`): the credential broker cannot keep the secret now, nothing was left behind; or the server was changed by another request before the add could connect it (no `code`, `Retry-After: 1`); or storage is unavailable", $ref: "#/components/responses/Problem" }
        "500": { description: "The write panicked or was ended before it finished (a bug, or the process stopping): fixed text, the cause is in the log. The write may have been made: read the list", $ref: "#/components/responses/Problem" }
  /api/user-tool-servers/{serverId}:
    parameters: [ { $ref: "#/components/parameters/UserToolServerId" } ]
    patch:
      operationId: updateUserToolServer
      summary: Change an MCP server of one's own, or give it a new key
      description: |
        Changes the caller's server ([ADR 0046](../decisions/0046-people-add-their-own-mcp-servers-secrets-in-a-credential-broker.md)).
        Needs `tools.user.add`. The members are `name`, `url`, `auth`, `secret` and `revision`, at least one of the first
        four; a value is checked as `createUserToolServer` checks it, before anything is read or written.

        | The change | What happens |
        |---|---|
        | `name`, or the `header` of an `api_key` | The definition is replaced. The credential is kept: it is bound to the URL, the kind and, for OAuth, the scopes and the client, not to a name or a header. |
        | `secret`, nothing else of the table below | The secret goes to the broker (only if the server still has the `revision` that was just read), then the definition is replaced `connected` with the new reference. Re-keys a `bearer` or `api_key` server, and brings a `needs_reauth` or `revoked` one back. |
        | `url`, the `kind`, the `scopes` (as a set) or the `clientId` of an `oauth2` | The credential was issued for the old ones, so **the definition is replaced `added` with no credential first** (a compare-and-swap on the `revision`: a write that fails, or a race that is lost, has revoked nothing), **and then the broker revokes the credential**. A revoke that fails is a 503 `broker_down` and leaves the server `added`, ready for a key; what the broker still holds is not named by the server and is not lent. With a `secret` for a `bearer` or `api_key`, the broker then keeps it for the new definition and the server is `connected`. A change to `none` makes it `connected`. |
        | nothing that differs | Nothing is written and the revision does not change. |

        `revision` is the one `listUserToolServers` gave: when the server changed since (the broker marked a grant that
        ended, another request edited it), the answer is **409 `stale_revision`** and nothing is written; read it again and
        decide again. The one exception is a new key: the broker keeps it in place of the old one before the definition is
        written (and only if the server still has the `revision` just before), so a writer that gets in within those
        milliseconds can leave the new key kept (and used) beside the 409 when the server still has a credential; a
        key kept for a server that the other writer moved, which then has none, is forgotten.
        Once the change has written the definition its `revision` is spent: a later conflict is read again and the change
        finished, never a 409 over a change that was made. Without a `revision` the change is made to the server as it is
        now (read again, up to three times, when the broker wrote in between; 503 after). A deployment that keeps no credentials refuses a change that would need the
        broker (a new URL or kind for a server that holds a credential, a kind that wants one): 422
        `credentials_not_kept`; the person deletes the server instead. **A change runs to its end on the server whether or not
        the client waits** (as the add does): a client that hangs up, or the API's own timeout, ends the response and not
        the change; the list says what was done. **`secret` is write-only.**
      requestBody:
        required: true
        content:
          application/json:
            schema: { $ref: "#/components/schemas/UpdateUserToolServerRequest" }
      responses:
        "401": { $ref: "#/components/responses/Problem" }
        "200":
          description: The server as it is now
          headers: { Cache-Control: { description: "`no-store`", schema: { type: string } } }
          content:
            application/json:
              schema: { $ref: "#/components/schemas/UserToolServer" }
        "400": { description: "As `createUserToolServer`, and an edit that names none of `name`, `url`, `auth` and `secret`", $ref: "#/components/responses/Problem" }
        "403": { description: "No role of the caller holds `tools.user.add` (`code: forbidden`), or their roles grant nothing (`code: no_access`)", $ref: "#/components/responses/Problem" }
        "404": { description: "The feature is off, or there is no such server for the caller: it never existed, was deleted, its id is not one, or it is another person's (one answer for all, whatever the roles)", $ref: "#/components/responses/Problem" }
        "409": { description: "`code: stale_revision`: the server changed since the `revision` the request is based on", $ref: "#/components/responses/Problem" }
        "422": { description: "`code: credentials_not_kept`: the change needs the credential broker and this deployment keeps no credentials", $ref: "#/components/responses/Problem" }
        "503": { description: "`code: broker_down` (`Retry-After`): the credential broker cannot revoke or keep a credential now (a change of URL or kind has then been written and the server is `added`: read it again); or the server kept changing under the edit (no `code`; the `detail` says that the server is being changed by another request, and `Retry-After` is 1); or storage is unavailable", $ref: "#/components/responses/Problem" }
        "500": { description: "As `createUserToolServer`: the write may have been made, read the list", $ref: "#/components/responses/Problem" }
    delete:
      operationId: deleteUserToolServer
      summary: Delete an MCP server of one's own, and forget its credential
      description: |
        Deletes the caller's server ([ADR 0046](../decisions/0046-people-add-their-own-mcp-servers-secrets-in-a-credential-broker.md)).
        **Needs no `tools.user.add`**: a person whose permission was taken away can still remove what they added and free
        the places they hold. Deleting is "revoke, then delete": the credential broker forgets the credential (and revokes
        it at the authorization server where it can) first, and a failure of that aborts the delete with the server still
        there, so a person tries again (503 `broker_down`); a server that wants no credential has none to revoke. A
        deployment that keeps no credentials cannot revoke and does not try: the definition is deleted, which a person must
        always be able to do. **A definition that does not read back is deleted by its id too**, its credential, if any,
        revoked first. The delete too runs to its end on the server whether or not the client waits, so a request that is
        dropped between the revoke and the delete still deletes. Nothing records the delete in a thread: a thread that
        had the server attached keeps the id. A second `DELETE` is a 404.
      responses:
        "204": { description: "The server is deleted and its credential forgotten" }
        "401": { $ref: "#/components/responses/Problem" }
        "403": { description: "The caller's roles grant nothing (`code: no_access`)", $ref: "#/components/responses/Problem" }
        "404": { description: "The feature is off, or there is no such server for the caller (never existed, already deleted, not an id, or another person's)", $ref: "#/components/responses/Problem" }
        "503": { description: "`code: broker_down` (`Retry-After`): the credential could not be revoked, so the server was not deleted; or storage is unavailable", $ref: "#/components/responses/Problem" }
        "500": { description: "As `createUserToolServer`: the write may have been made, read the list", $ref: "#/components/responses/Problem" }
  /api/user-tool-servers/{serverId}/authorize:
    parameters: [ { $ref: "#/components/parameters/UserToolServerId" } ]
    post:
      operationId: authorizeUserToolServer
      summary: Start the OAuth authorization of an MCP server of one's own
      description: |
        Starts the authorization code flow with PKCE of one of the caller's `oauth2` servers
        ([ADR 0046](../decisions/0046-people-add-their-own-mcp-servers-secrets-in-a-credential-broker.md), slice 4c). Needs
        `tools.user.add`, a deployment that keeps credentials and has an address for the OAuth callback
        (`userToolServers.oauth.callbackUrl`, or `server.publicUrl`). **There is no request body** (one is not read).

        The credential broker discovers the server's authorization server (the protected resource metadata of RFC 9728, then
        the authorization server's metadata of RFC 8414; it refuses one that does not offer PKCE `S256`), registers a client
        if it must, and keeps the PKCE verifier; the orchestrator keeps only `state` → (the caller, this server, until
        `expiresAt`). The answer is where to send the person: **the caller's client opens `authorizeUrl` in a browser** (the
        web in the page, the desktop in the system browser, mobile in an in-app tab) and shows `issuer`, the authorization
        server a stranger's MCP server chose, next to the button. The `state` is inside `authorizeUrl` and is not given
        beside it. When the person has consented, the authorization server sends the browser to the orchestrator's callback
        (`finishUserToolAuthorization`), which needs no session; the client then learns the new status from
        `listToolServers` or `listUserToolServers` (`ready` when it worked).

        A server that is already `connected` can be authorized again (another account, a wider scope): the grant is replaced
        when the callback finishes, and nothing is written before. A later call for the same server ends the earlier one: its
        `state` is no longer one. **Nothing of the definition is written by this operation.**

        **Rate limited per person**: ten calls a minute, in each process of the orchestrator (a burst of ten, then one more
        every six seconds). Every call counts, a refused one too. 429 with `Retry-After`.

        **What the answer and the authorization server see.** `authorizeUrl` is a link anybody can hand to somebody else, and
        the callback finds the person by the `state` and not by a session, so whoever opens it and consents completes the
        flow of the person who began it. The consent page is built from the client (`userToolServers.oauth.clientName`, the
        orchestrator's own name), the redirect URI, the `resource` (the server's URL) and the scopes; **nothing that names the
        owner, the server's id or the name the owner gave it is sent to an authorization server or in this answer**. Deployments
        should keep `tools.user.add` to roles they trust, list the authorization servers and MCP hosts they trust in
        `userToolServers.egress.allow`, and show `issuer` before the person consents (ADR 0046, "Amended 2026-10-15, slice 4c
        review", departure 125).

        **A name that does not resolve to a public address.** A URL whose name resolves to a private or reserved address is
        the 422 `egress_refused`; one that does not resolve is the 503 `authorization_unavailable`. The two answers tell the
        person who typed the URL a little about what a name resolves to; that is accepted, given the rate limit above.

        `Cache-Control: no-store`: `authorizeUrl` carries the `state` and the PKCE challenge.
      requestBody:
        required: false
        description: "None. A body, if one is sent, is not read"
      responses:
        "200":
          description: Where to send the person
          headers: { Cache-Control: { description: "`no-store`", schema: { type: string } } }
          content:
            application/json:
              schema: { $ref: "#/components/schemas/UserToolAuthorization" }
        "401": { $ref: "#/components/responses/Problem" }
        "403": { description: "No role of the caller holds `tools.user.add` (`code: forbidden`), or their roles grant nothing (`code: no_access`)", $ref: "#/components/responses/Problem" }
        "404": { description: "The feature is off, or there is no such server for the caller: it never existed, was deleted, its id is not one, it is another person's, or it is not an `oauth2` server (one answer for all, whatever the roles)", $ref: "#/components/responses/Problem" }
        "422": { description: "`code: credentials_not_kept`: this deployment keeps no credentials. `code: oauth_not_configured`: it has no address for the callback. `code: egress_refused`: a URL the authorization needs to fetch (the server's metadata, its authorization server's, the token endpoint) is refused by the deployment's egress lists or names a private or reserved address; `detail` is the guard's one sentence for a person, never the rule and never an address", $ref: "#/components/responses/Problem" }
        "429": { description: "`code: rate_limited`: too many authorization attempts by this person; `Retry-After` says when to try again", $ref: "#/components/responses/Problem" }
        "503": { description: "`code: authorization_unavailable` (`Retry-After`): the authorization could not be started now (the server publishes no usable metadata, its authorization server does not answer or does not offer PKCE `S256`, or the broker's store is down); the cause is in the orchestrator's log. Or storage is unavailable", $ref: "#/components/responses/Problem" }
        "500": { description: "The write panicked or was ended before it finished (a bug, or the process stopping): fixed text, the cause is in the log", $ref: "#/components/responses/Problem" }
  /api/user-tool-servers/oauth/callback:
    get:
      operationId: finishUserToolAuthorization
      summary: Where the browser comes back to after a person authorizes a server of their own
      description: |
        The `redirect_uri` of the OAuth authorization of a person's own MCP server
        ([ADR 0046](../decisions/0046-people-add-their-own-mcp-servers-secrets-in-a-credential-broker.md), slice 4c). **Outside
        the identity layer**: the browser that comes back is the system browser on the desktop and the in-app tab on mobile and
        carries neither the app's bearer token nor the web's cookie ([ADR 0047](../decisions/0047-one-ui-for-web-desktop-and-mobile-each-signs-in-as-a-public-oauth-client.md)),
        so no credential is read (an `Authorization` header or a cookie is ignored) and the person is found by the `state`
        alone: `state` → (who began, which server, until when), kept when the flow began and **taken once**. The edge must let
        a `GET` of this path through to the orchestrator with no sign-in (the dev stack's and the chart's edges do, since
        2026-11-14, and nothing else under `/api/user-tool-servers`; the chart still renders no `userToolServers` values: see the rollout steps
        of the ADR).

        The authorization server's redirect is read for `code`, `state`, `iss` (RFC 9207) and `error`, and nothing else
        (`error_description` is never read). A parameter that is one of the four and appears twice makes the request invalid and
        spends nothing. Then, whatever the outcome from the first callback that finds a pending `state` on, **the `state` is
        spent**: a callback with `error` (the person declined), with no `code`, whose `iss` the broker refuses (a mix-up), whose
        code the authorization server refuses, or that cannot be finished now, is over, and the person begins again
        (`authorizeUserToolServer`). Otherwise the broker exchanges the `code` (with the PKCE verifier and the `resource`), keeps
        the grant, and the server is made `connected`. The work runs to its end on the server whether or not the browser waits.

        The answer is a small HTML page with **fixed text**: nothing of the request (not the `code`, the `state`, the `iss`, the
        `error`, the server's name or URL, nor the person) is in it. It carries `Content-Security-Policy: default-src 'none'; frame-ancestors 'none'; base-uri 'none'; form-action 'none'`
        (no script and no style), `Referrer-Policy: no-referrer`, `Cache-Control: no-store`, `X-Content-Type-Options: nosniff`,
        `X-Frame-Options: DENY` and `X-Robots-Tag: noindex, nofollow`. The query is never logged. The page says whether the
        person can return to the app; the app learns the new status from `listToolServers`.

        `HEAD` is a **405**: a prefetch that asked for the headers must not spend the `state`. Rate limited with the other public
        routes, under a key of its own (the Client ID Metadata Document has another, so a flood of one cannot limit the other):
        a limited request is answered with **the same kind of page** (429, `Retry-After`, fixed words, the headers above) and
        its `state` is not spent, because it never reached the handler. A callback that takes longer than the API's request
        timeout is answered with the page "could not be finished" (503) and the same headers; the work runs on to its end.
      security: []
      parameters:
        - { name: code, in: query, required: false, description: "The authorization code (a secret until it is exchanged). Absent with `error`", schema: { type: string } }
        - { name: state, in: query, required: false, description: "The `state` of the authorization (a bearer value; it finds the person and the server)", schema: { type: string } }
        - { name: iss, in: query, required: false, description: "The issuer identifier of the authorization server that answered (RFC 9207), passed to the broker as it came", schema: { type: string } }
        - { name: error, in: query, required: false, description: "An OAuth error code: the person declined, or the authorization server refused. Its text is not read", schema: { type: string } }
      responses:
        "200":
          description: "The server is connected; the page says the person can return to the app"
          headers: &oauthCallbackHeaders
            Content-Security-Policy: { description: "`default-src 'none'; frame-ancestors 'none'; base-uri 'none'; form-action 'none'`", schema: { type: string } }
            Referrer-Policy: { description: "`no-referrer`", schema: { type: string } }
            Cache-Control: { description: "`no-store`", schema: { type: string } }
            X-Content-Type-Options: { description: "`nosniff`", schema: { type: string } }
            X-Frame-Options: { description: "`DENY`", schema: { type: string } }
            X-Robots-Tag: { description: "`noindex, nofollow`", schema: { type: string } }
          content:
            text/html: { schema: { type: string } }
        "400":
          description: "The link is not valid (no `state`, an unknown, used, replaced or ended one, a parameter given twice, a server that is gone or is no longer an `oauth2` one, one whose URL, scopes or client were changed since the authorization began, an `iss` the broker refuses), or the authorization was not completed (the person declined, no usable `code`, the authorization server refused it, the server was changed meanwhile). The page says which of the two, in fixed words"
          headers: *oauthCallbackHeaders
          content:
            text/html: { schema: { type: string } }
        "404": { description: "The deployment has people's own MCP servers off", $ref: "#/components/responses/Problem" }
        "405": { description: "`HEAD` (or another method): nothing was run, and no `state` was spent. `Allow: GET`" }
        "429":
          description: "Too many requests; `Retry-After` says when to try again. The page says so in fixed words, and the `state` is not spent"
          headers:
            Retry-After: { description: "Whole seconds, at least 1", schema: { type: integer, minimum: 1 } }
            Content-Security-Policy: { description: "`default-src 'none'; frame-ancestors 'none'; base-uri 'none'; form-action 'none'`", schema: { type: string } }
            Referrer-Policy: { description: "`no-referrer`", schema: { type: string } }
            Cache-Control: { description: "`no-store`", schema: { type: string } }
            X-Content-Type-Options: { description: "`nosniff`", schema: { type: string } }
            X-Frame-Options: { description: "`DENY`", schema: { type: string } }
            X-Robots-Tag: { description: "`noindex, nofollow`", schema: { type: string } }
          content:
            text/html: { schema: { type: string } }
        "503":
          description: "The authorization could not be finished now (the store, the broker or the authorization server could not be reached, or the callback took longer than the API's request timeout); the `state` is spent when the work reached it and the person begins again. The page says so"
          headers: *oauthCallbackHeaders
          content:
            text/html: { schema: { type: string } }
  /oauth/client-metadata.json:
    get:
      operationId: getOAuthClientMetadata
      summary: The orchestrator's OAuth client, as an authorization server fetches it
      description: |
        The **Client ID Metadata Document** of this orchestrator
        ([ADR 0046](../decisions/0046-people-add-their-own-mcp-servers-secrets-in-a-credential-broker.md), slice 4c;
        `draft-ietf-oauth-client-id-metadata-document`): the `client_id` the broker sends to an authorization server that says
        it supports such documents is the URL of this document, so the server fetches it instead of registering a client. **The
        path is the one of `userToolServers.oauth.clientMetadataUrl`**, an `https` URL with a path on the origin of the OAuth
        callback; `/oauth/client-metadata.json` is the path this contract uses as its example. It is served only while that key
        is set and credentials are kept, and is a 401 (the identity layer's, as for any path nothing serves) otherwise. The edge
        must route this path to the orchestrator and let a `GET` through with no sign-in: the fetcher is an authorization
        server.

        The document says: `client_id` (the URL, byte for byte as the broker sends it), `client_name`
        (`userToolServers.oauth.clientName`), `redirect_uris` (the callback and nothing else: the browser always comes back to
        the orchestrator), `grant_types` (`authorization_code`, `refresh_token`), `response_types` (`code`) and
        `token_endpoint_auth_method: none` (a public client with PKCE). It holds nothing secret and is made once at startup.
        Outside the identity layer; rate limited with the other public routes, under a key of its own (not the callback's); cacheable for five minutes.
      security: []
      responses:
        "200":
          description: The document
          headers:
            Cache-Control: { description: "`public, max-age=300`", schema: { type: string } }
          content:
            application/json:
              schema: { $ref: "#/components/schemas/OAuthClientMetadata" }
        "429": { description: "Too many requests; `Retry-After` says when to try again", $ref: "#/components/responses/Problem" }
  /api/search/threads:
    post:
      operationId: searchThreads
      summary: Search the caller's own threads by the words of their titles, descriptions and messages
      description: |
        The caller's own threads, and nobody else's ([ADR 0039](../decisions/0039-nobody-reads-another-persons-thread.md),
        [ADR 0068](../decisions/0068-a-person-searches-their-own-threads.md)): what it finds is always a **subset of what
        `listThreads` lists** for the same `archived` and `branches`, for every role (an administrator finds their own
        too). Another person's thread is never a hit, by its title or by its content. The permission is `thread.read`.
        A `POST`, though it is a safe read that writes nothing: the query is a person's words, and they must not be in a
        URL, a proxy's access log or a trace. The media type is exactly `application/json` (a parameter such as `charset` is
        allowed; `application/problem+json` and `application/json-seq` are not): any other is a 415. The checks run in
        one order, so two errors never leave a client guessing: 401, 429, 403, 415, then the body's shape (400
        `bad_request`: one JSON object, only the five members, each of its type, none twice, no `null`), `q` (400
        `query_empty`, `query_too_long`), `limit`'s range, `archived`, `branches`, the cursor (400 `bad_cursor`), and last
        the store (503). The vectors of `requests.json` hold every case.

        **Every rule is in [`thread-search-v1.md`](thread-search-v1.md), with vectors**: what a word is, how it is folded
        (`Café`, `cafe` and `CAFÉ` are one word; `cœur` is `coeur`), how the query is read, when a document matches (every
        term is the start of one word of one title, one description or one message), what is searched (titles,
        descriptions, a person's messages and an agent's **final** answers; not working text, reasoning, steps, tool
        results or file names), how the snippet is cut and its offsets, and the order. A second client reads that page and
        gets the same threads, snippets and order as this server.

        **Order:** `rank` descending (2: the title matches, 1: the description, 0: only messages), then the thread's `id`
        descending (the newest created first). A page that is read later differs from an earlier one only when a thread was
        renamed, deleted or written to in between.

        **Client recipe** (the server enforces every rule above; a client only offers the box):

        1. If `getConfig` has no `search`, offer no box.
        2. Debounce about 250 ms, cancel the request in flight when the text changes, and drop an answer that is not for
           the latest text.
        3. Send `{"q": text}`; do not trim, fold or bound it yourself. Draw each result with `thread.title`, and each
           hit's `snippet.text` split at `matches` (UTF-16 code unit offsets) into plain and marked runs, with an
           ellipsis where `cutStart` or `cutEnd`. Never interpret the text as markup. Say `messageHits` beyond the hits
           shown. `query.terms` says what was searched for.
        4. A message hit opens the thread at its `seq` (`getThreadHistory` with `since=<seq>`, as for a `#m-<seq>` link); a
           title or description hit opens the thread as usual.
        5. For more, send the same request with `cursor` set to `next`, until `next` is absent.
        6. On 429 wait `Retry-After`; on 503 say that the search is unavailable and offer to try again.

        A query that keeps no term (`a`, `!!`) is a 200 with `terms: []` and no result.
      requestBody:
        required: true
        content:
          application/json:
            schema: { $ref: "#/components/schemas/SearchThreadsRequest" }
      responses:
        "200":
          description: One page of results
          headers:
            Cache-Control: { description: "`no-store`: the page holds a person's words", schema: { type: string } }
          content:
            application/json:
              schema: { $ref: "#/components/schemas/ThreadSearchPage" }
        "400": { description: "`code: query_empty` (nothing is left of `q` after it is trimmed), `query_too_long` (more than 200 characters), `bad_cursor` (`cursor` is not a position of a page of this request: it is checked against the terms, `archived` and `branches` of the request, not the text of `q`, and a position that is not valid is refused); or `code: bad_request`: not JSON, not one object, a member that is not allowed (there is no `owner`: ADR 0039), a member twice, a member of the wrong type (`null` too), a lone surrogate, `limit` out of range or not an integer literal (`20.0` is refused), `archived` or `branches` not one of their words", $ref: "#/components/responses/Problem" }
        "401": { $ref: "#/components/responses/Problem" }
        "403": { description: "No role of the caller holds `thread.read`, or their roles grant nothing", $ref: "#/components/responses/Problem" }
        "415": { description: "The media type is not `application/json` (parameters such as `charset` are allowed)", $ref: "#/components/responses/Problem" }
        "429": { description: "`code: rate_limited`: a person searches in bursts of 20 and then twice a second; `Retry-After` says, in seconds, how long to wait", $ref: "#/components/responses/Problem" }
        "503": { description: "`code: search_unavailable`: the store is down, the whole search took more than 2 seconds, or this process is already running 8 searches (for everybody: it refuses at once and does not queue); `Retry-After` says, in seconds, when to try again", $ref: "#/components/responses/Problem" }
  /api/prompts:
    get:
      operationId: listPrompts
      summary: The caller's own prompts and the prompts shared with them, as summaries
      description: |
        A person's prompt library ([ADR 0070](../decisions/0070-a-persons-prompt-library.md),
        [`prompts-v1.md`](prompts-v1.md)): the prompts the caller owns and the ones **shared with a role of theirs**. It needs
        no permission of its own. **Summaries only**: no `body` and no `variables` (`variableCount` says how many), so the
        answer is small; `getPrompt` has the whole. Ordered by `id`, bytewise, **not by name**: a client sorts for display.
        `scope` is `all` (the default: the caller's own, and the shared ones), `mine` or `shared` (the caller's own are left
        out). `held` is how many prompts the caller owns, whatever the scope. A page holds at most `limit` (100); `nextCursor`
        is there when more follow, and is sent back as `cursor` (a position, never a capability: it is the id of the last
        prompt of the page before). A shared prompt has no `audience`, no owner and no created time: **it never names its
        author**. Never cached.

        **Client recipe: using a prompt.** (1) If `getConfig` has no `prompts`, offer no library. (2) List, and page with
        `nextCursor` until it is absent. (3) `getPrompt` for the one chosen. (4) Draw its `variables` as a `Choices` form with
        the client's own catalog renderer and collect the catalog's answer (`answers`); **a client that cannot draw a kind of
        question does not offer the prompt**. With no variables send `answers: []`. (5) `renderPrompt` with the `answers` and
        the `revision`; a 409 `stale_revision` means read the prompt again. (6) Put the `text` in the message box for the
        person to edit, and send it as an ordinary message: nothing here sends it. Draw a shared prompt's words as plain
        text, never as Markdown or HTML.
      parameters:
        - name: scope
          in: query
          description: "`all` (the default), `mine` or `shared`; anything else is 400 `bad_scope`"
          schema: { type: string, enum: [all, mine, shared], default: all }
        - name: cursor
          in: query
          description: "The `nextCursor` of the page before: a prompt id; anything else is 400 `bad_cursor`"
          schema: { type: string }
      responses:
        "200":
          description: One page of summaries
          headers:
            Cache-Control: { description: "`no-store`", schema: { type: string } }
          content:
            application/json:
              schema: { $ref: "#/components/schemas/PromptList" }
        "400": { description: "`code: bad_scope` or `bad_cursor`", $ref: "#/components/responses/Problem" }
        "401": { $ref: "#/components/responses/Problem" }
        "403": { description: "The caller's roles grant nothing (`code: no_access`)", $ref: "#/components/responses/Problem" }
        "503": { description: "The store cannot answer", $ref: "#/components/responses/Problem" }
    post:
      operationId: createPrompt
      summary: Save a prompt of one's own
      description: |
        Saves a prompt ([`prompts-v1.md`](prompts-v1.md)): `name` (`^[a-z0-9][a-z0-9-]{0,31}$`, unique for the caller),
        `title`, `description?`, `body` (text with `{{id}}` references; `\{{` writes `{{`), `variables?` (questions of the UI
        catalog, version 8, without `show` and without the type `images`: every one declared and used) and `audience?` (role
        values; `"*"` only alone; empty is private). **Sharing needs `prompts.share`** (no role holds it by default, `admin`
        included): a request whose audience is not empty without it is 403 `forbidden`, before the values are read. The
        checks run in one order (the vectors of `requests.json` and `prompts.json` hold them): 401, 403 `no_access`, 415, the
        shape (400 `bad_request`), 403 `forbidden`, the values (400 `bad_name`, `bad_title`, `bad_description`, `bad_body`,
        `bad_reference`, `bad_variable`, `undeclared_variable`, `unused_variable`, `bad_audience`, each with `at` and, for
        a reference, `offset` in UTF-16 code units), and last the store (409 `name_taken`, then `too_many_prompts`). The
        media type is exactly `application/json`, and the body at most 64 KiB. The caller holds at most 100. The text of a
        body, a title and an answer is in no log.
      requestBody:
        required: true
        content:
          application/json:
            schema: { $ref: "#/components/schemas/CreatePromptRequest" }
      responses:
        "201":
          description: The prompt as saved
          headers:
            Cache-Control: { description: "`no-store`", schema: { type: string } }
          content:
            application/json:
              schema: { $ref: "#/components/schemas/Prompt" }
        "400": { description: "`code: bad_request` (not one JSON object of these members, a member twice in any object of it, a member of the wrong type, `null`, a lone surrogate, a body over 64 KiB) or one of the codes above", $ref: "#/components/responses/Problem" }
        "401": { $ref: "#/components/responses/Problem" }
        "403": { description: "`code: forbidden` (a non-empty `audience` without `prompts.share`) or `no_access`", $ref: "#/components/responses/Problem" }
        "409": { description: "`code: name_taken` (the caller already has that name) or `too_many_prompts` (the caller holds 100)", $ref: "#/components/responses/Problem" }
        "415": { description: "The media type is not `application/json`", $ref: "#/components/responses/Problem" }
        "503": { description: "The store cannot answer", $ref: "#/components/responses/Problem" }
  /api/prompts/{promptId}:
    parameters: [ { $ref: "#/components/parameters/PromptId" } ]
    get:
      operationId: getPrompt
      summary: One prompt, with its body and variables
      description: |
        The caller's own prompt, or one shared with a role of theirs. **Anything else is 404, the same answer as for an id
        that never existed**: another person's private prompt, a shared prompt the caller's roles are outside of (an
        administrator included: `admin` reads no prompt that is not its own), an unshared one. A shared prompt's view has
        `own: false` and no `audience`. An id that is not `p-` and 12 characters of `[a-z0-9]` is 400 `bad_request`.
        Never cached.
      responses:
        "200":
          description: The prompt
          headers:
            Cache-Control: { description: "`no-store`", schema: { type: string } }
          content:
            application/json:
              schema: { $ref: "#/components/schemas/Prompt" }
        "400": { description: "`code: bad_request`: the id is not one", $ref: "#/components/responses/Problem" }
        "401": { $ref: "#/components/responses/Problem" }
        "403": { description: "The caller's roles grant nothing (`code: no_access`)", $ref: "#/components/responses/Problem" }
        "404": { description: "No such prompt for the caller (it never existed, was deleted, is private to another person, or is shared with roles the caller does not have)", $ref: "#/components/responses/Problem" }
        "503": { description: "The store cannot answer", $ref: "#/components/responses/Problem" }
    patch:
      operationId: updatePrompt
      summary: Change a prompt of one's own, or share it, or take its share back
      description: |
        Changes the caller's own prompt. **`revision` is required** (the one the last read gave) and at least one other
        member must follow: a member given **replaces the whole member** (`variables` is the whole list, `audience` the whole
        set). The checks run in this order: 401, 403 `no_access`, 415, the shape (400 `bad_request`), **404** (the prompt is
        not the caller's: another person's, shared with them, or not there), **403 `forbidden`** (the **resulting** audience
        is not empty and the caller lacks `prompts.share`: a person who lost it can still send `audience: []`, and nothing
        that leaves a share in place), **409 `stale_revision`** (the prompt changed since the `revision`), then the values of
        the whole prompt as it would be (the codes of `createPrompt`), and last 409 `name_taken`. A request that changes
        nothing writes nothing and keeps the revision. A write is one statement.
      requestBody:
        required: true
        content:
          application/json:
            schema: { $ref: "#/components/schemas/UpdatePromptRequest" }
      responses:
        "200":
          description: The prompt as it is now
          headers:
            Cache-Control: { description: "`no-store`", schema: { type: string } }
          content:
            application/json:
              schema: { $ref: "#/components/schemas/Prompt" }
        "400": { description: "`code: bad_request` (as `createPrompt`, and no `revision`, a `revision` that is not `^[1-9][0-9]{0,18}$`, or nothing to change) or a code of the values", $ref: "#/components/responses/Problem" }
        "401": { $ref: "#/components/responses/Problem" }
        "403": { description: "`code: forbidden` or `no_access`", $ref: "#/components/responses/Problem" }
        "404": { description: "No such prompt of the caller's", $ref: "#/components/responses/Problem" }
        "409": { description: "`code: stale_revision` or `name_taken`", $ref: "#/components/responses/Problem" }
        "415": { description: "The media type is not `application/json`", $ref: "#/components/responses/Problem" }
        "503": { description: "The store cannot answer", $ref: "#/components/responses/Problem" }
    delete:
      operationId: deletePrompt
      summary: Delete a prompt of one's own
      description: |
        Deletes the caller's own prompt. **Needs no `prompts.share`**: a person can always withdraw what they shared. With
        `?revision=N` (optional) it is 409 `stale_revision` when the prompt changed since. Another person's prompt, a
        shared one and an absent one are all 404. Nothing of a thread is touched: a prompt is in no thread.
      parameters:
        - name: revision
          in: query
          description: "The revision the caller last read; when it is there and the prompt has another, 409 `stale_revision`. Not `^[1-9][0-9]{0,18}$` is 400 `bad_request`"
          schema: { type: string }
      responses:
        "204": { description: Deleted }
        "400": { description: "`code: bad_request`: the id or the `revision` is not one", $ref: "#/components/responses/Problem" }
        "401": { $ref: "#/components/responses/Problem" }
        "403": { description: "The caller's roles grant nothing (`code: no_access`)", $ref: "#/components/responses/Problem" }
        "404": { description: "No such prompt of the caller's", $ref: "#/components/responses/Problem" }
        "409": { description: "`code: stale_revision`", $ref: "#/components/responses/Problem" }
        "503": { description: "The store cannot answer", $ref: "#/components/responses/Problem" }
  /api/prompts/{promptId}/render:
    parameters: [ { $ref: "#/components/parameters/PromptId" } ]
    post:
      operationId: renderPrompt
      summary: Fill a prompt's variables and get the text, without sending anything
      description: |
        Substitutes the person's `answers` into the prompt's body and returns the text. **It writes nothing**: no message is
        sent, no thread is touched, and the answer is in no log. Allowed for the caller's own prompts and for the ones
        shared with them. `answers` is the [Choices answer](ui-catalog-v1.md#choices-answers) to the prompt's variables:
        **one entry per variable, once each, in variable order**, `{id, values, other?, text?}`; a prompt has no free box,
        so a `note` is refused. Every rule is in [`prompts-v1.md`](prompts-v1.md) with vectors: a choice renders as its
        **label**, several as the labels in option order joined by `", "`, a text verbatim, `confirm` as `yes` or `no`, a
        number, a scale point and a date as sent, a rank as `1. A; 2. B`; an optional variable left alone renders as the empty
        string (its default is never used); nothing is trimmed and a value is never read again for references. The text is
        at most 32,768 bytes (422 `rendered_too_long`, decided before anything is built). With `revision` the prompt must
        still be at it (409 `stale_revision`: read it again). An answer that does not fit is **422 `invalid_answer`** with
        the first refusal: `question` (a variable's id, or `*` for the whole answer) and `rule` (`unknown`, `unexpected`,
        `required`, `too_many`, `too_few`, `not_offered`, `repeated`, `out_of_order`, `too_long`, `grammar`, `below_min`,
        `above_max`, `off_step`, `not_a_permutation`). The checks run in one order: 401, 403 `no_access`, 415, the shape
        (400 `bad_request`), 404, 409, 422.
      requestBody:
        required: true
        content:
          application/json:
            schema: { $ref: "#/components/schemas/RenderPromptRequest" }
      responses:
        "200":
          description: The text
          headers:
            Cache-Control: { description: "`no-store`", schema: { type: string } }
          content:
            application/json:
              schema: { $ref: "#/components/schemas/RenderedPrompt" }
        "400": { description: "`code: bad_request`: not one JSON object of `revision` and `answers` (and `note`), a `revision` of the wrong form, a member of the wrong type, or an id that is not one", $ref: "#/components/responses/Problem" }
        "401": { $ref: "#/components/responses/Problem" }
        "403": { description: "The caller's roles grant nothing (`code: no_access`)", $ref: "#/components/responses/Problem" }
        "404": { description: "No such prompt for the caller (as `getPrompt`)", $ref: "#/components/responses/Problem" }
        "409": { description: "`code: stale_revision`", $ref: "#/components/responses/Problem" }
        "415": { description: "The media type is not `application/json`", $ref: "#/components/responses/Problem" }
        "422": { description: "`code: invalid_answer` (with `question` and `rule`) or `rendered_too_long`", $ref: "#/components/responses/Problem" }
        "503": { description: "The store cannot answer", $ref: "#/components/responses/Problem" }
  /api/threads:
    get:
      operationId: listThreads
      summary: List the caller's threads, newest first or in their own order
      description: |
        The caller's own threads, and nobody else's: there is no listing of another person's threads or of
        everyone's, for any role ([ADR 0039](../decisions/0039-nobody-reads-another-persons-thread.md)).
        A request that carries an `owner` parameter, whatever its value, is a **400** (`owner is not
        supported (ADR 0039)`); until 2026-10-03 it was the administrators' way to list others' threads.

        **Order** ([ADR 0042](../decisions/0042-the-thread-list-is-the-owners.md)). `recent` (the default) is a flat
        list, `id` descending (ids sort by creation). `rail` is the order the person made of their list: the threads of
        the list's own level (the ones with no `nestedUnder`), the pinned first, then the rest, each by the place
        `arrangeThread` gave it (a new thread is on top; ties newest first), then the archived ones by when they were
        archived, newest first; and each is **followed by the threads nested under it**, newest first. With `rail`,
        `limit` counts the threads of the list's own level, so a page never splits a block, and `before` is the id of
        the last of them. `before` names a thread of the caller's: an unknown one, another person's, one nested under
        another (with `rail`) or one the `archived` filter does not list as a block (with `rail`) has no page after it:
        an empty list.

        **Archived.** `exclude` (the default) leaves the archived out: with `rail`, a block archived by its parent goes
        with it, and a child archived alone is left out of its parent's block; with `recent`, each row by its own state.
        `only` lists the archived: with `rail`, the archived threads of the list's own level, each with all its
        children, and the threads archived while their parent is not, each on its own; with `recent`, the archived rows.
        `include` lists everything: with `rail`, the archived blocks last. Until 2026-10-03 the list had no archived
        threads, so the default changes nothing for a client that never archives.
      parameters:
        - { name: limit, in: query, schema: { type: integer, minimum: 1, maximum: 100, default: 50 } }
        - { name: before, in: query, description: "Cursor: thread id to page before", schema: { type: string } }
        - name: branches
          in: query
          description: |
            `include`: list the threads made by an edit of a message too ([ADR 0029](../decisions/0029-forking-a-thread-copies-its-log.md)).
            Without it they are left out: an edit is a branch of a conversation the list already shows
            (`listBranches` says where its siblings are), and `limit` counts the threads listed. A thread made by
            "fork from here" is a conversation of its own and is always listed.
          schema: { type: string, enum: [include] }
        - name: order
          in: query
          description: "`recent` (the default): newest first, flat. `rail`: the person's own order, blocks of a thread and the threads nested under it ([ADR 0042](../decisions/0042-the-thread-list-is-the-owners.md))"
          schema: { type: string, enum: [recent, rail], default: recent }
        - name: archived
          in: query
          description: "`exclude` (the default): the threads that are not archived. `only`: the archived ones. `include`: all of them"
          schema: { type: string, enum: [exclude, only, include], default: exclude }
      responses:
        "400": { description: "`limit` out of range, `before` not a thread id, `branches` not `include`, `order` not `recent` or `rail`, `archived` not `exclude`, `only` or `include`, or an `owner` parameter (not supported: ADR 0039)", $ref: "#/components/responses/Problem" }
        "401": { $ref: "#/components/responses/Problem" }
        "403": { description: "No role of the caller holds `thread.read`, or their roles grant nothing", $ref: "#/components/responses/Problem" }
        "200":
          description: Threads
          content:
            application/json:
              schema: { type: array, items: { $ref: "#/components/schemas/Thread" } }
  /api/threads/{threadId}:
    parameters: [ { $ref: "#/components/parameters/ThreadId" } ]
    get:
      operationId: getThread
      summary: One thread
      description: "A thread the caller may read: their own. Another person's is a 404, the answer for one that does not exist, whatever the caller's roles (ADR 0039). A thread that is shared has `share`, with the link (`url`), and the response is then `Cache-Control: no-store`."
      responses:
        "401": { $ref: "#/components/responses/Problem" }
        "403": { description: "No role of the caller holds `thread.read`, or their roles grant nothing", $ref: "#/components/responses/Problem" }
        "200":
          description: Thread
          content:
            application/json:
              schema: { $ref: "#/components/schemas/Thread" }
        "404": { $ref: "#/components/responses/Problem" }
    patch:
      operationId: patchThread
      summary: Rename a thread, write its description, or set its default model and reasoning effort
      description: |
        Changes what a person writes about the thread, in any state of the thread, finished ones
        included (a title and a description label the conversation, not a job). At least one of four
        members is given:

        * `title`: the thread's new title. Trimmed, then one line of 1 to 200 characters with no
          control character. A rename is logged as a `thread_titled` event (`source: user`) and is
          final: nothing else replaces a title a person wrote. Renaming to the title the thread has
          from the person already writes nothing.
        * `description`: the thread's description ([ADR 0035](../decisions/0035-utility-model-tasks.md)):
          what the conversation is about now, in a sentence or two. Trimmed, then one line of 0 to
          500 characters with no control character; **an empty one clears it**. It is logged as a
          `thread_described` event (`source: user`) and is final, an empty one included: the model is
          never asked for this thread's description again, and one it had in flight is dropped.
          Writing the description the thread has from the person already writes nothing.
        * `model` and `reasoningEffort` ([ADR 0086](../decisions/0086-a-person-picks-a-model-or-a-reasoning-level-for-a-thread-or-a-message.md),
          [`model-pick-v1.md`](model-pick-v1.md)): the thread's **default** pick, what a message that names none is sent with
          (a message's own pick wins, then the thread's, then the agent's own default). A model alias, or one of `none`,
          `minimal`, `low`, `medium`, `high`, `xhigh`, `max`; `null` clears it, and a member that is absent is left as it is. It
          is **checked when it is set** against the thread's agent's live card, so a choice the agent does not offer is a
          **422** (`model_not_offered`, `reasoning_not_offered`, with `offered`) and nothing is written; it is checked again
          whenever a message resolves to it. It is a setting of the thread row: no event records it, and a fork or an export
          does not copy it. The answer then carries the default as it is now in `model` and `reasoningEffort`.

        All are checked before any is written, so a 400 changes nothing. A member other than
        these four is a 400, so that a client that thinks it can change more learns it cannot. The
        caller's own threads only (`thread.write`): someone else's is a 404 indistinguishable from one that
        does not exist, whatever the caller's roles. Everything else about the thread is as `getThread` says.
      requestBody:
        required: true
        content:
          application/json:
            schema: { $ref: "#/components/schemas/ThreadPatch" }
      responses:
        "401": { $ref: "#/components/responses/Problem" }
        "200":
          description: The thread, with what was changed
          content:
            application/json:
              schema: { $ref: "#/components/schemas/Thread" }
        "400": { $ref: "#/components/responses/Problem" }
        "403": { description: "No role of theirs holds `thread.write`, or their roles grant nothing", $ref: "#/components/responses/Problem" }
        "404": { $ref: "#/components/responses/Problem" }
        "422": { description: "`code: model_not_offered` or `code: reasoning_not_offered`: the agent's live card does not offer the default (`offered` lists what it does; empty when it lists none); nothing is written", $ref: "#/components/responses/Problem" }
        "503": { description: "The agent's live card cannot be read to check the default (\"the card of the agent <id> could not be read\"); retry after the number of seconds in the Retry-After header", $ref: "#/components/responses/Problem" }
    delete:
      operationId: deleteThread
      summary: Delete a thread, and erase it
      description: |
        Deletes the caller's thread **and every thread made from it by an edit, transitively** (an edit is a branch of
        the conversation that the list does not show, so deleting only the visible one would leave copies the person
        can no longer see or erase), and **erases** them ([ADR 0043](../decisions/0043-deleting-a-thread-erases-it.md)):

        * the log, the outbox, the agent binding, the watches and the timers are deleted, in one transaction;
        * the share goes with the row: **every link to the thread, a signed-in reader's and a public one, is a 404 from
          that moment**, and a stream open on it, the owner's or a reader's, ends (the client reconnects and is told
          the thread is not found);
        * the files of the thread and of its edits are erased from the artifact store right after, or within a
          sweep of the orchestrator's workers when the store is down (the answer does not wait for a sweep: the log is
          gone, and so is anything that referred to a file);
        * **forks are kept**: a fork is a conversation of its own (`forkedFrom` has no `threadId` any more) and, when
          it was nested under the deleted thread, takes its place in the caller's list, in the section (pinned,
          archived) and the order it had.

        A thread that works is **refused, 409 `thread_active`**: it is `queued`, `working` or `verifying`, or an agent
        its job asked is still running (the same goes for an edit of it). Deleting would cascade the unsent request to
        stop the agent away, and the agent would go on working, perhaps pushing to a repository. Stop it
        (`cancelThread`), wait for a terminal state on the stream (stopping is a request, not a state: the thread ends when
        the agent reports it), and delete it. A `blocked` thread, which waits for the person, can be deleted.

        Needs `thread.delete` and the thread to be the caller's, **not `thread.write`**. A deployment can withhold it
        (a legal hold, for instance); the people of such a role are erased by the operator. **What stays out of reach**,
        and is not promised away: the A2A agent's own store of its context, the model provider that saw the
        conversation, backups until they expire and, in a build that hosts an agent in-process, the agent's journal
        rows for the context. A second `DELETE` is a 404.
      responses:
        "204": { description: "The thread, and its edits, are deleted: their log is gone, their links are 404, their files are erased or on their way" }
        "401": { $ref: "#/components/responses/Problem" }
        "403": { description: "No role of the caller holds `thread.delete` (`code: forbidden`, whatever the id), or their roles grant nothing (`code: no_access`)", $ref: "#/components/responses/Problem" }
        "404": { description: "The thread does not exist, was deleted already, its id is not a UUID, or it is not the caller's (one answer for all, an administrator's included)", $ref: "#/components/responses/Problem" }
        "409": { description: "`code: thread_active`: the thread, or an edit of it, is `queued`, `working` or `verifying`, or has a running ask. Stop it, wait for it to end, then delete it", $ref: "#/components/responses/Problem" }
        "503": { description: "The thread kept changing under the delete (`Retry-After`), or storage is unavailable: nothing was deleted, try again", $ref: "#/components/responses/Problem" }
  /api/threads/{threadId}/rail:
    parameters: [ { $ref: "#/components/parameters/ThreadId" } ]
    patch:
      operationId: arrangeThread
      summary: Pin, archive, move or eject a thread in the caller's list
      description: |
        Changes how the caller's own list shows one thread ([ADR 0042](../decisions/0042-the-thread-list-is-the-owners.md)):
        a change of the thread's row, **written to no event** of its log (the log is the conversation, which a fork
        copies, an export carries and the readers of a share see: none of them sees or inherits it), so `version`,
        `updatedAt` and the thread's events do not change. At least one member is given, and an unknown one is a 400:

        * `pinned`: `true` pins the thread and puts it **on top of the pinned**; `false` unpins it and puts it **on top
          of the rest**. Pinning a thread that is pinned writes nothing.
        * `archived`: `true` archives the thread (it leaves the list `listThreads` gives by default and is listed with
          `archived=only`), `false` brings it back **in the place it had**. Archiving does not touch a share: the link
          keeps working, and `share` stays on the thread.
        * `nested`: `false` **ejects** a thread nested under another (a fork made nested under its parent): it becomes a
          thread of the list's own level, **right after the block it left** (on top of the unpinned when that block is
          pinned or archived). Its `forkedFrom` is untouched: ejecting is display grouping, not history. A thread that
          is not nested has nothing to eject. `nested: true` is a **422**: nesting a thread by moving it is not built.
        * `place`: where a thread of the list's own level goes among the caller's: `"top"` (on top of its section),
          `{"before": id}` or `{"after": id}` (right before, or right after, that thread). The server makes the place;
          a client never sends a key. The anchor must be a thread of the caller's that is on the list's own level, not
          archived and not the thread itself, else **422** `bad_anchor`; a client that gets it reads the list again. With
          `nested: false` the place is where the ejected thread goes. A thread nested under another is not pinned and
          not placed: **422** `nested_row` (eject it first, or give `nested: false` with the place).

        Changing a row to the state it already has is a 200 that writes nothing. Two arrangements at once may leave two
        threads of one place: they are ordered newest first, and nothing errors. It needs the thread to be the caller's
        and `thread.read`, **not `thread.write`**: it changes nothing in the conversation and nobody else sees it, the
        way taking a share down needs only ownership. Another person's thread is a **404** indistinguishable from one
        that does not exist, whatever the caller's roles.
      requestBody:
        required: true
        content:
          application/json:
            schema: { $ref: "#/components/schemas/ThreadArrangement" }
      responses:
        "401": { $ref: "#/components/responses/Problem" }
        "200":
          description: The thread as it is now, with `pinned`, `archived` and `nestedUnder` where they hold
          content:
            application/json:
              schema: { $ref: "#/components/schemas/Thread" }
        "400": { description: "A body that is not an object, with none of the members, with a member this API does not know, or with a value that is not of the member's type (a `place` that is not `top`, `before` or `after` an id, an id that is not a thread id)", $ref: "#/components/responses/Problem" }
        "403": { description: "No role of the caller holds `thread.read` (`code: forbidden`), or their roles grant nothing (`code: no_access`)", $ref: "#/components/responses/Problem" }
        "404": { $ref: "#/components/responses/Problem" }
        "422": { description: "`code: bad_anchor`: the thread to place it by is gone, archived, nested under another, another person's or the thread itself. `code: nested_row`: a thread nested under another cannot be pinned or placed without being ejected. And, with no code, `nested: true`", $ref: "#/components/responses/Problem" }
  /api/threads/{threadId}/tools:
    parameters: [ { $ref: "#/components/parameters/ThreadId" } ]
    put:
      operationId: putThreadTools
      summary: Set the MCP servers attached to a thread
      description: |
        Sets the whole set of [MCP servers attached to the thread](../decisions/0024-mcp-tools-attached-per-conversation.md),
        in any state of the thread, finished ones included (a thread is a conversation: the set applies to the next message
        sent to the agent). `servers` lists the ids, from `listToolServers`, that should be attached afterwards. What differs
        from what the thread has is logged as a `tools_attached` and a `tools_detached` event (attributed to the person); the
        same set writes nothing and is still a 200, so the call is idempotent. The agent is told the attached servers it may
        use (`attached` of the [`thread-tools/v1`](thread-tools-v1.md#the-attached-member) message) and finds their tools on
        the thread's endpoint; an agent whose card does not list `thread-tools/v1` gets nothing, which a client says before the
        person sends (the capabilities document).

        Anyone who may act on the thread (`thread.write`) may attach, the servers the deployment offers for the thread's agent
        (their `agents`), and **the servers the thread's owner added themselves** ([ADR 0046](../decisions/0046-people-add-their-own-mcp-servers-secrets-in-a-credential-broker.md),
        ids that start with `u-`, `listUserToolServers`) that are `ready`. A person's server has no `agents` list. A server the
        thread has already is not checked again: a deployment that stopped listing it, or a server of the person's that needs a
        new key, leaves the thread its attachment, and a person can detach it. Attaching asks the credential broker for nothing.
        A thread that is not the caller's is a **404** indistinguishable from one that does not exist, whatever their roles.
        Attaching a server the thread does not have is for the agent that will use it, so it takes `agent.invoke` for the
        thread's agent, **its audience included** ([ADR 0045](../decisions/0045-admin-dashboard-in-the-web-and-agent-access-from-the-registry.md)):
        for a thread whose agent the caller may no longer use, which is **read-only** for them, it is a **403**. Keeping the
        servers the thread has, or taking them off, is not attaching and is still theirs.

        A server of the person's that is not `ready` is a **422** with a `code` a client acts on: `tool_server_needs_auth` when
        the person has something to do (the server has no key or authorization yet, its key or authorization ended, it was
        disconnected: the picker's `needs_auth`), and `tool_server_unavailable` when a cause outside them has to clear (they
        lack `tools.user.add`, today's egress lists refuse the server, the deployment keeps no credentials: the picker's
        `unavailable`). The `detail` names the id and says why in words. **A server that is not the caller's own, one that does
        not exist, a malformed `u-` id and a deployment that has people's own servers off are all the same 422, with no code**
        and the sentence of an unknown id, so the answer does not say whether somebody else has a server by that id.
      requestBody:
        required: true
        content:
          application/json:
            schema: { $ref: "#/components/schemas/ThreadToolsRequest" }
      responses:
        "401": { $ref: "#/components/responses/Problem" }
        "200":
          description: The set after the change
          content:
            application/json:
              schema: { $ref: "#/components/schemas/ThreadTools" }
        "400": { description: "A body that is not exactly an object with a `servers` array of strings, or an id that is not `^[a-z0-9][a-z0-9-]{0,30}$`", $ref: "#/components/responses/Problem" }
        "403": { description: "No role of theirs holds `thread.write`, or their roles grant nothing; or the set adds a server and the caller may not use the thread's agent (`agent.invoke`: no role names it, or its audience leaves them out)", $ref: "#/components/responses/Problem" }
        "404": { $ref: "#/components/responses/Problem" }
        "422": { description: "A server the deployment does not list, or does not offer for the thread's agent, or more than 16 servers (the two kinds together); an id that is not a server of the thread owner's (the same answer for another person's, a missing one and a deployment with the feature off); or a server of the person's own that is not ready, with `code: tool_server_needs_auth` or `code: tool_server_unavailable`. The detail names the server's id, never a URL", $ref: "#/components/responses/Problem" }
  /api/threads/{threadId}/export:
    parameters: [ { $ref: "#/components/parameters/ThreadId" } ]
    get:
      operationId: exportThread
      summary: The whole thread as one JSON file, to share with a developer
      parameters:
        - name: X-Web-Revision
          in: header
          required: false
          description: |
            The build of the web that asks, as the web sends it (`NEXT_PUBLIC_BUILD_REVISION`, the commit its
            image was built from): written into the file as `versions.web.revision`
            ([ADR 0053](../decisions/0053-a-thread-export-says-which-builds-made-it.md)). 1 to 64 characters of
            letters, digits and `._+-`; anything else, or no header, is written as `unknown`. It authorises
            nothing and is the caller's word.
          schema: { type: string, maxLength: 64, pattern: "^[A-Za-z0-9._+-]{1,64}$" }
      description: |
        Everything the orchestrator holds about the thread, as a versioned `ThreadExport`
        document: the thread, its full job ledger (the gate, the attempt, the pushed commit, what
        each source said), the agent binding and the complete event log. Every card and line of
        the chat is derived from that log. Authorised exactly like `getThread` (`thread.read`): a thread
        the caller may not read is a 404 indistinguishable from one that does not exist.

        The response is an attachment (`Content-Disposition: attachment;
        filename="thread-<id>.json"`) and is never cached. It contains what the people and the
        agents wrote in the thread (messages, artifacts, findings, CI summaries) and the owner's
        e-mail address (`thread.owner`, and the `actor` of the owner's messages); it holds no credential the
        orchestrator uses (no bearer token, webhook secret or database URL is ever in the log).
        Read it before sharing it: a person can paste anything into a chat.

        **Client recipe: Export Markdown.** The same document is the input of the Markdown file of
        [`thread-markdown-v1.md`](thread-markdown-v1.md): a client writes it from this response, with no other
        request, so that every client writes the same file. Only what this export holds is written, and not a step's
        `input` or `output`. A share link has no export route, so a reader of a link cannot make that file (a gap the page names).
      responses:
        "401": { $ref: "#/components/responses/Problem" }
        "200":
          description: The thread export
          headers:
            Content-Disposition: { description: "`attachment; filename=\"thread-<id>.json\"`", schema: { type: string } }
            Cache-Control: { description: "`no-store`", schema: { type: string } }
          content:
            application/json:
              schema: { $ref: "#/components/schemas/ThreadExport" }
        "403": { description: "No role of the caller holds `thread.read`, or their roles grant nothing", $ref: "#/components/responses/Problem" }
        "404": { $ref: "#/components/responses/Problem" }
  /api/threads/{threadId}/cancel:
    parameters: [ { $ref: "#/components/parameters/ThreadId" } ]
    post:
      operationId: cancelThread
      summary: Cancel the thread's running work (A2A tasks/cancel on the target)
      description: |
        On a **child thread** ({ADR}) it stops the round the helper session is working on (`CancelTask` of that round): a
        kept-open session goes idle and takes the next message, any other session closes with the round.
      responses:
        "401": { $ref: "#/components/responses/Problem" }
        "202": { description: Cancellation requested; the outcome arrives as events }
        "403": { description: "No role of theirs holds `thread.write`, or their roles grant nothing", $ref: "#/components/responses/Problem" }
        "404": { $ref: "#/components/responses/Problem" }
  /api/threads/{threadId}/session/close:
    parameters: [ { $ref: "#/components/parameters/ThreadId" } ]
    post:
      operationId: closeChildSession
      summary: Close the helper session of a child thread
      description: |
        Asks the agent to close the session this **child thread** ([ADR 0072](../decisions/0072-child-sessions-are-nested-threads-followed-through-child-sessions-v1.md), [`child-sessions-v1.md`](child-sessions-v1.md)
        section 6): an idle session closes at once, a working one when its round ends, and with `cancel: true` its round is stopped
        first. The thread's owner only (`thread.write`; another person, an administrator included, gets 404). The request is
        asynchronous: the answer says what the orchestrator knows after it, and the outcome is the child's `child_session_state`
        event. A session that is closed already, or whose close was asked with the same or a stronger `cancel`, answers 202 and
        writes nothing.
      requestBody:
        required: false
        content:
          application/json:
            schema: { $ref: "#/components/schemas/ChildSessionClose" }
      responses:
        "401": { $ref: "#/components/responses/Problem" }
        "202":
          description: Close asked
          content:
            application/json:
              schema: { $ref: "#/components/schemas/ChildSessionCloseAccepted" }
        "400": { description: "The body is not JSON or not a `ChildSessionClose` (an unknown member, `cancel` that is not a boolean)", $ref: "#/components/responses/Problem" }
        "403": { description: "No role of theirs holds `thread.write`", $ref: "#/components/responses/Problem" }
        "404": { description: "The thread is missing, its id is not a UUID, it is not the caller's, or the registry no longer lists its agent (one answer for all four)", $ref: "#/components/responses/Problem" }
        "422": { description: "`code: not_child_thread`: the thread is not a helper session's (it has no `childOf`); `code: no_child_sessions`: the agent's live card no longer offers `child-sessions/v1` (nothing is written; a session closed already is 202 whatever the card says)", $ref: "#/components/responses/Problem" }
        "503": { description: "Storage is unavailable, or the agent's live card cannot be read; retry after the number of seconds in the Retry-After header", $ref: "#/components/responses/Problem" }
  /api/threads/{threadId}/sessions:
    parameters: [ { $ref: "#/components/parameters/ThreadId" } ]
    post:
      operationId: startChildSession
      summary: Start a helper session from a thread
      description: |
        A person starts a helper session of the thread's agent ([ADR 0072](../decisions/0072-child-sessions-are-nested-threads-followed-through-child-sessions-v1.md), [`child-sessions-v1.md`](child-sessions-v1.md) section 4):
        `text` is round 1's prompt, which the parent's model does not read. The thread's owner only (`thread.write`, and
        `agent.invoke` on the thread's agent). **Asynchronous:** the answer is 202 with the request's id, written before anything
        is sent to the agent; the outcome is the parent's `child_session_start_ended` event, `opened` with the child thread or
        `failed` with the agent's own words (`reason`, untrusted), which cover what only the agent can refuse: its limit of open
        sessions, of rounds working at once, of rounds per session. The text of a start that fails is not kept: a client keeps the
        draft until the outcome arrives. The request's `id` makes a repeat safe: the same `id` again answers 202 and writes nothing.
        At most 4 starts of one thread may wait for their outcome.

        Every refusal below is decided before anything is written. The helper sessions of a child thread are never started from
        it, and the card is read live (a card that stops offering the extension, or does not list the helper, refuses).
      requestBody:
        required: true
        content:
          application/json:
            schema: { $ref: "#/components/schemas/ChildSessionStart" }
      responses:
        "401": { $ref: "#/components/responses/Problem" }
        "202":
          description: Start asked; the outcome arrives as `child_session_start_ended` in this thread's log
          headers:
            Location: { description: "`/api/threads/<id>`", schema: { type: string } }
          content:
            application/json:
              schema: { $ref: "#/components/schemas/ChildSessionStartAccepted" }
        "400": { description: "The body is not JSON or not a `ChildSessionStart`: an unknown member, a missing member, `keepOpen` that is not a boolean, a `tier` that is not one of the four words", $ref: "#/components/responses/Problem" }
        "403": { description: "No role of theirs holds `thread.write`, or their roles do not name the thread's agent (`agent.invoke`)", $ref: "#/components/responses/Problem" }
        "404": { description: "The thread is missing, its id is not a UUID, it is not the caller's, or the registry no longer lists its agent (one answer for all four)", $ref: "#/components/responses/Problem" }
        "409": { description: "`code: no_context`: the agent has not answered the thread yet, so it has no context to start a session in (\"send the agent a message first\"); `code: too_many_starts`: 4 starts of this thread still wait for their outcome (\"wait for the helpers you started to open\"); `code: too_many_sessions`: the thread already notes 256 helper sessions, the most one thread may note", $ref: "#/components/responses/Problem" }
        "422": { description: "`code: child_thread`: the thread is itself a helper session's, which cannot start one; `code: no_child_sessions`: the agent's live card does not offer `child-sessions/v1` well formed; `code: unknown_helper`: `agent` is not one the card lists (the words say which are); `code: bad_description`: `description` is blank, longer than 80 characters, on more than one line or has a control or format character; `text` empty or larger than 100000 characters; a `tier` above what the caller's roles allow or one the agent's live card does not honour", $ref: "#/components/responses/Problem" }
        "503": { description: "Storage is unavailable, or the agent's live card cannot be read; retry after the number of seconds in the Retry-After header", $ref: "#/components/responses/Problem" }
  /api/threads/{threadId}/fork:
    parameters: [ { $ref: "#/components/parameters/ThreadId" } ]
    post:
      operationId: forkThread
      summary: Fork a thread from a point, or branch it by editing a message
      description: |
        Makes a new thread that begins as a copy of this one ([ADR 0029](../decisions/0029-forking-a-thread-copies-its-log.md)):
        the parent's events up to a cut, with the same `seq`, then a `thread_forked` event, then the new thread's own.
        The parent is not changed. The fork has its own A2A context, the parent's title (a person's rename of the
        parent stays theirs in the fork), the deployment's gate for its agent, and the same owner.

        * `after` (a `seq`): **fork from here**. The cut is the end of the turn that holds that event: the last event
          before the next message or action of a person, or the end of the log. The fork is `done`, a finished job:
          its next message starts the next job and is sent to its agent with the earlier conversation in front of it.
          A turn that is still going on (the thread is `queued`, `working` or `verifying`, and nothing follows the
          event) cannot be copied: 409, `code: turn_open`. With `target`, this is also "continue with another agent".
        * `after` with `text` (and `messageId`): the fork **is made with its first message**
          ([ADR 0042](../decisions/0042-the-thread-list-is-the-owners.md), decision 8). The copy, `thread_forked`, the message and
          the next job's start are one transaction, as for a new thread, so the fork is `queued` at once and its agent is told
          the conversation it continues together with the message; nothing exists if any part is refused. This route carries
          no mentions and no UI catalog: the AG-UI run (`runAgent`, `forwardedProps["vymalo.fork"]`) does, and is what the
          web sends. A repeat with the same `id`, the same `after` and the same message answers the fork it made (200) and
          writes no second message; the same `id` with another message or cut is a 409.
        * `replace` (the `seq` of a person's message) with the new `text`: **edit**. The cut is the event before that
          message, which may be 0; the fork then holds the new message, the next job's start and its delegation to
          the agent, and is `queued`. The thread is a branch of the one it was made from: it is left out of
          `listThreads` unless asked for, and `listBranches` finds its siblings. A conversation holds at most 256
          threads, its first thread and the threads made from it this way: the 256th edit is a 409.

        **Regenerate the last answer** is an edit with the same words; the server has no route of its own for it
        ([ADR 0029](../decisions/0029-forking-a-thread-copies-its-log.md), amended 2026-11-14). A client does this:
        1. Take the person's message that began the **newest** turn and `POST` `{id, replace: <its seq>, text: <its words,
           unchanged>, messageId}`. Send **no `tier`** and **no `locale`**: the server then keeps the replaced message's tier
           and interface locale (below). The
           answer is a new version of that message: `listBranches` finds it, and the client goes to the new thread.
        2. `id` and `messageId` are new UUIDs for each regenerate and the **same** ones for a retry after a failure
           (a lost response, a 5xx), so a retry never makes a second thread; the next regenerate, of the same
           message too, mints new ones.
        3. Do not offer it when the client can see, from what the API gives it, that the edit would lose something:
           the thread is `queued`, `working` or `verifying` (the turn is not over); the thread is `blocked` with a
           question open (the edit would drop it); the newest turn did not begin with a message of a person but with a
           form answer (`ui_action`, the `vymalo.action` activity: there is no message to replace); the message mentioned
           agents (`vymalo.mentions` in its `START` metadata: an edit carries none); the message was sent while the agent
           worked (`vymalo.delivery`, `steer` or `interrupt`: the turn also holds the agent's earlier work, which an
           edit of that message keeps, so it is not "again"); the caller holds no `thread.write` (`getMe`); or the
           thread is read through a share link (the owner's routes are a 404 to a reader).

        The server enforces only the caller's `thread.write` (403), ownership (404, a share link's reader included),
        that `replace` is a message of a person (422) and the tier rules below. Everything else in step 3 is the client's
        courtesy: a request that ignores it is accepted. The `seq` of a person's message is the resume point (SSE `id:`)
        of the last frame of that message in the stream ([`agui.md`](agui.md)).

        `tier` ([ADR 0061](../decisions/0061-the-person-picks-an-access-tier-for-each-message-the-agent-keeps-to-it.md),
        [`access-tier-v1.md`](access-tier-v1.md)) is the access tier of the message the fork carries, one of `plan`, `edits`,
        `auto`, `bypass`, read as `forwardedProps["vymalo.tier"]` is; it goes with `text`. An **edit** that names none is
        sent under the tier of the message it replaces, lowered to what the caller's roles allow and the agent's live
        card honours (422 `this agent no longer lists access tiers` or `has no tier at or below ...` when it cannot be
        kept). A first message that names none, from a caller with a role cap, is sent under the highest tier the agent
        offers that is not above the lower of its `default` and the cap, as for a new thread.

        `target` names the agent and release the fork talks to (the parent's when absent), validated as for a new
        thread: an agent the caller's audience leaves out ([ADR 0045](../decisions/0045-admin-dashboard-in-the-web-and-agent-access-from-the-registry.md))
        is a 400 "unknown agent" in the words, and with the shape, of one that is not listed. `id` is a UUID the caller chose for the new thread: a repeat of the request with the same `id` answers
        the fork it made (200) and writes nothing; the id of another thread is a 409. The caller's own threads only;
        someone else's is a 404.
      requestBody:
        required: true
        content:
          application/json:
            schema: { $ref: "#/components/schemas/ForkRequest" }
      responses:
        "401": { $ref: "#/components/responses/Problem" }
        "201":
          description: The fork
          headers:
            Location: { description: "`/api/threads/<id>`", schema: { type: string } }
          content:
            application/json:
              schema: { $ref: "#/components/schemas/Thread" }
        "200":
          description: The fork this request's `id` named, made by an earlier request
          headers:
            Location: { description: "`/api/threads/<id>`", schema: { type: string } }
          content:
            application/json:
              schema: { $ref: "#/components/schemas/Thread" }
        "400": { description: "The body is not JSON or not a `ForkRequest`: both or neither of `after` and `replace`, `messageId` without `text`, `replace` without `text`, an empty or too long text, a `messageId` longer than 256 bytes, an unknown agent or release, an unknown member, a thread that is too long to fork, a `tier` that is not one of the four words or comes without `text`", $ref: "#/components/responses/Problem" }
        "403": { description: "No role of theirs holds `thread.write`, or their roles do not name the target agent (`agent.invoke`)", $ref: "#/components/responses/Problem" }
        "404": { description: "The thread is missing, its id is not a UUID, or the caller may not read it (one answer for all three)", $ref: "#/components/responses/Problem" }
        "409": { description: "`code: turn_open`: the turn to copy is still going on, try again when it has ended; or `id` is another thread's (for `after` with `text`: any thread but the fork this very request made), or the conversation has 256 branches already", $ref: "#/components/responses/Problem" }
        "422": { description: "`code: child_thread`: the thread is the thread of a helper session (`childOf`, ADR 0072), which is never forked; `after` or `replace` is not an event of the thread, or `replace` is not a message of a person; a `tier` above what the caller's roles allow or one the agent's live card does not honour, or a tier an edit inherits that cannot be kept; `code: model_not_offered` or `code: reasoning_not_offered` (a `model` or `reasoningEffort` the agent's live card does not offer, one an edit inherits included), with `offered`", $ref: "#/components/responses/Problem" }
        "502": { description: "The target agent could not be reached to validate the release", $ref: "#/components/responses/Problem" }
        "503": { description: "Storage is unavailable, or the agent registry cannot say whether the target exists, or the agent's live card cannot be read to decide the access tier; retry after the number of seconds in the Retry-After header", $ref: "#/components/responses/Problem" }
  /api/threads/{threadId}/branches:
    parameters: [ { $ref: "#/components/parameters/ThreadId" } ]
    get:
      operationId: listBranches
      summary: The messages of a thread that have other versions
      description: |
        The conversation this thread is a branch of ([ADR 0029](../decisions/0029-forking-a-thread-copies-its-log.md)):
        threads made from one another by an edit of a message. `points` are the messages **of this thread** that have
        other versions, in the order they come, each with every version (the original first, then the edits in the
        order they were made) and which of them is this thread's, so that a client can show `‹ 2 / 3 ›` under the
        message and move between the threads. Everything of a thread up to its cut is its parent's, so it shows the
        parent's versions there. A thread made by "fork from here" is not a version of anything: it starts a
        conversation of its own. `root` is the thread the conversation started from. A thread that was never
        edited has no points. Authorised like `getThread`.
      responses:
        "401": { $ref: "#/components/responses/Problem" }
        "200":
          description: The branches
          content:
            application/json:
              schema: { $ref: "#/components/schemas/Branches" }
        "403": { description: "No role of the caller holds `thread.read`, or their roles grant nothing", $ref: "#/components/responses/Problem" }
        "404": { $ref: "#/components/responses/Problem" }
  /api/threads/{threadId}/artifacts/{sha256}:
    parameters:
      - { $ref: "#/components/parameters/ThreadId" }
      - { $ref: "#/components/parameters/Sha256" }
    get:
      operationId: getArtifact
      summary: A file an agent handed over, from the artifact store
      description: |
        The content of a file of the thread ([ADR 0032](../decisions/0032-files-from-agents-live-in-an-artifact-store.md)):
        the `file` of an `artifact` event, `href` of the projected artifact **on the owner's streams and pages** (a reader of a share link is given
        `getSharedArtifact`'s or `getPublicSharedArtifact`'s route as the `href`, [ADR 0040](../decisions/0040-thread-sharing-by-revocable-link.md)). `sha256` is the content's hash in 64
        lowercase hexadecimal digits, and the file belongs to the thread in the path: no thread reaches another's by
        hash. Authorised by the permission `artifact.read` ([ADR 0033](../decisions/0033-the-orchestrator-is-an-oauth2-resource-server.md))
        over the thread: the thread's owner, and nobody else ([ADR 0039](../decisions/0039-nobody-reads-another-persons-thread.md)).
        Another person's thread, a thread that does not exist, a hash the thread holds no
        file for, a hash that is not 64 lowercase hex digits and a deployment with no artifact store are all the same 404;
        a caller whose roles hold no `artifact.read` gets a 403 (`code: forbidden`), whatever they ask for.

        The body is **streamed** from the store. `Content-Type` is the type the worker kept (it sniffed it: an image
        whose bytes disagree with its declared type is `application/octet-stream`) for a preview type, and
        **`application/octet-stream` for every other type** (a kept `text/javascript` or `text/css` is never sent as
        one: the web allows scripts and styles of its own origin). A request whose `Sec-Fetch-Dest` is `script`,
        `worker`, `sharedworker`, `serviceworker`, `style` or `object` is a 403 (`code: forbidden`) before the file is
        opened; the shared routes do the same.

        * **Inline** (no `download`, or `download=0`): only for the preview types, `image/png`, `image/jpeg`,
          `image/gif`, `image/webp`, `image/svg+xml`, `text/plain` and `application/json` (the last two with
          `; charset=utf-8`), with `Content-Disposition: inline; filename="…"`. An SVG is **sanitized** first
          (`orch-svg-clean`: no script, no `foreignObject`, no external reference, no event handler); one that is larger
          than 2 MiB or cannot be sanitized is sent as an attachment instead. **Every other type is an attachment
          only.**
        * **Download** (`download=1`): `Content-Disposition: attachment; filename="…"`, the original bytes. The file
          name is the agent's, cleaned: one name with no path, no control or direction character, a printable ASCII
          fallback in `filename` and the real name as `filename*=UTF-8''…` (RFC 6266, RFC 5987); a file without a
          usable name is `artifact-<8 hex digits of the hash>`.

        Every response, inline or not, carries `X-Content-Type-Options: nosniff`, `Content-Security-Policy:
        default-src 'none'; img-src 'self' data:; style-src 'unsafe-inline'; sandbox`, `Cache-Control: private,
        max-age=31536000, immutable` (the URL is the content's hash) and `ETag: "<sha256>"`.

        **A redirect** ([ADR 0058](../decisions/0058-large-files-go-up-through-a-presigned-url-the-orchestrator-gives-the-agent.md),
        A1, amendment of 2026-10-14). When the deployment sets `artifacts.s3.downloads: redirect` (off by default: the
        web fetches a file with `fetch`, whose `connect-src` does not list the files host) and the artifact store can
        presign, the answer is **`302`** with `Location` set to a presigned `GET` on `artifacts.s3.publicEndpoint`,
        valid for `artifacts.s3.presignTtlSecs` (300 by default), and `Cache-Control: private, no-store`. It comes
        **after** every check above, which are unchanged and run first: a refusal is never a redirect, and a file the
        store does not hold is the same 404. The file is not read to be redirected. The URL carries three signed query
        members, so the holder cannot change them: `response-content-disposition` (`inline` for a preview type without
        `download`, else `attachment`, both with the cleaned name as above), `response-content-type` (the kept type for a
        preview type, `application/octet-stream` for every other) and `response-cache-control` (`private,
        max-age=<lifetime>`). The bytes, and `X-Content-Type-Options`, `Content-Security-Policy` and the CORS headers, are
        the files host's: none of them is on the `302`. **An SVG without `download` is never redirected**: it is sanitized
        and streamed as above; with `download=1` it is redirected like any download. A store that cannot presign, and
        `artifacts.s3.downloads: stream` (the default), stream as above. If the URL cannot be signed the answer is a
        5xx problem (`503` for a store that is unavailable, `500` for a fault of the deployment), never the bytes.
      parameters:
        - name: download
          in: query
          required: false
          description: "`1` (or `true`) sends the file as an attachment; `0`, `false` or absent shows a preview type inline. Any other value is a 400."
          schema: { type: string, enum: ["0", "1", "false", "true"] }
      responses:
        "401": { $ref: "#/components/responses/Problem" }
        "200":
          description: The file
          headers:
            Content-Type: { description: "The kept media type for a preview type, else `application/octet-stream`", schema: { type: string } }
            Content-Length: { description: "The size in bytes (the sanitized size for an inline SVG)", schema: { type: integer } }
            Content-Disposition: { description: "`inline; filename=\"…\"` or `attachment; filename=\"…\"`, with `filename*` for a name that is not ASCII", schema: { type: string } }
            X-Content-Type-Options: { description: "`nosniff`", schema: { type: string } }
            Content-Security-Policy: { description: "`default-src 'none'; img-src 'self' data:; style-src 'unsafe-inline'; sandbox`", schema: { type: string } }
            Cache-Control: { description: "`private, max-age=31536000, immutable`", schema: { type: string } }
            ETag: { description: "`\"<sha256>\"`", schema: { type: string } }
          content:
            application/octet-stream:
              schema: { type: string, format: binary }
        "302":
          description: "Only with `artifacts.s3.downloads: redirect` and a store that can presign: the file is on the files host, under a presigned URL. No body"
          headers:
            Location: { description: "A presigned `GET` on `artifacts.s3.publicEndpoint`, with the signed `response-content-disposition`, `response-content-type` and `response-cache-control`. A credential for `artifacts.s3.presignTtlSecs` seconds: it is not logged or cached", schema: { type: string, format: uri } }
            Cache-Control: { description: "`private, no-store`", schema: { type: string } }
            Referrer-Policy: { description: "`no-referrer`: the redirect's policy governs the request the browser is sent on (the page that asked may be a share link's)", schema: { type: string } }
        "400": { $ref: "#/components/responses/Problem" }
        "403": { description: "No role of the caller holds `artifact.read`, or their roles grant nothing; or the browser asked for the file as a script, a worker, a style or an object (`Sec-Fetch-Dest`)", $ref: "#/components/responses/Problem" }
        "404": { $ref: "#/components/responses/Problem" }
        "500": { description: "A deployment whose store says it can presign and cannot (only with `redirect`)", $ref: "#/components/responses/Problem" }
        "503": { description: "The store is unavailable (only with `redirect`: the file's meta could not be read, or the URL could not be signed)", $ref: "#/components/responses/Problem" }
  /api/threads/{threadId}/share:
    parameters: [ { $ref: "#/components/parameters/ThreadId" } ]
    put:
      operationId: shareThread
      summary: Share a thread by a link, or change who may read it
      description: |
        Shares one of the caller's threads ([ADR 0040](../decisions/0040-thread-sharing-by-revocable-link.md)): `internal`
        (signed-in people who have the link) or `public` (anybody who has it), read-only for them. A first share draws a
        nonce; a widening or a narrowing keeps it, so the link is the same. The same `visibility` as the thread has is
        the current link and writes nothing. Logged as a `thread_shared` event, in the commit that sets the thread's row.
        Needs `thread.share`, over the caller's own thread, within the deployment's cap (`sharing.mode`).
      requestBody:
        required: true
        content:
          application/json:
            schema: { $ref: "#/components/schemas/ThreadShareRequest" }
      responses:
        "200":
          description: The link
          headers: { Cache-Control: { description: "`no-store`", schema: { type: string } } }
          content:
            application/json:
              schema: { $ref: "#/components/schemas/ThreadShareLink" }
        "400": { description: "The body is not exactly `{visibility}`, or `visibility` is not `internal` or `public` (`private` included: stop sharing with `unshareThread`)", $ref: "#/components/responses/Problem" }
        "401": { $ref: "#/components/responses/Problem" }
        "403": { description: "No role of the caller holds `thread.share` (`code: forbidden`), or the deployment's cap is `disabled` (`code: sharing_disabled`)", $ref: "#/components/responses/Problem" }
        "404": { description: "The thread is missing, its id is not a UUID, or it is not the caller's (one answer for all three, an administrator's included)", $ref: "#/components/responses/Problem" }
        "409": { description: "`code: over_cap`: `visibility` is above the deployment's cap (`public` under `internal`)", $ref: "#/components/responses/Problem" }
        "422": { description: "`code: child_thread`: the thread is the thread of a helper session (`childOf`, ADR 0072), which is shared with the thread it belongs to and never alone", $ref: "#/components/responses/Problem" }
    delete:
      operationId: unshareThread
      summary: Take a link down
      description: |
        Stops sharing: the thread is private again, the nonce is gone, so the old link is a 404 from that moment and a
        stream open on it ends; sharing again makes a new link, a revoked one never comes back. Logged as a
        `thread_unshared` event. **Needs only ownership**: it is never refused for the deployment's cap or for a missing
        `thread.share`, so an owner can always take a link down. A thread that is not shared is left as it is: 204.
      responses:
        "204": { description: "The thread is private" }
        "401": { $ref: "#/components/responses/Problem" }
        "404": { description: "The thread is missing, its id is not a UUID, or it is not the caller's", $ref: "#/components/responses/Problem" }
  /api/threads/{threadId}/share/rotate:
    parameters: [ { $ref: "#/components/parameters/ThreadId" } ]
    post:
      operationId: rotateThreadShare
      summary: A new link for a shared thread
      description: |
        Draws a new nonce, so the old link is a 404 from now on and the thread stays shared at the visibility it had
        ([ADR 0040](../decisions/0040-thread-sharing-by-revocable-link.md)). Logged as a `thread_shared` event with a new
        `nonce_sha256`. Needs `thread.share`, over the caller's own thread.
      responses:
        "200":
          description: The new link
          headers: { Cache-Control: { description: "`no-store`", schema: { type: string } } }
          content:
            application/json:
              schema: { $ref: "#/components/schemas/ThreadShareLink" }
        "401": { $ref: "#/components/responses/Problem" }
        "403": { description: "No role of the caller holds `thread.share` (`code: forbidden`), or the cap is `disabled` (`code: sharing_disabled`)", $ref: "#/components/responses/Problem" }
        "404": { $ref: "#/components/responses/Problem" }
        "409": { description: "`code: not_shared`: the thread is private; share it first", $ref: "#/components/responses/Problem" }
  /api/shared/{token}:
    parameters: [ { $ref: "#/components/parameters/ShareToken" } ]
    get:
      operationId: getSharedThread
      summary: A shared thread, for a signed-in reader
      description: |
        The thread a link names, as a **signed-in** person is given it ([ADR 0040](../decisions/0040-thread-sharing-by-revocable-link.md)):
        the reader projection, with no owner, no parent and no tools. Served when the thread is effectively `internal` or
        `public`. Needs `thread.read` at any scope (the link is the grant): no role, `admin` included, reads a thread
        through it that the link does not name, and a reader acts on nothing. The thread's events come by
        `connectSharedThread`. A reader who is the thread's owner is told so (`isOwner`). Never cached.
      responses:
        "200":
          description: The shared thread
          headers:
            Cache-Control: { description: "`no-store`", schema: { type: string } }
            X-Robots-Tag: { description: "`noindex, nofollow`", schema: { type: string } }
          content:
            application/json:
              schema: { $ref: "#/components/schemas/SharedThread" }
        "401": { $ref: "#/components/responses/Problem" }
        "403": { description: "No role of the caller holds `thread.read`, or their roles grant nothing", $ref: "#/components/responses/Problem" }
        "404": { description: "**Every** way a link can fail: an unknown or malformed token, a bad MAC, a private or revoked thread, a cap that was lowered. One answer, one body", $ref: "#/components/responses/Problem" }
  /api/shared/{token}/artifacts/{sha256}:
    parameters:
      - { $ref: "#/components/parameters/ShareToken" }
      - { $ref: "#/components/parameters/Sha256" }
    get:
      operationId: getSharedArtifact
      summary: A file of a shared thread, for a signed-in reader
      description: |
        A file of the thread a link names ([ADR 0040](../decisions/0040-thread-sharing-by-revocable-link.md)): needs
        `artifact.read` as well as `thread.read`, and the file must be one **the thread's own log names**, found among the
        newest 1000 `artifact` events of the thread (a file named only by an older one is the same 404 through a link; the
        owner's `getArtifact` still serves it). Sent as
        `getArtifact` sends a file (sanitised SVG, `nosniff`, the sandboxing `Content-Security-Policy`, an attachment unless
        it is a preview type) except that it is **`Cache-Control: no-store`**, not the immutable cache of the owner's files, so
        a revoked file is not kept by the reader's browser.

        With `artifacts.s3.downloads: redirect` it answers **`302`** as `getArtifact` does, with two differences: the response
        is `Cache-Control: no-store` (the rule of everything served through a link), and the presigned URL lives **at most 60
        seconds** (`min(artifacts.s3.presignTtlSecs, 60)`, and its `response-cache-control` says so), so a link that is taken
        down stops serving a file within a minute. A URL already issued cannot be recalled: S3 has no revoke.
      parameters:
        - name: download
          in: query
          required: false
          schema: { type: string, enum: ["0", "1", "false", "true"] }
      responses:
        "200":
          description: The file
          headers:
            Cache-Control: { description: "`no-store`", schema: { type: string } }
            X-Content-Type-Options: { description: "`nosniff`", schema: { type: string } }
          content:
            application/octet-stream:
              schema: { type: string, format: binary }
        "302":
          description: "Only with `artifacts.s3.downloads: redirect` and a store that can presign: a presigned `GET` valid for at most 60 seconds. No body"
          headers:
            Location: { description: "A presigned `GET` on `artifacts.s3.publicEndpoint`; a credential for at most a minute", schema: { type: string, format: uri } }
            Cache-Control: { description: "`no-store`", schema: { type: string } }
            Referrer-Policy: { description: "`no-referrer`", schema: { type: string } }
        "400": { $ref: "#/components/responses/Problem" }
        "401": { $ref: "#/components/responses/Problem" }
        "403": { description: "No role of the caller holds `artifact.read` or `thread.read`; or the browser asked for the file as a script, a worker, a style or an object (`Sec-Fetch-Dest`)", $ref: "#/components/responses/Problem" }
        "404": { description: "Every way a link or a file can fail: the same answer as `getSharedThread`, and a file the thread's log does not name among its newest 1000 `artifact` events", $ref: "#/components/responses/Problem" }
        "500": { description: "As `getArtifact`", $ref: "#/components/responses/Problem" }
        "503": { description: "As `getArtifact`", $ref: "#/components/responses/Problem" }
  /api/public/auth:
    get:
      operationId: getPublicAuth
      summary: Where a browser signs in
      description: |
        What the web needs to sign a person in by itself ([ADR 0054](../decisions/0054-the-web-holds-its-own-tokens-dpop-bound-in-indexeddb.md),
        decision 7): the token issuer, the web's public OAuth client at it, and the scope to ask for. The orchestrator says it
        (`auth.browser`, and `auth.jwt.issuer`), so that a static export of the web needs no configuration of its own. **Outside
        the identity layer**: no credential is read (an `Authorization` header is ignored), because the person is not signed in
        yet; behind the same rate limit as the other public routes. A **404** when the deployment has not configured it, which the
        web reads as "the edge's cookie signs people in", as before. Nothing in the answer is secret: a public client has none.
        `Cache-Control: no-store`.
      security: []
      responses:
        "200":
          description: Where to sign in
          headers:
            Cache-Control: { description: "`no-store`", schema: { type: string } }
          content:
            application/json:
              schema: { $ref: "#/components/schemas/BrowserAuth" }
        "404": { description: "This deployment does not configure browser sign-in (`auth.browser` is absent)", $ref: "#/components/responses/Problem" }
        "429": { description: "Too many requests; `Retry-After` says when to try again", $ref: "#/components/responses/Problem" }
  /api/public/shared/{token}:
    parameters: [ { $ref: "#/components/parameters/ShareToken" } ]
    get:
      operationId: getPublicSharedThread
      summary: A public shared thread, for anybody
      description: |
        The thread a link names, for **anybody** ([ADR 0040](../decisions/0040-thread-sharing-by-revocable-link.md)): no
        identity, no cookie, and an `Authorization` or identity header is **ignored** (the orchestrator does not run the
        authenticator here, and the edge strips them). Served only when the thread is effectively `public`; an `internal`
        link is a 404. It is the reader projection of a public reader: step input and output and files are not in what
        follows unless the deployment's `sharing.public` says so, and the owner's address never is. Rate limited
        per link and in all (a 404 costs the shared bucket more, so guessing tokens is throttled): 429 with
        `Retry-After`. `Cache-Control: no-store`, `X-Robots-Tag: noindex, nofollow`.
      security: []
      responses:
        "200":
          description: The shared thread
          headers:
            Cache-Control: { description: "`no-store`", schema: { type: string } }
            X-Robots-Tag: { description: "`noindex, nofollow`", schema: { type: string } }
          content:
            application/json:
              schema: { $ref: "#/components/schemas/SharedThread" }
        "404": { description: "Every way a link can fail, with the same body as `getSharedThread`'s 404", $ref: "#/components/responses/Problem" }
        "429": { description: "Too many requests for this link or for all links; `Retry-After` says when to try again", $ref: "#/components/responses/Problem" }
  /api/public/shared/{token}/artifacts/{sha256}:
    parameters:
      - { $ref: "#/components/parameters/ShareToken" }
      - { $ref: "#/components/parameters/Sha256" }
    get:
      operationId: getPublicSharedArtifact
      summary: A file of a public shared thread, for anybody
      description: |
        As `getSharedArtifact`, for anybody, and **only when `sharing.public.files` is on** (otherwise the one 404). The file
        must be one the thread's log names, among its newest 1000 `artifact` events. `Cache-Control: no-store`. With
        `artifacts.s3.downloads: redirect` it answers `302` to a presigned `GET` that lives at most 60 seconds, as
        `getSharedArtifact` does.
      security: []
      parameters:
        - name: download
          in: query
          required: false
          schema: { type: string, enum: ["0", "1", "false", "true"] }
      responses:
        "200":
          description: The file
          headers:
            Cache-Control: { description: "`no-store`", schema: { type: string } }
          content:
            application/octet-stream:
              schema: { type: string, format: binary }
        "302":
          description: "Only with `artifacts.s3.downloads: redirect` and a store that can presign: a presigned `GET` valid for at most 60 seconds. No body"
          headers:
            Location: { description: "A presigned `GET` on `artifacts.s3.publicEndpoint`; a credential for at most a minute", schema: { type: string, format: uri } }
            Cache-Control: { description: "`no-store`", schema: { type: string } }
            Referrer-Policy: { description: "`no-referrer`", schema: { type: string } }
        "400": { $ref: "#/components/responses/Problem" }
        "403": { description: "The browser asked for the file as a script, a worker, a style or an object (`Sec-Fetch-Dest`)", $ref: "#/components/responses/Problem" }
        "404": { $ref: "#/components/responses/Problem" }
        "429": { description: "Too many requests; `Retry-After` says when to try again", $ref: "#/components/responses/Problem" }
        "500": { description: "As `getArtifact`", $ref: "#/components/responses/Problem" }
        "503": { description: "As `getArtifact`", $ref: "#/components/responses/Problem" }
  /agui/agents/{agentId}:
    parameters: [ { $ref: "#/components/parameters/AgentId" } ]
    post:
      operationId: runAgent
      summary: Run an agent (AG-UI 1.0 HTTP + SSE binding)
      description: |
        The standard AG-UI run endpoint ([ADR 0012](../decisions/0012-ag-ui-user-facing-protocol.md),
        [`agui.md`](agui.md#run-binding)). Creates a thread (the consumer mints `threadId`, a UUID),
        sends a message, answers an interrupt (`resume`), sends the user's action on an A2UI surface
        (`forwardedProps.a2uiAction.userAction`, [ADR 0013](../decisions/0013-a2ui-generative-ui.md))
        or attaches to a run already in the log (a retry with the same `runId`). The response streams the AG-UI events of that run, from
        `RUN_STARTED` to `RUN_FINISHED` or `RUN_ERROR`, then ends; closing it never cancels the run.

        A run whose `threadId` names no thread may create it **as a fork** with `forwardedProps["vymalo.fork"]`
        = `{from, after}` ([ADR 0042](../decisions/0042-the-thread-list-is-the-owners.md), decisions 8 and 9,
        [`agui.md`](agui.md#a-fork-made-with-its-first-message)): the parent's events up to the end of the turn that holds
        `after`, `thread_forked` and the run's message are one transaction, and the response is the run that message
        opens, from its `RUN_STARTED`, nothing of the copied turns. It needs `thread.write` on `from` (the caller's
        own thread, else 404) and `agent.invoke` on the run's `agentId`, which may be another agent than the parent's;
        `vymalo.mentions` and `vymalo.uiCatalog` apply to the message, and it is a 400 together with `vymalo.gate` or
        `vymalo.tools` (a fork has the deployment's gate and its parent's tools). The member is read on a run that
        creates the thread; a thread that exists already answers it only when it is the fork the same request made
        (the same `from`, `after` and `runId`, the same person's): the replay, which attaches to the run and writes
        nothing, so a resend after a lost response is safe. Any other existing thread is a 409.

        A run that carries a message may name the **access tier** the agent works under for it with
        `forwardedProps["vymalo.tier"]` (`plan`, `edits`, `auto` or `bypass`,
        [ADR 0061](../decisions/0061-the-person-picks-an-access-tier-for-each-message-the-agent-keeps-to-it.md),
        [`access-tier-v1.md`](access-tier-v1.md), [`agui.md`](agui.md#access-tier)). It is read on every run (a member that is
        not one of the four words is a 400), checked against the person's role cap (`auth.roles.<role>.maxTier`: 422) and the
        thread's agent's live card (422 when it does not honour the tier, 503 when it cannot be read) before anything is
        written, and never silently dropped; it is logged on the `user_message` (`tier`), shown on the message's
        `TEXT_MESSAGE_START` metadata (`vymalo.tier`) and sent to the agent only while its card still honours it. A message that
        names none is not always sent as plain A2A: a person whose roles cap the tier for this agent is given the highest tier the
        agent offers that is not above the lower of its `default` and the cap (422 when it offers none), an answer to a blocked
        job or an action on a surface continues the tier of the job, lowered to the cap and the card, and a person with no cap
        who names none is sent the message it always was. What the message was sent under is what the log says. The tiers an
        agent honours, and the highest the person may pick of that agent, are in `getAgentCapabilities`; `maxTier` of `getMe` is a hint.

        A run that carries a message may also pick the **model** and the **reasoning effort** the agent answers with, with
        `forwardedProps["vymalo.model"]` (an alias the agent's card offers: 1 to 64 characters of `a-z0-9._-`) and
        `forwardedProps["vymalo.reasoningEffort"]` (`none`, `minimal`, `low`, `medium`, `high`, `xhigh` or `max`),
        [ADR 0086](../decisions/0086-a-person-picks-a-model-or-a-reasoning-level-for-a-thread-or-a-message.md),
        [`model-pick-v1.md`](model-pick-v1.md). Each is read on every run (a value that is not one is a 400). **A pick is not
        a hint**: the message's own pick wins, then the thread's default (`patchThread`), then the agent's own default, and the
        result is checked against the thread's agent's live card before anything is written: a choice the card does not list is
        a **422** with `code: model_not_offered` or `code: reasoning_not_offered` and `offered`, the list the card offers (empty
        when it lists none), and nothing is written; a card that cannot be read is a 503. The resolved pick is logged on the
        `user_message` (`pick: {model?, reasoningEffort?}`, omitted when none), so a redelivery, a fork's first message, an edit
        and an export carry it; it is sent to the agent only while its card still offers it, and an agent that answers
        `InvalidParams` leaves the message undelivered, never retried without the pick.

        On a **child thread** ([ADR 0072](../decisions/0072-child-sessions-are-nested-threads-followed-through-child-sessions-v1.md)) the run is a message to the helper session: with the session idle it is the helper's next round, with a round working and
        `vymalo.send: steer` a steer into it, with the round waiting for the person (`blocked`) the answer to it. A Stop & send
        (`vymalo.send: interrupt`) is allowed only for a kept-open session. A message that mentions agents is refused (a helper
        cannot ask other agents). What only the agent can refuse (its limit of rounds working at once, of rounds per session)
        ends the job with `error` carrying the agent's own words.

        Every rejection is decided before the first stream byte and is a problem response; nothing
        was written. Cancel a run with `cancelThread`.
      requestBody:
        required: true
        content:
          application/json:
            schema: { $ref: "#/components/schemas/AgUiRunAgentInput" }
      responses:
        "200":
          description: The run's events (`text/event-stream`); frames carry `id:` on resume points
          content:
            text/event-stream:
              schema: { type: string }
              x-itemSchema: { $ref: "#/components/schemas/AgUiSseFrame" }
        "400": { description: "The body is not JSON or not a `RunAgentInput`; `threadId` is not a UUID; `protocolVersion` names another major; an id is longer than 256 bytes; an unknown release, or an agent without releases asked for one; a `forwardedProps[\"vymalo.gate\"]` (the verification gate, [`agui.md`](agui.md#verification-the-gate)) that is malformed, removes a required source, asks for attempts outside the deployment's cap, or needs what the build does not honour yet; a `forwardedProps[\"vymalo.send\"]` that is not `steer` or `interrupt`; a `forwardedProps[\"vymalo.fork\"]` that is not exactly `{from: <thread UUID>, after: <integer>}`, or that comes with `vymalo.gate` or `vymalo.tools`; a `forwardedProps[\"vymalo.tier\"]` that is not one of `plan`, `edits`, `auto`, `bypass`; a `forwardedProps[\"vymalo.model\"]` that is not an alias or a `forwardedProps[\"vymalo.reasoningEffort\"]` that is not one of the seven levels", $ref: "#/components/responses/Problem" }
        "401": { $ref: "#/components/responses/Problem" }
        "403": { description: "The caller's roles do not hold `thread.write`, or do not name the agent (`agent.invoke`)", $ref: "#/components/responses/Problem" }
        "404": { description: "The agent is not listed (by the deployment's own list or by the registry, which answered without it) **or its audience leaves the caller out** ([ADR 0045](../decisions/0045-admin-dashboard-in-the-web-and-agent-access-from-the-registry.md): the same problem, \"no such agent\"; but a message to the caller's own thread on that agent is a 403, the thread is read-only for them), or the thread belongs to someone else (whatever the caller's roles; indistinguishable from one that does not exist, including a minted id that collides with another owner's thread); for a `vymalo.fork`, the thread to fork (`from`) is not the caller's or does not exist", $ref: "#/components/responses/Problem" }
        "406": { description: "`Accept` does not admit `text/event-stream`", $ref: "#/components/responses/Problem" }
        "409": { description: "`code: turn_open`: the turn a `vymalo.fork` would copy is still going on, try again when it has ended; a `vymalo.fork` on a thread that exists and is not the fork this request made. Or: the thread targets another agent, a run is already open on it and the run is not one new message that says how it is delivered (`forwardedProps[\"vymalo.send\"]`: `steer` or `interrupt`, [ADR 0036](../decisions/0036-sending-while-an-agent-works.md), [`agui.md`](agui.md#sending-while-an-agent-works)), the run carries an A2UI action for a finished thread (`done`, `failed`, `cancelled`; a **message** on a finished thread is served and starts the thread's next job, ADR 0020), `code: session_closed`: the thread is a helper session that is closed and takes no more messages, or the run continues the thread and asks for a verification gate different from the thread's (a thread's gate is fixed when it is created)", $ref: "#/components/responses/Problem" }
        "413": { description: "The body is larger than 8 MiB, or an A2UI action's `name`, `surfaceId` or `sourceComponentId` is longer than 256 bytes or its `context` larger than 16 KiB", $ref: "#/components/responses/Problem" }
        "415": { description: "`Content-Type` is not `application/json`", $ref: "#/components/responses/Problem" }
        "422": { description: "A `vymalo.fork` whose `after` is not an event of the parent, or whose mentions or UI catalog do not hold; `code: child_mentions`: a message to a helper session's thread mentions agents; `code: session_closes_on_stop`: a Stop & send on a helper session that is not kept open (it closes when its round is stopped); `code: message_id_reused`: a message id the thread already holds, sent with other words (an id is bound to its text, [ADR 0082](../decisions/0082-a-stream-ends-after-a-minute-and-a-message-keeps-its-id.md), so an edited message needs a new id); nothing to run (no new message, no answer, and a run the thread does not hold — a resend of a message the log holds, with the same words, attaches to the run that message opened, whatever `runId` it carries); more than one new message; a new message that is not from the user or has no text; a `resume` payload without `text`; a `resume` answer together with a new message; a reused `runId`; an A2UI action that is malformed, names a surface the thread does not have, or comes with a message, an answer or a cancellation; a `vymalo.tier` above what the caller's roles allow (`the tier 'bypass' is above what your role allows`) or one the agent's live card does not honour (`this agent does not take the tier 'plan'`); `code: model_not_offered` or `code: reasoning_not_offered` (ADR 0086): a `vymalo.model` or `vymalo.reasoningEffort`, or the thread's default it resolves to, that the agent's live card does not offer, with `offered`", $ref: "#/components/responses/Problem" }
        "502": { description: "The target agent could not be reached to validate the release (its live card is unavailable, or the agent refused the card request)", $ref: "#/components/responses/Problem" }
        "503": { description: "Storage is unavailable, the thread is contended, the target agent is rate limiting, or the agent registry cannot say whether the agent exists (\"the agent registry is unreachable\", ADR 0022), or the agent's live card cannot be read to check a `vymalo.tier`, `vymalo.model` or `vymalo.reasoningEffort` (\"the card of the agent <id> could not be read\"); retry after the number of seconds in the Retry-After header", $ref: "#/components/responses/Problem" }
  /agui/threads/{threadId}/connect:
    parameters: [ { $ref: "#/components/parameters/ThreadId" } ]
    get:
      operationId: connectThread
      summary: Follow a thread (AG-UI, our connect extension)
      description: |
        Our documented extension of the AG-UI transport ([`agui.md`](agui.md#connect-binding)):
        replay the thread's events as AG-UI runs, then follow it live across runs, with keepalive
        comments at least every 15 s. `Last-Event-ID` (the `id:` of the last frame the client
        holds, a log `seq`) resumes after that point on any replica; absent or empty replays the
        whole thread. A cursor beyond the last seq waits for new events. `mode=run` closes the
        stream after the active run's terminal event, or right after the replay when no run is open.
        Closing the stream never cancels a run.

        **The stream ends after the deployment's lifetime** (60 s by default, [ADR 0082](../decisions/0082-a-stream-ends-after-a-minute-and-a-message-keeps-its-id.md)),
        whatever credential it was opened with: the shortest of the token's expiry plus its leeway, an hour, and the
        lifetime. Ending is the ordinary path, not an error: nothing leaves the log, and a client that reopens the
        stream with the last `id:` it saw is shown every later event exactly once.

        **Where the log ends.** A frame carries an `id:` (a resume point) and some events have no frame, so a log can
        end in events (`thread_shared`, `thread_unshared`, `ui_catalog`) that no `id:` names. When the replay has
        reached the thread's last event and the last `id:` written is below it, and after any later event that has no
        frame, the stream writes the `seq` of the last event it has read as an `id:` **with no `data:`**: a block the
        SSE parsing rules dispatch no event for, so a client that does not know of it reads the stream as before, and
        one that does knows it holds the thread's `lastSeq`. It is a valid `Last-Event-ID`, never written while a text
        message of the log is open, and never to a client that holds the head already.
      parameters:
        - { name: Last-Event-ID, in: header, description: "Resume after this seq: the id of the last frame the client holds", schema: { type: string, pattern: "^[0-9]*$" } }
        - { name: mode, in: query, description: "`run`: close after the active run; absent: follow across runs until the lifetime ends the stream", schema: { type: string, enum: [run] } }
      responses:
        "200":
          description: The thread's events (`text/event-stream`); frames carry `id:` on resume points
          content:
            text/event-stream:
              schema: { type: string }
              x-itemSchema: { $ref: "#/components/schemas/AgUiSseFrame" }
        "400": { description: "`Last-Event-ID` is not a non-negative integer, or `mode` is not `run`", $ref: "#/components/responses/Problem" }
        "401": { $ref: "#/components/responses/Problem" }
        "403": { description: "No role of the caller holds `thread.read`, or their roles grant nothing", $ref: "#/components/responses/Problem" }
        "404": { description: "The thread does not exist for the caller: it is missing, its id is not a UUID, or it is someone else's (one answer for all three, whatever the caller's roles)", $ref: "#/components/responses/Problem" }
        "406": { description: "`Accept` excludes `text/event-stream`", $ref: "#/components/responses/Problem" }
        "503": { description: "Storage is unavailable; retry after the number of seconds in the Retry-After header", $ref: "#/components/responses/Problem" }
  /agui/shared/{token}/connect:
    parameters: [ { $ref: "#/components/parameters/ShareToken" } ]
    get:
      operationId: connectSharedThread
      summary: Follow a shared thread, read-only (AG-UI), for a signed-in reader
      description: |
        `connectThread` for a thread a link names ([ADR 0040](../decisions/0040-thread-sharing-by-revocable-link.md),
        [`agui.md`](agui.md#reading-a-shared-thread)): the connect stream over the reader projection, replayed from the
        start or from `Last-Event-ID` and then followed, so what the owner writes after sharing is shown too. It
        starts no run and takes no input. **The stream ends** when the link is taken down, replaced by a new one, or
        narrowed below `internal`, at the token's expiry, and at the deployment's lifetime like every stream (an hour
        at most, [ADR 0082](../decisions/0082-a-stream-ends-after-a-minute-and-a-message-keeps-its-id.md)); a reader
        whose stream ended at its lifetime reopens it with its last `id:`, and one whose link was revoked gets the 404.
        The `href` of a kept file in its frames is `getSharedArtifact`'s route, and where the log ends is told as
        `connectThread` tells it (an `id:` with no `data:`), which for this thread is usually the share itself.
      parameters:
        - { name: Last-Event-ID, in: header, schema: { type: string, pattern: "^[0-9]*$" } }
        - { name: mode, in: query, schema: { type: string, enum: [run] } }
      responses:
        "200":
          description: "The shared thread's events (`text/event-stream`), `Cache-Control: no-store, no-transform`"
          content:
            text/event-stream:
              schema: { type: string }
              x-itemSchema: { $ref: "#/components/schemas/AgUiSseFrame" }
        "400": { $ref: "#/components/responses/Problem" }
        "401": { $ref: "#/components/responses/Problem" }
        "403": { description: "No role of the caller holds `thread.read`", $ref: "#/components/responses/Problem" }
        "404": { description: "Every way a link can fail (the same answer as `getSharedThread`)", $ref: "#/components/responses/Problem" }
        "406": { $ref: "#/components/responses/Problem" }
  /agui/public/shared/{token}/connect:
    parameters: [ { $ref: "#/components/parameters/ShareToken" } ]
    get:
      operationId: connectPublicSharedThread
      summary: Follow a public shared thread, read-only (AG-UI), for anybody
      description: |
        `connectSharedThread` for **anybody**, outside the identity layer, for a thread served as `public`, over the public
        projection. Rate limited like `getPublicSharedThread`, and each open stream holds one of the link's stream
        permits (5 per link and 50 in all, by default): 429 when they are taken. It ends at the deployment's lifetime,
        like any stream (an hour at most, [ADR 0082](../decisions/0082-a-stream-ends-after-a-minute-and-a-message-keeps-its-id.md)),
        and the reader reopens it with its last `id:`.
        The `href` of a kept file in its frames is `getPublicSharedArtifact`'s route, and where the log ends is told
        as `connectThread` tells it.
      security: []
      parameters:
        - { name: Last-Event-ID, in: header, schema: { type: string, pattern: "^[0-9]*$" } }
        - { name: mode, in: query, schema: { type: string, enum: [run] } }
      responses:
        "200":
          description: The shared thread's events (`text/event-stream`)
          content:
            text/event-stream:
              schema: { type: string }
              x-itemSchema: { $ref: "#/components/schemas/AgUiSseFrame" }
        "400": { $ref: "#/components/responses/Problem" }
        "404": { $ref: "#/components/responses/Problem" }
        "406": { $ref: "#/components/responses/Problem" }
        "429": { description: "Too many requests, or too many open streams, for this link or for all links", $ref: "#/components/responses/Problem" }
  /agui/threads/{threadId}/history:
    parameters: [ { $ref: "#/components/parameters/ThreadId" } ]
    get:
      operationId: getThreadHistory
      summary: A page of a thread's history, from its newest settled turn back (AG-UI frames, our extension)
      description: |
        A finite read of the same projection `connectThread` streams ([`history.md`](history.md), [ADR 0059](../decisions/0059-a-thread-opens-at-its-end-and-older-turns-load-on-scroll-up.md)):
        a whole number of **settled chains** of runs, as one JSON document, so that a client opens a long thread at its
        end and loads older turns when the person scrolls up, instead of replaying the whole log. With none of the
        query parameters it is the newest `ui.history.pageTurns` turns; `before` goes back from a point, `since` back
        to an event, `after` is a catch-up. The page's `end` is a **settled point**: `Last-Event-ID: <end>` on
        `connectThread` gives the rest, with no run to reopen, and says the chain still open in full. The frames are a
        replay's, never live text. The presence of `ui.history` in `getConfig` says this route exists.
      parameters:
        - { name: before, in: query, description: "An event of the chain the caller holds the page of, normally the `start` of its oldest page: the answer is the turns that precede the chain that holds it. A value beyond the log counts as absent. Not with `after`", schema: { type: integer, minimum: 1 } }
        - { name: limit, in: query, description: "How many turns, 1 to `server.history.maxTurns` (default `ui.history.pageTurns`). Not with `since` or `after`", schema: { type: integer, minimum: 1 } }
        - { name: since, in: query, description: "Go back at least to the chain that holds this event, never beyond `maxTurns` turns or `maxPageBytes`. **Inclusive**: the event itself is in the page, with the rest of its turn in front of it (a page starts at a turn's first event, so it may start earlier than `since`), unless a limit stops it first. A hit's `seq` opens the thread with it. Not with `limit` or `after`", schema: { type: integer, minimum: 1 } }
        - { name: after, in: query, description: "A catch-up: the settled chains after the chain that holds this event, to the newest settled point (at most `maxTurns` turns). The answer has `anchor`. Not with `limit`, `since` or `before`", schema: { type: integer, minimum: 1 } }
      responses:
        "200":
          description: "A page; `Cache-Control: no-store`"
          headers: { Cache-Control: { description: "`no-store`", schema: { type: string } } }
          content:
            application/json:
              schema: { $ref: "#/components/schemas/HistoryPage" }
        "400": { description: "`before`, `since` or `after` is not an integer of 1 or more, `limit` is outside 1 to `server.history.maxTurns`, or parameters that exclude each other are given", $ref: "#/components/responses/Problem" }
        "401": { $ref: "#/components/responses/Problem" }
        "403": { description: "No role of the caller holds `thread.read`, or their roles grant nothing", $ref: "#/components/responses/Problem" }
        "404": { description: "The thread does not exist for the caller: it is missing, its id is not a UUID, or it is someone else's (one answer for all three, whatever the caller's roles)", $ref: "#/components/responses/Problem" }
        "406": { description: "`Accept` excludes `application/json`", $ref: "#/components/responses/Problem" }
        "503": { description: "Storage is unavailable, or the log could not be read in time; retry after the number of seconds in the Retry-After header", $ref: "#/components/responses/Problem" }
  /agui/shared/{token}/history:
    parameters: [ { $ref: "#/components/parameters/ShareToken" } ]
    get:
      operationId: getSharedThreadHistory
      summary: A page of a shared thread's history, for a signed-in reader
      description: |
        `getThreadHistory` for a thread a link names ([ADR 0040](../decisions/0040-thread-sharing-by-revocable-link.md)):
        the same pages over the reader projection, read-only. `Cache-Control: no-store` and `X-Robots-Tag: noindex, nofollow`.
      parameters:
        - { name: before, in: query, schema: { type: integer, minimum: 1 } }
        - { name: limit, in: query, schema: { type: integer, minimum: 1 } }
        - { name: since, in: query, schema: { type: integer, minimum: 1 } }
        - { name: after, in: query, schema: { type: integer, minimum: 1 } }
      responses:
        "200":
          description: A page
          headers: { Cache-Control: { description: "`no-store`", schema: { type: string } } }
          content:
            application/json:
              schema: { $ref: "#/components/schemas/HistoryPage" }
        "400": { $ref: "#/components/responses/Problem" }
        "401": { $ref: "#/components/responses/Problem" }
        "403": { description: "No role of the caller holds `thread.read`", $ref: "#/components/responses/Problem" }
        "404": { description: "Every way a link can fail (the same answer as `getSharedThread`)", $ref: "#/components/responses/Problem" }
        "406": { $ref: "#/components/responses/Problem" }
        "503": { $ref: "#/components/responses/Problem" }
  /agui/public/shared/{token}/history:
    parameters: [ { $ref: "#/components/parameters/ShareToken" } ]
    get:
      operationId: getPublicSharedThreadHistory
      summary: A page of a public shared thread's history, for anybody
      description: |
        `getSharedThreadHistory` for **anybody**, outside the identity layer, for a thread served as `public`, over the
        public projection. Rate limited like `getPublicSharedThread`, and **holds one of the link's stream permits for as
        long as it folds**, as an open `connectPublicSharedThread` does (5 per link and 50 in all, by default): a page
        costs a full fold, and the permit is what bounds how many run at once. 429 when they are taken.
      security: []
      parameters:
        - { name: before, in: query, schema: { type: integer, minimum: 1 } }
        - { name: limit, in: query, schema: { type: integer, minimum: 1 } }
        - { name: since, in: query, schema: { type: integer, minimum: 1 } }
        - { name: after, in: query, schema: { type: integer, minimum: 1 } }
      responses:
        "200":
          description: A page
          headers: { Cache-Control: { description: "`no-store`", schema: { type: string } } }
          content:
            application/json:
              schema: { $ref: "#/components/schemas/HistoryPage" }
        "400": { $ref: "#/components/responses/Problem" }
        "404": { $ref: "#/components/responses/Problem" }
        "406": { $ref: "#/components/responses/Problem" }
        "429": { description: "Too many requests, or too many open streams, for this link or for all links", $ref: "#/components/responses/Problem" }
        "503": { $ref: "#/components/responses/Problem" }
  /agui/agents/{agentId}/capabilities:
    parameters: [ { $ref: "#/components/parameters/AgentId" } ]
    get:
      operationId: getAgentCapabilities
      summary: What an agent can do (AG-UI AgentCapabilities)
      description: |
        The shape is the spec's `AgentCapabilities`; retrieval is ours ([`agui.md`](agui.md#capabilities-document)).
        The agent card is read on every request and never cached (ADR 0008); a card that cannot be read
        in time gives the smaller document (identity with the name only, no `custom`). `custom[<access-tier/v1 URI>]`
        (`https://agents.vymalo.com/a2a/extensions/access-tier/v1`) is `{tiers, default}` while the card lists that extension with
        well-formed params ([ADR 0061](../decisions/0061-the-person-picks-an-access-tier-for-each-message-the-agent-keeps-to-it.md)):
        `tiers` lowest first, each of `plan`, `edits`, `auto`, `bypass` at most once, and `default` one of them, plus `maxTier`, the highest
        tier the person asking may use **of this agent** (over the roles that let them invoke it; absent when none caps it); the web draws
        its tier chip from it. `custom[<commands/v1 URI>]` (`https://agents.vymalo.com/a2a/extensions/commands/v1`) is
        `{commands: [{name, description, argumentHint?}]}` while the card lists that extension with well-formed params
        ([ADR 0079](../decisions/0079-an-agents-own-commands-listed-from-its-card.md), [`commands-v1.md`](commands-v1.md)): the agent's
        own prompt templates, sorted by name and each once, and the web draws its `/` menu from it. A command has no inbound member:
        it is the text of the message the person sends (`/name <arguments>`), which the orchestrator sends as it stands.
      responses:
        "200":
          description: Capabilities
          headers: { Cache-Control: { description: "`no-store`", schema: { type: string } } }
          content:
            application/json:
              schema: { $ref: "#/components/schemas/AgUiAgentCapabilities" }
        "401": { $ref: "#/components/responses/Problem" }
        "403": { description: "The caller's roles do not name the agent for `agent.read`, or grant nothing", $ref: "#/components/responses/Problem" }
        "404": { description: "The agent is not listed (the registry answered without it), **or its audience leaves the caller out** ([ADR 0045](../decisions/0045-admin-dashboard-in-the-web-and-agent-access-from-the-registry.md)): the same problem, so an agent the caller may not read looks like one that does not exist", $ref: "#/components/responses/Problem" }
        "503": { description: "The agent registry cannot say whether the agent exists (\"the agent registry is unreachable\", ADR 0022); retry after the number of seconds in the Retry-After header", $ref: "#/components/responses/Problem" }
components:
  securitySchemes:
    bearerToken:
      type: http
      scheme: bearer
      bearerFormat: JWT
      description: >
        A JWT signed by the configured issuer (RS256, RS384, ES256 or EdDSA), with the configured audience.
        Read when `auth.mode` is `jwt` or `jwt_or_proxy_header`. A missing or refused token gets 401 with
        `WWW-Authenticate: Bearer`; an issuer whose keys cannot be fetched gets 503.
    dpopToken:
      type: http
      scheme: DPoP
      description: >
        A JWT as `bearerToken`, bound to the key of the client (`cnf.jkt`, RFC 7638), sent as `Authorization: DPoP <token>`
        with one `DPoP` header holding a proof signed by that key (RFC 9449, [ADR 0054](../decisions/0054-the-web-holds-its-own-tokens-dpop-bound-in-indexeddb.md)).
        Read only when `auth.dpop` is configured. A bad proof gets 401 with `WWW-Authenticate: DPoP error="invalid_dpop_proof", algs="ES256 EdDSA"`,
        a bad or unbound token `error="invalid_token"`.
    proxyIdentity:
      type: apiKey
      in: header
      name: X-Auth-Request-Email
      description: >
        Set by oauth2-proxy after OIDC login; requests without it get 401. Read when `auth.mode` is
        `proxy_header` (the default) or `jwt_or_proxy_header` without a bearer token.
  parameters:
    ThreadId:
      name: threadId
      in: path
      required: true
      schema: { type: string, format: uuid }
    UserToolServerId:
      name: serverId
      in: path
      required: true
      description: "The id of one of the caller's own servers, `u-` and 10 lowercase letters or digits (`UserToolServer.id`)"
      schema: { type: string, pattern: "^u-[a-z0-9]{10}$" }
    PromptId:
      name: promptId
      in: path
      required: true
      description: "The id of a prompt of the caller's or shared with them, `p-` and 12 lowercase letters or digits (`Prompt.id`). Any other string is 400 `bad_request`"
      schema: { type: string, pattern: "^p-[a-z0-9]{12}$" }
    Sha256:
      name: sha256
      in: path
      required: true
      description: "The SHA-256 of a file's content, 64 lowercase hexadecimal digits (`ArtifactFile.sha256`)"
      schema: { type: string, pattern: "^[0-9a-f]{64}$" }
    ShareToken:
      name: token
      in: path
      required: true
      description: "The token of a share link: 43 characters of the unpadded base64url alphabet, `nonce || MAC` ([ADR 0040](../decisions/0040-thread-sharing-by-revocable-link.md)). Anything else is the one 404"
      schema: { type: string }
    AgentId:
      name: agentId
      in: path
      required: true
      description: Configuration key of the agent, as listed by `listAgents` (`Agent.id`)
      schema: { type: string }
  responses:
    Problem:
      description: RFC 9457 problem details
      content:
        application/problem+json:
          schema:
            type: object
            required: [title, status]
            properties:
              type: { type: string }
              title: { type: string }
              status: { type: integer }
              detail: { type: string }
              at: { type: string, description: "Where a save is refused (`createPrompt`, `updatePrompt`): `name`, `title`, `description`, `body`, `variables`, `variables.<i>`, `variables.<i>.<member>`, `variables.<i>.options.<j>.<member>` or `audience`" }
              offset: { type: integer, minimum: 0, description: "`bad_reference`, `undeclared_variable`: the UTF-16 code unit offset in `body` of the `{{` concerned" }
              question: { type: string, description: "`invalid_answer`: the id of the variable whose answer is refused, or `*` for the whole answer" }
              rule: { type: string, description: "`invalid_answer`: the rule that failed (a closed list, see `renderPrompt`)" }
              offered: { type: array, items: { type: string }, description: "`model_not_offered`, `reasoning_not_offered`: the model aliases or reasoning levels the agent's live card offers (empty when it lists none)" }
              code:
                type: string
                description: "A stable name for the problem, where a client acts on one: `turn_open` (`forkThread`, and `runAgent` with `vymalo.fork`: try again when the turn has ended); `forbidden` (403: the caller's roles lack the permission); `no_access` (403: the caller's roles grant nothing at all); `sharing_disabled` (403, `shareThread` and `rotateThreadShare`: the deployment's cap is `disabled`); `over_cap` (409, `shareThread`: above the deployment's cap); `not_shared` (409, `rotateThreadShare`: the thread is private); `bad_anchor` and `nested_row` (422, `arrangeThread`: the thread to place it by cannot be one; a nested thread cannot be pinned or placed); `thread_active` (409, `deleteThread`: the thread works, stop it first); `too_many_streams` (429: the public streams of a link, or of all links, are taken); `url_refused` (400, `createUserToolServer`, `updateUserToolServer`: the egress guard refuses the URL, `detail` is its reason for a person); `too_many_servers` (409, `createUserToolServer`: the person holds the most they may); `stale_revision` (409, `updateUserToolServer`: the server changed since the revision sent); `credentials_not_kept` (422: the deployment keeps no credentials and the request needs one); `broker_down` (503: the credential broker cannot keep or revoke a credential now); `egress_refused` (422, `authorizeUserToolServer`: a URL the authorization must fetch is refused by the deployment's egress lists, or names a private or reserved address); `oauth_not_configured` (422, `authorizeUserToolServer`: the deployment has no address for the OAuth callback); `authorization_unavailable` (503, `authorizeUserToolServer`: the authorization could not be started now; `Retry-After`); `rate_limited` (429, `authorizeUserToolServer`: ten calls a minute per person; `searchThreads`: a burst of 20 and then two a second; `Retry-After`); `query_empty`, `query_too_long`, `bad_cursor` (400, `searchThreads`: the query is blank or too long, the cursor is not this request's); `bad_request` (400, `searchThreads`: any other malformed request); `search_unavailable` (503, `searchThreads`: the store is down or the search took too long; `Retry-After`); `bad_scope`, `bad_cursor` (400, `listPrompts`), `bad_name`, `bad_title`, `bad_description`, `bad_body`, `bad_reference`, `bad_variable`, `undeclared_variable`, `unused_variable`, `bad_audience` (400, `createPrompt`, `updatePrompt`: a save the rules of `prompts-v1.md` refuse; the members `at` and `offset` say where), `name_taken` and `too_many_prompts` (409, `createPrompt`, `updatePrompt`), `stale_revision` (409, also `updatePrompt`, `deletePrompt`, `renderPrompt`: the prompt changed since the revision sent), `invalid_answer` (422, `renderPrompt`: the members `question` and `rule` say which answer and which rule) and `rendered_too_long` (422, `renderPrompt`); `model_not_offered` and `reasoning_not_offered` (422, `runAgent`, `forkThread`, `patchThread`: the agent's live card does not offer the model or the reasoning effort picked; the member `offered` lists what it does; [ADR 0086](../decisions/0086-a-person-picks-a-model-or-a-reasoning-level-for-a-thread-or-a-message.md)); `client_update_required` (426, any resource call of a deployment with a minimum: the client's `X-Client-Version` is lower, unreadable or absent; the member `minClientVersion` is the minimum, [client-version.md](client-version.md)); `limit_reached` (402, the person has used what they may use: on the AG-UI stream it is one `CUSTOM` event `vymalo.limit_reached` with `{status: 402, code, message}`, see [agui.md](agui.md) \"Chat contract of an application client\"; a message sent again under the same `messageId` is the same message and is never counted twice); `tool_server_needs_auth` and `tool_server_unavailable` (422, `putThreadTools`: a server of the person's own that is not ready; the first is a call to action (a key or an authorization to give), the second a cause that clears by itself)"
  schemas:
    BrowserAuth:
      type: object
      required: [issuer, clientId, scope]
      description: "What a browser signs in with ([ADR 0054](../decisions/0054-the-web-holds-its-own-tokens-dpop-bound-in-indexeddb.md))"
      properties:
        issuer: { type: string, description: "The token issuer, as its tokens say it in `iss` (`auth.jwt.issuer`): its discovery document is at `<issuer>/.well-known/openid-configuration`" }
        clientId: { type: string, description: "The web's OAuth client at the issuer, a public client with no secret (`auth.browser.clientId`)" }
        scope: { type: string, description: "The scope to ask for, tokens separated by single spaces (`auth.browser.scope`, default `openid email profile offline_access`)" }
    Me:
      type: object
      required: [user, roles, permissions, agents]
      properties:
        sharing:
          type: string
          enum: [disabled, internal, public]
          description: "What the deployment lets this person share their threads as ([ADR 0040](../decisions/0040-thread-sharing-by-revocable-link.md)): the cap (`sharing.mode`) when their roles hold `thread.share`, else `disabled`. A hint for the screen, never a check. Always sent by an orchestrator that has sharing; absent from one that has not, which a client reads as `disabled`"
        user: { type: string, description: "The key of everything the person owns: the e-mail, trimmed and lower-cased ([ADR 0033](../decisions/0033-the-orchestrator-is-an-oauth2-resource-server.md))" }
        email: { type: string, description: "The e-mail address the credential says, as it wrote it; absent when it says none" }
        name: { type: string, description: "The display name the credential says; absent when it says none" }
        roles:
          type: array
          items: { type: string }
          description: "The roles that count, sorted: the roles of the credential that `auth.roles` defines, or `auth.defaultRole` when it carries none of them. Empty when nothing is granted"
        permissions:
          type: array
          items: { $ref: "#/components/schemas/Permission" }
          description: "What the roles grant, in the order `agent.read`, `agent.invoke`, `thread.read`, `thread.write`, `thread.share`, `thread.delete`, `artifact.read`, `admin`, `tools.user.add`, `prompts.share`. `tools.user.add` is listed for a role that holds it whether or not the deployment has people's own MCP servers on (the routes are then a 404). `prompts.share` is the only thing that lets a person share a prompt (no role holds it by default)"
        agents: { $ref: "#/components/schemas/MeAgents" }
        maxTier:
          type: string
          enum: [plan, edits, auto, bypass]
          description: "The highest access tier the person may pick for a message ([`access-tier/v1`](access-tier-v1.md#8-roles-and-the-web), [ADR 0061](../decisions/0061-the-person-picks-an-access-tier-for-each-message-the-agent-keeps-to-it.md)): the highest `auth.roles.<role>.maxTier` of their roles that let them invoke an agent, and absent when any of those has no cap (the built-in `user` and `admin` have none; a role that cannot invoke any agent has no say). A hint, never a check, and not what the web draws its chip from: the cap differs by agent, so the capabilities document of the selected agent (`getAgentCapabilities`) carries the person's cap for that agent (`maxTier`), and the orchestrator decides per agent, over the roles that let them invoke that agent, when the message is written (`422`)"
    MyUsage:
      type: object
      required: [month, currency, prices, tasks, models, sandbox, unmeasured, total]
      description: "What a person used in a UTC month, priced (`getMyUsage`)"
      properties:
        month: { type: string, pattern: "^[0-9]{4}-(0[1-9]|1[0-2])$", description: "The month, `YYYY-MM`" }
        currency: { type: [string, "null"], pattern: "^[A-Z]{3}$", description: "The currency of every price on the page, three upper-case letters (`usage.prices.currency`); `null` when the deployment configured no prices" }
        prices: { type: [string, "null"], pattern: "^sha256:[0-9a-f]{16}$", description: "Which price table priced this answer: `sha256:` and the first 16 hex digits of the SHA-256 of its canonical form (the same whatever the order of its entries or how a price was written); `null` when no prices are configured. Prices are the current table's: an answer for a past month is priced as of now" }
        tasks: { type: integer, minimum: 0, description: "How many tasks the month holds" }
        models:
          type: array
          items: { $ref: "#/components/schemas/UsageModelLine" }
          description: "The tokens per provider and model, ordered by provider (none first) and model"
        sandbox:
          type: array
          items: { $ref: "#/components/schemas/UsageSandboxLine" }
          description: "The measured sandbox time per shape, ordered by environment, CPU and memory (a shape without a request first)"
        unmeasured:
          type: array
          items: { $ref: "#/components/schemas/UsageUnmeasured" }
          description: "The tasks whose commands ran where the sandbox is not measured, per environment; their time is not zero, it is not known, and it is never priced"
        total: { $ref: "#/components/schemas/UsageTotal" }
    UsageModelLine:
      type: object
      required: [model, inputTokens, outputTokens, totalTokens, price]
      description: "The month's tokens of one provider and model, AG-UI's `TokenUsage` accounting, with the price"
      properties:
        provider: { type: string, description: "The provider as the agent reported it; absent when it reported none" }
        model: { type: string }
        inputTokens: { type: integer, minimum: 0, description: "Every prompt token (a total)" }
        outputTokens: { type: integer, minimum: 0, description: "Every completion token, reasoning included (a total)" }
        totalTokens: { type: integer, minimum: 0, description: "`inputTokens` plus `outputTokens`" }
        reasoningTokens: { type: integer, minimum: 0, description: "Output tokens spent on reasoning: part of `outputTokens`. Absent until a task of the month says it" }
        cachedInputTokens: { type: integer, minimum: 0, description: "Input tokens read from a provider cache: part of `inputTokens`. Absent until a task of the month says it" }
        cacheWriteInputTokens: { type: integer, minimum: 0, description: "Input tokens written to a provider cache: part of `inputTokens`, priced as input. Absent until a task of the month says it" }
        price: { type: [string, "null"], pattern: "^[0-9]+\\.[0-9]{6}$", description: "What the line costs in `currency`, six decimals (a string: money is never a JSON number); `null` when it cannot be priced (see `total.unpriced`)" }
    UsageSandboxLine:
      type: object
      required: [environment, commands, milliseconds, price]
      description: "The time the commands of the month's runs used in a sandbox of one shape, summed"
      properties:
        environment: { type: string, enum: [kubernetes, local, devcontainer], description: "Where the commands ran; in practice `kubernetes`, the one environment that measures them" }
        cpuMillis: { type: integer, minimum: 0, description: "The CPU the sandbox reserved, in millicores; absent when the pod asked for none (the line is then unpriced)" }
        memoryBytes: { type: integer, minimum: 0, description: "The memory the sandbox reserved, in bytes; absent when the pod asked for none (the line is then unpriced)" }
        commands: { type: integer, minimum: 0, description: "How many commands ran" }
        milliseconds: { type: integer, minimum: 0, description: "The sum of their wall times in milliseconds; commands that ran at the same time are summed, so it can exceed the time the runs took" }
        price: { type: [string, "null"], pattern: "^[0-9]+\\.[0-9]{6}$", description: "What the line costs in `currency`, six decimals; `null` when it cannot be priced" }
    UsageUnmeasured:
      type: object
      required: [environment, tasks]
      properties:
        environment: { type: string, enum: [kubernetes, local, devcontainer] }
        tasks: { type: integer, minimum: 0, description: "How many tasks of the month ran their commands there" }
    UsageTotal:
      type: object
      required: [amount, currency, complete, unpriced]
      properties:
        amount: { type: string, pattern: "^[0-9]+\\.[0-9]{6}$", description: "The sum of the lines that are priced, six decimals. With `complete: false` it is a floor, not the cost" }
        currency: { type: [string, "null"], pattern: "^[A-Z]{3}$", description: "As `currency` of the answer" }
        complete: { type: boolean, description: "`true` when every line is priced and nothing is unmeasured, and for a month with no usage at all" }
        unpriced: { $ref: "#/components/schemas/UsageUnpriced" }
    UsageUnpriced:
      type: object
      required: [models, sandbox, unmeasured]
      description: "What `total.amount` leaves out"
      properties:
        models:
          type: array
          items:
            type: object
            required: [model]
            properties:
              provider: { type: string }
              model: { type: string }
          description: "The model lines with no price"
        sandbox: { type: integer, minimum: 0, description: "How many sandbox lines (shapes) have no price" }
        unmeasured: { type: integer, minimum: 0, description: "How many tasks ran their commands where the sandbox is not measured" }
    Permission:
      type: object
      required: [permission]
      properties:
        permission: { type: string, enum: [agent.read, agent.invoke, thread.read, thread.write, thread.share, thread.delete, artifact.read, admin, tools.user.add, prompts.share] }
        scope:
          type: string
          enum: [own]
          description: "How far a permission over threads reaches (`thread.read`, `thread.write`, `artifact.read`): `own`, the person's own threads, for every role and the only scope there is ([ADR 0039](../decisions/0039-nobody-reads-another-persons-thread.md)). Absent for `agent.*`, `thread.share` and `thread.delete` (which take no scope: they are over one's own thread), `admin`, `tools.user.add` and `prompts.share` (a person's servers and prompts are the person's own)"
    MeAgents:
      type: object
      required: [read, invoke]
      description: "The agents each agent permission is about"
      properties:
        read: { type: array, items: { type: string }, description: "Agent ids, or `[\"*\"]` for every agent; empty when no role holds `agent.read`" }
        invoke: { type: array, items: { type: string }, description: "Agent ids, or `[\"*\"]` for every agent; empty when no role holds `agent.invoke`" }
    Agent:
      type: object
      required: [id, name]
      properties:
        id: { type: string, description: "The agent's id: its configuration key or its registry service id, e.g. coder" }
        name: { type: string }
        aliases:
          type: array
          items: { type: string }
          description: |
            Other names the agent answers to ([ADR 0049](../decisions/0049-the-coder-is-shown-as-adam-agents-may-have-aliases.md)):
            a path (`/agui/agents/{agentId}`), a mention, a `start_job` argument or the `agent` of
            an `ask_agent` that names one is about this agent, and a thread started on one is created
            with `id`. A thread keeps the id it was created with, so a client that reads an older
            thread resolves its `agentId` through this list. The list names an agent once, under
            `id`. Omitted when there are none.
        description: { type: string }
        source:
          type: string
          enum: [static, registry]
          description: |
            Where the agent is listed from: `static` (the deployment's own list) or `registry` (the
            platform's agent registry). Always sent; a client that reads an orchestrator from before
            the registry treats an absent value as `static`.
        tags:
          type: array
          items: { type: string }
          description: |
            Labels the registry keeps on the agent, for a client to show and to filter by; they route,
            authorise and select nothing. Omitted when there are none (a static agent has none).
        cardUrl:
          type: string
          format: uri
          description: URL of the agent card; absent for an agent hosted in the orchestrator's own process
        releases:
          description: Present only when the card advertises the release-channels extension
          type: object
          required: [defaultChannel, channels]
          properties:
            defaultChannel: { type: string }
            channels: { type: object, additionalProperties: { type: string } }
            revisions: { type: array, items: { type: string } }
        pick:
          type: object
          description: |
            What the live card lists for a pick: `model-pick/v1` aliases and `reasoning/v1` levels, with
            the agent's own defaults ([ADR 0086](../decisions/0086-the-model-and-the-reasoning-effort-are-a-pick-on-the-message.md)). It is a
            listing for a screen to draw its chips, never a check: a run that names something else is
            refused. Absent when the card lists neither (or lists one badly).
          properties:
            models:
              type: array
              items:
                type: object
                required: [id, label]
                properties:
                  id: { type: string, description: "The alias a run sends" }
                  label: { type: string }
            modelDefault: { type: string, description: "The agent's own default alias, when the card names one" }
            efforts:
              type: array
              items: { type: string, enum: [none, minimal, low, medium, high, xhigh, max] }
            effortDefault: { type: string, enum: [none, minimal, low, medium, high, xhigh, max], description: "The agent's own default level, when the card names one" }
    HistoryPage:
      type: object
      description: |
        A page of a thread's history ([`history.md`](history.md)): the frames the projector writes for the events `start` to `end`,
        with the same `id`s a connect stream writes. They are **not** the frames of every connect stream (live text is never in a
        page, and a live stream rewrites the logged frames of a reply being written): a client stores only what a page returned.
      required: [threadId, start, end, head, earlier, projection, frames]
      properties:
        threadId: { type: string, format: uuid }
        start: { type: integer, minimum: 1, description: "The first event the page accounts for: a chain's first event (`end + 1` for an empty page)" }
        end: { type: integer, minimum: 0, description: "The last event it accounts for, and a settled point: no run is open after it. Send it as `Last-Event-ID` to `connectThread` and nothing is missed or said twice" }
        head: { type: integer, minimum: 0, description: "The thread's last `seq` when this was read; more than `end` while a chain is open or a message has just arrived" }
        earlier: { type: boolean, description: "Events exist before `start`" }
        projection: { type: integer, minimum: 1, description: "The version of the projection that wrote these frames (`ui.history.projection` of `getConfig` says it too)" }
        frames:
          type: array
          items:
            type: object
            required: [event]
            properties:
              id: { type: integer, minimum: 1, description: "The frame's resume point, as the SSE `id:` of the same frame; absent where the stream has none" }
              event: { $ref: "#/components/schemas/AgUiEvent" }
        anchor:
          type: object
          description: "A catch-up (`after`) only: what the log says about the last run that had ended by event `after`; absent when no run had"
          required: [seq, runId]
          properties:
            seq: { type: integer, minimum: 1 }
            runId: { type: string }
        carry: { $ref: "#/components/schemas/HistoryCarry" }
    HistoryCarry:
      type: object
      description: |
        What the log before a page contributes to the readouts that cover the whole thread, present when the page has events before it
        (`earlier`) and is not a catch-up. It is the **initial state** of the web's own folds, not a second rule: the state of the web built
        from the carry of the oldest page it holds and the frames of the pages it holds equals the state a replay of the whole log gives
        ([`history.md`](history.md), "Carry").
      required: [turns]
      properties:
        turns:
          type: integer
          minimum: 0
          description: "Agent turns before the page: the runs that said something an agent says. Added to the position of the turns the web holds, so a turn keeps its number when older pages load"
        usage:
          type: object
          description: "The token usage before the page (`usage/v1`, [`agui.md`](agui.md) \"Token usage\"); absent when there was none"
          required: [tasks, groups]
          properties:
            tasks:
              type: array
              description: "Per A2A task, what is known of it: its latest totals plus the calls reported after them (all its calls while it has none), per provider and model. The web holds each as a total that a real `vymalo.usage_total` of the task replaces"
              items:
                type: object
                required: [task, models]
                properties:
                  task: { type: string }
                  models: { type: array, items: { $ref: "#/components/schemas/HistoryModelCounts" } }
            groups:
              type: array
              description: "The calls of the agent, of each sub-agent and of each asked agent, apart, in the order they first spent"
              items:
                allOf:
                  - $ref: "#/components/schemas/HistoryTokenCounts"
                  - type: object
                    required: [kind, name, calls]
                    properties:
                      kind: { type: string, enum: [agent, subagent, ask] }
                      name: { type: string }
                      calls: { type: integer, minimum: 1 }
            latest:
              type: object
              description: "The latest call of the thread's agent (`by.kind` `agent`), as the `vymalo.usage` value says it, without its attribution to a path: what the context ring fills with when no call of the pages held is the agent's"
              additionalProperties: true
        files:
          type: array
          maxItems: 500
          description: "The kept files before the page, each hash once, in the order they were handed over; the newest 500. Each is the `content` of its `vymalo.artifact` activity (`kind: file`), so the web reads it as it reads the activity. An `Image` of a surface may name only a file the thread holds"
          items: { type: object, additionalProperties: true }
    HistoryTokenCounts:
      type: object
      required: [inputTokens, outputTokens, totalTokens]
      properties:
        inputTokens: { type: integer, minimum: 0 }
        outputTokens: { type: integer, minimum: 0 }
        totalTokens: { type: integer, minimum: 0 }
        reasoningTokens: { type: integer, minimum: 0 }
        cachedInputTokens: { type: integer, minimum: 0 }
        cacheWriteInputTokens: { type: integer, minimum: 0 }
    HistoryModelCounts:
      allOf:
        - $ref: "#/components/schemas/HistoryTokenCounts"
        - type: object
          required: [model]
          properties:
            provider: { type: string }
            model: { type: string }
    PublicConfig:
      type: object
      required: [ui]
      description: "`{ui, search, prompts}`: the `ui` section of the configuration file, and nothing else of it (a secret is never in it), and the capabilities of this build that are not configuration (`search`, `prompts`)."
      properties:
        search:
          type: object
          description: "**Its presence is the capability**: this orchestrator serves `searchThreads` ([ADR 0068](../decisions/0068-a-person-searches-their-own-threads.md)). An older one leaves it out, and a client then offers no search box. The numbers are what the server enforces, for a client that wants to bound its input."
          required: [maxQueryLength, maxTerms]
          properties:
            maxQueryLength: { type: integer, minimum: 1, description: "The longest `q`, in Unicode scalar values (200)" }
            maxTerms: { type: integer, minimum: 1, description: "The most terms of a query that are used (8)" }
        prompts:
          type: object
          description: "**Its presence is the capability**: this orchestrator serves the prompt library ([ADR 0070](../decisions/0070-a-persons-prompt-library.md), [`prompts-v1.md`](prompts-v1.md)). An older one leaves it out, and a client then offers no library. The numbers are what the server enforces. There is no switch: a build has it or not."
          required: [limit, maxVariables, maxBodyBytes, maxRenderedBytes]
          properties:
            limit: { type: integer, minimum: 1, description: "The most prompts a person holds (100). It is not the page size of `listPrompts`, which is `limit` of that answer: two numbers that are equal today and are not promised to stay so" }
            maxVariables: { type: integer, minimum: 1, description: "The most variables of a prompt (8)" }
            maxBodyBytes: { type: integer, minimum: 1, description: "The longest body in UTF-8 bytes (16384)" }
            maxRenderedBytes: { type: integer, minimum: 1, description: "The longest rendered text in UTF-8 bytes (32768)" }
        ui:
          type: object
          description: "Every key of the `ui` section with its effective value. A client ignores a key it does not know."
          properties:
            showDescriptions:
              type: boolean
              default: true
              description: "Whether the web shows a thread's description ([ADR 0035](../decisions/0035-utility-model-tasks.md)). The API returns it either way."
            history:
              type: object
              description: "How the web opens a long thread ([ADR 0059](../decisions/0059-a-thread-opens-at-its-end-and-older-turns-load-on-scroll-up.md)). **Its presence is the capability**: it is there only when this process serves `getThreadHistory`, so an older orchestrator, or one without the AG-UI surface, leaves it out and the web replays the log as it always did."
              required: [initialTurns, pageTurns, maxTurns, projection, windowed]
              properties:
                initialTurns: { type: integer, minimum: 1, description: "The turns the web asks for when it opens a thread (default 12)" }
                pageTurns: { type: integer, minimum: 1, description: "The turns of the first older page; each later one asks for more, up to `maxTurns` (default 20)" }
                maxTurns: { type: integer, minimum: 1, description: "The most turns a page holds (`server.history.maxTurns`, default 100): the largest `limit` the server accepts, where the pages that grow stop" }
                projection: { type: integer, minimum: 1, description: "The version of the projection this build writes: the `projection` of a page" }
                windowed: { type: boolean, description: "Whether the web opens a thread from its history (`ui.history.windowed`); false opens it by replaying the log" }
    SearchThreadsRequest:
      type: object
      required: [q]
      additionalProperties: false
      description: "A search of the caller's own threads ([`thread-search-v1.md`](thread-search-v1.md)). There is no `owner`: a person's threads are the only ones there are to search."
      properties:
        q: { type: string, description: "The words to look for. Trimmed of U+0020, U+0009, U+000A and U+000D; blank is `query_empty`; more than 200 Unicode scalar values (after the trim) is `query_too_long`. Read as words: quotes, `OR`, `-`, `*` and SQL are punctuation, there is no query syntax. At most 8 terms are used (`maxTerms` of `getConfig`)" }
        limit: { type: integer, minimum: 1, maximum: 50, default: 20, description: "Threads per page. A JSON integer literal: `20.0` and `2e1` are refused, and so is `null` (as for every member)" }
        cursor: { type: string, maxLength: 512, description: "The `next` of the page before, sent back with the same terms (the text of `q` may be spelled differently), `archived` and `branches`; anything else is `bad_cursor`. It is a position (rank, thread) and carries no authority; what is in it is the server's own" }
        archived: { type: string, enum: [exclude, only, include], default: include, description: "`include` (the default): archived threads are searched too (the `thread` says it is archived). `exclude`: the threads that are not archived. `only`: the archived ones" }
        branches: { type: string, enum: [include], description: "`include`: search the threads made by an edit of a message too, as `listThreads` does. Without it they are left out" }
    ThreadSearchPage:
      type: object
      required: [query, results]
      properties:
        query:
          type: object
          required: [terms]
          properties:
            terms: { type: array, items: { type: string }, description: "The terms the query was read as: folded keys (`Café` is `cafe`), at most 8, of 2 to 64 characters, each looked for as the start of a word. Empty when the query keeps none" }
        results: { type: array, items: { $ref: "#/components/schemas/ThreadHit" } }
        next: { type: string, description: "The `cursor` of the next page; absent on the last page" }
    ThreadHit:
      type: object
      required: [thread, rank, hits, messageHits]
      properties:
        thread: { $ref: "#/components/schemas/Thread" }
        rank: { type: integer, enum: [0, 1, 2], description: "2: the title matches. 1: the description does (and the title does not). 0: only messages match. Results are in `rank` order, descending, then newest thread first" }
        hits: { type: array, items: { $ref: "#/components/schemas/SearchHit" }, description: "The title hit, then the description hit, then at most three message hits, newest first" }
        messageHits: { type: integer, minimum: 0, description: "How many messages match in all (every one of `hits` that is a message is among them)" }
    SearchHit:
      type: object
      required: [field, snippet]
      properties:
        field: { type: string, enum: [title, description, message] }
        seq: { type: integer, format: int64, minimum: 1, description: "A message hit only: the `seq` of the event, the number to open the thread at (`getThreadHistory` with `since=<seq>`)" }
        role: { type: string, enum: [person, agent], description: "A message hit only: who said it. `agent` is a final answer" }
        at: { type: string, format: date-time, description: "A message hit only: when it was said" }
        snippet: { $ref: "#/components/schemas/SearchSnippet" }
    SearchSnippet:
      type: object
      required: [text, cutStart, cutEnd, matches]
      description: "A piece of a title, a description or a message around its first match, cut as [`thread-search-v1.md`](thread-search-v1.md#the-snippet) says. `text` is plain text (whitespace flattened) and is never markup."
      properties:
        text: { type: string }
        cutStart: { type: boolean, description: "Something of the document comes before `text`: draw an ellipsis in front" }
        cutEnd: { type: boolean, description: "Something comes after: draw an ellipsis behind" }
        matches:
          type: array
          description: "The words of `text` that start with a term, in order, as UTF-16 code unit offsets into `text` (what a JavaScript string indexes), never inside a surrogate pair"
          items:
            type: object
            required: [start, end]
            properties:
              start: { type: integer, minimum: 0, description: "Inclusive" }
              end: { type: integer, minimum: 1, description: "Exclusive" }
    PromptId:
      type: string
      pattern: "^p-[a-z0-9]{12}$"
      description: "`p-` and 12 lowercase letters or digits. Global: the id alone names a prompt"
    PromptRevision:
      type: string
      pattern: "^[1-9][0-9]{0,18}$"
      description: "Decimal digits. It grows with every write of every prompt and **is never given twice**; a client compares it for equality and never orders by it"
    ChoicesQuestion:
      type: object
      required: [id, question]
      additionalProperties: false
      description: "A question of the UI catalog's `Choices`, version 8 ([`ui-catalog-v1.md`](ui-catalog-v1.md)), as a prompt's variable: the same members and bounds, without the type `images`, without `show` and without an option's `image`, and without `min` and `max` on a question that takes one choice ([`prompts-v1.md`](prompts-v1.md#the-variables)). `required` is true when absent, for every kind."
      properties:
        id: { type: string, pattern: "^[A-Za-z0-9_.:-]{1,64}$", description: "The name of the reference `{{id}}` in the body; unique among the variables" }
        question: { type: string, minLength: 1, maxLength: 300 }
        help: { type: string, maxLength: 300 }
        type: { type: string, enum: [single, multiple, select, text, longText, confirm, number, scale, date, rank], description: "`single` when absent" }
        options:
          type: array
          maxItems: 50
          items:
            type: object
            required: [value, label]
            additionalProperties: false
            properties:
              value: { type: string, pattern: "^[A-Za-z0-9_.:-]{1,64}$" }
              label: { type: string, minLength: 1, maxLength: 120 }
              description: { type: string, maxLength: 300 }
              icon: { type: string, enum: [agent, read, edit, delete, move, search, execute, think, fetch, web, git, test, file, tool, opencode] }
              recommended: { type: boolean }
        multiple: { type: boolean }
        allowOther: { type: boolean }
        required: { type: boolean }
        default:
          description: "A string, or for several choices and a `rank` a list of option values; never substituted by the server"
          anyOf:
            - { type: string, maxLength: 2000 }
            - { type: array, maxItems: 50, items: { type: string } }
        min: { type: integer, minimum: 0, maximum: 50 }
        max: { type: integer, minimum: 1, maximum: 50 }
        yesLabel: { type: string, minLength: 1, maxLength: 40 }
        noLabel: { type: string, minLength: 1, maxLength: 40 }
        minValue: { type: string, pattern: "^-?(0|[1-9][0-9]{0,14})(\\.[0-9]{1,6})?$" }
        maxValue: { type: string, pattern: "^-?(0|[1-9][0-9]{0,14})(\\.[0-9]{1,6})?$" }
        step: { type: string, pattern: "^-?(0|[1-9][0-9]{0,14})(\\.[0-9]{1,6})?$" }
        unit: { type: string, minLength: 1, maxLength: 20 }
        from: { type: integer, minimum: 0, maximum: 1 }
        to: { type: integer, minimum: 2, maximum: 10 }
        fromLabel: { type: string, minLength: 1, maxLength: 60 }
        toLabel: { type: string, minLength: 1, maxLength: 60 }
        minDate: { type: string, pattern: "^[0-9]{4}-[0-9]{2}-[0-9]{2}$" }
        maxDate: { type: string, pattern: "^[0-9]{4}-[0-9]{2}-[0-9]{2}$" }
    PromptAudience:
      type: array
      maxItems: 32
      uniqueItems: true
      items: { type: string, minLength: 1, maxLength: 64, pattern: "^[!-~]+$" }
      description: "Role values of the roles claim, byte for byte; `\"*\"` means everybody and is only allowed alone; empty is private. The server returns the set sorted by bytes"
    Prompt:
      type: object
      required: [id, name, title, description, body, variables, own, revision, updatedAt]
      description: "A prompt ([`prompts-v1.md`](prompts-v1.md)). **A prompt that is not the caller's has `own: false` and no `audience`**: it never names its author, its audience or when it was created."
      properties:
        id: { $ref: "#/components/schemas/PromptId" }
        name: { type: string, pattern: "^[a-z0-9][a-z0-9-]{0,31}$", description: "Unique among the owner's prompts: the `/name` of a command menu" }
        title: { type: string, minLength: 1, maxLength: 120 }
        description: { type: string, maxLength: 500 }
        body: { type: string, description: "1 to 16,384 UTF-8 bytes of text with `{{id}}` references. Plain text: a client never draws it as Markdown or HTML" }
        variables: { type: array, maxItems: 8, items: { $ref: "#/components/schemas/ChoicesQuestion" } }
        own: { type: boolean, description: "Whether the caller owns it" }
        audience: { $ref: "#/components/schemas/PromptAudience" }
        revision: { $ref: "#/components/schemas/PromptRevision" }
        updatedAt: { type: string, format: date-time }
    PromptSummary:
      type: object
      required: [id, name, title, description, variableCount, own, revision, updatedAt]
      description: "A prompt without its `body` and `variables`. `audience` is the caller's own prompts' only."
      properties:
        id: { $ref: "#/components/schemas/PromptId" }
        name: { type: string, pattern: "^[a-z0-9][a-z0-9-]{0,31}$" }
        title: { type: string, minLength: 1, maxLength: 120 }
        description: { type: string, maxLength: 500 }
        variableCount: { type: integer, minimum: 0, maximum: 8 }
        own: { type: boolean }
        audience: { $ref: "#/components/schemas/PromptAudience" }
        revision: { $ref: "#/components/schemas/PromptRevision" }
        updatedAt: { type: string, format: date-time }
    PromptList:
      type: object
      required: [limit, held, items]
      properties:
        limit: { type: integer, minimum: 1, description: "The page size: the most prompts one answer of `listPrompts` holds (100). It is not the cap on what a person owns, which is `prompts.limit` of `getConfig`: two numbers that are equal today and are not promised to stay so" }
        held: { type: integer, minimum: 0, description: "How many prompts the caller owns, whatever the scope" }
        items: { type: array, items: { $ref: "#/components/schemas/PromptSummary" } }
        nextCursor: { type: string, description: "Send it back as `cursor` for the next page; absent on the last" }
    CreatePromptRequest:
      type: object
      required: [name, title, body]
      additionalProperties: false
      properties:
        name: { type: string, description: "`^[a-z0-9][a-z0-9-]{0,31}$`" }
        title: { type: string }
        description: { type: string }
        body: { type: string }
        variables: { type: array, items: { type: object } }
        audience: { type: array, items: { type: string } }
    UpdatePromptRequest:
      type: object
      required: [revision]
      additionalProperties: false
      description: "`revision` and at least one other member; a member given replaces the whole member"
      properties:
        revision: { $ref: "#/components/schemas/PromptRevision" }
        name: { type: string }
        title: { type: string }
        description: { type: string }
        body: { type: string }
        variables: { type: array, items: { type: object } }
        audience: { type: array, items: { type: string } }
    RenderPromptRequest:
      type: object
      additionalProperties: false
      description: "`answers` is the catalog's Choices answer, one entry per variable in variable order. A missing `answers` and a `note` are 422 (`unknown`, `unexpected` for `*`); any other member is 400"
      properties:
        revision: { $ref: "#/components/schemas/PromptRevision" }
        answers:
          type: array
          items:
            type: object
            properties:
              id: { type: string }
              values: { type: array }
              other: { type: string }
              text: { type: string }
        note: { description: "Always refused, whatever its type except `null`: a prompt has no free box, so a request with a `note` is 422 (`unexpected`, `question: \"*\"`). `null` is the wrong type for any member (400)" }
    RenderedPrompt:
      type: object
      required: [text, revision]
      properties:
        text: { type: string, description: "At most 32,768 UTF-8 bytes. Put it in the message box for the person to edit; nothing was sent" }
        revision: { $ref: "#/components/schemas/PromptRevision" }
    Registry:
      type: object
      required: [sources]
      properties:
        sources:
          type: array
          items: { $ref: "#/components/schemas/RegistrySource" }
    RegistrySource:
      type: object
      required: [name, status]
      properties:
        name:
          type: string
          description: "`static` (the deployment's own list) or `platform` (the platform's registry)"
        status:
          type: string
          enum: [ok, unavailable]
        detail:
          type: string
          description: |
            Present only when `unavailable`: why, in words fit for a person ("the registry could not
            be reached", "the registry refused the orchestrator's credentials", "a registry document
            this build cannot read"). Never a URL or a credential.
    AgentTarget:
      type: object
      required: [agentId]
      properties:
        agentId: { type: string }
        release: { type: string, description: "Channel or exact revision; only valid when the agent has releases" }
    Thread:
      type: object
      required: [id, owner, title, target, state, createdAt, updatedAt, lastSeq]
      properties:
        id: { type: string, format: uuid }
        owner: { type: string, description: "The e-mail address of the person the thread belongs to (the key of what they own, lower-cased); it is always the caller's own, since nobody reads another person's thread (ADR 0039). Additive" }
        title: { type: string }
        description:
          type: string
          minLength: 1
          maxLength: 500
          description: |
            What the conversation is about now, in a sentence or two, plain text, one line
            ([ADR 0035](../decisions/0035-utility-model-tasks.md)). Absent until the model or a person
            writes one, and again when a person clears it. Present in `GET /api/threads` items, in
            `getThread`, in the export's `thread` and in AG-UI's `STATE_SNAPSHOT.thread`. Additive.
        target: { $ref: "#/components/schemas/AgentTarget" }
        state: { $ref: "#/components/schemas/ThreadState" }
        tools:
          type: array
          maxItems: 16
          items: { type: string, pattern: "^[a-z0-9][a-z0-9-]{0,30}$" }
          description: |
            The ids of the MCP servers attached to the thread ([ADR 0024](../decisions/0024-mcp-tools-attached-per-conversation.md)),
            sorted: set with `putThreadTools` or when the thread is created, and kept from job to job. Absent when there are none.
            Present in `GET /api/threads` items, in `getThread`, in the export's `thread` and in AG-UI's
            `STATE_SNAPSHOT.thread`. Additive.
        job:
          $ref: "#/components/schemas/ThreadJob"
        share:
          $ref: "#/components/schemas/ThreadShare"
        createdAt: { type: string, format: date-time }
        updatedAt: { type: string, format: date-time }
        lastSeq: { type: integer, format: int64, description: "The `seq` of the thread's last event. It may be an event with no frame (a share, a UI catalog), so no frame's `id:` need name it: a connect stream says it has read as far with an `id:` that has no `data:` (`connectThread`)" }
        pinned: { type: boolean, enum: [true], description: "Present, and `true`, while the owner has the thread pinned ([ADR 0042](../decisions/0042-the-thread-list-is-the-owners.md)); absent otherwise. Set with `arrangeThread`. The owner's routes and the export say it; the reader projection of a shared thread never does. Additive" }
        archived: { type: boolean, enum: [true], description: "Present, and `true`, while the owner has the thread archived; absent otherwise. Set with `arrangeThread`. Same readers as `pinned`. Additive" }
        nestedUnder: { type: string, format: uuid, description: "The thread this one is nested under in the owner's list, one level deep: a fork is made nested under the thread the person sees (its parent; for a fork of a nested fork the same parent; for a fork of an edit the conversation's root), and a child thread (`childOf`, ADR 0072) under its parent's row. Absent for a thread of the list's own level. Display grouping only: the lineage is `forkedFrom`. `arrangeThread` with `nested: false` ejects it. Same readers as `pinned`. Additive" }
        childOf:
          type: object
          description: |
            Present only on the thread of a helper session an agent runs ([ADR 0072](../decisions/0072-child-sessions-are-nested-threads-followed-through-child-sessions-v1.md),
            [`child-sessions-v1.md`](child-sessions-v1.md)): a **child thread**. It is made by the orchestrator when the parent's agent
            says it started the session, never by a request, and is nested under its parent (`nestedUnder` is the parent's row of the list).
            Its log is the helper's own work, one job for each round of the session the orchestrator follows without sending the agent
            anything (`job_started` names the `round`). A person talks to it: a message is the helper's next round, or a steer or an answer while a round works
            (`runAgent`; 409 `session_closed` once it is closed, 422 `child_mentions` when the message mentions agents, 422
            `session_closes_on_stop` for a Stop & send on a session that is not kept open), `cancelThread` stops the round and
            `closeChildSession` closes the session. It is neither forked (`forkThread` is 422 `child_thread`) nor shared
            (`shareThread` is 422 `child_thread`), and deleting its parent deletes it. The reader projection of a shared thread never
            says it. Additive.
          required: [threadId, session]
          properties:
            threadId: { type: string, format: uuid, description: "The parent thread" }
            session: { type: string, maxLength: 128, description: "The session's id: the agent's own and opaque" }
            agent: { type: string, maxLength: 128, description: "The helper's name, as the agent gave it (the agent's text, untrusted, drawn as text)" }
            state: { type: string, enum: [working, idle, closed], description: "The session as the agent last said it, the contract's and not the thread's: `working` while a round is open, `idle` for a kept-open session between rounds, `closed` once it is over for good" }
            keepOpen: { type: boolean, description: "Whether the session goes idle after a round instead of closing. A client offers Stop & send only when it is true (`session_closes_on_stop` otherwise). Additive (S3)" }
            closing: { type: boolean, description: "A close waits for the round to end, or is on its way: the composer says so. Absent when false. Additive (S3)" }
            closeAsked: { type: boolean, description: "A person asked for the close (`closeChildSession`): the thread's own record, not the agent's. Absent when false. Additive (S3)" }
        forkedFrom:
          type: object
          description: |
            Present only on a thread that began as a copy of another ([ADR 0029](../decisions/0029-forking-a-thread-copies-its-log.md)).
          required: [seq, kind]
          properties:
            threadId: { type: string, format: uuid, description: "The thread it was forked from; absent once that thread is deleted (the fork is whole)" }
            seq: { type: integer, format: int64, minimum: 0, description: "The last event of that thread that was copied" }
            kind: { type: string, enum: [fork, edit], description: "`fork`: from the end of a turn, a conversation of its own; `edit`: a branch made by editing a message" }
    ThreadShareRequest:
      type: object
      additionalProperties: false
      required: [visibility]
      properties:
        visibility: { type: string, enum: [internal, public], description: "`internal`: signed-in people with the link; `public`: anybody with the link. `private` is not a value: to stop sharing, `unshareThread`" }
    ThreadShareLink:
      type: object
      required: [visibility, effective, sharedAt]
      description: "What the owner is told after sharing, widening, narrowing or making a new link: the link, recomputed from the thread's row under the current secret, so it can be copied again at any time. Never cached."
      properties:
        visibility: { type: string, enum: [internal, public], description: "What the thread is stored as" }
        effective: { type: string, enum: [private, internal, public], description: "What is served now: the narrower of `visibility` and the deployment's cap (`sharing.mode`), `private` under `disabled`. A thread stored as `public` under a cap of `internal` is served as `internal`; the link is paused, not gone, and a restart under a wider cap brings it back" }
        url: { type: string, description: "The link, `<server.publicUrl>/s/<token>` (the path `/s/<token>` when no public URL is configured): a capability. Absent when the deployment has no `sharing.secret` to make it with (the cap is `disabled`)" }
        sharedAt: { type: string, format: date-time, description: "When the share was last set (a new link and a change of visibility included)" }
    ThreadShare:
      type: object
      required: [visibility, effective]
      description: "The share of a thread that is shared (`share` of `getThread` and of the items of `listThreads`); absent while the thread is private. Only `getThread`, and only to the owner, carries the `url`."
      properties:
        visibility: { type: string, enum: [internal, public] }
        effective: { type: string, enum: [private, internal, public] }
        url: { type: string, description: "The link; only in `getThread`, and absent when the deployment has no `sharing.secret`" }
    SharedThread:
      type: object
      required: [id, title, target, state, lastSeq, visibility, isOwner, createdAt, updatedAt]
      description: |
        A shared thread as a reader is given it: the reader projection ([ADR 0040](../decisions/0040-thread-sharing-by-revocable-link.md), section 7)
        of a `Thread`. **No `owner`, no `forkedFrom`, no `childOf`, no `tools`, no `share`, and nothing of the owner's list (`pinned`, `archived`, `nestedUnder`)**: the owner's address is nowhere in it, and a reader acts on
        nothing. The thread's events come by `connectSharedThread` / `connectPublicSharedThread`.
      properties:
        id: { type: string, format: uuid, description: "The thread's id: not a capability, and the AG-UI `threadId` of the stream" }
        title: { type: string }
        description: { type: string, minLength: 1, maxLength: 500 }
        target: { $ref: "#/components/schemas/AgentTarget" }
        agentName: { type: string, description: "The display name of the agent `target` names (`name` of `listAgents`), for a **signed-in** reader who has the link and no agent list to look it up in: the label the owner's screen shows. An alias resolves to the agent it is an alias of. Nothing else of the agent is told (no card, description, address or release). **Absent for a public (anonymous) reader**, who is given `target.agentId` only: proposed 2026-10-14, awaiting the owner (open question 84). Absent too when the agent is no longer listed or the registry cannot say within a second. Additive" }
        state: { $ref: "#/components/schemas/ThreadState" }
        job: { $ref: "#/components/schemas/ThreadJob" }
        lastSeq: { type: integer, format: int64, description: "The `seq` of the thread's last event, which may be one with no frame (a share, a UI catalog): a connect stream says it has read as far with an `id:` that has no `data:` (`connectSharedThread`), so a reader that waits for its stream's last `id:` to reach this number is not left waiting" }
        visibility: { type: string, enum: [internal, public], description: "What the link is served at now: the narrower of the thread's visibility and the deployment's cap" }
        isOwner: { type: boolean, description: "Whether the person reading is the thread's owner (a signed-in read of their own link): the screen sends them to the thread itself. Always `false` on the public routes" }
        createdAt: { type: string, format: date-time }
        updatedAt: { type: string, format: date-time }
    ToolServer:
      type: object
      description: "An MCP server a person may attach to a conversation: one the deployment offers ([ADR 0024](../decisions/0024-mcp-tools-attached-per-conversation.md)), or one of the person's own ([ADR 0046](../decisions/0046-people-add-their-own-mcp-servers-secrets-in-a-credential-broker.md)). No URL, header, credential, tool allow-list or timeout: those belong to the orchestrator (a person's own URL is in `UserToolServer`). The deployment's servers have `id` and `name` and the members they always had; the person's own add `own`, `status` and `reason`, and have no description, icon or `agents`."
      required: [id, name]
      properties:
        id: { type: string, pattern: "^[a-z0-9][a-z0-9-]{0,30}$", description: "What a thread records, and the prefix of the server's tools on the thread's endpoint (`<id>__<tool>`). A deployment's id; or, for one of the person's own, `u-` and 10 lowercase letters or digits (a deployment's id never starts with `u-` while the feature is on)" }
        name: { type: string, minLength: 1, maxLength: 80, description: "The name the picker and the steps show" }
        description: { type: string, maxLength: 500, description: "What the server is for. Absent when the deployment says nothing" }
        icon: { type: string, pattern: "^data:image/(svg\\+xml|png|webp);base64,", maxLength: 8192, description: "A `data:` URI of at most 8 KiB that the screen draws as it is (an SVG is drawn as an image, never inlined). Never a URL: nothing is fetched. Absent: a generic icon" }
        agents: { type: array, minItems: 1, items: { type: string }, description: "The agent ids the server may be attached for. Absent: every agent" }
        own: { type: boolean, const: true, description: "`true` for one of the person's own servers; absent for the deployment's" }
        status: { $ref: "#/components/schemas/UserToolServerStatus" }
        reason: { $ref: "#/components/schemas/UserToolServerReason" }
    UserToolServerStatus:
      type: string
      enum: [ready, needs_auth, unavailable]
      description: "What a person's own server is to them now. `ready`: connected, offered. `needs_auth`: wants a key or an authorization from the person, a call to action and not an error. `unavailable`: not offered for now, for a reason that clears with its cause. Derived from the definition and the deployment's rules; the credential broker is not asked"
    UserToolServerReason:
      type: string
      enum: [not_connected, reauthorize, disconnected, not_permitted, egress_refused, broker_down]
      description: "Why a person's own server is not `ready`. `needs_auth`: `not_connected` (saved, no key given or authorization done), `reauthorize` (the credential ended: a refresh was refused, or the server answered 401), `disconnected` (the person disconnected it, or the authorization server revoked the grant). `unavailable`: `not_permitted` (the caller's roles lack `tools.user.add`), `egress_refused` (today's egress lists refuse the server's address), `broker_down` (the server wants a credential and this deployment keeps none). A closed list: a client shows its own words for each and a generic one for a code it does not know"
    UserToolAuth:
      type: object
      additionalProperties: false
      required: [kind]
      description: "How a person's server wants to be authenticated to: the **shape**, never a secret (the secret is `secret` of a request, and write-only). The same object is read and written."
      properties:
        kind: { type: string, enum: [none, bearer, api_key, oauth2], description: "`none`: nothing. `bearer`: a token, sent as `Authorization: Bearer`. `api_key`: a key in the header `header`. `oauth2`: authorization code with PKCE, which the orchestrator runs" }
        header: { type: string, minLength: 1, maxLength: 64, pattern: "^[A-Za-z0-9-]+$", description: "`api_key` only, required there: the header the key goes in. Not one the orchestrator or the HTTP client owns (`Authorization`, `Host`, `Accept`, `Content-Type`, `Last-Event-ID`, `Mcp-*`, `Content-Length`, `Transfer-Encoding`, `Connection`, `Upgrade`, `TE`, `Expect`, `Keep-Alive`, `Trailer`, `Cookie`, `Proxy-*`): 400" }
        scopes: { type: array, maxItems: 32, items: { type: string, minLength: 1, maxLength: 128 }, description: "`oauth2` only: the scopes to ask for. Absent or empty: none (the broker asks for no scope the person did not name). Compared as a set" }
        clientId: { type: string, minLength: 1, maxLength: 256, description: "`oauth2` only: the client id of a client the person registered with the authorization server; absent: the broker registers one" }
    UserToolServer:
      type: object
      description: "One of the caller's own MCP servers ([ADR 0046](../decisions/0046-people-add-their-own-mcp-servers-secrets-in-a-credential-broker.md)). **No secret**: `hasCredential` only says whether one is kept. The URL is the person's own, shown back so that they can edit it; it can hold a secret in its path, so the answers that carry it are not cached."
      required: [id, name, own, status, url, auth, state, hasCredential, revision]
      properties:
        id: { type: string, pattern: "^u-[a-z0-9]{10}$", description: "What a thread records, and the prefix of the server's tools (`<id>__<tool>`)" }
        name: { type: string, minLength: 1, maxLength: 80 }
        own: { type: boolean, const: true }
        status: { $ref: "#/components/schemas/UserToolServerStatus" }
        reason: { $ref: "#/components/schemas/UserToolServerReason" }
        url: { type: string, maxLength: 2048, description: "The server's MCP endpoint in its normal form: `https` (or `http` where the deployment allows it), a host, no user information, query or fragment" }
        auth: { $ref: "#/components/schemas/UserToolAuth" }
        state: { type: string, enum: [added, connected, needs_reauth, revoked], description: "Where the server is in the lifecycle of its credential. `added`: saved, no credential yet. `connected`: offered. `needs_reauth`: the credential ended. `revoked`: disconnected. `unavailable` is never a state: it is the `status` while a cause lasts" }
        hasCredential: { type: boolean, description: "Whether a credential is kept for it (a key given, an authorization done). Not the credential" }
        revision: { type: string, pattern: "^[0-9]+$", description: "Opaque: send it back as `revision` of `updateUserToolServer` and compare it for equality only. A new one for every write of the server" }
    UserToolServers:
      type: object
      required: [servers, limit, kinds]
      properties:
        servers: { type: array, maxItems: 8, items: { $ref: "#/components/schemas/UserToolServer" }, description: "The caller's own servers, sorted by name and then id. Empty when `error` is present" }
        limit: { type: integer, minimum: 1, description: "The most servers one person holds" }
        kinds: { type: array, items: { type: string, enum: [none, bearer, api_key, oauth2] }, description: "The kinds of authentication this deployment accepts for a server of one's own: all four where it keeps credentials, only `none` where it keeps none (no `secrets` section). A hint for the screen; the writes check" }
        error:
          type: object
          required: [code, detail]
          description: "Present when the servers could not be listed. A definition that does not read back fails the whole listing in the store; the other servers are not lost, and each can be deleted by its id. The answer names no id (the store's error has none); the operator finds the id of each damaged row in the orchestrator's log, one warning per row, which holds the id and nothing else of it, and tells the owner or deletes the row"
          properties:
            code: { type: string, enum: [unreadable] }
            detail: { type: string }
    UserToolAuthorization:
      type: object
      required: [authorizeUrl, issuer, expiresAt]
      description: "Where to send the person to authorize one of their `oauth2` servers. The `state` is inside `authorizeUrl` and is not a member: nothing else needs it."
      properties:
        authorizeUrl: { type: string, format: uri, description: "The authorization server's endpoint with the PKCE `S256` challenge, the `resource`, the scopes, the `redirect_uri` and the `state`. Open it in a browser. It is a capability for the length of the flow: never log it, never keep it" }
        issuer: { type: string, format: uri, description: "The issuer identifier (RFC 8414) of the authorization server the person is sent to: an `https` URL with no query or fragment. A stranger's MCP server chose it, so the screen shows its host next to the consent button" }
        expiresAt: { type: string, format: date-time, description: "When the flow ends: a callback at or after it finds nothing, and the person begins again" }
    OAuthClientMetadata:
      type: object
      additionalProperties: true
      required: [client_id, client_name, redirect_uris, grant_types, response_types, token_endpoint_auth_method]
      description: "The Client ID Metadata Document: the members the draft names that this client uses"
      properties:
        client_id: { type: string, format: uri, description: "The URL of this document, byte for byte as the broker sends it as the `client_id`" }
        client_name: { type: string, description: "`userToolServers.oauth.clientName`: what the consent page calls the client" }
        redirect_uris: { type: array, minItems: 1, maxItems: 1, items: { type: string, format: uri }, description: "The orchestrator's OAuth callback, and nothing else" }
        grant_types: { type: array, items: { type: string, enum: [authorization_code, refresh_token] } }
        response_types: { type: array, items: { type: string, enum: [code] } }
        token_endpoint_auth_method: { type: string, enum: [none], description: "A public client: the proof is PKCE" }
    CreateUserToolServerRequest:
      type: object
      additionalProperties: false
      required: [name, url, auth]
      description: "A server to add. An unknown member is a 400 that does not name it. **`secret` is write-only**: the token (`bearer`) or the key (`api_key`), required for those two and refused for the others; it is in no response, error or log line."
      properties:
        name: { type: string, minLength: 1, maxLength: 80, description: "The name the picker shows. Trimmed; one line" }
        url: { type: string, maxLength: 2048, description: "The server's MCP endpoint. `https`, a host, no user information, query or fragment, and not refused by the deployment's egress lists: a private, loopback, link-local or reserved address is refused, and a refusal never says which address" }
        auth: { $ref: "#/components/schemas/UserToolAuth" }
        secret: { type: string, minLength: 8, maxLength: 4096, writeOnly: true, description: "The token or the key: 8 to 4096 printable ASCII characters (spaces inside are fine, none at either end). Write-only" }
    UpdateUserToolServerRequest:
      type: object
      additionalProperties: false
      description: "What to change; every member is optional and at least one of `name`, `url`, `auth` and `secret` is needed. `auth` is the whole object when given. **`secret` is write-only**."
      properties:
        name: { type: string, minLength: 1, maxLength: 80 }
        url: { type: string, maxLength: 2048, description: "A new URL revokes the credential, which was issued for the old one, and leaves the server `added`" }
        auth: { $ref: "#/components/schemas/UserToolAuth" }
        secret: { type: string, minLength: 8, maxLength: 4096, writeOnly: true, description: "A new token or key, for a `bearer` or `api_key` server (8 to 4096 printable ASCII characters). Write-only" }
        revision: { type: string, pattern: "^[0-9]+$", description: "The `revision` the listing gave: the change is refused (409 `stale_revision`) when the server changed since" }
    ThreadToolsRequest:
      type: object
      additionalProperties: false
      required: [servers]
      properties:
        servers: { type: array, items: { type: string }, description: "The ids of the servers to have attached, from `listToolServers`: the whole set, `[]` for none. Repeats and order do not matter; at most 16 distinct ones" }
    ThreadTools:
      type: object
      required: [servers]
      properties:
        servers: { type: array, maxItems: 16, items: { type: string, pattern: "^[a-z0-9][a-z0-9-]{0,30}$" }, description: "The ids attached after the change, sorted" }
    ForkRequest:
      type: object
      additionalProperties: false
      description: "Where to cut a thread, and what the fork is. Exactly one of `after` and `replace`; `replace` needs `text`; `after` may come with `text`, which makes the fork with its first message ([ADR 0042](../decisions/0042-the-thread-list-is-the-owners.md)); `messageId` goes with `text`."
      properties:
        after: { type: integer, minimum: 1, description: "An event of the turn to copy: the cut is the end of that turn" }
        replace: { type: integer, minimum: 1, description: "The `seq` of a person's message to replace; the cut is the event before it" }
        text: { type: string, minLength: 1, maxLength: 100000, description: "What the person says instead (with `replace`), or says first in the new fork (with `after`)" }
        messageId: { type: string, maxLength: 256, description: "The id the screen gives the new message (with `text`)" }
        target:
          description: "The agent the fork talks to; the parent's when absent"
          $ref: "#/components/schemas/AgentTarget"
        id: { type: string, format: uuid, description: "The id of the new thread, chosen by the caller so that a repeat is recognised" }
        tier:
          type: string
          enum: [plan, edits, auto, bypass]
          description: "The access tier of the message the fork carries (with `text`; [ADR 0061](../decisions/0061-the-person-picks-an-access-tier-for-each-message-the-agent-keeps-to-it.md)): checked against the caller's role cap and the agent's live card. An edit that names none keeps the tier of the message it replaces"
        locale:
          type: string
          description: "The interface locale of the message the fork carries (with `text`; a BCP 47 tag, [ADR 0085](../decisions/0085-the-interface-language-travels-with-the-message-as-a-hint.md)): a hint. An edit that names none keeps the locale of the message it replaces"
        model:
          type: string
          pattern: "^[a-z0-9._-]{1,64}$"
          description: "The model alias of the message the fork carries (with `text`; [ADR 0086](../decisions/0086-a-person-picks-a-model-or-a-reasoning-level-for-a-thread-or-a-message.md)): checked against the agent's live card (422 `model_not_offered`, nothing written). An edit that names none keeps the pick of the message it replaces, which the card must still offer"
        reasoningEffort:
          type: string
          enum: [none, minimal, low, medium, high, xhigh, max]
          description: "The reasoning effort of the message the fork carries (with `text`; ADR 0086): checked against the agent's live card (422 `reasoning_not_offered`)"
    ChildSessionClose:
      type: object
      additionalProperties: false
      description: "How to close ([ADR 0072](../decisions/0072-child-sessions-are-nested-threads-followed-through-child-sessions-v1.md)). The body may be absent: `cancel` is then false."
      properties:
        cancel: { type: boolean, default: false, description: "Stop the round that is working first, then close. Without it a working session closes when its round ends" }
    ChildSessionCloseAccepted:
      type: object
      required: [state]
      properties:
        state: { type: string, enum: [closing, closed], description: "What the orchestrator's record says after the request: `closing` (a round is working and the session closes when it ends, or the close is on its way) or `closed`. The outcome is the child's `child_session_state` event" }
    ChildSessionStart:
      type: object
      required: [id, agent, description, text]
      additionalProperties: false
      description: "A helper session a person starts ([ADR 0072](../decisions/0072-child-sessions-are-nested-threads-followed-through-child-sessions-v1.md))."
      properties:
        id: { type: string, format: uuid, description: "The request's id, chosen by the caller so that a repeat is recognised" }
        agent: { type: string, minLength: 1, maxLength: 128, description: "The helper, one of the `agents` the agent's card lists in its `child-sessions/v1` entry (`getAgentCapabilities`)" }
        description: { type: string, minLength: 1, maxLength: 80, description: "What the session is for, shown on its row: required, one line, not blank, no control or format character" }
        text: { type: string, minLength: 1, maxLength: 100000, description: "Round 1's prompt. It is the person's message in the child thread and is not in the parent's log" }
        keepOpen: { type: boolean, default: false, description: "The session goes idle after a round, and takes more, instead of closing" }
        tier:
          type: string
          enum: [plan, edits, auto, bypass]
          description: "The access tier of round 1 ([ADR 0061](../decisions/0061-the-person-picks-an-access-tier-for-each-message-the-agent-keeps-to-it.md)): checked against the caller's role cap and the agent's live card, as on `runAgent`"
    ChildSessionStartAccepted:
      type: object
      required: [request]
      properties:
        request: { type: string, format: uuid, description: "The request's `id`; the parent's `child_session_start_ended` names it" }
    Branches:
      type: object
      required: [root, points]
      properties:
        root: { type: string, format: uuid, description: "The thread the conversation started from" }
        points:
          type: array
          items:
            type: object
            required: [seq, index, siblings]
            properties:
              seq: { type: integer, format: int64, description: "The `seq` of the message in this thread" }
              index: { type: integer, minimum: 0, description: "Which of `siblings` is this thread's" }
              siblings:
                type: array
                minItems: 2
                description: "Every version of the message: the original first, then the edits in the order they were made"
                items:
                  type: object
                  required: [threadId, seq, title]
                  properties:
                    threadId: { type: string, format: uuid }
                    seq: { type: integer, format: int64, description: "The `seq` of the message in that thread" }
                    title: { type: string }
    ThreadExport:
      type: object
      description: |
        The document `exportThread` returns. `version` moves only when a member changes meaning or
        goes away; adding a member does not move it, so a reader ignores members it does not know.
      required: [format, version, exportedAt, thread, job, binding, events, eventsTruncated, versions]
      properties:
        format: { type: string, const: another-agentic-system/thread-export }
        version: { type: integer, const: 1 }
        exportedAt: { type: string, format: date-time, description: "When the snapshot was taken" }
        thread:
          description: "The thread as `getThread` answers it"
          $ref: "#/components/schemas/Thread"
        job:
          type: object
          additionalProperties: true
          description: |
            The whole job ledger, which `Thread.job` only summarises (and omits without a gate), as
            the store keeps it: `number` (which job of the thread this is, from 1; a thread is a
            conversation and a message on a finished thread starts its next job, ADR 0020; earlier
            jobs are in `events`, between the `job_started` events), `gate` (the policy: `require`,
            `maxAttempts`, `ci`, `verifier`, `verifierTimeout`), `attempt`, `verification` (counted
            per thread, never reset by a new job), `task` (the person's messages of the
            job in order, each later one after a line `[next message]`, capped: the first message
            and the newest ones are kept, and a line `[… earlier messages omitted …]` stands for
            the ones left out), `branchProblem` (why the agent's last `branch` artifact could not
            be used, when it could not), `summary`, `pushed` (`repository`, `branch`, `commit`),
            `results` (what each source said in the current attempt), `hold`, `title` (whose title
            the thread has: `{"source": "user"}` once a person renamed it, absent while it has the
            first message's words) and `description` (whose description the thread has and which job
            asked the model for it last: `{"source": "model", "askedJob": 2}`, `{"source": "user"}`
            once a person wrote or cleared it, absent while the thread has none and none was asked) and `afterStop` (the text the
            next job starts with while a Stop & send is landing, [ADR 0036](../decisions/0036-sending-while-an-agent-works.md): the
            person's words, as in `task`; absent unless the thread is stopping), `earlierPush` (the commit an earlier attempt of the job pushed,
            which a rework still answers for: [ADR 0018](../decisions/0018-verification-gate-and-rework-loop.md), 2026-10-07) and `builds` (the
            builds of the agents the thread worked with, which `versions.agents` reads: ADR 0053).
            The members of the job itself that are empty (`task`, `branchProblem`, `summary`,
            `pushed`, `earlierPush`, `results`, `hold`, `title`, `description`, `afterStop`, `builds`) are absent; `gate` is always whole, and its `verifier` is `null`
            when there is none.
        versions:
          type: object
          description: |
            Which builds made the thread ([ADR 0053](../decisions/0053-a-thread-export-says-which-builds-made-it.md)),
            so that a developer who reads the file knows what ran. Additive: `version` stays 1, and a reader that does not
            know the member ignores it. No member is ever absent: what is not known says `unknown`.
          required: [orchestrator, agents, web]
          properties:
            orchestrator:
              type: object
              required: [version, revision]
              properties:
                version: { type: string, description: "The crate version of the orchestrator build" }
                revision: { type: string, description: "The commit the orchestrator image was built from (`ORCH_BUILD_REVISION`, set by the image build), or `unknown` for a build that was given none" }
            agents:
              type: array
              description: |
                Every agent that worked in the thread (the binding's, the actors of the log, the agents asked), in the order the
                log names them, with what its live card said when the orchestrator gave it work: one entry for each time the card
                said something different (an agent upgraded between two jobs appears twice). An agent whose card was never
                recorded (every thread older than the field, and a card that could not be read in time) has one entry with
                `name: null` and `version: unknown`. The text is the agents' own: untrusted, cut to 128 bytes.
              items:
                type: object
                required: [agent, name, version]
                properties:
                  agent: { type: string, description: "The agent's id in the orchestrator's configuration or registry" }
                  name: { type: [string, "null"], description: "The card's `name`" }
                  version: { type: string, description: "The card's `version` (adam-rs puts its revision in it as semver build metadata, `0.3.0+<sha>`), or `unknown`" }
                  build: { type: object, additionalProperties: { type: string }, description: "The parameters of the card's build extension, when it lists one (at most 8, values cut to 256 bytes); absent otherwise. Unverified: that adam-rs adds one" }
                  fromJob: { type: integer, minimum: 1, description: "The first job of the thread this build was seen working in; absent for `unknown`" }
            web:
              type: object
              required: [revision]
              properties:
                revision: { type: string, description: "The build of the web that asked for the file (`X-Web-Revision`), or `unknown`" }
        binding:
          type: [object, "null"]
          description: "The A2A side of the thread; null when it has none"
          required: [agentId, contextId]
          properties:
            agentId: { type: string }
            contextId:
              type: [string, "null"]
              description: |
                The A2A context every task of the thread shares, as the agent assigned it
                ([ADR 0055](../decisions/0055-the-agent-assigns-the-a2a-context.md)): `null` until the
                agent's first answer has been read. A thread that began before that ADR has its own id
                here, the context its first message was sent in.
            taskId: { type: [string, "null"], description: "The current or last task" }
            taskState: { type: [string, "null"], description: "The last known state of that task" }
            revision: { type: [string, "null"], description: "The agent revision that served it" }
        events:
          type: array
          description: |
            The thread's append-only event log, in order from `seq` 1 with no gap: the head of
            the log, cut at a number of events and at a number of bytes of serialized events, both
            configurable (defaults 50000 events and 32 MiB). The last `seq` equals
            `thread.lastSeq` unless `eventsTruncated`.
          items: { $ref: "#/components/schemas/Event" }
        eventsTruncated:
          type: boolean
          description: "True when the log is longer than `events`: either bound cut it"
    ThreadState:
      type: string
      description: |
        MVP subset of the job lifecycle (docs/architecture.md). `verifying`: the agent finished and
        the verification gate is checking its work (ADR 0018); only a thread under a gate is ever
        there, and it is implied by the `check_result` events, never announced by a `thread_state`
        event.
      enum: [queued, working, verifying, blocked, done, failed, cancelled]
    ThreadJob:
      type: object
      description: |
        Where a job stands under the verification gate (ADR 0018). Present only when the gate
        requires something; a thread without a gate has no `job`. The AG-UI `STATE_SNAPSHOT`
        carries the same object under `job`.
      required: [attempt, maxAttempts, gate]
      properties:
        number:
          type: integer
          minimum: 1
          description: "Which job of the thread this is. A thread is a conversation: a message on a finished thread starts its next job (ADR 0020). Present from job 2; absent means job 1"
        attempt: { type: integer, minimum: 1, description: "The attempt the agent is on in this job, from 1" }
        maxAttempts: { type: integer, minimum: 1, description: "The attempts there are, the first included" }
        gate:
          type: array
          description: "The sources that must pass before the thread is done"
          items: { $ref: "#/components/schemas/CheckSource" }
        sha:
          type: string
          description: "The commit the agent pushed in this attempt (its `branch` artifact), once it said so; not the commit a check ran on"
    CheckSource:
      type: string
      enum: [ci, agent_checks, verifier]
      description: |
        Where a verdict on the agent's work comes from: CI on the pushed commit, the checks the
        agent ran itself (its `checks` artifact), or a second agent that reviews the commit. A
        build honours only some of them; configuration spells them `ci`, `agent-checks` and
        `verifier`.
    ThreadArrangement:
      type: object
      minProperties: 1
      additionalProperties: false
      description: "How the caller's list shows a thread; see `arrangeThread`"
      properties:
        pinned: { type: boolean }
        archived: { type: boolean }
        nested: { type: boolean, enum: [false], description: "`false` ejects a thread from the thread it is nested under; `true` is a 422" }
        place:
          description: "`\"top\"`, or `{before: id}`, or `{after: id}`"
          oneOf:
            - { type: string, enum: [top] }
            - { type: object, additionalProperties: false, required: [before], properties: { before: { type: string, format: uuid } } }
            - { type: object, additionalProperties: false, required: [after], properties: { after: { type: string, format: uuid } } }
    ThreadPatch:
      type: object
      minProperties: 1
      additionalProperties: false
      properties:
        title:
          type: string
          minLength: 1
          maxLength: 200
          description: "The new title: one line, no control character. Spaces around it are cut before the length is checked."
        description:
          type: string
          maxLength: 500
          description: "The new description: one line, no control character; empty clears it. Spaces around it are cut before the length is checked."
        model:
          type: [string, "null"]
          pattern: "^[a-z0-9._-]{1,64}$"
          description: "The thread's default model alias (`model-pick/v1`, [ADR 0086](../decisions/0086-a-person-picks-a-model-or-a-reasoning-level-for-a-thread-or-a-message.md)); `null` clears it, absent leaves it. Checked against the agent's live card (422 `model_not_offered`)"
        reasoningEffort:
          type: [string, "null"]
          enum: [none, minimal, low, medium, high, xhigh, max, null]
          description: "The thread's default reasoning effort (`reasoning/v1`, [ADR 0086](../decisions/0086-a-person-picks-a-model-or-a-reasoning-level-for-a-thread-or-a-message.md)); `null` clears it, absent leaves it. Checked against the agent's live card (422 `reasoning_not_offered`)"
    Event:
      type: object
      required: [seq, threadId, at, kind, actor, data]
      properties:
        seq: { type: integer, format: int64, description: "Strictly increasing within a thread, starting at 1" }
        threadId: { type: string, format: uuid }
        at: { type: string, format: date-time }
        kind: { $ref: "#/components/schemas/EventKind" }
        actor: { $ref: "#/components/schemas/Actor" }
        data:
          description: Shape depends on kind (see EventData)
          $ref: "#/components/schemas/EventData"
    EventKind:
      type: string
      enum:
        - user_message        # data: { text, messageId?, runId?, delivery?: steer|interrupt, mentions?: [Mention], tier?: plan|edits|auto|bypass, tierCap?: plan|edits|auto|bypass }  (the ids are set when the message came from a surface that names them, e.g. AG-UI; absent otherwise). `delivery` says how a message sent while a job was `queued` or `working` reaches it ([ADR 0036](../decisions/0036-sending-while-an-agent-works.md)): `steer` (a plain Send: the agent reads it in its running task when its card lists `steer/v1`, else after its turn) or `interrupt` (Stop & send, or sent while a stop was landing: the running task is cancelled and the next job starts with the text). Written by the orchestrator, never by a client; absent when nothing was running and in every log written before it existed. `mentions` are the agents the person mentioned in the text ([ADR 0026](../decisions/0026-agent-mentions-as-structured-references.md), [`mentions-v1.md`](mentions-v1.md)), stored as the composer sent them, after the orchestrator checked them against the text, the registry and the person's roles; absent when there are none and in every log written before they existed. Additive.
        - agent_message       # data: { text, final: bool, purpose?: working|answer, via?: turn_output }  (final=false: streamed partial, replaced by the next agent_message with the same messageId). `purpose` says what the words are for in the turn (ADR 0031): `working` for words stated on a `working` status, `answer` for words stated on a status that ends the turn (`completed`, `input_required`, `auth_required`); absent for a plain A2A message and in every log written before it existed. `via` says how an answer was announced when it was not by that status (`turn_output`: the agent called the thread tool, written by the orchestrator with the id `out-<jti>-<n>`; once a turn has such an answer, the core writes everything else the agent says in the turn as `working`, and a later announcement replaces the earlier one by the rule that the answer of a turn is the last message marked `answer` in it). Additive.
        - agent_reasoning     # data: { messageId, text, truncated?: bool }  what the agent's model thought before one of its turns ([ADR 0044](../decisions/0044-an-agents-reasoning-is-relayed-live-and-logged-once-bounded.md), `kind: "reasoning"` of `text-stream/v1`): the reasoning stream's id, its text (at most 32 KiB) and `truncated` when the log does not hold all of it (cut at the bound, a piece lost, or the agent gave up). It is **not** the agent's words: no message, answer or summary, and a fork's conversation does not carry it. Attributed to the agent, written before the `agent_message` of the same turn. Additive: a reader that does not know the kind skips it.
        - agent_status        # data: { status: submitted|working|input_required|auth_required|completed|failed|canceled, detail?, tier?: plan|edits|auto|bypass }  (mirrors A2A TaskState; auth_required blocks the thread like input_required, detail names what to authenticate to). `tier` is the access tier the agent says it works under ([ADR 0061](../decisions/0061-the-person-picks-an-access-tier-for-each-message-the-agent-keeps-to-it.md), [`access-tier-v1.md`](access-tier-v1.md)): the echo in its task's metadata, as sent, on the first status after the agent said it and again after it changed; recorded and never compared with what was asked; absent when the agent echoed none and in every log written before it existed. Additive
        - artifact            # data: { name, mimeType?, uri?, text?, file?: ArtifactFile }  e.g. a branch, a PR URL, a patch, or a file the agent handed over (ADR 0032): then `file` is the reference (`sha256`, `size`, `filename?`) to the bytes kept in the artifact store and served by `getArtifact`, and `mimeType` is the type the worker sniffed. An artifact entry without `file` and `text` and `uri`, followed by an `error` event, is a file that was not kept (too large, over the job's limits, no store, the store failed). Additive.
        - thread_state        # data: { state: ThreadState }
        - error               # data: { message, retryable: bool }
        - ui_surface          # data: { operations: [A2UI message] }  an A2UI payload an agent sent to render (ADR 0013), already through the orchestrator's envelope check; attributed to the agent. Additive.
        - ui_action           # data: { surfaceId, name, sourceComponentId, context, version, runId?, tier?, tierCap? }  what the user did on an A2UI surface of the thread (ADR 0013); attributed to the user. Additive.
        - ci_result           # data: { provider: github|generic, repository, sha, branch?, name, conclusion: success|neutral|skipped|failure|cancelled|timed_out|action_required|stale|startup_failure, url?, summary? }  a CI provider reported a completed check on a commit (ADR 0017); attributed to the system. Additive; logged since MVP slice 6 (the CI webhooks).
        - check_result        # data: { source: CheckSource, attempt, status: pending|passed|failed, name?, commit?, summary?, stale?, findings?: [string] }  a source of the verification gate answered (ADR 0018); attributed to the system. `findings` are untrusted text (at most 20 items and 16 KiB). `stale`: the answer was for a verification that is no longer the current one and decided nothing. Additive.
        - job_started         # data: { job: integer, round?: { number: integer, by?: agent|person } }  a message on a finished thread started the thread's next job; `job` is its number, from 2 (ADR 0020); in a **child thread** (ADR 0072) a round the orchestrator follows without having sent it starts a job too, and the event names it in `round` (`job` is 1 for the first round): absent for a job a message started; attributed to the system, right after the `user_message` that caused it (or alone, for a message redelivered to the agent). Additive.
        - rework              # data: { attempt, maxAttempts, findings: [{ source: CheckSource, findings: [string] }] }  the gate failed and the agent was sent back to work; `attempt` is the one that starts now (ADR 0018); attributed to the system. Additive.
        - ui_catalog          # data: { catalogId, version: integer, digest, catalog }  the person's screen sent a version of its UI component catalog, a `ui-catalog/v2` A2UI inline catalog (ADR 0023, ADR 0075); attributed to the user, once per digest, appended first in the commit of the message or action that carried it. Additive. It has no AG-UI frame: the thread's current catalog is `thread.uiCatalog` of the state snapshot.
        - agent_step          # data: { id, path: [string], kind: subagent|tool|command|message, label, state: running|waiting|completed|failed|canceled, phase: start|update|end, icon?, detail?, input?, output?, ioDropped? }  a step of the agent's work started, moved or ended (ADR 0025, `steps/v1`); attributed to the agent that reported it, or to the orchestrator for a step it reports itself. `path` is the chain of step ids the step runs under, outermost first (empty at the top). Coalesced: a step logs its start, its end and at most 4 updates, so the log stays bounded. `input` (with the start) and `output` (with the end) say what the tool was called with and what it returned, cut, redacted and budgeted (ADR 0030). Additive.
        - thread_titled       # data: { title, source: model|user }  the thread has a new title: a person renamed it (`patchThread`, `source: user`, attributed to the person) or the orchestrator had a model write one after the agent's first reply (`source: model`, attributed to the orchestrator, [ADR 0005](../decisions/0005-openai-compatible-model-endpoint.md): the model is asked at most twice per thread, and never once a person has renamed it). `threads.title` and this event are one commit, so a listing that says the title has the event in the log. The title the thread starts with (the first words of its first message) has no event. Additive.
        - thread_described    # data: { description, source: model|user }  the thread has a new description ([ADR 0035](../decisions/0035-utility-model-tasks.md)): the orchestrator had a model write one when a job ended or paused for the person (`source: model`, attributed to the orchestrator; at most once per job, and only when the conversation grew by `minNewMessages` since the last one) or a person wrote it (`patchThread`, `source: user`, attributed to the person; an empty `description` is the person clearing it). `threads.description` and this event are one commit. Once a person has written or cleared it, the model never writes it again. Additive.
        - thread_forked       # data: { from: { threadId, seq }, kind: fork|edit, title, description?, target: AgentTarget }  the thread began as a copy of another (ADR 0029): its events `1..=from.seq` are the parent's, copied with the same `seq`, then this event at `from.seq + 1`, then the thread's own. `fork`: a copy to the end of a turn ("fork from here", "continue with another agent"); `edit`: a copy to just before a message of a person, followed by the message edited (a branch). `title` is the parent's title when the fork was made, and the fork's; `description` is the parent's description then (absent when it had none), and the fork's. `target` is the agent the fork talks to. Attributed to the person. Additive; the first event of the thread's own life, so a reader that skips it still reads a coherent log.
        - tools_attached      # data: { servers: [string] }  MCP servers were attached to the thread (ADR 0024): the ids newly attached, sorted, never empty; attributed to the person, in the commit of the first message when the thread was created with servers (after the message), or alone (`putThreadTools`). Ids only: no URL, no credential. Additive. AG-UI says it as a `vymalo.tools` activity and `thread.tools` of the state snapshot.
        - tools_detached      # data: { servers: [string] }  MCP servers were detached from the thread (ADR 0024): the ids detached, sorted, never empty; attributed to the person, or to the person's fork whose agent may not use a server its copied log had attached. Additive.
        - ask_started         # data: { ask: integer, agent, by: main|ask:<n>, depth: integer, text, stepId, parentStepId? }  the agent the job runs on (or an agent it asked) asked an agent the person mentioned to do part of the work ([ADR 0026](../decisions/0026-agent-mentions-as-structured-references.md), `ask_agent` of [`thread-tools-v1.md`](thread-tools-v1.md)); attributed to the asking agent. `ask` is the ask's number in the job, from 1; `depth` is 1 for the addressed agent's ask; `text` is what was asked (untrusted, at most 16 KiB); `stepId` is `ask-<ask>`. Additive; written since migration 0014, by the thread tools' `ask_agent` (not built yet), and not drawn by AG-UI yet.
        - thread_shared       # data: { visibility: internal|public, nonce_sha256 }  the owner shared the thread, widened or narrowed the share, or made a new link ([ADR 0040](../decisions/0040-thread-sharing-by-revocable-link.md)): `nonce_sha256` is the lower-case hex SHA-256 of the nonce the link is built on, which tells one link from another and is useless as a link (the nonce itself is never in the log, because the export carries it). Attributed to the owner. `threads.visibility`, `share_nonce` and this event are one commit. Additive; a build that does not know it cannot read a log that has one, so roll the build out before raising `sharing.mode` above `disabled`. A fork copies it as history; the fork itself is private. No AG-UI frame.
        - thread_unshared     # data: {}  the owner took the link down ([ADR 0040](../decisions/0040-thread-sharing-by-revocable-link.md)); the thread is private again and the nonce is gone. Attributed to the owner. Additive. No AG-UI frame.
        - ask_finished        # data: { ask: integer, state: completed|input_required|auth_required|failed|rejected|canceled|timed_out, text?, question?, artifacts?: [{ name, uri?, mimeType? }], error?, form?: true }  the ask ended, exactly once ([ADR 0026](../decisions/0026-agent-mentions-as-structured-references.md)); attributed to the asked agent for what it said, to the orchestrator for a deadline, a cancel (the person stopped the job, or the task that asked ended) or an agent it could not reach. `text` is the answer (untrusted, at most 64 KiB), `question` the question the agent asked back and `error` why it did not complete (at most 4 KiB each), `artifacts` at most 20. `form` is true when the asked agent showed an interface and then waited (`input_required` or `auth_required`): it waits for the **person's** answer to a form that nobody can see, so the ask is over, the task is cancelled, and the agent is not asked again in this job (a model does not answer a form that was shown). It is set when an interface was shown, or when a claim that re-attached saw the task wait (it cannot know what the task drew); an ask is sent the job's UI catalog, so a question with choices is a form, while a question in words that was seen from the start has no `form` and is still the asking agent's to answer. Absent when false and in older logs. Additive.
        - model_usage         # data: { job, agent, task, call, path: [string], provider?, model, inputTokens, outputTokens, totalTokens, reasoningTokens?, cachedInputTokens?, cacheWriteInputTokens?, contextWindow?, counted?: false }  the tokens of one model call an agent made ([ADR 0056](../decisions/0056-token-usage-per-model-call.md), [`usage-v1.md`](usage-v1.md)), once per call (the idempotency key `a2a:<task>:usage:<call>`): `job` is the thread's job, `agent` the agent that made it, `task` its A2A task, `call` the agent's id for it. `path` is the step path it ran under, as `agent_step`'s: empty for the agent's own call, the sub-agent step's path and the step for a call under one, `["ask-<n>"]` for an asked agent's. The counts are AG-UI 1.0's `TokenUsage` accounting (`totalTokens` is the sum of the two totals, the others are parts of them); `contextWindow` is the model's window as the deployment configured it. Labels and numbers only. At most 10 000 per job. Attributed to the agent. Additive.
        - model_usage_total   # data: { job, agent, task, path?: [string], totals: [{ provider?, model, inputTokens, outputTokens, totalTokens, reasoningTokens?, cachedInputTokens?, cacheWriteInputTokens? }], sandbox?: { environment, usage?: [{ cpuMillis?, memoryBytes?, commands, milliseconds }] }, counted?: false }  a task's token totals when it ended or paused ([ADR 0056](../decisions/0056-token-usage-per-model-call.md)): one entry per provider and model, every call of the task included, its sub-agents' too; the latest of a task is the record (a resumed task reports the totals of all its calls so far). `path` is `["ask-<n>"]` for an asked agent's task and absent for the thread's agent's. `sandbox` is the time the run's commands used in the environment they ran in ([`usage-v1.md`](usage-v1.md) section 5, ADR 0056 amended 2026-10-27), present only when the agent reported a valid one; events written before it existed have none. Attributed to the agent. Additive.
        - child_session_opened   # data: { session, thread, agent, description, keepOpen: bool, by?: agent|person, round?: integer }  a helper session the agent started became a child thread ([ADR 0072](../decisions/0072-child-sessions-are-nested-threads-followed-through-child-sessions-v1.md), [`child-sessions-v1.md`](child-sessions-v1.md)): `session` is the agent's id for it, `thread` the child thread made for it, `agent` and `description` the helper's name and what it was asked to do (the agent's text, untrusted, at most 256 characters), `round` the number of the round the report named when the session was first seen. Once per session, in the **parent's** log, attributed to the parent's agent; the helper's own work is in the child's log. Additive (S2).
        - child_session_reported # data: { session, thread, round: integer, report: done|failed|canceled|blocked }  a round of a child session ended ([ADR 0072](../decisions/0072-child-sessions-are-nested-threads-followed-through-child-sessions-v1.md)): `blocked` is a round waiting for the person. Once per round a report names, in increasing order, in the parent's log, attributed to the parent's agent: a round that ended unseen between two reports is not reported (the child's log has it), and none is reported after the session closed. Additive (S2).
        - child_session_closed   # data: { session, thread }  a child session closed ([ADR 0072](../decisions/0072-child-sessions-are-nested-threads-followed-through-child-sessions-v1.md)): once per session, in the parent's log, attributed to the parent's agent. Additive (S2).
        - child_session_start_asked # data: { request, agent, description, keepOpen: bool, tier? }  a person asked to start a helper session (`startChildSession`, [ADR 0072](../decisions/0072-child-sessions-are-nested-threads-followed-through-child-sessions-v1.md)): in the **parent's** log, attributed to the person, written with the request. **It holds no text**: the prompt is the person's message in the child thread, once it opens. Additive (S3).
        - child_session_start_ended # data: { request, outcome: opened|failed, session?, thread?, reason? }  the outcome of a start: `opened` names the session and the child thread (`child_session_opened` with `by: person` is written with it), `failed` says why in `reason`, the agent's own words (untrusted, at most 512 bytes; "the agent could not be reached" when it never answered). Exactly once per request, in the parent's log, attributed to the system. Additive (S3).
        - child_session_close_asked # data: { session, cancel: bool }  a person asked to close the session (`closeChildSession`): in the **child's** log, attributed to the person. Additive (S3).
        - child_session_state # data: { session, state: working|idle|closed, closing: bool, closeAsked?: true }  the session changed state or started or stopped closing, as the agent said it, or the agent refused a close a person asked (then `closeAsked` is absent, the ask being cleared): in the child's log, attributed to the system, written when `state` or `closing` differs from the last and after a refused close. `closeAsked` is `true` while a person's close is asked and not answered. Additive (S3).
        - trusted_request    # data: { component: McpCredential, hints: { name?, scopes?, expiresInDays? } }  an agent asked the client to draw a trusted component ([ADR 0083](../decisions/0083-trusted-components-the-agent-names-and-the-client-draws.md), [`trusted-components-v1.md`](trusted-components-v1.md)): the component and the agent's bounded suggestions (untrusted text), never a secret. Attributed to the agent; moves no state. A request for a component the agent's card did not offer never reaches the log. Additive; an older build refuses the kind at its check.
    Mention:
      type: object
      description: "An agent a person mentioned in a message, as a structured reference ([`mentions-v1.md`](mentions-v1.md), [ADR 0026](../decisions/0026-agent-mentions-as-structured-references.md)): the identity is `agentId`, never the label."
      required: [agentId, label, start, end]
      additionalProperties: false
      properties:
        agentId: { type: string, description: "The id the registry gives the agent" }
        label: { type: string, minLength: 2, description: "The text shown for it as it stands in the message: `@` and 1 to 63 more characters, at most 64 UTF-16 code units in all. Equal to the text at `start`..`end`." }
        start: { type: integer, minimum: 0, description: "Where the label begins in the message text, in UTF-16 code units (what a JavaScript string indexes), inclusive; never inside a surrogate pair" }
        end: { type: integer, minimum: 1, description: "Where the label ends, in UTF-16 code units, exclusive; greater than `start`, at most the length of the text" }
        cardUrl: { type: string, description: "The agent's card URL as the composer saw it in the agent list; when given it equalled the registry's when the message was checked" }
        tierCap: { type: string, enum: [plan, edits, auto, bypass], readOnly: true, description: "Set by the orchestrator, never by a client ([ADR 0061](../decisions/0061-the-person-picks-an-access-tier-for-each-message-the-agent-keeps-to-it.md)): the highest tier the person's roles let them use of the mentioned agent, when one caps it. The agent is asked under the highest tier it offers within it. Absent when none does and in older logs" }
    ArtifactFile:
      type: object
      description: "A file kept in the artifact store, as an `artifact` event refers to it (ADR 0032). The bytes are never in the log; `GET /api/threads/{threadId}/artifacts/{sha256}` serves them to the owner, and a share link's own routes to its readers."
      required: [sha256, size]
      properties:
        sha256: { type: string, pattern: "^[0-9a-f]{64}$", description: "The SHA-256 of the content: with the thread, its key in the store" }
        size: { type: integer, format: int64, minimum: 0, description: "Bytes" }
        filename: { type: string, description: "The name the agent gave the file, cleaned of path parts and control characters (untrusted text)" }
    Actor:
      type: object
      required: [type, name]
      properties:
        type: { type: string, enum: [user, agent, system] }
        name: { type: string, description: "User email, agent id, or 'orchestrator'" }
        revision: { type: string, description: "Agent revision that produced this event, when known (ADR 0008 echo)" }
    EventData:
      type: object
      additionalProperties: true
      properties:
        text: { type: string }
        messageId:
          type: string
          description: "agent_message: the agent's stable message id. agent_reasoning: the id of the reasoning stream (the agent's, and the live reasoning's). user_message: the id the surface gave the message, when it did (optional, absent otherwise)."
        delivery:
          type: string
          enum: [steer, interrupt]
          description: "user_message only (ADR 0036): how a message sent while a job was `queued` or `working` reaches it. `steer`: a plain Send; the agent reads it in its running task when its card lists `steer/v1`, else after its turn (today every agent: the extension is not built yet). `interrupt`: Stop & send, or a message sent while a stop was landing; the running task is cancelled and the next job starts with the text (joined with any other message sent meanwhile). Absent (never `null`) when nothing was running, and in older logs. A thread that is stopping is still `working`."
        mentions:
          type: array
          maxItems: 16
          items: { $ref: "#/components/schemas/Mention" }
          description: "user_message only (ADR 0026, `mentions/v1`): the agents the person mentioned in `text`, in order, as the composer sent them (offsets count UTF-16 code units). Checked before the message was written: each label is the text at its offsets, the agent is one the registry lists and the person's roles let them invoke, and the card URL, when given, was the registry's. Absent (never `[]`) when the message mentions nobody, and in older logs. The addressed agent is told them only when its card lists `mentions/v1`; the chat shows them as chips either way."
        pick:
          type: object
          additionalProperties: false
          description: "user_message only ([ADR 0086](../decisions/0086-a-person-picks-a-model-or-a-reasoning-level-for-a-thread-or-a-message.md), `model-pick/v1`): the model and the reasoning effort the message was sent with, as resolved (the message's own over the thread's default) and checked against the agent's live card. A redelivery, a fork's first message, an edit and an export carry it. Absent (never `{}`) when the message named none, and in older logs. An alias the agent offered, never a provider model id."
          properties:
            model: { type: string, pattern: "^[a-z0-9._-]{1,64}$" }
            reasoningEffort: { type: string, enum: [none, minimal, low, medium, high, xhigh, max] }
        tier:
          type: string
          enum: [plan, edits, auto, bypass]
          description: "user_message (ADR 0061, `access-tier/v1`): the access tier the message was written and sent under, one of the four, within the person's role cap and honoured by the agent's live card when it was written. It is the tier the person named (`forwardedProps[\"vymalo.tier\"]`, the body of a fork), or, for a message that named none, the one the orchestrator resolved: the job's tier for an answer to a blocked job or an action, the replaced message's for an edit, and the highest tier the agent offers within the person's cap for a person with a role cap. Absent when the message was sent under none (a person with no cap who named none, an agent that lists no tiers), and in older logs. The agent is sent it only while its card still lists the extension and honours it. For a person with a role cap whose agent's card offered no tier then, the message has no `tier` but a `tierCap`, and the orchestrator decides the tier from the live card at every send. agent_status (ADR 0061): the access tier the agent says it works under, its echo; see the event's description."
        tierCap:
          type: string
          enum: [plan, edits, auto, bypass]
          description: "user_message, ui_action (ADR 0061): the cap of the person's role on the agent, kept when the message (or action) could be given no `tier` because the agent's card offered none when it was written. Everything the orchestrator sends for it afterwards (a rework, a steer that became a delegation, a redelivered row) carries the cap, and the dispatcher decides the tier from the live card at each send: none while the card lists none, the highest tier within the lower of its `default` and the cap once it does, a failed job when it has none that low. Absent when the message has a `tier`, for a person with no cap, and in older logs. ui_action: also `tier`, the tier the action went out under."
        runId:
          type: string
          description: "user_message, ui_action: the id of the run the message or action started or continued, when the surface names runs (optional, absent otherwise)."
        final: { type: boolean }
        truncated:
          type: boolean
          description: "agent_reasoning only (ADR 0044): the text is not the whole of what the model thought. Absent when it is whole."
        purpose:
          type: string
          enum: [working, answer]
          description: "agent_message only (ADR 0031): what the words are for in the agent's turn. `working`: said while the agent works (the sentence before a tool call), stated on a `working` status. `answer`: the words that end the turn, stated on `completed`, `input_required` or `auth_required`, or an answer the agent announced with the `turn_output` thread tool (`via`). Absent when the protocol does not say (a plain A2A message, a log written before the field existed): a reader treats the last text of an ended turn as its answer, unless the turn has an announced answer. The answer of a turn is the last message marked `answer` in it; an earlier one is working text."
        via:
          type: string
          enum: [turn_output]
          description: "agent_message only, with `purpose: answer` (ADR 0031): how the answer was announced when it was not by the status that ends the turn: the agent called the `turn_output` thread tool (`thread-tools/v1`, ADR 0031 amendment). The message id is `out-<jti>-<n>`."
        status:
          type: string
          description: "agent_status: submitted, working, input_required, auth_required, completed, failed or canceled. check_result: pending, passed or failed."
        detail:
          type: string
          description: "agent_status: the agent's status message. agent_step: more words about the step (a failure, a result); untrusted text, at most 1000 characters."
        servers:
          type: array
          items: { type: string }
          description: "tools_attached, tools_detached: the server ids that were attached (or detached) by this event, sorted, never empty. Ids only."
        name: { type: string }
        mimeType: { type: string }
        uri: { type: string }
        file:
          description: "artifact only (ADR 0032): the file the artifact is, kept in the artifact store. Absent for text and links and for a file that was not kept."
          $ref: "#/components/schemas/ArtifactFile"
        state:
          description: "thread_state: the ThreadState the thread entered. agent_step: where the step stands (running, waiting, completed, failed or canceled). ask_finished: how the ask ended (completed, input_required, auth_required, failed, rejected, canceled or timed_out). child_session_state (ADR 0072): the helper session's state, `working`, `idle` or `closed`."
          anyOf:
            - { $ref: "#/components/schemas/ThreadState" }
            - { type: string, enum: [running, waiting, completed, failed, canceled] }
            - { type: string, enum: [input_required, auth_required, rejected, timed_out] }
            - { type: string, enum: [working, idle, closed] }
        ask:
          type: integer
          minimum: 1
          description: "ask_started, ask_finished (ADR 0026): the ask's number in the job, from 1."
        agent:
          type: string
          description: "ask_started: the agent that was asked (an agent id). model_usage, model_usage_total: the agent that spent the tokens. child_session_opened: the helper's name, as the agent gave it. child_session_start_asked: the helper the person chose."
        by:
          anyOf:
            - { type: string, pattern: "^(main|ask:[1-9][0-9]*)$" }
            - { type: string, enum: [agent, person] }
          description: "ask_started: who asked, the addressed agent (`main`) or an earlier ask of the job (`ask:<n>`). child_session_opened (ADR 0072): who started the session, the parent's model (`agent`) or a person (`person`); absent when the agent did not say."
        depth:
          type: integer
          minimum: 1
          description: "ask_started: how deep in a chain of asks, 1 for the addressed agent's ask."
        stepId:
          type: string
          description: "ask_started: the step the ask is shown as, `ask-<ask>`."
        parentStepId:
          type: string
          description: "ask_started: the step of the asking agent the ask belongs under, when the caller named one."
        question:
          type: string
          description: "ask_finished: the question an asked agent asked back (state input_required or auth_required). Untrusted text, at most 4 KiB."
        artifacts:
          type: array
          maxItems: 20
          items:
            type: object
            required: [name]
            additionalProperties: false
            properties:
              name: { type: string }
              uri: { type: string }
              mimeType: { type: string }
          description: "ask_finished: what the asked agent handed back."
        error:
          type: string
          description: "ask_finished: why the ask did not complete. Untrusted text, at most 4 KiB."
        form:
          type: boolean
          description: "ask_finished (ADR 0026, amended): true when the asked agent showed an interface and then waited (state input_required or auth_required), or when a claim that re-attached to its task saw it wait (it cannot know what the task drew). What it waits for is the person's answer to a form, and an asked agent's screens are not shown, so a model cannot give it: the ask ends, the task is cancelled and the agent is not asked again in this job. An ask is sent the job's UI catalog, so a question with choices is a form and a question in words is not. Absent when false and in older logs."
        message: { type: string }
        retryable: { type: boolean }
        operations:
          type: array
          description: "ui_surface only: the A2UI messages of one payload, as the agent sent them. Each is an object with a `version` (`1.0`, the only dialect since the cutover, [ADR 0075](../decisions/0075-a2ui-v1-0-cutover.md); an event written before it keeps `v0.9` or `v0.9.1`, which is relayed as it was sent and never acted on) and exactly one of createSurface, updateComponents, updateDataModel, deleteSurface, whose body names a `surfaceId`. At most 256 messages and 64 KiB per payload."
          items: { type: object, additionalProperties: true }
        surfaceId:
          type: string
          description: "ui_action only: the surface the user acted on (one the thread has), at most 256 bytes."
        sourceComponentId:
          type: string
          description: "ui_action only: the component that triggered the action (A2UI requires it), at most 256 bytes."
        context:
          type: object
          additionalProperties: true
          description: "ui_action only: the context the component's action declared, resolved by the renderer; at most 16 KiB."
        version:
          oneOf:
            - type: string
            - type: integer
              minimum: 1
              maximum: 1000000
          description: "ui_action: the A2UI version of the surface. Anything written now is `1.0` (ADR 0075, a hard cutover); an event written before it may hold `v0.9` or `v0.9.1`, which still **reads** (history, export, a fork) while an action on such a surface is refused with 422, so no new one is written — the field is what the log holds, not what a client may send. ui_catalog: the version of the catalog (an integer from 1, 9 for the first v2 catalog), raised by the UI with every change; the highest is the newest."
        catalogId:
          type: string
          maxLength: 256
          description: "ui_catalog only: the catalog's stable id, an absolute https URL. A UI keeps it across versions."
        digest:
          type: string
          pattern: "^sha256:[0-9a-f]{64}$"
          description: "ui_catalog only: `sha256:` and the lowercase hex of SHA-256 over the canonical JSON of `catalog` (keys sorted, no whitespace, integers in decimal). The orchestrator recomputes it and refuses a catalog whose digest differs."
        catalog:
          type: object
          additionalProperties: true
          description: "ui_catalog only: the catalog, `{catalogId, protocolVersion, components: {<Name>: <JSON Schema of the component>}}` — a `ui-catalog/v2` document, `protocolVersion` exactly `1.0` ([`ui-catalog-v2.md`](ui-catalog-v2.md)): at most 64 KiB and 64 components, with no `$ref`, `$id`, `$anchor` or `$schema` and only integer numbers. An event written before the cutover keeps a v1 document (no `protocolVersion`). Stored, relayed to agents, never interpreted by the orchestrator."
        source:
          description: "check_result: the source that answered. thread_titled: who wrote the title (a person, or the model). thread_described: who wrote the description (a person, or the model)."
          anyOf:
            - { $ref: "#/components/schemas/CheckSource" }
            - { type: string, enum: [model, user] }
        title:
          type: string
          minLength: 1
          maxLength: 200
          description: "thread_titled: the thread's new title. thread_forked: the parent's title when the fork was made, which is the fork's."
        description:
          type: string
          maxLength: 500
          description: "thread_described: the thread's new description; empty when a person cleared it. thread_forked: the parent's description when the fork was made, which is the fork's; absent when it had none. child_session_opened: what the helper was asked to do (the agent's text, untrusted, at most 256 characters). child_session_start_asked: what the person said it is for (at most 80 characters)."
        from:
          type: object
          required: [threadId, seq]
          properties:
            threadId: { type: string, format: uuid }
            seq: { type: integer, minimum: 0 }
          description: "thread_forked only: the thread that was forked and the last of its events that was copied (the cut). 0 when nothing was copied (an edit of the first message)."
        target:
          $ref: "#/components/schemas/AgentTarget"
        job:
          type: integer
          minimum: 1
          description: "job_started: the number of the job that started (from 2; 1 for the first round a child thread follows). model_usage, model_usage_total: the job the tokens were spent in (from 1)."
        session:
          type: string
          minLength: 1
          maxLength: 128
          description: "child_session_opened, child_session_reported, child_session_closed, child_session_start_ended, child_session_close_asked, child_session_state (ADR 0072): the session's id, the agent's own and opaque, at most 128 UTF-8 bytes (`maxLength` counts characters)."
        thread:
          type: string
          format: uuid
          description: "child_session_opened, child_session_reported, child_session_closed, child_session_start_ended (ADR 0072): the child thread made for the session. A reader of a shared thread never sees these events."
        keepOpen:
          type: boolean
          description: "child_session_opened, child_session_start_asked: whether the session goes idle after a round instead of closing."
        round:
          anyOf:
            - { type: integer, minimum: 1 }
            - type: object
              required: [number]
              additionalProperties: false
              properties:
                number: { type: integer, minimum: 1 }
                by: { type: string, enum: [agent, person] }
          description: "child_session_opened: the number of the round the report named when the session was first seen. child_session_reported: the round that ended. job_started (ADR 0072): the round of a child session this job follows, `{number, by?}`; absent for a job a message started."
        request:
          type: string
          format: uuid
          description: "child_session_start_asked, child_session_start_ended (ADR 0072): the id of the `startChildSession` request."
        outcome:
          type: string
          enum: [opened, failed]
          description: "child_session_start_ended: how the start ended."
        reason:
          type: string
          maxLength: 512
          description: "child_session_start_ended with `outcome: failed`: why, in the agent's own words (untrusted text, drawn as text, never an instruction)."
        cancel:
          type: boolean
          description: "child_session_close_asked: the person asked to stop the working round first."
        closing:
          type: boolean
          description: "child_session_state: a close waits for the round to end or is on its way."
        closeAsked:
          type: boolean
          description: "child_session_state: a person's close is asked and not answered yet; absent (false) otherwise, and after the agent refused it."
        report:
          type: string
          enum: [done, failed, canceled, blocked]
          description: "child_session_reported: how the round ended; `blocked` is a round that waits for the person."
        component:
          type: string
          enum: [McpCredential]
          description: "trusted_request only (ADR 0083, `trusted-components/v1`): the trusted component the agent asked the client to draw. A closed set: this build draws `McpCredential` (a person's own MCP server credential, ADR 0046). The agent never draws it and never sees a secret."
        hints:
          type: object
          additionalProperties: false
          description: "trusted_request only: the agent's suggestions, for the client to show as suggested by the agent and for the person to edit and confirm. Every member is optional and bounded; a request with a hint out of bounds is not logged."
          properties:
            name: { type: string, minLength: 1, maxLength: 80, description: "A name to suggest (for McpCredential, a server's name): no control character." }
            scopes:
              type: array
              maxItems: 32
              items: { type: string, minLength: 1, maxLength: 128, pattern: "^[\\x21\\x23-\\x5b\\x5d-\\x7e]+$" }
              description: "Scopes to suggest: at most 32, each 1 to 128 bytes of visible ASCII with no space, quote or backslash (RFC 6749, as ADR 0046 checks one)."
            expiresInDays: { type: integer, minimum: 1, maximum: 3650, description: "How long the person may want the grant to last." }
        counted:
          type: boolean
          enum: [false]
          description: "model_usage, model_usage_total (ADR 0072): `false` when the usage ledger does not count the tokens because they are the parent's, whose totals hold them (a round a child thread follows and a person did not start). Absent when counted, and in every event written before the member existed."
        attempt:
          type: integer
          minimum: 1
          description: "check_result: the attempt the answer belongs to. rework: the attempt that starts now."
        maxAttempts:
          type: integer
          minimum: 1
          description: "rework only: the attempts there are."
        commit:
          type: string
          description: "check_result only: the commit the answer was about, when the source named one."
        id:
          type: string
          maxLength: 200
          description: "agent_step only: the step's id, unique within the thread (an agent's own id is prefixed with its task id)."
        path:
          type: array
          maxItems: 8
          items: { type: string, maxLength: 200 }
          description: "agent_step: the ids of the steps this one runs under, outermost first; empty at the top. At most the 8 nearest. model_usage: the steps the call ran under (`[\"ask-<n>\"]` for an asked agent), empty for the agent's own call. model_usage_total: `[\"ask-<n>\"]` for an asked agent's task, absent otherwise (ADR 0056)."
        kind:
          type: string
          enum: [subagent, tool, command, message, fork, edit]
          description: "agent_step: what the step is (subagent, tool, command or message). thread_forked: how the fork was made (fork or edit)."
        label:
          type: string
          maxLength: 200
          description: "agent_step only: one line that says what the step is doing. Untrusted text."
        phase:
          type: string
          enum: [start, update, end]
          description: "agent_step only: which moment of the step this event is. A step that was reported ended without a start is one event, an `end`."
        icon:
          type: string
          description: "agent_step only: a name from the icon vocabulary of `steps/v1` (agent, read, edit, delete, move, search, execute, think, fetch, web, git, test, file, tool, opencode), or, for a step the orchestrator reports itself, `mcp-server:<id>`."
        input:
          type: object
          additionalProperties: true
          description: "agent_step only (ADR 0030): what the tool was called with, a JSON object of at most 4096 bytes serialized with credentials redacted (`\"[redacted]\"`), strings cut at 512 characters; or `{\"_cut\": true, \"bytes\": n}` when it was bigger. Logged once per step, with its start (or with the first report that has it). Absent when the agent sent none, when the record is off (`ORCH_STEPS_RECORD_IO=false`) or when the job's budget was spent. Untrusted."
        output:
          type: object
          required: [text]
          additionalProperties: false
          properties:
            text:
              type: string
              description: "What the tool returned, or the error it returned: at most 8192 bytes (the head and the tail of a longer text, with a line between that says how many bytes are not kept), credentials redacted, no control characters but line break and tab. Untrusted text."
            truncated:
              type: boolean
              enum: [true]
              description: "`text` is not all of what the tool returned. Absent when it is."
            bytes:
              type: integer
              minimum: 0
              description: "The size of all of what the tool returned, in bytes. Only with `truncated`."
            error:
              type: boolean
              enum: [true]
              description: "`text` is the error the tool returned. Absent otherwise."
          description: "agent_step only (ADR 0030): what the tool returned, on the step's end. Same absences as `input`."
        task:
          type: string
          maxLength: 256
          description: "model_usage, model_usage_total (ADR 0056): the agent's A2A task the tokens were spent in."
        call:
          type: string
          maxLength: 128
          description: "model_usage: the agent's id for the model call, unique within its task."
        provider: { type: string, maxLength: 128, description: "model_usage: the provider as the agent knows it (e.g. `openai`), when it said." }
        model: { type: string, maxLength: 128, description: "model_usage: the model as configured." }
        inputTokens: { $ref: "#/components/schemas/TokenCount" }
        outputTokens: { $ref: "#/components/schemas/TokenCount" }
        totalTokens: { $ref: "#/components/schemas/TokenCount" }
        reasoningTokens: { $ref: "#/components/schemas/TokenCount" }
        cachedInputTokens: { $ref: "#/components/schemas/TokenCount" }
        cacheWriteInputTokens: { $ref: "#/components/schemas/TokenCount" }
        contextWindow:
          allOf: [{ $ref: "#/components/schemas/TokenCount" }]
          description: "model_usage: the model's context window as the deployment configured it, when it did."
        totals:
          type: array
          maxItems: 32
          description: "model_usage_total: one entry per provider and model, AG-UI's `TokenUsage` accounting."
          items:
            type: object
            required: [model, inputTokens, outputTokens, totalTokens]
            properties:
              provider: { type: string, maxLength: 128 }
              model: { type: string, maxLength: 128 }
              inputTokens: { $ref: "#/components/schemas/TokenCount" }
              outputTokens: { $ref: "#/components/schemas/TokenCount" }
              totalTokens: { $ref: "#/components/schemas/TokenCount" }
              reasoningTokens: { $ref: "#/components/schemas/TokenCount" }
              cachedInputTokens: { $ref: "#/components/schemas/TokenCount" }
              cacheWriteInputTokens: { $ref: "#/components/schemas/TokenCount" }
        sandbox:
          type: object
          required: [environment]
          description: "model_usage_total (`usage-v1.md` section 5): the time the run's commands used in the environment they ran in. Absent: the run asked for no environment, or the agent's member did not pass the door (the totals beside it were kept). **`usage` absent is not measured, never zero**; `usage: []` is an environment that was asked for and ran no command."
          properties:
            environment:
              type: string
              enum: [kubernetes, local, devcontainer]
              description: "Where the commands ran. Only `kubernetes` measures them today."
            usage:
              type: array
              maxItems: 8
              description: "One entry per shape of the sandbox. Absent: not measured."
              items:
                type: object
                required: [commands, milliseconds]
                properties:
                  cpuMillis: { type: integer, minimum: 0, maximum: 9007199254740991, description: "The CPU the sandbox reserved, in millicores; absent when it reserved none." }
                  memoryBytes: { type: integer, minimum: 0, maximum: 9007199254740991, description: "The memory the sandbox reserved, in bytes; absent when it reserved none." }
                  commands: { type: integer, minimum: 0, maximum: 9007199254740991, description: "How many commands ran." }
                  milliseconds: { type: integer, minimum: 0, maximum: 9007199254740991, description: "The sum of the commands' wall times; concurrent commands are summed, so it can exceed the time the run took." }
        ioDropped:
          type: boolean
          enum: [true]
          description: "agent_step only (ADR 0030): the step had an `input` or an `output` that the job's budget (2 MiB of both over all its steps) had no room for, and it was dropped. Absent otherwise."
        summary:
          type: string
          description: "check_result, ci_result: a one-line summary from the source. Untrusted text."
        stale:
          type: boolean
          description: "check_result only: the answer was for a verification that is no longer the current one, and decided nothing."
        findings:
          type: array
          description: "check_result: what is wrong, as strings. rework: per failed source, {source, findings}. Untrusted text; at most 20 items and 16 KiB per source."
          items: {}
    TokenCount:
      type: integer
      minimum: 0
      maximum: 9007199254740991
      description: "A number of tokens (ADR 0056, `usage-v1.md`): an integer from 0 to 2^53 - 1."
    AgUiRunAgentInput:
      description: The AG-UI 1.0 `RunAgentInput` (the vendored JSON Schema, `$defs/RunAgentInput`)
      $ref: "../../orchestrator/crates/agui-proto/schema/ag-ui-1.0.schema.json#/$defs/RunAgentInput"
    AgUiEvent:
      description: Any AG-UI 1.0 event (the vendored JSON Schema, `$defs/Event`); the `data:` of every frame
      $ref: "../../orchestrator/crates/agui-proto/schema/ag-ui-1.0.schema.json#/$defs/Event"
    AgUiAgentCapabilities:
      description: The AG-UI 1.0 `AgentCapabilities` (the vendored JSON Schema, `$defs/AgentCapabilities`)
      $ref: "../../orchestrator/crates/agui-proto/schema/ag-ui-1.0.schema.json#/$defs/AgentCapabilities"
    AgUiSseFrame:
      description: |
        One server-sent-events message of an AG-UI stream, as OpenAPI 3.2 `itemSchema` would say it
        (carried as `x-itemSchema` because this document is 3.1): `data` is one JSON `AgUiEvent`, `id`
        is the log `seq`, present only on a resume point. There is no `event:` name.
      type: object
      required: [data]
      properties:
        id: { type: string, pattern: "^[0-9]+$" }
        data:
          type: string
          contentMediaType: application/json
          contentSchema: { $ref: "#/components/schemas/AgUiEvent" }
