// // AppDependencies.swift // Poche // // Author: Simon-Pierre Boucher // Contact: contact@spboucher.ai // import Foundation import SwiftData import FoundationModels import Observation /// Composition root. Everything is built here once, so there is a single /// ConfirmCenter (the only write path) and a single AgentSession (one /// request in flight, ever). @MainActor @Observable final class AppDependencies { let store: PocheStore let index: SemanticIndex let bridge: EventKitBridge let confirm: ConfirmCenter let agent: AgentSession let chat: ChatViewModel init(container: ModelContainer) { let store = PocheStore(container: container) let index = SemanticIndex() let bridge = EventKitBridge() let executor = ActionExecutor(bridge: bridge, store: store) let confirm = ConfirmCenter(executor: executor) // Hard cap from CLAUDE.md §4: at most 8 tools exposed simultaneously. let tools: [any Tool] = [ CreateReminderTool(confirm: confirm), CreateCalendarEventTool(confirm: confirm), SaveNoteTool(confirm: confirm), CreateTaskTool(confirm: confirm), UpdateTaskTool(confirm: confirm, store: store), SearchMyDataTool(store: store, index: index), GetUpcomingTool(bridge: bridge), ] precondition(tools.count <= 8, "Tool cardinality cap exceeded (CLAUDE.md §4)") let agent = AgentSession(tools: tools) self.store = store self.index = index self.bridge = bridge self.confirm = confirm self.agent = agent self.chat = ChatViewModel(agent: agent, confirm: confirm, store: store) } }