@camstack/system 1.2.222 → 1.2.224

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 (62) hide show
  1. package/dist/addon-runner.js +2 -2
  2. package/dist/addon-runner.mjs +2 -2
  3. package/dist/addon-utils.js +1 -1
  4. package/dist/addon-utils.mjs +1 -1
  5. package/dist/builtins/addon-pages-aggregator/addon-pages-aggregator.addon.js +1 -1
  6. package/dist/builtins/addon-pages-aggregator/addon-pages-aggregator.addon.mjs +1 -1
  7. package/dist/builtins/addon-widgets-aggregator/addon-widgets-aggregator.addon.js +1 -1
  8. package/dist/builtins/addon-widgets-aggregator/addon-widgets-aggregator.addon.mjs +1 -1
  9. package/dist/builtins/alerts/alerts.addon.js +1 -1
  10. package/dist/builtins/alerts/alerts.addon.mjs +1 -1
  11. package/dist/builtins/backup-orchestrator/backup-orchestrator.addon.js +2 -2
  12. package/dist/builtins/backup-orchestrator/backup-orchestrator.addon.mjs +2 -2
  13. package/dist/builtins/console-logging/index.js +1 -1
  14. package/dist/builtins/console-logging/index.mjs +1 -1
  15. package/dist/builtins/core-blocks/core-blocks.addon.js +1 -1
  16. package/dist/builtins/core-blocks/core-blocks.addon.mjs +1 -1
  17. package/dist/builtins/device-manager/device-manager.addon.js +2 -2
  18. package/dist/builtins/device-manager/device-manager.addon.mjs +2 -2
  19. package/dist/builtins/doorbell/virtual-doorbell.addon.js +1 -1
  20. package/dist/builtins/doorbell/virtual-doorbell.addon.mjs +1 -1
  21. package/dist/builtins/hub-forwarder/index.js +1 -1
  22. package/dist/builtins/hub-forwarder/index.mjs +1 -1
  23. package/dist/builtins/liveness-monitor/liveness-monitor.addon.js +1 -1
  24. package/dist/builtins/liveness-monitor/liveness-monitor.addon.mjs +1 -1
  25. package/dist/builtins/local-auth/local-auth.addon.js +1 -1
  26. package/dist/builtins/local-auth/local-auth.addon.mjs +1 -1
  27. package/dist/builtins/local-network/local-network.addon.js +1 -1
  28. package/dist/builtins/local-network/local-network.addon.mjs +1 -1
  29. package/dist/builtins/loki-logging/index.js +1 -1
  30. package/dist/builtins/loki-logging/index.mjs +1 -1
  31. package/dist/builtins/native-metrics/native-metrics.addon.js +1 -1
  32. package/dist/builtins/native-metrics/native-metrics.addon.mjs +1 -1
  33. package/dist/builtins/platform-probe/index.js +1 -1
  34. package/dist/builtins/platform-probe/index.mjs +1 -1
  35. package/dist/builtins/remote-access-orchestrator/remote-access-orchestrator.addon.js +1 -1
  36. package/dist/builtins/remote-access-orchestrator/remote-access-orchestrator.addon.mjs +1 -1
  37. package/dist/builtins/snapshot/index.js +1 -1
  38. package/dist/builtins/snapshot/index.mjs +1 -1
  39. package/dist/builtins/sqlite-storage/filesystem-storage.addon.js +1 -1
  40. package/dist/builtins/sqlite-storage/filesystem-storage.addon.mjs +1 -1
  41. package/dist/builtins/sqlite-storage/sqlite-settings-backend.d.ts +30 -1
  42. package/dist/builtins/sqlite-storage/sqlite-settings.addon.js +0 -0
  43. package/dist/builtins/sqlite-storage/sqlite-settings.addon.mjs +0 -0
  44. package/dist/builtins/storage-orchestrator/storage-orchestrator.addon.js +1 -1
  45. package/dist/builtins/storage-orchestrator/storage-orchestrator.addon.mjs +1 -1
  46. package/dist/builtins/system-config/system-config.addon.js +1 -1
  47. package/dist/builtins/system-config/system-config.addon.mjs +1 -1
  48. package/dist/builtins/winston-logging/index.js +1 -1
  49. package/dist/builtins/winston-logging/index.mjs +1 -1
  50. package/dist/{custom-action-registry-DvVMHLfJ.js → custom-action-registry-BTB-LgGN.js} +1 -1
  51. package/dist/{custom-action-registry-DvtOs-tp.mjs → custom-action-registry-CdLp1P9C.mjs} +1 -1
  52. package/dist/{dist-0sWJNwme.js → dist-DdRxWA7g.js} +151 -24
  53. package/dist/{dist-T9GvfhgV.mjs → dist-DmfYrdAn.mjs} +151 -24
  54. package/dist/index.js +3 -3
  55. package/dist/index.mjs +5 -5
  56. package/dist/kernel/heap-watch.d.ts +14 -0
  57. package/dist/kernel/process-cpu-census.d.ts +74 -0
  58. package/dist/{manifest-system-deps-YYKKCKSF.js → manifest-system-deps-8x1jgPz_.js} +138 -1
  59. package/dist/{manifest-system-deps-D4cmEnqQ.mjs → manifest-system-deps-BhYmLVHw.mjs} +139 -2
  60. package/dist/{retired-settings-keys-DmVZAH9M.mjs → retired-settings-keys-B0JHsynV.mjs} +1 -1
  61. package/dist/{retired-settings-keys-Dh-XMfFx.js → retired-settings-keys-C-jOWHI0.js} +1 -1
  62. package/package.json +1 -1
@@ -3384,8 +3384,23 @@ function errMsg(err) {
3384
3384
  if (typeof err === "string") return err;
3385
3385
  return String(err);
3386
3386
  }
3387
- //#endregion
3388
- //#region ../types/dist/index.mjs
3387
+ new Set([
3388
+ "track",
3389
+ "summary",
3390
+ "face",
3391
+ "identity",
3392
+ "plate",
3393
+ "vehicle",
3394
+ "scene",
3395
+ "motion",
3396
+ "object",
3397
+ "audio"
3398
+ ]);
3399
+ new Set([
3400
+ "motion",
3401
+ "object",
3402
+ "audio"
3403
+ ]);
3389
3404
  /**
3390
3405
  * Shared video / audio encode profile schemas used by every consumer
3391
3406
  * that asks the stream broker to spawn a derived stream
@@ -10085,8 +10100,17 @@ var settingsStoreCapability = {
10085
10100
  insert: method(zod.z.object({
10086
10101
  namespace: zod.z.string().optional(),
10087
10102
  collection: zod.z.string(),
10088
- record: SettingsRecordSchema
10089
- }), zod.z.void(), { kind: "mutation" }),
10103
+ record: zod.z.object({
10104
+ id: zod.z.string().optional(),
10105
+ data: zod.z.record(zod.z.string(), zod.z.unknown())
10106
+ })
10107
+ }), zod.z.object({
10108
+ /**
10109
+ * The id the row ACTUALLY got (D473): the one supplied, the UUID minted
10110
+ * for an absent one, or the ROWID SQLite assigned on an `INTEGER`
10111
+ * primary key — which is the only place an auto key is knowable.
10112
+ */
10113
+ id: zod.z.union([zod.z.string(), zod.z.number()]) }), { kind: "mutation" }),
10090
10114
  /**
10091
10115
  * Insert MANY records in ONE transaction, returning how many landed.
10092
10116
  *
@@ -10347,8 +10371,17 @@ var dataStoreProviderCapability = {
10347
10371
  insert: method(zod.z.object({
10348
10372
  namespace: zod.z.string().optional(),
10349
10373
  collection: zod.z.string(),
10350
- record: SettingsRecordSchema
10351
- }), zod.z.void(), {
10374
+ record: zod.z.object({
10375
+ id: zod.z.string().optional(),
10376
+ data: zod.z.record(zod.z.string(), zod.z.unknown())
10377
+ })
10378
+ }), zod.z.object({
10379
+ /**
10380
+ * The id the row ACTUALLY got (D473): the one supplied, the UUID minted
10381
+ * for an absent one, or the ROWID SQLite assigned on an `INTEGER`
10382
+ * primary key — which is the only place an auto key is knowable.
10383
+ */
10384
+ id: zod.z.union([zod.z.string(), zod.z.number()]) }), {
10352
10385
  kind: "mutation",
10353
10386
  auth: "admin"
10354
10387
  }),
@@ -18586,7 +18619,20 @@ var TrackSchema = zod.z.object({
18586
18619
  ...TrackRetrainFields
18587
18620
  });
18588
18621
  var BaseEventFields = {
18589
- id: zod.z.string(),
18622
+ /**
18623
+ * A SQLite ROWID, assigned by the database (D474).
18624
+ *
18625
+ * Was a 36-character UUID and cost 263 MB of a 1 117 MB database — paid
18626
+ * TWICE per row, in the row and in the primary-key index, across 2.1 million
18627
+ * motion, audio and object events. An `INTEGER PRIMARY KEY` in SQLite **is**
18628
+ * the rowid: the table itself is that B-tree, so the index stops existing
18629
+ * rather than getting smaller. No shorter string does that.
18630
+ *
18631
+ * Defined once here for all three event kinds, which is why they move
18632
+ * together: a per-table migration would have forked this and
18633
+ * `COMMON_BASE_COLUMNS` and reunited them two stages later.
18634
+ */
18635
+ id: zod.z.number().int(),
18590
18636
  deviceId: zod.z.number(),
18591
18637
  timestamp: zod.z.number()
18592
18638
  };
@@ -18605,7 +18651,34 @@ var MotionEventSchema = zod.z.object({
18605
18651
  /** Omitted in slim projection. */
18606
18652
  frameHeight: zod.z.number().optional(),
18607
18653
  /** Populated by B5 (recording playback URL for this event). */
18608
- mediaUrl: zod.z.string().optional()
18654
+ mediaUrl: zod.z.string().optional(),
18655
+ /**
18656
+ * One row per motion EPISODE, not one per push (D475). `null` while the
18657
+ * episode is still open — a further rising edge extends it in place rather
18658
+ * than inserting a new row. Set once, at close, to `lastOnAt - startedAt`
18659
+ * (the span from the first rising edge to the LAST one, deliberately NOT
18660
+ * `closedAt - startedAt` — the close delay is a quiet CONFIRMATION, not
18661
+ * movement, and folding it in would report `MOTION_CLOSE_AFTER_MS` of
18662
+ * motion for an instantaneous trigger).
18663
+ *
18664
+ * **Absent** (not merely `null`) on a row written before D475 — that means
18665
+ * "closed the old way, before this column existed", never "still open".
18666
+ * Nothing in this codebase may read an absent `durationMs` as an open
18667
+ * episode; only `null` means open.
18668
+ */
18669
+ durationMs: zod.z.number().nullable().optional(),
18670
+ /**
18671
+ * Ms offsets from `timestamp` (the episode's own first rising edge, so the
18672
+ * first entry is always `0`) of every genuine off→on transition the
18673
+ * episode saw — "ogni evento on si deve salvare" (D475). NOT one entry per
18674
+ * push: a firmware source that keepalives at ~1 Hz for the whole burst
18675
+ * (Reolink, Hikvision) produces exactly one edge; a source that reports an
18676
+ * explicit `false` mid-episode and then resumes before the quiet window
18677
+ * elapses produces another. Stored compactly — see `motion-edge-codec.ts`
18678
+ * — and decoded back to this shape on read. Absent/empty on a legacy row,
18679
+ * which must never be read as "no episode happened here".
18680
+ */
18681
+ edges: zod.z.array(zod.z.number()).readonly().optional()
18609
18682
  });
18610
18683
  /**
18611
18684
  * Which detection SOURCE produced an object event. `pipeline` = the ML
@@ -18668,6 +18741,23 @@ var ObjectEventSchema = zod.z.object({
18668
18741
  * includes it (it is light). Absent on rows written before this field.
18669
18742
  */
18670
18743
  frameId: zod.z.string().optional(),
18744
+ /**
18745
+ * A PRODUCER-chosen key that makes a synthetic event's emission idempotent
18746
+ * (D474).
18747
+ *
18748
+ * Only the package detector writes it, and it exists because the event id
18749
+ * stopped being choosable: the delivery and pick-up rows used to BE their
18750
+ * dedupe key (`pa-pkg-<entryId>-delivered`), which is how "never emit a
18751
+ * second delivery for this entry" survived a restart. An `INTEGER` rowid is
18752
+ * assigned by SQLite, so that key had to move off the primary key rather
18753
+ * than be dropped — a detector that cannot recognise its own row re-delivers
18754
+ * every parcel on every boot.
18755
+ *
18756
+ * Absent on every other object event, and on every row written before this
18757
+ * field. Never a substitute for `id`: it is unique per (producer, occasion),
18758
+ * not per row, and nothing addresses a row by it.
18759
+ */
18760
+ idempotencyKey: zod.z.string().optional(),
18671
18761
  /** Omitted in slim projection. */
18672
18762
  trackId: zod.z.string().optional(),
18673
18763
  className: zod.z.string(),
@@ -29325,26 +29415,59 @@ authKey: zod.z.string().optional() }), zod.z.object({
29325
29415
  }), { kind: "mutation" })
29326
29416
  }
29327
29417
  };
29328
- /**
29329
- * Hardware / firmware motion sensor cap — binary detected state plus
29330
- * a timestamp of the last observation. Distinct from
29331
- * `motion-detection.cap.ts` which owns the LOCAL ML motion pipeline;
29332
- * `motion` is the lightweight readout from on-camera motion (Reolink
29333
- * `GetMdState`, Baichuan push `type: motion`, ONVIF analytics).
29334
- *
29335
- * Native-motion providers also fan out to `detection.camera-native`
29336
- * with `source: 'onboard'` so cross-cutting system services
29337
- * (alert-center, advanced-notifier) can subscribe once and receive
29338
- * motion from every camera.
29339
- */
29340
29418
  var MotionStatusSchema = zod.z.object({
29341
29419
  detected: zod.z.boolean(),
29342
29420
  /** Ms epoch of the last detected-true observation. Null if never detected. */
29343
29421
  lastDetectedAt: zod.z.number().nullable(),
29344
29422
  /**
29345
- * Ms after which `detected` auto-reverts to false if no fresh push
29346
- * arrives. Null means the provider leaves detected state until a
29347
- * native "clear" event.
29423
+ * `MOTION_CLOSE_AFTER_MS` while `detected: true` on a `Camera` device,
29424
+ * `null` while false and on every `Sensor` device (D475) — see that
29425
+ * constant's doc for the one-authority rule.
29426
+ *
29427
+ * ## Reading this field still arms nothing
29428
+ *
29429
+ * It reads like an instruction to the consumer ("revert after N ms if
29430
+ * no fresh push arrives") and it is not one: nothing in this repo reads
29431
+ * the LIVE cap value to drive a timer. `pipeline-analytics`'s motion-episode
29432
+ * close DOES now use the same number — `MOTION_CLOSE_AFTER_MS` — but as an
29433
+ * imported constant, not as a read of `device.state.motion.value`, so this
29434
+ * field stays what it always was: DESCRIPTIVE output, mirroring an answer
29435
+ * computed elsewhere. Building a self-clear timer out of a READ of this
29436
+ * field would add a second falling-edge authority beside whichever one
29437
+ * already owns the device, and two that can disagree are worse than one.
29438
+ * Consumers that need a falling edge SHAPED differently — held open across
29439
+ * a flapping source — debounce on their own side and say so, as
29440
+ * `addon-export-alexa/src/motion-clear-hold.ts` and
29441
+ * `addon-export-hap`'s `RESET_DEBOUNCE_MS` both do.
29442
+ *
29443
+ * ## Who writes it
29444
+ *
29445
+ * - **Cameras** — the runner's phase machine, `active → watching` on
29446
+ * `cooldown_expired`, which then writes this slice with
29447
+ * `detected: false` (`handlePhaseChanged` in
29448
+ * `pipeline-runner/index.ts`). It produces the FALLING edge, which
29449
+ * matters most for the sources that only ever push a rising one:
29450
+ * Reolink emits `MotionOnMotionChanged { detected: true }` and never
29451
+ * a false.
29452
+ * - **Sensors** (Home Assistant binary sensors, Homematic) — the
29453
+ * provider pushes the false itself, from the upstream system's own
29454
+ * state change. No phase machine is involved.
29455
+ *
29456
+ * ### The phase machine is CANONICAL, not sole — and that is a defect
29457
+ *
29458
+ * An earlier revision of this docblock (mine, 2026-09-12) claimed the
29459
+ * phase machine is the sole writer for a camera. It is not.
29460
+ * `hikvision-camera.ts:3464` and `amcrest-camera.ts:445` both call
29461
+ * `setCapSlice(motionCapability, …)` on their own rising edge, and
29462
+ * Hikvision's comment says why: it read THIS docblock, agreed the
29463
+ * runner is canonical, and wrote anyway to avoid per-tick churn. So
29464
+ * two authorities can disagree about one slice, which this repo
29465
+ * forbids, and the doc said otherwise — which is worse than saying
29466
+ * nothing, because it reads as verification.
29467
+ *
29468
+ * This predates D475 and is not fixed there: the fix touches every
29469
+ * camera provider. Recorded in D475's Consequences. Do not restore the
29470
+ * "sole writer" wording without also removing the other writers.
29348
29471
  */
29349
29472
  autoClearAfterMs: zod.z.number().nullable()
29350
29473
  });
@@ -29414,7 +29537,11 @@ onMotionChanged: { data: MotionOnMotionChangedDataSchema } },
29414
29537
  */
29415
29538
  runtimeState: MotionStatusSchema,
29416
29539
  /**
29417
- * Runtime-state durability: **session** — self-clearing by construction (`autoClearAfterMs`); a restored `detected: true` is a frozen event, and the next frame re-publishes the real one.
29540
+ * Runtime-state durability: **session** — every writer of this slice
29541
+ * writes only on an EDGE, so a restored `detected: true` would stay
29542
+ * frozen until the next one instead of being corrected. The next edge
29543
+ * re-publishes the real state. (On who the writers are, and why there
29544
+ * is more than one, see `autoClearAfterMs` above.)
29418
29545
  *
29419
29546
  * See `RuntimeStateDurability`. Enforced by
29420
29547
  * `scripts/check-runtime-state-durability.ts`.
@@ -3384,8 +3384,23 @@ function errMsg(err) {
3384
3384
  if (typeof err === "string") return err;
3385
3385
  return String(err);
3386
3386
  }
3387
- //#endregion
3388
- //#region ../types/dist/index.mjs
3387
+ new Set([
3388
+ "track",
3389
+ "summary",
3390
+ "face",
3391
+ "identity",
3392
+ "plate",
3393
+ "vehicle",
3394
+ "scene",
3395
+ "motion",
3396
+ "object",
3397
+ "audio"
3398
+ ]);
3399
+ new Set([
3400
+ "motion",
3401
+ "object",
3402
+ "audio"
3403
+ ]);
3389
3404
  /**
3390
3405
  * Shared video / audio encode profile schemas used by every consumer
3391
3406
  * that asks the stream broker to spawn a derived stream
@@ -10085,8 +10100,17 @@ var settingsStoreCapability = {
10085
10100
  insert: method(z.object({
10086
10101
  namespace: z.string().optional(),
10087
10102
  collection: z.string(),
10088
- record: SettingsRecordSchema
10089
- }), z.void(), { kind: "mutation" }),
10103
+ record: z.object({
10104
+ id: z.string().optional(),
10105
+ data: z.record(z.string(), z.unknown())
10106
+ })
10107
+ }), z.object({
10108
+ /**
10109
+ * The id the row ACTUALLY got (D473): the one supplied, the UUID minted
10110
+ * for an absent one, or the ROWID SQLite assigned on an `INTEGER`
10111
+ * primary key — which is the only place an auto key is knowable.
10112
+ */
10113
+ id: z.union([z.string(), z.number()]) }), { kind: "mutation" }),
10090
10114
  /**
10091
10115
  * Insert MANY records in ONE transaction, returning how many landed.
10092
10116
  *
@@ -10347,8 +10371,17 @@ var dataStoreProviderCapability = {
10347
10371
  insert: method(z.object({
10348
10372
  namespace: z.string().optional(),
10349
10373
  collection: z.string(),
10350
- record: SettingsRecordSchema
10351
- }), z.void(), {
10374
+ record: z.object({
10375
+ id: z.string().optional(),
10376
+ data: z.record(z.string(), z.unknown())
10377
+ })
10378
+ }), z.object({
10379
+ /**
10380
+ * The id the row ACTUALLY got (D473): the one supplied, the UUID minted
10381
+ * for an absent one, or the ROWID SQLite assigned on an `INTEGER`
10382
+ * primary key — which is the only place an auto key is knowable.
10383
+ */
10384
+ id: z.union([z.string(), z.number()]) }), {
10352
10385
  kind: "mutation",
10353
10386
  auth: "admin"
10354
10387
  }),
@@ -18586,7 +18619,20 @@ var TrackSchema = z.object({
18586
18619
  ...TrackRetrainFields
18587
18620
  });
18588
18621
  var BaseEventFields = {
18589
- id: z.string(),
18622
+ /**
18623
+ * A SQLite ROWID, assigned by the database (D474).
18624
+ *
18625
+ * Was a 36-character UUID and cost 263 MB of a 1 117 MB database — paid
18626
+ * TWICE per row, in the row and in the primary-key index, across 2.1 million
18627
+ * motion, audio and object events. An `INTEGER PRIMARY KEY` in SQLite **is**
18628
+ * the rowid: the table itself is that B-tree, so the index stops existing
18629
+ * rather than getting smaller. No shorter string does that.
18630
+ *
18631
+ * Defined once here for all three event kinds, which is why they move
18632
+ * together: a per-table migration would have forked this and
18633
+ * `COMMON_BASE_COLUMNS` and reunited them two stages later.
18634
+ */
18635
+ id: z.number().int(),
18590
18636
  deviceId: z.number(),
18591
18637
  timestamp: z.number()
18592
18638
  };
@@ -18605,7 +18651,34 @@ var MotionEventSchema = z.object({
18605
18651
  /** Omitted in slim projection. */
18606
18652
  frameHeight: z.number().optional(),
18607
18653
  /** Populated by B5 (recording playback URL for this event). */
18608
- mediaUrl: z.string().optional()
18654
+ mediaUrl: z.string().optional(),
18655
+ /**
18656
+ * One row per motion EPISODE, not one per push (D475). `null` while the
18657
+ * episode is still open — a further rising edge extends it in place rather
18658
+ * than inserting a new row. Set once, at close, to `lastOnAt - startedAt`
18659
+ * (the span from the first rising edge to the LAST one, deliberately NOT
18660
+ * `closedAt - startedAt` — the close delay is a quiet CONFIRMATION, not
18661
+ * movement, and folding it in would report `MOTION_CLOSE_AFTER_MS` of
18662
+ * motion for an instantaneous trigger).
18663
+ *
18664
+ * **Absent** (not merely `null`) on a row written before D475 — that means
18665
+ * "closed the old way, before this column existed", never "still open".
18666
+ * Nothing in this codebase may read an absent `durationMs` as an open
18667
+ * episode; only `null` means open.
18668
+ */
18669
+ durationMs: z.number().nullable().optional(),
18670
+ /**
18671
+ * Ms offsets from `timestamp` (the episode's own first rising edge, so the
18672
+ * first entry is always `0`) of every genuine off→on transition the
18673
+ * episode saw — "ogni evento on si deve salvare" (D475). NOT one entry per
18674
+ * push: a firmware source that keepalives at ~1 Hz for the whole burst
18675
+ * (Reolink, Hikvision) produces exactly one edge; a source that reports an
18676
+ * explicit `false` mid-episode and then resumes before the quiet window
18677
+ * elapses produces another. Stored compactly — see `motion-edge-codec.ts`
18678
+ * — and decoded back to this shape on read. Absent/empty on a legacy row,
18679
+ * which must never be read as "no episode happened here".
18680
+ */
18681
+ edges: z.array(z.number()).readonly().optional()
18609
18682
  });
18610
18683
  /**
18611
18684
  * Which detection SOURCE produced an object event. `pipeline` = the ML
@@ -18668,6 +18741,23 @@ var ObjectEventSchema = z.object({
18668
18741
  * includes it (it is light). Absent on rows written before this field.
18669
18742
  */
18670
18743
  frameId: z.string().optional(),
18744
+ /**
18745
+ * A PRODUCER-chosen key that makes a synthetic event's emission idempotent
18746
+ * (D474).
18747
+ *
18748
+ * Only the package detector writes it, and it exists because the event id
18749
+ * stopped being choosable: the delivery and pick-up rows used to BE their
18750
+ * dedupe key (`pa-pkg-<entryId>-delivered`), which is how "never emit a
18751
+ * second delivery for this entry" survived a restart. An `INTEGER` rowid is
18752
+ * assigned by SQLite, so that key had to move off the primary key rather
18753
+ * than be dropped — a detector that cannot recognise its own row re-delivers
18754
+ * every parcel on every boot.
18755
+ *
18756
+ * Absent on every other object event, and on every row written before this
18757
+ * field. Never a substitute for `id`: it is unique per (producer, occasion),
18758
+ * not per row, and nothing addresses a row by it.
18759
+ */
18760
+ idempotencyKey: z.string().optional(),
18671
18761
  /** Omitted in slim projection. */
18672
18762
  trackId: z.string().optional(),
18673
18763
  className: z.string(),
@@ -29325,26 +29415,59 @@ authKey: z.string().optional() }), z.object({
29325
29415
  }), { kind: "mutation" })
29326
29416
  }
29327
29417
  };
29328
- /**
29329
- * Hardware / firmware motion sensor cap — binary detected state plus
29330
- * a timestamp of the last observation. Distinct from
29331
- * `motion-detection.cap.ts` which owns the LOCAL ML motion pipeline;
29332
- * `motion` is the lightweight readout from on-camera motion (Reolink
29333
- * `GetMdState`, Baichuan push `type: motion`, ONVIF analytics).
29334
- *
29335
- * Native-motion providers also fan out to `detection.camera-native`
29336
- * with `source: 'onboard'` so cross-cutting system services
29337
- * (alert-center, advanced-notifier) can subscribe once and receive
29338
- * motion from every camera.
29339
- */
29340
29418
  var MotionStatusSchema = z.object({
29341
29419
  detected: z.boolean(),
29342
29420
  /** Ms epoch of the last detected-true observation. Null if never detected. */
29343
29421
  lastDetectedAt: z.number().nullable(),
29344
29422
  /**
29345
- * Ms after which `detected` auto-reverts to false if no fresh push
29346
- * arrives. Null means the provider leaves detected state until a
29347
- * native "clear" event.
29423
+ * `MOTION_CLOSE_AFTER_MS` while `detected: true` on a `Camera` device,
29424
+ * `null` while false and on every `Sensor` device (D475) — see that
29425
+ * constant's doc for the one-authority rule.
29426
+ *
29427
+ * ## Reading this field still arms nothing
29428
+ *
29429
+ * It reads like an instruction to the consumer ("revert after N ms if
29430
+ * no fresh push arrives") and it is not one: nothing in this repo reads
29431
+ * the LIVE cap value to drive a timer. `pipeline-analytics`'s motion-episode
29432
+ * close DOES now use the same number — `MOTION_CLOSE_AFTER_MS` — but as an
29433
+ * imported constant, not as a read of `device.state.motion.value`, so this
29434
+ * field stays what it always was: DESCRIPTIVE output, mirroring an answer
29435
+ * computed elsewhere. Building a self-clear timer out of a READ of this
29436
+ * field would add a second falling-edge authority beside whichever one
29437
+ * already owns the device, and two that can disagree are worse than one.
29438
+ * Consumers that need a falling edge SHAPED differently — held open across
29439
+ * a flapping source — debounce on their own side and say so, as
29440
+ * `addon-export-alexa/src/motion-clear-hold.ts` and
29441
+ * `addon-export-hap`'s `RESET_DEBOUNCE_MS` both do.
29442
+ *
29443
+ * ## Who writes it
29444
+ *
29445
+ * - **Cameras** — the runner's phase machine, `active → watching` on
29446
+ * `cooldown_expired`, which then writes this slice with
29447
+ * `detected: false` (`handlePhaseChanged` in
29448
+ * `pipeline-runner/index.ts`). It produces the FALLING edge, which
29449
+ * matters most for the sources that only ever push a rising one:
29450
+ * Reolink emits `MotionOnMotionChanged { detected: true }` and never
29451
+ * a false.
29452
+ * - **Sensors** (Home Assistant binary sensors, Homematic) — the
29453
+ * provider pushes the false itself, from the upstream system's own
29454
+ * state change. No phase machine is involved.
29455
+ *
29456
+ * ### The phase machine is CANONICAL, not sole — and that is a defect
29457
+ *
29458
+ * An earlier revision of this docblock (mine, 2026-09-12) claimed the
29459
+ * phase machine is the sole writer for a camera. It is not.
29460
+ * `hikvision-camera.ts:3464` and `amcrest-camera.ts:445` both call
29461
+ * `setCapSlice(motionCapability, …)` on their own rising edge, and
29462
+ * Hikvision's comment says why: it read THIS docblock, agreed the
29463
+ * runner is canonical, and wrote anyway to avoid per-tick churn. So
29464
+ * two authorities can disagree about one slice, which this repo
29465
+ * forbids, and the doc said otherwise — which is worse than saying
29466
+ * nothing, because it reads as verification.
29467
+ *
29468
+ * This predates D475 and is not fixed there: the fix touches every
29469
+ * camera provider. Recorded in D475's Consequences. Do not restore the
29470
+ * "sole writer" wording without also removing the other writers.
29348
29471
  */
29349
29472
  autoClearAfterMs: z.number().nullable()
29350
29473
  });
@@ -29414,7 +29537,11 @@ onMotionChanged: { data: MotionOnMotionChangedDataSchema } },
29414
29537
  */
29415
29538
  runtimeState: MotionStatusSchema,
29416
29539
  /**
29417
- * Runtime-state durability: **session** — self-clearing by construction (`autoClearAfterMs`); a restored `detected: true` is a frozen event, and the next frame re-publishes the real one.
29540
+ * Runtime-state durability: **session** — every writer of this slice
29541
+ * writes only on an EDGE, so a restored `detected: true` would stay
29542
+ * frozen until the next one instead of being corrected. The next edge
29543
+ * re-publishes the real state. (On who the writers are, and why there
29544
+ * is more than one, see `autoClearAfterMs` above.)
29418
29545
  *
29419
29546
  * See `RuntimeStateDurability`. Enforced by
29420
29547
  * `scripts/check-runtime-state-durability.ts`.
package/dist/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
2
  const require_chunk = require("./chunk-Cek0wNdY.js");
3
- const require_dist = require("./dist-0sWJNwme.js");
3
+ const require_dist = require("./dist-DdRxWA7g.js");
4
4
  const require_builtins_alerts_alerts_addon = require("./builtins/alerts/alerts.addon.js");
5
5
  require("./builtins/alerts/index.js");
6
6
  const require_formatter = require("./formatter-DqAKDlvN.js");
@@ -27,9 +27,9 @@ require("./builtins/system-config/index.js");
27
27
  const require_builtins_winston_logging_index = require("./builtins/winston-logging/index.js");
28
28
  const require_event_loop_stall_monitor = require("./event-loop-stall-monitor-CAsHdMwP.js");
29
29
  const require_tls$1 = require("./tls-BFs4PzoW.js");
30
- const require_manifest_system_deps = require("./manifest-system-deps-YYKKCKSF.js");
30
+ const require_manifest_system_deps = require("./manifest-system-deps-8x1jgPz_.js");
31
31
  const require_resource_monitor = require("./resource-monitor-LVE1BoLs.js");
32
- const require_custom_action_registry = require("./custom-action-registry-DvVMHLfJ.js");
32
+ const require_custom_action_registry = require("./custom-action-registry-BTB-LgGN.js");
33
33
  let zod = require("zod");
34
34
  let node_crypto = require("node:crypto");
35
35
  let _camstack_types_node = require("@camstack/types/node");
package/dist/index.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  import { a as __toCommonJS, i as __require, n as __esmMin, o as __toESM$1, r as __exportAll, t as __commonJSMin$1 } from "./chunk-CNf5ZN-e.mjs";
2
- import { A as addonSettingsCapability, Dt as procedureAuthKey, Ft as scopesAllowDeviceCap, Jt as errMsg$1, Mt as resolveMethodAuth, Pt as scopesAllowAddon, Qt as DEVICE_STATUS_METHOD, Xt as DATAPLANE_SECRET_HEADER$1, Zt as DEVICE_SETTINGS_CONTRIBUTION_METHODS, _ as RUNTIME_DEFAULTS, _n as readinessKey, _t as logLevelAtMost, an as asJsonObject$1, at as isArrayOutputSchema, cn as createEvent, ct as isObjectInput, dn as expandCapMethods, dt as isVoidInput, ft as kebabToCamel, gn as parseJsonUnknown, h as METHOD_ACCESS_MAP, hn as parseJsonObject, ln as emitDownForOwnedCaps, mt as lifecycleJobSchema, nn as ReadinessRegistry, on as asNumber, ot as isCollectionArrayMethod, p as LOG_LEVEL_RANK, rn as ReadinessTimeoutError, sn as asString$1, t as ALL_CAPABILITY_DEFINITIONS, tt as extractNestedAddonId, vn as resolveCapMount, vt as looseSchema, wt as objectInputDeclaresAddonId, xn as EventCategory$1, yn as scopeKey } from "./dist-T9GvfhgV.mjs";
2
+ import { A as addonSettingsCapability, Dt as procedureAuthKey, Ft as scopesAllowDeviceCap, Jt as errMsg$1, Mt as resolveMethodAuth, Pt as scopesAllowAddon, Qt as DEVICE_STATUS_METHOD, Xt as DATAPLANE_SECRET_HEADER$1, Zt as DEVICE_SETTINGS_CONTRIBUTION_METHODS, _ as RUNTIME_DEFAULTS, _n as readinessKey, _t as logLevelAtMost, an as asJsonObject$1, at as isArrayOutputSchema, cn as createEvent, ct as isObjectInput, dn as expandCapMethods, dt as isVoidInput, ft as kebabToCamel, gn as parseJsonUnknown, h as METHOD_ACCESS_MAP, hn as parseJsonObject, ln as emitDownForOwnedCaps, mt as lifecycleJobSchema, nn as ReadinessRegistry, on as asNumber, ot as isCollectionArrayMethod, p as LOG_LEVEL_RANK, rn as ReadinessTimeoutError, sn as asString$1, t as ALL_CAPABILITY_DEFINITIONS, tt as extractNestedAddonId, vn as resolveCapMount, vt as looseSchema, wt as objectInputDeclaresAddonId, xn as EventCategory$1, yn as scopeKey } from "./dist-DmfYrdAn.mjs";
3
3
  import { AlertCenterAddon } from "./builtins/alerts/alerts.addon.mjs";
4
4
  import "./builtins/alerts/index.mjs";
5
5
  import { t as formatLogLine } from "./formatter-B7qW8bPJ.mjs";
@@ -26,9 +26,9 @@ import "./builtins/system-config/index.mjs";
26
26
  import { WinstonDestination, WinstonLoggingAddon } from "./builtins/winston-logging/index.mjs";
27
27
  import { _ as fetchJson, a as createFileDataPlaneHandler, c as parseRangeHeader, d as ModelDownloadService, f as collectModelFiles, g as ensureModel, h as downloadModel, i as startEventLoopStallMonitor, l as parseTokenizedUrl, m as downloadFile, n as STALL_TICK_MS, o as contentTypeFor, p as deleteModelFromDisk, r as attributeStall, s as createAuthenticatedFileServer, t as STALL_REPORT_MS, u as resolveFilePath, v as getModelFilePath, y as isModelDownloaded } from "./event-loop-stall-monitor-GPrVvx14.mjs";
28
28
  import { C as registerLanHttpHandler, S as readLanHttpState, _ as DEFAULT_LAN_HTTP_PORT, a as writeTlsMode, b as bindPendingLanHttp, c as loadTlsCert, d as collectCertIdentity, f as CA_VALIDITY_DAYS, g as evaluateExistingCert, h as SERVER_AUTH_OID, i as writeExtraSans, l as reissueTlsLeaf, m as MAX_LEAF_VALIDITY_DAYS, n as readTlsAccessStatus, o as validateUploadedTls, p as LEAF_RENEWAL_WINDOW_DAYS, r as readTlsMode, s as ensureTlsCert, t as readExtraSans, u as CA_COMMON_NAME, v as allFamiliesListenHost, x as closeLanHttp, y as applyLanHttp } from "./tls-2xbgg78V.mjs";
29
- import { $ as buildUdsNativeCapProxy, $t as ARRAY_BUFFER_RELEASE_MIN_DROP_RATIO, A as createUdsLoggerWithControl, An as sampleSocketDirection, At as HUB_MAIN_RSS_BUDGET_MB, B as readMoleculerFanoutMode, Bn as EVENT_PLANE_TOP_N, Bt as createV8Reclaimer, C as ipcParentLink, Cn as createSocketPlaneReader, Ct as createAddonDataPlaneFacility, D as createUdsEventBus, Dn as EMPTY_SOCKET_DIRECTION, Dt as HEAP_WATCH_INTERVAL_MS, E as createUdsEventBridge, En as readSocketQueues, Et as HEAP_RECLAIM_TRIGGER_MB, F as CapRouteError, Fn as EMPTY_CAP_ACTION_READING, Ft as RUNNER_RSS_BUDGET_ENV, G as createLocalTransport, Gt as reclaimIntervalMs, H as PARENT_ROUTED_PROVIDER_ADDON_ID, Hn as createEventPlaneReader, Ht as hubMainRssBudget, I as classifyCapRoute, In as MAX_CAP_ACTIONS_PER_PEER, It as ZERO_LOOP_DELAY, J as SocketChannel, Jt as startRunnerHeapWatch, K as UdsLocalTransportClient, Kt as shouldReclaim, L as LocalChildClient, Ln as capActionLabel, Lt as buildHeapSample, M as AGENT_CAP_FWD_SERVICE, Mn as socketDirectionMessages, Mt as RSS_BUDGET_REANNOUNCE_MIN_MS, N as CapRouteResolver, Nn as CAP_ACTION_OVERFLOW_LABEL, Nt as RSS_BUDGET_RELEASE_RATIO, O as udsChildLogToWorkerEntry, On as createSocketDirectionCounters, Ot as HEAP_WATCH_WARN_RATIO, P as callWithServiceDiscovery, Pn as CAP_ACTION_UNLABELLED, Pt as RUNNER_HEAP_WATCH_INTERVAL_MS, Q as buildNativeCapProxy, Qt as ARRAY_BUFFER_CENSUS_THRESHOLD_MB, R as LocalChildRegistry, Rn as createCapActionCensus, Rt as createDeferredHeapWatchSink, S as buildLinkChain, Sn as createSocketPlaneMeter, St as runNpm, T as createParentUnownedCallHandler, Tn as formatSocketPlane, Tt as HEAP_RECLAIM_STEADY_STATE_INTERVAL_MS, U as __resetCapUsageRegistryForTests, Un as diffEventPlane, Ut as nextRssBudgetState, V as CapUsageRegistry, Vn as createEventPlaneMeter, Vt as describeRss, W as getCapUsageRegistry, Wn as formatEventPlane, Wt as parseRssBudgetMb, X as FrameDecoder, Xt as ARRAY_BUFFER_CENSUS_COOLDOWN_MS, Y as localEndpointPath, Yt as strandedMb, Z as encodeFrame, Zt as ARRAY_BUFFER_CENSUS_SUSTAIN_MS, _ as AddonDepsManager, _n as createMeshQueueReader, _t as CapabilityUnavailableError, a as createUdsAddonContext, an as HEAP_SPACE_REPORT_MIN_MB, at as createAddonService, b as brokerCallForCap, bn as SOCKET_PLANE_TOP_N, bt as resolveAddonClass, c as getOrInitReadinessRegistryForClient, cn as heapSpaceField, ct as capActionName, d as clusterEventTopic, dn as OUTBOUND_QUEUE_COOLDOWN_MS, dt as capServiceName, en as createArrayBufferCensusGate, et as createBrokerDeviceManagerApi, f as getBrokerEventBus, fn as OUTBOUND_QUEUE_SUSTAIN_MS, ft as parseCapAction, g as subscribePassthrough, gn as MESH_QUEUE_TOP_N, gt as CapabilityHandle, h as setNodeEventInterest, hn as formatOutboundQueueVerdict, ht as DeviceRegistry, i as createAddonContext, in as DECISIVE_HEAP_SPACES, j as AGENT_CAP_FWD_ACTION, jn as socketDirectionBytes, jt as HUB_RSS_BUDGET_ENV, k as createUdsLogger, kn as recordSocketFrame, kt as HUB_MAIN_HEAP_WATCH_LABEL, l as setHubConnected, ln as readHeapSpaces, lt as capActionSuffix, m as registerEventBusService, mn as createOutboundQueueGate, mt as serializeTypedArrays, n as installManifestPythonDeps, nn as formatArrayBufferCensus, o as getWorkerDeviceRegistry, on as emitHeapDiagnosticReport, ot as validateProviderRegistrations, p as getMoleculerEventStats, pn as OUTBOUND_QUEUE_THRESHOLD_BYTES, pt as deserializeTypedArrays, q as UdsLocalTransportServer, qt as startHeapWatch, r as adaptBrokerToCluster, rn as isArrayBufferCensusReport, rt as mountNativeCapService, s as getOrInitReadinessRegistry, sn as formatHeapSpaces, st as NATIVE_PROVIDER_SERVICE_INFIX, t as installManifestSystemDeps, tn as createInspectorArrayBufferCensus, u as EVENT_TOPIC_PREFIX, un as selectReportedSpaces, ut as capBareAction, v as createKernelHwAccel, vn as formatMeshQueue, vt as copyBundledNativeModules, w as localProviderLink, wn as diffSocketPlane, wt as HEAP_RECLAIM_MIN_INTERVAL_MS, x as brokerTransportLink, xn as SOCKET_QUEUE_TOP_N, xt as resolveNpmInvocation, y as resolveHwAccel, yn as EMPTY_SOCKET_PLANE_BASELINE, yt as installManifestNativeDeps, z as UDS_NO_ROUTE_PREFIX, zn as diffCapActionCensus, zt as createLoopDelayMeter } from "./manifest-system-deps-D4cmEnqQ.mjs";
29
+ import { $ as buildUdsNativeCapProxy, $t as ARRAY_BUFFER_RELEASE_MIN_DROP_RATIO, A as createUdsLoggerWithControl, An as sampleSocketDirection, At as HUB_MAIN_RSS_BUDGET_MB, B as readMoleculerFanoutMode, Bn as EVENT_PLANE_TOP_N, Bt as createV8Reclaimer, C as ipcParentLink, Cn as createSocketPlaneReader, Ct as createAddonDataPlaneFacility, D as createUdsEventBus, Dn as EMPTY_SOCKET_DIRECTION, Dt as HEAP_WATCH_INTERVAL_MS, E as createUdsEventBridge, En as readSocketQueues, Et as HEAP_RECLAIM_TRIGGER_MB, F as CapRouteError, Fn as EMPTY_CAP_ACTION_READING, Ft as RUNNER_RSS_BUDGET_ENV, G as createLocalTransport, Gt as reclaimIntervalMs, H as PARENT_ROUTED_PROVIDER_ADDON_ID, Hn as createEventPlaneReader, Ht as hubMainRssBudget, I as classifyCapRoute, In as MAX_CAP_ACTIONS_PER_PEER, It as ZERO_LOOP_DELAY, J as SocketChannel, Jt as startRunnerHeapWatch, K as UdsLocalTransportClient, Kt as shouldReclaim, L as LocalChildClient, Ln as capActionLabel, Lt as buildHeapSample, M as AGENT_CAP_FWD_SERVICE, Mn as socketDirectionMessages, Mt as RSS_BUDGET_REANNOUNCE_MIN_MS, N as CapRouteResolver, Nn as CAP_ACTION_OVERFLOW_LABEL, Nt as RSS_BUDGET_RELEASE_RATIO, O as udsChildLogToWorkerEntry, On as createSocketDirectionCounters, Ot as HEAP_WATCH_WARN_RATIO, P as callWithServiceDiscovery, Pn as CAP_ACTION_UNLABELLED, Pt as RUNNER_HEAP_WATCH_INTERVAL_MS, Q as buildNativeCapProxy, Qt as ARRAY_BUFFER_CENSUS_THRESHOLD_MB, R as LocalChildRegistry, Rn as createCapActionCensus, Rt as createDeferredHeapWatchSink, S as buildLinkChain, Sn as createSocketPlaneMeter, St as runNpm, T as createParentUnownedCallHandler, Tn as formatSocketPlane, Tt as HEAP_RECLAIM_STEADY_STATE_INTERVAL_MS, U as __resetCapUsageRegistryForTests, Un as diffEventPlane, Ut as nextRssBudgetState, V as CapUsageRegistry, Vn as createEventPlaneMeter, Vt as describeRss, W as getCapUsageRegistry, Wn as formatEventPlane, Wt as parseRssBudgetMb, X as FrameDecoder, Xt as ARRAY_BUFFER_CENSUS_COOLDOWN_MS, Y as localEndpointPath, Yt as strandedMb, Z as encodeFrame, Zt as ARRAY_BUFFER_CENSUS_SUSTAIN_MS, _ as AddonDepsManager, _n as createMeshQueueReader, _t as CapabilityUnavailableError, a as createUdsAddonContext, an as HEAP_SPACE_REPORT_MIN_MB, at as createAddonService, b as brokerCallForCap, bn as SOCKET_PLANE_TOP_N, bt as resolveAddonClass, c as getOrInitReadinessRegistryForClient, cn as heapSpaceField, ct as capActionName, d as clusterEventTopic, dn as OUTBOUND_QUEUE_COOLDOWN_MS, dt as capServiceName, en as createArrayBufferCensusGate, et as createBrokerDeviceManagerApi, f as getBrokerEventBus, fn as OUTBOUND_QUEUE_SUSTAIN_MS, ft as parseCapAction, g as subscribePassthrough, gn as MESH_QUEUE_TOP_N, gt as CapabilityHandle, h as setNodeEventInterest, hn as formatOutboundQueueVerdict, ht as DeviceRegistry, i as createAddonContext, in as DECISIVE_HEAP_SPACES, j as AGENT_CAP_FWD_ACTION, jn as socketDirectionBytes, jt as HUB_RSS_BUDGET_ENV, k as createUdsLogger, kn as recordSocketFrame, kt as HUB_MAIN_HEAP_WATCH_LABEL, l as setHubConnected, ln as readHeapSpaces, lt as capActionSuffix, m as registerEventBusService, mn as createOutboundQueueGate, mt as serializeTypedArrays, n as installManifestPythonDeps, nn as formatArrayBufferCensus, o as getWorkerDeviceRegistry, on as emitHeapDiagnosticReport, ot as validateProviderRegistrations, p as getMoleculerEventStats, pn as OUTBOUND_QUEUE_THRESHOLD_BYTES, pt as deserializeTypedArrays, q as UdsLocalTransportServer, qt as startHeapWatch, r as adaptBrokerToCluster, rn as isArrayBufferCensusReport, rt as mountNativeCapService, s as getOrInitReadinessRegistry, sn as formatHeapSpaces, st as NATIVE_PROVIDER_SERVICE_INFIX, t as installManifestSystemDeps, tn as createInspectorArrayBufferCensus, u as EVENT_TOPIC_PREFIX, un as selectReportedSpaces, ut as capBareAction, v as createKernelHwAccel, vn as formatMeshQueue, vt as copyBundledNativeModules, w as localProviderLink, wn as diffSocketPlane, wt as HEAP_RECLAIM_MIN_INTERVAL_MS, x as brokerTransportLink, xn as SOCKET_QUEUE_TOP_N, xt as resolveNpmInvocation, y as resolveHwAccel, yn as EMPTY_SOCKET_PLANE_BASELINE, yt as installManifestNativeDeps, z as UDS_NO_ROUTE_PREFIX, zn as diffCapActionCensus, zt as createLoopDelayMeter } from "./manifest-system-deps-BhYmLVHw.mjs";
30
30
  import { n as getSinglePidStats, t as getPidStats } from "./resource-monitor-Vp0bPV3U.mjs";
31
- import { t as CustomActionRegistry } from "./custom-action-registry-DvtOs-tp.mjs";
31
+ import { t as CustomActionRegistry } from "./custom-action-registry-CdLp1P9C.mjs";
32
32
  import { z } from "zod";
33
33
  import { createHash, randomUUID, timingSafeEqual } from "node:crypto";
34
34
  import { PYTHON_VERSION, buildBinaryPath, downloadBinary, ensureBinary, ensureFfmpeg, ensurePython, findInPath, getFfmpegDownloadUrl, getPlatformInfo, getPythonDownloadUrl, installPythonPackages, installPythonRequirements } from "@camstack/types/node";
@@ -48,7 +48,7 @@ import { fileURLToPath, pathToFileURL } from "node:url";
48
48
  import { EventEmitter } from "node:events";
49
49
  import As from "node:stream";
50
50
  import { StringDecoder } from "node:string_decoder";
51
- import { lstatSync, readdir as readdir$1, readdirSync, readlinkSync, realpathSync } from "fs";
51
+ import { lstatSync, readdir as readdir$1, readdirSync as readdirSync$1, readlinkSync, realpathSync } from "fs";
52
52
  import "path";
53
53
  import { createRequire } from "module";
54
54
  //#region src/addon/addon-api-factory.ts
@@ -92203,7 +92203,7 @@ while (this[Le](this[Ft]()) && this[C].length);
92203
92203
  }, wt = {
92204
92204
  lstatSync,
92205
92205
  readdir: readdir$1,
92206
- readdirSync,
92206
+ readdirSync: readdirSync$1,
92207
92207
  readlinkSync,
92208
92208
  realpathSync: realpathSync.native,
92209
92209
  promises: {
@@ -4,6 +4,7 @@ import { MeshPeerQueue, MeshQueueReader } from './moleculer/mesh-queue-report.js
4
4
  import { OutboundQueueGateOptions, OutboundQueueReading } from './outbound-queue-watch.js';
5
5
  import { HeapSpaceReader } from './heap-spaces.js';
6
6
  import { NodeGcObserver } from './gc-census.js';
7
+ import { TaskTicks } from './process-cpu-census.js';
7
8
  import { ArrayBufferCensus, ArrayBufferCensusGateOptions } from './array-buffer-census.js';
8
9
  /**
9
10
  * What hub-main calls itself in a `[mem]` line.
@@ -641,6 +642,19 @@ export interface HeapWatchProbes {
641
642
  * sequence of collections can be posed; nothing in production passes one.
642
643
  */
643
644
  readonly gcObserver?: NodeGcObserver;
645
+ /**
646
+ * How this process reads its own CPU. Defaults to the real
647
+ * `process.cpuUsage()` and the real `/proc/self/task`, for EVERY process —
648
+ * `docker stats` reports the cgroup, and nothing on any line said what share
649
+ * of it this process was (see `process-cpu-census.ts`). A spec passes its own
650
+ * so a cost can be posed; nothing in production passes one.
651
+ */
652
+ readonly processCpu?: ProcessCpuProbe;
653
+ }
654
+ /** The two readings `process-cpu-census.ts` needs, injectable for a spec. */
655
+ export interface ProcessCpuProbe {
656
+ readonly cpuUsageUs: () => number;
657
+ readonly readTasks: () => readonly TaskTicks[] | null;
644
658
  }
645
659
  /** How the census is wired: the census itself plus the gate's thresholds. */
646
660
  export interface ArrayBufferCensusProbe extends ArrayBufferCensusGateOptions {
@@ -0,0 +1,74 @@
1
+ /**
2
+ * A window shorter than this is not answered. Same rule and same reason as
3
+ * `GC_CENSUS_MIN_WINDOW_MS`: the boot line spans milliseconds, and a percentage
4
+ * computed over it is noise wearing a decimal point. The unread interval is
5
+ * KEPT, so the next line describes it rather than losing it (D393 applied to a
6
+ * rate, as D458 part 3 put it).
7
+ */
8
+ export declare const PROCESS_CPU_MIN_WINDOW_MS = 1000;
9
+ /** One thread's cumulative scheduled time, in whatever unit `/proc` counts. */
10
+ export interface TaskTicks {
11
+ /** The thread name — `MainThread`, `V8Worker`, `libuv-worker`, … */
12
+ readonly comm: string;
13
+ /** Cumulative `utime + stime` for this thread. Units never leave this module. */
14
+ readonly ticks: number;
15
+ }
16
+ /** What V8's background threads cost, when the platform let us find out. */
17
+ export interface V8WorkerCpu {
18
+ /** Percent of ONE core, over the same window as the process reading. */
19
+ readonly percentOfCore: number;
20
+ /** How many threads that is spread over — 4 is the usual platform pool. */
21
+ readonly threads: number;
22
+ }
23
+ export interface ProcessCpuReading {
24
+ /** Percent of ONE core this process used across the window. */
25
+ readonly percentOfCore: number;
26
+ readonly windowMs: number;
27
+ /**
28
+ * `null` means UNKNOWN — not zero. Off Linux, or with `/proc` unreadable, or
29
+ * when the thread deltas cannot describe an interval, there is no reading,
30
+ * and the line says nothing rather than printing a zero somebody will quote.
31
+ */
32
+ readonly v8Workers: V8WorkerCpu | null;
33
+ }
34
+ export interface ProcessCpuCensus {
35
+ /** The window since the last read that ANSWERED. `null` when too short. */
36
+ read(at: number): ProcessCpuReading | null;
37
+ }
38
+ export interface ProcessCpuCensusOptions {
39
+ /** Cumulative user+system CPU for the whole process, in microseconds. */
40
+ readonly cpuUsageUs: () => number;
41
+ /** Per-thread cumulative ticks, or `null` when the platform cannot say. */
42
+ readonly readTasks: () => readonly TaskTicks[] | null;
43
+ readonly startedAt: number;
44
+ }
45
+ /**
46
+ * The census. Always exists — `process.cpuUsage()` is available on every
47
+ * platform Node runs on, so unlike the GC census there is no runtime in which
48
+ * this has nothing to report.
49
+ */
50
+ export declare function createProcessCpuCensus(options: ProcessCpuCensusOptions): ProcessCpuCensus;
51
+ /**
52
+ * Per-thread ticks for THIS process, or `null` where that cannot be read.
53
+ *
54
+ * `/proc/self/task/<tid>/stat` is `pid (comm) state ppid …`, and `comm` may
55
+ * itself contain spaces and parentheses — so the split is on the LAST `)`,
56
+ * never on whitespace. `utime` and `stime` are the 12th and 13th fields after
57
+ * it. Everything that can fail is inside the try: a non-Linux platform, a
58
+ * container with `hidepid`, a thread that exits between the readdir and the
59
+ * read. A thread that vanishes mid-scan is skipped rather than failing the
60
+ * whole reading — it contributed to neither snapshot's total.
61
+ */
62
+ export declare function readSelfTaskTicks(): readonly TaskTicks[] | null;
63
+ /**
64
+ * The two fields, APPENDED LAST on the `[mem]` line — after everything D446,
65
+ * D456 and D458 appended, so every Loki prefix written since 2026-08-29 still
66
+ * matches (D446's rule).
67
+ *
68
+ * `procCpu` prints whenever there is a window, including at 0.0 %, because an
69
+ * idle process is a reading and it is the one that says a runner is alive and
70
+ * doing nothing. `v8WorkerCpu` is CONDITIONAL and its absence is the reading:
71
+ * the platform could not be asked. It carries its thread count because "36.6 %
72
+ * over four threads" and "36.6 % on one" are different faults.
73
+ */
74
+ export declare function formatProcessCpu(reading: ProcessCpuReading | null | undefined): string;