@camstack/types 1.2.591 → 1.2.592

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.
@@ -8052,6 +8052,10 @@ var CAP_VOCABULARY = {
8052
8052
  it: "Commuta {device}"
8053
8053
  },
8054
8054
  icon: "toggle-right",
8055
+ sideEffects: [{
8056
+ field: "on",
8057
+ negate: true
8058
+ }],
8055
8059
  offeredWhen: {
8056
8060
  method: "getOptions",
8057
8061
  field: "supportsSetState"
@@ -9166,7 +9170,15 @@ var CAP_VOCABULARY = {
9166
9170
  effect: {
9167
9171
  field: "state",
9168
9172
  value: "locked"
9169
- }
9173
+ },
9174
+ hold: { effects: [{
9175
+ field: "state",
9176
+ value: "locking",
9177
+ when: {
9178
+ field: "state",
9179
+ notIn: ["locked"]
9180
+ }
9181
+ }] }
9170
9182
  },
9171
9183
  {
9172
9184
  id: "lock.unlock",
@@ -9195,7 +9207,15 @@ var CAP_VOCABULARY = {
9195
9207
  effect: {
9196
9208
  field: "state",
9197
9209
  value: "unlocked"
9198
- }
9210
+ },
9211
+ hold: { effects: [{
9212
+ field: "state",
9213
+ value: "unlocking",
9214
+ when: {
9215
+ field: "state",
9216
+ notIn: ["unlocked"]
9217
+ }
9218
+ }] }
9199
9219
  },
9200
9220
  {
9201
9221
  id: "lock.open",
@@ -9509,6 +9529,14 @@ var CAP_VOCABULARY = {
9509
9529
  step: .5,
9510
9530
  unit: "°C"
9511
9531
  }
9532
+ }],
9533
+ effect: {
9534
+ field: "targetLow",
9535
+ fromArg: "targetLow"
9536
+ },
9537
+ sideEffects: [{
9538
+ field: "targetHigh",
9539
+ fromArg: "targetHigh"
9512
9540
  }]
9513
9541
  },
9514
9542
  {
@@ -9565,7 +9593,11 @@ var CAP_VOCABULARY = {
9565
9593
  from: "status",
9566
9594
  field: "availableFanModes"
9567
9595
  }
9568
- }]
9596
+ }],
9597
+ effect: {
9598
+ field: "fanMode",
9599
+ fromArg: "fanMode"
9600
+ }
9569
9601
  },
9570
9602
  {
9571
9603
  id: "climate.preset",
@@ -9590,7 +9622,11 @@ var CAP_VOCABULARY = {
9590
9622
  from: "status",
9591
9623
  field: "availablePresets"
9592
9624
  }
9593
- }]
9625
+ }],
9626
+ effect: {
9627
+ field: "preset",
9628
+ fromArg: "preset"
9629
+ }
9594
9630
  },
9595
9631
  {
9596
9632
  id: "climate.swingVerticalOn",
@@ -9823,7 +9859,15 @@ var CAP_VOCABULARY = {
9823
9859
  effect: {
9824
9860
  field: "speed",
9825
9861
  value: 100
9826
- }
9862
+ },
9863
+ sideEffects: [{
9864
+ field: "preset",
9865
+ value: "",
9866
+ when: {
9867
+ field: "preset",
9868
+ notIn: [""]
9869
+ }
9870
+ }]
9827
9871
  },
9828
9872
  {
9829
9873
  id: "fan.speed",
@@ -9854,7 +9898,15 @@ var CAP_VOCABULARY = {
9854
9898
  effect: {
9855
9899
  field: "speed",
9856
9900
  fromArg: "speed"
9857
- }
9901
+ },
9902
+ sideEffects: [{
9903
+ field: "preset",
9904
+ value: "",
9905
+ when: {
9906
+ field: "preset",
9907
+ notIn: [""]
9908
+ }
9909
+ }]
9858
9910
  },
9859
9911
  {
9860
9912
  id: "fan.preset",
@@ -9879,7 +9931,11 @@ var CAP_VOCABULARY = {
9879
9931
  from: "status",
9880
9932
  field: "availablePresets"
9881
9933
  }
9882
- }]
9934
+ }],
9935
+ effect: {
9936
+ field: "preset",
9937
+ fromArg: "preset"
9938
+ }
9883
9939
  },
9884
9940
  {
9885
9941
  id: "fan.forward",
@@ -10424,7 +10480,15 @@ var CAP_VOCABULARY = {
10424
10480
  effect: {
10425
10481
  field: "state",
10426
10482
  value: "disarmed"
10427
- }
10483
+ },
10484
+ hold: { effects: [{
10485
+ field: "state",
10486
+ value: "disarming",
10487
+ when: {
10488
+ field: "state",
10489
+ notIn: ["disarmed"]
10490
+ }
10491
+ }] }
10428
10492
  },
10429
10493
  {
10430
10494
  id: "alarm.arm.home",
@@ -10454,7 +10518,15 @@ var CAP_VOCABULARY = {
10454
10518
  effect: {
10455
10519
  field: "state",
10456
10520
  value: "armed_home"
10457
- }
10521
+ },
10522
+ hold: { effects: [{
10523
+ field: "state",
10524
+ value: "arming",
10525
+ when: {
10526
+ field: "state",
10527
+ notIn: ["armed_home"]
10528
+ }
10529
+ }] }
10458
10530
  },
10459
10531
  {
10460
10532
  id: "alarm.arm.away",
@@ -10484,7 +10556,15 @@ var CAP_VOCABULARY = {
10484
10556
  effect: {
10485
10557
  field: "state",
10486
10558
  value: "armed_away"
10487
- }
10559
+ },
10560
+ hold: { effects: [{
10561
+ field: "state",
10562
+ value: "arming",
10563
+ when: {
10564
+ field: "state",
10565
+ notIn: ["armed_away"]
10566
+ }
10567
+ }] }
10488
10568
  },
10489
10569
  {
10490
10570
  id: "alarm.arm.night",
@@ -10514,7 +10594,15 @@ var CAP_VOCABULARY = {
10514
10594
  effect: {
10515
10595
  field: "state",
10516
10596
  value: "armed_night"
10517
- }
10597
+ },
10598
+ hold: { effects: [{
10599
+ field: "state",
10600
+ value: "arming",
10601
+ when: {
10602
+ field: "state",
10603
+ notIn: ["armed_night"]
10604
+ }
10605
+ }] }
10518
10606
  },
10519
10607
  {
10520
10608
  id: "alarm.arm.vacation",
@@ -10544,7 +10632,15 @@ var CAP_VOCABULARY = {
10544
10632
  effect: {
10545
10633
  field: "state",
10546
10634
  value: "armed_vacation"
10547
- }
10635
+ },
10636
+ hold: { effects: [{
10637
+ field: "state",
10638
+ value: "arming",
10639
+ when: {
10640
+ field: "state",
10641
+ notIn: ["armed_vacation"]
10642
+ }
10643
+ }] }
10548
10644
  },
10549
10645
  {
10550
10646
  id: "alarm.arm.custom_bypass",
@@ -10574,7 +10670,15 @@ var CAP_VOCABULARY = {
10574
10670
  effect: {
10575
10671
  field: "state",
10576
10672
  value: "armed_custom_bypass"
10577
- }
10673
+ },
10674
+ hold: { effects: [{
10675
+ field: "state",
10676
+ value: "arming",
10677
+ when: {
10678
+ field: "state",
10679
+ notIn: ["armed_custom_bypass"]
10680
+ }
10681
+ }] }
10578
10682
  }
10579
10683
  ],
10580
10684
  state: [{
@@ -11716,7 +11820,14 @@ var CAP_VOCABULARY = {
11716
11820
  quantity: "mass"
11717
11821
  },
11718
11822
  optional: true
11719
- }]
11823
+ }],
11824
+ hold: {
11825
+ effects: [{
11826
+ field: "feeding",
11827
+ value: true
11828
+ }],
11829
+ holdMs: 1e4
11830
+ }
11720
11831
  },
11721
11832
  {
11722
11833
  id: "petFeeder.feedHoppers",
@@ -11760,7 +11871,14 @@ var CAP_VOCABULARY = {
11760
11871
  quantity: "mass"
11761
11872
  },
11762
11873
  optional: true
11763
- }]
11874
+ }],
11875
+ hold: {
11876
+ effects: [{
11877
+ field: "feeding",
11878
+ value: true
11879
+ }],
11880
+ holdMs: 1e4
11881
+ }
11764
11882
  },
11765
11883
  {
11766
11884
  id: "petFeeder.cancelFeed",
@@ -11851,7 +11969,11 @@ var CAP_VOCABULARY = {
11851
11969
  it: "Attiva il blocco bambini di {device}"
11852
11970
  },
11853
11971
  icon: "lock",
11854
- args: { on: true }
11972
+ args: { on: true },
11973
+ effect: {
11974
+ field: "childLock",
11975
+ value: true
11976
+ }
11855
11977
  },
11856
11978
  {
11857
11979
  id: "petFeeder.childLockOff",
@@ -11865,7 +11987,11 @@ var CAP_VOCABULARY = {
11865
11987
  it: "Disattiva il blocco bambini di {device}"
11866
11988
  },
11867
11989
  icon: "lock-open",
11868
- args: { on: false }
11990
+ args: { on: false },
11991
+ effect: {
11992
+ field: "childLock",
11993
+ value: false
11994
+ }
11869
11995
  },
11870
11996
  {
11871
11997
  id: "petFeeder.lightOn",
@@ -11879,7 +12005,11 @@ var CAP_VOCABULARY = {
11879
12005
  it: "Accendi la spia di {device}"
11880
12006
  },
11881
12007
  icon: "lightbulb",
11882
- args: { on: true }
12008
+ args: { on: true },
12009
+ effect: {
12010
+ field: "indicatorLight",
12011
+ value: true
12012
+ }
11883
12013
  },
11884
12014
  {
11885
12015
  id: "petFeeder.lightOff",
@@ -11893,7 +12023,11 @@ var CAP_VOCABULARY = {
11893
12023
  it: "Spegni la spia di {device}"
11894
12024
  },
11895
12025
  icon: "lightbulb-off",
11896
- args: { on: false }
12026
+ args: { on: false },
12027
+ effect: {
12028
+ field: "indicatorLight",
12029
+ value: false
12030
+ }
11897
12031
  },
11898
12032
  {
11899
12033
  id: "petFeeder.feedSoundOn",
@@ -11907,7 +12041,11 @@ var CAP_VOCABULARY = {
11907
12041
  it: "Attiva il suono di erogazione di {device}"
11908
12042
  },
11909
12043
  icon: "volume-2",
11910
- args: { on: true }
12044
+ args: { on: true },
12045
+ effect: {
12046
+ field: "feedSound",
12047
+ value: true
12048
+ }
11911
12049
  },
11912
12050
  {
11913
12051
  id: "petFeeder.feedSoundOff",
@@ -11921,7 +12059,11 @@ var CAP_VOCABULARY = {
11921
12059
  it: "Disattiva il suono di erogazione di {device}"
11922
12060
  },
11923
12061
  icon: "volume-x",
11924
- args: { on: false }
12062
+ args: { on: false },
12063
+ effect: {
12064
+ field: "feedSound",
12065
+ value: false
12066
+ }
11925
12067
  },
11926
12068
  {
11927
12069
  id: "petFeeder.volume",
@@ -11946,7 +12088,11 @@ var CAP_VOCABULARY = {
11946
12088
  min: 0,
11947
12089
  step: 1
11948
12090
  }
11949
- }]
12091
+ }],
12092
+ effect: {
12093
+ field: "volume",
12094
+ fromArg: "level"
12095
+ }
11950
12096
  }
11951
12097
  ],
11952
12098
  state: [
@@ -12018,7 +12164,11 @@ var CAP_VOCABULARY = {
12018
12164
  it: "Avvia la pompa di {device}"
12019
12165
  },
12020
12166
  icon: "play",
12021
- args: { on: true }
12167
+ args: { on: true },
12168
+ effect: {
12169
+ field: "pumpRunning",
12170
+ value: true
12171
+ }
12022
12172
  }, {
12023
12173
  id: "petFountain.pumpOff",
12024
12174
  method: "setPump",
@@ -12031,7 +12181,11 @@ var CAP_VOCABULARY = {
12031
12181
  it: "Ferma la pompa di {device}"
12032
12182
  },
12033
12183
  icon: "square",
12034
- args: { on: false }
12184
+ args: { on: false },
12185
+ effect: {
12186
+ field: "pumpRunning",
12187
+ value: false
12188
+ }
12035
12189
  }],
12036
12190
  state: [{
12037
12191
  kind: "boolean",
@@ -12083,7 +12237,11 @@ var CAP_VOCABULARY = {
12083
12237
  it: "Fai lavorare la pompa di {device} a ciclo acceso/spento"
12084
12238
  },
12085
12239
  icon: "timer",
12086
- args: { on: true }
12240
+ args: { on: true },
12241
+ effect: {
12242
+ field: "enabled",
12243
+ value: true
12244
+ }
12087
12245
  },
12088
12246
  {
12089
12247
  id: "pumpCycle.off",
@@ -12097,7 +12255,11 @@ var CAP_VOCABULARY = {
12097
12255
  it: "Fai lavorare la pompa di {device} in continuo"
12098
12256
  },
12099
12257
  icon: "timer-off",
12100
- args: { on: false }
12258
+ args: { on: false },
12259
+ effect: {
12260
+ field: "enabled",
12261
+ value: false
12262
+ }
12101
12263
  },
12102
12264
  {
12103
12265
  id: "pumpCycle.onMinutes",
@@ -12123,7 +12285,12 @@ var CAP_VOCABULARY = {
12123
12285
  step: 1,
12124
12286
  unit: "min"
12125
12287
  }
12126
- }]
12288
+ }],
12289
+ effect: {
12290
+ field: "onTime",
12291
+ fromArg: "minutes",
12292
+ scale: 60
12293
+ }
12127
12294
  },
12128
12295
  {
12129
12296
  id: "pumpCycle.offMinutes",
@@ -12149,7 +12316,12 @@ var CAP_VOCABULARY = {
12149
12316
  step: 1,
12150
12317
  unit: "min"
12151
12318
  }
12152
- }]
12319
+ }],
12320
+ effect: {
12321
+ field: "offTime",
12322
+ fromArg: "minutes",
12323
+ scale: 60
12324
+ }
12153
12325
  }
12154
12326
  ],
12155
12327
  state: [{
@@ -12266,7 +12438,11 @@ var CAP_VOCABULARY = {
12266
12438
  en: "Play on {device}",
12267
12439
  it: "Avvia la riproduzione su {device}"
12268
12440
  },
12269
- icon: "play"
12441
+ icon: "play",
12442
+ effect: {
12443
+ field: "state",
12444
+ value: "playing"
12445
+ }
12270
12446
  },
12271
12447
  {
12272
12448
  id: "media.pause",
@@ -12279,7 +12455,11 @@ var CAP_VOCABULARY = {
12279
12455
  en: "Pause {device}",
12280
12456
  it: "Metti in pausa {device}"
12281
12457
  },
12282
- icon: "pause"
12458
+ icon: "pause",
12459
+ effect: {
12460
+ field: "state",
12461
+ value: "paused"
12462
+ }
12283
12463
  },
12284
12464
  {
12285
12465
  id: "media.stop",
@@ -12345,7 +12525,11 @@ var CAP_VOCABULARY = {
12345
12525
  step: 1,
12346
12526
  unit: "%"
12347
12527
  }
12348
- }]
12528
+ }],
12529
+ effect: {
12530
+ field: "volumeLevel",
12531
+ fromArg: "volumeLevel"
12532
+ }
12349
12533
  },
12350
12534
  {
12351
12535
  id: "media.mute",
@@ -12359,7 +12543,11 @@ var CAP_VOCABULARY = {
12359
12543
  it: "Silenzia {device}"
12360
12544
  },
12361
12545
  icon: "volume-x",
12362
- args: { muted: true }
12546
+ args: { muted: true },
12547
+ effect: {
12548
+ field: "isMuted",
12549
+ value: true
12550
+ }
12363
12551
  },
12364
12552
  {
12365
12553
  id: "media.unmute",
@@ -12373,7 +12561,11 @@ var CAP_VOCABULARY = {
12373
12561
  it: "Riattiva l’audio di {device}"
12374
12562
  },
12375
12563
  icon: "volume-2",
12376
- args: { muted: false }
12564
+ args: { muted: false },
12565
+ effect: {
12566
+ field: "isMuted",
12567
+ value: false
12568
+ }
12377
12569
  },
12378
12570
  {
12379
12571
  id: "media.shuffleOn",
@@ -12387,7 +12579,11 @@ var CAP_VOCABULARY = {
12387
12579
  it: "Attiva la riproduzione casuale su {device}"
12388
12580
  },
12389
12581
  icon: "shuffle",
12390
- args: { shuffle: true }
12582
+ args: { shuffle: true },
12583
+ effect: {
12584
+ field: "shuffle",
12585
+ value: true
12586
+ }
12391
12587
  },
12392
12588
  {
12393
12589
  id: "media.shuffleOff",
@@ -12401,7 +12597,11 @@ var CAP_VOCABULARY = {
12401
12597
  it: "Disattiva la riproduzione casuale su {device}"
12402
12598
  },
12403
12599
  icon: "shuffle",
12404
- args: { shuffle: false }
12600
+ args: { shuffle: false },
12601
+ effect: {
12602
+ field: "shuffle",
12603
+ value: false
12604
+ }
12405
12605
  },
12406
12606
  {
12407
12607
  id: "media.repeat",
@@ -12447,7 +12647,11 @@ var CAP_VOCABULARY = {
12447
12647
  }
12448
12648
  ]
12449
12649
  }
12450
- }]
12650
+ }],
12651
+ effect: {
12652
+ field: "repeat",
12653
+ fromArg: "repeat"
12654
+ }
12451
12655
  },
12452
12656
  {
12453
12657
  id: "media.source",
@@ -12472,7 +12676,11 @@ var CAP_VOCABULARY = {
12472
12676
  from: "status",
12473
12677
  field: "availableSources"
12474
12678
  }
12475
- }]
12679
+ }],
12680
+ effect: {
12681
+ field: "source",
12682
+ fromArg: "source"
12683
+ }
12476
12684
  },
12477
12685
  {
12478
12686
  id: "media.seek",
@@ -13012,7 +13220,14 @@ var CAP_VOCABULARY = {
13012
13220
  en: "Run {device}",
13013
13221
  it: "Esegui {device}"
13014
13222
  },
13015
- icon: "scroll-text"
13223
+ icon: "scroll-text",
13224
+ hold: {
13225
+ effects: [{
13226
+ field: "isRunning",
13227
+ value: true
13228
+ }],
13229
+ holdMs: 1e4
13230
+ }
13016
13231
  }, {
13017
13232
  id: "script.stop",
13018
13233
  method: "stop",
@@ -13024,7 +13239,11 @@ var CAP_VOCABULARY = {
13024
13239
  en: "Stop {device}",
13025
13240
  it: "Ferma {device}"
13026
13241
  },
13027
- icon: "square"
13242
+ icon: "square",
13243
+ effect: {
13244
+ field: "isRunning",
13245
+ value: false
13246
+ }
13028
13247
  }],
13029
13248
  state: [{
13030
13249
  kind: "boolean",
@@ -13062,7 +13281,11 @@ var CAP_VOCABULARY = {
13062
13281
  en: "Enable {device}",
13063
13282
  it: "Abilita {device}"
13064
13283
  },
13065
- icon: "toggle-right"
13284
+ icon: "toggle-right",
13285
+ effect: {
13286
+ field: "enabled",
13287
+ value: true
13288
+ }
13066
13289
  },
13067
13290
  {
13068
13291
  id: "haAutomation.disable",
@@ -13075,7 +13298,11 @@ var CAP_VOCABULARY = {
13075
13298
  en: "Disable {device}",
13076
13299
  it: "Disabilita {device}"
13077
13300
  },
13078
- icon: "toggle-left"
13301
+ icon: "toggle-left",
13302
+ effect: {
13303
+ field: "enabled",
13304
+ value: false
13305
+ }
13079
13306
  },
13080
13307
  {
13081
13308
  id: "haAutomation.trigger",
@@ -17466,7 +17693,12 @@ function actionEffect(actionId, args) {
17466
17693
  value: effect.value
17467
17694
  };
17468
17695
  const raw = args?.[effect.fromArg];
17469
- if (typeof raw === "string" || typeof raw === "number" || typeof raw === "boolean") return {
17696
+ if (typeof raw === "number") return {
17697
+ cap: found.cap,
17698
+ field: effect.field,
17699
+ value: raw * (effect.scale ?? 1)
17700
+ };
17701
+ if (typeof raw === "string" || typeof raw === "boolean") return {
17470
17702
  cap: found.cap,
17471
17703
  field: effect.field,
17472
17704
  value: raw
@@ -20674,7 +20906,10 @@ function buildAuditedFields() {
20674
20906
  set.add(field);
20675
20907
  byCap.set(cap, set);
20676
20908
  };
20677
- for (const { cap, action } of allVocabActions()) if (action.effect !== void 0) add(cap, action.effect.field);
20909
+ for (const { cap, action } of allVocabActions()) {
20910
+ if (action.effect !== void 0) add(cap, action.effect.field);
20911
+ for (const side of action.sideEffects ?? []) add(cap, side.field);
20912
+ }
20678
20913
  for (const [cap, entry] of Object.entries(CAP_VOCABULARY_BY_NAME)) {
20679
20914
  if (entry.scope !== "device") continue;
20680
20915
  for (const trigger of entry.state ?? []) if (trigger.kind === "boolean" || trigger.kind === "enum") add(cap, trigger.field);
@@ -20704,6 +20939,113 @@ function auditedFields(cap) {
20704
20939
  fieldsByCap ??= buildAuditedFields();
20705
20940
  return fieldsByCap.get(cap) ?? NO_FIELDS;
20706
20941
  }
20942
+ /** Does `slice` meet `when`? A field the slice lacks is in no list. */
20943
+ function effectConditionHolds(when, slice) {
20944
+ if (when === void 0) return true;
20945
+ const raw = slice?.[when.field];
20946
+ const value = typeof raw === "string" || typeof raw === "number" || typeof raw === "boolean" ? raw : void 0;
20947
+ if ("in" in when) return value !== void 0 && when.in.includes(value);
20948
+ return value === void 0 || !when.notIn.includes(value);
20949
+ }
20950
+ /** The step of the number open arg `key`, when the action offers one. */
20951
+ function stepOf(openArgs, key) {
20952
+ const offer = openArgs?.find((a) => a.key === key)?.offer;
20953
+ return offer?.kind === "number" && offer.step !== void 0 && offer.step > 0 ? offer.step : void 0;
20954
+ }
20955
+ /**
20956
+ * One side effect resolved against the args and the slice the command acts
20957
+ * on: `null` when the arg carrying its value is missing, or a `negate` names a
20958
+ * field the slice holds no boolean in. `openArgs` lends a copied number its
20959
+ * step as the tolerance.
20960
+ */
20961
+ function resolveSideEffect(side, args, shown, openArgs) {
20962
+ if ("value" in side) return {
20963
+ field: side.field,
20964
+ value: side.value
20965
+ };
20966
+ if ("negate" in side) {
20967
+ const raw = shown?.[side.field];
20968
+ return typeof raw === "boolean" ? {
20969
+ field: side.field,
20970
+ value: !raw
20971
+ } : null;
20972
+ }
20973
+ const raw = args?.[side.fromArg];
20974
+ if (typeof raw === "string" || typeof raw === "boolean") return {
20975
+ field: side.field,
20976
+ value: raw
20977
+ };
20978
+ if (typeof raw === "number") {
20979
+ const scale = side.scale ?? 1;
20980
+ const step = stepOf(openArgs, side.fromArg);
20981
+ return step === void 0 ? {
20982
+ field: side.field,
20983
+ value: raw * scale
20984
+ } : {
20985
+ field: side.field,
20986
+ value: raw * scale,
20987
+ tolerance: step * scale
20988
+ };
20989
+ }
20990
+ return null;
20991
+ }
20992
+ /**
20993
+ * The hold limit the vocabulary declares for `cap.method(args)` (its action's
20994
+ * `hold.holdMs`), or `undefined` for the default.
20995
+ */
20996
+ function commandHoldMs(cap, method, args) {
20997
+ return holdFor(cap, method, args)?.holdMs;
20998
+ }
20999
+ /**
21000
+ * The hold the vocabulary declares for `cap.method(args)`: the matched
21001
+ * action's, or — when several actions share the method and the args cannot
21002
+ * tell them apart (`petFeeder.feed` / `feedHoppers`) — the one they all
21003
+ * declare alike. Different holds on such actions resolve to none.
21004
+ */
21005
+ function holdFor(cap, method, args) {
21006
+ const actionId = vocabActionIdFor(cap, method, args);
21007
+ if (actionId !== void 0) return findVocabAction(actionId)?.action.hold;
21008
+ const holds = allVocabActions().filter(({ cap: c, action }) => c === cap && action.method === method).map(({ action }) => action.hold);
21009
+ const first = holds[0];
21010
+ if (first === void 0) return void 0;
21011
+ const key = JSON.stringify(first);
21012
+ return holds.every((h) => JSON.stringify(h) === key) ? first : void 0;
21013
+ }
21014
+ /**
21015
+ * EVERY state the command `cap.method(args)` leads to (D1061): its `effect`
21016
+ * first, then each side effect whose condition holds on `current` (the cap's
21017
+ * slice the device reported when the command arrived). Empty when it leads to
21018
+ * none. One field is named once — the first entry for it wins. A `negate`
21019
+ * side effect flips what `shown` (the slice the person saw, held values
21020
+ * included) holds, so a second toggle before the first is confirmed undoes it.
21021
+ * An action that declares `hold.effects` is held as THOSE instead (a lock
21022
+ * holds `locking`, not `locked`).
21023
+ */
21024
+ function commandEffects(cap, method, args, current, shown = current) {
21025
+ const out = [];
21026
+ const hold = holdFor(cap, method, args);
21027
+ if (hold?.effects !== void 0) {
21028
+ for (const entry of hold.effects) {
21029
+ if (!effectConditionHolds(entry.when, current)) continue;
21030
+ const resolved = resolveSideEffect(entry, args, shown);
21031
+ if (resolved !== null && !out.some((e) => e.field === resolved.field)) out.push(resolved);
21032
+ }
21033
+ return out;
21034
+ }
21035
+ const actionId = vocabActionIdFor(cap, method, args);
21036
+ if (actionId === void 0) return [];
21037
+ const action = findVocabAction(actionId)?.action;
21038
+ if (action?.effect !== void 0) {
21039
+ const primary = resolveSideEffect(action.effect, args, shown, action.openArgs);
21040
+ if (primary !== null) out.push(primary);
21041
+ }
21042
+ for (const side of action?.sideEffects ?? []) {
21043
+ if (!effectConditionHolds(side.when, current)) continue;
21044
+ const resolved = resolveSideEffect(side, args, shown, action?.openArgs);
21045
+ if (resolved !== null && !out.some((e) => e.field === resolved.field)) out.push(resolved);
21046
+ }
21047
+ return out;
21048
+ }
20707
21049
  //#endregion
20708
21050
  //#region src/device/device-state-handle.ts
20709
21051
  var DEVICE_STATE_EVENT_CATEGORY = "device.state-changed";
@@ -23465,6 +23807,18 @@ Object.defineProperty(exports, "commandEffect", {
23465
23807
  return commandEffect;
23466
23808
  }
23467
23809
  });
23810
+ Object.defineProperty(exports, "commandEffects", {
23811
+ enumerable: true,
23812
+ get: function() {
23813
+ return commandEffects;
23814
+ }
23815
+ });
23816
+ Object.defineProperty(exports, "commandHoldMs", {
23817
+ enumerable: true,
23818
+ get: function() {
23819
+ return commandHoldMs;
23820
+ }
23821
+ });
23468
23822
  Object.defineProperty(exports, "commandOrigin", {
23469
23823
  enumerable: true,
23470
23824
  get: function() {
@@ -23609,6 +23963,12 @@ Object.defineProperty(exports, "displayUnitFor", {
23609
23963
  return displayUnitFor;
23610
23964
  }
23611
23965
  });
23966
+ Object.defineProperty(exports, "effectConditionHolds", {
23967
+ enumerable: true,
23968
+ get: function() {
23969
+ return effectConditionHolds;
23970
+ }
23971
+ });
23612
23972
  Object.defineProperty(exports, "emitDownForOwnedCaps", {
23613
23973
  enumerable: true,
23614
23974
  get: function() {
@@ -24113,6 +24473,12 @@ Object.defineProperty(exports, "resolveSecretViewsIn", {
24113
24473
  return resolveSecretViewsIn;
24114
24474
  }
24115
24475
  });
24476
+ Object.defineProperty(exports, "resolveSideEffect", {
24477
+ enumerable: true,
24478
+ get: function() {
24479
+ return resolveSideEffect;
24480
+ }
24481
+ });
24116
24482
  Object.defineProperty(exports, "resolvedValues", {
24117
24483
  enumerable: true,
24118
24484
  get: function() {