Open History to see the last commit
1import * as Schema from "effect/Schema";
2
3import { NonNegativeInt, PositiveInt, TrimmedNonEmptyString } from "./baseSchemas.ts";
4import { HostPowerSnapshot } from "./background.ts";
5import { DesktopUpdateChannelSchema, DesktopUpdateStateSchema } from "./ipc.ts";
6
7export const RESOURCE_MONITOR_PROTOCOL_VERSION = 3 as const;
8
9export 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});
16export type HostResourcesSnapshot = typeof HostResourcesSnapshot.Type;
17
18export const ResourceTelemetryIoSemantics = Schema.Literals([
19 "storage",
20 "logical",
21 "all-io",
22 "unavailable",
23]);
24export type ResourceTelemetryIoSemantics = typeof ResourceTelemetryIoSemantics.Type;
25
26export 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]);
38export type ResourceTelemetryProcessCategory = typeof ResourceTelemetryProcessCategory.Type;
39
40export const ResourceTelemetrySourceStatus = Schema.Literals([
41 "starting",
42 "healthy",
43 "degraded",
44 "unavailable",
45 "stopped",
46]);
47export type ResourceTelemetrySourceStatus = typeof ResourceTelemetrySourceStatus.Type;
48
49export const ResourceTelemetryProcessIdentity = Schema.Struct({
50 pid: PositiveInt,
51 startTimeMs: NonNegativeInt,
52});
53export type ResourceTelemetryProcessIdentity = typeof ResourceTelemetryProcessIdentity.Type;
54
55export const ResourceMonitorExternalProcess = Schema.Struct({
56 pid: PositiveInt,
57 startTimeMs: Schema.optionalKey(NonNegativeInt),
58});
59export type ResourceMonitorExternalProcess = typeof ResourceMonitorExternalProcess.Type;
60
61export 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});
70export type ResourceMonitorCapabilities = typeof ResourceMonitorCapabilities.Type;
71
72export 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});
88export type ResourceMonitorProcessSample = typeof ResourceMonitorProcessSample.Type;
89
90export 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});
97export type ResourceMonitorConfigureCommand = typeof ResourceMonitorConfigureCommand.Type;
98
99export const ResourceMonitorSetExternalProcessesCommand = Schema.Struct({
100 version: Schema.Literal(RESOURCE_MONITOR_PROTOCOL_VERSION),
101 type: Schema.Literal("setExternalProcesses"),
102 processes: Schema.Array(ResourceMonitorExternalProcess),
103});
104export type ResourceMonitorSetExternalProcessesCommand =
105 typeof ResourceMonitorSetExternalProcessesCommand.Type;
106
107export const ResourceMonitorSampleNowCommand = Schema.Struct({
108 version: Schema.Literal(RESOURCE_MONITOR_PROTOCOL_VERSION),
109 type: Schema.Literal("sampleNow"),
110 requestId: TrimmedNonEmptyString,
111});
112export type ResourceMonitorSampleNowCommand = typeof ResourceMonitorSampleNowCommand.Type;
113
114export const ResourceMonitorProcessTableCommand = Schema.Struct({
115 version: Schema.Literal(RESOURCE_MONITOR_PROTOCOL_VERSION),
116 type: Schema.Literal("processTable"),
117 requestId: TrimmedNonEmptyString,
118});
119export type ResourceMonitorProcessTableCommand = typeof ResourceMonitorProcessTableCommand.Type;
120
121export const ResourceMonitorSetSampleIntervalCommand = Schema.Struct({
122 version: Schema.Literal(RESOURCE_MONITOR_PROTOCOL_VERSION),
123 type: Schema.Literal("setSampleInterval"),
124 sampleIntervalMs: NonNegativeInt,
125});
126export type ResourceMonitorSetSampleIntervalCommand =
127 typeof ResourceMonitorSetSampleIntervalCommand.Type;
128
129export const ResourceMonitorSetStreamingCommand = Schema.Struct({
130 version: Schema.Literal(RESOURCE_MONITOR_PROTOCOL_VERSION),
131 type: Schema.Literal("setStreaming"),
132 enabled: Schema.Boolean,
133});
134export type ResourceMonitorSetStreamingCommand = typeof ResourceMonitorSetStreamingCommand.Type;
135
136export const ResourceMonitorReadHistoryCommand = Schema.Struct({
137 version: Schema.Literal(RESOURCE_MONITOR_PROTOCOL_VERSION),
138 type: Schema.Literal("readHistory"),
139 requestId: TrimmedNonEmptyString,
140 windowMs: NonNegativeInt,
141});
142export type ResourceMonitorReadHistoryCommand = typeof ResourceMonitorReadHistoryCommand.Type;
143
144export const ResourceMonitorShutdownCommand = Schema.Struct({
145 version: Schema.Literal(RESOURCE_MONITOR_PROTOCOL_VERSION),
146 type: Schema.Literal("shutdown"),
147});
148export type ResourceMonitorShutdownCommand = typeof ResourceMonitorShutdownCommand.Type;
149
150export const ResourceMonitorCommand = Schema.Union([
151 ResourceMonitorConfigureCommand,
152 ResourceMonitorSetExternalProcessesCommand,
153 ResourceMonitorSetSampleIntervalCommand,
154 ResourceMonitorSetStreamingCommand,
155 ResourceMonitorSampleNowCommand,
156 ResourceMonitorProcessTableCommand,
157 ResourceMonitorReadHistoryCommand,
158 ResourceMonitorShutdownCommand,
159]);
160export type ResourceMonitorCommand = typeof ResourceMonitorCommand.Type;
161
162export 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});
171export type ResourceMonitorHelloEvent = typeof ResourceMonitorHelloEvent.Type;
172
173export 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});
186export type ResourceMonitorSnapshotEvent = typeof ResourceMonitorSnapshotEvent.Type;
187
188export const ResourceMonitorProcessTableEntry = Schema.Struct({
189 pid: PositiveInt,
190 ppid: NonNegativeInt,
191 name: Schema.String,
192});
193export type ResourceMonitorProcessTableEntry = typeof ResourceMonitorProcessTableEntry.Type;
194
195export 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});
201export type ResourceMonitorProcessTableEvent = typeof ResourceMonitorProcessTableEvent.Type;
202
203export 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});
210export type ResourceMonitorHistoryChunkEvent = typeof ResourceMonitorHistoryChunkEvent.Type;
211
212export 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});
219export type ResourceMonitorErrorEvent = typeof ResourceMonitorErrorEvent.Type;
220
221export const ResourceMonitorEvent = Schema.Union([
222 ResourceMonitorHelloEvent,
223 ResourceMonitorSnapshotEvent,
224 ResourceMonitorProcessTableEvent,
225 ResourceMonitorHistoryChunkEvent,
226 ResourceMonitorErrorEvent,
227]);
228export type ResourceMonitorEvent = typeof ResourceMonitorEvent.Type;
229
230export 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]);
241export type DesktopElectronProcessType = typeof DesktopElectronProcessType.Type;
242
243export 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});
255export type DesktopElectronProcessMetric = typeof DesktopElectronProcessMetric.Type;
256
257const DesktopHostPowerSnapshot = Schema.Struct({
258 ...HostPowerSnapshot.fields,
259 updatedAt: Schema.DateTimeUtcFromString,
260});
261
262export 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});
272export type DesktopHostTelemetrySnapshot = typeof DesktopHostTelemetrySnapshot.Type;
273
274export const DesktopHostTelemetryHello = Schema.Struct({
275 version: Schema.Literal(1),
276 type: Schema.Literal("desktopTelemetryHello"),
277 electronPid: PositiveInt,
278});
279export type DesktopHostTelemetryHello = typeof DesktopHostTelemetryHello.Type;
280
281export const DesktopUpdateRemoteOutcome = Schema.Literals([
282 "ready-to-install",
283 "up-to-date",
284 "failed",
285]);
286export type DesktopUpdateRemoteOutcome = typeof DesktopUpdateRemoteOutcome.Type;
287
288export 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});
297export type DesktopUpdateStatusReport = typeof DesktopUpdateStatusReport.Type;
298
299export 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 __MISE_DIFF: Schema.optionalKey(Schema.NullOr(Schema.String)),
325 JAVA_HOME: Schema.optionalKey(Schema.NullOr(Schema.String)),
326 FNM_DIR: Schema.optionalKey(Schema.NullOr(Schema.String)),
327 FNM_MULTISHELL_PATH: Schema.optionalKey(Schema.NullOr(Schema.String)),
328});
329export type ShellEnvironmentPatch = typeof ShellEnvironmentPatch.Type;
330
331export const DesktopShellEnvironmentSnapshot = Schema.Struct({
332 version: Schema.Literal(1),
333 type: Schema.Literal("shellEnvironment"),
334 discovered: Schema.Boolean,
335 platform: Schema.String,
336 environment: ShellEnvironmentPatch,
337});
338export type DesktopShellEnvironmentSnapshot = typeof DesktopShellEnvironmentSnapshot.Type;
339
340export const DesktopHostTelemetryMessage = Schema.Union([
341 DesktopHostTelemetryHello,
342 DesktopShellEnvironmentSnapshot,
343 DesktopHostTelemetrySnapshot,
344 DesktopUpdateStatusReport,
345]);
346export type DesktopHostTelemetryMessage = typeof DesktopHostTelemetryMessage.Type;
347
348export const DesktopTelemetrySetDiagnosticsDemand = Schema.Struct({
349 version: Schema.Literal(1),
350 type: Schema.Literal("setDiagnosticsDemand"),
351 enabled: Schema.Boolean,
352});
353export type DesktopTelemetrySetDiagnosticsDemand = typeof DesktopTelemetrySetDiagnosticsDemand.Type;
354
355export const DesktopTelemetrySetHostPowerIntervals = Schema.Struct({
356 version: Schema.Literal(1),
357 type: Schema.Literal("setHostPowerIntervals"),
358 activeIntervalMs: PositiveInt,
359 idleIntervalMs: PositiveInt,
360});
361export type DesktopTelemetrySetHostPowerIntervals =
362 typeof DesktopTelemetrySetHostPowerIntervals.Type;
363
364/** Runs check/download/quit-and-install without local confirmation; the remote RPC click supplies consent. */
365export const DesktopTelemetryRequestDesktopUpdate = Schema.Struct({
366 version: Schema.Literal(1),
367 type: Schema.Literal("requestDesktopUpdate"),
368 requestId: TrimmedNonEmptyString,
369 /** A track switch: move to this channel first, and install only `targetVersion`. */
370 channel: Schema.optionalKey(DesktopUpdateChannelSchema),
371 targetVersion: Schema.optionalKey(TrimmedNonEmptyString),
372});
373export type DesktopTelemetryRequestDesktopUpdate = typeof DesktopTelemetryRequestDesktopUpdate.Type;
374
375export const DesktopTelemetryCommitDesktopUpdate = Schema.Struct({
376 version: Schema.Literal(1),
377 type: Schema.Literal("commitDesktopUpdate"),
378 requestId: TrimmedNonEmptyString,
379});
380export type DesktopTelemetryCommitDesktopUpdate = typeof DesktopTelemetryCommitDesktopUpdate.Type;
381
382export const DesktopTelemetryCancelDesktopUpdate = Schema.Struct({
383 version: Schema.Literal(1),
384 type: Schema.Literal("cancelDesktopUpdate"),
385 requestId: TrimmedNonEmptyString,
386});
387export type DesktopTelemetryCancelDesktopUpdate = typeof DesktopTelemetryCancelDesktopUpdate.Type;
388
389/** The server accepts requests; the desktop treats this as backend readiness. */
390export const DesktopTelemetryServerReady = Schema.Struct({
391 version: Schema.Literal(1),
392 type: Schema.Literal("serverReady"),
393});
394export type DesktopTelemetryServerReady = typeof DesktopTelemetryServerReady.Type;
395
396export const DesktopTelemetryControlMessage = Schema.Union([
397 DesktopTelemetryServerReady,
398 DesktopTelemetrySetDiagnosticsDemand,
399 DesktopTelemetrySetHostPowerIntervals,
400 DesktopTelemetryRequestDesktopUpdate,
401 DesktopTelemetryCommitDesktopUpdate,
402 DesktopTelemetryCancelDesktopUpdate,
403]);
404export type DesktopTelemetryControlMessage = typeof DesktopTelemetryControlMessage.Type;
405
406export const ResourceTelemetryProcess = Schema.Struct({
407 identity: ResourceTelemetryProcessIdentity,
408 ppid: NonNegativeInt,
409 childPids: Schema.Array(PositiveInt),
410 depth: NonNegativeInt,
411 name: Schema.String,
412 command: Schema.String,
413 status: Schema.String,
414 category: ResourceTelemetryProcessCategory,
415 electronType: Schema.optionalKey(DesktopElectronProcessType),
416 electronServiceName: Schema.optionalKey(Schema.String),
417 cpuPercent: Schema.Number,
418 cpuTimeMs: NonNegativeInt,
419 residentBytes: NonNegativeInt,
420 peakResidentBytes: NonNegativeInt,
421 virtualBytes: NonNegativeInt,
422 ioReadBytes: NonNegativeInt,
423 ioWriteBytes: NonNegativeInt,
424 ioReadBytesPerSecond: Schema.Number,
425 ioWriteBytesPerSecond: Schema.Number,
426 ioSemantics: ResourceTelemetryIoSemantics,
427 idleWakeupsPerSecond: Schema.optionalKey(Schema.Number),
428 runTimeMs: NonNegativeInt,
429 firstSeenAt: Schema.DateTimeUtc,
430 lastSeenAt: Schema.DateTimeUtc,
431});
432export type ResourceTelemetryProcess = typeof ResourceTelemetryProcess.Type;
433
434export const ResourceTelemetryAggregate = Schema.Struct({
435 processCount: NonNegativeInt,
436 currentCpuPercent: Schema.Number,
437 cpuTimeMs: NonNegativeInt,
438 currentRssBytes: NonNegativeInt,
439 peakRssBytes: NonNegativeInt,
440 ioReadBytes: NonNegativeInt,
441 ioWriteBytes: NonNegativeInt,
442 ioReadBytesPerSecond: Schema.Number,
443 ioWriteBytesPerSecond: Schema.Number,
444 processStarts: NonNegativeInt,
445 processExits: NonNegativeInt,
446});
447export type ResourceTelemetryAggregate = typeof ResourceTelemetryAggregate.Type;
448
449export const ResourceTelemetryGroups = Schema.Struct({
450 backend: ResourceTelemetryAggregate,
451 electron: ResourceTelemetryAggregate,
452 monitor: ResourceTelemetryAggregate,
453 allT3: ResourceTelemetryAggregate,
454});
455export type ResourceTelemetryGroups = typeof ResourceTelemetryGroups.Type;
456
457export const ResourceTelemetrySourceHealth = Schema.Struct({
458 status: ResourceTelemetrySourceStatus,
459 lastSampleAt: Schema.Option(Schema.DateTimeUtc),
460 lastError: Schema.Option(TrimmedNonEmptyString),
461});
462export type ResourceTelemetrySourceHealth = typeof ResourceTelemetrySourceHealth.Type;
463
464export const ResourceTelemetryHealth = Schema.Struct({
465 native: ResourceTelemetrySourceHealth,
466 desktop: ResourceTelemetrySourceHealth,
467 sidecarVersion: Schema.Option(TrimmedNonEmptyString),
468 sidecarPid: Schema.Option(PositiveInt),
469 restartCount: NonNegativeInt,
470 collectionDurationMicros: NonNegativeInt,
471 scannedProcessCount: NonNegativeInt,
472 retainedProcessCount: NonNegativeInt,
473 inaccessibleProcessCount: NonNegativeInt,
474});
475export type ResourceTelemetryHealth = typeof ResourceTelemetryHealth.Type;
476
477export const ResourceAttributionEntry = Schema.Struct({
478 component: TrimmedNonEmptyString,
479 operation: TrimmedNonEmptyString,
480 logicalReadBytes: NonNegativeInt,
481 logicalWriteBytes: NonNegativeInt,
482 count: NonNegativeInt,
483 durationMs: NonNegativeInt,
484});
485export type ResourceAttributionEntry = typeof ResourceAttributionEntry.Type;
486
487export const ResourceAttributionSnapshot = Schema.Struct({
488 readAt: Schema.DateTimeUtc,
489 entries: Schema.Array(ResourceAttributionEntry),
490});
491export type ResourceAttributionSnapshot = typeof ResourceAttributionSnapshot.Type;
492
493export const ResourceTelemetrySnapshot = Schema.Struct({
494 readAt: Schema.DateTimeUtc,
495 sampleIntervalMs: NonNegativeInt,
496 processes: Schema.Array(ResourceTelemetryProcess),
497 groups: ResourceTelemetryGroups,
498 power: HostPowerSnapshot,
499 speedLimitPercent: Schema.Option(Schema.Number),
500 attribution: ResourceAttributionSnapshot,
501 health: ResourceTelemetryHealth,
502});
503export type ResourceTelemetrySnapshot = typeof ResourceTelemetrySnapshot.Type;
504
505export const ResourceTelemetryHistoryInput = Schema.Struct({
506 windowMs: NonNegativeInt,
507 bucketMs: NonNegativeInt,
508});
509export type ResourceTelemetryHistoryInput = typeof ResourceTelemetryHistoryInput.Type;
510
511export const ResourceTelemetryHistoryBucket = Schema.Struct({
512 startedAt: Schema.DateTimeUtc,
513 endedAt: Schema.DateTimeUtc,
514 avgCpuPercent: Schema.Number,
515 maxCpuPercent: Schema.Number,
516 maxRssBytes: NonNegativeInt,
517 ioReadBytes: NonNegativeInt,
518 ioWriteBytes: NonNegativeInt,
519 maxProcessCount: NonNegativeInt,
520});
521export type ResourceTelemetryHistoryBucket = typeof ResourceTelemetryHistoryBucket.Type;
522
523export const ResourceTelemetryProcessSummary = Schema.Struct({
524 identity: ResourceTelemetryProcessIdentity,
525 ppid: NonNegativeInt,
526 depth: NonNegativeInt,
527 name: Schema.String,
528 command: Schema.String,
529 category: ResourceTelemetryProcessCategory,
530 firstSeenAt: Schema.DateTimeUtc,
531 lastSeenAt: Schema.DateTimeUtc,
532 currentCpuPercent: Schema.Number,
533 avgCpuPercent: Schema.Number,
534 maxCpuPercent: Schema.Number,
535 cpuTimeMs: NonNegativeInt,
536 currentRssBytes: NonNegativeInt,
537 peakRssBytes: NonNegativeInt,
538 ioReadBytes: NonNegativeInt,
539 ioWriteBytes: NonNegativeInt,
540 ioSemantics: ResourceTelemetryIoSemantics,
541 sampleCount: NonNegativeInt,
542});
543export type ResourceTelemetryProcessSummary = typeof ResourceTelemetryProcessSummary.Type;
544
545export const ResourceTelemetryHistory = Schema.Struct({
546 readAt: Schema.DateTimeUtc,
547 windowMs: NonNegativeInt,
548 bucketMs: NonNegativeInt,
549 sampleIntervalMs: NonNegativeInt,
550 retainedSampleCount: NonNegativeInt,
551 buckets: Schema.Array(ResourceTelemetryHistoryBucket),
552 topProcesses: Schema.Array(ResourceTelemetryProcessSummary),
553 health: ResourceTelemetryHealth,
554});
555export type ResourceTelemetryHistory = typeof ResourceTelemetryHistory.Type;
556
557export const ResourceTelemetryRetryResult = Schema.Struct({
558 accepted: Schema.Boolean,
559 snapshot: ResourceTelemetrySnapshot,
560});
561export type ResourceTelemetryRetryResult = typeof ResourceTelemetryRetryResult.Type;