@camstack/addon-provider-dreame 0.2.129 → 0.2.130
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 +1847 -58
- package/dist/addon.mjs +1847 -58
- package/package.json +1 -1
package/dist/addon.mjs
CHANGED
|
@@ -46205,13 +46205,13 @@ var AI_FEATURE_JSON_KEY = {
|
|
|
46205
46205
|
furnitureDetection: "furniture_detect_switch",
|
|
46206
46206
|
fluidDetection: "fluid_detect_switch"
|
|
46207
46207
|
};
|
|
46208
|
-
function isRecord(v) {
|
|
46208
|
+
function isRecord$2(v) {
|
|
46209
46209
|
return v !== null && typeof v === "object" && !Array.isArray(v);
|
|
46210
46210
|
}
|
|
46211
46211
|
function parseJsonPayload(raw) {
|
|
46212
46212
|
try {
|
|
46213
46213
|
const parsed = JSON.parse(raw);
|
|
46214
|
-
return isRecord(parsed) ? parsed : null;
|
|
46214
|
+
return isRecord$2(parsed) ? parsed : null;
|
|
46215
46215
|
} catch {
|
|
46216
46216
|
return null;
|
|
46217
46217
|
}
|
|
@@ -52899,7 +52899,7 @@ var DreameCameraStream = class extends TypedEmitter {
|
|
|
52899
52899
|
}
|
|
52900
52900
|
};
|
|
52901
52901
|
//#endregion
|
|
52902
|
-
//#region ../types/dist/event-category-
|
|
52902
|
+
//#region ../types/dist/event-category-DaIZi00R.mjs
|
|
52903
52903
|
var EventCategory = /* @__PURE__ */ function(EventCategory) {
|
|
52904
52904
|
EventCategory["SystemBoot"] = "system.boot";
|
|
52905
52905
|
EventCategory["SystemAddonsReady"] = "system.addons-ready";
|
|
@@ -52978,6 +52978,13 @@ var EventCategory = /* @__PURE__ */ function(EventCategory) {
|
|
|
52978
52978
|
*/
|
|
52979
52979
|
EventCategory["AddonLoadFailed"] = "addon.load-failed";
|
|
52980
52980
|
/**
|
|
52981
|
+
* A keychain value was stored or removed (D787). Carries the ref, its
|
|
52982
|
+
* owner and the new version — NEVER the value. A process holding the ref
|
|
52983
|
+
* drops its cached copy and the owning `BaseAddon` re-resolves its config.
|
|
52984
|
+
* Telemetry (D8): a process that misses it still revalidates by version.
|
|
52985
|
+
*/
|
|
52986
|
+
EventCategory["KeychainChanged"] = "keychain.changed";
|
|
52987
|
+
/**
|
|
52981
52988
|
* Addon recovered from a previous failure. Emitted when an addon
|
|
52982
52989
|
* transitions from `failed` back to `healthy` (typically via the
|
|
52983
52990
|
* monitor's auto-retry loop, or after manual `addons.retryLoad`).
|
|
@@ -58270,7 +58277,7 @@ var ZodIssueCode = {
|
|
|
58270
58277
|
var ZodFirstPartyTypeKind;
|
|
58271
58278
|
ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {});
|
|
58272
58279
|
//#endregion
|
|
58273
|
-
//#region ../types/dist/sleep-
|
|
58280
|
+
//#region ../types/dist/sleep-Cr5YOk3m.mjs
|
|
58274
58281
|
/**
|
|
58275
58282
|
* The audio chunk plane's byte format, and the ONE expansion from a coded
|
|
58276
58283
|
* window to float samples (D455).
|
|
@@ -58349,6 +58356,97 @@ function buildAlawTable() {
|
|
|
58349
58356
|
}
|
|
58350
58357
|
buildUlawTable();
|
|
58351
58358
|
buildAlawTable();
|
|
58359
|
+
/** Is this field's stored value a credential? */
|
|
58360
|
+
function isSecretConfigField(field) {
|
|
58361
|
+
if (field.type === "password") return true;
|
|
58362
|
+
return "secret" in field && field.secret === true;
|
|
58363
|
+
}
|
|
58364
|
+
/**
|
|
58365
|
+
* Is this field's value stored in the KEYCHAIN (D787)? Every secret field is,
|
|
58366
|
+
* by its TYPE, unless it opts out with `storage: 'inline'` — never by its name.
|
|
58367
|
+
*/
|
|
58368
|
+
function isKeychainStoredField(field) {
|
|
58369
|
+
if (!isSecretConfigField(field)) return false;
|
|
58370
|
+
if (field.type === "textarea" && field.isJson === true) return false;
|
|
58371
|
+
return !("storage" in field && field.storage === "inline");
|
|
58372
|
+
}
|
|
58373
|
+
/**
|
|
58374
|
+
* What a settings blob holds where a secret used to be.
|
|
58375
|
+
*
|
|
58376
|
+
* A keychain-stored field never holds its value. It holds a self-describing
|
|
58377
|
+
* MARKER, `{"$secret":"secret://…","v":1}` — an object, never a string, so no
|
|
58378
|
+
* code can mistake it for a credential and no form can send it to a camera as
|
|
58379
|
+
* a password. The empty state is `null` / absent, never `''`.
|
|
58380
|
+
*
|
|
58381
|
+
* The same shapes travel to and from the admin UI:
|
|
58382
|
+
*
|
|
58383
|
+
* - read: `hydrateSchema` hands a secret field a {@link SecretFieldView}
|
|
58384
|
+
* (`{ $secret, v, set: true }`) or `null` — the browser learns whether a
|
|
58385
|
+
* value is set, never the value.
|
|
58386
|
+
* - write: an untouched field submits the view back unchanged (KEEP); a typed
|
|
58387
|
+
* value is a plain non-empty string (CHANGE); the Clear button submits
|
|
58388
|
+
* {@link SECRET_CLEAR} (CLEAR). `''`, `null` and the legacy redaction tokens
|
|
58389
|
+
* are KEEP — an empty string is what a defaults-fallback pushes back, and
|
|
58390
|
+
* treating it as "clear" is how a save destroyed a stored credential before.
|
|
58391
|
+
*
|
|
58392
|
+
* Pure and browser-safe.
|
|
58393
|
+
*/
|
|
58394
|
+
var SECRET_CLEAR = { $secretClear: true };
|
|
58395
|
+
/** The `'***'` token D634 redaction writes for non-admins. */
|
|
58396
|
+
var LEGACY_DEVICE_REDACTION = "***";
|
|
58397
|
+
function isRecord$1(value) {
|
|
58398
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
58399
|
+
}
|
|
58400
|
+
function makeSecretMarker(ref) {
|
|
58401
|
+
return {
|
|
58402
|
+
$secret: ref,
|
|
58403
|
+
v: 1
|
|
58404
|
+
};
|
|
58405
|
+
}
|
|
58406
|
+
/** A stored marker: an object whose `$secret` is a non-empty string. */
|
|
58407
|
+
function isSecretMarker(value) {
|
|
58408
|
+
if (!isRecord$1(value)) return false;
|
|
58409
|
+
const ref = value["$secret"];
|
|
58410
|
+
return typeof ref === "string" && ref.length > 0;
|
|
58411
|
+
}
|
|
58412
|
+
function isSecretClear(value) {
|
|
58413
|
+
return isRecord$1(value) && value["$secretClear"] === true;
|
|
58414
|
+
}
|
|
58415
|
+
/**
|
|
58416
|
+
* The UI view of a stored secret field value: a marker becomes "set", inline
|
|
58417
|
+
* plaintext becomes "set (inline)", nothing becomes `null`. A value never
|
|
58418
|
+
* survives this function.
|
|
58419
|
+
*/
|
|
58420
|
+
function toSecretFieldView(stored) {
|
|
58421
|
+
if (isSecretMarker(stored)) return {
|
|
58422
|
+
$secret: stored.$secret,
|
|
58423
|
+
v: 1,
|
|
58424
|
+
set: true
|
|
58425
|
+
};
|
|
58426
|
+
if (typeof stored === "string" && stored.length > 0) return {
|
|
58427
|
+
$secret: null,
|
|
58428
|
+
v: 1,
|
|
58429
|
+
set: true,
|
|
58430
|
+
inline: true
|
|
58431
|
+
};
|
|
58432
|
+
return null;
|
|
58433
|
+
}
|
|
58434
|
+
/**
|
|
58435
|
+
* Classify an incoming value for a secret path. Only a non-empty string that is
|
|
58436
|
+
* not a redaction token sets a value; only {@link SECRET_CLEAR} clears.
|
|
58437
|
+
* Everything else — a marker (ours or anyone's), a UI view, `''`, `null`,
|
|
58438
|
+
* `undefined`, a redaction token, a non-string — keeps what is stored.
|
|
58439
|
+
*/
|
|
58440
|
+
function classifySecretWrite(incoming) {
|
|
58441
|
+
if (isSecretClear(incoming)) return { kind: "clear" };
|
|
58442
|
+
if (typeof incoming !== "string") return { kind: "keep" };
|
|
58443
|
+
if (incoming.length === 0) return { kind: "keep" };
|
|
58444
|
+
if (incoming === "__camstack_redacted__" || incoming === LEGACY_DEVICE_REDACTION) return { kind: "keep" };
|
|
58445
|
+
return {
|
|
58446
|
+
kind: "set",
|
|
58447
|
+
value: incoming
|
|
58448
|
+
};
|
|
58449
|
+
}
|
|
58352
58450
|
Object.fromEntries([
|
|
58353
58451
|
{
|
|
58354
58452
|
id: "overview",
|
|
@@ -58520,33 +58618,19 @@ Object.fromEntries([
|
|
|
58520
58618
|
function isValuelessField(field) {
|
|
58521
58619
|
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";
|
|
58522
58620
|
}
|
|
58523
|
-
|
|
58524
|
-
* Merge a `ConfigUISchema` with a raw `values` record into a
|
|
58525
|
-
* `ConfigUISchemaWithValues`. Used by every `get*Settings` backend endpoint
|
|
58526
|
-
* before returning to the admin UI. Groups are walked recursively.
|
|
58527
|
-
*
|
|
58528
|
-
* For each leaf field:
|
|
58529
|
-
* - structural fields (`separator`, `info`, `button`) pass through unchanged
|
|
58530
|
-
* - other fields get `value = values[key] ?? field.default ?? null`
|
|
58531
|
-
*
|
|
58532
|
-
* Unknown keys in `values` (keys not declared in the schema) are silently
|
|
58533
|
-
* ignored — they don't contribute to the output. Missing keys fall back to
|
|
58534
|
-
* the schema default or `null`. This mirrors the old backend behaviour where
|
|
58535
|
-
* `FormBuilder` rendered `values[key] ?? field.default`.
|
|
58536
|
-
*/
|
|
58537
|
-
function hydrateSchema(schema, values) {
|
|
58621
|
+
function hydrateSchema(schema, values, options = {}) {
|
|
58538
58622
|
return {
|
|
58539
58623
|
...schema.tabs ? { tabs: [...schema.tabs] } : {},
|
|
58540
58624
|
sections: schema.sections.map((section) => ({
|
|
58541
58625
|
...section,
|
|
58542
|
-
fields: section.fields.map((field) => hydrateField(field, values))
|
|
58626
|
+
fields: section.fields.map((field) => hydrateField(field, values, options))
|
|
58543
58627
|
}))
|
|
58544
58628
|
};
|
|
58545
58629
|
}
|
|
58546
|
-
function hydrateField(field, values) {
|
|
58630
|
+
function hydrateField(field, values, options) {
|
|
58547
58631
|
if (isValuelessField(field)) return field;
|
|
58548
58632
|
if (field.type === "group") {
|
|
58549
|
-
const hydratedChildren = field.fields.map((child) => hydrateField(child, values));
|
|
58633
|
+
const hydratedChildren = field.fields.map((child) => hydrateField(child, values, options));
|
|
58550
58634
|
return {
|
|
58551
58635
|
...field,
|
|
58552
58636
|
fields: hydratedChildren
|
|
@@ -58555,7 +58639,7 @@ function hydrateField(field, values) {
|
|
|
58555
58639
|
if (field.type === "sub-tabs") {
|
|
58556
58640
|
const hydratedTabs = field.tabs.map((tab) => ({
|
|
58557
58641
|
...tab,
|
|
58558
|
-
fields: tab.fields.map((child) => hydrateField(child, values))
|
|
58642
|
+
fields: tab.fields.map((child) => hydrateField(child, values, options))
|
|
58559
58643
|
}));
|
|
58560
58644
|
return {
|
|
58561
58645
|
...field,
|
|
@@ -58565,6 +58649,33 @@ function hydrateField(field, values) {
|
|
|
58565
58649
|
const key = field.key;
|
|
58566
58650
|
const storedValue = Object.prototype.hasOwnProperty.call(values, key) ? values[key] : void 0;
|
|
58567
58651
|
const defaultValue = field.default;
|
|
58652
|
+
const asView = (v) => isSecretMarker(v) || options.inlineSecretsAsViews === true && v !== void 0;
|
|
58653
|
+
if (isKeychainStoredField(field) && asView(storedValue)) return {
|
|
58654
|
+
...field,
|
|
58655
|
+
value: toSecretFieldView(storedValue)
|
|
58656
|
+
};
|
|
58657
|
+
if (isKeychainStoredField(field) && options.inlineSecretsAsViews === true) return {
|
|
58658
|
+
...field,
|
|
58659
|
+
value: null
|
|
58660
|
+
};
|
|
58661
|
+
if (field.type === "editable-array" && Array.isArray(storedValue)) {
|
|
58662
|
+
const secretItemKeys = field.itemFields.filter((item) => "key" in item && isKeychainStoredField(item)).map((item) => "key" in item ? item.key : "");
|
|
58663
|
+
if (secretItemKeys.length > 0) {
|
|
58664
|
+
const rows = storedValue.map((row) => {
|
|
58665
|
+
if (row === null || typeof row !== "object" || Array.isArray(row)) return row;
|
|
58666
|
+
const out = { ...row };
|
|
58667
|
+
for (const k of secretItemKeys) {
|
|
58668
|
+
const v = Reflect.get(row, k);
|
|
58669
|
+
if (asView(v)) out[k] = toSecretFieldView(v);
|
|
58670
|
+
}
|
|
58671
|
+
return out;
|
|
58672
|
+
});
|
|
58673
|
+
return {
|
|
58674
|
+
...field,
|
|
58675
|
+
value: rows
|
|
58676
|
+
};
|
|
58677
|
+
}
|
|
58678
|
+
}
|
|
58568
58679
|
if (field.multiple) {
|
|
58569
58680
|
const stored = Array.isArray(storedValue) ? storedValue : storedValue !== void 0 && storedValue !== null ? [storedValue] : [];
|
|
58570
58681
|
const itemFallback = field.multiple.itemDefault !== void 0 ? field.multiple.itemDefault : defaultValue !== void 0 ? defaultValue : typeOf(field) === "string" ? "" : null;
|
|
@@ -58807,6 +58918,431 @@ function projectStore(store, perNodeKeys, nodeId) {
|
|
|
58807
58918
|
}
|
|
58808
58919
|
return out;
|
|
58809
58920
|
}
|
|
58921
|
+
var GLOBAL_SCOPE = { kind: "global" };
|
|
58922
|
+
/** The scope every addon-wide (not per-node, not per-device) setting lives in. */
|
|
58923
|
+
function globalSecretScope() {
|
|
58924
|
+
return GLOBAL_SCOPE;
|
|
58925
|
+
}
|
|
58926
|
+
function encodeSegment(value) {
|
|
58927
|
+
return encodeURIComponent(value);
|
|
58928
|
+
}
|
|
58929
|
+
/**
|
|
58930
|
+
* The field path of a value inside an array item, addressed by the item's id:
|
|
58931
|
+
* `arrayItemFieldPath('providers', 'authentik', 'clientSecret')` →
|
|
58932
|
+
* `providers[authentik].clientSecret`.
|
|
58933
|
+
*/
|
|
58934
|
+
function arrayItemFieldPath(arrayKey, itemId, fieldKey) {
|
|
58935
|
+
return `${arrayKey}[${encodeSegment(itemId)}].${fieldKey}`;
|
|
58936
|
+
}
|
|
58937
|
+
/** A write to a secret path could not be stored in the keychain, so it was refused. */
|
|
58938
|
+
var KeychainWriteRefusedError = class extends Error {
|
|
58939
|
+
fieldPath;
|
|
58940
|
+
constructor(fieldPath, cause) {
|
|
58941
|
+
super(`secret "${fieldPath}" was not saved: the keychain could not store it (${cause instanceof Error ? cause.message : String(cause)}). Nothing was written.`);
|
|
58942
|
+
this.fieldPath = fieldPath;
|
|
58943
|
+
this.name = "KeychainWriteRefusedError";
|
|
58944
|
+
}
|
|
58945
|
+
};
|
|
58946
|
+
var KEEP = { kind: "keep" };
|
|
58947
|
+
function isRecord(value) {
|
|
58948
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
58949
|
+
}
|
|
58950
|
+
function defaultMintId() {
|
|
58951
|
+
return globalThis.crypto.randomUUID();
|
|
58952
|
+
}
|
|
58953
|
+
/** Every marker ref anywhere under `value`. */
|
|
58954
|
+
function collectSecretMarkerRefs(value, out = []) {
|
|
58955
|
+
if (isSecretMarker(value)) {
|
|
58956
|
+
out.push(value.$secret);
|
|
58957
|
+
return out;
|
|
58958
|
+
}
|
|
58959
|
+
if (Array.isArray(value)) for (const item of value) collectSecretMarkerRefs(item, out);
|
|
58960
|
+
else if (isRecord(value)) for (const child of Object.values(value)) collectSecretMarkerRefs(child, out);
|
|
58961
|
+
return out;
|
|
58962
|
+
}
|
|
58963
|
+
async function storedValueEquals(secrets, marker, candidate) {
|
|
58964
|
+
const resolved = (await secrets.resolve([marker.$secret]))[marker.$secret];
|
|
58965
|
+
return resolved?.kind === "value" && resolved.value === candidate;
|
|
58966
|
+
}
|
|
58967
|
+
async function writeLeaf(ctx, incoming, stored, fieldPath) {
|
|
58968
|
+
const intent = classifySecretWrite(incoming);
|
|
58969
|
+
const ref = ctx.secrets.ref(ctx.scope, fieldPath);
|
|
58970
|
+
const storedIsOurs = isSecretMarker(stored) && stored.$secret === ref;
|
|
58971
|
+
if (intent.kind === "keep") return KEEP;
|
|
58972
|
+
if (intent.kind === "set" && !ctx.operatorWrite && typeof stored === "string" && stored === intent.value) return KEEP;
|
|
58973
|
+
if (intent.kind === "clear") {
|
|
58974
|
+
if (storedIsOurs) ctx.deletes.push(ref);
|
|
58975
|
+
return {
|
|
58976
|
+
kind: "value",
|
|
58977
|
+
value: null
|
|
58978
|
+
};
|
|
58979
|
+
}
|
|
58980
|
+
if (storedIsOurs && await storedValueEquals(ctx.secrets, stored, intent.value)) return {
|
|
58981
|
+
kind: "value",
|
|
58982
|
+
value: stored
|
|
58983
|
+
};
|
|
58984
|
+
try {
|
|
58985
|
+
await ctx.secrets.put(ref, intent.value);
|
|
58986
|
+
} catch (err) {
|
|
58987
|
+
throw new KeychainWriteRefusedError(fieldPath, err);
|
|
58988
|
+
}
|
|
58989
|
+
return {
|
|
58990
|
+
kind: "value",
|
|
58991
|
+
value: makeSecretMarker(ref)
|
|
58992
|
+
};
|
|
58993
|
+
}
|
|
58994
|
+
/** Apply a member result onto `out`: KEEP restores the stored member, or removes it. */
|
|
58995
|
+
function applyMember(out, key, result, storedParent) {
|
|
58996
|
+
if (result.kind === "value") {
|
|
58997
|
+
out[key] = result.value;
|
|
58998
|
+
return;
|
|
58999
|
+
}
|
|
59000
|
+
if (Object.prototype.hasOwnProperty.call(storedParent, key)) out[key] = storedParent[key];
|
|
59001
|
+
else delete out[key];
|
|
59002
|
+
}
|
|
59003
|
+
async function writeMembers(ctx, children, incoming, stored, pathOf) {
|
|
59004
|
+
const out = { ...incoming };
|
|
59005
|
+
for (const [member, node] of children) applyMember(out, member, await writeNode(ctx, node, incoming[member], stored[member], pathOf(member)), stored);
|
|
59006
|
+
return out;
|
|
59007
|
+
}
|
|
59008
|
+
function rowId(row, idKey) {
|
|
59009
|
+
const raw = row[idKey];
|
|
59010
|
+
if (typeof raw === "string" && raw.length > 0) return raw;
|
|
59011
|
+
if (typeof raw === "number" && Number.isFinite(raw)) return String(raw);
|
|
59012
|
+
return null;
|
|
59013
|
+
}
|
|
59014
|
+
async function writeArray(ctx, node, incoming, stored, fieldPath) {
|
|
59015
|
+
const storedRows = Array.isArray(stored) ? stored.filter(isRecord) : [];
|
|
59016
|
+
if (!Array.isArray(incoming)) {
|
|
59017
|
+
ctx.deletes.push(...collectSecretMarkerRefs(storedRows));
|
|
59018
|
+
return {
|
|
59019
|
+
kind: "value",
|
|
59020
|
+
value: incoming
|
|
59021
|
+
};
|
|
59022
|
+
}
|
|
59023
|
+
const storedById = /* @__PURE__ */ new Map();
|
|
59024
|
+
for (const row of storedRows) {
|
|
59025
|
+
const id = rowId(row, node.idKey);
|
|
59026
|
+
if (id !== null) storedById.set(id, row);
|
|
59027
|
+
}
|
|
59028
|
+
const kept = /* @__PURE__ */ new Set();
|
|
59029
|
+
const rows = [];
|
|
59030
|
+
for (const row of incoming) {
|
|
59031
|
+
if (!isRecord(row)) {
|
|
59032
|
+
rows.push(row);
|
|
59033
|
+
continue;
|
|
59034
|
+
}
|
|
59035
|
+
const id = rowId(row, node.idKey) ?? ctx.mintId();
|
|
59036
|
+
kept.add(id);
|
|
59037
|
+
const withId = {
|
|
59038
|
+
...row,
|
|
59039
|
+
[node.idKey]: row[node.idKey] ?? id
|
|
59040
|
+
};
|
|
59041
|
+
if (rowId(withId, node.idKey) === null) withId[node.idKey] = id;
|
|
59042
|
+
const storedRow = storedById.get(id) ?? {};
|
|
59043
|
+
rows.push(await writeMembers(ctx, node.item, withId, storedRow, (member) => arrayItemFieldPath(fieldPath, id, member)));
|
|
59044
|
+
}
|
|
59045
|
+
for (const [id, row] of storedById) if (!kept.has(id)) ctx.deletes.push(...collectSecretMarkerRefs(row));
|
|
59046
|
+
return {
|
|
59047
|
+
kind: "value",
|
|
59048
|
+
value: rows
|
|
59049
|
+
};
|
|
59050
|
+
}
|
|
59051
|
+
async function writeNode(ctx, node, incoming, stored, fieldPath) {
|
|
59052
|
+
switch (node.kind) {
|
|
59053
|
+
case "leaf": return writeLeaf(ctx, incoming, stored, fieldPath);
|
|
59054
|
+
case "array": return writeArray(ctx, node, incoming, stored, fieldPath);
|
|
59055
|
+
case "object": {
|
|
59056
|
+
if (!isRecord(incoming)) {
|
|
59057
|
+
if (incoming === void 0) return KEEP;
|
|
59058
|
+
ctx.deletes.push(...collectSecretMarkerRefs(stored));
|
|
59059
|
+
return {
|
|
59060
|
+
kind: "value",
|
|
59061
|
+
value: incoming
|
|
59062
|
+
};
|
|
59063
|
+
}
|
|
59064
|
+
const storedObj = isRecord(stored) ? stored : {};
|
|
59065
|
+
return {
|
|
59066
|
+
kind: "value",
|
|
59067
|
+
value: await writeMembers(ctx, node.children, incoming, storedObj, (m) => `${fieldPath}.${m}`)
|
|
59068
|
+
};
|
|
59069
|
+
}
|
|
59070
|
+
}
|
|
59071
|
+
}
|
|
59072
|
+
/** Split a perNode-scoped key (`key@nodeId`). */
|
|
59073
|
+
function splitNodeKey(key) {
|
|
59074
|
+
const at = key.indexOf("@");
|
|
59075
|
+
return at <= 0 ? {
|
|
59076
|
+
base: key,
|
|
59077
|
+
nodeId: null
|
|
59078
|
+
} : {
|
|
59079
|
+
base: key.slice(0, at),
|
|
59080
|
+
nodeId: key.slice(at + 1)
|
|
59081
|
+
};
|
|
59082
|
+
}
|
|
59083
|
+
/** Rewrite a settings patch so no secret value reaches the blob. See the file doc. */
|
|
59084
|
+
async function transformSecretWrite(input) {
|
|
59085
|
+
const deletes = [];
|
|
59086
|
+
const base = {
|
|
59087
|
+
secrets: input.secrets,
|
|
59088
|
+
mintId: input.mintId ?? defaultMintId,
|
|
59089
|
+
deletes,
|
|
59090
|
+
operatorWrite: input.operatorWrite === true
|
|
59091
|
+
};
|
|
59092
|
+
const out = {};
|
|
59093
|
+
for (const [key, incoming] of Object.entries(input.patch)) {
|
|
59094
|
+
const { base: baseKey, nodeId } = splitNodeKey(key);
|
|
59095
|
+
const node = input.tree.get(baseKey);
|
|
59096
|
+
if (node === void 0) {
|
|
59097
|
+
out[key] = incoming;
|
|
59098
|
+
continue;
|
|
59099
|
+
}
|
|
59100
|
+
const scope = nodeId !== null && nodeId.length > 0 ? {
|
|
59101
|
+
kind: "node",
|
|
59102
|
+
nodeId
|
|
59103
|
+
} : input.scope ?? globalSecretScope();
|
|
59104
|
+
const result = await writeNode({
|
|
59105
|
+
...base,
|
|
59106
|
+
scope
|
|
59107
|
+
}, node, incoming, input.stored[key], baseKey);
|
|
59108
|
+
if (result.kind === "value") out[key] = result.value;
|
|
59109
|
+
}
|
|
59110
|
+
return {
|
|
59111
|
+
patch: out,
|
|
59112
|
+
afterWrite: async () => {
|
|
59113
|
+
if (deletes.length === 0) return { orphaned: [] };
|
|
59114
|
+
try {
|
|
59115
|
+
await input.secrets.delete([...new Set(deletes)]);
|
|
59116
|
+
return { orphaned: [] };
|
|
59117
|
+
} catch {
|
|
59118
|
+
return { orphaned: [...new Set(deletes)] };
|
|
59119
|
+
}
|
|
59120
|
+
}
|
|
59121
|
+
};
|
|
59122
|
+
}
|
|
59123
|
+
/**
|
|
59124
|
+
* Replace every marker in `value` with its keychain value. Returns the SAME
|
|
59125
|
+
* reference when there is no marker (no allocation, no keychain call).
|
|
59126
|
+
*/
|
|
59127
|
+
async function resolveSecretMarkers(value, secrets) {
|
|
59128
|
+
const refs = collectSecretMarkerRefs(value);
|
|
59129
|
+
if (refs.length === 0) return {
|
|
59130
|
+
value,
|
|
59131
|
+
unresolved: []
|
|
59132
|
+
};
|
|
59133
|
+
const answers = await secrets.resolve(refs);
|
|
59134
|
+
const unresolved = [];
|
|
59135
|
+
for (const ref of new Set(refs)) {
|
|
59136
|
+
const answer = answers[ref];
|
|
59137
|
+
if (answer === void 0) unresolved.push({
|
|
59138
|
+
ref,
|
|
59139
|
+
reason: "not-initialized"
|
|
59140
|
+
});
|
|
59141
|
+
else if (answer.kind === "unavailable") unresolved.push({
|
|
59142
|
+
ref,
|
|
59143
|
+
reason: answer.reason
|
|
59144
|
+
});
|
|
59145
|
+
else if (answer.kind === "missing" || answer.kind === "forbidden") unresolved.push({
|
|
59146
|
+
ref,
|
|
59147
|
+
reason: answer.kind
|
|
59148
|
+
});
|
|
59149
|
+
}
|
|
59150
|
+
const substitute = (v) => {
|
|
59151
|
+
if (isSecretMarker(v)) {
|
|
59152
|
+
const answer = answers[v.$secret];
|
|
59153
|
+
return answer?.kind === "value" ? {
|
|
59154
|
+
keep: true,
|
|
59155
|
+
value: answer.value
|
|
59156
|
+
} : {
|
|
59157
|
+
keep: false,
|
|
59158
|
+
value: void 0
|
|
59159
|
+
};
|
|
59160
|
+
}
|
|
59161
|
+
if (Array.isArray(v)) {
|
|
59162
|
+
const items = [];
|
|
59163
|
+
for (const item of v) {
|
|
59164
|
+
const s = substitute(item);
|
|
59165
|
+
if (s.keep) items.push(s.value);
|
|
59166
|
+
}
|
|
59167
|
+
return {
|
|
59168
|
+
keep: true,
|
|
59169
|
+
value: items
|
|
59170
|
+
};
|
|
59171
|
+
}
|
|
59172
|
+
if (isRecord(v)) {
|
|
59173
|
+
const out = {};
|
|
59174
|
+
for (const [k, child] of Object.entries(v)) {
|
|
59175
|
+
const s = substitute(child);
|
|
59176
|
+
if (s.keep) out[k] = s.value;
|
|
59177
|
+
}
|
|
59178
|
+
return {
|
|
59179
|
+
keep: true,
|
|
59180
|
+
value: out
|
|
59181
|
+
};
|
|
59182
|
+
}
|
|
59183
|
+
return {
|
|
59184
|
+
keep: true,
|
|
59185
|
+
value: v
|
|
59186
|
+
};
|
|
59187
|
+
};
|
|
59188
|
+
return {
|
|
59189
|
+
value: substitute(value).value,
|
|
59190
|
+
unresolved
|
|
59191
|
+
};
|
|
59192
|
+
}
|
|
59193
|
+
function touchesTree(tree, patch) {
|
|
59194
|
+
if (tree.size === 0) return false;
|
|
59195
|
+
for (const key of Object.keys(patch)) {
|
|
59196
|
+
const at = key.indexOf("@");
|
|
59197
|
+
if (tree.has(at > 0 ? key.slice(0, at) : key)) return true;
|
|
59198
|
+
}
|
|
59199
|
+
return false;
|
|
59200
|
+
}
|
|
59201
|
+
/** The blob as stored now; a failed read REFUSES the write instead of guessing. */
|
|
59202
|
+
async function readStoredAddonBlob(raw) {
|
|
59203
|
+
const threeWay = raw.readAddonStoreResult;
|
|
59204
|
+
if (threeWay === void 0) return raw.readAddonStore();
|
|
59205
|
+
const result = await threeWay.call(raw);
|
|
59206
|
+
if (result.kind === "failed") throw new Error(`settings write refused: the stored blob could not be read (${result.error})`);
|
|
59207
|
+
return result.kind === "missing" ? {} : result.value;
|
|
59208
|
+
}
|
|
59209
|
+
function createSecretAwareSettings(raw, opts) {
|
|
59210
|
+
const chains = /* @__PURE__ */ new Map();
|
|
59211
|
+
const serialize = (key, fn) => {
|
|
59212
|
+
const next = (chains.get(key) ?? Promise.resolve()).then(fn, fn);
|
|
59213
|
+
const tail = next.catch(() => void 0);
|
|
59214
|
+
chains.set(key, tail);
|
|
59215
|
+
tail.then(() => {
|
|
59216
|
+
if (chains.get(key) === tail) chains.delete(key);
|
|
59217
|
+
});
|
|
59218
|
+
return next;
|
|
59219
|
+
};
|
|
59220
|
+
const write = async (chainKey, tree, scope, patch, readStored, rawWrite) => {
|
|
59221
|
+
if (!touchesTree(tree, patch)) return rawWrite(patch);
|
|
59222
|
+
return serialize(chainKey, async () => {
|
|
59223
|
+
const stored = await readStored();
|
|
59224
|
+
const result = await transformSecretWrite({
|
|
59225
|
+
tree,
|
|
59226
|
+
secrets: opts.secrets,
|
|
59227
|
+
patch,
|
|
59228
|
+
stored,
|
|
59229
|
+
...scope !== void 0 ? { scope } : {},
|
|
59230
|
+
operatorWrite: opts.isOperatorWrite?.() === true
|
|
59231
|
+
});
|
|
59232
|
+
if (Object.keys(result.patch).length > 0) await rawWrite(result.patch);
|
|
59233
|
+
const { orphaned } = await result.afterWrite();
|
|
59234
|
+
if (orphaned.length > 0) opts.onOrphaned(orphaned);
|
|
59235
|
+
});
|
|
59236
|
+
};
|
|
59237
|
+
const wrapped = {
|
|
59238
|
+
writeAddonStore: (patch) => write("addon", opts.addonTree(), void 0, patch, () => readStoredAddonBlob(raw), (p) => raw.writeAddonStore(p)),
|
|
59239
|
+
writeDeviceStore: (deviceId, patch) => write(`device:${deviceId}`, opts.deviceTree(), {
|
|
59240
|
+
kind: "device",
|
|
59241
|
+
deviceId
|
|
59242
|
+
}, patch, () => raw.readDeviceStore(deviceId), (p) => raw.writeDeviceStore(deviceId, p))
|
|
59243
|
+
};
|
|
59244
|
+
return new Proxy(raw, { get(target, prop, receiver) {
|
|
59245
|
+
if (prop === "writeAddonStore") return wrapped.writeAddonStore;
|
|
59246
|
+
if (prop === "writeDeviceStore") return wrapped.writeDeviceStore;
|
|
59247
|
+
const value = Reflect.get(target, prop, receiver);
|
|
59248
|
+
return typeof value === "function" ? value.bind(target) : value;
|
|
59249
|
+
} });
|
|
59250
|
+
}
|
|
59251
|
+
/** The context the addon sees: identical, except that its settings writes are secret-aware. */
|
|
59252
|
+
function withSecretAwareSettings(context, opts) {
|
|
59253
|
+
const raw = context.settings;
|
|
59254
|
+
if (raw === void 0) return context;
|
|
59255
|
+
const settings = createSecretAwareSettings(raw, opts);
|
|
59256
|
+
return new Proxy(context, { get(target, prop, receiver) {
|
|
59257
|
+
if (prop === "settings") return settings;
|
|
59258
|
+
return Reflect.get(target, prop, receiver);
|
|
59259
|
+
} });
|
|
59260
|
+
}
|
|
59261
|
+
var LEAF = { kind: "leaf" };
|
|
59262
|
+
var DEFAULT_ITEM_ID_KEY = "id";
|
|
59263
|
+
function collectFields(fields, out) {
|
|
59264
|
+
for (const field of fields) {
|
|
59265
|
+
if (field.type === "group") {
|
|
59266
|
+
collectFields(field.fields, out);
|
|
59267
|
+
continue;
|
|
59268
|
+
}
|
|
59269
|
+
if (field.type === "sub-tabs") {
|
|
59270
|
+
for (const tab of field.tabs) collectFields(tab.fields, out);
|
|
59271
|
+
continue;
|
|
59272
|
+
}
|
|
59273
|
+
if (field.type === "editable-array") {
|
|
59274
|
+
const item = /* @__PURE__ */ new Map();
|
|
59275
|
+
for (const itemField of field.itemFields) if ("key" in itemField && isKeychainStoredField(itemField)) item.set(itemField.key, LEAF);
|
|
59276
|
+
if (item.size > 0) out.set(field.key, {
|
|
59277
|
+
kind: "array",
|
|
59278
|
+
idKey: field.itemIdKey ?? DEFAULT_ITEM_ID_KEY,
|
|
59279
|
+
item
|
|
59280
|
+
});
|
|
59281
|
+
continue;
|
|
59282
|
+
}
|
|
59283
|
+
if (!("key" in field) || typeof field.key !== "string") continue;
|
|
59284
|
+
if (isKeychainStoredField(field)) out.set(field.key, LEAF);
|
|
59285
|
+
}
|
|
59286
|
+
}
|
|
59287
|
+
/** The secret tree a settings schema declares. */
|
|
59288
|
+
function secretTreeFromSchema(schema) {
|
|
59289
|
+
const out = /* @__PURE__ */ new Map();
|
|
59290
|
+
if (schema === null) return out;
|
|
59291
|
+
for (const section of schema.sections) collectFields(section.fields, out);
|
|
59292
|
+
return out;
|
|
59293
|
+
}
|
|
59294
|
+
/** Parse `a.b[id].c` into segments; throws on a malformed path (a declaration bug). */
|
|
59295
|
+
function parseSecretStatePath(path) {
|
|
59296
|
+
const segments = [];
|
|
59297
|
+
for (const raw of path.split(".")) {
|
|
59298
|
+
const m = /^([^[\]]+)(?:\[([^[\]]+)\])?$/.exec(raw);
|
|
59299
|
+
if (m === null || m[1] === void 0) throw new Error(`secretStatePaths: malformed path "${path}"`);
|
|
59300
|
+
segments.push(m[2] !== void 0 ? {
|
|
59301
|
+
key: m[1],
|
|
59302
|
+
idKey: m[2]
|
|
59303
|
+
} : { key: m[1] });
|
|
59304
|
+
}
|
|
59305
|
+
if (segments.length === 0) throw new Error(`secretStatePaths: empty path`);
|
|
59306
|
+
if (segments[segments.length - 1]?.idKey !== void 0) throw new Error(`secretStatePaths: "${path}" ends on an array — name the member that is secret`);
|
|
59307
|
+
return segments;
|
|
59308
|
+
}
|
|
59309
|
+
function insert(into, segments) {
|
|
59310
|
+
const [head, ...rest] = segments;
|
|
59311
|
+
if (head === void 0) return;
|
|
59312
|
+
if (rest.length === 0) {
|
|
59313
|
+
into.set(head.key, LEAF);
|
|
59314
|
+
return;
|
|
59315
|
+
}
|
|
59316
|
+
const existing = into.get(head.key);
|
|
59317
|
+
if (head.idKey !== void 0) {
|
|
59318
|
+
const item = new Map(existing?.kind === "array" ? existing.item : []);
|
|
59319
|
+
insert(item, rest);
|
|
59320
|
+
into.set(head.key, {
|
|
59321
|
+
kind: "array",
|
|
59322
|
+
idKey: head.idKey,
|
|
59323
|
+
item
|
|
59324
|
+
});
|
|
59325
|
+
return;
|
|
59326
|
+
}
|
|
59327
|
+
const children = new Map(existing?.kind === "object" ? existing.children : []);
|
|
59328
|
+
insert(children, rest);
|
|
59329
|
+
into.set(head.key, {
|
|
59330
|
+
kind: "object",
|
|
59331
|
+
children
|
|
59332
|
+
});
|
|
59333
|
+
}
|
|
59334
|
+
/** Add hidden-state paths (`secretStatePaths`) to a schema-derived tree. */
|
|
59335
|
+
function mergeSecretStatePaths(tree, paths) {
|
|
59336
|
+
if (paths.length === 0) return tree;
|
|
59337
|
+
const out = new Map(tree);
|
|
59338
|
+
for (const path of paths) insert(out, parseSecretStatePath(path));
|
|
59339
|
+
return out;
|
|
59340
|
+
}
|
|
59341
|
+
/** First retry of a secret the keychain could not serve; doubles to {@link SECRET_RETRY_MAX_MS}. */
|
|
59342
|
+
var SECRET_RETRY_FIRST_MS = 5e3;
|
|
59343
|
+
var SECRET_RETRY_MAX_MS = 5 * 6e4;
|
|
59344
|
+
/** Coalesces a burst of `keychain.changed` events into one re-resolve. */
|
|
59345
|
+
var SECRET_CHANGE_DEBOUNCE_MS = 250;
|
|
58810
59346
|
/**
|
|
58811
59347
|
* Base class for CamStack addons. Eliminates settings boilerplate:
|
|
58812
59348
|
*
|
|
@@ -58876,6 +59412,25 @@ var BaseAddon = class {
|
|
|
58876
59412
|
settingsStoreReady = false;
|
|
58877
59413
|
/** Default config values. Provided via constructor. */
|
|
58878
59414
|
defaults;
|
|
59415
|
+
/**
|
|
59416
|
+
* Hidden-state paths that hold secrets (D787) — values the addon writes
|
|
59417
|
+
* itself (`updateGlobalSettings`, `state()`) that no form field declares.
|
|
59418
|
+
* Stored in the keychain exactly like a `password` field. Syntax:
|
|
59419
|
+
* `'snapshotSigningKey'`, `'identity.pincode'`, `'tokens[userId].accessToken'`
|
|
59420
|
+
* (`key[<id field>]` addresses array items by id, never by index).
|
|
59421
|
+
*/
|
|
59422
|
+
secretStatePaths = [];
|
|
59423
|
+
_addonSecretTree = null;
|
|
59424
|
+
_deviceSecretTree = null;
|
|
59425
|
+
/** Refs the last resolved config pointed at — a change to one re-resolves. */
|
|
59426
|
+
_configSecretRefs = /* @__PURE__ */ new Set();
|
|
59427
|
+
_unresolvedSecrets = [];
|
|
59428
|
+
_secretRetryTimer = null;
|
|
59429
|
+
_secretRetryDelayMs = SECRET_RETRY_FIRST_MS;
|
|
59430
|
+
_secretChangeTimer = null;
|
|
59431
|
+
_secretChangeUnsub = null;
|
|
59432
|
+
/** >0 while an OPERATOR's settings write is being applied. */
|
|
59433
|
+
_operatorWriteDepth = 0;
|
|
58879
59434
|
constructor(defaults) {
|
|
58880
59435
|
this.defaults = defaults;
|
|
58881
59436
|
this._config = { ...defaults };
|
|
@@ -58911,8 +59466,18 @@ var BaseAddon = class {
|
|
|
58911
59466
|
return this._config;
|
|
58912
59467
|
}
|
|
58913
59468
|
async initialize(context) {
|
|
58914
|
-
|
|
59469
|
+
const secrets = context.secrets;
|
|
59470
|
+
this._ctx = secrets !== void 0 ? withSecretAwareSettings(context, {
|
|
59471
|
+
secrets,
|
|
59472
|
+
addonTree: () => this.addonSecretTree(),
|
|
59473
|
+
deviceTree: () => this.deviceSecretTree(),
|
|
59474
|
+
onOrphaned: (refs) => context.logger.warn("keychain refs dropped by a settings write could not be deleted", { meta: { refs: [...refs] } }),
|
|
59475
|
+
isOperatorWrite: () => this._operatorWriteDepth > 0
|
|
59476
|
+
}) : context;
|
|
58915
59477
|
await this.resolveConfig();
|
|
59478
|
+
if (secrets !== void 0) this._secretChangeUnsub = secrets.onChange((ref) => {
|
|
59479
|
+
if (this._configSecretRefs.has(ref)) this.scheduleSecretReresolve(SECRET_CHANGE_DEBOUNCE_MS);
|
|
59480
|
+
});
|
|
58916
59481
|
const result = await this.onInitialize();
|
|
58917
59482
|
this.emitLifecycle(EventCategory.AddonStarted);
|
|
58918
59483
|
const normalized = normalizeAddonInitResult(result);
|
|
@@ -58945,6 +59510,12 @@ var BaseAddon = class {
|
|
|
58945
59510
|
*/
|
|
58946
59511
|
async onHubReachable() {}
|
|
58947
59512
|
async shutdown() {
|
|
59513
|
+
this._secretChangeUnsub?.();
|
|
59514
|
+
this._secretChangeUnsub = null;
|
|
59515
|
+
if (this._secretRetryTimer !== null) clearTimeout(this._secretRetryTimer);
|
|
59516
|
+
if (this._secretChangeTimer !== null) clearTimeout(this._secretChangeTimer);
|
|
59517
|
+
this._secretRetryTimer = null;
|
|
59518
|
+
this._secretChangeTimer = null;
|
|
58948
59519
|
this.emitLifecycle(EventCategory.AddonStopped);
|
|
58949
59520
|
if (this.autoEmitReadiness) this.emitReadinessForProviders("down");
|
|
58950
59521
|
await this.onShutdown();
|
|
@@ -59023,7 +59594,7 @@ var BaseAddon = class {
|
|
|
59023
59594
|
return hydrateSchema(schema, overlay ? {
|
|
59024
59595
|
...projected,
|
|
59025
59596
|
...overlay
|
|
59026
|
-
} : projected);
|
|
59597
|
+
} : projected, { inlineSecretsAsViews: true });
|
|
59027
59598
|
}
|
|
59028
59599
|
/**
|
|
59029
59600
|
* The integration-level view of this addon's settings: exactly the sections
|
|
@@ -59072,7 +59643,7 @@ var BaseAddon = class {
|
|
|
59072
59643
|
return hydrateSchema({
|
|
59073
59644
|
...schema,
|
|
59074
59645
|
sections
|
|
59075
|
-
}, projected);
|
|
59646
|
+
}, projected, { inlineSecretsAsViews: true });
|
|
59076
59647
|
}
|
|
59077
59648
|
/**
|
|
59078
59649
|
* The raw addon store PROJECTED onto the target node's bare per-node keys:
|
|
@@ -59126,18 +59697,50 @@ var BaseAddon = class {
|
|
|
59126
59697
|
value: result.value[key]
|
|
59127
59698
|
};
|
|
59128
59699
|
}
|
|
59700
|
+
/**
|
|
59701
|
+
* The OPERATOR's write — a settings form or an admin API call, dispatched by
|
|
59702
|
+
* the kernel. Identical to {@link updateGlobalSettings}, except that a secret
|
|
59703
|
+
* the operator sends is stored as sent even when it equals a pre-keychain
|
|
59704
|
+
* inline value: the operator re-entering a password is a change, an addon
|
|
59705
|
+
* writing back what it read is not (D787).
|
|
59706
|
+
*/
|
|
59707
|
+
async updateGlobalSettingsAsOperator(patch, nodeId) {
|
|
59708
|
+
this._operatorWriteDepth++;
|
|
59709
|
+
try {
|
|
59710
|
+
await this.applyGlobalPatch(patch, nodeId);
|
|
59711
|
+
} finally {
|
|
59712
|
+
this._operatorWriteDepth--;
|
|
59713
|
+
}
|
|
59714
|
+
}
|
|
59129
59715
|
async updateGlobalSettings(patch, nodeId) {
|
|
59716
|
+
await this.applyGlobalPatch(patch, nodeId);
|
|
59717
|
+
}
|
|
59718
|
+
/**
|
|
59719
|
+
* REMOVE stored secrets — their keychain values and their markers (D787).
|
|
59720
|
+
*
|
|
59721
|
+
* Writing `''` to a secret field KEEPS what is stored (an empty string is
|
|
59722
|
+
* what a defaults fallback writes back, and it must never destroy a
|
|
59723
|
+
* credential), so code that means "forget this token" says so here. Without
|
|
59724
|
+
* a keychain (an older kernel) it writes `''`, as such code always did.
|
|
59725
|
+
*/
|
|
59726
|
+
async clearSecrets(keys, nodeId) {
|
|
59727
|
+
const tree = this.addonSecretTree();
|
|
59728
|
+
const keychain = this._ctx?.secrets !== void 0;
|
|
59729
|
+
const patch = {};
|
|
59730
|
+
for (const key of keys) patch[key] = keychain && tree.has(key) ? SECRET_CLEAR : "";
|
|
59731
|
+
await this.applyGlobalPatch(patch, nodeId);
|
|
59732
|
+
}
|
|
59733
|
+
async applyGlobalPatch(barePatch, nodeId) {
|
|
59130
59734
|
const keys = this.perNodeKeys();
|
|
59131
59735
|
const localNode = normalizeNodeId(this._ctx?.kernel?.localNodeId);
|
|
59132
59736
|
const target = normalizeNodeId(nodeId ?? this._ctx?.kernel?.localNodeId);
|
|
59133
|
-
const barePatch = patch;
|
|
59134
59737
|
const scoped = keys.size > 0 ? scopePatch(barePatch, keys, target) : barePatch;
|
|
59135
59738
|
await this._ctx?.settings?.writeAddonStore(scoped);
|
|
59136
59739
|
if (target !== localNode) return;
|
|
59137
59740
|
await this.resolveConfig();
|
|
59138
59741
|
await this.onConfigChanged();
|
|
59139
59742
|
this.emitLifecycle(EventCategory.AddonUpdated, { level: "global" });
|
|
59140
|
-
this.maybeAutoRestart(
|
|
59743
|
+
this.maybeAutoRestart(Object.keys(barePatch), this.globalSettingsSchema());
|
|
59141
59744
|
}
|
|
59142
59745
|
/**
|
|
59143
59746
|
* The set of field keys the global settings schema declares `perNode: true`
|
|
@@ -59162,7 +59765,7 @@ var BaseAddon = class {
|
|
|
59162
59765
|
* time to return its response before the addon is torn down and
|
|
59163
59766
|
* re-initialised by `AddonRegistryService.restartAddon`.
|
|
59164
59767
|
*/
|
|
59165
|
-
maybeAutoRestart(
|
|
59768
|
+
maybeAutoRestart(patchKeys, schema) {
|
|
59166
59769
|
if (!schema) return;
|
|
59167
59770
|
const restartKeys = /* @__PURE__ */ new Set();
|
|
59168
59771
|
for (const section of schema.sections) for (const field of section.fields) {
|
|
@@ -59170,13 +59773,13 @@ var BaseAddon = class {
|
|
|
59170
59773
|
if (field.requiresRestart) restartKeys.add(field.key);
|
|
59171
59774
|
}
|
|
59172
59775
|
if (restartKeys.size === 0) return;
|
|
59173
|
-
if (!
|
|
59776
|
+
if (!patchKeys.some((k) => restartKeys.has(k))) return;
|
|
59174
59777
|
const ctx = this._ctx;
|
|
59175
59778
|
if (!ctx) return;
|
|
59176
59779
|
const addonId = ctx.id;
|
|
59177
59780
|
setImmediate(() => {
|
|
59178
59781
|
ctx.api.addons?.restartAddon?.mutate({ addonId }).then(() => {
|
|
59179
|
-
ctx.logger.info("addon auto-restart triggered by restart-required setting change", { meta: { changedFields:
|
|
59782
|
+
ctx.logger.info("addon auto-restart triggered by restart-required setting change", { meta: { changedFields: patchKeys.filter((k) => restartKeys.has(k)) } });
|
|
59180
59783
|
}).catch((err) => {
|
|
59181
59784
|
ctx.logger.error("addon auto-restart failed", { meta: { error: err instanceof Error ? err.message : String(err) } });
|
|
59182
59785
|
});
|
|
@@ -59185,7 +59788,7 @@ var BaseAddon = class {
|
|
|
59185
59788
|
async getDeviceSettings(deviceId) {
|
|
59186
59789
|
const schema = this.deviceSettingsSchema();
|
|
59187
59790
|
if (!schema) return { sections: [] };
|
|
59188
|
-
return hydrateSchema(schema, await this._ctx?.settings?.readDeviceStore(deviceId) ?? {});
|
|
59791
|
+
return hydrateSchema(schema, await this._ctx?.settings?.readDeviceStore(deviceId) ?? {}, { inlineSecretsAsViews: true });
|
|
59189
59792
|
}
|
|
59190
59793
|
async updateDeviceSettings(deviceId, patch) {
|
|
59191
59794
|
await this._ctx?.settings?.writeDeviceStore(deviceId, patch);
|
|
@@ -59315,7 +59918,7 @@ var BaseAddon = class {
|
|
|
59315
59918
|
* selection at boot (absent scoped key ⇒ the constructor default wins).
|
|
59316
59919
|
*/
|
|
59317
59920
|
async resolveConfig() {
|
|
59318
|
-
const stored = await this.readAddonStoreWithRetry();
|
|
59921
|
+
const stored = await this.resolveStoredSecrets(await this.readAddonStoreWithRetry());
|
|
59319
59922
|
const perNode = this.perNodeKeys();
|
|
59320
59923
|
const localNode = normalizeNodeId(this._ctx?.kernel?.localNodeId);
|
|
59321
59924
|
const resolved = { ...this.defaults };
|
|
@@ -59340,7 +59943,7 @@ var BaseAddon = class {
|
|
|
59340
59943
|
key,
|
|
59341
59944
|
schema,
|
|
59342
59945
|
fallback,
|
|
59343
|
-
read: () => this.readAddonStoreWithRetry(),
|
|
59946
|
+
read: async () => this.resolveStoredSecrets(await this.readAddonStoreWithRetry()),
|
|
59344
59947
|
write: async (patch) => {
|
|
59345
59948
|
await this._ctx?.settings?.writeAddonStore(patch);
|
|
59346
59949
|
},
|
|
@@ -59357,7 +59960,7 @@ var BaseAddon = class {
|
|
|
59357
59960
|
key,
|
|
59358
59961
|
schema,
|
|
59359
59962
|
fallback,
|
|
59360
|
-
read: async () => await this._ctx?.settings?.readDeviceStore(deviceId) ?? {},
|
|
59963
|
+
read: async () => this.resolveStoredSecrets(await this._ctx?.settings?.readDeviceStore(deviceId) ?? {}, false),
|
|
59361
59964
|
write: async (patch) => {
|
|
59362
59965
|
await this._ctx?.settings?.writeDeviceStore(deviceId, patch);
|
|
59363
59966
|
},
|
|
@@ -59369,6 +59972,70 @@ var BaseAddon = class {
|
|
|
59369
59972
|
} })
|
|
59370
59973
|
});
|
|
59371
59974
|
}
|
|
59975
|
+
/** The addon store's secret tree: schema fields by TYPE, plus `secretStatePaths`. */
|
|
59976
|
+
addonSecretTree() {
|
|
59977
|
+
this._addonSecretTree ??= mergeSecretStatePaths(secretTreeFromSchema(this.globalSettingsSchema()), this.secretStatePaths);
|
|
59978
|
+
return this._addonSecretTree;
|
|
59979
|
+
}
|
|
59980
|
+
deviceSecretTree() {
|
|
59981
|
+
this._deviceSecretTree ??= secretTreeFromSchema(this.deviceSettingsSchema());
|
|
59982
|
+
return this._deviceSecretTree;
|
|
59983
|
+
}
|
|
59984
|
+
/**
|
|
59985
|
+
* Secrets of this addon's stored config that could not be resolved on the
|
|
59986
|
+
* last read, with why. Non-empty means the addon is running WITHOUT them —
|
|
59987
|
+
* an addon whose function needs one should report itself degraded rather
|
|
59988
|
+
* than start on an empty credential.
|
|
59989
|
+
*/
|
|
59990
|
+
get unresolvedSecrets() {
|
|
59991
|
+
return this._unresolvedSecrets;
|
|
59992
|
+
}
|
|
59993
|
+
/**
|
|
59994
|
+
* Substitute every keychain marker in a stored blob with its value. With no
|
|
59995
|
+
* keychain (no `ctx.secrets`) or no marker, the blob comes back unchanged.
|
|
59996
|
+
* An unresolvable value is LEFT OUT (never `''`), logged by ref — never by
|
|
59997
|
+
* value — and, when the cause can pass, retried with backoff. Nothing is
|
|
59998
|
+
* ever written back from here.
|
|
59999
|
+
*/
|
|
60000
|
+
async resolveStoredSecrets(blob, trackForConfig = true) {
|
|
60001
|
+
const secrets = this._ctx?.secrets;
|
|
60002
|
+
if (secrets === void 0) return blob;
|
|
60003
|
+
const refs = collectSecretMarkerRefs(blob);
|
|
60004
|
+
if (trackForConfig) this._configSecretRefs = new Set(refs);
|
|
60005
|
+
if (refs.length === 0) {
|
|
60006
|
+
if (trackForConfig) this._unresolvedSecrets = [];
|
|
60007
|
+
return blob;
|
|
60008
|
+
}
|
|
60009
|
+
const { value, unresolved } = await resolveSecretMarkers(blob, secrets);
|
|
60010
|
+
if (trackForConfig) {
|
|
60011
|
+
this._unresolvedSecrets = unresolved;
|
|
60012
|
+
if (unresolved.length > 0) {
|
|
60013
|
+
this._ctx?.logger?.error?.("secret unavailable — running without it, will retry", { meta: { secrets: unresolved.map((u) => ({
|
|
60014
|
+
ref: u.ref,
|
|
60015
|
+
reason: u.reason
|
|
60016
|
+
})) } });
|
|
60017
|
+
if (unresolved.some((u) => u.reason !== "missing" && u.reason !== "forbidden")) {
|
|
60018
|
+
this.scheduleSecretReresolve(this._secretRetryDelayMs);
|
|
60019
|
+
this._secretRetryDelayMs = Math.min(this._secretRetryDelayMs * 2, SECRET_RETRY_MAX_MS);
|
|
60020
|
+
}
|
|
60021
|
+
} else this._secretRetryDelayMs = SECRET_RETRY_FIRST_MS;
|
|
60022
|
+
}
|
|
60023
|
+
return value;
|
|
60024
|
+
}
|
|
60025
|
+
/** Re-resolve the config (a keychain-only change, or a retry) and apply it. */
|
|
60026
|
+
scheduleSecretReresolve(delayMs) {
|
|
60027
|
+
const timerOf = delayMs === SECRET_CHANGE_DEBOUNCE_MS ? "_secretChangeTimer" : "_secretRetryTimer";
|
|
60028
|
+
if (this[timerOf] !== null) return;
|
|
60029
|
+
const timer = setTimeout(() => {
|
|
60030
|
+
this[timerOf] = null;
|
|
60031
|
+
if (this._ctx === null) return;
|
|
60032
|
+
this.resolveConfig().then(() => this.onConfigChanged()).catch((err) => {
|
|
60033
|
+
this._ctx?.logger?.error?.("re-resolving secrets failed", { meta: { error: err instanceof Error ? err.message : String(err) } });
|
|
60034
|
+
});
|
|
60035
|
+
}, delayMs);
|
|
60036
|
+
timer.unref?.();
|
|
60037
|
+
this[timerOf] = timer;
|
|
60038
|
+
}
|
|
59372
60039
|
/**
|
|
59373
60040
|
* Wrap `ctx.settings.readAddonStore()` with a short retry budget so a
|
|
59374
60041
|
* transient settings-store outage (mid-restart of sqlite-settings, tsx-watch
|
|
@@ -59944,6 +60611,69 @@ method(object({ deviceId: number() }), array(StreamSourceEntrySchema)), method(o
|
|
|
59944
60611
|
kind: "mutation",
|
|
59945
60612
|
auth: "admin"
|
|
59946
60613
|
}), method(object({ deviceId: number() }), unknown().nullable()), method(object({ deviceId: number() }), RawStateResultSchema.nullable(), { auth: "protected" });
|
|
60614
|
+
function defOf(schema) {
|
|
60615
|
+
return schema._zod?.def ?? {};
|
|
60616
|
+
}
|
|
60617
|
+
function declaredHere(schema) {
|
|
60618
|
+
return globalRegistry.get(schema)?.secret === true;
|
|
60619
|
+
}
|
|
60620
|
+
/** Wrapper kinds whose `innerType` is the field itself. */
|
|
60621
|
+
var WRAPPERS = new Set([
|
|
60622
|
+
"optional",
|
|
60623
|
+
"nullable",
|
|
60624
|
+
"default",
|
|
60625
|
+
"prefault",
|
|
60626
|
+
"catch",
|
|
60627
|
+
"readonly",
|
|
60628
|
+
"nonoptional"
|
|
60629
|
+
]);
|
|
60630
|
+
/**
|
|
60631
|
+
* The schema layers that make up ONE field: the schema itself and every
|
|
60632
|
+
* wrapper below it (optional / default / nullable / readonly / catch), plus
|
|
60633
|
+
* both sides of a pipe (`z.preprocess` puts the real schema on `out`,
|
|
60634
|
+
* `.transform` on `in`).
|
|
60635
|
+
*/
|
|
60636
|
+
function layersOf(schema) {
|
|
60637
|
+
const out = [];
|
|
60638
|
+
const queue = [schema];
|
|
60639
|
+
while (queue.length > 0) {
|
|
60640
|
+
const s = queue.shift();
|
|
60641
|
+
if (!s || out.includes(s)) continue;
|
|
60642
|
+
out.push(s);
|
|
60643
|
+
const def = defOf(s);
|
|
60644
|
+
if (def.type !== void 0 && WRAPPERS.has(def.type) && def.innerType) queue.push(def.innerType);
|
|
60645
|
+
if (def.type === "pipe") {
|
|
60646
|
+
if (def.in) queue.push(def.in);
|
|
60647
|
+
if (def.out) queue.push(def.out);
|
|
60648
|
+
}
|
|
60649
|
+
}
|
|
60650
|
+
return out;
|
|
60651
|
+
}
|
|
60652
|
+
/** True when any layer of this field declares `.meta({ secret: true })`. */
|
|
60653
|
+
function isZodSecret(schema) {
|
|
60654
|
+
return layersOf(schema).some(declaredHere);
|
|
60655
|
+
}
|
|
60656
|
+
/**
|
|
60657
|
+
* Every declared secret path in a config schema: dotted keys, `[]` for "each
|
|
60658
|
+
* element of this array" (`connection.password`, `rows[].token`). A declared
|
|
60659
|
+
* object or array is reported as one path and not descended into — everything
|
|
60660
|
+
* under it is secret.
|
|
60661
|
+
*/
|
|
60662
|
+
function collectZodSecretPaths(schema, prefix = "") {
|
|
60663
|
+
if (isZodSecret(schema)) return prefix.length > 0 ? [prefix] : [];
|
|
60664
|
+
const paths = [];
|
|
60665
|
+
for (const layer of layersOf(schema)) {
|
|
60666
|
+
const def = defOf(layer);
|
|
60667
|
+
if (def.type === "object" && def.shape) for (const [key, child] of Object.entries(def.shape)) paths.push(...collectZodSecretPaths(child, prefix ? `${prefix}.${key}` : key));
|
|
60668
|
+
else if (def.type === "array" && def.element) paths.push(...collectZodSecretPaths(def.element, `${prefix}[]`));
|
|
60669
|
+
else if (def.type === "union" && def.options) for (const option of def.options) paths.push(...collectZodSecretPaths(option, prefix));
|
|
60670
|
+
else if (def.type === "intersection") {
|
|
60671
|
+
if (def.left) paths.push(...collectZodSecretPaths(def.left, prefix));
|
|
60672
|
+
if (def.right) paths.push(...collectZodSecretPaths(def.right, prefix));
|
|
60673
|
+
}
|
|
60674
|
+
}
|
|
60675
|
+
return [...new Set(paths)];
|
|
60676
|
+
}
|
|
59947
60677
|
//#endregion
|
|
59948
60678
|
//#region ../types/dist/err-msg-DX6i_MY4.mjs
|
|
59949
60679
|
var DeviceType = /* @__PURE__ */ function(DeviceType) {
|
|
@@ -66974,6 +67704,196 @@ id: union([string(), number()]) }), {
|
|
|
66974
67704
|
kind: "mutation",
|
|
66975
67705
|
auth: "admin"
|
|
66976
67706
|
});
|
|
67707
|
+
/**
|
|
67708
|
+
* `keychain` — the hub's encrypted store of secret values (D787).
|
|
67709
|
+
*
|
|
67710
|
+
* Settings blobs never hold a secret: they hold a marker
|
|
67711
|
+
* `{"$secret":"secret://<owner>/<scope>/<fieldPath>","v":1}` and the value
|
|
67712
|
+
* lives here, AES-256-GCM under a data key that a master key wraps. This cap
|
|
67713
|
+
* is the OWNER's door to its own values: every method is owner-checked
|
|
67714
|
+
* against the CALLER, never against anything the caller claims.
|
|
67715
|
+
*
|
|
67716
|
+
* Who the caller is: the transport stamps `callerAddonId` into the args of a
|
|
67717
|
+
* call that crossed a process (the parent `LocalChildRegistry` from the UDS
|
|
67718
|
+
* connection, the agent from its child's connection carried in
|
|
67719
|
+
* `$hub-cap-fwd`'s envelope). A stamp always overwrites; a wire call with no
|
|
67720
|
+
* stamp has its claim stripped. Only a hub in-process caller may state its own
|
|
67721
|
+
* identity — `ctx.secrets` does that with the addon id closed over. This is
|
|
67722
|
+
* identity against BUGS and misrouting, not against a malicious addon (every
|
|
67723
|
+
* runner is the same OS user): see the threat model in
|
|
67724
|
+
* `docs/design/2026-10-08-secrets-keychain.md`.
|
|
67725
|
+
*
|
|
67726
|
+
* `callerAddonId` is deliberately NOT in any input schema: the tRPC router
|
|
67727
|
+
* parses the input, so a session can never supply it, and the internal mount
|
|
67728
|
+
* floors every method to admin anyway (D240).
|
|
67729
|
+
*
|
|
67730
|
+
* Internal: addons reach it through `ctx.secrets`, never directly.
|
|
67731
|
+
*/
|
|
67732
|
+
/** Why a value cannot be served right now. Never folded into "missing". */
|
|
67733
|
+
var KeychainUnavailableReasonSchema = _enum([
|
|
67734
|
+
"key-missing",
|
|
67735
|
+
"wrong-key",
|
|
67736
|
+
"key-file-unreadable",
|
|
67737
|
+
"store-unavailable",
|
|
67738
|
+
"not-initialized",
|
|
67739
|
+
"decrypt-failed"
|
|
67740
|
+
]);
|
|
67741
|
+
var KeychainStateSchema = discriminatedUnion("state", [object({ state: literal("ready") }), object({
|
|
67742
|
+
state: literal("locked"),
|
|
67743
|
+
reason: KeychainUnavailableReasonSchema
|
|
67744
|
+
})]);
|
|
67745
|
+
var KeychainResolveEntrySchema = discriminatedUnion("kind", [
|
|
67746
|
+
object({
|
|
67747
|
+
kind: literal("value"),
|
|
67748
|
+
value: string(),
|
|
67749
|
+
version: number().int()
|
|
67750
|
+
}),
|
|
67751
|
+
object({ kind: literal("missing") }),
|
|
67752
|
+
object({
|
|
67753
|
+
kind: literal("unavailable"),
|
|
67754
|
+
reason: KeychainUnavailableReasonSchema
|
|
67755
|
+
}),
|
|
67756
|
+
object({ kind: literal("forbidden") })
|
|
67757
|
+
]);
|
|
67758
|
+
var KeychainResolveResultSchema = record(string(), KeychainResolveEntrySchema);
|
|
67759
|
+
/** Metadata of one stored value — never the value. */
|
|
67760
|
+
var KeychainSecretMetaSchema = object({
|
|
67761
|
+
ref: string(),
|
|
67762
|
+
owner: string(),
|
|
67763
|
+
/** Formatted scope (`global`, `node/<id>`, `device/<id>`, …). */
|
|
67764
|
+
scope: string(),
|
|
67765
|
+
fieldPath: string(),
|
|
67766
|
+
version: number().int(),
|
|
67767
|
+
createdAt: number(),
|
|
67768
|
+
updatedAt: number(),
|
|
67769
|
+
/** `addon:<id>` | `user:<id>` | `system`. */
|
|
67770
|
+
updatedBy: string(),
|
|
67771
|
+
/** Coarse — written at most once an hour per ref. `null` = never read. */
|
|
67772
|
+
lastReadAt: number().nullable()
|
|
67773
|
+
});
|
|
67774
|
+
var RefListSchema = array(string().min(1)).max(512);
|
|
67775
|
+
method(object({
|
|
67776
|
+
ref: string().min(1),
|
|
67777
|
+
value: string().min(1)
|
|
67778
|
+
}), object({
|
|
67779
|
+
ref: string(),
|
|
67780
|
+
version: number().int()
|
|
67781
|
+
}), {
|
|
67782
|
+
kind: "mutation",
|
|
67783
|
+
auth: "admin"
|
|
67784
|
+
}), method(object({ refs: RefListSchema }), KeychainResolveResultSchema, { auth: "admin" }), method(object({ refs: RefListSchema }), object({ deleted: number().int() }), {
|
|
67785
|
+
kind: "mutation",
|
|
67786
|
+
auth: "admin"
|
|
67787
|
+
}), method(object({}), array(KeychainSecretMetaSchema).readonly(), { auth: "admin" }), method(object({}), KeychainStateSchema, { auth: "admin" });
|
|
67788
|
+
var KeychainKeySourceSchema = object({
|
|
67789
|
+
kind: _enum([
|
|
67790
|
+
"config-file",
|
|
67791
|
+
"previous-config-file",
|
|
67792
|
+
"platform",
|
|
67793
|
+
"default-file"
|
|
67794
|
+
]),
|
|
67795
|
+
/** File sources only — a path is not a secret. */
|
|
67796
|
+
path: string().optional(),
|
|
67797
|
+
/**
|
|
67798
|
+
* True when a whole-volume backup of the data directory carries this key
|
|
67799
|
+
* next to the database it protects (the default file). The page warns.
|
|
67800
|
+
*/
|
|
67801
|
+
sharesBackupWithDatabase: boolean()
|
|
67802
|
+
});
|
|
67803
|
+
var KeychainStatusSchema = object({
|
|
67804
|
+
keychain: KeychainStateSchema,
|
|
67805
|
+
/** The source of the master key in use; `null` while locked. */
|
|
67806
|
+
keySource: KeychainKeySourceSchema.nullable(),
|
|
67807
|
+
/** The source configured to be primary — differs from `keySource` while a rotation is pending. */
|
|
67808
|
+
configuredSource: KeychainKeySourceSchema,
|
|
67809
|
+
/** Short fingerprint of the master key in use (`HMAC(KEK, label)`, 16 hex). */
|
|
67810
|
+
fingerprint: string().nullable(),
|
|
67811
|
+
activeKeyId: string().nullable(),
|
|
67812
|
+
/**
|
|
67813
|
+
* The keychain unlocked with a NON-primary source: the configured primary
|
|
67814
|
+
* key is not the one that wraps the data key yet. `rotateMasterKey` moves it.
|
|
67815
|
+
*/
|
|
67816
|
+
rotationPending: boolean(),
|
|
67817
|
+
/** Wrapped copies of the data key under a previous master key, kept until purged. */
|
|
67818
|
+
retiredWraps: number().int(),
|
|
67819
|
+
recoveryKeyDownloadedAt: number().nullable(),
|
|
67820
|
+
secretCount: number().int()
|
|
67821
|
+
});
|
|
67822
|
+
/**
|
|
67823
|
+
* Whether a stored value is still pointed at by its owner's settings.
|
|
67824
|
+
* `unknown` is a first-class answer: a scope whose blob could not be read is
|
|
67825
|
+
* never reported as an orphan (and never deleted as one).
|
|
67826
|
+
*/
|
|
67827
|
+
var KeychainSecretUsageSchema = _enum([
|
|
67828
|
+
"in-use",
|
|
67829
|
+
"orphan",
|
|
67830
|
+
"unknown"
|
|
67831
|
+
]);
|
|
67832
|
+
var KeychainAdminSecretSchema = KeychainSecretMetaSchema.extend({ usage: KeychainSecretUsageSchema });
|
|
67833
|
+
var KeychainAuditActionSchema = _enum([
|
|
67834
|
+
"put",
|
|
67835
|
+
"delete",
|
|
67836
|
+
"reveal",
|
|
67837
|
+
"rotate-master-key",
|
|
67838
|
+
"purge-retired-keys",
|
|
67839
|
+
"download-recovery-key",
|
|
67840
|
+
"delete-orphans",
|
|
67841
|
+
"reset",
|
|
67842
|
+
"initialize"
|
|
67843
|
+
]);
|
|
67844
|
+
var KeychainAuditEntrySchema = object({
|
|
67845
|
+
id: string(),
|
|
67846
|
+
at: number(),
|
|
67847
|
+
action: KeychainAuditActionSchema,
|
|
67848
|
+
/** `addon:<id>` | `user:<id>` | `system`. */
|
|
67849
|
+
actor: string(),
|
|
67850
|
+
ref: string().nullable(),
|
|
67851
|
+
detail: string().nullable()
|
|
67852
|
+
});
|
|
67853
|
+
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({
|
|
67854
|
+
value: string(),
|
|
67855
|
+
version: number().int()
|
|
67856
|
+
}), {
|
|
67857
|
+
kind: "mutation",
|
|
67858
|
+
auth: "admin",
|
|
67859
|
+
caller: "required"
|
|
67860
|
+
}), method(object({ refs: array(string().min(1)).max(1e3) }), object({
|
|
67861
|
+
deleted: array(string()).readonly(),
|
|
67862
|
+
kept: array(object({
|
|
67863
|
+
ref: string(),
|
|
67864
|
+
usage: KeychainSecretUsageSchema
|
|
67865
|
+
})).readonly()
|
|
67866
|
+
}), {
|
|
67867
|
+
kind: "mutation",
|
|
67868
|
+
auth: "admin",
|
|
67869
|
+
caller: "required"
|
|
67870
|
+
}), method(object({}), object({
|
|
67871
|
+
fingerprint: string(),
|
|
67872
|
+
keySource: KeychainKeySourceSchema
|
|
67873
|
+
}), {
|
|
67874
|
+
kind: "mutation",
|
|
67875
|
+
auth: "admin",
|
|
67876
|
+
caller: "required"
|
|
67877
|
+
}), method(object({}), object({ purged: number().int() }), {
|
|
67878
|
+
kind: "mutation",
|
|
67879
|
+
auth: "admin",
|
|
67880
|
+
caller: "required"
|
|
67881
|
+
}), method(object({}), object({
|
|
67882
|
+
key: string(),
|
|
67883
|
+
fingerprint: string(),
|
|
67884
|
+
keySource: KeychainKeySourceSchema
|
|
67885
|
+
}), {
|
|
67886
|
+
kind: "mutation",
|
|
67887
|
+
auth: "admin",
|
|
67888
|
+
caller: "required"
|
|
67889
|
+
}), method(object({ confirm: literal("RESET KEYCHAIN") }), object({
|
|
67890
|
+
archivedCollection: string().nullable(),
|
|
67891
|
+
archived: number().int()
|
|
67892
|
+
}), {
|
|
67893
|
+
kind: "mutation",
|
|
67894
|
+
auth: "admin",
|
|
67895
|
+
caller: "required"
|
|
67896
|
+
});
|
|
66977
67897
|
method(_void(), object({
|
|
66978
67898
|
id: string(),
|
|
66979
67899
|
name: string(),
|
|
@@ -68216,7 +69136,11 @@ var DeviceRegisterPayloadSchema = object({
|
|
|
68216
69136
|
var DeviceRemovePayloadSchema = object({ deviceId: number() });
|
|
68217
69137
|
var DevicePersistConfigPayloadSchema = object({
|
|
68218
69138
|
deviceId: number(),
|
|
68219
|
-
data: record(string(), unknown())
|
|
69139
|
+
data: record(string(), unknown()),
|
|
69140
|
+
/** The paths the device's schema declares secret (D783), when the caller
|
|
69141
|
+
* knows them — those values are kept in the keychain, not the blob (D787).
|
|
69142
|
+
* Absent: the paths the device last reported at `registerDevice` apply. */
|
|
69143
|
+
secretConfigPaths: array(string()).optional()
|
|
68220
69144
|
});
|
|
68221
69145
|
/** What a migration actually did, per switch. `unreachable` is a first-class
|
|
68222
69146
|
* answer: a camera that could not be asked is not a camera that was silenced. */
|
|
@@ -75245,8 +76169,23 @@ var RetrainMacroClassSchema = _enum([
|
|
|
75245
76169
|
]);
|
|
75246
76170
|
/** A subject to learn, or a phantom to unlearn (taught by OMISSION). */
|
|
75247
76171
|
var RetrainAnnotationKindSchema = _enum(["subject", "model_error"]);
|
|
75248
|
-
/**
|
|
75249
|
-
|
|
76172
|
+
/**
|
|
76173
|
+
* Where a box came from. A machine-sourced box is a DRAFT on the page until
|
|
76174
|
+
* the operator confirms it; once saved it keeps its source as provenance.
|
|
76175
|
+
*
|
|
76176
|
+
* - `operator` — drawn by hand.
|
|
76177
|
+
* - `assist` — proposed by a detector run on the copy (the camera's own
|
|
76178
|
+
* model, or a larger teacher model).
|
|
76179
|
+
* - `pipeline` — the box the live pipeline actually drew on that frame, read
|
|
76180
|
+
* back from the track store (never a re-run).
|
|
76181
|
+
* - `llm` — proposed by a vision-capable LLM profile.
|
|
76182
|
+
*/
|
|
76183
|
+
var RetrainAnnotationSourceSchema = _enum([
|
|
76184
|
+
"operator",
|
|
76185
|
+
"assist",
|
|
76186
|
+
"pipeline",
|
|
76187
|
+
"llm"
|
|
76188
|
+
]);
|
|
75250
76189
|
/** Normalised `[0,1]` rectangle against the FULL frame — the canonical form. */
|
|
75251
76190
|
var RetrainBboxSchema = object({
|
|
75252
76191
|
x: number(),
|
|
@@ -75264,7 +76203,8 @@ var RetrainBboxSchema = object({
|
|
|
75264
76203
|
*/
|
|
75265
76204
|
var RetrainAnnotationSchema = object({
|
|
75266
76205
|
id: string(),
|
|
75267
|
-
|
|
76206
|
+
/** The frame's track. Absent on a recording still, which has none. */
|
|
76207
|
+
trackId: string().optional(),
|
|
75268
76208
|
deviceId: number(),
|
|
75269
76209
|
/** The COPY in retrain storage — never the source track's media key. */
|
|
75270
76210
|
mediaKey: string(),
|
|
@@ -75313,13 +76253,47 @@ var RetrainFrameCandidateSchema = object({
|
|
|
75313
76253
|
* fail, whatever became of the original. */
|
|
75314
76254
|
copied: boolean()
|
|
75315
76255
|
});
|
|
76256
|
+
/**
|
|
76257
|
+
* One box the live pipeline drew on a copied frame — what a correction starts
|
|
76258
|
+
* from. Derived when the frame is listed, from the track store: the subject
|
|
76259
|
+
* box recorded on the source media row when there is one, else the track
|
|
76260
|
+
* position nearest the frame's capture time. Never stored as an annotation
|
|
76261
|
+
* until the operator confirms it.
|
|
76262
|
+
*/
|
|
76263
|
+
var RetrainPipelineBoxSchema = object({
|
|
76264
|
+
/** Normalised `[0,1]` against the full frame. */
|
|
76265
|
+
bbox: RetrainBboxSchema,
|
|
76266
|
+
macroClass: RetrainMacroClassSchema,
|
|
76267
|
+
label: string().optional(),
|
|
76268
|
+
subLabel: string().optional(),
|
|
76269
|
+
/** The detection score of the position used, when it was recorded. */
|
|
76270
|
+
score: number().optional(),
|
|
76271
|
+
/** The root model that produced the track, when it was recorded. */
|
|
76272
|
+
modelId: string().optional(),
|
|
76273
|
+
trackId: string(),
|
|
76274
|
+
/** `subject-box`: recorded on this very frame. `position`: the track's
|
|
76275
|
+
* position nearest the capture time, `deltaMs` away. */
|
|
76276
|
+
basis: _enum(["subject-box", "position"]),
|
|
76277
|
+
deltaMs: number()
|
|
76278
|
+
});
|
|
76279
|
+
/**
|
|
76280
|
+
* Where a retrain frame came from: a TRACK's stored media (copy-on-select),
|
|
76281
|
+
* or the RECORDING at an instant — the frame a model saw nothing in has no
|
|
76282
|
+
* track at all.
|
|
76283
|
+
*/
|
|
76284
|
+
var RetrainFrameOriginSchema = _enum(["track", "recording"]);
|
|
75316
76285
|
/** A frame the dataset OWNS: bytes copied at selection time. */
|
|
75317
76286
|
var RetrainFrameSchema = object({
|
|
75318
76287
|
frameId: string(),
|
|
75319
76288
|
deviceId: number(),
|
|
75320
|
-
|
|
75321
|
-
/**
|
|
75322
|
-
|
|
76289
|
+
origin: RetrainFrameOriginSchema,
|
|
76290
|
+
/** The track it was copied from. Absent on a recording still. */
|
|
76291
|
+
trackId: string().optional(),
|
|
76292
|
+
/** Provenance only. It may already point at nothing — that is expected.
|
|
76293
|
+
* Absent on a recording still. */
|
|
76294
|
+
sourceMediaId: number().int().optional(),
|
|
76295
|
+
/** A recording still: the playhead instant it was taken at. */
|
|
76296
|
+
epochMs: number().optional(),
|
|
75323
76297
|
sourceKind: MediaFileKindEnum,
|
|
75324
76298
|
sizeBytes: number().int(),
|
|
75325
76299
|
width: number().int(),
|
|
@@ -75330,7 +76304,12 @@ var RetrainFrameSchema = object({
|
|
|
75330
76304
|
/** The operator's "every subject in this frame is boxed". Detector
|
|
75331
76305
|
* evaluation keeps only complete frames: an unboxed subject would count as
|
|
75332
76306
|
* a false positive. */
|
|
75333
|
-
complete: boolean()
|
|
76307
|
+
complete: boolean(),
|
|
76308
|
+
/** The boxes the pipeline drew on this frame. Present on list answers;
|
|
76309
|
+
* empty when nothing the track store holds can be placed on it. */
|
|
76310
|
+
pipelineBoxes: array(RetrainPipelineBoxSchema).readonly().optional(),
|
|
76311
|
+
/** The named collections this frame belongs to. Present on list answers. */
|
|
76312
|
+
collectionIds: array(string()).readonly().optional()
|
|
75334
76313
|
});
|
|
75335
76314
|
/** Why a copy-on-select could not be honoured — named, never a silent skip. */
|
|
75336
76315
|
var RetrainCopyRefusalSchema = _enum([
|
|
@@ -75361,6 +76340,8 @@ var RetrainFrameListSchema = object({
|
|
|
75361
76340
|
var RetrainExportFilterSchema = object({
|
|
75362
76341
|
deviceIds: array(number()).optional(),
|
|
75363
76342
|
frameIds: array(string()).max(2e4).optional(),
|
|
76343
|
+
/** Only frames in at least one of these named collections. */
|
|
76344
|
+
collectionIds: array(string()).max(200).optional(),
|
|
75364
76345
|
batchId: string().optional(),
|
|
75365
76346
|
/** Only frames the operator marked complete (all subjects boxed). */
|
|
75366
76347
|
completeOnly: boolean().optional()
|
|
@@ -75425,6 +76406,109 @@ var RetrainAssistResultSchema = discriminatedUnion("kind", [object({
|
|
|
75425
76406
|
reason: string(),
|
|
75426
76407
|
detail: string().optional()
|
|
75427
76408
|
})]);
|
|
76409
|
+
/** A named set over the retrain corpus — membership only, it owns no pixels. */
|
|
76410
|
+
var RetrainCollectionSchema = object({
|
|
76411
|
+
id: string(),
|
|
76412
|
+
name: string(),
|
|
76413
|
+
createdAt: number(),
|
|
76414
|
+
frameCount: number().int()
|
|
76415
|
+
});
|
|
76416
|
+
var RetrainCollectionCreateResultSchema = discriminatedUnion("kind", [object({
|
|
76417
|
+
kind: literal("created"),
|
|
76418
|
+
collection: RetrainCollectionSchema
|
|
76419
|
+
}), object({
|
|
76420
|
+
kind: literal("refused"),
|
|
76421
|
+
reason: _enum(["empty-name", "duplicate-name"])
|
|
76422
|
+
})]);
|
|
76423
|
+
var RetrainCollectionRenameResultSchema = discriminatedUnion("kind", [object({
|
|
76424
|
+
kind: literal("renamed"),
|
|
76425
|
+
collection: RetrainCollectionSchema
|
|
76426
|
+
}), object({
|
|
76427
|
+
kind: literal("refused"),
|
|
76428
|
+
reason: _enum([
|
|
76429
|
+
"empty-name",
|
|
76430
|
+
"duplicate-name",
|
|
76431
|
+
"unknown-collection"
|
|
76432
|
+
])
|
|
76433
|
+
})]);
|
|
76434
|
+
/**
|
|
76435
|
+
* The outcome of adding the frame at a recording instant. Every refusal is
|
|
76436
|
+
* named: `still-unavailable` (not recording, a gap, or an undecodable frame —
|
|
76437
|
+
* `detail` says which), `still-busy` (the recorder is at its decode bound; try
|
|
76438
|
+
* again), `unreadable-image`, `write-failed`, `unknown-collection`.
|
|
76439
|
+
*/
|
|
76440
|
+
var AddRetrainFrameFromRecordingResultSchema = discriminatedUnion("kind", [object({
|
|
76441
|
+
kind: literal("added"),
|
|
76442
|
+
collectionId: string(),
|
|
76443
|
+
frame: RetrainFrameSchema,
|
|
76444
|
+
/** The moment was already in the dataset; nothing was decoded. */
|
|
76445
|
+
reused: boolean()
|
|
76446
|
+
}), object({
|
|
76447
|
+
kind: literal("refused"),
|
|
76448
|
+
reason: _enum([
|
|
76449
|
+
"unknown-collection",
|
|
76450
|
+
"still-unavailable",
|
|
76451
|
+
"still-busy",
|
|
76452
|
+
"unreadable-image",
|
|
76453
|
+
"write-failed"
|
|
76454
|
+
]),
|
|
76455
|
+
detail: string().optional()
|
|
76456
|
+
})]);
|
|
76457
|
+
/** A vision LLM profile the AI assist may use, and where it sends the frame. */
|
|
76458
|
+
var RetrainAssistProfileSchema = object({
|
|
76459
|
+
id: string(),
|
|
76460
|
+
name: string(),
|
|
76461
|
+
model: string(),
|
|
76462
|
+
kind: string(),
|
|
76463
|
+
/** `true` when the frame would leave the house (a cloud vendor, or an
|
|
76464
|
+
* endpoint that is not on the local network). The page confirms each such
|
|
76465
|
+
* run, and the provider refuses one without `allowCloud`. */
|
|
76466
|
+
leavesHouse: boolean()
|
|
76467
|
+
});
|
|
76468
|
+
/** A box the AI assist proposed: a draft, plus the model's own reason. */
|
|
76469
|
+
var RetrainLlmProposalSchema = RetrainAnnotationDraftSchema.extend({ reason: string() });
|
|
76470
|
+
/** What the AI assist said about a box that was already on the canvas. */
|
|
76471
|
+
var RetrainLlmReviewSchema = object({
|
|
76472
|
+
/** The `ref` the page sent the box under. */
|
|
76473
|
+
ref: string(),
|
|
76474
|
+
verdict: _enum([
|
|
76475
|
+
"confirmed",
|
|
76476
|
+
"wrong-class",
|
|
76477
|
+
"not-an-object",
|
|
76478
|
+
"uncertain"
|
|
76479
|
+
]),
|
|
76480
|
+
suggestedClass: RetrainMacroClassSchema.optional(),
|
|
76481
|
+
reason: string()
|
|
76482
|
+
});
|
|
76483
|
+
/**
|
|
76484
|
+
* The AI assist's answer. `proposed` carries drafts (`source: 'llm'`, the
|
|
76485
|
+
* model and its confidence) and reviews; items the model got wrong (a box off
|
|
76486
|
+
* the frame, an unasked class, an unknown ref) are dropped and counted in
|
|
76487
|
+
* `rejected`. A whole answer that is not the schema is `malformed-answer`.
|
|
76488
|
+
*/
|
|
76489
|
+
var RetrainLlmAssistResultSchema = discriminatedUnion("kind", [object({
|
|
76490
|
+
kind: literal("proposed"),
|
|
76491
|
+
profileId: string(),
|
|
76492
|
+
model: string(),
|
|
76493
|
+
/** The frame was sent outside the house for this answer. */
|
|
76494
|
+
leftHouse: boolean(),
|
|
76495
|
+
proposals: array(RetrainLlmProposalSchema).readonly(),
|
|
76496
|
+
reviews: array(RetrainLlmReviewSchema).readonly(),
|
|
76497
|
+
rejected: number().int()
|
|
76498
|
+
}), object({
|
|
76499
|
+
kind: literal("refused"),
|
|
76500
|
+
reason: _enum([
|
|
76501
|
+
"unknown-frame",
|
|
76502
|
+
"unreadable-frame",
|
|
76503
|
+
"unknown-profile",
|
|
76504
|
+
"profile-disabled",
|
|
76505
|
+
"no-vision",
|
|
76506
|
+
"cloud-not-confirmed",
|
|
76507
|
+
"llm-error",
|
|
76508
|
+
"malformed-answer"
|
|
76509
|
+
]),
|
|
76510
|
+
detail: string().optional()
|
|
76511
|
+
})]);
|
|
75428
76512
|
/** The outcome of a lifecycle move owned by the retrain page. */
|
|
75429
76513
|
var RetrainTransitionResultSchema = object({
|
|
75430
76514
|
trackId: string(),
|
|
@@ -76142,7 +77226,7 @@ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).rea
|
|
|
76142
77226
|
auth: "admin"
|
|
76143
77227
|
}), method(object({
|
|
76144
77228
|
deviceId: number(),
|
|
76145
|
-
trackId: string(),
|
|
77229
|
+
trackId: string().optional(),
|
|
76146
77230
|
frameId: string()
|
|
76147
77231
|
}), object({
|
|
76148
77232
|
removed: boolean(),
|
|
@@ -76159,7 +77243,8 @@ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).rea
|
|
|
76159
77243
|
auth: "admin"
|
|
76160
77244
|
}), method(object({
|
|
76161
77245
|
deviceId: number(),
|
|
76162
|
-
|
|
77246
|
+
/** The frame's track, when it has one — checked against the frame. */
|
|
77247
|
+
trackId: string().optional(),
|
|
76163
77248
|
frameId: string(),
|
|
76164
77249
|
subject: RetrainAssistSubjectSchema,
|
|
76165
77250
|
/** Which node runs it. Absent ⇒ wherever an unowned call lands. */
|
|
@@ -76167,12 +77252,16 @@ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).rea
|
|
|
76167
77252
|
}), RetrainAssistResultSchema, {
|
|
76168
77253
|
kind: "mutation",
|
|
76169
77254
|
auth: "admin"
|
|
76170
|
-
}), method(object({
|
|
77255
|
+
}), method(object({
|
|
77256
|
+
trackId: string().optional(),
|
|
77257
|
+
frameIds: array(string()).max(2e3).optional()
|
|
77258
|
+
}), array(RetrainAnnotationSchema).readonly(), {
|
|
76171
77259
|
kind: "query",
|
|
76172
77260
|
auth: "admin"
|
|
76173
77261
|
}), method(object({
|
|
76174
77262
|
deviceId: number(),
|
|
76175
|
-
|
|
77263
|
+
/** The frame's track, when it has one — checked against the frame. */
|
|
77264
|
+
trackId: string().optional(),
|
|
76176
77265
|
frameId: string(),
|
|
76177
77266
|
annotations: array(RetrainAnnotationDraftSchema)
|
|
76178
77267
|
}), array(RetrainAnnotationSchema).readonly(), {
|
|
@@ -76195,7 +77284,7 @@ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).rea
|
|
|
76195
77284
|
auth: "admin"
|
|
76196
77285
|
}), method(object({
|
|
76197
77286
|
deviceId: number(),
|
|
76198
|
-
trackId: string(),
|
|
77287
|
+
trackId: string().optional(),
|
|
76199
77288
|
frameId: string(),
|
|
76200
77289
|
complete: boolean()
|
|
76201
77290
|
}), RetrainFrameSchema, {
|
|
@@ -76209,6 +77298,74 @@ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).rea
|
|
|
76209
77298
|
kind: "mutation",
|
|
76210
77299
|
auth: "admin",
|
|
76211
77300
|
timeoutMs: 60 * 6e4
|
|
77301
|
+
}), method(object({}), array(RetrainAssistProfileSchema).readonly(), {
|
|
77302
|
+
kind: "query",
|
|
77303
|
+
auth: "admin"
|
|
77304
|
+
}), method(object({
|
|
77305
|
+
deviceId: number(),
|
|
77306
|
+
trackId: string().optional(),
|
|
77307
|
+
frameId: string(),
|
|
77308
|
+
profileId: string(),
|
|
77309
|
+
classes: array(RetrainMacroClassSchema).min(1),
|
|
77310
|
+
boxes: array(object({
|
|
77311
|
+
ref: string(),
|
|
77312
|
+
bbox: RetrainBboxSchema,
|
|
77313
|
+
macroClass: RetrainMacroClassSchema,
|
|
77314
|
+
label: string().optional()
|
|
77315
|
+
})).max(50),
|
|
77316
|
+
allowCloud: boolean()
|
|
77317
|
+
}), RetrainLlmAssistResultSchema, {
|
|
77318
|
+
kind: "mutation",
|
|
77319
|
+
auth: "admin",
|
|
77320
|
+
timeoutMs: 18e4
|
|
77321
|
+
}), method(object({ name: string().max(120) }), RetrainCollectionCreateResultSchema, {
|
|
77322
|
+
kind: "mutation",
|
|
77323
|
+
auth: "admin"
|
|
77324
|
+
}), method(object({}), array(RetrainCollectionSchema).readonly(), {
|
|
77325
|
+
kind: "query",
|
|
77326
|
+
auth: "admin"
|
|
77327
|
+
}), method(object({
|
|
77328
|
+
id: string(),
|
|
77329
|
+
name: string().max(120)
|
|
77330
|
+
}), RetrainCollectionRenameResultSchema, {
|
|
77331
|
+
kind: "mutation",
|
|
77332
|
+
auth: "admin"
|
|
77333
|
+
}), method(object({ id: string() }), object({
|
|
77334
|
+
deleted: boolean(),
|
|
77335
|
+
removedFrames: number().int()
|
|
77336
|
+
}), {
|
|
77337
|
+
kind: "mutation",
|
|
77338
|
+
auth: "admin"
|
|
77339
|
+
}), method(object({
|
|
77340
|
+
collectionId: string(),
|
|
77341
|
+
deviceId: number(),
|
|
77342
|
+
epochMs: number()
|
|
77343
|
+
}), AddRetrainFrameFromRecordingResultSchema, {
|
|
77344
|
+
kind: "mutation",
|
|
77345
|
+
auth: "admin",
|
|
77346
|
+
timeoutMs: 6e4
|
|
77347
|
+
}), method(object({
|
|
77348
|
+
collectionId: string(),
|
|
77349
|
+
frameIds: array(string()).min(1).max(500)
|
|
77350
|
+
}), object({
|
|
77351
|
+
added: number().int(),
|
|
77352
|
+
alreadyMember: number().int(),
|
|
77353
|
+
unknownFrameIds: array(string()).readonly()
|
|
77354
|
+
}), {
|
|
77355
|
+
kind: "mutation",
|
|
77356
|
+
auth: "admin"
|
|
77357
|
+
}), method(object({
|
|
77358
|
+
collectionId: string(),
|
|
77359
|
+
frameId: string()
|
|
77360
|
+
}), object({
|
|
77361
|
+
removed: boolean(),
|
|
77362
|
+
deletedFrame: boolean()
|
|
77363
|
+
}), {
|
|
77364
|
+
kind: "mutation",
|
|
77365
|
+
auth: "admin"
|
|
77366
|
+
}), method(object({ collectionId: string() }), array(RetrainFrameSchema).readonly(), {
|
|
77367
|
+
kind: "query",
|
|
77368
|
+
auth: "admin"
|
|
76212
77369
|
}), method(object({
|
|
76213
77370
|
/** Which of the three event tables owns the row. */
|
|
76214
77371
|
ownerType: EventOwnerTypeSchema,
|
|
@@ -76832,13 +77989,31 @@ var RecommendationReasonSchema = discriminatedUnion("kind", [
|
|
|
76832
77989
|
object({
|
|
76833
77990
|
kind: literal("no-family-build"),
|
|
76834
77991
|
format: ModelFormatSchema$1
|
|
77992
|
+
}),
|
|
77993
|
+
object({
|
|
77994
|
+
kind: literal("kept-custom-pin"),
|
|
77995
|
+
modelId: string(),
|
|
77996
|
+
deviceKey: string()
|
|
76835
77997
|
})
|
|
76836
77998
|
]);
|
|
77999
|
+
/** Why a device is left exactly as it is, whatever the plan would pick (D786). */
|
|
78000
|
+
var KeptReasonSchema = _enum(["custom-pin"]);
|
|
78001
|
+
/**
|
|
78002
|
+
* Where a choice's latency came from (D791): this node's own benchmark
|
|
78003
|
+
* result, or the hardware-class table. Measured on the node beats the table.
|
|
78004
|
+
*/
|
|
78005
|
+
var LatencySourceSchema = discriminatedUnion("kind", [object({ kind: literal("table") }), object({
|
|
78006
|
+
kind: literal("node-benchmark"),
|
|
78007
|
+
resultId: string(),
|
|
78008
|
+
measuredAtMs: number()
|
|
78009
|
+
})]);
|
|
76837
78010
|
var DeviceModelChoiceSchema = object({
|
|
76838
78011
|
modelId: string(),
|
|
76839
78012
|
p50Ms: number(),
|
|
76840
78013
|
fps: number(),
|
|
76841
78014
|
measured: boolean(),
|
|
78015
|
+
/** Absent on a plan from before D791 — read as the table. */
|
|
78016
|
+
source: LatencySourceSchema.optional(),
|
|
76842
78017
|
/** Parallel sessions at the camera rate with the headroom kept free: ⌊fps × (1 − headroom) / camera fps⌋. */
|
|
76843
78018
|
capacitySessions: number(),
|
|
76844
78019
|
personRecall: number()
|
|
@@ -76849,6 +78024,8 @@ var DeviceRecommendationSchema = object({
|
|
|
76849
78024
|
enabled: boolean(),
|
|
76850
78025
|
available: boolean(),
|
|
76851
78026
|
chosen: DeviceModelChoiceSchema.nullable(),
|
|
78027
|
+
/** Present when the device is kept as is: Apply writes nothing on it. */
|
|
78028
|
+
kept: KeptReasonSchema.optional(),
|
|
76852
78029
|
reasons: array(RecommendationReasonSchema).readonly()
|
|
76853
78030
|
});
|
|
76854
78031
|
var NodeRecommendationSchema = object({
|
|
@@ -76902,6 +78079,17 @@ var AutoTuneWarningSchema = discriminatedUnion("kind", [
|
|
|
76902
78079
|
kind: literal("coral-enabled"),
|
|
76903
78080
|
nodeId: string(),
|
|
76904
78081
|
deviceKey: string()
|
|
78082
|
+
}),
|
|
78083
|
+
object({
|
|
78084
|
+
kind: literal("custom-pin-kept"),
|
|
78085
|
+
nodeId: string(),
|
|
78086
|
+
deviceKey: string().nullable(),
|
|
78087
|
+
deviceId: number().nullable(),
|
|
78088
|
+
modelId: string()
|
|
78089
|
+
}),
|
|
78090
|
+
object({
|
|
78091
|
+
kind: literal("custom-registry-unreadable"),
|
|
78092
|
+
error: string()
|
|
76905
78093
|
})
|
|
76906
78094
|
]);
|
|
76907
78095
|
var AutoTuneOptionsSchema = object({
|
|
@@ -77080,13 +78268,14 @@ var SuggestSharesResultSchema = object({
|
|
|
77080
78268
|
nodes: array(SuggestedNodeShareSchema).readonly()
|
|
77081
78269
|
});
|
|
77082
78270
|
/**
|
|
77083
|
-
* Where the node and device shares come from (D750, D755).
|
|
77084
|
-
* - `
|
|
77085
|
-
*
|
|
77086
|
-
*
|
|
77087
|
-
*
|
|
77088
|
-
*
|
|
77089
|
-
*
|
|
78271
|
+
* Where the node and device shares come from (D750, D755, D791).
|
|
78272
|
+
* - `benchmark` (default since D791) — each node's capacity as its own node
|
|
78273
|
+
* benchmark measured it; a node without fresh results is sized from
|
|
78274
|
+
* `hardware` and says so. Measured on the node beats the table.
|
|
78275
|
+
* - `hardware` — computed from each node's static capacity only (its
|
|
78276
|
+
* accelerators at their Auto tune models, from the latency table).
|
|
78277
|
+
* Both are recomputed whenever a node or device joins, leaves, is switched
|
|
78278
|
+
* on or off, changes model, or a benchmark result is written. No load input.
|
|
77090
78279
|
* - `manual` — the operator's stored sliders.
|
|
77091
78280
|
* Either way a node or device that cannot take sessions gives its share to
|
|
77092
78281
|
* the others in proportion; the stored values are never rewritten for that.
|
|
@@ -77135,6 +78324,362 @@ var EffectiveSharesSchema = object({
|
|
|
77135
78324
|
nodeWeights: record(string(), number()),
|
|
77136
78325
|
deviceWeights: record(string(), record(string(), number()))
|
|
77137
78326
|
});
|
|
78327
|
+
/**
|
|
78328
|
+
* Wire shapes of the node benchmark (D791): the operator's plan, the
|
|
78329
|
+
* preflight the confirmation shows, the run the orchestrator owns, what the
|
|
78330
|
+
* measuring runner reports, and the result rows Auto tune and the automatic
|
|
78331
|
+
* shares read.
|
|
78332
|
+
*
|
|
78333
|
+
* ONE node at a time, owned by the pipeline orchestrator. While a run is
|
|
78334
|
+
* active the cluster is in BENCHMARK MODE for that node: it is not a
|
|
78335
|
+
* detection candidate, camera pins naming it are ignored so its sessions move
|
|
78336
|
+
* elsewhere, and both come back when the mode ends — after a crash or a hub
|
|
78337
|
+
* restart too (a persisted manifest, reconciled against the registry).
|
|
78338
|
+
*
|
|
78339
|
+
* Two measurements, both on the node, driven by its own runner (frames never
|
|
78340
|
+
* cross a process at frame rate, D9):
|
|
78341
|
+
* - `device` — one accelerator × one candidate detector, root only, open
|
|
78342
|
+
* loop: how many streams at the camera rate it carries inside the frame
|
|
78343
|
+
* interval;
|
|
78344
|
+
* - `pipeline` — the chosen detector plus the operator's detail steps
|
|
78345
|
+
* (faces, plates, classifiers, CLIP…), on varied frames from the bench
|
|
78346
|
+
* clip: how many parallel sessions the node carries before latency, drops,
|
|
78347
|
+
* CPU, RAM or the event loop give out.
|
|
78348
|
+
*/
|
|
78349
|
+
/** Defaults and bounds, one place. */
|
|
78350
|
+
var NODE_BENCHMARK_DEFAULTS = {
|
|
78351
|
+
fpsPerStream: 10,
|
|
78352
|
+
budgetMinutes: 45,
|
|
78353
|
+
minBudgetMinutes: 10,
|
|
78354
|
+
maxBudgetMinutes: 120,
|
|
78355
|
+
/** A result older than this no longer beats the table. */
|
|
78356
|
+
staleAfterDays: 30,
|
|
78357
|
+
/** Warm-in per ramp step (not accounted). */
|
|
78358
|
+
settleSec: 5,
|
|
78359
|
+
/** Accounted window per ramp step. */
|
|
78360
|
+
measureSec: 20,
|
|
78361
|
+
/** Longest the drain may take before the run is refused. */
|
|
78362
|
+
drainTimeoutSec: 120,
|
|
78363
|
+
/** Candidate models per device in one run. */
|
|
78364
|
+
maxModelsPerDevice: 6
|
|
78365
|
+
};
|
|
78366
|
+
/** The two measurements a run can make. */
|
|
78367
|
+
var NodeBenchmarkPhaseSchema = _enum(["device", "pipeline"]);
|
|
78368
|
+
var NodeBenchmarkDevicePlanSchema = object({
|
|
78369
|
+
/** `<backend>:<device>` — `openvino:npu`, `coreml:all`, `cpu`. */
|
|
78370
|
+
deviceKey: string().min(1),
|
|
78371
|
+
/**
|
|
78372
|
+
* Root detector candidates for the `device` measurement, in the order
|
|
78373
|
+
* measured. The FIRST is the one the `pipeline` measurement runs.
|
|
78374
|
+
*/
|
|
78375
|
+
modelIds: array(string().min(1)).min(1).max(NODE_BENCHMARK_DEFAULTS.maxModelsPerDevice)
|
|
78376
|
+
});
|
|
78377
|
+
/** What the operator confirmed. */
|
|
78378
|
+
var NodeBenchmarkPlanSchema = object({
|
|
78379
|
+
nodeId: string().min(1),
|
|
78380
|
+
devices: array(NodeBenchmarkDevicePlanSchema).min(1),
|
|
78381
|
+
/** Which measurements run. At least one. */
|
|
78382
|
+
phases: array(NodeBenchmarkPhaseSchema).min(1).default(["device", "pipeline"]),
|
|
78383
|
+
/**
|
|
78384
|
+
* Detail steps (catalog step ids under the root: faces, plates,
|
|
78385
|
+
* classifiers, CLIP…) the `pipeline` measurement enables. The root
|
|
78386
|
+
* detector always runs.
|
|
78387
|
+
*/
|
|
78388
|
+
steps: array(string().min(1)).default([]),
|
|
78389
|
+
/** Offered rate of one stream / session. */
|
|
78390
|
+
fpsPerStream: number().int().min(1).max(30).default(NODE_BENCHMARK_DEFAULTS.fpsPerStream),
|
|
78391
|
+
/** Hard deadline: the mode ends and the cluster is restored when it passes. */
|
|
78392
|
+
budgetMinutes: number().int().min(NODE_BENCHMARK_DEFAULTS.minBudgetMinutes).max(NODE_BENCHMARK_DEFAULTS.maxBudgetMinutes).default(NODE_BENCHMARK_DEFAULTS.budgetMinutes),
|
|
78393
|
+
/** Keep the models the run downloaded (default: delete what was not installed before). */
|
|
78394
|
+
keepDownloadedModels: boolean().default(false),
|
|
78395
|
+
/** Start although the other nodes' capacity does not cover the sessions running now. */
|
|
78396
|
+
acceptInsufficientHeadroom: boolean().default(false)
|
|
78397
|
+
});
|
|
78398
|
+
var NodeBenchmarkRefusalSchema = object({
|
|
78399
|
+
kind: _enum([
|
|
78400
|
+
"benchmark-active",
|
|
78401
|
+
"node-offline",
|
|
78402
|
+
"unknown-device",
|
|
78403
|
+
"no-phase",
|
|
78404
|
+
"insufficient-headroom"
|
|
78405
|
+
]),
|
|
78406
|
+
detail: string(),
|
|
78407
|
+
overridable: boolean()
|
|
78408
|
+
});
|
|
78409
|
+
/** A camera whose detection leaves the node for the run. */
|
|
78410
|
+
var NodeBenchmarkMovingCameraSchema = object({
|
|
78411
|
+
deviceId: number(),
|
|
78412
|
+
/** Placed on the node now (a standing attach or a running session). */
|
|
78413
|
+
placedOnNode: boolean(),
|
|
78414
|
+
/** A node pin naming this node, ignored for the run. */
|
|
78415
|
+
pinnedToNode: boolean()
|
|
78416
|
+
});
|
|
78417
|
+
/** A camera that cannot leave: no other node can obtain its frames. */
|
|
78418
|
+
var NodeBenchmarkStayingCameraSchema = object({
|
|
78419
|
+
deviceId: number(),
|
|
78420
|
+
reason: literal("only-frame-source")
|
|
78421
|
+
});
|
|
78422
|
+
var NodeBenchmarkPreflightSchema = object({
|
|
78423
|
+
nodeId: string(),
|
|
78424
|
+
online: boolean(),
|
|
78425
|
+
moving: array(NodeBenchmarkMovingCameraSchema).readonly(),
|
|
78426
|
+
/** Keep running on the node during the run; the result is flagged contaminated. */
|
|
78427
|
+
staying: array(NodeBenchmarkStayingCameraSchema).readonly(),
|
|
78428
|
+
estimatedDurationMs: number(),
|
|
78429
|
+
/** The run ends and the cluster is restored at the latest after this long. */
|
|
78430
|
+
budgetMs: number(),
|
|
78431
|
+
phases: array(NodeBenchmarkPhaseSchema).readonly(),
|
|
78432
|
+
steps: array(string()).readonly(),
|
|
78433
|
+
devices: array(NodeBenchmarkDevicePlanSchema).readonly(),
|
|
78434
|
+
/** Parallel sessions the cluster runs now, and what the other nodes can carry. */
|
|
78435
|
+
headroom: object({
|
|
78436
|
+
sessionsNow: number(),
|
|
78437
|
+
otherNodesCapacitySessions: number().nullable()
|
|
78438
|
+
}),
|
|
78439
|
+
refusals: array(NodeBenchmarkRefusalSchema).readonly(),
|
|
78440
|
+
canStart: boolean()
|
|
78441
|
+
});
|
|
78442
|
+
/** Where the measuring runner is. */
|
|
78443
|
+
var NodeBenchProgressSchema = object({
|
|
78444
|
+
phase: _enum([
|
|
78445
|
+
"preparing",
|
|
78446
|
+
"device",
|
|
78447
|
+
"pipeline",
|
|
78448
|
+
"cleanup"
|
|
78449
|
+
]),
|
|
78450
|
+
deviceKey: string().nullable(),
|
|
78451
|
+
modelId: string().nullable(),
|
|
78452
|
+
/** Streams (device) or sessions (pipeline) of the step running now. */
|
|
78453
|
+
load: number().nullable(),
|
|
78454
|
+
cellsDone: number(),
|
|
78455
|
+
cellsTotal: number(),
|
|
78456
|
+
message: string()
|
|
78457
|
+
});
|
|
78458
|
+
/** What limited a ramp. `none` = the ramp ran out of steps still passing. */
|
|
78459
|
+
var NodeBenchLimitSchema = _enum([
|
|
78460
|
+
"p95",
|
|
78461
|
+
"drops",
|
|
78462
|
+
"errors",
|
|
78463
|
+
"stall",
|
|
78464
|
+
"cpu",
|
|
78465
|
+
"ram",
|
|
78466
|
+
"none"
|
|
78467
|
+
]);
|
|
78468
|
+
var NodeBenchRampStepSchema = object({
|
|
78469
|
+
load: number(),
|
|
78470
|
+
pass: boolean(),
|
|
78471
|
+
p95Ms: number(),
|
|
78472
|
+
dropRatio: number(),
|
|
78473
|
+
/** Completed frames per second over the accounted window. */
|
|
78474
|
+
fps: number(),
|
|
78475
|
+
cpuPct: number().nullable(),
|
|
78476
|
+
ramFreePct: number().nullable(),
|
|
78477
|
+
failReasons: array(string()).readonly()
|
|
78478
|
+
});
|
|
78479
|
+
var NodeBenchCellSchema = discriminatedUnion("phase", [object({
|
|
78480
|
+
phase: literal("device"),
|
|
78481
|
+
deviceKey: string(),
|
|
78482
|
+
modelId: string(),
|
|
78483
|
+
/** Single-stream latency (the K = 1 step). */
|
|
78484
|
+
p50Ms: number(),
|
|
78485
|
+
p95Ms: number(),
|
|
78486
|
+
p99Ms: number(),
|
|
78487
|
+
/** Frames per second sustained at the last passing step. */
|
|
78488
|
+
fps: number(),
|
|
78489
|
+
/** Streams at the camera rate the device carried inside the frame interval; 0 = not even one. */
|
|
78490
|
+
kMax: number(),
|
|
78491
|
+
limitedBy: NodeBenchLimitSchema,
|
|
78492
|
+
/** First call (model load + warm-up). */
|
|
78493
|
+
warmupMs: number(),
|
|
78494
|
+
ramp: array(NodeBenchRampStepSchema).readonly()
|
|
78495
|
+
}), object({
|
|
78496
|
+
phase: literal("pipeline"),
|
|
78497
|
+
deviceKey: string(),
|
|
78498
|
+
modelId: string(),
|
|
78499
|
+
steps: array(string()).readonly(),
|
|
78500
|
+
/** Parallel sessions at the camera rate the node carried; 0 = not even one. */
|
|
78501
|
+
maxSessions: number(),
|
|
78502
|
+
limitedBy: NodeBenchLimitSchema,
|
|
78503
|
+
/** Detail steps that produced at least one result on the clip — a step that never fired measured nothing. */
|
|
78504
|
+
stepsFired: array(string()).readonly(),
|
|
78505
|
+
warmupMs: number(),
|
|
78506
|
+
ramp: array(NodeBenchRampStepSchema).readonly()
|
|
78507
|
+
})]);
|
|
78508
|
+
/**
|
|
78509
|
+
* What a result was measured ON. A result whose fingerprint no longer matches
|
|
78510
|
+
* the node no longer beats the table.
|
|
78511
|
+
*/
|
|
78512
|
+
var NodeBenchFingerprintSchema = object({
|
|
78513
|
+
pipelineVersion: string().nullable(),
|
|
78514
|
+
cpuModel: string().nullable(),
|
|
78515
|
+
ramGb: number().nullable(),
|
|
78516
|
+
os: string().nullable(),
|
|
78517
|
+
/** Per device: the pool the cells ran on (runtime + tuning). */
|
|
78518
|
+
pools: record(string(), object({
|
|
78519
|
+
runtime: string(),
|
|
78520
|
+
numWorkers: number(),
|
|
78521
|
+
concurrency: number(),
|
|
78522
|
+
batchMode: string()
|
|
78523
|
+
})).default({})
|
|
78524
|
+
});
|
|
78525
|
+
/** The frames the run used. */
|
|
78526
|
+
var NodeBenchClipSchema = object({
|
|
78527
|
+
/** `camstack-bench-v1` or `reference-images` (the fallback when the clip is not reachable). */
|
|
78528
|
+
id: string(),
|
|
78529
|
+
revision: string().nullable(),
|
|
78530
|
+
frames: number(),
|
|
78531
|
+
width: number(),
|
|
78532
|
+
height: number()
|
|
78533
|
+
});
|
|
78534
|
+
var NodeBenchRunnerInputSchema = object({
|
|
78535
|
+
runId: string().min(1),
|
|
78536
|
+
devices: array(NodeBenchmarkDevicePlanSchema).min(1),
|
|
78537
|
+
phases: array(NodeBenchmarkPhaseSchema).min(1),
|
|
78538
|
+
/** The full detail step tree root for the `pipeline` measurement is built on the node from these ids. */
|
|
78539
|
+
steps: array(string()).default([]),
|
|
78540
|
+
fpsPerStream: number().int().min(1).max(30),
|
|
78541
|
+
/** The runner stops on its own past this instant, whatever the hub does. */
|
|
78542
|
+
deadlineAtMs: number(),
|
|
78543
|
+
settleSec: number().min(0).max(60).default(NODE_BENCHMARK_DEFAULTS.settleSec),
|
|
78544
|
+
measureSec: number().min(2).max(300).default(NODE_BENCHMARK_DEFAULTS.measureSec),
|
|
78545
|
+
keepDownloadedModels: boolean().default(false)
|
|
78546
|
+
});
|
|
78547
|
+
var NodeBenchRunnerStateSchema = _enum([
|
|
78548
|
+
"running",
|
|
78549
|
+
"done",
|
|
78550
|
+
"failed",
|
|
78551
|
+
"aborted"
|
|
78552
|
+
]);
|
|
78553
|
+
var NodeBenchRunnerStatusSchema = object({
|
|
78554
|
+
runId: string(),
|
|
78555
|
+
nodeId: string(),
|
|
78556
|
+
state: NodeBenchRunnerStateSchema,
|
|
78557
|
+
progress: NodeBenchProgressSchema.nullable(),
|
|
78558
|
+
/** Every finished cell so far — a run stopped half way keeps what it measured. */
|
|
78559
|
+
cells: array(NodeBenchCellSchema).readonly(),
|
|
78560
|
+
fingerprint: NodeBenchFingerprintSchema.nullable(),
|
|
78561
|
+
clip: NodeBenchClipSchema.nullable(),
|
|
78562
|
+
/** Cameras seen running on the node during the run (they share its pools). */
|
|
78563
|
+
activeCameraIds: array(number()).readonly(),
|
|
78564
|
+
/** Models the run downloaded and then deleted (not installed before). */
|
|
78565
|
+
deletedModels: array(string()).readonly(),
|
|
78566
|
+
error: string().nullable(),
|
|
78567
|
+
startedAtMs: number(),
|
|
78568
|
+
finishedAtMs: number().nullable()
|
|
78569
|
+
});
|
|
78570
|
+
var NodeBenchmarkStateSchema = _enum([
|
|
78571
|
+
"draining",
|
|
78572
|
+
"measuring",
|
|
78573
|
+
"restoring",
|
|
78574
|
+
"done",
|
|
78575
|
+
"failed",
|
|
78576
|
+
"aborted"
|
|
78577
|
+
]);
|
|
78578
|
+
/** Why a run ended. */
|
|
78579
|
+
var NodeBenchmarkEndReasonSchema = _enum([
|
|
78580
|
+
"completed",
|
|
78581
|
+
"operator-abort",
|
|
78582
|
+
"deadline",
|
|
78583
|
+
"node-lost",
|
|
78584
|
+
"runner-lost",
|
|
78585
|
+
"hub-restart",
|
|
78586
|
+
"drain-timeout",
|
|
78587
|
+
"failed"
|
|
78588
|
+
]);
|
|
78589
|
+
var NodeBenchmarkRunSchema = object({
|
|
78590
|
+
runId: string(),
|
|
78591
|
+
nodeId: string(),
|
|
78592
|
+
state: NodeBenchmarkStateSchema,
|
|
78593
|
+
plan: NodeBenchmarkPlanSchema,
|
|
78594
|
+
startedAtMs: number(),
|
|
78595
|
+
deadlineAtMs: number(),
|
|
78596
|
+
finishedAtMs: number().nullable(),
|
|
78597
|
+
endReason: NodeBenchmarkEndReasonSchema.nullable(),
|
|
78598
|
+
error: string().nullable(),
|
|
78599
|
+
/** Cameras moved off the node for the run. */
|
|
78600
|
+
moved: array(number()).readonly(),
|
|
78601
|
+
/** Cameras that stayed (their only frame source is the node). */
|
|
78602
|
+
staying: array(number()).readonly(),
|
|
78603
|
+
/** Something else ran on the node's pools during the run. */
|
|
78604
|
+
contaminated: boolean(),
|
|
78605
|
+
progress: NodeBenchProgressSchema.nullable(),
|
|
78606
|
+
resultIds: array(string()).readonly()
|
|
78607
|
+
});
|
|
78608
|
+
/** `getNodeBenchmarkStatus`: the active run (or the last one), and whether benchmark mode is on. */
|
|
78609
|
+
var NodeBenchmarkStatusSchema = object({
|
|
78610
|
+
/** The node the cluster is in benchmark mode for; null = none. */
|
|
78611
|
+
modeNodeId: string().nullable(),
|
|
78612
|
+
run: NodeBenchmarkRunSchema.nullable()
|
|
78613
|
+
});
|
|
78614
|
+
/**
|
|
78615
|
+
* One stored measurement — the only authority Auto tune and the automatic
|
|
78616
|
+
* shares read measured capacity from. Written by the orchestrator when a run
|
|
78617
|
+
* ends, never by anyone else.
|
|
78618
|
+
*/
|
|
78619
|
+
var NodeBenchmarkResultSchema = object({
|
|
78620
|
+
id: string(),
|
|
78621
|
+
runId: string(),
|
|
78622
|
+
nodeId: string(),
|
|
78623
|
+
cell: NodeBenchCellSchema,
|
|
78624
|
+
fpsPerStream: number(),
|
|
78625
|
+
fingerprint: NodeBenchFingerprintSchema.nullable(),
|
|
78626
|
+
clip: NodeBenchClipSchema.nullable(),
|
|
78627
|
+
/** Other work shared the node's pools (a camera that could not move, or the hub's own duties). */
|
|
78628
|
+
contaminated: boolean(),
|
|
78629
|
+
stayingCameras: array(number()).readonly(),
|
|
78630
|
+
/** The run ended early; the cell itself completed. */
|
|
78631
|
+
partialRun: boolean(),
|
|
78632
|
+
measuredAtMs: number()
|
|
78633
|
+
});
|
|
78634
|
+
var ListNodeBenchmarkResultsInputSchema = object({
|
|
78635
|
+
nodeId: string().optional(),
|
|
78636
|
+
deviceKey: string().optional()
|
|
78637
|
+
});
|
|
78638
|
+
/** A result with its standing today: does it still beat the table? */
|
|
78639
|
+
var NodeBenchmarkResultViewSchema = NodeBenchmarkResultSchema.extend({
|
|
78640
|
+
/** `fresh` beats the table; `stale` falls back to it; `superseded` = a newer row covers the same cell. */
|
|
78641
|
+
standing: _enum([
|
|
78642
|
+
"fresh",
|
|
78643
|
+
"stale",
|
|
78644
|
+
"superseded"
|
|
78645
|
+
]),
|
|
78646
|
+
staleWhy: _enum([
|
|
78647
|
+
"age",
|
|
78648
|
+
"runtime",
|
|
78649
|
+
"pool-tuning"
|
|
78650
|
+
]).nullable()
|
|
78651
|
+
});
|
|
78652
|
+
object({
|
|
78653
|
+
runId: string(),
|
|
78654
|
+
nodeId: string(),
|
|
78655
|
+
startedAtMs: number(),
|
|
78656
|
+
deadlineAtMs: number(),
|
|
78657
|
+
plan: NodeBenchmarkPlanSchema,
|
|
78658
|
+
moved: array(number()).readonly(),
|
|
78659
|
+
staying: array(number()).readonly()
|
|
78660
|
+
});
|
|
78661
|
+
/** Candidate detectors per device, for the plan editor. */
|
|
78662
|
+
var NodeBenchmarkCandidatesSchema = object({
|
|
78663
|
+
nodeId: string(),
|
|
78664
|
+
reachable: boolean(),
|
|
78665
|
+
devices: array(object({
|
|
78666
|
+
deviceKey: string(),
|
|
78667
|
+
enabled: boolean(),
|
|
78668
|
+
available: boolean(),
|
|
78669
|
+
/** Ordered: what Auto tune would pick first, then the rest of the family by accuracy. */
|
|
78670
|
+
suggested: array(string()).readonly(),
|
|
78671
|
+
/** Every root detector the device has a build for. */
|
|
78672
|
+
all: array(string()).readonly(),
|
|
78673
|
+
/** The model the device runs now, when pinned. */
|
|
78674
|
+
currentModelId: string().nullable()
|
|
78675
|
+
})).readonly(),
|
|
78676
|
+
/** Detail steps the node's catalog offers under the root (for the `pipeline` measurement). */
|
|
78677
|
+
steps: array(object({
|
|
78678
|
+
id: string(),
|
|
78679
|
+
name: string(),
|
|
78680
|
+
slot: string()
|
|
78681
|
+
})).readonly()
|
|
78682
|
+
});
|
|
77138
78683
|
object({
|
|
77139
78684
|
activeCameras: number(),
|
|
77140
78685
|
throttledCameras: number(),
|
|
@@ -78263,7 +79808,16 @@ method(RunnerCameraConfigSchema, object({ success: literal(true) }), { kind: "mu
|
|
|
78263
79808
|
}), ParkedTrackFrameSchema.nullable()), method(object({
|
|
78264
79809
|
deviceId: number(),
|
|
78265
79810
|
trackId: string()
|
|
78266
|
-
}), object({ released: number().int().nonnegative() }), { kind: "mutation" })
|
|
79811
|
+
}), object({ released: number().int().nonnegative() }), { kind: "mutation" }), method(NodeBenchRunnerInputSchema, object({
|
|
79812
|
+
accepted: literal(true),
|
|
79813
|
+
runId: string()
|
|
79814
|
+
}), {
|
|
79815
|
+
kind: "mutation",
|
|
79816
|
+
auth: "admin"
|
|
79817
|
+
}), method(object({ runId: string() }), NodeBenchRunnerStatusSchema.nullable(), { auth: "admin" }), method(object({ runId: string() }), object({ aborted: boolean() }), {
|
|
79818
|
+
kind: "mutation",
|
|
79819
|
+
auth: "admin"
|
|
79820
|
+
});
|
|
78267
79821
|
var CameraPipelineConfigSchema = object({
|
|
78268
79822
|
engine: PipelineEngineChoiceSchema.optional(),
|
|
78269
79823
|
steps: array(PipelineStepInputSchema).readonly(),
|
|
@@ -78902,6 +80456,21 @@ method(object({
|
|
|
78902
80456
|
}), method(PlacementStatsInputSchema, PlacementStatsSchema, { auth: "admin" }), method(SuggestSharesInputSchema, SuggestSharesResultSchema, { auth: "admin" }), method(_void(), EffectiveSharesSchema, { auth: "admin" }), method(SetShareSourceInputSchema, object({ success: literal(true) }), {
|
|
78903
80457
|
kind: "mutation",
|
|
78904
80458
|
auth: "admin"
|
|
80459
|
+
}), method(NodeBenchmarkPlanSchema, NodeBenchmarkPreflightSchema, { auth: "admin" }), method(NodeBenchmarkPlanSchema, discriminatedUnion("kind", [object({
|
|
80460
|
+
kind: literal("started"),
|
|
80461
|
+
runId: string()
|
|
80462
|
+
}), object({
|
|
80463
|
+
kind: literal("refused"),
|
|
80464
|
+
preflight: NodeBenchmarkPreflightSchema
|
|
80465
|
+
})]), {
|
|
80466
|
+
kind: "mutation",
|
|
80467
|
+
auth: "admin"
|
|
80468
|
+
}), method(_void(), NodeBenchmarkStatusSchema, { auth: "admin" }), method(object({ runId: string() }), object({ aborted: boolean() }), {
|
|
80469
|
+
kind: "mutation",
|
|
80470
|
+
auth: "admin"
|
|
80471
|
+
}), method(object({ nodeId: string() }), NodeBenchmarkCandidatesSchema, { auth: "admin" }), method(ListNodeBenchmarkResultsInputSchema, array(NodeBenchmarkResultViewSchema).readonly(), { auth: "admin" }), method(object({ id: string() }), object({ deleted: boolean() }), {
|
|
80472
|
+
kind: "mutation",
|
|
80473
|
+
auth: "admin"
|
|
78905
80474
|
}), method(object({ deviceId: number() }), CameraPipelineSettingsSchema.nullable()), method(object({
|
|
78906
80475
|
deviceId: number(),
|
|
78907
80476
|
addonId: string(),
|
|
@@ -85034,6 +86603,9 @@ var CreateIntegrationInputSchema = object({
|
|
|
85034
86603
|
enabled: boolean().optional(),
|
|
85035
86604
|
info: record(string(), unknown()).optional(),
|
|
85036
86605
|
settings: record(string(), unknown()).optional(),
|
|
86606
|
+
/** Keys of `settings` the form's schema declares secret (by type) — kept in
|
|
86607
|
+
* the keychain, not the table (D787). */
|
|
86608
|
+
secretKeys: array(string()).optional(),
|
|
85037
86609
|
skipRestart: boolean().optional()
|
|
85038
86610
|
});
|
|
85039
86611
|
var UpdateIntegrationInputSchema = object({
|
|
@@ -85057,7 +86629,9 @@ method(_void(), array(IntegrationWithStateSchema)), method(object({ id: string()
|
|
|
85057
86629
|
auth: "admin"
|
|
85058
86630
|
}), method(object({ id: string() }), record(string(), unknown()), { auth: "admin" }), method(object({
|
|
85059
86631
|
id: string(),
|
|
85060
|
-
settings: record(string(), unknown())
|
|
86632
|
+
settings: record(string(), unknown()),
|
|
86633
|
+
/** Keys the form's schema declares secret (by type) — keychain-stored (D787). */
|
|
86634
|
+
secretKeys: array(string()).optional()
|
|
85061
86635
|
}), object({ success: boolean() }), {
|
|
85062
86636
|
kind: "mutation",
|
|
85063
86637
|
auth: "admin"
|
|
@@ -93368,7 +94942,8 @@ var BaseDevice = class {
|
|
|
93368
94942
|
this.role = options.role;
|
|
93369
94943
|
this.parentDeviceId = ctx.parentDeviceId;
|
|
93370
94944
|
const seedData = ctx.persistedConfig ?? {};
|
|
93371
|
-
|
|
94945
|
+
const declaredSecretPaths = collectZodSecretPaths(schema);
|
|
94946
|
+
this.config = DeviceConfig.fromSchema(schema, (data) => ctx.persistConfig(data, { secretConfigPaths: declaredSecretPaths }), seedData, ({ droppedKeys, issues }) => {
|
|
93372
94947
|
ctx.logger.warn("Device config recovery: dropping invalid persisted fields", {
|
|
93373
94948
|
tags: {
|
|
93374
94949
|
deviceId: ctx.id,
|
|
@@ -97057,6 +98632,90 @@ Object.freeze({
|
|
|
97057
98632
|
addonId: null,
|
|
97058
98633
|
access: "create"
|
|
97059
98634
|
},
|
|
98635
|
+
"keychain.delete": {
|
|
98636
|
+
capName: "keychain",
|
|
98637
|
+
capScope: "system",
|
|
98638
|
+
addonId: null,
|
|
98639
|
+
access: "delete"
|
|
98640
|
+
},
|
|
98641
|
+
"keychain.getState": {
|
|
98642
|
+
capName: "keychain",
|
|
98643
|
+
capScope: "system",
|
|
98644
|
+
addonId: null,
|
|
98645
|
+
access: "view"
|
|
98646
|
+
},
|
|
98647
|
+
"keychain.listMeta": {
|
|
98648
|
+
capName: "keychain",
|
|
98649
|
+
capScope: "system",
|
|
98650
|
+
addonId: null,
|
|
98651
|
+
access: "view"
|
|
98652
|
+
},
|
|
98653
|
+
"keychain.put": {
|
|
98654
|
+
capName: "keychain",
|
|
98655
|
+
capScope: "system",
|
|
98656
|
+
addonId: null,
|
|
98657
|
+
access: "create"
|
|
98658
|
+
},
|
|
98659
|
+
"keychain.resolve": {
|
|
98660
|
+
capName: "keychain",
|
|
98661
|
+
capScope: "system",
|
|
98662
|
+
addonId: null,
|
|
98663
|
+
access: "view"
|
|
98664
|
+
},
|
|
98665
|
+
"keychainAdmin.deleteOrphans": {
|
|
98666
|
+
capName: "keychain-admin",
|
|
98667
|
+
capScope: "system",
|
|
98668
|
+
addonId: null,
|
|
98669
|
+
access: "delete"
|
|
98670
|
+
},
|
|
98671
|
+
"keychainAdmin.downloadRecoveryKey": {
|
|
98672
|
+
capName: "keychain-admin",
|
|
98673
|
+
capScope: "system",
|
|
98674
|
+
addonId: null,
|
|
98675
|
+
access: "create"
|
|
98676
|
+
},
|
|
98677
|
+
"keychainAdmin.listAudit": {
|
|
98678
|
+
capName: "keychain-admin",
|
|
98679
|
+
capScope: "system",
|
|
98680
|
+
addonId: null,
|
|
98681
|
+
access: "view"
|
|
98682
|
+
},
|
|
98683
|
+
"keychainAdmin.listSecrets": {
|
|
98684
|
+
capName: "keychain-admin",
|
|
98685
|
+
capScope: "system",
|
|
98686
|
+
addonId: null,
|
|
98687
|
+
access: "view"
|
|
98688
|
+
},
|
|
98689
|
+
"keychainAdmin.purgeRetiredKeys": {
|
|
98690
|
+
capName: "keychain-admin",
|
|
98691
|
+
capScope: "system",
|
|
98692
|
+
addonId: null,
|
|
98693
|
+
access: "delete"
|
|
98694
|
+
},
|
|
98695
|
+
"keychainAdmin.resetKeychain": {
|
|
98696
|
+
capName: "keychain-admin",
|
|
98697
|
+
capScope: "system",
|
|
98698
|
+
addonId: null,
|
|
98699
|
+
access: "delete"
|
|
98700
|
+
},
|
|
98701
|
+
"keychainAdmin.reveal": {
|
|
98702
|
+
capName: "keychain-admin",
|
|
98703
|
+
capScope: "system",
|
|
98704
|
+
addonId: null,
|
|
98705
|
+
access: "create"
|
|
98706
|
+
},
|
|
98707
|
+
"keychainAdmin.rotateMasterKey": {
|
|
98708
|
+
capName: "keychain-admin",
|
|
98709
|
+
capScope: "system",
|
|
98710
|
+
addonId: null,
|
|
98711
|
+
access: "create"
|
|
98712
|
+
},
|
|
98713
|
+
"keychainAdmin.status": {
|
|
98714
|
+
capName: "keychain-admin",
|
|
98715
|
+
capScope: "system",
|
|
98716
|
+
addonId: null,
|
|
98717
|
+
access: "view"
|
|
98718
|
+
},
|
|
97060
98719
|
"lawnMowerControl.dock": {
|
|
97061
98720
|
capName: "lawn-mower-control",
|
|
97062
98721
|
capScope: "device",
|
|
@@ -98431,6 +100090,18 @@ Object.freeze({
|
|
|
98431
100090
|
addonId: null,
|
|
98432
100091
|
access: "create"
|
|
98433
100092
|
},
|
|
100093
|
+
"pipelineAnalytics.addRetrainFrameFromRecording": {
|
|
100094
|
+
capName: "pipeline-analytics",
|
|
100095
|
+
capScope: "device",
|
|
100096
|
+
addonId: null,
|
|
100097
|
+
access: "create"
|
|
100098
|
+
},
|
|
100099
|
+
"pipelineAnalytics.addRetrainFramesToCollection": {
|
|
100100
|
+
capName: "pipeline-analytics",
|
|
100101
|
+
capScope: "device",
|
|
100102
|
+
addonId: null,
|
|
100103
|
+
access: "create"
|
|
100104
|
+
},
|
|
98434
100105
|
"pipelineAnalytics.applyDeviceSettingsPatch": {
|
|
98435
100106
|
capName: "pipeline-analytics",
|
|
98436
100107
|
capScope: "device",
|
|
@@ -98479,12 +100150,24 @@ Object.freeze({
|
|
|
98479
100150
|
addonId: null,
|
|
98480
100151
|
access: "view"
|
|
98481
100152
|
},
|
|
100153
|
+
"pipelineAnalytics.createRetrainCollection": {
|
|
100154
|
+
capName: "pipeline-analytics",
|
|
100155
|
+
capScope: "device",
|
|
100156
|
+
addonId: null,
|
|
100157
|
+
access: "create"
|
|
100158
|
+
},
|
|
98482
100159
|
"pipelineAnalytics.deleteDeviceEvents": {
|
|
98483
100160
|
capName: "pipeline-analytics",
|
|
98484
100161
|
capScope: "device",
|
|
98485
100162
|
addonId: null,
|
|
98486
100163
|
access: "delete"
|
|
98487
100164
|
},
|
|
100165
|
+
"pipelineAnalytics.deleteRetrainCollection": {
|
|
100166
|
+
capName: "pipeline-analytics",
|
|
100167
|
+
capScope: "device",
|
|
100168
|
+
addonId: null,
|
|
100169
|
+
access: "delete"
|
|
100170
|
+
},
|
|
98488
100171
|
"pipelineAnalytics.deleteTracks": {
|
|
98489
100172
|
capName: "pipeline-analytics",
|
|
98490
100173
|
capScope: "device",
|
|
@@ -98689,6 +100372,24 @@ Object.freeze({
|
|
|
98689
100372
|
addonId: null,
|
|
98690
100373
|
access: "view"
|
|
98691
100374
|
},
|
|
100375
|
+
"pipelineAnalytics.listRetrainAssistProfiles": {
|
|
100376
|
+
capName: "pipeline-analytics",
|
|
100377
|
+
capScope: "device",
|
|
100378
|
+
addonId: null,
|
|
100379
|
+
access: "view"
|
|
100380
|
+
},
|
|
100381
|
+
"pipelineAnalytics.listRetrainCollectionFrames": {
|
|
100382
|
+
capName: "pipeline-analytics",
|
|
100383
|
+
capScope: "device",
|
|
100384
|
+
addonId: null,
|
|
100385
|
+
access: "view"
|
|
100386
|
+
},
|
|
100387
|
+
"pipelineAnalytics.listRetrainCollections": {
|
|
100388
|
+
capName: "pipeline-analytics",
|
|
100389
|
+
capScope: "device",
|
|
100390
|
+
addonId: null,
|
|
100391
|
+
access: "view"
|
|
100392
|
+
},
|
|
98692
100393
|
"pipelineAnalytics.listRetrainFrames": {
|
|
98693
100394
|
capName: "pipeline-analytics",
|
|
98694
100395
|
capScope: "device",
|
|
@@ -98737,6 +100438,12 @@ Object.freeze({
|
|
|
98737
100438
|
addonId: null,
|
|
98738
100439
|
access: "create"
|
|
98739
100440
|
},
|
|
100441
|
+
"pipelineAnalytics.proposeRetrainAnnotationsWithLlm": {
|
|
100442
|
+
capName: "pipeline-analytics",
|
|
100443
|
+
capScope: "device",
|
|
100444
|
+
addonId: null,
|
|
100445
|
+
access: "create"
|
|
100446
|
+
},
|
|
98740
100447
|
"pipelineAnalytics.pruneEvents": {
|
|
98741
100448
|
capName: "pipeline-analytics",
|
|
98742
100449
|
capScope: "device",
|
|
@@ -98791,6 +100498,18 @@ Object.freeze({
|
|
|
98791
100498
|
addonId: null,
|
|
98792
100499
|
access: "create"
|
|
98793
100500
|
},
|
|
100501
|
+
"pipelineAnalytics.removeRetrainFrameFromCollection": {
|
|
100502
|
+
capName: "pipeline-analytics",
|
|
100503
|
+
capScope: "device",
|
|
100504
|
+
addonId: null,
|
|
100505
|
+
access: "delete"
|
|
100506
|
+
},
|
|
100507
|
+
"pipelineAnalytics.renameRetrainCollection": {
|
|
100508
|
+
capName: "pipeline-analytics",
|
|
100509
|
+
capScope: "device",
|
|
100510
|
+
addonId: null,
|
|
100511
|
+
access: "create"
|
|
100512
|
+
},
|
|
98794
100513
|
"pipelineAnalytics.restageRetrainTrack": {
|
|
98795
100514
|
capName: "pipeline-analytics",
|
|
98796
100515
|
capScope: "device",
|
|
@@ -99079,6 +100798,12 @@ Object.freeze({
|
|
|
99079
100798
|
addonId: null,
|
|
99080
100799
|
access: "view"
|
|
99081
100800
|
},
|
|
100801
|
+
"pipelineOrchestrator.abortNodeBenchmark": {
|
|
100802
|
+
capName: "pipeline-orchestrator",
|
|
100803
|
+
capScope: "system",
|
|
100804
|
+
addonId: null,
|
|
100805
|
+
access: "create"
|
|
100806
|
+
},
|
|
99082
100807
|
"pipelineOrchestrator.applyAutoTune": {
|
|
99083
100808
|
capName: "pipeline-orchestrator",
|
|
99084
100809
|
capScope: "system",
|
|
@@ -99103,6 +100828,12 @@ Object.freeze({
|
|
|
99103
100828
|
addonId: null,
|
|
99104
100829
|
access: "create"
|
|
99105
100830
|
},
|
|
100831
|
+
"pipelineOrchestrator.deleteNodeBenchmarkResult": {
|
|
100832
|
+
capName: "pipeline-orchestrator",
|
|
100833
|
+
capScope: "system",
|
|
100834
|
+
addonId: null,
|
|
100835
|
+
access: "delete"
|
|
100836
|
+
},
|
|
99106
100837
|
"pipelineOrchestrator.getAgentLoad": {
|
|
99107
100838
|
capName: "pipeline-orchestrator",
|
|
99108
100839
|
capScope: "system",
|
|
@@ -99211,6 +100942,24 @@ Object.freeze({
|
|
|
99211
100942
|
addonId: null,
|
|
99212
100943
|
access: "view"
|
|
99213
100944
|
},
|
|
100945
|
+
"pipelineOrchestrator.getNodeBenchmarkCandidates": {
|
|
100946
|
+
capName: "pipeline-orchestrator",
|
|
100947
|
+
capScope: "system",
|
|
100948
|
+
addonId: null,
|
|
100949
|
+
access: "view"
|
|
100950
|
+
},
|
|
100951
|
+
"pipelineOrchestrator.getNodeBenchmarkPreflight": {
|
|
100952
|
+
capName: "pipeline-orchestrator",
|
|
100953
|
+
capScope: "system",
|
|
100954
|
+
addonId: null,
|
|
100955
|
+
access: "view"
|
|
100956
|
+
},
|
|
100957
|
+
"pipelineOrchestrator.getNodeBenchmarkStatus": {
|
|
100958
|
+
capName: "pipeline-orchestrator",
|
|
100959
|
+
capScope: "system",
|
|
100960
|
+
addonId: null,
|
|
100961
|
+
access: "view"
|
|
100962
|
+
},
|
|
99214
100963
|
"pipelineOrchestrator.getNodeInferenceDevices": {
|
|
99215
100964
|
capName: "pipeline-orchestrator",
|
|
99216
100965
|
capScope: "system",
|
|
@@ -99253,6 +101002,12 @@ Object.freeze({
|
|
|
99253
101002
|
addonId: null,
|
|
99254
101003
|
access: "view"
|
|
99255
101004
|
},
|
|
101005
|
+
"pipelineOrchestrator.listNodeBenchmarkResults": {
|
|
101006
|
+
capName: "pipeline-orchestrator",
|
|
101007
|
+
capScope: "system",
|
|
101008
|
+
addonId: null,
|
|
101009
|
+
access: "view"
|
|
101010
|
+
},
|
|
99256
101011
|
"pipelineOrchestrator.pauseForStorageMigration": {
|
|
99257
101012
|
capName: "pipeline-orchestrator",
|
|
99258
101013
|
capScope: "system",
|
|
@@ -99397,6 +101152,12 @@ Object.freeze({
|
|
|
99397
101152
|
addonId: null,
|
|
99398
101153
|
access: "create"
|
|
99399
101154
|
},
|
|
101155
|
+
"pipelineOrchestrator.startNodeBenchmark": {
|
|
101156
|
+
capName: "pipeline-orchestrator",
|
|
101157
|
+
capScope: "system",
|
|
101158
|
+
addonId: null,
|
|
101159
|
+
access: "create"
|
|
101160
|
+
},
|
|
99400
101161
|
"pipelineOrchestrator.suggestShares": {
|
|
99401
101162
|
capName: "pipeline-orchestrator",
|
|
99402
101163
|
capScope: "system",
|
|
@@ -99415,6 +101176,12 @@ Object.freeze({
|
|
|
99415
101176
|
addonId: null,
|
|
99416
101177
|
access: "create"
|
|
99417
101178
|
},
|
|
101179
|
+
"pipelineRunner.abortNodeBench": {
|
|
101180
|
+
capName: "pipeline-runner",
|
|
101181
|
+
capScope: "system",
|
|
101182
|
+
addonId: null,
|
|
101183
|
+
access: "create"
|
|
101184
|
+
},
|
|
99418
101185
|
"pipelineRunner.attachCamera": {
|
|
99419
101186
|
capName: "pipeline-runner",
|
|
99420
101187
|
capScope: "system",
|
|
@@ -99463,6 +101230,12 @@ Object.freeze({
|
|
|
99463
101230
|
addonId: null,
|
|
99464
101231
|
access: "view"
|
|
99465
101232
|
},
|
|
101233
|
+
"pipelineRunner.getNodeBenchStatus": {
|
|
101234
|
+
capName: "pipeline-runner",
|
|
101235
|
+
capScope: "system",
|
|
101236
|
+
addonId: null,
|
|
101237
|
+
access: "view"
|
|
101238
|
+
},
|
|
99466
101239
|
"pipelineRunner.getParkedTrackFrame": {
|
|
99467
101240
|
capName: "pipeline-runner",
|
|
99468
101241
|
capScope: "system",
|
|
@@ -99505,6 +101278,12 @@ Object.freeze({
|
|
|
99505
101278
|
addonId: null,
|
|
99506
101279
|
access: "create"
|
|
99507
101280
|
},
|
|
101281
|
+
"pipelineRunner.startNodeBench": {
|
|
101282
|
+
capName: "pipeline-runner",
|
|
101283
|
+
capScope: "system",
|
|
101284
|
+
addonId: null,
|
|
101285
|
+
access: "create"
|
|
101286
|
+
},
|
|
99508
101287
|
"plateGallery.assignPlate": {
|
|
99509
101288
|
capName: "plate-gallery",
|
|
99510
101289
|
capScope: "system",
|
|
@@ -104434,6 +106213,11 @@ Object.freeze({
|
|
|
104434
106213
|
form: "single",
|
|
104435
106214
|
optional: false
|
|
104436
106215
|
}],
|
|
106216
|
+
"pipelineAnalytics.addRetrainFrameFromRecording": [{
|
|
106217
|
+
name: "deviceId",
|
|
106218
|
+
form: "single",
|
|
106219
|
+
optional: false
|
|
106220
|
+
}],
|
|
104437
106221
|
"pipelineAnalytics.applyDeviceSettingsPatch": [{
|
|
104438
106222
|
name: "deviceId",
|
|
104439
106223
|
form: "single",
|
|
@@ -104624,6 +106408,11 @@ Object.freeze({
|
|
|
104624
106408
|
form: "single",
|
|
104625
106409
|
optional: false
|
|
104626
106410
|
}],
|
|
106411
|
+
"pipelineAnalytics.proposeRetrainAnnotationsWithLlm": [{
|
|
106412
|
+
name: "deviceId",
|
|
106413
|
+
form: "single",
|
|
106414
|
+
optional: false
|
|
106415
|
+
}],
|
|
104627
106416
|
"pipelineAnalytics.pruneEventsBefore": [{
|
|
104628
106417
|
name: "deviceId",
|
|
104629
106418
|
form: "single",
|