spb/poche Public
Agent personnel 100 % on-device — SwiftUI + Apple Foundation Models + EventKit + SwiftData. Aucune API, aucun serveur.
Swift 100%
1//2// GetUpcomingTool.swift3// Poche4//5// Author: Simon-Pierre Boucher6// Contact: contact@spboucher.ai7//89import Foundation10import FoundationModels1112/// Read-only view of upcoming events and reminders, strictly capped:13/// a tool that returns 30 calendar events blows the context and kills the14/// session (CLAUDE.md §4).15struct GetUpcomingTool: Tool {16 let name = "getUpcoming"17 let description = "Liste les prochains événements du calendrier et rappels à venir."1819 @Generable20 struct Arguments {21 @Guide(description: "Nombre de jours à couvrir, entre 1 et 14 (défaut 7)")22 let days: Int?23 }2425 private let bridge: EventKitBridge2627 init(bridge: EventKitBridge) {28 self.bridge = bridge29 }3031 func call(arguments: Arguments) async throws -> String {32 let days = min(max(arguments.days ?? 7, 1), 14)3334 var lines: [String] = []35 do {36 let events = try await bridge.upcomingEvents(days: days, limit: 5)37 if !events.isEmpty {38 lines.append("Événements :")39 lines.append(contentsOf: events)40 }41 } catch {42 lines.append("Calendrier inaccessible (accès non autorisé).")43 }4445 do {46 let reminders = try await bridge.upcomingReminders(limit: 5)47 if !reminders.isEmpty {48 lines.append("Rappels :")49 lines.append(contentsOf: reminders)50 }51 } catch {52 lines.append("Rappels inaccessibles (accès non autorisé).")53 }5455 if lines.isEmpty {56 return "Rien de prévu dans les \(days) prochains jours."57 }58 return lines.joined(separator: "\n")59 }60}61