@camstack/addon-pipeline-orchestrator 1.2.704 → 1.2.706
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 +20 -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-Dok-wGGT.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-BD9_uA2k.mjs} +2 -2
- package/dist/index.js +1089 -109
- package/dist/index.mjs +1089 -109
- 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.js
CHANGED
|
@@ -25,6 +25,7 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
25
25
|
}) : target, mod));
|
|
26
26
|
//#endregion
|
|
27
27
|
let node_crypto = require("node:crypto");
|
|
28
|
+
let node_util = require("node:util");
|
|
28
29
|
let node_fs = require("node:fs");
|
|
29
30
|
node_fs = __toESM(node_fs);
|
|
30
31
|
let node_path = require("node:path");
|
|
@@ -6153,7 +6154,7 @@ var ZodIssueCode = {
|
|
|
6153
6154
|
var ZodFirstPartyTypeKind;
|
|
6154
6155
|
ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {});
|
|
6155
6156
|
//#endregion
|
|
6156
|
-
//#region ../types/dist/runtime-capabilities-
|
|
6157
|
+
//#region ../types/dist/runtime-capabilities-qX7BpOYT.mjs
|
|
6157
6158
|
/**
|
|
6158
6159
|
* The audio chunk plane's byte format, and the ONE expansion from a coded
|
|
6159
6160
|
* window to float samples (D455).
|
|
@@ -49329,11 +49330,104 @@ var CROP_SUPPLY_STEP_IDS = ["plate-detection", "face-detection"];
|
|
|
49329
49330
|
* no camera tree carries.)
|
|
49330
49331
|
*/
|
|
49331
49332
|
var MASK_SUPPLY_STEP_IDS = ["segmentation"];
|
|
49332
|
-
|
|
49333
|
+
/** Every step a root model can supply. */
|
|
49334
|
+
var ROOT_SUPPLIABLE_STEP_IDS = [
|
|
49333
49335
|
...LABEL_SUPPLY_STEP_IDS,
|
|
49334
49336
|
...CROP_SUPPLY_STEP_IDS,
|
|
49335
49337
|
...MASK_SUPPLY_STEP_IDS
|
|
49336
49338
|
];
|
|
49339
|
+
/** Narrow a step id to a suppliable one — type guard, not a cast. */
|
|
49340
|
+
function isRootSuppliableStepId(value) {
|
|
49341
|
+
return ROOT_SUPPLIABLE_STEP_IDS.some((id) => id === value);
|
|
49342
|
+
}
|
|
49343
|
+
var CROP_SUPPLY_SOURCES = {
|
|
49344
|
+
"plate-detection": {
|
|
49345
|
+
rootLabels: ["license_plate"],
|
|
49346
|
+
parentMacro: "vehicle",
|
|
49347
|
+
childClass: "plate",
|
|
49348
|
+
servedChildSteps: ["plate-ocr"],
|
|
49349
|
+
use: "as-output"
|
|
49350
|
+
},
|
|
49351
|
+
"face-detection": {
|
|
49352
|
+
rootLabels: ["face"],
|
|
49353
|
+
parentMacro: "person",
|
|
49354
|
+
childClass: "face",
|
|
49355
|
+
servedChildSteps: ["face-embedding"],
|
|
49356
|
+
use: "refine",
|
|
49357
|
+
minRootInputPx: 640
|
|
49358
|
+
}
|
|
49359
|
+
};
|
|
49360
|
+
/**
|
|
49361
|
+
* Whether an operator intends a step to take the root's output when the
|
|
49362
|
+
* root declares it — the default of the `useRootModel` flag. The label kinds
|
|
49363
|
+
* default ON: the detector's answer is the cheaper one and the classifier
|
|
49364
|
+
* keeps its model for the day the root changes. The animal and vehicle
|
|
49365
|
+
* classifiers are also ENABLED by default (their catalog `enabledByDefault`,
|
|
49366
|
+
* D736), so out of the box a root that declares them names animals and
|
|
49367
|
+
* vehicles and a root that does not runs the classifier; `package-detection`
|
|
49368
|
+
* stays zone-driven and takes this default whenever a zone switches it on.
|
|
49369
|
+
* The crop kinds default OFF: a
|
|
49370
|
+
* root plate box has an uncalibrated OCR margin, and root-face refinement has
|
|
49371
|
+
* not run on live traffic yet.
|
|
49372
|
+
*/
|
|
49373
|
+
var USE_ROOT_MODEL_DEFAULTS = {
|
|
49374
|
+
"animal-classifier": true,
|
|
49375
|
+
"vehicle-classifier": true,
|
|
49376
|
+
"package-detection": true,
|
|
49377
|
+
"plate-detection": false,
|
|
49378
|
+
"face-detection": false,
|
|
49379
|
+
segmentation: true
|
|
49380
|
+
};
|
|
49381
|
+
/** The step-settings key the flag is stored under (DeviceStepConfig.settings, camera overrides). */
|
|
49382
|
+
var USE_ROOT_MODEL_SETTING_KEY = "useRootModel";
|
|
49383
|
+
/**
|
|
49384
|
+
* The retired D715 policy key. A `skip-when-filled` / `run` value still
|
|
49385
|
+
* stored under it reads as the flag (`true` / `false`) when no flag is stored
|
|
49386
|
+
* — the normal read path, not a migration.
|
|
49387
|
+
*/
|
|
49388
|
+
var RETIRED_LABEL_LINK_KEY = "labelLink";
|
|
49389
|
+
/** The supply a root declares for one step, if any. */
|
|
49390
|
+
function supplyFor(supplies, stepId) {
|
|
49391
|
+
return supplies?.find((s) => s.stepId === stepId);
|
|
49392
|
+
}
|
|
49393
|
+
/**
|
|
49394
|
+
* Read the `useRootModel` flag off a step's settings bag. Absent ⇒ the
|
|
49395
|
+
* retired `labelLink` value if one is stored, else the step's default.
|
|
49396
|
+
*/
|
|
49397
|
+
function readUseRootModel(stepId, settings) {
|
|
49398
|
+
const raw = settings?.[USE_ROOT_MODEL_SETTING_KEY];
|
|
49399
|
+
if (typeof raw === "boolean") return raw;
|
|
49400
|
+
const retired = settings?.[RETIRED_LABEL_LINK_KEY];
|
|
49401
|
+
if (retired === "skip-when-filled") return true;
|
|
49402
|
+
if (retired === "run") return false;
|
|
49403
|
+
return USE_ROOT_MODEL_DEFAULTS[stepId];
|
|
49404
|
+
}
|
|
49405
|
+
/** Why a DECLARED supply is still not usable, or `undefined` when it is. */
|
|
49406
|
+
function supplyBlocker(supply) {
|
|
49407
|
+
if (supply.kind !== "crop") return void 0;
|
|
49408
|
+
const min = CROP_SUPPLY_SOURCES[supply.stepId].minRootInputPx;
|
|
49409
|
+
if (min === void 0) return void 0;
|
|
49410
|
+
return supply.rootInputPx !== void 0 && supply.rootInputPx >= min ? void 0 : "root-input-too-small";
|
|
49411
|
+
}
|
|
49412
|
+
/**
|
|
49413
|
+
* THE decision. Effective = the operator intends it AND the current root
|
|
49414
|
+
* declares it. It never looks at, changes or clears the step's `modelId`: a
|
|
49415
|
+
* root that cannot supply the step leaves the step running its own model, and
|
|
49416
|
+
* switching back to a root that can re-activates the supply by itself.
|
|
49417
|
+
*/
|
|
49418
|
+
function resolveRootSupply(stepId, settings, rootSupplies) {
|
|
49419
|
+
const supply = supplyFor(rootSupplies, stepId);
|
|
49420
|
+
const intent = readUseRootModel(stepId, settings);
|
|
49421
|
+
const blocker = supply === void 0 ? "root-does-not-declare" : supplyBlocker(supply);
|
|
49422
|
+
return {
|
|
49423
|
+
stepId,
|
|
49424
|
+
supply,
|
|
49425
|
+
intent,
|
|
49426
|
+
effective: intent && blocker === void 0,
|
|
49427
|
+
inactive: intent && blocker !== void 0,
|
|
49428
|
+
...intent && blocker !== void 0 ? { inactiveReason: blocker } : {}
|
|
49429
|
+
};
|
|
49430
|
+
}
|
|
49337
49431
|
/**
|
|
49338
49432
|
* Multi-file format payload.
|
|
49339
49433
|
*
|
|
@@ -67274,6 +67368,16 @@ var IntegrationInstanceStatusSchema = object({
|
|
|
67274
67368
|
/** A short human word for the state ("Signed in", "Token expired"); shown instead of `state`. */
|
|
67275
67369
|
label: string().optional()
|
|
67276
67370
|
});
|
|
67371
|
+
/**
|
|
67372
|
+
* What "Add device" inside ONE instance offers, decided per instance by its provider. `scan`: the
|
|
67373
|
+
* LAN scan finds devices this instance holds; `children`: only the instance's own children, via
|
|
67374
|
+
* adoption (a scan would offer other hosts, which are new integrations); `none`: manual add only.
|
|
67375
|
+
*/
|
|
67376
|
+
var IntegrationInstanceAddDeviceSchema = _enum([
|
|
67377
|
+
"scan",
|
|
67378
|
+
"children",
|
|
67379
|
+
"none"
|
|
67380
|
+
]);
|
|
67277
67381
|
var IntegrationInstanceSchema = object({
|
|
67278
67382
|
id: IntegrationInstanceIdSchema,
|
|
67279
67383
|
name: string(),
|
|
@@ -67291,7 +67395,9 @@ var IntegrationInstanceSchema = object({
|
|
|
67291
67395
|
formValues: record(string(), unknown()),
|
|
67292
67396
|
status: IntegrationInstanceStatusSchema.optional(),
|
|
67293
67397
|
/** Epoch ms of the last probe of the remote that produced `status`; absent when never checked. */
|
|
67294
|
-
lastCheckedAt: number$1().optional()
|
|
67398
|
+
lastCheckedAt: number$1().optional(),
|
|
67399
|
+
/** 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). */
|
|
67400
|
+
addDevice: IntegrationInstanceAddDeviceSchema.optional()
|
|
67295
67401
|
});
|
|
67296
67402
|
var IntegrationInstancePatchSchema = object({
|
|
67297
67403
|
id: IntegrationInstanceIdSchema,
|
|
@@ -73785,7 +73891,13 @@ var pipelineExecutorCapability = {
|
|
|
73785
73891
|
/** Pool deaths inside the current window. */
|
|
73786
73892
|
deaths: number$1(),
|
|
73787
73893
|
/** The last death's message. */
|
|
73788
|
-
lastError: string()
|
|
73894
|
+
lastError: string(),
|
|
73895
|
+
/**
|
|
73896
|
+
* Present when the device is ABSENT rather than dead: the runtime
|
|
73897
|
+
* itself enumerates no such device (`no-gpu-device` — OpenVINO sees
|
|
73898
|
+
* no supported GPU; driver/runtime does not support this iGPU).
|
|
73899
|
+
*/
|
|
73900
|
+
absentReason: _enum(["no-gpu-device"]).optional()
|
|
73789
73901
|
})).readonly() })),
|
|
73790
73902
|
/**
|
|
73791
73903
|
* Re-arm a terminally `failed` inference device on `nodeId`: forget its
|
|
@@ -75102,7 +75214,15 @@ var RunnerInferenceDeviceSchema = object({
|
|
|
75102
75214
|
* Absent field ⇒ an orchestrator that predates D650: the jumped step keeps
|
|
75103
75215
|
* the elected device's provisioning, as before.
|
|
75104
75216
|
*/
|
|
75105
|
-
steps: record(string(), RunnerJumpStepProvisioningSchema).optional()
|
|
75217
|
+
steps: record(string(), RunnerJumpStepProvisioningSchema).optional(),
|
|
75218
|
+
/**
|
|
75219
|
+
* Steps switched OFF on this device (D1065, `inferenceDevices[key].steps[s]
|
|
75220
|
+
* .enabled === false`). The runner never runs a subtree containing one of
|
|
75221
|
+
* them here: it auto-jumps it to an allowed device, and when none can take
|
|
75222
|
+
* it the subtree is skipped (`disabled-on-device`), never run here anyway.
|
|
75223
|
+
* Absent ⇒ none (an orchestrator that predates D1065).
|
|
75224
|
+
*/
|
|
75225
|
+
disabledSteps: array(string()).readonly().optional()
|
|
75106
75226
|
});
|
|
75107
75227
|
/**
|
|
75108
75228
|
* Camera assignment payload sent by `addon-pipeline-orchestrator` to a
|
|
@@ -81268,7 +81388,15 @@ var DeviceStepConfigSchema = object({
|
|
|
81268
81388
|
* at a disabled/absent device on that node at save time. Absent ⇒ the runner
|
|
81269
81389
|
* auto-jumps only when the effective device's format cannot run the step.
|
|
81270
81390
|
*/
|
|
81271
|
-
jumpDeviceKey: string().optional()
|
|
81391
|
+
jumpDeviceKey: string().optional(),
|
|
81392
|
+
/**
|
|
81393
|
+
* DEVICE switch for this step (D1065). `false` = the step is never
|
|
81394
|
+
* provisioned on this accelerator: a detail step jumps to another enabled
|
|
81395
|
+
* device of the node where it is allowed, else it is skipped with reason
|
|
81396
|
+
* `disabled-on-device`; a root is skipped. Absent = inherit (on). Written by
|
|
81397
|
+
* `setDeviceStepEnabled`.
|
|
81398
|
+
*/
|
|
81399
|
+
enabled: boolean().optional()
|
|
81272
81400
|
});
|
|
81273
81401
|
var AgentPipelineSettingsSchema = object({
|
|
81274
81402
|
maxCameras: number$1().int().nonnegative().nullable().default(null),
|
|
@@ -81312,6 +81440,12 @@ var AgentPipelineSettingsSchema = object({
|
|
|
81312
81440
|
*/
|
|
81313
81441
|
stepSettings: record(string(), record(string(), unknown()).readonly()).optional(),
|
|
81314
81442
|
/**
|
|
81443
|
+
* NODE switch per step (D1065): `stepId → enabled`. `false` = the step never
|
|
81444
|
+
* runs on a camera whose pipeline runs on this node (skip reason
|
|
81445
|
+
* `disabled-on-node`). Absent = inherit. Written by `setNodeStepEnabled`.
|
|
81446
|
+
*/
|
|
81447
|
+
stepEnabled: record(string(), boolean()).optional(),
|
|
81448
|
+
/**
|
|
81315
81449
|
* Multi-device inference opt-in (Phase 4). Per-node map deviceKey → {enabled,
|
|
81316
81450
|
* weight, steps}. Absent / all-disabled ⇒ the node's single default
|
|
81317
81451
|
* accelerator (safe default); two+ enabled ⇒ the dispatcher balances
|
|
@@ -81633,7 +81767,9 @@ var InferenceDeviceExclusionReasonSchema = _enum([
|
|
|
81633
81767
|
"disabled",
|
|
81634
81768
|
"unavailable",
|
|
81635
81769
|
"cannot-host-camera-root",
|
|
81636
|
-
"accelerator-preferred"
|
|
81770
|
+
"accelerator-preferred",
|
|
81771
|
+
"root-switched-off",
|
|
81772
|
+
"no-gpu-device"
|
|
81637
81773
|
]);
|
|
81638
81774
|
var NodeInferenceDeviceSchema = object({
|
|
81639
81775
|
/** Stable per-node device key, e.g. `openvino:npu`, `edgetpu:usb`, `cpu`. */
|
|
@@ -81719,6 +81855,75 @@ var NodeInferenceDevicesSchema = object({
|
|
|
81719
81855
|
devices: array(NodeInferenceDeviceSchema).readonly()
|
|
81720
81856
|
});
|
|
81721
81857
|
/**
|
|
81858
|
+
* The CLUSTER switch of one pipeline step (D1065):
|
|
81859
|
+
* - `off` — hard off: no camera, node or device can turn it on;
|
|
81860
|
+
* - `on` — on by default; a camera may turn it off (`stepToggles`);
|
|
81861
|
+
* - `opt-in` — off by default; a camera turns it on (`stepToggles`).
|
|
81862
|
+
* Absent = the catalog's `enabledByDefault` (`true` → `on`, `false` → `opt-in`).
|
|
81863
|
+
*/
|
|
81864
|
+
var StepClusterModeSchema = _enum([
|
|
81865
|
+
"off",
|
|
81866
|
+
"on",
|
|
81867
|
+
"opt-in"
|
|
81868
|
+
]);
|
|
81869
|
+
/**
|
|
81870
|
+
* What one step does on one (node, device) — computed by the orchestrator with
|
|
81871
|
+
* the SAME placement function the attach path runs (`pipeline-resolver.ts`),
|
|
81872
|
+
* so a client never re-derives it. Precedence: cluster off > camera toggle
|
|
81873
|
+
* (else the cluster default) > node off > device off / jump.
|
|
81874
|
+
*/
|
|
81875
|
+
var StepSwitchCellSchema = discriminatedUnion("kind", [
|
|
81876
|
+
object({ kind: literal("on") }),
|
|
81877
|
+
object({ kind: literal("off-cluster") }),
|
|
81878
|
+
object({ kind: literal("off-node") }),
|
|
81879
|
+
object({ kind: literal("off-device") }),
|
|
81880
|
+
object({
|
|
81881
|
+
kind: literal("jump"),
|
|
81882
|
+
toDeviceKey: string()
|
|
81883
|
+
}),
|
|
81884
|
+
object({
|
|
81885
|
+
kind: literal("skip"),
|
|
81886
|
+
reason: _enum(["no-compatible-model", "root-not-runnable-on-elected-device"])
|
|
81887
|
+
}),
|
|
81888
|
+
object({ kind: literal("zone-driven") }),
|
|
81889
|
+
object({
|
|
81890
|
+
kind: literal("supplied-by-root"),
|
|
81891
|
+
rootModelId: string()
|
|
81892
|
+
}),
|
|
81893
|
+
object({ kind: literal("opt-in-unused") })
|
|
81894
|
+
]);
|
|
81895
|
+
var StepSwitchDeviceSchema = object({
|
|
81896
|
+
deviceKey: string(),
|
|
81897
|
+
format: _enum(MODEL_FORMATS),
|
|
81898
|
+
/** The device switch as stored (`inferenceDevices[key].steps[step].enabled`); `null` = inherit. */
|
|
81899
|
+
stepEnabled: boolean().nullable(),
|
|
81900
|
+
/** Whether the device is in the node's dispatch roster (enabled, available, not excluded). */
|
|
81901
|
+
eligible: boolean(),
|
|
81902
|
+
cell: StepSwitchCellSchema
|
|
81903
|
+
});
|
|
81904
|
+
var StepSwitchNodeSchema = object({
|
|
81905
|
+
nodeId: string(),
|
|
81906
|
+
/** False when the node's catalog or device probe did not answer — no cells are claimed. */
|
|
81907
|
+
reachable: boolean(),
|
|
81908
|
+
/** The node switch as stored (`stepEnabled[step]`); `null` = inherit. */
|
|
81909
|
+
stepEnabled: boolean().nullable(),
|
|
81910
|
+
devices: array(StepSwitchDeviceSchema).readonly()
|
|
81911
|
+
});
|
|
81912
|
+
var StepSwitchMatrixSchema = object({ steps: array(object({
|
|
81913
|
+
stepId: string(),
|
|
81914
|
+
name: string(),
|
|
81915
|
+
slot: string(),
|
|
81916
|
+
/** The stored cluster mode; `null` = the catalog default applies. */
|
|
81917
|
+
clusterMode: StepClusterModeSchema.nullable(),
|
|
81918
|
+
/** The mode in force (stored, else derived from `enabledByDefault`). */
|
|
81919
|
+
effectiveMode: StepClusterModeSchema,
|
|
81920
|
+
/** Cameras whose `stepToggles[step]` is `true`. */
|
|
81921
|
+
camerasEnabling: number$1().int().nonnegative(),
|
|
81922
|
+
/** Cameras whose `stepToggles[step]` is `false`. */
|
|
81923
|
+
camerasDisabling: number$1().int().nonnegative(),
|
|
81924
|
+
nodes: array(StepSwitchNodeSchema).readonly()
|
|
81925
|
+
})).readonly() });
|
|
81926
|
+
/**
|
|
81722
81927
|
* Pipeline Orchestrator capability — global load balancer + camera dispatcher.
|
|
81723
81928
|
*
|
|
81724
81929
|
* Lives on the hub. Tracks the camera-to-agent assignment map, listens to
|
|
@@ -82091,6 +82296,51 @@ var pipelineOrchestratorCapability = {
|
|
|
82091
82296
|
auth: "admin"
|
|
82092
82297
|
}),
|
|
82093
82298
|
/**
|
|
82299
|
+
* Set one step's CLUSTER switch (D1065): `off` | `on` | `opt-in`, or
|
|
82300
|
+
* `null` to return to the catalog default. Re-resolves every placed
|
|
82301
|
+
* camera's pipeline.
|
|
82302
|
+
*/
|
|
82303
|
+
setClusterStepMode: method(object({
|
|
82304
|
+
stepId: string(),
|
|
82305
|
+
mode: StepClusterModeSchema.nullable()
|
|
82306
|
+
}), object({ success: literal(true) }), {
|
|
82307
|
+
kind: "mutation",
|
|
82308
|
+
auth: "admin"
|
|
82309
|
+
}),
|
|
82310
|
+
/**
|
|
82311
|
+
* Set one step's NODE switch (D1065): `false` = the step never runs on a
|
|
82312
|
+
* camera whose pipeline runs on that node; `null` = inherit.
|
|
82313
|
+
*/
|
|
82314
|
+
setNodeStepEnabled: method(object({
|
|
82315
|
+
agentNodeId: string(),
|
|
82316
|
+
stepId: string(),
|
|
82317
|
+
enabled: boolean().nullable()
|
|
82318
|
+
}), object({ success: literal(true) }), {
|
|
82319
|
+
kind: "mutation",
|
|
82320
|
+
auth: "admin"
|
|
82321
|
+
}),
|
|
82322
|
+
/**
|
|
82323
|
+
* Set one step's DEVICE switch (D1065) on `(node, deviceKey)`: `false` =
|
|
82324
|
+
* the step is not provisioned there (a detail step jumps to an allowed
|
|
82325
|
+
* sibling, else is skipped); `null` = inherit.
|
|
82326
|
+
*/
|
|
82327
|
+
setDeviceStepEnabled: method(object({
|
|
82328
|
+
agentNodeId: string(),
|
|
82329
|
+
deviceKey: string(),
|
|
82330
|
+
stepId: string(),
|
|
82331
|
+
enabled: boolean().nullable()
|
|
82332
|
+
}), object({ success: literal(true) }), {
|
|
82333
|
+
kind: "mutation",
|
|
82334
|
+
auth: "admin"
|
|
82335
|
+
}),
|
|
82336
|
+
/**
|
|
82337
|
+
* The step switch matrix (D1065): per step, the cluster mode, how many
|
|
82338
|
+
* cameras turn it on / off, and per node and device the effective cell —
|
|
82339
|
+
* computed by the same placement function the attach path runs. The
|
|
82340
|
+
* inspector renders this; it never derives a cell itself.
|
|
82341
|
+
*/
|
|
82342
|
+
getStepSwitches: method(_void(), StepSwitchMatrixSchema),
|
|
82343
|
+
/**
|
|
82094
82344
|
* DEVICE-AWARE merged view of ONE node's inference accelerators. Joins each
|
|
82095
82345
|
* physical device the node HAS — probed live via a node-pinned
|
|
82096
82346
|
* `platformProbe.getCapabilities` (the platform-probe singleton is targeted
|
|
@@ -92344,7 +92594,7 @@ var WorkloadPortSchema = object({
|
|
|
92344
92594
|
hostIp: string().nullable(),
|
|
92345
92595
|
protocol: WorkloadPortProtocolSchema
|
|
92346
92596
|
});
|
|
92347
|
-
object({
|
|
92597
|
+
var WorkloadStatusSchema = object({
|
|
92348
92598
|
/** null = unknown, never stopped (D393). */
|
|
92349
92599
|
state: WorkloadStateSchema.nullable().meta({ label: "State" }),
|
|
92350
92600
|
/** Epoch ms the current state began (uptime while running); null when unknown. */
|
|
@@ -93798,23 +94048,56 @@ var fountainContribution = contribution("pet-fountain", PetFountainStatusSchema,
|
|
|
93798
94048
|
};
|
|
93799
94049
|
});
|
|
93800
94050
|
var minutesOf = (seconds) => Math.max(0, Math.round(seconds / 60));
|
|
94051
|
+
var pumpCycleContribution = contribution("pump-cycle", PumpCycleStatusSchema, (slice) => {
|
|
94052
|
+
const enabled = slice?.enabled ?? null;
|
|
94053
|
+
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;
|
|
94054
|
+
return { rows: [row$1("pump-cycle", "timer", enabled === null ? unknownText : enabled ? joinText([t("Cycling", "A cicli"), cycle]) : t("Runs continuously", "Sempre attiva"), [{
|
|
94055
|
+
kind: "toggle",
|
|
94056
|
+
id: "pump-cycle.enabled",
|
|
94057
|
+
label: t("Pump cycle", "Ciclo pompa"),
|
|
94058
|
+
on: enabled,
|
|
94059
|
+
turnOn: action("pump-cycle.on", t("Cycle the pump", "Attiva il ciclo"), "timer", "pump-cycle", "setEnabled", { on: true }),
|
|
94060
|
+
turnOff: action("pump-cycle.off", t("Run continuously", "Sempre attiva"), "timer-off", "pump-cycle", "setEnabled", { on: false })
|
|
94061
|
+
}])] };
|
|
94062
|
+
});
|
|
94063
|
+
var WORKLOAD_WORDS = {
|
|
94064
|
+
running: {
|
|
94065
|
+
state: "on",
|
|
94066
|
+
title: t("Running", "In esecuzione")
|
|
94067
|
+
},
|
|
94068
|
+
paused: {
|
|
94069
|
+
state: "standby",
|
|
94070
|
+
title: t("Paused", "In pausa")
|
|
94071
|
+
},
|
|
94072
|
+
stopped: {
|
|
94073
|
+
state: "off",
|
|
94074
|
+
title: t("Stopped", "Fermo")
|
|
94075
|
+
},
|
|
94076
|
+
starting: {
|
|
94077
|
+
state: "running",
|
|
94078
|
+
title: t("Starting", "In avvio")
|
|
94079
|
+
},
|
|
94080
|
+
stopping: {
|
|
94081
|
+
state: "running",
|
|
94082
|
+
title: t("Stopping", "In arresto")
|
|
94083
|
+
},
|
|
94084
|
+
crashed: {
|
|
94085
|
+
state: "alert",
|
|
94086
|
+
title: t("Crashed", "Andato in errore")
|
|
94087
|
+
}
|
|
94088
|
+
};
|
|
93801
94089
|
var DEVICES_FAMILY_CONTRIBUTIONS = {
|
|
93802
94090
|
"fan-control": fanContribution,
|
|
93803
94091
|
"vacuum-control": vacuumContribution,
|
|
93804
94092
|
"lawn-mower-control": mowerContribution,
|
|
93805
94093
|
"pet-feeder": feederContribution,
|
|
93806
94094
|
"pet-fountain": fountainContribution,
|
|
93807
|
-
"pump-cycle":
|
|
93808
|
-
|
|
93809
|
-
const
|
|
93810
|
-
|
|
93811
|
-
|
|
93812
|
-
|
|
93813
|
-
label: t("Pump cycle", "Ciclo pompa"),
|
|
93814
|
-
on: enabled,
|
|
93815
|
-
turnOn: action("pump-cycle.on", t("Cycle the pump", "Attiva il ciclo"), "timer", "pump-cycle", "setEnabled", { on: true }),
|
|
93816
|
-
turnOff: action("pump-cycle.off", t("Run continuously", "Sempre attiva"), "timer-off", "pump-cycle", "setEnabled", { on: false })
|
|
93817
|
-
}])] };
|
|
94095
|
+
"pump-cycle": pumpCycleContribution,
|
|
94096
|
+
workload: contribution("workload", WorkloadStatusSchema, (slice) => {
|
|
94097
|
+
const state = slice?.state ?? null;
|
|
94098
|
+
if (state === null) return { reading: reading("workload", "unknown") };
|
|
94099
|
+
const words = WORKLOAD_WORDS[state];
|
|
94100
|
+
return { reading: reading("workload", words.state, false, words.title) };
|
|
93818
94101
|
})
|
|
93819
94102
|
};
|
|
93820
94103
|
/**
|
|
@@ -102831,6 +103114,13 @@ Object.freeze({
|
|
|
102831
103114
|
access: "view",
|
|
102832
103115
|
role: "admin"
|
|
102833
103116
|
},
|
|
103117
|
+
"pipelineOrchestrator.getStepSwitches": {
|
|
103118
|
+
capName: "pipeline-orchestrator",
|
|
103119
|
+
capScope: "system",
|
|
103120
|
+
addonId: null,
|
|
103121
|
+
access: "view",
|
|
103122
|
+
role: "admin"
|
|
103123
|
+
},
|
|
102834
103124
|
"pipelineOrchestrator.listAgentSettings": {
|
|
102835
103125
|
capName: "pipeline-orchestrator",
|
|
102836
103126
|
capScope: "system",
|
|
@@ -102985,6 +103275,20 @@ Object.freeze({
|
|
|
102985
103275
|
access: "create",
|
|
102986
103276
|
role: "admin"
|
|
102987
103277
|
},
|
|
103278
|
+
"pipelineOrchestrator.setClusterStepMode": {
|
|
103279
|
+
capName: "pipeline-orchestrator",
|
|
103280
|
+
capScope: "system",
|
|
103281
|
+
addonId: null,
|
|
103282
|
+
access: "create",
|
|
103283
|
+
role: "admin"
|
|
103284
|
+
},
|
|
103285
|
+
"pipelineOrchestrator.setDeviceStepEnabled": {
|
|
103286
|
+
capName: "pipeline-orchestrator",
|
|
103287
|
+
capScope: "system",
|
|
103288
|
+
addonId: null,
|
|
103289
|
+
access: "create",
|
|
103290
|
+
role: "admin"
|
|
103291
|
+
},
|
|
102988
103292
|
"pipelineOrchestrator.setLoadBalancingShares": {
|
|
102989
103293
|
capName: "pipeline-orchestrator",
|
|
102990
103294
|
capScope: "system",
|
|
@@ -102992,6 +103296,13 @@ Object.freeze({
|
|
|
102992
103296
|
access: "create",
|
|
102993
103297
|
role: "admin"
|
|
102994
103298
|
},
|
|
103299
|
+
"pipelineOrchestrator.setNodeStepEnabled": {
|
|
103300
|
+
capName: "pipeline-orchestrator",
|
|
103301
|
+
capScope: "system",
|
|
103302
|
+
addonId: null,
|
|
103303
|
+
access: "create",
|
|
103304
|
+
role: "admin"
|
|
103305
|
+
},
|
|
102995
103306
|
"pipelineOrchestrator.setNodeStepSettings": {
|
|
102996
103307
|
capName: "pipeline-orchestrator",
|
|
102997
103308
|
capScope: "system",
|
|
@@ -114959,6 +115270,52 @@ function createDiskReconcileJobRunner(now = Date.now) {
|
|
|
114959
115270
|
};
|
|
114960
115271
|
}
|
|
114961
115272
|
//#endregion
|
|
115273
|
+
//#region src/node-step-settings.ts
|
|
115274
|
+
/**
|
|
115275
|
+
* The provisioning base for `deviceKey` (`''` = the runner's default pool,
|
|
115276
|
+
* which has no device entry and takes the node layer alone). Pure; fresh
|
|
115277
|
+
* objects only.
|
|
115278
|
+
*/
|
|
115279
|
+
function nodeDeviceBase(node, deviceKey) {
|
|
115280
|
+
const own = node?.inferenceDevices?.[deviceKey]?.steps ?? {};
|
|
115281
|
+
const nodeLayer = node?.stepSettings ?? {};
|
|
115282
|
+
const out = {};
|
|
115283
|
+
for (const stepId of new Set([...Object.keys(nodeLayer), ...Object.keys(own)])) {
|
|
115284
|
+
const device = own[stepId];
|
|
115285
|
+
const merged = {
|
|
115286
|
+
...nodeLayer[stepId],
|
|
115287
|
+
...device?.settings
|
|
115288
|
+
};
|
|
115289
|
+
out[stepId] = {
|
|
115290
|
+
...device?.modelId !== void 0 ? { modelId: device.modelId } : {},
|
|
115291
|
+
...device?.jumpDeviceKey !== void 0 ? { jumpDeviceKey: device.jumpDeviceKey } : {},
|
|
115292
|
+
...Object.keys(merged).length > 0 ? { settings: merged } : {}
|
|
115293
|
+
};
|
|
115294
|
+
}
|
|
115295
|
+
return out;
|
|
115296
|
+
}
|
|
115297
|
+
/**
|
|
115298
|
+
* The steps switched OFF on `deviceKey` of this node (D1065):
|
|
115299
|
+
* `inferenceDevices[deviceKey].steps[step].enabled === false`. Only that
|
|
115300
|
+
* device's own entry is read; `''` (the default pool) has none.
|
|
115301
|
+
*/
|
|
115302
|
+
function deviceDisabledSteps(node, deviceKey) {
|
|
115303
|
+
const steps = node?.inferenceDevices?.[deviceKey]?.steps ?? {};
|
|
115304
|
+
return new Set(Object.entries(steps).filter(([, cfg]) => cfg.enabled === false).map(([stepId]) => stepId));
|
|
115305
|
+
}
|
|
115306
|
+
/**
|
|
115307
|
+
* The steps a DEFAULT-POOL attach (no elected device) must not run (D1065):
|
|
115308
|
+
* those switched off on EVERY device the pool may be. The pool is the node's
|
|
115309
|
+
* eligible devices (one eligible device IS the pool, D745); with none
|
|
115310
|
+
* eligible it is any device the node has enabled. A step one of them still
|
|
115311
|
+
* allows is kept — the pool may be that device. No candidate ⇒ nothing.
|
|
115312
|
+
*/
|
|
115313
|
+
function poolDisabledSteps(node, eligibleKeys) {
|
|
115314
|
+
const [first, ...rest] = (eligibleKeys.length > 0 ? eligibleKeys : Object.entries(node?.inferenceDevices ?? {}).filter(([, device]) => device.enabled).map(([key]) => key)).map((key) => deviceDisabledSteps(node, key));
|
|
115315
|
+
if (first === void 0) return /* @__PURE__ */ new Set();
|
|
115316
|
+
return new Set([...first].filter((stepId) => rest.every((steps) => steps.has(stepId))));
|
|
115317
|
+
}
|
|
115318
|
+
//#endregion
|
|
114962
115319
|
//#region src/pipeline-resolver.ts
|
|
114963
115320
|
/**
|
|
114964
115321
|
* The `package-detection` root step id. Zone-driven activation
|
|
@@ -115035,38 +115392,86 @@ function addonHasCompatibleModel(addon, format) {
|
|
|
115035
115392
|
function isVideoRoot(addon) {
|
|
115036
115393
|
return (addon.inputClasses ?? []).length === 0;
|
|
115037
115394
|
}
|
|
115038
|
-
/**
|
|
115039
|
-
|
|
115040
|
-
|
|
115041
|
-
|
|
115042
|
-
|
|
115043
|
-
|
|
115044
|
-
|
|
115045
|
-
|
|
115046
|
-
|
|
115047
|
-
|
|
115048
|
-
|
|
115049
|
-
|
|
115050
|
-
|
|
115051
|
-
|
|
115052
|
-
|
|
115053
|
-
|
|
115054
|
-
|
|
115055
|
-
|
|
115056
|
-
|
|
115395
|
+
/** The cluster mode a step runs under when none is stored: the catalog default. */
|
|
115396
|
+
function defaultClusterStepMode(addon) {
|
|
115397
|
+
return addon.enabledByDefault === false ? "opt-in" : "on";
|
|
115398
|
+
}
|
|
115399
|
+
/** The cluster mode in force: the stored one, else the catalog default. */
|
|
115400
|
+
function effectiveClusterStepMode(addon, stored) {
|
|
115401
|
+
return stored ?? defaultClusterStepMode(addon);
|
|
115402
|
+
}
|
|
115403
|
+
function gateStep(addon, layers) {
|
|
115404
|
+
const mode = effectiveClusterStepMode(addon, layers.clusterMode);
|
|
115405
|
+
if (mode === "off") return {
|
|
115406
|
+
kind: "off",
|
|
115407
|
+
reason: "disabled-on-cluster"
|
|
115408
|
+
};
|
|
115409
|
+
if (!(layers.cameraToggle ?? mode === "on")) return {
|
|
115410
|
+
kind: "off",
|
|
115411
|
+
reason: "disabled-on-camera"
|
|
115412
|
+
};
|
|
115413
|
+
if (layers.nodeEnabled === false) return {
|
|
115414
|
+
kind: "off",
|
|
115415
|
+
reason: "disabled-on-node"
|
|
115416
|
+
};
|
|
115417
|
+
return { kind: "on" };
|
|
115418
|
+
}
|
|
115419
|
+
function placeStepOnDevices(addon, elected, roster) {
|
|
115420
|
+
if (addon.slot === "audio-classifier") return { kind: "run" };
|
|
115421
|
+
const builds = (slot) => addonHasCompatibleModel(addon, slot.format);
|
|
115422
|
+
const allowed = (slot) => !slot.disabledSteps.has(addon.id);
|
|
115423
|
+
const electedBuild = builds(elected);
|
|
115424
|
+
if (electedBuild && allowed(elected)) return { kind: "run" };
|
|
115425
|
+
if (isVideoRoot(addon)) {
|
|
115426
|
+
if (!allowed(elected)) return {
|
|
115427
|
+
kind: "skip",
|
|
115428
|
+
reason: "disabled-on-device"
|
|
115429
|
+
};
|
|
115430
|
+
return roster.some(builds) ? {
|
|
115431
|
+
kind: "skip",
|
|
115432
|
+
reason: "root-not-runnable-on-elected-device"
|
|
115433
|
+
} : {
|
|
115434
|
+
kind: "skip",
|
|
115435
|
+
reason: "no-compatible-model"
|
|
115436
|
+
};
|
|
115437
|
+
}
|
|
115438
|
+
const first = roster.filter((slot) => builds(slot) && allowed(slot)).toSorted((a, b) => slotOrderKey(a).localeCompare(slotOrderKey(b)))[0];
|
|
115439
|
+
if (first !== void 0) return {
|
|
115440
|
+
kind: "jump",
|
|
115441
|
+
toDeviceKey: first.deviceKey
|
|
115442
|
+
};
|
|
115443
|
+
return {
|
|
115444
|
+
kind: "skip",
|
|
115445
|
+
reason: electedBuild && !allowed(elected) || roster.some(builds) ? "disabled-on-device" : "no-compatible-model"
|
|
115446
|
+
};
|
|
115447
|
+
}
|
|
115448
|
+
function slotOrderKey(slot) {
|
|
115449
|
+
return slot.deviceKey ?? slot.format;
|
|
115450
|
+
}
|
|
115451
|
+
var NO_STEPS = /* @__PURE__ */ new Set();
|
|
115452
|
+
/** The gate layers of `addonId` read from a switch context (absent entries stay absent). */
|
|
115453
|
+
function gateLayersOf(addonId, switches) {
|
|
115454
|
+
const clusterMode = switches.clusterModes?.[addonId];
|
|
115455
|
+
const nodeEnabled = switches.nodeStepEnabled?.[addonId];
|
|
115456
|
+
return {
|
|
115457
|
+
...clusterMode !== void 0 ? { clusterMode } : {},
|
|
115458
|
+
...nodeEnabled !== void 0 ? { nodeEnabled } : {}
|
|
115459
|
+
};
|
|
115057
115460
|
}
|
|
115058
115461
|
/**
|
|
115059
115462
|
* Device-aware resolver — the SINGLE per-camera gate + per-DEVICE skip check.
|
|
115060
115463
|
*
|
|
115061
115464
|
* Step `S` runs for camera `C` on device `D` ⇔
|
|
115062
|
-
* gate(C, S)
|
|
115063
|
-
*
|
|
115465
|
+
* gate(C, N, S) — {@link gateStep}: cluster not off, the camera toggle
|
|
115466
|
+
* (else the cluster default), the node switch (D1065)
|
|
115467
|
+
* AND provided(D, S) — {@link placeStepOnDevices}: a device not switched off
|
|
115468
|
+
* for S has a build of it — the catalog lists a model with a build for D's FORMAT
|
|
115064
115469
|
* (a ROOT), or for D's format or any `jumpFormats`
|
|
115065
115470
|
* entry (a detail step — the runner jumps it, D650);
|
|
115066
115471
|
* `audio-classifier` is never format-gated (it runs
|
|
115067
115472
|
* on the audio-analyzer's own backend)
|
|
115068
115473
|
*
|
|
115069
|
-
*
|
|
115474
|
+
* Provisioning
|
|
115070
115475
|
* (`modelId` / `settings`) is NOT applied here — the returned tree carries bare
|
|
115071
115476
|
* `{ addonId, enabled: true, children }` nodes; {@link applyDeviceProvisioning}
|
|
115072
115477
|
* attaches model + settings at dispatch from the per-(node,device) base and the
|
|
@@ -115076,30 +115481,58 @@ function unprovisionedReason(addon, electedFormat, jumpFormats) {
|
|
|
115076
115481
|
* recorded in `skipped` so the caller can surface a visible "gated on, no model
|
|
115077
115482
|
* on this node" status at dispatch time.
|
|
115078
115483
|
*
|
|
115079
|
-
* `package-detection` is excluded
|
|
115080
|
-
* ({@link applyPackageZoneActivation}, applied by the caller)
|
|
115484
|
+
* `package-detection` is excluded from the tree — it is zone-driven
|
|
115485
|
+
* ({@link applyPackageZoneActivation}, applied by the caller); the cluster,
|
|
115486
|
+
* node and elected-device switches still apply, as `packageAllowed` (D1065).
|
|
115081
115487
|
*
|
|
115082
115488
|
* "Inference disabled for this camera" is NOT handled here — the caller
|
|
115083
115489
|
* (resolvePipelineForDevice) consults the detection-pipeline binding and
|
|
115084
115490
|
* short-circuits to an empty pipeline before invoking this resolver.
|
|
115085
115491
|
*/
|
|
115086
|
-
function resolvePipelineWithSkips(cameraSettings, deviceFormat, catalog, jumpFormats = []) {
|
|
115492
|
+
function resolvePipelineWithSkips(cameraSettings, deviceFormat, catalog, jumpFormats = [], switches = {}) {
|
|
115087
115493
|
const toggles = (cameraSettings ?? {}).stepToggles ?? {};
|
|
115088
|
-
const
|
|
115494
|
+
const elected = {
|
|
115495
|
+
format: deviceFormat,
|
|
115496
|
+
disabledSteps: switches.electedDisabledSteps ?? NO_STEPS
|
|
115497
|
+
};
|
|
115498
|
+
const roster = switches.jumpTargets ?? jumpFormats.map((format) => ({
|
|
115499
|
+
format,
|
|
115500
|
+
disabledSteps: NO_STEPS
|
|
115501
|
+
}));
|
|
115502
|
+
let packageAllowed = true;
|
|
115089
115503
|
const enabled = [];
|
|
115090
115504
|
const skipped = [];
|
|
115091
115505
|
const droppedRoots = [];
|
|
115092
115506
|
for (const slot of catalog.slots) for (const addon of slot.addons) {
|
|
115093
115507
|
const addonId = addon.id;
|
|
115094
|
-
|
|
115095
|
-
if (
|
|
115096
|
-
|
|
115097
|
-
|
|
115508
|
+
const layers = gateLayersOf(addonId, switches);
|
|
115509
|
+
if (addonId === "package-detection") {
|
|
115510
|
+
packageAllowed = gateStep(addon, {
|
|
115511
|
+
...layers,
|
|
115512
|
+
cameraToggle: true
|
|
115513
|
+
}).kind === "on" && !elected.disabledSteps.has(addonId);
|
|
115514
|
+
continue;
|
|
115515
|
+
}
|
|
115516
|
+
const cameraToggle = toggles[addonId];
|
|
115517
|
+
const gate = gateStep(addon, {
|
|
115518
|
+
...layers,
|
|
115519
|
+
...cameraToggle !== void 0 ? { cameraToggle } : {}
|
|
115520
|
+
});
|
|
115521
|
+
if (gate.kind === "off") {
|
|
115522
|
+
if (gate.reason !== "disabled-on-camera") skipped.push({
|
|
115523
|
+
addonId,
|
|
115524
|
+
reason: gate.reason
|
|
115525
|
+
});
|
|
115526
|
+
continue;
|
|
115527
|
+
}
|
|
115528
|
+
const placement = placeStepOnDevices(addon, elected, roster);
|
|
115529
|
+
if (placement.kind === "skip") {
|
|
115530
|
+
const reason = placement.reason;
|
|
115098
115531
|
skipped.push({
|
|
115099
115532
|
addonId,
|
|
115100
115533
|
reason
|
|
115101
115534
|
});
|
|
115102
|
-
if (addonId === "object-detection") droppedRoots.push(addonId);
|
|
115535
|
+
if (addonId === "object-detection" && reason !== "disabled-on-device") droppedRoots.push(addonId);
|
|
115103
115536
|
continue;
|
|
115104
115537
|
}
|
|
115105
115538
|
enabled.push({ addonId });
|
|
@@ -115118,7 +115551,8 @@ function resolvePipelineWithSkips(cameraSettings, deviceFormat, catalog, jumpFor
|
|
|
115118
115551
|
audio: audioAddons.length > 0 ? { enabled: true } : null
|
|
115119
115552
|
},
|
|
115120
115553
|
skipped,
|
|
115121
|
-
droppedRoots
|
|
115554
|
+
droppedRoots,
|
|
115555
|
+
packageAllowed
|
|
115122
115556
|
};
|
|
115123
115557
|
}
|
|
115124
115558
|
function findInCatalog(catalog, addonId) {
|
|
@@ -115222,6 +115656,29 @@ function makeRootCapabilityGuard(catalog) {
|
|
|
115222
115656
|
}
|
|
115223
115657
|
return () => true;
|
|
115224
115658
|
}
|
|
115659
|
+
/**
|
|
115660
|
+
* The camera-root SWITCH predicate for a node: `deviceKey → is the root on`.
|
|
115661
|
+
* The root ({@link OBJECT_DETECTION_STEP_ID}) is judged by the same
|
|
115662
|
+
* {@link gateStep} the attach path runs — cluster mode, then the node switch —
|
|
115663
|
+
* and then by the device's own step switch (D1065). The camera toggle is not a
|
|
115664
|
+
* layer here: the election picks a device for every camera of the node, and a
|
|
115665
|
+
* camera that turned its root off is refused by the attach itself.
|
|
115666
|
+
*
|
|
115667
|
+
* Fails OPEN when the catalog has no object-detection slot, like
|
|
115668
|
+
* {@link makeRootCapabilityGuard}. Pure.
|
|
115669
|
+
*/
|
|
115670
|
+
function makeRootSwitchGuard(catalog, clusterModes, node) {
|
|
115671
|
+
const root = catalog.slots.flatMap((slot) => slot.addons).find((a) => a.id === OBJECT_DETECTION_STEP_ID);
|
|
115672
|
+
if (root === void 0) return () => true;
|
|
115673
|
+
const clusterMode = clusterModes[OBJECT_DETECTION_STEP_ID];
|
|
115674
|
+
const nodeEnabled = node?.stepEnabled?.[OBJECT_DETECTION_STEP_ID];
|
|
115675
|
+
if (gateStep(root, {
|
|
115676
|
+
...clusterMode !== void 0 ? { clusterMode } : {},
|
|
115677
|
+
...nodeEnabled !== void 0 ? { nodeEnabled } : {},
|
|
115678
|
+
cameraToggle: true
|
|
115679
|
+
}).kind === "off") return () => false;
|
|
115680
|
+
return (deviceKey) => !deviceDisabledSteps(node, deviceKey).has(OBJECT_DETECTION_STEP_ID);
|
|
115681
|
+
}
|
|
115225
115682
|
/** Split a deviceKey (`<backend>:<device>`, or bare `cpu`) into its parts + format.
|
|
115226
115683
|
* Format comes from the shared {@link deviceBackendToFormat} SSOT (`@camstack/types`)
|
|
115227
115684
|
* — the previously-local `BACKEND_FORMAT` copy is gone (R3/node-F2). Used only for
|
|
@@ -115349,11 +115806,11 @@ function inferenceDeviceCaps(stored) {
|
|
|
115349
115806
|
function isCpuFallback(view) {
|
|
115350
115807
|
return view.backend === "cpu";
|
|
115351
115808
|
}
|
|
115352
|
-
function resolveInferenceDeviceEligibility(probed, stored, canRunRoot, isPoolUsable) {
|
|
115809
|
+
function resolveInferenceDeviceEligibility(probed, stored, canRunRoot, isPoolUsable, isRootSwitchedOn, absentReason) {
|
|
115353
115810
|
const eligible = {};
|
|
115354
115811
|
const excluded = [];
|
|
115355
115812
|
const merged = mergeInferenceDevices(probed, stored);
|
|
115356
|
-
const acceleratorServes = merged.some((d) => !isCpuFallback(d) && d.enabled && d.available && (!canRunRoot || canRunRoot(d.format)));
|
|
115813
|
+
const acceleratorServes = merged.some((d) => !isCpuFallback(d) && d.enabled && d.available && (absentReason?.(d.key) ?? null) === null && (!canRunRoot || canRunRoot(d.format)) && (!isRootSwitchedOn || isRootSwitchedOn(d.key)));
|
|
115357
115814
|
for (const d of merged) {
|
|
115358
115815
|
if (!d.enabled) {
|
|
115359
115816
|
excluded.push({
|
|
@@ -115371,6 +115828,15 @@ function resolveInferenceDeviceEligibility(probed, stored, canRunRoot, isPoolUsa
|
|
|
115371
115828
|
});
|
|
115372
115829
|
continue;
|
|
115373
115830
|
}
|
|
115831
|
+
const absent = absentReason?.(d.key) ?? null;
|
|
115832
|
+
if (absent !== null) {
|
|
115833
|
+
excluded.push({
|
|
115834
|
+
key: d.key,
|
|
115835
|
+
reason: absent,
|
|
115836
|
+
format: d.format
|
|
115837
|
+
});
|
|
115838
|
+
continue;
|
|
115839
|
+
}
|
|
115374
115840
|
if (isPoolUsable && !isPoolUsable(d.key)) {
|
|
115375
115841
|
excluded.push({
|
|
115376
115842
|
key: d.key,
|
|
@@ -115387,6 +115853,14 @@ function resolveInferenceDeviceEligibility(probed, stored, canRunRoot, isPoolUsa
|
|
|
115387
115853
|
});
|
|
115388
115854
|
continue;
|
|
115389
115855
|
}
|
|
115856
|
+
if (isRootSwitchedOn && !isRootSwitchedOn(d.key)) {
|
|
115857
|
+
excluded.push({
|
|
115858
|
+
key: d.key,
|
|
115859
|
+
reason: "root-switched-off",
|
|
115860
|
+
format: d.format
|
|
115861
|
+
});
|
|
115862
|
+
continue;
|
|
115863
|
+
}
|
|
115390
115864
|
if (isCpuFallback(d) && acceleratorServes) {
|
|
115391
115865
|
excluded.push({
|
|
115392
115866
|
key: d.key,
|
|
@@ -121812,10 +122286,14 @@ function pickInferenceDevice(input) {
|
|
|
121812
122286
|
eligibleKeys
|
|
121813
122287
|
};
|
|
121814
122288
|
const pin = input.pinnedDeviceKey ?? null;
|
|
121815
|
-
|
|
121816
|
-
|
|
121817
|
-
|
|
121818
|
-
|
|
122289
|
+
const sole = eligibleKeys.length === 1 ? eligibleKeys[0] : void 0;
|
|
122290
|
+
if (sole !== void 0 && !pin) return {
|
|
122291
|
+
kind: "selected",
|
|
122292
|
+
deviceKey: sole,
|
|
122293
|
+
reason: "sole-eligible",
|
|
122294
|
+
tieBreak: null,
|
|
122295
|
+
eligibleKeys,
|
|
122296
|
+
tiedKeys: eligibleKeys
|
|
121819
122297
|
};
|
|
121820
122298
|
const loadByKey = new Map((input.loads ?? []).map((l) => [l.deviceKey, l]));
|
|
121821
122299
|
const healthyKeys = eligibleKeys.filter((k) => !isDeviceSaturated(loadByKey.get(k)));
|
|
@@ -122367,7 +122845,7 @@ async function resolveAttachPipeline(input, store) {
|
|
|
122367
122845
|
eligible: input.eligible,
|
|
122368
122846
|
caps: input.caps
|
|
122369
122847
|
});
|
|
122370
|
-
const resolved = await store.resolvePipelineForDeviceWithRoots(input.deviceId, input.nodeId, input.deviceKey, jumpTargetKeys(roster, input.deviceKey));
|
|
122848
|
+
const resolved = await store.resolvePipelineForDeviceWithRoots(input.deviceId, input.nodeId, input.deviceKey, jumpTargetKeys(roster, input.deviceKey), defaultPoolOf(input));
|
|
122371
122849
|
if (resolved.droppedRoots.length > 0) return rootRefusal(input, resolved.droppedRoots);
|
|
122372
122850
|
return {
|
|
122373
122851
|
kind: "resolved",
|
|
@@ -122388,7 +122866,7 @@ async function resolveAttachPipelineIfCatalogCached(input, store) {
|
|
|
122388
122866
|
eligible: input.eligible,
|
|
122389
122867
|
caps: input.caps
|
|
122390
122868
|
});
|
|
122391
|
-
const outcome = await store.resolvePipelineForDeviceIfCatalogCached(input.deviceId, input.nodeId, input.deviceKey, jumpTargetKeys(roster, input.deviceKey));
|
|
122869
|
+
const outcome = await store.resolvePipelineForDeviceIfCatalogCached(input.deviceId, input.nodeId, input.deviceKey, jumpTargetKeys(roster, input.deviceKey), defaultPoolOf(input));
|
|
122392
122870
|
if (outcome.kind === "catalog-unavailable") return outcome;
|
|
122393
122871
|
if (outcome.droppedRoots.length > 0) return rootRefusal(input, outcome.droppedRoots);
|
|
122394
122872
|
return {
|
|
@@ -122396,6 +122874,10 @@ async function resolveAttachPipelineIfCatalogCached(input, store) {
|
|
|
122396
122874
|
pipeline: await provisionAttachPipeline(input, roster, outcome.config, store)
|
|
122397
122875
|
};
|
|
122398
122876
|
}
|
|
122877
|
+
/** No elected device ⇒ the runner's default pool, made of the eligible devices (D1065). */
|
|
122878
|
+
function defaultPoolOf(input) {
|
|
122879
|
+
return input.deviceKey === void 0 ? { eligibleKeys: Object.keys(input.eligible) } : void 0;
|
|
122880
|
+
}
|
|
122399
122881
|
function rootRefusal(input, droppedRoots) {
|
|
122400
122882
|
return {
|
|
122401
122883
|
kind: "root-refused",
|
|
@@ -122407,9 +122889,10 @@ function rootRefusal(input, droppedRoots) {
|
|
|
122407
122889
|
/**
|
|
122408
122890
|
* Whose provisioning an attach applies. The elected device when there is one.
|
|
122409
122891
|
* With NO elected device the runner's default pool serves the camera; when the
|
|
122410
|
-
* node has exactly one eligible device
|
|
122411
|
-
*
|
|
122412
|
-
*
|
|
122892
|
+
* node has exactly one eligible device (a Mac's `coreml:all`, an N100 with only
|
|
122893
|
+
* its iGPU on) that default pool IS that device. The balancer now elects such a
|
|
122894
|
+
* device itself (`sole-eligible`), so this branch serves a default-pool
|
|
122895
|
+
* dispatch on a one-device node; its model pin and the
|
|
122413
122896
|
* camera's override stored under its key apply (D745 — before, the empty key
|
|
122414
122897
|
* was read, which no store writes, and the pin was silently never run).
|
|
122415
122898
|
* Otherwise `''`: the node's folded settings with no hardware fields.
|
|
@@ -122429,9 +122912,11 @@ async function provisionAttachPipeline(input, roster, resolved, store) {
|
|
|
122429
122912
|
const steps = applyDeviceProvisioning(resolved.steps, elected?.base ?? {}, elected?.override ?? {});
|
|
122430
122913
|
const inferenceDevices = roster?.map((entry) => {
|
|
122431
122914
|
const src = sources.get(entry.deviceKey);
|
|
122915
|
+
const disabledSteps = src?.disabledSteps ?? [];
|
|
122432
122916
|
return {
|
|
122433
122917
|
...entry,
|
|
122434
|
-
steps: provisionDeviceSteps(resolved.steps, src?.base ?? {}, src?.override ?? {})
|
|
122918
|
+
steps: provisionDeviceSteps(resolved.steps, src?.base ?? {}, src?.override ?? {}),
|
|
122919
|
+
...disabledSteps.length > 0 ? { disabledSteps } : {}
|
|
122435
122920
|
};
|
|
122436
122921
|
});
|
|
122437
122922
|
return {
|
|
@@ -122898,6 +123383,26 @@ var PlacementService = class {
|
|
|
122898
123383
|
}, this.deps.settingsStore);
|
|
122899
123384
|
}
|
|
122900
123385
|
/**
|
|
123386
|
+
* What an attach of `deviceId` on `nodeId` WOULD run — the `resolvePipeline`
|
|
123387
|
+
* preview. Same owner as a dispatch ({@link resolveAttachPipeline}), on the
|
|
123388
|
+
* device the camera is elected onto when it is placed on that node; for a
|
|
123389
|
+
* camera placed elsewhere (or nowhere), on the node's highest-weight eligible
|
|
123390
|
+
* device (ties by key), or the default pool when it has none. Before, the
|
|
123391
|
+
* preview resolved on the node's default format with no jump roster, and
|
|
123392
|
+
* reported the detail steps a sibling accelerator runs as dropped.
|
|
123393
|
+
*/
|
|
123394
|
+
async previewAttachPipeline(input) {
|
|
123395
|
+
const [eligible, caps] = await Promise.all([this.deps.getEligibleInferenceDevices(input.nodeId), this.deps.getInferenceDeviceCaps(input.nodeId)]);
|
|
123396
|
+
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];
|
|
123397
|
+
return resolveAttachPipeline({
|
|
123398
|
+
deviceId: input.deviceId,
|
|
123399
|
+
nodeId: input.nodeId,
|
|
123400
|
+
deviceKey,
|
|
123401
|
+
eligible,
|
|
123402
|
+
caps
|
|
123403
|
+
}, this.deps.settingsStore);
|
|
123404
|
+
}
|
|
123405
|
+
/**
|
|
122901
123406
|
* FIRST placement of a standing camera: waits for the chosen node's catalog
|
|
122902
123407
|
* (the resolve reconciles against its executor until it answers). Callers:
|
|
122903
123408
|
* `startDetection`'s standing path — one camera, nothing to attach instead.
|
|
@@ -123447,6 +123952,129 @@ var PlacementService = class {
|
|
|
123447
123952
|
for (const deviceId of affected) await this.deps.emitResolvedCameraUpdated(deviceId);
|
|
123448
123953
|
}
|
|
123449
123954
|
/**
|
|
123955
|
+
* A step switch changed (D1065): re-resolve the attach pipeline of every
|
|
123956
|
+
* placed camera — on `nodeId`, or on every node when `null` (a cluster
|
|
123957
|
+
* switch) — on the device it is already elected onto, through the one owner
|
|
123958
|
+
* of an attach's steps ({@link resolveAttachPipelineOnDevice}). Only a camera
|
|
123959
|
+
* whose resolved steps, audio, device or roster DIFFERS from its cached
|
|
123960
|
+
* attach is re-attached; the rest are left running untouched. A camera whose
|
|
123961
|
+
* root (`object-detection`) the switch took away from its elected device is
|
|
123962
|
+
* RE-ELECTED through the normal placement path ({@link reelectAfterRootSwitch}),
|
|
123963
|
+
* which already excludes a device the root is off on. One camera's failure is
|
|
123964
|
+
* logged and does not stop the sweep; a refused root keeps the live attach.
|
|
123965
|
+
*/
|
|
123966
|
+
async reattachForStepSwitch(nodeId, reason) {
|
|
123967
|
+
const affected = [];
|
|
123968
|
+
for (const [deviceId, assignment] of this.deps.ledger.assignmentEntries()) if (nodeId === null || assignment.agentNodeId === nodeId) affected.push({
|
|
123969
|
+
deviceId,
|
|
123970
|
+
nodeId: assignment.agentNodeId
|
|
123971
|
+
});
|
|
123972
|
+
if (affected.length === 0) return;
|
|
123973
|
+
const logger = this.deps.ctx().logger;
|
|
123974
|
+
let changed = 0;
|
|
123975
|
+
let unchanged = 0;
|
|
123976
|
+
for (const target of affected) {
|
|
123977
|
+
const tags = {
|
|
123978
|
+
deviceId: target.deviceId,
|
|
123979
|
+
nodeId: target.nodeId
|
|
123980
|
+
};
|
|
123981
|
+
const cached = this.deps.ledger.getConfig(target.deviceId);
|
|
123982
|
+
if (!cached) {
|
|
123983
|
+
logger.warn("step switch re-attach skipped — no cached config for a placed camera", {
|
|
123984
|
+
tags,
|
|
123985
|
+
meta: { reason }
|
|
123986
|
+
});
|
|
123987
|
+
unchanged++;
|
|
123988
|
+
continue;
|
|
123989
|
+
}
|
|
123990
|
+
try {
|
|
123991
|
+
const outcome = await this.resolveAttachPipelineOnDevice({
|
|
123992
|
+
deviceId: target.deviceId,
|
|
123993
|
+
nodeId: target.nodeId,
|
|
123994
|
+
deviceKey: cached.deviceKey
|
|
123995
|
+
});
|
|
123996
|
+
if (outcome.kind === "root-refused") {
|
|
123997
|
+
logger.error("step switch re-attach refused — the elected device cannot run the camera root", {
|
|
123998
|
+
tags,
|
|
123999
|
+
meta: {
|
|
124000
|
+
deviceKey: outcome.deviceKey ?? null,
|
|
124001
|
+
droppedRoots: outcome.droppedRoots.join(",")
|
|
124002
|
+
}
|
|
124003
|
+
});
|
|
124004
|
+
unchanged++;
|
|
124005
|
+
continue;
|
|
124006
|
+
}
|
|
124007
|
+
const next = withAttachPipeline(cached, outcome.pipeline);
|
|
124008
|
+
if (hasCameraRoot(cached.steps) && !hasCameraRoot(next.steps)) {
|
|
124009
|
+
await this.reelectAfterRootSwitch(cached, target.nodeId, reason);
|
|
124010
|
+
changed++;
|
|
124011
|
+
continue;
|
|
124012
|
+
}
|
|
124013
|
+
if (sameAttachPipeline(cached, next)) {
|
|
124014
|
+
unchanged++;
|
|
124015
|
+
continue;
|
|
124016
|
+
}
|
|
124017
|
+
this.deps.ledger.setConfig(target.deviceId, next);
|
|
124018
|
+
await this.attachOn(target.nodeId, next);
|
|
124019
|
+
changed++;
|
|
124020
|
+
} catch (err) {
|
|
124021
|
+
logger.warn("step switch re-attach failed", {
|
|
124022
|
+
tags,
|
|
124023
|
+
meta: {
|
|
124024
|
+
reason,
|
|
124025
|
+
error: errMsg$2(err)
|
|
124026
|
+
}
|
|
124027
|
+
});
|
|
124028
|
+
}
|
|
124029
|
+
}
|
|
124030
|
+
logger.info("step switch changed — re-attached the affected cameras", {
|
|
124031
|
+
...nodeId !== null ? { tags: { nodeId } } : {},
|
|
124032
|
+
meta: {
|
|
124033
|
+
reason,
|
|
124034
|
+
changed,
|
|
124035
|
+
unchanged
|
|
124036
|
+
}
|
|
124037
|
+
});
|
|
124038
|
+
}
|
|
124039
|
+
/**
|
|
124040
|
+
* The switch took the camera root away from the device the camera is
|
|
124041
|
+
* elected on. Re-place the camera through the normal path — its election
|
|
124042
|
+
* already excludes a device the root is off on, so it moves to an allowed
|
|
124043
|
+
* device, or the CPU / default pool when one exists. When nothing can host
|
|
124044
|
+
* the root the camera is left as it is and the reason is named: never silent.
|
|
124045
|
+
*/
|
|
124046
|
+
async reelectAfterRootSwitch(cached, nodeId, reason) {
|
|
124047
|
+
const logger = this.deps.ctx().logger;
|
|
124048
|
+
const tags = {
|
|
124049
|
+
deviceId: cached.deviceId,
|
|
124050
|
+
nodeId
|
|
124051
|
+
};
|
|
124052
|
+
const result = await this.redispatchCamera(cached);
|
|
124053
|
+
const placedConfig = this.deps.ledger.getConfig(cached.deviceId);
|
|
124054
|
+
if (result.kind === "assigned" && hasCameraRoot(placedConfig?.steps)) {
|
|
124055
|
+
logger.info("step switch took the camera root off its device — camera re-elected", {
|
|
124056
|
+
tags: {
|
|
124057
|
+
deviceId: cached.deviceId,
|
|
124058
|
+
nodeId: result.agentNodeId
|
|
124059
|
+
},
|
|
124060
|
+
meta: {
|
|
124061
|
+
reason,
|
|
124062
|
+
from: cached.deviceKey ?? "default-pool",
|
|
124063
|
+
to: placedConfig?.deviceKey ?? "default-pool"
|
|
124064
|
+
}
|
|
124065
|
+
});
|
|
124066
|
+
return;
|
|
124067
|
+
}
|
|
124068
|
+
logger.warn("step switch left no device able to host the camera root", {
|
|
124069
|
+
tags,
|
|
124070
|
+
meta: {
|
|
124071
|
+
reason: result.kind === "pending" ? this.deps.ledger.getPendingReason(cached.deviceId) ?? "pending" : "root-switched-off-on-every-eligible-device",
|
|
124072
|
+
switch: reason,
|
|
124073
|
+
deviceKey: cached.deviceKey ?? "default-pool"
|
|
124074
|
+
}
|
|
124075
|
+
});
|
|
124076
|
+
}
|
|
124077
|
+
/**
|
|
123450
124078
|
* Re-dispatch EVERY assigned camera through the REAL attach path
|
|
123451
124079
|
* (`redispatchSingleCamera` → `attachOn`), so each camera's `frameSource`
|
|
123452
124080
|
* (`local-broker` vs `remote-restream` naming the current ingest owner) is
|
|
@@ -123587,6 +124215,14 @@ var PlacementService = class {
|
|
|
123587
124215
|
});
|
|
123588
124216
|
}
|
|
123589
124217
|
};
|
|
124218
|
+
/** Does an attach's step tree carry the camera root (`object-detection`)? */
|
|
124219
|
+
function hasCameraRoot(steps) {
|
|
124220
|
+
return (steps ?? []).some((step) => step.addonId === OBJECT_DETECTION_STEP_ID);
|
|
124221
|
+
}
|
|
124222
|
+
/** Would re-attaching `next` over `current` change anything the runner acts on? */
|
|
124223
|
+
function sameAttachPipeline(current, next) {
|
|
124224
|
+
return (0, node_util.isDeepStrictEqual)(current.steps, next.steps) && (0, node_util.isDeepStrictEqual)(current.audio, next.audio) && current.deviceKey === next.deviceKey && (0, node_util.isDeepStrictEqual)(current.inferenceDevices, next.inferenceDevices);
|
|
124225
|
+
}
|
|
123590
124226
|
//#endregion
|
|
123591
124227
|
//#region src/node-lifecycle-handler.ts
|
|
123592
124228
|
var NodeLifecycleHandler = class {
|
|
@@ -125585,31 +126221,6 @@ async function reattachAfterPackageZoneChange(deps, deviceId) {
|
|
|
125585
126221
|
}
|
|
125586
126222
|
}
|
|
125587
126223
|
//#endregion
|
|
125588
|
-
//#region src/node-step-settings.ts
|
|
125589
|
-
/**
|
|
125590
|
-
* The provisioning base for `deviceKey` (`''` = the runner's default pool,
|
|
125591
|
-
* which has no device entry and takes the node layer alone). Pure; fresh
|
|
125592
|
-
* objects only.
|
|
125593
|
-
*/
|
|
125594
|
-
function nodeDeviceBase(node, deviceKey) {
|
|
125595
|
-
const own = node?.inferenceDevices?.[deviceKey]?.steps ?? {};
|
|
125596
|
-
const nodeLayer = node?.stepSettings ?? {};
|
|
125597
|
-
const out = {};
|
|
125598
|
-
for (const stepId of new Set([...Object.keys(nodeLayer), ...Object.keys(own)])) {
|
|
125599
|
-
const device = own[stepId];
|
|
125600
|
-
const merged = {
|
|
125601
|
-
...nodeLayer[stepId],
|
|
125602
|
-
...device?.settings
|
|
125603
|
-
};
|
|
125604
|
-
out[stepId] = {
|
|
125605
|
-
...device?.modelId !== void 0 ? { modelId: device.modelId } : {},
|
|
125606
|
-
...device?.jumpDeviceKey !== void 0 ? { jumpDeviceKey: device.jumpDeviceKey } : {},
|
|
125607
|
-
...Object.keys(merged).length > 0 ? { settings: merged } : {}
|
|
125608
|
-
};
|
|
125609
|
-
}
|
|
125610
|
-
return out;
|
|
125611
|
-
}
|
|
125612
|
-
//#endregion
|
|
125613
126224
|
//#region src/removed-model-pin-reset.ts
|
|
125614
126225
|
/**
|
|
125615
126226
|
* A stored model pin naming a model DELETED from its step's catalog is reset to
|
|
@@ -125832,7 +126443,8 @@ var AutoBenchmarkAttemptsSchema = record(string(), record(string(), object({
|
|
|
125832
126443
|
var StoredDeviceStepConfigSchema = object({
|
|
125833
126444
|
modelId: string().optional(),
|
|
125834
126445
|
settings: record(string(), unknown()).readonly().optional(),
|
|
125835
|
-
jumpDeviceKey: string().optional()
|
|
126446
|
+
jumpDeviceKey: string().optional(),
|
|
126447
|
+
enabled: boolean().optional()
|
|
125836
126448
|
});
|
|
125837
126449
|
var StoredAgentPipelineSettingsSchema = object({
|
|
125838
126450
|
maxCameras: number$1().int().nonnegative().nullable().default(null),
|
|
@@ -125846,6 +126458,7 @@ var StoredAgentPipelineSettingsSchema = object({
|
|
|
125846
126458
|
reachableHost: string().optional(),
|
|
125847
126459
|
color: NodeColorIdSchema.optional(),
|
|
125848
126460
|
stepSettings: record(string(), record(string(), unknown()).readonly()).optional(),
|
|
126461
|
+
stepEnabled: record(string(), boolean()).optional(),
|
|
125849
126462
|
inferenceDevices: record(string(), object({
|
|
125850
126463
|
enabled: boolean(),
|
|
125851
126464
|
weight: number$1().positive().optional(),
|
|
@@ -125853,6 +126466,7 @@ var StoredAgentPipelineSettingsSchema = object({
|
|
|
125853
126466
|
steps: record(string(), StoredDeviceStepConfigSchema).optional()
|
|
125854
126467
|
})).optional()
|
|
125855
126468
|
});
|
|
126469
|
+
var ClusterStepModesSchema = record(string(), StepClusterModeSchema);
|
|
125856
126470
|
var AgentSettingsMapSchema = record(string(), StoredAgentPipelineSettingsSchema);
|
|
125857
126471
|
var StoredCameraPipelineSettingsSchema = object({
|
|
125858
126472
|
stepToggles: record(string(), boolean()).optional(),
|
|
@@ -125974,6 +126588,12 @@ var DeviceRows = class {
|
|
|
125974
126588
|
//#endregion
|
|
125975
126589
|
//#region src/pipeline-settings-store.ts
|
|
125976
126590
|
var PIPELINE_EXECUTOR_CAP = "pipeline-executor";
|
|
126591
|
+
/** The addon-store key of the cluster step switches (D1065). */
|
|
126592
|
+
var CLUSTER_STEP_MODES_KEY = "clusterStepModes";
|
|
126593
|
+
/** A skip an operator switch caused (D1065), as opposed to a missing build. */
|
|
126594
|
+
function isSwitchSkip(reason) {
|
|
126595
|
+
return reason === "disabled-on-cluster" || reason === "disabled-on-node" || reason === "disabled-on-device";
|
|
126596
|
+
}
|
|
125977
126597
|
var PipelineSettingsStore = class PipelineSettingsStore {
|
|
125978
126598
|
deps;
|
|
125979
126599
|
static CATALOG_CACHE_TTL_MS = 3e4;
|
|
@@ -126167,6 +126787,79 @@ var PipelineSettingsStore = class PipelineSettingsStore {
|
|
|
126167
126787
|
});
|
|
126168
126788
|
});
|
|
126169
126789
|
}
|
|
126790
|
+
clusterStepModesState() {
|
|
126791
|
+
return this.deps.state(CLUSTER_STEP_MODES_KEY, ClusterStepModesSchema, {});
|
|
126792
|
+
}
|
|
126793
|
+
/** The stored cluster step modes, `stepId → mode` (absent step = catalog default). */
|
|
126794
|
+
async readClusterStepModes() {
|
|
126795
|
+
return await this.clusterStepModesState().get();
|
|
126796
|
+
}
|
|
126797
|
+
/** Write one step's cluster mode; `null` removes it (back to the catalog default). */
|
|
126798
|
+
async writeClusterStepMode(stepId, mode) {
|
|
126799
|
+
await this.blobWriteLock.run(CLUSTER_STEP_MODES_KEY, async () => {
|
|
126800
|
+
await this.clusterStepModesState().update((prev) => {
|
|
126801
|
+
const { [stepId]: _drop, ...rest } = prev;
|
|
126802
|
+
return mode === null ? rest : {
|
|
126803
|
+
...rest,
|
|
126804
|
+
[stepId]: mode
|
|
126805
|
+
};
|
|
126806
|
+
});
|
|
126807
|
+
});
|
|
126808
|
+
}
|
|
126809
|
+
/**
|
|
126810
|
+
* Write one step's NODE switch under the agent-blob lock; `null` removes it
|
|
126811
|
+
* (inherit). An empty map is pruned. Creates the node's entry when absent.
|
|
126812
|
+
*/
|
|
126813
|
+
async writeNodeStepEnabled(nodeId, stepId, enabled) {
|
|
126814
|
+
await this.blobWriteLock.run(PipelineSettingsStore.AGENT_SETTINGS_LOCK_KEY, async () => {
|
|
126815
|
+
const { stepEnabled: prevMap, ...rest } = await this.agentRows.get(nodeId) ?? { maxCameras: null };
|
|
126816
|
+
const { [stepId]: _drop, ...others } = prevMap ?? {};
|
|
126817
|
+
const next = enabled === null ? others : {
|
|
126818
|
+
...others,
|
|
126819
|
+
[stepId]: enabled
|
|
126820
|
+
};
|
|
126821
|
+
await this.agentRows.set(nodeId, {
|
|
126822
|
+
...rest,
|
|
126823
|
+
...Object.keys(next).length > 0 ? { stepEnabled: next } : {}
|
|
126824
|
+
});
|
|
126825
|
+
});
|
|
126826
|
+
}
|
|
126827
|
+
/**
|
|
126828
|
+
* Write one step's DEVICE switch on `(nodeId, deviceKey)` under the
|
|
126829
|
+
* agent-blob lock; `null` removes it (inherit). A step entry left empty is
|
|
126830
|
+
* pruned. A device with no stored entry gets one with `deviceEnabled` — its
|
|
126831
|
+
* current participation, which the caller read from the merged device view,
|
|
126832
|
+
* so writing a step switch never flips whether the device dispatches.
|
|
126833
|
+
*/
|
|
126834
|
+
async writeDeviceStepEnabled(input) {
|
|
126835
|
+
const { nodeId, deviceKey, stepId, enabled } = input;
|
|
126836
|
+
await this.blobWriteLock.run(PipelineSettingsStore.AGENT_SETTINGS_LOCK_KEY, async () => {
|
|
126837
|
+
const existing = await this.agentRows.get(nodeId) ?? { maxCameras: null };
|
|
126838
|
+
const devices = existing.inferenceDevices ?? {};
|
|
126839
|
+
const device = devices[deviceKey] ?? { enabled: input.deviceEnabled };
|
|
126840
|
+
const { [stepId]: prevStep, ...otherSteps } = device.steps ?? {};
|
|
126841
|
+
const { enabled: _drop, ...stepRest } = prevStep ?? {};
|
|
126842
|
+
const nextStep = enabled === null ? stepRest : {
|
|
126843
|
+
...stepRest,
|
|
126844
|
+
enabled
|
|
126845
|
+
};
|
|
126846
|
+
const steps = Object.keys(nextStep).length > 0 ? {
|
|
126847
|
+
...otherSteps,
|
|
126848
|
+
[stepId]: nextStep
|
|
126849
|
+
} : otherSteps;
|
|
126850
|
+
const { steps: _oldSteps, ...deviceRest } = device;
|
|
126851
|
+
await this.agentRows.set(nodeId, {
|
|
126852
|
+
...existing,
|
|
126853
|
+
inferenceDevices: {
|
|
126854
|
+
...devices,
|
|
126855
|
+
[deviceKey]: {
|
|
126856
|
+
...deviceRest,
|
|
126857
|
+
...Object.keys(steps).length > 0 ? { steps } : {}
|
|
126858
|
+
}
|
|
126859
|
+
}
|
|
126860
|
+
});
|
|
126861
|
+
});
|
|
126862
|
+
}
|
|
126170
126863
|
/** Purge one device's row. */
|
|
126171
126864
|
async deleteCameraSettings(deviceId) {
|
|
126172
126865
|
await this.cameraRows.remove(deviceId);
|
|
@@ -126412,8 +127105,8 @@ var PipelineSettingsStore = class PipelineSettingsStore {
|
|
|
126412
127105
|
* cannot run (D650 round 3) — what an attach needs to refuse a camera whose
|
|
126413
127106
|
* own detector would not run. Waits for the catalog exactly as it does.
|
|
126414
127107
|
*/
|
|
126415
|
-
async resolvePipelineForDeviceWithRoots(deviceId, agentNodeId, deviceKey, jumpDeviceKeys) {
|
|
126416
|
-
const outcome = await this.resolvePipelineWithCatalog(deviceId, agentNodeId, deviceKey, jumpDeviceKeys, { kind: "await" });
|
|
127108
|
+
async resolvePipelineForDeviceWithRoots(deviceId, agentNodeId, deviceKey, jumpDeviceKeys, defaultPool) {
|
|
127109
|
+
const outcome = await this.resolvePipelineWithCatalog(deviceId, agentNodeId, deviceKey, jumpDeviceKeys, { kind: "await" }, defaultPool);
|
|
126417
127110
|
if (outcome.kind === "resolved") return outcome;
|
|
126418
127111
|
throw new Error(`PipelineSettingsStore.resolvePipelineForDeviceWithRoots: catalog unavailable for "${outcome.nodeId}"`);
|
|
126419
127112
|
}
|
|
@@ -126426,10 +127119,10 @@ var PipelineSettingsStore = class PipelineSettingsStore {
|
|
|
126426
127119
|
* node; D49: never gate on a fallible read). A cold cache also starts one
|
|
126427
127120
|
* background refresh, so the next retry round finds the catalog.
|
|
126428
127121
|
*/
|
|
126429
|
-
async resolvePipelineForDeviceIfCatalogCached(deviceId, agentNodeId, deviceKey, jumpDeviceKeys) {
|
|
126430
|
-
return this.resolvePipelineWithCatalog(deviceId, agentNodeId, deviceKey, jumpDeviceKeys, { kind: "cached" });
|
|
127122
|
+
async resolvePipelineForDeviceIfCatalogCached(deviceId, agentNodeId, deviceKey, jumpDeviceKeys, defaultPool) {
|
|
127123
|
+
return this.resolvePipelineWithCatalog(deviceId, agentNodeId, deviceKey, jumpDeviceKeys, { kind: "cached" }, defaultPool);
|
|
126431
127124
|
}
|
|
126432
|
-
async resolvePipelineWithCatalog(deviceId, agentNodeIdOverride, deviceKey, jumpDeviceKeys, catalogRead) {
|
|
127125
|
+
async resolvePipelineWithCatalog(deviceId, agentNodeIdOverride, deviceKey, jumpDeviceKeys, catalogRead, defaultPool) {
|
|
126433
127126
|
const agentNodeId = agentNodeIdOverride ?? this.deps.getAssignmentNode(deviceId);
|
|
126434
127127
|
if (!agentNodeId) throw new Error(`PipelineSettingsStore.resolvePipelineForDevice: no node resolvable for device ${deviceId}`);
|
|
126435
127128
|
if (!await this.isDetectionPipelineActive(deviceId)) {
|
|
@@ -126463,14 +127156,39 @@ var PipelineSettingsStore = class PipelineSettingsStore {
|
|
|
126463
127156
|
}
|
|
126464
127157
|
const deviceFormat = deviceKey ? parseDeviceKey(deviceKey).format : catalog.selectedEngine.format;
|
|
126465
127158
|
const jumpFormats = [...new Set(jumpDeviceKeys.map((k) => parseDeviceKey(k).format))];
|
|
126466
|
-
const
|
|
126467
|
-
|
|
127159
|
+
const [clusterModes, node] = await Promise.all([this.readClusterStepModes(), this.agentRows.get(agentNodeId)]);
|
|
127160
|
+
const switches = {
|
|
127161
|
+
clusterModes,
|
|
127162
|
+
...node?.stepEnabled !== void 0 ? { nodeStepEnabled: node.stepEnabled } : {},
|
|
127163
|
+
electedDisabledSteps: deviceKey !== void 0 ? deviceDisabledSteps(node, deviceKey) : defaultPool !== void 0 ? poolDisabledSteps(node, defaultPool.eligibleKeys) : deviceDisabledSteps(node, ""),
|
|
127164
|
+
jumpTargets: jumpDeviceKeys.map((key) => ({
|
|
127165
|
+
deviceKey: key,
|
|
127166
|
+
format: parseDeviceKey(key).format,
|
|
127167
|
+
disabledSteps: deviceDisabledSteps(node, key)
|
|
127168
|
+
}))
|
|
127169
|
+
};
|
|
127170
|
+
const { config: resolvedBase, skipped, droppedRoots, packageAllowed } = resolvePipelineWithSkips(cam, deviceFormat, catalog, jumpFormats, switches);
|
|
127171
|
+
const formatSkips = skipped.filter((s) => !isSwitchSkip(s.reason));
|
|
127172
|
+
const switchSkips = skipped.filter((s) => isSwitchSkip(s.reason));
|
|
127173
|
+
const packageOverruled = hasPackageZone && !packageAllowed;
|
|
127174
|
+
if (switchSkips.length > 0 || packageOverruled) this.deps.logger.info(`pipeline steps switched off — skipped (node ${agentNodeId}, device ${deviceId})`, {
|
|
126468
127175
|
tags: {
|
|
126469
127176
|
deviceId,
|
|
126470
127177
|
nodeId: agentNodeId
|
|
126471
127178
|
},
|
|
126472
127179
|
meta: {
|
|
126473
|
-
skipped:
|
|
127180
|
+
skipped: [...switchSkips.map((s) => `${s.addonId}:${s.reason}`), ...packageOverruled ? [`${PACKAGE_DETECTION_STEP_ID}:switched-off`] : []].join(","),
|
|
127181
|
+
electedDeviceKey: deviceKey ?? null,
|
|
127182
|
+
jumpDeviceKeys: jumpDeviceKeys.join(",")
|
|
127183
|
+
}
|
|
127184
|
+
});
|
|
127185
|
+
if (formatSkips.length > 0) this.deps.logger.warn(`pipeline steps gated on but not provisioned on this node — skipped (node ${agentNodeId}, device ${deviceId})`, {
|
|
127186
|
+
tags: {
|
|
127187
|
+
deviceId,
|
|
127188
|
+
nodeId: agentNodeId
|
|
127189
|
+
},
|
|
127190
|
+
meta: {
|
|
127191
|
+
skipped: formatSkips.map((s) => `${s.addonId}:${s.reason}`).join(","),
|
|
126474
127192
|
electedDeviceKey: deviceKey ?? null,
|
|
126475
127193
|
electedFormat: deviceFormat,
|
|
126476
127194
|
jumpDeviceKeys: jumpDeviceKeys.join(","),
|
|
@@ -126479,7 +127197,7 @@ var PipelineSettingsStore = class PipelineSettingsStore {
|
|
|
126479
127197
|
});
|
|
126480
127198
|
const resolved = {
|
|
126481
127199
|
...resolvedBase,
|
|
126482
|
-
steps: applyPackageZoneActivation(resolvedBase.steps, hasPackageZone)
|
|
127200
|
+
steps: applyPackageZoneActivation(resolvedBase.steps, hasPackageZone && packageAllowed)
|
|
126483
127201
|
};
|
|
126484
127202
|
if (resolved.steps.length === 0) this.deps.logger.info("resolvePipelineForDevice → empty (all steps gated off/unprovisioned)", {
|
|
126485
127203
|
tags: {
|
|
@@ -126661,7 +127379,8 @@ var PipelineSettingsStore = class PipelineSettingsStore {
|
|
|
126661
127379
|
const out = /* @__PURE__ */ new Map();
|
|
126662
127380
|
for (const deviceKey of deviceKeys) out.set(deviceKey, {
|
|
126663
127381
|
base: nodeDeviceBase(node, deviceKey),
|
|
126664
|
-
override: cameraLayer
|
|
127382
|
+
override: cameraLayer,
|
|
127383
|
+
disabledSteps: [...deviceDisabledSteps(node, deviceKey)].toSorted()
|
|
126665
127384
|
});
|
|
126666
127385
|
return out;
|
|
126667
127386
|
}
|
|
@@ -131176,6 +131895,141 @@ async function buildOrchestratorControllers(deps) {
|
|
|
131176
131895
|
};
|
|
131177
131896
|
}
|
|
131178
131897
|
//#endregion
|
|
131898
|
+
//#region src/step-switch-matrix.ts
|
|
131899
|
+
/** ONE cell — the gate, then the placement, in the attach path's order. */
|
|
131900
|
+
function stepSwitchCell(input) {
|
|
131901
|
+
const { addon, elected } = input;
|
|
131902
|
+
const layers = {
|
|
131903
|
+
...input.clusterMode !== void 0 ? { clusterMode: input.clusterMode } : {},
|
|
131904
|
+
...input.nodeEnabled !== void 0 ? { nodeEnabled: input.nodeEnabled } : {}
|
|
131905
|
+
};
|
|
131906
|
+
const mode = effectiveClusterStepMode(addon, input.clusterMode);
|
|
131907
|
+
if (mode === "off") return { kind: "off-cluster" };
|
|
131908
|
+
if (addon.id === "package-detection") {
|
|
131909
|
+
const gate = gateStep(addon, {
|
|
131910
|
+
...layers,
|
|
131911
|
+
cameraToggle: true
|
|
131912
|
+
});
|
|
131913
|
+
if (gate.kind === "off") return gate.reason === "disabled-on-node" ? { kind: "off-node" } : { kind: "off-cluster" };
|
|
131914
|
+
return elected.disabledSteps.has(addon.id) ? { kind: "off-device" } : { kind: "zone-driven" };
|
|
131915
|
+
}
|
|
131916
|
+
if (mode === "opt-in" && input.camerasEnabling === 0) return { kind: "opt-in-unused" };
|
|
131917
|
+
const gate = gateStep(addon, {
|
|
131918
|
+
...layers,
|
|
131919
|
+
cameraToggle: true
|
|
131920
|
+
});
|
|
131921
|
+
if (gate.kind === "off") return gate.reason === "disabled-on-node" ? { kind: "off-node" } : { kind: "off-cluster" };
|
|
131922
|
+
const placement = placeStepOnDevices(addon, elected, input.roster);
|
|
131923
|
+
if (placement.kind === "run") return input.suppliedByRootModelId !== void 0 ? {
|
|
131924
|
+
kind: "supplied-by-root",
|
|
131925
|
+
rootModelId: input.suppliedByRootModelId
|
|
131926
|
+
} : { kind: "on" };
|
|
131927
|
+
if (placement.kind === "jump") return placement.toDeviceKey !== void 0 ? {
|
|
131928
|
+
kind: "jump",
|
|
131929
|
+
toDeviceKey: placement.toDeviceKey
|
|
131930
|
+
} : { kind: "on" };
|
|
131931
|
+
if (placement.reason === "disabled-on-device") return { kind: "off-device" };
|
|
131932
|
+
return {
|
|
131933
|
+
kind: "skip",
|
|
131934
|
+
reason: placement.reason
|
|
131935
|
+
};
|
|
131936
|
+
}
|
|
131937
|
+
/** The catalog's steps across every answering node, first-seen order, by id. */
|
|
131938
|
+
function catalogSteps(nodes) {
|
|
131939
|
+
const seen = /* @__PURE__ */ new Map();
|
|
131940
|
+
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);
|
|
131941
|
+
return [...seen.values()];
|
|
131942
|
+
}
|
|
131943
|
+
function findAddon(catalog, id) {
|
|
131944
|
+
for (const slot of catalog.slots) {
|
|
131945
|
+
const found = slot.addons.find((a) => a.id === id);
|
|
131946
|
+
if (found) return found;
|
|
131947
|
+
}
|
|
131948
|
+
}
|
|
131949
|
+
/**
|
|
131950
|
+
* The root model a device runs: its pin, else the model the executor elects
|
|
131951
|
+
* for the device when the root lists it, else the format default.
|
|
131952
|
+
*/
|
|
131953
|
+
function rootModelOn(root, device) {
|
|
131954
|
+
const pin = device.steps?.[OBJECT_DETECTION_STEP_ID]?.modelId;
|
|
131955
|
+
if (pin !== void 0) return pin;
|
|
131956
|
+
if (root.models.some((m) => m.id === device.defaultModelId)) return device.defaultModelId;
|
|
131957
|
+
return root.defaultModelIdByFormat?.[device.format] ?? root.defaultModelId;
|
|
131958
|
+
}
|
|
131959
|
+
/** The root model id when it supplies `stepId` on `device`, else undefined. */
|
|
131960
|
+
function suppliedByRoot(catalog, stepId, device, settings) {
|
|
131961
|
+
if (!isRootSuppliableStepId(stepId)) return void 0;
|
|
131962
|
+
const root = findAddon(catalog, OBJECT_DETECTION_STEP_ID);
|
|
131963
|
+
if (root === void 0) return void 0;
|
|
131964
|
+
const rootModelId = rootModelOn(root, device);
|
|
131965
|
+
const supplies = root.models.find((m) => m.id === rootModelId)?.suppliesSteps;
|
|
131966
|
+
const stepSettings = nodeDeviceBase(settings, device.key)[stepId]?.settings;
|
|
131967
|
+
return resolveRootSupply(stepId, stepSettings, supplies).effective ? rootModelId : void 0;
|
|
131968
|
+
}
|
|
131969
|
+
function slotOf(device, settings) {
|
|
131970
|
+
return {
|
|
131971
|
+
deviceKey: device.key,
|
|
131972
|
+
format: device.format,
|
|
131973
|
+
disabledSteps: deviceDisabledSteps(settings, device.key)
|
|
131974
|
+
};
|
|
131975
|
+
}
|
|
131976
|
+
function countToggles(toggles, stepId, value) {
|
|
131977
|
+
return toggles.filter((t) => t[stepId] === value).length;
|
|
131978
|
+
}
|
|
131979
|
+
function buildStepSwitchMatrix(input) {
|
|
131980
|
+
return { steps: catalogSteps(input.nodes).map((addon) => {
|
|
131981
|
+
const clusterMode = input.clusterModes[addon.id];
|
|
131982
|
+
const camerasEnabling = countToggles(input.cameraToggles, addon.id, true);
|
|
131983
|
+
const nodes = input.nodes.map((node) => {
|
|
131984
|
+
const nodeEnabled = node.settings?.stepEnabled?.[addon.id];
|
|
131985
|
+
const catalog = node.catalog;
|
|
131986
|
+
const devices = node.devices;
|
|
131987
|
+
const nodeAddon = catalog ? findAddon(catalog, addon.id) : void 0;
|
|
131988
|
+
if (catalog === null || devices === null || nodeAddon === void 0) return {
|
|
131989
|
+
nodeId: node.nodeId,
|
|
131990
|
+
reachable: false,
|
|
131991
|
+
stepEnabled: nodeEnabled ?? null,
|
|
131992
|
+
devices: []
|
|
131993
|
+
};
|
|
131994
|
+
const eligible = devices.filter((d) => d.exclusion === null);
|
|
131995
|
+
return {
|
|
131996
|
+
nodeId: node.nodeId,
|
|
131997
|
+
reachable: true,
|
|
131998
|
+
stepEnabled: nodeEnabled ?? null,
|
|
131999
|
+
devices: devices.map((device) => {
|
|
132000
|
+
const roster = eligible.length >= 2 ? eligible.filter((d) => d.key !== device.key).map((d) => slotOf(d, node.settings)) : [];
|
|
132001
|
+
const supplied = suppliedByRoot(catalog, addon.id, device, node.settings);
|
|
132002
|
+
return {
|
|
132003
|
+
deviceKey: device.key,
|
|
132004
|
+
format: device.format,
|
|
132005
|
+
stepEnabled: device.steps?.[addon.id]?.enabled ?? null,
|
|
132006
|
+
eligible: device.exclusion === null,
|
|
132007
|
+
cell: stepSwitchCell({
|
|
132008
|
+
addon: nodeAddon,
|
|
132009
|
+
clusterMode,
|
|
132010
|
+
camerasEnabling,
|
|
132011
|
+
nodeEnabled,
|
|
132012
|
+
elected: slotOf(device, node.settings),
|
|
132013
|
+
roster,
|
|
132014
|
+
...supplied !== void 0 ? { suppliedByRootModelId: supplied } : {}
|
|
132015
|
+
})
|
|
132016
|
+
};
|
|
132017
|
+
})
|
|
132018
|
+
};
|
|
132019
|
+
});
|
|
132020
|
+
return {
|
|
132021
|
+
stepId: addon.id,
|
|
132022
|
+
name: addon.name,
|
|
132023
|
+
slot: addon.slot,
|
|
132024
|
+
clusterMode: clusterMode ?? null,
|
|
132025
|
+
effectiveMode: effectiveClusterStepMode(addon, clusterMode),
|
|
132026
|
+
camerasEnabling,
|
|
132027
|
+
camerasDisabling: countToggles(input.cameraToggles, addon.id, false),
|
|
132028
|
+
nodes
|
|
132029
|
+
};
|
|
132030
|
+
}) };
|
|
132031
|
+
}
|
|
132032
|
+
//#endregion
|
|
131179
132033
|
//#region src/rebalance-suggestion.ts
|
|
131180
132034
|
var REBALANCE_SUGGESTED_ALERT_ID = "pipeline-orchestrator:rebalance-suggested";
|
|
131181
132035
|
var NODE_NOT_USED_ALERT_PREFIX = "pipeline-orchestrator:node-not-used:";
|
|
@@ -134279,14 +135133,15 @@ var PipelineOrchestratorAddon = class PipelineOrchestratorAddon extends BaseAddo
|
|
|
134279
135133
|
*/
|
|
134280
135134
|
async getNodeInferenceDevices(input) {
|
|
134281
135135
|
const nodeId = input.nodeId;
|
|
134282
|
-
const
|
|
135136
|
+
const node = (await this.settingsStore.readAgentSettingsMap())[nodeId];
|
|
135137
|
+
const stored = node?.inferenceDevices ?? {};
|
|
134283
135138
|
const { probed, reachable } = await this.probeNodeInferenceDevices(nodeId);
|
|
134284
135139
|
const catalog = await this.settingsStore.getCatalogForNode(nodeId);
|
|
134285
135140
|
const canRunRoot = catalog ? makeRootCapabilityGuard(catalog) : void 0;
|
|
134286
135141
|
return {
|
|
134287
135142
|
nodeId,
|
|
134288
135143
|
reachable,
|
|
134289
|
-
devices: annotateInferenceDeviceExclusions(mergeInferenceDevices(probed, stored), resolveInferenceDeviceEligibility(probed, stored, canRunRoot, (deviceKey) => this.inferenceDeviceUsability.isUsable(nodeId, deviceKey))).map((row) => !reachable && row.presence === "absent" ? {
|
|
135144
|
+
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, this.absentReasonFor(nodeId))).map((row) => !reachable && row.presence === "absent" ? {
|
|
134290
135145
|
...row,
|
|
134291
135146
|
presence: "unknown"
|
|
134292
135147
|
} : row)
|
|
@@ -134361,6 +135216,7 @@ var PipelineOrchestratorAddon = class PipelineOrchestratorAddon extends BaseAddo
|
|
|
134361
135216
|
* again, not elected against the list it left with.
|
|
134362
135217
|
*/
|
|
134363
135218
|
forgetInferenceDeviceProbe(nodeId) {
|
|
135219
|
+
this.absentInferenceDevices.delete(nodeId);
|
|
134364
135220
|
if (!this.lastInferenceDeviceProbe.delete(nodeId)) return;
|
|
134365
135221
|
this.ctx.logger.info("inference device probe forgotten — the node left", {
|
|
134366
135222
|
tags: { nodeId },
|
|
@@ -134446,7 +135302,8 @@ var PipelineOrchestratorAddon = class PipelineOrchestratorAddon extends BaseAddo
|
|
|
134446
135302
|
});
|
|
134447
135303
|
return;
|
|
134448
135304
|
}
|
|
134449
|
-
this.noteInferenceDeviceHealth(nodeId, poolHealth, probe.probed.map((d) => d.key));
|
|
135305
|
+
this.noteInferenceDeviceHealth(nodeId, poolHealth === null ? null : poolHealth.refused, probe.probed.map((d) => d.key));
|
|
135306
|
+
if (poolHealth !== null) this.noteAbsentInferenceDevices(nodeId, poolHealth.absent);
|
|
134450
135307
|
const previous = this.lastInferenceDeviceProbe.get(nodeId);
|
|
134451
135308
|
this.lastInferenceDeviceProbe.set(nodeId, probe.probed);
|
|
134452
135309
|
if (previous === void 0 || probedDeviceSignature(previous) !== probedDeviceSignature(probe.probed)) {
|
|
@@ -134468,7 +135325,8 @@ var PipelineOrchestratorAddon = class PipelineOrchestratorAddon extends BaseAddo
|
|
|
134468
135325
|
}
|
|
134469
135326
|
/** Eligibility from a device list + catalog; records usability like every dispatch read. */
|
|
134470
135327
|
async electableDevices(nodeId, probed, catalog) {
|
|
134471
|
-
const
|
|
135328
|
+
const node = (await this.settingsStore.readAgentSettingsMap())[nodeId];
|
|
135329
|
+
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, this.absentReasonFor(nodeId));
|
|
134472
135330
|
const { eligible, excluded } = eligibility;
|
|
134473
135331
|
this.logInferenceDeviceShrinkage(nodeId, eligible, excluded);
|
|
134474
135332
|
this.noteNodeInferenceUsability(nodeId, resolveNodeInferenceUsability(eligibility));
|
|
@@ -134550,6 +135408,34 @@ var PipelineOrchestratorAddon = class PipelineOrchestratorAddon extends BaseAddo
|
|
|
134550
135408
|
*/
|
|
134551
135409
|
inferenceDeviceUsability = new InferenceDeviceUsabilityMirror();
|
|
134552
135410
|
/**
|
|
135411
|
+
* Per node, the devices the executor reports the RUNTIME does not enumerate,
|
|
135412
|
+
* with the named reason. Replaced wholesale by each answered health read (an
|
|
135413
|
+
* empty answer clears it — the driver was fixed); a failed read never reaches
|
|
135414
|
+
* it. Read synchronously by the eligibility resolution.
|
|
135415
|
+
*/
|
|
135416
|
+
absentInferenceDevices = /* @__PURE__ */ new Map();
|
|
135417
|
+
absentReasonFor(nodeId) {
|
|
135418
|
+
return (deviceKey) => this.absentInferenceDevices.get(nodeId)?.get(deviceKey) ?? null;
|
|
135419
|
+
}
|
|
135420
|
+
noteAbsentInferenceDevices(nodeId, absent) {
|
|
135421
|
+
const before = this.absentInferenceDevices.get(nodeId);
|
|
135422
|
+
const signature = (m) => [...m ?? []].map(([k, r]) => `${k}=${r}`).toSorted().join(",");
|
|
135423
|
+
if (signature(before) === signature(absent)) return;
|
|
135424
|
+
if (absent.size === 0) this.absentInferenceDevices.delete(nodeId);
|
|
135425
|
+
else this.absentInferenceDevices.set(nodeId, absent);
|
|
135426
|
+
this.ctx.logger.warn("inference devices: the runtime reports devices it does not see", {
|
|
135427
|
+
tags: { nodeId },
|
|
135428
|
+
meta: {
|
|
135429
|
+
nodeId,
|
|
135430
|
+
absent: [...absent].map(([deviceKey, reason]) => ({
|
|
135431
|
+
deviceKey,
|
|
135432
|
+
reason
|
|
135433
|
+
}))
|
|
135434
|
+
}
|
|
135435
|
+
});
|
|
135436
|
+
this.noteShareChange(`devices:${nodeId}`);
|
|
135437
|
+
}
|
|
135438
|
+
/**
|
|
134553
135439
|
* Ask ONE node's detection executor which of its inference devices it is
|
|
134554
135440
|
* currently refusing.
|
|
134555
135441
|
*
|
|
@@ -134565,7 +135451,13 @@ var PipelineOrchestratorAddon = class PipelineOrchestratorAddon extends BaseAddo
|
|
|
134565
135451
|
try {
|
|
134566
135452
|
const api = this.ctx.api;
|
|
134567
135453
|
if (!api) return null;
|
|
134568
|
-
|
|
135454
|
+
const health = await api.pipelineExecutor.getInferenceDeviceHealth.query({ nodeId });
|
|
135455
|
+
const absent = /* @__PURE__ */ new Map();
|
|
135456
|
+
for (const entry of health.unhealthy) if (entry.absentReason !== void 0) absent.set(entry.deviceKey, entry.absentReason);
|
|
135457
|
+
return {
|
|
135458
|
+
refused: health.unhealthy.filter((e) => e.absentReason === void 0).map((e) => e.deviceKey),
|
|
135459
|
+
absent
|
|
135460
|
+
};
|
|
134569
135461
|
} catch (err) {
|
|
134570
135462
|
this.ctx.logger.warn("inference device health read failed — mirror left unchanged", {
|
|
134571
135463
|
tags: { nodeId },
|
|
@@ -134909,7 +135801,7 @@ var PipelineOrchestratorAddon = class PipelineOrchestratorAddon extends BaseAddo
|
|
|
134909
135801
|
topologySignature: async () => {
|
|
134910
135802
|
const nodeIds = [...new Set(["hub", ...this.topology.collectRunnerNodeIds()])];
|
|
134911
135803
|
const blob = await store.readAgentSettingsMap();
|
|
134912
|
-
return shareTopologySignature(nodeIds, blob, this.liveDevicesByNode(nodeIds, blob));
|
|
135804
|
+
return shareTopologySignature(nodeIds, blob, this.liveDevicesByNode(nodeIds, blob, await store.readClusterStepModes()));
|
|
134913
135805
|
},
|
|
134914
135806
|
logger: this.ctx.logger
|
|
134915
135807
|
});
|
|
@@ -134922,14 +135814,14 @@ var PipelineOrchestratorAddon = class PipelineOrchestratorAddon extends BaseAddo
|
|
|
134922
135814
|
* call: a node never probed contributes nothing, and the probe that first
|
|
134923
135815
|
* answers announces itself through {@link noteInferenceDeviceProbe}.
|
|
134924
135816
|
*/
|
|
134925
|
-
liveDevicesByNode(nodeIds, blob) {
|
|
135817
|
+
liveDevicesByNode(nodeIds, blob, clusterModes) {
|
|
134926
135818
|
const out = {};
|
|
134927
135819
|
for (const nodeId of nodeIds) {
|
|
134928
135820
|
const probed = this.lastInferenceDeviceProbe.get(nodeId);
|
|
134929
135821
|
if (probed === void 0) continue;
|
|
134930
135822
|
const stored = blob[nodeId]?.inferenceDevices ?? {};
|
|
134931
135823
|
const catalog = this.settingsStore.peekCatalogForAgent(nodeId);
|
|
134932
|
-
const eligibility = resolveInferenceDeviceEligibility(probed, stored, catalog ? makeRootCapabilityGuard(catalog) : void 0, (deviceKey) => this.inferenceDeviceUsability.isUsable(nodeId, deviceKey));
|
|
135824
|
+
const eligibility = resolveInferenceDeviceEligibility(probed, stored, catalog ? makeRootCapabilityGuard(catalog) : void 0, (deviceKey) => this.inferenceDeviceUsability.isUsable(nodeId, deviceKey), catalog ? makeRootSwitchGuard(catalog, clusterModes, blob[nodeId]) : void 0, this.absentReasonFor(nodeId));
|
|
134933
135825
|
out[nodeId] = annotateInferenceDeviceExclusions(mergeInferenceDevices(probed, stored), eligibility).map((d) => ({
|
|
134934
135826
|
key: d.key,
|
|
134935
135827
|
available: d.available,
|
|
@@ -135046,7 +135938,7 @@ var PipelineOrchestratorAddon = class PipelineOrchestratorAddon extends BaseAddo
|
|
|
135046
135938
|
readNodes: async () => {
|
|
135047
135939
|
const online = this.topology.collectRunnerNodeIds();
|
|
135048
135940
|
const blob = await this.settingsStore.readAgentSettingsMap();
|
|
135049
|
-
const live = this.liveDevicesByNode(online, blob);
|
|
135941
|
+
const live = this.liveDevicesByNode(online, blob, await this.settingsStore.readClusterStepModes());
|
|
135050
135942
|
return readAutoBenchNodes({
|
|
135051
135943
|
onlineNodeIds: online,
|
|
135052
135944
|
liveDevices: (nodeId) => live[nodeId],
|
|
@@ -135314,7 +136206,95 @@ var PipelineOrchestratorAddon = class PipelineOrchestratorAddon extends BaseAddo
|
|
|
135314
136206
|
return { success: true };
|
|
135315
136207
|
}
|
|
135316
136208
|
async resolvePipeline(input) {
|
|
135317
|
-
|
|
136209
|
+
const nodeId = input.agentNodeId ?? this.placement.getPipelineAssignment({ deviceId: input.deviceId })?.agentNodeId ?? this.localNodeId;
|
|
136210
|
+
const outcome = await this.placement.previewAttachPipeline({
|
|
136211
|
+
deviceId: input.deviceId,
|
|
136212
|
+
nodeId
|
|
136213
|
+
});
|
|
136214
|
+
if (outcome.kind === "root-refused") return {
|
|
136215
|
+
steps: [],
|
|
136216
|
+
audio: null
|
|
136217
|
+
};
|
|
136218
|
+
return {
|
|
136219
|
+
steps: outcome.pipeline.steps,
|
|
136220
|
+
audio: outcome.pipeline.audio ?? null
|
|
136221
|
+
};
|
|
136222
|
+
}
|
|
136223
|
+
/** Set one step's cluster mode; `null` returns it to the catalog default. */
|
|
136224
|
+
async setClusterStepMode(input) {
|
|
136225
|
+
await this.settingsStore.writeClusterStepMode(input.stepId, input.mode);
|
|
136226
|
+
this.ctx.logger.info("cluster step mode written", { meta: {
|
|
136227
|
+
stepId: input.stepId,
|
|
136228
|
+
mode: input.mode ?? "default"
|
|
136229
|
+
} });
|
|
136230
|
+
await this.placement.reattachForStepSwitch(null, `cluster:${input.stepId}`);
|
|
136231
|
+
return { success: true };
|
|
136232
|
+
}
|
|
136233
|
+
/** Set one step's node switch; `null` = inherit. */
|
|
136234
|
+
async setNodeStepEnabled(input) {
|
|
136235
|
+
await this.settingsStore.writeNodeStepEnabled(input.agentNodeId, input.stepId, input.enabled);
|
|
136236
|
+
this.ctx.logger.info("node step switch written", {
|
|
136237
|
+
tags: { nodeId: input.agentNodeId },
|
|
136238
|
+
meta: {
|
|
136239
|
+
stepId: input.stepId,
|
|
136240
|
+
enabled: input.enabled ?? "inherit"
|
|
136241
|
+
}
|
|
136242
|
+
});
|
|
136243
|
+
await this.placement.reattachForStepSwitch(input.agentNodeId, `node:${input.stepId}`);
|
|
136244
|
+
return { success: true };
|
|
136245
|
+
}
|
|
136246
|
+
/**
|
|
136247
|
+
* Set one step's device switch; `null` = inherit. Refuses a device the node
|
|
136248
|
+
* does not list (neither probed nor stored) — a switch on a key nothing
|
|
136249
|
+
* dispatches to would be silently inert.
|
|
136250
|
+
*/
|
|
136251
|
+
async setDeviceStepEnabled(input) {
|
|
136252
|
+
const device = (await this.getNodeInferenceDevices({ nodeId: input.agentNodeId })).devices.find((d) => d.key === input.deviceKey);
|
|
136253
|
+
if (device === void 0) throw new Error(`setDeviceStepEnabled: node "${input.agentNodeId}" has no inference device "${input.deviceKey}"`);
|
|
136254
|
+
await this.settingsStore.writeDeviceStepEnabled({
|
|
136255
|
+
nodeId: input.agentNodeId,
|
|
136256
|
+
deviceKey: input.deviceKey,
|
|
136257
|
+
stepId: input.stepId,
|
|
136258
|
+
enabled: input.enabled,
|
|
136259
|
+
deviceEnabled: device.enabled
|
|
136260
|
+
});
|
|
136261
|
+
this.ctx.logger.info("device step switch written", {
|
|
136262
|
+
tags: { nodeId: input.agentNodeId },
|
|
136263
|
+
meta: {
|
|
136264
|
+
deviceKey: input.deviceKey,
|
|
136265
|
+
stepId: input.stepId,
|
|
136266
|
+
enabled: input.enabled ?? "inherit"
|
|
136267
|
+
}
|
|
136268
|
+
});
|
|
136269
|
+
await this.placement.reattachForStepSwitch(input.agentNodeId, `device:${input.stepId}`);
|
|
136270
|
+
return { success: true };
|
|
136271
|
+
}
|
|
136272
|
+
/**
|
|
136273
|
+
* The step switch matrix — cells computed by the attach path's own gate and
|
|
136274
|
+
* placement (`step-switch-matrix.ts`). A node whose catalog or device probe
|
|
136275
|
+
* does not answer is listed `reachable: false` with no cells.
|
|
136276
|
+
*/
|
|
136277
|
+
async getStepSwitches() {
|
|
136278
|
+
const store = this.settingsStore;
|
|
136279
|
+
const [clusterModes, agentMap, cameraMap] = await Promise.all([
|
|
136280
|
+
store.readClusterStepModes(),
|
|
136281
|
+
store.readAgentSettingsMap(),
|
|
136282
|
+
store.readCameraSettingsMap()
|
|
136283
|
+
]);
|
|
136284
|
+
const nodes = await Promise.all(Object.keys(agentMap).toSorted().map(async (nodeId) => {
|
|
136285
|
+
const [catalog, view] = await Promise.all([store.getCatalogForNode(nodeId).catch(() => null), this.getNodeInferenceDevices({ nodeId }).catch(() => null)]);
|
|
136286
|
+
return {
|
|
136287
|
+
nodeId,
|
|
136288
|
+
catalog,
|
|
136289
|
+
devices: view?.reachable === true ? view.devices : null,
|
|
136290
|
+
settings: agentMap[nodeId]
|
|
136291
|
+
};
|
|
136292
|
+
}));
|
|
136293
|
+
return buildStepSwitchMatrix({
|
|
136294
|
+
clusterModes,
|
|
136295
|
+
cameraToggles: Object.values(cameraMap).map((c) => c.stepToggles ?? {}),
|
|
136296
|
+
nodes
|
|
136297
|
+
});
|
|
135318
136298
|
}
|
|
135319
136299
|
/** Emit `pipeline.camera-updated` carrying the freshly-resolved config. */
|
|
135320
136300
|
async emitResolvedCameraUpdated(deviceId) {
|