@camstack/types 1.2.548 → 1.2.550

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 (90) hide show
  1. package/CHANGELOG.md +33 -0
  2. package/dist/addon/addon-instance.d.ts +24 -0
  3. package/dist/addon/build-addon-route-provider.d.ts +2 -0
  4. package/dist/addon.js +5 -5
  5. package/dist/addon.mjs +5 -5
  6. package/dist/automation/index.d.ts +4 -3
  7. package/dist/automation/recipe.d.ts +12105 -604
  8. package/dist/automation/scheduler.d.ts +7 -0
  9. package/dist/automation/step-runner.d.ts +70 -0
  10. package/dist/automation/trace.d.ts +252 -145
  11. package/dist/automation/wait-until.d.ts +32 -0
  12. package/dist/automation/when-site.d.ts +1 -1
  13. package/dist/capabilities/accessories.cap.d.ts +1 -1
  14. package/dist/capabilities/actions.cap.d.ts +1 -178
  15. package/dist/capabilities/addon-routes.cap.d.ts +3 -0
  16. package/dist/capabilities/battery.cap.d.ts +2 -2
  17. package/dist/capabilities/capability-definition.d.ts +47 -1
  18. package/dist/capabilities/climate-control.cap.d.ts +8 -1
  19. package/dist/capabilities/core-blocks.cap.d.ts +119 -8723
  20. package/dist/capabilities/customize-catalog.d.ts +3 -1
  21. package/dist/capabilities/customize-spec.d.ts +26 -2
  22. package/dist/capabilities/device-manager.cap.d.ts +6 -0
  23. package/dist/capabilities/event-emitter.cap.d.ts +99 -3
  24. package/dist/capabilities/event-vocabulary.d.ts +99 -0
  25. package/dist/capabilities/fan-control.cap.d.ts +248 -0
  26. package/dist/capabilities/fan-presets.cap.d.ts +172 -536
  27. package/dist/capabilities/group-active.cap.d.ts +1 -1
  28. package/dist/capabilities/group-commands.cap.d.ts +1 -1
  29. package/dist/capabilities/group-status.cap.d.ts +1 -1
  30. package/dist/capabilities/heating-valve.cap.d.ts +1 -1
  31. package/dist/capabilities/hero-layout.cap.d.ts +2 -0
  32. package/dist/capabilities/humidifier.cap.d.ts +5 -0
  33. package/dist/capabilities/humidity-sensor.cap.d.ts +1 -1
  34. package/dist/capabilities/index.d.ts +5 -4
  35. package/dist/capabilities/media-player.cap.d.ts +7 -0
  36. package/dist/capabilities/oauth-integration.cap.d.ts +8 -0
  37. package/dist/capabilities/pet-fountain.cap.d.ts +5 -0
  38. package/dist/capabilities/power-meter.cap.d.ts +5 -5
  39. package/dist/capabilities/power-source.cap.d.ts +5 -0
  40. package/dist/capabilities/running-state.cap.d.ts +2 -2
  41. package/dist/capabilities/schedulers.cap.d.ts +1 -178
  42. package/dist/capabilities/sso-bridge.cap.d.ts +3 -0
  43. package/dist/capabilities/switch.cap.d.ts +1 -1
  44. package/dist/capabilities/temperature-sensor.cap.d.ts +1 -1
  45. package/dist/capabilities/timed-run.cap.d.ts +19 -5
  46. package/dist/capabilities/user-management.cap.d.ts +4 -0
  47. package/dist/capabilities/water-heater.cap.d.ts +7 -0
  48. package/dist/client.js +7 -11
  49. package/dist/client.mjs +7 -11
  50. package/dist/{composed-stable-id-DrGLxjVF.js → composed-stable-id-CDNLq7Y8.js} +27 -10
  51. package/dist/{composed-stable-id-DFNyOFzz.mjs → composed-stable-id-CPp3votu.mjs} +27 -10
  52. package/dist/composition/composition-report.d.ts +6 -0
  53. package/dist/composition/evaluate-field.d.ts +7 -0
  54. package/dist/composition/field-kinds.d.ts +12 -1
  55. package/dist/composition/helpers/index.d.ts +1 -1
  56. package/dist/composition/helpers/source-pick.d.ts +0 -5
  57. package/dist/composition/power-source-link.d.ts +15 -0
  58. package/dist/composition/state-fields.d.ts +2 -0
  59. package/dist/composition/validate-composition.d.ts +15 -1
  60. package/dist/device/base-device-provider.d.ts +13 -0
  61. package/dist/device/device-control-resolution.d.ts +1 -33
  62. package/dist/device/device-kind.d.ts +36 -0
  63. package/dist/device/device-management.d.ts +3 -0
  64. package/dist/device/device-type.d.ts +27 -10
  65. package/dist/device/hero/hero-fragment.d.ts +2 -0
  66. package/dist/device/hero/hero-layout.d.ts +1 -3
  67. package/dist/device/hero/hero-look.d.ts +18 -12
  68. package/dist/device/hero/hero-scene.d.ts +9 -3
  69. package/dist/device/index.d.ts +2 -1
  70. package/dist/device/power-switch.d.ts +82 -0
  71. package/dist/device/schema-fields.d.ts +10 -1
  72. package/dist/generated/addon-api.d.ts +7 -0
  73. package/dist/generated/addon-cap-facts.d.ts +1 -1
  74. package/dist/generated/cap-input-defaults.d.ts +1 -1
  75. package/dist/generated/collection-array-methods.d.ts +1 -1
  76. package/dist/generated/customize-catalog.d.ts +257 -8
  77. package/dist/generated/method-access-map.d.ts +1 -1
  78. package/dist/generated/method-device-selectors.d.ts +1 -1
  79. package/dist/{implemented-methods-M5aguGon.mjs → implemented-methods-5YMDeE3f.mjs} +1 -1
  80. package/dist/{implemented-methods-8AU92riC.js → implemented-methods-Cj65uy2F.js} +1 -1
  81. package/dist/index.d.ts +11 -6
  82. package/dist/index.js +2386 -494
  83. package/dist/index.mjs +2312 -488
  84. package/dist/interfaces/addon-routes.d.ts +13 -0
  85. package/dist/interfaces/config-ui.d.ts +15 -24
  86. package/dist/node.js +2 -2
  87. package/dist/node.mjs +2 -2
  88. package/dist/{sleep-D_NpiLFP.mjs → sleep-D0roI_CZ.mjs} +50 -1
  89. package/dist/{sleep-vzHEmsrO.js → sleep-dcR4vBFG.js} +50 -1
  90. package/package.json +1 -1
@@ -93,6 +93,13 @@ export declare const DEFAULT_MAX_HOLD_ATTEMPTS = 3;
93
93
  export declare const MAX_HOLD_ATTEMPTS_LIMIT = 20;
94
94
  /** A missed edge up to this late still runs. */
95
95
  export declare const DEFAULT_MAX_LATE_MS: number;
96
+ /**
97
+ * The longest one `wait` of a scheduler point lasts. A point's steps run in
98
+ * the scheduler's one serial queue, with no run ceiling: a wait holds every
99
+ * other scheduler's points for as long as it lasts. An action (one hour) has
100
+ * its own run and ceiling; a point keeps the five minutes it always had.
101
+ */
102
+ export declare const SCHEDULER_WAIT_MAX_SECONDS = 300;
96
103
  export declare const SchedulerPointSchema: z.ZodObject<{
97
104
  id: z.ZodString;
98
105
  at: z.ZodDiscriminatedUnion<[z.ZodObject<{
@@ -7,6 +7,11 @@
7
7
  * sequence STOPS at the first failure (continuing past a failed step executes
8
8
  * an intent the operator never expressed), and every step is traced — the ones
9
9
  * after a failure, or after an abort, are `not-run` with the reason.
10
+ *
11
+ * Flow control (#500) is the operator EXPRESSING that intent: a step marked
12
+ * `continueOnError` is traced `failed-continued` and the sequence goes on; a
13
+ * `stop` step ends the run on purpose, as a success or as a failure, and the
14
+ * steps after it are `not-run` with its reason.
10
15
  */
11
16
  import type { CommandOriginClaim } from '../audit/device-transition.js';
12
17
  import type { DeviceTemplateRender } from '../expression/device-template.js';
@@ -34,6 +39,19 @@ export interface StepScope {
34
39
  setArgs(args: Readonly<Record<string, unknown>>): void;
35
40
  /** The device values the step's templates printed as `—`, with the reason (D1021). */
36
41
  setTemplateNotes(notes: readonly string[]): void;
42
+ /** End the run here, on purpose (#500): the later steps are `not-run` with this reason. */
43
+ stop(reason: string, outcome: StepStopOutcome): void;
44
+ /** The step waited for something that did not come and the run goes on (#500): traced `timed-out`. */
45
+ markTimedOut(reason: string): void;
46
+ }
47
+ /** How a `stop` step ends the run: as a success, or as a failure. */
48
+ export type StepStopOutcome = 'ok' | 'failed';
49
+ /** The `stop` that ended a run. */
50
+ export interface StepStop {
51
+ readonly reason: string;
52
+ readonly outcome: StepStopOutcome;
53
+ /** The step that stopped it. */
54
+ readonly path: string;
37
55
  }
38
56
  /** One step as the runner sees it: its meta and a closure that does the work. */
39
57
  export interface RunnableStep {
@@ -43,6 +61,46 @@ export interface RunnableStep {
43
61
  readonly guard?: () => Promise<StepConditionVerdict>;
44
62
  /** Run when the guard reads `false`; never when it reads `unknown`. */
45
63
  readonly otherwise?: readonly RunnableStep[];
64
+ /** A failure of THIS step is traced `failed-continued` and the sequence goes on (#500). */
65
+ readonly continueOnError?: boolean;
66
+ /** A `choose` step (#500): `run` is not called, the first branch that reads true is. */
67
+ readonly choose?: RunnableChoose;
68
+ /** A `parallel` step (#500): `run` is not called, these are started together and all awaited. */
69
+ readonly parallel?: readonly RunnableStep[];
70
+ /** A `repeat` step (#500): `run` is not called, the steps are, once per iteration. */
71
+ readonly repeat?: RunnableRepeat;
72
+ }
73
+ /** What a loop's condition answers: go on, or end the loop and why. */
74
+ export type RepeatCheck = {
75
+ readonly go: true;
76
+ } | {
77
+ readonly go: false;
78
+ readonly reason: string;
79
+ /** The condition could not be read: the loop ends and says so (D49). */
80
+ readonly unknown?: true;
81
+ };
82
+ export interface RunnableRepeat {
83
+ readonly steps: readonly RunnableStep[];
84
+ /** The most iterations the loop runs, whatever its condition says. */
85
+ readonly limit: number;
86
+ /** True when reaching `limit` means the condition never ended the loop: traced `timed-out`. */
87
+ readonly limitIsTimeout: boolean;
88
+ /** Asked before iteration `n` (0-based): a `while`, or the next device of a list. */
89
+ readonly before?: (iteration: number) => Promise<RepeatCheck>;
90
+ /** Asked after iteration `n`: an `until`. */
91
+ readonly after?: (iteration: number) => Promise<RepeatCheck>;
92
+ /** A pause between two iterations, never after the last. */
93
+ readonly between?: () => Promise<void>;
94
+ }
95
+ /** One branch of a `choose`: its condition and the steps it runs. */
96
+ export interface RunnableBranch {
97
+ readonly guard: () => Promise<StepConditionVerdict>;
98
+ readonly steps: readonly RunnableStep[];
99
+ }
100
+ export interface RunnableChoose {
101
+ readonly branches: readonly RunnableBranch[];
102
+ /** Run when every branch reads `false`; never when one reads `unknown`. */
103
+ readonly otherwise?: readonly RunnableStep[];
46
104
  }
47
105
  export interface StepFailure {
48
106
  readonly index: number;
@@ -68,12 +126,24 @@ export interface RunStepsOptions {
68
126
  readonly onFailure: (failure: StepFailure) => void;
69
127
  /** Called for a step skipped because its `if` read unknown: a branch that drops work says so (#472). */
70
128
  readonly onGuardUnknown?: (skipped: StepGuardUnknown) => void;
129
+ /** Called for a step that failed and was passed over (`continueOnError`): work that was dropped says so. */
130
+ readonly onContinuedFailure?: (failure: StepFailure) => void;
131
+ /** The index the first step of this list is traced at (a member of a `parallel` runs as a list of one). */
132
+ readonly indexOffset?: number;
71
133
  }
72
134
  export interface RunStepsResult {
73
135
  readonly steps: readonly AutomationStepTrace[];
74
136
  readonly failed: boolean;
75
137
  readonly aborted: boolean;
138
+ /** Set when a `stop` step ended the run. */
139
+ readonly stopped?: StepStop;
76
140
  }
141
+ /**
142
+ * What a loop's condition says about going on. A `while` goes on while it
143
+ * reads true, an `until` goes on while it reads false; `unknown` ends either,
144
+ * with the reason (D49): a loop never runs on a value it could not read.
145
+ */
146
+ export declare function repeatCheck(by: 'while' | 'until', verdict: StepConditionVerdict): RepeatCheck;
77
147
  export declare function runSteps(steps: readonly RunnableStep[], options: RunStepsOptions): Promise<RunStepsResult>;
78
148
  /** The bag of values `{ $var }` and `{{vars.x}}` read from. */
79
149
  export type StepVars = Readonly<Record<string, unknown>>;
@@ -136,6 +136,90 @@ export declare const StepDeviceTraceSchema: z.ZodObject<{
136
136
  export type StepDeviceTrace = z.infer<typeof StepDeviceTraceSchema>;
137
137
  /** How many unknown-value notes one step trace keeps. */
138
138
  export declare const MAX_STEP_TEMPLATE_NOTES = 20;
139
+ /** A step one level down: it may be a block step itself, whose own steps are plain rows (the nesting ends there). */
140
+ export declare const NestedStepTraceSchema: z.ZodObject<{
141
+ path: z.ZodString;
142
+ kind: z.ZodString;
143
+ cap: z.ZodOptional<z.ZodString>;
144
+ method: z.ZodOptional<z.ZodString>;
145
+ actionId: z.ZodOptional<z.ZodString>;
146
+ deviceId: z.ZodOptional<z.ZodNumber>;
147
+ devices: z.ZodOptional<z.ZodArray<z.ZodObject<{
148
+ deviceId: z.ZodNumber;
149
+ outcome: z.ZodEnum<{
150
+ error: "error";
151
+ ok: "ok";
152
+ }>;
153
+ message: z.ZodOptional<z.ZodString>;
154
+ }, z.core.$strip>>>;
155
+ startedAt: z.ZodOptional<z.ZodNumber>;
156
+ endedAt: z.ZodOptional<z.ZodNumber>;
157
+ args: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodNull, z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>]>>>;
158
+ templates: z.ZodOptional<z.ZodArray<z.ZodString>>;
159
+ condition: z.ZodOptional<z.ZodEnum<{
160
+ false: "false";
161
+ true: "true";
162
+ unknown: "unknown";
163
+ }>>;
164
+ conditionReason: z.ZodOptional<z.ZodString>;
165
+ outcome: z.ZodEnum<{
166
+ empty: "empty";
167
+ error: "error";
168
+ "failed-continued": "failed-continued";
169
+ "not-run": "not-run";
170
+ ok: "ok";
171
+ skipped: "skipped";
172
+ "timed-out": "timed-out";
173
+ }>;
174
+ message: z.ZodOptional<z.ZodString>;
175
+ branch: z.ZodOptional<z.ZodString>;
176
+ branchChecks: z.ZodOptional<z.ZodArray<z.ZodObject<{
177
+ condition: z.ZodEnum<{
178
+ false: "false";
179
+ true: "true";
180
+ unknown: "unknown";
181
+ }>;
182
+ conditionReason: z.ZodOptional<z.ZodString>;
183
+ }, z.core.$strip>>>;
184
+ iterations: z.ZodOptional<z.ZodNumber>;
185
+ steps: z.ZodOptional<z.ZodArray<z.ZodObject<{
186
+ path: z.ZodString;
187
+ kind: z.ZodString;
188
+ cap: z.ZodOptional<z.ZodString>;
189
+ method: z.ZodOptional<z.ZodString>;
190
+ actionId: z.ZodOptional<z.ZodString>;
191
+ deviceId: z.ZodOptional<z.ZodNumber>;
192
+ devices: z.ZodOptional<z.ZodArray<z.ZodObject<{
193
+ deviceId: z.ZodNumber;
194
+ outcome: z.ZodEnum<{
195
+ error: "error";
196
+ ok: "ok";
197
+ }>;
198
+ message: z.ZodOptional<z.ZodString>;
199
+ }, z.core.$strip>>>;
200
+ startedAt: z.ZodOptional<z.ZodNumber>;
201
+ endedAt: z.ZodOptional<z.ZodNumber>;
202
+ args: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodNull, z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>]>>>;
203
+ templates: z.ZodOptional<z.ZodArray<z.ZodString>>;
204
+ condition: z.ZodOptional<z.ZodEnum<{
205
+ false: "false";
206
+ true: "true";
207
+ unknown: "unknown";
208
+ }>>;
209
+ conditionReason: z.ZodOptional<z.ZodString>;
210
+ outcome: z.ZodEnum<{
211
+ empty: "empty";
212
+ error: "error";
213
+ "failed-continued": "failed-continued";
214
+ "not-run": "not-run";
215
+ ok: "ok";
216
+ skipped: "skipped";
217
+ "timed-out": "timed-out";
218
+ }>;
219
+ message: z.ZodOptional<z.ZodString>;
220
+ }, z.core.$strip>>>;
221
+ }, z.core.$strip>;
222
+ export type NestedStepTrace = z.infer<typeof NestedStepTraceSchema>;
139
223
  /** A step trace; the `else` steps that ran are one level of the same shape (the nesting is bounded at one). */
140
224
  export declare const AutomationStepTraceSchema: z.ZodObject<{
141
225
  path: z.ZodString;
@@ -165,11 +249,23 @@ export declare const AutomationStepTraceSchema: z.ZodObject<{
165
249
  outcome: z.ZodEnum<{
166
250
  empty: "empty";
167
251
  error: "error";
252
+ "failed-continued": "failed-continued";
168
253
  "not-run": "not-run";
169
254
  ok: "ok";
170
255
  skipped: "skipped";
256
+ "timed-out": "timed-out";
171
257
  }>;
172
258
  message: z.ZodOptional<z.ZodString>;
259
+ branch: z.ZodOptional<z.ZodString>;
260
+ branchChecks: z.ZodOptional<z.ZodArray<z.ZodObject<{
261
+ condition: z.ZodEnum<{
262
+ false: "false";
263
+ true: "true";
264
+ unknown: "unknown";
265
+ }>;
266
+ conditionReason: z.ZodOptional<z.ZodString>;
267
+ }, z.core.$strip>>>;
268
+ iterations: z.ZodOptional<z.ZodNumber>;
173
269
  else: z.ZodOptional<z.ZodArray<z.ZodObject<{
174
270
  path: z.ZodString;
175
271
  kind: z.ZodString;
@@ -198,15 +294,99 @@ export declare const AutomationStepTraceSchema: z.ZodObject<{
198
294
  outcome: z.ZodEnum<{
199
295
  empty: "empty";
200
296
  error: "error";
297
+ "failed-continued": "failed-continued";
201
298
  "not-run": "not-run";
202
299
  ok: "ok";
203
300
  skipped: "skipped";
301
+ "timed-out": "timed-out";
204
302
  }>;
205
303
  message: z.ZodOptional<z.ZodString>;
206
304
  }, z.core.$strip>>>;
305
+ steps: z.ZodOptional<z.ZodArray<z.ZodObject<{
306
+ path: z.ZodString;
307
+ kind: z.ZodString;
308
+ cap: z.ZodOptional<z.ZodString>;
309
+ method: z.ZodOptional<z.ZodString>;
310
+ actionId: z.ZodOptional<z.ZodString>;
311
+ deviceId: z.ZodOptional<z.ZodNumber>;
312
+ devices: z.ZodOptional<z.ZodArray<z.ZodObject<{
313
+ deviceId: z.ZodNumber;
314
+ outcome: z.ZodEnum<{
315
+ error: "error";
316
+ ok: "ok";
317
+ }>;
318
+ message: z.ZodOptional<z.ZodString>;
319
+ }, z.core.$strip>>>;
320
+ startedAt: z.ZodOptional<z.ZodNumber>;
321
+ endedAt: z.ZodOptional<z.ZodNumber>;
322
+ args: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodNull, z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>]>>>;
323
+ templates: z.ZodOptional<z.ZodArray<z.ZodString>>;
324
+ condition: z.ZodOptional<z.ZodEnum<{
325
+ false: "false";
326
+ true: "true";
327
+ unknown: "unknown";
328
+ }>>;
329
+ conditionReason: z.ZodOptional<z.ZodString>;
330
+ outcome: z.ZodEnum<{
331
+ empty: "empty";
332
+ error: "error";
333
+ "failed-continued": "failed-continued";
334
+ "not-run": "not-run";
335
+ ok: "ok";
336
+ skipped: "skipped";
337
+ "timed-out": "timed-out";
338
+ }>;
339
+ message: z.ZodOptional<z.ZodString>;
340
+ branch: z.ZodOptional<z.ZodString>;
341
+ branchChecks: z.ZodOptional<z.ZodArray<z.ZodObject<{
342
+ condition: z.ZodEnum<{
343
+ false: "false";
344
+ true: "true";
345
+ unknown: "unknown";
346
+ }>;
347
+ conditionReason: z.ZodOptional<z.ZodString>;
348
+ }, z.core.$strip>>>;
349
+ iterations: z.ZodOptional<z.ZodNumber>;
350
+ steps: z.ZodOptional<z.ZodArray<z.ZodObject<{
351
+ path: z.ZodString;
352
+ kind: z.ZodString;
353
+ cap: z.ZodOptional<z.ZodString>;
354
+ method: z.ZodOptional<z.ZodString>;
355
+ actionId: z.ZodOptional<z.ZodString>;
356
+ deviceId: z.ZodOptional<z.ZodNumber>;
357
+ devices: z.ZodOptional<z.ZodArray<z.ZodObject<{
358
+ deviceId: z.ZodNumber;
359
+ outcome: z.ZodEnum<{
360
+ error: "error";
361
+ ok: "ok";
362
+ }>;
363
+ message: z.ZodOptional<z.ZodString>;
364
+ }, z.core.$strip>>>;
365
+ startedAt: z.ZodOptional<z.ZodNumber>;
366
+ endedAt: z.ZodOptional<z.ZodNumber>;
367
+ args: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodNull, z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>]>>>;
368
+ templates: z.ZodOptional<z.ZodArray<z.ZodString>>;
369
+ condition: z.ZodOptional<z.ZodEnum<{
370
+ false: "false";
371
+ true: "true";
372
+ unknown: "unknown";
373
+ }>>;
374
+ conditionReason: z.ZodOptional<z.ZodString>;
375
+ outcome: z.ZodEnum<{
376
+ empty: "empty";
377
+ error: "error";
378
+ "failed-continued": "failed-continued";
379
+ "not-run": "not-run";
380
+ ok: "ok";
381
+ skipped: "skipped";
382
+ "timed-out": "timed-out";
383
+ }>;
384
+ message: z.ZodOptional<z.ZodString>;
385
+ }, z.core.$strip>>>;
386
+ }, z.core.$strip>>>;
207
387
  }, z.core.$strip>;
208
388
  export type AutomationStepTrace = z.infer<typeof AutomationStepTraceSchema>;
209
- export declare const AutomationRunTraceSchema: z.ZodObject<{
389
+ declare const runTraceObject: z.ZodObject<{
210
390
  runId: z.ZodString;
211
391
  startedAt: z.ZodNumber;
212
392
  endedAt: z.ZodNumber;
@@ -321,11 +501,23 @@ export declare const AutomationRunTraceSchema: z.ZodObject<{
321
501
  outcome: z.ZodEnum<{
322
502
  empty: "empty";
323
503
  error: "error";
504
+ "failed-continued": "failed-continued";
324
505
  "not-run": "not-run";
325
506
  ok: "ok";
326
507
  skipped: "skipped";
508
+ "timed-out": "timed-out";
327
509
  }>;
328
510
  message: z.ZodOptional<z.ZodString>;
511
+ branch: z.ZodOptional<z.ZodString>;
512
+ branchChecks: z.ZodOptional<z.ZodArray<z.ZodObject<{
513
+ condition: z.ZodEnum<{
514
+ false: "false";
515
+ true: "true";
516
+ unknown: "unknown";
517
+ }>;
518
+ conditionReason: z.ZodOptional<z.ZodString>;
519
+ }, z.core.$strip>>>;
520
+ iterations: z.ZodOptional<z.ZodNumber>;
329
521
  else: z.ZodOptional<z.ZodArray<z.ZodObject<{
330
522
  path: z.ZodString;
331
523
  kind: z.ZodString;
@@ -354,132 +546,15 @@ export declare const AutomationRunTraceSchema: z.ZodObject<{
354
546
  outcome: z.ZodEnum<{
355
547
  empty: "empty";
356
548
  error: "error";
549
+ "failed-continued": "failed-continued";
357
550
  "not-run": "not-run";
358
551
  ok: "ok";
359
552
  skipped: "skipped";
553
+ "timed-out": "timed-out";
360
554
  }>;
361
555
  message: z.ZodOptional<z.ZodString>;
362
556
  }, z.core.$strip>>>;
363
- }, z.core.$strip>>;
364
- outcome: z.ZodEnum<{
365
- aborted: "aborted";
366
- failed: "failed";
367
- ran: "ran";
368
- "skipped-conditions": "skipped-conditions";
369
- "skipped-cooldown": "skipped-cooldown";
370
- "skipped-overlap": "skipped-overlap";
371
- "skipped-trigger": "skipped-trigger";
372
- }>;
373
- repeat: z.ZodNumber;
374
- lastAt: z.ZodNumber;
375
- scheduler: z.ZodOptional<z.ZodEnum<{
376
- "condition-false": "condition-false";
377
- done: "done";
378
- failed: "failed";
379
- "gave-up": "gave-up";
380
- held: "held";
381
- inactive: "inactive";
382
- missed: "missed";
383
- overridden: "overridden";
384
- "suspended-manual": "suspended-manual";
385
- }>>;
386
- }, z.core.$strip>;
387
- export type AutomationRunTrace = z.infer<typeof AutomationRunTraceSchema>;
388
- /**
389
- * What the hub's `runs` ledger holds for one owner (`automation:<blockId>` or
390
- * `action:<actionId>`): the cooldown stamp and the trace ring.
391
- */
392
- export declare const AutomationStateDocSchema: z.ZodObject<{
393
- version: z.ZodLiteral<1>;
394
- lastRunStartedAt: z.ZodNullable<z.ZodNumber>;
395
- traces: z.ZodArray<z.ZodObject<{
396
- runId: z.ZodString;
397
- startedAt: z.ZodNumber;
398
- endedAt: z.ZodNumber;
399
- trigger: z.ZodObject<{
400
- kind: z.ZodString;
401
- path: z.ZodOptional<z.ZodString>;
402
- outcome: z.ZodEnum<{
403
- fail: "fail";
404
- pass: "pass";
405
- }>;
406
- reason: z.ZodString;
407
- vars: z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodNull, z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>]>>;
408
- hold: z.ZodOptional<z.ZodObject<{
409
- phase: z.ZodEnum<{
410
- cancelled: "cancelled";
411
- fired: "fired";
412
- pending: "pending";
413
- reseeded: "reseeded";
414
- }>;
415
- ms: z.ZodNumber;
416
- mode: z.ZodEnum<{
417
- held: "held";
418
- stable: "stable";
419
- }>;
420
- since: z.ZodOptional<z.ZodNumber>;
421
- deadline: z.ZodOptional<z.ZodNumber>;
422
- }, z.core.$strip>>;
423
- }, z.core.$strip>;
424
- conditions: z.ZodArray<z.ZodObject<{
425
- path: z.ZodString;
426
- kind: z.ZodEnum<{
427
- all: "all";
428
- any: "any";
429
- condition: "condition";
430
- detection: "detection";
431
- "device-becomes": "device-becomes";
432
- "device-event": "device-event";
433
- "device-is": "device-is";
434
- expression: "expression";
435
- interval: "interval";
436
- manual: "manual";
437
- not: "not";
438
- schedule: "schedule";
439
- stationary: "stationary";
440
- "stationary-present": "stationary-present";
441
- "time-is": "time-is";
442
- "triggered-by": "triggered-by";
443
- }>;
444
- outcome: z.ZodEnum<{
445
- fail: "fail";
446
- "not-evaluated": "not-evaluated";
447
- pass: "pass";
448
- }>;
449
- reason: z.ZodString;
450
- deviceId: z.ZodOptional<z.ZodNumber>;
451
- cap: z.ZodOptional<z.ZodString>;
452
- fieldPath: z.ZodOptional<z.ZodString>;
453
- operator: z.ZodOptional<z.ZodString>;
454
- expected: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodNull, z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>]>>;
455
- observed: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodNull, z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>]>>;
456
- }, z.core.$strip>>;
457
- verdict: z.ZodOptional<z.ZodObject<{
458
- mode: z.ZodDiscriminatedUnion<[z.ZodObject<{
459
- mode: z.ZodLiteral<"single">;
460
- }, z.core.$strip>, z.ZodObject<{
461
- mode: z.ZodLiteral<"restart">;
462
- }, z.core.$strip>, z.ZodObject<{
463
- mode: z.ZodLiteral<"queued">;
464
- max: z.ZodNumber;
465
- }, z.core.$strip>, z.ZodObject<{
466
- mode: z.ZodLiteral<"parallel">;
467
- max: z.ZodNumber;
468
- }, z.core.$strip>, z.ZodObject<{
469
- mode: z.ZodLiteral<"cooldown">;
470
- minutes: z.ZodNumber;
471
- }, z.core.$strip>], "mode">;
472
- decision: z.ZodEnum<{
473
- bypass: "bypass";
474
- cooldown: "cooldown";
475
- drop: "drop";
476
- queued: "queued";
477
- restart: "restart";
478
- run: "run";
479
- }>;
480
- reason: z.ZodString;
481
- }, z.core.$strip>>;
482
- steps: z.ZodArray<z.ZodObject<{
557
+ steps: z.ZodOptional<z.ZodArray<z.ZodObject<{
483
558
  path: z.ZodString;
484
559
  kind: z.ZodString;
485
560
  cap: z.ZodOptional<z.ZodString>;
@@ -507,12 +582,24 @@ export declare const AutomationStateDocSchema: z.ZodObject<{
507
582
  outcome: z.ZodEnum<{
508
583
  empty: "empty";
509
584
  error: "error";
585
+ "failed-continued": "failed-continued";
510
586
  "not-run": "not-run";
511
587
  ok: "ok";
512
588
  skipped: "skipped";
589
+ "timed-out": "timed-out";
513
590
  }>;
514
591
  message: z.ZodOptional<z.ZodString>;
515
- else: z.ZodOptional<z.ZodArray<z.ZodObject<{
592
+ branch: z.ZodOptional<z.ZodString>;
593
+ branchChecks: z.ZodOptional<z.ZodArray<z.ZodObject<{
594
+ condition: z.ZodEnum<{
595
+ false: "false";
596
+ true: "true";
597
+ unknown: "unknown";
598
+ }>;
599
+ conditionReason: z.ZodOptional<z.ZodString>;
600
+ }, z.core.$strip>>>;
601
+ iterations: z.ZodOptional<z.ZodNumber>;
602
+ steps: z.ZodOptional<z.ZodArray<z.ZodObject<{
516
603
  path: z.ZodString;
517
604
  kind: z.ZodString;
518
605
  cap: z.ZodOptional<z.ZodString>;
@@ -540,36 +627,55 @@ export declare const AutomationStateDocSchema: z.ZodObject<{
540
627
  outcome: z.ZodEnum<{
541
628
  empty: "empty";
542
629
  error: "error";
630
+ "failed-continued": "failed-continued";
543
631
  "not-run": "not-run";
544
632
  ok: "ok";
545
633
  skipped: "skipped";
634
+ "timed-out": "timed-out";
546
635
  }>;
547
636
  message: z.ZodOptional<z.ZodString>;
548
637
  }, z.core.$strip>>>;
549
- }, z.core.$strip>>;
550
- outcome: z.ZodEnum<{
551
- aborted: "aborted";
552
- failed: "failed";
553
- ran: "ran";
554
- "skipped-conditions": "skipped-conditions";
555
- "skipped-cooldown": "skipped-cooldown";
556
- "skipped-overlap": "skipped-overlap";
557
- "skipped-trigger": "skipped-trigger";
558
- }>;
559
- repeat: z.ZodNumber;
560
- lastAt: z.ZodNumber;
561
- scheduler: z.ZodOptional<z.ZodEnum<{
562
- "condition-false": "condition-false";
563
- done: "done";
564
- failed: "failed";
565
- "gave-up": "gave-up";
566
- held: "held";
567
- inactive: "inactive";
568
- missed: "missed";
569
- overridden: "overridden";
570
- "suspended-manual": "suspended-manual";
571
- }>>;
638
+ }, z.core.$strip>>>;
572
639
  }, z.core.$strip>>;
640
+ outcome: z.ZodEnum<{
641
+ aborted: "aborted";
642
+ failed: "failed";
643
+ ran: "ran";
644
+ "skipped-conditions": "skipped-conditions";
645
+ "skipped-cooldown": "skipped-cooldown";
646
+ "skipped-overlap": "skipped-overlap";
647
+ "skipped-trigger": "skipped-trigger";
648
+ }>;
649
+ repeat: z.ZodNumber;
650
+ lastAt: z.ZodNumber;
651
+ scheduler: z.ZodOptional<z.ZodEnum<{
652
+ "condition-false": "condition-false";
653
+ done: "done";
654
+ failed: "failed";
655
+ "gave-up": "gave-up";
656
+ held: "held";
657
+ inactive: "inactive";
658
+ missed: "missed";
659
+ overridden: "overridden";
660
+ "suspended-manual": "suspended-manual";
661
+ }>>;
662
+ }, z.core.$strip>;
663
+ /**
664
+ * Declared as an interface so it is printed by NAME: a capability that embeds
665
+ * the trace would otherwise inline every nested row into its own type, past
666
+ * what the compiler can print (TS7056).
667
+ */
668
+ export interface AutomationRunTrace extends z.infer<typeof runTraceObject> {
669
+ }
670
+ export declare const AutomationRunTraceSchema: z.ZodType<AutomationRunTrace>;
671
+ /**
672
+ * What the hub's `runs` ledger holds for one owner (`automation:<blockId>` or
673
+ * `action:<actionId>`): the cooldown stamp and the trace ring.
674
+ */
675
+ export declare const AutomationStateDocSchema: z.ZodObject<{
676
+ version: z.ZodLiteral<1>;
677
+ lastRunStartedAt: z.ZodNullable<z.ZodNumber>;
678
+ traces: z.ZodArray<z.ZodType<AutomationRunTrace, unknown, z.core.$ZodTypeInternals<AutomationRunTrace, unknown>>>;
573
679
  }, z.core.$strip>;
574
680
  export type AutomationStateDoc = z.infer<typeof AutomationStateDocSchema>;
575
681
  /** The state of an owner that never reported. */
@@ -615,3 +721,4 @@ export declare function buildStepArgsTrace(args: Readonly<Record<string, unknown
615
721
  * bookkeeping keys `kind`, `at` and `leaf` (the fired leaf's path, which moves to `path`).
616
722
  */
617
723
  export declare function buildTriggerTrace(trigger: Readonly<Record<string, unknown>>, outcome: 'pass' | 'fail', reason: string): AutomationTriggerTrace;
724
+ export {};
@@ -0,0 +1,32 @@
1
+ /**
2
+ * The loop of a `wait-until` step (#500): read the condition, and while it is
3
+ * not true wait for the next wake (a device report, the reconcile tick, a
4
+ * restart) and read again, until the timeout.
5
+ *
6
+ * `unknown` is never "met" (D49): a condition that cannot be read keeps the
7
+ * run waiting and, at the deadline, is what the timeout reports.
8
+ */
9
+ import type { StepConditionVerdict } from './step-condition.js';
10
+ export interface WaitUntilInput {
11
+ /** Read the condition NOW. A read that throws counts as `unknown`. */
12
+ readonly read: () => Promise<StepConditionVerdict>;
13
+ readonly timeoutMs: number;
14
+ readonly now: () => number;
15
+ /** Resolve at the next reason to read again, and no later than `ms` from now. */
16
+ readonly nextWake: (ms: number) => Promise<void>;
17
+ readonly isAborted: () => boolean;
18
+ }
19
+ export type WaitUntilResult = {
20
+ readonly result: 'met';
21
+ readonly waitedMs: number;
22
+ } | {
23
+ readonly result: 'timed-out';
24
+ readonly waitedMs: number;
25
+ readonly lastReason: string;
26
+ } | {
27
+ readonly result: 'aborted';
28
+ readonly waitedMs: number;
29
+ };
30
+ export declare function waitUntil(input: WaitUntilInput): Promise<WaitUntilResult>;
31
+ /** What the run trace says of a wait that ran out. */
32
+ export declare function waitTimedOutMessage(timeoutS: number, lastReason: string): string;
@@ -6,7 +6,7 @@
6
6
  * the operator believes is working. Pure: the site reading is handed in.
7
7
  */
8
8
  import { type SiteReading, type TimeSpecRefusal } from '../time/time-spec.js';
9
- import type { AutomationRecipe } from './recipe.js';
9
+ import { type AutomationRecipe } from './recipe.js';
10
10
  import { type AutomationWhen } from './when.js';
11
11
  export interface WhenSiteIssue {
12
12
  /** `when.1.between.from` — the end of the window that cannot be placed. */
@@ -34,7 +34,7 @@ export declare const accessoriesCapability: {
34
34
  readonly scope: 'device';
35
35
  readonly deviceNative: true;
36
36
  readonly mode: 'singleton';
37
- readonly deviceTypes: readonly [DeviceType.Camera, DeviceType.Switch, DeviceType.Light, DeviceType.Sensor, DeviceType.Thermostat, DeviceType.Cover, DeviceType.Lock, DeviceType.Fan, DeviceType.MediaPlayer, DeviceType.AlarmPanel, DeviceType.Generic];
37
+ readonly deviceTypes: readonly [DeviceType.Camera, DeviceType.Switch, DeviceType.Light, DeviceType.Sensor, DeviceType.Climate, DeviceType.Cover, DeviceType.Lock, DeviceType.Fan, DeviceType.MediaPlayer, DeviceType.AlarmPanel, DeviceType.Generic];
38
38
  readonly methods: {
39
39
  /**
40
40
  * Toggle the UI-visibility of a single accessory child. Hidden