kiliczsh/genui-bridge-swift
Validates agent tool calls into A2UI protocol messages.
Usage
import GenUIBridge
// 1. Build tool definitions from your A2UI catalog schema.
let toolset = A2UIToolset(catalogId: catalogID, catalogSchema: schema)
let tools = toolset.toolDefinitions() // hand these to your agent SDK
// 2. Route every incoming tool call through the interceptor.
let interceptor = A2UIToolCallInterceptor()
let verdict = await interceptor.handle(toolName: name, input: input)
// verdict tells the agent "rendered" or a correctable error
// 3. Consume the ordered, validated envelope stream.
for await envelope in interceptor.envelopes {
let data = try envelope.serializedMessage() // hand off to your renderer
}Requirements
- macOS 14+, Swift 5.9+
- No dependencies — Foundation only. One library product:
GenUIBridge.
Installation
.package(url: "https://github.com/kiliczsh/genui-bridge-swift.git", from: "0.1.0")Note: This package is a transitional layer in the GenUI architecture. Its validation and A2UI tooling responsibilities are moving to the cloud agent runtime; expect it to be deprecated once that migration completes.
Status
The agent → A2UI direction is implemented and covered by 16 tests (inputs constructed inline as typed JSONValue literals — no live agent or network anywhere in the suite): A2UIToolset (catalog → per-message-kind tool definitions, including the a2ui_action_response tool), A2UIEnvelope (fail-closed tool-call validation into versioned v1.0 envelopes), and A2UIToolCallInterceptor (an actor — verdict per call, spec surface-lifecycle enforcement, ordered envelope stream via AsyncStream). JSONValue uses Decimal for lossless numbers.
The reverse direction — turning a user's A2UI action (a button tap, a form submit) into the next agent turn — is by design left to the host app: this package supplies the validated a2ui_action_response tool and surface-lifecycle retract, but never talks to an agent SDK itself.
Package Metadata
Repository: kiliczsh/genui-bridge-swift
Default branch: main
README: README.md