@camstack/addon-provider-rademacher 0.2.123 → 0.2.124
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 +1845 -56
- package/dist/addon.mjs +1845 -56
- package/package.json +1 -1
package/dist/addon.mjs
CHANGED
|
@@ -983,7 +983,7 @@ var Rademacher = class {
|
|
|
983
983
|
}
|
|
984
984
|
};
|
|
985
985
|
//#endregion
|
|
986
|
-
//#region ../types/dist/event-category-
|
|
986
|
+
//#region ../types/dist/event-category-DaIZi00R.mjs
|
|
987
987
|
var EventCategory = /* @__PURE__ */ function(EventCategory) {
|
|
988
988
|
EventCategory["SystemBoot"] = "system.boot";
|
|
989
989
|
EventCategory["SystemAddonsReady"] = "system.addons-ready";
|
|
@@ -1062,6 +1062,13 @@ var EventCategory = /* @__PURE__ */ function(EventCategory) {
|
|
|
1062
1062
|
*/
|
|
1063
1063
|
EventCategory["AddonLoadFailed"] = "addon.load-failed";
|
|
1064
1064
|
/**
|
|
1065
|
+
* A keychain value was stored or removed (D787). Carries the ref, its
|
|
1066
|
+
* owner and the new version — NEVER the value. A process holding the ref
|
|
1067
|
+
* drops its cached copy and the owning `BaseAddon` re-resolves its config.
|
|
1068
|
+
* Telemetry (D8): a process that misses it still revalidates by version.
|
|
1069
|
+
*/
|
|
1070
|
+
EventCategory["KeychainChanged"] = "keychain.changed";
|
|
1071
|
+
/**
|
|
1065
1072
|
* Addon recovered from a previous failure. Emitted when an addon
|
|
1066
1073
|
* transitions from `failed` back to `healthy` (typically via the
|
|
1067
1074
|
* monitor's auto-retry loop, or after manual `addons.retryLoad`).
|
|
@@ -6354,7 +6361,7 @@ var ZodIssueCode = {
|
|
|
6354
6361
|
var ZodFirstPartyTypeKind;
|
|
6355
6362
|
ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {});
|
|
6356
6363
|
//#endregion
|
|
6357
|
-
//#region ../types/dist/sleep-
|
|
6364
|
+
//#region ../types/dist/sleep-Cr5YOk3m.mjs
|
|
6358
6365
|
/**
|
|
6359
6366
|
* The audio chunk plane's byte format, and the ONE expansion from a coded
|
|
6360
6367
|
* window to float samples (D455).
|
|
@@ -6433,6 +6440,97 @@ function buildAlawTable() {
|
|
|
6433
6440
|
}
|
|
6434
6441
|
buildUlawTable();
|
|
6435
6442
|
buildAlawTable();
|
|
6443
|
+
/** Is this field's stored value a credential? */
|
|
6444
|
+
function isSecretConfigField(field) {
|
|
6445
|
+
if (field.type === "password") return true;
|
|
6446
|
+
return "secret" in field && field.secret === true;
|
|
6447
|
+
}
|
|
6448
|
+
/**
|
|
6449
|
+
* Is this field's value stored in the KEYCHAIN (D787)? Every secret field is,
|
|
6450
|
+
* by its TYPE, unless it opts out with `storage: 'inline'` — never by its name.
|
|
6451
|
+
*/
|
|
6452
|
+
function isKeychainStoredField(field) {
|
|
6453
|
+
if (!isSecretConfigField(field)) return false;
|
|
6454
|
+
if (field.type === "textarea" && field.isJson === true) return false;
|
|
6455
|
+
return !("storage" in field && field.storage === "inline");
|
|
6456
|
+
}
|
|
6457
|
+
/**
|
|
6458
|
+
* What a settings blob holds where a secret used to be.
|
|
6459
|
+
*
|
|
6460
|
+
* A keychain-stored field never holds its value. It holds a self-describing
|
|
6461
|
+
* MARKER, `{"$secret":"secret://…","v":1}` — an object, never a string, so no
|
|
6462
|
+
* code can mistake it for a credential and no form can send it to a camera as
|
|
6463
|
+
* a password. The empty state is `null` / absent, never `''`.
|
|
6464
|
+
*
|
|
6465
|
+
* The same shapes travel to and from the admin UI:
|
|
6466
|
+
*
|
|
6467
|
+
* - read: `hydrateSchema` hands a secret field a {@link SecretFieldView}
|
|
6468
|
+
* (`{ $secret, v, set: true }`) or `null` — the browser learns whether a
|
|
6469
|
+
* value is set, never the value.
|
|
6470
|
+
* - write: an untouched field submits the view back unchanged (KEEP); a typed
|
|
6471
|
+
* value is a plain non-empty string (CHANGE); the Clear button submits
|
|
6472
|
+
* {@link SECRET_CLEAR} (CLEAR). `''`, `null` and the legacy redaction tokens
|
|
6473
|
+
* are KEEP — an empty string is what a defaults-fallback pushes back, and
|
|
6474
|
+
* treating it as "clear" is how a save destroyed a stored credential before.
|
|
6475
|
+
*
|
|
6476
|
+
* Pure and browser-safe.
|
|
6477
|
+
*/
|
|
6478
|
+
var SECRET_CLEAR = { $secretClear: true };
|
|
6479
|
+
/** The `'***'` token D634 redaction writes for non-admins. */
|
|
6480
|
+
var LEGACY_DEVICE_REDACTION = "***";
|
|
6481
|
+
function isRecord$1(value) {
|
|
6482
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
6483
|
+
}
|
|
6484
|
+
function makeSecretMarker(ref) {
|
|
6485
|
+
return {
|
|
6486
|
+
$secret: ref,
|
|
6487
|
+
v: 1
|
|
6488
|
+
};
|
|
6489
|
+
}
|
|
6490
|
+
/** A stored marker: an object whose `$secret` is a non-empty string. */
|
|
6491
|
+
function isSecretMarker(value) {
|
|
6492
|
+
if (!isRecord$1(value)) return false;
|
|
6493
|
+
const ref = value["$secret"];
|
|
6494
|
+
return typeof ref === "string" && ref.length > 0;
|
|
6495
|
+
}
|
|
6496
|
+
function isSecretClear(value) {
|
|
6497
|
+
return isRecord$1(value) && value["$secretClear"] === true;
|
|
6498
|
+
}
|
|
6499
|
+
/**
|
|
6500
|
+
* The UI view of a stored secret field value: a marker becomes "set", inline
|
|
6501
|
+
* plaintext becomes "set (inline)", nothing becomes `null`. A value never
|
|
6502
|
+
* survives this function.
|
|
6503
|
+
*/
|
|
6504
|
+
function toSecretFieldView(stored) {
|
|
6505
|
+
if (isSecretMarker(stored)) return {
|
|
6506
|
+
$secret: stored.$secret,
|
|
6507
|
+
v: 1,
|
|
6508
|
+
set: true
|
|
6509
|
+
};
|
|
6510
|
+
if (typeof stored === "string" && stored.length > 0) return {
|
|
6511
|
+
$secret: null,
|
|
6512
|
+
v: 1,
|
|
6513
|
+
set: true,
|
|
6514
|
+
inline: true
|
|
6515
|
+
};
|
|
6516
|
+
return null;
|
|
6517
|
+
}
|
|
6518
|
+
/**
|
|
6519
|
+
* Classify an incoming value for a secret path. Only a non-empty string that is
|
|
6520
|
+
* not a redaction token sets a value; only {@link SECRET_CLEAR} clears.
|
|
6521
|
+
* Everything else — a marker (ours or anyone's), a UI view, `''`, `null`,
|
|
6522
|
+
* `undefined`, a redaction token, a non-string — keeps what is stored.
|
|
6523
|
+
*/
|
|
6524
|
+
function classifySecretWrite(incoming) {
|
|
6525
|
+
if (isSecretClear(incoming)) return { kind: "clear" };
|
|
6526
|
+
if (typeof incoming !== "string") return { kind: "keep" };
|
|
6527
|
+
if (incoming.length === 0) return { kind: "keep" };
|
|
6528
|
+
if (incoming === "__camstack_redacted__" || incoming === LEGACY_DEVICE_REDACTION) return { kind: "keep" };
|
|
6529
|
+
return {
|
|
6530
|
+
kind: "set",
|
|
6531
|
+
value: incoming
|
|
6532
|
+
};
|
|
6533
|
+
}
|
|
6436
6534
|
Object.fromEntries([
|
|
6437
6535
|
{
|
|
6438
6536
|
id: "overview",
|
|
@@ -6604,33 +6702,19 @@ Object.fromEntries([
|
|
|
6604
6702
|
function isValuelessField(field) {
|
|
6605
6703
|
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";
|
|
6606
6704
|
}
|
|
6607
|
-
|
|
6608
|
-
* Merge a `ConfigUISchema` with a raw `values` record into a
|
|
6609
|
-
* `ConfigUISchemaWithValues`. Used by every `get*Settings` backend endpoint
|
|
6610
|
-
* before returning to the admin UI. Groups are walked recursively.
|
|
6611
|
-
*
|
|
6612
|
-
* For each leaf field:
|
|
6613
|
-
* - structural fields (`separator`, `info`, `button`) pass through unchanged
|
|
6614
|
-
* - other fields get `value = values[key] ?? field.default ?? null`
|
|
6615
|
-
*
|
|
6616
|
-
* Unknown keys in `values` (keys not declared in the schema) are silently
|
|
6617
|
-
* ignored — they don't contribute to the output. Missing keys fall back to
|
|
6618
|
-
* the schema default or `null`. This mirrors the old backend behaviour where
|
|
6619
|
-
* `FormBuilder` rendered `values[key] ?? field.default`.
|
|
6620
|
-
*/
|
|
6621
|
-
function hydrateSchema(schema, values) {
|
|
6705
|
+
function hydrateSchema(schema, values, options = {}) {
|
|
6622
6706
|
return {
|
|
6623
6707
|
...schema.tabs ? { tabs: [...schema.tabs] } : {},
|
|
6624
6708
|
sections: schema.sections.map((section) => ({
|
|
6625
6709
|
...section,
|
|
6626
|
-
fields: section.fields.map((field) => hydrateField(field, values))
|
|
6710
|
+
fields: section.fields.map((field) => hydrateField(field, values, options))
|
|
6627
6711
|
}))
|
|
6628
6712
|
};
|
|
6629
6713
|
}
|
|
6630
|
-
function hydrateField(field, values) {
|
|
6714
|
+
function hydrateField(field, values, options) {
|
|
6631
6715
|
if (isValuelessField(field)) return field;
|
|
6632
6716
|
if (field.type === "group") {
|
|
6633
|
-
const hydratedChildren = field.fields.map((child) => hydrateField(child, values));
|
|
6717
|
+
const hydratedChildren = field.fields.map((child) => hydrateField(child, values, options));
|
|
6634
6718
|
return {
|
|
6635
6719
|
...field,
|
|
6636
6720
|
fields: hydratedChildren
|
|
@@ -6639,7 +6723,7 @@ function hydrateField(field, values) {
|
|
|
6639
6723
|
if (field.type === "sub-tabs") {
|
|
6640
6724
|
const hydratedTabs = field.tabs.map((tab) => ({
|
|
6641
6725
|
...tab,
|
|
6642
|
-
fields: tab.fields.map((child) => hydrateField(child, values))
|
|
6726
|
+
fields: tab.fields.map((child) => hydrateField(child, values, options))
|
|
6643
6727
|
}));
|
|
6644
6728
|
return {
|
|
6645
6729
|
...field,
|
|
@@ -6649,6 +6733,33 @@ function hydrateField(field, values) {
|
|
|
6649
6733
|
const key = field.key;
|
|
6650
6734
|
const storedValue = Object.prototype.hasOwnProperty.call(values, key) ? values[key] : void 0;
|
|
6651
6735
|
const defaultValue = field.default;
|
|
6736
|
+
const asView = (v) => isSecretMarker(v) || options.inlineSecretsAsViews === true && v !== void 0;
|
|
6737
|
+
if (isKeychainStoredField(field) && asView(storedValue)) return {
|
|
6738
|
+
...field,
|
|
6739
|
+
value: toSecretFieldView(storedValue)
|
|
6740
|
+
};
|
|
6741
|
+
if (isKeychainStoredField(field) && options.inlineSecretsAsViews === true) return {
|
|
6742
|
+
...field,
|
|
6743
|
+
value: null
|
|
6744
|
+
};
|
|
6745
|
+
if (field.type === "editable-array" && Array.isArray(storedValue)) {
|
|
6746
|
+
const secretItemKeys = field.itemFields.filter((item) => "key" in item && isKeychainStoredField(item)).map((item) => "key" in item ? item.key : "");
|
|
6747
|
+
if (secretItemKeys.length > 0) {
|
|
6748
|
+
const rows = storedValue.map((row) => {
|
|
6749
|
+
if (row === null || typeof row !== "object" || Array.isArray(row)) return row;
|
|
6750
|
+
const out = { ...row };
|
|
6751
|
+
for (const k of secretItemKeys) {
|
|
6752
|
+
const v = Reflect.get(row, k);
|
|
6753
|
+
if (asView(v)) out[k] = toSecretFieldView(v);
|
|
6754
|
+
}
|
|
6755
|
+
return out;
|
|
6756
|
+
});
|
|
6757
|
+
return {
|
|
6758
|
+
...field,
|
|
6759
|
+
value: rows
|
|
6760
|
+
};
|
|
6761
|
+
}
|
|
6762
|
+
}
|
|
6652
6763
|
if (field.multiple) {
|
|
6653
6764
|
const stored = Array.isArray(storedValue) ? storedValue : storedValue !== void 0 && storedValue !== null ? [storedValue] : [];
|
|
6654
6765
|
const itemFallback = field.multiple.itemDefault !== void 0 ? field.multiple.itemDefault : defaultValue !== void 0 ? defaultValue : typeOf(field) === "string" ? "" : null;
|
|
@@ -6891,6 +7002,431 @@ function projectStore(store, perNodeKeys, nodeId) {
|
|
|
6891
7002
|
}
|
|
6892
7003
|
return out;
|
|
6893
7004
|
}
|
|
7005
|
+
var GLOBAL_SCOPE = { kind: "global" };
|
|
7006
|
+
/** The scope every addon-wide (not per-node, not per-device) setting lives in. */
|
|
7007
|
+
function globalSecretScope() {
|
|
7008
|
+
return GLOBAL_SCOPE;
|
|
7009
|
+
}
|
|
7010
|
+
function encodeSegment(value) {
|
|
7011
|
+
return encodeURIComponent(value);
|
|
7012
|
+
}
|
|
7013
|
+
/**
|
|
7014
|
+
* The field path of a value inside an array item, addressed by the item's id:
|
|
7015
|
+
* `arrayItemFieldPath('providers', 'authentik', 'clientSecret')` →
|
|
7016
|
+
* `providers[authentik].clientSecret`.
|
|
7017
|
+
*/
|
|
7018
|
+
function arrayItemFieldPath(arrayKey, itemId, fieldKey) {
|
|
7019
|
+
return `${arrayKey}[${encodeSegment(itemId)}].${fieldKey}`;
|
|
7020
|
+
}
|
|
7021
|
+
/** A write to a secret path could not be stored in the keychain, so it was refused. */
|
|
7022
|
+
var KeychainWriteRefusedError = class extends Error {
|
|
7023
|
+
fieldPath;
|
|
7024
|
+
constructor(fieldPath, cause) {
|
|
7025
|
+
super(`secret "${fieldPath}" was not saved: the keychain could not store it (${cause instanceof Error ? cause.message : String(cause)}). Nothing was written.`);
|
|
7026
|
+
this.fieldPath = fieldPath;
|
|
7027
|
+
this.name = "KeychainWriteRefusedError";
|
|
7028
|
+
}
|
|
7029
|
+
};
|
|
7030
|
+
var KEEP = { kind: "keep" };
|
|
7031
|
+
function isRecord(value) {
|
|
7032
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
7033
|
+
}
|
|
7034
|
+
function defaultMintId() {
|
|
7035
|
+
return globalThis.crypto.randomUUID();
|
|
7036
|
+
}
|
|
7037
|
+
/** Every marker ref anywhere under `value`. */
|
|
7038
|
+
function collectSecretMarkerRefs(value, out = []) {
|
|
7039
|
+
if (isSecretMarker(value)) {
|
|
7040
|
+
out.push(value.$secret);
|
|
7041
|
+
return out;
|
|
7042
|
+
}
|
|
7043
|
+
if (Array.isArray(value)) for (const item of value) collectSecretMarkerRefs(item, out);
|
|
7044
|
+
else if (isRecord(value)) for (const child of Object.values(value)) collectSecretMarkerRefs(child, out);
|
|
7045
|
+
return out;
|
|
7046
|
+
}
|
|
7047
|
+
async function storedValueEquals(secrets, marker, candidate) {
|
|
7048
|
+
const resolved = (await secrets.resolve([marker.$secret]))[marker.$secret];
|
|
7049
|
+
return resolved?.kind === "value" && resolved.value === candidate;
|
|
7050
|
+
}
|
|
7051
|
+
async function writeLeaf(ctx, incoming, stored, fieldPath) {
|
|
7052
|
+
const intent = classifySecretWrite(incoming);
|
|
7053
|
+
const ref = ctx.secrets.ref(ctx.scope, fieldPath);
|
|
7054
|
+
const storedIsOurs = isSecretMarker(stored) && stored.$secret === ref;
|
|
7055
|
+
if (intent.kind === "keep") return KEEP;
|
|
7056
|
+
if (intent.kind === "set" && !ctx.operatorWrite && typeof stored === "string" && stored === intent.value) return KEEP;
|
|
7057
|
+
if (intent.kind === "clear") {
|
|
7058
|
+
if (storedIsOurs) ctx.deletes.push(ref);
|
|
7059
|
+
return {
|
|
7060
|
+
kind: "value",
|
|
7061
|
+
value: null
|
|
7062
|
+
};
|
|
7063
|
+
}
|
|
7064
|
+
if (storedIsOurs && await storedValueEquals(ctx.secrets, stored, intent.value)) return {
|
|
7065
|
+
kind: "value",
|
|
7066
|
+
value: stored
|
|
7067
|
+
};
|
|
7068
|
+
try {
|
|
7069
|
+
await ctx.secrets.put(ref, intent.value);
|
|
7070
|
+
} catch (err) {
|
|
7071
|
+
throw new KeychainWriteRefusedError(fieldPath, err);
|
|
7072
|
+
}
|
|
7073
|
+
return {
|
|
7074
|
+
kind: "value",
|
|
7075
|
+
value: makeSecretMarker(ref)
|
|
7076
|
+
};
|
|
7077
|
+
}
|
|
7078
|
+
/** Apply a member result onto `out`: KEEP restores the stored member, or removes it. */
|
|
7079
|
+
function applyMember(out, key, result, storedParent) {
|
|
7080
|
+
if (result.kind === "value") {
|
|
7081
|
+
out[key] = result.value;
|
|
7082
|
+
return;
|
|
7083
|
+
}
|
|
7084
|
+
if (Object.prototype.hasOwnProperty.call(storedParent, key)) out[key] = storedParent[key];
|
|
7085
|
+
else delete out[key];
|
|
7086
|
+
}
|
|
7087
|
+
async function writeMembers(ctx, children, incoming, stored, pathOf) {
|
|
7088
|
+
const out = { ...incoming };
|
|
7089
|
+
for (const [member, node] of children) applyMember(out, member, await writeNode(ctx, node, incoming[member], stored[member], pathOf(member)), stored);
|
|
7090
|
+
return out;
|
|
7091
|
+
}
|
|
7092
|
+
function rowId(row, idKey) {
|
|
7093
|
+
const raw = row[idKey];
|
|
7094
|
+
if (typeof raw === "string" && raw.length > 0) return raw;
|
|
7095
|
+
if (typeof raw === "number" && Number.isFinite(raw)) return String(raw);
|
|
7096
|
+
return null;
|
|
7097
|
+
}
|
|
7098
|
+
async function writeArray(ctx, node, incoming, stored, fieldPath) {
|
|
7099
|
+
const storedRows = Array.isArray(stored) ? stored.filter(isRecord) : [];
|
|
7100
|
+
if (!Array.isArray(incoming)) {
|
|
7101
|
+
ctx.deletes.push(...collectSecretMarkerRefs(storedRows));
|
|
7102
|
+
return {
|
|
7103
|
+
kind: "value",
|
|
7104
|
+
value: incoming
|
|
7105
|
+
};
|
|
7106
|
+
}
|
|
7107
|
+
const storedById = /* @__PURE__ */ new Map();
|
|
7108
|
+
for (const row of storedRows) {
|
|
7109
|
+
const id = rowId(row, node.idKey);
|
|
7110
|
+
if (id !== null) storedById.set(id, row);
|
|
7111
|
+
}
|
|
7112
|
+
const kept = /* @__PURE__ */ new Set();
|
|
7113
|
+
const rows = [];
|
|
7114
|
+
for (const row of incoming) {
|
|
7115
|
+
if (!isRecord(row)) {
|
|
7116
|
+
rows.push(row);
|
|
7117
|
+
continue;
|
|
7118
|
+
}
|
|
7119
|
+
const id = rowId(row, node.idKey) ?? ctx.mintId();
|
|
7120
|
+
kept.add(id);
|
|
7121
|
+
const withId = {
|
|
7122
|
+
...row,
|
|
7123
|
+
[node.idKey]: row[node.idKey] ?? id
|
|
7124
|
+
};
|
|
7125
|
+
if (rowId(withId, node.idKey) === null) withId[node.idKey] = id;
|
|
7126
|
+
const storedRow = storedById.get(id) ?? {};
|
|
7127
|
+
rows.push(await writeMembers(ctx, node.item, withId, storedRow, (member) => arrayItemFieldPath(fieldPath, id, member)));
|
|
7128
|
+
}
|
|
7129
|
+
for (const [id, row] of storedById) if (!kept.has(id)) ctx.deletes.push(...collectSecretMarkerRefs(row));
|
|
7130
|
+
return {
|
|
7131
|
+
kind: "value",
|
|
7132
|
+
value: rows
|
|
7133
|
+
};
|
|
7134
|
+
}
|
|
7135
|
+
async function writeNode(ctx, node, incoming, stored, fieldPath) {
|
|
7136
|
+
switch (node.kind) {
|
|
7137
|
+
case "leaf": return writeLeaf(ctx, incoming, stored, fieldPath);
|
|
7138
|
+
case "array": return writeArray(ctx, node, incoming, stored, fieldPath);
|
|
7139
|
+
case "object": {
|
|
7140
|
+
if (!isRecord(incoming)) {
|
|
7141
|
+
if (incoming === void 0) return KEEP;
|
|
7142
|
+
ctx.deletes.push(...collectSecretMarkerRefs(stored));
|
|
7143
|
+
return {
|
|
7144
|
+
kind: "value",
|
|
7145
|
+
value: incoming
|
|
7146
|
+
};
|
|
7147
|
+
}
|
|
7148
|
+
const storedObj = isRecord(stored) ? stored : {};
|
|
7149
|
+
return {
|
|
7150
|
+
kind: "value",
|
|
7151
|
+
value: await writeMembers(ctx, node.children, incoming, storedObj, (m) => `${fieldPath}.${m}`)
|
|
7152
|
+
};
|
|
7153
|
+
}
|
|
7154
|
+
}
|
|
7155
|
+
}
|
|
7156
|
+
/** Split a perNode-scoped key (`key@nodeId`). */
|
|
7157
|
+
function splitNodeKey(key) {
|
|
7158
|
+
const at = key.indexOf("@");
|
|
7159
|
+
return at <= 0 ? {
|
|
7160
|
+
base: key,
|
|
7161
|
+
nodeId: null
|
|
7162
|
+
} : {
|
|
7163
|
+
base: key.slice(0, at),
|
|
7164
|
+
nodeId: key.slice(at + 1)
|
|
7165
|
+
};
|
|
7166
|
+
}
|
|
7167
|
+
/** Rewrite a settings patch so no secret value reaches the blob. See the file doc. */
|
|
7168
|
+
async function transformSecretWrite(input) {
|
|
7169
|
+
const deletes = [];
|
|
7170
|
+
const base = {
|
|
7171
|
+
secrets: input.secrets,
|
|
7172
|
+
mintId: input.mintId ?? defaultMintId,
|
|
7173
|
+
deletes,
|
|
7174
|
+
operatorWrite: input.operatorWrite === true
|
|
7175
|
+
};
|
|
7176
|
+
const out = {};
|
|
7177
|
+
for (const [key, incoming] of Object.entries(input.patch)) {
|
|
7178
|
+
const { base: baseKey, nodeId } = splitNodeKey(key);
|
|
7179
|
+
const node = input.tree.get(baseKey);
|
|
7180
|
+
if (node === void 0) {
|
|
7181
|
+
out[key] = incoming;
|
|
7182
|
+
continue;
|
|
7183
|
+
}
|
|
7184
|
+
const scope = nodeId !== null && nodeId.length > 0 ? {
|
|
7185
|
+
kind: "node",
|
|
7186
|
+
nodeId
|
|
7187
|
+
} : input.scope ?? globalSecretScope();
|
|
7188
|
+
const result = await writeNode({
|
|
7189
|
+
...base,
|
|
7190
|
+
scope
|
|
7191
|
+
}, node, incoming, input.stored[key], baseKey);
|
|
7192
|
+
if (result.kind === "value") out[key] = result.value;
|
|
7193
|
+
}
|
|
7194
|
+
return {
|
|
7195
|
+
patch: out,
|
|
7196
|
+
afterWrite: async () => {
|
|
7197
|
+
if (deletes.length === 0) return { orphaned: [] };
|
|
7198
|
+
try {
|
|
7199
|
+
await input.secrets.delete([...new Set(deletes)]);
|
|
7200
|
+
return { orphaned: [] };
|
|
7201
|
+
} catch {
|
|
7202
|
+
return { orphaned: [...new Set(deletes)] };
|
|
7203
|
+
}
|
|
7204
|
+
}
|
|
7205
|
+
};
|
|
7206
|
+
}
|
|
7207
|
+
/**
|
|
7208
|
+
* Replace every marker in `value` with its keychain value. Returns the SAME
|
|
7209
|
+
* reference when there is no marker (no allocation, no keychain call).
|
|
7210
|
+
*/
|
|
7211
|
+
async function resolveSecretMarkers(value, secrets) {
|
|
7212
|
+
const refs = collectSecretMarkerRefs(value);
|
|
7213
|
+
if (refs.length === 0) return {
|
|
7214
|
+
value,
|
|
7215
|
+
unresolved: []
|
|
7216
|
+
};
|
|
7217
|
+
const answers = await secrets.resolve(refs);
|
|
7218
|
+
const unresolved = [];
|
|
7219
|
+
for (const ref of new Set(refs)) {
|
|
7220
|
+
const answer = answers[ref];
|
|
7221
|
+
if (answer === void 0) unresolved.push({
|
|
7222
|
+
ref,
|
|
7223
|
+
reason: "not-initialized"
|
|
7224
|
+
});
|
|
7225
|
+
else if (answer.kind === "unavailable") unresolved.push({
|
|
7226
|
+
ref,
|
|
7227
|
+
reason: answer.reason
|
|
7228
|
+
});
|
|
7229
|
+
else if (answer.kind === "missing" || answer.kind === "forbidden") unresolved.push({
|
|
7230
|
+
ref,
|
|
7231
|
+
reason: answer.kind
|
|
7232
|
+
});
|
|
7233
|
+
}
|
|
7234
|
+
const substitute = (v) => {
|
|
7235
|
+
if (isSecretMarker(v)) {
|
|
7236
|
+
const answer = answers[v.$secret];
|
|
7237
|
+
return answer?.kind === "value" ? {
|
|
7238
|
+
keep: true,
|
|
7239
|
+
value: answer.value
|
|
7240
|
+
} : {
|
|
7241
|
+
keep: false,
|
|
7242
|
+
value: void 0
|
|
7243
|
+
};
|
|
7244
|
+
}
|
|
7245
|
+
if (Array.isArray(v)) {
|
|
7246
|
+
const items = [];
|
|
7247
|
+
for (const item of v) {
|
|
7248
|
+
const s = substitute(item);
|
|
7249
|
+
if (s.keep) items.push(s.value);
|
|
7250
|
+
}
|
|
7251
|
+
return {
|
|
7252
|
+
keep: true,
|
|
7253
|
+
value: items
|
|
7254
|
+
};
|
|
7255
|
+
}
|
|
7256
|
+
if (isRecord(v)) {
|
|
7257
|
+
const out = {};
|
|
7258
|
+
for (const [k, child] of Object.entries(v)) {
|
|
7259
|
+
const s = substitute(child);
|
|
7260
|
+
if (s.keep) out[k] = s.value;
|
|
7261
|
+
}
|
|
7262
|
+
return {
|
|
7263
|
+
keep: true,
|
|
7264
|
+
value: out
|
|
7265
|
+
};
|
|
7266
|
+
}
|
|
7267
|
+
return {
|
|
7268
|
+
keep: true,
|
|
7269
|
+
value: v
|
|
7270
|
+
};
|
|
7271
|
+
};
|
|
7272
|
+
return {
|
|
7273
|
+
value: substitute(value).value,
|
|
7274
|
+
unresolved
|
|
7275
|
+
};
|
|
7276
|
+
}
|
|
7277
|
+
function touchesTree(tree, patch) {
|
|
7278
|
+
if (tree.size === 0) return false;
|
|
7279
|
+
for (const key of Object.keys(patch)) {
|
|
7280
|
+
const at = key.indexOf("@");
|
|
7281
|
+
if (tree.has(at > 0 ? key.slice(0, at) : key)) return true;
|
|
7282
|
+
}
|
|
7283
|
+
return false;
|
|
7284
|
+
}
|
|
7285
|
+
/** The blob as stored now; a failed read REFUSES the write instead of guessing. */
|
|
7286
|
+
async function readStoredAddonBlob(raw) {
|
|
7287
|
+
const threeWay = raw.readAddonStoreResult;
|
|
7288
|
+
if (threeWay === void 0) return raw.readAddonStore();
|
|
7289
|
+
const result = await threeWay.call(raw);
|
|
7290
|
+
if (result.kind === "failed") throw new Error(`settings write refused: the stored blob could not be read (${result.error})`);
|
|
7291
|
+
return result.kind === "missing" ? {} : result.value;
|
|
7292
|
+
}
|
|
7293
|
+
function createSecretAwareSettings(raw, opts) {
|
|
7294
|
+
const chains = /* @__PURE__ */ new Map();
|
|
7295
|
+
const serialize = (key, fn) => {
|
|
7296
|
+
const next = (chains.get(key) ?? Promise.resolve()).then(fn, fn);
|
|
7297
|
+
const tail = next.catch(() => void 0);
|
|
7298
|
+
chains.set(key, tail);
|
|
7299
|
+
tail.then(() => {
|
|
7300
|
+
if (chains.get(key) === tail) chains.delete(key);
|
|
7301
|
+
});
|
|
7302
|
+
return next;
|
|
7303
|
+
};
|
|
7304
|
+
const write = async (chainKey, tree, scope, patch, readStored, rawWrite) => {
|
|
7305
|
+
if (!touchesTree(tree, patch)) return rawWrite(patch);
|
|
7306
|
+
return serialize(chainKey, async () => {
|
|
7307
|
+
const stored = await readStored();
|
|
7308
|
+
const result = await transformSecretWrite({
|
|
7309
|
+
tree,
|
|
7310
|
+
secrets: opts.secrets,
|
|
7311
|
+
patch,
|
|
7312
|
+
stored,
|
|
7313
|
+
...scope !== void 0 ? { scope } : {},
|
|
7314
|
+
operatorWrite: opts.isOperatorWrite?.() === true
|
|
7315
|
+
});
|
|
7316
|
+
if (Object.keys(result.patch).length > 0) await rawWrite(result.patch);
|
|
7317
|
+
const { orphaned } = await result.afterWrite();
|
|
7318
|
+
if (orphaned.length > 0) opts.onOrphaned(orphaned);
|
|
7319
|
+
});
|
|
7320
|
+
};
|
|
7321
|
+
const wrapped = {
|
|
7322
|
+
writeAddonStore: (patch) => write("addon", opts.addonTree(), void 0, patch, () => readStoredAddonBlob(raw), (p) => raw.writeAddonStore(p)),
|
|
7323
|
+
writeDeviceStore: (deviceId, patch) => write(`device:${deviceId}`, opts.deviceTree(), {
|
|
7324
|
+
kind: "device",
|
|
7325
|
+
deviceId
|
|
7326
|
+
}, patch, () => raw.readDeviceStore(deviceId), (p) => raw.writeDeviceStore(deviceId, p))
|
|
7327
|
+
};
|
|
7328
|
+
return new Proxy(raw, { get(target, prop, receiver) {
|
|
7329
|
+
if (prop === "writeAddonStore") return wrapped.writeAddonStore;
|
|
7330
|
+
if (prop === "writeDeviceStore") return wrapped.writeDeviceStore;
|
|
7331
|
+
const value = Reflect.get(target, prop, receiver);
|
|
7332
|
+
return typeof value === "function" ? value.bind(target) : value;
|
|
7333
|
+
} });
|
|
7334
|
+
}
|
|
7335
|
+
/** The context the addon sees: identical, except that its settings writes are secret-aware. */
|
|
7336
|
+
function withSecretAwareSettings(context, opts) {
|
|
7337
|
+
const raw = context.settings;
|
|
7338
|
+
if (raw === void 0) return context;
|
|
7339
|
+
const settings = createSecretAwareSettings(raw, opts);
|
|
7340
|
+
return new Proxy(context, { get(target, prop, receiver) {
|
|
7341
|
+
if (prop === "settings") return settings;
|
|
7342
|
+
return Reflect.get(target, prop, receiver);
|
|
7343
|
+
} });
|
|
7344
|
+
}
|
|
7345
|
+
var LEAF = { kind: "leaf" };
|
|
7346
|
+
var DEFAULT_ITEM_ID_KEY = "id";
|
|
7347
|
+
function collectFields(fields, out) {
|
|
7348
|
+
for (const field of fields) {
|
|
7349
|
+
if (field.type === "group") {
|
|
7350
|
+
collectFields(field.fields, out);
|
|
7351
|
+
continue;
|
|
7352
|
+
}
|
|
7353
|
+
if (field.type === "sub-tabs") {
|
|
7354
|
+
for (const tab of field.tabs) collectFields(tab.fields, out);
|
|
7355
|
+
continue;
|
|
7356
|
+
}
|
|
7357
|
+
if (field.type === "editable-array") {
|
|
7358
|
+
const item = /* @__PURE__ */ new Map();
|
|
7359
|
+
for (const itemField of field.itemFields) if ("key" in itemField && isKeychainStoredField(itemField)) item.set(itemField.key, LEAF);
|
|
7360
|
+
if (item.size > 0) out.set(field.key, {
|
|
7361
|
+
kind: "array",
|
|
7362
|
+
idKey: field.itemIdKey ?? DEFAULT_ITEM_ID_KEY,
|
|
7363
|
+
item
|
|
7364
|
+
});
|
|
7365
|
+
continue;
|
|
7366
|
+
}
|
|
7367
|
+
if (!("key" in field) || typeof field.key !== "string") continue;
|
|
7368
|
+
if (isKeychainStoredField(field)) out.set(field.key, LEAF);
|
|
7369
|
+
}
|
|
7370
|
+
}
|
|
7371
|
+
/** The secret tree a settings schema declares. */
|
|
7372
|
+
function secretTreeFromSchema(schema) {
|
|
7373
|
+
const out = /* @__PURE__ */ new Map();
|
|
7374
|
+
if (schema === null) return out;
|
|
7375
|
+
for (const section of schema.sections) collectFields(section.fields, out);
|
|
7376
|
+
return out;
|
|
7377
|
+
}
|
|
7378
|
+
/** Parse `a.b[id].c` into segments; throws on a malformed path (a declaration bug). */
|
|
7379
|
+
function parseSecretStatePath(path) {
|
|
7380
|
+
const segments = [];
|
|
7381
|
+
for (const raw of path.split(".")) {
|
|
7382
|
+
const m = /^([^[\]]+)(?:\[([^[\]]+)\])?$/.exec(raw);
|
|
7383
|
+
if (m === null || m[1] === void 0) throw new Error(`secretStatePaths: malformed path "${path}"`);
|
|
7384
|
+
segments.push(m[2] !== void 0 ? {
|
|
7385
|
+
key: m[1],
|
|
7386
|
+
idKey: m[2]
|
|
7387
|
+
} : { key: m[1] });
|
|
7388
|
+
}
|
|
7389
|
+
if (segments.length === 0) throw new Error(`secretStatePaths: empty path`);
|
|
7390
|
+
if (segments[segments.length - 1]?.idKey !== void 0) throw new Error(`secretStatePaths: "${path}" ends on an array — name the member that is secret`);
|
|
7391
|
+
return segments;
|
|
7392
|
+
}
|
|
7393
|
+
function insert(into, segments) {
|
|
7394
|
+
const [head, ...rest] = segments;
|
|
7395
|
+
if (head === void 0) return;
|
|
7396
|
+
if (rest.length === 0) {
|
|
7397
|
+
into.set(head.key, LEAF);
|
|
7398
|
+
return;
|
|
7399
|
+
}
|
|
7400
|
+
const existing = into.get(head.key);
|
|
7401
|
+
if (head.idKey !== void 0) {
|
|
7402
|
+
const item = new Map(existing?.kind === "array" ? existing.item : []);
|
|
7403
|
+
insert(item, rest);
|
|
7404
|
+
into.set(head.key, {
|
|
7405
|
+
kind: "array",
|
|
7406
|
+
idKey: head.idKey,
|
|
7407
|
+
item
|
|
7408
|
+
});
|
|
7409
|
+
return;
|
|
7410
|
+
}
|
|
7411
|
+
const children = new Map(existing?.kind === "object" ? existing.children : []);
|
|
7412
|
+
insert(children, rest);
|
|
7413
|
+
into.set(head.key, {
|
|
7414
|
+
kind: "object",
|
|
7415
|
+
children
|
|
7416
|
+
});
|
|
7417
|
+
}
|
|
7418
|
+
/** Add hidden-state paths (`secretStatePaths`) to a schema-derived tree. */
|
|
7419
|
+
function mergeSecretStatePaths(tree, paths) {
|
|
7420
|
+
if (paths.length === 0) return tree;
|
|
7421
|
+
const out = new Map(tree);
|
|
7422
|
+
for (const path of paths) insert(out, parseSecretStatePath(path));
|
|
7423
|
+
return out;
|
|
7424
|
+
}
|
|
7425
|
+
/** First retry of a secret the keychain could not serve; doubles to {@link SECRET_RETRY_MAX_MS}. */
|
|
7426
|
+
var SECRET_RETRY_FIRST_MS = 5e3;
|
|
7427
|
+
var SECRET_RETRY_MAX_MS = 5 * 6e4;
|
|
7428
|
+
/** Coalesces a burst of `keychain.changed` events into one re-resolve. */
|
|
7429
|
+
var SECRET_CHANGE_DEBOUNCE_MS = 250;
|
|
6894
7430
|
/**
|
|
6895
7431
|
* Base class for CamStack addons. Eliminates settings boilerplate:
|
|
6896
7432
|
*
|
|
@@ -6960,6 +7496,25 @@ var BaseAddon = class {
|
|
|
6960
7496
|
settingsStoreReady = false;
|
|
6961
7497
|
/** Default config values. Provided via constructor. */
|
|
6962
7498
|
defaults;
|
|
7499
|
+
/**
|
|
7500
|
+
* Hidden-state paths that hold secrets (D787) — values the addon writes
|
|
7501
|
+
* itself (`updateGlobalSettings`, `state()`) that no form field declares.
|
|
7502
|
+
* Stored in the keychain exactly like a `password` field. Syntax:
|
|
7503
|
+
* `'snapshotSigningKey'`, `'identity.pincode'`, `'tokens[userId].accessToken'`
|
|
7504
|
+
* (`key[<id field>]` addresses array items by id, never by index).
|
|
7505
|
+
*/
|
|
7506
|
+
secretStatePaths = [];
|
|
7507
|
+
_addonSecretTree = null;
|
|
7508
|
+
_deviceSecretTree = null;
|
|
7509
|
+
/** Refs the last resolved config pointed at — a change to one re-resolves. */
|
|
7510
|
+
_configSecretRefs = /* @__PURE__ */ new Set();
|
|
7511
|
+
_unresolvedSecrets = [];
|
|
7512
|
+
_secretRetryTimer = null;
|
|
7513
|
+
_secretRetryDelayMs = SECRET_RETRY_FIRST_MS;
|
|
7514
|
+
_secretChangeTimer = null;
|
|
7515
|
+
_secretChangeUnsub = null;
|
|
7516
|
+
/** >0 while an OPERATOR's settings write is being applied. */
|
|
7517
|
+
_operatorWriteDepth = 0;
|
|
6963
7518
|
constructor(defaults) {
|
|
6964
7519
|
this.defaults = defaults;
|
|
6965
7520
|
this._config = { ...defaults };
|
|
@@ -6995,8 +7550,18 @@ var BaseAddon = class {
|
|
|
6995
7550
|
return this._config;
|
|
6996
7551
|
}
|
|
6997
7552
|
async initialize(context) {
|
|
6998
|
-
|
|
7553
|
+
const secrets = context.secrets;
|
|
7554
|
+
this._ctx = secrets !== void 0 ? withSecretAwareSettings(context, {
|
|
7555
|
+
secrets,
|
|
7556
|
+
addonTree: () => this.addonSecretTree(),
|
|
7557
|
+
deviceTree: () => this.deviceSecretTree(),
|
|
7558
|
+
onOrphaned: (refs) => context.logger.warn("keychain refs dropped by a settings write could not be deleted", { meta: { refs: [...refs] } }),
|
|
7559
|
+
isOperatorWrite: () => this._operatorWriteDepth > 0
|
|
7560
|
+
}) : context;
|
|
6999
7561
|
await this.resolveConfig();
|
|
7562
|
+
if (secrets !== void 0) this._secretChangeUnsub = secrets.onChange((ref) => {
|
|
7563
|
+
if (this._configSecretRefs.has(ref)) this.scheduleSecretReresolve(SECRET_CHANGE_DEBOUNCE_MS);
|
|
7564
|
+
});
|
|
7000
7565
|
const result = await this.onInitialize();
|
|
7001
7566
|
this.emitLifecycle(EventCategory.AddonStarted);
|
|
7002
7567
|
const normalized = normalizeAddonInitResult(result);
|
|
@@ -7029,6 +7594,12 @@ var BaseAddon = class {
|
|
|
7029
7594
|
*/
|
|
7030
7595
|
async onHubReachable() {}
|
|
7031
7596
|
async shutdown() {
|
|
7597
|
+
this._secretChangeUnsub?.();
|
|
7598
|
+
this._secretChangeUnsub = null;
|
|
7599
|
+
if (this._secretRetryTimer !== null) clearTimeout(this._secretRetryTimer);
|
|
7600
|
+
if (this._secretChangeTimer !== null) clearTimeout(this._secretChangeTimer);
|
|
7601
|
+
this._secretRetryTimer = null;
|
|
7602
|
+
this._secretChangeTimer = null;
|
|
7032
7603
|
this.emitLifecycle(EventCategory.AddonStopped);
|
|
7033
7604
|
if (this.autoEmitReadiness) this.emitReadinessForProviders("down");
|
|
7034
7605
|
await this.onShutdown();
|
|
@@ -7107,7 +7678,7 @@ var BaseAddon = class {
|
|
|
7107
7678
|
return hydrateSchema(schema, overlay ? {
|
|
7108
7679
|
...projected,
|
|
7109
7680
|
...overlay
|
|
7110
|
-
} : projected);
|
|
7681
|
+
} : projected, { inlineSecretsAsViews: true });
|
|
7111
7682
|
}
|
|
7112
7683
|
/**
|
|
7113
7684
|
* The integration-level view of this addon's settings: exactly the sections
|
|
@@ -7156,7 +7727,7 @@ var BaseAddon = class {
|
|
|
7156
7727
|
return hydrateSchema({
|
|
7157
7728
|
...schema,
|
|
7158
7729
|
sections
|
|
7159
|
-
}, projected);
|
|
7730
|
+
}, projected, { inlineSecretsAsViews: true });
|
|
7160
7731
|
}
|
|
7161
7732
|
/**
|
|
7162
7733
|
* The raw addon store PROJECTED onto the target node's bare per-node keys:
|
|
@@ -7210,18 +7781,50 @@ var BaseAddon = class {
|
|
|
7210
7781
|
value: result.value[key]
|
|
7211
7782
|
};
|
|
7212
7783
|
}
|
|
7784
|
+
/**
|
|
7785
|
+
* The OPERATOR's write — a settings form or an admin API call, dispatched by
|
|
7786
|
+
* the kernel. Identical to {@link updateGlobalSettings}, except that a secret
|
|
7787
|
+
* the operator sends is stored as sent even when it equals a pre-keychain
|
|
7788
|
+
* inline value: the operator re-entering a password is a change, an addon
|
|
7789
|
+
* writing back what it read is not (D787).
|
|
7790
|
+
*/
|
|
7791
|
+
async updateGlobalSettingsAsOperator(patch, nodeId) {
|
|
7792
|
+
this._operatorWriteDepth++;
|
|
7793
|
+
try {
|
|
7794
|
+
await this.applyGlobalPatch(patch, nodeId);
|
|
7795
|
+
} finally {
|
|
7796
|
+
this._operatorWriteDepth--;
|
|
7797
|
+
}
|
|
7798
|
+
}
|
|
7213
7799
|
async updateGlobalSettings(patch, nodeId) {
|
|
7800
|
+
await this.applyGlobalPatch(patch, nodeId);
|
|
7801
|
+
}
|
|
7802
|
+
/**
|
|
7803
|
+
* REMOVE stored secrets — their keychain values and their markers (D787).
|
|
7804
|
+
*
|
|
7805
|
+
* Writing `''` to a secret field KEEPS what is stored (an empty string is
|
|
7806
|
+
* what a defaults fallback writes back, and it must never destroy a
|
|
7807
|
+
* credential), so code that means "forget this token" says so here. Without
|
|
7808
|
+
* a keychain (an older kernel) it writes `''`, as such code always did.
|
|
7809
|
+
*/
|
|
7810
|
+
async clearSecrets(keys, nodeId) {
|
|
7811
|
+
const tree = this.addonSecretTree();
|
|
7812
|
+
const keychain = this._ctx?.secrets !== void 0;
|
|
7813
|
+
const patch = {};
|
|
7814
|
+
for (const key of keys) patch[key] = keychain && tree.has(key) ? SECRET_CLEAR : "";
|
|
7815
|
+
await this.applyGlobalPatch(patch, nodeId);
|
|
7816
|
+
}
|
|
7817
|
+
async applyGlobalPatch(barePatch, nodeId) {
|
|
7214
7818
|
const keys = this.perNodeKeys();
|
|
7215
7819
|
const localNode = normalizeNodeId(this._ctx?.kernel?.localNodeId);
|
|
7216
7820
|
const target = normalizeNodeId(nodeId ?? this._ctx?.kernel?.localNodeId);
|
|
7217
|
-
const barePatch = patch;
|
|
7218
7821
|
const scoped = keys.size > 0 ? scopePatch(barePatch, keys, target) : barePatch;
|
|
7219
7822
|
await this._ctx?.settings?.writeAddonStore(scoped);
|
|
7220
7823
|
if (target !== localNode) return;
|
|
7221
7824
|
await this.resolveConfig();
|
|
7222
7825
|
await this.onConfigChanged();
|
|
7223
7826
|
this.emitLifecycle(EventCategory.AddonUpdated, { level: "global" });
|
|
7224
|
-
this.maybeAutoRestart(
|
|
7827
|
+
this.maybeAutoRestart(Object.keys(barePatch), this.globalSettingsSchema());
|
|
7225
7828
|
}
|
|
7226
7829
|
/**
|
|
7227
7830
|
* The set of field keys the global settings schema declares `perNode: true`
|
|
@@ -7246,7 +7849,7 @@ var BaseAddon = class {
|
|
|
7246
7849
|
* time to return its response before the addon is torn down and
|
|
7247
7850
|
* re-initialised by `AddonRegistryService.restartAddon`.
|
|
7248
7851
|
*/
|
|
7249
|
-
maybeAutoRestart(
|
|
7852
|
+
maybeAutoRestart(patchKeys, schema) {
|
|
7250
7853
|
if (!schema) return;
|
|
7251
7854
|
const restartKeys = /* @__PURE__ */ new Set();
|
|
7252
7855
|
for (const section of schema.sections) for (const field of section.fields) {
|
|
@@ -7254,13 +7857,13 @@ var BaseAddon = class {
|
|
|
7254
7857
|
if (field.requiresRestart) restartKeys.add(field.key);
|
|
7255
7858
|
}
|
|
7256
7859
|
if (restartKeys.size === 0) return;
|
|
7257
|
-
if (!
|
|
7860
|
+
if (!patchKeys.some((k) => restartKeys.has(k))) return;
|
|
7258
7861
|
const ctx = this._ctx;
|
|
7259
7862
|
if (!ctx) return;
|
|
7260
7863
|
const addonId = ctx.id;
|
|
7261
7864
|
setImmediate(() => {
|
|
7262
7865
|
ctx.api.addons?.restartAddon?.mutate({ addonId }).then(() => {
|
|
7263
|
-
ctx.logger.info("addon auto-restart triggered by restart-required setting change", { meta: { changedFields:
|
|
7866
|
+
ctx.logger.info("addon auto-restart triggered by restart-required setting change", { meta: { changedFields: patchKeys.filter((k) => restartKeys.has(k)) } });
|
|
7264
7867
|
}).catch((err) => {
|
|
7265
7868
|
ctx.logger.error("addon auto-restart failed", { meta: { error: err instanceof Error ? err.message : String(err) } });
|
|
7266
7869
|
});
|
|
@@ -7269,7 +7872,7 @@ var BaseAddon = class {
|
|
|
7269
7872
|
async getDeviceSettings(deviceId) {
|
|
7270
7873
|
const schema = this.deviceSettingsSchema();
|
|
7271
7874
|
if (!schema) return { sections: [] };
|
|
7272
|
-
return hydrateSchema(schema, await this._ctx?.settings?.readDeviceStore(deviceId) ?? {});
|
|
7875
|
+
return hydrateSchema(schema, await this._ctx?.settings?.readDeviceStore(deviceId) ?? {}, { inlineSecretsAsViews: true });
|
|
7273
7876
|
}
|
|
7274
7877
|
async updateDeviceSettings(deviceId, patch) {
|
|
7275
7878
|
await this._ctx?.settings?.writeDeviceStore(deviceId, patch);
|
|
@@ -7399,7 +8002,7 @@ var BaseAddon = class {
|
|
|
7399
8002
|
* selection at boot (absent scoped key ⇒ the constructor default wins).
|
|
7400
8003
|
*/
|
|
7401
8004
|
async resolveConfig() {
|
|
7402
|
-
const stored = await this.readAddonStoreWithRetry();
|
|
8005
|
+
const stored = await this.resolveStoredSecrets(await this.readAddonStoreWithRetry());
|
|
7403
8006
|
const perNode = this.perNodeKeys();
|
|
7404
8007
|
const localNode = normalizeNodeId(this._ctx?.kernel?.localNodeId);
|
|
7405
8008
|
const resolved = { ...this.defaults };
|
|
@@ -7424,7 +8027,7 @@ var BaseAddon = class {
|
|
|
7424
8027
|
key,
|
|
7425
8028
|
schema,
|
|
7426
8029
|
fallback,
|
|
7427
|
-
read: () => this.readAddonStoreWithRetry(),
|
|
8030
|
+
read: async () => this.resolveStoredSecrets(await this.readAddonStoreWithRetry()),
|
|
7428
8031
|
write: async (patch) => {
|
|
7429
8032
|
await this._ctx?.settings?.writeAddonStore(patch);
|
|
7430
8033
|
},
|
|
@@ -7441,7 +8044,7 @@ var BaseAddon = class {
|
|
|
7441
8044
|
key,
|
|
7442
8045
|
schema,
|
|
7443
8046
|
fallback,
|
|
7444
|
-
read: async () => await this._ctx?.settings?.readDeviceStore(deviceId) ?? {},
|
|
8047
|
+
read: async () => this.resolveStoredSecrets(await this._ctx?.settings?.readDeviceStore(deviceId) ?? {}, false),
|
|
7445
8048
|
write: async (patch) => {
|
|
7446
8049
|
await this._ctx?.settings?.writeDeviceStore(deviceId, patch);
|
|
7447
8050
|
},
|
|
@@ -7453,6 +8056,70 @@ var BaseAddon = class {
|
|
|
7453
8056
|
} })
|
|
7454
8057
|
});
|
|
7455
8058
|
}
|
|
8059
|
+
/** The addon store's secret tree: schema fields by TYPE, plus `secretStatePaths`. */
|
|
8060
|
+
addonSecretTree() {
|
|
8061
|
+
this._addonSecretTree ??= mergeSecretStatePaths(secretTreeFromSchema(this.globalSettingsSchema()), this.secretStatePaths);
|
|
8062
|
+
return this._addonSecretTree;
|
|
8063
|
+
}
|
|
8064
|
+
deviceSecretTree() {
|
|
8065
|
+
this._deviceSecretTree ??= secretTreeFromSchema(this.deviceSettingsSchema());
|
|
8066
|
+
return this._deviceSecretTree;
|
|
8067
|
+
}
|
|
8068
|
+
/**
|
|
8069
|
+
* Secrets of this addon's stored config that could not be resolved on the
|
|
8070
|
+
* last read, with why. Non-empty means the addon is running WITHOUT them —
|
|
8071
|
+
* an addon whose function needs one should report itself degraded rather
|
|
8072
|
+
* than start on an empty credential.
|
|
8073
|
+
*/
|
|
8074
|
+
get unresolvedSecrets() {
|
|
8075
|
+
return this._unresolvedSecrets;
|
|
8076
|
+
}
|
|
8077
|
+
/**
|
|
8078
|
+
* Substitute every keychain marker in a stored blob with its value. With no
|
|
8079
|
+
* keychain (no `ctx.secrets`) or no marker, the blob comes back unchanged.
|
|
8080
|
+
* An unresolvable value is LEFT OUT (never `''`), logged by ref — never by
|
|
8081
|
+
* value — and, when the cause can pass, retried with backoff. Nothing is
|
|
8082
|
+
* ever written back from here.
|
|
8083
|
+
*/
|
|
8084
|
+
async resolveStoredSecrets(blob, trackForConfig = true) {
|
|
8085
|
+
const secrets = this._ctx?.secrets;
|
|
8086
|
+
if (secrets === void 0) return blob;
|
|
8087
|
+
const refs = collectSecretMarkerRefs(blob);
|
|
8088
|
+
if (trackForConfig) this._configSecretRefs = new Set(refs);
|
|
8089
|
+
if (refs.length === 0) {
|
|
8090
|
+
if (trackForConfig) this._unresolvedSecrets = [];
|
|
8091
|
+
return blob;
|
|
8092
|
+
}
|
|
8093
|
+
const { value, unresolved } = await resolveSecretMarkers(blob, secrets);
|
|
8094
|
+
if (trackForConfig) {
|
|
8095
|
+
this._unresolvedSecrets = unresolved;
|
|
8096
|
+
if (unresolved.length > 0) {
|
|
8097
|
+
this._ctx?.logger?.error?.("secret unavailable — running without it, will retry", { meta: { secrets: unresolved.map((u) => ({
|
|
8098
|
+
ref: u.ref,
|
|
8099
|
+
reason: u.reason
|
|
8100
|
+
})) } });
|
|
8101
|
+
if (unresolved.some((u) => u.reason !== "missing" && u.reason !== "forbidden")) {
|
|
8102
|
+
this.scheduleSecretReresolve(this._secretRetryDelayMs);
|
|
8103
|
+
this._secretRetryDelayMs = Math.min(this._secretRetryDelayMs * 2, SECRET_RETRY_MAX_MS);
|
|
8104
|
+
}
|
|
8105
|
+
} else this._secretRetryDelayMs = SECRET_RETRY_FIRST_MS;
|
|
8106
|
+
}
|
|
8107
|
+
return value;
|
|
8108
|
+
}
|
|
8109
|
+
/** Re-resolve the config (a keychain-only change, or a retry) and apply it. */
|
|
8110
|
+
scheduleSecretReresolve(delayMs) {
|
|
8111
|
+
const timerOf = delayMs === SECRET_CHANGE_DEBOUNCE_MS ? "_secretChangeTimer" : "_secretRetryTimer";
|
|
8112
|
+
if (this[timerOf] !== null) return;
|
|
8113
|
+
const timer = setTimeout(() => {
|
|
8114
|
+
this[timerOf] = null;
|
|
8115
|
+
if (this._ctx === null) return;
|
|
8116
|
+
this.resolveConfig().then(() => this.onConfigChanged()).catch((err) => {
|
|
8117
|
+
this._ctx?.logger?.error?.("re-resolving secrets failed", { meta: { error: err instanceof Error ? err.message : String(err) } });
|
|
8118
|
+
});
|
|
8119
|
+
}, delayMs);
|
|
8120
|
+
timer.unref?.();
|
|
8121
|
+
this[timerOf] = timer;
|
|
8122
|
+
}
|
|
7456
8123
|
/**
|
|
7457
8124
|
* Wrap `ctx.settings.readAddonStore()` with a short retry budget so a
|
|
7458
8125
|
* transient settings-store outage (mid-restart of sqlite-settings, tsx-watch
|
|
@@ -8028,6 +8695,69 @@ method(object({ deviceId: number() }), array(StreamSourceEntrySchema)), method(o
|
|
|
8028
8695
|
kind: "mutation",
|
|
8029
8696
|
auth: "admin"
|
|
8030
8697
|
}), method(object({ deviceId: number() }), unknown().nullable()), method(object({ deviceId: number() }), RawStateResultSchema.nullable(), { auth: "protected" });
|
|
8698
|
+
function defOf(schema) {
|
|
8699
|
+
return schema._zod?.def ?? {};
|
|
8700
|
+
}
|
|
8701
|
+
function declaredHere(schema) {
|
|
8702
|
+
return globalRegistry.get(schema)?.secret === true;
|
|
8703
|
+
}
|
|
8704
|
+
/** Wrapper kinds whose `innerType` is the field itself. */
|
|
8705
|
+
var WRAPPERS = new Set([
|
|
8706
|
+
"optional",
|
|
8707
|
+
"nullable",
|
|
8708
|
+
"default",
|
|
8709
|
+
"prefault",
|
|
8710
|
+
"catch",
|
|
8711
|
+
"readonly",
|
|
8712
|
+
"nonoptional"
|
|
8713
|
+
]);
|
|
8714
|
+
/**
|
|
8715
|
+
* The schema layers that make up ONE field: the schema itself and every
|
|
8716
|
+
* wrapper below it (optional / default / nullable / readonly / catch), plus
|
|
8717
|
+
* both sides of a pipe (`z.preprocess` puts the real schema on `out`,
|
|
8718
|
+
* `.transform` on `in`).
|
|
8719
|
+
*/
|
|
8720
|
+
function layersOf(schema) {
|
|
8721
|
+
const out = [];
|
|
8722
|
+
const queue = [schema];
|
|
8723
|
+
while (queue.length > 0) {
|
|
8724
|
+
const s = queue.shift();
|
|
8725
|
+
if (!s || out.includes(s)) continue;
|
|
8726
|
+
out.push(s);
|
|
8727
|
+
const def = defOf(s);
|
|
8728
|
+
if (def.type !== void 0 && WRAPPERS.has(def.type) && def.innerType) queue.push(def.innerType);
|
|
8729
|
+
if (def.type === "pipe") {
|
|
8730
|
+
if (def.in) queue.push(def.in);
|
|
8731
|
+
if (def.out) queue.push(def.out);
|
|
8732
|
+
}
|
|
8733
|
+
}
|
|
8734
|
+
return out;
|
|
8735
|
+
}
|
|
8736
|
+
/** True when any layer of this field declares `.meta({ secret: true })`. */
|
|
8737
|
+
function isZodSecret(schema) {
|
|
8738
|
+
return layersOf(schema).some(declaredHere);
|
|
8739
|
+
}
|
|
8740
|
+
/**
|
|
8741
|
+
* Every declared secret path in a config schema: dotted keys, `[]` for "each
|
|
8742
|
+
* element of this array" (`connection.password`, `rows[].token`). A declared
|
|
8743
|
+
* object or array is reported as one path and not descended into — everything
|
|
8744
|
+
* under it is secret.
|
|
8745
|
+
*/
|
|
8746
|
+
function collectZodSecretPaths(schema, prefix = "") {
|
|
8747
|
+
if (isZodSecret(schema)) return prefix.length > 0 ? [prefix] : [];
|
|
8748
|
+
const paths = [];
|
|
8749
|
+
for (const layer of layersOf(schema)) {
|
|
8750
|
+
const def = defOf(layer);
|
|
8751
|
+
if (def.type === "object" && def.shape) for (const [key, child] of Object.entries(def.shape)) paths.push(...collectZodSecretPaths(child, prefix ? `${prefix}.${key}` : key));
|
|
8752
|
+
else if (def.type === "array" && def.element) paths.push(...collectZodSecretPaths(def.element, `${prefix}[]`));
|
|
8753
|
+
else if (def.type === "union" && def.options) for (const option of def.options) paths.push(...collectZodSecretPaths(option, prefix));
|
|
8754
|
+
else if (def.type === "intersection") {
|
|
8755
|
+
if (def.left) paths.push(...collectZodSecretPaths(def.left, prefix));
|
|
8756
|
+
if (def.right) paths.push(...collectZodSecretPaths(def.right, prefix));
|
|
8757
|
+
}
|
|
8758
|
+
}
|
|
8759
|
+
return [...new Set(paths)];
|
|
8760
|
+
}
|
|
8031
8761
|
//#endregion
|
|
8032
8762
|
//#region ../types/dist/err-msg-DX6i_MY4.mjs
|
|
8033
8763
|
var DeviceType = /* @__PURE__ */ function(DeviceType) {
|
|
@@ -15058,6 +15788,196 @@ id: union([string(), number()]) }), {
|
|
|
15058
15788
|
kind: "mutation",
|
|
15059
15789
|
auth: "admin"
|
|
15060
15790
|
});
|
|
15791
|
+
/**
|
|
15792
|
+
* `keychain` — the hub's encrypted store of secret values (D787).
|
|
15793
|
+
*
|
|
15794
|
+
* Settings blobs never hold a secret: they hold a marker
|
|
15795
|
+
* `{"$secret":"secret://<owner>/<scope>/<fieldPath>","v":1}` and the value
|
|
15796
|
+
* lives here, AES-256-GCM under a data key that a master key wraps. This cap
|
|
15797
|
+
* is the OWNER's door to its own values: every method is owner-checked
|
|
15798
|
+
* against the CALLER, never against anything the caller claims.
|
|
15799
|
+
*
|
|
15800
|
+
* Who the caller is: the transport stamps `callerAddonId` into the args of a
|
|
15801
|
+
* call that crossed a process (the parent `LocalChildRegistry` from the UDS
|
|
15802
|
+
* connection, the agent from its child's connection carried in
|
|
15803
|
+
* `$hub-cap-fwd`'s envelope). A stamp always overwrites; a wire call with no
|
|
15804
|
+
* stamp has its claim stripped. Only a hub in-process caller may state its own
|
|
15805
|
+
* identity — `ctx.secrets` does that with the addon id closed over. This is
|
|
15806
|
+
* identity against BUGS and misrouting, not against a malicious addon (every
|
|
15807
|
+
* runner is the same OS user): see the threat model in
|
|
15808
|
+
* `docs/design/2026-10-08-secrets-keychain.md`.
|
|
15809
|
+
*
|
|
15810
|
+
* `callerAddonId` is deliberately NOT in any input schema: the tRPC router
|
|
15811
|
+
* parses the input, so a session can never supply it, and the internal mount
|
|
15812
|
+
* floors every method to admin anyway (D240).
|
|
15813
|
+
*
|
|
15814
|
+
* Internal: addons reach it through `ctx.secrets`, never directly.
|
|
15815
|
+
*/
|
|
15816
|
+
/** Why a value cannot be served right now. Never folded into "missing". */
|
|
15817
|
+
var KeychainUnavailableReasonSchema = _enum([
|
|
15818
|
+
"key-missing",
|
|
15819
|
+
"wrong-key",
|
|
15820
|
+
"key-file-unreadable",
|
|
15821
|
+
"store-unavailable",
|
|
15822
|
+
"not-initialized",
|
|
15823
|
+
"decrypt-failed"
|
|
15824
|
+
]);
|
|
15825
|
+
var KeychainStateSchema = discriminatedUnion("state", [object({ state: literal("ready") }), object({
|
|
15826
|
+
state: literal("locked"),
|
|
15827
|
+
reason: KeychainUnavailableReasonSchema
|
|
15828
|
+
})]);
|
|
15829
|
+
var KeychainResolveEntrySchema = discriminatedUnion("kind", [
|
|
15830
|
+
object({
|
|
15831
|
+
kind: literal("value"),
|
|
15832
|
+
value: string(),
|
|
15833
|
+
version: number().int()
|
|
15834
|
+
}),
|
|
15835
|
+
object({ kind: literal("missing") }),
|
|
15836
|
+
object({
|
|
15837
|
+
kind: literal("unavailable"),
|
|
15838
|
+
reason: KeychainUnavailableReasonSchema
|
|
15839
|
+
}),
|
|
15840
|
+
object({ kind: literal("forbidden") })
|
|
15841
|
+
]);
|
|
15842
|
+
var KeychainResolveResultSchema = record(string(), KeychainResolveEntrySchema);
|
|
15843
|
+
/** Metadata of one stored value — never the value. */
|
|
15844
|
+
var KeychainSecretMetaSchema = object({
|
|
15845
|
+
ref: string(),
|
|
15846
|
+
owner: string(),
|
|
15847
|
+
/** Formatted scope (`global`, `node/<id>`, `device/<id>`, …). */
|
|
15848
|
+
scope: string(),
|
|
15849
|
+
fieldPath: string(),
|
|
15850
|
+
version: number().int(),
|
|
15851
|
+
createdAt: number(),
|
|
15852
|
+
updatedAt: number(),
|
|
15853
|
+
/** `addon:<id>` | `user:<id>` | `system`. */
|
|
15854
|
+
updatedBy: string(),
|
|
15855
|
+
/** Coarse — written at most once an hour per ref. `null` = never read. */
|
|
15856
|
+
lastReadAt: number().nullable()
|
|
15857
|
+
});
|
|
15858
|
+
var RefListSchema = array(string().min(1)).max(512);
|
|
15859
|
+
method(object({
|
|
15860
|
+
ref: string().min(1),
|
|
15861
|
+
value: string().min(1)
|
|
15862
|
+
}), object({
|
|
15863
|
+
ref: string(),
|
|
15864
|
+
version: number().int()
|
|
15865
|
+
}), {
|
|
15866
|
+
kind: "mutation",
|
|
15867
|
+
auth: "admin"
|
|
15868
|
+
}), method(object({ refs: RefListSchema }), KeychainResolveResultSchema, { auth: "admin" }), method(object({ refs: RefListSchema }), object({ deleted: number().int() }), {
|
|
15869
|
+
kind: "mutation",
|
|
15870
|
+
auth: "admin"
|
|
15871
|
+
}), method(object({}), array(KeychainSecretMetaSchema).readonly(), { auth: "admin" }), method(object({}), KeychainStateSchema, { auth: "admin" });
|
|
15872
|
+
var KeychainKeySourceSchema = object({
|
|
15873
|
+
kind: _enum([
|
|
15874
|
+
"config-file",
|
|
15875
|
+
"previous-config-file",
|
|
15876
|
+
"platform",
|
|
15877
|
+
"default-file"
|
|
15878
|
+
]),
|
|
15879
|
+
/** File sources only — a path is not a secret. */
|
|
15880
|
+
path: string().optional(),
|
|
15881
|
+
/**
|
|
15882
|
+
* True when a whole-volume backup of the data directory carries this key
|
|
15883
|
+
* next to the database it protects (the default file). The page warns.
|
|
15884
|
+
*/
|
|
15885
|
+
sharesBackupWithDatabase: boolean()
|
|
15886
|
+
});
|
|
15887
|
+
var KeychainStatusSchema = object({
|
|
15888
|
+
keychain: KeychainStateSchema,
|
|
15889
|
+
/** The source of the master key in use; `null` while locked. */
|
|
15890
|
+
keySource: KeychainKeySourceSchema.nullable(),
|
|
15891
|
+
/** The source configured to be primary — differs from `keySource` while a rotation is pending. */
|
|
15892
|
+
configuredSource: KeychainKeySourceSchema,
|
|
15893
|
+
/** Short fingerprint of the master key in use (`HMAC(KEK, label)`, 16 hex). */
|
|
15894
|
+
fingerprint: string().nullable(),
|
|
15895
|
+
activeKeyId: string().nullable(),
|
|
15896
|
+
/**
|
|
15897
|
+
* The keychain unlocked with a NON-primary source: the configured primary
|
|
15898
|
+
* key is not the one that wraps the data key yet. `rotateMasterKey` moves it.
|
|
15899
|
+
*/
|
|
15900
|
+
rotationPending: boolean(),
|
|
15901
|
+
/** Wrapped copies of the data key under a previous master key, kept until purged. */
|
|
15902
|
+
retiredWraps: number().int(),
|
|
15903
|
+
recoveryKeyDownloadedAt: number().nullable(),
|
|
15904
|
+
secretCount: number().int()
|
|
15905
|
+
});
|
|
15906
|
+
/**
|
|
15907
|
+
* Whether a stored value is still pointed at by its owner's settings.
|
|
15908
|
+
* `unknown` is a first-class answer: a scope whose blob could not be read is
|
|
15909
|
+
* never reported as an orphan (and never deleted as one).
|
|
15910
|
+
*/
|
|
15911
|
+
var KeychainSecretUsageSchema = _enum([
|
|
15912
|
+
"in-use",
|
|
15913
|
+
"orphan",
|
|
15914
|
+
"unknown"
|
|
15915
|
+
]);
|
|
15916
|
+
var KeychainAdminSecretSchema = KeychainSecretMetaSchema.extend({ usage: KeychainSecretUsageSchema });
|
|
15917
|
+
var KeychainAuditActionSchema = _enum([
|
|
15918
|
+
"put",
|
|
15919
|
+
"delete",
|
|
15920
|
+
"reveal",
|
|
15921
|
+
"rotate-master-key",
|
|
15922
|
+
"purge-retired-keys",
|
|
15923
|
+
"download-recovery-key",
|
|
15924
|
+
"delete-orphans",
|
|
15925
|
+
"reset",
|
|
15926
|
+
"initialize"
|
|
15927
|
+
]);
|
|
15928
|
+
var KeychainAuditEntrySchema = object({
|
|
15929
|
+
id: string(),
|
|
15930
|
+
at: number(),
|
|
15931
|
+
action: KeychainAuditActionSchema,
|
|
15932
|
+
/** `addon:<id>` | `user:<id>` | `system`. */
|
|
15933
|
+
actor: string(),
|
|
15934
|
+
ref: string().nullable(),
|
|
15935
|
+
detail: string().nullable()
|
|
15936
|
+
});
|
|
15937
|
+
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({
|
|
15938
|
+
value: string(),
|
|
15939
|
+
version: number().int()
|
|
15940
|
+
}), {
|
|
15941
|
+
kind: "mutation",
|
|
15942
|
+
auth: "admin",
|
|
15943
|
+
caller: "required"
|
|
15944
|
+
}), method(object({ refs: array(string().min(1)).max(1e3) }), object({
|
|
15945
|
+
deleted: array(string()).readonly(),
|
|
15946
|
+
kept: array(object({
|
|
15947
|
+
ref: string(),
|
|
15948
|
+
usage: KeychainSecretUsageSchema
|
|
15949
|
+
})).readonly()
|
|
15950
|
+
}), {
|
|
15951
|
+
kind: "mutation",
|
|
15952
|
+
auth: "admin",
|
|
15953
|
+
caller: "required"
|
|
15954
|
+
}), method(object({}), object({
|
|
15955
|
+
fingerprint: string(),
|
|
15956
|
+
keySource: KeychainKeySourceSchema
|
|
15957
|
+
}), {
|
|
15958
|
+
kind: "mutation",
|
|
15959
|
+
auth: "admin",
|
|
15960
|
+
caller: "required"
|
|
15961
|
+
}), method(object({}), object({ purged: number().int() }), {
|
|
15962
|
+
kind: "mutation",
|
|
15963
|
+
auth: "admin",
|
|
15964
|
+
caller: "required"
|
|
15965
|
+
}), method(object({}), object({
|
|
15966
|
+
key: string(),
|
|
15967
|
+
fingerprint: string(),
|
|
15968
|
+
keySource: KeychainKeySourceSchema
|
|
15969
|
+
}), {
|
|
15970
|
+
kind: "mutation",
|
|
15971
|
+
auth: "admin",
|
|
15972
|
+
caller: "required"
|
|
15973
|
+
}), method(object({ confirm: literal("RESET KEYCHAIN") }), object({
|
|
15974
|
+
archivedCollection: string().nullable(),
|
|
15975
|
+
archived: number().int()
|
|
15976
|
+
}), {
|
|
15977
|
+
kind: "mutation",
|
|
15978
|
+
auth: "admin",
|
|
15979
|
+
caller: "required"
|
|
15980
|
+
});
|
|
15061
15981
|
method(_void(), object({
|
|
15062
15982
|
id: string(),
|
|
15063
15983
|
name: string(),
|
|
@@ -16396,7 +17316,11 @@ var DeviceRegisterPayloadSchema = object({
|
|
|
16396
17316
|
var DeviceRemovePayloadSchema = object({ deviceId: number() });
|
|
16397
17317
|
var DevicePersistConfigPayloadSchema = object({
|
|
16398
17318
|
deviceId: number(),
|
|
16399
|
-
data: record(string(), unknown())
|
|
17319
|
+
data: record(string(), unknown()),
|
|
17320
|
+
/** The paths the device's schema declares secret (D783), when the caller
|
|
17321
|
+
* knows them — those values are kept in the keychain, not the blob (D787).
|
|
17322
|
+
* Absent: the paths the device last reported at `registerDevice` apply. */
|
|
17323
|
+
secretConfigPaths: array(string()).optional()
|
|
16400
17324
|
});
|
|
16401
17325
|
/** What a migration actually did, per switch. `unreachable` is a first-class
|
|
16402
17326
|
* answer: a camera that could not be asked is not a camera that was silenced. */
|
|
@@ -23413,8 +24337,23 @@ var RetrainMacroClassSchema = _enum([
|
|
|
23413
24337
|
]);
|
|
23414
24338
|
/** A subject to learn, or a phantom to unlearn (taught by OMISSION). */
|
|
23415
24339
|
var RetrainAnnotationKindSchema = _enum(["subject", "model_error"]);
|
|
23416
|
-
/**
|
|
23417
|
-
|
|
24340
|
+
/**
|
|
24341
|
+
* Where a box came from. A machine-sourced box is a DRAFT on the page until
|
|
24342
|
+
* the operator confirms it; once saved it keeps its source as provenance.
|
|
24343
|
+
*
|
|
24344
|
+
* - `operator` — drawn by hand.
|
|
24345
|
+
* - `assist` — proposed by a detector run on the copy (the camera's own
|
|
24346
|
+
* model, or a larger teacher model).
|
|
24347
|
+
* - `pipeline` — the box the live pipeline actually drew on that frame, read
|
|
24348
|
+
* back from the track store (never a re-run).
|
|
24349
|
+
* - `llm` — proposed by a vision-capable LLM profile.
|
|
24350
|
+
*/
|
|
24351
|
+
var RetrainAnnotationSourceSchema = _enum([
|
|
24352
|
+
"operator",
|
|
24353
|
+
"assist",
|
|
24354
|
+
"pipeline",
|
|
24355
|
+
"llm"
|
|
24356
|
+
]);
|
|
23418
24357
|
/** Normalised `[0,1]` rectangle against the FULL frame — the canonical form. */
|
|
23419
24358
|
var RetrainBboxSchema = object({
|
|
23420
24359
|
x: number(),
|
|
@@ -23432,7 +24371,8 @@ var RetrainBboxSchema = object({
|
|
|
23432
24371
|
*/
|
|
23433
24372
|
var RetrainAnnotationSchema = object({
|
|
23434
24373
|
id: string(),
|
|
23435
|
-
|
|
24374
|
+
/** The frame's track. Absent on a recording still, which has none. */
|
|
24375
|
+
trackId: string().optional(),
|
|
23436
24376
|
deviceId: number(),
|
|
23437
24377
|
/** The COPY in retrain storage — never the source track's media key. */
|
|
23438
24378
|
mediaKey: string(),
|
|
@@ -23481,13 +24421,47 @@ var RetrainFrameCandidateSchema = object({
|
|
|
23481
24421
|
* fail, whatever became of the original. */
|
|
23482
24422
|
copied: boolean()
|
|
23483
24423
|
});
|
|
24424
|
+
/**
|
|
24425
|
+
* One box the live pipeline drew on a copied frame — what a correction starts
|
|
24426
|
+
* from. Derived when the frame is listed, from the track store: the subject
|
|
24427
|
+
* box recorded on the source media row when there is one, else the track
|
|
24428
|
+
* position nearest the frame's capture time. Never stored as an annotation
|
|
24429
|
+
* until the operator confirms it.
|
|
24430
|
+
*/
|
|
24431
|
+
var RetrainPipelineBoxSchema = object({
|
|
24432
|
+
/** Normalised `[0,1]` against the full frame. */
|
|
24433
|
+
bbox: RetrainBboxSchema,
|
|
24434
|
+
macroClass: RetrainMacroClassSchema,
|
|
24435
|
+
label: string().optional(),
|
|
24436
|
+
subLabel: string().optional(),
|
|
24437
|
+
/** The detection score of the position used, when it was recorded. */
|
|
24438
|
+
score: number().optional(),
|
|
24439
|
+
/** The root model that produced the track, when it was recorded. */
|
|
24440
|
+
modelId: string().optional(),
|
|
24441
|
+
trackId: string(),
|
|
24442
|
+
/** `subject-box`: recorded on this very frame. `position`: the track's
|
|
24443
|
+
* position nearest the capture time, `deltaMs` away. */
|
|
24444
|
+
basis: _enum(["subject-box", "position"]),
|
|
24445
|
+
deltaMs: number()
|
|
24446
|
+
});
|
|
24447
|
+
/**
|
|
24448
|
+
* Where a retrain frame came from: a TRACK's stored media (copy-on-select),
|
|
24449
|
+
* or the RECORDING at an instant — the frame a model saw nothing in has no
|
|
24450
|
+
* track at all.
|
|
24451
|
+
*/
|
|
24452
|
+
var RetrainFrameOriginSchema = _enum(["track", "recording"]);
|
|
23484
24453
|
/** A frame the dataset OWNS: bytes copied at selection time. */
|
|
23485
24454
|
var RetrainFrameSchema = object({
|
|
23486
24455
|
frameId: string(),
|
|
23487
24456
|
deviceId: number(),
|
|
23488
|
-
|
|
23489
|
-
/**
|
|
23490
|
-
|
|
24457
|
+
origin: RetrainFrameOriginSchema,
|
|
24458
|
+
/** The track it was copied from. Absent on a recording still. */
|
|
24459
|
+
trackId: string().optional(),
|
|
24460
|
+
/** Provenance only. It may already point at nothing — that is expected.
|
|
24461
|
+
* Absent on a recording still. */
|
|
24462
|
+
sourceMediaId: number().int().optional(),
|
|
24463
|
+
/** A recording still: the playhead instant it was taken at. */
|
|
24464
|
+
epochMs: number().optional(),
|
|
23491
24465
|
sourceKind: MediaFileKindEnum,
|
|
23492
24466
|
sizeBytes: number().int(),
|
|
23493
24467
|
width: number().int(),
|
|
@@ -23498,7 +24472,12 @@ var RetrainFrameSchema = object({
|
|
|
23498
24472
|
/** The operator's "every subject in this frame is boxed". Detector
|
|
23499
24473
|
* evaluation keeps only complete frames: an unboxed subject would count as
|
|
23500
24474
|
* a false positive. */
|
|
23501
|
-
complete: boolean()
|
|
24475
|
+
complete: boolean(),
|
|
24476
|
+
/** The boxes the pipeline drew on this frame. Present on list answers;
|
|
24477
|
+
* empty when nothing the track store holds can be placed on it. */
|
|
24478
|
+
pipelineBoxes: array(RetrainPipelineBoxSchema).readonly().optional(),
|
|
24479
|
+
/** The named collections this frame belongs to. Present on list answers. */
|
|
24480
|
+
collectionIds: array(string()).readonly().optional()
|
|
23502
24481
|
});
|
|
23503
24482
|
/** Why a copy-on-select could not be honoured — named, never a silent skip. */
|
|
23504
24483
|
var RetrainCopyRefusalSchema = _enum([
|
|
@@ -23529,6 +24508,8 @@ var RetrainFrameListSchema = object({
|
|
|
23529
24508
|
var RetrainExportFilterSchema = object({
|
|
23530
24509
|
deviceIds: array(number()).optional(),
|
|
23531
24510
|
frameIds: array(string()).max(2e4).optional(),
|
|
24511
|
+
/** Only frames in at least one of these named collections. */
|
|
24512
|
+
collectionIds: array(string()).max(200).optional(),
|
|
23532
24513
|
batchId: string().optional(),
|
|
23533
24514
|
/** Only frames the operator marked complete (all subjects boxed). */
|
|
23534
24515
|
completeOnly: boolean().optional()
|
|
@@ -23593,6 +24574,109 @@ var RetrainAssistResultSchema = discriminatedUnion("kind", [object({
|
|
|
23593
24574
|
reason: string(),
|
|
23594
24575
|
detail: string().optional()
|
|
23595
24576
|
})]);
|
|
24577
|
+
/** A named set over the retrain corpus — membership only, it owns no pixels. */
|
|
24578
|
+
var RetrainCollectionSchema = object({
|
|
24579
|
+
id: string(),
|
|
24580
|
+
name: string(),
|
|
24581
|
+
createdAt: number(),
|
|
24582
|
+
frameCount: number().int()
|
|
24583
|
+
});
|
|
24584
|
+
var RetrainCollectionCreateResultSchema = discriminatedUnion("kind", [object({
|
|
24585
|
+
kind: literal("created"),
|
|
24586
|
+
collection: RetrainCollectionSchema
|
|
24587
|
+
}), object({
|
|
24588
|
+
kind: literal("refused"),
|
|
24589
|
+
reason: _enum(["empty-name", "duplicate-name"])
|
|
24590
|
+
})]);
|
|
24591
|
+
var RetrainCollectionRenameResultSchema = discriminatedUnion("kind", [object({
|
|
24592
|
+
kind: literal("renamed"),
|
|
24593
|
+
collection: RetrainCollectionSchema
|
|
24594
|
+
}), object({
|
|
24595
|
+
kind: literal("refused"),
|
|
24596
|
+
reason: _enum([
|
|
24597
|
+
"empty-name",
|
|
24598
|
+
"duplicate-name",
|
|
24599
|
+
"unknown-collection"
|
|
24600
|
+
])
|
|
24601
|
+
})]);
|
|
24602
|
+
/**
|
|
24603
|
+
* The outcome of adding the frame at a recording instant. Every refusal is
|
|
24604
|
+
* named: `still-unavailable` (not recording, a gap, or an undecodable frame —
|
|
24605
|
+
* `detail` says which), `still-busy` (the recorder is at its decode bound; try
|
|
24606
|
+
* again), `unreadable-image`, `write-failed`, `unknown-collection`.
|
|
24607
|
+
*/
|
|
24608
|
+
var AddRetrainFrameFromRecordingResultSchema = discriminatedUnion("kind", [object({
|
|
24609
|
+
kind: literal("added"),
|
|
24610
|
+
collectionId: string(),
|
|
24611
|
+
frame: RetrainFrameSchema,
|
|
24612
|
+
/** The moment was already in the dataset; nothing was decoded. */
|
|
24613
|
+
reused: boolean()
|
|
24614
|
+
}), object({
|
|
24615
|
+
kind: literal("refused"),
|
|
24616
|
+
reason: _enum([
|
|
24617
|
+
"unknown-collection",
|
|
24618
|
+
"still-unavailable",
|
|
24619
|
+
"still-busy",
|
|
24620
|
+
"unreadable-image",
|
|
24621
|
+
"write-failed"
|
|
24622
|
+
]),
|
|
24623
|
+
detail: string().optional()
|
|
24624
|
+
})]);
|
|
24625
|
+
/** A vision LLM profile the AI assist may use, and where it sends the frame. */
|
|
24626
|
+
var RetrainAssistProfileSchema = object({
|
|
24627
|
+
id: string(),
|
|
24628
|
+
name: string(),
|
|
24629
|
+
model: string(),
|
|
24630
|
+
kind: string(),
|
|
24631
|
+
/** `true` when the frame would leave the house (a cloud vendor, or an
|
|
24632
|
+
* endpoint that is not on the local network). The page confirms each such
|
|
24633
|
+
* run, and the provider refuses one without `allowCloud`. */
|
|
24634
|
+
leavesHouse: boolean()
|
|
24635
|
+
});
|
|
24636
|
+
/** A box the AI assist proposed: a draft, plus the model's own reason. */
|
|
24637
|
+
var RetrainLlmProposalSchema = RetrainAnnotationDraftSchema.extend({ reason: string() });
|
|
24638
|
+
/** What the AI assist said about a box that was already on the canvas. */
|
|
24639
|
+
var RetrainLlmReviewSchema = object({
|
|
24640
|
+
/** The `ref` the page sent the box under. */
|
|
24641
|
+
ref: string(),
|
|
24642
|
+
verdict: _enum([
|
|
24643
|
+
"confirmed",
|
|
24644
|
+
"wrong-class",
|
|
24645
|
+
"not-an-object",
|
|
24646
|
+
"uncertain"
|
|
24647
|
+
]),
|
|
24648
|
+
suggestedClass: RetrainMacroClassSchema.optional(),
|
|
24649
|
+
reason: string()
|
|
24650
|
+
});
|
|
24651
|
+
/**
|
|
24652
|
+
* The AI assist's answer. `proposed` carries drafts (`source: 'llm'`, the
|
|
24653
|
+
* model and its confidence) and reviews; items the model got wrong (a box off
|
|
24654
|
+
* the frame, an unasked class, an unknown ref) are dropped and counted in
|
|
24655
|
+
* `rejected`. A whole answer that is not the schema is `malformed-answer`.
|
|
24656
|
+
*/
|
|
24657
|
+
var RetrainLlmAssistResultSchema = discriminatedUnion("kind", [object({
|
|
24658
|
+
kind: literal("proposed"),
|
|
24659
|
+
profileId: string(),
|
|
24660
|
+
model: string(),
|
|
24661
|
+
/** The frame was sent outside the house for this answer. */
|
|
24662
|
+
leftHouse: boolean(),
|
|
24663
|
+
proposals: array(RetrainLlmProposalSchema).readonly(),
|
|
24664
|
+
reviews: array(RetrainLlmReviewSchema).readonly(),
|
|
24665
|
+
rejected: number().int()
|
|
24666
|
+
}), object({
|
|
24667
|
+
kind: literal("refused"),
|
|
24668
|
+
reason: _enum([
|
|
24669
|
+
"unknown-frame",
|
|
24670
|
+
"unreadable-frame",
|
|
24671
|
+
"unknown-profile",
|
|
24672
|
+
"profile-disabled",
|
|
24673
|
+
"no-vision",
|
|
24674
|
+
"cloud-not-confirmed",
|
|
24675
|
+
"llm-error",
|
|
24676
|
+
"malformed-answer"
|
|
24677
|
+
]),
|
|
24678
|
+
detail: string().optional()
|
|
24679
|
+
})]);
|
|
23596
24680
|
/** The outcome of a lifecycle move owned by the retrain page. */
|
|
23597
24681
|
var RetrainTransitionResultSchema = object({
|
|
23598
24682
|
trackId: string(),
|
|
@@ -24310,7 +25394,7 @@ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).rea
|
|
|
24310
25394
|
auth: "admin"
|
|
24311
25395
|
}), method(object({
|
|
24312
25396
|
deviceId: number(),
|
|
24313
|
-
trackId: string(),
|
|
25397
|
+
trackId: string().optional(),
|
|
24314
25398
|
frameId: string()
|
|
24315
25399
|
}), object({
|
|
24316
25400
|
removed: boolean(),
|
|
@@ -24327,7 +25411,8 @@ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).rea
|
|
|
24327
25411
|
auth: "admin"
|
|
24328
25412
|
}), method(object({
|
|
24329
25413
|
deviceId: number(),
|
|
24330
|
-
|
|
25414
|
+
/** The frame's track, when it has one — checked against the frame. */
|
|
25415
|
+
trackId: string().optional(),
|
|
24331
25416
|
frameId: string(),
|
|
24332
25417
|
subject: RetrainAssistSubjectSchema,
|
|
24333
25418
|
/** Which node runs it. Absent ⇒ wherever an unowned call lands. */
|
|
@@ -24335,12 +25420,16 @@ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).rea
|
|
|
24335
25420
|
}), RetrainAssistResultSchema, {
|
|
24336
25421
|
kind: "mutation",
|
|
24337
25422
|
auth: "admin"
|
|
24338
|
-
}), method(object({
|
|
25423
|
+
}), method(object({
|
|
25424
|
+
trackId: string().optional(),
|
|
25425
|
+
frameIds: array(string()).max(2e3).optional()
|
|
25426
|
+
}), array(RetrainAnnotationSchema).readonly(), {
|
|
24339
25427
|
kind: "query",
|
|
24340
25428
|
auth: "admin"
|
|
24341
25429
|
}), method(object({
|
|
24342
25430
|
deviceId: number(),
|
|
24343
|
-
|
|
25431
|
+
/** The frame's track, when it has one — checked against the frame. */
|
|
25432
|
+
trackId: string().optional(),
|
|
24344
25433
|
frameId: string(),
|
|
24345
25434
|
annotations: array(RetrainAnnotationDraftSchema)
|
|
24346
25435
|
}), array(RetrainAnnotationSchema).readonly(), {
|
|
@@ -24363,7 +25452,7 @@ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).rea
|
|
|
24363
25452
|
auth: "admin"
|
|
24364
25453
|
}), method(object({
|
|
24365
25454
|
deviceId: number(),
|
|
24366
|
-
trackId: string(),
|
|
25455
|
+
trackId: string().optional(),
|
|
24367
25456
|
frameId: string(),
|
|
24368
25457
|
complete: boolean()
|
|
24369
25458
|
}), RetrainFrameSchema, {
|
|
@@ -24377,6 +25466,74 @@ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).rea
|
|
|
24377
25466
|
kind: "mutation",
|
|
24378
25467
|
auth: "admin",
|
|
24379
25468
|
timeoutMs: 60 * 6e4
|
|
25469
|
+
}), method(object({}), array(RetrainAssistProfileSchema).readonly(), {
|
|
25470
|
+
kind: "query",
|
|
25471
|
+
auth: "admin"
|
|
25472
|
+
}), method(object({
|
|
25473
|
+
deviceId: number(),
|
|
25474
|
+
trackId: string().optional(),
|
|
25475
|
+
frameId: string(),
|
|
25476
|
+
profileId: string(),
|
|
25477
|
+
classes: array(RetrainMacroClassSchema).min(1),
|
|
25478
|
+
boxes: array(object({
|
|
25479
|
+
ref: string(),
|
|
25480
|
+
bbox: RetrainBboxSchema,
|
|
25481
|
+
macroClass: RetrainMacroClassSchema,
|
|
25482
|
+
label: string().optional()
|
|
25483
|
+
})).max(50),
|
|
25484
|
+
allowCloud: boolean()
|
|
25485
|
+
}), RetrainLlmAssistResultSchema, {
|
|
25486
|
+
kind: "mutation",
|
|
25487
|
+
auth: "admin",
|
|
25488
|
+
timeoutMs: 18e4
|
|
25489
|
+
}), method(object({ name: string().max(120) }), RetrainCollectionCreateResultSchema, {
|
|
25490
|
+
kind: "mutation",
|
|
25491
|
+
auth: "admin"
|
|
25492
|
+
}), method(object({}), array(RetrainCollectionSchema).readonly(), {
|
|
25493
|
+
kind: "query",
|
|
25494
|
+
auth: "admin"
|
|
25495
|
+
}), method(object({
|
|
25496
|
+
id: string(),
|
|
25497
|
+
name: string().max(120)
|
|
25498
|
+
}), RetrainCollectionRenameResultSchema, {
|
|
25499
|
+
kind: "mutation",
|
|
25500
|
+
auth: "admin"
|
|
25501
|
+
}), method(object({ id: string() }), object({
|
|
25502
|
+
deleted: boolean(),
|
|
25503
|
+
removedFrames: number().int()
|
|
25504
|
+
}), {
|
|
25505
|
+
kind: "mutation",
|
|
25506
|
+
auth: "admin"
|
|
25507
|
+
}), method(object({
|
|
25508
|
+
collectionId: string(),
|
|
25509
|
+
deviceId: number(),
|
|
25510
|
+
epochMs: number()
|
|
25511
|
+
}), AddRetrainFrameFromRecordingResultSchema, {
|
|
25512
|
+
kind: "mutation",
|
|
25513
|
+
auth: "admin",
|
|
25514
|
+
timeoutMs: 6e4
|
|
25515
|
+
}), method(object({
|
|
25516
|
+
collectionId: string(),
|
|
25517
|
+
frameIds: array(string()).min(1).max(500)
|
|
25518
|
+
}), object({
|
|
25519
|
+
added: number().int(),
|
|
25520
|
+
alreadyMember: number().int(),
|
|
25521
|
+
unknownFrameIds: array(string()).readonly()
|
|
25522
|
+
}), {
|
|
25523
|
+
kind: "mutation",
|
|
25524
|
+
auth: "admin"
|
|
25525
|
+
}), method(object({
|
|
25526
|
+
collectionId: string(),
|
|
25527
|
+
frameId: string()
|
|
25528
|
+
}), object({
|
|
25529
|
+
removed: boolean(),
|
|
25530
|
+
deletedFrame: boolean()
|
|
25531
|
+
}), {
|
|
25532
|
+
kind: "mutation",
|
|
25533
|
+
auth: "admin"
|
|
25534
|
+
}), method(object({ collectionId: string() }), array(RetrainFrameSchema).readonly(), {
|
|
25535
|
+
kind: "query",
|
|
25536
|
+
auth: "admin"
|
|
24380
25537
|
}), method(object({
|
|
24381
25538
|
/** Which of the three event tables owns the row. */
|
|
24382
25539
|
ownerType: EventOwnerTypeSchema,
|
|
@@ -25000,13 +26157,31 @@ var RecommendationReasonSchema = discriminatedUnion("kind", [
|
|
|
25000
26157
|
object({
|
|
25001
26158
|
kind: literal("no-family-build"),
|
|
25002
26159
|
format: ModelFormatSchema$1
|
|
26160
|
+
}),
|
|
26161
|
+
object({
|
|
26162
|
+
kind: literal("kept-custom-pin"),
|
|
26163
|
+
modelId: string(),
|
|
26164
|
+
deviceKey: string()
|
|
25003
26165
|
})
|
|
25004
26166
|
]);
|
|
26167
|
+
/** Why a device is left exactly as it is, whatever the plan would pick (D786). */
|
|
26168
|
+
var KeptReasonSchema = _enum(["custom-pin"]);
|
|
26169
|
+
/**
|
|
26170
|
+
* Where a choice's latency came from (D791): this node's own benchmark
|
|
26171
|
+
* result, or the hardware-class table. Measured on the node beats the table.
|
|
26172
|
+
*/
|
|
26173
|
+
var LatencySourceSchema = discriminatedUnion("kind", [object({ kind: literal("table") }), object({
|
|
26174
|
+
kind: literal("node-benchmark"),
|
|
26175
|
+
resultId: string(),
|
|
26176
|
+
measuredAtMs: number()
|
|
26177
|
+
})]);
|
|
25005
26178
|
var DeviceModelChoiceSchema = object({
|
|
25006
26179
|
modelId: string(),
|
|
25007
26180
|
p50Ms: number(),
|
|
25008
26181
|
fps: number(),
|
|
25009
26182
|
measured: boolean(),
|
|
26183
|
+
/** Absent on a plan from before D791 — read as the table. */
|
|
26184
|
+
source: LatencySourceSchema.optional(),
|
|
25010
26185
|
/** Parallel sessions at the camera rate with the headroom kept free: ⌊fps × (1 − headroom) / camera fps⌋. */
|
|
25011
26186
|
capacitySessions: number(),
|
|
25012
26187
|
personRecall: number()
|
|
@@ -25017,6 +26192,8 @@ var DeviceRecommendationSchema = object({
|
|
|
25017
26192
|
enabled: boolean(),
|
|
25018
26193
|
available: boolean(),
|
|
25019
26194
|
chosen: DeviceModelChoiceSchema.nullable(),
|
|
26195
|
+
/** Present when the device is kept as is: Apply writes nothing on it. */
|
|
26196
|
+
kept: KeptReasonSchema.optional(),
|
|
25020
26197
|
reasons: array(RecommendationReasonSchema).readonly()
|
|
25021
26198
|
});
|
|
25022
26199
|
var NodeRecommendationSchema = object({
|
|
@@ -25070,6 +26247,17 @@ var AutoTuneWarningSchema = discriminatedUnion("kind", [
|
|
|
25070
26247
|
kind: literal("coral-enabled"),
|
|
25071
26248
|
nodeId: string(),
|
|
25072
26249
|
deviceKey: string()
|
|
26250
|
+
}),
|
|
26251
|
+
object({
|
|
26252
|
+
kind: literal("custom-pin-kept"),
|
|
26253
|
+
nodeId: string(),
|
|
26254
|
+
deviceKey: string().nullable(),
|
|
26255
|
+
deviceId: number().nullable(),
|
|
26256
|
+
modelId: string()
|
|
26257
|
+
}),
|
|
26258
|
+
object({
|
|
26259
|
+
kind: literal("custom-registry-unreadable"),
|
|
26260
|
+
error: string()
|
|
25073
26261
|
})
|
|
25074
26262
|
]);
|
|
25075
26263
|
var AutoTuneOptionsSchema = object({
|
|
@@ -25248,13 +26436,14 @@ var SuggestSharesResultSchema = object({
|
|
|
25248
26436
|
nodes: array(SuggestedNodeShareSchema).readonly()
|
|
25249
26437
|
});
|
|
25250
26438
|
/**
|
|
25251
|
-
* Where the node and device shares come from (D750, D755).
|
|
25252
|
-
* - `
|
|
25253
|
-
*
|
|
25254
|
-
*
|
|
25255
|
-
*
|
|
25256
|
-
*
|
|
25257
|
-
*
|
|
26439
|
+
* Where the node and device shares come from (D750, D755, D791).
|
|
26440
|
+
* - `benchmark` (default since D791) — each node's capacity as its own node
|
|
26441
|
+
* benchmark measured it; a node without fresh results is sized from
|
|
26442
|
+
* `hardware` and says so. Measured on the node beats the table.
|
|
26443
|
+
* - `hardware` — computed from each node's static capacity only (its
|
|
26444
|
+
* accelerators at their Auto tune models, from the latency table).
|
|
26445
|
+
* Both are recomputed whenever a node or device joins, leaves, is switched
|
|
26446
|
+
* on or off, changes model, or a benchmark result is written. No load input.
|
|
25258
26447
|
* - `manual` — the operator's stored sliders.
|
|
25259
26448
|
* Either way a node or device that cannot take sessions gives its share to
|
|
25260
26449
|
* the others in proportion; the stored values are never rewritten for that.
|
|
@@ -25303,6 +26492,362 @@ var EffectiveSharesSchema = object({
|
|
|
25303
26492
|
nodeWeights: record(string(), number()),
|
|
25304
26493
|
deviceWeights: record(string(), record(string(), number()))
|
|
25305
26494
|
});
|
|
26495
|
+
/**
|
|
26496
|
+
* Wire shapes of the node benchmark (D791): the operator's plan, the
|
|
26497
|
+
* preflight the confirmation shows, the run the orchestrator owns, what the
|
|
26498
|
+
* measuring runner reports, and the result rows Auto tune and the automatic
|
|
26499
|
+
* shares read.
|
|
26500
|
+
*
|
|
26501
|
+
* ONE node at a time, owned by the pipeline orchestrator. While a run is
|
|
26502
|
+
* active the cluster is in BENCHMARK MODE for that node: it is not a
|
|
26503
|
+
* detection candidate, camera pins naming it are ignored so its sessions move
|
|
26504
|
+
* elsewhere, and both come back when the mode ends — after a crash or a hub
|
|
26505
|
+
* restart too (a persisted manifest, reconciled against the registry).
|
|
26506
|
+
*
|
|
26507
|
+
* Two measurements, both on the node, driven by its own runner (frames never
|
|
26508
|
+
* cross a process at frame rate, D9):
|
|
26509
|
+
* - `device` — one accelerator × one candidate detector, root only, open
|
|
26510
|
+
* loop: how many streams at the camera rate it carries inside the frame
|
|
26511
|
+
* interval;
|
|
26512
|
+
* - `pipeline` — the chosen detector plus the operator's detail steps
|
|
26513
|
+
* (faces, plates, classifiers, CLIP…), on varied frames from the bench
|
|
26514
|
+
* clip: how many parallel sessions the node carries before latency, drops,
|
|
26515
|
+
* CPU, RAM or the event loop give out.
|
|
26516
|
+
*/
|
|
26517
|
+
/** Defaults and bounds, one place. */
|
|
26518
|
+
var NODE_BENCHMARK_DEFAULTS = {
|
|
26519
|
+
fpsPerStream: 10,
|
|
26520
|
+
budgetMinutes: 45,
|
|
26521
|
+
minBudgetMinutes: 10,
|
|
26522
|
+
maxBudgetMinutes: 120,
|
|
26523
|
+
/** A result older than this no longer beats the table. */
|
|
26524
|
+
staleAfterDays: 30,
|
|
26525
|
+
/** Warm-in per ramp step (not accounted). */
|
|
26526
|
+
settleSec: 5,
|
|
26527
|
+
/** Accounted window per ramp step. */
|
|
26528
|
+
measureSec: 20,
|
|
26529
|
+
/** Longest the drain may take before the run is refused. */
|
|
26530
|
+
drainTimeoutSec: 120,
|
|
26531
|
+
/** Candidate models per device in one run. */
|
|
26532
|
+
maxModelsPerDevice: 6
|
|
26533
|
+
};
|
|
26534
|
+
/** The two measurements a run can make. */
|
|
26535
|
+
var NodeBenchmarkPhaseSchema = _enum(["device", "pipeline"]);
|
|
26536
|
+
var NodeBenchmarkDevicePlanSchema = object({
|
|
26537
|
+
/** `<backend>:<device>` — `openvino:npu`, `coreml:all`, `cpu`. */
|
|
26538
|
+
deviceKey: string().min(1),
|
|
26539
|
+
/**
|
|
26540
|
+
* Root detector candidates for the `device` measurement, in the order
|
|
26541
|
+
* measured. The FIRST is the one the `pipeline` measurement runs.
|
|
26542
|
+
*/
|
|
26543
|
+
modelIds: array(string().min(1)).min(1).max(NODE_BENCHMARK_DEFAULTS.maxModelsPerDevice)
|
|
26544
|
+
});
|
|
26545
|
+
/** What the operator confirmed. */
|
|
26546
|
+
var NodeBenchmarkPlanSchema = object({
|
|
26547
|
+
nodeId: string().min(1),
|
|
26548
|
+
devices: array(NodeBenchmarkDevicePlanSchema).min(1),
|
|
26549
|
+
/** Which measurements run. At least one. */
|
|
26550
|
+
phases: array(NodeBenchmarkPhaseSchema).min(1).default(["device", "pipeline"]),
|
|
26551
|
+
/**
|
|
26552
|
+
* Detail steps (catalog step ids under the root: faces, plates,
|
|
26553
|
+
* classifiers, CLIP…) the `pipeline` measurement enables. The root
|
|
26554
|
+
* detector always runs.
|
|
26555
|
+
*/
|
|
26556
|
+
steps: array(string().min(1)).default([]),
|
|
26557
|
+
/** Offered rate of one stream / session. */
|
|
26558
|
+
fpsPerStream: number().int().min(1).max(30).default(NODE_BENCHMARK_DEFAULTS.fpsPerStream),
|
|
26559
|
+
/** Hard deadline: the mode ends and the cluster is restored when it passes. */
|
|
26560
|
+
budgetMinutes: number().int().min(NODE_BENCHMARK_DEFAULTS.minBudgetMinutes).max(NODE_BENCHMARK_DEFAULTS.maxBudgetMinutes).default(NODE_BENCHMARK_DEFAULTS.budgetMinutes),
|
|
26561
|
+
/** Keep the models the run downloaded (default: delete what was not installed before). */
|
|
26562
|
+
keepDownloadedModels: boolean().default(false),
|
|
26563
|
+
/** Start although the other nodes' capacity does not cover the sessions running now. */
|
|
26564
|
+
acceptInsufficientHeadroom: boolean().default(false)
|
|
26565
|
+
});
|
|
26566
|
+
var NodeBenchmarkRefusalSchema = object({
|
|
26567
|
+
kind: _enum([
|
|
26568
|
+
"benchmark-active",
|
|
26569
|
+
"node-offline",
|
|
26570
|
+
"unknown-device",
|
|
26571
|
+
"no-phase",
|
|
26572
|
+
"insufficient-headroom"
|
|
26573
|
+
]),
|
|
26574
|
+
detail: string(),
|
|
26575
|
+
overridable: boolean()
|
|
26576
|
+
});
|
|
26577
|
+
/** A camera whose detection leaves the node for the run. */
|
|
26578
|
+
var NodeBenchmarkMovingCameraSchema = object({
|
|
26579
|
+
deviceId: number(),
|
|
26580
|
+
/** Placed on the node now (a standing attach or a running session). */
|
|
26581
|
+
placedOnNode: boolean(),
|
|
26582
|
+
/** A node pin naming this node, ignored for the run. */
|
|
26583
|
+
pinnedToNode: boolean()
|
|
26584
|
+
});
|
|
26585
|
+
/** A camera that cannot leave: no other node can obtain its frames. */
|
|
26586
|
+
var NodeBenchmarkStayingCameraSchema = object({
|
|
26587
|
+
deviceId: number(),
|
|
26588
|
+
reason: literal("only-frame-source")
|
|
26589
|
+
});
|
|
26590
|
+
var NodeBenchmarkPreflightSchema = object({
|
|
26591
|
+
nodeId: string(),
|
|
26592
|
+
online: boolean(),
|
|
26593
|
+
moving: array(NodeBenchmarkMovingCameraSchema).readonly(),
|
|
26594
|
+
/** Keep running on the node during the run; the result is flagged contaminated. */
|
|
26595
|
+
staying: array(NodeBenchmarkStayingCameraSchema).readonly(),
|
|
26596
|
+
estimatedDurationMs: number(),
|
|
26597
|
+
/** The run ends and the cluster is restored at the latest after this long. */
|
|
26598
|
+
budgetMs: number(),
|
|
26599
|
+
phases: array(NodeBenchmarkPhaseSchema).readonly(),
|
|
26600
|
+
steps: array(string()).readonly(),
|
|
26601
|
+
devices: array(NodeBenchmarkDevicePlanSchema).readonly(),
|
|
26602
|
+
/** Parallel sessions the cluster runs now, and what the other nodes can carry. */
|
|
26603
|
+
headroom: object({
|
|
26604
|
+
sessionsNow: number(),
|
|
26605
|
+
otherNodesCapacitySessions: number().nullable()
|
|
26606
|
+
}),
|
|
26607
|
+
refusals: array(NodeBenchmarkRefusalSchema).readonly(),
|
|
26608
|
+
canStart: boolean()
|
|
26609
|
+
});
|
|
26610
|
+
/** Where the measuring runner is. */
|
|
26611
|
+
var NodeBenchProgressSchema = object({
|
|
26612
|
+
phase: _enum([
|
|
26613
|
+
"preparing",
|
|
26614
|
+
"device",
|
|
26615
|
+
"pipeline",
|
|
26616
|
+
"cleanup"
|
|
26617
|
+
]),
|
|
26618
|
+
deviceKey: string().nullable(),
|
|
26619
|
+
modelId: string().nullable(),
|
|
26620
|
+
/** Streams (device) or sessions (pipeline) of the step running now. */
|
|
26621
|
+
load: number().nullable(),
|
|
26622
|
+
cellsDone: number(),
|
|
26623
|
+
cellsTotal: number(),
|
|
26624
|
+
message: string()
|
|
26625
|
+
});
|
|
26626
|
+
/** What limited a ramp. `none` = the ramp ran out of steps still passing. */
|
|
26627
|
+
var NodeBenchLimitSchema = _enum([
|
|
26628
|
+
"p95",
|
|
26629
|
+
"drops",
|
|
26630
|
+
"errors",
|
|
26631
|
+
"stall",
|
|
26632
|
+
"cpu",
|
|
26633
|
+
"ram",
|
|
26634
|
+
"none"
|
|
26635
|
+
]);
|
|
26636
|
+
var NodeBenchRampStepSchema = object({
|
|
26637
|
+
load: number(),
|
|
26638
|
+
pass: boolean(),
|
|
26639
|
+
p95Ms: number(),
|
|
26640
|
+
dropRatio: number(),
|
|
26641
|
+
/** Completed frames per second over the accounted window. */
|
|
26642
|
+
fps: number(),
|
|
26643
|
+
cpuPct: number().nullable(),
|
|
26644
|
+
ramFreePct: number().nullable(),
|
|
26645
|
+
failReasons: array(string()).readonly()
|
|
26646
|
+
});
|
|
26647
|
+
var NodeBenchCellSchema = discriminatedUnion("phase", [object({
|
|
26648
|
+
phase: literal("device"),
|
|
26649
|
+
deviceKey: string(),
|
|
26650
|
+
modelId: string(),
|
|
26651
|
+
/** Single-stream latency (the K = 1 step). */
|
|
26652
|
+
p50Ms: number(),
|
|
26653
|
+
p95Ms: number(),
|
|
26654
|
+
p99Ms: number(),
|
|
26655
|
+
/** Frames per second sustained at the last passing step. */
|
|
26656
|
+
fps: number(),
|
|
26657
|
+
/** Streams at the camera rate the device carried inside the frame interval; 0 = not even one. */
|
|
26658
|
+
kMax: number(),
|
|
26659
|
+
limitedBy: NodeBenchLimitSchema,
|
|
26660
|
+
/** First call (model load + warm-up). */
|
|
26661
|
+
warmupMs: number(),
|
|
26662
|
+
ramp: array(NodeBenchRampStepSchema).readonly()
|
|
26663
|
+
}), object({
|
|
26664
|
+
phase: literal("pipeline"),
|
|
26665
|
+
deviceKey: string(),
|
|
26666
|
+
modelId: string(),
|
|
26667
|
+
steps: array(string()).readonly(),
|
|
26668
|
+
/** Parallel sessions at the camera rate the node carried; 0 = not even one. */
|
|
26669
|
+
maxSessions: number(),
|
|
26670
|
+
limitedBy: NodeBenchLimitSchema,
|
|
26671
|
+
/** Detail steps that produced at least one result on the clip — a step that never fired measured nothing. */
|
|
26672
|
+
stepsFired: array(string()).readonly(),
|
|
26673
|
+
warmupMs: number(),
|
|
26674
|
+
ramp: array(NodeBenchRampStepSchema).readonly()
|
|
26675
|
+
})]);
|
|
26676
|
+
/**
|
|
26677
|
+
* What a result was measured ON. A result whose fingerprint no longer matches
|
|
26678
|
+
* the node no longer beats the table.
|
|
26679
|
+
*/
|
|
26680
|
+
var NodeBenchFingerprintSchema = object({
|
|
26681
|
+
pipelineVersion: string().nullable(),
|
|
26682
|
+
cpuModel: string().nullable(),
|
|
26683
|
+
ramGb: number().nullable(),
|
|
26684
|
+
os: string().nullable(),
|
|
26685
|
+
/** Per device: the pool the cells ran on (runtime + tuning). */
|
|
26686
|
+
pools: record(string(), object({
|
|
26687
|
+
runtime: string(),
|
|
26688
|
+
numWorkers: number(),
|
|
26689
|
+
concurrency: number(),
|
|
26690
|
+
batchMode: string()
|
|
26691
|
+
})).default({})
|
|
26692
|
+
});
|
|
26693
|
+
/** The frames the run used. */
|
|
26694
|
+
var NodeBenchClipSchema = object({
|
|
26695
|
+
/** `camstack-bench-v1` or `reference-images` (the fallback when the clip is not reachable). */
|
|
26696
|
+
id: string(),
|
|
26697
|
+
revision: string().nullable(),
|
|
26698
|
+
frames: number(),
|
|
26699
|
+
width: number(),
|
|
26700
|
+
height: number()
|
|
26701
|
+
});
|
|
26702
|
+
var NodeBenchRunnerInputSchema = object({
|
|
26703
|
+
runId: string().min(1),
|
|
26704
|
+
devices: array(NodeBenchmarkDevicePlanSchema).min(1),
|
|
26705
|
+
phases: array(NodeBenchmarkPhaseSchema).min(1),
|
|
26706
|
+
/** The full detail step tree root for the `pipeline` measurement is built on the node from these ids. */
|
|
26707
|
+
steps: array(string()).default([]),
|
|
26708
|
+
fpsPerStream: number().int().min(1).max(30),
|
|
26709
|
+
/** The runner stops on its own past this instant, whatever the hub does. */
|
|
26710
|
+
deadlineAtMs: number(),
|
|
26711
|
+
settleSec: number().min(0).max(60).default(NODE_BENCHMARK_DEFAULTS.settleSec),
|
|
26712
|
+
measureSec: number().min(2).max(300).default(NODE_BENCHMARK_DEFAULTS.measureSec),
|
|
26713
|
+
keepDownloadedModels: boolean().default(false)
|
|
26714
|
+
});
|
|
26715
|
+
var NodeBenchRunnerStateSchema = _enum([
|
|
26716
|
+
"running",
|
|
26717
|
+
"done",
|
|
26718
|
+
"failed",
|
|
26719
|
+
"aborted"
|
|
26720
|
+
]);
|
|
26721
|
+
var NodeBenchRunnerStatusSchema = object({
|
|
26722
|
+
runId: string(),
|
|
26723
|
+
nodeId: string(),
|
|
26724
|
+
state: NodeBenchRunnerStateSchema,
|
|
26725
|
+
progress: NodeBenchProgressSchema.nullable(),
|
|
26726
|
+
/** Every finished cell so far — a run stopped half way keeps what it measured. */
|
|
26727
|
+
cells: array(NodeBenchCellSchema).readonly(),
|
|
26728
|
+
fingerprint: NodeBenchFingerprintSchema.nullable(),
|
|
26729
|
+
clip: NodeBenchClipSchema.nullable(),
|
|
26730
|
+
/** Cameras seen running on the node during the run (they share its pools). */
|
|
26731
|
+
activeCameraIds: array(number()).readonly(),
|
|
26732
|
+
/** Models the run downloaded and then deleted (not installed before). */
|
|
26733
|
+
deletedModels: array(string()).readonly(),
|
|
26734
|
+
error: string().nullable(),
|
|
26735
|
+
startedAtMs: number(),
|
|
26736
|
+
finishedAtMs: number().nullable()
|
|
26737
|
+
});
|
|
26738
|
+
var NodeBenchmarkStateSchema = _enum([
|
|
26739
|
+
"draining",
|
|
26740
|
+
"measuring",
|
|
26741
|
+
"restoring",
|
|
26742
|
+
"done",
|
|
26743
|
+
"failed",
|
|
26744
|
+
"aborted"
|
|
26745
|
+
]);
|
|
26746
|
+
/** Why a run ended. */
|
|
26747
|
+
var NodeBenchmarkEndReasonSchema = _enum([
|
|
26748
|
+
"completed",
|
|
26749
|
+
"operator-abort",
|
|
26750
|
+
"deadline",
|
|
26751
|
+
"node-lost",
|
|
26752
|
+
"runner-lost",
|
|
26753
|
+
"hub-restart",
|
|
26754
|
+
"drain-timeout",
|
|
26755
|
+
"failed"
|
|
26756
|
+
]);
|
|
26757
|
+
var NodeBenchmarkRunSchema = object({
|
|
26758
|
+
runId: string(),
|
|
26759
|
+
nodeId: string(),
|
|
26760
|
+
state: NodeBenchmarkStateSchema,
|
|
26761
|
+
plan: NodeBenchmarkPlanSchema,
|
|
26762
|
+
startedAtMs: number(),
|
|
26763
|
+
deadlineAtMs: number(),
|
|
26764
|
+
finishedAtMs: number().nullable(),
|
|
26765
|
+
endReason: NodeBenchmarkEndReasonSchema.nullable(),
|
|
26766
|
+
error: string().nullable(),
|
|
26767
|
+
/** Cameras moved off the node for the run. */
|
|
26768
|
+
moved: array(number()).readonly(),
|
|
26769
|
+
/** Cameras that stayed (their only frame source is the node). */
|
|
26770
|
+
staying: array(number()).readonly(),
|
|
26771
|
+
/** Something else ran on the node's pools during the run. */
|
|
26772
|
+
contaminated: boolean(),
|
|
26773
|
+
progress: NodeBenchProgressSchema.nullable(),
|
|
26774
|
+
resultIds: array(string()).readonly()
|
|
26775
|
+
});
|
|
26776
|
+
/** `getNodeBenchmarkStatus`: the active run (or the last one), and whether benchmark mode is on. */
|
|
26777
|
+
var NodeBenchmarkStatusSchema = object({
|
|
26778
|
+
/** The node the cluster is in benchmark mode for; null = none. */
|
|
26779
|
+
modeNodeId: string().nullable(),
|
|
26780
|
+
run: NodeBenchmarkRunSchema.nullable()
|
|
26781
|
+
});
|
|
26782
|
+
/**
|
|
26783
|
+
* One stored measurement — the only authority Auto tune and the automatic
|
|
26784
|
+
* shares read measured capacity from. Written by the orchestrator when a run
|
|
26785
|
+
* ends, never by anyone else.
|
|
26786
|
+
*/
|
|
26787
|
+
var NodeBenchmarkResultSchema = object({
|
|
26788
|
+
id: string(),
|
|
26789
|
+
runId: string(),
|
|
26790
|
+
nodeId: string(),
|
|
26791
|
+
cell: NodeBenchCellSchema,
|
|
26792
|
+
fpsPerStream: number(),
|
|
26793
|
+
fingerprint: NodeBenchFingerprintSchema.nullable(),
|
|
26794
|
+
clip: NodeBenchClipSchema.nullable(),
|
|
26795
|
+
/** Other work shared the node's pools (a camera that could not move, or the hub's own duties). */
|
|
26796
|
+
contaminated: boolean(),
|
|
26797
|
+
stayingCameras: array(number()).readonly(),
|
|
26798
|
+
/** The run ended early; the cell itself completed. */
|
|
26799
|
+
partialRun: boolean(),
|
|
26800
|
+
measuredAtMs: number()
|
|
26801
|
+
});
|
|
26802
|
+
var ListNodeBenchmarkResultsInputSchema = object({
|
|
26803
|
+
nodeId: string().optional(),
|
|
26804
|
+
deviceKey: string().optional()
|
|
26805
|
+
});
|
|
26806
|
+
/** A result with its standing today: does it still beat the table? */
|
|
26807
|
+
var NodeBenchmarkResultViewSchema = NodeBenchmarkResultSchema.extend({
|
|
26808
|
+
/** `fresh` beats the table; `stale` falls back to it; `superseded` = a newer row covers the same cell. */
|
|
26809
|
+
standing: _enum([
|
|
26810
|
+
"fresh",
|
|
26811
|
+
"stale",
|
|
26812
|
+
"superseded"
|
|
26813
|
+
]),
|
|
26814
|
+
staleWhy: _enum([
|
|
26815
|
+
"age",
|
|
26816
|
+
"runtime",
|
|
26817
|
+
"pool-tuning"
|
|
26818
|
+
]).nullable()
|
|
26819
|
+
});
|
|
26820
|
+
object({
|
|
26821
|
+
runId: string(),
|
|
26822
|
+
nodeId: string(),
|
|
26823
|
+
startedAtMs: number(),
|
|
26824
|
+
deadlineAtMs: number(),
|
|
26825
|
+
plan: NodeBenchmarkPlanSchema,
|
|
26826
|
+
moved: array(number()).readonly(),
|
|
26827
|
+
staying: array(number()).readonly()
|
|
26828
|
+
});
|
|
26829
|
+
/** Candidate detectors per device, for the plan editor. */
|
|
26830
|
+
var NodeBenchmarkCandidatesSchema = object({
|
|
26831
|
+
nodeId: string(),
|
|
26832
|
+
reachable: boolean(),
|
|
26833
|
+
devices: array(object({
|
|
26834
|
+
deviceKey: string(),
|
|
26835
|
+
enabled: boolean(),
|
|
26836
|
+
available: boolean(),
|
|
26837
|
+
/** Ordered: what Auto tune would pick first, then the rest of the family by accuracy. */
|
|
26838
|
+
suggested: array(string()).readonly(),
|
|
26839
|
+
/** Every root detector the device has a build for. */
|
|
26840
|
+
all: array(string()).readonly(),
|
|
26841
|
+
/** The model the device runs now, when pinned. */
|
|
26842
|
+
currentModelId: string().nullable()
|
|
26843
|
+
})).readonly(),
|
|
26844
|
+
/** Detail steps the node's catalog offers under the root (for the `pipeline` measurement). */
|
|
26845
|
+
steps: array(object({
|
|
26846
|
+
id: string(),
|
|
26847
|
+
name: string(),
|
|
26848
|
+
slot: string()
|
|
26849
|
+
})).readonly()
|
|
26850
|
+
});
|
|
25306
26851
|
object({
|
|
25307
26852
|
activeCameras: number(),
|
|
25308
26853
|
throttledCameras: number(),
|
|
@@ -26431,7 +27976,16 @@ method(RunnerCameraConfigSchema, object({ success: literal(true) }), { kind: "mu
|
|
|
26431
27976
|
}), ParkedTrackFrameSchema.nullable()), method(object({
|
|
26432
27977
|
deviceId: number(),
|
|
26433
27978
|
trackId: string()
|
|
26434
|
-
}), object({ released: number().int().nonnegative() }), { kind: "mutation" })
|
|
27979
|
+
}), object({ released: number().int().nonnegative() }), { kind: "mutation" }), method(NodeBenchRunnerInputSchema, object({
|
|
27980
|
+
accepted: literal(true),
|
|
27981
|
+
runId: string()
|
|
27982
|
+
}), {
|
|
27983
|
+
kind: "mutation",
|
|
27984
|
+
auth: "admin"
|
|
27985
|
+
}), method(object({ runId: string() }), NodeBenchRunnerStatusSchema.nullable(), { auth: "admin" }), method(object({ runId: string() }), object({ aborted: boolean() }), {
|
|
27986
|
+
kind: "mutation",
|
|
27987
|
+
auth: "admin"
|
|
27988
|
+
});
|
|
26435
27989
|
var CameraPipelineConfigSchema = object({
|
|
26436
27990
|
engine: PipelineEngineChoiceSchema.optional(),
|
|
26437
27991
|
steps: array(PipelineStepInputSchema).readonly(),
|
|
@@ -27070,6 +28624,21 @@ method(object({
|
|
|
27070
28624
|
}), method(PlacementStatsInputSchema, PlacementStatsSchema, { auth: "admin" }), method(SuggestSharesInputSchema, SuggestSharesResultSchema, { auth: "admin" }), method(_void(), EffectiveSharesSchema, { auth: "admin" }), method(SetShareSourceInputSchema, object({ success: literal(true) }), {
|
|
27071
28625
|
kind: "mutation",
|
|
27072
28626
|
auth: "admin"
|
|
28627
|
+
}), method(NodeBenchmarkPlanSchema, NodeBenchmarkPreflightSchema, { auth: "admin" }), method(NodeBenchmarkPlanSchema, discriminatedUnion("kind", [object({
|
|
28628
|
+
kind: literal("started"),
|
|
28629
|
+
runId: string()
|
|
28630
|
+
}), object({
|
|
28631
|
+
kind: literal("refused"),
|
|
28632
|
+
preflight: NodeBenchmarkPreflightSchema
|
|
28633
|
+
})]), {
|
|
28634
|
+
kind: "mutation",
|
|
28635
|
+
auth: "admin"
|
|
28636
|
+
}), method(_void(), NodeBenchmarkStatusSchema, { auth: "admin" }), method(object({ runId: string() }), object({ aborted: boolean() }), {
|
|
28637
|
+
kind: "mutation",
|
|
28638
|
+
auth: "admin"
|
|
28639
|
+
}), method(object({ nodeId: string() }), NodeBenchmarkCandidatesSchema, { auth: "admin" }), method(ListNodeBenchmarkResultsInputSchema, array(NodeBenchmarkResultViewSchema).readonly(), { auth: "admin" }), method(object({ id: string() }), object({ deleted: boolean() }), {
|
|
28640
|
+
kind: "mutation",
|
|
28641
|
+
auth: "admin"
|
|
27073
28642
|
}), method(object({ deviceId: number() }), CameraPipelineSettingsSchema.nullable()), method(object({
|
|
27074
28643
|
deviceId: number(),
|
|
27075
28644
|
addonId: string(),
|
|
@@ -33177,6 +34746,9 @@ var CreateIntegrationInputSchema = object({
|
|
|
33177
34746
|
enabled: boolean().optional(),
|
|
33178
34747
|
info: record(string(), unknown()).optional(),
|
|
33179
34748
|
settings: record(string(), unknown()).optional(),
|
|
34749
|
+
/** Keys of `settings` the form's schema declares secret (by type) — kept in
|
|
34750
|
+
* the keychain, not the table (D787). */
|
|
34751
|
+
secretKeys: array(string()).optional(),
|
|
33180
34752
|
skipRestart: boolean().optional()
|
|
33181
34753
|
});
|
|
33182
34754
|
var UpdateIntegrationInputSchema = object({
|
|
@@ -33200,7 +34772,9 @@ method(_void(), array(IntegrationWithStateSchema)), method(object({ id: string()
|
|
|
33200
34772
|
auth: "admin"
|
|
33201
34773
|
}), method(object({ id: string() }), record(string(), unknown()), { auth: "admin" }), method(object({
|
|
33202
34774
|
id: string(),
|
|
33203
|
-
settings: record(string(), unknown())
|
|
34775
|
+
settings: record(string(), unknown()),
|
|
34776
|
+
/** Keys the form's schema declares secret (by type) — keychain-stored (D787). */
|
|
34777
|
+
secretKeys: array(string()).optional()
|
|
33204
34778
|
}), object({ success: boolean() }), {
|
|
33205
34779
|
kind: "mutation",
|
|
33206
34780
|
auth: "admin"
|
|
@@ -41363,7 +42937,8 @@ var BaseDevice = class {
|
|
|
41363
42937
|
this.role = options.role;
|
|
41364
42938
|
this.parentDeviceId = ctx.parentDeviceId;
|
|
41365
42939
|
const seedData = ctx.persistedConfig ?? {};
|
|
41366
|
-
|
|
42940
|
+
const declaredSecretPaths = collectZodSecretPaths(schema);
|
|
42941
|
+
this.config = DeviceConfig.fromSchema(schema, (data) => ctx.persistConfig(data, { secretConfigPaths: declaredSecretPaths }), seedData, ({ droppedKeys, issues }) => {
|
|
41367
42942
|
ctx.logger.warn("Device config recovery: dropping invalid persisted fields", {
|
|
41368
42943
|
tags: {
|
|
41369
42944
|
deviceId: ctx.id,
|
|
@@ -45052,6 +46627,90 @@ Object.freeze({
|
|
|
45052
46627
|
addonId: null,
|
|
45053
46628
|
access: "create"
|
|
45054
46629
|
},
|
|
46630
|
+
"keychain.delete": {
|
|
46631
|
+
capName: "keychain",
|
|
46632
|
+
capScope: "system",
|
|
46633
|
+
addonId: null,
|
|
46634
|
+
access: "delete"
|
|
46635
|
+
},
|
|
46636
|
+
"keychain.getState": {
|
|
46637
|
+
capName: "keychain",
|
|
46638
|
+
capScope: "system",
|
|
46639
|
+
addonId: null,
|
|
46640
|
+
access: "view"
|
|
46641
|
+
},
|
|
46642
|
+
"keychain.listMeta": {
|
|
46643
|
+
capName: "keychain",
|
|
46644
|
+
capScope: "system",
|
|
46645
|
+
addonId: null,
|
|
46646
|
+
access: "view"
|
|
46647
|
+
},
|
|
46648
|
+
"keychain.put": {
|
|
46649
|
+
capName: "keychain",
|
|
46650
|
+
capScope: "system",
|
|
46651
|
+
addonId: null,
|
|
46652
|
+
access: "create"
|
|
46653
|
+
},
|
|
46654
|
+
"keychain.resolve": {
|
|
46655
|
+
capName: "keychain",
|
|
46656
|
+
capScope: "system",
|
|
46657
|
+
addonId: null,
|
|
46658
|
+
access: "view"
|
|
46659
|
+
},
|
|
46660
|
+
"keychainAdmin.deleteOrphans": {
|
|
46661
|
+
capName: "keychain-admin",
|
|
46662
|
+
capScope: "system",
|
|
46663
|
+
addonId: null,
|
|
46664
|
+
access: "delete"
|
|
46665
|
+
},
|
|
46666
|
+
"keychainAdmin.downloadRecoveryKey": {
|
|
46667
|
+
capName: "keychain-admin",
|
|
46668
|
+
capScope: "system",
|
|
46669
|
+
addonId: null,
|
|
46670
|
+
access: "create"
|
|
46671
|
+
},
|
|
46672
|
+
"keychainAdmin.listAudit": {
|
|
46673
|
+
capName: "keychain-admin",
|
|
46674
|
+
capScope: "system",
|
|
46675
|
+
addonId: null,
|
|
46676
|
+
access: "view"
|
|
46677
|
+
},
|
|
46678
|
+
"keychainAdmin.listSecrets": {
|
|
46679
|
+
capName: "keychain-admin",
|
|
46680
|
+
capScope: "system",
|
|
46681
|
+
addonId: null,
|
|
46682
|
+
access: "view"
|
|
46683
|
+
},
|
|
46684
|
+
"keychainAdmin.purgeRetiredKeys": {
|
|
46685
|
+
capName: "keychain-admin",
|
|
46686
|
+
capScope: "system",
|
|
46687
|
+
addonId: null,
|
|
46688
|
+
access: "delete"
|
|
46689
|
+
},
|
|
46690
|
+
"keychainAdmin.resetKeychain": {
|
|
46691
|
+
capName: "keychain-admin",
|
|
46692
|
+
capScope: "system",
|
|
46693
|
+
addonId: null,
|
|
46694
|
+
access: "delete"
|
|
46695
|
+
},
|
|
46696
|
+
"keychainAdmin.reveal": {
|
|
46697
|
+
capName: "keychain-admin",
|
|
46698
|
+
capScope: "system",
|
|
46699
|
+
addonId: null,
|
|
46700
|
+
access: "create"
|
|
46701
|
+
},
|
|
46702
|
+
"keychainAdmin.rotateMasterKey": {
|
|
46703
|
+
capName: "keychain-admin",
|
|
46704
|
+
capScope: "system",
|
|
46705
|
+
addonId: null,
|
|
46706
|
+
access: "create"
|
|
46707
|
+
},
|
|
46708
|
+
"keychainAdmin.status": {
|
|
46709
|
+
capName: "keychain-admin",
|
|
46710
|
+
capScope: "system",
|
|
46711
|
+
addonId: null,
|
|
46712
|
+
access: "view"
|
|
46713
|
+
},
|
|
45055
46714
|
"lawnMowerControl.dock": {
|
|
45056
46715
|
capName: "lawn-mower-control",
|
|
45057
46716
|
capScope: "device",
|
|
@@ -46426,6 +48085,18 @@ Object.freeze({
|
|
|
46426
48085
|
addonId: null,
|
|
46427
48086
|
access: "create"
|
|
46428
48087
|
},
|
|
48088
|
+
"pipelineAnalytics.addRetrainFrameFromRecording": {
|
|
48089
|
+
capName: "pipeline-analytics",
|
|
48090
|
+
capScope: "device",
|
|
48091
|
+
addonId: null,
|
|
48092
|
+
access: "create"
|
|
48093
|
+
},
|
|
48094
|
+
"pipelineAnalytics.addRetrainFramesToCollection": {
|
|
48095
|
+
capName: "pipeline-analytics",
|
|
48096
|
+
capScope: "device",
|
|
48097
|
+
addonId: null,
|
|
48098
|
+
access: "create"
|
|
48099
|
+
},
|
|
46429
48100
|
"pipelineAnalytics.applyDeviceSettingsPatch": {
|
|
46430
48101
|
capName: "pipeline-analytics",
|
|
46431
48102
|
capScope: "device",
|
|
@@ -46474,12 +48145,24 @@ Object.freeze({
|
|
|
46474
48145
|
addonId: null,
|
|
46475
48146
|
access: "view"
|
|
46476
48147
|
},
|
|
48148
|
+
"pipelineAnalytics.createRetrainCollection": {
|
|
48149
|
+
capName: "pipeline-analytics",
|
|
48150
|
+
capScope: "device",
|
|
48151
|
+
addonId: null,
|
|
48152
|
+
access: "create"
|
|
48153
|
+
},
|
|
46477
48154
|
"pipelineAnalytics.deleteDeviceEvents": {
|
|
46478
48155
|
capName: "pipeline-analytics",
|
|
46479
48156
|
capScope: "device",
|
|
46480
48157
|
addonId: null,
|
|
46481
48158
|
access: "delete"
|
|
46482
48159
|
},
|
|
48160
|
+
"pipelineAnalytics.deleteRetrainCollection": {
|
|
48161
|
+
capName: "pipeline-analytics",
|
|
48162
|
+
capScope: "device",
|
|
48163
|
+
addonId: null,
|
|
48164
|
+
access: "delete"
|
|
48165
|
+
},
|
|
46483
48166
|
"pipelineAnalytics.deleteTracks": {
|
|
46484
48167
|
capName: "pipeline-analytics",
|
|
46485
48168
|
capScope: "device",
|
|
@@ -46684,6 +48367,24 @@ Object.freeze({
|
|
|
46684
48367
|
addonId: null,
|
|
46685
48368
|
access: "view"
|
|
46686
48369
|
},
|
|
48370
|
+
"pipelineAnalytics.listRetrainAssistProfiles": {
|
|
48371
|
+
capName: "pipeline-analytics",
|
|
48372
|
+
capScope: "device",
|
|
48373
|
+
addonId: null,
|
|
48374
|
+
access: "view"
|
|
48375
|
+
},
|
|
48376
|
+
"pipelineAnalytics.listRetrainCollectionFrames": {
|
|
48377
|
+
capName: "pipeline-analytics",
|
|
48378
|
+
capScope: "device",
|
|
48379
|
+
addonId: null,
|
|
48380
|
+
access: "view"
|
|
48381
|
+
},
|
|
48382
|
+
"pipelineAnalytics.listRetrainCollections": {
|
|
48383
|
+
capName: "pipeline-analytics",
|
|
48384
|
+
capScope: "device",
|
|
48385
|
+
addonId: null,
|
|
48386
|
+
access: "view"
|
|
48387
|
+
},
|
|
46687
48388
|
"pipelineAnalytics.listRetrainFrames": {
|
|
46688
48389
|
capName: "pipeline-analytics",
|
|
46689
48390
|
capScope: "device",
|
|
@@ -46732,6 +48433,12 @@ Object.freeze({
|
|
|
46732
48433
|
addonId: null,
|
|
46733
48434
|
access: "create"
|
|
46734
48435
|
},
|
|
48436
|
+
"pipelineAnalytics.proposeRetrainAnnotationsWithLlm": {
|
|
48437
|
+
capName: "pipeline-analytics",
|
|
48438
|
+
capScope: "device",
|
|
48439
|
+
addonId: null,
|
|
48440
|
+
access: "create"
|
|
48441
|
+
},
|
|
46735
48442
|
"pipelineAnalytics.pruneEvents": {
|
|
46736
48443
|
capName: "pipeline-analytics",
|
|
46737
48444
|
capScope: "device",
|
|
@@ -46786,6 +48493,18 @@ Object.freeze({
|
|
|
46786
48493
|
addonId: null,
|
|
46787
48494
|
access: "create"
|
|
46788
48495
|
},
|
|
48496
|
+
"pipelineAnalytics.removeRetrainFrameFromCollection": {
|
|
48497
|
+
capName: "pipeline-analytics",
|
|
48498
|
+
capScope: "device",
|
|
48499
|
+
addonId: null,
|
|
48500
|
+
access: "delete"
|
|
48501
|
+
},
|
|
48502
|
+
"pipelineAnalytics.renameRetrainCollection": {
|
|
48503
|
+
capName: "pipeline-analytics",
|
|
48504
|
+
capScope: "device",
|
|
48505
|
+
addonId: null,
|
|
48506
|
+
access: "create"
|
|
48507
|
+
},
|
|
46789
48508
|
"pipelineAnalytics.restageRetrainTrack": {
|
|
46790
48509
|
capName: "pipeline-analytics",
|
|
46791
48510
|
capScope: "device",
|
|
@@ -47074,6 +48793,12 @@ Object.freeze({
|
|
|
47074
48793
|
addonId: null,
|
|
47075
48794
|
access: "view"
|
|
47076
48795
|
},
|
|
48796
|
+
"pipelineOrchestrator.abortNodeBenchmark": {
|
|
48797
|
+
capName: "pipeline-orchestrator",
|
|
48798
|
+
capScope: "system",
|
|
48799
|
+
addonId: null,
|
|
48800
|
+
access: "create"
|
|
48801
|
+
},
|
|
47077
48802
|
"pipelineOrchestrator.applyAutoTune": {
|
|
47078
48803
|
capName: "pipeline-orchestrator",
|
|
47079
48804
|
capScope: "system",
|
|
@@ -47098,6 +48823,12 @@ Object.freeze({
|
|
|
47098
48823
|
addonId: null,
|
|
47099
48824
|
access: "create"
|
|
47100
48825
|
},
|
|
48826
|
+
"pipelineOrchestrator.deleteNodeBenchmarkResult": {
|
|
48827
|
+
capName: "pipeline-orchestrator",
|
|
48828
|
+
capScope: "system",
|
|
48829
|
+
addonId: null,
|
|
48830
|
+
access: "delete"
|
|
48831
|
+
},
|
|
47101
48832
|
"pipelineOrchestrator.getAgentLoad": {
|
|
47102
48833
|
capName: "pipeline-orchestrator",
|
|
47103
48834
|
capScope: "system",
|
|
@@ -47206,6 +48937,24 @@ Object.freeze({
|
|
|
47206
48937
|
addonId: null,
|
|
47207
48938
|
access: "view"
|
|
47208
48939
|
},
|
|
48940
|
+
"pipelineOrchestrator.getNodeBenchmarkCandidates": {
|
|
48941
|
+
capName: "pipeline-orchestrator",
|
|
48942
|
+
capScope: "system",
|
|
48943
|
+
addonId: null,
|
|
48944
|
+
access: "view"
|
|
48945
|
+
},
|
|
48946
|
+
"pipelineOrchestrator.getNodeBenchmarkPreflight": {
|
|
48947
|
+
capName: "pipeline-orchestrator",
|
|
48948
|
+
capScope: "system",
|
|
48949
|
+
addonId: null,
|
|
48950
|
+
access: "view"
|
|
48951
|
+
},
|
|
48952
|
+
"pipelineOrchestrator.getNodeBenchmarkStatus": {
|
|
48953
|
+
capName: "pipeline-orchestrator",
|
|
48954
|
+
capScope: "system",
|
|
48955
|
+
addonId: null,
|
|
48956
|
+
access: "view"
|
|
48957
|
+
},
|
|
47209
48958
|
"pipelineOrchestrator.getNodeInferenceDevices": {
|
|
47210
48959
|
capName: "pipeline-orchestrator",
|
|
47211
48960
|
capScope: "system",
|
|
@@ -47248,6 +48997,12 @@ Object.freeze({
|
|
|
47248
48997
|
addonId: null,
|
|
47249
48998
|
access: "view"
|
|
47250
48999
|
},
|
|
49000
|
+
"pipelineOrchestrator.listNodeBenchmarkResults": {
|
|
49001
|
+
capName: "pipeline-orchestrator",
|
|
49002
|
+
capScope: "system",
|
|
49003
|
+
addonId: null,
|
|
49004
|
+
access: "view"
|
|
49005
|
+
},
|
|
47251
49006
|
"pipelineOrchestrator.pauseForStorageMigration": {
|
|
47252
49007
|
capName: "pipeline-orchestrator",
|
|
47253
49008
|
capScope: "system",
|
|
@@ -47392,6 +49147,12 @@ Object.freeze({
|
|
|
47392
49147
|
addonId: null,
|
|
47393
49148
|
access: "create"
|
|
47394
49149
|
},
|
|
49150
|
+
"pipelineOrchestrator.startNodeBenchmark": {
|
|
49151
|
+
capName: "pipeline-orchestrator",
|
|
49152
|
+
capScope: "system",
|
|
49153
|
+
addonId: null,
|
|
49154
|
+
access: "create"
|
|
49155
|
+
},
|
|
47395
49156
|
"pipelineOrchestrator.suggestShares": {
|
|
47396
49157
|
capName: "pipeline-orchestrator",
|
|
47397
49158
|
capScope: "system",
|
|
@@ -47410,6 +49171,12 @@ Object.freeze({
|
|
|
47410
49171
|
addonId: null,
|
|
47411
49172
|
access: "create"
|
|
47412
49173
|
},
|
|
49174
|
+
"pipelineRunner.abortNodeBench": {
|
|
49175
|
+
capName: "pipeline-runner",
|
|
49176
|
+
capScope: "system",
|
|
49177
|
+
addonId: null,
|
|
49178
|
+
access: "create"
|
|
49179
|
+
},
|
|
47413
49180
|
"pipelineRunner.attachCamera": {
|
|
47414
49181
|
capName: "pipeline-runner",
|
|
47415
49182
|
capScope: "system",
|
|
@@ -47458,6 +49225,12 @@ Object.freeze({
|
|
|
47458
49225
|
addonId: null,
|
|
47459
49226
|
access: "view"
|
|
47460
49227
|
},
|
|
49228
|
+
"pipelineRunner.getNodeBenchStatus": {
|
|
49229
|
+
capName: "pipeline-runner",
|
|
49230
|
+
capScope: "system",
|
|
49231
|
+
addonId: null,
|
|
49232
|
+
access: "view"
|
|
49233
|
+
},
|
|
47461
49234
|
"pipelineRunner.getParkedTrackFrame": {
|
|
47462
49235
|
capName: "pipeline-runner",
|
|
47463
49236
|
capScope: "system",
|
|
@@ -47500,6 +49273,12 @@ Object.freeze({
|
|
|
47500
49273
|
addonId: null,
|
|
47501
49274
|
access: "create"
|
|
47502
49275
|
},
|
|
49276
|
+
"pipelineRunner.startNodeBench": {
|
|
49277
|
+
capName: "pipeline-runner",
|
|
49278
|
+
capScope: "system",
|
|
49279
|
+
addonId: null,
|
|
49280
|
+
access: "create"
|
|
49281
|
+
},
|
|
47503
49282
|
"plateGallery.assignPlate": {
|
|
47504
49283
|
capName: "plate-gallery",
|
|
47505
49284
|
capScope: "system",
|
|
@@ -52429,6 +54208,11 @@ Object.freeze({
|
|
|
52429
54208
|
form: "single",
|
|
52430
54209
|
optional: false
|
|
52431
54210
|
}],
|
|
54211
|
+
"pipelineAnalytics.addRetrainFrameFromRecording": [{
|
|
54212
|
+
name: "deviceId",
|
|
54213
|
+
form: "single",
|
|
54214
|
+
optional: false
|
|
54215
|
+
}],
|
|
52432
54216
|
"pipelineAnalytics.applyDeviceSettingsPatch": [{
|
|
52433
54217
|
name: "deviceId",
|
|
52434
54218
|
form: "single",
|
|
@@ -52619,6 +54403,11 @@ Object.freeze({
|
|
|
52619
54403
|
form: "single",
|
|
52620
54404
|
optional: false
|
|
52621
54405
|
}],
|
|
54406
|
+
"pipelineAnalytics.proposeRetrainAnnotationsWithLlm": [{
|
|
54407
|
+
name: "deviceId",
|
|
54408
|
+
form: "single",
|
|
54409
|
+
optional: false
|
|
54410
|
+
}],
|
|
52622
54411
|
"pipelineAnalytics.pruneEventsBefore": [{
|
|
52623
54412
|
name: "deviceId",
|
|
52624
54413
|
form: "single",
|