// // ToolInput.swift // Poche // // Author: Simon-Pierre Boucher // Contact: contact@spboucher.ai // import Foundation /// Shared sanitation for model-provided tool arguments. Model output is /// hostile input: trim it, cap it, never let it balloon the store or the /// confirmation card. enum ToolInput { static let maxTitleLength = 80 static let maxBodyLength = 2000 /// Trimmed, capped title — nil when effectively empty. static func title(_ raw: String) -> String? { let trimmed = raw.trimmingCharacters(in: .whitespacesAndNewlines) guard !trimmed.isEmpty else { return nil } return String(trimmed.prefix(maxTitleLength)) } static func body(_ raw: String) -> String? { let trimmed = raw.trimmingCharacters(in: .whitespacesAndNewlines) guard !trimmed.isEmpty else { return nil } return String(trimmed.prefix(maxBodyLength)) } static func optionalText(_ raw: String?) -> String? { guard let raw else { return nil } return title(raw) } }