@camstack/server 1.2.786 → 1.2.788

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 (104) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/dist/api/core/cap-providers.js +62 -96
  3. package/dist/api/trpc/generated-cap-mounts.js +1 -10
  4. package/dist/api/trpc/generated-cap-routers.js +2289 -2366
  5. package/dist/core/addon/addon-registry.service.js +29 -28
  6. package/dist/core/addon/boot-health-snapshot.js +42 -0
  7. package/dist/core/addon/hub-spawn-gate.js +1 -0
  8. package/dist/core/addon/instances-of-cap.js +35 -0
  9. package/package.json +64 -46
  10. package/system/dist/addon-utils.mjs +1 -1
  11. package/system/dist/{agent-https-snFEmSqQ.js → agent-https-jJDe-XNl.js} +1 -1
  12. package/system/dist/{agent-https-D779EYj3.mjs → agent-https-szf2FU49.mjs} +1 -1
  13. package/system/dist/builtins/addon-pages-aggregator/addon-pages-aggregator.addon.js +1 -1
  14. package/system/dist/builtins/addon-pages-aggregator/addon-pages-aggregator.addon.mjs +4 -4
  15. package/system/dist/builtins/addon-widgets-aggregator/addon-widgets-aggregator.addon.js +1 -1
  16. package/system/dist/builtins/addon-widgets-aggregator/addon-widgets-aggregator.addon.mjs +5 -5
  17. package/system/dist/builtins/alerts/alerts.addon.js +1 -1
  18. package/system/dist/builtins/alerts/alerts.addon.mjs +3 -3
  19. package/system/dist/builtins/autotrack/index.js +1 -1
  20. package/system/dist/builtins/autotrack/index.mjs +1 -1
  21. package/system/dist/builtins/backup-orchestrator/backup-orchestrator.addon.js +2 -2
  22. package/system/dist/builtins/backup-orchestrator/backup-orchestrator.addon.mjs +5 -5
  23. package/system/dist/builtins/calendars/calendars.addon.js +1 -1
  24. package/system/dist/builtins/calendars/calendars.addon.mjs +1 -1
  25. package/system/dist/builtins/camera-grid/index.js +1 -1
  26. package/system/dist/builtins/camera-grid/index.mjs +1 -1
  27. package/system/dist/builtins/composer/composer.addon.js +3 -3
  28. package/system/dist/builtins/composer/composer.addon.mjs +3 -3
  29. package/system/dist/builtins/console-logging/index.js +1 -1
  30. package/system/dist/builtins/console-logging/index.mjs +1 -1
  31. package/system/dist/builtins/core-blocks/core-blocks.addon.js +3 -3
  32. package/system/dist/builtins/core-blocks/core-blocks.addon.mjs +3 -3
  33. package/system/dist/builtins/device-history/device-history.addon.js +2 -2
  34. package/system/dist/builtins/device-history/device-history.addon.mjs +2 -2
  35. package/system/dist/builtins/device-manager/device-manager.addon.js +1 -1
  36. package/system/dist/builtins/device-manager/device-manager.addon.mjs +1 -1
  37. package/system/dist/builtins/hub-forwarder/index.js +1 -1
  38. package/system/dist/builtins/hub-forwarder/index.mjs +1 -1
  39. package/system/dist/builtins/keychain/index.js +4 -4
  40. package/system/dist/builtins/keychain/index.mjs +4 -4
  41. package/system/dist/builtins/liveness-monitor/liveness-monitor.addon.js +1 -1
  42. package/system/dist/builtins/liveness-monitor/liveness-monitor.addon.mjs +1 -1
  43. package/system/dist/builtins/local-auth/local-auth.addon.js +2 -2
  44. package/system/dist/builtins/local-auth/local-auth.addon.mjs +5 -5
  45. package/system/dist/builtins/local-network/local-network.addon.js +2 -2
  46. package/system/dist/builtins/local-network/local-network.addon.mjs +2 -2
  47. package/system/dist/builtins/loki-logging/index.js +1 -1
  48. package/system/dist/builtins/loki-logging/index.mjs +1 -1
  49. package/system/dist/builtins/native-metrics/native-metrics.addon.js +1 -1
  50. package/system/dist/builtins/native-metrics/native-metrics.addon.mjs +10 -10
  51. package/system/dist/builtins/platform-probe/index.js +1 -1
  52. package/system/dist/builtins/platform-probe/index.mjs +10 -10
  53. package/system/dist/builtins/record-entries/index.js +1 -1
  54. package/system/dist/builtins/record-entries/index.mjs +1 -1
  55. package/system/dist/builtins/remote-access-orchestrator/remote-access-orchestrator.addon.js +1 -1
  56. package/system/dist/builtins/remote-access-orchestrator/remote-access-orchestrator.addon.mjs +1 -1
  57. package/system/dist/builtins/snapshot/index.js +1 -1
  58. package/system/dist/builtins/snapshot/index.mjs +1 -1
  59. package/system/dist/builtins/sqlite-storage/filesystem-storage.addon.js +1 -1
  60. package/system/dist/builtins/sqlite-storage/filesystem-storage.addon.mjs +20 -20
  61. package/system/dist/builtins/sqlite-storage/index.js +1 -1
  62. package/system/dist/builtins/sqlite-storage/index.mjs +1 -1
  63. package/system/dist/builtins/sqlite-storage/integration-record-kinds.d.ts +0 -1
  64. package/system/dist/builtins/sqlite-storage/integration-registry.d.ts +2 -4
  65. package/system/dist/builtins/sqlite-storage/migrations/migration-types.d.ts +6 -1
  66. package/system/dist/builtins/sqlite-storage/sqlite-settings.addon.js +7 -4
  67. package/system/dist/builtins/sqlite-storage/sqlite-settings.addon.mjs +7 -4
  68. package/system/dist/builtins/storage-orchestrator/drain-state-store.d.ts +4 -8
  69. package/system/dist/builtins/storage-orchestrator/location-store.d.ts +9 -26
  70. package/system/dist/builtins/storage-orchestrator/record-kinds.d.ts +0 -1
  71. package/system/dist/builtins/storage-orchestrator/storage-orchestrator.addon.js +35 -407
  72. package/system/dist/builtins/storage-orchestrator/storage-orchestrator.addon.mjs +36 -407
  73. package/system/dist/builtins/system-config/system-config.addon.js +3 -3
  74. package/system/dist/builtins/system-config/system-config.addon.mjs +115 -115
  75. package/system/dist/builtins/winston-logging/index.js +1 -1
  76. package/system/dist/builtins/winston-logging/index.mjs +1 -1
  77. package/system/dist/{capture-engine-DkTEWrRe.mjs → capture-engine-BsKY_3xa.mjs} +1 -1
  78. package/system/dist/{capture-engine-NZ11ORZS.js → capture-engine-DNHgjQot.js} +1 -1
  79. package/system/dist/{composition-sources-B9-lkIvO.mjs → composition-sources-BRdGsbVT.mjs} +1 -1
  80. package/system/dist/{composition-sources-B6GYTy_7.js → composition-sources-BgO0GQYW.js} +1 -1
  81. package/system/dist/{constants-DR8hdi45.js → constants-C3jGKQSQ.js} +1 -1
  82. package/system/dist/{constants--9ui1LK0.mjs → constants-CQeMrR4f.mjs} +1 -1
  83. package/system/dist/{coral-accelerators-DBlgWB8k.mjs → coral-accelerators-BW3OcrLD.mjs} +6 -6
  84. package/system/dist/{custom-action-registry-B9zFBNVa.mjs → custom-action-registry-N7flBDwT.mjs} +37 -37
  85. package/system/dist/{device-ca-D-7tAHJ_.mjs → device-ca-ByVi5eUC.mjs} +1 -1
  86. package/system/dist/{device-ca-sIFmKkGM.js → device-ca-D3y6wGmn.js} +1 -1
  87. package/system/dist/{dist-h3Yla8gE.js → dist-BRI-Mwx0.js} +824 -957
  88. package/system/dist/{dist-D-iGSnX_.mjs → dist-BsQA6-0i.mjs} +824 -957
  89. package/system/dist/file-host-worker.js +1 -1
  90. package/system/dist/file-host-worker.mjs +1 -1
  91. package/system/dist/{hub-mdns-ciao-DuEfM0fI.mjs → hub-mdns-ciao-8dJTW2LI.mjs} +2 -2
  92. package/system/dist/{hub-mdns-ciao-C5DkUEZF.js → hub-mdns-ciao-Ry_Jpljx.js} +2 -2
  93. package/system/dist/index.d.ts +2 -2
  94. package/system/dist/index.js +85 -223
  95. package/system/dist/index.mjs +298 -434
  96. package/system/dist/kernel/addon-health-monitor.d.ts +21 -0
  97. package/system/dist/{legacy-integration-rows-door-BTdhD-Yp.mjs → legacy-integration-rows-door-CjXTbmvH.mjs} +1 -1
  98. package/system/dist/{legacy-integration-rows-door-DTDD5wwC.js → legacy-integration-rows-door-D5BdSNla.js} +1 -1
  99. package/system/dist/migrations/hub/2026-11-06-drop-legacy-integrations-and-storage-locations.d.ts +12 -0
  100. package/system/dist/{restore-archive-DQWz5Wp-.mjs → restore-archive-Co2lk3OU.mjs} +94 -94
  101. package/system/dist/{restore-archive-CkAD_-E9.js → restore-archive-GoWJMdHy.js} +1 -1
  102. package/system/dist/{wal-maintenance-CB-O-GPP.js → wal-maintenance-C1Haue74.js} +0 -0
  103. package/system/dist/{wal-maintenance-DouX1XsY.mjs → wal-maintenance-DRnV6QYu.mjs} +0 -0
  104. package/system/package.json +1 -1
@@ -1,5 +1,5 @@
1
1
  require("./chunk-Cek0wNdY.js");
2
- const require_wal_maintenance = require("./wal-maintenance-CB-O-GPP.js");
2
+ const require_wal_maintenance = require("./wal-maintenance-C1Haue74.js");
3
3
  let node_worker_threads = require("node:worker_threads");
4
4
  //#region src/builtins/sqlite-storage/file-host-worker.ts
5
5
  /**
@@ -1,4 +1,4 @@
1
- import { A as callRecords, C as isFileHostWorkerData, D as RecordsEngine, M as controlTargetOf, O as callControl, S as isFileHostRequest, a as WalMaintenance, b as collectTransferables, d as callMigrate, f as migrateTargetOf, j as callVector, k as callData, l as SqliteSettingsBackend, o as createVectorIndex, s as vectorProviderOf, u as HUB_MIGRATIONS, v as serializeError, w as trustInput } from "./wal-maintenance-DouX1XsY.mjs";
1
+ import { A as callRecords, C as isFileHostWorkerData, D as RecordsEngine, M as controlTargetOf, O as callControl, S as isFileHostRequest, a as WalMaintenance, b as collectTransferables, d as callMigrate, f as migrateTargetOf, j as callVector, k as callData, l as SqliteSettingsBackend, o as createVectorIndex, s as vectorProviderOf, u as HUB_MIGRATIONS, v as serializeError, w as trustInput } from "./wal-maintenance-DRnV6QYu.mjs";
2
2
  import { parentPort, threadId, workerData } from "node:worker_threads";
3
3
  //#region src/builtins/sqlite-storage/file-host-worker.ts
4
4
  /**
@@ -1,7 +1,7 @@
1
1
  import { o as __toESM } from "./chunk-CNf5ZN-e.mjs";
2
- import { bc as userError } from "./dist-D-iGSnX_.mjs";
2
+ import { bc as userError } from "./dist-BsQA6-0i.mjs";
3
3
  import { f as X509Certificate$1 } from "./x509.es-BRiJgOvu.mjs";
4
- import { D as reasonRequiresNewCa, E as evaluateExistingCert, F as readNameConstraints, N as permitsIdentity, _ as issueLeaf, b as collectCertIdentity, g as generateCa, j as isConstrainedCa, v as loadCa, y as localCaCommonName } from "./agent-https-D779EYj3.mjs";
4
+ import { D as reasonRequiresNewCa, E as evaluateExistingCert, F as readNameConstraints, N as permitsIdentity, _ as issueLeaf, b as collectCertIdentity, g as generateCa, j as isConstrainedCa, v as loadCa, y as localCaCommonName } from "./agent-https-szf2FU49.mjs";
5
5
  import { X509Certificate, createPrivateKey } from "node:crypto";
6
6
  import { writeOwnerOnlyFileSync } from "@camstack/types/node";
7
7
  import { copyFileSync, existsSync, mkdirSync, readFileSync, renameSync, rmSync, writeFileSync } from "node:fs";
@@ -1,7 +1,7 @@
1
1
  const require_chunk = require("./chunk-Cek0wNdY.js");
2
- const require_dist = require("./dist-h3Yla8gE.js");
2
+ const require_dist = require("./dist-BRI-Mwx0.js");
3
3
  const require_x509_es = require("./x509.es-WtnRNyYS.js");
4
- const require_agent_https = require("./agent-https-snFEmSqQ.js");
4
+ const require_agent_https = require("./agent-https-jJDe-XNl.js");
5
5
  let node_crypto = require("node:crypto");
6
6
  let _camstack_types_node = require("@camstack/types/node");
7
7
  let node_fs = require("node:fs");
@@ -136,10 +136,10 @@ export type { HubMdnsAnnouncement, HubMdnsHandle, HubMdnsPublisher } from "./bui
136
136
  export { IntegrationRegistry } from "./builtins/sqlite-storage/integration-registry.js";
137
137
  export { clearIntegrationRows } from "./builtins/sqlite-storage/integration-rows-ports.js";
138
138
  export type { IntegrationRecordStores } from "./builtins/sqlite-storage/integration-registry.js";
139
- export { integrationRegistryRecordKinds, INTEGRATIONS_LEGACY } from "./builtins/sqlite-storage/integration-record-kinds.js";
139
+ export { integrationRegistryRecordKinds } from "./builtins/sqlite-storage/integration-record-kinds.js";
140
140
  export { clusterAgentRecordKinds, clusterNodeHistoryRecordKind, clusterNodeTombstoneRecordKind, ClusterNodeHistoryBodySchema, ClusterNodeTombstoneBodySchema } from "./builtins/cluster-agent/record-kinds.js";
141
141
  export type { ClusterNodeHistoryBody, ClusterNodeTombstoneBody } from "./builtins/cluster-agent/record-kinds.js";
142
- export { storageOrchestratorRecordKinds, STORAGE_DRAIN_STATE_LEGACY } from "./builtins/storage-orchestrator/record-kinds.js";
142
+ export { storageOrchestratorRecordKinds } from "./builtins/storage-orchestrator/record-kinds.js";
143
143
  export { backupOrchestratorRecordKinds, backupRecordStoresOf, type BackupRecordStores } from "./builtins/backup-orchestrator/record-kinds.js";
144
144
  export { readAllRows } from "./records/read-all-rows.js";
145
145
  export { clearNodeSettings } from "./kernel/addon-settings-store.js";
@@ -1,7 +1,7 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
2
  const require_chunk = require("./chunk-Cek0wNdY.js");
3
- const require_dist = require("./dist-h3Yla8gE.js");
4
- const require_device_ca = require("./device-ca-sIFmKkGM.js");
3
+ const require_dist = require("./dist-BRI-Mwx0.js");
4
+ const require_device_ca = require("./device-ca-D3y6wGmn.js");
5
5
  const require_read_all_rows$1 = require("./read-all-rows-CVoO1ONM.js");
6
6
  const require_builtins_alerts_alerts_addon = require("./builtins/alerts/alerts.addon.js");
7
7
  require("./builtins/alerts/index.js");
@@ -26,22 +26,22 @@ const require_builtins_loki_logging_index = require("./builtins/loki-logging/ind
26
26
  const require_builtins_native_metrics_native_metrics_addon = require("./builtins/native-metrics/native-metrics.addon.js");
27
27
  const require_builtins_device_history_device_history_addon = require("./builtins/device-history/device-history.addon.js");
28
28
  const require_builtins_sqlite_storage_filesystem_storage_addon = require("./builtins/sqlite-storage/filesystem-storage.addon.js");
29
- const require_wal_maintenance = require("./wal-maintenance-CB-O-GPP.js");
30
- const require_legacy_integration_rows_door = require("./legacy-integration-rows-door-DTDD5wwC.js");
29
+ const require_wal_maintenance = require("./wal-maintenance-C1Haue74.js");
30
+ const require_legacy_integration_rows_door = require("./legacy-integration-rows-door-D5BdSNla.js");
31
31
  const require_builtins_sqlite_storage_sqlite_settings_addon = require("./builtins/sqlite-storage/sqlite-settings.addon.js");
32
32
  const require_builtins_sqlite_storage_index = require("./builtins/sqlite-storage/index.js");
33
33
  const require_builtins_storage_orchestrator_storage_orchestrator_addon = require("./builtins/storage-orchestrator/storage-orchestrator.addon.js");
34
34
  require("./builtins/storage-orchestrator/index.js");
35
- const require_agent_https = require("./agent-https-snFEmSqQ.js");
36
- const require_constants = require("./constants-DR8hdi45.js");
35
+ const require_agent_https = require("./agent-https-jJDe-XNl.js");
36
+ const require_constants = require("./constants-C3jGKQSQ.js");
37
37
  const require_builtins_system_config_system_config_addon = require("./builtins/system-config/system-config.addon.js");
38
38
  require("./builtins/system-config/index.js");
39
39
  const require_builtins_winston_logging_index = require("./builtins/winston-logging/index.js");
40
40
  const require_custom_action_registry = require("./custom-action-registry-CmWpSeMS.js");
41
- const require_hub_mdns_ciao = require("./hub-mdns-ciao-C5DkUEZF.js");
41
+ const require_hub_mdns_ciao = require("./hub-mdns-ciao-Ry_Jpljx.js");
42
42
  const require_platform_key_source = require("./platform-key-source-Di7HrlGR.js");
43
43
  const require_resource_monitor = require("./resource-monitor-mio9dSCT.js");
44
- const require_restore_archive = require("./restore-archive-CkAD_-E9.js");
44
+ const require_restore_archive = require("./restore-archive-GoWJMdHy.js");
45
45
  const require_coral_accelerators = require("./coral-accelerators-BSVsBVzt.js");
46
46
  let zod = require("zod");
47
47
  let node_crypto = require("node:crypto");
@@ -5579,13 +5579,6 @@ var AgentMdnsAdvertiser = class {
5579
5579
  //#endregion
5580
5580
  //#region src/builtins/sqlite-storage/integration-record-kinds.ts
5581
5581
  var import_read_all_rows = require_read_all_rows$1.require_read_all_rows();
5582
- /**
5583
- * Record kinds owned by integration-registry (phase 4).
5584
- *
5585
- * An integration's configuration is the addon's own instance record. This owner
5586
- * keeps only the registry row (id, addon, name, enabled, info).
5587
- */
5588
- var INTEGRATIONS_LEGACY = "integrations";
5589
5582
  var IntegrationBodySchema = zod.z.object({
5590
5583
  addonId: zod.z.string(),
5591
5584
  name: zod.z.string(),
@@ -5631,62 +5624,6 @@ var integrationCounter = 0;
5631
5624
  function nextIntegrationId() {
5632
5625
  return `int_${String(++integrationCounter).padStart(4, "0")}`;
5633
5626
  }
5634
- var INTEGRATIONS_COLUMNS = [
5635
- {
5636
- name: "id",
5637
- type: "TEXT",
5638
- primaryKey: true
5639
- },
5640
- {
5641
- name: "addon_id",
5642
- type: "TEXT",
5643
- notNull: true
5644
- },
5645
- {
5646
- name: "name",
5647
- type: "TEXT",
5648
- notNull: true
5649
- },
5650
- {
5651
- name: "enabled",
5652
- type: "INTEGER",
5653
- notNull: true,
5654
- defaultValue: 1
5655
- },
5656
- {
5657
- name: "info",
5658
- type: "JSON",
5659
- notNull: true,
5660
- defaultValue: "{}"
5661
- },
5662
- {
5663
- name: "origin_stable_id",
5664
- type: "TEXT"
5665
- },
5666
- {
5667
- name: "created_at",
5668
- type: "INTEGER",
5669
- notNull: true
5670
- },
5671
- {
5672
- name: "updated_at",
5673
- type: "INTEGER",
5674
- notNull: true
5675
- }
5676
- ];
5677
- var INTEGRATIONS_INDEXES = [{
5678
- name: "idx_integrations_addon",
5679
- columns: ["addon_id"]
5680
- }];
5681
- /**
5682
- * @durable class=config owner=integration-registry
5683
- * write="`createIntegration` — an operator adds a provider, or an addon declares
5684
- * a FIXED one (`info.fixed`); `updateIntegration` rewrites name/enabled/info"
5685
- * retention="`deleteIntegration` only, and a fixed integration refuses to be
5686
- * deleted. Nothing ages out. The `int_NNNN` counter resumes from the highest
5687
- * surviving row at boot, so wiping the table restarts numbering."
5688
- */
5689
- var INTEGRATIONS = INTEGRATIONS_LEGACY;
5690
5627
  /**
5691
5628
  * The persisted INTEGRATIONS — one row per provider instance an operator (or a
5692
5629
  * declaring addon) added. The instance's configuration lives on the addon's own
@@ -5715,47 +5652,22 @@ function mapIntegrationBody(id, body) {
5715
5652
  };
5716
5653
  }
5717
5654
  var IntegrationRegistry = class IntegrationRegistry {
5718
- store;
5719
5655
  recordStores;
5720
- constructor(backend, recordStores) {
5721
- this.store = backend;
5656
+ constructor(recordStores) {
5722
5657
  this.recordStores = recordStores;
5723
5658
  }
5724
5659
  static recordStoresOf(records) {
5725
5660
  return { integrations: records.kind(integrationRegistryRecordKinds.integrations) };
5726
5661
  }
5727
5662
  async initialize() {
5728
- if (this.recordStores === void 0) await this.store.declareCollection({
5729
- collection: INTEGRATIONS,
5730
- columns: INTEGRATIONS_COLUMNS,
5731
- indexes: INTEGRATIONS_INDEXES
5732
- });
5733
5663
  await this.resumeCounter();
5734
5664
  }
5735
5665
  async resumeCounter() {
5736
- const kind = this.recordStores?.integrations;
5737
- if (kind !== void 0) {
5738
- const rows = await (0, import_read_all_rows.readAllRows)(kind, { order: "id" });
5739
- rows.sort((a, b) => b.id.localeCompare(a.id));
5740
- const top = rows[0];
5741
- if (top !== void 0) {
5742
- const num = parseInt(top.id.replace("int_", ""), 10);
5743
- if (!isNaN(num)) integrationCounter = num;
5744
- }
5745
- return;
5746
- }
5747
- const ints = await this.store.query({
5748
- collection: INTEGRATIONS,
5749
- filter: {
5750
- orderBy: {
5751
- field: "id",
5752
- direction: "desc"
5753
- },
5754
- limit: 1
5755
- }
5756
- });
5757
- if (ints[0]) {
5758
- const num = parseInt(ints[0].id.replace("int_", ""), 10);
5666
+ const rows = await (0, import_read_all_rows.readAllRows)(this.recordStores.integrations, { order: "id" });
5667
+ rows.sort((a, b) => b.id.localeCompare(a.id));
5668
+ const top = rows[0];
5669
+ if (top !== void 0) {
5670
+ const num = parseInt(top.id.replace("int_", ""), 10);
5759
5671
  if (!isNaN(num)) integrationCounter = num;
5760
5672
  }
5761
5673
  }
@@ -5777,115 +5689,45 @@ var IntegrationRegistry = class IntegrationRegistry {
5777
5689
  createdAt: now,
5778
5690
  updatedAt: now
5779
5691
  };
5780
- const kind = this.recordStores?.integrations;
5781
- if (kind !== void 0) await kind.put({
5692
+ await this.recordStores.integrations.put({
5782
5693
  id,
5783
5694
  data: body
5784
5695
  });
5785
- else await this.store.insert({
5786
- collection: INTEGRATIONS,
5787
- record: {
5788
- id,
5789
- data: {
5790
- addon_id: input.addonId,
5791
- name: input.name,
5792
- enabled: enabled ? 1 : 0,
5793
- info,
5794
- origin_stable_id: input.originStableId ?? null,
5795
- created_at: now,
5796
- updated_at: now
5797
- }
5798
- }
5799
- });
5800
- return {
5801
- id,
5802
- addonId: input.addonId,
5803
- name: input.name,
5804
- enabled,
5805
- info,
5806
- ...input.originStableId !== void 0 ? { originStableId: input.originStableId } : {},
5807
- createdAt: now,
5808
- updatedAt: now
5809
- };
5696
+ return mapIntegrationBody(id, body);
5810
5697
  }
5811
5698
  async getIntegration(id) {
5812
- const kind = this.recordStores?.integrations;
5813
- if (kind !== void 0) {
5814
- const row = await kind.get(id);
5815
- return row === null ? null : mapIntegrationBody(row.id, row.data);
5816
- }
5817
- const rows = await this.store.query({
5818
- collection: INTEGRATIONS,
5819
- filter: {
5820
- where: { id },
5821
- limit: 1
5822
- }
5823
- });
5824
- return rows[0] ? this.mapIntegration(rows[0].data) : null;
5699
+ const row = await this.recordStores.integrations.get(id);
5700
+ return row === null ? null : mapIntegrationBody(row.id, row.data);
5825
5701
  }
5826
5702
  async getIntegrationByAddonId(rawAddonId) {
5827
5703
  const addonId = require_dist.bareAddonId(rawAddonId);
5828
- const kind = this.recordStores?.integrations;
5829
- if (kind !== void 0) {
5830
- const row = (await kind.query({
5831
- where: { addonId },
5832
- limit: 1
5833
- })).records[0];
5834
- return row === void 0 ? null : mapIntegrationBody(row.id, row.data);
5835
- }
5836
- const rows = await this.store.query({
5837
- collection: INTEGRATIONS,
5838
- filter: {
5839
- where: { addon_id: addonId },
5840
- limit: 1
5841
- }
5842
- });
5843
- return rows[0] ? this.mapIntegration(rows[0].data) : null;
5704
+ const row = (await this.recordStores.integrations.query({
5705
+ where: { addonId },
5706
+ limit: 1
5707
+ })).records[0];
5708
+ return row === void 0 ? null : mapIntegrationBody(row.id, row.data);
5844
5709
  }
5845
5710
  async listIntegrations() {
5846
- const kind = this.recordStores?.integrations;
5847
- if (kind !== void 0) {
5848
- const rows = await (0, import_read_all_rows.readAllRows)(kind);
5849
- rows.sort((a, b) => a.data.createdAt - b.data.createdAt);
5850
- return rows.map((r) => mapIntegrationBody(r.id, r.data));
5851
- }
5852
- return (await this.store.query({
5853
- collection: INTEGRATIONS,
5854
- filter: { orderBy: {
5855
- field: "created_at",
5856
- direction: "asc"
5857
- } }
5858
- })).map((r) => this.mapIntegration(r.data));
5711
+ const rows = await (0, import_read_all_rows.readAllRows)(this.recordStores.integrations);
5712
+ rows.sort((a, b) => a.data.createdAt - b.data.createdAt);
5713
+ return rows.map((r) => mapIntegrationBody(r.id, r.data));
5859
5714
  }
5860
5715
  async updateIntegration(id, updates) {
5861
5716
  const now = Math.floor(Date.now() / 1e3);
5862
- const kind = this.recordStores?.integrations;
5863
- if (kind !== void 0) {
5864
- const existing = await kind.get(id);
5865
- if (existing === null) return null;
5866
- const next = {
5867
- ...existing.data,
5868
- updatedAt: now,
5869
- ...updates.name !== void 0 ? { name: updates.name } : {},
5870
- ...updates.enabled !== void 0 ? { enabled: updates.enabled } : {},
5871
- ...updates.info !== void 0 ? { info: updates.info } : {}
5872
- };
5873
- await kind.put({
5874
- id,
5875
- data: next
5876
- });
5877
- return mapIntegrationBody(id, next);
5878
- }
5879
- const updateRow = { updated_at: now };
5880
- if (updates.name !== void 0) updateRow["name"] = updates.name;
5881
- if (updates.enabled !== void 0) updateRow["enabled"] = updates.enabled ? 1 : 0;
5882
- if (updates.info !== void 0) updateRow["info"] = updates.info;
5883
- await this.store.updateWhere({
5884
- collection: INTEGRATIONS,
5885
- filter: { where: { id } },
5886
- data: updateRow
5717
+ const existing = await this.recordStores.integrations.get(id);
5718
+ if (existing === null) return null;
5719
+ const next = {
5720
+ ...existing.data,
5721
+ updatedAt: now,
5722
+ ...updates.name !== void 0 ? { name: updates.name } : {},
5723
+ ...updates.enabled !== void 0 ? { enabled: updates.enabled } : {},
5724
+ ...updates.info !== void 0 ? { info: updates.info } : {}
5725
+ };
5726
+ await this.recordStores.integrations.put({
5727
+ id,
5728
+ data: next
5887
5729
  });
5888
- return this.getIntegration(id);
5730
+ return mapIntegrationBody(id, next);
5889
5731
  }
5890
5732
  /**
5891
5733
  * A FIXED integration exists because an addon declares it, not because an
@@ -5900,29 +5742,9 @@ var IntegrationRegistry = class IntegrationRegistry {
5900
5742
  async deleteIntegration(id) {
5901
5743
  const integration = await this.getIntegration(id);
5902
5744
  if (integration !== null && IntegrationRegistry.isFixed(integration)) throw new Error(`integration "${id}" is fixed — it belongs to the addon that declared it and cannot be deleted`);
5903
- const integrationsKind = this.recordStores?.integrations;
5904
- if (integrationsKind !== void 0) {
5905
- await integrationsKind.delete(id);
5906
- return true;
5907
- }
5908
- await this.store.deleteWhere({
5909
- collection: INTEGRATIONS,
5910
- filter: { where: { id } }
5911
- });
5745
+ await this.recordStores.integrations.delete(id);
5912
5746
  return true;
5913
5747
  }
5914
- mapIntegration(row) {
5915
- return {
5916
- id: String(row["id"]),
5917
- addonId: String(row["addon_id"]),
5918
- name: String(row["name"]),
5919
- enabled: row["enabled"] === 1,
5920
- info: readInfo(row["info"]),
5921
- ...typeof row["origin_stable_id"] === "string" ? { originStableId: row["origin_stable_id"] } : {},
5922
- createdAt: Number(row["created_at"]),
5923
- updatedAt: Number(row["updated_at"])
5924
- };
5925
- }
5926
5748
  };
5927
5749
  //#endregion
5928
5750
  //#region src/builtins/sqlite-storage/integration-rows-ports.ts
@@ -25736,6 +25558,7 @@ var AddonHealthMonitor = class {
25736
25558
  logger;
25737
25559
  retryFn;
25738
25560
  now;
25561
+ isHeldBack;
25739
25562
  timer = null;
25740
25563
  graceEmittedFor = false;
25741
25564
  constructor(opts) {
@@ -25743,6 +25566,7 @@ var AddonHealthMonitor = class {
25743
25566
  this.logger = opts.logger;
25744
25567
  this.retryFn = opts.retryFn;
25745
25568
  this.now = opts.now ?? (() => Date.now());
25569
+ this.isHeldBack = opts.isHeldBack ?? (() => false);
25746
25570
  this.tickIntervalMs = opts.tickIntervalMs ?? 3e4;
25747
25571
  this.gracePeriodMs = opts.gracePeriodMs ?? 3e5;
25748
25572
  this.retryIntervalsMs = opts.retryIntervalsMs ?? HEALTH_MONITOR_RETRY_INTERVALS_MS;
@@ -25770,7 +25594,8 @@ var AddonHealthMonitor = class {
25770
25594
  lastError: null,
25771
25595
  nextRetryAt: null,
25772
25596
  alertEmitted: false,
25773
- retrying: false
25597
+ retrying: false,
25598
+ heldBack: false
25774
25599
  });
25775
25600
  if (wasAlerting) this.emit(require_dist.EventCategory.AddonLoadRecovered, {
25776
25601
  packageName,
@@ -25785,6 +25610,11 @@ var AddonHealthMonitor = class {
25785
25610
  */
25786
25611
  recordFailure(packageName, err, addonId) {
25787
25612
  const existing = this.state.get(packageName);
25613
+ const id = addonId ?? existing?.addonId;
25614
+ if (id !== void 0 && this.isHeldBack(id)) {
25615
+ this.recordHeldBack(packageName, require_dist.errMsg(err), id);
25616
+ return;
25617
+ }
25788
25618
  const t = this.now();
25789
25619
  const retryCount = (existing?.retryCount ?? 0) + 1;
25790
25620
  const intervalIdx = Math.min(retryCount - 1, this.retryIntervalsMs.length - 1);
@@ -25803,7 +25633,8 @@ var AddonHealthMonitor = class {
25803
25633
  lastError: errPayload,
25804
25634
  nextRetryAt,
25805
25635
  alertEmitted: existing?.alertEmitted ?? false,
25806
- retrying: false
25636
+ retrying: false,
25637
+ heldBack: false
25807
25638
  };
25808
25639
  this.state.set(packageName, next);
25809
25640
  this.logger.warn("Addon load/init failure recorded", { meta: {
@@ -25832,6 +25663,39 @@ var AddonHealthMonitor = class {
25832
25663
  }
25833
25664
  }
25834
25665
  /**
25666
+ * The spawn gate holds this addon back (its package is not yet at the version the
25667
+ * server requires). Not a failure: the same retry backoff is armed, so the addon
25668
+ * is reloaded once its package is current, but no failure is logged as a warning
25669
+ * and no `AddonLoadFailed` / `AddonRetryScheduled` event is emitted. A retry that
25670
+ * finds the gate open records success the normal way.
25671
+ */
25672
+ recordHeldBack(packageName, reason, addonId) {
25673
+ const existing = this.state.get(packageName);
25674
+ const t = this.now();
25675
+ const retryCount = (existing?.retryCount ?? 0) + 1;
25676
+ const nextRetryAt = t + this.retryIntervalsMs[Math.min(retryCount - 1, this.retryIntervalsMs.length - 1)];
25677
+ this.state.set(packageName, {
25678
+ packageName,
25679
+ addonId: addonId ?? existing?.addonId,
25680
+ phase: "failed",
25681
+ retryCount,
25682
+ firstFailureAt: existing?.firstFailureAt ?? t,
25683
+ lastAttemptAt: t,
25684
+ lastError: { message: reason },
25685
+ nextRetryAt,
25686
+ alertEmitted: false,
25687
+ retrying: false,
25688
+ heldBack: true
25689
+ });
25690
+ this.logger.info("Addon held back by the stale gate, retry armed", { meta: {
25691
+ packageName,
25692
+ addonId: addonId ?? existing?.addonId,
25693
+ retryCount,
25694
+ nextRetryAt,
25695
+ reason
25696
+ } });
25697
+ }
25698
+ /**
25835
25699
  * Force an immediate retry attempt for a package, resetting the
25836
25700
  * counter back to 0 (next failure goes to the 60s interval again).
25837
25701
  * Used by the user-facing `addons.retryLoad` tRPC procedure and by
@@ -25908,7 +25772,7 @@ var AddonHealthMonitor = class {
25908
25772
  const t = this.now();
25909
25773
  if (!this.inGracePeriod() && !this.graceEmittedFor) {
25910
25774
  this.graceEmittedFor = true;
25911
- for (const s of this.state.values()) if (s.phase === "failed" && !s.alertEmitted && s.lastError) {
25775
+ for (const s of this.state.values()) if (s.phase === "failed" && !s.heldBack && !s.alertEmitted && s.lastError) {
25912
25776
  s.alertEmitted = true;
25913
25777
  this.emit(require_dist.EventCategory.AddonLoadFailed, {
25914
25778
  packageName: s.packageName,
@@ -28479,7 +28343,6 @@ exports.HubLogForwarder = HubLogForwarder;
28479
28343
  exports.HubNodeRegistry = HubNodeRegistry;
28480
28344
  exports.HubPairing = require_builtins_system_config_system_config_addon.HubPairing;
28481
28345
  exports.INFRA_CAPABILITIES = INFRA_CAPABILITIES;
28482
- exports.INTEGRATIONS_LEGACY = INTEGRATIONS_LEGACY;
28483
28346
  exports.IntegrationRegistry = IntegrationRegistry;
28484
28347
  exports.InvalidCorsOriginError = require_builtins_system_config_system_config_addon.InvalidCorsOriginError;
28485
28348
  exports.JWT_SIGNING_KEY_REF = require_device_ca.JWT_SIGNING_KEY_REF;
@@ -28571,7 +28434,6 @@ exports.SOCKET_PLANE_TOP_N = SOCKET_PLANE_TOP_N;
28571
28434
  exports.SOCKET_QUEUE_TOP_N = SOCKET_QUEUE_TOP_N;
28572
28435
  exports.STALL_REPORT_MS = require_custom_action_registry.STALL_REPORT_MS;
28573
28436
  exports.STALL_TICK_MS = require_custom_action_registry.STALL_TICK_MS;
28574
- exports.STORAGE_DRAIN_STATE_LEGACY = require_builtins_storage_orchestrator_storage_orchestrator_addon.STORAGE_DRAIN_STATE_LEGACY;
28575
28437
  exports.STORE_READABLE_BOOTSTRAP_KEYS = STORE_READABLE_BOOTSTRAP_KEYS;
28576
28438
  exports.SYSTEM_SECRET_OWNER = require_device_ca.SYSTEM_SECRET_OWNER;
28577
28439
  exports.ScopedLogger = ScopedLogger;