@camstack/server 1.2.735 → 1.2.736

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 (93) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/dist/api/core/cap-providers.js +114 -8
  3. package/dist/api/trpc/generated-cap-mounts.js +17 -1
  4. package/dist/api/trpc/generated-cap-routers.js +1789 -1708
  5. package/dist/core/addon/addon-registry.service.js +2 -0
  6. package/dist/core/addon/addon-settings-provider.js +4 -0
  7. package/dist/core/addon/integration-instances-provider.js +21 -0
  8. package/package.json +4 -4
  9. package/system/dist/{agent-https-DrCbFr4p.js → agent-https-Bi3JY1e0.js} +1 -1
  10. package/system/dist/{agent-https-BVCIU0eH.mjs → agent-https-DiK6iQzW.mjs} +1 -1
  11. package/system/dist/builtins/addon-pages-aggregator/addon-pages-aggregator.addon.js +1 -1
  12. package/system/dist/builtins/addon-pages-aggregator/addon-pages-aggregator.addon.mjs +1 -1
  13. package/system/dist/builtins/addon-widgets-aggregator/addon-widgets-aggregator.addon.js +1 -1
  14. package/system/dist/builtins/addon-widgets-aggregator/addon-widgets-aggregator.addon.mjs +1 -1
  15. package/system/dist/builtins/alerts/alerts.addon.js +1 -1
  16. package/system/dist/builtins/alerts/alerts.addon.mjs +1 -1
  17. package/system/dist/builtins/autotrack/index.js +1 -1
  18. package/system/dist/builtins/autotrack/index.mjs +1 -1
  19. package/system/dist/builtins/backup-orchestrator/backup-orchestrator.addon.js +2 -2
  20. package/system/dist/builtins/backup-orchestrator/backup-orchestrator.addon.mjs +2 -2
  21. package/system/dist/builtins/calendars/calendars.addon.js +1 -1
  22. package/system/dist/builtins/calendars/calendars.addon.mjs +1 -1
  23. package/system/dist/builtins/camera-grid/index.js +1 -1
  24. package/system/dist/builtins/camera-grid/index.mjs +1 -1
  25. package/system/dist/builtins/composer/composer.addon.js +3 -3
  26. package/system/dist/builtins/composer/composer.addon.mjs +3 -3
  27. package/system/dist/builtins/console-logging/index.js +1 -1
  28. package/system/dist/builtins/console-logging/index.mjs +1 -1
  29. package/system/dist/builtins/core-blocks/core-blocks.addon.js +2 -2
  30. package/system/dist/builtins/core-blocks/core-blocks.addon.mjs +2 -2
  31. package/system/dist/builtins/device-history/device-history.addon.js +2 -2
  32. package/system/dist/builtins/device-history/device-history.addon.mjs +2 -2
  33. package/system/dist/builtins/device-manager/device-manager.addon.js +1 -1
  34. package/system/dist/builtins/device-manager/device-manager.addon.mjs +1 -1
  35. package/system/dist/builtins/hub-forwarder/index.js +1 -1
  36. package/system/dist/builtins/hub-forwarder/index.mjs +1 -1
  37. package/system/dist/builtins/keychain/index.js +3 -3
  38. package/system/dist/builtins/keychain/index.mjs +3 -3
  39. package/system/dist/builtins/liveness-monitor/liveness-monitor.addon.js +1 -1
  40. package/system/dist/builtins/liveness-monitor/liveness-monitor.addon.mjs +1 -1
  41. package/system/dist/builtins/local-auth/local-auth.addon.js +2 -2
  42. package/system/dist/builtins/local-auth/local-auth.addon.mjs +2 -2
  43. package/system/dist/builtins/local-network/local-network.addon.js +2 -2
  44. package/system/dist/builtins/local-network/local-network.addon.mjs +2 -2
  45. package/system/dist/builtins/loki-logging/index.js +440 -25
  46. package/system/dist/builtins/loki-logging/index.mjs +438 -25
  47. package/system/dist/builtins/loki-logging/loki-logging.addon.d.ts +23 -14
  48. package/system/dist/builtins/loki-logging/loki-record-kinds.d.ts +33 -0
  49. package/system/dist/builtins/loki-logging/migrations/connection-to-records.d.ts +47 -0
  50. package/system/dist/builtins/loki-logging/migrations/index.d.ts +8 -0
  51. package/system/dist/builtins/native-metrics/native-metrics.addon.js +1 -1
  52. package/system/dist/builtins/native-metrics/native-metrics.addon.mjs +1 -1
  53. package/system/dist/builtins/platform-probe/index.js +1 -1
  54. package/system/dist/builtins/platform-probe/index.mjs +1 -1
  55. package/system/dist/builtins/record-entries/index.js +2 -22
  56. package/system/dist/builtins/record-entries/index.mjs +2 -22
  57. package/system/dist/builtins/remote-access-orchestrator/remote-access-orchestrator.addon.js +1 -1
  58. package/system/dist/builtins/remote-access-orchestrator/remote-access-orchestrator.addon.mjs +1 -1
  59. package/system/dist/builtins/snapshot/index.js +1 -1
  60. package/system/dist/builtins/snapshot/index.mjs +1 -1
  61. package/system/dist/builtins/sqlite-storage/filesystem-storage.addon.js +1 -1
  62. package/system/dist/builtins/sqlite-storage/filesystem-storage.addon.mjs +1 -1
  63. package/system/dist/builtins/sqlite-storage/index.js +1 -1
  64. package/system/dist/builtins/sqlite-storage/index.mjs +1 -1
  65. package/system/dist/builtins/sqlite-storage/sqlite-settings.addon.js +2 -2
  66. package/system/dist/builtins/sqlite-storage/sqlite-settings.addon.mjs +2 -2
  67. package/system/dist/builtins/storage-orchestrator/storage-orchestrator.addon.js +1 -1
  68. package/system/dist/builtins/storage-orchestrator/storage-orchestrator.addon.mjs +1 -1
  69. package/system/dist/builtins/system-config/system-config.addon.js +3 -3
  70. package/system/dist/builtins/system-config/system-config.addon.mjs +7 -7
  71. package/system/dist/builtins/winston-logging/index.js +1 -1
  72. package/system/dist/builtins/winston-logging/index.mjs +1 -1
  73. package/system/dist/{composition-sources-BV9n2ivT.js → composition-sources-DQLGJMMh.js} +1 -1
  74. package/system/dist/{composition-sources-CI2tZzAo.mjs → composition-sources-lnsR-YuH.mjs} +1 -1
  75. package/system/dist/{constants-Bskr2h1W.mjs → constants-D7I0cM20.mjs} +1 -1
  76. package/system/dist/{constants-dYIQm8ab.js → constants-DA5jgmYT.js} +1 -1
  77. package/system/dist/{device-ca-04o7NByo.mjs → device-ca-Clr2bCe-.mjs} +1 -1
  78. package/system/dist/{device-ca-BF8N9fC6.js → device-ca-GPjZE-Mm.js} +1 -1
  79. package/system/dist/{dist-CnC8-kF6.mjs → dist-Cyj93AvD.mjs} +529 -152
  80. package/system/dist/{dist-B4r3_aYb.js → dist-Xi7ZQ7UI.js} +564 -151
  81. package/system/dist/file-host-worker.js +1 -1
  82. package/system/dist/file-host-worker.mjs +1 -1
  83. package/system/dist/{hub-mdns-ciao-MdXDARI0.js → hub-mdns-ciao-BMgUdxgG.js} +2 -2
  84. package/system/dist/{hub-mdns-ciao-BE1vqriF.mjs → hub-mdns-ciao-ouzCfqVS.mjs} +2 -2
  85. package/system/dist/index.js +7 -7
  86. package/system/dist/index.mjs +7 -7
  87. package/system/dist/{restore-archive-Dx9F-3zV.mjs → restore-archive-BG22FodH.mjs} +5 -5
  88. package/system/dist/{restore-archive-BEUIhG8U.js → restore-archive-CZozfCX-.js} +1 -1
  89. package/system/dist/{retention-fsBjIfxP.mjs → retention-BfC_C1vy.mjs} +1 -1
  90. package/system/dist/{retention-nNCAON-6.js → retention-DCrdPMot.js} +1 -1
  91. package/system/dist/{wal-maintenance-0XhlopB5.mjs → wal-maintenance-C2GNRuvy.mjs} +0 -0
  92. package/system/dist/{wal-maintenance-UKXXEEoS.js → wal-maintenance-PjOoh6-K.js} +0 -0
  93. package/system/package.json +4 -1
@@ -1162,7 +1162,7 @@ var DeviceRole = /* @__PURE__ */ function(DeviceRole) {
1162
1162
  return DeviceRole;
1163
1163
  }({});
1164
1164
  //#endregion
1165
- //#region ../types/dist/sleep-47MM9p3b.mjs
1165
+ //#region ../types/dist/sleep-CdJHPm-k.mjs
1166
1166
  /**
1167
1167
  * The audio chunk plane's byte format, and the ONE expansion from a coded
1168
1168
  * window to float samples (D455).
@@ -1274,21 +1274,21 @@ function collectSecretConfigKeys(schema) {
1274
1274
  for (const section of sectionsOf(schema)) for (const field of fieldsOf(section)) walkField(field, keys);
1275
1275
  return keys;
1276
1276
  }
1277
- function isRecord$7(value) {
1277
+ function isRecord$8(value) {
1278
1278
  return typeof value === "object" && value !== null && !Array.isArray(value);
1279
1279
  }
1280
1280
  function sectionsOf(schema) {
1281
- if (!isRecord$7(schema)) return [];
1281
+ if (!isRecord$8(schema)) return [];
1282
1282
  const sections = schema["sections"];
1283
1283
  return Array.isArray(sections) ? sections : [];
1284
1284
  }
1285
1285
  function fieldsOf(node) {
1286
- if (!isRecord$7(node)) return [];
1286
+ if (!isRecord$8(node)) return [];
1287
1287
  const fields = node["fields"];
1288
1288
  return Array.isArray(fields) ? fields : [];
1289
1289
  }
1290
1290
  function walkField(field, out) {
1291
- if (!isRecord$7(field)) return;
1291
+ if (!isRecord$8(field)) return;
1292
1292
  const type = field["type"];
1293
1293
  const key = field["key"];
1294
1294
  if ((type === "password" || field["secret"] === true) && typeof key === "string" && key.length > 0) out.add(key);
@@ -1326,7 +1326,7 @@ function walkField(field, out) {
1326
1326
  var SECRET_CLEAR = { $secretClear: true };
1327
1327
  /** The `'***'` token D634 redaction writes for non-admins. */
1328
1328
  var LEGACY_DEVICE_REDACTION = "***";
1329
- function isRecord$6(value) {
1329
+ function isRecord$7(value) {
1330
1330
  return typeof value === "object" && value !== null && !Array.isArray(value);
1331
1331
  }
1332
1332
  function makeSecretMarker(ref) {
@@ -1337,16 +1337,19 @@ function makeSecretMarker(ref) {
1337
1337
  }
1338
1338
  /** A stored marker: an object whose `$secret` is a non-empty string. */
1339
1339
  function isSecretMarker(value) {
1340
- if (!isRecord$6(value)) return false;
1340
+ if (!isRecord$7(value)) return false;
1341
1341
  const ref = value["$secret"];
1342
1342
  return typeof ref === "string" && ref.length > 0;
1343
1343
  }
1344
1344
  /** Anything carrying a `$secret` key — a stored marker or a UI view of one. */
1345
1345
  function isSecretMarkerLike(value) {
1346
- return isRecord$6(value) && Object.prototype.hasOwnProperty.call(value, "$secret");
1346
+ return isRecord$7(value) && Object.prototype.hasOwnProperty.call(value, "$secret");
1347
1347
  }
1348
1348
  function isSecretClear(value) {
1349
- return isRecord$6(value) && value["$secretClear"] === true;
1349
+ return isRecord$7(value) && value["$secretClear"] === true;
1350
+ }
1351
+ function isSecretFieldView(value) {
1352
+ return isRecord$7(value) && value["set"] === true && isSecretMarkerLike(value);
1350
1353
  }
1351
1354
  /**
1352
1355
  * The UI view of a stored secret field value: a marker becomes "set", inline
@@ -1746,6 +1749,53 @@ function emitReadiness(bus, params) {
1746
1749
  ts
1747
1750
  }));
1748
1751
  }
1752
+ /** Why a catalogue entry is not a runnable body of its declared kind. */
1753
+ var AddonMigrationDefinitionError = class extends Error {
1754
+ id;
1755
+ constructor(id, message) {
1756
+ super(`${id}: ${message}`);
1757
+ this.id = id;
1758
+ this.name = "AddonMigrationDefinitionError";
1759
+ }
1760
+ };
1761
+ /**
1762
+ * Bind a catalogue to the addon's ports. Throws {@link AddonMigrationDefinitionError} when
1763
+ * an entry's `bodyKind` does not match the body it carries, or is `sql` (a hub-only
1764
+ * body). A throwing body never escapes `execute`: it is reported as a failed result.
1765
+ */
1766
+ function defineAddonMigrations(catalogue, ports) {
1767
+ return catalogue.map((entry) => {
1768
+ const { meta } = entry;
1769
+ if ("plan" in entry) {
1770
+ if (meta.bodyKind !== "plan") throw new AddonMigrationDefinitionError(meta.id, `carries a plan body but declares "${meta.bodyKind}"`);
1771
+ return {
1772
+ meta,
1773
+ execute: () => guarded(async () => ({
1774
+ kind: "plan",
1775
+ plan: await entry.plan(ports)
1776
+ }))
1777
+ };
1778
+ }
1779
+ if (meta.bodyKind !== "procedure") throw new AddonMigrationDefinitionError(meta.id, `carries a procedure body but declares "${meta.bodyKind}"`);
1780
+ return {
1781
+ meta,
1782
+ execute: () => guarded(async () => ({
1783
+ kind: "procedure",
1784
+ result: await entry.procedure(ports)
1785
+ }))
1786
+ };
1787
+ });
1788
+ }
1789
+ async function guarded(work) {
1790
+ try {
1791
+ return await work();
1792
+ } catch (err) {
1793
+ return {
1794
+ kind: "failed",
1795
+ error: errMsg(err)
1796
+ };
1797
+ }
1798
+ }
1749
1799
  var NOT_RUN = {
1750
1800
  declared: false,
1751
1801
  snapshot: null,
@@ -2111,7 +2161,7 @@ var KeychainWriteRefusedError = class extends Error {
2111
2161
  }
2112
2162
  };
2113
2163
  var KEEP = { kind: "keep" };
2114
- function isRecord$5(value) {
2164
+ function isRecord$6(value) {
2115
2165
  return typeof value === "object" && value !== null && !Array.isArray(value);
2116
2166
  }
2117
2167
  function defaultMintId() {
@@ -2124,7 +2174,7 @@ function collectSecretMarkerRefs(value, out = []) {
2124
2174
  return out;
2125
2175
  }
2126
2176
  if (Array.isArray(value)) for (const item of value) collectSecretMarkerRefs(item, out);
2127
- else if (isRecord$5(value)) for (const child of Object.values(value)) collectSecretMarkerRefs(child, out);
2177
+ else if (isRecord$6(value)) for (const child of Object.values(value)) collectSecretMarkerRefs(child, out);
2128
2178
  return out;
2129
2179
  }
2130
2180
  async function storedValueEquals(secrets, marker, candidate) {
@@ -2179,7 +2229,7 @@ function rowId(row, idKey) {
2179
2229
  return null;
2180
2230
  }
2181
2231
  async function writeArray(ctx, node, incoming, stored, fieldPath) {
2182
- const storedRows = Array.isArray(stored) ? stored.filter(isRecord$5) : [];
2232
+ const storedRows = Array.isArray(stored) ? stored.filter(isRecord$6) : [];
2183
2233
  if (!Array.isArray(incoming)) {
2184
2234
  ctx.deletes.push(...collectSecretMarkerRefs(storedRows));
2185
2235
  return {
@@ -2195,7 +2245,7 @@ async function writeArray(ctx, node, incoming, stored, fieldPath) {
2195
2245
  const kept = /* @__PURE__ */ new Set();
2196
2246
  const rows = [];
2197
2247
  for (const row of incoming) {
2198
- if (!isRecord$5(row)) {
2248
+ if (!isRecord$6(row)) {
2199
2249
  rows.push(row);
2200
2250
  continue;
2201
2251
  }
@@ -2220,7 +2270,7 @@ async function writeNode(ctx, node, incoming, stored, fieldPath) {
2220
2270
  case "leaf": return writeLeaf(ctx, incoming, stored, fieldPath);
2221
2271
  case "array": return writeArray(ctx, node, incoming, stored, fieldPath);
2222
2272
  case "object": {
2223
- if (!isRecord$5(incoming)) {
2273
+ if (!isRecord$6(incoming)) {
2224
2274
  if (incoming === void 0) return KEEP;
2225
2275
  ctx.deletes.push(...collectSecretMarkerRefs(stored));
2226
2276
  return {
@@ -2228,7 +2278,7 @@ async function writeNode(ctx, node, incoming, stored, fieldPath) {
2228
2278
  value: incoming
2229
2279
  };
2230
2280
  }
2231
- const storedObj = isRecord$5(stored) ? stored : {};
2281
+ const storedObj = isRecord$6(stored) ? stored : {};
2232
2282
  return {
2233
2283
  kind: "value",
2234
2284
  value: await writeMembers(ctx, node.children, incoming, storedObj, (m) => `${fieldPath}.${m}`)
@@ -2351,7 +2401,7 @@ async function resolveSecretMarkers(value, secrets, options = {}) {
2351
2401
  value: items
2352
2402
  };
2353
2403
  }
2354
- if (isRecord$5(v)) {
2404
+ if (isRecord$6(v)) {
2355
2405
  const out = {};
2356
2406
  for (const [k, child] of Object.entries(v)) {
2357
2407
  const s = substitute(child);
@@ -2383,7 +2433,7 @@ var SecretOverwriteRefusedError = class extends Error {
2383
2433
  this.name = "SecretOverwriteRefusedError";
2384
2434
  }
2385
2435
  };
2386
- function isRecord$4(value) {
2436
+ function isRecord$5(value) {
2387
2437
  return typeof value === "object" && value !== null && !Array.isArray(value);
2388
2438
  }
2389
2439
  function resolvedValue(pass, marker) {
@@ -2412,7 +2462,7 @@ function inArray(pass, incoming, stored) {
2412
2462
  return incoming.map((item, index) => {
2413
2463
  const twin = stored[index];
2414
2464
  if (isSecretMarker(twin)) return typeof item === "string" && item === resolvedValue(pass, twin) ? twin : item;
2415
- if (isRecord$4(item) && isRecord$4(twin)) return inArrayRow(pass, item, twin);
2465
+ if (isRecord$5(item) && isRecord$5(twin)) return inArrayRow(pass, item, twin);
2416
2466
  if (Array.isArray(item) && Array.isArray(twin)) return inArray(pass, item, twin);
2417
2467
  return item;
2418
2468
  });
@@ -2423,7 +2473,7 @@ function inArrayRow(pass, incoming, stored) {
2423
2473
  const twin = stored[key];
2424
2474
  if (isSecretMarker(twin)) {
2425
2475
  if (typeof value === "string" && value === resolvedValue(pass, twin)) out[key] = twin;
2426
- } else if (isRecord$4(value) && isRecord$4(twin)) out[key] = inArrayRow(pass, value, twin);
2476
+ } else if (isRecord$5(value) && isRecord$5(twin)) out[key] = inArrayRow(pass, value, twin);
2427
2477
  else if (Array.isArray(value) && Array.isArray(twin)) out[key] = inArray(pass, value, twin);
2428
2478
  }
2429
2479
  return out;
@@ -2431,7 +2481,7 @@ function inArrayRow(pass, incoming, stored) {
2431
2481
  async function walk(pass, incoming, stored) {
2432
2482
  if (isSecretMarker(stored)) return atMarker(pass, incoming, stored);
2433
2483
  if (Array.isArray(incoming) && Array.isArray(stored)) return inArray(pass, incoming, stored);
2434
- if (!isRecord$4(incoming) || !isRecord$4(stored)) return incoming;
2484
+ if (!isRecord$5(incoming) || !isRecord$5(stored)) return incoming;
2435
2485
  const out = { ...incoming };
2436
2486
  for (const [key, value] of Object.entries(incoming)) out[key] = await walk(pass, value, stored[key]);
2437
2487
  return out;
@@ -2462,7 +2512,7 @@ async function restoreUnchangedSecrets(input) {
2462
2512
  function isJsonEqual(a, b) {
2463
2513
  if (Object.is(a, b)) return true;
2464
2514
  if (Array.isArray(a)) return Array.isArray(b) && a.length === b.length && a.every((v, i) => isJsonEqual(v, b[i]));
2465
- if (isRecord$4(a) && isRecord$4(b)) {
2515
+ if (isRecord$5(a) && isRecord$5(b)) {
2466
2516
  const keys = Object.keys(a);
2467
2517
  if (keys.length !== Object.keys(b).length) return false;
2468
2518
  return keys.every((k) => Object.prototype.hasOwnProperty.call(b, k) && isJsonEqual(a[k], b[k]));
@@ -2486,7 +2536,7 @@ function markerKeysOf(blob, owner) {
2486
2536
  }
2487
2537
  function nodeFromStored(value, owner) {
2488
2538
  if (isSecretMarker(value)) return isSecretRefOwnedBy(value.$secret, owner) ? { kind: "leaf" } : null;
2489
- if (!isRecord$4(value)) return null;
2539
+ if (!isRecord$5(value)) return null;
2490
2540
  const children = /* @__PURE__ */ new Map();
2491
2541
  for (const [key, child] of Object.entries(value)) {
2492
2542
  const node = nodeFromStored(child, owner);
@@ -3960,61 +4010,6 @@ function nodeIdOfScopedKey(key) {
3960
4010
  const nodeId = key.slice(at + 1);
3961
4011
  return nodeId === "" ? null : nodeId;
3962
4012
  }
3963
- /**
3964
- * Per-listener shared-secret header the hub injects on every reverse-proxied
3965
- * data-plane request and the addon's framework wrapper validates — so only the
3966
- * hub can reach the addon's `127.0.0.1` listener. Defined here (shared by the
3967
- * core proxy and the kernel listener) to keep both off a kernel↔core import.
3968
- */
3969
- var DATAPLANE_SECRET_HEADER = "x-camstack-dataplane-secret";
3970
- /**
3971
- * The share-view scope kinds a share-link token can carry. The hub mints
3972
- * and validates them (`ShareViewGrantSchema` builds its
3973
- * enum from this list); a data plane names the kinds it ACCEPTS in `share`.
3974
- */
3975
- var SHARE_VIEW_KINDS = ["grid-view", "events-view"];
3976
- /** The wire shape of {@link PeerBytesTicket} — see the type for what it is. */
3977
- var PeerBytesTicketSchema = zod.z.object({
3978
- /** `http://127.0.0.1:<port>/<token>`. One `GET` takes it. */
3979
- url: zod.z.string().min(1),
3980
- /**
3981
- * The HOST node this URL means something on — the hub or a named agent,
3982
- * never a runner. {@link AddonPeerBytes.open} compares it to its own and
3983
- * refuses `cross-node` by name when they differ, without dialling.
3984
- */
3985
- hostNodeId: zod.z.string().min(1),
3986
- expiresAtMs: zod.z.number().int().nonnegative(),
3987
- /**
3988
- * What the producer DECLARED the body to be, when it knows — `null` when it
3989
- * does not. Never `0` for unknown (D393): a consumer sizing a bound off this
3990
- * must be able to tell "the producer did not say" from "the body is empty".
3991
- */
3992
- declaredBytes: zod.z.number().int().nonnegative().nullable()
3993
- });
3994
- /** Limits and names of `ctx.records` (D881). One authority; the engine and the facade read it. */
3995
- /** The files a kind may live in. `history` is device-history's (D850), never records. */
3996
- var RECORD_DATABASES = ["settings", "events"];
3997
- /** The classes of a kind: the `@durable` vocabulary, one authority (replaces the annotation). */
3998
- var RECORD_CLASSES = [
3999
- "config",
4000
- "ledger",
4001
- "audit",
4002
- "mirror",
4003
- "ephemeral"
4004
- ];
4005
- var RECORD_DEFAULT_MAX_DATA_BYTES = 64 * 1024;
4006
- var RECORD_MAX_DATA_BYTES = 1024 * 1024;
4007
- var RECORD_BATCH_MAX = 1e3;
4008
- var RECORD_BATCH_MAX_BYTES = 4 * 1024 * 1024;
4009
- var RECORD_QUERY_MAX = 1e3;
4010
- /** Rows one DELETE statement removes before the serving thread yields. */
4011
- var RECORD_DELETE_BATCH = 5e3;
4012
- /** A kind in the `settings` file may not bound itself above this (D447: high volume is `events`). */
4013
- var RECORD_SETTINGS_MAX_ROWS = 5e4;
4014
- /** The engine's TTL sweep cadence. */
4015
- var RECORD_SWEEP_INTERVAL_MS = 10 * 6e4;
4016
- /** The `Column`-free proof prefix: a ref collection for a kind's secret fields. */
4017
- var RECORD_SECRET_COLLECTION_PREFIX = "records:";
4018
4013
  var PREFIX = "records/";
4019
4014
  /** The base of every records failure. `detail` is the human part of the message. */
4020
4015
  var RecordsError = class extends Error {
@@ -4089,6 +4084,13 @@ var ForeignSecretMarkerError = class extends RecordsError {
4089
4084
  this.name = "ForeignSecretMarkerError";
4090
4085
  }
4091
4086
  };
4087
+ /** The keychain could not store or serve a value: explicit, never an empty string. */
4088
+ var RecordSecretUnavailableError = class extends RecordsError {
4089
+ constructor(detail) {
4090
+ super("secret-unavailable", detail);
4091
+ this.name = "RecordSecretUnavailableError";
4092
+ }
4093
+ };
4092
4094
  var InvalidRecordError = class extends RecordsError {
4093
4095
  constructor(detail) {
4094
4096
  super("invalid-record", detail);
@@ -4125,73 +4127,30 @@ var TransactRefusedError = class extends RecordsError {
4125
4127
  this.name = "TransactRefusedError";
4126
4128
  }
4127
4129
  };
4128
- function defOf(schema) {
4129
- const zodBag = Reflect.get(schema, "_zod");
4130
- if (typeof zodBag !== "object" || zodBag === null) return {};
4131
- const def = Reflect.get(zodBag, "def");
4132
- if (typeof def !== "object" || def === null) return {};
4133
- return def;
4134
- }
4135
- function declaredHere(schema) {
4136
- return zod.z.globalRegistry.get(schema)?.secret === true;
4137
- }
4138
- /** Wrapper kinds whose `innerType` is the field itself. */
4139
- var WRAPPERS = new Set([
4140
- "optional",
4141
- "nullable",
4142
- "default",
4143
- "prefault",
4144
- "catch",
4145
- "readonly",
4146
- "nonoptional"
4147
- ]);
4148
- /**
4149
- * The schema layers that make up ONE field: the schema itself and every
4150
- * wrapper below it (optional / default / nullable / readonly / catch), plus
4151
- * both sides of a pipe (`z.preprocess` puts the real schema on `out`,
4152
- * `.transform` on `in`).
4153
- */
4154
- function layersOf(schema) {
4155
- const out = [];
4156
- const queue = [schema];
4157
- while (queue.length > 0) {
4158
- const s = queue.shift();
4159
- if (!s || out.includes(s)) continue;
4160
- out.push(s);
4161
- const def = defOf(s);
4162
- if (def.type !== void 0 && WRAPPERS.has(def.type) && def.innerType) queue.push(def.innerType);
4163
- if (def.type === "pipe") {
4164
- if (def.in) queue.push(def.in);
4165
- if (def.out) queue.push(def.out);
4166
- }
4167
- }
4168
- return out;
4169
- }
4170
- /** True when any layer of this field declares `.meta({ secret: true })`. */
4171
- function isZodSecret(schema) {
4172
- return layersOf(schema).some(declaredHere);
4173
- }
4174
- /**
4175
- * Every declared secret path in a config schema: dotted keys, `[]` for "each
4176
- * element of this array" (`connection.password`, `rows[].token`). A declared
4177
- * object or array is reported as one path and not descended into — everything
4178
- * under it is secret.
4179
- */
4180
- function collectZodSecretPaths(schema, prefix = "") {
4181
- if (isZodSecret(schema)) return prefix.length > 0 ? [prefix] : [];
4182
- const paths = [];
4183
- for (const layer of layersOf(schema)) {
4184
- const def = defOf(layer);
4185
- if (def.type === "object" && def.shape) for (const [key, child] of Object.entries(def.shape)) paths.push(...collectZodSecretPaths(child, prefix ? `${prefix}.${key}` : key));
4186
- else if (def.type === "array" && def.element) paths.push(...collectZodSecretPaths(def.element, `${prefix}[]`));
4187
- else if (def.type === "union" && def.options) for (const option of def.options) paths.push(...collectZodSecretPaths(option, prefix));
4188
- else if (def.type === "intersection") {
4189
- if (def.left) paths.push(...collectZodSecretPaths(def.left, prefix));
4190
- if (def.right) paths.push(...collectZodSecretPaths(def.right, prefix));
4191
- }
4192
- }
4193
- return [...new Set(paths)];
4194
- }
4130
+ /** Limits and names of `ctx.records` (D881). One authority; the engine and the facade read it. */
4131
+ /** The files a kind may live in. `history` is device-history's (D850), never records. */
4132
+ var RECORD_DATABASES = ["settings", "events"];
4133
+ /** The classes of a kind: the `@durable` vocabulary, one authority (replaces the annotation). */
4134
+ var RECORD_CLASSES = [
4135
+ "config",
4136
+ "ledger",
4137
+ "audit",
4138
+ "mirror",
4139
+ "ephemeral"
4140
+ ];
4141
+ var RECORD_DEFAULT_MAX_DATA_BYTES = 64 * 1024;
4142
+ var RECORD_MAX_DATA_BYTES = 1024 * 1024;
4143
+ var RECORD_BATCH_MAX = 1e3;
4144
+ var RECORD_BATCH_MAX_BYTES = 4 * 1024 * 1024;
4145
+ var RECORD_QUERY_MAX = 1e3;
4146
+ /** Rows one DELETE statement removes before the serving thread yields. */
4147
+ var RECORD_DELETE_BATCH = 5e3;
4148
+ /** A kind in the `settings` file may not bound itself above this (D447: high volume is `events`). */
4149
+ var RECORD_SETTINGS_MAX_ROWS = 5e4;
4150
+ /** The engine's TTL sweep cadence. */
4151
+ var RECORD_SWEEP_INTERVAL_MS = 10 * 6e4;
4152
+ /** The `Column`-free proof prefix: a ref collection for a kind's secret fields. */
4153
+ var RECORD_SECRET_COLLECTION_PREFIX = "records:";
4195
4154
  /**
4196
4155
  * Secret fields of a record, addressed the way a Zod schema declares them
4197
4156
  * (`collectZodSecretPaths`): dotted keys, `[]` for "each element of this array"
@@ -4228,11 +4187,11 @@ function secretArrayPrefixes(path) {
4228
4187
  }
4229
4188
  return prefixes;
4230
4189
  }
4231
- function isRecord$3(value) {
4190
+ function isRecord$4(value) {
4232
4191
  return typeof value === "object" && value !== null && !Array.isArray(value);
4233
4192
  }
4234
4193
  function elementId(element, idKey, declared, prefix) {
4235
- const id = isRecord$3(element) ? element[idKey] : void 0;
4194
+ const id = isRecord$4(element) ? element[idKey] : void 0;
4236
4195
  if (typeof id !== "string" || id.length === 0) throw new InvalidRecordError(`"${declared}": every element of "${prefix}" needs a non-empty string "${idKey}" to carry a secret`);
4237
4196
  return id;
4238
4197
  }
@@ -4243,7 +4202,7 @@ function elementId(element, idKey, declared, prefix) {
4243
4202
  */
4244
4203
  var REMOVE_LEAF = Symbol("remove-leaf");
4245
4204
  function mapAt(node, segments, index, walkedKeys, concretePrefix, declared, arrayKeys, visit) {
4246
- if (!isRecord$3(node)) return node;
4205
+ if (!isRecord$4(node)) return node;
4247
4206
  const segment = segments[index];
4248
4207
  if (segment === void 0) return node;
4249
4208
  if (!Object.prototype.hasOwnProperty.call(node, segment.key)) return node;
@@ -4319,6 +4278,129 @@ function recordSecretRef(owner, kind, rowId, concretePath) {
4319
4278
  });
4320
4279
  }
4321
4280
  /**
4281
+ * A stored secret, as an admin read shows it: a VIEW naming the row's own
4282
+ * keychain ref (`set: true`), never the value and no longer the bare redaction
4283
+ * token. The form hands it to the secret field, which reveals the value by ref
4284
+ * through the audited `keychain-admin.reveal`; sent back untouched it keeps the
4285
+ * stored secret (the records door reads a view as KEEP).
4286
+ *
4287
+ * ONE implementation for the entries service and for every addon that serves
4288
+ * its own instances (`RecordIntegrationInstances`).
4289
+ */
4290
+ function isRecord$3(value) {
4291
+ return typeof value === "object" && value !== null && !Array.isArray(value);
4292
+ }
4293
+ function secretViewsOf(owner, kind, id, decl, data) {
4294
+ if (decl.secretPaths.length === 0) return data;
4295
+ const shown = mapSecretLeaves(data, decl.secretPaths, decl.secretArrayKeys, (leaf) => {
4296
+ if (leaf.value !== "__camstack_redacted__") return leaf.value;
4297
+ return {
4298
+ $secret: recordSecretRef(owner, kind, id, leaf.concrete),
4299
+ v: 1,
4300
+ set: true
4301
+ };
4302
+ });
4303
+ return isRecord$3(shown) ? shown : data;
4304
+ }
4305
+ /**
4306
+ * Per-listener shared-secret header the hub injects on every reverse-proxied
4307
+ * data-plane request and the addon's framework wrapper validates — so only the
4308
+ * hub can reach the addon's `127.0.0.1` listener. Defined here (shared by the
4309
+ * core proxy and the kernel listener) to keep both off a kernel↔core import.
4310
+ */
4311
+ var DATAPLANE_SECRET_HEADER = "x-camstack-dataplane-secret";
4312
+ /**
4313
+ * The share-view scope kinds a share-link token can carry. The hub mints
4314
+ * and validates them (`ShareViewGrantSchema` builds its
4315
+ * enum from this list); a data plane names the kinds it ACCEPTS in `share`.
4316
+ */
4317
+ var SHARE_VIEW_KINDS = ["grid-view", "events-view"];
4318
+ /** The wire shape of {@link PeerBytesTicket} — see the type for what it is. */
4319
+ var PeerBytesTicketSchema = zod.z.object({
4320
+ /** `http://127.0.0.1:<port>/<token>`. One `GET` takes it. */
4321
+ url: zod.z.string().min(1),
4322
+ /**
4323
+ * The HOST node this URL means something on — the hub or a named agent,
4324
+ * never a runner. {@link AddonPeerBytes.open} compares it to its own and
4325
+ * refuses `cross-node` by name when they differ, without dialling.
4326
+ */
4327
+ hostNodeId: zod.z.string().min(1),
4328
+ expiresAtMs: zod.z.number().int().nonnegative(),
4329
+ /**
4330
+ * What the producer DECLARED the body to be, when it knows — `null` when it
4331
+ * does not. Never `0` for unknown (D393): a consumer sizing a bound off this
4332
+ * must be able to tell "the producer did not say" from "the body is empty".
4333
+ */
4334
+ declaredBytes: zod.z.number().int().nonnegative().nullable()
4335
+ });
4336
+ function defOf(schema) {
4337
+ const zodBag = Reflect.get(schema, "_zod");
4338
+ if (typeof zodBag !== "object" || zodBag === null) return {};
4339
+ const def = Reflect.get(zodBag, "def");
4340
+ if (typeof def !== "object" || def === null) return {};
4341
+ return def;
4342
+ }
4343
+ function declaredHere(schema) {
4344
+ return zod.z.globalRegistry.get(schema)?.secret === true;
4345
+ }
4346
+ /** Wrapper kinds whose `innerType` is the field itself. */
4347
+ var WRAPPERS = new Set([
4348
+ "optional",
4349
+ "nullable",
4350
+ "default",
4351
+ "prefault",
4352
+ "catch",
4353
+ "readonly",
4354
+ "nonoptional"
4355
+ ]);
4356
+ /**
4357
+ * The schema layers that make up ONE field: the schema itself and every
4358
+ * wrapper below it (optional / default / nullable / readonly / catch), plus
4359
+ * both sides of a pipe (`z.preprocess` puts the real schema on `out`,
4360
+ * `.transform` on `in`).
4361
+ */
4362
+ function layersOf(schema) {
4363
+ const out = [];
4364
+ const queue = [schema];
4365
+ while (queue.length > 0) {
4366
+ const s = queue.shift();
4367
+ if (!s || out.includes(s)) continue;
4368
+ out.push(s);
4369
+ const def = defOf(s);
4370
+ if (def.type !== void 0 && WRAPPERS.has(def.type) && def.innerType) queue.push(def.innerType);
4371
+ if (def.type === "pipe") {
4372
+ if (def.in) queue.push(def.in);
4373
+ if (def.out) queue.push(def.out);
4374
+ }
4375
+ }
4376
+ return out;
4377
+ }
4378
+ /** True when any layer of this field declares `.meta({ secret: true })`. */
4379
+ function isZodSecret(schema) {
4380
+ return layersOf(schema).some(declaredHere);
4381
+ }
4382
+ /**
4383
+ * Every declared secret path in a config schema: dotted keys, `[]` for "each
4384
+ * element of this array" (`connection.password`, `rows[].token`). A declared
4385
+ * object or array is reported as one path and not descended into — everything
4386
+ * under it is secret.
4387
+ */
4388
+ function collectZodSecretPaths(schema, prefix = "") {
4389
+ if (isZodSecret(schema)) return prefix.length > 0 ? [prefix] : [];
4390
+ const paths = [];
4391
+ for (const layer of layersOf(schema)) {
4392
+ const def = defOf(layer);
4393
+ if (def.type === "object" && def.shape) for (const [key, child] of Object.entries(def.shape)) paths.push(...collectZodSecretPaths(child, prefix ? `${prefix}.${key}` : key));
4394
+ else if (def.type === "array" && def.element) paths.push(...collectZodSecretPaths(def.element, `${prefix}[]`));
4395
+ else if (def.type === "union" && def.options) for (const option of def.options) paths.push(...collectZodSecretPaths(option, prefix));
4396
+ else if (def.type === "intersection") {
4397
+ if (def.left) paths.push(...collectZodSecretPaths(def.left, prefix));
4398
+ if (def.right) paths.push(...collectZodSecretPaths(def.right, prefix));
4399
+ }
4400
+ }
4401
+ return [...new Set(paths)];
4402
+ }
4403
+ /**
4322
4404
  * Record kinds (D881): the declaration an addon makes of one kind of fact, the
4323
4405
  * Zod row schema that describes it, and the helper that turns the two into the
4324
4406
  * JSON the engine stores.
@@ -4491,6 +4573,27 @@ function assertTransactScope(members) {
4491
4573
  if (missing.length > 0) throw new TransactRefusedError(`no-family: ${missing.map((m) => m.kind).join(", ")} declare no transactFamily; kinds that must agree through transact share one`);
4492
4574
  if (new Set(kinds.map((m) => m.declaration.transactFamily)).size > 1) throw new TransactRefusedError(`cross-family: the ops span more than one transactFamily (${kinds.map((m) => `${m.kind}=${String(m.declaration.transactFamily)}`).join(", ")})`);
4493
4575
  }
4576
+ /**
4577
+ * Declare one entry kind. An entry is configuration: never trimmed by the
4578
+ * engine, never aged, belonging to no device.
4579
+ */
4580
+ function defineEntryKind(name, spec) {
4581
+ const defined = defineRecordKinds({ [name]: {
4582
+ schema: spec.schema,
4583
+ class: "config",
4584
+ writeTrigger: spec.writeTrigger ?? "an operator adds or edits an entry in the entries UI",
4585
+ retention: { none: "an entry goes only when the operator deletes it" },
4586
+ ...spec.database === void 0 ? {} : { database: spec.database },
4587
+ ...spec.indexes === void 0 ? {} : { indexes: spec.indexes },
4588
+ ...spec.secretArrayKeys === void 0 ? {} : { secretArrayKeys: spec.secretArrayKeys },
4589
+ entry: {
4590
+ title: spec.title,
4591
+ ...spec.nameField === void 0 ? {} : { nameField: spec.nameField }
4592
+ }
4593
+ } })[name];
4594
+ if (defined === void 0) throw new DeclarationRefusedError(`entry kind "${name}" was not built`);
4595
+ return defined;
4596
+ }
4494
4597
  zod.z.object({
4495
4598
  field: zod.z.string().min(1),
4496
4599
  on: zod.z.literal("advance")
@@ -6026,6 +6129,7 @@ var CAP_NAMES = Object.freeze([
6026
6129
  "humidity-sensor",
6027
6130
  "image",
6028
6131
  "image-settings",
6132
+ "integration-instances",
6029
6133
  "integrations",
6030
6134
  "intercom",
6031
6135
  "ir-transmitter",
@@ -10865,6 +10969,134 @@ var IntegrationInstanceRefSchema = zod.z.object({
10865
10969
  ]),
10866
10970
  candidateStableId: zod.z.string().optional()
10867
10971
  });
10972
+ /** The most instances one addon lists (an integrations page, not a table). */
10973
+ var INSTANCES_LIST_MAX = 1e3;
10974
+ /** The keys of the kind's secret fields that sit at the top level of the body. */
10975
+ function topLevelSecretKeys(paths) {
10976
+ return new Set(paths.filter((p) => !p.includes(".") && !p.includes("[")));
10977
+ }
10978
+ var RecordIntegrationInstances = class {
10979
+ records;
10980
+ kind;
10981
+ hooks;
10982
+ handle;
10983
+ secretKeys;
10984
+ nameField;
10985
+ constructor(records, kind, hooks) {
10986
+ this.records = records;
10987
+ this.kind = kind;
10988
+ this.hooks = hooks;
10989
+ this.handle = records.kind(kind);
10990
+ this.secretKeys = topLevelSecretKeys(kind.declaration.secretPaths);
10991
+ this.nameField = kind.declaration.entry?.nameField ?? "name";
10992
+ }
10993
+ /**
10994
+ * One instance read for the addon's own runtime; null when absent. When the keychain is
10995
+ * locked the row is served WITHOUT its secrets and says so (`secrets: 'unavailable'`), so the
10996
+ * caller can keep what it had instead of reconfiguring with an empty secret (D49).
10997
+ */
10998
+ async readResolved(id) {
10999
+ try {
11000
+ const record = await this.handle.getResolved(id);
11001
+ return record === null ? null : {
11002
+ id,
11003
+ body: record.data,
11004
+ secrets: "resolved"
11005
+ };
11006
+ } catch (err) {
11007
+ if (!(err instanceof RecordSecretUnavailableError)) throw err;
11008
+ const stored = await this.handle.get(id);
11009
+ if (stored === null) return null;
11010
+ return {
11011
+ id,
11012
+ body: Object.fromEntries(Object.entries(stored.data).filter(([key]) => !this.secretKeys.has(key))),
11013
+ secrets: "unavailable"
11014
+ };
11015
+ }
11016
+ }
11017
+ /** The body of {@link readResolved} alone; a locked keychain yields the row without secrets. */
11018
+ async getResolved(id) {
11019
+ return (await this.readResolved(id))?.body ?? null;
11020
+ }
11021
+ /** Every instance, secrets resolved where the keychain allows; an absent one is skipped. */
11022
+ async listResolved() {
11023
+ const page = await this.handle.query({ limit: INSTANCES_LIST_MAX });
11024
+ const out = [];
11025
+ for (const record of page.records) {
11026
+ const read = await this.readResolved(record.id);
11027
+ if (read !== null) out.push(read);
11028
+ }
11029
+ return out;
11030
+ }
11031
+ viewOf(record) {
11032
+ const shown = secretViewsOf(this.records.owner, this.kind.name, record.id, this.kind.declaration, record.data);
11033
+ const rawName = record.data[this.nameField];
11034
+ return {
11035
+ id: record.id,
11036
+ name: typeof rawName === "string" ? rawName : record.id,
11037
+ configured: this.hooks.configured(record.data),
11038
+ formValues: shown
11039
+ };
11040
+ }
11041
+ describe = async () => this.hooks.description;
11042
+ instanceFormSchema = async ({ id }) => this.hooks.formSchema(id);
11043
+ listInstances = async () => {
11044
+ return (await this.handle.query({ limit: INSTANCES_LIST_MAX })).records.map((record) => this.viewOf(record));
11045
+ };
11046
+ getInstance = async ({ id }) => {
11047
+ const record = await this.handle.get(id);
11048
+ return record === null ? null : this.viewOf(record);
11049
+ };
11050
+ /** Insert ONE row (`ifRev: 0`: an existing id is refused, never overwritten). */
11051
+ createInstance = async ({ id, name }) => {
11052
+ await this.handle.put({
11053
+ id,
11054
+ data: this.hooks.initialBody(name)
11055
+ }, { ifRev: 0 });
11056
+ await this.hooks.onChanged?.(id);
11057
+ return { id };
11058
+ };
11059
+ updateInstance = async ({ id, name, values }) => {
11060
+ const patch = {};
11061
+ for (const [key, value] of Object.entries(values)) {
11062
+ if (value === void 0) continue;
11063
+ if (!this.secretKeys.has(key)) patch[key] = value;
11064
+ else if (isSecretClear(value)) patch[key] = null;
11065
+ else if (typeof value === "string" && value !== "" && value !== "__camstack_redacted__" && !isSecretFieldView(value)) patch[key] = value;
11066
+ }
11067
+ if (name !== void 0) patch[this.nameField] = name;
11068
+ await this.handle.patch(id, patch);
11069
+ await this.hooks.onChanged?.(id);
11070
+ return { ok: true };
11071
+ };
11072
+ /** The row and its keychain refs go together (the records door). */
11073
+ deleteInstance = async ({ id }) => {
11074
+ await this.handle.delete(id);
11075
+ await this.hooks.onChanged?.(id);
11076
+ return { ok: true };
11077
+ };
11078
+ testInstance = async (input) => {
11079
+ if (this.hooks.test === void 0) return {
11080
+ success: false,
11081
+ status: "unsupported",
11082
+ error: "This integration declares no connection test"
11083
+ };
11084
+ return this.hooks.test(input);
11085
+ };
11086
+ /** The flat provider object to hand to `registerProvider`. */
11087
+ toProvider() {
11088
+ return {
11089
+ describe: this.describe,
11090
+ instanceFormSchema: this.instanceFormSchema,
11091
+ listInstances: this.listInstances,
11092
+ getInstance: this.getInstance,
11093
+ createInstance: this.createInstance,
11094
+ updateInstance: this.updateInstance,
11095
+ deleteInstance: this.deleteInstance,
11096
+ testInstance: this.testInstance
11097
+ };
11098
+ }
11099
+ };
10868
11100
  /**
10869
11101
  * Shared video / audio encode profile schemas used by every consumer
10870
11102
  * that asks the stream broker to spawn a derived stream
@@ -19826,6 +20058,7 @@ var SYSTEM_CAP_VOCABULARY = {
19826
20058
  "load-contribution": system(INTERNAL),
19827
20059
  "local-network": system(NETWORK),
19828
20060
  "log-channels": system(INTERNAL),
20061
+ "integration-instances": system(INTERNAL),
19829
20062
  "log-destination": system(INTERNAL),
19830
20063
  "login-method": system(IDENTITY),
19831
20064
  "mesh-network": system(NETWORK),
@@ -43737,7 +43970,7 @@ var TargetKindCapsSchema = zod.z.object({
43737
43970
  * the union is large and not meant for runtime validation here; the exported
43738
43971
  * `TargetKind` type re-tightens `configSchema` to `ConfigUISchema`.
43739
43972
  */
43740
- var ConfigSchemaPassthrough$3 = zod.z.unknown();
43973
+ var ConfigSchemaPassthrough$4 = zod.z.unknown();
43741
43974
  var TargetKindSchema = zod.z.object({
43742
43975
  kind: zod.z.string(),
43743
43976
  label: zod.z.string(),
@@ -43774,7 +44007,7 @@ var TargetKindSchema = zod.z.object({
43774
44007
  * its raster path, which is the safe default for an unknown image.
43775
44008
  */
43776
44009
  iconMediaType: zod.z.string().optional(),
43777
- configSchema: ConfigSchemaPassthrough$3,
44010
+ configSchema: ConfigSchemaPassthrough$4,
43778
44011
  /**
43779
44012
  * The config keys that decide WHERE this kind's secrets are sent (server,
43780
44013
  * base URL, instance, chat, recipient). A save that changes any of them
@@ -61362,9 +61595,15 @@ var AvailableIntegrationTypeSchema = zod.z.object({
61362
61595
  * branch on CAP — never on addon name. `device-adoption` integrations
61363
61596
  * (Home Assistant, …) route through the broker step (Approach A);
61364
61597
  * `device-provider` integrations (Reolink/ONVIF) keep the
61365
- * legacy config → discovery flow.
61598
+ * legacy config → discovery flow. `connection` is an addon that only holds a
61599
+ * connection as typed records (`integration-instances`, D985): no devices,
61600
+ * no discovery.
61366
61601
  */
61367
- kind: zod.z.enum(["device-adoption", "device-provider"]),
61602
+ kind: zod.z.enum([
61603
+ "device-adoption",
61604
+ "device-provider",
61605
+ "connection"
61606
+ ]),
61368
61607
  /**
61369
61608
  * For `device-adoption` addons: the broker kind to create/link
61370
61609
  * (e.g. `home-assistant`), declared in the addon manifest. `null` for
@@ -61495,6 +61734,87 @@ var integrationsCapability = {
61495
61734
  mount: { kind: "server-provided" }
61496
61735
  };
61497
61736
  /**
61737
+ * `integration-instances` - the connection of an addon that holds ONE or SEVERAL
61738
+ * (an account, a relay, a destination) as typed records, shown on the
61739
+ * Integrations page like every other integration (D985, D986).
61740
+ *
61741
+ * A collection of providers: each addon that holds connections registers one
61742
+ * and the hub aggregator (`integrations.*`) reaches a provider with the pinned
61743
+ * `addonId`. It is internal and has no route: the operator-facing surface is
61744
+ * the `integrations` cap, which keeps ONE list.
61745
+ *
61746
+ * Identity: the instance id IS the `integrations` registry id (`int_NNNN`,
61747
+ * immutable, already in the `/integrations/<id>` URL). A second operator-chosen
61748
+ * slug would be a second authority over one identity (D224). `name` is the
61749
+ * editable label.
61750
+ *
61751
+ * Secrets: every field the instance kind marks `.meta({ secret: true })` reaches
61752
+ * the form as a `SecretFieldView`, never text (D789). A patch value omitted, `''`
61753
+ * or the redaction token KEEPS the stored secret; `{ $secretClear: true }`
61754
+ * clears it.
61755
+ */
61756
+ var ConfigSchemaPassthrough$3 = zod.z.custom();
61757
+ var IntegrationInstanceIdSchema = zod.z.string().min(1);
61758
+ var IntegrationInstanceModeSchema = zod.z.enum(["single", "multiple"]);
61759
+ var IntegrationInstanceDescriptionSchema = zod.z.object({
61760
+ /** `single`: at most one instance can exist (Loki). `multiple`: an account each. */
61761
+ instanceMode: IntegrationInstanceModeSchema,
61762
+ /** What the instance is, for the UI (`destination`, `relay`, `account`). */
61763
+ kind: zod.z.string(),
61764
+ /** True when `testInstance` really probes the remote. */
61765
+ canTest: zod.z.boolean()
61766
+ });
61767
+ var IntegrationInstanceStatusSchema = zod.z.object({
61768
+ state: zod.z.enum([
61769
+ "ok",
61770
+ "off",
61771
+ "error",
61772
+ "unknown"
61773
+ ]),
61774
+ detail: zod.z.string().optional()
61775
+ });
61776
+ var IntegrationInstanceSchema = zod.z.object({
61777
+ id: IntegrationInstanceIdSchema,
61778
+ name: zod.z.string(),
61779
+ /** The addon's own rule (an URL is present, a client id is present...). */
61780
+ configured: zod.z.boolean(),
61781
+ /** Values for the instance form; a secret is a `SecretFieldView`, never text. */
61782
+ formValues: zod.z.record(zod.z.string(), zod.z.unknown()),
61783
+ status: IntegrationInstanceStatusSchema.optional()
61784
+ });
61785
+ var IntegrationInstancePatchSchema = zod.z.object({
61786
+ id: IntegrationInstanceIdSchema,
61787
+ name: zod.z.string().min(1).optional(),
61788
+ /** Omitted / '' / redaction token keeps a secret; `{ $secretClear: true }` clears it. */
61789
+ values: zod.z.record(zod.z.string(), zod.z.unknown())
61790
+ });
61791
+ var integrationInstancesCapability = {
61792
+ name: "integration-instances",
61793
+ scope: "system",
61794
+ mode: "collection",
61795
+ internal: true,
61796
+ methods: {
61797
+ describe: method(zod.z.void(), IntegrationInstanceDescriptionSchema),
61798
+ /** The form; `id: null` is the create form. */
61799
+ instanceFormSchema: method(zod.z.object({ id: IntegrationInstanceIdSchema.nullable() }), ConfigSchemaPassthrough$3),
61800
+ listInstances: method(zod.z.void(), zod.z.array(IntegrationInstanceSchema).readonly()),
61801
+ getInstance: method(zod.z.object({ id: IntegrationInstanceIdSchema }), IntegrationInstanceSchema.nullable()),
61802
+ /** Insert the typed record for a registry row that already exists. */
61803
+ createInstance: method(zod.z.object({
61804
+ id: IntegrationInstanceIdSchema,
61805
+ name: zod.z.string().min(1)
61806
+ }), zod.z.object({ id: zod.z.string() }), { kind: "mutation" }),
61807
+ updateInstance: method(IntegrationInstancePatchSchema, zod.z.object({ ok: zod.z.literal(true) }), { kind: "mutation" }),
61808
+ /** Delete the record and its keychain refs together. */
61809
+ deleteInstance: method(zod.z.object({ id: IntegrationInstanceIdSchema }), zod.z.object({ ok: zod.z.literal(true) }), { kind: "mutation" }),
61810
+ testInstance: optionalMethod(zod.z.object({
61811
+ id: IntegrationInstanceIdSchema.nullable(),
61812
+ values: zod.z.record(zod.z.string(), zod.z.unknown())
61813
+ }), TestConnectionResultSchema$1, { kind: "mutation" })
61814
+ },
61815
+ mount: { kind: "skip" }
61816
+ };
61817
+ /**
61498
61818
  * Two-way audio / talk-back cap. Clients open a WebRTC audio-only
61499
61819
  * session (server-initiated offer pattern, identical to the main
61500
61820
  * video WebRTC flow) and the browser captures the mic; the server
@@ -90816,6 +91136,7 @@ var ALL_CAPABILITY_DEFINITIONS = [
90816
91136
  humiditySensorCapability,
90817
91137
  imageCapability,
90818
91138
  imageSettingsCapability,
91139
+ integrationInstancesCapability,
90819
91140
  integrationsCapability,
90820
91141
  intercomCapability,
90821
91142
  irTransmitterCapability,
@@ -97219,6 +97540,62 @@ var METHOD_ACCESS_MAP = Object.freeze({
97219
97540
  access: "create",
97220
97541
  role: "admin"
97221
97542
  },
97543
+ "integrationInstances.createInstance": {
97544
+ capName: "integration-instances",
97545
+ capScope: "system",
97546
+ addonId: null,
97547
+ access: "create",
97548
+ role: "admin"
97549
+ },
97550
+ "integrationInstances.deleteInstance": {
97551
+ capName: "integration-instances",
97552
+ capScope: "system",
97553
+ addonId: null,
97554
+ access: "delete",
97555
+ role: "admin"
97556
+ },
97557
+ "integrationInstances.describe": {
97558
+ capName: "integration-instances",
97559
+ capScope: "system",
97560
+ addonId: null,
97561
+ access: "view",
97562
+ role: "admin"
97563
+ },
97564
+ "integrationInstances.getInstance": {
97565
+ capName: "integration-instances",
97566
+ capScope: "system",
97567
+ addonId: null,
97568
+ access: "view",
97569
+ role: "admin"
97570
+ },
97571
+ "integrationInstances.instanceFormSchema": {
97572
+ capName: "integration-instances",
97573
+ capScope: "system",
97574
+ addonId: null,
97575
+ access: "view",
97576
+ role: "admin"
97577
+ },
97578
+ "integrationInstances.listInstances": {
97579
+ capName: "integration-instances",
97580
+ capScope: "system",
97581
+ addonId: null,
97582
+ access: "view",
97583
+ role: "admin"
97584
+ },
97585
+ "integrationInstances.testInstance": {
97586
+ capName: "integration-instances",
97587
+ capScope: "system",
97588
+ addonId: null,
97589
+ access: "create",
97590
+ role: "admin"
97591
+ },
97592
+ "integrationInstances.updateInstance": {
97593
+ capName: "integration-instances",
97594
+ capScope: "system",
97595
+ addonId: null,
97596
+ access: "create",
97597
+ role: "admin"
97598
+ },
97222
97599
  "integrations.create": {
97223
97600
  capName: "integrations",
97224
97601
  capScope: "system",
@@ -110106,6 +110483,12 @@ Object.defineProperty(exports, "ReadinessTimeoutError", {
110106
110483
  return ReadinessTimeoutError;
110107
110484
  }
110108
110485
  });
110486
+ Object.defineProperty(exports, "RecordIntegrationInstances", {
110487
+ enumerable: true,
110488
+ get: function() {
110489
+ return RecordIntegrationInstances;
110490
+ }
110491
+ });
110109
110492
  Object.defineProperty(exports, "RecordKindDeclarationSchema", {
110110
110493
  enumerable: true,
110111
110494
  get: function() {
@@ -110712,12 +111095,24 @@ Object.defineProperty(exports, "decodeVectorBase64", {
110712
111095
  return decodeVectorBase64;
110713
111096
  }
110714
111097
  });
111098
+ Object.defineProperty(exports, "defineAddonMigrations", {
111099
+ enumerable: true,
111100
+ get: function() {
111101
+ return defineAddonMigrations;
111102
+ }
111103
+ });
110715
111104
  Object.defineProperty(exports, "defineCustomActions", {
110716
111105
  enumerable: true,
110717
111106
  get: function() {
110718
111107
  return defineCustomActions;
110719
111108
  }
110720
111109
  });
111110
+ Object.defineProperty(exports, "defineEntryKind", {
111111
+ enumerable: true,
111112
+ get: function() {
111113
+ return defineEntryKind;
111114
+ }
111115
+ });
110721
111116
  Object.defineProperty(exports, "defineExtensionSlotProvider", {
110722
111117
  enumerable: true,
110723
111118
  get: function() {
@@ -110994,6 +111389,12 @@ Object.defineProperty(exports, "integrateReading", {
110994
111389
  return integrateReading;
110995
111390
  }
110996
111391
  });
111392
+ Object.defineProperty(exports, "integrationInstancesCapability", {
111393
+ enumerable: true,
111394
+ get: function() {
111395
+ return integrationInstancesCapability;
111396
+ }
111397
+ });
110997
111398
  Object.defineProperty(exports, "internalActionId", {
110998
111399
  enumerable: true,
110999
111400
  get: function() {
@@ -111114,6 +111515,12 @@ Object.defineProperty(exports, "isSecretClear", {
111114
111515
  return isSecretClear;
111115
111516
  }
111116
111517
  });
111518
+ Object.defineProperty(exports, "isSecretFieldView", {
111519
+ enumerable: true,
111520
+ get: function() {
111521
+ return isSecretFieldView;
111522
+ }
111523
+ });
111117
111524
  Object.defineProperty(exports, "isSecretMarker", {
111118
111525
  enumerable: true,
111119
111526
  get: function() {
@@ -111678,6 +112085,12 @@ Object.defineProperty(exports, "secretTreeFromSchema", {
111678
112085
  return secretTreeFromSchema;
111679
112086
  }
111680
112087
  });
112088
+ Object.defineProperty(exports, "secretViewsOf", {
112089
+ enumerable: true,
112090
+ get: function() {
112091
+ return secretViewsOf;
112092
+ }
112093
+ });
111681
112094
  Object.defineProperty(exports, "settingsStoreCapability", {
111682
112095
  enumerable: true,
111683
112096
  get: function() {