Skip to content
Source
Sign inSign up
pingdotgg/t3code
Open History to see the last commit

resourceTelemetry.ts

560 lines21.1 KB

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 outcome: Schema.optionalKey(DesktopUpdateRemoteOutcome),
293 reason: Schema.optionalKey(TrimmedNonEmptyString),
294 state: DesktopUpdateStateSchema,
295});
296export type DesktopUpdateStatusReport = typeof DesktopUpdateStatusReport.Type;
297​
298export const ShellEnvironmentPatch = Schema.Struct({
299 PATH: Schema.optionalKey(Schema.NullOr(Schema.String)),
300 ANDROID_HOME: Schema.optionalKey(Schema.NullOr(Schema.String)),
301 ANDROID_SDK_ROOT: Schema.optionalKey(Schema.NullOr(Schema.String)),
302 DBUS_SESSION_BUS_ADDRESS: Schema.optionalKey(Schema.NullOr(Schema.String)),
303 DISPLAY: Schema.optionalKey(Schema.NullOr(Schema.String)),
304 LANG: Schema.optionalKey(Schema.NullOr(Schema.String)),
305 LC_ALL: Schema.optionalKey(Schema.NullOr(Schema.String)),
306 LC_CTYPE: Schema.optionalKey(Schema.NullOr(Schema.String)),
307 SSH_AUTH_SOCK: Schema.optionalKey(Schema.NullOr(Schema.String)),
308 HOMEBREW_PREFIX: Schema.optionalKey(Schema.NullOr(Schema.String)),
309 HOMEBREW_CELLAR: Schema.optionalKey(Schema.NullOr(Schema.String)),
310 HOMEBREW_REPOSITORY: Schema.optionalKey(Schema.NullOr(Schema.String)),
311 XDG_CONFIG_HOME: Schema.optionalKey(Schema.NullOr(Schema.String)),
312 XDG_CURRENT_DESKTOP: Schema.optionalKey(Schema.NullOr(Schema.String)),
313 XDG_DATA_HOME: Schema.optionalKey(Schema.NullOr(Schema.String)),
314 XDG_RUNTIME_DIR: Schema.optionalKey(Schema.NullOr(Schema.String)),
315 XDG_SESSION_DESKTOP: Schema.optionalKey(Schema.NullOr(Schema.String)),
316 XDG_SESSION_TYPE: Schema.optionalKey(Schema.NullOr(Schema.String)),
317 WAYLAND_DISPLAY: Schema.optionalKey(Schema.NullOr(Schema.String)),
318 SSL_CERT_FILE: Schema.optionalKey(Schema.NullOr(Schema.String)),
319 SSL_CERT_DIR: Schema.optionalKey(Schema.NullOr(Schema.String)),
320 NODE_EXTRA_CA_CERTS: Schema.optionalKey(Schema.NullOr(Schema.String)),
321 T3CODE_TELEMETRY_ENABLED: Schema.optionalKey(Schema.NullOr(Schema.String)),
322 T3CODE_GITHUB_APP_CLIENT_ID: Schema.optionalKey(Schema.NullOr(Schema.String)),
323 __MISE_DIFF: Schema.optionalKey(Schema.NullOr(Schema.String)),
324 JAVA_HOME: Schema.optionalKey(Schema.NullOr(Schema.String)),
325 FNM_DIR: Schema.optionalKey(Schema.NullOr(Schema.String)),
326 FNM_MULTISHELL_PATH: Schema.optionalKey(Schema.NullOr(Schema.String)),
327});
328export type ShellEnvironmentPatch = typeof ShellEnvironmentPatch.Type;
329​
330export const DesktopShellEnvironmentSnapshot = Schema.Struct({
331 version: Schema.Literal(1),
332 type: Schema.Literal("shellEnvironment"),
333 discovered: Schema.Boolean,
334 platform: Schema.String,
335 environment: ShellEnvironmentPatch,
336});
337export type DesktopShellEnvironmentSnapshot = typeof DesktopShellEnvironmentSnapshot.Type;
338​
339export const DesktopHostTelemetryMessage = Schema.Union([
340 DesktopHostTelemetryHello,
341 DesktopShellEnvironmentSnapshot,
342 DesktopHostTelemetrySnapshot,
343 DesktopUpdateStatusReport,
344]);
345export type DesktopHostTelemetryMessage = typeof DesktopHostTelemetryMessage.Type;
346​
347export const DesktopTelemetrySetDiagnosticsDemand = Schema.Struct({
348 version: Schema.Literal(1),
349 type: Schema.Literal("setDiagnosticsDemand"),
350 enabled: Schema.Boolean,
351});
352export type DesktopTelemetrySetDiagnosticsDemand = typeof DesktopTelemetrySetDiagnosticsDemand.Type;
353​
354export const DesktopTelemetrySetHostPowerIntervals = Schema.Struct({
355 version: Schema.Literal(1),
356 type: Schema.Literal("setHostPowerIntervals"),
357 activeIntervalMs: PositiveInt,
358 idleIntervalMs: PositiveInt,
359});
360export type DesktopTelemetrySetHostPowerIntervals =
361 typeof DesktopTelemetrySetHostPowerIntervals.Type;
362​
363/** Runs check/download/quit-and-install without local confirmation; the remote RPC click supplies consent. */
364export const DesktopTelemetryRequestDesktopUpdate = Schema.Struct({
365 version: Schema.Literal(1),
366 type: Schema.Literal("requestDesktopUpdate"),
367 requestId: TrimmedNonEmptyString,
368 /** A track switch: move to this channel first, and install only `targetVersion`. */
369 channel: Schema.optionalKey(DesktopUpdateChannelSchema),
370 targetVersion: Schema.optionalKey(TrimmedNonEmptyString),
371});
372export type DesktopTelemetryRequestDesktopUpdate = typeof DesktopTelemetryRequestDesktopUpdate.Type;
373​
374export const DesktopTelemetryCommitDesktopUpdate = Schema.Struct({
375 version: Schema.Literal(1),
376 type: Schema.Literal("commitDesktopUpdate"),
377 requestId: TrimmedNonEmptyString,
378});
379export type DesktopTelemetryCommitDesktopUpdate = typeof DesktopTelemetryCommitDesktopUpdate.Type;
380​
381export const DesktopTelemetryCancelDesktopUpdate = Schema.Struct({
382 version: Schema.Literal(1),
383 type: Schema.Literal("cancelDesktopUpdate"),
384 requestId: TrimmedNonEmptyString,
385});
386export type DesktopTelemetryCancelDesktopUpdate = typeof DesktopTelemetryCancelDesktopUpdate.Type;
387​
388/** The server accepts requests; the desktop treats this as backend readiness. */
389export const DesktopTelemetryServerReady = Schema.Struct({
390 version: Schema.Literal(1),
391 type: Schema.Literal("serverReady"),
392});
393export type DesktopTelemetryServerReady = typeof DesktopTelemetryServerReady.Type;
394​
395export const DesktopTelemetryControlMessage = Schema.Union([
396 DesktopTelemetryServerReady,
397 DesktopTelemetrySetDiagnosticsDemand,
398 DesktopTelemetrySetHostPowerIntervals,
399 DesktopTelemetryRequestDesktopUpdate,
400 DesktopTelemetryCommitDesktopUpdate,
401 DesktopTelemetryCancelDesktopUpdate,
402]);
403export type DesktopTelemetryControlMessage = typeof DesktopTelemetryControlMessage.Type;
404​
405export const ResourceTelemetryProcess = Schema.Struct({
406 identity: ResourceTelemetryProcessIdentity,
407 ppid: NonNegativeInt,
408 childPids: Schema.Array(PositiveInt),
409 depth: NonNegativeInt,
410 name: Schema.String,
411 command: Schema.String,
412 status: Schema.String,
413 category: ResourceTelemetryProcessCategory,
414 electronType: Schema.optionalKey(DesktopElectronProcessType),
415 electronServiceName: Schema.optionalKey(Schema.String),
416 cpuPercent: Schema.Number,
417 cpuTimeMs: NonNegativeInt,
418 residentBytes: NonNegativeInt,
419 peakResidentBytes: NonNegativeInt,
420 virtualBytes: NonNegativeInt,
421 ioReadBytes: NonNegativeInt,
422 ioWriteBytes: NonNegativeInt,
423 ioReadBytesPerSecond: Schema.Number,
424 ioWriteBytesPerSecond: Schema.Number,
425 ioSemantics: ResourceTelemetryIoSemantics,
426 idleWakeupsPerSecond: Schema.optionalKey(Schema.Number),
427 runTimeMs: NonNegativeInt,
428 firstSeenAt: Schema.DateTimeUtc,
429 lastSeenAt: Schema.DateTimeUtc,
430});
431export type ResourceTelemetryProcess = typeof ResourceTelemetryProcess.Type;
432​
433export const ResourceTelemetryAggregate = Schema.Struct({
434 processCount: NonNegativeInt,
435 currentCpuPercent: Schema.Number,
436 cpuTimeMs: NonNegativeInt,
437 currentRssBytes: NonNegativeInt,
438 peakRssBytes: NonNegativeInt,
439 ioReadBytes: NonNegativeInt,
440 ioWriteBytes: NonNegativeInt,
441 ioReadBytesPerSecond: Schema.Number,
442 ioWriteBytesPerSecond: Schema.Number,
443 processStarts: NonNegativeInt,
444 processExits: NonNegativeInt,
445});
446export type ResourceTelemetryAggregate = typeof ResourceTelemetryAggregate.Type;
447​
448export const ResourceTelemetryGroups = Schema.Struct({
449 backend: ResourceTelemetryAggregate,
450 electron: ResourceTelemetryAggregate,
451 monitor: ResourceTelemetryAggregate,
452 allT3: ResourceTelemetryAggregate,
453});
454export type ResourceTelemetryGroups = typeof ResourceTelemetryGroups.Type;
455​
456export const ResourceTelemetrySourceHealth = Schema.Struct({
457 status: ResourceTelemetrySourceStatus,
458 lastSampleAt: Schema.Option(Schema.DateTimeUtc),
459 lastError: Schema.Option(TrimmedNonEmptyString),
460});
461export type ResourceTelemetrySourceHealth = typeof ResourceTelemetrySourceHealth.Type;
462​
463export const ResourceTelemetryHealth = Schema.Struct({
464 native: ResourceTelemetrySourceHealth,
465 desktop: ResourceTelemetrySourceHealth,
466 sidecarVersion: Schema.Option(TrimmedNonEmptyString),
467 sidecarPid: Schema.Option(PositiveInt),
468 restartCount: NonNegativeInt,
469 collectionDurationMicros: NonNegativeInt,
470 scannedProcessCount: NonNegativeInt,
471 retainedProcessCount: NonNegativeInt,
472 inaccessibleProcessCount: NonNegativeInt,
473});
474export type ResourceTelemetryHealth = typeof ResourceTelemetryHealth.Type;
475​
476export const ResourceAttributionEntry = Schema.Struct({
477 component: TrimmedNonEmptyString,
478 operation: TrimmedNonEmptyString,
479 logicalReadBytes: NonNegativeInt,
480 logicalWriteBytes: NonNegativeInt,
481 count: NonNegativeInt,
482 durationMs: NonNegativeInt,
483});
484export type ResourceAttributionEntry = typeof ResourceAttributionEntry.Type;
485​
486export const ResourceAttributionSnapshot = Schema.Struct({
487 readAt: Schema.DateTimeUtc,
488 entries: Schema.Array(ResourceAttributionEntry),
489});
490export type ResourceAttributionSnapshot = typeof ResourceAttributionSnapshot.Type;
491​
492export const ResourceTelemetrySnapshot = Schema.Struct({
493 readAt: Schema.DateTimeUtc,
494 sampleIntervalMs: NonNegativeInt,
495 processes: Schema.Array(ResourceTelemetryProcess),
496 groups: ResourceTelemetryGroups,
497 power: HostPowerSnapshot,
498 speedLimitPercent: Schema.Option(Schema.Number),
499 attribution: ResourceAttributionSnapshot,
500 health: ResourceTelemetryHealth,
501});
502export type ResourceTelemetrySnapshot = typeof ResourceTelemetrySnapshot.Type;
503​
504export const ResourceTelemetryHistoryInput = Schema.Struct({
505 windowMs: NonNegativeInt,
506 bucketMs: NonNegativeInt,
507});
508export type ResourceTelemetryHistoryInput = typeof ResourceTelemetryHistoryInput.Type;
509​
510export const ResourceTelemetryHistoryBucket = Schema.Struct({
511 startedAt: Schema.DateTimeUtc,
512 endedAt: Schema.DateTimeUtc,
513 avgCpuPercent: Schema.Number,
514 maxCpuPercent: Schema.Number,
515 maxRssBytes: NonNegativeInt,
516 ioReadBytes: NonNegativeInt,
517 ioWriteBytes: NonNegativeInt,
518 maxProcessCount: NonNegativeInt,
519});
520export type ResourceTelemetryHistoryBucket = typeof ResourceTelemetryHistoryBucket.Type;
521​
522export const ResourceTelemetryProcessSummary = Schema.Struct({
523 identity: ResourceTelemetryProcessIdentity,
524 ppid: NonNegativeInt,
525 depth: NonNegativeInt,
526 name: Schema.String,
527 command: Schema.String,
528 category: ResourceTelemetryProcessCategory,
529 firstSeenAt: Schema.DateTimeUtc,
530 lastSeenAt: Schema.DateTimeUtc,
531 currentCpuPercent: Schema.Number,
532 avgCpuPercent: Schema.Number,
533 maxCpuPercent: Schema.Number,
534 cpuTimeMs: NonNegativeInt,
535 currentRssBytes: NonNegativeInt,
536 peakRssBytes: NonNegativeInt,
537 ioReadBytes: NonNegativeInt,
538 ioWriteBytes: NonNegativeInt,
539 ioSemantics: ResourceTelemetryIoSemantics,
540 sampleCount: NonNegativeInt,
541});
542export type ResourceTelemetryProcessSummary = typeof ResourceTelemetryProcessSummary.Type;
543​
544export const ResourceTelemetryHistory = Schema.Struct({
545 readAt: Schema.DateTimeUtc,
546 windowMs: NonNegativeInt,
547 bucketMs: NonNegativeInt,
548 sampleIntervalMs: NonNegativeInt,
549 retainedSampleCount: NonNegativeInt,
550 buckets: Schema.Array(ResourceTelemetryHistoryBucket),
551 topProcesses: Schema.Array(ResourceTelemetryProcessSummary),
552 health: ResourceTelemetryHealth,
553});
554export type ResourceTelemetryHistory = typeof ResourceTelemetryHistory.Type;
555​
556export const ResourceTelemetryRetryResult = Schema.Struct({
557 accepted: Schema.Boolean,
558 snapshot: ResourceTelemetrySnapshot,
559});
560export type ResourceTelemetryRetryResult = typeof ResourceTelemetryRetryResult.Type;