kv2-agent-protocol (0.1.0)

Published 2026-06-12 00:23:21 +00:00 by kapable

Installation

[registries.forgejo]
index = "sparse+" # Sparse index
# index = "" # Git

[net]
git-fetch-with-cli = true
cargo add kv2-agent-protocol@0.1.0 --registry forgejo

About this package

KAP — Kapable Agent Protocol: the shared wire vocabulary every Kapable agent backend emits (assist, designer, conductor normalization) and every agent UI consumes

kv2-agent-protocol

Rust types for KAP — the Kapable Agent Protocol: the shared wire vocabulary between Kapable agent backends and agent UIs. The normative spec is SPEC.md; the enums in src/lib.rs are its executable form (serde, internally tagged on "type", snake_case).

The core vocabulary is kapable-assist's live protocol adopted verbatim (golden decode fixtures in the test suite pin those exact wire shapes), plus KAP's additive extensions: turn framing (turn_started/turn_finished), artifacts (artifact/artifact_update — the island's pin-as-cast vehicle), and cost/budget (cost_update/budget_exceeded).

Consumers

  • kapable-assist (H8 in research/agentic-harness/STANDARDIZATION.md) — replaces its private protocol.rs with this crate; adds the turn/artifact/budget events additively.
  • claude-conductor daemon (H3) — the per-harness event-normalization layer emits these types as its output vocabulary; the daemon's session/canvas/schedule surface stays a conductor.* capability extension.
  • kapable-designer — its 5 SSE AgentEvents are a strict subset (mapping table in SPEC.md §7.2); migration is mechanical when it adopts the shared core crates (H7).
  • @kapable/agent-ui — the ./stream transport codecs (WS/SSE/assist adapters) mirror this vocabulary on the TypeScript side.

Usage

use kv2_agent_protocol::{Outbound, Inbound};

let ev: Outbound = serde_json::from_str(frame)?;   // unknown events decode to Outbound::Unknown — ignore them
if ev.is_terminal() { /* turn over: done | error */ }

Key invariants (see SPEC.md §2/§5):

  • unknown event types decode to Unknown and MUST be ignored, never treated as errors;
  • absent optional fields are omitted on the wire (never null);
  • every turn ends in exactly one terminal event (done | error) — Outbound::is_terminal().

Versioning

Semver tracks the spec: additive events/fields → minor; any wire-breaking change → major. The golden assist fixtures failing = you broke the wire, not the test.

Dev

cargo test          # 8 tests: roundtrips, golden assist fixtures, unknown-tolerance, invariants
cargo clippy --no-deps

Standalone crate (no workspace); edition 2021; deps: serde, serde_json only.

Dependencies

ID Version
serde ^1
serde_json ^1
Details
Cargo
2026-06-12 00:23:21 +00:00
6
11 KiB
Assets (1)
Versions (1) View all
0.1.0 2026-06-12