@camstack/server 1.2.829 → 1.2.831

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 (87) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/package.json +16 -15
  3. package/system/dist/builtins/addon-pages-aggregator/addon-pages-aggregator.addon.js +1 -1
  4. package/system/dist/builtins/addon-pages-aggregator/addon-pages-aggregator.addon.mjs +1 -1
  5. package/system/dist/builtins/addon-widgets-aggregator/addon-widgets-aggregator.addon.js +1 -1
  6. package/system/dist/builtins/addon-widgets-aggregator/addon-widgets-aggregator.addon.mjs +1 -1
  7. package/system/dist/builtins/alerts/alerts.addon.js +1 -1
  8. package/system/dist/builtins/alerts/alerts.addon.mjs +1 -1
  9. package/system/dist/builtins/autotrack/index.js +1 -1
  10. package/system/dist/builtins/autotrack/index.mjs +1 -1
  11. package/system/dist/builtins/backup-orchestrator/backup-orchestrator.addon.js +2 -2
  12. package/system/dist/builtins/backup-orchestrator/backup-orchestrator.addon.mjs +2 -2
  13. package/system/dist/builtins/calendars/calendars.addon.js +1 -1
  14. package/system/dist/builtins/calendars/calendars.addon.mjs +1 -1
  15. package/system/dist/builtins/camera-grid/index.js +1 -1
  16. package/system/dist/builtins/camera-grid/index.mjs +1 -1
  17. package/system/dist/builtins/composer/composer.addon.js +4 -4
  18. package/system/dist/builtins/composer/composer.addon.mjs +4 -4
  19. package/system/dist/builtins/console-logging/index.js +1 -1
  20. package/system/dist/builtins/console-logging/index.mjs +1 -1
  21. package/system/dist/builtins/core-blocks/core-blocks.addon.js +3 -3
  22. package/system/dist/builtins/core-blocks/core-blocks.addon.mjs +3 -3
  23. package/system/dist/builtins/device-history/device-history.addon.js +2 -2
  24. package/system/dist/builtins/device-history/device-history.addon.mjs +2 -2
  25. package/system/dist/builtins/device-manager/device-manager.addon.js +2 -2
  26. package/system/dist/builtins/device-manager/device-manager.addon.mjs +2 -2
  27. package/system/dist/builtins/hub-forwarder/index.js +1 -1
  28. package/system/dist/builtins/hub-forwarder/index.mjs +1 -1
  29. package/system/dist/builtins/keychain/index.js +4 -4
  30. package/system/dist/builtins/keychain/index.mjs +4 -4
  31. package/system/dist/builtins/liveness-monitor/liveness-monitor.addon.js +1 -1
  32. package/system/dist/builtins/liveness-monitor/liveness-monitor.addon.mjs +1 -1
  33. package/system/dist/builtins/local-auth/local-auth.addon.js +2 -2
  34. package/system/dist/builtins/local-auth/local-auth.addon.mjs +2 -2
  35. package/system/dist/builtins/local-network/local-network.addon.js +3 -3
  36. package/system/dist/builtins/local-network/local-network.addon.mjs +3 -3
  37. package/system/dist/builtins/loki-logging/index.js +1 -1
  38. package/system/dist/builtins/loki-logging/index.mjs +1 -1
  39. package/system/dist/builtins/native-metrics/native-metrics.addon.js +1 -1
  40. package/system/dist/builtins/native-metrics/native-metrics.addon.mjs +1 -1
  41. package/system/dist/builtins/platform-probe/index.js +1 -1
  42. package/system/dist/builtins/platform-probe/index.mjs +1 -1
  43. package/system/dist/builtins/record-entries/index.js +1 -1
  44. package/system/dist/builtins/record-entries/index.mjs +1 -1
  45. package/system/dist/builtins/remote-access-orchestrator/remote-access-orchestrator.addon.js +1 -1
  46. package/system/dist/builtins/remote-access-orchestrator/remote-access-orchestrator.addon.mjs +1 -1
  47. package/system/dist/builtins/snapshot/index.js +1 -1
  48. package/system/dist/builtins/snapshot/index.mjs +1 -1
  49. package/system/dist/builtins/sqlite-storage/filesystem-storage.addon.js +1 -1
  50. package/system/dist/builtins/sqlite-storage/filesystem-storage.addon.mjs +1 -1
  51. package/system/dist/builtins/sqlite-storage/index.js +1 -1
  52. package/system/dist/builtins/sqlite-storage/index.mjs +1 -1
  53. package/system/dist/builtins/sqlite-storage/sqlite-settings.addon.js +3 -3
  54. package/system/dist/builtins/sqlite-storage/sqlite-settings.addon.mjs +3 -3
  55. package/system/dist/builtins/storage-orchestrator/storage-orchestrator.addon.js +1 -1
  56. package/system/dist/builtins/storage-orchestrator/storage-orchestrator.addon.mjs +1 -1
  57. package/system/dist/builtins/system-config/system-config.addon.js +3 -3
  58. package/system/dist/builtins/system-config/system-config.addon.mjs +3 -3
  59. package/system/dist/builtins/winston-logging/index.js +1 -1
  60. package/system/dist/builtins/winston-logging/index.mjs +1 -1
  61. package/system/dist/{capture-engine-Cvetsl63.js → capture-engine-CAXBK7ww.js} +1 -1
  62. package/system/dist/{capture-engine-CsFrmbpC.mjs → capture-engine-D8AiIjQC.mjs} +1 -1
  63. package/system/dist/{composition-sources-wNOckeFb.js → composition-sources-BunkRPGS.js} +1 -1
  64. package/system/dist/{composition-sources-Yw0KDrdI.mjs → composition-sources-UhXWDHi8.mjs} +1 -1
  65. package/system/dist/{constants-BqrgVNCL.js → constants-B5QCyskv.js} +1 -1
  66. package/system/dist/{constants-B7-Ccoim.mjs → constants-C0KB1WOf.mjs} +1 -1
  67. package/system/dist/{device-ca-C9VMoted.js → device-ca-DJNiUFgb.js} +1 -1
  68. package/system/dist/{device-ca-BDKMOSKW.mjs → device-ca-I_cMOy9W.mjs} +1 -1
  69. package/system/dist/{dist-KJhkakFo.js → dist-BObCeiJC.js} +310 -57
  70. package/system/dist/{dist-Bv_ADY4Y.mjs → dist-BkjJt6LD.mjs} +310 -57
  71. package/system/dist/file-host-worker.js +1 -1
  72. package/system/dist/file-host-worker.mjs +1 -1
  73. package/system/dist/{hub-identity-DSLLzLph.mjs → hub-identity-DOgoRPxv.mjs} +1 -1
  74. package/system/dist/{hub-identity-BS1rzEes.js → hub-identity-QhEXr2sn.js} +1 -1
  75. package/system/dist/{hub-mdns-ciao-FVifxI5j.mjs → hub-mdns-ciao-CHGaz6Vj.mjs} +2 -2
  76. package/system/dist/{hub-mdns-ciao-BQh04Eo9.js → hub-mdns-ciao-L9Qt3eVs.js} +2 -2
  77. package/system/dist/index.js +8 -8
  78. package/system/dist/index.mjs +8 -8
  79. package/system/dist/{legacy-integration-rows-door-B3K3A9JU.js → legacy-integration-rows-door-4SwHHOO6.js} +1 -1
  80. package/system/dist/{legacy-integration-rows-door-Cu9uee1R.mjs → legacy-integration-rows-door-tl15MjSN.mjs} +1 -1
  81. package/system/dist/{rename-composition-block-31JmUak2.js → rename-composition-block-BRlgC6CC.js} +1 -1
  82. package/system/dist/{rename-composition-block-BglTrMYB.mjs → rename-composition-block-DunKva8Y.mjs} +1 -1
  83. package/system/dist/{restore-archive-BHOc02Fh.js → restore-archive-DDeWKKhR.js} +1 -1
  84. package/system/dist/{restore-archive-5UHNYi4u.mjs → restore-archive-ZLiUoIzW.mjs} +1 -1
  85. package/system/dist/{wal-maintenance-COJdLp-y.mjs → wal-maintenance-7Zug5GTs.mjs} +0 -0
  86. package/system/dist/{wal-maintenance-At5TeYwr.js → wal-maintenance-CXx0PMNE.js} +0 -0
  87. package/system/package.json +1 -1
@@ -43385,6 +43385,92 @@ function zoneOnlySite(timeZone) {
43385
43385
  timeZone
43386
43386
  };
43387
43387
  }
43388
+ /**
43389
+ * Hold semantics — "for N seconds" on a leaf of the `when` tree (#498).
43390
+ *
43391
+ * ONE primitive, `for: { ms, mode, tolerance? }`, shared by `device-becomes`,
43392
+ * `device-is` and `expression`:
43393
+ *
43394
+ * - `held`: the condition stays true for `ms`;
43395
+ * - `stable`: the value does not move by more than `tolerance` (absolute, in
43396
+ * the field's base unit) for `ms` while the condition holds.
43397
+ *
43398
+ * {@link HoldCore} is the pure state machine (an input observation → a reading).
43399
+ * {@link HoldTracker} keys cores by a leaf path for the STATE leaves the tree
43400
+ * evaluator judges. {@link BecomesWatch} wraps a core with a timer for the
43401
+ * `device-becomes` EVENT leaf: the deadline is armed when the hold starts and
43402
+ * cancelled when it breaks, and the leaf fires ONCE per episode.
43403
+ *
43404
+ * Hold state is memory only. A hold that is already running when the watcher
43405
+ * first looks (a restart) is INHERITED: nobody knows when it began, so it never
43406
+ * fires for that episode and a state leaf reads it as unknown until the window
43407
+ * has elapsed from the moment the watcher started (D49: not-known is not false).
43408
+ */
43409
+ var HOLD_MAX_MS = 864e5;
43410
+ var HoldModeSchema = z.enum(["held", "stable"]);
43411
+ var HoldSpecSchema = z.object({
43412
+ /** How long the condition (or the value) must hold. */
43413
+ ms: z.number().int().min(1).max(HOLD_MAX_MS),
43414
+ mode: HoldModeSchema,
43415
+ /** `stable` only: the largest move of the value that still counts as unchanged (absolute, base unit). */
43416
+ tolerance: z.number().min(0).optional()
43417
+ });
43418
+ /** What a trace says about a hold. */
43419
+ var HoldTraceSchema = z.object({
43420
+ phase: z.enum([
43421
+ "pending",
43422
+ "cancelled",
43423
+ "fired",
43424
+ "reseeded"
43425
+ ]),
43426
+ ms: z.number().int(),
43427
+ mode: HoldModeSchema,
43428
+ /** When the hold started (ms epoch). */
43429
+ since: z.number().optional(),
43430
+ /** When it completes (ms epoch), for a pending hold. */
43431
+ deadline: z.number().optional()
43432
+ });
43433
+ /** `30 s`, `5 min`, `1 h 5 min` — a hold window for a human. */
43434
+ function describeHoldMs(ms) {
43435
+ const s = Math.round(ms / 1e3);
43436
+ if (s < 60) return `${s} s`;
43437
+ const m = Math.floor(s / 60);
43438
+ const rest = s % 60;
43439
+ if (m < 60) return rest === 0 ? `${m} min` : `${m} min ${rest} s`;
43440
+ const h = Math.floor(m / 60);
43441
+ return m % 60 === 0 ? `${h} h` : `${h} h ${m % 60} min`;
43442
+ }
43443
+ /** The operators a `device-becomes` leaf may carry: a threshold or a range. */
43444
+ var BecomesOperatorSchema = z.enum([
43445
+ "eq",
43446
+ "ne",
43447
+ "gt",
43448
+ "gte",
43449
+ "lt",
43450
+ "lte",
43451
+ "between",
43452
+ "outside"
43453
+ ]);
43454
+ function compareValues(actual, operator, expected) {
43455
+ switch (operator) {
43456
+ case "eq": return actual === expected;
43457
+ case "ne": return actual !== expected;
43458
+ case "gt": return typeof actual === "number" && typeof expected === "number" && actual > expected;
43459
+ case "gte": return typeof actual === "number" && typeof expected === "number" && actual >= expected;
43460
+ case "lt": return typeof actual === "number" && typeof expected === "number" && actual < expected;
43461
+ case "lte": return typeof actual === "number" && typeof expected === "number" && actual <= expected;
43462
+ case "contains": return typeof actual === "string" && typeof expected === "string" && actual.includes(expected);
43463
+ case "in": return Array.isArray(expected) && expected.some((v) => v === actual);
43464
+ case "between":
43465
+ case "outside": {
43466
+ if (typeof actual !== "number" || !Array.isArray(expected)) return false;
43467
+ const [low, high] = expected;
43468
+ if (typeof low !== "number" || typeof high !== "number") return false;
43469
+ const inside = actual >= low && actual <= high;
43470
+ return operator === "between" ? inside : !inside;
43471
+ }
43472
+ }
43473
+ }
43388
43474
  /** How a state leaf compares a device field to a value. Derived from the
43389
43475
  * field's `kind` in `deviceManager.getWireableFields`, never hand-maintained. */
43390
43476
  var AutomationConditionOperatorSchema = z.enum([
@@ -43408,18 +43494,52 @@ var DeviceBecomesLeafSchema = z.object({
43408
43494
  deviceId: z.number().int().nonnegative(),
43409
43495
  cap: z.string().min(1),
43410
43496
  fieldPath: z.string().min(1),
43411
- /** Fire when the field takes this value. Omit to fire on any change. */
43497
+ /** Fire when the field takes this value. Omit (with no `operator`) to fire on any change. */
43412
43498
  becomes: z.union([
43413
43499
  z.string(),
43414
43500
  z.number(),
43415
43501
  z.boolean()
43416
43502
  ]).optional(),
43417
- /** Only on a CHANGE of value, not on every re-report. */
43503
+ /**
43504
+ * A threshold or a range instead of an equality: "crosses above 3000", "enters
43505
+ * 18..24". The leaf fires on the TRANSITION into the predicate, never on a re-report.
43506
+ * `value` is in the field's base unit; `between` / `outside` take `[low, high]`.
43507
+ */
43508
+ operator: BecomesOperatorSchema.optional(),
43509
+ value: z.union([
43510
+ z.number(),
43511
+ z.string(),
43512
+ z.boolean(),
43513
+ z.array(z.number()).length(2)
43514
+ ]).optional(),
43515
+ /**
43516
+ * Hold: the transition (or, with no predicate, the new value) must stay for
43517
+ * `for.ms` before the leaf fires, ONCE per episode. See `hold.ts`.
43518
+ */
43519
+ for: HoldSpecSchema.optional(),
43520
+ /** @deprecated every leaf fires on a transition now; read as always on. */
43418
43521
  edge: z.boolean().optional(),
43419
- /** The new value must hold this long before it counts. */
43420
- forMs: z.number().int().min(0).max(864e5).optional(),
43522
+ /** @deprecated legacy `held` window — read through `holdOf` as `for: { ms, mode: 'held' }`. */
43523
+ forMs: z.number().int().min(0).max(HOLD_MAX_MS).optional(),
43421
43524
  /** Collapse a burst into one occurrence. */
43422
43525
  debounceMs: z.number().int().min(0).max(6e5).optional()
43526
+ }).superRefine((leaf, ctx) => {
43527
+ if (leaf.becomes !== void 0 && leaf.operator !== void 0) ctx.addIssue({
43528
+ code: "custom",
43529
+ message: "a leaf names `becomes` or `operator`, not both",
43530
+ path: ["operator"]
43531
+ });
43532
+ if (leaf.operator !== void 0 && leaf.value === void 0) ctx.addIssue({
43533
+ code: "custom",
43534
+ message: "an operator needs the value to compare to",
43535
+ path: ["value"]
43536
+ });
43537
+ const range = leaf.operator === "between" || leaf.operator === "outside";
43538
+ if (leaf.operator !== void 0 && range !== Array.isArray(leaf.value)) ctx.addIssue({
43539
+ code: "custom",
43540
+ message: range ? "a range takes [low, high]" : "only a range takes [low, high]",
43541
+ path: ["value"]
43542
+ });
43423
43543
  });
43424
43544
  var DeviceEventLeafSchema = z.object({
43425
43545
  kind: z.literal("device-event"),
@@ -43484,7 +43604,9 @@ var DeviceIsLeafSchema = z.object({
43484
43604
  QuantityValueSchema
43485
43605
  ]),
43486
43606
  /** The unit the person picked for `value` (display only; `value` is in the base unit). */
43487
- unit: z.string().min(1).optional()
43607
+ unit: z.string().min(1).optional(),
43608
+ /** The comparison must hold (`held`) or the value stay put (`stable`) this long. */
43609
+ for: HoldSpecSchema.optional()
43488
43610
  });
43489
43611
  /**
43490
43612
  * True when the camera currently has a PARKED object matching `subjects` in at
@@ -43507,7 +43629,9 @@ var StationaryPresentLeafSchema = z.object({
43507
43629
  var ExpressionLeafSchema = z.object({
43508
43630
  kind: z.literal("expression"),
43509
43631
  expr: z.string().min(1).max(MAX_EXPRESSION_SOURCE_LENGTH),
43510
- bindings: z.record(z.string().regex(EXPRESSION_IDENTIFIER_RE), ExpressionBindingSourceSchema)
43632
+ bindings: z.record(z.string().regex(EXPRESSION_IDENTIFIER_RE), ExpressionBindingSourceSchema),
43633
+ /** The expression must stay true this long. An expression has no single value, so only `held`. */
43634
+ for: HoldSpecSchema.optional()
43511
43635
  }).superRefine((src, ctx) => {
43512
43636
  const err = validateExpressionSource(src);
43513
43637
  if (err !== null) ctx.addIssue({
@@ -43515,6 +43639,11 @@ var ExpressionLeafSchema = z.object({
43515
43639
  message: err,
43516
43640
  path: ["expr"]
43517
43641
  });
43642
+ if (src.for?.mode === "stable") ctx.addIssue({
43643
+ code: "custom",
43644
+ message: "an expression is held, not stable: it has no single value to keep still",
43645
+ path: ["for", "mode"]
43646
+ });
43518
43647
  });
43519
43648
  var AutomationWhenSchema = z.lazy(() => z.discriminatedUnion("kind", [
43520
43649
  z.object({
@@ -44064,28 +44193,6 @@ function convertLegacyRecipe(legacy) {
44064
44193
  * it. The output type is always the new one.
44065
44194
  */
44066
44195
  var AutomationRecipeSchema = z.union([CurrentAutomationRecipeSchema, LegacyAutomationRecipeSchema.transform(convertLegacyRecipe)]);
44067
- var DETECTION_DESCRIPTIONS = {
44068
- deviceId: "the camera that saw it",
44069
- className: "what it saw",
44070
- trackId: "the track",
44071
- score: "how sure the detector was",
44072
- label: "the label it matched (a name, a plate), empty when none"
44073
- };
44074
- var STATIONARY_DESCRIPTIONS = {
44075
- deviceId: "the camera that saw it",
44076
- className: "what it saw",
44077
- zones: "the zones it is in",
44078
- phase: "appeared or departed",
44079
- entryId: "the stopped object"
44080
- };
44081
- function describe$1(descriptions) {
44082
- return Object.entries(descriptions).map(([name, description]) => ({
44083
- name,
44084
- description
44085
- }));
44086
- }
44087
- describe$1(DETECTION_DESCRIPTIONS);
44088
- describe$1(STATIONARY_DESCRIPTIONS);
44089
44196
  /**
44090
44197
  * Evaluating an automation's condition tree against the ConditionMirror.
44091
44198
  *
@@ -44264,18 +44371,7 @@ var OPERATOR_SYMBOL = {
44264
44371
  contains: "contains",
44265
44372
  in: "in"
44266
44373
  };
44267
- function compare(actual, operator, expected) {
44268
- switch (operator) {
44269
- case "eq": return actual === expected;
44270
- case "ne": return actual !== expected;
44271
- case "gt": return typeof actual === "number" && typeof expected === "number" && actual > expected;
44272
- case "gte": return typeof actual === "number" && typeof expected === "number" && actual >= expected;
44273
- case "lt": return typeof actual === "number" && typeof expected === "number" && actual < expected;
44274
- case "lte": return typeof actual === "number" && typeof expected === "number" && actual <= expected;
44275
- case "contains": return typeof actual === "string" && typeof expected === "string" && actual.includes(expected);
44276
- case "in": return Array.isArray(expected) && expected.some((v) => v === actual);
44277
- }
44278
- }
44374
+ var compare = compareValues;
44279
44375
  function toTraceValue(value) {
44280
44376
  if (value === void 0 || value === null) return null;
44281
44377
  if (typeof value === "string" || typeof value === "number" || typeof value === "boolean") return value;
@@ -44364,6 +44460,42 @@ function judgeStationaryPresent(cond, reader) {
44364
44460
  why: `${parked.length} parked on device ${cond.deviceId}, none matching the class/zone filter`
44365
44461
  };
44366
44462
  }
44463
+ function noteDue(state, hold) {
44464
+ if (hold?.due === void 0) return;
44465
+ state.holdDueInMs = state.holdDueInMs === void 0 ? hold.due : Math.min(state.holdDueInMs, hold.due);
44466
+ }
44467
+ /** What a state leaf's hold says, given whether the leaf's own condition is true NOW. */
44468
+ function judgeHold(hold, reading, conditionTrue) {
44469
+ const window = `${hold.mode === "stable" ? "stable" : "held"} for ${describeHoldMs(hold.ms)}`;
44470
+ if (reading === void 0) return {
44471
+ pass: false,
44472
+ unknown: true,
44473
+ why: `${window}: nothing keeps this leaf's history here`
44474
+ };
44475
+ switch (reading.phase) {
44476
+ case "met": return {
44477
+ pass: true,
44478
+ unknown: false,
44479
+ why: `${window}: met`
44480
+ };
44481
+ case "pending": return {
44482
+ due: reading.remainingMs,
44483
+ pass: false,
44484
+ unknown: false,
44485
+ why: `${window}: ${describeHoldMs(hold.ms - reading.remainingMs)} so far`
44486
+ };
44487
+ case "inherited": return {
44488
+ pass: false,
44489
+ unknown: true,
44490
+ why: `${window}: it was already true when watching began, so how long it has held is not known`
44491
+ };
44492
+ case "idle": return {
44493
+ pass: false,
44494
+ unknown: false,
44495
+ why: conditionTrue ? `${window}: just changed` : `${window}: the condition is not true`
44496
+ };
44497
+ }
44498
+ }
44367
44499
  function evalEventLeaf(cond, path, state, out) {
44368
44500
  const occurred = state.firedPath === path;
44369
44501
  out.push({
@@ -44406,11 +44538,18 @@ function evalNode(cond, path, reader, now, out, state) {
44406
44538
  });
44407
44539
  return false;
44408
44540
  }
44409
- const ok = compare(observed, cond.operator, cond.value);
44541
+ const compared = compare(observed, cond.operator, cond.value);
44542
+ const hold = cond.for === void 0 ? void 0 : judgeHold(cond.for, state.holds?.observe(path, cond.for, {
44543
+ holds: compared,
44544
+ value: observed
44545
+ }, now), compared);
44546
+ if (hold?.unknown === true) state.unknown = true;
44547
+ noteDue(state, hold);
44548
+ const ok = compared && (hold === void 0 || hold.pass);
44410
44549
  out.push({
44411
44550
  ...base,
44412
44551
  outcome: ok ? "pass" : "fail",
44413
- reason: `${cond.fieldPath} ${show(observed)}, expected ${OPERATOR_SYMBOL[cond.operator]} ${show(cond.value)} → ${ok ? "pass" : "fail"}`
44552
+ reason: `${cond.fieldPath} ${show(observed)}, expected ${OPERATOR_SYMBOL[cond.operator]} ${show(cond.value)}${hold === void 0 ? "" : ` (${hold.why})`} → ${ok ? "pass" : "fail"}`
44414
44553
  });
44415
44554
  return ok;
44416
44555
  }
@@ -44457,12 +44596,19 @@ function evalNode(cond, path, reader, now, out, state) {
44457
44596
  });
44458
44597
  return false;
44459
44598
  }
44460
- const ok = result.value === true;
44599
+ const truth = result.value === true;
44600
+ const hold = cond.for === void 0 ? void 0 : judgeHold(cond.for, state.holds?.observe(path, cond.for, {
44601
+ holds: truth,
44602
+ value: truth
44603
+ }, now), truth);
44604
+ if (hold?.unknown === true) state.unknown = true;
44605
+ noteDue(state, hold);
44606
+ const ok = truth && (hold === void 0 || hold.pass);
44461
44607
  out.push({
44462
44608
  path,
44463
44609
  kind: cond.kind,
44464
44610
  outcome: ok ? "pass" : "fail",
44465
- reason: `${cond.expr} with ${JSON.stringify(values)} → ${ok ? "pass" : "fail"}`
44611
+ reason: `${cond.expr} with ${JSON.stringify(values)}${hold === void 0 ? "" : ` (${hold.why})`} → ${ok ? "pass" : "fail"}`
44466
44612
  });
44467
44613
  return ok;
44468
44614
  }
@@ -44522,14 +44668,39 @@ function evaluateWhenTree(when, reader, now, options = {}) {
44522
44668
  const nodes = [];
44523
44669
  const state = {
44524
44670
  firedPath: options.firedPath,
44525
- unknown: false
44671
+ holds: options.holds,
44672
+ unknown: false,
44673
+ holdDueInMs: void 0
44526
44674
  };
44527
44675
  return {
44528
44676
  pass: evalNode(when, options.rootPath ?? "when", reader, now, nodes, state),
44529
44677
  unknown: state.unknown,
44530
- nodes
44678
+ nodes,
44679
+ ...state.holdDueInMs === void 0 ? {} : { holdDueInMs: state.holdDueInMs }
44531
44680
  };
44532
44681
  }
44682
+ var DETECTION_DESCRIPTIONS = {
44683
+ deviceId: "the camera that saw it",
44684
+ className: "what it saw",
44685
+ trackId: "the track",
44686
+ score: "how sure the detector was",
44687
+ label: "the label it matched (a name, a plate), empty when none"
44688
+ };
44689
+ var STATIONARY_DESCRIPTIONS = {
44690
+ deviceId: "the camera that saw it",
44691
+ className: "what it saw",
44692
+ zones: "the zones it is in",
44693
+ phase: "appeared or departed",
44694
+ entryId: "the stopped object"
44695
+ };
44696
+ function describe$1(descriptions) {
44697
+ return Object.entries(descriptions).map(([name, description]) => ({
44698
+ name,
44699
+ description
44700
+ }));
44701
+ }
44702
+ describe$1(DETECTION_DESCRIPTIONS);
44703
+ describe$1(STATIONARY_DESCRIPTIONS);
44533
44704
  new Set(Object.values(COCO_TO_MACRO.mapping));
44534
44705
  /**
44535
44706
  * Schedulers (D983) — an entity that performs actions over the day.
@@ -44854,7 +45025,9 @@ var AutomationTriggerTraceSchema = z.object({
44854
45025
  /** Why an event was rejected ("class person not in [dog]") or what fired. */
44855
45026
  reason: z.string(),
44856
45027
  /** deviceId, className, trackId, score … — only what the trigger exposes. */
44857
- vars: z.record(z.string(), TraceValueSchema)
45028
+ vars: z.record(z.string(), TraceValueSchema),
45029
+ /** A hold (`for`) this occurrence went through: pending, cancelled, fired or re-seeded. */
45030
+ hold: HoldTraceSchema.optional()
44858
45031
  });
44859
45032
  var AutomationConditionTraceNodeSchema = z.object({
44860
45033
  /** `when` for the root, `when.<i>` for its i-th child, … (`conditions…` on an old trace). */
@@ -45302,10 +45475,13 @@ var ActionRunChangedSchema = z.object({
45302
45475
  * nothing, and never decides a branch).
45303
45476
  */
45304
45477
  /** Fill a mirror for the tree's leaves from `fetchers` and judge it NOW. */
45305
- async function evaluateStepCondition(when, fetchers, now = Date.now) {
45306
- const mirror = new ConditionMirror(collectWhenMirrorSources(when));
45478
+ async function evaluateStepCondition(when, fetchers, now = Date.now, history) {
45479
+ const mirror = history?.mirror ?? new ConditionMirror(collectWhenMirrorSources(when));
45307
45480
  await mirror.refresh(fetchers);
45308
- const evaluation = evaluateWhenTree(when, mirror, now());
45481
+ const evaluation = evaluateWhenTree(when, mirror, now(), { ...history === void 0 ? {} : {
45482
+ holds: history.holds,
45483
+ rootPath: history.rootPath
45484
+ } });
45309
45485
  const first = evaluation.nodes.filter((n) => n.outcome !== "pass").map((n) => n.reason)[0];
45310
45486
  if (evaluation.unknown) return {
45311
45487
  result: "unknown",
@@ -64776,13 +64952,11 @@ var HeroConfirmSchema = z.enum([
64776
64952
  "press"
64777
64953
  ]);
64778
64954
  var HeroActionSchema = z.object({
64779
- /** Unique within the model; the `gated` list and the specs name it. */
64780
64955
  id: z.string(),
64781
64956
  label: HeroTextSchema,
64782
64957
  icon: IconKeySchema,
64783
64958
  call: HeroCallSchema,
64784
64959
  emphasis: z.enum(["primary", "normal"]),
64785
- /** Ask before running it. */
64786
64960
  confirm: HeroConfirmSchema.nullable()
64787
64961
  });
64788
64962
  var HeroControlSchema = z.discriminatedUnion("kind", [
@@ -64878,9 +65052,18 @@ var HeroBadgeSchema = z.object({
64878
65052
  value: z.number().nullable(),
64879
65053
  label: HeroTextSchema
64880
65054
  });
64881
- var HeroRemoteSlotSchema = z.object({
64882
- /** Saved commands; `null` = not known yet (the button still shows). */
64883
- commands: z.number().int().nullable() });
65055
+ /** The id of the action a row recognises as "open the device's remote". */
65056
+ var REMOTE_OPEN_ACTION_ID = "remote.open";
65057
+ var HeroRemoteSlotSchema = z.object({
65058
+ /** Saved commands; `null` = not known yet (the button still shows). */
65059
+ commands: z.number().int().nullable(),
65060
+ /**
65061
+ * The control a list row draws as the "open the remote" icon. Recognised by its id
65062
+ * ({@link REMOTE_OPEN_ACTION_ID}); it changes no state, so a client opens the remote
65063
+ * instead of running `call`. Absent on a model from an older server.
65064
+ */
65065
+ open: HeroActionSchema.optional()
65066
+ });
64884
65067
  var HeroConsumableItemSchema = z.object({
64885
65068
  key: z.string(),
64886
65069
  label: z.string(),
@@ -65049,6 +65232,8 @@ var HeroModelSchema = z.object({
65049
65232
  * the FIRST row that has any (a later row's control is never promoted). When
65050
65233
  * the model lists that part in `gated`, the row has no inline control: the
65051
65234
  * projection never falls through to another control the caller could use.
65235
+ * - a climate or thermostat row's primary is its `climate.mode` control (no power
65236
+ * toggle: "off" is a mode); when the model gates it the rule above applies as before;
65052
65237
  * - a timed run, when the model carries the slot, sits beside that primary:
65053
65238
  * Run while idle, Stop while armed. Gating the slot hides the control.
65054
65239
  * - the status line is the head (what plays, else the state) plus at most
@@ -65056,6 +65241,13 @@ var HeroModelSchema = z.object({
65056
65241
  * time left on an armed timed run;
65057
65242
  * - the trailing fact is the first of power, battery, consumables.
65058
65243
  *
65244
+ * - `extras` are the further inline controls of the types that carry more than one
65245
+ * ({@link ROW_EXTRAS_BY_TYPE}): climate setpoint, a robot's return to base,
65246
+ * a player's volume and remote. Each is a control the model already has, named by id,
65247
+ * in that order and at most {@link ROW_EXTRAS_MAX}; one the model lacks, or lists in
65248
+ * `gated`, is absent, and the one `primary` already is never repeats. Empty = the
65249
+ * row of an older server: `primary` alone.
65250
+ *
65059
65251
  * `projectDeviceRow` is pure and computes nothing: it selects from a
65060
65252
  * {@link HeroModel}. A row that needed a value the hero lacks would mean the
65061
65253
  * model is missing it, so the fix goes in the model.
@@ -65087,6 +65279,12 @@ var HeroRowModelSchema = z.object({
65087
65279
  * while armed. `null` when there is no slot, or the caller may not act.
65088
65280
  */
65089
65281
  timedRun: HeroRowTimedRunSchema.nullable(),
65282
+ /**
65283
+ * The further inline controls after `primary`, in order (see the header). The remote
65284
+ * is an `action` with id `remote.open`: the client opens the remote, it does not run
65285
+ * the call. Absent or empty = `primary` alone.
65286
+ */
65287
+ extras: z.array(HeroControlSchema).max(2).optional(),
65090
65288
  trailing: HeroFactSchema.nullable()
65091
65289
  });
65092
65290
  /** The trailing fact, in order of preference. */
@@ -65102,7 +65300,20 @@ function trailingOf(facts) {
65102
65300
  }
65103
65301
  return null;
65104
65302
  }
65303
+ /**
65304
+ * A type whose primary is a named control, not its power: a climate row is the mode
65305
+ * (which carries "off") and the setpoint, with no power toggle.
65306
+ */
65307
+ var ROW_PRIMARY_BY_TYPE = {
65308
+ [DeviceType.Climate]: "climate.mode",
65309
+ [DeviceType.Thermostat]: "climate.mode"
65310
+ };
65105
65311
  function primaryOf(model) {
65312
+ const named = ROW_PRIMARY_BY_TYPE[model.type];
65313
+ if (named !== void 0) {
65314
+ const found = extraOf(model, named);
65315
+ if (found !== null) return found;
65316
+ }
65106
65317
  const power = model.ownPower;
65107
65318
  if (power !== null) {
65108
65319
  if (model.gated.includes("own-power")) return null;
@@ -65122,6 +65333,43 @@ function primaryOf(model) {
65122
65333
  }
65123
65334
  return null;
65124
65335
  }
65336
+ /**
65337
+ * The extras of a type, by control id, in the order they are drawn. The ids are the
65338
+ * model's own: a `remote.open` is read from the model's remote slot, every other
65339
+ * from the rows. A type not listed has no extras.
65340
+ */
65341
+ var ROW_EXTRAS_BY_TYPE = {
65342
+ [DeviceType.Climate]: ["climate.target"],
65343
+ [DeviceType.Thermostat]: ["climate.target"],
65344
+ [DeviceType.Vacuum]: ["vacuum.base"],
65345
+ [DeviceType.LawnMower]: ["mower.dock"],
65346
+ [DeviceType.MediaPlayer]: ["volume.level", REMOTE_OPEN_ACTION_ID]
65347
+ };
65348
+ var controlId = (c) => c.kind === "action" ? c.action.id : c.id;
65349
+ function extraOf(model, id) {
65350
+ if (id === "remote.open") {
65351
+ const open = model.remote?.open;
65352
+ if (open === void 0 || model.gated.includes("remote")) return null;
65353
+ return {
65354
+ kind: "action",
65355
+ action: open
65356
+ };
65357
+ }
65358
+ for (const row of model.rows) {
65359
+ if (model.gated.includes(row.id)) continue;
65360
+ const found = row.controls.find((c) => controlId(c) === id);
65361
+ if (found !== void 0) return found;
65362
+ }
65363
+ return null;
65364
+ }
65365
+ function extrasOf(model, primary) {
65366
+ const ids = ROW_EXTRAS_BY_TYPE[model.type] ?? [];
65367
+ const taken = primary === null ? null : controlId(primary);
65368
+ return ids.filter((id) => id !== taken).flatMap((id) => {
65369
+ const found = extraOf(model, id);
65370
+ return found === null ? [] : [found];
65371
+ }).slice(0, 2);
65372
+ }
65125
65373
  function statusLineOf(model, trailing) {
65126
65374
  const head = model.rows.find((r) => r.id === "now-playing")?.status ?? null ?? model.title;
65127
65375
  const rest = model.facts.filter((f) => f !== trailing).map((f) => f.text).slice(0, 3);
@@ -65150,6 +65398,7 @@ function timedRunOf(model) {
65150
65398
  }
65151
65399
  function projectDeviceRow(model) {
65152
65400
  const trailing = trailingOf(model.facts);
65401
+ const primary = primaryOf(model);
65153
65402
  return {
65154
65403
  deviceId: model.deviceId,
65155
65404
  name: model.name,
@@ -65159,8 +65408,9 @@ function projectDeviceRow(model) {
65159
65408
  look: model.look,
65160
65409
  scene: model.scene,
65161
65410
  statusLine: statusLineOf(model, trailing),
65162
- primary: primaryOf(model),
65411
+ primary,
65163
65412
  timedRun: timedRunOf(model),
65413
+ extras: extrasOf(model, primary),
65164
65414
  trailing
65165
65415
  };
65166
65416
  }
@@ -101480,7 +101730,10 @@ var powerSourceContribution = contribution("power-source", PowerSourceStateSchem
101480
101730
  /** The remote cap has no status: the model's input carries how many commands it holds. */
101481
101731
  var remoteContribution = {
101482
101732
  cap: "remote",
101483
- contribute: (_slice, ctx) => ctx.remoteCommands === 0 ? {} : { remote: { commands: ctx.remoteCommands } }
101733
+ contribute: (_slice, ctx) => ctx.remoteCommands === 0 ? {} : { remote: {
101734
+ commands: ctx.remoteCommands,
101735
+ open: action(REMOTE_OPEN_ACTION_ID, t("Remote", "Telecomando"), "gamepad-2", "remote", "open")
101736
+ } }
101484
101737
  };
101485
101738
  var ATTENTION_STATUSES = [
101486
101739
  "low",
@@ -1,5 +1,5 @@
1
1
  require("./chunk-Cek0wNdY.js");
2
- const require_wal_maintenance = require("./wal-maintenance-At5TeYwr.js");
2
+ const require_wal_maintenance = require("./wal-maintenance-CXx0PMNE.js");
3
3
  let node_worker_threads = require("node:worker_threads");
4
4
  //#region src/builtins/sqlite-storage/file-host-worker.ts
5
5
  /**
@@ -1,4 +1,4 @@
1
- import { A as callRecords, C as isFileHostWorkerData, D as RecordsEngine, M as controlTargetOf, O as callControl, S as isFileHostRequest, a as WalMaintenance, b as collectTransferables, d as callMigrate, f as migrateTargetOf, j as callVector, k as callData, l as SqliteSettingsBackend, o as createVectorIndex, s as vectorProviderOf, u as HUB_MIGRATIONS, v as serializeError, w as trustInput } from "./wal-maintenance-COJdLp-y.mjs";
1
+ import { A as callRecords, C as isFileHostWorkerData, D as RecordsEngine, M as controlTargetOf, O as callControl, S as isFileHostRequest, a as WalMaintenance, b as collectTransferables, d as callMigrate, f as migrateTargetOf, j as callVector, k as callData, l as SqliteSettingsBackend, o as createVectorIndex, s as vectorProviderOf, u as HUB_MIGRATIONS, v as serializeError, w as trustInput } from "./wal-maintenance-7Zug5GTs.mjs";
2
2
  import { parentPort, threadId, workerData } from "node:worker_threads";
3
3
  //#region src/builtins/sqlite-storage/file-host-worker.ts
4
4
  /**
@@ -1,4 +1,4 @@
1
- import { mc as defineRecordKinds } from "./dist-Bv_ADY4Y.mjs";
1
+ import { mc as defineRecordKinds } from "./dist-BkjJt6LD.mjs";
2
2
  import { C as backdatedNotBefore, S as withUtcTimeEncoding, _ as NameConstraints, a as KeyUsageFlags, c as Pkcs10CertificateRequest, d as SubjectKeyIdentifierExtension, f as X509Certificate$1, g as GeneralSubtrees, h as GeneralSubtree, i as Extension, l as Pkcs10CertificateRequestGenerator, m as cryptoProvider, n as BasicConstraintsExtension, o as KeyUsagesExtension, p as X509CertificateGenerator, r as ExtendedKeyUsageExtension, s as PemConverter, t as AuthorityKeyIdentifierExtension, u as SubjectAlternativeNameExtension, v as GeneralName, x as AsnConvert } from "./x509.es-BRiJgOvu.mjs";
3
3
  import { z } from "zod";
4
4
  import { X509Certificate, createHash, createPrivateKey, randomBytes, webcrypto } from "node:crypto";
@@ -1,5 +1,5 @@
1
1
  const require_chunk = require("./chunk-Cek0wNdY.js");
2
- const require_dist = require("./dist-KJhkakFo.js");
2
+ const require_dist = require("./dist-BObCeiJC.js");
3
3
  const require_x509_es = require("./x509.es-WtnRNyYS.js");
4
4
  let zod = require("zod");
5
5
  let node_crypto = require("node:crypto");
@@ -1,7 +1,7 @@
1
1
  import { o as __toESM } from "./chunk-CNf5ZN-e.mjs";
2
- import { il as userError } from "./dist-Bv_ADY4Y.mjs";
2
+ import { il as userError } from "./dist-BkjJt6LD.mjs";
3
3
  import { f as X509Certificate$1 } from "./x509.es-BRiJgOvu.mjs";
4
- import { A as evaluateExistingCert, C as localCaCommonName, F as isConstrainedCa, L as permitsIdentity, S as loadCa, b as generateCa, j as reasonRequiresNewCa, w as collectCertIdentity, x as issueLeaf, z as readNameConstraints } from "./hub-identity-DSLLzLph.mjs";
4
+ import { A as evaluateExistingCert, C as localCaCommonName, F as isConstrainedCa, L as permitsIdentity, S as loadCa, b as generateCa, j as reasonRequiresNewCa, w as collectCertIdentity, x as issueLeaf, z as readNameConstraints } from "./hub-identity-DOgoRPxv.mjs";
5
5
  import { X509Certificate, createPrivateKey } from "node:crypto";
6
6
  import { writeOwnerOnlyFileSync } from "@camstack/types/node";
7
7
  import { copyFileSync, existsSync, mkdirSync, readFileSync, renameSync, rmSync, writeFileSync } from "node:fs";
@@ -1,7 +1,7 @@
1
1
  const require_chunk = require("./chunk-Cek0wNdY.js");
2
- const require_dist = require("./dist-KJhkakFo.js");
2
+ const require_dist = require("./dist-BObCeiJC.js");
3
3
  const require_x509_es = require("./x509.es-WtnRNyYS.js");
4
- const require_hub_identity = require("./hub-identity-BS1rzEes.js");
4
+ const require_hub_identity = require("./hub-identity-QhEXr2sn.js");
5
5
  let node_crypto = require("node:crypto");
6
6
  let _camstack_types_node = require("@camstack/types/node");
7
7
  let node_fs = require("node:fs");
@@ -1,7 +1,7 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
2
  const require_chunk = require("./chunk-Cek0wNdY.js");
3
- const require_dist = require("./dist-KJhkakFo.js");
4
- const require_device_ca = require("./device-ca-C9VMoted.js");
3
+ const require_dist = require("./dist-BObCeiJC.js");
4
+ const require_device_ca = require("./device-ca-DJNiUFgb.js");
5
5
  const require_read_all_rows$1 = require("./read-all-rows-CVoO1ONM.js");
6
6
  const require_log_redactor = require("./log-redactor-BhIEMaG9.js");
7
7
  const require_builtins_alerts_alerts_addon = require("./builtins/alerts/alerts.addon.js");
@@ -28,22 +28,22 @@ const require_builtins_loki_logging_index = require("./builtins/loki-logging/ind
28
28
  const require_builtins_native_metrics_native_metrics_addon = require("./builtins/native-metrics/native-metrics.addon.js");
29
29
  const require_builtins_device_history_device_history_addon = require("./builtins/device-history/device-history.addon.js");
30
30
  const require_builtins_sqlite_storage_filesystem_storage_addon = require("./builtins/sqlite-storage/filesystem-storage.addon.js");
31
- const require_wal_maintenance = require("./wal-maintenance-At5TeYwr.js");
32
- const require_legacy_integration_rows_door = require("./legacy-integration-rows-door-B3K3A9JU.js");
31
+ const require_wal_maintenance = require("./wal-maintenance-CXx0PMNE.js");
32
+ const require_legacy_integration_rows_door = require("./legacy-integration-rows-door-4SwHHOO6.js");
33
33
  const require_builtins_sqlite_storage_sqlite_settings_addon = require("./builtins/sqlite-storage/sqlite-settings.addon.js");
34
34
  const require_builtins_sqlite_storage_index = require("./builtins/sqlite-storage/index.js");
35
35
  const require_builtins_storage_orchestrator_storage_orchestrator_addon = require("./builtins/storage-orchestrator/storage-orchestrator.addon.js");
36
36
  require("./builtins/storage-orchestrator/index.js");
37
- const require_hub_identity = require("./hub-identity-BS1rzEes.js");
38
- const require_constants = require("./constants-BqrgVNCL.js");
37
+ const require_hub_identity = require("./hub-identity-QhEXr2sn.js");
38
+ const require_constants = require("./constants-B5QCyskv.js");
39
39
  const require_builtins_system_config_system_config_addon = require("./builtins/system-config/system-config.addon.js");
40
40
  require("./builtins/system-config/index.js");
41
41
  const require_builtins_winston_logging_index = require("./builtins/winston-logging/index.js");
42
42
  const require_custom_action_registry = require("./custom-action-registry-CmWpSeMS.js");
43
- const require_hub_mdns_ciao = require("./hub-mdns-ciao-BQh04Eo9.js");
43
+ const require_hub_mdns_ciao = require("./hub-mdns-ciao-L9Qt3eVs.js");
44
44
  const require_platform_key_source = require("./platform-key-source-Di7HrlGR.js");
45
45
  const require_resource_monitor = require("./resource-monitor-mio9dSCT.js");
46
- const require_restore_archive = require("./restore-archive-BHOc02Fh.js");
46
+ const require_restore_archive = require("./restore-archive-DDeWKKhR.js");
47
47
  const require_coral_accelerators = require("./coral-accelerators-BSVsBVzt.js");
48
48
  let zod = require("zod");
49
49
  let node_crypto = require("node:crypto");