@camstack/addon-pipeline-orchestrator 1.2.654 → 1.2.655
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 +6 -0
- package/dist/{_virtual_mf-localSharedImportMap___mfe_internal__addon_pipeline_orchestrator_widgets-DsWUbwWZ.mjs → _virtual_mf-localSharedImportMap___mfe_internal__addon_pipeline_orchestrator_widgets-BaY1hyoO.mjs} +1 -1
- package/dist/{hostInit-2bk84xSF.mjs → hostInit-Ck0vdKwf.mjs} +1 -1
- package/dist/index.js +376 -122
- package/dist/index.mjs +376 -122
- package/dist/remoteEntry.js +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -6012,7 +6012,7 @@ var ZodIssueCode = {
|
|
|
6012
6012
|
var ZodFirstPartyTypeKind;
|
|
6013
6013
|
ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {});
|
|
6014
6014
|
//#endregion
|
|
6015
|
-
//#region ../types/dist/sleep-
|
|
6015
|
+
//#region ../types/dist/sleep-DV4qxEyD.mjs
|
|
6016
6016
|
/**
|
|
6017
6017
|
* The audio chunk plane's byte format, and the ONE expansion from a coded
|
|
6018
6018
|
* window to float samples (D455).
|
|
@@ -8116,6 +8116,10 @@ var BaseAddon = class {
|
|
|
8116
8116
|
const stored = keychain ? await this.readAddonStoreWithRetry() : {};
|
|
8117
8117
|
const patch = {};
|
|
8118
8118
|
for (const key of keys) {
|
|
8119
|
+
if (tree.get(key)?.kind === "array") {
|
|
8120
|
+
patch[key] = [];
|
|
8121
|
+
continue;
|
|
8122
|
+
}
|
|
8119
8123
|
const keychainStored = tree.has(key) || collectSecretMarkerRefs(stored[key]).length > 0;
|
|
8120
8124
|
patch[key] = keychain && keychainStored ? SECRET_CLEAR : "";
|
|
8121
8125
|
}
|
|
@@ -94833,9 +94837,114 @@ async function readRawKeys(read, addonId, keys) {
|
|
|
94833
94837
|
return found;
|
|
94834
94838
|
}
|
|
94835
94839
|
//#endregion
|
|
94840
|
+
//#region src/migrations/blob-to-rows.ts
|
|
94841
|
+
/**
|
|
94842
|
+
* The orchestrator's three id-keyed JSON maps become one row per id (D986 §2):
|
|
94843
|
+
*
|
|
94844
|
+
* - `nodeBindings` and `agentSettings` (a map keyed on node id) become node rows
|
|
94845
|
+
* `<addonId>.<field>@<nodeId>` in `addon-settings`, carrying `nodeId`;
|
|
94846
|
+
* - `cameraSettings` (a map keyed on device id) becomes one device row
|
|
94847
|
+
* `<addonId>:<deviceId>.cameraSettings` in `addon-device-settings`.
|
|
94848
|
+
*
|
|
94849
|
+
* Each entry is copied VERBATIM (the value of a row is the entry the map held), so a field the
|
|
94850
|
+
* schema does not know yet survives byte for byte. The map key stays for a release (the purge is
|
|
94851
|
+
* `retired-settings-keys.ts`, one release later), so a rolled-back build still reads it.
|
|
94852
|
+
*
|
|
94853
|
+
* A row that already exists is never overwritten: it was written by the build that reads rows,
|
|
94854
|
+
* and a seed never overwrites. A plan that has nothing left to copy is empty, so a second run is
|
|
94855
|
+
* a no-op. A read that fails throws, and nothing is written. A map whose shape is not a map of
|
|
94856
|
+
* objects throws too: copying part of it would leave the readers with a half-moved store.
|
|
94857
|
+
*/
|
|
94858
|
+
/** The per-device settings table: one row per field, id `<addonId>:<deviceId>.<field>`. */
|
|
94859
|
+
var ADDON_DEVICE_SETTINGS_TABLE = "addon-device-settings";
|
|
94860
|
+
var isRecord = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
94861
|
+
/** A node id the orchestrator itself refuses to persist (`writeAgentSettings`): never a real node. */
|
|
94862
|
+
var GHOST_NODE_IDS = new Set([
|
|
94863
|
+
"",
|
|
94864
|
+
"undefined",
|
|
94865
|
+
"null"
|
|
94866
|
+
]);
|
|
94867
|
+
function entriesOf(field, blob) {
|
|
94868
|
+
if (blob === void 0) return [];
|
|
94869
|
+
if (!isRecord(blob)) throw new Error(`${field} is not a map: it is left as it is`);
|
|
94870
|
+
return Object.entries(blob).map(([id, entry]) => {
|
|
94871
|
+
if (!isRecord(entry)) throw new Error(`${field}[${id}] is not an object: nothing is copied, fix it and retry`);
|
|
94872
|
+
return [id, entry];
|
|
94873
|
+
});
|
|
94874
|
+
}
|
|
94875
|
+
/** Copy each node's entry of `field` to its node row `<field>@<nodeId>`. */
|
|
94876
|
+
async function planBlobToNodeRows(addonId, field, ports) {
|
|
94877
|
+
const blob = (await ports.readStored([field]))[field];
|
|
94878
|
+
const entries = entriesOf(field, blob).filter(([nodeId]) => !GHOST_NODE_IDS.has(nodeId) && !nodeId.includes("@"));
|
|
94879
|
+
if (entries.length === 0) return { edits: [] };
|
|
94880
|
+
const rowKey = (nodeId) => `${field}@${nodeId}`;
|
|
94881
|
+
const existing = await ports.readStored(entries.map(([nodeId]) => rowKey(nodeId)));
|
|
94882
|
+
const values = {};
|
|
94883
|
+
for (const [nodeId, entry] of entries) {
|
|
94884
|
+
if (rowKey(nodeId) in existing) continue;
|
|
94885
|
+
values[`${addonId}.${rowKey(nodeId)}`] = {
|
|
94886
|
+
addonId,
|
|
94887
|
+
key: rowKey(nodeId),
|
|
94888
|
+
value: entry,
|
|
94889
|
+
nodeId
|
|
94890
|
+
};
|
|
94891
|
+
}
|
|
94892
|
+
const ids = Object.keys(values);
|
|
94893
|
+
if (ids.length === 0) return { edits: [] };
|
|
94894
|
+
return { edits: [{
|
|
94895
|
+
op: "setKeys",
|
|
94896
|
+
scope: ADDON_SETTINGS_TABLE,
|
|
94897
|
+
values,
|
|
94898
|
+
precondition: preconditionOf(Object.fromEntries(ids.map((id) => [id, null])))
|
|
94899
|
+
}] };
|
|
94900
|
+
}
|
|
94901
|
+
/** A device id as the blob spells it: a positive integer. */
|
|
94902
|
+
function deviceIdOf(key) {
|
|
94903
|
+
const id = Number(key);
|
|
94904
|
+
return Number.isInteger(id) && id > 0 && String(id) === key ? id : null;
|
|
94905
|
+
}
|
|
94906
|
+
/** Copy each device's entry of `field` to its device row `<addonId>:<deviceId>.<field>`. */
|
|
94907
|
+
async function planBlobToDeviceRows(addonId, field, ports) {
|
|
94908
|
+
const blob = (await ports.readStored([field]))[field];
|
|
94909
|
+
const entries = entriesOf(field, blob).flatMap(([key, entry]) => {
|
|
94910
|
+
const deviceId = deviceIdOf(key);
|
|
94911
|
+
return deviceId === null ? [] : [{
|
|
94912
|
+
deviceId,
|
|
94913
|
+
entry
|
|
94914
|
+
}];
|
|
94915
|
+
});
|
|
94916
|
+
if (entries.length === 0) return { edits: [] };
|
|
94917
|
+
const existing = await ports.readDeviceField(entries.map((e) => e.deviceId), field);
|
|
94918
|
+
const values = {};
|
|
94919
|
+
for (const { deviceId, entry } of entries) {
|
|
94920
|
+
if (existing.has(deviceId)) continue;
|
|
94921
|
+
values[`${addonId}:${deviceId}.${field}`] = {
|
|
94922
|
+
addonId,
|
|
94923
|
+
deviceId: String(deviceId),
|
|
94924
|
+
key: field,
|
|
94925
|
+
value: entry
|
|
94926
|
+
};
|
|
94927
|
+
}
|
|
94928
|
+
const ids = Object.keys(values);
|
|
94929
|
+
if (ids.length === 0) return { edits: [] };
|
|
94930
|
+
return { edits: [{
|
|
94931
|
+
op: "setKeys",
|
|
94932
|
+
scope: ADDON_DEVICE_SETTINGS_TABLE,
|
|
94933
|
+
values,
|
|
94934
|
+
precondition: preconditionOf(Object.fromEntries(ids.map((id) => [id, null])))
|
|
94935
|
+
}] };
|
|
94936
|
+
}
|
|
94937
|
+
//#endregion
|
|
94836
94938
|
//#region src/migrations/index.ts
|
|
94837
94939
|
var PIPELINE_ORCHESTRATOR_ID = "pipeline-orchestrator";
|
|
94838
94940
|
var DROP_BINDINGS_MIGRATION_FLAG_ID = "pipeline-orchestrator/2026-11-03-drop-bindings-migration-flag";
|
|
94941
|
+
var NODE_BINDINGS_TO_NODE_ROWS_ID = "pipeline-orchestrator/2026-11-03-node-bindings-to-node-rows";
|
|
94942
|
+
var AGENT_SETTINGS_TO_NODE_ROWS_ID = "pipeline-orchestrator/2026-11-03-agent-settings-to-node-rows";
|
|
94943
|
+
var CAMERA_SETTINGS_TO_DEVICE_ROWS_ID = "pipeline-orchestrator/2026-11-03-camera-settings-to-device-rows";
|
|
94944
|
+
/** The three id-keyed maps this version stopped reading; their keys stay one release. */
|
|
94945
|
+
var NODE_BINDINGS_FIELD = "nodeBindings";
|
|
94946
|
+
var AGENT_SETTINGS_FIELD = "agentSettings";
|
|
94947
|
+
var CAMERA_SETTINGS_FIELD = "cameraSettings";
|
|
94839
94948
|
/** The one-shot flag of the retired legacy-flags-to-bindings carry-over; the D987 ledger replaces it. */
|
|
94840
94949
|
var RETIRED_FLAG_KEYS = ["bindingsMigration_v1_done"];
|
|
94841
94950
|
/**
|
|
@@ -94850,22 +94959,72 @@ async function planDropFlag(ports) {
|
|
|
94850
94959
|
return planDropKeys(PIPELINE_ORCHESTRATOR_ID, RETIRED_FLAG_KEYS, ports);
|
|
94851
94960
|
}
|
|
94852
94961
|
/** The `pipeline-orchestrator` catalogue (D987): offered to the engine when the addon initialises. */
|
|
94853
|
-
var ADDON_MIGRATIONS = [
|
|
94854
|
-
|
|
94855
|
-
|
|
94856
|
-
|
|
94857
|
-
|
|
94858
|
-
|
|
94859
|
-
|
|
94860
|
-
|
|
94861
|
-
|
|
94862
|
-
|
|
94863
|
-
|
|
94864
|
-
|
|
94865
|
-
|
|
94866
|
-
|
|
94867
|
-
|
|
94868
|
-
|
|
94962
|
+
var ADDON_MIGRATIONS = [
|
|
94963
|
+
{
|
|
94964
|
+
meta: {
|
|
94965
|
+
id: DROP_BINDINGS_MIGRATION_FLAG_ID,
|
|
94966
|
+
owner: PIPELINE_ORCHESTRATOR_ID,
|
|
94967
|
+
level: "addon-state",
|
|
94968
|
+
seq: 1,
|
|
94969
|
+
dependsOn: [],
|
|
94970
|
+
store: "settings",
|
|
94971
|
+
scope: "cluster",
|
|
94972
|
+
onFailure: "tolerate",
|
|
94973
|
+
bodyKind: "plan",
|
|
94974
|
+
description: "Delete the one-shot flag of the retired legacy-flags-to-bindings carry-over",
|
|
94975
|
+
fixtureMark: "a setting the migration does not know"
|
|
94976
|
+
},
|
|
94977
|
+
plan: planDropFlag
|
|
94978
|
+
},
|
|
94979
|
+
{
|
|
94980
|
+
meta: {
|
|
94981
|
+
id: NODE_BINDINGS_TO_NODE_ROWS_ID,
|
|
94982
|
+
owner: PIPELINE_ORCHESTRATOR_ID,
|
|
94983
|
+
level: "addon-state",
|
|
94984
|
+
seq: 2,
|
|
94985
|
+
dependsOn: [],
|
|
94986
|
+
store: "settings",
|
|
94987
|
+
scope: "per-node",
|
|
94988
|
+
onFailure: "block-owner",
|
|
94989
|
+
bodyKind: "plan",
|
|
94990
|
+
description: "Explode the node-keyed nodeBindings map into one node row per node",
|
|
94991
|
+
fixtureMark: "a capability binding of one node, and a node that only this map holds"
|
|
94992
|
+
},
|
|
94993
|
+
plan: (ports) => planBlobToNodeRows(PIPELINE_ORCHESTRATOR_ID, NODE_BINDINGS_FIELD, ports)
|
|
94994
|
+
},
|
|
94995
|
+
{
|
|
94996
|
+
meta: {
|
|
94997
|
+
id: AGENT_SETTINGS_TO_NODE_ROWS_ID,
|
|
94998
|
+
owner: PIPELINE_ORCHESTRATOR_ID,
|
|
94999
|
+
level: "addon-state",
|
|
95000
|
+
seq: 3,
|
|
95001
|
+
dependsOn: [NODE_BINDINGS_TO_NODE_ROWS_ID],
|
|
95002
|
+
store: "settings",
|
|
95003
|
+
scope: "per-node",
|
|
95004
|
+
onFailure: "block-owner",
|
|
95005
|
+
bodyKind: "plan",
|
|
95006
|
+
description: "Explode the node-keyed agentSettings map into one node row per node",
|
|
95007
|
+
fixtureMark: "a detection weight and a pinned model of one node"
|
|
95008
|
+
},
|
|
95009
|
+
plan: (ports) => planBlobToNodeRows(PIPELINE_ORCHESTRATOR_ID, AGENT_SETTINGS_FIELD, ports)
|
|
95010
|
+
},
|
|
95011
|
+
{
|
|
95012
|
+
meta: {
|
|
95013
|
+
id: CAMERA_SETTINGS_TO_DEVICE_ROWS_ID,
|
|
95014
|
+
owner: PIPELINE_ORCHESTRATOR_ID,
|
|
95015
|
+
level: "addon-state",
|
|
95016
|
+
seq: 4,
|
|
95017
|
+
dependsOn: [AGENT_SETTINGS_TO_NODE_ROWS_ID],
|
|
95018
|
+
store: "settings",
|
|
95019
|
+
scope: "cluster",
|
|
95020
|
+
onFailure: "block-owner",
|
|
95021
|
+
bodyKind: "plan",
|
|
95022
|
+
description: "Explode the device-keyed cameraSettings map into one device row per camera",
|
|
95023
|
+
fixtureMark: "a step toggle and a step setting of one camera"
|
|
95024
|
+
},
|
|
95025
|
+
plan: (ports) => planBlobToDeviceRows(PIPELINE_ORCHESTRATOR_ID, CAMERA_SETTINGS_FIELD, ports)
|
|
95026
|
+
}
|
|
95027
|
+
];
|
|
94869
95028
|
var orchestratorRecordKinds = defineRecordKinds({
|
|
94870
95029
|
/**
|
|
94871
95030
|
* One row per APPLIED failover move. The id is `${deviceId}:${at}`.
|
|
@@ -107420,6 +107579,8 @@ async function redispatchAffected(deps, cleared) {
|
|
|
107420
107579
|
* schema is kept faithful to the on-disk shape rather than overly strict.
|
|
107421
107580
|
*/
|
|
107422
107581
|
var NodeBindingsSchema = record(string(), record(string(), string()));
|
|
107582
|
+
/** One node's entry of the map: `capName -> addonId`, the value of its `nodeBindings@<node>` row. */
|
|
107583
|
+
var StoredNodeBindingsSchema = record(string(), string());
|
|
107423
107584
|
var AutoBenchmarkAttemptsSchema = record(string(), record(string(), object({
|
|
107424
107585
|
count: number().int().min(0),
|
|
107425
107586
|
lastAtMs: number()
|
|
@@ -107455,6 +107616,118 @@ var StoredCameraPipelineSettingsSchema = object({
|
|
|
107455
107616
|
});
|
|
107456
107617
|
var CameraSettingsMapSchema = record(string(), StoredCameraPipelineSettingsSchema);
|
|
107457
107618
|
//#endregion
|
|
107619
|
+
//#region src/orchestrator-row-maps.ts
|
|
107620
|
+
/** A node id that is a real one: the orchestrator refuses to persist the others. */
|
|
107621
|
+
var isNodeId = (nodeId) => nodeId.length > 0 && nodeId !== "undefined" && nodeId !== "null" && !nodeId.includes("@");
|
|
107622
|
+
/** One node row per node: `<field>@<nodeId>`. */
|
|
107623
|
+
var NodeRows = class {
|
|
107624
|
+
deps;
|
|
107625
|
+
field;
|
|
107626
|
+
schema;
|
|
107627
|
+
constructor(deps, field, schema) {
|
|
107628
|
+
this.deps = deps;
|
|
107629
|
+
this.field = field;
|
|
107630
|
+
this.schema = schema;
|
|
107631
|
+
}
|
|
107632
|
+
keyOf(nodeId) {
|
|
107633
|
+
return `${this.field}@${nodeId}`;
|
|
107634
|
+
}
|
|
107635
|
+
parse(nodeId, raw) {
|
|
107636
|
+
if (raw === void 0) return void 0;
|
|
107637
|
+
const parsed = this.schema.safeParse(raw);
|
|
107638
|
+
if (parsed.success) return parsed.data;
|
|
107639
|
+
this.deps.logger.warn(`${this.field} row failed validation — ignored`, {
|
|
107640
|
+
tags: { nodeId },
|
|
107641
|
+
meta: {
|
|
107642
|
+
field: this.field,
|
|
107643
|
+
error: parsed.error.message
|
|
107644
|
+
}
|
|
107645
|
+
});
|
|
107646
|
+
}
|
|
107647
|
+
async get(nodeId) {
|
|
107648
|
+
return this.parse(nodeId, (await this.deps.readStore())[this.keyOf(nodeId)]);
|
|
107649
|
+
}
|
|
107650
|
+
/** Every node that has a row, by node id. */
|
|
107651
|
+
async getAll() {
|
|
107652
|
+
const prefix = `${this.field}@`;
|
|
107653
|
+
const out = {};
|
|
107654
|
+
for (const [key, raw] of Object.entries(await this.deps.readStore())) {
|
|
107655
|
+
if (!key.startsWith(prefix)) continue;
|
|
107656
|
+
const nodeId = key.slice(prefix.length);
|
|
107657
|
+
if (!isNodeId(nodeId)) continue;
|
|
107658
|
+
const value = this.parse(nodeId, raw);
|
|
107659
|
+
if (value !== void 0) out[nodeId] = value;
|
|
107660
|
+
}
|
|
107661
|
+
return out;
|
|
107662
|
+
}
|
|
107663
|
+
async set(nodeId, value) {
|
|
107664
|
+
await this.deps.state(this.keyOf(nodeId), this.schema, value).set(value);
|
|
107665
|
+
}
|
|
107666
|
+
/** Delete the node's row; whether one existed. A failed read throws. */
|
|
107667
|
+
async remove(nodeId) {
|
|
107668
|
+
if (!(this.keyOf(nodeId) in await this.deps.readStore())) return false;
|
|
107669
|
+
const optional = this.schema.optional();
|
|
107670
|
+
await this.deps.state(this.keyOf(nodeId), optional, void 0).set(void 0);
|
|
107671
|
+
return true;
|
|
107672
|
+
}
|
|
107673
|
+
/**
|
|
107674
|
+
* Make the rows equal `next` given they held `prev`: a node whose entry changed is written, a
|
|
107675
|
+
* node that is gone is removed, an untouched node is not written at all.
|
|
107676
|
+
*/
|
|
107677
|
+
async applyDiff(prev, next) {
|
|
107678
|
+
for (const [nodeId, value] of Object.entries(next)) if (JSON.stringify(prev[nodeId]) !== JSON.stringify(value)) await this.set(nodeId, value);
|
|
107679
|
+
for (const nodeId of Object.keys(prev)) if (!(nodeId in next)) await this.remove(nodeId);
|
|
107680
|
+
}
|
|
107681
|
+
};
|
|
107682
|
+
/** One field of the per-device store, per device. */
|
|
107683
|
+
var DeviceRows = class {
|
|
107684
|
+
deps;
|
|
107685
|
+
field;
|
|
107686
|
+
schema;
|
|
107687
|
+
constructor(deps, field, schema) {
|
|
107688
|
+
this.deps = deps;
|
|
107689
|
+
this.field = field;
|
|
107690
|
+
this.schema = schema;
|
|
107691
|
+
}
|
|
107692
|
+
port() {
|
|
107693
|
+
const port = this.deps.deviceSettings();
|
|
107694
|
+
if (port === null) throw new Error(`${this.field}: the per-device settings store is unavailable`);
|
|
107695
|
+
return port;
|
|
107696
|
+
}
|
|
107697
|
+
parse(deviceId, blob) {
|
|
107698
|
+
const raw = blob[this.field];
|
|
107699
|
+
if (raw === void 0) return void 0;
|
|
107700
|
+
const parsed = this.schema.safeParse(raw);
|
|
107701
|
+
if (parsed.success) return parsed.data;
|
|
107702
|
+
this.deps.logger.warn(`${this.field} row failed validation — ignored`, {
|
|
107703
|
+
tags: { deviceId },
|
|
107704
|
+
meta: {
|
|
107705
|
+
field: this.field,
|
|
107706
|
+
error: parsed.error.message
|
|
107707
|
+
}
|
|
107708
|
+
});
|
|
107709
|
+
}
|
|
107710
|
+
async get(deviceId) {
|
|
107711
|
+
return this.parse(deviceId, await this.port().readDeviceStore(deviceId));
|
|
107712
|
+
}
|
|
107713
|
+
/** Every device that has the field, by device id as a string (the legacy map's key). */
|
|
107714
|
+
async getAll() {
|
|
107715
|
+
const port = this.port();
|
|
107716
|
+
const out = {};
|
|
107717
|
+
for (const [deviceId, blob] of await port.readDeviceStoreBatch(await port.listDeviceStoreIds())) {
|
|
107718
|
+
const value = this.parse(deviceId, blob);
|
|
107719
|
+
if (value !== void 0) out[String(deviceId)] = value;
|
|
107720
|
+
}
|
|
107721
|
+
return out;
|
|
107722
|
+
}
|
|
107723
|
+
async set(deviceId, value) {
|
|
107724
|
+
await this.port().writeDeviceStore(deviceId, { [this.field]: this.schema.parse(value) });
|
|
107725
|
+
}
|
|
107726
|
+
async remove(deviceId) {
|
|
107727
|
+
await this.port().writeDeviceStore(deviceId, { [this.field]: void 0 });
|
|
107728
|
+
}
|
|
107729
|
+
};
|
|
107730
|
+
//#endregion
|
|
107458
107731
|
//#region src/pipeline-settings-store.ts
|
|
107459
107732
|
var PIPELINE_EXECUTOR_CAP = "pipeline-executor";
|
|
107460
107733
|
var PipelineSettingsStore = class PipelineSettingsStore {
|
|
@@ -107481,8 +107754,17 @@ var PipelineSettingsStore = class PipelineSettingsStore {
|
|
|
107481
107754
|
* UNBOUNDED reconcile (cameras are never dispatched with empty steps).
|
|
107482
107755
|
*/
|
|
107483
107756
|
static SEED_MAX_RECONCILE_ROUNDS = 4;
|
|
107757
|
+
/** One node row per node: the capability bindings (`nodeBindings@<node>`). */
|
|
107758
|
+
bindingRows;
|
|
107759
|
+
/** One node row per node: the agent settings (`agentSettings@<node>`). */
|
|
107760
|
+
agentRows;
|
|
107761
|
+
/** One device row per camera: the pipeline settings (`cameraSettings` of the device store). */
|
|
107762
|
+
cameraRows;
|
|
107484
107763
|
constructor(deps) {
|
|
107485
107764
|
this.deps = deps;
|
|
107765
|
+
this.bindingRows = new NodeRows(deps, "nodeBindings", StoredNodeBindingsSchema);
|
|
107766
|
+
this.agentRows = new NodeRows(deps, "agentSettings", StoredAgentPipelineSettingsSchema);
|
|
107767
|
+
this.cameraRows = new DeviceRows(deps, "cameraSettings", StoredCameraPipelineSettingsSchema);
|
|
107486
107768
|
}
|
|
107487
107769
|
disposed = false;
|
|
107488
107770
|
/** Whether `dispose()` has run — a `null` catalog from a bounded wait means "not answered" only while this is false. */
|
|
@@ -107495,66 +107777,38 @@ var PipelineSettingsStore = class PipelineSettingsStore {
|
|
|
107495
107777
|
}
|
|
107496
107778
|
blobWriteLock = new KeyedAsyncLock({ isShuttingDown: () => this.disposed });
|
|
107497
107779
|
static AGENT_SETTINGS_LOCK_KEY = "agentSettings";
|
|
107498
|
-
|
|
107499
|
-
_agentSettingsState = null;
|
|
107500
|
-
_cameraSettingsState = null;
|
|
107501
|
-
get nodeBindingsState() {
|
|
107502
|
-
if (!this._nodeBindingsState) this._nodeBindingsState = this.deps.state("nodeBindings", NodeBindingsSchema, {});
|
|
107503
|
-
return this._nodeBindingsState;
|
|
107504
|
-
}
|
|
107505
|
-
get agentSettingsState() {
|
|
107506
|
-
if (!this._agentSettingsState) this._agentSettingsState = this.deps.state("agentSettings", AgentSettingsMapSchema, {});
|
|
107507
|
-
return this._agentSettingsState;
|
|
107508
|
-
}
|
|
107509
|
-
get cameraSettingsState() {
|
|
107510
|
-
if (!this._cameraSettingsState) this._cameraSettingsState = this.deps.state("cameraSettings", CameraSettingsMapSchema, {});
|
|
107511
|
-
return this._cameraSettingsState;
|
|
107512
|
-
}
|
|
107780
|
+
static NODE_BINDINGS_LOCK_KEY = "nodeBindings";
|
|
107513
107781
|
async getCapabilityBindings(nodeId) {
|
|
107514
|
-
const
|
|
107515
|
-
if (!
|
|
107516
|
-
const perNode = { ...perNodeRaw };
|
|
107782
|
+
const bindings = await this.bindingRows.get(nodeId).catch(() => void 0);
|
|
107783
|
+
if (!bindings) return {};
|
|
107517
107784
|
const out = {};
|
|
107518
|
-
for (const [capName, addonId] of Object.entries(
|
|
107785
|
+
for (const [capName, addonId] of Object.entries(bindings)) if (typeof addonId === "string" && addonId.length > 0) out[capName] = addonId;
|
|
107519
107786
|
return out;
|
|
107520
107787
|
}
|
|
107521
107788
|
/**
|
|
107522
|
-
* Drop one node's capability bindings. `false` when it had none.
|
|
107523
|
-
*
|
|
107524
|
-
* A failed read propagates: an unanswered read never counts as "nothing there".
|
|
107789
|
+
* Drop one node's capability bindings. `false` when it had none. A failed read
|
|
107790
|
+
* propagates: an unanswered read never counts as "nothing there".
|
|
107525
107791
|
*/
|
|
107526
107792
|
async removeCapabilityBindings(nodeId) {
|
|
107527
107793
|
let removed = false;
|
|
107528
|
-
await this.
|
|
107529
|
-
|
|
107530
|
-
const { [nodeId]: _drop, ...rest } = prev;
|
|
107531
|
-
removed = true;
|
|
107532
|
-
return rest;
|
|
107794
|
+
await this.blobWriteLock.run(PipelineSettingsStore.NODE_BINDINGS_LOCK_KEY, async () => {
|
|
107795
|
+
removed = await this.bindingRows.remove(nodeId);
|
|
107533
107796
|
});
|
|
107534
107797
|
return removed;
|
|
107535
107798
|
}
|
|
107536
|
-
/** Read-modify-write
|
|
107799
|
+
/** Read-modify-write ONE node's row, so a concurrent binding for another cap of the node is kept. */
|
|
107537
107800
|
async setCapabilityBinding(nodeId, capName, addonId) {
|
|
107538
|
-
await this.
|
|
107539
|
-
const
|
|
107540
|
-
|
|
107541
|
-
|
|
107542
|
-
|
|
107543
|
-
|
|
107544
|
-
for (const [cn, aid] of Object.entries(nodeAsRecord)) if (typeof aid === "string") nodeBinding[cn] = aid;
|
|
107545
|
-
prevBindings[nodeKey] = nodeBinding;
|
|
107546
|
-
}
|
|
107547
|
-
const nodeBindings = { ...prevBindings[nodeId] };
|
|
107548
|
-
nodeBindings[capName] = addonId;
|
|
107549
|
-
return {
|
|
107550
|
-
...prevBindings,
|
|
107551
|
-
[nodeId]: nodeBindings
|
|
107552
|
-
};
|
|
107801
|
+
await this.blobWriteLock.run(PipelineSettingsStore.NODE_BINDINGS_LOCK_KEY, async () => {
|
|
107802
|
+
const prev = await this.bindingRows.get(nodeId) ?? {};
|
|
107803
|
+
await this.bindingRows.set(nodeId, {
|
|
107804
|
+
...prev,
|
|
107805
|
+
[capName]: addonId
|
|
107806
|
+
});
|
|
107553
107807
|
});
|
|
107554
107808
|
}
|
|
107555
107809
|
/** Read the `agentSettings` map (keyed on `nodeId`) via the durable handle. */
|
|
107556
107810
|
async readAgentSettingsMap() {
|
|
107557
|
-
return
|
|
107811
|
+
return await this.agentRows.getAll();
|
|
107558
107812
|
}
|
|
107559
107813
|
/**
|
|
107560
107814
|
* Drop every per-(node, device) `modelId` pin that names a model deleted
|
|
@@ -107567,9 +107821,10 @@ var PipelineSettingsStore = class PipelineSettingsStore {
|
|
|
107567
107821
|
async resetRemovedModelPins(isCustom) {
|
|
107568
107822
|
const cleared = [];
|
|
107569
107823
|
await this.blobWriteLock.run(PipelineSettingsStore.AGENT_SETTINGS_LOCK_KEY, async () => {
|
|
107570
|
-
const
|
|
107824
|
+
const prev = await this.agentRows.getAll();
|
|
107825
|
+
const swept = sweepAgentSettingsPins(prev, isCustom);
|
|
107571
107826
|
if (swept.cleared.length === 0) return;
|
|
107572
|
-
await this.
|
|
107827
|
+
await this.agentRows.applyDiff(prev, swept.next);
|
|
107573
107828
|
cleared.push(...swept.cleared);
|
|
107574
107829
|
});
|
|
107575
107830
|
return cleared;
|
|
@@ -107586,17 +107841,13 @@ var PipelineSettingsStore = class PipelineSettingsStore {
|
|
|
107586
107841
|
return;
|
|
107587
107842
|
}
|
|
107588
107843
|
await this.blobWriteLock.run(PipelineSettingsStore.AGENT_SETTINGS_LOCK_KEY, async () => {
|
|
107589
|
-
const
|
|
107590
|
-
const existing = all[nodeId];
|
|
107844
|
+
const existing = await this.agentRows.get(nodeId);
|
|
107591
107845
|
const merged = {
|
|
107592
107846
|
...existing,
|
|
107593
107847
|
...settings,
|
|
107594
107848
|
maxCameras: settings.maxCameras !== void 0 ? settings.maxCameras ?? null : existing?.maxCameras ?? null
|
|
107595
107849
|
};
|
|
107596
|
-
await this.
|
|
107597
|
-
...all,
|
|
107598
|
-
[nodeId]: merged
|
|
107599
|
-
});
|
|
107850
|
+
await this.agentRows.set(nodeId, merged);
|
|
107600
107851
|
});
|
|
107601
107852
|
}
|
|
107602
107853
|
/**
|
|
@@ -107607,7 +107858,8 @@ var PipelineSettingsStore = class PipelineSettingsStore {
|
|
|
107607
107858
|
*/
|
|
107608
107859
|
async rewriteAgentSettingsMap(transform) {
|
|
107609
107860
|
await this.blobWriteLock.run(PipelineSettingsStore.AGENT_SETTINGS_LOCK_KEY, async () => {
|
|
107610
|
-
await this.
|
|
107861
|
+
const prev = await this.agentRows.getAll();
|
|
107862
|
+
await this.agentRows.applyDiff(prev, transform(prev));
|
|
107611
107863
|
});
|
|
107612
107864
|
}
|
|
107613
107865
|
/**
|
|
@@ -107619,23 +107871,21 @@ var PipelineSettingsStore = class PipelineSettingsStore {
|
|
|
107619
107871
|
async removeAgentSettings(nodeId) {
|
|
107620
107872
|
let removed = false;
|
|
107621
107873
|
await this.blobWriteLock.run(PipelineSettingsStore.AGENT_SETTINGS_LOCK_KEY, async () => {
|
|
107622
|
-
|
|
107623
|
-
if (!(nodeId in all)) return;
|
|
107624
|
-
const { [nodeId]: _drop, ...rest } = all;
|
|
107625
|
-
await this.agentSettingsState.set(rest);
|
|
107626
|
-
removed = true;
|
|
107874
|
+
removed = await this.agentRows.remove(nodeId);
|
|
107627
107875
|
});
|
|
107628
107876
|
return removed;
|
|
107629
107877
|
}
|
|
107630
107878
|
/** Read the `cameraSettings` map (keyed on `deviceId` as string) via the durable handle. */
|
|
107631
107879
|
async readCameraSettingsMap() {
|
|
107632
|
-
return
|
|
107880
|
+
return await this.cameraRows.getAll();
|
|
107881
|
+
}
|
|
107882
|
+
/** One camera's settings, `null` when it has none. A failed read throws. */
|
|
107883
|
+
async readCameraSettings(deviceId) {
|
|
107884
|
+
return await this.cameraRows.get(deviceId) ?? null;
|
|
107633
107885
|
}
|
|
107634
107886
|
/** Overwrite one camera's settings. */
|
|
107635
107887
|
async writeCameraSettings(deviceId, settings) {
|
|
107636
|
-
|
|
107637
|
-
all[String(deviceId)] = settings;
|
|
107638
|
-
await this.cameraSettingsState.set(all);
|
|
107888
|
+
await this.cameraRows.set(deviceId, settings);
|
|
107639
107889
|
}
|
|
107640
107890
|
/**
|
|
107641
107891
|
* Write or clear one camera's CAMERA-WIDE settings for `addonId` (D754): the
|
|
@@ -107644,22 +107894,16 @@ var PipelineSettingsStore = class PipelineSettingsStore {
|
|
|
107644
107894
|
* Read-patch-write, immutable. The caller refuses a model-scoped key (D927).
|
|
107645
107895
|
*/
|
|
107646
107896
|
async writeCameraStepSettings(deviceId, addonId, settings) {
|
|
107647
|
-
await this.
|
|
107648
|
-
|
|
107649
|
-
|
|
107650
|
-
|
|
107651
|
-
|
|
107652
|
-
|
|
107653
|
-
|
|
107654
|
-
|
|
107655
|
-
|
|
107656
|
-
|
|
107657
|
-
};
|
|
107658
|
-
return {
|
|
107659
|
-
...prev,
|
|
107660
|
-
[key]: nextCamera
|
|
107661
|
-
};
|
|
107662
|
-
});
|
|
107897
|
+
const camera = await this.cameraRows.get(deviceId) ?? {};
|
|
107898
|
+
const nextLayer = { ...camera.stepSettings };
|
|
107899
|
+
if (settings === null || Object.keys(settings).length === 0) delete nextLayer[addonId];
|
|
107900
|
+
else nextLayer[addonId] = { ...settings };
|
|
107901
|
+
const { stepSettings: _drop, ...rest } = camera;
|
|
107902
|
+
const nextCamera = {
|
|
107903
|
+
...rest,
|
|
107904
|
+
...Object.keys(nextLayer).length > 0 ? { stepSettings: nextLayer } : {}
|
|
107905
|
+
};
|
|
107906
|
+
await this.cameraRows.set(deviceId, nextCamera);
|
|
107663
107907
|
}
|
|
107664
107908
|
/**
|
|
107665
107909
|
* Write or clear one step's NODE-wide settings (D927) under the agent-blob
|
|
@@ -107668,27 +107912,20 @@ var PipelineSettingsStore = class PipelineSettingsStore {
|
|
|
107668
107912
|
*/
|
|
107669
107913
|
async writeNodeStepSettings(nodeId, addonId, settings) {
|
|
107670
107914
|
await this.blobWriteLock.run(PipelineSettingsStore.AGENT_SETTINGS_LOCK_KEY, async () => {
|
|
107671
|
-
const
|
|
107672
|
-
const existing = all[nodeId] ?? { maxCameras: null };
|
|
107915
|
+
const existing = await this.agentRows.get(nodeId) ?? { maxCameras: null };
|
|
107673
107916
|
const layer = { ...existing.stepSettings };
|
|
107674
107917
|
if (settings === null || Object.keys(settings).length === 0) delete layer[addonId];
|
|
107675
107918
|
else layer[addonId] = { ...settings };
|
|
107676
107919
|
const { stepSettings: _drop, ...rest } = existing;
|
|
107677
|
-
await this.
|
|
107678
|
-
...
|
|
107679
|
-
|
|
107680
|
-
...rest,
|
|
107681
|
-
...Object.keys(layer).length > 0 ? { stepSettings: layer } : {}
|
|
107682
|
-
}
|
|
107920
|
+
await this.agentRows.set(nodeId, {
|
|
107921
|
+
...rest,
|
|
107922
|
+
...Object.keys(layer).length > 0 ? { stepSettings: layer } : {}
|
|
107683
107923
|
});
|
|
107684
107924
|
});
|
|
107685
107925
|
}
|
|
107686
|
-
/** Purge one device's
|
|
107926
|
+
/** Purge one device's row. */
|
|
107687
107927
|
async deleteCameraSettings(deviceId) {
|
|
107688
|
-
await this.
|
|
107689
|
-
const { [String(deviceId)]: _c, ...rest } = prev;
|
|
107690
|
-
return rest;
|
|
107691
|
-
});
|
|
107928
|
+
await this.cameraRows.remove(deviceId);
|
|
107692
107929
|
}
|
|
107693
107930
|
catalogCache = /* @__PURE__ */ new Map();
|
|
107694
107931
|
/**
|
|
@@ -107865,7 +108102,7 @@ var PipelineSettingsStore = class PipelineSettingsStore {
|
|
|
107865
108102
|
*/
|
|
107866
108103
|
async seedAgentSettingsFromCatalog(nodeId) {
|
|
107867
108104
|
if (!await this.awaitExecutorCatalog(nodeId, { maxRounds: PipelineSettingsStore.SEED_MAX_RECONCILE_ROUNDS })) return null;
|
|
107868
|
-
const existing =
|
|
108105
|
+
const existing = await this.agentRows.get(nodeId);
|
|
107869
108106
|
if (existing) return existing;
|
|
107870
108107
|
const next = { maxCameras: null };
|
|
107871
108108
|
await this.writeAgentSettings(nodeId, next);
|
|
@@ -107969,7 +108206,7 @@ var PipelineSettingsStore = class PipelineSettingsStore {
|
|
|
107969
108206
|
};
|
|
107970
108207
|
}
|
|
107971
108208
|
const hasPackageZone = await this.deps.hasPackageZone(deviceId);
|
|
107972
|
-
const cam =
|
|
108209
|
+
const cam = await this.cameraRows.get(deviceId) ?? null;
|
|
107973
108210
|
let catalog;
|
|
107974
108211
|
if (catalogRead.kind === "await") catalog = (await this.waitForAgentAndCatalog(agentNodeId)).catalog;
|
|
107975
108212
|
else {
|
|
@@ -108088,13 +108325,13 @@ var PipelineSettingsStore = class PipelineSettingsStore {
|
|
|
108088
108325
|
while (!this.disposed) {
|
|
108089
108326
|
const catalog = await this.awaitExecutorCatalog(nodeId);
|
|
108090
108327
|
if (!catalog) break;
|
|
108091
|
-
let agent =
|
|
108328
|
+
let agent = await this.agentRows.get(nodeId);
|
|
108092
108329
|
if (!agent) {
|
|
108093
108330
|
if (!await this.seedAgentSettingsFromCatalog(nodeId)) {
|
|
108094
108331
|
await sleep(2e3);
|
|
108095
108332
|
continue;
|
|
108096
108333
|
}
|
|
108097
|
-
agent =
|
|
108334
|
+
agent = await this.agentRows.get(nodeId);
|
|
108098
108335
|
}
|
|
108099
108336
|
if (!agent) {
|
|
108100
108337
|
await sleep(2e3);
|
|
@@ -108114,7 +108351,7 @@ var PipelineSettingsStore = class PipelineSettingsStore {
|
|
|
108114
108351
|
* per-node maximums without polling the store on each decision.
|
|
108115
108352
|
*/
|
|
108116
108353
|
async buildNodeCaps() {
|
|
108117
|
-
const blob = await this.
|
|
108354
|
+
const blob = await this.agentRows.getAll();
|
|
108118
108355
|
const caps = {};
|
|
108119
108356
|
for (const [nodeId, settings] of Object.entries(blob)) caps[nodeId] = settings.maxCameras ?? null;
|
|
108120
108357
|
return caps;
|
|
@@ -108134,7 +108371,7 @@ var PipelineSettingsStore = class PipelineSettingsStore {
|
|
|
108134
108371
|
* `manual` applies and what `auto` falls back to before its first answer.
|
|
108135
108372
|
*/
|
|
108136
108373
|
async buildStoredNodeWeights() {
|
|
108137
|
-
const blob = await this.
|
|
108374
|
+
const blob = await this.agentRows.getAll();
|
|
108138
108375
|
const weights = {};
|
|
108139
108376
|
for (const [nodeId, settings] of Object.entries(blob)) if (typeof settings.detectWeight === "number" && settings.detectWeight > 0) weights[nodeId] = settings.detectWeight;
|
|
108140
108377
|
return weights;
|
|
@@ -108163,7 +108400,7 @@ var PipelineSettingsStore = class PipelineSettingsStore {
|
|
|
108163
108400
|
* (no attach).
|
|
108164
108401
|
*/
|
|
108165
108402
|
async buildNodeInferenceDeviceSteps(nodeId, deviceKey) {
|
|
108166
|
-
return nodeDeviceBase(
|
|
108403
|
+
return nodeDeviceBase(await this.agentRows.get(nodeId), deviceKey);
|
|
108167
108404
|
}
|
|
108168
108405
|
/**
|
|
108169
108406
|
* The provisioning SOURCES of every device an attach may run a step on
|
|
@@ -108175,9 +108412,8 @@ var PipelineSettingsStore = class PipelineSettingsStore {
|
|
|
108175
108412
|
* node's folded settings.
|
|
108176
108413
|
*/
|
|
108177
108414
|
async readDeviceProvisioning(deviceId, nodeId, deviceKeys) {
|
|
108178
|
-
const [
|
|
108179
|
-
const
|
|
108180
|
-
const cameraLayer = layerCameraStepSettings(cameraMap[String(deviceId)]?.stepSettings);
|
|
108415
|
+
const [node, camera] = await Promise.all([this.agentRows.get(nodeId), this.cameraRows.get(deviceId)]);
|
|
108416
|
+
const cameraLayer = layerCameraStepSettings(camera?.stepSettings);
|
|
108181
108417
|
const out = /* @__PURE__ */ new Map();
|
|
108182
108418
|
for (const deviceKey of deviceKeys) out.set(deviceKey, {
|
|
108183
108419
|
base: nodeDeviceBase(node, deviceKey),
|
|
@@ -111930,6 +112166,8 @@ async function buildOrchestratorControllers(deps) {
|
|
|
111930
112166
|
});
|
|
111931
112167
|
const settingsStore = new PipelineSettingsStore({
|
|
111932
112168
|
state: deps.state,
|
|
112169
|
+
readStore: () => deps.resolveGlobalStore(),
|
|
112170
|
+
deviceSettings: () => deps.ctxIfReady()?.settings ?? null,
|
|
111933
112171
|
api: () => deps.ctxIfReady()?.api ?? null,
|
|
111934
112172
|
acquireCapability: (capName, scope, opts) => {
|
|
111935
112173
|
const ctx = deps.ctxIfReady();
|
|
@@ -114894,9 +115132,25 @@ var PipelineOrchestratorAddon = class PipelineOrchestratorAddon extends BaseAddo
|
|
|
114894
115132
|
}
|
|
114895
115133
|
};
|
|
114896
115134
|
}
|
|
114897
|
-
/**
|
|
115135
|
+
/**
|
|
115136
|
+
* The orchestrator's D987 catalogue: the retired bindings flag is deleted, and the three id-keyed
|
|
115137
|
+
* maps become one row per node / per camera (D986 §2). The readers read the rows, so a failure
|
|
115138
|
+
* here blocks the addon (`block-owner`) instead of letting it serve an empty store.
|
|
115139
|
+
*/
|
|
114898
115140
|
async migrateSettings() {
|
|
114899
|
-
await this.runMigrations(defineAddonMigrations(ADDON_MIGRATIONS, {
|
|
115141
|
+
await this.runMigrations(defineAddonMigrations(ADDON_MIGRATIONS, {
|
|
115142
|
+
readStored: (keys) => readRawKeys((key) => this.readStoredGlobalKey(key), PIPELINE_ORCHESTRATOR_ID, keys),
|
|
115143
|
+
readDeviceField: async (deviceIds, field) => {
|
|
115144
|
+
const settings = this.ctx.settings;
|
|
115145
|
+
if (settings === void 0) throw new Error("the per-device settings store is unavailable");
|
|
115146
|
+
const found = /* @__PURE__ */ new Map();
|
|
115147
|
+
for (const [deviceId, blob] of await settings.readDeviceStoreBatch(deviceIds)) if (field in blob) found.set(deviceId, blob[field]);
|
|
115148
|
+
return found;
|
|
115149
|
+
}
|
|
115150
|
+
}));
|
|
115151
|
+
this.state(NODE_BINDINGS_FIELD, NodeBindingsSchema, {});
|
|
115152
|
+
this.state(AGENT_SETTINGS_FIELD, AgentSettingsMapSchema, {});
|
|
115153
|
+
this.state(CAMERA_SETTINGS_FIELD, CameraSettingsMapSchema, {});
|
|
114900
115154
|
}
|
|
114901
115155
|
async onInitialize() {
|
|
114902
115156
|
this.initTimestamp = Date.now();
|
|
@@ -116640,10 +116894,10 @@ var PipelineOrchestratorAddon = class PipelineOrchestratorAddon extends BaseAddo
|
|
|
116640
116894
|
return { success: true };
|
|
116641
116895
|
}
|
|
116642
116896
|
async getCameraSettings(input) {
|
|
116643
|
-
return
|
|
116897
|
+
return await this.settingsStore.readCameraSettings(input.deviceId);
|
|
116644
116898
|
}
|
|
116645
116899
|
async setCameraStepToggle(input) {
|
|
116646
|
-
const existing =
|
|
116900
|
+
const existing = await this.settingsStore.readCameraSettings(input.deviceId) ?? {};
|
|
116647
116901
|
const nextToggles = { ...existing.stepToggles };
|
|
116648
116902
|
if (input.enabled === null) delete nextToggles[input.addonId];
|
|
116649
116903
|
else nextToggles[input.addonId] = input.enabled;
|