Skip to content

Reorganize some files - #223

Merged
renal128 merged 7 commits into
nextfrom
refine-public-layout
Aug 4, 2026
Merged

Reorganize some files#223
renal128 merged 7 commits into
nextfrom
refine-public-layout

Conversation

@renal128

@renal128 renal128 commented Jul 25, 2026

Copy link
Copy Markdown
Contributor

Summary

  • File moves: TokenService → Internal, audio/networking internals, ConversationClient / LogLevel up to Public/, models under Conversation/Models
  • Merge DisconnectionReason into EndReason and collapse ConversationAgentReadyReport into agentReady(elapsed:)
  • Colocate CallInfo / EndReason with ConversationState, and session config knobs with ConversationConfig
  • Merge startup state/metrics/result into ConversationStartup.swift

Test plan

  • swift build
  • swift test

Note

Medium Risk
Breaking changes for SDK consumers (onDisconnect type, endConversation signature, startup state shape, and file/type locations), though behavior is largely preserved and tests were updated accordingly.

Overview
This PR reorganizes the ElevenLabs Swift SDK’s conversation surface area and simplifies a few overlapping public types, with matching test updates.

Public API / type model

  • onDisconnect now receives EndReason instead of DisconnectionReason; DisconnectionReason is removed.
  • endConversation takes a single reason: EndReason (no separate disconnect vs end reason).
  • ConversationStartupState.agentReady carries elapsed: TimeInterval directly instead of wrapping ConversationAgentReadyReport (that struct is removed).
  • CallInfo and EndReason live alongside ConversationState; startup types (ConversationStartupState, metrics, ConversationStartResult) are merged into ConversationStartup.swift.
  • Session knobs (WebRTCConfiguration, AgentStateConfiguration, AudioPipelineConfiguration, MicrophoneMuteMode, ConversationStartupConfiguration) are colocated in ConversationConfig.swift instead of scattered files.
  • AgentState moves under Conversation/Models/; several small standalone public files are deleted as part of the consolidation.

Internal visibility

  • TokenService is no longer public (internal SDK use only).

Tests

  • Agent disconnect expectations use EndReason.remoteDisconnected instead of DisconnectionReason.agent.

Reviewed by Cursor Bugbot for commit 1f1ad8d. Bugbot is set up for automated code reviews on this repo. Configure here.

Comment on lines -250 to -251
disconnectReason: DisconnectionReason = .user,
endReason: EndReason = .userEnded

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

redundant, just one reason is enough

switch await waitForAgentReady(timeout: agentTimeout) {
case let .success(elapsed):
metrics.agentReady = elapsed
onStartupStateChange(.agentReady(ConversationAgentReadyReport(elapsed: elapsed)))

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

unnecessary wrapper class with a single field


/// Configuration for event-based agent state management using VAD and client events.
/// Pass `nil` to use the default LiveKit-based behaviour.
public struct AgentStateConfiguration: Sendable {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Moved to ConfigurationConfig.swift

@@ -1,16 +0,0 @@
import Foundation

public struct ConversationStartupConfiguration: Sendable, Equatable {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Moved to ConfigurationConfig.swift

import Foundation

/// Configures microphone pipeline and voice activity reporting exposed by the SDK.
public struct AudioPipelineConfiguration: Sendable {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Moved to ConfigurationConfig.swift

@@ -1,6 +0,0 @@
import Foundation

public enum EndReason: Equatable, Sendable {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Moved to ConversationState.swift

@@ -1,6 +0,0 @@
import Foundation

public struct CallInfo: Equatable, Sendable {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Moved to ConversationState.swift

@@ -1,9 +0,0 @@
import Foundation

public struct ConversationAgentReadyReport: Sendable, Equatable {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Deleted the wrapper class in favor of using elapsed directly

@@ -1,4 +0,0 @@
public struct ConversationStartResult: Equatable, Sendable {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Moved to ConversationStartup.swift

import Foundation

/// In-flight startup stage while `ConversationState` is `.connecting`.
public enum ConversationStartupState: Sendable, Equatable {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Moved to ConversationStartup.swift

@renal128 renal128 mentioned this pull request Jul 25, 2026
3 tasks
@renal128
renal128 force-pushed the refine-public-layout branch from 9d934e6 to 194d47d Compare July 26, 2026 07:25
@renal128
renal128 force-pushed the refine-public-layout branch from 194d47d to 0a9e852 Compare July 26, 2026 16:30
@renal128
renal128 force-pushed the refine-public-layout branch 2 times, most recently from cbe68ec to e548d7c Compare July 26, 2026 16:59
@renal128
renal128 force-pushed the refine-public-layout branch from e548d7c to 57cc551 Compare July 26, 2026 17:09
@renal128 renal128 mentioned this pull request Jul 26, 2026
@renal128
renal128 changed the base branch from reshuffle-files to remove-global-config July 26, 2026 17:24
@renal128 renal128 changed the title Refine public Conversation type layout Reshuffle files and refine public Conversation layout Jul 26, 2026
@renal128 renal128 changed the title Reshuffle files and refine public Conversation layout Reorganize some files Jul 26, 2026
import Foundation

/// Agent state indicating what the agent is currently doing.
public enum AgentState: Sendable, Equatable {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

moved to Sources/ElevenLabs/Public/Conversation/Models/AgentState.swift

@renal128
renal128 force-pushed the refine-public-layout branch from 57cc551 to a9b4019 Compare August 4, 2026 15:47
@renal128
renal128 force-pushed the refine-public-layout branch from a9b4019 to 23ac1e2 Compare August 4, 2026 16:38
@renal128
renal128 force-pushed the refine-public-layout branch from 23ac1e2 to 5896c38 Compare August 4, 2026 18:33
@renal128
renal128 force-pushed the refine-public-layout branch from 5896c38 to 07e4acc Compare August 4, 2026 19:23
@renal128
renal128 force-pushed the refine-public-layout branch from 07e4acc to c2aa348 Compare August 4, 2026 19:31
Base automatically changed from remove-global-config to next August 4, 2026 19:34
renal128 and others added 7 commits August 4, 2026 20:34
Co-authored-by: Cursor <cursoragent@cursor.com>
Use a single EndReason for ConversationState.ended and onDisconnect, and give endConversation one reason parameter.

Co-authored-by: Cursor <cursoragent@cursor.com>
Replace the one-field wrapper with agentReady(elapsed:) on ConversationStartupState.

Co-authored-by: Cursor <cursoragent@cursor.com>
These types only exist as associated values of ConversationState; keep them in the same file and drop the Models junk-drawer entries.

Co-authored-by: Cursor <cursoragent@cursor.com>
Move audio, WebRTC, startup, and agent-state configuration into ConversationConfig.swift so session knobs live in one file. Leave AgentState as a separate runtime type.

Co-authored-by: Cursor <cursoragent@cursor.com>
Colocate ConversationStartupState, ConversationStartupMetrics, and ConversationStartResult in one file.

Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
@renal128
renal128 force-pushed the refine-public-layout branch from c2aa348 to 1f1ad8d Compare August 4, 2026 19:34
@renal128
renal128 merged commit f39cc89 into next Aug 4, 2026
2 checks passed
@renal128
renal128 deleted the refine-public-layout branch August 4, 2026 19:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants