@camstack/addon-provider-tuya 0.2.121 → 0.2.122
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.js
CHANGED
|
@@ -819,7 +819,7 @@ async function discoverDevices(options = {}, binder = createDgramBinder()) {
|
|
|
819
819
|
return [...byId.values()];
|
|
820
820
|
}
|
|
821
821
|
//#endregion
|
|
822
|
-
//#region ../types/dist/event-category-
|
|
822
|
+
//#region ../types/dist/event-category-DaIZi00R.mjs
|
|
823
823
|
var EventCategory = /* @__PURE__ */ function(EventCategory) {
|
|
824
824
|
EventCategory["SystemBoot"] = "system.boot";
|
|
825
825
|
EventCategory["SystemAddonsReady"] = "system.addons-ready";
|
|
@@ -898,6 +898,13 @@ var EventCategory = /* @__PURE__ */ function(EventCategory) {
|
|
|
898
898
|
*/
|
|
899
899
|
EventCategory["AddonLoadFailed"] = "addon.load-failed";
|
|
900
900
|
/**
|
|
901
|
+
* A keychain value was stored or removed (D787). Carries the ref, its
|
|
902
|
+
* owner and the new version — NEVER the value. A process holding the ref
|
|
903
|
+
* drops its cached copy and the owning `BaseAddon` re-resolves its config.
|
|
904
|
+
* Telemetry (D8): a process that misses it still revalidates by version.
|
|
905
|
+
*/
|
|
906
|
+
EventCategory["KeychainChanged"] = "keychain.changed";
|
|
907
|
+
/**
|
|
901
908
|
* Addon recovered from a previous failure. Emitted when an addon
|
|
902
909
|
* transitions from `failed` back to `healthy` (typically via the
|
|
903
910
|
* monitor's auto-retry loop, or after manual `addons.retryLoad`).
|
|
@@ -6190,7 +6197,7 @@ var ZodIssueCode = {
|
|
|
6190
6197
|
var ZodFirstPartyTypeKind;
|
|
6191
6198
|
ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {});
|
|
6192
6199
|
//#endregion
|
|
6193
|
-
//#region ../types/dist/sleep-
|
|
6200
|
+
//#region ../types/dist/sleep-Cr5YOk3m.mjs
|
|
6194
6201
|
/**
|
|
6195
6202
|
* The audio chunk plane's byte format, and the ONE expansion from a coded
|
|
6196
6203
|
* window to float samples (D455).
|
|
@@ -6269,6 +6276,97 @@ function buildAlawTable() {
|
|
|
6269
6276
|
}
|
|
6270
6277
|
buildUlawTable();
|
|
6271
6278
|
buildAlawTable();
|
|
6279
|
+
/** Is this field's stored value a credential? */
|
|
6280
|
+
function isSecretConfigField(field) {
|
|
6281
|
+
if (field.type === "password") return true;
|
|
6282
|
+
return "secret" in field && field.secret === true;
|
|
6283
|
+
}
|
|
6284
|
+
/**
|
|
6285
|
+
* Is this field's value stored in the KEYCHAIN (D787)? Every secret field is,
|
|
6286
|
+
* by its TYPE, unless it opts out with `storage: 'inline'` — never by its name.
|
|
6287
|
+
*/
|
|
6288
|
+
function isKeychainStoredField(field) {
|
|
6289
|
+
if (!isSecretConfigField(field)) return false;
|
|
6290
|
+
if (field.type === "textarea" && field.isJson === true) return false;
|
|
6291
|
+
return !("storage" in field && field.storage === "inline");
|
|
6292
|
+
}
|
|
6293
|
+
/**
|
|
6294
|
+
* What a settings blob holds where a secret used to be.
|
|
6295
|
+
*
|
|
6296
|
+
* A keychain-stored field never holds its value. It holds a self-describing
|
|
6297
|
+
* MARKER, `{"$secret":"secret://…","v":1}` — an object, never a string, so no
|
|
6298
|
+
* code can mistake it for a credential and no form can send it to a camera as
|
|
6299
|
+
* a password. The empty state is `null` / absent, never `''`.
|
|
6300
|
+
*
|
|
6301
|
+
* The same shapes travel to and from the admin UI:
|
|
6302
|
+
*
|
|
6303
|
+
* - read: `hydrateSchema` hands a secret field a {@link SecretFieldView}
|
|
6304
|
+
* (`{ $secret, v, set: true }`) or `null` — the browser learns whether a
|
|
6305
|
+
* value is set, never the value.
|
|
6306
|
+
* - write: an untouched field submits the view back unchanged (KEEP); a typed
|
|
6307
|
+
* value is a plain non-empty string (CHANGE); the Clear button submits
|
|
6308
|
+
* {@link SECRET_CLEAR} (CLEAR). `''`, `null` and the legacy redaction tokens
|
|
6309
|
+
* are KEEP — an empty string is what a defaults-fallback pushes back, and
|
|
6310
|
+
* treating it as "clear" is how a save destroyed a stored credential before.
|
|
6311
|
+
*
|
|
6312
|
+
* Pure and browser-safe.
|
|
6313
|
+
*/
|
|
6314
|
+
var SECRET_CLEAR = { $secretClear: true };
|
|
6315
|
+
/** The `'***'` token D634 redaction writes for non-admins. */
|
|
6316
|
+
var LEGACY_DEVICE_REDACTION = "***";
|
|
6317
|
+
function isRecord$1(value) {
|
|
6318
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
6319
|
+
}
|
|
6320
|
+
function makeSecretMarker(ref) {
|
|
6321
|
+
return {
|
|
6322
|
+
$secret: ref,
|
|
6323
|
+
v: 1
|
|
6324
|
+
};
|
|
6325
|
+
}
|
|
6326
|
+
/** A stored marker: an object whose `$secret` is a non-empty string. */
|
|
6327
|
+
function isSecretMarker(value) {
|
|
6328
|
+
if (!isRecord$1(value)) return false;
|
|
6329
|
+
const ref = value["$secret"];
|
|
6330
|
+
return typeof ref === "string" && ref.length > 0;
|
|
6331
|
+
}
|
|
6332
|
+
function isSecretClear(value) {
|
|
6333
|
+
return isRecord$1(value) && value["$secretClear"] === true;
|
|
6334
|
+
}
|
|
6335
|
+
/**
|
|
6336
|
+
* The UI view of a stored secret field value: a marker becomes "set", inline
|
|
6337
|
+
* plaintext becomes "set (inline)", nothing becomes `null`. A value never
|
|
6338
|
+
* survives this function.
|
|
6339
|
+
*/
|
|
6340
|
+
function toSecretFieldView(stored) {
|
|
6341
|
+
if (isSecretMarker(stored)) return {
|
|
6342
|
+
$secret: stored.$secret,
|
|
6343
|
+
v: 1,
|
|
6344
|
+
set: true
|
|
6345
|
+
};
|
|
6346
|
+
if (typeof stored === "string" && stored.length > 0) return {
|
|
6347
|
+
$secret: null,
|
|
6348
|
+
v: 1,
|
|
6349
|
+
set: true,
|
|
6350
|
+
inline: true
|
|
6351
|
+
};
|
|
6352
|
+
return null;
|
|
6353
|
+
}
|
|
6354
|
+
/**
|
|
6355
|
+
* Classify an incoming value for a secret path. Only a non-empty string that is
|
|
6356
|
+
* not a redaction token sets a value; only {@link SECRET_CLEAR} clears.
|
|
6357
|
+
* Everything else — a marker (ours or anyone's), a UI view, `''`, `null`,
|
|
6358
|
+
* `undefined`, a redaction token, a non-string — keeps what is stored.
|
|
6359
|
+
*/
|
|
6360
|
+
function classifySecretWrite(incoming) {
|
|
6361
|
+
if (isSecretClear(incoming)) return { kind: "clear" };
|
|
6362
|
+
if (typeof incoming !== "string") return { kind: "keep" };
|
|
6363
|
+
if (incoming.length === 0) return { kind: "keep" };
|
|
6364
|
+
if (incoming === "__camstack_redacted__" || incoming === LEGACY_DEVICE_REDACTION) return { kind: "keep" };
|
|
6365
|
+
return {
|
|
6366
|
+
kind: "set",
|
|
6367
|
+
value: incoming
|
|
6368
|
+
};
|
|
6369
|
+
}
|
|
6272
6370
|
Object.fromEntries([
|
|
6273
6371
|
{
|
|
6274
6372
|
id: "overview",
|
|
@@ -6440,33 +6538,19 @@ Object.fromEntries([
|
|
|
6440
6538
|
function isValuelessField(field) {
|
|
6441
6539
|
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";
|
|
6442
6540
|
}
|
|
6443
|
-
|
|
6444
|
-
* Merge a `ConfigUISchema` with a raw `values` record into a
|
|
6445
|
-
* `ConfigUISchemaWithValues`. Used by every `get*Settings` backend endpoint
|
|
6446
|
-
* before returning to the admin UI. Groups are walked recursively.
|
|
6447
|
-
*
|
|
6448
|
-
* For each leaf field:
|
|
6449
|
-
* - structural fields (`separator`, `info`, `button`) pass through unchanged
|
|
6450
|
-
* - other fields get `value = values[key] ?? field.default ?? null`
|
|
6451
|
-
*
|
|
6452
|
-
* Unknown keys in `values` (keys not declared in the schema) are silently
|
|
6453
|
-
* ignored — they don't contribute to the output. Missing keys fall back to
|
|
6454
|
-
* the schema default or `null`. This mirrors the old backend behaviour where
|
|
6455
|
-
* `FormBuilder` rendered `values[key] ?? field.default`.
|
|
6456
|
-
*/
|
|
6457
|
-
function hydrateSchema(schema, values) {
|
|
6541
|
+
function hydrateSchema(schema, values, options = {}) {
|
|
6458
6542
|
return {
|
|
6459
6543
|
...schema.tabs ? { tabs: [...schema.tabs] } : {},
|
|
6460
6544
|
sections: schema.sections.map((section) => ({
|
|
6461
6545
|
...section,
|
|
6462
|
-
fields: section.fields.map((field) => hydrateField(field, values))
|
|
6546
|
+
fields: section.fields.map((field) => hydrateField(field, values, options))
|
|
6463
6547
|
}))
|
|
6464
6548
|
};
|
|
6465
6549
|
}
|
|
6466
|
-
function hydrateField(field, values) {
|
|
6550
|
+
function hydrateField(field, values, options) {
|
|
6467
6551
|
if (isValuelessField(field)) return field;
|
|
6468
6552
|
if (field.type === "group") {
|
|
6469
|
-
const hydratedChildren = field.fields.map((child) => hydrateField(child, values));
|
|
6553
|
+
const hydratedChildren = field.fields.map((child) => hydrateField(child, values, options));
|
|
6470
6554
|
return {
|
|
6471
6555
|
...field,
|
|
6472
6556
|
fields: hydratedChildren
|
|
@@ -6475,7 +6559,7 @@ function hydrateField(field, values) {
|
|
|
6475
6559
|
if (field.type === "sub-tabs") {
|
|
6476
6560
|
const hydratedTabs = field.tabs.map((tab) => ({
|
|
6477
6561
|
...tab,
|
|
6478
|
-
fields: tab.fields.map((child) => hydrateField(child, values))
|
|
6562
|
+
fields: tab.fields.map((child) => hydrateField(child, values, options))
|
|
6479
6563
|
}));
|
|
6480
6564
|
return {
|
|
6481
6565
|
...field,
|
|
@@ -6485,6 +6569,33 @@ function hydrateField(field, values) {
|
|
|
6485
6569
|
const key = field.key;
|
|
6486
6570
|
const storedValue = Object.prototype.hasOwnProperty.call(values, key) ? values[key] : void 0;
|
|
6487
6571
|
const defaultValue = field.default;
|
|
6572
|
+
const asView = (v) => isSecretMarker(v) || options.inlineSecretsAsViews === true && v !== void 0;
|
|
6573
|
+
if (isKeychainStoredField(field) && asView(storedValue)) return {
|
|
6574
|
+
...field,
|
|
6575
|
+
value: toSecretFieldView(storedValue)
|
|
6576
|
+
};
|
|
6577
|
+
if (isKeychainStoredField(field) && options.inlineSecretsAsViews === true) return {
|
|
6578
|
+
...field,
|
|
6579
|
+
value: null
|
|
6580
|
+
};
|
|
6581
|
+
if (field.type === "editable-array" && Array.isArray(storedValue)) {
|
|
6582
|
+
const secretItemKeys = field.itemFields.filter((item) => "key" in item && isKeychainStoredField(item)).map((item) => "key" in item ? item.key : "");
|
|
6583
|
+
if (secretItemKeys.length > 0) {
|
|
6584
|
+
const rows = storedValue.map((row) => {
|
|
6585
|
+
if (row === null || typeof row !== "object" || Array.isArray(row)) return row;
|
|
6586
|
+
const out = { ...row };
|
|
6587
|
+
for (const k of secretItemKeys) {
|
|
6588
|
+
const v = Reflect.get(row, k);
|
|
6589
|
+
if (asView(v)) out[k] = toSecretFieldView(v);
|
|
6590
|
+
}
|
|
6591
|
+
return out;
|
|
6592
|
+
});
|
|
6593
|
+
return {
|
|
6594
|
+
...field,
|
|
6595
|
+
value: rows
|
|
6596
|
+
};
|
|
6597
|
+
}
|
|
6598
|
+
}
|
|
6488
6599
|
if (field.multiple) {
|
|
6489
6600
|
const stored = Array.isArray(storedValue) ? storedValue : storedValue !== void 0 && storedValue !== null ? [storedValue] : [];
|
|
6490
6601
|
const itemFallback = field.multiple.itemDefault !== void 0 ? field.multiple.itemDefault : defaultValue !== void 0 ? defaultValue : typeOf(field) === "string" ? "" : null;
|
|
@@ -6727,6 +6838,431 @@ function projectStore(store, perNodeKeys, nodeId) {
|
|
|
6727
6838
|
}
|
|
6728
6839
|
return out;
|
|
6729
6840
|
}
|
|
6841
|
+
var GLOBAL_SCOPE = { kind: "global" };
|
|
6842
|
+
/** The scope every addon-wide (not per-node, not per-device) setting lives in. */
|
|
6843
|
+
function globalSecretScope() {
|
|
6844
|
+
return GLOBAL_SCOPE;
|
|
6845
|
+
}
|
|
6846
|
+
function encodeSegment(value) {
|
|
6847
|
+
return encodeURIComponent(value);
|
|
6848
|
+
}
|
|
6849
|
+
/**
|
|
6850
|
+
* The field path of a value inside an array item, addressed by the item's id:
|
|
6851
|
+
* `arrayItemFieldPath('providers', 'authentik', 'clientSecret')` →
|
|
6852
|
+
* `providers[authentik].clientSecret`.
|
|
6853
|
+
*/
|
|
6854
|
+
function arrayItemFieldPath(arrayKey, itemId, fieldKey) {
|
|
6855
|
+
return `${arrayKey}[${encodeSegment(itemId)}].${fieldKey}`;
|
|
6856
|
+
}
|
|
6857
|
+
/** A write to a secret path could not be stored in the keychain, so it was refused. */
|
|
6858
|
+
var KeychainWriteRefusedError = class extends Error {
|
|
6859
|
+
fieldPath;
|
|
6860
|
+
constructor(fieldPath, cause) {
|
|
6861
|
+
super(`secret "${fieldPath}" was not saved: the keychain could not store it (${cause instanceof Error ? cause.message : String(cause)}). Nothing was written.`);
|
|
6862
|
+
this.fieldPath = fieldPath;
|
|
6863
|
+
this.name = "KeychainWriteRefusedError";
|
|
6864
|
+
}
|
|
6865
|
+
};
|
|
6866
|
+
var KEEP = { kind: "keep" };
|
|
6867
|
+
function isRecord(value) {
|
|
6868
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
6869
|
+
}
|
|
6870
|
+
function defaultMintId() {
|
|
6871
|
+
return globalThis.crypto.randomUUID();
|
|
6872
|
+
}
|
|
6873
|
+
/** Every marker ref anywhere under `value`. */
|
|
6874
|
+
function collectSecretMarkerRefs(value, out = []) {
|
|
6875
|
+
if (isSecretMarker(value)) {
|
|
6876
|
+
out.push(value.$secret);
|
|
6877
|
+
return out;
|
|
6878
|
+
}
|
|
6879
|
+
if (Array.isArray(value)) for (const item of value) collectSecretMarkerRefs(item, out);
|
|
6880
|
+
else if (isRecord(value)) for (const child of Object.values(value)) collectSecretMarkerRefs(child, out);
|
|
6881
|
+
return out;
|
|
6882
|
+
}
|
|
6883
|
+
async function storedValueEquals(secrets, marker, candidate) {
|
|
6884
|
+
const resolved = (await secrets.resolve([marker.$secret]))[marker.$secret];
|
|
6885
|
+
return resolved?.kind === "value" && resolved.value === candidate;
|
|
6886
|
+
}
|
|
6887
|
+
async function writeLeaf(ctx, incoming, stored, fieldPath) {
|
|
6888
|
+
const intent = classifySecretWrite(incoming);
|
|
6889
|
+
const ref = ctx.secrets.ref(ctx.scope, fieldPath);
|
|
6890
|
+
const storedIsOurs = isSecretMarker(stored) && stored.$secret === ref;
|
|
6891
|
+
if (intent.kind === "keep") return KEEP;
|
|
6892
|
+
if (intent.kind === "set" && !ctx.operatorWrite && typeof stored === "string" && stored === intent.value) return KEEP;
|
|
6893
|
+
if (intent.kind === "clear") {
|
|
6894
|
+
if (storedIsOurs) ctx.deletes.push(ref);
|
|
6895
|
+
return {
|
|
6896
|
+
kind: "value",
|
|
6897
|
+
value: null
|
|
6898
|
+
};
|
|
6899
|
+
}
|
|
6900
|
+
if (storedIsOurs && await storedValueEquals(ctx.secrets, stored, intent.value)) return {
|
|
6901
|
+
kind: "value",
|
|
6902
|
+
value: stored
|
|
6903
|
+
};
|
|
6904
|
+
try {
|
|
6905
|
+
await ctx.secrets.put(ref, intent.value);
|
|
6906
|
+
} catch (err) {
|
|
6907
|
+
throw new KeychainWriteRefusedError(fieldPath, err);
|
|
6908
|
+
}
|
|
6909
|
+
return {
|
|
6910
|
+
kind: "value",
|
|
6911
|
+
value: makeSecretMarker(ref)
|
|
6912
|
+
};
|
|
6913
|
+
}
|
|
6914
|
+
/** Apply a member result onto `out`: KEEP restores the stored member, or removes it. */
|
|
6915
|
+
function applyMember(out, key, result, storedParent) {
|
|
6916
|
+
if (result.kind === "value") {
|
|
6917
|
+
out[key] = result.value;
|
|
6918
|
+
return;
|
|
6919
|
+
}
|
|
6920
|
+
if (Object.prototype.hasOwnProperty.call(storedParent, key)) out[key] = storedParent[key];
|
|
6921
|
+
else delete out[key];
|
|
6922
|
+
}
|
|
6923
|
+
async function writeMembers(ctx, children, incoming, stored, pathOf) {
|
|
6924
|
+
const out = { ...incoming };
|
|
6925
|
+
for (const [member, node] of children) applyMember(out, member, await writeNode(ctx, node, incoming[member], stored[member], pathOf(member)), stored);
|
|
6926
|
+
return out;
|
|
6927
|
+
}
|
|
6928
|
+
function rowId(row, idKey) {
|
|
6929
|
+
const raw = row[idKey];
|
|
6930
|
+
if (typeof raw === "string" && raw.length > 0) return raw;
|
|
6931
|
+
if (typeof raw === "number" && Number.isFinite(raw)) return String(raw);
|
|
6932
|
+
return null;
|
|
6933
|
+
}
|
|
6934
|
+
async function writeArray(ctx, node, incoming, stored, fieldPath) {
|
|
6935
|
+
const storedRows = Array.isArray(stored) ? stored.filter(isRecord) : [];
|
|
6936
|
+
if (!Array.isArray(incoming)) {
|
|
6937
|
+
ctx.deletes.push(...collectSecretMarkerRefs(storedRows));
|
|
6938
|
+
return {
|
|
6939
|
+
kind: "value",
|
|
6940
|
+
value: incoming
|
|
6941
|
+
};
|
|
6942
|
+
}
|
|
6943
|
+
const storedById = /* @__PURE__ */ new Map();
|
|
6944
|
+
for (const row of storedRows) {
|
|
6945
|
+
const id = rowId(row, node.idKey);
|
|
6946
|
+
if (id !== null) storedById.set(id, row);
|
|
6947
|
+
}
|
|
6948
|
+
const kept = /* @__PURE__ */ new Set();
|
|
6949
|
+
const rows = [];
|
|
6950
|
+
for (const row of incoming) {
|
|
6951
|
+
if (!isRecord(row)) {
|
|
6952
|
+
rows.push(row);
|
|
6953
|
+
continue;
|
|
6954
|
+
}
|
|
6955
|
+
const id = rowId(row, node.idKey) ?? ctx.mintId();
|
|
6956
|
+
kept.add(id);
|
|
6957
|
+
const withId = {
|
|
6958
|
+
...row,
|
|
6959
|
+
[node.idKey]: row[node.idKey] ?? id
|
|
6960
|
+
};
|
|
6961
|
+
if (rowId(withId, node.idKey) === null) withId[node.idKey] = id;
|
|
6962
|
+
const storedRow = storedById.get(id) ?? {};
|
|
6963
|
+
rows.push(await writeMembers(ctx, node.item, withId, storedRow, (member) => arrayItemFieldPath(fieldPath, id, member)));
|
|
6964
|
+
}
|
|
6965
|
+
for (const [id, row] of storedById) if (!kept.has(id)) ctx.deletes.push(...collectSecretMarkerRefs(row));
|
|
6966
|
+
return {
|
|
6967
|
+
kind: "value",
|
|
6968
|
+
value: rows
|
|
6969
|
+
};
|
|
6970
|
+
}
|
|
6971
|
+
async function writeNode(ctx, node, incoming, stored, fieldPath) {
|
|
6972
|
+
switch (node.kind) {
|
|
6973
|
+
case "leaf": return writeLeaf(ctx, incoming, stored, fieldPath);
|
|
6974
|
+
case "array": return writeArray(ctx, node, incoming, stored, fieldPath);
|
|
6975
|
+
case "object": {
|
|
6976
|
+
if (!isRecord(incoming)) {
|
|
6977
|
+
if (incoming === void 0) return KEEP;
|
|
6978
|
+
ctx.deletes.push(...collectSecretMarkerRefs(stored));
|
|
6979
|
+
return {
|
|
6980
|
+
kind: "value",
|
|
6981
|
+
value: incoming
|
|
6982
|
+
};
|
|
6983
|
+
}
|
|
6984
|
+
const storedObj = isRecord(stored) ? stored : {};
|
|
6985
|
+
return {
|
|
6986
|
+
kind: "value",
|
|
6987
|
+
value: await writeMembers(ctx, node.children, incoming, storedObj, (m) => `${fieldPath}.${m}`)
|
|
6988
|
+
};
|
|
6989
|
+
}
|
|
6990
|
+
}
|
|
6991
|
+
}
|
|
6992
|
+
/** Split a perNode-scoped key (`key@nodeId`). */
|
|
6993
|
+
function splitNodeKey(key) {
|
|
6994
|
+
const at = key.indexOf("@");
|
|
6995
|
+
return at <= 0 ? {
|
|
6996
|
+
base: key,
|
|
6997
|
+
nodeId: null
|
|
6998
|
+
} : {
|
|
6999
|
+
base: key.slice(0, at),
|
|
7000
|
+
nodeId: key.slice(at + 1)
|
|
7001
|
+
};
|
|
7002
|
+
}
|
|
7003
|
+
/** Rewrite a settings patch so no secret value reaches the blob. See the file doc. */
|
|
7004
|
+
async function transformSecretWrite(input) {
|
|
7005
|
+
const deletes = [];
|
|
7006
|
+
const base = {
|
|
7007
|
+
secrets: input.secrets,
|
|
7008
|
+
mintId: input.mintId ?? defaultMintId,
|
|
7009
|
+
deletes,
|
|
7010
|
+
operatorWrite: input.operatorWrite === true
|
|
7011
|
+
};
|
|
7012
|
+
const out = {};
|
|
7013
|
+
for (const [key, incoming] of Object.entries(input.patch)) {
|
|
7014
|
+
const { base: baseKey, nodeId } = splitNodeKey(key);
|
|
7015
|
+
const node = input.tree.get(baseKey);
|
|
7016
|
+
if (node === void 0) {
|
|
7017
|
+
out[key] = incoming;
|
|
7018
|
+
continue;
|
|
7019
|
+
}
|
|
7020
|
+
const scope = nodeId !== null && nodeId.length > 0 ? {
|
|
7021
|
+
kind: "node",
|
|
7022
|
+
nodeId
|
|
7023
|
+
} : input.scope ?? globalSecretScope();
|
|
7024
|
+
const result = await writeNode({
|
|
7025
|
+
...base,
|
|
7026
|
+
scope
|
|
7027
|
+
}, node, incoming, input.stored[key], baseKey);
|
|
7028
|
+
if (result.kind === "value") out[key] = result.value;
|
|
7029
|
+
}
|
|
7030
|
+
return {
|
|
7031
|
+
patch: out,
|
|
7032
|
+
afterWrite: async () => {
|
|
7033
|
+
if (deletes.length === 0) return { orphaned: [] };
|
|
7034
|
+
try {
|
|
7035
|
+
await input.secrets.delete([...new Set(deletes)]);
|
|
7036
|
+
return { orphaned: [] };
|
|
7037
|
+
} catch {
|
|
7038
|
+
return { orphaned: [...new Set(deletes)] };
|
|
7039
|
+
}
|
|
7040
|
+
}
|
|
7041
|
+
};
|
|
7042
|
+
}
|
|
7043
|
+
/**
|
|
7044
|
+
* Replace every marker in `value` with its keychain value. Returns the SAME
|
|
7045
|
+
* reference when there is no marker (no allocation, no keychain call).
|
|
7046
|
+
*/
|
|
7047
|
+
async function resolveSecretMarkers(value, secrets) {
|
|
7048
|
+
const refs = collectSecretMarkerRefs(value);
|
|
7049
|
+
if (refs.length === 0) return {
|
|
7050
|
+
value,
|
|
7051
|
+
unresolved: []
|
|
7052
|
+
};
|
|
7053
|
+
const answers = await secrets.resolve(refs);
|
|
7054
|
+
const unresolved = [];
|
|
7055
|
+
for (const ref of new Set(refs)) {
|
|
7056
|
+
const answer = answers[ref];
|
|
7057
|
+
if (answer === void 0) unresolved.push({
|
|
7058
|
+
ref,
|
|
7059
|
+
reason: "not-initialized"
|
|
7060
|
+
});
|
|
7061
|
+
else if (answer.kind === "unavailable") unresolved.push({
|
|
7062
|
+
ref,
|
|
7063
|
+
reason: answer.reason
|
|
7064
|
+
});
|
|
7065
|
+
else if (answer.kind === "missing" || answer.kind === "forbidden") unresolved.push({
|
|
7066
|
+
ref,
|
|
7067
|
+
reason: answer.kind
|
|
7068
|
+
});
|
|
7069
|
+
}
|
|
7070
|
+
const substitute = (v) => {
|
|
7071
|
+
if (isSecretMarker(v)) {
|
|
7072
|
+
const answer = answers[v.$secret];
|
|
7073
|
+
return answer?.kind === "value" ? {
|
|
7074
|
+
keep: true,
|
|
7075
|
+
value: answer.value
|
|
7076
|
+
} : {
|
|
7077
|
+
keep: false,
|
|
7078
|
+
value: void 0
|
|
7079
|
+
};
|
|
7080
|
+
}
|
|
7081
|
+
if (Array.isArray(v)) {
|
|
7082
|
+
const items = [];
|
|
7083
|
+
for (const item of v) {
|
|
7084
|
+
const s = substitute(item);
|
|
7085
|
+
if (s.keep) items.push(s.value);
|
|
7086
|
+
}
|
|
7087
|
+
return {
|
|
7088
|
+
keep: true,
|
|
7089
|
+
value: items
|
|
7090
|
+
};
|
|
7091
|
+
}
|
|
7092
|
+
if (isRecord(v)) {
|
|
7093
|
+
const out = {};
|
|
7094
|
+
for (const [k, child] of Object.entries(v)) {
|
|
7095
|
+
const s = substitute(child);
|
|
7096
|
+
if (s.keep) out[k] = s.value;
|
|
7097
|
+
}
|
|
7098
|
+
return {
|
|
7099
|
+
keep: true,
|
|
7100
|
+
value: out
|
|
7101
|
+
};
|
|
7102
|
+
}
|
|
7103
|
+
return {
|
|
7104
|
+
keep: true,
|
|
7105
|
+
value: v
|
|
7106
|
+
};
|
|
7107
|
+
};
|
|
7108
|
+
return {
|
|
7109
|
+
value: substitute(value).value,
|
|
7110
|
+
unresolved
|
|
7111
|
+
};
|
|
7112
|
+
}
|
|
7113
|
+
function touchesTree(tree, patch) {
|
|
7114
|
+
if (tree.size === 0) return false;
|
|
7115
|
+
for (const key of Object.keys(patch)) {
|
|
7116
|
+
const at = key.indexOf("@");
|
|
7117
|
+
if (tree.has(at > 0 ? key.slice(0, at) : key)) return true;
|
|
7118
|
+
}
|
|
7119
|
+
return false;
|
|
7120
|
+
}
|
|
7121
|
+
/** The blob as stored now; a failed read REFUSES the write instead of guessing. */
|
|
7122
|
+
async function readStoredAddonBlob(raw) {
|
|
7123
|
+
const threeWay = raw.readAddonStoreResult;
|
|
7124
|
+
if (threeWay === void 0) return raw.readAddonStore();
|
|
7125
|
+
const result = await threeWay.call(raw);
|
|
7126
|
+
if (result.kind === "failed") throw new Error(`settings write refused: the stored blob could not be read (${result.error})`);
|
|
7127
|
+
return result.kind === "missing" ? {} : result.value;
|
|
7128
|
+
}
|
|
7129
|
+
function createSecretAwareSettings(raw, opts) {
|
|
7130
|
+
const chains = /* @__PURE__ */ new Map();
|
|
7131
|
+
const serialize = (key, fn) => {
|
|
7132
|
+
const next = (chains.get(key) ?? Promise.resolve()).then(fn, fn);
|
|
7133
|
+
const tail = next.catch(() => void 0);
|
|
7134
|
+
chains.set(key, tail);
|
|
7135
|
+
tail.then(() => {
|
|
7136
|
+
if (chains.get(key) === tail) chains.delete(key);
|
|
7137
|
+
});
|
|
7138
|
+
return next;
|
|
7139
|
+
};
|
|
7140
|
+
const write = async (chainKey, tree, scope, patch, readStored, rawWrite) => {
|
|
7141
|
+
if (!touchesTree(tree, patch)) return rawWrite(patch);
|
|
7142
|
+
return serialize(chainKey, async () => {
|
|
7143
|
+
const stored = await readStored();
|
|
7144
|
+
const result = await transformSecretWrite({
|
|
7145
|
+
tree,
|
|
7146
|
+
secrets: opts.secrets,
|
|
7147
|
+
patch,
|
|
7148
|
+
stored,
|
|
7149
|
+
...scope !== void 0 ? { scope } : {},
|
|
7150
|
+
operatorWrite: opts.isOperatorWrite?.() === true
|
|
7151
|
+
});
|
|
7152
|
+
if (Object.keys(result.patch).length > 0) await rawWrite(result.patch);
|
|
7153
|
+
const { orphaned } = await result.afterWrite();
|
|
7154
|
+
if (orphaned.length > 0) opts.onOrphaned(orphaned);
|
|
7155
|
+
});
|
|
7156
|
+
};
|
|
7157
|
+
const wrapped = {
|
|
7158
|
+
writeAddonStore: (patch) => write("addon", opts.addonTree(), void 0, patch, () => readStoredAddonBlob(raw), (p) => raw.writeAddonStore(p)),
|
|
7159
|
+
writeDeviceStore: (deviceId, patch) => write(`device:${deviceId}`, opts.deviceTree(), {
|
|
7160
|
+
kind: "device",
|
|
7161
|
+
deviceId
|
|
7162
|
+
}, patch, () => raw.readDeviceStore(deviceId), (p) => raw.writeDeviceStore(deviceId, p))
|
|
7163
|
+
};
|
|
7164
|
+
return new Proxy(raw, { get(target, prop, receiver) {
|
|
7165
|
+
if (prop === "writeAddonStore") return wrapped.writeAddonStore;
|
|
7166
|
+
if (prop === "writeDeviceStore") return wrapped.writeDeviceStore;
|
|
7167
|
+
const value = Reflect.get(target, prop, receiver);
|
|
7168
|
+
return typeof value === "function" ? value.bind(target) : value;
|
|
7169
|
+
} });
|
|
7170
|
+
}
|
|
7171
|
+
/** The context the addon sees: identical, except that its settings writes are secret-aware. */
|
|
7172
|
+
function withSecretAwareSettings(context, opts) {
|
|
7173
|
+
const raw = context.settings;
|
|
7174
|
+
if (raw === void 0) return context;
|
|
7175
|
+
const settings = createSecretAwareSettings(raw, opts);
|
|
7176
|
+
return new Proxy(context, { get(target, prop, receiver) {
|
|
7177
|
+
if (prop === "settings") return settings;
|
|
7178
|
+
return Reflect.get(target, prop, receiver);
|
|
7179
|
+
} });
|
|
7180
|
+
}
|
|
7181
|
+
var LEAF = { kind: "leaf" };
|
|
7182
|
+
var DEFAULT_ITEM_ID_KEY = "id";
|
|
7183
|
+
function collectFields(fields, out) {
|
|
7184
|
+
for (const field of fields) {
|
|
7185
|
+
if (field.type === "group") {
|
|
7186
|
+
collectFields(field.fields, out);
|
|
7187
|
+
continue;
|
|
7188
|
+
}
|
|
7189
|
+
if (field.type === "sub-tabs") {
|
|
7190
|
+
for (const tab of field.tabs) collectFields(tab.fields, out);
|
|
7191
|
+
continue;
|
|
7192
|
+
}
|
|
7193
|
+
if (field.type === "editable-array") {
|
|
7194
|
+
const item = /* @__PURE__ */ new Map();
|
|
7195
|
+
for (const itemField of field.itemFields) if ("key" in itemField && isKeychainStoredField(itemField)) item.set(itemField.key, LEAF);
|
|
7196
|
+
if (item.size > 0) out.set(field.key, {
|
|
7197
|
+
kind: "array",
|
|
7198
|
+
idKey: field.itemIdKey ?? DEFAULT_ITEM_ID_KEY,
|
|
7199
|
+
item
|
|
7200
|
+
});
|
|
7201
|
+
continue;
|
|
7202
|
+
}
|
|
7203
|
+
if (!("key" in field) || typeof field.key !== "string") continue;
|
|
7204
|
+
if (isKeychainStoredField(field)) out.set(field.key, LEAF);
|
|
7205
|
+
}
|
|
7206
|
+
}
|
|
7207
|
+
/** The secret tree a settings schema declares. */
|
|
7208
|
+
function secretTreeFromSchema(schema) {
|
|
7209
|
+
const out = /* @__PURE__ */ new Map();
|
|
7210
|
+
if (schema === null) return out;
|
|
7211
|
+
for (const section of schema.sections) collectFields(section.fields, out);
|
|
7212
|
+
return out;
|
|
7213
|
+
}
|
|
7214
|
+
/** Parse `a.b[id].c` into segments; throws on a malformed path (a declaration bug). */
|
|
7215
|
+
function parseSecretStatePath(path) {
|
|
7216
|
+
const segments = [];
|
|
7217
|
+
for (const raw of path.split(".")) {
|
|
7218
|
+
const m = /^([^[\]]+)(?:\[([^[\]]+)\])?$/.exec(raw);
|
|
7219
|
+
if (m === null || m[1] === void 0) throw new Error(`secretStatePaths: malformed path "${path}"`);
|
|
7220
|
+
segments.push(m[2] !== void 0 ? {
|
|
7221
|
+
key: m[1],
|
|
7222
|
+
idKey: m[2]
|
|
7223
|
+
} : { key: m[1] });
|
|
7224
|
+
}
|
|
7225
|
+
if (segments.length === 0) throw new Error(`secretStatePaths: empty path`);
|
|
7226
|
+
if (segments[segments.length - 1]?.idKey !== void 0) throw new Error(`secretStatePaths: "${path}" ends on an array — name the member that is secret`);
|
|
7227
|
+
return segments;
|
|
7228
|
+
}
|
|
7229
|
+
function insert(into, segments) {
|
|
7230
|
+
const [head, ...rest] = segments;
|
|
7231
|
+
if (head === void 0) return;
|
|
7232
|
+
if (rest.length === 0) {
|
|
7233
|
+
into.set(head.key, LEAF);
|
|
7234
|
+
return;
|
|
7235
|
+
}
|
|
7236
|
+
const existing = into.get(head.key);
|
|
7237
|
+
if (head.idKey !== void 0) {
|
|
7238
|
+
const item = new Map(existing?.kind === "array" ? existing.item : []);
|
|
7239
|
+
insert(item, rest);
|
|
7240
|
+
into.set(head.key, {
|
|
7241
|
+
kind: "array",
|
|
7242
|
+
idKey: head.idKey,
|
|
7243
|
+
item
|
|
7244
|
+
});
|
|
7245
|
+
return;
|
|
7246
|
+
}
|
|
7247
|
+
const children = new Map(existing?.kind === "object" ? existing.children : []);
|
|
7248
|
+
insert(children, rest);
|
|
7249
|
+
into.set(head.key, {
|
|
7250
|
+
kind: "object",
|
|
7251
|
+
children
|
|
7252
|
+
});
|
|
7253
|
+
}
|
|
7254
|
+
/** Add hidden-state paths (`secretStatePaths`) to a schema-derived tree. */
|
|
7255
|
+
function mergeSecretStatePaths(tree, paths) {
|
|
7256
|
+
if (paths.length === 0) return tree;
|
|
7257
|
+
const out = new Map(tree);
|
|
7258
|
+
for (const path of paths) insert(out, parseSecretStatePath(path));
|
|
7259
|
+
return out;
|
|
7260
|
+
}
|
|
7261
|
+
/** First retry of a secret the keychain could not serve; doubles to {@link SECRET_RETRY_MAX_MS}. */
|
|
7262
|
+
var SECRET_RETRY_FIRST_MS = 5e3;
|
|
7263
|
+
var SECRET_RETRY_MAX_MS = 5 * 6e4;
|
|
7264
|
+
/** Coalesces a burst of `keychain.changed` events into one re-resolve. */
|
|
7265
|
+
var SECRET_CHANGE_DEBOUNCE_MS = 250;
|
|
6730
7266
|
/**
|
|
6731
7267
|
* Base class for CamStack addons. Eliminates settings boilerplate:
|
|
6732
7268
|
*
|
|
@@ -6796,6 +7332,25 @@ var BaseAddon = class {
|
|
|
6796
7332
|
settingsStoreReady = false;
|
|
6797
7333
|
/** Default config values. Provided via constructor. */
|
|
6798
7334
|
defaults;
|
|
7335
|
+
/**
|
|
7336
|
+
* Hidden-state paths that hold secrets (D787) — values the addon writes
|
|
7337
|
+
* itself (`updateGlobalSettings`, `state()`) that no form field declares.
|
|
7338
|
+
* Stored in the keychain exactly like a `password` field. Syntax:
|
|
7339
|
+
* `'snapshotSigningKey'`, `'identity.pincode'`, `'tokens[userId].accessToken'`
|
|
7340
|
+
* (`key[<id field>]` addresses array items by id, never by index).
|
|
7341
|
+
*/
|
|
7342
|
+
secretStatePaths = [];
|
|
7343
|
+
_addonSecretTree = null;
|
|
7344
|
+
_deviceSecretTree = null;
|
|
7345
|
+
/** Refs the last resolved config pointed at — a change to one re-resolves. */
|
|
7346
|
+
_configSecretRefs = /* @__PURE__ */ new Set();
|
|
7347
|
+
_unresolvedSecrets = [];
|
|
7348
|
+
_secretRetryTimer = null;
|
|
7349
|
+
_secretRetryDelayMs = SECRET_RETRY_FIRST_MS;
|
|
7350
|
+
_secretChangeTimer = null;
|
|
7351
|
+
_secretChangeUnsub = null;
|
|
7352
|
+
/** >0 while an OPERATOR's settings write is being applied. */
|
|
7353
|
+
_operatorWriteDepth = 0;
|
|
6799
7354
|
constructor(defaults) {
|
|
6800
7355
|
this.defaults = defaults;
|
|
6801
7356
|
this._config = { ...defaults };
|
|
@@ -6831,8 +7386,18 @@ var BaseAddon = class {
|
|
|
6831
7386
|
return this._config;
|
|
6832
7387
|
}
|
|
6833
7388
|
async initialize(context) {
|
|
6834
|
-
|
|
7389
|
+
const secrets = context.secrets;
|
|
7390
|
+
this._ctx = secrets !== void 0 ? withSecretAwareSettings(context, {
|
|
7391
|
+
secrets,
|
|
7392
|
+
addonTree: () => this.addonSecretTree(),
|
|
7393
|
+
deviceTree: () => this.deviceSecretTree(),
|
|
7394
|
+
onOrphaned: (refs) => context.logger.warn("keychain refs dropped by a settings write could not be deleted", { meta: { refs: [...refs] } }),
|
|
7395
|
+
isOperatorWrite: () => this._operatorWriteDepth > 0
|
|
7396
|
+
}) : context;
|
|
6835
7397
|
await this.resolveConfig();
|
|
7398
|
+
if (secrets !== void 0) this._secretChangeUnsub = secrets.onChange((ref) => {
|
|
7399
|
+
if (this._configSecretRefs.has(ref)) this.scheduleSecretReresolve(SECRET_CHANGE_DEBOUNCE_MS);
|
|
7400
|
+
});
|
|
6836
7401
|
const result = await this.onInitialize();
|
|
6837
7402
|
this.emitLifecycle(EventCategory.AddonStarted);
|
|
6838
7403
|
const normalized = normalizeAddonInitResult(result);
|
|
@@ -6865,6 +7430,12 @@ var BaseAddon = class {
|
|
|
6865
7430
|
*/
|
|
6866
7431
|
async onHubReachable() {}
|
|
6867
7432
|
async shutdown() {
|
|
7433
|
+
this._secretChangeUnsub?.();
|
|
7434
|
+
this._secretChangeUnsub = null;
|
|
7435
|
+
if (this._secretRetryTimer !== null) clearTimeout(this._secretRetryTimer);
|
|
7436
|
+
if (this._secretChangeTimer !== null) clearTimeout(this._secretChangeTimer);
|
|
7437
|
+
this._secretRetryTimer = null;
|
|
7438
|
+
this._secretChangeTimer = null;
|
|
6868
7439
|
this.emitLifecycle(EventCategory.AddonStopped);
|
|
6869
7440
|
if (this.autoEmitReadiness) this.emitReadinessForProviders("down");
|
|
6870
7441
|
await this.onShutdown();
|
|
@@ -6943,7 +7514,7 @@ var BaseAddon = class {
|
|
|
6943
7514
|
return hydrateSchema(schema, overlay ? {
|
|
6944
7515
|
...projected,
|
|
6945
7516
|
...overlay
|
|
6946
|
-
} : projected);
|
|
7517
|
+
} : projected, { inlineSecretsAsViews: true });
|
|
6947
7518
|
}
|
|
6948
7519
|
/**
|
|
6949
7520
|
* The integration-level view of this addon's settings: exactly the sections
|
|
@@ -6992,7 +7563,7 @@ var BaseAddon = class {
|
|
|
6992
7563
|
return hydrateSchema({
|
|
6993
7564
|
...schema,
|
|
6994
7565
|
sections
|
|
6995
|
-
}, projected);
|
|
7566
|
+
}, projected, { inlineSecretsAsViews: true });
|
|
6996
7567
|
}
|
|
6997
7568
|
/**
|
|
6998
7569
|
* The raw addon store PROJECTED onto the target node's bare per-node keys:
|
|
@@ -7046,18 +7617,50 @@ var BaseAddon = class {
|
|
|
7046
7617
|
value: result.value[key]
|
|
7047
7618
|
};
|
|
7048
7619
|
}
|
|
7620
|
+
/**
|
|
7621
|
+
* The OPERATOR's write — a settings form or an admin API call, dispatched by
|
|
7622
|
+
* the kernel. Identical to {@link updateGlobalSettings}, except that a secret
|
|
7623
|
+
* the operator sends is stored as sent even when it equals a pre-keychain
|
|
7624
|
+
* inline value: the operator re-entering a password is a change, an addon
|
|
7625
|
+
* writing back what it read is not (D787).
|
|
7626
|
+
*/
|
|
7627
|
+
async updateGlobalSettingsAsOperator(patch, nodeId) {
|
|
7628
|
+
this._operatorWriteDepth++;
|
|
7629
|
+
try {
|
|
7630
|
+
await this.applyGlobalPatch(patch, nodeId);
|
|
7631
|
+
} finally {
|
|
7632
|
+
this._operatorWriteDepth--;
|
|
7633
|
+
}
|
|
7634
|
+
}
|
|
7049
7635
|
async updateGlobalSettings(patch, nodeId) {
|
|
7636
|
+
await this.applyGlobalPatch(patch, nodeId);
|
|
7637
|
+
}
|
|
7638
|
+
/**
|
|
7639
|
+
* REMOVE stored secrets — their keychain values and their markers (D787).
|
|
7640
|
+
*
|
|
7641
|
+
* Writing `''` to a secret field KEEPS what is stored (an empty string is
|
|
7642
|
+
* what a defaults fallback writes back, and it must never destroy a
|
|
7643
|
+
* credential), so code that means "forget this token" says so here. Without
|
|
7644
|
+
* a keychain (an older kernel) it writes `''`, as such code always did.
|
|
7645
|
+
*/
|
|
7646
|
+
async clearSecrets(keys, nodeId) {
|
|
7647
|
+
const tree = this.addonSecretTree();
|
|
7648
|
+
const keychain = this._ctx?.secrets !== void 0;
|
|
7649
|
+
const patch = {};
|
|
7650
|
+
for (const key of keys) patch[key] = keychain && tree.has(key) ? SECRET_CLEAR : "";
|
|
7651
|
+
await this.applyGlobalPatch(patch, nodeId);
|
|
7652
|
+
}
|
|
7653
|
+
async applyGlobalPatch(barePatch, nodeId) {
|
|
7050
7654
|
const keys = this.perNodeKeys();
|
|
7051
7655
|
const localNode = normalizeNodeId(this._ctx?.kernel?.localNodeId);
|
|
7052
7656
|
const target = normalizeNodeId(nodeId ?? this._ctx?.kernel?.localNodeId);
|
|
7053
|
-
const barePatch = patch;
|
|
7054
7657
|
const scoped = keys.size > 0 ? scopePatch(barePatch, keys, target) : barePatch;
|
|
7055
7658
|
await this._ctx?.settings?.writeAddonStore(scoped);
|
|
7056
7659
|
if (target !== localNode) return;
|
|
7057
7660
|
await this.resolveConfig();
|
|
7058
7661
|
await this.onConfigChanged();
|
|
7059
7662
|
this.emitLifecycle(EventCategory.AddonUpdated, { level: "global" });
|
|
7060
|
-
this.maybeAutoRestart(
|
|
7663
|
+
this.maybeAutoRestart(Object.keys(barePatch), this.globalSettingsSchema());
|
|
7061
7664
|
}
|
|
7062
7665
|
/**
|
|
7063
7666
|
* The set of field keys the global settings schema declares `perNode: true`
|
|
@@ -7082,7 +7685,7 @@ var BaseAddon = class {
|
|
|
7082
7685
|
* time to return its response before the addon is torn down and
|
|
7083
7686
|
* re-initialised by `AddonRegistryService.restartAddon`.
|
|
7084
7687
|
*/
|
|
7085
|
-
maybeAutoRestart(
|
|
7688
|
+
maybeAutoRestart(patchKeys, schema) {
|
|
7086
7689
|
if (!schema) return;
|
|
7087
7690
|
const restartKeys = /* @__PURE__ */ new Set();
|
|
7088
7691
|
for (const section of schema.sections) for (const field of section.fields) {
|
|
@@ -7090,13 +7693,13 @@ var BaseAddon = class {
|
|
|
7090
7693
|
if (field.requiresRestart) restartKeys.add(field.key);
|
|
7091
7694
|
}
|
|
7092
7695
|
if (restartKeys.size === 0) return;
|
|
7093
|
-
if (!
|
|
7696
|
+
if (!patchKeys.some((k) => restartKeys.has(k))) return;
|
|
7094
7697
|
const ctx = this._ctx;
|
|
7095
7698
|
if (!ctx) return;
|
|
7096
7699
|
const addonId = ctx.id;
|
|
7097
7700
|
setImmediate(() => {
|
|
7098
7701
|
ctx.api.addons?.restartAddon?.mutate({ addonId }).then(() => {
|
|
7099
|
-
ctx.logger.info("addon auto-restart triggered by restart-required setting change", { meta: { changedFields:
|
|
7702
|
+
ctx.logger.info("addon auto-restart triggered by restart-required setting change", { meta: { changedFields: patchKeys.filter((k) => restartKeys.has(k)) } });
|
|
7100
7703
|
}).catch((err) => {
|
|
7101
7704
|
ctx.logger.error("addon auto-restart failed", { meta: { error: err instanceof Error ? err.message : String(err) } });
|
|
7102
7705
|
});
|
|
@@ -7105,7 +7708,7 @@ var BaseAddon = class {
|
|
|
7105
7708
|
async getDeviceSettings(deviceId) {
|
|
7106
7709
|
const schema = this.deviceSettingsSchema();
|
|
7107
7710
|
if (!schema) return { sections: [] };
|
|
7108
|
-
return hydrateSchema(schema, await this._ctx?.settings?.readDeviceStore(deviceId) ?? {});
|
|
7711
|
+
return hydrateSchema(schema, await this._ctx?.settings?.readDeviceStore(deviceId) ?? {}, { inlineSecretsAsViews: true });
|
|
7109
7712
|
}
|
|
7110
7713
|
async updateDeviceSettings(deviceId, patch) {
|
|
7111
7714
|
await this._ctx?.settings?.writeDeviceStore(deviceId, patch);
|
|
@@ -7235,7 +7838,7 @@ var BaseAddon = class {
|
|
|
7235
7838
|
* selection at boot (absent scoped key ⇒ the constructor default wins).
|
|
7236
7839
|
*/
|
|
7237
7840
|
async resolveConfig() {
|
|
7238
|
-
const stored = await this.readAddonStoreWithRetry();
|
|
7841
|
+
const stored = await this.resolveStoredSecrets(await this.readAddonStoreWithRetry());
|
|
7239
7842
|
const perNode = this.perNodeKeys();
|
|
7240
7843
|
const localNode = normalizeNodeId(this._ctx?.kernel?.localNodeId);
|
|
7241
7844
|
const resolved = { ...this.defaults };
|
|
@@ -7260,7 +7863,7 @@ var BaseAddon = class {
|
|
|
7260
7863
|
key,
|
|
7261
7864
|
schema,
|
|
7262
7865
|
fallback,
|
|
7263
|
-
read: () => this.readAddonStoreWithRetry(),
|
|
7866
|
+
read: async () => this.resolveStoredSecrets(await this.readAddonStoreWithRetry()),
|
|
7264
7867
|
write: async (patch) => {
|
|
7265
7868
|
await this._ctx?.settings?.writeAddonStore(patch);
|
|
7266
7869
|
},
|
|
@@ -7277,7 +7880,7 @@ var BaseAddon = class {
|
|
|
7277
7880
|
key,
|
|
7278
7881
|
schema,
|
|
7279
7882
|
fallback,
|
|
7280
|
-
read: async () => await this._ctx?.settings?.readDeviceStore(deviceId) ?? {},
|
|
7883
|
+
read: async () => this.resolveStoredSecrets(await this._ctx?.settings?.readDeviceStore(deviceId) ?? {}, false),
|
|
7281
7884
|
write: async (patch) => {
|
|
7282
7885
|
await this._ctx?.settings?.writeDeviceStore(deviceId, patch);
|
|
7283
7886
|
},
|
|
@@ -7289,6 +7892,70 @@ var BaseAddon = class {
|
|
|
7289
7892
|
} })
|
|
7290
7893
|
});
|
|
7291
7894
|
}
|
|
7895
|
+
/** The addon store's secret tree: schema fields by TYPE, plus `secretStatePaths`. */
|
|
7896
|
+
addonSecretTree() {
|
|
7897
|
+
this._addonSecretTree ??= mergeSecretStatePaths(secretTreeFromSchema(this.globalSettingsSchema()), this.secretStatePaths);
|
|
7898
|
+
return this._addonSecretTree;
|
|
7899
|
+
}
|
|
7900
|
+
deviceSecretTree() {
|
|
7901
|
+
this._deviceSecretTree ??= secretTreeFromSchema(this.deviceSettingsSchema());
|
|
7902
|
+
return this._deviceSecretTree;
|
|
7903
|
+
}
|
|
7904
|
+
/**
|
|
7905
|
+
* Secrets of this addon's stored config that could not be resolved on the
|
|
7906
|
+
* last read, with why. Non-empty means the addon is running WITHOUT them —
|
|
7907
|
+
* an addon whose function needs one should report itself degraded rather
|
|
7908
|
+
* than start on an empty credential.
|
|
7909
|
+
*/
|
|
7910
|
+
get unresolvedSecrets() {
|
|
7911
|
+
return this._unresolvedSecrets;
|
|
7912
|
+
}
|
|
7913
|
+
/**
|
|
7914
|
+
* Substitute every keychain marker in a stored blob with its value. With no
|
|
7915
|
+
* keychain (no `ctx.secrets`) or no marker, the blob comes back unchanged.
|
|
7916
|
+
* An unresolvable value is LEFT OUT (never `''`), logged by ref — never by
|
|
7917
|
+
* value — and, when the cause can pass, retried with backoff. Nothing is
|
|
7918
|
+
* ever written back from here.
|
|
7919
|
+
*/
|
|
7920
|
+
async resolveStoredSecrets(blob, trackForConfig = true) {
|
|
7921
|
+
const secrets = this._ctx?.secrets;
|
|
7922
|
+
if (secrets === void 0) return blob;
|
|
7923
|
+
const refs = collectSecretMarkerRefs(blob);
|
|
7924
|
+
if (trackForConfig) this._configSecretRefs = new Set(refs);
|
|
7925
|
+
if (refs.length === 0) {
|
|
7926
|
+
if (trackForConfig) this._unresolvedSecrets = [];
|
|
7927
|
+
return blob;
|
|
7928
|
+
}
|
|
7929
|
+
const { value, unresolved } = await resolveSecretMarkers(blob, secrets);
|
|
7930
|
+
if (trackForConfig) {
|
|
7931
|
+
this._unresolvedSecrets = unresolved;
|
|
7932
|
+
if (unresolved.length > 0) {
|
|
7933
|
+
this._ctx?.logger?.error?.("secret unavailable — running without it, will retry", { meta: { secrets: unresolved.map((u) => ({
|
|
7934
|
+
ref: u.ref,
|
|
7935
|
+
reason: u.reason
|
|
7936
|
+
})) } });
|
|
7937
|
+
if (unresolved.some((u) => u.reason !== "missing" && u.reason !== "forbidden")) {
|
|
7938
|
+
this.scheduleSecretReresolve(this._secretRetryDelayMs);
|
|
7939
|
+
this._secretRetryDelayMs = Math.min(this._secretRetryDelayMs * 2, SECRET_RETRY_MAX_MS);
|
|
7940
|
+
}
|
|
7941
|
+
} else this._secretRetryDelayMs = SECRET_RETRY_FIRST_MS;
|
|
7942
|
+
}
|
|
7943
|
+
return value;
|
|
7944
|
+
}
|
|
7945
|
+
/** Re-resolve the config (a keychain-only change, or a retry) and apply it. */
|
|
7946
|
+
scheduleSecretReresolve(delayMs) {
|
|
7947
|
+
const timerOf = delayMs === SECRET_CHANGE_DEBOUNCE_MS ? "_secretChangeTimer" : "_secretRetryTimer";
|
|
7948
|
+
if (this[timerOf] !== null) return;
|
|
7949
|
+
const timer = setTimeout(() => {
|
|
7950
|
+
this[timerOf] = null;
|
|
7951
|
+
if (this._ctx === null) return;
|
|
7952
|
+
this.resolveConfig().then(() => this.onConfigChanged()).catch((err) => {
|
|
7953
|
+
this._ctx?.logger?.error?.("re-resolving secrets failed", { meta: { error: err instanceof Error ? err.message : String(err) } });
|
|
7954
|
+
});
|
|
7955
|
+
}, delayMs);
|
|
7956
|
+
timer.unref?.();
|
|
7957
|
+
this[timerOf] = timer;
|
|
7958
|
+
}
|
|
7292
7959
|
/**
|
|
7293
7960
|
* Wrap `ctx.settings.readAddonStore()` with a short retry budget so a
|
|
7294
7961
|
* transient settings-store outage (mid-restart of sqlite-settings, tsx-watch
|
|
@@ -7864,6 +8531,69 @@ method(object({ deviceId: number() }), array(StreamSourceEntrySchema)), method(o
|
|
|
7864
8531
|
kind: "mutation",
|
|
7865
8532
|
auth: "admin"
|
|
7866
8533
|
}), method(object({ deviceId: number() }), unknown().nullable()), method(object({ deviceId: number() }), RawStateResultSchema.nullable(), { auth: "protected" });
|
|
8534
|
+
function defOf(schema) {
|
|
8535
|
+
return schema._zod?.def ?? {};
|
|
8536
|
+
}
|
|
8537
|
+
function declaredHere(schema) {
|
|
8538
|
+
return globalRegistry.get(schema)?.secret === true;
|
|
8539
|
+
}
|
|
8540
|
+
/** Wrapper kinds whose `innerType` is the field itself. */
|
|
8541
|
+
var WRAPPERS = new Set([
|
|
8542
|
+
"optional",
|
|
8543
|
+
"nullable",
|
|
8544
|
+
"default",
|
|
8545
|
+
"prefault",
|
|
8546
|
+
"catch",
|
|
8547
|
+
"readonly",
|
|
8548
|
+
"nonoptional"
|
|
8549
|
+
]);
|
|
8550
|
+
/**
|
|
8551
|
+
* The schema layers that make up ONE field: the schema itself and every
|
|
8552
|
+
* wrapper below it (optional / default / nullable / readonly / catch), plus
|
|
8553
|
+
* both sides of a pipe (`z.preprocess` puts the real schema on `out`,
|
|
8554
|
+
* `.transform` on `in`).
|
|
8555
|
+
*/
|
|
8556
|
+
function layersOf(schema) {
|
|
8557
|
+
const out = [];
|
|
8558
|
+
const queue = [schema];
|
|
8559
|
+
while (queue.length > 0) {
|
|
8560
|
+
const s = queue.shift();
|
|
8561
|
+
if (!s || out.includes(s)) continue;
|
|
8562
|
+
out.push(s);
|
|
8563
|
+
const def = defOf(s);
|
|
8564
|
+
if (def.type !== void 0 && WRAPPERS.has(def.type) && def.innerType) queue.push(def.innerType);
|
|
8565
|
+
if (def.type === "pipe") {
|
|
8566
|
+
if (def.in) queue.push(def.in);
|
|
8567
|
+
if (def.out) queue.push(def.out);
|
|
8568
|
+
}
|
|
8569
|
+
}
|
|
8570
|
+
return out;
|
|
8571
|
+
}
|
|
8572
|
+
/** True when any layer of this field declares `.meta({ secret: true })`. */
|
|
8573
|
+
function isZodSecret(schema) {
|
|
8574
|
+
return layersOf(schema).some(declaredHere);
|
|
8575
|
+
}
|
|
8576
|
+
/**
|
|
8577
|
+
* Every declared secret path in a config schema: dotted keys, `[]` for "each
|
|
8578
|
+
* element of this array" (`connection.password`, `rows[].token`). A declared
|
|
8579
|
+
* object or array is reported as one path and not descended into — everything
|
|
8580
|
+
* under it is secret.
|
|
8581
|
+
*/
|
|
8582
|
+
function collectZodSecretPaths(schema, prefix = "") {
|
|
8583
|
+
if (isZodSecret(schema)) return prefix.length > 0 ? [prefix] : [];
|
|
8584
|
+
const paths = [];
|
|
8585
|
+
for (const layer of layersOf(schema)) {
|
|
8586
|
+
const def = defOf(layer);
|
|
8587
|
+
if (def.type === "object" && def.shape) for (const [key, child] of Object.entries(def.shape)) paths.push(...collectZodSecretPaths(child, prefix ? `${prefix}.${key}` : key));
|
|
8588
|
+
else if (def.type === "array" && def.element) paths.push(...collectZodSecretPaths(def.element, `${prefix}[]`));
|
|
8589
|
+
else if (def.type === "union" && def.options) for (const option of def.options) paths.push(...collectZodSecretPaths(option, prefix));
|
|
8590
|
+
else if (def.type === "intersection") {
|
|
8591
|
+
if (def.left) paths.push(...collectZodSecretPaths(def.left, prefix));
|
|
8592
|
+
if (def.right) paths.push(...collectZodSecretPaths(def.right, prefix));
|
|
8593
|
+
}
|
|
8594
|
+
}
|
|
8595
|
+
return [...new Set(paths)];
|
|
8596
|
+
}
|
|
7867
8597
|
//#endregion
|
|
7868
8598
|
//#region ../types/dist/err-msg-DX6i_MY4.mjs
|
|
7869
8599
|
var DeviceType = /* @__PURE__ */ function(DeviceType) {
|
|
@@ -14894,6 +15624,196 @@ id: union([string(), number()]) }), {
|
|
|
14894
15624
|
kind: "mutation",
|
|
14895
15625
|
auth: "admin"
|
|
14896
15626
|
});
|
|
15627
|
+
/**
|
|
15628
|
+
* `keychain` — the hub's encrypted store of secret values (D787).
|
|
15629
|
+
*
|
|
15630
|
+
* Settings blobs never hold a secret: they hold a marker
|
|
15631
|
+
* `{"$secret":"secret://<owner>/<scope>/<fieldPath>","v":1}` and the value
|
|
15632
|
+
* lives here, AES-256-GCM under a data key that a master key wraps. This cap
|
|
15633
|
+
* is the OWNER's door to its own values: every method is owner-checked
|
|
15634
|
+
* against the CALLER, never against anything the caller claims.
|
|
15635
|
+
*
|
|
15636
|
+
* Who the caller is: the transport stamps `callerAddonId` into the args of a
|
|
15637
|
+
* call that crossed a process (the parent `LocalChildRegistry` from the UDS
|
|
15638
|
+
* connection, the agent from its child's connection carried in
|
|
15639
|
+
* `$hub-cap-fwd`'s envelope). A stamp always overwrites; a wire call with no
|
|
15640
|
+
* stamp has its claim stripped. Only a hub in-process caller may state its own
|
|
15641
|
+
* identity — `ctx.secrets` does that with the addon id closed over. This is
|
|
15642
|
+
* identity against BUGS and misrouting, not against a malicious addon (every
|
|
15643
|
+
* runner is the same OS user): see the threat model in
|
|
15644
|
+
* `docs/design/2026-10-08-secrets-keychain.md`.
|
|
15645
|
+
*
|
|
15646
|
+
* `callerAddonId` is deliberately NOT in any input schema: the tRPC router
|
|
15647
|
+
* parses the input, so a session can never supply it, and the internal mount
|
|
15648
|
+
* floors every method to admin anyway (D240).
|
|
15649
|
+
*
|
|
15650
|
+
* Internal: addons reach it through `ctx.secrets`, never directly.
|
|
15651
|
+
*/
|
|
15652
|
+
/** Why a value cannot be served right now. Never folded into "missing". */
|
|
15653
|
+
var KeychainUnavailableReasonSchema = _enum([
|
|
15654
|
+
"key-missing",
|
|
15655
|
+
"wrong-key",
|
|
15656
|
+
"key-file-unreadable",
|
|
15657
|
+
"store-unavailable",
|
|
15658
|
+
"not-initialized",
|
|
15659
|
+
"decrypt-failed"
|
|
15660
|
+
]);
|
|
15661
|
+
var KeychainStateSchema = discriminatedUnion("state", [object({ state: literal("ready") }), object({
|
|
15662
|
+
state: literal("locked"),
|
|
15663
|
+
reason: KeychainUnavailableReasonSchema
|
|
15664
|
+
})]);
|
|
15665
|
+
var KeychainResolveEntrySchema = discriminatedUnion("kind", [
|
|
15666
|
+
object({
|
|
15667
|
+
kind: literal("value"),
|
|
15668
|
+
value: string(),
|
|
15669
|
+
version: number().int()
|
|
15670
|
+
}),
|
|
15671
|
+
object({ kind: literal("missing") }),
|
|
15672
|
+
object({
|
|
15673
|
+
kind: literal("unavailable"),
|
|
15674
|
+
reason: KeychainUnavailableReasonSchema
|
|
15675
|
+
}),
|
|
15676
|
+
object({ kind: literal("forbidden") })
|
|
15677
|
+
]);
|
|
15678
|
+
var KeychainResolveResultSchema = record(string(), KeychainResolveEntrySchema);
|
|
15679
|
+
/** Metadata of one stored value — never the value. */
|
|
15680
|
+
var KeychainSecretMetaSchema = object({
|
|
15681
|
+
ref: string(),
|
|
15682
|
+
owner: string(),
|
|
15683
|
+
/** Formatted scope (`global`, `node/<id>`, `device/<id>`, …). */
|
|
15684
|
+
scope: string(),
|
|
15685
|
+
fieldPath: string(),
|
|
15686
|
+
version: number().int(),
|
|
15687
|
+
createdAt: number(),
|
|
15688
|
+
updatedAt: number(),
|
|
15689
|
+
/** `addon:<id>` | `user:<id>` | `system`. */
|
|
15690
|
+
updatedBy: string(),
|
|
15691
|
+
/** Coarse — written at most once an hour per ref. `null` = never read. */
|
|
15692
|
+
lastReadAt: number().nullable()
|
|
15693
|
+
});
|
|
15694
|
+
var RefListSchema = array(string().min(1)).max(512);
|
|
15695
|
+
method(object({
|
|
15696
|
+
ref: string().min(1),
|
|
15697
|
+
value: string().min(1)
|
|
15698
|
+
}), object({
|
|
15699
|
+
ref: string(),
|
|
15700
|
+
version: number().int()
|
|
15701
|
+
}), {
|
|
15702
|
+
kind: "mutation",
|
|
15703
|
+
auth: "admin"
|
|
15704
|
+
}), method(object({ refs: RefListSchema }), KeychainResolveResultSchema, { auth: "admin" }), method(object({ refs: RefListSchema }), object({ deleted: number().int() }), {
|
|
15705
|
+
kind: "mutation",
|
|
15706
|
+
auth: "admin"
|
|
15707
|
+
}), method(object({}), array(KeychainSecretMetaSchema).readonly(), { auth: "admin" }), method(object({}), KeychainStateSchema, { auth: "admin" });
|
|
15708
|
+
var KeychainKeySourceSchema = object({
|
|
15709
|
+
kind: _enum([
|
|
15710
|
+
"config-file",
|
|
15711
|
+
"previous-config-file",
|
|
15712
|
+
"platform",
|
|
15713
|
+
"default-file"
|
|
15714
|
+
]),
|
|
15715
|
+
/** File sources only — a path is not a secret. */
|
|
15716
|
+
path: string().optional(),
|
|
15717
|
+
/**
|
|
15718
|
+
* True when a whole-volume backup of the data directory carries this key
|
|
15719
|
+
* next to the database it protects (the default file). The page warns.
|
|
15720
|
+
*/
|
|
15721
|
+
sharesBackupWithDatabase: boolean()
|
|
15722
|
+
});
|
|
15723
|
+
var KeychainStatusSchema = object({
|
|
15724
|
+
keychain: KeychainStateSchema,
|
|
15725
|
+
/** The source of the master key in use; `null` while locked. */
|
|
15726
|
+
keySource: KeychainKeySourceSchema.nullable(),
|
|
15727
|
+
/** The source configured to be primary — differs from `keySource` while a rotation is pending. */
|
|
15728
|
+
configuredSource: KeychainKeySourceSchema,
|
|
15729
|
+
/** Short fingerprint of the master key in use (`HMAC(KEK, label)`, 16 hex). */
|
|
15730
|
+
fingerprint: string().nullable(),
|
|
15731
|
+
activeKeyId: string().nullable(),
|
|
15732
|
+
/**
|
|
15733
|
+
* The keychain unlocked with a NON-primary source: the configured primary
|
|
15734
|
+
* key is not the one that wraps the data key yet. `rotateMasterKey` moves it.
|
|
15735
|
+
*/
|
|
15736
|
+
rotationPending: boolean(),
|
|
15737
|
+
/** Wrapped copies of the data key under a previous master key, kept until purged. */
|
|
15738
|
+
retiredWraps: number().int(),
|
|
15739
|
+
recoveryKeyDownloadedAt: number().nullable(),
|
|
15740
|
+
secretCount: number().int()
|
|
15741
|
+
});
|
|
15742
|
+
/**
|
|
15743
|
+
* Whether a stored value is still pointed at by its owner's settings.
|
|
15744
|
+
* `unknown` is a first-class answer: a scope whose blob could not be read is
|
|
15745
|
+
* never reported as an orphan (and never deleted as one).
|
|
15746
|
+
*/
|
|
15747
|
+
var KeychainSecretUsageSchema = _enum([
|
|
15748
|
+
"in-use",
|
|
15749
|
+
"orphan",
|
|
15750
|
+
"unknown"
|
|
15751
|
+
]);
|
|
15752
|
+
var KeychainAdminSecretSchema = KeychainSecretMetaSchema.extend({ usage: KeychainSecretUsageSchema });
|
|
15753
|
+
var KeychainAuditActionSchema = _enum([
|
|
15754
|
+
"put",
|
|
15755
|
+
"delete",
|
|
15756
|
+
"reveal",
|
|
15757
|
+
"rotate-master-key",
|
|
15758
|
+
"purge-retired-keys",
|
|
15759
|
+
"download-recovery-key",
|
|
15760
|
+
"delete-orphans",
|
|
15761
|
+
"reset",
|
|
15762
|
+
"initialize"
|
|
15763
|
+
]);
|
|
15764
|
+
var KeychainAuditEntrySchema = object({
|
|
15765
|
+
id: string(),
|
|
15766
|
+
at: number(),
|
|
15767
|
+
action: KeychainAuditActionSchema,
|
|
15768
|
+
/** `addon:<id>` | `user:<id>` | `system`. */
|
|
15769
|
+
actor: string(),
|
|
15770
|
+
ref: string().nullable(),
|
|
15771
|
+
detail: string().nullable()
|
|
15772
|
+
});
|
|
15773
|
+
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({
|
|
15774
|
+
value: string(),
|
|
15775
|
+
version: number().int()
|
|
15776
|
+
}), {
|
|
15777
|
+
kind: "mutation",
|
|
15778
|
+
auth: "admin",
|
|
15779
|
+
caller: "required"
|
|
15780
|
+
}), method(object({ refs: array(string().min(1)).max(1e3) }), object({
|
|
15781
|
+
deleted: array(string()).readonly(),
|
|
15782
|
+
kept: array(object({
|
|
15783
|
+
ref: string(),
|
|
15784
|
+
usage: KeychainSecretUsageSchema
|
|
15785
|
+
})).readonly()
|
|
15786
|
+
}), {
|
|
15787
|
+
kind: "mutation",
|
|
15788
|
+
auth: "admin",
|
|
15789
|
+
caller: "required"
|
|
15790
|
+
}), method(object({}), object({
|
|
15791
|
+
fingerprint: string(),
|
|
15792
|
+
keySource: KeychainKeySourceSchema
|
|
15793
|
+
}), {
|
|
15794
|
+
kind: "mutation",
|
|
15795
|
+
auth: "admin",
|
|
15796
|
+
caller: "required"
|
|
15797
|
+
}), method(object({}), object({ purged: number().int() }), {
|
|
15798
|
+
kind: "mutation",
|
|
15799
|
+
auth: "admin",
|
|
15800
|
+
caller: "required"
|
|
15801
|
+
}), method(object({}), object({
|
|
15802
|
+
key: string(),
|
|
15803
|
+
fingerprint: string(),
|
|
15804
|
+
keySource: KeychainKeySourceSchema
|
|
15805
|
+
}), {
|
|
15806
|
+
kind: "mutation",
|
|
15807
|
+
auth: "admin",
|
|
15808
|
+
caller: "required"
|
|
15809
|
+
}), method(object({ confirm: literal("RESET KEYCHAIN") }), object({
|
|
15810
|
+
archivedCollection: string().nullable(),
|
|
15811
|
+
archived: number().int()
|
|
15812
|
+
}), {
|
|
15813
|
+
kind: "mutation",
|
|
15814
|
+
auth: "admin",
|
|
15815
|
+
caller: "required"
|
|
15816
|
+
});
|
|
14897
15817
|
method(_void(), object({
|
|
14898
15818
|
id: string(),
|
|
14899
15819
|
name: string(),
|
|
@@ -16136,7 +17056,11 @@ var DeviceRegisterPayloadSchema = object({
|
|
|
16136
17056
|
var DeviceRemovePayloadSchema = object({ deviceId: number() });
|
|
16137
17057
|
var DevicePersistConfigPayloadSchema = object({
|
|
16138
17058
|
deviceId: number(),
|
|
16139
|
-
data: record(string(), unknown())
|
|
17059
|
+
data: record(string(), unknown()),
|
|
17060
|
+
/** The paths the device's schema declares secret (D783), when the caller
|
|
17061
|
+
* knows them — those values are kept in the keychain, not the blob (D787).
|
|
17062
|
+
* Absent: the paths the device last reported at `registerDevice` apply. */
|
|
17063
|
+
secretConfigPaths: array(string()).optional()
|
|
16140
17064
|
});
|
|
16141
17065
|
/** What a migration actually did, per switch. `unreachable` is a first-class
|
|
16142
17066
|
* answer: a camera that could not be asked is not a camera that was silenced. */
|
|
@@ -23153,8 +24077,23 @@ var RetrainMacroClassSchema = _enum([
|
|
|
23153
24077
|
]);
|
|
23154
24078
|
/** A subject to learn, or a phantom to unlearn (taught by OMISSION). */
|
|
23155
24079
|
var RetrainAnnotationKindSchema = _enum(["subject", "model_error"]);
|
|
23156
|
-
/**
|
|
23157
|
-
|
|
24080
|
+
/**
|
|
24081
|
+
* Where a box came from. A machine-sourced box is a DRAFT on the page until
|
|
24082
|
+
* the operator confirms it; once saved it keeps its source as provenance.
|
|
24083
|
+
*
|
|
24084
|
+
* - `operator` — drawn by hand.
|
|
24085
|
+
* - `assist` — proposed by a detector run on the copy (the camera's own
|
|
24086
|
+
* model, or a larger teacher model).
|
|
24087
|
+
* - `pipeline` — the box the live pipeline actually drew on that frame, read
|
|
24088
|
+
* back from the track store (never a re-run).
|
|
24089
|
+
* - `llm` — proposed by a vision-capable LLM profile.
|
|
24090
|
+
*/
|
|
24091
|
+
var RetrainAnnotationSourceSchema = _enum([
|
|
24092
|
+
"operator",
|
|
24093
|
+
"assist",
|
|
24094
|
+
"pipeline",
|
|
24095
|
+
"llm"
|
|
24096
|
+
]);
|
|
23158
24097
|
/** Normalised `[0,1]` rectangle against the FULL frame — the canonical form. */
|
|
23159
24098
|
var RetrainBboxSchema = object({
|
|
23160
24099
|
x: number(),
|
|
@@ -23172,7 +24111,8 @@ var RetrainBboxSchema = object({
|
|
|
23172
24111
|
*/
|
|
23173
24112
|
var RetrainAnnotationSchema = object({
|
|
23174
24113
|
id: string(),
|
|
23175
|
-
|
|
24114
|
+
/** The frame's track. Absent on a recording still, which has none. */
|
|
24115
|
+
trackId: string().optional(),
|
|
23176
24116
|
deviceId: number(),
|
|
23177
24117
|
/** The COPY in retrain storage — never the source track's media key. */
|
|
23178
24118
|
mediaKey: string(),
|
|
@@ -23221,13 +24161,47 @@ var RetrainFrameCandidateSchema = object({
|
|
|
23221
24161
|
* fail, whatever became of the original. */
|
|
23222
24162
|
copied: boolean()
|
|
23223
24163
|
});
|
|
24164
|
+
/**
|
|
24165
|
+
* One box the live pipeline drew on a copied frame — what a correction starts
|
|
24166
|
+
* from. Derived when the frame is listed, from the track store: the subject
|
|
24167
|
+
* box recorded on the source media row when there is one, else the track
|
|
24168
|
+
* position nearest the frame's capture time. Never stored as an annotation
|
|
24169
|
+
* until the operator confirms it.
|
|
24170
|
+
*/
|
|
24171
|
+
var RetrainPipelineBoxSchema = object({
|
|
24172
|
+
/** Normalised `[0,1]` against the full frame. */
|
|
24173
|
+
bbox: RetrainBboxSchema,
|
|
24174
|
+
macroClass: RetrainMacroClassSchema,
|
|
24175
|
+
label: string().optional(),
|
|
24176
|
+
subLabel: string().optional(),
|
|
24177
|
+
/** The detection score of the position used, when it was recorded. */
|
|
24178
|
+
score: number().optional(),
|
|
24179
|
+
/** The root model that produced the track, when it was recorded. */
|
|
24180
|
+
modelId: string().optional(),
|
|
24181
|
+
trackId: string(),
|
|
24182
|
+
/** `subject-box`: recorded on this very frame. `position`: the track's
|
|
24183
|
+
* position nearest the capture time, `deltaMs` away. */
|
|
24184
|
+
basis: _enum(["subject-box", "position"]),
|
|
24185
|
+
deltaMs: number()
|
|
24186
|
+
});
|
|
24187
|
+
/**
|
|
24188
|
+
* Where a retrain frame came from: a TRACK's stored media (copy-on-select),
|
|
24189
|
+
* or the RECORDING at an instant — the frame a model saw nothing in has no
|
|
24190
|
+
* track at all.
|
|
24191
|
+
*/
|
|
24192
|
+
var RetrainFrameOriginSchema = _enum(["track", "recording"]);
|
|
23224
24193
|
/** A frame the dataset OWNS: bytes copied at selection time. */
|
|
23225
24194
|
var RetrainFrameSchema = object({
|
|
23226
24195
|
frameId: string(),
|
|
23227
24196
|
deviceId: number(),
|
|
23228
|
-
|
|
23229
|
-
/**
|
|
23230
|
-
|
|
24197
|
+
origin: RetrainFrameOriginSchema,
|
|
24198
|
+
/** The track it was copied from. Absent on a recording still. */
|
|
24199
|
+
trackId: string().optional(),
|
|
24200
|
+
/** Provenance only. It may already point at nothing — that is expected.
|
|
24201
|
+
* Absent on a recording still. */
|
|
24202
|
+
sourceMediaId: number().int().optional(),
|
|
24203
|
+
/** A recording still: the playhead instant it was taken at. */
|
|
24204
|
+
epochMs: number().optional(),
|
|
23231
24205
|
sourceKind: MediaFileKindEnum,
|
|
23232
24206
|
sizeBytes: number().int(),
|
|
23233
24207
|
width: number().int(),
|
|
@@ -23238,7 +24212,12 @@ var RetrainFrameSchema = object({
|
|
|
23238
24212
|
/** The operator's "every subject in this frame is boxed". Detector
|
|
23239
24213
|
* evaluation keeps only complete frames: an unboxed subject would count as
|
|
23240
24214
|
* a false positive. */
|
|
23241
|
-
complete: boolean()
|
|
24215
|
+
complete: boolean(),
|
|
24216
|
+
/** The boxes the pipeline drew on this frame. Present on list answers;
|
|
24217
|
+
* empty when nothing the track store holds can be placed on it. */
|
|
24218
|
+
pipelineBoxes: array(RetrainPipelineBoxSchema).readonly().optional(),
|
|
24219
|
+
/** The named collections this frame belongs to. Present on list answers. */
|
|
24220
|
+
collectionIds: array(string()).readonly().optional()
|
|
23242
24221
|
});
|
|
23243
24222
|
/** Why a copy-on-select could not be honoured — named, never a silent skip. */
|
|
23244
24223
|
var RetrainCopyRefusalSchema = _enum([
|
|
@@ -23269,6 +24248,8 @@ var RetrainFrameListSchema = object({
|
|
|
23269
24248
|
var RetrainExportFilterSchema = object({
|
|
23270
24249
|
deviceIds: array(number()).optional(),
|
|
23271
24250
|
frameIds: array(string()).max(2e4).optional(),
|
|
24251
|
+
/** Only frames in at least one of these named collections. */
|
|
24252
|
+
collectionIds: array(string()).max(200).optional(),
|
|
23272
24253
|
batchId: string().optional(),
|
|
23273
24254
|
/** Only frames the operator marked complete (all subjects boxed). */
|
|
23274
24255
|
completeOnly: boolean().optional()
|
|
@@ -23333,6 +24314,109 @@ var RetrainAssistResultSchema = discriminatedUnion("kind", [object({
|
|
|
23333
24314
|
reason: string(),
|
|
23334
24315
|
detail: string().optional()
|
|
23335
24316
|
})]);
|
|
24317
|
+
/** A named set over the retrain corpus — membership only, it owns no pixels. */
|
|
24318
|
+
var RetrainCollectionSchema = object({
|
|
24319
|
+
id: string(),
|
|
24320
|
+
name: string(),
|
|
24321
|
+
createdAt: number(),
|
|
24322
|
+
frameCount: number().int()
|
|
24323
|
+
});
|
|
24324
|
+
var RetrainCollectionCreateResultSchema = discriminatedUnion("kind", [object({
|
|
24325
|
+
kind: literal("created"),
|
|
24326
|
+
collection: RetrainCollectionSchema
|
|
24327
|
+
}), object({
|
|
24328
|
+
kind: literal("refused"),
|
|
24329
|
+
reason: _enum(["empty-name", "duplicate-name"])
|
|
24330
|
+
})]);
|
|
24331
|
+
var RetrainCollectionRenameResultSchema = discriminatedUnion("kind", [object({
|
|
24332
|
+
kind: literal("renamed"),
|
|
24333
|
+
collection: RetrainCollectionSchema
|
|
24334
|
+
}), object({
|
|
24335
|
+
kind: literal("refused"),
|
|
24336
|
+
reason: _enum([
|
|
24337
|
+
"empty-name",
|
|
24338
|
+
"duplicate-name",
|
|
24339
|
+
"unknown-collection"
|
|
24340
|
+
])
|
|
24341
|
+
})]);
|
|
24342
|
+
/**
|
|
24343
|
+
* The outcome of adding the frame at a recording instant. Every refusal is
|
|
24344
|
+
* named: `still-unavailable` (not recording, a gap, or an undecodable frame —
|
|
24345
|
+
* `detail` says which), `still-busy` (the recorder is at its decode bound; try
|
|
24346
|
+
* again), `unreadable-image`, `write-failed`, `unknown-collection`.
|
|
24347
|
+
*/
|
|
24348
|
+
var AddRetrainFrameFromRecordingResultSchema = discriminatedUnion("kind", [object({
|
|
24349
|
+
kind: literal("added"),
|
|
24350
|
+
collectionId: string(),
|
|
24351
|
+
frame: RetrainFrameSchema,
|
|
24352
|
+
/** The moment was already in the dataset; nothing was decoded. */
|
|
24353
|
+
reused: boolean()
|
|
24354
|
+
}), object({
|
|
24355
|
+
kind: literal("refused"),
|
|
24356
|
+
reason: _enum([
|
|
24357
|
+
"unknown-collection",
|
|
24358
|
+
"still-unavailable",
|
|
24359
|
+
"still-busy",
|
|
24360
|
+
"unreadable-image",
|
|
24361
|
+
"write-failed"
|
|
24362
|
+
]),
|
|
24363
|
+
detail: string().optional()
|
|
24364
|
+
})]);
|
|
24365
|
+
/** A vision LLM profile the AI assist may use, and where it sends the frame. */
|
|
24366
|
+
var RetrainAssistProfileSchema = object({
|
|
24367
|
+
id: string(),
|
|
24368
|
+
name: string(),
|
|
24369
|
+
model: string(),
|
|
24370
|
+
kind: string(),
|
|
24371
|
+
/** `true` when the frame would leave the house (a cloud vendor, or an
|
|
24372
|
+
* endpoint that is not on the local network). The page confirms each such
|
|
24373
|
+
* run, and the provider refuses one without `allowCloud`. */
|
|
24374
|
+
leavesHouse: boolean()
|
|
24375
|
+
});
|
|
24376
|
+
/** A box the AI assist proposed: a draft, plus the model's own reason. */
|
|
24377
|
+
var RetrainLlmProposalSchema = RetrainAnnotationDraftSchema.extend({ reason: string() });
|
|
24378
|
+
/** What the AI assist said about a box that was already on the canvas. */
|
|
24379
|
+
var RetrainLlmReviewSchema = object({
|
|
24380
|
+
/** The `ref` the page sent the box under. */
|
|
24381
|
+
ref: string(),
|
|
24382
|
+
verdict: _enum([
|
|
24383
|
+
"confirmed",
|
|
24384
|
+
"wrong-class",
|
|
24385
|
+
"not-an-object",
|
|
24386
|
+
"uncertain"
|
|
24387
|
+
]),
|
|
24388
|
+
suggestedClass: RetrainMacroClassSchema.optional(),
|
|
24389
|
+
reason: string()
|
|
24390
|
+
});
|
|
24391
|
+
/**
|
|
24392
|
+
* The AI assist's answer. `proposed` carries drafts (`source: 'llm'`, the
|
|
24393
|
+
* model and its confidence) and reviews; items the model got wrong (a box off
|
|
24394
|
+
* the frame, an unasked class, an unknown ref) are dropped and counted in
|
|
24395
|
+
* `rejected`. A whole answer that is not the schema is `malformed-answer`.
|
|
24396
|
+
*/
|
|
24397
|
+
var RetrainLlmAssistResultSchema = discriminatedUnion("kind", [object({
|
|
24398
|
+
kind: literal("proposed"),
|
|
24399
|
+
profileId: string(),
|
|
24400
|
+
model: string(),
|
|
24401
|
+
/** The frame was sent outside the house for this answer. */
|
|
24402
|
+
leftHouse: boolean(),
|
|
24403
|
+
proposals: array(RetrainLlmProposalSchema).readonly(),
|
|
24404
|
+
reviews: array(RetrainLlmReviewSchema).readonly(),
|
|
24405
|
+
rejected: number().int()
|
|
24406
|
+
}), object({
|
|
24407
|
+
kind: literal("refused"),
|
|
24408
|
+
reason: _enum([
|
|
24409
|
+
"unknown-frame",
|
|
24410
|
+
"unreadable-frame",
|
|
24411
|
+
"unknown-profile",
|
|
24412
|
+
"profile-disabled",
|
|
24413
|
+
"no-vision",
|
|
24414
|
+
"cloud-not-confirmed",
|
|
24415
|
+
"llm-error",
|
|
24416
|
+
"malformed-answer"
|
|
24417
|
+
]),
|
|
24418
|
+
detail: string().optional()
|
|
24419
|
+
})]);
|
|
23336
24420
|
/** The outcome of a lifecycle move owned by the retrain page. */
|
|
23337
24421
|
var RetrainTransitionResultSchema = object({
|
|
23338
24422
|
trackId: string(),
|
|
@@ -24050,7 +25134,7 @@ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).rea
|
|
|
24050
25134
|
auth: "admin"
|
|
24051
25135
|
}), method(object({
|
|
24052
25136
|
deviceId: number(),
|
|
24053
|
-
trackId: string(),
|
|
25137
|
+
trackId: string().optional(),
|
|
24054
25138
|
frameId: string()
|
|
24055
25139
|
}), object({
|
|
24056
25140
|
removed: boolean(),
|
|
@@ -24067,7 +25151,8 @@ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).rea
|
|
|
24067
25151
|
auth: "admin"
|
|
24068
25152
|
}), method(object({
|
|
24069
25153
|
deviceId: number(),
|
|
24070
|
-
|
|
25154
|
+
/** The frame's track, when it has one — checked against the frame. */
|
|
25155
|
+
trackId: string().optional(),
|
|
24071
25156
|
frameId: string(),
|
|
24072
25157
|
subject: RetrainAssistSubjectSchema,
|
|
24073
25158
|
/** Which node runs it. Absent ⇒ wherever an unowned call lands. */
|
|
@@ -24075,12 +25160,16 @@ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).rea
|
|
|
24075
25160
|
}), RetrainAssistResultSchema, {
|
|
24076
25161
|
kind: "mutation",
|
|
24077
25162
|
auth: "admin"
|
|
24078
|
-
}), method(object({
|
|
25163
|
+
}), method(object({
|
|
25164
|
+
trackId: string().optional(),
|
|
25165
|
+
frameIds: array(string()).max(2e3).optional()
|
|
25166
|
+
}), array(RetrainAnnotationSchema).readonly(), {
|
|
24079
25167
|
kind: "query",
|
|
24080
25168
|
auth: "admin"
|
|
24081
25169
|
}), method(object({
|
|
24082
25170
|
deviceId: number(),
|
|
24083
|
-
|
|
25171
|
+
/** The frame's track, when it has one — checked against the frame. */
|
|
25172
|
+
trackId: string().optional(),
|
|
24084
25173
|
frameId: string(),
|
|
24085
25174
|
annotations: array(RetrainAnnotationDraftSchema)
|
|
24086
25175
|
}), array(RetrainAnnotationSchema).readonly(), {
|
|
@@ -24103,7 +25192,7 @@ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).rea
|
|
|
24103
25192
|
auth: "admin"
|
|
24104
25193
|
}), method(object({
|
|
24105
25194
|
deviceId: number(),
|
|
24106
|
-
trackId: string(),
|
|
25195
|
+
trackId: string().optional(),
|
|
24107
25196
|
frameId: string(),
|
|
24108
25197
|
complete: boolean()
|
|
24109
25198
|
}), RetrainFrameSchema, {
|
|
@@ -24117,6 +25206,74 @@ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).rea
|
|
|
24117
25206
|
kind: "mutation",
|
|
24118
25207
|
auth: "admin",
|
|
24119
25208
|
timeoutMs: 60 * 6e4
|
|
25209
|
+
}), method(object({}), array(RetrainAssistProfileSchema).readonly(), {
|
|
25210
|
+
kind: "query",
|
|
25211
|
+
auth: "admin"
|
|
25212
|
+
}), method(object({
|
|
25213
|
+
deviceId: number(),
|
|
25214
|
+
trackId: string().optional(),
|
|
25215
|
+
frameId: string(),
|
|
25216
|
+
profileId: string(),
|
|
25217
|
+
classes: array(RetrainMacroClassSchema).min(1),
|
|
25218
|
+
boxes: array(object({
|
|
25219
|
+
ref: string(),
|
|
25220
|
+
bbox: RetrainBboxSchema,
|
|
25221
|
+
macroClass: RetrainMacroClassSchema,
|
|
25222
|
+
label: string().optional()
|
|
25223
|
+
})).max(50),
|
|
25224
|
+
allowCloud: boolean()
|
|
25225
|
+
}), RetrainLlmAssistResultSchema, {
|
|
25226
|
+
kind: "mutation",
|
|
25227
|
+
auth: "admin",
|
|
25228
|
+
timeoutMs: 18e4
|
|
25229
|
+
}), method(object({ name: string().max(120) }), RetrainCollectionCreateResultSchema, {
|
|
25230
|
+
kind: "mutation",
|
|
25231
|
+
auth: "admin"
|
|
25232
|
+
}), method(object({}), array(RetrainCollectionSchema).readonly(), {
|
|
25233
|
+
kind: "query",
|
|
25234
|
+
auth: "admin"
|
|
25235
|
+
}), method(object({
|
|
25236
|
+
id: string(),
|
|
25237
|
+
name: string().max(120)
|
|
25238
|
+
}), RetrainCollectionRenameResultSchema, {
|
|
25239
|
+
kind: "mutation",
|
|
25240
|
+
auth: "admin"
|
|
25241
|
+
}), method(object({ id: string() }), object({
|
|
25242
|
+
deleted: boolean(),
|
|
25243
|
+
removedFrames: number().int()
|
|
25244
|
+
}), {
|
|
25245
|
+
kind: "mutation",
|
|
25246
|
+
auth: "admin"
|
|
25247
|
+
}), method(object({
|
|
25248
|
+
collectionId: string(),
|
|
25249
|
+
deviceId: number(),
|
|
25250
|
+
epochMs: number()
|
|
25251
|
+
}), AddRetrainFrameFromRecordingResultSchema, {
|
|
25252
|
+
kind: "mutation",
|
|
25253
|
+
auth: "admin",
|
|
25254
|
+
timeoutMs: 6e4
|
|
25255
|
+
}), method(object({
|
|
25256
|
+
collectionId: string(),
|
|
25257
|
+
frameIds: array(string()).min(1).max(500)
|
|
25258
|
+
}), object({
|
|
25259
|
+
added: number().int(),
|
|
25260
|
+
alreadyMember: number().int(),
|
|
25261
|
+
unknownFrameIds: array(string()).readonly()
|
|
25262
|
+
}), {
|
|
25263
|
+
kind: "mutation",
|
|
25264
|
+
auth: "admin"
|
|
25265
|
+
}), method(object({
|
|
25266
|
+
collectionId: string(),
|
|
25267
|
+
frameId: string()
|
|
25268
|
+
}), object({
|
|
25269
|
+
removed: boolean(),
|
|
25270
|
+
deletedFrame: boolean()
|
|
25271
|
+
}), {
|
|
25272
|
+
kind: "mutation",
|
|
25273
|
+
auth: "admin"
|
|
25274
|
+
}), method(object({ collectionId: string() }), array(RetrainFrameSchema).readonly(), {
|
|
25275
|
+
kind: "query",
|
|
25276
|
+
auth: "admin"
|
|
24120
25277
|
}), method(object({
|
|
24121
25278
|
/** Which of the three event tables owns the row. */
|
|
24122
25279
|
ownerType: EventOwnerTypeSchema,
|
|
@@ -24740,13 +25897,31 @@ var RecommendationReasonSchema = discriminatedUnion("kind", [
|
|
|
24740
25897
|
object({
|
|
24741
25898
|
kind: literal("no-family-build"),
|
|
24742
25899
|
format: ModelFormatSchema$1
|
|
25900
|
+
}),
|
|
25901
|
+
object({
|
|
25902
|
+
kind: literal("kept-custom-pin"),
|
|
25903
|
+
modelId: string(),
|
|
25904
|
+
deviceKey: string()
|
|
24743
25905
|
})
|
|
24744
25906
|
]);
|
|
25907
|
+
/** Why a device is left exactly as it is, whatever the plan would pick (D786). */
|
|
25908
|
+
var KeptReasonSchema = _enum(["custom-pin"]);
|
|
25909
|
+
/**
|
|
25910
|
+
* Where a choice's latency came from (D791): this node's own benchmark
|
|
25911
|
+
* result, or the hardware-class table. Measured on the node beats the table.
|
|
25912
|
+
*/
|
|
25913
|
+
var LatencySourceSchema = discriminatedUnion("kind", [object({ kind: literal("table") }), object({
|
|
25914
|
+
kind: literal("node-benchmark"),
|
|
25915
|
+
resultId: string(),
|
|
25916
|
+
measuredAtMs: number()
|
|
25917
|
+
})]);
|
|
24745
25918
|
var DeviceModelChoiceSchema = object({
|
|
24746
25919
|
modelId: string(),
|
|
24747
25920
|
p50Ms: number(),
|
|
24748
25921
|
fps: number(),
|
|
24749
25922
|
measured: boolean(),
|
|
25923
|
+
/** Absent on a plan from before D791 — read as the table. */
|
|
25924
|
+
source: LatencySourceSchema.optional(),
|
|
24750
25925
|
/** Parallel sessions at the camera rate with the headroom kept free: ⌊fps × (1 − headroom) / camera fps⌋. */
|
|
24751
25926
|
capacitySessions: number(),
|
|
24752
25927
|
personRecall: number()
|
|
@@ -24757,6 +25932,8 @@ var DeviceRecommendationSchema = object({
|
|
|
24757
25932
|
enabled: boolean(),
|
|
24758
25933
|
available: boolean(),
|
|
24759
25934
|
chosen: DeviceModelChoiceSchema.nullable(),
|
|
25935
|
+
/** Present when the device is kept as is: Apply writes nothing on it. */
|
|
25936
|
+
kept: KeptReasonSchema.optional(),
|
|
24760
25937
|
reasons: array(RecommendationReasonSchema).readonly()
|
|
24761
25938
|
});
|
|
24762
25939
|
var NodeRecommendationSchema = object({
|
|
@@ -24810,6 +25987,17 @@ var AutoTuneWarningSchema = discriminatedUnion("kind", [
|
|
|
24810
25987
|
kind: literal("coral-enabled"),
|
|
24811
25988
|
nodeId: string(),
|
|
24812
25989
|
deviceKey: string()
|
|
25990
|
+
}),
|
|
25991
|
+
object({
|
|
25992
|
+
kind: literal("custom-pin-kept"),
|
|
25993
|
+
nodeId: string(),
|
|
25994
|
+
deviceKey: string().nullable(),
|
|
25995
|
+
deviceId: number().nullable(),
|
|
25996
|
+
modelId: string()
|
|
25997
|
+
}),
|
|
25998
|
+
object({
|
|
25999
|
+
kind: literal("custom-registry-unreadable"),
|
|
26000
|
+
error: string()
|
|
24813
26001
|
})
|
|
24814
26002
|
]);
|
|
24815
26003
|
var AutoTuneOptionsSchema = object({
|
|
@@ -24988,13 +26176,14 @@ var SuggestSharesResultSchema = object({
|
|
|
24988
26176
|
nodes: array(SuggestedNodeShareSchema).readonly()
|
|
24989
26177
|
});
|
|
24990
26178
|
/**
|
|
24991
|
-
* Where the node and device shares come from (D750, D755).
|
|
24992
|
-
* - `
|
|
24993
|
-
*
|
|
24994
|
-
*
|
|
24995
|
-
*
|
|
24996
|
-
*
|
|
24997
|
-
*
|
|
26179
|
+
* Where the node and device shares come from (D750, D755, D791).
|
|
26180
|
+
* - `benchmark` (default since D791) — each node's capacity as its own node
|
|
26181
|
+
* benchmark measured it; a node without fresh results is sized from
|
|
26182
|
+
* `hardware` and says so. Measured on the node beats the table.
|
|
26183
|
+
* - `hardware` — computed from each node's static capacity only (its
|
|
26184
|
+
* accelerators at their Auto tune models, from the latency table).
|
|
26185
|
+
* Both are recomputed whenever a node or device joins, leaves, is switched
|
|
26186
|
+
* on or off, changes model, or a benchmark result is written. No load input.
|
|
24998
26187
|
* - `manual` — the operator's stored sliders.
|
|
24999
26188
|
* Either way a node or device that cannot take sessions gives its share to
|
|
25000
26189
|
* the others in proportion; the stored values are never rewritten for that.
|
|
@@ -25043,6 +26232,362 @@ var EffectiveSharesSchema = object({
|
|
|
25043
26232
|
nodeWeights: record(string(), number()),
|
|
25044
26233
|
deviceWeights: record(string(), record(string(), number()))
|
|
25045
26234
|
});
|
|
26235
|
+
/**
|
|
26236
|
+
* Wire shapes of the node benchmark (D791): the operator's plan, the
|
|
26237
|
+
* preflight the confirmation shows, the run the orchestrator owns, what the
|
|
26238
|
+
* measuring runner reports, and the result rows Auto tune and the automatic
|
|
26239
|
+
* shares read.
|
|
26240
|
+
*
|
|
26241
|
+
* ONE node at a time, owned by the pipeline orchestrator. While a run is
|
|
26242
|
+
* active the cluster is in BENCHMARK MODE for that node: it is not a
|
|
26243
|
+
* detection candidate, camera pins naming it are ignored so its sessions move
|
|
26244
|
+
* elsewhere, and both come back when the mode ends — after a crash or a hub
|
|
26245
|
+
* restart too (a persisted manifest, reconciled against the registry).
|
|
26246
|
+
*
|
|
26247
|
+
* Two measurements, both on the node, driven by its own runner (frames never
|
|
26248
|
+
* cross a process at frame rate, D9):
|
|
26249
|
+
* - `device` — one accelerator × one candidate detector, root only, open
|
|
26250
|
+
* loop: how many streams at the camera rate it carries inside the frame
|
|
26251
|
+
* interval;
|
|
26252
|
+
* - `pipeline` — the chosen detector plus the operator's detail steps
|
|
26253
|
+
* (faces, plates, classifiers, CLIP…), on varied frames from the bench
|
|
26254
|
+
* clip: how many parallel sessions the node carries before latency, drops,
|
|
26255
|
+
* CPU, RAM or the event loop give out.
|
|
26256
|
+
*/
|
|
26257
|
+
/** Defaults and bounds, one place. */
|
|
26258
|
+
var NODE_BENCHMARK_DEFAULTS = {
|
|
26259
|
+
fpsPerStream: 10,
|
|
26260
|
+
budgetMinutes: 45,
|
|
26261
|
+
minBudgetMinutes: 10,
|
|
26262
|
+
maxBudgetMinutes: 120,
|
|
26263
|
+
/** A result older than this no longer beats the table. */
|
|
26264
|
+
staleAfterDays: 30,
|
|
26265
|
+
/** Warm-in per ramp step (not accounted). */
|
|
26266
|
+
settleSec: 5,
|
|
26267
|
+
/** Accounted window per ramp step. */
|
|
26268
|
+
measureSec: 20,
|
|
26269
|
+
/** Longest the drain may take before the run is refused. */
|
|
26270
|
+
drainTimeoutSec: 120,
|
|
26271
|
+
/** Candidate models per device in one run. */
|
|
26272
|
+
maxModelsPerDevice: 6
|
|
26273
|
+
};
|
|
26274
|
+
/** The two measurements a run can make. */
|
|
26275
|
+
var NodeBenchmarkPhaseSchema = _enum(["device", "pipeline"]);
|
|
26276
|
+
var NodeBenchmarkDevicePlanSchema = object({
|
|
26277
|
+
/** `<backend>:<device>` — `openvino:npu`, `coreml:all`, `cpu`. */
|
|
26278
|
+
deviceKey: string().min(1),
|
|
26279
|
+
/**
|
|
26280
|
+
* Root detector candidates for the `device` measurement, in the order
|
|
26281
|
+
* measured. The FIRST is the one the `pipeline` measurement runs.
|
|
26282
|
+
*/
|
|
26283
|
+
modelIds: array(string().min(1)).min(1).max(NODE_BENCHMARK_DEFAULTS.maxModelsPerDevice)
|
|
26284
|
+
});
|
|
26285
|
+
/** What the operator confirmed. */
|
|
26286
|
+
var NodeBenchmarkPlanSchema = object({
|
|
26287
|
+
nodeId: string().min(1),
|
|
26288
|
+
devices: array(NodeBenchmarkDevicePlanSchema).min(1),
|
|
26289
|
+
/** Which measurements run. At least one. */
|
|
26290
|
+
phases: array(NodeBenchmarkPhaseSchema).min(1).default(["device", "pipeline"]),
|
|
26291
|
+
/**
|
|
26292
|
+
* Detail steps (catalog step ids under the root: faces, plates,
|
|
26293
|
+
* classifiers, CLIP…) the `pipeline` measurement enables. The root
|
|
26294
|
+
* detector always runs.
|
|
26295
|
+
*/
|
|
26296
|
+
steps: array(string().min(1)).default([]),
|
|
26297
|
+
/** Offered rate of one stream / session. */
|
|
26298
|
+
fpsPerStream: number().int().min(1).max(30).default(NODE_BENCHMARK_DEFAULTS.fpsPerStream),
|
|
26299
|
+
/** Hard deadline: the mode ends and the cluster is restored when it passes. */
|
|
26300
|
+
budgetMinutes: number().int().min(NODE_BENCHMARK_DEFAULTS.minBudgetMinutes).max(NODE_BENCHMARK_DEFAULTS.maxBudgetMinutes).default(NODE_BENCHMARK_DEFAULTS.budgetMinutes),
|
|
26301
|
+
/** Keep the models the run downloaded (default: delete what was not installed before). */
|
|
26302
|
+
keepDownloadedModels: boolean().default(false),
|
|
26303
|
+
/** Start although the other nodes' capacity does not cover the sessions running now. */
|
|
26304
|
+
acceptInsufficientHeadroom: boolean().default(false)
|
|
26305
|
+
});
|
|
26306
|
+
var NodeBenchmarkRefusalSchema = object({
|
|
26307
|
+
kind: _enum([
|
|
26308
|
+
"benchmark-active",
|
|
26309
|
+
"node-offline",
|
|
26310
|
+
"unknown-device",
|
|
26311
|
+
"no-phase",
|
|
26312
|
+
"insufficient-headroom"
|
|
26313
|
+
]),
|
|
26314
|
+
detail: string(),
|
|
26315
|
+
overridable: boolean()
|
|
26316
|
+
});
|
|
26317
|
+
/** A camera whose detection leaves the node for the run. */
|
|
26318
|
+
var NodeBenchmarkMovingCameraSchema = object({
|
|
26319
|
+
deviceId: number(),
|
|
26320
|
+
/** Placed on the node now (a standing attach or a running session). */
|
|
26321
|
+
placedOnNode: boolean(),
|
|
26322
|
+
/** A node pin naming this node, ignored for the run. */
|
|
26323
|
+
pinnedToNode: boolean()
|
|
26324
|
+
});
|
|
26325
|
+
/** A camera that cannot leave: no other node can obtain its frames. */
|
|
26326
|
+
var NodeBenchmarkStayingCameraSchema = object({
|
|
26327
|
+
deviceId: number(),
|
|
26328
|
+
reason: literal("only-frame-source")
|
|
26329
|
+
});
|
|
26330
|
+
var NodeBenchmarkPreflightSchema = object({
|
|
26331
|
+
nodeId: string(),
|
|
26332
|
+
online: boolean(),
|
|
26333
|
+
moving: array(NodeBenchmarkMovingCameraSchema).readonly(),
|
|
26334
|
+
/** Keep running on the node during the run; the result is flagged contaminated. */
|
|
26335
|
+
staying: array(NodeBenchmarkStayingCameraSchema).readonly(),
|
|
26336
|
+
estimatedDurationMs: number(),
|
|
26337
|
+
/** The run ends and the cluster is restored at the latest after this long. */
|
|
26338
|
+
budgetMs: number(),
|
|
26339
|
+
phases: array(NodeBenchmarkPhaseSchema).readonly(),
|
|
26340
|
+
steps: array(string()).readonly(),
|
|
26341
|
+
devices: array(NodeBenchmarkDevicePlanSchema).readonly(),
|
|
26342
|
+
/** Parallel sessions the cluster runs now, and what the other nodes can carry. */
|
|
26343
|
+
headroom: object({
|
|
26344
|
+
sessionsNow: number(),
|
|
26345
|
+
otherNodesCapacitySessions: number().nullable()
|
|
26346
|
+
}),
|
|
26347
|
+
refusals: array(NodeBenchmarkRefusalSchema).readonly(),
|
|
26348
|
+
canStart: boolean()
|
|
26349
|
+
});
|
|
26350
|
+
/** Where the measuring runner is. */
|
|
26351
|
+
var NodeBenchProgressSchema = object({
|
|
26352
|
+
phase: _enum([
|
|
26353
|
+
"preparing",
|
|
26354
|
+
"device",
|
|
26355
|
+
"pipeline",
|
|
26356
|
+
"cleanup"
|
|
26357
|
+
]),
|
|
26358
|
+
deviceKey: string().nullable(),
|
|
26359
|
+
modelId: string().nullable(),
|
|
26360
|
+
/** Streams (device) or sessions (pipeline) of the step running now. */
|
|
26361
|
+
load: number().nullable(),
|
|
26362
|
+
cellsDone: number(),
|
|
26363
|
+
cellsTotal: number(),
|
|
26364
|
+
message: string()
|
|
26365
|
+
});
|
|
26366
|
+
/** What limited a ramp. `none` = the ramp ran out of steps still passing. */
|
|
26367
|
+
var NodeBenchLimitSchema = _enum([
|
|
26368
|
+
"p95",
|
|
26369
|
+
"drops",
|
|
26370
|
+
"errors",
|
|
26371
|
+
"stall",
|
|
26372
|
+
"cpu",
|
|
26373
|
+
"ram",
|
|
26374
|
+
"none"
|
|
26375
|
+
]);
|
|
26376
|
+
var NodeBenchRampStepSchema = object({
|
|
26377
|
+
load: number(),
|
|
26378
|
+
pass: boolean(),
|
|
26379
|
+
p95Ms: number(),
|
|
26380
|
+
dropRatio: number(),
|
|
26381
|
+
/** Completed frames per second over the accounted window. */
|
|
26382
|
+
fps: number(),
|
|
26383
|
+
cpuPct: number().nullable(),
|
|
26384
|
+
ramFreePct: number().nullable(),
|
|
26385
|
+
failReasons: array(string()).readonly()
|
|
26386
|
+
});
|
|
26387
|
+
var NodeBenchCellSchema = discriminatedUnion("phase", [object({
|
|
26388
|
+
phase: literal("device"),
|
|
26389
|
+
deviceKey: string(),
|
|
26390
|
+
modelId: string(),
|
|
26391
|
+
/** Single-stream latency (the K = 1 step). */
|
|
26392
|
+
p50Ms: number(),
|
|
26393
|
+
p95Ms: number(),
|
|
26394
|
+
p99Ms: number(),
|
|
26395
|
+
/** Frames per second sustained at the last passing step. */
|
|
26396
|
+
fps: number(),
|
|
26397
|
+
/** Streams at the camera rate the device carried inside the frame interval; 0 = not even one. */
|
|
26398
|
+
kMax: number(),
|
|
26399
|
+
limitedBy: NodeBenchLimitSchema,
|
|
26400
|
+
/** First call (model load + warm-up). */
|
|
26401
|
+
warmupMs: number(),
|
|
26402
|
+
ramp: array(NodeBenchRampStepSchema).readonly()
|
|
26403
|
+
}), object({
|
|
26404
|
+
phase: literal("pipeline"),
|
|
26405
|
+
deviceKey: string(),
|
|
26406
|
+
modelId: string(),
|
|
26407
|
+
steps: array(string()).readonly(),
|
|
26408
|
+
/** Parallel sessions at the camera rate the node carried; 0 = not even one. */
|
|
26409
|
+
maxSessions: number(),
|
|
26410
|
+
limitedBy: NodeBenchLimitSchema,
|
|
26411
|
+
/** Detail steps that produced at least one result on the clip — a step that never fired measured nothing. */
|
|
26412
|
+
stepsFired: array(string()).readonly(),
|
|
26413
|
+
warmupMs: number(),
|
|
26414
|
+
ramp: array(NodeBenchRampStepSchema).readonly()
|
|
26415
|
+
})]);
|
|
26416
|
+
/**
|
|
26417
|
+
* What a result was measured ON. A result whose fingerprint no longer matches
|
|
26418
|
+
* the node no longer beats the table.
|
|
26419
|
+
*/
|
|
26420
|
+
var NodeBenchFingerprintSchema = object({
|
|
26421
|
+
pipelineVersion: string().nullable(),
|
|
26422
|
+
cpuModel: string().nullable(),
|
|
26423
|
+
ramGb: number().nullable(),
|
|
26424
|
+
os: string().nullable(),
|
|
26425
|
+
/** Per device: the pool the cells ran on (runtime + tuning). */
|
|
26426
|
+
pools: record(string(), object({
|
|
26427
|
+
runtime: string(),
|
|
26428
|
+
numWorkers: number(),
|
|
26429
|
+
concurrency: number(),
|
|
26430
|
+
batchMode: string()
|
|
26431
|
+
})).default({})
|
|
26432
|
+
});
|
|
26433
|
+
/** The frames the run used. */
|
|
26434
|
+
var NodeBenchClipSchema = object({
|
|
26435
|
+
/** `camstack-bench-v1` or `reference-images` (the fallback when the clip is not reachable). */
|
|
26436
|
+
id: string(),
|
|
26437
|
+
revision: string().nullable(),
|
|
26438
|
+
frames: number(),
|
|
26439
|
+
width: number(),
|
|
26440
|
+
height: number()
|
|
26441
|
+
});
|
|
26442
|
+
var NodeBenchRunnerInputSchema = object({
|
|
26443
|
+
runId: string().min(1),
|
|
26444
|
+
devices: array(NodeBenchmarkDevicePlanSchema).min(1),
|
|
26445
|
+
phases: array(NodeBenchmarkPhaseSchema).min(1),
|
|
26446
|
+
/** The full detail step tree root for the `pipeline` measurement is built on the node from these ids. */
|
|
26447
|
+
steps: array(string()).default([]),
|
|
26448
|
+
fpsPerStream: number().int().min(1).max(30),
|
|
26449
|
+
/** The runner stops on its own past this instant, whatever the hub does. */
|
|
26450
|
+
deadlineAtMs: number(),
|
|
26451
|
+
settleSec: number().min(0).max(60).default(NODE_BENCHMARK_DEFAULTS.settleSec),
|
|
26452
|
+
measureSec: number().min(2).max(300).default(NODE_BENCHMARK_DEFAULTS.measureSec),
|
|
26453
|
+
keepDownloadedModels: boolean().default(false)
|
|
26454
|
+
});
|
|
26455
|
+
var NodeBenchRunnerStateSchema = _enum([
|
|
26456
|
+
"running",
|
|
26457
|
+
"done",
|
|
26458
|
+
"failed",
|
|
26459
|
+
"aborted"
|
|
26460
|
+
]);
|
|
26461
|
+
var NodeBenchRunnerStatusSchema = object({
|
|
26462
|
+
runId: string(),
|
|
26463
|
+
nodeId: string(),
|
|
26464
|
+
state: NodeBenchRunnerStateSchema,
|
|
26465
|
+
progress: NodeBenchProgressSchema.nullable(),
|
|
26466
|
+
/** Every finished cell so far — a run stopped half way keeps what it measured. */
|
|
26467
|
+
cells: array(NodeBenchCellSchema).readonly(),
|
|
26468
|
+
fingerprint: NodeBenchFingerprintSchema.nullable(),
|
|
26469
|
+
clip: NodeBenchClipSchema.nullable(),
|
|
26470
|
+
/** Cameras seen running on the node during the run (they share its pools). */
|
|
26471
|
+
activeCameraIds: array(number()).readonly(),
|
|
26472
|
+
/** Models the run downloaded and then deleted (not installed before). */
|
|
26473
|
+
deletedModels: array(string()).readonly(),
|
|
26474
|
+
error: string().nullable(),
|
|
26475
|
+
startedAtMs: number(),
|
|
26476
|
+
finishedAtMs: number().nullable()
|
|
26477
|
+
});
|
|
26478
|
+
var NodeBenchmarkStateSchema = _enum([
|
|
26479
|
+
"draining",
|
|
26480
|
+
"measuring",
|
|
26481
|
+
"restoring",
|
|
26482
|
+
"done",
|
|
26483
|
+
"failed",
|
|
26484
|
+
"aborted"
|
|
26485
|
+
]);
|
|
26486
|
+
/** Why a run ended. */
|
|
26487
|
+
var NodeBenchmarkEndReasonSchema = _enum([
|
|
26488
|
+
"completed",
|
|
26489
|
+
"operator-abort",
|
|
26490
|
+
"deadline",
|
|
26491
|
+
"node-lost",
|
|
26492
|
+
"runner-lost",
|
|
26493
|
+
"hub-restart",
|
|
26494
|
+
"drain-timeout",
|
|
26495
|
+
"failed"
|
|
26496
|
+
]);
|
|
26497
|
+
var NodeBenchmarkRunSchema = object({
|
|
26498
|
+
runId: string(),
|
|
26499
|
+
nodeId: string(),
|
|
26500
|
+
state: NodeBenchmarkStateSchema,
|
|
26501
|
+
plan: NodeBenchmarkPlanSchema,
|
|
26502
|
+
startedAtMs: number(),
|
|
26503
|
+
deadlineAtMs: number(),
|
|
26504
|
+
finishedAtMs: number().nullable(),
|
|
26505
|
+
endReason: NodeBenchmarkEndReasonSchema.nullable(),
|
|
26506
|
+
error: string().nullable(),
|
|
26507
|
+
/** Cameras moved off the node for the run. */
|
|
26508
|
+
moved: array(number()).readonly(),
|
|
26509
|
+
/** Cameras that stayed (their only frame source is the node). */
|
|
26510
|
+
staying: array(number()).readonly(),
|
|
26511
|
+
/** Something else ran on the node's pools during the run. */
|
|
26512
|
+
contaminated: boolean(),
|
|
26513
|
+
progress: NodeBenchProgressSchema.nullable(),
|
|
26514
|
+
resultIds: array(string()).readonly()
|
|
26515
|
+
});
|
|
26516
|
+
/** `getNodeBenchmarkStatus`: the active run (or the last one), and whether benchmark mode is on. */
|
|
26517
|
+
var NodeBenchmarkStatusSchema = object({
|
|
26518
|
+
/** The node the cluster is in benchmark mode for; null = none. */
|
|
26519
|
+
modeNodeId: string().nullable(),
|
|
26520
|
+
run: NodeBenchmarkRunSchema.nullable()
|
|
26521
|
+
});
|
|
26522
|
+
/**
|
|
26523
|
+
* One stored measurement — the only authority Auto tune and the automatic
|
|
26524
|
+
* shares read measured capacity from. Written by the orchestrator when a run
|
|
26525
|
+
* ends, never by anyone else.
|
|
26526
|
+
*/
|
|
26527
|
+
var NodeBenchmarkResultSchema = object({
|
|
26528
|
+
id: string(),
|
|
26529
|
+
runId: string(),
|
|
26530
|
+
nodeId: string(),
|
|
26531
|
+
cell: NodeBenchCellSchema,
|
|
26532
|
+
fpsPerStream: number(),
|
|
26533
|
+
fingerprint: NodeBenchFingerprintSchema.nullable(),
|
|
26534
|
+
clip: NodeBenchClipSchema.nullable(),
|
|
26535
|
+
/** Other work shared the node's pools (a camera that could not move, or the hub's own duties). */
|
|
26536
|
+
contaminated: boolean(),
|
|
26537
|
+
stayingCameras: array(number()).readonly(),
|
|
26538
|
+
/** The run ended early; the cell itself completed. */
|
|
26539
|
+
partialRun: boolean(),
|
|
26540
|
+
measuredAtMs: number()
|
|
26541
|
+
});
|
|
26542
|
+
var ListNodeBenchmarkResultsInputSchema = object({
|
|
26543
|
+
nodeId: string().optional(),
|
|
26544
|
+
deviceKey: string().optional()
|
|
26545
|
+
});
|
|
26546
|
+
/** A result with its standing today: does it still beat the table? */
|
|
26547
|
+
var NodeBenchmarkResultViewSchema = NodeBenchmarkResultSchema.extend({
|
|
26548
|
+
/** `fresh` beats the table; `stale` falls back to it; `superseded` = a newer row covers the same cell. */
|
|
26549
|
+
standing: _enum([
|
|
26550
|
+
"fresh",
|
|
26551
|
+
"stale",
|
|
26552
|
+
"superseded"
|
|
26553
|
+
]),
|
|
26554
|
+
staleWhy: _enum([
|
|
26555
|
+
"age",
|
|
26556
|
+
"runtime",
|
|
26557
|
+
"pool-tuning"
|
|
26558
|
+
]).nullable()
|
|
26559
|
+
});
|
|
26560
|
+
object({
|
|
26561
|
+
runId: string(),
|
|
26562
|
+
nodeId: string(),
|
|
26563
|
+
startedAtMs: number(),
|
|
26564
|
+
deadlineAtMs: number(),
|
|
26565
|
+
plan: NodeBenchmarkPlanSchema,
|
|
26566
|
+
moved: array(number()).readonly(),
|
|
26567
|
+
staying: array(number()).readonly()
|
|
26568
|
+
});
|
|
26569
|
+
/** Candidate detectors per device, for the plan editor. */
|
|
26570
|
+
var NodeBenchmarkCandidatesSchema = object({
|
|
26571
|
+
nodeId: string(),
|
|
26572
|
+
reachable: boolean(),
|
|
26573
|
+
devices: array(object({
|
|
26574
|
+
deviceKey: string(),
|
|
26575
|
+
enabled: boolean(),
|
|
26576
|
+
available: boolean(),
|
|
26577
|
+
/** Ordered: what Auto tune would pick first, then the rest of the family by accuracy. */
|
|
26578
|
+
suggested: array(string()).readonly(),
|
|
26579
|
+
/** Every root detector the device has a build for. */
|
|
26580
|
+
all: array(string()).readonly(),
|
|
26581
|
+
/** The model the device runs now, when pinned. */
|
|
26582
|
+
currentModelId: string().nullable()
|
|
26583
|
+
})).readonly(),
|
|
26584
|
+
/** Detail steps the node's catalog offers under the root (for the `pipeline` measurement). */
|
|
26585
|
+
steps: array(object({
|
|
26586
|
+
id: string(),
|
|
26587
|
+
name: string(),
|
|
26588
|
+
slot: string()
|
|
26589
|
+
})).readonly()
|
|
26590
|
+
});
|
|
25046
26591
|
object({
|
|
25047
26592
|
activeCameras: number(),
|
|
25048
26593
|
throttledCameras: number(),
|
|
@@ -26171,7 +27716,16 @@ method(RunnerCameraConfigSchema, object({ success: literal(true) }), { kind: "mu
|
|
|
26171
27716
|
}), ParkedTrackFrameSchema.nullable()), method(object({
|
|
26172
27717
|
deviceId: number(),
|
|
26173
27718
|
trackId: string()
|
|
26174
|
-
}), object({ released: number().int().nonnegative() }), { kind: "mutation" })
|
|
27719
|
+
}), object({ released: number().int().nonnegative() }), { kind: "mutation" }), method(NodeBenchRunnerInputSchema, object({
|
|
27720
|
+
accepted: literal(true),
|
|
27721
|
+
runId: string()
|
|
27722
|
+
}), {
|
|
27723
|
+
kind: "mutation",
|
|
27724
|
+
auth: "admin"
|
|
27725
|
+
}), method(object({ runId: string() }), NodeBenchRunnerStatusSchema.nullable(), { auth: "admin" }), method(object({ runId: string() }), object({ aborted: boolean() }), {
|
|
27726
|
+
kind: "mutation",
|
|
27727
|
+
auth: "admin"
|
|
27728
|
+
});
|
|
26175
27729
|
var CameraPipelineConfigSchema = object({
|
|
26176
27730
|
engine: PipelineEngineChoiceSchema.optional(),
|
|
26177
27731
|
steps: array(PipelineStepInputSchema).readonly(),
|
|
@@ -26810,6 +28364,21 @@ method(object({
|
|
|
26810
28364
|
}), method(PlacementStatsInputSchema, PlacementStatsSchema, { auth: "admin" }), method(SuggestSharesInputSchema, SuggestSharesResultSchema, { auth: "admin" }), method(_void(), EffectiveSharesSchema, { auth: "admin" }), method(SetShareSourceInputSchema, object({ success: literal(true) }), {
|
|
26811
28365
|
kind: "mutation",
|
|
26812
28366
|
auth: "admin"
|
|
28367
|
+
}), method(NodeBenchmarkPlanSchema, NodeBenchmarkPreflightSchema, { auth: "admin" }), method(NodeBenchmarkPlanSchema, discriminatedUnion("kind", [object({
|
|
28368
|
+
kind: literal("started"),
|
|
28369
|
+
runId: string()
|
|
28370
|
+
}), object({
|
|
28371
|
+
kind: literal("refused"),
|
|
28372
|
+
preflight: NodeBenchmarkPreflightSchema
|
|
28373
|
+
})]), {
|
|
28374
|
+
kind: "mutation",
|
|
28375
|
+
auth: "admin"
|
|
28376
|
+
}), method(_void(), NodeBenchmarkStatusSchema, { auth: "admin" }), method(object({ runId: string() }), object({ aborted: boolean() }), {
|
|
28377
|
+
kind: "mutation",
|
|
28378
|
+
auth: "admin"
|
|
28379
|
+
}), method(object({ nodeId: string() }), NodeBenchmarkCandidatesSchema, { auth: "admin" }), method(ListNodeBenchmarkResultsInputSchema, array(NodeBenchmarkResultViewSchema).readonly(), { auth: "admin" }), method(object({ id: string() }), object({ deleted: boolean() }), {
|
|
28380
|
+
kind: "mutation",
|
|
28381
|
+
auth: "admin"
|
|
26813
28382
|
}), method(object({ deviceId: number() }), CameraPipelineSettingsSchema.nullable()), method(object({
|
|
26814
28383
|
deviceId: number(),
|
|
26815
28384
|
addonId: string(),
|
|
@@ -32925,6 +34494,9 @@ var CreateIntegrationInputSchema = object({
|
|
|
32925
34494
|
enabled: boolean().optional(),
|
|
32926
34495
|
info: record(string(), unknown()).optional(),
|
|
32927
34496
|
settings: record(string(), unknown()).optional(),
|
|
34497
|
+
/** Keys of `settings` the form's schema declares secret (by type) — kept in
|
|
34498
|
+
* the keychain, not the table (D787). */
|
|
34499
|
+
secretKeys: array(string()).optional(),
|
|
32928
34500
|
skipRestart: boolean().optional()
|
|
32929
34501
|
});
|
|
32930
34502
|
var UpdateIntegrationInputSchema = object({
|
|
@@ -32948,7 +34520,9 @@ method(_void(), array(IntegrationWithStateSchema)), method(object({ id: string()
|
|
|
32948
34520
|
auth: "admin"
|
|
32949
34521
|
}), method(object({ id: string() }), record(string(), unknown()), { auth: "admin" }), method(object({
|
|
32950
34522
|
id: string(),
|
|
32951
|
-
settings: record(string(), unknown())
|
|
34523
|
+
settings: record(string(), unknown()),
|
|
34524
|
+
/** Keys the form's schema declares secret (by type) — keychain-stored (D787). */
|
|
34525
|
+
secretKeys: array(string()).optional()
|
|
32952
34526
|
}), object({ success: boolean() }), {
|
|
32953
34527
|
kind: "mutation",
|
|
32954
34528
|
auth: "admin"
|
|
@@ -41111,7 +42685,8 @@ var BaseDevice = class {
|
|
|
41111
42685
|
this.role = options.role;
|
|
41112
42686
|
this.parentDeviceId = ctx.parentDeviceId;
|
|
41113
42687
|
const seedData = ctx.persistedConfig ?? {};
|
|
41114
|
-
|
|
42688
|
+
const declaredSecretPaths = collectZodSecretPaths(schema);
|
|
42689
|
+
this.config = DeviceConfig.fromSchema(schema, (data) => ctx.persistConfig(data, { secretConfigPaths: declaredSecretPaths }), seedData, ({ droppedKeys, issues }) => {
|
|
41115
42690
|
ctx.logger.warn("Device config recovery: dropping invalid persisted fields", {
|
|
41116
42691
|
tags: {
|
|
41117
42692
|
deviceId: ctx.id,
|
|
@@ -44800,6 +46375,90 @@ Object.freeze({
|
|
|
44800
46375
|
addonId: null,
|
|
44801
46376
|
access: "create"
|
|
44802
46377
|
},
|
|
46378
|
+
"keychain.delete": {
|
|
46379
|
+
capName: "keychain",
|
|
46380
|
+
capScope: "system",
|
|
46381
|
+
addonId: null,
|
|
46382
|
+
access: "delete"
|
|
46383
|
+
},
|
|
46384
|
+
"keychain.getState": {
|
|
46385
|
+
capName: "keychain",
|
|
46386
|
+
capScope: "system",
|
|
46387
|
+
addonId: null,
|
|
46388
|
+
access: "view"
|
|
46389
|
+
},
|
|
46390
|
+
"keychain.listMeta": {
|
|
46391
|
+
capName: "keychain",
|
|
46392
|
+
capScope: "system",
|
|
46393
|
+
addonId: null,
|
|
46394
|
+
access: "view"
|
|
46395
|
+
},
|
|
46396
|
+
"keychain.put": {
|
|
46397
|
+
capName: "keychain",
|
|
46398
|
+
capScope: "system",
|
|
46399
|
+
addonId: null,
|
|
46400
|
+
access: "create"
|
|
46401
|
+
},
|
|
46402
|
+
"keychain.resolve": {
|
|
46403
|
+
capName: "keychain",
|
|
46404
|
+
capScope: "system",
|
|
46405
|
+
addonId: null,
|
|
46406
|
+
access: "view"
|
|
46407
|
+
},
|
|
46408
|
+
"keychainAdmin.deleteOrphans": {
|
|
46409
|
+
capName: "keychain-admin",
|
|
46410
|
+
capScope: "system",
|
|
46411
|
+
addonId: null,
|
|
46412
|
+
access: "delete"
|
|
46413
|
+
},
|
|
46414
|
+
"keychainAdmin.downloadRecoveryKey": {
|
|
46415
|
+
capName: "keychain-admin",
|
|
46416
|
+
capScope: "system",
|
|
46417
|
+
addonId: null,
|
|
46418
|
+
access: "create"
|
|
46419
|
+
},
|
|
46420
|
+
"keychainAdmin.listAudit": {
|
|
46421
|
+
capName: "keychain-admin",
|
|
46422
|
+
capScope: "system",
|
|
46423
|
+
addonId: null,
|
|
46424
|
+
access: "view"
|
|
46425
|
+
},
|
|
46426
|
+
"keychainAdmin.listSecrets": {
|
|
46427
|
+
capName: "keychain-admin",
|
|
46428
|
+
capScope: "system",
|
|
46429
|
+
addonId: null,
|
|
46430
|
+
access: "view"
|
|
46431
|
+
},
|
|
46432
|
+
"keychainAdmin.purgeRetiredKeys": {
|
|
46433
|
+
capName: "keychain-admin",
|
|
46434
|
+
capScope: "system",
|
|
46435
|
+
addonId: null,
|
|
46436
|
+
access: "delete"
|
|
46437
|
+
},
|
|
46438
|
+
"keychainAdmin.resetKeychain": {
|
|
46439
|
+
capName: "keychain-admin",
|
|
46440
|
+
capScope: "system",
|
|
46441
|
+
addonId: null,
|
|
46442
|
+
access: "delete"
|
|
46443
|
+
},
|
|
46444
|
+
"keychainAdmin.reveal": {
|
|
46445
|
+
capName: "keychain-admin",
|
|
46446
|
+
capScope: "system",
|
|
46447
|
+
addonId: null,
|
|
46448
|
+
access: "create"
|
|
46449
|
+
},
|
|
46450
|
+
"keychainAdmin.rotateMasterKey": {
|
|
46451
|
+
capName: "keychain-admin",
|
|
46452
|
+
capScope: "system",
|
|
46453
|
+
addonId: null,
|
|
46454
|
+
access: "create"
|
|
46455
|
+
},
|
|
46456
|
+
"keychainAdmin.status": {
|
|
46457
|
+
capName: "keychain-admin",
|
|
46458
|
+
capScope: "system",
|
|
46459
|
+
addonId: null,
|
|
46460
|
+
access: "view"
|
|
46461
|
+
},
|
|
44803
46462
|
"lawnMowerControl.dock": {
|
|
44804
46463
|
capName: "lawn-mower-control",
|
|
44805
46464
|
capScope: "device",
|
|
@@ -46174,6 +47833,18 @@ Object.freeze({
|
|
|
46174
47833
|
addonId: null,
|
|
46175
47834
|
access: "create"
|
|
46176
47835
|
},
|
|
47836
|
+
"pipelineAnalytics.addRetrainFrameFromRecording": {
|
|
47837
|
+
capName: "pipeline-analytics",
|
|
47838
|
+
capScope: "device",
|
|
47839
|
+
addonId: null,
|
|
47840
|
+
access: "create"
|
|
47841
|
+
},
|
|
47842
|
+
"pipelineAnalytics.addRetrainFramesToCollection": {
|
|
47843
|
+
capName: "pipeline-analytics",
|
|
47844
|
+
capScope: "device",
|
|
47845
|
+
addonId: null,
|
|
47846
|
+
access: "create"
|
|
47847
|
+
},
|
|
46177
47848
|
"pipelineAnalytics.applyDeviceSettingsPatch": {
|
|
46178
47849
|
capName: "pipeline-analytics",
|
|
46179
47850
|
capScope: "device",
|
|
@@ -46222,12 +47893,24 @@ Object.freeze({
|
|
|
46222
47893
|
addonId: null,
|
|
46223
47894
|
access: "view"
|
|
46224
47895
|
},
|
|
47896
|
+
"pipelineAnalytics.createRetrainCollection": {
|
|
47897
|
+
capName: "pipeline-analytics",
|
|
47898
|
+
capScope: "device",
|
|
47899
|
+
addonId: null,
|
|
47900
|
+
access: "create"
|
|
47901
|
+
},
|
|
46225
47902
|
"pipelineAnalytics.deleteDeviceEvents": {
|
|
46226
47903
|
capName: "pipeline-analytics",
|
|
46227
47904
|
capScope: "device",
|
|
46228
47905
|
addonId: null,
|
|
46229
47906
|
access: "delete"
|
|
46230
47907
|
},
|
|
47908
|
+
"pipelineAnalytics.deleteRetrainCollection": {
|
|
47909
|
+
capName: "pipeline-analytics",
|
|
47910
|
+
capScope: "device",
|
|
47911
|
+
addonId: null,
|
|
47912
|
+
access: "delete"
|
|
47913
|
+
},
|
|
46231
47914
|
"pipelineAnalytics.deleteTracks": {
|
|
46232
47915
|
capName: "pipeline-analytics",
|
|
46233
47916
|
capScope: "device",
|
|
@@ -46432,6 +48115,24 @@ Object.freeze({
|
|
|
46432
48115
|
addonId: null,
|
|
46433
48116
|
access: "view"
|
|
46434
48117
|
},
|
|
48118
|
+
"pipelineAnalytics.listRetrainAssistProfiles": {
|
|
48119
|
+
capName: "pipeline-analytics",
|
|
48120
|
+
capScope: "device",
|
|
48121
|
+
addonId: null,
|
|
48122
|
+
access: "view"
|
|
48123
|
+
},
|
|
48124
|
+
"pipelineAnalytics.listRetrainCollectionFrames": {
|
|
48125
|
+
capName: "pipeline-analytics",
|
|
48126
|
+
capScope: "device",
|
|
48127
|
+
addonId: null,
|
|
48128
|
+
access: "view"
|
|
48129
|
+
},
|
|
48130
|
+
"pipelineAnalytics.listRetrainCollections": {
|
|
48131
|
+
capName: "pipeline-analytics",
|
|
48132
|
+
capScope: "device",
|
|
48133
|
+
addonId: null,
|
|
48134
|
+
access: "view"
|
|
48135
|
+
},
|
|
46435
48136
|
"pipelineAnalytics.listRetrainFrames": {
|
|
46436
48137
|
capName: "pipeline-analytics",
|
|
46437
48138
|
capScope: "device",
|
|
@@ -46480,6 +48181,12 @@ Object.freeze({
|
|
|
46480
48181
|
addonId: null,
|
|
46481
48182
|
access: "create"
|
|
46482
48183
|
},
|
|
48184
|
+
"pipelineAnalytics.proposeRetrainAnnotationsWithLlm": {
|
|
48185
|
+
capName: "pipeline-analytics",
|
|
48186
|
+
capScope: "device",
|
|
48187
|
+
addonId: null,
|
|
48188
|
+
access: "create"
|
|
48189
|
+
},
|
|
46483
48190
|
"pipelineAnalytics.pruneEvents": {
|
|
46484
48191
|
capName: "pipeline-analytics",
|
|
46485
48192
|
capScope: "device",
|
|
@@ -46534,6 +48241,18 @@ Object.freeze({
|
|
|
46534
48241
|
addonId: null,
|
|
46535
48242
|
access: "create"
|
|
46536
48243
|
},
|
|
48244
|
+
"pipelineAnalytics.removeRetrainFrameFromCollection": {
|
|
48245
|
+
capName: "pipeline-analytics",
|
|
48246
|
+
capScope: "device",
|
|
48247
|
+
addonId: null,
|
|
48248
|
+
access: "delete"
|
|
48249
|
+
},
|
|
48250
|
+
"pipelineAnalytics.renameRetrainCollection": {
|
|
48251
|
+
capName: "pipeline-analytics",
|
|
48252
|
+
capScope: "device",
|
|
48253
|
+
addonId: null,
|
|
48254
|
+
access: "create"
|
|
48255
|
+
},
|
|
46537
48256
|
"pipelineAnalytics.restageRetrainTrack": {
|
|
46538
48257
|
capName: "pipeline-analytics",
|
|
46539
48258
|
capScope: "device",
|
|
@@ -46822,6 +48541,12 @@ Object.freeze({
|
|
|
46822
48541
|
addonId: null,
|
|
46823
48542
|
access: "view"
|
|
46824
48543
|
},
|
|
48544
|
+
"pipelineOrchestrator.abortNodeBenchmark": {
|
|
48545
|
+
capName: "pipeline-orchestrator",
|
|
48546
|
+
capScope: "system",
|
|
48547
|
+
addonId: null,
|
|
48548
|
+
access: "create"
|
|
48549
|
+
},
|
|
46825
48550
|
"pipelineOrchestrator.applyAutoTune": {
|
|
46826
48551
|
capName: "pipeline-orchestrator",
|
|
46827
48552
|
capScope: "system",
|
|
@@ -46846,6 +48571,12 @@ Object.freeze({
|
|
|
46846
48571
|
addonId: null,
|
|
46847
48572
|
access: "create"
|
|
46848
48573
|
},
|
|
48574
|
+
"pipelineOrchestrator.deleteNodeBenchmarkResult": {
|
|
48575
|
+
capName: "pipeline-orchestrator",
|
|
48576
|
+
capScope: "system",
|
|
48577
|
+
addonId: null,
|
|
48578
|
+
access: "delete"
|
|
48579
|
+
},
|
|
46849
48580
|
"pipelineOrchestrator.getAgentLoad": {
|
|
46850
48581
|
capName: "pipeline-orchestrator",
|
|
46851
48582
|
capScope: "system",
|
|
@@ -46954,6 +48685,24 @@ Object.freeze({
|
|
|
46954
48685
|
addonId: null,
|
|
46955
48686
|
access: "view"
|
|
46956
48687
|
},
|
|
48688
|
+
"pipelineOrchestrator.getNodeBenchmarkCandidates": {
|
|
48689
|
+
capName: "pipeline-orchestrator",
|
|
48690
|
+
capScope: "system",
|
|
48691
|
+
addonId: null,
|
|
48692
|
+
access: "view"
|
|
48693
|
+
},
|
|
48694
|
+
"pipelineOrchestrator.getNodeBenchmarkPreflight": {
|
|
48695
|
+
capName: "pipeline-orchestrator",
|
|
48696
|
+
capScope: "system",
|
|
48697
|
+
addonId: null,
|
|
48698
|
+
access: "view"
|
|
48699
|
+
},
|
|
48700
|
+
"pipelineOrchestrator.getNodeBenchmarkStatus": {
|
|
48701
|
+
capName: "pipeline-orchestrator",
|
|
48702
|
+
capScope: "system",
|
|
48703
|
+
addonId: null,
|
|
48704
|
+
access: "view"
|
|
48705
|
+
},
|
|
46957
48706
|
"pipelineOrchestrator.getNodeInferenceDevices": {
|
|
46958
48707
|
capName: "pipeline-orchestrator",
|
|
46959
48708
|
capScope: "system",
|
|
@@ -46996,6 +48745,12 @@ Object.freeze({
|
|
|
46996
48745
|
addonId: null,
|
|
46997
48746
|
access: "view"
|
|
46998
48747
|
},
|
|
48748
|
+
"pipelineOrchestrator.listNodeBenchmarkResults": {
|
|
48749
|
+
capName: "pipeline-orchestrator",
|
|
48750
|
+
capScope: "system",
|
|
48751
|
+
addonId: null,
|
|
48752
|
+
access: "view"
|
|
48753
|
+
},
|
|
46999
48754
|
"pipelineOrchestrator.pauseForStorageMigration": {
|
|
47000
48755
|
capName: "pipeline-orchestrator",
|
|
47001
48756
|
capScope: "system",
|
|
@@ -47140,6 +48895,12 @@ Object.freeze({
|
|
|
47140
48895
|
addonId: null,
|
|
47141
48896
|
access: "create"
|
|
47142
48897
|
},
|
|
48898
|
+
"pipelineOrchestrator.startNodeBenchmark": {
|
|
48899
|
+
capName: "pipeline-orchestrator",
|
|
48900
|
+
capScope: "system",
|
|
48901
|
+
addonId: null,
|
|
48902
|
+
access: "create"
|
|
48903
|
+
},
|
|
47143
48904
|
"pipelineOrchestrator.suggestShares": {
|
|
47144
48905
|
capName: "pipeline-orchestrator",
|
|
47145
48906
|
capScope: "system",
|
|
@@ -47158,6 +48919,12 @@ Object.freeze({
|
|
|
47158
48919
|
addonId: null,
|
|
47159
48920
|
access: "create"
|
|
47160
48921
|
},
|
|
48922
|
+
"pipelineRunner.abortNodeBench": {
|
|
48923
|
+
capName: "pipeline-runner",
|
|
48924
|
+
capScope: "system",
|
|
48925
|
+
addonId: null,
|
|
48926
|
+
access: "create"
|
|
48927
|
+
},
|
|
47161
48928
|
"pipelineRunner.attachCamera": {
|
|
47162
48929
|
capName: "pipeline-runner",
|
|
47163
48930
|
capScope: "system",
|
|
@@ -47206,6 +48973,12 @@ Object.freeze({
|
|
|
47206
48973
|
addonId: null,
|
|
47207
48974
|
access: "view"
|
|
47208
48975
|
},
|
|
48976
|
+
"pipelineRunner.getNodeBenchStatus": {
|
|
48977
|
+
capName: "pipeline-runner",
|
|
48978
|
+
capScope: "system",
|
|
48979
|
+
addonId: null,
|
|
48980
|
+
access: "view"
|
|
48981
|
+
},
|
|
47209
48982
|
"pipelineRunner.getParkedTrackFrame": {
|
|
47210
48983
|
capName: "pipeline-runner",
|
|
47211
48984
|
capScope: "system",
|
|
@@ -47248,6 +49021,12 @@ Object.freeze({
|
|
|
47248
49021
|
addonId: null,
|
|
47249
49022
|
access: "create"
|
|
47250
49023
|
},
|
|
49024
|
+
"pipelineRunner.startNodeBench": {
|
|
49025
|
+
capName: "pipeline-runner",
|
|
49026
|
+
capScope: "system",
|
|
49027
|
+
addonId: null,
|
|
49028
|
+
access: "create"
|
|
49029
|
+
},
|
|
47251
49030
|
"plateGallery.assignPlate": {
|
|
47252
49031
|
capName: "plate-gallery",
|
|
47253
49032
|
capScope: "system",
|
|
@@ -52177,6 +53956,11 @@ Object.freeze({
|
|
|
52177
53956
|
form: "single",
|
|
52178
53957
|
optional: false
|
|
52179
53958
|
}],
|
|
53959
|
+
"pipelineAnalytics.addRetrainFrameFromRecording": [{
|
|
53960
|
+
name: "deviceId",
|
|
53961
|
+
form: "single",
|
|
53962
|
+
optional: false
|
|
53963
|
+
}],
|
|
52180
53964
|
"pipelineAnalytics.applyDeviceSettingsPatch": [{
|
|
52181
53965
|
name: "deviceId",
|
|
52182
53966
|
form: "single",
|
|
@@ -52367,6 +54151,11 @@ Object.freeze({
|
|
|
52367
54151
|
form: "single",
|
|
52368
54152
|
optional: false
|
|
52369
54153
|
}],
|
|
54154
|
+
"pipelineAnalytics.proposeRetrainAnnotationsWithLlm": [{
|
|
54155
|
+
name: "deviceId",
|
|
54156
|
+
form: "single",
|
|
54157
|
+
optional: false
|
|
54158
|
+
}],
|
|
52370
54159
|
"pipelineAnalytics.pruneEventsBefore": [{
|
|
52371
54160
|
name: "deviceId",
|
|
52372
54161
|
form: "single",
|