spt-apple-bridge
UniFFI bindings exposing SPT Rust engine to Swift for Apple platforms
Overview
spt-apple-bridge is the bridge layer between the Rust cognitive engine and native Swift Apple apps (macOS, iOS, visionOS). It wraps spt-cognitive::CognitiveEngine and spt-indexer behind UniFFI-exported functions and types, providing Swift-callable APIs for memory operations, cognitive think/recall/evolve, and file indexing.
Key Features
- UniFFI Exports --- all types and functions exported to Swift via UniFFI scaffolding
- Cognitive Operations --- think, recall, remember, evolve, cycle exposed to Swift
- Semantic Search --- vector memory search with scored results
- File Indexing --- index directories into vector storage via spt-indexer
- Engine Statistics --- retrieve memory counts, thought counts, SONA patterns
Dependencies
Key internal dependencies:
spt-cognitive--- cognitive engine (think, recall, remember, evolve)spt-core(storage, hnsw) --- vector database backendspt-sona--- adaptive learningspt-indexer--- document indexing pipelineuniffi--- Swift/Kotlin binding generation
Usage
swift
// Swift side (generated by UniFFI):
let bridge = SptBridge()
try bridge.initialize(dbPath: "/path/to/db")
let results = try bridge.search(query: "authentication patterns", limit: 5)
let stats = try bridge.engineStats()API Reference
UniFFI Records (Swift structs)
| Type | Description |
|---|---|
SearchResult | Search hit with id, content, type, score, metadata |
MemoryRecord | Stored memory with importance and access count |
ThinkResult | Think response with confidence and memories used |
EngineStats | Engine metrics (memories, thoughts, cycles, SONA patterns) |
BridgeError | Error enum: Engine, Serialization, NotInitialized, InvalidArgument, NotFound |
Architecture
Swift (SptBrainCore) -> UniFFI FFI -> SptBridge -> spt-cognitive -> spt-core / spt-sona