The best way to control Claude Code, Codex and more from any computer or phone
| 1 | import * as Schema from "effect/Schema"; |
| 2 | |
| 3 | import { NonNegativeInt, PositiveInt, TrimmedNonEmptyString } from "./baseSchemas.ts"; |
| 4 | import { HostPowerSnapshot } from "./background.ts"; |
| 5 | import { DesktopUpdateChannelSchema, DesktopUpdateStateSchema } from "./ipc.ts"; |
| 6 | |
| 7 | export const RESOURCE_MONITOR_PROTOCOL_VERSION = 3 as const; |
| 8 | |
| 9 | export const HostResourcesSnapshot = Schema.Struct({ |
| 10 | sampledAt: NonNegativeInt, |
| 11 | cpuUtilization: Schema.NullOr(Schema.Number.check(Schema.isBetween({ minimum: 0, maximum: 1 }))), |
| 12 | cpuCount: NonNegativeInt, |
| 13 | availableMemoryBytes: NonNegativeInt, |
| 14 | totalMemoryBytes: NonNegativeInt, |
| 15 | }); |
| 16 | export type HostResourcesSnapshot = typeof HostResourcesSnapshot.Type; |
| 17 | |
| 18 | export const ResourceTelemetryIoSemantics = Schema.Literals([ |
| 19 | "storage", |
| 20 | "logical", |
| 21 | "all-io", |
| 22 | "unavailable", |
| 23 | ]); |
| 24 | export type ResourceTelemetryIoSemantics = typeof ResourceTelemetryIoSemantics.Type; |
| 25 | |
| 26 | export const ResourceTelemetryProcessCategory = Schema.Literals([ |
| 27 | "server", |
| 28 | "server-child", |
| 29 | "provider-root", |
| 30 | "terminal-root", |
| 31 | "electron-main", |
| 32 | "electron-renderer", |
| 33 | "electron-gpu", |
| 34 | "electron-utility", |
| 35 | "resource-monitor", |
| 36 | "unknown-t3", |
| 37 | ]); |
| 38 | export type ResourceTelemetryProcessCategory = typeof ResourceTelemetryProcessCategory.Type; |
| 39 | |
| 40 | export const ResourceTelemetrySourceStatus = Schema.Literals([ |
| 41 | "starting", |
| 42 | "healthy", |
| 43 | "degraded", |
| 44 | "unavailable", |
| 45 | "stopped", |
| 46 | ]); |
| 47 | export type ResourceTelemetrySourceStatus = typeof ResourceTelemetrySourceStatus.Type; |
| 48 | |
| 49 | export const ResourceTelemetryProcessIdentity = Schema.Struct({ |
| 50 | pid: PositiveInt, |
| 51 | startTimeMs: NonNegativeInt, |
| 52 | }); |
| 53 | export type ResourceTelemetryProcessIdentity = typeof ResourceTelemetryProcessIdentity.Type; |
| 54 | |
| 55 | export const ResourceMonitorExternalProcess = Schema.Struct({ |
| 56 | pid: PositiveInt, |
| 57 | startTimeMs: Schema.optionalKey(NonNegativeInt), |
| 58 | }); |
| 59 | export type ResourceMonitorExternalProcess = typeof ResourceMonitorExternalProcess.Type; |
| 60 | |
| 61 | export const ResourceMonitorCapabilities = Schema.Struct({ |
| 62 | cumulativeCpuTime: Schema.Boolean, |
| 63 | currentCpuPercent: Schema.Boolean, |
| 64 | residentMemory: Schema.Boolean, |
| 65 | virtualMemory: Schema.Boolean, |
| 66 | ioBytes: Schema.Boolean, |
| 67 | processStartTime: Schema.Boolean, |
| 68 | processTree: Schema.Boolean, |
| 69 | }); |
| 70 | export type ResourceMonitorCapabilities = typeof ResourceMonitorCapabilities.Type; |
| 71 | |
| 72 | export const ResourceMonitorProcessSample = Schema.Struct({ |
| 73 | pid: PositiveInt, |
| 74 | ppid: NonNegativeInt, |
| 75 | startTimeMs: NonNegativeInt, |
| 76 | runTimeMs: NonNegativeInt, |
| 77 | name: Schema.String, |
| 78 | command: Schema.String, |
| 79 | status: Schema.String, |
| 80 | cpuPercent: Schema.Number, |
| 81 | cpuTimeMs: NonNegativeInt, |
| 82 | residentBytes: NonNegativeInt, |
| 83 | virtualBytes: NonNegativeInt, |
| 84 | ioReadBytes: NonNegativeInt, |
| 85 | ioWriteBytes: NonNegativeInt, |
| 86 | ioSemantics: Schema.Literals(["storage", "all-io"]), |
| 87 | }); |
| 88 | export type ResourceMonitorProcessSample = typeof ResourceMonitorProcessSample.Type; |
| 89 | |
| 90 | export const ResourceMonitorConfigureCommand = Schema.Struct({ |
| 91 | version: Schema.Literal(RESOURCE_MONITOR_PROTOCOL_VERSION), |
| 92 | type: Schema.Literal("configure"), |
| 93 | rootPid: PositiveInt, |
| 94 | sampleIntervalMs: NonNegativeInt, |
| 95 | externalProcesses: Schema.Array(ResourceMonitorExternalProcess), |
| 96 | }); |
| 97 | export type ResourceMonitorConfigureCommand = typeof ResourceMonitorConfigureCommand.Type; |
| 98 | |
| 99 | export const ResourceMonitorSetExternalProcessesCommand = Schema.Struct({ |
| 100 | version: Schema.Literal(RESOURCE_MONITOR_PROTOCOL_VERSION), |
| 101 | type: Schema.Literal("setExternalProcesses"), |
| 102 | processes: Schema.Array(ResourceMonitorExternalProcess), |
| 103 | }); |
| 104 | export type ResourceMonitorSetExternalProcessesCommand = |
| 105 | typeof ResourceMonitorSetExternalProcessesCommand.Type; |
| 106 | |
| 107 | export const ResourceMonitorSampleNowCommand = Schema.Struct({ |
| 108 | version: Schema.Literal(RESOURCE_MONITOR_PROTOCOL_VERSION), |
| 109 | type: Schema.Literal("sampleNow"), |
| 110 | requestId: TrimmedNonEmptyString, |
| 111 | }); |
| 112 | export type ResourceMonitorSampleNowCommand = typeof ResourceMonitorSampleNowCommand.Type; |
| 113 | |
| 114 | export const ResourceMonitorProcessTableCommand = Schema.Struct({ |
| 115 | version: Schema.Literal(RESOURCE_MONITOR_PROTOCOL_VERSION), |
| 116 | type: Schema.Literal("processTable"), |
| 117 | requestId: TrimmedNonEmptyString, |
| 118 | }); |
| 119 | export type ResourceMonitorProcessTableCommand = typeof ResourceMonitorProcessTableCommand.Type; |
| 120 | |
| 121 | export const ResourceMonitorSetSampleIntervalCommand = Schema.Struct({ |
| 122 | version: Schema.Literal(RESOURCE_MONITOR_PROTOCOL_VERSION), |
| 123 | type: Schema.Literal("setSampleInterval"), |
| 124 | sampleIntervalMs: NonNegativeInt, |
| 125 | }); |
| 126 | export type ResourceMonitorSetSampleIntervalCommand = |
| 127 | typeof ResourceMonitorSetSampleIntervalCommand.Type; |
| 128 | |
| 129 | export const ResourceMonitorSetStreamingCommand = Schema.Struct({ |
| 130 | version: Schema.Literal(RESOURCE_MONITOR_PROTOCOL_VERSION), |
| 131 | type: Schema.Literal("setStreaming"), |
| 132 | enabled: Schema.Boolean, |
| 133 | }); |
| 134 | export type ResourceMonitorSetStreamingCommand = typeof ResourceMonitorSetStreamingCommand.Type; |
| 135 | |
| 136 | export const ResourceMonitorReadHistoryCommand = Schema.Struct({ |
| 137 | version: Schema.Literal(RESOURCE_MONITOR_PROTOCOL_VERSION), |
| 138 | type: Schema.Literal("readHistory"), |
| 139 | requestId: TrimmedNonEmptyString, |
| 140 | windowMs: NonNegativeInt, |
| 141 | }); |
| 142 | export type ResourceMonitorReadHistoryCommand = typeof ResourceMonitorReadHistoryCommand.Type; |
| 143 | |
| 144 | export const ResourceMonitorShutdownCommand = Schema.Struct({ |
| 145 | version: Schema.Literal(RESOURCE_MONITOR_PROTOCOL_VERSION), |
| 146 | type: Schema.Literal("shutdown"), |
| 147 | }); |
| 148 | export type ResourceMonitorShutdownCommand = typeof ResourceMonitorShutdownCommand.Type; |
| 149 | |
| 150 | export const ResourceMonitorCommand = Schema.Union([ |
| 151 | ResourceMonitorConfigureCommand, |
| 152 | ResourceMonitorSetExternalProcessesCommand, |
| 153 | ResourceMonitorSetSampleIntervalCommand, |
| 154 | ResourceMonitorSetStreamingCommand, |
| 155 | ResourceMonitorSampleNowCommand, |
| 156 | ResourceMonitorProcessTableCommand, |
| 157 | ResourceMonitorReadHistoryCommand, |
| 158 | ResourceMonitorShutdownCommand, |
| 159 | ]); |
| 160 | export type ResourceMonitorCommand = typeof ResourceMonitorCommand.Type; |
| 161 | |
| 162 | export const ResourceMonitorHelloEvent = Schema.Struct({ |
| 163 | version: Schema.Literal(RESOURCE_MONITOR_PROTOCOL_VERSION), |
| 164 | type: Schema.Literal("hello"), |
| 165 | sidecarVersion: TrimmedNonEmptyString, |
| 166 | sidecarPid: PositiveInt, |
| 167 | platform: TrimmedNonEmptyString, |
| 168 | arch: TrimmedNonEmptyString, |
| 169 | capabilities: ResourceMonitorCapabilities, |
| 170 | }); |
| 171 | export type ResourceMonitorHelloEvent = typeof ResourceMonitorHelloEvent.Type; |
| 172 | |
| 173 | export const ResourceMonitorSnapshotEvent = Schema.Struct({ |
| 174 | version: Schema.Literal(RESOURCE_MONITOR_PROTOCOL_VERSION), |
| 175 | type: Schema.Literal("snapshot"), |
| 176 | sequence: NonNegativeInt, |
| 177 | sampledAtUnixMs: NonNegativeInt, |
| 178 | collectionDurationMicros: NonNegativeInt, |
| 179 | scannedProcessCount: NonNegativeInt, |
| 180 | retainedProcessCount: NonNegativeInt, |
| 181 | inaccessibleProcessCount: NonNegativeInt, |
| 182 | requestId: Schema.optionalKey(TrimmedNonEmptyString), |
| 183 | externalProcesses: Schema.optionalKey(Schema.Array(ResourceMonitorExternalProcess)), |
| 184 | processes: Schema.Array(ResourceMonitorProcessSample), |
| 185 | }); |
| 186 | export type ResourceMonitorSnapshotEvent = typeof ResourceMonitorSnapshotEvent.Type; |
| 187 | |
| 188 | export const ResourceMonitorProcessTableEntry = Schema.Struct({ |
| 189 | pid: PositiveInt, |
| 190 | ppid: NonNegativeInt, |
| 191 | name: Schema.String, |
| 192 | }); |
| 193 | export type ResourceMonitorProcessTableEntry = typeof ResourceMonitorProcessTableEntry.Type; |
| 194 | |
| 195 | export const ResourceMonitorProcessTableEvent = Schema.Struct({ |
| 196 | version: Schema.Literal(RESOURCE_MONITOR_PROTOCOL_VERSION), |
| 197 | type: Schema.Literal("processTable"), |
| 198 | requestId: TrimmedNonEmptyString, |
| 199 | processes: Schema.Array(ResourceMonitorProcessTableEntry), |
| 200 | }); |
| 201 | export type ResourceMonitorProcessTableEvent = typeof ResourceMonitorProcessTableEvent.Type; |
| 202 | |
| 203 | export const ResourceMonitorHistoryChunkEvent = Schema.Struct({ |
| 204 | version: Schema.Literal(RESOURCE_MONITOR_PROTOCOL_VERSION), |
| 205 | type: Schema.Literal("historyChunk"), |
| 206 | requestId: TrimmedNonEmptyString, |
| 207 | done: Schema.Boolean, |
| 208 | snapshots: Schema.Array(ResourceMonitorSnapshotEvent), |
| 209 | }); |
| 210 | export type ResourceMonitorHistoryChunkEvent = typeof ResourceMonitorHistoryChunkEvent.Type; |
| 211 | |
| 212 | export const ResourceMonitorErrorEvent = Schema.Struct({ |
| 213 | version: Schema.Literal(RESOURCE_MONITOR_PROTOCOL_VERSION), |
| 214 | type: Schema.Literal("error"), |
| 215 | code: TrimmedNonEmptyString, |
| 216 | message: TrimmedNonEmptyString, |
| 217 | recoverable: Schema.Boolean, |
| 218 | }); |
| 219 | export type ResourceMonitorErrorEvent = typeof ResourceMonitorErrorEvent.Type; |
| 220 | |
| 221 | export const ResourceMonitorEvent = Schema.Union([ |
| 222 | ResourceMonitorHelloEvent, |
| 223 | ResourceMonitorSnapshotEvent, |
| 224 | ResourceMonitorProcessTableEvent, |
| 225 | ResourceMonitorHistoryChunkEvent, |
| 226 | ResourceMonitorErrorEvent, |
| 227 | ]); |
| 228 | export type ResourceMonitorEvent = typeof ResourceMonitorEvent.Type; |
| 229 | |
| 230 | export const DesktopElectronProcessType = Schema.Literals([ |
| 231 | "Browser", |
| 232 | "Tab", |
| 233 | "Utility", |
| 234 | "Zygote", |
| 235 | "Sandbox helper", |
| 236 | "GPU", |
| 237 | "Pepper Plugin", |
| 238 | "Pepper Plugin Broker", |
| 239 | "Unknown", |
| 240 | ]); |
| 241 | export type DesktopElectronProcessType = typeof DesktopElectronProcessType.Type; |
| 242 | |
| 243 | export const DesktopElectronProcessMetric = Schema.Struct({ |
| 244 | pid: PositiveInt, |
| 245 | creationTimeMs: NonNegativeInt, |
| 246 | type: DesktopElectronProcessType, |
| 247 | name: Schema.optionalKey(Schema.String), |
| 248 | serviceName: Schema.optionalKey(Schema.String), |
| 249 | cpuPercent: Schema.Number, |
| 250 | cumulativeCpuSeconds: Schema.optionalKey(Schema.Number), |
| 251 | idleWakeupsPerSecond: Schema.Number, |
| 252 | workingSetBytes: NonNegativeInt, |
| 253 | peakWorkingSetBytes: NonNegativeInt, |
| 254 | }); |
| 255 | export type DesktopElectronProcessMetric = typeof DesktopElectronProcessMetric.Type; |
| 256 | |
| 257 | const DesktopHostPowerSnapshot = Schema.Struct({ |
| 258 | ...HostPowerSnapshot.fields, |
| 259 | updatedAt: Schema.DateTimeUtcFromString, |
| 260 | }); |
| 261 | |
| 262 | export const DesktopHostTelemetrySnapshot = Schema.Struct({ |
| 263 | version: Schema.Literal(1), |
| 264 | type: Schema.Literal("desktopTelemetry"), |
| 265 | sequence: NonNegativeInt, |
| 266 | sampledAtUnixMs: NonNegativeInt, |
| 267 | electronPid: PositiveInt, |
| 268 | power: DesktopHostPowerSnapshot, |
| 269 | speedLimitPercent: Schema.OptionFromNullOr(Schema.Number), |
| 270 | electronProcesses: Schema.Array(DesktopElectronProcessMetric), |
| 271 | }); |
| 272 | export type DesktopHostTelemetrySnapshot = typeof DesktopHostTelemetrySnapshot.Type; |
| 273 | |
| 274 | export const DesktopHostTelemetryHello = Schema.Struct({ |
| 275 | version: Schema.Literal(1), |
| 276 | type: Schema.Literal("desktopTelemetryHello"), |
| 277 | electronPid: PositiveInt, |
| 278 | }); |
| 279 | export type DesktopHostTelemetryHello = typeof DesktopHostTelemetryHello.Type; |
| 280 | |
| 281 | export const DesktopUpdateRemoteOutcome = Schema.Literals([ |
| 282 | "ready-to-install", |
| 283 | "up-to-date", |
| 284 | "failed", |
| 285 | ]); |
| 286 | export type DesktopUpdateRemoteOutcome = typeof DesktopUpdateRemoteOutcome.Type; |
| 287 | |
| 288 | export const DesktopUpdateStatusReport = Schema.Struct({ |
| 289 | version: Schema.Literal(1), |
| 290 | type: Schema.Literal("desktopUpdateStatus"), |
| 291 | requestId: Schema.optionalKey(TrimmedNonEmptyString), |
| 292 | preparedRequestId: Schema.optionalKey(TrimmedNonEmptyString), |
| 293 | outcome: Schema.optionalKey(DesktopUpdateRemoteOutcome), |
| 294 | reason: Schema.optionalKey(TrimmedNonEmptyString), |
| 295 | state: DesktopUpdateStateSchema, |
| 296 | }); |
| 297 | export type DesktopUpdateStatusReport = typeof DesktopUpdateStatusReport.Type; |
| 298 | |
| 299 | export const ShellEnvironmentPatch = Schema.Struct({ |
| 300 | PATH: Schema.optionalKey(Schema.NullOr(Schema.String)), |
| 301 | ANDROID_HOME: Schema.optionalKey(Schema.NullOr(Schema.String)), |
| 302 | ANDROID_SDK_ROOT: Schema.optionalKey(Schema.NullOr(Schema.String)), |
| 303 | DBUS_SESSION_BUS_ADDRESS: Schema.optionalKey(Schema.NullOr(Schema.String)), |
| 304 | DISPLAY: Schema.optionalKey(Schema.NullOr(Schema.String)), |
| 305 | LANG: Schema.optionalKey(Schema.NullOr(Schema.String)), |
| 306 | LC_ALL: Schema.optionalKey(Schema.NullOr(Schema.String)), |
| 307 | LC_CTYPE: Schema.optionalKey(Schema.NullOr(Schema.String)), |
| 308 | SSH_AUTH_SOCK: Schema.optionalKey(Schema.NullOr(Schema.String)), |
| 309 | HOMEBREW_PREFIX: Schema.optionalKey(Schema.NullOr(Schema.String)), |
| 310 | HOMEBREW_CELLAR: Schema.optionalKey(Schema.NullOr(Schema.String)), |
| 311 | HOMEBREW_REPOSITORY: Schema.optionalKey(Schema.NullOr(Schema.String)), |
| 312 | XDG_CONFIG_HOME: Schema.optionalKey(Schema.NullOr(Schema.String)), |
| 313 | XDG_CURRENT_DESKTOP: Schema.optionalKey(Schema.NullOr(Schema.String)), |
| 314 | XDG_DATA_HOME: Schema.optionalKey(Schema.NullOr(Schema.String)), |
| 315 | XDG_RUNTIME_DIR: Schema.optionalKey(Schema.NullOr(Schema.String)), |
| 316 | XDG_SESSION_DESKTOP: Schema.optionalKey(Schema.NullOr(Schema.String)), |
| 317 | XDG_SESSION_TYPE: Schema.optionalKey(Schema.NullOr(Schema.String)), |
| 318 | WAYLAND_DISPLAY: Schema.optionalKey(Schema.NullOr(Schema.String)), |
| 319 | SSL_CERT_FILE: Schema.optionalKey(Schema.NullOr(Schema.String)), |
| 320 | SSL_CERT_DIR: Schema.optionalKey(Schema.NullOr(Schema.String)), |
| 321 | NODE_EXTRA_CA_CERTS: Schema.optionalKey(Schema.NullOr(Schema.String)), |
| 322 | T3CODE_TELEMETRY_ENABLED: Schema.optionalKey(Schema.NullOr(Schema.String)), |
| 323 | T3CODE_GITHUB_APP_CLIENT_ID: Schema.optionalKey(Schema.NullOr(Schema.String)), |
| 324 | T3CODE_RELEASE_BASE_URL: Schema.optionalKey(Schema.NullOr(Schema.String)), |
| 325 | __MISE_DIFF: Schema.optionalKey(Schema.NullOr(Schema.String)), |
| 326 | JAVA_HOME: Schema.optionalKey(Schema.NullOr(Schema.String)), |
| 327 | PNPM_HOME: Schema.optionalKey(Schema.NullOr(Schema.String)), |
| 328 | FNM_DIR: Schema.optionalKey(Schema.NullOr(Schema.String)), |
| 329 | FNM_MULTISHELL_PATH: Schema.optionalKey(Schema.NullOr(Schema.String)), |
| 330 | }); |
| 331 | export type ShellEnvironmentPatch = typeof ShellEnvironmentPatch.Type; |
| 332 | |
| 333 | export const DesktopShellEnvironmentSnapshot = Schema.Struct({ |
| 334 | version: Schema.Literal(1), |
| 335 | type: Schema.Literal("shellEnvironment"), |
| 336 | discovered: Schema.Boolean, |
| 337 | platform: Schema.String, |
| 338 | environment: ShellEnvironmentPatch, |
| 339 | }); |
| 340 | export type DesktopShellEnvironmentSnapshot = typeof DesktopShellEnvironmentSnapshot.Type; |
| 341 | |
| 342 | export const DesktopHostTelemetryMessage = Schema.Union([ |
| 343 | DesktopHostTelemetryHello, |
| 344 | DesktopShellEnvironmentSnapshot, |
| 345 | DesktopHostTelemetrySnapshot, |
| 346 | DesktopUpdateStatusReport, |
| 347 | ]); |
| 348 | export type DesktopHostTelemetryMessage = typeof DesktopHostTelemetryMessage.Type; |
| 349 | |
| 350 | export const DesktopTelemetrySetDiagnosticsDemand = Schema.Struct({ |
| 351 | version: Schema.Literal(1), |
| 352 | type: Schema.Literal("setDiagnosticsDemand"), |
| 353 | enabled: Schema.Boolean, |
| 354 | }); |
| 355 | export type DesktopTelemetrySetDiagnosticsDemand = typeof DesktopTelemetrySetDiagnosticsDemand.Type; |
| 356 | |
| 357 | export const DesktopTelemetrySetHostPowerIntervals = Schema.Struct({ |
| 358 | version: Schema.Literal(1), |
| 359 | type: Schema.Literal("setHostPowerIntervals"), |
| 360 | activeIntervalMs: PositiveInt, |
| 361 | idleIntervalMs: PositiveInt, |
| 362 | }); |
| 363 | export type DesktopTelemetrySetHostPowerIntervals = |
| 364 | typeof DesktopTelemetrySetHostPowerIntervals.Type; |
| 365 | |
| 366 | /** Runs check/download/quit-and-install without local confirmation; the remote RPC click supplies consent. */ |
| 367 | export const DesktopTelemetryRequestDesktopUpdate = Schema.Struct({ |
| 368 | version: Schema.Literal(1), |
| 369 | type: Schema.Literal("requestDesktopUpdate"), |
| 370 | requestId: TrimmedNonEmptyString, |
| 371 | /** A track switch: move to this channel first, and install only `targetVersion`. */ |
| 372 | channel: Schema.optionalKey(DesktopUpdateChannelSchema), |
| 373 | targetVersion: Schema.optionalKey(TrimmedNonEmptyString), |
| 374 | }); |
| 375 | export type DesktopTelemetryRequestDesktopUpdate = typeof DesktopTelemetryRequestDesktopUpdate.Type; |
| 376 | |
| 377 | export const DesktopTelemetryCommitDesktopUpdate = Schema.Struct({ |
| 378 | version: Schema.Literal(1), |
| 379 | type: Schema.Literal("commitDesktopUpdate"), |
| 380 | requestId: TrimmedNonEmptyString, |
| 381 | }); |
| 382 | export type DesktopTelemetryCommitDesktopUpdate = typeof DesktopTelemetryCommitDesktopUpdate.Type; |
| 383 | |
| 384 | export const DesktopTelemetryCancelDesktopUpdate = Schema.Struct({ |
| 385 | version: Schema.Literal(1), |
| 386 | type: Schema.Literal("cancelDesktopUpdate"), |
| 387 | requestId: TrimmedNonEmptyString, |
| 388 | }); |
| 389 | export type DesktopTelemetryCancelDesktopUpdate = typeof DesktopTelemetryCancelDesktopUpdate.Type; |
| 390 | |
| 391 | /** The server accepts requests; the desktop treats this as backend readiness. */ |
| 392 | export const DesktopTelemetryServerReady = Schema.Struct({ |
| 393 | version: Schema.Literal(1), |
| 394 | type: Schema.Literal("serverReady"), |
| 395 | }); |
| 396 | export type DesktopTelemetryServerReady = typeof DesktopTelemetryServerReady.Type; |
| 397 | |
| 398 | export const DesktopTelemetryControlMessage = Schema.Union([ |
| 399 | DesktopTelemetryServerReady, |
| 400 | DesktopTelemetrySetDiagnosticsDemand, |
| 401 | DesktopTelemetrySetHostPowerIntervals, |
| 402 | DesktopTelemetryRequestDesktopUpdate, |
| 403 | DesktopTelemetryCommitDesktopUpdate, |
| 404 | DesktopTelemetryCancelDesktopUpdate, |
| 405 | ]); |
| 406 | export type DesktopTelemetryControlMessage = typeof DesktopTelemetryControlMessage.Type; |
| 407 | |
| 408 | export const ResourceTelemetryProcess = Schema.Struct({ |
| 409 | identity: ResourceTelemetryProcessIdentity, |
| 410 | ppid: NonNegativeInt, |
| 411 | childPids: Schema.Array(PositiveInt), |
| 412 | depth: NonNegativeInt, |
| 413 | name: Schema.String, |
| 414 | command: Schema.String, |
| 415 | status: Schema.String, |
| 416 | category: ResourceTelemetryProcessCategory, |
| 417 | electronType: Schema.optionalKey(DesktopElectronProcessType), |
| 418 | electronServiceName: Schema.optionalKey(Schema.String), |
| 419 | cpuPercent: Schema.Number, |
| 420 | cpuTimeMs: NonNegativeInt, |
| 421 | residentBytes: NonNegativeInt, |
| 422 | peakResidentBytes: NonNegativeInt, |
| 423 | virtualBytes: NonNegativeInt, |
| 424 | ioReadBytes: NonNegativeInt, |
| 425 | ioWriteBytes: NonNegativeInt, |
| 426 | ioReadBytesPerSecond: Schema.Number, |
| 427 | ioWriteBytesPerSecond: Schema.Number, |
| 428 | ioSemantics: ResourceTelemetryIoSemantics, |
| 429 | idleWakeupsPerSecond: Schema.optionalKey(Schema.Number), |
| 430 | runTimeMs: NonNegativeInt, |
| 431 | firstSeenAt: Schema.DateTimeUtc, |
| 432 | lastSeenAt: Schema.DateTimeUtc, |
| 433 | }); |
| 434 | export type ResourceTelemetryProcess = typeof ResourceTelemetryProcess.Type; |
| 435 | |
| 436 | export const ResourceTelemetryAggregate = Schema.Struct({ |
| 437 | processCount: NonNegativeInt, |
| 438 | currentCpuPercent: Schema.Number, |
| 439 | cpuTimeMs: NonNegativeInt, |
| 440 | currentRssBytes: NonNegativeInt, |
| 441 | peakRssBytes: NonNegativeInt, |
| 442 | ioReadBytes: NonNegativeInt, |
| 443 | ioWriteBytes: NonNegativeInt, |
| 444 | ioReadBytesPerSecond: Schema.Number, |
| 445 | ioWriteBytesPerSecond: Schema.Number, |
| 446 | processStarts: NonNegativeInt, |
| 447 | processExits: NonNegativeInt, |
| 448 | }); |
| 449 | export type ResourceTelemetryAggregate = typeof ResourceTelemetryAggregate.Type; |
| 450 | |
| 451 | export const ResourceTelemetryGroups = Schema.Struct({ |
| 452 | backend: ResourceTelemetryAggregate, |
| 453 | electron: ResourceTelemetryAggregate, |
| 454 | monitor: ResourceTelemetryAggregate, |
| 455 | allT3: ResourceTelemetryAggregate, |
| 456 | }); |
| 457 | export type ResourceTelemetryGroups = typeof ResourceTelemetryGroups.Type; |
| 458 | |
| 459 | export const ResourceTelemetrySourceHealth = Schema.Struct({ |
| 460 | status: ResourceTelemetrySourceStatus, |
| 461 | lastSampleAt: Schema.Option(Schema.DateTimeUtc), |
| 462 | lastError: Schema.Option(TrimmedNonEmptyString), |
| 463 | }); |
| 464 | export type ResourceTelemetrySourceHealth = typeof ResourceTelemetrySourceHealth.Type; |
| 465 | |
| 466 | export const ResourceTelemetryHealth = Schema.Struct({ |
| 467 | native: ResourceTelemetrySourceHealth, |
| 468 | desktop: ResourceTelemetrySourceHealth, |
| 469 | sidecarVersion: Schema.Option(TrimmedNonEmptyString), |
| 470 | sidecarPid: Schema.Option(PositiveInt), |
| 471 | restartCount: NonNegativeInt, |
| 472 | collectionDurationMicros: NonNegativeInt, |
| 473 | scannedProcessCount: NonNegativeInt, |
| 474 | retainedProcessCount: NonNegativeInt, |
| 475 | inaccessibleProcessCount: NonNegativeInt, |
| 476 | }); |
| 477 | export type ResourceTelemetryHealth = typeof ResourceTelemetryHealth.Type; |
| 478 | |
| 479 | export const ResourceAttributionEntry = Schema.Struct({ |
| 480 | component: TrimmedNonEmptyString, |
| 481 | operation: TrimmedNonEmptyString, |
| 482 | logicalReadBytes: NonNegativeInt, |
| 483 | logicalWriteBytes: NonNegativeInt, |
| 484 | count: NonNegativeInt, |
| 485 | durationMs: NonNegativeInt, |
| 486 | }); |
| 487 | export type ResourceAttributionEntry = typeof ResourceAttributionEntry.Type; |
| 488 | |
| 489 | export const ResourceAttributionSnapshot = Schema.Struct({ |
| 490 | readAt: Schema.DateTimeUtc, |
| 491 | entries: Schema.Array(ResourceAttributionEntry), |
| 492 | }); |
| 493 | export type ResourceAttributionSnapshot = typeof ResourceAttributionSnapshot.Type; |
| 494 | |
| 495 | export const ResourceTelemetrySnapshot = Schema.Struct({ |
| 496 | readAt: Schema.DateTimeUtc, |
| 497 | sampleIntervalMs: NonNegativeInt, |
| 498 | processes: Schema.Array(ResourceTelemetryProcess), |
| 499 | groups: ResourceTelemetryGroups, |
| 500 | power: HostPowerSnapshot, |
| 501 | speedLimitPercent: Schema.Option(Schema.Number), |
| 502 | attribution: ResourceAttributionSnapshot, |
| 503 | health: ResourceTelemetryHealth, |
| 504 | }); |
| 505 | export type ResourceTelemetrySnapshot = typeof ResourceTelemetrySnapshot.Type; |
| 506 | |
| 507 | export const ResourceTelemetryHistoryInput = Schema.Struct({ |
| 508 | windowMs: NonNegativeInt, |
| 509 | bucketMs: NonNegativeInt, |
| 510 | }); |
| 511 | export type ResourceTelemetryHistoryInput = typeof ResourceTelemetryHistoryInput.Type; |
| 512 | |
| 513 | export const ResourceTelemetryHistoryBucket = Schema.Struct({ |
| 514 | startedAt: Schema.DateTimeUtc, |
| 515 | endedAt: Schema.DateTimeUtc, |
| 516 | avgCpuPercent: Schema.Number, |
| 517 | maxCpuPercent: Schema.Number, |
| 518 | maxRssBytes: NonNegativeInt, |
| 519 | ioReadBytes: NonNegativeInt, |
| 520 | ioWriteBytes: NonNegativeInt, |
| 521 | maxProcessCount: NonNegativeInt, |
| 522 | }); |
| 523 | export type ResourceTelemetryHistoryBucket = typeof ResourceTelemetryHistoryBucket.Type; |
| 524 | |
| 525 | export const ResourceTelemetryProcessSummary = Schema.Struct({ |
| 526 | identity: ResourceTelemetryProcessIdentity, |
| 527 | ppid: NonNegativeInt, |
| 528 | depth: NonNegativeInt, |
| 529 | name: Schema.String, |
| 530 | command: Schema.String, |
| 531 | category: ResourceTelemetryProcessCategory, |
| 532 | firstSeenAt: Schema.DateTimeUtc, |
| 533 | lastSeenAt: Schema.DateTimeUtc, |
| 534 | currentCpuPercent: Schema.Number, |
| 535 | avgCpuPercent: Schema.Number, |
| 536 | maxCpuPercent: Schema.Number, |
| 537 | cpuTimeMs: NonNegativeInt, |
| 538 | currentRssBytes: NonNegativeInt, |
| 539 | peakRssBytes: NonNegativeInt, |
| 540 | ioReadBytes: NonNegativeInt, |
| 541 | ioWriteBytes: NonNegativeInt, |
| 542 | ioSemantics: ResourceTelemetryIoSemantics, |
| 543 | sampleCount: NonNegativeInt, |
| 544 | }); |
| 545 | export type ResourceTelemetryProcessSummary = typeof ResourceTelemetryProcessSummary.Type; |
| 546 | |
| 547 | export const ResourceTelemetryHistory = Schema.Struct({ |
| 548 | readAt: Schema.DateTimeUtc, |
| 549 | windowMs: NonNegativeInt, |
| 550 | bucketMs: NonNegativeInt, |
| 551 | sampleIntervalMs: NonNegativeInt, |
| 552 | retainedSampleCount: NonNegativeInt, |
| 553 | buckets: Schema.Array(ResourceTelemetryHistoryBucket), |
| 554 | topProcesses: Schema.Array(ResourceTelemetryProcessSummary), |
| 555 | health: ResourceTelemetryHealth, |
| 556 | }); |
| 557 | export type ResourceTelemetryHistory = typeof ResourceTelemetryHistory.Type; |
| 558 | |
| 559 | export const ResourceTelemetryRetryResult = Schema.Struct({ |
| 560 | accepted: Schema.Boolean, |
| 561 | snapshot: ResourceTelemetrySnapshot, |
| 562 | }); |
| 563 | export type ResourceTelemetryRetryResult = typeof ResourceTelemetryRetryResult.Type; |