@camstack/addon-pipeline-orchestrator 1.2.704 → 1.2.705
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 +14 -0
- package/dist/_stub.js +2 -2
- package/dist/{_virtual_mf-localSharedImportMap___mfe_internal__addon_pipeline_orchestrator_widgets-Cj52fOl5.mjs → _virtual_mf-localSharedImportMap___mfe_internal__addon_pipeline_orchestrator_widgets-D9Ieg-TJ.mjs} +2 -2
- package/dist/_virtual_mf___mfe_internal__addon_pipeline_orchestrator_widgets__loadShare___mf_0_camstack_mf_1_types__loadShare__.js-D5hGghmf.mjs +26 -0
- package/dist/{_virtual_mf___mfe_internal__addon_pipeline_orchestrator_widgets__loadShare___mf_0_camstack_mf_1_ui_mf_2_library__loadShare__.js-db42AynZ.mjs → _virtual_mf___mfe_internal__addon_pipeline_orchestrator_widgets__loadShare___mf_0_camstack_mf_1_ui_mf_2_library__loadShare__.js-CWJvaMDE.mjs} +1 -1
- package/dist/{hostInit-gz1wzjps.mjs → hostInit-BVdelTmU.mjs} +2 -2
- package/dist/index.js +1022 -99
- package/dist/index.mjs +1022 -99
- package/dist/remoteEntry.js +1 -1
- package/package.json +2 -2
- package/dist/_virtual_mf___mfe_internal__addon_pipeline_orchestrator_widgets__loadShare___mf_0_camstack_mf_1_types__loadShare__.js-CQQGnCt3.mjs +0 -26
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { createHash, randomUUID } from "node:crypto";
|
|
2
|
+
import { isDeepStrictEqual } from "node:util";
|
|
2
3
|
import fs from "node:fs";
|
|
3
4
|
import path from "node:path";
|
|
4
5
|
import { fileURLToPath } from "node:url";
|
|
@@ -6125,7 +6126,7 @@ var ZodIssueCode = {
|
|
|
6125
6126
|
var ZodFirstPartyTypeKind;
|
|
6126
6127
|
ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {});
|
|
6127
6128
|
//#endregion
|
|
6128
|
-
//#region ../types/dist/runtime-capabilities-
|
|
6129
|
+
//#region ../types/dist/runtime-capabilities-qX7BpOYT.mjs
|
|
6129
6130
|
/**
|
|
6130
6131
|
* The audio chunk plane's byte format, and the ONE expansion from a coded
|
|
6131
6132
|
* window to float samples (D455).
|
|
@@ -49301,11 +49302,104 @@ var CROP_SUPPLY_STEP_IDS = ["plate-detection", "face-detection"];
|
|
|
49301
49302
|
* no camera tree carries.)
|
|
49302
49303
|
*/
|
|
49303
49304
|
var MASK_SUPPLY_STEP_IDS = ["segmentation"];
|
|
49304
|
-
|
|
49305
|
+
/** Every step a root model can supply. */
|
|
49306
|
+
var ROOT_SUPPLIABLE_STEP_IDS = [
|
|
49305
49307
|
...LABEL_SUPPLY_STEP_IDS,
|
|
49306
49308
|
...CROP_SUPPLY_STEP_IDS,
|
|
49307
49309
|
...MASK_SUPPLY_STEP_IDS
|
|
49308
49310
|
];
|
|
49311
|
+
/** Narrow a step id to a suppliable one — type guard, not a cast. */
|
|
49312
|
+
function isRootSuppliableStepId(value) {
|
|
49313
|
+
return ROOT_SUPPLIABLE_STEP_IDS.some((id) => id === value);
|
|
49314
|
+
}
|
|
49315
|
+
var CROP_SUPPLY_SOURCES = {
|
|
49316
|
+
"plate-detection": {
|
|
49317
|
+
rootLabels: ["license_plate"],
|
|
49318
|
+
parentMacro: "vehicle",
|
|
49319
|
+
childClass: "plate",
|
|
49320
|
+
servedChildSteps: ["plate-ocr"],
|
|
49321
|
+
use: "as-output"
|
|
49322
|
+
},
|
|
49323
|
+
"face-detection": {
|
|
49324
|
+
rootLabels: ["face"],
|
|
49325
|
+
parentMacro: "person",
|
|
49326
|
+
childClass: "face",
|
|
49327
|
+
servedChildSteps: ["face-embedding"],
|
|
49328
|
+
use: "refine",
|
|
49329
|
+
minRootInputPx: 640
|
|
49330
|
+
}
|
|
49331
|
+
};
|
|
49332
|
+
/**
|
|
49333
|
+
* Whether an operator intends a step to take the root's output when the
|
|
49334
|
+
* root declares it — the default of the `useRootModel` flag. The label kinds
|
|
49335
|
+
* default ON: the detector's answer is the cheaper one and the classifier
|
|
49336
|
+
* keeps its model for the day the root changes. The animal and vehicle
|
|
49337
|
+
* classifiers are also ENABLED by default (their catalog `enabledByDefault`,
|
|
49338
|
+
* D736), so out of the box a root that declares them names animals and
|
|
49339
|
+
* vehicles and a root that does not runs the classifier; `package-detection`
|
|
49340
|
+
* stays zone-driven and takes this default whenever a zone switches it on.
|
|
49341
|
+
* The crop kinds default OFF: a
|
|
49342
|
+
* root plate box has an uncalibrated OCR margin, and root-face refinement has
|
|
49343
|
+
* not run on live traffic yet.
|
|
49344
|
+
*/
|
|
49345
|
+
var USE_ROOT_MODEL_DEFAULTS = {
|
|
49346
|
+
"animal-classifier": true,
|
|
49347
|
+
"vehicle-classifier": true,
|
|
49348
|
+
"package-detection": true,
|
|
49349
|
+
"plate-detection": false,
|
|
49350
|
+
"face-detection": false,
|
|
49351
|
+
segmentation: true
|
|
49352
|
+
};
|
|
49353
|
+
/** The step-settings key the flag is stored under (DeviceStepConfig.settings, camera overrides). */
|
|
49354
|
+
var USE_ROOT_MODEL_SETTING_KEY = "useRootModel";
|
|
49355
|
+
/**
|
|
49356
|
+
* The retired D715 policy key. A `skip-when-filled` / `run` value still
|
|
49357
|
+
* stored under it reads as the flag (`true` / `false`) when no flag is stored
|
|
49358
|
+
* — the normal read path, not a migration.
|
|
49359
|
+
*/
|
|
49360
|
+
var RETIRED_LABEL_LINK_KEY = "labelLink";
|
|
49361
|
+
/** The supply a root declares for one step, if any. */
|
|
49362
|
+
function supplyFor(supplies, stepId) {
|
|
49363
|
+
return supplies?.find((s) => s.stepId === stepId);
|
|
49364
|
+
}
|
|
49365
|
+
/**
|
|
49366
|
+
* Read the `useRootModel` flag off a step's settings bag. Absent ⇒ the
|
|
49367
|
+
* retired `labelLink` value if one is stored, else the step's default.
|
|
49368
|
+
*/
|
|
49369
|
+
function readUseRootModel(stepId, settings) {
|
|
49370
|
+
const raw = settings?.[USE_ROOT_MODEL_SETTING_KEY];
|
|
49371
|
+
if (typeof raw === "boolean") return raw;
|
|
49372
|
+
const retired = settings?.[RETIRED_LABEL_LINK_KEY];
|
|
49373
|
+
if (retired === "skip-when-filled") return true;
|
|
49374
|
+
if (retired === "run") return false;
|
|
49375
|
+
return USE_ROOT_MODEL_DEFAULTS[stepId];
|
|
49376
|
+
}
|
|
49377
|
+
/** Why a DECLARED supply is still not usable, or `undefined` when it is. */
|
|
49378
|
+
function supplyBlocker(supply) {
|
|
49379
|
+
if (supply.kind !== "crop") return void 0;
|
|
49380
|
+
const min = CROP_SUPPLY_SOURCES[supply.stepId].minRootInputPx;
|
|
49381
|
+
if (min === void 0) return void 0;
|
|
49382
|
+
return supply.rootInputPx !== void 0 && supply.rootInputPx >= min ? void 0 : "root-input-too-small";
|
|
49383
|
+
}
|
|
49384
|
+
/**
|
|
49385
|
+
* THE decision. Effective = the operator intends it AND the current root
|
|
49386
|
+
* declares it. It never looks at, changes or clears the step's `modelId`: a
|
|
49387
|
+
* root that cannot supply the step leaves the step running its own model, and
|
|
49388
|
+
* switching back to a root that can re-activates the supply by itself.
|
|
49389
|
+
*/
|
|
49390
|
+
function resolveRootSupply(stepId, settings, rootSupplies) {
|
|
49391
|
+
const supply = supplyFor(rootSupplies, stepId);
|
|
49392
|
+
const intent = readUseRootModel(stepId, settings);
|
|
49393
|
+
const blocker = supply === void 0 ? "root-does-not-declare" : supplyBlocker(supply);
|
|
49394
|
+
return {
|
|
49395
|
+
stepId,
|
|
49396
|
+
supply,
|
|
49397
|
+
intent,
|
|
49398
|
+
effective: intent && blocker === void 0,
|
|
49399
|
+
inactive: intent && blocker !== void 0,
|
|
49400
|
+
...intent && blocker !== void 0 ? { inactiveReason: blocker } : {}
|
|
49401
|
+
};
|
|
49402
|
+
}
|
|
49309
49403
|
/**
|
|
49310
49404
|
* Multi-file format payload.
|
|
49311
49405
|
*
|
|
@@ -67246,6 +67340,16 @@ var IntegrationInstanceStatusSchema = object({
|
|
|
67246
67340
|
/** A short human word for the state ("Signed in", "Token expired"); shown instead of `state`. */
|
|
67247
67341
|
label: string().optional()
|
|
67248
67342
|
});
|
|
67343
|
+
/**
|
|
67344
|
+
* What "Add device" inside ONE instance offers, decided per instance by its provider. `scan`: the
|
|
67345
|
+
* LAN scan finds devices this instance holds; `children`: only the instance's own children, via
|
|
67346
|
+
* adoption (a scan would offer other hosts, which are new integrations); `none`: manual add only.
|
|
67347
|
+
*/
|
|
67348
|
+
var IntegrationInstanceAddDeviceSchema = _enum([
|
|
67349
|
+
"scan",
|
|
67350
|
+
"children",
|
|
67351
|
+
"none"
|
|
67352
|
+
]);
|
|
67249
67353
|
var IntegrationInstanceSchema = object({
|
|
67250
67354
|
id: IntegrationInstanceIdSchema,
|
|
67251
67355
|
name: string(),
|
|
@@ -67263,7 +67367,9 @@ var IntegrationInstanceSchema = object({
|
|
|
67263
67367
|
formValues: record(string(), unknown()),
|
|
67264
67368
|
status: IntegrationInstanceStatusSchema.optional(),
|
|
67265
67369
|
/** Epoch ms of the last probe of the remote that produced `status`; absent when never checked. */
|
|
67266
|
-
lastCheckedAt: number$1().optional()
|
|
67370
|
+
lastCheckedAt: number$1().optional(),
|
|
67371
|
+
/** What "Add device" inside this instance offers; see {@link IntegrationInstanceAddDeviceSchema}. Absent means the caller derives it from `describe().discovery` with `defaultAddDeviceMode` (lan → scan, account → children, else none). */
|
|
67372
|
+
addDevice: IntegrationInstanceAddDeviceSchema.optional()
|
|
67267
67373
|
});
|
|
67268
67374
|
var IntegrationInstancePatchSchema = object({
|
|
67269
67375
|
id: IntegrationInstanceIdSchema,
|
|
@@ -75074,7 +75180,15 @@ var RunnerInferenceDeviceSchema = object({
|
|
|
75074
75180
|
* Absent field ⇒ an orchestrator that predates D650: the jumped step keeps
|
|
75075
75181
|
* the elected device's provisioning, as before.
|
|
75076
75182
|
*/
|
|
75077
|
-
steps: record(string(), RunnerJumpStepProvisioningSchema).optional()
|
|
75183
|
+
steps: record(string(), RunnerJumpStepProvisioningSchema).optional(),
|
|
75184
|
+
/**
|
|
75185
|
+
* Steps switched OFF on this device (D1065, `inferenceDevices[key].steps[s]
|
|
75186
|
+
* .enabled === false`). The runner never runs a subtree containing one of
|
|
75187
|
+
* them here: it auto-jumps it to an allowed device, and when none can take
|
|
75188
|
+
* it the subtree is skipped (`disabled-on-device`), never run here anyway.
|
|
75189
|
+
* Absent ⇒ none (an orchestrator that predates D1065).
|
|
75190
|
+
*/
|
|
75191
|
+
disabledSteps: array(string()).readonly().optional()
|
|
75078
75192
|
});
|
|
75079
75193
|
/**
|
|
75080
75194
|
* Camera assignment payload sent by `addon-pipeline-orchestrator` to a
|
|
@@ -81240,7 +81354,15 @@ var DeviceStepConfigSchema = object({
|
|
|
81240
81354
|
* at a disabled/absent device on that node at save time. Absent ⇒ the runner
|
|
81241
81355
|
* auto-jumps only when the effective device's format cannot run the step.
|
|
81242
81356
|
*/
|
|
81243
|
-
jumpDeviceKey: string().optional()
|
|
81357
|
+
jumpDeviceKey: string().optional(),
|
|
81358
|
+
/**
|
|
81359
|
+
* DEVICE switch for this step (D1065). `false` = the step is never
|
|
81360
|
+
* provisioned on this accelerator: a detail step jumps to another enabled
|
|
81361
|
+
* device of the node where it is allowed, else it is skipped with reason
|
|
81362
|
+
* `disabled-on-device`; a root is skipped. Absent = inherit (on). Written by
|
|
81363
|
+
* `setDeviceStepEnabled`.
|
|
81364
|
+
*/
|
|
81365
|
+
enabled: boolean().optional()
|
|
81244
81366
|
});
|
|
81245
81367
|
var AgentPipelineSettingsSchema = object({
|
|
81246
81368
|
maxCameras: number$1().int().nonnegative().nullable().default(null),
|
|
@@ -81284,6 +81406,12 @@ var AgentPipelineSettingsSchema = object({
|
|
|
81284
81406
|
*/
|
|
81285
81407
|
stepSettings: record(string(), record(string(), unknown()).readonly()).optional(),
|
|
81286
81408
|
/**
|
|
81409
|
+
* NODE switch per step (D1065): `stepId → enabled`. `false` = the step never
|
|
81410
|
+
* runs on a camera whose pipeline runs on this node (skip reason
|
|
81411
|
+
* `disabled-on-node`). Absent = inherit. Written by `setNodeStepEnabled`.
|
|
81412
|
+
*/
|
|
81413
|
+
stepEnabled: record(string(), boolean()).optional(),
|
|
81414
|
+
/**
|
|
81287
81415
|
* Multi-device inference opt-in (Phase 4). Per-node map deviceKey → {enabled,
|
|
81288
81416
|
* weight, steps}. Absent / all-disabled ⇒ the node's single default
|
|
81289
81417
|
* accelerator (safe default); two+ enabled ⇒ the dispatcher balances
|
|
@@ -81605,7 +81733,8 @@ var InferenceDeviceExclusionReasonSchema = _enum([
|
|
|
81605
81733
|
"disabled",
|
|
81606
81734
|
"unavailable",
|
|
81607
81735
|
"cannot-host-camera-root",
|
|
81608
|
-
"accelerator-preferred"
|
|
81736
|
+
"accelerator-preferred",
|
|
81737
|
+
"root-switched-off"
|
|
81609
81738
|
]);
|
|
81610
81739
|
var NodeInferenceDeviceSchema = object({
|
|
81611
81740
|
/** Stable per-node device key, e.g. `openvino:npu`, `edgetpu:usb`, `cpu`. */
|
|
@@ -81691,6 +81820,75 @@ var NodeInferenceDevicesSchema = object({
|
|
|
81691
81820
|
devices: array(NodeInferenceDeviceSchema).readonly()
|
|
81692
81821
|
});
|
|
81693
81822
|
/**
|
|
81823
|
+
* The CLUSTER switch of one pipeline step (D1065):
|
|
81824
|
+
* - `off` — hard off: no camera, node or device can turn it on;
|
|
81825
|
+
* - `on` — on by default; a camera may turn it off (`stepToggles`);
|
|
81826
|
+
* - `opt-in` — off by default; a camera turns it on (`stepToggles`).
|
|
81827
|
+
* Absent = the catalog's `enabledByDefault` (`true` → `on`, `false` → `opt-in`).
|
|
81828
|
+
*/
|
|
81829
|
+
var StepClusterModeSchema = _enum([
|
|
81830
|
+
"off",
|
|
81831
|
+
"on",
|
|
81832
|
+
"opt-in"
|
|
81833
|
+
]);
|
|
81834
|
+
/**
|
|
81835
|
+
* What one step does on one (node, device) — computed by the orchestrator with
|
|
81836
|
+
* the SAME placement function the attach path runs (`pipeline-resolver.ts`),
|
|
81837
|
+
* so a client never re-derives it. Precedence: cluster off > camera toggle
|
|
81838
|
+
* (else the cluster default) > node off > device off / jump.
|
|
81839
|
+
*/
|
|
81840
|
+
var StepSwitchCellSchema = discriminatedUnion("kind", [
|
|
81841
|
+
object({ kind: literal("on") }),
|
|
81842
|
+
object({ kind: literal("off-cluster") }),
|
|
81843
|
+
object({ kind: literal("off-node") }),
|
|
81844
|
+
object({ kind: literal("off-device") }),
|
|
81845
|
+
object({
|
|
81846
|
+
kind: literal("jump"),
|
|
81847
|
+
toDeviceKey: string()
|
|
81848
|
+
}),
|
|
81849
|
+
object({
|
|
81850
|
+
kind: literal("skip"),
|
|
81851
|
+
reason: _enum(["no-compatible-model", "root-not-runnable-on-elected-device"])
|
|
81852
|
+
}),
|
|
81853
|
+
object({ kind: literal("zone-driven") }),
|
|
81854
|
+
object({
|
|
81855
|
+
kind: literal("supplied-by-root"),
|
|
81856
|
+
rootModelId: string()
|
|
81857
|
+
}),
|
|
81858
|
+
object({ kind: literal("opt-in-unused") })
|
|
81859
|
+
]);
|
|
81860
|
+
var StepSwitchDeviceSchema = object({
|
|
81861
|
+
deviceKey: string(),
|
|
81862
|
+
format: _enum(MODEL_FORMATS),
|
|
81863
|
+
/** The device switch as stored (`inferenceDevices[key].steps[step].enabled`); `null` = inherit. */
|
|
81864
|
+
stepEnabled: boolean().nullable(),
|
|
81865
|
+
/** Whether the device is in the node's dispatch roster (enabled, available, not excluded). */
|
|
81866
|
+
eligible: boolean(),
|
|
81867
|
+
cell: StepSwitchCellSchema
|
|
81868
|
+
});
|
|
81869
|
+
var StepSwitchNodeSchema = object({
|
|
81870
|
+
nodeId: string(),
|
|
81871
|
+
/** False when the node's catalog or device probe did not answer — no cells are claimed. */
|
|
81872
|
+
reachable: boolean(),
|
|
81873
|
+
/** The node switch as stored (`stepEnabled[step]`); `null` = inherit. */
|
|
81874
|
+
stepEnabled: boolean().nullable(),
|
|
81875
|
+
devices: array(StepSwitchDeviceSchema).readonly()
|
|
81876
|
+
});
|
|
81877
|
+
var StepSwitchMatrixSchema = object({ steps: array(object({
|
|
81878
|
+
stepId: string(),
|
|
81879
|
+
name: string(),
|
|
81880
|
+
slot: string(),
|
|
81881
|
+
/** The stored cluster mode; `null` = the catalog default applies. */
|
|
81882
|
+
clusterMode: StepClusterModeSchema.nullable(),
|
|
81883
|
+
/** The mode in force (stored, else derived from `enabledByDefault`). */
|
|
81884
|
+
effectiveMode: StepClusterModeSchema,
|
|
81885
|
+
/** Cameras whose `stepToggles[step]` is `true`. */
|
|
81886
|
+
camerasEnabling: number$1().int().nonnegative(),
|
|
81887
|
+
/** Cameras whose `stepToggles[step]` is `false`. */
|
|
81888
|
+
camerasDisabling: number$1().int().nonnegative(),
|
|
81889
|
+
nodes: array(StepSwitchNodeSchema).readonly()
|
|
81890
|
+
})).readonly() });
|
|
81891
|
+
/**
|
|
81694
81892
|
* Pipeline Orchestrator capability — global load balancer + camera dispatcher.
|
|
81695
81893
|
*
|
|
81696
81894
|
* Lives on the hub. Tracks the camera-to-agent assignment map, listens to
|
|
@@ -82063,6 +82261,51 @@ var pipelineOrchestratorCapability = {
|
|
|
82063
82261
|
auth: "admin"
|
|
82064
82262
|
}),
|
|
82065
82263
|
/**
|
|
82264
|
+
* Set one step's CLUSTER switch (D1065): `off` | `on` | `opt-in`, or
|
|
82265
|
+
* `null` to return to the catalog default. Re-resolves every placed
|
|
82266
|
+
* camera's pipeline.
|
|
82267
|
+
*/
|
|
82268
|
+
setClusterStepMode: method(object({
|
|
82269
|
+
stepId: string(),
|
|
82270
|
+
mode: StepClusterModeSchema.nullable()
|
|
82271
|
+
}), object({ success: literal(true) }), {
|
|
82272
|
+
kind: "mutation",
|
|
82273
|
+
auth: "admin"
|
|
82274
|
+
}),
|
|
82275
|
+
/**
|
|
82276
|
+
* Set one step's NODE switch (D1065): `false` = the step never runs on a
|
|
82277
|
+
* camera whose pipeline runs on that node; `null` = inherit.
|
|
82278
|
+
*/
|
|
82279
|
+
setNodeStepEnabled: method(object({
|
|
82280
|
+
agentNodeId: string(),
|
|
82281
|
+
stepId: string(),
|
|
82282
|
+
enabled: boolean().nullable()
|
|
82283
|
+
}), object({ success: literal(true) }), {
|
|
82284
|
+
kind: "mutation",
|
|
82285
|
+
auth: "admin"
|
|
82286
|
+
}),
|
|
82287
|
+
/**
|
|
82288
|
+
* Set one step's DEVICE switch (D1065) on `(node, deviceKey)`: `false` =
|
|
82289
|
+
* the step is not provisioned there (a detail step jumps to an allowed
|
|
82290
|
+
* sibling, else is skipped); `null` = inherit.
|
|
82291
|
+
*/
|
|
82292
|
+
setDeviceStepEnabled: method(object({
|
|
82293
|
+
agentNodeId: string(),
|
|
82294
|
+
deviceKey: string(),
|
|
82295
|
+
stepId: string(),
|
|
82296
|
+
enabled: boolean().nullable()
|
|
82297
|
+
}), object({ success: literal(true) }), {
|
|
82298
|
+
kind: "mutation",
|
|
82299
|
+
auth: "admin"
|
|
82300
|
+
}),
|
|
82301
|
+
/**
|
|
82302
|
+
* The step switch matrix (D1065): per step, the cluster mode, how many
|
|
82303
|
+
* cameras turn it on / off, and per node and device the effective cell —
|
|
82304
|
+
* computed by the same placement function the attach path runs. The
|
|
82305
|
+
* inspector renders this; it never derives a cell itself.
|
|
82306
|
+
*/
|
|
82307
|
+
getStepSwitches: method(_void(), StepSwitchMatrixSchema),
|
|
82308
|
+
/**
|
|
82066
82309
|
* DEVICE-AWARE merged view of ONE node's inference accelerators. Joins each
|
|
82067
82310
|
* physical device the node HAS — probed live via a node-pinned
|
|
82068
82311
|
* `platformProbe.getCapabilities` (the platform-probe singleton is targeted
|
|
@@ -92316,7 +92559,7 @@ var WorkloadPortSchema = object({
|
|
|
92316
92559
|
hostIp: string().nullable(),
|
|
92317
92560
|
protocol: WorkloadPortProtocolSchema
|
|
92318
92561
|
});
|
|
92319
|
-
object({
|
|
92562
|
+
var WorkloadStatusSchema = object({
|
|
92320
92563
|
/** null = unknown, never stopped (D393). */
|
|
92321
92564
|
state: WorkloadStateSchema.nullable().meta({ label: "State" }),
|
|
92322
92565
|
/** Epoch ms the current state began (uptime while running); null when unknown. */
|
|
@@ -93770,23 +94013,56 @@ var fountainContribution = contribution("pet-fountain", PetFountainStatusSchema,
|
|
|
93770
94013
|
};
|
|
93771
94014
|
});
|
|
93772
94015
|
var minutesOf = (seconds) => Math.max(0, Math.round(seconds / 60));
|
|
94016
|
+
var pumpCycleContribution = contribution("pump-cycle", PumpCycleStatusSchema, (slice) => {
|
|
94017
|
+
const enabled = slice?.enabled ?? null;
|
|
94018
|
+
const cycle = slice?.onTime != null && slice.offTime != null ? t(`${minutesOf(slice.onTime)} min on · ${minutesOf(slice.offTime)} min off`, `${minutesOf(slice.onTime)} min acceso · ${minutesOf(slice.offTime)} min spento`) : null;
|
|
94019
|
+
return { rows: [row$1("pump-cycle", "timer", enabled === null ? unknownText : enabled ? joinText([t("Cycling", "A cicli"), cycle]) : t("Runs continuously", "Sempre attiva"), [{
|
|
94020
|
+
kind: "toggle",
|
|
94021
|
+
id: "pump-cycle.enabled",
|
|
94022
|
+
label: t("Pump cycle", "Ciclo pompa"),
|
|
94023
|
+
on: enabled,
|
|
94024
|
+
turnOn: action("pump-cycle.on", t("Cycle the pump", "Attiva il ciclo"), "timer", "pump-cycle", "setEnabled", { on: true }),
|
|
94025
|
+
turnOff: action("pump-cycle.off", t("Run continuously", "Sempre attiva"), "timer-off", "pump-cycle", "setEnabled", { on: false })
|
|
94026
|
+
}])] };
|
|
94027
|
+
});
|
|
94028
|
+
var WORKLOAD_WORDS = {
|
|
94029
|
+
running: {
|
|
94030
|
+
state: "on",
|
|
94031
|
+
title: t("Running", "In esecuzione")
|
|
94032
|
+
},
|
|
94033
|
+
paused: {
|
|
94034
|
+
state: "standby",
|
|
94035
|
+
title: t("Paused", "In pausa")
|
|
94036
|
+
},
|
|
94037
|
+
stopped: {
|
|
94038
|
+
state: "off",
|
|
94039
|
+
title: t("Stopped", "Fermo")
|
|
94040
|
+
},
|
|
94041
|
+
starting: {
|
|
94042
|
+
state: "running",
|
|
94043
|
+
title: t("Starting", "In avvio")
|
|
94044
|
+
},
|
|
94045
|
+
stopping: {
|
|
94046
|
+
state: "running",
|
|
94047
|
+
title: t("Stopping", "In arresto")
|
|
94048
|
+
},
|
|
94049
|
+
crashed: {
|
|
94050
|
+
state: "alert",
|
|
94051
|
+
title: t("Crashed", "Andato in errore")
|
|
94052
|
+
}
|
|
94053
|
+
};
|
|
93773
94054
|
var DEVICES_FAMILY_CONTRIBUTIONS = {
|
|
93774
94055
|
"fan-control": fanContribution,
|
|
93775
94056
|
"vacuum-control": vacuumContribution,
|
|
93776
94057
|
"lawn-mower-control": mowerContribution,
|
|
93777
94058
|
"pet-feeder": feederContribution,
|
|
93778
94059
|
"pet-fountain": fountainContribution,
|
|
93779
|
-
"pump-cycle":
|
|
93780
|
-
|
|
93781
|
-
const
|
|
93782
|
-
|
|
93783
|
-
|
|
93784
|
-
|
|
93785
|
-
label: t("Pump cycle", "Ciclo pompa"),
|
|
93786
|
-
on: enabled,
|
|
93787
|
-
turnOn: action("pump-cycle.on", t("Cycle the pump", "Attiva il ciclo"), "timer", "pump-cycle", "setEnabled", { on: true }),
|
|
93788
|
-
turnOff: action("pump-cycle.off", t("Run continuously", "Sempre attiva"), "timer-off", "pump-cycle", "setEnabled", { on: false })
|
|
93789
|
-
}])] };
|
|
94060
|
+
"pump-cycle": pumpCycleContribution,
|
|
94061
|
+
workload: contribution("workload", WorkloadStatusSchema, (slice) => {
|
|
94062
|
+
const state = slice?.state ?? null;
|
|
94063
|
+
if (state === null) return { reading: reading("workload", "unknown") };
|
|
94064
|
+
const words = WORKLOAD_WORDS[state];
|
|
94065
|
+
return { reading: reading("workload", words.state, false, words.title) };
|
|
93790
94066
|
})
|
|
93791
94067
|
};
|
|
93792
94068
|
/**
|
|
@@ -102803,6 +103079,13 @@ Object.freeze({
|
|
|
102803
103079
|
access: "view",
|
|
102804
103080
|
role: "admin"
|
|
102805
103081
|
},
|
|
103082
|
+
"pipelineOrchestrator.getStepSwitches": {
|
|
103083
|
+
capName: "pipeline-orchestrator",
|
|
103084
|
+
capScope: "system",
|
|
103085
|
+
addonId: null,
|
|
103086
|
+
access: "view",
|
|
103087
|
+
role: "admin"
|
|
103088
|
+
},
|
|
102806
103089
|
"pipelineOrchestrator.listAgentSettings": {
|
|
102807
103090
|
capName: "pipeline-orchestrator",
|
|
102808
103091
|
capScope: "system",
|
|
@@ -102957,6 +103240,20 @@ Object.freeze({
|
|
|
102957
103240
|
access: "create",
|
|
102958
103241
|
role: "admin"
|
|
102959
103242
|
},
|
|
103243
|
+
"pipelineOrchestrator.setClusterStepMode": {
|
|
103244
|
+
capName: "pipeline-orchestrator",
|
|
103245
|
+
capScope: "system",
|
|
103246
|
+
addonId: null,
|
|
103247
|
+
access: "create",
|
|
103248
|
+
role: "admin"
|
|
103249
|
+
},
|
|
103250
|
+
"pipelineOrchestrator.setDeviceStepEnabled": {
|
|
103251
|
+
capName: "pipeline-orchestrator",
|
|
103252
|
+
capScope: "system",
|
|
103253
|
+
addonId: null,
|
|
103254
|
+
access: "create",
|
|
103255
|
+
role: "admin"
|
|
103256
|
+
},
|
|
102960
103257
|
"pipelineOrchestrator.setLoadBalancingShares": {
|
|
102961
103258
|
capName: "pipeline-orchestrator",
|
|
102962
103259
|
capScope: "system",
|
|
@@ -102964,6 +103261,13 @@ Object.freeze({
|
|
|
102964
103261
|
access: "create",
|
|
102965
103262
|
role: "admin"
|
|
102966
103263
|
},
|
|
103264
|
+
"pipelineOrchestrator.setNodeStepEnabled": {
|
|
103265
|
+
capName: "pipeline-orchestrator",
|
|
103266
|
+
capScope: "system",
|
|
103267
|
+
addonId: null,
|
|
103268
|
+
access: "create",
|
|
103269
|
+
role: "admin"
|
|
103270
|
+
},
|
|
102967
103271
|
"pipelineOrchestrator.setNodeStepSettings": {
|
|
102968
103272
|
capName: "pipeline-orchestrator",
|
|
102969
103273
|
capScope: "system",
|
|
@@ -114931,6 +115235,52 @@ function createDiskReconcileJobRunner(now = Date.now) {
|
|
|
114931
115235
|
};
|
|
114932
115236
|
}
|
|
114933
115237
|
//#endregion
|
|
115238
|
+
//#region src/node-step-settings.ts
|
|
115239
|
+
/**
|
|
115240
|
+
* The provisioning base for `deviceKey` (`''` = the runner's default pool,
|
|
115241
|
+
* which has no device entry and takes the node layer alone). Pure; fresh
|
|
115242
|
+
* objects only.
|
|
115243
|
+
*/
|
|
115244
|
+
function nodeDeviceBase(node, deviceKey) {
|
|
115245
|
+
const own = node?.inferenceDevices?.[deviceKey]?.steps ?? {};
|
|
115246
|
+
const nodeLayer = node?.stepSettings ?? {};
|
|
115247
|
+
const out = {};
|
|
115248
|
+
for (const stepId of new Set([...Object.keys(nodeLayer), ...Object.keys(own)])) {
|
|
115249
|
+
const device = own[stepId];
|
|
115250
|
+
const merged = {
|
|
115251
|
+
...nodeLayer[stepId],
|
|
115252
|
+
...device?.settings
|
|
115253
|
+
};
|
|
115254
|
+
out[stepId] = {
|
|
115255
|
+
...device?.modelId !== void 0 ? { modelId: device.modelId } : {},
|
|
115256
|
+
...device?.jumpDeviceKey !== void 0 ? { jumpDeviceKey: device.jumpDeviceKey } : {},
|
|
115257
|
+
...Object.keys(merged).length > 0 ? { settings: merged } : {}
|
|
115258
|
+
};
|
|
115259
|
+
}
|
|
115260
|
+
return out;
|
|
115261
|
+
}
|
|
115262
|
+
/**
|
|
115263
|
+
* The steps switched OFF on `deviceKey` of this node (D1065):
|
|
115264
|
+
* `inferenceDevices[deviceKey].steps[step].enabled === false`. Only that
|
|
115265
|
+
* device's own entry is read; `''` (the default pool) has none.
|
|
115266
|
+
*/
|
|
115267
|
+
function deviceDisabledSteps(node, deviceKey) {
|
|
115268
|
+
const steps = node?.inferenceDevices?.[deviceKey]?.steps ?? {};
|
|
115269
|
+
return new Set(Object.entries(steps).filter(([, cfg]) => cfg.enabled === false).map(([stepId]) => stepId));
|
|
115270
|
+
}
|
|
115271
|
+
/**
|
|
115272
|
+
* The steps a DEFAULT-POOL attach (no elected device) must not run (D1065):
|
|
115273
|
+
* those switched off on EVERY device the pool may be. The pool is the node's
|
|
115274
|
+
* eligible devices (one eligible device IS the pool, D745); with none
|
|
115275
|
+
* eligible it is any device the node has enabled. A step one of them still
|
|
115276
|
+
* allows is kept — the pool may be that device. No candidate ⇒ nothing.
|
|
115277
|
+
*/
|
|
115278
|
+
function poolDisabledSteps(node, eligibleKeys) {
|
|
115279
|
+
const [first, ...rest] = (eligibleKeys.length > 0 ? eligibleKeys : Object.entries(node?.inferenceDevices ?? {}).filter(([, device]) => device.enabled).map(([key]) => key)).map((key) => deviceDisabledSteps(node, key));
|
|
115280
|
+
if (first === void 0) return /* @__PURE__ */ new Set();
|
|
115281
|
+
return new Set([...first].filter((stepId) => rest.every((steps) => steps.has(stepId))));
|
|
115282
|
+
}
|
|
115283
|
+
//#endregion
|
|
114934
115284
|
//#region src/pipeline-resolver.ts
|
|
114935
115285
|
/**
|
|
114936
115286
|
* The `package-detection` root step id. Zone-driven activation
|
|
@@ -115007,38 +115357,86 @@ function addonHasCompatibleModel(addon, format) {
|
|
|
115007
115357
|
function isVideoRoot(addon) {
|
|
115008
115358
|
return (addon.inputClasses ?? []).length === 0;
|
|
115009
115359
|
}
|
|
115010
|
-
/**
|
|
115011
|
-
|
|
115012
|
-
|
|
115013
|
-
|
|
115014
|
-
|
|
115015
|
-
|
|
115016
|
-
|
|
115017
|
-
|
|
115018
|
-
|
|
115019
|
-
|
|
115020
|
-
|
|
115021
|
-
|
|
115022
|
-
|
|
115023
|
-
|
|
115024
|
-
|
|
115025
|
-
|
|
115026
|
-
|
|
115027
|
-
|
|
115028
|
-
|
|
115360
|
+
/** The cluster mode a step runs under when none is stored: the catalog default. */
|
|
115361
|
+
function defaultClusterStepMode(addon) {
|
|
115362
|
+
return addon.enabledByDefault === false ? "opt-in" : "on";
|
|
115363
|
+
}
|
|
115364
|
+
/** The cluster mode in force: the stored one, else the catalog default. */
|
|
115365
|
+
function effectiveClusterStepMode(addon, stored) {
|
|
115366
|
+
return stored ?? defaultClusterStepMode(addon);
|
|
115367
|
+
}
|
|
115368
|
+
function gateStep(addon, layers) {
|
|
115369
|
+
const mode = effectiveClusterStepMode(addon, layers.clusterMode);
|
|
115370
|
+
if (mode === "off") return {
|
|
115371
|
+
kind: "off",
|
|
115372
|
+
reason: "disabled-on-cluster"
|
|
115373
|
+
};
|
|
115374
|
+
if (!(layers.cameraToggle ?? mode === "on")) return {
|
|
115375
|
+
kind: "off",
|
|
115376
|
+
reason: "disabled-on-camera"
|
|
115377
|
+
};
|
|
115378
|
+
if (layers.nodeEnabled === false) return {
|
|
115379
|
+
kind: "off",
|
|
115380
|
+
reason: "disabled-on-node"
|
|
115381
|
+
};
|
|
115382
|
+
return { kind: "on" };
|
|
115383
|
+
}
|
|
115384
|
+
function placeStepOnDevices(addon, elected, roster) {
|
|
115385
|
+
if (addon.slot === "audio-classifier") return { kind: "run" };
|
|
115386
|
+
const builds = (slot) => addonHasCompatibleModel(addon, slot.format);
|
|
115387
|
+
const allowed = (slot) => !slot.disabledSteps.has(addon.id);
|
|
115388
|
+
const electedBuild = builds(elected);
|
|
115389
|
+
if (electedBuild && allowed(elected)) return { kind: "run" };
|
|
115390
|
+
if (isVideoRoot(addon)) {
|
|
115391
|
+
if (!allowed(elected)) return {
|
|
115392
|
+
kind: "skip",
|
|
115393
|
+
reason: "disabled-on-device"
|
|
115394
|
+
};
|
|
115395
|
+
return roster.some(builds) ? {
|
|
115396
|
+
kind: "skip",
|
|
115397
|
+
reason: "root-not-runnable-on-elected-device"
|
|
115398
|
+
} : {
|
|
115399
|
+
kind: "skip",
|
|
115400
|
+
reason: "no-compatible-model"
|
|
115401
|
+
};
|
|
115402
|
+
}
|
|
115403
|
+
const first = roster.filter((slot) => builds(slot) && allowed(slot)).toSorted((a, b) => slotOrderKey(a).localeCompare(slotOrderKey(b)))[0];
|
|
115404
|
+
if (first !== void 0) return {
|
|
115405
|
+
kind: "jump",
|
|
115406
|
+
toDeviceKey: first.deviceKey
|
|
115407
|
+
};
|
|
115408
|
+
return {
|
|
115409
|
+
kind: "skip",
|
|
115410
|
+
reason: electedBuild && !allowed(elected) || roster.some(builds) ? "disabled-on-device" : "no-compatible-model"
|
|
115411
|
+
};
|
|
115412
|
+
}
|
|
115413
|
+
function slotOrderKey(slot) {
|
|
115414
|
+
return slot.deviceKey ?? slot.format;
|
|
115415
|
+
}
|
|
115416
|
+
var NO_STEPS = /* @__PURE__ */ new Set();
|
|
115417
|
+
/** The gate layers of `addonId` read from a switch context (absent entries stay absent). */
|
|
115418
|
+
function gateLayersOf(addonId, switches) {
|
|
115419
|
+
const clusterMode = switches.clusterModes?.[addonId];
|
|
115420
|
+
const nodeEnabled = switches.nodeStepEnabled?.[addonId];
|
|
115421
|
+
return {
|
|
115422
|
+
...clusterMode !== void 0 ? { clusterMode } : {},
|
|
115423
|
+
...nodeEnabled !== void 0 ? { nodeEnabled } : {}
|
|
115424
|
+
};
|
|
115029
115425
|
}
|
|
115030
115426
|
/**
|
|
115031
115427
|
* Device-aware resolver — the SINGLE per-camera gate + per-DEVICE skip check.
|
|
115032
115428
|
*
|
|
115033
115429
|
* Step `S` runs for camera `C` on device `D` ⇔
|
|
115034
|
-
* gate(C, S)
|
|
115035
|
-
*
|
|
115430
|
+
* gate(C, N, S) — {@link gateStep}: cluster not off, the camera toggle
|
|
115431
|
+
* (else the cluster default), the node switch (D1065)
|
|
115432
|
+
* AND provided(D, S) — {@link placeStepOnDevices}: a device not switched off
|
|
115433
|
+
* for S has a build of it — the catalog lists a model with a build for D's FORMAT
|
|
115036
115434
|
* (a ROOT), or for D's format or any `jumpFormats`
|
|
115037
115435
|
* entry (a detail step — the runner jumps it, D650);
|
|
115038
115436
|
* `audio-classifier` is never format-gated (it runs
|
|
115039
115437
|
* on the audio-analyzer's own backend)
|
|
115040
115438
|
*
|
|
115041
|
-
*
|
|
115439
|
+
* Provisioning
|
|
115042
115440
|
* (`modelId` / `settings`) is NOT applied here — the returned tree carries bare
|
|
115043
115441
|
* `{ addonId, enabled: true, children }` nodes; {@link applyDeviceProvisioning}
|
|
115044
115442
|
* attaches model + settings at dispatch from the per-(node,device) base and the
|
|
@@ -115048,30 +115446,58 @@ function unprovisionedReason(addon, electedFormat, jumpFormats) {
|
|
|
115048
115446
|
* recorded in `skipped` so the caller can surface a visible "gated on, no model
|
|
115049
115447
|
* on this node" status at dispatch time.
|
|
115050
115448
|
*
|
|
115051
|
-
* `package-detection` is excluded
|
|
115052
|
-
* ({@link applyPackageZoneActivation}, applied by the caller)
|
|
115449
|
+
* `package-detection` is excluded from the tree — it is zone-driven
|
|
115450
|
+
* ({@link applyPackageZoneActivation}, applied by the caller); the cluster,
|
|
115451
|
+
* node and elected-device switches still apply, as `packageAllowed` (D1065).
|
|
115053
115452
|
*
|
|
115054
115453
|
* "Inference disabled for this camera" is NOT handled here — the caller
|
|
115055
115454
|
* (resolvePipelineForDevice) consults the detection-pipeline binding and
|
|
115056
115455
|
* short-circuits to an empty pipeline before invoking this resolver.
|
|
115057
115456
|
*/
|
|
115058
|
-
function resolvePipelineWithSkips(cameraSettings, deviceFormat, catalog, jumpFormats = []) {
|
|
115457
|
+
function resolvePipelineWithSkips(cameraSettings, deviceFormat, catalog, jumpFormats = [], switches = {}) {
|
|
115059
115458
|
const toggles = (cameraSettings ?? {}).stepToggles ?? {};
|
|
115060
|
-
const
|
|
115459
|
+
const elected = {
|
|
115460
|
+
format: deviceFormat,
|
|
115461
|
+
disabledSteps: switches.electedDisabledSteps ?? NO_STEPS
|
|
115462
|
+
};
|
|
115463
|
+
const roster = switches.jumpTargets ?? jumpFormats.map((format) => ({
|
|
115464
|
+
format,
|
|
115465
|
+
disabledSteps: NO_STEPS
|
|
115466
|
+
}));
|
|
115467
|
+
let packageAllowed = true;
|
|
115061
115468
|
const enabled = [];
|
|
115062
115469
|
const skipped = [];
|
|
115063
115470
|
const droppedRoots = [];
|
|
115064
115471
|
for (const slot of catalog.slots) for (const addon of slot.addons) {
|
|
115065
115472
|
const addonId = addon.id;
|
|
115066
|
-
|
|
115067
|
-
if (
|
|
115068
|
-
|
|
115069
|
-
|
|
115473
|
+
const layers = gateLayersOf(addonId, switches);
|
|
115474
|
+
if (addonId === "package-detection") {
|
|
115475
|
+
packageAllowed = gateStep(addon, {
|
|
115476
|
+
...layers,
|
|
115477
|
+
cameraToggle: true
|
|
115478
|
+
}).kind === "on" && !elected.disabledSteps.has(addonId);
|
|
115479
|
+
continue;
|
|
115480
|
+
}
|
|
115481
|
+
const cameraToggle = toggles[addonId];
|
|
115482
|
+
const gate = gateStep(addon, {
|
|
115483
|
+
...layers,
|
|
115484
|
+
...cameraToggle !== void 0 ? { cameraToggle } : {}
|
|
115485
|
+
});
|
|
115486
|
+
if (gate.kind === "off") {
|
|
115487
|
+
if (gate.reason !== "disabled-on-camera") skipped.push({
|
|
115488
|
+
addonId,
|
|
115489
|
+
reason: gate.reason
|
|
115490
|
+
});
|
|
115491
|
+
continue;
|
|
115492
|
+
}
|
|
115493
|
+
const placement = placeStepOnDevices(addon, elected, roster);
|
|
115494
|
+
if (placement.kind === "skip") {
|
|
115495
|
+
const reason = placement.reason;
|
|
115070
115496
|
skipped.push({
|
|
115071
115497
|
addonId,
|
|
115072
115498
|
reason
|
|
115073
115499
|
});
|
|
115074
|
-
if (addonId === "object-detection") droppedRoots.push(addonId);
|
|
115500
|
+
if (addonId === "object-detection" && reason !== "disabled-on-device") droppedRoots.push(addonId);
|
|
115075
115501
|
continue;
|
|
115076
115502
|
}
|
|
115077
115503
|
enabled.push({ addonId });
|
|
@@ -115090,7 +115516,8 @@ function resolvePipelineWithSkips(cameraSettings, deviceFormat, catalog, jumpFor
|
|
|
115090
115516
|
audio: audioAddons.length > 0 ? { enabled: true } : null
|
|
115091
115517
|
},
|
|
115092
115518
|
skipped,
|
|
115093
|
-
droppedRoots
|
|
115519
|
+
droppedRoots,
|
|
115520
|
+
packageAllowed
|
|
115094
115521
|
};
|
|
115095
115522
|
}
|
|
115096
115523
|
function findInCatalog(catalog, addonId) {
|
|
@@ -115194,6 +115621,29 @@ function makeRootCapabilityGuard(catalog) {
|
|
|
115194
115621
|
}
|
|
115195
115622
|
return () => true;
|
|
115196
115623
|
}
|
|
115624
|
+
/**
|
|
115625
|
+
* The camera-root SWITCH predicate for a node: `deviceKey → is the root on`.
|
|
115626
|
+
* The root ({@link OBJECT_DETECTION_STEP_ID}) is judged by the same
|
|
115627
|
+
* {@link gateStep} the attach path runs — cluster mode, then the node switch —
|
|
115628
|
+
* and then by the device's own step switch (D1065). The camera toggle is not a
|
|
115629
|
+
* layer here: the election picks a device for every camera of the node, and a
|
|
115630
|
+
* camera that turned its root off is refused by the attach itself.
|
|
115631
|
+
*
|
|
115632
|
+
* Fails OPEN when the catalog has no object-detection slot, like
|
|
115633
|
+
* {@link makeRootCapabilityGuard}. Pure.
|
|
115634
|
+
*/
|
|
115635
|
+
function makeRootSwitchGuard(catalog, clusterModes, node) {
|
|
115636
|
+
const root = catalog.slots.flatMap((slot) => slot.addons).find((a) => a.id === OBJECT_DETECTION_STEP_ID);
|
|
115637
|
+
if (root === void 0) return () => true;
|
|
115638
|
+
const clusterMode = clusterModes[OBJECT_DETECTION_STEP_ID];
|
|
115639
|
+
const nodeEnabled = node?.stepEnabled?.[OBJECT_DETECTION_STEP_ID];
|
|
115640
|
+
if (gateStep(root, {
|
|
115641
|
+
...clusterMode !== void 0 ? { clusterMode } : {},
|
|
115642
|
+
...nodeEnabled !== void 0 ? { nodeEnabled } : {},
|
|
115643
|
+
cameraToggle: true
|
|
115644
|
+
}).kind === "off") return () => false;
|
|
115645
|
+
return (deviceKey) => !deviceDisabledSteps(node, deviceKey).has(OBJECT_DETECTION_STEP_ID);
|
|
115646
|
+
}
|
|
115197
115647
|
/** Split a deviceKey (`<backend>:<device>`, or bare `cpu`) into its parts + format.
|
|
115198
115648
|
* Format comes from the shared {@link deviceBackendToFormat} SSOT (`@camstack/types`)
|
|
115199
115649
|
* — the previously-local `BACKEND_FORMAT` copy is gone (R3/node-F2). Used only for
|
|
@@ -115321,11 +115771,11 @@ function inferenceDeviceCaps(stored) {
|
|
|
115321
115771
|
function isCpuFallback(view) {
|
|
115322
115772
|
return view.backend === "cpu";
|
|
115323
115773
|
}
|
|
115324
|
-
function resolveInferenceDeviceEligibility(probed, stored, canRunRoot, isPoolUsable) {
|
|
115774
|
+
function resolveInferenceDeviceEligibility(probed, stored, canRunRoot, isPoolUsable, isRootSwitchedOn) {
|
|
115325
115775
|
const eligible = {};
|
|
115326
115776
|
const excluded = [];
|
|
115327
115777
|
const merged = mergeInferenceDevices(probed, stored);
|
|
115328
|
-
const acceleratorServes = merged.some((d) => !isCpuFallback(d) && d.enabled && d.available && (!canRunRoot || canRunRoot(d.format)));
|
|
115778
|
+
const acceleratorServes = merged.some((d) => !isCpuFallback(d) && d.enabled && d.available && (!canRunRoot || canRunRoot(d.format)) && (!isRootSwitchedOn || isRootSwitchedOn(d.key)));
|
|
115329
115779
|
for (const d of merged) {
|
|
115330
115780
|
if (!d.enabled) {
|
|
115331
115781
|
excluded.push({
|
|
@@ -115359,6 +115809,14 @@ function resolveInferenceDeviceEligibility(probed, stored, canRunRoot, isPoolUsa
|
|
|
115359
115809
|
});
|
|
115360
115810
|
continue;
|
|
115361
115811
|
}
|
|
115812
|
+
if (isRootSwitchedOn && !isRootSwitchedOn(d.key)) {
|
|
115813
|
+
excluded.push({
|
|
115814
|
+
key: d.key,
|
|
115815
|
+
reason: "root-switched-off",
|
|
115816
|
+
format: d.format
|
|
115817
|
+
});
|
|
115818
|
+
continue;
|
|
115819
|
+
}
|
|
115362
115820
|
if (isCpuFallback(d) && acceleratorServes) {
|
|
115363
115821
|
excluded.push({
|
|
115364
115822
|
key: d.key,
|
|
@@ -122339,7 +122797,7 @@ async function resolveAttachPipeline(input, store) {
|
|
|
122339
122797
|
eligible: input.eligible,
|
|
122340
122798
|
caps: input.caps
|
|
122341
122799
|
});
|
|
122342
|
-
const resolved = await store.resolvePipelineForDeviceWithRoots(input.deviceId, input.nodeId, input.deviceKey, jumpTargetKeys(roster, input.deviceKey));
|
|
122800
|
+
const resolved = await store.resolvePipelineForDeviceWithRoots(input.deviceId, input.nodeId, input.deviceKey, jumpTargetKeys(roster, input.deviceKey), defaultPoolOf(input));
|
|
122343
122801
|
if (resolved.droppedRoots.length > 0) return rootRefusal(input, resolved.droppedRoots);
|
|
122344
122802
|
return {
|
|
122345
122803
|
kind: "resolved",
|
|
@@ -122360,7 +122818,7 @@ async function resolveAttachPipelineIfCatalogCached(input, store) {
|
|
|
122360
122818
|
eligible: input.eligible,
|
|
122361
122819
|
caps: input.caps
|
|
122362
122820
|
});
|
|
122363
|
-
const outcome = await store.resolvePipelineForDeviceIfCatalogCached(input.deviceId, input.nodeId, input.deviceKey, jumpTargetKeys(roster, input.deviceKey));
|
|
122821
|
+
const outcome = await store.resolvePipelineForDeviceIfCatalogCached(input.deviceId, input.nodeId, input.deviceKey, jumpTargetKeys(roster, input.deviceKey), defaultPoolOf(input));
|
|
122364
122822
|
if (outcome.kind === "catalog-unavailable") return outcome;
|
|
122365
122823
|
if (outcome.droppedRoots.length > 0) return rootRefusal(input, outcome.droppedRoots);
|
|
122366
122824
|
return {
|
|
@@ -122368,6 +122826,10 @@ async function resolveAttachPipelineIfCatalogCached(input, store) {
|
|
|
122368
122826
|
pipeline: await provisionAttachPipeline(input, roster, outcome.config, store)
|
|
122369
122827
|
};
|
|
122370
122828
|
}
|
|
122829
|
+
/** No elected device ⇒ the runner's default pool, made of the eligible devices (D1065). */
|
|
122830
|
+
function defaultPoolOf(input) {
|
|
122831
|
+
return input.deviceKey === void 0 ? { eligibleKeys: Object.keys(input.eligible) } : void 0;
|
|
122832
|
+
}
|
|
122371
122833
|
function rootRefusal(input, droppedRoots) {
|
|
122372
122834
|
return {
|
|
122373
122835
|
kind: "root-refused",
|
|
@@ -122401,9 +122863,11 @@ async function provisionAttachPipeline(input, roster, resolved, store) {
|
|
|
122401
122863
|
const steps = applyDeviceProvisioning(resolved.steps, elected?.base ?? {}, elected?.override ?? {});
|
|
122402
122864
|
const inferenceDevices = roster?.map((entry) => {
|
|
122403
122865
|
const src = sources.get(entry.deviceKey);
|
|
122866
|
+
const disabledSteps = src?.disabledSteps ?? [];
|
|
122404
122867
|
return {
|
|
122405
122868
|
...entry,
|
|
122406
|
-
steps: provisionDeviceSteps(resolved.steps, src?.base ?? {}, src?.override ?? {})
|
|
122869
|
+
steps: provisionDeviceSteps(resolved.steps, src?.base ?? {}, src?.override ?? {}),
|
|
122870
|
+
...disabledSteps.length > 0 ? { disabledSteps } : {}
|
|
122407
122871
|
};
|
|
122408
122872
|
});
|
|
122409
122873
|
return {
|
|
@@ -122870,6 +123334,26 @@ var PlacementService = class {
|
|
|
122870
123334
|
}, this.deps.settingsStore);
|
|
122871
123335
|
}
|
|
122872
123336
|
/**
|
|
123337
|
+
* What an attach of `deviceId` on `nodeId` WOULD run — the `resolvePipeline`
|
|
123338
|
+
* preview. Same owner as a dispatch ({@link resolveAttachPipeline}), on the
|
|
123339
|
+
* device the camera is elected onto when it is placed on that node; for a
|
|
123340
|
+
* camera placed elsewhere (or nowhere), on the node's highest-weight eligible
|
|
123341
|
+
* device (ties by key), or the default pool when it has none. Before, the
|
|
123342
|
+
* preview resolved on the node's default format with no jump roster, and
|
|
123343
|
+
* reported the detail steps a sibling accelerator runs as dropped.
|
|
123344
|
+
*/
|
|
123345
|
+
async previewAttachPipeline(input) {
|
|
123346
|
+
const [eligible, caps] = await Promise.all([this.deps.getEligibleInferenceDevices(input.nodeId), this.deps.getInferenceDeviceCaps(input.nodeId)]);
|
|
123347
|
+
const deviceKey = this.deps.ledger.getAssignment(input.deviceId)?.agentNodeId === input.nodeId ? this.deps.ledger.getConfig(input.deviceId)?.deviceKey : Object.entries(eligible).toSorted(([ka, wa], [kb, wb]) => wb - wa || ka.localeCompare(kb))[0]?.[0];
|
|
123348
|
+
return resolveAttachPipeline({
|
|
123349
|
+
deviceId: input.deviceId,
|
|
123350
|
+
nodeId: input.nodeId,
|
|
123351
|
+
deviceKey,
|
|
123352
|
+
eligible,
|
|
123353
|
+
caps
|
|
123354
|
+
}, this.deps.settingsStore);
|
|
123355
|
+
}
|
|
123356
|
+
/**
|
|
122873
123357
|
* FIRST placement of a standing camera: waits for the chosen node's catalog
|
|
122874
123358
|
* (the resolve reconciles against its executor until it answers). Callers:
|
|
122875
123359
|
* `startDetection`'s standing path — one camera, nothing to attach instead.
|
|
@@ -123419,6 +123903,129 @@ var PlacementService = class {
|
|
|
123419
123903
|
for (const deviceId of affected) await this.deps.emitResolvedCameraUpdated(deviceId);
|
|
123420
123904
|
}
|
|
123421
123905
|
/**
|
|
123906
|
+
* A step switch changed (D1065): re-resolve the attach pipeline of every
|
|
123907
|
+
* placed camera — on `nodeId`, or on every node when `null` (a cluster
|
|
123908
|
+
* switch) — on the device it is already elected onto, through the one owner
|
|
123909
|
+
* of an attach's steps ({@link resolveAttachPipelineOnDevice}). Only a camera
|
|
123910
|
+
* whose resolved steps, audio, device or roster DIFFERS from its cached
|
|
123911
|
+
* attach is re-attached; the rest are left running untouched. A camera whose
|
|
123912
|
+
* root (`object-detection`) the switch took away from its elected device is
|
|
123913
|
+
* RE-ELECTED through the normal placement path ({@link reelectAfterRootSwitch}),
|
|
123914
|
+
* which already excludes a device the root is off on. One camera's failure is
|
|
123915
|
+
* logged and does not stop the sweep; a refused root keeps the live attach.
|
|
123916
|
+
*/
|
|
123917
|
+
async reattachForStepSwitch(nodeId, reason) {
|
|
123918
|
+
const affected = [];
|
|
123919
|
+
for (const [deviceId, assignment] of this.deps.ledger.assignmentEntries()) if (nodeId === null || assignment.agentNodeId === nodeId) affected.push({
|
|
123920
|
+
deviceId,
|
|
123921
|
+
nodeId: assignment.agentNodeId
|
|
123922
|
+
});
|
|
123923
|
+
if (affected.length === 0) return;
|
|
123924
|
+
const logger = this.deps.ctx().logger;
|
|
123925
|
+
let changed = 0;
|
|
123926
|
+
let unchanged = 0;
|
|
123927
|
+
for (const target of affected) {
|
|
123928
|
+
const tags = {
|
|
123929
|
+
deviceId: target.deviceId,
|
|
123930
|
+
nodeId: target.nodeId
|
|
123931
|
+
};
|
|
123932
|
+
const cached = this.deps.ledger.getConfig(target.deviceId);
|
|
123933
|
+
if (!cached) {
|
|
123934
|
+
logger.warn("step switch re-attach skipped — no cached config for a placed camera", {
|
|
123935
|
+
tags,
|
|
123936
|
+
meta: { reason }
|
|
123937
|
+
});
|
|
123938
|
+
unchanged++;
|
|
123939
|
+
continue;
|
|
123940
|
+
}
|
|
123941
|
+
try {
|
|
123942
|
+
const outcome = await this.resolveAttachPipelineOnDevice({
|
|
123943
|
+
deviceId: target.deviceId,
|
|
123944
|
+
nodeId: target.nodeId,
|
|
123945
|
+
deviceKey: cached.deviceKey
|
|
123946
|
+
});
|
|
123947
|
+
if (outcome.kind === "root-refused") {
|
|
123948
|
+
logger.error("step switch re-attach refused — the elected device cannot run the camera root", {
|
|
123949
|
+
tags,
|
|
123950
|
+
meta: {
|
|
123951
|
+
deviceKey: outcome.deviceKey ?? null,
|
|
123952
|
+
droppedRoots: outcome.droppedRoots.join(",")
|
|
123953
|
+
}
|
|
123954
|
+
});
|
|
123955
|
+
unchanged++;
|
|
123956
|
+
continue;
|
|
123957
|
+
}
|
|
123958
|
+
const next = withAttachPipeline(cached, outcome.pipeline);
|
|
123959
|
+
if (hasCameraRoot(cached.steps) && !hasCameraRoot(next.steps)) {
|
|
123960
|
+
await this.reelectAfterRootSwitch(cached, target.nodeId, reason);
|
|
123961
|
+
changed++;
|
|
123962
|
+
continue;
|
|
123963
|
+
}
|
|
123964
|
+
if (sameAttachPipeline(cached, next)) {
|
|
123965
|
+
unchanged++;
|
|
123966
|
+
continue;
|
|
123967
|
+
}
|
|
123968
|
+
this.deps.ledger.setConfig(target.deviceId, next);
|
|
123969
|
+
await this.attachOn(target.nodeId, next);
|
|
123970
|
+
changed++;
|
|
123971
|
+
} catch (err) {
|
|
123972
|
+
logger.warn("step switch re-attach failed", {
|
|
123973
|
+
tags,
|
|
123974
|
+
meta: {
|
|
123975
|
+
reason,
|
|
123976
|
+
error: errMsg$2(err)
|
|
123977
|
+
}
|
|
123978
|
+
});
|
|
123979
|
+
}
|
|
123980
|
+
}
|
|
123981
|
+
logger.info("step switch changed — re-attached the affected cameras", {
|
|
123982
|
+
...nodeId !== null ? { tags: { nodeId } } : {},
|
|
123983
|
+
meta: {
|
|
123984
|
+
reason,
|
|
123985
|
+
changed,
|
|
123986
|
+
unchanged
|
|
123987
|
+
}
|
|
123988
|
+
});
|
|
123989
|
+
}
|
|
123990
|
+
/**
|
|
123991
|
+
* The switch took the camera root away from the device the camera is
|
|
123992
|
+
* elected on. Re-place the camera through the normal path — its election
|
|
123993
|
+
* already excludes a device the root is off on, so it moves to an allowed
|
|
123994
|
+
* device, or the CPU / default pool when one exists. When nothing can host
|
|
123995
|
+
* the root the camera is left as it is and the reason is named: never silent.
|
|
123996
|
+
*/
|
|
123997
|
+
async reelectAfterRootSwitch(cached, nodeId, reason) {
|
|
123998
|
+
const logger = this.deps.ctx().logger;
|
|
123999
|
+
const tags = {
|
|
124000
|
+
deviceId: cached.deviceId,
|
|
124001
|
+
nodeId
|
|
124002
|
+
};
|
|
124003
|
+
const result = await this.redispatchCamera(cached);
|
|
124004
|
+
const placedConfig = this.deps.ledger.getConfig(cached.deviceId);
|
|
124005
|
+
if (result.kind === "assigned" && hasCameraRoot(placedConfig?.steps)) {
|
|
124006
|
+
logger.info("step switch took the camera root off its device — camera re-elected", {
|
|
124007
|
+
tags: {
|
|
124008
|
+
deviceId: cached.deviceId,
|
|
124009
|
+
nodeId: result.agentNodeId
|
|
124010
|
+
},
|
|
124011
|
+
meta: {
|
|
124012
|
+
reason,
|
|
124013
|
+
from: cached.deviceKey ?? "default-pool",
|
|
124014
|
+
to: placedConfig?.deviceKey ?? "default-pool"
|
|
124015
|
+
}
|
|
124016
|
+
});
|
|
124017
|
+
return;
|
|
124018
|
+
}
|
|
124019
|
+
logger.warn("step switch left no device able to host the camera root", {
|
|
124020
|
+
tags,
|
|
124021
|
+
meta: {
|
|
124022
|
+
reason: result.kind === "pending" ? this.deps.ledger.getPendingReason(cached.deviceId) ?? "pending" : "root-switched-off-on-every-eligible-device",
|
|
124023
|
+
switch: reason,
|
|
124024
|
+
deviceKey: cached.deviceKey ?? "default-pool"
|
|
124025
|
+
}
|
|
124026
|
+
});
|
|
124027
|
+
}
|
|
124028
|
+
/**
|
|
123422
124029
|
* Re-dispatch EVERY assigned camera through the REAL attach path
|
|
123423
124030
|
* (`redispatchSingleCamera` → `attachOn`), so each camera's `frameSource`
|
|
123424
124031
|
* (`local-broker` vs `remote-restream` naming the current ingest owner) is
|
|
@@ -123559,6 +124166,14 @@ var PlacementService = class {
|
|
|
123559
124166
|
});
|
|
123560
124167
|
}
|
|
123561
124168
|
};
|
|
124169
|
+
/** Does an attach's step tree carry the camera root (`object-detection`)? */
|
|
124170
|
+
function hasCameraRoot(steps) {
|
|
124171
|
+
return (steps ?? []).some((step) => step.addonId === OBJECT_DETECTION_STEP_ID);
|
|
124172
|
+
}
|
|
124173
|
+
/** Would re-attaching `next` over `current` change anything the runner acts on? */
|
|
124174
|
+
function sameAttachPipeline(current, next) {
|
|
124175
|
+
return isDeepStrictEqual(current.steps, next.steps) && isDeepStrictEqual(current.audio, next.audio) && current.deviceKey === next.deviceKey && isDeepStrictEqual(current.inferenceDevices, next.inferenceDevices);
|
|
124176
|
+
}
|
|
123562
124177
|
//#endregion
|
|
123563
124178
|
//#region src/node-lifecycle-handler.ts
|
|
123564
124179
|
var NodeLifecycleHandler = class {
|
|
@@ -125557,31 +126172,6 @@ async function reattachAfterPackageZoneChange(deps, deviceId) {
|
|
|
125557
126172
|
}
|
|
125558
126173
|
}
|
|
125559
126174
|
//#endregion
|
|
125560
|
-
//#region src/node-step-settings.ts
|
|
125561
|
-
/**
|
|
125562
|
-
* The provisioning base for `deviceKey` (`''` = the runner's default pool,
|
|
125563
|
-
* which has no device entry and takes the node layer alone). Pure; fresh
|
|
125564
|
-
* objects only.
|
|
125565
|
-
*/
|
|
125566
|
-
function nodeDeviceBase(node, deviceKey) {
|
|
125567
|
-
const own = node?.inferenceDevices?.[deviceKey]?.steps ?? {};
|
|
125568
|
-
const nodeLayer = node?.stepSettings ?? {};
|
|
125569
|
-
const out = {};
|
|
125570
|
-
for (const stepId of new Set([...Object.keys(nodeLayer), ...Object.keys(own)])) {
|
|
125571
|
-
const device = own[stepId];
|
|
125572
|
-
const merged = {
|
|
125573
|
-
...nodeLayer[stepId],
|
|
125574
|
-
...device?.settings
|
|
125575
|
-
};
|
|
125576
|
-
out[stepId] = {
|
|
125577
|
-
...device?.modelId !== void 0 ? { modelId: device.modelId } : {},
|
|
125578
|
-
...device?.jumpDeviceKey !== void 0 ? { jumpDeviceKey: device.jumpDeviceKey } : {},
|
|
125579
|
-
...Object.keys(merged).length > 0 ? { settings: merged } : {}
|
|
125580
|
-
};
|
|
125581
|
-
}
|
|
125582
|
-
return out;
|
|
125583
|
-
}
|
|
125584
|
-
//#endregion
|
|
125585
126175
|
//#region src/removed-model-pin-reset.ts
|
|
125586
126176
|
/**
|
|
125587
126177
|
* A stored model pin naming a model DELETED from its step's catalog is reset to
|
|
@@ -125804,7 +126394,8 @@ var AutoBenchmarkAttemptsSchema = record(string(), record(string(), object({
|
|
|
125804
126394
|
var StoredDeviceStepConfigSchema = object({
|
|
125805
126395
|
modelId: string().optional(),
|
|
125806
126396
|
settings: record(string(), unknown()).readonly().optional(),
|
|
125807
|
-
jumpDeviceKey: string().optional()
|
|
126397
|
+
jumpDeviceKey: string().optional(),
|
|
126398
|
+
enabled: boolean().optional()
|
|
125808
126399
|
});
|
|
125809
126400
|
var StoredAgentPipelineSettingsSchema = object({
|
|
125810
126401
|
maxCameras: number$1().int().nonnegative().nullable().default(null),
|
|
@@ -125818,6 +126409,7 @@ var StoredAgentPipelineSettingsSchema = object({
|
|
|
125818
126409
|
reachableHost: string().optional(),
|
|
125819
126410
|
color: NodeColorIdSchema.optional(),
|
|
125820
126411
|
stepSettings: record(string(), record(string(), unknown()).readonly()).optional(),
|
|
126412
|
+
stepEnabled: record(string(), boolean()).optional(),
|
|
125821
126413
|
inferenceDevices: record(string(), object({
|
|
125822
126414
|
enabled: boolean(),
|
|
125823
126415
|
weight: number$1().positive().optional(),
|
|
@@ -125825,6 +126417,7 @@ var StoredAgentPipelineSettingsSchema = object({
|
|
|
125825
126417
|
steps: record(string(), StoredDeviceStepConfigSchema).optional()
|
|
125826
126418
|
})).optional()
|
|
125827
126419
|
});
|
|
126420
|
+
var ClusterStepModesSchema = record(string(), StepClusterModeSchema);
|
|
125828
126421
|
var AgentSettingsMapSchema = record(string(), StoredAgentPipelineSettingsSchema);
|
|
125829
126422
|
var StoredCameraPipelineSettingsSchema = object({
|
|
125830
126423
|
stepToggles: record(string(), boolean()).optional(),
|
|
@@ -125946,6 +126539,12 @@ var DeviceRows = class {
|
|
|
125946
126539
|
//#endregion
|
|
125947
126540
|
//#region src/pipeline-settings-store.ts
|
|
125948
126541
|
var PIPELINE_EXECUTOR_CAP = "pipeline-executor";
|
|
126542
|
+
/** The addon-store key of the cluster step switches (D1065). */
|
|
126543
|
+
var CLUSTER_STEP_MODES_KEY = "clusterStepModes";
|
|
126544
|
+
/** A skip an operator switch caused (D1065), as opposed to a missing build. */
|
|
126545
|
+
function isSwitchSkip(reason) {
|
|
126546
|
+
return reason === "disabled-on-cluster" || reason === "disabled-on-node" || reason === "disabled-on-device";
|
|
126547
|
+
}
|
|
125949
126548
|
var PipelineSettingsStore = class PipelineSettingsStore {
|
|
125950
126549
|
deps;
|
|
125951
126550
|
static CATALOG_CACHE_TTL_MS = 3e4;
|
|
@@ -126139,6 +126738,79 @@ var PipelineSettingsStore = class PipelineSettingsStore {
|
|
|
126139
126738
|
});
|
|
126140
126739
|
});
|
|
126141
126740
|
}
|
|
126741
|
+
clusterStepModesState() {
|
|
126742
|
+
return this.deps.state(CLUSTER_STEP_MODES_KEY, ClusterStepModesSchema, {});
|
|
126743
|
+
}
|
|
126744
|
+
/** The stored cluster step modes, `stepId → mode` (absent step = catalog default). */
|
|
126745
|
+
async readClusterStepModes() {
|
|
126746
|
+
return await this.clusterStepModesState().get();
|
|
126747
|
+
}
|
|
126748
|
+
/** Write one step's cluster mode; `null` removes it (back to the catalog default). */
|
|
126749
|
+
async writeClusterStepMode(stepId, mode) {
|
|
126750
|
+
await this.blobWriteLock.run(CLUSTER_STEP_MODES_KEY, async () => {
|
|
126751
|
+
await this.clusterStepModesState().update((prev) => {
|
|
126752
|
+
const { [stepId]: _drop, ...rest } = prev;
|
|
126753
|
+
return mode === null ? rest : {
|
|
126754
|
+
...rest,
|
|
126755
|
+
[stepId]: mode
|
|
126756
|
+
};
|
|
126757
|
+
});
|
|
126758
|
+
});
|
|
126759
|
+
}
|
|
126760
|
+
/**
|
|
126761
|
+
* Write one step's NODE switch under the agent-blob lock; `null` removes it
|
|
126762
|
+
* (inherit). An empty map is pruned. Creates the node's entry when absent.
|
|
126763
|
+
*/
|
|
126764
|
+
async writeNodeStepEnabled(nodeId, stepId, enabled) {
|
|
126765
|
+
await this.blobWriteLock.run(PipelineSettingsStore.AGENT_SETTINGS_LOCK_KEY, async () => {
|
|
126766
|
+
const { stepEnabled: prevMap, ...rest } = await this.agentRows.get(nodeId) ?? { maxCameras: null };
|
|
126767
|
+
const { [stepId]: _drop, ...others } = prevMap ?? {};
|
|
126768
|
+
const next = enabled === null ? others : {
|
|
126769
|
+
...others,
|
|
126770
|
+
[stepId]: enabled
|
|
126771
|
+
};
|
|
126772
|
+
await this.agentRows.set(nodeId, {
|
|
126773
|
+
...rest,
|
|
126774
|
+
...Object.keys(next).length > 0 ? { stepEnabled: next } : {}
|
|
126775
|
+
});
|
|
126776
|
+
});
|
|
126777
|
+
}
|
|
126778
|
+
/**
|
|
126779
|
+
* Write one step's DEVICE switch on `(nodeId, deviceKey)` under the
|
|
126780
|
+
* agent-blob lock; `null` removes it (inherit). A step entry left empty is
|
|
126781
|
+
* pruned. A device with no stored entry gets one with `deviceEnabled` — its
|
|
126782
|
+
* current participation, which the caller read from the merged device view,
|
|
126783
|
+
* so writing a step switch never flips whether the device dispatches.
|
|
126784
|
+
*/
|
|
126785
|
+
async writeDeviceStepEnabled(input) {
|
|
126786
|
+
const { nodeId, deviceKey, stepId, enabled } = input;
|
|
126787
|
+
await this.blobWriteLock.run(PipelineSettingsStore.AGENT_SETTINGS_LOCK_KEY, async () => {
|
|
126788
|
+
const existing = await this.agentRows.get(nodeId) ?? { maxCameras: null };
|
|
126789
|
+
const devices = existing.inferenceDevices ?? {};
|
|
126790
|
+
const device = devices[deviceKey] ?? { enabled: input.deviceEnabled };
|
|
126791
|
+
const { [stepId]: prevStep, ...otherSteps } = device.steps ?? {};
|
|
126792
|
+
const { enabled: _drop, ...stepRest } = prevStep ?? {};
|
|
126793
|
+
const nextStep = enabled === null ? stepRest : {
|
|
126794
|
+
...stepRest,
|
|
126795
|
+
enabled
|
|
126796
|
+
};
|
|
126797
|
+
const steps = Object.keys(nextStep).length > 0 ? {
|
|
126798
|
+
...otherSteps,
|
|
126799
|
+
[stepId]: nextStep
|
|
126800
|
+
} : otherSteps;
|
|
126801
|
+
const { steps: _oldSteps, ...deviceRest } = device;
|
|
126802
|
+
await this.agentRows.set(nodeId, {
|
|
126803
|
+
...existing,
|
|
126804
|
+
inferenceDevices: {
|
|
126805
|
+
...devices,
|
|
126806
|
+
[deviceKey]: {
|
|
126807
|
+
...deviceRest,
|
|
126808
|
+
...Object.keys(steps).length > 0 ? { steps } : {}
|
|
126809
|
+
}
|
|
126810
|
+
}
|
|
126811
|
+
});
|
|
126812
|
+
});
|
|
126813
|
+
}
|
|
126142
126814
|
/** Purge one device's row. */
|
|
126143
126815
|
async deleteCameraSettings(deviceId) {
|
|
126144
126816
|
await this.cameraRows.remove(deviceId);
|
|
@@ -126384,8 +127056,8 @@ var PipelineSettingsStore = class PipelineSettingsStore {
|
|
|
126384
127056
|
* cannot run (D650 round 3) — what an attach needs to refuse a camera whose
|
|
126385
127057
|
* own detector would not run. Waits for the catalog exactly as it does.
|
|
126386
127058
|
*/
|
|
126387
|
-
async resolvePipelineForDeviceWithRoots(deviceId, agentNodeId, deviceKey, jumpDeviceKeys) {
|
|
126388
|
-
const outcome = await this.resolvePipelineWithCatalog(deviceId, agentNodeId, deviceKey, jumpDeviceKeys, { kind: "await" });
|
|
127059
|
+
async resolvePipelineForDeviceWithRoots(deviceId, agentNodeId, deviceKey, jumpDeviceKeys, defaultPool) {
|
|
127060
|
+
const outcome = await this.resolvePipelineWithCatalog(deviceId, agentNodeId, deviceKey, jumpDeviceKeys, { kind: "await" }, defaultPool);
|
|
126389
127061
|
if (outcome.kind === "resolved") return outcome;
|
|
126390
127062
|
throw new Error(`PipelineSettingsStore.resolvePipelineForDeviceWithRoots: catalog unavailable for "${outcome.nodeId}"`);
|
|
126391
127063
|
}
|
|
@@ -126398,10 +127070,10 @@ var PipelineSettingsStore = class PipelineSettingsStore {
|
|
|
126398
127070
|
* node; D49: never gate on a fallible read). A cold cache also starts one
|
|
126399
127071
|
* background refresh, so the next retry round finds the catalog.
|
|
126400
127072
|
*/
|
|
126401
|
-
async resolvePipelineForDeviceIfCatalogCached(deviceId, agentNodeId, deviceKey, jumpDeviceKeys) {
|
|
126402
|
-
return this.resolvePipelineWithCatalog(deviceId, agentNodeId, deviceKey, jumpDeviceKeys, { kind: "cached" });
|
|
127073
|
+
async resolvePipelineForDeviceIfCatalogCached(deviceId, agentNodeId, deviceKey, jumpDeviceKeys, defaultPool) {
|
|
127074
|
+
return this.resolvePipelineWithCatalog(deviceId, agentNodeId, deviceKey, jumpDeviceKeys, { kind: "cached" }, defaultPool);
|
|
126403
127075
|
}
|
|
126404
|
-
async resolvePipelineWithCatalog(deviceId, agentNodeIdOverride, deviceKey, jumpDeviceKeys, catalogRead) {
|
|
127076
|
+
async resolvePipelineWithCatalog(deviceId, agentNodeIdOverride, deviceKey, jumpDeviceKeys, catalogRead, defaultPool) {
|
|
126405
127077
|
const agentNodeId = agentNodeIdOverride ?? this.deps.getAssignmentNode(deviceId);
|
|
126406
127078
|
if (!agentNodeId) throw new Error(`PipelineSettingsStore.resolvePipelineForDevice: no node resolvable for device ${deviceId}`);
|
|
126407
127079
|
if (!await this.isDetectionPipelineActive(deviceId)) {
|
|
@@ -126435,14 +127107,39 @@ var PipelineSettingsStore = class PipelineSettingsStore {
|
|
|
126435
127107
|
}
|
|
126436
127108
|
const deviceFormat = deviceKey ? parseDeviceKey(deviceKey).format : catalog.selectedEngine.format;
|
|
126437
127109
|
const jumpFormats = [...new Set(jumpDeviceKeys.map((k) => parseDeviceKey(k).format))];
|
|
126438
|
-
const
|
|
126439
|
-
|
|
127110
|
+
const [clusterModes, node] = await Promise.all([this.readClusterStepModes(), this.agentRows.get(agentNodeId)]);
|
|
127111
|
+
const switches = {
|
|
127112
|
+
clusterModes,
|
|
127113
|
+
...node?.stepEnabled !== void 0 ? { nodeStepEnabled: node.stepEnabled } : {},
|
|
127114
|
+
electedDisabledSteps: deviceKey !== void 0 ? deviceDisabledSteps(node, deviceKey) : defaultPool !== void 0 ? poolDisabledSteps(node, defaultPool.eligibleKeys) : deviceDisabledSteps(node, ""),
|
|
127115
|
+
jumpTargets: jumpDeviceKeys.map((key) => ({
|
|
127116
|
+
deviceKey: key,
|
|
127117
|
+
format: parseDeviceKey(key).format,
|
|
127118
|
+
disabledSteps: deviceDisabledSteps(node, key)
|
|
127119
|
+
}))
|
|
127120
|
+
};
|
|
127121
|
+
const { config: resolvedBase, skipped, droppedRoots, packageAllowed } = resolvePipelineWithSkips(cam, deviceFormat, catalog, jumpFormats, switches);
|
|
127122
|
+
const formatSkips = skipped.filter((s) => !isSwitchSkip(s.reason));
|
|
127123
|
+
const switchSkips = skipped.filter((s) => isSwitchSkip(s.reason));
|
|
127124
|
+
const packageOverruled = hasPackageZone && !packageAllowed;
|
|
127125
|
+
if (switchSkips.length > 0 || packageOverruled) this.deps.logger.info(`pipeline steps switched off — skipped (node ${agentNodeId}, device ${deviceId})`, {
|
|
126440
127126
|
tags: {
|
|
126441
127127
|
deviceId,
|
|
126442
127128
|
nodeId: agentNodeId
|
|
126443
127129
|
},
|
|
126444
127130
|
meta: {
|
|
126445
|
-
skipped:
|
|
127131
|
+
skipped: [...switchSkips.map((s) => `${s.addonId}:${s.reason}`), ...packageOverruled ? [`${PACKAGE_DETECTION_STEP_ID}:switched-off`] : []].join(","),
|
|
127132
|
+
electedDeviceKey: deviceKey ?? null,
|
|
127133
|
+
jumpDeviceKeys: jumpDeviceKeys.join(",")
|
|
127134
|
+
}
|
|
127135
|
+
});
|
|
127136
|
+
if (formatSkips.length > 0) this.deps.logger.warn(`pipeline steps gated on but not provisioned on this node — skipped (node ${agentNodeId}, device ${deviceId})`, {
|
|
127137
|
+
tags: {
|
|
127138
|
+
deviceId,
|
|
127139
|
+
nodeId: agentNodeId
|
|
127140
|
+
},
|
|
127141
|
+
meta: {
|
|
127142
|
+
skipped: formatSkips.map((s) => `${s.addonId}:${s.reason}`).join(","),
|
|
126446
127143
|
electedDeviceKey: deviceKey ?? null,
|
|
126447
127144
|
electedFormat: deviceFormat,
|
|
126448
127145
|
jumpDeviceKeys: jumpDeviceKeys.join(","),
|
|
@@ -126451,7 +127148,7 @@ var PipelineSettingsStore = class PipelineSettingsStore {
|
|
|
126451
127148
|
});
|
|
126452
127149
|
const resolved = {
|
|
126453
127150
|
...resolvedBase,
|
|
126454
|
-
steps: applyPackageZoneActivation(resolvedBase.steps, hasPackageZone)
|
|
127151
|
+
steps: applyPackageZoneActivation(resolvedBase.steps, hasPackageZone && packageAllowed)
|
|
126455
127152
|
};
|
|
126456
127153
|
if (resolved.steps.length === 0) this.deps.logger.info("resolvePipelineForDevice → empty (all steps gated off/unprovisioned)", {
|
|
126457
127154
|
tags: {
|
|
@@ -126633,7 +127330,8 @@ var PipelineSettingsStore = class PipelineSettingsStore {
|
|
|
126633
127330
|
const out = /* @__PURE__ */ new Map();
|
|
126634
127331
|
for (const deviceKey of deviceKeys) out.set(deviceKey, {
|
|
126635
127332
|
base: nodeDeviceBase(node, deviceKey),
|
|
126636
|
-
override: cameraLayer
|
|
127333
|
+
override: cameraLayer,
|
|
127334
|
+
disabledSteps: [...deviceDisabledSteps(node, deviceKey)].toSorted()
|
|
126637
127335
|
});
|
|
126638
127336
|
return out;
|
|
126639
127337
|
}
|
|
@@ -131148,6 +131846,141 @@ async function buildOrchestratorControllers(deps) {
|
|
|
131148
131846
|
};
|
|
131149
131847
|
}
|
|
131150
131848
|
//#endregion
|
|
131849
|
+
//#region src/step-switch-matrix.ts
|
|
131850
|
+
/** ONE cell — the gate, then the placement, in the attach path's order. */
|
|
131851
|
+
function stepSwitchCell(input) {
|
|
131852
|
+
const { addon, elected } = input;
|
|
131853
|
+
const layers = {
|
|
131854
|
+
...input.clusterMode !== void 0 ? { clusterMode: input.clusterMode } : {},
|
|
131855
|
+
...input.nodeEnabled !== void 0 ? { nodeEnabled: input.nodeEnabled } : {}
|
|
131856
|
+
};
|
|
131857
|
+
const mode = effectiveClusterStepMode(addon, input.clusterMode);
|
|
131858
|
+
if (mode === "off") return { kind: "off-cluster" };
|
|
131859
|
+
if (addon.id === "package-detection") {
|
|
131860
|
+
const gate = gateStep(addon, {
|
|
131861
|
+
...layers,
|
|
131862
|
+
cameraToggle: true
|
|
131863
|
+
});
|
|
131864
|
+
if (gate.kind === "off") return gate.reason === "disabled-on-node" ? { kind: "off-node" } : { kind: "off-cluster" };
|
|
131865
|
+
return elected.disabledSteps.has(addon.id) ? { kind: "off-device" } : { kind: "zone-driven" };
|
|
131866
|
+
}
|
|
131867
|
+
if (mode === "opt-in" && input.camerasEnabling === 0) return { kind: "opt-in-unused" };
|
|
131868
|
+
const gate = gateStep(addon, {
|
|
131869
|
+
...layers,
|
|
131870
|
+
cameraToggle: true
|
|
131871
|
+
});
|
|
131872
|
+
if (gate.kind === "off") return gate.reason === "disabled-on-node" ? { kind: "off-node" } : { kind: "off-cluster" };
|
|
131873
|
+
const placement = placeStepOnDevices(addon, elected, input.roster);
|
|
131874
|
+
if (placement.kind === "run") return input.suppliedByRootModelId !== void 0 ? {
|
|
131875
|
+
kind: "supplied-by-root",
|
|
131876
|
+
rootModelId: input.suppliedByRootModelId
|
|
131877
|
+
} : { kind: "on" };
|
|
131878
|
+
if (placement.kind === "jump") return placement.toDeviceKey !== void 0 ? {
|
|
131879
|
+
kind: "jump",
|
|
131880
|
+
toDeviceKey: placement.toDeviceKey
|
|
131881
|
+
} : { kind: "on" };
|
|
131882
|
+
if (placement.reason === "disabled-on-device") return { kind: "off-device" };
|
|
131883
|
+
return {
|
|
131884
|
+
kind: "skip",
|
|
131885
|
+
reason: placement.reason
|
|
131886
|
+
};
|
|
131887
|
+
}
|
|
131888
|
+
/** The catalog's steps across every answering node, first-seen order, by id. */
|
|
131889
|
+
function catalogSteps(nodes) {
|
|
131890
|
+
const seen = /* @__PURE__ */ new Map();
|
|
131891
|
+
for (const node of nodes) for (const slot of node.catalog?.slots ?? []) for (const addon of slot.addons) if (!seen.has(addon.id)) seen.set(addon.id, addon);
|
|
131892
|
+
return [...seen.values()];
|
|
131893
|
+
}
|
|
131894
|
+
function findAddon(catalog, id) {
|
|
131895
|
+
for (const slot of catalog.slots) {
|
|
131896
|
+
const found = slot.addons.find((a) => a.id === id);
|
|
131897
|
+
if (found) return found;
|
|
131898
|
+
}
|
|
131899
|
+
}
|
|
131900
|
+
/**
|
|
131901
|
+
* The root model a device runs: its pin, else the model the executor elects
|
|
131902
|
+
* for the device when the root lists it, else the format default.
|
|
131903
|
+
*/
|
|
131904
|
+
function rootModelOn(root, device) {
|
|
131905
|
+
const pin = device.steps?.[OBJECT_DETECTION_STEP_ID]?.modelId;
|
|
131906
|
+
if (pin !== void 0) return pin;
|
|
131907
|
+
if (root.models.some((m) => m.id === device.defaultModelId)) return device.defaultModelId;
|
|
131908
|
+
return root.defaultModelIdByFormat?.[device.format] ?? root.defaultModelId;
|
|
131909
|
+
}
|
|
131910
|
+
/** The root model id when it supplies `stepId` on `device`, else undefined. */
|
|
131911
|
+
function suppliedByRoot(catalog, stepId, device, settings) {
|
|
131912
|
+
if (!isRootSuppliableStepId(stepId)) return void 0;
|
|
131913
|
+
const root = findAddon(catalog, OBJECT_DETECTION_STEP_ID);
|
|
131914
|
+
if (root === void 0) return void 0;
|
|
131915
|
+
const rootModelId = rootModelOn(root, device);
|
|
131916
|
+
const supplies = root.models.find((m) => m.id === rootModelId)?.suppliesSteps;
|
|
131917
|
+
const stepSettings = nodeDeviceBase(settings, device.key)[stepId]?.settings;
|
|
131918
|
+
return resolveRootSupply(stepId, stepSettings, supplies).effective ? rootModelId : void 0;
|
|
131919
|
+
}
|
|
131920
|
+
function slotOf(device, settings) {
|
|
131921
|
+
return {
|
|
131922
|
+
deviceKey: device.key,
|
|
131923
|
+
format: device.format,
|
|
131924
|
+
disabledSteps: deviceDisabledSteps(settings, device.key)
|
|
131925
|
+
};
|
|
131926
|
+
}
|
|
131927
|
+
function countToggles(toggles, stepId, value) {
|
|
131928
|
+
return toggles.filter((t) => t[stepId] === value).length;
|
|
131929
|
+
}
|
|
131930
|
+
function buildStepSwitchMatrix(input) {
|
|
131931
|
+
return { steps: catalogSteps(input.nodes).map((addon) => {
|
|
131932
|
+
const clusterMode = input.clusterModes[addon.id];
|
|
131933
|
+
const camerasEnabling = countToggles(input.cameraToggles, addon.id, true);
|
|
131934
|
+
const nodes = input.nodes.map((node) => {
|
|
131935
|
+
const nodeEnabled = node.settings?.stepEnabled?.[addon.id];
|
|
131936
|
+
const catalog = node.catalog;
|
|
131937
|
+
const devices = node.devices;
|
|
131938
|
+
const nodeAddon = catalog ? findAddon(catalog, addon.id) : void 0;
|
|
131939
|
+
if (catalog === null || devices === null || nodeAddon === void 0) return {
|
|
131940
|
+
nodeId: node.nodeId,
|
|
131941
|
+
reachable: false,
|
|
131942
|
+
stepEnabled: nodeEnabled ?? null,
|
|
131943
|
+
devices: []
|
|
131944
|
+
};
|
|
131945
|
+
const eligible = devices.filter((d) => d.exclusion === null);
|
|
131946
|
+
return {
|
|
131947
|
+
nodeId: node.nodeId,
|
|
131948
|
+
reachable: true,
|
|
131949
|
+
stepEnabled: nodeEnabled ?? null,
|
|
131950
|
+
devices: devices.map((device) => {
|
|
131951
|
+
const roster = eligible.length >= 2 ? eligible.filter((d) => d.key !== device.key).map((d) => slotOf(d, node.settings)) : [];
|
|
131952
|
+
const supplied = suppliedByRoot(catalog, addon.id, device, node.settings);
|
|
131953
|
+
return {
|
|
131954
|
+
deviceKey: device.key,
|
|
131955
|
+
format: device.format,
|
|
131956
|
+
stepEnabled: device.steps?.[addon.id]?.enabled ?? null,
|
|
131957
|
+
eligible: device.exclusion === null,
|
|
131958
|
+
cell: stepSwitchCell({
|
|
131959
|
+
addon: nodeAddon,
|
|
131960
|
+
clusterMode,
|
|
131961
|
+
camerasEnabling,
|
|
131962
|
+
nodeEnabled,
|
|
131963
|
+
elected: slotOf(device, node.settings),
|
|
131964
|
+
roster,
|
|
131965
|
+
...supplied !== void 0 ? { suppliedByRootModelId: supplied } : {}
|
|
131966
|
+
})
|
|
131967
|
+
};
|
|
131968
|
+
})
|
|
131969
|
+
};
|
|
131970
|
+
});
|
|
131971
|
+
return {
|
|
131972
|
+
stepId: addon.id,
|
|
131973
|
+
name: addon.name,
|
|
131974
|
+
slot: addon.slot,
|
|
131975
|
+
clusterMode: clusterMode ?? null,
|
|
131976
|
+
effectiveMode: effectiveClusterStepMode(addon, clusterMode),
|
|
131977
|
+
camerasEnabling,
|
|
131978
|
+
camerasDisabling: countToggles(input.cameraToggles, addon.id, false),
|
|
131979
|
+
nodes
|
|
131980
|
+
};
|
|
131981
|
+
}) };
|
|
131982
|
+
}
|
|
131983
|
+
//#endregion
|
|
131151
131984
|
//#region src/rebalance-suggestion.ts
|
|
131152
131985
|
var REBALANCE_SUGGESTED_ALERT_ID = "pipeline-orchestrator:rebalance-suggested";
|
|
131153
131986
|
var NODE_NOT_USED_ALERT_PREFIX = "pipeline-orchestrator:node-not-used:";
|
|
@@ -134251,14 +135084,15 @@ var PipelineOrchestratorAddon = class PipelineOrchestratorAddon extends BaseAddo
|
|
|
134251
135084
|
*/
|
|
134252
135085
|
async getNodeInferenceDevices(input) {
|
|
134253
135086
|
const nodeId = input.nodeId;
|
|
134254
|
-
const
|
|
135087
|
+
const node = (await this.settingsStore.readAgentSettingsMap())[nodeId];
|
|
135088
|
+
const stored = node?.inferenceDevices ?? {};
|
|
134255
135089
|
const { probed, reachable } = await this.probeNodeInferenceDevices(nodeId);
|
|
134256
135090
|
const catalog = await this.settingsStore.getCatalogForNode(nodeId);
|
|
134257
135091
|
const canRunRoot = catalog ? makeRootCapabilityGuard(catalog) : void 0;
|
|
134258
135092
|
return {
|
|
134259
135093
|
nodeId,
|
|
134260
135094
|
reachable,
|
|
134261
|
-
devices: annotateInferenceDeviceExclusions(mergeInferenceDevices(probed, stored), resolveInferenceDeviceEligibility(probed, stored, canRunRoot, (deviceKey) => this.inferenceDeviceUsability.isUsable(nodeId, deviceKey))).map((row) => !reachable && row.presence === "absent" ? {
|
|
135095
|
+
devices: annotateInferenceDeviceExclusions(mergeInferenceDevices(probed, stored), resolveInferenceDeviceEligibility(probed, stored, canRunRoot, (deviceKey) => this.inferenceDeviceUsability.isUsable(nodeId, deviceKey), catalog ? makeRootSwitchGuard(catalog, await this.settingsStore.readClusterStepModes(), node) : void 0)).map((row) => !reachable && row.presence === "absent" ? {
|
|
134262
135096
|
...row,
|
|
134263
135097
|
presence: "unknown"
|
|
134264
135098
|
} : row)
|
|
@@ -134440,7 +135274,8 @@ var PipelineOrchestratorAddon = class PipelineOrchestratorAddon extends BaseAddo
|
|
|
134440
135274
|
}
|
|
134441
135275
|
/** Eligibility from a device list + catalog; records usability like every dispatch read. */
|
|
134442
135276
|
async electableDevices(nodeId, probed, catalog) {
|
|
134443
|
-
const
|
|
135277
|
+
const node = (await this.settingsStore.readAgentSettingsMap())[nodeId];
|
|
135278
|
+
const eligibility = resolveInferenceDeviceEligibility(probed, node?.inferenceDevices ?? {}, catalog ? makeRootCapabilityGuard(catalog) : void 0, (deviceKey) => this.inferenceDeviceUsability.isUsable(nodeId, deviceKey), catalog ? makeRootSwitchGuard(catalog, await this.settingsStore.readClusterStepModes(), node) : void 0);
|
|
134444
135279
|
const { eligible, excluded } = eligibility;
|
|
134445
135280
|
this.logInferenceDeviceShrinkage(nodeId, eligible, excluded);
|
|
134446
135281
|
this.noteNodeInferenceUsability(nodeId, resolveNodeInferenceUsability(eligibility));
|
|
@@ -134881,7 +135716,7 @@ var PipelineOrchestratorAddon = class PipelineOrchestratorAddon extends BaseAddo
|
|
|
134881
135716
|
topologySignature: async () => {
|
|
134882
135717
|
const nodeIds = [...new Set(["hub", ...this.topology.collectRunnerNodeIds()])];
|
|
134883
135718
|
const blob = await store.readAgentSettingsMap();
|
|
134884
|
-
return shareTopologySignature(nodeIds, blob, this.liveDevicesByNode(nodeIds, blob));
|
|
135719
|
+
return shareTopologySignature(nodeIds, blob, this.liveDevicesByNode(nodeIds, blob, await store.readClusterStepModes()));
|
|
134885
135720
|
},
|
|
134886
135721
|
logger: this.ctx.logger
|
|
134887
135722
|
});
|
|
@@ -134894,14 +135729,14 @@ var PipelineOrchestratorAddon = class PipelineOrchestratorAddon extends BaseAddo
|
|
|
134894
135729
|
* call: a node never probed contributes nothing, and the probe that first
|
|
134895
135730
|
* answers announces itself through {@link noteInferenceDeviceProbe}.
|
|
134896
135731
|
*/
|
|
134897
|
-
liveDevicesByNode(nodeIds, blob) {
|
|
135732
|
+
liveDevicesByNode(nodeIds, blob, clusterModes) {
|
|
134898
135733
|
const out = {};
|
|
134899
135734
|
for (const nodeId of nodeIds) {
|
|
134900
135735
|
const probed = this.lastInferenceDeviceProbe.get(nodeId);
|
|
134901
135736
|
if (probed === void 0) continue;
|
|
134902
135737
|
const stored = blob[nodeId]?.inferenceDevices ?? {};
|
|
134903
135738
|
const catalog = this.settingsStore.peekCatalogForAgent(nodeId);
|
|
134904
|
-
const eligibility = resolveInferenceDeviceEligibility(probed, stored, catalog ? makeRootCapabilityGuard(catalog) : void 0, (deviceKey) => this.inferenceDeviceUsability.isUsable(nodeId, deviceKey));
|
|
135739
|
+
const eligibility = resolveInferenceDeviceEligibility(probed, stored, catalog ? makeRootCapabilityGuard(catalog) : void 0, (deviceKey) => this.inferenceDeviceUsability.isUsable(nodeId, deviceKey), catalog ? makeRootSwitchGuard(catalog, clusterModes, blob[nodeId]) : void 0);
|
|
134905
135740
|
out[nodeId] = annotateInferenceDeviceExclusions(mergeInferenceDevices(probed, stored), eligibility).map((d) => ({
|
|
134906
135741
|
key: d.key,
|
|
134907
135742
|
available: d.available,
|
|
@@ -135018,7 +135853,7 @@ var PipelineOrchestratorAddon = class PipelineOrchestratorAddon extends BaseAddo
|
|
|
135018
135853
|
readNodes: async () => {
|
|
135019
135854
|
const online = this.topology.collectRunnerNodeIds();
|
|
135020
135855
|
const blob = await this.settingsStore.readAgentSettingsMap();
|
|
135021
|
-
const live = this.liveDevicesByNode(online, blob);
|
|
135856
|
+
const live = this.liveDevicesByNode(online, blob, await this.settingsStore.readClusterStepModes());
|
|
135022
135857
|
return readAutoBenchNodes({
|
|
135023
135858
|
onlineNodeIds: online,
|
|
135024
135859
|
liveDevices: (nodeId) => live[nodeId],
|
|
@@ -135286,7 +136121,95 @@ var PipelineOrchestratorAddon = class PipelineOrchestratorAddon extends BaseAddo
|
|
|
135286
136121
|
return { success: true };
|
|
135287
136122
|
}
|
|
135288
136123
|
async resolvePipeline(input) {
|
|
135289
|
-
|
|
136124
|
+
const nodeId = input.agentNodeId ?? this.placement.getPipelineAssignment({ deviceId: input.deviceId })?.agentNodeId ?? this.localNodeId;
|
|
136125
|
+
const outcome = await this.placement.previewAttachPipeline({
|
|
136126
|
+
deviceId: input.deviceId,
|
|
136127
|
+
nodeId
|
|
136128
|
+
});
|
|
136129
|
+
if (outcome.kind === "root-refused") return {
|
|
136130
|
+
steps: [],
|
|
136131
|
+
audio: null
|
|
136132
|
+
};
|
|
136133
|
+
return {
|
|
136134
|
+
steps: outcome.pipeline.steps,
|
|
136135
|
+
audio: outcome.pipeline.audio ?? null
|
|
136136
|
+
};
|
|
136137
|
+
}
|
|
136138
|
+
/** Set one step's cluster mode; `null` returns it to the catalog default. */
|
|
136139
|
+
async setClusterStepMode(input) {
|
|
136140
|
+
await this.settingsStore.writeClusterStepMode(input.stepId, input.mode);
|
|
136141
|
+
this.ctx.logger.info("cluster step mode written", { meta: {
|
|
136142
|
+
stepId: input.stepId,
|
|
136143
|
+
mode: input.mode ?? "default"
|
|
136144
|
+
} });
|
|
136145
|
+
await this.placement.reattachForStepSwitch(null, `cluster:${input.stepId}`);
|
|
136146
|
+
return { success: true };
|
|
136147
|
+
}
|
|
136148
|
+
/** Set one step's node switch; `null` = inherit. */
|
|
136149
|
+
async setNodeStepEnabled(input) {
|
|
136150
|
+
await this.settingsStore.writeNodeStepEnabled(input.agentNodeId, input.stepId, input.enabled);
|
|
136151
|
+
this.ctx.logger.info("node step switch written", {
|
|
136152
|
+
tags: { nodeId: input.agentNodeId },
|
|
136153
|
+
meta: {
|
|
136154
|
+
stepId: input.stepId,
|
|
136155
|
+
enabled: input.enabled ?? "inherit"
|
|
136156
|
+
}
|
|
136157
|
+
});
|
|
136158
|
+
await this.placement.reattachForStepSwitch(input.agentNodeId, `node:${input.stepId}`);
|
|
136159
|
+
return { success: true };
|
|
136160
|
+
}
|
|
136161
|
+
/**
|
|
136162
|
+
* Set one step's device switch; `null` = inherit. Refuses a device the node
|
|
136163
|
+
* does not list (neither probed nor stored) — a switch on a key nothing
|
|
136164
|
+
* dispatches to would be silently inert.
|
|
136165
|
+
*/
|
|
136166
|
+
async setDeviceStepEnabled(input) {
|
|
136167
|
+
const device = (await this.getNodeInferenceDevices({ nodeId: input.agentNodeId })).devices.find((d) => d.key === input.deviceKey);
|
|
136168
|
+
if (device === void 0) throw new Error(`setDeviceStepEnabled: node "${input.agentNodeId}" has no inference device "${input.deviceKey}"`);
|
|
136169
|
+
await this.settingsStore.writeDeviceStepEnabled({
|
|
136170
|
+
nodeId: input.agentNodeId,
|
|
136171
|
+
deviceKey: input.deviceKey,
|
|
136172
|
+
stepId: input.stepId,
|
|
136173
|
+
enabled: input.enabled,
|
|
136174
|
+
deviceEnabled: device.enabled
|
|
136175
|
+
});
|
|
136176
|
+
this.ctx.logger.info("device step switch written", {
|
|
136177
|
+
tags: { nodeId: input.agentNodeId },
|
|
136178
|
+
meta: {
|
|
136179
|
+
deviceKey: input.deviceKey,
|
|
136180
|
+
stepId: input.stepId,
|
|
136181
|
+
enabled: input.enabled ?? "inherit"
|
|
136182
|
+
}
|
|
136183
|
+
});
|
|
136184
|
+
await this.placement.reattachForStepSwitch(input.agentNodeId, `device:${input.stepId}`);
|
|
136185
|
+
return { success: true };
|
|
136186
|
+
}
|
|
136187
|
+
/**
|
|
136188
|
+
* The step switch matrix — cells computed by the attach path's own gate and
|
|
136189
|
+
* placement (`step-switch-matrix.ts`). A node whose catalog or device probe
|
|
136190
|
+
* does not answer is listed `reachable: false` with no cells.
|
|
136191
|
+
*/
|
|
136192
|
+
async getStepSwitches() {
|
|
136193
|
+
const store = this.settingsStore;
|
|
136194
|
+
const [clusterModes, agentMap, cameraMap] = await Promise.all([
|
|
136195
|
+
store.readClusterStepModes(),
|
|
136196
|
+
store.readAgentSettingsMap(),
|
|
136197
|
+
store.readCameraSettingsMap()
|
|
136198
|
+
]);
|
|
136199
|
+
const nodes = await Promise.all(Object.keys(agentMap).toSorted().map(async (nodeId) => {
|
|
136200
|
+
const [catalog, view] = await Promise.all([store.getCatalogForNode(nodeId).catch(() => null), this.getNodeInferenceDevices({ nodeId }).catch(() => null)]);
|
|
136201
|
+
return {
|
|
136202
|
+
nodeId,
|
|
136203
|
+
catalog,
|
|
136204
|
+
devices: view?.reachable === true ? view.devices : null,
|
|
136205
|
+
settings: agentMap[nodeId]
|
|
136206
|
+
};
|
|
136207
|
+
}));
|
|
136208
|
+
return buildStepSwitchMatrix({
|
|
136209
|
+
clusterModes,
|
|
136210
|
+
cameraToggles: Object.values(cameraMap).map((c) => c.stepToggles ?? {}),
|
|
136211
|
+
nodes
|
|
136212
|
+
});
|
|
135290
136213
|
}
|
|
135291
136214
|
/** Emit `pipeline.camera-updated` carrying the freshly-resolved config. */
|
|
135292
136215
|
async emitResolvedCameraUpdated(deviceId) {
|