@camstack/addon-provider-hikvision 1.2.184 → 1.2.185

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
@@ -5989,7 +5989,7 @@ var ZodIssueCode = {
5989
5989
  var ZodFirstPartyTypeKind;
5990
5990
  ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {});
5991
5991
  //#endregion
5992
- //#region ../types/dist/sleep-CmjWurK5.mjs
5992
+ //#region ../types/dist/sleep-D7ZKm4nb.mjs
5993
5993
  /**
5994
5994
  * The audio chunk plane's byte format, and the ONE expansion from a coded
5995
5995
  * window to float samples (D455).
@@ -6784,10 +6784,33 @@ function defaultIntegrationDepsOver(api) {
6784
6784
  };
6785
6785
  }
6786
6786
  var PREFIX = "records/";
6787
+ /**
6788
+ * Cross-realm brand. An addon bundles its own copy of this module (D15) while
6789
+ * `ctx.records` is the HOST's door, so an error thrown by the host is an
6790
+ * instance of the host's classes, not of the addon's. The brand plus the code
6791
+ * make `instanceof` answer by identity of the failure, not of the copy.
6792
+ */
6793
+ var RECORDS_ERROR_BRAND = Symbol.for("camstack.records-error");
6794
+ function carriesBrand(value) {
6795
+ return typeof value === "object" && value !== null && Reflect.get(value, RECORDS_ERROR_BRAND) === true;
6796
+ }
6787
6797
  /** The base of every records failure. `detail` is the human part of the message. */
6788
6798
  var RecordsError = class extends Error {
6799
+ /** The code a subclass stands for; the base stands for every code. */
6800
+ static code = void 0;
6801
+ /**
6802
+ * `instanceof` across copies of this module: any branded error is a
6803
+ * `RecordsError`, and is an instance of a subclass only when its code is the
6804
+ * subclass's code. Same-copy answers are unchanged.
6805
+ */
6806
+ static [Symbol.hasInstance](value) {
6807
+ if (Function.prototype[Symbol.hasInstance].call(this, value)) return true;
6808
+ if (!carriesBrand(value)) return false;
6809
+ return this.code === void 0 || value.code === this.code;
6810
+ }
6789
6811
  code;
6790
6812
  detail;
6813
+ [RECORDS_ERROR_BRAND] = true;
6791
6814
  constructor(code, detail) {
6792
6815
  super(`${PREFIX}${code}: ${detail}`);
6793
6816
  this.name = "RecordsError";
@@ -6796,29 +6819,33 @@ var RecordsError = class extends Error {
6796
6819
  }
6797
6820
  };
6798
6821
  /** A write guarded by `ifRev` found another revision (or an existing row for `ifRev: 0`). */
6799
- var RevConflictError = class extends RecordsError {
6822
+ var RevConflictError = class RevConflictError extends RecordsError {
6823
+ static code = "rev-conflict";
6800
6824
  constructor(detail) {
6801
- super("rev-conflict", detail);
6825
+ super(RevConflictError.code, detail);
6802
6826
  this.name = "RevConflictError";
6803
6827
  }
6804
6828
  };
6805
6829
  /** The keychain could not store or serve a value: explicit, never an empty string. */
6806
- var RecordSecretUnavailableError = class extends RecordsError {
6830
+ var RecordSecretUnavailableError = class RecordSecretUnavailableError extends RecordsError {
6831
+ static code = "secret-unavailable";
6807
6832
  constructor(detail) {
6808
- super("secret-unavailable", detail);
6833
+ super(RecordSecretUnavailableError.code, detail);
6809
6834
  this.name = "RecordSecretUnavailableError";
6810
6835
  }
6811
6836
  };
6812
- var InvalidRecordError = class extends RecordsError {
6837
+ var InvalidRecordError = class InvalidRecordError extends RecordsError {
6838
+ static code = "invalid-record";
6813
6839
  constructor(detail) {
6814
- super("invalid-record", detail);
6840
+ super(InvalidRecordError.code, detail);
6815
6841
  this.name = "InvalidRecordError";
6816
6842
  }
6817
6843
  };
6818
6844
  /** A kind declaration the engine refuses (non-additive change, bad shape, wrong file). */
6819
- var DeclarationRefusedError = class extends RecordsError {
6845
+ var DeclarationRefusedError = class DeclarationRefusedError extends RecordsError {
6846
+ static code = "declaration-refused";
6820
6847
  constructor(detail) {
6821
- super("declaration-refused", detail);
6848
+ super(DeclarationRefusedError.code, detail);
6822
6849
  this.name = "DeclarationRefusedError";
6823
6850
  }
6824
6851
  };
@@ -9622,286 +9649,6 @@ function normalizeAddonInitResult(result) {
9622
9649
  if (Array.isArray(result)) return { providers: result };
9623
9650
  return result;
9624
9651
  }
9625
- /**
9626
- * The share-view scope kinds a share-link token can carry. The hub mints
9627
- * and validates them (`ShareViewGrantSchema` builds its
9628
- * enum from this list); a data plane names the kinds it ACCEPTS in `share`.
9629
- */
9630
- var SHARE_VIEW_KINDS = ["grid-view", "events-view"];
9631
- /** The wire shape of {@link PeerBytesTicket} — see the type for what it is. */
9632
- var PeerBytesTicketSchema = object({
9633
- /** `http://127.0.0.1:<port>/<token>`. One `GET` takes it. */
9634
- url: string().min(1),
9635
- /**
9636
- * The HOST node this URL means something on — the hub or a named agent,
9637
- * never a runner. {@link AddonPeerBytes.open} compares it to its own and
9638
- * refuses `cross-node` by name when they differ, without dialling.
9639
- */
9640
- hostNodeId: string().min(1),
9641
- expiresAtMs: number().int().nonnegative(),
9642
- /**
9643
- * What the producer DECLARED the body to be, when it knows — `null` when it
9644
- * does not. Never `0` for unknown (D393): a consumer sizing a bound off this
9645
- * must be able to tell "the producer did not say" from "the body is empty".
9646
- */
9647
- declaredBytes: number().int().nonnegative().nullable()
9648
- });
9649
- function defOf(schema) {
9650
- const zodBag = Reflect.get(schema, "_zod");
9651
- if (typeof zodBag !== "object" || zodBag === null) return {};
9652
- const def = Reflect.get(zodBag, "def");
9653
- if (typeof def !== "object" || def === null) return {};
9654
- return def;
9655
- }
9656
- function declaredHere(schema) {
9657
- return globalRegistry.get(schema)?.secret === true;
9658
- }
9659
- /** Wrapper kinds whose `innerType` is the field itself. */
9660
- var WRAPPERS = new Set([
9661
- "optional",
9662
- "nullable",
9663
- "default",
9664
- "prefault",
9665
- "catch",
9666
- "readonly",
9667
- "nonoptional"
9668
- ]);
9669
- /**
9670
- * The schema layers that make up ONE field: the schema itself and every
9671
- * wrapper below it (optional / default / nullable / readonly / catch), plus
9672
- * both sides of a pipe (`z.preprocess` puts the real schema on `out`,
9673
- * `.transform` on `in`).
9674
- */
9675
- function layersOf(schema) {
9676
- const out = [];
9677
- const queue = [schema];
9678
- while (queue.length > 0) {
9679
- const s = queue.shift();
9680
- if (!s || out.includes(s)) continue;
9681
- out.push(s);
9682
- const def = defOf(s);
9683
- if (def.type !== void 0 && WRAPPERS.has(def.type) && def.innerType) queue.push(def.innerType);
9684
- if (def.type === "pipe") {
9685
- if (def.in) queue.push(def.in);
9686
- if (def.out) queue.push(def.out);
9687
- }
9688
- }
9689
- return out;
9690
- }
9691
- /** True when any layer of this field declares `.meta({ secret: true })`. */
9692
- function isZodSecret(schema) {
9693
- return layersOf(schema).some(declaredHere);
9694
- }
9695
- /**
9696
- * Every declared secret path in a config schema: dotted keys, `[]` for "each
9697
- * element of this array" (`connection.password`, `rows[].token`), `{}` for "each value of this
9698
- * map" (`applianceSecrets{}`). A declared
9699
- * object or array is reported as one path and not descended into — everything
9700
- * under it is secret.
9701
- */
9702
- function collectZodSecretPaths(schema, prefix = "") {
9703
- if (isZodSecret(schema)) return prefix.length > 0 ? [prefix] : [];
9704
- const paths = [];
9705
- for (const layer of layersOf(schema)) {
9706
- const def = defOf(layer);
9707
- if (def.type === "object" && def.shape) for (const [key, child] of Object.entries(def.shape)) paths.push(...collectZodSecretPaths(child, prefix ? `${prefix}.${key}` : key));
9708
- else if (def.type === "array" && def.element) paths.push(...collectZodSecretPaths(def.element, `${prefix}[]`));
9709
- else if (def.type === "record" && def.valueType) paths.push(...collectZodSecretPaths(def.valueType, `${prefix}{}`));
9710
- else if (def.type === "union" && def.options) for (const option of def.options) paths.push(...collectZodSecretPaths(option, prefix));
9711
- else if (def.type === "intersection") {
9712
- if (def.left) paths.push(...collectZodSecretPaths(def.left, prefix));
9713
- if (def.right) paths.push(...collectZodSecretPaths(def.right, prefix));
9714
- }
9715
- }
9716
- return [...new Set(paths)];
9717
- }
9718
- /**
9719
- * Record kinds (D881): the declaration an addon makes of one kind of fact, the
9720
- * Zod row schema that describes it, and the helper that turns the two into the
9721
- * JSON the engine stores.
9722
- *
9723
- * A kind is declared ONCE, next to the code that owns it, and the engine's
9724
- * reconciler creates its indexes - nothing creates DDL at runtime from a write.
9725
- * Everything the generic machinery needs (secret fields, the entry descriptor)
9726
- * is DERIVED from the Zod schema: `.meta({ secret: true })` marks a credential,
9727
- * never a field name (D879).
9728
- */
9729
- /** A JSON field path: `trackId`, `auth.accessToken`. Charset-restricted: it is rendered into DDL. */
9730
- var RecordFieldPathSchema = string().regex(/^[A-Za-z_][A-Za-z0-9_]{0,63}(\.[A-Za-z_][A-Za-z0-9_]{0,63}){0,3}$/);
9731
- var RecordIndexSchema = object({
9732
- name: string().regex(/^[a-z][a-z0-9_]{0,31}$/),
9733
- fields: array(RecordFieldPathSchema).min(1).max(4),
9734
- unique: boolean().optional()
9735
- }).strict();
9736
- var RecordRetentionSchema = union([
9737
- object({
9738
- ttlMs: number().int().positive(),
9739
- from: _enum(["at", "write"])
9740
- }).strict(),
9741
- object({
9742
- maxRows: number().int().positive().optional(),
9743
- maxRowsPerDevice: number().int().positive().optional()
9744
- }).strict().refine((r) => r.maxRows !== void 0 || r.maxRowsPerDevice !== void 0, { message: "name maxRows, maxRowsPerDevice or both" }),
9745
- object({
9746
- owner: string().min(1),
9747
- reason: string().min(1)
9748
- }).strict(),
9749
- object({ none: string().min(1) }).strict()
9750
- ]);
9751
- /** The descriptor a generic entries UI reads (D881 "generic entries"). */
9752
- var EntryDescriptorSchema = object({
9753
- title: string().min(1),
9754
- /** The record body field shown as the entry's name. */
9755
- nameField: string().min(1),
9756
- /** JSON Schema of the entry body; `secret: true` marks a password field. */
9757
- fields: record(string(), unknown())
9758
- }).strict();
9759
- /** What crosses the wire from an addon: JSON only, no Zod. An unknown key is refused. */
9760
- var RecordKindDeclarationSchema = object({
9761
- database: _enum(RECORD_DATABASES).default("settings"),
9762
- class: _enum(RECORD_CLASSES),
9763
- writeTrigger: string().min(1),
9764
- device: _enum([
9765
- "required",
9766
- "optional",
9767
- "none"
9768
- ]).default("none"),
9769
- at: _enum(["required", "none"]).default("none"),
9770
- indexes: array(RecordIndexSchema).max(8).default([]),
9771
- retention: RecordRetentionSchema,
9772
- deviceRemoval: _enum(["delete", "none"]).default("none"),
9773
- maxDataBytes: number().int().positive().max(RECORD_MAX_DATA_BYTES).default(RECORD_DEFAULT_MAX_DATA_BYTES),
9774
- /** Derived from the Zod schema; never written by hand. */
9775
- secretPaths: array(string().min(1)).default([]),
9776
- /** The id key of each array that carries a secret (`{ headers: 'name' }`). */
9777
- secretArrayKeys: record(string(), string()).default({}),
9778
- /** Kinds that must agree through `transact` sit in one file under one family name. */
9779
- transactFamily: string().min(1).optional(),
9780
- entry: EntryDescriptorSchema.optional()
9781
- }).strict();
9782
- /** The kind names: lower-case, dash separated, short enough for an index name. */
9783
- var RecordKindNameSchema = string().regex(/^[a-z][a-z0-9-]{0,47}$/);
9784
- /** Cross-field rules a declaration must satisfy. Throws {@link DeclarationRefusedError}. */
9785
- function assertValidDeclaration(name, decl) {
9786
- const refuse = (why) => {
9787
- throw new DeclarationRefusedError(`kind "${name}": ${why}`);
9788
- };
9789
- if (!RecordKindNameSchema.safeParse(name).success) refuse("the name must be lower-case-dashed");
9790
- const seen = /* @__PURE__ */ new Set();
9791
- for (const index of decl.indexes) {
9792
- if (seen.has(index.name)) refuse(`index name "${index.name}" is declared twice`);
9793
- seen.add(index.name);
9794
- }
9795
- const { retention } = decl;
9796
- const hasSecrets = decl.secretPaths.length > 0;
9797
- if ("ttlMs" in retention) {
9798
- if (retention.from === "at" && decl.at !== "required") refuse("a ttl from \"at\" needs at: \"required\"");
9799
- if (hasSecrets) refuse("a kind with secret fields cannot use engine TTL (its keychain values would be orphaned)");
9800
- }
9801
- if ("maxRows" in retention || "maxRowsPerDevice" in retention) {
9802
- if (retention.maxRowsPerDevice !== void 0 && decl.device !== "required") refuse("maxRowsPerDevice needs device: \"required\"");
9803
- if (decl.at !== "required") refuse("a row bound trims the oldest \"at\": it needs at: \"required\"");
9804
- if (hasSecrets) refuse("a kind with secret fields cannot use an engine row bound");
9805
- const bound = Math.max(retention.maxRows ?? 0, retention.maxRowsPerDevice ?? 0);
9806
- 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)`);
9807
- }
9808
- if (decl.deviceRemoval === "delete" && decl.device === "none") refuse("deviceRemoval: \"delete\" needs a device: \"required\" or \"optional\"");
9809
- 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`);
9810
- }
9811
- function bodyFieldsOf(schema) {
9812
- return { ...toJSONSchema(schema, {
9813
- unrepresentable: "any",
9814
- io: "input"
9815
- }) };
9816
- }
9817
- function isRecordLike(value) {
9818
- return typeof value === "object" && value !== null && !Array.isArray(value);
9819
- }
9820
- /** Does every branch of the body schema carry `field`? (A discriminated union has several.) */
9821
- function hasNameField(json, field) {
9822
- const branches = json["oneOf"] ?? json["anyOf"];
9823
- if (Array.isArray(branches)) return branches.length > 0 && branches.every((b) => isRecordLike(b) && hasNameField(b, field));
9824
- const properties = json["properties"];
9825
- return isRecordLike(properties) && Object.prototype.hasOwnProperty.call(properties, field);
9826
- }
9827
- /**
9828
- * Declare the kinds of a package. The keys are the kind names. The result is
9829
- * what `ctx.records.declare` sends to the engine and what `ctx.records.kind`
9830
- * types its handle from.
9831
- */
9832
- function defineRecordKinds(specs) {
9833
- const out = {};
9834
- for (const [name, spec] of Object.entries(specs)) {
9835
- const secretPaths = collectZodSecretPaths(spec.schema);
9836
- const nameField = spec.entry?.nameField ?? "name";
9837
- const fields = bodyFieldsOf(spec.schema);
9838
- if (spec.entry !== void 0 && !hasNameField(fields, nameField)) throw new DeclarationRefusedError(`kind "${name}": an entry kind's schema needs a "${nameField}" field`);
9839
- const parsed = RecordKindDeclarationSchema.parse({
9840
- database: spec.database,
9841
- class: spec.class,
9842
- writeTrigger: spec.writeTrigger,
9843
- device: spec.device,
9844
- at: spec.at,
9845
- indexes: spec.indexes === void 0 ? void 0 : [...spec.indexes],
9846
- retention: spec.retention,
9847
- deviceRemoval: spec.deviceRemoval,
9848
- maxDataBytes: spec.maxDataBytes,
9849
- secretPaths: [...new Set([...secretPaths, ...spec.retiredSecretPaths ?? []])],
9850
- secretArrayKeys: spec.secretArrayKeys === void 0 ? void 0 : { ...spec.secretArrayKeys },
9851
- transactFamily: spec.transactFamily,
9852
- entry: spec.entry === void 0 ? void 0 : {
9853
- title: spec.entry.title,
9854
- nameField,
9855
- fields
9856
- }
9857
- });
9858
- assertValidDeclaration(name, parsed);
9859
- out[name] = {
9860
- name,
9861
- schema: spec.schema,
9862
- declaration: parsed
9863
- };
9864
- }
9865
- return out;
9866
- }
9867
- /**
9868
- * Entry kinds (D881): every list of user-created entries (notification
9869
- * targets, brokers, LLM profiles) is ONE record kind with an id, a name and a
9870
- * kind-specific body, and the admin UI lists/adds/edits/deletes all of them
9871
- * through the `record-entries` capability with password fields derived from
9872
- * the schema (`.meta({ secret: true })`).
9873
- */
9874
- /** The body of a plain entry: a name and the fields the kind adds. */
9875
- function entryBody(shape) {
9876
- return object({
9877
- name: string().min(1),
9878
- enabled: boolean().optional(),
9879
- ...shape
9880
- });
9881
- }
9882
- /**
9883
- * Declare one entry kind. An entry is configuration: never trimmed by the
9884
- * engine, never aged, belonging to no device.
9885
- */
9886
- function defineEntryKind(name, spec) {
9887
- const defined = defineRecordKinds({ [name]: {
9888
- schema: spec.schema,
9889
- class: "config",
9890
- writeTrigger: spec.writeTrigger ?? "an operator adds or edits an entry in the entries UI",
9891
- retention: { none: "an entry goes only when the operator deletes it" },
9892
- ...spec.maxDataBytes === void 0 ? {} : { maxDataBytes: spec.maxDataBytes },
9893
- ...spec.database === void 0 ? {} : { database: spec.database },
9894
- ...spec.indexes === void 0 ? {} : { indexes: spec.indexes },
9895
- ...spec.secretArrayKeys === void 0 ? {} : { secretArrayKeys: spec.secretArrayKeys },
9896
- ...spec.retiredSecretPaths === void 0 ? {} : { retiredSecretPaths: spec.retiredSecretPaths },
9897
- entry: {
9898
- title: spec.title,
9899
- ...spec.nameField === void 0 ? {} : { nameField: spec.nameField }
9900
- }
9901
- } })[name];
9902
- if (defined === void 0) throw new DeclarationRefusedError(`entry kind "${name}" was not built`);
9903
- return defined;
9904
- }
9905
9652
  object({
9906
9653
  field: string().min(1),
9907
9654
  on: literal("advance")
@@ -9994,6 +9741,286 @@ function optionalMethod(input, output, options) {
9994
9741
  function event(data) {
9995
9742
  return { data };
9996
9743
  }
9744
+ function defOf(schema) {
9745
+ const zodBag = Reflect.get(schema, "_zod");
9746
+ if (typeof zodBag !== "object" || zodBag === null) return {};
9747
+ const def = Reflect.get(zodBag, "def");
9748
+ if (typeof def !== "object" || def === null) return {};
9749
+ return def;
9750
+ }
9751
+ function declaredHere(schema) {
9752
+ return globalRegistry.get(schema)?.secret === true;
9753
+ }
9754
+ /** Wrapper kinds whose `innerType` is the field itself. */
9755
+ var WRAPPERS = new Set([
9756
+ "optional",
9757
+ "nullable",
9758
+ "default",
9759
+ "prefault",
9760
+ "catch",
9761
+ "readonly",
9762
+ "nonoptional"
9763
+ ]);
9764
+ /**
9765
+ * The schema layers that make up ONE field: the schema itself and every
9766
+ * wrapper below it (optional / default / nullable / readonly / catch), plus
9767
+ * both sides of a pipe (`z.preprocess` puts the real schema on `out`,
9768
+ * `.transform` on `in`).
9769
+ */
9770
+ function layersOf(schema) {
9771
+ const out = [];
9772
+ const queue = [schema];
9773
+ while (queue.length > 0) {
9774
+ const s = queue.shift();
9775
+ if (!s || out.includes(s)) continue;
9776
+ out.push(s);
9777
+ const def = defOf(s);
9778
+ if (def.type !== void 0 && WRAPPERS.has(def.type) && def.innerType) queue.push(def.innerType);
9779
+ if (def.type === "pipe") {
9780
+ if (def.in) queue.push(def.in);
9781
+ if (def.out) queue.push(def.out);
9782
+ }
9783
+ }
9784
+ return out;
9785
+ }
9786
+ /** True when any layer of this field declares `.meta({ secret: true })`. */
9787
+ function isZodSecret(schema) {
9788
+ return layersOf(schema).some(declaredHere);
9789
+ }
9790
+ /**
9791
+ * Every declared secret path in a config schema: dotted keys, `[]` for "each
9792
+ * element of this array" (`connection.password`, `rows[].token`), `{}` for "each value of this
9793
+ * map" (`applianceSecrets{}`). A declared
9794
+ * object or array is reported as one path and not descended into — everything
9795
+ * under it is secret.
9796
+ */
9797
+ function collectZodSecretPaths(schema, prefix = "") {
9798
+ if (isZodSecret(schema)) return prefix.length > 0 ? [prefix] : [];
9799
+ const paths = [];
9800
+ for (const layer of layersOf(schema)) {
9801
+ const def = defOf(layer);
9802
+ if (def.type === "object" && def.shape) for (const [key, child] of Object.entries(def.shape)) paths.push(...collectZodSecretPaths(child, prefix ? `${prefix}.${key}` : key));
9803
+ else if (def.type === "array" && def.element) paths.push(...collectZodSecretPaths(def.element, `${prefix}[]`));
9804
+ else if (def.type === "record" && def.valueType) paths.push(...collectZodSecretPaths(def.valueType, `${prefix}{}`));
9805
+ else if (def.type === "union" && def.options) for (const option of def.options) paths.push(...collectZodSecretPaths(option, prefix));
9806
+ else if (def.type === "intersection") {
9807
+ if (def.left) paths.push(...collectZodSecretPaths(def.left, prefix));
9808
+ if (def.right) paths.push(...collectZodSecretPaths(def.right, prefix));
9809
+ }
9810
+ }
9811
+ return [...new Set(paths)];
9812
+ }
9813
+ /**
9814
+ * Record kinds (D881): the declaration an addon makes of one kind of fact, the
9815
+ * Zod row schema that describes it, and the helper that turns the two into the
9816
+ * JSON the engine stores.
9817
+ *
9818
+ * A kind is declared ONCE, next to the code that owns it, and the engine's
9819
+ * reconciler creates its indexes - nothing creates DDL at runtime from a write.
9820
+ * Everything the generic machinery needs (secret fields, the entry descriptor)
9821
+ * is DERIVED from the Zod schema: `.meta({ secret: true })` marks a credential,
9822
+ * never a field name (D879).
9823
+ */
9824
+ /** A JSON field path: `trackId`, `auth.accessToken`. Charset-restricted: it is rendered into DDL. */
9825
+ var RecordFieldPathSchema = string().regex(/^[A-Za-z_][A-Za-z0-9_]{0,63}(\.[A-Za-z_][A-Za-z0-9_]{0,63}){0,3}$/);
9826
+ var RecordIndexSchema = object({
9827
+ name: string().regex(/^[a-z][a-z0-9_]{0,31}$/),
9828
+ fields: array(RecordFieldPathSchema).min(1).max(4),
9829
+ unique: boolean().optional()
9830
+ }).strict();
9831
+ var RecordRetentionSchema = union([
9832
+ object({
9833
+ ttlMs: number().int().positive(),
9834
+ from: _enum(["at", "write"])
9835
+ }).strict(),
9836
+ object({
9837
+ maxRows: number().int().positive().optional(),
9838
+ maxRowsPerDevice: number().int().positive().optional()
9839
+ }).strict().refine((r) => r.maxRows !== void 0 || r.maxRowsPerDevice !== void 0, { message: "name maxRows, maxRowsPerDevice or both" }),
9840
+ object({
9841
+ owner: string().min(1),
9842
+ reason: string().min(1)
9843
+ }).strict(),
9844
+ object({ none: string().min(1) }).strict()
9845
+ ]);
9846
+ /** The descriptor a generic entries UI reads (D881 "generic entries"). */
9847
+ var EntryDescriptorSchema = object({
9848
+ title: string().min(1),
9849
+ /** The record body field shown as the entry's name. */
9850
+ nameField: string().min(1),
9851
+ /** JSON Schema of the entry body; `secret: true` marks a password field. */
9852
+ fields: record(string(), unknown())
9853
+ }).strict();
9854
+ /** What crosses the wire from an addon: JSON only, no Zod. An unknown key is refused. */
9855
+ var RecordKindDeclarationSchema = object({
9856
+ database: _enum(RECORD_DATABASES).default("settings"),
9857
+ class: _enum(RECORD_CLASSES),
9858
+ writeTrigger: string().min(1),
9859
+ device: _enum([
9860
+ "required",
9861
+ "optional",
9862
+ "none"
9863
+ ]).default("none"),
9864
+ at: _enum(["required", "none"]).default("none"),
9865
+ indexes: array(RecordIndexSchema).max(8).default([]),
9866
+ retention: RecordRetentionSchema,
9867
+ deviceRemoval: _enum(["delete", "none"]).default("none"),
9868
+ maxDataBytes: number().int().positive().max(RECORD_MAX_DATA_BYTES).default(RECORD_DEFAULT_MAX_DATA_BYTES),
9869
+ /** Derived from the Zod schema; never written by hand. */
9870
+ secretPaths: array(string().min(1)).default([]),
9871
+ /** The id key of each array that carries a secret (`{ headers: 'name' }`). */
9872
+ secretArrayKeys: record(string(), string()).default({}),
9873
+ /** Kinds that must agree through `transact` sit in one file under one family name. */
9874
+ transactFamily: string().min(1).optional(),
9875
+ entry: EntryDescriptorSchema.optional()
9876
+ }).strict();
9877
+ /** The kind names: lower-case, dash separated, short enough for an index name. */
9878
+ var RecordKindNameSchema = string().regex(/^[a-z][a-z0-9-]{0,47}$/);
9879
+ /** Cross-field rules a declaration must satisfy. Throws {@link DeclarationRefusedError}. */
9880
+ function assertValidDeclaration(name, decl) {
9881
+ const refuse = (why) => {
9882
+ throw new DeclarationRefusedError(`kind "${name}": ${why}`);
9883
+ };
9884
+ if (!RecordKindNameSchema.safeParse(name).success) refuse("the name must be lower-case-dashed");
9885
+ const seen = /* @__PURE__ */ new Set();
9886
+ for (const index of decl.indexes) {
9887
+ if (seen.has(index.name)) refuse(`index name "${index.name}" is declared twice`);
9888
+ seen.add(index.name);
9889
+ }
9890
+ const { retention } = decl;
9891
+ const hasSecrets = decl.secretPaths.length > 0;
9892
+ if ("ttlMs" in retention) {
9893
+ if (retention.from === "at" && decl.at !== "required") refuse("a ttl from \"at\" needs at: \"required\"");
9894
+ if (hasSecrets) refuse("a kind with secret fields cannot use engine TTL (its keychain values would be orphaned)");
9895
+ }
9896
+ if ("maxRows" in retention || "maxRowsPerDevice" in retention) {
9897
+ if (retention.maxRowsPerDevice !== void 0 && decl.device !== "required") refuse("maxRowsPerDevice needs device: \"required\"");
9898
+ if (decl.at !== "required") refuse("a row bound trims the oldest \"at\": it needs at: \"required\"");
9899
+ if (hasSecrets) refuse("a kind with secret fields cannot use an engine row bound");
9900
+ const bound = Math.max(retention.maxRows ?? 0, retention.maxRowsPerDevice ?? 0);
9901
+ 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)`);
9902
+ }
9903
+ if (decl.deviceRemoval === "delete" && decl.device === "none") refuse("deviceRemoval: \"delete\" needs a device: \"required\" or \"optional\"");
9904
+ 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`);
9905
+ }
9906
+ function bodyFieldsOf(schema) {
9907
+ return { ...toJSONSchema(schema, {
9908
+ unrepresentable: "any",
9909
+ io: "input"
9910
+ }) };
9911
+ }
9912
+ function isRecordLike(value) {
9913
+ return typeof value === "object" && value !== null && !Array.isArray(value);
9914
+ }
9915
+ /** Does every branch of the body schema carry `field`? (A discriminated union has several.) */
9916
+ function hasNameField(json, field) {
9917
+ const branches = json["oneOf"] ?? json["anyOf"];
9918
+ if (Array.isArray(branches)) return branches.length > 0 && branches.every((b) => isRecordLike(b) && hasNameField(b, field));
9919
+ const properties = json["properties"];
9920
+ return isRecordLike(properties) && Object.prototype.hasOwnProperty.call(properties, field);
9921
+ }
9922
+ /**
9923
+ * Declare the kinds of a package. The keys are the kind names. The result is
9924
+ * what `ctx.records.declare` sends to the engine and what `ctx.records.kind`
9925
+ * types its handle from.
9926
+ */
9927
+ function defineRecordKinds(specs) {
9928
+ const out = {};
9929
+ for (const [name, spec] of Object.entries(specs)) {
9930
+ const secretPaths = collectZodSecretPaths(spec.schema);
9931
+ const nameField = spec.entry?.nameField ?? "name";
9932
+ const fields = bodyFieldsOf(spec.schema);
9933
+ if (spec.entry !== void 0 && !hasNameField(fields, nameField)) throw new DeclarationRefusedError(`kind "${name}": an entry kind's schema needs a "${nameField}" field`);
9934
+ const parsed = RecordKindDeclarationSchema.parse({
9935
+ database: spec.database,
9936
+ class: spec.class,
9937
+ writeTrigger: spec.writeTrigger,
9938
+ device: spec.device,
9939
+ at: spec.at,
9940
+ indexes: spec.indexes === void 0 ? void 0 : [...spec.indexes],
9941
+ retention: spec.retention,
9942
+ deviceRemoval: spec.deviceRemoval,
9943
+ maxDataBytes: spec.maxDataBytes,
9944
+ secretPaths: [...new Set([...secretPaths, ...spec.retiredSecretPaths ?? []])],
9945
+ secretArrayKeys: spec.secretArrayKeys === void 0 ? void 0 : { ...spec.secretArrayKeys },
9946
+ transactFamily: spec.transactFamily,
9947
+ entry: spec.entry === void 0 ? void 0 : {
9948
+ title: spec.entry.title,
9949
+ nameField,
9950
+ fields
9951
+ }
9952
+ });
9953
+ assertValidDeclaration(name, parsed);
9954
+ out[name] = {
9955
+ name,
9956
+ schema: spec.schema,
9957
+ declaration: parsed
9958
+ };
9959
+ }
9960
+ return out;
9961
+ }
9962
+ /**
9963
+ * Entry kinds (D881): every list of user-created entries (notification
9964
+ * targets, brokers, LLM profiles) is ONE record kind with an id, a name and a
9965
+ * kind-specific body, and the admin UI lists/adds/edits/deletes all of them
9966
+ * through the `record-entries` capability with password fields derived from
9967
+ * the schema (`.meta({ secret: true })`).
9968
+ */
9969
+ /** The body of a plain entry: a name and the fields the kind adds. */
9970
+ function entryBody(shape) {
9971
+ return object({
9972
+ name: string().min(1),
9973
+ enabled: boolean().optional(),
9974
+ ...shape
9975
+ });
9976
+ }
9977
+ /**
9978
+ * Declare one entry kind. An entry is configuration: never trimmed by the
9979
+ * engine, never aged, belonging to no device.
9980
+ */
9981
+ function defineEntryKind(name, spec) {
9982
+ const defined = defineRecordKinds({ [name]: {
9983
+ schema: spec.schema,
9984
+ class: "config",
9985
+ writeTrigger: spec.writeTrigger ?? "an operator adds or edits an entry in the entries UI",
9986
+ retention: { none: "an entry goes only when the operator deletes it" },
9987
+ ...spec.maxDataBytes === void 0 ? {} : { maxDataBytes: spec.maxDataBytes },
9988
+ ...spec.database === void 0 ? {} : { database: spec.database },
9989
+ ...spec.indexes === void 0 ? {} : { indexes: spec.indexes },
9990
+ ...spec.secretArrayKeys === void 0 ? {} : { secretArrayKeys: spec.secretArrayKeys },
9991
+ ...spec.retiredSecretPaths === void 0 ? {} : { retiredSecretPaths: spec.retiredSecretPaths },
9992
+ entry: {
9993
+ title: spec.title,
9994
+ ...spec.nameField === void 0 ? {} : { nameField: spec.nameField }
9995
+ }
9996
+ } })[name];
9997
+ if (defined === void 0) throw new DeclarationRefusedError(`entry kind "${name}" was not built`);
9998
+ return defined;
9999
+ }
10000
+ /**
10001
+ * The share-view scope kinds a share-link token can carry. The hub mints
10002
+ * and validates them (`ShareViewGrantSchema` builds its
10003
+ * enum from this list); a data plane names the kinds it ACCEPTS in `share`.
10004
+ */
10005
+ var SHARE_VIEW_KINDS = ["grid-view", "events-view"];
10006
+ /** The wire shape of {@link PeerBytesTicket} — see the type for what it is. */
10007
+ var PeerBytesTicketSchema = object({
10008
+ /** `http://127.0.0.1:<port>/<token>`. One `GET` takes it. */
10009
+ url: string().min(1),
10010
+ /**
10011
+ * The HOST node this URL means something on — the hub or a named agent,
10012
+ * never a runner. {@link AddonPeerBytes.open} compares it to its own and
10013
+ * refuses `cross-node` by name when they differ, without dialling.
10014
+ */
10015
+ hostNodeId: string().min(1),
10016
+ expiresAtMs: number().int().nonnegative(),
10017
+ /**
10018
+ * What the producer DECLARED the body to be, when it knows — `null` when it
10019
+ * does not. Never `0` for unknown (D393): a consumer sizing a bound off this
10020
+ * must be able to tell "the producer did not say" from "the body is empty".
10021
+ */
10022
+ declaredBytes: number().int().nonnegative().nullable()
10023
+ });
9997
10024
  var READING_QUANTITIES = [
9998
10025
  "temperature",
9999
10026
  "pressure",
@@ -10584,7 +10611,6 @@ var CAP_NAMES = Object.freeze([
10584
10611
  "climate-control",
10585
10612
  "color",
10586
10613
  "composer",
10587
- "connection-test",
10588
10614
  "connectivity",
10589
10615
  "consumables",
10590
10616
  "contact",
@@ -12604,8 +12630,7 @@ Object.freeze({
12604
12630
  "offerArtifact": 3e5,
12605
12631
  "readResult": 3e5,
12606
12632
  "submitJob": 18e5,
12607
- "uploadDataset": 72e5,
12608
- "validateCredentials": 3e4
12633
+ "uploadDataset": 72e5
12609
12634
  }
12610
12635
  });
12611
12636
  object({
@@ -13974,6 +13999,432 @@ var IntegrationInstanceRefSchema = object({
13974
13999
  ]),
13975
14000
  candidateStableId: string().optional()
13976
14001
  });
14002
+ /**
14003
+ * notification-output — canonical, capability-gated notification delivery.
14004
+ *
14005
+ * Apprise-derived model (see
14006
+ * `docs/superpowers/specs/2026-07-03-notification-output-notifier-matrix.md`):
14007
+ * callers emit ONE canonical `Notification`; each provider declares a
14008
+ * per-kind capability descriptor (`TargetKind`), and the pure degrade
14009
+ * engine (`@camstack/types` `prepareNotification`) transcodes / degrades the
14010
+ * message to what the kind supports — callers never special-case a service.
14011
+ *
14012
+ * DESIGN DECISIONS (locked):
14013
+ * - Target CRUD lives on THIS cap (`upsertTarget` / `deleteTarget` /
14014
+ * `setTargetEnabled`), each provider persisting via the `settings-store`
14015
+ * cap. Rationale: the admin UI needs one uniform surface across the
14016
+ * notifiers addon AND the HA addon; the addon-`globalSettingsSchema`-array
14017
+ * alternative would fork the UI per addon and cannot host the
14018
+ * discovery→adopt flow.
14019
+ * - `listTargetKinds` / `listTargets` / `discoverTargets` return arrays →
14020
+ * the generated cap-mount auto-`concatCollection`-fans them across every
14021
+ * registered provider (notifiers addon + HA addon) so one catalog is
14022
+ * routable. `send` / `testTarget` / CRUD route to ONE provider by the
14023
+ * `addonId` the generated collection router extracts from the call input.
14024
+ * - `Attachment.bytes` is `Uint8Array`. Transport-safe: superjson (the tRPC
14025
+ * transformer) + UDS MsgPack both round-trip typed arrays — already used by
14026
+ * `storage` / `storage-provider` / `recording` caps over the same path. No
14027
+ * base64 fallback needed.
14028
+ *
14029
+ * TODO (deferred, closed-set change — separate decision): add
14030
+ * `providerKind: 'notify'` so notification providers surface on the unified
14031
+ * admin "Integrations" page.
14032
+ */
14033
+ /**
14034
+ * Zentik-derived typed-media enum — the superset across every kind. Each
14035
+ * adapter picks what it supports and the degrade engine filters the rest.
14036
+ */
14037
+ var AttachmentMediaTypeSchema = _enum([
14038
+ "image",
14039
+ "video",
14040
+ "gif",
14041
+ "audio",
14042
+ "icon"
14043
+ ]);
14044
+ /**
14045
+ * A single attachment. Exactly one of `url` (remote source, most adapters
14046
+ * prefer this) or `bytes` (inline source; required for Pushover-style
14047
+ * bytes-only kinds) MUST be present — the degrade engine expresses a
14048
+ * url→bytes fetch as a `needsFetch` directive the adapter executes.
14049
+ */
14050
+ var AttachmentSchema = object({
14051
+ mediaType: AttachmentMediaTypeSchema,
14052
+ url: string().optional(),
14053
+ bytes: _instanceof(Uint8Array).optional(),
14054
+ mime: string().optional(),
14055
+ name: string().optional()
14056
+ }).refine((a) => a.url !== void 0 || a.bytes !== void 0, { message: "Attachment requires either `url` or `bytes`" });
14057
+ var NotificationFormatSchema = _enum([
14058
+ "text",
14059
+ "markdown",
14060
+ "html"
14061
+ ]);
14062
+ /**
14063
+ * The CLOSED icon vocabulary an action button may use.
14064
+ *
14065
+ * A closed set, not a free string, and that is the whole point: an arbitrary
14066
+ * icon name is one that ntfy renders, zentik silently drops, and nobody
14067
+ * notices — the same class of gap as a zone vocabulary nothing produced
14068
+ * ([D35](../../../docs/decisions/adr-0035.md)). Every adapter maps this set or
14069
+ * declares `actionIcons: false` and the degrade engine strips the field.
14070
+ *
14071
+ * Named by INTENT, never by glyph. "check" would tie the vocabulary to one
14072
+ * renderer's icon set; "acknowledge" survives an adapter that draws it
14073
+ * differently.
14074
+ *
14075
+ * ── A TOKEN IS NOT A WIRE VALUE ─────────────────────────────────────
14076
+ *
14077
+ * These names are for US. **No adapter may forward one verbatim.** Each maps
14078
+ * the whole set onto its own renderer's vocabulary through a
14079
+ * `Record<NotificationActionIcon, string>` — a Record, never a lookup with a
14080
+ * fallback, so adding a member here fails every adapter's build until someone
14081
+ * decides its glyph, which is the only place that decision can be made
14082
+ * honestly.
14083
+ *
14084
+ * This paragraph is the bug. Zentik declared `actionIcons: true` and passed
14085
+ * `disarm` straight through; iOS feeds that string to
14086
+ * `UNNotificationActionIcon(systemImageName:)`, `disarm` is not an SF Symbol,
14087
+ * and every snooze and alarm button arrived BLANK. A pass-through is not a
14088
+ * mapping, and "the field is documented" is not "the value renders".
14089
+ *
14090
+ * Adding a member is TRAIN-BOUND. The enum lives in the published
14091
+ * `@camstack/server` closure and the cap seam validates against the HUB's copy,
14092
+ * so an addon that emits a token the running hub does not know does not lose an
14093
+ * icon — its whole `send` fails Zod validation and the notification never
14094
+ * arrives. Never emit a new token from an addon before the train carrying it.
14095
+ */
14096
+ var NotificationActionIconSchema = _enum([
14097
+ "acknowledge",
14098
+ "dismiss",
14099
+ "silence",
14100
+ "snooze",
14101
+ "view",
14102
+ "play",
14103
+ "open",
14104
+ "close",
14105
+ "lock",
14106
+ "unlock",
14107
+ "arm",
14108
+ "arm-home",
14109
+ "arm-away",
14110
+ "arm-night",
14111
+ "disarm",
14112
+ "light",
14113
+ "alert",
14114
+ "camera"
14115
+ ]);
14116
+ /** A single tap-through action button. */
14117
+ var NotificationActionSchema = object({
14118
+ id: string(),
14119
+ label: string(),
14120
+ url: string().optional(),
14121
+ /** Dropped by the degrade engine for a kind with `caps.actionIcons: false`. */
14122
+ icon: NotificationActionIconSchema.optional(),
14123
+ /**
14124
+ * Renders in a warning style where the notifier supports it.
14125
+ *
14126
+ * A HINT, never a gate. The callback's authority is its token and nothing
14127
+ * else — see `notification-center/action-token.ts` for what that does and
14128
+ * does not buy.
14129
+ */
14130
+ destructive: boolean().optional(),
14131
+ /**
14132
+ * How the tap should REACH the url.
14133
+ *
14134
+ * `navigate` (absent, and every button authored before this field) opens it:
14135
+ * the phone leaves the notification and shows whatever the callback returns.
14136
+ * That is right for a button whose answer the operator wants to read.
14137
+ *
14138
+ * `background` fires it as a POST and stays put. It exists for the buttons
14139
+ * whose whole point is not to interrupt — "silence this for 30 minutes" is
14140
+ * an answer to the notification, and being thrown into a browser tab to
14141
+ * confirm it costs more attention than the notification did. A backend that
14142
+ * cannot do a background call renders it as an ordinary link (the adapters
14143
+ * fall back rather than dropping the button), so this is a preference, never
14144
+ * a requirement.
14145
+ */
14146
+ mode: _enum(["navigate", "background"]).optional()
14147
+ });
14148
+ /** A delivery parameter value: what a notifier declared it takes. */
14149
+ var DeliveryParamValueSchema = union([
14150
+ string(),
14151
+ number(),
14152
+ boolean()
14153
+ ]);
14154
+ /**
14155
+ * One extra delivery parameter a notifier KIND declares (D938). A rule that
14156
+ * addresses a target of that kind may set it; a kind that declares nothing is
14157
+ * never handed one. The admin UI derives its control from this descriptor —
14158
+ * no editor knows a service by name.
14159
+ *
14160
+ * Optional fields are `.optional()`, never `.default()` (a Zod default does not
14161
+ * run on the addon cap path).
14162
+ */
14163
+ var DeliveryParamSchema = object({
14164
+ key: string().min(1),
14165
+ label: string(),
14166
+ /** i18n key of the label, resolved by the declaring addon's namespace. */
14167
+ labelKey: string().optional(),
14168
+ type: _enum([
14169
+ "enum",
14170
+ "number",
14171
+ "boolean",
14172
+ "string"
14173
+ ]),
14174
+ /** `enum` only: the closed set of accepted values. */
14175
+ options: array(object({
14176
+ value: string(),
14177
+ label: string()
14178
+ })).optional(),
14179
+ /** `number` only. */
14180
+ min: number().optional(),
14181
+ max: number().optional(),
14182
+ /** What the notifier does when the rule sets nothing; shown as the placeholder. */
14183
+ default: DeliveryParamValueSchema.optional()
14184
+ });
14185
+ /**
14186
+ * The canonical notification. `body` is the only hard field (Apprise model).
14187
+ * `priority` is a 5-level ORDINAL (1=lowest … 3=normal(default) … 5=urgent),
14188
+ * NOT a fixed severity enum — each kind declares its own `caps.levels` and
14189
+ * the adapter maps this ordinal onto its native level. `level?` is an
14190
+ * optional kind-native level id (`emergency`, `silent`, …) that overrides
14191
+ * `priority` for that one target.
14192
+ */
14193
+ var NotificationSchema = object({
14194
+ body: string(),
14195
+ title: string().optional(),
14196
+ format: NotificationFormatSchema.default("text"),
14197
+ priority: number().int().min(1).max(5).default(3),
14198
+ level: string().optional(),
14199
+ attachments: array(AttachmentSchema).optional(),
14200
+ clickUrl: string().optional(),
14201
+ actions: array(NotificationActionSchema).optional(),
14202
+ sound: string().optional(),
14203
+ ttl: number().optional(),
14204
+ tag: string().optional(),
14205
+ deviceId: number().optional(),
14206
+ eventId: string().optional(),
14207
+ metadata: record(string(), unknown()).optional(),
14208
+ /**
14209
+ * Values for the parameters the target's kind DECLARES in
14210
+ * {@link TargetKindSchema} `deliveryParams`. Already validated against the
14211
+ * declaration by the sender; a notifier reads only the keys it declared.
14212
+ */
14213
+ delivery: record(string(), DeliveryParamValueSchema).optional()
14214
+ });
14215
+ /** One declared native severity/priority level for a kind. */
14216
+ var TargetKindLevelSchema = object({
14217
+ id: string(),
14218
+ label: string(),
14219
+ /** Which canonical priority (1..5) this level maps to. `null` = qualitative-only. */
14220
+ ordinal: number().int().min(1).max(5).nullable(),
14221
+ flags: object({
14222
+ critical: boolean().optional(),
14223
+ silent: boolean().optional(),
14224
+ noPush: boolean().optional()
14225
+ }).optional(),
14226
+ /** e.g. Pushover `emergency` requires `retry` / `expire`. */
14227
+ requires: array(string()).optional(),
14228
+ description: string().optional()
14229
+ });
14230
+ /** The full capability block consulted before dispatch. */
14231
+ var TargetKindCapsSchema = object({
14232
+ attachments: object({
14233
+ mediaTypes: array(AttachmentMediaTypeSchema),
14234
+ mode: _enum([
14235
+ "url",
14236
+ "bytes",
14237
+ "both"
14238
+ ]),
14239
+ max: number().int().nonnegative(),
14240
+ maxBytes: number().int().positive().optional()
14241
+ }),
14242
+ /** Max action buttons (0 = none). */
14243
+ actions: number().int().nonnegative(),
14244
+ /**
14245
+ * Whether this kind renders a per-action ICON.
14246
+ *
14247
+ * `.optional()`, deliberately NOT `.default(false)`: a Zod default does not
14248
+ * run on the addon cap path — three production failures in one day taught
14249
+ * this repo that once. Absent is read as false by the degrade engine, which
14250
+ * is the safe direction: an icon that is not rendered costs nothing, an icon
14251
+ * assumed and dropped costs the operator's trust in the field.
14252
+ */
14253
+ actionIcons: boolean().optional(),
14254
+ levels: array(TargetKindLevelSchema),
14255
+ format: array(NotificationFormatSchema),
14256
+ clickUrl: boolean(),
14257
+ sound: boolean(),
14258
+ ttl: boolean(),
14259
+ bodyMaxLen: number().int().positive()
14260
+ });
14261
+ /**
14262
+ * `configSchema` is a `ConfigUISchema` tree passed through to the admin
14263
+ * FormBuilder. Stored as `z.unknown()` at the cap seam (mirrors
14264
+ * `device-provider.getChildCreationSchema` `CreationSchemaOutputSchema`) —
14265
+ * the union is large and not meant for runtime validation here; the exported
14266
+ * `TargetKind` type re-tightens `configSchema` to `ConfigUISchema`.
14267
+ */
14268
+ var ConfigSchemaPassthrough$4 = unknown();
14269
+ var TargetKindSchema = object({
14270
+ kind: string(),
14271
+ label: string(),
14272
+ icon: string(),
14273
+ /** Stamped by each provider so the concat-fanned catalog stays routable. */
14274
+ addonId: string(),
14275
+ /**
14276
+ * URL of the kind's bundled BRAND icon, served by the providing addon over
14277
+ * its own `addon-routes` surface (`/addon/<addonId>/icons/<kind>`). Absent
14278
+ * when the addon bundles no icon for that kind — the client then falls back
14279
+ * to a neutral glyph rather than rendering the raw `icon` NAME as text.
14280
+ *
14281
+ * Root-relative on purpose: it resolves against whatever origin serves a web
14282
+ * client, and a native client joins it onto its own hub base.
14283
+ *
14284
+ * DECLARED here deliberately. It used to travel as an undeclared passthrough
14285
+ * field that survived only because the runtime cap-router forwards provider
14286
+ * output verbatim — so every consumer had to re-declare it by hand to stop
14287
+ * its own Zod parse from stripping it, and the whole arrangement would have
14288
+ * broken silently the moment output validation was tightened anywhere.
14289
+ */
14290
+ iconUrl: string().optional(),
14291
+ /**
14292
+ * Media type of {@link iconUrl} (`image/svg+xml`, `image/png`, …).
14293
+ *
14294
+ * The server knows this and therefore says it, because the client cannot
14295
+ * safely guess: a React-Native client renders SVG and raster through two
14296
+ * DIFFERENT components (`react-native-svg` vs `expo-image` — expo-image does
14297
+ * not decode SVG on iOS/Android), so without this it silently fell back to a
14298
+ * placeholder glyph for every vector icon while the web build looked fine.
14299
+ *
14300
+ * Absent when {@link iconUrl} is absent, or for a legacy provider that has
14301
+ * not been updated — a client that cannot determine the type should prefer
14302
+ * its raster path, which is the safe default for an unknown image.
14303
+ */
14304
+ iconMediaType: string().optional(),
14305
+ configSchema: ConfigSchemaPassthrough$4,
14306
+ /**
14307
+ * The config keys that decide WHERE this kind's secrets are sent (server,
14308
+ * base URL, instance, chat, recipient). A save that changes any of them
14309
+ * while leaving a secret redacted is refused by the provider (D634), so an
14310
+ * editor uses this to ask for the secret on exactly those edits instead of
14311
+ * on every edit.
14312
+ *
14313
+ * Optional: absent from a provider that holds no secret (the Home Assistant
14314
+ * kinds) and from a provider older than this field — an editor that finds
14315
+ * it absent must assume ANY edit may need the secret.
14316
+ */
14317
+ destinationKeys: array(string()).optional(),
14318
+ supportsDiscovery: boolean(),
14319
+ /**
14320
+ * Extra delivery parameters a rule may set for a target of this kind (D938).
14321
+ * Absent = none; the rule editor then offers nothing.
14322
+ */
14323
+ deliveryParams: array(DeliveryParamSchema).optional(),
14324
+ caps: TargetKindCapsSchema
14325
+ });
14326
+ /**
14327
+ * A persisted target. `config` holds secrets; providers REDACT secret fields
14328
+ * (return a presence marker only) when serving `listTargets` — never
14329
+ * round-trip a stored secret to the UI.
14330
+ */
14331
+ var TargetSchema = object({
14332
+ id: string(),
14333
+ name: string(),
14334
+ kind: string(),
14335
+ addonId: string(),
14336
+ enabled: boolean(),
14337
+ config: record(string(), unknown())
14338
+ });
14339
+ /** A discovery-surfaced candidate (config is partial + non-secret). */
14340
+ var DiscoveredTargetSchema = object({
14341
+ kind: string(),
14342
+ suggestedName: string(),
14343
+ config: record(string(), unknown())
14344
+ });
14345
+ /** The degrade engine's report — what was resolved / dropped / degraded. */
14346
+ var RenderedAsSchema = object({
14347
+ level: string(),
14348
+ format: NotificationFormatSchema,
14349
+ attachmentsSent: number().int().nonnegative(),
14350
+ actionsSent: number().int().nonnegative(),
14351
+ truncated: boolean(),
14352
+ dropped: array(string())
14353
+ });
14354
+ var SendResultSchema = object({
14355
+ success: boolean(),
14356
+ error: string().optional(),
14357
+ renderedAs: RenderedAsSchema.optional()
14358
+ });
14359
+ /** Same shape as SendResult — kept as a distinct name for the test panel. */
14360
+ var TestResultSchema = SendResultSchema;
14361
+ /**
14362
+ * Pre-save credential probe against a partial (unsaved) target config.
14363
+ * `resolvedUrl` never includes secrets (token stripped from path).
14364
+ */
14365
+ var ProbeTargetConfigResultSchema = object({
14366
+ ok: boolean(),
14367
+ resolvedUrl: string(),
14368
+ httpStatus: number().int().optional(),
14369
+ stateInstance: string().optional(),
14370
+ error: string().optional()
14371
+ });
14372
+ method(object({}), array(TargetKindSchema)), method(object({}), array(TargetSchema), { auth: "admin" }), method(object({ targetId: string() }), TargetSchema, { auth: "admin" }), method(object({
14373
+ kind: string(),
14374
+ config: record(string(), unknown()).optional(),
14375
+ /**
14376
+ * When editing / duplicating, the blank password field never round-trips
14377
+ * the stored token. Pass the source target id so the provider can restore
14378
+ * secrets server-side before dialling (same merge as upsert).
14379
+ */
14380
+ targetId: string().optional()
14381
+ }), array(DiscoveredTargetSchema), { auth: "admin" }), method(object({
14382
+ kind: string(),
14383
+ config: record(string(), unknown()),
14384
+ /** See `discoverTargets.targetId` — restore stored secrets for a blank password. */
14385
+ targetId: string().optional()
14386
+ }), ProbeTargetConfigResultSchema, {
14387
+ kind: "mutation",
14388
+ auth: "admin"
14389
+ }), method(object({
14390
+ targetId: string(),
14391
+ notification: NotificationSchema
14392
+ }), SendResultSchema, {
14393
+ kind: "mutation",
14394
+ auth: "admin"
14395
+ }), method(object({
14396
+ targetId: string(),
14397
+ sample: NotificationSchema.optional()
14398
+ }), TestResultSchema, {
14399
+ kind: "mutation",
14400
+ auth: "admin"
14401
+ }), method(object({
14402
+ target: TargetSchema,
14403
+ /**
14404
+ * Duplicate flow: create a NEW target id while copying secrets from an
14405
+ * existing row. The UI never holds the stored token; blank / redacted
14406
+ * password fields are restored from this source (D634 still applies if
14407
+ * destinations diverge without a re-typed secret).
14408
+ */
14409
+ cloneSecretsFrom: string().optional()
14410
+ }), TargetSchema, {
14411
+ kind: "mutation",
14412
+ auth: "admin"
14413
+ }), method(object({ targetId: string() }), _void(), {
14414
+ kind: "mutation",
14415
+ auth: "admin"
14416
+ }), method(object({
14417
+ targetId: string(),
14418
+ enabled: boolean()
14419
+ }), _void(), {
14420
+ kind: "mutation",
14421
+ auth: "admin"
14422
+ });
14423
+ looseObject({
14424
+ name: string().min(1),
14425
+ enabled: boolean().optional()
14426
+ });
14427
+ TargetSchema.omit({ id: true });
13977
14428
  var EncodeProfileSchema = object({
13978
14429
  video: object({
13979
14430
  codec: _enum([
@@ -22824,7 +23275,6 @@ var SYSTEM_CAP_VOCABULARY = {
22824
23275
  "calendar-source": system(INTERNAL),
22825
23276
  calendars: system("calendars feed schedules and conditions, not device actions"),
22826
23277
  composer: system("device composition — an authoring tool, not an action"),
22827
- "connection-test": system(INTERNAL),
22828
23278
  "core-blocks": system(INTERNAL),
22829
23279
  "custom-model-registry": system(ML),
22830
23280
  "data-store-provider": system(INTERNAL),
@@ -44801,427 +45251,6 @@ var UnitWarningSchema = object({
44801
45251
  assumedUnit: string(),
44802
45252
  message: string()
44803
45253
  });
44804
- /**
44805
- * notification-output — canonical, capability-gated notification delivery.
44806
- *
44807
- * Apprise-derived model (see
44808
- * `docs/superpowers/specs/2026-07-03-notification-output-notifier-matrix.md`):
44809
- * callers emit ONE canonical `Notification`; each provider declares a
44810
- * per-kind capability descriptor (`TargetKind`), and the pure degrade
44811
- * engine (`@camstack/types` `prepareNotification`) transcodes / degrades the
44812
- * message to what the kind supports — callers never special-case a service.
44813
- *
44814
- * DESIGN DECISIONS (locked):
44815
- * - Target CRUD lives on THIS cap (`upsertTarget` / `deleteTarget` /
44816
- * `setTargetEnabled`), each provider persisting via the `settings-store`
44817
- * cap. Rationale: the admin UI needs one uniform surface across the
44818
- * notifiers addon AND the HA addon; the addon-`globalSettingsSchema`-array
44819
- * alternative would fork the UI per addon and cannot host the
44820
- * discovery→adopt flow.
44821
- * - `listTargetKinds` / `listTargets` / `discoverTargets` return arrays →
44822
- * the generated cap-mount auto-`concatCollection`-fans them across every
44823
- * registered provider (notifiers addon + HA addon) so one catalog is
44824
- * routable. `send` / `testTarget` / CRUD route to ONE provider by the
44825
- * `addonId` the generated collection router extracts from the call input.
44826
- * - `Attachment.bytes` is `Uint8Array`. Transport-safe: superjson (the tRPC
44827
- * transformer) + UDS MsgPack both round-trip typed arrays — already used by
44828
- * `storage` / `storage-provider` / `recording` caps over the same path. No
44829
- * base64 fallback needed.
44830
- *
44831
- * TODO (deferred, closed-set change — separate decision): add
44832
- * `providerKind: 'notify'` so notification providers surface on the unified
44833
- * admin "Integrations" page.
44834
- */
44835
- /**
44836
- * Zentik-derived typed-media enum — the superset across every kind. Each
44837
- * adapter picks what it supports and the degrade engine filters the rest.
44838
- */
44839
- var AttachmentMediaTypeSchema = _enum([
44840
- "image",
44841
- "video",
44842
- "gif",
44843
- "audio",
44844
- "icon"
44845
- ]);
44846
- /**
44847
- * A single attachment. Exactly one of `url` (remote source, most adapters
44848
- * prefer this) or `bytes` (inline source; required for Pushover-style
44849
- * bytes-only kinds) MUST be present — the degrade engine expresses a
44850
- * url→bytes fetch as a `needsFetch` directive the adapter executes.
44851
- */
44852
- var AttachmentSchema = object({
44853
- mediaType: AttachmentMediaTypeSchema,
44854
- url: string().optional(),
44855
- bytes: _instanceof(Uint8Array).optional(),
44856
- mime: string().optional(),
44857
- name: string().optional()
44858
- }).refine((a) => a.url !== void 0 || a.bytes !== void 0, { message: "Attachment requires either `url` or `bytes`" });
44859
- var NotificationFormatSchema = _enum([
44860
- "text",
44861
- "markdown",
44862
- "html"
44863
- ]);
44864
- /**
44865
- * The CLOSED icon vocabulary an action button may use.
44866
- *
44867
- * A closed set, not a free string, and that is the whole point: an arbitrary
44868
- * icon name is one that ntfy renders, zentik silently drops, and nobody
44869
- * notices — the same class of gap as a zone vocabulary nothing produced
44870
- * ([D35](../../../docs/decisions/adr-0035.md)). Every adapter maps this set or
44871
- * declares `actionIcons: false` and the degrade engine strips the field.
44872
- *
44873
- * Named by INTENT, never by glyph. "check" would tie the vocabulary to one
44874
- * renderer's icon set; "acknowledge" survives an adapter that draws it
44875
- * differently.
44876
- *
44877
- * ── A TOKEN IS NOT A WIRE VALUE ─────────────────────────────────────
44878
- *
44879
- * These names are for US. **No adapter may forward one verbatim.** Each maps
44880
- * the whole set onto its own renderer's vocabulary through a
44881
- * `Record<NotificationActionIcon, string>` — a Record, never a lookup with a
44882
- * fallback, so adding a member here fails every adapter's build until someone
44883
- * decides its glyph, which is the only place that decision can be made
44884
- * honestly.
44885
- *
44886
- * This paragraph is the bug. Zentik declared `actionIcons: true` and passed
44887
- * `disarm` straight through; iOS feeds that string to
44888
- * `UNNotificationActionIcon(systemImageName:)`, `disarm` is not an SF Symbol,
44889
- * and every snooze and alarm button arrived BLANK. A pass-through is not a
44890
- * mapping, and "the field is documented" is not "the value renders".
44891
- *
44892
- * Adding a member is TRAIN-BOUND. The enum lives in the published
44893
- * `@camstack/server` closure and the cap seam validates against the HUB's copy,
44894
- * so an addon that emits a token the running hub does not know does not lose an
44895
- * icon — its whole `send` fails Zod validation and the notification never
44896
- * arrives. Never emit a new token from an addon before the train carrying it.
44897
- */
44898
- var NotificationActionIconSchema = _enum([
44899
- "acknowledge",
44900
- "dismiss",
44901
- "silence",
44902
- "snooze",
44903
- "view",
44904
- "play",
44905
- "open",
44906
- "close",
44907
- "lock",
44908
- "unlock",
44909
- "arm",
44910
- "arm-home",
44911
- "arm-away",
44912
- "arm-night",
44913
- "disarm",
44914
- "light",
44915
- "alert",
44916
- "camera"
44917
- ]);
44918
- /** A single tap-through action button. */
44919
- var NotificationActionSchema = object({
44920
- id: string(),
44921
- label: string(),
44922
- url: string().optional(),
44923
- /** Dropped by the degrade engine for a kind with `caps.actionIcons: false`. */
44924
- icon: NotificationActionIconSchema.optional(),
44925
- /**
44926
- * Renders in a warning style where the notifier supports it.
44927
- *
44928
- * A HINT, never a gate. The callback's authority is its token and nothing
44929
- * else — see `notification-center/action-token.ts` for what that does and
44930
- * does not buy.
44931
- */
44932
- destructive: boolean().optional(),
44933
- /**
44934
- * How the tap should REACH the url.
44935
- *
44936
- * `navigate` (absent, and every button authored before this field) opens it:
44937
- * the phone leaves the notification and shows whatever the callback returns.
44938
- * That is right for a button whose answer the operator wants to read.
44939
- *
44940
- * `background` fires it as a POST and stays put. It exists for the buttons
44941
- * whose whole point is not to interrupt — "silence this for 30 minutes" is
44942
- * an answer to the notification, and being thrown into a browser tab to
44943
- * confirm it costs more attention than the notification did. A backend that
44944
- * cannot do a background call renders it as an ordinary link (the adapters
44945
- * fall back rather than dropping the button), so this is a preference, never
44946
- * a requirement.
44947
- */
44948
- mode: _enum(["navigate", "background"]).optional()
44949
- });
44950
- /** A delivery parameter value: what a notifier declared it takes. */
44951
- var DeliveryParamValueSchema = union([
44952
- string(),
44953
- number(),
44954
- boolean()
44955
- ]);
44956
- /**
44957
- * One extra delivery parameter a notifier KIND declares (D938). A rule that
44958
- * addresses a target of that kind may set it; a kind that declares nothing is
44959
- * never handed one. The admin UI derives its control from this descriptor —
44960
- * no editor knows a service by name.
44961
- *
44962
- * Optional fields are `.optional()`, never `.default()` (a Zod default does not
44963
- * run on the addon cap path).
44964
- */
44965
- var DeliveryParamSchema = object({
44966
- key: string().min(1),
44967
- label: string(),
44968
- /** i18n key of the label, resolved by the declaring addon's namespace. */
44969
- labelKey: string().optional(),
44970
- type: _enum([
44971
- "enum",
44972
- "number",
44973
- "boolean",
44974
- "string"
44975
- ]),
44976
- /** `enum` only: the closed set of accepted values. */
44977
- options: array(object({
44978
- value: string(),
44979
- label: string()
44980
- })).optional(),
44981
- /** `number` only. */
44982
- min: number().optional(),
44983
- max: number().optional(),
44984
- /** What the notifier does when the rule sets nothing; shown as the placeholder. */
44985
- default: DeliveryParamValueSchema.optional()
44986
- });
44987
- /**
44988
- * The canonical notification. `body` is the only hard field (Apprise model).
44989
- * `priority` is a 5-level ORDINAL (1=lowest … 3=normal(default) … 5=urgent),
44990
- * NOT a fixed severity enum — each kind declares its own `caps.levels` and
44991
- * the adapter maps this ordinal onto its native level. `level?` is an
44992
- * optional kind-native level id (`emergency`, `silent`, …) that overrides
44993
- * `priority` for that one target.
44994
- */
44995
- var NotificationSchema = object({
44996
- body: string(),
44997
- title: string().optional(),
44998
- format: NotificationFormatSchema.default("text"),
44999
- priority: number().int().min(1).max(5).default(3),
45000
- level: string().optional(),
45001
- attachments: array(AttachmentSchema).optional(),
45002
- clickUrl: string().optional(),
45003
- actions: array(NotificationActionSchema).optional(),
45004
- sound: string().optional(),
45005
- ttl: number().optional(),
45006
- tag: string().optional(),
45007
- deviceId: number().optional(),
45008
- eventId: string().optional(),
45009
- metadata: record(string(), unknown()).optional(),
45010
- /**
45011
- * Values for the parameters the target's kind DECLARES in
45012
- * {@link TargetKindSchema} `deliveryParams`. Already validated against the
45013
- * declaration by the sender; a notifier reads only the keys it declared.
45014
- */
45015
- delivery: record(string(), DeliveryParamValueSchema).optional()
45016
- });
45017
- /** One declared native severity/priority level for a kind. */
45018
- var TargetKindLevelSchema = object({
45019
- id: string(),
45020
- label: string(),
45021
- /** Which canonical priority (1..5) this level maps to. `null` = qualitative-only. */
45022
- ordinal: number().int().min(1).max(5).nullable(),
45023
- flags: object({
45024
- critical: boolean().optional(),
45025
- silent: boolean().optional(),
45026
- noPush: boolean().optional()
45027
- }).optional(),
45028
- /** e.g. Pushover `emergency` requires `retry` / `expire`. */
45029
- requires: array(string()).optional(),
45030
- description: string().optional()
45031
- });
45032
- /** The full capability block consulted before dispatch. */
45033
- var TargetKindCapsSchema = object({
45034
- attachments: object({
45035
- mediaTypes: array(AttachmentMediaTypeSchema),
45036
- mode: _enum([
45037
- "url",
45038
- "bytes",
45039
- "both"
45040
- ]),
45041
- max: number().int().nonnegative(),
45042
- maxBytes: number().int().positive().optional()
45043
- }),
45044
- /** Max action buttons (0 = none). */
45045
- actions: number().int().nonnegative(),
45046
- /**
45047
- * Whether this kind renders a per-action ICON.
45048
- *
45049
- * `.optional()`, deliberately NOT `.default(false)`: a Zod default does not
45050
- * run on the addon cap path — three production failures in one day taught
45051
- * this repo that once. Absent is read as false by the degrade engine, which
45052
- * is the safe direction: an icon that is not rendered costs nothing, an icon
45053
- * assumed and dropped costs the operator's trust in the field.
45054
- */
45055
- actionIcons: boolean().optional(),
45056
- levels: array(TargetKindLevelSchema),
45057
- format: array(NotificationFormatSchema),
45058
- clickUrl: boolean(),
45059
- sound: boolean(),
45060
- ttl: boolean(),
45061
- bodyMaxLen: number().int().positive()
45062
- });
45063
- /**
45064
- * `configSchema` is a `ConfigUISchema` tree passed through to the admin
45065
- * FormBuilder. Stored as `z.unknown()` at the cap seam (mirrors
45066
- * `device-provider.getChildCreationSchema` `CreationSchemaOutputSchema`) —
45067
- * the union is large and not meant for runtime validation here; the exported
45068
- * `TargetKind` type re-tightens `configSchema` to `ConfigUISchema`.
45069
- */
45070
- var ConfigSchemaPassthrough$4 = unknown();
45071
- var TargetKindSchema = object({
45072
- kind: string(),
45073
- label: string(),
45074
- icon: string(),
45075
- /** Stamped by each provider so the concat-fanned catalog stays routable. */
45076
- addonId: string(),
45077
- /**
45078
- * URL of the kind's bundled BRAND icon, served by the providing addon over
45079
- * its own `addon-routes` surface (`/addon/<addonId>/icons/<kind>`). Absent
45080
- * when the addon bundles no icon for that kind — the client then falls back
45081
- * to a neutral glyph rather than rendering the raw `icon` NAME as text.
45082
- *
45083
- * Root-relative on purpose: it resolves against whatever origin serves a web
45084
- * client, and a native client joins it onto its own hub base.
45085
- *
45086
- * DECLARED here deliberately. It used to travel as an undeclared passthrough
45087
- * field that survived only because the runtime cap-router forwards provider
45088
- * output verbatim — so every consumer had to re-declare it by hand to stop
45089
- * its own Zod parse from stripping it, and the whole arrangement would have
45090
- * broken silently the moment output validation was tightened anywhere.
45091
- */
45092
- iconUrl: string().optional(),
45093
- /**
45094
- * Media type of {@link iconUrl} (`image/svg+xml`, `image/png`, …).
45095
- *
45096
- * The server knows this and therefore says it, because the client cannot
45097
- * safely guess: a React-Native client renders SVG and raster through two
45098
- * DIFFERENT components (`react-native-svg` vs `expo-image` — expo-image does
45099
- * not decode SVG on iOS/Android), so without this it silently fell back to a
45100
- * placeholder glyph for every vector icon while the web build looked fine.
45101
- *
45102
- * Absent when {@link iconUrl} is absent, or for a legacy provider that has
45103
- * not been updated — a client that cannot determine the type should prefer
45104
- * its raster path, which is the safe default for an unknown image.
45105
- */
45106
- iconMediaType: string().optional(),
45107
- configSchema: ConfigSchemaPassthrough$4,
45108
- /**
45109
- * The config keys that decide WHERE this kind's secrets are sent (server,
45110
- * base URL, instance, chat, recipient). A save that changes any of them
45111
- * while leaving a secret redacted is refused by the provider (D634), so an
45112
- * editor uses this to ask for the secret on exactly those edits instead of
45113
- * on every edit.
45114
- *
45115
- * Optional: absent from a provider that holds no secret (the Home Assistant
45116
- * kinds) and from a provider older than this field — an editor that finds
45117
- * it absent must assume ANY edit may need the secret.
45118
- */
45119
- destinationKeys: array(string()).optional(),
45120
- supportsDiscovery: boolean(),
45121
- /**
45122
- * Extra delivery parameters a rule may set for a target of this kind (D938).
45123
- * Absent = none; the rule editor then offers nothing.
45124
- */
45125
- deliveryParams: array(DeliveryParamSchema).optional(),
45126
- caps: TargetKindCapsSchema
45127
- });
45128
- /**
45129
- * A persisted target. `config` holds secrets; providers REDACT secret fields
45130
- * (return a presence marker only) when serving `listTargets` — never
45131
- * round-trip a stored secret to the UI.
45132
- */
45133
- var TargetSchema = object({
45134
- id: string(),
45135
- name: string(),
45136
- kind: string(),
45137
- addonId: string(),
45138
- enabled: boolean(),
45139
- config: record(string(), unknown())
45140
- });
45141
- /** A discovery-surfaced candidate (config is partial + non-secret). */
45142
- var DiscoveredTargetSchema = object({
45143
- kind: string(),
45144
- suggestedName: string(),
45145
- config: record(string(), unknown())
45146
- });
45147
- /** The degrade engine's report — what was resolved / dropped / degraded. */
45148
- var RenderedAsSchema = object({
45149
- level: string(),
45150
- format: NotificationFormatSchema,
45151
- attachmentsSent: number().int().nonnegative(),
45152
- actionsSent: number().int().nonnegative(),
45153
- truncated: boolean(),
45154
- dropped: array(string())
45155
- });
45156
- var SendResultSchema = object({
45157
- success: boolean(),
45158
- error: string().optional(),
45159
- renderedAs: RenderedAsSchema.optional()
45160
- });
45161
- /** Same shape as SendResult — kept as a distinct name for the test panel. */
45162
- var TestResultSchema = SendResultSchema;
45163
- /**
45164
- * Pre-save credential probe against a partial (unsaved) target config.
45165
- * `resolvedUrl` never includes secrets (token stripped from path).
45166
- */
45167
- var ProbeTargetConfigResultSchema = object({
45168
- ok: boolean(),
45169
- resolvedUrl: string(),
45170
- httpStatus: number().int().optional(),
45171
- stateInstance: string().optional(),
45172
- error: string().optional()
45173
- });
45174
- method(object({}), array(TargetKindSchema)), method(object({}), array(TargetSchema), { auth: "admin" }), method(object({ targetId: string() }), TargetSchema, { auth: "admin" }), method(object({
45175
- kind: string(),
45176
- config: record(string(), unknown()).optional(),
45177
- /**
45178
- * When editing / duplicating, the blank password field never round-trips
45179
- * the stored token. Pass the source target id so the provider can restore
45180
- * secrets server-side before dialling (same merge as upsert).
45181
- */
45182
- targetId: string().optional()
45183
- }), array(DiscoveredTargetSchema), { auth: "admin" }), method(object({
45184
- kind: string(),
45185
- config: record(string(), unknown()),
45186
- /** See `discoverTargets.targetId` — restore stored secrets for a blank password. */
45187
- targetId: string().optional()
45188
- }), ProbeTargetConfigResultSchema, {
45189
- kind: "mutation",
45190
- auth: "admin"
45191
- }), method(object({
45192
- targetId: string(),
45193
- notification: NotificationSchema
45194
- }), SendResultSchema, {
45195
- kind: "mutation",
45196
- auth: "admin"
45197
- }), method(object({
45198
- targetId: string(),
45199
- sample: NotificationSchema.optional()
45200
- }), TestResultSchema, {
45201
- kind: "mutation",
45202
- auth: "admin"
45203
- }), method(object({
45204
- target: TargetSchema,
45205
- /**
45206
- * Duplicate flow: create a NEW target id while copying secrets from an
45207
- * existing row. The UI never holds the stored token; blank / redacted
45208
- * password fields are restored from this source (D634 still applies if
45209
- * destinations diverge without a re-typed secret).
45210
- */
45211
- cloneSecretsFrom: string().optional()
45212
- }), TargetSchema, {
45213
- kind: "mutation",
45214
- auth: "admin"
45215
- }), method(object({ targetId: string() }), _void(), {
45216
- kind: "mutation",
45217
- auth: "admin"
45218
- }), method(object({
45219
- targetId: string(),
45220
- enabled: boolean()
45221
- }), _void(), {
45222
- kind: "mutation",
45223
- auth: "admin"
45224
- });
45225
45254
  _enum([
45226
45255
  "automation",
45227
45256
  "action",
@@ -49761,37 +49790,6 @@ method(object({
49761
49790
  kind: "mutation",
49762
49791
  auth: "admin"
49763
49792
  }), method(object({ blockIds: array(string()) }), object({ states: array(CompositionBlockStateSchema) }), { auth: "admin" });
49764
- var ConnectionTestOutcomeSchema = discriminatedUnion("outcome", [
49765
- object({
49766
- outcome: literal("validated"),
49767
- /** Round-trip of the sign-in, when the provider measured it. */
49768
- latencyMs: number().nonnegative().optional(),
49769
- /** Optional human detail worth showing next to the tick
49770
- * ("3 devices visible on this account"). */
49771
- detail: string().optional()
49772
- }).strict(),
49773
- object({
49774
- outcome: literal("rejected"),
49775
- error: string()
49776
- }).strict(),
49777
- object({
49778
- outcome: literal("inconclusive"),
49779
- error: string()
49780
- }).strict()
49781
- ]);
49782
- var ConnectionTestInputSchema = object({
49783
- /** Candidate integration settings, exactly as the create form collected them. */
49784
- settings: record(string(), unknown()) });
49785
- /**
49786
- * What the provider's test actually DOES, so the UI can say it in words before
49787
- * the operator presses the button ("Signs in to the Dreo cloud"). Purely
49788
- * descriptive — it never changes routing.
49789
- */
49790
- var ConnectionTestDescriptorSchema = object({ label: string() });
49791
- method(ConnectionTestInputSchema, ConnectionTestOutcomeSchema, {
49792
- kind: "mutation",
49793
- auth: "admin"
49794
- }), method(_void(), ConnectionTestDescriptorSchema, { auth: "admin" });
49795
49793
  /**
49796
49794
  * Upstream-system connectivity sensor — distinct from `device-status`,
49797
49795
  * which is the kernel-managed online/offline flag for the device's
@@ -56968,10 +56966,9 @@ var AvailableIntegrationTypeSchema = object({
56968
56966
  * locations" checkbox. Provider-declared in the addon manifest. */
56969
56967
  supportsLocationImport: boolean(),
56970
56968
  /**
56971
- * True when this integration DECLARES a pre-creation test (the
56972
- * `connection-test` cap, or a broker whose settings it stores). Drives the
56973
- * Test button: an integration that cannot be tested must say so up front
56974
- * rather than offering a button that always answers the same nonsense.
56969
+ * True when this integration's instances declare a Test (`integration-instances.describe().canTest`,
56970
+ * D1016). An integration that cannot be tested must say so up front rather than offering a
56971
+ * button that always answers the same nonsense.
56975
56972
  */
56976
56973
  canTest: boolean(),
56977
56974
  existingInstances: array(object({
@@ -57025,7 +57022,9 @@ var CreateIntegrationInputSchema = object({
57025
57022
  info: record(string(), unknown()).optional(),
57026
57023
  /** `stableId` of the discovery candidate the form was seeded from (D984). */
57027
57024
  originStableId: string().optional(),
57028
- settings: record(string(), unknown()).optional()
57025
+ settings: record(string(), unknown()).optional(),
57026
+ /** The instance kind being created, for a provider with several; omitted = its only testable kind. */
57027
+ kind: string().min(1).optional()
57029
57028
  });
57030
57029
  var UpdateIntegrationInputSchema = object({
57031
57030
  id: string(),
@@ -57051,13 +57050,7 @@ method(_void(), array(IntegrationWithStateSchema)), method(object({ id: string()
57051
57050
  }), method(object({ id: string() }), DeleteIntegrationResultSchema, {
57052
57051
  kind: "mutation",
57053
57052
  auth: "admin"
57054
- }), method(_void(), array(AvailableIntegrationTypeSchema), { auth: "admin" }), method(object({
57055
- addonId: string(),
57056
- settings: record(string(), unknown())
57057
- }), TestConnectionResultSchema, {
57058
- kind: "mutation",
57059
- auth: "admin"
57060
- });
57053
+ }), method(_void(), array(AvailableIntegrationTypeSchema), { auth: "admin" });
57061
57054
  /**
57062
57055
  * `integration-instances` - the connection of an addon that holds ONE or SEVERAL
57063
57056
  * (an account, a relay, a destination) as typed records (D985, D986). The addon's
@@ -65800,13 +65793,6 @@ var AddBrokerInputSchema = object({
65800
65793
  });
65801
65794
  var AddBrokerResultSchema = object({ id: string() });
65802
65795
  var IdInputSchema = object({ id: string() });
65803
- var TestResultSchema$1 = discriminatedUnion("ok", [object({
65804
- ok: literal(true),
65805
- latencyMs: number()
65806
- }), object({
65807
- ok: literal(false),
65808
- error: string()
65809
- })]);
65810
65796
  var StartEmbeddedInputSchema = object({
65811
65797
  port: number().int().min(1).max(65535).default(1883),
65812
65798
  /** Allow anonymous connect (no username/password). Default: false. */
@@ -65829,9 +65815,6 @@ method(_void(), array(BrokerInfoSchema)), method(IdInputSchema, BrokerConnection
65829
65815
  }), method(IdInputSchema, _void(), {
65830
65816
  kind: "mutation",
65831
65817
  auth: "admin"
65832
- }), method(IdInputSchema, TestResultSchema$1, {
65833
- kind: "mutation",
65834
- auth: "admin"
65835
65818
  }), method(StartEmbeddedInputSchema, StartEmbeddedResultSchema, {
65836
65819
  kind: "mutation",
65837
65820
  auth: "admin"
@@ -79648,7 +79631,7 @@ var TrainingProviderTypeSchema = object({
79648
79631
  label: string(),
79649
79632
  /** Path under the addon package (e.g. `assets/training-modal/icon.svg`). */
79650
79633
  iconAsset: string(),
79651
- /** Owning `training-provider` addon — collection selector for createEntry. */
79634
+ /** Owning `training-provider` addon. */
79652
79635
  addonId: string(),
79653
79636
  /**
79654
79637
  * Fields for one entry of this type (credentials + defaults). Absent on a
@@ -79693,36 +79676,6 @@ var TrainingProviderDescriptorSchema = object({
79693
79676
  */
79694
79677
  formValues: record(string(), unknown()).optional()
79695
79678
  });
79696
- /**
79697
- * Patch one entry's name, credentials and defaults. Pin with owning `{ addonId }`.
79698
- * An omitted or empty `tokenSecret` means KEEP the stored secret (D787).
79699
- * `{ $secretClear: true }` clears it.
79700
- */
79701
- var TrainingProviderUpdateEntryInputSchema = object({
79702
- entryId: string().min(1),
79703
- name: string().min(1),
79704
- tokenId: string().optional(),
79705
- tokenSecret: union([string(), object({ $secretClear: literal(true) })]).optional(),
79706
- environment: string().optional(),
79707
- gpuType: string().optional(),
79708
- region: string().optional(),
79709
- costCapUsd: number().nonnegative().optional(),
79710
- maxRuntimeSec: number().int().positive().optional(),
79711
- failedDatasetGraceHours: number().nonnegative().optional()
79712
- });
79713
- var TrainingCredentialCheckSchema = object({
79714
- ok: boolean(),
79715
- /** Workspace / account name, when the provider says. */
79716
- account: string().optional(),
79717
- reason: _enum([
79718
- "missing",
79719
- "invalid",
79720
- "forbidden",
79721
- "network",
79722
- "quota"
79723
- ]).optional(),
79724
- detail: string().optional()
79725
- });
79726
79679
  var ProviderJobStateSchema = _enum([
79727
79680
  "pending",
79728
79681
  "starting",
@@ -79770,22 +79723,6 @@ var TrainingLogLineSchema = object({
79770
79723
  text: string()
79771
79724
  });
79772
79725
  method(object({}), array(TrainingProviderDescriptorSchema).readonly(), { auth: "admin" }), method(object({}), array(TrainingProviderTypeSchema).readonly(), { auth: "admin" }), method(object({}), array(TrainingProviderEntrySchema).readonly(), { auth: "admin" }), method(object({
79773
- typeId: string().min(1),
79774
- name: string().min(1)
79775
- }), object({ entryId: string() }), {
79776
- kind: "mutation",
79777
- auth: "admin"
79778
- }), method(object({ entryId: string().min(1) }), object({ ok: literal(true) }), {
79779
- kind: "mutation",
79780
- auth: "admin"
79781
- }), method(TrainingProviderUpdateEntryInputSchema, object({ ok: literal(true) }), {
79782
- kind: "mutation",
79783
- auth: "admin"
79784
- }), method(object({ entryId: string().min(1) }), TrainingCredentialCheckSchema, {
79785
- kind: "mutation",
79786
- auth: "admin",
79787
- timeoutMs: 3e4
79788
- }), method(object({
79789
79726
  entryId: string().min(1),
79790
79727
  gpuType: string(),
79791
79728
  region: string(),
@@ -85764,20 +85701,6 @@ Object.freeze({
85764
85701
  access: "view",
85765
85702
  role: "admin"
85766
85703
  },
85767
- "connectionTest.describeTest": {
85768
- capName: "connection-test",
85769
- capScope: "system",
85770
- addonId: null,
85771
- access: "view",
85772
- role: "admin"
85773
- },
85774
- "connectionTest.testSettings": {
85775
- capName: "connection-test",
85776
- capScope: "system",
85777
- addonId: null,
85778
- access: "create",
85779
- role: "admin"
85780
- },
85781
85704
  "connectivity.getStatus": {
85782
85705
  capName: "connectivity",
85783
85706
  capScope: "device",
@@ -88144,13 +88067,6 @@ Object.freeze({
88144
88067
  access: "view",
88145
88068
  role: "admin"
88146
88069
  },
88147
- "integrations.testConnection": {
88148
- capName: "integrations",
88149
- capScope: "system",
88150
- addonId: null,
88151
- access: "create",
88152
- role: "admin"
88153
- },
88154
88070
  "integrations.update": {
88155
88071
  capName: "integrations",
88156
88072
  capScope: "system",
@@ -89383,13 +89299,6 @@ Object.freeze({
89383
89299
  access: "create",
89384
89300
  role: "admin"
89385
89301
  },
89386
- "mqttBroker.testConnection": {
89387
- capName: "mqtt-broker",
89388
- capScope: "system",
89389
- addonId: null,
89390
- access: "create",
89391
- role: "admin"
89392
- },
89393
89302
  "nativeObjectDetection.getOptions": {
89394
89303
  capName: "native-object-detection",
89395
89304
  capScope: "device",
@@ -94220,20 +94129,6 @@ Object.freeze({
94220
94129
  access: "create",
94221
94130
  role: "admin"
94222
94131
  },
94223
- "trainingProvider.createEntry": {
94224
- capName: "training-provider",
94225
- capScope: "system",
94226
- addonId: null,
94227
- access: "create",
94228
- role: "admin"
94229
- },
94230
- "trainingProvider.deleteEntry": {
94231
- capName: "training-provider",
94232
- capScope: "system",
94233
- addonId: null,
94234
- access: "delete",
94235
- role: "admin"
94236
- },
94237
94132
  "trainingProvider.describe": {
94238
94133
  capName: "training-provider",
94239
94134
  capScope: "system",
@@ -94304,13 +94199,6 @@ Object.freeze({
94304
94199
  access: "create",
94305
94200
  role: "admin"
94306
94201
  },
94307
- "trainingProvider.updateEntry": {
94308
- capName: "training-provider",
94309
- capScope: "system",
94310
- addonId: null,
94311
- access: "create",
94312
- role: "admin"
94313
- },
94314
94202
  "trainingProvider.uploadDataset": {
94315
94203
  capName: "training-provider",
94316
94204
  capScope: "system",
@@ -94318,13 +94206,6 @@ Object.freeze({
94318
94206
  access: "create",
94319
94207
  role: "admin"
94320
94208
  },
94321
- "trainingProvider.validateCredentials": {
94322
- capName: "training-provider",
94323
- capScope: "system",
94324
- addonId: null,
94325
- access: "create",
94326
- role: "admin"
94327
- },
94328
94209
  "turnProvider.getTurnServers": {
94329
94210
  capName: "turn-provider",
94330
94211
  capScope: "system",