@camstack/addon-pipeline-orchestrator 1.2.663 → 1.2.665

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
@@ -30,7 +30,7 @@ node_fs = __toESM(node_fs);
30
30
  let node_path = require("node:path");
31
31
  node_path = __toESM(node_path);
32
32
  let node_url = require("node:url");
33
- //#region ../types/dist/event-category-BmPm98n0.mjs
33
+ //#region ../types/dist/event-category-78tcBemo.mjs
34
34
  var EventCategory = /* @__PURE__ */ function(EventCategory) {
35
35
  EventCategory["SystemBoot"] = "system.boot";
36
36
  EventCategory["SystemAddonsReady"] = "system.addons-ready";
@@ -151,6 +151,23 @@ var EventCategory = /* @__PURE__ */ function(EventCategory) {
151
151
  */
152
152
  EventCategory["AddonLoadRecovered"] = "addon.load-recovered";
153
153
  /**
154
+ * An addon is RUNNING although its installed package is below what the
155
+ * running server requires (`camstack.requires.addons` of the server, or the
156
+ * addon's own `requires.server`). Raised once per streak by the unsupported-
157
+ * addon tracker, on the hub and on agents; AlertCenter turns it into one
158
+ * operator alert per node and package. The addon is never held back for it.
159
+ *
160
+ * Payload: `{ packageName, addonId, nodeId, installedVersion, requiredMinimum, serverVersion, unmet }`.
161
+ */
162
+ EventCategory["AddonUnsupportedVersion"] = "addon.unsupported-version";
163
+ /**
164
+ * The package of an {@link AddonUnsupportedVersion} alert reached a supported
165
+ * version, or is no longer installed on the node. AlertCenter dismisses the matching alert.
166
+ *
167
+ * Payload: `{ packageName, addonId, nodeId }`.
168
+ */
169
+ EventCategory["AddonUnsupportedResolved"] = "addon.unsupported-resolved";
170
+ /**
154
171
  * Monitor scheduled the next retry for a failed addon. Transient —
155
172
  * surfaced to the UI for live-updating the "next retry in Ns"
156
173
  * countdown on the Addons page row, NOT persisted as an alert.
@@ -261,7 +278,7 @@ var EventCategory = /* @__PURE__ */ function(EventCategory) {
261
278
  EventCategory["ProcessRestarted"] = "process.restarted";
262
279
  /**
263
280
  * The SET of storage locations changed — one was created, edited, enabled,
264
- * disabled or deleted through `storage.upsertLocation` / `deleteLocation`.
281
+ * disabled or deleted through the location instances or the forced-delete action.
265
282
  *
266
283
  * Telemetry, not a transaction (D8/D11): every consumer that re-resolves on
267
284
  * it must also converge on its own periodic path, because a dropped event
@@ -6012,7 +6029,7 @@ var ZodIssueCode = {
6012
6029
  var ZodFirstPartyTypeKind;
6013
6030
  ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {});
6014
6031
  //#endregion
6015
- //#region ../types/dist/sleep-BX_MqzUe.mjs
6032
+ //#region ../types/dist/sleep-CQP-REJp.mjs
6016
6033
  /**
6017
6034
  * The audio chunk plane's byte format, and the ONE expansion from a coded
6018
6035
  * window to float samples (D455).
@@ -6369,6 +6386,59 @@ Object.fromEntries([
6369
6386
  function isValuelessField(field) {
6370
6387
  return field.type === "separator" || field.type === "info" || field.type === "qr-code" || field.type === "button" || field.type === "object-array" || field.type === "widget" || field.type === "addon-action-button" || field.type === "device-action-button" || field.type === "account-sign-in" || field.type === "secret-presence";
6371
6388
  }
6389
+ /**
6390
+ * Base collector: flatten a hydrated `ConfigUISchemaWithValues` into
6391
+ * `key → { value, default }`, recursing through `group` and `sub-tabs`
6392
+ * layout fields. Keeping `value` and `default` SEPARATE (rather than
6393
+ * pre-resolving) lets callers both read the effective value AND detect
6394
+ * overrides (`value` differs from `default`). Structural over `unknown`;
6395
+ * malformed input yields an empty map, never throws.
6396
+ */
6397
+ function collectHydratedFieldEntries(schema) {
6398
+ const out = /* @__PURE__ */ new Map();
6399
+ if (typeof schema !== "object" || schema === null) return out;
6400
+ const sections = schema.sections;
6401
+ if (!Array.isArray(sections)) return out;
6402
+ for (const section of sections) if (typeof section === "object" && section !== null) collectFieldEntriesInto(section.fields, out);
6403
+ return out;
6404
+ }
6405
+ /** Recursive field walker for {@link collectHydratedFieldEntries}. */
6406
+ function collectFieldEntriesInto(fields, into) {
6407
+ if (!Array.isArray(fields)) return;
6408
+ for (const field of fields) {
6409
+ if (typeof field !== "object" || field === null) continue;
6410
+ const type = field.type;
6411
+ if (type === "group") {
6412
+ collectFieldEntriesInto(field.fields, into);
6413
+ continue;
6414
+ }
6415
+ if (type === "sub-tabs") {
6416
+ const tabs = field.tabs;
6417
+ if (Array.isArray(tabs)) {
6418
+ for (const tab of tabs) if (typeof tab === "object" && tab !== null) collectFieldEntriesInto(tab.fields, into);
6419
+ }
6420
+ continue;
6421
+ }
6422
+ const key = field.key;
6423
+ if (typeof key !== "string" || key.length === 0) continue;
6424
+ if (!("value" in field)) continue;
6425
+ into.set(key, {
6426
+ value: field.value,
6427
+ default: field.default
6428
+ });
6429
+ }
6430
+ }
6431
+ /**
6432
+ * Flatten a hydrated settings payload into `key → EFFECTIVE value`
6433
+ * (`value ?? default`). The read-side inverse of `hydrateSchema` for the
6434
+ * common "just give me the resolved values" case. Built on
6435
+ * {@link collectHydratedFieldEntries}.
6436
+ */
6437
+ function collectHydratedFieldValues(schema) {
6438
+ const out = /* @__PURE__ */ new Map();
6439
+ for (const [key, entry] of collectHydratedFieldEntries(schema)) out.set(key, entry.value ?? entry.default);
6440
+ return out;
6441
+ }
6372
6442
  function hydrateSchema(schema, values, options = {}) {
6373
6443
  return {
6374
6444
  ...schema.tabs ? { tabs: [...schema.tabs] } : {},
@@ -6705,6 +6775,344 @@ async function runAddonMigrations(host, migrations, logger, options = {}) {
6705
6775
  blockOwner
6706
6776
  };
6707
6777
  }
6778
+ /** The record calls the one-switch migration makes, over the migration API. */
6779
+ function switchRecordsOverMigrationApi(api) {
6780
+ return { kind: (definition) => {
6781
+ const handle = api.records.kind(definition);
6782
+ return {
6783
+ get: (id) => handle.get({ id }),
6784
+ put: (input, opts) => handle.put({
6785
+ ...input,
6786
+ ...opts?.ifRev === void 0 ? {} : { ifRev: opts.ifRev }
6787
+ }),
6788
+ patch: (id, partial) => handle.patch({
6789
+ id,
6790
+ partial
6791
+ })
6792
+ };
6793
+ } };
6794
+ }
6795
+ function integrationRowsApiOver(api) {
6796
+ return {
6797
+ list: async () => (await api.integrations.list({})).integrations,
6798
+ readLegacyIntegrationRows: (input) => api.legacyRows.read(input),
6799
+ clearLegacyIntegrationRows: (input) => api.legacyRows.clear(input)
6800
+ };
6801
+ }
6802
+ var PREFIX = "records/";
6803
+ /**
6804
+ * Cross-realm brand. An addon bundles its own copy of this module (D15) while
6805
+ * `ctx.records` is the HOST's door, so an error thrown by the host is an
6806
+ * instance of the host's classes, not of the addon's. The brand plus the code
6807
+ * make `instanceof` answer by identity of the failure, not of the copy.
6808
+ */
6809
+ var RECORDS_ERROR_BRAND = Symbol.for("camstack.records-error");
6810
+ function carriesBrand(value) {
6811
+ return typeof value === "object" && value !== null && Reflect.get(value, RECORDS_ERROR_BRAND) === true;
6812
+ }
6813
+ /** The base of every records failure. `detail` is the human part of the message. */
6814
+ var RecordsError = class extends Error {
6815
+ /** The code a subclass stands for; the base stands for every code. */
6816
+ static code = void 0;
6817
+ /**
6818
+ * `instanceof` across copies of this module: any branded error is a
6819
+ * `RecordsError`, and is an instance of a subclass only when its code is the
6820
+ * subclass's code. Same-copy answers are unchanged.
6821
+ */
6822
+ static [Symbol.hasInstance](value) {
6823
+ if (Function.prototype[Symbol.hasInstance].call(this, value)) return true;
6824
+ if (!carriesBrand(value)) return false;
6825
+ return this.code === void 0 || value.code === this.code;
6826
+ }
6827
+ code;
6828
+ detail;
6829
+ [RECORDS_ERROR_BRAND] = true;
6830
+ constructor(code, detail) {
6831
+ super(`${PREFIX}${code}: ${detail}`);
6832
+ this.name = "RecordsError";
6833
+ this.code = code;
6834
+ this.detail = detail;
6835
+ }
6836
+ };
6837
+ var InvalidRecordError = class InvalidRecordError extends RecordsError {
6838
+ static code = "invalid-record";
6839
+ constructor(detail) {
6840
+ super(InvalidRecordError.code, detail);
6841
+ this.name = "InvalidRecordError";
6842
+ }
6843
+ };
6844
+ /** A kind declaration the engine refuses (non-additive change, bad shape, wrong file). */
6845
+ var DeclarationRefusedError = class DeclarationRefusedError extends RecordsError {
6846
+ static code = "declaration-refused";
6847
+ constructor(detail) {
6848
+ super(DeclarationRefusedError.code, detail);
6849
+ this.name = "DeclarationRefusedError";
6850
+ }
6851
+ };
6852
+ object({
6853
+ cap: string().min(1),
6854
+ kind: string().min(1).optional()
6855
+ });
6856
+ var GLOBAL_SCOPE = { kind: "global" };
6857
+ /** The scope every addon-wide (not per-node, not per-device) setting lives in. */
6858
+ function globalSecretScope() {
6859
+ return GLOBAL_SCOPE;
6860
+ }
6861
+ function encodeSegment(value) {
6862
+ return encodeURIComponent(value);
6863
+ }
6864
+ function decodeSegment(value) {
6865
+ try {
6866
+ return decodeURIComponent(value);
6867
+ } catch {
6868
+ return null;
6869
+ }
6870
+ }
6871
+ /**
6872
+ * The field path of a value inside an array item, addressed by the item's id:
6873
+ * `arrayItemFieldPath('providers', 'authentik', 'clientSecret')` →
6874
+ * `providers[authentik].clientSecret`.
6875
+ */
6876
+ function arrayItemFieldPath(arrayKey, itemId, fieldKey) {
6877
+ return `${arrayKey}[${encodeSegment(itemId)}].${fieldKey}`;
6878
+ }
6879
+ function parseScope(segments) {
6880
+ switch (segments[0]) {
6881
+ case "global": return {
6882
+ scope: GLOBAL_SCOPE,
6883
+ used: 1
6884
+ };
6885
+ case "node": {
6886
+ const nodeId = segments[1] !== void 0 ? decodeSegment(segments[1]) : null;
6887
+ return nodeId === null || nodeId.length === 0 ? null : {
6888
+ scope: {
6889
+ kind: "node",
6890
+ nodeId
6891
+ },
6892
+ used: 2
6893
+ };
6894
+ }
6895
+ case "device": {
6896
+ const raw = segments[1];
6897
+ if (raw === void 0 || !/^\d+$/.test(raw)) return null;
6898
+ return {
6899
+ scope: {
6900
+ kind: "device",
6901
+ deviceId: Number(raw)
6902
+ },
6903
+ used: 2
6904
+ };
6905
+ }
6906
+ case "integration": {
6907
+ const id = segments[1] !== void 0 ? decodeSegment(segments[1]) : null;
6908
+ return id === null || id.length === 0 ? null : {
6909
+ scope: {
6910
+ kind: "integration",
6911
+ integrationId: id
6912
+ },
6913
+ used: 2
6914
+ };
6915
+ }
6916
+ case "row": {
6917
+ const collection = segments[1] !== void 0 ? decodeSegment(segments[1]) : null;
6918
+ const rowId = segments[2] !== void 0 ? decodeSegment(segments[2]) : null;
6919
+ if (collection === null || rowId === null || collection.length === 0 || rowId.length === 0) return null;
6920
+ return {
6921
+ scope: {
6922
+ kind: "row",
6923
+ collection,
6924
+ rowId
6925
+ },
6926
+ used: 3
6927
+ };
6928
+ }
6929
+ default: return null;
6930
+ }
6931
+ }
6932
+ /** Take a ref apart; `null` when it is not a well-formed ref. */
6933
+ function parseSecretRef(ref) {
6934
+ if (!ref.startsWith("secret://")) return null;
6935
+ const segments = ref.slice(9).split("/");
6936
+ const owner = segments[0] !== void 0 ? decodeSegment(segments[0]) : null;
6937
+ if (owner === null || owner.length === 0) return null;
6938
+ const parsed = parseScope(segments.slice(1));
6939
+ if (parsed === null) return null;
6940
+ const fieldPath = segments.slice(1 + parsed.used).join("/");
6941
+ if (fieldPath.length === 0) return null;
6942
+ return {
6943
+ owner,
6944
+ scope: parsed.scope,
6945
+ fieldPath
6946
+ };
6947
+ }
6948
+ /** Limits and names of `ctx.records` (D881). One authority; the engine and the facade read it. */
6949
+ /** The files a kind may live in. `history` is device-history's (D850), never records. */
6950
+ var RECORD_DATABASES = ["settings", "events"];
6951
+ /** The classes of a kind: the `@durable` vocabulary, one authority (replaces the annotation). */
6952
+ var RECORD_CLASSES = [
6953
+ "config",
6954
+ "ledger",
6955
+ "audit",
6956
+ "mirror",
6957
+ "ephemeral"
6958
+ ];
6959
+ var RECORD_DEFAULT_MAX_DATA_BYTES = 64 * 1024;
6960
+ var RECORD_MAX_DATA_BYTES = 1024 * 1024;
6961
+ var RECORD_BATCH_MAX = 1e3;
6962
+ var RECORD_QUERY_MAX = 1e3;
6963
+ /** A kind in the `settings` file may not bound itself above this (D447: high volume is `events`). */
6964
+ var RECORD_SETTINGS_MAX_ROWS = 5e4;
6965
+ /**
6966
+ * Secret fields of a record, addressed the way a Zod schema declares them
6967
+ * (`collectZodSecretPaths`): dotted keys, `[]` for "each element of this array"
6968
+ * (`auth.accessToken`, `headers[].value`).
6969
+ *
6970
+ * `{}` after a key means "each value of this map" (`applianceSecrets{}`): the map's own key
6971
+ * names the value (`applianceSecrets{fridge}`), so no id key is declared and a body that drops a
6972
+ * key releases exactly that key's secret.
6973
+ *
6974
+ * Array elements are matched by a DECLARED id key (`secretArrayKeys`:
6975
+ * `{ headers: 'name' }`), never by index, so reordering a list keeps every
6976
+ * keychain ref (the same rule as `arrayItemFieldPath`). The concrete path of a
6977
+ * leaf names its element: `headers[X-Api].value`.
6978
+ *
6979
+ * Pure and browser-safe. Nothing here mutates: every transform returns a new value.
6980
+ */
6981
+ /** The array prefixes (declared form, e.g. `headers` or `a.headers`) of a path. */
6982
+ function parseSecretPath(path) {
6983
+ if (path.length === 0) throw new InvalidRecordError("an empty secret path");
6984
+ return path.split(".").map((raw) => {
6985
+ const each = raw.endsWith("[]");
6986
+ const map = raw.endsWith("{}");
6987
+ const key = each || map ? raw.slice(0, -2) : raw;
6988
+ if (key.length === 0) throw new InvalidRecordError(`secret path "${path}" has an empty segment`);
6989
+ return {
6990
+ key,
6991
+ each,
6992
+ map
6993
+ };
6994
+ });
6995
+ }
6996
+ /** The declared array prefixes of `path` that need an id key (`headers`, `a.rows`). */
6997
+ function secretArrayPrefixes(path) {
6998
+ const segments = parseSecretPath(path);
6999
+ const prefixes = [];
7000
+ const walked = [];
7001
+ for (const segment of segments) {
7002
+ walked.push(segment.key);
7003
+ if (segment.each) prefixes.push(walked.join("."));
7004
+ }
7005
+ return prefixes;
7006
+ }
7007
+ /** The body key of the switch; only {@link RecordIntegrationInstances.setInstanceEnabled} writes it. */
7008
+ var SWITCH_KEY = "enabled";
7009
+ /**
7010
+ * The one-switch migration (epic #440, step 3). An integration's on/off state used to live in the
7011
+ * registry's `enabled` column for a device addon; it now lives only in the instance record's
7012
+ * body (`enabled`, D1007 superseded). This moves a registry `enabled = false` into the body, once.
7013
+ *
7014
+ * For every registry row of the addon that is OFF:
7015
+ * - no record under its id: the record is created from `initialBody(name)` with `enabled: false`
7016
+ * (a default integration that never had settings, Reolink's among them);
7017
+ * - a record whose body states no `enabled`: `enabled: false` is written into it;
7018
+ * - a record that already states `enabled` (either way) is the newer truth and is left alone.
7019
+ * A row that is ON writes nothing: an absent field reads as on. A rerun finds every off row with
7020
+ * a stated switch and does nothing, so nothing switched off comes back on and nothing switched on
7021
+ * goes off. The registry column itself is neither read afterwards nor written; its drop is step 5.
7022
+ *
7023
+ * It runs in the addon process, BEFORE the addon registers its `integration-instances` provider,
7024
+ * which is also why `integrations.list` still answers the stored column at that point.
7025
+ */
7026
+ function registrySwitchToBodyId(addonId, date) {
7027
+ return `${addonId}/${date}-registry-switch-to-body`;
7028
+ }
7029
+ async function moveRegistrySwitchToBody(ports, spec) {
7030
+ const rows = await ports.listIntegrations(spec.addonId);
7031
+ let created = 0;
7032
+ let switched = 0;
7033
+ let kept = 0;
7034
+ for (const row of rows) {
7035
+ if (row.enabled) continue;
7036
+ const body = await ports.readBody(row.id);
7037
+ if (body === null) {
7038
+ if (await ports.createRecord(row.id, {
7039
+ ...spec.initialBody(row.name),
7040
+ ["enabled"]: false
7041
+ }) === "created") created += 1;
7042
+ else kept += 1;
7043
+ continue;
7044
+ }
7045
+ if ("enabled" in body) {
7046
+ kept += 1;
7047
+ continue;
7048
+ }
7049
+ await ports.switchOff(row.id);
7050
+ switched += 1;
7051
+ }
7052
+ const summary = {
7053
+ integrations: rows.length,
7054
+ off: rows.filter((r) => !r.enabled).length,
7055
+ created,
7056
+ switched,
7057
+ kept
7058
+ };
7059
+ return created === 0 && switched === 0 ? {
7060
+ outcome: "already-done",
7061
+ summary
7062
+ } : {
7063
+ outcome: "done",
7064
+ summary
7065
+ };
7066
+ }
7067
+ /** A migration entry: an addon states its kind and how a new body starts, nothing else. */
7068
+ function registrySwitchToBodyMigration(spec) {
7069
+ return {
7070
+ meta: {
7071
+ id: registrySwitchToBodyId(spec.addonId, spec.date),
7072
+ owner: spec.addonId,
7073
+ level: "addon-state",
7074
+ seq: spec.seq,
7075
+ dependsOn: [],
7076
+ store: "settings",
7077
+ scope: "cluster",
7078
+ onFailure: "block-owner",
7079
+ bodyKind: "procedure",
7080
+ description: "Move the registry enabled flag of every switched-off integration into its instance record body, creating the record when there is none",
7081
+ fixtureMark: "enabled"
7082
+ },
7083
+ procedure: (ports) => moveRegistrySwitchToBody(ports, {
7084
+ addonId: spec.addonId,
7085
+ initialBody: spec.initialBody
7086
+ })
7087
+ };
7088
+ }
7089
+ /** The hub and records sides of {@link registrySwitchToBodyMigration}. */
7090
+ function registrySwitchPortsOver(deps) {
7091
+ const handle = deps.records.kind({
7092
+ name: deps.kind.name,
7093
+ declaration: deps.kind.declaration,
7094
+ schema: record(string(), unknown())
7095
+ });
7096
+ return {
7097
+ listIntegrations: async (addonId) => (await deps.api.list()).filter((i) => i.addonId === addonId).map((i) => ({
7098
+ id: i.id,
7099
+ name: i.name,
7100
+ enabled: i.enabled !== false
7101
+ })),
7102
+ readBody: async (id) => (await handle.get(id))?.data ?? null,
7103
+ createRecord: async (id, body) => {
7104
+ if (await handle.get(id) !== null) return "exists";
7105
+ await handle.put({
7106
+ id,
7107
+ data: body
7108
+ }, { ifRev: 0 });
7109
+ return "created";
7110
+ },
7111
+ switchOff: async (id) => {
7112
+ await handle.patch(id, { [SWITCH_KEY]: false });
7113
+ }
7114
+ };
7115
+ }
6708
7116
  /**
6709
7117
  * Build a {@link DurableState} over a single store key. Transport-agnostic:
6710
7118
  * `read`/`write` are the addon-store or device-store accessors. The whole
@@ -6836,96 +7244,19 @@ var SCOPED_SETTINGS_SCOPES = [
6836
7244
  "device-defaults",
6837
7245
  "node"
6838
7246
  ];
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;
7247
+ /** The one refusal of a key a scope did not declare. */
7248
+ function assertDeclaredKeys(keys, declared) {
7249
+ const undeclared = keys.filter((key) => !declared.has(key));
7250
+ if (undeclared.length > 0) throw new Error(`scoped settings: [${undeclared.join(", ")}] not declared for this scope (declared: [${[...declared].join(", ")}])`);
6843
7251
  }
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;
7252
+ /** Build the handle over an addon's scoped read, write and unset. */
7253
+ function createScopedSettings(deps) {
6925
7254
  return {
6926
- owner,
6927
- scope: parsed.scope,
6928
- fieldPath
7255
+ async get() {
7256
+ return deps.schema.parse(await deps.read());
7257
+ },
7258
+ patch: (patch) => deps.write(Object.fromEntries(Object.entries(patch))),
7259
+ unset: (keys) => deps.unset(keys)
6929
7260
  };
6930
7261
  }
6931
7262
  /** A write to a secret path could not be stored in the keychain, so it was refused. */
@@ -6938,7 +7269,7 @@ var KeychainWriteRefusedError = class extends Error {
6938
7269
  }
6939
7270
  };
6940
7271
  var KEEP = { kind: "keep" };
6941
- function isRecord$6(value) {
7272
+ function isRecord$4(value) {
6942
7273
  return typeof value === "object" && value !== null && !Array.isArray(value);
6943
7274
  }
6944
7275
  function defaultMintId() {
@@ -6951,7 +7282,7 @@ function collectSecretMarkerRefs(value, out = []) {
6951
7282
  return out;
6952
7283
  }
6953
7284
  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);
7285
+ else if (isRecord$4(value)) for (const child of Object.values(value)) collectSecretMarkerRefs(child, out);
6955
7286
  return out;
6956
7287
  }
6957
7288
  async function storedValueEquals(secrets, marker, candidate) {
@@ -7006,7 +7337,7 @@ function rowId(row, idKey) {
7006
7337
  return null;
7007
7338
  }
7008
7339
  async function writeArray(ctx, node, incoming, stored, fieldPath) {
7009
- const storedRows = Array.isArray(stored) ? stored.filter(isRecord$6) : [];
7340
+ const storedRows = Array.isArray(stored) ? stored.filter(isRecord$4) : [];
7010
7341
  if (!Array.isArray(incoming)) {
7011
7342
  ctx.deletes.push(...collectSecretMarkerRefs(storedRows));
7012
7343
  return {
@@ -7022,7 +7353,7 @@ async function writeArray(ctx, node, incoming, stored, fieldPath) {
7022
7353
  const kept = /* @__PURE__ */ new Set();
7023
7354
  const rows = [];
7024
7355
  for (const row of incoming) {
7025
- if (!isRecord$6(row)) {
7356
+ if (!isRecord$4(row)) {
7026
7357
  rows.push(row);
7027
7358
  continue;
7028
7359
  }
@@ -7047,7 +7378,7 @@ async function writeNode(ctx, node, incoming, stored, fieldPath) {
7047
7378
  case "leaf": return writeLeaf(ctx, incoming, stored, fieldPath);
7048
7379
  case "array": return writeArray(ctx, node, incoming, stored, fieldPath);
7049
7380
  case "object": {
7050
- if (!isRecord$6(incoming)) {
7381
+ if (!isRecord$4(incoming)) {
7051
7382
  if (incoming === void 0) return KEEP;
7052
7383
  ctx.deletes.push(...collectSecretMarkerRefs(stored));
7053
7384
  return {
@@ -7055,7 +7386,7 @@ async function writeNode(ctx, node, incoming, stored, fieldPath) {
7055
7386
  value: incoming
7056
7387
  };
7057
7388
  }
7058
- const storedObj = isRecord$6(stored) ? stored : {};
7389
+ const storedObj = isRecord$4(stored) ? stored : {};
7059
7390
  return {
7060
7391
  kind: "value",
7061
7392
  value: await writeMembers(ctx, node.children, incoming, storedObj, (m) => `${fieldPath}.${m}`)
@@ -7178,7 +7509,7 @@ async function resolveSecretMarkers(value, secrets, options = {}) {
7178
7509
  value: items
7179
7510
  };
7180
7511
  }
7181
- if (isRecord$6(v)) {
7512
+ if (isRecord$4(v)) {
7182
7513
  const out = {};
7183
7514
  for (const [k, child] of Object.entries(v)) {
7184
7515
  const s = substitute(child);
@@ -7210,7 +7541,7 @@ var SecretOverwriteRefusedError = class extends Error {
7210
7541
  this.name = "SecretOverwriteRefusedError";
7211
7542
  }
7212
7543
  };
7213
- function isRecord$5(value) {
7544
+ function isRecord$3(value) {
7214
7545
  return typeof value === "object" && value !== null && !Array.isArray(value);
7215
7546
  }
7216
7547
  function resolvedValue(pass, marker) {
@@ -7239,7 +7570,7 @@ function inArray(pass, incoming, stored) {
7239
7570
  return incoming.map((item, index) => {
7240
7571
  const twin = stored[index];
7241
7572
  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);
7573
+ if (isRecord$3(item) && isRecord$3(twin)) return inArrayRow(pass, item, twin);
7243
7574
  if (Array.isArray(item) && Array.isArray(twin)) return inArray(pass, item, twin);
7244
7575
  return item;
7245
7576
  });
@@ -7250,7 +7581,7 @@ function inArrayRow(pass, incoming, stored) {
7250
7581
  const twin = stored[key];
7251
7582
  if (isSecretMarker(twin)) {
7252
7583
  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);
7584
+ } else if (isRecord$3(value) && isRecord$3(twin)) out[key] = inArrayRow(pass, value, twin);
7254
7585
  else if (Array.isArray(value) && Array.isArray(twin)) out[key] = inArray(pass, value, twin);
7255
7586
  }
7256
7587
  return out;
@@ -7258,7 +7589,7 @@ function inArrayRow(pass, incoming, stored) {
7258
7589
  async function walk(pass, incoming, stored) {
7259
7590
  if (isSecretMarker(stored)) return atMarker(pass, incoming, stored);
7260
7591
  if (Array.isArray(incoming) && Array.isArray(stored)) return inArray(pass, incoming, stored);
7261
- if (!isRecord$5(incoming) || !isRecord$5(stored)) return incoming;
7592
+ if (!isRecord$3(incoming) || !isRecord$3(stored)) return incoming;
7262
7593
  const out = { ...incoming };
7263
7594
  for (const [key, value] of Object.entries(incoming)) out[key] = await walk(pass, value, stored[key]);
7264
7595
  return out;
@@ -7289,7 +7620,7 @@ async function restoreUnchangedSecrets(input) {
7289
7620
  function isJsonEqual(a, b) {
7290
7621
  if (Object.is(a, b)) return true;
7291
7622
  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)) {
7623
+ if (isRecord$3(a) && isRecord$3(b)) {
7293
7624
  const keys = Object.keys(a);
7294
7625
  if (keys.length !== Object.keys(b).length) return false;
7295
7626
  return keys.every((k) => Object.prototype.hasOwnProperty.call(b, k) && isJsonEqual(a[k], b[k]));
@@ -7313,7 +7644,7 @@ function markerKeysOf(blob, owner) {
7313
7644
  }
7314
7645
  function nodeFromStored(value, owner) {
7315
7646
  if (isSecretMarker(value)) return isSecretRefOwnedBy(value.$secret, owner) ? { kind: "leaf" } : null;
7316
- if (!isRecord$5(value)) return null;
7647
+ if (!isRecord$3(value)) return null;
7317
7648
  const children = /* @__PURE__ */ new Map();
7318
7649
  for (const [key, child] of Object.entries(value)) {
7319
7650
  const node = nodeFromStored(child, owner);
@@ -7503,7 +7834,16 @@ function createHandle(raw, opts) {
7503
7834
  return blob;
7504
7835
  }
7505
7836
  },
7506
- writeAddonStore: writeAddon
7837
+ writeAddonStore: writeAddon,
7838
+ removeClearedKeys: (keys) => serialize("addon", async () => {
7839
+ const stored = await readStoredAddonBlob(raw);
7840
+ index.seen("addon", stored);
7841
+ const removable = keys.filter((key) => collectSecretMarkerRefs(stored[key]).length === 0);
7842
+ if (removable.length === 0) return;
7843
+ const patch = Object.fromEntries(removable.map((key) => [key, void 0]));
7844
+ await raw.writeAddonStore(patch);
7845
+ index.wrote("addon", patch);
7846
+ })
7507
7847
  };
7508
7848
  }
7509
7849
  /** The context the addon sees, plus the private raw view and write outcome. */
@@ -7810,13 +8150,48 @@ var BaseAddon = class {
7810
8150
  if (api === void 0) throw new Error(`${this.ctx.id}: the migration API is not available on this context`);
7811
8151
  return this.runBound(sets.flatMap((set) => set.bind(api)), options);
7812
8152
  }
7813
- async runBound(migrations, options) {
8153
+ /**
8154
+ * A device addon states its instance kind once, before its migrations run, and the one-switch
8155
+ * migration (registry `enabled` to the instance body, epic #440 step 3) joins whatever
8156
+ * catalogue the addon runs, in the SAME declaration (the engine replaces an owner's catalogue
8157
+ * on every declare).
8158
+ */
8159
+ declareRegistrySwitch(spec) {
8160
+ this.registrySwitchSpec = spec;
8161
+ }
8162
+ registrySwitchSpec = null;
8163
+ registrySwitchBound() {
8164
+ const spec = this.registrySwitchSpec;
8165
+ if (spec === null) return [];
8166
+ const api = this.ctx.migrationApi;
8167
+ if (api === void 0) {
8168
+ this.ctx.logger.warn("the registry switch migration is skipped: the migration API is not available on this context");
8169
+ return [];
8170
+ }
8171
+ return migrationSet([registrySwitchToBodyMigration({
8172
+ addonId: this.ctx.id,
8173
+ date: "2026-11-06",
8174
+ seq: 1e3,
8175
+ initialBody: spec.initialBody
8176
+ })], (a) => registrySwitchPortsOver({
8177
+ api: integrationRowsApiOver(a),
8178
+ records: switchRecordsOverMigrationApi(a),
8179
+ kind: spec.kind
8180
+ })).bind(api);
8181
+ }
8182
+ async runBound(declared, options) {
8183
+ const added = this.registrySwitchBound();
8184
+ const migrations = [...declared, ...added];
8185
+ const phased = options?.only === void 0 || added.length === 0 ? options : {
8186
+ ...options,
8187
+ only: [...options.only, ...added.map((m) => m.meta.id)]
8188
+ };
7814
8189
  const api = this.ctx.api.migrations;
7815
8190
  const report = await runAddonMigrations({
7816
8191
  declareOwner: (input) => api.declareOwner.mutate(input),
7817
8192
  startMigration: (input) => api.startMigration.mutate(input),
7818
8193
  finishMigration: (input) => api.finishMigration.mutate(input)
7819
- }, migrations, this.ctx.logger, options);
8194
+ }, migrations, this.ctx.logger, phased);
7820
8195
  if (report.blockOwner.length > 0) throw new AddonMigrationsBlockedError(report.blockOwner);
7821
8196
  return report;
7822
8197
  }
@@ -8013,6 +8388,151 @@ var BaseAddon = class {
8013
8388
  }
8014
8389
  }
8015
8390
  /**
8391
+ * Hook: values layered over the stored ones when the FORM of one scope is served
8392
+ * ({@link getScopedSettings}) — a preview that derives dependent options without writing.
8393
+ * Never applied to {@link ScopedSettings.get} or to a write. `null` ⇒ no overlay.
8394
+ */
8395
+ async scopedSettingsOverlay(_scope, _cap, _nodeId) {
8396
+ return null;
8397
+ }
8398
+ /**
8399
+ * Hook: a write of one scope changed stored values (not called when the store reports no change,
8400
+ * e.g. the write-back of a stored secret). `keys` are the bare field keys of the write, node keys included.
8401
+ */
8402
+ async onScopedSettingsChanged(_scope, _cap, _keys) {}
8403
+ /** Typed handle over the CLUSTER settings `cap` declares (`clusterSettingsSchema`). */
8404
+ clusterSettings(cap, schema) {
8405
+ return this.scopedHandle("cluster", cap, schema);
8406
+ }
8407
+ /** Typed handle over the fleet defaults of the per-device settings `cap` declares. */
8408
+ deviceDefaults(cap, schema) {
8409
+ return this.scopedHandle("device-defaults", cap, schema);
8410
+ }
8411
+ /**
8412
+ * Typed handle over the settings `cap` owns PER NODE. `nodeId` omitted ⇒ the local node. A node
8413
+ * with no row yields the schema defaults — never a bare-key fallback.
8414
+ */
8415
+ nodeSettings(cap, schema, nodeId) {
8416
+ return this.scopedHandle("node", cap, schema, nodeId);
8417
+ }
8418
+ /**
8419
+ * {@link state} for a value that is kept per node: stored under `<key>@<nodeId>`, and the
8420
+ * settings store carries `nodeId` in the row data (D986 §1), so a forgotten node's rows go in one
8421
+ * central delete. `nodeId` omitted ⇒ the local node.
8422
+ */
8423
+ nodeState(key, schema, fallback, nodeId) {
8424
+ this._declaredStateKeys.add(key);
8425
+ return createDurableState({
8426
+ key: nodeScopedKey(key, nodeId ?? this._ctx?.kernel?.localNodeId ?? ""),
8427
+ schema,
8428
+ fallback,
8429
+ read: async () => this.resolveStoredSecrets(await this.readAddonStoreWithRetry()),
8430
+ write: async (patch) => {
8431
+ await this._ctx?.settings?.writeAddonStore(patch);
8432
+ },
8433
+ onParseError: (k, e) => this._ctx?.logger?.warn?.(`durable-state: stored "${k}" failed validation — using fallback`, { meta: {
8434
+ addonId: this._ctx?.id,
8435
+ key: k,
8436
+ error: String(e)
8437
+ } })
8438
+ });
8439
+ }
8440
+ /** The loaded schema `cap` declares for `scope`, or `null`. */
8441
+ async declaredScopedSchema(scope, cap) {
8442
+ await this.loadScopedSchemas(cap);
8443
+ return this.loadedScopedSchemas(cap).find((entry) => entry.scope === scope)?.schema ?? null;
8444
+ }
8445
+ async requireScopedSchema(scope, cap) {
8446
+ const schema = await this.declaredScopedSchema(scope, cap);
8447
+ if (schema === null) throw new Error(`${this.constructor.name}: cap "${cap}" declares no ${scope} settings`);
8448
+ return schema;
8449
+ }
8450
+ scopedKeys(schema) {
8451
+ return new Set(schema.sections.flatMap((section) => collectValueFieldKeys(section.fields)));
8452
+ }
8453
+ /** `store` narrowed to the keys `schema` declares. */
8454
+ narrowToScope(store, schema) {
8455
+ const keys = this.scopedKeys(schema);
8456
+ return Object.fromEntries(Object.entries(store).filter(([key]) => keys.has(key)));
8457
+ }
8458
+ scopedHandle(scope, cap, schema, nodeId) {
8459
+ return createScopedSettings({
8460
+ schema,
8461
+ read: async () => {
8462
+ const declared = await this.requireScopedSchema(scope, cap);
8463
+ const stored = this.narrowToScope(await this.resolveGlobalStore(nodeId, cap), declared);
8464
+ const effective = collectHydratedFieldValues(hydrateSchema(declared, stored));
8465
+ return {
8466
+ ...Object.fromEntries([...effective].filter(([, value]) => value !== void 0)),
8467
+ ...stored
8468
+ };
8469
+ },
8470
+ write: (patch) => this.writeScoped(scope, cap, patch, nodeId),
8471
+ unset: (keys) => this.unsetScoped(scope, cap, keys, nodeId)
8472
+ });
8473
+ }
8474
+ /** The one write path of the scoped API: declared keys only, then the global patch. */
8475
+ async writeScoped(scope, cap, patch, nodeId) {
8476
+ assertDeclaredKeys(Object.keys(patch), this.scopedKeys(await this.requireScopedSchema(scope, cap)));
8477
+ if (await this.applyGlobalPatch(patch, scope === "node" ? nodeId : void 0, cap)) await this.onScopedSettingsChanged(scope, cap, Object.keys(patch));
8478
+ }
8479
+ /**
8480
+ * Remove declared keys of one scope. A secret goes through {@link clearSecrets} — its keychain
8481
+ * value is released exactly as there — and the emptied row is then removed; every other key is
8482
+ * removed by an `undefined` patch (which a secret transform would read as "keep").
8483
+ */
8484
+ async unsetScoped(scope, cap, keys, nodeId) {
8485
+ assertDeclaredKeys(keys, this.scopedKeys(await this.requireScopedSchema(scope, cap)));
8486
+ const target = scope === "node" ? nodeId : void 0;
8487
+ const tree = this.addonSecretTree();
8488
+ const secretKeys = keys.filter((key) => tree.has(key));
8489
+ const plainKeys = keys.filter((key) => !tree.has(key));
8490
+ let changed = false;
8491
+ if (plainKeys.length > 0) {
8492
+ const patch = Object.fromEntries(plainKeys.map((key) => [key, void 0]));
8493
+ changed = await this.applyGlobalPatch(patch, target, cap) || changed;
8494
+ }
8495
+ if (secretKeys.length > 0) {
8496
+ await this.clearSecretKeys(secretKeys, target, cap);
8497
+ const node = normalizeNodeId(target ?? this._ctx?.kernel?.localNodeId);
8498
+ const rows = secretKeys.map((key) => scope === "node" ? nodeScopedKey(key, node) : key);
8499
+ if (this._secretSettings !== null) await this._secretSettings.removeClearedKeys(rows);
8500
+ else await this._ctx?.settings?.writeAddonStore(Object.fromEntries(rows.map((row) => [row, void 0])));
8501
+ changed = true;
8502
+ }
8503
+ if (changed) await this.onScopedSettingsChanged(scope, cap, [...keys]);
8504
+ }
8505
+ /**
8506
+ * The hydrated form of one scope of one capability's settings (any
8507
+ * {@link scopedSettingsOverlay} applied), or `null` when the capability declares nothing there.
8508
+ */
8509
+ async getScopedSettings(scope, cap, nodeId) {
8510
+ const schema = await this.declaredScopedSchema(scope, cap);
8511
+ if (schema === null) return null;
8512
+ const stored = this.narrowToScope(await this.readRawProjectedStore(nodeId, cap), schema);
8513
+ const overlay = await this.scopedSettingsOverlay(scope, cap, nodeId);
8514
+ return hydrateSchema(schema, overlay ? await this.overlayKeepingMarkers(stored, overlay) : stored, { inlineSecretsAsViews: true });
8515
+ }
8516
+ /** The OPERATOR's write of declared keys of one scope (D787 secret semantics). */
8517
+ async updateScopedSettings(scope, cap, patch, nodeId) {
8518
+ this._operatorWriteDepth++;
8519
+ try {
8520
+ await this.writeScoped(scope, cap, patch, nodeId);
8521
+ } finally {
8522
+ this._operatorWriteDepth--;
8523
+ }
8524
+ }
8525
+ /**
8526
+ * The effective values (`stored ?? default`) of one scope, a secret as its `set` view — never
8527
+ * its value. `null` when the capability declares nothing for the scope.
8528
+ */
8529
+ async readScopedValues(scope, cap, nodeId) {
8530
+ const schema = await this.declaredScopedSchema(scope, cap);
8531
+ if (schema === null) return null;
8532
+ const form = hydrateSchema(schema, this.narrowToScope(await this.readRawProjectedStore(nodeId, cap), schema), { inlineSecretsAsViews: true });
8533
+ return Object.fromEntries([...collectHydratedFieldValues(form)].filter(([, value]) => value !== void 0));
8534
+ }
8535
+ /**
8016
8536
  * What the create wizard and the integration edit page render for one instance: the addon's
8017
8537
  * per-instance schema when it declares one, else its global schema (what they always showed).
8018
8538
  */
@@ -8164,6 +8684,9 @@ var BaseAddon = class {
8164
8684
  * a keychain (an older kernel) it writes `''`, as such code always did.
8165
8685
  */
8166
8686
  async clearSecrets(keys, nodeId) {
8687
+ await this.clearSecretKeys(keys, nodeId);
8688
+ }
8689
+ async clearSecretKeys(keys, nodeId, cap) {
8167
8690
  const tree = this.addonSecretTree();
8168
8691
  const keychain = this._ctx?.secrets !== void 0;
8169
8692
  const stored = keychain ? await this.readAddonStoreWithRetry() : {};
@@ -8176,25 +8699,27 @@ var BaseAddon = class {
8176
8699
  const keychainStored = tree.has(key) || collectSecretMarkerRefs(stored[key]).length > 0;
8177
8700
  patch[key] = keychain && keychainStored ? SECRET_CLEAR : "";
8178
8701
  }
8179
- await this.applyGlobalPatch(patch, nodeId);
8702
+ await this.applyGlobalPatch(patch, nodeId, cap);
8180
8703
  }
8181
- async applyGlobalPatch(barePatch, nodeId) {
8182
- await this.loadScopedSchemas();
8183
- const keys = this.perNodeKeys();
8704
+ /** Resolves `true` when the write changed stored values. */
8705
+ async applyGlobalPatch(barePatch, nodeId, cap) {
8706
+ await this.loadScopedSchemas(cap);
8707
+ const keys = this.perNodeKeys(cap);
8184
8708
  const localNode = normalizeNodeId(this._ctx?.kernel?.localNodeId);
8185
8709
  const target = normalizeNodeId(nodeId ?? this._ctx?.kernel?.localNodeId);
8186
8710
  const scoped = keys.size > 0 ? scopePatch(barePatch, keys, target) : barePatch;
8187
8711
  const handle = this._secretSettings;
8188
8712
  if (handle !== null) {
8189
8713
  const { changed } = await handle.writeAddonStore(scoped);
8190
- if (!changed) return;
8714
+ if (!changed) return false;
8191
8715
  } else await this._ctx?.settings?.writeAddonStore(scoped);
8192
- if (target !== localNode) return;
8716
+ if (target !== localNode) return true;
8193
8717
  await this.resolveConfig();
8194
8718
  await this.onConfigChanged();
8195
8719
  this.emitLifecycle(EventCategory.AddonUpdated, { level: "global" });
8196
8720
  const legacy = this.globalSettingsSchema();
8197
8721
  this.maybeAutoRestart(Object.keys(barePatch), [...legacy === null ? [] : [legacy], ...this.loadedScopedSchemas().map((entry) => entry.schema)]);
8722
+ return true;
8198
8723
  }
8199
8724
  /**
8200
8725
  * The set of field keys the global settings schema declares `perNode: true`
@@ -8889,114 +9414,94 @@ function normalizeAddonInitResult(result) {
8889
9414
  if (Array.isArray(result)) return { providers: result };
8890
9415
  return result;
8891
9416
  }
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;
9417
+ object({
9418
+ field: string().min(1),
9419
+ on: literal("advance")
9420
+ });
8934
9421
  /**
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.
9422
+ * Output schema shared by the contribution + live methods.
8942
9423
  *
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`.
9424
+ * Mirrors the `ConfigUISchemaWithValues` shape (sections[] + optional
9425
+ * tabs[]) without importing from `../interfaces/config-ui.js` — a
9426
+ * concrete-but-lenient Zod object keeps tRPC output inference happy
9427
+ * (using `z.unknown()` here collapses unrelated router branches to
9428
+ * `unknown` when the generator re-inlines the huge AppRouter type).
8947
9429
  *
8948
- * Pure and browser-safe. Nothing here mutates: every transform returns a new value.
9430
+ * `.passthrough()` on sections/fields accepts whatever FormBuilder
9431
+ * extensions the caller adds (showWhen, displayScale, …) without
9432
+ * rebuilding every time a new field kind is introduced.
8949
9433
  */
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
- });
9434
+ var ContributionSectionSchema = object({
9435
+ id: string(),
9436
+ title: string(),
9437
+ description: string().optional(),
9438
+ style: _enum(["card", "accordion"]).optional(),
9439
+ defaultCollapsed: boolean().optional(),
9440
+ columns: union([
9441
+ literal(1),
9442
+ literal(2),
9443
+ literal(3),
9444
+ literal(4)
9445
+ ]).optional(),
9446
+ tab: string().optional(),
9447
+ location: _enum([
9448
+ "settings",
9449
+ "top-tab",
9450
+ "hero"
9451
+ ]).optional(),
9452
+ order: number().optional(),
9453
+ fields: array(any())
9454
+ });
9455
+ object({
9456
+ tabs: array(object({
9457
+ id: string(),
9458
+ label: string(),
9459
+ icon: string(),
9460
+ order: number().optional()
9461
+ })).optional(),
9462
+ sections: array(ContributionSectionSchema)
9463
+ }).nullable();
9464
+ object({ deviceId: number() }), object({ deviceId: number() }), object({
9465
+ deviceId: number(),
9466
+ patch: record(string(), unknown())
9467
+ }), object({ success: literal(true) });
9468
+ object({ deviceId: number() }), unknown().nullable();
9469
+ function method(input, output, options) {
9470
+ return {
9471
+ input,
9472
+ output,
9473
+ kind: options?.kind ?? "query",
9474
+ ...options?.auth !== void 0 ? { auth: options.auth } : {},
9475
+ ...options?.access !== void 0 ? { access: options.access } : {},
9476
+ ...options?.role !== void 0 ? { role: options.role } : {},
9477
+ ...options?.caller !== void 0 ? { caller: options.caller } : {},
9478
+ timeoutMs: options?.timeoutMs
9479
+ };
8964
9480
  }
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;
9481
+ /**
9482
+ * A wrapper/system-only method: served exclusively by the cap's system-level
9483
+ * provider (`InferProvider`), and OPTIONAL on `InferNativeProvider` so per-device
9484
+ * driver natives don't stub out a wrapper concern (e.g. a cross-device cache
9485
+ * overview). The `systemOnly: true` literal is what `InferNativeProvider` keys on.
9486
+ */
9487
+ function systemMethod(input, output, options) {
9488
+ return {
9489
+ ...method(input, output, options),
9490
+ systemOnly: true
9491
+ };
8975
9492
  }
8976
9493
  /**
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`.
9494
+ * A method a SOURCE of a collection cap may legitimately not serve — OPTIONAL
9495
+ * on `InferProvider`. The `providerOptional: true` literal is what
9496
+ * `InferProvider` keys on; see {@link CapabilityMethodSchema.providerOptional}
9497
+ * for when this is the honest answer and when it is a soft stub.
8980
9498
  */
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
- });
9499
+ function optionalMethod(input, output, options) {
9500
+ return {
9501
+ ...method(input, output, options),
9502
+ providerOptional: true
9503
+ };
9504
+ }
9000
9505
  function defOf(schema) {
9001
9506
  const zodBag = Reflect.get(schema, "_zod");
9002
9507
  if (typeof zodBag !== "object" || zodBag === null) return {};
@@ -9216,107 +9721,29 @@ function defineRecordKinds(specs) {
9216
9721
  return out;
9217
9722
  }
9218
9723
  /**
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.
9724
+ * The share-view scope kinds a share-link token can carry. The hub mints
9725
+ * and validates them (`ShareViewGrantSchema` builds its
9726
+ * enum from this list); a data plane names the kinds it ACCEPTS in `share`.
9248
9727
  */
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())
9728
+ var SHARE_VIEW_KINDS = ["grid-view", "events-view"];
9729
+ /** The wire shape of {@link PeerBytesTicket} — see the type for what it is. */
9730
+ var PeerBytesTicketSchema = object({
9731
+ /** `http://127.0.0.1:<port>/<token>`. One `GET` takes it. */
9732
+ url: string().min(1),
9733
+ /**
9734
+ * The HOST node this URL means something on — the hub or a named agent,
9735
+ * never a runner. {@link AddonPeerBytes.open} compares it to its own and
9736
+ * refuses `cross-node` by name when they differ, without dialling.
9737
+ */
9738
+ hostNodeId: string().min(1),
9739
+ expiresAtMs: number().int().nonnegative(),
9740
+ /**
9741
+ * What the producer DECLARED the body to be, when it knows — `null` when it
9742
+ * does not. Never `0` for unknown (D393): a consumer sizing a bound off this
9743
+ * must be able to tell "the producer did not say" from "the body is empty".
9744
+ */
9745
+ declaredBytes: number().int().nonnegative().nullable()
9269
9746
  });
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
9747
  var READING_QUANTITIES = [
9321
9748
  "temperature",
9322
9749
  "pressure",
@@ -10451,7 +10878,6 @@ var CAP_NAMES = Object.freeze([
10451
10878
  "climate-control",
10452
10879
  "color",
10453
10880
  "composer",
10454
- "connection-test",
10455
10881
  "connectivity",
10456
10882
  "consumables",
10457
10883
  "contact",
@@ -10541,7 +10967,6 @@ var CAP_NAMES = Object.freeze([
10541
10967
  "notifier",
10542
10968
  "numeric-sensor",
10543
10969
  "oauth-integration",
10544
- "oidc-connections",
10545
10970
  "osd",
10546
10971
  "osd-manager",
10547
10972
  "pet-feeder",
@@ -11598,6 +12023,10 @@ Object.freeze({
11598
12023
  "all",
11599
12024
  "one"
11600
12025
  ]
12026
+ },
12027
+ {
12028
+ "path": "positionUpdatedAt",
12029
+ "valueType": "number"
11601
12030
  }
11602
12031
  ],
11603
12032
  "meter": [{
@@ -11852,22 +12281,6 @@ Object.freeze({
11852
12281
  "path": "pumpRunning",
11853
12282
  "valueType": "boolean"
11854
12283
  },
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
12284
  {
11872
12285
  "path": "error",
11873
12286
  "valueType": "string"
@@ -12433,6 +12846,58 @@ Object.freeze({
12433
12846
  }
12434
12847
  ]
12435
12848
  });
12849
+ Object.freeze({
12850
+ "actions": { "run": 363e4 },
12851
+ "audio-analyzer": { "classify": 3e4 },
12852
+ "custom-model-registry": { "importModelBundle": 18e5 },
12853
+ "database-snapshot": { "writeSnapshot": 18e5 },
12854
+ "device-manager": {
12855
+ "migrateDevice": 72e4,
12856
+ "runDiscoverySweep": 12e4
12857
+ },
12858
+ "device-provider": { "reloadDevice": 18e4 },
12859
+ "llm": {
12860
+ "generate": 6e5,
12861
+ "generateVision": 6e5
12862
+ },
12863
+ "llm-runtime": {
12864
+ "complete": 6e5,
12865
+ "completeApple": 6e5,
12866
+ "ensureStarted": 6e5,
12867
+ "installModel": 36e5
12868
+ },
12869
+ "local-network": { "scanNetwork": 9e4 },
12870
+ "model-convert": { "convert": 6e5 },
12871
+ "pipeline-analytics": {
12872
+ "addRetrainFrameFromRecording": 6e4,
12873
+ "offerRetrainArchive": 12e4,
12874
+ "proposeRetrainAnnotationsWithLlm": 18e4,
12875
+ "resolveRetrainTrainingCorpus": 6e4,
12876
+ "writeRetrainArchive": 36e5
12877
+ },
12878
+ "server-management": { "applyServerUpdate": 96e4 },
12879
+ "terminal-session": { "pullOutput": 15e3 },
12880
+ "training": {
12881
+ "canaryResult": 12e4,
12882
+ "cancelJob": 12e4,
12883
+ "planJob": 6e4,
12884
+ "registerResult": 18e5,
12885
+ "rollbackCanary": 12e4,
12886
+ "startJob": 12e4,
12887
+ "startJobBatch": 12e4
12888
+ },
12889
+ "training-provider": {
12890
+ "cancelJob": 6e4,
12891
+ "cleanupJob": 3e5,
12892
+ "getJob": 6e4,
12893
+ "listJobEvents": 6e4,
12894
+ "listJobs": 12e4,
12895
+ "offerArtifact": 3e5,
12896
+ "readResult": 3e5,
12897
+ "submitJob": 18e5,
12898
+ "uploadDataset": 72e5
12899
+ }
12900
+ });
12436
12901
  object({
12437
12902
  code: string().regex(/^[a-z][a-z0-9-]*(\.[a-z0-9-]+)+$/),
12438
12903
  params: record(string(), union([string(), number()])).optional()
@@ -13977,10 +14442,414 @@ var IntegrationInstanceRefSchema = object({
13977
14442
  ]),
13978
14443
  candidateStableId: string().optional()
13979
14444
  });
13980
- object({
13981
- cap: string().min(1),
13982
- kind: string().min(1).optional()
14445
+ /**
14446
+ * notification-output — canonical, capability-gated notification delivery.
14447
+ *
14448
+ * Apprise-derived model (see
14449
+ * `docs/superpowers/specs/2026-07-03-notification-output-notifier-matrix.md`):
14450
+ * callers emit ONE canonical `Notification`; each provider declares a
14451
+ * per-kind capability descriptor (`TargetKind`), and the pure degrade
14452
+ * engine (`@camstack/types` `prepareNotification`) transcodes / degrades the
14453
+ * message to what the kind supports — callers never special-case a service.
14454
+ *
14455
+ * DESIGN DECISIONS (locked):
14456
+ * - A target is an INSTANCE of this function cap (epic #440, step 6): the
14457
+ * providers serve their targets as `integration-instances` records, one
14458
+ * record kind per target kind, and the admin lists, adds, edits, switches
14459
+ * and deletes them through that cap. This cap keeps what an instance cannot
14460
+ * say: the kind catalogue (`listTargetKinds`: capabilities, delivery
14461
+ * parameters, brand icon), dispatch (`send`, `testTarget`) and the form
14462
+ * helpers (`discoverTargets`, `probeTargetConfig`).
14463
+ * - `listTargetKinds` / `discoverTargets` return arrays → the generated
14464
+ * cap-mount auto-`concatCollection`-fans them across every registered
14465
+ * provider so one catalog is routable. `send` / `testTarget` /
14466
+ * `probeTargetConfig` route to ONE provider by the `addonId` the generated
14467
+ * collection router extracts from the call input.
14468
+ * - `Attachment.bytes` is `Uint8Array`. Transport-safe: superjson (the tRPC
14469
+ * transformer) + UDS MsgPack both round-trip typed arrays — already used by
14470
+ * `storage` / `storage-provider` / `recording` caps over the same path. No
14471
+ * base64 fallback needed.
14472
+ *
14473
+ * TODO (deferred, closed-set change — separate decision): add
14474
+ * `providerKind: 'notify'` so notification providers surface on the unified
14475
+ * admin "Integrations" page.
14476
+ */
14477
+ /**
14478
+ * Zentik-derived typed-media enum — the superset across every kind. Each
14479
+ * adapter picks what it supports and the degrade engine filters the rest.
14480
+ */
14481
+ var AttachmentMediaTypeSchema = _enum([
14482
+ "image",
14483
+ "video",
14484
+ "gif",
14485
+ "audio",
14486
+ "icon"
14487
+ ]);
14488
+ /**
14489
+ * A single attachment. Exactly one of `url` (remote source, most adapters
14490
+ * prefer this) or `bytes` (inline source; required for Pushover-style
14491
+ * bytes-only kinds) MUST be present — the degrade engine expresses a
14492
+ * url→bytes fetch as a `needsFetch` directive the adapter executes.
14493
+ */
14494
+ var AttachmentSchema = object({
14495
+ mediaType: AttachmentMediaTypeSchema,
14496
+ url: string().optional(),
14497
+ bytes: _instanceof(Uint8Array).optional(),
14498
+ mime: string().optional(),
14499
+ name: string().optional()
14500
+ }).refine((a) => a.url !== void 0 || a.bytes !== void 0, { message: "Attachment requires either `url` or `bytes`" });
14501
+ var NotificationFormatSchema = _enum([
14502
+ "text",
14503
+ "markdown",
14504
+ "html"
14505
+ ]);
14506
+ /**
14507
+ * The CLOSED icon vocabulary an action button may use.
14508
+ *
14509
+ * A closed set, not a free string, and that is the whole point: an arbitrary
14510
+ * icon name is one that ntfy renders, zentik silently drops, and nobody
14511
+ * notices — the same class of gap as a zone vocabulary nothing produced
14512
+ * ([D35](../../../docs/decisions/adr-0035.md)). Every adapter maps this set or
14513
+ * declares `actionIcons: false` and the degrade engine strips the field.
14514
+ *
14515
+ * Named by INTENT, never by glyph. "check" would tie the vocabulary to one
14516
+ * renderer's icon set; "acknowledge" survives an adapter that draws it
14517
+ * differently.
14518
+ *
14519
+ * ── A TOKEN IS NOT A WIRE VALUE ─────────────────────────────────────
14520
+ *
14521
+ * These names are for US. **No adapter may forward one verbatim.** Each maps
14522
+ * the whole set onto its own renderer's vocabulary through a
14523
+ * `Record<NotificationActionIcon, string>` — a Record, never a lookup with a
14524
+ * fallback, so adding a member here fails every adapter's build until someone
14525
+ * decides its glyph, which is the only place that decision can be made
14526
+ * honestly.
14527
+ *
14528
+ * This paragraph is the bug. Zentik declared `actionIcons: true` and passed
14529
+ * `disarm` straight through; iOS feeds that string to
14530
+ * `UNNotificationActionIcon(systemImageName:)`, `disarm` is not an SF Symbol,
14531
+ * and every snooze and alarm button arrived BLANK. A pass-through is not a
14532
+ * mapping, and "the field is documented" is not "the value renders".
14533
+ *
14534
+ * Adding a member is TRAIN-BOUND. The enum lives in the published
14535
+ * `@camstack/server` closure and the cap seam validates against the HUB's copy,
14536
+ * so an addon that emits a token the running hub does not know does not lose an
14537
+ * icon — its whole `send` fails Zod validation and the notification never
14538
+ * arrives. Never emit a new token from an addon before the train carrying it.
14539
+ */
14540
+ var NotificationActionIconSchema = _enum([
14541
+ "acknowledge",
14542
+ "dismiss",
14543
+ "silence",
14544
+ "snooze",
14545
+ "view",
14546
+ "play",
14547
+ "open",
14548
+ "close",
14549
+ "lock",
14550
+ "unlock",
14551
+ "arm",
14552
+ "arm-home",
14553
+ "arm-away",
14554
+ "arm-night",
14555
+ "disarm",
14556
+ "light",
14557
+ "alert",
14558
+ "camera"
14559
+ ]);
14560
+ /** A single tap-through action button. */
14561
+ var NotificationActionSchema = object({
14562
+ id: string(),
14563
+ label: string(),
14564
+ url: string().optional(),
14565
+ /** Dropped by the degrade engine for a kind with `caps.actionIcons: false`. */
14566
+ icon: NotificationActionIconSchema.optional(),
14567
+ /**
14568
+ * Renders in a warning style where the notifier supports it.
14569
+ *
14570
+ * A HINT, never a gate. The callback's authority is its token and nothing
14571
+ * else — see `notification-center/action-token.ts` for what that does and
14572
+ * does not buy.
14573
+ */
14574
+ destructive: boolean().optional(),
14575
+ /**
14576
+ * How the tap should REACH the url.
14577
+ *
14578
+ * `navigate` (absent, and every button authored before this field) opens it:
14579
+ * the phone leaves the notification and shows whatever the callback returns.
14580
+ * That is right for a button whose answer the operator wants to read.
14581
+ *
14582
+ * `background` fires it as a POST and stays put. It exists for the buttons
14583
+ * whose whole point is not to interrupt — "silence this for 30 minutes" is
14584
+ * an answer to the notification, and being thrown into a browser tab to
14585
+ * confirm it costs more attention than the notification did. A backend that
14586
+ * cannot do a background call renders it as an ordinary link (the adapters
14587
+ * fall back rather than dropping the button), so this is a preference, never
14588
+ * a requirement.
14589
+ */
14590
+ mode: _enum(["navigate", "background"]).optional()
14591
+ });
14592
+ /** A delivery parameter value: what a notifier declared it takes. */
14593
+ var DeliveryParamValueSchema = union([
14594
+ string(),
14595
+ number(),
14596
+ boolean()
14597
+ ]);
14598
+ /**
14599
+ * One extra delivery parameter a notifier KIND declares (D938). A rule that
14600
+ * addresses a target of that kind may set it; a kind that declares nothing is
14601
+ * never handed one. The admin UI derives its control from this descriptor —
14602
+ * no editor knows a service by name.
14603
+ *
14604
+ * Optional fields are `.optional()`, never `.default()` (a Zod default does not
14605
+ * run on the addon cap path).
14606
+ */
14607
+ var DeliveryParamSchema = object({
14608
+ key: string().min(1),
14609
+ label: string(),
14610
+ /** i18n key of the label, resolved by the declaring addon's namespace. */
14611
+ labelKey: string().optional(),
14612
+ type: _enum([
14613
+ "enum",
14614
+ "number",
14615
+ "boolean",
14616
+ "string"
14617
+ ]),
14618
+ /** `enum` only: the closed set of accepted values. */
14619
+ options: array(object({
14620
+ value: string(),
14621
+ label: string()
14622
+ })).optional(),
14623
+ /** `number` only. */
14624
+ min: number().optional(),
14625
+ max: number().optional(),
14626
+ /** What the notifier does when the rule sets nothing; shown as the placeholder. */
14627
+ default: DeliveryParamValueSchema.optional()
14628
+ });
14629
+ /**
14630
+ * The canonical notification. `body` is the only hard field (Apprise model).
14631
+ * `priority` is a 5-level ORDINAL (1=lowest … 3=normal(default) … 5=urgent),
14632
+ * NOT a fixed severity enum — each kind declares its own `caps.levels` and
14633
+ * the adapter maps this ordinal onto its native level. `level?` is an
14634
+ * optional kind-native level id (`emergency`, `silent`, …) that overrides
14635
+ * `priority` for that one target.
14636
+ */
14637
+ var NotificationSchema = object({
14638
+ body: string(),
14639
+ title: string().optional(),
14640
+ format: NotificationFormatSchema.default("text"),
14641
+ priority: number().int().min(1).max(5).default(3),
14642
+ level: string().optional(),
14643
+ attachments: array(AttachmentSchema).optional(),
14644
+ clickUrl: string().optional(),
14645
+ actions: array(NotificationActionSchema).optional(),
14646
+ sound: string().optional(),
14647
+ ttl: number().optional(),
14648
+ tag: string().optional(),
14649
+ deviceId: number().optional(),
14650
+ eventId: string().optional(),
14651
+ metadata: record(string(), unknown()).optional(),
14652
+ /**
14653
+ * Values for the parameters the target's kind DECLARES in
14654
+ * {@link TargetKindSchema} `deliveryParams`. Already validated against the
14655
+ * declaration by the sender; a notifier reads only the keys it declared.
14656
+ */
14657
+ delivery: record(string(), DeliveryParamValueSchema).optional()
14658
+ });
14659
+ /** One declared native severity/priority level for a kind. */
14660
+ var TargetKindLevelSchema = object({
14661
+ id: string(),
14662
+ label: string(),
14663
+ /** Which canonical priority (1..5) this level maps to. `null` = qualitative-only. */
14664
+ ordinal: number().int().min(1).max(5).nullable(),
14665
+ flags: object({
14666
+ critical: boolean().optional(),
14667
+ silent: boolean().optional(),
14668
+ noPush: boolean().optional()
14669
+ }).optional(),
14670
+ /** e.g. Pushover `emergency` requires `retry` / `expire`. */
14671
+ requires: array(string()).optional(),
14672
+ description: string().optional()
14673
+ });
14674
+ /** The full capability block consulted before dispatch. */
14675
+ var TargetKindCapsSchema = object({
14676
+ attachments: object({
14677
+ mediaTypes: array(AttachmentMediaTypeSchema),
14678
+ mode: _enum([
14679
+ "url",
14680
+ "bytes",
14681
+ "both"
14682
+ ]),
14683
+ max: number().int().nonnegative(),
14684
+ maxBytes: number().int().positive().optional()
14685
+ }),
14686
+ /** Max action buttons (0 = none). */
14687
+ actions: number().int().nonnegative(),
14688
+ /**
14689
+ * Whether this kind renders a per-action ICON.
14690
+ *
14691
+ * `.optional()`, deliberately NOT `.default(false)`: a Zod default does not
14692
+ * run on the addon cap path — three production failures in one day taught
14693
+ * this repo that once. Absent is read as false by the degrade engine, which
14694
+ * is the safe direction: an icon that is not rendered costs nothing, an icon
14695
+ * assumed and dropped costs the operator's trust in the field.
14696
+ */
14697
+ actionIcons: boolean().optional(),
14698
+ levels: array(TargetKindLevelSchema),
14699
+ format: array(NotificationFormatSchema),
14700
+ clickUrl: boolean(),
14701
+ sound: boolean(),
14702
+ ttl: boolean(),
14703
+ bodyMaxLen: number().int().positive()
14704
+ });
14705
+ /**
14706
+ * `configSchema` is a `ConfigUISchema` tree passed through to the admin
14707
+ * FormBuilder. Stored as `z.unknown()` at the cap seam (mirrors
14708
+ * `device-provider.getChildCreationSchema` `CreationSchemaOutputSchema`) —
14709
+ * the union is large and not meant for runtime validation here; the exported
14710
+ * `TargetKind` type re-tightens `configSchema` to `ConfigUISchema`.
14711
+ */
14712
+ var ConfigSchemaPassthrough$3 = unknown();
14713
+ var TargetKindSchema = object({
14714
+ kind: string(),
14715
+ label: string(),
14716
+ icon: string(),
14717
+ /** Stamped by each provider so the concat-fanned catalog stays routable. */
14718
+ addonId: string(),
14719
+ /**
14720
+ * URL of the kind's bundled BRAND icon, served by the providing addon over
14721
+ * its own `addon-routes` surface (`/addon/<addonId>/icons/<kind>`). Absent
14722
+ * when the addon bundles no icon for that kind — the client then falls back
14723
+ * to a neutral glyph rather than rendering the raw `icon` NAME as text.
14724
+ *
14725
+ * Root-relative on purpose: it resolves against whatever origin serves a web
14726
+ * client, and a native client joins it onto its own hub base.
14727
+ *
14728
+ * DECLARED here deliberately. It used to travel as an undeclared passthrough
14729
+ * field that survived only because the runtime cap-router forwards provider
14730
+ * output verbatim — so every consumer had to re-declare it by hand to stop
14731
+ * its own Zod parse from stripping it, and the whole arrangement would have
14732
+ * broken silently the moment output validation was tightened anywhere.
14733
+ */
14734
+ iconUrl: string().optional(),
14735
+ /**
14736
+ * Media type of {@link iconUrl} (`image/svg+xml`, `image/png`, …).
14737
+ *
14738
+ * The server knows this and therefore says it, because the client cannot
14739
+ * safely guess: a React-Native client renders SVG and raster through two
14740
+ * DIFFERENT components (`react-native-svg` vs `expo-image` — expo-image does
14741
+ * not decode SVG on iOS/Android), so without this it silently fell back to a
14742
+ * placeholder glyph for every vector icon while the web build looked fine.
14743
+ *
14744
+ * Absent when {@link iconUrl} is absent, or for a legacy provider that has
14745
+ * not been updated — a client that cannot determine the type should prefer
14746
+ * its raster path, which is the safe default for an unknown image.
14747
+ */
14748
+ iconMediaType: string().optional(),
14749
+ configSchema: ConfigSchemaPassthrough$3,
14750
+ /**
14751
+ * The config keys that decide WHERE this kind's secrets are sent (server,
14752
+ * base URL, instance, chat, recipient). A save that changes any of them
14753
+ * while leaving a secret redacted is refused by the provider (D634), so an
14754
+ * editor uses this to ask for the secret on exactly those edits instead of
14755
+ * on every edit.
14756
+ *
14757
+ * Optional: absent from a provider that holds no secret (the Home Assistant
14758
+ * kinds) and from a provider older than this field — an editor that finds
14759
+ * it absent must assume ANY edit may need the secret.
14760
+ */
14761
+ destinationKeys: array(string()).optional(),
14762
+ supportsDiscovery: boolean(),
14763
+ /**
14764
+ * Extra delivery parameters a rule may set for a target of this kind (D938).
14765
+ * Absent = none; the rule editor then offers nothing.
14766
+ */
14767
+ deliveryParams: array(DeliveryParamSchema).optional(),
14768
+ caps: TargetKindCapsSchema
14769
+ });
14770
+ /**
14771
+ * A target as a provider's own code sees it (the notification-center bridge, the
14772
+ * send path): the flat record body split into the name, the switch and the
14773
+ * kind's fields. `config` holds secrets; a reader that serves it to a client
14774
+ * REDACTS secret fields (a presence marker only) — never round-trip a stored
14775
+ * secret to the UI.
14776
+ */
14777
+ var TargetSchema = object({
14778
+ id: string(),
14779
+ name: string(),
14780
+ kind: string(),
14781
+ addonId: string(),
14782
+ enabled: boolean(),
14783
+ config: record(string(), unknown())
14784
+ });
14785
+ /** A discovery-surfaced candidate (config is partial + non-secret). */
14786
+ var DiscoveredTargetSchema = object({
14787
+ kind: string(),
14788
+ suggestedName: string(),
14789
+ config: record(string(), unknown())
14790
+ });
14791
+ /** The degrade engine's report — what was resolved / dropped / degraded. */
14792
+ var RenderedAsSchema = object({
14793
+ level: string(),
14794
+ format: NotificationFormatSchema,
14795
+ attachmentsSent: number().int().nonnegative(),
14796
+ actionsSent: number().int().nonnegative(),
14797
+ truncated: boolean(),
14798
+ dropped: array(string())
14799
+ });
14800
+ var SendResultSchema = object({
14801
+ success: boolean(),
14802
+ error: string().optional(),
14803
+ renderedAs: RenderedAsSchema.optional()
14804
+ });
14805
+ /** Same shape as SendResult — kept as a distinct name for the test panel. */
14806
+ var TestResultSchema = SendResultSchema;
14807
+ /**
14808
+ * Pre-save credential probe against a partial (unsaved) target config.
14809
+ * `resolvedUrl` never includes secrets (token stripped from path).
14810
+ */
14811
+ var ProbeTargetConfigResultSchema = object({
14812
+ ok: boolean(),
14813
+ resolvedUrl: string(),
14814
+ httpStatus: number().int().optional(),
14815
+ stateInstance: string().optional(),
14816
+ error: string().optional()
14817
+ });
14818
+ method(object({}), array(TargetKindSchema)), method(object({
14819
+ kind: string(),
14820
+ config: record(string(), unknown()).optional(),
14821
+ /**
14822
+ * When editing / duplicating, the blank password field never round-trips
14823
+ * the stored token. Pass the source target id so the provider can restore
14824
+ * secrets server-side before dialling.
14825
+ */
14826
+ targetId: string().optional()
14827
+ }), array(DiscoveredTargetSchema), { auth: "admin" }), method(object({
14828
+ kind: string(),
14829
+ config: record(string(), unknown()),
14830
+ /** See `discoverTargets.targetId` — restore stored secrets for a blank password. */
14831
+ targetId: string().optional()
14832
+ }), ProbeTargetConfigResultSchema, {
14833
+ kind: "mutation",
14834
+ auth: "admin"
14835
+ }), method(object({
14836
+ targetId: string(),
14837
+ notification: NotificationSchema
14838
+ }), SendResultSchema, {
14839
+ kind: "mutation",
14840
+ auth: "admin"
14841
+ }), method(object({
14842
+ targetId: string(),
14843
+ sample: NotificationSchema.optional()
14844
+ }), TestResultSchema, {
14845
+ kind: "mutation",
14846
+ auth: "admin"
14847
+ });
14848
+ looseObject({
14849
+ name: string().min(1),
14850
+ enabled: boolean().optional()
13983
14851
  });
14852
+ TargetSchema.omit({ id: true });
13984
14853
  var EncodeProfileSchema = object({
13985
14854
  video: object({
13986
14855
  codec: _enum([
@@ -20477,31 +21346,21 @@ var APPLIANCE_CAP_VOCABULARY = {
20477
21346
  "pet-fountain": {
20478
21347
  scope: "device",
20479
21348
  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
- ],
21349
+ actions: [{
21350
+ id: "petFountain.pumpOn",
21351
+ method: "setPump",
21352
+ label: t("Pump on", "Pompa accesa"),
21353
+ phrase: t("Start the pump of {device}", "Avvia la pompa di {device}"),
21354
+ icon: "play",
21355
+ args: { on: true }
21356
+ }, {
21357
+ id: "petFountain.pumpOff",
21358
+ method: "setPump",
21359
+ label: t("Pump off", "Pompa spenta"),
21360
+ phrase: t("Stop the pump of {device}", "Ferma la pompa di {device}"),
21361
+ icon: "square",
21362
+ args: { on: false }
21363
+ }],
20505
21364
  state: [{
20506
21365
  kind: "boolean",
20507
21366
  field: "empty",
@@ -22520,7 +23379,6 @@ var SYSTEM_CAP_VOCABULARY = {
22520
23379
  "calendar-source": system(INTERNAL),
22521
23380
  calendars: system("calendars feed schedules and conditions, not device actions"),
22522
23381
  composer: system("device composition — an authoring tool, not an action"),
22523
- "connection-test": system(INTERNAL),
22524
23382
  "core-blocks": system(INTERNAL),
22525
23383
  "custom-model-registry": system(ML),
22526
23384
  "data-store-provider": system(INTERNAL),
@@ -22565,7 +23423,6 @@ var SYSTEM_CAP_VOCABULARY = {
22565
23423
  "notification-output": system("notification delivery — reached through notifier devices and rules"),
22566
23424
  "notification-rules": system("notification rules — authored on their own page"),
22567
23425
  "oauth-integration": system(IDENTITY),
22568
- "oidc-connections": system(IDENTITY),
22569
23426
  "osd-manager": system(PIPELINE),
22570
23427
  "pipeline-executor": system(PIPELINE),
22571
23428
  "pipeline-orchestrator": system(PIPELINE),
@@ -44395,8 +45252,15 @@ var ActionInputSchema = object({
44395
45252
  var ActionRunOriginSchema = object({
44396
45253
  /** The automation block whose step started it. */
44397
45254
  blockId: string().min(1).optional() });
44398
- /** `started` = the caller did not ask to wait. */
44399
- var ActionRunOutcomeSchema = union([AutomationRunOutcomeSchema, literal("started")]);
45255
+ /**
45256
+ * `started` = the caller did not ask to wait. `timed-out` = the run reached the
45257
+ * ceiling (`ACTION_RUN_MAX_MS`) and was stopped; it is never a `ran`.
45258
+ */
45259
+ var ActionRunOutcomeSchema = union([
45260
+ AutomationRunOutcomeSchema,
45261
+ literal("started"),
45262
+ literal("timed-out")
45263
+ ]);
44400
45264
  var ActionRunResultSchema = object({
44401
45265
  runId: string().min(1),
44402
45266
  outcome: ActionRunOutcomeSchema,
@@ -44430,427 +45294,6 @@ var UnitWarningSchema = object({
44430
45294
  assumedUnit: string(),
44431
45295
  message: string()
44432
45296
  });
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
45297
  _enum([
44855
45298
  "automation",
44856
45299
  "action",
@@ -44918,6 +45361,8 @@ method(object({}), array(ActionEntrySchema), { auth: "admin" }), method(object({
44918
45361
  kind: "mutation",
44919
45362
  auth: "admin"
44920
45363
  });
45364
+ /** `timeoutMs` of `actions.run`: a waited call outlives any legal run. */
45365
+ var ACTION_RUN_TIMEOUT_MS = 363e4;
44921
45366
  /**
44922
45367
  * actions — the ONE surface for runnable actions, for the UI and for
44923
45368
  * automations. Provided by the core-blocks builtin on the hub.
@@ -44936,6 +45381,12 @@ method(object({}), array(ActionEntrySchema), { auth: "admin" }), method(object({
44936
45381
  * An admin, and an in-process caller (an automation block), may run any action.
44937
45382
  * Every refusal is typed (`[not-linked] …`) and logged.
44938
45383
  *
45384
+ * **A run lasts at most `ACTION_RUN_MAX_MS` (60 min).** The provider stops a
45385
+ * run that reaches it and answers `timed-out` (never `ran`); an action whose
45386
+ * `wait` steps alone add up to more is refused at create/update
45387
+ * (`[invalid-steps]`). `run` declares a `timeoutMs` above that ceiling, so a
45388
+ * waited call (an automation step) is never cut by the 60 s transport default.
45389
+ *
44939
45390
  * A second `run` of an action that is already running is REFUSED — traced and
44940
45391
  * logged — never queued.
44941
45392
  */
@@ -44962,7 +45413,8 @@ method(object({}), array(ActionEntrySchema), { auth: "admin" }), method(object({
44962
45413
  role: "viewer",
44963
45414
  auth: "protected",
44964
45415
  kind: "mutation",
44965
- caller: "required"
45416
+ caller: "required",
45417
+ timeoutMs: ACTION_RUN_TIMEOUT_MS
44966
45418
  }), method(ActionIdInput, _void(), {
44967
45419
  kind: "mutation",
44968
45420
  auth: "admin"
@@ -45112,6 +45564,8 @@ var SettingsSchemaWithValuesSchema = object({
45112
45564
  });
45113
45565
  /** Patch object — keys are field names, values are the new field values. */
45114
45566
  var SettingsPatchSchema = record(string(), unknown());
45567
+ /** The scope of a scoped-settings call (D986): where the capability declared the values. */
45568
+ var ScopedSettingsScopeSchema = _enum(SCOPED_SETTINGS_SCOPES);
45115
45569
  /** Standard success response for update operations. */
45116
45570
  var SettingsUpdateResultSchema = object({ success: literal(true) });
45117
45571
  method(object({
@@ -45127,6 +45581,25 @@ method(object({
45127
45581
  kind: "mutation",
45128
45582
  auth: "admin"
45129
45583
  }), method(object({
45584
+ addonId: string(),
45585
+ cap: string(),
45586
+ scope: ScopedSettingsScopeSchema,
45587
+ nodeId: string().optional()
45588
+ }), SettingsSchemaWithValuesSchema.nullable()), method(object({
45589
+ addonId: string(),
45590
+ cap: string(),
45591
+ scope: ScopedSettingsScopeSchema,
45592
+ nodeId: string().optional(),
45593
+ patch: SettingsPatchSchema
45594
+ }), SettingsUpdateResultSchema, {
45595
+ kind: "mutation",
45596
+ auth: "admin"
45597
+ }), method(object({
45598
+ addonId: string(),
45599
+ cap: string(),
45600
+ scope: ScopedSettingsScopeSchema,
45601
+ nodeId: string().optional()
45602
+ }), record(string(), unknown()).nullable()), method(object({
45130
45603
  addonId: string(),
45131
45604
  nodeId: string().optional()
45132
45605
  }), SettingsSchemaWithValuesSchema.nullable()), method(object({
@@ -48748,37 +49221,6 @@ method(object({
48748
49221
  kind: "mutation",
48749
49222
  auth: "admin"
48750
49223
  }), 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
49224
  object({
48783
49225
  /** True when the upstream system considers the entity connected. */
48784
49226
  connected: boolean(),
@@ -49036,6 +49478,9 @@ var MediaPlayerStatusSchema = object({
49036
49478
  /** Repeat mode. Null when no repeat surface.
49037
49479
  * Pair with `DeviceFeature.MediaPlayerRepeat`. */
49038
49480
  repeat: MediaPlayerRepeatSchema.nullable(),
49481
+ /** Ms epoch when `position` was read from the device. Null when the driver
49482
+ * does not say; a UI that advances the position while playing counts from it. */
49483
+ positionUpdatedAt: number().nullable().default(null),
49039
49484
  /** Ms epoch when the slice was last updated. */
49040
49485
  lastChangedAt: number()
49041
49486
  });
@@ -54847,6 +55292,7 @@ var IntegrationWithStateSchema = object({
54847
55292
  id: string(),
54848
55293
  addonId: string(),
54849
55294
  name: string(),
55295
+ /** A projection of the instance body's switch (`setInstanceEnabled` is the only writer). */
54850
55296
  enabled: boolean(),
54851
55297
  info: record(string(), unknown()).readonly(),
54852
55298
  /** The discovery candidate this integration was set up from (D984). */
@@ -54859,6 +55305,7 @@ var IntegrationLiteSchema = object({
54859
55305
  id: string(),
54860
55306
  addonId: string(),
54861
55307
  name: string(),
55308
+ /** A projection of the instance body's switch (`setInstanceEnabled` is the only writer). */
54862
55309
  enabled: boolean(),
54863
55310
  info: record(string(), unknown()).readonly(),
54864
55311
  /** The discovery candidate this integration was set up from (D984). */
@@ -54904,10 +55351,9 @@ var AvailableIntegrationTypeSchema = object({
54904
55351
  * locations" checkbox. Provider-declared in the addon manifest. */
54905
55352
  supportsLocationImport: boolean(),
54906
55353
  /**
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.
55354
+ * True when this integration's instances declare a Test (`integration-instances.describe().canTest`,
55355
+ * D1016). An integration that cannot be tested must say so up front rather than offering a
55356
+ * button that always answers the same nonsense.
54911
55357
  */
54912
55358
  canTest: boolean(),
54913
55359
  existingInstances: array(object({
@@ -54958,15 +55404,21 @@ var TestConnectionResultSchema = object({
54958
55404
  var CreateIntegrationInputSchema = object({
54959
55405
  addonId: string(),
54960
55406
  name: string(),
54961
- enabled: boolean().optional(),
54962
55407
  info: record(string(), unknown()).optional(),
54963
55408
  /** `stableId` of the discovery candidate the form was seeded from (D984). */
54964
55409
  originStableId: string().optional(),
54965
- settings: record(string(), unknown()).optional()
55410
+ settings: record(string(), unknown()).optional(),
55411
+ /** The instance kind being created, for a provider with several; omitted = its only testable kind. */
55412
+ kind: string().min(1).optional()
54966
55413
  });
54967
55414
  var UpdateIntegrationInputSchema = object({
54968
55415
  id: string(),
54969
55416
  name: string().optional(),
55417
+ /**
55418
+ * Accepted for a FIXED builtin only (`info.fixed`: alarm panel, camera grid, core blocks,
55419
+ * terminal), which keeps no instance record: the registry flag is its one store. Any other
55420
+ * integration is switched through `integration-instances.setInstanceEnabled`.
55421
+ */
54970
55422
  enabled: boolean().optional(),
54971
55423
  info: record(string(), unknown()).optional()
54972
55424
  });
@@ -54983,13 +55435,7 @@ method(_void(), array(IntegrationWithStateSchema)), method(object({ id: string()
54983
55435
  }), method(object({ id: string() }), DeleteIntegrationResultSchema, {
54984
55436
  kind: "mutation",
54985
55437
  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
- });
55438
+ }), method(_void(), array(AvailableIntegrationTypeSchema), { auth: "admin" });
54993
55439
  /**
54994
55440
  * `integration-instances` - the connection of an addon that holds ONE or SEVERAL
54995
55441
  * (an account, a relay, a destination) as typed records (D985, D986). The addon's
@@ -55009,12 +55455,12 @@ method(_void(), array(IntegrationWithStateSchema)), method(object({ id: string()
55009
55455
  * or the redaction token KEEPS the stored secret; `{ $secretClear: true }`
55010
55456
  * clears it.
55011
55457
  */
55012
- var ConfigSchemaPassthrough$3 = custom();
55458
+ var ConfigSchemaPassthrough$2 = custom();
55013
55459
  var IntegrationInstanceIdSchema = string().min(1);
55014
55460
  var IntegrationInstanceModeSchema = _enum(["single", "multiple"]);
55015
55461
  /**
55016
55462
  * 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);
55463
+ * instance is an integration that brings devices (its record body owns the on/off switch);
55018
55464
  * `services`: a connection configured from the addon's own function page, never listed on
55019
55465
  * Integrations.
55020
55466
  * It is the same vocabulary as the manifest's `integrationRole`, which stays as an override.
@@ -55055,7 +55501,16 @@ var IntegrationInstanceKindSchema = object({
55055
55501
  /** Relative hub path to start an interactive account link of an instance of this kind. */
55056
55502
  connectPath: string().min(1).optional(),
55057
55503
  /** Relative hub path to disconnect that account. */
55058
- disconnectPath: string().min(1).optional()
55504
+ disconnectPath: string().min(1).optional(),
55505
+ /**
55506
+ * Parts of the edit dialog the flat form cannot draw (a node picker, a model source), named by a
55507
+ * GENERIC widget id the client maps to a component; a client that knows none of them shows none.
55508
+ * `connection` widgets write connection values, `model` widgets own the model choice.
55509
+ */
55510
+ widgets: array(object({
55511
+ id: string().min(1),
55512
+ placement: _enum(["connection", "model"])
55513
+ })).optional()
55059
55514
  });
55060
55515
  /**
55061
55516
  * How devices of an instance are found. `none`: the operator adds them by hand; `lan`: the addon
@@ -55131,8 +55586,8 @@ var IntegrationInstanceSchema = object({
55131
55586
  configured: boolean(),
55132
55587
  /**
55133
55588
  * 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.
55589
+ * so a row written before the field existed is on). The same for every role, `devices` included:
55590
+ * the body is the one store, `setInstanceEnabled` the one writer (epic #440, step 3).
55136
55591
  */
55137
55592
  enabled: boolean().optional(),
55138
55593
  /** The kind of this instance (one of `describe().kinds[].id`), when the provider has kinds. */
@@ -55153,7 +55608,7 @@ method(_void(), IntegrationInstanceDescriptionSchema, { auth: "admin" }), method
55153
55608
  id: IntegrationInstanceIdSchema.nullable(),
55154
55609
  /** The kind of the create form (`id: null`) of a provider with several. */
55155
55610
  kind: string().min(1).optional()
55156
- }), ConfigSchemaPassthrough$3, { auth: "admin" }), method(_void(), array(IntegrationInstanceSchema).readonly(), { auth: "admin" }), method(object({ id: IntegrationInstanceIdSchema }), IntegrationInstanceSchema.nullable(), { auth: "admin" }), method(object({
55611
+ }), ConfigSchemaPassthrough$2, { auth: "admin" }), method(_void(), array(IntegrationInstanceSchema).readonly(), { auth: "admin" }), method(object({ id: IntegrationInstanceIdSchema }), IntegrationInstanceSchema.nullable(), { auth: "admin" }), method(object({
55157
55612
  id: IntegrationInstanceIdSchema.optional(),
55158
55613
  name: string().min(1),
55159
55614
  kind: string().min(1).optional(),
@@ -56085,12 +56540,12 @@ var LlmModelInfoSchema = object({
56085
56540
  });
56086
56541
  /**
56087
56542
  * The provider-specific part of a profile, validated by the provider that owns
56088
- * the kind (`upsertProfile` refuses what it does not accept). A field its
56543
+ * the kind (saving an instance refuses what it does not accept). A field its
56089
56544
  * `connectionSchema` declares `type: 'password'` is a secret: it is held in the
56090
56545
  * keychain, never in the row, and reads back as the redaction marker.
56091
56546
  */
56092
56547
  var LlmProviderConfigSchema = record(string(), unknown());
56093
- var LlmProfileSchema = object({
56548
+ object({
56094
56549
  id: string(),
56095
56550
  name: string(),
56096
56551
  /** The provider-declared kind (`LlmProfileKindDescriptor.kind`). */
@@ -56184,8 +56639,8 @@ var LlmProviderWidgetSchema = object({
56184
56639
  /** ConfigUISchema tree passed through untyped on the wire (the
56185
56640
  * notification-output `ConfigSchemaPassthrough` precedent at
56186
56641
  * notification-output.cap.ts:151); the exported TS type re-tightens it. */
56187
- var ConfigSchemaPassthrough$2 = unknown();
56188
- var LlmProfileKindDescriptorSchema = object({
56642
+ var ConfigSchemaPassthrough$1 = unknown();
56643
+ object({
56189
56644
  kind: LlmProfileKindSchema,
56190
56645
  label: string(),
56191
56646
  /** A generic icon name (`cloud`, `plug`, `cpu`) — never a glyph or a logo. */
@@ -56193,9 +56648,9 @@ var LlmProfileKindDescriptorSchema = object({
56193
56648
  /** Stamped by each provider so the concat-fanned catalog stays routable. */
56194
56649
  addonId: string(),
56195
56650
  /** The provider's own fields (`providerConfig`); `password` fields are keychain-held. */
56196
- connectionSchema: ConfigSchemaPassthrough$2,
56651
+ connectionSchema: ConfigSchemaPassthrough$1,
56197
56652
  /** Provider fields that belong under "Advanced" (extra headers, runtime tuning). */
56198
- advancedSchema: ConfigSchemaPassthrough$2.optional(),
56653
+ advancedSchema: ConfigSchemaPassthrough$1.optional(),
56199
56654
  /** The kind's defaults; a model from `listModels` may override any of them. */
56200
56655
  features: LlmModelFeaturesSchema,
56201
56656
  /** `false` = the provider stamps `supportsVision` itself (from what a node reports). */
@@ -56324,20 +56779,7 @@ method(LlmGenerateBaseInputSchema, LlmGenerateResultSchema, {
56324
56779
  }), method(object({
56325
56780
  addonId: string().optional(),
56326
56781
  requestId: string()
56327
- }), _void(), { kind: "mutation" }), method(object({}), array(LlmProfileKindDescriptorSchema)), method(object({}), array(LlmProfileSchema)), method(object({ profile: LlmProfileSchema }), LlmProfileSchema, {
56328
- kind: "mutation",
56329
- auth: "admin"
56330
- }), method(RawSecretMigrationInputSchema, RawSecretMigrationReportSchema, {
56331
- kind: "mutation",
56332
- auth: "admin"
56333
- }), method(ProfileRefInputSchema, _void(), {
56334
- kind: "mutation",
56335
- auth: "admin"
56336
- }), method(ProfileRefInputSchema, LlmGenerateResultSchema, {
56337
- kind: "mutation",
56338
- auth: "admin",
56339
- timeoutMs: AI_CAP_TRANSPORT_TIMEOUT_MS
56340
- }), method(LlmListModelsInputSchema, LlmListModelsResultSchema, {
56782
+ }), _void(), { kind: "mutation" }), method(LlmListModelsInputSchema, LlmListModelsResultSchema, {
56341
56783
  kind: "mutation",
56342
56784
  auth: "admin"
56343
56785
  }), method(object({}), array(LlmDefaultSchema)), method(object({
@@ -57332,20 +57774,7 @@ method(_void(), MeshStatusSchema), method(object({
57332
57774
  /** Optional hostname override the host should advertise once joined. */
57333
57775
  hostname: string().optional() }), object({
57334
57776
  /** Authentication URL the operator should open in a browser. */
57335
- loginUrl: string() }), { kind: "mutation" }), method(_void(), object({ left: literal(true) }), { kind: "mutation" }), method(_void(), object({ loggedOut: literal(true) }), { kind: "mutation" }), method(_void(), object({ peers: array(MeshPeerSchema).readonly() })), method(object({
57336
- /** Optional auth key — when provided, probes the key validity
57337
- * against the provider's API. Omit when already joined to
57338
- * just ping the daemon. */
57339
- authKey: string().optional() }), object({
57340
- ok: boolean(),
57341
- /** Provider-side identifier resolved by the probe (tailnet
57342
- * name for Tailscale, network id for ZeroTier, etc.). */
57343
- tenant: string().optional(),
57344
- /** Daemon binary version, when reachable. */
57345
- daemonVersion: string().optional(),
57346
- /** Human-readable error when `ok: false`. */
57347
- error: string().optional()
57348
- }), { kind: "mutation" });
57777
+ loginUrl: string() }), { kind: "mutation" }), method(_void(), object({ left: literal(true) }), { kind: "mutation" }), method(_void(), object({ loggedOut: literal(true) }), { kind: "mutation" }), method(_void(), object({ peers: array(MeshPeerSchema).readonly() }));
57349
57778
  object({
57350
57779
  value: number().nullable().meta(readingMeta("device", { label: "Total" })),
57351
57780
  lastFetchedAt: number()
@@ -57968,6 +58397,8 @@ var MigrationIntegrationSchema = object({
57968
58397
  addonId: string(),
57969
58398
  name: string(),
57970
58399
  info: Rows,
58400
+ /** The registry's stored switch: read by the one-switch migration, nothing else. */
58401
+ enabled: boolean().optional(),
57971
58402
  originStableId: string().optional()
57972
58403
  });
57973
58404
  var MigrationDeviceSchema = object({
@@ -63672,13 +64103,6 @@ var AddBrokerInputSchema = object({
63672
64103
  });
63673
64104
  var AddBrokerResultSchema = object({ id: string() });
63674
64105
  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
64106
  var StartEmbeddedInputSchema = object({
63683
64107
  port: number().int().min(1).max(65535).default(1883),
63684
64108
  /** Allow anonymous connect (no username/password). Default: false. */
@@ -63701,9 +64125,6 @@ method(_void(), array(BrokerInfoSchema)), method(IdInputSchema, BrokerConnection
63701
64125
  }), method(IdInputSchema, _void(), {
63702
64126
  kind: "mutation",
63703
64127
  auth: "admin"
63704
- }), method(IdInputSchema, TestResultSchema$1, {
63705
- kind: "mutation",
63706
- auth: "admin"
63707
64128
  }), method(StartEmbeddedInputSchema, StartEmbeddedResultSchema, {
63708
64129
  kind: "mutation",
63709
64130
  auth: "admin"
@@ -67489,61 +67910,6 @@ var OauthIntegrationDescriptorSchema = object({
67489
67910
  });
67490
67911
  method(_void(), OauthIntegrationDescriptorSchema, { auth: "admin" });
67491
67912
  /**
67492
- * `oidc-connections` — CRUD for IdP rows under `auth-oidc` (D828 sibling).
67493
- *
67494
- * One hub-only singleton (`auth-oidc`). The Settings UI is a DataTable +
67495
- * ItemFormDialog; there is no `editable-array` in `globalSettingsSchema`.
67496
- * Operator-chosen `id` is the URL slug (`/addon/auth-oidc/<id>/…`) and is
67497
- * immutable after create.
67498
- */
67499
- var ConfigSchemaPassthrough$1 = unknown();
67500
- var OidcConnectionSchema = object({
67501
- id: string().min(1),
67502
- displayName: string(),
67503
- icon: string(),
67504
- issuerUrl: string(),
67505
- clientId: string(),
67506
- /** Client id + secret present — never the secret value. */
67507
- configured: boolean(),
67508
- /**
67509
- * Values for the connection form schema. `clientSecret` is a keychain
67510
- * {@link SecretFieldView} or `null` / `''`, never plaintext (D789).
67511
- */
67512
- formValues: record(string(), unknown()).optional()
67513
- });
67514
- /**
67515
- * Patch one connection. Omitted or empty `clientSecret` keeps the stored
67516
- * secret (D787). `{ $secretClear: true }` clears it. `id` is never renamed.
67517
- */
67518
- var OidcConnectionUpdateInputSchema = object({
67519
- id: string().min(1),
67520
- displayName: string().min(1),
67521
- icon: string().optional(),
67522
- issuerUrl: string().optional(),
67523
- clientId: string().optional(),
67524
- clientSecret: union([string(), object({ $secretClear: literal(true) })]).optional(),
67525
- redirectUri: string().optional(),
67526
- scopes: string().optional(),
67527
- usernameClaim: _enum([
67528
- "preferred_username",
67529
- "email",
67530
- "sub"
67531
- ]).optional()
67532
- });
67533
- method(object({}), ConfigSchemaPassthrough$1, { auth: "admin" }), method(object({}), array(OidcConnectionSchema).readonly(), { auth: "admin" }), method(object({
67534
- id: string().min(1).regex(/^[a-z0-9][a-z0-9-]{0,63}$/, "id must be a lowercase slug"),
67535
- displayName: string().min(1)
67536
- }), object({ id: string() }), {
67537
- kind: "mutation",
67538
- auth: "admin"
67539
- }), method(OidcConnectionUpdateInputSchema, object({ ok: literal(true) }), {
67540
- kind: "mutation",
67541
- auth: "admin"
67542
- }), method(object({ id: string().min(1) }), object({ ok: literal(true) }), {
67543
- kind: "mutation",
67544
- auth: "admin"
67545
- });
67546
- /**
67547
67913
  * Generic on-screen-display (video overlay) cap. Each camera exposes
67548
67914
  * a firmware-defined list of overlays (channel name, timestamp,
67549
67915
  * watermark, logo, …); the cap models them as a homogeneous array of
@@ -67964,14 +68330,6 @@ object({
67964
68330
  empty: boolean().nullable(),
67965
68331
  /** True while the pump is running. Null while unknown. */
67966
68332
  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
68333
  /** Decoded fault message. Null means healthy; a non-null string is an active fault. */
67976
68334
  error: string().nullable(),
67977
68335
  /** Ms epoch when the slice was last refreshed. */
@@ -67984,9 +68342,6 @@ DeviceType.PetFountain, method(object({
67984
68342
  }), _void(), {
67985
68343
  kind: "mutation",
67986
68344
  auth: "protected"
67987
- }), method(object({ deviceId: DeviceIdSchema$1 }), _void(), {
67988
- kind: "mutation",
67989
- auth: "protected"
67990
68345
  });
67991
68346
  /**
67992
68347
  * The wire shapes of the Auto tune plan and apply (D745), used by the
@@ -74956,21 +75311,6 @@ method(object({
74956
75311
  */
74957
75312
  ttlSec: union([number().int().positive(), literal("never")]).optional()
74958
75313
  }), object({ token: string() }), { auth: "admin" }), method(object({ token: string() }), SsoBridgeClaimsSchema.nullable(), { auth: "admin" });
74959
- var ProviderListEntrySchema = discriminatedUnion("shouldSaveDiskSpace", [object({
74960
- providerId: string().min(1),
74961
- displayName: string().min(1),
74962
- configSchema: unknown(),
74963
- nodeLocal: boolean(),
74964
- shouldSaveDiskSpace: literal(true),
74965
- minFreePercent: number().min(0).max(100)
74966
- }), object({
74967
- providerId: string().min(1),
74968
- displayName: string().min(1),
74969
- configSchema: unknown(),
74970
- nodeLocal: boolean(),
74971
- shouldSaveDiskSpace: literal(false),
74972
- minFreePercent: literal(null)
74973
- })]);
74974
75314
  method(object({
74975
75315
  location: StorageLocationRefSchema,
74976
75316
  relativePath: string()
@@ -75032,42 +75372,7 @@ method(object({
75032
75372
  }), _instanceof(Uint8Array), { auth: "admin" }), method(object({ downloadId: string() }), _void(), {
75033
75373
  kind: "mutation",
75034
75374
  auth: "admin"
75035
- }), method(object({ type: StorageLocationTypeSchema.optional() }), array(StorageLocationSchema).readonly()), method(_void(), array(StorageLocationDeclarationSchema).readonly()), method(StorageLocationSchema.omit({
75036
- createdAt: true,
75037
- updatedAt: true
75038
- }), StorageLocationSchema, {
75039
- kind: "mutation",
75040
- auth: "admin"
75041
- }), method(object({
75042
- id: string(),
75043
- force: boolean().optional()
75044
- }), _void(), {
75045
- kind: "mutation",
75046
- auth: "admin"
75047
- }), method(_void(), array(StorageDrainProgressSchema).readonly()), method(object({ id: string() }), object({
75048
- ok: boolean(),
75049
- error: string().optional()
75050
- }), { auth: "admin" }), method(_void(), array(ProviderListEntrySchema).readonly()), method(object({
75051
- providerId: string(),
75052
- /**
75053
- * The location this config is an UNSAVED edit of, when there is one.
75054
- *
75055
- * `listLocations` replaces every declared secret with the redaction
75056
- * sentinel, so the edit modal's form state holds the sentinel for any
75057
- * credential the operator did not retype — and posting that here
75058
- * without a way to resolve it makes the provider try to authenticate
75059
- * as `__camstack_redacted__` and report the operator's own working
75060
- * password as wrong. Given this id, the orchestrator restores each
75061
- * sentinel from the stored config (same rule as `upsertLocation`)
75062
- * before dispatching. Omitted by the "Add location" wizard, where
75063
- * every value was typed just now and nothing is stored yet.
75064
- */
75065
- locationId: string().optional(),
75066
- config: record(string(), unknown())
75067
- }), object({
75068
- ok: boolean(),
75069
- error: string().optional()
75070
- }), { auth: "admin" });
75375
+ }), method(object({ type: StorageLocationTypeSchema.optional() }), array(StorageLocationSchema).readonly()), method(_void(), array(StorageLocationDeclarationSchema).readonly()), method(_void(), array(StorageDrainProgressSchema).readonly());
75071
75376
  /** One table of the settings database. */
75072
75377
  var StorageTableSchema = object({
75073
75378
  /** The table's full name, e.g. `recorder:addon-settings` or `addon-device-settings`. */
@@ -76565,7 +76870,7 @@ var TrainingProviderTypeSchema = object({
76565
76870
  label: string(),
76566
76871
  /** Path under the addon package (e.g. `assets/training-modal/icon.svg`). */
76567
76872
  iconAsset: string(),
76568
- /** Owning `training-provider` addon — collection selector for createEntry. */
76873
+ /** Owning `training-provider` addon. */
76569
76874
  addonId: string(),
76570
76875
  /**
76571
76876
  * Fields for one entry of this type (credentials + defaults). Absent on a
@@ -76610,36 +76915,6 @@ var TrainingProviderDescriptorSchema = object({
76610
76915
  */
76611
76916
  formValues: record(string(), unknown()).optional()
76612
76917
  });
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
76918
  var ProviderJobStateSchema = _enum([
76644
76919
  "pending",
76645
76920
  "starting",
@@ -76687,22 +76962,6 @@ var TrainingLogLineSchema = object({
76687
76962
  text: string()
76688
76963
  });
76689
76964
  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
76965
  entryId: string().min(1),
76707
76966
  gpuType: string(),
76708
76967
  region: string(),
@@ -79294,6 +79553,20 @@ Object.freeze({
79294
79553
  access: "view",
79295
79554
  role: "admin"
79296
79555
  },
79556
+ "addonSettings.getScopedSettings": {
79557
+ capName: "addon-settings",
79558
+ capScope: "system",
79559
+ addonId: null,
79560
+ access: "view",
79561
+ role: "admin"
79562
+ },
79563
+ "addonSettings.readScopedValues": {
79564
+ capName: "addon-settings",
79565
+ capScope: "system",
79566
+ addonId: null,
79567
+ access: "view",
79568
+ role: "admin"
79569
+ },
79297
79570
  "addonSettings.unsetStoredSettingsKeys": {
79298
79571
  capName: "addon-settings",
79299
79572
  capScope: "system",
@@ -79315,6 +79588,13 @@ Object.freeze({
79315
79588
  access: "create",
79316
79589
  role: "admin"
79317
79590
  },
79591
+ "addonSettings.updateScopedSettings": {
79592
+ capName: "addon-settings",
79593
+ capScope: "system",
79594
+ addonId: null,
79595
+ access: "create",
79596
+ role: "admin"
79597
+ },
79318
79598
  "addonWidgets.listWidgets": {
79319
79599
  capName: "addon-widgets",
79320
79600
  capScope: "system",
@@ -80148,20 +80428,6 @@ Object.freeze({
80148
80428
  access: "view",
80149
80429
  role: "admin"
80150
80430
  },
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
80431
  "connectivity.getStatus": {
80166
80432
  capName: "connectivity",
80167
80433
  capScope: "device",
@@ -82528,13 +82794,6 @@ Object.freeze({
82528
82794
  access: "view",
82529
82795
  role: "admin"
82530
82796
  },
82531
- "integrations.testConnection": {
82532
- capName: "integrations",
82533
- capScope: "system",
82534
- addonId: null,
82535
- access: "create",
82536
- role: "admin"
82537
- },
82538
82797
  "integrations.update": {
82539
82798
  capName: "integrations",
82540
82799
  capScope: "system",
@@ -82787,13 +83046,6 @@ Object.freeze({
82787
83046
  access: "delete",
82788
83047
  role: "admin"
82789
83048
  },
82790
- "llm.deleteProfile": {
82791
- capName: "llm",
82792
- capScope: "system",
82793
- addonId: null,
82794
- access: "delete",
82795
- role: "admin"
82796
- },
82797
83049
  "llm.generate": {
82798
83050
  capName: "llm",
82799
83051
  capScope: "system",
@@ -82857,20 +83109,6 @@ Object.freeze({
82857
83109
  access: "view",
82858
83110
  role: "admin"
82859
83111
  },
82860
- "llm.listProfileKinds": {
82861
- capName: "llm",
82862
- capScope: "system",
82863
- addonId: null,
82864
- access: "view",
82865
- role: "admin"
82866
- },
82867
- "llm.listProfiles": {
82868
- capName: "llm",
82869
- capScope: "system",
82870
- addonId: null,
82871
- access: "view",
82872
- role: "admin"
82873
- },
82874
83112
  "llm.listRuntimeNodes": {
82875
83113
  capName: "llm",
82876
83114
  capScope: "system",
@@ -82878,13 +83116,6 @@ Object.freeze({
82878
83116
  access: "view",
82879
83117
  role: "admin"
82880
83118
  },
82881
- "llm.migrateRawSecrets": {
82882
- capName: "llm",
82883
- capScope: "system",
82884
- addonId: null,
82885
- access: "create",
82886
- role: "admin"
82887
- },
82888
83119
  "llm.resolveModelRef": {
82889
83120
  capName: "llm",
82890
83121
  capScope: "system",
@@ -82913,20 +83144,6 @@ Object.freeze({
82913
83144
  access: "create",
82914
83145
  role: "admin"
82915
83146
  },
82916
- "llm.testProfile": {
82917
- capName: "llm",
82918
- capScope: "system",
82919
- addonId: null,
82920
- access: "create",
82921
- role: "admin"
82922
- },
82923
- "llm.upsertProfile": {
82924
- capName: "llm",
82925
- capScope: "system",
82926
- addonId: null,
82927
- access: "create",
82928
- role: "admin"
82929
- },
82930
83147
  "llmRuntime.appleAvailability": {
82931
83148
  capName: "llm-runtime",
82932
83149
  capScope: "system",
@@ -83431,13 +83648,6 @@ Object.freeze({
83431
83648
  access: "create",
83432
83649
  role: "admin"
83433
83650
  },
83434
- "meshNetwork.testConnection": {
83435
- capName: "mesh-network",
83436
- capScope: "system",
83437
- addonId: null,
83438
- access: "create",
83439
- role: "admin"
83440
- },
83441
83651
  "meter.getStatus": {
83442
83652
  capName: "meter",
83443
83653
  capScope: "device",
@@ -83767,13 +83977,6 @@ Object.freeze({
83767
83977
  access: "create",
83768
83978
  role: "admin"
83769
83979
  },
83770
- "mqttBroker.testConnection": {
83771
- capName: "mqtt-broker",
83772
- capScope: "system",
83773
- addonId: null,
83774
- access: "create",
83775
- role: "admin"
83776
- },
83777
83980
  "nativeObjectDetection.getOptions": {
83778
83981
  capName: "native-object-detection",
83779
83982
  capScope: "device",
@@ -84103,13 +84306,6 @@ Object.freeze({
84103
84306
  access: "create",
84104
84307
  role: "admin"
84105
84308
  },
84106
- "notificationOutput.deleteTarget": {
84107
- capName: "notification-output",
84108
- capScope: "system",
84109
- addonId: null,
84110
- access: "delete",
84111
- role: "admin"
84112
- },
84113
84309
  "notificationOutput.discoverTargets": {
84114
84310
  capName: "notification-output",
84115
84311
  capScope: "system",
@@ -84117,13 +84313,6 @@ Object.freeze({
84117
84313
  access: "view",
84118
84314
  role: "admin"
84119
84315
  },
84120
- "notificationOutput.getTarget": {
84121
- capName: "notification-output",
84122
- capScope: "system",
84123
- addonId: null,
84124
- access: "view",
84125
- role: "admin"
84126
- },
84127
84316
  "notificationOutput.listTargetKinds": {
84128
84317
  capName: "notification-output",
84129
84318
  capScope: "system",
@@ -84131,13 +84320,6 @@ Object.freeze({
84131
84320
  access: "view",
84132
84321
  role: "admin"
84133
84322
  },
84134
- "notificationOutput.listTargets": {
84135
- capName: "notification-output",
84136
- capScope: "system",
84137
- addonId: null,
84138
- access: "view",
84139
- role: "admin"
84140
- },
84141
84323
  "notificationOutput.probeTargetConfig": {
84142
84324
  capName: "notification-output",
84143
84325
  capScope: "system",
@@ -84152,13 +84334,6 @@ Object.freeze({
84152
84334
  access: "create",
84153
84335
  role: "admin"
84154
84336
  },
84155
- "notificationOutput.setTargetEnabled": {
84156
- capName: "notification-output",
84157
- capScope: "system",
84158
- addonId: null,
84159
- access: "create",
84160
- role: "admin"
84161
- },
84162
84337
  "notificationOutput.testTarget": {
84163
84338
  capName: "notification-output",
84164
84339
  capScope: "system",
@@ -84166,13 +84341,6 @@ Object.freeze({
84166
84341
  access: "create",
84167
84342
  role: "admin"
84168
84343
  },
84169
- "notificationOutput.upsertTarget": {
84170
- capName: "notification-output",
84171
- capScope: "system",
84172
- addonId: null,
84173
- access: "create",
84174
- role: "admin"
84175
- },
84176
84344
  "notificationRules.activateAlarmProfile": {
84177
84345
  capName: "notification-rules",
84178
84346
  capScope: "system",
@@ -84432,41 +84600,6 @@ Object.freeze({
84432
84600
  access: "view",
84433
84601
  role: "admin"
84434
84602
  },
84435
- "oidcConnections.connectionFormSchema": {
84436
- capName: "oidc-connections",
84437
- capScope: "system",
84438
- addonId: null,
84439
- access: "view",
84440
- role: "admin"
84441
- },
84442
- "oidcConnections.createConnection": {
84443
- capName: "oidc-connections",
84444
- capScope: "system",
84445
- addonId: null,
84446
- access: "create",
84447
- role: "admin"
84448
- },
84449
- "oidcConnections.deleteConnection": {
84450
- capName: "oidc-connections",
84451
- capScope: "system",
84452
- addonId: null,
84453
- access: "delete",
84454
- role: "admin"
84455
- },
84456
- "oidcConnections.listConnections": {
84457
- capName: "oidc-connections",
84458
- capScope: "system",
84459
- addonId: null,
84460
- access: "view",
84461
- role: "admin"
84462
- },
84463
- "oidcConnections.updateConnection": {
84464
- capName: "oidc-connections",
84465
- capScope: "system",
84466
- addonId: null,
84467
- access: "create",
84468
- role: "admin"
84469
- },
84470
84603
  "osd.getStatus": {
84471
84604
  capName: "osd",
84472
84605
  capScope: "device",
@@ -84649,13 +84782,6 @@ Object.freeze({
84649
84782
  access: "view",
84650
84783
  role: "viewer"
84651
84784
  },
84652
- "petFountain.resetDailyConsumption": {
84653
- capName: "pet-fountain",
84654
- capScope: "device",
84655
- addonId: null,
84656
- access: "delete",
84657
- role: "viewer"
84658
- },
84659
84785
  "petFountain.setPump": {
84660
84786
  capName: "pet-fountain",
84661
84787
  capScope: "device",
@@ -87505,13 +87631,6 @@ Object.freeze({
87505
87631
  access: "delete",
87506
87632
  role: "admin"
87507
87633
  },
87508
- "storage.deleteLocation": {
87509
- capName: "storage",
87510
- capScope: "system",
87511
- addonId: null,
87512
- access: "delete",
87513
- role: "admin"
87514
- },
87515
87634
  "storage.endDownload": {
87516
87635
  capName: "storage",
87517
87636
  capScope: "system",
@@ -87568,13 +87687,6 @@ Object.freeze({
87568
87687
  access: "view",
87569
87688
  role: "admin"
87570
87689
  },
87571
- "storage.listProviders": {
87572
- capName: "storage",
87573
- capScope: "system",
87574
- addonId: null,
87575
- access: "view",
87576
- role: "admin"
87577
- },
87578
87690
  "storage.read": {
87579
87691
  capName: "storage",
87580
87692
  capScope: "system",
@@ -87596,27 +87708,6 @@ Object.freeze({
87596
87708
  access: "view",
87597
87709
  role: "admin"
87598
87710
  },
87599
- "storage.testConfig": {
87600
- capName: "storage",
87601
- capScope: "system",
87602
- addonId: null,
87603
- access: "view",
87604
- role: "admin"
87605
- },
87606
- "storage.testLocation": {
87607
- capName: "storage",
87608
- capScope: "system",
87609
- addonId: null,
87610
- access: "view",
87611
- role: "admin"
87612
- },
87613
- "storage.upsertLocation": {
87614
- capName: "storage",
87615
- capScope: "system",
87616
- addonId: null,
87617
- access: "create",
87618
- role: "admin"
87619
- },
87620
87711
  "storage.write": {
87621
87712
  capName: "storage",
87622
87713
  capScope: "system",
@@ -88611,20 +88702,6 @@ Object.freeze({
88611
88702
  access: "create",
88612
88703
  role: "admin"
88613
88704
  },
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
88705
  "trainingProvider.describe": {
88629
88706
  capName: "training-provider",
88630
88707
  capScope: "system",
@@ -88695,13 +88772,6 @@ Object.freeze({
88695
88772
  access: "create",
88696
88773
  role: "admin"
88697
88774
  },
88698
- "trainingProvider.updateEntry": {
88699
- capName: "training-provider",
88700
- capScope: "system",
88701
- addonId: null,
88702
- access: "create",
88703
- role: "admin"
88704
- },
88705
88775
  "trainingProvider.uploadDataset": {
88706
88776
  capName: "training-provider",
88707
88777
  capScope: "system",
@@ -88709,13 +88779,6 @@ Object.freeze({
88709
88779
  access: "create",
88710
88780
  role: "admin"
88711
88781
  },
88712
- "trainingProvider.validateCredentials": {
88713
- capName: "training-provider",
88714
- capScope: "system",
88715
- addonId: null,
88716
- access: "create",
88717
- role: "admin"
88718
- },
88719
88782
  "turnProvider.getTurnServers": {
88720
88783
  capName: "turn-provider",
88721
88784
  capScope: "system",
@@ -91080,11 +91143,6 @@ Object.freeze({
91080
91143
  form: "single",
91081
91144
  optional: false
91082
91145
  }],
91083
- "petFountain.resetDailyConsumption": [{
91084
- name: "deviceId",
91085
- form: "single",
91086
- optional: false
91087
- }],
91088
91146
  "petFountain.setPump": [{
91089
91147
  name: "deviceId",
91090
91148
  form: "single",
@@ -95160,7 +95218,6 @@ object({
95160
95218
  delay: number().nonnegative().optional(),
95161
95219
  commands: record(string(), unknown())
95162
95220
  });
95163
- entryBody({ brokerId: string() });
95164
95221
  //#endregion
95165
95222
  //#region src/migrations/drop-keys.ts
95166
95223
  /** The canonical settings table: one row per key, id `<addonId>.<key>`. */
@@ -98412,7 +98469,7 @@ var LoadShedController = class LoadShedController {
98412
98469
  return state?.pausedAt !== null && state?.pausedAt !== void 0;
98413
98470
  }
98414
98471
  /**
98415
- * Mirrors the former inline block inside `updateGlobalSettings`: clear
98472
+ * Mirrors the former inline block inside the cluster-write follow-up: clear
98416
98473
  * load-shed pauses so suspended cameras get re-evaluated with the new
98417
98474
  * thresholds on the next dispatch cycle, then re-dispatch each of them.
98418
98475
  */
@@ -104255,9 +104312,12 @@ var DeviceConfigContributions = class {
104255
104312
  constructor(deps) {
104256
104313
  this.deps = deps;
104257
104314
  }
104258
- async updateGlobalSettings(patch) {
104315
+ /**
104316
+ * The side effects of a cluster settings write that already landed. Runs BEFORE
104317
+ * `applyRuntimeSettings`, so `topology.clusterRoles` still holds the previous roles here.
104318
+ */
104319
+ async afterClusterSettingsWritten() {
104259
104320
  const previousIngestNode = this.deps.topology.clusterRoles.ingestNode;
104260
- await this.deps.baseUpdateGlobalSettings(patch);
104261
104321
  const full = await this.deps.resolveGlobalStore();
104262
104322
  this.deps.setGlobalSettings({ ...full });
104263
104323
  this.deps.applyRuntimeSettings(full);
@@ -107889,7 +107949,7 @@ async function resetClusterRows(deps, isCustom) {
107889
107949
  if (read.kind === "present") stored.set(key, read.value);
107890
107950
  }
107891
107951
  const { patch, cleared } = clusterRowsToReset((key) => stored.get(key), isCustom);
107892
- if (cleared.length > 0) await deps.updateGlobalSettings({ ...patch });
107952
+ if (cleared.length > 0) await deps.patchClusterSettings({ ...patch });
107893
107953
  return cleared;
107894
107954
  }
107895
107955
  function logResetPin(logger, pin, trigger) {
@@ -112693,7 +112753,6 @@ async function buildOrchestratorControllers(deps) {
112693
112753
  deviceHasOnboardMotionCap: (deviceId) => deps.deviceHasOnboardMotionCap(deviceId),
112694
112754
  deviceHasActivitySignalCap: (deviceId) => deps.deviceHasActivitySignalCap(deviceId),
112695
112755
  deviceHasNativeObjectDetectionCap: (deviceId) => deps.deviceHasNativeObjectDetectionCap(deviceId),
112696
- baseUpdateGlobalSettings: (patch) => deps.baseUpdateGlobalSettings(patch),
112697
112756
  resolveGlobalStore: () => deps.resolveGlobalStore(),
112698
112757
  setGlobalSettings: (settings) => {
112699
112758
  globalSettings = settings;
@@ -115170,6 +115229,8 @@ function findStaleDevicePins(pins, nodes) {
115170
115229
  * because nobody discovers it is missing until they need it.
115171
115230
  */
115172
115231
  var customActions = pipelineOrchestratorActions;
115232
+ /** The cluster form is read and written key by key; the declared schema refuses any other key. */
115233
+ var CLUSTER_VALUES_SCHEMA = record(string(), unknown());
115173
115234
  var PipelineOrchestratorAddon = class PipelineOrchestratorAddon extends BaseAddon {
115174
115235
  /** This node's Moleculer nodeId (from this.ctx.kernel.localNodeId). */
115175
115236
  localNodeId = "hub";
@@ -115311,7 +115372,7 @@ var PipelineOrchestratorAddon = class PipelineOrchestratorAddon extends BaseAddo
115311
115372
  /**
115312
115373
  * Device-details aggregator contributions (`getDeviceSettingsContribution`/
115313
115374
  * `getDeviceLiveContribution`/`applyDeviceSettingsPatch`/
115314
- * `updateGlobalSettings`/`writeDeviceOrchestratorSettings`/
115375
+ * `afterClusterSettingsWritten`/`writeDeviceOrchestratorSettings`/
115315
115376
  * `splitPipelinePatch`/`applyPipelinePatch`) — see
115316
115377
  * `device-config-contributions.ts` (S11 Task 1 extraction, C13 remnant).
115317
115378
  * Owns nothing durable (reads through injected closures); constructed in
@@ -115319,6 +115380,8 @@ var PipelineOrchestratorAddon = class PipelineOrchestratorAddon extends BaseAddo
115319
115380
  * exist. Stateless — no `dispose()`, just nulled at the end of `onShutdown`.
115320
115381
  */
115321
115382
  deviceConfig = null;
115383
+ /** True while the removed-model pin sweep runs, so its own cluster writes never re-enter it. */
115384
+ pinResetRunning = false;
115322
115385
  /**
115323
115386
  * Read-only test-seam compat accessor — mirrors the pre-S9 `protected
115324
115387
  * remoteHealthAttempts` field so `remote-health.spec.ts`'s subclass
@@ -115471,7 +115534,6 @@ var PipelineOrchestratorAddon = class PipelineOrchestratorAddon extends BaseAddo
115471
115534
  isIdleSessionCamera: (deviceId) => this.isIdleSessionCamera(deviceId),
115472
115535
  deviceSettingsSchema: () => this.deviceSettingsSchema(),
115473
115536
  resolveGlobalStore: () => this.resolveGlobalStore(),
115474
- baseUpdateGlobalSettings: (patch) => super.updateGlobalSettings(patch),
115475
115537
  watchCapability: (capNames, handlers) => this.watchCapability(capNames, handlers),
115476
115538
  state: this.state.bind(this),
115477
115539
  rebalance: (opts) => this.rebalance(opts),
@@ -117245,7 +117307,8 @@ var PipelineOrchestratorAddon = class PipelineOrchestratorAddon extends BaseAddo
117245
117307
  const auto = this.effectiveShares().current();
117246
117308
  if (auto !== null) await this.setLoadBalancingShares(auto.weights);
117247
117309
  }
117248
- await this.updateGlobalSettings({ [SHARE_SOURCE_SETTING_KEY]: input.source });
117310
+ await this.state(SHARE_SOURCE_SETTING_KEY, ShareSourceSchema, DEFAULT_SHARE_SOURCE).set(input.source);
117311
+ await this.afterClusterWrite([SHARE_SOURCE_SETTING_KEY]);
117249
117312
  this.ctx.logger.info("load balancing: share source changed", { meta: {
117250
117313
  from: previous,
117251
117314
  to: input.source
@@ -117422,9 +117485,18 @@ var PipelineOrchestratorAddon = class PipelineOrchestratorAddon extends BaseAddo
117422
117485
  deviceSettingsSchema() {
117423
117486
  return this.schema({ sections: buildDeviceSettingsSections({ runnerNodeIds: this.topology.collectRunnerNodeIds() }) });
117424
117487
  }
117425
- async updateGlobalSettings(patch) {
117426
- await this.deviceConfig.updateGlobalSettings(patch);
117427
- if (CLUSTER_MODEL_SCOPED_STEPS.some((step) => typeof patch[clusterModelSettingKey(step.stepId)] === "string")) await this.resetRemovedModelPins("cluster-row-write");
117488
+ /** The cluster form's stored values, written under their bare keys. */
117489
+ clusterStore() {
117490
+ return this.clusterSettings(PIPELINE_ORCHESTRATOR_ID, CLUSTER_VALUES_SCHEMA);
117491
+ }
117492
+ async onScopedSettingsChanged(scope, cap, keys) {
117493
+ if (scope !== "cluster" || cap !== "pipeline-orchestrator") return;
117494
+ await this.afterClusterWrite(keys);
117495
+ }
117496
+ async afterClusterWrite(keys) {
117497
+ if (this.deviceConfig === null) return;
117498
+ await this.deviceConfig.afterClusterSettingsWritten();
117499
+ if (CLUSTER_MODEL_SCOPED_STEPS.some((step) => keys.includes(clusterModelSettingKey(step.stepId))) && !this.pinResetRunning) await this.resetRemovedModelPins("cluster-row-write");
117428
117500
  }
117429
117501
  /**
117430
117502
  * The ONE stored-pin reset (D725): drop every pin to a model deleted from
@@ -117448,6 +117520,14 @@ var PipelineOrchestratorAddon = class PipelineOrchestratorAddon extends BaseAddo
117448
117520
  });
117449
117521
  }
117450
117522
  async resetRemovedModelPins(trigger) {
117523
+ this.pinResetRunning = true;
117524
+ try {
117525
+ return await this.runRemovedModelPinReset(trigger);
117526
+ } finally {
117527
+ this.pinResetRunning = false;
117528
+ }
117529
+ }
117530
+ async runRemovedModelPinReset(trigger) {
117451
117531
  return resetRemovedModelPins({
117452
117532
  listCustomModels: async () => {
117453
117533
  const api = this.ctx.api;
@@ -117456,7 +117536,7 @@ var PipelineOrchestratorAddon = class PipelineOrchestratorAddon extends BaseAddo
117456
117536
  },
117457
117537
  resetStoredPins: (isCustom) => this.settingsStore.resetRemovedModelPins(isCustom),
117458
117538
  readStoredGlobalKey: (key) => this.readStoredGlobalKey(key),
117459
- updateGlobalSettings: (patch) => this.deviceConfig.updateGlobalSettings(patch),
117539
+ patchClusterSettings: (patch) => this.clusterStore().patch(patch),
117460
117540
  redispatchNode: (nodeId) => this.placement.redispatchCamerasOnAgent(nodeId),
117461
117541
  logger: this.ctx.logger
117462
117542
  }, trigger);