@camstack/addon-pipeline-orchestrator 1.2.663 → 1.2.664

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.
package/dist/index.js CHANGED
@@ -6012,7 +6012,7 @@ var ZodIssueCode = {
6012
6012
  var ZodFirstPartyTypeKind;
6013
6013
  ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {});
6014
6014
  //#endregion
6015
- //#region ../types/dist/sleep-BX_MqzUe.mjs
6015
+ //#region ../types/dist/sleep-D7ZKm4nb.mjs
6016
6016
  /**
6017
6017
  * The audio chunk plane's byte format, and the ONE expansion from a coded
6018
6018
  * window to float samples (D455).
@@ -6705,6 +6705,344 @@ async function runAddonMigrations(host, migrations, logger, options = {}) {
6705
6705
  blockOwner
6706
6706
  };
6707
6707
  }
6708
+ /** The record calls the one-switch migration makes, over the migration API. */
6709
+ function switchRecordsOverMigrationApi(api) {
6710
+ return { kind: (definition) => {
6711
+ const handle = api.records.kind(definition);
6712
+ return {
6713
+ get: (id) => handle.get({ id }),
6714
+ put: (input, opts) => handle.put({
6715
+ ...input,
6716
+ ...opts?.ifRev === void 0 ? {} : { ifRev: opts.ifRev }
6717
+ }),
6718
+ patch: (id, partial) => handle.patch({
6719
+ id,
6720
+ partial
6721
+ })
6722
+ };
6723
+ } };
6724
+ }
6725
+ function integrationRowsApiOver(api) {
6726
+ return {
6727
+ list: async () => (await api.integrations.list({})).integrations,
6728
+ readLegacyIntegrationRows: (input) => api.legacyRows.read(input),
6729
+ clearLegacyIntegrationRows: (input) => api.legacyRows.clear(input)
6730
+ };
6731
+ }
6732
+ var PREFIX = "records/";
6733
+ /**
6734
+ * Cross-realm brand. An addon bundles its own copy of this module (D15) while
6735
+ * `ctx.records` is the HOST's door, so an error thrown by the host is an
6736
+ * instance of the host's classes, not of the addon's. The brand plus the code
6737
+ * make `instanceof` answer by identity of the failure, not of the copy.
6738
+ */
6739
+ var RECORDS_ERROR_BRAND = Symbol.for("camstack.records-error");
6740
+ function carriesBrand(value) {
6741
+ return typeof value === "object" && value !== null && Reflect.get(value, RECORDS_ERROR_BRAND) === true;
6742
+ }
6743
+ /** The base of every records failure. `detail` is the human part of the message. */
6744
+ var RecordsError = class extends Error {
6745
+ /** The code a subclass stands for; the base stands for every code. */
6746
+ static code = void 0;
6747
+ /**
6748
+ * `instanceof` across copies of this module: any branded error is a
6749
+ * `RecordsError`, and is an instance of a subclass only when its code is the
6750
+ * subclass's code. Same-copy answers are unchanged.
6751
+ */
6752
+ static [Symbol.hasInstance](value) {
6753
+ if (Function.prototype[Symbol.hasInstance].call(this, value)) return true;
6754
+ if (!carriesBrand(value)) return false;
6755
+ return this.code === void 0 || value.code === this.code;
6756
+ }
6757
+ code;
6758
+ detail;
6759
+ [RECORDS_ERROR_BRAND] = true;
6760
+ constructor(code, detail) {
6761
+ super(`${PREFIX}${code}: ${detail}`);
6762
+ this.name = "RecordsError";
6763
+ this.code = code;
6764
+ this.detail = detail;
6765
+ }
6766
+ };
6767
+ var InvalidRecordError = class InvalidRecordError extends RecordsError {
6768
+ static code = "invalid-record";
6769
+ constructor(detail) {
6770
+ super(InvalidRecordError.code, detail);
6771
+ this.name = "InvalidRecordError";
6772
+ }
6773
+ };
6774
+ /** A kind declaration the engine refuses (non-additive change, bad shape, wrong file). */
6775
+ var DeclarationRefusedError = class DeclarationRefusedError extends RecordsError {
6776
+ static code = "declaration-refused";
6777
+ constructor(detail) {
6778
+ super(DeclarationRefusedError.code, detail);
6779
+ this.name = "DeclarationRefusedError";
6780
+ }
6781
+ };
6782
+ object({
6783
+ cap: string().min(1),
6784
+ kind: string().min(1).optional()
6785
+ });
6786
+ var GLOBAL_SCOPE = { kind: "global" };
6787
+ /** The scope every addon-wide (not per-node, not per-device) setting lives in. */
6788
+ function globalSecretScope() {
6789
+ return GLOBAL_SCOPE;
6790
+ }
6791
+ function encodeSegment(value) {
6792
+ return encodeURIComponent(value);
6793
+ }
6794
+ function decodeSegment(value) {
6795
+ try {
6796
+ return decodeURIComponent(value);
6797
+ } catch {
6798
+ return null;
6799
+ }
6800
+ }
6801
+ /**
6802
+ * The field path of a value inside an array item, addressed by the item's id:
6803
+ * `arrayItemFieldPath('providers', 'authentik', 'clientSecret')` →
6804
+ * `providers[authentik].clientSecret`.
6805
+ */
6806
+ function arrayItemFieldPath(arrayKey, itemId, fieldKey) {
6807
+ return `${arrayKey}[${encodeSegment(itemId)}].${fieldKey}`;
6808
+ }
6809
+ function parseScope(segments) {
6810
+ switch (segments[0]) {
6811
+ case "global": return {
6812
+ scope: GLOBAL_SCOPE,
6813
+ used: 1
6814
+ };
6815
+ case "node": {
6816
+ const nodeId = segments[1] !== void 0 ? decodeSegment(segments[1]) : null;
6817
+ return nodeId === null || nodeId.length === 0 ? null : {
6818
+ scope: {
6819
+ kind: "node",
6820
+ nodeId
6821
+ },
6822
+ used: 2
6823
+ };
6824
+ }
6825
+ case "device": {
6826
+ const raw = segments[1];
6827
+ if (raw === void 0 || !/^\d+$/.test(raw)) return null;
6828
+ return {
6829
+ scope: {
6830
+ kind: "device",
6831
+ deviceId: Number(raw)
6832
+ },
6833
+ used: 2
6834
+ };
6835
+ }
6836
+ case "integration": {
6837
+ const id = segments[1] !== void 0 ? decodeSegment(segments[1]) : null;
6838
+ return id === null || id.length === 0 ? null : {
6839
+ scope: {
6840
+ kind: "integration",
6841
+ integrationId: id
6842
+ },
6843
+ used: 2
6844
+ };
6845
+ }
6846
+ case "row": {
6847
+ const collection = segments[1] !== void 0 ? decodeSegment(segments[1]) : null;
6848
+ const rowId = segments[2] !== void 0 ? decodeSegment(segments[2]) : null;
6849
+ if (collection === null || rowId === null || collection.length === 0 || rowId.length === 0) return null;
6850
+ return {
6851
+ scope: {
6852
+ kind: "row",
6853
+ collection,
6854
+ rowId
6855
+ },
6856
+ used: 3
6857
+ };
6858
+ }
6859
+ default: return null;
6860
+ }
6861
+ }
6862
+ /** Take a ref apart; `null` when it is not a well-formed ref. */
6863
+ function parseSecretRef(ref) {
6864
+ if (!ref.startsWith("secret://")) return null;
6865
+ const segments = ref.slice(9).split("/");
6866
+ const owner = segments[0] !== void 0 ? decodeSegment(segments[0]) : null;
6867
+ if (owner === null || owner.length === 0) return null;
6868
+ const parsed = parseScope(segments.slice(1));
6869
+ if (parsed === null) return null;
6870
+ const fieldPath = segments.slice(1 + parsed.used).join("/");
6871
+ if (fieldPath.length === 0) return null;
6872
+ return {
6873
+ owner,
6874
+ scope: parsed.scope,
6875
+ fieldPath
6876
+ };
6877
+ }
6878
+ /** Limits and names of `ctx.records` (D881). One authority; the engine and the facade read it. */
6879
+ /** The files a kind may live in. `history` is device-history's (D850), never records. */
6880
+ var RECORD_DATABASES = ["settings", "events"];
6881
+ /** The classes of a kind: the `@durable` vocabulary, one authority (replaces the annotation). */
6882
+ var RECORD_CLASSES = [
6883
+ "config",
6884
+ "ledger",
6885
+ "audit",
6886
+ "mirror",
6887
+ "ephemeral"
6888
+ ];
6889
+ var RECORD_DEFAULT_MAX_DATA_BYTES = 64 * 1024;
6890
+ var RECORD_MAX_DATA_BYTES = 1024 * 1024;
6891
+ var RECORD_BATCH_MAX = 1e3;
6892
+ var RECORD_QUERY_MAX = 1e3;
6893
+ /** A kind in the `settings` file may not bound itself above this (D447: high volume is `events`). */
6894
+ var RECORD_SETTINGS_MAX_ROWS = 5e4;
6895
+ /**
6896
+ * Secret fields of a record, addressed the way a Zod schema declares them
6897
+ * (`collectZodSecretPaths`): dotted keys, `[]` for "each element of this array"
6898
+ * (`auth.accessToken`, `headers[].value`).
6899
+ *
6900
+ * `{}` after a key means "each value of this map" (`applianceSecrets{}`): the map's own key
6901
+ * names the value (`applianceSecrets{fridge}`), so no id key is declared and a body that drops a
6902
+ * key releases exactly that key's secret.
6903
+ *
6904
+ * Array elements are matched by a DECLARED id key (`secretArrayKeys`:
6905
+ * `{ headers: 'name' }`), never by index, so reordering a list keeps every
6906
+ * keychain ref (the same rule as `arrayItemFieldPath`). The concrete path of a
6907
+ * leaf names its element: `headers[X-Api].value`.
6908
+ *
6909
+ * Pure and browser-safe. Nothing here mutates: every transform returns a new value.
6910
+ */
6911
+ /** The array prefixes (declared form, e.g. `headers` or `a.headers`) of a path. */
6912
+ function parseSecretPath(path) {
6913
+ if (path.length === 0) throw new InvalidRecordError("an empty secret path");
6914
+ return path.split(".").map((raw) => {
6915
+ const each = raw.endsWith("[]");
6916
+ const map = raw.endsWith("{}");
6917
+ const key = each || map ? raw.slice(0, -2) : raw;
6918
+ if (key.length === 0) throw new InvalidRecordError(`secret path "${path}" has an empty segment`);
6919
+ return {
6920
+ key,
6921
+ each,
6922
+ map
6923
+ };
6924
+ });
6925
+ }
6926
+ /** The declared array prefixes of `path` that need an id key (`headers`, `a.rows`). */
6927
+ function secretArrayPrefixes(path) {
6928
+ const segments = parseSecretPath(path);
6929
+ const prefixes = [];
6930
+ const walked = [];
6931
+ for (const segment of segments) {
6932
+ walked.push(segment.key);
6933
+ if (segment.each) prefixes.push(walked.join("."));
6934
+ }
6935
+ return prefixes;
6936
+ }
6937
+ /** The body key of the switch; only {@link RecordIntegrationInstances.setInstanceEnabled} writes it. */
6938
+ var SWITCH_KEY = "enabled";
6939
+ /**
6940
+ * The one-switch migration (epic #440, step 3). An integration's on/off state used to live in the
6941
+ * registry's `enabled` column for a device addon; it now lives only in the instance record's
6942
+ * body (`enabled`, D1007 superseded). This moves a registry `enabled = false` into the body, once.
6943
+ *
6944
+ * For every registry row of the addon that is OFF:
6945
+ * - no record under its id: the record is created from `initialBody(name)` with `enabled: false`
6946
+ * (a default integration that never had settings, Reolink's among them);
6947
+ * - a record whose body states no `enabled`: `enabled: false` is written into it;
6948
+ * - a record that already states `enabled` (either way) is the newer truth and is left alone.
6949
+ * A row that is ON writes nothing: an absent field reads as on. A rerun finds every off row with
6950
+ * a stated switch and does nothing, so nothing switched off comes back on and nothing switched on
6951
+ * goes off. The registry column itself is neither read afterwards nor written; its drop is step 5.
6952
+ *
6953
+ * It runs in the addon process, BEFORE the addon registers its `integration-instances` provider,
6954
+ * which is also why `integrations.list` still answers the stored column at that point.
6955
+ */
6956
+ function registrySwitchToBodyId(addonId, date) {
6957
+ return `${addonId}/${date}-registry-switch-to-body`;
6958
+ }
6959
+ async function moveRegistrySwitchToBody(ports, spec) {
6960
+ const rows = await ports.listIntegrations(spec.addonId);
6961
+ let created = 0;
6962
+ let switched = 0;
6963
+ let kept = 0;
6964
+ for (const row of rows) {
6965
+ if (row.enabled) continue;
6966
+ const body = await ports.readBody(row.id);
6967
+ if (body === null) {
6968
+ if (await ports.createRecord(row.id, {
6969
+ ...spec.initialBody(row.name),
6970
+ ["enabled"]: false
6971
+ }) === "created") created += 1;
6972
+ else kept += 1;
6973
+ continue;
6974
+ }
6975
+ if ("enabled" in body) {
6976
+ kept += 1;
6977
+ continue;
6978
+ }
6979
+ await ports.switchOff(row.id);
6980
+ switched += 1;
6981
+ }
6982
+ const summary = {
6983
+ integrations: rows.length,
6984
+ off: rows.filter((r) => !r.enabled).length,
6985
+ created,
6986
+ switched,
6987
+ kept
6988
+ };
6989
+ return created === 0 && switched === 0 ? {
6990
+ outcome: "already-done",
6991
+ summary
6992
+ } : {
6993
+ outcome: "done",
6994
+ summary
6995
+ };
6996
+ }
6997
+ /** A migration entry: an addon states its kind and how a new body starts, nothing else. */
6998
+ function registrySwitchToBodyMigration(spec) {
6999
+ return {
7000
+ meta: {
7001
+ id: registrySwitchToBodyId(spec.addonId, spec.date),
7002
+ owner: spec.addonId,
7003
+ level: "addon-state",
7004
+ seq: spec.seq,
7005
+ dependsOn: [],
7006
+ store: "settings",
7007
+ scope: "cluster",
7008
+ onFailure: "block-owner",
7009
+ bodyKind: "procedure",
7010
+ description: "Move the registry enabled flag of every switched-off integration into its instance record body, creating the record when there is none",
7011
+ fixtureMark: "enabled"
7012
+ },
7013
+ procedure: (ports) => moveRegistrySwitchToBody(ports, {
7014
+ addonId: spec.addonId,
7015
+ initialBody: spec.initialBody
7016
+ })
7017
+ };
7018
+ }
7019
+ /** The hub and records sides of {@link registrySwitchToBodyMigration}. */
7020
+ function registrySwitchPortsOver(deps) {
7021
+ const handle = deps.records.kind({
7022
+ name: deps.kind.name,
7023
+ declaration: deps.kind.declaration,
7024
+ schema: record(string(), unknown())
7025
+ });
7026
+ return {
7027
+ listIntegrations: async (addonId) => (await deps.api.list()).filter((i) => i.addonId === addonId).map((i) => ({
7028
+ id: i.id,
7029
+ name: i.name,
7030
+ enabled: i.enabled !== false
7031
+ })),
7032
+ readBody: async (id) => (await handle.get(id))?.data ?? null,
7033
+ createRecord: async (id, body) => {
7034
+ if (await handle.get(id) !== null) return "exists";
7035
+ await handle.put({
7036
+ id,
7037
+ data: body
7038
+ }, { ifRev: 0 });
7039
+ return "created";
7040
+ },
7041
+ switchOff: async (id) => {
7042
+ await handle.patch(id, { [SWITCH_KEY]: false });
7043
+ }
7044
+ };
7045
+ }
6708
7046
  /**
6709
7047
  * Build a {@link DurableState} over a single store key. Transport-agnostic:
6710
7048
  * `read`/`write` are the addon-store or device-store accessors. The whole
@@ -6836,98 +7174,6 @@ var SCOPED_SETTINGS_SCOPES = [
6836
7174
  "device-defaults",
6837
7175
  "node"
6838
7176
  ];
6839
- var GLOBAL_SCOPE = { kind: "global" };
6840
- /** The scope every addon-wide (not per-node, not per-device) setting lives in. */
6841
- function globalSecretScope() {
6842
- return GLOBAL_SCOPE;
6843
- }
6844
- function encodeSegment(value) {
6845
- return encodeURIComponent(value);
6846
- }
6847
- function decodeSegment(value) {
6848
- try {
6849
- return decodeURIComponent(value);
6850
- } catch {
6851
- return null;
6852
- }
6853
- }
6854
- /**
6855
- * The field path of a value inside an array item, addressed by the item's id:
6856
- * `arrayItemFieldPath('providers', 'authentik', 'clientSecret')` →
6857
- * `providers[authentik].clientSecret`.
6858
- */
6859
- function arrayItemFieldPath(arrayKey, itemId, fieldKey) {
6860
- return `${arrayKey}[${encodeSegment(itemId)}].${fieldKey}`;
6861
- }
6862
- function parseScope(segments) {
6863
- switch (segments[0]) {
6864
- case "global": return {
6865
- scope: GLOBAL_SCOPE,
6866
- used: 1
6867
- };
6868
- case "node": {
6869
- const nodeId = segments[1] !== void 0 ? decodeSegment(segments[1]) : null;
6870
- return nodeId === null || nodeId.length === 0 ? null : {
6871
- scope: {
6872
- kind: "node",
6873
- nodeId
6874
- },
6875
- used: 2
6876
- };
6877
- }
6878
- case "device": {
6879
- const raw = segments[1];
6880
- if (raw === void 0 || !/^\d+$/.test(raw)) return null;
6881
- return {
6882
- scope: {
6883
- kind: "device",
6884
- deviceId: Number(raw)
6885
- },
6886
- used: 2
6887
- };
6888
- }
6889
- case "integration": {
6890
- const id = segments[1] !== void 0 ? decodeSegment(segments[1]) : null;
6891
- return id === null || id.length === 0 ? null : {
6892
- scope: {
6893
- kind: "integration",
6894
- integrationId: id
6895
- },
6896
- used: 2
6897
- };
6898
- }
6899
- case "row": {
6900
- const collection = segments[1] !== void 0 ? decodeSegment(segments[1]) : null;
6901
- const rowId = segments[2] !== void 0 ? decodeSegment(segments[2]) : null;
6902
- if (collection === null || rowId === null || collection.length === 0 || rowId.length === 0) return null;
6903
- return {
6904
- scope: {
6905
- kind: "row",
6906
- collection,
6907
- rowId
6908
- },
6909
- used: 3
6910
- };
6911
- }
6912
- default: return null;
6913
- }
6914
- }
6915
- /** Take a ref apart; `null` when it is not a well-formed ref. */
6916
- function parseSecretRef(ref) {
6917
- if (!ref.startsWith("secret://")) return null;
6918
- const segments = ref.slice(9).split("/");
6919
- const owner = segments[0] !== void 0 ? decodeSegment(segments[0]) : null;
6920
- if (owner === null || owner.length === 0) return null;
6921
- const parsed = parseScope(segments.slice(1));
6922
- if (parsed === null) return null;
6923
- const fieldPath = segments.slice(1 + parsed.used).join("/");
6924
- if (fieldPath.length === 0) return null;
6925
- return {
6926
- owner,
6927
- scope: parsed.scope,
6928
- fieldPath
6929
- };
6930
- }
6931
7177
  /** A write to a secret path could not be stored in the keychain, so it was refused. */
6932
7178
  var KeychainWriteRefusedError = class extends Error {
6933
7179
  fieldPath;
@@ -6938,7 +7184,7 @@ var KeychainWriteRefusedError = class extends Error {
6938
7184
  }
6939
7185
  };
6940
7186
  var KEEP = { kind: "keep" };
6941
- function isRecord$6(value) {
7187
+ function isRecord$4(value) {
6942
7188
  return typeof value === "object" && value !== null && !Array.isArray(value);
6943
7189
  }
6944
7190
  function defaultMintId() {
@@ -6951,7 +7197,7 @@ function collectSecretMarkerRefs(value, out = []) {
6951
7197
  return out;
6952
7198
  }
6953
7199
  if (Array.isArray(value)) for (const item of value) collectSecretMarkerRefs(item, out);
6954
- else if (isRecord$6(value)) for (const child of Object.values(value)) collectSecretMarkerRefs(child, out);
7200
+ else if (isRecord$4(value)) for (const child of Object.values(value)) collectSecretMarkerRefs(child, out);
6955
7201
  return out;
6956
7202
  }
6957
7203
  async function storedValueEquals(secrets, marker, candidate) {
@@ -7006,7 +7252,7 @@ function rowId(row, idKey) {
7006
7252
  return null;
7007
7253
  }
7008
7254
  async function writeArray(ctx, node, incoming, stored, fieldPath) {
7009
- const storedRows = Array.isArray(stored) ? stored.filter(isRecord$6) : [];
7255
+ const storedRows = Array.isArray(stored) ? stored.filter(isRecord$4) : [];
7010
7256
  if (!Array.isArray(incoming)) {
7011
7257
  ctx.deletes.push(...collectSecretMarkerRefs(storedRows));
7012
7258
  return {
@@ -7022,7 +7268,7 @@ async function writeArray(ctx, node, incoming, stored, fieldPath) {
7022
7268
  const kept = /* @__PURE__ */ new Set();
7023
7269
  const rows = [];
7024
7270
  for (const row of incoming) {
7025
- if (!isRecord$6(row)) {
7271
+ if (!isRecord$4(row)) {
7026
7272
  rows.push(row);
7027
7273
  continue;
7028
7274
  }
@@ -7047,7 +7293,7 @@ async function writeNode(ctx, node, incoming, stored, fieldPath) {
7047
7293
  case "leaf": return writeLeaf(ctx, incoming, stored, fieldPath);
7048
7294
  case "array": return writeArray(ctx, node, incoming, stored, fieldPath);
7049
7295
  case "object": {
7050
- if (!isRecord$6(incoming)) {
7296
+ if (!isRecord$4(incoming)) {
7051
7297
  if (incoming === void 0) return KEEP;
7052
7298
  ctx.deletes.push(...collectSecretMarkerRefs(stored));
7053
7299
  return {
@@ -7055,7 +7301,7 @@ async function writeNode(ctx, node, incoming, stored, fieldPath) {
7055
7301
  value: incoming
7056
7302
  };
7057
7303
  }
7058
- const storedObj = isRecord$6(stored) ? stored : {};
7304
+ const storedObj = isRecord$4(stored) ? stored : {};
7059
7305
  return {
7060
7306
  kind: "value",
7061
7307
  value: await writeMembers(ctx, node.children, incoming, storedObj, (m) => `${fieldPath}.${m}`)
@@ -7178,7 +7424,7 @@ async function resolveSecretMarkers(value, secrets, options = {}) {
7178
7424
  value: items
7179
7425
  };
7180
7426
  }
7181
- if (isRecord$6(v)) {
7427
+ if (isRecord$4(v)) {
7182
7428
  const out = {};
7183
7429
  for (const [k, child] of Object.entries(v)) {
7184
7430
  const s = substitute(child);
@@ -7210,7 +7456,7 @@ var SecretOverwriteRefusedError = class extends Error {
7210
7456
  this.name = "SecretOverwriteRefusedError";
7211
7457
  }
7212
7458
  };
7213
- function isRecord$5(value) {
7459
+ function isRecord$3(value) {
7214
7460
  return typeof value === "object" && value !== null && !Array.isArray(value);
7215
7461
  }
7216
7462
  function resolvedValue(pass, marker) {
@@ -7239,7 +7485,7 @@ function inArray(pass, incoming, stored) {
7239
7485
  return incoming.map((item, index) => {
7240
7486
  const twin = stored[index];
7241
7487
  if (isSecretMarker(twin)) return typeof item === "string" && item === resolvedValue(pass, twin) ? twin : item;
7242
- if (isRecord$5(item) && isRecord$5(twin)) return inArrayRow(pass, item, twin);
7488
+ if (isRecord$3(item) && isRecord$3(twin)) return inArrayRow(pass, item, twin);
7243
7489
  if (Array.isArray(item) && Array.isArray(twin)) return inArray(pass, item, twin);
7244
7490
  return item;
7245
7491
  });
@@ -7250,7 +7496,7 @@ function inArrayRow(pass, incoming, stored) {
7250
7496
  const twin = stored[key];
7251
7497
  if (isSecretMarker(twin)) {
7252
7498
  if (typeof value === "string" && value === resolvedValue(pass, twin)) out[key] = twin;
7253
- } else if (isRecord$5(value) && isRecord$5(twin)) out[key] = inArrayRow(pass, value, twin);
7499
+ } else if (isRecord$3(value) && isRecord$3(twin)) out[key] = inArrayRow(pass, value, twin);
7254
7500
  else if (Array.isArray(value) && Array.isArray(twin)) out[key] = inArray(pass, value, twin);
7255
7501
  }
7256
7502
  return out;
@@ -7258,7 +7504,7 @@ function inArrayRow(pass, incoming, stored) {
7258
7504
  async function walk(pass, incoming, stored) {
7259
7505
  if (isSecretMarker(stored)) return atMarker(pass, incoming, stored);
7260
7506
  if (Array.isArray(incoming) && Array.isArray(stored)) return inArray(pass, incoming, stored);
7261
- if (!isRecord$5(incoming) || !isRecord$5(stored)) return incoming;
7507
+ if (!isRecord$3(incoming) || !isRecord$3(stored)) return incoming;
7262
7508
  const out = { ...incoming };
7263
7509
  for (const [key, value] of Object.entries(incoming)) out[key] = await walk(pass, value, stored[key]);
7264
7510
  return out;
@@ -7289,7 +7535,7 @@ async function restoreUnchangedSecrets(input) {
7289
7535
  function isJsonEqual(a, b) {
7290
7536
  if (Object.is(a, b)) return true;
7291
7537
  if (Array.isArray(a)) return Array.isArray(b) && a.length === b.length && a.every((v, i) => isJsonEqual(v, b[i]));
7292
- if (isRecord$5(a) && isRecord$5(b)) {
7538
+ if (isRecord$3(a) && isRecord$3(b)) {
7293
7539
  const keys = Object.keys(a);
7294
7540
  if (keys.length !== Object.keys(b).length) return false;
7295
7541
  return keys.every((k) => Object.prototype.hasOwnProperty.call(b, k) && isJsonEqual(a[k], b[k]));
@@ -7313,7 +7559,7 @@ function markerKeysOf(blob, owner) {
7313
7559
  }
7314
7560
  function nodeFromStored(value, owner) {
7315
7561
  if (isSecretMarker(value)) return isSecretRefOwnedBy(value.$secret, owner) ? { kind: "leaf" } : null;
7316
- if (!isRecord$5(value)) return null;
7562
+ if (!isRecord$3(value)) return null;
7317
7563
  const children = /* @__PURE__ */ new Map();
7318
7564
  for (const [key, child] of Object.entries(value)) {
7319
7565
  const node = nodeFromStored(child, owner);
@@ -7810,13 +8056,48 @@ var BaseAddon = class {
7810
8056
  if (api === void 0) throw new Error(`${this.ctx.id}: the migration API is not available on this context`);
7811
8057
  return this.runBound(sets.flatMap((set) => set.bind(api)), options);
7812
8058
  }
7813
- async runBound(migrations, options) {
8059
+ /**
8060
+ * A device addon states its instance kind once, before its migrations run, and the one-switch
8061
+ * migration (registry `enabled` to the instance body, epic #440 step 3) joins whatever
8062
+ * catalogue the addon runs, in the SAME declaration (the engine replaces an owner's catalogue
8063
+ * on every declare).
8064
+ */
8065
+ declareRegistrySwitch(spec) {
8066
+ this.registrySwitchSpec = spec;
8067
+ }
8068
+ registrySwitchSpec = null;
8069
+ registrySwitchBound() {
8070
+ const spec = this.registrySwitchSpec;
8071
+ if (spec === null) return [];
8072
+ const api = this.ctx.migrationApi;
8073
+ if (api === void 0) {
8074
+ this.ctx.logger.warn("the registry switch migration is skipped: the migration API is not available on this context");
8075
+ return [];
8076
+ }
8077
+ return migrationSet([registrySwitchToBodyMigration({
8078
+ addonId: this.ctx.id,
8079
+ date: "2026-11-06",
8080
+ seq: 1e3,
8081
+ initialBody: spec.initialBody
8082
+ })], (a) => registrySwitchPortsOver({
8083
+ api: integrationRowsApiOver(a),
8084
+ records: switchRecordsOverMigrationApi(a),
8085
+ kind: spec.kind
8086
+ })).bind(api);
8087
+ }
8088
+ async runBound(declared, options) {
8089
+ const added = this.registrySwitchBound();
8090
+ const migrations = [...declared, ...added];
8091
+ const phased = options?.only === void 0 || added.length === 0 ? options : {
8092
+ ...options,
8093
+ only: [...options.only, ...added.map((m) => m.meta.id)]
8094
+ };
7814
8095
  const api = this.ctx.api.migrations;
7815
8096
  const report = await runAddonMigrations({
7816
8097
  declareOwner: (input) => api.declareOwner.mutate(input),
7817
8098
  startMigration: (input) => api.startMigration.mutate(input),
7818
8099
  finishMigration: (input) => api.finishMigration.mutate(input)
7819
- }, migrations, this.ctx.logger, options);
8100
+ }, migrations, this.ctx.logger, phased);
7820
8101
  if (report.blockOwner.length > 0) throw new AddonMigrationsBlockedError(report.blockOwner);
7821
8102
  return report;
7822
8103
  }
@@ -8889,114 +9170,94 @@ function normalizeAddonInitResult(result) {
8889
9170
  if (Array.isArray(result)) return { providers: result };
8890
9171
  return result;
8891
9172
  }
8892
- var PREFIX = "records/";
8893
- /** The base of every records failure. `detail` is the human part of the message. */
8894
- var RecordsError = class extends Error {
8895
- code;
8896
- detail;
8897
- constructor(code, detail) {
8898
- super(`${PREFIX}${code}: ${detail}`);
8899
- this.name = "RecordsError";
8900
- this.code = code;
8901
- this.detail = detail;
8902
- }
8903
- };
8904
- var InvalidRecordError = class extends RecordsError {
8905
- constructor(detail) {
8906
- super("invalid-record", detail);
8907
- this.name = "InvalidRecordError";
8908
- }
8909
- };
8910
- /** A kind declaration the engine refuses (non-additive change, bad shape, wrong file). */
8911
- var DeclarationRefusedError = class extends RecordsError {
8912
- constructor(detail) {
8913
- super("declaration-refused", detail);
8914
- this.name = "DeclarationRefusedError";
8915
- }
8916
- };
8917
- /** Limits and names of `ctx.records` (D881). One authority; the engine and the facade read it. */
8918
- /** The files a kind may live in. `history` is device-history's (D850), never records. */
8919
- var RECORD_DATABASES = ["settings", "events"];
8920
- /** The classes of a kind: the `@durable` vocabulary, one authority (replaces the annotation). */
8921
- var RECORD_CLASSES = [
8922
- "config",
8923
- "ledger",
8924
- "audit",
8925
- "mirror",
8926
- "ephemeral"
8927
- ];
8928
- var RECORD_DEFAULT_MAX_DATA_BYTES = 64 * 1024;
8929
- var RECORD_MAX_DATA_BYTES = 1024 * 1024;
8930
- var RECORD_BATCH_MAX = 1e3;
8931
- var RECORD_QUERY_MAX = 1e3;
8932
- /** A kind in the `settings` file may not bound itself above this (D447: high volume is `events`). */
8933
- var RECORD_SETTINGS_MAX_ROWS = 5e4;
9173
+ object({
9174
+ field: string().min(1),
9175
+ on: literal("advance")
9176
+ });
8934
9177
  /**
8935
- * Secret fields of a record, addressed the way a Zod schema declares them
8936
- * (`collectZodSecretPaths`): dotted keys, `[]` for "each element of this array"
8937
- * (`auth.accessToken`, `headers[].value`).
8938
- *
8939
- * `{}` after a key means "each value of this map" (`applianceSecrets{}`): the map's own key
8940
- * names the value (`applianceSecrets{fridge}`), so no id key is declared and a body that drops a
8941
- * key releases exactly that key's secret.
9178
+ * Output schema shared by the contribution + live methods.
8942
9179
  *
8943
- * Array elements are matched by a DECLARED id key (`secretArrayKeys`:
8944
- * `{ headers: 'name' }`), never by index, so reordering a list keeps every
8945
- * keychain ref (the same rule as `arrayItemFieldPath`). The concrete path of a
8946
- * leaf names its element: `headers[X-Api].value`.
9180
+ * Mirrors the `ConfigUISchemaWithValues` shape (sections[] + optional
9181
+ * tabs[]) without importing from `../interfaces/config-ui.js` — a
9182
+ * concrete-but-lenient Zod object keeps tRPC output inference happy
9183
+ * (using `z.unknown()` here collapses unrelated router branches to
9184
+ * `unknown` when the generator re-inlines the huge AppRouter type).
8947
9185
  *
8948
- * Pure and browser-safe. Nothing here mutates: every transform returns a new value.
9186
+ * `.passthrough()` on sections/fields accepts whatever FormBuilder
9187
+ * extensions the caller adds (showWhen, displayScale, …) without
9188
+ * rebuilding every time a new field kind is introduced.
8949
9189
  */
8950
- /** The array prefixes (declared form, e.g. `headers` or `a.headers`) of a path. */
8951
- function parseSecretPath(path) {
8952
- if (path.length === 0) throw new InvalidRecordError("an empty secret path");
8953
- return path.split(".").map((raw) => {
8954
- const each = raw.endsWith("[]");
8955
- const map = raw.endsWith("{}");
8956
- const key = each || map ? raw.slice(0, -2) : raw;
8957
- if (key.length === 0) throw new InvalidRecordError(`secret path "${path}" has an empty segment`);
8958
- return {
8959
- key,
8960
- each,
8961
- map
8962
- };
8963
- });
9190
+ var ContributionSectionSchema = object({
9191
+ id: string(),
9192
+ title: string(),
9193
+ description: string().optional(),
9194
+ style: _enum(["card", "accordion"]).optional(),
9195
+ defaultCollapsed: boolean().optional(),
9196
+ columns: union([
9197
+ literal(1),
9198
+ literal(2),
9199
+ literal(3),
9200
+ literal(4)
9201
+ ]).optional(),
9202
+ tab: string().optional(),
9203
+ location: _enum([
9204
+ "settings",
9205
+ "top-tab",
9206
+ "hero"
9207
+ ]).optional(),
9208
+ order: number().optional(),
9209
+ fields: array(any())
9210
+ });
9211
+ object({
9212
+ tabs: array(object({
9213
+ id: string(),
9214
+ label: string(),
9215
+ icon: string(),
9216
+ order: number().optional()
9217
+ })).optional(),
9218
+ sections: array(ContributionSectionSchema)
9219
+ }).nullable();
9220
+ object({ deviceId: number() }), object({ deviceId: number() }), object({
9221
+ deviceId: number(),
9222
+ patch: record(string(), unknown())
9223
+ }), object({ success: literal(true) });
9224
+ object({ deviceId: number() }), unknown().nullable();
9225
+ function method(input, output, options) {
9226
+ return {
9227
+ input,
9228
+ output,
9229
+ kind: options?.kind ?? "query",
9230
+ ...options?.auth !== void 0 ? { auth: options.auth } : {},
9231
+ ...options?.access !== void 0 ? { access: options.access } : {},
9232
+ ...options?.role !== void 0 ? { role: options.role } : {},
9233
+ ...options?.caller !== void 0 ? { caller: options.caller } : {},
9234
+ timeoutMs: options?.timeoutMs
9235
+ };
8964
9236
  }
8965
- /** The declared array prefixes of `path` that need an id key (`headers`, `a.rows`). */
8966
- function secretArrayPrefixes(path) {
8967
- const segments = parseSecretPath(path);
8968
- const prefixes = [];
8969
- const walked = [];
8970
- for (const segment of segments) {
8971
- walked.push(segment.key);
8972
- if (segment.each) prefixes.push(walked.join("."));
8973
- }
8974
- return prefixes;
9237
+ /**
9238
+ * A wrapper/system-only method: served exclusively by the cap's system-level
9239
+ * provider (`InferProvider`), and OPTIONAL on `InferNativeProvider` so per-device
9240
+ * driver natives don't stub out a wrapper concern (e.g. a cross-device cache
9241
+ * overview). The `systemOnly: true` literal is what `InferNativeProvider` keys on.
9242
+ */
9243
+ function systemMethod(input, output, options) {
9244
+ return {
9245
+ ...method(input, output, options),
9246
+ systemOnly: true
9247
+ };
8975
9248
  }
8976
9249
  /**
8977
- * The share-view scope kinds a share-link token can carry. The hub mints
8978
- * and validates them (`ShareViewGrantSchema` builds its
8979
- * enum from this list); a data plane names the kinds it ACCEPTS in `share`.
9250
+ * A method a SOURCE of a collection cap may legitimately not serve — OPTIONAL
9251
+ * on `InferProvider`. The `providerOptional: true` literal is what
9252
+ * `InferProvider` keys on; see {@link CapabilityMethodSchema.providerOptional}
9253
+ * for when this is the honest answer and when it is a soft stub.
8980
9254
  */
8981
- var SHARE_VIEW_KINDS = ["grid-view", "events-view"];
8982
- /** The wire shape of {@link PeerBytesTicket} — see the type for what it is. */
8983
- var PeerBytesTicketSchema = object({
8984
- /** `http://127.0.0.1:<port>/<token>`. One `GET` takes it. */
8985
- url: string().min(1),
8986
- /**
8987
- * The HOST node this URL means something on — the hub or a named agent,
8988
- * never a runner. {@link AddonPeerBytes.open} compares it to its own and
8989
- * refuses `cross-node` by name when they differ, without dialling.
8990
- */
8991
- hostNodeId: string().min(1),
8992
- expiresAtMs: number().int().nonnegative(),
8993
- /**
8994
- * What the producer DECLARED the body to be, when it knows — `null` when it
8995
- * does not. Never `0` for unknown (D393): a consumer sizing a bound off this
8996
- * must be able to tell "the producer did not say" from "the body is empty".
8997
- */
8998
- declaredBytes: number().int().nonnegative().nullable()
8999
- });
9255
+ function optionalMethod(input, output, options) {
9256
+ return {
9257
+ ...method(input, output, options),
9258
+ providerOptional: true
9259
+ };
9260
+ }
9000
9261
  function defOf(schema) {
9001
9262
  const zodBag = Reflect.get(schema, "_zod");
9002
9263
  if (typeof zodBag !== "object" || zodBag === null) return {};
@@ -9216,107 +9477,29 @@ function defineRecordKinds(specs) {
9216
9477
  return out;
9217
9478
  }
9218
9479
  /**
9219
- * Entry kinds (D881): every list of user-created entries (notification
9220
- * targets, brokers, LLM profiles) is ONE record kind with an id, a name and a
9221
- * kind-specific body, and the admin UI lists/adds/edits/deletes all of them
9222
- * through the `record-entries` capability with password fields derived from
9223
- * the schema (`.meta({ secret: true })`).
9224
- */
9225
- /** The body of a plain entry: a name and the fields the kind adds. */
9226
- function entryBody(shape) {
9227
- return object({
9228
- name: string().min(1),
9229
- ...shape
9230
- });
9231
- }
9232
- object({
9233
- field: string().min(1),
9234
- on: literal("advance")
9235
- });
9236
- /**
9237
- * Output schema shared by the contribution + live methods.
9238
- *
9239
- * Mirrors the `ConfigUISchemaWithValues` shape (sections[] + optional
9240
- * tabs[]) without importing from `../interfaces/config-ui.js` — a
9241
- * concrete-but-lenient Zod object keeps tRPC output inference happy
9242
- * (using `z.unknown()` here collapses unrelated router branches to
9243
- * `unknown` when the generator re-inlines the huge AppRouter type).
9244
- *
9245
- * `.passthrough()` on sections/fields accepts whatever FormBuilder
9246
- * extensions the caller adds (showWhen, displayScale, …) without
9247
- * rebuilding every time a new field kind is introduced.
9480
+ * The share-view scope kinds a share-link token can carry. The hub mints
9481
+ * and validates them (`ShareViewGrantSchema` builds its
9482
+ * enum from this list); a data plane names the kinds it ACCEPTS in `share`.
9248
9483
  */
9249
- var ContributionSectionSchema = object({
9250
- id: string(),
9251
- title: string(),
9252
- description: string().optional(),
9253
- style: _enum(["card", "accordion"]).optional(),
9254
- defaultCollapsed: boolean().optional(),
9255
- columns: union([
9256
- literal(1),
9257
- literal(2),
9258
- literal(3),
9259
- literal(4)
9260
- ]).optional(),
9261
- tab: string().optional(),
9262
- location: _enum([
9263
- "settings",
9264
- "top-tab",
9265
- "hero"
9266
- ]).optional(),
9267
- order: number().optional(),
9268
- fields: array(any())
9484
+ var SHARE_VIEW_KINDS = ["grid-view", "events-view"];
9485
+ /** The wire shape of {@link PeerBytesTicket} — see the type for what it is. */
9486
+ var PeerBytesTicketSchema = object({
9487
+ /** `http://127.0.0.1:<port>/<token>`. One `GET` takes it. */
9488
+ url: string().min(1),
9489
+ /**
9490
+ * The HOST node this URL means something on — the hub or a named agent,
9491
+ * never a runner. {@link AddonPeerBytes.open} compares it to its own and
9492
+ * refuses `cross-node` by name when they differ, without dialling.
9493
+ */
9494
+ hostNodeId: string().min(1),
9495
+ expiresAtMs: number().int().nonnegative(),
9496
+ /**
9497
+ * What the producer DECLARED the body to be, when it knows — `null` when it
9498
+ * does not. Never `0` for unknown (D393): a consumer sizing a bound off this
9499
+ * must be able to tell "the producer did not say" from "the body is empty".
9500
+ */
9501
+ declaredBytes: number().int().nonnegative().nullable()
9269
9502
  });
9270
- object({
9271
- tabs: array(object({
9272
- id: string(),
9273
- label: string(),
9274
- icon: string(),
9275
- order: number().optional()
9276
- })).optional(),
9277
- sections: array(ContributionSectionSchema)
9278
- }).nullable();
9279
- object({ deviceId: number() }), object({ deviceId: number() }), object({
9280
- deviceId: number(),
9281
- patch: record(string(), unknown())
9282
- }), object({ success: literal(true) });
9283
- object({ deviceId: number() }), unknown().nullable();
9284
- function method(input, output, options) {
9285
- return {
9286
- input,
9287
- output,
9288
- kind: options?.kind ?? "query",
9289
- ...options?.auth !== void 0 ? { auth: options.auth } : {},
9290
- ...options?.access !== void 0 ? { access: options.access } : {},
9291
- ...options?.role !== void 0 ? { role: options.role } : {},
9292
- ...options?.caller !== void 0 ? { caller: options.caller } : {},
9293
- timeoutMs: options?.timeoutMs
9294
- };
9295
- }
9296
- /**
9297
- * A wrapper/system-only method: served exclusively by the cap's system-level
9298
- * provider (`InferProvider`), and OPTIONAL on `InferNativeProvider` so per-device
9299
- * driver natives don't stub out a wrapper concern (e.g. a cross-device cache
9300
- * overview). The `systemOnly: true` literal is what `InferNativeProvider` keys on.
9301
- */
9302
- function systemMethod(input, output, options) {
9303
- return {
9304
- ...method(input, output, options),
9305
- systemOnly: true
9306
- };
9307
- }
9308
- /**
9309
- * A method a SOURCE of a collection cap may legitimately not serve — OPTIONAL
9310
- * on `InferProvider`. The `providerOptional: true` literal is what
9311
- * `InferProvider` keys on; see {@link CapabilityMethodSchema.providerOptional}
9312
- * for when this is the honest answer and when it is a soft stub.
9313
- */
9314
- function optionalMethod(input, output, options) {
9315
- return {
9316
- ...method(input, output, options),
9317
- providerOptional: true
9318
- };
9319
- }
9320
9503
  var READING_QUANTITIES = [
9321
9504
  "temperature",
9322
9505
  "pressure",
@@ -10451,7 +10634,6 @@ var CAP_NAMES = Object.freeze([
10451
10634
  "climate-control",
10452
10635
  "color",
10453
10636
  "composer",
10454
- "connection-test",
10455
10637
  "connectivity",
10456
10638
  "consumables",
10457
10639
  "contact",
@@ -11598,6 +11780,10 @@ Object.freeze({
11598
11780
  "all",
11599
11781
  "one"
11600
11782
  ]
11783
+ },
11784
+ {
11785
+ "path": "positionUpdatedAt",
11786
+ "valueType": "number"
11601
11787
  }
11602
11788
  ],
11603
11789
  "meter": [{
@@ -11852,22 +12038,6 @@ Object.freeze({
11852
12038
  "path": "pumpRunning",
11853
12039
  "valueType": "boolean"
11854
12040
  },
11855
- {
11856
- "path": "lastDrink",
11857
- "valueType": "number"
11858
- },
11859
- {
11860
- "path": "currentHourDrink",
11861
- "valueType": "number"
11862
- },
11863
- {
11864
- "path": "last24hDrink",
11865
- "valueType": "number"
11866
- },
11867
- {
11868
- "path": "todayDrink",
11869
- "valueType": "number"
11870
- },
11871
12041
  {
11872
12042
  "path": "error",
11873
12043
  "valueType": "string"
@@ -12433,6 +12603,59 @@ Object.freeze({
12433
12603
  }
12434
12604
  ]
12435
12605
  });
12606
+ Object.freeze({
12607
+ "actions": { "run": 363e4 },
12608
+ "audio-analyzer": { "classify": 3e4 },
12609
+ "custom-model-registry": { "importModelBundle": 18e5 },
12610
+ "database-snapshot": { "writeSnapshot": 18e5 },
12611
+ "device-manager": {
12612
+ "migrateDevice": 72e4,
12613
+ "runDiscoverySweep": 12e4
12614
+ },
12615
+ "device-provider": { "reloadDevice": 18e4 },
12616
+ "llm": {
12617
+ "generate": 6e5,
12618
+ "generateVision": 6e5,
12619
+ "testProfile": 6e5
12620
+ },
12621
+ "llm-runtime": {
12622
+ "complete": 6e5,
12623
+ "completeApple": 6e5,
12624
+ "ensureStarted": 6e5,
12625
+ "installModel": 36e5
12626
+ },
12627
+ "local-network": { "scanNetwork": 9e4 },
12628
+ "model-convert": { "convert": 6e5 },
12629
+ "pipeline-analytics": {
12630
+ "addRetrainFrameFromRecording": 6e4,
12631
+ "offerRetrainArchive": 12e4,
12632
+ "proposeRetrainAnnotationsWithLlm": 18e4,
12633
+ "resolveRetrainTrainingCorpus": 6e4,
12634
+ "writeRetrainArchive": 36e5
12635
+ },
12636
+ "server-management": { "applyServerUpdate": 96e4 },
12637
+ "terminal-session": { "pullOutput": 15e3 },
12638
+ "training": {
12639
+ "canaryResult": 12e4,
12640
+ "cancelJob": 12e4,
12641
+ "planJob": 6e4,
12642
+ "registerResult": 18e5,
12643
+ "rollbackCanary": 12e4,
12644
+ "startJob": 12e4,
12645
+ "startJobBatch": 12e4
12646
+ },
12647
+ "training-provider": {
12648
+ "cancelJob": 6e4,
12649
+ "cleanupJob": 3e5,
12650
+ "getJob": 6e4,
12651
+ "listJobEvents": 6e4,
12652
+ "listJobs": 12e4,
12653
+ "offerArtifact": 3e5,
12654
+ "readResult": 3e5,
12655
+ "submitJob": 18e5,
12656
+ "uploadDataset": 72e5
12657
+ }
12658
+ });
12436
12659
  object({
12437
12660
  code: string().regex(/^[a-z][a-z0-9-]*(\.[a-z0-9-]+)+$/),
12438
12661
  params: record(string(), union([string(), number()])).optional()
@@ -13977,10 +14200,432 @@ var IntegrationInstanceRefSchema = object({
13977
14200
  ]),
13978
14201
  candidateStableId: string().optional()
13979
14202
  });
13980
- object({
13981
- cap: string().min(1),
13982
- kind: string().min(1).optional()
14203
+ /**
14204
+ * notification-output — canonical, capability-gated notification delivery.
14205
+ *
14206
+ * Apprise-derived model (see
14207
+ * `docs/superpowers/specs/2026-07-03-notification-output-notifier-matrix.md`):
14208
+ * callers emit ONE canonical `Notification`; each provider declares a
14209
+ * per-kind capability descriptor (`TargetKind`), and the pure degrade
14210
+ * engine (`@camstack/types` `prepareNotification`) transcodes / degrades the
14211
+ * message to what the kind supports — callers never special-case a service.
14212
+ *
14213
+ * DESIGN DECISIONS (locked):
14214
+ * - Target CRUD lives on THIS cap (`upsertTarget` / `deleteTarget` /
14215
+ * `setTargetEnabled`), each provider persisting via the `settings-store`
14216
+ * cap. Rationale: the admin UI needs one uniform surface across the
14217
+ * notifiers addon AND the HA addon; the addon-`globalSettingsSchema`-array
14218
+ * alternative would fork the UI per addon and cannot host the
14219
+ * discovery→adopt flow.
14220
+ * - `listTargetKinds` / `listTargets` / `discoverTargets` return arrays →
14221
+ * the generated cap-mount auto-`concatCollection`-fans them across every
14222
+ * registered provider (notifiers addon + HA addon) so one catalog is
14223
+ * routable. `send` / `testTarget` / CRUD route to ONE provider by the
14224
+ * `addonId` the generated collection router extracts from the call input.
14225
+ * - `Attachment.bytes` is `Uint8Array`. Transport-safe: superjson (the tRPC
14226
+ * transformer) + UDS MsgPack both round-trip typed arrays — already used by
14227
+ * `storage` / `storage-provider` / `recording` caps over the same path. No
14228
+ * base64 fallback needed.
14229
+ *
14230
+ * TODO (deferred, closed-set change — separate decision): add
14231
+ * `providerKind: 'notify'` so notification providers surface on the unified
14232
+ * admin "Integrations" page.
14233
+ */
14234
+ /**
14235
+ * Zentik-derived typed-media enum — the superset across every kind. Each
14236
+ * adapter picks what it supports and the degrade engine filters the rest.
14237
+ */
14238
+ var AttachmentMediaTypeSchema = _enum([
14239
+ "image",
14240
+ "video",
14241
+ "gif",
14242
+ "audio",
14243
+ "icon"
14244
+ ]);
14245
+ /**
14246
+ * A single attachment. Exactly one of `url` (remote source, most adapters
14247
+ * prefer this) or `bytes` (inline source; required for Pushover-style
14248
+ * bytes-only kinds) MUST be present — the degrade engine expresses a
14249
+ * url→bytes fetch as a `needsFetch` directive the adapter executes.
14250
+ */
14251
+ var AttachmentSchema = object({
14252
+ mediaType: AttachmentMediaTypeSchema,
14253
+ url: string().optional(),
14254
+ bytes: _instanceof(Uint8Array).optional(),
14255
+ mime: string().optional(),
14256
+ name: string().optional()
14257
+ }).refine((a) => a.url !== void 0 || a.bytes !== void 0, { message: "Attachment requires either `url` or `bytes`" });
14258
+ var NotificationFormatSchema = _enum([
14259
+ "text",
14260
+ "markdown",
14261
+ "html"
14262
+ ]);
14263
+ /**
14264
+ * The CLOSED icon vocabulary an action button may use.
14265
+ *
14266
+ * A closed set, not a free string, and that is the whole point: an arbitrary
14267
+ * icon name is one that ntfy renders, zentik silently drops, and nobody
14268
+ * notices — the same class of gap as a zone vocabulary nothing produced
14269
+ * ([D35](../../../docs/decisions/adr-0035.md)). Every adapter maps this set or
14270
+ * declares `actionIcons: false` and the degrade engine strips the field.
14271
+ *
14272
+ * Named by INTENT, never by glyph. "check" would tie the vocabulary to one
14273
+ * renderer's icon set; "acknowledge" survives an adapter that draws it
14274
+ * differently.
14275
+ *
14276
+ * ── A TOKEN IS NOT A WIRE VALUE ─────────────────────────────────────
14277
+ *
14278
+ * These names are for US. **No adapter may forward one verbatim.** Each maps
14279
+ * the whole set onto its own renderer's vocabulary through a
14280
+ * `Record<NotificationActionIcon, string>` — a Record, never a lookup with a
14281
+ * fallback, so adding a member here fails every adapter's build until someone
14282
+ * decides its glyph, which is the only place that decision can be made
14283
+ * honestly.
14284
+ *
14285
+ * This paragraph is the bug. Zentik declared `actionIcons: true` and passed
14286
+ * `disarm` straight through; iOS feeds that string to
14287
+ * `UNNotificationActionIcon(systemImageName:)`, `disarm` is not an SF Symbol,
14288
+ * and every snooze and alarm button arrived BLANK. A pass-through is not a
14289
+ * mapping, and "the field is documented" is not "the value renders".
14290
+ *
14291
+ * Adding a member is TRAIN-BOUND. The enum lives in the published
14292
+ * `@camstack/server` closure and the cap seam validates against the HUB's copy,
14293
+ * so an addon that emits a token the running hub does not know does not lose an
14294
+ * icon — its whole `send` fails Zod validation and the notification never
14295
+ * arrives. Never emit a new token from an addon before the train carrying it.
14296
+ */
14297
+ var NotificationActionIconSchema = _enum([
14298
+ "acknowledge",
14299
+ "dismiss",
14300
+ "silence",
14301
+ "snooze",
14302
+ "view",
14303
+ "play",
14304
+ "open",
14305
+ "close",
14306
+ "lock",
14307
+ "unlock",
14308
+ "arm",
14309
+ "arm-home",
14310
+ "arm-away",
14311
+ "arm-night",
14312
+ "disarm",
14313
+ "light",
14314
+ "alert",
14315
+ "camera"
14316
+ ]);
14317
+ /** A single tap-through action button. */
14318
+ var NotificationActionSchema = object({
14319
+ id: string(),
14320
+ label: string(),
14321
+ url: string().optional(),
14322
+ /** Dropped by the degrade engine for a kind with `caps.actionIcons: false`. */
14323
+ icon: NotificationActionIconSchema.optional(),
14324
+ /**
14325
+ * Renders in a warning style where the notifier supports it.
14326
+ *
14327
+ * A HINT, never a gate. The callback's authority is its token and nothing
14328
+ * else — see `notification-center/action-token.ts` for what that does and
14329
+ * does not buy.
14330
+ */
14331
+ destructive: boolean().optional(),
14332
+ /**
14333
+ * How the tap should REACH the url.
14334
+ *
14335
+ * `navigate` (absent, and every button authored before this field) opens it:
14336
+ * the phone leaves the notification and shows whatever the callback returns.
14337
+ * That is right for a button whose answer the operator wants to read.
14338
+ *
14339
+ * `background` fires it as a POST and stays put. It exists for the buttons
14340
+ * whose whole point is not to interrupt — "silence this for 30 minutes" is
14341
+ * an answer to the notification, and being thrown into a browser tab to
14342
+ * confirm it costs more attention than the notification did. A backend that
14343
+ * cannot do a background call renders it as an ordinary link (the adapters
14344
+ * fall back rather than dropping the button), so this is a preference, never
14345
+ * a requirement.
14346
+ */
14347
+ mode: _enum(["navigate", "background"]).optional()
14348
+ });
14349
+ /** A delivery parameter value: what a notifier declared it takes. */
14350
+ var DeliveryParamValueSchema = union([
14351
+ string(),
14352
+ number(),
14353
+ boolean()
14354
+ ]);
14355
+ /**
14356
+ * One extra delivery parameter a notifier KIND declares (D938). A rule that
14357
+ * addresses a target of that kind may set it; a kind that declares nothing is
14358
+ * never handed one. The admin UI derives its control from this descriptor —
14359
+ * no editor knows a service by name.
14360
+ *
14361
+ * Optional fields are `.optional()`, never `.default()` (a Zod default does not
14362
+ * run on the addon cap path).
14363
+ */
14364
+ var DeliveryParamSchema = object({
14365
+ key: string().min(1),
14366
+ label: string(),
14367
+ /** i18n key of the label, resolved by the declaring addon's namespace. */
14368
+ labelKey: string().optional(),
14369
+ type: _enum([
14370
+ "enum",
14371
+ "number",
14372
+ "boolean",
14373
+ "string"
14374
+ ]),
14375
+ /** `enum` only: the closed set of accepted values. */
14376
+ options: array(object({
14377
+ value: string(),
14378
+ label: string()
14379
+ })).optional(),
14380
+ /** `number` only. */
14381
+ min: number().optional(),
14382
+ max: number().optional(),
14383
+ /** What the notifier does when the rule sets nothing; shown as the placeholder. */
14384
+ default: DeliveryParamValueSchema.optional()
14385
+ });
14386
+ /**
14387
+ * The canonical notification. `body` is the only hard field (Apprise model).
14388
+ * `priority` is a 5-level ORDINAL (1=lowest … 3=normal(default) … 5=urgent),
14389
+ * NOT a fixed severity enum — each kind declares its own `caps.levels` and
14390
+ * the adapter maps this ordinal onto its native level. `level?` is an
14391
+ * optional kind-native level id (`emergency`, `silent`, …) that overrides
14392
+ * `priority` for that one target.
14393
+ */
14394
+ var NotificationSchema = object({
14395
+ body: string(),
14396
+ title: string().optional(),
14397
+ format: NotificationFormatSchema.default("text"),
14398
+ priority: number().int().min(1).max(5).default(3),
14399
+ level: string().optional(),
14400
+ attachments: array(AttachmentSchema).optional(),
14401
+ clickUrl: string().optional(),
14402
+ actions: array(NotificationActionSchema).optional(),
14403
+ sound: string().optional(),
14404
+ ttl: number().optional(),
14405
+ tag: string().optional(),
14406
+ deviceId: number().optional(),
14407
+ eventId: string().optional(),
14408
+ metadata: record(string(), unknown()).optional(),
14409
+ /**
14410
+ * Values for the parameters the target's kind DECLARES in
14411
+ * {@link TargetKindSchema} `deliveryParams`. Already validated against the
14412
+ * declaration by the sender; a notifier reads only the keys it declared.
14413
+ */
14414
+ delivery: record(string(), DeliveryParamValueSchema).optional()
14415
+ });
14416
+ /** One declared native severity/priority level for a kind. */
14417
+ var TargetKindLevelSchema = object({
14418
+ id: string(),
14419
+ label: string(),
14420
+ /** Which canonical priority (1..5) this level maps to. `null` = qualitative-only. */
14421
+ ordinal: number().int().min(1).max(5).nullable(),
14422
+ flags: object({
14423
+ critical: boolean().optional(),
14424
+ silent: boolean().optional(),
14425
+ noPush: boolean().optional()
14426
+ }).optional(),
14427
+ /** e.g. Pushover `emergency` requires `retry` / `expire`. */
14428
+ requires: array(string()).optional(),
14429
+ description: string().optional()
14430
+ });
14431
+ /** The full capability block consulted before dispatch. */
14432
+ var TargetKindCapsSchema = object({
14433
+ attachments: object({
14434
+ mediaTypes: array(AttachmentMediaTypeSchema),
14435
+ mode: _enum([
14436
+ "url",
14437
+ "bytes",
14438
+ "both"
14439
+ ]),
14440
+ max: number().int().nonnegative(),
14441
+ maxBytes: number().int().positive().optional()
14442
+ }),
14443
+ /** Max action buttons (0 = none). */
14444
+ actions: number().int().nonnegative(),
14445
+ /**
14446
+ * Whether this kind renders a per-action ICON.
14447
+ *
14448
+ * `.optional()`, deliberately NOT `.default(false)`: a Zod default does not
14449
+ * run on the addon cap path — three production failures in one day taught
14450
+ * this repo that once. Absent is read as false by the degrade engine, which
14451
+ * is the safe direction: an icon that is not rendered costs nothing, an icon
14452
+ * assumed and dropped costs the operator's trust in the field.
14453
+ */
14454
+ actionIcons: boolean().optional(),
14455
+ levels: array(TargetKindLevelSchema),
14456
+ format: array(NotificationFormatSchema),
14457
+ clickUrl: boolean(),
14458
+ sound: boolean(),
14459
+ ttl: boolean(),
14460
+ bodyMaxLen: number().int().positive()
14461
+ });
14462
+ /**
14463
+ * `configSchema` is a `ConfigUISchema` tree passed through to the admin
14464
+ * FormBuilder. Stored as `z.unknown()` at the cap seam (mirrors
14465
+ * `device-provider.getChildCreationSchema` `CreationSchemaOutputSchema`) —
14466
+ * the union is large and not meant for runtime validation here; the exported
14467
+ * `TargetKind` type re-tightens `configSchema` to `ConfigUISchema`.
14468
+ */
14469
+ var ConfigSchemaPassthrough$4 = unknown();
14470
+ var TargetKindSchema = object({
14471
+ kind: string(),
14472
+ label: string(),
14473
+ icon: string(),
14474
+ /** Stamped by each provider so the concat-fanned catalog stays routable. */
14475
+ addonId: string(),
14476
+ /**
14477
+ * URL of the kind's bundled BRAND icon, served by the providing addon over
14478
+ * its own `addon-routes` surface (`/addon/<addonId>/icons/<kind>`). Absent
14479
+ * when the addon bundles no icon for that kind — the client then falls back
14480
+ * to a neutral glyph rather than rendering the raw `icon` NAME as text.
14481
+ *
14482
+ * Root-relative on purpose: it resolves against whatever origin serves a web
14483
+ * client, and a native client joins it onto its own hub base.
14484
+ *
14485
+ * DECLARED here deliberately. It used to travel as an undeclared passthrough
14486
+ * field that survived only because the runtime cap-router forwards provider
14487
+ * output verbatim — so every consumer had to re-declare it by hand to stop
14488
+ * its own Zod parse from stripping it, and the whole arrangement would have
14489
+ * broken silently the moment output validation was tightened anywhere.
14490
+ */
14491
+ iconUrl: string().optional(),
14492
+ /**
14493
+ * Media type of {@link iconUrl} (`image/svg+xml`, `image/png`, …).
14494
+ *
14495
+ * The server knows this and therefore says it, because the client cannot
14496
+ * safely guess: a React-Native client renders SVG and raster through two
14497
+ * DIFFERENT components (`react-native-svg` vs `expo-image` — expo-image does
14498
+ * not decode SVG on iOS/Android), so without this it silently fell back to a
14499
+ * placeholder glyph for every vector icon while the web build looked fine.
14500
+ *
14501
+ * Absent when {@link iconUrl} is absent, or for a legacy provider that has
14502
+ * not been updated — a client that cannot determine the type should prefer
14503
+ * its raster path, which is the safe default for an unknown image.
14504
+ */
14505
+ iconMediaType: string().optional(),
14506
+ configSchema: ConfigSchemaPassthrough$4,
14507
+ /**
14508
+ * The config keys that decide WHERE this kind's secrets are sent (server,
14509
+ * base URL, instance, chat, recipient). A save that changes any of them
14510
+ * while leaving a secret redacted is refused by the provider (D634), so an
14511
+ * editor uses this to ask for the secret on exactly those edits instead of
14512
+ * on every edit.
14513
+ *
14514
+ * Optional: absent from a provider that holds no secret (the Home Assistant
14515
+ * kinds) and from a provider older than this field — an editor that finds
14516
+ * it absent must assume ANY edit may need the secret.
14517
+ */
14518
+ destinationKeys: array(string()).optional(),
14519
+ supportsDiscovery: boolean(),
14520
+ /**
14521
+ * Extra delivery parameters a rule may set for a target of this kind (D938).
14522
+ * Absent = none; the rule editor then offers nothing.
14523
+ */
14524
+ deliveryParams: array(DeliveryParamSchema).optional(),
14525
+ caps: TargetKindCapsSchema
14526
+ });
14527
+ /**
14528
+ * A persisted target. `config` holds secrets; providers REDACT secret fields
14529
+ * (return a presence marker only) when serving `listTargets` — never
14530
+ * round-trip a stored secret to the UI.
14531
+ */
14532
+ var TargetSchema = object({
14533
+ id: string(),
14534
+ name: string(),
14535
+ kind: string(),
14536
+ addonId: string(),
14537
+ enabled: boolean(),
14538
+ config: record(string(), unknown())
14539
+ });
14540
+ /** A discovery-surfaced candidate (config is partial + non-secret). */
14541
+ var DiscoveredTargetSchema = object({
14542
+ kind: string(),
14543
+ suggestedName: string(),
14544
+ config: record(string(), unknown())
14545
+ });
14546
+ /** The degrade engine's report — what was resolved / dropped / degraded. */
14547
+ var RenderedAsSchema = object({
14548
+ level: string(),
14549
+ format: NotificationFormatSchema,
14550
+ attachmentsSent: number().int().nonnegative(),
14551
+ actionsSent: number().int().nonnegative(),
14552
+ truncated: boolean(),
14553
+ dropped: array(string())
14554
+ });
14555
+ var SendResultSchema = object({
14556
+ success: boolean(),
14557
+ error: string().optional(),
14558
+ renderedAs: RenderedAsSchema.optional()
14559
+ });
14560
+ /** Same shape as SendResult — kept as a distinct name for the test panel. */
14561
+ var TestResultSchema = SendResultSchema;
14562
+ /**
14563
+ * Pre-save credential probe against a partial (unsaved) target config.
14564
+ * `resolvedUrl` never includes secrets (token stripped from path).
14565
+ */
14566
+ var ProbeTargetConfigResultSchema = object({
14567
+ ok: boolean(),
14568
+ resolvedUrl: string(),
14569
+ httpStatus: number().int().optional(),
14570
+ stateInstance: string().optional(),
14571
+ error: string().optional()
14572
+ });
14573
+ method(object({}), array(TargetKindSchema)), method(object({}), array(TargetSchema), { auth: "admin" }), method(object({ targetId: string() }), TargetSchema, { auth: "admin" }), method(object({
14574
+ kind: string(),
14575
+ config: record(string(), unknown()).optional(),
14576
+ /**
14577
+ * When editing / duplicating, the blank password field never round-trips
14578
+ * the stored token. Pass the source target id so the provider can restore
14579
+ * secrets server-side before dialling (same merge as upsert).
14580
+ */
14581
+ targetId: string().optional()
14582
+ }), array(DiscoveredTargetSchema), { auth: "admin" }), method(object({
14583
+ kind: string(),
14584
+ config: record(string(), unknown()),
14585
+ /** See `discoverTargets.targetId` — restore stored secrets for a blank password. */
14586
+ targetId: string().optional()
14587
+ }), ProbeTargetConfigResultSchema, {
14588
+ kind: "mutation",
14589
+ auth: "admin"
14590
+ }), method(object({
14591
+ targetId: string(),
14592
+ notification: NotificationSchema
14593
+ }), SendResultSchema, {
14594
+ kind: "mutation",
14595
+ auth: "admin"
14596
+ }), method(object({
14597
+ targetId: string(),
14598
+ sample: NotificationSchema.optional()
14599
+ }), TestResultSchema, {
14600
+ kind: "mutation",
14601
+ auth: "admin"
14602
+ }), method(object({
14603
+ target: TargetSchema,
14604
+ /**
14605
+ * Duplicate flow: create a NEW target id while copying secrets from an
14606
+ * existing row. The UI never holds the stored token; blank / redacted
14607
+ * password fields are restored from this source (D634 still applies if
14608
+ * destinations diverge without a re-typed secret).
14609
+ */
14610
+ cloneSecretsFrom: string().optional()
14611
+ }), TargetSchema, {
14612
+ kind: "mutation",
14613
+ auth: "admin"
14614
+ }), method(object({ targetId: string() }), _void(), {
14615
+ kind: "mutation",
14616
+ auth: "admin"
14617
+ }), method(object({
14618
+ targetId: string(),
14619
+ enabled: boolean()
14620
+ }), _void(), {
14621
+ kind: "mutation",
14622
+ auth: "admin"
14623
+ });
14624
+ looseObject({
14625
+ name: string().min(1),
14626
+ enabled: boolean().optional()
13983
14627
  });
14628
+ TargetSchema.omit({ id: true });
13984
14629
  var EncodeProfileSchema = object({
13985
14630
  video: object({
13986
14631
  codec: _enum([
@@ -20477,31 +21122,21 @@ var APPLIANCE_CAP_VOCABULARY = {
20477
21122
  "pet-fountain": {
20478
21123
  scope: "device",
20479
21124
  noun: t("Pet fountain", "Fontana per animali"),
20480
- actions: [
20481
- {
20482
- id: "petFountain.pumpOn",
20483
- method: "setPump",
20484
- label: t("Pump on", "Pompa accesa"),
20485
- phrase: t("Start the pump of {device}", "Avvia la pompa di {device}"),
20486
- icon: "play",
20487
- args: { on: true }
20488
- },
20489
- {
20490
- id: "petFountain.pumpOff",
20491
- method: "setPump",
20492
- label: t("Pump off", "Pompa spenta"),
20493
- phrase: t("Stop the pump of {device}", "Ferma la pompa di {device}"),
20494
- icon: "square",
20495
- args: { on: false }
20496
- },
20497
- {
20498
- id: "petFountain.resetDailyConsumption",
20499
- method: "resetDailyConsumption",
20500
- label: t("Clear daily consumption", "Azzera il consumo giornaliero"),
20501
- phrase: t("Clear the daily water consumption of {device}", "Azzera il consumo giornaliero di acqua di {device}"),
20502
- icon: "rotate-ccw"
20503
- }
20504
- ],
21125
+ actions: [{
21126
+ id: "petFountain.pumpOn",
21127
+ method: "setPump",
21128
+ label: t("Pump on", "Pompa accesa"),
21129
+ phrase: t("Start the pump of {device}", "Avvia la pompa di {device}"),
21130
+ icon: "play",
21131
+ args: { on: true }
21132
+ }, {
21133
+ id: "petFountain.pumpOff",
21134
+ method: "setPump",
21135
+ label: t("Pump off", "Pompa spenta"),
21136
+ phrase: t("Stop the pump of {device}", "Ferma la pompa di {device}"),
21137
+ icon: "square",
21138
+ args: { on: false }
21139
+ }],
20505
21140
  state: [{
20506
21141
  kind: "boolean",
20507
21142
  field: "empty",
@@ -22520,7 +23155,6 @@ var SYSTEM_CAP_VOCABULARY = {
22520
23155
  "calendar-source": system(INTERNAL),
22521
23156
  calendars: system("calendars feed schedules and conditions, not device actions"),
22522
23157
  composer: system("device composition — an authoring tool, not an action"),
22523
- "connection-test": system(INTERNAL),
22524
23158
  "core-blocks": system(INTERNAL),
22525
23159
  "custom-model-registry": system(ML),
22526
23160
  "data-store-provider": system(INTERNAL),
@@ -44395,8 +45029,15 @@ var ActionInputSchema = object({
44395
45029
  var ActionRunOriginSchema = object({
44396
45030
  /** The automation block whose step started it. */
44397
45031
  blockId: string().min(1).optional() });
44398
- /** `started` = the caller did not ask to wait. */
44399
- var ActionRunOutcomeSchema = union([AutomationRunOutcomeSchema, literal("started")]);
45032
+ /**
45033
+ * `started` = the caller did not ask to wait. `timed-out` = the run reached the
45034
+ * ceiling (`ACTION_RUN_MAX_MS`) and was stopped; it is never a `ran`.
45035
+ */
45036
+ var ActionRunOutcomeSchema = union([
45037
+ AutomationRunOutcomeSchema,
45038
+ literal("started"),
45039
+ literal("timed-out")
45040
+ ]);
44400
45041
  var ActionRunResultSchema = object({
44401
45042
  runId: string().min(1),
44402
45043
  outcome: ActionRunOutcomeSchema,
@@ -44430,427 +45071,6 @@ var UnitWarningSchema = object({
44430
45071
  assumedUnit: string(),
44431
45072
  message: string()
44432
45073
  });
44433
- /**
44434
- * notification-output — canonical, capability-gated notification delivery.
44435
- *
44436
- * Apprise-derived model (see
44437
- * `docs/superpowers/specs/2026-07-03-notification-output-notifier-matrix.md`):
44438
- * callers emit ONE canonical `Notification`; each provider declares a
44439
- * per-kind capability descriptor (`TargetKind`), and the pure degrade
44440
- * engine (`@camstack/types` `prepareNotification`) transcodes / degrades the
44441
- * message to what the kind supports — callers never special-case a service.
44442
- *
44443
- * DESIGN DECISIONS (locked):
44444
- * - Target CRUD lives on THIS cap (`upsertTarget` / `deleteTarget` /
44445
- * `setTargetEnabled`), each provider persisting via the `settings-store`
44446
- * cap. Rationale: the admin UI needs one uniform surface across the
44447
- * notifiers addon AND the HA addon; the addon-`globalSettingsSchema`-array
44448
- * alternative would fork the UI per addon and cannot host the
44449
- * discovery→adopt flow.
44450
- * - `listTargetKinds` / `listTargets` / `discoverTargets` return arrays →
44451
- * the generated cap-mount auto-`concatCollection`-fans them across every
44452
- * registered provider (notifiers addon + HA addon) so one catalog is
44453
- * routable. `send` / `testTarget` / CRUD route to ONE provider by the
44454
- * `addonId` the generated collection router extracts from the call input.
44455
- * - `Attachment.bytes` is `Uint8Array`. Transport-safe: superjson (the tRPC
44456
- * transformer) + UDS MsgPack both round-trip typed arrays — already used by
44457
- * `storage` / `storage-provider` / `recording` caps over the same path. No
44458
- * base64 fallback needed.
44459
- *
44460
- * TODO (deferred, closed-set change — separate decision): add
44461
- * `providerKind: 'notify'` so notification providers surface on the unified
44462
- * admin "Integrations" page.
44463
- */
44464
- /**
44465
- * Zentik-derived typed-media enum — the superset across every kind. Each
44466
- * adapter picks what it supports and the degrade engine filters the rest.
44467
- */
44468
- var AttachmentMediaTypeSchema = _enum([
44469
- "image",
44470
- "video",
44471
- "gif",
44472
- "audio",
44473
- "icon"
44474
- ]);
44475
- /**
44476
- * A single attachment. Exactly one of `url` (remote source, most adapters
44477
- * prefer this) or `bytes` (inline source; required for Pushover-style
44478
- * bytes-only kinds) MUST be present — the degrade engine expresses a
44479
- * url→bytes fetch as a `needsFetch` directive the adapter executes.
44480
- */
44481
- var AttachmentSchema = object({
44482
- mediaType: AttachmentMediaTypeSchema,
44483
- url: string().optional(),
44484
- bytes: _instanceof(Uint8Array).optional(),
44485
- mime: string().optional(),
44486
- name: string().optional()
44487
- }).refine((a) => a.url !== void 0 || a.bytes !== void 0, { message: "Attachment requires either `url` or `bytes`" });
44488
- var NotificationFormatSchema = _enum([
44489
- "text",
44490
- "markdown",
44491
- "html"
44492
- ]);
44493
- /**
44494
- * The CLOSED icon vocabulary an action button may use.
44495
- *
44496
- * A closed set, not a free string, and that is the whole point: an arbitrary
44497
- * icon name is one that ntfy renders, zentik silently drops, and nobody
44498
- * notices — the same class of gap as a zone vocabulary nothing produced
44499
- * ([D35](../../../docs/decisions/adr-0035.md)). Every adapter maps this set or
44500
- * declares `actionIcons: false` and the degrade engine strips the field.
44501
- *
44502
- * Named by INTENT, never by glyph. "check" would tie the vocabulary to one
44503
- * renderer's icon set; "acknowledge" survives an adapter that draws it
44504
- * differently.
44505
- *
44506
- * ── A TOKEN IS NOT A WIRE VALUE ─────────────────────────────────────
44507
- *
44508
- * These names are for US. **No adapter may forward one verbatim.** Each maps
44509
- * the whole set onto its own renderer's vocabulary through a
44510
- * `Record<NotificationActionIcon, string>` — a Record, never a lookup with a
44511
- * fallback, so adding a member here fails every adapter's build until someone
44512
- * decides its glyph, which is the only place that decision can be made
44513
- * honestly.
44514
- *
44515
- * This paragraph is the bug. Zentik declared `actionIcons: true` and passed
44516
- * `disarm` straight through; iOS feeds that string to
44517
- * `UNNotificationActionIcon(systemImageName:)`, `disarm` is not an SF Symbol,
44518
- * and every snooze and alarm button arrived BLANK. A pass-through is not a
44519
- * mapping, and "the field is documented" is not "the value renders".
44520
- *
44521
- * Adding a member is TRAIN-BOUND. The enum lives in the published
44522
- * `@camstack/server` closure and the cap seam validates against the HUB's copy,
44523
- * so an addon that emits a token the running hub does not know does not lose an
44524
- * icon — its whole `send` fails Zod validation and the notification never
44525
- * arrives. Never emit a new token from an addon before the train carrying it.
44526
- */
44527
- var NotificationActionIconSchema = _enum([
44528
- "acknowledge",
44529
- "dismiss",
44530
- "silence",
44531
- "snooze",
44532
- "view",
44533
- "play",
44534
- "open",
44535
- "close",
44536
- "lock",
44537
- "unlock",
44538
- "arm",
44539
- "arm-home",
44540
- "arm-away",
44541
- "arm-night",
44542
- "disarm",
44543
- "light",
44544
- "alert",
44545
- "camera"
44546
- ]);
44547
- /** A single tap-through action button. */
44548
- var NotificationActionSchema = object({
44549
- id: string(),
44550
- label: string(),
44551
- url: string().optional(),
44552
- /** Dropped by the degrade engine for a kind with `caps.actionIcons: false`. */
44553
- icon: NotificationActionIconSchema.optional(),
44554
- /**
44555
- * Renders in a warning style where the notifier supports it.
44556
- *
44557
- * A HINT, never a gate. The callback's authority is its token and nothing
44558
- * else — see `notification-center/action-token.ts` for what that does and
44559
- * does not buy.
44560
- */
44561
- destructive: boolean().optional(),
44562
- /**
44563
- * How the tap should REACH the url.
44564
- *
44565
- * `navigate` (absent, and every button authored before this field) opens it:
44566
- * the phone leaves the notification and shows whatever the callback returns.
44567
- * That is right for a button whose answer the operator wants to read.
44568
- *
44569
- * `background` fires it as a POST and stays put. It exists for the buttons
44570
- * whose whole point is not to interrupt — "silence this for 30 minutes" is
44571
- * an answer to the notification, and being thrown into a browser tab to
44572
- * confirm it costs more attention than the notification did. A backend that
44573
- * cannot do a background call renders it as an ordinary link (the adapters
44574
- * fall back rather than dropping the button), so this is a preference, never
44575
- * a requirement.
44576
- */
44577
- mode: _enum(["navigate", "background"]).optional()
44578
- });
44579
- /** A delivery parameter value: what a notifier declared it takes. */
44580
- var DeliveryParamValueSchema = union([
44581
- string(),
44582
- number(),
44583
- boolean()
44584
- ]);
44585
- /**
44586
- * One extra delivery parameter a notifier KIND declares (D938). A rule that
44587
- * addresses a target of that kind may set it; a kind that declares nothing is
44588
- * never handed one. The admin UI derives its control from this descriptor —
44589
- * no editor knows a service by name.
44590
- *
44591
- * Optional fields are `.optional()`, never `.default()` (a Zod default does not
44592
- * run on the addon cap path).
44593
- */
44594
- var DeliveryParamSchema = object({
44595
- key: string().min(1),
44596
- label: string(),
44597
- /** i18n key of the label, resolved by the declaring addon's namespace. */
44598
- labelKey: string().optional(),
44599
- type: _enum([
44600
- "enum",
44601
- "number",
44602
- "boolean",
44603
- "string"
44604
- ]),
44605
- /** `enum` only: the closed set of accepted values. */
44606
- options: array(object({
44607
- value: string(),
44608
- label: string()
44609
- })).optional(),
44610
- /** `number` only. */
44611
- min: number().optional(),
44612
- max: number().optional(),
44613
- /** What the notifier does when the rule sets nothing; shown as the placeholder. */
44614
- default: DeliveryParamValueSchema.optional()
44615
- });
44616
- /**
44617
- * The canonical notification. `body` is the only hard field (Apprise model).
44618
- * `priority` is a 5-level ORDINAL (1=lowest … 3=normal(default) … 5=urgent),
44619
- * NOT a fixed severity enum — each kind declares its own `caps.levels` and
44620
- * the adapter maps this ordinal onto its native level. `level?` is an
44621
- * optional kind-native level id (`emergency`, `silent`, …) that overrides
44622
- * `priority` for that one target.
44623
- */
44624
- var NotificationSchema = object({
44625
- body: string(),
44626
- title: string().optional(),
44627
- format: NotificationFormatSchema.default("text"),
44628
- priority: number().int().min(1).max(5).default(3),
44629
- level: string().optional(),
44630
- attachments: array(AttachmentSchema).optional(),
44631
- clickUrl: string().optional(),
44632
- actions: array(NotificationActionSchema).optional(),
44633
- sound: string().optional(),
44634
- ttl: number().optional(),
44635
- tag: string().optional(),
44636
- deviceId: number().optional(),
44637
- eventId: string().optional(),
44638
- metadata: record(string(), unknown()).optional(),
44639
- /**
44640
- * Values for the parameters the target's kind DECLARES in
44641
- * {@link TargetKindSchema} `deliveryParams`. Already validated against the
44642
- * declaration by the sender; a notifier reads only the keys it declared.
44643
- */
44644
- delivery: record(string(), DeliveryParamValueSchema).optional()
44645
- });
44646
- /** One declared native severity/priority level for a kind. */
44647
- var TargetKindLevelSchema = object({
44648
- id: string(),
44649
- label: string(),
44650
- /** Which canonical priority (1..5) this level maps to. `null` = qualitative-only. */
44651
- ordinal: number().int().min(1).max(5).nullable(),
44652
- flags: object({
44653
- critical: boolean().optional(),
44654
- silent: boolean().optional(),
44655
- noPush: boolean().optional()
44656
- }).optional(),
44657
- /** e.g. Pushover `emergency` requires `retry` / `expire`. */
44658
- requires: array(string()).optional(),
44659
- description: string().optional()
44660
- });
44661
- /** The full capability block consulted before dispatch. */
44662
- var TargetKindCapsSchema = object({
44663
- attachments: object({
44664
- mediaTypes: array(AttachmentMediaTypeSchema),
44665
- mode: _enum([
44666
- "url",
44667
- "bytes",
44668
- "both"
44669
- ]),
44670
- max: number().int().nonnegative(),
44671
- maxBytes: number().int().positive().optional()
44672
- }),
44673
- /** Max action buttons (0 = none). */
44674
- actions: number().int().nonnegative(),
44675
- /**
44676
- * Whether this kind renders a per-action ICON.
44677
- *
44678
- * `.optional()`, deliberately NOT `.default(false)`: a Zod default does not
44679
- * run on the addon cap path — three production failures in one day taught
44680
- * this repo that once. Absent is read as false by the degrade engine, which
44681
- * is the safe direction: an icon that is not rendered costs nothing, an icon
44682
- * assumed and dropped costs the operator's trust in the field.
44683
- */
44684
- actionIcons: boolean().optional(),
44685
- levels: array(TargetKindLevelSchema),
44686
- format: array(NotificationFormatSchema),
44687
- clickUrl: boolean(),
44688
- sound: boolean(),
44689
- ttl: boolean(),
44690
- bodyMaxLen: number().int().positive()
44691
- });
44692
- /**
44693
- * `configSchema` is a `ConfigUISchema` tree passed through to the admin
44694
- * FormBuilder. Stored as `z.unknown()` at the cap seam (mirrors
44695
- * `device-provider.getChildCreationSchema` `CreationSchemaOutputSchema`) —
44696
- * the union is large and not meant for runtime validation here; the exported
44697
- * `TargetKind` type re-tightens `configSchema` to `ConfigUISchema`.
44698
- */
44699
- var ConfigSchemaPassthrough$4 = unknown();
44700
- var TargetKindSchema = object({
44701
- kind: string(),
44702
- label: string(),
44703
- icon: string(),
44704
- /** Stamped by each provider so the concat-fanned catalog stays routable. */
44705
- addonId: string(),
44706
- /**
44707
- * URL of the kind's bundled BRAND icon, served by the providing addon over
44708
- * its own `addon-routes` surface (`/addon/<addonId>/icons/<kind>`). Absent
44709
- * when the addon bundles no icon for that kind — the client then falls back
44710
- * to a neutral glyph rather than rendering the raw `icon` NAME as text.
44711
- *
44712
- * Root-relative on purpose: it resolves against whatever origin serves a web
44713
- * client, and a native client joins it onto its own hub base.
44714
- *
44715
- * DECLARED here deliberately. It used to travel as an undeclared passthrough
44716
- * field that survived only because the runtime cap-router forwards provider
44717
- * output verbatim — so every consumer had to re-declare it by hand to stop
44718
- * its own Zod parse from stripping it, and the whole arrangement would have
44719
- * broken silently the moment output validation was tightened anywhere.
44720
- */
44721
- iconUrl: string().optional(),
44722
- /**
44723
- * Media type of {@link iconUrl} (`image/svg+xml`, `image/png`, …).
44724
- *
44725
- * The server knows this and therefore says it, because the client cannot
44726
- * safely guess: a React-Native client renders SVG and raster through two
44727
- * DIFFERENT components (`react-native-svg` vs `expo-image` — expo-image does
44728
- * not decode SVG on iOS/Android), so without this it silently fell back to a
44729
- * placeholder glyph for every vector icon while the web build looked fine.
44730
- *
44731
- * Absent when {@link iconUrl} is absent, or for a legacy provider that has
44732
- * not been updated — a client that cannot determine the type should prefer
44733
- * its raster path, which is the safe default for an unknown image.
44734
- */
44735
- iconMediaType: string().optional(),
44736
- configSchema: ConfigSchemaPassthrough$4,
44737
- /**
44738
- * The config keys that decide WHERE this kind's secrets are sent (server,
44739
- * base URL, instance, chat, recipient). A save that changes any of them
44740
- * while leaving a secret redacted is refused by the provider (D634), so an
44741
- * editor uses this to ask for the secret on exactly those edits instead of
44742
- * on every edit.
44743
- *
44744
- * Optional: absent from a provider that holds no secret (the Home Assistant
44745
- * kinds) and from a provider older than this field — an editor that finds
44746
- * it absent must assume ANY edit may need the secret.
44747
- */
44748
- destinationKeys: array(string()).optional(),
44749
- supportsDiscovery: boolean(),
44750
- /**
44751
- * Extra delivery parameters a rule may set for a target of this kind (D938).
44752
- * Absent = none; the rule editor then offers nothing.
44753
- */
44754
- deliveryParams: array(DeliveryParamSchema).optional(),
44755
- caps: TargetKindCapsSchema
44756
- });
44757
- /**
44758
- * A persisted target. `config` holds secrets; providers REDACT secret fields
44759
- * (return a presence marker only) when serving `listTargets` — never
44760
- * round-trip a stored secret to the UI.
44761
- */
44762
- var TargetSchema = object({
44763
- id: string(),
44764
- name: string(),
44765
- kind: string(),
44766
- addonId: string(),
44767
- enabled: boolean(),
44768
- config: record(string(), unknown())
44769
- });
44770
- /** A discovery-surfaced candidate (config is partial + non-secret). */
44771
- var DiscoveredTargetSchema = object({
44772
- kind: string(),
44773
- suggestedName: string(),
44774
- config: record(string(), unknown())
44775
- });
44776
- /** The degrade engine's report — what was resolved / dropped / degraded. */
44777
- var RenderedAsSchema = object({
44778
- level: string(),
44779
- format: NotificationFormatSchema,
44780
- attachmentsSent: number().int().nonnegative(),
44781
- actionsSent: number().int().nonnegative(),
44782
- truncated: boolean(),
44783
- dropped: array(string())
44784
- });
44785
- var SendResultSchema = object({
44786
- success: boolean(),
44787
- error: string().optional(),
44788
- renderedAs: RenderedAsSchema.optional()
44789
- });
44790
- /** Same shape as SendResult — kept as a distinct name for the test panel. */
44791
- var TestResultSchema = SendResultSchema;
44792
- /**
44793
- * Pre-save credential probe against a partial (unsaved) target config.
44794
- * `resolvedUrl` never includes secrets (token stripped from path).
44795
- */
44796
- var ProbeTargetConfigResultSchema = object({
44797
- ok: boolean(),
44798
- resolvedUrl: string(),
44799
- httpStatus: number().int().optional(),
44800
- stateInstance: string().optional(),
44801
- error: string().optional()
44802
- });
44803
- method(object({}), array(TargetKindSchema)), method(object({}), array(TargetSchema), { auth: "admin" }), method(object({ targetId: string() }), TargetSchema, { auth: "admin" }), method(object({
44804
- kind: string(),
44805
- config: record(string(), unknown()).optional(),
44806
- /**
44807
- * When editing / duplicating, the blank password field never round-trips
44808
- * the stored token. Pass the source target id so the provider can restore
44809
- * secrets server-side before dialling (same merge as upsert).
44810
- */
44811
- targetId: string().optional()
44812
- }), array(DiscoveredTargetSchema), { auth: "admin" }), method(object({
44813
- kind: string(),
44814
- config: record(string(), unknown()),
44815
- /** See `discoverTargets.targetId` — restore stored secrets for a blank password. */
44816
- targetId: string().optional()
44817
- }), ProbeTargetConfigResultSchema, {
44818
- kind: "mutation",
44819
- auth: "admin"
44820
- }), method(object({
44821
- targetId: string(),
44822
- notification: NotificationSchema
44823
- }), SendResultSchema, {
44824
- kind: "mutation",
44825
- auth: "admin"
44826
- }), method(object({
44827
- targetId: string(),
44828
- sample: NotificationSchema.optional()
44829
- }), TestResultSchema, {
44830
- kind: "mutation",
44831
- auth: "admin"
44832
- }), method(object({
44833
- target: TargetSchema,
44834
- /**
44835
- * Duplicate flow: create a NEW target id while copying secrets from an
44836
- * existing row. The UI never holds the stored token; blank / redacted
44837
- * password fields are restored from this source (D634 still applies if
44838
- * destinations diverge without a re-typed secret).
44839
- */
44840
- cloneSecretsFrom: string().optional()
44841
- }), TargetSchema, {
44842
- kind: "mutation",
44843
- auth: "admin"
44844
- }), method(object({ targetId: string() }), _void(), {
44845
- kind: "mutation",
44846
- auth: "admin"
44847
- }), method(object({
44848
- targetId: string(),
44849
- enabled: boolean()
44850
- }), _void(), {
44851
- kind: "mutation",
44852
- auth: "admin"
44853
- });
44854
45074
  _enum([
44855
45075
  "automation",
44856
45076
  "action",
@@ -44918,6 +45138,8 @@ method(object({}), array(ActionEntrySchema), { auth: "admin" }), method(object({
44918
45138
  kind: "mutation",
44919
45139
  auth: "admin"
44920
45140
  });
45141
+ /** `timeoutMs` of `actions.run`: a waited call outlives any legal run. */
45142
+ var ACTION_RUN_TIMEOUT_MS = 363e4;
44921
45143
  /**
44922
45144
  * actions — the ONE surface for runnable actions, for the UI and for
44923
45145
  * automations. Provided by the core-blocks builtin on the hub.
@@ -44936,6 +45158,12 @@ method(object({}), array(ActionEntrySchema), { auth: "admin" }), method(object({
44936
45158
  * An admin, and an in-process caller (an automation block), may run any action.
44937
45159
  * Every refusal is typed (`[not-linked] …`) and logged.
44938
45160
  *
45161
+ * **A run lasts at most `ACTION_RUN_MAX_MS` (60 min).** The provider stops a
45162
+ * run that reaches it and answers `timed-out` (never `ran`); an action whose
45163
+ * `wait` steps alone add up to more is refused at create/update
45164
+ * (`[invalid-steps]`). `run` declares a `timeoutMs` above that ceiling, so a
45165
+ * waited call (an automation step) is never cut by the 60 s transport default.
45166
+ *
44939
45167
  * A second `run` of an action that is already running is REFUSED — traced and
44940
45168
  * logged — never queued.
44941
45169
  */
@@ -44962,7 +45190,8 @@ method(object({}), array(ActionEntrySchema), { auth: "admin" }), method(object({
44962
45190
  role: "viewer",
44963
45191
  auth: "protected",
44964
45192
  kind: "mutation",
44965
- caller: "required"
45193
+ caller: "required",
45194
+ timeoutMs: ACTION_RUN_TIMEOUT_MS
44966
45195
  }), method(ActionIdInput, _void(), {
44967
45196
  kind: "mutation",
44968
45197
  auth: "admin"
@@ -48748,37 +48977,6 @@ method(object({
48748
48977
  kind: "mutation",
48749
48978
  auth: "admin"
48750
48979
  }), method(object({ blockIds: array(string()) }), object({ states: array(CompositionBlockStateSchema) }), { auth: "admin" });
48751
- var ConnectionTestOutcomeSchema = discriminatedUnion("outcome", [
48752
- object({
48753
- outcome: literal("validated"),
48754
- /** Round-trip of the sign-in, when the provider measured it. */
48755
- latencyMs: number().nonnegative().optional(),
48756
- /** Optional human detail worth showing next to the tick
48757
- * ("3 devices visible on this account"). */
48758
- detail: string().optional()
48759
- }).strict(),
48760
- object({
48761
- outcome: literal("rejected"),
48762
- error: string()
48763
- }).strict(),
48764
- object({
48765
- outcome: literal("inconclusive"),
48766
- error: string()
48767
- }).strict()
48768
- ]);
48769
- var ConnectionTestInputSchema = object({
48770
- /** Candidate integration settings, exactly as the create form collected them. */
48771
- settings: record(string(), unknown()) });
48772
- /**
48773
- * What the provider's test actually DOES, so the UI can say it in words before
48774
- * the operator presses the button ("Signs in to the Dreo cloud"). Purely
48775
- * descriptive — it never changes routing.
48776
- */
48777
- var ConnectionTestDescriptorSchema = object({ label: string() });
48778
- method(ConnectionTestInputSchema, ConnectionTestOutcomeSchema, {
48779
- kind: "mutation",
48780
- auth: "admin"
48781
- }), method(_void(), ConnectionTestDescriptorSchema, { auth: "admin" });
48782
48980
  object({
48783
48981
  /** True when the upstream system considers the entity connected. */
48784
48982
  connected: boolean(),
@@ -49036,6 +49234,9 @@ var MediaPlayerStatusSchema = object({
49036
49234
  /** Repeat mode. Null when no repeat surface.
49037
49235
  * Pair with `DeviceFeature.MediaPlayerRepeat`. */
49038
49236
  repeat: MediaPlayerRepeatSchema.nullable(),
49237
+ /** Ms epoch when `position` was read from the device. Null when the driver
49238
+ * does not say; a UI that advances the position while playing counts from it. */
49239
+ positionUpdatedAt: number().nullable().default(null),
49039
49240
  /** Ms epoch when the slice was last updated. */
49040
49241
  lastChangedAt: number()
49041
49242
  });
@@ -54847,6 +55048,7 @@ var IntegrationWithStateSchema = object({
54847
55048
  id: string(),
54848
55049
  addonId: string(),
54849
55050
  name: string(),
55051
+ /** A projection of the instance body's switch (`setInstanceEnabled` is the only writer). */
54850
55052
  enabled: boolean(),
54851
55053
  info: record(string(), unknown()).readonly(),
54852
55054
  /** The discovery candidate this integration was set up from (D984). */
@@ -54859,6 +55061,7 @@ var IntegrationLiteSchema = object({
54859
55061
  id: string(),
54860
55062
  addonId: string(),
54861
55063
  name: string(),
55064
+ /** A projection of the instance body's switch (`setInstanceEnabled` is the only writer). */
54862
55065
  enabled: boolean(),
54863
55066
  info: record(string(), unknown()).readonly(),
54864
55067
  /** The discovery candidate this integration was set up from (D984). */
@@ -54904,10 +55107,9 @@ var AvailableIntegrationTypeSchema = object({
54904
55107
  * locations" checkbox. Provider-declared in the addon manifest. */
54905
55108
  supportsLocationImport: boolean(),
54906
55109
  /**
54907
- * True when this integration DECLARES a pre-creation test (the
54908
- * `connection-test` cap, or a broker whose settings it stores). Drives the
54909
- * Test button: an integration that cannot be tested must say so up front
54910
- * rather than offering a button that always answers the same nonsense.
55110
+ * True when this integration's instances declare a Test (`integration-instances.describe().canTest`,
55111
+ * D1016). An integration that cannot be tested must say so up front rather than offering a
55112
+ * button that always answers the same nonsense.
54911
55113
  */
54912
55114
  canTest: boolean(),
54913
55115
  existingInstances: array(object({
@@ -54958,15 +55160,21 @@ var TestConnectionResultSchema = object({
54958
55160
  var CreateIntegrationInputSchema = object({
54959
55161
  addonId: string(),
54960
55162
  name: string(),
54961
- enabled: boolean().optional(),
54962
55163
  info: record(string(), unknown()).optional(),
54963
55164
  /** `stableId` of the discovery candidate the form was seeded from (D984). */
54964
55165
  originStableId: string().optional(),
54965
- settings: record(string(), unknown()).optional()
55166
+ settings: record(string(), unknown()).optional(),
55167
+ /** The instance kind being created, for a provider with several; omitted = its only testable kind. */
55168
+ kind: string().min(1).optional()
54966
55169
  });
54967
55170
  var UpdateIntegrationInputSchema = object({
54968
55171
  id: string(),
54969
55172
  name: string().optional(),
55173
+ /**
55174
+ * Accepted for a FIXED builtin only (`info.fixed`: alarm panel, camera grid, core blocks,
55175
+ * terminal), which keeps no instance record: the registry flag is its one store. Any other
55176
+ * integration is switched through `integration-instances.setInstanceEnabled`.
55177
+ */
54970
55178
  enabled: boolean().optional(),
54971
55179
  info: record(string(), unknown()).optional()
54972
55180
  });
@@ -54983,13 +55191,7 @@ method(_void(), array(IntegrationWithStateSchema)), method(object({ id: string()
54983
55191
  }), method(object({ id: string() }), DeleteIntegrationResultSchema, {
54984
55192
  kind: "mutation",
54985
55193
  auth: "admin"
54986
- }), method(_void(), array(AvailableIntegrationTypeSchema), { auth: "admin" }), method(object({
54987
- addonId: string(),
54988
- settings: record(string(), unknown())
54989
- }), TestConnectionResultSchema, {
54990
- kind: "mutation",
54991
- auth: "admin"
54992
- });
55194
+ }), method(_void(), array(AvailableIntegrationTypeSchema), { auth: "admin" });
54993
55195
  /**
54994
55196
  * `integration-instances` - the connection of an addon that holds ONE or SEVERAL
54995
55197
  * (an account, a relay, a destination) as typed records (D985, D986). The addon's
@@ -55014,7 +55216,7 @@ var IntegrationInstanceIdSchema = string().min(1);
55014
55216
  var IntegrationInstanceModeSchema = _enum(["single", "multiple"]);
55015
55217
  /**
55016
55218
  * What the addon's instances ARE for the Integrations page (planning#416). `devices`: each
55017
- * instance is an integration that brings devices (the registry owns its on/off switch);
55219
+ * instance is an integration that brings devices (its record body owns the on/off switch);
55018
55220
  * `services`: a connection configured from the addon's own function page, never listed on
55019
55221
  * Integrations.
55020
55222
  * It is the same vocabulary as the manifest's `integrationRole`, which stays as an override.
@@ -55131,8 +55333,8 @@ var IntegrationInstanceSchema = object({
55131
55333
  configured: boolean(),
55132
55334
  /**
55133
55335
  * The instance's own on/off switch (D996), derived from the record body (`enabled !== false`,
55134
- * so a row written before the field existed is on). Absent when the `integrations` registry
55135
- * owns the switch (`describe().role` is `devices`): read it from the registry row.
55336
+ * so a row written before the field existed is on). The same for every role, `devices` included:
55337
+ * the body is the one store, `setInstanceEnabled` the one writer (epic #440, step 3).
55136
55338
  */
55137
55339
  enabled: boolean().optional(),
55138
55340
  /** The kind of this instance (one of `describe().kinds[].id`), when the provider has kinds. */
@@ -57968,6 +58170,8 @@ var MigrationIntegrationSchema = object({
57968
58170
  addonId: string(),
57969
58171
  name: string(),
57970
58172
  info: Rows,
58173
+ /** The registry's stored switch: read by the one-switch migration, nothing else. */
58174
+ enabled: boolean().optional(),
57971
58175
  originStableId: string().optional()
57972
58176
  });
57973
58177
  var MigrationDeviceSchema = object({
@@ -63672,13 +63876,6 @@ var AddBrokerInputSchema = object({
63672
63876
  });
63673
63877
  var AddBrokerResultSchema = object({ id: string() });
63674
63878
  var IdInputSchema = object({ id: string() });
63675
- var TestResultSchema$1 = discriminatedUnion("ok", [object({
63676
- ok: literal(true),
63677
- latencyMs: number()
63678
- }), object({
63679
- ok: literal(false),
63680
- error: string()
63681
- })]);
63682
63879
  var StartEmbeddedInputSchema = object({
63683
63880
  port: number().int().min(1).max(65535).default(1883),
63684
63881
  /** Allow anonymous connect (no username/password). Default: false. */
@@ -63701,9 +63898,6 @@ method(_void(), array(BrokerInfoSchema)), method(IdInputSchema, BrokerConnection
63701
63898
  }), method(IdInputSchema, _void(), {
63702
63899
  kind: "mutation",
63703
63900
  auth: "admin"
63704
- }), method(IdInputSchema, TestResultSchema$1, {
63705
- kind: "mutation",
63706
- auth: "admin"
63707
63901
  }), method(StartEmbeddedInputSchema, StartEmbeddedResultSchema, {
63708
63902
  kind: "mutation",
63709
63903
  auth: "admin"
@@ -67964,14 +68158,6 @@ object({
67964
68158
  empty: boolean().nullable(),
67965
68159
  /** True while the pump is running. Null while unknown. */
67966
68160
  pumpRunning: boolean().nullable(),
67967
- /** Water drunk in the last drink, in litres. */
67968
- lastDrink: number().min(0).nullable().meta(readingMeta("volume")),
67969
- /** Water drunk in the current hour, in litres. */
67970
- currentHourDrink: number().min(0).nullable().meta(readingMeta("volume")),
67971
- /** Water drunk over the last 24 hours (rolling), in litres. */
67972
- last24hDrink: number().min(0).nullable().meta(readingMeta("volume")),
67973
- /** Water drunk since local midnight, in litres. Null when the fountain has no such sensor. */
67974
- todayDrink: number().min(0).nullable().meta(readingMeta("volume")),
67975
68161
  /** Decoded fault message. Null means healthy; a non-null string is an active fault. */
67976
68162
  error: string().nullable(),
67977
68163
  /** Ms epoch when the slice was last refreshed. */
@@ -67984,9 +68170,6 @@ DeviceType.PetFountain, method(object({
67984
68170
  }), _void(), {
67985
68171
  kind: "mutation",
67986
68172
  auth: "protected"
67987
- }), method(object({ deviceId: DeviceIdSchema$1 }), _void(), {
67988
- kind: "mutation",
67989
- auth: "protected"
67990
68173
  });
67991
68174
  /**
67992
68175
  * The wire shapes of the Auto tune plan and apply (D745), used by the
@@ -76565,7 +76748,7 @@ var TrainingProviderTypeSchema = object({
76565
76748
  label: string(),
76566
76749
  /** Path under the addon package (e.g. `assets/training-modal/icon.svg`). */
76567
76750
  iconAsset: string(),
76568
- /** Owning `training-provider` addon — collection selector for createEntry. */
76751
+ /** Owning `training-provider` addon. */
76569
76752
  addonId: string(),
76570
76753
  /**
76571
76754
  * Fields for one entry of this type (credentials + defaults). Absent on a
@@ -76610,36 +76793,6 @@ var TrainingProviderDescriptorSchema = object({
76610
76793
  */
76611
76794
  formValues: record(string(), unknown()).optional()
76612
76795
  });
76613
- /**
76614
- * Patch one entry's name, credentials and defaults. Pin with owning `{ addonId }`.
76615
- * An omitted or empty `tokenSecret` means KEEP the stored secret (D787).
76616
- * `{ $secretClear: true }` clears it.
76617
- */
76618
- var TrainingProviderUpdateEntryInputSchema = object({
76619
- entryId: string().min(1),
76620
- name: string().min(1),
76621
- tokenId: string().optional(),
76622
- tokenSecret: union([string(), object({ $secretClear: literal(true) })]).optional(),
76623
- environment: string().optional(),
76624
- gpuType: string().optional(),
76625
- region: string().optional(),
76626
- costCapUsd: number().nonnegative().optional(),
76627
- maxRuntimeSec: number().int().positive().optional(),
76628
- failedDatasetGraceHours: number().nonnegative().optional()
76629
- });
76630
- var TrainingCredentialCheckSchema = object({
76631
- ok: boolean(),
76632
- /** Workspace / account name, when the provider says. */
76633
- account: string().optional(),
76634
- reason: _enum([
76635
- "missing",
76636
- "invalid",
76637
- "forbidden",
76638
- "network",
76639
- "quota"
76640
- ]).optional(),
76641
- detail: string().optional()
76642
- });
76643
76796
  var ProviderJobStateSchema = _enum([
76644
76797
  "pending",
76645
76798
  "starting",
@@ -76687,22 +76840,6 @@ var TrainingLogLineSchema = object({
76687
76840
  text: string()
76688
76841
  });
76689
76842
  method(object({}), array(TrainingProviderDescriptorSchema).readonly(), { auth: "admin" }), method(object({}), array(TrainingProviderTypeSchema).readonly(), { auth: "admin" }), method(object({}), array(TrainingProviderEntrySchema).readonly(), { auth: "admin" }), method(object({
76690
- typeId: string().min(1),
76691
- name: string().min(1)
76692
- }), object({ entryId: string() }), {
76693
- kind: "mutation",
76694
- auth: "admin"
76695
- }), method(object({ entryId: string().min(1) }), object({ ok: literal(true) }), {
76696
- kind: "mutation",
76697
- auth: "admin"
76698
- }), method(TrainingProviderUpdateEntryInputSchema, object({ ok: literal(true) }), {
76699
- kind: "mutation",
76700
- auth: "admin"
76701
- }), method(object({ entryId: string().min(1) }), TrainingCredentialCheckSchema, {
76702
- kind: "mutation",
76703
- auth: "admin",
76704
- timeoutMs: 3e4
76705
- }), method(object({
76706
76843
  entryId: string().min(1),
76707
76844
  gpuType: string(),
76708
76845
  region: string(),
@@ -80148,20 +80285,6 @@ Object.freeze({
80148
80285
  access: "view",
80149
80286
  role: "admin"
80150
80287
  },
80151
- "connectionTest.describeTest": {
80152
- capName: "connection-test",
80153
- capScope: "system",
80154
- addonId: null,
80155
- access: "view",
80156
- role: "admin"
80157
- },
80158
- "connectionTest.testSettings": {
80159
- capName: "connection-test",
80160
- capScope: "system",
80161
- addonId: null,
80162
- access: "create",
80163
- role: "admin"
80164
- },
80165
80288
  "connectivity.getStatus": {
80166
80289
  capName: "connectivity",
80167
80290
  capScope: "device",
@@ -82528,13 +82651,6 @@ Object.freeze({
82528
82651
  access: "view",
82529
82652
  role: "admin"
82530
82653
  },
82531
- "integrations.testConnection": {
82532
- capName: "integrations",
82533
- capScope: "system",
82534
- addonId: null,
82535
- access: "create",
82536
- role: "admin"
82537
- },
82538
82654
  "integrations.update": {
82539
82655
  capName: "integrations",
82540
82656
  capScope: "system",
@@ -83767,13 +83883,6 @@ Object.freeze({
83767
83883
  access: "create",
83768
83884
  role: "admin"
83769
83885
  },
83770
- "mqttBroker.testConnection": {
83771
- capName: "mqtt-broker",
83772
- capScope: "system",
83773
- addonId: null,
83774
- access: "create",
83775
- role: "admin"
83776
- },
83777
83886
  "nativeObjectDetection.getOptions": {
83778
83887
  capName: "native-object-detection",
83779
83888
  capScope: "device",
@@ -84649,13 +84758,6 @@ Object.freeze({
84649
84758
  access: "view",
84650
84759
  role: "viewer"
84651
84760
  },
84652
- "petFountain.resetDailyConsumption": {
84653
- capName: "pet-fountain",
84654
- capScope: "device",
84655
- addonId: null,
84656
- access: "delete",
84657
- role: "viewer"
84658
- },
84659
84761
  "petFountain.setPump": {
84660
84762
  capName: "pet-fountain",
84661
84763
  capScope: "device",
@@ -88611,20 +88713,6 @@ Object.freeze({
88611
88713
  access: "create",
88612
88714
  role: "admin"
88613
88715
  },
88614
- "trainingProvider.createEntry": {
88615
- capName: "training-provider",
88616
- capScope: "system",
88617
- addonId: null,
88618
- access: "create",
88619
- role: "admin"
88620
- },
88621
- "trainingProvider.deleteEntry": {
88622
- capName: "training-provider",
88623
- capScope: "system",
88624
- addonId: null,
88625
- access: "delete",
88626
- role: "admin"
88627
- },
88628
88716
  "trainingProvider.describe": {
88629
88717
  capName: "training-provider",
88630
88718
  capScope: "system",
@@ -88695,13 +88783,6 @@ Object.freeze({
88695
88783
  access: "create",
88696
88784
  role: "admin"
88697
88785
  },
88698
- "trainingProvider.updateEntry": {
88699
- capName: "training-provider",
88700
- capScope: "system",
88701
- addonId: null,
88702
- access: "create",
88703
- role: "admin"
88704
- },
88705
88786
  "trainingProvider.uploadDataset": {
88706
88787
  capName: "training-provider",
88707
88788
  capScope: "system",
@@ -88709,13 +88790,6 @@ Object.freeze({
88709
88790
  access: "create",
88710
88791
  role: "admin"
88711
88792
  },
88712
- "trainingProvider.validateCredentials": {
88713
- capName: "training-provider",
88714
- capScope: "system",
88715
- addonId: null,
88716
- access: "create",
88717
- role: "admin"
88718
- },
88719
88793
  "turnProvider.getTurnServers": {
88720
88794
  capName: "turn-provider",
88721
88795
  capScope: "system",
@@ -91080,11 +91154,6 @@ Object.freeze({
91080
91154
  form: "single",
91081
91155
  optional: false
91082
91156
  }],
91083
- "petFountain.resetDailyConsumption": [{
91084
- name: "deviceId",
91085
- form: "single",
91086
- optional: false
91087
- }],
91088
91157
  "petFountain.setPump": [{
91089
91158
  name: "deviceId",
91090
91159
  form: "single",
@@ -95160,7 +95229,6 @@ object({
95160
95229
  delay: number().nonnegative().optional(),
95161
95230
  commands: record(string(), unknown())
95162
95231
  });
95163
- entryBody({ brokerId: string() });
95164
95232
  //#endregion
95165
95233
  //#region src/migrations/drop-keys.ts
95166
95234
  /** The canonical settings table: one row per key, id `<addonId>.<key>`. */