@camstack/types 1.2.423 → 1.2.424

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 (46) hide show
  1. package/dist/addon.js +1 -1
  2. package/dist/addon.mjs +1 -1
  3. package/dist/capabilities/composer.cap.d.ts +6 -0
  4. package/dist/capabilities/core-blocks.cap.d.ts +43 -0
  5. package/dist/capabilities/group-active.cap.d.ts +46 -0
  6. package/dist/capabilities/group-commands.cap.d.ts +1 -1
  7. package/dist/capabilities/group-status.cap.d.ts +1 -1
  8. package/dist/capabilities/index.d.ts +3 -1
  9. package/dist/capabilities/lock-control.cap.d.ts +1 -0
  10. package/dist/capabilities/switch.cap.d.ts +1 -1
  11. package/dist/client.js +3 -0
  12. package/dist/client.mjs +3 -0
  13. package/dist/composition/composition-report.d.ts +2 -0
  14. package/dist/composition/composition.d.ts +9 -0
  15. package/dist/composition/helpers/actuator-methods.d.ts +39 -0
  16. package/dist/composition/helpers/aggregate.d.ts +2 -0
  17. package/dist/composition/helpers/catalog.d.ts +7 -1
  18. package/dist/composition/helpers/compile-history.d.ts +16 -1
  19. package/dist/composition/helpers/compile-math.d.ts +9 -0
  20. package/dist/composition/helpers/history-math.d.ts +8 -0
  21. package/dist/composition/helpers/index.d.ts +6 -4
  22. package/dist/composition/helpers/source-pick.d.ts +8 -1
  23. package/dist/composition/helpers/spec.d.ts +49 -3
  24. package/dist/{composition-CpETZ4HL.mjs → composition-Bb8iwHEJ.mjs} +175 -5
  25. package/dist/{composition-CPRAP41h.js → composition-CpAc0YfQ.js} +228 -4
  26. package/dist/device/cap-vocabulary/entries/sensors.d.ts +1 -1
  27. package/dist/expression/builtins.d.ts +11 -2
  28. package/dist/expression/expression-source.d.ts +6 -1
  29. package/dist/generated/addon-api.d.ts +14 -0
  30. package/dist/generated/addon-cap-facts.d.ts +1 -1
  31. package/dist/generated/cap-status-types.d.ts +3 -1
  32. package/dist/generated/capability-router-map.d.ts +5 -2
  33. package/dist/generated/device-local-state.d.ts +3 -0
  34. package/dist/generated/device-proxy.d.ts +3 -0
  35. package/dist/generated/device-scoped-caps.d.ts +1 -1
  36. package/dist/generated/history-catalog.d.ts +1 -1
  37. package/dist/generated/method-access-map.d.ts +1 -1
  38. package/dist/generated/method-device-selectors.d.ts +1 -1
  39. package/dist/generated/runtime-state-durability.d.ts +1 -1
  40. package/dist/index.js +634 -33
  41. package/dist/index.mjs +611 -34
  42. package/dist/node.js +1 -1
  43. package/dist/node.mjs +1 -1
  44. package/dist/{sleep-0sD_LHLI.mjs → sleep--jXS9hWo.mjs} +10 -1
  45. package/dist/{sleep-CEKGW7A5.js → sleep-edKiOXLo.js} +10 -1
  46. package/package.json +1 -1
@@ -1138,7 +1138,7 @@ var ExpressionEvalError = class extends Error {
1138
1138
  //#endregion
1139
1139
  //#region src/expression/builtins.ts
1140
1140
  function isStatefulBuiltin(name) {
1141
- return name === "rose" || name === "count" || name === "dwell" || name === "latchedAt";
1141
+ return name === "rose" || name === "count" || name === "dwell" || name === "latchedAt" || name === "schmitt";
1142
1142
  }
1143
1143
  function asFiniteNumber(value, name, index) {
1144
1144
  if (typeof value !== "number" || !Number.isFinite(value)) throw new ExpressionEvalError(`${name}: argument ${index + 1} must be a finite number`);
@@ -1266,6 +1266,41 @@ function evaluateDwell(activeRaw, onForMsRaw, offForMsRaw, call, nowMs, hooks) {
1266
1266
  hooks?.noteDeadline?.(call.pendingSince + delay);
1267
1267
  return call.latched;
1268
1268
  }
1269
+ /**
1270
+ * `schmitt(x, high, low[, onForMs, offForMs])`: true once `x >= high`, false
1271
+ * once `x <= low`, and the last answer in between. A transition waits its delay
1272
+ * and is dropped if `x` returns to the held side first. The first answer needs
1273
+ * a crossing, or the restored output as `seed`: a reading inside the band with
1274
+ * nothing to hold is unknown, never off (D393). A null reading throws, so the
1275
+ * field is unavailable and the latch is kept.
1276
+ */
1277
+ function evaluateSchmitt(args, call, nowMs, seed, hooks) {
1278
+ const x = asFiniteNumber(args[0], "schmitt", 0);
1279
+ const high = asFiniteNumber(args[1], "schmitt", 1);
1280
+ const low = asFiniteNumber(args[2], "schmitt", 2);
1281
+ const onForMs = args.length > 3 ? asNonNegativeMs(args[3], "schmitt", 3) : 0;
1282
+ const offForMs = args.length > 4 ? asNonNegativeMs(args[4], "schmitt", 4) : 0;
1283
+ if (low > high) throw new ExpressionEvalError("schmitt: the low edge is above the high edge");
1284
+ if (call.latched === null && seed !== null) call.latched = seed;
1285
+ const wants = x >= high ? true : x <= low ? false : call.latched;
1286
+ if (call.latched === null) {
1287
+ if (wants !== null) call.latched = wants;
1288
+ return call.latched;
1289
+ }
1290
+ if (wants === null || wants === call.latched) {
1291
+ call.pendingSince = null;
1292
+ return call.latched;
1293
+ }
1294
+ if (call.pendingSince === null) call.pendingSince = nowMs;
1295
+ const delay = wants ? onForMs : offForMs;
1296
+ if (nowMs - call.pendingSince >= delay) {
1297
+ call.latched = wants;
1298
+ call.pendingSince = null;
1299
+ return call.latched;
1300
+ }
1301
+ hooks?.noteDeadline?.(call.pendingSince + delay);
1302
+ return call.latched;
1303
+ }
1269
1304
  /** `latchedAt(value)`: epoch ms when `value` last changed; null clears the stamp. */
1270
1305
  function evaluateLatchedAt(value, call, nowMs) {
1271
1306
  if (value === null) {
@@ -1463,6 +1498,13 @@ var table = {
1463
1498
  apply: () => {
1464
1499
  throw new ExpressionEvalError("latchedAt: stateful evaluation context is required");
1465
1500
  }
1501
+ },
1502
+ schmitt: {
1503
+ minArgs: 3,
1504
+ maxArgs: 5,
1505
+ apply: () => {
1506
+ throw new ExpressionEvalError("schmitt: stateful evaluation context is required");
1507
+ }
1466
1508
  }
1467
1509
  };
1468
1510
  /** Frozen, null-prototype builtin table. */
@@ -2072,6 +2114,16 @@ function evaluateStatefulExpressionCall(invocation, memory, env, hooks) {
2072
2114
  memory.calls.set(invocation.path, call);
2073
2115
  return evaluateDwell(invocation.args[0], invocation.args[1], invocation.args[2], call, env.nowMs, hooks);
2074
2116
  }
2117
+ case "schmitt": {
2118
+ const call = existing?.kind === "schmitt" ? existing : {
2119
+ kind: "schmitt",
2120
+ latched: null,
2121
+ pendingSince: null
2122
+ };
2123
+ memory.calls.set(invocation.path, call);
2124
+ const seed = typeof env.currentOutput === "boolean" ? env.currentOutput : null;
2125
+ return evaluateSchmitt(invocation.args, call, env.nowMs, seed, hooks);
2126
+ }
2075
2127
  case "latchedAt": {
2076
2128
  const call = existing?.kind === "latchedAt" ? existing : {
2077
2129
  kind: "latchedAt",
@@ -2442,6 +2494,58 @@ function integrateReading(read, scale) {
2442
2494
  for (const segment of covered.segments) unitMs += segment.value * segment.ms;
2443
2495
  return numberValue(scale === "energy-kwh" ? wattMillisecondsToKwh(unitMs) : unitMs / 1e3, covered.included, covered.gaps, GAP_REASON);
2444
2496
  }
2497
+ function samplesOf(read) {
2498
+ const out = [];
2499
+ if (read.before !== null && finite(read.before.value)) out.push({
2500
+ at: read.from,
2501
+ value: read.before.value
2502
+ });
2503
+ for (const point of read.points) {
2504
+ if (point.t < read.from || point.t > read.to) continue;
2505
+ const value = pointValue(point);
2506
+ if (value === null) continue;
2507
+ const at = read.tier === "raw" || !finite(point.twMs) ? point.t : point.t + point.twMs;
2508
+ out.push({
2509
+ at: Math.min(at, read.to),
2510
+ value
2511
+ });
2512
+ }
2513
+ return out.toSorted((a, b) => a.at - b.at);
2514
+ }
2515
+ /** A sample-less tail or head longer than this share of the window is counted as a gap. */
2516
+ var UNCOVERED_LIMIT = .1;
2517
+ var DERIVATIVE_GAP_REASON = "history stops short of the window — the rate is over the part that was measured";
2518
+ function derivativeValue(change, spanMs, perMs, included, windowMs) {
2519
+ return numberValue(change / (spanMs / perMs), included, windowMs - spanMs > windowMs * UNCOVERED_LIMIT ? 1 : 0, DERIVATIVE_GAP_REASON);
2520
+ }
2521
+ /**
2522
+ * Rate of change over a window, per `perMs`. The slope is taken between the
2523
+ * first and the last measured sample, so a hole inside the window neither
2524
+ * counts as zero nor stretches the elapsed time. A gauge that reported
2525
+ * nothing after the value held at the start is flat (rate 0); fewer than two
2526
+ * samples and no held value is a known gap (D393).
2527
+ */
2528
+ function evaluateDerivative(read, perMs) {
2529
+ if (read.truncated) return hold("the history query was truncated — the last rate is kept");
2530
+ if (read.to <= read.from) return gapValue("the range is empty", 0);
2531
+ const windowMs = read.to - read.from;
2532
+ const samples = samplesOf(read);
2533
+ const first = samples[0];
2534
+ const last = samples[samples.length - 1];
2535
+ if (first === void 0 || last === void 0) return gapValue("history has no reading in this window", 0);
2536
+ if (read.kind === "counter") {
2537
+ const heldAtStart = read.before !== null && finite(read.before.value);
2538
+ const startsAt = heldAtStart ? read.from : first.at;
2539
+ const deltas = read.points.flatMap((point) => point.t >= read.from && point.t <= read.to && finite(point.delta) && (heldAtStart || point.t > first.at) ? [point.delta] : []);
2540
+ const spanMs = last.at - startsAt;
2541
+ if (deltas.length === 0 || spanMs <= 0) return gapValue("the counter has no growth in this window", samples.length);
2542
+ return derivativeValue(deltas.reduce((sum, delta) => sum + delta, 0), spanMs, perMs, samples.length, windowMs);
2543
+ }
2544
+ if (samples.length === 1 && first.at === read.from && read.before !== null) return numberValue(0, 1, 0, null);
2545
+ const spanMs = last.at - first.at;
2546
+ if (samples.length < 2 || spanMs <= 0) return gapValue("the rate needs two readings in the window", samples.length);
2547
+ return derivativeValue(last.value - first.value, spanMs, perMs, samples.length, windowMs);
2548
+ }
2445
2549
  //#endregion
2446
2550
  //#region src/composition/helpers/history-window.ts
2447
2551
  /**
@@ -2805,7 +2909,13 @@ var GROUP_TEMPLATE_IDS = [
2805
2909
  "occupancy",
2806
2910
  "binary",
2807
2911
  "switch",
2808
- "light"
2912
+ "light",
2913
+ "fan",
2914
+ "cover",
2915
+ "valve",
2916
+ "lock",
2917
+ "media-player",
2918
+ "climate"
2809
2919
  ];
2810
2920
  var NUMERIC_AGGREGATES = [
2811
2921
  "mean",
@@ -2868,19 +2978,73 @@ var integralHelperObject = zod.z.object({
2868
2978
  source: HelperMemberSchema
2869
2979
  });
2870
2980
  var IntegralHelperSpecSchema = integralHelperObject;
2981
+ var thresholdHelperObject = zod.z.object({
2982
+ kind: zod.z.literal("threshold"),
2983
+ source: HelperMemberSchema,
2984
+ high: zod.z.number(),
2985
+ low: zod.z.number(),
2986
+ onForMs: zod.z.number().int().nonnegative(),
2987
+ offForMs: zod.z.number().int().nonnegative()
2988
+ });
2989
+ var ThresholdHelperSpecSchema = thresholdHelperObject;
2990
+ var ARITHMETIC_OPS = [
2991
+ "sum",
2992
+ "difference",
2993
+ "ratio"
2994
+ ];
2995
+ var arithmeticHelperObject = zod.z.object({
2996
+ kind: zod.z.literal("arithmetic"),
2997
+ op: zod.z.enum(ARITHMETIC_OPS),
2998
+ inputs: zod.z.array(HelperMemberSchema).min(2).max(64)
2999
+ });
3000
+ var ArithmeticHelperSpecSchema = arithmeticHelperObject;
3001
+ var EXPRESSION_OUTPUTS = ["number", "boolean"];
3002
+ var expressionHelperObject = zod.z.object({
3003
+ kind: zod.z.literal("expression"),
3004
+ expr: zod.z.string().min(1),
3005
+ inputs: zod.z.array(zod.z.object({
3006
+ name: zod.z.string().min(1),
3007
+ member: HelperMemberSchema
3008
+ })).min(1).max(64),
3009
+ output: zod.z.enum(EXPRESSION_OUTPUTS)
3010
+ });
3011
+ var ExpressionHelperSpecSchema = expressionHelperObject;
3012
+ var DERIVATIVE_UNITS = [
3013
+ "second",
3014
+ "minute",
3015
+ "hour"
3016
+ ];
3017
+ var derivativeHelperObject = zod.z.object({
3018
+ kind: zod.z.literal("derivative"),
3019
+ window: RollingWindowSchema,
3020
+ per: zod.z.enum(DERIVATIVE_UNITS),
3021
+ source: HelperMemberSchema
3022
+ });
3023
+ var DerivativeHelperSpecSchema = derivativeHelperObject;
2871
3024
  var HelperSpecSchema = zod.z.discriminatedUnion("kind", [
2872
3025
  GroupHelperSpecSchema,
2873
3026
  ApplianceHelperSpecSchema,
2874
3027
  statisticHelperObject,
2875
- integralHelperObject
3028
+ integralHelperObject,
3029
+ thresholdHelperObject,
3030
+ arithmeticHelperObject,
3031
+ expressionHelperObject,
3032
+ derivativeHelperObject
2876
3033
  ]);
3034
+ function isHistoryHelper(spec) {
3035
+ return spec.kind === "statistic" || spec.kind === "integral" || spec.kind === "derivative";
3036
+ }
2877
3037
  /** Every member a helper reads. A group has many; the others have one. */
2878
3038
  function helperMembers(spec) {
2879
3039
  switch (spec.kind) {
2880
3040
  case "group": return spec.members;
2881
3041
  case "appliance": return [spec.member];
2882
3042
  case "statistic":
2883
- case "integral": return [spec.source];
3043
+ case "integral":
3044
+ case "threshold":
3045
+ case "derivative": return [spec.source];
3046
+ case "arithmetic": return spec.inputs;
3047
+ case "expression": return spec.inputs.map((input) => input.member);
2884
3048
  }
2885
3049
  }
2886
3050
  //#endregion
@@ -2978,6 +3142,12 @@ var CompositionAggregateSourceSchema = zod.z.object({
2978
3142
  "all"
2979
3143
  ]),
2980
3144
  reads: zod.z.array(CompositionFieldReadSchema).min(1).max(64),
3145
+ /**
3146
+ * Set when the reads are an enum state, not a yes/no: the listed states
3147
+ * count as active (a cover is `open`). A state outside the list is inactive;
3148
+ * a read that is not a state at all is left out. Only `any` / `all` use it.
3149
+ */
3150
+ activeWhen: zod.z.array(zod.z.string().min(1)).min(1).optional(),
2981
3151
  /** `value` is the reading; the others are the member counts. */
2982
3152
  publish: zod.z.enum([
2983
3153
  "value",
@@ -3198,6 +3368,12 @@ Object.defineProperty(exports, "APPLIANCE_TEMPLATE_ID", {
3198
3368
  return APPLIANCE_TEMPLATE_ID;
3199
3369
  }
3200
3370
  });
3371
+ Object.defineProperty(exports, "ARITHMETIC_OPS", {
3372
+ enumerable: true,
3373
+ get: function() {
3374
+ return ARITHMETIC_OPS;
3375
+ }
3376
+ });
3201
3377
  Object.defineProperty(exports, "AUDIO_PRESETS", {
3202
3378
  enumerable: true,
3203
3379
  get: function() {
@@ -3222,6 +3398,12 @@ Object.defineProperty(exports, "ApplianceHelperSpecSchema", {
3222
3398
  return ApplianceHelperSpecSchema;
3223
3399
  }
3224
3400
  });
3401
+ Object.defineProperty(exports, "ArithmeticHelperSpecSchema", {
3402
+ enumerable: true,
3403
+ get: function() {
3404
+ return ArithmeticHelperSpecSchema;
3405
+ }
3406
+ });
3225
3407
  Object.defineProperty(exports, "BINARY_AGGREGATES", {
3226
3408
  enumerable: true,
3227
3409
  get: function() {
@@ -3408,6 +3590,18 @@ Object.defineProperty(exports, "DEFAULT_HISTORY_RETENTION", {
3408
3590
  return DEFAULT_HISTORY_RETENTION;
3409
3591
  }
3410
3592
  });
3593
+ Object.defineProperty(exports, "DERIVATIVE_UNITS", {
3594
+ enumerable: true,
3595
+ get: function() {
3596
+ return DERIVATIVE_UNITS;
3597
+ }
3598
+ });
3599
+ Object.defineProperty(exports, "DerivativeHelperSpecSchema", {
3600
+ enumerable: true,
3601
+ get: function() {
3602
+ return DerivativeHelperSpecSchema;
3603
+ }
3604
+ });
3411
3605
  Object.defineProperty(exports, "EXPRESSION_BUILTINS", {
3412
3606
  enumerable: true,
3413
3607
  get: function() {
@@ -3438,12 +3632,24 @@ Object.defineProperty(exports, "EXPRESSION_INJECTED_NOW", {
3438
3632
  return EXPRESSION_INJECTED_NOW;
3439
3633
  }
3440
3634
  });
3635
+ Object.defineProperty(exports, "EXPRESSION_OUTPUTS", {
3636
+ enumerable: true,
3637
+ get: function() {
3638
+ return EXPRESSION_OUTPUTS;
3639
+ }
3640
+ });
3441
3641
  Object.defineProperty(exports, "ExpressionEvalError", {
3442
3642
  enumerable: true,
3443
3643
  get: function() {
3444
3644
  return ExpressionEvalError;
3445
3645
  }
3446
3646
  });
3647
+ Object.defineProperty(exports, "ExpressionHelperSpecSchema", {
3648
+ enumerable: true,
3649
+ get: function() {
3650
+ return ExpressionHelperSpecSchema;
3651
+ }
3652
+ });
3447
3653
  Object.defineProperty(exports, "ExpressionParseError", {
3448
3654
  enumerable: true,
3449
3655
  get: function() {
@@ -3690,6 +3896,12 @@ Object.defineProperty(exports, "StatisticWindowSchema", {
3690
3896
  return StatisticWindowSchema;
3691
3897
  }
3692
3898
  });
3899
+ Object.defineProperty(exports, "ThresholdHelperSpecSchema", {
3900
+ enumerable: true,
3901
+ get: function() {
3902
+ return ThresholdHelperSpecSchema;
3903
+ }
3904
+ });
3693
3905
  Object.defineProperty(exports, "applianceDeviceType", {
3694
3906
  enumerable: true,
3695
3907
  get: function() {
@@ -3828,6 +4040,12 @@ Object.defineProperty(exports, "evaluateCount", {
3828
4040
  return evaluateCount;
3829
4041
  }
3830
4042
  });
4043
+ Object.defineProperty(exports, "evaluateDerivative", {
4044
+ enumerable: true,
4045
+ get: function() {
4046
+ return evaluateDerivative;
4047
+ }
4048
+ });
3831
4049
  Object.defineProperty(exports, "evaluateExpressionSource", {
3832
4050
  enumerable: true,
3833
4051
  get: function() {
@@ -3930,6 +4148,12 @@ Object.defineProperty(exports, "isApplianceKind", {
3930
4148
  return isApplianceKind;
3931
4149
  }
3932
4150
  });
4151
+ Object.defineProperty(exports, "isHistoryHelper", {
4152
+ enumerable: true,
4153
+ get: function() {
4154
+ return isHistoryHelper;
4155
+ }
4156
+ });
3933
4157
  Object.defineProperty(exports, "isSoftwareDecode", {
3934
4158
  enumerable: true,
3935
4159
  get: function() {
@@ -1,5 +1,5 @@
1
1
  import type { CapVocabularySlice } from '../types.js';
2
- type SensorCap = 'air-quality-sensor' | 'ambient-light-sensor' | 'binary' | 'carbon-monoxide' | 'connectivity' | 'contact' | 'enum-sensor' | 'flood' | 'gas' | 'group-commands' | 'group-status' | 'humidity-sensor' | 'meter' | 'motion' | 'numeric-sensor' | 'power-meter' | 'presence' | 'pressure-sensor' | 'smoke' | 'tamper' | 'temperature-sensor' | 'vibration' | 'weather' | 'battery' | 'network-link' | 'device-status' | 'doorbell' | 'event-emitter';
2
+ type SensorCap = 'air-quality-sensor' | 'ambient-light-sensor' | 'binary' | 'carbon-monoxide' | 'connectivity' | 'contact' | 'enum-sensor' | 'flood' | 'gas' | 'group-active' | 'group-commands' | 'group-status' | 'humidity-sensor' | 'meter' | 'motion' | 'numeric-sensor' | 'power-meter' | 'presence' | 'pressure-sensor' | 'smoke' | 'tamper' | 'temperature-sensor' | 'vibration' | 'weather' | 'battery' | 'network-link' | 'device-status' | 'doorbell' | 'event-emitter';
3
3
  /** The sensor family of the vocabulary. */
4
4
  export declare const SENSOR_CAP_VOCABULARY: CapVocabularySlice<SensorCap>;
5
5
  export {};
@@ -16,7 +16,7 @@
16
16
  * closed rather than emitting a garbage value.
17
17
  */
18
18
  import type { ExpressionValue } from './ast.js';
19
- import type { CountCallState, DwellCallState, LatchedAtCallState, RoseCallState, StatefulExpressionMemory } from './expression-source.js';
19
+ import type { CountCallState, DwellCallState, LatchedAtCallState, RoseCallState, SchmittCallState, StatefulExpressionMemory } from './expression-source.js';
20
20
  /** Optional runtime hooks the evaluator threads through to builtins. */
21
21
  export interface ExpressionEvalHooks {
22
22
  /** Convert `value` from unit `from` to unit `to`; `null` when the pair is
@@ -41,7 +41,7 @@ export interface ExpressionBuiltin {
41
41
  readonly maxArgs: number;
42
42
  readonly apply: (args: readonly ExpressionValue[], hooks: ExpressionEvalHooks) => ExpressionValue;
43
43
  }
44
- export type StatefulExpressionBuiltin = 'rose' | 'count' | 'dwell' | 'latchedAt';
44
+ export type StatefulExpressionBuiltin = 'rose' | 'count' | 'dwell' | 'latchedAt' | 'schmitt';
45
45
  export declare function isStatefulBuiltin(name: string): name is StatefulExpressionBuiltin;
46
46
  export declare function evaluateRose(level: unknown, changedAt: unknown, debounceMs: unknown, call: RoseCallState, field: StatefulExpressionMemory, env: {
47
47
  readonly currentOutput: number | null;
@@ -55,6 +55,15 @@ export declare function disarmRoseMemory(memory: StatefulExpressionMemory): void
55
55
  * the latched boolean through gaps shorter than the opposing delay (D933).
56
56
  */
57
57
  export declare function evaluateDwell(activeRaw: unknown, onForMsRaw: unknown, offForMsRaw: unknown, call: DwellCallState, nowMs: number, hooks?: ExpressionEvalHooks): boolean | null;
58
+ /**
59
+ * `schmitt(x, high, low[, onForMs, offForMs])`: true once `x >= high`, false
60
+ * once `x <= low`, and the last answer in between. A transition waits its delay
61
+ * and is dropped if `x` returns to the held side first. The first answer needs
62
+ * a crossing, or the restored output as `seed`: a reading inside the band with
63
+ * nothing to hold is unknown, never off (D393). A null reading throws, so the
64
+ * field is unavailable and the latch is kept.
65
+ */
66
+ export declare function evaluateSchmitt(args: readonly unknown[], call: SchmittCallState, nowMs: number, seed: boolean | null, hooks?: ExpressionEvalHooks): boolean | null;
58
67
  /** `latchedAt(value)`: epoch ms when `value` last changed; null clears the stamp. */
59
68
  export declare function evaluateLatchedAt(value: unknown, call: LatchedAtCallState, nowMs: number): number | null;
60
69
  export declare function evaluateCount(input: unknown, call: CountCallState, currentOutput: unknown): number;
@@ -39,7 +39,12 @@ export interface LatchedAtCallState {
39
39
  last: ExpressionValue | undefined;
40
40
  at: number | null;
41
41
  }
42
- export type StatefulCallState = RoseCallState | CountCallState | DwellCallState | LatchedAtCallState;
42
+ export interface SchmittCallState {
43
+ readonly kind: 'schmitt';
44
+ latched: boolean | null;
45
+ pendingSince: number | null;
46
+ }
47
+ export type StatefulCallState = RoseCallState | CountCallState | DwellCallState | LatchedAtCallState | SchmittCallState;
43
48
  export interface StatefulExpressionMemory {
44
49
  readonly calls: Map<string, StatefulCallState>;
45
50
  acceptedEdgeAt: number | null;
@@ -3850,6 +3850,20 @@ export type AppRouter = TrpcCoreRouter<{
3850
3850
  meta: object;
3851
3851
  }>;
3852
3852
  }>>;
3853
+ groupActive: TRPCBuiltRouter<{
3854
+ ctx: TrpcContext;
3855
+ meta: object;
3856
+ errorShape: AugmentedErrorShape;
3857
+ transformer: true;
3858
+ }, TRPCDecorateCreateRouterOptions<{
3859
+ getStatus: TRPCQueryProcedure<{
3860
+ input: {
3861
+ [x: string]: unknown;
3862
+ } & z.input<typeof DEVICE_STATUS_METHOD.getStatus.input>;
3863
+ output: z.infer<typeof DEVICE_STATUS_METHOD.getStatus.output>;
3864
+ meta: object;
3865
+ }>;
3866
+ }>>;
3853
3867
  groupCommands: TRPCBuiltRouter<{
3854
3868
  ctx: TrpcContext;
3855
3869
  meta: object;
@@ -5,7 +5,7 @@
5
5
  * `ALL_CAPABILITY_DEFINITIONS` (the whole Zod schema graph, ~+100 MB heap per
6
6
  * runner). See docs/decisions/adr-0028.md.
7
7
  *
8
- * Coverage: 1 advance-derived caps, 76 caps with 352 state leaves.
8
+ * Coverage: 1 advance-derived caps, 77 caps with 353 state leaves.
9
9
  */
10
10
  /** A bindable scalar in a capability's runtime state. */
11
11
  export interface CapStateLeaf {
@@ -30,6 +30,7 @@ import type { FanControlStatusSchema } from '../capabilities/fan-control.cap.js'
30
30
  import type { FeatureProbeStatusSchema } from '../capabilities/feature-probe.cap.js';
31
31
  import type { FloodStatusSchema } from '../capabilities/flood.cap.js';
32
32
  import type { GasStatusSchema } from '../capabilities/gas.cap.js';
33
+ import type { groupActiveCapability } from '../capabilities/group-active.cap.js';
33
34
  import type { groupCommandsCapability } from '../capabilities/group-commands.cap.js';
34
35
  import type { groupStatusCapability } from '../capabilities/group-status.cap.js';
35
36
  import type { HeatingValveStatusSchema } from '../capabilities/heating-valve.cap.js';
@@ -114,6 +115,7 @@ export type CapStatusTypeMap = {
114
115
  readonly 'feature-probe': z.infer<typeof FeatureProbeStatusSchema>;
115
116
  readonly 'flood': z.infer<typeof FloodStatusSchema>;
116
117
  readonly 'gas': z.infer<typeof GasStatusSchema>;
118
+ readonly 'group-active': z.infer<(typeof groupActiveCapability)['status']['schema']>;
117
119
  readonly 'group-commands': z.infer<(typeof groupCommandsCapability)['status']['schema']>;
118
120
  readonly 'group-status': z.infer<(typeof groupStatusCapability)['status']['schema']>;
119
121
  readonly 'heating-valve': z.infer<typeof HeatingValveStatusSchema>;
@@ -169,4 +171,4 @@ export type CapNameWithStatus = keyof CapStatusTypeMap;
169
171
  * aggregator to enumerate caps whose `status` should be polled +
170
172
  * streamed via `subscribeDeviceStatusAggregate`.
171
173
  */
172
- export declare const CAP_NAMES_WITH_STATUS: readonly ["accessories", "air-quality-sensor", "alarm-panel", "ambient-light-sensor", "automation-control", "battery", "binary", "brightness", "broker", "camera-credentials", "carbon-monoxide", "climate-control", "color", "connectivity", "consumables", "contact", "control", "cover", "day-night", "device-adoption", "device-discovery", "device-export", "device-status", "dishwasher", "doorbell", "enum-sensor", "event-emitter", "fan-control", "feature-probe", "flood", "gas", "group-commands", "group-status", "heating-valve", "humidifier", "humidity-sensor", "image", "image-settings", "intercom", "lawn-mower-control", "lock-control", "media-player", "meter", "motion", "motion-trigger", "motion-zones", "mqtt-broker", "native-object-detection", "navigation", "network-link", "notifier", "numeric-sensor", "osd", "pet-feeder", "power-meter", "presence", "pressure-sensor", "privacy-mask", "ptz", "ptz-autotrack", "recording-archive", "recording-onboard", "recording-signal", "running-state", "scene-monitor", "script-runner", "smoke", "snapshot", "stream-params", "switch", "tamper", "temperature-sensor", "update", "vacuum-control", "valve", "vibration", "water-heater", "weather"];
174
+ export declare const CAP_NAMES_WITH_STATUS: readonly ["accessories", "air-quality-sensor", "alarm-panel", "ambient-light-sensor", "automation-control", "battery", "binary", "brightness", "broker", "camera-credentials", "carbon-monoxide", "climate-control", "color", "connectivity", "consumables", "contact", "control", "cover", "day-night", "device-adoption", "device-discovery", "device-export", "device-status", "dishwasher", "doorbell", "enum-sensor", "event-emitter", "fan-control", "feature-probe", "flood", "gas", "group-active", "group-commands", "group-status", "heating-valve", "humidifier", "humidity-sensor", "image", "image-settings", "intercom", "lawn-mower-control", "lock-control", "media-player", "meter", "motion", "motion-trigger", "motion-zones", "mqtt-broker", "native-object-detection", "navigation", "network-link", "notifier", "numeric-sensor", "osd", "pet-feeder", "power-meter", "presence", "pressure-sensor", "privacy-mask", "ptz", "ptz-autotrack", "recording-archive", "recording-onboard", "recording-signal", "running-state", "scene-monitor", "script-runner", "smoke", "snapshot", "stream-params", "switch", "tamper", "temperature-sensor", "update", "vacuum-control", "valve", "vibration", "water-heater", "weather"];
@@ -72,6 +72,7 @@ export { featureProbeCapability } from '../capabilities/feature-probe.cap.js';
72
72
  export { filesystemBrowseCapability } from '../capabilities/filesystem-browse.cap.js';
73
73
  export { floodCapability } from '../capabilities/flood.cap.js';
74
74
  export { gasCapability } from '../capabilities/gas.cap.js';
75
+ export { groupActiveCapability } from '../capabilities/group-active.cap.js';
75
76
  export { groupCommandsCapability } from '../capabilities/group-commands.cap.js';
76
77
  export { groupStatusCapability } from '../capabilities/group-status.cap.js';
77
78
  export { heatingValveCapability } from '../capabilities/heating-valve.cap.js';
@@ -257,6 +258,7 @@ export declare const CAPABILITY_NAMES: {
257
258
  readonly filesystemBrowse: 'filesystem-browse';
258
259
  readonly flood: 'flood';
259
260
  readonly gas: 'gas';
261
+ readonly groupActive: 'group-active';
260
262
  readonly groupCommands: 'group-commands';
261
263
  readonly groupStatus: 'group-status';
262
264
  readonly heatingValve: 'heating-valve';
@@ -455,6 +457,7 @@ export interface CapabilityRouterMap<TRouter = unknown> {
455
457
  readonly filesystemBrowse: TRouter;
456
458
  readonly flood: TRouter;
457
459
  readonly gas: TRouter;
460
+ readonly groupActive: TRouter;
458
461
  readonly groupCommands: TRouter;
459
462
  readonly groupStatus: TRouter;
460
463
  readonly heatingValve: TRouter;
@@ -566,8 +569,8 @@ export interface CapabilityRouterMap<TRouter = unknown> {
566
569
  readonly zoneRules: TRouter;
567
570
  readonly zones: TRouter;
568
571
  }
569
- /** Capability names whose mode is `singleton` (149 caps). */
570
- export declare const SINGLETON_CAPABILITY_NAMES: readonly ['accessories', 'addon-pages', 'addon-settings', 'addon-widgets', 'addons', 'admin-ui', 'air-quality-sensor', 'alarm-panel', 'alerts', 'ambient-light-sensor', 'audio-analysis', 'audio-analyzer', 'audio-codec', 'audio-metrics', 'automation-control', 'backup', 'battery', 'binary', 'brightness', 'button', 'calendars', 'camera-credentials', 'camera-grid-layout', 'camera-pipeline-config', 'camera-streams', 'carbon-monoxide', 'climate-control', 'color', 'composer', 'connectivity', 'consumables', 'contact', 'control', 'core-blocks', 'cover', 'database-snapshot', 'day-night', 'decoder', 'detection-pipeline', 'device-admin-link', 'device-credentials', 'device-discovery', 'device-history', 'device-manager', 'device-ops', 'device-state', 'device-status', 'dishwasher', 'display-palette', 'doorbell', 'enum-sensor', 'event-emitter', 'face-gallery', 'fan-control', 'feature-probe', 'filesystem-browse', 'flood', 'gas', 'group-commands', 'group-status', 'heating-valve', 'humidifier', 'humidity-sensor', 'image', 'image-settings', 'integrations', 'intercom', 'keychain', 'keychain-admin', 'lawn-mower-control', 'llm-runtime', 'local-network', 'lock-control', 'media-player', 'meter', 'metrics-provider', 'model-convert', 'model-distributor', 'motion', 'motion-detection', 'motion-trigger', 'motion-zones', 'native-object-detection', 'navigation', 'network-link', 'network-quality', 'node-certificates', 'nodes', 'notification-rules', 'notifier', 'numeric-sensor', 'oidc-connections', 'osd', 'osd-manager', 'pet-feeder', 'pipeline-analytics', 'pipeline-executor', 'pipeline-orchestrator', 'pipeline-runner', 'plate-gallery', 'platform-probe', 'power-meter', 'presence', 'pressure-sensor', 'privacy-mask', 'ptz', 'ptz-autotrack', 'reboot', 'record-entries', 'recording-archive', 'recording-export', 'recording-onboard', 'recording-signal', 'records', 'running-state', 'scene-monitor', 'script-runner', 'server-management', 'settings-store', 'smoke', 'snapshot', 'sso-bridge', 'storage', 'storage-admin', 'storage-migration', 'stream-broker', 'stream-catalog', 'stream-params', 'stream-signals', 'switch', 'system', 'tamper', 'temperature-sensor', 'terminal-session', 'toast', 'training', 'update', 'user-management', 'vacuum-control', 'valve', 'vector-store', 'vibration', 'viewer-ui', 'water-heater', 'weather', 'webrtc-session', 'zone-analytics', 'zone-rules', 'zones'];
572
+ /** Capability names whose mode is `singleton` (150 caps). */
573
+ export declare const SINGLETON_CAPABILITY_NAMES: readonly ['accessories', 'addon-pages', 'addon-settings', 'addon-widgets', 'addons', 'admin-ui', 'air-quality-sensor', 'alarm-panel', 'alerts', 'ambient-light-sensor', 'audio-analysis', 'audio-analyzer', 'audio-codec', 'audio-metrics', 'automation-control', 'backup', 'battery', 'binary', 'brightness', 'button', 'calendars', 'camera-credentials', 'camera-grid-layout', 'camera-pipeline-config', 'camera-streams', 'carbon-monoxide', 'climate-control', 'color', 'composer', 'connectivity', 'consumables', 'contact', 'control', 'core-blocks', 'cover', 'database-snapshot', 'day-night', 'decoder', 'detection-pipeline', 'device-admin-link', 'device-credentials', 'device-discovery', 'device-history', 'device-manager', 'device-ops', 'device-state', 'device-status', 'dishwasher', 'display-palette', 'doorbell', 'enum-sensor', 'event-emitter', 'face-gallery', 'fan-control', 'feature-probe', 'filesystem-browse', 'flood', 'gas', 'group-active', 'group-commands', 'group-status', 'heating-valve', 'humidifier', 'humidity-sensor', 'image', 'image-settings', 'integrations', 'intercom', 'keychain', 'keychain-admin', 'lawn-mower-control', 'llm-runtime', 'local-network', 'lock-control', 'media-player', 'meter', 'metrics-provider', 'model-convert', 'model-distributor', 'motion', 'motion-detection', 'motion-trigger', 'motion-zones', 'native-object-detection', 'navigation', 'network-link', 'network-quality', 'node-certificates', 'nodes', 'notification-rules', 'notifier', 'numeric-sensor', 'oidc-connections', 'osd', 'osd-manager', 'pet-feeder', 'pipeline-analytics', 'pipeline-executor', 'pipeline-orchestrator', 'pipeline-runner', 'plate-gallery', 'platform-probe', 'power-meter', 'presence', 'pressure-sensor', 'privacy-mask', 'ptz', 'ptz-autotrack', 'reboot', 'record-entries', 'recording-archive', 'recording-export', 'recording-onboard', 'recording-signal', 'records', 'running-state', 'scene-monitor', 'script-runner', 'server-management', 'settings-store', 'smoke', 'snapshot', 'sso-bridge', 'storage', 'storage-admin', 'storage-migration', 'stream-broker', 'stream-catalog', 'stream-params', 'stream-signals', 'switch', 'system', 'tamper', 'temperature-sensor', 'terminal-session', 'toast', 'training', 'update', 'user-management', 'vacuum-control', 'valve', 'vector-store', 'vibration', 'viewer-ui', 'water-heater', 'weather', 'webrtc-session', 'zone-analytics', 'zone-rules', 'zones'];
571
574
  /** Union of singleton capability names (literal string union). */
572
575
  export type SingletonCapabilityName = typeof SINGLETON_CAPABILITY_NAMES[number];
573
576
  /** Capability names whose mode is `collection` (35 caps). */
@@ -27,6 +27,7 @@ import { fanControlCapability } from '../capabilities/fan-control.cap.js';
27
27
  import { featureProbeCapability } from '../capabilities/feature-probe.cap.js';
28
28
  import { floodCapability } from '../capabilities/flood.cap.js';
29
29
  import { gasCapability } from '../capabilities/gas.cap.js';
30
+ import { groupActiveCapability } from '../capabilities/group-active.cap.js';
30
31
  import { groupCommandsCapability } from '../capabilities/group-commands.cap.js';
31
32
  import { groupStatusCapability } from '../capabilities/group-status.cap.js';
32
33
  import { heatingValveCapability } from '../capabilities/heating-valve.cap.js';
@@ -114,6 +115,7 @@ export interface DeviceLocalState {
114
115
  featureProbe: InferRuntimeState<typeof featureProbeCapability>;
115
116
  flood: InferRuntimeState<typeof floodCapability>;
116
117
  gas: InferRuntimeState<typeof gasCapability>;
118
+ groupActive: InferRuntimeState<typeof groupActiveCapability>;
117
119
  groupCommands: InferRuntimeState<typeof groupCommandsCapability>;
118
120
  groupStatus: InferRuntimeState<typeof groupStatusCapability>;
119
121
  heatingValve: InferRuntimeState<typeof heatingValveCapability>;
@@ -211,6 +213,7 @@ export interface CapNameToRuntimeStateMap {
211
213
  'feature-probe': InferRuntimeState<typeof featureProbeCapability>;
212
214
  'flood': InferRuntimeState<typeof floodCapability>;
213
215
  'gas': InferRuntimeState<typeof gasCapability>;
216
+ 'group-active': InferRuntimeState<typeof groupActiveCapability>;
214
217
  'group-commands': InferRuntimeState<typeof groupCommandsCapability>;
215
218
  'group-status': InferRuntimeState<typeof groupStatusCapability>;
216
219
  'heating-valve': InferRuntimeState<typeof heatingValveCapability>;
@@ -40,6 +40,7 @@ import type { fanControlCapability } from '../capabilities/fan-control.cap.js';
40
40
  import type { featureProbeCapability } from '../capabilities/feature-probe.cap.js';
41
41
  import type { floodCapability } from '../capabilities/flood.cap.js';
42
42
  import type { gasCapability } from '../capabilities/gas.cap.js';
43
+ import type { groupActiveCapability } from '../capabilities/group-active.cap.js';
43
44
  import type { groupCommandsCapability } from '../capabilities/group-commands.cap.js';
44
45
  import type { groupStatusCapability } from '../capabilities/group-status.cap.js';
45
46
  import type { heatingValveCapability } from '../capabilities/heating-valve.cap.js';
@@ -148,6 +149,7 @@ export interface DeviceProxyState {
148
149
  readonly featureProbe: SliceHandle<InferRuntimeState<typeof featureProbeCapability>>;
149
150
  readonly flood: SliceHandle<InferRuntimeState<typeof floodCapability>>;
150
151
  readonly gas: SliceHandle<InferRuntimeState<typeof gasCapability>>;
152
+ readonly groupActive: SliceHandle<InferRuntimeState<typeof groupActiveCapability>>;
151
153
  readonly groupCommands: SliceHandle<InferRuntimeState<typeof groupCommandsCapability>>;
152
154
  readonly groupStatus: SliceHandle<InferRuntimeState<typeof groupStatusCapability>>;
153
155
  readonly heatingValve: SliceHandle<InferRuntimeState<typeof heatingValveCapability>>;
@@ -252,6 +254,7 @@ export interface DeviceProxy {
252
254
  readonly featureProbe?: InferDeviceProxyCap<typeof featureProbeCapability>;
253
255
  readonly flood?: InferDeviceProxyCap<typeof floodCapability>;
254
256
  readonly gas?: InferDeviceProxyCap<typeof gasCapability>;
257
+ readonly groupActive?: InferDeviceProxyCap<typeof groupActiveCapability>;
255
258
  readonly groupCommands?: InferDeviceProxyCap<typeof groupCommandsCapability>;
256
259
  readonly groupStatus?: InferDeviceProxyCap<typeof groupStatusCapability>;
257
260
  readonly heatingValve?: InferDeviceProxyCap<typeof heatingValveCapability>;
@@ -5,7 +5,7 @@
5
5
  * can answer "may a rule actuate this?" without importing the schema barrel
6
6
  * (~144MB RSS per runner, D28).
7
7
  *
8
- * Coverage: 94 device-scoped capabilities.
8
+ * Coverage: 95 device-scoped capabilities.
9
9
  */
10
10
  export declare const DEVICE_SCOPED_CAPS: ReadonlySet<string>;
11
11
  /**
@@ -1,7 +1,7 @@
1
1
  import type { CapabilityHistoryField, CapabilityHistoryItems } from '../capabilities/capability-definition.js';
2
2
  /**
3
3
  * Cap history catalog, projected from every `*.cap.ts` `history` block.
4
- * 42 caps with series (76 series), 32 caps answered `'none'`.
4
+ * 42 caps with series (76 series), 33 caps answered `'none'`.
5
5
  * Field keys are `runtimeState` paths (`a.b` into fixed objects only).
6
6
  */
7
7
  export declare const HISTORY_CATALOG: Readonly<Record<string, Readonly<Record<string, CapabilityHistoryField>>>>;
@@ -6,7 +6,7 @@
6
6
  * scope+access check inside `protectedProcedure` (see
7
7
  * `server/backend/src/api/trpc/trpc.middleware.ts`).
8
8
  *
9
- * Coverage: 1386 method paths across 184 capabilities.
9
+ * Coverage: 1387 method paths across 185 capabilities.
10
10
  */
11
11
  import type { MethodRole } from '../auth/viewer-access.js';
12
12
  import type { CapabilityMethodAccess } from '../capabilities/capability-definition.js';
@@ -6,7 +6,7 @@
6
6
  * system-scope cap that takes a deviceId was previously never device-filtered
7
7
  * — see the generator header).
8
8
  *
9
- * Coverage: 549 methods carry a device reference, of which
9
+ * Coverage: 550 methods carry a device reference, of which
10
10
  * 174 are on SYSTEM-scope caps.
11
11
  *
12
12
  * Top-level fields, number arrays, and one-level arrays of objects carrying
@@ -11,7 +11,7 @@ export interface RuntimeStatePolicy {
11
11
  }
12
12
  /**
13
13
  * Per-cap runtime-state policy, projected from every `*.cap.ts` that declares
14
- * `runtimeState`. 75 caps: 39 `restored`, 36 `session`.
14
+ * `runtimeState`. 76 caps: 39 `restored`, 37 `session`.
15
15
  *
16
16
  * A cap absent from this map has no runtime-state slice at all. A cap PRESENT
17
17
  * with `durability: 'session'` has one and has decided not to keep it.