@camstack/addon-provider-homematic 1.2.184 → 1.2.186

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/addon.mjs CHANGED
@@ -5991,7 +5991,7 @@ var ZodIssueCode = {
5991
5991
  var ZodFirstPartyTypeKind;
5992
5992
  ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {});
5993
5993
  //#endregion
5994
- //#region ../types/dist/sleep-CmjWurK5.mjs
5994
+ //#region ../types/dist/sleep-D7ZKm4nb.mjs
5995
5995
  /**
5996
5996
  * The audio chunk plane's byte format, and the ONE expansion from a coded
5997
5997
  * window to float samples (D455).
@@ -6700,10 +6700,33 @@ function integrationRowsApiOver(api) {
6700
6700
  };
6701
6701
  }
6702
6702
  var PREFIX = "records/";
6703
+ /**
6704
+ * Cross-realm brand. An addon bundles its own copy of this module (D15) while
6705
+ * `ctx.records` is the HOST's door, so an error thrown by the host is an
6706
+ * instance of the host's classes, not of the addon's. The brand plus the code
6707
+ * make `instanceof` answer by identity of the failure, not of the copy.
6708
+ */
6709
+ var RECORDS_ERROR_BRAND = Symbol.for("camstack.records-error");
6710
+ function carriesBrand(value) {
6711
+ return typeof value === "object" && value !== null && Reflect.get(value, RECORDS_ERROR_BRAND) === true;
6712
+ }
6703
6713
  /** The base of every records failure. `detail` is the human part of the message. */
6704
6714
  var RecordsError = class extends Error {
6715
+ /** The code a subclass stands for; the base stands for every code. */
6716
+ static code = void 0;
6717
+ /**
6718
+ * `instanceof` across copies of this module: any branded error is a
6719
+ * `RecordsError`, and is an instance of a subclass only when its code is the
6720
+ * subclass's code. Same-copy answers are unchanged.
6721
+ */
6722
+ static [Symbol.hasInstance](value) {
6723
+ if (Function.prototype[Symbol.hasInstance].call(this, value)) return true;
6724
+ if (!carriesBrand(value)) return false;
6725
+ return this.code === void 0 || value.code === this.code;
6726
+ }
6705
6727
  code;
6706
6728
  detail;
6729
+ [RECORDS_ERROR_BRAND] = true;
6707
6730
  constructor(code, detail) {
6708
6731
  super(`${PREFIX}${code}: ${detail}`);
6709
6732
  this.name = "RecordsError";
@@ -6712,29 +6735,33 @@ var RecordsError = class extends Error {
6712
6735
  }
6713
6736
  };
6714
6737
  /** A write guarded by `ifRev` found another revision (or an existing row for `ifRev: 0`). */
6715
- var RevConflictError = class extends RecordsError {
6738
+ var RevConflictError = class RevConflictError extends RecordsError {
6739
+ static code = "rev-conflict";
6716
6740
  constructor(detail) {
6717
- super("rev-conflict", detail);
6741
+ super(RevConflictError.code, detail);
6718
6742
  this.name = "RevConflictError";
6719
6743
  }
6720
6744
  };
6721
6745
  /** The keychain could not store or serve a value: explicit, never an empty string. */
6722
- var RecordSecretUnavailableError = class extends RecordsError {
6746
+ var RecordSecretUnavailableError = class RecordSecretUnavailableError extends RecordsError {
6747
+ static code = "secret-unavailable";
6723
6748
  constructor(detail) {
6724
- super("secret-unavailable", detail);
6749
+ super(RecordSecretUnavailableError.code, detail);
6725
6750
  this.name = "RecordSecretUnavailableError";
6726
6751
  }
6727
6752
  };
6728
- var InvalidRecordError = class extends RecordsError {
6753
+ var InvalidRecordError = class InvalidRecordError extends RecordsError {
6754
+ static code = "invalid-record";
6729
6755
  constructor(detail) {
6730
- super("invalid-record", detail);
6756
+ super(InvalidRecordError.code, detail);
6731
6757
  this.name = "InvalidRecordError";
6732
6758
  }
6733
6759
  };
6734
6760
  /** A kind declaration the engine refuses (non-additive change, bad shape, wrong file). */
6735
- var DeclarationRefusedError = class extends RecordsError {
6761
+ var DeclarationRefusedError = class DeclarationRefusedError extends RecordsError {
6762
+ static code = "declaration-refused";
6736
6763
  constructor(detail) {
6737
- super("declaration-refused", detail);
6764
+ super(DeclarationRefusedError.code, detail);
6738
6765
  this.name = "DeclarationRefusedError";
6739
6766
  }
6740
6767
  };
@@ -9538,286 +9565,6 @@ function normalizeAddonInitResult(result) {
9538
9565
  if (Array.isArray(result)) return { providers: result };
9539
9566
  return result;
9540
9567
  }
9541
- /**
9542
- * The share-view scope kinds a share-link token can carry. The hub mints
9543
- * and validates them (`ShareViewGrantSchema` builds its
9544
- * enum from this list); a data plane names the kinds it ACCEPTS in `share`.
9545
- */
9546
- var SHARE_VIEW_KINDS = ["grid-view", "events-view"];
9547
- /** The wire shape of {@link PeerBytesTicket} — see the type for what it is. */
9548
- var PeerBytesTicketSchema = object({
9549
- /** `http://127.0.0.1:<port>/<token>`. One `GET` takes it. */
9550
- url: string().min(1),
9551
- /**
9552
- * The HOST node this URL means something on — the hub or a named agent,
9553
- * never a runner. {@link AddonPeerBytes.open} compares it to its own and
9554
- * refuses `cross-node` by name when they differ, without dialling.
9555
- */
9556
- hostNodeId: string().min(1),
9557
- expiresAtMs: number().int().nonnegative(),
9558
- /**
9559
- * What the producer DECLARED the body to be, when it knows — `null` when it
9560
- * does not. Never `0` for unknown (D393): a consumer sizing a bound off this
9561
- * must be able to tell "the producer did not say" from "the body is empty".
9562
- */
9563
- declaredBytes: number().int().nonnegative().nullable()
9564
- });
9565
- function defOf(schema) {
9566
- const zodBag = Reflect.get(schema, "_zod");
9567
- if (typeof zodBag !== "object" || zodBag === null) return {};
9568
- const def = Reflect.get(zodBag, "def");
9569
- if (typeof def !== "object" || def === null) return {};
9570
- return def;
9571
- }
9572
- function declaredHere(schema) {
9573
- return globalRegistry.get(schema)?.secret === true;
9574
- }
9575
- /** Wrapper kinds whose `innerType` is the field itself. */
9576
- var WRAPPERS = new Set([
9577
- "optional",
9578
- "nullable",
9579
- "default",
9580
- "prefault",
9581
- "catch",
9582
- "readonly",
9583
- "nonoptional"
9584
- ]);
9585
- /**
9586
- * The schema layers that make up ONE field: the schema itself and every
9587
- * wrapper below it (optional / default / nullable / readonly / catch), plus
9588
- * both sides of a pipe (`z.preprocess` puts the real schema on `out`,
9589
- * `.transform` on `in`).
9590
- */
9591
- function layersOf(schema) {
9592
- const out = [];
9593
- const queue = [schema];
9594
- while (queue.length > 0) {
9595
- const s = queue.shift();
9596
- if (!s || out.includes(s)) continue;
9597
- out.push(s);
9598
- const def = defOf(s);
9599
- if (def.type !== void 0 && WRAPPERS.has(def.type) && def.innerType) queue.push(def.innerType);
9600
- if (def.type === "pipe") {
9601
- if (def.in) queue.push(def.in);
9602
- if (def.out) queue.push(def.out);
9603
- }
9604
- }
9605
- return out;
9606
- }
9607
- /** True when any layer of this field declares `.meta({ secret: true })`. */
9608
- function isZodSecret(schema) {
9609
- return layersOf(schema).some(declaredHere);
9610
- }
9611
- /**
9612
- * Every declared secret path in a config schema: dotted keys, `[]` for "each
9613
- * element of this array" (`connection.password`, `rows[].token`), `{}` for "each value of this
9614
- * map" (`applianceSecrets{}`). A declared
9615
- * object or array is reported as one path and not descended into — everything
9616
- * under it is secret.
9617
- */
9618
- function collectZodSecretPaths(schema, prefix = "") {
9619
- if (isZodSecret(schema)) return prefix.length > 0 ? [prefix] : [];
9620
- const paths = [];
9621
- for (const layer of layersOf(schema)) {
9622
- const def = defOf(layer);
9623
- if (def.type === "object" && def.shape) for (const [key, child] of Object.entries(def.shape)) paths.push(...collectZodSecretPaths(child, prefix ? `${prefix}.${key}` : key));
9624
- else if (def.type === "array" && def.element) paths.push(...collectZodSecretPaths(def.element, `${prefix}[]`));
9625
- else if (def.type === "record" && def.valueType) paths.push(...collectZodSecretPaths(def.valueType, `${prefix}{}`));
9626
- else if (def.type === "union" && def.options) for (const option of def.options) paths.push(...collectZodSecretPaths(option, prefix));
9627
- else if (def.type === "intersection") {
9628
- if (def.left) paths.push(...collectZodSecretPaths(def.left, prefix));
9629
- if (def.right) paths.push(...collectZodSecretPaths(def.right, prefix));
9630
- }
9631
- }
9632
- return [...new Set(paths)];
9633
- }
9634
- /**
9635
- * Record kinds (D881): the declaration an addon makes of one kind of fact, the
9636
- * Zod row schema that describes it, and the helper that turns the two into the
9637
- * JSON the engine stores.
9638
- *
9639
- * A kind is declared ONCE, next to the code that owns it, and the engine's
9640
- * reconciler creates its indexes - nothing creates DDL at runtime from a write.
9641
- * Everything the generic machinery needs (secret fields, the entry descriptor)
9642
- * is DERIVED from the Zod schema: `.meta({ secret: true })` marks a credential,
9643
- * never a field name (D879).
9644
- */
9645
- /** A JSON field path: `trackId`, `auth.accessToken`. Charset-restricted: it is rendered into DDL. */
9646
- var RecordFieldPathSchema = string().regex(/^[A-Za-z_][A-Za-z0-9_]{0,63}(\.[A-Za-z_][A-Za-z0-9_]{0,63}){0,3}$/);
9647
- var RecordIndexSchema = object({
9648
- name: string().regex(/^[a-z][a-z0-9_]{0,31}$/),
9649
- fields: array(RecordFieldPathSchema).min(1).max(4),
9650
- unique: boolean().optional()
9651
- }).strict();
9652
- var RecordRetentionSchema = union([
9653
- object({
9654
- ttlMs: number().int().positive(),
9655
- from: _enum(["at", "write"])
9656
- }).strict(),
9657
- object({
9658
- maxRows: number().int().positive().optional(),
9659
- maxRowsPerDevice: number().int().positive().optional()
9660
- }).strict().refine((r) => r.maxRows !== void 0 || r.maxRowsPerDevice !== void 0, { message: "name maxRows, maxRowsPerDevice or both" }),
9661
- object({
9662
- owner: string().min(1),
9663
- reason: string().min(1)
9664
- }).strict(),
9665
- object({ none: string().min(1) }).strict()
9666
- ]);
9667
- /** The descriptor a generic entries UI reads (D881 "generic entries"). */
9668
- var EntryDescriptorSchema = object({
9669
- title: string().min(1),
9670
- /** The record body field shown as the entry's name. */
9671
- nameField: string().min(1),
9672
- /** JSON Schema of the entry body; `secret: true` marks a password field. */
9673
- fields: record(string(), unknown())
9674
- }).strict();
9675
- /** What crosses the wire from an addon: JSON only, no Zod. An unknown key is refused. */
9676
- var RecordKindDeclarationSchema = object({
9677
- database: _enum(RECORD_DATABASES).default("settings"),
9678
- class: _enum(RECORD_CLASSES),
9679
- writeTrigger: string().min(1),
9680
- device: _enum([
9681
- "required",
9682
- "optional",
9683
- "none"
9684
- ]).default("none"),
9685
- at: _enum(["required", "none"]).default("none"),
9686
- indexes: array(RecordIndexSchema).max(8).default([]),
9687
- retention: RecordRetentionSchema,
9688
- deviceRemoval: _enum(["delete", "none"]).default("none"),
9689
- maxDataBytes: number().int().positive().max(RECORD_MAX_DATA_BYTES).default(RECORD_DEFAULT_MAX_DATA_BYTES),
9690
- /** Derived from the Zod schema; never written by hand. */
9691
- secretPaths: array(string().min(1)).default([]),
9692
- /** The id key of each array that carries a secret (`{ headers: 'name' }`). */
9693
- secretArrayKeys: record(string(), string()).default({}),
9694
- /** Kinds that must agree through `transact` sit in one file under one family name. */
9695
- transactFamily: string().min(1).optional(),
9696
- entry: EntryDescriptorSchema.optional()
9697
- }).strict();
9698
- /** The kind names: lower-case, dash separated, short enough for an index name. */
9699
- var RecordKindNameSchema = string().regex(/^[a-z][a-z0-9-]{0,47}$/);
9700
- /** Cross-field rules a declaration must satisfy. Throws {@link DeclarationRefusedError}. */
9701
- function assertValidDeclaration(name, decl) {
9702
- const refuse = (why) => {
9703
- throw new DeclarationRefusedError(`kind "${name}": ${why}`);
9704
- };
9705
- if (!RecordKindNameSchema.safeParse(name).success) refuse("the name must be lower-case-dashed");
9706
- const seen = /* @__PURE__ */ new Set();
9707
- for (const index of decl.indexes) {
9708
- if (seen.has(index.name)) refuse(`index name "${index.name}" is declared twice`);
9709
- seen.add(index.name);
9710
- }
9711
- const { retention } = decl;
9712
- const hasSecrets = decl.secretPaths.length > 0;
9713
- if ("ttlMs" in retention) {
9714
- if (retention.from === "at" && decl.at !== "required") refuse("a ttl from \"at\" needs at: \"required\"");
9715
- if (hasSecrets) refuse("a kind with secret fields cannot use engine TTL (its keychain values would be orphaned)");
9716
- }
9717
- if ("maxRows" in retention || "maxRowsPerDevice" in retention) {
9718
- if (retention.maxRowsPerDevice !== void 0 && decl.device !== "required") refuse("maxRowsPerDevice needs device: \"required\"");
9719
- if (decl.at !== "required") refuse("a row bound trims the oldest \"at\": it needs at: \"required\"");
9720
- if (hasSecrets) refuse("a kind with secret fields cannot use an engine row bound");
9721
- const bound = Math.max(retention.maxRows ?? 0, retention.maxRowsPerDevice ?? 0);
9722
- if (decl.database === "settings" && bound > 5e4) refuse(`a row bound above ${RECORD_SETTINGS_MAX_ROWS} belongs in database: "events" (a big delete on the settings thread stalls every configuration read)`);
9723
- }
9724
- if (decl.deviceRemoval === "delete" && decl.device === "none") refuse("deviceRemoval: \"delete\" needs a device: \"required\" or \"optional\"");
9725
- for (const path of decl.secretPaths) for (const prefix of secretArrayPrefixes(path)) if (decl.secretArrayKeys[prefix] === void 0) refuse(`secret path "${path}" crosses the array "${prefix}": declare its id key in secretArrayKeys`);
9726
- }
9727
- function bodyFieldsOf(schema) {
9728
- return { ...toJSONSchema(schema, {
9729
- unrepresentable: "any",
9730
- io: "input"
9731
- }) };
9732
- }
9733
- function isRecordLike(value) {
9734
- return typeof value === "object" && value !== null && !Array.isArray(value);
9735
- }
9736
- /** Does every branch of the body schema carry `field`? (A discriminated union has several.) */
9737
- function hasNameField(json, field) {
9738
- const branches = json["oneOf"] ?? json["anyOf"];
9739
- if (Array.isArray(branches)) return branches.length > 0 && branches.every((b) => isRecordLike(b) && hasNameField(b, field));
9740
- const properties = json["properties"];
9741
- return isRecordLike(properties) && Object.prototype.hasOwnProperty.call(properties, field);
9742
- }
9743
- /**
9744
- * Declare the kinds of a package. The keys are the kind names. The result is
9745
- * what `ctx.records.declare` sends to the engine and what `ctx.records.kind`
9746
- * types its handle from.
9747
- */
9748
- function defineRecordKinds(specs) {
9749
- const out = {};
9750
- for (const [name, spec] of Object.entries(specs)) {
9751
- const secretPaths = collectZodSecretPaths(spec.schema);
9752
- const nameField = spec.entry?.nameField ?? "name";
9753
- const fields = bodyFieldsOf(spec.schema);
9754
- if (spec.entry !== void 0 && !hasNameField(fields, nameField)) throw new DeclarationRefusedError(`kind "${name}": an entry kind's schema needs a "${nameField}" field`);
9755
- const parsed = RecordKindDeclarationSchema.parse({
9756
- database: spec.database,
9757
- class: spec.class,
9758
- writeTrigger: spec.writeTrigger,
9759
- device: spec.device,
9760
- at: spec.at,
9761
- indexes: spec.indexes === void 0 ? void 0 : [...spec.indexes],
9762
- retention: spec.retention,
9763
- deviceRemoval: spec.deviceRemoval,
9764
- maxDataBytes: spec.maxDataBytes,
9765
- secretPaths: [...new Set([...secretPaths, ...spec.retiredSecretPaths ?? []])],
9766
- secretArrayKeys: spec.secretArrayKeys === void 0 ? void 0 : { ...spec.secretArrayKeys },
9767
- transactFamily: spec.transactFamily,
9768
- entry: spec.entry === void 0 ? void 0 : {
9769
- title: spec.entry.title,
9770
- nameField,
9771
- fields
9772
- }
9773
- });
9774
- assertValidDeclaration(name, parsed);
9775
- out[name] = {
9776
- name,
9777
- schema: spec.schema,
9778
- declaration: parsed
9779
- };
9780
- }
9781
- return out;
9782
- }
9783
- /**
9784
- * Entry kinds (D881): every list of user-created entries (notification
9785
- * targets, brokers, LLM profiles) is ONE record kind with an id, a name and a
9786
- * kind-specific body, and the admin UI lists/adds/edits/deletes all of them
9787
- * through the `record-entries` capability with password fields derived from
9788
- * the schema (`.meta({ secret: true })`).
9789
- */
9790
- /** The body of a plain entry: a name and the fields the kind adds. */
9791
- function entryBody(shape) {
9792
- return object({
9793
- name: string().min(1),
9794
- enabled: boolean().optional(),
9795
- ...shape
9796
- });
9797
- }
9798
- /**
9799
- * Declare one entry kind. An entry is configuration: never trimmed by the
9800
- * engine, never aged, belonging to no device.
9801
- */
9802
- function defineEntryKind(name, spec) {
9803
- const defined = defineRecordKinds({ [name]: {
9804
- schema: spec.schema,
9805
- class: "config",
9806
- writeTrigger: spec.writeTrigger ?? "an operator adds or edits an entry in the entries UI",
9807
- retention: { none: "an entry goes only when the operator deletes it" },
9808
- ...spec.maxDataBytes === void 0 ? {} : { maxDataBytes: spec.maxDataBytes },
9809
- ...spec.database === void 0 ? {} : { database: spec.database },
9810
- ...spec.indexes === void 0 ? {} : { indexes: spec.indexes },
9811
- ...spec.secretArrayKeys === void 0 ? {} : { secretArrayKeys: spec.secretArrayKeys },
9812
- ...spec.retiredSecretPaths === void 0 ? {} : { retiredSecretPaths: spec.retiredSecretPaths },
9813
- entry: {
9814
- title: spec.title,
9815
- ...spec.nameField === void 0 ? {} : { nameField: spec.nameField }
9816
- }
9817
- } })[name];
9818
- if (defined === void 0) throw new DeclarationRefusedError(`entry kind "${name}" was not built`);
9819
- return defined;
9820
- }
9821
9568
  object({
9822
9569
  field: string().min(1),
9823
9570
  on: literal("advance")
@@ -9910,6 +9657,286 @@ function optionalMethod(input, output, options) {
9910
9657
  function event(data) {
9911
9658
  return { data };
9912
9659
  }
9660
+ function defOf(schema) {
9661
+ const zodBag = Reflect.get(schema, "_zod");
9662
+ if (typeof zodBag !== "object" || zodBag === null) return {};
9663
+ const def = Reflect.get(zodBag, "def");
9664
+ if (typeof def !== "object" || def === null) return {};
9665
+ return def;
9666
+ }
9667
+ function declaredHere(schema) {
9668
+ return globalRegistry.get(schema)?.secret === true;
9669
+ }
9670
+ /** Wrapper kinds whose `innerType` is the field itself. */
9671
+ var WRAPPERS = new Set([
9672
+ "optional",
9673
+ "nullable",
9674
+ "default",
9675
+ "prefault",
9676
+ "catch",
9677
+ "readonly",
9678
+ "nonoptional"
9679
+ ]);
9680
+ /**
9681
+ * The schema layers that make up ONE field: the schema itself and every
9682
+ * wrapper below it (optional / default / nullable / readonly / catch), plus
9683
+ * both sides of a pipe (`z.preprocess` puts the real schema on `out`,
9684
+ * `.transform` on `in`).
9685
+ */
9686
+ function layersOf(schema) {
9687
+ const out = [];
9688
+ const queue = [schema];
9689
+ while (queue.length > 0) {
9690
+ const s = queue.shift();
9691
+ if (!s || out.includes(s)) continue;
9692
+ out.push(s);
9693
+ const def = defOf(s);
9694
+ if (def.type !== void 0 && WRAPPERS.has(def.type) && def.innerType) queue.push(def.innerType);
9695
+ if (def.type === "pipe") {
9696
+ if (def.in) queue.push(def.in);
9697
+ if (def.out) queue.push(def.out);
9698
+ }
9699
+ }
9700
+ return out;
9701
+ }
9702
+ /** True when any layer of this field declares `.meta({ secret: true })`. */
9703
+ function isZodSecret(schema) {
9704
+ return layersOf(schema).some(declaredHere);
9705
+ }
9706
+ /**
9707
+ * Every declared secret path in a config schema: dotted keys, `[]` for "each
9708
+ * element of this array" (`connection.password`, `rows[].token`), `{}` for "each value of this
9709
+ * map" (`applianceSecrets{}`). A declared
9710
+ * object or array is reported as one path and not descended into — everything
9711
+ * under it is secret.
9712
+ */
9713
+ function collectZodSecretPaths(schema, prefix = "") {
9714
+ if (isZodSecret(schema)) return prefix.length > 0 ? [prefix] : [];
9715
+ const paths = [];
9716
+ for (const layer of layersOf(schema)) {
9717
+ const def = defOf(layer);
9718
+ if (def.type === "object" && def.shape) for (const [key, child] of Object.entries(def.shape)) paths.push(...collectZodSecretPaths(child, prefix ? `${prefix}.${key}` : key));
9719
+ else if (def.type === "array" && def.element) paths.push(...collectZodSecretPaths(def.element, `${prefix}[]`));
9720
+ else if (def.type === "record" && def.valueType) paths.push(...collectZodSecretPaths(def.valueType, `${prefix}{}`));
9721
+ else if (def.type === "union" && def.options) for (const option of def.options) paths.push(...collectZodSecretPaths(option, prefix));
9722
+ else if (def.type === "intersection") {
9723
+ if (def.left) paths.push(...collectZodSecretPaths(def.left, prefix));
9724
+ if (def.right) paths.push(...collectZodSecretPaths(def.right, prefix));
9725
+ }
9726
+ }
9727
+ return [...new Set(paths)];
9728
+ }
9729
+ /**
9730
+ * Record kinds (D881): the declaration an addon makes of one kind of fact, the
9731
+ * Zod row schema that describes it, and the helper that turns the two into the
9732
+ * JSON the engine stores.
9733
+ *
9734
+ * A kind is declared ONCE, next to the code that owns it, and the engine's
9735
+ * reconciler creates its indexes - nothing creates DDL at runtime from a write.
9736
+ * Everything the generic machinery needs (secret fields, the entry descriptor)
9737
+ * is DERIVED from the Zod schema: `.meta({ secret: true })` marks a credential,
9738
+ * never a field name (D879).
9739
+ */
9740
+ /** A JSON field path: `trackId`, `auth.accessToken`. Charset-restricted: it is rendered into DDL. */
9741
+ var RecordFieldPathSchema = string().regex(/^[A-Za-z_][A-Za-z0-9_]{0,63}(\.[A-Za-z_][A-Za-z0-9_]{0,63}){0,3}$/);
9742
+ var RecordIndexSchema = object({
9743
+ name: string().regex(/^[a-z][a-z0-9_]{0,31}$/),
9744
+ fields: array(RecordFieldPathSchema).min(1).max(4),
9745
+ unique: boolean().optional()
9746
+ }).strict();
9747
+ var RecordRetentionSchema = union([
9748
+ object({
9749
+ ttlMs: number().int().positive(),
9750
+ from: _enum(["at", "write"])
9751
+ }).strict(),
9752
+ object({
9753
+ maxRows: number().int().positive().optional(),
9754
+ maxRowsPerDevice: number().int().positive().optional()
9755
+ }).strict().refine((r) => r.maxRows !== void 0 || r.maxRowsPerDevice !== void 0, { message: "name maxRows, maxRowsPerDevice or both" }),
9756
+ object({
9757
+ owner: string().min(1),
9758
+ reason: string().min(1)
9759
+ }).strict(),
9760
+ object({ none: string().min(1) }).strict()
9761
+ ]);
9762
+ /** The descriptor a generic entries UI reads (D881 "generic entries"). */
9763
+ var EntryDescriptorSchema = object({
9764
+ title: string().min(1),
9765
+ /** The record body field shown as the entry's name. */
9766
+ nameField: string().min(1),
9767
+ /** JSON Schema of the entry body; `secret: true` marks a password field. */
9768
+ fields: record(string(), unknown())
9769
+ }).strict();
9770
+ /** What crosses the wire from an addon: JSON only, no Zod. An unknown key is refused. */
9771
+ var RecordKindDeclarationSchema = object({
9772
+ database: _enum(RECORD_DATABASES).default("settings"),
9773
+ class: _enum(RECORD_CLASSES),
9774
+ writeTrigger: string().min(1),
9775
+ device: _enum([
9776
+ "required",
9777
+ "optional",
9778
+ "none"
9779
+ ]).default("none"),
9780
+ at: _enum(["required", "none"]).default("none"),
9781
+ indexes: array(RecordIndexSchema).max(8).default([]),
9782
+ retention: RecordRetentionSchema,
9783
+ deviceRemoval: _enum(["delete", "none"]).default("none"),
9784
+ maxDataBytes: number().int().positive().max(RECORD_MAX_DATA_BYTES).default(RECORD_DEFAULT_MAX_DATA_BYTES),
9785
+ /** Derived from the Zod schema; never written by hand. */
9786
+ secretPaths: array(string().min(1)).default([]),
9787
+ /** The id key of each array that carries a secret (`{ headers: 'name' }`). */
9788
+ secretArrayKeys: record(string(), string()).default({}),
9789
+ /** Kinds that must agree through `transact` sit in one file under one family name. */
9790
+ transactFamily: string().min(1).optional(),
9791
+ entry: EntryDescriptorSchema.optional()
9792
+ }).strict();
9793
+ /** The kind names: lower-case, dash separated, short enough for an index name. */
9794
+ var RecordKindNameSchema = string().regex(/^[a-z][a-z0-9-]{0,47}$/);
9795
+ /** Cross-field rules a declaration must satisfy. Throws {@link DeclarationRefusedError}. */
9796
+ function assertValidDeclaration(name, decl) {
9797
+ const refuse = (why) => {
9798
+ throw new DeclarationRefusedError(`kind "${name}": ${why}`);
9799
+ };
9800
+ if (!RecordKindNameSchema.safeParse(name).success) refuse("the name must be lower-case-dashed");
9801
+ const seen = /* @__PURE__ */ new Set();
9802
+ for (const index of decl.indexes) {
9803
+ if (seen.has(index.name)) refuse(`index name "${index.name}" is declared twice`);
9804
+ seen.add(index.name);
9805
+ }
9806
+ const { retention } = decl;
9807
+ const hasSecrets = decl.secretPaths.length > 0;
9808
+ if ("ttlMs" in retention) {
9809
+ if (retention.from === "at" && decl.at !== "required") refuse("a ttl from \"at\" needs at: \"required\"");
9810
+ if (hasSecrets) refuse("a kind with secret fields cannot use engine TTL (its keychain values would be orphaned)");
9811
+ }
9812
+ if ("maxRows" in retention || "maxRowsPerDevice" in retention) {
9813
+ if (retention.maxRowsPerDevice !== void 0 && decl.device !== "required") refuse("maxRowsPerDevice needs device: \"required\"");
9814
+ if (decl.at !== "required") refuse("a row bound trims the oldest \"at\": it needs at: \"required\"");
9815
+ if (hasSecrets) refuse("a kind with secret fields cannot use an engine row bound");
9816
+ const bound = Math.max(retention.maxRows ?? 0, retention.maxRowsPerDevice ?? 0);
9817
+ if (decl.database === "settings" && bound > 5e4) refuse(`a row bound above ${RECORD_SETTINGS_MAX_ROWS} belongs in database: "events" (a big delete on the settings thread stalls every configuration read)`);
9818
+ }
9819
+ if (decl.deviceRemoval === "delete" && decl.device === "none") refuse("deviceRemoval: \"delete\" needs a device: \"required\" or \"optional\"");
9820
+ for (const path of decl.secretPaths) for (const prefix of secretArrayPrefixes(path)) if (decl.secretArrayKeys[prefix] === void 0) refuse(`secret path "${path}" crosses the array "${prefix}": declare its id key in secretArrayKeys`);
9821
+ }
9822
+ function bodyFieldsOf(schema) {
9823
+ return { ...toJSONSchema(schema, {
9824
+ unrepresentable: "any",
9825
+ io: "input"
9826
+ }) };
9827
+ }
9828
+ function isRecordLike(value) {
9829
+ return typeof value === "object" && value !== null && !Array.isArray(value);
9830
+ }
9831
+ /** Does every branch of the body schema carry `field`? (A discriminated union has several.) */
9832
+ function hasNameField(json, field) {
9833
+ const branches = json["oneOf"] ?? json["anyOf"];
9834
+ if (Array.isArray(branches)) return branches.length > 0 && branches.every((b) => isRecordLike(b) && hasNameField(b, field));
9835
+ const properties = json["properties"];
9836
+ return isRecordLike(properties) && Object.prototype.hasOwnProperty.call(properties, field);
9837
+ }
9838
+ /**
9839
+ * Declare the kinds of a package. The keys are the kind names. The result is
9840
+ * what `ctx.records.declare` sends to the engine and what `ctx.records.kind`
9841
+ * types its handle from.
9842
+ */
9843
+ function defineRecordKinds(specs) {
9844
+ const out = {};
9845
+ for (const [name, spec] of Object.entries(specs)) {
9846
+ const secretPaths = collectZodSecretPaths(spec.schema);
9847
+ const nameField = spec.entry?.nameField ?? "name";
9848
+ const fields = bodyFieldsOf(spec.schema);
9849
+ if (spec.entry !== void 0 && !hasNameField(fields, nameField)) throw new DeclarationRefusedError(`kind "${name}": an entry kind's schema needs a "${nameField}" field`);
9850
+ const parsed = RecordKindDeclarationSchema.parse({
9851
+ database: spec.database,
9852
+ class: spec.class,
9853
+ writeTrigger: spec.writeTrigger,
9854
+ device: spec.device,
9855
+ at: spec.at,
9856
+ indexes: spec.indexes === void 0 ? void 0 : [...spec.indexes],
9857
+ retention: spec.retention,
9858
+ deviceRemoval: spec.deviceRemoval,
9859
+ maxDataBytes: spec.maxDataBytes,
9860
+ secretPaths: [...new Set([...secretPaths, ...spec.retiredSecretPaths ?? []])],
9861
+ secretArrayKeys: spec.secretArrayKeys === void 0 ? void 0 : { ...spec.secretArrayKeys },
9862
+ transactFamily: spec.transactFamily,
9863
+ entry: spec.entry === void 0 ? void 0 : {
9864
+ title: spec.entry.title,
9865
+ nameField,
9866
+ fields
9867
+ }
9868
+ });
9869
+ assertValidDeclaration(name, parsed);
9870
+ out[name] = {
9871
+ name,
9872
+ schema: spec.schema,
9873
+ declaration: parsed
9874
+ };
9875
+ }
9876
+ return out;
9877
+ }
9878
+ /**
9879
+ * Entry kinds (D881): every list of user-created entries (notification
9880
+ * targets, brokers, LLM profiles) is ONE record kind with an id, a name and a
9881
+ * kind-specific body, and the admin UI lists/adds/edits/deletes all of them
9882
+ * through the `record-entries` capability with password fields derived from
9883
+ * the schema (`.meta({ secret: true })`).
9884
+ */
9885
+ /** The body of a plain entry: a name and the fields the kind adds. */
9886
+ function entryBody(shape) {
9887
+ return object({
9888
+ name: string().min(1),
9889
+ enabled: boolean().optional(),
9890
+ ...shape
9891
+ });
9892
+ }
9893
+ /**
9894
+ * Declare one entry kind. An entry is configuration: never trimmed by the
9895
+ * engine, never aged, belonging to no device.
9896
+ */
9897
+ function defineEntryKind(name, spec) {
9898
+ const defined = defineRecordKinds({ [name]: {
9899
+ schema: spec.schema,
9900
+ class: "config",
9901
+ writeTrigger: spec.writeTrigger ?? "an operator adds or edits an entry in the entries UI",
9902
+ retention: { none: "an entry goes only when the operator deletes it" },
9903
+ ...spec.maxDataBytes === void 0 ? {} : { maxDataBytes: spec.maxDataBytes },
9904
+ ...spec.database === void 0 ? {} : { database: spec.database },
9905
+ ...spec.indexes === void 0 ? {} : { indexes: spec.indexes },
9906
+ ...spec.secretArrayKeys === void 0 ? {} : { secretArrayKeys: spec.secretArrayKeys },
9907
+ ...spec.retiredSecretPaths === void 0 ? {} : { retiredSecretPaths: spec.retiredSecretPaths },
9908
+ entry: {
9909
+ title: spec.title,
9910
+ ...spec.nameField === void 0 ? {} : { nameField: spec.nameField }
9911
+ }
9912
+ } })[name];
9913
+ if (defined === void 0) throw new DeclarationRefusedError(`entry kind "${name}" was not built`);
9914
+ return defined;
9915
+ }
9916
+ /**
9917
+ * The share-view scope kinds a share-link token can carry. The hub mints
9918
+ * and validates them (`ShareViewGrantSchema` builds its
9919
+ * enum from this list); a data plane names the kinds it ACCEPTS in `share`.
9920
+ */
9921
+ var SHARE_VIEW_KINDS = ["grid-view", "events-view"];
9922
+ /** The wire shape of {@link PeerBytesTicket} — see the type for what it is. */
9923
+ var PeerBytesTicketSchema = object({
9924
+ /** `http://127.0.0.1:<port>/<token>`. One `GET` takes it. */
9925
+ url: string().min(1),
9926
+ /**
9927
+ * The HOST node this URL means something on — the hub or a named agent,
9928
+ * never a runner. {@link AddonPeerBytes.open} compares it to its own and
9929
+ * refuses `cross-node` by name when they differ, without dialling.
9930
+ */
9931
+ hostNodeId: string().min(1),
9932
+ expiresAtMs: number().int().nonnegative(),
9933
+ /**
9934
+ * What the producer DECLARED the body to be, when it knows — `null` when it
9935
+ * does not. Never `0` for unknown (D393): a consumer sizing a bound off this
9936
+ * must be able to tell "the producer did not say" from "the body is empty".
9937
+ */
9938
+ declaredBytes: number().int().nonnegative().nullable()
9939
+ });
9913
9940
  var READING_QUANTITIES = [
9914
9941
  "temperature",
9915
9942
  "pressure",
@@ -10527,7 +10554,6 @@ var CAP_NAMES = Object.freeze([
10527
10554
  "climate-control",
10528
10555
  "color",
10529
10556
  "composer",
10530
- "connection-test",
10531
10557
  "connectivity",
10532
10558
  "consumables",
10533
10559
  "contact",
@@ -12547,8 +12573,7 @@ Object.freeze({
12547
12573
  "offerArtifact": 3e5,
12548
12574
  "readResult": 3e5,
12549
12575
  "submitJob": 18e5,
12550
- "uploadDataset": 72e5,
12551
- "validateCredentials": 3e4
12576
+ "uploadDataset": 72e5
12552
12577
  }
12553
12578
  });
12554
12579
  object({
@@ -13903,6 +13928,432 @@ var IntegrationInstanceRefSchema = object({
13903
13928
  ]),
13904
13929
  candidateStableId: string().optional()
13905
13930
  });
13931
+ /**
13932
+ * notification-output — canonical, capability-gated notification delivery.
13933
+ *
13934
+ * Apprise-derived model (see
13935
+ * `docs/superpowers/specs/2026-07-03-notification-output-notifier-matrix.md`):
13936
+ * callers emit ONE canonical `Notification`; each provider declares a
13937
+ * per-kind capability descriptor (`TargetKind`), and the pure degrade
13938
+ * engine (`@camstack/types` `prepareNotification`) transcodes / degrades the
13939
+ * message to what the kind supports — callers never special-case a service.
13940
+ *
13941
+ * DESIGN DECISIONS (locked):
13942
+ * - Target CRUD lives on THIS cap (`upsertTarget` / `deleteTarget` /
13943
+ * `setTargetEnabled`), each provider persisting via the `settings-store`
13944
+ * cap. Rationale: the admin UI needs one uniform surface across the
13945
+ * notifiers addon AND the HA addon; the addon-`globalSettingsSchema`-array
13946
+ * alternative would fork the UI per addon and cannot host the
13947
+ * discovery→adopt flow.
13948
+ * - `listTargetKinds` / `listTargets` / `discoverTargets` return arrays →
13949
+ * the generated cap-mount auto-`concatCollection`-fans them across every
13950
+ * registered provider (notifiers addon + HA addon) so one catalog is
13951
+ * routable. `send` / `testTarget` / CRUD route to ONE provider by the
13952
+ * `addonId` the generated collection router extracts from the call input.
13953
+ * - `Attachment.bytes` is `Uint8Array`. Transport-safe: superjson (the tRPC
13954
+ * transformer) + UDS MsgPack both round-trip typed arrays — already used by
13955
+ * `storage` / `storage-provider` / `recording` caps over the same path. No
13956
+ * base64 fallback needed.
13957
+ *
13958
+ * TODO (deferred, closed-set change — separate decision): add
13959
+ * `providerKind: 'notify'` so notification providers surface on the unified
13960
+ * admin "Integrations" page.
13961
+ */
13962
+ /**
13963
+ * Zentik-derived typed-media enum — the superset across every kind. Each
13964
+ * adapter picks what it supports and the degrade engine filters the rest.
13965
+ */
13966
+ var AttachmentMediaTypeSchema = _enum([
13967
+ "image",
13968
+ "video",
13969
+ "gif",
13970
+ "audio",
13971
+ "icon"
13972
+ ]);
13973
+ /**
13974
+ * A single attachment. Exactly one of `url` (remote source, most adapters
13975
+ * prefer this) or `bytes` (inline source; required for Pushover-style
13976
+ * bytes-only kinds) MUST be present — the degrade engine expresses a
13977
+ * url→bytes fetch as a `needsFetch` directive the adapter executes.
13978
+ */
13979
+ var AttachmentSchema = object({
13980
+ mediaType: AttachmentMediaTypeSchema,
13981
+ url: string().optional(),
13982
+ bytes: _instanceof(Uint8Array).optional(),
13983
+ mime: string().optional(),
13984
+ name: string().optional()
13985
+ }).refine((a) => a.url !== void 0 || a.bytes !== void 0, { message: "Attachment requires either `url` or `bytes`" });
13986
+ var NotificationFormatSchema = _enum([
13987
+ "text",
13988
+ "markdown",
13989
+ "html"
13990
+ ]);
13991
+ /**
13992
+ * The CLOSED icon vocabulary an action button may use.
13993
+ *
13994
+ * A closed set, not a free string, and that is the whole point: an arbitrary
13995
+ * icon name is one that ntfy renders, zentik silently drops, and nobody
13996
+ * notices — the same class of gap as a zone vocabulary nothing produced
13997
+ * ([D35](../../../docs/decisions/adr-0035.md)). Every adapter maps this set or
13998
+ * declares `actionIcons: false` and the degrade engine strips the field.
13999
+ *
14000
+ * Named by INTENT, never by glyph. "check" would tie the vocabulary to one
14001
+ * renderer's icon set; "acknowledge" survives an adapter that draws it
14002
+ * differently.
14003
+ *
14004
+ * ── A TOKEN IS NOT A WIRE VALUE ─────────────────────────────────────
14005
+ *
14006
+ * These names are for US. **No adapter may forward one verbatim.** Each maps
14007
+ * the whole set onto its own renderer's vocabulary through a
14008
+ * `Record<NotificationActionIcon, string>` — a Record, never a lookup with a
14009
+ * fallback, so adding a member here fails every adapter's build until someone
14010
+ * decides its glyph, which is the only place that decision can be made
14011
+ * honestly.
14012
+ *
14013
+ * This paragraph is the bug. Zentik declared `actionIcons: true` and passed
14014
+ * `disarm` straight through; iOS feeds that string to
14015
+ * `UNNotificationActionIcon(systemImageName:)`, `disarm` is not an SF Symbol,
14016
+ * and every snooze and alarm button arrived BLANK. A pass-through is not a
14017
+ * mapping, and "the field is documented" is not "the value renders".
14018
+ *
14019
+ * Adding a member is TRAIN-BOUND. The enum lives in the published
14020
+ * `@camstack/server` closure and the cap seam validates against the HUB's copy,
14021
+ * so an addon that emits a token the running hub does not know does not lose an
14022
+ * icon — its whole `send` fails Zod validation and the notification never
14023
+ * arrives. Never emit a new token from an addon before the train carrying it.
14024
+ */
14025
+ var NotificationActionIconSchema = _enum([
14026
+ "acknowledge",
14027
+ "dismiss",
14028
+ "silence",
14029
+ "snooze",
14030
+ "view",
14031
+ "play",
14032
+ "open",
14033
+ "close",
14034
+ "lock",
14035
+ "unlock",
14036
+ "arm",
14037
+ "arm-home",
14038
+ "arm-away",
14039
+ "arm-night",
14040
+ "disarm",
14041
+ "light",
14042
+ "alert",
14043
+ "camera"
14044
+ ]);
14045
+ /** A single tap-through action button. */
14046
+ var NotificationActionSchema = object({
14047
+ id: string(),
14048
+ label: string(),
14049
+ url: string().optional(),
14050
+ /** Dropped by the degrade engine for a kind with `caps.actionIcons: false`. */
14051
+ icon: NotificationActionIconSchema.optional(),
14052
+ /**
14053
+ * Renders in a warning style where the notifier supports it.
14054
+ *
14055
+ * A HINT, never a gate. The callback's authority is its token and nothing
14056
+ * else — see `notification-center/action-token.ts` for what that does and
14057
+ * does not buy.
14058
+ */
14059
+ destructive: boolean().optional(),
14060
+ /**
14061
+ * How the tap should REACH the url.
14062
+ *
14063
+ * `navigate` (absent, and every button authored before this field) opens it:
14064
+ * the phone leaves the notification and shows whatever the callback returns.
14065
+ * That is right for a button whose answer the operator wants to read.
14066
+ *
14067
+ * `background` fires it as a POST and stays put. It exists for the buttons
14068
+ * whose whole point is not to interrupt — "silence this for 30 minutes" is
14069
+ * an answer to the notification, and being thrown into a browser tab to
14070
+ * confirm it costs more attention than the notification did. A backend that
14071
+ * cannot do a background call renders it as an ordinary link (the adapters
14072
+ * fall back rather than dropping the button), so this is a preference, never
14073
+ * a requirement.
14074
+ */
14075
+ mode: _enum(["navigate", "background"]).optional()
14076
+ });
14077
+ /** A delivery parameter value: what a notifier declared it takes. */
14078
+ var DeliveryParamValueSchema = union([
14079
+ string(),
14080
+ number(),
14081
+ boolean()
14082
+ ]);
14083
+ /**
14084
+ * One extra delivery parameter a notifier KIND declares (D938). A rule that
14085
+ * addresses a target of that kind may set it; a kind that declares nothing is
14086
+ * never handed one. The admin UI derives its control from this descriptor —
14087
+ * no editor knows a service by name.
14088
+ *
14089
+ * Optional fields are `.optional()`, never `.default()` (a Zod default does not
14090
+ * run on the addon cap path).
14091
+ */
14092
+ var DeliveryParamSchema = object({
14093
+ key: string().min(1),
14094
+ label: string(),
14095
+ /** i18n key of the label, resolved by the declaring addon's namespace. */
14096
+ labelKey: string().optional(),
14097
+ type: _enum([
14098
+ "enum",
14099
+ "number",
14100
+ "boolean",
14101
+ "string"
14102
+ ]),
14103
+ /** `enum` only: the closed set of accepted values. */
14104
+ options: array(object({
14105
+ value: string(),
14106
+ label: string()
14107
+ })).optional(),
14108
+ /** `number` only. */
14109
+ min: number().optional(),
14110
+ max: number().optional(),
14111
+ /** What the notifier does when the rule sets nothing; shown as the placeholder. */
14112
+ default: DeliveryParamValueSchema.optional()
14113
+ });
14114
+ /**
14115
+ * The canonical notification. `body` is the only hard field (Apprise model).
14116
+ * `priority` is a 5-level ORDINAL (1=lowest … 3=normal(default) … 5=urgent),
14117
+ * NOT a fixed severity enum — each kind declares its own `caps.levels` and
14118
+ * the adapter maps this ordinal onto its native level. `level?` is an
14119
+ * optional kind-native level id (`emergency`, `silent`, …) that overrides
14120
+ * `priority` for that one target.
14121
+ */
14122
+ var NotificationSchema = object({
14123
+ body: string(),
14124
+ title: string().optional(),
14125
+ format: NotificationFormatSchema.default("text"),
14126
+ priority: number().int().min(1).max(5).default(3),
14127
+ level: string().optional(),
14128
+ attachments: array(AttachmentSchema).optional(),
14129
+ clickUrl: string().optional(),
14130
+ actions: array(NotificationActionSchema).optional(),
14131
+ sound: string().optional(),
14132
+ ttl: number().optional(),
14133
+ tag: string().optional(),
14134
+ deviceId: number().optional(),
14135
+ eventId: string().optional(),
14136
+ metadata: record(string(), unknown()).optional(),
14137
+ /**
14138
+ * Values for the parameters the target's kind DECLARES in
14139
+ * {@link TargetKindSchema} `deliveryParams`. Already validated against the
14140
+ * declaration by the sender; a notifier reads only the keys it declared.
14141
+ */
14142
+ delivery: record(string(), DeliveryParamValueSchema).optional()
14143
+ });
14144
+ /** One declared native severity/priority level for a kind. */
14145
+ var TargetKindLevelSchema = object({
14146
+ id: string(),
14147
+ label: string(),
14148
+ /** Which canonical priority (1..5) this level maps to. `null` = qualitative-only. */
14149
+ ordinal: number().int().min(1).max(5).nullable(),
14150
+ flags: object({
14151
+ critical: boolean().optional(),
14152
+ silent: boolean().optional(),
14153
+ noPush: boolean().optional()
14154
+ }).optional(),
14155
+ /** e.g. Pushover `emergency` requires `retry` / `expire`. */
14156
+ requires: array(string()).optional(),
14157
+ description: string().optional()
14158
+ });
14159
+ /** The full capability block consulted before dispatch. */
14160
+ var TargetKindCapsSchema = object({
14161
+ attachments: object({
14162
+ mediaTypes: array(AttachmentMediaTypeSchema),
14163
+ mode: _enum([
14164
+ "url",
14165
+ "bytes",
14166
+ "both"
14167
+ ]),
14168
+ max: number().int().nonnegative(),
14169
+ maxBytes: number().int().positive().optional()
14170
+ }),
14171
+ /** Max action buttons (0 = none). */
14172
+ actions: number().int().nonnegative(),
14173
+ /**
14174
+ * Whether this kind renders a per-action ICON.
14175
+ *
14176
+ * `.optional()`, deliberately NOT `.default(false)`: a Zod default does not
14177
+ * run on the addon cap path — three production failures in one day taught
14178
+ * this repo that once. Absent is read as false by the degrade engine, which
14179
+ * is the safe direction: an icon that is not rendered costs nothing, an icon
14180
+ * assumed and dropped costs the operator's trust in the field.
14181
+ */
14182
+ actionIcons: boolean().optional(),
14183
+ levels: array(TargetKindLevelSchema),
14184
+ format: array(NotificationFormatSchema),
14185
+ clickUrl: boolean(),
14186
+ sound: boolean(),
14187
+ ttl: boolean(),
14188
+ bodyMaxLen: number().int().positive()
14189
+ });
14190
+ /**
14191
+ * `configSchema` is a `ConfigUISchema` tree passed through to the admin
14192
+ * FormBuilder. Stored as `z.unknown()` at the cap seam (mirrors
14193
+ * `device-provider.getChildCreationSchema` `CreationSchemaOutputSchema`) —
14194
+ * the union is large and not meant for runtime validation here; the exported
14195
+ * `TargetKind` type re-tightens `configSchema` to `ConfigUISchema`.
14196
+ */
14197
+ var ConfigSchemaPassthrough$4 = unknown();
14198
+ var TargetKindSchema = object({
14199
+ kind: string(),
14200
+ label: string(),
14201
+ icon: string(),
14202
+ /** Stamped by each provider so the concat-fanned catalog stays routable. */
14203
+ addonId: string(),
14204
+ /**
14205
+ * URL of the kind's bundled BRAND icon, served by the providing addon over
14206
+ * its own `addon-routes` surface (`/addon/<addonId>/icons/<kind>`). Absent
14207
+ * when the addon bundles no icon for that kind — the client then falls back
14208
+ * to a neutral glyph rather than rendering the raw `icon` NAME as text.
14209
+ *
14210
+ * Root-relative on purpose: it resolves against whatever origin serves a web
14211
+ * client, and a native client joins it onto its own hub base.
14212
+ *
14213
+ * DECLARED here deliberately. It used to travel as an undeclared passthrough
14214
+ * field that survived only because the runtime cap-router forwards provider
14215
+ * output verbatim — so every consumer had to re-declare it by hand to stop
14216
+ * its own Zod parse from stripping it, and the whole arrangement would have
14217
+ * broken silently the moment output validation was tightened anywhere.
14218
+ */
14219
+ iconUrl: string().optional(),
14220
+ /**
14221
+ * Media type of {@link iconUrl} (`image/svg+xml`, `image/png`, …).
14222
+ *
14223
+ * The server knows this and therefore says it, because the client cannot
14224
+ * safely guess: a React-Native client renders SVG and raster through two
14225
+ * DIFFERENT components (`react-native-svg` vs `expo-image` — expo-image does
14226
+ * not decode SVG on iOS/Android), so without this it silently fell back to a
14227
+ * placeholder glyph for every vector icon while the web build looked fine.
14228
+ *
14229
+ * Absent when {@link iconUrl} is absent, or for a legacy provider that has
14230
+ * not been updated — a client that cannot determine the type should prefer
14231
+ * its raster path, which is the safe default for an unknown image.
14232
+ */
14233
+ iconMediaType: string().optional(),
14234
+ configSchema: ConfigSchemaPassthrough$4,
14235
+ /**
14236
+ * The config keys that decide WHERE this kind's secrets are sent (server,
14237
+ * base URL, instance, chat, recipient). A save that changes any of them
14238
+ * while leaving a secret redacted is refused by the provider (D634), so an
14239
+ * editor uses this to ask for the secret on exactly those edits instead of
14240
+ * on every edit.
14241
+ *
14242
+ * Optional: absent from a provider that holds no secret (the Home Assistant
14243
+ * kinds) and from a provider older than this field — an editor that finds
14244
+ * it absent must assume ANY edit may need the secret.
14245
+ */
14246
+ destinationKeys: array(string()).optional(),
14247
+ supportsDiscovery: boolean(),
14248
+ /**
14249
+ * Extra delivery parameters a rule may set for a target of this kind (D938).
14250
+ * Absent = none; the rule editor then offers nothing.
14251
+ */
14252
+ deliveryParams: array(DeliveryParamSchema).optional(),
14253
+ caps: TargetKindCapsSchema
14254
+ });
14255
+ /**
14256
+ * A persisted target. `config` holds secrets; providers REDACT secret fields
14257
+ * (return a presence marker only) when serving `listTargets` — never
14258
+ * round-trip a stored secret to the UI.
14259
+ */
14260
+ var TargetSchema = object({
14261
+ id: string(),
14262
+ name: string(),
14263
+ kind: string(),
14264
+ addonId: string(),
14265
+ enabled: boolean(),
14266
+ config: record(string(), unknown())
14267
+ });
14268
+ /** A discovery-surfaced candidate (config is partial + non-secret). */
14269
+ var DiscoveredTargetSchema = object({
14270
+ kind: string(),
14271
+ suggestedName: string(),
14272
+ config: record(string(), unknown())
14273
+ });
14274
+ /** The degrade engine's report — what was resolved / dropped / degraded. */
14275
+ var RenderedAsSchema = object({
14276
+ level: string(),
14277
+ format: NotificationFormatSchema,
14278
+ attachmentsSent: number().int().nonnegative(),
14279
+ actionsSent: number().int().nonnegative(),
14280
+ truncated: boolean(),
14281
+ dropped: array(string())
14282
+ });
14283
+ var SendResultSchema = object({
14284
+ success: boolean(),
14285
+ error: string().optional(),
14286
+ renderedAs: RenderedAsSchema.optional()
14287
+ });
14288
+ /** Same shape as SendResult — kept as a distinct name for the test panel. */
14289
+ var TestResultSchema = SendResultSchema;
14290
+ /**
14291
+ * Pre-save credential probe against a partial (unsaved) target config.
14292
+ * `resolvedUrl` never includes secrets (token stripped from path).
14293
+ */
14294
+ var ProbeTargetConfigResultSchema = object({
14295
+ ok: boolean(),
14296
+ resolvedUrl: string(),
14297
+ httpStatus: number().int().optional(),
14298
+ stateInstance: string().optional(),
14299
+ error: string().optional()
14300
+ });
14301
+ method(object({}), array(TargetKindSchema)), method(object({}), array(TargetSchema), { auth: "admin" }), method(object({ targetId: string() }), TargetSchema, { auth: "admin" }), method(object({
14302
+ kind: string(),
14303
+ config: record(string(), unknown()).optional(),
14304
+ /**
14305
+ * When editing / duplicating, the blank password field never round-trips
14306
+ * the stored token. Pass the source target id so the provider can restore
14307
+ * secrets server-side before dialling (same merge as upsert).
14308
+ */
14309
+ targetId: string().optional()
14310
+ }), array(DiscoveredTargetSchema), { auth: "admin" }), method(object({
14311
+ kind: string(),
14312
+ config: record(string(), unknown()),
14313
+ /** See `discoverTargets.targetId` — restore stored secrets for a blank password. */
14314
+ targetId: string().optional()
14315
+ }), ProbeTargetConfigResultSchema, {
14316
+ kind: "mutation",
14317
+ auth: "admin"
14318
+ }), method(object({
14319
+ targetId: string(),
14320
+ notification: NotificationSchema
14321
+ }), SendResultSchema, {
14322
+ kind: "mutation",
14323
+ auth: "admin"
14324
+ }), method(object({
14325
+ targetId: string(),
14326
+ sample: NotificationSchema.optional()
14327
+ }), TestResultSchema, {
14328
+ kind: "mutation",
14329
+ auth: "admin"
14330
+ }), method(object({
14331
+ target: TargetSchema,
14332
+ /**
14333
+ * Duplicate flow: create a NEW target id while copying secrets from an
14334
+ * existing row. The UI never holds the stored token; blank / redacted
14335
+ * password fields are restored from this source (D634 still applies if
14336
+ * destinations diverge without a re-typed secret).
14337
+ */
14338
+ cloneSecretsFrom: string().optional()
14339
+ }), TargetSchema, {
14340
+ kind: "mutation",
14341
+ auth: "admin"
14342
+ }), method(object({ targetId: string() }), _void(), {
14343
+ kind: "mutation",
14344
+ auth: "admin"
14345
+ }), method(object({
14346
+ targetId: string(),
14347
+ enabled: boolean()
14348
+ }), _void(), {
14349
+ kind: "mutation",
14350
+ auth: "admin"
14351
+ });
14352
+ looseObject({
14353
+ name: string().min(1),
14354
+ enabled: boolean().optional()
14355
+ });
14356
+ TargetSchema.omit({ id: true });
13906
14357
  var EncodeProfileSchema = object({
13907
14358
  video: object({
13908
14359
  codec: _enum([
@@ -22263,7 +22714,6 @@ var SYSTEM_CAP_VOCABULARY = {
22263
22714
  "calendar-source": system(INTERNAL),
22264
22715
  calendars: system("calendars feed schedules and conditions, not device actions"),
22265
22716
  composer: system("device composition — an authoring tool, not an action"),
22266
- "connection-test": system(INTERNAL),
22267
22717
  "core-blocks": system(INTERNAL),
22268
22718
  "custom-model-registry": system(ML),
22269
22719
  "data-store-provider": system(INTERNAL),
@@ -44319,427 +44769,6 @@ var UnitWarningSchema = object({
44319
44769
  assumedUnit: string(),
44320
44770
  message: string()
44321
44771
  });
44322
- /**
44323
- * notification-output — canonical, capability-gated notification delivery.
44324
- *
44325
- * Apprise-derived model (see
44326
- * `docs/superpowers/specs/2026-07-03-notification-output-notifier-matrix.md`):
44327
- * callers emit ONE canonical `Notification`; each provider declares a
44328
- * per-kind capability descriptor (`TargetKind`), and the pure degrade
44329
- * engine (`@camstack/types` `prepareNotification`) transcodes / degrades the
44330
- * message to what the kind supports — callers never special-case a service.
44331
- *
44332
- * DESIGN DECISIONS (locked):
44333
- * - Target CRUD lives on THIS cap (`upsertTarget` / `deleteTarget` /
44334
- * `setTargetEnabled`), each provider persisting via the `settings-store`
44335
- * cap. Rationale: the admin UI needs one uniform surface across the
44336
- * notifiers addon AND the HA addon; the addon-`globalSettingsSchema`-array
44337
- * alternative would fork the UI per addon and cannot host the
44338
- * discovery→adopt flow.
44339
- * - `listTargetKinds` / `listTargets` / `discoverTargets` return arrays →
44340
- * the generated cap-mount auto-`concatCollection`-fans them across every
44341
- * registered provider (notifiers addon + HA addon) so one catalog is
44342
- * routable. `send` / `testTarget` / CRUD route to ONE provider by the
44343
- * `addonId` the generated collection router extracts from the call input.
44344
- * - `Attachment.bytes` is `Uint8Array`. Transport-safe: superjson (the tRPC
44345
- * transformer) + UDS MsgPack both round-trip typed arrays — already used by
44346
- * `storage` / `storage-provider` / `recording` caps over the same path. No
44347
- * base64 fallback needed.
44348
- *
44349
- * TODO (deferred, closed-set change — separate decision): add
44350
- * `providerKind: 'notify'` so notification providers surface on the unified
44351
- * admin "Integrations" page.
44352
- */
44353
- /**
44354
- * Zentik-derived typed-media enum — the superset across every kind. Each
44355
- * adapter picks what it supports and the degrade engine filters the rest.
44356
- */
44357
- var AttachmentMediaTypeSchema = _enum([
44358
- "image",
44359
- "video",
44360
- "gif",
44361
- "audio",
44362
- "icon"
44363
- ]);
44364
- /**
44365
- * A single attachment. Exactly one of `url` (remote source, most adapters
44366
- * prefer this) or `bytes` (inline source; required for Pushover-style
44367
- * bytes-only kinds) MUST be present — the degrade engine expresses a
44368
- * url→bytes fetch as a `needsFetch` directive the adapter executes.
44369
- */
44370
- var AttachmentSchema = object({
44371
- mediaType: AttachmentMediaTypeSchema,
44372
- url: string().optional(),
44373
- bytes: _instanceof(Uint8Array).optional(),
44374
- mime: string().optional(),
44375
- name: string().optional()
44376
- }).refine((a) => a.url !== void 0 || a.bytes !== void 0, { message: "Attachment requires either `url` or `bytes`" });
44377
- var NotificationFormatSchema = _enum([
44378
- "text",
44379
- "markdown",
44380
- "html"
44381
- ]);
44382
- /**
44383
- * The CLOSED icon vocabulary an action button may use.
44384
- *
44385
- * A closed set, not a free string, and that is the whole point: an arbitrary
44386
- * icon name is one that ntfy renders, zentik silently drops, and nobody
44387
- * notices — the same class of gap as a zone vocabulary nothing produced
44388
- * ([D35](../../../docs/decisions/adr-0035.md)). Every adapter maps this set or
44389
- * declares `actionIcons: false` and the degrade engine strips the field.
44390
- *
44391
- * Named by INTENT, never by glyph. "check" would tie the vocabulary to one
44392
- * renderer's icon set; "acknowledge" survives an adapter that draws it
44393
- * differently.
44394
- *
44395
- * ── A TOKEN IS NOT A WIRE VALUE ─────────────────────────────────────
44396
- *
44397
- * These names are for US. **No adapter may forward one verbatim.** Each maps
44398
- * the whole set onto its own renderer's vocabulary through a
44399
- * `Record<NotificationActionIcon, string>` — a Record, never a lookup with a
44400
- * fallback, so adding a member here fails every adapter's build until someone
44401
- * decides its glyph, which is the only place that decision can be made
44402
- * honestly.
44403
- *
44404
- * This paragraph is the bug. Zentik declared `actionIcons: true` and passed
44405
- * `disarm` straight through; iOS feeds that string to
44406
- * `UNNotificationActionIcon(systemImageName:)`, `disarm` is not an SF Symbol,
44407
- * and every snooze and alarm button arrived BLANK. A pass-through is not a
44408
- * mapping, and "the field is documented" is not "the value renders".
44409
- *
44410
- * Adding a member is TRAIN-BOUND. The enum lives in the published
44411
- * `@camstack/server` closure and the cap seam validates against the HUB's copy,
44412
- * so an addon that emits a token the running hub does not know does not lose an
44413
- * icon — its whole `send` fails Zod validation and the notification never
44414
- * arrives. Never emit a new token from an addon before the train carrying it.
44415
- */
44416
- var NotificationActionIconSchema = _enum([
44417
- "acknowledge",
44418
- "dismiss",
44419
- "silence",
44420
- "snooze",
44421
- "view",
44422
- "play",
44423
- "open",
44424
- "close",
44425
- "lock",
44426
- "unlock",
44427
- "arm",
44428
- "arm-home",
44429
- "arm-away",
44430
- "arm-night",
44431
- "disarm",
44432
- "light",
44433
- "alert",
44434
- "camera"
44435
- ]);
44436
- /** A single tap-through action button. */
44437
- var NotificationActionSchema = object({
44438
- id: string(),
44439
- label: string(),
44440
- url: string().optional(),
44441
- /** Dropped by the degrade engine for a kind with `caps.actionIcons: false`. */
44442
- icon: NotificationActionIconSchema.optional(),
44443
- /**
44444
- * Renders in a warning style where the notifier supports it.
44445
- *
44446
- * A HINT, never a gate. The callback's authority is its token and nothing
44447
- * else — see `notification-center/action-token.ts` for what that does and
44448
- * does not buy.
44449
- */
44450
- destructive: boolean().optional(),
44451
- /**
44452
- * How the tap should REACH the url.
44453
- *
44454
- * `navigate` (absent, and every button authored before this field) opens it:
44455
- * the phone leaves the notification and shows whatever the callback returns.
44456
- * That is right for a button whose answer the operator wants to read.
44457
- *
44458
- * `background` fires it as a POST and stays put. It exists for the buttons
44459
- * whose whole point is not to interrupt — "silence this for 30 minutes" is
44460
- * an answer to the notification, and being thrown into a browser tab to
44461
- * confirm it costs more attention than the notification did. A backend that
44462
- * cannot do a background call renders it as an ordinary link (the adapters
44463
- * fall back rather than dropping the button), so this is a preference, never
44464
- * a requirement.
44465
- */
44466
- mode: _enum(["navigate", "background"]).optional()
44467
- });
44468
- /** A delivery parameter value: what a notifier declared it takes. */
44469
- var DeliveryParamValueSchema = union([
44470
- string(),
44471
- number(),
44472
- boolean()
44473
- ]);
44474
- /**
44475
- * One extra delivery parameter a notifier KIND declares (D938). A rule that
44476
- * addresses a target of that kind may set it; a kind that declares nothing is
44477
- * never handed one. The admin UI derives its control from this descriptor —
44478
- * no editor knows a service by name.
44479
- *
44480
- * Optional fields are `.optional()`, never `.default()` (a Zod default does not
44481
- * run on the addon cap path).
44482
- */
44483
- var DeliveryParamSchema = object({
44484
- key: string().min(1),
44485
- label: string(),
44486
- /** i18n key of the label, resolved by the declaring addon's namespace. */
44487
- labelKey: string().optional(),
44488
- type: _enum([
44489
- "enum",
44490
- "number",
44491
- "boolean",
44492
- "string"
44493
- ]),
44494
- /** `enum` only: the closed set of accepted values. */
44495
- options: array(object({
44496
- value: string(),
44497
- label: string()
44498
- })).optional(),
44499
- /** `number` only. */
44500
- min: number().optional(),
44501
- max: number().optional(),
44502
- /** What the notifier does when the rule sets nothing; shown as the placeholder. */
44503
- default: DeliveryParamValueSchema.optional()
44504
- });
44505
- /**
44506
- * The canonical notification. `body` is the only hard field (Apprise model).
44507
- * `priority` is a 5-level ORDINAL (1=lowest … 3=normal(default) … 5=urgent),
44508
- * NOT a fixed severity enum — each kind declares its own `caps.levels` and
44509
- * the adapter maps this ordinal onto its native level. `level?` is an
44510
- * optional kind-native level id (`emergency`, `silent`, …) that overrides
44511
- * `priority` for that one target.
44512
- */
44513
- var NotificationSchema = object({
44514
- body: string(),
44515
- title: string().optional(),
44516
- format: NotificationFormatSchema.default("text"),
44517
- priority: number().int().min(1).max(5).default(3),
44518
- level: string().optional(),
44519
- attachments: array(AttachmentSchema).optional(),
44520
- clickUrl: string().optional(),
44521
- actions: array(NotificationActionSchema).optional(),
44522
- sound: string().optional(),
44523
- ttl: number().optional(),
44524
- tag: string().optional(),
44525
- deviceId: number().optional(),
44526
- eventId: string().optional(),
44527
- metadata: record(string(), unknown()).optional(),
44528
- /**
44529
- * Values for the parameters the target's kind DECLARES in
44530
- * {@link TargetKindSchema} `deliveryParams`. Already validated against the
44531
- * declaration by the sender; a notifier reads only the keys it declared.
44532
- */
44533
- delivery: record(string(), DeliveryParamValueSchema).optional()
44534
- });
44535
- /** One declared native severity/priority level for a kind. */
44536
- var TargetKindLevelSchema = object({
44537
- id: string(),
44538
- label: string(),
44539
- /** Which canonical priority (1..5) this level maps to. `null` = qualitative-only. */
44540
- ordinal: number().int().min(1).max(5).nullable(),
44541
- flags: object({
44542
- critical: boolean().optional(),
44543
- silent: boolean().optional(),
44544
- noPush: boolean().optional()
44545
- }).optional(),
44546
- /** e.g. Pushover `emergency` requires `retry` / `expire`. */
44547
- requires: array(string()).optional(),
44548
- description: string().optional()
44549
- });
44550
- /** The full capability block consulted before dispatch. */
44551
- var TargetKindCapsSchema = object({
44552
- attachments: object({
44553
- mediaTypes: array(AttachmentMediaTypeSchema),
44554
- mode: _enum([
44555
- "url",
44556
- "bytes",
44557
- "both"
44558
- ]),
44559
- max: number().int().nonnegative(),
44560
- maxBytes: number().int().positive().optional()
44561
- }),
44562
- /** Max action buttons (0 = none). */
44563
- actions: number().int().nonnegative(),
44564
- /**
44565
- * Whether this kind renders a per-action ICON.
44566
- *
44567
- * `.optional()`, deliberately NOT `.default(false)`: a Zod default does not
44568
- * run on the addon cap path — three production failures in one day taught
44569
- * this repo that once. Absent is read as false by the degrade engine, which
44570
- * is the safe direction: an icon that is not rendered costs nothing, an icon
44571
- * assumed and dropped costs the operator's trust in the field.
44572
- */
44573
- actionIcons: boolean().optional(),
44574
- levels: array(TargetKindLevelSchema),
44575
- format: array(NotificationFormatSchema),
44576
- clickUrl: boolean(),
44577
- sound: boolean(),
44578
- ttl: boolean(),
44579
- bodyMaxLen: number().int().positive()
44580
- });
44581
- /**
44582
- * `configSchema` is a `ConfigUISchema` tree passed through to the admin
44583
- * FormBuilder. Stored as `z.unknown()` at the cap seam (mirrors
44584
- * `device-provider.getChildCreationSchema` `CreationSchemaOutputSchema`) —
44585
- * the union is large and not meant for runtime validation here; the exported
44586
- * `TargetKind` type re-tightens `configSchema` to `ConfigUISchema`.
44587
- */
44588
- var ConfigSchemaPassthrough$4 = unknown();
44589
- var TargetKindSchema = object({
44590
- kind: string(),
44591
- label: string(),
44592
- icon: string(),
44593
- /** Stamped by each provider so the concat-fanned catalog stays routable. */
44594
- addonId: string(),
44595
- /**
44596
- * URL of the kind's bundled BRAND icon, served by the providing addon over
44597
- * its own `addon-routes` surface (`/addon/<addonId>/icons/<kind>`). Absent
44598
- * when the addon bundles no icon for that kind — the client then falls back
44599
- * to a neutral glyph rather than rendering the raw `icon` NAME as text.
44600
- *
44601
- * Root-relative on purpose: it resolves against whatever origin serves a web
44602
- * client, and a native client joins it onto its own hub base.
44603
- *
44604
- * DECLARED here deliberately. It used to travel as an undeclared passthrough
44605
- * field that survived only because the runtime cap-router forwards provider
44606
- * output verbatim — so every consumer had to re-declare it by hand to stop
44607
- * its own Zod parse from stripping it, and the whole arrangement would have
44608
- * broken silently the moment output validation was tightened anywhere.
44609
- */
44610
- iconUrl: string().optional(),
44611
- /**
44612
- * Media type of {@link iconUrl} (`image/svg+xml`, `image/png`, …).
44613
- *
44614
- * The server knows this and therefore says it, because the client cannot
44615
- * safely guess: a React-Native client renders SVG and raster through two
44616
- * DIFFERENT components (`react-native-svg` vs `expo-image` — expo-image does
44617
- * not decode SVG on iOS/Android), so without this it silently fell back to a
44618
- * placeholder glyph for every vector icon while the web build looked fine.
44619
- *
44620
- * Absent when {@link iconUrl} is absent, or for a legacy provider that has
44621
- * not been updated — a client that cannot determine the type should prefer
44622
- * its raster path, which is the safe default for an unknown image.
44623
- */
44624
- iconMediaType: string().optional(),
44625
- configSchema: ConfigSchemaPassthrough$4,
44626
- /**
44627
- * The config keys that decide WHERE this kind's secrets are sent (server,
44628
- * base URL, instance, chat, recipient). A save that changes any of them
44629
- * while leaving a secret redacted is refused by the provider (D634), so an
44630
- * editor uses this to ask for the secret on exactly those edits instead of
44631
- * on every edit.
44632
- *
44633
- * Optional: absent from a provider that holds no secret (the Home Assistant
44634
- * kinds) and from a provider older than this field — an editor that finds
44635
- * it absent must assume ANY edit may need the secret.
44636
- */
44637
- destinationKeys: array(string()).optional(),
44638
- supportsDiscovery: boolean(),
44639
- /**
44640
- * Extra delivery parameters a rule may set for a target of this kind (D938).
44641
- * Absent = none; the rule editor then offers nothing.
44642
- */
44643
- deliveryParams: array(DeliveryParamSchema).optional(),
44644
- caps: TargetKindCapsSchema
44645
- });
44646
- /**
44647
- * A persisted target. `config` holds secrets; providers REDACT secret fields
44648
- * (return a presence marker only) when serving `listTargets` — never
44649
- * round-trip a stored secret to the UI.
44650
- */
44651
- var TargetSchema = object({
44652
- id: string(),
44653
- name: string(),
44654
- kind: string(),
44655
- addonId: string(),
44656
- enabled: boolean(),
44657
- config: record(string(), unknown())
44658
- });
44659
- /** A discovery-surfaced candidate (config is partial + non-secret). */
44660
- var DiscoveredTargetSchema = object({
44661
- kind: string(),
44662
- suggestedName: string(),
44663
- config: record(string(), unknown())
44664
- });
44665
- /** The degrade engine's report — what was resolved / dropped / degraded. */
44666
- var RenderedAsSchema = object({
44667
- level: string(),
44668
- format: NotificationFormatSchema,
44669
- attachmentsSent: number().int().nonnegative(),
44670
- actionsSent: number().int().nonnegative(),
44671
- truncated: boolean(),
44672
- dropped: array(string())
44673
- });
44674
- var SendResultSchema = object({
44675
- success: boolean(),
44676
- error: string().optional(),
44677
- renderedAs: RenderedAsSchema.optional()
44678
- });
44679
- /** Same shape as SendResult — kept as a distinct name for the test panel. */
44680
- var TestResultSchema = SendResultSchema;
44681
- /**
44682
- * Pre-save credential probe against a partial (unsaved) target config.
44683
- * `resolvedUrl` never includes secrets (token stripped from path).
44684
- */
44685
- var ProbeTargetConfigResultSchema = object({
44686
- ok: boolean(),
44687
- resolvedUrl: string(),
44688
- httpStatus: number().int().optional(),
44689
- stateInstance: string().optional(),
44690
- error: string().optional()
44691
- });
44692
- method(object({}), array(TargetKindSchema)), method(object({}), array(TargetSchema), { auth: "admin" }), method(object({ targetId: string() }), TargetSchema, { auth: "admin" }), method(object({
44693
- kind: string(),
44694
- config: record(string(), unknown()).optional(),
44695
- /**
44696
- * When editing / duplicating, the blank password field never round-trips
44697
- * the stored token. Pass the source target id so the provider can restore
44698
- * secrets server-side before dialling (same merge as upsert).
44699
- */
44700
- targetId: string().optional()
44701
- }), array(DiscoveredTargetSchema), { auth: "admin" }), method(object({
44702
- kind: string(),
44703
- config: record(string(), unknown()),
44704
- /** See `discoverTargets.targetId` — restore stored secrets for a blank password. */
44705
- targetId: string().optional()
44706
- }), ProbeTargetConfigResultSchema, {
44707
- kind: "mutation",
44708
- auth: "admin"
44709
- }), method(object({
44710
- targetId: string(),
44711
- notification: NotificationSchema
44712
- }), SendResultSchema, {
44713
- kind: "mutation",
44714
- auth: "admin"
44715
- }), method(object({
44716
- targetId: string(),
44717
- sample: NotificationSchema.optional()
44718
- }), TestResultSchema, {
44719
- kind: "mutation",
44720
- auth: "admin"
44721
- }), method(object({
44722
- target: TargetSchema,
44723
- /**
44724
- * Duplicate flow: create a NEW target id while copying secrets from an
44725
- * existing row. The UI never holds the stored token; blank / redacted
44726
- * password fields are restored from this source (D634 still applies if
44727
- * destinations diverge without a re-typed secret).
44728
- */
44729
- cloneSecretsFrom: string().optional()
44730
- }), TargetSchema, {
44731
- kind: "mutation",
44732
- auth: "admin"
44733
- }), method(object({ targetId: string() }), _void(), {
44734
- kind: "mutation",
44735
- auth: "admin"
44736
- }), method(object({
44737
- targetId: string(),
44738
- enabled: boolean()
44739
- }), _void(), {
44740
- kind: "mutation",
44741
- auth: "admin"
44742
- });
44743
44772
  _enum([
44744
44773
  "automation",
44745
44774
  "action",
@@ -49279,45 +49308,6 @@ method(object({
49279
49308
  kind: "mutation",
49280
49309
  auth: "admin"
49281
49310
  }), method(object({ blockIds: array(string()) }), object({ states: array(CompositionBlockStateSchema) }), { auth: "admin" });
49282
- var ConnectionTestOutcomeSchema = discriminatedUnion("outcome", [
49283
- object({
49284
- outcome: literal("validated"),
49285
- /** Round-trip of the sign-in, when the provider measured it. */
49286
- latencyMs: number().nonnegative().optional(),
49287
- /** Optional human detail worth showing next to the tick
49288
- * ("3 devices visible on this account"). */
49289
- detail: string().optional()
49290
- }).strict(),
49291
- object({
49292
- outcome: literal("rejected"),
49293
- error: string()
49294
- }).strict(),
49295
- object({
49296
- outcome: literal("inconclusive"),
49297
- error: string()
49298
- }).strict()
49299
- ]);
49300
- var ConnectionTestInputSchema = object({
49301
- /** Candidate integration settings, exactly as the create form collected them. */
49302
- settings: record(string(), unknown()) });
49303
- /**
49304
- * What the provider's test actually DOES, so the UI can say it in words before
49305
- * the operator presses the button ("Signs in to the Dreo cloud"). Purely
49306
- * descriptive — it never changes routing.
49307
- */
49308
- var ConnectionTestDescriptorSchema = object({ label: string() });
49309
- var connectionTestCapability = {
49310
- name: "connection-test",
49311
- scope: "system",
49312
- mode: "collection",
49313
- methods: {
49314
- testSettings: method(ConnectionTestInputSchema, ConnectionTestOutcomeSchema, {
49315
- kind: "mutation",
49316
- auth: "admin"
49317
- }),
49318
- describeTest: method(_void(), ConnectionTestDescriptorSchema, { auth: "admin" })
49319
- }
49320
- };
49321
49311
  /**
49322
49312
  * Upstream-system connectivity sensor — distinct from `device-status`,
49323
49313
  * which is the kernel-managed online/offline flag for the device's
@@ -56492,10 +56482,9 @@ var AvailableIntegrationTypeSchema = object({
56492
56482
  * locations" checkbox. Provider-declared in the addon manifest. */
56493
56483
  supportsLocationImport: boolean(),
56494
56484
  /**
56495
- * True when this integration DECLARES a pre-creation test (the
56496
- * `connection-test` cap, or a broker whose settings it stores). Drives the
56497
- * Test button: an integration that cannot be tested must say so up front
56498
- * rather than offering a button that always answers the same nonsense.
56485
+ * True when this integration's instances declare a Test (`integration-instances.describe().canTest`,
56486
+ * D1016). An integration that cannot be tested must say so up front rather than offering a
56487
+ * button that always answers the same nonsense.
56499
56488
  */
56500
56489
  canTest: boolean(),
56501
56490
  existingInstances: array(object({
@@ -56549,7 +56538,9 @@ var CreateIntegrationInputSchema = object({
56549
56538
  info: record(string(), unknown()).optional(),
56550
56539
  /** `stableId` of the discovery candidate the form was seeded from (D984). */
56551
56540
  originStableId: string().optional(),
56552
- settings: record(string(), unknown()).optional()
56541
+ settings: record(string(), unknown()).optional(),
56542
+ /** The instance kind being created, for a provider with several; omitted = its only testable kind. */
56543
+ kind: string().min(1).optional()
56553
56544
  });
56554
56545
  var UpdateIntegrationInputSchema = object({
56555
56546
  id: string(),
@@ -56575,13 +56566,7 @@ method(_void(), array(IntegrationWithStateSchema)), method(object({ id: string()
56575
56566
  }), method(object({ id: string() }), DeleteIntegrationResultSchema, {
56576
56567
  kind: "mutation",
56577
56568
  auth: "admin"
56578
- }), method(_void(), array(AvailableIntegrationTypeSchema), { auth: "admin" }), method(object({
56579
- addonId: string(),
56580
- settings: record(string(), unknown())
56581
- }), TestConnectionResultSchema, {
56582
- kind: "mutation",
56583
- auth: "admin"
56584
- });
56569
+ }), method(_void(), array(AvailableIntegrationTypeSchema), { auth: "admin" });
56585
56570
  /**
56586
56571
  * `integration-instances` - the connection of an addon that holds ONE or SEVERAL
56587
56572
  * (an account, a relay, a destination) as typed records (D985, D986). The addon's
@@ -65324,13 +65309,6 @@ var AddBrokerInputSchema = object({
65324
65309
  });
65325
65310
  var AddBrokerResultSchema = object({ id: string() });
65326
65311
  var IdInputSchema = object({ id: string() });
65327
- var TestResultSchema$1 = discriminatedUnion("ok", [object({
65328
- ok: literal(true),
65329
- latencyMs: number()
65330
- }), object({
65331
- ok: literal(false),
65332
- error: string()
65333
- })]);
65334
65312
  var StartEmbeddedInputSchema = object({
65335
65313
  port: number().int().min(1).max(65535).default(1883),
65336
65314
  /** Allow anonymous connect (no username/password). Default: false. */
@@ -65353,9 +65331,6 @@ method(_void(), array(BrokerInfoSchema)), method(IdInputSchema, BrokerConnection
65353
65331
  }), method(IdInputSchema, _void(), {
65354
65332
  kind: "mutation",
65355
65333
  auth: "admin"
65356
- }), method(IdInputSchema, TestResultSchema$1, {
65357
- kind: "mutation",
65358
- auth: "admin"
65359
65334
  }), method(StartEmbeddedInputSchema, StartEmbeddedResultSchema, {
65360
65335
  kind: "mutation",
65361
65336
  auth: "admin"
@@ -78462,7 +78437,7 @@ var TrainingProviderTypeSchema = object({
78462
78437
  label: string(),
78463
78438
  /** Path under the addon package (e.g. `assets/training-modal/icon.svg`). */
78464
78439
  iconAsset: string(),
78465
- /** Owning `training-provider` addon — collection selector for createEntry. */
78440
+ /** Owning `training-provider` addon. */
78466
78441
  addonId: string(),
78467
78442
  /**
78468
78443
  * Fields for one entry of this type (credentials + defaults). Absent on a
@@ -78507,36 +78482,6 @@ var TrainingProviderDescriptorSchema = object({
78507
78482
  */
78508
78483
  formValues: record(string(), unknown()).optional()
78509
78484
  });
78510
- /**
78511
- * Patch one entry's name, credentials and defaults. Pin with owning `{ addonId }`.
78512
- * An omitted or empty `tokenSecret` means KEEP the stored secret (D787).
78513
- * `{ $secretClear: true }` clears it.
78514
- */
78515
- var TrainingProviderUpdateEntryInputSchema = object({
78516
- entryId: string().min(1),
78517
- name: string().min(1),
78518
- tokenId: string().optional(),
78519
- tokenSecret: union([string(), object({ $secretClear: literal(true) })]).optional(),
78520
- environment: string().optional(),
78521
- gpuType: string().optional(),
78522
- region: string().optional(),
78523
- costCapUsd: number().nonnegative().optional(),
78524
- maxRuntimeSec: number().int().positive().optional(),
78525
- failedDatasetGraceHours: number().nonnegative().optional()
78526
- });
78527
- var TrainingCredentialCheckSchema = object({
78528
- ok: boolean(),
78529
- /** Workspace / account name, when the provider says. */
78530
- account: string().optional(),
78531
- reason: _enum([
78532
- "missing",
78533
- "invalid",
78534
- "forbidden",
78535
- "network",
78536
- "quota"
78537
- ]).optional(),
78538
- detail: string().optional()
78539
- });
78540
78485
  var ProviderJobStateSchema = _enum([
78541
78486
  "pending",
78542
78487
  "starting",
@@ -78584,22 +78529,6 @@ var TrainingLogLineSchema = object({
78584
78529
  text: string()
78585
78530
  });
78586
78531
  method(object({}), array(TrainingProviderDescriptorSchema).readonly(), { auth: "admin" }), method(object({}), array(TrainingProviderTypeSchema).readonly(), { auth: "admin" }), method(object({}), array(TrainingProviderEntrySchema).readonly(), { auth: "admin" }), method(object({
78587
- typeId: string().min(1),
78588
- name: string().min(1)
78589
- }), object({ entryId: string() }), {
78590
- kind: "mutation",
78591
- auth: "admin"
78592
- }), method(object({ entryId: string().min(1) }), object({ ok: literal(true) }), {
78593
- kind: "mutation",
78594
- auth: "admin"
78595
- }), method(TrainingProviderUpdateEntryInputSchema, object({ ok: literal(true) }), {
78596
- kind: "mutation",
78597
- auth: "admin"
78598
- }), method(object({ entryId: string().min(1) }), TrainingCredentialCheckSchema, {
78599
- kind: "mutation",
78600
- auth: "admin",
78601
- timeoutMs: 3e4
78602
- }), method(object({
78603
78532
  entryId: string().min(1),
78604
78533
  gpuType: string(),
78605
78534
  region: string(),
@@ -84052,20 +83981,6 @@ Object.freeze({
84052
83981
  access: "view",
84053
83982
  role: "admin"
84054
83983
  },
84055
- "connectionTest.describeTest": {
84056
- capName: "connection-test",
84057
- capScope: "system",
84058
- addonId: null,
84059
- access: "view",
84060
- role: "admin"
84061
- },
84062
- "connectionTest.testSettings": {
84063
- capName: "connection-test",
84064
- capScope: "system",
84065
- addonId: null,
84066
- access: "create",
84067
- role: "admin"
84068
- },
84069
83984
  "connectivity.getStatus": {
84070
83985
  capName: "connectivity",
84071
83986
  capScope: "device",
@@ -86432,13 +86347,6 @@ Object.freeze({
86432
86347
  access: "view",
86433
86348
  role: "admin"
86434
86349
  },
86435
- "integrations.testConnection": {
86436
- capName: "integrations",
86437
- capScope: "system",
86438
- addonId: null,
86439
- access: "create",
86440
- role: "admin"
86441
- },
86442
86350
  "integrations.update": {
86443
86351
  capName: "integrations",
86444
86352
  capScope: "system",
@@ -87671,13 +87579,6 @@ Object.freeze({
87671
87579
  access: "create",
87672
87580
  role: "admin"
87673
87581
  },
87674
- "mqttBroker.testConnection": {
87675
- capName: "mqtt-broker",
87676
- capScope: "system",
87677
- addonId: null,
87678
- access: "create",
87679
- role: "admin"
87680
- },
87681
87582
  "nativeObjectDetection.getOptions": {
87682
87583
  capName: "native-object-detection",
87683
87584
  capScope: "device",
@@ -92508,20 +92409,6 @@ Object.freeze({
92508
92409
  access: "create",
92509
92410
  role: "admin"
92510
92411
  },
92511
- "trainingProvider.createEntry": {
92512
- capName: "training-provider",
92513
- capScope: "system",
92514
- addonId: null,
92515
- access: "create",
92516
- role: "admin"
92517
- },
92518
- "trainingProvider.deleteEntry": {
92519
- capName: "training-provider",
92520
- capScope: "system",
92521
- addonId: null,
92522
- access: "delete",
92523
- role: "admin"
92524
- },
92525
92412
  "trainingProvider.describe": {
92526
92413
  capName: "training-provider",
92527
92414
  capScope: "system",
@@ -92592,13 +92479,6 @@ Object.freeze({
92592
92479
  access: "create",
92593
92480
  role: "admin"
92594
92481
  },
92595
- "trainingProvider.updateEntry": {
92596
- capName: "training-provider",
92597
- capScope: "system",
92598
- addonId: null,
92599
- access: "create",
92600
- role: "admin"
92601
- },
92602
92482
  "trainingProvider.uploadDataset": {
92603
92483
  capName: "training-provider",
92604
92484
  capScope: "system",
@@ -92606,13 +92486,6 @@ Object.freeze({
92606
92486
  access: "create",
92607
92487
  role: "admin"
92608
92488
  },
92609
- "trainingProvider.validateCredentials": {
92610
- capName: "training-provider",
92611
- capScope: "system",
92612
- addonId: null,
92613
- access: "create",
92614
- role: "admin"
92615
- },
92616
92489
  "turnProvider.getTurnServers": {
92617
92490
  capName: "turn-provider",
92618
92491
  capScope: "system",
@@ -122254,6 +122127,7 @@ function settingsReadOf(resolved) {
122254
122127
  };
122255
122128
  }
122256
122129
  function buildHomematicInstances(records, deps) {
122130
+ const handle = records.kind(homematicConnectionsEntryKind);
122257
122131
  return new RecordIntegrationInstances(records, homematicConnectionsEntryKind, {
122258
122132
  description: {
122259
122133
  role: "devices",
@@ -122263,12 +122137,33 @@ function buildHomematicInstances(records, deps) {
122263
122137
  },
122264
122138
  instanceMode: "multiple",
122265
122139
  kind: "connection",
122266
- canTest: false
122140
+ canTest: true
122267
122141
  },
122268
122142
  formSchema: () => buildConnectionFormSchema(),
122269
122143
  initialBody: (name) => ({ name }),
122270
122144
  configured: (body) => (body.host ?? "").trim().length > 0,
122271
- onChanged: () => deps.onChanged()
122145
+ onChanged: () => deps.onChanged(),
122146
+ test: async ({ id, values }) => {
122147
+ const stored = id === null ? null : (await handle.getResolved(id))?.data ?? null;
122148
+ const typed = values["password"];
122149
+ const password = typeof typed === "string" && typed !== "" && typed !== "__camstack_redacted__" ? typed : stored?.password ?? "";
122150
+ const outcome = await deps.tester.testSettings({ settings: {
122151
+ ...stored === null ? {} : connectionSettingsOf(stored),
122152
+ ...values,
122153
+ password
122154
+ } });
122155
+ if (outcome.outcome === "validated") return {
122156
+ success: true,
122157
+ status: "validated",
122158
+ ...outcome.latencyMs !== void 0 ? { latencyMs: outcome.latencyMs } : {},
122159
+ ...outcome.detail !== void 0 ? { detail: outcome.detail } : {}
122160
+ };
122161
+ return {
122162
+ success: false,
122163
+ status: outcome.outcome,
122164
+ error: outcome.error
122165
+ };
122166
+ }
122272
122167
  });
122273
122168
  }
122274
122169
  /** The ONE reader of a CCU's connection: the integration's record, never the legacy rows. */
@@ -125610,7 +125505,6 @@ var HmClientRegistry = class {
125610
125505
  };
125611
125506
  //#endregion
125612
125507
  //#region src/homematic-connection-test.ts
125613
- var TEST_LABEL = "Asks each enabled XML-RPC interface of the CCU for its methods, and signs in to the WebUI when credentials are set";
125614
125508
  /** How long one request to the CCU may take before the test gives up on it. */
125615
125509
  var PROBE_TIMEOUT_MS = 5e3;
125616
125510
  /** The ports the wrapped library binds each interface on (plain, TLS) and the path it serves. */
@@ -125764,65 +125658,62 @@ function describeSuccess(result) {
125764
125658
  }
125765
125659
  function buildHomematicConnectionTestProvider(deps) {
125766
125660
  const { logger, probe = probeCcu } = deps;
125767
- return {
125768
- describeTest: async () => ({ label: TEST_LABEL }),
125769
- testSettings: async ({ settings }) => {
125770
- if (readHost(settings) === null) return {
125771
- outcome: "rejected",
125772
- error: "Enter the CCU host or IP address."
125773
- };
125774
- const connection = connectionFromSettings(settings);
125775
- if (connection === null) return {
125776
- outcome: "rejected",
125777
- error: "Some of the connection settings are not valid."
125778
- };
125779
- const interfaces = enabledInterfaces(connection);
125780
- if (interfaces.length === 0) return {
125781
- outcome: "rejected",
125782
- error: "Enable at least one interface."
125661
+ return { testSettings: async ({ settings }) => {
125662
+ if (readHost(settings) === null) return {
125663
+ outcome: "rejected",
125664
+ error: "Enter the CCU host or IP address."
125665
+ };
125666
+ const connection = connectionFromSettings(settings);
125667
+ if (connection === null) return {
125668
+ outcome: "rejected",
125669
+ error: "Some of the connection settings are not valid."
125670
+ };
125671
+ const interfaces = enabledInterfaces(connection);
125672
+ if (interfaces.length === 0) return {
125673
+ outcome: "rejected",
125674
+ error: "Enable at least one interface."
125675
+ };
125676
+ const startedAt = Date.now();
125677
+ try {
125678
+ const result = await probe({
125679
+ host: connection.host,
125680
+ tls: connection.tls,
125681
+ username: connection.username,
125682
+ password: connection.password,
125683
+ interfaces
125684
+ });
125685
+ return {
125686
+ outcome: "validated",
125687
+ latencyMs: Date.now() - startedAt,
125688
+ detail: describeSuccess(result)
125783
125689
  };
125784
- const startedAt = Date.now();
125785
- try {
125786
- const result = await probe({
125787
- host: connection.host,
125788
- tls: connection.tls,
125789
- username: connection.username,
125790
- password: connection.password,
125791
- interfaces
125792
- });
125793
- return {
125794
- outcome: "validated",
125795
- latencyMs: Date.now() - startedAt,
125796
- detail: describeSuccess(result)
125690
+ } catch (err) {
125691
+ const kind = err instanceof CcuProbeError ? err.kind : "other";
125692
+ logger.warn("Homematic connection test failed", { meta: {
125693
+ host: connection.host,
125694
+ kind,
125695
+ error: errMsg(err)
125696
+ } });
125697
+ switch (kind) {
125698
+ case "bad-credentials": return {
125699
+ outcome: "rejected",
125700
+ error: "The CCU refused the WebUI username or password."
125701
+ };
125702
+ case "not-a-ccu": return {
125703
+ outcome: "rejected",
125704
+ error: `${connection.host} did not answer as a CCU3 or RaspberryMatic. Check the address.`
125705
+ };
125706
+ case "unreachable": return {
125707
+ outcome: "inconclusive",
125708
+ error: `Could not reach the CCU at ${connection.host}: ${errMsg(err)}`
125709
+ };
125710
+ case "other": return {
125711
+ outcome: "inconclusive",
125712
+ error: `The CCU test did not finish: ${errMsg(err)}`
125797
125713
  };
125798
- } catch (err) {
125799
- const kind = err instanceof CcuProbeError ? err.kind : "other";
125800
- logger.warn("Homematic connection test failed", { meta: {
125801
- host: connection.host,
125802
- kind,
125803
- error: errMsg(err)
125804
- } });
125805
- switch (kind) {
125806
- case "bad-credentials": return {
125807
- outcome: "rejected",
125808
- error: "The CCU refused the WebUI username or password."
125809
- };
125810
- case "not-a-ccu": return {
125811
- outcome: "rejected",
125812
- error: `${connection.host} did not answer as a CCU3 or RaspberryMatic. Check the address.`
125813
- };
125814
- case "unreachable": return {
125815
- outcome: "inconclusive",
125816
- error: `Could not reach the CCU at ${connection.host}: ${errMsg(err)}`
125817
- };
125818
- case "other": return {
125819
- outcome: "inconclusive",
125820
- error: `The CCU test did not finish: ${errMsg(err)}`
125821
- };
125822
- }
125823
125714
  }
125824
125715
  }
125825
- };
125716
+ } };
125826
125717
  }
125827
125718
  //#endregion
125828
125719
  //#region src/homematic-integration-device-cascade.ts
@@ -125920,7 +125811,10 @@ var HomematicProviderAddon = class extends BaseDeviceProvider {
125920
125811
  const records = this.ctx.records;
125921
125812
  if (records === void 0) throw new Error("provider-homematic: ctx.records is required (hub-only addon)");
125922
125813
  await records.declare(homematicRecordKinds);
125923
- const instances = buildHomematicInstances(records, { onChanged: () => this.reconcileIntegrations() });
125814
+ const instances = buildHomematicInstances(records, {
125815
+ onChanged: () => this.reconcileIntegrations(),
125816
+ tester: this.buildConnectionTestProvider()
125817
+ });
125924
125818
  this.instances = instances;
125925
125819
  this.declareRegistrySwitch({
125926
125820
  kind: homematicConnectionsEntryKind,
@@ -125959,10 +125853,6 @@ var HomematicProviderAddon = class extends BaseDeviceProvider {
125959
125853
  capability: deviceAdoptionCapability,
125960
125854
  provider: this.buildAdoptionProvider()
125961
125855
  },
125962
- {
125963
- capability: connectionTestCapability,
125964
- provider: this.buildConnectionTestProvider()
125965
- },
125966
125856
  {
125967
125857
  capability: addonPagesSourceCapability,
125968
125858
  provider: this.buildPagesProvider()