@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
@@ -1171,7 +1171,7 @@ var DeviceRole = /* @__PURE__ */ function(DeviceRole) {
1171
1171
  return DeviceRole;
1172
1172
  }({});
1173
1173
  //#endregion
1174
- //#region ../types/dist/sleep-CmjWurK5.mjs
1174
+ //#region ../types/dist/sleep-D7ZKm4nb.mjs
1175
1175
  /**
1176
1176
  * The audio chunk plane's byte format, and the ONE expansion from a coded
1177
1177
  * window to float samples (D455).
@@ -1944,10 +1944,33 @@ function integrationRowsApiOver(api) {
1944
1944
  };
1945
1945
  }
1946
1946
  var PREFIX = "records/";
1947
+ /**
1948
+ * Cross-realm brand. An addon bundles its own copy of this module (D15) while
1949
+ * `ctx.records` is the HOST's door, so an error thrown by the host is an
1950
+ * instance of the host's classes, not of the addon's. The brand plus the code
1951
+ * make `instanceof` answer by identity of the failure, not of the copy.
1952
+ */
1953
+ var RECORDS_ERROR_BRAND = Symbol.for("camstack.records-error");
1954
+ function carriesBrand(value) {
1955
+ return typeof value === "object" && value !== null && Reflect.get(value, RECORDS_ERROR_BRAND) === true;
1956
+ }
1947
1957
  /** The base of every records failure. `detail` is the human part of the message. */
1948
1958
  var RecordsError = class extends Error {
1959
+ /** The code a subclass stands for; the base stands for every code. */
1960
+ static code = void 0;
1961
+ /**
1962
+ * `instanceof` across copies of this module: any branded error is a
1963
+ * `RecordsError`, and is an instance of a subclass only when its code is the
1964
+ * subclass's code. Same-copy answers are unchanged.
1965
+ */
1966
+ static [Symbol.hasInstance](value) {
1967
+ if (Function.prototype[Symbol.hasInstance].call(this, value)) return true;
1968
+ if (!carriesBrand(value)) return false;
1969
+ return this.code === void 0 || value.code === this.code;
1970
+ }
1949
1971
  code;
1950
1972
  detail;
1973
+ [RECORDS_ERROR_BRAND] = true;
1951
1974
  constructor(code, detail) {
1952
1975
  super(`${PREFIX}${code}: ${detail}`);
1953
1976
  this.name = "RecordsError";
@@ -1956,96 +1979,110 @@ var RecordsError = class extends Error {
1956
1979
  }
1957
1980
  };
1958
1981
  /** A write guarded by `ifRev` found another revision (or an existing row for `ifRev: 0`). */
1959
- var RevConflictError = class extends RecordsError {
1982
+ var RevConflictError = class RevConflictError extends RecordsError {
1983
+ static code = "rev-conflict";
1960
1984
  constructor(detail) {
1961
- super("rev-conflict", detail);
1985
+ super(RevConflictError.code, detail);
1962
1986
  this.name = "RevConflictError";
1963
1987
  }
1964
1988
  };
1965
1989
  /** `data` exceeds the kind's `maxDataBytes`. Bytes are never record fields (D613). */
1966
- var RecordTooLargeError = class extends RecordsError {
1990
+ var RecordTooLargeError = class RecordTooLargeError extends RecordsError {
1991
+ static code = "too-large";
1967
1992
  constructor(detail) {
1968
- super("too-large", detail);
1993
+ super(RecordTooLargeError.code, detail);
1969
1994
  this.name = "RecordTooLargeError";
1970
1995
  }
1971
1996
  };
1972
1997
  /** A filter, order or aggregate names a field no declared index serves. */
1973
- var UnindexedFilterError = class extends RecordsError {
1998
+ var UnindexedFilterError = class UnindexedFilterError extends RecordsError {
1999
+ static code = "unindexed-filter";
1974
2000
  constructor(detail) {
1975
- super("unindexed-filter", detail);
2001
+ super(UnindexedFilterError.code, detail);
1976
2002
  this.name = "UnindexedFilterError";
1977
2003
  }
1978
2004
  };
1979
2005
  /** A bulk delete with no predicate at all. */
1980
- var FilterRequiredError = class extends RecordsError {
2006
+ var FilterRequiredError = class FilterRequiredError extends RecordsError {
2007
+ static code = "filter-required";
1981
2008
  constructor(detail) {
1982
- super("filter-required", detail);
2009
+ super(FilterRequiredError.code, detail);
1983
2010
  this.name = "FilterRequiredError";
1984
2011
  }
1985
2012
  };
1986
2013
  /** The caller declared no such kind (another addon's kind is indistinguishable from none). */
1987
- var UnknownRecordKindError = class extends RecordsError {
2014
+ var UnknownRecordKindError = class UnknownRecordKindError extends RecordsError {
2015
+ static code = "unknown-kind";
1988
2016
  constructor(detail) {
1989
- super("unknown-kind", detail);
2017
+ super(UnknownRecordKindError.code, detail);
1990
2018
  this.name = "UnknownRecordKindError";
1991
2019
  }
1992
2020
  };
1993
- var RecordNotFoundError = class extends RecordsError {
2021
+ var RecordNotFoundError = class RecordNotFoundError extends RecordsError {
2022
+ static code = "not-found";
1994
2023
  constructor(detail) {
1995
- super("not-found", detail);
2024
+ super(RecordNotFoundError.code, detail);
1996
2025
  this.name = "RecordNotFoundError";
1997
2026
  }
1998
2027
  };
1999
2028
  /** A unique index refused the write. */
2000
- var RecordUniqueViolationError = class extends RecordsError {
2029
+ var RecordUniqueViolationError = class RecordUniqueViolationError extends RecordsError {
2030
+ static code = "unique-violation";
2001
2031
  constructor(detail) {
2002
- super("unique-violation", detail);
2032
+ super(RecordUniqueViolationError.code, detail);
2003
2033
  this.name = "RecordUniqueViolationError";
2004
2034
  }
2005
2035
  };
2006
2036
  /** A secret field held a plain string where only a keychain marker may be stored. */
2007
- var PlaintextSecretError = class extends RecordsError {
2037
+ var PlaintextSecretError = class PlaintextSecretError extends RecordsError {
2038
+ static code = "plaintext-secret";
2008
2039
  constructor(detail) {
2009
- super("plaintext-secret", detail);
2040
+ super(PlaintextSecretError.code, detail);
2010
2041
  this.name = "PlaintextSecretError";
2011
2042
  }
2012
2043
  };
2013
2044
  /** A marker whose ref is not the row's own (the D878 rule). */
2014
- var ForeignSecretMarkerError = class extends RecordsError {
2045
+ var ForeignSecretMarkerError = class ForeignSecretMarkerError extends RecordsError {
2046
+ static code = "foreign-marker";
2015
2047
  constructor(detail) {
2016
- super("foreign-marker", detail);
2048
+ super(ForeignSecretMarkerError.code, detail);
2017
2049
  this.name = "ForeignSecretMarkerError";
2018
2050
  }
2019
2051
  };
2020
2052
  /** The keychain could not store or serve a value: explicit, never an empty string. */
2021
- var RecordSecretUnavailableError = class extends RecordsError {
2053
+ var RecordSecretUnavailableError = class RecordSecretUnavailableError extends RecordsError {
2054
+ static code = "secret-unavailable";
2022
2055
  constructor(detail) {
2023
- super("secret-unavailable", detail);
2056
+ super(RecordSecretUnavailableError.code, detail);
2024
2057
  this.name = "RecordSecretUnavailableError";
2025
2058
  }
2026
2059
  };
2027
- var InvalidRecordError = class extends RecordsError {
2060
+ var InvalidRecordError = class InvalidRecordError extends RecordsError {
2061
+ static code = "invalid-record";
2028
2062
  constructor(detail) {
2029
- super("invalid-record", detail);
2063
+ super(InvalidRecordError.code, detail);
2030
2064
  this.name = "InvalidRecordError";
2031
2065
  }
2032
2066
  };
2033
2067
  /** A kind declaration the engine refuses (non-additive change, bad shape, wrong file). */
2034
- var DeclarationRefusedError = class extends RecordsError {
2068
+ var DeclarationRefusedError = class DeclarationRefusedError extends RecordsError {
2069
+ static code = "declaration-refused";
2035
2070
  constructor(detail) {
2036
- super("declaration-refused", detail);
2071
+ super(DeclarationRefusedError.code, detail);
2037
2072
  this.name = "DeclarationRefusedError";
2038
2073
  }
2039
2074
  };
2040
- var NoCallerError = class extends RecordsError {
2075
+ var NoCallerError = class NoCallerError extends RecordsError {
2076
+ static code = "no-caller";
2041
2077
  constructor(detail) {
2042
- super("no-caller", detail);
2078
+ super(NoCallerError.code, detail);
2043
2079
  this.name = "NoCallerError";
2044
2080
  }
2045
2081
  };
2046
- var BatchTooLargeError = class extends RecordsError {
2082
+ var BatchTooLargeError = class BatchTooLargeError extends RecordsError {
2083
+ static code = "batch-too-large";
2047
2084
  constructor(detail) {
2048
- super("batch-too-large", detail);
2085
+ super(BatchTooLargeError.code, detail);
2049
2086
  this.name = "BatchTooLargeError";
2050
2087
  }
2051
2088
  };
@@ -2054,9 +2091,10 @@ var BatchTooLargeError = class extends RecordsError {
2054
2091
  * caller did not declare in ONE file and ONE `transactFamily`. The detail names
2055
2092
  * which rule (`cross-file`, `cross-family`, `no-family`); it is never a silent split.
2056
2093
  */
2057
- var TransactRefusedError = class extends RecordsError {
2094
+ var TransactRefusedError = class TransactRefusedError extends RecordsError {
2095
+ static code = "transact-refused";
2058
2096
  constructor(detail) {
2059
- super("transact-refused", detail);
2097
+ super(TransactRefusedError.code, detail);
2060
2098
  this.name = "TransactRefusedError";
2061
2099
  }
2062
2100
  };
@@ -4889,302 +4927,6 @@ function normalizeAddonInitResult(result) {
4889
4927
  if (Array.isArray(result)) return { providers: result };
4890
4928
  return result;
4891
4929
  }
4892
- /**
4893
- * Per-listener shared-secret header the hub injects on every reverse-proxied
4894
- * data-plane request and the addon's framework wrapper validates — so only the
4895
- * hub can reach the addon's `127.0.0.1` listener. Defined here (shared by the
4896
- * core proxy and the kernel listener) to keep both off a kernel↔core import.
4897
- */
4898
- var DATAPLANE_SECRET_HEADER = "x-camstack-dataplane-secret";
4899
- /**
4900
- * The share-view scope kinds a share-link token can carry. The hub mints
4901
- * and validates them (`ShareViewGrantSchema` builds its
4902
- * enum from this list); a data plane names the kinds it ACCEPTS in `share`.
4903
- */
4904
- var SHARE_VIEW_KINDS = ["grid-view", "events-view"];
4905
- /** The wire shape of {@link PeerBytesTicket} — see the type for what it is. */
4906
- var PeerBytesTicketSchema = z.object({
4907
- /** `http://127.0.0.1:<port>/<token>`. One `GET` takes it. */
4908
- url: z.string().min(1),
4909
- /**
4910
- * The HOST node this URL means something on — the hub or a named agent,
4911
- * never a runner. {@link AddonPeerBytes.open} compares it to its own and
4912
- * refuses `cross-node` by name when they differ, without dialling.
4913
- */
4914
- hostNodeId: z.string().min(1),
4915
- expiresAtMs: z.number().int().nonnegative(),
4916
- /**
4917
- * What the producer DECLARED the body to be, when it knows — `null` when it
4918
- * does not. Never `0` for unknown (D393): a consumer sizing a bound off this
4919
- * must be able to tell "the producer did not say" from "the body is empty".
4920
- */
4921
- declaredBytes: z.number().int().nonnegative().nullable()
4922
- });
4923
- function defOf(schema) {
4924
- const zodBag = Reflect.get(schema, "_zod");
4925
- if (typeof zodBag !== "object" || zodBag === null) return {};
4926
- const def = Reflect.get(zodBag, "def");
4927
- if (typeof def !== "object" || def === null) return {};
4928
- return def;
4929
- }
4930
- function declaredHere(schema) {
4931
- return z.globalRegistry.get(schema)?.secret === true;
4932
- }
4933
- /** Wrapper kinds whose `innerType` is the field itself. */
4934
- var WRAPPERS = new Set([
4935
- "optional",
4936
- "nullable",
4937
- "default",
4938
- "prefault",
4939
- "catch",
4940
- "readonly",
4941
- "nonoptional"
4942
- ]);
4943
- /**
4944
- * The schema layers that make up ONE field: the schema itself and every
4945
- * wrapper below it (optional / default / nullable / readonly / catch), plus
4946
- * both sides of a pipe (`z.preprocess` puts the real schema on `out`,
4947
- * `.transform` on `in`).
4948
- */
4949
- function layersOf(schema) {
4950
- const out = [];
4951
- const queue = [schema];
4952
- while (queue.length > 0) {
4953
- const s = queue.shift();
4954
- if (!s || out.includes(s)) continue;
4955
- out.push(s);
4956
- const def = defOf(s);
4957
- if (def.type !== void 0 && WRAPPERS.has(def.type) && def.innerType) queue.push(def.innerType);
4958
- if (def.type === "pipe") {
4959
- if (def.in) queue.push(def.in);
4960
- if (def.out) queue.push(def.out);
4961
- }
4962
- }
4963
- return out;
4964
- }
4965
- /** True when any layer of this field declares `.meta({ secret: true })`. */
4966
- function isZodSecret(schema) {
4967
- return layersOf(schema).some(declaredHere);
4968
- }
4969
- /**
4970
- * Every declared secret path in a config schema: dotted keys, `[]` for "each
4971
- * element of this array" (`connection.password`, `rows[].token`), `{}` for "each value of this
4972
- * map" (`applianceSecrets{}`). A declared
4973
- * object or array is reported as one path and not descended into — everything
4974
- * under it is secret.
4975
- */
4976
- function collectZodSecretPaths(schema, prefix = "") {
4977
- if (isZodSecret(schema)) return prefix.length > 0 ? [prefix] : [];
4978
- const paths = [];
4979
- for (const layer of layersOf(schema)) {
4980
- const def = defOf(layer);
4981
- if (def.type === "object" && def.shape) for (const [key, child] of Object.entries(def.shape)) paths.push(...collectZodSecretPaths(child, prefix ? `${prefix}.${key}` : key));
4982
- else if (def.type === "array" && def.element) paths.push(...collectZodSecretPaths(def.element, `${prefix}[]`));
4983
- else if (def.type === "record" && def.valueType) paths.push(...collectZodSecretPaths(def.valueType, `${prefix}{}`));
4984
- else if (def.type === "union" && def.options) for (const option of def.options) paths.push(...collectZodSecretPaths(option, prefix));
4985
- else if (def.type === "intersection") {
4986
- if (def.left) paths.push(...collectZodSecretPaths(def.left, prefix));
4987
- if (def.right) paths.push(...collectZodSecretPaths(def.right, prefix));
4988
- }
4989
- }
4990
- return [...new Set(paths)];
4991
- }
4992
- /**
4993
- * Record kinds (D881): the declaration an addon makes of one kind of fact, the
4994
- * Zod row schema that describes it, and the helper that turns the two into the
4995
- * JSON the engine stores.
4996
- *
4997
- * A kind is declared ONCE, next to the code that owns it, and the engine's
4998
- * reconciler creates its indexes - nothing creates DDL at runtime from a write.
4999
- * Everything the generic machinery needs (secret fields, the entry descriptor)
5000
- * is DERIVED from the Zod schema: `.meta({ secret: true })` marks a credential,
5001
- * never a field name (D879).
5002
- */
5003
- /** A JSON field path: `trackId`, `auth.accessToken`. Charset-restricted: it is rendered into DDL. */
5004
- var RecordFieldPathSchema = z.string().regex(/^[A-Za-z_][A-Za-z0-9_]{0,63}(\.[A-Za-z_][A-Za-z0-9_]{0,63}){0,3}$/);
5005
- var RecordIndexSchema = z.object({
5006
- name: z.string().regex(/^[a-z][a-z0-9_]{0,31}$/),
5007
- fields: z.array(RecordFieldPathSchema).min(1).max(4),
5008
- unique: z.boolean().optional()
5009
- }).strict();
5010
- var RecordRetentionSchema = z.union([
5011
- z.object({
5012
- ttlMs: z.number().int().positive(),
5013
- from: z.enum(["at", "write"])
5014
- }).strict(),
5015
- z.object({
5016
- maxRows: z.number().int().positive().optional(),
5017
- maxRowsPerDevice: z.number().int().positive().optional()
5018
- }).strict().refine((r) => r.maxRows !== void 0 || r.maxRowsPerDevice !== void 0, { message: "name maxRows, maxRowsPerDevice or both" }),
5019
- z.object({
5020
- owner: z.string().min(1),
5021
- reason: z.string().min(1)
5022
- }).strict(),
5023
- z.object({ none: z.string().min(1) }).strict()
5024
- ]);
5025
- /** The descriptor a generic entries UI reads (D881 "generic entries"). */
5026
- var EntryDescriptorSchema = z.object({
5027
- title: z.string().min(1),
5028
- /** The record body field shown as the entry's name. */
5029
- nameField: z.string().min(1),
5030
- /** JSON Schema of the entry body; `secret: true` marks a password field. */
5031
- fields: z.record(z.string(), z.unknown())
5032
- }).strict();
5033
- var RecordKindDeclarationShape = z.object({
5034
- database: z.enum(RECORD_DATABASES).default("settings"),
5035
- class: z.enum(RECORD_CLASSES),
5036
- writeTrigger: z.string().min(1),
5037
- device: z.enum([
5038
- "required",
5039
- "optional",
5040
- "none"
5041
- ]).default("none"),
5042
- at: z.enum(["required", "none"]).default("none"),
5043
- indexes: z.array(RecordIndexSchema).max(8).default([]),
5044
- retention: RecordRetentionSchema,
5045
- deviceRemoval: z.enum(["delete", "none"]).default("none"),
5046
- maxDataBytes: z.number().int().positive().max(RECORD_MAX_DATA_BYTES).default(RECORD_DEFAULT_MAX_DATA_BYTES),
5047
- /** Derived from the Zod schema; never written by hand. */
5048
- secretPaths: z.array(z.string().min(1)).default([]),
5049
- /** The id key of each array that carries a secret (`{ headers: 'name' }`). */
5050
- secretArrayKeys: z.record(z.string(), z.string()).default({}),
5051
- /** Kinds that must agree through `transact` sit in one file under one family name. */
5052
- transactFamily: z.string().min(1).optional(),
5053
- entry: EntryDescriptorSchema.optional()
5054
- });
5055
- /** What crosses the wire from an addon: JSON only, no Zod. An unknown key is refused. */
5056
- var RecordKindDeclarationSchema = RecordKindDeclarationShape.strict();
5057
- /**
5058
- * A declaration as the engine's catalog stored it: an unknown key is DROPPED,
5059
- * because a row written by an older engine must never stop records from
5060
- * starting. Only for rows read back from the catalog, never for input.
5061
- */
5062
- var StoredRecordKindDeclarationSchema = RecordKindDeclarationShape;
5063
- /** The kind names: lower-case, dash separated, short enough for an index name. */
5064
- var RecordKindNameSchema = z.string().regex(/^[a-z][a-z0-9-]{0,47}$/);
5065
- /** Cross-field rules a declaration must satisfy. Throws {@link DeclarationRefusedError}. */
5066
- function assertValidDeclaration(name, decl) {
5067
- const refuse = (why) => {
5068
- throw new DeclarationRefusedError(`kind "${name}": ${why}`);
5069
- };
5070
- if (!RecordKindNameSchema.safeParse(name).success) refuse("the name must be lower-case-dashed");
5071
- const seen = /* @__PURE__ */ new Set();
5072
- for (const index of decl.indexes) {
5073
- if (seen.has(index.name)) refuse(`index name "${index.name}" is declared twice`);
5074
- seen.add(index.name);
5075
- }
5076
- const { retention } = decl;
5077
- const hasSecrets = decl.secretPaths.length > 0;
5078
- if ("ttlMs" in retention) {
5079
- if (retention.from === "at" && decl.at !== "required") refuse("a ttl from \"at\" needs at: \"required\"");
5080
- if (hasSecrets) refuse("a kind with secret fields cannot use engine TTL (its keychain values would be orphaned)");
5081
- }
5082
- if ("maxRows" in retention || "maxRowsPerDevice" in retention) {
5083
- if (retention.maxRowsPerDevice !== void 0 && decl.device !== "required") refuse("maxRowsPerDevice needs device: \"required\"");
5084
- if (decl.at !== "required") refuse("a row bound trims the oldest \"at\": it needs at: \"required\"");
5085
- if (hasSecrets) refuse("a kind with secret fields cannot use an engine row bound");
5086
- const bound = Math.max(retention.maxRows ?? 0, retention.maxRowsPerDevice ?? 0);
5087
- if (decl.database === "settings" && bound > 5e4) refuse(`a row bound above ${RECORD_SETTINGS_MAX_ROWS} belongs in database: "events" (a big delete on the settings thread stalls every configuration read)`);
5088
- }
5089
- if (decl.deviceRemoval === "delete" && decl.device === "none") refuse("deviceRemoval: \"delete\" needs a device: \"required\" or \"optional\"");
5090
- for (const path of decl.secretPaths) for (const prefix of secretArrayPrefixes(path)) if (decl.secretArrayKeys[prefix] === void 0) refuse(`secret path "${path}" crosses the array "${prefix}": declare its id key in secretArrayKeys`);
5091
- }
5092
- function bodyFieldsOf(schema) {
5093
- return { ...z.toJSONSchema(schema, {
5094
- unrepresentable: "any",
5095
- io: "input"
5096
- }) };
5097
- }
5098
- function isRecordLike(value) {
5099
- return typeof value === "object" && value !== null && !Array.isArray(value);
5100
- }
5101
- /** Does every branch of the body schema carry `field`? (A discriminated union has several.) */
5102
- function hasNameField(json, field) {
5103
- const branches = json["oneOf"] ?? json["anyOf"];
5104
- if (Array.isArray(branches)) return branches.length > 0 && branches.every((b) => isRecordLike(b) && hasNameField(b, field));
5105
- const properties = json["properties"];
5106
- return isRecordLike(properties) && Object.prototype.hasOwnProperty.call(properties, field);
5107
- }
5108
- /**
5109
- * Declare the kinds of a package. The keys are the kind names. The result is
5110
- * what `ctx.records.declare` sends to the engine and what `ctx.records.kind`
5111
- * types its handle from.
5112
- */
5113
- function defineRecordKinds(specs) {
5114
- const out = {};
5115
- for (const [name, spec] of Object.entries(specs)) {
5116
- const secretPaths = collectZodSecretPaths(spec.schema);
5117
- const nameField = spec.entry?.nameField ?? "name";
5118
- const fields = bodyFieldsOf(spec.schema);
5119
- if (spec.entry !== void 0 && !hasNameField(fields, nameField)) throw new DeclarationRefusedError(`kind "${name}": an entry kind's schema needs a "${nameField}" field`);
5120
- const parsed = RecordKindDeclarationSchema.parse({
5121
- database: spec.database,
5122
- class: spec.class,
5123
- writeTrigger: spec.writeTrigger,
5124
- device: spec.device,
5125
- at: spec.at,
5126
- indexes: spec.indexes === void 0 ? void 0 : [...spec.indexes],
5127
- retention: spec.retention,
5128
- deviceRemoval: spec.deviceRemoval,
5129
- maxDataBytes: spec.maxDataBytes,
5130
- secretPaths: [...new Set([...secretPaths, ...spec.retiredSecretPaths ?? []])],
5131
- secretArrayKeys: spec.secretArrayKeys === void 0 ? void 0 : { ...spec.secretArrayKeys },
5132
- transactFamily: spec.transactFamily,
5133
- entry: spec.entry === void 0 ? void 0 : {
5134
- title: spec.entry.title,
5135
- nameField,
5136
- fields
5137
- }
5138
- });
5139
- assertValidDeclaration(name, parsed);
5140
- out[name] = {
5141
- name,
5142
- schema: spec.schema,
5143
- declaration: parsed
5144
- };
5145
- }
5146
- return out;
5147
- }
5148
- /**
5149
- * The scope rule of `transact`, shared by the engine, the provider and the
5150
- * in-memory records so they cannot disagree: every op's kind sits in ONE
5151
- * database file, and when more than one kind is involved they all name the
5152
- * SAME `transactFamily`. A refusal names the rule; nothing is split silently.
5153
- */
5154
- /** Throws {@link TransactRefusedError} unless the kinds may share one transaction. */
5155
- function assertTransactScope(members) {
5156
- const byKind = /* @__PURE__ */ new Map();
5157
- for (const m of members) byKind.set(m.kind, m);
5158
- const kinds = [...byKind.values()];
5159
- if (new Set(kinds.map((m) => m.declaration.database)).size > 1) throw new TransactRefusedError(`cross-file: the ops span more than one database file (${kinds.map((m) => `${m.kind}@${m.declaration.database}`).join(", ")}); a transaction lives in ONE file`);
5160
- if (kinds.length <= 1) return;
5161
- const missing = kinds.filter((m) => m.declaration.transactFamily === void 0);
5162
- 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`);
5163
- 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(", ")})`);
5164
- }
5165
- /**
5166
- * Declare one entry kind. An entry is configuration: never trimmed by the
5167
- * engine, never aged, belonging to no device.
5168
- */
5169
- function defineEntryKind(name, spec) {
5170
- const defined = defineRecordKinds({ [name]: {
5171
- schema: spec.schema,
5172
- class: "config",
5173
- writeTrigger: spec.writeTrigger ?? "an operator adds or edits an entry in the entries UI",
5174
- retention: { none: "an entry goes only when the operator deletes it" },
5175
- ...spec.maxDataBytes === void 0 ? {} : { maxDataBytes: spec.maxDataBytes },
5176
- ...spec.database === void 0 ? {} : { database: spec.database },
5177
- ...spec.indexes === void 0 ? {} : { indexes: spec.indexes },
5178
- ...spec.secretArrayKeys === void 0 ? {} : { secretArrayKeys: spec.secretArrayKeys },
5179
- ...spec.retiredSecretPaths === void 0 ? {} : { retiredSecretPaths: spec.retiredSecretPaths },
5180
- entry: {
5181
- title: spec.title,
5182
- ...spec.nameField === void 0 ? {} : { nameField: spec.nameField }
5183
- }
5184
- } })[name];
5185
- if (defined === void 0) throw new DeclarationRefusedError(`entry kind "${name}" was not built`);
5186
- return defined;
5187
- }
5188
4930
  z.object({
5189
4931
  field: z.string().min(1),
5190
4932
  on: z.literal("advance")
@@ -5358,6 +5100,302 @@ function event(data) {
5358
5100
  function isDeviceConfigCap(def) {
5359
5101
  return def?.deviceConfig !== void 0;
5360
5102
  }
5103
+ function defOf(schema) {
5104
+ const zodBag = Reflect.get(schema, "_zod");
5105
+ if (typeof zodBag !== "object" || zodBag === null) return {};
5106
+ const def = Reflect.get(zodBag, "def");
5107
+ if (typeof def !== "object" || def === null) return {};
5108
+ return def;
5109
+ }
5110
+ function declaredHere(schema) {
5111
+ return z.globalRegistry.get(schema)?.secret === true;
5112
+ }
5113
+ /** Wrapper kinds whose `innerType` is the field itself. */
5114
+ var WRAPPERS = new Set([
5115
+ "optional",
5116
+ "nullable",
5117
+ "default",
5118
+ "prefault",
5119
+ "catch",
5120
+ "readonly",
5121
+ "nonoptional"
5122
+ ]);
5123
+ /**
5124
+ * The schema layers that make up ONE field: the schema itself and every
5125
+ * wrapper below it (optional / default / nullable / readonly / catch), plus
5126
+ * both sides of a pipe (`z.preprocess` puts the real schema on `out`,
5127
+ * `.transform` on `in`).
5128
+ */
5129
+ function layersOf(schema) {
5130
+ const out = [];
5131
+ const queue = [schema];
5132
+ while (queue.length > 0) {
5133
+ const s = queue.shift();
5134
+ if (!s || out.includes(s)) continue;
5135
+ out.push(s);
5136
+ const def = defOf(s);
5137
+ if (def.type !== void 0 && WRAPPERS.has(def.type) && def.innerType) queue.push(def.innerType);
5138
+ if (def.type === "pipe") {
5139
+ if (def.in) queue.push(def.in);
5140
+ if (def.out) queue.push(def.out);
5141
+ }
5142
+ }
5143
+ return out;
5144
+ }
5145
+ /** True when any layer of this field declares `.meta({ secret: true })`. */
5146
+ function isZodSecret(schema) {
5147
+ return layersOf(schema).some(declaredHere);
5148
+ }
5149
+ /**
5150
+ * Every declared secret path in a config schema: dotted keys, `[]` for "each
5151
+ * element of this array" (`connection.password`, `rows[].token`), `{}` for "each value of this
5152
+ * map" (`applianceSecrets{}`). A declared
5153
+ * object or array is reported as one path and not descended into — everything
5154
+ * under it is secret.
5155
+ */
5156
+ function collectZodSecretPaths(schema, prefix = "") {
5157
+ if (isZodSecret(schema)) return prefix.length > 0 ? [prefix] : [];
5158
+ const paths = [];
5159
+ for (const layer of layersOf(schema)) {
5160
+ const def = defOf(layer);
5161
+ if (def.type === "object" && def.shape) for (const [key, child] of Object.entries(def.shape)) paths.push(...collectZodSecretPaths(child, prefix ? `${prefix}.${key}` : key));
5162
+ else if (def.type === "array" && def.element) paths.push(...collectZodSecretPaths(def.element, `${prefix}[]`));
5163
+ else if (def.type === "record" && def.valueType) paths.push(...collectZodSecretPaths(def.valueType, `${prefix}{}`));
5164
+ else if (def.type === "union" && def.options) for (const option of def.options) paths.push(...collectZodSecretPaths(option, prefix));
5165
+ else if (def.type === "intersection") {
5166
+ if (def.left) paths.push(...collectZodSecretPaths(def.left, prefix));
5167
+ if (def.right) paths.push(...collectZodSecretPaths(def.right, prefix));
5168
+ }
5169
+ }
5170
+ return [...new Set(paths)];
5171
+ }
5172
+ /**
5173
+ * Record kinds (D881): the declaration an addon makes of one kind of fact, the
5174
+ * Zod row schema that describes it, and the helper that turns the two into the
5175
+ * JSON the engine stores.
5176
+ *
5177
+ * A kind is declared ONCE, next to the code that owns it, and the engine's
5178
+ * reconciler creates its indexes - nothing creates DDL at runtime from a write.
5179
+ * Everything the generic machinery needs (secret fields, the entry descriptor)
5180
+ * is DERIVED from the Zod schema: `.meta({ secret: true })` marks a credential,
5181
+ * never a field name (D879).
5182
+ */
5183
+ /** A JSON field path: `trackId`, `auth.accessToken`. Charset-restricted: it is rendered into DDL. */
5184
+ var RecordFieldPathSchema = z.string().regex(/^[A-Za-z_][A-Za-z0-9_]{0,63}(\.[A-Za-z_][A-Za-z0-9_]{0,63}){0,3}$/);
5185
+ var RecordIndexSchema = z.object({
5186
+ name: z.string().regex(/^[a-z][a-z0-9_]{0,31}$/),
5187
+ fields: z.array(RecordFieldPathSchema).min(1).max(4),
5188
+ unique: z.boolean().optional()
5189
+ }).strict();
5190
+ var RecordRetentionSchema = z.union([
5191
+ z.object({
5192
+ ttlMs: z.number().int().positive(),
5193
+ from: z.enum(["at", "write"])
5194
+ }).strict(),
5195
+ z.object({
5196
+ maxRows: z.number().int().positive().optional(),
5197
+ maxRowsPerDevice: z.number().int().positive().optional()
5198
+ }).strict().refine((r) => r.maxRows !== void 0 || r.maxRowsPerDevice !== void 0, { message: "name maxRows, maxRowsPerDevice or both" }),
5199
+ z.object({
5200
+ owner: z.string().min(1),
5201
+ reason: z.string().min(1)
5202
+ }).strict(),
5203
+ z.object({ none: z.string().min(1) }).strict()
5204
+ ]);
5205
+ /** The descriptor a generic entries UI reads (D881 "generic entries"). */
5206
+ var EntryDescriptorSchema = z.object({
5207
+ title: z.string().min(1),
5208
+ /** The record body field shown as the entry's name. */
5209
+ nameField: z.string().min(1),
5210
+ /** JSON Schema of the entry body; `secret: true` marks a password field. */
5211
+ fields: z.record(z.string(), z.unknown())
5212
+ }).strict();
5213
+ var RecordKindDeclarationShape = z.object({
5214
+ database: z.enum(RECORD_DATABASES).default("settings"),
5215
+ class: z.enum(RECORD_CLASSES),
5216
+ writeTrigger: z.string().min(1),
5217
+ device: z.enum([
5218
+ "required",
5219
+ "optional",
5220
+ "none"
5221
+ ]).default("none"),
5222
+ at: z.enum(["required", "none"]).default("none"),
5223
+ indexes: z.array(RecordIndexSchema).max(8).default([]),
5224
+ retention: RecordRetentionSchema,
5225
+ deviceRemoval: z.enum(["delete", "none"]).default("none"),
5226
+ maxDataBytes: z.number().int().positive().max(RECORD_MAX_DATA_BYTES).default(RECORD_DEFAULT_MAX_DATA_BYTES),
5227
+ /** Derived from the Zod schema; never written by hand. */
5228
+ secretPaths: z.array(z.string().min(1)).default([]),
5229
+ /** The id key of each array that carries a secret (`{ headers: 'name' }`). */
5230
+ secretArrayKeys: z.record(z.string(), z.string()).default({}),
5231
+ /** Kinds that must agree through `transact` sit in one file under one family name. */
5232
+ transactFamily: z.string().min(1).optional(),
5233
+ entry: EntryDescriptorSchema.optional()
5234
+ });
5235
+ /** What crosses the wire from an addon: JSON only, no Zod. An unknown key is refused. */
5236
+ var RecordKindDeclarationSchema = RecordKindDeclarationShape.strict();
5237
+ /**
5238
+ * A declaration as the engine's catalog stored it: an unknown key is DROPPED,
5239
+ * because a row written by an older engine must never stop records from
5240
+ * starting. Only for rows read back from the catalog, never for input.
5241
+ */
5242
+ var StoredRecordKindDeclarationSchema = RecordKindDeclarationShape;
5243
+ /** The kind names: lower-case, dash separated, short enough for an index name. */
5244
+ var RecordKindNameSchema = z.string().regex(/^[a-z][a-z0-9-]{0,47}$/);
5245
+ /** Cross-field rules a declaration must satisfy. Throws {@link DeclarationRefusedError}. */
5246
+ function assertValidDeclaration(name, decl) {
5247
+ const refuse = (why) => {
5248
+ throw new DeclarationRefusedError(`kind "${name}": ${why}`);
5249
+ };
5250
+ if (!RecordKindNameSchema.safeParse(name).success) refuse("the name must be lower-case-dashed");
5251
+ const seen = /* @__PURE__ */ new Set();
5252
+ for (const index of decl.indexes) {
5253
+ if (seen.has(index.name)) refuse(`index name "${index.name}" is declared twice`);
5254
+ seen.add(index.name);
5255
+ }
5256
+ const { retention } = decl;
5257
+ const hasSecrets = decl.secretPaths.length > 0;
5258
+ if ("ttlMs" in retention) {
5259
+ if (retention.from === "at" && decl.at !== "required") refuse("a ttl from \"at\" needs at: \"required\"");
5260
+ if (hasSecrets) refuse("a kind with secret fields cannot use engine TTL (its keychain values would be orphaned)");
5261
+ }
5262
+ if ("maxRows" in retention || "maxRowsPerDevice" in retention) {
5263
+ if (retention.maxRowsPerDevice !== void 0 && decl.device !== "required") refuse("maxRowsPerDevice needs device: \"required\"");
5264
+ if (decl.at !== "required") refuse("a row bound trims the oldest \"at\": it needs at: \"required\"");
5265
+ if (hasSecrets) refuse("a kind with secret fields cannot use an engine row bound");
5266
+ const bound = Math.max(retention.maxRows ?? 0, retention.maxRowsPerDevice ?? 0);
5267
+ if (decl.database === "settings" && bound > 5e4) refuse(`a row bound above ${RECORD_SETTINGS_MAX_ROWS} belongs in database: "events" (a big delete on the settings thread stalls every configuration read)`);
5268
+ }
5269
+ if (decl.deviceRemoval === "delete" && decl.device === "none") refuse("deviceRemoval: \"delete\" needs a device: \"required\" or \"optional\"");
5270
+ for (const path of decl.secretPaths) for (const prefix of secretArrayPrefixes(path)) if (decl.secretArrayKeys[prefix] === void 0) refuse(`secret path "${path}" crosses the array "${prefix}": declare its id key in secretArrayKeys`);
5271
+ }
5272
+ function bodyFieldsOf(schema) {
5273
+ return { ...z.toJSONSchema(schema, {
5274
+ unrepresentable: "any",
5275
+ io: "input"
5276
+ }) };
5277
+ }
5278
+ function isRecordLike(value) {
5279
+ return typeof value === "object" && value !== null && !Array.isArray(value);
5280
+ }
5281
+ /** Does every branch of the body schema carry `field`? (A discriminated union has several.) */
5282
+ function hasNameField(json, field) {
5283
+ const branches = json["oneOf"] ?? json["anyOf"];
5284
+ if (Array.isArray(branches)) return branches.length > 0 && branches.every((b) => isRecordLike(b) && hasNameField(b, field));
5285
+ const properties = json["properties"];
5286
+ return isRecordLike(properties) && Object.prototype.hasOwnProperty.call(properties, field);
5287
+ }
5288
+ /**
5289
+ * Declare the kinds of a package. The keys are the kind names. The result is
5290
+ * what `ctx.records.declare` sends to the engine and what `ctx.records.kind`
5291
+ * types its handle from.
5292
+ */
5293
+ function defineRecordKinds(specs) {
5294
+ const out = {};
5295
+ for (const [name, spec] of Object.entries(specs)) {
5296
+ const secretPaths = collectZodSecretPaths(spec.schema);
5297
+ const nameField = spec.entry?.nameField ?? "name";
5298
+ const fields = bodyFieldsOf(spec.schema);
5299
+ if (spec.entry !== void 0 && !hasNameField(fields, nameField)) throw new DeclarationRefusedError(`kind "${name}": an entry kind's schema needs a "${nameField}" field`);
5300
+ const parsed = RecordKindDeclarationSchema.parse({
5301
+ database: spec.database,
5302
+ class: spec.class,
5303
+ writeTrigger: spec.writeTrigger,
5304
+ device: spec.device,
5305
+ at: spec.at,
5306
+ indexes: spec.indexes === void 0 ? void 0 : [...spec.indexes],
5307
+ retention: spec.retention,
5308
+ deviceRemoval: spec.deviceRemoval,
5309
+ maxDataBytes: spec.maxDataBytes,
5310
+ secretPaths: [...new Set([...secretPaths, ...spec.retiredSecretPaths ?? []])],
5311
+ secretArrayKeys: spec.secretArrayKeys === void 0 ? void 0 : { ...spec.secretArrayKeys },
5312
+ transactFamily: spec.transactFamily,
5313
+ entry: spec.entry === void 0 ? void 0 : {
5314
+ title: spec.entry.title,
5315
+ nameField,
5316
+ fields
5317
+ }
5318
+ });
5319
+ assertValidDeclaration(name, parsed);
5320
+ out[name] = {
5321
+ name,
5322
+ schema: spec.schema,
5323
+ declaration: parsed
5324
+ };
5325
+ }
5326
+ return out;
5327
+ }
5328
+ /**
5329
+ * Declare one entry kind. An entry is configuration: never trimmed by the
5330
+ * engine, never aged, belonging to no device.
5331
+ */
5332
+ function defineEntryKind(name, spec) {
5333
+ const defined = defineRecordKinds({ [name]: {
5334
+ schema: spec.schema,
5335
+ class: "config",
5336
+ writeTrigger: spec.writeTrigger ?? "an operator adds or edits an entry in the entries UI",
5337
+ retention: { none: "an entry goes only when the operator deletes it" },
5338
+ ...spec.maxDataBytes === void 0 ? {} : { maxDataBytes: spec.maxDataBytes },
5339
+ ...spec.database === void 0 ? {} : { database: spec.database },
5340
+ ...spec.indexes === void 0 ? {} : { indexes: spec.indexes },
5341
+ ...spec.secretArrayKeys === void 0 ? {} : { secretArrayKeys: spec.secretArrayKeys },
5342
+ ...spec.retiredSecretPaths === void 0 ? {} : { retiredSecretPaths: spec.retiredSecretPaths },
5343
+ entry: {
5344
+ title: spec.title,
5345
+ ...spec.nameField === void 0 ? {} : { nameField: spec.nameField }
5346
+ }
5347
+ } })[name];
5348
+ if (defined === void 0) throw new DeclarationRefusedError(`entry kind "${name}" was not built`);
5349
+ return defined;
5350
+ }
5351
+ /**
5352
+ * Per-listener shared-secret header the hub injects on every reverse-proxied
5353
+ * data-plane request and the addon's framework wrapper validates — so only the
5354
+ * hub can reach the addon's `127.0.0.1` listener. Defined here (shared by the
5355
+ * core proxy and the kernel listener) to keep both off a kernel↔core import.
5356
+ */
5357
+ var DATAPLANE_SECRET_HEADER = "x-camstack-dataplane-secret";
5358
+ /**
5359
+ * The share-view scope kinds a share-link token can carry. The hub mints
5360
+ * and validates them (`ShareViewGrantSchema` builds its
5361
+ * enum from this list); a data plane names the kinds it ACCEPTS in `share`.
5362
+ */
5363
+ var SHARE_VIEW_KINDS = ["grid-view", "events-view"];
5364
+ /** The wire shape of {@link PeerBytesTicket} — see the type for what it is. */
5365
+ var PeerBytesTicketSchema = z.object({
5366
+ /** `http://127.0.0.1:<port>/<token>`. One `GET` takes it. */
5367
+ url: z.string().min(1),
5368
+ /**
5369
+ * The HOST node this URL means something on — the hub or a named agent,
5370
+ * never a runner. {@link AddonPeerBytes.open} compares it to its own and
5371
+ * refuses `cross-node` by name when they differ, without dialling.
5372
+ */
5373
+ hostNodeId: z.string().min(1),
5374
+ expiresAtMs: z.number().int().nonnegative(),
5375
+ /**
5376
+ * What the producer DECLARED the body to be, when it knows — `null` when it
5377
+ * does not. Never `0` for unknown (D393): a consumer sizing a bound off this
5378
+ * must be able to tell "the producer did not say" from "the body is empty".
5379
+ */
5380
+ declaredBytes: z.number().int().nonnegative().nullable()
5381
+ });
5382
+ /**
5383
+ * The scope rule of `transact`, shared by the engine, the provider and the
5384
+ * in-memory records so they cannot disagree: every op's kind sits in ONE
5385
+ * database file, and when more than one kind is involved they all name the
5386
+ * SAME `transactFamily`. A refusal names the rule; nothing is split silently.
5387
+ */
5388
+ /** Throws {@link TransactRefusedError} unless the kinds may share one transaction. */
5389
+ function assertTransactScope(members) {
5390
+ const byKind = /* @__PURE__ */ new Map();
5391
+ for (const m of members) byKind.set(m.kind, m);
5392
+ const kinds = [...byKind.values()];
5393
+ if (new Set(kinds.map((m) => m.declaration.database)).size > 1) throw new TransactRefusedError(`cross-file: the ops span more than one database file (${kinds.map((m) => `${m.kind}@${m.declaration.database}`).join(", ")}); a transaction lives in ONE file`);
5394
+ if (kinds.length <= 1) return;
5395
+ const missing = kinds.filter((m) => m.declaration.transactFamily === void 0);
5396
+ 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`);
5397
+ 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(", ")})`);
5398
+ }
5361
5399
  var READING_QUANTITIES = [
5362
5400
  "temperature",
5363
5401
  "pressure",
@@ -6671,7 +6709,6 @@ var CAP_NAMES = Object.freeze([
6671
6709
  "climate-control",
6672
6710
  "color",
6673
6711
  "composer",
6674
- "connection-test",
6675
6712
  "connectivity",
6676
6713
  "consumables",
6677
6714
  "contact",
@@ -8691,8 +8728,7 @@ Object.freeze({
8691
8728
  "offerArtifact": 3e5,
8692
8729
  "readResult": 3e5,
8693
8730
  "submitJob": 18e5,
8694
- "uploadDataset": 72e5,
8695
- "validateCredentials": 3e4
8731
+ "uploadDataset": 72e5
8696
8732
  }
8697
8733
  });
8698
8734
  /**
@@ -11781,6 +11817,456 @@ var IntegrationInstanceRefSchema = z.object({
11781
11817
  candidateStableId: z.string().optional()
11782
11818
  });
11783
11819
  /**
11820
+ * notification-output — canonical, capability-gated notification delivery.
11821
+ *
11822
+ * Apprise-derived model (see
11823
+ * `docs/superpowers/specs/2026-07-03-notification-output-notifier-matrix.md`):
11824
+ * callers emit ONE canonical `Notification`; each provider declares a
11825
+ * per-kind capability descriptor (`TargetKind`), and the pure degrade
11826
+ * engine (`@camstack/types` `prepareNotification`) transcodes / degrades the
11827
+ * message to what the kind supports — callers never special-case a service.
11828
+ *
11829
+ * DESIGN DECISIONS (locked):
11830
+ * - Target CRUD lives on THIS cap (`upsertTarget` / `deleteTarget` /
11831
+ * `setTargetEnabled`), each provider persisting via the `settings-store`
11832
+ * cap. Rationale: the admin UI needs one uniform surface across the
11833
+ * notifiers addon AND the HA addon; the addon-`globalSettingsSchema`-array
11834
+ * alternative would fork the UI per addon and cannot host the
11835
+ * discovery→adopt flow.
11836
+ * - `listTargetKinds` / `listTargets` / `discoverTargets` return arrays →
11837
+ * the generated cap-mount auto-`concatCollection`-fans them across every
11838
+ * registered provider (notifiers addon + HA addon) so one catalog is
11839
+ * routable. `send` / `testTarget` / CRUD route to ONE provider by the
11840
+ * `addonId` the generated collection router extracts from the call input.
11841
+ * - `Attachment.bytes` is `Uint8Array`. Transport-safe: superjson (the tRPC
11842
+ * transformer) + UDS MsgPack both round-trip typed arrays — already used by
11843
+ * `storage` / `storage-provider` / `recording` caps over the same path. No
11844
+ * base64 fallback needed.
11845
+ *
11846
+ * TODO (deferred, closed-set change — separate decision): add
11847
+ * `providerKind: 'notify'` so notification providers surface on the unified
11848
+ * admin "Integrations" page.
11849
+ */
11850
+ /**
11851
+ * Zentik-derived typed-media enum — the superset across every kind. Each
11852
+ * adapter picks what it supports and the degrade engine filters the rest.
11853
+ */
11854
+ var AttachmentMediaTypeSchema = z.enum([
11855
+ "image",
11856
+ "video",
11857
+ "gif",
11858
+ "audio",
11859
+ "icon"
11860
+ ]);
11861
+ /**
11862
+ * A single attachment. Exactly one of `url` (remote source, most adapters
11863
+ * prefer this) or `bytes` (inline source; required for Pushover-style
11864
+ * bytes-only kinds) MUST be present — the degrade engine expresses a
11865
+ * url→bytes fetch as a `needsFetch` directive the adapter executes.
11866
+ */
11867
+ var AttachmentSchema = z.object({
11868
+ mediaType: AttachmentMediaTypeSchema,
11869
+ url: z.string().optional(),
11870
+ bytes: z.instanceof(Uint8Array).optional(),
11871
+ mime: z.string().optional(),
11872
+ name: z.string().optional()
11873
+ }).refine((a) => a.url !== void 0 || a.bytes !== void 0, { message: "Attachment requires either `url` or `bytes`" });
11874
+ var NotificationFormatSchema = z.enum([
11875
+ "text",
11876
+ "markdown",
11877
+ "html"
11878
+ ]);
11879
+ /**
11880
+ * The CLOSED icon vocabulary an action button may use.
11881
+ *
11882
+ * A closed set, not a free string, and that is the whole point: an arbitrary
11883
+ * icon name is one that ntfy renders, zentik silently drops, and nobody
11884
+ * notices — the same class of gap as a zone vocabulary nothing produced
11885
+ * ([D35](../../../docs/decisions/adr-0035.md)). Every adapter maps this set or
11886
+ * declares `actionIcons: false` and the degrade engine strips the field.
11887
+ *
11888
+ * Named by INTENT, never by glyph. "check" would tie the vocabulary to one
11889
+ * renderer's icon set; "acknowledge" survives an adapter that draws it
11890
+ * differently.
11891
+ *
11892
+ * ── A TOKEN IS NOT A WIRE VALUE ─────────────────────────────────────
11893
+ *
11894
+ * These names are for US. **No adapter may forward one verbatim.** Each maps
11895
+ * the whole set onto its own renderer's vocabulary through a
11896
+ * `Record<NotificationActionIcon, string>` — a Record, never a lookup with a
11897
+ * fallback, so adding a member here fails every adapter's build until someone
11898
+ * decides its glyph, which is the only place that decision can be made
11899
+ * honestly.
11900
+ *
11901
+ * This paragraph is the bug. Zentik declared `actionIcons: true` and passed
11902
+ * `disarm` straight through; iOS feeds that string to
11903
+ * `UNNotificationActionIcon(systemImageName:)`, `disarm` is not an SF Symbol,
11904
+ * and every snooze and alarm button arrived BLANK. A pass-through is not a
11905
+ * mapping, and "the field is documented" is not "the value renders".
11906
+ *
11907
+ * Adding a member is TRAIN-BOUND. The enum lives in the published
11908
+ * `@camstack/server` closure and the cap seam validates against the HUB's copy,
11909
+ * so an addon that emits a token the running hub does not know does not lose an
11910
+ * icon — its whole `send` fails Zod validation and the notification never
11911
+ * arrives. Never emit a new token from an addon before the train carrying it.
11912
+ */
11913
+ var NotificationActionIconSchema = z.enum([
11914
+ "acknowledge",
11915
+ "dismiss",
11916
+ "silence",
11917
+ "snooze",
11918
+ "view",
11919
+ "play",
11920
+ "open",
11921
+ "close",
11922
+ "lock",
11923
+ "unlock",
11924
+ "arm",
11925
+ "arm-home",
11926
+ "arm-away",
11927
+ "arm-night",
11928
+ "disarm",
11929
+ "light",
11930
+ "alert",
11931
+ "camera"
11932
+ ]);
11933
+ /** A single tap-through action button. */
11934
+ var NotificationActionSchema = z.object({
11935
+ id: z.string(),
11936
+ label: z.string(),
11937
+ url: z.string().optional(),
11938
+ /** Dropped by the degrade engine for a kind with `caps.actionIcons: false`. */
11939
+ icon: NotificationActionIconSchema.optional(),
11940
+ /**
11941
+ * Renders in a warning style where the notifier supports it.
11942
+ *
11943
+ * A HINT, never a gate. The callback's authority is its token and nothing
11944
+ * else — see `notification-center/action-token.ts` for what that does and
11945
+ * does not buy.
11946
+ */
11947
+ destructive: z.boolean().optional(),
11948
+ /**
11949
+ * How the tap should REACH the url.
11950
+ *
11951
+ * `navigate` (absent, and every button authored before this field) opens it:
11952
+ * the phone leaves the notification and shows whatever the callback returns.
11953
+ * That is right for a button whose answer the operator wants to read.
11954
+ *
11955
+ * `background` fires it as a POST and stays put. It exists for the buttons
11956
+ * whose whole point is not to interrupt — "silence this for 30 minutes" is
11957
+ * an answer to the notification, and being thrown into a browser tab to
11958
+ * confirm it costs more attention than the notification did. A backend that
11959
+ * cannot do a background call renders it as an ordinary link (the adapters
11960
+ * fall back rather than dropping the button), so this is a preference, never
11961
+ * a requirement.
11962
+ */
11963
+ mode: z.enum(["navigate", "background"]).optional()
11964
+ });
11965
+ /** A delivery parameter value: what a notifier declared it takes. */
11966
+ var DeliveryParamValueSchema = z.union([
11967
+ z.string(),
11968
+ z.number(),
11969
+ z.boolean()
11970
+ ]);
11971
+ /**
11972
+ * One extra delivery parameter a notifier KIND declares (D938). A rule that
11973
+ * addresses a target of that kind may set it; a kind that declares nothing is
11974
+ * never handed one. The admin UI derives its control from this descriptor —
11975
+ * no editor knows a service by name.
11976
+ *
11977
+ * Optional fields are `.optional()`, never `.default()` (a Zod default does not
11978
+ * run on the addon cap path).
11979
+ */
11980
+ var DeliveryParamSchema = z.object({
11981
+ key: z.string().min(1),
11982
+ label: z.string(),
11983
+ /** i18n key of the label, resolved by the declaring addon's namespace. */
11984
+ labelKey: z.string().optional(),
11985
+ type: z.enum([
11986
+ "enum",
11987
+ "number",
11988
+ "boolean",
11989
+ "string"
11990
+ ]),
11991
+ /** `enum` only: the closed set of accepted values. */
11992
+ options: z.array(z.object({
11993
+ value: z.string(),
11994
+ label: z.string()
11995
+ })).optional(),
11996
+ /** `number` only. */
11997
+ min: z.number().optional(),
11998
+ max: z.number().optional(),
11999
+ /** What the notifier does when the rule sets nothing; shown as the placeholder. */
12000
+ default: DeliveryParamValueSchema.optional()
12001
+ });
12002
+ /**
12003
+ * The canonical notification. `body` is the only hard field (Apprise model).
12004
+ * `priority` is a 5-level ORDINAL (1=lowest … 3=normal(default) … 5=urgent),
12005
+ * NOT a fixed severity enum — each kind declares its own `caps.levels` and
12006
+ * the adapter maps this ordinal onto its native level. `level?` is an
12007
+ * optional kind-native level id (`emergency`, `silent`, …) that overrides
12008
+ * `priority` for that one target.
12009
+ */
12010
+ var NotificationSchema = z.object({
12011
+ body: z.string(),
12012
+ title: z.string().optional(),
12013
+ format: NotificationFormatSchema.default("text"),
12014
+ priority: z.number().int().min(1).max(5).default(3),
12015
+ level: z.string().optional(),
12016
+ attachments: z.array(AttachmentSchema).optional(),
12017
+ clickUrl: z.string().optional(),
12018
+ actions: z.array(NotificationActionSchema).optional(),
12019
+ sound: z.string().optional(),
12020
+ ttl: z.number().optional(),
12021
+ tag: z.string().optional(),
12022
+ deviceId: z.number().optional(),
12023
+ eventId: z.string().optional(),
12024
+ metadata: z.record(z.string(), z.unknown()).optional(),
12025
+ /**
12026
+ * Values for the parameters the target's kind DECLARES in
12027
+ * {@link TargetKindSchema} `deliveryParams`. Already validated against the
12028
+ * declaration by the sender; a notifier reads only the keys it declared.
12029
+ */
12030
+ delivery: z.record(z.string(), DeliveryParamValueSchema).optional()
12031
+ });
12032
+ /** One declared native severity/priority level for a kind. */
12033
+ var TargetKindLevelSchema = z.object({
12034
+ id: z.string(),
12035
+ label: z.string(),
12036
+ /** Which canonical priority (1..5) this level maps to. `null` = qualitative-only. */
12037
+ ordinal: z.number().int().min(1).max(5).nullable(),
12038
+ flags: z.object({
12039
+ critical: z.boolean().optional(),
12040
+ silent: z.boolean().optional(),
12041
+ noPush: z.boolean().optional()
12042
+ }).optional(),
12043
+ /** e.g. Pushover `emergency` requires `retry` / `expire`. */
12044
+ requires: z.array(z.string()).optional(),
12045
+ description: z.string().optional()
12046
+ });
12047
+ /** Attachment capabilities for a kind (drives the degrade engine + test panel). */
12048
+ var TargetKindAttachmentsCapsSchema = z.object({
12049
+ mediaTypes: z.array(AttachmentMediaTypeSchema),
12050
+ mode: z.enum([
12051
+ "url",
12052
+ "bytes",
12053
+ "both"
12054
+ ]),
12055
+ max: z.number().int().nonnegative(),
12056
+ maxBytes: z.number().int().positive().optional()
12057
+ });
12058
+ /** The full capability block consulted before dispatch. */
12059
+ var TargetKindCapsSchema = z.object({
12060
+ attachments: TargetKindAttachmentsCapsSchema,
12061
+ /** Max action buttons (0 = none). */
12062
+ actions: z.number().int().nonnegative(),
12063
+ /**
12064
+ * Whether this kind renders a per-action ICON.
12065
+ *
12066
+ * `.optional()`, deliberately NOT `.default(false)`: a Zod default does not
12067
+ * run on the addon cap path — three production failures in one day taught
12068
+ * this repo that once. Absent is read as false by the degrade engine, which
12069
+ * is the safe direction: an icon that is not rendered costs nothing, an icon
12070
+ * assumed and dropped costs the operator's trust in the field.
12071
+ */
12072
+ actionIcons: z.boolean().optional(),
12073
+ levels: z.array(TargetKindLevelSchema),
12074
+ format: z.array(NotificationFormatSchema),
12075
+ clickUrl: z.boolean(),
12076
+ sound: z.boolean(),
12077
+ ttl: z.boolean(),
12078
+ bodyMaxLen: z.number().int().positive()
12079
+ });
12080
+ /**
12081
+ * `configSchema` is a `ConfigUISchema` tree passed through to the admin
12082
+ * FormBuilder. Stored as `z.unknown()` at the cap seam (mirrors
12083
+ * `device-provider.getChildCreationSchema` `CreationSchemaOutputSchema`) —
12084
+ * the union is large and not meant for runtime validation here; the exported
12085
+ * `TargetKind` type re-tightens `configSchema` to `ConfigUISchema`.
12086
+ */
12087
+ var ConfigSchemaPassthrough$4 = z.unknown();
12088
+ var TargetKindSchema = z.object({
12089
+ kind: z.string(),
12090
+ label: z.string(),
12091
+ icon: z.string(),
12092
+ /** Stamped by each provider so the concat-fanned catalog stays routable. */
12093
+ addonId: z.string(),
12094
+ /**
12095
+ * URL of the kind's bundled BRAND icon, served by the providing addon over
12096
+ * its own `addon-routes` surface (`/addon/<addonId>/icons/<kind>`). Absent
12097
+ * when the addon bundles no icon for that kind — the client then falls back
12098
+ * to a neutral glyph rather than rendering the raw `icon` NAME as text.
12099
+ *
12100
+ * Root-relative on purpose: it resolves against whatever origin serves a web
12101
+ * client, and a native client joins it onto its own hub base.
12102
+ *
12103
+ * DECLARED here deliberately. It used to travel as an undeclared passthrough
12104
+ * field that survived only because the runtime cap-router forwards provider
12105
+ * output verbatim — so every consumer had to re-declare it by hand to stop
12106
+ * its own Zod parse from stripping it, and the whole arrangement would have
12107
+ * broken silently the moment output validation was tightened anywhere.
12108
+ */
12109
+ iconUrl: z.string().optional(),
12110
+ /**
12111
+ * Media type of {@link iconUrl} (`image/svg+xml`, `image/png`, …).
12112
+ *
12113
+ * The server knows this and therefore says it, because the client cannot
12114
+ * safely guess: a React-Native client renders SVG and raster through two
12115
+ * DIFFERENT components (`react-native-svg` vs `expo-image` — expo-image does
12116
+ * not decode SVG on iOS/Android), so without this it silently fell back to a
12117
+ * placeholder glyph for every vector icon while the web build looked fine.
12118
+ *
12119
+ * Absent when {@link iconUrl} is absent, or for a legacy provider that has
12120
+ * not been updated — a client that cannot determine the type should prefer
12121
+ * its raster path, which is the safe default for an unknown image.
12122
+ */
12123
+ iconMediaType: z.string().optional(),
12124
+ configSchema: ConfigSchemaPassthrough$4,
12125
+ /**
12126
+ * The config keys that decide WHERE this kind's secrets are sent (server,
12127
+ * base URL, instance, chat, recipient). A save that changes any of them
12128
+ * while leaving a secret redacted is refused by the provider (D634), so an
12129
+ * editor uses this to ask for the secret on exactly those edits instead of
12130
+ * on every edit.
12131
+ *
12132
+ * Optional: absent from a provider that holds no secret (the Home Assistant
12133
+ * kinds) and from a provider older than this field — an editor that finds
12134
+ * it absent must assume ANY edit may need the secret.
12135
+ */
12136
+ destinationKeys: z.array(z.string()).optional(),
12137
+ supportsDiscovery: z.boolean(),
12138
+ /**
12139
+ * Extra delivery parameters a rule may set for a target of this kind (D938).
12140
+ * Absent = none; the rule editor then offers nothing.
12141
+ */
12142
+ deliveryParams: z.array(DeliveryParamSchema).optional(),
12143
+ caps: TargetKindCapsSchema
12144
+ });
12145
+ /**
12146
+ * A persisted target. `config` holds secrets; providers REDACT secret fields
12147
+ * (return a presence marker only) when serving `listTargets` — never
12148
+ * round-trip a stored secret to the UI.
12149
+ */
12150
+ var TargetSchema = z.object({
12151
+ id: z.string(),
12152
+ name: z.string(),
12153
+ kind: z.string(),
12154
+ addonId: z.string(),
12155
+ enabled: z.boolean(),
12156
+ config: z.record(z.string(), z.unknown())
12157
+ });
12158
+ /** A discovery-surfaced candidate (config is partial + non-secret). */
12159
+ var DiscoveredTargetSchema = z.object({
12160
+ kind: z.string(),
12161
+ suggestedName: z.string(),
12162
+ config: z.record(z.string(), z.unknown())
12163
+ });
12164
+ /** The degrade engine's report — what was resolved / dropped / degraded. */
12165
+ var RenderedAsSchema = z.object({
12166
+ level: z.string(),
12167
+ format: NotificationFormatSchema,
12168
+ attachmentsSent: z.number().int().nonnegative(),
12169
+ actionsSent: z.number().int().nonnegative(),
12170
+ truncated: z.boolean(),
12171
+ dropped: z.array(z.string())
12172
+ });
12173
+ var SendResultSchema = z.object({
12174
+ success: z.boolean(),
12175
+ error: z.string().optional(),
12176
+ renderedAs: RenderedAsSchema.optional()
12177
+ });
12178
+ /** Same shape as SendResult — kept as a distinct name for the test panel. */
12179
+ var TestResultSchema = SendResultSchema;
12180
+ /**
12181
+ * Pre-save credential probe against a partial (unsaved) target config.
12182
+ * `resolvedUrl` never includes secrets (token stripped from path).
12183
+ */
12184
+ var ProbeTargetConfigResultSchema = z.object({
12185
+ ok: z.boolean(),
12186
+ resolvedUrl: z.string(),
12187
+ httpStatus: z.number().int().optional(),
12188
+ stateInstance: z.string().optional(),
12189
+ error: z.string().optional()
12190
+ });
12191
+ var notificationOutputCapability = {
12192
+ name: "notification-output",
12193
+ scope: "system",
12194
+ mode: "collection",
12195
+ methods: {
12196
+ listTargetKinds: method(z.object({}), z.array(TargetKindSchema)),
12197
+ listTargets: method(z.object({}), z.array(TargetSchema), { auth: "admin" }),
12198
+ /**
12199
+ * One target WITH secrets — admin edit / duplicate hydration only.
12200
+ * `listTargets` stays redacted; the editor loads this so password fields
12201
+ * are filled (masked in the input) and a save can round-trip the token
12202
+ * when a destination changes (Duplicate with a new chatId, etc.).
12203
+ */
12204
+ getTarget: method(z.object({ targetId: z.string() }), TargetSchema, { auth: "admin" }),
12205
+ discoverTargets: method(z.object({
12206
+ kind: z.string(),
12207
+ config: z.record(z.string(), z.unknown()).optional(),
12208
+ /**
12209
+ * When editing / duplicating, the blank password field never round-trips
12210
+ * the stored token. Pass the source target id so the provider can restore
12211
+ * secrets server-side before dialling (same merge as upsert).
12212
+ */
12213
+ targetId: z.string().optional()
12214
+ }), z.array(DiscoveredTargetSchema), { auth: "admin" }),
12215
+ probeTargetConfig: method(z.object({
12216
+ kind: z.string(),
12217
+ config: z.record(z.string(), z.unknown()),
12218
+ /** See `discoverTargets.targetId` — restore stored secrets for a blank password. */
12219
+ targetId: z.string().optional()
12220
+ }), ProbeTargetConfigResultSchema, {
12221
+ kind: "mutation",
12222
+ auth: "admin"
12223
+ }),
12224
+ send: method(z.object({
12225
+ targetId: z.string(),
12226
+ notification: NotificationSchema
12227
+ }), SendResultSchema, {
12228
+ kind: "mutation",
12229
+ auth: "admin"
12230
+ }),
12231
+ testTarget: method(z.object({
12232
+ targetId: z.string(),
12233
+ sample: NotificationSchema.optional()
12234
+ }), TestResultSchema, {
12235
+ kind: "mutation",
12236
+ auth: "admin"
12237
+ }),
12238
+ upsertTarget: method(z.object({
12239
+ target: TargetSchema,
12240
+ /**
12241
+ * Duplicate flow: create a NEW target id while copying secrets from an
12242
+ * existing row. The UI never holds the stored token; blank / redacted
12243
+ * password fields are restored from this source (D634 still applies if
12244
+ * destinations diverge without a re-typed secret).
12245
+ */
12246
+ cloneSecretsFrom: z.string().optional()
12247
+ }), TargetSchema, {
12248
+ kind: "mutation",
12249
+ auth: "admin"
12250
+ }),
12251
+ deleteTarget: method(z.object({ targetId: z.string() }), z.void(), {
12252
+ kind: "mutation",
12253
+ auth: "admin"
12254
+ }),
12255
+ setTargetEnabled: method(z.object({
12256
+ targetId: z.string(),
12257
+ enabled: z.boolean()
12258
+ }), z.void(), {
12259
+ kind: "mutation",
12260
+ auth: "admin"
12261
+ })
12262
+ }
12263
+ };
12264
+ z.looseObject({
12265
+ name: z.string().min(1),
12266
+ enabled: z.boolean().optional()
12267
+ });
12268
+ TargetSchema.omit({ id: true });
12269
+ /**
11784
12270
  * Shared video / audio encode profile schemas used by every consumer
11785
12271
  * that asks the stream broker to spawn a derived stream
11786
12272
  * (WebRTC, HAP, Alexa, custom addons).
@@ -20812,7 +21298,6 @@ var SYSTEM_CAP_VOCABULARY = {
20812
21298
  "calendar-source": system(INTERNAL),
20813
21299
  calendars: system("calendars feed schedules and conditions, not device actions"),
20814
21300
  composer: system("device composition — an authoring tool, not an action"),
20815
- "connection-test": system(INTERNAL),
20816
21301
  "core-blocks": system(INTERNAL),
20817
21302
  "custom-model-registry": system(ML),
20818
21303
  "data-store-provider": system(INTERNAL),
@@ -44492,451 +44977,6 @@ function normalizeActionUnits(actions, resolver, path = "steps") {
44492
44977
  warnings
44493
44978
  };
44494
44979
  }
44495
- /**
44496
- * notification-output — canonical, capability-gated notification delivery.
44497
- *
44498
- * Apprise-derived model (see
44499
- * `docs/superpowers/specs/2026-07-03-notification-output-notifier-matrix.md`):
44500
- * callers emit ONE canonical `Notification`; each provider declares a
44501
- * per-kind capability descriptor (`TargetKind`), and the pure degrade
44502
- * engine (`@camstack/types` `prepareNotification`) transcodes / degrades the
44503
- * message to what the kind supports — callers never special-case a service.
44504
- *
44505
- * DESIGN DECISIONS (locked):
44506
- * - Target CRUD lives on THIS cap (`upsertTarget` / `deleteTarget` /
44507
- * `setTargetEnabled`), each provider persisting via the `settings-store`
44508
- * cap. Rationale: the admin UI needs one uniform surface across the
44509
- * notifiers addon AND the HA addon; the addon-`globalSettingsSchema`-array
44510
- * alternative would fork the UI per addon and cannot host the
44511
- * discovery→adopt flow.
44512
- * - `listTargetKinds` / `listTargets` / `discoverTargets` return arrays →
44513
- * the generated cap-mount auto-`concatCollection`-fans them across every
44514
- * registered provider (notifiers addon + HA addon) so one catalog is
44515
- * routable. `send` / `testTarget` / CRUD route to ONE provider by the
44516
- * `addonId` the generated collection router extracts from the call input.
44517
- * - `Attachment.bytes` is `Uint8Array`. Transport-safe: superjson (the tRPC
44518
- * transformer) + UDS MsgPack both round-trip typed arrays — already used by
44519
- * `storage` / `storage-provider` / `recording` caps over the same path. No
44520
- * base64 fallback needed.
44521
- *
44522
- * TODO (deferred, closed-set change — separate decision): add
44523
- * `providerKind: 'notify'` so notification providers surface on the unified
44524
- * admin "Integrations" page.
44525
- */
44526
- /**
44527
- * Zentik-derived typed-media enum — the superset across every kind. Each
44528
- * adapter picks what it supports and the degrade engine filters the rest.
44529
- */
44530
- var AttachmentMediaTypeSchema = z.enum([
44531
- "image",
44532
- "video",
44533
- "gif",
44534
- "audio",
44535
- "icon"
44536
- ]);
44537
- /**
44538
- * A single attachment. Exactly one of `url` (remote source, most adapters
44539
- * prefer this) or `bytes` (inline source; required for Pushover-style
44540
- * bytes-only kinds) MUST be present — the degrade engine expresses a
44541
- * url→bytes fetch as a `needsFetch` directive the adapter executes.
44542
- */
44543
- var AttachmentSchema = z.object({
44544
- mediaType: AttachmentMediaTypeSchema,
44545
- url: z.string().optional(),
44546
- bytes: z.instanceof(Uint8Array).optional(),
44547
- mime: z.string().optional(),
44548
- name: z.string().optional()
44549
- }).refine((a) => a.url !== void 0 || a.bytes !== void 0, { message: "Attachment requires either `url` or `bytes`" });
44550
- var NotificationFormatSchema = z.enum([
44551
- "text",
44552
- "markdown",
44553
- "html"
44554
- ]);
44555
- /**
44556
- * The CLOSED icon vocabulary an action button may use.
44557
- *
44558
- * A closed set, not a free string, and that is the whole point: an arbitrary
44559
- * icon name is one that ntfy renders, zentik silently drops, and nobody
44560
- * notices — the same class of gap as a zone vocabulary nothing produced
44561
- * ([D35](../../../docs/decisions/adr-0035.md)). Every adapter maps this set or
44562
- * declares `actionIcons: false` and the degrade engine strips the field.
44563
- *
44564
- * Named by INTENT, never by glyph. "check" would tie the vocabulary to one
44565
- * renderer's icon set; "acknowledge" survives an adapter that draws it
44566
- * differently.
44567
- *
44568
- * ── A TOKEN IS NOT A WIRE VALUE ─────────────────────────────────────
44569
- *
44570
- * These names are for US. **No adapter may forward one verbatim.** Each maps
44571
- * the whole set onto its own renderer's vocabulary through a
44572
- * `Record<NotificationActionIcon, string>` — a Record, never a lookup with a
44573
- * fallback, so adding a member here fails every adapter's build until someone
44574
- * decides its glyph, which is the only place that decision can be made
44575
- * honestly.
44576
- *
44577
- * This paragraph is the bug. Zentik declared `actionIcons: true` and passed
44578
- * `disarm` straight through; iOS feeds that string to
44579
- * `UNNotificationActionIcon(systemImageName:)`, `disarm` is not an SF Symbol,
44580
- * and every snooze and alarm button arrived BLANK. A pass-through is not a
44581
- * mapping, and "the field is documented" is not "the value renders".
44582
- *
44583
- * Adding a member is TRAIN-BOUND. The enum lives in the published
44584
- * `@camstack/server` closure and the cap seam validates against the HUB's copy,
44585
- * so an addon that emits a token the running hub does not know does not lose an
44586
- * icon — its whole `send` fails Zod validation and the notification never
44587
- * arrives. Never emit a new token from an addon before the train carrying it.
44588
- */
44589
- var NotificationActionIconSchema = z.enum([
44590
- "acknowledge",
44591
- "dismiss",
44592
- "silence",
44593
- "snooze",
44594
- "view",
44595
- "play",
44596
- "open",
44597
- "close",
44598
- "lock",
44599
- "unlock",
44600
- "arm",
44601
- "arm-home",
44602
- "arm-away",
44603
- "arm-night",
44604
- "disarm",
44605
- "light",
44606
- "alert",
44607
- "camera"
44608
- ]);
44609
- /** A single tap-through action button. */
44610
- var NotificationActionSchema = z.object({
44611
- id: z.string(),
44612
- label: z.string(),
44613
- url: z.string().optional(),
44614
- /** Dropped by the degrade engine for a kind with `caps.actionIcons: false`. */
44615
- icon: NotificationActionIconSchema.optional(),
44616
- /**
44617
- * Renders in a warning style where the notifier supports it.
44618
- *
44619
- * A HINT, never a gate. The callback's authority is its token and nothing
44620
- * else — see `notification-center/action-token.ts` for what that does and
44621
- * does not buy.
44622
- */
44623
- destructive: z.boolean().optional(),
44624
- /**
44625
- * How the tap should REACH the url.
44626
- *
44627
- * `navigate` (absent, and every button authored before this field) opens it:
44628
- * the phone leaves the notification and shows whatever the callback returns.
44629
- * That is right for a button whose answer the operator wants to read.
44630
- *
44631
- * `background` fires it as a POST and stays put. It exists for the buttons
44632
- * whose whole point is not to interrupt — "silence this for 30 minutes" is
44633
- * an answer to the notification, and being thrown into a browser tab to
44634
- * confirm it costs more attention than the notification did. A backend that
44635
- * cannot do a background call renders it as an ordinary link (the adapters
44636
- * fall back rather than dropping the button), so this is a preference, never
44637
- * a requirement.
44638
- */
44639
- mode: z.enum(["navigate", "background"]).optional()
44640
- });
44641
- /** A delivery parameter value: what a notifier declared it takes. */
44642
- var DeliveryParamValueSchema = z.union([
44643
- z.string(),
44644
- z.number(),
44645
- z.boolean()
44646
- ]);
44647
- /**
44648
- * One extra delivery parameter a notifier KIND declares (D938). A rule that
44649
- * addresses a target of that kind may set it; a kind that declares nothing is
44650
- * never handed one. The admin UI derives its control from this descriptor —
44651
- * no editor knows a service by name.
44652
- *
44653
- * Optional fields are `.optional()`, never `.default()` (a Zod default does not
44654
- * run on the addon cap path).
44655
- */
44656
- var DeliveryParamSchema = z.object({
44657
- key: z.string().min(1),
44658
- label: z.string(),
44659
- /** i18n key of the label, resolved by the declaring addon's namespace. */
44660
- labelKey: z.string().optional(),
44661
- type: z.enum([
44662
- "enum",
44663
- "number",
44664
- "boolean",
44665
- "string"
44666
- ]),
44667
- /** `enum` only: the closed set of accepted values. */
44668
- options: z.array(z.object({
44669
- value: z.string(),
44670
- label: z.string()
44671
- })).optional(),
44672
- /** `number` only. */
44673
- min: z.number().optional(),
44674
- max: z.number().optional(),
44675
- /** What the notifier does when the rule sets nothing; shown as the placeholder. */
44676
- default: DeliveryParamValueSchema.optional()
44677
- });
44678
- /**
44679
- * The canonical notification. `body` is the only hard field (Apprise model).
44680
- * `priority` is a 5-level ORDINAL (1=lowest … 3=normal(default) … 5=urgent),
44681
- * NOT a fixed severity enum — each kind declares its own `caps.levels` and
44682
- * the adapter maps this ordinal onto its native level. `level?` is an
44683
- * optional kind-native level id (`emergency`, `silent`, …) that overrides
44684
- * `priority` for that one target.
44685
- */
44686
- var NotificationSchema = z.object({
44687
- body: z.string(),
44688
- title: z.string().optional(),
44689
- format: NotificationFormatSchema.default("text"),
44690
- priority: z.number().int().min(1).max(5).default(3),
44691
- level: z.string().optional(),
44692
- attachments: z.array(AttachmentSchema).optional(),
44693
- clickUrl: z.string().optional(),
44694
- actions: z.array(NotificationActionSchema).optional(),
44695
- sound: z.string().optional(),
44696
- ttl: z.number().optional(),
44697
- tag: z.string().optional(),
44698
- deviceId: z.number().optional(),
44699
- eventId: z.string().optional(),
44700
- metadata: z.record(z.string(), z.unknown()).optional(),
44701
- /**
44702
- * Values for the parameters the target's kind DECLARES in
44703
- * {@link TargetKindSchema} `deliveryParams`. Already validated against the
44704
- * declaration by the sender; a notifier reads only the keys it declared.
44705
- */
44706
- delivery: z.record(z.string(), DeliveryParamValueSchema).optional()
44707
- });
44708
- /** One declared native severity/priority level for a kind. */
44709
- var TargetKindLevelSchema = z.object({
44710
- id: z.string(),
44711
- label: z.string(),
44712
- /** Which canonical priority (1..5) this level maps to. `null` = qualitative-only. */
44713
- ordinal: z.number().int().min(1).max(5).nullable(),
44714
- flags: z.object({
44715
- critical: z.boolean().optional(),
44716
- silent: z.boolean().optional(),
44717
- noPush: z.boolean().optional()
44718
- }).optional(),
44719
- /** e.g. Pushover `emergency` requires `retry` / `expire`. */
44720
- requires: z.array(z.string()).optional(),
44721
- description: z.string().optional()
44722
- });
44723
- /** Attachment capabilities for a kind (drives the degrade engine + test panel). */
44724
- var TargetKindAttachmentsCapsSchema = z.object({
44725
- mediaTypes: z.array(AttachmentMediaTypeSchema),
44726
- mode: z.enum([
44727
- "url",
44728
- "bytes",
44729
- "both"
44730
- ]),
44731
- max: z.number().int().nonnegative(),
44732
- maxBytes: z.number().int().positive().optional()
44733
- });
44734
- /** The full capability block consulted before dispatch. */
44735
- var TargetKindCapsSchema = z.object({
44736
- attachments: TargetKindAttachmentsCapsSchema,
44737
- /** Max action buttons (0 = none). */
44738
- actions: z.number().int().nonnegative(),
44739
- /**
44740
- * Whether this kind renders a per-action ICON.
44741
- *
44742
- * `.optional()`, deliberately NOT `.default(false)`: a Zod default does not
44743
- * run on the addon cap path — three production failures in one day taught
44744
- * this repo that once. Absent is read as false by the degrade engine, which
44745
- * is the safe direction: an icon that is not rendered costs nothing, an icon
44746
- * assumed and dropped costs the operator's trust in the field.
44747
- */
44748
- actionIcons: z.boolean().optional(),
44749
- levels: z.array(TargetKindLevelSchema),
44750
- format: z.array(NotificationFormatSchema),
44751
- clickUrl: z.boolean(),
44752
- sound: z.boolean(),
44753
- ttl: z.boolean(),
44754
- bodyMaxLen: z.number().int().positive()
44755
- });
44756
- /**
44757
- * `configSchema` is a `ConfigUISchema` tree passed through to the admin
44758
- * FormBuilder. Stored as `z.unknown()` at the cap seam (mirrors
44759
- * `device-provider.getChildCreationSchema` `CreationSchemaOutputSchema`) —
44760
- * the union is large and not meant for runtime validation here; the exported
44761
- * `TargetKind` type re-tightens `configSchema` to `ConfigUISchema`.
44762
- */
44763
- var ConfigSchemaPassthrough$4 = z.unknown();
44764
- var TargetKindSchema = z.object({
44765
- kind: z.string(),
44766
- label: z.string(),
44767
- icon: z.string(),
44768
- /** Stamped by each provider so the concat-fanned catalog stays routable. */
44769
- addonId: z.string(),
44770
- /**
44771
- * URL of the kind's bundled BRAND icon, served by the providing addon over
44772
- * its own `addon-routes` surface (`/addon/<addonId>/icons/<kind>`). Absent
44773
- * when the addon bundles no icon for that kind — the client then falls back
44774
- * to a neutral glyph rather than rendering the raw `icon` NAME as text.
44775
- *
44776
- * Root-relative on purpose: it resolves against whatever origin serves a web
44777
- * client, and a native client joins it onto its own hub base.
44778
- *
44779
- * DECLARED here deliberately. It used to travel as an undeclared passthrough
44780
- * field that survived only because the runtime cap-router forwards provider
44781
- * output verbatim — so every consumer had to re-declare it by hand to stop
44782
- * its own Zod parse from stripping it, and the whole arrangement would have
44783
- * broken silently the moment output validation was tightened anywhere.
44784
- */
44785
- iconUrl: z.string().optional(),
44786
- /**
44787
- * Media type of {@link iconUrl} (`image/svg+xml`, `image/png`, …).
44788
- *
44789
- * The server knows this and therefore says it, because the client cannot
44790
- * safely guess: a React-Native client renders SVG and raster through two
44791
- * DIFFERENT components (`react-native-svg` vs `expo-image` — expo-image does
44792
- * not decode SVG on iOS/Android), so without this it silently fell back to a
44793
- * placeholder glyph for every vector icon while the web build looked fine.
44794
- *
44795
- * Absent when {@link iconUrl} is absent, or for a legacy provider that has
44796
- * not been updated — a client that cannot determine the type should prefer
44797
- * its raster path, which is the safe default for an unknown image.
44798
- */
44799
- iconMediaType: z.string().optional(),
44800
- configSchema: ConfigSchemaPassthrough$4,
44801
- /**
44802
- * The config keys that decide WHERE this kind's secrets are sent (server,
44803
- * base URL, instance, chat, recipient). A save that changes any of them
44804
- * while leaving a secret redacted is refused by the provider (D634), so an
44805
- * editor uses this to ask for the secret on exactly those edits instead of
44806
- * on every edit.
44807
- *
44808
- * Optional: absent from a provider that holds no secret (the Home Assistant
44809
- * kinds) and from a provider older than this field — an editor that finds
44810
- * it absent must assume ANY edit may need the secret.
44811
- */
44812
- destinationKeys: z.array(z.string()).optional(),
44813
- supportsDiscovery: z.boolean(),
44814
- /**
44815
- * Extra delivery parameters a rule may set for a target of this kind (D938).
44816
- * Absent = none; the rule editor then offers nothing.
44817
- */
44818
- deliveryParams: z.array(DeliveryParamSchema).optional(),
44819
- caps: TargetKindCapsSchema
44820
- });
44821
- /**
44822
- * A persisted target. `config` holds secrets; providers REDACT secret fields
44823
- * (return a presence marker only) when serving `listTargets` — never
44824
- * round-trip a stored secret to the UI.
44825
- */
44826
- var TargetSchema = z.object({
44827
- id: z.string(),
44828
- name: z.string(),
44829
- kind: z.string(),
44830
- addonId: z.string(),
44831
- enabled: z.boolean(),
44832
- config: z.record(z.string(), z.unknown())
44833
- });
44834
- /** A discovery-surfaced candidate (config is partial + non-secret). */
44835
- var DiscoveredTargetSchema = z.object({
44836
- kind: z.string(),
44837
- suggestedName: z.string(),
44838
- config: z.record(z.string(), z.unknown())
44839
- });
44840
- /** The degrade engine's report — what was resolved / dropped / degraded. */
44841
- var RenderedAsSchema = z.object({
44842
- level: z.string(),
44843
- format: NotificationFormatSchema,
44844
- attachmentsSent: z.number().int().nonnegative(),
44845
- actionsSent: z.number().int().nonnegative(),
44846
- truncated: z.boolean(),
44847
- dropped: z.array(z.string())
44848
- });
44849
- var SendResultSchema = z.object({
44850
- success: z.boolean(),
44851
- error: z.string().optional(),
44852
- renderedAs: RenderedAsSchema.optional()
44853
- });
44854
- /** Same shape as SendResult — kept as a distinct name for the test panel. */
44855
- var TestResultSchema = SendResultSchema;
44856
- /**
44857
- * Pre-save credential probe against a partial (unsaved) target config.
44858
- * `resolvedUrl` never includes secrets (token stripped from path).
44859
- */
44860
- var ProbeTargetConfigResultSchema = z.object({
44861
- ok: z.boolean(),
44862
- resolvedUrl: z.string(),
44863
- httpStatus: z.number().int().optional(),
44864
- stateInstance: z.string().optional(),
44865
- error: z.string().optional()
44866
- });
44867
- var notificationOutputCapability = {
44868
- name: "notification-output",
44869
- scope: "system",
44870
- mode: "collection",
44871
- methods: {
44872
- listTargetKinds: method(z.object({}), z.array(TargetKindSchema)),
44873
- listTargets: method(z.object({}), z.array(TargetSchema), { auth: "admin" }),
44874
- /**
44875
- * One target WITH secrets — admin edit / duplicate hydration only.
44876
- * `listTargets` stays redacted; the editor loads this so password fields
44877
- * are filled (masked in the input) and a save can round-trip the token
44878
- * when a destination changes (Duplicate with a new chatId, etc.).
44879
- */
44880
- getTarget: method(z.object({ targetId: z.string() }), TargetSchema, { auth: "admin" }),
44881
- discoverTargets: method(z.object({
44882
- kind: z.string(),
44883
- config: z.record(z.string(), z.unknown()).optional(),
44884
- /**
44885
- * When editing / duplicating, the blank password field never round-trips
44886
- * the stored token. Pass the source target id so the provider can restore
44887
- * secrets server-side before dialling (same merge as upsert).
44888
- */
44889
- targetId: z.string().optional()
44890
- }), z.array(DiscoveredTargetSchema), { auth: "admin" }),
44891
- probeTargetConfig: method(z.object({
44892
- kind: z.string(),
44893
- config: z.record(z.string(), z.unknown()),
44894
- /** See `discoverTargets.targetId` — restore stored secrets for a blank password. */
44895
- targetId: z.string().optional()
44896
- }), ProbeTargetConfigResultSchema, {
44897
- kind: "mutation",
44898
- auth: "admin"
44899
- }),
44900
- send: method(z.object({
44901
- targetId: z.string(),
44902
- notification: NotificationSchema
44903
- }), SendResultSchema, {
44904
- kind: "mutation",
44905
- auth: "admin"
44906
- }),
44907
- testTarget: method(z.object({
44908
- targetId: z.string(),
44909
- sample: NotificationSchema.optional()
44910
- }), TestResultSchema, {
44911
- kind: "mutation",
44912
- auth: "admin"
44913
- }),
44914
- upsertTarget: method(z.object({
44915
- target: TargetSchema,
44916
- /**
44917
- * Duplicate flow: create a NEW target id while copying secrets from an
44918
- * existing row. The UI never holds the stored token; blank / redacted
44919
- * password fields are restored from this source (D634 still applies if
44920
- * destinations diverge without a re-typed secret).
44921
- */
44922
- cloneSecretsFrom: z.string().optional()
44923
- }), TargetSchema, {
44924
- kind: "mutation",
44925
- auth: "admin"
44926
- }),
44927
- deleteTarget: method(z.object({ targetId: z.string() }), z.void(), {
44928
- kind: "mutation",
44929
- auth: "admin"
44930
- }),
44931
- setTargetEnabled: method(z.object({
44932
- targetId: z.string(),
44933
- enabled: z.boolean()
44934
- }), z.void(), {
44935
- kind: "mutation",
44936
- auth: "admin"
44937
- })
44938
- }
44939
- };
44940
44980
  z.enum([
44941
44981
  "automation",
44942
44982
  "action",
@@ -50842,45 +50882,6 @@ var composerCapability = {
50842
50882
  getStates: method(z.object({ blockIds: z.array(z.string()) }), z.object({ states: z.array(CompositionBlockStateSchema) }), { auth: "admin" })
50843
50883
  }
50844
50884
  };
50845
- var ConnectionTestOutcomeSchema = z.discriminatedUnion("outcome", [
50846
- z.object({
50847
- outcome: z.literal("validated"),
50848
- /** Round-trip of the sign-in, when the provider measured it. */
50849
- latencyMs: z.number().nonnegative().optional(),
50850
- /** Optional human detail worth showing next to the tick
50851
- * ("3 devices visible on this account"). */
50852
- detail: z.string().optional()
50853
- }).strict(),
50854
- z.object({
50855
- outcome: z.literal("rejected"),
50856
- error: z.string()
50857
- }).strict(),
50858
- z.object({
50859
- outcome: z.literal("inconclusive"),
50860
- error: z.string()
50861
- }).strict()
50862
- ]);
50863
- var ConnectionTestInputSchema = z.object({
50864
- /** Candidate integration settings, exactly as the create form collected them. */
50865
- settings: z.record(z.string(), z.unknown()) });
50866
- /**
50867
- * What the provider's test actually DOES, so the UI can say it in words before
50868
- * the operator presses the button ("Signs in to the Dreo cloud"). Purely
50869
- * descriptive — it never changes routing.
50870
- */
50871
- var ConnectionTestDescriptorSchema = z.object({ label: z.string() });
50872
- var connectionTestCapability = {
50873
- name: "connection-test",
50874
- scope: "system",
50875
- mode: "collection",
50876
- methods: {
50877
- testSettings: method(ConnectionTestInputSchema, ConnectionTestOutcomeSchema, {
50878
- kind: "mutation",
50879
- auth: "admin"
50880
- }),
50881
- describeTest: method(z.void(), ConnectionTestDescriptorSchema, { auth: "admin" })
50882
- }
50883
- };
50884
50885
  /**
50885
50886
  * Upstream-system connectivity sensor — distinct from `device-status`,
50886
50887
  * which is the kernel-managed online/offline flag for the device's
@@ -62456,10 +62457,9 @@ var AvailableIntegrationTypeSchema = z.object({
62456
62457
  * locations" checkbox. Provider-declared in the addon manifest. */
62457
62458
  supportsLocationImport: z.boolean(),
62458
62459
  /**
62459
- * True when this integration DECLARES a pre-creation test (the
62460
- * `connection-test` cap, or a broker whose settings it stores). Drives the
62461
- * Test button: an integration that cannot be tested must say so up front
62462
- * rather than offering a button that always answers the same nonsense.
62460
+ * True when this integration's instances declare a Test (`integration-instances.describe().canTest`,
62461
+ * D1016). An integration that cannot be tested must say so up front rather than offering a
62462
+ * button that always answers the same nonsense.
62463
62463
  */
62464
62464
  canTest: z.boolean(),
62465
62465
  existingInstances: z.array(z.object({
@@ -62513,7 +62513,9 @@ var CreateIntegrationInputSchema = z.object({
62513
62513
  info: z.record(z.string(), z.unknown()).optional(),
62514
62514
  /** `stableId` of the discovery candidate the form was seeded from (D984). */
62515
62515
  originStableId: z.string().optional(),
62516
- settings: z.record(z.string(), z.unknown()).optional()
62516
+ settings: z.record(z.string(), z.unknown()).optional(),
62517
+ /** The instance kind being created, for a provider with several; omitted = its only testable kind. */
62518
+ kind: z.string().min(1).optional()
62517
62519
  });
62518
62520
  var UpdateIntegrationInputSchema = z.object({
62519
62521
  id: z.string(),
@@ -62550,14 +62552,7 @@ var integrationsCapability = {
62550
62552
  kind: "mutation",
62551
62553
  auth: "admin"
62552
62554
  }),
62553
- getAvailableTypes: method(z.void(), z.array(AvailableIntegrationTypeSchema), { auth: "admin" }),
62554
- testConnection: method(z.object({
62555
- addonId: z.string(),
62556
- settings: z.record(z.string(), z.unknown())
62557
- }), TestConnectionResultSchema, {
62558
- kind: "mutation",
62559
- auth: "admin"
62560
- })
62555
+ getAvailableTypes: method(z.void(), z.array(AvailableIntegrationTypeSchema), { auth: "admin" })
62561
62556
  },
62562
62557
  /** BIG PLAN 2: declarative mount hint — read by `@camstack/server/system` `buildCapRouters`. */
62563
62558
  mount: { kind: "server-provided" }
@@ -73796,13 +73791,6 @@ var AddBrokerInputSchema = z.object({
73796
73791
  });
73797
73792
  var AddBrokerResultSchema = z.object({ id: z.string() });
73798
73793
  var IdInputSchema = z.object({ id: z.string() });
73799
- var TestResultSchema$1 = z.discriminatedUnion("ok", [z.object({
73800
- ok: z.literal(true),
73801
- latencyMs: z.number()
73802
- }), z.object({
73803
- ok: z.literal(false),
73804
- error: z.string()
73805
- })]);
73806
73794
  var StartEmbeddedInputSchema = z.object({
73807
73795
  port: z.number().int().min(1).max(65535).default(1883),
73808
73796
  /** Allow anonymous connect (no username/password). Default: false. */
@@ -73839,10 +73827,6 @@ var mqttBrokerCapability = {
73839
73827
  kind: "mutation",
73840
73828
  auth: "admin"
73841
73829
  }),
73842
- testConnection: method(IdInputSchema, TestResultSchema$1, {
73843
- kind: "mutation",
73844
- auth: "admin"
73845
- }),
73846
73830
  startEmbeddedBroker: method(StartEmbeddedInputSchema, StartEmbeddedResultSchema, {
73847
73831
  kind: "mutation",
73848
73832
  auth: "admin"
@@ -89596,7 +89580,7 @@ var TrainingProviderTypeSchema = z.object({
89596
89580
  label: z.string(),
89597
89581
  /** Path under the addon package (e.g. `assets/training-modal/icon.svg`). */
89598
89582
  iconAsset: z.string(),
89599
- /** Owning `training-provider` addon — collection selector for createEntry. */
89583
+ /** Owning `training-provider` addon. */
89600
89584
  addonId: z.string(),
89601
89585
  /**
89602
89586
  * Fields for one entry of this type (credentials + defaults). Absent on a
@@ -89641,36 +89625,6 @@ var TrainingProviderDescriptorSchema = z.object({
89641
89625
  */
89642
89626
  formValues: z.record(z.string(), z.unknown()).optional()
89643
89627
  });
89644
- /**
89645
- * Patch one entry's name, credentials and defaults. Pin with owning `{ addonId }`.
89646
- * An omitted or empty `tokenSecret` means KEEP the stored secret (D787).
89647
- * `{ $secretClear: true }` clears it.
89648
- */
89649
- var TrainingProviderUpdateEntryInputSchema = z.object({
89650
- entryId: z.string().min(1),
89651
- name: z.string().min(1),
89652
- tokenId: z.string().optional(),
89653
- tokenSecret: z.union([z.string(), z.object({ $secretClear: z.literal(true) })]).optional(),
89654
- environment: z.string().optional(),
89655
- gpuType: z.string().optional(),
89656
- region: z.string().optional(),
89657
- costCapUsd: z.number().nonnegative().optional(),
89658
- maxRuntimeSec: z.number().int().positive().optional(),
89659
- failedDatasetGraceHours: z.number().nonnegative().optional()
89660
- });
89661
- var TrainingCredentialCheckSchema = z.object({
89662
- ok: z.boolean(),
89663
- /** Workspace / account name, when the provider says. */
89664
- account: z.string().optional(),
89665
- reason: z.enum([
89666
- "missing",
89667
- "invalid",
89668
- "forbidden",
89669
- "network",
89670
- "quota"
89671
- ]).optional(),
89672
- detail: z.string().optional()
89673
- });
89674
89628
  var ProviderJobStateSchema = z.enum([
89675
89629
  "pending",
89676
89630
  "starting",
@@ -89729,36 +89683,6 @@ var trainingProviderCapability = {
89729
89683
  describeTypes: method(z.object({}), z.array(TrainingProviderTypeSchema).readonly(), { auth: "admin" }),
89730
89684
  /** Configured entries (pills). Concat-fans. */
89731
89685
  listEntries: method(z.object({}), z.array(TrainingProviderEntrySchema).readonly(), { auth: "admin" }),
89732
- /**
89733
- * Create an entry under this provider type. Pin with `{ addonId }` of the
89734
- * type's owning addon (from describeTypes).
89735
- */
89736
- createEntry: method(z.object({
89737
- typeId: z.string().min(1),
89738
- name: z.string().min(1)
89739
- }), z.object({ entryId: z.string() }), {
89740
- kind: "mutation",
89741
- auth: "admin"
89742
- }),
89743
- /** Delete an entry. Pin with the owning `{ addonId }`. */
89744
- deleteEntry: method(z.object({ entryId: z.string().min(1) }), z.object({ ok: z.literal(true) }), {
89745
- kind: "mutation",
89746
- auth: "admin"
89747
- }),
89748
- /**
89749
- * Update one entry (name, credentials, defaults). Pin with owning
89750
- * `{ addonId }`. Empty/omitted `tokenSecret` keeps the stored secret.
89751
- */
89752
- updateEntry: method(TrainingProviderUpdateEntryInputSchema, z.object({ ok: z.literal(true) }), {
89753
- kind: "mutation",
89754
- auth: "admin"
89755
- }),
89756
- /** Call the provider with the entry's stored credentials. Never returns them. */
89757
- validateCredentials: method(z.object({ entryId: z.string().min(1) }), TrainingCredentialCheckSchema, {
89758
- kind: "mutation",
89759
- auth: "admin",
89760
- timeoutMs: 3e4
89761
- }),
89762
89686
  /** USD range for a run of `gpuSeconds` on `gpuType` in `region`. */
89763
89687
  estimateJob: method(z.object({
89764
89688
  entryId: z.string().min(1),
@@ -92410,7 +92334,6 @@ var ALL_CAPABILITY_DEFINITIONS = [
92410
92334
  climateControlCapability,
92411
92335
  colorCapability,
92412
92336
  composerCapability,
92413
- connectionTestCapability,
92414
92337
  connectivityCapability,
92415
92338
  consumablesCapability,
92416
92339
  contactCapability,
@@ -97246,20 +97169,6 @@ var METHOD_ACCESS_MAP = Object.freeze({
97246
97169
  access: "view",
97247
97170
  role: "admin"
97248
97171
  },
97249
- "connectionTest.describeTest": {
97250
- capName: "connection-test",
97251
- capScope: "system",
97252
- addonId: null,
97253
- access: "view",
97254
- role: "admin"
97255
- },
97256
- "connectionTest.testSettings": {
97257
- capName: "connection-test",
97258
- capScope: "system",
97259
- addonId: null,
97260
- access: "create",
97261
- role: "admin"
97262
- },
97263
97172
  "connectivity.getStatus": {
97264
97173
  capName: "connectivity",
97265
97174
  capScope: "device",
@@ -99626,13 +99535,6 @@ var METHOD_ACCESS_MAP = Object.freeze({
99626
99535
  access: "view",
99627
99536
  role: "admin"
99628
99537
  },
99629
- "integrations.testConnection": {
99630
- capName: "integrations",
99631
- capScope: "system",
99632
- addonId: null,
99633
- access: "create",
99634
- role: "admin"
99635
- },
99636
99538
  "integrations.update": {
99637
99539
  capName: "integrations",
99638
99540
  capScope: "system",
@@ -100865,13 +100767,6 @@ var METHOD_ACCESS_MAP = Object.freeze({
100865
100767
  access: "create",
100866
100768
  role: "admin"
100867
100769
  },
100868
- "mqttBroker.testConnection": {
100869
- capName: "mqtt-broker",
100870
- capScope: "system",
100871
- addonId: null,
100872
- access: "create",
100873
- role: "admin"
100874
- },
100875
100770
  "nativeObjectDetection.getOptions": {
100876
100771
  capName: "native-object-detection",
100877
100772
  capScope: "device",
@@ -105702,20 +105597,6 @@ var METHOD_ACCESS_MAP = Object.freeze({
105702
105597
  access: "create",
105703
105598
  role: "admin"
105704
105599
  },
105705
- "trainingProvider.createEntry": {
105706
- capName: "training-provider",
105707
- capScope: "system",
105708
- addonId: null,
105709
- access: "create",
105710
- role: "admin"
105711
- },
105712
- "trainingProvider.deleteEntry": {
105713
- capName: "training-provider",
105714
- capScope: "system",
105715
- addonId: null,
105716
- access: "delete",
105717
- role: "admin"
105718
- },
105719
105600
  "trainingProvider.describe": {
105720
105601
  capName: "training-provider",
105721
105602
  capScope: "system",
@@ -105786,13 +105667,6 @@ var METHOD_ACCESS_MAP = Object.freeze({
105786
105667
  access: "create",
105787
105668
  role: "admin"
105788
105669
  },
105789
- "trainingProvider.updateEntry": {
105790
- capName: "training-provider",
105791
- capScope: "system",
105792
- addonId: null,
105793
- access: "create",
105794
- role: "admin"
105795
- },
105796
105670
  "trainingProvider.uploadDataset": {
105797
105671
  capName: "training-provider",
105798
105672
  capScope: "system",
@@ -105800,13 +105674,6 @@ var METHOD_ACCESS_MAP = Object.freeze({
105800
105674
  access: "create",
105801
105675
  role: "admin"
105802
105676
  },
105803
- "trainingProvider.validateCredentials": {
105804
- capName: "training-provider",
105805
- capScope: "system",
105806
- addonId: null,
105807
- access: "create",
105808
- role: "admin"
105809
- },
105810
105677
  "turnProvider.getTurnServers": {
105811
105678
  capName: "turn-provider",
105812
105679
  capScope: "system",