@camstack/server 1.2.841 → 1.2.842
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/oauth2/oauth2-routes.js +50 -6
- package/dist/core/addon/addon-registry.service.js +4 -0
- package/dist/core/addon/addon-route-request.js +18 -0
- package/dist/main.js +8 -5
- package/package.json +16 -18
- package/system/dist/addon-routes/addon-route-registry.d.ts +27 -1
- package/system/dist/addon-runner.js +3 -1
- package/system/dist/addon-runner.mjs +3 -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/composer.addon.js +4 -4
- package/system/dist/builtins/composer/composer.addon.mjs +4 -4
- 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 +3 -3
- package/system/dist/builtins/core-blocks/core-blocks.addon.mjs +3 -3
- 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 +2 -2
- package/system/dist/builtins/device-manager/device-manager.addon.mjs +2 -2
- 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 +21 -7
- package/system/dist/builtins/local-auth/local-auth.addon.mjs +21 -7
- package/system/dist/builtins/local-auth/oauth-grants.d.ts +9 -1
- package/system/dist/builtins/local-auth/oauth-session-manager.d.ts +8 -0
- package/system/dist/builtins/local-auth/record-kinds.d.ts +2 -0
- 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/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-CGU4rnN-.js → capture-engine-DSrJUGYs.js} +1 -1
- package/system/dist/{capture-engine-CLrh3FG0.mjs → capture-engine-DySELkE_.mjs} +1 -1
- package/system/dist/{composition-sources-bhWIz4Rp.js → composition-sources-CNfFz3Cz.js} +1 -1
- package/system/dist/{composition-sources-CoLbBru1.mjs → composition-sources-DZ4E9FFU.mjs} +1 -1
- package/system/dist/{constants-CfAS4Qm6.mjs → constants-BEXN_b1Y.mjs} +1 -1
- package/system/dist/{constants-DZwpZY5J.js → constants-DkgFDCQ7.js} +1 -1
- package/system/dist/{device-ca-CAbEBLyf.mjs → device-ca-Dk_9f4MY.mjs} +1 -1
- package/system/dist/{device-ca-ksS811fC.js → device-ca-sYcSz-Fv.js} +1 -1
- package/system/dist/{dist-ByiDJLen.mjs → dist-4jAoRtpT.mjs} +621 -38
- package/system/dist/{dist-DlRUArVs.js → dist-LQWK1_M4.js} +626 -37
- package/system/dist/file-host-worker.js +1 -1
- package/system/dist/file-host-worker.mjs +1 -1
- package/system/dist/{hub-identity-Bh28ooQx.mjs → hub-identity-BxGHDga-.mjs} +1 -1
- package/system/dist/{hub-identity-C-1NeWlr.js → hub-identity-haC7V8-b.js} +1 -1
- package/system/dist/{hub-mdns-ciao-OWO6Bw-X.mjs → hub-mdns-ciao-Birwi8W5.mjs} +2 -2
- package/system/dist/{hub-mdns-ciao-CL-Z9yMs.js → hub-mdns-ciao-zxNvdRQz.js} +2 -2
- package/system/dist/index.d.ts +1 -1
- package/system/dist/index.js +55 -9
- package/system/dist/index.mjs +54 -10
- package/system/dist/kernel/moleculer/child-addon-call-dispatch.d.ts +1 -0
- package/system/dist/{legacy-integration-rows-door-Be_QKUlY.mjs → legacy-integration-rows-door-C-hOd-lt.mjs} +1 -1
- package/system/dist/{legacy-integration-rows-door-CDPH26e8.js → legacy-integration-rows-door-CCtcCRjZ.js} +1 -1
- package/system/dist/{rename-composition-block-Bs5KT3Gn.js → rename-composition-block-BCZeI3eY.js} +1 -1
- package/system/dist/{rename-composition-block-CncvFIHl.mjs → rename-composition-block-YpAVqp4W.mjs} +1 -1
- package/system/dist/{restore-archive-DX7kK3LQ.mjs → restore-archive-BpC3y50e.mjs} +1 -1
- package/system/dist/{restore-archive-CHUKcl3T.js → restore-archive-D0Nyukhb.js} +1 -1
- package/system/dist/{wal-maintenance-Fibm7rsM.mjs → wal-maintenance-C7jLVFCw.mjs} +0 -0
- package/system/dist/{wal-maintenance-GNE9Oqdu.js → wal-maintenance-CRiSNk0X.js} +0 -0
- package/system/package.json +1 -1
|
@@ -1243,7 +1243,7 @@ var DeviceRole = /* @__PURE__ */ function(DeviceRole) {
|
|
|
1243
1243
|
*/
|
|
1244
1244
|
var COMPOSED_DEVICE_STABLE_ID_PREFIX = "composed-";
|
|
1245
1245
|
//#endregion
|
|
1246
|
-
//#region ../types/dist/sleep-
|
|
1246
|
+
//#region ../types/dist/sleep-D0roI_CZ.mjs
|
|
1247
1247
|
/**
|
|
1248
1248
|
* The audio chunk plane's byte format, and the ONE expansion from a coded
|
|
1249
1249
|
* window to float samples (D455).
|
|
@@ -12508,6 +12508,10 @@ Object.freeze({
|
|
|
12508
12508
|
"path": "lastEvent.eventType",
|
|
12509
12509
|
"valueType": "string"
|
|
12510
12510
|
},
|
|
12511
|
+
{
|
|
12512
|
+
"path": "lastEvent.sourceId",
|
|
12513
|
+
"valueType": "string"
|
|
12514
|
+
},
|
|
12511
12515
|
{
|
|
12512
12516
|
"path": "lastEvent.timestamp",
|
|
12513
12517
|
"valueType": "number"
|
|
@@ -17259,6 +17263,22 @@ function describeUnmet(unmet) {
|
|
|
17259
17263
|
}
|
|
17260
17264
|
}
|
|
17261
17265
|
/**
|
|
17266
|
+
* The integration instance of an addon, as it appears in an address or on an
|
|
17267
|
+
* OAuth link (planning#415, D1046).
|
|
17268
|
+
*
|
|
17269
|
+
* The DEFAULT instance has two spellings on the wire and one in the code: a
|
|
17270
|
+
* path with no instance segment and a link with no instance both mean it, and
|
|
17271
|
+
* its id is the addon id. {@link oauthLinkServesInstance} is the one
|
|
17272
|
+
* comparison a per-instance route is meant to call, so nobody compares
|
|
17273
|
+
* `undefined` with an id. Nothing calls it yet: no route declares
|
|
17274
|
+
* `perInstance` (the Alexa per-instance route, T3, is the first consumer).
|
|
17275
|
+
*/
|
|
17276
|
+
/** An instance id as it may appear in a path or a query: no separator, no escape, bounded. */
|
|
17277
|
+
var ADDON_INSTANCE_ID_RE = /^[A-Za-z0-9._-]{1,64}$/;
|
|
17278
|
+
function isAddonInstanceId(value) {
|
|
17279
|
+
return ADDON_INSTANCE_ID_RE.test(value);
|
|
17280
|
+
}
|
|
17281
|
+
/**
|
|
17262
17282
|
* notification-output — canonical, capability-gated notification delivery.
|
|
17263
17283
|
*
|
|
17264
17284
|
* Apprise-derived model (see
|
|
@@ -44149,9 +44169,12 @@ function convertLegacyWhen(half) {
|
|
|
44149
44169
|
* every caller — automations, Actions, and the notification centre, which runs
|
|
44150
44170
|
* only Actions (planning#473).
|
|
44151
44171
|
*/
|
|
44172
|
+
/** The longest one `wait` step lasts. It is cut by a restart of the run and does not survive a hub restart. */
|
|
44173
|
+
var WAIT_MAX_SECONDS = 3600;
|
|
44174
|
+
var WAIT_TOO_LONG = `a wait is at most one hour (${WAIT_MAX_SECONDS} s)`;
|
|
44152
44175
|
var AutomationWaitStepSchema = zod.z.object({
|
|
44153
44176
|
kind: zod.z.literal("wait"),
|
|
44154
|
-
seconds: zod.z.number().min(0).max(
|
|
44177
|
+
seconds: zod.z.number().min(0).max(WAIT_MAX_SECONDS, WAIT_TOO_LONG)
|
|
44155
44178
|
});
|
|
44156
44179
|
/** The legacy `deviceId` of a cap step: still READ, never written (D983). */
|
|
44157
44180
|
var LegacyStepDeviceSchema = zod.z.union([
|
|
@@ -44281,20 +44304,210 @@ var ActionStepSchema = zod.z.discriminatedUnion("kind", [GuardedWaitStepSchema,
|
|
|
44281
44304
|
path: ["if"]
|
|
44282
44305
|
});
|
|
44283
44306
|
});
|
|
44307
|
+
/**
|
|
44308
|
+
* Flow control of an AUTOMATION's list (#500). A standalone list (an action, a
|
|
44309
|
+
* scheduler point, a preset) stays `wait` and `cap`: it has no run of its own
|
|
44310
|
+
* to end and no variable bag to write.
|
|
44311
|
+
*/
|
|
44312
|
+
var continueOnErrorShape = {
|
|
44313
|
+
/** A failure of this step is traced `failed-continued` and the next step runs. */
|
|
44314
|
+
continueOnError: zod.z.literal(true).optional() };
|
|
44315
|
+
/** An automation's cap step: the shared guarded cap step, plus `continueOnError`. */
|
|
44316
|
+
var AutomationGuardedCapStepSchema = AutomationCapStepBaseSchema.extend({
|
|
44317
|
+
...stepGuardShape,
|
|
44318
|
+
...continueOnErrorShape
|
|
44319
|
+
}).refine((step) => step.target !== void 0 || step.deviceId !== void 0, {
|
|
44320
|
+
message: "a cap step needs a target",
|
|
44321
|
+
path: ["target"]
|
|
44322
|
+
}).refine((step) => step.target?.kind !== "domain" || step.actionId !== void 0, {
|
|
44323
|
+
message: "a domain target needs the vocabulary action it applies to (actionId)",
|
|
44324
|
+
path: ["actionId"]
|
|
44325
|
+
}).refine((step) => step.else === void 0 || step.if !== void 0, elseNeedsIf);
|
|
44326
|
+
/** End the run here, on purpose. `reason` may carry `{{vars.x}}` slots. */
|
|
44327
|
+
var AutomationStopStepSchema = zod.z.object({
|
|
44328
|
+
kind: zod.z.literal("stop"),
|
|
44329
|
+
reason: zod.z.string().min(1, "a stop needs a reason: it is what the run trace shows").max(200),
|
|
44330
|
+
/** `ok`: the run ends as a success. `failed`: it ends as a failure, with the reason. */
|
|
44331
|
+
outcome: zod.z.enum(["ok", "failed"]),
|
|
44332
|
+
/** Stop only when this reads true; false or unknown does not stop. */
|
|
44333
|
+
if: AutomationWhenSchema.optional()
|
|
44334
|
+
});
|
|
44335
|
+
var SET_VAR_NAME_RE = /^[A-Za-z_][A-Za-z0-9_]{0,39}$/;
|
|
44336
|
+
/** Names the run itself writes and reads (`leaf` is what `triggered-by` judges): a step may not overwrite them. */
|
|
44337
|
+
var RESERVED_RUN_VARS = [
|
|
44338
|
+
"kind",
|
|
44339
|
+
"leaf",
|
|
44340
|
+
"at"
|
|
44341
|
+
];
|
|
44342
|
+
/**
|
|
44343
|
+
* Write variables into the run's bag, for the steps after it. SUBSTITUTION
|
|
44344
|
+
* only, never evaluation: a text value may carry `{{vars.x}}` slots.
|
|
44345
|
+
*/
|
|
44346
|
+
var AutomationSetStepSchema = zod.z.object({
|
|
44347
|
+
kind: zod.z.literal("set"),
|
|
44348
|
+
vars: zod.z.record(zod.z.string(), zod.z.union([
|
|
44349
|
+
zod.z.string().max(500),
|
|
44350
|
+
zod.z.number(),
|
|
44351
|
+
zod.z.boolean()
|
|
44352
|
+
])).refine((vars) => Object.keys(vars).every((name) => SET_VAR_NAME_RE.test(name)), { message: "a variable name is letters, digits and _, not starting with a digit (max 40)" }).refine((vars) => Object.keys(vars).length >= 1, { message: "set needs at least one variable" }).refine((vars) => Object.keys(vars).length <= 20, { message: `set holds at most 20 variables` }).refine((vars) => Object.keys(vars).every((name) => !RESERVED_RUN_VARS.includes(name)), { message: `the names ${RESERVED_RUN_VARS.join(", ")} belong to the run and cannot be set` }),
|
|
44353
|
+
/** Set only when this reads true; false or unknown leaves the bag as it is. */
|
|
44354
|
+
if: AutomationWhenSchema.optional()
|
|
44355
|
+
});
|
|
44356
|
+
var AutomationRunActionStepSchema = zod.z.object({
|
|
44357
|
+
kind: zod.z.literal("action"),
|
|
44358
|
+
/** An entry of the `actions` surface (`internal:<uuid>` or `<addonId>:<localId>`). */
|
|
44359
|
+
actionId: zod.z.string().min(1),
|
|
44360
|
+
/** Values for the action's declared variables; the others take their default. */
|
|
44361
|
+
variables: zod.z.record(zod.z.string(), zod.z.union([
|
|
44362
|
+
zod.z.string(),
|
|
44363
|
+
zod.z.number(),
|
|
44364
|
+
zod.z.boolean()
|
|
44365
|
+
])).optional(),
|
|
44366
|
+
...continueOnErrorShape
|
|
44367
|
+
});
|
|
44368
|
+
/**
|
|
44369
|
+
* A step INSIDE a branch of a `choose`: a flow step with no condition of its
|
|
44370
|
+
* own (the branch is the condition) and no block inside it. Strict, so an `if`
|
|
44371
|
+
* written on such a step is refused rather than dropped.
|
|
44372
|
+
*/
|
|
44373
|
+
/** The longest a `wait-until` may wait: six hours. */
|
|
44374
|
+
var WAIT_UNTIL_TIMEOUT_MAX_S = 21600;
|
|
44375
|
+
/**
|
|
44376
|
+
* Pause the run until a condition is true (#500). The timeout is mandatory: a
|
|
44377
|
+
* run never waits without an end. `onTimeout` says what a wait that ran out
|
|
44378
|
+
* does: `continue` goes on to the next step, `stop` ends the run as a failure.
|
|
44379
|
+
* A condition that cannot be read is not "true": the wait goes on (D49).
|
|
44380
|
+
*/
|
|
44381
|
+
var AutomationWaitUntilStepSchema = zod.z.object({
|
|
44382
|
+
kind: zod.z.literal("wait-until"),
|
|
44383
|
+
when: AutomationWhenSchema,
|
|
44384
|
+
timeoutS: zod.z.number().int().min(1, "a wait needs a timeout of at least one second").max(WAIT_UNTIL_TIMEOUT_MAX_S, `a wait for a condition is at most six hours (${WAIT_UNTIL_TIMEOUT_MAX_S} s)`),
|
|
44385
|
+
onTimeout: zod.z.enum(["continue", "stop"])
|
|
44386
|
+
}).strict();
|
|
44387
|
+
/** The step kinds that hold steps of their own, or pause on a condition: they nest two levels at most. */
|
|
44388
|
+
var BLOCK_STEP_KINDS = [
|
|
44389
|
+
"choose",
|
|
44390
|
+
"repeat",
|
|
44391
|
+
"parallel",
|
|
44392
|
+
"wait-until"
|
|
44393
|
+
];
|
|
44394
|
+
var NEST_TOO_DEEP = `steps nest two levels at most: a step inside a nested choose or repeat can be a plain step only`;
|
|
44395
|
+
function kindOf(input) {
|
|
44396
|
+
return typeof input === "object" && input !== null ? Reflect.get(input, "kind") : void 0;
|
|
44397
|
+
}
|
|
44398
|
+
/** Where the nesting ends, a block step is refused in words rather than as an unknown kind. */
|
|
44399
|
+
function nestTooDeep(issue) {
|
|
44400
|
+
const kind = kindOf(issue.input);
|
|
44401
|
+
return typeof kind === "string" && BLOCK_STEP_KINDS.includes(kind) ? NEST_TOO_DEEP : void 0;
|
|
44402
|
+
}
|
|
44403
|
+
var plainStepSchemas = [
|
|
44404
|
+
AutomationWaitStepSchema.strict(),
|
|
44405
|
+
AutomationCapStepBaseSchema.extend(continueOnErrorShape).strict().refine((step) => step.target !== void 0 || step.deviceId !== void 0, {
|
|
44406
|
+
message: "a cap step needs a target",
|
|
44407
|
+
path: ["target"]
|
|
44408
|
+
}).refine((step) => step.target?.kind !== "domain" || step.actionId !== void 0, {
|
|
44409
|
+
message: "a domain target needs the vocabulary action it applies to (actionId)",
|
|
44410
|
+
path: ["actionId"]
|
|
44411
|
+
}),
|
|
44412
|
+
AutomationStopStepSchema.omit({ if: true }).strict(),
|
|
44413
|
+
AutomationSetStepSchema.omit({ if: true }).strict(),
|
|
44414
|
+
AutomationRunActionStepSchema.strict()
|
|
44415
|
+
];
|
|
44416
|
+
/**
|
|
44417
|
+
* A plain step: a flow step with no condition of its own and no step inside
|
|
44418
|
+
* it. The second (last) level of nesting holds these only.
|
|
44419
|
+
*/
|
|
44420
|
+
var AutomationBranchStepSchema = zod.z.discriminatedUnion("kind", plainStepSchemas, { error: nestTooDeep });
|
|
44421
|
+
/** A step that can run beside others: it writes no variable and does not end the run. */
|
|
44422
|
+
var AutomationParallelMemberSchema = AutomationBranchStepSchema.refine((step) => step.kind === "cap" || step.kind === "action" || step.kind === "wait", "a parallel holds device commands, actions and waits only: a set or a stop beside other steps has no order");
|
|
44423
|
+
/**
|
|
44424
|
+
* Several steps at once (#500): all are started together and all are awaited.
|
|
44425
|
+
* A failure fails the run once the others finished, as in a sequence; a member
|
|
44426
|
+
* marked "continue if this fails" does not.
|
|
44427
|
+
*/
|
|
44428
|
+
var AutomationParallelStepSchema = zod.z.object({
|
|
44429
|
+
kind: zod.z.literal("parallel"),
|
|
44430
|
+
steps: zod.z.array(AutomationParallelMemberSchema).min(2, "a parallel needs at least two steps").max(5, `a parallel takes at most 5 steps`)
|
|
44431
|
+
}).strict();
|
|
44432
|
+
var REPEAT_NEEDS_MAX = "a repeat on a condition needs a maximum number of iterations";
|
|
44433
|
+
/** A loop on a condition: the bound is mandatory, so a run never loops without an end. */
|
|
44434
|
+
var repeatConditionShape = {
|
|
44435
|
+
when: AutomationWhenSchema,
|
|
44436
|
+
maxIterations: zod.z.number({ error: REPEAT_NEEDS_MAX }).int().min(1, REPEAT_NEEDS_MAX).max(50, `a repeat on a condition runs at most 50 times`),
|
|
44437
|
+
/** A pause between two iterations, never after the last. */
|
|
44438
|
+
waitS: zod.z.number().int().min(1).max(WAIT_MAX_SECONDS, WAIT_TOO_LONG).optional()
|
|
44439
|
+
};
|
|
44440
|
+
/** What decides how many times a `repeat` runs. */
|
|
44441
|
+
var AutomationRepeatLoopSchema = zod.z.discriminatedUnion("by", [
|
|
44442
|
+
zod.z.object({
|
|
44443
|
+
by: zod.z.literal("count"),
|
|
44444
|
+
count: zod.z.number().int().min(1).max(20, `a repeat runs at most 20 times`)
|
|
44445
|
+
}).strict(),
|
|
44446
|
+
zod.z.object({
|
|
44447
|
+
by: zod.z.literal("while"),
|
|
44448
|
+
...repeatConditionShape
|
|
44449
|
+
}).strict(),
|
|
44450
|
+
zod.z.object({
|
|
44451
|
+
by: zod.z.literal("until"),
|
|
44452
|
+
...repeatConditionShape
|
|
44453
|
+
}).strict(),
|
|
44454
|
+
zod.z.object({
|
|
44455
|
+
by: zod.z.literal("forEach"),
|
|
44456
|
+
target: zod.z.object({
|
|
44457
|
+
kind: zod.z.literal("devices"),
|
|
44458
|
+
ids: zod.z.array(zod.z.number().int()).min(1, "a repeat over devices needs at least one device").max(50, `a repeat over devices takes at most 50 devices`)
|
|
44459
|
+
}).strict()
|
|
44460
|
+
}).strict()
|
|
44461
|
+
]);
|
|
44462
|
+
/**
|
|
44463
|
+
* The same steps several times (#500). Every form is bounded at save, so a
|
|
44464
|
+
* run cannot loop without an end. A failure or a `stop` in the steps ends the
|
|
44465
|
+
* loop and the run, as in a sequence.
|
|
44466
|
+
*/
|
|
44467
|
+
function repeatSchemaOf(step) {
|
|
44468
|
+
return zod.z.object({
|
|
44469
|
+
kind: zod.z.literal("repeat"),
|
|
44470
|
+
loop: AutomationRepeatLoopSchema,
|
|
44471
|
+
steps: zod.z.array(step).min(1, "a repeat needs at least one step").max(10, `a repeat takes at most 10 steps`)
|
|
44472
|
+
}).strict();
|
|
44473
|
+
}
|
|
44474
|
+
/**
|
|
44475
|
+
* One step, several ways (#500): the branches are read in order and the FIRST
|
|
44476
|
+
* whose condition is true runs; `else` runs when every branch is false. A
|
|
44477
|
+
* branch that cannot be read ends the choice: nothing runs, not the branches
|
|
44478
|
+
* after it and not the else (D49). The #472 `if` / `else` of a wait or cap
|
|
44479
|
+
* step is the one-branch case and stays as it is stored.
|
|
44480
|
+
*/
|
|
44481
|
+
function chooseSchemaOf(step) {
|
|
44482
|
+
const steps = zod.z.array(step).max(10);
|
|
44483
|
+
return zod.z.object({
|
|
44484
|
+
kind: zod.z.literal("choose"),
|
|
44485
|
+
branches: zod.z.array(zod.z.object({
|
|
44486
|
+
if: AutomationWhenSchema,
|
|
44487
|
+
steps: steps.min(1, "a branch needs at least one step")
|
|
44488
|
+
})).min(1, "a choose needs at least one branch").max(6, `a choose takes at most 6 branches`),
|
|
44489
|
+
else: steps.optional()
|
|
44490
|
+
});
|
|
44491
|
+
}
|
|
44492
|
+
var AutomationBodyStepSchema = zod.z.discriminatedUnion("kind", [
|
|
44493
|
+
...plainStepSchemas,
|
|
44494
|
+
AutomationWaitUntilStepSchema,
|
|
44495
|
+
AutomationParallelStepSchema,
|
|
44496
|
+
chooseSchemaOf(AutomationBranchStepSchema),
|
|
44497
|
+
repeatSchemaOf(AutomationBranchStepSchema)
|
|
44498
|
+
]);
|
|
44499
|
+
var AutomationRepeatStepSchema = repeatSchemaOf(AutomationBodyStepSchema);
|
|
44500
|
+
var AutomationChooseStepSchema = chooseSchemaOf(AutomationBodyStepSchema);
|
|
44284
44501
|
var AutomationActionSchema = zod.z.discriminatedUnion("kind", [
|
|
44285
44502
|
GuardedWaitStepSchema,
|
|
44286
|
-
|
|
44287
|
-
|
|
44288
|
-
|
|
44289
|
-
|
|
44290
|
-
|
|
44291
|
-
|
|
44292
|
-
|
|
44293
|
-
|
|
44294
|
-
zod.z.number(),
|
|
44295
|
-
zod.z.boolean()
|
|
44296
|
-
])).optional()
|
|
44297
|
-
}),
|
|
44503
|
+
AutomationGuardedCapStepSchema,
|
|
44504
|
+
AutomationStopStepSchema,
|
|
44505
|
+
AutomationSetStepSchema,
|
|
44506
|
+
AutomationChooseStepSchema,
|
|
44507
|
+
AutomationWaitUntilStepSchema,
|
|
44508
|
+
AutomationParallelStepSchema,
|
|
44509
|
+
AutomationRepeatStepSchema,
|
|
44510
|
+
AutomationRunActionStepSchema,
|
|
44298
44511
|
zod.z.object({
|
|
44299
44512
|
kind: zod.z.literal("code"),
|
|
44300
44513
|
/** Compiled into the automation's OWN block by esbuild — not a third
|
|
@@ -44357,11 +44570,6 @@ function convertLegacyRecipe(legacy) {
|
|
|
44357
44570
|
...rest
|
|
44358
44571
|
};
|
|
44359
44572
|
}
|
|
44360
|
-
/**
|
|
44361
|
-
* Where recipes are PARSED (the core-blocks cap, the MCP tool, the literal a
|
|
44362
|
-
* saved block carries): the new shape as it is, or the old shape converted to
|
|
44363
|
-
* it. The output type is always the new one.
|
|
44364
|
-
*/
|
|
44365
44573
|
var AutomationRecipeSchema = zod.z.union([CurrentAutomationRecipeSchema, LegacyAutomationRecipeSchema.transform(convertLegacyRecipe)]);
|
|
44366
44574
|
/**
|
|
44367
44575
|
* A daily window as a STATE: is this instant inside it, and when does that
|
|
@@ -45125,12 +45333,16 @@ var HoldOverrideSchema = zod.z.discriminatedUnion("mode", [zod.z.object({ mode:
|
|
|
45125
45333
|
var DEFAULT_HOLD_OVERRIDE = { mode: "respect" };
|
|
45126
45334
|
/** A missed edge up to this late still runs. */
|
|
45127
45335
|
var DEFAULT_MAX_LATE_MS = 10 * 6e4;
|
|
45336
|
+
var SchedulerStepSchema = ActionStepSchema.refine((step) => step.kind !== "wait" || step.seconds <= 300, {
|
|
45337
|
+
message: `a scheduler point waits at most five minutes (300 s); put a longer wait in an action`,
|
|
45338
|
+
path: ["seconds"]
|
|
45339
|
+
});
|
|
45128
45340
|
var SchedulerPointSchema = zod.z.object({
|
|
45129
45341
|
id: zod.z.string().min(1).max(64),
|
|
45130
45342
|
at: SchedulerTimeSpecSchema,
|
|
45131
45343
|
mode: SchedulerPointModeSchema,
|
|
45132
45344
|
/** The actions of an `edge` or `hold`; a `release` has none. */
|
|
45133
|
-
steps: zod.z.array(
|
|
45345
|
+
steps: zod.z.array(SchedulerStepSchema).max(20).default([]),
|
|
45134
45346
|
/** Checked when the point runs (an edge) or is applied (a hold). */
|
|
45135
45347
|
conditions: SchedulerStateTreeSchema.optional(),
|
|
45136
45348
|
/** Hold only; absent means `respect`. */
|
|
@@ -45502,18 +45714,46 @@ var StepTraceBaseSchema = zod.z.object({
|
|
|
45502
45714
|
]).optional(),
|
|
45503
45715
|
/** Why the condition read what it read, in the evaluator's own words. */
|
|
45504
45716
|
conditionReason: zod.z.string().optional(),
|
|
45505
|
-
/** `empty`: the target resolved to no device, so nothing was done — never silently `ok`. `skipped`: its `if` was false (or unknown) and nothing ran in its place. */
|
|
45717
|
+
/** `empty`: the target resolved to no device, so nothing was done — never silently `ok`. `skipped`: its `if` was false (or unknown) and nothing ran in its place. `failed-continued`: it failed and was marked to be passed over (#500). */
|
|
45506
45718
|
outcome: zod.z.enum([
|
|
45507
45719
|
"ok",
|
|
45508
45720
|
"error",
|
|
45509
45721
|
"not-run",
|
|
45510
45722
|
"empty",
|
|
45511
|
-
"skipped"
|
|
45723
|
+
"skipped",
|
|
45724
|
+
"failed-continued",
|
|
45725
|
+
"timed-out"
|
|
45512
45726
|
]),
|
|
45513
45727
|
message: zod.z.string().optional()
|
|
45514
45728
|
});
|
|
45729
|
+
/** What a block step adds to its row: which list ran, what each branch read, how many rounds. */
|
|
45730
|
+
var blockTraceShape = {
|
|
45731
|
+
/** A `choose` step (#500): the list that ran, `branches.<n>` or `else`. Absent when none did. */
|
|
45732
|
+
branch: zod.z.string().optional(),
|
|
45733
|
+
/** A `choose` step: what each branch read, in order, up to the one that decided. */
|
|
45734
|
+
branchChecks: zod.z.array(zod.z.object({
|
|
45735
|
+
condition: zod.z.enum([
|
|
45736
|
+
"true",
|
|
45737
|
+
"false",
|
|
45738
|
+
"unknown"
|
|
45739
|
+
]),
|
|
45740
|
+
conditionReason: zod.z.string().optional()
|
|
45741
|
+
})).optional(),
|
|
45742
|
+
/** A `repeat` step (#500): how many times its steps ran. */
|
|
45743
|
+
iterations: zod.z.number().int().optional()
|
|
45744
|
+
};
|
|
45745
|
+
/** A step one level down: it may be a block step itself, whose own steps are plain rows (the nesting ends there). */
|
|
45746
|
+
var NestedStepTraceSchema = StepTraceBaseSchema.extend({
|
|
45747
|
+
...blockTraceShape,
|
|
45748
|
+
steps: zod.z.array(StepTraceBaseSchema).optional()
|
|
45749
|
+
});
|
|
45515
45750
|
/** A step trace; the `else` steps that ran are one level of the same shape (the nesting is bounded at one). */
|
|
45516
|
-
var AutomationStepTraceSchema = StepTraceBaseSchema.extend({
|
|
45751
|
+
var AutomationStepTraceSchema = StepTraceBaseSchema.extend({
|
|
45752
|
+
else: zod.z.array(StepTraceBaseSchema).optional(),
|
|
45753
|
+
...blockTraceShape,
|
|
45754
|
+
/** A `choose` step: the steps of the list that ran. A `parallel`: its members. A `repeat`: the LAST iteration. */
|
|
45755
|
+
steps: zod.z.array(NestedStepTraceSchema).optional()
|
|
45756
|
+
});
|
|
45517
45757
|
var AutomationRunTraceSchema = zod.z.object({
|
|
45518
45758
|
runId: zod.z.string().min(1),
|
|
45519
45759
|
startedAt: zod.z.number(),
|
|
@@ -45882,6 +46122,46 @@ async function evaluateStepCondition(when, fetchers, now = Date.now, history, si
|
|
|
45882
46122
|
reason: first ?? "the condition does not hold"
|
|
45883
46123
|
};
|
|
45884
46124
|
}
|
|
46125
|
+
/**
|
|
46126
|
+
* Read the branches in order and stop at the first that decides: `true` runs
|
|
46127
|
+
* it, `unknown` ends the choice with nothing run (D49). All `false` runs the
|
|
46128
|
+
* else list, when there is one.
|
|
46129
|
+
*/
|
|
46130
|
+
async function readChoose(choose) {
|
|
46131
|
+
const checks = [];
|
|
46132
|
+
for (const [index, branch] of choose.branches.entries()) {
|
|
46133
|
+
const verdict = await readGuard(branch.guard);
|
|
46134
|
+
checks.push({
|
|
46135
|
+
condition: verdict.result,
|
|
46136
|
+
conditionReason: verdict.reason
|
|
46137
|
+
});
|
|
46138
|
+
if (verdict.result === "true") return {
|
|
46139
|
+
checks,
|
|
46140
|
+
decision: {
|
|
46141
|
+
kind: "run",
|
|
46142
|
+
branch: `branches.${index}`,
|
|
46143
|
+
steps: branch.steps
|
|
46144
|
+
}
|
|
46145
|
+
};
|
|
46146
|
+
if (verdict.result === "unknown") return {
|
|
46147
|
+
checks,
|
|
46148
|
+
decision: {
|
|
46149
|
+
kind: "unknown",
|
|
46150
|
+
index,
|
|
46151
|
+
reason: verdict.reason
|
|
46152
|
+
}
|
|
46153
|
+
};
|
|
46154
|
+
}
|
|
46155
|
+
const otherwise = choose.otherwise ?? [];
|
|
46156
|
+
return {
|
|
46157
|
+
checks,
|
|
46158
|
+
decision: otherwise.length === 0 ? { kind: "none" } : {
|
|
46159
|
+
kind: "run",
|
|
46160
|
+
branch: "else",
|
|
46161
|
+
steps: otherwise
|
|
46162
|
+
}
|
|
46163
|
+
};
|
|
46164
|
+
}
|
|
45885
46165
|
function errorMessage(err) {
|
|
45886
46166
|
return err instanceof Error ? err.message : String(err);
|
|
45887
46167
|
}
|
|
@@ -45896,17 +46176,105 @@ async function readGuard(guard) {
|
|
|
45896
46176
|
};
|
|
45897
46177
|
}
|
|
45898
46178
|
}
|
|
46179
|
+
/** A loop condition that throws ends the loop as unreadable, never a crash of the run. */
|
|
46180
|
+
async function readRepeatCheck(check, iteration) {
|
|
46181
|
+
if (check === void 0) return { go: true };
|
|
46182
|
+
try {
|
|
46183
|
+
return await check(iteration);
|
|
46184
|
+
} catch (err) {
|
|
46185
|
+
return {
|
|
46186
|
+
go: false,
|
|
46187
|
+
reason: `the condition could not be read: ${errorMessage(err)}`,
|
|
46188
|
+
unknown: true
|
|
46189
|
+
};
|
|
46190
|
+
}
|
|
46191
|
+
}
|
|
46192
|
+
/** Run a loop's steps until its count, its condition, its bound, a failure, a stop or an abort ends it. */
|
|
46193
|
+
async function runRepeat(repeat, options, path) {
|
|
46194
|
+
let iterations = 0;
|
|
46195
|
+
let last;
|
|
46196
|
+
for (;;) {
|
|
46197
|
+
if (options.isAborted()) return {
|
|
46198
|
+
iterations,
|
|
46199
|
+
last,
|
|
46200
|
+
timedOut: false
|
|
46201
|
+
};
|
|
46202
|
+
const before = await readRepeatCheck(repeat.before, iterations);
|
|
46203
|
+
if (!before.go) return {
|
|
46204
|
+
iterations,
|
|
46205
|
+
last,
|
|
46206
|
+
ended: before.reason,
|
|
46207
|
+
timedOut: false,
|
|
46208
|
+
...before.unknown === true ? { unknown: before.reason } : {}
|
|
46209
|
+
};
|
|
46210
|
+
if (iterations >= repeat.limit) return repeat.limitIsTimeout ? {
|
|
46211
|
+
iterations,
|
|
46212
|
+
last,
|
|
46213
|
+
ended: `stopped at ${repeat.limit} iterations`,
|
|
46214
|
+
timedOut: true
|
|
46215
|
+
} : {
|
|
46216
|
+
iterations,
|
|
46217
|
+
last,
|
|
46218
|
+
ended: "",
|
|
46219
|
+
timedOut: false
|
|
46220
|
+
};
|
|
46221
|
+
last = await runSteps(repeat.steps, {
|
|
46222
|
+
...options,
|
|
46223
|
+
pathPrefix: `${path}.steps`,
|
|
46224
|
+
indexOffset: 0
|
|
46225
|
+
});
|
|
46226
|
+
iterations += 1;
|
|
46227
|
+
if (last.failed || last.aborted || last.stopped !== void 0) return {
|
|
46228
|
+
iterations,
|
|
46229
|
+
last,
|
|
46230
|
+
timedOut: false
|
|
46231
|
+
};
|
|
46232
|
+
const after = await readRepeatCheck(repeat.after, iterations - 1);
|
|
46233
|
+
if (!after.go) return {
|
|
46234
|
+
iterations,
|
|
46235
|
+
last,
|
|
46236
|
+
ended: after.reason,
|
|
46237
|
+
timedOut: false,
|
|
46238
|
+
...after.unknown === true ? { unknown: after.reason } : {}
|
|
46239
|
+
};
|
|
46240
|
+
if (repeat.between !== void 0 && iterations < repeat.limit) await repeat.between();
|
|
46241
|
+
}
|
|
46242
|
+
}
|
|
45899
46243
|
/** The else level of a trace is one level deep: a nested trace carries no `else` of its own. */
|
|
45900
46244
|
function withoutElse(trace) {
|
|
45901
46245
|
const { else: _else, ...rest } = trace;
|
|
45902
46246
|
return rest;
|
|
45903
46247
|
}
|
|
46248
|
+
/** A plain row: the last level of a trace carries no list of its own. */
|
|
46249
|
+
function plainRow(trace) {
|
|
46250
|
+
const { else: _else, steps: _steps, ...rest } = trace;
|
|
46251
|
+
return rest;
|
|
46252
|
+
}
|
|
46253
|
+
/** A row one level down: it keeps its own steps as plain rows, and no `else`. */
|
|
46254
|
+
function withoutNested(trace) {
|
|
46255
|
+
const { else: _else, steps, ...rest } = trace;
|
|
46256
|
+
return steps === void 0 ? rest : {
|
|
46257
|
+
...rest,
|
|
46258
|
+
steps: steps.map(plainRow)
|
|
46259
|
+
};
|
|
46260
|
+
}
|
|
45904
46261
|
async function runSteps(steps, options) {
|
|
45905
46262
|
const traces = [];
|
|
45906
46263
|
let failed = false;
|
|
45907
46264
|
let aborted = false;
|
|
45908
|
-
|
|
46265
|
+
let stopped;
|
|
46266
|
+
for (const [position, step] of steps.entries()) {
|
|
46267
|
+
const index = position + (options.indexOffset ?? 0);
|
|
45909
46268
|
const path = `${options.pathPrefix}.${index}`;
|
|
46269
|
+
if (stopped !== void 0) {
|
|
46270
|
+
traces.push({
|
|
46271
|
+
...step.meta,
|
|
46272
|
+
path,
|
|
46273
|
+
outcome: "not-run",
|
|
46274
|
+
message: `stopped at ${stopped.path}: ${stopped.reason}`
|
|
46275
|
+
});
|
|
46276
|
+
continue;
|
|
46277
|
+
}
|
|
45910
46278
|
if (failed || aborted || options.isAborted()) {
|
|
45911
46279
|
if (!failed) aborted = true;
|
|
45912
46280
|
traces.push({
|
|
@@ -45918,6 +46286,96 @@ async function runSteps(steps, options) {
|
|
|
45918
46286
|
continue;
|
|
45919
46287
|
}
|
|
45920
46288
|
const startedAt = options.now();
|
|
46289
|
+
if (step.parallel !== void 0) {
|
|
46290
|
+
const members = await Promise.all(step.parallel.map((member, at) => runSteps([member], {
|
|
46291
|
+
...options,
|
|
46292
|
+
pathPrefix: `${path}.steps`,
|
|
46293
|
+
indexOffset: at
|
|
46294
|
+
})));
|
|
46295
|
+
const anyFailed = members.some((m) => m.failed);
|
|
46296
|
+
if (anyFailed) failed = true;
|
|
46297
|
+
else if (members.some((m) => m.aborted)) aborted = true;
|
|
46298
|
+
traces.push({
|
|
46299
|
+
...step.meta,
|
|
46300
|
+
path,
|
|
46301
|
+
startedAt,
|
|
46302
|
+
endedAt: options.now(),
|
|
46303
|
+
outcome: anyFailed ? "error" : "ok",
|
|
46304
|
+
...anyFailed ? { message: "a parallel step failed" } : {},
|
|
46305
|
+
steps: members.flatMap((m) => m.steps.map(withoutNested))
|
|
46306
|
+
});
|
|
46307
|
+
continue;
|
|
46308
|
+
}
|
|
46309
|
+
if (step.repeat !== void 0) {
|
|
46310
|
+
const loop = await runRepeat(step.repeat, options, path);
|
|
46311
|
+
const sub = loop.last;
|
|
46312
|
+
if (loop.unknown !== void 0) options.onGuardUnknown?.({
|
|
46313
|
+
index,
|
|
46314
|
+
path: `${path}.loop.when`,
|
|
46315
|
+
reason: loop.unknown,
|
|
46316
|
+
deviceId: step.meta.deviceId
|
|
46317
|
+
});
|
|
46318
|
+
const bodyFailed = loop.ended === void 0 && sub?.failed === true;
|
|
46319
|
+
if (bodyFailed) failed = true;
|
|
46320
|
+
else if (loop.ended === void 0 && sub?.stopped !== void 0) stopped = sub.stopped;
|
|
46321
|
+
else if (loop.ended === void 0) aborted = true;
|
|
46322
|
+
const times = `ran ${loop.iterations} times`;
|
|
46323
|
+
const message = bodyFailed ? `a step failed in iteration ${loop.iterations}` : loop.ended === void 0 ? times : loop.timedOut ? loop.ended : loop.ended === "" ? times : `${times}: ${loop.ended}`;
|
|
46324
|
+
traces.push({
|
|
46325
|
+
...step.meta,
|
|
46326
|
+
path,
|
|
46327
|
+
startedAt,
|
|
46328
|
+
endedAt: options.now(),
|
|
46329
|
+
outcome: bodyFailed ? "error" : loop.timedOut ? "timed-out" : "ok",
|
|
46330
|
+
message,
|
|
46331
|
+
iterations: loop.iterations,
|
|
46332
|
+
...sub === void 0 ? {} : { steps: sub.steps.map(withoutNested) }
|
|
46333
|
+
});
|
|
46334
|
+
continue;
|
|
46335
|
+
}
|
|
46336
|
+
if (step.choose !== void 0) {
|
|
46337
|
+
const reading = await readChoose(step.choose);
|
|
46338
|
+
const base = {
|
|
46339
|
+
...step.meta,
|
|
46340
|
+
path,
|
|
46341
|
+
startedAt,
|
|
46342
|
+
branchChecks: [...reading.checks]
|
|
46343
|
+
};
|
|
46344
|
+
const { decision } = reading;
|
|
46345
|
+
if (decision.kind !== "run") {
|
|
46346
|
+
if (decision.kind === "unknown") options.onGuardUnknown?.({
|
|
46347
|
+
index,
|
|
46348
|
+
path: `${path}.branches.${decision.index}.if`,
|
|
46349
|
+
reason: decision.reason,
|
|
46350
|
+
deviceId: step.meta.deviceId
|
|
46351
|
+
});
|
|
46352
|
+
traces.push({
|
|
46353
|
+
...base,
|
|
46354
|
+
endedAt: options.now(),
|
|
46355
|
+
outcome: "skipped",
|
|
46356
|
+
message: decision.kind === "unknown" ? `not run: branch ${decision.index + 1} could not be read (${decision.reason})` : "not run: no branch is true"
|
|
46357
|
+
});
|
|
46358
|
+
continue;
|
|
46359
|
+
}
|
|
46360
|
+
const listPath = decision.branch === "else" ? `${path}.else` : `${path}.${decision.branch}.steps`;
|
|
46361
|
+
const sub = await runSteps(decision.steps, {
|
|
46362
|
+
...options,
|
|
46363
|
+
pathPrefix: listPath,
|
|
46364
|
+
indexOffset: 0
|
|
46365
|
+
});
|
|
46366
|
+
if (sub.failed) failed = true;
|
|
46367
|
+
else if (sub.aborted) aborted = true;
|
|
46368
|
+
if (sub.stopped !== void 0) stopped = sub.stopped;
|
|
46369
|
+
traces.push({
|
|
46370
|
+
...base,
|
|
46371
|
+
endedAt: options.now(),
|
|
46372
|
+
outcome: sub.failed ? "error" : "ok",
|
|
46373
|
+
...sub.failed ? { message: "a step of the branch failed" } : {},
|
|
46374
|
+
branch: decision.branch,
|
|
46375
|
+
steps: sub.steps.map(withoutNested)
|
|
46376
|
+
});
|
|
46377
|
+
continue;
|
|
46378
|
+
}
|
|
45921
46379
|
let guardTrace = {};
|
|
45922
46380
|
if (step.guard !== void 0) {
|
|
45923
46381
|
const verdict = await readGuard(step.guard);
|
|
@@ -45947,10 +46405,12 @@ async function runSteps(steps, options) {
|
|
|
45947
46405
|
}
|
|
45948
46406
|
const sub = await runSteps(branch, {
|
|
45949
46407
|
...options,
|
|
45950
|
-
pathPrefix: `${path}.else
|
|
46408
|
+
pathPrefix: `${path}.else`,
|
|
46409
|
+
indexOffset: 0
|
|
45951
46410
|
});
|
|
45952
46411
|
if (sub.failed) failed = true;
|
|
45953
46412
|
else if (sub.aborted) aborted = true;
|
|
46413
|
+
if (sub.stopped !== void 0) stopped = sub.stopped;
|
|
45954
46414
|
traces.push({
|
|
45955
46415
|
...step.meta,
|
|
45956
46416
|
...guardTrace,
|
|
@@ -45968,6 +46428,7 @@ async function runSteps(steps, options) {
|
|
|
45968
46428
|
let sent;
|
|
45969
46429
|
const perDevice = [];
|
|
45970
46430
|
let emptyReason;
|
|
46431
|
+
let timedOutReason;
|
|
45971
46432
|
let templateNotes = [];
|
|
45972
46433
|
const scope = {
|
|
45973
46434
|
setDeviceId: (id) => {
|
|
@@ -45984,6 +46445,16 @@ async function runSteps(steps, options) {
|
|
|
45984
46445
|
},
|
|
45985
46446
|
setTemplateNotes: (notes) => {
|
|
45986
46447
|
templateNotes = notes.slice(0, 20);
|
|
46448
|
+
},
|
|
46449
|
+
stop: (reason, outcome) => {
|
|
46450
|
+
stopped = {
|
|
46451
|
+
reason,
|
|
46452
|
+
outcome,
|
|
46453
|
+
path
|
|
46454
|
+
};
|
|
46455
|
+
},
|
|
46456
|
+
markTimedOut: (reason) => {
|
|
46457
|
+
timedOutReason = reason;
|
|
45987
46458
|
}
|
|
45988
46459
|
};
|
|
45989
46460
|
const templatesTrace = () => templateNotes.length === 0 ? {} : { templates: [...templateNotes] };
|
|
@@ -45991,6 +46462,29 @@ async function runSteps(steps, options) {
|
|
|
45991
46462
|
const devicesTrace = () => perDevice.length === 0 ? {} : { devices: perDevice.slice(0, 200) };
|
|
45992
46463
|
try {
|
|
45993
46464
|
await step.run(scope);
|
|
46465
|
+
const stop = (() => stopped)();
|
|
46466
|
+
if (stop !== void 0) {
|
|
46467
|
+
const message = `stopped: ${stop.reason}`;
|
|
46468
|
+
if (stop.outcome === "failed") {
|
|
46469
|
+
failed = true;
|
|
46470
|
+
options.onFailure({
|
|
46471
|
+
index,
|
|
46472
|
+
path,
|
|
46473
|
+
message,
|
|
46474
|
+
deviceId
|
|
46475
|
+
});
|
|
46476
|
+
}
|
|
46477
|
+
traces.push({
|
|
46478
|
+
...step.meta,
|
|
46479
|
+
...guardTrace,
|
|
46480
|
+
path,
|
|
46481
|
+
startedAt,
|
|
46482
|
+
endedAt: options.now(),
|
|
46483
|
+
outcome: stop.outcome === "failed" ? "error" : "ok",
|
|
46484
|
+
message
|
|
46485
|
+
});
|
|
46486
|
+
continue;
|
|
46487
|
+
}
|
|
45994
46488
|
traces.push({
|
|
45995
46489
|
...step.meta,
|
|
45996
46490
|
...deviceId === void 0 || perDevice.length > 1 ? {} : { deviceId },
|
|
@@ -46001,18 +46495,27 @@ async function runSteps(steps, options) {
|
|
|
46001
46495
|
path,
|
|
46002
46496
|
startedAt,
|
|
46003
46497
|
endedAt: options.now(),
|
|
46004
|
-
outcome: emptyReason === void 0 ? "ok" : "empty",
|
|
46005
|
-
...emptyReason === void 0 ? {} : { message: emptyReason }
|
|
46498
|
+
outcome: timedOutReason !== void 0 ? "timed-out" : emptyReason === void 0 ? "ok" : "empty",
|
|
46499
|
+
...timedOutReason !== void 0 ? { message: timedOutReason } : emptyReason === void 0 ? {} : { message: emptyReason }
|
|
46006
46500
|
});
|
|
46007
46501
|
} catch (err) {
|
|
46008
|
-
failed = true;
|
|
46009
46502
|
const message = errorMessage(err);
|
|
46010
|
-
|
|
46503
|
+
const continued = step.continueOnError === true;
|
|
46504
|
+
if (continued) options.onContinuedFailure?.({
|
|
46011
46505
|
index,
|
|
46012
46506
|
path,
|
|
46013
46507
|
message,
|
|
46014
46508
|
deviceId
|
|
46015
46509
|
});
|
|
46510
|
+
else {
|
|
46511
|
+
failed = true;
|
|
46512
|
+
options.onFailure({
|
|
46513
|
+
index,
|
|
46514
|
+
path,
|
|
46515
|
+
message,
|
|
46516
|
+
deviceId
|
|
46517
|
+
});
|
|
46518
|
+
}
|
|
46016
46519
|
traces.push({
|
|
46017
46520
|
...step.meta,
|
|
46018
46521
|
...deviceId === void 0 || perDevice.length > 1 ? {} : { deviceId },
|
|
@@ -46023,7 +46526,7 @@ async function runSteps(steps, options) {
|
|
|
46023
46526
|
path,
|
|
46024
46527
|
startedAt,
|
|
46025
46528
|
endedAt: options.now(),
|
|
46026
|
-
outcome: "error",
|
|
46529
|
+
outcome: continued ? "failed-continued" : "error",
|
|
46027
46530
|
message
|
|
46028
46531
|
});
|
|
46029
46532
|
}
|
|
@@ -46031,7 +46534,8 @@ async function runSteps(steps, options) {
|
|
|
46031
46534
|
return {
|
|
46032
46535
|
steps: traces,
|
|
46033
46536
|
failed,
|
|
46034
|
-
aborted: aborted && !failed
|
|
46537
|
+
aborted: aborted && !failed,
|
|
46538
|
+
...stopped === void 0 ? {} : { stopped }
|
|
46035
46539
|
};
|
|
46036
46540
|
}
|
|
46037
46541
|
function isVarRef(value) {
|
|
@@ -46803,7 +47307,9 @@ var AddonHttpRouteSchema = zod.z.object({
|
|
|
46803
47307
|
]).optional(),
|
|
46804
47308
|
description: zod.z.string().optional(),
|
|
46805
47309
|
/** The hub limits this route per client address before the handler runs. */
|
|
46806
|
-
rateLimit: zod.z.enum(["auth"]).optional()
|
|
47310
|
+
rateLimit: zod.z.enum(["auth"]).optional(),
|
|
47311
|
+
/** Served once per integration instance; the handler reads `instanceId`. */
|
|
47312
|
+
perInstance: zod.z.boolean().optional()
|
|
46807
47313
|
});
|
|
46808
47314
|
/**
|
|
46809
47315
|
* Cross-process route invocation envelope. The hub captures the
|
|
@@ -46820,6 +47326,8 @@ var InvokeRequestSchema = zod.z.object({
|
|
|
46820
47326
|
query: zod.z.record(zod.z.string(), zod.z.string()),
|
|
46821
47327
|
body: zod.z.unknown(),
|
|
46822
47328
|
headers: zod.z.record(zod.z.string(), zod.z.string()),
|
|
47329
|
+
/** The instance the hub resolved for a `perInstance` route. */
|
|
47330
|
+
instanceId: zod.z.string().optional(),
|
|
46823
47331
|
user: zod.z.object({
|
|
46824
47332
|
id: zod.z.string(),
|
|
46825
47333
|
username: zod.z.string(),
|
|
@@ -63785,25 +64293,71 @@ var enumSensorCapability = {
|
|
|
63785
64293
|
* whether persisting is worth a SQLite commit. */
|
|
63786
64294
|
volatileStateFields: ["lastFetchedAt", "timestamp"]
|
|
63787
64295
|
};
|
|
64296
|
+
var EventVocabularyKindSchema = zod.z.enum([
|
|
64297
|
+
"press",
|
|
64298
|
+
"long-press",
|
|
64299
|
+
"long-press-start",
|
|
64300
|
+
"release",
|
|
64301
|
+
"repeat",
|
|
64302
|
+
"double-press",
|
|
64303
|
+
"other"
|
|
64304
|
+
]);
|
|
64305
|
+
/** The part of the device an event comes from: a button, a channel. */
|
|
64306
|
+
var EventVocabularySourceSchema = zod.z.object({
|
|
64307
|
+
id: zod.z.string().min(1),
|
|
64308
|
+
label: zod.z.string().min(1)
|
|
64309
|
+
});
|
|
64310
|
+
/** One scalar field of an event's `data`, by dotted path. */
|
|
64311
|
+
var EventVocabularyFieldSchema = zod.z.object({
|
|
64312
|
+
path: zod.z.string().min(1),
|
|
64313
|
+
kind: zod.z.enum([
|
|
64314
|
+
"string",
|
|
64315
|
+
"number",
|
|
64316
|
+
"boolean",
|
|
64317
|
+
"enum"
|
|
64318
|
+
]),
|
|
64319
|
+
enumValues: zod.z.array(zod.z.string()).optional(),
|
|
64320
|
+
label: zod.z.string().min(1).optional()
|
|
64321
|
+
});
|
|
64322
|
+
var EventVocabularyEntrySchema = zod.z.object({
|
|
64323
|
+
/** The native token, verbatim. */
|
|
64324
|
+
id: zod.z.string().min(1),
|
|
64325
|
+
source: EventVocabularySourceSchema.optional(),
|
|
64326
|
+
label: zod.z.string().min(1),
|
|
64327
|
+
description: zod.z.string().optional(),
|
|
64328
|
+
kind: EventVocabularyKindSchema.optional(),
|
|
64329
|
+
payload: zod.z.array(EventVocabularyFieldSchema).optional()
|
|
64330
|
+
});
|
|
63788
64331
|
/**
|
|
63789
64332
|
* Generic stateless event emitter. Installed on a `DeviceType.EventEmitter`
|
|
63790
64333
|
* device. Carries the device's EXACT declared event vocabulary verbatim
|
|
63791
64334
|
* (NO normalization). Two shapes:
|
|
63792
|
-
* - structured source (HA `event.*` entity) → `
|
|
63793
|
-
* declared
|
|
63794
|
-
* - generic/legacy source (HA bus events, e.g. zha_event) → `
|
|
64335
|
+
* - structured source (HA `event.*` entity) → `vocabulary` is the fixed
|
|
64336
|
+
* declared set (e.g. press_short, press_long, …).
|
|
64337
|
+
* - generic/legacy source (HA bus events, e.g. zha_event) → `vocabulary`
|
|
63795
64338
|
* is [] (open) and `lastEvent.data` carries the complex payload.
|
|
64339
|
+
* `vocabulary` (D1044) names each event for a person and types it for a
|
|
64340
|
+
* rule; `eventTypes` is its list of native tokens, kept for older readers.
|
|
64341
|
+
* A fire names the part of the device it came from in `sourceId` when the
|
|
64342
|
+
* vocabulary declares sources (a remote's buttons).
|
|
63796
64343
|
* `seq` is monotonic so two identical events still produce distinct slice writes.
|
|
63797
64344
|
*/
|
|
63798
64345
|
var EventFireSchema = zod.z.object({
|
|
63799
64346
|
deviceId: zod.z.number(),
|
|
63800
64347
|
eventType: zod.z.string(),
|
|
64348
|
+
sourceId: zod.z.string().optional(),
|
|
63801
64349
|
data: zod.z.record(zod.z.string(), zod.z.unknown()).nullable(),
|
|
63802
64350
|
timestamp: zod.z.number().meta(readingMeta("none")),
|
|
63803
64351
|
seq: zod.z.number().meta(readingMeta("count"))
|
|
63804
64352
|
});
|
|
63805
64353
|
var EventEmitterStatusSchema = zod.z.object({
|
|
63806
64354
|
eventTypes: zod.z.array(zod.z.string()),
|
|
64355
|
+
/**
|
|
64356
|
+
* Required of a provider by the type. A status written before the field
|
|
64357
|
+
* existed still parses, as an empty vocabulary: read it through
|
|
64358
|
+
* `readEventVocabulary`, which then answers with the plain tokens.
|
|
64359
|
+
*/
|
|
64360
|
+
vocabulary: zod.z.array(EventVocabularyEntrySchema).default([]),
|
|
63807
64361
|
lastEvent: EventFireSchema.nullable(),
|
|
63808
64362
|
eventCountSinceStart: zod.z.number().meta(readingMeta("count"))
|
|
63809
64363
|
});
|
|
@@ -82632,7 +83186,18 @@ var OauthIntegrationDescriptorSchema = zod.z.object({
|
|
|
82632
83186
|
* The value is baked into the authorization code at `/authorize` and travels
|
|
82633
83187
|
* on the tokens, so editing this field changes FUTURE links only.
|
|
82634
83188
|
*/
|
|
82635
|
-
refreshTokenTtlSec: zod.z.union([zod.z.number().int().positive(), zod.z.literal("never")]).optional()
|
|
83189
|
+
refreshTokenTtlSec: zod.z.union([zod.z.number().int().positive(), zod.z.literal("never")]).optional(),
|
|
83190
|
+
/**
|
|
83191
|
+
* The integration instances an account can be linked to (planning#415),
|
|
83192
|
+
* beside the default one. `/api/oauth2/authorize?instance=<id>` is accepted
|
|
83193
|
+
* only for an id listed here; with no `instance=` the link is made to the
|
|
83194
|
+
* default instance, which is never listed and always accepted — it is the
|
|
83195
|
+
* address third parties already hold. Omit for a single-instance integration.
|
|
83196
|
+
*/
|
|
83197
|
+
instances: zod.z.array(zod.z.object({
|
|
83198
|
+
id: zod.z.string(),
|
|
83199
|
+
displayName: zod.z.string()
|
|
83200
|
+
})).optional()
|
|
82636
83201
|
});
|
|
82637
83202
|
var oauthIntegrationCapability = {
|
|
82638
83203
|
name: "oauth-integration",
|
|
@@ -91358,6 +91923,13 @@ var SsoBridgeClaimsSchema = zod.z.object({
|
|
|
91358
91923
|
/** OAuth authorization-code binding — set only on `oauth-code` tokens. */
|
|
91359
91924
|
redirectUri: zod.z.string().optional(),
|
|
91360
91925
|
integrationId: zod.z.string().optional(),
|
|
91926
|
+
/**
|
|
91927
|
+
* The integration INSTANCE an OAuth link was made for (planning#415). Set on
|
|
91928
|
+
* `oauth-code`, `oauth-access` and `oauth-refresh` tokens of a link made
|
|
91929
|
+
* with `instance=`; absent on a link to the default instance. A cloud relay
|
|
91930
|
+
* reads it off the access token to route; the hub answers from the session.
|
|
91931
|
+
*/
|
|
91932
|
+
instanceId: zod.z.string().optional(),
|
|
91361
91933
|
/** JWT ID — unique per issued code; consumed-set enforces single-use. */
|
|
91362
91934
|
jti: zod.z.string().optional(),
|
|
91363
91935
|
/** PKCE S256 challenge — set only on `oauth-code` tokens issued to a public
|
|
@@ -94329,6 +94901,8 @@ var OauthSessionSummarySchema = zod.z.object({
|
|
|
94329
94901
|
userId: zod.z.string(),
|
|
94330
94902
|
username: zod.z.string(),
|
|
94331
94903
|
integrationId: zod.z.string(),
|
|
94904
|
+
/** The instance the link was made for; `null` = the default instance. */
|
|
94905
|
+
instanceId: zod.z.string().nullable().optional(),
|
|
94332
94906
|
scopes: zod.z.array(TokenScopeSchema),
|
|
94333
94907
|
createdAt: zod.z.number(),
|
|
94334
94908
|
lastUsedAt: zod.z.number(),
|
|
@@ -94457,6 +95031,9 @@ var userManagementCapability = {
|
|
|
94457
95031
|
}),
|
|
94458
95032
|
oauthIssueCode: method(zod.z.object({
|
|
94459
95033
|
integrationId: zod.z.string(),
|
|
95034
|
+
/** The integration instance the link is for. Omit for the default
|
|
95035
|
+
* instance — never pass the addon id to mean it. */
|
|
95036
|
+
instanceId: zod.z.string().optional(),
|
|
94460
95037
|
userId: zod.z.string(),
|
|
94461
95038
|
username: zod.z.string(),
|
|
94462
95039
|
scopes: zod.z.array(TokenScopeSchema),
|
|
@@ -94498,7 +95075,13 @@ var userManagementCapability = {
|
|
|
94498
95075
|
oauthVerifyAccessToken: method(zod.z.object({ token: zod.z.string() }), zod.z.object({
|
|
94499
95076
|
userId: zod.z.string(),
|
|
94500
95077
|
username: zod.z.string(),
|
|
94501
|
-
scopes: zod.z.array(TokenScopeSchema)
|
|
95078
|
+
scopes: zod.z.array(TokenScopeSchema),
|
|
95079
|
+
/** The instance the link was made for, read from the SESSION.
|
|
95080
|
+
* Absent = the default instance. `oauthLinkServesInstance` is the
|
|
95081
|
+
* helper a per-instance route calls to compare it with the instance
|
|
95082
|
+
* of its path; no route declares `perInstance` yet (the Alexa
|
|
95083
|
+
* per-instance route, T3, is the first consumer). */
|
|
95084
|
+
instanceId: zod.z.string().optional()
|
|
94502
95085
|
}).nullable(), { access: "view" }),
|
|
94503
95086
|
listExternalIdentities: method(zod.z.object({ userId: zod.z.string() }), zod.z.array(ExternalIdentitySchema), { auth: "admin" }),
|
|
94504
95087
|
/** The user an identity is linked to, or `null`. */
|
|
@@ -122069,6 +122652,12 @@ Object.defineProperty(exports, "interpolate", {
|
|
|
122069
122652
|
return interpolate;
|
|
122070
122653
|
}
|
|
122071
122654
|
});
|
|
122655
|
+
Object.defineProperty(exports, "isAddonInstanceId", {
|
|
122656
|
+
enumerable: true,
|
|
122657
|
+
get: function() {
|
|
122658
|
+
return isAddonInstanceId;
|
|
122659
|
+
}
|
|
122660
|
+
});
|
|
122072
122661
|
Object.defineProperty(exports, "isAlertEpisodeOpen", {
|
|
122073
122662
|
enumerable: true,
|
|
122074
122663
|
get: function() {
|