ForgeCollab
Swift ForgeCollab library product.
Swift ForgeCollab library product.
Package contract
| Field | Value |
|---|---|
| Language | swift |
| Source version | Swift package source snapshot |
| Manifest | forge-swift/Package.swift |
| Source files | 8 |
| Evidence | Source reference; registry publication and runtime conformance are separate checks |
Import boundary
import ForgeCollabUse a source checkout or your verified private registry. Manifest coordinates identify the package; they do not establish that a public registry release exists.
Source reference
Download package reference JSON. Each original source file and generated declaration artifact has its own SHA-256 digest. Function bodies and constant values are omitted from downloads. These are source declaration inventories, not compiler-resolved rustdoc, TypeDoc, DocC, or Dokka output. Private modules can contain public declarations that are not reachable through the package boundary; consult the entry point before importing.
CapabilityAdvertiser.swift
Read declaration text · 7 declaration entries
public protocol CapabilityAdvertiser: Sendable
public struct CapabilityAdvertisement: Codable, Sendable, Equatable
public let agentDid: String
/// The agent's advertised capabilities.
public let capabilities: [String]
/// When the advertisement was created.
public let timestamp: Timestamp
/// Creates a new capability advertisement.
///
/// - Parameters:
/// - agentDid: The agent's DID.
/// - capabilities: The agent's capabilities.
public init(agentDid: String, capabilities: [String])
public let capabilities: [String]
/// When the advertisement was created.
public let timestamp: Timestamp
/// Creates a new capability advertisement.
///
/// - Parameters:
/// - agentDid: The agent's DID.
/// - capabilities: The agent's capabilities.
public init(agentDid: String, capabilities: [String])
public let timestamp: Timestamp
/// Creates a new capability advertisement.
///
/// - Parameters:
/// - agentDid: The agent's DID.
/// - capabilities: The agent's capabilities.
public init(agentDid: String, capabilities: [String])
public init(agentDid: String, capabilities: [String])
public func matchTaskToAgents(
task: DelegatedTask,
advertisements: [CapabilityAdvertisement]
) -> [String]CollabError.swift
Read declaration text · 2 declaration entries
public enum CollabError: Error, Sendable, Equatable
public var errorDescription: String?CollaborationTypes.swift
Read declaration text · 50 declaration entries
public enum CollaborationRole: String, Codable, Sendable, Hashable, CaseIterable
public enum SessionState: String, Codable, Sendable, Hashable, CaseIterable
public var validTransitions: [SessionState]
public var isTerminal: Bool
public struct CollaborationSession: Codable, Sendable, Equatable
public let id: String
/// Human-readable session name.
public let name: String
/// The current session state.
public var state: SessionState
/// Map of agent DIDs to their roles in this session.
public var participants: [String: CollaborationRole]
/// When the session was created.
public let createdAt: Timestamp
/// When the session was last updated.
public var updatedAt: Timestamp
/// Creates a new collaboration session.
///
/// - Parameters:
/// - id: Unique session identifier. Defaults to a new UUID.
/// - name: Human-readable session name.
/// - participants: Initial participants and their roles.
public init(
id: String;
public let name: String
/// The current session state.
public var state: SessionState
/// Map of agent DIDs to their roles in this session.
public var participants: [String: CollaborationRole]
/// When the session was created.
public let createdAt: Timestamp
/// When the session was last updated.
public var updatedAt: Timestamp
/// Creates a new collaboration session.
///
/// - Parameters:
/// - id: Unique session identifier. Defaults to a new UUID.
/// - name: Human-readable session name.
/// - participants: Initial participants and their roles.
public init(
id: String;
public var state: SessionState
/// Map of agent DIDs to their roles in this session.
public var participants: [String: CollaborationRole]
/// When the session was created.
public let createdAt: Timestamp
/// When the session was last updated.
public var updatedAt: Timestamp
/// Creates a new collaboration session.
///
/// - Parameters:
/// - id: Unique session identifier. Defaults to a new UUID.
/// - name: Human-readable session name.
/// - participants: Initial participants and their roles.
public init(
id: String;
public var participants: [String: CollaborationRole]
/// When the session was created.
public let createdAt: Timestamp
/// When the session was last updated.
public var updatedAt: Timestamp
/// Creates a new collaboration session.
///
/// - Parameters:
/// - id: Unique session identifier. Defaults to a new UUID.
/// - name: Human-readable session name.
/// - participants: Initial participants and their roles.
public init(
id: String;
public let createdAt: Timestamp
/// When the session was last updated.
public var updatedAt: Timestamp
/// Creates a new collaboration session.
///
/// - Parameters:
/// - id: Unique session identifier. Defaults to a new UUID.
/// - name: Human-readable session name.
/// - participants: Initial participants and their roles.
public init(
id: String;
public var updatedAt: Timestamp
/// Creates a new collaboration session.
///
/// - Parameters:
/// - id: Unique session identifier. Defaults to a new UUID.
/// - name: Human-readable session name.
/// - participants: Initial participants and their roles.
public init(
id: String;
public init(
id: String;
public enum TaskPriority: String, Codable, Sendable, Hashable, CaseIterable
public struct TaskConstraints: Codable, Sendable, Equatable
public var timeoutMs: UInt64?
/// Maximum number of tool invocations allowed.
public var maxToolInvocations: UInt32?
/// Maximum tokens the task may consume.
public var maxTokens: UInt64?
/// Required capabilities the executing agent must have.
public var requiredCapabilities: [String]
/// Whether the task may be further delegated to sub-agents.
public var allowSubDelegation: Bool
/// Creates task constraints with defaults.
///
/// - Parameters:
/// - timeoutMs: Maximum time in milliseconds. `nil` means no timeout.
/// - maxToolInvocations: Maximum tool invocations. `nil` means no limit.
/// - maxTokens: Maximum tokens. `nil` means no limit.
/// - requiredCapabilities: Required capabilities. Defaults to empty.
/// - allowSubDelegation: Whether sub-delegation is allowed. Defaults to `false`.
public init(
timeoutMs: UInt64?;
public var maxToolInvocations: UInt32?
/// Maximum tokens the task may consume.
public var maxTokens: UInt64?
/// Required capabilities the executing agent must have.
public var requiredCapabilities: [String]
/// Whether the task may be further delegated to sub-agents.
public var allowSubDelegation: Bool
/// Creates task constraints with defaults.
///
/// - Parameters:
/// - timeoutMs: Maximum time in milliseconds. `nil` means no timeout.
/// - maxToolInvocations: Maximum tool invocations. `nil` means no limit.
/// - maxTokens: Maximum tokens. `nil` means no limit.
/// - requiredCapabilities: Required capabilities. Defaults to empty.
/// - allowSubDelegation: Whether sub-delegation is allowed. Defaults to `false`.
public init(
timeoutMs: UInt64?;
public var maxTokens: UInt64?
/// Required capabilities the executing agent must have.
public var requiredCapabilities: [String]
/// Whether the task may be further delegated to sub-agents.
public var allowSubDelegation: Bool
/// Creates task constraints with defaults.
///
/// - Parameters:
/// - timeoutMs: Maximum time in milliseconds. `nil` means no timeout.
/// - maxToolInvocations: Maximum tool invocations. `nil` means no limit.
/// - maxTokens: Maximum tokens. `nil` means no limit.
/// - requiredCapabilities: Required capabilities. Defaults to empty.
/// - allowSubDelegation: Whether sub-delegation is allowed. Defaults to `false`.
public init(
timeoutMs: UInt64?;
public var requiredCapabilities: [String]
/// Whether the task may be further delegated to sub-agents.
public var allowSubDelegation: Bool
/// Creates task constraints with defaults.
///
/// - Parameters:
/// - timeoutMs: Maximum time in milliseconds. `nil` means no timeout.
/// - maxToolInvocations: Maximum tool invocations. `nil` means no limit.
/// - maxTokens: Maximum tokens. `nil` means no limit.
/// - requiredCapabilities: Required capabilities. Defaults to empty.
/// - allowSubDelegation: Whether sub-delegation is allowed. Defaults to `false`.
public init(
timeoutMs: UInt64?;
public var allowSubDelegation: Bool
/// Creates task constraints with defaults.
///
/// - Parameters:
/// - timeoutMs: Maximum time in milliseconds. `nil` means no timeout.
/// - maxToolInvocations: Maximum tool invocations. `nil` means no limit.
/// - maxTokens: Maximum tokens. `nil` means no limit.
/// - requiredCapabilities: Required capabilities. Defaults to empty.
/// - allowSubDelegation: Whether sub-delegation is allowed. Defaults to `false`.
public init(
timeoutMs: UInt64?;
public init(
timeoutMs: UInt64?;
public struct DelegatedTask: Codable, Sendable, Equatable
public let id: String
/// The session this task belongs to.
public let sessionId: String
/// The delegating agent's DID.
public let delegatorDid: String
/// The assigned agent's DID. `nil` if unassigned.
public var assigneeDid: String?
/// Human-readable task description.
public let description: String
/// The task input/instructions.
public let input: JSONValue
/// Task priority.
public let priority: TaskPriority
/// Execution constraints.
public let constraints: TaskConstraints
/// When the task was created.
public let createdAt: Timestamp
/// Creates a new delegated task.
///
/// - Parameters:
/// - id: Unique task identifier. Defaults to a new UUID.
/// - sessionId: The collaboration session ID.
/// - delegatorDid: The delegating agent's DID.
/// - assigneeDid: The assigned agent's DID.
/// - description: Human-readable task description.
public let sessionId: String
/// The delegating agent's DID.
public let delegatorDid: String
/// The assigned agent's DID. `nil` if unassigned.
public var assigneeDid: String?
/// Human-readable task description.
public let description: String
/// The task input/instructions.
public let input: JSONValue
/// Task priority.
public let priority: TaskPriority
/// Execution constraints.
public let constraints: TaskConstraints
/// When the task was created.
public let createdAt: Timestamp
/// Creates a new delegated task.
///
/// - Parameters:
/// - id: Unique task identifier. Defaults to a new UUID.
/// - sessionId: The collaboration session ID.
/// - delegatorDid: The delegating agent's DID.
/// - assigneeDid: The assigned agent's DID.
/// - description: Human-readable task description.
/// - input: The task input/instructions.
/// - priority: Task priority. Defaults to `.normal`.
public let delegatorDid: String
/// The assigned agent's DID. `nil` if unassigned.
public var assigneeDid: String?
/// Human-readable task description.
public let description: String
/// The task input/instructions.
public let input: JSONValue
/// Task priority.
public let priority: TaskPriority
/// Execution constraints.
public let constraints: TaskConstraints
/// When the task was created.
public let createdAt: Timestamp
/// Creates a new delegated task.
///
/// - Parameters:
/// - id: Unique task identifier. Defaults to a new UUID.
/// - sessionId: The collaboration session ID.
/// - delegatorDid: The delegating agent's DID.
/// - assigneeDid: The assigned agent's DID.
/// - description: Human-readable task description.
/// - input: The task input/instructions.
/// - priority: Task priority. Defaults to `.normal`.
/// - constraints: Execution constraints.
public init(
public var assigneeDid: String?
/// Human-readable task description.
public let description: String
/// The task input/instructions.
public let input: JSONValue
/// Task priority.
public let priority: TaskPriority
/// Execution constraints.
public let constraints: TaskConstraints
/// When the task was created.
public let createdAt: Timestamp
/// Creates a new delegated task.
///
/// - Parameters:
/// - id: Unique task identifier. Defaults to a new UUID.
/// - sessionId: The collaboration session ID.
/// - delegatorDid: The delegating agent's DID.
/// - assigneeDid: The assigned agent's DID.
/// - description: Human-readable task description.
/// - input: The task input/instructions.
/// - priority: Task priority. Defaults to `.normal`.
/// - constraints: Execution constraints.
public init(
id: String;
public let description: String
/// The task input/instructions.
public let input: JSONValue
/// Task priority.
public let priority: TaskPriority
/// Execution constraints.
public let constraints: TaskConstraints
/// When the task was created.
public let createdAt: Timestamp
/// Creates a new delegated task.
///
/// - Parameters:
/// - id: Unique task identifier. Defaults to a new UUID.
/// - sessionId: The collaboration session ID.
/// - delegatorDid: The delegating agent's DID.
/// - assigneeDid: The assigned agent's DID.
/// - description: Human-readable task description.
/// - input: The task input/instructions.
/// - priority: Task priority. Defaults to `.normal`.
/// - constraints: Execution constraints.
public init(
id: String;
public let input: JSONValue
/// Task priority.
public let priority: TaskPriority
/// Execution constraints.
public let constraints: TaskConstraints
/// When the task was created.
public let createdAt: Timestamp
/// Creates a new delegated task.
///
/// - Parameters:
/// - id: Unique task identifier. Defaults to a new UUID.
/// - sessionId: The collaboration session ID.
/// - delegatorDid: The delegating agent's DID.
/// - assigneeDid: The assigned agent's DID.
/// - description: Human-readable task description.
/// - input: The task input/instructions.
/// - priority: Task priority. Defaults to `.normal`.
/// - constraints: Execution constraints.
public init(
id: String;
public let priority: TaskPriority
/// Execution constraints.
public let constraints: TaskConstraints
/// When the task was created.
public let createdAt: Timestamp
/// Creates a new delegated task.
///
/// - Parameters:
/// - id: Unique task identifier. Defaults to a new UUID.
/// - sessionId: The collaboration session ID.
/// - delegatorDid: The delegating agent's DID.
/// - assigneeDid: The assigned agent's DID.
/// - description: Human-readable task description.
/// - input: The task input/instructions.
/// - priority: Task priority. Defaults to `.normal`.
/// - constraints: Execution constraints.
public init(
id: String;
public let constraints: TaskConstraints
/// When the task was created.
public let createdAt: Timestamp
/// Creates a new delegated task.
///
/// - Parameters:
/// - id: Unique task identifier. Defaults to a new UUID.
/// - sessionId: The collaboration session ID.
/// - delegatorDid: The delegating agent's DID.
/// - assigneeDid: The assigned agent's DID.
/// - description: Human-readable task description.
/// - input: The task input/instructions.
/// - priority: Task priority. Defaults to `.normal`.
/// - constraints: Execution constraints.
public init(
id: String;
public let createdAt: Timestamp
/// Creates a new delegated task.
///
/// - Parameters:
/// - id: Unique task identifier. Defaults to a new UUID.
/// - sessionId: The collaboration session ID.
/// - delegatorDid: The delegating agent's DID.
/// - assigneeDid: The assigned agent's DID.
/// - description: Human-readable task description.
/// - input: The task input/instructions.
/// - priority: Task priority. Defaults to `.normal`.
/// - constraints: Execution constraints.
public init(
id: String;
public init(
id: String;
public struct TaskResult: Codable, Sendable, Equatable
public let taskId: String
/// The executing agent's DID.
public let executorDid: String
/// Whether the task completed successfully.
public let success: Bool
/// The task output.
public let output: JSONValue
/// Error message if the task failed.
public let errorMessage: String?
/// When the result was produced.
public let completedAt: Timestamp
/// Creates a successful task result.
///
/// - Parameters:
/// - taskId: The task ID.
/// - executorDid: The executing agent's DID.
/// - output: The task output.
/// - Returns: A successful `TaskResult`.
public static func success(
taskId: String,
executorDid: String,
output: JSONValue
) -> TaskResult
public let executorDid: String
/// Whether the task completed successfully.
public let success: Bool
/// The task output.
public let output: JSONValue
/// Error message if the task failed.
public let errorMessage: String?
/// When the result was produced.
public let completedAt: Timestamp
/// Creates a successful task result.
///
/// - Parameters:
/// - taskId: The task ID.
/// - executorDid: The executing agent's DID.
/// - output: The task output.
/// - Returns: A successful `TaskResult`.
public static func success(
taskId: String,
executorDid: String,
output: JSONValue
) -> TaskResult
public let success: Bool
/// The task output.
public let output: JSONValue
/// Error message if the task failed.
public let errorMessage: String?
/// When the result was produced.
public let completedAt: Timestamp
/// Creates a successful task result.
///
/// - Parameters:
/// - taskId: The task ID.
/// - executorDid: The executing agent's DID.
/// - output: The task output.
/// - Returns: A successful `TaskResult`.
public static func success(
taskId: String,
executorDid: String,
output: JSONValue
) -> TaskResult
public let output: JSONValue
/// Error message if the task failed.
public let errorMessage: String?
/// When the result was produced.
public let completedAt: Timestamp
/// Creates a successful task result.
///
/// - Parameters:
/// - taskId: The task ID.
/// - executorDid: The executing agent's DID.
/// - output: The task output.
/// - Returns: A successful `TaskResult`.
public static func success(
taskId: String,
executorDid: String,
output: JSONValue
) -> TaskResult
public let errorMessage: String?
/// When the result was produced.
public let completedAt: Timestamp
/// Creates a successful task result.
///
/// - Parameters:
/// - taskId: The task ID.
/// - executorDid: The executing agent's DID.
/// - output: The task output.
/// - Returns: A successful `TaskResult`.
public static func success(
taskId: String,
executorDid: String,
output: JSONValue
) -> TaskResult
public let completedAt: Timestamp
/// Creates a successful task result.
///
/// - Parameters:
/// - taskId: The task ID.
/// - executorDid: The executing agent's DID.
/// - output: The task output.
/// - Returns: A successful `TaskResult`.
public static func success(
taskId: String,
executorDid: String,
output: JSONValue
) -> TaskResult
public static func success(
taskId: String,
executorDid: String,
output: JSONValue
) -> TaskResult
public static func failure(
taskId: String,
executorDid: String,
error: String
) -> TaskResult
public enum InterruptType: String, Codable, Sendable, Hashable, CaseIterable
public struct Interrupt: Codable, Sendable, Equatable
public let id: String
/// The task that raised the interrupt.
public let taskId: String
/// The agent that raised the interrupt.
public let raiserDid: String
/// The type of interrupt.
public let interruptType: InterruptType
/// Description of why the interrupt was raised.
public let reason: String
/// Additional context data.
public let context: JSONValue
/// When the interrupt was raised.
public let timestamp: Timestamp
/// Creates a new interrupt.
///
/// - Parameters:
/// - id: Unique interrupt identifier. Defaults to a new UUID.
/// - taskId: The task that raised the interrupt.
/// - raiserDid: The agent that raised the interrupt.
/// - interruptType: The type of interrupt.
/// - reason: Description of why the interrupt was raised.
/// - context: Additional context data.
public init(
id: String;
public let taskId: String
/// The agent that raised the interrupt.
public let raiserDid: String
/// The type of interrupt.
public let interruptType: InterruptType
/// Description of why the interrupt was raised.
public let reason: String
/// Additional context data.
public let context: JSONValue
/// When the interrupt was raised.
public let timestamp: Timestamp
/// Creates a new interrupt.
///
/// - Parameters:
/// - id: Unique interrupt identifier. Defaults to a new UUID.
/// - taskId: The task that raised the interrupt.
/// - raiserDid: The agent that raised the interrupt.
/// - interruptType: The type of interrupt.
/// - reason: Description of why the interrupt was raised.
/// - context: Additional context data.
public init(
id: String;
public let raiserDid: String
/// The type of interrupt.
public let interruptType: InterruptType
/// Description of why the interrupt was raised.
public let reason: String
/// Additional context data.
public let context: JSONValue
/// When the interrupt was raised.
public let timestamp: Timestamp
/// Creates a new interrupt.
///
/// - Parameters:
/// - id: Unique interrupt identifier. Defaults to a new UUID.
/// - taskId: The task that raised the interrupt.
/// - raiserDid: The agent that raised the interrupt.
/// - interruptType: The type of interrupt.
/// - reason: Description of why the interrupt was raised.
/// - context: Additional context data.
public init(
id: String;
public let interruptType: InterruptType
/// Description of why the interrupt was raised.
public let reason: String
/// Additional context data.
public let context: JSONValue
/// When the interrupt was raised.
public let timestamp: Timestamp
/// Creates a new interrupt.
///
/// - Parameters:
/// - id: Unique interrupt identifier. Defaults to a new UUID.
/// - taskId: The task that raised the interrupt.
/// - raiserDid: The agent that raised the interrupt.
/// - interruptType: The type of interrupt.
/// - reason: Description of why the interrupt was raised.
/// - context: Additional context data.
public init(
id: String;
public let reason: String
/// Additional context data.
public let context: JSONValue
/// When the interrupt was raised.
public let timestamp: Timestamp
/// Creates a new interrupt.
///
/// - Parameters:
/// - id: Unique interrupt identifier. Defaults to a new UUID.
/// - taskId: The task that raised the interrupt.
/// - raiserDid: The agent that raised the interrupt.
/// - interruptType: The type of interrupt.
/// - reason: Description of why the interrupt was raised.
/// - context: Additional context data.
public init(
id: String;
public let context: JSONValue
/// When the interrupt was raised.
public let timestamp: Timestamp
/// Creates a new interrupt.
///
/// - Parameters:
/// - id: Unique interrupt identifier. Defaults to a new UUID.
/// - taskId: The task that raised the interrupt.
/// - raiserDid: The agent that raised the interrupt.
/// - interruptType: The type of interrupt.
/// - reason: Description of why the interrupt was raised.
/// - context: Additional context data.
public init(
id: String;
public let timestamp: Timestamp
/// Creates a new interrupt.
///
/// - Parameters:
/// - id: Unique interrupt identifier. Defaults to a new UUID.
/// - taskId: The task that raised the interrupt.
/// - raiserDid: The agent that raised the interrupt.
/// - interruptType: The type of interrupt.
/// - reason: Description of why the interrupt was raised.
/// - context: Additional context data.
public init(
id: String;
public init(
id: String;Delegation.swift
Read declaration text · 2 declaration entries
public func createDelegatedTask(
sessionId: String,
delegatorDid: String,
assigneeDid: String?;
public func validateTaskConstraints(
task: DelegatedTask,
agentCapabilities: [String]
) throwsInterruptHandler.swift
Read declaration text · 5 declaration entries
public protocol InterruptHandler: Sendable
public func createInterrupt(
taskId: String,
raiserDid: String,
type: InterruptType,
reason: String,
context: JSONValue;
public final class NoopInterruptHandler: InterruptHandler, Sendable
public init()
public func handle(_ interrupt: Interrupt) async throws -> JSONValueRoleContracts.swift
Read declaration text · 3 declaration entries
public protocol CoordinatorContract: Sendable
public protocol WorkerContract: Sendable
public protocol PeerContract: SendableSessionContract.swift
Read declaration text · 11 declaration entries
public final class SessionManager: @unchecked Sendable
public init(name: String, sessionId: String;
public var session: CollaborationSession
public var state: SessionState
public func addParticipant(_ did: String, role: CollaborationRole) throws
public func removeParticipant(_ did: String)
public func transition(to target: SessionState) throws
public func addTask(_ task: DelegatedTask) throws
public func recordResult(_ result: TaskResult)
public func tasks() -> [DelegatedTask]
public func results() -> [TaskResult]SharedContext.swift
Read declaration text · 8 declaration entries
public protocol SharedContextContract: Sendable
public final class InMemorySharedContext: SharedContextContract, @unchecked Sendable
public init()
public func get(_ key: String) -> JSONValue?
public func set(_ key: String, value: JSONValue, writerDid: String)
public func remove(_ key: String) -> JSONValue?
public func keys() -> [String]
public var count: Int