@camstack/server 1.2.838 → 1.2.839

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 (92) hide show
  1. package/CHANGELOG.md +10 -0
  2. package/dist/api/core/auth.router.js +19 -0
  3. package/dist/api/trpc/device-access.js +54 -0
  4. package/dist/api/trpc/trpc.middleware.js +3 -2
  5. package/package.json +7 -6
  6. package/system/dist/builtins/addon-pages-aggregator/addon-pages-aggregator.addon.js +1 -1
  7. package/system/dist/builtins/addon-pages-aggregator/addon-pages-aggregator.addon.mjs +1 -1
  8. package/system/dist/builtins/addon-widgets-aggregator/addon-widgets-aggregator.addon.js +1 -1
  9. package/system/dist/builtins/addon-widgets-aggregator/addon-widgets-aggregator.addon.mjs +1 -1
  10. package/system/dist/builtins/alerts/alerts.addon.js +1 -1
  11. package/system/dist/builtins/alerts/alerts.addon.mjs +1 -1
  12. package/system/dist/builtins/autotrack/index.js +1 -1
  13. package/system/dist/builtins/autotrack/index.mjs +1 -1
  14. package/system/dist/builtins/backup-orchestrator/backup-orchestrator.addon.js +2 -2
  15. package/system/dist/builtins/backup-orchestrator/backup-orchestrator.addon.mjs +2 -2
  16. package/system/dist/builtins/calendars/calendars.addon.js +1 -1
  17. package/system/dist/builtins/calendars/calendars.addon.mjs +1 -1
  18. package/system/dist/builtins/camera-grid/index.js +1 -1
  19. package/system/dist/builtins/camera-grid/index.mjs +1 -1
  20. package/system/dist/builtins/composer/composer.addon.js +4 -4
  21. package/system/dist/builtins/composer/composer.addon.mjs +4 -4
  22. package/system/dist/builtins/console-logging/index.js +1 -1
  23. package/system/dist/builtins/console-logging/index.mjs +1 -1
  24. package/system/dist/builtins/core-blocks/core-blocks.addon.js +45 -6
  25. package/system/dist/builtins/core-blocks/core-blocks.addon.mjs +45 -6
  26. package/system/dist/builtins/core-blocks/scheduler/scheduler-engine.d.ts +7 -0
  27. package/system/dist/builtins/core-blocks/step-condition-door.d.ts +4 -0
  28. package/system/dist/builtins/device-history/device-history.addon.js +2 -2
  29. package/system/dist/builtins/device-history/device-history.addon.mjs +2 -2
  30. package/system/dist/builtins/device-manager/device-manager.addon.js +2 -2
  31. package/system/dist/builtins/device-manager/device-manager.addon.mjs +2 -2
  32. package/system/dist/builtins/hub-forwarder/index.js +1 -1
  33. package/system/dist/builtins/hub-forwarder/index.mjs +1 -1
  34. package/system/dist/builtins/keychain/index.js +4 -4
  35. package/system/dist/builtins/keychain/index.mjs +4 -4
  36. package/system/dist/builtins/liveness-monitor/liveness-monitor.addon.js +1 -1
  37. package/system/dist/builtins/liveness-monitor/liveness-monitor.addon.mjs +1 -1
  38. package/system/dist/builtins/local-auth/local-auth.addon.js +2 -2
  39. package/system/dist/builtins/local-auth/local-auth.addon.mjs +2 -2
  40. package/system/dist/builtins/local-network/local-network.addon.js +3 -3
  41. package/system/dist/builtins/local-network/local-network.addon.mjs +3 -3
  42. package/system/dist/builtins/loki-logging/index.js +1 -1
  43. package/system/dist/builtins/loki-logging/index.mjs +1 -1
  44. package/system/dist/builtins/native-metrics/native-metrics.addon.js +1 -1
  45. package/system/dist/builtins/native-metrics/native-metrics.addon.mjs +1 -1
  46. package/system/dist/builtins/platform-probe/index.js +1 -1
  47. package/system/dist/builtins/platform-probe/index.mjs +1 -1
  48. package/system/dist/builtins/record-entries/index.js +1 -1
  49. package/system/dist/builtins/record-entries/index.mjs +1 -1
  50. package/system/dist/builtins/remote-access-orchestrator/remote-access-orchestrator.addon.js +1 -1
  51. package/system/dist/builtins/remote-access-orchestrator/remote-access-orchestrator.addon.mjs +1 -1
  52. package/system/dist/builtins/snapshot/index.js +1 -1
  53. package/system/dist/builtins/snapshot/index.mjs +1 -1
  54. package/system/dist/builtins/sqlite-storage/filesystem-storage.addon.js +1 -1
  55. package/system/dist/builtins/sqlite-storage/filesystem-storage.addon.mjs +1 -1
  56. package/system/dist/builtins/sqlite-storage/index.js +1 -1
  57. package/system/dist/builtins/sqlite-storage/index.mjs +1 -1
  58. package/system/dist/builtins/sqlite-storage/sqlite-settings.addon.js +3 -3
  59. package/system/dist/builtins/sqlite-storage/sqlite-settings.addon.mjs +3 -3
  60. package/system/dist/builtins/storage-orchestrator/storage-orchestrator.addon.js +1 -1
  61. package/system/dist/builtins/storage-orchestrator/storage-orchestrator.addon.mjs +1 -1
  62. package/system/dist/builtins/system-config/system-config.addon.js +3 -3
  63. package/system/dist/builtins/system-config/system-config.addon.mjs +3 -3
  64. package/system/dist/builtins/winston-logging/index.js +1 -1
  65. package/system/dist/builtins/winston-logging/index.mjs +1 -1
  66. package/system/dist/{capture-engine-Bgml6l8Z.js → capture-engine-7E2O4-UN.js} +1 -1
  67. package/system/dist/{capture-engine-BQjIa865.mjs → capture-engine-B5IBWIRT.mjs} +1 -1
  68. package/system/dist/{composition-sources-CrL4KcSA.mjs → composition-sources-Cfqn4cly.mjs} +1 -1
  69. package/system/dist/{composition-sources-C7hUy8w0.js → composition-sources-DLtc8lSL.js} +1 -1
  70. package/system/dist/{constants-CUAo3cLm.js → constants-Cc70YreG.js} +1 -1
  71. package/system/dist/{constants-Bw5qtfbX.mjs → constants-DjsgCnZk.mjs} +1 -1
  72. package/system/dist/{device-ca-YELIR9gF.js → device-ca-C6JqeFfK.js} +1 -1
  73. package/system/dist/{device-ca-BDmoMgA3.mjs → device-ca-CVP5h3u1.mjs} +1 -1
  74. package/system/dist/{dist-D3_60xED.js → dist-CLnTYKFn.js} +346 -21
  75. package/system/dist/{dist-yQfQUpYA.mjs → dist-OmrC_RZs.mjs} +335 -22
  76. package/system/dist/file-host-worker.js +1 -1
  77. package/system/dist/file-host-worker.mjs +1 -1
  78. package/system/dist/{hub-identity-C8FGw7Mt.mjs → hub-identity-CKQVXf4o.mjs} +1 -1
  79. package/system/dist/{hub-identity-c_zPVKOY.js → hub-identity-TrZcnJkB.js} +1 -1
  80. package/system/dist/{hub-mdns-ciao-CM64AtFQ.mjs → hub-mdns-ciao-C8G0K1Z1.mjs} +2 -2
  81. package/system/dist/{hub-mdns-ciao-CaWa1FY1.js → hub-mdns-ciao-ocg6suyX.js} +2 -2
  82. package/system/dist/index.js +8 -8
  83. package/system/dist/index.mjs +8 -8
  84. package/system/dist/{legacy-integration-rows-door-D5Qe0A95.mjs → legacy-integration-rows-door-BPkJUGaX.mjs} +1 -1
  85. package/system/dist/{legacy-integration-rows-door-BnEJMuwz.js → legacy-integration-rows-door-b6CUxtXX.js} +1 -1
  86. package/system/dist/{rename-composition-block-DXN1dVXs.mjs → rename-composition-block-DPlsP1xF.mjs} +1 -1
  87. package/system/dist/{rename-composition-block-CbAR4yC9.js → rename-composition-block-N7lslQJK.js} +1 -1
  88. package/system/dist/{restore-archive-C88Ee7w9.mjs → restore-archive-Btc3H-Fg.mjs} +1 -1
  89. package/system/dist/{restore-archive-DDzgcjNf.js → restore-archive-CcuEoEtj.js} +1 -1
  90. package/system/dist/{wal-maintenance-BNN52u-q.js → wal-maintenance-B2_uCEi5.js} +0 -0
  91. package/system/dist/{wal-maintenance-EvgkvDZK.mjs → wal-maintenance-g7yvxLMj.mjs} +0 -0
  92. package/system/package.json +1 -1
package/CHANGELOG.md CHANGED
@@ -7,6 +7,16 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [1.2.839] - 2026-11-11
11
+
12
+ ### Added
13
+
14
+ - Automations and step conditions can gate on the time of day with a new 'time is' condition, read on the site clock.
15
+
16
+ ### Changed
17
+
18
+ - New auth.deviceAccess answers, per device, whether the signed-in user may view and command it, decided by the same rules that enforce the command
19
+
10
20
  ## [1.2.838] - 2026-11-11
11
21
 
12
22
  ### Changed
@@ -34,6 +34,7 @@ const session_mint_js_1 = require("../../auth/session-mint.js");
34
34
  const handoff_code_service_js_1 = require("../../core/auth/handoff-code.service.js");
35
35
  const cli_approval_service_js_1 = require("../../core/auth/cli-approval.service.js");
36
36
  const auth_cli_login_procedures_js_1 = require("./auth-cli-login.procedures.js");
37
+ const device_access_js_1 = require("../trpc/device-access.js");
37
38
  const trpc_middleware_js_1 = require("../trpc/trpc.middleware.js");
38
39
  const auth_limits_js_1 = require("./auth-limits.js");
39
40
  const auth_audit_procedures_js_1 = require("./auth-audit.procedures.js");
@@ -241,6 +242,8 @@ const EffectiveScopeSchema = zod_1.z.object({
241
242
  capabilities: zod_1.z.array(ScopeGrantSummarySchema).readonly(),
242
243
  addons: zod_1.z.array(ScopeGrantSummarySchema).readonly(),
243
244
  });
245
+ /** Wire shape of `auth.deviceAccess`: what the caller may do on one device. */
246
+ const DeviceAccessSchema = zod_1.z.object({ view: zod_1.z.boolean(), command: zod_1.z.boolean() });
244
247
  /** Wire shape of the authenticated user returned by `auth.me`. */
245
248
  const MeSchema = zod_1.z
246
249
  .object({
@@ -919,6 +922,22 @@ function createAuthRouter(auth, registry, moleculer = null, handoffCodes = new h
919
922
  const scope = (0, types_1.summarizeEffectiveScope)((0, types_2.capabilityScopesOf)(ctx.user.scopes ?? []), fleet, ctx.user.isAdmin);
920
923
  return { ...ctx.user, scope };
921
924
  }),
925
+ /**
926
+ * What the caller may do on ONE device: `view` and `command`. A device card
927
+ * draws its controls from it (disabled with the reason when `command` is
928
+ * false). Answered by the middleware's own matcher over the middleware's
929
+ * own scopes (`deviceAccessOf`), so it cannot disagree with enforcement;
930
+ * the hub still checks every real call. `auth.me`'s `scope` is counts, not
931
+ * this device.
932
+ */
933
+ deviceAccess: trpc_middleware_js_1.protectedProcedure
934
+ .input(zod_1.z.object({ deviceId: zod_1.z.number().int() }))
935
+ .output(DeviceAccessSchema)
936
+ .query(({ ctx, input }) => {
937
+ if (!ctx.user)
938
+ return { view: false, command: false };
939
+ return (0, device_access_js_1.deviceAccessOf)(ctx.user, input.deviceId, ctx.deviceScopeLookup);
940
+ }),
922
941
  /**
923
942
  * Resolve a PROPOSED grant set the same way `me` resolves the caller's
924
943
  * own — so the Users page can show "12 devices viewable, 2 actionable"
@@ -0,0 +1,54 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DEVICE_COMMAND_PROBE = exports.DEVICE_VIEW_PROBE = void 0;
4
+ exports.enforcedScopesOf = enforcedScopesOf;
5
+ exports.deviceAccessOf = deviceAccessOf;
6
+ /**
7
+ * "What may THIS caller do on THIS device?" — the per-device answer a device
8
+ * card needs to draw its controls enabled or disabled-with-a-reason.
9
+ *
10
+ * It is not a second scope check: it runs the SAME `authorizeProcedure` the
11
+ * `protectedProcedure` middleware runs, over the SAME scopes
12
+ * ({@link enforcedScopesOf}), against a canonical device method per access
13
+ * flavour. So the card and the hub cannot disagree about whether the device
14
+ * is in the caller's grant; the hub still checks every real call.
15
+ *
16
+ * Pure module — no tRPC machinery — so the spec exercises it directly.
17
+ */
18
+ const system_1 = require("@camstack/server/system");
19
+ const person_session_scopes_js_1 = require("../../auth/person-session-scopes.js");
20
+ const principal_authorization_js_1 = require("./principal-authorization.js");
21
+ /** A device-scope `view` method with the `viewer` role (the auto-injected getStatus). */
22
+ exports.DEVICE_VIEW_PROBE = 'switch.getStatus';
23
+ /**
24
+ * A device-scope `create` method with the `viewer` role: what a device command
25
+ * needs (device in the grant, `create` access, no viewer feature). A grant
26
+ * narrowed to one capability (`capability:<name>`) is answered for `switch`
27
+ * only; the hub refuses the other capabilities' commands on the real call.
28
+ */
29
+ exports.DEVICE_COMMAND_PROBE = 'switch.setState';
30
+ function assertProbe(path, access) {
31
+ const meta = system_1.METHOD_ACCESS_MAP[path];
32
+ if (meta === undefined || meta.capScope !== 'device' || meta.access !== access) {
33
+ throw new Error(`device-access: probe '${path}' is not a device-scope ${access} method (codegen drift)`);
34
+ }
35
+ }
36
+ assertProbe(exports.DEVICE_VIEW_PROBE, 'view');
37
+ assertProbe(exports.DEVICE_COMMAND_PROBE, 'create');
38
+ /**
39
+ * The scopes the middleware authorizes a caller with. A person (interactive,
40
+ * non-admin) is decided by the viewer row alone (D921); a token keeps its rows.
41
+ */
42
+ function enforcedScopesOf(user) {
43
+ const raw = user.scopes ?? [];
44
+ return user.interactive === true && !user.isAdmin ? (0, person_session_scopes_js_1.personSessionScopes)(raw) : raw;
45
+ }
46
+ /** {@link DeviceAccess} for `user` on `deviceId`, decided by the hub's own matcher. */
47
+ function deviceAccessOf(user, deviceId, lookup) {
48
+ const scopes = enforcedScopesOf(user);
49
+ const input = { deviceId };
50
+ return {
51
+ view: (0, principal_authorization_js_1.authorizeProcedure)(scopes, exports.DEVICE_VIEW_PROBE, input, lookup).ok,
52
+ command: (0, principal_authorization_js_1.authorizeProcedure)(scopes, exports.DEVICE_COMMAND_PROBE, input, lookup).ok,
53
+ };
54
+ }
@@ -8,7 +8,7 @@ exports.iterableSubscription = iterableSubscription;
8
8
  exports.iterableInterval = iterableInterval;
9
9
  const system_1 = require("@camstack/server/system");
10
10
  const types_1 = require("@camstack/types");
11
- const person_session_scopes_js_1 = require("../../auth/person-session-scopes.js");
11
+ const device_access_js_1 = require("./device-access.js");
12
12
  const person_without_viewer_js_1 = require("./person-without-viewer.js");
13
13
  const server_1 = require("@trpc/server");
14
14
  const superjson_1 = __importDefault(require("superjson"));
@@ -124,7 +124,8 @@ exports.protectedProcedure = localized.use(async ({ ctx, next, path, getRawInput
124
124
  // A person is an admin or a viewer (D921). Grant rows on the user record
125
125
  // are not a role: the session is decided by its viewer row alone, and a
126
126
  // person with none reaches no labelled method. Tokens keep their rows.
127
- const scopes = user.interactive === true && !user.isAdmin ? (0, person_session_scopes_js_1.personSessionScopes)(rawScopes) : rawScopes;
127
+ // `auth.deviceAccess` answers from the same scopes (`enforcedScopesOf`).
128
+ const scopes = (0, device_access_js_1.enforcedScopesOf)(user);
128
129
  const verdict = (0, principal_authorization_js_1.authorizeProcedure)(scopes, path, await getRawInput(), ctx.deviceScopeLookup);
129
130
  if (!verdict.ok) {
130
131
  if (user.interactive === true &&
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@camstack/server",
3
- "version": "1.2.838",
3
+ "version": "1.2.839",
4
4
  "license": "MIT",
5
5
  "repository": {
6
6
  "type": "git",
@@ -66,7 +66,8 @@
66
66
  ],
67
67
  "requires": {
68
68
  "addons": {
69
- "@camstack/addon-admin-ui": ">=1.2.643"
69
+ "@camstack/addon-admin-ui": ">=1.2.644",
70
+ "@camstack/addon-agent-ui": ">=1.2.365"
70
71
  },
71
72
  "wrapper": {
72
73
  "desktop": ">=0.0.1",
@@ -75,8 +76,8 @@
75
76
  }
76
77
  },
77
78
  "dependencies": {
78
- "@camstack/addon-admin-ui": "1.2.643",
79
- "@camstack/addon-agent-ui": "1.2.364",
79
+ "@camstack/addon-admin-ui": "1.2.644",
80
+ "@camstack/addon-agent-ui": "1.2.365",
80
81
  "@camstack/addon-auth": "1.2.182",
81
82
  "@camstack/addon-benchmark": "1.2.313",
82
83
  "@camstack/addon-decoder-nodeav": "1.2.149",
@@ -86,8 +87,8 @@
86
87
  "@camstack/addon-post-analysis": "1.2.693",
87
88
  "@camstack/develop": "0.1.52",
88
89
  "@camstack/sdk": "1.2.157",
89
- "@camstack/types": "1.2.547",
90
- "@camstack/ui-library": "1.2.424",
90
+ "@camstack/types": "1.2.548",
91
+ "@camstack/ui-library": "1.2.425",
91
92
  "@fastify/compress": "^9.0.0",
92
93
  "@fastify/cookie": "^11.0.2",
93
94
  "@fastify/cors": "^11.2.0",
@@ -3,7 +3,7 @@ Object.defineProperties(exports, {
3
3
  [Symbol.toStringTag]: { value: "Module" }
4
4
  });
5
5
  const require_chunk = require("../../chunk-Cek0wNdY.js");
6
- const require_dist = require("../../dist-D3_60xED.js");
6
+ const require_dist = require("../../dist-CLnTYKFn.js");
7
7
  const require_settle_sources = require("../../settle-sources-Bhsy57y-.js");
8
8
  let node_crypto = require("node:crypto");
9
9
  let node_fs = require("node:fs");
@@ -1,4 +1,4 @@
1
- import { dl as errMsg, pl as EventCategory, ps as BaseAddon, yn as addonPagesCapability } from "../../dist-yQfQUpYA.mjs";
1
+ import { hl as EventCategory, hs as BaseAddon, pl as errMsg, yn as addonPagesCapability } from "../../dist-OmrC_RZs.mjs";
2
2
  import { t as settleSourcesWithTimeout } from "../../settle-sources-CDtNC8ub.mjs";
3
3
  import { createHash, randomUUID } from "node:crypto";
4
4
  import * as fs$1 from "node:fs";
@@ -3,7 +3,7 @@ Object.defineProperties(exports, {
3
3
  [Symbol.toStringTag]: { value: "Module" }
4
4
  });
5
5
  const require_chunk = require("../../chunk-Cek0wNdY.js");
6
- const require_dist = require("../../dist-D3_60xED.js");
6
+ const require_dist = require("../../dist-CLnTYKFn.js");
7
7
  const require_settle_sources = require("../../settle-sources-Bhsy57y-.js");
8
8
  let node_crypto = require("node:crypto");
9
9
  let node_fs = require("node:fs");
@@ -1,4 +1,4 @@
1
- import { dl as errMsg, pl as EventCategory, ps as BaseAddon, xn as addonWidgetsCapability } from "../../dist-yQfQUpYA.mjs";
1
+ import { hl as EventCategory, hs as BaseAddon, pl as errMsg, xn as addonWidgetsCapability } from "../../dist-OmrC_RZs.mjs";
2
2
  import { t as settleSourcesWithTimeout } from "../../settle-sources-CDtNC8ub.mjs";
3
3
  import { createHash, randomUUID } from "node:crypto";
4
4
  import * as fs$1 from "node:fs";
@@ -3,7 +3,7 @@ Object.defineProperties(exports, {
3
3
  [Symbol.toStringTag]: { value: "Module" }
4
4
  });
5
5
  const require_chunk = require("../../chunk-Cek0wNdY.js");
6
- const require_dist = require("../../dist-D3_60xED.js");
6
+ const require_dist = require("../../dist-CLnTYKFn.js");
7
7
  const require_read_all_rows$1 = require("../../read-all-rows-CVoO1ONM.js");
8
8
  const require_log_redactor = require("../../log-redactor-BhIEMaG9.js");
9
9
  let node_fs = require("node:fs");
@@ -1,4 +1,4 @@
1
- import { Cn as alertEpisodePayload, Sn as alertEpisodeId, T as CORE_BLOCK_ADDON_PREFIX, dl as errMsg, lc as createEvent, mc as defineRecordKinds, ni as isAlertEpisodeSeverity, p as AlertSchema, pl as EventCategory, ps as BaseAddon, ti as isAlertEpisodeOpen, wn as alertsCapability } from "../../dist-yQfQUpYA.mjs";
1
+ import { Cn as alertEpisodePayload, Sn as alertEpisodeId, T as CORE_BLOCK_ADDON_PREFIX, dc as createEvent, gc as defineRecordKinds, hl as EventCategory, hs as BaseAddon, ni as isAlertEpisodeOpen, p as AlertSchema, pl as errMsg, ri as isAlertEpisodeSeverity, wn as alertsCapability } from "../../dist-OmrC_RZs.mjs";
2
2
  import { t as require_read_all_rows } from "../../read-all-rows-TaPqdWNF.mjs";
3
3
  import { a as redactLogText } from "../../log-redactor-XLDrPzOi.mjs";
4
4
  import * as fs$1 from "node:fs";
@@ -3,7 +3,7 @@ Object.defineProperties(exports, {
3
3
  [Symbol.toStringTag]: { value: "Module" }
4
4
  });
5
5
  require("../../chunk-Cek0wNdY.js");
6
- const require_dist = require("../../dist-D3_60xED.js");
6
+ const require_dist = require("../../dist-CLnTYKFn.js");
7
7
  let zod = require("zod");
8
8
  //#region src/builtins/autotrack/autotrack-config.ts
9
9
  var DEFAULT_AUTOTRACK_LOOP_CONFIG = {
@@ -1,4 +1,4 @@
1
- import { Dc as isEvent, da as ptzAutotrackCapability, dl as errMsg, kn as bareAddonId, lt as FIRST_LEVEL_MACRO_CLASSES, pl as EventCategory, ps as BaseAddon } from "../../dist-yQfQUpYA.mjs";
1
+ import { hl as EventCategory, hs as BaseAddon, kc as isEvent, kn as bareAddonId, lt as FIRST_LEVEL_MACRO_CLASSES, pa as ptzAutotrackCapability, pl as errMsg } from "../../dist-OmrC_RZs.mjs";
2
2
  import { z } from "zod";
3
3
  //#region src/builtins/autotrack/autotrack-config.ts
4
4
  var DEFAULT_AUTOTRACK_LOOP_CONFIG = {
@@ -3,9 +3,9 @@ Object.defineProperties(exports, {
3
3
  [Symbol.toStringTag]: { value: "Module" }
4
4
  });
5
5
  const require_chunk = require("../../chunk-Cek0wNdY.js");
6
- const require_dist = require("../../dist-D3_60xED.js");
6
+ const require_dist = require("../../dist-CLnTYKFn.js");
7
7
  const require_read_all_rows$1 = require("../../read-all-rows-CVoO1ONM.js");
8
- const require_restore_archive = require("../../restore-archive-DDzgcjNf.js");
8
+ const require_restore_archive = require("../../restore-archive-CcuEoEtj.js");
9
9
  let node_crypto = require("node:crypto");
10
10
  let node_fs = require("node:fs");
11
11
  node_fs = require_chunk.__toESM(node_fs);
@@ -1,6 +1,6 @@
1
- import { On as backupCapability, ao as storageOccupancyCapability, ki as mayWriteToLocation, pl as EventCategory, ps as BaseAddon, tl as toNodeId, zc as nodePin } from "../../dist-yQfQUpYA.mjs";
1
+ import { Ai as mayWriteToLocation, On as backupCapability, Vc as nodePin, hl as EventCategory, hs as BaseAddon, rl as toNodeId, so as storageOccupancyCapability } from "../../dist-OmrC_RZs.mjs";
2
2
  import { t as require_read_all_rows } from "../../read-all-rows-TaPqdWNF.mjs";
3
- import { _ as backupRecordStoresOf, a as BackupSnapshotRefusedError, d as ENCRYPTED_BACKUP_SUFFIX, f as generateBackupKeyPair, g as backupOrchestratorRecordKinds, i as BackupCancelledError, l as BackupKeyFormatError, m as parseBackupSecretKey, n as precheckRestoreKey, o as DEFAULT_BACKUP_DATABASES, p as parseBackupPublicKey, r as prepareRestoreArchive, s as SystemBackupService } from "../../restore-archive-C88Ee7w9.mjs";
3
+ import { _ as backupRecordStoresOf, a as BackupSnapshotRefusedError, d as ENCRYPTED_BACKUP_SUFFIX, f as generateBackupKeyPair, g as backupOrchestratorRecordKinds, i as BackupCancelledError, l as BackupKeyFormatError, m as parseBackupSecretKey, n as precheckRestoreKey, o as DEFAULT_BACKUP_DATABASES, p as parseBackupPublicKey, r as prepareRestoreArchive, s as SystemBackupService } from "../../restore-archive-Btc3H-Fg.mjs";
4
4
  import { randomUUID } from "node:crypto";
5
5
  import * as fs$1 from "node:fs";
6
6
  import * as path$1 from "node:path";
@@ -3,7 +3,7 @@ Object.defineProperties(exports, {
3
3
  [Symbol.toStringTag]: { value: "Module" }
4
4
  });
5
5
  require("../../chunk-Cek0wNdY.js");
6
- const require_dist = require("../../dist-D3_60xED.js");
6
+ const require_dist = require("../../dist-CLnTYKFn.js");
7
7
  const require_settle_sources = require("../../settle-sources-Bhsy57y-.js");
8
8
  let zod = require("zod");
9
9
  //#region src/builtins/calendars/calendar-color.ts
@@ -1,4 +1,4 @@
1
- import { D as CalendarPreferencesSchema, Rn as calendarsCapability, mc as defineRecordKinds, ps as BaseAddon } from "../../dist-yQfQUpYA.mjs";
1
+ import { D as CalendarPreferencesSchema, Rn as calendarsCapability, gc as defineRecordKinds, hs as BaseAddon } from "../../dist-OmrC_RZs.mjs";
2
2
  import { t as settleSourcesWithTimeout } from "../../settle-sources-CDtNC8ub.mjs";
3
3
  import { z } from "zod";
4
4
  //#region src/builtins/calendars/calendar-color.ts
@@ -3,7 +3,7 @@ Object.defineProperties(exports, {
3
3
  [Symbol.toStringTag]: { value: "Module" }
4
4
  });
5
5
  require("../../chunk-Cek0wNdY.js");
6
- const require_dist = require("../../dist-D3_60xED.js");
6
+ const require_dist = require("../../dist-CLnTYKFn.js");
7
7
  let zod = require("zod");
8
8
  let node_crypto = require("node:crypto");
9
9
  let _camstack_types_node = require("@camstack/types/node");
@@ -1,4 +1,4 @@
1
- import { $a as snapshotCapability, At as MOTION_CLOSE_AFTER_MS, B as DERIVED_CAMERA_SILENCED_CAP_NAMES, Cc as hydrateSchema, Ls as RecordIntegrationInstances, Mi as memoizePinnedFfmpeg, Oc as isInstanceEnabled, Qr as integrationInstancesCapability, Ri as motionCapability, Vo as buildFfmpegArgs, cl as DeviceFeature, dl as errMsg, et as DeclaredDevices, fr as declarationOwnerNodeId, g as BaseDevice, kn as bareAddonId, lc as createEvent, pc as defineEntryKind, pl as EventCategory, ps as BaseAddon, so as streamCatalogCapability, ul as DeviceType, zn as cameraGridLayoutCapability } from "../../dist-yQfQUpYA.mjs";
1
+ import { $r as integrationInstancesCapability, Ac as isInstanceEnabled, At as MOTION_CLOSE_AFTER_MS, B as DERIVED_CAMERA_SILENCED_CAP_NAMES, Ni as memoizePinnedFfmpeg, Tc as hydrateSchema, Uo as buildFfmpegArgs, dc as createEvent, et as DeclaredDevices, fl as DeviceType, fr as declarationOwnerNodeId, g as BaseDevice, hc as defineEntryKind, hl as EventCategory, hs as BaseAddon, kn as bareAddonId, lo as streamCatalogCapability, pl as errMsg, to as snapshotCapability, ul as DeviceFeature, zi as motionCapability, zn as cameraGridLayoutCapability, zs as RecordIntegrationInstances } from "../../dist-OmrC_RZs.mjs";
2
2
  import { z } from "zod";
3
3
  import { createHash } from "node:crypto";
4
4
  import { FfmpegProcess } from "@camstack/types/node";
@@ -3,11 +3,11 @@ Object.defineProperties(exports, {
3
3
  [Symbol.toStringTag]: { value: "Module" }
4
4
  });
5
5
  require("../../chunk-Cek0wNdY.js");
6
- const require_dist = require("../../dist-D3_60xED.js");
7
- const require_composition_sources = require("../../composition-sources-C7hUy8w0.js");
8
- const require_capture_engine = require("../../capture-engine-Bgml6l8Z.js");
6
+ const require_dist = require("../../dist-CLnTYKFn.js");
7
+ const require_composition_sources = require("../../composition-sources-DLtc8lSL.js");
8
+ const require_capture_engine = require("../../capture-engine-7E2O4-UN.js");
9
9
  const require_retention = require("../../retention-BcOSL6b9.js");
10
- const require_rename_composition_block = require("../../rename-composition-block-CbAR4yC9.js");
10
+ const require_rename_composition_block = require("../../rename-composition-block-N7lslQJK.js");
11
11
  let zod = require("zod");
12
12
  //#region src/builtins/composer/actuator-invoke.ts
13
13
  /**
@@ -1,8 +1,8 @@
1
- import { $i as petFountainWaterItem, $n as compositionFieldKey, A as ConsumableItemSchema, Aa as resolveMutate, Ac as isReadingQuantity, Ai as mediaPlayerCapability, Bo as MINUTE_MS, Ci as lockControlCapability, Fo as DEFAULT_HISTORY_RETENTION, Go as compositionFeatureEnabled, Ho as cloneStatefulExpressionMemory, Ia as runFanOut, Io as HISTORY_FAST_MS, Ir as expressionContainsBuiltinCall, Ja as sharedActuatorMethods, Jo as compositionSourceKey, Kn as climateControlCapability, Ko as compositionItemFieldPath, Lo as HISTORY_SLOW_MS, Mo as COMPOSER_ADDON_ID, Ni as methodRefusal, Nn as buildCapabilityLookup, Qi as petFountainCapability, Qn as composerCapability, Qo as evaluateStatistic, Ri as motionCapability, Ro as HOUR_MS, Rr as fanControlCapability, S as COMPOSED_ITEM_FIXED_FIELDS, Uo as composedDeviceRef, Vr as featureForwards, Wo as composedDeviceStableId, Xi as parseColorInput, Xo as disarmRoseMemory, Xr as groupTemplate, Ya as sharedColorModes, Yn as colorCapability, Yo as createStatefulExpressionMemory, Yr as groupCommandsCapability, Zo as evaluateDerivative, as as nextLocalMidnight, bt as HvacModeSchema, ca as processTimeZoneOr, cs as planResetTier, dl as errMsg, ds as toExpressionValue, dt as FanDirectionSchema, es as historyRetentionFromSettings, et as DeclaredDevices, fl as featuresOfBoundCaps, g as BaseDevice, ht as GroupCommandResultSchema, i as ACTUATOR_TEMPLATE_IDS, is as isHistoryHelper, ji as mediaPlayerFeaturesOfRoles, jn as brightnessCapability, jr as evaluateCompositionField, ko as withDefaultRunning, lc as createEvent, ls as planStatisticTier, mi as kebabToCamel, ns as integrateReading, os as openReset, pl as EventCategory, pr as declaredSeriesKind, ps as BaseAddon, qa as sharedActuatorFeatures, qo as compositionSliceKey, r as ACTUATOR_METHODS, rs as isForwardInputRef, s as ALL_CAPABILITY_DEFINITIONS, sr as coverCapability, ss as openStatistic, ta as planComposition, tr as consumablesCapability, ul as DeviceType, uo as switchCapability, us as statisticCadenceMs, wo as valveCapability, zr as fanOutTargets, zt as PetFountainStatusSchema } from "../../dist-yQfQUpYA.mjs";
2
- import { i as parseDeviceStateChanged, n as normalizedNativeOwner, r as isRecord$4 } from "../../composition-sources-CrL4KcSA.mjs";
3
- import { i as capSeriesKey } from "../../capture-engine-BQjIa865.mjs";
1
+ import { $n as compositionFieldKey, $o as evaluateDerivative, A as ConsumableItemSchema, Bo as HOUR_MS, Eo as valveCapability, Go as composedDeviceRef, Ho as MINUTE_MS, Ir as expressionContainsBuiltinCall, Jo as compositionItemFieldPath, Kn as climateControlCapability, Ko as composedDeviceStableId, Lo as DEFAULT_HISTORY_RETENTION, Ma as resolveMutate, Mc as isReadingQuantity, Mi as mediaPlayerFeaturesOfRoles, Nn as buildCapabilityLookup, Pi as methodRefusal, Po as COMPOSER_ADDON_ID, Qi as parseColorInput, Qn as composerCapability, Qo as disarmRoseMemory, Ra as runFanOut, Ro as HISTORY_FAST_MS, Rr as fanControlCapability, S as COMPOSED_ITEM_FIXED_FIELDS, Vr as featureForwards, Wo as cloneStatefulExpressionMemory, Xa as sharedActuatorMethods, Xo as compositionSourceKey, Xr as groupTemplate, Ya as sharedActuatorFeatures, Yn as colorCapability, Yo as compositionSliceKey, Yr as groupCommandsCapability, Za as sharedColorModes, Zo as createStatefulExpressionMemory, as as isForwardInputRef, bt as HvacModeSchema, cs as openReset, dc as createEvent, ds as planStatisticTier, dt as FanDirectionSchema, ea as petFountainCapability, es as evaluateStatistic, et as DeclaredDevices, fl as DeviceType, fo as switchCapability, fs as statisticCadenceMs, g as BaseDevice, hi as kebabToCamel, hl as EventCategory, hs as BaseAddon, ht as GroupCommandResultSchema, i as ACTUATOR_TEMPLATE_IDS, is as integrateReading, ji as mediaPlayerCapability, jn as brightnessCapability, jo as withDefaultRunning, jr as evaluateCompositionField, ls as openStatistic, ml as featuresOfBoundCaps, ns as historyRetentionFromSettings, os as isHistoryHelper, pl as errMsg, pr as declaredSeriesKind, ps as toExpressionValue, qo as compositionFeatureEnabled, r as ACTUATOR_METHODS, ra as planComposition, s as ALL_CAPABILITY_DEFINITIONS, sr as coverCapability, ss as nextLocalMidnight, ta as petFountainWaterItem, tr as consumablesCapability, ua as processTimeZoneOr, us as planResetTier, wi as lockControlCapability, zi as motionCapability, zo as HISTORY_SLOW_MS, zr as fanOutTargets, zt as PetFountainStatusSchema } from "../../dist-OmrC_RZs.mjs";
2
+ import { i as parseDeviceStateChanged, n as normalizedNativeOwner, r as isRecord$4 } from "../../composition-sources-Cfqn4cly.mjs";
3
+ import { i as capSeriesKey } from "../../capture-engine-B5IBWIRT.mjs";
4
4
  import { i as DAY_MS, t as DEFAULT_RETENTION } from "../../retention-CUOVI1p7.mjs";
5
- import { n as renameCompositionBlock } from "../../rename-composition-block-DXN1dVXs.mjs";
5
+ import { n as renameCompositionBlock } from "../../rename-composition-block-DPlsP1xF.mjs";
6
6
  import { z } from "zod";
7
7
  //#region src/builtins/composer/actuator-invoke.ts
8
8
  /**
@@ -3,7 +3,7 @@ Object.defineProperties(exports, {
3
3
  [Symbol.toStringTag]: { value: "Module" }
4
4
  });
5
5
  require("../../chunk-Cek0wNdY.js");
6
- const require_dist = require("../../dist-D3_60xED.js");
6
+ const require_dist = require("../../dist-CLnTYKFn.js");
7
7
  const require_formatter = require("../../formatter-xbxeV4GD.js");
8
8
  //#region src/builtins/console-logging/console-destination.ts
9
9
  var LEVEL_RANK = {
@@ -1,4 +1,4 @@
1
- import { Ti as logDestinationCapability, ps as BaseAddon } from "../../dist-yQfQUpYA.mjs";
1
+ import { Ei as logDestinationCapability, hs as BaseAddon } from "../../dist-OmrC_RZs.mjs";
2
2
  import { t as formatLogLine } from "../../formatter-DkYZ4LXp.mjs";
3
3
  //#region src/builtins/console-logging/console-destination.ts
4
4
  var LEVEL_RANK = {
@@ -1,9 +1,9 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
2
  const require_chunk = require("../../chunk-Cek0wNdY.js");
3
- const require_dist = require("../../dist-D3_60xED.js");
3
+ const require_dist = require("../../dist-CLnTYKFn.js");
4
4
  const require_read_all_rows$1 = require("../../read-all-rows-CVoO1ONM.js");
5
- const require_composition_sources = require("../../composition-sources-C7hUy8w0.js");
6
- const require_capture_engine = require("../../capture-engine-Bgml6l8Z.js");
5
+ const require_composition_sources = require("../../composition-sources-DLtc8lSL.js");
6
+ const require_capture_engine = require("../../capture-engine-7E2O4-UN.js");
7
7
  const require_prefix_range = require("../../prefix-range-D_KueXbQ.js");
8
8
  const require_prefix_walk = require("../../prefix-walk-Dv6MLZlM.js");
9
9
  const require_cap_call_scope = require("../../cap-call-scope-8eiugfLl.js");
@@ -2825,6 +2825,10 @@ function stepRenderer(door, allowedDeviceIds) {
2825
2825
  * answer, and an out-of-scope answer is a leak — so a tree naming any other
2826
2826
  * device (or a stable id, which cannot be proven) reads `unknown`: neither side
2827
2827
  * runs, and the trace says why.
2828
+ *
2829
+ * A `time-is` leaf reads the site clock: the door reads `system.getSiteLocation`
2830
+ * for a tree that holds one (never for a tree that does not). A site that
2831
+ * cannot be read is `unknown`, as any other read the guard depends on.
2828
2832
  */
2829
2833
  function conditionDoorOver(api) {
2830
2834
  return (readable) => async (when) => {
@@ -2839,13 +2843,23 @@ function conditionDoorOver(api) {
2839
2843
  reason: "the condition reads a device this caller was not proven to see"
2840
2844
  };
2841
2845
  }
2846
+ let site;
2847
+ if (require_dist.hasTimeLeaves(when)) try {
2848
+ const reading = await current.system.getSiteLocation.query();
2849
+ site = require_dist.siteFor(reading) ?? require_dist.zoneOnlySite(reading.timeZone);
2850
+ } catch (error) {
2851
+ return {
2852
+ result: "unknown",
2853
+ reason: `the site could not be read, so the time window cannot be judged (${error instanceof Error ? error.message : String(error)})`
2854
+ };
2855
+ }
2842
2856
  return require_dist.evaluateStepCondition(when, {
2843
2857
  fetchSlice: (deviceId, cap) => current.deviceState.getCapSlice.query({
2844
2858
  deviceId,
2845
2859
  capName: cap
2846
2860
  }),
2847
2861
  fetchStableIds: async () => require_dist.stableIdMapOf(await current.deviceManager.listAll.query({}))
2848
- });
2862
+ }, () => Date.now(), void 0, site);
2849
2863
  };
2850
2864
  }
2851
2865
  /** The evaluator a step run is given; `undefined` when the consumer has no door. */
@@ -5214,7 +5228,7 @@ var SchedulerEngine = class {
5214
5228
  }
5215
5229
  }
5216
5230
  truthAt(now) {
5217
- return (when) => when === void 0 || require_dist.evaluateWhenTree(when, this.mirror, now).pass;
5231
+ return (when) => when === void 0 || require_dist.evaluateWhenTree(when, this.mirror, now, { site: this.site }).pass;
5218
5232
  }
5219
5233
  /** Every (device, cap) a scheduler's rules or holds read, so state events can wake it. */
5220
5234
  async rebuildMirror() {
@@ -5337,11 +5351,36 @@ var SchedulerEngine = class {
5337
5351
  for (const id of ids) {
5338
5352
  const s = this.schedulers.find((x) => x.id === id);
5339
5353
  if (s === void 0) this.holds.end(id);
5340
- else await this.holds.reconcile(s);
5354
+ else {
5355
+ await this.holds.reconcile(s);
5356
+ this.wakeAtTimeBoundary(s);
5357
+ }
5341
5358
  }
5342
5359
  }
5343
5360
  this.arm();
5344
5361
  }
5362
+ /**
5363
+ * A `time-is` leaf changes sides at a boundary with no device event and no
5364
+ * point of the timeline: queue a wake there, so the scheduler is reconciled
5365
+ * AT the boundary. Every tree of the scheduler is walked; the wake it leads to
5366
+ * reconciles and arms the next one.
5367
+ */
5368
+ wakeAtTimeBoundary(s) {
5369
+ if (!s.enabled) return;
5370
+ const now = this.clock.now();
5371
+ const trees = [s.activeWhen, ...s.profiles.flatMap((profile) => [profile.activeWhen, ...profile.points.map((point) => point.conditions)])];
5372
+ let due;
5373
+ for (const tree of trees) {
5374
+ if (tree === void 0) continue;
5375
+ const ms = require_dist.nextTimeBoundaryInMs(tree, now, this.site);
5376
+ if (ms !== void 0) due = due === void 0 ? ms : Math.min(due, ms);
5377
+ }
5378
+ if (due !== void 0) this.insert({
5379
+ kind: "wake",
5380
+ at: now + due,
5381
+ schedulerId: s.id
5382
+ });
5383
+ }
5345
5384
  async handlePoint(entry) {
5346
5385
  const scheduler = this.schedulers.find((s) => s.id === entry.schedulerId);
5347
5386
  const profile = scheduler?.profiles.find((p) => p.id === entry.profileId);
@@ -1,7 +1,7 @@
1
- import { $o as helperMembers, $r as internalActionId, Ba as schedulersCapability, Bi as normalizeActionUnits, Br as fanPresetsCapability, Bt as PowerSourceInfoSchema, C as COMPOSER_RUNNER_ID, Cc as hydrateSchema, Co as validateSchedulerInput, Ea as resolveHeroLayout, Fc as isSecretRefOwnedBy, Gn as checkTemplatePayload, Hi as normalizeCoreBlockWrite, In as buildHeroModel, Jc as resolveSecretMarkers, Jn as collectWhenMirrorSources, Jo as compositionSourceKey, Kt as REMOTE_MEDIA_COMMANDS, La as runSteps, Ls as RecordIntegrationInstances, M as CoreBlockSchema, Ma as resolveRemoteSource, Mn as buildActionSteps, Mo as COMPOSER_ADDON_ID, Mr as evaluateStepCondition, Nc as isSecretMarker, Nn as buildCapabilityLookup, No as CompositionSchema, Nr as evaluateWhenTree, Oo as weekdayOfLocalDate, Pa as resolveStepArgs, Po as DAY_MS, Qc as secretTreeFromSchema, Qr as integrationInstancesCapability, St as INTERNAL_ACTION_PREFIX, T as CORE_BLOCK_ADDON_PREFIX, Ta as resolveCoreBlockFiles, Tn as appendTrace, Ui as normalizeStepTargets, Uo as composedDeviceRef, Ur as findChannelSource, Vi as normalizeCapStep, Vn as capUnitResolver, Wa as seedInstanceOnce, Wo as composedDeviceStableId, Wt as QuantityUnitError, Xt as RemoteLayoutPayloadSchema, Yc as ruleFireOfClaim, Ys as actionEffect, Yt as RemoteAssumedStateSchema, Za as siteFor, Zn as compileScalarOverride, Zr as heroLayoutCapability, Zt as RunningStateStatusSchema, _a as remoteCapability, _c as entryBody, _n as actionsCapability, _o as timedRunSeconds, _r as describeComposableCaps, ac as collectSecretMarkerRefs, al as vocabActionIdFor, ar as coreBlockSourceKind, at as EMPTY_AUTOMATION_STATE, ba as replacedFieldKeys, bi as localDateOf, c as ActionError, cc as commandOrigin$1, ci as isInternalActionId, ct as FAN_CAPTURE_FIELDS, d as ActionTargetResolver, dc as defineAddonMigrations, dl as errMsg$1, dn as TemplateKindSchema, er as compositionSourceRefs, es as historyRetentionFromSettings, et as DeclaredDevices, f as ActionVariableSchema, fa as readStoredRemoteConfig, fo as templateCapability, ft as FanPresetSchema, gn as actionWaitTotalMs, go as timedRunQuickRun, h as BUILTIN_REMOTE_COMPONENTS, hn as actionSourceCapability, ho as timedRunMaxIn, ia as powerSourceLinkOfComposition, ir as coreBlockIdFromAddonId, j as ControlStatusSchema, jo as zoneOnlySite, jt as MediaPlayerStatusSchema, k as ConditionMirror, l as ActionMinDelaySecSchema, la as projectDeviceRow, lr as customKeyOfRole, m as AutomationStateDocSchema, mc as defineRecordKinds, mi as kebabToCamel, mo as timedRunLimitOf, n as ACTION_TARGET_INVALIDATION_EVENTS, nn as SchedulerSchema, nr as coreBlockAddonId, oa as problemsBlockSave, or as coreBlocksCapability, ot as EMPTY_REMOTE_ASSUMED_STATE, pc as defineEntryKind, pl as EventCategory$1, po as timedRunCapability, ps as BaseAddon, qi as occurrenceOn, qn as collectDeviceTemplates, ra as powerSourceCapability, rl as transformSecretWrite, rr as coreBlockComposition, s as ALL_CAPABILITY_DEFINITIONS, st as EMPTY_REMOTE_CONFIG, ta as planComposition, tn as SchedulerError, to as stableIdMapOf, u as ActionStepSchema, ua as proposeRunningThreshold, ul as DeviceType$1, un as SwitchStatusSchema, ut as FanControlStatusSchema, va as remoteLayoutComponentsCapability, vn as addonIdOfActionId, vo as toTimings, w as CORE_BLOCKS_ADDON_ID, wa as resolveCoreBlockEntry, wi as lockDoorLinkOfComposition, xa as resolveActionVariables, xo as validateComposition, xt as IDLE_ACTION_STATUS, ya as remoteSourceSteps, z as DEFAULT_HOLD_OVERRIDE, zi as nextOccurrence, zo as HelperMemberSchema } from "../../dist-yQfQUpYA.mjs";
1
+ import { $a as siteFor, $r as integrationInstancesCapability, Ao as weekdayOfLocalDate, Bi as nextOccurrence, Br as fanPresetsCapability, Bt as PowerSourceInfoSchema, C as COMPOSER_RUNNER_ID, Ca as resolveActionVariables, Co as validateComposition, Da as resolveCoreBlockFiles, Ea as resolveCoreBlockEntry, Fc as isSecretMarker, Fo as CompositionSchema, Gi as normalizeStepTargets, Gn as checkTemplatePayload, Go as composedDeviceRef, Ha as schedulersCapability, Hi as normalizeActionUnits, Ia as resolveStepArgs, In as buildHeroModel, Io as DAY_MS, Jn as collectWhenMirrorSources, Ka as seedInstanceOnce, Ko as composedDeviceStableId, Kt as REMOTE_MEDIA_COMMANDS, Lc as isSecretRefOwnedBy, M as CoreBlockSchema, Mn as buildActionSteps, Mr as evaluateStepCondition, Nn as buildCapabilityLookup, No as zoneOnlySite, Nr as evaluateWhenTree, Oa as resolveHeroLayout, Pa as resolveRemoteSource, Po as COMPOSER_ADDON_ID, Qr as heroLayoutCapability, Sa as replacedFieldKeys, St as INTERNAL_ACTION_PREFIX, T as CORE_BLOCK_ADDON_PREFIX, Tc as hydrateSchema, Ti as lockDoorLinkOfComposition, Tn as appendTrace, To as validateSchedulerInput, Ui as normalizeCapStep, Ur as findChannelSource, Vi as nextTimeBoundaryInMs, Vn as capUnitResolver, Vo as HelperMemberSchema, Wi as normalizeCoreBlockWrite, Wt as QuantityUnitError, Xc as resolveSecretMarkers, Xo as compositionSourceKey, Xt as RemoteLayoutPayloadSchema, Yi as occurrenceOn, Yt as RemoteAssumedStateSchema, Zc as ruleFireOfClaim, Zn as compileScalarOverride, Zr as hasTimeLeaves, Zs as actionEffect, Zt as RunningStateStatusSchema, _n as actionsCapability, _o as timedRunMaxIn, _r as describeComposableCaps, aa as powerSourceCapability, al as transformSecretWrite, ar as coreBlockSourceKind, at as EMPTY_AUTOMATION_STATE, ba as remoteLayoutComponentsCapability, bo as toTimings, c as ActionError, ca as problemsBlockSave, ct as FAN_CAPTURE_FIELDS, d as ActionTargetResolver, da as projectDeviceRow, dn as TemplateKindSchema, ei as internalActionId, el as secretTreeFromSchema, er as compositionSourceRefs, et as DeclaredDevices, f as ActionVariableSchema, fa as proposeRunningThreshold, fl as DeviceType$1, ft as FanPresetSchema, gc as defineRecordKinds, gn as actionWaitTotalMs, go as timedRunLimitOf, h as BUILTIN_REMOTE_COMPONENTS, hc as defineEntryKind, hi as kebabToCamel, hl as EventCategory$1, hn as actionSourceCapability, ho as timedRunCapability, hs as BaseAddon, ir as coreBlockIdFromAddonId, j as ControlStatusSchema, jt as MediaPlayerStatusSchema, k as ConditionMirror, l as ActionMinDelaySecSchema, li as isInternalActionId, lr as customKeyOfRole, m as AutomationStateDocSchema, ma as readStoredRemoteConfig, mo as templateCapability, n as ACTION_TARGET_INVALIDATION_EVENTS, nn as SchedulerSchema, nr as coreBlockAddonId, ns as historyRetentionFromSettings, oa as powerSourceLinkOfComposition, or as coreBlocksCapability, ot as EMPTY_REMOTE_ASSUMED_STATE, pc as defineAddonMigrations, pl as errMsg$1, qn as collectDeviceTemplates, ra as planComposition, ro as stableIdMapOf, rr as coreBlockComposition, s as ALL_CAPABILITY_DEFINITIONS, sc as collectSecretMarkerRefs, sl as vocabActionIdFor, st as EMPTY_REMOTE_CONFIG, tn as SchedulerError, ts as helperMembers, u as ActionStepSchema, uc as commandOrigin$1, un as SwitchStatusSchema, ut as FanControlStatusSchema, vn as addonIdOfActionId, vo as timedRunQuickRun, w as CORE_BLOCKS_ADDON_ID, xa as remoteSourceSteps, xi as localDateOf, xt as IDLE_ACTION_STATUS, ya as remoteCapability, yc as entryBody, yo as timedRunSeconds, z as DEFAULT_HOLD_OVERRIDE, za as runSteps, zs as RecordIntegrationInstances } from "../../dist-OmrC_RZs.mjs";
2
2
  import { t as require_read_all_rows } from "../../read-all-rows-TaPqdWNF.mjs";
3
- import { i as parseDeviceStateChanged, r as isRecord$1, t as describeCompositionSources } from "../../composition-sources-CrL4KcSA.mjs";
4
- import { i as capSeriesKey } from "../../capture-engine-BQjIa865.mjs";
3
+ import { i as parseDeviceStateChanged, r as isRecord$1, t as describeCompositionSources } from "../../composition-sources-Cfqn4cly.mjs";
4
+ import { i as capSeriesKey } from "../../capture-engine-B5IBWIRT.mjs";
5
5
  import { t as prefixRange } from "../../prefix-range-Dl0znowN.mjs";
6
6
  import { n as unwrapStoredValue, t as loadPrefixed } from "../../prefix-walk-DAOBSyH1.mjs";
7
7
  import { n as readCurrentCommandOrigin } from "../../cap-call-scope-Bic6Ekfw.mjs";
@@ -2819,6 +2819,10 @@ function stepRenderer(door, allowedDeviceIds) {
2819
2819
  * answer, and an out-of-scope answer is a leak — so a tree naming any other
2820
2820
  * device (or a stable id, which cannot be proven) reads `unknown`: neither side
2821
2821
  * runs, and the trace says why.
2822
+ *
2823
+ * A `time-is` leaf reads the site clock: the door reads `system.getSiteLocation`
2824
+ * for a tree that holds one (never for a tree that does not). A site that
2825
+ * cannot be read is `unknown`, as any other read the guard depends on.
2822
2826
  */
2823
2827
  function conditionDoorOver(api) {
2824
2828
  return (readable) => async (when) => {
@@ -2833,13 +2837,23 @@ function conditionDoorOver(api) {
2833
2837
  reason: "the condition reads a device this caller was not proven to see"
2834
2838
  };
2835
2839
  }
2840
+ let site;
2841
+ if (hasTimeLeaves(when)) try {
2842
+ const reading = await current.system.getSiteLocation.query();
2843
+ site = siteFor(reading) ?? zoneOnlySite(reading.timeZone);
2844
+ } catch (error) {
2845
+ return {
2846
+ result: "unknown",
2847
+ reason: `the site could not be read, so the time window cannot be judged (${error instanceof Error ? error.message : String(error)})`
2848
+ };
2849
+ }
2836
2850
  return evaluateStepCondition(when, {
2837
2851
  fetchSlice: (deviceId, cap) => current.deviceState.getCapSlice.query({
2838
2852
  deviceId,
2839
2853
  capName: cap
2840
2854
  }),
2841
2855
  fetchStableIds: async () => stableIdMapOf(await current.deviceManager.listAll.query({}))
2842
- });
2856
+ }, () => Date.now(), void 0, site);
2843
2857
  };
2844
2858
  }
2845
2859
  /** The evaluator a step run is given; `undefined` when the consumer has no door. */
@@ -5208,7 +5222,7 @@ var SchedulerEngine = class {
5208
5222
  }
5209
5223
  }
5210
5224
  truthAt(now) {
5211
- return (when) => when === void 0 || evaluateWhenTree(when, this.mirror, now).pass;
5225
+ return (when) => when === void 0 || evaluateWhenTree(when, this.mirror, now, { site: this.site }).pass;
5212
5226
  }
5213
5227
  /** Every (device, cap) a scheduler's rules or holds read, so state events can wake it. */
5214
5228
  async rebuildMirror() {
@@ -5331,11 +5345,36 @@ var SchedulerEngine = class {
5331
5345
  for (const id of ids) {
5332
5346
  const s = this.schedulers.find((x) => x.id === id);
5333
5347
  if (s === void 0) this.holds.end(id);
5334
- else await this.holds.reconcile(s);
5348
+ else {
5349
+ await this.holds.reconcile(s);
5350
+ this.wakeAtTimeBoundary(s);
5351
+ }
5335
5352
  }
5336
5353
  }
5337
5354
  this.arm();
5338
5355
  }
5356
+ /**
5357
+ * A `time-is` leaf changes sides at a boundary with no device event and no
5358
+ * point of the timeline: queue a wake there, so the scheduler is reconciled
5359
+ * AT the boundary. Every tree of the scheduler is walked; the wake it leads to
5360
+ * reconciles and arms the next one.
5361
+ */
5362
+ wakeAtTimeBoundary(s) {
5363
+ if (!s.enabled) return;
5364
+ const now = this.clock.now();
5365
+ const trees = [s.activeWhen, ...s.profiles.flatMap((profile) => [profile.activeWhen, ...profile.points.map((point) => point.conditions)])];
5366
+ let due;
5367
+ for (const tree of trees) {
5368
+ if (tree === void 0) continue;
5369
+ const ms = nextTimeBoundaryInMs(tree, now, this.site);
5370
+ if (ms !== void 0) due = due === void 0 ? ms : Math.min(due, ms);
5371
+ }
5372
+ if (due !== void 0) this.insert({
5373
+ kind: "wake",
5374
+ at: now + due,
5375
+ schedulerId: s.id
5376
+ });
5377
+ }
5339
5378
  async handlePoint(entry) {
5340
5379
  const scheduler = this.schedulers.find((s) => s.id === entry.schedulerId);
5341
5380
  const profile = scheduler?.profiles.find((p) => p.id === entry.profileId);
@@ -87,6 +87,13 @@ export declare class SchedulerEngine {
87
87
  /** Everything due, in time order, then the holds. */
88
88
  private drain;
89
89
  private settle;
90
+ /**
91
+ * A `time-is` leaf changes sides at a boundary with no device event and no
92
+ * point of the timeline: queue a wake there, so the scheduler is reconciled
93
+ * AT the boundary. Every tree of the scheduler is walked; the wake it leads to
94
+ * reconciles and arms the next one.
95
+ */
96
+ private wakeAtTimeBoundary;
90
97
  private handlePoint;
91
98
  private runEdge;
92
99
  private performEdge;
@@ -6,6 +6,10 @@
6
6
  * answer, and an out-of-scope answer is a leak — so a tree naming any other
7
7
  * device (or a stable id, which cannot be proven) reads `unknown`: neither side
8
8
  * runs, and the trace says why.
9
+ *
10
+ * A `time-is` leaf reads the site clock: the door reads `system.getSiteLocation`
11
+ * for a tree that holds one (never for a tree that does not). A site that
12
+ * cannot be read is `unknown`, as any other read the guard depends on.
9
13
  */
10
14
  import { type AddonApi, type EvaluateStepCondition } from "@camstack/types";
11
15
  /** Builds the evaluator for one run, bound to the devices its caller may read (`undefined` = all). */
@@ -3,8 +3,8 @@ Object.defineProperties(exports, {
3
3
  [Symbol.toStringTag]: { value: "Module" }
4
4
  });
5
5
  require("../../chunk-Cek0wNdY.js");
6
- const require_dist = require("../../dist-D3_60xED.js");
7
- const require_capture_engine = require("../../capture-engine-Bgml6l8Z.js");
6
+ const require_dist = require("../../dist-CLnTYKFn.js");
7
+ const require_capture_engine = require("../../capture-engine-7E2O4-UN.js");
8
8
  const require_retention = require("../../retention-BcOSL6b9.js");
9
9
  let node_crypto = require("node:crypto");
10
10
  //#region src/builtins/device-history/capture/point-writer.ts