@camstack/server 1.2.890 → 1.2.892

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 (119) hide show
  1. package/CHANGELOG.md +22 -0
  2. package/dist/api/trpc/generated-cap-mounts.js +2 -1
  3. package/dist/api/trpc/generated-cap-routers.js +212 -39
  4. package/dist/core/addon/addon-registry.service.js +47 -0
  5. package/dist/core/addon/retire-undeclared-fixed-integrations.js +57 -0
  6. package/package.json +31 -19
  7. package/system/dist/addon-runner.js +25 -9
  8. package/system/dist/addon-runner.mjs +25 -9
  9. package/system/dist/builtins/addon-pages-aggregator/addon-pages-aggregator.addon.js +1 -1
  10. package/system/dist/builtins/addon-pages-aggregator/addon-pages-aggregator.addon.mjs +1 -1
  11. package/system/dist/builtins/addon-widgets-aggregator/addon-widgets-aggregator.addon.js +1 -1
  12. package/system/dist/builtins/addon-widgets-aggregator/addon-widgets-aggregator.addon.mjs +1 -1
  13. package/system/dist/builtins/alerts/alerts.addon.js +1 -1
  14. package/system/dist/builtins/alerts/alerts.addon.mjs +1 -1
  15. package/system/dist/builtins/autotrack/index.js +1 -1
  16. package/system/dist/builtins/autotrack/index.mjs +1 -1
  17. package/system/dist/builtins/backup-orchestrator/backup-orchestrator.addon.js +2 -2
  18. package/system/dist/builtins/backup-orchestrator/backup-orchestrator.addon.mjs +2 -2
  19. package/system/dist/builtins/calendars/calendars.addon.js +1 -1
  20. package/system/dist/builtins/calendars/calendars.addon.mjs +1 -1
  21. package/system/dist/builtins/camera-grid/addon.d.ts +65 -41
  22. package/system/dist/builtins/camera-grid/grid-blocks.d.ts +51 -0
  23. package/system/dist/builtins/camera-grid/grid-camera-device.d.ts +4 -3
  24. package/system/dist/builtins/camera-grid/grid-layout-native-provider.d.ts +3 -1
  25. package/system/dist/builtins/camera-grid/grid-plan.d.ts +3 -3
  26. package/system/dist/builtins/camera-grid/index.d.ts +2 -6
  27. package/system/dist/builtins/camera-grid/index.js +431 -727
  28. package/system/dist/builtins/camera-grid/index.mjs +428 -719
  29. package/system/dist/builtins/composer/composed-device.d.ts +12 -2
  30. package/system/dist/builtins/composer/composer.addon.js +28 -10
  31. package/system/dist/builtins/composer/composer.addon.mjs +28 -10
  32. package/system/dist/builtins/composer/composition-declarations.d.ts +3 -1
  33. package/system/dist/builtins/console-logging/index.js +1 -1
  34. package/system/dist/builtins/console-logging/index.mjs +1 -1
  35. package/system/dist/builtins/core-blocks/core-blocks.addon.js +283 -51
  36. package/system/dist/builtins/core-blocks/core-blocks.addon.mjs +284 -52
  37. package/system/dist/builtins/core-blocks/hero-layout-service.d.ts +19 -1
  38. package/system/dist/builtins/core-blocks/power-source-devices.d.ts +9 -0
  39. package/system/dist/builtins/core-blocks/power-source-service.d.ts +39 -2
  40. package/system/dist/builtins/core-blocks/tags-service.d.ts +20 -3
  41. package/system/dist/builtins/core-blocks/tags-wiring.d.ts +15 -2
  42. package/system/dist/builtins/device-history/device-history.addon.js +2 -2
  43. package/system/dist/builtins/device-history/device-history.addon.mjs +2 -2
  44. package/system/dist/builtins/device-manager/device-identifiers-action.d.ts +9 -0
  45. package/system/dist/builtins/device-manager/device-manager.addon.js +172 -5
  46. package/system/dist/builtins/device-manager/device-manager.addon.mjs +172 -5
  47. package/system/dist/builtins/device-manager/device-meta-types.d.ts +5 -1
  48. package/system/dist/builtins/device-manager/device-row-store.d.ts +3 -2
  49. package/system/dist/builtins/device-manager/device-state-mirror.d.ts +7 -0
  50. package/system/dist/builtins/device-manager/workload-transition.d.ts +23 -0
  51. package/system/dist/builtins/hub-forwarder/index.js +1 -1
  52. package/system/dist/builtins/hub-forwarder/index.mjs +1 -1
  53. package/system/dist/builtins/keychain/index.js +4 -4
  54. package/system/dist/builtins/keychain/index.mjs +4 -4
  55. package/system/dist/builtins/liveness-monitor/liveness-monitor.addon.js +1 -1
  56. package/system/dist/builtins/liveness-monitor/liveness-monitor.addon.mjs +1 -1
  57. package/system/dist/builtins/local-auth/local-auth.addon.js +2 -2
  58. package/system/dist/builtins/local-auth/local-auth.addon.mjs +2 -2
  59. package/system/dist/builtins/local-network/local-network.addon.js +3 -3
  60. package/system/dist/builtins/local-network/local-network.addon.mjs +3 -3
  61. package/system/dist/builtins/loki-logging/index.js +1 -1
  62. package/system/dist/builtins/loki-logging/index.mjs +1 -1
  63. package/system/dist/builtins/native-metrics/native-metrics.addon.js +1 -1
  64. package/system/dist/builtins/native-metrics/native-metrics.addon.mjs +1 -1
  65. package/system/dist/builtins/platform-probe/index.js +1 -1
  66. package/system/dist/builtins/platform-probe/index.mjs +1 -1
  67. package/system/dist/builtins/record-entries/index.js +1 -1
  68. package/system/dist/builtins/record-entries/index.mjs +1 -1
  69. package/system/dist/builtins/remote-access-orchestrator/remote-access-orchestrator.addon.js +1 -1
  70. package/system/dist/builtins/remote-access-orchestrator/remote-access-orchestrator.addon.mjs +1 -1
  71. package/system/dist/builtins/snapshot/index.js +1 -1
  72. package/system/dist/builtins/snapshot/index.mjs +1 -1
  73. package/system/dist/builtins/sqlite-storage/filesystem-storage.addon.js +1 -1
  74. package/system/dist/builtins/sqlite-storage/filesystem-storage.addon.mjs +1 -1
  75. package/system/dist/builtins/sqlite-storage/index.js +1 -1
  76. package/system/dist/builtins/sqlite-storage/index.mjs +1 -1
  77. package/system/dist/builtins/sqlite-storage/sqlite-settings.addon.js +3 -3
  78. package/system/dist/builtins/sqlite-storage/sqlite-settings.addon.mjs +3 -3
  79. package/system/dist/builtins/storage-orchestrator/storage-orchestrator.addon.js +1 -1
  80. package/system/dist/builtins/storage-orchestrator/storage-orchestrator.addon.mjs +1 -1
  81. package/system/dist/builtins/system-config/system-config.addon.js +3 -3
  82. package/system/dist/builtins/system-config/system-config.addon.mjs +284 -284
  83. package/system/dist/builtins/winston-logging/index.js +1 -1
  84. package/system/dist/builtins/winston-logging/index.mjs +1 -1
  85. package/system/dist/{capture-engine-C1vdBL88.js → capture-engine-DHmlkW_d.js} +1 -1
  86. package/system/dist/{capture-engine-B1bMuzVX.mjs → capture-engine-sl6e9f9S.mjs} +1 -1
  87. package/system/dist/{composition-sources-Dj6qn5PP.mjs → composition-sources-CznD85Ri.mjs} +1 -1
  88. package/system/dist/{composition-sources-BfLlyKRe.js → composition-sources-PqcZfe3j.js} +1 -1
  89. package/system/dist/{constants-Ba51ywI4.mjs → constants-CHwj_mIM.mjs} +1 -1
  90. package/system/dist/{constants-DuB_xXYx.js → constants-_2SOk0By.js} +1 -1
  91. package/system/dist/{device-ca-CkXjf3ms.mjs → device-ca-D2H1EMUY.mjs} +1 -1
  92. package/system/dist/{device-ca-CVjaotgX.js → device-ca-WIEO5ZcE.js} +1 -1
  93. package/system/dist/{dist-BKojK6Wf.mjs → dist-DbAhCrHy.mjs} +2468 -454
  94. package/system/dist/{dist-BjhII4Uq.js → dist-yx2KHo3b.js} +2575 -453
  95. package/system/dist/file-host-worker.js +1 -1
  96. package/system/dist/file-host-worker.mjs +1 -1
  97. package/system/dist/{hub-identity-C0qf888i.mjs → hub-identity-BcvZqT0L.mjs} +1 -1
  98. package/system/dist/{hub-identity-C0ehkt78.js → hub-identity-Buegac-w.js} +1 -1
  99. package/system/dist/{hub-mdns-ciao-BYe34S2Q.mjs → hub-mdns-ciao-B6K_dO2s.mjs} +2 -2
  100. package/system/dist/{hub-mdns-ciao-DJHjyjvT.js → hub-mdns-ciao-DcNPj7WJ.js} +2 -2
  101. package/system/dist/index.js +33 -19
  102. package/system/dist/index.mjs +33 -19
  103. package/system/dist/kernel/moleculer/child-cap-dispatch.d.ts +3 -6
  104. package/system/dist/kernel/moleculer/switch-toggle.d.ts +7 -2
  105. package/system/dist/{legacy-integration-rows-door-G6EceE_J.js → legacy-integration-rows-door-BsZyVNiR.js} +1 -1
  106. package/system/dist/{legacy-integration-rows-door-BEYgXSXr.mjs → legacy-integration-rows-door-DHOJeDPG.mjs} +1 -1
  107. package/system/dist/{rename-composition-block-D1mO51F9.js → rename-composition-block-BXMor7MR.js} +1 -1
  108. package/system/dist/{rename-composition-block-D6bq3Twf.mjs → rename-composition-block-DcVS1LuC.mjs} +1 -1
  109. package/system/dist/{restore-archive-FXsCWq_f.mjs → restore-archive-BG8VJ8Ar.mjs} +82 -82
  110. package/system/dist/{restore-archive-CJvMq13C.js → restore-archive-BURufVQd.js} +1 -1
  111. package/system/dist/{wal-maintenance-Ci9Dl-lB.mjs → wal-maintenance-B4wGD6QR.mjs} +0 -0
  112. package/system/dist/{wal-maintenance-COJ_JxrD.js → wal-maintenance-CeaJyKNT.js} +0 -0
  113. package/system/package.json +2 -5
  114. package/system/dist/builtins/camera-grid/grid-camera-declarations.d.ts +0 -59
  115. package/system/dist/builtins/camera-grid/grid-instances.d.ts +0 -40
  116. package/system/dist/builtins/camera-grid/grid-record-kinds.d.ts +0 -31
  117. package/system/dist/builtins/camera-grid/migrations/__fixtures__/seed.d.ts +0 -13
  118. package/system/dist/builtins/camera-grid/migrations/camera-grids-to-records.d.ts +0 -26
  119. package/system/dist/builtins/camera-grid/migrations/index.d.ts +0 -6
@@ -5726,13 +5726,14 @@ function recordsTransportOf(api) {
5726
5726
  //#region src/kernel/moleculer/switch-toggle.ts
5727
5727
  var REFUSAL_TEXT = {
5728
5728
  "no-slice": "switch has no state slice",
5729
- stale: "switch state is unknown"
5729
+ stale: "switch state is unknown",
5730
+ "not-settable": "switch only reports its state and cannot be set"
5730
5731
  };
5731
5732
  var SwitchToggleRefusedError = class extends Error {
5732
5733
  reason;
5733
5734
  deviceId;
5734
5735
  constructor(reason, deviceId) {
5735
- super(`device ${deviceId}: ${REFUSAL_TEXT[reason]}; refusing to guess on or off`);
5736
+ super(reason === "not-settable" ? `device ${deviceId}: ${REFUSAL_TEXT[reason]}` : `device ${deviceId}: ${REFUSAL_TEXT[reason]}; refusing to guess on or off`);
5736
5737
  this.name = "SwitchToggleRefusedError";
5737
5738
  this.reason = reason;
5738
5739
  this.deviceId = deviceId;
@@ -5768,8 +5769,29 @@ function refuse(read, deviceId, reason) {
5768
5769
  });
5769
5770
  throw new SwitchToggleRefusedError(reason, deviceId);
5770
5771
  }
5772
+ function isGetOptions(fn) {
5773
+ return typeof fn === "function";
5774
+ }
5775
+ /**
5776
+ * What the provider's own `getOptions` answered; `undefined` when it has none, or when the read
5777
+ * failed — logged, and the toggle then acts as a plain switch would (unknown is not "cannot").
5778
+ */
5779
+ async function optionsOf(provider, read, deviceId) {
5780
+ const getOptions = Reflect.get(provider, "getOptions");
5781
+ if (!isGetOptions(getOptions)) return void 0;
5782
+ try {
5783
+ return await getOptions.call(provider, { deviceId });
5784
+ } catch (err) {
5785
+ read.logger.warn("switch.toggle: getOptions failed; toggling as a plain on/off switch", {
5786
+ tags: { deviceId },
5787
+ meta: { error: err instanceof Error ? err.message : String(err) }
5788
+ });
5789
+ return;
5790
+ }
5791
+ }
5771
5792
  async function runToggle(provider, setState, read, input) {
5772
5793
  const deviceId = typeof input?.deviceId === "number" ? input.deviceId : read.deviceId;
5794
+ if ((0, _camstack_types_addon.switchRefusesSetState)(await optionsOf(provider, read, deviceId))) refuse(read, deviceId, "not-settable");
5773
5795
  const state = classifySwitchOn(deviceId === read.deviceId ? read.readSlice() : void 0);
5774
5796
  if (!state.known) refuse(read, deviceId, state.reason);
5775
5797
  await setState.call(provider, {
@@ -11727,12 +11749,6 @@ function isCapMethod(value) {
11727
11749
  return typeof value === "function";
11728
11750
  }
11729
11751
  /**
11730
- * Prefix the hub matches to turn a child-side "declared optional, not served"
11731
- * into a `NOT_IMPLEMENTED`. A prefix rather than an error subclass because the
11732
- * error crosses a UDS boundary as a plain message.
11733
- */
11734
- var CAP_METHOD_NOT_IMPLEMENTED = "CAP_METHOD_NOT_IMPLEMENTED";
11735
- /**
11736
11752
  * Extract a string `addonId` out of arbitrary method args — the fallback
11737
11753
  * provider-selection hint for calls that arrive WITHOUT the out-of-band
11738
11754
  * `CapCallMessage.addonId` (e.g. a sibling child's unowned collection call
@@ -11764,7 +11780,7 @@ function createChildCapDispatch(deps) {
11764
11780
  const fn = Reflect.get(provider, method);
11765
11781
  if (!isCapMethod(fn)) {
11766
11782
  if (deps.isCollectionListMethod(capName, method)) return [];
11767
- if (deps.isProviderOptionalMethod(capName, method)) throw new Error(`${CAP_METHOD_NOT_IMPLEMENTED}: '${capName}.${method}' is declared optional and this provider does not serve it`);
11783
+ if (deps.isProviderOptionalMethod(capName, method)) throw new Error(`${_camstack_types_addon.CAP_METHOD_NOT_IMPLEMENTED}: '${capName}.${method}' is declared optional and this provider does not serve it`);
11768
11784
  throw new Error(`child-cap-dispatch: method '${method}' not found on provider '${capName}'`);
11769
11785
  }
11770
11786
  const run = () => fn.call(provider, args);
@@ -1,5 +1,5 @@
1
1
  import { register } from "node:module";
2
- import { BOOT_RECOVERY_BACKOFF_MS, CALLER_STAMPED_CAPABILITIES, CAP_METHOD_TIMEOUTS_MS, COLLECTION_ARRAY_METHODS, COMPOSED_DEVICE_STABLE_ID_PREFIX, DATAPLANE_SECRET_HEADER, DEVICE_CHILDREN_BATCH_MAX, DeviceType, DisposerChain, ErrorI18nPayloadSchema, EventCategory, MIGRATION_API_VERSION, PEER_BYTES_CHUNK_BYTES, PEER_BYTES_MAX_OUTSTANDING, PEER_BYTES_STALL_MS, PEER_BYTES_TICKET_TTL_MS, ReadinessRegistry, ReadinessTimeoutError, addonSliceHandleApi, asJsonObject, asString, collectZodSecretPaths, commandOrigin, createDebugEmitter, createDeviceProxy, createEventBusSliceSource, createRecordsAccess, createSecretsAccess, describeCustomActions, deviceOpsCapability, emitReadiness, errMsg, expandCapMethods, findMigrationsBlocked, isCollectionArrayMethodName, isProviderOptionalMethodName, maskUrlCredentials, nodeIdOfScopedKey, normalizeAddonInitResult, readCommandOrigin, readErrorI18n, readNodePin, resolveDeviceSettings, resolveSecretViewsIn, scopeKey, scrubKnownSecrets, withCapInputDefaults } from "@camstack/types/addon";
2
+ import { BOOT_RECOVERY_BACKOFF_MS, CALLER_STAMPED_CAPABILITIES, CAP_METHOD_NOT_IMPLEMENTED, CAP_METHOD_TIMEOUTS_MS, COLLECTION_ARRAY_METHODS, COMPOSED_DEVICE_STABLE_ID_PREFIX, DATAPLANE_SECRET_HEADER, DEVICE_CHILDREN_BATCH_MAX, DeviceType, DisposerChain, ErrorI18nPayloadSchema, EventCategory, MIGRATION_API_VERSION, PEER_BYTES_CHUNK_BYTES, PEER_BYTES_MAX_OUTSTANDING, PEER_BYTES_STALL_MS, PEER_BYTES_TICKET_TTL_MS, ReadinessRegistry, ReadinessTimeoutError, addonSliceHandleApi, asJsonObject, asString, collectZodSecretPaths, commandOrigin, createDebugEmitter, createDeviceProxy, createEventBusSliceSource, createRecordsAccess, createSecretsAccess, describeCustomActions, deviceOpsCapability, emitReadiness, errMsg, expandCapMethods, findMigrationsBlocked, isCollectionArrayMethodName, isProviderOptionalMethodName, maskUrlCredentials, nodeIdOfScopedKey, normalizeAddonInitResult, readCommandOrigin, readErrorI18n, readNodePin, resolveDeviceSettings, resolveSecretViewsIn, scopeKey, scrubKnownSecrets, switchRefusesSetState, withCapInputDefaults } from "@camstack/types/addon";
3
3
  import * as fs$1 from "node:fs";
4
4
  import fs, { createReadStream, createWriteStream, existsSync, readFileSync, readdirSync } from "node:fs";
5
5
  import * as path from "node:path";
@@ -5671,13 +5671,14 @@ function recordsTransportOf(api) {
5671
5671
  //#region src/kernel/moleculer/switch-toggle.ts
5672
5672
  var REFUSAL_TEXT = {
5673
5673
  "no-slice": "switch has no state slice",
5674
- stale: "switch state is unknown"
5674
+ stale: "switch state is unknown",
5675
+ "not-settable": "switch only reports its state and cannot be set"
5675
5676
  };
5676
5677
  var SwitchToggleRefusedError = class extends Error {
5677
5678
  reason;
5678
5679
  deviceId;
5679
5680
  constructor(reason, deviceId) {
5680
- super(`device ${deviceId}: ${REFUSAL_TEXT[reason]}; refusing to guess on or off`);
5681
+ super(reason === "not-settable" ? `device ${deviceId}: ${REFUSAL_TEXT[reason]}` : `device ${deviceId}: ${REFUSAL_TEXT[reason]}; refusing to guess on or off`);
5681
5682
  this.name = "SwitchToggleRefusedError";
5682
5683
  this.reason = reason;
5683
5684
  this.deviceId = deviceId;
@@ -5713,8 +5714,29 @@ function refuse(read, deviceId, reason) {
5713
5714
  });
5714
5715
  throw new SwitchToggleRefusedError(reason, deviceId);
5715
5716
  }
5717
+ function isGetOptions(fn) {
5718
+ return typeof fn === "function";
5719
+ }
5720
+ /**
5721
+ * What the provider's own `getOptions` answered; `undefined` when it has none, or when the read
5722
+ * failed — logged, and the toggle then acts as a plain switch would (unknown is not "cannot").
5723
+ */
5724
+ async function optionsOf(provider, read, deviceId) {
5725
+ const getOptions = Reflect.get(provider, "getOptions");
5726
+ if (!isGetOptions(getOptions)) return void 0;
5727
+ try {
5728
+ return await getOptions.call(provider, { deviceId });
5729
+ } catch (err) {
5730
+ read.logger.warn("switch.toggle: getOptions failed; toggling as a plain on/off switch", {
5731
+ tags: { deviceId },
5732
+ meta: { error: err instanceof Error ? err.message : String(err) }
5733
+ });
5734
+ return;
5735
+ }
5736
+ }
5716
5737
  async function runToggle(provider, setState, read, input) {
5717
5738
  const deviceId = typeof input?.deviceId === "number" ? input.deviceId : read.deviceId;
5739
+ if (switchRefusesSetState(await optionsOf(provider, read, deviceId))) refuse(read, deviceId, "not-settable");
5718
5740
  const state = classifySwitchOn(deviceId === read.deviceId ? read.readSlice() : void 0);
5719
5741
  if (!state.known) refuse(read, deviceId, state.reason);
5720
5742
  await setState.call(provider, {
@@ -11672,12 +11694,6 @@ function isCapMethod(value) {
11672
11694
  return typeof value === "function";
11673
11695
  }
11674
11696
  /**
11675
- * Prefix the hub matches to turn a child-side "declared optional, not served"
11676
- * into a `NOT_IMPLEMENTED`. A prefix rather than an error subclass because the
11677
- * error crosses a UDS boundary as a plain message.
11678
- */
11679
- var CAP_METHOD_NOT_IMPLEMENTED = "CAP_METHOD_NOT_IMPLEMENTED";
11680
- /**
11681
11697
  * Extract a string `addonId` out of arbitrary method args — the fallback
11682
11698
  * provider-selection hint for calls that arrive WITHOUT the out-of-band
11683
11699
  * `CapCallMessage.addonId` (e.g. a sibling child's unowned collection call
@@ -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-BjhII4Uq.js");
6
+ const require_dist = require("../../dist-yx2KHo3b.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 { En as addonPagesCapability, Jl as EventCategory, Kl as errMsg, Ks as BaseAddon } from "../../dist-BKojK6Wf.mjs";
1
+ import { Mn as addonPagesCapability, fu as EventCategory, uc as BaseAddon, uu as errMsg } from "../../dist-DbAhCrHy.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-BjhII4Uq.js");
6
+ const require_dist = require("../../dist-yx2KHo3b.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 { Jl as EventCategory, Kl as errMsg, Ks as BaseAddon, On as addonWidgetsCapability } from "../../dist-BKojK6Wf.mjs";
1
+ import { Pn as addonWidgetsCapability, fu as EventCategory, uc as BaseAddon, uu as errMsg } from "../../dist-DbAhCrHy.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-BjhII4Uq.js");
6
+ const require_dist = require("../../dist-yx2KHo3b.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 { An as alertEpisodePayload, D as CORE_BLOCK_ADDON_PREFIX, Jc as defineRecordKinds, Jl as EventCategory, Kl as errMsg, Ks as BaseAddon, Uc as createEvent, bi as isAlertEpisodeOpen, jn as alertsCapability, kn as alertEpisodeId, p as AlertSchema, xi as isAlertEpisodeSeverity } from "../../dist-BKojK6Wf.mjs";
1
+ import { D as CORE_BLOCK_ADDON_PREFIX, Fn as alertEpisodeId, In as alertEpisodePayload, Ln as alertsCapability, Oi as isAlertEpisodeOpen, fl as defineRecordKinds, fu as EventCategory, ki as isAlertEpisodeSeverity, p as AlertSchema, sl as createEvent, uc as BaseAddon, uu as errMsg } from "../../dist-DbAhCrHy.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-BjhII4Uq.js");
6
+ const require_dist = require("../../dist-yx2KHo3b.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 { Jl as EventCategory, Kl as errMsg, Ks as BaseAddon, Ln as bareAddonId, Na as ptzAutotrackCapability, pt as FIRST_LEVEL_MACRO_CLASSES, sl as isEvent } from "../../dist-BKojK6Wf.mjs";
1
+ import { Ga as ptzAutotrackCapability, Tl as isEvent, Un as bareAddonId, fu as EventCategory, mt as FIRST_LEVEL_MACRO_CLASSES, uc as BaseAddon, uu as errMsg } from "../../dist-DbAhCrHy.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-BjhII4Uq.js");
6
+ const require_dist = require("../../dist-yx2KHo3b.js");
7
7
  const require_read_all_rows$1 = require("../../read-all-rows-CVoO1ONM.js");
8
- const require_restore_archive = require("../../restore-archive-CJvMq13C.js");
8
+ const require_restore_archive = require("../../restore-archive-BURufVQd.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 { Fl as toNodeId, In as backupCapability, Jl as EventCategory, Ks as BaseAddon, No as storageOccupancyCapability, Yi as mayWriteToLocation, yl as nodePin } from "../../dist-BKojK6Wf.mjs";
1
+ import { $l as toNodeId, Hn as backupCapability, Ll as nodePin, fu as EventCategory, oa as mayWriteToLocation, qo as storageOccupancyCapability, uc as BaseAddon } from "../../dist-DbAhCrHy.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-FXsCWq_f.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-BG8VJ8Ar.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-BjhII4Uq.js");
6
+ const require_dist = require("../../dist-yx2KHo3b.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 { Jc as defineRecordKinds, Ks as BaseAddon, k as CalendarPreferencesSchema, qn as calendarsCapability } from "../../dist-BKojK6Wf.mjs";
1
+ import { $n as calendarsCapability, fl as defineRecordKinds, k as CalendarPreferencesSchema, uc as BaseAddon } from "../../dist-DbAhCrHy.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
@@ -4,12 +4,19 @@
4
4
  *
5
5
  * ## What it is
6
6
  *
7
- * A grid is a DEVICE this addon declares, with one stream that is composed
8
- * rather than dialled. Everything downstream treats it as a camera: it records,
9
- * it appears in the timeline, it has a profile slot, it is bound like any other
10
- * — with ONE deliberate exception, object detection, which is switched off at
11
- * creation (see `silence-analysis.ts` for why, and for why it is never
12
- * re-asserted afterwards).
7
+ * A grid is a core block (planning#580) with a `grid` helper spec. The composer
8
+ * owns its camera row `composed-<blockId>` and its name; this engine builds a
9
+ * `GridCameraDevice` ON that row and serves every camera cap there as a
10
+ * cross-addon native (D663, resolved through the bindings, D13). Everything
11
+ * downstream treats it as a camera: it records, it appears in the timeline, it
12
+ * has a profile slot — with ONE deliberate exception, object detection, which
13
+ * is switched off the first time the engine hosts the device (see
14
+ * `silence-analysis.ts`, and the per-device flag below).
15
+ *
16
+ * The engine keeps no list of its own (D3): each pass reads the blocks
17
+ * (`coreBlocks.listCompositions`) and the composer's rows. `not-loaded` or a
18
+ * failed read changes nothing, and a hosted grid is withdrawn only after two
19
+ * consecutive trusted reads agree it is gone (D49).
13
20
  *
14
21
  * ## Hub-only, one process
15
22
  *
@@ -25,23 +32,20 @@
25
32
  */
26
33
  import type { AddonInitResult, DeviceProxy } from "@camstack/types";
27
34
  import { BaseAddon } from "@camstack/types";
28
- /** The grids are records (D1013); the addon keeps no settings of its own. */
35
+ /** The grids are core blocks (planning#580); the addon keeps no settings of its own. */
29
36
  type CameraGridAddonConfig = Record<string, never>;
30
37
  export declare class CameraGridAddon extends BaseAddon<CameraGridAddonConfig> {
31
38
  private relay;
32
39
  private reconcileTimer;
33
- /** Keyed by instance id — ONE composition per grid. */
40
+ /** Keyed by session key — ONE composition per (grid, profile). */
34
41
  private readonly sessions;
35
- private readonly deviceIdByInstanceId;
36
- private instances;
37
- /** The grids, as the last read of the records saw them. */
38
- private instanceRows;
39
- /**
40
- * False until the records are readable and the grids migration landed: a camera is never
41
- * withdrawn on a list that may be incomplete (D49).
42
- */
43
- private instancesTrusted;
44
- private migrationLanded;
42
+ /** The grids this engine hosts, by block id. */
43
+ private grids;
44
+ private readonly withdrawalGate;
45
+ /** One pass at a time: a save and the timer must not host the same block twice. */
46
+ private passChain;
47
+ /** True once a pass found no legacy `camera-grid` row left to remove. */
48
+ private legacySwept;
45
49
  /**
46
50
  * What each grid can honestly publish, per profile.
47
51
  *
@@ -52,7 +56,7 @@ export declare class CameraGridAddon extends BaseAddon<CameraGridAddonConfig> {
52
56
  * (D224), and 60 s is the window for a fact — "does 101 have a low assigned"
53
57
  * — that only changes when an operator changes it.
54
58
  */
55
- private readonly plansByInstanceId;
59
+ private readonly plansByBlockId;
56
60
  private activity;
57
61
  private snapshots;
58
62
  private frameSampler;
@@ -63,30 +67,42 @@ export declare class CameraGridAddon extends BaseAddon<CameraGridAddonConfig> {
63
67
  private readonly pinnedFfmpeg;
64
68
  /** A resolution in flight, so a reconcile pass never starts a second. */
65
69
  private ffmpegResolving;
66
- private integrationId;
67
70
  constructor();
68
71
  protected onInitialize(): Promise<AddonInitResult>;
69
72
  protected onShutdown(): Promise<void>;
70
- private instanceList;
71
- private instanceById;
73
+ private gridById;
74
+ private gridForDevice;
75
+ /** One pass at a time, in order: a save waits for a running pass and the reverse. */
76
+ private serialized;
77
+ private reconcile;
78
+ /** Read the grid blocks and host what they name. A read that cannot be trusted changes nothing (D49). */
79
+ private hostGridBlocks;
80
+ /** Build (or refresh) one grid. A failure is logged per device and leaves the previous state. */
81
+ private hostOne;
72
82
  /**
73
- * Hub only: declare the `camera-grid` kind, serve it through `integration-instances`, move the
74
- * old settings list into records (D987), then read the rows. A migration that did not land
75
- * leaves the declared cameras exactly as they are (`instancesTrusted` stays false).
83
+ * The grid's cells resolved to device ids. A source whose addon could not be
84
+ * read keeps the previous resolution; a source that has no row is left out
85
+ * and named.
76
86
  */
77
- private initInstanceRecords;
78
- /** Re-read every grid record. A failed read changes nothing (D49). */
79
- private refreshInstanceRows;
87
+ private layoutOf;
88
+ /** One indexed read per source addon (`listAll({ addonId })`), never the fleet. */
89
+ private readSources;
90
+ private unhost;
80
91
  /**
81
- * A grid is created with a name only; its layout is authored afterwards in the camera's own
82
- * device details (a generated form for the geometry would render "cell 1 source = 592" and be
83
- * unusable), so the form carries no field of its own.
92
+ * Analysis is silenced the FIRST time this engine hosts the device, and the
93
+ * fact is kept per device (`ctx.settings` device store, cleared with the
94
+ * device, D865). An operator who turns detection back on must win: it is
95
+ * never re-asserted.
84
96
  */
85
- private instanceForm;
86
- /** Runs after every create / edit / switch / delete of a grid record, on the hub. */
87
- private onInstanceChanged;
88
- private reconcile;
89
- private silenceAnalysis;
97
+ private silenceOnce;
98
+ /**
99
+ * The grid cameras declared before grids were blocks are not carried over
100
+ * (planning#580: the operator recreates them as blocks). Every row this addon
101
+ * still owns under its old integration is removed through the declared sweep
102
+ * (`removeDevice` → tombstone, D865). No integration means nothing was ever
103
+ * declared, and nothing is minted to find out.
104
+ */
105
+ private sweepLegacyCameras;
90
106
  /**
91
107
  * Listen to the SOURCES, so the grid can say the same things about itself.
92
108
  *
@@ -157,12 +173,10 @@ export declare class CameraGridAddon extends BaseAddon<CameraGridAddonConfig> {
157
173
  */
158
174
  private sourceNames;
159
175
  private makeSession;
160
- /** The session a dial is asking for, or `null` - which the relay answers 404 to. */
176
+ /** The session a dial is asking for, or `null` - which the relay answers 404 to. The relay's `instanceId` is the block id. */
161
177
  private sessionFor;
162
178
  /** This grid's sessions, in DESCENDING quality — the snapshot takes the first running one. */
163
179
  private sessionsForDevice;
164
- /** A grid that is gone stops immediately - it must not keep N sources dialled. */
165
- private retireWithdrawnSessions;
166
180
  /**
167
181
  * A geometry change is a NEW composition. The running child is composing the
168
182
  * old one, and ffmpeg has no way to be told otherwise, so it is stopped: the
@@ -186,9 +200,19 @@ export declare class CameraGridAddon extends BaseAddon<CameraGridAddonConfig> {
186
200
  * sweeping every stream it holds for the grid.
187
201
  */
188
202
  private descriptorsFor;
189
- private instanceIdForDevice;
190
- private instanceForDevice;
203
+ /**
204
+ * The grid's name is its DEVICE row's: the composer owns the row and keeps
205
+ * it in step with the block, and an operator rename lands there. Asked at
206
+ * the moment the editor reads, never kept here (D224).
207
+ */
191
208
  private gridViewFor;
209
+ /** The identity `(addonId, stableId)` of each source device, by one targeted read. */
210
+ private sourceRefs;
211
+ /**
212
+ * A layout save writes the BLOCK: its spec, sources by identity, with the
213
+ * block's `updatedAt` as the optimistic guard. The name is not the editor's
214
+ * to write (it is the block's, renamed through the block).
215
+ */
192
216
  private saveGridLayout;
193
217
  /**
194
218
  * Resolve the pinned build, single-flighted, and hand it to the frame sampler.
@@ -0,0 +1,51 @@
1
+ /**
2
+ * A grid is a core block (planning#580): its configuration is the block's
3
+ * `GridHelperSpec`, its camera is the composer's row `composed-<blockId>`, and
4
+ * this engine serves the camera caps on it. The spec names its sources by
5
+ * `(addonId, stableId)`; the compositor addresses them by device id, so a pass
6
+ * resolves one into the other here, and a layout save resolves back.
7
+ */
8
+ import { type Composition, type CompositionSourceRef, type GridHelperSpec, type GridLayoutCell, type GridProfile } from "@camstack/types";
9
+ export type NormalizedRect = {
10
+ readonly x: number;
11
+ readonly y: number;
12
+ readonly width: number;
13
+ readonly height: number;
14
+ };
15
+ /** One cell as the compositor reads it: a source DEVICE, the part taken, where it lands. */
16
+ export type GridCellConfig = {
17
+ readonly deviceId: number;
18
+ readonly source: NormalizedRect;
19
+ readonly cell: NormalizedRect;
20
+ };
21
+ /** What the compositor and the profile planner read of a grid. */
22
+ export interface GridComposition {
23
+ readonly fps: number;
24
+ readonly publishedProfiles: readonly GridProfile[];
25
+ readonly cells: readonly GridCellConfig[];
26
+ }
27
+ export declare function sourceRefKey(ref: CompositionSourceRef): string;
28
+ /** The cells whose source resolved, and the refs that did not. */
29
+ export interface ResolvedGridCells {
30
+ readonly cells: readonly GridCellConfig[];
31
+ readonly unresolved: readonly CompositionSourceRef[];
32
+ }
33
+ /**
34
+ * Resolve every cell's source to its device id. A source with no row is left
35
+ * out of the composition and NAMED: a deleted camera must not keep the grid
36
+ * from composing the cells that remain.
37
+ */
38
+ export declare function resolveGridCells(spec: GridHelperSpec, deviceIdOf: (ref: CompositionSourceRef) => number | null): ResolvedGridCells;
39
+ /** What a layout save writes: the patch, with each source device named by its identity. */
40
+ export interface GridSpecPatch {
41
+ readonly fps?: number | undefined;
42
+ readonly publishedProfiles?: readonly GridProfile[] | undefined;
43
+ readonly cells: readonly GridLayoutCell[];
44
+ }
45
+ /**
46
+ * The spec a layout save stores. A cell whose device has no identity is
47
+ * refused by id: a saved spec must never carry a numeric device id.
48
+ */
49
+ export declare function gridSpecFromPatch(current: GridHelperSpec, patch: GridSpecPatch, refOf: (deviceId: number) => CompositionSourceRef | null): GridHelperSpec;
50
+ /** The composition a grid spec compiles to — the shape a block of this kind stores. */
51
+ export declare function gridComposition(spec: GridHelperSpec): Composition;
@@ -28,7 +28,7 @@ import { BaseDevice, type CamStreamDescriptor, type DeviceContext, DeviceFeature
28
28
  import { z } from "zod";
29
29
  import type { GridSnapshotImage } from "./grid-snapshot.js";
30
30
  declare const gridCameraSchema: z.ZodObject<{
31
- instanceId: z.ZodString;
31
+ blockId: z.ZodString;
32
32
  }>;
33
33
  /**
34
34
  * What the device needs from the running addon. Installed as a module
@@ -41,9 +41,10 @@ export interface GridCameraRuntime {
41
41
  * when the addon cannot say. `null` is a REFUSAL to describe, never an empty
42
42
  * catalog with a shrug: see the note on the empty branch below.
43
43
  */
44
- descriptorsFor(instanceId: string): readonly CamStreamDescriptor[] | null;
44
+ descriptorsFor(blockId: string): readonly CamStreamDescriptor[] | null;
45
45
  /** The grid behind a device, or `null` — which means "answered: not a grid". */
46
- getLayout(deviceId: number): GridLayoutView | null;
46
+ getLayout(deviceId: number): Promise<GridLayoutView | null>;
47
+ isGrid(deviceId: number): boolean;
47
48
  saveLayout(patch: GridLayoutPatch): Promise<GridLayoutView>;
48
49
  /** A frame of the composition, or `null`. Never starts one. */
49
50
  getSnapshot(deviceId: number): Promise<GridSnapshotImage | null>;
@@ -28,7 +28,9 @@ import { type GridLayoutPatch, type GridLayoutView, type ICameraGridLayoutSettin
28
28
  /** What the provider needs from the running addon — nothing more. */
29
29
  export interface GridLayoutSource {
30
30
  /** The grid behind a device, or `null` — "answered: not a grid". */
31
- getLayout(deviceId: number): GridLayoutView | null;
31
+ getLayout(deviceId: number): Promise<GridLayoutView | null>;
32
+ /** Whether this engine hosts a grid on the device — answered from memory. */
33
+ isGrid(deviceId: number): boolean;
32
34
  saveLayout(patch: GridLayoutPatch): Promise<GridLayoutView>;
33
35
  }
34
36
  export declare function buildGridLayoutNativeProvider(source: GridLayoutSource): ICameraGridLayoutSettingsProvider;
@@ -1,5 +1,5 @@
1
1
  /**
2
- * A persisted grid row → the composition plan the stream session runs.
2
+ * A grid block's resolved layout → the composition plan the stream session runs.
3
3
  *
4
4
  * The one piece of real work here is the source→ordinal mapping. The operator
5
5
  * authors cells against CAMERAS; ffmpeg addresses them by INPUT ORDINAL, and a
@@ -9,7 +9,7 @@
9
9
  * no extra picture.
10
10
  */
11
11
  import type { FfmpegVideoEncoderId } from "@camstack/types";
12
- import type { GridInstance } from "./grid-instances.js";
12
+ import type { GridComposition } from "./grid-blocks.js";
13
13
  import type { GridStreamPlan } from "./grid-stream-session.js";
14
14
  export interface GridPlanEncodeContext {
15
15
  readonly encoder: FfmpegVideoEncoderId;
@@ -31,4 +31,4 @@ export interface GridPlanEncodeContext {
31
31
  };
32
32
  }
33
33
  /** `null` when the grid has nothing to compose — the normal freshly-created state. */
34
- export declare function gridPlanFor(instance: GridInstance, encode: GridPlanEncodeContext): GridStreamPlan | null;
34
+ export declare function gridPlanFor(instance: Pick<GridComposition, "cells" | "fps">, encode: GridPlanEncodeContext): GridStreamPlan | null;
@@ -11,16 +11,12 @@ export { CameraGridAddon } from "./addon.js";
11
11
  export { CameraGridAddon as default } from "./addon.js";
12
12
  export { buildGridFilterGraph } from "./grid-filter-graph.js";
13
13
  export type { GridCell, GridFilterGraph, GridLayout, NormalizedRect } from "./grid-filter-graph.js";
14
- export { buildGridCameraDeclarations, gridCameraReconciliationIndex, newGridCameraStableId } from "./grid-camera-declarations.js";
15
- export type { ExistingGridCameraRow, GridCameraConfig, GridCameraDeclaration } from "./grid-camera-declarations.js";
16
14
  export { GridCameraDevice, installGridCameraRuntime } from "./grid-camera-device.js";
17
15
  export type { GridCameraRuntime } from "./grid-camera-device.js";
18
- export { readGridInstances } from "./grid-instances.js";
19
- export type { GridCellConfig, GridInstance } from "./grid-instances.js";
16
+ export { gridComposition, gridSpecFromPatch, resolveGridCells, sourceRefKey } from "./grid-blocks.js";
17
+ export type { GridCellConfig, GridComposition, GridSpecPatch, ResolvedGridCells } from "./grid-blocks.js";
20
18
  export { gridPlanFor } from "./grid-plan.js";
21
19
  export type { GridPlanEncodeContext } from "./grid-plan.js";
22
- export { CAMERA_GRID_KIND_NAME, cameraGridKind, GridBodySchema, initialGridBody, rawGridOfRecord } from "./grid-record-kinds.js";
23
- export type { GridBody } from "./grid-record-kinds.js";
24
20
  export { gridStreamDescriptor } from "./grid-stream-descriptor.js";
25
21
  export { GRID_CAM_STREAM_ID, GRID_PROFILES, gridCamStreamId, gridProfilePlans } from "./grid-profiles.js";
26
22
  export type { GridProfilePlan, ServedProfile } from "./grid-profiles.js";