// swift-tools-version: 5.9
import PackageDescription

let package = Package(
    name: "MLXCore",
    platforms: [.macOS(.v14)],
    dependencies: [
        // Pinned to 0.10.x — last version without Swift 6.2-only `withThrowingTaskGroup { ... }`
        // syntax. macos-14's Xcode is Swift 6.1.x. 0.11 added 2025-11-25 spec coverage + icons +
        // elicitation updates we don't use; 0.12 added OAuth we don't use.
        .package(url: "https://github.com/modelcontextprotocol/swift-sdk.git", "0.10.2" ..< "0.11.0"),
        // Already pulled transitively by swift-sdk; declared here so we can use OrderedDictionary
        // directly to preserve user-edited key order in mcp.json.
        .package(url: "https://github.com/apple/swift-collections.git", from: "1.0.0"),
        // libopus + libogg wrapper (Element/Matrix team) — decodes Telegram's
        // Ogg/Opus voice notes, which AVFoundation can't read. Used only by
        // `VoicePreprocessor`; statically linked, so no dylib bundling/signing.
        .package(url: "https://github.com/element-hq/swift-ogg.git", from: "0.0.4"),
    ],
    targets: [
        .executableTarget(
            name: "MLXCore",
            dependencies: [
                .product(name: "MCP", package: "swift-sdk"),
                .product(name: "OrderedCollections", package: "swift-collections"),
                .product(name: "SwiftOGG", package: "swift-ogg"),
            ],
            path: "Sources/MLXServe",
            exclude: ["Resources"]
        ),
        .testTarget(
            name: "MLXCoreTests",
            dependencies: [
                "MLXCore",
                // Used only to synthesise an Ogg/Opus fixture for the
                // VoicePreprocessor round-trip test.
                .product(name: "SwiftOGG", package: "swift-ogg"),
            ],
            path: "Tests/MLXCoreTests"
        ),
    ]
)
