# Agent Blueprint Protocol cheatsheet

This reference is for developers using the Elixir or TypeScript facade. It lists the common calls for decoding, encoding, reconciling, and running conformance.

## Elixir facade

### Decode artifacts

Excerpt. Provide the artifact bytes before running these calls.

<!-- fragment -->
```elixir
{:ok, blueprint} = AgentBlueprintProtocol.decode_blueprint(blueprint_bytes)
{:ok, deployment} = AgentBlueprintProtocol.decode_deployment(deployment_bytes)
{:ok, envelope} = AgentBlueprintProtocol.decode_federation_envelope(envelope_bytes)
```

### Encode and compute identity

Excerpt. `blueprint` is a decoded Blueprint.

<!-- fragment -->
```elixir
{:ok, canonical_bytes} = AgentBlueprintProtocol.canonical_bytes(blueprint)
digest = AgentBlueprintProtocol.Blueprint.content_digest(blueprint)
tagged_digest = AgentBlueprintProtocol.Digest.to_tagged(digest)
```

### Reconcile artifacts

Excerpt. Supply host bounds, revision support, keys, and observations in an `AgentBlueprintProtocol.Reconcile.Inputs` struct.

<!-- fragment -->
```elixir
{:ok, evidence} = AgentBlueprintProtocol.reconcile(blueprint, deployment, inputs)
```

### Declare host core-field support

For a host that supports every core field of revision 1, declare the union of the Blueprint and Deployment vocabularies:

```elixir
alias AgentBlueprintProtocol.{Blueprint, Deployment, Negotiation}
{:ok, blueprint_members} = Blueprint.members(1)
{:ok, deployment_members} = Deployment.members(1)
support = %Negotiation.Support{
  revisions: MapSet.new([1]),
  core_fields: MapSet.new(blueprint_members ++ deployment_members)
}
```

Use `support` with `negotiate/2` or `Reconcile.Inputs`. `Federation.members/1` returns the separate TaskEnvelope vocabulary.

### Supply host extensions

`Negotiation.Support.registry` maps namespaces to `ExtensionRegistry` entries.
Supply criticality, state, and a schema digest pin; put the held schema in
`schemas`. In TypeScript, the public `Support` type exposes the same fields
with `schemaDigest` spelling. Only the protocol's two federation entries ship.
See the [complete examples](extensions.md#register-a-namespace-with-the-host).

### Run the corpus

From a checkout of the repository:

```sh
mix conformance.verify
```

## TypeScript facade

### Import package-root functions

Excerpt. Provide byte arrays and inputs from your application.

<!-- fragment -->
```ts
import {
  canonicalBytes,
  decodeBlueprint,
  decodeDeployment,
  decodeFederationEnvelope,
  reconcile
} from "@agent-blueprint-protocol/verifier";

const blueprint = decodeBlueprint(blueprintBytes);
const deployment = decodeDeployment(deploymentBytes);
const envelope = decodeFederationEnvelope(envelopeBytes);
if (blueprint.ok && deployment.ok) {
  const result = reconcile(blueprint.value, deployment.value, inputs);
}
```

### Run the embedded corpus

```sh
npx @agent-blueprint-protocol/verifier@1.1.0
```

### Run an external implementation

Command template (excerpt). Replace `./example-adapter` with the adapter executable supplied by the implementation.

```sh
npx @agent-blueprint-protocol/verifier@1.1.0 conformance run --corpus ./conformance --results results.json -- ./example-adapter
```

Cost amounts are integer millionths of the named currency unit. Verification returns evidence and does not grant permission to act.

## Next steps

- [Elixir quickstart](quickstart.md)
- [TypeScript guide](typescript.md)
- [Complete error reference](errors.md)
