swift-acp
Agent Client Protocol(ACP)の Swift 実装。ホスト↔エージェント間の JSON-RPC 契約を 135 の $defs として厳密に型付け
English | 日本語
swift-acp
A test-driven, fully-conformant Swift implementation of the Agent Client Protocol (ACP) — the JSON-RPC standard that connects any editor/host to any agent.
Conformance target: schema crate 0.13.6 / protocol v1 (the latest stable). Every type is proven against the authoritative wire schema, the reference crate's serialization vectors, and the method registry — not assumed.
Why
ACP's core (session/prompt → streamed session/update of plans, thoughts,
tool calls, and permission requests → session/cancel) is a domain-agnostic
contract for a host observing and steering a single agent's working session.
The file-system and terminal capabilities are optional client-side bolt-ons, so
this is just as usable as the progress/control plane for a non-coding agent as
for a coding one. The transport is a swappable boundary: in-process the messages
cross as Swift values with no serialization; over stdio they are JSON-RPC.
Targets
| Target | Role |
|---|---|
ACPJSONRPC |
JSON-RPC 2.0 envelope (RequestId, RPCError, ErrorCode, JSONValue), decoupled from ACP |
ACPCore |
The 135 ACP v1 $defs as Codable value types — sum-typed unions, open string enums, unknown cases for forward-compat |
ACPAgent |
The agent-role contract (protocol ACPAgent) |
ACPClient |
The client/host-role contract (protocol ACPClient) |
ACPTransport |
InProcessConnection (typed, no serialization) + StdioTransport/AgentConnection (JSON-RPC) + StreamingSessionClient |
In-process (no serialization)
import ACPTransport
let connection = InProcessConnection { client in
MyResearchAgent(client: client) // the agent reports progress via `client`
}
Task {
for await update in connection.updates { // the progress channel a UI renders
render(update)
}
}
let response = try await connection.agent.prompt(promptRequest)
connection.finish()
Over stdio (interop)
let connection = AgentConnection(transport: StdioTransport())
await connection.start { client in MyAgent(client: client) }
try await connection.run() // serves the agent to any ACP client over stdin/stdout
Conformance
The ACPConformanceTests suite enforces three independent guarantees against the
version-pinned spec vendored under Tests/ACPConformanceTests/Spec/v1:
- Schema coverage — every one of the 135
$defsmaps to exactly one modelled type. - Golden round-trip — 30 wire samples harvested verbatim from the reference
crate's
#[test]assertions decode and re-encode losslessly (field-level conformance). - Method parity — the Swift method-name tables equal
meta.jsonexactly.
swift test
Apache-2.0, matching the reference protocol.
同じカテゴリの OSS — エージェント / プロトコル
swift-a2a
Swift PackageGoogle A2A(Agent-to-Agent)プロトコルの Swift クライアント実装。エージェント同士を相互運用させる
swift-a2ui
Swift PackageGoogle A2UI プロトコルの Swift 実装。LLM エージェントがクライアントに型安全なリッチ UI を描画する
swift-acp-a2a-bridge
Swift Packageswift-a2a エージェントを ACP エージェントとして公開するブリッジ。ACP 契約と A2A メッセージ交換を相互変換する
swift-acp-presentation
Swift PackageACP のホスト側プレゼンテーション層。session/update を UI 非依存の状態に畳み込み、文言を String Catalog に集約する
swift-agent-skills
Swift PackageSKILL.md オープン標準(Apache-2.0)の Swift 実装。スキルの読み込み・探索・実行・ツール統合を担う
swift-agent-runtime
Swift PackageA2A 前提のオーケストレータ+ワーカー実行環境。専門ワーカーへの委譲・並列実行・ACP ゲートウェイをパッケージルートとして提供する Swift ランタイム