@camstack/system 1.2.475 → 1.2.477

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (92) hide show
  1. package/dist/{agent-https-BsqT0qni.js → agent-https-DkXBXEvz.js} +1 -1
  2. package/dist/{agent-https-wA8gGLc1.mjs → agent-https-vpf_D97z.mjs} +1 -1
  3. package/dist/builtins/addon-pages-aggregator/addon-pages-aggregator.addon.js +1 -1
  4. package/dist/builtins/addon-pages-aggregator/addon-pages-aggregator.addon.mjs +1 -1
  5. package/dist/builtins/addon-widgets-aggregator/addon-widgets-aggregator.addon.js +1 -1
  6. package/dist/builtins/addon-widgets-aggregator/addon-widgets-aggregator.addon.mjs +1 -1
  7. package/dist/builtins/alerts/alerts.addon.js +1 -1
  8. package/dist/builtins/alerts/alerts.addon.mjs +1 -1
  9. package/dist/builtins/autotrack/index.js +1 -1
  10. package/dist/builtins/autotrack/index.mjs +1 -1
  11. package/dist/builtins/backup-orchestrator/backup-orchestrator.addon.js +2 -2
  12. package/dist/builtins/backup-orchestrator/backup-orchestrator.addon.mjs +2 -2
  13. package/dist/builtins/calendars/calendars.addon.js +1 -1
  14. package/dist/builtins/calendars/calendars.addon.mjs +1 -1
  15. package/dist/builtins/camera-grid/index.js +1 -1
  16. package/dist/builtins/camera-grid/index.mjs +1 -1
  17. package/dist/builtins/composer/composer-live-set.d.ts +9 -1
  18. package/dist/builtins/composer/composer-runtime-factory.d.ts +2 -1
  19. package/dist/builtins/composer/composer.addon.js +581 -15
  20. package/dist/builtins/composer/composer.addon.mjs +581 -15
  21. package/dist/builtins/composer/composer.d.ts +14 -1
  22. package/dist/builtins/composer/composition-runtime.d.ts +5 -0
  23. package/dist/builtins/composer/composition-target.d.ts +6 -0
  24. package/dist/builtins/composer/field-record.d.ts +7 -0
  25. package/dist/builtins/composer/owned-fields-target.d.ts +9 -0
  26. package/dist/builtins/composer/pulse-seed-resolve.d.ts +59 -0
  27. package/dist/builtins/composer/pulse-seed.d.ts +75 -0
  28. package/dist/builtins/console-logging/index.js +1 -1
  29. package/dist/builtins/console-logging/index.mjs +1 -1
  30. package/dist/builtins/core-blocks/block-supervisor.d.ts +19 -1
  31. package/dist/builtins/core-blocks/composition-api.d.ts +7 -1
  32. package/dist/builtins/core-blocks/core-blocks.addon.js +108 -10
  33. package/dist/builtins/core-blocks/core-blocks.addon.mjs +108 -10
  34. package/dist/builtins/device-history/device-history.addon.js +63 -953
  35. package/dist/builtins/device-history/device-history.addon.mjs +2 -892
  36. package/dist/builtins/device-manager/device-manager.addon.js +1 -1
  37. package/dist/builtins/device-manager/device-manager.addon.mjs +1 -1
  38. package/dist/builtins/hub-forwarder/index.js +1 -1
  39. package/dist/builtins/hub-forwarder/index.mjs +1 -1
  40. package/dist/builtins/keychain/index.js +3 -3
  41. package/dist/builtins/keychain/index.mjs +3 -3
  42. package/dist/builtins/liveness-monitor/liveness-monitor.addon.js +1 -1
  43. package/dist/builtins/liveness-monitor/liveness-monitor.addon.mjs +1 -1
  44. package/dist/builtins/local-auth/local-auth.addon.js +2 -2
  45. package/dist/builtins/local-auth/local-auth.addon.mjs +2 -2
  46. package/dist/builtins/local-network/local-network.addon.js +2 -2
  47. package/dist/builtins/local-network/local-network.addon.mjs +2 -2
  48. package/dist/builtins/loki-logging/index.js +1 -1
  49. package/dist/builtins/loki-logging/index.mjs +1 -1
  50. package/dist/builtins/native-metrics/native-metrics.addon.js +1 -1
  51. package/dist/builtins/native-metrics/native-metrics.addon.mjs +1 -1
  52. package/dist/builtins/platform-probe/index.js +1 -1
  53. package/dist/builtins/platform-probe/index.mjs +1 -1
  54. package/dist/builtins/record-entries/index.js +1 -1
  55. package/dist/builtins/record-entries/index.mjs +1 -1
  56. package/dist/builtins/remote-access-orchestrator/remote-access-orchestrator.addon.js +1 -1
  57. package/dist/builtins/remote-access-orchestrator/remote-access-orchestrator.addon.mjs +1 -1
  58. package/dist/builtins/snapshot/index.js +1 -1
  59. package/dist/builtins/snapshot/index.mjs +1 -1
  60. package/dist/builtins/sqlite-storage/filesystem-storage.addon.js +1 -1
  61. package/dist/builtins/sqlite-storage/filesystem-storage.addon.mjs +1 -1
  62. package/dist/builtins/sqlite-storage/index.js +1 -1
  63. package/dist/builtins/sqlite-storage/index.mjs +1 -1
  64. package/dist/builtins/sqlite-storage/sqlite-settings.addon.js +2 -2
  65. package/dist/builtins/sqlite-storage/sqlite-settings.addon.mjs +2 -2
  66. package/dist/builtins/storage-orchestrator/storage-orchestrator.addon.js +1 -1
  67. package/dist/builtins/storage-orchestrator/storage-orchestrator.addon.mjs +1 -1
  68. package/dist/builtins/system-config/system-config.addon.js +3 -3
  69. package/dist/builtins/system-config/system-config.addon.mjs +3 -3
  70. package/dist/builtins/winston-logging/index.js +1 -1
  71. package/dist/builtins/winston-logging/index.mjs +1 -1
  72. package/dist/{composition-sources-CiFkyAcf.mjs → composition-sources-B5nK7pHt.mjs} +1 -1
  73. package/dist/{composition-sources-DeUSUid6.js → composition-sources-BNOP9mFp.js} +1 -1
  74. package/dist/{constants-3Wj5OyEk.js → constants-D4VigrMM.js} +1 -1
  75. package/dist/{constants-DZJAkne8.mjs → constants-jbhoFV7w.mjs} +1 -1
  76. package/dist/{device-ca-DiV5xcMz.mjs → device-ca-CvBZeyVX.mjs} +1 -1
  77. package/dist/{device-ca-ftrfVdc0.js → device-ca-DhyQeXsa.js} +1 -1
  78. package/dist/{dist-DygMs3Qc.mjs → dist-B_V9r61Z.mjs} +21 -2
  79. package/dist/{dist-BtDdPdZ7.js → dist-CNU7cdFf.js} +21 -2
  80. package/dist/file-host-worker.js +1 -1
  81. package/dist/file-host-worker.mjs +1 -1
  82. package/dist/{hub-mdns-ciao-Bc9PnWu3.mjs → hub-mdns-ciao-BuUg0gpI.mjs} +2 -2
  83. package/dist/{hub-mdns-ciao-B1VcdfT1.js → hub-mdns-ciao-DFidf52M.js} +2 -2
  84. package/dist/index.js +7 -7
  85. package/dist/index.mjs +7 -7
  86. package/dist/{restore-archive-TDkQfmLO.js → restore-archive-BtCheeWu.js} +1 -1
  87. package/dist/{restore-archive-D_Pwryre.mjs → restore-archive-CDo4Zlmx.mjs} +1 -1
  88. package/dist/retention-1QA8e4o0.js +1024 -0
  89. package/dist/retention-lPgwLane.mjs +893 -0
  90. package/dist/{wal-maintenance-D3UwIKX5.js → wal-maintenance-B7xBeIFi.js} +0 -0
  91. package/dist/{wal-maintenance-rLv4uOmp.mjs → wal-maintenance-DItlr0Yu.mjs} +0 -0
  92. package/package.json +1 -1
@@ -1,6 +1,6 @@
1
- import { $i as hydrateSchema, $n as planComposition, Bt as coreBlockComposition, Hi as collectSecretMarkerRefs, Hr as composedDeviceRef, Ht as coreBlockSourceKind, Kn as normalizeCoreBlockWrite, N as DeclaredDevices, Nr as validateComposition, Ot as buildCapabilityLookup, Rt as compositionSourceRefs, Ta as transformSecretWrite, Ut as coreBlocksCapability, Vt as coreBlockIdFromAddonId, Zt as describeComposableCaps, ei as errMsg, f as COMPOSER_RUNNER_ID, ia as isSecretMarker, lr as resolveCoreBlockEntry, m as CORE_BLOCK_ADDON_PREFIX, oa as isSecretRefOwnedBy, or as replacedFieldKeys, p as CORE_BLOCKS_ADDON_ID, qi as defineRecordKinds, qr as compositionSourceKey, r as ALL_CAPABILITY_DEFINITIONS, ti as BaseAddon, ur as resolveCoreBlockFiles, v as CoreBlockSchema, va as resolveSecretMarkers, xa as secretTreeFromSchema, zt as coreBlockAddonId } from "../../dist-DygMs3Qc.mjs";
1
+ import { $i as hydrateSchema, $n as planComposition, Bt as coreBlockComposition, Hi as collectSecretMarkerRefs, Hr as composedDeviceRef, Ht as coreBlockSourceKind, Kn as normalizeCoreBlockWrite, N as DeclaredDevices, Nr as validateComposition, Ot as buildCapabilityLookup, Rt as compositionSourceRefs, Ta as transformSecretWrite, Ut as coreBlocksCapability, Vt as coreBlockIdFromAddonId, Zt as describeComposableCaps, ei as errMsg, f as COMPOSER_RUNNER_ID, ia as isSecretMarker, lr as resolveCoreBlockEntry, m as CORE_BLOCK_ADDON_PREFIX, oa as isSecretRefOwnedBy, or as replacedFieldKeys, p as CORE_BLOCKS_ADDON_ID, qi as defineRecordKinds, qr as compositionSourceKey, r as ALL_CAPABILITY_DEFINITIONS, ti as BaseAddon, ur as resolveCoreBlockFiles, v as CoreBlockSchema, va as resolveSecretMarkers, xa as secretTreeFromSchema, zt as coreBlockAddonId } from "../../dist-B_V9r61Z.mjs";
2
2
  import { t as require_read_all_rows } from "../../read-all-rows-TaPqdWNF.mjs";
3
- import { t as describeCompositionSources } from "../../composition-sources-CiFkyAcf.mjs";
3
+ import { t as describeCompositionSources } from "../../composition-sources-B5nK7pHt.mjs";
4
4
  import { t as prefixRange } from "../../prefix-range-Dl0znowN.mjs";
5
5
  import { n as unwrapStoredValue, t as loadPrefixed } from "../../prefix-walk-DAOBSyH1.mjs";
6
6
  import { createRequire } from "node:module";
@@ -241,6 +241,13 @@ var BlockSupervisor = class {
241
241
  emptyAppliesOwed = 2;
242
242
  /** Consecutive applies that could not reach the composer: warned once per run. */
243
243
  failedApplies = 0;
244
+ /** Composition ids the operator deleted. Passed until their claims are released. */
245
+ retiredBlockIds = /* @__PURE__ */ new Set();
246
+ /** What the last composition apply said about claim releases. */
247
+ releaseReport = {
248
+ error: null,
249
+ unreleased: []
250
+ };
244
251
  constructor(deps) {
245
252
  this.deps = deps;
246
253
  }
@@ -276,6 +283,26 @@ var BlockSupervisor = class {
276
283
  * timer tick could stop a runner the tick had just decided was healthy and
277
284
  * then never re-launch it.
278
285
  */
286
+ /**
287
+ * The block row is already gone. The next apply names it retired so its
288
+ * claims are released before this resolves. A release that does not land is
289
+ * returned; the id stays retired so the following pass tries again.
290
+ */
291
+ retireComposition(blockId) {
292
+ this.retiredBlockIds = new Set([...this.retiredBlockIds, blockId]);
293
+ return this.converge().then(() => this.claimsOf(blockId));
294
+ }
295
+ /**
296
+ * One apply, awaited. Used when an edit replaced a block's caps: the
297
+ * composer releases what the new plan dropped before this resolves.
298
+ */
299
+ convergeForClaims() {
300
+ if (this.deps.composer === null) return Promise.reject(/* @__PURE__ */ new Error("core-blocks: no composer is available — a replaced claim cannot be released"));
301
+ return this.converge().then(() => {
302
+ if (this.releaseReport.error !== null) throw new Error(`core-blocks: a replaced claim was not released — ${this.releaseReport.error}`);
303
+ return this.releaseReport.unreleased;
304
+ });
305
+ }
279
306
  restart(blockId) {
280
307
  const block = this.deps.store.get(blockId);
281
308
  if (block !== null && coreBlockSourceKind(block) === "composition") {
@@ -364,9 +391,13 @@ var BlockSupervisor = class {
364
391
  });
365
392
  const unreadable = this.deps.store.unreadableCompositions();
366
393
  const nothingToSay = compositions.length === 0 && unreadable.length === 0;
367
- if (nothingToSay && this.emptyAppliesOwed === 0) return;
394
+ if (nothingToSay && this.emptyAppliesOwed === 0 && this.retiredBlockIds.size === 0) return;
368
395
  const composer = this.deps.composer;
369
396
  if (composer === null) {
397
+ if (this.retiredBlockIds.size > 0) this.releaseReport = {
398
+ error: "no composer is available on this node — claims cannot be released",
399
+ unreleased: []
400
+ };
370
401
  for (const { block } of compositions) await this.report(block.id, "failed", "no composer is available on this node — a composition cannot run here");
371
402
  return;
372
403
  }
@@ -389,7 +420,8 @@ var BlockSupervisor = class {
389
420
  composition
390
421
  })),
391
422
  restartBlockIds: [...restart],
392
- unreadableBlocks: [...unreadable]
423
+ unreadableBlocks: [...unreadable],
424
+ retiredBlockIds: [...this.retiredBlockIds]
393
425
  });
394
426
  if (this.failedApplies > 0) {
395
427
  this.deps.logger.info("the composer answered again", { meta: { failedApplies: this.failedApplies } });
@@ -397,6 +429,7 @@ var BlockSupervisor = class {
397
429
  }
398
430
  this.pendingCompositionRestarts = new Set([...this.pendingCompositionRestarts].filter((id) => !restart.has(id)));
399
431
  this.emptyAppliesOwed = !nothingToSay || !result.acted ? 2 : Math.max(0, this.emptyAppliesOwed - 1);
432
+ this.noteRelease(result);
400
433
  const verdicts = new Map(result.blocks.map((v) => [v.blockId, v]));
401
434
  for (const { block } of compositions) {
402
435
  const verdict = verdicts.get(block.id);
@@ -404,13 +437,39 @@ var BlockSupervisor = class {
404
437
  else await this.report(block.id, verdict.status, verdict.reason);
405
438
  }
406
439
  } catch (err) {
440
+ const error = errMsg(err);
441
+ this.releaseReport = {
442
+ error,
443
+ unreleased: []
444
+ };
407
445
  this.failedApplies += 1;
408
446
  if (this.failedApplies === 1) this.deps.logger.warn("the composer could not be reached — compositions keep their last status", { meta: {
409
- error: errMsg(err),
447
+ error,
410
448
  compositions: compositions.length
411
449
  } });
412
- for (const { block } of compositions) if (block.status === "stopped" && block.enabled) await this.report(block.id, "starting", `the composer is not reachable yet: ${errMsg(err)}`);
450
+ for (const { block } of compositions) if (block.status === "stopped" && block.enabled) await this.report(block.id, "starting", `the composer is not reachable yet: ${error}`);
451
+ }
452
+ }
453
+ claimsOf(blockId) {
454
+ if (this.releaseReport.error !== null) throw new Error(`core-blocks: claims of "${blockId}" were not released — ${this.releaseReport.error}`);
455
+ return this.releaseReport.unreleased.filter((claim) => claim.owner === blockId);
456
+ }
457
+ /** Remember which retired ids still hold a claim. An apply that did not act keeps every id. */
458
+ noteRelease(result) {
459
+ const unreleased = result.unreleasedClaims ?? [];
460
+ if (!result.acted) {
461
+ this.releaseReport = {
462
+ error: "the composer did not apply — claims stay until it does",
463
+ unreleased
464
+ };
465
+ return;
413
466
  }
467
+ this.releaseReport = {
468
+ error: null,
469
+ unreleased
470
+ };
471
+ const failed = new Set(unreleased.map((claim) => claim.owner));
472
+ this.retiredBlockIds = new Set([...this.retiredBlockIds].filter((id) => failed.has(id)));
414
473
  }
415
474
  /** Compile, write the package, spawn. Each failure is reported ON the block
416
475
  * — the author asked for this to run, so they are owed the reason it does
@@ -2077,7 +2136,21 @@ function buildCompositionApi(deps) {
2077
2136
  blockId,
2078
2137
  by: caller.userId
2079
2138
  } });
2080
- deps.convergeSoon();
2139
+ if (block.composition !== void 0) {
2140
+ const unreleased = (await deps.convergeForClaims()).filter((claim) => claim.owner === blockId);
2141
+ if (unreleased.length > 0) {
2142
+ for (const claim of unreleased) deps.logger.error("composition saved but a replaced claim was not released", {
2143
+ tags: { deviceId: claim.deviceId },
2144
+ meta: {
2145
+ blockId,
2146
+ cap: claim.capName,
2147
+ error: claim.error
2148
+ }
2149
+ });
2150
+ const detail = unreleased.map((claim) => `${claim.capName} on device ${claim.deviceId}: ${claim.error}`).join("; ");
2151
+ throw new Error(`core-blocks: "${blockId}" was saved but a replaced claim was not released — ${detail}`);
2152
+ }
2153
+ } else deps.convergeSoon();
2081
2154
  return { block: updated };
2082
2155
  }),
2083
2156
  getComposition: async ({ blockId }) => {
@@ -2453,9 +2526,30 @@ var CoreBlocksAddon = class extends BaseAddon {
2453
2526
  return { block: updated };
2454
2527
  },
2455
2528
  delete: async ({ blockId }) => {
2529
+ const existing = this.requireStore().get(blockId);
2530
+ const composition = existing !== null && coreBlockComposition(existing) !== null;
2456
2531
  await this.requireStore().delete(blockId);
2457
2532
  await this.requirePrefs().delete(blockId);
2458
- this.convergeSoon();
2533
+ if (composition && this.supervisor === null) {
2534
+ this.ctx.logger.error("composition deleted but no supervisor can release its claims", { meta: { blockId } });
2535
+ throw new Error(`core-blocks: "${blockId}" was deleted but no supervisor runs here — its claims were not released`);
2536
+ }
2537
+ if (composition && this.supervisor !== null) {
2538
+ const unreleased = await this.supervisor.retireComposition(blockId);
2539
+ if (unreleased.length > 0) {
2540
+ for (const claim of unreleased) this.ctx.logger.error("composition deleted but its claim was not released", {
2541
+ tags: { deviceId: claim.deviceId },
2542
+ meta: {
2543
+ blockId,
2544
+ cap: claim.capName,
2545
+ owner: claim.owner,
2546
+ error: claim.error
2547
+ }
2548
+ });
2549
+ const detail = unreleased.map((claim) => `${claim.capName} on device ${claim.deviceId}: ${claim.error}`).join("; ");
2550
+ throw new Error(`core-blocks: "${blockId}" was deleted but its claims were not released — ${detail}`);
2551
+ }
2552
+ } else this.convergeSoon();
2459
2553
  return { success: true };
2460
2554
  },
2461
2555
  setEnabled: async ({ blockId, enabled }) => {
@@ -2464,9 +2558,9 @@ var CoreBlocksAddon = class extends BaseAddon {
2464
2558
  return { block: updated };
2465
2559
  },
2466
2560
  /**
2467
- * Awaited, unlike every other write here.
2561
+ * Awaited, like a composition delete.
2468
2562
  *
2469
- * `create`/`update` deliberately do not wait — the write is already
2563
+ * `create`/`update` of a code block deliberately do not wait — the write is already
2470
2564
  * durable and converging forks a process. A restart has no durable half:
2471
2565
  * the whole thing IS the converge, so returning before it ran would hand
2472
2566
  * the operator the old status and read as "nothing happened".
@@ -2547,6 +2641,10 @@ var CoreBlocksAddon = class extends BaseAddon {
2547
2641
  lookupCap: buildCapabilityLookup(ALL_CAPABILITY_DEFINITIONS),
2548
2642
  composerStates: async (blockIds) => (await requireApi().composer.getStates.query({ blockIds: [...blockIds] })).states,
2549
2643
  convergeSoon: () => this.convergeSoon(),
2644
+ convergeForClaims: () => {
2645
+ if (this.supervisor === null) return Promise.reject(/* @__PURE__ */ new Error("core-blocks: no block supervisor runs on this node — claims cannot be released"));
2646
+ return this.supervisor.convergeForClaims();
2647
+ },
2550
2648
  logger: this.ctx.logger.child("compositions"),
2551
2649
  capabilityDefinitions: ALL_CAPABILITY_DEFINITIONS
2552
2650
  });