@camstack/addon-pipeline-orchestrator 1.2.704 → 1.2.705
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +14 -0
- package/dist/_stub.js +2 -2
- package/dist/{_virtual_mf-localSharedImportMap___mfe_internal__addon_pipeline_orchestrator_widgets-Cj52fOl5.mjs → _virtual_mf-localSharedImportMap___mfe_internal__addon_pipeline_orchestrator_widgets-D9Ieg-TJ.mjs} +2 -2
- package/dist/_virtual_mf___mfe_internal__addon_pipeline_orchestrator_widgets__loadShare___mf_0_camstack_mf_1_types__loadShare__.js-D5hGghmf.mjs +26 -0
- package/dist/{_virtual_mf___mfe_internal__addon_pipeline_orchestrator_widgets__loadShare___mf_0_camstack_mf_1_ui_mf_2_library__loadShare__.js-db42AynZ.mjs → _virtual_mf___mfe_internal__addon_pipeline_orchestrator_widgets__loadShare___mf_0_camstack_mf_1_ui_mf_2_library__loadShare__.js-CWJvaMDE.mjs} +1 -1
- package/dist/{hostInit-gz1wzjps.mjs → hostInit-BVdelTmU.mjs} +2 -2
- package/dist/index.js +1022 -99
- package/dist/index.mjs +1022 -99
- package/dist/remoteEntry.js +1 -1
- package/package.json +2 -2
- package/dist/_virtual_mf___mfe_internal__addon_pipeline_orchestrator_widgets__loadShare___mf_0_camstack_mf_1_types__loadShare__.js-CQQGnCt3.mjs +0 -26
package/dist/index.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,
|
|
@@ -75102,7 +75208,15 @@ var RunnerInferenceDeviceSchema = object({
|
|
|
75102
75208
|
* Absent field ⇒ an orchestrator that predates D650: the jumped step keeps
|
|
75103
75209
|
* the elected device's provisioning, as before.
|
|
75104
75210
|
*/
|
|
75105
|
-
steps: record(string(), RunnerJumpStepProvisioningSchema).optional()
|
|
75211
|
+
steps: record(string(), RunnerJumpStepProvisioningSchema).optional(),
|
|
75212
|
+
/**
|
|
75213
|
+
* Steps switched OFF on this device (D1065, `inferenceDevices[key].steps[s]
|
|
75214
|
+
* .enabled === false`). The runner never runs a subtree containing one of
|
|
75215
|
+
* them here: it auto-jumps it to an allowed device, and when none can take
|
|
75216
|
+
* it the subtree is skipped (`disabled-on-device`), never run here anyway.
|
|
75217
|
+
* Absent ⇒ none (an orchestrator that predates D1065).
|
|
75218
|
+
*/
|
|
75219
|
+
disabledSteps: array(string()).readonly().optional()
|
|
75106
75220
|
});
|
|
75107
75221
|
/**
|
|
75108
75222
|
* Camera assignment payload sent by `addon-pipeline-orchestrator` to a
|
|
@@ -81268,7 +81382,15 @@ var DeviceStepConfigSchema = object({
|
|
|
81268
81382
|
* at a disabled/absent device on that node at save time. Absent ⇒ the runner
|
|
81269
81383
|
* auto-jumps only when the effective device's format cannot run the step.
|
|
81270
81384
|
*/
|
|
81271
|
-
jumpDeviceKey: string().optional()
|
|
81385
|
+
jumpDeviceKey: string().optional(),
|
|
81386
|
+
/**
|
|
81387
|
+
* DEVICE switch for this step (D1065). `false` = the step is never
|
|
81388
|
+
* provisioned on this accelerator: a detail step jumps to another enabled
|
|
81389
|
+
* device of the node where it is allowed, else it is skipped with reason
|
|
81390
|
+
* `disabled-on-device`; a root is skipped. Absent = inherit (on). Written by
|
|
81391
|
+
* `setDeviceStepEnabled`.
|
|
81392
|
+
*/
|
|
81393
|
+
enabled: boolean().optional()
|
|
81272
81394
|
});
|
|
81273
81395
|
var AgentPipelineSettingsSchema = object({
|
|
81274
81396
|
maxCameras: number$1().int().nonnegative().nullable().default(null),
|
|
@@ -81312,6 +81434,12 @@ var AgentPipelineSettingsSchema = object({
|
|
|
81312
81434
|
*/
|
|
81313
81435
|
stepSettings: record(string(), record(string(), unknown()).readonly()).optional(),
|
|
81314
81436
|
/**
|
|
81437
|
+
* NODE switch per step (D1065): `stepId → enabled`. `false` = the step never
|
|
81438
|
+
* runs on a camera whose pipeline runs on this node (skip reason
|
|
81439
|
+
* `disabled-on-node`). Absent = inherit. Written by `setNodeStepEnabled`.
|
|
81440
|
+
*/
|
|
81441
|
+
stepEnabled: record(string(), boolean()).optional(),
|
|
81442
|
+
/**
|
|
81315
81443
|
* Multi-device inference opt-in (Phase 4). Per-node map deviceKey → {enabled,
|
|
81316
81444
|
* weight, steps}. Absent / all-disabled ⇒ the node's single default
|
|
81317
81445
|
* accelerator (safe default); two+ enabled ⇒ the dispatcher balances
|
|
@@ -81633,7 +81761,8 @@ var InferenceDeviceExclusionReasonSchema = _enum([
|
|
|
81633
81761
|
"disabled",
|
|
81634
81762
|
"unavailable",
|
|
81635
81763
|
"cannot-host-camera-root",
|
|
81636
|
-
"accelerator-preferred"
|
|
81764
|
+
"accelerator-preferred",
|
|
81765
|
+
"root-switched-off"
|
|
81637
81766
|
]);
|
|
81638
81767
|
var NodeInferenceDeviceSchema = object({
|
|
81639
81768
|
/** Stable per-node device key, e.g. `openvino:npu`, `edgetpu:usb`, `cpu`. */
|
|
@@ -81719,6 +81848,75 @@ var NodeInferenceDevicesSchema = object({
|
|
|
81719
81848
|
devices: array(NodeInferenceDeviceSchema).readonly()
|
|
81720
81849
|
});
|
|
81721
81850
|
/**
|
|
81851
|
+
* The CLUSTER switch of one pipeline step (D1065):
|
|
81852
|
+
* - `off` — hard off: no camera, node or device can turn it on;
|
|
81853
|
+
* - `on` — on by default; a camera may turn it off (`stepToggles`);
|
|
81854
|
+
* - `opt-in` — off by default; a camera turns it on (`stepToggles`).
|
|
81855
|
+
* Absent = the catalog's `enabledByDefault` (`true` → `on`, `false` → `opt-in`).
|
|
81856
|
+
*/
|
|
81857
|
+
var StepClusterModeSchema = _enum([
|
|
81858
|
+
"off",
|
|
81859
|
+
"on",
|
|
81860
|
+
"opt-in"
|
|
81861
|
+
]);
|
|
81862
|
+
/**
|
|
81863
|
+
* What one step does on one (node, device) — computed by the orchestrator with
|
|
81864
|
+
* the SAME placement function the attach path runs (`pipeline-resolver.ts`),
|
|
81865
|
+
* so a client never re-derives it. Precedence: cluster off > camera toggle
|
|
81866
|
+
* (else the cluster default) > node off > device off / jump.
|
|
81867
|
+
*/
|
|
81868
|
+
var StepSwitchCellSchema = discriminatedUnion("kind", [
|
|
81869
|
+
object({ kind: literal("on") }),
|
|
81870
|
+
object({ kind: literal("off-cluster") }),
|
|
81871
|
+
object({ kind: literal("off-node") }),
|
|
81872
|
+
object({ kind: literal("off-device") }),
|
|
81873
|
+
object({
|
|
81874
|
+
kind: literal("jump"),
|
|
81875
|
+
toDeviceKey: string()
|
|
81876
|
+
}),
|
|
81877
|
+
object({
|
|
81878
|
+
kind: literal("skip"),
|
|
81879
|
+
reason: _enum(["no-compatible-model", "root-not-runnable-on-elected-device"])
|
|
81880
|
+
}),
|
|
81881
|
+
object({ kind: literal("zone-driven") }),
|
|
81882
|
+
object({
|
|
81883
|
+
kind: literal("supplied-by-root"),
|
|
81884
|
+
rootModelId: string()
|
|
81885
|
+
}),
|
|
81886
|
+
object({ kind: literal("opt-in-unused") })
|
|
81887
|
+
]);
|
|
81888
|
+
var StepSwitchDeviceSchema = object({
|
|
81889
|
+
deviceKey: string(),
|
|
81890
|
+
format: _enum(MODEL_FORMATS),
|
|
81891
|
+
/** The device switch as stored (`inferenceDevices[key].steps[step].enabled`); `null` = inherit. */
|
|
81892
|
+
stepEnabled: boolean().nullable(),
|
|
81893
|
+
/** Whether the device is in the node's dispatch roster (enabled, available, not excluded). */
|
|
81894
|
+
eligible: boolean(),
|
|
81895
|
+
cell: StepSwitchCellSchema
|
|
81896
|
+
});
|
|
81897
|
+
var StepSwitchNodeSchema = object({
|
|
81898
|
+
nodeId: string(),
|
|
81899
|
+
/** False when the node's catalog or device probe did not answer — no cells are claimed. */
|
|
81900
|
+
reachable: boolean(),
|
|
81901
|
+
/** The node switch as stored (`stepEnabled[step]`); `null` = inherit. */
|
|
81902
|
+
stepEnabled: boolean().nullable(),
|
|
81903
|
+
devices: array(StepSwitchDeviceSchema).readonly()
|
|
81904
|
+
});
|
|
81905
|
+
var StepSwitchMatrixSchema = object({ steps: array(object({
|
|
81906
|
+
stepId: string(),
|
|
81907
|
+
name: string(),
|
|
81908
|
+
slot: string(),
|
|
81909
|
+
/** The stored cluster mode; `null` = the catalog default applies. */
|
|
81910
|
+
clusterMode: StepClusterModeSchema.nullable(),
|
|
81911
|
+
/** The mode in force (stored, else derived from `enabledByDefault`). */
|
|
81912
|
+
effectiveMode: StepClusterModeSchema,
|
|
81913
|
+
/** Cameras whose `stepToggles[step]` is `true`. */
|
|
81914
|
+
camerasEnabling: number$1().int().nonnegative(),
|
|
81915
|
+
/** Cameras whose `stepToggles[step]` is `false`. */
|
|
81916
|
+
camerasDisabling: number$1().int().nonnegative(),
|
|
81917
|
+
nodes: array(StepSwitchNodeSchema).readonly()
|
|
81918
|
+
})).readonly() });
|
|
81919
|
+
/**
|
|
81722
81920
|
* Pipeline Orchestrator capability — global load balancer + camera dispatcher.
|
|
81723
81921
|
*
|
|
81724
81922
|
* Lives on the hub. Tracks the camera-to-agent assignment map, listens to
|
|
@@ -82091,6 +82289,51 @@ var pipelineOrchestratorCapability = {
|
|
|
82091
82289
|
auth: "admin"
|
|
82092
82290
|
}),
|
|
82093
82291
|
/**
|
|
82292
|
+
* Set one step's CLUSTER switch (D1065): `off` | `on` | `opt-in`, or
|
|
82293
|
+
* `null` to return to the catalog default. Re-resolves every placed
|
|
82294
|
+
* camera's pipeline.
|
|
82295
|
+
*/
|
|
82296
|
+
setClusterStepMode: method(object({
|
|
82297
|
+
stepId: string(),
|
|
82298
|
+
mode: StepClusterModeSchema.nullable()
|
|
82299
|
+
}), object({ success: literal(true) }), {
|
|
82300
|
+
kind: "mutation",
|
|
82301
|
+
auth: "admin"
|
|
82302
|
+
}),
|
|
82303
|
+
/**
|
|
82304
|
+
* Set one step's NODE switch (D1065): `false` = the step never runs on a
|
|
82305
|
+
* camera whose pipeline runs on that node; `null` = inherit.
|
|
82306
|
+
*/
|
|
82307
|
+
setNodeStepEnabled: method(object({
|
|
82308
|
+
agentNodeId: string(),
|
|
82309
|
+
stepId: string(),
|
|
82310
|
+
enabled: boolean().nullable()
|
|
82311
|
+
}), object({ success: literal(true) }), {
|
|
82312
|
+
kind: "mutation",
|
|
82313
|
+
auth: "admin"
|
|
82314
|
+
}),
|
|
82315
|
+
/**
|
|
82316
|
+
* Set one step's DEVICE switch (D1065) on `(node, deviceKey)`: `false` =
|
|
82317
|
+
* the step is not provisioned there (a detail step jumps to an allowed
|
|
82318
|
+
* sibling, else is skipped); `null` = inherit.
|
|
82319
|
+
*/
|
|
82320
|
+
setDeviceStepEnabled: method(object({
|
|
82321
|
+
agentNodeId: string(),
|
|
82322
|
+
deviceKey: string(),
|
|
82323
|
+
stepId: string(),
|
|
82324
|
+
enabled: boolean().nullable()
|
|
82325
|
+
}), object({ success: literal(true) }), {
|
|
82326
|
+
kind: "mutation",
|
|
82327
|
+
auth: "admin"
|
|
82328
|
+
}),
|
|
82329
|
+
/**
|
|
82330
|
+
* The step switch matrix (D1065): per step, the cluster mode, how many
|
|
82331
|
+
* cameras turn it on / off, and per node and device the effective cell —
|
|
82332
|
+
* computed by the same placement function the attach path runs. The
|
|
82333
|
+
* inspector renders this; it never derives a cell itself.
|
|
82334
|
+
*/
|
|
82335
|
+
getStepSwitches: method(_void(), StepSwitchMatrixSchema),
|
|
82336
|
+
/**
|
|
82094
82337
|
* DEVICE-AWARE merged view of ONE node's inference accelerators. Joins each
|
|
82095
82338
|
* physical device the node HAS — probed live via a node-pinned
|
|
82096
82339
|
* `platformProbe.getCapabilities` (the platform-probe singleton is targeted
|
|
@@ -92344,7 +92587,7 @@ var WorkloadPortSchema = object({
|
|
|
92344
92587
|
hostIp: string().nullable(),
|
|
92345
92588
|
protocol: WorkloadPortProtocolSchema
|
|
92346
92589
|
});
|
|
92347
|
-
object({
|
|
92590
|
+
var WorkloadStatusSchema = object({
|
|
92348
92591
|
/** null = unknown, never stopped (D393). */
|
|
92349
92592
|
state: WorkloadStateSchema.nullable().meta({ label: "State" }),
|
|
92350
92593
|
/** Epoch ms the current state began (uptime while running); null when unknown. */
|
|
@@ -93798,23 +94041,56 @@ var fountainContribution = contribution("pet-fountain", PetFountainStatusSchema,
|
|
|
93798
94041
|
};
|
|
93799
94042
|
});
|
|
93800
94043
|
var minutesOf = (seconds) => Math.max(0, Math.round(seconds / 60));
|
|
94044
|
+
var pumpCycleContribution = contribution("pump-cycle", PumpCycleStatusSchema, (slice) => {
|
|
94045
|
+
const enabled = slice?.enabled ?? null;
|
|
94046
|
+
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;
|
|
94047
|
+
return { rows: [row$1("pump-cycle", "timer", enabled === null ? unknownText : enabled ? joinText([t("Cycling", "A cicli"), cycle]) : t("Runs continuously", "Sempre attiva"), [{
|
|
94048
|
+
kind: "toggle",
|
|
94049
|
+
id: "pump-cycle.enabled",
|
|
94050
|
+
label: t("Pump cycle", "Ciclo pompa"),
|
|
94051
|
+
on: enabled,
|
|
94052
|
+
turnOn: action("pump-cycle.on", t("Cycle the pump", "Attiva il ciclo"), "timer", "pump-cycle", "setEnabled", { on: true }),
|
|
94053
|
+
turnOff: action("pump-cycle.off", t("Run continuously", "Sempre attiva"), "timer-off", "pump-cycle", "setEnabled", { on: false })
|
|
94054
|
+
}])] };
|
|
94055
|
+
});
|
|
94056
|
+
var WORKLOAD_WORDS = {
|
|
94057
|
+
running: {
|
|
94058
|
+
state: "on",
|
|
94059
|
+
title: t("Running", "In esecuzione")
|
|
94060
|
+
},
|
|
94061
|
+
paused: {
|
|
94062
|
+
state: "standby",
|
|
94063
|
+
title: t("Paused", "In pausa")
|
|
94064
|
+
},
|
|
94065
|
+
stopped: {
|
|
94066
|
+
state: "off",
|
|
94067
|
+
title: t("Stopped", "Fermo")
|
|
94068
|
+
},
|
|
94069
|
+
starting: {
|
|
94070
|
+
state: "running",
|
|
94071
|
+
title: t("Starting", "In avvio")
|
|
94072
|
+
},
|
|
94073
|
+
stopping: {
|
|
94074
|
+
state: "running",
|
|
94075
|
+
title: t("Stopping", "In arresto")
|
|
94076
|
+
},
|
|
94077
|
+
crashed: {
|
|
94078
|
+
state: "alert",
|
|
94079
|
+
title: t("Crashed", "Andato in errore")
|
|
94080
|
+
}
|
|
94081
|
+
};
|
|
93801
94082
|
var DEVICES_FAMILY_CONTRIBUTIONS = {
|
|
93802
94083
|
"fan-control": fanContribution,
|
|
93803
94084
|
"vacuum-control": vacuumContribution,
|
|
93804
94085
|
"lawn-mower-control": mowerContribution,
|
|
93805
94086
|
"pet-feeder": feederContribution,
|
|
93806
94087
|
"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
|
-
}])] };
|
|
94088
|
+
"pump-cycle": pumpCycleContribution,
|
|
94089
|
+
workload: contribution("workload", WorkloadStatusSchema, (slice) => {
|
|
94090
|
+
const state = slice?.state ?? null;
|
|
94091
|
+
if (state === null) return { reading: reading("workload", "unknown") };
|
|
94092
|
+
const words = WORKLOAD_WORDS[state];
|
|
94093
|
+
return { reading: reading("workload", words.state, false, words.title) };
|
|
93818
94094
|
})
|
|
93819
94095
|
};
|
|
93820
94096
|
/**
|
|
@@ -102831,6 +103107,13 @@ Object.freeze({
|
|
|
102831
103107
|
access: "view",
|
|
102832
103108
|
role: "admin"
|
|
102833
103109
|
},
|
|
103110
|
+
"pipelineOrchestrator.getStepSwitches": {
|
|
103111
|
+
capName: "pipeline-orchestrator",
|
|
103112
|
+
capScope: "system",
|
|
103113
|
+
addonId: null,
|
|
103114
|
+
access: "view",
|
|
103115
|
+
role: "admin"
|
|
103116
|
+
},
|
|
102834
103117
|
"pipelineOrchestrator.listAgentSettings": {
|
|
102835
103118
|
capName: "pipeline-orchestrator",
|
|
102836
103119
|
capScope: "system",
|
|
@@ -102985,6 +103268,20 @@ Object.freeze({
|
|
|
102985
103268
|
access: "create",
|
|
102986
103269
|
role: "admin"
|
|
102987
103270
|
},
|
|
103271
|
+
"pipelineOrchestrator.setClusterStepMode": {
|
|
103272
|
+
capName: "pipeline-orchestrator",
|
|
103273
|
+
capScope: "system",
|
|
103274
|
+
addonId: null,
|
|
103275
|
+
access: "create",
|
|
103276
|
+
role: "admin"
|
|
103277
|
+
},
|
|
103278
|
+
"pipelineOrchestrator.setDeviceStepEnabled": {
|
|
103279
|
+
capName: "pipeline-orchestrator",
|
|
103280
|
+
capScope: "system",
|
|
103281
|
+
addonId: null,
|
|
103282
|
+
access: "create",
|
|
103283
|
+
role: "admin"
|
|
103284
|
+
},
|
|
102988
103285
|
"pipelineOrchestrator.setLoadBalancingShares": {
|
|
102989
103286
|
capName: "pipeline-orchestrator",
|
|
102990
103287
|
capScope: "system",
|
|
@@ -102992,6 +103289,13 @@ Object.freeze({
|
|
|
102992
103289
|
access: "create",
|
|
102993
103290
|
role: "admin"
|
|
102994
103291
|
},
|
|
103292
|
+
"pipelineOrchestrator.setNodeStepEnabled": {
|
|
103293
|
+
capName: "pipeline-orchestrator",
|
|
103294
|
+
capScope: "system",
|
|
103295
|
+
addonId: null,
|
|
103296
|
+
access: "create",
|
|
103297
|
+
role: "admin"
|
|
103298
|
+
},
|
|
102995
103299
|
"pipelineOrchestrator.setNodeStepSettings": {
|
|
102996
103300
|
capName: "pipeline-orchestrator",
|
|
102997
103301
|
capScope: "system",
|
|
@@ -114959,6 +115263,52 @@ function createDiskReconcileJobRunner(now = Date.now) {
|
|
|
114959
115263
|
};
|
|
114960
115264
|
}
|
|
114961
115265
|
//#endregion
|
|
115266
|
+
//#region src/node-step-settings.ts
|
|
115267
|
+
/**
|
|
115268
|
+
* The provisioning base for `deviceKey` (`''` = the runner's default pool,
|
|
115269
|
+
* which has no device entry and takes the node layer alone). Pure; fresh
|
|
115270
|
+
* objects only.
|
|
115271
|
+
*/
|
|
115272
|
+
function nodeDeviceBase(node, deviceKey) {
|
|
115273
|
+
const own = node?.inferenceDevices?.[deviceKey]?.steps ?? {};
|
|
115274
|
+
const nodeLayer = node?.stepSettings ?? {};
|
|
115275
|
+
const out = {};
|
|
115276
|
+
for (const stepId of new Set([...Object.keys(nodeLayer), ...Object.keys(own)])) {
|
|
115277
|
+
const device = own[stepId];
|
|
115278
|
+
const merged = {
|
|
115279
|
+
...nodeLayer[stepId],
|
|
115280
|
+
...device?.settings
|
|
115281
|
+
};
|
|
115282
|
+
out[stepId] = {
|
|
115283
|
+
...device?.modelId !== void 0 ? { modelId: device.modelId } : {},
|
|
115284
|
+
...device?.jumpDeviceKey !== void 0 ? { jumpDeviceKey: device.jumpDeviceKey } : {},
|
|
115285
|
+
...Object.keys(merged).length > 0 ? { settings: merged } : {}
|
|
115286
|
+
};
|
|
115287
|
+
}
|
|
115288
|
+
return out;
|
|
115289
|
+
}
|
|
115290
|
+
/**
|
|
115291
|
+
* The steps switched OFF on `deviceKey` of this node (D1065):
|
|
115292
|
+
* `inferenceDevices[deviceKey].steps[step].enabled === false`. Only that
|
|
115293
|
+
* device's own entry is read; `''` (the default pool) has none.
|
|
115294
|
+
*/
|
|
115295
|
+
function deviceDisabledSteps(node, deviceKey) {
|
|
115296
|
+
const steps = node?.inferenceDevices?.[deviceKey]?.steps ?? {};
|
|
115297
|
+
return new Set(Object.entries(steps).filter(([, cfg]) => cfg.enabled === false).map(([stepId]) => stepId));
|
|
115298
|
+
}
|
|
115299
|
+
/**
|
|
115300
|
+
* The steps a DEFAULT-POOL attach (no elected device) must not run (D1065):
|
|
115301
|
+
* those switched off on EVERY device the pool may be. The pool is the node's
|
|
115302
|
+
* eligible devices (one eligible device IS the pool, D745); with none
|
|
115303
|
+
* eligible it is any device the node has enabled. A step one of them still
|
|
115304
|
+
* allows is kept — the pool may be that device. No candidate ⇒ nothing.
|
|
115305
|
+
*/
|
|
115306
|
+
function poolDisabledSteps(node, eligibleKeys) {
|
|
115307
|
+
const [first, ...rest] = (eligibleKeys.length > 0 ? eligibleKeys : Object.entries(node?.inferenceDevices ?? {}).filter(([, device]) => device.enabled).map(([key]) => key)).map((key) => deviceDisabledSteps(node, key));
|
|
115308
|
+
if (first === void 0) return /* @__PURE__ */ new Set();
|
|
115309
|
+
return new Set([...first].filter((stepId) => rest.every((steps) => steps.has(stepId))));
|
|
115310
|
+
}
|
|
115311
|
+
//#endregion
|
|
114962
115312
|
//#region src/pipeline-resolver.ts
|
|
114963
115313
|
/**
|
|
114964
115314
|
* The `package-detection` root step id. Zone-driven activation
|
|
@@ -115035,38 +115385,86 @@ function addonHasCompatibleModel(addon, format) {
|
|
|
115035
115385
|
function isVideoRoot(addon) {
|
|
115036
115386
|
return (addon.inputClasses ?? []).length === 0;
|
|
115037
115387
|
}
|
|
115038
|
-
/**
|
|
115039
|
-
|
|
115040
|
-
|
|
115041
|
-
|
|
115042
|
-
|
|
115043
|
-
|
|
115044
|
-
|
|
115045
|
-
|
|
115046
|
-
|
|
115047
|
-
|
|
115048
|
-
|
|
115049
|
-
|
|
115050
|
-
|
|
115051
|
-
|
|
115052
|
-
|
|
115053
|
-
|
|
115054
|
-
|
|
115055
|
-
|
|
115056
|
-
|
|
115388
|
+
/** The cluster mode a step runs under when none is stored: the catalog default. */
|
|
115389
|
+
function defaultClusterStepMode(addon) {
|
|
115390
|
+
return addon.enabledByDefault === false ? "opt-in" : "on";
|
|
115391
|
+
}
|
|
115392
|
+
/** The cluster mode in force: the stored one, else the catalog default. */
|
|
115393
|
+
function effectiveClusterStepMode(addon, stored) {
|
|
115394
|
+
return stored ?? defaultClusterStepMode(addon);
|
|
115395
|
+
}
|
|
115396
|
+
function gateStep(addon, layers) {
|
|
115397
|
+
const mode = effectiveClusterStepMode(addon, layers.clusterMode);
|
|
115398
|
+
if (mode === "off") return {
|
|
115399
|
+
kind: "off",
|
|
115400
|
+
reason: "disabled-on-cluster"
|
|
115401
|
+
};
|
|
115402
|
+
if (!(layers.cameraToggle ?? mode === "on")) return {
|
|
115403
|
+
kind: "off",
|
|
115404
|
+
reason: "disabled-on-camera"
|
|
115405
|
+
};
|
|
115406
|
+
if (layers.nodeEnabled === false) return {
|
|
115407
|
+
kind: "off",
|
|
115408
|
+
reason: "disabled-on-node"
|
|
115409
|
+
};
|
|
115410
|
+
return { kind: "on" };
|
|
115411
|
+
}
|
|
115412
|
+
function placeStepOnDevices(addon, elected, roster) {
|
|
115413
|
+
if (addon.slot === "audio-classifier") return { kind: "run" };
|
|
115414
|
+
const builds = (slot) => addonHasCompatibleModel(addon, slot.format);
|
|
115415
|
+
const allowed = (slot) => !slot.disabledSteps.has(addon.id);
|
|
115416
|
+
const electedBuild = builds(elected);
|
|
115417
|
+
if (electedBuild && allowed(elected)) return { kind: "run" };
|
|
115418
|
+
if (isVideoRoot(addon)) {
|
|
115419
|
+
if (!allowed(elected)) return {
|
|
115420
|
+
kind: "skip",
|
|
115421
|
+
reason: "disabled-on-device"
|
|
115422
|
+
};
|
|
115423
|
+
return roster.some(builds) ? {
|
|
115424
|
+
kind: "skip",
|
|
115425
|
+
reason: "root-not-runnable-on-elected-device"
|
|
115426
|
+
} : {
|
|
115427
|
+
kind: "skip",
|
|
115428
|
+
reason: "no-compatible-model"
|
|
115429
|
+
};
|
|
115430
|
+
}
|
|
115431
|
+
const first = roster.filter((slot) => builds(slot) && allowed(slot)).toSorted((a, b) => slotOrderKey(a).localeCompare(slotOrderKey(b)))[0];
|
|
115432
|
+
if (first !== void 0) return {
|
|
115433
|
+
kind: "jump",
|
|
115434
|
+
toDeviceKey: first.deviceKey
|
|
115435
|
+
};
|
|
115436
|
+
return {
|
|
115437
|
+
kind: "skip",
|
|
115438
|
+
reason: electedBuild && !allowed(elected) || roster.some(builds) ? "disabled-on-device" : "no-compatible-model"
|
|
115439
|
+
};
|
|
115440
|
+
}
|
|
115441
|
+
function slotOrderKey(slot) {
|
|
115442
|
+
return slot.deviceKey ?? slot.format;
|
|
115443
|
+
}
|
|
115444
|
+
var NO_STEPS = /* @__PURE__ */ new Set();
|
|
115445
|
+
/** The gate layers of `addonId` read from a switch context (absent entries stay absent). */
|
|
115446
|
+
function gateLayersOf(addonId, switches) {
|
|
115447
|
+
const clusterMode = switches.clusterModes?.[addonId];
|
|
115448
|
+
const nodeEnabled = switches.nodeStepEnabled?.[addonId];
|
|
115449
|
+
return {
|
|
115450
|
+
...clusterMode !== void 0 ? { clusterMode } : {},
|
|
115451
|
+
...nodeEnabled !== void 0 ? { nodeEnabled } : {}
|
|
115452
|
+
};
|
|
115057
115453
|
}
|
|
115058
115454
|
/**
|
|
115059
115455
|
* Device-aware resolver — the SINGLE per-camera gate + per-DEVICE skip check.
|
|
115060
115456
|
*
|
|
115061
115457
|
* Step `S` runs for camera `C` on device `D` ⇔
|
|
115062
|
-
* gate(C, S)
|
|
115063
|
-
*
|
|
115458
|
+
* gate(C, N, S) — {@link gateStep}: cluster not off, the camera toggle
|
|
115459
|
+
* (else the cluster default), the node switch (D1065)
|
|
115460
|
+
* AND provided(D, S) — {@link placeStepOnDevices}: a device not switched off
|
|
115461
|
+
* for S has a build of it — the catalog lists a model with a build for D's FORMAT
|
|
115064
115462
|
* (a ROOT), or for D's format or any `jumpFormats`
|
|
115065
115463
|
* entry (a detail step — the runner jumps it, D650);
|
|
115066
115464
|
* `audio-classifier` is never format-gated (it runs
|
|
115067
115465
|
* on the audio-analyzer's own backend)
|
|
115068
115466
|
*
|
|
115069
|
-
*
|
|
115467
|
+
* Provisioning
|
|
115070
115468
|
* (`modelId` / `settings`) is NOT applied here — the returned tree carries bare
|
|
115071
115469
|
* `{ addonId, enabled: true, children }` nodes; {@link applyDeviceProvisioning}
|
|
115072
115470
|
* attaches model + settings at dispatch from the per-(node,device) base and the
|
|
@@ -115076,30 +115474,58 @@ function unprovisionedReason(addon, electedFormat, jumpFormats) {
|
|
|
115076
115474
|
* recorded in `skipped` so the caller can surface a visible "gated on, no model
|
|
115077
115475
|
* on this node" status at dispatch time.
|
|
115078
115476
|
*
|
|
115079
|
-
* `package-detection` is excluded
|
|
115080
|
-
* ({@link applyPackageZoneActivation}, applied by the caller)
|
|
115477
|
+
* `package-detection` is excluded from the tree — it is zone-driven
|
|
115478
|
+
* ({@link applyPackageZoneActivation}, applied by the caller); the cluster,
|
|
115479
|
+
* node and elected-device switches still apply, as `packageAllowed` (D1065).
|
|
115081
115480
|
*
|
|
115082
115481
|
* "Inference disabled for this camera" is NOT handled here — the caller
|
|
115083
115482
|
* (resolvePipelineForDevice) consults the detection-pipeline binding and
|
|
115084
115483
|
* short-circuits to an empty pipeline before invoking this resolver.
|
|
115085
115484
|
*/
|
|
115086
|
-
function resolvePipelineWithSkips(cameraSettings, deviceFormat, catalog, jumpFormats = []) {
|
|
115485
|
+
function resolvePipelineWithSkips(cameraSettings, deviceFormat, catalog, jumpFormats = [], switches = {}) {
|
|
115087
115486
|
const toggles = (cameraSettings ?? {}).stepToggles ?? {};
|
|
115088
|
-
const
|
|
115487
|
+
const elected = {
|
|
115488
|
+
format: deviceFormat,
|
|
115489
|
+
disabledSteps: switches.electedDisabledSteps ?? NO_STEPS
|
|
115490
|
+
};
|
|
115491
|
+
const roster = switches.jumpTargets ?? jumpFormats.map((format) => ({
|
|
115492
|
+
format,
|
|
115493
|
+
disabledSteps: NO_STEPS
|
|
115494
|
+
}));
|
|
115495
|
+
let packageAllowed = true;
|
|
115089
115496
|
const enabled = [];
|
|
115090
115497
|
const skipped = [];
|
|
115091
115498
|
const droppedRoots = [];
|
|
115092
115499
|
for (const slot of catalog.slots) for (const addon of slot.addons) {
|
|
115093
115500
|
const addonId = addon.id;
|
|
115094
|
-
|
|
115095
|
-
if (
|
|
115096
|
-
|
|
115097
|
-
|
|
115501
|
+
const layers = gateLayersOf(addonId, switches);
|
|
115502
|
+
if (addonId === "package-detection") {
|
|
115503
|
+
packageAllowed = gateStep(addon, {
|
|
115504
|
+
...layers,
|
|
115505
|
+
cameraToggle: true
|
|
115506
|
+
}).kind === "on" && !elected.disabledSteps.has(addonId);
|
|
115507
|
+
continue;
|
|
115508
|
+
}
|
|
115509
|
+
const cameraToggle = toggles[addonId];
|
|
115510
|
+
const gate = gateStep(addon, {
|
|
115511
|
+
...layers,
|
|
115512
|
+
...cameraToggle !== void 0 ? { cameraToggle } : {}
|
|
115513
|
+
});
|
|
115514
|
+
if (gate.kind === "off") {
|
|
115515
|
+
if (gate.reason !== "disabled-on-camera") skipped.push({
|
|
115516
|
+
addonId,
|
|
115517
|
+
reason: gate.reason
|
|
115518
|
+
});
|
|
115519
|
+
continue;
|
|
115520
|
+
}
|
|
115521
|
+
const placement = placeStepOnDevices(addon, elected, roster);
|
|
115522
|
+
if (placement.kind === "skip") {
|
|
115523
|
+
const reason = placement.reason;
|
|
115098
115524
|
skipped.push({
|
|
115099
115525
|
addonId,
|
|
115100
115526
|
reason
|
|
115101
115527
|
});
|
|
115102
|
-
if (addonId === "object-detection") droppedRoots.push(addonId);
|
|
115528
|
+
if (addonId === "object-detection" && reason !== "disabled-on-device") droppedRoots.push(addonId);
|
|
115103
115529
|
continue;
|
|
115104
115530
|
}
|
|
115105
115531
|
enabled.push({ addonId });
|
|
@@ -115118,7 +115544,8 @@ function resolvePipelineWithSkips(cameraSettings, deviceFormat, catalog, jumpFor
|
|
|
115118
115544
|
audio: audioAddons.length > 0 ? { enabled: true } : null
|
|
115119
115545
|
},
|
|
115120
115546
|
skipped,
|
|
115121
|
-
droppedRoots
|
|
115547
|
+
droppedRoots,
|
|
115548
|
+
packageAllowed
|
|
115122
115549
|
};
|
|
115123
115550
|
}
|
|
115124
115551
|
function findInCatalog(catalog, addonId) {
|
|
@@ -115222,6 +115649,29 @@ function makeRootCapabilityGuard(catalog) {
|
|
|
115222
115649
|
}
|
|
115223
115650
|
return () => true;
|
|
115224
115651
|
}
|
|
115652
|
+
/**
|
|
115653
|
+
* The camera-root SWITCH predicate for a node: `deviceKey → is the root on`.
|
|
115654
|
+
* The root ({@link OBJECT_DETECTION_STEP_ID}) is judged by the same
|
|
115655
|
+
* {@link gateStep} the attach path runs — cluster mode, then the node switch —
|
|
115656
|
+
* and then by the device's own step switch (D1065). The camera toggle is not a
|
|
115657
|
+
* layer here: the election picks a device for every camera of the node, and a
|
|
115658
|
+
* camera that turned its root off is refused by the attach itself.
|
|
115659
|
+
*
|
|
115660
|
+
* Fails OPEN when the catalog has no object-detection slot, like
|
|
115661
|
+
* {@link makeRootCapabilityGuard}. Pure.
|
|
115662
|
+
*/
|
|
115663
|
+
function makeRootSwitchGuard(catalog, clusterModes, node) {
|
|
115664
|
+
const root = catalog.slots.flatMap((slot) => slot.addons).find((a) => a.id === OBJECT_DETECTION_STEP_ID);
|
|
115665
|
+
if (root === void 0) return () => true;
|
|
115666
|
+
const clusterMode = clusterModes[OBJECT_DETECTION_STEP_ID];
|
|
115667
|
+
const nodeEnabled = node?.stepEnabled?.[OBJECT_DETECTION_STEP_ID];
|
|
115668
|
+
if (gateStep(root, {
|
|
115669
|
+
...clusterMode !== void 0 ? { clusterMode } : {},
|
|
115670
|
+
...nodeEnabled !== void 0 ? { nodeEnabled } : {},
|
|
115671
|
+
cameraToggle: true
|
|
115672
|
+
}).kind === "off") return () => false;
|
|
115673
|
+
return (deviceKey) => !deviceDisabledSteps(node, deviceKey).has(OBJECT_DETECTION_STEP_ID);
|
|
115674
|
+
}
|
|
115225
115675
|
/** Split a deviceKey (`<backend>:<device>`, or bare `cpu`) into its parts + format.
|
|
115226
115676
|
* Format comes from the shared {@link deviceBackendToFormat} SSOT (`@camstack/types`)
|
|
115227
115677
|
* — the previously-local `BACKEND_FORMAT` copy is gone (R3/node-F2). Used only for
|
|
@@ -115349,11 +115799,11 @@ function inferenceDeviceCaps(stored) {
|
|
|
115349
115799
|
function isCpuFallback(view) {
|
|
115350
115800
|
return view.backend === "cpu";
|
|
115351
115801
|
}
|
|
115352
|
-
function resolveInferenceDeviceEligibility(probed, stored, canRunRoot, isPoolUsable) {
|
|
115802
|
+
function resolveInferenceDeviceEligibility(probed, stored, canRunRoot, isPoolUsable, isRootSwitchedOn) {
|
|
115353
115803
|
const eligible = {};
|
|
115354
115804
|
const excluded = [];
|
|
115355
115805
|
const merged = mergeInferenceDevices(probed, stored);
|
|
115356
|
-
const acceleratorServes = merged.some((d) => !isCpuFallback(d) && d.enabled && d.available && (!canRunRoot || canRunRoot(d.format)));
|
|
115806
|
+
const acceleratorServes = merged.some((d) => !isCpuFallback(d) && d.enabled && d.available && (!canRunRoot || canRunRoot(d.format)) && (!isRootSwitchedOn || isRootSwitchedOn(d.key)));
|
|
115357
115807
|
for (const d of merged) {
|
|
115358
115808
|
if (!d.enabled) {
|
|
115359
115809
|
excluded.push({
|
|
@@ -115387,6 +115837,14 @@ function resolveInferenceDeviceEligibility(probed, stored, canRunRoot, isPoolUsa
|
|
|
115387
115837
|
});
|
|
115388
115838
|
continue;
|
|
115389
115839
|
}
|
|
115840
|
+
if (isRootSwitchedOn && !isRootSwitchedOn(d.key)) {
|
|
115841
|
+
excluded.push({
|
|
115842
|
+
key: d.key,
|
|
115843
|
+
reason: "root-switched-off",
|
|
115844
|
+
format: d.format
|
|
115845
|
+
});
|
|
115846
|
+
continue;
|
|
115847
|
+
}
|
|
115390
115848
|
if (isCpuFallback(d) && acceleratorServes) {
|
|
115391
115849
|
excluded.push({
|
|
115392
115850
|
key: d.key,
|
|
@@ -122367,7 +122825,7 @@ async function resolveAttachPipeline(input, store) {
|
|
|
122367
122825
|
eligible: input.eligible,
|
|
122368
122826
|
caps: input.caps
|
|
122369
122827
|
});
|
|
122370
|
-
const resolved = await store.resolvePipelineForDeviceWithRoots(input.deviceId, input.nodeId, input.deviceKey, jumpTargetKeys(roster, input.deviceKey));
|
|
122828
|
+
const resolved = await store.resolvePipelineForDeviceWithRoots(input.deviceId, input.nodeId, input.deviceKey, jumpTargetKeys(roster, input.deviceKey), defaultPoolOf(input));
|
|
122371
122829
|
if (resolved.droppedRoots.length > 0) return rootRefusal(input, resolved.droppedRoots);
|
|
122372
122830
|
return {
|
|
122373
122831
|
kind: "resolved",
|
|
@@ -122388,7 +122846,7 @@ async function resolveAttachPipelineIfCatalogCached(input, store) {
|
|
|
122388
122846
|
eligible: input.eligible,
|
|
122389
122847
|
caps: input.caps
|
|
122390
122848
|
});
|
|
122391
|
-
const outcome = await store.resolvePipelineForDeviceIfCatalogCached(input.deviceId, input.nodeId, input.deviceKey, jumpTargetKeys(roster, input.deviceKey));
|
|
122849
|
+
const outcome = await store.resolvePipelineForDeviceIfCatalogCached(input.deviceId, input.nodeId, input.deviceKey, jumpTargetKeys(roster, input.deviceKey), defaultPoolOf(input));
|
|
122392
122850
|
if (outcome.kind === "catalog-unavailable") return outcome;
|
|
122393
122851
|
if (outcome.droppedRoots.length > 0) return rootRefusal(input, outcome.droppedRoots);
|
|
122394
122852
|
return {
|
|
@@ -122396,6 +122854,10 @@ async function resolveAttachPipelineIfCatalogCached(input, store) {
|
|
|
122396
122854
|
pipeline: await provisionAttachPipeline(input, roster, outcome.config, store)
|
|
122397
122855
|
};
|
|
122398
122856
|
}
|
|
122857
|
+
/** No elected device ⇒ the runner's default pool, made of the eligible devices (D1065). */
|
|
122858
|
+
function defaultPoolOf(input) {
|
|
122859
|
+
return input.deviceKey === void 0 ? { eligibleKeys: Object.keys(input.eligible) } : void 0;
|
|
122860
|
+
}
|
|
122399
122861
|
function rootRefusal(input, droppedRoots) {
|
|
122400
122862
|
return {
|
|
122401
122863
|
kind: "root-refused",
|
|
@@ -122429,9 +122891,11 @@ async function provisionAttachPipeline(input, roster, resolved, store) {
|
|
|
122429
122891
|
const steps = applyDeviceProvisioning(resolved.steps, elected?.base ?? {}, elected?.override ?? {});
|
|
122430
122892
|
const inferenceDevices = roster?.map((entry) => {
|
|
122431
122893
|
const src = sources.get(entry.deviceKey);
|
|
122894
|
+
const disabledSteps = src?.disabledSteps ?? [];
|
|
122432
122895
|
return {
|
|
122433
122896
|
...entry,
|
|
122434
|
-
steps: provisionDeviceSteps(resolved.steps, src?.base ?? {}, src?.override ?? {})
|
|
122897
|
+
steps: provisionDeviceSteps(resolved.steps, src?.base ?? {}, src?.override ?? {}),
|
|
122898
|
+
...disabledSteps.length > 0 ? { disabledSteps } : {}
|
|
122435
122899
|
};
|
|
122436
122900
|
});
|
|
122437
122901
|
return {
|
|
@@ -122898,6 +123362,26 @@ var PlacementService = class {
|
|
|
122898
123362
|
}, this.deps.settingsStore);
|
|
122899
123363
|
}
|
|
122900
123364
|
/**
|
|
123365
|
+
* What an attach of `deviceId` on `nodeId` WOULD run — the `resolvePipeline`
|
|
123366
|
+
* preview. Same owner as a dispatch ({@link resolveAttachPipeline}), on the
|
|
123367
|
+
* device the camera is elected onto when it is placed on that node; for a
|
|
123368
|
+
* camera placed elsewhere (or nowhere), on the node's highest-weight eligible
|
|
123369
|
+
* device (ties by key), or the default pool when it has none. Before, the
|
|
123370
|
+
* preview resolved on the node's default format with no jump roster, and
|
|
123371
|
+
* reported the detail steps a sibling accelerator runs as dropped.
|
|
123372
|
+
*/
|
|
123373
|
+
async previewAttachPipeline(input) {
|
|
123374
|
+
const [eligible, caps] = await Promise.all([this.deps.getEligibleInferenceDevices(input.nodeId), this.deps.getInferenceDeviceCaps(input.nodeId)]);
|
|
123375
|
+
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];
|
|
123376
|
+
return resolveAttachPipeline({
|
|
123377
|
+
deviceId: input.deviceId,
|
|
123378
|
+
nodeId: input.nodeId,
|
|
123379
|
+
deviceKey,
|
|
123380
|
+
eligible,
|
|
123381
|
+
caps
|
|
123382
|
+
}, this.deps.settingsStore);
|
|
123383
|
+
}
|
|
123384
|
+
/**
|
|
122901
123385
|
* FIRST placement of a standing camera: waits for the chosen node's catalog
|
|
122902
123386
|
* (the resolve reconciles against its executor until it answers). Callers:
|
|
122903
123387
|
* `startDetection`'s standing path — one camera, nothing to attach instead.
|
|
@@ -123447,6 +123931,129 @@ var PlacementService = class {
|
|
|
123447
123931
|
for (const deviceId of affected) await this.deps.emitResolvedCameraUpdated(deviceId);
|
|
123448
123932
|
}
|
|
123449
123933
|
/**
|
|
123934
|
+
* A step switch changed (D1065): re-resolve the attach pipeline of every
|
|
123935
|
+
* placed camera — on `nodeId`, or on every node when `null` (a cluster
|
|
123936
|
+
* switch) — on the device it is already elected onto, through the one owner
|
|
123937
|
+
* of an attach's steps ({@link resolveAttachPipelineOnDevice}). Only a camera
|
|
123938
|
+
* whose resolved steps, audio, device or roster DIFFERS from its cached
|
|
123939
|
+
* attach is re-attached; the rest are left running untouched. A camera whose
|
|
123940
|
+
* root (`object-detection`) the switch took away from its elected device is
|
|
123941
|
+
* RE-ELECTED through the normal placement path ({@link reelectAfterRootSwitch}),
|
|
123942
|
+
* which already excludes a device the root is off on. One camera's failure is
|
|
123943
|
+
* logged and does not stop the sweep; a refused root keeps the live attach.
|
|
123944
|
+
*/
|
|
123945
|
+
async reattachForStepSwitch(nodeId, reason) {
|
|
123946
|
+
const affected = [];
|
|
123947
|
+
for (const [deviceId, assignment] of this.deps.ledger.assignmentEntries()) if (nodeId === null || assignment.agentNodeId === nodeId) affected.push({
|
|
123948
|
+
deviceId,
|
|
123949
|
+
nodeId: assignment.agentNodeId
|
|
123950
|
+
});
|
|
123951
|
+
if (affected.length === 0) return;
|
|
123952
|
+
const logger = this.deps.ctx().logger;
|
|
123953
|
+
let changed = 0;
|
|
123954
|
+
let unchanged = 0;
|
|
123955
|
+
for (const target of affected) {
|
|
123956
|
+
const tags = {
|
|
123957
|
+
deviceId: target.deviceId,
|
|
123958
|
+
nodeId: target.nodeId
|
|
123959
|
+
};
|
|
123960
|
+
const cached = this.deps.ledger.getConfig(target.deviceId);
|
|
123961
|
+
if (!cached) {
|
|
123962
|
+
logger.warn("step switch re-attach skipped — no cached config for a placed camera", {
|
|
123963
|
+
tags,
|
|
123964
|
+
meta: { reason }
|
|
123965
|
+
});
|
|
123966
|
+
unchanged++;
|
|
123967
|
+
continue;
|
|
123968
|
+
}
|
|
123969
|
+
try {
|
|
123970
|
+
const outcome = await this.resolveAttachPipelineOnDevice({
|
|
123971
|
+
deviceId: target.deviceId,
|
|
123972
|
+
nodeId: target.nodeId,
|
|
123973
|
+
deviceKey: cached.deviceKey
|
|
123974
|
+
});
|
|
123975
|
+
if (outcome.kind === "root-refused") {
|
|
123976
|
+
logger.error("step switch re-attach refused — the elected device cannot run the camera root", {
|
|
123977
|
+
tags,
|
|
123978
|
+
meta: {
|
|
123979
|
+
deviceKey: outcome.deviceKey ?? null,
|
|
123980
|
+
droppedRoots: outcome.droppedRoots.join(",")
|
|
123981
|
+
}
|
|
123982
|
+
});
|
|
123983
|
+
unchanged++;
|
|
123984
|
+
continue;
|
|
123985
|
+
}
|
|
123986
|
+
const next = withAttachPipeline(cached, outcome.pipeline);
|
|
123987
|
+
if (hasCameraRoot(cached.steps) && !hasCameraRoot(next.steps)) {
|
|
123988
|
+
await this.reelectAfterRootSwitch(cached, target.nodeId, reason);
|
|
123989
|
+
changed++;
|
|
123990
|
+
continue;
|
|
123991
|
+
}
|
|
123992
|
+
if (sameAttachPipeline(cached, next)) {
|
|
123993
|
+
unchanged++;
|
|
123994
|
+
continue;
|
|
123995
|
+
}
|
|
123996
|
+
this.deps.ledger.setConfig(target.deviceId, next);
|
|
123997
|
+
await this.attachOn(target.nodeId, next);
|
|
123998
|
+
changed++;
|
|
123999
|
+
} catch (err) {
|
|
124000
|
+
logger.warn("step switch re-attach failed", {
|
|
124001
|
+
tags,
|
|
124002
|
+
meta: {
|
|
124003
|
+
reason,
|
|
124004
|
+
error: errMsg$2(err)
|
|
124005
|
+
}
|
|
124006
|
+
});
|
|
124007
|
+
}
|
|
124008
|
+
}
|
|
124009
|
+
logger.info("step switch changed — re-attached the affected cameras", {
|
|
124010
|
+
...nodeId !== null ? { tags: { nodeId } } : {},
|
|
124011
|
+
meta: {
|
|
124012
|
+
reason,
|
|
124013
|
+
changed,
|
|
124014
|
+
unchanged
|
|
124015
|
+
}
|
|
124016
|
+
});
|
|
124017
|
+
}
|
|
124018
|
+
/**
|
|
124019
|
+
* The switch took the camera root away from the device the camera is
|
|
124020
|
+
* elected on. Re-place the camera through the normal path — its election
|
|
124021
|
+
* already excludes a device the root is off on, so it moves to an allowed
|
|
124022
|
+
* device, or the CPU / default pool when one exists. When nothing can host
|
|
124023
|
+
* the root the camera is left as it is and the reason is named: never silent.
|
|
124024
|
+
*/
|
|
124025
|
+
async reelectAfterRootSwitch(cached, nodeId, reason) {
|
|
124026
|
+
const logger = this.deps.ctx().logger;
|
|
124027
|
+
const tags = {
|
|
124028
|
+
deviceId: cached.deviceId,
|
|
124029
|
+
nodeId
|
|
124030
|
+
};
|
|
124031
|
+
const result = await this.redispatchCamera(cached);
|
|
124032
|
+
const placedConfig = this.deps.ledger.getConfig(cached.deviceId);
|
|
124033
|
+
if (result.kind === "assigned" && hasCameraRoot(placedConfig?.steps)) {
|
|
124034
|
+
logger.info("step switch took the camera root off its device — camera re-elected", {
|
|
124035
|
+
tags: {
|
|
124036
|
+
deviceId: cached.deviceId,
|
|
124037
|
+
nodeId: result.agentNodeId
|
|
124038
|
+
},
|
|
124039
|
+
meta: {
|
|
124040
|
+
reason,
|
|
124041
|
+
from: cached.deviceKey ?? "default-pool",
|
|
124042
|
+
to: placedConfig?.deviceKey ?? "default-pool"
|
|
124043
|
+
}
|
|
124044
|
+
});
|
|
124045
|
+
return;
|
|
124046
|
+
}
|
|
124047
|
+
logger.warn("step switch left no device able to host the camera root", {
|
|
124048
|
+
tags,
|
|
124049
|
+
meta: {
|
|
124050
|
+
reason: result.kind === "pending" ? this.deps.ledger.getPendingReason(cached.deviceId) ?? "pending" : "root-switched-off-on-every-eligible-device",
|
|
124051
|
+
switch: reason,
|
|
124052
|
+
deviceKey: cached.deviceKey ?? "default-pool"
|
|
124053
|
+
}
|
|
124054
|
+
});
|
|
124055
|
+
}
|
|
124056
|
+
/**
|
|
123450
124057
|
* Re-dispatch EVERY assigned camera through the REAL attach path
|
|
123451
124058
|
* (`redispatchSingleCamera` → `attachOn`), so each camera's `frameSource`
|
|
123452
124059
|
* (`local-broker` vs `remote-restream` naming the current ingest owner) is
|
|
@@ -123587,6 +124194,14 @@ var PlacementService = class {
|
|
|
123587
124194
|
});
|
|
123588
124195
|
}
|
|
123589
124196
|
};
|
|
124197
|
+
/** Does an attach's step tree carry the camera root (`object-detection`)? */
|
|
124198
|
+
function hasCameraRoot(steps) {
|
|
124199
|
+
return (steps ?? []).some((step) => step.addonId === OBJECT_DETECTION_STEP_ID);
|
|
124200
|
+
}
|
|
124201
|
+
/** Would re-attaching `next` over `current` change anything the runner acts on? */
|
|
124202
|
+
function sameAttachPipeline(current, next) {
|
|
124203
|
+
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);
|
|
124204
|
+
}
|
|
123590
124205
|
//#endregion
|
|
123591
124206
|
//#region src/node-lifecycle-handler.ts
|
|
123592
124207
|
var NodeLifecycleHandler = class {
|
|
@@ -125585,31 +126200,6 @@ async function reattachAfterPackageZoneChange(deps, deviceId) {
|
|
|
125585
126200
|
}
|
|
125586
126201
|
}
|
|
125587
126202
|
//#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
126203
|
//#region src/removed-model-pin-reset.ts
|
|
125614
126204
|
/**
|
|
125615
126205
|
* A stored model pin naming a model DELETED from its step's catalog is reset to
|
|
@@ -125832,7 +126422,8 @@ var AutoBenchmarkAttemptsSchema = record(string(), record(string(), object({
|
|
|
125832
126422
|
var StoredDeviceStepConfigSchema = object({
|
|
125833
126423
|
modelId: string().optional(),
|
|
125834
126424
|
settings: record(string(), unknown()).readonly().optional(),
|
|
125835
|
-
jumpDeviceKey: string().optional()
|
|
126425
|
+
jumpDeviceKey: string().optional(),
|
|
126426
|
+
enabled: boolean().optional()
|
|
125836
126427
|
});
|
|
125837
126428
|
var StoredAgentPipelineSettingsSchema = object({
|
|
125838
126429
|
maxCameras: number$1().int().nonnegative().nullable().default(null),
|
|
@@ -125846,6 +126437,7 @@ var StoredAgentPipelineSettingsSchema = object({
|
|
|
125846
126437
|
reachableHost: string().optional(),
|
|
125847
126438
|
color: NodeColorIdSchema.optional(),
|
|
125848
126439
|
stepSettings: record(string(), record(string(), unknown()).readonly()).optional(),
|
|
126440
|
+
stepEnabled: record(string(), boolean()).optional(),
|
|
125849
126441
|
inferenceDevices: record(string(), object({
|
|
125850
126442
|
enabled: boolean(),
|
|
125851
126443
|
weight: number$1().positive().optional(),
|
|
@@ -125853,6 +126445,7 @@ var StoredAgentPipelineSettingsSchema = object({
|
|
|
125853
126445
|
steps: record(string(), StoredDeviceStepConfigSchema).optional()
|
|
125854
126446
|
})).optional()
|
|
125855
126447
|
});
|
|
126448
|
+
var ClusterStepModesSchema = record(string(), StepClusterModeSchema);
|
|
125856
126449
|
var AgentSettingsMapSchema = record(string(), StoredAgentPipelineSettingsSchema);
|
|
125857
126450
|
var StoredCameraPipelineSettingsSchema = object({
|
|
125858
126451
|
stepToggles: record(string(), boolean()).optional(),
|
|
@@ -125974,6 +126567,12 @@ var DeviceRows = class {
|
|
|
125974
126567
|
//#endregion
|
|
125975
126568
|
//#region src/pipeline-settings-store.ts
|
|
125976
126569
|
var PIPELINE_EXECUTOR_CAP = "pipeline-executor";
|
|
126570
|
+
/** The addon-store key of the cluster step switches (D1065). */
|
|
126571
|
+
var CLUSTER_STEP_MODES_KEY = "clusterStepModes";
|
|
126572
|
+
/** A skip an operator switch caused (D1065), as opposed to a missing build. */
|
|
126573
|
+
function isSwitchSkip(reason) {
|
|
126574
|
+
return reason === "disabled-on-cluster" || reason === "disabled-on-node" || reason === "disabled-on-device";
|
|
126575
|
+
}
|
|
125977
126576
|
var PipelineSettingsStore = class PipelineSettingsStore {
|
|
125978
126577
|
deps;
|
|
125979
126578
|
static CATALOG_CACHE_TTL_MS = 3e4;
|
|
@@ -126167,6 +126766,79 @@ var PipelineSettingsStore = class PipelineSettingsStore {
|
|
|
126167
126766
|
});
|
|
126168
126767
|
});
|
|
126169
126768
|
}
|
|
126769
|
+
clusterStepModesState() {
|
|
126770
|
+
return this.deps.state(CLUSTER_STEP_MODES_KEY, ClusterStepModesSchema, {});
|
|
126771
|
+
}
|
|
126772
|
+
/** The stored cluster step modes, `stepId → mode` (absent step = catalog default). */
|
|
126773
|
+
async readClusterStepModes() {
|
|
126774
|
+
return await this.clusterStepModesState().get();
|
|
126775
|
+
}
|
|
126776
|
+
/** Write one step's cluster mode; `null` removes it (back to the catalog default). */
|
|
126777
|
+
async writeClusterStepMode(stepId, mode) {
|
|
126778
|
+
await this.blobWriteLock.run(CLUSTER_STEP_MODES_KEY, async () => {
|
|
126779
|
+
await this.clusterStepModesState().update((prev) => {
|
|
126780
|
+
const { [stepId]: _drop, ...rest } = prev;
|
|
126781
|
+
return mode === null ? rest : {
|
|
126782
|
+
...rest,
|
|
126783
|
+
[stepId]: mode
|
|
126784
|
+
};
|
|
126785
|
+
});
|
|
126786
|
+
});
|
|
126787
|
+
}
|
|
126788
|
+
/**
|
|
126789
|
+
* Write one step's NODE switch under the agent-blob lock; `null` removes it
|
|
126790
|
+
* (inherit). An empty map is pruned. Creates the node's entry when absent.
|
|
126791
|
+
*/
|
|
126792
|
+
async writeNodeStepEnabled(nodeId, stepId, enabled) {
|
|
126793
|
+
await this.blobWriteLock.run(PipelineSettingsStore.AGENT_SETTINGS_LOCK_KEY, async () => {
|
|
126794
|
+
const { stepEnabled: prevMap, ...rest } = await this.agentRows.get(nodeId) ?? { maxCameras: null };
|
|
126795
|
+
const { [stepId]: _drop, ...others } = prevMap ?? {};
|
|
126796
|
+
const next = enabled === null ? others : {
|
|
126797
|
+
...others,
|
|
126798
|
+
[stepId]: enabled
|
|
126799
|
+
};
|
|
126800
|
+
await this.agentRows.set(nodeId, {
|
|
126801
|
+
...rest,
|
|
126802
|
+
...Object.keys(next).length > 0 ? { stepEnabled: next } : {}
|
|
126803
|
+
});
|
|
126804
|
+
});
|
|
126805
|
+
}
|
|
126806
|
+
/**
|
|
126807
|
+
* Write one step's DEVICE switch on `(nodeId, deviceKey)` under the
|
|
126808
|
+
* agent-blob lock; `null` removes it (inherit). A step entry left empty is
|
|
126809
|
+
* pruned. A device with no stored entry gets one with `deviceEnabled` — its
|
|
126810
|
+
* current participation, which the caller read from the merged device view,
|
|
126811
|
+
* so writing a step switch never flips whether the device dispatches.
|
|
126812
|
+
*/
|
|
126813
|
+
async writeDeviceStepEnabled(input) {
|
|
126814
|
+
const { nodeId, deviceKey, stepId, enabled } = input;
|
|
126815
|
+
await this.blobWriteLock.run(PipelineSettingsStore.AGENT_SETTINGS_LOCK_KEY, async () => {
|
|
126816
|
+
const existing = await this.agentRows.get(nodeId) ?? { maxCameras: null };
|
|
126817
|
+
const devices = existing.inferenceDevices ?? {};
|
|
126818
|
+
const device = devices[deviceKey] ?? { enabled: input.deviceEnabled };
|
|
126819
|
+
const { [stepId]: prevStep, ...otherSteps } = device.steps ?? {};
|
|
126820
|
+
const { enabled: _drop, ...stepRest } = prevStep ?? {};
|
|
126821
|
+
const nextStep = enabled === null ? stepRest : {
|
|
126822
|
+
...stepRest,
|
|
126823
|
+
enabled
|
|
126824
|
+
};
|
|
126825
|
+
const steps = Object.keys(nextStep).length > 0 ? {
|
|
126826
|
+
...otherSteps,
|
|
126827
|
+
[stepId]: nextStep
|
|
126828
|
+
} : otherSteps;
|
|
126829
|
+
const { steps: _oldSteps, ...deviceRest } = device;
|
|
126830
|
+
await this.agentRows.set(nodeId, {
|
|
126831
|
+
...existing,
|
|
126832
|
+
inferenceDevices: {
|
|
126833
|
+
...devices,
|
|
126834
|
+
[deviceKey]: {
|
|
126835
|
+
...deviceRest,
|
|
126836
|
+
...Object.keys(steps).length > 0 ? { steps } : {}
|
|
126837
|
+
}
|
|
126838
|
+
}
|
|
126839
|
+
});
|
|
126840
|
+
});
|
|
126841
|
+
}
|
|
126170
126842
|
/** Purge one device's row. */
|
|
126171
126843
|
async deleteCameraSettings(deviceId) {
|
|
126172
126844
|
await this.cameraRows.remove(deviceId);
|
|
@@ -126412,8 +127084,8 @@ var PipelineSettingsStore = class PipelineSettingsStore {
|
|
|
126412
127084
|
* cannot run (D650 round 3) — what an attach needs to refuse a camera whose
|
|
126413
127085
|
* own detector would not run. Waits for the catalog exactly as it does.
|
|
126414
127086
|
*/
|
|
126415
|
-
async resolvePipelineForDeviceWithRoots(deviceId, agentNodeId, deviceKey, jumpDeviceKeys) {
|
|
126416
|
-
const outcome = await this.resolvePipelineWithCatalog(deviceId, agentNodeId, deviceKey, jumpDeviceKeys, { kind: "await" });
|
|
127087
|
+
async resolvePipelineForDeviceWithRoots(deviceId, agentNodeId, deviceKey, jumpDeviceKeys, defaultPool) {
|
|
127088
|
+
const outcome = await this.resolvePipelineWithCatalog(deviceId, agentNodeId, deviceKey, jumpDeviceKeys, { kind: "await" }, defaultPool);
|
|
126417
127089
|
if (outcome.kind === "resolved") return outcome;
|
|
126418
127090
|
throw new Error(`PipelineSettingsStore.resolvePipelineForDeviceWithRoots: catalog unavailable for "${outcome.nodeId}"`);
|
|
126419
127091
|
}
|
|
@@ -126426,10 +127098,10 @@ var PipelineSettingsStore = class PipelineSettingsStore {
|
|
|
126426
127098
|
* node; D49: never gate on a fallible read). A cold cache also starts one
|
|
126427
127099
|
* background refresh, so the next retry round finds the catalog.
|
|
126428
127100
|
*/
|
|
126429
|
-
async resolvePipelineForDeviceIfCatalogCached(deviceId, agentNodeId, deviceKey, jumpDeviceKeys) {
|
|
126430
|
-
return this.resolvePipelineWithCatalog(deviceId, agentNodeId, deviceKey, jumpDeviceKeys, { kind: "cached" });
|
|
127101
|
+
async resolvePipelineForDeviceIfCatalogCached(deviceId, agentNodeId, deviceKey, jumpDeviceKeys, defaultPool) {
|
|
127102
|
+
return this.resolvePipelineWithCatalog(deviceId, agentNodeId, deviceKey, jumpDeviceKeys, { kind: "cached" }, defaultPool);
|
|
126431
127103
|
}
|
|
126432
|
-
async resolvePipelineWithCatalog(deviceId, agentNodeIdOverride, deviceKey, jumpDeviceKeys, catalogRead) {
|
|
127104
|
+
async resolvePipelineWithCatalog(deviceId, agentNodeIdOverride, deviceKey, jumpDeviceKeys, catalogRead, defaultPool) {
|
|
126433
127105
|
const agentNodeId = agentNodeIdOverride ?? this.deps.getAssignmentNode(deviceId);
|
|
126434
127106
|
if (!agentNodeId) throw new Error(`PipelineSettingsStore.resolvePipelineForDevice: no node resolvable for device ${deviceId}`);
|
|
126435
127107
|
if (!await this.isDetectionPipelineActive(deviceId)) {
|
|
@@ -126463,14 +127135,39 @@ var PipelineSettingsStore = class PipelineSettingsStore {
|
|
|
126463
127135
|
}
|
|
126464
127136
|
const deviceFormat = deviceKey ? parseDeviceKey(deviceKey).format : catalog.selectedEngine.format;
|
|
126465
127137
|
const jumpFormats = [...new Set(jumpDeviceKeys.map((k) => parseDeviceKey(k).format))];
|
|
126466
|
-
const
|
|
126467
|
-
|
|
127138
|
+
const [clusterModes, node] = await Promise.all([this.readClusterStepModes(), this.agentRows.get(agentNodeId)]);
|
|
127139
|
+
const switches = {
|
|
127140
|
+
clusterModes,
|
|
127141
|
+
...node?.stepEnabled !== void 0 ? { nodeStepEnabled: node.stepEnabled } : {},
|
|
127142
|
+
electedDisabledSteps: deviceKey !== void 0 ? deviceDisabledSteps(node, deviceKey) : defaultPool !== void 0 ? poolDisabledSteps(node, defaultPool.eligibleKeys) : deviceDisabledSteps(node, ""),
|
|
127143
|
+
jumpTargets: jumpDeviceKeys.map((key) => ({
|
|
127144
|
+
deviceKey: key,
|
|
127145
|
+
format: parseDeviceKey(key).format,
|
|
127146
|
+
disabledSteps: deviceDisabledSteps(node, key)
|
|
127147
|
+
}))
|
|
127148
|
+
};
|
|
127149
|
+
const { config: resolvedBase, skipped, droppedRoots, packageAllowed } = resolvePipelineWithSkips(cam, deviceFormat, catalog, jumpFormats, switches);
|
|
127150
|
+
const formatSkips = skipped.filter((s) => !isSwitchSkip(s.reason));
|
|
127151
|
+
const switchSkips = skipped.filter((s) => isSwitchSkip(s.reason));
|
|
127152
|
+
const packageOverruled = hasPackageZone && !packageAllowed;
|
|
127153
|
+
if (switchSkips.length > 0 || packageOverruled) this.deps.logger.info(`pipeline steps switched off — skipped (node ${agentNodeId}, device ${deviceId})`, {
|
|
126468
127154
|
tags: {
|
|
126469
127155
|
deviceId,
|
|
126470
127156
|
nodeId: agentNodeId
|
|
126471
127157
|
},
|
|
126472
127158
|
meta: {
|
|
126473
|
-
skipped:
|
|
127159
|
+
skipped: [...switchSkips.map((s) => `${s.addonId}:${s.reason}`), ...packageOverruled ? [`${PACKAGE_DETECTION_STEP_ID}:switched-off`] : []].join(","),
|
|
127160
|
+
electedDeviceKey: deviceKey ?? null,
|
|
127161
|
+
jumpDeviceKeys: jumpDeviceKeys.join(",")
|
|
127162
|
+
}
|
|
127163
|
+
});
|
|
127164
|
+
if (formatSkips.length > 0) this.deps.logger.warn(`pipeline steps gated on but not provisioned on this node — skipped (node ${agentNodeId}, device ${deviceId})`, {
|
|
127165
|
+
tags: {
|
|
127166
|
+
deviceId,
|
|
127167
|
+
nodeId: agentNodeId
|
|
127168
|
+
},
|
|
127169
|
+
meta: {
|
|
127170
|
+
skipped: formatSkips.map((s) => `${s.addonId}:${s.reason}`).join(","),
|
|
126474
127171
|
electedDeviceKey: deviceKey ?? null,
|
|
126475
127172
|
electedFormat: deviceFormat,
|
|
126476
127173
|
jumpDeviceKeys: jumpDeviceKeys.join(","),
|
|
@@ -126479,7 +127176,7 @@ var PipelineSettingsStore = class PipelineSettingsStore {
|
|
|
126479
127176
|
});
|
|
126480
127177
|
const resolved = {
|
|
126481
127178
|
...resolvedBase,
|
|
126482
|
-
steps: applyPackageZoneActivation(resolvedBase.steps, hasPackageZone)
|
|
127179
|
+
steps: applyPackageZoneActivation(resolvedBase.steps, hasPackageZone && packageAllowed)
|
|
126483
127180
|
};
|
|
126484
127181
|
if (resolved.steps.length === 0) this.deps.logger.info("resolvePipelineForDevice → empty (all steps gated off/unprovisioned)", {
|
|
126485
127182
|
tags: {
|
|
@@ -126661,7 +127358,8 @@ var PipelineSettingsStore = class PipelineSettingsStore {
|
|
|
126661
127358
|
const out = /* @__PURE__ */ new Map();
|
|
126662
127359
|
for (const deviceKey of deviceKeys) out.set(deviceKey, {
|
|
126663
127360
|
base: nodeDeviceBase(node, deviceKey),
|
|
126664
|
-
override: cameraLayer
|
|
127361
|
+
override: cameraLayer,
|
|
127362
|
+
disabledSteps: [...deviceDisabledSteps(node, deviceKey)].toSorted()
|
|
126665
127363
|
});
|
|
126666
127364
|
return out;
|
|
126667
127365
|
}
|
|
@@ -131176,6 +131874,141 @@ async function buildOrchestratorControllers(deps) {
|
|
|
131176
131874
|
};
|
|
131177
131875
|
}
|
|
131178
131876
|
//#endregion
|
|
131877
|
+
//#region src/step-switch-matrix.ts
|
|
131878
|
+
/** ONE cell — the gate, then the placement, in the attach path's order. */
|
|
131879
|
+
function stepSwitchCell(input) {
|
|
131880
|
+
const { addon, elected } = input;
|
|
131881
|
+
const layers = {
|
|
131882
|
+
...input.clusterMode !== void 0 ? { clusterMode: input.clusterMode } : {},
|
|
131883
|
+
...input.nodeEnabled !== void 0 ? { nodeEnabled: input.nodeEnabled } : {}
|
|
131884
|
+
};
|
|
131885
|
+
const mode = effectiveClusterStepMode(addon, input.clusterMode);
|
|
131886
|
+
if (mode === "off") return { kind: "off-cluster" };
|
|
131887
|
+
if (addon.id === "package-detection") {
|
|
131888
|
+
const gate = gateStep(addon, {
|
|
131889
|
+
...layers,
|
|
131890
|
+
cameraToggle: true
|
|
131891
|
+
});
|
|
131892
|
+
if (gate.kind === "off") return gate.reason === "disabled-on-node" ? { kind: "off-node" } : { kind: "off-cluster" };
|
|
131893
|
+
return elected.disabledSteps.has(addon.id) ? { kind: "off-device" } : { kind: "zone-driven" };
|
|
131894
|
+
}
|
|
131895
|
+
if (mode === "opt-in" && input.camerasEnabling === 0) return { kind: "opt-in-unused" };
|
|
131896
|
+
const gate = gateStep(addon, {
|
|
131897
|
+
...layers,
|
|
131898
|
+
cameraToggle: true
|
|
131899
|
+
});
|
|
131900
|
+
if (gate.kind === "off") return gate.reason === "disabled-on-node" ? { kind: "off-node" } : { kind: "off-cluster" };
|
|
131901
|
+
const placement = placeStepOnDevices(addon, elected, input.roster);
|
|
131902
|
+
if (placement.kind === "run") return input.suppliedByRootModelId !== void 0 ? {
|
|
131903
|
+
kind: "supplied-by-root",
|
|
131904
|
+
rootModelId: input.suppliedByRootModelId
|
|
131905
|
+
} : { kind: "on" };
|
|
131906
|
+
if (placement.kind === "jump") return placement.toDeviceKey !== void 0 ? {
|
|
131907
|
+
kind: "jump",
|
|
131908
|
+
toDeviceKey: placement.toDeviceKey
|
|
131909
|
+
} : { kind: "on" };
|
|
131910
|
+
if (placement.reason === "disabled-on-device") return { kind: "off-device" };
|
|
131911
|
+
return {
|
|
131912
|
+
kind: "skip",
|
|
131913
|
+
reason: placement.reason
|
|
131914
|
+
};
|
|
131915
|
+
}
|
|
131916
|
+
/** The catalog's steps across every answering node, first-seen order, by id. */
|
|
131917
|
+
function catalogSteps(nodes) {
|
|
131918
|
+
const seen = /* @__PURE__ */ new Map();
|
|
131919
|
+
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);
|
|
131920
|
+
return [...seen.values()];
|
|
131921
|
+
}
|
|
131922
|
+
function findAddon(catalog, id) {
|
|
131923
|
+
for (const slot of catalog.slots) {
|
|
131924
|
+
const found = slot.addons.find((a) => a.id === id);
|
|
131925
|
+
if (found) return found;
|
|
131926
|
+
}
|
|
131927
|
+
}
|
|
131928
|
+
/**
|
|
131929
|
+
* The root model a device runs: its pin, else the model the executor elects
|
|
131930
|
+
* for the device when the root lists it, else the format default.
|
|
131931
|
+
*/
|
|
131932
|
+
function rootModelOn(root, device) {
|
|
131933
|
+
const pin = device.steps?.[OBJECT_DETECTION_STEP_ID]?.modelId;
|
|
131934
|
+
if (pin !== void 0) return pin;
|
|
131935
|
+
if (root.models.some((m) => m.id === device.defaultModelId)) return device.defaultModelId;
|
|
131936
|
+
return root.defaultModelIdByFormat?.[device.format] ?? root.defaultModelId;
|
|
131937
|
+
}
|
|
131938
|
+
/** The root model id when it supplies `stepId` on `device`, else undefined. */
|
|
131939
|
+
function suppliedByRoot(catalog, stepId, device, settings) {
|
|
131940
|
+
if (!isRootSuppliableStepId(stepId)) return void 0;
|
|
131941
|
+
const root = findAddon(catalog, OBJECT_DETECTION_STEP_ID);
|
|
131942
|
+
if (root === void 0) return void 0;
|
|
131943
|
+
const rootModelId = rootModelOn(root, device);
|
|
131944
|
+
const supplies = root.models.find((m) => m.id === rootModelId)?.suppliesSteps;
|
|
131945
|
+
const stepSettings = nodeDeviceBase(settings, device.key)[stepId]?.settings;
|
|
131946
|
+
return resolveRootSupply(stepId, stepSettings, supplies).effective ? rootModelId : void 0;
|
|
131947
|
+
}
|
|
131948
|
+
function slotOf(device, settings) {
|
|
131949
|
+
return {
|
|
131950
|
+
deviceKey: device.key,
|
|
131951
|
+
format: device.format,
|
|
131952
|
+
disabledSteps: deviceDisabledSteps(settings, device.key)
|
|
131953
|
+
};
|
|
131954
|
+
}
|
|
131955
|
+
function countToggles(toggles, stepId, value) {
|
|
131956
|
+
return toggles.filter((t) => t[stepId] === value).length;
|
|
131957
|
+
}
|
|
131958
|
+
function buildStepSwitchMatrix(input) {
|
|
131959
|
+
return { steps: catalogSteps(input.nodes).map((addon) => {
|
|
131960
|
+
const clusterMode = input.clusterModes[addon.id];
|
|
131961
|
+
const camerasEnabling = countToggles(input.cameraToggles, addon.id, true);
|
|
131962
|
+
const nodes = input.nodes.map((node) => {
|
|
131963
|
+
const nodeEnabled = node.settings?.stepEnabled?.[addon.id];
|
|
131964
|
+
const catalog = node.catalog;
|
|
131965
|
+
const devices = node.devices;
|
|
131966
|
+
const nodeAddon = catalog ? findAddon(catalog, addon.id) : void 0;
|
|
131967
|
+
if (catalog === null || devices === null || nodeAddon === void 0) return {
|
|
131968
|
+
nodeId: node.nodeId,
|
|
131969
|
+
reachable: false,
|
|
131970
|
+
stepEnabled: nodeEnabled ?? null,
|
|
131971
|
+
devices: []
|
|
131972
|
+
};
|
|
131973
|
+
const eligible = devices.filter((d) => d.exclusion === null);
|
|
131974
|
+
return {
|
|
131975
|
+
nodeId: node.nodeId,
|
|
131976
|
+
reachable: true,
|
|
131977
|
+
stepEnabled: nodeEnabled ?? null,
|
|
131978
|
+
devices: devices.map((device) => {
|
|
131979
|
+
const roster = eligible.length >= 2 ? eligible.filter((d) => d.key !== device.key).map((d) => slotOf(d, node.settings)) : [];
|
|
131980
|
+
const supplied = suppliedByRoot(catalog, addon.id, device, node.settings);
|
|
131981
|
+
return {
|
|
131982
|
+
deviceKey: device.key,
|
|
131983
|
+
format: device.format,
|
|
131984
|
+
stepEnabled: device.steps?.[addon.id]?.enabled ?? null,
|
|
131985
|
+
eligible: device.exclusion === null,
|
|
131986
|
+
cell: stepSwitchCell({
|
|
131987
|
+
addon: nodeAddon,
|
|
131988
|
+
clusterMode,
|
|
131989
|
+
camerasEnabling,
|
|
131990
|
+
nodeEnabled,
|
|
131991
|
+
elected: slotOf(device, node.settings),
|
|
131992
|
+
roster,
|
|
131993
|
+
...supplied !== void 0 ? { suppliedByRootModelId: supplied } : {}
|
|
131994
|
+
})
|
|
131995
|
+
};
|
|
131996
|
+
})
|
|
131997
|
+
};
|
|
131998
|
+
});
|
|
131999
|
+
return {
|
|
132000
|
+
stepId: addon.id,
|
|
132001
|
+
name: addon.name,
|
|
132002
|
+
slot: addon.slot,
|
|
132003
|
+
clusterMode: clusterMode ?? null,
|
|
132004
|
+
effectiveMode: effectiveClusterStepMode(addon, clusterMode),
|
|
132005
|
+
camerasEnabling,
|
|
132006
|
+
camerasDisabling: countToggles(input.cameraToggles, addon.id, false),
|
|
132007
|
+
nodes
|
|
132008
|
+
};
|
|
132009
|
+
}) };
|
|
132010
|
+
}
|
|
132011
|
+
//#endregion
|
|
131179
132012
|
//#region src/rebalance-suggestion.ts
|
|
131180
132013
|
var REBALANCE_SUGGESTED_ALERT_ID = "pipeline-orchestrator:rebalance-suggested";
|
|
131181
132014
|
var NODE_NOT_USED_ALERT_PREFIX = "pipeline-orchestrator:node-not-used:";
|
|
@@ -134279,14 +135112,15 @@ var PipelineOrchestratorAddon = class PipelineOrchestratorAddon extends BaseAddo
|
|
|
134279
135112
|
*/
|
|
134280
135113
|
async getNodeInferenceDevices(input) {
|
|
134281
135114
|
const nodeId = input.nodeId;
|
|
134282
|
-
const
|
|
135115
|
+
const node = (await this.settingsStore.readAgentSettingsMap())[nodeId];
|
|
135116
|
+
const stored = node?.inferenceDevices ?? {};
|
|
134283
135117
|
const { probed, reachable } = await this.probeNodeInferenceDevices(nodeId);
|
|
134284
135118
|
const catalog = await this.settingsStore.getCatalogForNode(nodeId);
|
|
134285
135119
|
const canRunRoot = catalog ? makeRootCapabilityGuard(catalog) : void 0;
|
|
134286
135120
|
return {
|
|
134287
135121
|
nodeId,
|
|
134288
135122
|
reachable,
|
|
134289
|
-
devices: annotateInferenceDeviceExclusions(mergeInferenceDevices(probed, stored), resolveInferenceDeviceEligibility(probed, stored, canRunRoot, (deviceKey) => this.inferenceDeviceUsability.isUsable(nodeId, deviceKey))).map((row) => !reachable && row.presence === "absent" ? {
|
|
135123
|
+
devices: annotateInferenceDeviceExclusions(mergeInferenceDevices(probed, stored), resolveInferenceDeviceEligibility(probed, stored, canRunRoot, (deviceKey) => this.inferenceDeviceUsability.isUsable(nodeId, deviceKey), catalog ? makeRootSwitchGuard(catalog, await this.settingsStore.readClusterStepModes(), node) : void 0)).map((row) => !reachable && row.presence === "absent" ? {
|
|
134290
135124
|
...row,
|
|
134291
135125
|
presence: "unknown"
|
|
134292
135126
|
} : row)
|
|
@@ -134468,7 +135302,8 @@ var PipelineOrchestratorAddon = class PipelineOrchestratorAddon extends BaseAddo
|
|
|
134468
135302
|
}
|
|
134469
135303
|
/** Eligibility from a device list + catalog; records usability like every dispatch read. */
|
|
134470
135304
|
async electableDevices(nodeId, probed, catalog) {
|
|
134471
|
-
const
|
|
135305
|
+
const node = (await this.settingsStore.readAgentSettingsMap())[nodeId];
|
|
135306
|
+
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);
|
|
134472
135307
|
const { eligible, excluded } = eligibility;
|
|
134473
135308
|
this.logInferenceDeviceShrinkage(nodeId, eligible, excluded);
|
|
134474
135309
|
this.noteNodeInferenceUsability(nodeId, resolveNodeInferenceUsability(eligibility));
|
|
@@ -134909,7 +135744,7 @@ var PipelineOrchestratorAddon = class PipelineOrchestratorAddon extends BaseAddo
|
|
|
134909
135744
|
topologySignature: async () => {
|
|
134910
135745
|
const nodeIds = [...new Set(["hub", ...this.topology.collectRunnerNodeIds()])];
|
|
134911
135746
|
const blob = await store.readAgentSettingsMap();
|
|
134912
|
-
return shareTopologySignature(nodeIds, blob, this.liveDevicesByNode(nodeIds, blob));
|
|
135747
|
+
return shareTopologySignature(nodeIds, blob, this.liveDevicesByNode(nodeIds, blob, await store.readClusterStepModes()));
|
|
134913
135748
|
},
|
|
134914
135749
|
logger: this.ctx.logger
|
|
134915
135750
|
});
|
|
@@ -134922,14 +135757,14 @@ var PipelineOrchestratorAddon = class PipelineOrchestratorAddon extends BaseAddo
|
|
|
134922
135757
|
* call: a node never probed contributes nothing, and the probe that first
|
|
134923
135758
|
* answers announces itself through {@link noteInferenceDeviceProbe}.
|
|
134924
135759
|
*/
|
|
134925
|
-
liveDevicesByNode(nodeIds, blob) {
|
|
135760
|
+
liveDevicesByNode(nodeIds, blob, clusterModes) {
|
|
134926
135761
|
const out = {};
|
|
134927
135762
|
for (const nodeId of nodeIds) {
|
|
134928
135763
|
const probed = this.lastInferenceDeviceProbe.get(nodeId);
|
|
134929
135764
|
if (probed === void 0) continue;
|
|
134930
135765
|
const stored = blob[nodeId]?.inferenceDevices ?? {};
|
|
134931
135766
|
const catalog = this.settingsStore.peekCatalogForAgent(nodeId);
|
|
134932
|
-
const eligibility = resolveInferenceDeviceEligibility(probed, stored, catalog ? makeRootCapabilityGuard(catalog) : void 0, (deviceKey) => this.inferenceDeviceUsability.isUsable(nodeId, deviceKey));
|
|
135767
|
+
const eligibility = resolveInferenceDeviceEligibility(probed, stored, catalog ? makeRootCapabilityGuard(catalog) : void 0, (deviceKey) => this.inferenceDeviceUsability.isUsable(nodeId, deviceKey), catalog ? makeRootSwitchGuard(catalog, clusterModes, blob[nodeId]) : void 0);
|
|
134933
135768
|
out[nodeId] = annotateInferenceDeviceExclusions(mergeInferenceDevices(probed, stored), eligibility).map((d) => ({
|
|
134934
135769
|
key: d.key,
|
|
134935
135770
|
available: d.available,
|
|
@@ -135046,7 +135881,7 @@ var PipelineOrchestratorAddon = class PipelineOrchestratorAddon extends BaseAddo
|
|
|
135046
135881
|
readNodes: async () => {
|
|
135047
135882
|
const online = this.topology.collectRunnerNodeIds();
|
|
135048
135883
|
const blob = await this.settingsStore.readAgentSettingsMap();
|
|
135049
|
-
const live = this.liveDevicesByNode(online, blob);
|
|
135884
|
+
const live = this.liveDevicesByNode(online, blob, await this.settingsStore.readClusterStepModes());
|
|
135050
135885
|
return readAutoBenchNodes({
|
|
135051
135886
|
onlineNodeIds: online,
|
|
135052
135887
|
liveDevices: (nodeId) => live[nodeId],
|
|
@@ -135314,7 +136149,95 @@ var PipelineOrchestratorAddon = class PipelineOrchestratorAddon extends BaseAddo
|
|
|
135314
136149
|
return { success: true };
|
|
135315
136150
|
}
|
|
135316
136151
|
async resolvePipeline(input) {
|
|
135317
|
-
|
|
136152
|
+
const nodeId = input.agentNodeId ?? this.placement.getPipelineAssignment({ deviceId: input.deviceId })?.agentNodeId ?? this.localNodeId;
|
|
136153
|
+
const outcome = await this.placement.previewAttachPipeline({
|
|
136154
|
+
deviceId: input.deviceId,
|
|
136155
|
+
nodeId
|
|
136156
|
+
});
|
|
136157
|
+
if (outcome.kind === "root-refused") return {
|
|
136158
|
+
steps: [],
|
|
136159
|
+
audio: null
|
|
136160
|
+
};
|
|
136161
|
+
return {
|
|
136162
|
+
steps: outcome.pipeline.steps,
|
|
136163
|
+
audio: outcome.pipeline.audio ?? null
|
|
136164
|
+
};
|
|
136165
|
+
}
|
|
136166
|
+
/** Set one step's cluster mode; `null` returns it to the catalog default. */
|
|
136167
|
+
async setClusterStepMode(input) {
|
|
136168
|
+
await this.settingsStore.writeClusterStepMode(input.stepId, input.mode);
|
|
136169
|
+
this.ctx.logger.info("cluster step mode written", { meta: {
|
|
136170
|
+
stepId: input.stepId,
|
|
136171
|
+
mode: input.mode ?? "default"
|
|
136172
|
+
} });
|
|
136173
|
+
await this.placement.reattachForStepSwitch(null, `cluster:${input.stepId}`);
|
|
136174
|
+
return { success: true };
|
|
136175
|
+
}
|
|
136176
|
+
/** Set one step's node switch; `null` = inherit. */
|
|
136177
|
+
async setNodeStepEnabled(input) {
|
|
136178
|
+
await this.settingsStore.writeNodeStepEnabled(input.agentNodeId, input.stepId, input.enabled);
|
|
136179
|
+
this.ctx.logger.info("node step switch written", {
|
|
136180
|
+
tags: { nodeId: input.agentNodeId },
|
|
136181
|
+
meta: {
|
|
136182
|
+
stepId: input.stepId,
|
|
136183
|
+
enabled: input.enabled ?? "inherit"
|
|
136184
|
+
}
|
|
136185
|
+
});
|
|
136186
|
+
await this.placement.reattachForStepSwitch(input.agentNodeId, `node:${input.stepId}`);
|
|
136187
|
+
return { success: true };
|
|
136188
|
+
}
|
|
136189
|
+
/**
|
|
136190
|
+
* Set one step's device switch; `null` = inherit. Refuses a device the node
|
|
136191
|
+
* does not list (neither probed nor stored) — a switch on a key nothing
|
|
136192
|
+
* dispatches to would be silently inert.
|
|
136193
|
+
*/
|
|
136194
|
+
async setDeviceStepEnabled(input) {
|
|
136195
|
+
const device = (await this.getNodeInferenceDevices({ nodeId: input.agentNodeId })).devices.find((d) => d.key === input.deviceKey);
|
|
136196
|
+
if (device === void 0) throw new Error(`setDeviceStepEnabled: node "${input.agentNodeId}" has no inference device "${input.deviceKey}"`);
|
|
136197
|
+
await this.settingsStore.writeDeviceStepEnabled({
|
|
136198
|
+
nodeId: input.agentNodeId,
|
|
136199
|
+
deviceKey: input.deviceKey,
|
|
136200
|
+
stepId: input.stepId,
|
|
136201
|
+
enabled: input.enabled,
|
|
136202
|
+
deviceEnabled: device.enabled
|
|
136203
|
+
});
|
|
136204
|
+
this.ctx.logger.info("device step switch written", {
|
|
136205
|
+
tags: { nodeId: input.agentNodeId },
|
|
136206
|
+
meta: {
|
|
136207
|
+
deviceKey: input.deviceKey,
|
|
136208
|
+
stepId: input.stepId,
|
|
136209
|
+
enabled: input.enabled ?? "inherit"
|
|
136210
|
+
}
|
|
136211
|
+
});
|
|
136212
|
+
await this.placement.reattachForStepSwitch(input.agentNodeId, `device:${input.stepId}`);
|
|
136213
|
+
return { success: true };
|
|
136214
|
+
}
|
|
136215
|
+
/**
|
|
136216
|
+
* The step switch matrix — cells computed by the attach path's own gate and
|
|
136217
|
+
* placement (`step-switch-matrix.ts`). A node whose catalog or device probe
|
|
136218
|
+
* does not answer is listed `reachable: false` with no cells.
|
|
136219
|
+
*/
|
|
136220
|
+
async getStepSwitches() {
|
|
136221
|
+
const store = this.settingsStore;
|
|
136222
|
+
const [clusterModes, agentMap, cameraMap] = await Promise.all([
|
|
136223
|
+
store.readClusterStepModes(),
|
|
136224
|
+
store.readAgentSettingsMap(),
|
|
136225
|
+
store.readCameraSettingsMap()
|
|
136226
|
+
]);
|
|
136227
|
+
const nodes = await Promise.all(Object.keys(agentMap).toSorted().map(async (nodeId) => {
|
|
136228
|
+
const [catalog, view] = await Promise.all([store.getCatalogForNode(nodeId).catch(() => null), this.getNodeInferenceDevices({ nodeId }).catch(() => null)]);
|
|
136229
|
+
return {
|
|
136230
|
+
nodeId,
|
|
136231
|
+
catalog,
|
|
136232
|
+
devices: view?.reachable === true ? view.devices : null,
|
|
136233
|
+
settings: agentMap[nodeId]
|
|
136234
|
+
};
|
|
136235
|
+
}));
|
|
136236
|
+
return buildStepSwitchMatrix({
|
|
136237
|
+
clusterModes,
|
|
136238
|
+
cameraToggles: Object.values(cameraMap).map((c) => c.stepToggles ?? {}),
|
|
136239
|
+
nodes
|
|
136240
|
+
});
|
|
135318
136241
|
}
|
|
135319
136242
|
/** Emit `pipeline.camera-updated` carrying the freshly-resolved config. */
|
|
135320
136243
|
async emitResolvedCameraUpdated(deviceId) {
|