ArtAdk

1.0.1

aiotrixdev/art-swift-adk

What's New

Swift ADK 1.0.1

2026-07-16T05:20:59Z

🚀 What's New

Added

  • Added Agent Builder support
  • Added Orchestrator support
  • Added Thread ID support
  • Improved example documentation

Improved

  • Updated README
  • Updated CHANGELOG
  • Enhanced API documentation

Fixed

  • Improved stability
  • Various bug fixes

Documentation

  • Updated installation guide
  • Improved usage examples
  • Added migration notes

ART Swift ADK

Swift Platform License

Swift SDK for ART – A Realtime Tech Communication, a realtime communication platform for building intelligent applications with WebSocket-based messaging, AI Agents, AI Orchestrators, presence tracking, end-to-end encrypted channels, and CRDT-backed shared objects.


Features

  • WebSocket connection management (connect, pause, resume, auto-reconnect)
  • Channel subscriptions (default, targeted, group, encrypted, CRDT)
  • Push messages with structured payloads
  • Event-based message listening (emitter.on)
  • Real-time presence tracking
  • End-to-end encryption support
  • Interceptors for message processing
  • Shared objects using CRDT
  • AI Agent integration
  • AI Orchestrator workflows

Installation

Swift Package Manager

dependencies: [
    .package(url: "https://github.com/aiotrixdev/art-swift-adk.git", from: "1.0.1")
]

Or in Xcode:

File → Add Packages → Paste repository URL

Configuration

1. Create credentials

Store your ART credentials securely:

let creds = CredentialStore(
    environment:  "YOUR_ENV",
    projectKey:   "YOUR_PROJECT_KEY",
    orgTitle:     "YOUR_ORG",
    clientID:     "CLIENT_ID",
    clientSecret: "CLIENT_SECRET"
)

2. Get a user passcode

ART uses a short-lived passcode for authentication:

func fetchPasscode(creds: CredentialStore) async throws -> String {
    let url = URL(string: "YOUR_ORCHESTRATOR_ID")!
    
    var request = URLRequest(url: url)
    request.httpMethod = "POST"
    
    request.addValue(creds.clientID, forHTTPHeaderField: "Client-Id")
    request.addValue(creds.clientSecret, forHTTPHeaderField: "Client-Secret")
    request.addValue(creds.orgTitle, forHTTPHeaderField: "X-Org")
    request.addValue(creds.environment, forHTTPHeaderField: "Environment")
    request.addValue(creds.projectKey, forHTTPHeaderField: "ProjectKey")
    request.addValue("application/json", forHTTPHeaderField: "Content-Type")
    
    let body: [String: Any] = [
        "username": "john_doe",
        "first_name": "John",
        "last_name": "Doe"
    ]
    
    request.httpBody = try JSONSerialization.data(withJSONObject: body)
    
    let (data, _) = try await URLSession.shared.data(for: request)
    let json = try JSONSerialization.jsonObject(with: data) as? [String: Any]
    let dataObj = json?["data"] as? [String: Any]
    
    return dataObj?["passcode"] as? String ?? ""
}

Quick Start

import ArtAdk

let passcode = try await fetchPasscode(creds: creds)

let adk = Adk(config: AdkConfig(
    uri: "YOUR_WEBSOCKET_URI",
    authToken: passcode,
    getCredentials: { creds }
))

adk.on("connection") { data in
    if let conn = data as? ConnectionDetail {
        print("Connected → \(conn.connectionId)")
    }
}

adk.on("close") { reason in
    print("Closed:", reason)
}

try await adk.connect()

let sub = try await adk.subscribe(channel: "room-42")

sub.emitter.on("message") { data in
    print("Received:", data)
}

try await sub.push(
    event: "message",
    data: ["text": "Hello ART!"]
)

Connecting

try await adk.connect()

Safe usage:

do {
    try await adk.connect()
} finally {
    await adk.disconnect()
}

Check state:

adk.getState() // connected | retrying | paused | stopped

Subscribing to a Channel

let sub = try await adk.subscribe(channel: "room-42")

if let live = sub as? LiveObjSubscription {
    // CRDT channel
}

Unsubscribe:

await sub.unsubscribe()

Pushing Messages

try await sub.push(
    event: "message",
    data: ["text": "Hello"]
)

Targeted messaging:

try await sub.push(
    event: "message",
    data: ["text": "Hi Bob"],
    options: PushConfig(to: ["bob"])
)

Receiving Messages

sub.emitter.on("message") { data in
    print("Got:", data)
}

Presence

let cancel = try await sub.fetchPresence { users in
    print("Online:", users)
}

// later
await cancel()

Encrypted Channels

try await adk.generateKeyPair()

let secure = try await adk.subscribe(channel: "SECURE_CHANNEL")

try await secure.push(
    event: "message",
    data: ["text": "Private"],
    options: PushConfig(to: ["bob"])
)

secure.emitter.on("message") { data in
    print("Decrypted:", data)
}

Shared Object Channels (CRDT)

let sub = try await adk.subscribe(channel: "CRDT_CHANNEL")

if let live = sub as? LiveObjSubscription {
    
    // Write
    live.state()["document"]["title"].set("My Doc")
    await live.flush()
    
    // Read
    let snapshot = await live.query(path: "document").execute()
    print(snapshot)
    
    // Listen
    let dispose = await live.query(path: "document").listen { data in
        print("Updated:", data)
    }
    
    dispose()
}

Array Operations

let items = live.state()["items"]

items.push("alpha")
items.unshift("zero")
items.pop()
items.removeAt(2)
items.splice(start: 1, deleteCount: 1, insert: ["x"])

await live.flush()

Interceptors

try await adk.intercept(interceptor: "filter") { payload, resolve, reject in
    
    if let text = payload["text"] as? String,
       text.contains("anyword") {
        reject("Blocked")
        return
    }
    
    resolve(payload)
}

Connection Lifecycle

adk.on("connection") { data in
    print("Connected")
}

adk.on("close") { _ in
    print("Closed")
}

adk.pause()
await adk.resume()
await adk.disconnect()

AI Workflows

The Swift ADK provides first-class support for both AI Agents and Multi-Agent Orchestrators.

Agent

Connect to an Agent Builder agent and start a conversation.

let agent = adk.agent("YOUR_AGENT_ID")

let thread = agent.thread()

await thread.listen { envelope in
    print(envelope.event)
}

let run = await thread.run(
    "Plan a 3-day trip to Dubai"
)

do {
    let output = try await run.done()
    print(output.message)
} catch let error as AgentError {
    print(error.message)
}

Human-in-the-Loop (HITL)

When an agent requires additional information, register a feedback handler before starting the run.

thread.feedbackRequest { request, run in
    Task {
        try await run.sendFeedback(
            "Budget 50,000 travelling in December"
        )
    }
}

Workflow Trace

await thread.listenTrace { frame in
    print(frame)
}

Orchestrator

Connect to an Orchestrator Builder workflow.

let orchestrator = adk.orchestrator(
    "YOUR_ORCHESTRATOR_ID"
)

let thread = try await orchestrator.thread()

thread.listen { event in
    print(event)
}

try await thread.push(
    event: "user_input",
    data: [
        "message": "Plan a 3-day trip to Goa"
    ]
)

Human-in-the-Loop

thread.listen { event in

    guard
        let content = event["content"] as? [String: Any],
        let reply = content["reply"] as? ([String: Any]) -> Void
    else { return }

    reply([
        "user_input":
            "Budget 50,000 travelling in December"
    ])
}

Workflow Trace

thread.listenTrace { frame in
    print(frame)
}

Documentation

Full documentation is available at: https://docs.arealtimetech.com/docs/adk/

Topic Link
Overview ADK Overview
Installation Swift Installation
Publish & Subscribe Pub/Sub Docs
Connection Management Connection Docs
User Presence Presence Docs
Encrypted Channels Encryption Docs
Shared Object Channels Shared Object Docs
Interceptors Interceptor Docs
Agents Agent Docs
Orchestrator Orchestrator Docs

License

Released under the MIT License.

Description

  • Swift Tools 5.9.0
View More Packages from this Author

Dependencies

Last updated: Sun Jul 26 2026 13:01:21 GMT-0900 (Hawaii-Aleutian Daylight Time)