Skip to content

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 backend
  • spt-sona --- adaptive learning
  • spt-indexer --- document indexing pipeline
  • uniffi --- 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)

TypeDescription
SearchResultSearch hit with id, content, type, score, metadata
MemoryRecordStored memory with importance and access count
ThinkResultThink response with confidence and memories used
EngineStatsEngine metrics (memories, thoughts, cycles, SONA patterns)
BridgeErrorError enum: Engine, Serialization, NotInitialized, InvalidArgument, NotFound

Architecture

Swift (SptBrainCore) -> UniFFI FFI -> SptBridge -> spt-cognitive -> spt-core / spt-sona

Released under the MIT License.