Skip to content

Align Swift SDK broker API parity#1103

Open
willwashburn wants to merge 1 commit into
mainfrom
codex/review-sdks-for-parity
Open

Align Swift SDK broker API parity#1103
willwashburn wants to merge 1 commit into
mainfrom
codex/review-sdks-for-parity

Conversation

@willwashburn

Copy link
Copy Markdown
Member

Motivation

  • Ensure the Swift SDK exposes the same broker control, observability, and REST surfaces available in the TypeScript and Python SDKs so consumers have consistent cross-language capabilities.
  • Add missing types and payload fields needed to represent broker responses and request bodies used by tooling and the harness driver.
  • Document the new Swift API surface and add parity tests so the SDK behavior remains verifiable.

Description

  • Added broker control and observability helpers to the Swift SDK including listAgents, sendInput, resizePty, flush, snapshot, sendMessage (full payload), setModel, subscribeChannels, unsubscribeChannels, getStatus, getMetrics, getCrashInsights, preflight, and renewLease in AgentRelayClient/RelayCore.
  • Introduced Swift Codable parity types and fields in RelayTypes.swift (message mode, SnapshotFormat, ListAgent, BrokerStatus, PendingDeliveryInfo, SendMessageResult, ModelUpdateResult, FlushResult, PreflightResult, RenewLeaseResult, metrics/crash types, and related keys) and added JSON key mappings to preserve wire compatibility.
  • Updated the Swift transport/observer to import FoundationNetworking when available so URLSession/WebSocket APIs compile on Linux, and added small helper utilities for URL/query/path escaping and JSON encode/decode helpers used by the new REST helpers.
  • Expanded packages/sdk-swift/README.md and CHANGELOG.md to document the new public API surface and the user-visible parity change, and added unit tests validating send-message payload encoding and broker-status decoding.

Testing

  • Ran swift test --package-path packages/sdk-swift and the Swift unit test suite passed (56 tests, 0 failures).
  • Ran npm --prefix packages/sdk test and the TypeScript SDK tests passed (107 tests, 0 failures).
  • Verified git diff --check (style/sanity) had no errors.
  • Attempted Python SDK smoke tests with python -m pytest packages/sdk-py/tests/test_send_message_mode.py packages/sdk-py/tests/test_builder.py, but test collection failed due to missing Python dependencies (aiohttp, pyyaml) and inability to fetch optional deps from PyPI in the current environment, so Python tests were not executed successfully in this run.

Codex Task

@gemini-code-assist

Copy link
Copy Markdown

Warning

You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again!

@coderabbitai

coderabbitai Bot commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

@willwashburn, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 14 minutes and 30 seconds. Learn how PR review limits work.

Your organization has run out of usage credits. Purchase more credits in the billing tab to continue.

⌛ How to resolve this issue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 2a07e2a8-930c-459a-aed5-23b7c3f115d8

📥 Commits

Reviewing files that changed from the base of the PR and between 50c8cc5 and f71c875.

📒 Files selected for processing (7)
  • CHANGELOG.md
  • packages/sdk-swift/README.md
  • packages/sdk-swift/Sources/AgentRelaySDK/AgentRelayClient.swift
  • packages/sdk-swift/Sources/AgentRelaySDK/RelayObserver.swift
  • packages/sdk-swift/Sources/AgentRelaySDK/RelayTransport.swift
  • packages/sdk-swift/Sources/AgentRelaySDK/RelayTypes.swift
  • packages/sdk-swift/Tests/AgentRelaySDKTests/AgentRelaySDKTests.swift
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/review-sdks-for-parity

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: f71c875ad1

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".



func listAgents() async throws -> [ListAgent] {
try decodeJSON(try await http.get(path: "/api/spawned"), as: [ListAgent].self)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Decode the /api/spawned response envelope

In the broker, GET /api/spawned returns an object envelope like { "agents": workers.list() } (also what the TS/Python clients unwrap), not a top-level array. As written, every successful listAgents() call attempts to decode that object as [ListAgent] and throws decodingFailed, so the new API is unusable against the real broker.

Useful? React with 👍 / 👎.


func sendInput(name: String, data: String) async throws {
let body = try encodeJSON(InputRequestBody(data: data))
_ = try await http.post(path: "/api/spawned/\(escapePathSegment(name))/input", body: body)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Use the broker PTY input route

The broker registers PTY input at POST /api/input/{name} and the existing TS/Python clients use that route; there is no /api/spawned/{name}/input route in crates/broker/src/listen_api.rs. Any caller of this new sendInput helper will get a 404/protocol error instead of writing to the agent PTY.

Useful? React with 👍 / 👎.


func resizePty(name: String, rows: Int, cols: Int) async throws {
let body = try encodeJSON(ResizeRequestBody(rows: rows, cols: cols))
_ = try await http.post(path: "/api/spawned/\(escapePathSegment(name))/resize", body: body)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Use the broker PTY resize route

The broker exposes resize as POST /api/resize/{name} and the other SDKs call that endpoint; /api/spawned/{name}/resize is not registered. In contexts like attach/terminal resizing, this new Swift method will consistently fail with a 404 instead of resizing the PTY.

Useful? React with 👍 / 👎.

}

public struct CrashRecord: Codable, Sendable {
public var name: String

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Match crash insight response fields

When /api/crash-insights has any recorded crashes, the broker returns recent entries with fields like agent_name, exit_code, timestamp, uptime_secs, category, and description, while patterns use category, count, and agents. This model requires absent fields such as name (and the pattern model below requires name/crashes/restarts), so getCrashInsights() starts throwing a decoding error precisely when diagnostics are present.

Useful? React with 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant