@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.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,
|
|
@@ -73757,7 +73863,13 @@ var pipelineExecutorCapability = {
|
|
|
73757
73863
|
/** Pool deaths inside the current window. */
|
|
73758
73864
|
deaths: number$1(),
|
|
73759
73865
|
/** The last death's message. */
|
|
73760
|
-
lastError: string()
|
|
73866
|
+
lastError: string(),
|
|
73867
|
+
/**
|
|
73868
|
+
* Present when the device is ABSENT rather than dead: the runtime
|
|
73869
|
+
* itself enumerates no such device (`no-gpu-device` — OpenVINO sees
|
|
73870
|
+
* no supported GPU; driver/runtime does not support this iGPU).
|
|
73871
|
+
*/
|
|
73872
|
+
absentReason: _enum(["no-gpu-device"]).optional()
|
|
73761
73873
|
})).readonly() })),
|
|
73762
73874
|
/**
|
|
73763
73875
|
* Re-arm a terminally `failed` inference device on `nodeId`: forget its
|
|
@@ -75074,7 +75186,15 @@ var RunnerInferenceDeviceSchema = object({
|
|
|
75074
75186
|
* Absent field ⇒ an orchestrator that predates D650: the jumped step keeps
|
|
75075
75187
|
* the elected device's provisioning, as before.
|
|
75076
75188
|
*/
|
|
75077
|
-
steps: record(string(), RunnerJumpStepProvisioningSchema).optional()
|
|
75189
|
+
steps: record(string(), RunnerJumpStepProvisioningSchema).optional(),
|
|
75190
|
+
/**
|
|
75191
|
+
* Steps switched OFF on this device (D1065, `inferenceDevices[key].steps[s]
|
|
75192
|
+
* .enabled === false`). The runner never runs a subtree containing one of
|
|
75193
|
+
* them here: it auto-jumps it to an allowed device, and when none can take
|
|
75194
|
+
* it the subtree is skipped (`disabled-on-device`), never run here anyway.
|
|
75195
|
+
* Absent ⇒ none (an orchestrator that predates D1065).
|
|
75196
|
+
*/
|
|
75197
|
+
disabledSteps: array(string()).readonly().optional()
|
|
75078
75198
|
});
|
|
75079
75199
|
/**
|
|
75080
75200
|
* Camera assignment payload sent by `addon-pipeline-orchestrator` to a
|
|
@@ -81240,7 +81360,15 @@ var DeviceStepConfigSchema = object({
|
|
|
81240
81360
|
* at a disabled/absent device on that node at save time. Absent ⇒ the runner
|
|
81241
81361
|
* auto-jumps only when the effective device's format cannot run the step.
|
|
81242
81362
|
*/
|
|
81243
|
-
jumpDeviceKey: string().optional()
|
|
81363
|
+
jumpDeviceKey: string().optional(),
|
|
81364
|
+
/**
|
|
81365
|
+
* DEVICE switch for this step (D1065). `false` = the step is never
|
|
81366
|
+
* provisioned on this accelerator: a detail step jumps to another enabled
|
|
81367
|
+
* device of the node where it is allowed, else it is skipped with reason
|
|
81368
|
+
* `disabled-on-device`; a root is skipped. Absent = inherit (on). Written by
|
|
81369
|
+
* `setDeviceStepEnabled`.
|
|
81370
|
+
*/
|
|
81371
|
+
enabled: boolean().optional()
|
|
81244
81372
|
});
|
|
81245
81373
|
var AgentPipelineSettingsSchema = object({
|
|
81246
81374
|
maxCameras: number$1().int().nonnegative().nullable().default(null),
|
|
@@ -81284,6 +81412,12 @@ var AgentPipelineSettingsSchema = object({
|
|
|
81284
81412
|
*/
|
|
81285
81413
|
stepSettings: record(string(), record(string(), unknown()).readonly()).optional(),
|
|
81286
81414
|
/**
|
|
81415
|
+
* NODE switch per step (D1065): `stepId → enabled`. `false` = the step never
|
|
81416
|
+
* runs on a camera whose pipeline runs on this node (skip reason
|
|
81417
|
+
* `disabled-on-node`). Absent = inherit. Written by `setNodeStepEnabled`.
|
|
81418
|
+
*/
|
|
81419
|
+
stepEnabled: record(string(), boolean()).optional(),
|
|
81420
|
+
/**
|
|
81287
81421
|
* Multi-device inference opt-in (Phase 4). Per-node map deviceKey → {enabled,
|
|
81288
81422
|
* weight, steps}. Absent / all-disabled ⇒ the node's single default
|
|
81289
81423
|
* accelerator (safe default); two+ enabled ⇒ the dispatcher balances
|
|
@@ -81605,7 +81739,9 @@ var InferenceDeviceExclusionReasonSchema = _enum([
|
|
|
81605
81739
|
"disabled",
|
|
81606
81740
|
"unavailable",
|
|
81607
81741
|
"cannot-host-camera-root",
|
|
81608
|
-
"accelerator-preferred"
|
|
81742
|
+
"accelerator-preferred",
|
|
81743
|
+
"root-switched-off",
|
|
81744
|
+
"no-gpu-device"
|
|
81609
81745
|
]);
|
|
81610
81746
|
var NodeInferenceDeviceSchema = object({
|
|
81611
81747
|
/** Stable per-node device key, e.g. `openvino:npu`, `edgetpu:usb`, `cpu`. */
|
|
@@ -81691,6 +81827,75 @@ var NodeInferenceDevicesSchema = object({
|
|
|
81691
81827
|
devices: array(NodeInferenceDeviceSchema).readonly()
|
|
81692
81828
|
});
|
|
81693
81829
|
/**
|
|
81830
|
+
* The CLUSTER switch of one pipeline step (D1065):
|
|
81831
|
+
* - `off` — hard off: no camera, node or device can turn it on;
|
|
81832
|
+
* - `on` — on by default; a camera may turn it off (`stepToggles`);
|
|
81833
|
+
* - `opt-in` — off by default; a camera turns it on (`stepToggles`).
|
|
81834
|
+
* Absent = the catalog's `enabledByDefault` (`true` → `on`, `false` → `opt-in`).
|
|
81835
|
+
*/
|
|
81836
|
+
var StepClusterModeSchema = _enum([
|
|
81837
|
+
"off",
|
|
81838
|
+
"on",
|
|
81839
|
+
"opt-in"
|
|
81840
|
+
]);
|
|
81841
|
+
/**
|
|
81842
|
+
* What one step does on one (node, device) — computed by the orchestrator with
|
|
81843
|
+
* the SAME placement function the attach path runs (`pipeline-resolver.ts`),
|
|
81844
|
+
* so a client never re-derives it. Precedence: cluster off > camera toggle
|
|
81845
|
+
* (else the cluster default) > node off > device off / jump.
|
|
81846
|
+
*/
|
|
81847
|
+
var StepSwitchCellSchema = discriminatedUnion("kind", [
|
|
81848
|
+
object({ kind: literal("on") }),
|
|
81849
|
+
object({ kind: literal("off-cluster") }),
|
|
81850
|
+
object({ kind: literal("off-node") }),
|
|
81851
|
+
object({ kind: literal("off-device") }),
|
|
81852
|
+
object({
|
|
81853
|
+
kind: literal("jump"),
|
|
81854
|
+
toDeviceKey: string()
|
|
81855
|
+
}),
|
|
81856
|
+
object({
|
|
81857
|
+
kind: literal("skip"),
|
|
81858
|
+
reason: _enum(["no-compatible-model", "root-not-runnable-on-elected-device"])
|
|
81859
|
+
}),
|
|
81860
|
+
object({ kind: literal("zone-driven") }),
|
|
81861
|
+
object({
|
|
81862
|
+
kind: literal("supplied-by-root"),
|
|
81863
|
+
rootModelId: string()
|
|
81864
|
+
}),
|
|
81865
|
+
object({ kind: literal("opt-in-unused") })
|
|
81866
|
+
]);
|
|
81867
|
+
var StepSwitchDeviceSchema = object({
|
|
81868
|
+
deviceKey: string(),
|
|
81869
|
+
format: _enum(MODEL_FORMATS),
|
|
81870
|
+
/** The device switch as stored (`inferenceDevices[key].steps[step].enabled`); `null` = inherit. */
|
|
81871
|
+
stepEnabled: boolean().nullable(),
|
|
81872
|
+
/** Whether the device is in the node's dispatch roster (enabled, available, not excluded). */
|
|
81873
|
+
eligible: boolean(),
|
|
81874
|
+
cell: StepSwitchCellSchema
|
|
81875
|
+
});
|
|
81876
|
+
var StepSwitchNodeSchema = object({
|
|
81877
|
+
nodeId: string(),
|
|
81878
|
+
/** False when the node's catalog or device probe did not answer — no cells are claimed. */
|
|
81879
|
+
reachable: boolean(),
|
|
81880
|
+
/** The node switch as stored (`stepEnabled[step]`); `null` = inherit. */
|
|
81881
|
+
stepEnabled: boolean().nullable(),
|
|
81882
|
+
devices: array(StepSwitchDeviceSchema).readonly()
|
|
81883
|
+
});
|
|
81884
|
+
var StepSwitchMatrixSchema = object({ steps: array(object({
|
|
81885
|
+
stepId: string(),
|
|
81886
|
+
name: string(),
|
|
81887
|
+
slot: string(),
|
|
81888
|
+
/** The stored cluster mode; `null` = the catalog default applies. */
|
|
81889
|
+
clusterMode: StepClusterModeSchema.nullable(),
|
|
81890
|
+
/** The mode in force (stored, else derived from `enabledByDefault`). */
|
|
81891
|
+
effectiveMode: StepClusterModeSchema,
|
|
81892
|
+
/** Cameras whose `stepToggles[step]` is `true`. */
|
|
81893
|
+
camerasEnabling: number$1().int().nonnegative(),
|
|
81894
|
+
/** Cameras whose `stepToggles[step]` is `false`. */
|
|
81895
|
+
camerasDisabling: number$1().int().nonnegative(),
|
|
81896
|
+
nodes: array(StepSwitchNodeSchema).readonly()
|
|
81897
|
+
})).readonly() });
|
|
81898
|
+
/**
|
|
81694
81899
|
* Pipeline Orchestrator capability — global load balancer + camera dispatcher.
|
|
81695
81900
|
*
|
|
81696
81901
|
* Lives on the hub. Tracks the camera-to-agent assignment map, listens to
|
|
@@ -82063,6 +82268,51 @@ var pipelineOrchestratorCapability = {
|
|
|
82063
82268
|
auth: "admin"
|
|
82064
82269
|
}),
|
|
82065
82270
|
/**
|
|
82271
|
+
* Set one step's CLUSTER switch (D1065): `off` | `on` | `opt-in`, or
|
|
82272
|
+
* `null` to return to the catalog default. Re-resolves every placed
|
|
82273
|
+
* camera's pipeline.
|
|
82274
|
+
*/
|
|
82275
|
+
setClusterStepMode: method(object({
|
|
82276
|
+
stepId: string(),
|
|
82277
|
+
mode: StepClusterModeSchema.nullable()
|
|
82278
|
+
}), object({ success: literal(true) }), {
|
|
82279
|
+
kind: "mutation",
|
|
82280
|
+
auth: "admin"
|
|
82281
|
+
}),
|
|
82282
|
+
/**
|
|
82283
|
+
* Set one step's NODE switch (D1065): `false` = the step never runs on a
|
|
82284
|
+
* camera whose pipeline runs on that node; `null` = inherit.
|
|
82285
|
+
*/
|
|
82286
|
+
setNodeStepEnabled: method(object({
|
|
82287
|
+
agentNodeId: string(),
|
|
82288
|
+
stepId: string(),
|
|
82289
|
+
enabled: boolean().nullable()
|
|
82290
|
+
}), object({ success: literal(true) }), {
|
|
82291
|
+
kind: "mutation",
|
|
82292
|
+
auth: "admin"
|
|
82293
|
+
}),
|
|
82294
|
+
/**
|
|
82295
|
+
* Set one step's DEVICE switch (D1065) on `(node, deviceKey)`: `false` =
|
|
82296
|
+
* the step is not provisioned there (a detail step jumps to an allowed
|
|
82297
|
+
* sibling, else is skipped); `null` = inherit.
|
|
82298
|
+
*/
|
|
82299
|
+
setDeviceStepEnabled: method(object({
|
|
82300
|
+
agentNodeId: string(),
|
|
82301
|
+
deviceKey: string(),
|
|
82302
|
+
stepId: string(),
|
|
82303
|
+
enabled: boolean().nullable()
|
|
82304
|
+
}), object({ success: literal(true) }), {
|
|
82305
|
+
kind: "mutation",
|
|
82306
|
+
auth: "admin"
|
|
82307
|
+
}),
|
|
82308
|
+
/**
|
|
82309
|
+
* The step switch matrix (D1065): per step, the cluster mode, how many
|
|
82310
|
+
* cameras turn it on / off, and per node and device the effective cell —
|
|
82311
|
+
* computed by the same placement function the attach path runs. The
|
|
82312
|
+
* inspector renders this; it never derives a cell itself.
|
|
82313
|
+
*/
|
|
82314
|
+
getStepSwitches: method(_void(), StepSwitchMatrixSchema),
|
|
82315
|
+
/**
|
|
82066
82316
|
* DEVICE-AWARE merged view of ONE node's inference accelerators. Joins each
|
|
82067
82317
|
* physical device the node HAS — probed live via a node-pinned
|
|
82068
82318
|
* `platformProbe.getCapabilities` (the platform-probe singleton is targeted
|
|
@@ -92316,7 +92566,7 @@ var WorkloadPortSchema = object({
|
|
|
92316
92566
|
hostIp: string().nullable(),
|
|
92317
92567
|
protocol: WorkloadPortProtocolSchema
|
|
92318
92568
|
});
|
|
92319
|
-
object({
|
|
92569
|
+
var WorkloadStatusSchema = object({
|
|
92320
92570
|
/** null = unknown, never stopped (D393). */
|
|
92321
92571
|
state: WorkloadStateSchema.nullable().meta({ label: "State" }),
|
|
92322
92572
|
/** Epoch ms the current state began (uptime while running); null when unknown. */
|
|
@@ -93770,23 +94020,56 @@ var fountainContribution = contribution("pet-fountain", PetFountainStatusSchema,
|
|
|
93770
94020
|
};
|
|
93771
94021
|
});
|
|
93772
94022
|
var minutesOf = (seconds) => Math.max(0, Math.round(seconds / 60));
|
|
94023
|
+
var pumpCycleContribution = contribution("pump-cycle", PumpCycleStatusSchema, (slice) => {
|
|
94024
|
+
const enabled = slice?.enabled ?? null;
|
|
94025
|
+
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;
|
|
94026
|
+
return { rows: [row$1("pump-cycle", "timer", enabled === null ? unknownText : enabled ? joinText([t("Cycling", "A cicli"), cycle]) : t("Runs continuously", "Sempre attiva"), [{
|
|
94027
|
+
kind: "toggle",
|
|
94028
|
+
id: "pump-cycle.enabled",
|
|
94029
|
+
label: t("Pump cycle", "Ciclo pompa"),
|
|
94030
|
+
on: enabled,
|
|
94031
|
+
turnOn: action("pump-cycle.on", t("Cycle the pump", "Attiva il ciclo"), "timer", "pump-cycle", "setEnabled", { on: true }),
|
|
94032
|
+
turnOff: action("pump-cycle.off", t("Run continuously", "Sempre attiva"), "timer-off", "pump-cycle", "setEnabled", { on: false })
|
|
94033
|
+
}])] };
|
|
94034
|
+
});
|
|
94035
|
+
var WORKLOAD_WORDS = {
|
|
94036
|
+
running: {
|
|
94037
|
+
state: "on",
|
|
94038
|
+
title: t("Running", "In esecuzione")
|
|
94039
|
+
},
|
|
94040
|
+
paused: {
|
|
94041
|
+
state: "standby",
|
|
94042
|
+
title: t("Paused", "In pausa")
|
|
94043
|
+
},
|
|
94044
|
+
stopped: {
|
|
94045
|
+
state: "off",
|
|
94046
|
+
title: t("Stopped", "Fermo")
|
|
94047
|
+
},
|
|
94048
|
+
starting: {
|
|
94049
|
+
state: "running",
|
|
94050
|
+
title: t("Starting", "In avvio")
|
|
94051
|
+
},
|
|
94052
|
+
stopping: {
|
|
94053
|
+
state: "running",
|
|
94054
|
+
title: t("Stopping", "In arresto")
|
|
94055
|
+
},
|
|
94056
|
+
crashed: {
|
|
94057
|
+
state: "alert",
|
|
94058
|
+
title: t("Crashed", "Andato in errore")
|
|
94059
|
+
}
|
|
94060
|
+
};
|
|
93773
94061
|
var DEVICES_FAMILY_CONTRIBUTIONS = {
|
|
93774
94062
|
"fan-control": fanContribution,
|
|
93775
94063
|
"vacuum-control": vacuumContribution,
|
|
93776
94064
|
"lawn-mower-control": mowerContribution,
|
|
93777
94065
|
"pet-feeder": feederContribution,
|
|
93778
94066
|
"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
|
-
}])] };
|
|
94067
|
+
"pump-cycle": pumpCycleContribution,
|
|
94068
|
+
workload: contribution("workload", WorkloadStatusSchema, (slice) => {
|
|
94069
|
+
const state = slice?.state ?? null;
|
|
94070
|
+
if (state === null) return { reading: reading("workload", "unknown") };
|
|
94071
|
+
const words = WORKLOAD_WORDS[state];
|
|
94072
|
+
return { reading: reading("workload", words.state, false, words.title) };
|
|
93790
94073
|
})
|
|
93791
94074
|
};
|
|
93792
94075
|
/**
|
|
@@ -102803,6 +103086,13 @@ Object.freeze({
|
|
|
102803
103086
|
access: "view",
|
|
102804
103087
|
role: "admin"
|
|
102805
103088
|
},
|
|
103089
|
+
"pipelineOrchestrator.getStepSwitches": {
|
|
103090
|
+
capName: "pipeline-orchestrator",
|
|
103091
|
+
capScope: "system",
|
|
103092
|
+
addonId: null,
|
|
103093
|
+
access: "view",
|
|
103094
|
+
role: "admin"
|
|
103095
|
+
},
|
|
102806
103096
|
"pipelineOrchestrator.listAgentSettings": {
|
|
102807
103097
|
capName: "pipeline-orchestrator",
|
|
102808
103098
|
capScope: "system",
|
|
@@ -102957,6 +103247,20 @@ Object.freeze({
|
|
|
102957
103247
|
access: "create",
|
|
102958
103248
|
role: "admin"
|
|
102959
103249
|
},
|
|
103250
|
+
"pipelineOrchestrator.setClusterStepMode": {
|
|
103251
|
+
capName: "pipeline-orchestrator",
|
|
103252
|
+
capScope: "system",
|
|
103253
|
+
addonId: null,
|
|
103254
|
+
access: "create",
|
|
103255
|
+
role: "admin"
|
|
103256
|
+
},
|
|
103257
|
+
"pipelineOrchestrator.setDeviceStepEnabled": {
|
|
103258
|
+
capName: "pipeline-orchestrator",
|
|
103259
|
+
capScope: "system",
|
|
103260
|
+
addonId: null,
|
|
103261
|
+
access: "create",
|
|
103262
|
+
role: "admin"
|
|
103263
|
+
},
|
|
102960
103264
|
"pipelineOrchestrator.setLoadBalancingShares": {
|
|
102961
103265
|
capName: "pipeline-orchestrator",
|
|
102962
103266
|
capScope: "system",
|
|
@@ -102964,6 +103268,13 @@ Object.freeze({
|
|
|
102964
103268
|
access: "create",
|
|
102965
103269
|
role: "admin"
|
|
102966
103270
|
},
|
|
103271
|
+
"pipelineOrchestrator.setNodeStepEnabled": {
|
|
103272
|
+
capName: "pipeline-orchestrator",
|
|
103273
|
+
capScope: "system",
|
|
103274
|
+
addonId: null,
|
|
103275
|
+
access: "create",
|
|
103276
|
+
role: "admin"
|
|
103277
|
+
},
|
|
102967
103278
|
"pipelineOrchestrator.setNodeStepSettings": {
|
|
102968
103279
|
capName: "pipeline-orchestrator",
|
|
102969
103280
|
capScope: "system",
|
|
@@ -114931,6 +115242,52 @@ function createDiskReconcileJobRunner(now = Date.now) {
|
|
|
114931
115242
|
};
|
|
114932
115243
|
}
|
|
114933
115244
|
//#endregion
|
|
115245
|
+
//#region src/node-step-settings.ts
|
|
115246
|
+
/**
|
|
115247
|
+
* The provisioning base for `deviceKey` (`''` = the runner's default pool,
|
|
115248
|
+
* which has no device entry and takes the node layer alone). Pure; fresh
|
|
115249
|
+
* objects only.
|
|
115250
|
+
*/
|
|
115251
|
+
function nodeDeviceBase(node, deviceKey) {
|
|
115252
|
+
const own = node?.inferenceDevices?.[deviceKey]?.steps ?? {};
|
|
115253
|
+
const nodeLayer = node?.stepSettings ?? {};
|
|
115254
|
+
const out = {};
|
|
115255
|
+
for (const stepId of new Set([...Object.keys(nodeLayer), ...Object.keys(own)])) {
|
|
115256
|
+
const device = own[stepId];
|
|
115257
|
+
const merged = {
|
|
115258
|
+
...nodeLayer[stepId],
|
|
115259
|
+
...device?.settings
|
|
115260
|
+
};
|
|
115261
|
+
out[stepId] = {
|
|
115262
|
+
...device?.modelId !== void 0 ? { modelId: device.modelId } : {},
|
|
115263
|
+
...device?.jumpDeviceKey !== void 0 ? { jumpDeviceKey: device.jumpDeviceKey } : {},
|
|
115264
|
+
...Object.keys(merged).length > 0 ? { settings: merged } : {}
|
|
115265
|
+
};
|
|
115266
|
+
}
|
|
115267
|
+
return out;
|
|
115268
|
+
}
|
|
115269
|
+
/**
|
|
115270
|
+
* The steps switched OFF on `deviceKey` of this node (D1065):
|
|
115271
|
+
* `inferenceDevices[deviceKey].steps[step].enabled === false`. Only that
|
|
115272
|
+
* device's own entry is read; `''` (the default pool) has none.
|
|
115273
|
+
*/
|
|
115274
|
+
function deviceDisabledSteps(node, deviceKey) {
|
|
115275
|
+
const steps = node?.inferenceDevices?.[deviceKey]?.steps ?? {};
|
|
115276
|
+
return new Set(Object.entries(steps).filter(([, cfg]) => cfg.enabled === false).map(([stepId]) => stepId));
|
|
115277
|
+
}
|
|
115278
|
+
/**
|
|
115279
|
+
* The steps a DEFAULT-POOL attach (no elected device) must not run (D1065):
|
|
115280
|
+
* those switched off on EVERY device the pool may be. The pool is the node's
|
|
115281
|
+
* eligible devices (one eligible device IS the pool, D745); with none
|
|
115282
|
+
* eligible it is any device the node has enabled. A step one of them still
|
|
115283
|
+
* allows is kept — the pool may be that device. No candidate ⇒ nothing.
|
|
115284
|
+
*/
|
|
115285
|
+
function poolDisabledSteps(node, eligibleKeys) {
|
|
115286
|
+
const [first, ...rest] = (eligibleKeys.length > 0 ? eligibleKeys : Object.entries(node?.inferenceDevices ?? {}).filter(([, device]) => device.enabled).map(([key]) => key)).map((key) => deviceDisabledSteps(node, key));
|
|
115287
|
+
if (first === void 0) return /* @__PURE__ */ new Set();
|
|
115288
|
+
return new Set([...first].filter((stepId) => rest.every((steps) => steps.has(stepId))));
|
|
115289
|
+
}
|
|
115290
|
+
//#endregion
|
|
114934
115291
|
//#region src/pipeline-resolver.ts
|
|
114935
115292
|
/**
|
|
114936
115293
|
* The `package-detection` root step id. Zone-driven activation
|
|
@@ -115007,38 +115364,86 @@ function addonHasCompatibleModel(addon, format) {
|
|
|
115007
115364
|
function isVideoRoot(addon) {
|
|
115008
115365
|
return (addon.inputClasses ?? []).length === 0;
|
|
115009
115366
|
}
|
|
115010
|
-
/**
|
|
115011
|
-
|
|
115012
|
-
|
|
115013
|
-
|
|
115014
|
-
|
|
115015
|
-
|
|
115016
|
-
|
|
115017
|
-
|
|
115018
|
-
|
|
115019
|
-
|
|
115020
|
-
|
|
115021
|
-
|
|
115022
|
-
|
|
115023
|
-
|
|
115024
|
-
|
|
115025
|
-
|
|
115026
|
-
|
|
115027
|
-
|
|
115028
|
-
|
|
115367
|
+
/** The cluster mode a step runs under when none is stored: the catalog default. */
|
|
115368
|
+
function defaultClusterStepMode(addon) {
|
|
115369
|
+
return addon.enabledByDefault === false ? "opt-in" : "on";
|
|
115370
|
+
}
|
|
115371
|
+
/** The cluster mode in force: the stored one, else the catalog default. */
|
|
115372
|
+
function effectiveClusterStepMode(addon, stored) {
|
|
115373
|
+
return stored ?? defaultClusterStepMode(addon);
|
|
115374
|
+
}
|
|
115375
|
+
function gateStep(addon, layers) {
|
|
115376
|
+
const mode = effectiveClusterStepMode(addon, layers.clusterMode);
|
|
115377
|
+
if (mode === "off") return {
|
|
115378
|
+
kind: "off",
|
|
115379
|
+
reason: "disabled-on-cluster"
|
|
115380
|
+
};
|
|
115381
|
+
if (!(layers.cameraToggle ?? mode === "on")) return {
|
|
115382
|
+
kind: "off",
|
|
115383
|
+
reason: "disabled-on-camera"
|
|
115384
|
+
};
|
|
115385
|
+
if (layers.nodeEnabled === false) return {
|
|
115386
|
+
kind: "off",
|
|
115387
|
+
reason: "disabled-on-node"
|
|
115388
|
+
};
|
|
115389
|
+
return { kind: "on" };
|
|
115390
|
+
}
|
|
115391
|
+
function placeStepOnDevices(addon, elected, roster) {
|
|
115392
|
+
if (addon.slot === "audio-classifier") return { kind: "run" };
|
|
115393
|
+
const builds = (slot) => addonHasCompatibleModel(addon, slot.format);
|
|
115394
|
+
const allowed = (slot) => !slot.disabledSteps.has(addon.id);
|
|
115395
|
+
const electedBuild = builds(elected);
|
|
115396
|
+
if (electedBuild && allowed(elected)) return { kind: "run" };
|
|
115397
|
+
if (isVideoRoot(addon)) {
|
|
115398
|
+
if (!allowed(elected)) return {
|
|
115399
|
+
kind: "skip",
|
|
115400
|
+
reason: "disabled-on-device"
|
|
115401
|
+
};
|
|
115402
|
+
return roster.some(builds) ? {
|
|
115403
|
+
kind: "skip",
|
|
115404
|
+
reason: "root-not-runnable-on-elected-device"
|
|
115405
|
+
} : {
|
|
115406
|
+
kind: "skip",
|
|
115407
|
+
reason: "no-compatible-model"
|
|
115408
|
+
};
|
|
115409
|
+
}
|
|
115410
|
+
const first = roster.filter((slot) => builds(slot) && allowed(slot)).toSorted((a, b) => slotOrderKey(a).localeCompare(slotOrderKey(b)))[0];
|
|
115411
|
+
if (first !== void 0) return {
|
|
115412
|
+
kind: "jump",
|
|
115413
|
+
toDeviceKey: first.deviceKey
|
|
115414
|
+
};
|
|
115415
|
+
return {
|
|
115416
|
+
kind: "skip",
|
|
115417
|
+
reason: electedBuild && !allowed(elected) || roster.some(builds) ? "disabled-on-device" : "no-compatible-model"
|
|
115418
|
+
};
|
|
115419
|
+
}
|
|
115420
|
+
function slotOrderKey(slot) {
|
|
115421
|
+
return slot.deviceKey ?? slot.format;
|
|
115422
|
+
}
|
|
115423
|
+
var NO_STEPS = /* @__PURE__ */ new Set();
|
|
115424
|
+
/** The gate layers of `addonId` read from a switch context (absent entries stay absent). */
|
|
115425
|
+
function gateLayersOf(addonId, switches) {
|
|
115426
|
+
const clusterMode = switches.clusterModes?.[addonId];
|
|
115427
|
+
const nodeEnabled = switches.nodeStepEnabled?.[addonId];
|
|
115428
|
+
return {
|
|
115429
|
+
...clusterMode !== void 0 ? { clusterMode } : {},
|
|
115430
|
+
...nodeEnabled !== void 0 ? { nodeEnabled } : {}
|
|
115431
|
+
};
|
|
115029
115432
|
}
|
|
115030
115433
|
/**
|
|
115031
115434
|
* Device-aware resolver — the SINGLE per-camera gate + per-DEVICE skip check.
|
|
115032
115435
|
*
|
|
115033
115436
|
* Step `S` runs for camera `C` on device `D` ⇔
|
|
115034
|
-
* gate(C, S)
|
|
115035
|
-
*
|
|
115437
|
+
* gate(C, N, S) — {@link gateStep}: cluster not off, the camera toggle
|
|
115438
|
+
* (else the cluster default), the node switch (D1065)
|
|
115439
|
+
* AND provided(D, S) — {@link placeStepOnDevices}: a device not switched off
|
|
115440
|
+
* for S has a build of it — the catalog lists a model with a build for D's FORMAT
|
|
115036
115441
|
* (a ROOT), or for D's format or any `jumpFormats`
|
|
115037
115442
|
* entry (a detail step — the runner jumps it, D650);
|
|
115038
115443
|
* `audio-classifier` is never format-gated (it runs
|
|
115039
115444
|
* on the audio-analyzer's own backend)
|
|
115040
115445
|
*
|
|
115041
|
-
*
|
|
115446
|
+
* Provisioning
|
|
115042
115447
|
* (`modelId` / `settings`) is NOT applied here — the returned tree carries bare
|
|
115043
115448
|
* `{ addonId, enabled: true, children }` nodes; {@link applyDeviceProvisioning}
|
|
115044
115449
|
* attaches model + settings at dispatch from the per-(node,device) base and the
|
|
@@ -115048,30 +115453,58 @@ function unprovisionedReason(addon, electedFormat, jumpFormats) {
|
|
|
115048
115453
|
* recorded in `skipped` so the caller can surface a visible "gated on, no model
|
|
115049
115454
|
* on this node" status at dispatch time.
|
|
115050
115455
|
*
|
|
115051
|
-
* `package-detection` is excluded
|
|
115052
|
-
* ({@link applyPackageZoneActivation}, applied by the caller)
|
|
115456
|
+
* `package-detection` is excluded from the tree — it is zone-driven
|
|
115457
|
+
* ({@link applyPackageZoneActivation}, applied by the caller); the cluster,
|
|
115458
|
+
* node and elected-device switches still apply, as `packageAllowed` (D1065).
|
|
115053
115459
|
*
|
|
115054
115460
|
* "Inference disabled for this camera" is NOT handled here — the caller
|
|
115055
115461
|
* (resolvePipelineForDevice) consults the detection-pipeline binding and
|
|
115056
115462
|
* short-circuits to an empty pipeline before invoking this resolver.
|
|
115057
115463
|
*/
|
|
115058
|
-
function resolvePipelineWithSkips(cameraSettings, deviceFormat, catalog, jumpFormats = []) {
|
|
115464
|
+
function resolvePipelineWithSkips(cameraSettings, deviceFormat, catalog, jumpFormats = [], switches = {}) {
|
|
115059
115465
|
const toggles = (cameraSettings ?? {}).stepToggles ?? {};
|
|
115060
|
-
const
|
|
115466
|
+
const elected = {
|
|
115467
|
+
format: deviceFormat,
|
|
115468
|
+
disabledSteps: switches.electedDisabledSteps ?? NO_STEPS
|
|
115469
|
+
};
|
|
115470
|
+
const roster = switches.jumpTargets ?? jumpFormats.map((format) => ({
|
|
115471
|
+
format,
|
|
115472
|
+
disabledSteps: NO_STEPS
|
|
115473
|
+
}));
|
|
115474
|
+
let packageAllowed = true;
|
|
115061
115475
|
const enabled = [];
|
|
115062
115476
|
const skipped = [];
|
|
115063
115477
|
const droppedRoots = [];
|
|
115064
115478
|
for (const slot of catalog.slots) for (const addon of slot.addons) {
|
|
115065
115479
|
const addonId = addon.id;
|
|
115066
|
-
|
|
115067
|
-
if (
|
|
115068
|
-
|
|
115069
|
-
|
|
115480
|
+
const layers = gateLayersOf(addonId, switches);
|
|
115481
|
+
if (addonId === "package-detection") {
|
|
115482
|
+
packageAllowed = gateStep(addon, {
|
|
115483
|
+
...layers,
|
|
115484
|
+
cameraToggle: true
|
|
115485
|
+
}).kind === "on" && !elected.disabledSteps.has(addonId);
|
|
115486
|
+
continue;
|
|
115487
|
+
}
|
|
115488
|
+
const cameraToggle = toggles[addonId];
|
|
115489
|
+
const gate = gateStep(addon, {
|
|
115490
|
+
...layers,
|
|
115491
|
+
...cameraToggle !== void 0 ? { cameraToggle } : {}
|
|
115492
|
+
});
|
|
115493
|
+
if (gate.kind === "off") {
|
|
115494
|
+
if (gate.reason !== "disabled-on-camera") skipped.push({
|
|
115495
|
+
addonId,
|
|
115496
|
+
reason: gate.reason
|
|
115497
|
+
});
|
|
115498
|
+
continue;
|
|
115499
|
+
}
|
|
115500
|
+
const placement = placeStepOnDevices(addon, elected, roster);
|
|
115501
|
+
if (placement.kind === "skip") {
|
|
115502
|
+
const reason = placement.reason;
|
|
115070
115503
|
skipped.push({
|
|
115071
115504
|
addonId,
|
|
115072
115505
|
reason
|
|
115073
115506
|
});
|
|
115074
|
-
if (addonId === "object-detection") droppedRoots.push(addonId);
|
|
115507
|
+
if (addonId === "object-detection" && reason !== "disabled-on-device") droppedRoots.push(addonId);
|
|
115075
115508
|
continue;
|
|
115076
115509
|
}
|
|
115077
115510
|
enabled.push({ addonId });
|
|
@@ -115090,7 +115523,8 @@ function resolvePipelineWithSkips(cameraSettings, deviceFormat, catalog, jumpFor
|
|
|
115090
115523
|
audio: audioAddons.length > 0 ? { enabled: true } : null
|
|
115091
115524
|
},
|
|
115092
115525
|
skipped,
|
|
115093
|
-
droppedRoots
|
|
115526
|
+
droppedRoots,
|
|
115527
|
+
packageAllowed
|
|
115094
115528
|
};
|
|
115095
115529
|
}
|
|
115096
115530
|
function findInCatalog(catalog, addonId) {
|
|
@@ -115194,6 +115628,29 @@ function makeRootCapabilityGuard(catalog) {
|
|
|
115194
115628
|
}
|
|
115195
115629
|
return () => true;
|
|
115196
115630
|
}
|
|
115631
|
+
/**
|
|
115632
|
+
* The camera-root SWITCH predicate for a node: `deviceKey → is the root on`.
|
|
115633
|
+
* The root ({@link OBJECT_DETECTION_STEP_ID}) is judged by the same
|
|
115634
|
+
* {@link gateStep} the attach path runs — cluster mode, then the node switch —
|
|
115635
|
+
* and then by the device's own step switch (D1065). The camera toggle is not a
|
|
115636
|
+
* layer here: the election picks a device for every camera of the node, and a
|
|
115637
|
+
* camera that turned its root off is refused by the attach itself.
|
|
115638
|
+
*
|
|
115639
|
+
* Fails OPEN when the catalog has no object-detection slot, like
|
|
115640
|
+
* {@link makeRootCapabilityGuard}. Pure.
|
|
115641
|
+
*/
|
|
115642
|
+
function makeRootSwitchGuard(catalog, clusterModes, node) {
|
|
115643
|
+
const root = catalog.slots.flatMap((slot) => slot.addons).find((a) => a.id === OBJECT_DETECTION_STEP_ID);
|
|
115644
|
+
if (root === void 0) return () => true;
|
|
115645
|
+
const clusterMode = clusterModes[OBJECT_DETECTION_STEP_ID];
|
|
115646
|
+
const nodeEnabled = node?.stepEnabled?.[OBJECT_DETECTION_STEP_ID];
|
|
115647
|
+
if (gateStep(root, {
|
|
115648
|
+
...clusterMode !== void 0 ? { clusterMode } : {},
|
|
115649
|
+
...nodeEnabled !== void 0 ? { nodeEnabled } : {},
|
|
115650
|
+
cameraToggle: true
|
|
115651
|
+
}).kind === "off") return () => false;
|
|
115652
|
+
return (deviceKey) => !deviceDisabledSteps(node, deviceKey).has(OBJECT_DETECTION_STEP_ID);
|
|
115653
|
+
}
|
|
115197
115654
|
/** Split a deviceKey (`<backend>:<device>`, or bare `cpu`) into its parts + format.
|
|
115198
115655
|
* Format comes from the shared {@link deviceBackendToFormat} SSOT (`@camstack/types`)
|
|
115199
115656
|
* — the previously-local `BACKEND_FORMAT` copy is gone (R3/node-F2). Used only for
|
|
@@ -115321,11 +115778,11 @@ function inferenceDeviceCaps(stored) {
|
|
|
115321
115778
|
function isCpuFallback(view) {
|
|
115322
115779
|
return view.backend === "cpu";
|
|
115323
115780
|
}
|
|
115324
|
-
function resolveInferenceDeviceEligibility(probed, stored, canRunRoot, isPoolUsable) {
|
|
115781
|
+
function resolveInferenceDeviceEligibility(probed, stored, canRunRoot, isPoolUsable, isRootSwitchedOn, absentReason) {
|
|
115325
115782
|
const eligible = {};
|
|
115326
115783
|
const excluded = [];
|
|
115327
115784
|
const merged = mergeInferenceDevices(probed, stored);
|
|
115328
|
-
const acceleratorServes = merged.some((d) => !isCpuFallback(d) && d.enabled && d.available && (!canRunRoot || canRunRoot(d.format)));
|
|
115785
|
+
const acceleratorServes = merged.some((d) => !isCpuFallback(d) && d.enabled && d.available && (absentReason?.(d.key) ?? null) === null && (!canRunRoot || canRunRoot(d.format)) && (!isRootSwitchedOn || isRootSwitchedOn(d.key)));
|
|
115329
115786
|
for (const d of merged) {
|
|
115330
115787
|
if (!d.enabled) {
|
|
115331
115788
|
excluded.push({
|
|
@@ -115343,6 +115800,15 @@ function resolveInferenceDeviceEligibility(probed, stored, canRunRoot, isPoolUsa
|
|
|
115343
115800
|
});
|
|
115344
115801
|
continue;
|
|
115345
115802
|
}
|
|
115803
|
+
const absent = absentReason?.(d.key) ?? null;
|
|
115804
|
+
if (absent !== null) {
|
|
115805
|
+
excluded.push({
|
|
115806
|
+
key: d.key,
|
|
115807
|
+
reason: absent,
|
|
115808
|
+
format: d.format
|
|
115809
|
+
});
|
|
115810
|
+
continue;
|
|
115811
|
+
}
|
|
115346
115812
|
if (isPoolUsable && !isPoolUsable(d.key)) {
|
|
115347
115813
|
excluded.push({
|
|
115348
115814
|
key: d.key,
|
|
@@ -115359,6 +115825,14 @@ function resolveInferenceDeviceEligibility(probed, stored, canRunRoot, isPoolUsa
|
|
|
115359
115825
|
});
|
|
115360
115826
|
continue;
|
|
115361
115827
|
}
|
|
115828
|
+
if (isRootSwitchedOn && !isRootSwitchedOn(d.key)) {
|
|
115829
|
+
excluded.push({
|
|
115830
|
+
key: d.key,
|
|
115831
|
+
reason: "root-switched-off",
|
|
115832
|
+
format: d.format
|
|
115833
|
+
});
|
|
115834
|
+
continue;
|
|
115835
|
+
}
|
|
115362
115836
|
if (isCpuFallback(d) && acceleratorServes) {
|
|
115363
115837
|
excluded.push({
|
|
115364
115838
|
key: d.key,
|
|
@@ -121784,10 +122258,14 @@ function pickInferenceDevice(input) {
|
|
|
121784
122258
|
eligibleKeys
|
|
121785
122259
|
};
|
|
121786
122260
|
const pin = input.pinnedDeviceKey ?? null;
|
|
121787
|
-
|
|
121788
|
-
|
|
121789
|
-
|
|
121790
|
-
|
|
122261
|
+
const sole = eligibleKeys.length === 1 ? eligibleKeys[0] : void 0;
|
|
122262
|
+
if (sole !== void 0 && !pin) return {
|
|
122263
|
+
kind: "selected",
|
|
122264
|
+
deviceKey: sole,
|
|
122265
|
+
reason: "sole-eligible",
|
|
122266
|
+
tieBreak: null,
|
|
122267
|
+
eligibleKeys,
|
|
122268
|
+
tiedKeys: eligibleKeys
|
|
121791
122269
|
};
|
|
121792
122270
|
const loadByKey = new Map((input.loads ?? []).map((l) => [l.deviceKey, l]));
|
|
121793
122271
|
const healthyKeys = eligibleKeys.filter((k) => !isDeviceSaturated(loadByKey.get(k)));
|
|
@@ -122339,7 +122817,7 @@ async function resolveAttachPipeline(input, store) {
|
|
|
122339
122817
|
eligible: input.eligible,
|
|
122340
122818
|
caps: input.caps
|
|
122341
122819
|
});
|
|
122342
|
-
const resolved = await store.resolvePipelineForDeviceWithRoots(input.deviceId, input.nodeId, input.deviceKey, jumpTargetKeys(roster, input.deviceKey));
|
|
122820
|
+
const resolved = await store.resolvePipelineForDeviceWithRoots(input.deviceId, input.nodeId, input.deviceKey, jumpTargetKeys(roster, input.deviceKey), defaultPoolOf(input));
|
|
122343
122821
|
if (resolved.droppedRoots.length > 0) return rootRefusal(input, resolved.droppedRoots);
|
|
122344
122822
|
return {
|
|
122345
122823
|
kind: "resolved",
|
|
@@ -122360,7 +122838,7 @@ async function resolveAttachPipelineIfCatalogCached(input, store) {
|
|
|
122360
122838
|
eligible: input.eligible,
|
|
122361
122839
|
caps: input.caps
|
|
122362
122840
|
});
|
|
122363
|
-
const outcome = await store.resolvePipelineForDeviceIfCatalogCached(input.deviceId, input.nodeId, input.deviceKey, jumpTargetKeys(roster, input.deviceKey));
|
|
122841
|
+
const outcome = await store.resolvePipelineForDeviceIfCatalogCached(input.deviceId, input.nodeId, input.deviceKey, jumpTargetKeys(roster, input.deviceKey), defaultPoolOf(input));
|
|
122364
122842
|
if (outcome.kind === "catalog-unavailable") return outcome;
|
|
122365
122843
|
if (outcome.droppedRoots.length > 0) return rootRefusal(input, outcome.droppedRoots);
|
|
122366
122844
|
return {
|
|
@@ -122368,6 +122846,10 @@ async function resolveAttachPipelineIfCatalogCached(input, store) {
|
|
|
122368
122846
|
pipeline: await provisionAttachPipeline(input, roster, outcome.config, store)
|
|
122369
122847
|
};
|
|
122370
122848
|
}
|
|
122849
|
+
/** No elected device ⇒ the runner's default pool, made of the eligible devices (D1065). */
|
|
122850
|
+
function defaultPoolOf(input) {
|
|
122851
|
+
return input.deviceKey === void 0 ? { eligibleKeys: Object.keys(input.eligible) } : void 0;
|
|
122852
|
+
}
|
|
122371
122853
|
function rootRefusal(input, droppedRoots) {
|
|
122372
122854
|
return {
|
|
122373
122855
|
kind: "root-refused",
|
|
@@ -122379,9 +122861,10 @@ function rootRefusal(input, droppedRoots) {
|
|
|
122379
122861
|
/**
|
|
122380
122862
|
* Whose provisioning an attach applies. The elected device when there is one.
|
|
122381
122863
|
* With NO elected device the runner's default pool serves the camera; when the
|
|
122382
|
-
* node has exactly one eligible device
|
|
122383
|
-
*
|
|
122384
|
-
*
|
|
122864
|
+
* node has exactly one eligible device (a Mac's `coreml:all`, an N100 with only
|
|
122865
|
+
* its iGPU on) that default pool IS that device. The balancer now elects such a
|
|
122866
|
+
* device itself (`sole-eligible`), so this branch serves a default-pool
|
|
122867
|
+
* dispatch on a one-device node; its model pin and the
|
|
122385
122868
|
* camera's override stored under its key apply (D745 — before, the empty key
|
|
122386
122869
|
* was read, which no store writes, and the pin was silently never run).
|
|
122387
122870
|
* Otherwise `''`: the node's folded settings with no hardware fields.
|
|
@@ -122401,9 +122884,11 @@ async function provisionAttachPipeline(input, roster, resolved, store) {
|
|
|
122401
122884
|
const steps = applyDeviceProvisioning(resolved.steps, elected?.base ?? {}, elected?.override ?? {});
|
|
122402
122885
|
const inferenceDevices = roster?.map((entry) => {
|
|
122403
122886
|
const src = sources.get(entry.deviceKey);
|
|
122887
|
+
const disabledSteps = src?.disabledSteps ?? [];
|
|
122404
122888
|
return {
|
|
122405
122889
|
...entry,
|
|
122406
|
-
steps: provisionDeviceSteps(resolved.steps, src?.base ?? {}, src?.override ?? {})
|
|
122890
|
+
steps: provisionDeviceSteps(resolved.steps, src?.base ?? {}, src?.override ?? {}),
|
|
122891
|
+
...disabledSteps.length > 0 ? { disabledSteps } : {}
|
|
122407
122892
|
};
|
|
122408
122893
|
});
|
|
122409
122894
|
return {
|
|
@@ -122870,6 +123355,26 @@ var PlacementService = class {
|
|
|
122870
123355
|
}, this.deps.settingsStore);
|
|
122871
123356
|
}
|
|
122872
123357
|
/**
|
|
123358
|
+
* What an attach of `deviceId` on `nodeId` WOULD run — the `resolvePipeline`
|
|
123359
|
+
* preview. Same owner as a dispatch ({@link resolveAttachPipeline}), on the
|
|
123360
|
+
* device the camera is elected onto when it is placed on that node; for a
|
|
123361
|
+
* camera placed elsewhere (or nowhere), on the node's highest-weight eligible
|
|
123362
|
+
* device (ties by key), or the default pool when it has none. Before, the
|
|
123363
|
+
* preview resolved on the node's default format with no jump roster, and
|
|
123364
|
+
* reported the detail steps a sibling accelerator runs as dropped.
|
|
123365
|
+
*/
|
|
123366
|
+
async previewAttachPipeline(input) {
|
|
123367
|
+
const [eligible, caps] = await Promise.all([this.deps.getEligibleInferenceDevices(input.nodeId), this.deps.getInferenceDeviceCaps(input.nodeId)]);
|
|
123368
|
+
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];
|
|
123369
|
+
return resolveAttachPipeline({
|
|
123370
|
+
deviceId: input.deviceId,
|
|
123371
|
+
nodeId: input.nodeId,
|
|
123372
|
+
deviceKey,
|
|
123373
|
+
eligible,
|
|
123374
|
+
caps
|
|
123375
|
+
}, this.deps.settingsStore);
|
|
123376
|
+
}
|
|
123377
|
+
/**
|
|
122873
123378
|
* FIRST placement of a standing camera: waits for the chosen node's catalog
|
|
122874
123379
|
* (the resolve reconciles against its executor until it answers). Callers:
|
|
122875
123380
|
* `startDetection`'s standing path — one camera, nothing to attach instead.
|
|
@@ -123419,6 +123924,129 @@ var PlacementService = class {
|
|
|
123419
123924
|
for (const deviceId of affected) await this.deps.emitResolvedCameraUpdated(deviceId);
|
|
123420
123925
|
}
|
|
123421
123926
|
/**
|
|
123927
|
+
* A step switch changed (D1065): re-resolve the attach pipeline of every
|
|
123928
|
+
* placed camera — on `nodeId`, or on every node when `null` (a cluster
|
|
123929
|
+
* switch) — on the device it is already elected onto, through the one owner
|
|
123930
|
+
* of an attach's steps ({@link resolveAttachPipelineOnDevice}). Only a camera
|
|
123931
|
+
* whose resolved steps, audio, device or roster DIFFERS from its cached
|
|
123932
|
+
* attach is re-attached; the rest are left running untouched. A camera whose
|
|
123933
|
+
* root (`object-detection`) the switch took away from its elected device is
|
|
123934
|
+
* RE-ELECTED through the normal placement path ({@link reelectAfterRootSwitch}),
|
|
123935
|
+
* which already excludes a device the root is off on. One camera's failure is
|
|
123936
|
+
* logged and does not stop the sweep; a refused root keeps the live attach.
|
|
123937
|
+
*/
|
|
123938
|
+
async reattachForStepSwitch(nodeId, reason) {
|
|
123939
|
+
const affected = [];
|
|
123940
|
+
for (const [deviceId, assignment] of this.deps.ledger.assignmentEntries()) if (nodeId === null || assignment.agentNodeId === nodeId) affected.push({
|
|
123941
|
+
deviceId,
|
|
123942
|
+
nodeId: assignment.agentNodeId
|
|
123943
|
+
});
|
|
123944
|
+
if (affected.length === 0) return;
|
|
123945
|
+
const logger = this.deps.ctx().logger;
|
|
123946
|
+
let changed = 0;
|
|
123947
|
+
let unchanged = 0;
|
|
123948
|
+
for (const target of affected) {
|
|
123949
|
+
const tags = {
|
|
123950
|
+
deviceId: target.deviceId,
|
|
123951
|
+
nodeId: target.nodeId
|
|
123952
|
+
};
|
|
123953
|
+
const cached = this.deps.ledger.getConfig(target.deviceId);
|
|
123954
|
+
if (!cached) {
|
|
123955
|
+
logger.warn("step switch re-attach skipped — no cached config for a placed camera", {
|
|
123956
|
+
tags,
|
|
123957
|
+
meta: { reason }
|
|
123958
|
+
});
|
|
123959
|
+
unchanged++;
|
|
123960
|
+
continue;
|
|
123961
|
+
}
|
|
123962
|
+
try {
|
|
123963
|
+
const outcome = await this.resolveAttachPipelineOnDevice({
|
|
123964
|
+
deviceId: target.deviceId,
|
|
123965
|
+
nodeId: target.nodeId,
|
|
123966
|
+
deviceKey: cached.deviceKey
|
|
123967
|
+
});
|
|
123968
|
+
if (outcome.kind === "root-refused") {
|
|
123969
|
+
logger.error("step switch re-attach refused — the elected device cannot run the camera root", {
|
|
123970
|
+
tags,
|
|
123971
|
+
meta: {
|
|
123972
|
+
deviceKey: outcome.deviceKey ?? null,
|
|
123973
|
+
droppedRoots: outcome.droppedRoots.join(",")
|
|
123974
|
+
}
|
|
123975
|
+
});
|
|
123976
|
+
unchanged++;
|
|
123977
|
+
continue;
|
|
123978
|
+
}
|
|
123979
|
+
const next = withAttachPipeline(cached, outcome.pipeline);
|
|
123980
|
+
if (hasCameraRoot(cached.steps) && !hasCameraRoot(next.steps)) {
|
|
123981
|
+
await this.reelectAfterRootSwitch(cached, target.nodeId, reason);
|
|
123982
|
+
changed++;
|
|
123983
|
+
continue;
|
|
123984
|
+
}
|
|
123985
|
+
if (sameAttachPipeline(cached, next)) {
|
|
123986
|
+
unchanged++;
|
|
123987
|
+
continue;
|
|
123988
|
+
}
|
|
123989
|
+
this.deps.ledger.setConfig(target.deviceId, next);
|
|
123990
|
+
await this.attachOn(target.nodeId, next);
|
|
123991
|
+
changed++;
|
|
123992
|
+
} catch (err) {
|
|
123993
|
+
logger.warn("step switch re-attach failed", {
|
|
123994
|
+
tags,
|
|
123995
|
+
meta: {
|
|
123996
|
+
reason,
|
|
123997
|
+
error: errMsg$2(err)
|
|
123998
|
+
}
|
|
123999
|
+
});
|
|
124000
|
+
}
|
|
124001
|
+
}
|
|
124002
|
+
logger.info("step switch changed — re-attached the affected cameras", {
|
|
124003
|
+
...nodeId !== null ? { tags: { nodeId } } : {},
|
|
124004
|
+
meta: {
|
|
124005
|
+
reason,
|
|
124006
|
+
changed,
|
|
124007
|
+
unchanged
|
|
124008
|
+
}
|
|
124009
|
+
});
|
|
124010
|
+
}
|
|
124011
|
+
/**
|
|
124012
|
+
* The switch took the camera root away from the device the camera is
|
|
124013
|
+
* elected on. Re-place the camera through the normal path — its election
|
|
124014
|
+
* already excludes a device the root is off on, so it moves to an allowed
|
|
124015
|
+
* device, or the CPU / default pool when one exists. When nothing can host
|
|
124016
|
+
* the root the camera is left as it is and the reason is named: never silent.
|
|
124017
|
+
*/
|
|
124018
|
+
async reelectAfterRootSwitch(cached, nodeId, reason) {
|
|
124019
|
+
const logger = this.deps.ctx().logger;
|
|
124020
|
+
const tags = {
|
|
124021
|
+
deviceId: cached.deviceId,
|
|
124022
|
+
nodeId
|
|
124023
|
+
};
|
|
124024
|
+
const result = await this.redispatchCamera(cached);
|
|
124025
|
+
const placedConfig = this.deps.ledger.getConfig(cached.deviceId);
|
|
124026
|
+
if (result.kind === "assigned" && hasCameraRoot(placedConfig?.steps)) {
|
|
124027
|
+
logger.info("step switch took the camera root off its device — camera re-elected", {
|
|
124028
|
+
tags: {
|
|
124029
|
+
deviceId: cached.deviceId,
|
|
124030
|
+
nodeId: result.agentNodeId
|
|
124031
|
+
},
|
|
124032
|
+
meta: {
|
|
124033
|
+
reason,
|
|
124034
|
+
from: cached.deviceKey ?? "default-pool",
|
|
124035
|
+
to: placedConfig?.deviceKey ?? "default-pool"
|
|
124036
|
+
}
|
|
124037
|
+
});
|
|
124038
|
+
return;
|
|
124039
|
+
}
|
|
124040
|
+
logger.warn("step switch left no device able to host the camera root", {
|
|
124041
|
+
tags,
|
|
124042
|
+
meta: {
|
|
124043
|
+
reason: result.kind === "pending" ? this.deps.ledger.getPendingReason(cached.deviceId) ?? "pending" : "root-switched-off-on-every-eligible-device",
|
|
124044
|
+
switch: reason,
|
|
124045
|
+
deviceKey: cached.deviceKey ?? "default-pool"
|
|
124046
|
+
}
|
|
124047
|
+
});
|
|
124048
|
+
}
|
|
124049
|
+
/**
|
|
123422
124050
|
* Re-dispatch EVERY assigned camera through the REAL attach path
|
|
123423
124051
|
* (`redispatchSingleCamera` → `attachOn`), so each camera's `frameSource`
|
|
123424
124052
|
* (`local-broker` vs `remote-restream` naming the current ingest owner) is
|
|
@@ -123559,6 +124187,14 @@ var PlacementService = class {
|
|
|
123559
124187
|
});
|
|
123560
124188
|
}
|
|
123561
124189
|
};
|
|
124190
|
+
/** Does an attach's step tree carry the camera root (`object-detection`)? */
|
|
124191
|
+
function hasCameraRoot(steps) {
|
|
124192
|
+
return (steps ?? []).some((step) => step.addonId === OBJECT_DETECTION_STEP_ID);
|
|
124193
|
+
}
|
|
124194
|
+
/** Would re-attaching `next` over `current` change anything the runner acts on? */
|
|
124195
|
+
function sameAttachPipeline(current, next) {
|
|
124196
|
+
return isDeepStrictEqual(current.steps, next.steps) && isDeepStrictEqual(current.audio, next.audio) && current.deviceKey === next.deviceKey && isDeepStrictEqual(current.inferenceDevices, next.inferenceDevices);
|
|
124197
|
+
}
|
|
123562
124198
|
//#endregion
|
|
123563
124199
|
//#region src/node-lifecycle-handler.ts
|
|
123564
124200
|
var NodeLifecycleHandler = class {
|
|
@@ -125557,31 +126193,6 @@ async function reattachAfterPackageZoneChange(deps, deviceId) {
|
|
|
125557
126193
|
}
|
|
125558
126194
|
}
|
|
125559
126195
|
//#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
126196
|
//#region src/removed-model-pin-reset.ts
|
|
125586
126197
|
/**
|
|
125587
126198
|
* A stored model pin naming a model DELETED from its step's catalog is reset to
|
|
@@ -125804,7 +126415,8 @@ var AutoBenchmarkAttemptsSchema = record(string(), record(string(), object({
|
|
|
125804
126415
|
var StoredDeviceStepConfigSchema = object({
|
|
125805
126416
|
modelId: string().optional(),
|
|
125806
126417
|
settings: record(string(), unknown()).readonly().optional(),
|
|
125807
|
-
jumpDeviceKey: string().optional()
|
|
126418
|
+
jumpDeviceKey: string().optional(),
|
|
126419
|
+
enabled: boolean().optional()
|
|
125808
126420
|
});
|
|
125809
126421
|
var StoredAgentPipelineSettingsSchema = object({
|
|
125810
126422
|
maxCameras: number$1().int().nonnegative().nullable().default(null),
|
|
@@ -125818,6 +126430,7 @@ var StoredAgentPipelineSettingsSchema = object({
|
|
|
125818
126430
|
reachableHost: string().optional(),
|
|
125819
126431
|
color: NodeColorIdSchema.optional(),
|
|
125820
126432
|
stepSettings: record(string(), record(string(), unknown()).readonly()).optional(),
|
|
126433
|
+
stepEnabled: record(string(), boolean()).optional(),
|
|
125821
126434
|
inferenceDevices: record(string(), object({
|
|
125822
126435
|
enabled: boolean(),
|
|
125823
126436
|
weight: number$1().positive().optional(),
|
|
@@ -125825,6 +126438,7 @@ var StoredAgentPipelineSettingsSchema = object({
|
|
|
125825
126438
|
steps: record(string(), StoredDeviceStepConfigSchema).optional()
|
|
125826
126439
|
})).optional()
|
|
125827
126440
|
});
|
|
126441
|
+
var ClusterStepModesSchema = record(string(), StepClusterModeSchema);
|
|
125828
126442
|
var AgentSettingsMapSchema = record(string(), StoredAgentPipelineSettingsSchema);
|
|
125829
126443
|
var StoredCameraPipelineSettingsSchema = object({
|
|
125830
126444
|
stepToggles: record(string(), boolean()).optional(),
|
|
@@ -125946,6 +126560,12 @@ var DeviceRows = class {
|
|
|
125946
126560
|
//#endregion
|
|
125947
126561
|
//#region src/pipeline-settings-store.ts
|
|
125948
126562
|
var PIPELINE_EXECUTOR_CAP = "pipeline-executor";
|
|
126563
|
+
/** The addon-store key of the cluster step switches (D1065). */
|
|
126564
|
+
var CLUSTER_STEP_MODES_KEY = "clusterStepModes";
|
|
126565
|
+
/** A skip an operator switch caused (D1065), as opposed to a missing build. */
|
|
126566
|
+
function isSwitchSkip(reason) {
|
|
126567
|
+
return reason === "disabled-on-cluster" || reason === "disabled-on-node" || reason === "disabled-on-device";
|
|
126568
|
+
}
|
|
125949
126569
|
var PipelineSettingsStore = class PipelineSettingsStore {
|
|
125950
126570
|
deps;
|
|
125951
126571
|
static CATALOG_CACHE_TTL_MS = 3e4;
|
|
@@ -126139,6 +126759,79 @@ var PipelineSettingsStore = class PipelineSettingsStore {
|
|
|
126139
126759
|
});
|
|
126140
126760
|
});
|
|
126141
126761
|
}
|
|
126762
|
+
clusterStepModesState() {
|
|
126763
|
+
return this.deps.state(CLUSTER_STEP_MODES_KEY, ClusterStepModesSchema, {});
|
|
126764
|
+
}
|
|
126765
|
+
/** The stored cluster step modes, `stepId → mode` (absent step = catalog default). */
|
|
126766
|
+
async readClusterStepModes() {
|
|
126767
|
+
return await this.clusterStepModesState().get();
|
|
126768
|
+
}
|
|
126769
|
+
/** Write one step's cluster mode; `null` removes it (back to the catalog default). */
|
|
126770
|
+
async writeClusterStepMode(stepId, mode) {
|
|
126771
|
+
await this.blobWriteLock.run(CLUSTER_STEP_MODES_KEY, async () => {
|
|
126772
|
+
await this.clusterStepModesState().update((prev) => {
|
|
126773
|
+
const { [stepId]: _drop, ...rest } = prev;
|
|
126774
|
+
return mode === null ? rest : {
|
|
126775
|
+
...rest,
|
|
126776
|
+
[stepId]: mode
|
|
126777
|
+
};
|
|
126778
|
+
});
|
|
126779
|
+
});
|
|
126780
|
+
}
|
|
126781
|
+
/**
|
|
126782
|
+
* Write one step's NODE switch under the agent-blob lock; `null` removes it
|
|
126783
|
+
* (inherit). An empty map is pruned. Creates the node's entry when absent.
|
|
126784
|
+
*/
|
|
126785
|
+
async writeNodeStepEnabled(nodeId, stepId, enabled) {
|
|
126786
|
+
await this.blobWriteLock.run(PipelineSettingsStore.AGENT_SETTINGS_LOCK_KEY, async () => {
|
|
126787
|
+
const { stepEnabled: prevMap, ...rest } = await this.agentRows.get(nodeId) ?? { maxCameras: null };
|
|
126788
|
+
const { [stepId]: _drop, ...others } = prevMap ?? {};
|
|
126789
|
+
const next = enabled === null ? others : {
|
|
126790
|
+
...others,
|
|
126791
|
+
[stepId]: enabled
|
|
126792
|
+
};
|
|
126793
|
+
await this.agentRows.set(nodeId, {
|
|
126794
|
+
...rest,
|
|
126795
|
+
...Object.keys(next).length > 0 ? { stepEnabled: next } : {}
|
|
126796
|
+
});
|
|
126797
|
+
});
|
|
126798
|
+
}
|
|
126799
|
+
/**
|
|
126800
|
+
* Write one step's DEVICE switch on `(nodeId, deviceKey)` under the
|
|
126801
|
+
* agent-blob lock; `null` removes it (inherit). A step entry left empty is
|
|
126802
|
+
* pruned. A device with no stored entry gets one with `deviceEnabled` — its
|
|
126803
|
+
* current participation, which the caller read from the merged device view,
|
|
126804
|
+
* so writing a step switch never flips whether the device dispatches.
|
|
126805
|
+
*/
|
|
126806
|
+
async writeDeviceStepEnabled(input) {
|
|
126807
|
+
const { nodeId, deviceKey, stepId, enabled } = input;
|
|
126808
|
+
await this.blobWriteLock.run(PipelineSettingsStore.AGENT_SETTINGS_LOCK_KEY, async () => {
|
|
126809
|
+
const existing = await this.agentRows.get(nodeId) ?? { maxCameras: null };
|
|
126810
|
+
const devices = existing.inferenceDevices ?? {};
|
|
126811
|
+
const device = devices[deviceKey] ?? { enabled: input.deviceEnabled };
|
|
126812
|
+
const { [stepId]: prevStep, ...otherSteps } = device.steps ?? {};
|
|
126813
|
+
const { enabled: _drop, ...stepRest } = prevStep ?? {};
|
|
126814
|
+
const nextStep = enabled === null ? stepRest : {
|
|
126815
|
+
...stepRest,
|
|
126816
|
+
enabled
|
|
126817
|
+
};
|
|
126818
|
+
const steps = Object.keys(nextStep).length > 0 ? {
|
|
126819
|
+
...otherSteps,
|
|
126820
|
+
[stepId]: nextStep
|
|
126821
|
+
} : otherSteps;
|
|
126822
|
+
const { steps: _oldSteps, ...deviceRest } = device;
|
|
126823
|
+
await this.agentRows.set(nodeId, {
|
|
126824
|
+
...existing,
|
|
126825
|
+
inferenceDevices: {
|
|
126826
|
+
...devices,
|
|
126827
|
+
[deviceKey]: {
|
|
126828
|
+
...deviceRest,
|
|
126829
|
+
...Object.keys(steps).length > 0 ? { steps } : {}
|
|
126830
|
+
}
|
|
126831
|
+
}
|
|
126832
|
+
});
|
|
126833
|
+
});
|
|
126834
|
+
}
|
|
126142
126835
|
/** Purge one device's row. */
|
|
126143
126836
|
async deleteCameraSettings(deviceId) {
|
|
126144
126837
|
await this.cameraRows.remove(deviceId);
|
|
@@ -126384,8 +127077,8 @@ var PipelineSettingsStore = class PipelineSettingsStore {
|
|
|
126384
127077
|
* cannot run (D650 round 3) — what an attach needs to refuse a camera whose
|
|
126385
127078
|
* own detector would not run. Waits for the catalog exactly as it does.
|
|
126386
127079
|
*/
|
|
126387
|
-
async resolvePipelineForDeviceWithRoots(deviceId, agentNodeId, deviceKey, jumpDeviceKeys) {
|
|
126388
|
-
const outcome = await this.resolvePipelineWithCatalog(deviceId, agentNodeId, deviceKey, jumpDeviceKeys, { kind: "await" });
|
|
127080
|
+
async resolvePipelineForDeviceWithRoots(deviceId, agentNodeId, deviceKey, jumpDeviceKeys, defaultPool) {
|
|
127081
|
+
const outcome = await this.resolvePipelineWithCatalog(deviceId, agentNodeId, deviceKey, jumpDeviceKeys, { kind: "await" }, defaultPool);
|
|
126389
127082
|
if (outcome.kind === "resolved") return outcome;
|
|
126390
127083
|
throw new Error(`PipelineSettingsStore.resolvePipelineForDeviceWithRoots: catalog unavailable for "${outcome.nodeId}"`);
|
|
126391
127084
|
}
|
|
@@ -126398,10 +127091,10 @@ var PipelineSettingsStore = class PipelineSettingsStore {
|
|
|
126398
127091
|
* node; D49: never gate on a fallible read). A cold cache also starts one
|
|
126399
127092
|
* background refresh, so the next retry round finds the catalog.
|
|
126400
127093
|
*/
|
|
126401
|
-
async resolvePipelineForDeviceIfCatalogCached(deviceId, agentNodeId, deviceKey, jumpDeviceKeys) {
|
|
126402
|
-
return this.resolvePipelineWithCatalog(deviceId, agentNodeId, deviceKey, jumpDeviceKeys, { kind: "cached" });
|
|
127094
|
+
async resolvePipelineForDeviceIfCatalogCached(deviceId, agentNodeId, deviceKey, jumpDeviceKeys, defaultPool) {
|
|
127095
|
+
return this.resolvePipelineWithCatalog(deviceId, agentNodeId, deviceKey, jumpDeviceKeys, { kind: "cached" }, defaultPool);
|
|
126403
127096
|
}
|
|
126404
|
-
async resolvePipelineWithCatalog(deviceId, agentNodeIdOverride, deviceKey, jumpDeviceKeys, catalogRead) {
|
|
127097
|
+
async resolvePipelineWithCatalog(deviceId, agentNodeIdOverride, deviceKey, jumpDeviceKeys, catalogRead, defaultPool) {
|
|
126405
127098
|
const agentNodeId = agentNodeIdOverride ?? this.deps.getAssignmentNode(deviceId);
|
|
126406
127099
|
if (!agentNodeId) throw new Error(`PipelineSettingsStore.resolvePipelineForDevice: no node resolvable for device ${deviceId}`);
|
|
126407
127100
|
if (!await this.isDetectionPipelineActive(deviceId)) {
|
|
@@ -126435,14 +127128,39 @@ var PipelineSettingsStore = class PipelineSettingsStore {
|
|
|
126435
127128
|
}
|
|
126436
127129
|
const deviceFormat = deviceKey ? parseDeviceKey(deviceKey).format : catalog.selectedEngine.format;
|
|
126437
127130
|
const jumpFormats = [...new Set(jumpDeviceKeys.map((k) => parseDeviceKey(k).format))];
|
|
126438
|
-
const
|
|
126439
|
-
|
|
127131
|
+
const [clusterModes, node] = await Promise.all([this.readClusterStepModes(), this.agentRows.get(agentNodeId)]);
|
|
127132
|
+
const switches = {
|
|
127133
|
+
clusterModes,
|
|
127134
|
+
...node?.stepEnabled !== void 0 ? { nodeStepEnabled: node.stepEnabled } : {},
|
|
127135
|
+
electedDisabledSteps: deviceKey !== void 0 ? deviceDisabledSteps(node, deviceKey) : defaultPool !== void 0 ? poolDisabledSteps(node, defaultPool.eligibleKeys) : deviceDisabledSteps(node, ""),
|
|
127136
|
+
jumpTargets: jumpDeviceKeys.map((key) => ({
|
|
127137
|
+
deviceKey: key,
|
|
127138
|
+
format: parseDeviceKey(key).format,
|
|
127139
|
+
disabledSteps: deviceDisabledSteps(node, key)
|
|
127140
|
+
}))
|
|
127141
|
+
};
|
|
127142
|
+
const { config: resolvedBase, skipped, droppedRoots, packageAllowed } = resolvePipelineWithSkips(cam, deviceFormat, catalog, jumpFormats, switches);
|
|
127143
|
+
const formatSkips = skipped.filter((s) => !isSwitchSkip(s.reason));
|
|
127144
|
+
const switchSkips = skipped.filter((s) => isSwitchSkip(s.reason));
|
|
127145
|
+
const packageOverruled = hasPackageZone && !packageAllowed;
|
|
127146
|
+
if (switchSkips.length > 0 || packageOverruled) this.deps.logger.info(`pipeline steps switched off — skipped (node ${agentNodeId}, device ${deviceId})`, {
|
|
126440
127147
|
tags: {
|
|
126441
127148
|
deviceId,
|
|
126442
127149
|
nodeId: agentNodeId
|
|
126443
127150
|
},
|
|
126444
127151
|
meta: {
|
|
126445
|
-
skipped:
|
|
127152
|
+
skipped: [...switchSkips.map((s) => `${s.addonId}:${s.reason}`), ...packageOverruled ? [`${PACKAGE_DETECTION_STEP_ID}:switched-off`] : []].join(","),
|
|
127153
|
+
electedDeviceKey: deviceKey ?? null,
|
|
127154
|
+
jumpDeviceKeys: jumpDeviceKeys.join(",")
|
|
127155
|
+
}
|
|
127156
|
+
});
|
|
127157
|
+
if (formatSkips.length > 0) this.deps.logger.warn(`pipeline steps gated on but not provisioned on this node — skipped (node ${agentNodeId}, device ${deviceId})`, {
|
|
127158
|
+
tags: {
|
|
127159
|
+
deviceId,
|
|
127160
|
+
nodeId: agentNodeId
|
|
127161
|
+
},
|
|
127162
|
+
meta: {
|
|
127163
|
+
skipped: formatSkips.map((s) => `${s.addonId}:${s.reason}`).join(","),
|
|
126446
127164
|
electedDeviceKey: deviceKey ?? null,
|
|
126447
127165
|
electedFormat: deviceFormat,
|
|
126448
127166
|
jumpDeviceKeys: jumpDeviceKeys.join(","),
|
|
@@ -126451,7 +127169,7 @@ var PipelineSettingsStore = class PipelineSettingsStore {
|
|
|
126451
127169
|
});
|
|
126452
127170
|
const resolved = {
|
|
126453
127171
|
...resolvedBase,
|
|
126454
|
-
steps: applyPackageZoneActivation(resolvedBase.steps, hasPackageZone)
|
|
127172
|
+
steps: applyPackageZoneActivation(resolvedBase.steps, hasPackageZone && packageAllowed)
|
|
126455
127173
|
};
|
|
126456
127174
|
if (resolved.steps.length === 0) this.deps.logger.info("resolvePipelineForDevice → empty (all steps gated off/unprovisioned)", {
|
|
126457
127175
|
tags: {
|
|
@@ -126633,7 +127351,8 @@ var PipelineSettingsStore = class PipelineSettingsStore {
|
|
|
126633
127351
|
const out = /* @__PURE__ */ new Map();
|
|
126634
127352
|
for (const deviceKey of deviceKeys) out.set(deviceKey, {
|
|
126635
127353
|
base: nodeDeviceBase(node, deviceKey),
|
|
126636
|
-
override: cameraLayer
|
|
127354
|
+
override: cameraLayer,
|
|
127355
|
+
disabledSteps: [...deviceDisabledSteps(node, deviceKey)].toSorted()
|
|
126637
127356
|
});
|
|
126638
127357
|
return out;
|
|
126639
127358
|
}
|
|
@@ -131148,6 +131867,141 @@ async function buildOrchestratorControllers(deps) {
|
|
|
131148
131867
|
};
|
|
131149
131868
|
}
|
|
131150
131869
|
//#endregion
|
|
131870
|
+
//#region src/step-switch-matrix.ts
|
|
131871
|
+
/** ONE cell — the gate, then the placement, in the attach path's order. */
|
|
131872
|
+
function stepSwitchCell(input) {
|
|
131873
|
+
const { addon, elected } = input;
|
|
131874
|
+
const layers = {
|
|
131875
|
+
...input.clusterMode !== void 0 ? { clusterMode: input.clusterMode } : {},
|
|
131876
|
+
...input.nodeEnabled !== void 0 ? { nodeEnabled: input.nodeEnabled } : {}
|
|
131877
|
+
};
|
|
131878
|
+
const mode = effectiveClusterStepMode(addon, input.clusterMode);
|
|
131879
|
+
if (mode === "off") return { kind: "off-cluster" };
|
|
131880
|
+
if (addon.id === "package-detection") {
|
|
131881
|
+
const gate = gateStep(addon, {
|
|
131882
|
+
...layers,
|
|
131883
|
+
cameraToggle: true
|
|
131884
|
+
});
|
|
131885
|
+
if (gate.kind === "off") return gate.reason === "disabled-on-node" ? { kind: "off-node" } : { kind: "off-cluster" };
|
|
131886
|
+
return elected.disabledSteps.has(addon.id) ? { kind: "off-device" } : { kind: "zone-driven" };
|
|
131887
|
+
}
|
|
131888
|
+
if (mode === "opt-in" && input.camerasEnabling === 0) return { kind: "opt-in-unused" };
|
|
131889
|
+
const gate = gateStep(addon, {
|
|
131890
|
+
...layers,
|
|
131891
|
+
cameraToggle: true
|
|
131892
|
+
});
|
|
131893
|
+
if (gate.kind === "off") return gate.reason === "disabled-on-node" ? { kind: "off-node" } : { kind: "off-cluster" };
|
|
131894
|
+
const placement = placeStepOnDevices(addon, elected, input.roster);
|
|
131895
|
+
if (placement.kind === "run") return input.suppliedByRootModelId !== void 0 ? {
|
|
131896
|
+
kind: "supplied-by-root",
|
|
131897
|
+
rootModelId: input.suppliedByRootModelId
|
|
131898
|
+
} : { kind: "on" };
|
|
131899
|
+
if (placement.kind === "jump") return placement.toDeviceKey !== void 0 ? {
|
|
131900
|
+
kind: "jump",
|
|
131901
|
+
toDeviceKey: placement.toDeviceKey
|
|
131902
|
+
} : { kind: "on" };
|
|
131903
|
+
if (placement.reason === "disabled-on-device") return { kind: "off-device" };
|
|
131904
|
+
return {
|
|
131905
|
+
kind: "skip",
|
|
131906
|
+
reason: placement.reason
|
|
131907
|
+
};
|
|
131908
|
+
}
|
|
131909
|
+
/** The catalog's steps across every answering node, first-seen order, by id. */
|
|
131910
|
+
function catalogSteps(nodes) {
|
|
131911
|
+
const seen = /* @__PURE__ */ new Map();
|
|
131912
|
+
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);
|
|
131913
|
+
return [...seen.values()];
|
|
131914
|
+
}
|
|
131915
|
+
function findAddon(catalog, id) {
|
|
131916
|
+
for (const slot of catalog.slots) {
|
|
131917
|
+
const found = slot.addons.find((a) => a.id === id);
|
|
131918
|
+
if (found) return found;
|
|
131919
|
+
}
|
|
131920
|
+
}
|
|
131921
|
+
/**
|
|
131922
|
+
* The root model a device runs: its pin, else the model the executor elects
|
|
131923
|
+
* for the device when the root lists it, else the format default.
|
|
131924
|
+
*/
|
|
131925
|
+
function rootModelOn(root, device) {
|
|
131926
|
+
const pin = device.steps?.[OBJECT_DETECTION_STEP_ID]?.modelId;
|
|
131927
|
+
if (pin !== void 0) return pin;
|
|
131928
|
+
if (root.models.some((m) => m.id === device.defaultModelId)) return device.defaultModelId;
|
|
131929
|
+
return root.defaultModelIdByFormat?.[device.format] ?? root.defaultModelId;
|
|
131930
|
+
}
|
|
131931
|
+
/** The root model id when it supplies `stepId` on `device`, else undefined. */
|
|
131932
|
+
function suppliedByRoot(catalog, stepId, device, settings) {
|
|
131933
|
+
if (!isRootSuppliableStepId(stepId)) return void 0;
|
|
131934
|
+
const root = findAddon(catalog, OBJECT_DETECTION_STEP_ID);
|
|
131935
|
+
if (root === void 0) return void 0;
|
|
131936
|
+
const rootModelId = rootModelOn(root, device);
|
|
131937
|
+
const supplies = root.models.find((m) => m.id === rootModelId)?.suppliesSteps;
|
|
131938
|
+
const stepSettings = nodeDeviceBase(settings, device.key)[stepId]?.settings;
|
|
131939
|
+
return resolveRootSupply(stepId, stepSettings, supplies).effective ? rootModelId : void 0;
|
|
131940
|
+
}
|
|
131941
|
+
function slotOf(device, settings) {
|
|
131942
|
+
return {
|
|
131943
|
+
deviceKey: device.key,
|
|
131944
|
+
format: device.format,
|
|
131945
|
+
disabledSteps: deviceDisabledSteps(settings, device.key)
|
|
131946
|
+
};
|
|
131947
|
+
}
|
|
131948
|
+
function countToggles(toggles, stepId, value) {
|
|
131949
|
+
return toggles.filter((t) => t[stepId] === value).length;
|
|
131950
|
+
}
|
|
131951
|
+
function buildStepSwitchMatrix(input) {
|
|
131952
|
+
return { steps: catalogSteps(input.nodes).map((addon) => {
|
|
131953
|
+
const clusterMode = input.clusterModes[addon.id];
|
|
131954
|
+
const camerasEnabling = countToggles(input.cameraToggles, addon.id, true);
|
|
131955
|
+
const nodes = input.nodes.map((node) => {
|
|
131956
|
+
const nodeEnabled = node.settings?.stepEnabled?.[addon.id];
|
|
131957
|
+
const catalog = node.catalog;
|
|
131958
|
+
const devices = node.devices;
|
|
131959
|
+
const nodeAddon = catalog ? findAddon(catalog, addon.id) : void 0;
|
|
131960
|
+
if (catalog === null || devices === null || nodeAddon === void 0) return {
|
|
131961
|
+
nodeId: node.nodeId,
|
|
131962
|
+
reachable: false,
|
|
131963
|
+
stepEnabled: nodeEnabled ?? null,
|
|
131964
|
+
devices: []
|
|
131965
|
+
};
|
|
131966
|
+
const eligible = devices.filter((d) => d.exclusion === null);
|
|
131967
|
+
return {
|
|
131968
|
+
nodeId: node.nodeId,
|
|
131969
|
+
reachable: true,
|
|
131970
|
+
stepEnabled: nodeEnabled ?? null,
|
|
131971
|
+
devices: devices.map((device) => {
|
|
131972
|
+
const roster = eligible.length >= 2 ? eligible.filter((d) => d.key !== device.key).map((d) => slotOf(d, node.settings)) : [];
|
|
131973
|
+
const supplied = suppliedByRoot(catalog, addon.id, device, node.settings);
|
|
131974
|
+
return {
|
|
131975
|
+
deviceKey: device.key,
|
|
131976
|
+
format: device.format,
|
|
131977
|
+
stepEnabled: device.steps?.[addon.id]?.enabled ?? null,
|
|
131978
|
+
eligible: device.exclusion === null,
|
|
131979
|
+
cell: stepSwitchCell({
|
|
131980
|
+
addon: nodeAddon,
|
|
131981
|
+
clusterMode,
|
|
131982
|
+
camerasEnabling,
|
|
131983
|
+
nodeEnabled,
|
|
131984
|
+
elected: slotOf(device, node.settings),
|
|
131985
|
+
roster,
|
|
131986
|
+
...supplied !== void 0 ? { suppliedByRootModelId: supplied } : {}
|
|
131987
|
+
})
|
|
131988
|
+
};
|
|
131989
|
+
})
|
|
131990
|
+
};
|
|
131991
|
+
});
|
|
131992
|
+
return {
|
|
131993
|
+
stepId: addon.id,
|
|
131994
|
+
name: addon.name,
|
|
131995
|
+
slot: addon.slot,
|
|
131996
|
+
clusterMode: clusterMode ?? null,
|
|
131997
|
+
effectiveMode: effectiveClusterStepMode(addon, clusterMode),
|
|
131998
|
+
camerasEnabling,
|
|
131999
|
+
camerasDisabling: countToggles(input.cameraToggles, addon.id, false),
|
|
132000
|
+
nodes
|
|
132001
|
+
};
|
|
132002
|
+
}) };
|
|
132003
|
+
}
|
|
132004
|
+
//#endregion
|
|
131151
132005
|
//#region src/rebalance-suggestion.ts
|
|
131152
132006
|
var REBALANCE_SUGGESTED_ALERT_ID = "pipeline-orchestrator:rebalance-suggested";
|
|
131153
132007
|
var NODE_NOT_USED_ALERT_PREFIX = "pipeline-orchestrator:node-not-used:";
|
|
@@ -134251,14 +135105,15 @@ var PipelineOrchestratorAddon = class PipelineOrchestratorAddon extends BaseAddo
|
|
|
134251
135105
|
*/
|
|
134252
135106
|
async getNodeInferenceDevices(input) {
|
|
134253
135107
|
const nodeId = input.nodeId;
|
|
134254
|
-
const
|
|
135108
|
+
const node = (await this.settingsStore.readAgentSettingsMap())[nodeId];
|
|
135109
|
+
const stored = node?.inferenceDevices ?? {};
|
|
134255
135110
|
const { probed, reachable } = await this.probeNodeInferenceDevices(nodeId);
|
|
134256
135111
|
const catalog = await this.settingsStore.getCatalogForNode(nodeId);
|
|
134257
135112
|
const canRunRoot = catalog ? makeRootCapabilityGuard(catalog) : void 0;
|
|
134258
135113
|
return {
|
|
134259
135114
|
nodeId,
|
|
134260
135115
|
reachable,
|
|
134261
|
-
devices: annotateInferenceDeviceExclusions(mergeInferenceDevices(probed, stored), resolveInferenceDeviceEligibility(probed, stored, canRunRoot, (deviceKey) => this.inferenceDeviceUsability.isUsable(nodeId, deviceKey))).map((row) => !reachable && row.presence === "absent" ? {
|
|
135116
|
+
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" ? {
|
|
134262
135117
|
...row,
|
|
134263
135118
|
presence: "unknown"
|
|
134264
135119
|
} : row)
|
|
@@ -134333,6 +135188,7 @@ var PipelineOrchestratorAddon = class PipelineOrchestratorAddon extends BaseAddo
|
|
|
134333
135188
|
* again, not elected against the list it left with.
|
|
134334
135189
|
*/
|
|
134335
135190
|
forgetInferenceDeviceProbe(nodeId) {
|
|
135191
|
+
this.absentInferenceDevices.delete(nodeId);
|
|
134336
135192
|
if (!this.lastInferenceDeviceProbe.delete(nodeId)) return;
|
|
134337
135193
|
this.ctx.logger.info("inference device probe forgotten — the node left", {
|
|
134338
135194
|
tags: { nodeId },
|
|
@@ -134418,7 +135274,8 @@ var PipelineOrchestratorAddon = class PipelineOrchestratorAddon extends BaseAddo
|
|
|
134418
135274
|
});
|
|
134419
135275
|
return;
|
|
134420
135276
|
}
|
|
134421
|
-
this.noteInferenceDeviceHealth(nodeId, poolHealth, probe.probed.map((d) => d.key));
|
|
135277
|
+
this.noteInferenceDeviceHealth(nodeId, poolHealth === null ? null : poolHealth.refused, probe.probed.map((d) => d.key));
|
|
135278
|
+
if (poolHealth !== null) this.noteAbsentInferenceDevices(nodeId, poolHealth.absent);
|
|
134422
135279
|
const previous = this.lastInferenceDeviceProbe.get(nodeId);
|
|
134423
135280
|
this.lastInferenceDeviceProbe.set(nodeId, probe.probed);
|
|
134424
135281
|
if (previous === void 0 || probedDeviceSignature(previous) !== probedDeviceSignature(probe.probed)) {
|
|
@@ -134440,7 +135297,8 @@ var PipelineOrchestratorAddon = class PipelineOrchestratorAddon extends BaseAddo
|
|
|
134440
135297
|
}
|
|
134441
135298
|
/** Eligibility from a device list + catalog; records usability like every dispatch read. */
|
|
134442
135299
|
async electableDevices(nodeId, probed, catalog) {
|
|
134443
|
-
const
|
|
135300
|
+
const node = (await this.settingsStore.readAgentSettingsMap())[nodeId];
|
|
135301
|
+
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));
|
|
134444
135302
|
const { eligible, excluded } = eligibility;
|
|
134445
135303
|
this.logInferenceDeviceShrinkage(nodeId, eligible, excluded);
|
|
134446
135304
|
this.noteNodeInferenceUsability(nodeId, resolveNodeInferenceUsability(eligibility));
|
|
@@ -134522,6 +135380,34 @@ var PipelineOrchestratorAddon = class PipelineOrchestratorAddon extends BaseAddo
|
|
|
134522
135380
|
*/
|
|
134523
135381
|
inferenceDeviceUsability = new InferenceDeviceUsabilityMirror();
|
|
134524
135382
|
/**
|
|
135383
|
+
* Per node, the devices the executor reports the RUNTIME does not enumerate,
|
|
135384
|
+
* with the named reason. Replaced wholesale by each answered health read (an
|
|
135385
|
+
* empty answer clears it — the driver was fixed); a failed read never reaches
|
|
135386
|
+
* it. Read synchronously by the eligibility resolution.
|
|
135387
|
+
*/
|
|
135388
|
+
absentInferenceDevices = /* @__PURE__ */ new Map();
|
|
135389
|
+
absentReasonFor(nodeId) {
|
|
135390
|
+
return (deviceKey) => this.absentInferenceDevices.get(nodeId)?.get(deviceKey) ?? null;
|
|
135391
|
+
}
|
|
135392
|
+
noteAbsentInferenceDevices(nodeId, absent) {
|
|
135393
|
+
const before = this.absentInferenceDevices.get(nodeId);
|
|
135394
|
+
const signature = (m) => [...m ?? []].map(([k, r]) => `${k}=${r}`).toSorted().join(",");
|
|
135395
|
+
if (signature(before) === signature(absent)) return;
|
|
135396
|
+
if (absent.size === 0) this.absentInferenceDevices.delete(nodeId);
|
|
135397
|
+
else this.absentInferenceDevices.set(nodeId, absent);
|
|
135398
|
+
this.ctx.logger.warn("inference devices: the runtime reports devices it does not see", {
|
|
135399
|
+
tags: { nodeId },
|
|
135400
|
+
meta: {
|
|
135401
|
+
nodeId,
|
|
135402
|
+
absent: [...absent].map(([deviceKey, reason]) => ({
|
|
135403
|
+
deviceKey,
|
|
135404
|
+
reason
|
|
135405
|
+
}))
|
|
135406
|
+
}
|
|
135407
|
+
});
|
|
135408
|
+
this.noteShareChange(`devices:${nodeId}`);
|
|
135409
|
+
}
|
|
135410
|
+
/**
|
|
134525
135411
|
* Ask ONE node's detection executor which of its inference devices it is
|
|
134526
135412
|
* currently refusing.
|
|
134527
135413
|
*
|
|
@@ -134537,7 +135423,13 @@ var PipelineOrchestratorAddon = class PipelineOrchestratorAddon extends BaseAddo
|
|
|
134537
135423
|
try {
|
|
134538
135424
|
const api = this.ctx.api;
|
|
134539
135425
|
if (!api) return null;
|
|
134540
|
-
|
|
135426
|
+
const health = await api.pipelineExecutor.getInferenceDeviceHealth.query({ nodeId });
|
|
135427
|
+
const absent = /* @__PURE__ */ new Map();
|
|
135428
|
+
for (const entry of health.unhealthy) if (entry.absentReason !== void 0) absent.set(entry.deviceKey, entry.absentReason);
|
|
135429
|
+
return {
|
|
135430
|
+
refused: health.unhealthy.filter((e) => e.absentReason === void 0).map((e) => e.deviceKey),
|
|
135431
|
+
absent
|
|
135432
|
+
};
|
|
134541
135433
|
} catch (err) {
|
|
134542
135434
|
this.ctx.logger.warn("inference device health read failed — mirror left unchanged", {
|
|
134543
135435
|
tags: { nodeId },
|
|
@@ -134881,7 +135773,7 @@ var PipelineOrchestratorAddon = class PipelineOrchestratorAddon extends BaseAddo
|
|
|
134881
135773
|
topologySignature: async () => {
|
|
134882
135774
|
const nodeIds = [...new Set(["hub", ...this.topology.collectRunnerNodeIds()])];
|
|
134883
135775
|
const blob = await store.readAgentSettingsMap();
|
|
134884
|
-
return shareTopologySignature(nodeIds, blob, this.liveDevicesByNode(nodeIds, blob));
|
|
135776
|
+
return shareTopologySignature(nodeIds, blob, this.liveDevicesByNode(nodeIds, blob, await store.readClusterStepModes()));
|
|
134885
135777
|
},
|
|
134886
135778
|
logger: this.ctx.logger
|
|
134887
135779
|
});
|
|
@@ -134894,14 +135786,14 @@ var PipelineOrchestratorAddon = class PipelineOrchestratorAddon extends BaseAddo
|
|
|
134894
135786
|
* call: a node never probed contributes nothing, and the probe that first
|
|
134895
135787
|
* answers announces itself through {@link noteInferenceDeviceProbe}.
|
|
134896
135788
|
*/
|
|
134897
|
-
liveDevicesByNode(nodeIds, blob) {
|
|
135789
|
+
liveDevicesByNode(nodeIds, blob, clusterModes) {
|
|
134898
135790
|
const out = {};
|
|
134899
135791
|
for (const nodeId of nodeIds) {
|
|
134900
135792
|
const probed = this.lastInferenceDeviceProbe.get(nodeId);
|
|
134901
135793
|
if (probed === void 0) continue;
|
|
134902
135794
|
const stored = blob[nodeId]?.inferenceDevices ?? {};
|
|
134903
135795
|
const catalog = this.settingsStore.peekCatalogForAgent(nodeId);
|
|
134904
|
-
const eligibility = resolveInferenceDeviceEligibility(probed, stored, catalog ? makeRootCapabilityGuard(catalog) : void 0, (deviceKey) => this.inferenceDeviceUsability.isUsable(nodeId, deviceKey));
|
|
135796
|
+
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));
|
|
134905
135797
|
out[nodeId] = annotateInferenceDeviceExclusions(mergeInferenceDevices(probed, stored), eligibility).map((d) => ({
|
|
134906
135798
|
key: d.key,
|
|
134907
135799
|
available: d.available,
|
|
@@ -135018,7 +135910,7 @@ var PipelineOrchestratorAddon = class PipelineOrchestratorAddon extends BaseAddo
|
|
|
135018
135910
|
readNodes: async () => {
|
|
135019
135911
|
const online = this.topology.collectRunnerNodeIds();
|
|
135020
135912
|
const blob = await this.settingsStore.readAgentSettingsMap();
|
|
135021
|
-
const live = this.liveDevicesByNode(online, blob);
|
|
135913
|
+
const live = this.liveDevicesByNode(online, blob, await this.settingsStore.readClusterStepModes());
|
|
135022
135914
|
return readAutoBenchNodes({
|
|
135023
135915
|
onlineNodeIds: online,
|
|
135024
135916
|
liveDevices: (nodeId) => live[nodeId],
|
|
@@ -135286,7 +136178,95 @@ var PipelineOrchestratorAddon = class PipelineOrchestratorAddon extends BaseAddo
|
|
|
135286
136178
|
return { success: true };
|
|
135287
136179
|
}
|
|
135288
136180
|
async resolvePipeline(input) {
|
|
135289
|
-
|
|
136181
|
+
const nodeId = input.agentNodeId ?? this.placement.getPipelineAssignment({ deviceId: input.deviceId })?.agentNodeId ?? this.localNodeId;
|
|
136182
|
+
const outcome = await this.placement.previewAttachPipeline({
|
|
136183
|
+
deviceId: input.deviceId,
|
|
136184
|
+
nodeId
|
|
136185
|
+
});
|
|
136186
|
+
if (outcome.kind === "root-refused") return {
|
|
136187
|
+
steps: [],
|
|
136188
|
+
audio: null
|
|
136189
|
+
};
|
|
136190
|
+
return {
|
|
136191
|
+
steps: outcome.pipeline.steps,
|
|
136192
|
+
audio: outcome.pipeline.audio ?? null
|
|
136193
|
+
};
|
|
136194
|
+
}
|
|
136195
|
+
/** Set one step's cluster mode; `null` returns it to the catalog default. */
|
|
136196
|
+
async setClusterStepMode(input) {
|
|
136197
|
+
await this.settingsStore.writeClusterStepMode(input.stepId, input.mode);
|
|
136198
|
+
this.ctx.logger.info("cluster step mode written", { meta: {
|
|
136199
|
+
stepId: input.stepId,
|
|
136200
|
+
mode: input.mode ?? "default"
|
|
136201
|
+
} });
|
|
136202
|
+
await this.placement.reattachForStepSwitch(null, `cluster:${input.stepId}`);
|
|
136203
|
+
return { success: true };
|
|
136204
|
+
}
|
|
136205
|
+
/** Set one step's node switch; `null` = inherit. */
|
|
136206
|
+
async setNodeStepEnabled(input) {
|
|
136207
|
+
await this.settingsStore.writeNodeStepEnabled(input.agentNodeId, input.stepId, input.enabled);
|
|
136208
|
+
this.ctx.logger.info("node step switch written", {
|
|
136209
|
+
tags: { nodeId: input.agentNodeId },
|
|
136210
|
+
meta: {
|
|
136211
|
+
stepId: input.stepId,
|
|
136212
|
+
enabled: input.enabled ?? "inherit"
|
|
136213
|
+
}
|
|
136214
|
+
});
|
|
136215
|
+
await this.placement.reattachForStepSwitch(input.agentNodeId, `node:${input.stepId}`);
|
|
136216
|
+
return { success: true };
|
|
136217
|
+
}
|
|
136218
|
+
/**
|
|
136219
|
+
* Set one step's device switch; `null` = inherit. Refuses a device the node
|
|
136220
|
+
* does not list (neither probed nor stored) — a switch on a key nothing
|
|
136221
|
+
* dispatches to would be silently inert.
|
|
136222
|
+
*/
|
|
136223
|
+
async setDeviceStepEnabled(input) {
|
|
136224
|
+
const device = (await this.getNodeInferenceDevices({ nodeId: input.agentNodeId })).devices.find((d) => d.key === input.deviceKey);
|
|
136225
|
+
if (device === void 0) throw new Error(`setDeviceStepEnabled: node "${input.agentNodeId}" has no inference device "${input.deviceKey}"`);
|
|
136226
|
+
await this.settingsStore.writeDeviceStepEnabled({
|
|
136227
|
+
nodeId: input.agentNodeId,
|
|
136228
|
+
deviceKey: input.deviceKey,
|
|
136229
|
+
stepId: input.stepId,
|
|
136230
|
+
enabled: input.enabled,
|
|
136231
|
+
deviceEnabled: device.enabled
|
|
136232
|
+
});
|
|
136233
|
+
this.ctx.logger.info("device step switch written", {
|
|
136234
|
+
tags: { nodeId: input.agentNodeId },
|
|
136235
|
+
meta: {
|
|
136236
|
+
deviceKey: input.deviceKey,
|
|
136237
|
+
stepId: input.stepId,
|
|
136238
|
+
enabled: input.enabled ?? "inherit"
|
|
136239
|
+
}
|
|
136240
|
+
});
|
|
136241
|
+
await this.placement.reattachForStepSwitch(input.agentNodeId, `device:${input.stepId}`);
|
|
136242
|
+
return { success: true };
|
|
136243
|
+
}
|
|
136244
|
+
/**
|
|
136245
|
+
* The step switch matrix — cells computed by the attach path's own gate and
|
|
136246
|
+
* placement (`step-switch-matrix.ts`). A node whose catalog or device probe
|
|
136247
|
+
* does not answer is listed `reachable: false` with no cells.
|
|
136248
|
+
*/
|
|
136249
|
+
async getStepSwitches() {
|
|
136250
|
+
const store = this.settingsStore;
|
|
136251
|
+
const [clusterModes, agentMap, cameraMap] = await Promise.all([
|
|
136252
|
+
store.readClusterStepModes(),
|
|
136253
|
+
store.readAgentSettingsMap(),
|
|
136254
|
+
store.readCameraSettingsMap()
|
|
136255
|
+
]);
|
|
136256
|
+
const nodes = await Promise.all(Object.keys(agentMap).toSorted().map(async (nodeId) => {
|
|
136257
|
+
const [catalog, view] = await Promise.all([store.getCatalogForNode(nodeId).catch(() => null), this.getNodeInferenceDevices({ nodeId }).catch(() => null)]);
|
|
136258
|
+
return {
|
|
136259
|
+
nodeId,
|
|
136260
|
+
catalog,
|
|
136261
|
+
devices: view?.reachable === true ? view.devices : null,
|
|
136262
|
+
settings: agentMap[nodeId]
|
|
136263
|
+
};
|
|
136264
|
+
}));
|
|
136265
|
+
return buildStepSwitchMatrix({
|
|
136266
|
+
clusterModes,
|
|
136267
|
+
cameraToggles: Object.values(cameraMap).map((c) => c.stepToggles ?? {}),
|
|
136268
|
+
nodes
|
|
136269
|
+
});
|
|
135290
136270
|
}
|
|
135291
136271
|
/** Emit `pipeline.camera-updated` carrying the freshly-resolved config. */
|
|
135292
136272
|
async emitResolvedCameraUpdated(deviceId) {
|