@camstack/server 1.2.785 → 1.2.786
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 +7 -0
- package/dist/api/core/cap-providers.js +44 -7
- package/dist/api/trpc/generated-cap-routers.js +0 -9
- package/package.json +39 -11
- package/system/dist/addon-runner.js +11 -2
- package/system/dist/addon-runner.mjs +12 -3
- package/system/dist/{agent-https-CACfLh65.mjs → agent-https-D779EYj3.mjs} +1 -1
- package/system/dist/{agent-https-B7lqIrF1.js → agent-https-snFEmSqQ.js} +1 -1
- 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/composed-device.d.ts +16 -0
- package/system/dist/builtins/composer/composer.addon.js +62 -13
- package/system/dist/builtins/composer/composer.addon.mjs +62 -13
- 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/actions-service.d.ts +16 -0
- package/system/dist/builtins/core-blocks/core-blocks.addon.js +235 -37
- package/system/dist/builtins/core-blocks/core-blocks.addon.mjs +235 -37
- package/system/dist/builtins/core-blocks/migrations/fountain-drink-drop.d.ts +21 -0
- package/system/dist/builtins/core-blocks/migrations/index.d.ts +1 -0
- package/system/dist/builtins/device-history/device-history.addon.js +2 -2
- package/system/dist/builtins/device-history/device-history.addon.mjs +2 -2
- package/system/dist/builtins/device-manager/device-manager.addon.js +1 -1
- package/system/dist/builtins/device-manager/device-manager.addon.mjs +1 -1
- 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 +2 -2
- package/system/dist/builtins/local-network/local-network.addon.mjs +2 -2
- package/system/dist/builtins/loki-logging/index.js +2 -2
- package/system/dist/builtins/loki-logging/index.mjs +2 -2
- 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/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 +284 -284
- 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-Dw82x5UW.mjs → capture-engine-DkTEWrRe.mjs} +1 -1
- package/system/dist/{capture-engine-n5mJUHzf.js → capture-engine-NZ11ORZS.js} +1 -1
- package/system/dist/{composition-sources-Cdow6PNn.js → composition-sources-B6GYTy_7.js} +1 -1
- package/system/dist/{composition-sources-D-bbLadz.mjs → composition-sources-B9-lkIvO.mjs} +1 -1
- package/system/dist/{constants-C6UsfDdP.mjs → constants--9ui1LK0.mjs} +1 -1
- package/system/dist/{constants-Dmc-T4Zw.js → constants-DR8hdi45.js} +1 -1
- package/system/dist/{device-ca-OQqtK7Yy.mjs → device-ca-D-7tAHJ_.mjs} +1 -1
- package/system/dist/{device-ca-v8lGdWVk.js → device-ca-sIFmKkGM.js} +1 -1
- package/system/dist/{dist-CRWinpyX.mjs → dist-D-iGSnX_.mjs} +1039 -821
- package/system/dist/{dist-1X5ccoX2.js → dist-h3Yla8gE.js} +1092 -820
- package/system/dist/file-host-worker.js +1 -1
- package/system/dist/file-host-worker.mjs +1 -1
- package/system/dist/{hub-mdns-ciao-hBZgojNT.js → hub-mdns-ciao-C5DkUEZF.js} +2 -2
- package/system/dist/{hub-mdns-ciao-BQqm5eSM.mjs → hub-mdns-ciao-DuEfM0fI.mjs} +2 -2
- package/system/dist/index.js +19 -10
- package/system/dist/index.mjs +20 -11
- package/system/dist/kernel/moleculer/migration-api-facade.d.ts +2 -0
- package/system/dist/kernel/transport/local-child-client.d.ts +9 -0
- package/system/dist/{legacy-integration-rows-door-B7bwfRev.mjs → legacy-integration-rows-door-BTdhD-Yp.mjs} +1 -1
- package/system/dist/{legacy-integration-rows-door-BUjw8YoW.js → legacy-integration-rows-door-DTDD5wwC.js} +1 -1
- package/system/dist/{restore-archive-D9vM-Kzb.js → restore-archive-CkAD_-E9.js} +1 -1
- package/system/dist/{restore-archive-TST7tvBk.mjs → restore-archive-DQWz5Wp-.mjs} +82 -82
- package/system/dist/{wal-maintenance-wfVwXxO4.js → wal-maintenance-CB-O-GPP.js} +0 -0
- package/system/dist/{wal-maintenance-C7dJSaPS.mjs → wal-maintenance-DouX1XsY.mjs} +0 -0
- package/system/package.json +1 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { $
|
|
2
|
-
import { i as parseDeviceStateChanged, n as normalizedNativeOwner, r as isRecord$4 } from "../../composition-sources-
|
|
3
|
-
import { i as capSeriesKey } from "../../capture-engine-
|
|
1
|
+
import { $n as coverCapability, Ao as openReset, Ar as fanOutTargets, Ca as sharedActuatorFeatures, Co as evaluateStatistic, Cr as evaluateCompositionField, Do as isForwardInputRef, Dr as expressionContainsBuiltinCall, Ec as EventCategory, En as brightnessCapability, Eo as integrateReading, Fo as toExpressionValue, Gn as compositionFieldKey, Ii as parseColorInput, J as DeclaredDevices, Ji as processTimeZoneOr, Lo as BaseAddon, Mo as planResetTier, Mr as featureForwards, No as planStatisticTier, On as buildCapabilityLookup, Oo as isHistoryHelper, Os as createEvent, Po as statisticCadenceMs, Pt as PetFountainStatusSchema, Ri as petFountainCapability, Rr as groupCommandsCapability, So as evaluateDerivative, Ta as sharedColorModes, Tc as errMsg, To as historyRetentionFromSettings, Vi as planComposition, Vn as colorCapability, Wn as composerCapability, Ya as valveCapability, _i as mediaPlayerCapability, _o as compositionItemFieldPath, at as FanDirectionSchema, bi as methodRefusal, bo as createStatefulExpressionMemory, co as HISTORY_SLOW_MS, da as resolveMutate, do as MINUTE_MS, go as compositionFeatureEnabled, h as BaseDevice, ha as runFanOut, ho as composedDeviceStableId, i as ACTUATOR_TEMPLATE_IDS, jo as openStatistic, k as ConsumableItemSchema, ko as nextLocalMidnight, kr as fanControlCapability, lo as HOUR_MS, lt as GroupCommandResultSchema, mo as composedDeviceRef, mt as HvacModeSchema, oo as DEFAULT_HISTORY_RETENTION, or as declaredSeriesKind, po as cloneStatefulExpressionMemory, qn as consumablesCapability, qs as isReadingQuantity, r as ACTUATOR_METHODS, ro as COMPOSER_ADDON_ID, s as ALL_CAPABILITY_DEFINITIONS, so as HISTORY_FAST_MS, ti as kebabToCamel, ui as lockControlCapability, vi as mediaPlayerFeaturesOfRoles, vo as compositionSliceKey, wa as sharedActuatorMethods, wc as DeviceType, wi as motionCapability, x as COMPOSED_ITEM_FIXED_FIELDS, xo as disarmRoseMemory, yo as compositionSourceKey, za as switchCapability, zi as petFountainWaterItem, zn as climateControlCapability, zr as groupTemplate } from "../../dist-D-iGSnX_.mjs";
|
|
2
|
+
import { i as parseDeviceStateChanged, n as normalizedNativeOwner, r as isRecord$4 } from "../../composition-sources-B9-lkIvO.mjs";
|
|
3
|
+
import { i as capSeriesKey } from "../../capture-engine-DkTEWrRe.mjs";
|
|
4
4
|
import { i as DAY_MS, t as DEFAULT_RETENTION } from "../../retention-B9l9TnGE.mjs";
|
|
5
5
|
import { z } from "zod";
|
|
6
6
|
//#region src/builtins/composer/actuator-invoke.ts
|
|
@@ -122,6 +122,12 @@ var GROUP_COMMAND_TYPES = new Set([
|
|
|
122
122
|
function present(args) {
|
|
123
123
|
return Object.fromEntries(Object.entries(args).filter(([, value]) => value !== void 0));
|
|
124
124
|
}
|
|
125
|
+
/** What the derived water item reads from the `pet-fountain` slice, and the clock it is stamped with. */
|
|
126
|
+
var TANK_READING = PetFountainStatusSchema.pick({
|
|
127
|
+
waterLevel: true,
|
|
128
|
+
empty: true,
|
|
129
|
+
lastFetchedAt: true
|
|
130
|
+
});
|
|
125
131
|
var COMPOSED_DEVICE_CONFIG_SCHEMA = z.object({});
|
|
126
132
|
/** What a command carries: the caller's input without `deviceId` (the composed device is the dispatch key). */
|
|
127
133
|
function commandInput(input) {
|
|
@@ -149,11 +155,16 @@ function sliceBoolean(slice, field) {
|
|
|
149
155
|
var ComposedDevice = class extends BaseDevice {
|
|
150
156
|
sharedFeatures = [];
|
|
151
157
|
extraCaps = /* @__PURE__ */ new Set();
|
|
158
|
+
/** Whether this device's tank is also a `water` consumable (derived, never bound). */
|
|
159
|
+
derivesWater;
|
|
160
|
+
/** The `consumables` items the composition last wrote — the derived water item is added to these. */
|
|
161
|
+
composedItems = [];
|
|
152
162
|
get features() {
|
|
153
163
|
return this.sharedFeatures;
|
|
154
164
|
}
|
|
155
165
|
constructor(ctx, type, caps) {
|
|
156
166
|
super(ctx, COMPOSED_DEVICE_CONFIG_SCHEMA, { type });
|
|
167
|
+
this.derivesWater = type === DeviceType.PetFountain;
|
|
157
168
|
for (const cap of caps) {
|
|
158
169
|
if (cap.name === motionCapability.name) {
|
|
159
170
|
const read = () => this.runtimeState.getCapState(motionCapability.name);
|
|
@@ -169,6 +180,7 @@ var ComposedDevice = class extends BaseDevice {
|
|
|
169
180
|
ctx.registerNativeCap(cap, this.commandProvider(cap));
|
|
170
181
|
}
|
|
171
182
|
if (GROUP_COMMAND_TYPES.has(type)) ctx.registerNativeCap(groupCommandsCapability, {});
|
|
183
|
+
if (this.derivesWater && !caps.some((cap) => cap.name === consumablesCapability.name)) ctx.registerNativeCap(consumablesCapability, { reset: (input) => this.dispatch("consumables", "reset", commandInput(input)) });
|
|
172
184
|
this.markOnline(false);
|
|
173
185
|
}
|
|
174
186
|
/**
|
|
@@ -335,19 +347,20 @@ var ComposedDevice = class extends BaseDevice {
|
|
|
335
347
|
});
|
|
336
348
|
}
|
|
337
349
|
seed(capName, slice) {
|
|
338
|
-
|
|
339
|
-
this.runtimeState.setCapState(capName, { ...slice });
|
|
340
|
-
return { ok: true };
|
|
341
|
-
} catch (err) {
|
|
342
|
-
return {
|
|
343
|
-
ok: false,
|
|
344
|
-
error: errMsg(err)
|
|
345
|
-
};
|
|
346
|
-
}
|
|
350
|
+
return this.writeSlice("seed", capName, slice);
|
|
347
351
|
}
|
|
348
352
|
patch(capName, patch) {
|
|
353
|
+
return this.writeSlice("patch", capName, patch);
|
|
354
|
+
}
|
|
355
|
+
writeSlice(op, capName, slice) {
|
|
356
|
+
const own = this.writeCap(op, capName, this.derivesWater ? this.withWater(capName, slice) : slice);
|
|
357
|
+
if (!own.ok || !this.derivesWater || capName !== petFountainCapability.name) return own;
|
|
358
|
+
return this.refreshWater();
|
|
359
|
+
}
|
|
360
|
+
writeCap(op, capName, slice) {
|
|
349
361
|
try {
|
|
350
|
-
this.runtimeState.
|
|
362
|
+
if (op === "seed") this.runtimeState.setCapState(capName, { ...slice });
|
|
363
|
+
else this.runtimeState.patchCapState(capName, { ...slice });
|
|
351
364
|
return { ok: true };
|
|
352
365
|
} catch (err) {
|
|
353
366
|
return {
|
|
@@ -356,6 +369,42 @@ var ComposedDevice = class extends BaseDevice {
|
|
|
356
369
|
};
|
|
357
370
|
}
|
|
358
371
|
}
|
|
372
|
+
/**
|
|
373
|
+
* The ONE place a fountain's tank becomes a consumable: the composition's own
|
|
374
|
+
* `consumables` items plus a `water` item derived from the `pet-fountain` slice
|
|
375
|
+
* (`petFountainWaterItem`). A composition that names its own `water` item keeps it.
|
|
376
|
+
*/
|
|
377
|
+
withWater(capName, slice) {
|
|
378
|
+
if (capName !== consumablesCapability.name) return slice;
|
|
379
|
+
const parsed = ConsumableItemSchema.array().safeParse(slice["items"]);
|
|
380
|
+
if (parsed.success) this.composedItems = parsed.data;
|
|
381
|
+
return {
|
|
382
|
+
...slice,
|
|
383
|
+
items: this.itemsWithWater()
|
|
384
|
+
};
|
|
385
|
+
}
|
|
386
|
+
fountainTank() {
|
|
387
|
+
const tank = TANK_READING.safeParse(this.runtimeState.getCapState(petFountainCapability.name));
|
|
388
|
+
return tank.success ? tank.data : null;
|
|
389
|
+
}
|
|
390
|
+
itemsWithWater() {
|
|
391
|
+
const tank = this.fountainTank();
|
|
392
|
+
if (tank === null || this.composedItems.some((item) => item.key === "water")) return this.composedItems;
|
|
393
|
+
return [...this.composedItems, petFountainWaterItem(tank)];
|
|
394
|
+
}
|
|
395
|
+
/** The fountain slice moved: re-publish the consumables with the new water item. */
|
|
396
|
+
refreshWater() {
|
|
397
|
+
const tank = this.fountainTank();
|
|
398
|
+
if (tank === null) return { ok: true };
|
|
399
|
+
const known = this.runtimeState.getCapState(consumablesCapability.name);
|
|
400
|
+
const items = this.itemsWithWater();
|
|
401
|
+
if (known !== void 0 && JSON.stringify(known["items"]) === JSON.stringify(items)) return { ok: true };
|
|
402
|
+
return this.writeCap(known === void 0 ? "seed" : "patch", consumablesCapability.name, {
|
|
403
|
+
items,
|
|
404
|
+
lastChangedAt: tank.lastFetchedAt,
|
|
405
|
+
lastFetchedAt: tank.lastFetchedAt
|
|
406
|
+
});
|
|
407
|
+
}
|
|
359
408
|
setAvailable(available) {
|
|
360
409
|
this.markOnline(available);
|
|
361
410
|
}
|
|
@@ -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-h3Yla8gE.js");
|
|
7
7
|
const require_formatter = require("../../formatter-xbxeV4GD.js");
|
|
8
8
|
//#region src/builtins/console-logging/console-destination.ts
|
|
9
9
|
var LEVEL_RANK = {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Lo as BaseAddon, fi as logDestinationCapability } from "../../dist-D-iGSnX_.mjs";
|
|
2
2
|
import { t as formatLogLine } from "../../formatter-DkYZ4LXp.mjs";
|
|
3
3
|
//#region src/builtins/console-logging/console-destination.ts
|
|
4
4
|
var LEVEL_RANK = {
|
|
@@ -27,6 +27,10 @@ export interface ActionsServiceDeps {
|
|
|
27
27
|
readonly newRunId?: () => string;
|
|
28
28
|
/** What the caps say about quantity params; the generated registry by default. */
|
|
29
29
|
readonly units?: UnitResolver;
|
|
30
|
+
/** The longest a run may last; `ACTION_RUN_MAX_MS` by default (a test injects a short one). */
|
|
31
|
+
readonly maxRunMs?: number;
|
|
32
|
+
/** How long a stopped run is given to wind down before its call is answered anyway. */
|
|
33
|
+
readonly stopGraceMs?: number;
|
|
30
34
|
}
|
|
31
35
|
type RunInput = Parameters<IActionsProvider["run"]>[0];
|
|
32
36
|
type GetInput = Parameters<IActionsProvider["get"]>[0];
|
|
@@ -42,6 +46,8 @@ export declare class ActionsService implements IActionsProvider {
|
|
|
42
46
|
private readonly units;
|
|
43
47
|
private readonly targets;
|
|
44
48
|
private readonly running;
|
|
49
|
+
private readonly maxRunMs;
|
|
50
|
+
private readonly stopGraceMs;
|
|
45
51
|
constructor(deps: ActionsServiceDeps);
|
|
46
52
|
/** One-shot at boot: stored steps written before D983 are rewritten to the target shape. */
|
|
47
53
|
migrateTargets(): Promise<number>;
|
|
@@ -76,6 +82,14 @@ export declare class ActionsService implements IActionsProvider {
|
|
|
76
82
|
private triggerOf;
|
|
77
83
|
/** Never rejects: a run's failure is its outcome. */
|
|
78
84
|
private execute;
|
|
85
|
+
private timeoutMessage;
|
|
86
|
+
/**
|
|
87
|
+
* The run's ceiling. At `maxRunMs` the run is stopped through the same path
|
|
88
|
+
* an operator's stop takes; a run that does not wind down within the grace
|
|
89
|
+
* (an addon script that ignores the stop) is answered `expired` anyway, so a
|
|
90
|
+
* waiting caller is never held past the limit.
|
|
91
|
+
*/
|
|
92
|
+
private armDeadline;
|
|
79
93
|
private runnableFor;
|
|
80
94
|
/** A ledger write that fails is on the record; it never fails the run it describes. */
|
|
81
95
|
private record;
|
|
@@ -90,6 +104,8 @@ export declare class ActionsService implements IActionsProvider {
|
|
|
90
104
|
action: ActionEntry;
|
|
91
105
|
warnings?: UnitWarning[];
|
|
92
106
|
}>;
|
|
107
|
+
/** An action whose waits alone exceed the run ceiling could never finish: refuse the save. */
|
|
108
|
+
private requireWithinCeiling;
|
|
93
109
|
/**
|
|
94
110
|
* D972: a quantity arg sent as `{ value, unit }` is converted to the unit the
|
|
95
111
|
* method declares; a unit that cannot be that quantity refuses the save; a
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
2
|
const require_chunk = require("../../chunk-Cek0wNdY.js");
|
|
3
|
-
const require_dist = require("../../dist-
|
|
3
|
+
const require_dist = require("../../dist-h3Yla8gE.js");
|
|
4
4
|
const require_read_all_rows$1 = require("../../read-all-rows-CVoO1ONM.js");
|
|
5
|
-
const require_composition_sources = require("../../composition-sources-
|
|
6
|
-
const require_capture_engine = require("../../capture-engine-
|
|
5
|
+
const require_composition_sources = require("../../composition-sources-B6GYTy_7.js");
|
|
6
|
+
const require_capture_engine = require("../../capture-engine-NZ11ORZS.js");
|
|
7
7
|
const require_prefix_range = require("../../prefix-range-D_KueXbQ.js");
|
|
8
8
|
const require_prefix_walk = require("../../prefix-walk-Dv6MLZlM.js");
|
|
9
9
|
let zod = require("zod");
|
|
@@ -1867,6 +1867,110 @@ var CoreBlockStore = class CoreBlockStore {
|
|
|
1867
1867
|
}
|
|
1868
1868
|
};
|
|
1869
1869
|
//#endregion
|
|
1870
|
+
//#region src/builtins/core-blocks/migrations/fountain-drink-drop.ts
|
|
1871
|
+
/**
|
|
1872
|
+
* The drink counters leave the `pet-fountain` feature of a stored composition.
|
|
1873
|
+
*
|
|
1874
|
+
* The cap no longer has `lastDrink`, `currentHourDrink`, `last24hDrink` or
|
|
1875
|
+
* `todayDrink`, nor the `resetDailyConsumption` method (a fountain's tank is now a
|
|
1876
|
+
* `water` consumable derived from `waterLevel`). A fountain composed by the
|
|
1877
|
+
* previous preset still names them as fields and forwards the reset to a button,
|
|
1878
|
+
* which no longer validates. This removes the four fields and the one forward from
|
|
1879
|
+
* the `pet-fountain` feature and nothing else: the pump forward, the other fields,
|
|
1880
|
+
* the other features, the name and the enabled flag are kept.
|
|
1881
|
+
*
|
|
1882
|
+
* Only compositions that BUILD a pet fountain are touched. A row that does not
|
|
1883
|
+
* parse, a code block, a customization of an existing device, and a fountain
|
|
1884
|
+
* already without the counters are left exactly as they are, so a rerun edits
|
|
1885
|
+
* nothing. The block's `updatedAt` moves (it is the version an editor's
|
|
1886
|
+
* `expectedUpdatedAt` is checked against).
|
|
1887
|
+
*/
|
|
1888
|
+
var FOUNTAIN_DRINK_DROP_ID = "core-blocks/2026-11-06-fountain-drink-drop";
|
|
1889
|
+
var DROPPED_FIELDS = [
|
|
1890
|
+
"lastDrink",
|
|
1891
|
+
"currentHourDrink",
|
|
1892
|
+
"last24hDrink",
|
|
1893
|
+
"todayDrink"
|
|
1894
|
+
];
|
|
1895
|
+
var DROPPED_COMMANDS = ["resetDailyConsumption"];
|
|
1896
|
+
function without$1(record, keys) {
|
|
1897
|
+
return Object.fromEntries(Object.entries(record).filter(([key]) => !keys.includes(key)));
|
|
1898
|
+
}
|
|
1899
|
+
/** The composition without the counters, or null when this one has none. */
|
|
1900
|
+
function dropCounters(composition) {
|
|
1901
|
+
if (composition.target.kind !== "new" || composition.target.type !== require_dist.DeviceType.PetFountain) return null;
|
|
1902
|
+
let changed = false;
|
|
1903
|
+
const features = composition.features.map((feature) => {
|
|
1904
|
+
if (feature.kind !== "fields" || feature.cap !== "pet-fountain") return feature;
|
|
1905
|
+
const commands = feature.commands ?? {};
|
|
1906
|
+
if (!(DROPPED_FIELDS.some((key) => key in feature.fields) || DROPPED_COMMANDS.some((key) => key in commands))) return feature;
|
|
1907
|
+
changed = true;
|
|
1908
|
+
return {
|
|
1909
|
+
...feature,
|
|
1910
|
+
fields: without$1(feature.fields, DROPPED_FIELDS),
|
|
1911
|
+
commands: without$1(commands, DROPPED_COMMANDS)
|
|
1912
|
+
};
|
|
1913
|
+
});
|
|
1914
|
+
return changed ? {
|
|
1915
|
+
...composition,
|
|
1916
|
+
features
|
|
1917
|
+
} : null;
|
|
1918
|
+
}
|
|
1919
|
+
function dropFromBlock(block) {
|
|
1920
|
+
const source = block.source;
|
|
1921
|
+
if (source === void 0 || source.kind !== "composition") return null;
|
|
1922
|
+
const composition = dropCounters(source.composition);
|
|
1923
|
+
if (composition === null) return null;
|
|
1924
|
+
return {
|
|
1925
|
+
...block,
|
|
1926
|
+
source: {
|
|
1927
|
+
kind: "composition",
|
|
1928
|
+
composition
|
|
1929
|
+
}
|
|
1930
|
+
};
|
|
1931
|
+
}
|
|
1932
|
+
function rewriteOf$2(row, ports) {
|
|
1933
|
+
const parsed = require_dist.CoreBlockSchema.safeParse(row.data.block);
|
|
1934
|
+
if (!parsed.success) return null;
|
|
1935
|
+
const dropped = dropFromBlock(parsed.data);
|
|
1936
|
+
if (dropped === null) return null;
|
|
1937
|
+
const updatedAt = Math.max(parsed.data.updatedAt + 1, ports.now());
|
|
1938
|
+
const next = require_dist.CoreBlockSchema.safeParse({
|
|
1939
|
+
...dropped,
|
|
1940
|
+
updatedAt
|
|
1941
|
+
});
|
|
1942
|
+
if (!next.success) {
|
|
1943
|
+
ports.warn("core block left as it is: the fountain without drink counters does not validate", {
|
|
1944
|
+
blockId: row.id,
|
|
1945
|
+
error: next.error.message
|
|
1946
|
+
});
|
|
1947
|
+
return null;
|
|
1948
|
+
}
|
|
1949
|
+
return {
|
|
1950
|
+
row,
|
|
1951
|
+
data: {
|
|
1952
|
+
...row.data,
|
|
1953
|
+
updatedAt,
|
|
1954
|
+
block: next.data
|
|
1955
|
+
}
|
|
1956
|
+
};
|
|
1957
|
+
}
|
|
1958
|
+
async function dropFountainDrinkCounters(ports) {
|
|
1959
|
+
const rewrites = (await ports.listBlockRows()).flatMap((row) => {
|
|
1960
|
+
const rewrite = rewriteOf$2(row, ports);
|
|
1961
|
+
return rewrite === null ? [] : [rewrite];
|
|
1962
|
+
});
|
|
1963
|
+
if (rewrites.length === 0) return {
|
|
1964
|
+
outcome: "already-done",
|
|
1965
|
+
summary: { blocks: 0 }
|
|
1966
|
+
};
|
|
1967
|
+
for (const { row, data } of rewrites) await ports.replaceBlockRow(row.id, data, row.rev);
|
|
1968
|
+
return {
|
|
1969
|
+
outcome: "done",
|
|
1970
|
+
summary: { blocks: rewrites.length }
|
|
1971
|
+
};
|
|
1972
|
+
}
|
|
1973
|
+
//#endregion
|
|
1870
1974
|
//#region src/builtins/core-blocks/migrations/helper-to-customize.ts
|
|
1871
1975
|
/**
|
|
1872
1976
|
* The appliance and heater helper compositions become plain Customize
|
|
@@ -2320,37 +2424,56 @@ async function splitPumpCycleFromFountain(ports) {
|
|
|
2320
2424
|
//#endregion
|
|
2321
2425
|
//#region src/builtins/core-blocks/migrations/index.ts
|
|
2322
2426
|
/** The `core-blocks` catalogue (D987): offered to the engine when the hub-resident addon initialises. */
|
|
2323
|
-
var ADDON_MIGRATIONS = [
|
|
2324
|
-
|
|
2325
|
-
|
|
2326
|
-
|
|
2327
|
-
|
|
2328
|
-
|
|
2329
|
-
|
|
2330
|
-
|
|
2331
|
-
|
|
2332
|
-
|
|
2333
|
-
|
|
2334
|
-
|
|
2335
|
-
|
|
2427
|
+
var ADDON_MIGRATIONS = [
|
|
2428
|
+
{
|
|
2429
|
+
meta: {
|
|
2430
|
+
id: PUMP_CYCLE_SPLIT_ID,
|
|
2431
|
+
owner: "core-blocks",
|
|
2432
|
+
level: "addon-state",
|
|
2433
|
+
seq: 1,
|
|
2434
|
+
dependsOn: [],
|
|
2435
|
+
store: "settings",
|
|
2436
|
+
scope: "cluster",
|
|
2437
|
+
onFailure: "block-owner",
|
|
2438
|
+
bodyKind: "procedure",
|
|
2439
|
+
description: "Move the pump duty cycle of a stored pet-fountain composition from the pet-fountain feature to a pump-cycle feature",
|
|
2440
|
+
fixtureMark: "the block createdBy and name, which the migration does not know"
|
|
2441
|
+
},
|
|
2442
|
+
procedure: splitPumpCycleFromFountain
|
|
2336
2443
|
},
|
|
2337
|
-
|
|
2338
|
-
|
|
2339
|
-
|
|
2340
|
-
|
|
2341
|
-
|
|
2342
|
-
|
|
2343
|
-
|
|
2344
|
-
|
|
2345
|
-
|
|
2346
|
-
|
|
2347
|
-
|
|
2348
|
-
|
|
2349
|
-
|
|
2350
|
-
|
|
2444
|
+
{
|
|
2445
|
+
meta: {
|
|
2446
|
+
id: HELPER_TO_CUSTOMIZE_ID,
|
|
2447
|
+
owner: "core-blocks",
|
|
2448
|
+
level: "addon-state",
|
|
2449
|
+
seq: 2,
|
|
2450
|
+
dependsOn: [],
|
|
2451
|
+
store: "settings",
|
|
2452
|
+
scope: "cluster",
|
|
2453
|
+
onFailure: "block-owner",
|
|
2454
|
+
bodyKind: "procedure",
|
|
2455
|
+
description: "Rewrite each stored appliance and heater helper composition into plain Customize features (running-state, power-meter, power-source) with the same threshold, dwells and plugs, and drop the helper spec",
|
|
2456
|
+
fixtureMark: "the marked threshold, start and stop dwell, plug and offSeconds of each helper"
|
|
2457
|
+
},
|
|
2458
|
+
procedure: rewriteHelpersToCustomize
|
|
2351
2459
|
},
|
|
2352
|
-
|
|
2353
|
-
|
|
2460
|
+
{
|
|
2461
|
+
meta: {
|
|
2462
|
+
id: FOUNTAIN_DRINK_DROP_ID,
|
|
2463
|
+
owner: "core-blocks",
|
|
2464
|
+
level: "addon-state",
|
|
2465
|
+
seq: 3,
|
|
2466
|
+
dependsOn: [],
|
|
2467
|
+
store: "settings",
|
|
2468
|
+
scope: "cluster",
|
|
2469
|
+
onFailure: "block-owner",
|
|
2470
|
+
bodyKind: "procedure",
|
|
2471
|
+
description: "Remove the drink counters and the reset-daily-count forward from the pet-fountain feature of each stored fountain composition",
|
|
2472
|
+
fixtureMark: "the block createdBy and name, which the migration does not know"
|
|
2473
|
+
},
|
|
2474
|
+
procedure: dropFountainDrinkCounters
|
|
2475
|
+
}
|
|
2476
|
+
];
|
|
2354
2477
|
//#endregion
|
|
2355
2478
|
//#region src/builtins/core-blocks/runs-ledger.ts
|
|
2356
2479
|
/**
|
|
@@ -2514,9 +2637,13 @@ function isSkip(trace) {
|
|
|
2514
2637
|
*/
|
|
2515
2638
|
/** The ring an Action keeps. */
|
|
2516
2639
|
var ACTION_TRACE_KEEP = 20;
|
|
2640
|
+
/** After a timeout stops a run, the call is answered once the run ended or this long passed. */
|
|
2641
|
+
var STOP_GRACE_MS = 1e4;
|
|
2517
2642
|
/** A run in flight: the stop flag and whatever sleeps it can wake. */
|
|
2518
2643
|
var RunToken = class {
|
|
2519
2644
|
aborted = false;
|
|
2645
|
+
/** Set by the ceiling, so a stopped run is told apart from one the operator stopped. */
|
|
2646
|
+
timedOut = false;
|
|
2520
2647
|
wakers = /* @__PURE__ */ new Set();
|
|
2521
2648
|
sleep(ms) {
|
|
2522
2649
|
return new Promise((resolve) => {
|
|
@@ -2537,6 +2664,9 @@ var RunToken = class {
|
|
|
2537
2664
|
function errorMessage$2(err) {
|
|
2538
2665
|
return err instanceof Error ? err.message : String(err);
|
|
2539
2666
|
}
|
|
2667
|
+
function spanLabel(ms) {
|
|
2668
|
+
return ms < 12e4 ? `${Math.round(ms / 1e3)} seconds` : `${Math.round(ms / 6e4)} minutes`;
|
|
2669
|
+
}
|
|
2540
2670
|
var ActionsService = class {
|
|
2541
2671
|
store;
|
|
2542
2672
|
ledger;
|
|
@@ -2549,6 +2679,8 @@ var ActionsService = class {
|
|
|
2549
2679
|
units;
|
|
2550
2680
|
targets;
|
|
2551
2681
|
running = /* @__PURE__ */ new Map();
|
|
2682
|
+
maxRunMs;
|
|
2683
|
+
stopGraceMs;
|
|
2552
2684
|
constructor(deps) {
|
|
2553
2685
|
this.store = deps.store;
|
|
2554
2686
|
this.ledger = deps.ledger;
|
|
@@ -2558,6 +2690,8 @@ var ActionsService = class {
|
|
|
2558
2690
|
this.logger = deps.logger;
|
|
2559
2691
|
this.now = deps.now ?? Date.now;
|
|
2560
2692
|
this.newRunId = deps.newRunId ?? node_crypto.randomUUID;
|
|
2693
|
+
this.maxRunMs = deps.maxRunMs ?? 36e5;
|
|
2694
|
+
this.stopGraceMs = deps.stopGraceMs ?? STOP_GRACE_MS;
|
|
2561
2695
|
this.units = deps.units ?? require_dist.capUnitResolver(require_dist.ALL_CAPABILITY_DEFINITIONS);
|
|
2562
2696
|
this.targets = new require_dist.ActionTargetResolver(deps.directory, deps.logger);
|
|
2563
2697
|
}
|
|
@@ -2716,8 +2850,9 @@ var ActionsService = class {
|
|
|
2716
2850
|
let outcome = "failed";
|
|
2717
2851
|
let steps = [];
|
|
2718
2852
|
let message;
|
|
2853
|
+
const deadline = this.armDeadline(entry.id, runId, token);
|
|
2719
2854
|
try {
|
|
2720
|
-
const
|
|
2855
|
+
const running = require_dist.runSteps(this.runnableFor(entry, values, token), {
|
|
2721
2856
|
pathPrefix: "steps",
|
|
2722
2857
|
isAborted: () => token.aborted,
|
|
2723
2858
|
abortReason: "the run was stopped",
|
|
@@ -2734,9 +2869,16 @@ var ActionsService = class {
|
|
|
2734
2869
|
});
|
|
2735
2870
|
}
|
|
2736
2871
|
});
|
|
2737
|
-
|
|
2738
|
-
|
|
2739
|
-
|
|
2872
|
+
const result = await Promise.race([running, deadline.expired]);
|
|
2873
|
+
if (result !== "expired") {
|
|
2874
|
+
steps = result.steps;
|
|
2875
|
+
outcome = result.failed ? "failed" : result.aborted ? "aborted" : "ran";
|
|
2876
|
+
message = result.steps.find((s) => s.outcome === "error")?.message;
|
|
2877
|
+
}
|
|
2878
|
+
if (token.timedOut) {
|
|
2879
|
+
outcome = "failed";
|
|
2880
|
+
message = this.timeoutMessage();
|
|
2881
|
+
}
|
|
2740
2882
|
} catch (err) {
|
|
2741
2883
|
message = errorMessage$2(err);
|
|
2742
2884
|
this.logger.error("action run crashed", { meta: {
|
|
@@ -2744,6 +2886,8 @@ var ActionsService = class {
|
|
|
2744
2886
|
runId,
|
|
2745
2887
|
error: message
|
|
2746
2888
|
} });
|
|
2889
|
+
} finally {
|
|
2890
|
+
deadline.disarm();
|
|
2747
2891
|
}
|
|
2748
2892
|
const endedAt = this.now();
|
|
2749
2893
|
const trace = {
|
|
@@ -2769,10 +2913,49 @@ var ActionsService = class {
|
|
|
2769
2913
|
});
|
|
2770
2914
|
return {
|
|
2771
2915
|
runId,
|
|
2772
|
-
outcome,
|
|
2916
|
+
outcome: token.timedOut ? "timed-out" : outcome,
|
|
2773
2917
|
...message === void 0 ? {} : { message }
|
|
2774
2918
|
};
|
|
2775
2919
|
}
|
|
2920
|
+
timeoutMessage() {
|
|
2921
|
+
return `the run reached the ${spanLabel(this.maxRunMs)} limit and was stopped`;
|
|
2922
|
+
}
|
|
2923
|
+
/**
|
|
2924
|
+
* The run's ceiling. At `maxRunMs` the run is stopped through the same path
|
|
2925
|
+
* an operator's stop takes; a run that does not wind down within the grace
|
|
2926
|
+
* (an addon script that ignores the stop) is answered `expired` anyway, so a
|
|
2927
|
+
* waiting caller is never held past the limit.
|
|
2928
|
+
*/
|
|
2929
|
+
armDeadline(actionId, runId, token) {
|
|
2930
|
+
let grace = null;
|
|
2931
|
+
let expire = () => void 0;
|
|
2932
|
+
const expired = new Promise((resolve) => {
|
|
2933
|
+
expire = resolve;
|
|
2934
|
+
});
|
|
2935
|
+
const limit = setTimeout(() => {
|
|
2936
|
+
token.timedOut = true;
|
|
2937
|
+
this.logger.error("action run reached its time limit — stopping it", { meta: {
|
|
2938
|
+
actionId,
|
|
2939
|
+
runId,
|
|
2940
|
+
maxRunMs: this.maxRunMs
|
|
2941
|
+
} });
|
|
2942
|
+
this.stop({ actionId }).catch((err) => {
|
|
2943
|
+
this.logger.warn("stopping a timed-out action run failed", { meta: {
|
|
2944
|
+
actionId,
|
|
2945
|
+
runId,
|
|
2946
|
+
error: errorMessage$2(err)
|
|
2947
|
+
} });
|
|
2948
|
+
});
|
|
2949
|
+
grace = setTimeout(() => expire("expired"), this.stopGraceMs);
|
|
2950
|
+
}, this.maxRunMs);
|
|
2951
|
+
return {
|
|
2952
|
+
expired,
|
|
2953
|
+
disarm: () => {
|
|
2954
|
+
clearTimeout(limit);
|
|
2955
|
+
if (grace !== null) clearTimeout(grace);
|
|
2956
|
+
}
|
|
2957
|
+
};
|
|
2958
|
+
}
|
|
2776
2959
|
runnableFor(entry, values, token) {
|
|
2777
2960
|
if (entry.source === "internal") return require_dist.buildActionSteps(entry.steps ?? [], values, {
|
|
2778
2961
|
invokeCap: (call) => this.invokeCap(call),
|
|
@@ -2822,6 +3005,7 @@ var ActionsService = class {
|
|
|
2822
3005
|
});
|
|
2823
3006
|
}
|
|
2824
3007
|
async create(input) {
|
|
3008
|
+
this.requireWithinCeiling(input.action.steps, input.action.name);
|
|
2825
3009
|
const { steps, warnings } = this.normalizeSteps(input.action.steps, input.action.name);
|
|
2826
3010
|
const action = await this.store.create({
|
|
2827
3011
|
...input.action,
|
|
@@ -2841,6 +3025,7 @@ var ActionsService = class {
|
|
|
2841
3025
|
const existing = await this.store.get(input.actionId);
|
|
2842
3026
|
if (existing === null) throw new require_dist.ActionError("not-found", `no action "${input.actionId}"`);
|
|
2843
3027
|
const patch = input.action;
|
|
3028
|
+
if (patch.steps !== void 0) this.requireWithinCeiling(patch.steps, patch.name ?? existing.name);
|
|
2844
3029
|
const { steps, warnings } = this.normalizeSteps(patch.steps ?? existing.steps ?? [], patch.name ?? existing.name);
|
|
2845
3030
|
const action = await this.store.update(input.actionId, {
|
|
2846
3031
|
name: patch.name ?? existing.name,
|
|
@@ -2853,6 +3038,18 @@ var ActionsService = class {
|
|
|
2853
3038
|
...warnings.length > 0 ? { warnings } : {}
|
|
2854
3039
|
};
|
|
2855
3040
|
}
|
|
3041
|
+
/** An action whose waits alone exceed the run ceiling could never finish: refuse the save. */
|
|
3042
|
+
requireWithinCeiling(steps, actionName) {
|
|
3043
|
+
const total = require_dist.actionWaitTotalMs(steps);
|
|
3044
|
+
if (total <= this.maxRunMs) return;
|
|
3045
|
+
const message = `the wait steps add up to ${spanLabel(total)}; an action may run at most ${spanLabel(this.maxRunMs)}`;
|
|
3046
|
+
this.logger.warn("action save refused — it could never finish within the run limit", { meta: {
|
|
3047
|
+
action: actionName,
|
|
3048
|
+
waitTotalMs: total,
|
|
3049
|
+
maxRunMs: this.maxRunMs
|
|
3050
|
+
} });
|
|
3051
|
+
throw new require_dist.ActionError("invalid-steps", message);
|
|
3052
|
+
}
|
|
2856
3053
|
/**
|
|
2857
3054
|
* D972: a quantity arg sent as `{ value, unit }` is converted to the unit the
|
|
2858
3055
|
* method declares; a unit that cannot be that quantity refuses the save; a
|
|
@@ -5500,6 +5697,7 @@ var RemoteService = class {
|
|
|
5500
5697
|
duration: null,
|
|
5501
5698
|
shuffle: null,
|
|
5502
5699
|
repeat: null,
|
|
5700
|
+
positionUpdatedAt: null,
|
|
5503
5701
|
lastChangedAt: input.changedAt
|
|
5504
5702
|
};
|
|
5505
5703
|
}
|