@camstack/types 1.2.115 → 1.2.117
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/addon.js +4 -3
- package/dist/addon.mjs +4 -3
- package/dist/capabilities/data-store-provider.cap.d.ts +11 -0
- package/dist/capabilities/index.d.ts +6 -3
- package/dist/capabilities/load-contribution.cap.d.ts +146 -0
- package/dist/capabilities/metrics-provider.cap.d.ts +156 -38
- package/dist/capabilities/settings-store.cap.d.ts +48 -1
- package/dist/capabilities/system.cap.d.ts +67 -1
- package/dist/enums/event-category.d.ts +1 -1
- package/dist/enums.js +1 -1
- package/dist/enums.mjs +1 -1
- package/dist/{event-category-CIa_iT6b.mjs → event-category-BZL-fdNj.mjs} +1 -1
- package/dist/{event-category-EY0GNjV9.js → event-category-BaEgqJNv.js} +1 -1
- package/dist/generated/addon-api.d.ts +40 -3
- package/dist/generated/capability-router-map.d.ts +5 -2
- package/dist/generated/collection-array-methods.d.ts +1 -1
- package/dist/generated/method-access-map.d.ts +1 -1
- package/dist/generated/system-proxy.d.ts +3 -3
- package/dist/index.d.ts +2 -0
- package/dist/index.js +585 -36
- package/dist/index.mjs +575 -37
- package/dist/interfaces/addon.d.ts +28 -0
- package/dist/interfaces/event-bus.d.ts +1 -1
- package/dist/interfaces/metrics-provider.d.ts +5 -3
- package/dist/metrics/load-series-fold.d.ts +142 -0
- package/dist/node.d.ts +2 -0
- package/dist/node.js +191 -0
- package/dist/node.mjs +186 -1
- package/dist/process/child-cost-registry.d.ts +105 -0
- package/dist/{sleep-CSodb2vQ.js → sleep-9d8tJRbO.js} +1 -1
- package/dist/{sleep-CdbM8ge4.mjs → sleep-Dolp38qx.mjs} +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import type { LoadContribution, LoadContributionAttribution, LoadContributionRole } from '../capabilities/load-contribution.cap.js';
|
|
2
|
+
/** What a spawn site knows about the child it just started. */
|
|
3
|
+
export interface ChildCostClaimInput {
|
|
4
|
+
readonly role: LoadContributionRole;
|
|
5
|
+
/**
|
|
6
|
+
* The NUMERIC device id, or `null` when this child genuinely serves no
|
|
7
|
+
* single camera. A spawn site that cannot name its camera should not claim
|
|
8
|
+
* at all: an unnamed per-camera claim is indistinguishable from a shared one
|
|
9
|
+
* and would turn one camera's cost into everybody's.
|
|
10
|
+
*/
|
|
11
|
+
readonly deviceId: number | null;
|
|
12
|
+
/** What this one child is, in the contributor's own words: `615/high`. */
|
|
13
|
+
readonly unit: string;
|
|
14
|
+
/**
|
|
15
|
+
* Defaults to `measured` — the ordinary case for a child that serves exactly
|
|
16
|
+
* one camera. Set it explicitly for a shared resource that reports itself as
|
|
17
|
+
* unattributable.
|
|
18
|
+
*/
|
|
19
|
+
readonly attribution?: LoadContributionAttribution;
|
|
20
|
+
/**
|
|
21
|
+
* The child's pid. `undefined` is accepted and the claim is then INERT: the
|
|
22
|
+
* cost cannot be measured and the entry would be a role and a camera with no
|
|
23
|
+
* numbers, which the unattributed bucket already covers more honestly.
|
|
24
|
+
*/
|
|
25
|
+
readonly pid: number | undefined;
|
|
26
|
+
}
|
|
27
|
+
/** The only way to remove a claim. See the module docblock. */
|
|
28
|
+
export interface ChildCostClaimHandle {
|
|
29
|
+
/** Idempotent: releasing twice, or after the registry was cleared, is safe. */
|
|
30
|
+
readonly release: () => void;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* The handle a spawn site gets when nobody is collecting — a test harness, or
|
|
34
|
+
* a runner built before its addon registered a registry. Reporting nothing is
|
|
35
|
+
* the correct behaviour: the process still appears in the node's process
|
|
36
|
+
* snapshot, unclaimed, which is exactly what "nobody reported this" should
|
|
37
|
+
* look like.
|
|
38
|
+
*/
|
|
39
|
+
export declare const NO_COST_CLAIM: ChildCostClaimHandle;
|
|
40
|
+
/** Injectable procfs surface — the whole reason this module is testable. */
|
|
41
|
+
export interface ProcStatReader {
|
|
42
|
+
/** `/proc/<pid>/stat` */
|
|
43
|
+
readonly readStat: (pid: number) => Promise<string>;
|
|
44
|
+
/** `/proc/<pid>/statm` */
|
|
45
|
+
readonly readStatm: (pid: number) => Promise<string>;
|
|
46
|
+
}
|
|
47
|
+
export declare const nodeProcStatReader: ProcStatReader;
|
|
48
|
+
/**
|
|
49
|
+
* Cumulative CPU seconds from a `/proc/<pid>/stat` line.
|
|
50
|
+
*
|
|
51
|
+
* The `comm` field is field 2, wrapped in parentheses, and can itself contain
|
|
52
|
+
* spaces and parentheses — so the only correct parse cuts at the LAST `)` and
|
|
53
|
+
* indexes from there. After the cut, field 3 (`state`) is index 0, so `utime`
|
|
54
|
+
* (field 14) is index 11 and `stime` (field 15) is index 12.
|
|
55
|
+
*
|
|
56
|
+
* `null` for a line that does not parse: a process that exited between the
|
|
57
|
+
* claim and the read leaves a truncated or empty file, and that is normal.
|
|
58
|
+
*/
|
|
59
|
+
export declare function parseProcCpuSeconds(line: string): number | null;
|
|
60
|
+
/**
|
|
61
|
+
* Resident bytes from a `/proc/<pid>/statm` line — field 2 is the resident set
|
|
62
|
+
* in pages. `null` when the line does not parse.
|
|
63
|
+
*/
|
|
64
|
+
export declare function parseProcRssBytes(line: string): number | null;
|
|
65
|
+
/**
|
|
66
|
+
* What the OS will say about one process right now: cumulative CPU seconds and
|
|
67
|
+
* resident bytes, each ABSENT when it cannot be read.
|
|
68
|
+
*
|
|
69
|
+
* Exported because not every cost has a spawn site inside a registry. The
|
|
70
|
+
* shared inference pool is the case that forced it: its process is created
|
|
71
|
+
* deep inside the engine factory and belongs to no camera, so it is reported
|
|
72
|
+
* as an `unattributable` contribution built from the live pool's pids rather
|
|
73
|
+
* than from a claim — but its numbers must be read the same way, by the same
|
|
74
|
+
* parsers, or two "CPU seconds" in one payload would mean two things.
|
|
75
|
+
*/
|
|
76
|
+
export declare function readProcessCost(pid: number, reader?: ProcStatReader): Promise<{
|
|
77
|
+
readonly cpuSeconds?: number;
|
|
78
|
+
readonly rssBytes?: number;
|
|
79
|
+
}>;
|
|
80
|
+
export declare class ChildCostRegistry {
|
|
81
|
+
private readonly reader;
|
|
82
|
+
private readonly now;
|
|
83
|
+
private claims;
|
|
84
|
+
constructor(reader?: ProcStatReader, now?: () => number);
|
|
85
|
+
/**
|
|
86
|
+
* Record one child. The returned handle is the only way to remove it.
|
|
87
|
+
*
|
|
88
|
+
* A claim with no pid is dropped rather than stored: it could carry no
|
|
89
|
+
* measurement, and an entry with a camera and no numbers reads on a chart as
|
|
90
|
+
* a camera that cost nothing.
|
|
91
|
+
*/
|
|
92
|
+
claim(input: ChildCostClaimInput): ChildCostClaimHandle;
|
|
93
|
+
/** Live claims, in claim order. Diagnostics and tests; not a contribution. */
|
|
94
|
+
list(): readonly ChildCostClaimInput[];
|
|
95
|
+
/**
|
|
96
|
+
* This addon's contribution: one entry per live claim, with whatever the OS
|
|
97
|
+
* will tell us about that child right now.
|
|
98
|
+
*
|
|
99
|
+
* A child that has exited between the claim and this read contributes an
|
|
100
|
+
* entry with no numbers rather than no entry — the unit exists, the addon
|
|
101
|
+
* believes it is running, and hiding it would make a dying writer look like
|
|
102
|
+
* a writer that was never started.
|
|
103
|
+
*/
|
|
104
|
+
contributions(): Promise<readonly LoadContribution[]>;
|
|
105
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const require_event_category = require("./event-category-
|
|
1
|
+
const require_event_category = require("./event-category-BaEgqJNv.js");
|
|
2
2
|
let zod = require("zod");
|
|
3
3
|
//#region src/interfaces/config-ui.ts
|
|
4
4
|
/** Predefined tabs with standard label, icon, and sort order.
|