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