@camstack/server 1.2.807 → 1.2.809

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.
@@ -1,6 +1,6 @@
1
1
  import { $ as EMPTY_AUTOMATION_STATE, $i as proposeRunningThreshold, $n as coreBlockSourceKind, $r as isInternalActionId, A as ControlStatusSchema, Ai as normalizeActionUnits, Bn as checkTemplatePayload, C as CORE_BLOCKS_ADDON_ID, Cc as secretTreeFromSchema, Co as composedDeviceRef, Er as evaluateWhenTree, Et as MediaPlayerStatusSchema, Fa as stableIdMapOf, Fs as collectSecretMarkerRefs, Ft as PowerSourceInfoSchema, Gi as planComposition, Gn as compileScalarOverride, Gt as RemoteConfigSchema, Hn as collectWhenMirrorSources, Hs as defineRecordKinds, Ic as EventCategory$1, In as capUnitResolver, J as DeclaredDevices, Ja as timedRunLimitOf, Ji as powerSourceLinkOfComposition, Jn as compositionSourceRefs, Ka as templateCapability, Ko as BaseAddon, Kt as RunningStateStatusSchema, Li as occurrenceOn, Mi as normalizeCoreBlockWrite, Nc as DeviceType$1, Ni as normalizeStepTargets, No as helperMembers, Nr as fanPresetsCapability, O as ConditionMirror, Oc as transformSecretWrite, On as buildActionSteps, Oo as compositionSourceKey, Pc as errMsg$1, Po as historyRetentionFromSettings, Qn as coreBlockIdFromAddonId, R as DEFAULT_HOLD_OVERRIDE, S as COMPOSER_RUNNER_ID, Sa as schedulersCapability, Vt as REMOTE_MEDIA_COMMANDS, Wr as internalActionId, Wt as RemoteAssumedStateSchema, Xa as timedRunQuickRun, Xi as problemsBlockSave, Xn as coreBlockAddonId, Xs as hydrateSchema, Xt as SchedulerError, Ya as timedRunMaxIn, Za as timedRunSeconds, Zn as coreBlockComposition, Zt as SchedulerSchema, aa as remoteLayoutComponentsCapability, ac as isSecretMarker, an as SwitchStatusSchema, ba as runSteps, bc as resolveSecretMarkers, c as ActionError, co as weekdayOfLocalDate, d as ActionVariableSchema, da as resolveCoreBlockFiles, dn as actionSourceCapability, do as zoneOnlySite, eo as validateComposition, er as coreBlocksCapability, et as EMPTY_REMOTE_ASSUMED_STATE, fn as actionWaitTotalMs, fr as describeComposableCaps, gt as INTERNAL_ACTION_PREFIX, ht as IDLE_ACTION_STATUS, ia as remoteCapability, ii as kebabToCamel, ir as customRole, it as FanControlStatusSchema, j as CoreBlockSchema, ja as siteFor, ji as normalizeCapStep, ki as nextOccurrence, kn as buildCapabilityLookup, l as ActionStepSchema, m as BUILTIN_REMOTE_COMPONENTS, mi as lockDoorLinkOfComposition, mn as addonIdOfActionId, mo as DAY_MS, n as ACTION_TARGET_INVALIDATION_EVENTS, no as validateSchedulerInput, nt as FAN_CAPTURE_FIELDS, oa as replacedFieldKeys, on as TemplateKindSchema, ot as FanPresetSchema, p as AutomationStateDocSchema, pn as actionsCapability, po as CompositionSchema, qa as timedRunCapability, qi as powerSourceCapability, rr as customKeyOfRole, s as ALL_CAPABILITY_DEFINITIONS, sa as resolveActionVariables, sc as isSecretRefOwnedBy, so as vocabActionIdFor, tt as EMPTY_REMOTE_CONFIG, u as ActionTargetResolver, ua as resolveCoreBlockEntry, ui as localDateOf, un as actionEffect, va as resolveStepArgs, w as CORE_BLOCK_ADDON_PREFIX, xn as appendTrace, yo as HelperMemberSchema, zs as defineAddonMigrations, zt as QuantityUnitError } from "../../dist-CogtCQxu.mjs";
2
2
  import { t as require_read_all_rows } from "../../read-all-rows-TaPqdWNF.mjs";
3
- import { i as parseDeviceStateChanged, t as describeCompositionSources } from "../../composition-sources-BhM6G9QT.mjs";
3
+ import { i as parseDeviceStateChanged, r as isRecord$1, t as describeCompositionSources } from "../../composition-sources-BhM6G9QT.mjs";
4
4
  import { i as capSeriesKey } from "../../capture-engine-CnVIcnyN.mjs";
5
5
  import { t as prefixRange } from "../../prefix-range-Dl0znowN.mjs";
6
6
  import { n as unwrapStoredValue, t as loadPrefixed } from "../../prefix-walk-DAOBSyH1.mjs";
@@ -5647,6 +5647,10 @@ var RemoteService = class {
5647
5647
  deps;
5648
5648
  now;
5649
5649
  sleep;
5650
+ /** Remote devices seen so far, and the plug each one waits on: who an input event affects. */
5651
+ plugOf = /* @__PURE__ */ new Map();
5652
+ sliceRuns = /* @__PURE__ */ new Map();
5653
+ slicePending = /* @__PURE__ */ new Set();
5650
5654
  constructor(deps) {
5651
5655
  this.deps = deps;
5652
5656
  this.now = deps.now ?? Date.now;
@@ -5665,6 +5669,7 @@ var RemoteService = class {
5665
5669
  detail: `no template "${config.layoutTemplateId}"`
5666
5670
  };
5667
5671
  await this.deps.store.write(deviceId, config);
5672
+ await this.refreshSlice(deviceId);
5668
5673
  return { status: "saved" };
5669
5674
  };
5670
5675
  listCommands = async ({ deviceId }) => {
@@ -5697,6 +5702,60 @@ var RemoteService = class {
5697
5702
  return this.run(deviceId, config, role, repeat);
5698
5703
  };
5699
5704
  /**
5705
+ * Writes the device's `media-player` slice from `assumedStatus`, but only
5706
+ * when the remote is what answers for it: a media player, no native source
5707
+ * (`hasNative`), and a power state the remote knows. Overlapping calls for a
5708
+ * device coalesce: one run in flight, one more pending. A failed write is
5709
+ * logged, never thrown — the next input change or send is the retry (D3).
5710
+ */
5711
+ refreshSlice(deviceId) {
5712
+ const running = this.sliceRuns.get(deviceId);
5713
+ if (running !== void 0) {
5714
+ this.slicePending.add(deviceId);
5715
+ return running;
5716
+ }
5717
+ const run = this.drainSlice(deviceId).finally(() => {
5718
+ this.sliceRuns.delete(deviceId);
5719
+ });
5720
+ this.sliceRuns.set(deviceId, run);
5721
+ return run;
5722
+ }
5723
+ async drainSlice(deviceId) {
5724
+ do {
5725
+ this.slicePending.delete(deviceId);
5726
+ await this.writeSlice(deviceId);
5727
+ } while (this.slicePending.has(deviceId));
5728
+ }
5729
+ async writeSlice(deviceId) {
5730
+ try {
5731
+ if (this.deps.hasNative(deviceId)) return;
5732
+ if (!await this.deps.isMediaPlayer(deviceId)) return;
5733
+ this.plugOf.set(deviceId, await this.deps.plugDeviceOf(deviceId));
5734
+ const status = await this.statusOf(deviceId, false);
5735
+ if (status === null) return;
5736
+ await this.deps.slice.publish(deviceId, status);
5737
+ } catch (err) {
5738
+ this.deps.logger.warn("remote: the media-player slice could not be written", {
5739
+ tags: { deviceId },
5740
+ meta: { error: errorText(err) }
5741
+ });
5742
+ }
5743
+ }
5744
+ /** Boot: every remote device. */
5745
+ async refreshSlices() {
5746
+ for (const deviceId of await this.deps.slice.devices()) await this.refreshSlice(deviceId);
5747
+ }
5748
+ /**
5749
+ * A device's state changed: refresh the remote devices it feeds — the TV
5750
+ * itself (its running-state) and every TV whose linked plug it is. Any other
5751
+ * device costs no read.
5752
+ */
5753
+ async onInputChanged(deviceId) {
5754
+ const affected = [];
5755
+ for (const [tv, plug] of this.plugOf) if (tv === deviceId || plug === deviceId) affected.push(tv);
5756
+ await Promise.all(affected.map((tv) => this.refreshSlice(tv)));
5757
+ }
5758
+ /**
5700
5759
  * What the remote ASSUMES (the last power and mute it sent), or null when it
5701
5760
  * knows neither. No plug, no running-state: that is `assumedStatus`.
5702
5761
  */
@@ -5707,7 +5766,7 @@ var RemoteService = class {
5707
5766
  const assumedFields = [];
5708
5767
  if (kept.power !== null) assumedFields.push("state");
5709
5768
  if (kept.muted !== null) assumedFields.push("isMuted");
5710
- return this.statusOf({
5769
+ return this.buildStatus({
5711
5770
  state: kept.power?.state ?? "standby",
5712
5771
  assumedFields,
5713
5772
  muted: kept.muted?.value ?? null,
@@ -5723,8 +5782,12 @@ var RemoteService = class {
5723
5782
  * the assumption, and only while the device may be on.
5724
5783
  */
5725
5784
  async assumedStatus(deviceId) {
5785
+ return this.statusOf(deviceId, true);
5786
+ }
5787
+ /** `forget`: whether a plug that is off drops the kept power guess (a read's side effect). */
5788
+ async statusOf(deviceId, forget) {
5726
5789
  const kept = await this.readAssumed(deviceId);
5727
- const truth = await this.powerTruth(deviceId);
5790
+ const truth = await this.powerTruth(deviceId, forget);
5728
5791
  if (truth === null) return null;
5729
5792
  const assumedFields = truth.assumed ? ["state"] : [];
5730
5793
  const state = truth.state;
@@ -5732,7 +5795,7 @@ var RemoteService = class {
5732
5795
  const mute = state === "off" ? null : kept.muted ?? null;
5733
5796
  if (mute !== null) assumedFields.push("isMuted");
5734
5797
  const config = await this.deps.store.read(deviceId);
5735
- return this.statusOf({
5798
+ return this.buildStatus({
5736
5799
  state,
5737
5800
  assumedFields,
5738
5801
  muted: mute?.value ?? null,
@@ -5740,7 +5803,7 @@ var RemoteService = class {
5740
5803
  sources: config.customButtons.map((b) => b.name)
5741
5804
  });
5742
5805
  }
5743
- statusOf(input) {
5806
+ buildStatus(input) {
5744
5807
  return {
5745
5808
  state: input.state,
5746
5809
  stateSource: input.assumedFields.length > 0 ? "assumed" : "reported",
@@ -5790,7 +5853,7 @@ var RemoteService = class {
5790
5853
  * standby; on contradicts an assumed `off`, which is dropped); then the
5791
5854
  * remote's own assumption; a plug on with nothing sent is `standby`.
5792
5855
  */
5793
- async powerTruth(deviceId) {
5856
+ async powerTruth(deviceId, forget = true) {
5794
5857
  const running = await this.deps.runningState(deviceId);
5795
5858
  if (running !== null) return {
5796
5859
  state: running ? "on" : "off",
@@ -5800,7 +5863,7 @@ var RemoteService = class {
5800
5863
  const plug = await this.deps.plugOn(deviceId);
5801
5864
  const kept = await this.readAssumed(deviceId);
5802
5865
  if (plug === false) {
5803
- if (kept.power !== null) await this.deps.assumptions.write(deviceId, {
5866
+ if (forget && kept.power !== null) await this.deps.assumptions.write(deviceId, {
5804
5867
  ...kept,
5805
5868
  power: null
5806
5869
  });
@@ -5858,6 +5921,7 @@ var RemoteService = class {
5858
5921
  at: this.now()
5859
5922
  }
5860
5923
  });
5924
+ await this.refreshSlice(deviceId);
5861
5925
  }
5862
5926
  return result;
5863
5927
  }
@@ -5910,6 +5974,7 @@ var RemoteService = class {
5910
5974
  }
5911
5975
  }
5912
5976
  await this.moveAssumption(deviceId, role, wantsState);
5977
+ await this.refreshSlice(deviceId);
5913
5978
  return {
5914
5979
  status: "sent",
5915
5980
  sends: times
@@ -6226,6 +6291,76 @@ function reportedStatusOver(api, logger) {
6226
6291
  }
6227
6292
  };
6228
6293
  }
6294
+ /** The cap whose runtime slice the remote writes for a device no native source reads. */
6295
+ var MEDIA_PLAYER_CAP = "media-player";
6296
+ /** A slice says the same when only its change stamp moved. */
6297
+ function sameStatus(a, b) {
6298
+ return JSON.stringify({
6299
+ ...a,
6300
+ lastChangedAt: 0
6301
+ }) === JSON.stringify({
6302
+ ...b,
6303
+ lastChangedAt: 0
6304
+ });
6305
+ }
6306
+ /**
6307
+ * The standard runtime-state path (`deviceState.setCapSlice`, the entry every
6308
+ * `setCapState` reaches). The current slice is read back from the hub, never
6309
+ * kept here, so a write that would change nothing is skipped without a cache.
6310
+ */
6311
+ function remoteSliceWriterOver(settings, api) {
6312
+ return {
6313
+ devices: async () => {
6314
+ const ids = await settings.listDeviceStoreIds();
6315
+ if (ids.length === 0) return [];
6316
+ const rows = await settings.readDeviceStoreBatch(ids);
6317
+ const carrying = [];
6318
+ for (const [deviceId, row] of rows) if (RemoteConfigSchema.safeParse(row["remote"]).success) carrying.push(deviceId);
6319
+ return carrying;
6320
+ },
6321
+ publish: async (deviceId, status) => {
6322
+ const current = api();
6323
+ if (current === void 0) throw new Error("no ctx.api on this node");
6324
+ const kept = MediaPlayerStatusSchema.safeParse(await current.deviceState.getCapSlice.query({
6325
+ deviceId,
6326
+ capName: MEDIA_PLAYER_CAP
6327
+ }));
6328
+ if (kept.success && sameStatus(kept.data, status)) return;
6329
+ await current.deviceState.setCapSlice.mutate({
6330
+ deviceId,
6331
+ capName: MEDIA_PLAYER_CAP,
6332
+ slice: { ...status }
6333
+ });
6334
+ }
6335
+ };
6336
+ }
6337
+ /** The device of the linked plug (`power-source`), null when none is linked or it errors. */
6338
+ function plugDeviceOver(api) {
6339
+ return async (deviceId) => {
6340
+ const current = api();
6341
+ if (current === void 0) return null;
6342
+ try {
6343
+ const parsed = PowerSourceInfoSchema.safeParse(await current.powerSource.getStatus.query({ deviceId }));
6344
+ return parsed.success && parsed.data.linked ? parsed.data.switchDeviceId : null;
6345
+ } catch {
6346
+ return null;
6347
+ }
6348
+ };
6349
+ }
6350
+ /** The caps whose change can move the assumed state: the plug's switch and a running-state. */
6351
+ var REMOTE_SLICE_INPUT_CAPS = new Set(["switch", "running-state"]);
6352
+ /**
6353
+ * Seeds every remote device's slice ONCE at boot. No retry timer (D3): a read
6354
+ * that fails changes nothing, and `DeviceRegistered` and the input events
6355
+ * re-drive the refresh.
6356
+ */
6357
+ async function seedRemoteSlices(remote, logger) {
6358
+ try {
6359
+ await remote.refreshSlices();
6360
+ } catch (error) {
6361
+ logger.warn("remote: the media-player slices could not be seeded at boot", { meta: { error: error instanceof Error ? error.message : String(error) } });
6362
+ }
6363
+ }
6229
6364
  function buildRemoteRuntime(deps) {
6230
6365
  const templateRows = deps.records.kind(coreBlocksRecordKinds.templates);
6231
6366
  return {
@@ -6245,6 +6380,9 @@ function buildRemoteRuntime(deps) {
6245
6380
  runningState: runningStateOver(deps.api, deps.logger.child("remote")),
6246
6381
  plugOn: plugOnOver(deps.api, deps.logger.child("remote")),
6247
6382
  assumptions: remoteAssumptionStoreOver(deps.settings, deps.logger.child("remote")),
6383
+ slice: remoteSliceWriterOver(deps.settings, deps.api),
6384
+ hasNative: deps.hasNative,
6385
+ plugDeviceOf: plugDeviceOver(deps.api),
6248
6386
  logger: deps.logger.child("remote"),
6249
6387
  ...deps.sleep === void 0 ? {} : { sleep: deps.sleep },
6250
6388
  ...deps.now === void 0 ? {} : { now: deps.now }
@@ -7680,6 +7818,7 @@ var CoreBlocksAddon = class extends BaseAddon {
7680
7818
  this.remoteRuntime = this.buildRemote(records);
7681
7819
  this.fanPresets = this.buildFanPresets();
7682
7820
  this.installDeviceCallRedirect();
7821
+ this.armRemoteSlices();
7683
7822
  const timedRun = buildTimedRunService({
7684
7823
  records,
7685
7824
  settings: () => this.ctx.settings,
@@ -7788,9 +7927,15 @@ var CoreBlocksAddon = class extends BaseAddon {
7788
7927
  records,
7789
7928
  settings,
7790
7929
  api: () => this.ctx.api,
7791
- logger: this.ctx.logger
7930
+ logger: this.ctx.logger,
7931
+ hasNative: (deviceId) => this.hasNativeMediaPlayer(deviceId)
7792
7932
  });
7793
7933
  }
7934
+ /** A driver's native media-player cap reads the device; the composer's own native holds no reading. */
7935
+ hasNativeMediaPlayer(deviceId) {
7936
+ const owner = this.ctx.kernel?.capabilityRegistry?.getNativeAddonId("media-player", deviceId);
7937
+ return owner !== void 0 && owner !== null && owner !== "composer";
7938
+ }
7794
7939
  /**
7795
7940
  * Precedence at DISPATCH (D963, D984): the redirect lives in the registry, so it
7796
7941
  * holds for every caller. ONE slot, so the authorities compose: the remote's
@@ -7812,13 +7957,30 @@ var CoreBlocksAddon = class extends BaseAddon {
7812
7957
  const runtime = this.remoteRuntime;
7813
7958
  registry.setDeviceCallRedirect(composeRedirects([...runtime === null ? [] : [remoteCallRedirect({
7814
7959
  remote: runtime.remote,
7815
- hasNative: (deviceId) => {
7816
- const owner = registry.getNativeAddonId("media-player", deviceId);
7817
- return owner !== null && owner !== "composer";
7818
- },
7960
+ hasNative: (deviceId) => this.hasNativeMediaPlayer(deviceId),
7819
7961
  logger: this.ctx.logger.child("remote")
7820
7962
  })], gate.redirect()]));
7821
7963
  }
7964
+ /**
7965
+ * The remote writes each of its devices' `media-player` slice itself: seeded
7966
+ * once at boot (never awaited), refreshed when a device registers, a config
7967
+ * is saved, a send lands, or a device that feeds the assumed state changes (its
7968
+ * running-state, or the switch of its linked plug). Our own slice write is a
7969
+ * `media-player` event, not one of those inputs, so it cannot loop.
7970
+ */
7971
+ armRemoteSlices() {
7972
+ const remote = this.remoteRuntime?.remote;
7973
+ if (remote === void 0) return;
7974
+ seedRemoteSlices(remote, this.ctx.logger.child("remote"));
7975
+ this.subscribe({ category: EventCategory$1.DeviceRegistered }, (event) => {
7976
+ const deviceId = isRecord$1(event.data) ? event.data["deviceId"] : void 0;
7977
+ if (typeof deviceId === "number") remote.refreshSlice(deviceId);
7978
+ });
7979
+ this.subscribe({ category: EventCategory$1.DeviceStateChanged }, (event) => {
7980
+ const data = parseDeviceStateChanged(event.data);
7981
+ if (data !== null && REMOTE_SLICE_INPUT_CAPS.has(data.capName)) remote.onInputChanged(data.deviceId);
7982
+ });
7983
+ }
7822
7984
  seedGate(gate) {
7823
7985
  const api = this.ctx.api;
7824
7986
  if (!api) return;
@@ -36,9 +36,28 @@ export interface RemoteAssumptionStore {
36
36
  read(deviceId: number): Promise<RemoteAssumedState | null>;
37
37
  write(deviceId: number, state: RemoteAssumedState): Promise<void>;
38
38
  }
39
+ /**
40
+ * The device's `media-player` runtime slice, written through the standard
41
+ * runtime-state path. The slice is a PROJECTION of `assumedStatus` — the one
42
+ * computation `getStatus` is also answered from — so there is no second cache.
43
+ */
44
+ export interface RemoteSliceWriter {
45
+ /** The devices that carry a remote configuration. */
46
+ devices(): Promise<readonly number[]>;
47
+ /** Writes the slice; a no-op when it already says the same. */
48
+ publish(deviceId: number, status: MediaPlayerStatus): Promise<void>;
49
+ }
39
50
  export interface RemoteServiceDeps {
40
51
  readonly store: RemoteConfigStore;
41
52
  readonly assumptions: RemoteAssumptionStore;
53
+ readonly slice: RemoteSliceWriter;
54
+ /**
55
+ * Whether a driver's native media-player cap reads the device — the SAME
56
+ * predicate the dispatch redirect uses. Such a device never gets an assumed slice.
57
+ */
58
+ hasNative(deviceId: number): boolean;
59
+ /** The device of the linked plug, or null when none is linked. */
60
+ plugDeviceOf(deviceId: number): Promise<number | null>;
42
61
  /** Runs the action a role is bound to. Throws when the call fails. */
43
62
  invoke(call: CapCall): Promise<void>;
44
63
  templateExists(templateId: string): Promise<boolean>;
@@ -60,6 +79,10 @@ export declare class RemoteService implements IRemoteProvider {
60
79
  private readonly deps;
61
80
  private readonly now;
62
81
  private readonly sleep;
82
+ /** Remote devices seen so far, and the plug each one waits on: who an input event affects. */
83
+ private readonly plugOf;
84
+ private readonly sliceRuns;
85
+ private readonly slicePending;
63
86
  constructor(deps: RemoteServiceDeps);
64
87
  readonly getConfig: IRemoteProvider["getConfig"];
65
88
  readonly setConfig: IRemoteProvider["setConfig"];
@@ -67,6 +90,24 @@ export declare class RemoteService implements IRemoteProvider {
67
90
  readonly sendCommand: IRemoteProvider["sendCommand"];
68
91
  readonly sendMediaCommand: IRemoteProvider["sendMediaCommand"];
69
92
  /**
93
+ * Writes the device's `media-player` slice from `assumedStatus`, but only
94
+ * when the remote is what answers for it: a media player, no native source
95
+ * (`hasNative`), and a power state the remote knows. Overlapping calls for a
96
+ * device coalesce: one run in flight, one more pending. A failed write is
97
+ * logged, never thrown — the next input change or send is the retry (D3).
98
+ */
99
+ refreshSlice(deviceId: number): Promise<void>;
100
+ private drainSlice;
101
+ private writeSlice;
102
+ /** Boot: every remote device. */
103
+ refreshSlices(): Promise<void>;
104
+ /**
105
+ * A device's state changed: refresh the remote devices it feeds — the TV
106
+ * itself (its running-state) and every TV whose linked plug it is. Any other
107
+ * device costs no read.
108
+ */
109
+ onInputChanged(deviceId: number): Promise<void>;
110
+ /**
70
111
  * What the remote ASSUMES (the last power and mute it sent), or null when it
71
112
  * knows neither. No plug, no running-state: that is `assumedStatus`.
72
113
  */
@@ -79,7 +120,9 @@ export declare class RemoteService implements IRemoteProvider {
79
120
  * the assumption, and only while the device may be on.
80
121
  */
81
122
  assumedStatus(deviceId: number): Promise<MediaPlayerStatus | null>;
123
+ /** `forget`: whether a plug that is off drops the kept power guess (a read's side effect). */
82
124
  private statusOf;
125
+ private buildStatus;
83
126
  private mediaRole;
84
127
  /** A role is reachable when bound, or when a toggle `power` stands for `power_on` / `power_off`. */
85
128
  private isBound;
@@ -10,7 +10,7 @@
10
10
  * addon.
11
11
  */
12
12
  import { type AddonApi, type AddonContext, type IScopedLogger, type MediaPlayerStatus, type RecordsAccess } from "@camstack/types";
13
- import { RemoteService, type RemoteAssumptionStore, type RemoteConfigStore } from "./remote-service.js";
13
+ import { RemoteService, type RemoteAssumptionStore, type RemoteConfigStore, type RemoteSliceWriter } from "./remote-service.js";
14
14
  import { TemplatesService, type TemplateUsage } from "./templates-service.js";
15
15
  /** The key of the device's settings store that holds its remote configuration. */
16
16
  export declare const REMOTE_STORE_KEY = "remote";
@@ -22,6 +22,8 @@ export interface RemoteRuntimeDeps {
22
22
  readonly settings: DeviceSettings;
23
23
  readonly api: () => AddonApi | undefined;
24
24
  readonly logger: IScopedLogger;
25
+ /** Whether a driver's native media-player cap reads the device (the redirect's predicate). */
26
+ readonly hasNative: (deviceId: number) => boolean;
25
27
  /** The wait between two sends of a repeat; a spec drives it. */
26
28
  readonly sleep?: (ms: number) => Promise<void>;
27
29
  readonly now?: () => number;
@@ -53,5 +55,21 @@ export declare function templateUsageOver(settings: Pick<DeviceSettings, "listDe
53
55
  * reading and must not be fed back as one.
54
56
  */
55
57
  export declare function reportedStatusOver(api: () => AddonApi | undefined, logger: IScopedLogger): (deviceId: number) => Promise<MediaPlayerStatus | null>;
58
+ /**
59
+ * The standard runtime-state path (`deviceState.setCapSlice`, the entry every
60
+ * `setCapState` reaches). The current slice is read back from the hub, never
61
+ * kept here, so a write that would change nothing is skipped without a cache.
62
+ */
63
+ export declare function remoteSliceWriterOver(settings: Pick<DeviceSettings, "readDeviceStoreBatch" | "listDeviceStoreIds">, api: () => AddonApi | undefined): RemoteSliceWriter;
64
+ /** The device of the linked plug (`power-source`), null when none is linked or it errors. */
65
+ export declare function plugDeviceOver(api: () => AddonApi | undefined): (deviceId: number) => Promise<number | null>;
66
+ /** The caps whose change can move the assumed state: the plug's switch and a running-state. */
67
+ export declare const REMOTE_SLICE_INPUT_CAPS: ReadonlySet<string>;
68
+ /**
69
+ * Seeds every remote device's slice ONCE at boot. No retry timer (D3): a read
70
+ * that fails changes nothing, and `DeviceRegistered` and the input events
71
+ * re-drive the refresh.
72
+ */
73
+ export declare function seedRemoteSlices(remote: Pick<RemoteService, "refreshSlices">, logger: IScopedLogger): Promise<void>;
56
74
  export declare function buildRemoteRuntime(deps: RemoteRuntimeDeps): RemoteRuntime;
57
75
  export {};