@camstack/addon-provider-homematic 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.js CHANGED
@@ -5990,7 +5990,7 @@ var ZodIssueCode = {
5990
5990
  var ZodFirstPartyTypeKind;
5991
5991
  ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {});
5992
5992
  //#endregion
5993
- //#region ../types/dist/sleep-CmjWurK5.mjs
5993
+ //#region ../types/dist/sleep-CdKka2ri.mjs
5994
5994
  /**
5995
5995
  * The audio chunk plane's byte format, and the ONE expansion from a coded
5996
5996
  * window to float samples (D455).
@@ -9537,30 +9537,98 @@ function normalizeAddonInitResult(result) {
9537
9537
  if (Array.isArray(result)) return { providers: result };
9538
9538
  return result;
9539
9539
  }
9540
+ object({
9541
+ field: string().min(1),
9542
+ on: literal("advance")
9543
+ });
9540
9544
  /**
9541
- * The share-view scope kinds a share-link token can carry. The hub mints
9542
- * and validates them (`ShareViewGrantSchema` builds its
9543
- * enum from this list); a data plane names the kinds it ACCEPTS in `share`.
9545
+ * Output schema shared by the contribution + live methods.
9546
+ *
9547
+ * Mirrors the `ConfigUISchemaWithValues` shape (sections[] + optional
9548
+ * tabs[]) without importing from `../interfaces/config-ui.js` — a
9549
+ * concrete-but-lenient Zod object keeps tRPC output inference happy
9550
+ * (using `z.unknown()` here collapses unrelated router branches to
9551
+ * `unknown` when the generator re-inlines the huge AppRouter type).
9552
+ *
9553
+ * `.passthrough()` on sections/fields accepts whatever FormBuilder
9554
+ * extensions the caller adds (showWhen, displayScale, …) without
9555
+ * rebuilding every time a new field kind is introduced.
9544
9556
  */
9545
- var SHARE_VIEW_KINDS = ["grid-view", "events-view"];
9546
- /** The wire shape of {@link PeerBytesTicket} — see the type for what it is. */
9547
- var PeerBytesTicketSchema = object({
9548
- /** `http://127.0.0.1:<port>/<token>`. One `GET` takes it. */
9549
- url: string().min(1),
9550
- /**
9551
- * The HOST node this URL means something on — the hub or a named agent,
9552
- * never a runner. {@link AddonPeerBytes.open} compares it to its own and
9553
- * refuses `cross-node` by name when they differ, without dialling.
9554
- */
9555
- hostNodeId: string().min(1),
9556
- expiresAtMs: number().int().nonnegative(),
9557
- /**
9558
- * What the producer DECLARED the body to be, when it knows — `null` when it
9559
- * does not. Never `0` for unknown (D393): a consumer sizing a bound off this
9560
- * must be able to tell "the producer did not say" from "the body is empty".
9561
- */
9562
- declaredBytes: number().int().nonnegative().nullable()
9557
+ var ContributionSectionSchema = object({
9558
+ id: string(),
9559
+ title: string(),
9560
+ description: string().optional(),
9561
+ style: _enum(["card", "accordion"]).optional(),
9562
+ defaultCollapsed: boolean().optional(),
9563
+ columns: union([
9564
+ literal(1),
9565
+ literal(2),
9566
+ literal(3),
9567
+ literal(4)
9568
+ ]).optional(),
9569
+ tab: string().optional(),
9570
+ location: _enum([
9571
+ "settings",
9572
+ "top-tab",
9573
+ "hero"
9574
+ ]).optional(),
9575
+ order: number().optional(),
9576
+ fields: array(any())
9563
9577
  });
9578
+ object({
9579
+ tabs: array(object({
9580
+ id: string(),
9581
+ label: string(),
9582
+ icon: string(),
9583
+ order: number().optional()
9584
+ })).optional(),
9585
+ sections: array(ContributionSectionSchema)
9586
+ }).nullable();
9587
+ object({ deviceId: number() }), object({ deviceId: number() }), object({
9588
+ deviceId: number(),
9589
+ patch: record(string(), unknown())
9590
+ }), object({ success: literal(true) });
9591
+ object({ deviceId: number() }), unknown().nullable();
9592
+ function method(input, output, options) {
9593
+ return {
9594
+ input,
9595
+ output,
9596
+ kind: options?.kind ?? "query",
9597
+ ...options?.auth !== void 0 ? { auth: options.auth } : {},
9598
+ ...options?.access !== void 0 ? { access: options.access } : {},
9599
+ ...options?.role !== void 0 ? { role: options.role } : {},
9600
+ ...options?.caller !== void 0 ? { caller: options.caller } : {},
9601
+ timeoutMs: options?.timeoutMs
9602
+ };
9603
+ }
9604
+ /**
9605
+ * A wrapper/system-only method: served exclusively by the cap's system-level
9606
+ * provider (`InferProvider`), and OPTIONAL on `InferNativeProvider` so per-device
9607
+ * driver natives don't stub out a wrapper concern (e.g. a cross-device cache
9608
+ * overview). The `systemOnly: true` literal is what `InferNativeProvider` keys on.
9609
+ */
9610
+ function systemMethod(input, output, options) {
9611
+ return {
9612
+ ...method(input, output, options),
9613
+ systemOnly: true
9614
+ };
9615
+ }
9616
+ /**
9617
+ * A method a SOURCE of a collection cap may legitimately not serve — OPTIONAL
9618
+ * on `InferProvider`. The `providerOptional: true` literal is what
9619
+ * `InferProvider` keys on; see {@link CapabilityMethodSchema.providerOptional}
9620
+ * for when this is the honest answer and when it is a soft stub.
9621
+ */
9622
+ function optionalMethod(input, output, options) {
9623
+ return {
9624
+ ...method(input, output, options),
9625
+ providerOptional: true
9626
+ };
9627
+ }
9628
+ /** Shorthand to define an event schema */
9629
+ function event(data) {
9630
+ return { data };
9631
+ }
9564
9632
  function defOf(schema) {
9565
9633
  const zodBag = Reflect.get(schema, "_zod");
9566
9634
  if (typeof zodBag !== "object" || zodBag === null) return {};
@@ -9817,98 +9885,30 @@ function defineEntryKind(name, spec) {
9817
9885
  if (defined === void 0) throw new DeclarationRefusedError(`entry kind "${name}" was not built`);
9818
9886
  return defined;
9819
9887
  }
9820
- object({
9821
- field: string().min(1),
9822
- on: literal("advance")
9823
- });
9824
9888
  /**
9825
- * Output schema shared by the contribution + live methods.
9826
- *
9827
- * Mirrors the `ConfigUISchemaWithValues` shape (sections[] + optional
9828
- * tabs[]) without importing from `../interfaces/config-ui.js` — a
9829
- * concrete-but-lenient Zod object keeps tRPC output inference happy
9830
- * (using `z.unknown()` here collapses unrelated router branches to
9831
- * `unknown` when the generator re-inlines the huge AppRouter type).
9832
- *
9833
- * `.passthrough()` on sections/fields accepts whatever FormBuilder
9834
- * extensions the caller adds (showWhen, displayScale, …) without
9835
- * rebuilding every time a new field kind is introduced.
9889
+ * The share-view scope kinds a share-link token can carry. The hub mints
9890
+ * and validates them (`ShareViewGrantSchema` builds its
9891
+ * enum from this list); a data plane names the kinds it ACCEPTS in `share`.
9836
9892
  */
9837
- var ContributionSectionSchema = object({
9838
- id: string(),
9839
- title: string(),
9840
- description: string().optional(),
9841
- style: _enum(["card", "accordion"]).optional(),
9842
- defaultCollapsed: boolean().optional(),
9843
- columns: union([
9844
- literal(1),
9845
- literal(2),
9846
- literal(3),
9847
- literal(4)
9848
- ]).optional(),
9849
- tab: string().optional(),
9850
- location: _enum([
9851
- "settings",
9852
- "top-tab",
9853
- "hero"
9854
- ]).optional(),
9855
- order: number().optional(),
9856
- fields: array(any())
9893
+ var SHARE_VIEW_KINDS = ["grid-view", "events-view"];
9894
+ /** The wire shape of {@link PeerBytesTicket} — see the type for what it is. */
9895
+ var PeerBytesTicketSchema = object({
9896
+ /** `http://127.0.0.1:<port>/<token>`. One `GET` takes it. */
9897
+ url: string().min(1),
9898
+ /**
9899
+ * The HOST node this URL means something on — the hub or a named agent,
9900
+ * never a runner. {@link AddonPeerBytes.open} compares it to its own and
9901
+ * refuses `cross-node` by name when they differ, without dialling.
9902
+ */
9903
+ hostNodeId: string().min(1),
9904
+ expiresAtMs: number().int().nonnegative(),
9905
+ /**
9906
+ * What the producer DECLARED the body to be, when it knows — `null` when it
9907
+ * does not. Never `0` for unknown (D393): a consumer sizing a bound off this
9908
+ * must be able to tell "the producer did not say" from "the body is empty".
9909
+ */
9910
+ declaredBytes: number().int().nonnegative().nullable()
9857
9911
  });
9858
- object({
9859
- tabs: array(object({
9860
- id: string(),
9861
- label: string(),
9862
- icon: string(),
9863
- order: number().optional()
9864
- })).optional(),
9865
- sections: array(ContributionSectionSchema)
9866
- }).nullable();
9867
- object({ deviceId: number() }), object({ deviceId: number() }), object({
9868
- deviceId: number(),
9869
- patch: record(string(), unknown())
9870
- }), object({ success: literal(true) });
9871
- object({ deviceId: number() }), unknown().nullable();
9872
- function method(input, output, options) {
9873
- return {
9874
- input,
9875
- output,
9876
- kind: options?.kind ?? "query",
9877
- ...options?.auth !== void 0 ? { auth: options.auth } : {},
9878
- ...options?.access !== void 0 ? { access: options.access } : {},
9879
- ...options?.role !== void 0 ? { role: options.role } : {},
9880
- ...options?.caller !== void 0 ? { caller: options.caller } : {},
9881
- timeoutMs: options?.timeoutMs
9882
- };
9883
- }
9884
- /**
9885
- * A wrapper/system-only method: served exclusively by the cap's system-level
9886
- * provider (`InferProvider`), and OPTIONAL on `InferNativeProvider` so per-device
9887
- * driver natives don't stub out a wrapper concern (e.g. a cross-device cache
9888
- * overview). The `systemOnly: true` literal is what `InferNativeProvider` keys on.
9889
- */
9890
- function systemMethod(input, output, options) {
9891
- return {
9892
- ...method(input, output, options),
9893
- systemOnly: true
9894
- };
9895
- }
9896
- /**
9897
- * A method a SOURCE of a collection cap may legitimately not serve — OPTIONAL
9898
- * on `InferProvider`. The `providerOptional: true` literal is what
9899
- * `InferProvider` keys on; see {@link CapabilityMethodSchema.providerOptional}
9900
- * for when this is the honest answer and when it is a soft stub.
9901
- */
9902
- function optionalMethod(input, output, options) {
9903
- return {
9904
- ...method(input, output, options),
9905
- providerOptional: true
9906
- };
9907
- }
9908
- /** Shorthand to define an event schema */
9909
- function event(data) {
9910
- return { data };
9911
- }
9912
9912
  var READING_QUANTITIES = [
9913
9913
  "temperature",
9914
9914
  "pressure",
@@ -10526,7 +10526,6 @@ var CAP_NAMES = Object.freeze([
10526
10526
  "climate-control",
10527
10527
  "color",
10528
10528
  "composer",
10529
- "connection-test",
10530
10529
  "connectivity",
10531
10530
  "consumables",
10532
10531
  "contact",
@@ -12546,8 +12545,7 @@ Object.freeze({
12546
12545
  "offerArtifact": 3e5,
12547
12546
  "readResult": 3e5,
12548
12547
  "submitJob": 18e5,
12549
- "uploadDataset": 72e5,
12550
- "validateCredentials": 3e4
12548
+ "uploadDataset": 72e5
12551
12549
  }
12552
12550
  });
12553
12551
  object({
@@ -13902,6 +13900,432 @@ var IntegrationInstanceRefSchema = object({
13902
13900
  ]),
13903
13901
  candidateStableId: string().optional()
13904
13902
  });
13903
+ /**
13904
+ * notification-output — canonical, capability-gated notification delivery.
13905
+ *
13906
+ * Apprise-derived model (see
13907
+ * `docs/superpowers/specs/2026-07-03-notification-output-notifier-matrix.md`):
13908
+ * callers emit ONE canonical `Notification`; each provider declares a
13909
+ * per-kind capability descriptor (`TargetKind`), and the pure degrade
13910
+ * engine (`@camstack/types` `prepareNotification`) transcodes / degrades the
13911
+ * message to what the kind supports — callers never special-case a service.
13912
+ *
13913
+ * DESIGN DECISIONS (locked):
13914
+ * - Target CRUD lives on THIS cap (`upsertTarget` / `deleteTarget` /
13915
+ * `setTargetEnabled`), each provider persisting via the `settings-store`
13916
+ * cap. Rationale: the admin UI needs one uniform surface across the
13917
+ * notifiers addon AND the HA addon; the addon-`globalSettingsSchema`-array
13918
+ * alternative would fork the UI per addon and cannot host the
13919
+ * discovery→adopt flow.
13920
+ * - `listTargetKinds` / `listTargets` / `discoverTargets` return arrays →
13921
+ * the generated cap-mount auto-`concatCollection`-fans them across every
13922
+ * registered provider (notifiers addon + HA addon) so one catalog is
13923
+ * routable. `send` / `testTarget` / CRUD route to ONE provider by the
13924
+ * `addonId` the generated collection router extracts from the call input.
13925
+ * - `Attachment.bytes` is `Uint8Array`. Transport-safe: superjson (the tRPC
13926
+ * transformer) + UDS MsgPack both round-trip typed arrays — already used by
13927
+ * `storage` / `storage-provider` / `recording` caps over the same path. No
13928
+ * base64 fallback needed.
13929
+ *
13930
+ * TODO (deferred, closed-set change — separate decision): add
13931
+ * `providerKind: 'notify'` so notification providers surface on the unified
13932
+ * admin "Integrations" page.
13933
+ */
13934
+ /**
13935
+ * Zentik-derived typed-media enum — the superset across every kind. Each
13936
+ * adapter picks what it supports and the degrade engine filters the rest.
13937
+ */
13938
+ var AttachmentMediaTypeSchema = _enum([
13939
+ "image",
13940
+ "video",
13941
+ "gif",
13942
+ "audio",
13943
+ "icon"
13944
+ ]);
13945
+ /**
13946
+ * A single attachment. Exactly one of `url` (remote source, most adapters
13947
+ * prefer this) or `bytes` (inline source; required for Pushover-style
13948
+ * bytes-only kinds) MUST be present — the degrade engine expresses a
13949
+ * url→bytes fetch as a `needsFetch` directive the adapter executes.
13950
+ */
13951
+ var AttachmentSchema = object({
13952
+ mediaType: AttachmentMediaTypeSchema,
13953
+ url: string().optional(),
13954
+ bytes: _instanceof(Uint8Array).optional(),
13955
+ mime: string().optional(),
13956
+ name: string().optional()
13957
+ }).refine((a) => a.url !== void 0 || a.bytes !== void 0, { message: "Attachment requires either `url` or `bytes`" });
13958
+ var NotificationFormatSchema = _enum([
13959
+ "text",
13960
+ "markdown",
13961
+ "html"
13962
+ ]);
13963
+ /**
13964
+ * The CLOSED icon vocabulary an action button may use.
13965
+ *
13966
+ * A closed set, not a free string, and that is the whole point: an arbitrary
13967
+ * icon name is one that ntfy renders, zentik silently drops, and nobody
13968
+ * notices — the same class of gap as a zone vocabulary nothing produced
13969
+ * ([D35](../../../docs/decisions/adr-0035.md)). Every adapter maps this set or
13970
+ * declares `actionIcons: false` and the degrade engine strips the field.
13971
+ *
13972
+ * Named by INTENT, never by glyph. "check" would tie the vocabulary to one
13973
+ * renderer's icon set; "acknowledge" survives an adapter that draws it
13974
+ * differently.
13975
+ *
13976
+ * ── A TOKEN IS NOT A WIRE VALUE ─────────────────────────────────────
13977
+ *
13978
+ * These names are for US. **No adapter may forward one verbatim.** Each maps
13979
+ * the whole set onto its own renderer's vocabulary through a
13980
+ * `Record<NotificationActionIcon, string>` — a Record, never a lookup with a
13981
+ * fallback, so adding a member here fails every adapter's build until someone
13982
+ * decides its glyph, which is the only place that decision can be made
13983
+ * honestly.
13984
+ *
13985
+ * This paragraph is the bug. Zentik declared `actionIcons: true` and passed
13986
+ * `disarm` straight through; iOS feeds that string to
13987
+ * `UNNotificationActionIcon(systemImageName:)`, `disarm` is not an SF Symbol,
13988
+ * and every snooze and alarm button arrived BLANK. A pass-through is not a
13989
+ * mapping, and "the field is documented" is not "the value renders".
13990
+ *
13991
+ * Adding a member is TRAIN-BOUND. The enum lives in the published
13992
+ * `@camstack/server` closure and the cap seam validates against the HUB's copy,
13993
+ * so an addon that emits a token the running hub does not know does not lose an
13994
+ * icon — its whole `send` fails Zod validation and the notification never
13995
+ * arrives. Never emit a new token from an addon before the train carrying it.
13996
+ */
13997
+ var NotificationActionIconSchema = _enum([
13998
+ "acknowledge",
13999
+ "dismiss",
14000
+ "silence",
14001
+ "snooze",
14002
+ "view",
14003
+ "play",
14004
+ "open",
14005
+ "close",
14006
+ "lock",
14007
+ "unlock",
14008
+ "arm",
14009
+ "arm-home",
14010
+ "arm-away",
14011
+ "arm-night",
14012
+ "disarm",
14013
+ "light",
14014
+ "alert",
14015
+ "camera"
14016
+ ]);
14017
+ /** A single tap-through action button. */
14018
+ var NotificationActionSchema = object({
14019
+ id: string(),
14020
+ label: string(),
14021
+ url: string().optional(),
14022
+ /** Dropped by the degrade engine for a kind with `caps.actionIcons: false`. */
14023
+ icon: NotificationActionIconSchema.optional(),
14024
+ /**
14025
+ * Renders in a warning style where the notifier supports it.
14026
+ *
14027
+ * A HINT, never a gate. The callback's authority is its token and nothing
14028
+ * else — see `notification-center/action-token.ts` for what that does and
14029
+ * does not buy.
14030
+ */
14031
+ destructive: boolean().optional(),
14032
+ /**
14033
+ * How the tap should REACH the url.
14034
+ *
14035
+ * `navigate` (absent, and every button authored before this field) opens it:
14036
+ * the phone leaves the notification and shows whatever the callback returns.
14037
+ * That is right for a button whose answer the operator wants to read.
14038
+ *
14039
+ * `background` fires it as a POST and stays put. It exists for the buttons
14040
+ * whose whole point is not to interrupt — "silence this for 30 minutes" is
14041
+ * an answer to the notification, and being thrown into a browser tab to
14042
+ * confirm it costs more attention than the notification did. A backend that
14043
+ * cannot do a background call renders it as an ordinary link (the adapters
14044
+ * fall back rather than dropping the button), so this is a preference, never
14045
+ * a requirement.
14046
+ */
14047
+ mode: _enum(["navigate", "background"]).optional()
14048
+ });
14049
+ /** A delivery parameter value: what a notifier declared it takes. */
14050
+ var DeliveryParamValueSchema = union([
14051
+ string(),
14052
+ number(),
14053
+ boolean()
14054
+ ]);
14055
+ /**
14056
+ * One extra delivery parameter a notifier KIND declares (D938). A rule that
14057
+ * addresses a target of that kind may set it; a kind that declares nothing is
14058
+ * never handed one. The admin UI derives its control from this descriptor —
14059
+ * no editor knows a service by name.
14060
+ *
14061
+ * Optional fields are `.optional()`, never `.default()` (a Zod default does not
14062
+ * run on the addon cap path).
14063
+ */
14064
+ var DeliveryParamSchema = object({
14065
+ key: string().min(1),
14066
+ label: string(),
14067
+ /** i18n key of the label, resolved by the declaring addon's namespace. */
14068
+ labelKey: string().optional(),
14069
+ type: _enum([
14070
+ "enum",
14071
+ "number",
14072
+ "boolean",
14073
+ "string"
14074
+ ]),
14075
+ /** `enum` only: the closed set of accepted values. */
14076
+ options: array(object({
14077
+ value: string(),
14078
+ label: string()
14079
+ })).optional(),
14080
+ /** `number` only. */
14081
+ min: number().optional(),
14082
+ max: number().optional(),
14083
+ /** What the notifier does when the rule sets nothing; shown as the placeholder. */
14084
+ default: DeliveryParamValueSchema.optional()
14085
+ });
14086
+ /**
14087
+ * The canonical notification. `body` is the only hard field (Apprise model).
14088
+ * `priority` is a 5-level ORDINAL (1=lowest … 3=normal(default) … 5=urgent),
14089
+ * NOT a fixed severity enum — each kind declares its own `caps.levels` and
14090
+ * the adapter maps this ordinal onto its native level. `level?` is an
14091
+ * optional kind-native level id (`emergency`, `silent`, …) that overrides
14092
+ * `priority` for that one target.
14093
+ */
14094
+ var NotificationSchema = object({
14095
+ body: string(),
14096
+ title: string().optional(),
14097
+ format: NotificationFormatSchema.default("text"),
14098
+ priority: number().int().min(1).max(5).default(3),
14099
+ level: string().optional(),
14100
+ attachments: array(AttachmentSchema).optional(),
14101
+ clickUrl: string().optional(),
14102
+ actions: array(NotificationActionSchema).optional(),
14103
+ sound: string().optional(),
14104
+ ttl: number().optional(),
14105
+ tag: string().optional(),
14106
+ deviceId: number().optional(),
14107
+ eventId: string().optional(),
14108
+ metadata: record(string(), unknown()).optional(),
14109
+ /**
14110
+ * Values for the parameters the target's kind DECLARES in
14111
+ * {@link TargetKindSchema} `deliveryParams`. Already validated against the
14112
+ * declaration by the sender; a notifier reads only the keys it declared.
14113
+ */
14114
+ delivery: record(string(), DeliveryParamValueSchema).optional()
14115
+ });
14116
+ /** One declared native severity/priority level for a kind. */
14117
+ var TargetKindLevelSchema = object({
14118
+ id: string(),
14119
+ label: string(),
14120
+ /** Which canonical priority (1..5) this level maps to. `null` = qualitative-only. */
14121
+ ordinal: number().int().min(1).max(5).nullable(),
14122
+ flags: object({
14123
+ critical: boolean().optional(),
14124
+ silent: boolean().optional(),
14125
+ noPush: boolean().optional()
14126
+ }).optional(),
14127
+ /** e.g. Pushover `emergency` requires `retry` / `expire`. */
14128
+ requires: array(string()).optional(),
14129
+ description: string().optional()
14130
+ });
14131
+ /** The full capability block consulted before dispatch. */
14132
+ var TargetKindCapsSchema = object({
14133
+ attachments: object({
14134
+ mediaTypes: array(AttachmentMediaTypeSchema),
14135
+ mode: _enum([
14136
+ "url",
14137
+ "bytes",
14138
+ "both"
14139
+ ]),
14140
+ max: number().int().nonnegative(),
14141
+ maxBytes: number().int().positive().optional()
14142
+ }),
14143
+ /** Max action buttons (0 = none). */
14144
+ actions: number().int().nonnegative(),
14145
+ /**
14146
+ * Whether this kind renders a per-action ICON.
14147
+ *
14148
+ * `.optional()`, deliberately NOT `.default(false)`: a Zod default does not
14149
+ * run on the addon cap path — three production failures in one day taught
14150
+ * this repo that once. Absent is read as false by the degrade engine, which
14151
+ * is the safe direction: an icon that is not rendered costs nothing, an icon
14152
+ * assumed and dropped costs the operator's trust in the field.
14153
+ */
14154
+ actionIcons: boolean().optional(),
14155
+ levels: array(TargetKindLevelSchema),
14156
+ format: array(NotificationFormatSchema),
14157
+ clickUrl: boolean(),
14158
+ sound: boolean(),
14159
+ ttl: boolean(),
14160
+ bodyMaxLen: number().int().positive()
14161
+ });
14162
+ /**
14163
+ * `configSchema` is a `ConfigUISchema` tree passed through to the admin
14164
+ * FormBuilder. Stored as `z.unknown()` at the cap seam (mirrors
14165
+ * `device-provider.getChildCreationSchema` `CreationSchemaOutputSchema`) —
14166
+ * the union is large and not meant for runtime validation here; the exported
14167
+ * `TargetKind` type re-tightens `configSchema` to `ConfigUISchema`.
14168
+ */
14169
+ var ConfigSchemaPassthrough$4 = unknown();
14170
+ var TargetKindSchema = object({
14171
+ kind: string(),
14172
+ label: string(),
14173
+ icon: string(),
14174
+ /** Stamped by each provider so the concat-fanned catalog stays routable. */
14175
+ addonId: string(),
14176
+ /**
14177
+ * URL of the kind's bundled BRAND icon, served by the providing addon over
14178
+ * its own `addon-routes` surface (`/addon/<addonId>/icons/<kind>`). Absent
14179
+ * when the addon bundles no icon for that kind — the client then falls back
14180
+ * to a neutral glyph rather than rendering the raw `icon` NAME as text.
14181
+ *
14182
+ * Root-relative on purpose: it resolves against whatever origin serves a web
14183
+ * client, and a native client joins it onto its own hub base.
14184
+ *
14185
+ * DECLARED here deliberately. It used to travel as an undeclared passthrough
14186
+ * field that survived only because the runtime cap-router forwards provider
14187
+ * output verbatim — so every consumer had to re-declare it by hand to stop
14188
+ * its own Zod parse from stripping it, and the whole arrangement would have
14189
+ * broken silently the moment output validation was tightened anywhere.
14190
+ */
14191
+ iconUrl: string().optional(),
14192
+ /**
14193
+ * Media type of {@link iconUrl} (`image/svg+xml`, `image/png`, …).
14194
+ *
14195
+ * The server knows this and therefore says it, because the client cannot
14196
+ * safely guess: a React-Native client renders SVG and raster through two
14197
+ * DIFFERENT components (`react-native-svg` vs `expo-image` — expo-image does
14198
+ * not decode SVG on iOS/Android), so without this it silently fell back to a
14199
+ * placeholder glyph for every vector icon while the web build looked fine.
14200
+ *
14201
+ * Absent when {@link iconUrl} is absent, or for a legacy provider that has
14202
+ * not been updated — a client that cannot determine the type should prefer
14203
+ * its raster path, which is the safe default for an unknown image.
14204
+ */
14205
+ iconMediaType: string().optional(),
14206
+ configSchema: ConfigSchemaPassthrough$4,
14207
+ /**
14208
+ * The config keys that decide WHERE this kind's secrets are sent (server,
14209
+ * base URL, instance, chat, recipient). A save that changes any of them
14210
+ * while leaving a secret redacted is refused by the provider (D634), so an
14211
+ * editor uses this to ask for the secret on exactly those edits instead of
14212
+ * on every edit.
14213
+ *
14214
+ * Optional: absent from a provider that holds no secret (the Home Assistant
14215
+ * kinds) and from a provider older than this field — an editor that finds
14216
+ * it absent must assume ANY edit may need the secret.
14217
+ */
14218
+ destinationKeys: array(string()).optional(),
14219
+ supportsDiscovery: boolean(),
14220
+ /**
14221
+ * Extra delivery parameters a rule may set for a target of this kind (D938).
14222
+ * Absent = none; the rule editor then offers nothing.
14223
+ */
14224
+ deliveryParams: array(DeliveryParamSchema).optional(),
14225
+ caps: TargetKindCapsSchema
14226
+ });
14227
+ /**
14228
+ * A persisted target. `config` holds secrets; providers REDACT secret fields
14229
+ * (return a presence marker only) when serving `listTargets` — never
14230
+ * round-trip a stored secret to the UI.
14231
+ */
14232
+ var TargetSchema = object({
14233
+ id: string(),
14234
+ name: string(),
14235
+ kind: string(),
14236
+ addonId: string(),
14237
+ enabled: boolean(),
14238
+ config: record(string(), unknown())
14239
+ });
14240
+ /** A discovery-surfaced candidate (config is partial + non-secret). */
14241
+ var DiscoveredTargetSchema = object({
14242
+ kind: string(),
14243
+ suggestedName: string(),
14244
+ config: record(string(), unknown())
14245
+ });
14246
+ /** The degrade engine's report — what was resolved / dropped / degraded. */
14247
+ var RenderedAsSchema = object({
14248
+ level: string(),
14249
+ format: NotificationFormatSchema,
14250
+ attachmentsSent: number().int().nonnegative(),
14251
+ actionsSent: number().int().nonnegative(),
14252
+ truncated: boolean(),
14253
+ dropped: array(string())
14254
+ });
14255
+ var SendResultSchema = object({
14256
+ success: boolean(),
14257
+ error: string().optional(),
14258
+ renderedAs: RenderedAsSchema.optional()
14259
+ });
14260
+ /** Same shape as SendResult — kept as a distinct name for the test panel. */
14261
+ var TestResultSchema = SendResultSchema;
14262
+ /**
14263
+ * Pre-save credential probe against a partial (unsaved) target config.
14264
+ * `resolvedUrl` never includes secrets (token stripped from path).
14265
+ */
14266
+ var ProbeTargetConfigResultSchema = object({
14267
+ ok: boolean(),
14268
+ resolvedUrl: string(),
14269
+ httpStatus: number().int().optional(),
14270
+ stateInstance: string().optional(),
14271
+ error: string().optional()
14272
+ });
14273
+ method(object({}), array(TargetKindSchema)), method(object({}), array(TargetSchema), { auth: "admin" }), method(object({ targetId: string() }), TargetSchema, { auth: "admin" }), method(object({
14274
+ kind: string(),
14275
+ config: record(string(), unknown()).optional(),
14276
+ /**
14277
+ * When editing / duplicating, the blank password field never round-trips
14278
+ * the stored token. Pass the source target id so the provider can restore
14279
+ * secrets server-side before dialling (same merge as upsert).
14280
+ */
14281
+ targetId: string().optional()
14282
+ }), array(DiscoveredTargetSchema), { auth: "admin" }), method(object({
14283
+ kind: string(),
14284
+ config: record(string(), unknown()),
14285
+ /** See `discoverTargets.targetId` — restore stored secrets for a blank password. */
14286
+ targetId: string().optional()
14287
+ }), ProbeTargetConfigResultSchema, {
14288
+ kind: "mutation",
14289
+ auth: "admin"
14290
+ }), method(object({
14291
+ targetId: string(),
14292
+ notification: NotificationSchema
14293
+ }), SendResultSchema, {
14294
+ kind: "mutation",
14295
+ auth: "admin"
14296
+ }), method(object({
14297
+ targetId: string(),
14298
+ sample: NotificationSchema.optional()
14299
+ }), TestResultSchema, {
14300
+ kind: "mutation",
14301
+ auth: "admin"
14302
+ }), method(object({
14303
+ target: TargetSchema,
14304
+ /**
14305
+ * Duplicate flow: create a NEW target id while copying secrets from an
14306
+ * existing row. The UI never holds the stored token; blank / redacted
14307
+ * password fields are restored from this source (D634 still applies if
14308
+ * destinations diverge without a re-typed secret).
14309
+ */
14310
+ cloneSecretsFrom: string().optional()
14311
+ }), TargetSchema, {
14312
+ kind: "mutation",
14313
+ auth: "admin"
14314
+ }), method(object({ targetId: string() }), _void(), {
14315
+ kind: "mutation",
14316
+ auth: "admin"
14317
+ }), method(object({
14318
+ targetId: string(),
14319
+ enabled: boolean()
14320
+ }), _void(), {
14321
+ kind: "mutation",
14322
+ auth: "admin"
14323
+ });
14324
+ looseObject({
14325
+ name: string().min(1),
14326
+ enabled: boolean().optional()
14327
+ });
14328
+ TargetSchema.omit({ id: true });
13905
14329
  var EncodeProfileSchema = object({
13906
14330
  video: object({
13907
14331
  codec: _enum([
@@ -22262,7 +22686,6 @@ var SYSTEM_CAP_VOCABULARY = {
22262
22686
  "calendar-source": system(INTERNAL),
22263
22687
  calendars: system("calendars feed schedules and conditions, not device actions"),
22264
22688
  composer: system("device composition — an authoring tool, not an action"),
22265
- "connection-test": system(INTERNAL),
22266
22689
  "core-blocks": system(INTERNAL),
22267
22690
  "custom-model-registry": system(ML),
22268
22691
  "data-store-provider": system(INTERNAL),
@@ -44108,636 +44531,215 @@ var AutomationStepTraceSchema = object({
44108
44531
  startedAt: number().optional(),
44109
44532
  endedAt: number().optional(),
44110
44533
  /**
44111
- * The parameters the step SENT, after `{{vars.x}}` substitution — what the
44112
- * device was actually asked. Bounded like trigger `vars`; a secret parameter
44113
- * is shown as {@link REDACTED_ARG}. Absent on traces written before it existed.
44114
- */
44115
- args: record(string(), TraceValueSchema).optional(),
44116
- /** `empty`: the target resolved to no device, so nothing was done — never silently `ok`. */
44117
- outcome: _enum([
44118
- "ok",
44119
- "error",
44120
- "not-run",
44121
- "empty"
44122
- ]),
44123
- message: string().optional()
44124
- });
44125
- var AutomationRunTraceSchema = object({
44126
- runId: string().min(1),
44127
- startedAt: number(),
44128
- endedAt: number(),
44129
- trigger: AutomationTriggerTraceSchema,
44130
- conditions: array(AutomationConditionTraceNodeSchema),
44131
- verdict: AutomationRunVerdictSchema.optional(),
44132
- steps: array(AutomationStepTraceSchema),
44133
- outcome: AutomationRunOutcomeSchema,
44134
- /** How many identical consecutive skips this trace stands for (>= 1). */
44135
- repeat: number().int().min(1),
44136
- /** When the latest of those repeats happened. */
44137
- lastAt: number(),
44138
- /**
44139
- * A scheduler point's own outcome (D983). `outcome` carries the closest
44140
- * automation outcome so a reader that does not know schedulers still reads
44141
- * the trace; this field says exactly what happened.
44142
- */
44143
- scheduler: SchedulerOutcomeSchema.optional()
44144
- });
44145
- /**
44146
- * What the hub's `runs` ledger holds for one owner (`automation:<blockId>` or
44147
- * `action:<actionId>`): the cooldown stamp and the trace ring.
44148
- */
44149
- var AutomationStateDocSchema = object({
44150
- version: literal(1),
44151
- lastRunStartedAt: number().nullable(),
44152
- traces: array(AutomationRunTraceSchema)
44153
- });
44154
- /**
44155
- * Actions — named, runnable things an operator (or an automation) can start,
44156
- * declared as LIST ENTRIES, never as devices.
44157
- *
44158
- * An entry is either **internal** (a short list of cap/wait steps kept in the
44159
- * hub's `actions` record kind) or declared by an addon through the
44160
- * `action-source` collection (a Home Assistant script, a scene …). The one
44161
- * surface the UI and automations talk to is the `actions` cap; it keeps no
44162
- * catalog of its own (D3) — every `list` asks the providers live.
44163
- *
44164
- * This file is the data half: the entry schema, the variables an entry may
44165
- * declare, and the pure resolution of the values a run was given. It holds no
44166
- * runtime.
44167
- */
44168
- /** What a variable's value is. `select` takes one of `options`. */
44169
- var ActionVariableTypeSchema = _enum([
44170
- "string",
44171
- "number",
44172
- "boolean",
44173
- "select"
44174
- ]);
44175
- var ACTION_VARIABLE_NAME_RE = /^[A-Za-z_][A-Za-z0-9_]*$/;
44176
- var ActionVariableValueSchema = union([
44177
- string(),
44178
- number(),
44179
- boolean()
44180
- ]);
44181
- /**
44182
- * One declared variable. Steps reference it as `{ $var: 'name' }` (the whole
44183
- * value) or `{{vars.name}}` (inside a string) in their args.
44184
- */
44185
- var ActionVariableSchema = object({
44186
- name: string().regex(ACTION_VARIABLE_NAME_RE),
44187
- label: string().min(1).max(120).optional(),
44188
- type: ActionVariableTypeSchema,
44189
- required: boolean().optional(),
44190
- default: ActionVariableValueSchema.optional(),
44191
- /** The allowed values of a `select`. */
44192
- options: array(string().min(1)).min(1).optional()
44193
- }).superRefine((v, ctx) => {
44194
- if (v.type === "select" && v.options === void 0) ctx.addIssue({
44195
- code: "custom",
44196
- message: "a select variable needs options",
44197
- path: ["options"]
44198
- });
44199
- if (v.default !== void 0 && variableValueError(v, v.default) !== null) ctx.addIssue({
44200
- code: "custom",
44201
- message: variableValueError(v, v.default) ?? "invalid default",
44202
- path: ["default"]
44203
- });
44204
- });
44205
- /** Why `value` is not a legal value for the variable, or null when it is. */
44206
- function variableValueError(variable, value) {
44207
- switch (variable.type) {
44208
- case "string": return typeof value === "string" ? null : `variable "${variable.name}" must be a string`;
44209
- case "number": return typeof value === "number" && Number.isFinite(value) ? null : `variable "${variable.name}" must be a number`;
44210
- case "boolean": return typeof value === "boolean" ? null : `variable "${variable.name}" must be true or false`;
44211
- case "select": return typeof value === "string" && (variable.options ?? []).includes(value) ? null : `variable "${variable.name}" must be one of ${(variable.options ?? []).join(", ")}`;
44212
- }
44213
- }
44214
- var ActionSourceKindSchema = _enum(["internal", "addon"]);
44215
- function isInternalActionId(actionId) {
44216
- return actionId.startsWith("internal:") && actionId.length > 9;
44217
- }
44218
- /** The addon behind a `<addonId>:<localId>` id, or null for anything else (internal included). */
44219
- function addonIdOfActionId(actionId) {
44220
- if (isInternalActionId(actionId)) return null;
44221
- const at = actionId.indexOf(":");
44222
- return at > 0 && at < actionId.length - 1 ? actionId.slice(0, at) : null;
44223
- }
44224
- var ActionStatusSchema = object({
44225
- isRunning: boolean(),
44226
- /** Ms epoch the latest run STARTED; null when it never ran. */
44227
- lastRunAt: number().nullable(),
44228
- /** The latest run's failure; null on success or when it never ran. */
44229
- lastError: string().nullable()
44230
- });
44231
- var ActionEntrySchema = object({
44232
- /** `internal:<uuid>` or `<addonId>:<localId>`. */
44233
- id: string().min(3),
44234
- name: string().min(1).max(120),
44235
- /** The addon that declared it; `core-blocks` for an internal one. */
44236
- addonId: string().min(1),
44237
- source: ActionSourceKindSchema,
44238
- /** An addon-declared entry is edited where it was declared. */
44239
- readOnly: boolean(),
44240
- /** Internal only: cap and wait steps. No action-in-action, so no cycles. */
44241
- steps: array(ActionStepSchema).min(1).max(50).optional(),
44242
- variables: array(ActionVariableSchema).max(20).optional(),
44243
- status: ActionStatusSchema
44244
- }).superRefine((entry, ctx) => {
44245
- if (entry.source === "internal") {
44246
- if (!isInternalActionId(entry.id)) ctx.addIssue({
44247
- code: "custom",
44248
- message: "an internal action id is internal:<uuid>",
44249
- path: ["id"]
44250
- });
44251
- return;
44252
- }
44253
- if (entry.steps !== void 0) ctx.addIssue({
44254
- code: "custom",
44255
- message: "only an internal action carries steps",
44256
- path: ["steps"]
44257
- });
44258
- if (!entry.readOnly) ctx.addIssue({
44259
- code: "custom",
44260
- message: "an addon action is read-only here",
44261
- path: ["readOnly"]
44262
- });
44263
- if (addonIdOfActionId(entry.id) === null) ctx.addIssue({
44264
- code: "custom",
44265
- message: "an addon action id is <addonId>:<localId>",
44266
- path: ["id"]
44267
- });
44268
- });
44269
- /** What an operator writes for an internal action. */
44270
- var ActionInputSchema = object({
44271
- name: string().min(1).max(120),
44272
- steps: array(ActionStepSchema).min(1).max(50),
44273
- variables: array(ActionVariableSchema).max(20).optional()
44274
- });
44275
- /** Who started a run. Absent = the operator pressed it. */
44276
- var ActionRunOriginSchema = object({
44277
- /** The automation block whose step started it. */
44278
- blockId: string().min(1).optional() });
44279
- /**
44280
- * `started` = the caller did not ask to wait. `timed-out` = the run reached the
44281
- * ceiling (`ACTION_RUN_MAX_MS`) and was stopped; it is never a `ran`.
44282
- */
44283
- var ActionRunOutcomeSchema = union([
44284
- AutomationRunOutcomeSchema,
44285
- literal("started"),
44286
- literal("timed-out")
44287
- ]);
44288
- var ActionRunResultSchema = object({
44289
- runId: string().min(1),
44290
- outcome: ActionRunOutcomeSchema,
44291
- /** Why it did not run, or what failed. */
44292
- message: string().optional()
44293
- });
44294
- _enum([
44295
- "not-found",
44296
- "read-only",
44297
- "invalid-variables",
44298
- "invalid-steps",
44299
- "not-linked",
44300
- "busy"
44301
- ]);
44302
- object({
44303
- actionId: string(),
44304
- runId: string(),
44305
- isRunning: boolean(),
44306
- /** Set when the run ended. */
44307
- outcome: AutomationRunOutcomeSchema.optional(),
44308
- lastRunAt: number().nullable(),
44309
- lastError: string().nullable()
44310
- });
44311
- /** A bare number accepted as a base unit — the save succeeded, say so. */
44312
- var UnitWarningSchema = object({
44313
- /** Where in the saved record, e.g. `conditions.children.0` or `steps.2.args.grams`. */
44314
- path: string(),
44315
- deviceId: number().int().optional(),
44316
- field: string(),
44317
- value: number(),
44318
- assumedUnit: string(),
44319
- message: string()
44320
- });
44321
- /**
44322
- * notification-output — canonical, capability-gated notification delivery.
44323
- *
44324
- * Apprise-derived model (see
44325
- * `docs/superpowers/specs/2026-07-03-notification-output-notifier-matrix.md`):
44326
- * callers emit ONE canonical `Notification`; each provider declares a
44327
- * per-kind capability descriptor (`TargetKind`), and the pure degrade
44328
- * engine (`@camstack/types` `prepareNotification`) transcodes / degrades the
44329
- * message to what the kind supports — callers never special-case a service.
44330
- *
44331
- * DESIGN DECISIONS (locked):
44332
- * - Target CRUD lives on THIS cap (`upsertTarget` / `deleteTarget` /
44333
- * `setTargetEnabled`), each provider persisting via the `settings-store`
44334
- * cap. Rationale: the admin UI needs one uniform surface across the
44335
- * notifiers addon AND the HA addon; the addon-`globalSettingsSchema`-array
44336
- * alternative would fork the UI per addon and cannot host the
44337
- * discovery→adopt flow.
44338
- * - `listTargetKinds` / `listTargets` / `discoverTargets` return arrays →
44339
- * the generated cap-mount auto-`concatCollection`-fans them across every
44340
- * registered provider (notifiers addon + HA addon) so one catalog is
44341
- * routable. `send` / `testTarget` / CRUD route to ONE provider by the
44342
- * `addonId` the generated collection router extracts from the call input.
44343
- * - `Attachment.bytes` is `Uint8Array`. Transport-safe: superjson (the tRPC
44344
- * transformer) + UDS MsgPack both round-trip typed arrays — already used by
44345
- * `storage` / `storage-provider` / `recording` caps over the same path. No
44346
- * base64 fallback needed.
44347
- *
44348
- * TODO (deferred, closed-set change — separate decision): add
44349
- * `providerKind: 'notify'` so notification providers surface on the unified
44350
- * admin "Integrations" page.
44351
- */
44352
- /**
44353
- * Zentik-derived typed-media enum — the superset across every kind. Each
44354
- * adapter picks what it supports and the degrade engine filters the rest.
44355
- */
44356
- var AttachmentMediaTypeSchema = _enum([
44357
- "image",
44358
- "video",
44359
- "gif",
44360
- "audio",
44361
- "icon"
44362
- ]);
44363
- /**
44364
- * A single attachment. Exactly one of `url` (remote source, most adapters
44365
- * prefer this) or `bytes` (inline source; required for Pushover-style
44366
- * bytes-only kinds) MUST be present — the degrade engine expresses a
44367
- * url→bytes fetch as a `needsFetch` directive the adapter executes.
44368
- */
44369
- var AttachmentSchema = object({
44370
- mediaType: AttachmentMediaTypeSchema,
44371
- url: string().optional(),
44372
- bytes: _instanceof(Uint8Array).optional(),
44373
- mime: string().optional(),
44374
- name: string().optional()
44375
- }).refine((a) => a.url !== void 0 || a.bytes !== void 0, { message: "Attachment requires either `url` or `bytes`" });
44376
- var NotificationFormatSchema = _enum([
44377
- "text",
44378
- "markdown",
44379
- "html"
44380
- ]);
44381
- /**
44382
- * The CLOSED icon vocabulary an action button may use.
44383
- *
44384
- * A closed set, not a free string, and that is the whole point: an arbitrary
44385
- * icon name is one that ntfy renders, zentik silently drops, and nobody
44386
- * notices — the same class of gap as a zone vocabulary nothing produced
44387
- * ([D35](../../../docs/decisions/adr-0035.md)). Every adapter maps this set or
44388
- * declares `actionIcons: false` and the degrade engine strips the field.
44389
- *
44390
- * Named by INTENT, never by glyph. "check" would tie the vocabulary to one
44391
- * renderer's icon set; "acknowledge" survives an adapter that draws it
44392
- * differently.
44393
- *
44394
- * ── A TOKEN IS NOT A WIRE VALUE ─────────────────────────────────────
44395
- *
44396
- * These names are for US. **No adapter may forward one verbatim.** Each maps
44397
- * the whole set onto its own renderer's vocabulary through a
44398
- * `Record<NotificationActionIcon, string>` — a Record, never a lookup with a
44399
- * fallback, so adding a member here fails every adapter's build until someone
44400
- * decides its glyph, which is the only place that decision can be made
44401
- * honestly.
44402
- *
44403
- * This paragraph is the bug. Zentik declared `actionIcons: true` and passed
44404
- * `disarm` straight through; iOS feeds that string to
44405
- * `UNNotificationActionIcon(systemImageName:)`, `disarm` is not an SF Symbol,
44406
- * and every snooze and alarm button arrived BLANK. A pass-through is not a
44407
- * mapping, and "the field is documented" is not "the value renders".
44408
- *
44409
- * Adding a member is TRAIN-BOUND. The enum lives in the published
44410
- * `@camstack/server` closure and the cap seam validates against the HUB's copy,
44411
- * so an addon that emits a token the running hub does not know does not lose an
44412
- * icon — its whole `send` fails Zod validation and the notification never
44413
- * arrives. Never emit a new token from an addon before the train carrying it.
44414
- */
44415
- var NotificationActionIconSchema = _enum([
44416
- "acknowledge",
44417
- "dismiss",
44418
- "silence",
44419
- "snooze",
44420
- "view",
44421
- "play",
44422
- "open",
44423
- "close",
44424
- "lock",
44425
- "unlock",
44426
- "arm",
44427
- "arm-home",
44428
- "arm-away",
44429
- "arm-night",
44430
- "disarm",
44431
- "light",
44432
- "alert",
44433
- "camera"
44434
- ]);
44435
- /** A single tap-through action button. */
44436
- var NotificationActionSchema = object({
44437
- id: string(),
44438
- label: string(),
44439
- url: string().optional(),
44440
- /** Dropped by the degrade engine for a kind with `caps.actionIcons: false`. */
44441
- icon: NotificationActionIconSchema.optional(),
44442
- /**
44443
- * Renders in a warning style where the notifier supports it.
44444
- *
44445
- * A HINT, never a gate. The callback's authority is its token and nothing
44446
- * else — see `notification-center/action-token.ts` for what that does and
44447
- * does not buy.
44448
- */
44449
- destructive: boolean().optional(),
44450
- /**
44451
- * How the tap should REACH the url.
44452
- *
44453
- * `navigate` (absent, and every button authored before this field) opens it:
44454
- * the phone leaves the notification and shows whatever the callback returns.
44455
- * That is right for a button whose answer the operator wants to read.
44456
- *
44457
- * `background` fires it as a POST and stays put. It exists for the buttons
44458
- * whose whole point is not to interrupt — "silence this for 30 minutes" is
44459
- * an answer to the notification, and being thrown into a browser tab to
44460
- * confirm it costs more attention than the notification did. A backend that
44461
- * cannot do a background call renders it as an ordinary link (the adapters
44462
- * fall back rather than dropping the button), so this is a preference, never
44463
- * a requirement.
44464
- */
44465
- mode: _enum(["navigate", "background"]).optional()
44466
- });
44467
- /** A delivery parameter value: what a notifier declared it takes. */
44468
- var DeliveryParamValueSchema = union([
44469
- string(),
44470
- number(),
44471
- boolean()
44472
- ]);
44473
- /**
44474
- * One extra delivery parameter a notifier KIND declares (D938). A rule that
44475
- * addresses a target of that kind may set it; a kind that declares nothing is
44476
- * never handed one. The admin UI derives its control from this descriptor —
44477
- * no editor knows a service by name.
44478
- *
44479
- * Optional fields are `.optional()`, never `.default()` (a Zod default does not
44480
- * run on the addon cap path).
44481
- */
44482
- var DeliveryParamSchema = object({
44483
- key: string().min(1),
44484
- label: string(),
44485
- /** i18n key of the label, resolved by the declaring addon's namespace. */
44486
- labelKey: string().optional(),
44487
- type: _enum([
44488
- "enum",
44489
- "number",
44490
- "boolean",
44491
- "string"
44492
- ]),
44493
- /** `enum` only: the closed set of accepted values. */
44494
- options: array(object({
44495
- value: string(),
44496
- label: string()
44497
- })).optional(),
44498
- /** `number` only. */
44499
- min: number().optional(),
44500
- max: number().optional(),
44501
- /** What the notifier does when the rule sets nothing; shown as the placeholder. */
44502
- default: DeliveryParamValueSchema.optional()
44503
- });
44504
- /**
44505
- * The canonical notification. `body` is the only hard field (Apprise model).
44506
- * `priority` is a 5-level ORDINAL (1=lowest … 3=normal(default) … 5=urgent),
44507
- * NOT a fixed severity enum — each kind declares its own `caps.levels` and
44508
- * the adapter maps this ordinal onto its native level. `level?` is an
44509
- * optional kind-native level id (`emergency`, `silent`, …) that overrides
44510
- * `priority` for that one target.
44511
- */
44512
- var NotificationSchema = object({
44513
- body: string(),
44514
- title: string().optional(),
44515
- format: NotificationFormatSchema.default("text"),
44516
- priority: number().int().min(1).max(5).default(3),
44517
- level: string().optional(),
44518
- attachments: array(AttachmentSchema).optional(),
44519
- clickUrl: string().optional(),
44520
- actions: array(NotificationActionSchema).optional(),
44521
- sound: string().optional(),
44522
- ttl: number().optional(),
44523
- tag: string().optional(),
44524
- deviceId: number().optional(),
44525
- eventId: string().optional(),
44526
- metadata: record(string(), unknown()).optional(),
44527
- /**
44528
- * Values for the parameters the target's kind DECLARES in
44529
- * {@link TargetKindSchema} `deliveryParams`. Already validated against the
44530
- * declaration by the sender; a notifier reads only the keys it declared.
44531
- */
44532
- delivery: record(string(), DeliveryParamValueSchema).optional()
44533
- });
44534
- /** One declared native severity/priority level for a kind. */
44535
- var TargetKindLevelSchema = object({
44536
- id: string(),
44537
- label: string(),
44538
- /** Which canonical priority (1..5) this level maps to. `null` = qualitative-only. */
44539
- ordinal: number().int().min(1).max(5).nullable(),
44540
- flags: object({
44541
- critical: boolean().optional(),
44542
- silent: boolean().optional(),
44543
- noPush: boolean().optional()
44544
- }).optional(),
44545
- /** e.g. Pushover `emergency` requires `retry` / `expire`. */
44546
- requires: array(string()).optional(),
44547
- description: string().optional()
44534
+ * The parameters the step SENT, after `{{vars.x}}` substitution — what the
44535
+ * device was actually asked. Bounded like trigger `vars`; a secret parameter
44536
+ * is shown as {@link REDACTED_ARG}. Absent on traces written before it existed.
44537
+ */
44538
+ args: record(string(), TraceValueSchema).optional(),
44539
+ /** `empty`: the target resolved to no device, so nothing was done — never silently `ok`. */
44540
+ outcome: _enum([
44541
+ "ok",
44542
+ "error",
44543
+ "not-run",
44544
+ "empty"
44545
+ ]),
44546
+ message: string().optional()
44548
44547
  });
44549
- /** The full capability block consulted before dispatch. */
44550
- var TargetKindCapsSchema = object({
44551
- attachments: object({
44552
- mediaTypes: array(AttachmentMediaTypeSchema),
44553
- mode: _enum([
44554
- "url",
44555
- "bytes",
44556
- "both"
44557
- ]),
44558
- max: number().int().nonnegative(),
44559
- maxBytes: number().int().positive().optional()
44560
- }),
44561
- /** Max action buttons (0 = none). */
44562
- actions: number().int().nonnegative(),
44548
+ var AutomationRunTraceSchema = object({
44549
+ runId: string().min(1),
44550
+ startedAt: number(),
44551
+ endedAt: number(),
44552
+ trigger: AutomationTriggerTraceSchema,
44553
+ conditions: array(AutomationConditionTraceNodeSchema),
44554
+ verdict: AutomationRunVerdictSchema.optional(),
44555
+ steps: array(AutomationStepTraceSchema),
44556
+ outcome: AutomationRunOutcomeSchema,
44557
+ /** How many identical consecutive skips this trace stands for (>= 1). */
44558
+ repeat: number().int().min(1),
44559
+ /** When the latest of those repeats happened. */
44560
+ lastAt: number(),
44563
44561
  /**
44564
- * Whether this kind renders a per-action ICON.
44565
- *
44566
- * `.optional()`, deliberately NOT `.default(false)`: a Zod default does not
44567
- * run on the addon cap path — three production failures in one day taught
44568
- * this repo that once. Absent is read as false by the degrade engine, which
44569
- * is the safe direction: an icon that is not rendered costs nothing, an icon
44570
- * assumed and dropped costs the operator's trust in the field.
44562
+ * A scheduler point's own outcome (D983). `outcome` carries the closest
44563
+ * automation outcome so a reader that does not know schedulers still reads
44564
+ * the trace; this field says exactly what happened.
44571
44565
  */
44572
- actionIcons: boolean().optional(),
44573
- levels: array(TargetKindLevelSchema),
44574
- format: array(NotificationFormatSchema),
44575
- clickUrl: boolean(),
44576
- sound: boolean(),
44577
- ttl: boolean(),
44578
- bodyMaxLen: number().int().positive()
44566
+ scheduler: SchedulerOutcomeSchema.optional()
44579
44567
  });
44580
44568
  /**
44581
- * `configSchema` is a `ConfigUISchema` tree passed through to the admin
44582
- * FormBuilder. Stored as `z.unknown()` at the cap seam (mirrors
44583
- * `device-provider.getChildCreationSchema` `CreationSchemaOutputSchema`) —
44584
- * the union is large and not meant for runtime validation here; the exported
44585
- * `TargetKind` type re-tightens `configSchema` to `ConfigUISchema`.
44569
+ * What the hub's `runs` ledger holds for one owner (`automation:<blockId>` or
44570
+ * `action:<actionId>`): the cooldown stamp and the trace ring.
44586
44571
  */
44587
- var ConfigSchemaPassthrough$4 = unknown();
44588
- var TargetKindSchema = object({
44589
- kind: string(),
44590
- label: string(),
44591
- icon: string(),
44592
- /** Stamped by each provider so the concat-fanned catalog stays routable. */
44593
- addonId: string(),
44594
- /**
44595
- * URL of the kind's bundled BRAND icon, served by the providing addon over
44596
- * its own `addon-routes` surface (`/addon/<addonId>/icons/<kind>`). Absent
44597
- * when the addon bundles no icon for that kind — the client then falls back
44598
- * to a neutral glyph rather than rendering the raw `icon` NAME as text.
44599
- *
44600
- * Root-relative on purpose: it resolves against whatever origin serves a web
44601
- * client, and a native client joins it onto its own hub base.
44602
- *
44603
- * DECLARED here deliberately. It used to travel as an undeclared passthrough
44604
- * field that survived only because the runtime cap-router forwards provider
44605
- * output verbatim — so every consumer had to re-declare it by hand to stop
44606
- * its own Zod parse from stripping it, and the whole arrangement would have
44607
- * broken silently the moment output validation was tightened anywhere.
44608
- */
44609
- iconUrl: string().optional(),
44610
- /**
44611
- * Media type of {@link iconUrl} (`image/svg+xml`, `image/png`, …).
44612
- *
44613
- * The server knows this and therefore says it, because the client cannot
44614
- * safely guess: a React-Native client renders SVG and raster through two
44615
- * DIFFERENT components (`react-native-svg` vs `expo-image` — expo-image does
44616
- * not decode SVG on iOS/Android), so without this it silently fell back to a
44617
- * placeholder glyph for every vector icon while the web build looked fine.
44618
- *
44619
- * Absent when {@link iconUrl} is absent, or for a legacy provider that has
44620
- * not been updated — a client that cannot determine the type should prefer
44621
- * its raster path, which is the safe default for an unknown image.
44622
- */
44623
- iconMediaType: string().optional(),
44624
- configSchema: ConfigSchemaPassthrough$4,
44625
- /**
44626
- * The config keys that decide WHERE this kind's secrets are sent (server,
44627
- * base URL, instance, chat, recipient). A save that changes any of them
44628
- * while leaving a secret redacted is refused by the provider (D634), so an
44629
- * editor uses this to ask for the secret on exactly those edits instead of
44630
- * on every edit.
44631
- *
44632
- * Optional: absent from a provider that holds no secret (the Home Assistant
44633
- * kinds) and from a provider older than this field — an editor that finds
44634
- * it absent must assume ANY edit may need the secret.
44635
- */
44636
- destinationKeys: array(string()).optional(),
44637
- supportsDiscovery: boolean(),
44638
- /**
44639
- * Extra delivery parameters a rule may set for a target of this kind (D938).
44640
- * Absent = none; the rule editor then offers nothing.
44641
- */
44642
- deliveryParams: array(DeliveryParamSchema).optional(),
44643
- caps: TargetKindCapsSchema
44572
+ var AutomationStateDocSchema = object({
44573
+ version: literal(1),
44574
+ lastRunStartedAt: number().nullable(),
44575
+ traces: array(AutomationRunTraceSchema)
44644
44576
  });
44645
44577
  /**
44646
- * A persisted target. `config` holds secrets; providers REDACT secret fields
44647
- * (return a presence marker only) when serving `listTargets` — never
44648
- * round-trip a stored secret to the UI.
44578
+ * Actions — named, runnable things an operator (or an automation) can start,
44579
+ * declared as LIST ENTRIES, never as devices.
44580
+ *
44581
+ * An entry is either **internal** (a short list of cap/wait steps kept in the
44582
+ * hub's `actions` record kind) or declared by an addon through the
44583
+ * `action-source` collection (a Home Assistant script, a scene …). The one
44584
+ * surface the UI and automations talk to is the `actions` cap; it keeps no
44585
+ * catalog of its own (D3) — every `list` asks the providers live.
44586
+ *
44587
+ * This file is the data half: the entry schema, the variables an entry may
44588
+ * declare, and the pure resolution of the values a run was given. It holds no
44589
+ * runtime.
44649
44590
  */
44650
- var TargetSchema = object({
44651
- id: string(),
44652
- name: string(),
44653
- kind: string(),
44654
- addonId: string(),
44655
- enabled: boolean(),
44656
- config: record(string(), unknown())
44591
+ /** What a variable's value is. `select` takes one of `options`. */
44592
+ var ActionVariableTypeSchema = _enum([
44593
+ "string",
44594
+ "number",
44595
+ "boolean",
44596
+ "select"
44597
+ ]);
44598
+ var ACTION_VARIABLE_NAME_RE = /^[A-Za-z_][A-Za-z0-9_]*$/;
44599
+ var ActionVariableValueSchema = union([
44600
+ string(),
44601
+ number(),
44602
+ boolean()
44603
+ ]);
44604
+ /**
44605
+ * One declared variable. Steps reference it as `{ $var: 'name' }` (the whole
44606
+ * value) or `{{vars.name}}` (inside a string) in their args.
44607
+ */
44608
+ var ActionVariableSchema = object({
44609
+ name: string().regex(ACTION_VARIABLE_NAME_RE),
44610
+ label: string().min(1).max(120).optional(),
44611
+ type: ActionVariableTypeSchema,
44612
+ required: boolean().optional(),
44613
+ default: ActionVariableValueSchema.optional(),
44614
+ /** The allowed values of a `select`. */
44615
+ options: array(string().min(1)).min(1).optional()
44616
+ }).superRefine((v, ctx) => {
44617
+ if (v.type === "select" && v.options === void 0) ctx.addIssue({
44618
+ code: "custom",
44619
+ message: "a select variable needs options",
44620
+ path: ["options"]
44621
+ });
44622
+ if (v.default !== void 0 && variableValueError(v, v.default) !== null) ctx.addIssue({
44623
+ code: "custom",
44624
+ message: variableValueError(v, v.default) ?? "invalid default",
44625
+ path: ["default"]
44626
+ });
44657
44627
  });
44658
- /** A discovery-surfaced candidate (config is partial + non-secret). */
44659
- var DiscoveredTargetSchema = object({
44660
- kind: string(),
44661
- suggestedName: string(),
44662
- config: record(string(), unknown())
44628
+ /** Why `value` is not a legal value for the variable, or null when it is. */
44629
+ function variableValueError(variable, value) {
44630
+ switch (variable.type) {
44631
+ case "string": return typeof value === "string" ? null : `variable "${variable.name}" must be a string`;
44632
+ case "number": return typeof value === "number" && Number.isFinite(value) ? null : `variable "${variable.name}" must be a number`;
44633
+ case "boolean": return typeof value === "boolean" ? null : `variable "${variable.name}" must be true or false`;
44634
+ case "select": return typeof value === "string" && (variable.options ?? []).includes(value) ? null : `variable "${variable.name}" must be one of ${(variable.options ?? []).join(", ")}`;
44635
+ }
44636
+ }
44637
+ var ActionSourceKindSchema = _enum(["internal", "addon"]);
44638
+ function isInternalActionId(actionId) {
44639
+ return actionId.startsWith("internal:") && actionId.length > 9;
44640
+ }
44641
+ /** The addon behind a `<addonId>:<localId>` id, or null for anything else (internal included). */
44642
+ function addonIdOfActionId(actionId) {
44643
+ if (isInternalActionId(actionId)) return null;
44644
+ const at = actionId.indexOf(":");
44645
+ return at > 0 && at < actionId.length - 1 ? actionId.slice(0, at) : null;
44646
+ }
44647
+ var ActionStatusSchema = object({
44648
+ isRunning: boolean(),
44649
+ /** Ms epoch the latest run STARTED; null when it never ran. */
44650
+ lastRunAt: number().nullable(),
44651
+ /** The latest run's failure; null on success or when it never ran. */
44652
+ lastError: string().nullable()
44663
44653
  });
44664
- /** The degrade engine's report — what was resolved / dropped / degraded. */
44665
- var RenderedAsSchema = object({
44666
- level: string(),
44667
- format: NotificationFormatSchema,
44668
- attachmentsSent: number().int().nonnegative(),
44669
- actionsSent: number().int().nonnegative(),
44670
- truncated: boolean(),
44671
- dropped: array(string())
44654
+ var ActionEntrySchema = object({
44655
+ /** `internal:<uuid>` or `<addonId>:<localId>`. */
44656
+ id: string().min(3),
44657
+ name: string().min(1).max(120),
44658
+ /** The addon that declared it; `core-blocks` for an internal one. */
44659
+ addonId: string().min(1),
44660
+ source: ActionSourceKindSchema,
44661
+ /** An addon-declared entry is edited where it was declared. */
44662
+ readOnly: boolean(),
44663
+ /** Internal only: cap and wait steps. No action-in-action, so no cycles. */
44664
+ steps: array(ActionStepSchema).min(1).max(50).optional(),
44665
+ variables: array(ActionVariableSchema).max(20).optional(),
44666
+ status: ActionStatusSchema
44667
+ }).superRefine((entry, ctx) => {
44668
+ if (entry.source === "internal") {
44669
+ if (!isInternalActionId(entry.id)) ctx.addIssue({
44670
+ code: "custom",
44671
+ message: "an internal action id is internal:<uuid>",
44672
+ path: ["id"]
44673
+ });
44674
+ return;
44675
+ }
44676
+ if (entry.steps !== void 0) ctx.addIssue({
44677
+ code: "custom",
44678
+ message: "only an internal action carries steps",
44679
+ path: ["steps"]
44680
+ });
44681
+ if (!entry.readOnly) ctx.addIssue({
44682
+ code: "custom",
44683
+ message: "an addon action is read-only here",
44684
+ path: ["readOnly"]
44685
+ });
44686
+ if (addonIdOfActionId(entry.id) === null) ctx.addIssue({
44687
+ code: "custom",
44688
+ message: "an addon action id is <addonId>:<localId>",
44689
+ path: ["id"]
44690
+ });
44672
44691
  });
44673
- var SendResultSchema = object({
44674
- success: boolean(),
44675
- error: string().optional(),
44676
- renderedAs: RenderedAsSchema.optional()
44692
+ /** What an operator writes for an internal action. */
44693
+ var ActionInputSchema = object({
44694
+ name: string().min(1).max(120),
44695
+ steps: array(ActionStepSchema).min(1).max(50),
44696
+ variables: array(ActionVariableSchema).max(20).optional()
44677
44697
  });
44678
- /** Same shape as SendResult — kept as a distinct name for the test panel. */
44679
- var TestResultSchema = SendResultSchema;
44698
+ /** Who started a run. Absent = the operator pressed it. */
44699
+ var ActionRunOriginSchema = object({
44700
+ /** The automation block whose step started it. */
44701
+ blockId: string().min(1).optional() });
44680
44702
  /**
44681
- * Pre-save credential probe against a partial (unsaved) target config.
44682
- * `resolvedUrl` never includes secrets (token stripped from path).
44703
+ * `started` = the caller did not ask to wait. `timed-out` = the run reached the
44704
+ * ceiling (`ACTION_RUN_MAX_MS`) and was stopped; it is never a `ran`.
44683
44705
  */
44684
- var ProbeTargetConfigResultSchema = object({
44685
- ok: boolean(),
44686
- resolvedUrl: string(),
44687
- httpStatus: number().int().optional(),
44688
- stateInstance: string().optional(),
44689
- error: string().optional()
44706
+ var ActionRunOutcomeSchema = union([
44707
+ AutomationRunOutcomeSchema,
44708
+ literal("started"),
44709
+ literal("timed-out")
44710
+ ]);
44711
+ var ActionRunResultSchema = object({
44712
+ runId: string().min(1),
44713
+ outcome: ActionRunOutcomeSchema,
44714
+ /** Why it did not run, or what failed. */
44715
+ message: string().optional()
44690
44716
  });
44691
- method(object({}), array(TargetKindSchema)), method(object({}), array(TargetSchema), { auth: "admin" }), method(object({ targetId: string() }), TargetSchema, { auth: "admin" }), method(object({
44692
- kind: string(),
44693
- config: record(string(), unknown()).optional(),
44694
- /**
44695
- * When editing / duplicating, the blank password field never round-trips
44696
- * the stored token. Pass the source target id so the provider can restore
44697
- * secrets server-side before dialling (same merge as upsert).
44698
- */
44699
- targetId: string().optional()
44700
- }), array(DiscoveredTargetSchema), { auth: "admin" }), method(object({
44701
- kind: string(),
44702
- config: record(string(), unknown()),
44703
- /** See `discoverTargets.targetId` — restore stored secrets for a blank password. */
44704
- targetId: string().optional()
44705
- }), ProbeTargetConfigResultSchema, {
44706
- kind: "mutation",
44707
- auth: "admin"
44708
- }), method(object({
44709
- targetId: string(),
44710
- notification: NotificationSchema
44711
- }), SendResultSchema, {
44712
- kind: "mutation",
44713
- auth: "admin"
44714
- }), method(object({
44715
- targetId: string(),
44716
- sample: NotificationSchema.optional()
44717
- }), TestResultSchema, {
44718
- kind: "mutation",
44719
- auth: "admin"
44720
- }), method(object({
44721
- target: TargetSchema,
44722
- /**
44723
- * Duplicate flow: create a NEW target id while copying secrets from an
44724
- * existing row. The UI never holds the stored token; blank / redacted
44725
- * password fields are restored from this source (D634 still applies if
44726
- * destinations diverge without a re-typed secret).
44727
- */
44728
- cloneSecretsFrom: string().optional()
44729
- }), TargetSchema, {
44730
- kind: "mutation",
44731
- auth: "admin"
44732
- }), method(object({ targetId: string() }), _void(), {
44733
- kind: "mutation",
44734
- auth: "admin"
44735
- }), method(object({
44736
- targetId: string(),
44737
- enabled: boolean()
44738
- }), _void(), {
44739
- kind: "mutation",
44740
- auth: "admin"
44717
+ _enum([
44718
+ "not-found",
44719
+ "read-only",
44720
+ "invalid-variables",
44721
+ "invalid-steps",
44722
+ "not-linked",
44723
+ "busy"
44724
+ ]);
44725
+ object({
44726
+ actionId: string(),
44727
+ runId: string(),
44728
+ isRunning: boolean(),
44729
+ /** Set when the run ended. */
44730
+ outcome: AutomationRunOutcomeSchema.optional(),
44731
+ lastRunAt: number().nullable(),
44732
+ lastError: string().nullable()
44733
+ });
44734
+ /** A bare number accepted as a base unit — the save succeeded, say so. */
44735
+ var UnitWarningSchema = object({
44736
+ /** Where in the saved record, e.g. `conditions.children.0` or `steps.2.args.grams`. */
44737
+ path: string(),
44738
+ deviceId: number().int().optional(),
44739
+ field: string(),
44740
+ value: number(),
44741
+ assumedUnit: string(),
44742
+ message: string()
44741
44743
  });
44742
44744
  _enum([
44743
44745
  "automation",
@@ -49278,45 +49280,6 @@ method(object({
49278
49280
  kind: "mutation",
49279
49281
  auth: "admin"
49280
49282
  }), method(object({ blockIds: array(string()) }), object({ states: array(CompositionBlockStateSchema) }), { auth: "admin" });
49281
- var ConnectionTestOutcomeSchema = discriminatedUnion("outcome", [
49282
- object({
49283
- outcome: literal("validated"),
49284
- /** Round-trip of the sign-in, when the provider measured it. */
49285
- latencyMs: number().nonnegative().optional(),
49286
- /** Optional human detail worth showing next to the tick
49287
- * ("3 devices visible on this account"). */
49288
- detail: string().optional()
49289
- }).strict(),
49290
- object({
49291
- outcome: literal("rejected"),
49292
- error: string()
49293
- }).strict(),
49294
- object({
49295
- outcome: literal("inconclusive"),
49296
- error: string()
49297
- }).strict()
49298
- ]);
49299
- var ConnectionTestInputSchema = object({
49300
- /** Candidate integration settings, exactly as the create form collected them. */
49301
- settings: record(string(), unknown()) });
49302
- /**
49303
- * What the provider's test actually DOES, so the UI can say it in words before
49304
- * the operator presses the button ("Signs in to the Dreo cloud"). Purely
49305
- * descriptive — it never changes routing.
49306
- */
49307
- var ConnectionTestDescriptorSchema = object({ label: string() });
49308
- var connectionTestCapability = {
49309
- name: "connection-test",
49310
- scope: "system",
49311
- mode: "collection",
49312
- methods: {
49313
- testSettings: method(ConnectionTestInputSchema, ConnectionTestOutcomeSchema, {
49314
- kind: "mutation",
49315
- auth: "admin"
49316
- }),
49317
- describeTest: method(_void(), ConnectionTestDescriptorSchema, { auth: "admin" })
49318
- }
49319
- };
49320
49283
  /**
49321
49284
  * Upstream-system connectivity sensor — distinct from `device-status`,
49322
49285
  * which is the kernel-managed online/offline flag for the device's
@@ -56491,10 +56454,9 @@ var AvailableIntegrationTypeSchema = object({
56491
56454
  * locations" checkbox. Provider-declared in the addon manifest. */
56492
56455
  supportsLocationImport: boolean(),
56493
56456
  /**
56494
- * True when this integration DECLARES a pre-creation test (the
56495
- * `connection-test` cap, or a broker whose settings it stores). Drives the
56496
- * Test button: an integration that cannot be tested must say so up front
56497
- * rather than offering a button that always answers the same nonsense.
56457
+ * True when this integration's instances declare a Test (`integration-instances.describe().canTest`,
56458
+ * D1016). An integration that cannot be tested must say so up front rather than offering a
56459
+ * button that always answers the same nonsense.
56498
56460
  */
56499
56461
  canTest: boolean(),
56500
56462
  existingInstances: array(object({
@@ -56548,7 +56510,9 @@ var CreateIntegrationInputSchema = object({
56548
56510
  info: record(string(), unknown()).optional(),
56549
56511
  /** `stableId` of the discovery candidate the form was seeded from (D984). */
56550
56512
  originStableId: string().optional(),
56551
- settings: record(string(), unknown()).optional()
56513
+ settings: record(string(), unknown()).optional(),
56514
+ /** The instance kind being created, for a provider with several; omitted = its only testable kind. */
56515
+ kind: string().min(1).optional()
56552
56516
  });
56553
56517
  var UpdateIntegrationInputSchema = object({
56554
56518
  id: string(),
@@ -56574,13 +56538,7 @@ method(_void(), array(IntegrationWithStateSchema)), method(object({ id: string()
56574
56538
  }), method(object({ id: string() }), DeleteIntegrationResultSchema, {
56575
56539
  kind: "mutation",
56576
56540
  auth: "admin"
56577
- }), method(_void(), array(AvailableIntegrationTypeSchema), { auth: "admin" }), method(object({
56578
- addonId: string(),
56579
- settings: record(string(), unknown())
56580
- }), TestConnectionResultSchema, {
56581
- kind: "mutation",
56582
- auth: "admin"
56583
- });
56541
+ }), method(_void(), array(AvailableIntegrationTypeSchema), { auth: "admin" });
56584
56542
  /**
56585
56543
  * `integration-instances` - the connection of an addon that holds ONE or SEVERAL
56586
56544
  * (an account, a relay, a destination) as typed records (D985, D986). The addon's
@@ -65323,13 +65281,6 @@ var AddBrokerInputSchema = object({
65323
65281
  });
65324
65282
  var AddBrokerResultSchema = object({ id: string() });
65325
65283
  var IdInputSchema = object({ id: string() });
65326
- var TestResultSchema$1 = discriminatedUnion("ok", [object({
65327
- ok: literal(true),
65328
- latencyMs: number()
65329
- }), object({
65330
- ok: literal(false),
65331
- error: string()
65332
- })]);
65333
65284
  var StartEmbeddedInputSchema = object({
65334
65285
  port: number().int().min(1).max(65535).default(1883),
65335
65286
  /** Allow anonymous connect (no username/password). Default: false. */
@@ -65352,9 +65303,6 @@ method(_void(), array(BrokerInfoSchema)), method(IdInputSchema, BrokerConnection
65352
65303
  }), method(IdInputSchema, _void(), {
65353
65304
  kind: "mutation",
65354
65305
  auth: "admin"
65355
- }), method(IdInputSchema, TestResultSchema$1, {
65356
- kind: "mutation",
65357
- auth: "admin"
65358
65306
  }), method(StartEmbeddedInputSchema, StartEmbeddedResultSchema, {
65359
65307
  kind: "mutation",
65360
65308
  auth: "admin"
@@ -78461,7 +78409,7 @@ var TrainingProviderTypeSchema = object({
78461
78409
  label: string(),
78462
78410
  /** Path under the addon package (e.g. `assets/training-modal/icon.svg`). */
78463
78411
  iconAsset: string(),
78464
- /** Owning `training-provider` addon — collection selector for createEntry. */
78412
+ /** Owning `training-provider` addon. */
78465
78413
  addonId: string(),
78466
78414
  /**
78467
78415
  * Fields for one entry of this type (credentials + defaults). Absent on a
@@ -78506,36 +78454,6 @@ var TrainingProviderDescriptorSchema = object({
78506
78454
  */
78507
78455
  formValues: record(string(), unknown()).optional()
78508
78456
  });
78509
- /**
78510
- * Patch one entry's name, credentials and defaults. Pin with owning `{ addonId }`.
78511
- * An omitted or empty `tokenSecret` means KEEP the stored secret (D787).
78512
- * `{ $secretClear: true }` clears it.
78513
- */
78514
- var TrainingProviderUpdateEntryInputSchema = object({
78515
- entryId: string().min(1),
78516
- name: string().min(1),
78517
- tokenId: string().optional(),
78518
- tokenSecret: union([string(), object({ $secretClear: literal(true) })]).optional(),
78519
- environment: string().optional(),
78520
- gpuType: string().optional(),
78521
- region: string().optional(),
78522
- costCapUsd: number().nonnegative().optional(),
78523
- maxRuntimeSec: number().int().positive().optional(),
78524
- failedDatasetGraceHours: number().nonnegative().optional()
78525
- });
78526
- var TrainingCredentialCheckSchema = object({
78527
- ok: boolean(),
78528
- /** Workspace / account name, when the provider says. */
78529
- account: string().optional(),
78530
- reason: _enum([
78531
- "missing",
78532
- "invalid",
78533
- "forbidden",
78534
- "network",
78535
- "quota"
78536
- ]).optional(),
78537
- detail: string().optional()
78538
- });
78539
78457
  var ProviderJobStateSchema = _enum([
78540
78458
  "pending",
78541
78459
  "starting",
@@ -78583,22 +78501,6 @@ var TrainingLogLineSchema = object({
78583
78501
  text: string()
78584
78502
  });
78585
78503
  method(object({}), array(TrainingProviderDescriptorSchema).readonly(), { auth: "admin" }), method(object({}), array(TrainingProviderTypeSchema).readonly(), { auth: "admin" }), method(object({}), array(TrainingProviderEntrySchema).readonly(), { auth: "admin" }), method(object({
78586
- typeId: string().min(1),
78587
- name: string().min(1)
78588
- }), object({ entryId: string() }), {
78589
- kind: "mutation",
78590
- auth: "admin"
78591
- }), method(object({ entryId: string().min(1) }), object({ ok: literal(true) }), {
78592
- kind: "mutation",
78593
- auth: "admin"
78594
- }), method(TrainingProviderUpdateEntryInputSchema, object({ ok: literal(true) }), {
78595
- kind: "mutation",
78596
- auth: "admin"
78597
- }), method(object({ entryId: string().min(1) }), TrainingCredentialCheckSchema, {
78598
- kind: "mutation",
78599
- auth: "admin",
78600
- timeoutMs: 3e4
78601
- }), method(object({
78602
78504
  entryId: string().min(1),
78603
78505
  gpuType: string(),
78604
78506
  region: string(),
@@ -84051,20 +83953,6 @@ Object.freeze({
84051
83953
  access: "view",
84052
83954
  role: "admin"
84053
83955
  },
84054
- "connectionTest.describeTest": {
84055
- capName: "connection-test",
84056
- capScope: "system",
84057
- addonId: null,
84058
- access: "view",
84059
- role: "admin"
84060
- },
84061
- "connectionTest.testSettings": {
84062
- capName: "connection-test",
84063
- capScope: "system",
84064
- addonId: null,
84065
- access: "create",
84066
- role: "admin"
84067
- },
84068
83956
  "connectivity.getStatus": {
84069
83957
  capName: "connectivity",
84070
83958
  capScope: "device",
@@ -86431,13 +86319,6 @@ Object.freeze({
86431
86319
  access: "view",
86432
86320
  role: "admin"
86433
86321
  },
86434
- "integrations.testConnection": {
86435
- capName: "integrations",
86436
- capScope: "system",
86437
- addonId: null,
86438
- access: "create",
86439
- role: "admin"
86440
- },
86441
86322
  "integrations.update": {
86442
86323
  capName: "integrations",
86443
86324
  capScope: "system",
@@ -87670,13 +87551,6 @@ Object.freeze({
87670
87551
  access: "create",
87671
87552
  role: "admin"
87672
87553
  },
87673
- "mqttBroker.testConnection": {
87674
- capName: "mqtt-broker",
87675
- capScope: "system",
87676
- addonId: null,
87677
- access: "create",
87678
- role: "admin"
87679
- },
87680
87554
  "nativeObjectDetection.getOptions": {
87681
87555
  capName: "native-object-detection",
87682
87556
  capScope: "device",
@@ -92507,20 +92381,6 @@ Object.freeze({
92507
92381
  access: "create",
92508
92382
  role: "admin"
92509
92383
  },
92510
- "trainingProvider.createEntry": {
92511
- capName: "training-provider",
92512
- capScope: "system",
92513
- addonId: null,
92514
- access: "create",
92515
- role: "admin"
92516
- },
92517
- "trainingProvider.deleteEntry": {
92518
- capName: "training-provider",
92519
- capScope: "system",
92520
- addonId: null,
92521
- access: "delete",
92522
- role: "admin"
92523
- },
92524
92384
  "trainingProvider.describe": {
92525
92385
  capName: "training-provider",
92526
92386
  capScope: "system",
@@ -92591,13 +92451,6 @@ Object.freeze({
92591
92451
  access: "create",
92592
92452
  role: "admin"
92593
92453
  },
92594
- "trainingProvider.updateEntry": {
92595
- capName: "training-provider",
92596
- capScope: "system",
92597
- addonId: null,
92598
- access: "create",
92599
- role: "admin"
92600
- },
92601
92454
  "trainingProvider.uploadDataset": {
92602
92455
  capName: "training-provider",
92603
92456
  capScope: "system",
@@ -92605,13 +92458,6 @@ Object.freeze({
92605
92458
  access: "create",
92606
92459
  role: "admin"
92607
92460
  },
92608
- "trainingProvider.validateCredentials": {
92609
- capName: "training-provider",
92610
- capScope: "system",
92611
- addonId: null,
92612
- access: "create",
92613
- role: "admin"
92614
- },
92615
92461
  "turnProvider.getTurnServers": {
92616
92462
  capName: "turn-provider",
92617
92463
  capScope: "system",
@@ -122253,6 +122099,7 @@ function settingsReadOf(resolved) {
122253
122099
  };
122254
122100
  }
122255
122101
  function buildHomematicInstances(records, deps) {
122102
+ const handle = records.kind(homematicConnectionsEntryKind);
122256
122103
  return new RecordIntegrationInstances(records, homematicConnectionsEntryKind, {
122257
122104
  description: {
122258
122105
  role: "devices",
@@ -122262,12 +122109,33 @@ function buildHomematicInstances(records, deps) {
122262
122109
  },
122263
122110
  instanceMode: "multiple",
122264
122111
  kind: "connection",
122265
- canTest: false
122112
+ canTest: true
122266
122113
  },
122267
122114
  formSchema: () => buildConnectionFormSchema(),
122268
122115
  initialBody: (name) => ({ name }),
122269
122116
  configured: (body) => (body.host ?? "").trim().length > 0,
122270
- onChanged: () => deps.onChanged()
122117
+ onChanged: () => deps.onChanged(),
122118
+ test: async ({ id, values }) => {
122119
+ const stored = id === null ? null : (await handle.getResolved(id))?.data ?? null;
122120
+ const typed = values["password"];
122121
+ const password = typeof typed === "string" && typed !== "" && typed !== "__camstack_redacted__" ? typed : stored?.password ?? "";
122122
+ const outcome = await deps.tester.testSettings({ settings: {
122123
+ ...stored === null ? {} : connectionSettingsOf(stored),
122124
+ ...values,
122125
+ password
122126
+ } });
122127
+ if (outcome.outcome === "validated") return {
122128
+ success: true,
122129
+ status: "validated",
122130
+ ...outcome.latencyMs !== void 0 ? { latencyMs: outcome.latencyMs } : {},
122131
+ ...outcome.detail !== void 0 ? { detail: outcome.detail } : {}
122132
+ };
122133
+ return {
122134
+ success: false,
122135
+ status: outcome.outcome,
122136
+ error: outcome.error
122137
+ };
122138
+ }
122271
122139
  });
122272
122140
  }
122273
122141
  /** The ONE reader of a CCU's connection: the integration's record, never the legacy rows. */
@@ -125609,7 +125477,6 @@ var HmClientRegistry = class {
125609
125477
  };
125610
125478
  //#endregion
125611
125479
  //#region src/homematic-connection-test.ts
125612
- 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";
125613
125480
  /** How long one request to the CCU may take before the test gives up on it. */
125614
125481
  var PROBE_TIMEOUT_MS = 5e3;
125615
125482
  /** The ports the wrapped library binds each interface on (plain, TLS) and the path it serves. */
@@ -125763,65 +125630,62 @@ function describeSuccess(result) {
125763
125630
  }
125764
125631
  function buildHomematicConnectionTestProvider(deps) {
125765
125632
  const { logger, probe = probeCcu } = deps;
125766
- return {
125767
- describeTest: async () => ({ label: TEST_LABEL }),
125768
- testSettings: async ({ settings }) => {
125769
- if (readHost(settings) === null) return {
125770
- outcome: "rejected",
125771
- error: "Enter the CCU host or IP address."
125772
- };
125773
- const connection = connectionFromSettings(settings);
125774
- if (connection === null) return {
125775
- outcome: "rejected",
125776
- error: "Some of the connection settings are not valid."
125777
- };
125778
- const interfaces = enabledInterfaces(connection);
125779
- if (interfaces.length === 0) return {
125780
- outcome: "rejected",
125781
- error: "Enable at least one interface."
125633
+ return { testSettings: async ({ settings }) => {
125634
+ if (readHost(settings) === null) return {
125635
+ outcome: "rejected",
125636
+ error: "Enter the CCU host or IP address."
125637
+ };
125638
+ const connection = connectionFromSettings(settings);
125639
+ if (connection === null) return {
125640
+ outcome: "rejected",
125641
+ error: "Some of the connection settings are not valid."
125642
+ };
125643
+ const interfaces = enabledInterfaces(connection);
125644
+ if (interfaces.length === 0) return {
125645
+ outcome: "rejected",
125646
+ error: "Enable at least one interface."
125647
+ };
125648
+ const startedAt = Date.now();
125649
+ try {
125650
+ const result = await probe({
125651
+ host: connection.host,
125652
+ tls: connection.tls,
125653
+ username: connection.username,
125654
+ password: connection.password,
125655
+ interfaces
125656
+ });
125657
+ return {
125658
+ outcome: "validated",
125659
+ latencyMs: Date.now() - startedAt,
125660
+ detail: describeSuccess(result)
125782
125661
  };
125783
- const startedAt = Date.now();
125784
- try {
125785
- const result = await probe({
125786
- host: connection.host,
125787
- tls: connection.tls,
125788
- username: connection.username,
125789
- password: connection.password,
125790
- interfaces
125791
- });
125792
- return {
125793
- outcome: "validated",
125794
- latencyMs: Date.now() - startedAt,
125795
- detail: describeSuccess(result)
125662
+ } catch (err) {
125663
+ const kind = err instanceof CcuProbeError ? err.kind : "other";
125664
+ logger.warn("Homematic connection test failed", { meta: {
125665
+ host: connection.host,
125666
+ kind,
125667
+ error: errMsg(err)
125668
+ } });
125669
+ switch (kind) {
125670
+ case "bad-credentials": return {
125671
+ outcome: "rejected",
125672
+ error: "The CCU refused the WebUI username or password."
125673
+ };
125674
+ case "not-a-ccu": return {
125675
+ outcome: "rejected",
125676
+ error: `${connection.host} did not answer as a CCU3 or RaspberryMatic. Check the address.`
125677
+ };
125678
+ case "unreachable": return {
125679
+ outcome: "inconclusive",
125680
+ error: `Could not reach the CCU at ${connection.host}: ${errMsg(err)}`
125681
+ };
125682
+ case "other": return {
125683
+ outcome: "inconclusive",
125684
+ error: `The CCU test did not finish: ${errMsg(err)}`
125796
125685
  };
125797
- } catch (err) {
125798
- const kind = err instanceof CcuProbeError ? err.kind : "other";
125799
- logger.warn("Homematic connection test failed", { meta: {
125800
- host: connection.host,
125801
- kind,
125802
- error: errMsg(err)
125803
- } });
125804
- switch (kind) {
125805
- case "bad-credentials": return {
125806
- outcome: "rejected",
125807
- error: "The CCU refused the WebUI username or password."
125808
- };
125809
- case "not-a-ccu": return {
125810
- outcome: "rejected",
125811
- error: `${connection.host} did not answer as a CCU3 or RaspberryMatic. Check the address.`
125812
- };
125813
- case "unreachable": return {
125814
- outcome: "inconclusive",
125815
- error: `Could not reach the CCU at ${connection.host}: ${errMsg(err)}`
125816
- };
125817
- case "other": return {
125818
- outcome: "inconclusive",
125819
- error: `The CCU test did not finish: ${errMsg(err)}`
125820
- };
125821
- }
125822
125686
  }
125823
125687
  }
125824
- };
125688
+ } };
125825
125689
  }
125826
125690
  //#endregion
125827
125691
  //#region src/homematic-integration-device-cascade.ts
@@ -125919,7 +125783,10 @@ var HomematicProviderAddon = class extends BaseDeviceProvider {
125919
125783
  const records = this.ctx.records;
125920
125784
  if (records === void 0) throw new Error("provider-homematic: ctx.records is required (hub-only addon)");
125921
125785
  await records.declare(homematicRecordKinds);
125922
- const instances = buildHomematicInstances(records, { onChanged: () => this.reconcileIntegrations() });
125786
+ const instances = buildHomematicInstances(records, {
125787
+ onChanged: () => this.reconcileIntegrations(),
125788
+ tester: this.buildConnectionTestProvider()
125789
+ });
125923
125790
  this.instances = instances;
125924
125791
  this.declareRegistrySwitch({
125925
125792
  kind: homematicConnectionsEntryKind,
@@ -125958,10 +125825,6 @@ var HomematicProviderAddon = class extends BaseDeviceProvider {
125958
125825
  capability: deviceAdoptionCapability,
125959
125826
  provider: this.buildAdoptionProvider()
125960
125827
  },
125961
- {
125962
- capability: connectionTestCapability,
125963
- provider: this.buildConnectionTestProvider()
125964
- },
125965
125828
  {
125966
125829
  capability: addonPagesSourceCapability,
125967
125830
  provider: this.buildPagesProvider()