@camstack/types 1.2.610 → 1.2.612

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.
Files changed (41) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/dist/addon.js +2 -2
  3. package/dist/addon.mjs +2 -2
  4. package/dist/automation/action.d.ts +12 -0
  5. package/dist/automation/index.d.ts +2 -2
  6. package/dist/automation/recipe.d.ts +3473 -0
  7. package/dist/automation/scheduler.d.ts +24 -0
  8. package/dist/automation/step-runner.d.ts +4 -0
  9. package/dist/capabilities/action-source.cap.d.ts +6 -0
  10. package/dist/capabilities/actions.cap.d.ts +42 -0
  11. package/dist/capabilities/camera-streams.cap.d.ts +2 -0
  12. package/dist/capabilities/error.cap.d.ts +44 -1
  13. package/dist/capabilities/index.d.ts +1 -1
  14. package/dist/capabilities/integration-instances.cap.d.ts +3 -0
  15. package/dist/capabilities/notification-rules.cap.d.ts +14 -0
  16. package/dist/capabilities/osd-manager.cap.d.ts +6 -0
  17. package/dist/capabilities/schedulers.cap.d.ts +48 -0
  18. package/dist/capabilities/schemas/streaming-shared.d.ts +1 -0
  19. package/dist/capabilities/stream-broker.cap.d.ts +8 -0
  20. package/dist/capabilities/stream-catalog.cap.d.ts +4 -0
  21. package/dist/client.js +55 -3
  22. package/dist/client.mjs +55 -3
  23. package/dist/device/base-device.d.ts +10 -1
  24. package/dist/enums/event-category.d.ts +8 -0
  25. package/dist/enums.js +2 -1
  26. package/dist/enums.mjs +2 -1
  27. package/dist/{event-category-7P4A3bYA.mjs → event-category-BEsBTS72.mjs} +8 -0
  28. package/dist/{event-category-CMA0-jGW.js → event-category-CbY1jgIP.js} +8 -0
  29. package/dist/generated/addon-api.d.ts +8 -0
  30. package/dist/generated/method-access-map.d.ts +1 -1
  31. package/dist/generated/method-device-selectors.d.ts +1 -1
  32. package/dist/index.d.ts +2 -2
  33. package/dist/index.js +209 -12
  34. package/dist/index.mjs +205 -13
  35. package/dist/interfaces/event-bus.d.ts +11 -0
  36. package/dist/interfaces/stream-broker.d.ts +7 -0
  37. package/dist/notification/alert-episode.d.ts +8 -0
  38. package/dist/notification/system-event-filters.d.ts +1 -1
  39. package/dist/{runtime-capabilities-CK6y0W5U.mjs → runtime-capabilities-CG61dYnO.mjs} +14 -2
  40. package/dist/{runtime-capabilities-1FIC5jNX.js → runtime-capabilities-LaTKVCAw.js} +14 -2
  41. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_runtime_capabilities = require("./runtime-capabilities-1FIC5jNX.js");
3
- const require_event_category = require("./event-category-CMA0-jGW.js");
2
+ const require_runtime_capabilities = require("./runtime-capabilities-LaTKVCAw.js");
3
+ const require_event_category = require("./event-category-CbY1jgIP.js");
4
4
  const require_composed_stable_id = require("./composed-stable-id-DkF5-kuf.js");
5
5
  const require_implemented_methods = require("./implemented-methods-BHN-Utsb.js");
6
6
  const require_node_color = require("./node-color.js");
@@ -34029,8 +34029,15 @@ function convertLegacyWhen(half) {
34029
34029
  /** The longest one `wait` step lasts. It is cut by a restart of the run and does not survive a hub restart. */
34030
34030
  var WAIT_MAX_SECONDS = 3600;
34031
34031
  var WAIT_TOO_LONG = `a wait is at most one hour (${WAIT_MAX_SECONDS} s)`;
34032
+ /**
34033
+ * Every step kind may be switched off without deleting it: `enabled: false`
34034
+ * skips the step (and, for a block step, its whole subtree), traced `disabled`.
34035
+ * Absent means enabled.
34036
+ */
34037
+ var stepEnabledShape = { enabled: zod.z.boolean().optional() };
34032
34038
  var AutomationWaitStepSchema = zod.z.object({
34033
34039
  kind: zod.z.literal("wait"),
34040
+ ...stepEnabledShape,
34034
34041
  seconds: zod.z.number().min(0).max(WAIT_MAX_SECONDS, WAIT_TOO_LONG)
34035
34042
  });
34036
34043
  /**
@@ -34039,6 +34046,7 @@ var AutomationWaitStepSchema = zod.z.object({
34039
34046
  */
34040
34047
  var AutomationCommandStepBaseSchema = zod.z.object({
34041
34048
  kind: zod.z.literal("command"),
34049
+ ...stepEnabledShape,
34042
34050
  /** WHO the step acts on. */
34043
34051
  target: ActionTargetSchema,
34044
34052
  /** The vocabulary action this step performs (`cover.open`). */
@@ -34117,6 +34125,7 @@ var STOP_REASON_MAX = 200;
34117
34125
  /** End the run here, on purpose. `reason` may carry `{{vars.x}}` slots. */
34118
34126
  var AutomationStopStepSchema = zod.z.object({
34119
34127
  kind: zod.z.literal("stop"),
34128
+ ...stepEnabledShape,
34120
34129
  reason: zod.z.string().min(1, "a stop needs a reason: it is what the run trace shows").max(200),
34121
34130
  /** `ok`: the run ends as a success. `failed`: it ends as a failure, with the reason. */
34122
34131
  outcome: zod.z.enum(["ok", "failed"]),
@@ -34138,6 +34147,7 @@ var RESERVED_RUN_VARS = [
34138
34147
  */
34139
34148
  var AutomationSetStepSchema = zod.z.object({
34140
34149
  kind: zod.z.literal("set"),
34150
+ ...stepEnabledShape,
34141
34151
  vars: zod.z.record(zod.z.string(), zod.z.union([
34142
34152
  zod.z.string().max(500),
34143
34153
  zod.z.number(),
@@ -34146,8 +34156,25 @@ var AutomationSetStepSchema = zod.z.object({
34146
34156
  /** Set only when this reads true; false or unknown leaves the bag as it is. */
34147
34157
  if: AutomationWhenSchema.optional()
34148
34158
  });
34159
+ var NOTIFY_BODY_MAX = 2e3;
34160
+ /**
34161
+ * Send a notification through one notification target (the same targets the
34162
+ * notification centre addresses). Title and body may carry `{{vars.x}}` slots.
34163
+ * Not a device command: a notification target is an instance of the
34164
+ * `notification-output` cap, not a device.
34165
+ */
34166
+ var AutomationNotifyStepSchema = zod.z.object({
34167
+ kind: zod.z.literal("notify"),
34168
+ ...stepEnabledShape,
34169
+ /** The notification target (an instance id of `notification-output`). */
34170
+ targetId: zod.z.string().min(1, "pick the notification target"),
34171
+ title: zod.z.string().max(200).optional(),
34172
+ body: zod.z.string().min(1, "a notification needs a message").max(NOTIFY_BODY_MAX),
34173
+ ...continueOnErrorShape
34174
+ });
34149
34175
  var AutomationRunActionStepSchema = zod.z.object({
34150
34176
  kind: zod.z.literal("action"),
34177
+ ...stepEnabledShape,
34151
34178
  /** An entry of the `actions` surface (`internal:<uuid>` or `<addonId>:<localId>`). */
34152
34179
  actionId: zod.z.string().min(1),
34153
34180
  /** Values for the action's declared variables; the others take their default. */
@@ -34175,6 +34202,7 @@ var WAIT_UNTIL_TIMEOUT_MAX_S = 21600;
34175
34202
  */
34176
34203
  var AutomationWaitUntilStepSchema = zod.z.object({
34177
34204
  kind: zod.z.literal("wait-until"),
34205
+ ...stepEnabledShape,
34178
34206
  when: AutomationWhenSchema,
34179
34207
  timeoutS: zod.z.number().int().min(1, "a wait needs a timeout of at least one second").max(WAIT_UNTIL_TIMEOUT_MAX_S, `a wait for a condition is at most six hours (${WAIT_UNTIL_TIMEOUT_MAX_S} s)`),
34180
34208
  onTimeout: zod.z.enum(["continue", "stop"])
@@ -34201,7 +34229,8 @@ var plainStepSchemas = [
34201
34229
  AutomationCommandStepBaseSchema.extend(continueOnErrorShape).strict().superRefine(refineKnownAction),
34202
34230
  AutomationStopStepSchema.omit({ if: true }).strict(),
34203
34231
  AutomationSetStepSchema.omit({ if: true }).strict(),
34204
- AutomationRunActionStepSchema.strict()
34232
+ AutomationRunActionStepSchema.strict(),
34233
+ AutomationNotifyStepSchema.strict()
34205
34234
  ];
34206
34235
  /**
34207
34236
  * A plain step: a flow step with no condition of its own and no step inside
@@ -34211,7 +34240,7 @@ var AutomationBranchStepSchema = zod.z.discriminatedUnion("kind", plainStepSchem
34211
34240
  var PARALLEL_STEPS_MIN = 2;
34212
34241
  var PARALLEL_STEPS_MAX = 5;
34213
34242
  /** A step that can run beside others: it writes no variable and does not end the run. */
34214
- var AutomationParallelMemberSchema = AutomationBranchStepSchema.refine((step) => step.kind === "command" || step.kind === "action" || step.kind === "wait", "a parallel holds device commands, actions and waits only: a set or a stop beside other steps has no order");
34243
+ var AutomationParallelMemberSchema = AutomationBranchStepSchema.refine((step) => step.kind === "command" || step.kind === "action" || step.kind === "notify" || step.kind === "wait", "a parallel holds device commands, actions and waits only: a set or a stop beside other steps has no order");
34215
34244
  /**
34216
34245
  * Several steps at once (#500): all are started together and all are awaited.
34217
34246
  * A failure fails the run once the others finished, as in a sequence; a member
@@ -34219,6 +34248,7 @@ var AutomationParallelMemberSchema = AutomationBranchStepSchema.refine((step) =>
34219
34248
  */
34220
34249
  var AutomationParallelStepSchema = zod.z.object({
34221
34250
  kind: zod.z.literal("parallel"),
34251
+ ...stepEnabledShape,
34222
34252
  steps: zod.z.array(AutomationParallelMemberSchema).min(2, "a parallel needs at least two steps").max(5, `a parallel takes at most 5 steps`)
34223
34253
  }).strict();
34224
34254
  var REPEAT_COUNT_MAX = 20;
@@ -34265,6 +34295,7 @@ var AutomationRepeatLoopSchema = zod.z.discriminatedUnion("by", [
34265
34295
  function repeatSchemaOf(step) {
34266
34296
  return zod.z.object({
34267
34297
  kind: zod.z.literal("repeat"),
34298
+ ...stepEnabledShape,
34268
34299
  loop: AutomationRepeatLoopSchema,
34269
34300
  steps: zod.z.array(step).min(1, "a repeat needs at least one step").max(10, `a repeat takes at most 10 steps`)
34270
34301
  }).strict();
@@ -34280,6 +34311,7 @@ function chooseSchemaOf(step) {
34280
34311
  const steps = zod.z.array(step).max(10);
34281
34312
  return zod.z.object({
34282
34313
  kind: zod.z.literal("choose"),
34314
+ ...stepEnabledShape,
34283
34315
  branches: zod.z.array(zod.z.object({
34284
34316
  if: AutomationWhenSchema,
34285
34317
  steps: steps.min(1, "a branch needs at least one step")
@@ -34306,8 +34338,10 @@ var AutomationActionSchema = zod.z.discriminatedUnion("kind", [
34306
34338
  AutomationParallelStepSchema,
34307
34339
  AutomationRepeatStepSchema,
34308
34340
  AutomationRunActionStepSchema,
34341
+ AutomationNotifyStepSchema,
34309
34342
  zod.z.object({
34310
34343
  kind: zod.z.literal("code"),
34344
+ ...stepEnabledShape,
34311
34345
  /** Compiled into the automation's OWN block by esbuild — not a third
34312
34346
  * runtime, not a `vm`, and not dynamically evaluated. */
34313
34347
  code: zod.z.string().min(1).max(2e4)
@@ -34382,6 +34416,7 @@ var AutomationRecipeSchema = zod.z.union([CurrentAutomationRecipeSchema, LegacyA
34382
34416
  function stepGuardOf(action) {
34383
34417
  switch (action.kind) {
34384
34418
  case "action":
34419
+ case "notify":
34385
34420
  case "code":
34386
34421
  case "choose":
34387
34422
  case "wait-until":
@@ -35297,6 +35332,8 @@ function withoutNested(trace) {
35297
35332
  steps: steps.map(plainRow)
35298
35333
  };
35299
35334
  }
35335
+ /** The trace message of a step switched off with `enabled: false`. */
35336
+ var DISABLED_STEP_MESSAGE = "disabled";
35300
35337
  async function runSteps(steps, options) {
35301
35338
  const traces = [];
35302
35339
  let failed = false;
@@ -35324,6 +35361,18 @@ async function runSteps(steps, options) {
35324
35361
  });
35325
35362
  continue;
35326
35363
  }
35364
+ if (step.disabled === true) {
35365
+ const at = options.now();
35366
+ traces.push({
35367
+ ...step.meta,
35368
+ path,
35369
+ startedAt: at,
35370
+ endedAt: at,
35371
+ outcome: "skipped",
35372
+ message: DISABLED_STEP_MESSAGE
35373
+ });
35374
+ continue;
35375
+ }
35327
35376
  const startedAt = options.now();
35328
35377
  if (step.parallel !== void 0) {
35329
35378
  const members = await Promise.all(step.parallel.map((member, at) => runSteps([member], {
@@ -35822,7 +35871,10 @@ function guardOf(step, vars, deps) {
35822
35871
  }
35823
35872
  function buildActionSteps(steps, vars, deps) {
35824
35873
  return steps.map((step) => {
35825
- const guarded = guardOf(step, vars, deps);
35874
+ const guarded = {
35875
+ ...guardOf(step, vars, deps),
35876
+ ...step.enabled === false ? { disabled: true } : {}
35877
+ };
35826
35878
  const meta = stepMetaOfAction(step);
35827
35879
  if (step.kind === "wait") return {
35828
35880
  meta,
@@ -36753,6 +36805,7 @@ function stepMetaOf(action) {
36753
36805
  case "wait": return { kind: "wait" };
36754
36806
  case "code": return { kind: "code" };
36755
36807
  case "action": return { kind: "action" };
36808
+ case "notify": return { kind: "notify" };
36756
36809
  case "stop": return { kind: "stop" };
36757
36810
  case "wait-until": return { kind: "wait-until" };
36758
36811
  case "parallel": return { kind: "parallel" };
@@ -37031,6 +37084,17 @@ function emitStepBody(action) {
37031
37084
  if (result.outcome !== 'ran') {
37032
37085
  throw new Error('action ' + ${j(action.actionId)} + ' ' + result.outcome + (result.message === undefined ? '' : ': ' + result.message))
37033
37086
  }`;
37087
+ case "notify": return ` // a notification through one target: the one send path the exporters use
37088
+ const sent = await sendToExportedTarget(ctx.api, ctx.logger, {
37089
+ exporter: 'automation',
37090
+ targetId: ${j(action.targetId)},
37091
+ notification: {
37092
+ body: String(substitute(${j(action.body)}, vars)),
37093
+ ${action.title === void 0 ? "" : `title: String(substitute(${j(action.title)}, vars)),`}
37094
+ },
37095
+ })
37096
+ if (sent.status === 'refused') throw new Error('notification target ' + sent.reason)
37097
+ if (sent.status === 'failed') throw new Error('notification failed: ' + sent.message)`;
37034
37098
  case "stop": return ` // end the run here, on purpose: the steps after it are not-run with this reason
37035
37099
  scope.stop(String(substitute(${j(action.reason)}, vars)), ${j(action.outcome)})`;
37036
37100
  case "set": return ` // write the run's own bag, for the steps after this one — substitution only
@@ -37042,7 +37106,7 @@ ${action.code.split("\n").map((line) => ` ${line}`).join("\n")}
37042
37106
  }
37043
37107
  }
37044
37108
  function continues(action) {
37045
- return (action.kind === "command" || action.kind === "action") && action.continueOnError === true;
37109
+ return (action.kind === "command" || action.kind === "action" || action.kind === "notify") && action.continueOnError === true;
37046
37110
  }
37047
37111
  /** Whether the site is inside a block step: the automation's own steps sit at `actions.<n>`. */
37048
37112
  function isNestedSite(site) {
@@ -37143,6 +37207,12 @@ function emitRepeatLoop(loop, site) {
37143
37207
  }
37144
37208
  /** One step, wherever it sits: a block step emits its own steps one level down, under its path. */
37145
37209
  function emitStep(action, site) {
37210
+ const emitted = emitStepEnabled(action, site);
37211
+ if (action.enabled !== false) return emitted;
37212
+ const marker = `meta: ${site.meta},`;
37213
+ return emitted.replace(marker, `${marker}\n disabled: true,`);
37214
+ }
37215
+ function emitStepEnabled(action, site) {
37146
37216
  if (action.kind === "repeat") return ` {
37147
37217
  meta: ${site.meta},
37148
37218
  // a repeat step: the runner runs these once per iteration, under the bound
@@ -37283,6 +37353,7 @@ import {
37283
37353
  resolveStepArgs,
37284
37354
  resolveStepArgsWithTemplates,
37285
37355
  runForDevices,
37356
+ sendToExportedTarget,
37286
37357
  vocabCall,
37287
37358
  evaluateStepCondition,
37288
37359
  runSteps,
@@ -45382,6 +45453,8 @@ var streamBrokerCapability = {
45382
45453
  /** The slot the publisher says this stream IS — see `CameraStreamSchema.profileHint`. */
45383
45454
  profileHint: require_runtime_capabilities.CamProfileSchema.optional(),
45384
45455
  metadata: zod.z.record(zod.z.string(), zod.z.unknown()).optional(),
45456
+ /** The longest session the source keeps open (ms) — see `CameraStreamSchema.maxSessionMs`. */
45457
+ maxSessionMs: zod.z.number().int().positive().optional(),
45385
45458
  /** Required when kind === 'derived' — the source camStreamId the
45386
45459
  * derived broker reads its encoded plane from.
45387
45460
  * The runtime guard (broker manager, Task 10) enforces presence for
@@ -45825,6 +45898,12 @@ var streamBrokerCapability = {
45825
45898
  deviceId: zod.z.number().int().nonnegative(),
45826
45899
  camStreamId: zod.z.string(),
45827
45900
  brokerId: zod.z.string()
45901
+ })),
45902
+ onSourceRestart: require_runtime_capabilities.event(zod.z.object({
45903
+ deviceId: zod.z.number().int().nonnegative(),
45904
+ camStreamId: zod.z.string(),
45905
+ brokerId: zod.z.string(),
45906
+ reason: zod.z.string()
45828
45907
  }))
45829
45908
  },
45830
45909
  vocabulary: { notOperatorFacing: require_runtime_capabilities.NOT_A_DEVICE.PIPELINE }
@@ -62832,6 +62911,15 @@ var DeviceFaultSchema = zod.z.object({
62832
62911
  label: zod.z.string(),
62833
62912
  severity: DeviceErrorSeveritySchema
62834
62913
  });
62914
+ /** One kind of fault a device CAN raise: the integration's own declared catalog entry. */
62915
+ var DeviceFaultTypeSchema = DeviceFaultSchema;
62916
+ /**
62917
+ * The fault catalog of a device, declared by its integration at runtime (never a
62918
+ * code enum). A fault outside the catalog is still published and still matches
62919
+ * a rule that names no code.
62920
+ */
62921
+ var ListFaultTypesInputSchema = zod.z.object({ deviceId: zod.z.number().int().nonnegative() });
62922
+ var FaultTypesSchema = zod.z.object({ types: zod.z.array(DeviceFaultTypeSchema) });
62835
62923
  /**
62836
62924
  * The fault a device reports right now. One slice per device.
62837
62925
  *
@@ -62869,7 +62957,12 @@ var errorCapability = {
62869
62957
  scope: "device",
62870
62958
  deviceNative: true,
62871
62959
  mode: "singleton",
62872
- methods: {},
62960
+ methods: {
62961
+ /** The fault codes this device's integration can raise; `[]` when it declares none. */
62962
+ listFaultTypes: require_runtime_capabilities.method(ListFaultTypesInputSchema, FaultTypesSchema, {
62963
+ kind: "query",
62964
+ auth: "protected"
62965
+ }) },
62873
62966
  status: {
62874
62967
  schema: ErrorStatusSchema,
62875
62968
  kind: "push",
@@ -67484,6 +67577,8 @@ var IntegrationInstanceKindSchema = zod.z.object({
67484
67577
  role: IntegrationInstanceRoleSchema.optional(),
67485
67578
  /** `testInstance` really probes the remote for this kind; absent takes the provider's `canTest`. */
67486
67579
  canTest: zod.z.boolean().optional(),
67580
+ /** `false`: Add never offers this kind (the system creates its one instance, e.g. a default integration). Absent = creatable. */
67581
+ creatable: zod.z.boolean().optional(),
67487
67582
  /** The kind signs in through a server-held interactive session. */
67488
67583
  signIn: zod.z.object({
67489
67584
  basePath: zod.z.string().min(1),
@@ -82421,6 +82516,13 @@ var NcSystemEventConditionSchema = zod.z.object({
82421
82516
  * pick from. The hub refuses an id the action index does not know.
82422
82517
  */
82423
82518
  commandActions: zod.z.array(zod.z.string().min(1)).min(1).optional(),
82519
+ /**
82520
+ * `device-attention-*` only: the fault CODES this rule speaks about (the
82521
+ * integration declares them through `error.listFaultTypes`; free text is
82522
+ * accepted too). Absent or empty = any fault. The rule matches when any
82523
+ * fault of the episode is in the list.
82524
+ */
82525
+ faultCodes: zod.z.array(zod.z.string().min(1)).optional(),
82424
82526
  /** `device-command` only: how the command settled. A device's own change is not a command. */
82425
82527
  commandOutcomes: zod.z.array(zod.z.enum(NC_COMMAND_OUTCOMES)).min(1).optional(),
82426
82528
  /** `device-command` only: who asked (`user`, `addon`, `action`, `scheduler`, `composition`, `node`). */
@@ -98573,7 +98675,16 @@ var CamStreamDescriptorSchema = zod.z.object({
98573
98675
  /** The slot the publisher says this stream IS — see `CameraStreamSchema.profileHint`. */
98574
98676
  profileHint: require_runtime_capabilities.CamProfileSchema.optional(),
98575
98677
  /** Transport-specific opaque metadata (e.g. rfc4571 SDP). */
98576
- metadata: zod.z.record(zod.z.string(), zod.z.unknown()).optional()
98678
+ metadata: zod.z.record(zod.z.string(), zod.z.unknown()).optional(),
98679
+ /**
98680
+ * The longest continuous session the SOURCE will keep open, in ms, declared by
98681
+ * the provider that knows it (a hub that cuts every child's session on a
98682
+ * timer). Absent = no limit. The broker re-dials a live source a little
98683
+ * BEFORE this elapses, on its own terms and announced to consumers, so the
98684
+ * source's cut never lands mid-recording. Declare slightly under what was
98685
+ * observed.
98686
+ */
98687
+ maxSessionMs: zod.z.number().int().positive().optional()
98577
98688
  });
98578
98689
  /**
98579
98690
  * `stream-catalog` — device-scoped, provider-implemented. The pull counterpart
@@ -115018,6 +115129,20 @@ function deviceErrorEdge(previous, next) {
115018
115129
  function deviceErrorAlertId(deviceId) {
115019
115130
  return `device-error:${String(deviceId)}`;
115020
115131
  }
115132
+ /** Every active fault, the principal first; a status that lists none still names its principal. */
115133
+ function activeFaults(status) {
115134
+ if (status.faults !== void 0 && status.faults.length > 0) return status.faults.map(({ code, label, severity }) => ({
115135
+ code,
115136
+ label,
115137
+ severity
115138
+ }));
115139
+ if (status.code === null) return [];
115140
+ return [{
115141
+ code: status.code,
115142
+ label: status.label ?? status.code,
115143
+ severity: status.severity
115144
+ }];
115145
+ }
115021
115146
  /** The alert that opens an episode. `since` is the fault's own start, else `now`. */
115022
115147
  function buildDeviceErrorAlert(deviceId, deviceName, status, now) {
115023
115148
  const label = status.label ?? status.code ?? "Fault";
@@ -115045,7 +115170,9 @@ function buildDeviceErrorAlert(deviceId, deviceName, status, now) {
115045
115170
  metadata: {
115046
115171
  episodeId: `${alertId}@${String(startedAt)}`,
115047
115172
  code: status.code,
115048
- deviceSeverity: status.severity
115173
+ deviceSeverity: status.severity,
115174
+ label: status.label,
115175
+ faults: activeFaults(status)
115049
115176
  }
115050
115177
  };
115051
115178
  }
@@ -115057,6 +115184,8 @@ var BaseDevice = class {
115057
115184
  type;
115058
115185
  /** True when another process owns the base slices (`options.deviceStatus: 'external'`). */
115059
115186
  statusIsExternal;
115187
+ /** The fault catalog the integration declared; `[]` until it does. */
115188
+ faultTypes = [];
115060
115189
  name;
115061
115190
  parentDeviceId;
115062
115191
  role;
@@ -115394,10 +115523,19 @@ var BaseDevice = class {
115394
115523
  * a restart is compared, not announced again.
115395
115524
  */
115396
115525
  registerErrorCap() {
115397
- this.ctx.registerNativeCap?.(errorCapability, {});
115526
+ this.ctx.registerNativeCap?.(errorCapability, { listFaultTypes: async () => ({ types: [...this.faultTypes] }) });
115398
115527
  if (this.runtimeState.getCapState(errorCapability.name) === void 0) this.setCapSlice(errorCapability, ERROR_STATUS_COLD);
115399
115528
  }
115400
115529
  /**
115530
+ * Declare the fault kinds this device's integration can raise (code, label,
115531
+ * severity), served by `error.listFaultTypes` so a rule's code picker is
115532
+ * offered the integration's own words. The default is `[]`; a fault outside
115533
+ * the catalog is still published. Call it before or after `registerErrorCap`.
115534
+ */
115535
+ declareFaultTypes(types) {
115536
+ this.faultTypes = types.map((type) => ({ ...type }));
115537
+ }
115538
+ /**
115401
115539
  * Publish the device's fault. The slice is written; on an EDGE (a fault
115402
115540
  * starts, or one resolves) an attention episode opens or closes through the
115403
115541
  * alerts cap, which the notification center announces as
@@ -124573,6 +124711,13 @@ var METHOD_ACCESS_MAP = Object.freeze({
124573
124711
  access: "view",
124574
124712
  role: "viewer"
124575
124713
  },
124714
+ "error.listFaultTypes": {
124715
+ capName: "error",
124716
+ capScope: "device",
124717
+ addonId: null,
124718
+ access: "view",
124719
+ role: "viewer"
124720
+ },
124576
124721
  "eventEmitter.getStatus": {
124577
124722
  capName: "event-emitter",
124578
124723
  capScope: "device",
@@ -135478,6 +135623,11 @@ var METHOD_DEVICE_SELECTORS = Object.freeze({
135478
135623
  form: "single",
135479
135624
  optional: false
135480
135625
  }],
135626
+ "error.listFaultTypes": [{
135627
+ name: "deviceId",
135628
+ form: "single",
135629
+ optional: false
135630
+ }],
135481
135631
  "eventEmitter.getStatus": [{
135482
135632
  name: "deviceId",
135483
135633
  form: "single",
@@ -140935,7 +141085,8 @@ var NC_SYSTEM_EVENT_FILTER_KEYS = [
140935
141085
  "consumableLowPercent",
140936
141086
  "commandActions",
140937
141087
  "commandOutcomes",
140938
- "commandActorKinds"
141088
+ "commandActorKinds",
141089
+ "faultCodes"
140939
141090
  ];
140940
141091
  /**
140941
141092
  * Does `filter` say anything about `kind`?
@@ -140954,6 +141105,7 @@ function systemEventFilterApplies(kind, filter) {
140954
141105
  case "commandActions":
140955
141106
  case "commandOutcomes":
140956
141107
  case "commandActorKinds": return kind === "device-command";
141108
+ case "faultCodes": return kind === "device-attention-required" || kind === "device-attention-resolved";
140957
141109
  }
140958
141110
  }
140959
141111
  /**
@@ -141069,7 +141221,8 @@ var NC_SYSTEM_EVENT_FAMILY_FILTERS = {
141069
141221
  "consumableLowPercent",
141070
141222
  "commandActions",
141071
141223
  "commandOutcomes",
141072
- "commandActorKinds"
141224
+ "commandActorKinds",
141225
+ "faultCodes"
141073
141226
  ],
141074
141227
  system: ["nodeIds", "packageNames"],
141075
141228
  alarm: ["deviceIds"]
@@ -143112,6 +143265,8 @@ var AlertEpisodePayloadSchema = zod.z.object({
143112
143265
  nodeId: zod.z.string().optional(),
143113
143266
  /** The alert's own action link (where the operator acts on it), when it has one. */
143114
143267
  actionUrl: zod.z.string().optional(),
143268
+ /** A device fault episode: every active fault (`metadata.faults`), principal first. */
143269
+ faults: zod.z.array(DeviceFaultSchema).optional(),
143115
143270
  at: zod.z.number()
143116
143271
  });
143117
143272
  /** The payload of an `alert.episode` event's `data`, or `null` when it is not one. */
@@ -143161,8 +143316,14 @@ function deviceAttentionKind(severity, phase) {
143161
143316
  if (severity !== "critical") return null;
143162
143317
  return phase === "raised" ? "device-attention-required" : "device-attention-resolved";
143163
143318
  }
143319
+ /** The faults a device-error alert carries in its metadata; none when absent or malformed. */
143320
+ function alertFaults(alert) {
143321
+ const parsed = zod.z.array(DeviceFaultSchema).safeParse(alert.metadata?.["faults"]);
143322
+ return parsed.success && parsed.data.length > 0 ? parsed.data : void 0;
143323
+ }
143164
143324
  function alertEpisodePayload(alert, phase, at) {
143165
143325
  const nodeId = alertNodeId(alert);
143326
+ const faults = alertFaults(alert);
143166
143327
  return {
143167
143328
  phase,
143168
143329
  episodeId: alertEpisodeId(alert),
@@ -143177,6 +143338,7 @@ function alertEpisodePayload(alert, phase, at) {
143177
143338
  } : {},
143178
143339
  ...nodeId !== void 0 ? { nodeId } : {},
143179
143340
  ...alert.action?.href !== void 0 ? { actionUrl: alert.action.href } : {},
143341
+ ...faults !== void 0 ? { faults } : {},
143180
143342
  at
143181
143343
  };
143182
143344
  }
@@ -144305,6 +144467,36 @@ var NC_TEMPLATE_VARS = [
144305
144467
  kinds: ["system"],
144306
144468
  systemEventKinds: [...DEVICE_ATTENTION, ...ALERT_EPISODE]
144307
144469
  },
144470
+ {
144471
+ name: "faultCode",
144472
+ label: "Fault code",
144473
+ example: "hb-rf-eth-connection",
144474
+ group: "system",
144475
+ families: ["rule"],
144476
+ fields: [...RULE_TEXT],
144477
+ kinds: ["system"],
144478
+ systemEventKinds: [...DEVICE_ATTENTION]
144479
+ },
144480
+ {
144481
+ name: "faultLabel",
144482
+ label: "Fault",
144483
+ example: "HB-RF-ETH connection lost",
144484
+ group: "system",
144485
+ families: ["rule"],
144486
+ fields: [...RULE_TEXT],
144487
+ kinds: ["system"],
144488
+ systemEventKinds: [...DEVICE_ATTENTION]
144489
+ },
144490
+ {
144491
+ name: "faults",
144492
+ label: "All active faults",
144493
+ example: "HB-RF-ETH connection lost, CCU supply voltage low",
144494
+ group: "system",
144495
+ families: ["rule"],
144496
+ fields: [...RULE_TEXT],
144497
+ kinds: ["system"],
144498
+ systemEventKinds: [...DEVICE_ATTENTION]
144499
+ },
144308
144500
  {
144309
144501
  name: "exportId",
144310
144502
  label: "Export id",
@@ -151925,6 +152117,7 @@ exports.AutomationCommandStepSchema = AutomationCommandStepSchema;
151925
152117
  exports.AutomationConditionOperatorSchema = AutomationConditionOperatorSchema;
151926
152118
  exports.AutomationConditionTraceNodeSchema = AutomationConditionTraceNodeSchema;
151927
152119
  exports.AutomationControlStatusSchema = AutomationControlStatusSchema;
152120
+ exports.AutomationNotifyStepSchema = AutomationNotifyStepSchema;
151928
152121
  exports.AutomationParallelStepSchema = AutomationParallelStepSchema;
151929
152122
  exports.AutomationRecipeSchema = AutomationRecipeSchema;
151930
152123
  exports.AutomationRepeatLoopSchema = AutomationRepeatLoopSchema;
@@ -152399,6 +152592,7 @@ exports.DEVICE_TRANSITIONS_RECORD_BATCH_MAX = DEVICE_TRANSITIONS_RECORD_BATCH_MA
152399
152592
  exports.DEVICE_TYPE_CONTROL_KIND = DEVICE_TYPE_CONTROL_KIND;
152400
152593
  exports.DEVICE_TYPE_ICON = DEVICE_TYPE_ICON;
152401
152594
  exports.DEVICE_TYPE_INFO = DEVICE_TYPE_INFO;
152595
+ exports.DISABLED_STEP_MESSAGE = DISABLED_STEP_MESSAGE;
152402
152596
  exports.DISPLAY_PREFERENCES = require_runtime_capabilities.DISPLAY_PREFERENCES;
152403
152597
  exports.DISPLAY_PRESETS = DISPLAY_PRESETS;
152404
152598
  exports.DOORBELL_RISE_DEBOUNCE_MS = DOORBELL_RISE_DEBOUNCE_MS;
@@ -152457,6 +152651,7 @@ exports.DeviceExportSetExposedNameInputSchema = SetExposedNameInputSchema;
152457
152651
  exports.DeviceExportStatusSchema = DeviceExportStatusSchema;
152458
152652
  exports.DeviceExportUnexposeInputSchema = UnexposeInputSchema;
152459
152653
  exports.DeviceFaultSchema = DeviceFaultSchema;
152654
+ exports.DeviceFaultTypeSchema = DeviceFaultTypeSchema;
152460
152655
  exports.DeviceFeature = require_composed_stable_id.DeviceFeature;
152461
152656
  exports.DeviceFiredMatchSchema = DeviceFiredMatchSchema;
152462
152657
  exports.DeviceFiredWatch = DeviceFiredWatch;
@@ -152729,6 +152924,7 @@ exports.FanPresetSchema = FanPresetSchema;
152729
152924
  exports.FanPresetStateSchema = FanPresetStateSchema;
152730
152925
  exports.FanPresetsRefusalSchema = FanPresetsRefusalSchema;
152731
152926
  exports.FanPresetsSetResultSchema = FanPresetsSetResultSchema;
152927
+ exports.FaultTypesSchema = FaultTypesSchema;
152732
152928
  exports.FeatureManifestSchema = FeatureManifestSchema;
152733
152929
  exports.FeatureProbeStatusSchema = FeatureProbeStatusSchema;
152734
152930
  exports.FieldClaimModeSchema = FieldClaimModeSchema;
@@ -152994,6 +153190,7 @@ exports.LegacyTriggerSchema = LegacyTriggerSchema;
152994
153190
  exports.LinkedDeviceSchema = LinkedDeviceSchema;
152995
153191
  exports.LinkedDevicesModeSchema = LinkedDevicesModeSchema;
152996
153192
  exports.LinkedDevicesSlotValueSchema = LinkedDevicesSlotValueSchema;
153193
+ exports.ListFaultTypesInputSchema = ListFaultTypesInputSchema;
152997
153194
  exports.ListNodeBenchmarkResultsInputSchema = ListNodeBenchmarkResultsInputSchema;
152998
153195
  exports.ListTrackRelationsInputSchema = ListTrackRelationsInputSchema;
152999
153196
  exports.ListTrackRelationsResultSchema = ListTrackRelationsResultSchema;