@ycodium-ai/plugin-resource-telemetry 0.2.2988 → 0.2.2992
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +56 -50
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -4,10 +4,8 @@ import {
|
|
|
4
4
|
definePlugin
|
|
5
5
|
} from "@ycodium-ai/plugin-api";
|
|
6
6
|
|
|
7
|
-
// src/
|
|
7
|
+
// src/monitorProtocol.ts
|
|
8
8
|
var RESOURCE_MONITOR_PROTOCOL_VERSION = 2;
|
|
9
|
-
var MAX_DELTA_INTERVAL_MS = 3e4;
|
|
10
|
-
var MAX_HISTORY_WINDOW_MS = 60 * 6e4;
|
|
11
9
|
var isRecord = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
12
10
|
var finite = (value) => typeof value === "number" && Number.isFinite(value) ? value : null;
|
|
13
11
|
var nonNegativeInt = (value) => {
|
|
@@ -147,6 +145,10 @@ var parseMonitorEvent = (value) => {
|
|
|
147
145
|
return null;
|
|
148
146
|
}
|
|
149
147
|
};
|
|
148
|
+
|
|
149
|
+
// src/telemetryProjection.ts
|
|
150
|
+
var MAX_DELTA_INTERVAL_MS = 3e4;
|
|
151
|
+
var MAX_HISTORY_WINDOW_MS = 60 * 6e4;
|
|
150
152
|
var emptyGroupCounters = () => ({
|
|
151
153
|
cpuTimeMs: 0,
|
|
152
154
|
ioReadBytes: 0,
|
|
@@ -492,6 +494,8 @@ var buildHistory = (input) => {
|
|
|
492
494
|
|
|
493
495
|
// src/sidecar.ts
|
|
494
496
|
import * as NodeCrypto from "node:crypto";
|
|
497
|
+
|
|
498
|
+
// src/sidecarSupport.ts
|
|
495
499
|
var SAMPLE_INTERVAL_MS = 1e3;
|
|
496
500
|
var BACKGROUND_SAMPLE_INTERVAL_MS = 5e3;
|
|
497
501
|
var BATTERY_SAMPLE_INTERVAL_MS = 5e3;
|
|
@@ -514,6 +518,55 @@ var resolveSampleIntervalMs = (power, liveSubscriberCount) => {
|
|
|
514
518
|
};
|
|
515
519
|
var restartDelayMs = (attempt) => Math.min(INITIAL_RESTART_DELAY_MS * 2 ** attempt, MAX_RESTART_DELAY_MS);
|
|
516
520
|
var toError = (value) => value instanceof Error ? value : new Error(String(value));
|
|
521
|
+
var raceHandshake = (hello, ended, timeoutMs) => {
|
|
522
|
+
let timer;
|
|
523
|
+
return Promise.race([
|
|
524
|
+
hello,
|
|
525
|
+
ended.then(() => null),
|
|
526
|
+
new Promise((resolve) => {
|
|
527
|
+
timer = setTimeout(() => resolve(null), timeoutMs);
|
|
528
|
+
})
|
|
529
|
+
]).finally(() => {
|
|
530
|
+
if (timer !== void 0) clearTimeout(timer);
|
|
531
|
+
});
|
|
532
|
+
};
|
|
533
|
+
var withTimeout = (promise, timeoutMs, operation) => {
|
|
534
|
+
let timer;
|
|
535
|
+
return Promise.race([
|
|
536
|
+
promise,
|
|
537
|
+
new Promise((_, reject) => {
|
|
538
|
+
timer = setTimeout(() => {
|
|
539
|
+
reject(
|
|
540
|
+
new Error(
|
|
541
|
+
`the resource monitor '${operation}' request timed out after ${String(timeoutMs)}ms`
|
|
542
|
+
)
|
|
543
|
+
);
|
|
544
|
+
}, timeoutMs);
|
|
545
|
+
})
|
|
546
|
+
]).finally(() => {
|
|
547
|
+
if (timer !== void 0) clearTimeout(timer);
|
|
548
|
+
});
|
|
549
|
+
};
|
|
550
|
+
var pumpLines = async (source, onLine) => {
|
|
551
|
+
const decoder = new TextDecoder();
|
|
552
|
+
let buffer = "";
|
|
553
|
+
for await (const chunk of source) {
|
|
554
|
+
buffer += decoder.decode(chunk, { stream: true });
|
|
555
|
+
let index = buffer.indexOf("\n");
|
|
556
|
+
while (index >= 0) {
|
|
557
|
+
onLine(buffer.slice(0, index));
|
|
558
|
+
buffer = buffer.slice(index + 1);
|
|
559
|
+
index = buffer.indexOf("\n");
|
|
560
|
+
}
|
|
561
|
+
}
|
|
562
|
+
onLine(buffer);
|
|
563
|
+
};
|
|
564
|
+
var pumpChunks = async (source, onText) => {
|
|
565
|
+
const decoder = new TextDecoder();
|
|
566
|
+
for await (const chunk of source) onText(decoder.decode(chunk, { stream: true }));
|
|
567
|
+
};
|
|
568
|
+
|
|
569
|
+
// src/sidecar.ts
|
|
517
570
|
var TelemetrySidecar = class {
|
|
518
571
|
input;
|
|
519
572
|
state = {
|
|
@@ -981,53 +1034,6 @@ var TelemetrySidecar = class {
|
|
|
981
1034
|
}
|
|
982
1035
|
}
|
|
983
1036
|
};
|
|
984
|
-
var raceHandshake = (hello, ended, timeoutMs) => {
|
|
985
|
-
let timer;
|
|
986
|
-
return Promise.race([
|
|
987
|
-
hello,
|
|
988
|
-
ended.then(() => null),
|
|
989
|
-
new Promise((resolve) => {
|
|
990
|
-
timer = setTimeout(() => resolve(null), timeoutMs);
|
|
991
|
-
})
|
|
992
|
-
]).finally(() => {
|
|
993
|
-
if (timer !== void 0) clearTimeout(timer);
|
|
994
|
-
});
|
|
995
|
-
};
|
|
996
|
-
var withTimeout = (promise, timeoutMs, operation) => {
|
|
997
|
-
let timer;
|
|
998
|
-
return Promise.race([
|
|
999
|
-
promise,
|
|
1000
|
-
new Promise((_, reject) => {
|
|
1001
|
-
timer = setTimeout(() => {
|
|
1002
|
-
reject(
|
|
1003
|
-
new Error(
|
|
1004
|
-
`the resource monitor '${operation}' request timed out after ${String(timeoutMs)}ms`
|
|
1005
|
-
)
|
|
1006
|
-
);
|
|
1007
|
-
}, timeoutMs);
|
|
1008
|
-
})
|
|
1009
|
-
]).finally(() => {
|
|
1010
|
-
if (timer !== void 0) clearTimeout(timer);
|
|
1011
|
-
});
|
|
1012
|
-
};
|
|
1013
|
-
var pumpLines = async (source, onLine) => {
|
|
1014
|
-
const decoder = new TextDecoder();
|
|
1015
|
-
let buffer = "";
|
|
1016
|
-
for await (const chunk of source) {
|
|
1017
|
-
buffer += decoder.decode(chunk, { stream: true });
|
|
1018
|
-
let index = buffer.indexOf("\n");
|
|
1019
|
-
while (index >= 0) {
|
|
1020
|
-
onLine(buffer.slice(0, index));
|
|
1021
|
-
buffer = buffer.slice(index + 1);
|
|
1022
|
-
index = buffer.indexOf("\n");
|
|
1023
|
-
}
|
|
1024
|
-
}
|
|
1025
|
-
onLine(buffer);
|
|
1026
|
-
};
|
|
1027
|
-
var pumpChunks = async (source, onText) => {
|
|
1028
|
-
const decoder = new TextDecoder();
|
|
1029
|
-
for await (const chunk of source) onText(decoder.decode(chunk, { stream: true }));
|
|
1030
|
-
};
|
|
1031
1037
|
|
|
1032
1038
|
// src/index.ts
|
|
1033
1039
|
var unknownPower = (readAtIso) => ({
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ycodium-ai/plugin-resource-telemetry",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.2992",
|
|
4
4
|
"description": "Measures what this machine's processes cost in CPU, memory and disk.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"telemetry",
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
"effect": "4.0.0-beta.103",
|
|
21
21
|
"esbuild": "0.28.1",
|
|
22
22
|
"vite-plus": "0.2.2",
|
|
23
|
-
"@ycodium-ai/plugin-api": "0.2.
|
|
23
|
+
"@ycodium-ai/plugin-api": "0.2.2992"
|
|
24
24
|
},
|
|
25
25
|
"ycodium": {
|
|
26
26
|
"plugin": "./dist/index.js",
|