@camstack/system 1.2.145 → 1.2.147

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.
Files changed (65) hide show
  1. package/dist/addon-runner.js +2 -1
  2. package/dist/addon-runner.mjs +2 -1
  3. package/dist/builtins/addon-pages-aggregator/addon-pages-aggregator.addon.js +1 -1
  4. package/dist/builtins/addon-pages-aggregator/addon-pages-aggregator.addon.mjs +1 -1
  5. package/dist/builtins/addon-widgets-aggregator/addon-widgets-aggregator.addon.js +1 -1
  6. package/dist/builtins/addon-widgets-aggregator/addon-widgets-aggregator.addon.mjs +1 -1
  7. package/dist/builtins/alerts/alerts.addon.js +1 -1
  8. package/dist/builtins/alerts/alerts.addon.mjs +1 -1
  9. package/dist/builtins/backup-orchestrator/backup-orchestrator.addon.js +1 -1
  10. package/dist/builtins/backup-orchestrator/backup-orchestrator.addon.mjs +1 -1
  11. package/dist/builtins/console-logging/index.js +1 -1
  12. package/dist/builtins/console-logging/index.mjs +1 -1
  13. package/dist/builtins/core-blocks/core-blocks.addon.js +1 -1
  14. package/dist/builtins/core-blocks/core-blocks.addon.mjs +1 -1
  15. package/dist/builtins/device-manager/device-manager.addon.js +2 -2
  16. package/dist/builtins/device-manager/device-manager.addon.mjs +2 -2
  17. package/dist/builtins/doorbell/virtual-doorbell.addon.js +1 -1
  18. package/dist/builtins/doorbell/virtual-doorbell.addon.mjs +1 -1
  19. package/dist/builtins/hub-forwarder/index.js +1 -1
  20. package/dist/builtins/hub-forwarder/index.mjs +1 -1
  21. package/dist/builtins/liveness-monitor/liveness-monitor.addon.js +1 -1
  22. package/dist/builtins/liveness-monitor/liveness-monitor.addon.mjs +1 -1
  23. package/dist/builtins/local-auth/local-auth.addon.js +1 -1
  24. package/dist/builtins/local-auth/local-auth.addon.mjs +1 -1
  25. package/dist/builtins/local-network/local-network.addon.js +1 -1
  26. package/dist/builtins/local-network/local-network.addon.mjs +1 -1
  27. package/dist/builtins/loki-logging/index.js +1 -1
  28. package/dist/builtins/loki-logging/index.mjs +1 -1
  29. package/dist/builtins/native-metrics/load-series-config.d.ts +74 -0
  30. package/dist/builtins/native-metrics/load-series-reader.d.ts +37 -0
  31. package/dist/builtins/native-metrics/load-series-store.d.ts +232 -0
  32. package/dist/builtins/native-metrics/native-metrics.addon.d.ts +118 -35
  33. package/dist/builtins/native-metrics/native-metrics.addon.js +1463 -199
  34. package/dist/builtins/native-metrics/native-metrics.addon.mjs +1463 -199
  35. package/dist/builtins/native-metrics/node-load-ring.d.ts +214 -0
  36. package/dist/builtins/native-metrics/process-classification.d.ts +51 -0
  37. package/dist/builtins/native-metrics/thread-cpu-sampler.d.ts +116 -0
  38. package/dist/builtins/platform-probe/index.js +1 -1
  39. package/dist/builtins/platform-probe/index.mjs +1 -1
  40. package/dist/builtins/remote-access-orchestrator/remote-access-orchestrator.addon.js +1 -1
  41. package/dist/builtins/remote-access-orchestrator/remote-access-orchestrator.addon.mjs +1 -1
  42. package/dist/builtins/snapshot/index.js +1 -1
  43. package/dist/builtins/snapshot/index.mjs +1 -1
  44. package/dist/builtins/sqlite-storage/filesystem-storage.addon.js +1 -1
  45. package/dist/builtins/sqlite-storage/filesystem-storage.addon.mjs +1 -1
  46. package/dist/builtins/sqlite-storage/sqlite-settings-backend.d.ts +25 -1
  47. package/dist/builtins/sqlite-storage/sqlite-settings.addon.js +0 -0
  48. package/dist/builtins/sqlite-storage/sqlite-settings.addon.mjs +0 -0
  49. package/dist/builtins/storage-orchestrator/storage-orchestrator.addon.js +2 -1
  50. package/dist/builtins/storage-orchestrator/storage-orchestrator.addon.mjs +2 -1
  51. package/dist/builtins/system-config/system-config.addon.js +1 -1
  52. package/dist/builtins/system-config/system-config.addon.mjs +1 -1
  53. package/dist/builtins/winston-logging/index.js +1 -1
  54. package/dist/builtins/winston-logging/index.mjs +1 -1
  55. package/dist/{dist-BVU5JADq.js → dist-Dl6MFXPr.js} +496 -35
  56. package/dist/{dist-CG7kwIZp.mjs → dist-DrBc-7Y3.mjs} +479 -36
  57. package/dist/index.d.ts +2 -2
  58. package/dist/index.js +45 -5
  59. package/dist/index.mjs +37 -6
  60. package/dist/kernel/heap-watch.d.ts +209 -1
  61. package/dist/{manifest-python-deps-BRyNCnnG.mjs → manifest-python-deps-DhT0oFOZ.mjs} +200 -8
  62. package/dist/{manifest-python-deps-GjlyPjm0.js → manifest-python-deps-FYZBHc3v.js} +253 -7
  63. package/dist/{retired-settings-keys-_PLI9w0k.js → retired-settings-keys-6w_JOqBg.js} +1 -1
  64. package/dist/{retired-settings-keys-Dm1z4mO4.mjs → retired-settings-keys-CF5r4YKq.mjs} +1 -1
  65. package/package.json +1 -1
@@ -1,5 +1,5 @@
1
1
  import { z } from "zod";
2
- //#region ../types/dist/event-category-CIa_iT6b.mjs
2
+ //#region ../types/dist/event-category-BZL-fdNj.mjs
3
3
  var EventCategory = /* @__PURE__ */ function(EventCategory) {
4
4
  EventCategory["SystemBoot"] = "system.boot";
5
5
  EventCategory["SystemAddonsReady"] = "system.addons-ready";
@@ -436,7 +436,7 @@ var EventCategory = /* @__PURE__ */ function(EventCategory) {
436
436
  EventCategory["MetricsNodeResourcesSnapshot"] = "metrics.node-resources-snapshot";
437
437
  /**
438
438
  * Periodic per-node process-tree snapshot (camstack-related pids
439
- * with ghost / managed / root classification). Emitted ~0.2 Hz by
439
+ * with root / managed / system classification). Emitted ~0.2 Hz by
440
440
  * the metrics-provider addon. Drives the Cluster → Processes tab
441
441
  * without polling `metricsProvider.listNodeProcesses`.
442
442
  */
@@ -4340,6 +4340,143 @@ var DecoderSessionConfigSchema = z.object({
4340
4340
  */
4341
4341
  debug: z.boolean().optional()
4342
4342
  });
4343
+ /** Bucket key for rows no addon owns. Stable, so its series is continuous. */
4344
+ var UNATTRIBUTED_BUCKET_KEY = "__unattributed__";
4345
+ var ROOT_BUCKET_KEY = "__root__";
4346
+ function bucketFor(row) {
4347
+ if (row.addonId !== null) return {
4348
+ key: row.addonId,
4349
+ kind: "addon"
4350
+ };
4351
+ if (row.classification === "root") return {
4352
+ key: ROOT_BUCKET_KEY,
4353
+ kind: "root"
4354
+ };
4355
+ return {
4356
+ key: UNATTRIBUTED_BUCKET_KEY,
4357
+ kind: "unattributed"
4358
+ };
4359
+ }
4360
+ /** Round to one decimal — the precision both producers already emit at. */
4361
+ function deci(value) {
4362
+ return Math.round(value * 10) / 10;
4363
+ }
4364
+ /**
4365
+ * Fold one snapshot into one point per function.
4366
+ *
4367
+ * Produces a ONE-SAMPLE point: `min === max` on every field, `samples === 1`.
4368
+ * That is what lets a live event and a reduced server bucket sit in the same
4369
+ * series without the consumer knowing which is which.
4370
+ */
4371
+ function foldSnapshotByFunction(rows, atMs) {
4372
+ const acc = /* @__PURE__ */ new Map();
4373
+ for (const row of rows) {
4374
+ const { key, kind } = bucketFor(row);
4375
+ const cur = acc.get(key) ?? {
4376
+ kind,
4377
+ main: 0,
4378
+ gc: 0,
4379
+ lifetime: 0,
4380
+ memory: 0,
4381
+ count: 0,
4382
+ splitKnown: true
4383
+ };
4384
+ const known = row.cpuMainPercent !== null && row.cpuGcPercent !== null;
4385
+ acc.set(key, {
4386
+ kind: cur.kind,
4387
+ main: cur.main + (row.cpuMainPercent ?? 0),
4388
+ gc: cur.gc + (row.cpuGcPercent ?? 0),
4389
+ lifetime: cur.lifetime + row.cpuPercent,
4390
+ memory: cur.memory + row.memoryRssBytes,
4391
+ count: cur.count + 1,
4392
+ splitKnown: cur.splitKnown && known
4393
+ });
4394
+ }
4395
+ return [...acc.entries()].map(([key, a]) => {
4396
+ const main = a.splitKnown ? deci(a.main) : null;
4397
+ const gc = a.splitKnown ? deci(a.gc) : null;
4398
+ const lifetime = deci(a.lifetime);
4399
+ return {
4400
+ key,
4401
+ kind: a.kind,
4402
+ point: {
4403
+ atMs,
4404
+ samples: 1,
4405
+ cpuMainPercent: main,
4406
+ cpuMainPercentMin: main,
4407
+ cpuGcPercent: gc,
4408
+ cpuGcPercentMin: gc,
4409
+ cpuLifetimePercent: lifetime,
4410
+ cpuLifetimePercentMin: lifetime,
4411
+ memoryRssBytes: a.memory,
4412
+ memoryRssBytesMin: a.memory,
4413
+ processCount: a.count,
4414
+ processCountMin: a.count
4415
+ }
4416
+ };
4417
+ });
4418
+ }
4419
+ /** The narrower of two bounds, treating `null` (UNKNOWN) as absorbing. */
4420
+ function minNullable(a, b) {
4421
+ if (a === null || b === null) return null;
4422
+ return a < b ? a : b;
4423
+ }
4424
+ function maxNullable(a, b) {
4425
+ if (a === null || b === null) return null;
4426
+ return a > b ? a : b;
4427
+ }
4428
+ /** Merge `next` into `held`, keeping the widest [min, max] of each field. */
4429
+ function mergePoints(held, next, atMs) {
4430
+ return {
4431
+ atMs,
4432
+ samples: held.samples + next.samples,
4433
+ cpuMainPercent: maxNullable(held.cpuMainPercent, next.cpuMainPercent),
4434
+ cpuMainPercentMin: minNullable(held.cpuMainPercentMin, next.cpuMainPercentMin),
4435
+ cpuGcPercent: maxNullable(held.cpuGcPercent, next.cpuGcPercent),
4436
+ cpuGcPercentMin: minNullable(held.cpuGcPercentMin, next.cpuGcPercentMin),
4437
+ cpuLifetimePercent: Math.max(held.cpuLifetimePercent, next.cpuLifetimePercent),
4438
+ cpuLifetimePercentMin: Math.min(held.cpuLifetimePercentMin, next.cpuLifetimePercentMin),
4439
+ memoryRssBytes: Math.max(held.memoryRssBytes, next.memoryRssBytes),
4440
+ memoryRssBytesMin: Math.min(held.memoryRssBytesMin, next.memoryRssBytesMin),
4441
+ processCount: Math.max(held.processCount, next.processCount),
4442
+ processCountMin: Math.min(held.processCountMin, next.processCountMin)
4443
+ };
4444
+ }
4445
+ /**
4446
+ * The bucket width that brings `spanMs` down to at most `maxPoints` points,
4447
+ * snapped up to a whole multiple of the sampling cadence.
4448
+ *
4449
+ * Returns `cadenceMs` (no reduction) when the span already fits. A caller that
4450
+ * asks for a `maxPoints` of 0 or less gets no reduction rather than an
4451
+ * infinite bucket — a nonsensical request must not produce a plausible chart.
4452
+ */
4453
+ function resolveBucketMs(spanMs, cadenceMs, maxPoints) {
4454
+ if (maxPoints <= 0 || cadenceMs <= 0 || spanMs <= 0) return Math.max(cadenceMs, 1);
4455
+ const wanted = spanMs / maxPoints;
4456
+ if (wanted <= cadenceMs) return cadenceMs;
4457
+ return Math.ceil(wanted / cadenceMs) * cadenceMs;
4458
+ }
4459
+ /**
4460
+ * Reduce one function's points into buckets of `bucketMs`, preserving the
4461
+ * extremes.
4462
+ *
4463
+ * Points are expected oldest-first and are returned oldest-first. A bucket
4464
+ * with no samples is ABSENT — not zero, not interpolated, not the previous
4465
+ * value held over.
4466
+ */
4467
+ function reducePoints(points, bucketMs, origin) {
4468
+ if (bucketMs <= 0 || points.length === 0) return points;
4469
+ const buckets = /* @__PURE__ */ new Map();
4470
+ for (const point of points) {
4471
+ const start = origin + Math.floor((point.atMs - origin) / bucketMs) * bucketMs;
4472
+ const held = buckets.get(start);
4473
+ buckets.set(start, held === void 0 ? {
4474
+ ...point,
4475
+ atMs: start
4476
+ } : mergePoints(held, point, start));
4477
+ }
4478
+ return [...buckets.values()].toSorted((a, b) => a.atMs - b.atMs);
4479
+ }
4343
4480
  var MODEL_FORMATS = [
4344
4481
  "onnx",
4345
4482
  "coreml",
@@ -8274,6 +8411,19 @@ var SettingsRecordSchema = z.object({
8274
8411
  data: z.record(z.string(), z.unknown())
8275
8412
  });
8276
8413
  /**
8414
+ * One record of a BULK insert — {@link SettingsRecordSchema} with the id made
8415
+ * optional.
8416
+ *
8417
+ * A separate schema rather than loosening the shared one: every other method
8418
+ * on this cap addresses a row BY its id, and making that field optional
8419
+ * everywhere would turn a forgotten key into a silently generated one on
8420
+ * `update` and `delete` as well.
8421
+ */
8422
+ var BulkRecordSchema = z.object({
8423
+ id: z.string().optional(),
8424
+ data: z.record(z.string(), z.unknown())
8425
+ });
8426
+ /**
8277
8427
  * Column declaration for a structured (SQL-backed) collection.
8278
8428
  *
8279
8429
  * Logical types — the backend translates each to the matching SQLite
@@ -8386,6 +8536,34 @@ var settingsStoreCapability = {
8386
8536
  collection: z.string(),
8387
8537
  record: SettingsRecordSchema
8388
8538
  }), z.void(), { kind: "mutation" }),
8539
+ /**
8540
+ * Insert MANY records in ONE transaction, returning how many landed.
8541
+ *
8542
+ * The write-side twin of {@link deleteWhere}, and it exists for the same
8543
+ * reason: without it, appending a batch is N round trips and N COMMITs on
8544
+ * the single shared connection that also serves every cluster-wide
8545
+ * configuration read. The durable load series writes one process row per
8546
+ * process per sample — 76 rows every 10 s on the live fleet — and the
8547
+ * operator's rule for it is *one transaction per sample, never one per
8548
+ * row*. `insert` cannot express that; nothing else could.
8549
+ *
8550
+ * **All or nothing.** A batch that fails on its fifth row leaves none of
8551
+ * the five behind. A half-written sample is worse than a missing one: the
8552
+ * missing one reads as "nobody reported", which is true, while the half
8553
+ * one reads as "these were the only processes running", which is not.
8554
+ *
8555
+ * `id` is OPTIONAL per record, and that is the difference from
8556
+ * {@link insert}. A collection whose primary key is an `INTEGER` rowid
8557
+ * alias has no id to supply — SQLite assigns it, for free, and inventing a
8558
+ * `randomUUID()` for such a column would write a 36-character string into
8559
+ * an integer key. Omitted on a TEXT key, a uuid is generated exactly as
8560
+ * `insert` does.
8561
+ */
8562
+ insertMany: method(z.object({
8563
+ namespace: z.string().optional(),
8564
+ collection: z.string(),
8565
+ records: z.array(BulkRecordSchema).readonly()
8566
+ }), z.object({ inserted: z.number().int() }), { kind: "mutation" }),
8389
8567
  /** Update an existing record by ID. */
8390
8568
  update: method(z.object({
8391
8569
  namespace: z.string().optional(),
@@ -8623,6 +8801,15 @@ var dataStoreProviderCapability = {
8623
8801
  kind: "mutation",
8624
8802
  auth: "admin"
8625
8803
  }),
8804
+ /** Insert many records in ONE transaction. All or nothing. */
8805
+ insertMany: method(z.object({
8806
+ namespace: z.string().optional(),
8807
+ collection: z.string(),
8808
+ records: z.array(BulkRecordSchema).readonly()
8809
+ }), z.object({ inserted: z.number().int() }), {
8810
+ kind: "mutation",
8811
+ auth: "admin"
8812
+ }),
8626
8813
  /** Update an existing record by ID. */
8627
8814
  update: method(z.object({
8628
8815
  namespace: z.string().optional(),
@@ -11298,6 +11485,82 @@ var logDestinationCapability = {
11298
11485
  /** BIG PLAN 2: declarative mount hint — read by `@camstack/system` `buildCapRouters`. */
11299
11486
  mount: { kind: "skip" }
11300
11487
  };
11488
+ var LoadContributionSchema = z.object({
11489
+ role: z.enum([
11490
+ "decode",
11491
+ "transcode",
11492
+ "recording",
11493
+ "streaming",
11494
+ "detection"
11495
+ ]),
11496
+ /**
11497
+ * The NUMERIC device id — the same value every log line carries as
11498
+ * `tags.deviceId`. `null` means this cost genuinely belongs to no single
11499
+ * camera (a shared pool), NOT that the contributor forgot to look it up: a
11500
+ * contributor that cannot name its camera must not emit the entry at all,
11501
+ * because an unnamed per-camera entry is indistinguishable from a shared one
11502
+ * and would quietly turn one camera's cost into everybody's.
11503
+ */
11504
+ deviceId: z.number().int().positive().nullable(),
11505
+ attribution: z.enum([
11506
+ "measured",
11507
+ "accounted",
11508
+ "unattributable"
11509
+ ]),
11510
+ /**
11511
+ * What ONE entry is, in the contributor's own words — `615/high`,
11512
+ * `617/native`, `cuda:0 shared pool`. Free text because the unit differs per
11513
+ * family and inventing a common one would lose the only information that
11514
+ * makes two entries for the same camera distinguishable.
11515
+ */
11516
+ unit: z.string(),
11517
+ /**
11518
+ * The OS process this cost lives in, when there is one. Present so a
11519
+ * consumer can (a) tell two generations of the same unit apart across a
11520
+ * restart, and (b) subtract claimed processes from the node's process
11521
+ * snapshot to see what NOBODY claimed. Absent for an entry that owns no
11522
+ * process of its own.
11523
+ */
11524
+ pid: z.number().int().positive().optional(),
11525
+ /**
11526
+ * When this generation started. The pid's incarnation marker: a consumer
11527
+ * differencing {@link LoadContributionSchema.shape.cpuSeconds} must drop the
11528
+ * window when this changes, because the counter restarted from zero in a new
11529
+ * process.
11530
+ */
11531
+ startedAtMs: z.number().optional(),
11532
+ /**
11533
+ * CUMULATIVE CPU seconds this unit has consumed since it started — user +
11534
+ * system, read from the child's own `/proc/<pid>/stat` at the moment the
11535
+ * contribution is asked for.
11536
+ *
11537
+ * Cumulative and not a rate on purpose: a rate needs a window, a window
11538
+ * needs a sampler, and a new per-node sampler is the defect half of
11539
+ * `docs/architecture/load-ledger.md` documents. A counter can be differenced
11540
+ * by whoever already keeps a history; a rate cannot be un-averaged.
11541
+ *
11542
+ * Absent — never zero — on a node with no `/proc`, on a read failure, and on
11543
+ * an entry with no process.
11544
+ */
11545
+ cpuSeconds: z.number().optional(),
11546
+ /** Resident bytes of this unit's process, same source and same rules. */
11547
+ rssBytes: z.number().optional()
11548
+ });
11549
+ var loadContributionCapability = {
11550
+ name: "load-contribution",
11551
+ scope: "system",
11552
+ mode: "collection",
11553
+ internal: true,
11554
+ methods: {
11555
+ /**
11556
+ * This addon's own cost entries, computed live from state it already
11557
+ * holds. Inert: no persistence, no sampling, no timer. It is answered on
11558
+ * whatever beat the caller already has.
11559
+ */
11560
+ list: method(z.void(), z.array(LoadContributionSchema).readonly()) },
11561
+ /** In-process only — enumerated through `addons.listCapabilityProviders`. */
11562
+ mount: { kind: "skip" }
11563
+ };
11301
11564
  /**
11302
11565
  * `login-method` — collection cap through which auth addons contribute
11303
11566
  * their pre-auth login surfaces to the login page. This is the SINGLE,
@@ -11529,8 +11792,7 @@ var NodeProcessSchema = z.object({
11529
11792
  classification: z.enum([
11530
11793
  "root",
11531
11794
  "managed",
11532
- "system",
11533
- "ghost"
11795
+ "system"
11534
11796
  ]),
11535
11797
  /** `$process` addon binding when `managed`, else null. */
11536
11798
  addonId: z.string().nullable(),
@@ -11538,22 +11800,39 @@ var NodeProcessSchema = z.object({
11538
11800
  nodeId: z.string().nullable(),
11539
11801
  /** Truncated command line. */
11540
11802
  command: z.string(),
11803
+ /**
11804
+ * `ps pcpu` — CPU averaged over the process's WHOLE LIFETIME, not a rate.
11805
+ * On a runner up for days it barely moves. Fine as a column, useless as a
11806
+ * series: use `cpuMainPercent + cpuGcPercent` for anything time-varying.
11807
+ */
11541
11808
  cpuPercent: z.number(),
11542
11809
  memoryRssBytes: z.number(),
11810
+ /**
11811
+ * Instantaneous CPU% of the process's own threads over the last
11812
+ * process-snapshot window, from a `/proc/<pid>/task/*` tick delta.
11813
+ *
11814
+ * `null` = UNKNOWN, never zero: no previous sample yet (first tick after
11815
+ * boot), the pid was recycled, or this node is not Linux.
11816
+ */
11817
+ cpuMainPercent: z.number().nullable(),
11818
+ /**
11819
+ * Instantaneous CPU% of V8's `V8Worker` platform pool over the same window.
11820
+ *
11821
+ * This is the number that rewrote the 2026-08-27 diagnosis — hub-main 73%,
11822
+ * `stream-broker` 61% (`docs/architecture/load-ledger.md`). A CPU chart that
11823
+ * does not separate it from `cpuMainPercent` shows "busy" where the truth is
11824
+ * "allocating too much".
11825
+ *
11826
+ * Concurrent GC is the dominant tenant of that pool but not the only one
11827
+ * (background compilation runs there too), so it is reported as
11828
+ * "GC / V8 helpers" rather than as pure collection time. `null` has the same
11829
+ * meaning as on `cpuMainPercent`.
11830
+ */
11831
+ cpuGcPercent: z.number().nullable(),
11832
+ /** Threads seen in the tick scan. `null` under the same conditions. */
11833
+ threadCount: z.number().nullable(),
11543
11834
  /** Wall-clock uptime (seconds). Parsed from `ps etime`. */
11544
- uptimeSec: z.number(),
11545
- /** True when ancestor walk reaches `ppid=1` (reparented to init/launchd). */
11546
- orphaned: z.boolean()
11547
- });
11548
- var KillProcessInputSchema = z.object({
11549
- pid: z.number(),
11550
- /** Force = SIGKILL. Default is SIGTERM. */
11551
- force: z.boolean().optional()
11552
- });
11553
- var KillProcessResultSchema = z.object({
11554
- success: z.boolean(),
11555
- reason: z.string().optional(),
11556
- signal: z.enum(["SIGTERM", "SIGKILL"]).optional()
11835
+ uptimeSec: z.number()
11557
11836
  });
11558
11837
  var DumpHeapSnapshotInputSchema = z.object({
11559
11838
  /** The addon whose runner should dump a heap snapshot. */
@@ -11566,6 +11845,104 @@ var DumpHeapSnapshotResultSchema = z.object({
11566
11845
  pid: z.number().optional(),
11567
11846
  reason: z.string().optional()
11568
11847
  });
11848
+ /**
11849
+ * One point of one function's series.
11850
+ *
11851
+ * The unsuffixed fields are the bucket's **MAXIMUM**, and that choice is the
11852
+ * point of the whole surface. The two obvious reductions both lie: a mean per
11853
+ * bucket smears a spike away, and taking every Nth sample skips it outright.
11854
+ * Either would give us a tool built to find peaks that does not show peaks.
11855
+ * `...Min` carries the other end, `samples` says how many raw snapshots folded
11856
+ * into the bucket, and a mean stays derivable where it is wanted.
11857
+ *
11858
+ * An UNREDUCED point is a one-sample bucket: `samples === 1` and each `...Min`
11859
+ * equals its unsuffixed twin. Reduced and unreduced are the same shape, so a
11860
+ * caller cannot tell which it received — which is what "one reader" means.
11861
+ */
11862
+ var LoadPointSchema = z.object({
11863
+ /** Bucket START, or the snapshot's own timestamp when unreduced. */
11864
+ atMs: z.number(),
11865
+ /** Raw snapshots in this bucket. Never 0 — AN EMPTY BUCKET IS ABSENT. */
11866
+ samples: z.number().int(),
11867
+ /**
11868
+ * `null` = UNKNOWN and it PROPAGATES: a bucket is null unless every process
11869
+ * of every snapshot in it reported a thread split. A partial sum is a
11870
+ * smaller number that looks exactly as real as a complete one.
11871
+ */
11872
+ cpuMainPercent: z.number().nullable(),
11873
+ cpuMainPercentMin: z.number().nullable(),
11874
+ cpuGcPercent: z.number().nullable(),
11875
+ cpuGcPercentMin: z.number().nullable(),
11876
+ /** Lifetime-average CPU%, summed. Always known — and never a rate. */
11877
+ cpuLifetimePercent: z.number(),
11878
+ cpuLifetimePercentMin: z.number(),
11879
+ memoryRssBytes: z.number(),
11880
+ memoryRssBytesMin: z.number(),
11881
+ processCount: z.number().int(),
11882
+ processCountMin: z.number().int()
11883
+ });
11884
+ /** One function's series. `key` is an addonId, `__root__` or `__unattributed__`. */
11885
+ var LoadFunctionSeriesSchema = z.object({
11886
+ key: z.string(),
11887
+ kind: z.enum([
11888
+ "addon",
11889
+ "root",
11890
+ "unattributed"
11891
+ ]),
11892
+ /** Oldest-first. A missing interval is MISSING — never zero-filled. */
11893
+ points: z.array(LoadPointSchema).readonly()
11894
+ });
11895
+ var NodeLoadSeriesSchema = z.object({
11896
+ nodeId: z.string(),
11897
+ /** One entry per function seen in the window, heaviest-first. */
11898
+ series: z.array(LoadFunctionSeriesSchema).readonly(),
11899
+ /**
11900
+ * Width of one returned bucket, in ms. Equals the sampling cadence when no
11901
+ * reduction was needed — so a caller can always say what one point covers
11902
+ * without having to know whether it was reduced.
11903
+ */
11904
+ bucketMs: z.number(),
11905
+ /** Raw snapshots that went into this answer, across both tiers. */
11906
+ retainedSamples: z.number(),
11907
+ /** Oldest snapshot represented, or `null` when nothing is retained. */
11908
+ oldestAtMs: z.number().nullable(),
11909
+ /** The fixed sampling cadence in force on the cluster, in ms. */
11910
+ cadenceMs: z.number(),
11911
+ /**
11912
+ * Did the DURABLE tier contribute? `false` means the answer is the hot ring
11913
+ * alone — an agent (which holds no table), or a store that refused.
11914
+ * Reported because "the last hour" and "the last six hours" are different
11915
+ * questions and an operator must not have to guess which was answered.
11916
+ */
11917
+ durable: z.boolean()
11918
+ });
11919
+ var GetLoadSeriesInputSchema = z.object({
11920
+ /**
11921
+ * The node whose series is wanted.
11922
+ *
11923
+ * NOT named `nodeId`: the generated cap router strips a top-level
11924
+ * `nodeId` from every method input and uses it to ROUTE the call to
11925
+ * that node's provider (`generated-cap-routers.ts`). A series target
11926
+ * called `nodeId` would silently become a routing pin and never reach
11927
+ * the provider. The hub holds every node it hears from, so the
11928
+ * ordinary call is unpinned — answered by the hub, for any node.
11929
+ */
11930
+ forNodeId: z.string(),
11931
+ /**
11932
+ * EXCLUSIVE lower bound. A caller passes the newest `atMs` it already
11933
+ * holds and receives only what it is missing, so seeding a live chart
11934
+ * from this method cannot double a point already drawn.
11935
+ */
11936
+ sinceMs: z.number().optional(),
11937
+ /**
11938
+ * Most points the caller wants PER FUNCTION. The window is reduced to fit,
11939
+ * preserving min and max per bucket.
11940
+ *
11941
+ * Absent means NO reduction — legitimate for a short window and a trap for a
11942
+ * long one, which is why a chart passes its own pixel width.
11943
+ */
11944
+ maxPoints: z.number().int().positive().optional()
11945
+ });
11569
11946
  var SystemMetricsSchema = z.object({
11570
11947
  cpuPercent: z.number(),
11571
11948
  memoryPercent: z.number(),
@@ -11611,28 +11988,44 @@ var metricsProviderCapability = {
11611
11988
  getAddonStats: method(z.object({ addonId: z.string() }), PidResourceStatsSchema.nullable()),
11612
11989
  /**
11613
11990
  * Snapshot of every camstack-related process on this node with a
11614
- * ghost/managed/root classification. Powers the Cluster → Agent →
11615
- * Processes tab: cross-references `$process.list` against a `ps` scan
11616
- * so orphaned trees (PPID=1) or unknown children show up as `ghost`
11617
- * and can be killed from the UI.
11991
+ * root/managed/system classification. Powers the Cluster → Agent →
11992
+ * Processes tab: cross-references `$process.list` against a `ps` scan so
11993
+ * per-addon CPU and RSS can be attributed, and so a process the cluster
11994
+ * does not manage is still visible.
11995
+ *
11996
+ * **Read-only, by design.** This cap once carried a `killProcess`
11997
+ * mutation; it was deleted on 2026-08-27. A runner's lifecycle belongs to
11998
+ * `CrashSupervisor` and is driven through `addons.restartAddon` /
11999
+ * `$process.restart` — signalling a raw pid went around the supervisor
12000
+ * (D6), and the one class it was willing to signal turned out to be the
12001
+ * container's own init and the operator's desktop app.
11618
12002
  */
11619
12003
  listNodeProcesses: method(z.void(), z.array(NodeProcessSchema).readonly()),
11620
12004
  /**
11621
- * Send SIGTERM (or SIGKILL when `force`) to a pid inside this node's
11622
- * process tree. The provider refuses pids that aren't in the live
11623
- * `listNodeProcesses()` snapshot callers can't use this endpoint
11624
- * to kill arbitrary system processes.
12005
+ * The retained per-node load series the ONE reader over BOTH tiers.
12006
+ *
12007
+ * The in-memory ring is the HOT window (the last 180 snapshots, held by
12008
+ * every node's `native-metrics`); the hub's `metrics:node-load-samples`
12009
+ * table is the COLD one (the operator's retention, six hours by default).
12010
+ * This method merges them and DEDUPES on `atMs`, so a snapshot present in
12011
+ * both contributes once and the caller never learns which tier a point
12012
+ * came from. There is deliberately no second read surface: two readers is
12013
+ * how two charts start disagreeing about the same node.
12014
+ *
12015
+ * Reads only; nothing is sampled to answer it. Normally called UNPINNED —
12016
+ * the hub hears every node's snapshot and holds every node's rows — and
12017
+ * answers for any `forNodeId`. Pinned to an agent it answers from that
12018
+ * agent's ring alone (`durable: false`). Empty is a legitimate answer: a
12019
+ * node nobody has heard from has no series, and saying so is the truth.
11625
12020
  */
11626
- killProcess: method(KillProcessInputSchema, KillProcessResultSchema, {
11627
- kind: "mutation",
11628
- auth: "admin"
11629
- }),
12021
+ getLoadSeries: method(GetLoadSeriesInputSchema, NodeLoadSeriesSchema),
11630
12022
  /**
11631
12023
  * Tell the addon's forked runner to write a V8 heap snapshot to disk (via
11632
12024
  * SIGUSR2 — the runner's diagnostic handler). Also logs its
11633
- * `process.memoryUsage()` + heap-space breakdown. Refuses pids not in the
11634
- * live `listNodeProcesses()` snapshot. Use for deep per-addon memory
11635
- * attribution; copy the returned path off the node to analyze.
12025
+ * `process.memoryUsage()` + heap-space breakdown. Resolves the pid from
12026
+ * `$process.list`, so it can only reach a runner this node spawned. Use
12027
+ * for deep per-addon memory attribution; copy the returned path off the
12028
+ * node to analyze.
11636
12029
  */
11637
12030
  dumpHeapSnapshot: method(DumpHeapSnapshotInputSchema, DumpHeapSnapshotResultSchema, {
11638
12031
  kind: "mutation",
@@ -30148,6 +30541,15 @@ var LoggingSettingsPatchSchema = z.object({
30148
30541
  * authority over the whole hierarchy and answers for every layer, so the
30149
30542
  * layer selector needs a name the transport does not already own.
30150
30543
  */
30544
+ /**
30545
+ * One contribution, plus WHO reported it.
30546
+ *
30547
+ * The addon and node are added by the hub as it enumerates providers, never by
30548
+ * the contributor: an addon reporting its own identity could report somebody
30549
+ * else's, and the whole point of this surface is that no claim is made by
30550
+ * anyone but its owner.
30551
+ */
30552
+ var ReportedLoadContributionSchema = LoadContributionSchema.extend({ addonId: z.string() });
30151
30553
  var GetLoggingSettingsInputSchema = z.object({
30152
30554
  scopeNodeId: z.string().optional(),
30153
30555
  /**
@@ -30250,6 +30652,22 @@ var systemCapability = {
30250
30652
  */
30251
30653
  getRequestCensus: method(z.void(), RequestCensusStatusSchema, { auth: "admin" }),
30252
30654
  /**
30655
+ * Every `load-contribution` an addon on this cluster reports — each
30656
+ * addon's OWN cost, already attributed by the addon that owns it.
30657
+ *
30658
+ * There is no central list of what costs what: an addon that spawns a
30659
+ * per-camera child declares it, and one that cannot attribute its cost
30660
+ * (the shared inference pool) declares THAT. So a new cost family appears
30661
+ * here the moment its addon is redeployed, with nobody editing anything.
30662
+ *
30663
+ * What this does NOT do is measure the node. `metrics.node-processes-
30664
+ * snapshot` still does that, and the difference between the two is the
30665
+ * finding: a process no contribution claims is either a leak or a family
30666
+ * nobody has taught to report. Both belong in the unattributed bucket, and
30667
+ * neither may be folded into a camera.
30668
+ */
30669
+ getLoadContributions: method(z.void(), z.array(ReportedLoadContributionSchema).readonly(), { auth: "admin" }),
30670
+ /**
30253
30671
  * The logging settings document — levels and armed diagnostics — resolved
30254
30672
  * for `nodeId`, or for the cluster when `nodeId` is absent.
30255
30673
  *
@@ -32048,6 +32466,7 @@ var ALL_CAPABILITY_DEFINITIONS = [
32048
32466
  lawnMowerControlCapability,
32049
32467
  llmCapability,
32050
32468
  llmRuntimeCapability,
32469
+ loadContributionCapability,
32051
32470
  localNetworkCapability,
32052
32471
  lockControlCapability,
32053
32472
  logChannelsCapability,
@@ -33071,6 +33490,12 @@ var METHOD_ACCESS_MAP = Object.freeze({
33071
33490
  addonId: null,
33072
33491
  access: "create"
33073
33492
  },
33493
+ "dataStoreProvider.insertMany": {
33494
+ capName: "data-store-provider",
33495
+ capScope: "system",
33496
+ addonId: null,
33497
+ access: "create"
33498
+ },
33074
33499
  "dataStoreProvider.isEmpty": {
33075
33500
  capName: "data-store-provider",
33076
33501
  capScope: "system",
@@ -34385,6 +34810,12 @@ var METHOD_ACCESS_MAP = Object.freeze({
34385
34810
  addonId: null,
34386
34811
  access: "create"
34387
34812
  },
34813
+ "loadContribution.list": {
34814
+ capName: "load-contribution",
34815
+ capScope: "system",
34816
+ addonId: null,
34817
+ access: "view"
34818
+ },
34388
34819
  "localNetwork.downloadCa": {
34389
34820
  capName: "local-network",
34390
34821
  capScope: "system",
@@ -34685,17 +35116,17 @@ var METHOD_ACCESS_MAP = Object.freeze({
34685
35116
  addonId: null,
34686
35117
  access: "view"
34687
35118
  },
34688
- "metricsProvider.getProcessStats": {
35119
+ "metricsProvider.getLoadSeries": {
34689
35120
  capName: "metrics-provider",
34690
35121
  capScope: "system",
34691
35122
  addonId: null,
34692
35123
  access: "view"
34693
35124
  },
34694
- "metricsProvider.killProcess": {
35125
+ "metricsProvider.getProcessStats": {
34695
35126
  capName: "metrics-provider",
34696
35127
  capScope: "system",
34697
35128
  addonId: null,
34698
- access: "create"
35129
+ access: "view"
34699
35130
  },
34700
35131
  "metricsProvider.listAddonInstances": {
34701
35132
  capName: "metrics-provider",
@@ -36707,6 +37138,12 @@ var METHOD_ACCESS_MAP = Object.freeze({
36707
37138
  addonId: null,
36708
37139
  access: "create"
36709
37140
  },
37141
+ "settingsStore.insertMany": {
37142
+ capName: "settings-store",
37143
+ capScope: "system",
37144
+ addonId: null,
37145
+ access: "create"
37146
+ },
36710
37147
  "settingsStore.isEmpty": {
36711
37148
  capName: "settings-store",
36712
37149
  capScope: "system",
@@ -37319,6 +37756,12 @@ var METHOD_ACCESS_MAP = Object.freeze({
37319
37756
  addonId: null,
37320
37757
  access: "create"
37321
37758
  },
37759
+ "system.getLoadContributions": {
37760
+ capName: "system",
37761
+ capScope: "system",
37762
+ addonId: null,
37763
+ access: "view"
37764
+ },
37322
37765
  "system.getLoggingSettings": {
37323
37766
  capName: "system",
37324
37767
  capScope: "system",
@@ -40647,4 +41090,4 @@ function enumerateInferenceDevices(hw) {
40647
41090
  return out;
40648
41091
  }
40649
41092
  //#endregion
40650
- export { kebabToCamel as $, buildStreamParamsConfigSchema as A, DeviceFeature as At, doorbellCapability as B, emitDownForOwnedCaps as Bt, addonSettingsCapability as C, vectorDimFromBase64 as Ct, backupCapability as D, DATAPLANE_SECRET_HEADER as Dt, authProviderCapability as E, BaseAddon as Et, decodeVectorBase64 as F, WELL_KNOWN_TAB_MAP as Ft, extractNestedAddonId as G, nodePin as Gt, enumerateItemArrayFields as H, expandCapMethods as Ht, deriveBatteryPresence as I, asJsonObject as It, isCollectionArrayMethod as J, readinessKey as Jt, filesystemBrowseCapability as K, parseJsonObject as Kt, deviceManagerCapability as L, asNumber as Lt, coreBlockIdFromAddonId as M, DeviceType as Mt, coreBlocksCapability as N, ReadinessRegistry as Nt, bareAddonId as O, DEVICE_SETTINGS_CONTRIBUTION_METHODS as Ot, dataStoreProviderCapability as P, ReadinessTimeoutError as Pt, isVoidInput as Q, EventCategory as Qt, deviceStateCapability as R, asString as Rt, addonPagesCapability as S, userManagementCapability as St, alertsCapability as T, errMsg as Tt, enumerateSchemaFields as U, hydrateSchema as Ut, enumerateInferenceDevices as V, emitReadiness as Vt, evaluateSensorEdge as W, isDeviceConfigCap as Wt, isSameAddonId as X, scopeKey as Xt, isObjectInput as Y, resolveCapMount as Yt, isSourceCap as Z, sleep as Zt, STREAM_PROFILE_META as _, snapshotCapability as _t, CAP_NAMES_WITH_STATUS as a, metricsProviderCapability as at, StorageMigrationJobSchema as b, storageProviderCapability as bt, CoreBlockSchema as c, parseStreamParamsFormPatch as ct, DeviceStatusSchema as d, resolveMethodAuth as dt, lifecycleJobSchema as et, LOG_LEVEL_RANK as f, runtimeStatePolicyFor as ft, SOURCE_DEVICE_TYPES as g, settingsStoreCapability as gt, SOURCE_CAPS as h, scoreRuntimes as ht, BatteryStatusSchema as i, looseSchema as it, coreBlockAddonId as j, DeviceRole as jt, batteryCapability as k, DEVICE_STATUS_METHOD as kt, DEFAULT_FIRST_SIGHTING_FRESHNESS_MS as l, platformProbeCapability as lt, RUNTIME_DEFAULTS as m, scopesAllowDeviceCap as mt, AlertSchema as n, logDestinationCapability as nt, CORE_BLOCKS_ADDON_ID as o, normalizeUnit as ot, METHOD_ACCESS_MAP as p, scopesAllowAddon as pt, isArrayOutputSchema as q, parseJsonUnknown as qt, ApiKeyRecordSchema as r, logLevelAtMost as rt, CORE_BLOCK_ADDON_PREFIX as s, objectInputDeclaresAddonId as st, ALL_CAPABILITY_DEFINITIONS as t, localNetworkCapability as tt, DeclaredDevices as u, procedureAuthKey as ut, ScopedTokenSchema as v, storageCapability as vt, addonWidgetsCapability as w, vectorStoreCapability as wt, UserRecordSchema as x, streamQualityLabel as xt, StorageLocationTypeSchema as y, storageMigrationCapability as yt, deviceStatusCapability as z, createEvent as zt };
41093
+ export { isVoidInput as $, scopeKey as $t, buildStreamParamsConfigSchema as A, DATAPLANE_SECRET_HEADER as At, doorbellCapability as B, asNumber as Bt, addonSettingsCapability as C, storageProviderCapability as Ct, backupCapability as D, vectorStoreCapability as Dt, authProviderCapability as E, vectorDimFromBase64 as Et, decodeVectorBase64 as F, DeviceType as Ft, extractNestedAddonId as G, expandCapMethods as Gt, enumerateItemArrayFields as H, createEvent as Ht, deriveBatteryPresence as I, ReadinessRegistry as It, isArrayOutputSchema as J, nodePin as Jt, filesystemBrowseCapability as K, hydrateSchema as Kt, deviceManagerCapability as L, ReadinessTimeoutError as Lt, coreBlockIdFromAddonId as M, DEVICE_STATUS_METHOD as Mt, coreBlocksCapability as N, DeviceFeature as Nt, bareAddonId as O, errMsg as Ot, dataStoreProviderCapability as P, DeviceRole as Pt, isSourceCap as Q, resolveCapMount as Qt, deviceStateCapability as R, WELL_KNOWN_TAB_MAP as Rt, addonPagesCapability as S, storageMigrationCapability as St, alertsCapability as T, userManagementCapability as Tt, enumerateSchemaFields as U, emitDownForOwnedCaps as Ut, enumerateInferenceDevices as V, asString as Vt, evaluateSensorEdge as W, emitReadiness as Wt, isObjectInput as X, parseJsonUnknown as Xt, isCollectionArrayMethod as Y, parseJsonObject as Yt, isSameAddonId as Z, readinessKey as Zt, STREAM_PROFILE_META as _, scopesAllowDeviceCap as _t, CAP_NAMES_WITH_STATUS as a, looseSchema as at, StorageMigrationJobSchema as b, snapshotCapability as bt, CoreBlockSchema as c, objectInputDeclaresAddonId as ct, DeviceStatusSchema as d, procedureAuthKey as dt, sleep as en, kebabToCamel as et, LOG_LEVEL_RANK as f, reducePoints as ft, SOURCE_DEVICE_TYPES as g, scopesAllowAddon as gt, SOURCE_CAPS as h, runtimeStatePolicyFor as ht, BatteryStatusSchema as i, logLevelAtMost as it, coreBlockAddonId as j, DEVICE_SETTINGS_CONTRIBUTION_METHODS as jt, batteryCapability as k, BaseAddon as kt, DEFAULT_FIRST_SIGHTING_FRESHNESS_MS as l, parseStreamParamsFormPatch as lt, RUNTIME_DEFAULTS as m, resolveMethodAuth as mt, AlertSchema as n, localNetworkCapability as nt, CORE_BLOCKS_ADDON_ID as o, metricsProviderCapability as ot, METHOD_ACCESS_MAP as p, resolveBucketMs as pt, foldSnapshotByFunction as q, isDeviceConfigCap as qt, ApiKeyRecordSchema as r, logDestinationCapability as rt, CORE_BLOCK_ADDON_PREFIX as s, normalizeUnit as st, ALL_CAPABILITY_DEFINITIONS as t, EventCategory as tn, lifecycleJobSchema as tt, DeclaredDevices as u, platformProbeCapability as ut, ScopedTokenSchema as v, scoreRuntimes as vt, addonWidgetsCapability as w, streamQualityLabel as wt, UserRecordSchema as x, storageCapability as xt, StorageLocationTypeSchema as y, settingsStoreCapability as yt, deviceStatusCapability as z, asJsonObject as zt };
package/dist/index.d.ts CHANGED
@@ -46,8 +46,8 @@ export { createFileDataPlaneHandler } from './http/file-data-plane.js';
46
46
  export { allFamiliesListenHost, applyLanHttp, bindPendingLanHttp, closeLanHttp, DEFAULT_LAN_HTTP_PORT, readLanHttpState, registerLanHttpHandler, } from './http/lan-http-bind.js';
47
47
  export type { ReverseProxyOptions } from './http/reverse-proxy.js';
48
48
  export { proxyToUpstream } from './http/reverse-proxy.js';
49
- export type { HeapReclaimer, HeapReclaimOptions, HeapSample, HeapWatchSink, RunnerHeapWatchOptions, } from './kernel/heap-watch.js';
50
- export { buildHeapSample, createV8Reclaimer, HEAP_RECLAIM_MIN_INTERVAL_MS, HEAP_RECLAIM_TRIGGER_MB, HEAP_WATCH_INTERVAL_MS, HEAP_WATCH_WARN_RATIO, RUNNER_HEAP_WATCH_INTERVAL_MS, shouldReclaim, startHeapWatch, startRunnerHeapWatch, strandedMb, } from './kernel/heap-watch.js';
49
+ export type { HeapReclaimer, HeapReclaimOptions, HeapSample, HeapWatchSink, RssBreakdown, RssBudgetOptions, RssBudgetState, RssGrowthShape, RunnerHeapWatchOptions, } from './kernel/heap-watch.js';
50
+ export { buildHeapSample, createV8Reclaimer, HEAP_RECLAIM_MIN_INTERVAL_MS, HEAP_RECLAIM_TRIGGER_MB, HEAP_WATCH_INTERVAL_MS, HEAP_WATCH_WARN_RATIO, HUB_MAIN_RSS_BUDGET_MB, HUB_RSS_BUDGET_ENV, hubMainRssBudget, describeRss, nextRssBudgetState, parseRssBudgetMb, RSS_BUDGET_REANNOUNCE_MIN_MS, RSS_BUDGET_RELEASE_RATIO, RUNNER_HEAP_WATCH_INTERVAL_MS, RUNNER_RSS_BUDGET_ENV, shouldReclaim, startHeapWatch, startRunnerHeapWatch, strandedMb, } from './kernel/heap-watch.js';
51
51
  export type { AddonDataPlaneFacility, DataPlaneSink, } from './kernel/moleculer/addon-data-plane-facility.js';
52
52
  export { createAddonDataPlaneFacility } from './kernel/moleculer/addon-data-plane-facility.js';
53
53
  export type { ElementState, ElementStatus, } from './lifecycle/lifecycle-state-machine.js';