Repository Public
1// =============================================================================2// SP BOUCHER | SOFTWARE & RESEARCH3// ARTIFICIAL INTELLIGENCE • FINANCE • ENGINEERING4// =============================================================================5//6// PROJECT METADATA7// -----------------------------------------------------------------------------8// Project : Claude Remote / Codex Remote9// File : Packages/ClaudeRemoteKit/Sources/ClaudeRemoteModels/ClusterDTO.swift10// Module : ClaudeRemoteModels11// Repository : https://git.spboucher.ai/claude-remote-apple12// Project Website : https://claude.spboucher.ai13// Created : 2026-11-2914// Last Modified : 2026-11-2915//16// =============================================================================17// AUTHOR & PROFESSIONAL AFFILIATION18// =============================================================================19//20// Author : Simon-Pierre Boucher21// Position : Professor of Finance22// Institution : Université du Québec en Outaouais (UQO)23// Department : Département des sciences administratives24// Organization : SP Boucher25//26// Website : https://spboucher.ai27// Git : https://git.spboucher.ai28//29// =============================================================================30// OFFICIAL CONTACT DIRECTORY31// =============================================================================32//33// General : info@spboucher.ai34// Professional : contact@spboucher.ai35// Direct : simon@spboucher.ai36// Research : research@spboucher.ai37// Development : dev@spboucher.ai38// Support : support@spboucher.ai39// Security/Admin : admin@spboucher.ai40// Notifications : notifications@spboucher.ai41//42// Preferred Contact: support@spboucher.ai43//44// =============================================================================45// COPYRIGHT & INTELLECTUAL PROPERTY46// =============================================================================47//48// Copyright (c) 202649// Simon-Pierre Boucher50//51// All rights reserved where applicable.52//53// This file is governed by the applicable project license,54// copyright notices, institutional agreements and relevant law.55//56// Unless expressly authorized by the applicable license or57// rights holder, copying, redistribution, sublicensing,58// publication and commercial exploitation are not permitted.59//60// Existing third-party rights and notices remain unaffected.61//62// =============================================================================63// CONFIDENTIALITY & SECURITY64// =============================================================================65//66// Classification : Public67// Distribution : Public repository; use is governed by the project license68// Security Contact : admin@spboucher.ai69//70// Access to this source does not independently grant permission71// to redistribute or disclose confidential materials.72//73// Do not embed credentials, private keys, access tokens,74// certificates or confidential personal information.75//76// =============================================================================77// LICENSE & MAINTENANCE78// =============================================================================79//80// License : None specified (no license file in this repository)81// Maintainer : Simon-Pierre Boucher82// Technical Contact: dev@spboucher.ai83//84// =============================================================================85// END OF SP BOUCHER SOURCE HEADER86// =============================================================================8788import Foundation8990public struct AppCounts: Codable, Hashable, Sendable {91 public var total: Int92 public var up: Int93 public var degraded: Int94 public var down: Int95}9697public enum ClusterNodeKind: OpenStringEnum {98 case mac, server, mobile, storage, other99 case unknown(String)100 public static var known: [(ClusterNodeKind, String)] {101 [(.mac, "mac"), (.server, "server"), (.mobile, "mobile"), (.storage, "storage"), (.other, "other")]102 }103 public var unknownRawValue: String? { if case .unknown(let r) = self { r } else { nil } }104}105106public struct ClusterNode: Codable, Hashable, Sendable, Identifiable {107 /// Alias, e.g. "M5M36".108 public var id: String109 public var model: String?110 public var chip: String?111 public var kind: ClusterNodeKind112 public var role: String?113 public var cpuCores: Int?114 public var gpuCores: Int?115 public var memoryMb: Double?116 public var os: String?117 public var health: Health118 /// When the metrics below were collected; nil = never.119 public var metricsAt: Date?120 public var stale: Bool121 public var cpuPct: Double?122 public var memUsedMb: Double?123 public var diskFreeGb: Double?124 public var diskTotalGb: Double?125 public var load1: Double?126 public var apps: [String]127 public var execAllowed: Bool128 /// The node this instance runs on.129 public var isHost: Bool130 // Extended telemetry (agentd ≥ 3): nil when the source does not report it.131 public var gpuPct: Double?132 public var thermal: String?133 public var uptimeSec: Double?134 public var netInKbs: Double?135 public var netOutKbs: Double?136 public var appStats: AppCounts?137138 public var memPct: Double? {139 guard let used = memUsedMb, let total = memoryMb, total > 0 else { return nil }140 return used / total * 100141 }142}143144public enum ClusterSource: OpenStringEnum {145 case agentd, none146 case unknown(String)147 public static var known: [(ClusterSource, String)] { [(.agentd, "agentd"), (.none, "none")] }148 public var unknownRawValue: String? { if case .unknown(let r) = self { r } else { nil } }149}150151public enum ClusterEdgeKind: OpenStringEnum {152 case lan, tunnel, service153 case unknown(String)154 public static var known: [(ClusterEdgeKind, String)] { [(.lan, "lan"), (.tunnel, "tunnel"), (.service, "service")] }155 public var unknownRawValue: String? { if case .unknown(let r) = self { r } else { nil } }156}157158public struct ClusterOverview: Codable, Hashable, Sendable {159 public struct Edge: Codable, Hashable, Sendable {160 public var from: String161 public var to: String162 public var kind: ClusterEdgeKind163 }164 public struct Totals: Codable, Hashable, Sendable {165 public var nodes: Int166 public var online: Int167 public var cores: Int168 public var memoryGb: Double169 }170 public struct Aggregate: Codable, Hashable, Sendable {171 public var cpuPct: Double?172 public var memPct: Double?173 public var memUsedGb: Double?174 public var memTotalGb: Double?175 public var gpuPct: Double?176 public var netInKbs: Double?177 public var netOutKbs: Double?178 }179 public struct Incidents: Codable, Hashable, Sendable {180 public var critical: Int181 public var warning: Int182 public var total: Int183 }184 public var source: ClusterSource185 public var collectedAt: Date?186 public var health: Health187 public var nodes: [ClusterNode]188 public var edges: [Edge]189 public var totals: Totals190 /// Nil when not reported or when the snapshot is stale.191 public var aggregate: Aggregate?192 public var apps: AppCounts?193 public var incidents: Incidents?194 public var agentVersion: String?195}196197public enum ClusterAppState: OpenStringEnum {198 case up, degraded, down199 case unknown(String)200 public static var known: [(ClusterAppState, String)] { [(.up, "up"), (.degraded, "degraded"), (.down, "down")] }201 public var unknownRawValue: String? { if case .unknown(let r) = self { r } else { nil } }202}203204public struct ClusterApp: Codable, Hashable, Sendable, Identifiable {205 public var id: String206 public var label: String207 public var node: String?208 /// Public hostname, when exposed through the tunnel.209 public var domain: String?210 public var port: Int?211 public var state: ClusterAppState212 public var reason: String?213 /// As reported by the registry (not guaranteed ISO-8601).214 public var deployedAt: String?215 public var uptime24hPct: Double?216 public var cpuPct: Double?217 public var memMb: Double?218 public var latencyMs: Double?219 public var processes: Int220}221222public struct ClusterApps: Codable, Hashable, Sendable {223 public var source: ClusterSource224 public var collectedAt: Date?225 public var summary: AppCounts226 public var apps: [ClusterApp]227}228229public enum IncidentSeverity: OpenStringEnum {230 case critical, warning, info231 case unknown(String)232 public static var known: [(IncidentSeverity, String)] { [(.critical, "critical"), (.warning, "warning"), (.info, "info")] }233 public var unknownRawValue: String? { if case .unknown(let r) = self { r } else { nil } }234}235236public struct ClusterIncident: Codable, Hashable, Sendable, Identifiable {237 public var id: String238 public var severity: IncidentSeverity239 public var kind: String240 public var subject: String241 public var title: String242 public var detail: String?243 public var since: Date?244 public var acked: Bool245}246247public struct ClusterTrend: Codable, Hashable, Sendable {248 public struct Point: Codable, Hashable, Sendable {249 public var at: Date250 public var cpuPct: Double?251 public var memPct: Double?252 public var gpuPct: Double?253 public var netInKbs: Double?254 public var netOutKbs: Double?255 }256 public var source: ClusterSource257 public var points: [Point]258}259260/// One recorded per-node sample (1/min).261public struct ClusterMetricPoint: Codable, Hashable, Sendable {262 public var at: Date263 public var online: Bool264 public var cpuPct: Double?265 public var memUsedMb: Double?266 public var diskFreeGb: Double?267 public var load1: Double?268}269270/// `GET /cluster/nodes/:id`: the node and its recorded metrics (24 h).271public struct ClusterNodeDetail: Codable, Hashable, Sendable {272 public var node: ClusterNode273 public var history: [ClusterMetricPoint]274}275276/// `GET /cluster/metrics?node=&minutes=`.277public struct ClusterMetrics: Codable, Hashable, Sendable {278 public var since: Date279 /// Node id → samples.280 public var series: [String: [ClusterMetricPoint]]281}282283public struct LocalModel: Codable, Hashable, Sendable, Identifiable {284 public var id: String285 public var name: String286 public var host: String287 public var engine: String?288 /// Display label; the endpoint is only reachable from the server.289 public var endpoint: String290 public var health: Health291 public var checkedAt: Date?292 public var latencyMs: Double?293 public var tokensPerSec: Double?294}295296/// `POST /cluster/models/:id/test`: a real small completion.297public struct LocalModelTest: Codable, Hashable, Sendable {298 public var ok: Bool299 public var checkedAt: Date300 public var latencyMs: Double?301 public var tokensPerSec: Double?302 public var error: String?303}304