@camstack/server 1.2.897 → 1.2.898
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +6 -0
- package/package.json +17 -10
- package/system/dist/addon-runner.js +103 -12
- package/system/dist/addon-runner.mjs +103 -12
- package/system/dist/builtins/addon-pages-aggregator/addon-pages-aggregator.addon.js +1 -1
- package/system/dist/builtins/addon-pages-aggregator/addon-pages-aggregator.addon.mjs +1 -1
- package/system/dist/builtins/addon-widgets-aggregator/addon-widgets-aggregator.addon.js +1 -1
- package/system/dist/builtins/addon-widgets-aggregator/addon-widgets-aggregator.addon.mjs +1 -1
- package/system/dist/builtins/alerts/alerts.addon.js +1 -1
- package/system/dist/builtins/alerts/alerts.addon.mjs +1 -1
- package/system/dist/builtins/autotrack/index.js +1 -1
- package/system/dist/builtins/autotrack/index.mjs +1 -1
- package/system/dist/builtins/backup-orchestrator/backup-orchestrator.addon.js +2 -2
- package/system/dist/builtins/backup-orchestrator/backup-orchestrator.addon.mjs +2 -2
- package/system/dist/builtins/calendars/calendars.addon.js +1 -1
- package/system/dist/builtins/calendars/calendars.addon.mjs +1 -1
- package/system/dist/builtins/camera-grid/index.js +1 -1
- package/system/dist/builtins/camera-grid/index.mjs +1 -1
- package/system/dist/builtins/composer/composer.addon.js +14 -11
- package/system/dist/builtins/composer/composer.addon.mjs +11 -8
- package/system/dist/builtins/console-logging/index.js +1 -1
- package/system/dist/builtins/console-logging/index.mjs +1 -1
- package/system/dist/builtins/core-blocks/core-blocks.addon.js +170 -14
- package/system/dist/builtins/core-blocks/core-blocks.addon.mjs +169 -13
- package/system/dist/builtins/core-blocks/migrations/automation-confirmed-view.d.ts +23 -0
- package/system/dist/builtins/core-blocks/migrations/index.d.ts +1 -0
- package/system/dist/builtins/core-blocks/migrations/pump-cycle-split.d.ts +1 -0
- package/system/dist/builtins/device-history/device-history.addon.js +10 -9
- package/system/dist/builtins/device-history/device-history.addon.mjs +10 -9
- package/system/dist/builtins/device-manager/command-holds-wiring.d.ts +22 -0
- package/system/dist/builtins/device-manager/command-holds.d.ts +75 -0
- package/system/dist/builtins/device-manager/device-manager.addon.d.ts +2 -0
- package/system/dist/builtins/device-manager/device-manager.addon.js +381 -26
- package/system/dist/builtins/device-manager/device-manager.addon.mjs +378 -27
- package/system/dist/builtins/device-manager/device-state-mirror.d.ts +35 -9
- package/system/dist/builtins/hub-forwarder/index.js +1 -1
- package/system/dist/builtins/hub-forwarder/index.mjs +1 -1
- package/system/dist/builtins/keychain/index.js +4 -4
- package/system/dist/builtins/keychain/index.mjs +4 -4
- package/system/dist/builtins/liveness-monitor/liveness-monitor.addon.js +1 -1
- package/system/dist/builtins/liveness-monitor/liveness-monitor.addon.mjs +1 -1
- package/system/dist/builtins/local-auth/local-auth.addon.js +2 -2
- package/system/dist/builtins/local-auth/local-auth.addon.mjs +2 -2
- package/system/dist/builtins/local-network/local-network.addon.js +3 -3
- package/system/dist/builtins/local-network/local-network.addon.mjs +3 -3
- package/system/dist/builtins/loki-logging/index.js +1 -1
- package/system/dist/builtins/loki-logging/index.mjs +1 -1
- package/system/dist/builtins/native-metrics/native-metrics.addon.js +1 -1
- package/system/dist/builtins/native-metrics/native-metrics.addon.mjs +1 -1
- package/system/dist/builtins/platform-probe/index.js +1 -1
- package/system/dist/builtins/platform-probe/index.mjs +1 -1
- package/system/dist/builtins/record-entries/index.js +1 -1
- package/system/dist/builtins/record-entries/index.mjs +1 -1
- package/system/dist/builtins/remote-access-orchestrator/remote-access-orchestrator.addon.js +1 -1
- package/system/dist/builtins/remote-access-orchestrator/remote-access-orchestrator.addon.mjs +1 -1
- package/system/dist/builtins/shared/device-state-changed.d.ts +8 -0
- package/system/dist/builtins/snapshot/index.js +1 -1
- package/system/dist/builtins/snapshot/index.mjs +1 -1
- package/system/dist/builtins/sqlite-storage/filesystem-storage.addon.js +1 -1
- package/system/dist/builtins/sqlite-storage/filesystem-storage.addon.mjs +1 -1
- package/system/dist/builtins/sqlite-storage/index.js +1 -1
- package/system/dist/builtins/sqlite-storage/index.mjs +1 -1
- package/system/dist/builtins/sqlite-storage/sqlite-settings.addon.js +3 -3
- package/system/dist/builtins/sqlite-storage/sqlite-settings.addon.mjs +3 -3
- package/system/dist/builtins/storage-orchestrator/storage-orchestrator.addon.js +1 -1
- package/system/dist/builtins/storage-orchestrator/storage-orchestrator.addon.mjs +1 -1
- package/system/dist/builtins/system-config/system-config.addon.js +3 -3
- package/system/dist/builtins/system-config/system-config.addon.mjs +3 -3
- package/system/dist/builtins/winston-logging/index.js +1 -1
- package/system/dist/builtins/winston-logging/index.mjs +1 -1
- package/system/dist/{capture-engine-D1rjl2dW.js → capture-engine-BWS0KTbm.js} +48 -1
- package/system/dist/{capture-engine-Bjgs__i9.mjs → capture-engine-DBQDaDxJ.mjs} +37 -2
- package/system/dist/{composition-sources-CF2-u58e.js → composition-sources-CDOW1dnY.js} +1 -32
- package/system/dist/{composition-sources-B727nlA0.mjs → composition-sources-CGUWmf-T.mjs} +2 -21
- package/system/dist/{constants-BF309c_I.mjs → constants-BmrLkwZs.mjs} +1 -1
- package/system/dist/{constants-DaR1SUh7.js → constants-BwrRoq-j.js} +1 -1
- package/system/dist/{device-ca-DT1hYtdW.mjs → device-ca-BGgZXEto.mjs} +1 -1
- package/system/dist/{device-ca-BqcX5_f2.js → device-ca-DiuwWyZY.js} +1 -1
- package/system/dist/{dist-BoEy9sm9.js → dist-CCd8IeIU.js} +685 -53
- package/system/dist/{dist-DorY_sjS.mjs → dist-D7t8wLTF.mjs} +674 -54
- package/system/dist/file-host-worker.js +1 -1
- package/system/dist/file-host-worker.mjs +1 -1
- package/system/dist/{hub-identity-CZ0nE3GK.mjs → hub-identity-BohJeqdO.mjs} +1 -1
- package/system/dist/{hub-identity-DH1rxUMD.js → hub-identity-G_ZdyPpc.js} +1 -1
- package/system/dist/{hub-mdns-ciao-N0nL34fx.js → hub-mdns-ciao-CKD4EgkG.js} +2 -2
- package/system/dist/{hub-mdns-ciao-7HK57Vtx.mjs → hub-mdns-ciao-D5RxSMrH.mjs} +2 -2
- package/system/dist/index.js +45 -13
- package/system/dist/index.mjs +46 -14
- package/system/dist/kernel/command-hold-overrides.d.ts +42 -0
- package/system/dist/kernel/moleculer/child-cap-descriptors.d.ts +3 -0
- package/system/dist/kernel/moleculer/device-cap-proxy.d.ts +2 -1
- package/system/dist/kernel/transport/child-cap-protocol.d.ts +6 -1
- package/system/dist/{legacy-integration-rows-door-BTfeULYt.js → legacy-integration-rows-door-BgCl68ek.js} +1 -1
- package/system/dist/{legacy-integration-rows-door-CdAQlIvv.mjs → legacy-integration-rows-door-Rm9JmIsl.mjs} +1 -1
- package/system/dist/{rename-composition-block-B1x-yK5U.js → rename-composition-block-2Z2ED7Og.js} +1 -1
- package/system/dist/{rename-composition-block-CIQjxBUa.mjs → rename-composition-block-DNO3mNEO.mjs} +1 -1
- package/system/dist/{restore-archive-Bj_gYmE9.mjs → restore-archive-2L5TymvF.mjs} +1 -1
- package/system/dist/{restore-archive-B086o8pL.js → restore-archive-CZkQO8t3.js} +1 -1
- package/system/dist/{wal-maintenance-Dgfmi-Ao.mjs → wal-maintenance-BMYe_n18.mjs} +0 -0
- package/system/dist/{wal-maintenance-MVIyxmu7.js → wal-maintenance-YjDJ73Qd.js} +0 -0
- package/system/package.json +1 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { A as ConditionMirror,
|
|
1
|
+
import { A as ConditionMirror, Ao as sameIdentifiers, Br as deviceExtensionCapability, Dl as isCommand$1, Dr as createDeviceExtensionProvider, Ds as workloadCapability, Ea as normalizeUnit, Fo as searchRank, Fr as defineExtensionSlotProvider, Gc as SECRET_CLEAR, Go as siteZoneKey, Hr as deviceManagerCapability, Hs as capAppliesToDeviceKind, Il as isSecretMarker, It as MINUTES_PER_DAY, J as DEVICE_TEMPLATE_FILTERS, Jr as deviceStatusCapability, Ki as isWorkloadSettled, Ll as isSecretMarkerLike, Ml as isKeychainStoredField, Na as parseStreamParamsFormPatch, On as WORKLOAD_TRANSITION_CATEGORY, Oo as runtimeFieldUnit, Os as workloadTransition, Pl as isSecretClear, Q as DEVICE_TEMPLATE_VALUES_CAP, Qa as reconcileReportedFeatures, Qn as buildStreamParamsConfigSchema, Qr as enumerateSchemaFields, R as DAY_NAMES, Ta as normalizeTags, Ti as identifierStrength, To as resolveTemplateRef, U as DEVICE_IDENTIFIER_KEYS, Ur as deviceOffersActions, Vi as isKernelDerivedFeature, Vs as canonicalStoredDeviceType, X as DEVICE_TEMPLATE_MAX_OUTPUT, Xi as legacyAutoLinkIds, Y as DEVICE_TEMPLATE_MAX_LENGTH, Zc as WELL_KNOWN_TAB_MAP, Zl as resolveSecretMarkers, Zr as enumerateItemArrayFields, _l as defineRecordKinds, _u as EventCategory$1, at as DeviceTombstoneSchema, au as toSecretFieldView, cu as vocabActionIdFor, eu as secretTreeFromPaths, fu as DeviceFeature, gi as formatMinutes, hc as BaseAddon, hu as errMsg$1, il as auditedFields, it as DeviceStatusSchema, kl as isDeviceConfigCap, kn as WorkloadStateSchema, ko as runtimeStatePolicyFor, ll as collectZodSecretPaths$1, ln as STREAM_PROFILE_META, ma as mergeIdentifiers, mu as DeviceType$1, na as locationIconKey, nc as implementedMethodsOf$1, nr as canonicalIconKey, nt as DeviceIdentifiersSchema, oi as extractSourceInfoFromMetadata, or as checkDeviceAlias, ot as DiscoveryProposalBodySchema, ou as transformSecretWrite, po as resolveCommandHold, pu as DeviceRole, qr as deviceStateCapability, ri as expandContainer, ru as sleep$2, s as ALL_CAPABILITY_DEFINITIONS, su as userError, ul as commandEffect, ut as ExportNameRefusedError, vt as FieldClaimModeSchema, x as CAP_NAMES_WITH_STATUS, xl as expandCapMethods$1, y as CAMERA_SWITCH_ORDER, yi as generateDeviceAlias, yt as FieldClaimSchema, zi as isEmptyIdentifiers, zo as settleDeviceFeatures } from "../../dist-D7t8wLTF.mjs";
|
|
2
2
|
import { t as require_read_all_rows } from "../../read-all-rows-TaPqdWNF.mjs";
|
|
3
3
|
import { a as redactLogText, i as redactLogMeta, n as isSecretArgumentKey } from "../../log-redactor-XLDrPzOi.mjs";
|
|
4
|
-
import { n as renameCompositionBlock, t as composedBlockIdOf } from "../../rename-composition-block-
|
|
4
|
+
import { n as renameCompositionBlock, t as composedBlockIdOf } from "../../rename-composition-block-DNO3mNEO.mjs";
|
|
5
5
|
import { t as prefixRange } from "../../prefix-range-Dl0znowN.mjs";
|
|
6
6
|
import { t as loadPrefixed } from "../../prefix-walk-DAOBSyH1.mjs";
|
|
7
7
|
import { n as purgeRetiredSettingsRows } from "../../retired-settings-keys-u6xQA6r7.mjs";
|
|
@@ -12090,6 +12090,201 @@ var MirrorRowWriter = class MirrorRowWriter {
|
|
|
12090
12090
|
}
|
|
12091
12091
|
};
|
|
12092
12092
|
//#endregion
|
|
12093
|
+
//#region src/builtins/device-manager/command-holds.ts
|
|
12094
|
+
function same(a, b) {
|
|
12095
|
+
return Object.is(a, b);
|
|
12096
|
+
}
|
|
12097
|
+
/** Does `reading` confirm `held`: equal, or a number within its tolerance? */
|
|
12098
|
+
function confirms(reading, held, tolerance) {
|
|
12099
|
+
if (same(reading, held)) return true;
|
|
12100
|
+
if (typeof reading !== "number" || typeof held !== "number" || tolerance <= 0) return false;
|
|
12101
|
+
return Math.abs(reading - held) <= tolerance + 1e-9;
|
|
12102
|
+
}
|
|
12103
|
+
function judge(reading, held) {
|
|
12104
|
+
if (confirms(reading, held.value, held.tolerance)) return "confirmed";
|
|
12105
|
+
if (held.stale.some((v) => same(v, reading))) return "stale";
|
|
12106
|
+
return "device-answered";
|
|
12107
|
+
}
|
|
12108
|
+
var CommandHolds = class {
|
|
12109
|
+
deps;
|
|
12110
|
+
/** device → cap → field → held value. */
|
|
12111
|
+
held = /* @__PURE__ */ new Map();
|
|
12112
|
+
armings = /* @__PURE__ */ new Map();
|
|
12113
|
+
seq = 0;
|
|
12114
|
+
constructor(deps) {
|
|
12115
|
+
this.deps = deps;
|
|
12116
|
+
}
|
|
12117
|
+
/**
|
|
12118
|
+
* Hold what a command leads to. A field the slice already holds is not held
|
|
12119
|
+
* (and a standing hold on it is dropped: the newer command wins). Returns the
|
|
12120
|
+
* token that `release` takes, or `null` when nothing is held.
|
|
12121
|
+
*/
|
|
12122
|
+
arm(request) {
|
|
12123
|
+
const base = this.deps.baseSlice(request.deviceId, request.capName);
|
|
12124
|
+
if (base === null) {
|
|
12125
|
+
this.deps.logger.debug("command hold: the cap has no slice yet — nothing held", {
|
|
12126
|
+
tags: { deviceId: request.deviceId },
|
|
12127
|
+
meta: {
|
|
12128
|
+
cap: request.capName,
|
|
12129
|
+
method: request.method
|
|
12130
|
+
}
|
|
12131
|
+
});
|
|
12132
|
+
return null;
|
|
12133
|
+
}
|
|
12134
|
+
this.seq += 1;
|
|
12135
|
+
const token = this.seq;
|
|
12136
|
+
const fields = this.fieldsOf(request.deviceId, request.capName);
|
|
12137
|
+
let changed = false;
|
|
12138
|
+
let holding = false;
|
|
12139
|
+
for (const effect of request.effects) {
|
|
12140
|
+
const standing = fields.get(effect.field);
|
|
12141
|
+
const tolerance = effect.tolerance ?? 0;
|
|
12142
|
+
const reported = Object.hasOwn(base, effect.field) ? base[effect.field] : void 0;
|
|
12143
|
+
if (Object.hasOwn(base, effect.field) && confirms(reported, effect.value, tolerance)) {
|
|
12144
|
+
if (standing !== void 0) {
|
|
12145
|
+
fields.delete(effect.field);
|
|
12146
|
+
changed = true;
|
|
12147
|
+
}
|
|
12148
|
+
continue;
|
|
12149
|
+
}
|
|
12150
|
+
if (standing === void 0 || !same(standing.value, effect.value)) changed = true;
|
|
12151
|
+
const stale = standing === void 0 ? [reported] : [...standing.stale, standing.value];
|
|
12152
|
+
fields.set(effect.field, {
|
|
12153
|
+
value: effect.value,
|
|
12154
|
+
tolerance,
|
|
12155
|
+
stale,
|
|
12156
|
+
token
|
|
12157
|
+
});
|
|
12158
|
+
holding = true;
|
|
12159
|
+
}
|
|
12160
|
+
this.dropEmpty(request.deviceId, request.capName);
|
|
12161
|
+
this.forgetStaleArmings();
|
|
12162
|
+
if (holding) {
|
|
12163
|
+
const timer = setTimeout(() => this.release(token, "unconfirmed"), request.holdMs);
|
|
12164
|
+
timer.unref?.();
|
|
12165
|
+
this.armings.set(token, {
|
|
12166
|
+
token,
|
|
12167
|
+
deviceId: request.deviceId,
|
|
12168
|
+
capName: request.capName,
|
|
12169
|
+
method: request.method,
|
|
12170
|
+
holdMs: request.holdMs,
|
|
12171
|
+
timer
|
|
12172
|
+
});
|
|
12173
|
+
}
|
|
12174
|
+
if (changed) this.deps.reemit(request.deviceId, request.capName);
|
|
12175
|
+
return holding ? token : null;
|
|
12176
|
+
}
|
|
12177
|
+
/** End what `token` still holds — refused at once, or unconfirmed at the limit. */
|
|
12178
|
+
release(token, reason) {
|
|
12179
|
+
const arming = this.armings.get(token);
|
|
12180
|
+
if (arming === void 0) return;
|
|
12181
|
+
this.armings.delete(token);
|
|
12182
|
+
clearTimeout(arming.timer);
|
|
12183
|
+
const fields = this.held.get(arming.deviceId)?.get(arming.capName);
|
|
12184
|
+
if (fields === void 0) return;
|
|
12185
|
+
const dropped = [];
|
|
12186
|
+
for (const [field, held] of fields) {
|
|
12187
|
+
if (held.token !== token) continue;
|
|
12188
|
+
fields.delete(field);
|
|
12189
|
+
dropped.push(field);
|
|
12190
|
+
}
|
|
12191
|
+
if (dropped.length === 0) return;
|
|
12192
|
+
this.dropEmpty(arming.deviceId, arming.capName);
|
|
12193
|
+
const tags = { deviceId: arming.deviceId };
|
|
12194
|
+
const meta = {
|
|
12195
|
+
cap: arming.capName,
|
|
12196
|
+
method: arming.method,
|
|
12197
|
+
fields: dropped
|
|
12198
|
+
};
|
|
12199
|
+
if (reason === "unconfirmed" && arming.holdMs <= 1e4) this.deps.logger.debug("one-shot command hold ended", {
|
|
12200
|
+
tags,
|
|
12201
|
+
meta
|
|
12202
|
+
});
|
|
12203
|
+
else if (reason === "unconfirmed") this.deps.logger.warn("command hold reverted: the device did not confirm in time", {
|
|
12204
|
+
tags,
|
|
12205
|
+
meta
|
|
12206
|
+
});
|
|
12207
|
+
else this.deps.logger.info("command hold rolled back: the command was refused", {
|
|
12208
|
+
tags,
|
|
12209
|
+
meta
|
|
12210
|
+
});
|
|
12211
|
+
this.deps.reemit(arming.deviceId, arming.capName);
|
|
12212
|
+
}
|
|
12213
|
+
/**
|
|
12214
|
+
* The slice under the hold moved: keep each held field it still reports
|
|
12215
|
+
* stale, drop the ones it confirms or answers otherwise.
|
|
12216
|
+
*/
|
|
12217
|
+
settle(deviceId, capName, base) {
|
|
12218
|
+
const fields = this.held.get(deviceId)?.get(capName);
|
|
12219
|
+
if (fields === void 0) return;
|
|
12220
|
+
for (const [field, held] of fields) {
|
|
12221
|
+
if (!Object.hasOwn(base, field)) continue;
|
|
12222
|
+
const reading = judge(base[field], held);
|
|
12223
|
+
if (reading === "stale") continue;
|
|
12224
|
+
fields.delete(field);
|
|
12225
|
+
if (reading === "device-answered") this.deps.logger.debug("command hold released: the device answered otherwise", {
|
|
12226
|
+
tags: { deviceId },
|
|
12227
|
+
meta: {
|
|
12228
|
+
cap: capName,
|
|
12229
|
+
field,
|
|
12230
|
+
reason: reading
|
|
12231
|
+
}
|
|
12232
|
+
});
|
|
12233
|
+
}
|
|
12234
|
+
this.dropEmpty(deviceId, capName);
|
|
12235
|
+
this.forgetStaleArmings();
|
|
12236
|
+
}
|
|
12237
|
+
/** `base` with the held values over it; `base` itself when nothing is held. */
|
|
12238
|
+
overlay(deviceId, capName, base) {
|
|
12239
|
+
const fields = this.held.get(deviceId)?.get(capName);
|
|
12240
|
+
if (fields === void 0 || fields.size === 0) return base;
|
|
12241
|
+
const out = { ...base };
|
|
12242
|
+
for (const [field, held] of fields) out[field] = held.value;
|
|
12243
|
+
return out;
|
|
12244
|
+
}
|
|
12245
|
+
/** Is any field of the cap held? */
|
|
12246
|
+
isHolding(deviceId, capName) {
|
|
12247
|
+
return (this.held.get(deviceId)?.get(capName)?.size ?? 0) > 0;
|
|
12248
|
+
}
|
|
12249
|
+
/** Forget a removed device's holds. */
|
|
12250
|
+
clearDevice(deviceId) {
|
|
12251
|
+
this.held.delete(deviceId);
|
|
12252
|
+
for (const [token, arming] of this.armings) {
|
|
12253
|
+
if (arming.deviceId !== deviceId) continue;
|
|
12254
|
+
clearTimeout(arming.timer);
|
|
12255
|
+
this.armings.delete(token);
|
|
12256
|
+
}
|
|
12257
|
+
}
|
|
12258
|
+
/** Stop every timer (shutdown). */
|
|
12259
|
+
dispose() {
|
|
12260
|
+
for (const arming of this.armings.values()) clearTimeout(arming.timer);
|
|
12261
|
+
this.armings.clear();
|
|
12262
|
+
this.held.clear();
|
|
12263
|
+
}
|
|
12264
|
+
fieldsOf(deviceId, capName) {
|
|
12265
|
+
const perCap = this.held.get(deviceId) ?? /* @__PURE__ */ new Map();
|
|
12266
|
+
this.held.set(deviceId, perCap);
|
|
12267
|
+
const fields = perCap.get(capName) ?? /* @__PURE__ */ new Map();
|
|
12268
|
+
perCap.set(capName, fields);
|
|
12269
|
+
return fields;
|
|
12270
|
+
}
|
|
12271
|
+
dropEmpty(deviceId, capName) {
|
|
12272
|
+
const perCap = this.held.get(deviceId);
|
|
12273
|
+
if (perCap === void 0) return;
|
|
12274
|
+
if ((perCap.get(capName)?.size ?? 0) === 0) perCap.delete(capName);
|
|
12275
|
+
if (perCap.size === 0) this.held.delete(deviceId);
|
|
12276
|
+
}
|
|
12277
|
+
/** An arming whose fields were all confirmed or replaced holds nothing: stop its timer. */
|
|
12278
|
+
forgetStaleArmings() {
|
|
12279
|
+
for (const [token, arming] of this.armings) {
|
|
12280
|
+
const fields = this.held.get(arming.deviceId)?.get(arming.capName);
|
|
12281
|
+
if (fields !== void 0 && [...fields.values()].some((f) => f.token === token)) continue;
|
|
12282
|
+
clearTimeout(arming.timer);
|
|
12283
|
+
this.armings.delete(token);
|
|
12284
|
+
}
|
|
12285
|
+
}
|
|
12286
|
+
};
|
|
12287
|
+
//#endregion
|
|
12093
12288
|
//#region src/builtins/device-manager/device-state-mirror.ts
|
|
12094
12289
|
/**
|
|
12095
12290
|
* Hub-side runtime-state mirror for the device-manager addon.
|
|
@@ -12138,6 +12333,8 @@ var DeviceStateMirror = class {
|
|
|
12138
12333
|
stateMirror = /* @__PURE__ */ new Map();
|
|
12139
12334
|
/** The claims and the merged view of every claimed cap (D663). */
|
|
12140
12335
|
claims;
|
|
12336
|
+
/** Commanded values shown before the device confirms them (D1061). Memory only. */
|
|
12337
|
+
holds;
|
|
12141
12338
|
/**
|
|
12142
12339
|
* Devices whose CLAIMS are known: the row was read, or a loaded claims index
|
|
12143
12340
|
* vouched that it names none (D447). This is a READ-path fact — what a
|
|
@@ -12168,6 +12365,14 @@ var DeviceStateMirror = class {
|
|
|
12168
12365
|
schemaFor,
|
|
12169
12366
|
emitSlice: (deviceId, capName, slice) => this.emitStateChanged(deviceId, capName, slice)
|
|
12170
12367
|
});
|
|
12368
|
+
this.holds = new CommandHolds({
|
|
12369
|
+
logger: ctx.logger,
|
|
12370
|
+
baseSlice: (deviceId, capName) => this.baseSlice(deviceId, capName),
|
|
12371
|
+
reemit: (deviceId, capName) => {
|
|
12372
|
+
const base = this.baseSlice(deviceId, capName);
|
|
12373
|
+
if (base !== null) this.emitStateChanged(deviceId, capName, { ...base });
|
|
12374
|
+
}
|
|
12375
|
+
});
|
|
12171
12376
|
this.writer = new MirrorRowWriter({
|
|
12172
12377
|
logger: ctx.logger,
|
|
12173
12378
|
policyFor,
|
|
@@ -12180,6 +12385,22 @@ var DeviceStateMirror = class {
|
|
|
12180
12385
|
setTransitionTap(tap) {
|
|
12181
12386
|
this.transitionTap = tap;
|
|
12182
12387
|
}
|
|
12388
|
+
/**
|
|
12389
|
+
* Hold what a command leads to: the effective slice shows it at once (and
|
|
12390
|
+
* `DeviceStateChanged` carries it), the stored, persisted and recorded slice
|
|
12391
|
+
* does not change. Returns the token {@link releaseCommand} takes, or `null`.
|
|
12392
|
+
*/
|
|
12393
|
+
holdCommand(request) {
|
|
12394
|
+
return this.holds.arm(request);
|
|
12395
|
+
}
|
|
12396
|
+
/** End a command's hold: refused (rolled back at once) or unconfirmed (at the limit). */
|
|
12397
|
+
releaseCommand(token, reason) {
|
|
12398
|
+
this.holds.release(token, reason);
|
|
12399
|
+
}
|
|
12400
|
+
/** Stop the hold timers (shutdown). */
|
|
12401
|
+
disposeHolds() {
|
|
12402
|
+
this.holds.dispose();
|
|
12403
|
+
}
|
|
12183
12404
|
/** The native slice the mirror holds for `capName`, as a read-only view. */
|
|
12184
12405
|
currentSlice(deviceId, capName) {
|
|
12185
12406
|
return this.stateMirror.get(deviceId)?.get(capName);
|
|
@@ -12392,6 +12613,7 @@ var DeviceStateMirror = class {
|
|
|
12392
12613
|
await this.seeding.get(deviceId)?.catch(() => void 0);
|
|
12393
12614
|
await this.writer.forget(deviceId);
|
|
12394
12615
|
this.stateMirror.delete(deviceId);
|
|
12616
|
+
this.holds.clearDevice(deviceId);
|
|
12395
12617
|
this.workloadTransitions.forget(deviceId);
|
|
12396
12618
|
this.claims.clearDevice(deviceId);
|
|
12397
12619
|
this.seeded.delete(deviceId);
|
|
@@ -12683,25 +12905,33 @@ var DeviceStateMirror = class {
|
|
|
12683
12905
|
if (!raw) return true;
|
|
12684
12906
|
return (typeof raw.lastProbedAt === "number" ? raw.lastProbedAt : 0) > 0;
|
|
12685
12907
|
}
|
|
12686
|
-
/** The
|
|
12687
|
-
*
|
|
12688
|
-
|
|
12908
|
+
/** The slices of a device: native for an unclaimed cap, the merge for a
|
|
12909
|
+
* claimed one (a held cap is not reported) — and, in the `effective` view,
|
|
12910
|
+
* a commanded value over either (D1061). */
|
|
12911
|
+
snapshotForDevice(deviceId, view = "effective") {
|
|
12689
12912
|
const out = {};
|
|
12690
12913
|
for (const [k, v] of this.stateMirror.get(deviceId) ?? []) {
|
|
12691
12914
|
if (this.claims.isClaimed(deviceId, k)) continue;
|
|
12692
|
-
out[k] =
|
|
12915
|
+
out[k] = this.viewOf(deviceId, k, v, view);
|
|
12693
12916
|
}
|
|
12694
|
-
for (const [k, v] of this.claims.visibleCaps(deviceId)) out[k] =
|
|
12917
|
+
for (const [k, v] of this.claims.visibleCaps(deviceId)) out[k] = this.viewOf(deviceId, k, v, view);
|
|
12695
12918
|
return out;
|
|
12696
12919
|
}
|
|
12697
|
-
/** One cap's
|
|
12920
|
+
/** One cap's slice in `view`, cloned. Null when the device has never written
|
|
12698
12921
|
* it — callers read that as "the cap has no state", never as an empty slice —
|
|
12699
12922
|
* and null while a claim holds it. */
|
|
12700
|
-
capSlice(deviceId, cap) {
|
|
12923
|
+
capSlice(deviceId, cap, view = "effective") {
|
|
12924
|
+
const base = this.baseSlice(deviceId, cap);
|
|
12925
|
+
return base === null ? null : this.viewOf(deviceId, cap, base, view);
|
|
12926
|
+
}
|
|
12927
|
+
/** What the device reported for the cap, or the claim's merge — never a hold. Not cloned. */
|
|
12928
|
+
baseSlice(deviceId, cap) {
|
|
12701
12929
|
const visible = this.claims.visible(deviceId, cap);
|
|
12702
|
-
if (visible !== void 0) return visible ?
|
|
12703
|
-
|
|
12704
|
-
|
|
12930
|
+
if (visible !== void 0) return visible ? visible : null;
|
|
12931
|
+
return this.stateMirror.get(deviceId)?.get(cap) ?? null;
|
|
12932
|
+
}
|
|
12933
|
+
viewOf(deviceId, cap, base, view) {
|
|
12934
|
+
return view === "confirmed" ? { ...base } : { ...this.holds.overlay(deviceId, cap, base) };
|
|
12705
12935
|
}
|
|
12706
12936
|
/** The device's NATIVE slices — what the row stores under the cap names. */
|
|
12707
12937
|
nativeSnapshotForDevice(deviceId) {
|
|
@@ -12713,10 +12943,10 @@ var DeviceStateMirror = class {
|
|
|
12713
12943
|
}
|
|
12714
12944
|
/** Whole-system mirror dump. Backs `deviceState.getAllSnapshots` — one
|
|
12715
12945
|
* round-trip for a warm boot instead of N per-device calls. */
|
|
12716
|
-
allSnapshots() {
|
|
12946
|
+
allSnapshots(view = "effective") {
|
|
12717
12947
|
const out = {};
|
|
12718
12948
|
const deviceIds = new Set([...this.stateMirror.keys(), ...this.claims.deviceIds()]);
|
|
12719
|
-
for (const deviceId of deviceIds) out[String(deviceId)] = this.snapshotForDevice(deviceId);
|
|
12949
|
+
for (const deviceId of deviceIds) out[String(deviceId)] = this.snapshotForDevice(deviceId, view);
|
|
12720
12950
|
return out;
|
|
12721
12951
|
}
|
|
12722
12952
|
/**
|
|
@@ -12745,17 +12975,21 @@ var DeviceStateMirror = class {
|
|
|
12745
12975
|
}
|
|
12746
12976
|
/** Remember a restored running bit so the first public merge does not emit a flip. */
|
|
12747
12977
|
seedRunningFlip(deviceId) {
|
|
12748
|
-
const slice = this.capSlice(deviceId, RUNNING_STATE_CAP);
|
|
12978
|
+
const slice = this.capSlice(deviceId, RUNNING_STATE_CAP, "confirmed");
|
|
12749
12979
|
if (slice === null) return;
|
|
12750
12980
|
const running = slice["running"];
|
|
12751
12981
|
this.runningFlip.seed(deviceId, running === true || running === false ? running : null);
|
|
12752
12982
|
}
|
|
12753
12983
|
/**
|
|
12754
|
-
* The PUBLIC event:
|
|
12755
|
-
*
|
|
12756
|
-
* `
|
|
12984
|
+
* The PUBLIC event: `{ deviceId, capName, slice }` for every device, claimed
|
|
12985
|
+
* or not; `slice` is the EFFECTIVE slice. While a command hold changes it
|
|
12986
|
+
* (D1061), `confirmed` carries the slice without the hold — what history,
|
|
12987
|
+
* automations and the edge detectors below read. The native shadow of a
|
|
12988
|
+
* claim never rides here (D224) — see `emitNativeShadow`.
|
|
12757
12989
|
*/
|
|
12758
12990
|
emitStateChanged(deviceId, capName, slice) {
|
|
12991
|
+
this.holds.settle(deviceId, capName, slice);
|
|
12992
|
+
const effective = this.holds.overlay(deviceId, capName, slice);
|
|
12759
12993
|
if (capName === RUNNING_STATE_CAP) {
|
|
12760
12994
|
const flip = this.runningFlip.note(deviceId, slice);
|
|
12761
12995
|
if (flip !== null) this.ctx.eventBus.emit({
|
|
@@ -12782,10 +13016,15 @@ var DeviceStateMirror = class {
|
|
|
12782
13016
|
id: deviceId
|
|
12783
13017
|
},
|
|
12784
13018
|
category: EventCategory$1.DeviceStateChanged,
|
|
12785
|
-
data: {
|
|
13019
|
+
data: effective === slice ? {
|
|
12786
13020
|
deviceId,
|
|
12787
13021
|
capName,
|
|
12788
13022
|
slice
|
|
13023
|
+
} : {
|
|
13024
|
+
deviceId,
|
|
13025
|
+
capName,
|
|
13026
|
+
slice: { ...effective },
|
|
13027
|
+
confirmed: slice
|
|
12789
13028
|
}
|
|
12790
13029
|
});
|
|
12791
13030
|
}
|
|
@@ -12886,15 +13125,15 @@ var CommandObserverRegistry = class {
|
|
|
12886
13125
|
} catch {}
|
|
12887
13126
|
}
|
|
12888
13127
|
};
|
|
12889
|
-
var registry;
|
|
13128
|
+
var registry$1;
|
|
12890
13129
|
/** The process-wide registry. */
|
|
12891
13130
|
function getCommandObserverRegistry() {
|
|
12892
|
-
registry ??= new CommandObserverRegistry();
|
|
12893
|
-
return registry;
|
|
13131
|
+
registry$1 ??= new CommandObserverRegistry();
|
|
13132
|
+
return registry$1;
|
|
12894
13133
|
}
|
|
12895
13134
|
/** Test seam: forget every subscriber. */
|
|
12896
13135
|
function __resetCommandObserverRegistryForTests() {
|
|
12897
|
-
registry = void 0;
|
|
13136
|
+
registry$1 = void 0;
|
|
12898
13137
|
}
|
|
12899
13138
|
function isRecord(value) {
|
|
12900
13139
|
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
@@ -13074,6 +13313,110 @@ function runObservedCommand(sink, facts, call) {
|
|
|
13074
13313
|
throw err;
|
|
13075
13314
|
}
|
|
13076
13315
|
}
|
|
13316
|
+
//#endregion
|
|
13317
|
+
//#region src/kernel/command-hold-overrides.ts
|
|
13318
|
+
/** The source key of an in-process registration. */
|
|
13319
|
+
var IN_PROCESS_HOLD_SOURCE = "in-process";
|
|
13320
|
+
/** The source key of a forked child's registrations. */
|
|
13321
|
+
function childHoldSource(childId) {
|
|
13322
|
+
return `child:${childId}`;
|
|
13323
|
+
}
|
|
13324
|
+
/** The options a child's cap descriptors carry, one entry per device cap. */
|
|
13325
|
+
function childCommandHoldEntries(caps) {
|
|
13326
|
+
const out = [];
|
|
13327
|
+
for (const cap of caps) {
|
|
13328
|
+
if (cap.deviceId === void 0 || cap.commandHolds === void 0) continue;
|
|
13329
|
+
out.push({
|
|
13330
|
+
deviceId: cap.deviceId,
|
|
13331
|
+
capName: cap.capName,
|
|
13332
|
+
commands: cap.commandHolds
|
|
13333
|
+
});
|
|
13334
|
+
}
|
|
13335
|
+
return out;
|
|
13336
|
+
}
|
|
13337
|
+
function keyOf$1(deviceId, capName) {
|
|
13338
|
+
return `${deviceId}|${capName}`;
|
|
13339
|
+
}
|
|
13340
|
+
var CommandHoldOverrideRegistry = class {
|
|
13341
|
+
bySource = /* @__PURE__ */ new Map();
|
|
13342
|
+
/** Record (or replace) one device cap's options from `source`. */
|
|
13343
|
+
set(source, entry) {
|
|
13344
|
+
const perSource = this.bySource.get(source) ?? /* @__PURE__ */ new Map();
|
|
13345
|
+
perSource.set(keyOf$1(entry.deviceId, entry.capName), entry.commands);
|
|
13346
|
+
this.bySource.set(source, perSource);
|
|
13347
|
+
}
|
|
13348
|
+
/** Forget one device cap's options from `source`. */
|
|
13349
|
+
delete(source, deviceId, capName) {
|
|
13350
|
+
const perSource = this.bySource.get(source);
|
|
13351
|
+
if (perSource === void 0) return;
|
|
13352
|
+
perSource.delete(keyOf$1(deviceId, capName));
|
|
13353
|
+
if (perSource.size === 0) this.bySource.delete(source);
|
|
13354
|
+
}
|
|
13355
|
+
/** Replace everything `source` reported with `entries` (an empty list forgets the source). */
|
|
13356
|
+
replaceSource(source, entries) {
|
|
13357
|
+
if (entries.length === 0) {
|
|
13358
|
+
this.bySource.delete(source);
|
|
13359
|
+
return;
|
|
13360
|
+
}
|
|
13361
|
+
this.bySource.set(source, new Map(entries.map((e) => [keyOf$1(e.deviceId, e.capName), e.commands])));
|
|
13362
|
+
}
|
|
13363
|
+
/** The options for a device cap, from whichever source registered it; `undefined` = default. */
|
|
13364
|
+
get(deviceId, capName) {
|
|
13365
|
+
const key = keyOf$1(deviceId, capName);
|
|
13366
|
+
for (const perSource of this.bySource.values()) {
|
|
13367
|
+
const found = perSource.get(key);
|
|
13368
|
+
if (found !== void 0) return found;
|
|
13369
|
+
}
|
|
13370
|
+
}
|
|
13371
|
+
};
|
|
13372
|
+
var registry;
|
|
13373
|
+
/** The process-wide registry. */
|
|
13374
|
+
function getCommandHoldOverrideRegistry() {
|
|
13375
|
+
registry ??= new CommandHoldOverrideRegistry();
|
|
13376
|
+
return registry;
|
|
13377
|
+
}
|
|
13378
|
+
//#endregion
|
|
13379
|
+
//#region src/builtins/device-manager/command-holds-wiring.ts
|
|
13380
|
+
/**
|
|
13381
|
+
* Arms the command hold (D1061) from the D1022 command seams.
|
|
13382
|
+
*
|
|
13383
|
+
* Every device command the hub sees — its tRPC mount, the UDS parent for a
|
|
13384
|
+
* forked addon's `ctx.api`, an in-process addon's `ctx.api` — reaches the
|
|
13385
|
+
* process-wide observer registry BEFORE the call runs. Here each one resolves
|
|
13386
|
+
* what it leads to (the vocabulary's effects under the provider's option) on
|
|
13387
|
+
* the slice the device last reported, and the mirror holds it; a refused call
|
|
13388
|
+
* rolls the hold back at once.
|
|
13389
|
+
*
|
|
13390
|
+
* Telemetry in, never a gate (D8): a throw here costs the hold, never the call.
|
|
13391
|
+
*/
|
|
13392
|
+
/** Subscribe the hold to the command observations; returns the unsubscribe. */
|
|
13393
|
+
function startCommandHolds(deps) {
|
|
13394
|
+
const optionsFor = deps.optionsFor ?? ((deviceId, capName) => getCommandHoldOverrideRegistry().get(deviceId, capName));
|
|
13395
|
+
const unsubscribe = getCommandObserverRegistry().subscribe((obs) => {
|
|
13396
|
+
try {
|
|
13397
|
+
const current = deps.mirror.capSlice(obs.deviceId, obs.capName, "confirmed") ?? void 0;
|
|
13398
|
+
const shown = deps.mirror.capSlice(obs.deviceId, obs.capName) ?? void 0;
|
|
13399
|
+
const option = optionsFor(obs.deviceId, obs.capName)?.[obs.method];
|
|
13400
|
+
const hold = resolveCommandHold(obs.capName, obs.method, obs.args, current, option, shown);
|
|
13401
|
+
if (hold === null) return;
|
|
13402
|
+
const token = deps.mirror.holdCommand({
|
|
13403
|
+
deviceId: obs.deviceId,
|
|
13404
|
+
capName: obs.capName,
|
|
13405
|
+
method: obs.method,
|
|
13406
|
+
effects: hold.effects,
|
|
13407
|
+
holdMs: hold.holdMs
|
|
13408
|
+
});
|
|
13409
|
+
if (token === null) return;
|
|
13410
|
+
obs.outcome?.catch(() => deps.mirror.releaseCommand(token, "refused"));
|
|
13411
|
+
} catch (err) {
|
|
13412
|
+
deps.logger.error(`command hold: arming ${obs.capName}.${obs.method} failed: ${err instanceof Error ? err.message : String(err)}`, { tags: { deviceId: obs.deviceId } });
|
|
13413
|
+
}
|
|
13414
|
+
});
|
|
13415
|
+
return () => {
|
|
13416
|
+
unsubscribe();
|
|
13417
|
+
deps.mirror.disposeHolds();
|
|
13418
|
+
};
|
|
13419
|
+
}
|
|
13077
13420
|
var REDACTED = "***";
|
|
13078
13421
|
var ROUTING_KEYS = new Set([
|
|
13079
13422
|
"deviceId",
|
|
@@ -13992,6 +14335,8 @@ var DeviceManagerAddon = class extends BaseAddon {
|
|
|
13992
14335
|
stateMirrorImpl = null;
|
|
13993
14336
|
/** The transition audit (D1022): command + mirror correlation, shipped to device-history. */
|
|
13994
14337
|
transitions = null;
|
|
14338
|
+
/** Unsubscribes the command hold (D1061). */
|
|
14339
|
+
stopCommandHolds = null;
|
|
13995
14340
|
/**
|
|
13996
14341
|
* Removes the claimed-status overlay this addon installed on the capability
|
|
13997
14342
|
* registry (D663, S3): `getStatus` of a claimed cap answers the mirror for
|
|
@@ -14338,6 +14683,10 @@ var DeviceManagerAddon = class extends BaseAddon {
|
|
|
14338
14683
|
const metaStore = new DeviceMetaStore(settings, registry, deviceRows, this.addonStoreWriteLock);
|
|
14339
14684
|
this.stateMirrorImpl = new DeviceStateMirror(this.ctx);
|
|
14340
14685
|
const stateMirror = this.stateMirrorImpl;
|
|
14686
|
+
this.stopCommandHolds = startCommandHolds({
|
|
14687
|
+
mirror: stateMirror,
|
|
14688
|
+
logger: this.ctx.logger.child("command-holds")
|
|
14689
|
+
});
|
|
14341
14690
|
this.transitions = startDeviceTransitions({
|
|
14342
14691
|
mirror: stateMirror,
|
|
14343
14692
|
logger: this.ctx.logger.child("transitions"),
|
|
@@ -14632,13 +14981,13 @@ var DeviceManagerAddon = class extends BaseAddon {
|
|
|
14632
14981
|
return stateMirror.snapshotForDevice(input.deviceId);
|
|
14633
14982
|
},
|
|
14634
14983
|
getCapSlice: async (input) => {
|
|
14635
|
-
return stateMirror.capSlice(input.deviceId, input.capName);
|
|
14984
|
+
return stateMirror.capSlice(input.deviceId, input.capName, input.confirmed === true ? "confirmed" : "effective");
|
|
14636
14985
|
},
|
|
14637
14986
|
getNativeCapSlice: async (input) => {
|
|
14638
14987
|
return stateMirror.nativeSlice(input.deviceId, input.capName);
|
|
14639
14988
|
},
|
|
14640
|
-
getAllSnapshots: async () => {
|
|
14641
|
-
return stateMirror.allSnapshots();
|
|
14989
|
+
getAllSnapshots: async (input) => {
|
|
14990
|
+
return stateMirror.allSnapshots(input?.confirmed === true ? "confirmed" : "effective");
|
|
14642
14991
|
},
|
|
14643
14992
|
setCapSlice: async (input) => {
|
|
14644
14993
|
const { deviceId, capName, slice } = input;
|
|
@@ -14736,6 +15085,8 @@ var DeviceManagerAddon = class extends BaseAddon {
|
|
|
14736
15085
|
this.templateActions = null;
|
|
14737
15086
|
await this.transitions?.stop();
|
|
14738
15087
|
this.transitions = null;
|
|
15088
|
+
this.stopCommandHolds?.();
|
|
15089
|
+
this.stopCommandHolds = null;
|
|
14739
15090
|
this.removalCleanupImpl?.dispose();
|
|
14740
15091
|
this.removalCleanupImpl = null;
|
|
14741
15092
|
this.removalHooksCleanupImpl?.dispose();
|
|
@@ -14750,4 +15101,4 @@ var DeviceManagerAddon = class extends BaseAddon {
|
|
|
14750
15101
|
}
|
|
14751
15102
|
};
|
|
14752
15103
|
//#endregion
|
|
14753
|
-
export { DeviceManagerAddon, DeviceManagerAddon as default,
|
|
15104
|
+
export { DeviceManagerAddon, DeviceManagerAddon as default, CommandObserverRegistry as a, commandActorFromContext as c, reportCommand as d, runObservedCommand as f, setWrapperActive as g, readDeviceOrThrow as h, getCommandHoldOverrideRegistry as i, commandObserverLink as l, createDeviceSettingsStore as m, mergeAggregates, childCommandHoldEntries as n, __resetCommandObserverRegistryForTests as o, observable as p, childHoldSource as r, addonCommandActor as s, IN_PROCESS_HOLD_SOURCE as t, getCommandObserverRegistry as u };
|
|
@@ -3,8 +3,16 @@ import type { DeviceManagerSettings } from "./device-meta-store.js";
|
|
|
3
3
|
import { type RuntimeStateSchemaLookup } from "./device-state-claim-views.js";
|
|
4
4
|
import { type MergedSlice, type OwnedCap, type OwnedCaps } from "./field-ownership.js";
|
|
5
5
|
import { type MirrorWriteHold } from "./mirror-row-writer.js";
|
|
6
|
+
import { type ArmRequest, type HoldRelease } from "./command-holds.js";
|
|
6
7
|
import { type RuntimeStatePolicyLookup } from "./runtime-state-persist-gate.js";
|
|
7
8
|
/**
|
|
9
|
+
* Which slice a read wants (D1061): `effective` is what a UI or an exporter
|
|
10
|
+
* shows — a held command's value over the device's; `confirmed` is what the
|
|
11
|
+
* device reported (or a claim's merge), the only view history, automations and
|
|
12
|
+
* transition records read.
|
|
13
|
+
*/
|
|
14
|
+
export type SliceView = "effective" | "confirmed";
|
|
15
|
+
/**
|
|
8
16
|
* What the seed consults first: the claims index (Task 6). It is written
|
|
9
17
|
* BEFORE the row, so a loaded index is a superset of the rows' claims and a
|
|
10
18
|
* device it does not name has nothing to merge — no row read (D447).
|
|
@@ -42,6 +50,8 @@ export declare class DeviceStateMirror {
|
|
|
42
50
|
private readonly stateMirror;
|
|
43
51
|
/** The claims and the merged view of every claimed cap (D663). */
|
|
44
52
|
private readonly claims;
|
|
53
|
+
/** Commanded values shown before the device confirms them (D1061). Memory only. */
|
|
54
|
+
private readonly holds;
|
|
45
55
|
/**
|
|
46
56
|
* Devices whose CLAIMS are known: the row was read, or a loaded claims index
|
|
47
57
|
* vouched that it names none (D447). This is a READ-path fact — what a
|
|
@@ -67,6 +77,16 @@ export declare class DeviceStateMirror {
|
|
|
67
77
|
constructor(ctx: AddonContext, policyFor?: RuntimeStatePolicyLookup, schemaFor?: RuntimeStateSchemaLookup);
|
|
68
78
|
/** Set once by the device-manager: told, after the mirror stored it, of every native slice that actually changed (D1022). */
|
|
69
79
|
setTransitionTap(tap: SliceChangeTap | null): void;
|
|
80
|
+
/**
|
|
81
|
+
* Hold what a command leads to: the effective slice shows it at once (and
|
|
82
|
+
* `DeviceStateChanged` carries it), the stored, persisted and recorded slice
|
|
83
|
+
* does not change. Returns the token {@link releaseCommand} takes, or `null`.
|
|
84
|
+
*/
|
|
85
|
+
holdCommand(request: ArmRequest): number | null;
|
|
86
|
+
/** End a command's hold: refused (rolled back at once) or unconfirmed (at the limit). */
|
|
87
|
+
releaseCommand(token: number, reason: HoldRelease): void;
|
|
88
|
+
/** Stop the hold timers (shutdown). */
|
|
89
|
+
disposeHolds(): void;
|
|
70
90
|
/** The native slice the mirror holds for `capName`, as a read-only view. */
|
|
71
91
|
currentSlice(deviceId: number, capName: string): Readonly<Record<string, unknown>> | undefined;
|
|
72
92
|
/**
|
|
@@ -255,18 +275,22 @@ export declare class DeviceStateMirror {
|
|
|
255
275
|
* `true` — a brief transient window, same as `resolveDeviceOnline`.
|
|
256
276
|
*/
|
|
257
277
|
resolveDeviceProbed(deviceId: number): boolean;
|
|
258
|
-
/** The
|
|
259
|
-
*
|
|
260
|
-
|
|
261
|
-
|
|
278
|
+
/** The slices of a device: native for an unclaimed cap, the merge for a
|
|
279
|
+
* claimed one (a held cap is not reported) — and, in the `effective` view,
|
|
280
|
+
* a commanded value over either (D1061). */
|
|
281
|
+
snapshotForDevice(deviceId: number, view?: SliceView): Record<string, Record<string, unknown>>;
|
|
282
|
+
/** One cap's slice in `view`, cloned. Null when the device has never written
|
|
262
283
|
* it — callers read that as "the cap has no state", never as an empty slice —
|
|
263
284
|
* and null while a claim holds it. */
|
|
264
|
-
capSlice(deviceId: number, cap: string): Record<string, unknown> | null;
|
|
285
|
+
capSlice(deviceId: number, cap: string, view?: SliceView): Record<string, unknown> | null;
|
|
286
|
+
/** What the device reported for the cap, or the claim's merge — never a hold. Not cloned. */
|
|
287
|
+
private baseSlice;
|
|
288
|
+
private viewOf;
|
|
265
289
|
/** The device's NATIVE slices — what the row stores under the cap names. */
|
|
266
290
|
private nativeSnapshotForDevice;
|
|
267
291
|
/** Whole-system mirror dump. Backs `deviceState.getAllSnapshots` — one
|
|
268
292
|
* round-trip for a warm boot instead of N per-device calls. */
|
|
269
|
-
allSnapshots(): Record<string, Record<string, Record<string, unknown>>>;
|
|
293
|
+
allSnapshots(view?: SliceView): Record<string, Record<string, Record<string, unknown>>>;
|
|
270
294
|
/**
|
|
271
295
|
* The `workload` cap's events (#585): judged from the PUBLIC slice like the
|
|
272
296
|
* running flip, so a provider only writes its state. The first state seen is
|
|
@@ -276,9 +300,11 @@ export declare class DeviceStateMirror {
|
|
|
276
300
|
/** Remember a restored running bit so the first public merge does not emit a flip. */
|
|
277
301
|
private seedRunningFlip;
|
|
278
302
|
/**
|
|
279
|
-
* The PUBLIC event:
|
|
280
|
-
*
|
|
281
|
-
* `
|
|
303
|
+
* The PUBLIC event: `{ deviceId, capName, slice }` for every device, claimed
|
|
304
|
+
* or not; `slice` is the EFFECTIVE slice. While a command hold changes it
|
|
305
|
+
* (D1061), `confirmed` carries the slice without the hold — what history,
|
|
306
|
+
* automations and the edge detectors below read. The native shadow of a
|
|
307
|
+
* claim never rides here (D224) — see `emitNativeShadow`.
|
|
282
308
|
*/
|
|
283
309
|
private emitStateChanged;
|
|
284
310
|
/**
|
|
@@ -3,7 +3,7 @@ Object.defineProperties(exports, {
|
|
|
3
3
|
[Symbol.toStringTag]: { value: "Module" }
|
|
4
4
|
});
|
|
5
5
|
require("../../chunk-Cek0wNdY.js");
|
|
6
|
-
const require_dist = require("../../dist-
|
|
6
|
+
const require_dist = require("../../dist-CCd8IeIU.js");
|
|
7
7
|
const require_formatter = require("../../formatter-xbxeV4GD.js");
|
|
8
8
|
//#region src/builtins/hub-forwarder/hub-forwarder-destination.ts
|
|
9
9
|
var DEFAULT_OUTBOUND_BUFFER_SIZE = 500;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { aa as logDestinationCapability, hc as BaseAddon } from "../../dist-D7t8wLTF.mjs";
|
|
2
2
|
import { t as formatLogLine } from "../../formatter-DkYZ4LXp.mjs";
|
|
3
3
|
//#region src/builtins/hub-forwarder/hub-forwarder-destination.ts
|
|
4
4
|
var DEFAULT_OUTBOUND_BUFFER_SIZE = 500;
|