@camstack/addon-provider-wyze 0.2.131 → 0.2.133
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/dist/addon.js +2028 -57
- package/dist/addon.mjs +2028 -57
- package/package.json +1 -1
package/dist/addon.js
CHANGED
|
@@ -31,7 +31,7 @@ let net = require("net");
|
|
|
31
31
|
net = __toESM(net, 1);
|
|
32
32
|
let node_child_process = require("node:child_process");
|
|
33
33
|
let node_tls = require("node:tls");
|
|
34
|
-
//#region ../types/dist/event-category-
|
|
34
|
+
//#region ../types/dist/event-category-DaIZi00R.mjs
|
|
35
35
|
var EventCategory = /* @__PURE__ */ function(EventCategory) {
|
|
36
36
|
EventCategory["SystemBoot"] = "system.boot";
|
|
37
37
|
EventCategory["SystemAddonsReady"] = "system.addons-ready";
|
|
@@ -110,6 +110,13 @@ var EventCategory = /* @__PURE__ */ function(EventCategory) {
|
|
|
110
110
|
*/
|
|
111
111
|
EventCategory["AddonLoadFailed"] = "addon.load-failed";
|
|
112
112
|
/**
|
|
113
|
+
* A keychain value was stored or removed (D787). Carries the ref, its
|
|
114
|
+
* owner and the new version — NEVER the value. A process holding the ref
|
|
115
|
+
* drops its cached copy and the owning `BaseAddon` re-resolves its config.
|
|
116
|
+
* Telemetry (D8): a process that misses it still revalidates by version.
|
|
117
|
+
*/
|
|
118
|
+
EventCategory["KeychainChanged"] = "keychain.changed";
|
|
119
|
+
/**
|
|
113
120
|
* Addon recovered from a previous failure. Emitted when an addon
|
|
114
121
|
* transitions from `failed` back to `healthy` (typically via the
|
|
115
122
|
* monitor's auto-retry loop, or after manual `addons.retryLoad`).
|
|
@@ -5402,7 +5409,7 @@ var ZodIssueCode = {
|
|
|
5402
5409
|
var ZodFirstPartyTypeKind;
|
|
5403
5410
|
ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {});
|
|
5404
5411
|
//#endregion
|
|
5405
|
-
//#region ../types/dist/sleep-
|
|
5412
|
+
//#region ../types/dist/sleep-DujUvOcb.mjs
|
|
5406
5413
|
/**
|
|
5407
5414
|
* The audio chunk plane's byte format, and the ONE expansion from a coded
|
|
5408
5415
|
* window to float samples (D455).
|
|
@@ -5481,6 +5488,97 @@ function buildAlawTable() {
|
|
|
5481
5488
|
}
|
|
5482
5489
|
buildUlawTable();
|
|
5483
5490
|
buildAlawTable();
|
|
5491
|
+
/** Is this field's stored value a credential? */
|
|
5492
|
+
function isSecretConfigField(field) {
|
|
5493
|
+
if (field.type === "password") return true;
|
|
5494
|
+
return "secret" in field && field.secret === true;
|
|
5495
|
+
}
|
|
5496
|
+
/**
|
|
5497
|
+
* Is this field's value stored in the KEYCHAIN (D787)? Every secret field is,
|
|
5498
|
+
* by its TYPE, unless it opts out with `storage: 'inline'` — never by its name.
|
|
5499
|
+
*/
|
|
5500
|
+
function isKeychainStoredField(field) {
|
|
5501
|
+
if (!isSecretConfigField(field)) return false;
|
|
5502
|
+
if (field.type === "textarea" && field.isJson === true) return false;
|
|
5503
|
+
return !("storage" in field && field.storage === "inline");
|
|
5504
|
+
}
|
|
5505
|
+
/**
|
|
5506
|
+
* What a settings blob holds where a secret used to be.
|
|
5507
|
+
*
|
|
5508
|
+
* A keychain-stored field never holds its value. It holds a self-describing
|
|
5509
|
+
* MARKER, `{"$secret":"secret://…","v":1}` — an object, never a string, so no
|
|
5510
|
+
* code can mistake it for a credential and no form can send it to a camera as
|
|
5511
|
+
* a password. The empty state is `null` / absent, never `''`.
|
|
5512
|
+
*
|
|
5513
|
+
* The same shapes travel to and from the admin UI:
|
|
5514
|
+
*
|
|
5515
|
+
* - read: `hydrateSchema` hands a secret field a {@link SecretFieldView}
|
|
5516
|
+
* (`{ $secret, v, set: true }`) or `null` — the browser learns whether a
|
|
5517
|
+
* value is set, never the value.
|
|
5518
|
+
* - write: an untouched field submits the view back unchanged (KEEP); a typed
|
|
5519
|
+
* value is a plain non-empty string (CHANGE); the Clear button submits
|
|
5520
|
+
* {@link SECRET_CLEAR} (CLEAR). `''`, `null` and the legacy redaction tokens
|
|
5521
|
+
* are KEEP — an empty string is what a defaults-fallback pushes back, and
|
|
5522
|
+
* treating it as "clear" is how a save destroyed a stored credential before.
|
|
5523
|
+
*
|
|
5524
|
+
* Pure and browser-safe.
|
|
5525
|
+
*/
|
|
5526
|
+
var SECRET_CLEAR = { $secretClear: true };
|
|
5527
|
+
/** The `'***'` token D634 redaction writes for non-admins. */
|
|
5528
|
+
var LEGACY_DEVICE_REDACTION = "***";
|
|
5529
|
+
function isRecord$1(value) {
|
|
5530
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
5531
|
+
}
|
|
5532
|
+
function makeSecretMarker(ref) {
|
|
5533
|
+
return {
|
|
5534
|
+
$secret: ref,
|
|
5535
|
+
v: 1
|
|
5536
|
+
};
|
|
5537
|
+
}
|
|
5538
|
+
/** A stored marker: an object whose `$secret` is a non-empty string. */
|
|
5539
|
+
function isSecretMarker(value) {
|
|
5540
|
+
if (!isRecord$1(value)) return false;
|
|
5541
|
+
const ref = value["$secret"];
|
|
5542
|
+
return typeof ref === "string" && ref.length > 0;
|
|
5543
|
+
}
|
|
5544
|
+
function isSecretClear(value) {
|
|
5545
|
+
return isRecord$1(value) && value["$secretClear"] === true;
|
|
5546
|
+
}
|
|
5547
|
+
/**
|
|
5548
|
+
* The UI view of a stored secret field value: a marker becomes "set", inline
|
|
5549
|
+
* plaintext becomes "set (inline)", nothing becomes `null`. A value never
|
|
5550
|
+
* survives this function.
|
|
5551
|
+
*/
|
|
5552
|
+
function toSecretFieldView(stored) {
|
|
5553
|
+
if (isSecretMarker(stored)) return {
|
|
5554
|
+
$secret: stored.$secret,
|
|
5555
|
+
v: 1,
|
|
5556
|
+
set: true
|
|
5557
|
+
};
|
|
5558
|
+
if (typeof stored === "string" && stored.length > 0) return {
|
|
5559
|
+
$secret: null,
|
|
5560
|
+
v: 1,
|
|
5561
|
+
set: true,
|
|
5562
|
+
inline: true
|
|
5563
|
+
};
|
|
5564
|
+
return null;
|
|
5565
|
+
}
|
|
5566
|
+
/**
|
|
5567
|
+
* Classify an incoming value for a secret path. Only a non-empty string that is
|
|
5568
|
+
* not a redaction token sets a value; only {@link SECRET_CLEAR} clears.
|
|
5569
|
+
* Everything else — a marker (ours or anyone's), a UI view, `''`, `null`,
|
|
5570
|
+
* `undefined`, a redaction token, a non-string — keeps what is stored.
|
|
5571
|
+
*/
|
|
5572
|
+
function classifySecretWrite(incoming) {
|
|
5573
|
+
if (isSecretClear(incoming)) return { kind: "clear" };
|
|
5574
|
+
if (typeof incoming !== "string") return { kind: "keep" };
|
|
5575
|
+
if (incoming.length === 0) return { kind: "keep" };
|
|
5576
|
+
if (incoming === "__camstack_redacted__" || incoming === LEGACY_DEVICE_REDACTION) return { kind: "keep" };
|
|
5577
|
+
return {
|
|
5578
|
+
kind: "set",
|
|
5579
|
+
value: incoming
|
|
5580
|
+
};
|
|
5581
|
+
}
|
|
5484
5582
|
Object.fromEntries([
|
|
5485
5583
|
{
|
|
5486
5584
|
id: "overview",
|
|
@@ -5652,33 +5750,19 @@ Object.fromEntries([
|
|
|
5652
5750
|
function isValuelessField(field) {
|
|
5653
5751
|
return field.type === "separator" || field.type === "info" || field.type === "qr-code" || field.type === "button" || field.type === "object-array" || field.type === "widget" || field.type === "addon-action-button" || field.type === "device-action-button";
|
|
5654
5752
|
}
|
|
5655
|
-
|
|
5656
|
-
* Merge a `ConfigUISchema` with a raw `values` record into a
|
|
5657
|
-
* `ConfigUISchemaWithValues`. Used by every `get*Settings` backend endpoint
|
|
5658
|
-
* before returning to the admin UI. Groups are walked recursively.
|
|
5659
|
-
*
|
|
5660
|
-
* For each leaf field:
|
|
5661
|
-
* - structural fields (`separator`, `info`, `button`) pass through unchanged
|
|
5662
|
-
* - other fields get `value = values[key] ?? field.default ?? null`
|
|
5663
|
-
*
|
|
5664
|
-
* Unknown keys in `values` (keys not declared in the schema) are silently
|
|
5665
|
-
* ignored — they don't contribute to the output. Missing keys fall back to
|
|
5666
|
-
* the schema default or `null`. This mirrors the old backend behaviour where
|
|
5667
|
-
* `FormBuilder` rendered `values[key] ?? field.default`.
|
|
5668
|
-
*/
|
|
5669
|
-
function hydrateSchema(schema, values) {
|
|
5753
|
+
function hydrateSchema(schema, values, options = {}) {
|
|
5670
5754
|
return {
|
|
5671
5755
|
...schema.tabs ? { tabs: [...schema.tabs] } : {},
|
|
5672
5756
|
sections: schema.sections.map((section) => ({
|
|
5673
5757
|
...section,
|
|
5674
|
-
fields: section.fields.map((field) => hydrateField(field, values))
|
|
5758
|
+
fields: section.fields.map((field) => hydrateField(field, values, options))
|
|
5675
5759
|
}))
|
|
5676
5760
|
};
|
|
5677
5761
|
}
|
|
5678
|
-
function hydrateField(field, values) {
|
|
5762
|
+
function hydrateField(field, values, options) {
|
|
5679
5763
|
if (isValuelessField(field)) return field;
|
|
5680
5764
|
if (field.type === "group") {
|
|
5681
|
-
const hydratedChildren = field.fields.map((child) => hydrateField(child, values));
|
|
5765
|
+
const hydratedChildren = field.fields.map((child) => hydrateField(child, values, options));
|
|
5682
5766
|
return {
|
|
5683
5767
|
...field,
|
|
5684
5768
|
fields: hydratedChildren
|
|
@@ -5687,7 +5771,7 @@ function hydrateField(field, values) {
|
|
|
5687
5771
|
if (field.type === "sub-tabs") {
|
|
5688
5772
|
const hydratedTabs = field.tabs.map((tab) => ({
|
|
5689
5773
|
...tab,
|
|
5690
|
-
fields: tab.fields.map((child) => hydrateField(child, values))
|
|
5774
|
+
fields: tab.fields.map((child) => hydrateField(child, values, options))
|
|
5691
5775
|
}));
|
|
5692
5776
|
return {
|
|
5693
5777
|
...field,
|
|
@@ -5697,6 +5781,33 @@ function hydrateField(field, values) {
|
|
|
5697
5781
|
const key = field.key;
|
|
5698
5782
|
const storedValue = Object.prototype.hasOwnProperty.call(values, key) ? values[key] : void 0;
|
|
5699
5783
|
const defaultValue = field.default;
|
|
5784
|
+
const asView = (v) => isSecretMarker(v) || options.inlineSecretsAsViews === true && v !== void 0;
|
|
5785
|
+
if (isKeychainStoredField(field) && asView(storedValue)) return {
|
|
5786
|
+
...field,
|
|
5787
|
+
value: toSecretFieldView(storedValue)
|
|
5788
|
+
};
|
|
5789
|
+
if (isKeychainStoredField(field) && options.inlineSecretsAsViews === true) return {
|
|
5790
|
+
...field,
|
|
5791
|
+
value: null
|
|
5792
|
+
};
|
|
5793
|
+
if (field.type === "editable-array" && Array.isArray(storedValue)) {
|
|
5794
|
+
const secretItemKeys = field.itemFields.filter((item) => "key" in item && isKeychainStoredField(item)).map((item) => "key" in item ? item.key : "");
|
|
5795
|
+
if (secretItemKeys.length > 0) {
|
|
5796
|
+
const rows = storedValue.map((row) => {
|
|
5797
|
+
if (row === null || typeof row !== "object" || Array.isArray(row)) return row;
|
|
5798
|
+
const out = { ...row };
|
|
5799
|
+
for (const k of secretItemKeys) {
|
|
5800
|
+
const v = Reflect.get(row, k);
|
|
5801
|
+
if (asView(v)) out[k] = toSecretFieldView(v);
|
|
5802
|
+
}
|
|
5803
|
+
return out;
|
|
5804
|
+
});
|
|
5805
|
+
return {
|
|
5806
|
+
...field,
|
|
5807
|
+
value: rows
|
|
5808
|
+
};
|
|
5809
|
+
}
|
|
5810
|
+
}
|
|
5700
5811
|
if (field.multiple) {
|
|
5701
5812
|
const stored = Array.isArray(storedValue) ? storedValue : storedValue !== void 0 && storedValue !== null ? [storedValue] : [];
|
|
5702
5813
|
const itemFallback = field.multiple.itemDefault !== void 0 ? field.multiple.itemDefault : defaultValue !== void 0 ? defaultValue : typeOf(field) === "string" ? "" : null;
|
|
@@ -5939,6 +6050,431 @@ function projectStore(store, perNodeKeys, nodeId) {
|
|
|
5939
6050
|
}
|
|
5940
6051
|
return out;
|
|
5941
6052
|
}
|
|
6053
|
+
var GLOBAL_SCOPE = { kind: "global" };
|
|
6054
|
+
/** The scope every addon-wide (not per-node, not per-device) setting lives in. */
|
|
6055
|
+
function globalSecretScope() {
|
|
6056
|
+
return GLOBAL_SCOPE;
|
|
6057
|
+
}
|
|
6058
|
+
function encodeSegment(value) {
|
|
6059
|
+
return encodeURIComponent(value);
|
|
6060
|
+
}
|
|
6061
|
+
/**
|
|
6062
|
+
* The field path of a value inside an array item, addressed by the item's id:
|
|
6063
|
+
* `arrayItemFieldPath('providers', 'authentik', 'clientSecret')` →
|
|
6064
|
+
* `providers[authentik].clientSecret`.
|
|
6065
|
+
*/
|
|
6066
|
+
function arrayItemFieldPath(arrayKey, itemId, fieldKey) {
|
|
6067
|
+
return `${arrayKey}[${encodeSegment(itemId)}].${fieldKey}`;
|
|
6068
|
+
}
|
|
6069
|
+
/** A write to a secret path could not be stored in the keychain, so it was refused. */
|
|
6070
|
+
var KeychainWriteRefusedError = class extends Error {
|
|
6071
|
+
fieldPath;
|
|
6072
|
+
constructor(fieldPath, cause) {
|
|
6073
|
+
super(`secret "${fieldPath}" was not saved: the keychain could not store it (${cause instanceof Error ? cause.message : String(cause)}). Nothing was written.`);
|
|
6074
|
+
this.fieldPath = fieldPath;
|
|
6075
|
+
this.name = "KeychainWriteRefusedError";
|
|
6076
|
+
}
|
|
6077
|
+
};
|
|
6078
|
+
var KEEP = { kind: "keep" };
|
|
6079
|
+
function isRecord(value) {
|
|
6080
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
6081
|
+
}
|
|
6082
|
+
function defaultMintId() {
|
|
6083
|
+
return globalThis.crypto.randomUUID();
|
|
6084
|
+
}
|
|
6085
|
+
/** Every marker ref anywhere under `value`. */
|
|
6086
|
+
function collectSecretMarkerRefs(value, out = []) {
|
|
6087
|
+
if (isSecretMarker(value)) {
|
|
6088
|
+
out.push(value.$secret);
|
|
6089
|
+
return out;
|
|
6090
|
+
}
|
|
6091
|
+
if (Array.isArray(value)) for (const item of value) collectSecretMarkerRefs(item, out);
|
|
6092
|
+
else if (isRecord(value)) for (const child of Object.values(value)) collectSecretMarkerRefs(child, out);
|
|
6093
|
+
return out;
|
|
6094
|
+
}
|
|
6095
|
+
async function storedValueEquals(secrets, marker, candidate) {
|
|
6096
|
+
const resolved = (await secrets.resolve([marker.$secret]))[marker.$secret];
|
|
6097
|
+
return resolved?.kind === "value" && resolved.value === candidate;
|
|
6098
|
+
}
|
|
6099
|
+
async function writeLeaf(ctx, incoming, stored, fieldPath) {
|
|
6100
|
+
const intent = classifySecretWrite(incoming);
|
|
6101
|
+
const ref = ctx.secrets.ref(ctx.scope, fieldPath);
|
|
6102
|
+
const storedIsOurs = isSecretMarker(stored) && stored.$secret === ref;
|
|
6103
|
+
if (intent.kind === "keep") return KEEP;
|
|
6104
|
+
if (intent.kind === "set" && !ctx.operatorWrite && typeof stored === "string" && stored === intent.value) return KEEP;
|
|
6105
|
+
if (intent.kind === "clear") {
|
|
6106
|
+
if (storedIsOurs) ctx.deletes.push(ref);
|
|
6107
|
+
return {
|
|
6108
|
+
kind: "value",
|
|
6109
|
+
value: null
|
|
6110
|
+
};
|
|
6111
|
+
}
|
|
6112
|
+
if (storedIsOurs && await storedValueEquals(ctx.secrets, stored, intent.value)) return {
|
|
6113
|
+
kind: "value",
|
|
6114
|
+
value: stored
|
|
6115
|
+
};
|
|
6116
|
+
try {
|
|
6117
|
+
await ctx.secrets.put(ref, intent.value);
|
|
6118
|
+
} catch (err) {
|
|
6119
|
+
throw new KeychainWriteRefusedError(fieldPath, err);
|
|
6120
|
+
}
|
|
6121
|
+
return {
|
|
6122
|
+
kind: "value",
|
|
6123
|
+
value: makeSecretMarker(ref)
|
|
6124
|
+
};
|
|
6125
|
+
}
|
|
6126
|
+
/** Apply a member result onto `out`: KEEP restores the stored member, or removes it. */
|
|
6127
|
+
function applyMember(out, key, result, storedParent) {
|
|
6128
|
+
if (result.kind === "value") {
|
|
6129
|
+
out[key] = result.value;
|
|
6130
|
+
return;
|
|
6131
|
+
}
|
|
6132
|
+
if (Object.prototype.hasOwnProperty.call(storedParent, key)) out[key] = storedParent[key];
|
|
6133
|
+
else delete out[key];
|
|
6134
|
+
}
|
|
6135
|
+
async function writeMembers(ctx, children, incoming, stored, pathOf) {
|
|
6136
|
+
const out = { ...incoming };
|
|
6137
|
+
for (const [member, node] of children) applyMember(out, member, await writeNode(ctx, node, incoming[member], stored[member], pathOf(member)), stored);
|
|
6138
|
+
return out;
|
|
6139
|
+
}
|
|
6140
|
+
function rowId(row, idKey) {
|
|
6141
|
+
const raw = row[idKey];
|
|
6142
|
+
if (typeof raw === "string" && raw.length > 0) return raw;
|
|
6143
|
+
if (typeof raw === "number" && Number.isFinite(raw)) return String(raw);
|
|
6144
|
+
return null;
|
|
6145
|
+
}
|
|
6146
|
+
async function writeArray(ctx, node, incoming, stored, fieldPath) {
|
|
6147
|
+
const storedRows = Array.isArray(stored) ? stored.filter(isRecord) : [];
|
|
6148
|
+
if (!Array.isArray(incoming)) {
|
|
6149
|
+
ctx.deletes.push(...collectSecretMarkerRefs(storedRows));
|
|
6150
|
+
return {
|
|
6151
|
+
kind: "value",
|
|
6152
|
+
value: incoming
|
|
6153
|
+
};
|
|
6154
|
+
}
|
|
6155
|
+
const storedById = /* @__PURE__ */ new Map();
|
|
6156
|
+
for (const row of storedRows) {
|
|
6157
|
+
const id = rowId(row, node.idKey);
|
|
6158
|
+
if (id !== null) storedById.set(id, row);
|
|
6159
|
+
}
|
|
6160
|
+
const kept = /* @__PURE__ */ new Set();
|
|
6161
|
+
const rows = [];
|
|
6162
|
+
for (const row of incoming) {
|
|
6163
|
+
if (!isRecord(row)) {
|
|
6164
|
+
rows.push(row);
|
|
6165
|
+
continue;
|
|
6166
|
+
}
|
|
6167
|
+
const id = rowId(row, node.idKey) ?? ctx.mintId();
|
|
6168
|
+
kept.add(id);
|
|
6169
|
+
const withId = {
|
|
6170
|
+
...row,
|
|
6171
|
+
[node.idKey]: row[node.idKey] ?? id
|
|
6172
|
+
};
|
|
6173
|
+
if (rowId(withId, node.idKey) === null) withId[node.idKey] = id;
|
|
6174
|
+
const storedRow = storedById.get(id) ?? {};
|
|
6175
|
+
rows.push(await writeMembers(ctx, node.item, withId, storedRow, (member) => arrayItemFieldPath(fieldPath, id, member)));
|
|
6176
|
+
}
|
|
6177
|
+
for (const [id, row] of storedById) if (!kept.has(id)) ctx.deletes.push(...collectSecretMarkerRefs(row));
|
|
6178
|
+
return {
|
|
6179
|
+
kind: "value",
|
|
6180
|
+
value: rows
|
|
6181
|
+
};
|
|
6182
|
+
}
|
|
6183
|
+
async function writeNode(ctx, node, incoming, stored, fieldPath) {
|
|
6184
|
+
switch (node.kind) {
|
|
6185
|
+
case "leaf": return writeLeaf(ctx, incoming, stored, fieldPath);
|
|
6186
|
+
case "array": return writeArray(ctx, node, incoming, stored, fieldPath);
|
|
6187
|
+
case "object": {
|
|
6188
|
+
if (!isRecord(incoming)) {
|
|
6189
|
+
if (incoming === void 0) return KEEP;
|
|
6190
|
+
ctx.deletes.push(...collectSecretMarkerRefs(stored));
|
|
6191
|
+
return {
|
|
6192
|
+
kind: "value",
|
|
6193
|
+
value: incoming
|
|
6194
|
+
};
|
|
6195
|
+
}
|
|
6196
|
+
const storedObj = isRecord(stored) ? stored : {};
|
|
6197
|
+
return {
|
|
6198
|
+
kind: "value",
|
|
6199
|
+
value: await writeMembers(ctx, node.children, incoming, storedObj, (m) => `${fieldPath}.${m}`)
|
|
6200
|
+
};
|
|
6201
|
+
}
|
|
6202
|
+
}
|
|
6203
|
+
}
|
|
6204
|
+
/** Split a perNode-scoped key (`key@nodeId`). */
|
|
6205
|
+
function splitNodeKey(key) {
|
|
6206
|
+
const at = key.indexOf("@");
|
|
6207
|
+
return at <= 0 ? {
|
|
6208
|
+
base: key,
|
|
6209
|
+
nodeId: null
|
|
6210
|
+
} : {
|
|
6211
|
+
base: key.slice(0, at),
|
|
6212
|
+
nodeId: key.slice(at + 1)
|
|
6213
|
+
};
|
|
6214
|
+
}
|
|
6215
|
+
/** Rewrite a settings patch so no secret value reaches the blob. See the file doc. */
|
|
6216
|
+
async function transformSecretWrite(input) {
|
|
6217
|
+
const deletes = [];
|
|
6218
|
+
const base = {
|
|
6219
|
+
secrets: input.secrets,
|
|
6220
|
+
mintId: input.mintId ?? defaultMintId,
|
|
6221
|
+
deletes,
|
|
6222
|
+
operatorWrite: input.operatorWrite === true
|
|
6223
|
+
};
|
|
6224
|
+
const out = {};
|
|
6225
|
+
for (const [key, incoming] of Object.entries(input.patch)) {
|
|
6226
|
+
const { base: baseKey, nodeId } = splitNodeKey(key);
|
|
6227
|
+
const node = input.tree.get(baseKey);
|
|
6228
|
+
if (node === void 0) {
|
|
6229
|
+
out[key] = incoming;
|
|
6230
|
+
continue;
|
|
6231
|
+
}
|
|
6232
|
+
const scope = nodeId !== null && nodeId.length > 0 ? {
|
|
6233
|
+
kind: "node",
|
|
6234
|
+
nodeId
|
|
6235
|
+
} : input.scope ?? globalSecretScope();
|
|
6236
|
+
const result = await writeNode({
|
|
6237
|
+
...base,
|
|
6238
|
+
scope
|
|
6239
|
+
}, node, incoming, input.stored[key], baseKey);
|
|
6240
|
+
if (result.kind === "value") out[key] = result.value;
|
|
6241
|
+
}
|
|
6242
|
+
return {
|
|
6243
|
+
patch: out,
|
|
6244
|
+
afterWrite: async () => {
|
|
6245
|
+
if (deletes.length === 0) return { orphaned: [] };
|
|
6246
|
+
try {
|
|
6247
|
+
await input.secrets.delete([...new Set(deletes)]);
|
|
6248
|
+
return { orphaned: [] };
|
|
6249
|
+
} catch {
|
|
6250
|
+
return { orphaned: [...new Set(deletes)] };
|
|
6251
|
+
}
|
|
6252
|
+
}
|
|
6253
|
+
};
|
|
6254
|
+
}
|
|
6255
|
+
/**
|
|
6256
|
+
* Replace every marker in `value` with its keychain value. Returns the SAME
|
|
6257
|
+
* reference when there is no marker (no allocation, no keychain call).
|
|
6258
|
+
*/
|
|
6259
|
+
async function resolveSecretMarkers(value, secrets) {
|
|
6260
|
+
const refs = collectSecretMarkerRefs(value);
|
|
6261
|
+
if (refs.length === 0) return {
|
|
6262
|
+
value,
|
|
6263
|
+
unresolved: []
|
|
6264
|
+
};
|
|
6265
|
+
const answers = await secrets.resolve(refs);
|
|
6266
|
+
const unresolved = [];
|
|
6267
|
+
for (const ref of new Set(refs)) {
|
|
6268
|
+
const answer = answers[ref];
|
|
6269
|
+
if (answer === void 0) unresolved.push({
|
|
6270
|
+
ref,
|
|
6271
|
+
reason: "not-initialized"
|
|
6272
|
+
});
|
|
6273
|
+
else if (answer.kind === "unavailable") unresolved.push({
|
|
6274
|
+
ref,
|
|
6275
|
+
reason: answer.reason
|
|
6276
|
+
});
|
|
6277
|
+
else if (answer.kind === "missing" || answer.kind === "forbidden") unresolved.push({
|
|
6278
|
+
ref,
|
|
6279
|
+
reason: answer.kind
|
|
6280
|
+
});
|
|
6281
|
+
}
|
|
6282
|
+
const substitute = (v) => {
|
|
6283
|
+
if (isSecretMarker(v)) {
|
|
6284
|
+
const answer = answers[v.$secret];
|
|
6285
|
+
return answer?.kind === "value" ? {
|
|
6286
|
+
keep: true,
|
|
6287
|
+
value: answer.value
|
|
6288
|
+
} : {
|
|
6289
|
+
keep: false,
|
|
6290
|
+
value: void 0
|
|
6291
|
+
};
|
|
6292
|
+
}
|
|
6293
|
+
if (Array.isArray(v)) {
|
|
6294
|
+
const items = [];
|
|
6295
|
+
for (const item of v) {
|
|
6296
|
+
const s = substitute(item);
|
|
6297
|
+
if (s.keep) items.push(s.value);
|
|
6298
|
+
}
|
|
6299
|
+
return {
|
|
6300
|
+
keep: true,
|
|
6301
|
+
value: items
|
|
6302
|
+
};
|
|
6303
|
+
}
|
|
6304
|
+
if (isRecord(v)) {
|
|
6305
|
+
const out = {};
|
|
6306
|
+
for (const [k, child] of Object.entries(v)) {
|
|
6307
|
+
const s = substitute(child);
|
|
6308
|
+
if (s.keep) out[k] = s.value;
|
|
6309
|
+
}
|
|
6310
|
+
return {
|
|
6311
|
+
keep: true,
|
|
6312
|
+
value: out
|
|
6313
|
+
};
|
|
6314
|
+
}
|
|
6315
|
+
return {
|
|
6316
|
+
keep: true,
|
|
6317
|
+
value: v
|
|
6318
|
+
};
|
|
6319
|
+
};
|
|
6320
|
+
return {
|
|
6321
|
+
value: substitute(value).value,
|
|
6322
|
+
unresolved
|
|
6323
|
+
};
|
|
6324
|
+
}
|
|
6325
|
+
function touchesTree(tree, patch) {
|
|
6326
|
+
if (tree.size === 0) return false;
|
|
6327
|
+
for (const key of Object.keys(patch)) {
|
|
6328
|
+
const at = key.indexOf("@");
|
|
6329
|
+
if (tree.has(at > 0 ? key.slice(0, at) : key)) return true;
|
|
6330
|
+
}
|
|
6331
|
+
return false;
|
|
6332
|
+
}
|
|
6333
|
+
/** The blob as stored now; a failed read REFUSES the write instead of guessing. */
|
|
6334
|
+
async function readStoredAddonBlob(raw) {
|
|
6335
|
+
const threeWay = raw.readAddonStoreResult;
|
|
6336
|
+
if (threeWay === void 0) return raw.readAddonStore();
|
|
6337
|
+
const result = await threeWay.call(raw);
|
|
6338
|
+
if (result.kind === "failed") throw new Error(`settings write refused: the stored blob could not be read (${result.error})`);
|
|
6339
|
+
return result.kind === "missing" ? {} : result.value;
|
|
6340
|
+
}
|
|
6341
|
+
function createSecretAwareSettings(raw, opts) {
|
|
6342
|
+
const chains = /* @__PURE__ */ new Map();
|
|
6343
|
+
const serialize = (key, fn) => {
|
|
6344
|
+
const next = (chains.get(key) ?? Promise.resolve()).then(fn, fn);
|
|
6345
|
+
const tail = next.catch(() => void 0);
|
|
6346
|
+
chains.set(key, tail);
|
|
6347
|
+
tail.then(() => {
|
|
6348
|
+
if (chains.get(key) === tail) chains.delete(key);
|
|
6349
|
+
});
|
|
6350
|
+
return next;
|
|
6351
|
+
};
|
|
6352
|
+
const write = async (chainKey, tree, scope, patch, readStored, rawWrite) => {
|
|
6353
|
+
if (!touchesTree(tree, patch)) return rawWrite(patch);
|
|
6354
|
+
return serialize(chainKey, async () => {
|
|
6355
|
+
const stored = await readStored();
|
|
6356
|
+
const result = await transformSecretWrite({
|
|
6357
|
+
tree,
|
|
6358
|
+
secrets: opts.secrets,
|
|
6359
|
+
patch,
|
|
6360
|
+
stored,
|
|
6361
|
+
...scope !== void 0 ? { scope } : {},
|
|
6362
|
+
operatorWrite: opts.isOperatorWrite?.() === true
|
|
6363
|
+
});
|
|
6364
|
+
if (Object.keys(result.patch).length > 0) await rawWrite(result.patch);
|
|
6365
|
+
const { orphaned } = await result.afterWrite();
|
|
6366
|
+
if (orphaned.length > 0) opts.onOrphaned(orphaned);
|
|
6367
|
+
});
|
|
6368
|
+
};
|
|
6369
|
+
const wrapped = {
|
|
6370
|
+
writeAddonStore: (patch) => write("addon", opts.addonTree(), void 0, patch, () => readStoredAddonBlob(raw), (p) => raw.writeAddonStore(p)),
|
|
6371
|
+
writeDeviceStore: (deviceId, patch) => write(`device:${deviceId}`, opts.deviceTree(), {
|
|
6372
|
+
kind: "device",
|
|
6373
|
+
deviceId
|
|
6374
|
+
}, patch, () => raw.readDeviceStore(deviceId), (p) => raw.writeDeviceStore(deviceId, p))
|
|
6375
|
+
};
|
|
6376
|
+
return new Proxy(raw, { get(target, prop, receiver) {
|
|
6377
|
+
if (prop === "writeAddonStore") return wrapped.writeAddonStore;
|
|
6378
|
+
if (prop === "writeDeviceStore") return wrapped.writeDeviceStore;
|
|
6379
|
+
const value = Reflect.get(target, prop, receiver);
|
|
6380
|
+
return typeof value === "function" ? value.bind(target) : value;
|
|
6381
|
+
} });
|
|
6382
|
+
}
|
|
6383
|
+
/** The context the addon sees: identical, except that its settings writes are secret-aware. */
|
|
6384
|
+
function withSecretAwareSettings(context, opts) {
|
|
6385
|
+
const raw = context.settings;
|
|
6386
|
+
if (raw === void 0) return context;
|
|
6387
|
+
const settings = createSecretAwareSettings(raw, opts);
|
|
6388
|
+
return new Proxy(context, { get(target, prop, receiver) {
|
|
6389
|
+
if (prop === "settings") return settings;
|
|
6390
|
+
return Reflect.get(target, prop, receiver);
|
|
6391
|
+
} });
|
|
6392
|
+
}
|
|
6393
|
+
var LEAF = { kind: "leaf" };
|
|
6394
|
+
var DEFAULT_ITEM_ID_KEY = "id";
|
|
6395
|
+
function collectFields(fields, out) {
|
|
6396
|
+
for (const field of fields) {
|
|
6397
|
+
if (field.type === "group") {
|
|
6398
|
+
collectFields(field.fields, out);
|
|
6399
|
+
continue;
|
|
6400
|
+
}
|
|
6401
|
+
if (field.type === "sub-tabs") {
|
|
6402
|
+
for (const tab of field.tabs) collectFields(tab.fields, out);
|
|
6403
|
+
continue;
|
|
6404
|
+
}
|
|
6405
|
+
if (field.type === "editable-array") {
|
|
6406
|
+
const item = /* @__PURE__ */ new Map();
|
|
6407
|
+
for (const itemField of field.itemFields) if ("key" in itemField && isKeychainStoredField(itemField)) item.set(itemField.key, LEAF);
|
|
6408
|
+
if (item.size > 0) out.set(field.key, {
|
|
6409
|
+
kind: "array",
|
|
6410
|
+
idKey: field.itemIdKey ?? DEFAULT_ITEM_ID_KEY,
|
|
6411
|
+
item
|
|
6412
|
+
});
|
|
6413
|
+
continue;
|
|
6414
|
+
}
|
|
6415
|
+
if (!("key" in field) || typeof field.key !== "string") continue;
|
|
6416
|
+
if (isKeychainStoredField(field)) out.set(field.key, LEAF);
|
|
6417
|
+
}
|
|
6418
|
+
}
|
|
6419
|
+
/** The secret tree a settings schema declares. */
|
|
6420
|
+
function secretTreeFromSchema(schema) {
|
|
6421
|
+
const out = /* @__PURE__ */ new Map();
|
|
6422
|
+
if (schema === null) return out;
|
|
6423
|
+
for (const section of schema.sections) collectFields(section.fields, out);
|
|
6424
|
+
return out;
|
|
6425
|
+
}
|
|
6426
|
+
/** Parse `a.b[id].c` into segments; throws on a malformed path (a declaration bug). */
|
|
6427
|
+
function parseSecretStatePath(path) {
|
|
6428
|
+
const segments = [];
|
|
6429
|
+
for (const raw of path.split(".")) {
|
|
6430
|
+
const m = /^([^[\]]+)(?:\[([^[\]]+)\])?$/.exec(raw);
|
|
6431
|
+
if (m === null || m[1] === void 0) throw new Error(`secretStatePaths: malformed path "${path}"`);
|
|
6432
|
+
segments.push(m[2] !== void 0 ? {
|
|
6433
|
+
key: m[1],
|
|
6434
|
+
idKey: m[2]
|
|
6435
|
+
} : { key: m[1] });
|
|
6436
|
+
}
|
|
6437
|
+
if (segments.length === 0) throw new Error(`secretStatePaths: empty path`);
|
|
6438
|
+
if (segments[segments.length - 1]?.idKey !== void 0) throw new Error(`secretStatePaths: "${path}" ends on an array — name the member that is secret`);
|
|
6439
|
+
return segments;
|
|
6440
|
+
}
|
|
6441
|
+
function insert(into, segments) {
|
|
6442
|
+
const [head, ...rest] = segments;
|
|
6443
|
+
if (head === void 0) return;
|
|
6444
|
+
if (rest.length === 0) {
|
|
6445
|
+
into.set(head.key, LEAF);
|
|
6446
|
+
return;
|
|
6447
|
+
}
|
|
6448
|
+
const existing = into.get(head.key);
|
|
6449
|
+
if (head.idKey !== void 0) {
|
|
6450
|
+
const item = new Map(existing?.kind === "array" ? existing.item : []);
|
|
6451
|
+
insert(item, rest);
|
|
6452
|
+
into.set(head.key, {
|
|
6453
|
+
kind: "array",
|
|
6454
|
+
idKey: head.idKey,
|
|
6455
|
+
item
|
|
6456
|
+
});
|
|
6457
|
+
return;
|
|
6458
|
+
}
|
|
6459
|
+
const children = new Map(existing?.kind === "object" ? existing.children : []);
|
|
6460
|
+
insert(children, rest);
|
|
6461
|
+
into.set(head.key, {
|
|
6462
|
+
kind: "object",
|
|
6463
|
+
children
|
|
6464
|
+
});
|
|
6465
|
+
}
|
|
6466
|
+
/** Add hidden-state paths (`secretStatePaths`) to a schema-derived tree. */
|
|
6467
|
+
function mergeSecretStatePaths(tree, paths) {
|
|
6468
|
+
if (paths.length === 0) return tree;
|
|
6469
|
+
const out = new Map(tree);
|
|
6470
|
+
for (const path of paths) insert(out, parseSecretStatePath(path));
|
|
6471
|
+
return out;
|
|
6472
|
+
}
|
|
6473
|
+
/** First retry of a secret the keychain could not serve; doubles to {@link SECRET_RETRY_MAX_MS}. */
|
|
6474
|
+
var SECRET_RETRY_FIRST_MS = 5e3;
|
|
6475
|
+
var SECRET_RETRY_MAX_MS = 5 * 6e4;
|
|
6476
|
+
/** Coalesces a burst of `keychain.changed` events into one re-resolve. */
|
|
6477
|
+
var SECRET_CHANGE_DEBOUNCE_MS = 250;
|
|
5942
6478
|
/**
|
|
5943
6479
|
* Base class for CamStack addons. Eliminates settings boilerplate:
|
|
5944
6480
|
*
|
|
@@ -6008,6 +6544,25 @@ var BaseAddon = class {
|
|
|
6008
6544
|
settingsStoreReady = false;
|
|
6009
6545
|
/** Default config values. Provided via constructor. */
|
|
6010
6546
|
defaults;
|
|
6547
|
+
/**
|
|
6548
|
+
* Hidden-state paths that hold secrets (D787) — values the addon writes
|
|
6549
|
+
* itself (`updateGlobalSettings`, `state()`) that no form field declares.
|
|
6550
|
+
* Stored in the keychain exactly like a `password` field. Syntax:
|
|
6551
|
+
* `'snapshotSigningKey'`, `'identity.pincode'`, `'tokens[userId].accessToken'`
|
|
6552
|
+
* (`key[<id field>]` addresses array items by id, never by index).
|
|
6553
|
+
*/
|
|
6554
|
+
secretStatePaths = [];
|
|
6555
|
+
_addonSecretTree = null;
|
|
6556
|
+
_deviceSecretTree = null;
|
|
6557
|
+
/** Refs the last resolved config pointed at — a change to one re-resolves. */
|
|
6558
|
+
_configSecretRefs = /* @__PURE__ */ new Set();
|
|
6559
|
+
_unresolvedSecrets = [];
|
|
6560
|
+
_secretRetryTimer = null;
|
|
6561
|
+
_secretRetryDelayMs = SECRET_RETRY_FIRST_MS;
|
|
6562
|
+
_secretChangeTimer = null;
|
|
6563
|
+
_secretChangeUnsub = null;
|
|
6564
|
+
/** >0 while an OPERATOR's settings write is being applied. */
|
|
6565
|
+
_operatorWriteDepth = 0;
|
|
6011
6566
|
constructor(defaults) {
|
|
6012
6567
|
this.defaults = defaults;
|
|
6013
6568
|
this._config = { ...defaults };
|
|
@@ -6043,8 +6598,18 @@ var BaseAddon = class {
|
|
|
6043
6598
|
return this._config;
|
|
6044
6599
|
}
|
|
6045
6600
|
async initialize(context) {
|
|
6046
|
-
|
|
6601
|
+
const secrets = context.secrets;
|
|
6602
|
+
this._ctx = secrets !== void 0 ? withSecretAwareSettings(context, {
|
|
6603
|
+
secrets,
|
|
6604
|
+
addonTree: () => this.addonSecretTree(),
|
|
6605
|
+
deviceTree: () => this.deviceSecretTree(),
|
|
6606
|
+
onOrphaned: (refs) => context.logger.warn("keychain refs dropped by a settings write could not be deleted", { meta: { refs: [...refs] } }),
|
|
6607
|
+
isOperatorWrite: () => this._operatorWriteDepth > 0
|
|
6608
|
+
}) : context;
|
|
6047
6609
|
await this.resolveConfig();
|
|
6610
|
+
if (secrets !== void 0) this._secretChangeUnsub = secrets.onChange((ref) => {
|
|
6611
|
+
if (this._configSecretRefs.has(ref)) this.scheduleSecretReresolve(SECRET_CHANGE_DEBOUNCE_MS);
|
|
6612
|
+
});
|
|
6048
6613
|
const result = await this.onInitialize();
|
|
6049
6614
|
this.emitLifecycle(EventCategory.AddonStarted);
|
|
6050
6615
|
const normalized = normalizeAddonInitResult(result);
|
|
@@ -6077,6 +6642,12 @@ var BaseAddon = class {
|
|
|
6077
6642
|
*/
|
|
6078
6643
|
async onHubReachable() {}
|
|
6079
6644
|
async shutdown() {
|
|
6645
|
+
this._secretChangeUnsub?.();
|
|
6646
|
+
this._secretChangeUnsub = null;
|
|
6647
|
+
if (this._secretRetryTimer !== null) clearTimeout(this._secretRetryTimer);
|
|
6648
|
+
if (this._secretChangeTimer !== null) clearTimeout(this._secretChangeTimer);
|
|
6649
|
+
this._secretRetryTimer = null;
|
|
6650
|
+
this._secretChangeTimer = null;
|
|
6080
6651
|
this.emitLifecycle(EventCategory.AddonStopped);
|
|
6081
6652
|
if (this.autoEmitReadiness) this.emitReadinessForProviders("down");
|
|
6082
6653
|
await this.onShutdown();
|
|
@@ -6155,7 +6726,7 @@ var BaseAddon = class {
|
|
|
6155
6726
|
return hydrateSchema(schema, overlay ? {
|
|
6156
6727
|
...projected,
|
|
6157
6728
|
...overlay
|
|
6158
|
-
} : projected);
|
|
6729
|
+
} : projected, { inlineSecretsAsViews: true });
|
|
6159
6730
|
}
|
|
6160
6731
|
/**
|
|
6161
6732
|
* The integration-level view of this addon's settings: exactly the sections
|
|
@@ -6204,7 +6775,7 @@ var BaseAddon = class {
|
|
|
6204
6775
|
return hydrateSchema({
|
|
6205
6776
|
...schema,
|
|
6206
6777
|
sections
|
|
6207
|
-
}, projected);
|
|
6778
|
+
}, projected, { inlineSecretsAsViews: true });
|
|
6208
6779
|
}
|
|
6209
6780
|
/**
|
|
6210
6781
|
* The raw addon store PROJECTED onto the target node's bare per-node keys:
|
|
@@ -6258,18 +6829,50 @@ var BaseAddon = class {
|
|
|
6258
6829
|
value: result.value[key]
|
|
6259
6830
|
};
|
|
6260
6831
|
}
|
|
6832
|
+
/**
|
|
6833
|
+
* The OPERATOR's write — a settings form or an admin API call, dispatched by
|
|
6834
|
+
* the kernel. Identical to {@link updateGlobalSettings}, except that a secret
|
|
6835
|
+
* the operator sends is stored as sent even when it equals a pre-keychain
|
|
6836
|
+
* inline value: the operator re-entering a password is a change, an addon
|
|
6837
|
+
* writing back what it read is not (D787).
|
|
6838
|
+
*/
|
|
6839
|
+
async updateGlobalSettingsAsOperator(patch, nodeId) {
|
|
6840
|
+
this._operatorWriteDepth++;
|
|
6841
|
+
try {
|
|
6842
|
+
await this.applyGlobalPatch(patch, nodeId);
|
|
6843
|
+
} finally {
|
|
6844
|
+
this._operatorWriteDepth--;
|
|
6845
|
+
}
|
|
6846
|
+
}
|
|
6261
6847
|
async updateGlobalSettings(patch, nodeId) {
|
|
6848
|
+
await this.applyGlobalPatch(patch, nodeId);
|
|
6849
|
+
}
|
|
6850
|
+
/**
|
|
6851
|
+
* REMOVE stored secrets — their keychain values and their markers (D787).
|
|
6852
|
+
*
|
|
6853
|
+
* Writing `''` to a secret field KEEPS what is stored (an empty string is
|
|
6854
|
+
* what a defaults fallback writes back, and it must never destroy a
|
|
6855
|
+
* credential), so code that means "forget this token" says so here. Without
|
|
6856
|
+
* a keychain (an older kernel) it writes `''`, as such code always did.
|
|
6857
|
+
*/
|
|
6858
|
+
async clearSecrets(keys, nodeId) {
|
|
6859
|
+
const tree = this.addonSecretTree();
|
|
6860
|
+
const keychain = this._ctx?.secrets !== void 0;
|
|
6861
|
+
const patch = {};
|
|
6862
|
+
for (const key of keys) patch[key] = keychain && tree.has(key) ? SECRET_CLEAR : "";
|
|
6863
|
+
await this.applyGlobalPatch(patch, nodeId);
|
|
6864
|
+
}
|
|
6865
|
+
async applyGlobalPatch(barePatch, nodeId) {
|
|
6262
6866
|
const keys = this.perNodeKeys();
|
|
6263
6867
|
const localNode = normalizeNodeId(this._ctx?.kernel?.localNodeId);
|
|
6264
6868
|
const target = normalizeNodeId(nodeId ?? this._ctx?.kernel?.localNodeId);
|
|
6265
|
-
const barePatch = patch;
|
|
6266
6869
|
const scoped = keys.size > 0 ? scopePatch(barePatch, keys, target) : barePatch;
|
|
6267
6870
|
await this._ctx?.settings?.writeAddonStore(scoped);
|
|
6268
6871
|
if (target !== localNode) return;
|
|
6269
6872
|
await this.resolveConfig();
|
|
6270
6873
|
await this.onConfigChanged();
|
|
6271
6874
|
this.emitLifecycle(EventCategory.AddonUpdated, { level: "global" });
|
|
6272
|
-
this.maybeAutoRestart(
|
|
6875
|
+
this.maybeAutoRestart(Object.keys(barePatch), this.globalSettingsSchema());
|
|
6273
6876
|
}
|
|
6274
6877
|
/**
|
|
6275
6878
|
* The set of field keys the global settings schema declares `perNode: true`
|
|
@@ -6294,7 +6897,7 @@ var BaseAddon = class {
|
|
|
6294
6897
|
* time to return its response before the addon is torn down and
|
|
6295
6898
|
* re-initialised by `AddonRegistryService.restartAddon`.
|
|
6296
6899
|
*/
|
|
6297
|
-
maybeAutoRestart(
|
|
6900
|
+
maybeAutoRestart(patchKeys, schema) {
|
|
6298
6901
|
if (!schema) return;
|
|
6299
6902
|
const restartKeys = /* @__PURE__ */ new Set();
|
|
6300
6903
|
for (const section of schema.sections) for (const field of section.fields) {
|
|
@@ -6302,13 +6905,13 @@ var BaseAddon = class {
|
|
|
6302
6905
|
if (field.requiresRestart) restartKeys.add(field.key);
|
|
6303
6906
|
}
|
|
6304
6907
|
if (restartKeys.size === 0) return;
|
|
6305
|
-
if (!
|
|
6908
|
+
if (!patchKeys.some((k) => restartKeys.has(k))) return;
|
|
6306
6909
|
const ctx = this._ctx;
|
|
6307
6910
|
if (!ctx) return;
|
|
6308
6911
|
const addonId = ctx.id;
|
|
6309
6912
|
setImmediate(() => {
|
|
6310
6913
|
ctx.api.addons?.restartAddon?.mutate({ addonId }).then(() => {
|
|
6311
|
-
ctx.logger.info("addon auto-restart triggered by restart-required setting change", { meta: { changedFields:
|
|
6914
|
+
ctx.logger.info("addon auto-restart triggered by restart-required setting change", { meta: { changedFields: patchKeys.filter((k) => restartKeys.has(k)) } });
|
|
6312
6915
|
}).catch((err) => {
|
|
6313
6916
|
ctx.logger.error("addon auto-restart failed", { meta: { error: err instanceof Error ? err.message : String(err) } });
|
|
6314
6917
|
});
|
|
@@ -6317,7 +6920,7 @@ var BaseAddon = class {
|
|
|
6317
6920
|
async getDeviceSettings(deviceId) {
|
|
6318
6921
|
const schema = this.deviceSettingsSchema();
|
|
6319
6922
|
if (!schema) return { sections: [] };
|
|
6320
|
-
return hydrateSchema(schema, await this._ctx?.settings?.readDeviceStore(deviceId) ?? {});
|
|
6923
|
+
return hydrateSchema(schema, await this._ctx?.settings?.readDeviceStore(deviceId) ?? {}, { inlineSecretsAsViews: true });
|
|
6321
6924
|
}
|
|
6322
6925
|
async updateDeviceSettings(deviceId, patch) {
|
|
6323
6926
|
await this._ctx?.settings?.writeDeviceStore(deviceId, patch);
|
|
@@ -6447,7 +7050,7 @@ var BaseAddon = class {
|
|
|
6447
7050
|
* selection at boot (absent scoped key ⇒ the constructor default wins).
|
|
6448
7051
|
*/
|
|
6449
7052
|
async resolveConfig() {
|
|
6450
|
-
const stored = await this.readAddonStoreWithRetry();
|
|
7053
|
+
const stored = await this.resolveStoredSecrets(await this.readAddonStoreWithRetry());
|
|
6451
7054
|
const perNode = this.perNodeKeys();
|
|
6452
7055
|
const localNode = normalizeNodeId(this._ctx?.kernel?.localNodeId);
|
|
6453
7056
|
const resolved = { ...this.defaults };
|
|
@@ -6472,7 +7075,7 @@ var BaseAddon = class {
|
|
|
6472
7075
|
key,
|
|
6473
7076
|
schema,
|
|
6474
7077
|
fallback,
|
|
6475
|
-
read: () => this.readAddonStoreWithRetry(),
|
|
7078
|
+
read: async () => this.resolveStoredSecrets(await this.readAddonStoreWithRetry()),
|
|
6476
7079
|
write: async (patch) => {
|
|
6477
7080
|
await this._ctx?.settings?.writeAddonStore(patch);
|
|
6478
7081
|
},
|
|
@@ -6489,7 +7092,7 @@ var BaseAddon = class {
|
|
|
6489
7092
|
key,
|
|
6490
7093
|
schema,
|
|
6491
7094
|
fallback,
|
|
6492
|
-
read: async () => await this._ctx?.settings?.readDeviceStore(deviceId) ?? {},
|
|
7095
|
+
read: async () => this.resolveStoredSecrets(await this._ctx?.settings?.readDeviceStore(deviceId) ?? {}, false),
|
|
6493
7096
|
write: async (patch) => {
|
|
6494
7097
|
await this._ctx?.settings?.writeDeviceStore(deviceId, patch);
|
|
6495
7098
|
},
|
|
@@ -6501,6 +7104,70 @@ var BaseAddon = class {
|
|
|
6501
7104
|
} })
|
|
6502
7105
|
});
|
|
6503
7106
|
}
|
|
7107
|
+
/** The addon store's secret tree: schema fields by TYPE, plus `secretStatePaths`. */
|
|
7108
|
+
addonSecretTree() {
|
|
7109
|
+
this._addonSecretTree ??= mergeSecretStatePaths(secretTreeFromSchema(this.globalSettingsSchema()), this.secretStatePaths);
|
|
7110
|
+
return this._addonSecretTree;
|
|
7111
|
+
}
|
|
7112
|
+
deviceSecretTree() {
|
|
7113
|
+
this._deviceSecretTree ??= secretTreeFromSchema(this.deviceSettingsSchema());
|
|
7114
|
+
return this._deviceSecretTree;
|
|
7115
|
+
}
|
|
7116
|
+
/**
|
|
7117
|
+
* Secrets of this addon's stored config that could not be resolved on the
|
|
7118
|
+
* last read, with why. Non-empty means the addon is running WITHOUT them —
|
|
7119
|
+
* an addon whose function needs one should report itself degraded rather
|
|
7120
|
+
* than start on an empty credential.
|
|
7121
|
+
*/
|
|
7122
|
+
get unresolvedSecrets() {
|
|
7123
|
+
return this._unresolvedSecrets;
|
|
7124
|
+
}
|
|
7125
|
+
/**
|
|
7126
|
+
* Substitute every keychain marker in a stored blob with its value. With no
|
|
7127
|
+
* keychain (no `ctx.secrets`) or no marker, the blob comes back unchanged.
|
|
7128
|
+
* An unresolvable value is LEFT OUT (never `''`), logged by ref — never by
|
|
7129
|
+
* value — and, when the cause can pass, retried with backoff. Nothing is
|
|
7130
|
+
* ever written back from here.
|
|
7131
|
+
*/
|
|
7132
|
+
async resolveStoredSecrets(blob, trackForConfig = true) {
|
|
7133
|
+
const secrets = this._ctx?.secrets;
|
|
7134
|
+
if (secrets === void 0) return blob;
|
|
7135
|
+
const refs = collectSecretMarkerRefs(blob);
|
|
7136
|
+
if (trackForConfig) this._configSecretRefs = new Set(refs);
|
|
7137
|
+
if (refs.length === 0) {
|
|
7138
|
+
if (trackForConfig) this._unresolvedSecrets = [];
|
|
7139
|
+
return blob;
|
|
7140
|
+
}
|
|
7141
|
+
const { value, unresolved } = await resolveSecretMarkers(blob, secrets);
|
|
7142
|
+
if (trackForConfig) {
|
|
7143
|
+
this._unresolvedSecrets = unresolved;
|
|
7144
|
+
if (unresolved.length > 0) {
|
|
7145
|
+
this._ctx?.logger?.error?.("secret unavailable — running without it, will retry", { meta: { secrets: unresolved.map((u) => ({
|
|
7146
|
+
ref: u.ref,
|
|
7147
|
+
reason: u.reason
|
|
7148
|
+
})) } });
|
|
7149
|
+
if (unresolved.some((u) => u.reason !== "missing" && u.reason !== "forbidden")) {
|
|
7150
|
+
this.scheduleSecretReresolve(this._secretRetryDelayMs);
|
|
7151
|
+
this._secretRetryDelayMs = Math.min(this._secretRetryDelayMs * 2, SECRET_RETRY_MAX_MS);
|
|
7152
|
+
}
|
|
7153
|
+
} else this._secretRetryDelayMs = SECRET_RETRY_FIRST_MS;
|
|
7154
|
+
}
|
|
7155
|
+
return value;
|
|
7156
|
+
}
|
|
7157
|
+
/** Re-resolve the config (a keychain-only change, or a retry) and apply it. */
|
|
7158
|
+
scheduleSecretReresolve(delayMs) {
|
|
7159
|
+
const timerOf = delayMs === SECRET_CHANGE_DEBOUNCE_MS ? "_secretChangeTimer" : "_secretRetryTimer";
|
|
7160
|
+
if (this[timerOf] !== null) return;
|
|
7161
|
+
const timer = setTimeout(() => {
|
|
7162
|
+
this[timerOf] = null;
|
|
7163
|
+
if (this._ctx === null) return;
|
|
7164
|
+
this.resolveConfig().then(() => this.onConfigChanged()).catch((err) => {
|
|
7165
|
+
this._ctx?.logger?.error?.("re-resolving secrets failed", { meta: { error: err instanceof Error ? err.message : String(err) } });
|
|
7166
|
+
});
|
|
7167
|
+
}, delayMs);
|
|
7168
|
+
timer.unref?.();
|
|
7169
|
+
this[timerOf] = timer;
|
|
7170
|
+
}
|
|
6504
7171
|
/**
|
|
6505
7172
|
* Wrap `ctx.settings.readAddonStore()` with a short retry budget so a
|
|
6506
7173
|
* transient settings-store outage (mid-restart of sqlite-settings, tsx-watch
|
|
@@ -7076,6 +7743,69 @@ method(object({ deviceId: number() }), array(StreamSourceEntrySchema)), method(o
|
|
|
7076
7743
|
kind: "mutation",
|
|
7077
7744
|
auth: "admin"
|
|
7078
7745
|
}), method(object({ deviceId: number() }), unknown().nullable()), method(object({ deviceId: number() }), RawStateResultSchema.nullable(), { auth: "protected" });
|
|
7746
|
+
function defOf(schema) {
|
|
7747
|
+
return schema._zod?.def ?? {};
|
|
7748
|
+
}
|
|
7749
|
+
function declaredHere(schema) {
|
|
7750
|
+
return globalRegistry.get(schema)?.secret === true;
|
|
7751
|
+
}
|
|
7752
|
+
/** Wrapper kinds whose `innerType` is the field itself. */
|
|
7753
|
+
var WRAPPERS = new Set([
|
|
7754
|
+
"optional",
|
|
7755
|
+
"nullable",
|
|
7756
|
+
"default",
|
|
7757
|
+
"prefault",
|
|
7758
|
+
"catch",
|
|
7759
|
+
"readonly",
|
|
7760
|
+
"nonoptional"
|
|
7761
|
+
]);
|
|
7762
|
+
/**
|
|
7763
|
+
* The schema layers that make up ONE field: the schema itself and every
|
|
7764
|
+
* wrapper below it (optional / default / nullable / readonly / catch), plus
|
|
7765
|
+
* both sides of a pipe (`z.preprocess` puts the real schema on `out`,
|
|
7766
|
+
* `.transform` on `in`).
|
|
7767
|
+
*/
|
|
7768
|
+
function layersOf(schema) {
|
|
7769
|
+
const out = [];
|
|
7770
|
+
const queue = [schema];
|
|
7771
|
+
while (queue.length > 0) {
|
|
7772
|
+
const s = queue.shift();
|
|
7773
|
+
if (!s || out.includes(s)) continue;
|
|
7774
|
+
out.push(s);
|
|
7775
|
+
const def = defOf(s);
|
|
7776
|
+
if (def.type !== void 0 && WRAPPERS.has(def.type) && def.innerType) queue.push(def.innerType);
|
|
7777
|
+
if (def.type === "pipe") {
|
|
7778
|
+
if (def.in) queue.push(def.in);
|
|
7779
|
+
if (def.out) queue.push(def.out);
|
|
7780
|
+
}
|
|
7781
|
+
}
|
|
7782
|
+
return out;
|
|
7783
|
+
}
|
|
7784
|
+
/** True when any layer of this field declares `.meta({ secret: true })`. */
|
|
7785
|
+
function isZodSecret(schema) {
|
|
7786
|
+
return layersOf(schema).some(declaredHere);
|
|
7787
|
+
}
|
|
7788
|
+
/**
|
|
7789
|
+
* Every declared secret path in a config schema: dotted keys, `[]` for "each
|
|
7790
|
+
* element of this array" (`connection.password`, `rows[].token`). A declared
|
|
7791
|
+
* object or array is reported as one path and not descended into — everything
|
|
7792
|
+
* under it is secret.
|
|
7793
|
+
*/
|
|
7794
|
+
function collectZodSecretPaths(schema, prefix = "") {
|
|
7795
|
+
if (isZodSecret(schema)) return prefix.length > 0 ? [prefix] : [];
|
|
7796
|
+
const paths = [];
|
|
7797
|
+
for (const layer of layersOf(schema)) {
|
|
7798
|
+
const def = defOf(layer);
|
|
7799
|
+
if (def.type === "object" && def.shape) for (const [key, child] of Object.entries(def.shape)) paths.push(...collectZodSecretPaths(child, prefix ? `${prefix}.${key}` : key));
|
|
7800
|
+
else if (def.type === "array" && def.element) paths.push(...collectZodSecretPaths(def.element, `${prefix}[]`));
|
|
7801
|
+
else if (def.type === "union" && def.options) for (const option of def.options) paths.push(...collectZodSecretPaths(option, prefix));
|
|
7802
|
+
else if (def.type === "intersection") {
|
|
7803
|
+
if (def.left) paths.push(...collectZodSecretPaths(def.left, prefix));
|
|
7804
|
+
if (def.right) paths.push(...collectZodSecretPaths(def.right, prefix));
|
|
7805
|
+
}
|
|
7806
|
+
}
|
|
7807
|
+
return [...new Set(paths)];
|
|
7808
|
+
}
|
|
7079
7809
|
//#endregion
|
|
7080
7810
|
//#region ../types/dist/err-msg-DX6i_MY4.mjs
|
|
7081
7811
|
var DeviceType = /* @__PURE__ */ function(DeviceType) {
|
|
@@ -14126,6 +14856,214 @@ id: union([string(), number()]) }), {
|
|
|
14126
14856
|
kind: "mutation",
|
|
14127
14857
|
auth: "admin"
|
|
14128
14858
|
});
|
|
14859
|
+
/**
|
|
14860
|
+
* `keychain` — the hub's encrypted store of secret values (D787).
|
|
14861
|
+
*
|
|
14862
|
+
* Settings blobs never hold a secret: they hold a marker
|
|
14863
|
+
* `{"$secret":"secret://<owner>/<scope>/<fieldPath>","v":1}` and the value
|
|
14864
|
+
* lives here, AES-256-GCM under a data key that a master key wraps. This cap
|
|
14865
|
+
* is the OWNER's door to its own values: every method is owner-checked
|
|
14866
|
+
* against the CALLER, never against anything the caller claims.
|
|
14867
|
+
*
|
|
14868
|
+
* Who the caller is: the transport stamps `callerAddonId` into the args of a
|
|
14869
|
+
* call that crossed a process (the parent `LocalChildRegistry` from the UDS
|
|
14870
|
+
* connection, the agent from its child's connection carried in
|
|
14871
|
+
* `$hub-cap-fwd`'s envelope). A stamp always overwrites; a wire call with no
|
|
14872
|
+
* stamp has its claim stripped. Only a hub in-process caller may state its own
|
|
14873
|
+
* identity — `ctx.secrets` does that with the addon id closed over. This is
|
|
14874
|
+
* identity against BUGS and misrouting, not against a malicious addon (every
|
|
14875
|
+
* runner is the same OS user): see the threat model in
|
|
14876
|
+
* `docs/design/2026-10-08-secrets-keychain.md`.
|
|
14877
|
+
*
|
|
14878
|
+
* `callerAddonId` is deliberately NOT in any input schema: the tRPC router
|
|
14879
|
+
* parses the input, so a session can never supply it, and the internal mount
|
|
14880
|
+
* floors every method to admin anyway (D240).
|
|
14881
|
+
*
|
|
14882
|
+
* Internal: addons reach it through `ctx.secrets`, never directly.
|
|
14883
|
+
*/
|
|
14884
|
+
/** Why a value cannot be served right now. Never folded into "missing". */
|
|
14885
|
+
var KeychainUnavailableReasonSchema = _enum([
|
|
14886
|
+
"key-missing",
|
|
14887
|
+
"wrong-key",
|
|
14888
|
+
"key-file-unreadable",
|
|
14889
|
+
"store-unavailable",
|
|
14890
|
+
"not-initialized",
|
|
14891
|
+
"decrypt-failed"
|
|
14892
|
+
]);
|
|
14893
|
+
var KeychainStateSchema = discriminatedUnion("state", [object({ state: literal("ready") }), object({
|
|
14894
|
+
state: literal("locked"),
|
|
14895
|
+
reason: KeychainUnavailableReasonSchema
|
|
14896
|
+
})]);
|
|
14897
|
+
var KeychainResolveEntrySchema = discriminatedUnion("kind", [
|
|
14898
|
+
object({
|
|
14899
|
+
kind: literal("value"),
|
|
14900
|
+
value: string(),
|
|
14901
|
+
version: number().int()
|
|
14902
|
+
}),
|
|
14903
|
+
object({ kind: literal("missing") }),
|
|
14904
|
+
object({
|
|
14905
|
+
kind: literal("unavailable"),
|
|
14906
|
+
reason: KeychainUnavailableReasonSchema
|
|
14907
|
+
}),
|
|
14908
|
+
object({ kind: literal("forbidden") })
|
|
14909
|
+
]);
|
|
14910
|
+
var KeychainResolveResultSchema = record(string(), KeychainResolveEntrySchema);
|
|
14911
|
+
/** Metadata of one stored value — never the value. */
|
|
14912
|
+
var KeychainSecretMetaSchema = object({
|
|
14913
|
+
ref: string(),
|
|
14914
|
+
owner: string(),
|
|
14915
|
+
/** Formatted scope (`global`, `node/<id>`, `device/<id>`, …). */
|
|
14916
|
+
scope: string(),
|
|
14917
|
+
fieldPath: string(),
|
|
14918
|
+
version: number().int(),
|
|
14919
|
+
createdAt: number(),
|
|
14920
|
+
updatedAt: number(),
|
|
14921
|
+
/** `addon:<id>` | `user:<id>` | `system`. */
|
|
14922
|
+
updatedBy: string(),
|
|
14923
|
+
/** Coarse — written at most once an hour per ref. `null` = never read. */
|
|
14924
|
+
lastReadAt: number().nullable()
|
|
14925
|
+
});
|
|
14926
|
+
var RefListSchema = array(string().min(1)).max(512);
|
|
14927
|
+
method(object({
|
|
14928
|
+
ref: string().min(1),
|
|
14929
|
+
value: string().min(1)
|
|
14930
|
+
}), object({
|
|
14931
|
+
ref: string(),
|
|
14932
|
+
version: number().int()
|
|
14933
|
+
}), {
|
|
14934
|
+
kind: "mutation",
|
|
14935
|
+
auth: "admin"
|
|
14936
|
+
}), method(object({ refs: RefListSchema }), KeychainResolveResultSchema, { auth: "admin" }), method(object({ refs: RefListSchema }), object({ deleted: number().int() }), {
|
|
14937
|
+
kind: "mutation",
|
|
14938
|
+
auth: "admin"
|
|
14939
|
+
}), method(object({}), array(KeychainSecretMetaSchema).readonly(), { auth: "admin" }), method(object({}), KeychainStateSchema, { auth: "admin" });
|
|
14940
|
+
var KeychainKeySourceSchema = object({
|
|
14941
|
+
kind: _enum([
|
|
14942
|
+
"config-file",
|
|
14943
|
+
"previous-config-file",
|
|
14944
|
+
"platform",
|
|
14945
|
+
"default-file"
|
|
14946
|
+
]),
|
|
14947
|
+
/** File sources only — a path is not a secret. */
|
|
14948
|
+
path: string().optional(),
|
|
14949
|
+
/**
|
|
14950
|
+
* True when a whole-volume backup of the data directory carries this key
|
|
14951
|
+
* next to the database it protects (the default file). The page warns.
|
|
14952
|
+
*/
|
|
14953
|
+
sharesBackupWithDatabase: boolean()
|
|
14954
|
+
});
|
|
14955
|
+
var KeychainStatusSchema = object({
|
|
14956
|
+
keychain: KeychainStateSchema,
|
|
14957
|
+
/** The source of the master key in use; `null` while locked. */
|
|
14958
|
+
keySource: KeychainKeySourceSchema.nullable(),
|
|
14959
|
+
/** The source configured to be primary — differs from `keySource` while a rotation is pending. */
|
|
14960
|
+
configuredSource: KeychainKeySourceSchema,
|
|
14961
|
+
/** Short fingerprint of the master key in use (`HMAC(KEK, label)`, 16 hex). */
|
|
14962
|
+
fingerprint: string().nullable(),
|
|
14963
|
+
activeKeyId: string().nullable(),
|
|
14964
|
+
/**
|
|
14965
|
+
* The keychain unlocked with a NON-primary source: the configured primary
|
|
14966
|
+
* key is not the one that wraps the data key yet. `rotateMasterKey` moves it.
|
|
14967
|
+
*/
|
|
14968
|
+
rotationPending: boolean(),
|
|
14969
|
+
/** Wrapped copies of the data key under a previous master key, kept until purged. */
|
|
14970
|
+
retiredWraps: number().int(),
|
|
14971
|
+
recoveryKeyDownloadedAt: number().nullable(),
|
|
14972
|
+
secretCount: number().int()
|
|
14973
|
+
});
|
|
14974
|
+
/**
|
|
14975
|
+
* Whether a stored value is still pointed at by its owner's settings.
|
|
14976
|
+
* `unknown` is a first-class answer: a scope whose blob could not be read is
|
|
14977
|
+
* never reported as an orphan (and never deleted as one).
|
|
14978
|
+
*/
|
|
14979
|
+
var KeychainSecretUsageSchema = _enum([
|
|
14980
|
+
"in-use",
|
|
14981
|
+
"orphan",
|
|
14982
|
+
"unknown"
|
|
14983
|
+
]);
|
|
14984
|
+
var KeychainAdminSecretSchema = KeychainSecretMetaSchema.extend({ usage: KeychainSecretUsageSchema });
|
|
14985
|
+
var KeychainAuditActionSchema = _enum([
|
|
14986
|
+
"put",
|
|
14987
|
+
"delete",
|
|
14988
|
+
"reveal",
|
|
14989
|
+
"rotate-master-key",
|
|
14990
|
+
"purge-retired-keys",
|
|
14991
|
+
"download-recovery-key",
|
|
14992
|
+
"delete-orphans",
|
|
14993
|
+
"reset",
|
|
14994
|
+
"initialize"
|
|
14995
|
+
]);
|
|
14996
|
+
var KeychainAuditEntrySchema = object({
|
|
14997
|
+
id: string(),
|
|
14998
|
+
at: number(),
|
|
14999
|
+
action: KeychainAuditActionSchema,
|
|
15000
|
+
/** `addon:<id>` | `user:<id>` | `system`. */
|
|
15001
|
+
actor: string(),
|
|
15002
|
+
ref: string().nullable(),
|
|
15003
|
+
detail: string().nullable()
|
|
15004
|
+
});
|
|
15005
|
+
var KEYCHAIN_RESET_CONFIRMATION = "RESET KEYCHAIN";
|
|
15006
|
+
/**
|
|
15007
|
+
* Secrets the HUB itself holds (owner `system`) that no settings form shows:
|
|
15008
|
+
* `jwt-signing-key` — the session signing key (D797). It is always "in use",
|
|
15009
|
+
* never an orphan; it is generated on a fresh hub and replaced only through
|
|
15010
|
+
* {@link keychainAdminCapability.methods.setSystemSecret}.
|
|
15011
|
+
*/
|
|
15012
|
+
var SystemHeldSecretNameSchema = _enum(["jwt-signing-key"]);
|
|
15013
|
+
method(object({}), KeychainStatusSchema, { auth: "admin" }), method(object({}), array(KeychainAdminSecretSchema).readonly(), { auth: "admin" }), method(object({ limit: number().int().min(1).max(500).optional() }), array(KeychainAuditEntrySchema).readonly(), { auth: "admin" }), method(object({ ref: string().min(1) }), object({
|
|
15014
|
+
value: string(),
|
|
15015
|
+
version: number().int()
|
|
15016
|
+
}), {
|
|
15017
|
+
kind: "mutation",
|
|
15018
|
+
auth: "admin",
|
|
15019
|
+
caller: "required"
|
|
15020
|
+
}), method(object({
|
|
15021
|
+
name: SystemHeldSecretNameSchema,
|
|
15022
|
+
value: string().min(16)
|
|
15023
|
+
}), object({
|
|
15024
|
+
ref: string(),
|
|
15025
|
+
version: number().int()
|
|
15026
|
+
}), {
|
|
15027
|
+
kind: "mutation",
|
|
15028
|
+
auth: "admin",
|
|
15029
|
+
caller: "required"
|
|
15030
|
+
}), method(object({ refs: array(string().min(1)).max(1e3) }), object({
|
|
15031
|
+
deleted: array(string()).readonly(),
|
|
15032
|
+
kept: array(object({
|
|
15033
|
+
ref: string(),
|
|
15034
|
+
usage: KeychainSecretUsageSchema
|
|
15035
|
+
})).readonly()
|
|
15036
|
+
}), {
|
|
15037
|
+
kind: "mutation",
|
|
15038
|
+
auth: "admin",
|
|
15039
|
+
caller: "required"
|
|
15040
|
+
}), method(object({}), object({
|
|
15041
|
+
fingerprint: string(),
|
|
15042
|
+
keySource: KeychainKeySourceSchema
|
|
15043
|
+
}), {
|
|
15044
|
+
kind: "mutation",
|
|
15045
|
+
auth: "admin",
|
|
15046
|
+
caller: "required"
|
|
15047
|
+
}), method(object({}), object({ purged: number().int() }), {
|
|
15048
|
+
kind: "mutation",
|
|
15049
|
+
auth: "admin",
|
|
15050
|
+
caller: "required"
|
|
15051
|
+
}), method(object({}), object({
|
|
15052
|
+
key: string(),
|
|
15053
|
+
fingerprint: string(),
|
|
15054
|
+
keySource: KeychainKeySourceSchema
|
|
15055
|
+
}), {
|
|
15056
|
+
kind: "mutation",
|
|
15057
|
+
auth: "admin",
|
|
15058
|
+
caller: "required"
|
|
15059
|
+
}), method(object({ confirm: literal(KEYCHAIN_RESET_CONFIRMATION) }), object({
|
|
15060
|
+
archivedCollection: string().nullable(),
|
|
15061
|
+
archived: number().int()
|
|
15062
|
+
}), {
|
|
15063
|
+
kind: "mutation",
|
|
15064
|
+
auth: "admin",
|
|
15065
|
+
caller: "required"
|
|
15066
|
+
});
|
|
14129
15067
|
method(_void(), object({
|
|
14130
15068
|
id: string(),
|
|
14131
15069
|
name: string(),
|
|
@@ -15368,7 +16306,11 @@ var DeviceRegisterPayloadSchema = object({
|
|
|
15368
16306
|
var DeviceRemovePayloadSchema = object({ deviceId: number() });
|
|
15369
16307
|
var DevicePersistConfigPayloadSchema = object({
|
|
15370
16308
|
deviceId: number(),
|
|
15371
|
-
data: record(string(), unknown())
|
|
16309
|
+
data: record(string(), unknown()),
|
|
16310
|
+
/** The paths the device's schema declares secret (D783), when the caller
|
|
16311
|
+
* knows them — those values are kept in the keychain, not the blob (D787).
|
|
16312
|
+
* Absent: the paths the device last reported at `registerDevice` apply. */
|
|
16313
|
+
secretConfigPaths: array(string()).optional()
|
|
15372
16314
|
});
|
|
15373
16315
|
/** What a migration actually did, per switch. `unreachable` is a first-class
|
|
15374
16316
|
* answer: a camera that could not be asked is not a camera that was silenced. */
|
|
@@ -22385,8 +23327,23 @@ var RetrainMacroClassSchema = _enum([
|
|
|
22385
23327
|
]);
|
|
22386
23328
|
/** A subject to learn, or a phantom to unlearn (taught by OMISSION). */
|
|
22387
23329
|
var RetrainAnnotationKindSchema = _enum(["subject", "model_error"]);
|
|
22388
|
-
/**
|
|
22389
|
-
|
|
23330
|
+
/**
|
|
23331
|
+
* Where a box came from. A machine-sourced box is a DRAFT on the page until
|
|
23332
|
+
* the operator confirms it; once saved it keeps its source as provenance.
|
|
23333
|
+
*
|
|
23334
|
+
* - `operator` — drawn by hand.
|
|
23335
|
+
* - `assist` — proposed by a detector run on the copy (the camera's own
|
|
23336
|
+
* model, or a larger teacher model).
|
|
23337
|
+
* - `pipeline` — the box the live pipeline actually drew on that frame, read
|
|
23338
|
+
* back from the track store (never a re-run).
|
|
23339
|
+
* - `llm` — proposed by a vision-capable LLM profile.
|
|
23340
|
+
*/
|
|
23341
|
+
var RetrainAnnotationSourceSchema = _enum([
|
|
23342
|
+
"operator",
|
|
23343
|
+
"assist",
|
|
23344
|
+
"pipeline",
|
|
23345
|
+
"llm"
|
|
23346
|
+
]);
|
|
22390
23347
|
/** Normalised `[0,1]` rectangle against the FULL frame — the canonical form. */
|
|
22391
23348
|
var RetrainBboxSchema = object({
|
|
22392
23349
|
x: number(),
|
|
@@ -22404,7 +23361,8 @@ var RetrainBboxSchema = object({
|
|
|
22404
23361
|
*/
|
|
22405
23362
|
var RetrainAnnotationSchema = object({
|
|
22406
23363
|
id: string(),
|
|
22407
|
-
|
|
23364
|
+
/** The frame's track. Absent on a recording still, which has none. */
|
|
23365
|
+
trackId: string().optional(),
|
|
22408
23366
|
deviceId: number(),
|
|
22409
23367
|
/** The COPY in retrain storage — never the source track's media key. */
|
|
22410
23368
|
mediaKey: string(),
|
|
@@ -22453,13 +23411,47 @@ var RetrainFrameCandidateSchema = object({
|
|
|
22453
23411
|
* fail, whatever became of the original. */
|
|
22454
23412
|
copied: boolean()
|
|
22455
23413
|
});
|
|
23414
|
+
/**
|
|
23415
|
+
* One box the live pipeline drew on a copied frame — what a correction starts
|
|
23416
|
+
* from. Derived when the frame is listed, from the track store: the subject
|
|
23417
|
+
* box recorded on the source media row when there is one, else the track
|
|
23418
|
+
* position nearest the frame's capture time. Never stored as an annotation
|
|
23419
|
+
* until the operator confirms it.
|
|
23420
|
+
*/
|
|
23421
|
+
var RetrainPipelineBoxSchema = object({
|
|
23422
|
+
/** Normalised `[0,1]` against the full frame. */
|
|
23423
|
+
bbox: RetrainBboxSchema,
|
|
23424
|
+
macroClass: RetrainMacroClassSchema,
|
|
23425
|
+
label: string().optional(),
|
|
23426
|
+
subLabel: string().optional(),
|
|
23427
|
+
/** The detection score of the position used, when it was recorded. */
|
|
23428
|
+
score: number().optional(),
|
|
23429
|
+
/** The root model that produced the track, when it was recorded. */
|
|
23430
|
+
modelId: string().optional(),
|
|
23431
|
+
trackId: string(),
|
|
23432
|
+
/** `subject-box`: recorded on this very frame. `position`: the track's
|
|
23433
|
+
* position nearest the capture time, `deltaMs` away. */
|
|
23434
|
+
basis: _enum(["subject-box", "position"]),
|
|
23435
|
+
deltaMs: number()
|
|
23436
|
+
});
|
|
23437
|
+
/**
|
|
23438
|
+
* Where a retrain frame came from: a TRACK's stored media (copy-on-select),
|
|
23439
|
+
* or the RECORDING at an instant — the frame a model saw nothing in has no
|
|
23440
|
+
* track at all.
|
|
23441
|
+
*/
|
|
23442
|
+
var RetrainFrameOriginSchema = _enum(["track", "recording"]);
|
|
22456
23443
|
/** A frame the dataset OWNS: bytes copied at selection time. */
|
|
22457
23444
|
var RetrainFrameSchema = object({
|
|
22458
23445
|
frameId: string(),
|
|
22459
23446
|
deviceId: number(),
|
|
22460
|
-
|
|
22461
|
-
/**
|
|
22462
|
-
|
|
23447
|
+
origin: RetrainFrameOriginSchema,
|
|
23448
|
+
/** The track it was copied from. Absent on a recording still. */
|
|
23449
|
+
trackId: string().optional(),
|
|
23450
|
+
/** Provenance only. It may already point at nothing — that is expected.
|
|
23451
|
+
* Absent on a recording still. */
|
|
23452
|
+
sourceMediaId: number().int().optional(),
|
|
23453
|
+
/** A recording still: the playhead instant it was taken at. */
|
|
23454
|
+
epochMs: number().optional(),
|
|
22463
23455
|
sourceKind: MediaFileKindEnum,
|
|
22464
23456
|
sizeBytes: number().int(),
|
|
22465
23457
|
width: number().int(),
|
|
@@ -22470,7 +23462,12 @@ var RetrainFrameSchema = object({
|
|
|
22470
23462
|
/** The operator's "every subject in this frame is boxed". Detector
|
|
22471
23463
|
* evaluation keeps only complete frames: an unboxed subject would count as
|
|
22472
23464
|
* a false positive. */
|
|
22473
|
-
complete: boolean()
|
|
23465
|
+
complete: boolean(),
|
|
23466
|
+
/** The boxes the pipeline drew on this frame. Present on list answers;
|
|
23467
|
+
* empty when nothing the track store holds can be placed on it. */
|
|
23468
|
+
pipelineBoxes: array(RetrainPipelineBoxSchema).readonly().optional(),
|
|
23469
|
+
/** The named collections this frame belongs to. Present on list answers. */
|
|
23470
|
+
collectionIds: array(string()).readonly().optional()
|
|
22474
23471
|
});
|
|
22475
23472
|
/** Why a copy-on-select could not be honoured — named, never a silent skip. */
|
|
22476
23473
|
var RetrainCopyRefusalSchema = _enum([
|
|
@@ -22501,6 +23498,11 @@ var RetrainFrameListSchema = object({
|
|
|
22501
23498
|
var RetrainExportFilterSchema = object({
|
|
22502
23499
|
deviceIds: array(number()).optional(),
|
|
22503
23500
|
frameIds: array(string()).max(2e4).optional(),
|
|
23501
|
+
/** Only frames in at least one of these named collections. */
|
|
23502
|
+
collectionIds: array(string()).max(200).optional(),
|
|
23503
|
+
/** Exactly the frames of this dataset version (and its completeOnly). An
|
|
23504
|
+
* unknown id selects nothing. */
|
|
23505
|
+
datasetVersionId: string().optional(),
|
|
22504
23506
|
batchId: string().optional(),
|
|
22505
23507
|
/** Only frames the operator marked complete (all subjects boxed). */
|
|
22506
23508
|
completeOnly: boolean().optional()
|
|
@@ -22565,6 +23567,170 @@ var RetrainAssistResultSchema = discriminatedUnion("kind", [object({
|
|
|
22565
23567
|
reason: string(),
|
|
22566
23568
|
detail: string().optional()
|
|
22567
23569
|
})]);
|
|
23570
|
+
/** A named set over the retrain corpus — membership only, it owns no pixels. */
|
|
23571
|
+
var RetrainCollectionSchema = object({
|
|
23572
|
+
id: string(),
|
|
23573
|
+
name: string(),
|
|
23574
|
+
createdAt: number(),
|
|
23575
|
+
frameCount: number().int()
|
|
23576
|
+
});
|
|
23577
|
+
var RetrainCollectionCreateResultSchema = discriminatedUnion("kind", [object({
|
|
23578
|
+
kind: literal("created"),
|
|
23579
|
+
collection: RetrainCollectionSchema
|
|
23580
|
+
}), object({
|
|
23581
|
+
kind: literal("refused"),
|
|
23582
|
+
reason: _enum(["empty-name", "duplicate-name"])
|
|
23583
|
+
})]);
|
|
23584
|
+
var RetrainCollectionRenameResultSchema = discriminatedUnion("kind", [object({
|
|
23585
|
+
kind: literal("renamed"),
|
|
23586
|
+
collection: RetrainCollectionSchema
|
|
23587
|
+
}), object({
|
|
23588
|
+
kind: literal("refused"),
|
|
23589
|
+
reason: _enum([
|
|
23590
|
+
"empty-name",
|
|
23591
|
+
"duplicate-name",
|
|
23592
|
+
"unknown-collection"
|
|
23593
|
+
])
|
|
23594
|
+
})]);
|
|
23595
|
+
/**
|
|
23596
|
+
* The outcome of adding the frame at a recording instant. Every refusal is
|
|
23597
|
+
* named: `still-unavailable` (not recording, a gap, or an undecodable frame —
|
|
23598
|
+
* `detail` says which), `still-busy` (the recorder is at its decode bound; try
|
|
23599
|
+
* again), `unreadable-image`, `write-failed`, `unknown-collection`.
|
|
23600
|
+
*/
|
|
23601
|
+
var AddRetrainFrameFromRecordingResultSchema = discriminatedUnion("kind", [object({
|
|
23602
|
+
kind: literal("added"),
|
|
23603
|
+
collectionId: string(),
|
|
23604
|
+
frame: RetrainFrameSchema,
|
|
23605
|
+
/** The moment was already in the dataset; nothing was decoded. */
|
|
23606
|
+
reused: boolean()
|
|
23607
|
+
}), object({
|
|
23608
|
+
kind: literal("refused"),
|
|
23609
|
+
reason: _enum([
|
|
23610
|
+
"unknown-collection",
|
|
23611
|
+
"still-unavailable",
|
|
23612
|
+
"still-busy",
|
|
23613
|
+
"unreadable-image",
|
|
23614
|
+
"write-failed"
|
|
23615
|
+
]),
|
|
23616
|
+
detail: string().optional()
|
|
23617
|
+
})]);
|
|
23618
|
+
/** A vision LLM profile the AI assist may use, and where it sends the frame. */
|
|
23619
|
+
var RetrainAssistProfileSchema = object({
|
|
23620
|
+
id: string(),
|
|
23621
|
+
name: string(),
|
|
23622
|
+
model: string(),
|
|
23623
|
+
kind: string(),
|
|
23624
|
+
/** `true` when the frame would leave the house (a cloud vendor, or an
|
|
23625
|
+
* endpoint that is not on the local network). The page confirms each such
|
|
23626
|
+
* run, and the provider refuses one without `allowCloud`. */
|
|
23627
|
+
leavesHouse: boolean()
|
|
23628
|
+
});
|
|
23629
|
+
/** A box the AI assist proposed: a draft, plus the model's own reason. */
|
|
23630
|
+
var RetrainLlmProposalSchema = RetrainAnnotationDraftSchema.extend({ reason: string() });
|
|
23631
|
+
/** What the AI assist said about a box that was already on the canvas. */
|
|
23632
|
+
var RetrainLlmReviewSchema = object({
|
|
23633
|
+
/** The `ref` the page sent the box under. */
|
|
23634
|
+
ref: string(),
|
|
23635
|
+
verdict: _enum([
|
|
23636
|
+
"confirmed",
|
|
23637
|
+
"wrong-class",
|
|
23638
|
+
"not-an-object",
|
|
23639
|
+
"uncertain"
|
|
23640
|
+
]),
|
|
23641
|
+
suggestedClass: RetrainMacroClassSchema.optional(),
|
|
23642
|
+
reason: string()
|
|
23643
|
+
});
|
|
23644
|
+
/**
|
|
23645
|
+
* The AI assist's answer. `proposed` carries drafts (`source: 'llm'`, the
|
|
23646
|
+
* model and its confidence) and reviews; items the model got wrong (a box off
|
|
23647
|
+
* the frame, an unasked class, an unknown ref) are dropped and counted in
|
|
23648
|
+
* `rejected`. A whole answer that is not the schema is `malformed-answer`.
|
|
23649
|
+
*/
|
|
23650
|
+
var RetrainLlmAssistResultSchema = discriminatedUnion("kind", [object({
|
|
23651
|
+
kind: literal("proposed"),
|
|
23652
|
+
profileId: string(),
|
|
23653
|
+
model: string(),
|
|
23654
|
+
/** The frame was sent outside the house for this answer. */
|
|
23655
|
+
leftHouse: boolean(),
|
|
23656
|
+
proposals: array(RetrainLlmProposalSchema).readonly(),
|
|
23657
|
+
reviews: array(RetrainLlmReviewSchema).readonly(),
|
|
23658
|
+
rejected: number().int()
|
|
23659
|
+
}), object({
|
|
23660
|
+
kind: literal("refused"),
|
|
23661
|
+
reason: _enum([
|
|
23662
|
+
"unknown-frame",
|
|
23663
|
+
"unreadable-frame",
|
|
23664
|
+
"unknown-profile",
|
|
23665
|
+
"profile-disabled",
|
|
23666
|
+
"no-vision",
|
|
23667
|
+
"cloud-not-confirmed",
|
|
23668
|
+
"llm-error",
|
|
23669
|
+
"malformed-answer"
|
|
23670
|
+
]),
|
|
23671
|
+
detail: string().optional()
|
|
23672
|
+
})]);
|
|
23673
|
+
/** What a dataset version is cut from. Every field narrows. */
|
|
23674
|
+
var RetrainDatasetSelectionSchema = object({
|
|
23675
|
+
deviceIds: array(number()).readonly().optional(),
|
|
23676
|
+
collectionIds: array(string()).max(200).readonly().optional(),
|
|
23677
|
+
frameIds: array(string()).max(2e4).readonly().optional()
|
|
23678
|
+
});
|
|
23679
|
+
/** The counts a dataset is judged by. */
|
|
23680
|
+
var RetrainDatasetStatsSchema = object({
|
|
23681
|
+
frames: number().int(),
|
|
23682
|
+
completeFrames: number().int(),
|
|
23683
|
+
/** `completeFrames / frames`, 0..1. */
|
|
23684
|
+
completeness: number(),
|
|
23685
|
+
/** Boxes to learn (model errors excluded). */
|
|
23686
|
+
subjects: number().int(),
|
|
23687
|
+
modelErrors: number().int(),
|
|
23688
|
+
/** Complete frames with no subject. */
|
|
23689
|
+
hardNegatives: number().int(),
|
|
23690
|
+
/** Subjects per class × camera × day/night. */
|
|
23691
|
+
cells: array(object({
|
|
23692
|
+
macroClass: string(),
|
|
23693
|
+
deviceId: number(),
|
|
23694
|
+
lighting: _enum([
|
|
23695
|
+
"day",
|
|
23696
|
+
"night",
|
|
23697
|
+
"unknown"
|
|
23698
|
+
]),
|
|
23699
|
+
subjects: number().int(),
|
|
23700
|
+
frames: number().int()
|
|
23701
|
+
})).readonly(),
|
|
23702
|
+
cameras: array(object({
|
|
23703
|
+
deviceId: number(),
|
|
23704
|
+
frames: number().int(),
|
|
23705
|
+
completeFrames: number().int()
|
|
23706
|
+
})).readonly()
|
|
23707
|
+
});
|
|
23708
|
+
/** An immutable dataset version, without its frame list. */
|
|
23709
|
+
var RetrainDatasetVersionSchema = object({
|
|
23710
|
+
id: string(),
|
|
23711
|
+
name: string(),
|
|
23712
|
+
createdAt: number(),
|
|
23713
|
+
selection: RetrainDatasetSelectionSchema,
|
|
23714
|
+
layout: RetrainExportLayoutSchema,
|
|
23715
|
+
completeOnly: boolean(),
|
|
23716
|
+
frameCount: number().int(),
|
|
23717
|
+
/** sha256 of what the frames taught when the version was frozen. */
|
|
23718
|
+
annotationHash: string(),
|
|
23719
|
+
/** The export manifest schema the version was cut under. */
|
|
23720
|
+
manifestSchema: string(),
|
|
23721
|
+
stats: RetrainDatasetStatsSchema
|
|
23722
|
+
});
|
|
23723
|
+
var CreateRetrainDatasetVersionResultSchema = discriminatedUnion("kind", [object({
|
|
23724
|
+
kind: literal("created"),
|
|
23725
|
+
version: RetrainDatasetVersionSchema
|
|
23726
|
+
}), object({
|
|
23727
|
+
kind: literal("refused"),
|
|
23728
|
+
reason: _enum([
|
|
23729
|
+
"empty-name",
|
|
23730
|
+
"duplicate-name",
|
|
23731
|
+
"no-frames"
|
|
23732
|
+
])
|
|
23733
|
+
})]);
|
|
22568
23734
|
/** The outcome of a lifecycle move owned by the retrain page. */
|
|
22569
23735
|
var RetrainTransitionResultSchema = object({
|
|
22570
23736
|
trackId: string(),
|
|
@@ -23282,7 +24448,7 @@ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).rea
|
|
|
23282
24448
|
auth: "admin"
|
|
23283
24449
|
}), method(object({
|
|
23284
24450
|
deviceId: number(),
|
|
23285
|
-
trackId: string(),
|
|
24451
|
+
trackId: string().optional(),
|
|
23286
24452
|
frameId: string()
|
|
23287
24453
|
}), object({
|
|
23288
24454
|
removed: boolean(),
|
|
@@ -23299,7 +24465,8 @@ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).rea
|
|
|
23299
24465
|
auth: "admin"
|
|
23300
24466
|
}), method(object({
|
|
23301
24467
|
deviceId: number(),
|
|
23302
|
-
|
|
24468
|
+
/** The frame's track, when it has one — checked against the frame. */
|
|
24469
|
+
trackId: string().optional(),
|
|
23303
24470
|
frameId: string(),
|
|
23304
24471
|
subject: RetrainAssistSubjectSchema,
|
|
23305
24472
|
/** Which node runs it. Absent ⇒ wherever an unowned call lands. */
|
|
@@ -23307,12 +24474,16 @@ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).rea
|
|
|
23307
24474
|
}), RetrainAssistResultSchema, {
|
|
23308
24475
|
kind: "mutation",
|
|
23309
24476
|
auth: "admin"
|
|
23310
|
-
}), method(object({
|
|
24477
|
+
}), method(object({
|
|
24478
|
+
trackId: string().optional(),
|
|
24479
|
+
frameIds: array(string()).max(2e3).optional()
|
|
24480
|
+
}), array(RetrainAnnotationSchema).readonly(), {
|
|
23311
24481
|
kind: "query",
|
|
23312
24482
|
auth: "admin"
|
|
23313
24483
|
}), method(object({
|
|
23314
24484
|
deviceId: number(),
|
|
23315
|
-
|
|
24485
|
+
/** The frame's track, when it has one — checked against the frame. */
|
|
24486
|
+
trackId: string().optional(),
|
|
23316
24487
|
frameId: string(),
|
|
23317
24488
|
annotations: array(RetrainAnnotationDraftSchema)
|
|
23318
24489
|
}), array(RetrainAnnotationSchema).readonly(), {
|
|
@@ -23335,7 +24506,7 @@ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).rea
|
|
|
23335
24506
|
auth: "admin"
|
|
23336
24507
|
}), method(object({
|
|
23337
24508
|
deviceId: number(),
|
|
23338
|
-
trackId: string(),
|
|
24509
|
+
trackId: string().optional(),
|
|
23339
24510
|
frameId: string(),
|
|
23340
24511
|
complete: boolean()
|
|
23341
24512
|
}), RetrainFrameSchema, {
|
|
@@ -23349,6 +24520,104 @@ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).rea
|
|
|
23349
24520
|
kind: "mutation",
|
|
23350
24521
|
auth: "admin",
|
|
23351
24522
|
timeoutMs: 60 * 6e4
|
|
24523
|
+
}), method(object({
|
|
24524
|
+
selection: RetrainDatasetSelectionSchema,
|
|
24525
|
+
completeOnly: boolean().optional()
|
|
24526
|
+
}), RetrainDatasetStatsSchema, {
|
|
24527
|
+
kind: "query",
|
|
24528
|
+
auth: "admin"
|
|
24529
|
+
}), method(object({
|
|
24530
|
+
name: string().max(120),
|
|
24531
|
+
selection: RetrainDatasetSelectionSchema,
|
|
24532
|
+
layout: RetrainExportLayoutSchema,
|
|
24533
|
+
completeOnly: boolean()
|
|
24534
|
+
}), CreateRetrainDatasetVersionResultSchema, {
|
|
24535
|
+
kind: "mutation",
|
|
24536
|
+
auth: "admin",
|
|
24537
|
+
timeoutMs: 12e4
|
|
24538
|
+
}), method(object({}), array(RetrainDatasetVersionSchema).readonly(), {
|
|
24539
|
+
kind: "query",
|
|
24540
|
+
auth: "admin"
|
|
24541
|
+
}), method(object({ id: string() }), object({ deleted: boolean() }), {
|
|
24542
|
+
kind: "mutation",
|
|
24543
|
+
auth: "admin"
|
|
24544
|
+
}), method(object({ id: string() }), object({
|
|
24545
|
+
found: boolean(),
|
|
24546
|
+
annotationHash: string(),
|
|
24547
|
+
matches: boolean(),
|
|
24548
|
+
missingFrames: number().int()
|
|
24549
|
+
}), {
|
|
24550
|
+
kind: "query",
|
|
24551
|
+
auth: "admin",
|
|
24552
|
+
timeoutMs: 12e4
|
|
24553
|
+
}), method(object({}), array(RetrainAssistProfileSchema).readonly(), {
|
|
24554
|
+
kind: "query",
|
|
24555
|
+
auth: "admin"
|
|
24556
|
+
}), method(object({
|
|
24557
|
+
deviceId: number(),
|
|
24558
|
+
trackId: string().optional(),
|
|
24559
|
+
frameId: string(),
|
|
24560
|
+
profileId: string(),
|
|
24561
|
+
classes: array(RetrainMacroClassSchema).min(1),
|
|
24562
|
+
boxes: array(object({
|
|
24563
|
+
ref: string(),
|
|
24564
|
+
bbox: RetrainBboxSchema,
|
|
24565
|
+
macroClass: RetrainMacroClassSchema,
|
|
24566
|
+
label: string().optional()
|
|
24567
|
+
})).max(50),
|
|
24568
|
+
allowCloud: boolean()
|
|
24569
|
+
}), RetrainLlmAssistResultSchema, {
|
|
24570
|
+
kind: "mutation",
|
|
24571
|
+
auth: "admin",
|
|
24572
|
+
timeoutMs: 18e4
|
|
24573
|
+
}), method(object({ name: string().max(120) }), RetrainCollectionCreateResultSchema, {
|
|
24574
|
+
kind: "mutation",
|
|
24575
|
+
auth: "admin"
|
|
24576
|
+
}), method(object({}), array(RetrainCollectionSchema).readonly(), {
|
|
24577
|
+
kind: "query",
|
|
24578
|
+
auth: "admin"
|
|
24579
|
+
}), method(object({
|
|
24580
|
+
id: string(),
|
|
24581
|
+
name: string().max(120)
|
|
24582
|
+
}), RetrainCollectionRenameResultSchema, {
|
|
24583
|
+
kind: "mutation",
|
|
24584
|
+
auth: "admin"
|
|
24585
|
+
}), method(object({ id: string() }), object({
|
|
24586
|
+
deleted: boolean(),
|
|
24587
|
+
removedFrames: number().int()
|
|
24588
|
+
}), {
|
|
24589
|
+
kind: "mutation",
|
|
24590
|
+
auth: "admin"
|
|
24591
|
+
}), method(object({
|
|
24592
|
+
collectionId: string(),
|
|
24593
|
+
deviceId: number(),
|
|
24594
|
+
epochMs: number()
|
|
24595
|
+
}), AddRetrainFrameFromRecordingResultSchema, {
|
|
24596
|
+
kind: "mutation",
|
|
24597
|
+
auth: "admin",
|
|
24598
|
+
timeoutMs: 6e4
|
|
24599
|
+
}), method(object({
|
|
24600
|
+
collectionId: string(),
|
|
24601
|
+
frameIds: array(string()).min(1).max(500)
|
|
24602
|
+
}), object({
|
|
24603
|
+
added: number().int(),
|
|
24604
|
+
alreadyMember: number().int(),
|
|
24605
|
+
unknownFrameIds: array(string()).readonly()
|
|
24606
|
+
}), {
|
|
24607
|
+
kind: "mutation",
|
|
24608
|
+
auth: "admin"
|
|
24609
|
+
}), method(object({
|
|
24610
|
+
collectionId: string(),
|
|
24611
|
+
frameId: string()
|
|
24612
|
+
}), object({
|
|
24613
|
+
removed: boolean(),
|
|
24614
|
+
deletedFrame: boolean()
|
|
24615
|
+
}), {
|
|
24616
|
+
kind: "mutation",
|
|
24617
|
+
auth: "admin"
|
|
24618
|
+
}), method(object({ collectionId: string() }), array(RetrainFrameSchema).readonly(), {
|
|
24619
|
+
kind: "query",
|
|
24620
|
+
auth: "admin"
|
|
23352
24621
|
}), method(object({
|
|
23353
24622
|
/** Which of the three event tables owns the row. */
|
|
23354
24623
|
ownerType: EventOwnerTypeSchema,
|
|
@@ -23972,13 +25241,31 @@ var RecommendationReasonSchema = discriminatedUnion("kind", [
|
|
|
23972
25241
|
object({
|
|
23973
25242
|
kind: literal("no-family-build"),
|
|
23974
25243
|
format: ModelFormatSchema$1
|
|
25244
|
+
}),
|
|
25245
|
+
object({
|
|
25246
|
+
kind: literal("kept-custom-pin"),
|
|
25247
|
+
modelId: string(),
|
|
25248
|
+
deviceKey: string()
|
|
23975
25249
|
})
|
|
23976
25250
|
]);
|
|
25251
|
+
/** Why a device is left exactly as it is, whatever the plan would pick (D786). */
|
|
25252
|
+
var KeptReasonSchema = _enum(["custom-pin"]);
|
|
25253
|
+
/**
|
|
25254
|
+
* Where a choice's latency came from (D791): this node's own benchmark
|
|
25255
|
+
* result, or the hardware-class table. Measured on the node beats the table.
|
|
25256
|
+
*/
|
|
25257
|
+
var LatencySourceSchema = discriminatedUnion("kind", [object({ kind: literal("table") }), object({
|
|
25258
|
+
kind: literal("node-benchmark"),
|
|
25259
|
+
resultId: string(),
|
|
25260
|
+
measuredAtMs: number()
|
|
25261
|
+
})]);
|
|
23977
25262
|
var DeviceModelChoiceSchema = object({
|
|
23978
25263
|
modelId: string(),
|
|
23979
25264
|
p50Ms: number(),
|
|
23980
25265
|
fps: number(),
|
|
23981
25266
|
measured: boolean(),
|
|
25267
|
+
/** Absent on a plan from before D791 — read as the table. */
|
|
25268
|
+
source: LatencySourceSchema.optional(),
|
|
23982
25269
|
/** Parallel sessions at the camera rate with the headroom kept free: ⌊fps × (1 − headroom) / camera fps⌋. */
|
|
23983
25270
|
capacitySessions: number(),
|
|
23984
25271
|
personRecall: number()
|
|
@@ -23989,6 +25276,8 @@ var DeviceRecommendationSchema = object({
|
|
|
23989
25276
|
enabled: boolean(),
|
|
23990
25277
|
available: boolean(),
|
|
23991
25278
|
chosen: DeviceModelChoiceSchema.nullable(),
|
|
25279
|
+
/** Present when the device is kept as is: Apply writes nothing on it. */
|
|
25280
|
+
kept: KeptReasonSchema.optional(),
|
|
23992
25281
|
reasons: array(RecommendationReasonSchema).readonly()
|
|
23993
25282
|
});
|
|
23994
25283
|
var NodeRecommendationSchema = object({
|
|
@@ -24042,6 +25331,17 @@ var AutoTuneWarningSchema = discriminatedUnion("kind", [
|
|
|
24042
25331
|
kind: literal("coral-enabled"),
|
|
24043
25332
|
nodeId: string(),
|
|
24044
25333
|
deviceKey: string()
|
|
25334
|
+
}),
|
|
25335
|
+
object({
|
|
25336
|
+
kind: literal("custom-pin-kept"),
|
|
25337
|
+
nodeId: string(),
|
|
25338
|
+
deviceKey: string().nullable(),
|
|
25339
|
+
deviceId: number().nullable(),
|
|
25340
|
+
modelId: string()
|
|
25341
|
+
}),
|
|
25342
|
+
object({
|
|
25343
|
+
kind: literal("custom-registry-unreadable"),
|
|
25344
|
+
error: string()
|
|
24045
25345
|
})
|
|
24046
25346
|
]);
|
|
24047
25347
|
var AutoTuneOptionsSchema = object({
|
|
@@ -24220,13 +25520,14 @@ var SuggestSharesResultSchema = object({
|
|
|
24220
25520
|
nodes: array(SuggestedNodeShareSchema).readonly()
|
|
24221
25521
|
});
|
|
24222
25522
|
/**
|
|
24223
|
-
* Where the node and device shares come from (D750, D755).
|
|
24224
|
-
* - `
|
|
24225
|
-
*
|
|
24226
|
-
*
|
|
24227
|
-
*
|
|
24228
|
-
*
|
|
24229
|
-
*
|
|
25523
|
+
* Where the node and device shares come from (D750, D755, D791).
|
|
25524
|
+
* - `benchmark` (default since D791) — each node's capacity as its own node
|
|
25525
|
+
* benchmark measured it; a node without fresh results is sized from
|
|
25526
|
+
* `hardware` and says so. Measured on the node beats the table.
|
|
25527
|
+
* - `hardware` — computed from each node's static capacity only (its
|
|
25528
|
+
* accelerators at their Auto tune models, from the latency table).
|
|
25529
|
+
* Both are recomputed whenever a node or device joins, leaves, is switched
|
|
25530
|
+
* on or off, changes model, or a benchmark result is written. No load input.
|
|
24230
25531
|
* - `manual` — the operator's stored sliders.
|
|
24231
25532
|
* Either way a node or device that cannot take sessions gives its share to
|
|
24232
25533
|
* the others in proportion; the stored values are never rewritten for that.
|
|
@@ -24275,6 +25576,362 @@ var EffectiveSharesSchema = object({
|
|
|
24275
25576
|
nodeWeights: record(string(), number()),
|
|
24276
25577
|
deviceWeights: record(string(), record(string(), number()))
|
|
24277
25578
|
});
|
|
25579
|
+
/**
|
|
25580
|
+
* Wire shapes of the node benchmark (D791): the operator's plan, the
|
|
25581
|
+
* preflight the confirmation shows, the run the orchestrator owns, what the
|
|
25582
|
+
* measuring runner reports, and the result rows Auto tune and the automatic
|
|
25583
|
+
* shares read.
|
|
25584
|
+
*
|
|
25585
|
+
* ONE node at a time, owned by the pipeline orchestrator. While a run is
|
|
25586
|
+
* active the cluster is in BENCHMARK MODE for that node: it is not a
|
|
25587
|
+
* detection candidate, camera pins naming it are ignored so its sessions move
|
|
25588
|
+
* elsewhere, and both come back when the mode ends — after a crash or a hub
|
|
25589
|
+
* restart too (a persisted manifest, reconciled against the registry).
|
|
25590
|
+
*
|
|
25591
|
+
* Two measurements, both on the node, driven by its own runner (frames never
|
|
25592
|
+
* cross a process at frame rate, D9):
|
|
25593
|
+
* - `device` — one accelerator × one candidate detector, root only, open
|
|
25594
|
+
* loop: how many streams at the camera rate it carries inside the frame
|
|
25595
|
+
* interval;
|
|
25596
|
+
* - `pipeline` — the chosen detector plus the operator's detail steps
|
|
25597
|
+
* (faces, plates, classifiers, CLIP…), on varied frames from the bench
|
|
25598
|
+
* clip: how many parallel sessions the node carries before latency, drops,
|
|
25599
|
+
* CPU, RAM or the event loop give out.
|
|
25600
|
+
*/
|
|
25601
|
+
/** Defaults and bounds, one place. */
|
|
25602
|
+
var NODE_BENCHMARK_DEFAULTS = {
|
|
25603
|
+
fpsPerStream: 10,
|
|
25604
|
+
budgetMinutes: 45,
|
|
25605
|
+
minBudgetMinutes: 10,
|
|
25606
|
+
maxBudgetMinutes: 120,
|
|
25607
|
+
/** A result older than this no longer beats the table. */
|
|
25608
|
+
staleAfterDays: 30,
|
|
25609
|
+
/** Warm-in per ramp step (not accounted). */
|
|
25610
|
+
settleSec: 5,
|
|
25611
|
+
/** Accounted window per ramp step. */
|
|
25612
|
+
measureSec: 20,
|
|
25613
|
+
/** Longest the drain may take before the run is refused. */
|
|
25614
|
+
drainTimeoutSec: 120,
|
|
25615
|
+
/** Candidate models per device in one run. */
|
|
25616
|
+
maxModelsPerDevice: 6
|
|
25617
|
+
};
|
|
25618
|
+
/** The two measurements a run can make. */
|
|
25619
|
+
var NodeBenchmarkPhaseSchema = _enum(["device", "pipeline"]);
|
|
25620
|
+
var NodeBenchmarkDevicePlanSchema = object({
|
|
25621
|
+
/** `<backend>:<device>` — `openvino:npu`, `coreml:all`, `cpu`. */
|
|
25622
|
+
deviceKey: string().min(1),
|
|
25623
|
+
/**
|
|
25624
|
+
* Root detector candidates for the `device` measurement, in the order
|
|
25625
|
+
* measured. The FIRST is the one the `pipeline` measurement runs.
|
|
25626
|
+
*/
|
|
25627
|
+
modelIds: array(string().min(1)).min(1).max(NODE_BENCHMARK_DEFAULTS.maxModelsPerDevice)
|
|
25628
|
+
});
|
|
25629
|
+
/** What the operator confirmed. */
|
|
25630
|
+
var NodeBenchmarkPlanSchema = object({
|
|
25631
|
+
nodeId: string().min(1),
|
|
25632
|
+
devices: array(NodeBenchmarkDevicePlanSchema).min(1),
|
|
25633
|
+
/** Which measurements run. At least one. */
|
|
25634
|
+
phases: array(NodeBenchmarkPhaseSchema).min(1).default(["device", "pipeline"]),
|
|
25635
|
+
/**
|
|
25636
|
+
* Detail steps (catalog step ids under the root: faces, plates,
|
|
25637
|
+
* classifiers, CLIP…) the `pipeline` measurement enables. The root
|
|
25638
|
+
* detector always runs.
|
|
25639
|
+
*/
|
|
25640
|
+
steps: array(string().min(1)).default([]),
|
|
25641
|
+
/** Offered rate of one stream / session. */
|
|
25642
|
+
fpsPerStream: number().int().min(1).max(30).default(NODE_BENCHMARK_DEFAULTS.fpsPerStream),
|
|
25643
|
+
/** Hard deadline: the mode ends and the cluster is restored when it passes. */
|
|
25644
|
+
budgetMinutes: number().int().min(NODE_BENCHMARK_DEFAULTS.minBudgetMinutes).max(NODE_BENCHMARK_DEFAULTS.maxBudgetMinutes).default(NODE_BENCHMARK_DEFAULTS.budgetMinutes),
|
|
25645
|
+
/** Keep the models the run downloaded (default: delete what was not installed before). */
|
|
25646
|
+
keepDownloadedModels: boolean().default(false),
|
|
25647
|
+
/** Start although the other nodes' capacity does not cover the sessions running now. */
|
|
25648
|
+
acceptInsufficientHeadroom: boolean().default(false)
|
|
25649
|
+
});
|
|
25650
|
+
var NodeBenchmarkRefusalSchema = object({
|
|
25651
|
+
kind: _enum([
|
|
25652
|
+
"benchmark-active",
|
|
25653
|
+
"node-offline",
|
|
25654
|
+
"unknown-device",
|
|
25655
|
+
"no-phase",
|
|
25656
|
+
"insufficient-headroom"
|
|
25657
|
+
]),
|
|
25658
|
+
detail: string(),
|
|
25659
|
+
overridable: boolean()
|
|
25660
|
+
});
|
|
25661
|
+
/** A camera whose detection leaves the node for the run. */
|
|
25662
|
+
var NodeBenchmarkMovingCameraSchema = object({
|
|
25663
|
+
deviceId: number(),
|
|
25664
|
+
/** Placed on the node now (a standing attach or a running session). */
|
|
25665
|
+
placedOnNode: boolean(),
|
|
25666
|
+
/** A node pin naming this node, ignored for the run. */
|
|
25667
|
+
pinnedToNode: boolean()
|
|
25668
|
+
});
|
|
25669
|
+
/** A camera that cannot leave: no other node can obtain its frames. */
|
|
25670
|
+
var NodeBenchmarkStayingCameraSchema = object({
|
|
25671
|
+
deviceId: number(),
|
|
25672
|
+
reason: literal("only-frame-source")
|
|
25673
|
+
});
|
|
25674
|
+
var NodeBenchmarkPreflightSchema = object({
|
|
25675
|
+
nodeId: string(),
|
|
25676
|
+
online: boolean(),
|
|
25677
|
+
moving: array(NodeBenchmarkMovingCameraSchema).readonly(),
|
|
25678
|
+
/** Keep running on the node during the run; the result is flagged contaminated. */
|
|
25679
|
+
staying: array(NodeBenchmarkStayingCameraSchema).readonly(),
|
|
25680
|
+
estimatedDurationMs: number(),
|
|
25681
|
+
/** The run ends and the cluster is restored at the latest after this long. */
|
|
25682
|
+
budgetMs: number(),
|
|
25683
|
+
phases: array(NodeBenchmarkPhaseSchema).readonly(),
|
|
25684
|
+
steps: array(string()).readonly(),
|
|
25685
|
+
devices: array(NodeBenchmarkDevicePlanSchema).readonly(),
|
|
25686
|
+
/** Parallel sessions the cluster runs now, and what the other nodes can carry. */
|
|
25687
|
+
headroom: object({
|
|
25688
|
+
sessionsNow: number(),
|
|
25689
|
+
otherNodesCapacitySessions: number().nullable()
|
|
25690
|
+
}),
|
|
25691
|
+
refusals: array(NodeBenchmarkRefusalSchema).readonly(),
|
|
25692
|
+
canStart: boolean()
|
|
25693
|
+
});
|
|
25694
|
+
/** Where the measuring runner is. */
|
|
25695
|
+
var NodeBenchProgressSchema = object({
|
|
25696
|
+
phase: _enum([
|
|
25697
|
+
"preparing",
|
|
25698
|
+
"device",
|
|
25699
|
+
"pipeline",
|
|
25700
|
+
"cleanup"
|
|
25701
|
+
]),
|
|
25702
|
+
deviceKey: string().nullable(),
|
|
25703
|
+
modelId: string().nullable(),
|
|
25704
|
+
/** Streams (device) or sessions (pipeline) of the step running now. */
|
|
25705
|
+
load: number().nullable(),
|
|
25706
|
+
cellsDone: number(),
|
|
25707
|
+
cellsTotal: number(),
|
|
25708
|
+
message: string()
|
|
25709
|
+
});
|
|
25710
|
+
/** What limited a ramp. `none` = the ramp ran out of steps still passing. */
|
|
25711
|
+
var NodeBenchLimitSchema = _enum([
|
|
25712
|
+
"p95",
|
|
25713
|
+
"drops",
|
|
25714
|
+
"errors",
|
|
25715
|
+
"stall",
|
|
25716
|
+
"cpu",
|
|
25717
|
+
"ram",
|
|
25718
|
+
"none"
|
|
25719
|
+
]);
|
|
25720
|
+
var NodeBenchRampStepSchema = object({
|
|
25721
|
+
load: number(),
|
|
25722
|
+
pass: boolean(),
|
|
25723
|
+
p95Ms: number(),
|
|
25724
|
+
dropRatio: number(),
|
|
25725
|
+
/** Completed frames per second over the accounted window. */
|
|
25726
|
+
fps: number(),
|
|
25727
|
+
cpuPct: number().nullable(),
|
|
25728
|
+
ramFreePct: number().nullable(),
|
|
25729
|
+
failReasons: array(string()).readonly()
|
|
25730
|
+
});
|
|
25731
|
+
var NodeBenchCellSchema = discriminatedUnion("phase", [object({
|
|
25732
|
+
phase: literal("device"),
|
|
25733
|
+
deviceKey: string(),
|
|
25734
|
+
modelId: string(),
|
|
25735
|
+
/** Single-stream latency (the K = 1 step). */
|
|
25736
|
+
p50Ms: number(),
|
|
25737
|
+
p95Ms: number(),
|
|
25738
|
+
p99Ms: number(),
|
|
25739
|
+
/** Frames per second sustained at the last passing step. */
|
|
25740
|
+
fps: number(),
|
|
25741
|
+
/** Streams at the camera rate the device carried inside the frame interval; 0 = not even one. */
|
|
25742
|
+
kMax: number(),
|
|
25743
|
+
limitedBy: NodeBenchLimitSchema,
|
|
25744
|
+
/** First call (model load + warm-up). */
|
|
25745
|
+
warmupMs: number(),
|
|
25746
|
+
ramp: array(NodeBenchRampStepSchema).readonly()
|
|
25747
|
+
}), object({
|
|
25748
|
+
phase: literal("pipeline"),
|
|
25749
|
+
deviceKey: string(),
|
|
25750
|
+
modelId: string(),
|
|
25751
|
+
steps: array(string()).readonly(),
|
|
25752
|
+
/** Parallel sessions at the camera rate the node carried; 0 = not even one. */
|
|
25753
|
+
maxSessions: number(),
|
|
25754
|
+
limitedBy: NodeBenchLimitSchema,
|
|
25755
|
+
/** Detail steps that produced at least one result on the clip — a step that never fired measured nothing. */
|
|
25756
|
+
stepsFired: array(string()).readonly(),
|
|
25757
|
+
warmupMs: number(),
|
|
25758
|
+
ramp: array(NodeBenchRampStepSchema).readonly()
|
|
25759
|
+
})]);
|
|
25760
|
+
/**
|
|
25761
|
+
* What a result was measured ON. A result whose fingerprint no longer matches
|
|
25762
|
+
* the node no longer beats the table.
|
|
25763
|
+
*/
|
|
25764
|
+
var NodeBenchFingerprintSchema = object({
|
|
25765
|
+
pipelineVersion: string().nullable(),
|
|
25766
|
+
cpuModel: string().nullable(),
|
|
25767
|
+
ramGb: number().nullable(),
|
|
25768
|
+
os: string().nullable(),
|
|
25769
|
+
/** Per device: the pool the cells ran on (runtime + tuning). */
|
|
25770
|
+
pools: record(string(), object({
|
|
25771
|
+
runtime: string(),
|
|
25772
|
+
numWorkers: number(),
|
|
25773
|
+
concurrency: number(),
|
|
25774
|
+
batchMode: string()
|
|
25775
|
+
})).default({})
|
|
25776
|
+
});
|
|
25777
|
+
/** The frames the run used. */
|
|
25778
|
+
var NodeBenchClipSchema = object({
|
|
25779
|
+
/** `camstack-bench-v1` or `reference-images` (the fallback when the clip is not reachable). */
|
|
25780
|
+
id: string(),
|
|
25781
|
+
revision: string().nullable(),
|
|
25782
|
+
frames: number(),
|
|
25783
|
+
width: number(),
|
|
25784
|
+
height: number()
|
|
25785
|
+
});
|
|
25786
|
+
var NodeBenchRunnerInputSchema = object({
|
|
25787
|
+
runId: string().min(1),
|
|
25788
|
+
devices: array(NodeBenchmarkDevicePlanSchema).min(1),
|
|
25789
|
+
phases: array(NodeBenchmarkPhaseSchema).min(1),
|
|
25790
|
+
/** The full detail step tree root for the `pipeline` measurement is built on the node from these ids. */
|
|
25791
|
+
steps: array(string()).default([]),
|
|
25792
|
+
fpsPerStream: number().int().min(1).max(30),
|
|
25793
|
+
/** The runner stops on its own past this instant, whatever the hub does. */
|
|
25794
|
+
deadlineAtMs: number(),
|
|
25795
|
+
settleSec: number().min(0).max(60).default(NODE_BENCHMARK_DEFAULTS.settleSec),
|
|
25796
|
+
measureSec: number().min(2).max(300).default(NODE_BENCHMARK_DEFAULTS.measureSec),
|
|
25797
|
+
keepDownloadedModels: boolean().default(false)
|
|
25798
|
+
});
|
|
25799
|
+
var NodeBenchRunnerStateSchema = _enum([
|
|
25800
|
+
"running",
|
|
25801
|
+
"done",
|
|
25802
|
+
"failed",
|
|
25803
|
+
"aborted"
|
|
25804
|
+
]);
|
|
25805
|
+
var NodeBenchRunnerStatusSchema = object({
|
|
25806
|
+
runId: string(),
|
|
25807
|
+
nodeId: string(),
|
|
25808
|
+
state: NodeBenchRunnerStateSchema,
|
|
25809
|
+
progress: NodeBenchProgressSchema.nullable(),
|
|
25810
|
+
/** Every finished cell so far — a run stopped half way keeps what it measured. */
|
|
25811
|
+
cells: array(NodeBenchCellSchema).readonly(),
|
|
25812
|
+
fingerprint: NodeBenchFingerprintSchema.nullable(),
|
|
25813
|
+
clip: NodeBenchClipSchema.nullable(),
|
|
25814
|
+
/** Cameras seen running on the node during the run (they share its pools). */
|
|
25815
|
+
activeCameraIds: array(number()).readonly(),
|
|
25816
|
+
/** Models the run downloaded and then deleted (not installed before). */
|
|
25817
|
+
deletedModels: array(string()).readonly(),
|
|
25818
|
+
error: string().nullable(),
|
|
25819
|
+
startedAtMs: number(),
|
|
25820
|
+
finishedAtMs: number().nullable()
|
|
25821
|
+
});
|
|
25822
|
+
var NodeBenchmarkStateSchema = _enum([
|
|
25823
|
+
"draining",
|
|
25824
|
+
"measuring",
|
|
25825
|
+
"restoring",
|
|
25826
|
+
"done",
|
|
25827
|
+
"failed",
|
|
25828
|
+
"aborted"
|
|
25829
|
+
]);
|
|
25830
|
+
/** Why a run ended. */
|
|
25831
|
+
var NodeBenchmarkEndReasonSchema = _enum([
|
|
25832
|
+
"completed",
|
|
25833
|
+
"operator-abort",
|
|
25834
|
+
"deadline",
|
|
25835
|
+
"node-lost",
|
|
25836
|
+
"runner-lost",
|
|
25837
|
+
"hub-restart",
|
|
25838
|
+
"drain-timeout",
|
|
25839
|
+
"failed"
|
|
25840
|
+
]);
|
|
25841
|
+
var NodeBenchmarkRunSchema = object({
|
|
25842
|
+
runId: string(),
|
|
25843
|
+
nodeId: string(),
|
|
25844
|
+
state: NodeBenchmarkStateSchema,
|
|
25845
|
+
plan: NodeBenchmarkPlanSchema,
|
|
25846
|
+
startedAtMs: number(),
|
|
25847
|
+
deadlineAtMs: number(),
|
|
25848
|
+
finishedAtMs: number().nullable(),
|
|
25849
|
+
endReason: NodeBenchmarkEndReasonSchema.nullable(),
|
|
25850
|
+
error: string().nullable(),
|
|
25851
|
+
/** Cameras moved off the node for the run. */
|
|
25852
|
+
moved: array(number()).readonly(),
|
|
25853
|
+
/** Cameras that stayed (their only frame source is the node). */
|
|
25854
|
+
staying: array(number()).readonly(),
|
|
25855
|
+
/** Something else ran on the node's pools during the run. */
|
|
25856
|
+
contaminated: boolean(),
|
|
25857
|
+
progress: NodeBenchProgressSchema.nullable(),
|
|
25858
|
+
resultIds: array(string()).readonly()
|
|
25859
|
+
});
|
|
25860
|
+
/** `getNodeBenchmarkStatus`: the active run (or the last one), and whether benchmark mode is on. */
|
|
25861
|
+
var NodeBenchmarkStatusSchema = object({
|
|
25862
|
+
/** The node the cluster is in benchmark mode for; null = none. */
|
|
25863
|
+
modeNodeId: string().nullable(),
|
|
25864
|
+
run: NodeBenchmarkRunSchema.nullable()
|
|
25865
|
+
});
|
|
25866
|
+
/**
|
|
25867
|
+
* One stored measurement — the only authority Auto tune and the automatic
|
|
25868
|
+
* shares read measured capacity from. Written by the orchestrator when a run
|
|
25869
|
+
* ends, never by anyone else.
|
|
25870
|
+
*/
|
|
25871
|
+
var NodeBenchmarkResultSchema = object({
|
|
25872
|
+
id: string(),
|
|
25873
|
+
runId: string(),
|
|
25874
|
+
nodeId: string(),
|
|
25875
|
+
cell: NodeBenchCellSchema,
|
|
25876
|
+
fpsPerStream: number(),
|
|
25877
|
+
fingerprint: NodeBenchFingerprintSchema.nullable(),
|
|
25878
|
+
clip: NodeBenchClipSchema.nullable(),
|
|
25879
|
+
/** Other work shared the node's pools (a camera that could not move, or the hub's own duties). */
|
|
25880
|
+
contaminated: boolean(),
|
|
25881
|
+
stayingCameras: array(number()).readonly(),
|
|
25882
|
+
/** The run ended early; the cell itself completed. */
|
|
25883
|
+
partialRun: boolean(),
|
|
25884
|
+
measuredAtMs: number()
|
|
25885
|
+
});
|
|
25886
|
+
var ListNodeBenchmarkResultsInputSchema = object({
|
|
25887
|
+
nodeId: string().optional(),
|
|
25888
|
+
deviceKey: string().optional()
|
|
25889
|
+
});
|
|
25890
|
+
/** A result with its standing today: does it still beat the table? */
|
|
25891
|
+
var NodeBenchmarkResultViewSchema = NodeBenchmarkResultSchema.extend({
|
|
25892
|
+
/** `fresh` beats the table; `stale` falls back to it; `superseded` = a newer row covers the same cell. */
|
|
25893
|
+
standing: _enum([
|
|
25894
|
+
"fresh",
|
|
25895
|
+
"stale",
|
|
25896
|
+
"superseded"
|
|
25897
|
+
]),
|
|
25898
|
+
staleWhy: _enum([
|
|
25899
|
+
"age",
|
|
25900
|
+
"runtime",
|
|
25901
|
+
"pool-tuning"
|
|
25902
|
+
]).nullable()
|
|
25903
|
+
});
|
|
25904
|
+
object({
|
|
25905
|
+
runId: string(),
|
|
25906
|
+
nodeId: string(),
|
|
25907
|
+
startedAtMs: number(),
|
|
25908
|
+
deadlineAtMs: number(),
|
|
25909
|
+
plan: NodeBenchmarkPlanSchema,
|
|
25910
|
+
moved: array(number()).readonly(),
|
|
25911
|
+
staying: array(number()).readonly()
|
|
25912
|
+
});
|
|
25913
|
+
/** Candidate detectors per device, for the plan editor. */
|
|
25914
|
+
var NodeBenchmarkCandidatesSchema = object({
|
|
25915
|
+
nodeId: string(),
|
|
25916
|
+
reachable: boolean(),
|
|
25917
|
+
devices: array(object({
|
|
25918
|
+
deviceKey: string(),
|
|
25919
|
+
enabled: boolean(),
|
|
25920
|
+
available: boolean(),
|
|
25921
|
+
/** Ordered: what Auto tune would pick first, then the rest of the family by accuracy. */
|
|
25922
|
+
suggested: array(string()).readonly(),
|
|
25923
|
+
/** Every root detector the device has a build for. */
|
|
25924
|
+
all: array(string()).readonly(),
|
|
25925
|
+
/** The model the device runs now, when pinned. */
|
|
25926
|
+
currentModelId: string().nullable()
|
|
25927
|
+
})).readonly(),
|
|
25928
|
+
/** Detail steps the node's catalog offers under the root (for the `pipeline` measurement). */
|
|
25929
|
+
steps: array(object({
|
|
25930
|
+
id: string(),
|
|
25931
|
+
name: string(),
|
|
25932
|
+
slot: string()
|
|
25933
|
+
})).readonly()
|
|
25934
|
+
});
|
|
24278
25935
|
object({
|
|
24279
25936
|
activeCameras: number(),
|
|
24280
25937
|
throttledCameras: number(),
|
|
@@ -25403,7 +27060,16 @@ method(RunnerCameraConfigSchema, object({ success: literal(true) }), { kind: "mu
|
|
|
25403
27060
|
}), ParkedTrackFrameSchema.nullable()), method(object({
|
|
25404
27061
|
deviceId: number(),
|
|
25405
27062
|
trackId: string()
|
|
25406
|
-
}), object({ released: number().int().nonnegative() }), { kind: "mutation" })
|
|
27063
|
+
}), object({ released: number().int().nonnegative() }), { kind: "mutation" }), method(NodeBenchRunnerInputSchema, object({
|
|
27064
|
+
accepted: literal(true),
|
|
27065
|
+
runId: string()
|
|
27066
|
+
}), {
|
|
27067
|
+
kind: "mutation",
|
|
27068
|
+
auth: "admin"
|
|
27069
|
+
}), method(object({ runId: string() }), NodeBenchRunnerStatusSchema.nullable(), { auth: "admin" }), method(object({ runId: string() }), object({ aborted: boolean() }), {
|
|
27070
|
+
kind: "mutation",
|
|
27071
|
+
auth: "admin"
|
|
27072
|
+
});
|
|
25407
27073
|
var CameraPipelineConfigSchema = object({
|
|
25408
27074
|
engine: PipelineEngineChoiceSchema.optional(),
|
|
25409
27075
|
steps: array(PipelineStepInputSchema).readonly(),
|
|
@@ -26042,6 +27708,21 @@ method(object({
|
|
|
26042
27708
|
}), method(PlacementStatsInputSchema, PlacementStatsSchema, { auth: "admin" }), method(SuggestSharesInputSchema, SuggestSharesResultSchema, { auth: "admin" }), method(_void(), EffectiveSharesSchema, { auth: "admin" }), method(SetShareSourceInputSchema, object({ success: literal(true) }), {
|
|
26043
27709
|
kind: "mutation",
|
|
26044
27710
|
auth: "admin"
|
|
27711
|
+
}), method(NodeBenchmarkPlanSchema, NodeBenchmarkPreflightSchema, { auth: "admin" }), method(NodeBenchmarkPlanSchema, discriminatedUnion("kind", [object({
|
|
27712
|
+
kind: literal("started"),
|
|
27713
|
+
runId: string()
|
|
27714
|
+
}), object({
|
|
27715
|
+
kind: literal("refused"),
|
|
27716
|
+
preflight: NodeBenchmarkPreflightSchema
|
|
27717
|
+
})]), {
|
|
27718
|
+
kind: "mutation",
|
|
27719
|
+
auth: "admin"
|
|
27720
|
+
}), method(_void(), NodeBenchmarkStatusSchema, { auth: "admin" }), method(object({ runId: string() }), object({ aborted: boolean() }), {
|
|
27721
|
+
kind: "mutation",
|
|
27722
|
+
auth: "admin"
|
|
27723
|
+
}), method(object({ nodeId: string() }), NodeBenchmarkCandidatesSchema, { auth: "admin" }), method(ListNodeBenchmarkResultsInputSchema, array(NodeBenchmarkResultViewSchema).readonly(), { auth: "admin" }), method(object({ id: string() }), object({ deleted: boolean() }), {
|
|
27724
|
+
kind: "mutation",
|
|
27725
|
+
auth: "admin"
|
|
26045
27726
|
}), method(object({ deviceId: number() }), CameraPipelineSettingsSchema.nullable()), method(object({
|
|
26046
27727
|
deviceId: number(),
|
|
26047
27728
|
addonId: string(),
|
|
@@ -32261,6 +33942,9 @@ var CreateIntegrationInputSchema = object({
|
|
|
32261
33942
|
enabled: boolean().optional(),
|
|
32262
33943
|
info: record(string(), unknown()).optional(),
|
|
32263
33944
|
settings: record(string(), unknown()).optional(),
|
|
33945
|
+
/** Keys of `settings` the form's schema declares secret (by type) — kept in
|
|
33946
|
+
* the keychain, not the table (D787). */
|
|
33947
|
+
secretKeys: array(string()).optional(),
|
|
32264
33948
|
skipRestart: boolean().optional()
|
|
32265
33949
|
});
|
|
32266
33950
|
var UpdateIntegrationInputSchema = object({
|
|
@@ -32284,7 +33968,9 @@ method(_void(), array(IntegrationWithStateSchema)), method(object({ id: string()
|
|
|
32284
33968
|
auth: "admin"
|
|
32285
33969
|
}), method(object({ id: string() }), record(string(), unknown()), { auth: "admin" }), method(object({
|
|
32286
33970
|
id: string(),
|
|
32287
|
-
settings: record(string(), unknown())
|
|
33971
|
+
settings: record(string(), unknown()),
|
|
33972
|
+
/** Keys the form's schema declares secret (by type) — keychain-stored (D787). */
|
|
33973
|
+
secretKeys: array(string()).optional()
|
|
32288
33974
|
}), object({ success: boolean() }), {
|
|
32289
33975
|
kind: "mutation",
|
|
32290
33976
|
auth: "admin"
|
|
@@ -40447,7 +42133,8 @@ var BaseDevice = class {
|
|
|
40447
42133
|
this.role = options.role;
|
|
40448
42134
|
this.parentDeviceId = ctx.parentDeviceId;
|
|
40449
42135
|
const seedData = ctx.persistedConfig ?? {};
|
|
40450
|
-
|
|
42136
|
+
const declaredSecretPaths = collectZodSecretPaths(schema);
|
|
42137
|
+
this.config = DeviceConfig.fromSchema(schema, (data) => ctx.persistConfig(data, { secretConfigPaths: declaredSecretPaths }), seedData, ({ droppedKeys, issues }) => {
|
|
40451
42138
|
ctx.logger.warn("Device config recovery: dropping invalid persisted fields", {
|
|
40452
42139
|
tags: {
|
|
40453
42140
|
deviceId: ctx.id,
|
|
@@ -44136,6 +45823,96 @@ Object.freeze({
|
|
|
44136
45823
|
addonId: null,
|
|
44137
45824
|
access: "create"
|
|
44138
45825
|
},
|
|
45826
|
+
"keychain.delete": {
|
|
45827
|
+
capName: "keychain",
|
|
45828
|
+
capScope: "system",
|
|
45829
|
+
addonId: null,
|
|
45830
|
+
access: "delete"
|
|
45831
|
+
},
|
|
45832
|
+
"keychain.getState": {
|
|
45833
|
+
capName: "keychain",
|
|
45834
|
+
capScope: "system",
|
|
45835
|
+
addonId: null,
|
|
45836
|
+
access: "view"
|
|
45837
|
+
},
|
|
45838
|
+
"keychain.listMeta": {
|
|
45839
|
+
capName: "keychain",
|
|
45840
|
+
capScope: "system",
|
|
45841
|
+
addonId: null,
|
|
45842
|
+
access: "view"
|
|
45843
|
+
},
|
|
45844
|
+
"keychain.put": {
|
|
45845
|
+
capName: "keychain",
|
|
45846
|
+
capScope: "system",
|
|
45847
|
+
addonId: null,
|
|
45848
|
+
access: "create"
|
|
45849
|
+
},
|
|
45850
|
+
"keychain.resolve": {
|
|
45851
|
+
capName: "keychain",
|
|
45852
|
+
capScope: "system",
|
|
45853
|
+
addonId: null,
|
|
45854
|
+
access: "view"
|
|
45855
|
+
},
|
|
45856
|
+
"keychainAdmin.deleteOrphans": {
|
|
45857
|
+
capName: "keychain-admin",
|
|
45858
|
+
capScope: "system",
|
|
45859
|
+
addonId: null,
|
|
45860
|
+
access: "delete"
|
|
45861
|
+
},
|
|
45862
|
+
"keychainAdmin.downloadRecoveryKey": {
|
|
45863
|
+
capName: "keychain-admin",
|
|
45864
|
+
capScope: "system",
|
|
45865
|
+
addonId: null,
|
|
45866
|
+
access: "create"
|
|
45867
|
+
},
|
|
45868
|
+
"keychainAdmin.listAudit": {
|
|
45869
|
+
capName: "keychain-admin",
|
|
45870
|
+
capScope: "system",
|
|
45871
|
+
addonId: null,
|
|
45872
|
+
access: "view"
|
|
45873
|
+
},
|
|
45874
|
+
"keychainAdmin.listSecrets": {
|
|
45875
|
+
capName: "keychain-admin",
|
|
45876
|
+
capScope: "system",
|
|
45877
|
+
addonId: null,
|
|
45878
|
+
access: "view"
|
|
45879
|
+
},
|
|
45880
|
+
"keychainAdmin.purgeRetiredKeys": {
|
|
45881
|
+
capName: "keychain-admin",
|
|
45882
|
+
capScope: "system",
|
|
45883
|
+
addonId: null,
|
|
45884
|
+
access: "delete"
|
|
45885
|
+
},
|
|
45886
|
+
"keychainAdmin.resetKeychain": {
|
|
45887
|
+
capName: "keychain-admin",
|
|
45888
|
+
capScope: "system",
|
|
45889
|
+
addonId: null,
|
|
45890
|
+
access: "delete"
|
|
45891
|
+
},
|
|
45892
|
+
"keychainAdmin.reveal": {
|
|
45893
|
+
capName: "keychain-admin",
|
|
45894
|
+
capScope: "system",
|
|
45895
|
+
addonId: null,
|
|
45896
|
+
access: "create"
|
|
45897
|
+
},
|
|
45898
|
+
"keychainAdmin.rotateMasterKey": {
|
|
45899
|
+
capName: "keychain-admin",
|
|
45900
|
+
capScope: "system",
|
|
45901
|
+
addonId: null,
|
|
45902
|
+
access: "create"
|
|
45903
|
+
},
|
|
45904
|
+
"keychainAdmin.setSystemSecret": {
|
|
45905
|
+
capName: "keychain-admin",
|
|
45906
|
+
capScope: "system",
|
|
45907
|
+
addonId: null,
|
|
45908
|
+
access: "create"
|
|
45909
|
+
},
|
|
45910
|
+
"keychainAdmin.status": {
|
|
45911
|
+
capName: "keychain-admin",
|
|
45912
|
+
capScope: "system",
|
|
45913
|
+
addonId: null,
|
|
45914
|
+
access: "view"
|
|
45915
|
+
},
|
|
44139
45916
|
"lawnMowerControl.dock": {
|
|
44140
45917
|
capName: "lawn-mower-control",
|
|
44141
45918
|
capScope: "device",
|
|
@@ -45510,6 +47287,18 @@ Object.freeze({
|
|
|
45510
47287
|
addonId: null,
|
|
45511
47288
|
access: "create"
|
|
45512
47289
|
},
|
|
47290
|
+
"pipelineAnalytics.addRetrainFrameFromRecording": {
|
|
47291
|
+
capName: "pipeline-analytics",
|
|
47292
|
+
capScope: "device",
|
|
47293
|
+
addonId: null,
|
|
47294
|
+
access: "create"
|
|
47295
|
+
},
|
|
47296
|
+
"pipelineAnalytics.addRetrainFramesToCollection": {
|
|
47297
|
+
capName: "pipeline-analytics",
|
|
47298
|
+
capScope: "device",
|
|
47299
|
+
addonId: null,
|
|
47300
|
+
access: "create"
|
|
47301
|
+
},
|
|
45513
47302
|
"pipelineAnalytics.applyDeviceSettingsPatch": {
|
|
45514
47303
|
capName: "pipeline-analytics",
|
|
45515
47304
|
capScope: "device",
|
|
@@ -45558,12 +47347,36 @@ Object.freeze({
|
|
|
45558
47347
|
addonId: null,
|
|
45559
47348
|
access: "view"
|
|
45560
47349
|
},
|
|
47350
|
+
"pipelineAnalytics.createRetrainCollection": {
|
|
47351
|
+
capName: "pipeline-analytics",
|
|
47352
|
+
capScope: "device",
|
|
47353
|
+
addonId: null,
|
|
47354
|
+
access: "create"
|
|
47355
|
+
},
|
|
47356
|
+
"pipelineAnalytics.createRetrainDatasetVersion": {
|
|
47357
|
+
capName: "pipeline-analytics",
|
|
47358
|
+
capScope: "device",
|
|
47359
|
+
addonId: null,
|
|
47360
|
+
access: "create"
|
|
47361
|
+
},
|
|
45561
47362
|
"pipelineAnalytics.deleteDeviceEvents": {
|
|
45562
47363
|
capName: "pipeline-analytics",
|
|
45563
47364
|
capScope: "device",
|
|
45564
47365
|
addonId: null,
|
|
45565
47366
|
access: "delete"
|
|
45566
47367
|
},
|
|
47368
|
+
"pipelineAnalytics.deleteRetrainCollection": {
|
|
47369
|
+
capName: "pipeline-analytics",
|
|
47370
|
+
capScope: "device",
|
|
47371
|
+
addonId: null,
|
|
47372
|
+
access: "delete"
|
|
47373
|
+
},
|
|
47374
|
+
"pipelineAnalytics.deleteRetrainDatasetVersion": {
|
|
47375
|
+
capName: "pipeline-analytics",
|
|
47376
|
+
capScope: "device",
|
|
47377
|
+
addonId: null,
|
|
47378
|
+
access: "delete"
|
|
47379
|
+
},
|
|
45567
47380
|
"pipelineAnalytics.deleteTracks": {
|
|
45568
47381
|
capName: "pipeline-analytics",
|
|
45569
47382
|
capScope: "device",
|
|
@@ -45768,6 +47581,30 @@ Object.freeze({
|
|
|
45768
47581
|
addonId: null,
|
|
45769
47582
|
access: "view"
|
|
45770
47583
|
},
|
|
47584
|
+
"pipelineAnalytics.listRetrainAssistProfiles": {
|
|
47585
|
+
capName: "pipeline-analytics",
|
|
47586
|
+
capScope: "device",
|
|
47587
|
+
addonId: null,
|
|
47588
|
+
access: "view"
|
|
47589
|
+
},
|
|
47590
|
+
"pipelineAnalytics.listRetrainCollectionFrames": {
|
|
47591
|
+
capName: "pipeline-analytics",
|
|
47592
|
+
capScope: "device",
|
|
47593
|
+
addonId: null,
|
|
47594
|
+
access: "view"
|
|
47595
|
+
},
|
|
47596
|
+
"pipelineAnalytics.listRetrainCollections": {
|
|
47597
|
+
capName: "pipeline-analytics",
|
|
47598
|
+
capScope: "device",
|
|
47599
|
+
addonId: null,
|
|
47600
|
+
access: "view"
|
|
47601
|
+
},
|
|
47602
|
+
"pipelineAnalytics.listRetrainDatasetVersions": {
|
|
47603
|
+
capName: "pipeline-analytics",
|
|
47604
|
+
capScope: "device",
|
|
47605
|
+
addonId: null,
|
|
47606
|
+
access: "view"
|
|
47607
|
+
},
|
|
45771
47608
|
"pipelineAnalytics.listRetrainFrames": {
|
|
45772
47609
|
capName: "pipeline-analytics",
|
|
45773
47610
|
capScope: "device",
|
|
@@ -45810,12 +47647,24 @@ Object.freeze({
|
|
|
45810
47647
|
addonId: null,
|
|
45811
47648
|
access: "create"
|
|
45812
47649
|
},
|
|
47650
|
+
"pipelineAnalytics.previewRetrainDataset": {
|
|
47651
|
+
capName: "pipeline-analytics",
|
|
47652
|
+
capScope: "device",
|
|
47653
|
+
addonId: null,
|
|
47654
|
+
access: "view"
|
|
47655
|
+
},
|
|
45813
47656
|
"pipelineAnalytics.proposeRetrainAnnotations": {
|
|
45814
47657
|
capName: "pipeline-analytics",
|
|
45815
47658
|
capScope: "device",
|
|
45816
47659
|
addonId: null,
|
|
45817
47660
|
access: "create"
|
|
45818
47661
|
},
|
|
47662
|
+
"pipelineAnalytics.proposeRetrainAnnotationsWithLlm": {
|
|
47663
|
+
capName: "pipeline-analytics",
|
|
47664
|
+
capScope: "device",
|
|
47665
|
+
addonId: null,
|
|
47666
|
+
access: "create"
|
|
47667
|
+
},
|
|
45819
47668
|
"pipelineAnalytics.pruneEvents": {
|
|
45820
47669
|
capName: "pipeline-analytics",
|
|
45821
47670
|
capScope: "device",
|
|
@@ -45870,6 +47719,18 @@ Object.freeze({
|
|
|
45870
47719
|
addonId: null,
|
|
45871
47720
|
access: "create"
|
|
45872
47721
|
},
|
|
47722
|
+
"pipelineAnalytics.removeRetrainFrameFromCollection": {
|
|
47723
|
+
capName: "pipeline-analytics",
|
|
47724
|
+
capScope: "device",
|
|
47725
|
+
addonId: null,
|
|
47726
|
+
access: "delete"
|
|
47727
|
+
},
|
|
47728
|
+
"pipelineAnalytics.renameRetrainCollection": {
|
|
47729
|
+
capName: "pipeline-analytics",
|
|
47730
|
+
capScope: "device",
|
|
47731
|
+
addonId: null,
|
|
47732
|
+
access: "create"
|
|
47733
|
+
},
|
|
45873
47734
|
"pipelineAnalytics.restageRetrainTrack": {
|
|
45874
47735
|
capName: "pipeline-analytics",
|
|
45875
47736
|
capScope: "device",
|
|
@@ -45930,6 +47791,12 @@ Object.freeze({
|
|
|
45930
47791
|
addonId: null,
|
|
45931
47792
|
access: "create"
|
|
45932
47793
|
},
|
|
47794
|
+
"pipelineAnalytics.verifyRetrainDatasetVersion": {
|
|
47795
|
+
capName: "pipeline-analytics",
|
|
47796
|
+
capScope: "device",
|
|
47797
|
+
addonId: null,
|
|
47798
|
+
access: "view"
|
|
47799
|
+
},
|
|
45933
47800
|
"pipelineAnalytics.wipeAllAnalytics": {
|
|
45934
47801
|
capName: "pipeline-analytics",
|
|
45935
47802
|
capScope: "device",
|
|
@@ -46158,6 +48025,12 @@ Object.freeze({
|
|
|
46158
48025
|
addonId: null,
|
|
46159
48026
|
access: "view"
|
|
46160
48027
|
},
|
|
48028
|
+
"pipelineOrchestrator.abortNodeBenchmark": {
|
|
48029
|
+
capName: "pipeline-orchestrator",
|
|
48030
|
+
capScope: "system",
|
|
48031
|
+
addonId: null,
|
|
48032
|
+
access: "create"
|
|
48033
|
+
},
|
|
46161
48034
|
"pipelineOrchestrator.applyAutoTune": {
|
|
46162
48035
|
capName: "pipeline-orchestrator",
|
|
46163
48036
|
capScope: "system",
|
|
@@ -46182,6 +48055,12 @@ Object.freeze({
|
|
|
46182
48055
|
addonId: null,
|
|
46183
48056
|
access: "create"
|
|
46184
48057
|
},
|
|
48058
|
+
"pipelineOrchestrator.deleteNodeBenchmarkResult": {
|
|
48059
|
+
capName: "pipeline-orchestrator",
|
|
48060
|
+
capScope: "system",
|
|
48061
|
+
addonId: null,
|
|
48062
|
+
access: "delete"
|
|
48063
|
+
},
|
|
46185
48064
|
"pipelineOrchestrator.getAgentLoad": {
|
|
46186
48065
|
capName: "pipeline-orchestrator",
|
|
46187
48066
|
capScope: "system",
|
|
@@ -46290,6 +48169,24 @@ Object.freeze({
|
|
|
46290
48169
|
addonId: null,
|
|
46291
48170
|
access: "view"
|
|
46292
48171
|
},
|
|
48172
|
+
"pipelineOrchestrator.getNodeBenchmarkCandidates": {
|
|
48173
|
+
capName: "pipeline-orchestrator",
|
|
48174
|
+
capScope: "system",
|
|
48175
|
+
addonId: null,
|
|
48176
|
+
access: "view"
|
|
48177
|
+
},
|
|
48178
|
+
"pipelineOrchestrator.getNodeBenchmarkPreflight": {
|
|
48179
|
+
capName: "pipeline-orchestrator",
|
|
48180
|
+
capScope: "system",
|
|
48181
|
+
addonId: null,
|
|
48182
|
+
access: "view"
|
|
48183
|
+
},
|
|
48184
|
+
"pipelineOrchestrator.getNodeBenchmarkStatus": {
|
|
48185
|
+
capName: "pipeline-orchestrator",
|
|
48186
|
+
capScope: "system",
|
|
48187
|
+
addonId: null,
|
|
48188
|
+
access: "view"
|
|
48189
|
+
},
|
|
46293
48190
|
"pipelineOrchestrator.getNodeInferenceDevices": {
|
|
46294
48191
|
capName: "pipeline-orchestrator",
|
|
46295
48192
|
capScope: "system",
|
|
@@ -46332,6 +48229,12 @@ Object.freeze({
|
|
|
46332
48229
|
addonId: null,
|
|
46333
48230
|
access: "view"
|
|
46334
48231
|
},
|
|
48232
|
+
"pipelineOrchestrator.listNodeBenchmarkResults": {
|
|
48233
|
+
capName: "pipeline-orchestrator",
|
|
48234
|
+
capScope: "system",
|
|
48235
|
+
addonId: null,
|
|
48236
|
+
access: "view"
|
|
48237
|
+
},
|
|
46335
48238
|
"pipelineOrchestrator.pauseForStorageMigration": {
|
|
46336
48239
|
capName: "pipeline-orchestrator",
|
|
46337
48240
|
capScope: "system",
|
|
@@ -46476,6 +48379,12 @@ Object.freeze({
|
|
|
46476
48379
|
addonId: null,
|
|
46477
48380
|
access: "create"
|
|
46478
48381
|
},
|
|
48382
|
+
"pipelineOrchestrator.startNodeBenchmark": {
|
|
48383
|
+
capName: "pipeline-orchestrator",
|
|
48384
|
+
capScope: "system",
|
|
48385
|
+
addonId: null,
|
|
48386
|
+
access: "create"
|
|
48387
|
+
},
|
|
46479
48388
|
"pipelineOrchestrator.suggestShares": {
|
|
46480
48389
|
capName: "pipeline-orchestrator",
|
|
46481
48390
|
capScope: "system",
|
|
@@ -46494,6 +48403,12 @@ Object.freeze({
|
|
|
46494
48403
|
addonId: null,
|
|
46495
48404
|
access: "create"
|
|
46496
48405
|
},
|
|
48406
|
+
"pipelineRunner.abortNodeBench": {
|
|
48407
|
+
capName: "pipeline-runner",
|
|
48408
|
+
capScope: "system",
|
|
48409
|
+
addonId: null,
|
|
48410
|
+
access: "create"
|
|
48411
|
+
},
|
|
46497
48412
|
"pipelineRunner.attachCamera": {
|
|
46498
48413
|
capName: "pipeline-runner",
|
|
46499
48414
|
capScope: "system",
|
|
@@ -46542,6 +48457,12 @@ Object.freeze({
|
|
|
46542
48457
|
addonId: null,
|
|
46543
48458
|
access: "view"
|
|
46544
48459
|
},
|
|
48460
|
+
"pipelineRunner.getNodeBenchStatus": {
|
|
48461
|
+
capName: "pipeline-runner",
|
|
48462
|
+
capScope: "system",
|
|
48463
|
+
addonId: null,
|
|
48464
|
+
access: "view"
|
|
48465
|
+
},
|
|
46545
48466
|
"pipelineRunner.getParkedTrackFrame": {
|
|
46546
48467
|
capName: "pipeline-runner",
|
|
46547
48468
|
capScope: "system",
|
|
@@ -46584,6 +48505,12 @@ Object.freeze({
|
|
|
46584
48505
|
addonId: null,
|
|
46585
48506
|
access: "create"
|
|
46586
48507
|
},
|
|
48508
|
+
"pipelineRunner.startNodeBench": {
|
|
48509
|
+
capName: "pipeline-runner",
|
|
48510
|
+
capScope: "system",
|
|
48511
|
+
addonId: null,
|
|
48512
|
+
access: "create"
|
|
48513
|
+
},
|
|
46587
48514
|
"plateGallery.assignPlate": {
|
|
46588
48515
|
capName: "plate-gallery",
|
|
46589
48516
|
capScope: "system",
|
|
@@ -51513,6 +53440,11 @@ Object.freeze({
|
|
|
51513
53440
|
form: "single",
|
|
51514
53441
|
optional: false
|
|
51515
53442
|
}],
|
|
53443
|
+
"pipelineAnalytics.addRetrainFrameFromRecording": [{
|
|
53444
|
+
name: "deviceId",
|
|
53445
|
+
form: "single",
|
|
53446
|
+
optional: false
|
|
53447
|
+
}],
|
|
51516
53448
|
"pipelineAnalytics.applyDeviceSettingsPatch": [{
|
|
51517
53449
|
name: "deviceId",
|
|
51518
53450
|
form: "single",
|
|
@@ -51703,6 +53635,11 @@ Object.freeze({
|
|
|
51703
53635
|
form: "single",
|
|
51704
53636
|
optional: false
|
|
51705
53637
|
}],
|
|
53638
|
+
"pipelineAnalytics.proposeRetrainAnnotationsWithLlm": [{
|
|
53639
|
+
name: "deviceId",
|
|
53640
|
+
form: "single",
|
|
53641
|
+
optional: false
|
|
53642
|
+
}],
|
|
51706
53643
|
"pipelineAnalytics.pruneEventsBefore": [{
|
|
51707
53644
|
name: "deviceId",
|
|
51708
53645
|
form: "single",
|
|
@@ -58558,6 +60495,20 @@ function getString(obj, key) {
|
|
|
58558
60495
|
const v = obj[key];
|
|
58559
60496
|
return typeof v === "string" ? v : "";
|
|
58560
60497
|
}
|
|
60498
|
+
/**
|
|
60499
|
+
* Keys the account form declares. They belong to `integration.settings`; in
|
|
60500
|
+
* the addon's global store they are stale leftovers.
|
|
60501
|
+
*/
|
|
60502
|
+
var GLOBAL_CREDENTIAL_KEYS = [
|
|
60503
|
+
"email",
|
|
60504
|
+
"password",
|
|
60505
|
+
"apiKey",
|
|
60506
|
+
"apiId"
|
|
60507
|
+
];
|
|
60508
|
+
/** A stored value worth removing: a non-empty string or a keychain marker. */
|
|
60509
|
+
function isStoredValue(v) {
|
|
60510
|
+
return typeof v === "string" && v.length > 0 || isSecretMarker(v);
|
|
60511
|
+
}
|
|
58561
60512
|
/** Extract account credentials from an integration's settings, or null. */
|
|
58562
60513
|
function credentialsFromSettings(settings) {
|
|
58563
60514
|
const email = getString(settings, "email").trim();
|
|
@@ -58622,6 +60573,9 @@ var WyzeProviderAddon = class extends BaseDeviceProvider {
|
|
|
58622
60573
|
});
|
|
58623
60574
|
});
|
|
58624
60575
|
});
|
|
60576
|
+
await this.purgeStaleGlobalCredentials().catch((err) => {
|
|
60577
|
+
this.ctx.logger.warn("could not remove stale Wyze credentials from the global store", { meta: { error: errMsg(err) } });
|
|
60578
|
+
});
|
|
58625
60579
|
await this.reconcileIntegrations();
|
|
58626
60580
|
this.subscribeIntegrationLifecycle();
|
|
58627
60581
|
return [
|
|
@@ -58757,8 +60711,25 @@ var WyzeProviderAddon = class extends BaseDeviceProvider {
|
|
|
58757
60711
|
}
|
|
58758
60712
|
});
|
|
58759
60713
|
}
|
|
60714
|
+
globalSettingsSchema() {
|
|
60715
|
+
return buildSettingsSchema();
|
|
60716
|
+
}
|
|
58760
60717
|
async getGlobalSettings() {
|
|
58761
|
-
return hydrateSchema(
|
|
60718
|
+
return hydrateSchema(this.globalSettingsSchema(), {});
|
|
60719
|
+
}
|
|
60720
|
+
/**
|
|
60721
|
+
* Remove account credentials left in the GLOBAL store. They are dead — the
|
|
60722
|
+
* addon reads credentials only from `integration.settings` — and an older
|
|
60723
|
+
* build left them there as plaintext. Idempotent: a clean store is not
|
|
60724
|
+
* written. Secret keys are cleared through `clearSecrets`, which also drops
|
|
60725
|
+
* any keychain value a marker points at.
|
|
60726
|
+
*/
|
|
60727
|
+
async purgeStaleGlobalCredentials() {
|
|
60728
|
+
const stored = await this.resolveGlobalStore();
|
|
60729
|
+
const present = GLOBAL_CREDENTIAL_KEYS.filter((key) => isStoredValue(stored[key]));
|
|
60730
|
+
if (present.length === 0) return;
|
|
60731
|
+
await this.clearSecrets(present);
|
|
60732
|
+
this.ctx.logger.info("Removed stale Wyze credentials from the addon global store", { meta: { keys: present } });
|
|
58762
60733
|
}
|
|
58763
60734
|
async onGetCreationSchema(type) {
|
|
58764
60735
|
if (type !== DeviceType.Camera) return null;
|