Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
39fed3e
feat(community): add Swift SDK
paduh Apr 13, 2026
9d4ef59
ci: add Swift SDK unit test workflow
paduh Apr 13, 2026
14e1c8e
Merge branch 'main' into feature/add-swift-community-sdk
paduh May 1, 2026
31635f3
feat(community/swift): sync Swift SDK with upstream ag-ui-swift
paduh May 2, 2026
af503bb
feat(community): add Swift SDK
paduh Apr 13, 2026
f8d856d
ci: add Swift SDK unit test workflow
paduh Apr 13, 2026
e385b8b
feat(community/swift): sync Swift SDK with upstream ag-ui-swift
paduh May 2, 2026
6fbcc80
Merge branch 'main' into feature/add-swift-community-sdk
paduh May 8, 2026
0f58a0f
Merge branch 'main' into feature/add-swift-community-sdk
paduh Jun 20, 2026
d290407
Merge branch 'feature/add-swift-community-sdk' of github.com:paduh/ag…
paduh Jun 20, 2026
53b1b54
fix(swift-sdk): align wire protocol decoding with AG-UI spec
paduh Jun 20, 2026
ab2ddeb
fix(swift-sdk): address PR review issues 4-13
paduh Jun 20, 2026
bef155a
fix(swift-sdk): address PR review issues 14-27
paduh Jun 20, 2026
4347b8c
fix(swift): address PR review comments 36-50
paduh Jun 20, 2026
96e0a10
fix(swift): propagate protocol violations from EventStream
paduh Jun 21, 2026
c1e4bdc
Merge branch 'main' into feature/add-swift-community-sdk
paduh Jun 21, 2026
7bc6241
Merge branch 'main' into feature/add-swift-community-sdk
paduh Jun 24, 2026
35971c2
Merge branch 'main' into feature/add-swift-community-sdk
paduh Jun 30, 2026
11f1768
Merge branch 'main' into feature/add-swift-community-sdk
paduh Jul 16, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
33 changes: 33 additions & 0 deletions .github/workflows/unit-swift-sdk.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: unit-swift-sdk

on:
push:
branches: [main]
paths:
- "sdks/community/swift/**"
- ".github/workflows/unit-swift-sdk.yml"
pull_request:
branches: [main]
paths:
- "sdks/community/swift/**"
- ".github/workflows/unit-swift-sdk.yml"

jobs:
swift:
runs-on: macos-latest

steps:
- name: Checkout code
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2

- name: Resolve dependencies
working-directory: sdks/community/swift
run: swift package resolve

- name: Build
working-directory: sdks/community/swift
run: swift build

- name: Run tests
working-directory: sdks/community/swift
run: swift test
57 changes: 57 additions & 0 deletions sdks/community/swift/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# Xcode

## User settings
xcuserdata/

## Compatibility files no longer needed since Xcode 9
*.xcscmblueprint
*.xccheckout

## Compatibility files no longer needed since Xcode 4
build/
DerivedData/
*.moved-aside
*.pbxuser
!default.pbxuser
*.mode1v3
!default.mode1v3
*.mode2v3
!default.mode2v3
*.perspectivev3
!default.perspectivev3

## Obj-C/Swift specific
*.hmap

## App packaging
*.ipa
*.dSYM.zip
*.dSYM

## Playgrounds
timeline.xctimeline
playground.xcworkspace

# Swift Package Manager
.build/
# Package.resolved is intentionally checked in — this is a library package and
# pinning transitive dependencies makes CI reproducible without a separate lock file.

# macOS
.DS_Store

# Documentation (generated files, keep README.md and .nojekyll)
docs/*
!docs/README.md
!docs/.nojekyll
!docs/WORKFLOW.md

# SwiftLint
.swiftlintcache

# Claude Code worktrees
.claude/worktrees/

# Local documentation (not for public repository)
MEDIUM_ARTICLE.md
docs-test/
26 changes: 26 additions & 0 deletions sdks/community/swift/.swiftlint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
included:
- Sources
- Package.swift

excluded:
- .build
- Tests

only_rules:
- force_cast
- force_try
- force_unwrapping
- custom_rules
- large_tuple

custom_rules:
no_assume_isolated:
name: "No assumeIsolated"
regex: "\\b(?:MainActor|[A-Za-z_][A-Za-z0-9_]*)\\.assumeIsolated\\s*(?:\\(|\\{)"
match_kinds:
- identifier
message: "Do not use assumeIsolated. Use explicit actor isolation or restructure the code to stay within structured concurrency."
severity: error

large_tuple:
warning_length: 3

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

141 changes: 141 additions & 0 deletions sdks/community/swift/ARCHITECTURE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,141 @@
# AGUISwift Architecture

AGUISwift follows a clean, modular architecture with strict Domain-Driven Design (DDD) layering principles:

```
┌─────────────────────────────────────────────────────────────┐
│ Your Application │
│ (iOS, macOS, tvOS, watchOS) │
├─────────────────────────────────────────────────────────────┤
│ AGUIAgentSDK │
│ ┌─────────────┐ ┌───────────────────┐ ┌──────────────┐ │
│ │ AgUiAgent │ │StatefulAgUiAgent │ │ Builders │ │
│ │ │ │ │ │ │ │
│ └─────────────┘ └───────────────────┘ └──────────────┘ │
├─────────────────────────────────────────────────────────────┤
│ AGUIClient │ AGUITools │
│ ┌────────────┐ ┌─────────────┐ │ ┌──────────────────────┐ │
│ │ HttpAgent │ │AbstractAgent│ │ │ ToolRegistry │ │
│ ├────────────┤ ├─────────────┤ │ ├──────────────────────┤ │
│ │EventStream │ │EventDecoder │ │ │ ToolExecutor │ │
│ │ SseParser │ │ Manager │ │ │ToolExecutionManager │ │
│ └────────────┘ └─────────────┘ │ └──────────────────────┘ │
├─────────────────────────────────────────────────────────────┤
│ AGUICore │
│ ┌──────────────────────────────────────────────────────┐ │
│ │ Infrastructure Layer │ │
│ │ ┌──────────────────┐ ┌─────────────────────────┐ │ │
│ │ │ Serialization │ │ Adapters │ │ │
│ │ │ ┌──────────────┐ │ │ ┌─────────────────────┐ │ │ │
│ │ │ │Serializable │ │ │ │ValueObjectAdapter │ │ │ │
│ │ │ │ThreadId │ │ │ │ │ │ │ │
│ │ │ │Serializable │ │ │ │ │ │ │ │
│ │ │ │RunId │ │ │ │ │ │ │ │
│ │ │ │Serializable │ │ │ │ │ │ │ │
│ │ │ │EventTimestamp│ │ │ │ │ │ │ │
│ │ │ └──────────────┘ │ │ └─────────────────────┘ │ │ │
│ │ └──────────────────┘ └─────────────────────────┘ │ │
│ ├──────────────────────────────────────────────────────┤ │
│ │ Protocol Layer │ │
│ │ ┌──────────────┐ ┌──────────────┐ ┌───────────┐ │ │
│ │ │ AGUIEvent │ │ EventType │ │EventDecoder│ │ │
│ │ │ │ │ │ │ │ │ │
│ │ │RunStarted │ │ │ │ │ │ │
│ │ │RunFinished │ │ │ │ │ │ │
│ │ └──────────────┘ └──────────────┘ └───────────┘ │ │
│ ├──────────────────────────────────────────────────────┤ │
│ │ Domain Layer │ │
│ │ ┌──────────────┐ ┌──────────────┐ ┌───────────┐ │ │
│ │ │ ValueObjects │ │ Events │ │ Errors │ │ │
│ │ │ │ │ │ │ │ │ │
│ │ │ ThreadId │ │ RunStarted │ │DomainError │ │ │
│ │ │ RunId │ │ RunFinished │ │ │ │ │
│ │ │EventTimestamp│ │ │ │ │ │ │
│ │ └──────────────┘ └──────────────┘ └───────────┘ │ │
│ └──────────────────────────────────────────────────────┘ │
└─────────────────────────────────────────────────────────────┘
```

## Module Overview

### AGUICore
Protocol types, events, and message definitions with strict DDD layering.

**Domain Layer** (Pure domain logic, no infrastructure dependencies):
- **ValueObjects**: `ThreadId`, `RunId`, `EventTimestamp` - Type-safe domain value objects
- **Events**: Domain event definitions (to be implemented)
- **Errors**: `DomainError` - Domain validation errors

**Protocol Layer** (Protocol-specific types):
- **AGUIEvent**: Base protocol for all AG-UI protocol events
- **EventType**: Enumeration of all AG-UI protocol event types
- **EventDecoder**: Polymorphic event decoder helper
- **Concrete Events**: `RunStartedEvent`, `RunFinishedEvent` (and more to come)

**Infrastructure Layer** (Serialization and adapters):
- **Serialization**: `SerializableThreadId`, `SerializableRunId`, `SerializableEventTimestamp` - Infrastructure wrappers for JSON serialization
- **Adapters**: `ValueObjectAdapter` - Converts between domain and infrastructure layers

### AGUIAgentSDK
High-level APIs for common agent interaction patterns.
- **AgUiAgent**: Stateless client for cases where no ongoing context is needed
- **StatefulAgUiAgent**: Stateful client that maintains conversation history
- **Builders**: Convenient builder patterns for agent configuration

### AGUIClient
Low-level client infrastructure and transport implementations.
- **HttpAgent**: Low-level HTTP transport implementation
- **AbstractAgent**: Base class for custom agent implementations
- **SseParser**: Server-Sent Events parser for streaming responses
- **EventStreamManager**: Event stream management and processing

### AGUITools
Tool execution framework for extending agent capabilities.
- **ToolExecutor**: Protocol for implementing custom tools
- **ToolRegistry**: Tool registration and management
- **ToolExecutionManager**: Tool execution with circuit breaker patterns

## Design Principles

### Domain-Driven Design (DDD)
- **Domain Layer**: Pure business logic with no infrastructure dependencies
- **Infrastructure Layer**: Handles serialization, networking, and external concerns
- **Clear Boundaries**: Strict separation between domain and infrastructure
- **Value Objects**: Type-safe domain concepts (ThreadId, RunId, EventTimestamp)

### Layered Architecture
- **Application Layer**: High-level APIs (AGUIAgentSDK)
- **Client Layer**: Low-level transport and infrastructure (AGUIClient)
- **Domain Layer**: Core business logic and domain models (AGUICore)
- **Infrastructure Layer**: Technical implementation details (AGUICore)

### Modularity
- **AGUICore**: Foundation layer with protocol definitions
- **AGUIClient**: Low-level client infrastructure and transport
- **AGUIAgentSDK**: High-level agent APIs and builders
- **AGUITools**: Tool execution framework
- Each module can be used independently or together

## Current Implementation Status

### ✅ Completed
- Domain value objects (ThreadId, RunId, EventTimestamp)
- Infrastructure serialization wrappers
- Domain/Infrastructure adapters
- AGUIEvent protocol and EventType enum
- RunStartedEvent and RunFinishedEvent implementations
- Comprehensive unit tests for events
- DDD layering structure

### 🚧 In Progress
- Additional event types (TextMessage, ToolCall, StateManagement events)
- Client agent implementations
- Tool execution framework

### 📋 Planned
- HTTP transport layer
- SSE (Server-Sent Events) parser
- State management
- Authentication support
- Error handling and recovery

Loading