@camstack/server 1.2.768 → 1.2.770

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 (100) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/dist/api/core/cap-providers.js +4 -193
  3. package/dist/api/trpc/generated-cap-routers.js +40 -30
  4. package/dist/core/addon/integration-visibility.js +0 -5
  5. package/package.json +36 -12
  6. package/system/dist/addon-runner.js +7 -1
  7. package/system/dist/addon-runner.mjs +7 -1
  8. package/system/dist/{agent-https-D03iyjJk.mjs → agent-https-BGRPCKwT.mjs} +1 -1
  9. package/system/dist/{agent-https-D62iihRo.js → agent-https-mq6d71iq.js} +1 -1
  10. package/system/dist/builtins/addon-pages-aggregator/addon-pages-aggregator.addon.js +1 -1
  11. package/system/dist/builtins/addon-pages-aggregator/addon-pages-aggregator.addon.mjs +1 -1
  12. package/system/dist/builtins/addon-widgets-aggregator/addon-widgets-aggregator.addon.js +1 -1
  13. package/system/dist/builtins/addon-widgets-aggregator/addon-widgets-aggregator.addon.mjs +1 -1
  14. package/system/dist/builtins/alerts/alerts.addon.d.ts +15 -0
  15. package/system/dist/builtins/alerts/alerts.addon.js +104 -4
  16. package/system/dist/builtins/alerts/alerts.addon.mjs +104 -4
  17. package/system/dist/builtins/alerts/cluster-state-alerts.d.ts +32 -0
  18. package/system/dist/builtins/autotrack/index.js +1 -1
  19. package/system/dist/builtins/autotrack/index.mjs +1 -1
  20. package/system/dist/builtins/backup-orchestrator/backup-orchestrator.addon.js +2 -2
  21. package/system/dist/builtins/backup-orchestrator/backup-orchestrator.addon.mjs +2 -2
  22. package/system/dist/builtins/calendars/calendars.addon.js +1 -1
  23. package/system/dist/builtins/calendars/calendars.addon.mjs +1 -1
  24. package/system/dist/builtins/camera-grid/index.js +1 -1
  25. package/system/dist/builtins/camera-grid/index.mjs +1 -1
  26. package/system/dist/builtins/composer/composer.addon.js +5 -4
  27. package/system/dist/builtins/composer/composer.addon.mjs +5 -4
  28. package/system/dist/builtins/console-logging/index.js +1 -1
  29. package/system/dist/builtins/console-logging/index.mjs +1 -1
  30. package/system/dist/builtins/core-blocks/core-blocks.addon.js +3 -3
  31. package/system/dist/builtins/core-blocks/core-blocks.addon.mjs +3 -3
  32. package/system/dist/builtins/device-history/device-history.addon.js +2 -2
  33. package/system/dist/builtins/device-history/device-history.addon.mjs +2 -2
  34. package/system/dist/builtins/device-manager/device-manager.addon.js +1 -1
  35. package/system/dist/builtins/device-manager/device-manager.addon.mjs +1 -1
  36. package/system/dist/builtins/hub-forwarder/index.js +1 -1
  37. package/system/dist/builtins/hub-forwarder/index.mjs +1 -1
  38. package/system/dist/builtins/keychain/index.js +17 -10
  39. package/system/dist/builtins/keychain/index.mjs +17 -10
  40. package/system/dist/builtins/liveness-monitor/liveness-monitor.addon.js +1 -1
  41. package/system/dist/builtins/liveness-monitor/liveness-monitor.addon.mjs +1 -1
  42. package/system/dist/builtins/local-auth/local-auth.addon.js +2 -2
  43. package/system/dist/builtins/local-auth/local-auth.addon.mjs +2 -2
  44. package/system/dist/builtins/local-network/local-network.addon.js +2 -2
  45. package/system/dist/builtins/local-network/local-network.addon.mjs +2 -2
  46. package/system/dist/builtins/loki-logging/index.js +1 -1
  47. package/system/dist/builtins/loki-logging/index.mjs +1 -1
  48. package/system/dist/builtins/native-metrics/native-metrics.addon.js +1 -1
  49. package/system/dist/builtins/native-metrics/native-metrics.addon.mjs +1 -1
  50. package/system/dist/builtins/platform-probe/index.js +1 -1
  51. package/system/dist/builtins/platform-probe/index.mjs +1 -1
  52. package/system/dist/builtins/record-entries/index.js +1 -1
  53. package/system/dist/builtins/record-entries/index.mjs +1 -1
  54. package/system/dist/builtins/remote-access-orchestrator/remote-access-orchestrator.addon.js +1 -1
  55. package/system/dist/builtins/remote-access-orchestrator/remote-access-orchestrator.addon.mjs +1 -1
  56. package/system/dist/builtins/snapshot/index.js +1 -1
  57. package/system/dist/builtins/snapshot/index.mjs +1 -1
  58. package/system/dist/builtins/sqlite-storage/filesystem-storage.addon.js +1 -1
  59. package/system/dist/builtins/sqlite-storage/filesystem-storage.addon.mjs +1 -1
  60. package/system/dist/builtins/sqlite-storage/index.js +1 -1
  61. package/system/dist/builtins/sqlite-storage/index.mjs +1 -1
  62. package/system/dist/builtins/sqlite-storage/integration-record-kinds.d.ts +3 -10
  63. package/system/dist/builtins/sqlite-storage/integration-registry.d.ts +1 -11
  64. package/system/dist/builtins/sqlite-storage/integration-rows-ports.d.ts +13 -15
  65. package/system/dist/builtins/sqlite-storage/migrations/legacy-integration-rows-door.d.ts +31 -0
  66. package/system/dist/builtins/sqlite-storage/migrations/migrations-provider.d.ts +39 -1
  67. package/system/dist/builtins/sqlite-storage/sqlite-settings.addon.js +48 -5
  68. package/system/dist/builtins/sqlite-storage/sqlite-settings.addon.mjs +48 -5
  69. package/system/dist/builtins/storage-orchestrator/storage-orchestrator.addon.js +1 -1
  70. package/system/dist/builtins/storage-orchestrator/storage-orchestrator.addon.mjs +1 -1
  71. package/system/dist/builtins/system-config/system-config.addon.js +3 -3
  72. package/system/dist/builtins/system-config/system-config.addon.mjs +284 -284
  73. package/system/dist/builtins/winston-logging/index.js +1 -1
  74. package/system/dist/builtins/winston-logging/index.mjs +1 -1
  75. package/system/dist/{capture-engine-BpoL1zQ0.js → capture-engine--FQ8NUHh.js} +1 -1
  76. package/system/dist/{capture-engine-CYmRx0Ce.mjs → capture-engine-Cmx7DIzV.mjs} +1 -1
  77. package/system/dist/{composition-sources-CknQxftO.mjs → composition-sources-Bd09D5f4.mjs} +1 -1
  78. package/system/dist/{composition-sources-B7VyYbEU.js → composition-sources-cvZAN87H.js} +1 -1
  79. package/system/dist/{constants-C9Gxs1jW.mjs → constants-Dce28BAx.mjs} +1 -1
  80. package/system/dist/{constants-DJqUggkW.js → constants-gM9xHjyj.js} +1 -1
  81. package/system/dist/{device-ca-9BTS4o-T.js → device-ca-BmeH6Y9E.js} +1 -1
  82. package/system/dist/{device-ca-D76OqRnW.mjs → device-ca-DcMuT-Yp.mjs} +1 -1
  83. package/system/dist/{dist-BhR34kF8.mjs → dist-C3WXy3Ix.mjs} +185 -84
  84. package/system/dist/{dist-DLVfdGSW.js → dist-Dtw1sIeQ.js} +185 -84
  85. package/system/dist/file-host-worker.js +1 -1
  86. package/system/dist/file-host-worker.mjs +1 -1
  87. package/system/dist/{hub-mdns-ciao-DimaT9WQ.js → hub-mdns-ciao-C49eqyby.js} +2 -2
  88. package/system/dist/{hub-mdns-ciao-i31GIYWP.mjs → hub-mdns-ciao-Dfue_0kR.mjs} +2 -2
  89. package/system/dist/index.d.ts +1 -1
  90. package/system/dist/index.js +49 -231
  91. package/system/dist/index.mjs +58 -240
  92. package/system/dist/legacy-integration-rows-door-B8_XCqUX.js +290 -0
  93. package/system/dist/legacy-integration-rows-door-DK42Bh2Q.mjs +255 -0
  94. package/system/dist/migrations/hub/2026-11-05-drop-integration-settings.d.ts +16 -0
  95. package/system/dist/{restore-archive-nWi73iy0.mjs → restore-archive-C0YDO-qd.mjs} +82 -82
  96. package/system/dist/{restore-archive-BkiXu43U.js → restore-archive-DuktQtye.js} +1 -1
  97. package/system/dist/{wal-maintenance-UQEtPem2.js → wal-maintenance-BEo-y-cQ.js} +0 -0
  98. package/system/dist/{wal-maintenance-DG2bwMif.mjs → wal-maintenance-DhuvKiGK.mjs} +0 -0
  99. package/system/package.json +1 -1
  100. package/dist/api/core/integration-secrets.js +0 -96
@@ -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-DLVfdGSW.js");
6
+ const require_dist = require("../../dist-Dtw1sIeQ.js");
7
7
  const require_formatter = require("../../formatter-xbxeV4GD.js");
8
8
  const require_log_file_read_protocol = require("../../log-file-read-protocol-D0WcLbIV.js");
9
9
  let node_path = require("node:path");
@@ -1,4 +1,4 @@
1
- import { ri as logDestinationCapability, wo as BaseAddon } from "../../dist-BhR34kF8.mjs";
1
+ import { ri as logDestinationCapability, wo as BaseAddon } from "../../dist-C3WXy3Ix.mjs";
2
2
  import { t as formatLogLine } from "../../formatter-DkYZ4LXp.mjs";
3
3
  import { a as LogFileIndexStore, i as serveRead, n as isFromReader, t as CancelBook } from "../../log-file-read-protocol-B7M3X3bT.mjs";
4
4
  import { createRequire } from "node:module";
@@ -1,4 +1,4 @@
1
- const require_dist = require("./dist-DLVfdGSW.js");
1
+ const require_dist = require("./dist-Dtw1sIeQ.js");
2
2
  //#region src/builtins/device-history/store/series-registry.ts
3
3
  function subjectIdOf(subject) {
4
4
  return subject.kind === "device" ? `d:${subject.deviceId}` : `n:${subject.nodeId}`;
@@ -1,4 +1,4 @@
1
- import { No as HISTORY_DEFAULT_MIN_INTERVAL_MS, Ts as historyItemFieldPath, lc as DeviceType } from "./dist-BhR34kF8.mjs";
1
+ import { No as HISTORY_DEFAULT_MIN_INTERVAL_MS, Ts as historyItemFieldPath, lc as DeviceType } from "./dist-C3WXy3Ix.mjs";
2
2
  //#region src/builtins/device-history/store/series-registry.ts
3
3
  function subjectIdOf(subject) {
4
4
  return subject.kind === "device" ? `d:${subject.deviceId}` : `n:${subject.nodeId}`;
@@ -1,4 +1,4 @@
1
- import { oo as compositionSourceKey, uc as errMsg } from "./dist-BhR34kF8.mjs";
1
+ import { oo as compositionSourceKey, uc as errMsg } from "./dist-C3WXy3Ix.mjs";
2
2
  //#region src/builtins/shared/device-state-changed.ts
3
3
  /** Structural narrowing helper for untrusted bus payloads. */
4
4
  function isRecord(value) {
@@ -1,4 +1,4 @@
1
- const require_dist = require("./dist-DLVfdGSW.js");
1
+ const require_dist = require("./dist-Dtw1sIeQ.js");
2
2
  //#region src/builtins/shared/device-state-changed.ts
3
3
  /** Structural narrowing helper for untrusted bus payloads. */
4
4
  function isRecord(value) {
@@ -1,4 +1,4 @@
1
- import { ls as buildSecretRef } from "./dist-BhR34kF8.mjs";
1
+ import { ls as buildSecretRef } from "./dist-C3WXy3Ix.mjs";
2
2
  /** `secret://system/global/meshCaKey` — EC P-256 PKCS#8 PEM of the hub mesh CA. */
3
3
  var MESH_CA_KEY_REF = buildSecretRef({
4
4
  owner: "system",
@@ -1,5 +1,5 @@
1
1
  /** `secret://system/global/meshCaKey` — EC P-256 PKCS#8 PEM of the hub mesh CA. */
2
- var MESH_CA_KEY_REF = require("./dist-DLVfdGSW.js").buildSecretRef({
2
+ var MESH_CA_KEY_REF = require("./dist-Dtw1sIeQ.js").buildSecretRef({
3
3
  owner: "system",
4
4
  scope: { kind: "global" },
5
5
  fieldPath: "meshCaKey"
@@ -1,4 +1,4 @@
1
- const require_dist = require("./dist-DLVfdGSW.js");
1
+ const require_dist = require("./dist-Dtw1sIeQ.js");
2
2
  const require_x509_es = require("./x509.es-WtnRNyYS.js");
3
3
  let node_crypto = require("node:crypto");
4
4
  //#region src/auth/jwt-signing-key.ts
@@ -1,4 +1,4 @@
1
- import { H as DEVICE_SAN_CREDENTIAL_PREFIX, U as DEVICE_SAN_USER_PREFIX, ls as buildSecretRef } from "./dist-BhR34kF8.mjs";
1
+ import { H as DEVICE_SAN_CREDENTIAL_PREFIX, U as DEVICE_SAN_USER_PREFIX, ls as buildSecretRef } from "./dist-C3WXy3Ix.mjs";
2
2
  import { C as backdatedNotBefore, S as withUtcTimeEncoding, a as KeyUsageFlags, d as SubjectKeyIdentifierExtension, f as X509Certificate$1, m as cryptoProvider, n as BasicConstraintsExtension, o as KeyUsagesExtension, p as X509CertificateGenerator, r as ExtendedKeyUsageExtension, s as PemConverter, t as AuthorityKeyIdentifierExtension, u as SubjectAlternativeNameExtension } from "./x509.es-BRiJgOvu.mjs";
3
3
  import { X509Certificate, createPublicKey, randomBytes, verify, webcrypto } from "node:crypto";
4
4
  //#region src/auth/jwt-signing-key.ts
@@ -1171,7 +1171,7 @@ var DeviceRole = /* @__PURE__ */ function(DeviceRole) {
1171
1171
  return DeviceRole;
1172
1172
  }({});
1173
1173
  //#endregion
1174
- //#region ../types/dist/sleep-D1jjWAr8.mjs
1174
+ //#region ../types/dist/sleep-9TIHFj1w.mjs
1175
1175
  /**
1176
1176
  * The audio chunk plane's byte format, and the ONE expansion from a coded
1177
1177
  * window to float samples (D455).
@@ -3192,10 +3192,9 @@ var BaseAddon = class {
3192
3192
  *
3193
3193
  * Override it only when an `instanceMode: multiple` addon's instances differ: an NVR integration
3194
3194
  * needs its connection fields, the default integration the addon's own sections. It is the
3195
- * SHAPE of the form only — the values live in `integrations.getSettings`, and the write path is
3196
- * unchanged (`integrations.setSettings` for an account integration).
3195
+ * SHAPE of the form only — the values live on the instance record.
3197
3196
  */
3198
- async integrationSettingsSchema(_instance) {
3197
+ async integrationFormSchema(_instance) {
3199
3198
  return null;
3200
3199
  }
3201
3200
  /**
@@ -3241,7 +3240,7 @@ var BaseAddon = class {
3241
3240
  * per-instance schema when it declares one, else its global schema (what they always showed).
3242
3241
  */
3243
3242
  async getIntegrationFormSchema(instance, nodeId) {
3244
- const scoped = await this.integrationSettingsSchema(instance);
3243
+ const scoped = await this.integrationFormSchema(instance);
3245
3244
  if (scoped === null) return this.getGlobalSettings(void 0, void 0, nodeId);
3246
3245
  return hydrateSchema(scoped, {}, { inlineSecretsAsViews: true });
3247
3246
  }
@@ -8237,7 +8236,7 @@ function sleep(ms) {
8237
8236
  return new Promise((resolve) => setTimeout(resolve, Math.max(0, ms)));
8238
8237
  }
8239
8238
  //#endregion
8240
- //#region ../types/dist/composition-CRNwcFYY.mjs
8239
+ //#region ../types/dist/composition-pOHbTzRB.mjs
8241
8240
  var AUDIO_ENCODER_BY_CODEC = {
8242
8241
  opus: "libopus",
8243
8242
  aac: "aac",
@@ -8875,6 +8874,7 @@ function evaluateDwell(activeRaw, onForMsRaw, offForMsRaw, call, nowMs, hooks) {
8875
8874
  const active = asBoolean(activeRaw, "dwell", 0);
8876
8875
  const onForMs = asNonNegativeMs(onForMsRaw, "dwell", 1);
8877
8876
  const offForMs = asNonNegativeMs(offForMsRaw, "dwell", 2);
8877
+ call.transition = null;
8878
8878
  if (call.latched === null) {
8879
8879
  if (call.seenSince === null) call.seenSince = nowMs;
8880
8880
  const delay = active ? onForMs : offForMs;
@@ -8885,20 +8885,52 @@ function evaluateDwell(activeRaw, onForMsRaw, offForMsRaw, call, nowMs, hooks) {
8885
8885
  hooks?.noteDeadline?.(call.seenSince + delay);
8886
8886
  return null;
8887
8887
  }
8888
- if (active === call.latched) {
8889
- call.pendingSince = null;
8890
- return call.latched;
8891
- }
8888
+ if (active === call.latched) return holdAgainstReturn(call, active, onForMs, nowMs, hooks);
8889
+ call.returnSince = null;
8892
8890
  if (call.pendingSince === null) call.pendingSince = nowMs;
8893
8891
  const delay = active ? onForMs : offForMs;
8894
- if (nowMs - call.pendingSince >= delay) {
8895
- call.latched = active;
8896
- call.pendingSince = null;
8897
- return call.latched;
8898
- }
8892
+ if (nowMs - call.pendingSince >= delay) return flip(call, active, call.pendingSince);
8899
8893
  hooks?.noteDeadline?.(call.pendingSince + delay);
8900
8894
  return call.latched;
8901
8895
  }
8896
+ function flip(call, to, startedAt) {
8897
+ const transition = {
8898
+ value: to,
8899
+ startedAt
8900
+ };
8901
+ call.latched = to;
8902
+ call.pendingSince = null;
8903
+ call.returnSince = null;
8904
+ call.transition = transition;
8905
+ return to;
8906
+ }
8907
+ /**
8908
+ * The input is on the latched side. Without a pending transition that is the
8909
+ * steady state. A pending ON is dropped at once (a start needs `onForMs` of
8910
+ * unbroken activity). A pending OFF survives a return until the return has held
8911
+ * `onForMs`: a shorter one (an anti-crease pulse) must not re-arm a finished
8912
+ * run, and the original deadline still fires once the input is off again.
8913
+ */
8914
+ function holdAgainstReturn(call, latched, onForMs, nowMs, hooks) {
8915
+ if (call.pendingSince === null) {
8916
+ call.returnSince = null;
8917
+ return latched;
8918
+ }
8919
+ if (!latched) {
8920
+ call.pendingSince = null;
8921
+ call.returnSince = null;
8922
+ return latched;
8923
+ }
8924
+ if (call.returnSince === null) call.returnSince = nowMs;
8925
+ const returnDeadline = call.returnSince + onForMs;
8926
+ if (nowMs >= returnDeadline) {
8927
+ call.pendingSince = null;
8928
+ call.returnSince = null;
8929
+ return latched;
8930
+ }
8931
+ hooks?.noteDeadline?.(returnDeadline);
8932
+ return latched;
8933
+ }
8902
8934
  /**
8903
8935
  * `schmitt(x, high, low[, onForMs, offForMs])`: true once `x >= high`, false
8904
8936
  * once `x <= low`, and the last answer in between. A transition waits its delay
@@ -8935,7 +8967,7 @@ function evaluateSchmitt(args, call, nowMs, seed, hooks) {
8935
8967
  return call.latched;
8936
8968
  }
8937
8969
  /** `latchedAt(value)`: epoch ms when `value` last changed; null clears the stamp. */
8938
- function evaluateLatchedAt(value, call, nowMs) {
8970
+ function evaluateLatchedAt(value, call, nowMs, dwellTransition = null) {
8939
8971
  if (value === null) {
8940
8972
  call.last = null;
8941
8973
  call.at = null;
@@ -8944,7 +8976,7 @@ function evaluateLatchedAt(value, call, nowMs) {
8944
8976
  if (typeof value !== "boolean" && typeof value !== "number" && typeof value !== "string") return call.at;
8945
8977
  if (call.last !== value) {
8946
8978
  call.last = value;
8947
- call.at = nowMs;
8979
+ call.at = dwellTransition?.value === false && value === false ? dwellTransition.startedAt : nowMs;
8948
8980
  }
8949
8981
  return call.at;
8950
8982
  }
@@ -9673,6 +9705,7 @@ function createStatefulExpressionMemory() {
9673
9705
  return {
9674
9706
  calls: /* @__PURE__ */ new Map(),
9675
9707
  acceptedEdgeAt: null,
9708
+ dwellTransition: null,
9676
9709
  disarmRoseNext: false
9677
9710
  };
9678
9711
  }
@@ -9680,6 +9713,7 @@ function cloneStatefulExpressionMemory(memory) {
9680
9713
  return {
9681
9714
  calls: new Map([...memory.calls].map(([path, call]) => [path, { ...call }])),
9682
9715
  acceptedEdgeAt: memory.acceptedEdgeAt,
9716
+ dwellTransition: memory.dwellTransition,
9683
9717
  disarmRoseNext: memory.disarmRoseNext
9684
9718
  };
9685
9719
  }
@@ -9709,11 +9743,15 @@ function evaluateStatefulExpressionCall(invocation, memory, env, hooks) {
9709
9743
  const call = existing?.kind === "dwell" ? existing : {
9710
9744
  kind: "dwell",
9711
9745
  pendingSince: null,
9746
+ returnSince: null,
9747
+ transition: null,
9712
9748
  latched: typeof env.currentOutput === "boolean" ? env.currentOutput : null,
9713
9749
  seenSince: null
9714
9750
  };
9715
9751
  memory.calls.set(invocation.path, call);
9716
- return evaluateDwell(invocation.args[0], invocation.args[1], invocation.args[2], call, env.nowMs, hooks);
9752
+ const dwelled = evaluateDwell(invocation.args[0], invocation.args[1], invocation.args[2], call, env.nowMs, hooks);
9753
+ memory.dwellTransition = call.transition;
9754
+ return dwelled;
9717
9755
  }
9718
9756
  case "schmitt": {
9719
9757
  const call = existing?.kind === "schmitt" ? existing : {
@@ -9732,7 +9770,9 @@ function evaluateStatefulExpressionCall(invocation, memory, env, hooks) {
9732
9770
  at: null
9733
9771
  };
9734
9772
  memory.calls.set(invocation.path, call);
9735
- return evaluateLatchedAt(invocation.args[0], call, env.nowMs);
9773
+ const stamped = evaluateLatchedAt(invocation.args[0], call, env.nowMs, memory.dwellTransition);
9774
+ memory.dwellTransition = null;
9775
+ return stamped;
9736
9776
  }
9737
9777
  }
9738
9778
  }
@@ -54645,6 +54685,9 @@ var RunningProposalEvidenceSchema = z.object({
54645
54685
  runsFound: z.number().int().nonnegative(),
54646
54686
  pausesFound: z.number().int().nonnegative(),
54647
54687
  longestPauseMs: z.number().nonnegative(),
54688
+ /** Episodes shorter than ~90 s (an anti-crease pulse, a display waking): never a run, never a pause. */
54689
+ pulsesFound: z.number().int().nonnegative(),
54690
+ longestPulseMs: z.number().nonnegative(),
54648
54691
  idleFloorW: z.number(),
54649
54692
  noiseCeilingW: z.number(),
54650
54693
  plateauW: z.number(),
@@ -62115,11 +62158,7 @@ var CreateIntegrationInputSchema = z.object({
62115
62158
  info: z.record(z.string(), z.unknown()).optional(),
62116
62159
  /** `stableId` of the discovery candidate the form was seeded from (D984). */
62117
62160
  originStableId: z.string().optional(),
62118
- settings: z.record(z.string(), z.unknown()).optional(),
62119
- /** Keys of `settings` the form's schema declares secret (by type) — kept in
62120
- * the keychain, not the table (D787). */
62121
- secretKeys: z.array(z.string()).optional(),
62122
- skipRestart: z.boolean().optional()
62161
+ settings: z.record(z.string(), z.unknown()).optional()
62123
62162
  });
62124
62163
  var UpdateIntegrationInputSchema = z.object({
62125
62164
  id: z.string(),
@@ -62151,30 +62190,6 @@ var integrationsCapability = {
62151
62190
  kind: "mutation",
62152
62191
  auth: "admin"
62153
62192
  }),
62154
- getSettings: method(z.object({ id: z.string() }), z.record(z.string(), z.unknown()), { auth: "admin" }),
62155
- setSettings: method(z.object({
62156
- id: z.string(),
62157
- settings: z.record(z.string(), z.unknown()),
62158
- /** Keys the form's schema declares secret (by type) — keychain-stored (D787). */
62159
- secretKeys: z.array(z.string()).optional(),
62160
- /** The integration's own addon applies the change in-process and asks the hub not to respawn it. */
62161
- skipRestart: z.boolean().optional()
62162
- }), z.object({ success: z.boolean() }), {
62163
- kind: "mutation",
62164
- auth: "admin"
62165
- }),
62166
- /**
62167
- * Delete the integration's LEGACY setting rows and their keychain values, once the owning addon
62168
- * moved them into its own record and read the record back (D1007). Only the integration's own
62169
- * addon may call it; the integration itself stays. Answers counts, never a value.
62170
- */
62171
- clearSettings: method(z.object({ id: z.string() }), z.object({
62172
- rows: z.number().int().nonnegative(),
62173
- secrets: z.number().int().nonnegative()
62174
- }), {
62175
- kind: "mutation",
62176
- auth: "admin"
62177
- }),
62178
62193
  getAvailableTypes: method(z.void(), z.array(AvailableIntegrationTypeSchema), { auth: "admin" }),
62179
62194
  testConnection: method(z.object({
62180
62195
  addonId: z.string(),
@@ -66212,6 +66227,51 @@ var migrationsCapability = {
66212
66227
  }), {
66213
66228
  kind: "mutation",
66214
66229
  auth: "admin"
66230
+ }),
66231
+ /**
66232
+ * Migration-only. The stored rows of one integration, markers included, on
66233
+ * the settings connection. Empty when the store is gone — a copy migration
66234
+ * on a node that already dropped it is a no-op. Deleted with the last copy
66235
+ * migration. Not a settings API.
66236
+ */
66237
+ readLegacyIntegrationRows: method(z.object({ integrationId: z.string().min(1) }), z.record(z.string(), z.unknown()), { auth: "admin" }),
66238
+ /**
66239
+ * Migration-only. Delete that integration's rows. The caller releases the
66240
+ * keychain values first. `secrets` is how many marker refs the rows held.
66241
+ * A missing store deletes nothing. Deleted with the last copy migration.
66242
+ */
66243
+ clearLegacyIntegrationRows: method(z.object({ integrationId: z.string().min(1) }), z.object({
66244
+ rows: z.number().int().nonnegative(),
66245
+ secrets: z.number().int().nonnegative()
66246
+ }), {
66247
+ kind: "mutation",
66248
+ auth: "admin"
66249
+ }),
66250
+ /**
66251
+ * Migration-only. Upsert the given keys and leave every other key as stored.
66252
+ * `written` is false when the store is gone. Deleted with the last copy migration.
66253
+ */
66254
+ patchLegacyIntegrationRows: method(z.object({
66255
+ integrationId: z.string().min(1),
66256
+ patch: z.record(z.string(), z.unknown())
66257
+ }), z.object({ written: z.boolean() }), {
66258
+ kind: "mutation",
66259
+ auth: "admin"
66260
+ }),
66261
+ /**
66262
+ * Migration-only. Remove the named keys. `present` is false when the store
66263
+ * is gone; `removed` is what those keys held (markers included). Deleted
66264
+ * with the last copy migration.
66265
+ */
66266
+ deleteLegacyIntegrationRowKeys: method(z.object({
66267
+ integrationId: z.string().min(1),
66268
+ keys: z.array(z.string().min(1))
66269
+ }), z.object({
66270
+ present: z.boolean(),
66271
+ removed: z.record(z.string(), z.unknown())
66272
+ }), {
66273
+ kind: "mutation",
66274
+ auth: "admin"
66215
66275
  })
66216
66276
  }
66217
66277
  };
@@ -92725,11 +92785,15 @@ z.discriminatedUnion("kind", [z.object({
92725
92785
  * 1. idle floor F = time-weighted median; noise ceiling N = highest value seen
92726
92786
  * near F. A device that is not near one level most of the time has no floor.
92727
92787
  * 2. coarse activity = above max(2N, N + 5 W); consecutive stretches are episodes.
92728
- * 3. gaps between episodes split in two by the largest log-scale jump (>= 3x):
92729
- * the short ones are pauses INSIDE a run (a soak), the long ones separate runs.
92788
+ * 3. an episode shorter than `PULSE_MAX_MS` is a PULSE (an anti-crease tumble, a
92789
+ * display waking): it is neither a run nor a pause. Among the remaining
92790
+ * episodes, gaps over `PAUSE_MAX_MS` always separate runs; the rest split in
92791
+ * two by the largest log-scale jump (>= 3x): the short ones are pauses INSIDE
92792
+ * a run (a soak), the long ones separate runs. A stretch under `MIN_RUN_MS`
92793
+ * is no run.
92730
92794
  * 4. T = geometric mean of N and the plateau's 10th percentile, snapped to a
92731
- * grid a person would type; stop dwell covers the longest pause; start dwell
92732
- * covers the longest standby blip above T.
92795
+ * grid a person would type; stop dwell covers the longest pause and the
92796
+ * kind's floor; start dwell covers the longest pulse and standby blip above T.
92733
92797
  * 5. the numbers are proved by REPLAY through the real `dwell` evaluation: each
92734
92798
  * run must hold exactly one true interval and nothing may flap outside.
92735
92799
  */
@@ -92748,6 +92812,17 @@ var STOP_FACTOR = 1.5;
92748
92812
  var STOP_STEP_MS = 30 * SECOND_MS;
92749
92813
  var STOP_MIN_MS = 60 * SECOND_MS;
92750
92814
  var STOP_MAX_MS = 20 * MINUTE_MS$1;
92815
+ /** An episode shorter than this is a pulse: the start dwell is held above it. */
92816
+ var PULSE_MAX_MS = 90 * SECOND_MS;
92817
+ 30 * MINUTE_MS$1;
92818
+ /** A stretch above the threshold shorter than this is a pulse, not a run. */
92819
+ var MIN_RUN_MS = 10 * MINUTE_MS$1;
92820
+ /** What a kind needs at least before it is called stopped: a soak pause is longer for a washer. */
92821
+ var STOP_FLOOR_BY_KIND = {
92822
+ [DeviceType.Dryer]: 3 * MINUTE_MS$1,
92823
+ [DeviceType.Dishwasher]: 3 * MINUTE_MS$1,
92824
+ [DeviceType.Washer]: 10 * MINUTE_MS$1
92825
+ };
92751
92826
  var START_STEP_MS = 10 * SECOND_MS;
92752
92827
  var START_MIN_MS = 10 * SECOND_MS;
92753
92828
  var STOP_WALK_STEPS = 6;
@@ -92804,17 +92879,25 @@ function proposeRunningThreshold(series) {
92804
92879
  const active = segments.filter((s) => s.value > coarse);
92805
92880
  const episodes = mergeContiguous(active);
92806
92881
  if (durationOf(active) < MIN_ACTIVE_MS || episodes.length === 0) return insufficient("no-runs", 0);
92807
- const { runs, pauses, betweenGaps } = splitRuns(episodes);
92882
+ const pulseEpisodes = episodes.filter((e) => e.end - e.start < PULSE_MAX_MS);
92883
+ const split = splitRuns(episodes.filter((e) => e.end - e.start >= PULSE_MAX_MS));
92884
+ const runs = split.runs.filter((r) => r.end - r.start >= MIN_RUN_MS);
92885
+ const { pauses, betweenGaps } = split;
92886
+ const pulsesFound = pulseEpisodes.length + (split.runs.length - runs.length);
92887
+ const longestPulse = maxOf(pulseEpisodes.map((e) => e.end - e.start));
92888
+ if (runs.length === 0) return insufficient("no-runs", 0);
92808
92889
  const plateau = weightedQuantile(weigh(active.filter((s) => runs.some((r) => s.start < r.end && s.end > r.start))), PLATEAU_QUANTILE);
92809
92890
  const threshold = pickThreshold(noise, plateau);
92810
92891
  if (threshold === null) return insufficient("no-separation", runs.length);
92811
92892
  const notes = [];
92812
92893
  const longestPause = pauses.length === 0 ? 0 : Math.max(...pauses);
92813
- let stop = clamp(roundUp(STOP_FACTOR * longestPause, STOP_STEP_MS), STOP_MIN_MS, STOP_MAX_MS);
92894
+ const stopFloor = series.deviceType === void 0 ? STOP_MIN_MS : STOP_FLOOR_BY_KIND[series.deviceType] ?? STOP_MIN_MS;
92895
+ let stop = clamp(Math.max(stopFloor, roundUp(STOP_FACTOR * longestPause, STOP_STEP_MS)), STOP_MIN_MS, STOP_MAX_MS);
92814
92896
  const shortestGap = betweenGaps.length === 0 ? null : Math.min(...betweenGaps);
92815
- if (shortestGap !== null && stop > shortestGap / 2) notes.push("stop-dwell-exceeds-half-of-shortest-gap");
92897
+ if (shortestGap !== null && stop >= shortestGap) notes.push("stop-dwell-exceeds-shortest-gap");
92816
92898
  const blips = excursionsOutside(segments, threshold, runs);
92817
92899
  let start = Math.max(START_MIN_MS, roundUp(STOP_FACTOR * maxOf(blips), START_STEP_MS));
92900
+ if (pulsesFound > 0) start = Math.max(start, PULSE_MAX_MS);
92818
92901
  const shortestRun = Math.min(...runs.map((r) => r.end - r.start));
92819
92902
  if (start > shortestRun / 2) {
92820
92903
  notes.push("start-dwell-exceeds-half-of-shortest-run");
@@ -92844,6 +92927,8 @@ function proposeRunningThreshold(series) {
92844
92927
  runsFound: runs.length,
92845
92928
  pausesFound: pauses.length,
92846
92929
  longestPauseMs: longestPause,
92930
+ pulsesFound,
92931
+ longestPulseMs: longestPulse,
92847
92932
  idleFloorW: idleFloor,
92848
92933
  noiseCeilingW: noise,
92849
92934
  plateauW: plateau,
@@ -92928,8 +93013,9 @@ function mergeContiguous(segments) {
92928
93013
  }
92929
93014
  /**
92930
93015
  * Gaps between episodes: the largest log-scale jump (>= 3x) in the sorted gaps
92931
- * separates pauses inside a run from the gaps between runs. No jump: every gap
92932
- * separates runs — a lone pause is indistinguishable from a short standby.
93016
+ * separates pauses inside a run from the gaps between runs, but a pause is never
93017
+ * longer than `PAUSE_MAX_MS`: a cut above it is not taken. No jump: every gap separates
93018
+ * runs - a lone pause is indistinguishable from a short standby.
92933
93019
  */
92934
93020
  function splitRuns(episodes) {
92935
93021
  const gaps = episodes.slice(1).map((e, i) => e.start - (episodes[i]?.end ?? e.start));
@@ -92940,7 +93026,7 @@ function splitRuns(episodes) {
92940
93026
  const lo = sorted[i] ?? 0;
92941
93027
  const hi = sorted[i + 1] ?? 0;
92942
93028
  const ratio = lo > 0 ? hi / lo : Number.POSITIVE_INFINITY;
92943
- if (ratio >= best) {
93029
+ if (ratio >= best && lo <= 18e5) {
92944
93030
  best = ratio;
92945
93031
  cut = lo;
92946
93032
  }
@@ -92984,17 +93070,21 @@ function pickThreshold(noise, plateau) {
92984
93070
  function excursionsOutside(segments, threshold, runs) {
92985
93071
  return mergeContiguous(segments.filter((s) => s.value >= threshold)).filter((h) => !runs.some((r) => h.start < r.end && h.end > r.start)).map((h) => h.end - h.start);
92986
93072
  }
92987
- /** Drive the real `dwell` evaluation over the series, deadlines included. */
92988
93073
  function replayDwell(segments, to, threshold, startMs, stopMs, runs) {
93074
+ return judge(runDwell(segments, to, threshold, startMs, stopMs), runs);
93075
+ }
93076
+ function runDwell(segments, to, threshold, startMs, stopMs) {
92989
93077
  const call = {
92990
93078
  kind: "dwell",
92991
93079
  pendingSince: null,
93080
+ returnSince: null,
92992
93081
  latched: null,
92993
- seenSince: null
93082
+ seenSince: null,
93083
+ transition: null
92994
93084
  };
92995
93085
  let deadline = null;
92996
93086
  const hooks = { noteDeadline: (at) => {
92997
- deadline = at;
93087
+ deadline = deadline === null ? at : Math.min(deadline, at);
92998
93088
  } };
92999
93089
  const intervals = [];
93000
93090
  let openAt = null;
@@ -93020,7 +93110,7 @@ function replayDwell(segments, to, threshold, startMs, stopMs, runs) {
93020
93110
  start: openAt,
93021
93111
  end: to
93022
93112
  });
93023
- return judge(intervals, runs);
93113
+ return intervals;
93024
93114
  }
93025
93115
  function judge(intervals, runs) {
93026
93116
  const hits = (i, r) => i.start < r.end && i.end > r.start;
@@ -93398,6 +93488,7 @@ function expressionOutcome(source, read, now, stateful) {
93398
93488
  continue;
93399
93489
  }
93400
93490
  values[name] = reading.value;
93491
+ if (reading.state === "fresh" && reading.transition !== void 0 && stateful !== void 0) stateful.expressionMemory.dwellTransition = reading.transition;
93401
93492
  if (reading.state === "stale") staleReasons.push(`\`${name}\`: ${reading.reason}`);
93402
93493
  }
93403
93494
  const unavailable = fatalUnavailable ?? nonFatalUnavailable;
@@ -93430,6 +93521,8 @@ function expressionOutcome(source, read, now, stateful) {
93430
93521
  nowMs: now
93431
93522
  }, hooks) }
93432
93523
  });
93524
+ const transition = stateful?.expressionMemory.dwellTransition ?? null;
93525
+ if (stateful !== void 0) stateful.expressionMemory.dwellTransition = null;
93433
93526
  if (!result.ok) return {
93434
93527
  state: "unavailable",
93435
93528
  value: null,
@@ -93442,7 +93535,8 @@ function expressionOutcome(source, read, now, stateful) {
93442
93535
  state: staleReasons.length > 0 ? "stale" : "fresh",
93443
93536
  value: result.value,
93444
93537
  reason: staleReasons.length > 0 ? staleReasons.join("; ") : null,
93445
- deadline: deadlines.length > 0 ? Math.min(...deadlines) : null
93538
+ deadline: deadlines.length > 0 ? Math.min(...deadlines) : null,
93539
+ ...transition === null ? {} : { transition }
93446
93540
  };
93447
93541
  }
93448
93542
  function aggregateRead(reading) {
@@ -98854,13 +98948,6 @@ var METHOD_ACCESS_MAP = Object.freeze({
98854
98948
  access: "create",
98855
98949
  role: "admin"
98856
98950
  },
98857
- "integrations.clearSettings": {
98858
- capName: "integrations",
98859
- capScope: "system",
98860
- addonId: null,
98861
- access: "delete",
98862
- role: "admin"
98863
- },
98864
98951
  "integrations.create": {
98865
98952
  capName: "integrations",
98866
98953
  capScope: "system",
@@ -98896,13 +98983,6 @@ var METHOD_ACCESS_MAP = Object.freeze({
98896
98983
  access: "view",
98897
98984
  role: "admin"
98898
98985
  },
98899
- "integrations.getSettings": {
98900
- capName: "integrations",
98901
- capScope: "system",
98902
- addonId: null,
98903
- access: "view",
98904
- role: "admin"
98905
- },
98906
98986
  "integrations.list": {
98907
98987
  capName: "integrations",
98908
98988
  capScope: "system",
@@ -98910,13 +98990,6 @@ var METHOD_ACCESS_MAP = Object.freeze({
98910
98990
  access: "view",
98911
98991
  role: "admin"
98912
98992
  },
98913
- "integrations.setSettings": {
98914
- capName: "integrations",
98915
- capScope: "system",
98916
- addonId: null,
98917
- access: "create",
98918
- role: "admin"
98919
- },
98920
98993
  "integrations.testConnection": {
98921
98994
  capName: "integrations",
98922
98995
  capScope: "system",
@@ -99911,6 +99984,13 @@ var METHOD_ACCESS_MAP = Object.freeze({
99911
99984
  access: "view",
99912
99985
  role: "admin"
99913
99986
  },
99987
+ "migrations.clearLegacyIntegrationRows": {
99988
+ capName: "migrations",
99989
+ capScope: "system",
99990
+ addonId: null,
99991
+ access: "delete",
99992
+ role: "admin"
99993
+ },
99914
99994
  "migrations.declareOwner": {
99915
99995
  capName: "migrations",
99916
99996
  capScope: "system",
@@ -99918,6 +99998,13 @@ var METHOD_ACCESS_MAP = Object.freeze({
99918
99998
  access: "create",
99919
99999
  role: "admin"
99920
100000
  },
100001
+ "migrations.deleteLegacyIntegrationRowKeys": {
100002
+ capName: "migrations",
100003
+ capScope: "system",
100004
+ addonId: null,
100005
+ access: "delete",
100006
+ role: "admin"
100007
+ },
99921
100008
  "migrations.dryRun": {
99922
100009
  capName: "migrations",
99923
100010
  capScope: "system",
@@ -99953,6 +100040,20 @@ var METHOD_ACCESS_MAP = Object.freeze({
99953
100040
  access: "create",
99954
100041
  role: "admin"
99955
100042
  },
100043
+ "migrations.patchLegacyIntegrationRows": {
100044
+ capName: "migrations",
100045
+ capScope: "system",
100046
+ addonId: null,
100047
+ access: "create",
100048
+ role: "admin"
100049
+ },
100050
+ "migrations.readLegacyIntegrationRows": {
100051
+ capName: "migrations",
100052
+ capScope: "system",
100053
+ addonId: null,
100054
+ access: "view",
100055
+ role: "admin"
100056
+ },
99956
100057
  "migrations.restorePreMigration": {
99957
100058
  capName: "migrations",
99958
100059
  capScope: "system",