Skip to content

Open-source AI teammates in Slack, Teams, Discord, Telegram and Mattermost. Self-host it, with any agent harness and any model.

3.0 KB
Raw Blame
"""Generated from artifacts.yaml by scripts/gen_artifacts.py.

Do NOT edit this file. Edit artifacts.yaml and run `just artifacts`.
"""

from typing import Final, NamedTuple


class ContractRange(NamedTuple):
    """The revisions of one contract an artifact implements.

    Two peers are compatible when their ranges overlap; they then
    operate at the lower of the two `speaks`.
    """

    speaks: int
    accepts: int


# Where each artifact is. Says nothing about compatibility — that is
# CONTRACTS below. The two must never be derived from one another.
ARTIFACT_VERSIONS: Final[dict[str, str]] = {
    "switch-core": "0.31.0",
    "switch-console": "0.40.1",
    "agent-runtime": "0.8.2",
    "sidecar": "1.9.12",
    "gateway": "0.31.0",
    "setup": "0.31.0",
    "switch-decision": "0.31.0",
    "switch-decision-strands": "0.31.0",
    "helm-chart": "0.31.0",
    "hosted-controller": "0.31.0",
    "hosted-controller-chart": "0.31.0",
    "compose": "0.31.0",
}

CONTRACTS: Final[dict[str, dict[str, ContractRange]]] = {
    # The wire protocol between switch-core's agent bridge and an agent runtime: the event stream, its frame shapes, the resume cursor, and the tool-call channel.
    "agent-protocol": {
        "switch-core": ContractRange(speaks=9, accepts=8),
        "agent-runtime": ContractRange(speaks=9, accepts=8),
    },
    # The HTTP API switch-core serves to first-party UI clients. Excludes the authentication surface, which is deliberately frozen and unversioned so that a client can always authenticate far enough to be told what is wrong.
    "gateway-api": {
        "switch-core": ContractRange(speaks=1, accepts=1),
        "switch-console": ContractRange(speaks=1, accepts=1),
    },
    # The interface of the published standalone compose artifact — its service names, profiles, and environment variables — which Switch Console's local-server mode drives.
    "stack-compose": {
        "switch-console": ContractRange(speaks=2, accepts=1),
        "compose": ContractRange(speaks=2, accepts=1),
    },
    # How Switch Console controls a deployed sidecar on a remote host: the ready file it reads, and the control channel it opens.
    "sidecar-control": {
        "switch-console": ContractRange(speaks=1, accepts=1),
        "sidecar": ContractRange(speaks=1, accepts=1),
    },
    # The database schema switch-core expects. Internal to switch-core — this contract is never disclosed in an externally facing response.
    "db-schema": {
        "switch-core": ContractRange(speaks=1, accepts=1),
    },
}


def contract_range(contract: str, artifact: str) -> ContractRange:
    """Return an artifact's declared range for a contract.

    Raises KeyError for a pair the registry does not know. An
    unregistered pair is a bug in the caller, never a reason to
    assume a default — a wrong default reads as compatible.
    """
    try:
        return CONTRACTS[contract][artifact]
    except KeyError:
        raise KeyError(
            f"artifacts.yaml declares no range for artifact {artifact!r} "
            f"in contract {contract!r}"
        ) from None