@@ -148,6 +148,89 @@ public struct CodexRouteStatus: Decodable, Equatable, Sendable {
148148 }
149149}
150150
151+ /// Read-only activation observation from `GET /api/codex-catalog/status`.
152+ /// A restart prompt requires both a published catalog and confirmed stale workers;
153+ /// an unknown or pending status must not tell the user a restart will fix it.
154+ public enum CatalogReloadStatus : Equatable , Sendable {
155+ case unknown
156+ case current
157+ case restartRequired ( staleWorkerCount : Int )
158+ }
159+
160+ /// Closed result contract from authenticated `POST /api/sync`.
161+ public enum CodexCatalogSyncStatus : String , Decodable , Equatable , Sendable {
162+ case applied
163+ case skipped
164+ case refused
165+ }
166+
167+ public enum CodexCatalogSyncSkipReason : String , Decodable , Equatable , Sendable {
168+ case desiredDisabled = " desired_disabled "
169+ case externalProvider = " external_provider "
170+ }
171+
172+ public struct CodexCatalogSyncResponse : Decodable , Equatable , Sendable {
173+ public let status : CodexCatalogSyncStatus
174+ public let ok : Bool
175+ public let skippedReason : CodexCatalogSyncSkipReason ?
176+ public let warning : String ?
177+
178+ public var outcome : CodexCatalogSyncOutcome {
179+ guard ok else { return . failed }
180+ switch status {
181+ case . applied :
182+ return . applied ( warning : warning )
183+ case . skipped :
184+ guard let skippedReason else { return . failed }
185+ return . skipped ( skippedReason )
186+ case . refused :
187+ return . failed
188+ }
189+ }
190+ }
191+
192+ public enum CodexCatalogSyncOutcome : Equatable , Sendable {
193+ case applied ( warning : String ? )
194+ case skipped ( CodexCatalogSyncSkipReason )
195+ case failed
196+ }
197+
198+ public struct CodexCatalogStatus : Decodable , Sendable {
199+ public struct Activation : Decodable , Sendable {
200+ public struct State : Decodable , Sendable {
201+ public let status : String
202+ }
203+
204+ public struct Workers : Decodable , Sendable {
205+ public let status : String
206+ public let staleCount : Int
207+ }
208+
209+ public let schemaVersion : Int
210+ public let catalog : State
211+ public let routing : State
212+ public let workers : Workers
213+ }
214+
215+ public let activation : Activation
216+
217+ public var reloadStatus : CatalogReloadStatus {
218+ guard activation . schemaVersion == 1 ,
219+ activation . catalog . status == " current " ,
220+ activation . routing . status == " current "
221+ else { return . unknown }
222+
223+ switch activation . workers . status {
224+ case " reload_required " where activation . workers . staleCount > 0 :
225+ return . restartRequired ( staleWorkerCount : activation . workers . staleCount )
226+ case " current " , " not_running " :
227+ return . current
228+ default :
229+ return . unknown
230+ }
231+ }
232+ }
233+
151234/// `GET /api/startup-health`
152235public struct StartupHealth : Decodable , Equatable , Sendable {
153236 public let status : String
@@ -265,13 +348,13 @@ public struct QuotaWindow: Decodable, Equatable, Sendable {
265348 public let resetAt : Double ?
266349}
267350
268- /// A published provider cap paired with observations from this local CodexCommander usage
269- /// log. This is reference data, not a provider-reported balance or remaining percent .
351+ /// Observations from this local CodexCommander usage log. Older proxy versions may
352+ /// include a published cap, but it is not a provider-reported balance or current limit .
270353public struct QuotaReferenceWindow : Decodable , Equatable , Sendable {
271354 public let id : String
272355 public let label : String
273356 public let windowSeconds : Double
274- public let publishedLimitUsd : Double
357+ public let publishedLimitUsd : Double ?
275358 public let observedSpendUsd : Double ?
276359 public let observedTokens : Int64
277360 public let observedRequests : Int
@@ -381,6 +464,24 @@ public struct ProviderQuotaEnvelope: Decodable, Equatable, Sendable {
381464 public let availability : [ ProviderQuotaAvailability ]
382465}
383466
467+ /// Completed local requests in the management usage log. These are observations,
468+ /// not an OpenCode Go account balance or a live token counter.
469+ public struct ProviderModelUsage : Decodable , Equatable , Sendable {
470+ public let provider : String
471+ public let model : String
472+ public let requests : Int
473+ public let measuredRequests : Int
474+ public let totalTokens : Int64
475+ public let inputTokens : Int64
476+ public let outputTokens : Int64
477+ public let estimatedCostUsd : Double ?
478+ }
479+
480+ public struct ProviderUsageEnvelope : Decodable , Equatable , Sendable {
481+ public let generatedAt : Double
482+ public let models : [ ProviderModelUsage ]
483+ }
484+
384485public enum AgentActivityRole : String , Decodable , Equatable , Sendable {
385486 case primary
386487 case subagent
0 commit comments