refactor(sdk-swift): wrap relaycast engine SDK in hosted transport
Summary
Refactors the hosted-participant path of the Swift SDK (AgentRelaySDK) to wrap relaycast's Swift engine SDK (Relaycast, package relaycast-swift) instead of hand-rolling URLSession/WebSocket. The local broker product AgentRelayBrokerSDK is untouched.
The bespoke HostedHTTP (RelayHTTP.swift) and RelayEventTransport (RelayTransport.swift) are deleted; all HTTP + realtime work is now delegated to Relaycast.RelayCast / Relaycast.AgentClient / Relaycast.WsClient. The relay-specific glue is kept on top.
Mapping (relay hosted -> relaycast)
| relay hosted call | relaycast |
|---|---|
| register / registerOrRotate (409 -> get + rotate-token) | RelayCast.agents.register / RelayCast.registerOrRotate |
reconnect by token (GET /v1/agent) | RelayCast.reconnect + AgentClient.me |
| workspace info | RelayCast.workspace.info |
| post channel / dm | AgentClient.send / AgentClient.dm (mode .wait) |
| action register / delete | RelayCast.actions.register / .delete |
| invocation get / complete | AgentClient.actions.getInvocation / .completeInvocation |
| WS subscribe + typed events | AgentClient.subscribe + AgentClient.on (message.created, thread.reply, dm.received, group_dm.received, action.invoked) |
Kept on top (unchanged behavior / signatures)
- The action-dispatch loop:
action.invoked->loadInvocation-> handler ->completeInvocation. - The
RelayChannelEventshape and theAsyncStream-based public API. - All public type signatures of
AgentRelayClientso callers don't break.
Hard constraints honored
- Default base URL
https://gateway.relaycast.devis preserved and passed explicitly intoRelayCastOptions.baseURL. - SwiftPM dependency added.
RegisterActionRequest upstream check
Relaycast.RegisterActionRequest (relaycast Models.swift) already carries handlerAgent (handler_agent) and inputSchema (input_schema). No upstream relaycast change was required.
SwiftPM dependency wiring (note for reviewers)
relaycast-swift lives in the relaycast monorepo under packages/sdk-swift โ not at the repo root โ so SwiftPM can't consume it by git URL directly, and its directory basename (sdk-swift) collides with this package's own SwiftPM identity. The dependency is therefore referenced through a committed relative symlink packages/sdk-swift/.relaycast-swift -> ../../../relaycast/packages/sdk-swift (a sibling clone of relaycast). Repoint the symlink for other checkout locations, or swap in a git/tag reference (e.g. from: "4.1.6") once a root-level relaycast-swift mirror is published. Documented in Package.swift and the README.
Verification
swift build and swift test both pass โ 69 tests, 0 failures (Swift 6.2.4 toolchain). Hosted tests were rewritten to cover facade config + bridging glue (the old tests mocked now-deleted internal transport types); broker and RelayObserver tests are unchanged.
๐ค Generated with Claude Code