@camstack/addon-provider-reolink 1.2.178 → 1.2.179
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 +1927 -66
- package/dist/addon.mjs +1927 -66
- package/package.json +1 -1
package/dist/addon.js
CHANGED
|
@@ -35,7 +35,7 @@ let node_os = require("node:os");
|
|
|
35
35
|
node_os = require_chunk.__toESM(node_os);
|
|
36
36
|
let node_fs = require("node:fs");
|
|
37
37
|
node_fs = require_chunk.__toESM(node_fs, 1);
|
|
38
|
-
//#region ../types/dist/event-category-
|
|
38
|
+
//#region ../types/dist/event-category-DaIZi00R.mjs
|
|
39
39
|
var EventCategory = /* @__PURE__ */ function(EventCategory) {
|
|
40
40
|
EventCategory["SystemBoot"] = "system.boot";
|
|
41
41
|
EventCategory["SystemAddonsReady"] = "system.addons-ready";
|
|
@@ -114,6 +114,13 @@ var EventCategory = /* @__PURE__ */ function(EventCategory) {
|
|
|
114
114
|
*/
|
|
115
115
|
EventCategory["AddonLoadFailed"] = "addon.load-failed";
|
|
116
116
|
/**
|
|
117
|
+
* A keychain value was stored or removed (D787). Carries the ref, its
|
|
118
|
+
* owner and the new version — NEVER the value. A process holding the ref
|
|
119
|
+
* drops its cached copy and the owning `BaseAddon` re-resolves its config.
|
|
120
|
+
* Telemetry (D8): a process that misses it still revalidates by version.
|
|
121
|
+
*/
|
|
122
|
+
EventCategory["KeychainChanged"] = "keychain.changed";
|
|
123
|
+
/**
|
|
117
124
|
* Addon recovered from a previous failure. Emitted when an addon
|
|
118
125
|
* transitions from `failed` back to `healthy` (typically via the
|
|
119
126
|
* monitor's auto-retry loop, or after manual `addons.retryLoad`).
|
|
@@ -5406,7 +5413,7 @@ var ZodIssueCode = {
|
|
|
5406
5413
|
var ZodFirstPartyTypeKind;
|
|
5407
5414
|
ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {});
|
|
5408
5415
|
//#endregion
|
|
5409
|
-
//#region ../types/dist/sleep-
|
|
5416
|
+
//#region ../types/dist/sleep-Cr5YOk3m.mjs
|
|
5410
5417
|
/**
|
|
5411
5418
|
* The audio chunk plane's byte format, and the ONE expansion from a coded
|
|
5412
5419
|
* window to float samples (D455).
|
|
@@ -5485,6 +5492,97 @@ function buildAlawTable() {
|
|
|
5485
5492
|
}
|
|
5486
5493
|
buildUlawTable();
|
|
5487
5494
|
buildAlawTable();
|
|
5495
|
+
/** Is this field's stored value a credential? */
|
|
5496
|
+
function isSecretConfigField(field) {
|
|
5497
|
+
if (field.type === "password") return true;
|
|
5498
|
+
return "secret" in field && field.secret === true;
|
|
5499
|
+
}
|
|
5500
|
+
/**
|
|
5501
|
+
* Is this field's value stored in the KEYCHAIN (D787)? Every secret field is,
|
|
5502
|
+
* by its TYPE, unless it opts out with `storage: 'inline'` — never by its name.
|
|
5503
|
+
*/
|
|
5504
|
+
function isKeychainStoredField(field) {
|
|
5505
|
+
if (!isSecretConfigField(field)) return false;
|
|
5506
|
+
if (field.type === "textarea" && field.isJson === true) return false;
|
|
5507
|
+
return !("storage" in field && field.storage === "inline");
|
|
5508
|
+
}
|
|
5509
|
+
/**
|
|
5510
|
+
* What a settings blob holds where a secret used to be.
|
|
5511
|
+
*
|
|
5512
|
+
* A keychain-stored field never holds its value. It holds a self-describing
|
|
5513
|
+
* MARKER, `{"$secret":"secret://…","v":1}` — an object, never a string, so no
|
|
5514
|
+
* code can mistake it for a credential and no form can send it to a camera as
|
|
5515
|
+
* a password. The empty state is `null` / absent, never `''`.
|
|
5516
|
+
*
|
|
5517
|
+
* The same shapes travel to and from the admin UI:
|
|
5518
|
+
*
|
|
5519
|
+
* - read: `hydrateSchema` hands a secret field a {@link SecretFieldView}
|
|
5520
|
+
* (`{ $secret, v, set: true }`) or `null` — the browser learns whether a
|
|
5521
|
+
* value is set, never the value.
|
|
5522
|
+
* - write: an untouched field submits the view back unchanged (KEEP); a typed
|
|
5523
|
+
* value is a plain non-empty string (CHANGE); the Clear button submits
|
|
5524
|
+
* {@link SECRET_CLEAR} (CLEAR). `''`, `null` and the legacy redaction tokens
|
|
5525
|
+
* are KEEP — an empty string is what a defaults-fallback pushes back, and
|
|
5526
|
+
* treating it as "clear" is how a save destroyed a stored credential before.
|
|
5527
|
+
*
|
|
5528
|
+
* Pure and browser-safe.
|
|
5529
|
+
*/
|
|
5530
|
+
var SECRET_CLEAR = { $secretClear: true };
|
|
5531
|
+
/** The `'***'` token D634 redaction writes for non-admins. */
|
|
5532
|
+
var LEGACY_DEVICE_REDACTION = "***";
|
|
5533
|
+
function isRecord$1(value) {
|
|
5534
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
5535
|
+
}
|
|
5536
|
+
function makeSecretMarker(ref) {
|
|
5537
|
+
return {
|
|
5538
|
+
$secret: ref,
|
|
5539
|
+
v: 1
|
|
5540
|
+
};
|
|
5541
|
+
}
|
|
5542
|
+
/** A stored marker: an object whose `$secret` is a non-empty string. */
|
|
5543
|
+
function isSecretMarker(value) {
|
|
5544
|
+
if (!isRecord$1(value)) return false;
|
|
5545
|
+
const ref = value["$secret"];
|
|
5546
|
+
return typeof ref === "string" && ref.length > 0;
|
|
5547
|
+
}
|
|
5548
|
+
function isSecretClear(value) {
|
|
5549
|
+
return isRecord$1(value) && value["$secretClear"] === true;
|
|
5550
|
+
}
|
|
5551
|
+
/**
|
|
5552
|
+
* The UI view of a stored secret field value: a marker becomes "set", inline
|
|
5553
|
+
* plaintext becomes "set (inline)", nothing becomes `null`. A value never
|
|
5554
|
+
* survives this function.
|
|
5555
|
+
*/
|
|
5556
|
+
function toSecretFieldView(stored) {
|
|
5557
|
+
if (isSecretMarker(stored)) return {
|
|
5558
|
+
$secret: stored.$secret,
|
|
5559
|
+
v: 1,
|
|
5560
|
+
set: true
|
|
5561
|
+
};
|
|
5562
|
+
if (typeof stored === "string" && stored.length > 0) return {
|
|
5563
|
+
$secret: null,
|
|
5564
|
+
v: 1,
|
|
5565
|
+
set: true,
|
|
5566
|
+
inline: true
|
|
5567
|
+
};
|
|
5568
|
+
return null;
|
|
5569
|
+
}
|
|
5570
|
+
/**
|
|
5571
|
+
* Classify an incoming value for a secret path. Only a non-empty string that is
|
|
5572
|
+
* not a redaction token sets a value; only {@link SECRET_CLEAR} clears.
|
|
5573
|
+
* Everything else — a marker (ours or anyone's), a UI view, `''`, `null`,
|
|
5574
|
+
* `undefined`, a redaction token, a non-string — keeps what is stored.
|
|
5575
|
+
*/
|
|
5576
|
+
function classifySecretWrite(incoming) {
|
|
5577
|
+
if (isSecretClear(incoming)) return { kind: "clear" };
|
|
5578
|
+
if (typeof incoming !== "string") return { kind: "keep" };
|
|
5579
|
+
if (incoming.length === 0) return { kind: "keep" };
|
|
5580
|
+
if (incoming === "__camstack_redacted__" || incoming === LEGACY_DEVICE_REDACTION) return { kind: "keep" };
|
|
5581
|
+
return {
|
|
5582
|
+
kind: "set",
|
|
5583
|
+
value: incoming
|
|
5584
|
+
};
|
|
5585
|
+
}
|
|
5488
5586
|
Object.fromEntries([
|
|
5489
5587
|
{
|
|
5490
5588
|
id: "overview",
|
|
@@ -5656,33 +5754,19 @@ Object.fromEntries([
|
|
|
5656
5754
|
function isValuelessField(field) {
|
|
5657
5755
|
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";
|
|
5658
5756
|
}
|
|
5659
|
-
|
|
5660
|
-
* Merge a `ConfigUISchema` with a raw `values` record into a
|
|
5661
|
-
* `ConfigUISchemaWithValues`. Used by every `get*Settings` backend endpoint
|
|
5662
|
-
* before returning to the admin UI. Groups are walked recursively.
|
|
5663
|
-
*
|
|
5664
|
-
* For each leaf field:
|
|
5665
|
-
* - structural fields (`separator`, `info`, `button`) pass through unchanged
|
|
5666
|
-
* - other fields get `value = values[key] ?? field.default ?? null`
|
|
5667
|
-
*
|
|
5668
|
-
* Unknown keys in `values` (keys not declared in the schema) are silently
|
|
5669
|
-
* ignored — they don't contribute to the output. Missing keys fall back to
|
|
5670
|
-
* the schema default or `null`. This mirrors the old backend behaviour where
|
|
5671
|
-
* `FormBuilder` rendered `values[key] ?? field.default`.
|
|
5672
|
-
*/
|
|
5673
|
-
function hydrateSchema(schema, values) {
|
|
5757
|
+
function hydrateSchema(schema, values, options = {}) {
|
|
5674
5758
|
return {
|
|
5675
5759
|
...schema.tabs ? { tabs: [...schema.tabs] } : {},
|
|
5676
5760
|
sections: schema.sections.map((section) => ({
|
|
5677
5761
|
...section,
|
|
5678
|
-
fields: section.fields.map((field) => hydrateField(field, values))
|
|
5762
|
+
fields: section.fields.map((field) => hydrateField(field, values, options))
|
|
5679
5763
|
}))
|
|
5680
5764
|
};
|
|
5681
5765
|
}
|
|
5682
|
-
function hydrateField(field, values) {
|
|
5766
|
+
function hydrateField(field, values, options) {
|
|
5683
5767
|
if (isValuelessField(field)) return field;
|
|
5684
5768
|
if (field.type === "group") {
|
|
5685
|
-
const hydratedChildren = field.fields.map((child) => hydrateField(child, values));
|
|
5769
|
+
const hydratedChildren = field.fields.map((child) => hydrateField(child, values, options));
|
|
5686
5770
|
return {
|
|
5687
5771
|
...field,
|
|
5688
5772
|
fields: hydratedChildren
|
|
@@ -5691,7 +5775,7 @@ function hydrateField(field, values) {
|
|
|
5691
5775
|
if (field.type === "sub-tabs") {
|
|
5692
5776
|
const hydratedTabs = field.tabs.map((tab) => ({
|
|
5693
5777
|
...tab,
|
|
5694
|
-
fields: tab.fields.map((child) => hydrateField(child, values))
|
|
5778
|
+
fields: tab.fields.map((child) => hydrateField(child, values, options))
|
|
5695
5779
|
}));
|
|
5696
5780
|
return {
|
|
5697
5781
|
...field,
|
|
@@ -5701,6 +5785,33 @@ function hydrateField(field, values) {
|
|
|
5701
5785
|
const key = field.key;
|
|
5702
5786
|
const storedValue = Object.prototype.hasOwnProperty.call(values, key) ? values[key] : void 0;
|
|
5703
5787
|
const defaultValue = field.default;
|
|
5788
|
+
const asView = (v) => isSecretMarker(v) || options.inlineSecretsAsViews === true && v !== void 0;
|
|
5789
|
+
if (isKeychainStoredField(field) && asView(storedValue)) return {
|
|
5790
|
+
...field,
|
|
5791
|
+
value: toSecretFieldView(storedValue)
|
|
5792
|
+
};
|
|
5793
|
+
if (isKeychainStoredField(field) && options.inlineSecretsAsViews === true) return {
|
|
5794
|
+
...field,
|
|
5795
|
+
value: null
|
|
5796
|
+
};
|
|
5797
|
+
if (field.type === "editable-array" && Array.isArray(storedValue)) {
|
|
5798
|
+
const secretItemKeys = field.itemFields.filter((item) => "key" in item && isKeychainStoredField(item)).map((item) => "key" in item ? item.key : "");
|
|
5799
|
+
if (secretItemKeys.length > 0) {
|
|
5800
|
+
const rows = storedValue.map((row) => {
|
|
5801
|
+
if (row === null || typeof row !== "object" || Array.isArray(row)) return row;
|
|
5802
|
+
const out = { ...row };
|
|
5803
|
+
for (const k of secretItemKeys) {
|
|
5804
|
+
const v = Reflect.get(row, k);
|
|
5805
|
+
if (asView(v)) out[k] = toSecretFieldView(v);
|
|
5806
|
+
}
|
|
5807
|
+
return out;
|
|
5808
|
+
});
|
|
5809
|
+
return {
|
|
5810
|
+
...field,
|
|
5811
|
+
value: rows
|
|
5812
|
+
};
|
|
5813
|
+
}
|
|
5814
|
+
}
|
|
5704
5815
|
if (field.multiple) {
|
|
5705
5816
|
const stored = Array.isArray(storedValue) ? storedValue : storedValue !== void 0 && storedValue !== null ? [storedValue] : [];
|
|
5706
5817
|
const itemFallback = field.multiple.itemDefault !== void 0 ? field.multiple.itemDefault : defaultValue !== void 0 ? defaultValue : typeOf(field) === "string" ? "" : null;
|
|
@@ -5943,6 +6054,431 @@ function projectStore(store, perNodeKeys, nodeId) {
|
|
|
5943
6054
|
}
|
|
5944
6055
|
return out;
|
|
5945
6056
|
}
|
|
6057
|
+
var GLOBAL_SCOPE = { kind: "global" };
|
|
6058
|
+
/** The scope every addon-wide (not per-node, not per-device) setting lives in. */
|
|
6059
|
+
function globalSecretScope() {
|
|
6060
|
+
return GLOBAL_SCOPE;
|
|
6061
|
+
}
|
|
6062
|
+
function encodeSegment(value) {
|
|
6063
|
+
return encodeURIComponent(value);
|
|
6064
|
+
}
|
|
6065
|
+
/**
|
|
6066
|
+
* The field path of a value inside an array item, addressed by the item's id:
|
|
6067
|
+
* `arrayItemFieldPath('providers', 'authentik', 'clientSecret')` →
|
|
6068
|
+
* `providers[authentik].clientSecret`.
|
|
6069
|
+
*/
|
|
6070
|
+
function arrayItemFieldPath(arrayKey, itemId, fieldKey) {
|
|
6071
|
+
return `${arrayKey}[${encodeSegment(itemId)}].${fieldKey}`;
|
|
6072
|
+
}
|
|
6073
|
+
/** A write to a secret path could not be stored in the keychain, so it was refused. */
|
|
6074
|
+
var KeychainWriteRefusedError = class extends Error {
|
|
6075
|
+
fieldPath;
|
|
6076
|
+
constructor(fieldPath, cause) {
|
|
6077
|
+
super(`secret "${fieldPath}" was not saved: the keychain could not store it (${cause instanceof Error ? cause.message : String(cause)}). Nothing was written.`);
|
|
6078
|
+
this.fieldPath = fieldPath;
|
|
6079
|
+
this.name = "KeychainWriteRefusedError";
|
|
6080
|
+
}
|
|
6081
|
+
};
|
|
6082
|
+
var KEEP = { kind: "keep" };
|
|
6083
|
+
function isRecord$2(value) {
|
|
6084
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
6085
|
+
}
|
|
6086
|
+
function defaultMintId() {
|
|
6087
|
+
return globalThis.crypto.randomUUID();
|
|
6088
|
+
}
|
|
6089
|
+
/** Every marker ref anywhere under `value`. */
|
|
6090
|
+
function collectSecretMarkerRefs(value, out = []) {
|
|
6091
|
+
if (isSecretMarker(value)) {
|
|
6092
|
+
out.push(value.$secret);
|
|
6093
|
+
return out;
|
|
6094
|
+
}
|
|
6095
|
+
if (Array.isArray(value)) for (const item of value) collectSecretMarkerRefs(item, out);
|
|
6096
|
+
else if (isRecord$2(value)) for (const child of Object.values(value)) collectSecretMarkerRefs(child, out);
|
|
6097
|
+
return out;
|
|
6098
|
+
}
|
|
6099
|
+
async function storedValueEquals(secrets, marker, candidate) {
|
|
6100
|
+
const resolved = (await secrets.resolve([marker.$secret]))[marker.$secret];
|
|
6101
|
+
return resolved?.kind === "value" && resolved.value === candidate;
|
|
6102
|
+
}
|
|
6103
|
+
async function writeLeaf(ctx, incoming, stored, fieldPath) {
|
|
6104
|
+
const intent = classifySecretWrite(incoming);
|
|
6105
|
+
const ref = ctx.secrets.ref(ctx.scope, fieldPath);
|
|
6106
|
+
const storedIsOurs = isSecretMarker(stored) && stored.$secret === ref;
|
|
6107
|
+
if (intent.kind === "keep") return KEEP;
|
|
6108
|
+
if (intent.kind === "set" && !ctx.operatorWrite && typeof stored === "string" && stored === intent.value) return KEEP;
|
|
6109
|
+
if (intent.kind === "clear") {
|
|
6110
|
+
if (storedIsOurs) ctx.deletes.push(ref);
|
|
6111
|
+
return {
|
|
6112
|
+
kind: "value",
|
|
6113
|
+
value: null
|
|
6114
|
+
};
|
|
6115
|
+
}
|
|
6116
|
+
if (storedIsOurs && await storedValueEquals(ctx.secrets, stored, intent.value)) return {
|
|
6117
|
+
kind: "value",
|
|
6118
|
+
value: stored
|
|
6119
|
+
};
|
|
6120
|
+
try {
|
|
6121
|
+
await ctx.secrets.put(ref, intent.value);
|
|
6122
|
+
} catch (err) {
|
|
6123
|
+
throw new KeychainWriteRefusedError(fieldPath, err);
|
|
6124
|
+
}
|
|
6125
|
+
return {
|
|
6126
|
+
kind: "value",
|
|
6127
|
+
value: makeSecretMarker(ref)
|
|
6128
|
+
};
|
|
6129
|
+
}
|
|
6130
|
+
/** Apply a member result onto `out`: KEEP restores the stored member, or removes it. */
|
|
6131
|
+
function applyMember(out, key, result, storedParent) {
|
|
6132
|
+
if (result.kind === "value") {
|
|
6133
|
+
out[key] = result.value;
|
|
6134
|
+
return;
|
|
6135
|
+
}
|
|
6136
|
+
if (Object.prototype.hasOwnProperty.call(storedParent, key)) out[key] = storedParent[key];
|
|
6137
|
+
else delete out[key];
|
|
6138
|
+
}
|
|
6139
|
+
async function writeMembers(ctx, children, incoming, stored, pathOf) {
|
|
6140
|
+
const out = { ...incoming };
|
|
6141
|
+
for (const [member, node] of children) applyMember(out, member, await writeNode(ctx, node, incoming[member], stored[member], pathOf(member)), stored);
|
|
6142
|
+
return out;
|
|
6143
|
+
}
|
|
6144
|
+
function rowId(row, idKey) {
|
|
6145
|
+
const raw = row[idKey];
|
|
6146
|
+
if (typeof raw === "string" && raw.length > 0) return raw;
|
|
6147
|
+
if (typeof raw === "number" && Number.isFinite(raw)) return String(raw);
|
|
6148
|
+
return null;
|
|
6149
|
+
}
|
|
6150
|
+
async function writeArray(ctx, node, incoming, stored, fieldPath) {
|
|
6151
|
+
const storedRows = Array.isArray(stored) ? stored.filter(isRecord$2) : [];
|
|
6152
|
+
if (!Array.isArray(incoming)) {
|
|
6153
|
+
ctx.deletes.push(...collectSecretMarkerRefs(storedRows));
|
|
6154
|
+
return {
|
|
6155
|
+
kind: "value",
|
|
6156
|
+
value: incoming
|
|
6157
|
+
};
|
|
6158
|
+
}
|
|
6159
|
+
const storedById = /* @__PURE__ */ new Map();
|
|
6160
|
+
for (const row of storedRows) {
|
|
6161
|
+
const id = rowId(row, node.idKey);
|
|
6162
|
+
if (id !== null) storedById.set(id, row);
|
|
6163
|
+
}
|
|
6164
|
+
const kept = /* @__PURE__ */ new Set();
|
|
6165
|
+
const rows = [];
|
|
6166
|
+
for (const row of incoming) {
|
|
6167
|
+
if (!isRecord$2(row)) {
|
|
6168
|
+
rows.push(row);
|
|
6169
|
+
continue;
|
|
6170
|
+
}
|
|
6171
|
+
const id = rowId(row, node.idKey) ?? ctx.mintId();
|
|
6172
|
+
kept.add(id);
|
|
6173
|
+
const withId = {
|
|
6174
|
+
...row,
|
|
6175
|
+
[node.idKey]: row[node.idKey] ?? id
|
|
6176
|
+
};
|
|
6177
|
+
if (rowId(withId, node.idKey) === null) withId[node.idKey] = id;
|
|
6178
|
+
const storedRow = storedById.get(id) ?? {};
|
|
6179
|
+
rows.push(await writeMembers(ctx, node.item, withId, storedRow, (member) => arrayItemFieldPath(fieldPath, id, member)));
|
|
6180
|
+
}
|
|
6181
|
+
for (const [id, row] of storedById) if (!kept.has(id)) ctx.deletes.push(...collectSecretMarkerRefs(row));
|
|
6182
|
+
return {
|
|
6183
|
+
kind: "value",
|
|
6184
|
+
value: rows
|
|
6185
|
+
};
|
|
6186
|
+
}
|
|
6187
|
+
async function writeNode(ctx, node, incoming, stored, fieldPath) {
|
|
6188
|
+
switch (node.kind) {
|
|
6189
|
+
case "leaf": return writeLeaf(ctx, incoming, stored, fieldPath);
|
|
6190
|
+
case "array": return writeArray(ctx, node, incoming, stored, fieldPath);
|
|
6191
|
+
case "object": {
|
|
6192
|
+
if (!isRecord$2(incoming)) {
|
|
6193
|
+
if (incoming === void 0) return KEEP;
|
|
6194
|
+
ctx.deletes.push(...collectSecretMarkerRefs(stored));
|
|
6195
|
+
return {
|
|
6196
|
+
kind: "value",
|
|
6197
|
+
value: incoming
|
|
6198
|
+
};
|
|
6199
|
+
}
|
|
6200
|
+
const storedObj = isRecord$2(stored) ? stored : {};
|
|
6201
|
+
return {
|
|
6202
|
+
kind: "value",
|
|
6203
|
+
value: await writeMembers(ctx, node.children, incoming, storedObj, (m) => `${fieldPath}.${m}`)
|
|
6204
|
+
};
|
|
6205
|
+
}
|
|
6206
|
+
}
|
|
6207
|
+
}
|
|
6208
|
+
/** Split a perNode-scoped key (`key@nodeId`). */
|
|
6209
|
+
function splitNodeKey(key) {
|
|
6210
|
+
const at = key.indexOf("@");
|
|
6211
|
+
return at <= 0 ? {
|
|
6212
|
+
base: key,
|
|
6213
|
+
nodeId: null
|
|
6214
|
+
} : {
|
|
6215
|
+
base: key.slice(0, at),
|
|
6216
|
+
nodeId: key.slice(at + 1)
|
|
6217
|
+
};
|
|
6218
|
+
}
|
|
6219
|
+
/** Rewrite a settings patch so no secret value reaches the blob. See the file doc. */
|
|
6220
|
+
async function transformSecretWrite(input) {
|
|
6221
|
+
const deletes = [];
|
|
6222
|
+
const base = {
|
|
6223
|
+
secrets: input.secrets,
|
|
6224
|
+
mintId: input.mintId ?? defaultMintId,
|
|
6225
|
+
deletes,
|
|
6226
|
+
operatorWrite: input.operatorWrite === true
|
|
6227
|
+
};
|
|
6228
|
+
const out = {};
|
|
6229
|
+
for (const [key, incoming] of Object.entries(input.patch)) {
|
|
6230
|
+
const { base: baseKey, nodeId } = splitNodeKey(key);
|
|
6231
|
+
const node = input.tree.get(baseKey);
|
|
6232
|
+
if (node === void 0) {
|
|
6233
|
+
out[key] = incoming;
|
|
6234
|
+
continue;
|
|
6235
|
+
}
|
|
6236
|
+
const scope = nodeId !== null && nodeId.length > 0 ? {
|
|
6237
|
+
kind: "node",
|
|
6238
|
+
nodeId
|
|
6239
|
+
} : input.scope ?? globalSecretScope();
|
|
6240
|
+
const result = await writeNode({
|
|
6241
|
+
...base,
|
|
6242
|
+
scope
|
|
6243
|
+
}, node, incoming, input.stored[key], baseKey);
|
|
6244
|
+
if (result.kind === "value") out[key] = result.value;
|
|
6245
|
+
}
|
|
6246
|
+
return {
|
|
6247
|
+
patch: out,
|
|
6248
|
+
afterWrite: async () => {
|
|
6249
|
+
if (deletes.length === 0) return { orphaned: [] };
|
|
6250
|
+
try {
|
|
6251
|
+
await input.secrets.delete([...new Set(deletes)]);
|
|
6252
|
+
return { orphaned: [] };
|
|
6253
|
+
} catch {
|
|
6254
|
+
return { orphaned: [...new Set(deletes)] };
|
|
6255
|
+
}
|
|
6256
|
+
}
|
|
6257
|
+
};
|
|
6258
|
+
}
|
|
6259
|
+
/**
|
|
6260
|
+
* Replace every marker in `value` with its keychain value. Returns the SAME
|
|
6261
|
+
* reference when there is no marker (no allocation, no keychain call).
|
|
6262
|
+
*/
|
|
6263
|
+
async function resolveSecretMarkers(value, secrets) {
|
|
6264
|
+
const refs = collectSecretMarkerRefs(value);
|
|
6265
|
+
if (refs.length === 0) return {
|
|
6266
|
+
value,
|
|
6267
|
+
unresolved: []
|
|
6268
|
+
};
|
|
6269
|
+
const answers = await secrets.resolve(refs);
|
|
6270
|
+
const unresolved = [];
|
|
6271
|
+
for (const ref of new Set(refs)) {
|
|
6272
|
+
const answer = answers[ref];
|
|
6273
|
+
if (answer === void 0) unresolved.push({
|
|
6274
|
+
ref,
|
|
6275
|
+
reason: "not-initialized"
|
|
6276
|
+
});
|
|
6277
|
+
else if (answer.kind === "unavailable") unresolved.push({
|
|
6278
|
+
ref,
|
|
6279
|
+
reason: answer.reason
|
|
6280
|
+
});
|
|
6281
|
+
else if (answer.kind === "missing" || answer.kind === "forbidden") unresolved.push({
|
|
6282
|
+
ref,
|
|
6283
|
+
reason: answer.kind
|
|
6284
|
+
});
|
|
6285
|
+
}
|
|
6286
|
+
const substitute = (v) => {
|
|
6287
|
+
if (isSecretMarker(v)) {
|
|
6288
|
+
const answer = answers[v.$secret];
|
|
6289
|
+
return answer?.kind === "value" ? {
|
|
6290
|
+
keep: true,
|
|
6291
|
+
value: answer.value
|
|
6292
|
+
} : {
|
|
6293
|
+
keep: false,
|
|
6294
|
+
value: void 0
|
|
6295
|
+
};
|
|
6296
|
+
}
|
|
6297
|
+
if (Array.isArray(v)) {
|
|
6298
|
+
const items = [];
|
|
6299
|
+
for (const item of v) {
|
|
6300
|
+
const s = substitute(item);
|
|
6301
|
+
if (s.keep) items.push(s.value);
|
|
6302
|
+
}
|
|
6303
|
+
return {
|
|
6304
|
+
keep: true,
|
|
6305
|
+
value: items
|
|
6306
|
+
};
|
|
6307
|
+
}
|
|
6308
|
+
if (isRecord$2(v)) {
|
|
6309
|
+
const out = {};
|
|
6310
|
+
for (const [k, child] of Object.entries(v)) {
|
|
6311
|
+
const s = substitute(child);
|
|
6312
|
+
if (s.keep) out[k] = s.value;
|
|
6313
|
+
}
|
|
6314
|
+
return {
|
|
6315
|
+
keep: true,
|
|
6316
|
+
value: out
|
|
6317
|
+
};
|
|
6318
|
+
}
|
|
6319
|
+
return {
|
|
6320
|
+
keep: true,
|
|
6321
|
+
value: v
|
|
6322
|
+
};
|
|
6323
|
+
};
|
|
6324
|
+
return {
|
|
6325
|
+
value: substitute(value).value,
|
|
6326
|
+
unresolved
|
|
6327
|
+
};
|
|
6328
|
+
}
|
|
6329
|
+
function touchesTree(tree, patch) {
|
|
6330
|
+
if (tree.size === 0) return false;
|
|
6331
|
+
for (const key of Object.keys(patch)) {
|
|
6332
|
+
const at = key.indexOf("@");
|
|
6333
|
+
if (tree.has(at > 0 ? key.slice(0, at) : key)) return true;
|
|
6334
|
+
}
|
|
6335
|
+
return false;
|
|
6336
|
+
}
|
|
6337
|
+
/** The blob as stored now; a failed read REFUSES the write instead of guessing. */
|
|
6338
|
+
async function readStoredAddonBlob(raw) {
|
|
6339
|
+
const threeWay = raw.readAddonStoreResult;
|
|
6340
|
+
if (threeWay === void 0) return raw.readAddonStore();
|
|
6341
|
+
const result = await threeWay.call(raw);
|
|
6342
|
+
if (result.kind === "failed") throw new Error(`settings write refused: the stored blob could not be read (${result.error})`);
|
|
6343
|
+
return result.kind === "missing" ? {} : result.value;
|
|
6344
|
+
}
|
|
6345
|
+
function createSecretAwareSettings(raw, opts) {
|
|
6346
|
+
const chains = /* @__PURE__ */ new Map();
|
|
6347
|
+
const serialize = (key, fn) => {
|
|
6348
|
+
const next = (chains.get(key) ?? Promise.resolve()).then(fn, fn);
|
|
6349
|
+
const tail = next.catch(() => void 0);
|
|
6350
|
+
chains.set(key, tail);
|
|
6351
|
+
tail.then(() => {
|
|
6352
|
+
if (chains.get(key) === tail) chains.delete(key);
|
|
6353
|
+
});
|
|
6354
|
+
return next;
|
|
6355
|
+
};
|
|
6356
|
+
const write = async (chainKey, tree, scope, patch, readStored, rawWrite) => {
|
|
6357
|
+
if (!touchesTree(tree, patch)) return rawWrite(patch);
|
|
6358
|
+
return serialize(chainKey, async () => {
|
|
6359
|
+
const stored = await readStored();
|
|
6360
|
+
const result = await transformSecretWrite({
|
|
6361
|
+
tree,
|
|
6362
|
+
secrets: opts.secrets,
|
|
6363
|
+
patch,
|
|
6364
|
+
stored,
|
|
6365
|
+
...scope !== void 0 ? { scope } : {},
|
|
6366
|
+
operatorWrite: opts.isOperatorWrite?.() === true
|
|
6367
|
+
});
|
|
6368
|
+
if (Object.keys(result.patch).length > 0) await rawWrite(result.patch);
|
|
6369
|
+
const { orphaned } = await result.afterWrite();
|
|
6370
|
+
if (orphaned.length > 0) opts.onOrphaned(orphaned);
|
|
6371
|
+
});
|
|
6372
|
+
};
|
|
6373
|
+
const wrapped = {
|
|
6374
|
+
writeAddonStore: (patch) => write("addon", opts.addonTree(), void 0, patch, () => readStoredAddonBlob(raw), (p) => raw.writeAddonStore(p)),
|
|
6375
|
+
writeDeviceStore: (deviceId, patch) => write(`device:${deviceId}`, opts.deviceTree(), {
|
|
6376
|
+
kind: "device",
|
|
6377
|
+
deviceId
|
|
6378
|
+
}, patch, () => raw.readDeviceStore(deviceId), (p) => raw.writeDeviceStore(deviceId, p))
|
|
6379
|
+
};
|
|
6380
|
+
return new Proxy(raw, { get(target, prop, receiver) {
|
|
6381
|
+
if (prop === "writeAddonStore") return wrapped.writeAddonStore;
|
|
6382
|
+
if (prop === "writeDeviceStore") return wrapped.writeDeviceStore;
|
|
6383
|
+
const value = Reflect.get(target, prop, receiver);
|
|
6384
|
+
return typeof value === "function" ? value.bind(target) : value;
|
|
6385
|
+
} });
|
|
6386
|
+
}
|
|
6387
|
+
/** The context the addon sees: identical, except that its settings writes are secret-aware. */
|
|
6388
|
+
function withSecretAwareSettings(context, opts) {
|
|
6389
|
+
const raw = context.settings;
|
|
6390
|
+
if (raw === void 0) return context;
|
|
6391
|
+
const settings = createSecretAwareSettings(raw, opts);
|
|
6392
|
+
return new Proxy(context, { get(target, prop, receiver) {
|
|
6393
|
+
if (prop === "settings") return settings;
|
|
6394
|
+
return Reflect.get(target, prop, receiver);
|
|
6395
|
+
} });
|
|
6396
|
+
}
|
|
6397
|
+
var LEAF = { kind: "leaf" };
|
|
6398
|
+
var DEFAULT_ITEM_ID_KEY = "id";
|
|
6399
|
+
function collectFields(fields, out) {
|
|
6400
|
+
for (const field of fields) {
|
|
6401
|
+
if (field.type === "group") {
|
|
6402
|
+
collectFields(field.fields, out);
|
|
6403
|
+
continue;
|
|
6404
|
+
}
|
|
6405
|
+
if (field.type === "sub-tabs") {
|
|
6406
|
+
for (const tab of field.tabs) collectFields(tab.fields, out);
|
|
6407
|
+
continue;
|
|
6408
|
+
}
|
|
6409
|
+
if (field.type === "editable-array") {
|
|
6410
|
+
const item = /* @__PURE__ */ new Map();
|
|
6411
|
+
for (const itemField of field.itemFields) if ("key" in itemField && isKeychainStoredField(itemField)) item.set(itemField.key, LEAF);
|
|
6412
|
+
if (item.size > 0) out.set(field.key, {
|
|
6413
|
+
kind: "array",
|
|
6414
|
+
idKey: field.itemIdKey ?? DEFAULT_ITEM_ID_KEY,
|
|
6415
|
+
item
|
|
6416
|
+
});
|
|
6417
|
+
continue;
|
|
6418
|
+
}
|
|
6419
|
+
if (!("key" in field) || typeof field.key !== "string") continue;
|
|
6420
|
+
if (isKeychainStoredField(field)) out.set(field.key, LEAF);
|
|
6421
|
+
}
|
|
6422
|
+
}
|
|
6423
|
+
/** The secret tree a settings schema declares. */
|
|
6424
|
+
function secretTreeFromSchema(schema) {
|
|
6425
|
+
const out = /* @__PURE__ */ new Map();
|
|
6426
|
+
if (schema === null) return out;
|
|
6427
|
+
for (const section of schema.sections) collectFields(section.fields, out);
|
|
6428
|
+
return out;
|
|
6429
|
+
}
|
|
6430
|
+
/** Parse `a.b[id].c` into segments; throws on a malformed path (a declaration bug). */
|
|
6431
|
+
function parseSecretStatePath(path) {
|
|
6432
|
+
const segments = [];
|
|
6433
|
+
for (const raw of path.split(".")) {
|
|
6434
|
+
const m = /^([^[\]]+)(?:\[([^[\]]+)\])?$/.exec(raw);
|
|
6435
|
+
if (m === null || m[1] === void 0) throw new Error(`secretStatePaths: malformed path "${path}"`);
|
|
6436
|
+
segments.push(m[2] !== void 0 ? {
|
|
6437
|
+
key: m[1],
|
|
6438
|
+
idKey: m[2]
|
|
6439
|
+
} : { key: m[1] });
|
|
6440
|
+
}
|
|
6441
|
+
if (segments.length === 0) throw new Error(`secretStatePaths: empty path`);
|
|
6442
|
+
if (segments[segments.length - 1]?.idKey !== void 0) throw new Error(`secretStatePaths: "${path}" ends on an array — name the member that is secret`);
|
|
6443
|
+
return segments;
|
|
6444
|
+
}
|
|
6445
|
+
function insert(into, segments) {
|
|
6446
|
+
const [head, ...rest] = segments;
|
|
6447
|
+
if (head === void 0) return;
|
|
6448
|
+
if (rest.length === 0) {
|
|
6449
|
+
into.set(head.key, LEAF);
|
|
6450
|
+
return;
|
|
6451
|
+
}
|
|
6452
|
+
const existing = into.get(head.key);
|
|
6453
|
+
if (head.idKey !== void 0) {
|
|
6454
|
+
const item = new Map(existing?.kind === "array" ? existing.item : []);
|
|
6455
|
+
insert(item, rest);
|
|
6456
|
+
into.set(head.key, {
|
|
6457
|
+
kind: "array",
|
|
6458
|
+
idKey: head.idKey,
|
|
6459
|
+
item
|
|
6460
|
+
});
|
|
6461
|
+
return;
|
|
6462
|
+
}
|
|
6463
|
+
const children = new Map(existing?.kind === "object" ? existing.children : []);
|
|
6464
|
+
insert(children, rest);
|
|
6465
|
+
into.set(head.key, {
|
|
6466
|
+
kind: "object",
|
|
6467
|
+
children
|
|
6468
|
+
});
|
|
6469
|
+
}
|
|
6470
|
+
/** Add hidden-state paths (`secretStatePaths`) to a schema-derived tree. */
|
|
6471
|
+
function mergeSecretStatePaths(tree, paths) {
|
|
6472
|
+
if (paths.length === 0) return tree;
|
|
6473
|
+
const out = new Map(tree);
|
|
6474
|
+
for (const path of paths) insert(out, parseSecretStatePath(path));
|
|
6475
|
+
return out;
|
|
6476
|
+
}
|
|
6477
|
+
/** First retry of a secret the keychain could not serve; doubles to {@link SECRET_RETRY_MAX_MS}. */
|
|
6478
|
+
var SECRET_RETRY_FIRST_MS = 5e3;
|
|
6479
|
+
var SECRET_RETRY_MAX_MS = 5 * 6e4;
|
|
6480
|
+
/** Coalesces a burst of `keychain.changed` events into one re-resolve. */
|
|
6481
|
+
var SECRET_CHANGE_DEBOUNCE_MS = 250;
|
|
5946
6482
|
/**
|
|
5947
6483
|
* Base class for CamStack addons. Eliminates settings boilerplate:
|
|
5948
6484
|
*
|
|
@@ -6012,6 +6548,25 @@ var BaseAddon = class {
|
|
|
6012
6548
|
settingsStoreReady = false;
|
|
6013
6549
|
/** Default config values. Provided via constructor. */
|
|
6014
6550
|
defaults;
|
|
6551
|
+
/**
|
|
6552
|
+
* Hidden-state paths that hold secrets (D787) — values the addon writes
|
|
6553
|
+
* itself (`updateGlobalSettings`, `state()`) that no form field declares.
|
|
6554
|
+
* Stored in the keychain exactly like a `password` field. Syntax:
|
|
6555
|
+
* `'snapshotSigningKey'`, `'identity.pincode'`, `'tokens[userId].accessToken'`
|
|
6556
|
+
* (`key[<id field>]` addresses array items by id, never by index).
|
|
6557
|
+
*/
|
|
6558
|
+
secretStatePaths = [];
|
|
6559
|
+
_addonSecretTree = null;
|
|
6560
|
+
_deviceSecretTree = null;
|
|
6561
|
+
/** Refs the last resolved config pointed at — a change to one re-resolves. */
|
|
6562
|
+
_configSecretRefs = /* @__PURE__ */ new Set();
|
|
6563
|
+
_unresolvedSecrets = [];
|
|
6564
|
+
_secretRetryTimer = null;
|
|
6565
|
+
_secretRetryDelayMs = SECRET_RETRY_FIRST_MS;
|
|
6566
|
+
_secretChangeTimer = null;
|
|
6567
|
+
_secretChangeUnsub = null;
|
|
6568
|
+
/** >0 while an OPERATOR's settings write is being applied. */
|
|
6569
|
+
_operatorWriteDepth = 0;
|
|
6015
6570
|
constructor(defaults) {
|
|
6016
6571
|
this.defaults = defaults;
|
|
6017
6572
|
this._config = { ...defaults };
|
|
@@ -6047,8 +6602,18 @@ var BaseAddon = class {
|
|
|
6047
6602
|
return this._config;
|
|
6048
6603
|
}
|
|
6049
6604
|
async initialize(context) {
|
|
6050
|
-
|
|
6605
|
+
const secrets = context.secrets;
|
|
6606
|
+
this._ctx = secrets !== void 0 ? withSecretAwareSettings(context, {
|
|
6607
|
+
secrets,
|
|
6608
|
+
addonTree: () => this.addonSecretTree(),
|
|
6609
|
+
deviceTree: () => this.deviceSecretTree(),
|
|
6610
|
+
onOrphaned: (refs) => context.logger.warn("keychain refs dropped by a settings write could not be deleted", { meta: { refs: [...refs] } }),
|
|
6611
|
+
isOperatorWrite: () => this._operatorWriteDepth > 0
|
|
6612
|
+
}) : context;
|
|
6051
6613
|
await this.resolveConfig();
|
|
6614
|
+
if (secrets !== void 0) this._secretChangeUnsub = secrets.onChange((ref) => {
|
|
6615
|
+
if (this._configSecretRefs.has(ref)) this.scheduleSecretReresolve(SECRET_CHANGE_DEBOUNCE_MS);
|
|
6616
|
+
});
|
|
6052
6617
|
const result = await this.onInitialize();
|
|
6053
6618
|
this.emitLifecycle(EventCategory.AddonStarted);
|
|
6054
6619
|
const normalized = normalizeAddonInitResult(result);
|
|
@@ -6081,6 +6646,12 @@ var BaseAddon = class {
|
|
|
6081
6646
|
*/
|
|
6082
6647
|
async onHubReachable() {}
|
|
6083
6648
|
async shutdown() {
|
|
6649
|
+
this._secretChangeUnsub?.();
|
|
6650
|
+
this._secretChangeUnsub = null;
|
|
6651
|
+
if (this._secretRetryTimer !== null) clearTimeout(this._secretRetryTimer);
|
|
6652
|
+
if (this._secretChangeTimer !== null) clearTimeout(this._secretChangeTimer);
|
|
6653
|
+
this._secretRetryTimer = null;
|
|
6654
|
+
this._secretChangeTimer = null;
|
|
6084
6655
|
this.emitLifecycle(EventCategory.AddonStopped);
|
|
6085
6656
|
if (this.autoEmitReadiness) this.emitReadinessForProviders("down");
|
|
6086
6657
|
await this.onShutdown();
|
|
@@ -6159,7 +6730,7 @@ var BaseAddon = class {
|
|
|
6159
6730
|
return hydrateSchema(schema, overlay ? {
|
|
6160
6731
|
...projected,
|
|
6161
6732
|
...overlay
|
|
6162
|
-
} : projected);
|
|
6733
|
+
} : projected, { inlineSecretsAsViews: true });
|
|
6163
6734
|
}
|
|
6164
6735
|
/**
|
|
6165
6736
|
* The integration-level view of this addon's settings: exactly the sections
|
|
@@ -6208,7 +6779,7 @@ var BaseAddon = class {
|
|
|
6208
6779
|
return hydrateSchema({
|
|
6209
6780
|
...schema,
|
|
6210
6781
|
sections
|
|
6211
|
-
}, projected);
|
|
6782
|
+
}, projected, { inlineSecretsAsViews: true });
|
|
6212
6783
|
}
|
|
6213
6784
|
/**
|
|
6214
6785
|
* The raw addon store PROJECTED onto the target node's bare per-node keys:
|
|
@@ -6262,18 +6833,50 @@ var BaseAddon = class {
|
|
|
6262
6833
|
value: result.value[key]
|
|
6263
6834
|
};
|
|
6264
6835
|
}
|
|
6836
|
+
/**
|
|
6837
|
+
* The OPERATOR's write — a settings form or an admin API call, dispatched by
|
|
6838
|
+
* the kernel. Identical to {@link updateGlobalSettings}, except that a secret
|
|
6839
|
+
* the operator sends is stored as sent even when it equals a pre-keychain
|
|
6840
|
+
* inline value: the operator re-entering a password is a change, an addon
|
|
6841
|
+
* writing back what it read is not (D787).
|
|
6842
|
+
*/
|
|
6843
|
+
async updateGlobalSettingsAsOperator(patch, nodeId) {
|
|
6844
|
+
this._operatorWriteDepth++;
|
|
6845
|
+
try {
|
|
6846
|
+
await this.applyGlobalPatch(patch, nodeId);
|
|
6847
|
+
} finally {
|
|
6848
|
+
this._operatorWriteDepth--;
|
|
6849
|
+
}
|
|
6850
|
+
}
|
|
6265
6851
|
async updateGlobalSettings(patch, nodeId) {
|
|
6852
|
+
await this.applyGlobalPatch(patch, nodeId);
|
|
6853
|
+
}
|
|
6854
|
+
/**
|
|
6855
|
+
* REMOVE stored secrets — their keychain values and their markers (D787).
|
|
6856
|
+
*
|
|
6857
|
+
* Writing `''` to a secret field KEEPS what is stored (an empty string is
|
|
6858
|
+
* what a defaults fallback writes back, and it must never destroy a
|
|
6859
|
+
* credential), so code that means "forget this token" says so here. Without
|
|
6860
|
+
* a keychain (an older kernel) it writes `''`, as such code always did.
|
|
6861
|
+
*/
|
|
6862
|
+
async clearSecrets(keys, nodeId) {
|
|
6863
|
+
const tree = this.addonSecretTree();
|
|
6864
|
+
const keychain = this._ctx?.secrets !== void 0;
|
|
6865
|
+
const patch = {};
|
|
6866
|
+
for (const key of keys) patch[key] = keychain && tree.has(key) ? SECRET_CLEAR : "";
|
|
6867
|
+
await this.applyGlobalPatch(patch, nodeId);
|
|
6868
|
+
}
|
|
6869
|
+
async applyGlobalPatch(barePatch, nodeId) {
|
|
6266
6870
|
const keys = this.perNodeKeys();
|
|
6267
6871
|
const localNode = normalizeNodeId(this._ctx?.kernel?.localNodeId);
|
|
6268
6872
|
const target = normalizeNodeId(nodeId ?? this._ctx?.kernel?.localNodeId);
|
|
6269
|
-
const barePatch = patch;
|
|
6270
6873
|
const scoped = keys.size > 0 ? scopePatch(barePatch, keys, target) : barePatch;
|
|
6271
6874
|
await this._ctx?.settings?.writeAddonStore(scoped);
|
|
6272
6875
|
if (target !== localNode) return;
|
|
6273
6876
|
await this.resolveConfig();
|
|
6274
6877
|
await this.onConfigChanged();
|
|
6275
6878
|
this.emitLifecycle(EventCategory.AddonUpdated, { level: "global" });
|
|
6276
|
-
this.maybeAutoRestart(
|
|
6879
|
+
this.maybeAutoRestart(Object.keys(barePatch), this.globalSettingsSchema());
|
|
6277
6880
|
}
|
|
6278
6881
|
/**
|
|
6279
6882
|
* The set of field keys the global settings schema declares `perNode: true`
|
|
@@ -6298,7 +6901,7 @@ var BaseAddon = class {
|
|
|
6298
6901
|
* time to return its response before the addon is torn down and
|
|
6299
6902
|
* re-initialised by `AddonRegistryService.restartAddon`.
|
|
6300
6903
|
*/
|
|
6301
|
-
maybeAutoRestart(
|
|
6904
|
+
maybeAutoRestart(patchKeys, schema) {
|
|
6302
6905
|
if (!schema) return;
|
|
6303
6906
|
const restartKeys = /* @__PURE__ */ new Set();
|
|
6304
6907
|
for (const section of schema.sections) for (const field of section.fields) {
|
|
@@ -6306,13 +6909,13 @@ var BaseAddon = class {
|
|
|
6306
6909
|
if (field.requiresRestart) restartKeys.add(field.key);
|
|
6307
6910
|
}
|
|
6308
6911
|
if (restartKeys.size === 0) return;
|
|
6309
|
-
if (!
|
|
6912
|
+
if (!patchKeys.some((k) => restartKeys.has(k))) return;
|
|
6310
6913
|
const ctx = this._ctx;
|
|
6311
6914
|
if (!ctx) return;
|
|
6312
6915
|
const addonId = ctx.id;
|
|
6313
6916
|
setImmediate(() => {
|
|
6314
6917
|
ctx.api.addons?.restartAddon?.mutate({ addonId }).then(() => {
|
|
6315
|
-
ctx.logger.info("addon auto-restart triggered by restart-required setting change", { meta: { changedFields:
|
|
6918
|
+
ctx.logger.info("addon auto-restart triggered by restart-required setting change", { meta: { changedFields: patchKeys.filter((k) => restartKeys.has(k)) } });
|
|
6316
6919
|
}).catch((err) => {
|
|
6317
6920
|
ctx.logger.error("addon auto-restart failed", { meta: { error: err instanceof Error ? err.message : String(err) } });
|
|
6318
6921
|
});
|
|
@@ -6321,7 +6924,7 @@ var BaseAddon = class {
|
|
|
6321
6924
|
async getDeviceSettings(deviceId) {
|
|
6322
6925
|
const schema = this.deviceSettingsSchema();
|
|
6323
6926
|
if (!schema) return { sections: [] };
|
|
6324
|
-
return hydrateSchema(schema, await this._ctx?.settings?.readDeviceStore(deviceId) ?? {});
|
|
6927
|
+
return hydrateSchema(schema, await this._ctx?.settings?.readDeviceStore(deviceId) ?? {}, { inlineSecretsAsViews: true });
|
|
6325
6928
|
}
|
|
6326
6929
|
async updateDeviceSettings(deviceId, patch) {
|
|
6327
6930
|
await this._ctx?.settings?.writeDeviceStore(deviceId, patch);
|
|
@@ -6451,7 +7054,7 @@ var BaseAddon = class {
|
|
|
6451
7054
|
* selection at boot (absent scoped key ⇒ the constructor default wins).
|
|
6452
7055
|
*/
|
|
6453
7056
|
async resolveConfig() {
|
|
6454
|
-
const stored = await this.readAddonStoreWithRetry();
|
|
7057
|
+
const stored = await this.resolveStoredSecrets(await this.readAddonStoreWithRetry());
|
|
6455
7058
|
const perNode = this.perNodeKeys();
|
|
6456
7059
|
const localNode = normalizeNodeId(this._ctx?.kernel?.localNodeId);
|
|
6457
7060
|
const resolved = { ...this.defaults };
|
|
@@ -6476,7 +7079,7 @@ var BaseAddon = class {
|
|
|
6476
7079
|
key,
|
|
6477
7080
|
schema,
|
|
6478
7081
|
fallback,
|
|
6479
|
-
read: () => this.readAddonStoreWithRetry(),
|
|
7082
|
+
read: async () => this.resolveStoredSecrets(await this.readAddonStoreWithRetry()),
|
|
6480
7083
|
write: async (patch) => {
|
|
6481
7084
|
await this._ctx?.settings?.writeAddonStore(patch);
|
|
6482
7085
|
},
|
|
@@ -6493,7 +7096,7 @@ var BaseAddon = class {
|
|
|
6493
7096
|
key,
|
|
6494
7097
|
schema,
|
|
6495
7098
|
fallback,
|
|
6496
|
-
read: async () => await this._ctx?.settings?.readDeviceStore(deviceId) ?? {},
|
|
7099
|
+
read: async () => this.resolveStoredSecrets(await this._ctx?.settings?.readDeviceStore(deviceId) ?? {}, false),
|
|
6497
7100
|
write: async (patch) => {
|
|
6498
7101
|
await this._ctx?.settings?.writeDeviceStore(deviceId, patch);
|
|
6499
7102
|
},
|
|
@@ -6505,6 +7108,70 @@ var BaseAddon = class {
|
|
|
6505
7108
|
} })
|
|
6506
7109
|
});
|
|
6507
7110
|
}
|
|
7111
|
+
/** The addon store's secret tree: schema fields by TYPE, plus `secretStatePaths`. */
|
|
7112
|
+
addonSecretTree() {
|
|
7113
|
+
this._addonSecretTree ??= mergeSecretStatePaths(secretTreeFromSchema(this.globalSettingsSchema()), this.secretStatePaths);
|
|
7114
|
+
return this._addonSecretTree;
|
|
7115
|
+
}
|
|
7116
|
+
deviceSecretTree() {
|
|
7117
|
+
this._deviceSecretTree ??= secretTreeFromSchema(this.deviceSettingsSchema());
|
|
7118
|
+
return this._deviceSecretTree;
|
|
7119
|
+
}
|
|
7120
|
+
/**
|
|
7121
|
+
* Secrets of this addon's stored config that could not be resolved on the
|
|
7122
|
+
* last read, with why. Non-empty means the addon is running WITHOUT them —
|
|
7123
|
+
* an addon whose function needs one should report itself degraded rather
|
|
7124
|
+
* than start on an empty credential.
|
|
7125
|
+
*/
|
|
7126
|
+
get unresolvedSecrets() {
|
|
7127
|
+
return this._unresolvedSecrets;
|
|
7128
|
+
}
|
|
7129
|
+
/**
|
|
7130
|
+
* Substitute every keychain marker in a stored blob with its value. With no
|
|
7131
|
+
* keychain (no `ctx.secrets`) or no marker, the blob comes back unchanged.
|
|
7132
|
+
* An unresolvable value is LEFT OUT (never `''`), logged by ref — never by
|
|
7133
|
+
* value — and, when the cause can pass, retried with backoff. Nothing is
|
|
7134
|
+
* ever written back from here.
|
|
7135
|
+
*/
|
|
7136
|
+
async resolveStoredSecrets(blob, trackForConfig = true) {
|
|
7137
|
+
const secrets = this._ctx?.secrets;
|
|
7138
|
+
if (secrets === void 0) return blob;
|
|
7139
|
+
const refs = collectSecretMarkerRefs(blob);
|
|
7140
|
+
if (trackForConfig) this._configSecretRefs = new Set(refs);
|
|
7141
|
+
if (refs.length === 0) {
|
|
7142
|
+
if (trackForConfig) this._unresolvedSecrets = [];
|
|
7143
|
+
return blob;
|
|
7144
|
+
}
|
|
7145
|
+
const { value, unresolved } = await resolveSecretMarkers(blob, secrets);
|
|
7146
|
+
if (trackForConfig) {
|
|
7147
|
+
this._unresolvedSecrets = unresolved;
|
|
7148
|
+
if (unresolved.length > 0) {
|
|
7149
|
+
this._ctx?.logger?.error?.("secret unavailable — running without it, will retry", { meta: { secrets: unresolved.map((u) => ({
|
|
7150
|
+
ref: u.ref,
|
|
7151
|
+
reason: u.reason
|
|
7152
|
+
})) } });
|
|
7153
|
+
if (unresolved.some((u) => u.reason !== "missing" && u.reason !== "forbidden")) {
|
|
7154
|
+
this.scheduleSecretReresolve(this._secretRetryDelayMs);
|
|
7155
|
+
this._secretRetryDelayMs = Math.min(this._secretRetryDelayMs * 2, SECRET_RETRY_MAX_MS);
|
|
7156
|
+
}
|
|
7157
|
+
} else this._secretRetryDelayMs = SECRET_RETRY_FIRST_MS;
|
|
7158
|
+
}
|
|
7159
|
+
return value;
|
|
7160
|
+
}
|
|
7161
|
+
/** Re-resolve the config (a keychain-only change, or a retry) and apply it. */
|
|
7162
|
+
scheduleSecretReresolve(delayMs) {
|
|
7163
|
+
const timerOf = delayMs === SECRET_CHANGE_DEBOUNCE_MS ? "_secretChangeTimer" : "_secretRetryTimer";
|
|
7164
|
+
if (this[timerOf] !== null) return;
|
|
7165
|
+
const timer = setTimeout(() => {
|
|
7166
|
+
this[timerOf] = null;
|
|
7167
|
+
if (this._ctx === null) return;
|
|
7168
|
+
this.resolveConfig().then(() => this.onConfigChanged()).catch((err) => {
|
|
7169
|
+
this._ctx?.logger?.error?.("re-resolving secrets failed", { meta: { error: err instanceof Error ? err.message : String(err) } });
|
|
7170
|
+
});
|
|
7171
|
+
}, delayMs);
|
|
7172
|
+
timer.unref?.();
|
|
7173
|
+
this[timerOf] = timer;
|
|
7174
|
+
}
|
|
6508
7175
|
/**
|
|
6509
7176
|
* Wrap `ctx.settings.readAddonStore()` with a short retry budget so a
|
|
6510
7177
|
* transient settings-store outage (mid-restart of sqlite-settings, tsx-watch
|
|
@@ -7114,6 +7781,69 @@ method(object({ deviceId: number() }), array(StreamSourceEntrySchema)), method(o
|
|
|
7114
7781
|
kind: "mutation",
|
|
7115
7782
|
auth: "admin"
|
|
7116
7783
|
}), method(object({ deviceId: number() }), unknown().nullable()), method(object({ deviceId: number() }), RawStateResultSchema.nullable(), { auth: "protected" });
|
|
7784
|
+
function defOf(schema) {
|
|
7785
|
+
return schema._zod?.def ?? {};
|
|
7786
|
+
}
|
|
7787
|
+
function declaredHere(schema) {
|
|
7788
|
+
return globalRegistry.get(schema)?.secret === true;
|
|
7789
|
+
}
|
|
7790
|
+
/** Wrapper kinds whose `innerType` is the field itself. */
|
|
7791
|
+
var WRAPPERS = new Set([
|
|
7792
|
+
"optional",
|
|
7793
|
+
"nullable",
|
|
7794
|
+
"default",
|
|
7795
|
+
"prefault",
|
|
7796
|
+
"catch",
|
|
7797
|
+
"readonly",
|
|
7798
|
+
"nonoptional"
|
|
7799
|
+
]);
|
|
7800
|
+
/**
|
|
7801
|
+
* The schema layers that make up ONE field: the schema itself and every
|
|
7802
|
+
* wrapper below it (optional / default / nullable / readonly / catch), plus
|
|
7803
|
+
* both sides of a pipe (`z.preprocess` puts the real schema on `out`,
|
|
7804
|
+
* `.transform` on `in`).
|
|
7805
|
+
*/
|
|
7806
|
+
function layersOf(schema) {
|
|
7807
|
+
const out = [];
|
|
7808
|
+
const queue = [schema];
|
|
7809
|
+
while (queue.length > 0) {
|
|
7810
|
+
const s = queue.shift();
|
|
7811
|
+
if (!s || out.includes(s)) continue;
|
|
7812
|
+
out.push(s);
|
|
7813
|
+
const def = defOf(s);
|
|
7814
|
+
if (def.type !== void 0 && WRAPPERS.has(def.type) && def.innerType) queue.push(def.innerType);
|
|
7815
|
+
if (def.type === "pipe") {
|
|
7816
|
+
if (def.in) queue.push(def.in);
|
|
7817
|
+
if (def.out) queue.push(def.out);
|
|
7818
|
+
}
|
|
7819
|
+
}
|
|
7820
|
+
return out;
|
|
7821
|
+
}
|
|
7822
|
+
/** True when any layer of this field declares `.meta({ secret: true })`. */
|
|
7823
|
+
function isZodSecret(schema) {
|
|
7824
|
+
return layersOf(schema).some(declaredHere);
|
|
7825
|
+
}
|
|
7826
|
+
/**
|
|
7827
|
+
* Every declared secret path in a config schema: dotted keys, `[]` for "each
|
|
7828
|
+
* element of this array" (`connection.password`, `rows[].token`). A declared
|
|
7829
|
+
* object or array is reported as one path and not descended into — everything
|
|
7830
|
+
* under it is secret.
|
|
7831
|
+
*/
|
|
7832
|
+
function collectZodSecretPaths(schema, prefix = "") {
|
|
7833
|
+
if (isZodSecret(schema)) return prefix.length > 0 ? [prefix] : [];
|
|
7834
|
+
const paths = [];
|
|
7835
|
+
for (const layer of layersOf(schema)) {
|
|
7836
|
+
const def = defOf(layer);
|
|
7837
|
+
if (def.type === "object" && def.shape) for (const [key, child] of Object.entries(def.shape)) paths.push(...collectZodSecretPaths(child, prefix ? `${prefix}.${key}` : key));
|
|
7838
|
+
else if (def.type === "array" && def.element) paths.push(...collectZodSecretPaths(def.element, `${prefix}[]`));
|
|
7839
|
+
else if (def.type === "union" && def.options) for (const option of def.options) paths.push(...collectZodSecretPaths(option, prefix));
|
|
7840
|
+
else if (def.type === "intersection") {
|
|
7841
|
+
if (def.left) paths.push(...collectZodSecretPaths(def.left, prefix));
|
|
7842
|
+
if (def.right) paths.push(...collectZodSecretPaths(def.right, prefix));
|
|
7843
|
+
}
|
|
7844
|
+
}
|
|
7845
|
+
return [...new Set(paths)];
|
|
7846
|
+
}
|
|
7117
7847
|
/**
|
|
7118
7848
|
* Promise-based timer helpers — used everywhere the codebase needs to
|
|
7119
7849
|
* wait, back off, or schedule a retry. Before these helpers landed, each
|
|
@@ -14710,6 +15440,196 @@ id: union([string(), number()]) }), {
|
|
|
14710
15440
|
kind: "mutation",
|
|
14711
15441
|
auth: "admin"
|
|
14712
15442
|
});
|
|
15443
|
+
/**
|
|
15444
|
+
* `keychain` — the hub's encrypted store of secret values (D787).
|
|
15445
|
+
*
|
|
15446
|
+
* Settings blobs never hold a secret: they hold a marker
|
|
15447
|
+
* `{"$secret":"secret://<owner>/<scope>/<fieldPath>","v":1}` and the value
|
|
15448
|
+
* lives here, AES-256-GCM under a data key that a master key wraps. This cap
|
|
15449
|
+
* is the OWNER's door to its own values: every method is owner-checked
|
|
15450
|
+
* against the CALLER, never against anything the caller claims.
|
|
15451
|
+
*
|
|
15452
|
+
* Who the caller is: the transport stamps `callerAddonId` into the args of a
|
|
15453
|
+
* call that crossed a process (the parent `LocalChildRegistry` from the UDS
|
|
15454
|
+
* connection, the agent from its child's connection carried in
|
|
15455
|
+
* `$hub-cap-fwd`'s envelope). A stamp always overwrites; a wire call with no
|
|
15456
|
+
* stamp has its claim stripped. Only a hub in-process caller may state its own
|
|
15457
|
+
* identity — `ctx.secrets` does that with the addon id closed over. This is
|
|
15458
|
+
* identity against BUGS and misrouting, not against a malicious addon (every
|
|
15459
|
+
* runner is the same OS user): see the threat model in
|
|
15460
|
+
* `docs/design/2026-10-08-secrets-keychain.md`.
|
|
15461
|
+
*
|
|
15462
|
+
* `callerAddonId` is deliberately NOT in any input schema: the tRPC router
|
|
15463
|
+
* parses the input, so a session can never supply it, and the internal mount
|
|
15464
|
+
* floors every method to admin anyway (D240).
|
|
15465
|
+
*
|
|
15466
|
+
* Internal: addons reach it through `ctx.secrets`, never directly.
|
|
15467
|
+
*/
|
|
15468
|
+
/** Why a value cannot be served right now. Never folded into "missing". */
|
|
15469
|
+
var KeychainUnavailableReasonSchema = _enum([
|
|
15470
|
+
"key-missing",
|
|
15471
|
+
"wrong-key",
|
|
15472
|
+
"key-file-unreadable",
|
|
15473
|
+
"store-unavailable",
|
|
15474
|
+
"not-initialized",
|
|
15475
|
+
"decrypt-failed"
|
|
15476
|
+
]);
|
|
15477
|
+
var KeychainStateSchema = discriminatedUnion("state", [object({ state: literal("ready") }), object({
|
|
15478
|
+
state: literal("locked"),
|
|
15479
|
+
reason: KeychainUnavailableReasonSchema
|
|
15480
|
+
})]);
|
|
15481
|
+
var KeychainResolveEntrySchema = discriminatedUnion("kind", [
|
|
15482
|
+
object({
|
|
15483
|
+
kind: literal("value"),
|
|
15484
|
+
value: string(),
|
|
15485
|
+
version: number().int()
|
|
15486
|
+
}),
|
|
15487
|
+
object({ kind: literal("missing") }),
|
|
15488
|
+
object({
|
|
15489
|
+
kind: literal("unavailable"),
|
|
15490
|
+
reason: KeychainUnavailableReasonSchema
|
|
15491
|
+
}),
|
|
15492
|
+
object({ kind: literal("forbidden") })
|
|
15493
|
+
]);
|
|
15494
|
+
var KeychainResolveResultSchema = record(string(), KeychainResolveEntrySchema);
|
|
15495
|
+
/** Metadata of one stored value — never the value. */
|
|
15496
|
+
var KeychainSecretMetaSchema = object({
|
|
15497
|
+
ref: string(),
|
|
15498
|
+
owner: string(),
|
|
15499
|
+
/** Formatted scope (`global`, `node/<id>`, `device/<id>`, …). */
|
|
15500
|
+
scope: string(),
|
|
15501
|
+
fieldPath: string(),
|
|
15502
|
+
version: number().int(),
|
|
15503
|
+
createdAt: number(),
|
|
15504
|
+
updatedAt: number(),
|
|
15505
|
+
/** `addon:<id>` | `user:<id>` | `system`. */
|
|
15506
|
+
updatedBy: string(),
|
|
15507
|
+
/** Coarse — written at most once an hour per ref. `null` = never read. */
|
|
15508
|
+
lastReadAt: number().nullable()
|
|
15509
|
+
});
|
|
15510
|
+
var RefListSchema = array(string().min(1)).max(512);
|
|
15511
|
+
method(object({
|
|
15512
|
+
ref: string().min(1),
|
|
15513
|
+
value: string().min(1)
|
|
15514
|
+
}), object({
|
|
15515
|
+
ref: string(),
|
|
15516
|
+
version: number().int()
|
|
15517
|
+
}), {
|
|
15518
|
+
kind: "mutation",
|
|
15519
|
+
auth: "admin"
|
|
15520
|
+
}), method(object({ refs: RefListSchema }), KeychainResolveResultSchema, { auth: "admin" }), method(object({ refs: RefListSchema }), object({ deleted: number().int() }), {
|
|
15521
|
+
kind: "mutation",
|
|
15522
|
+
auth: "admin"
|
|
15523
|
+
}), method(object({}), array(KeychainSecretMetaSchema).readonly(), { auth: "admin" }), method(object({}), KeychainStateSchema, { auth: "admin" });
|
|
15524
|
+
var KeychainKeySourceSchema = object({
|
|
15525
|
+
kind: _enum([
|
|
15526
|
+
"config-file",
|
|
15527
|
+
"previous-config-file",
|
|
15528
|
+
"platform",
|
|
15529
|
+
"default-file"
|
|
15530
|
+
]),
|
|
15531
|
+
/** File sources only — a path is not a secret. */
|
|
15532
|
+
path: string().optional(),
|
|
15533
|
+
/**
|
|
15534
|
+
* True when a whole-volume backup of the data directory carries this key
|
|
15535
|
+
* next to the database it protects (the default file). The page warns.
|
|
15536
|
+
*/
|
|
15537
|
+
sharesBackupWithDatabase: boolean()
|
|
15538
|
+
});
|
|
15539
|
+
var KeychainStatusSchema = object({
|
|
15540
|
+
keychain: KeychainStateSchema,
|
|
15541
|
+
/** The source of the master key in use; `null` while locked. */
|
|
15542
|
+
keySource: KeychainKeySourceSchema.nullable(),
|
|
15543
|
+
/** The source configured to be primary — differs from `keySource` while a rotation is pending. */
|
|
15544
|
+
configuredSource: KeychainKeySourceSchema,
|
|
15545
|
+
/** Short fingerprint of the master key in use (`HMAC(KEK, label)`, 16 hex). */
|
|
15546
|
+
fingerprint: string().nullable(),
|
|
15547
|
+
activeKeyId: string().nullable(),
|
|
15548
|
+
/**
|
|
15549
|
+
* The keychain unlocked with a NON-primary source: the configured primary
|
|
15550
|
+
* key is not the one that wraps the data key yet. `rotateMasterKey` moves it.
|
|
15551
|
+
*/
|
|
15552
|
+
rotationPending: boolean(),
|
|
15553
|
+
/** Wrapped copies of the data key under a previous master key, kept until purged. */
|
|
15554
|
+
retiredWraps: number().int(),
|
|
15555
|
+
recoveryKeyDownloadedAt: number().nullable(),
|
|
15556
|
+
secretCount: number().int()
|
|
15557
|
+
});
|
|
15558
|
+
/**
|
|
15559
|
+
* Whether a stored value is still pointed at by its owner's settings.
|
|
15560
|
+
* `unknown` is a first-class answer: a scope whose blob could not be read is
|
|
15561
|
+
* never reported as an orphan (and never deleted as one).
|
|
15562
|
+
*/
|
|
15563
|
+
var KeychainSecretUsageSchema = _enum([
|
|
15564
|
+
"in-use",
|
|
15565
|
+
"orphan",
|
|
15566
|
+
"unknown"
|
|
15567
|
+
]);
|
|
15568
|
+
var KeychainAdminSecretSchema = KeychainSecretMetaSchema.extend({ usage: KeychainSecretUsageSchema });
|
|
15569
|
+
var KeychainAuditActionSchema = _enum([
|
|
15570
|
+
"put",
|
|
15571
|
+
"delete",
|
|
15572
|
+
"reveal",
|
|
15573
|
+
"rotate-master-key",
|
|
15574
|
+
"purge-retired-keys",
|
|
15575
|
+
"download-recovery-key",
|
|
15576
|
+
"delete-orphans",
|
|
15577
|
+
"reset",
|
|
15578
|
+
"initialize"
|
|
15579
|
+
]);
|
|
15580
|
+
var KeychainAuditEntrySchema = object({
|
|
15581
|
+
id: string(),
|
|
15582
|
+
at: number(),
|
|
15583
|
+
action: KeychainAuditActionSchema,
|
|
15584
|
+
/** `addon:<id>` | `user:<id>` | `system`. */
|
|
15585
|
+
actor: string(),
|
|
15586
|
+
ref: string().nullable(),
|
|
15587
|
+
detail: string().nullable()
|
|
15588
|
+
});
|
|
15589
|
+
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({
|
|
15590
|
+
value: string(),
|
|
15591
|
+
version: number().int()
|
|
15592
|
+
}), {
|
|
15593
|
+
kind: "mutation",
|
|
15594
|
+
auth: "admin",
|
|
15595
|
+
caller: "required"
|
|
15596
|
+
}), method(object({ refs: array(string().min(1)).max(1e3) }), object({
|
|
15597
|
+
deleted: array(string()).readonly(),
|
|
15598
|
+
kept: array(object({
|
|
15599
|
+
ref: string(),
|
|
15600
|
+
usage: KeychainSecretUsageSchema
|
|
15601
|
+
})).readonly()
|
|
15602
|
+
}), {
|
|
15603
|
+
kind: "mutation",
|
|
15604
|
+
auth: "admin",
|
|
15605
|
+
caller: "required"
|
|
15606
|
+
}), method(object({}), object({
|
|
15607
|
+
fingerprint: string(),
|
|
15608
|
+
keySource: KeychainKeySourceSchema
|
|
15609
|
+
}), {
|
|
15610
|
+
kind: "mutation",
|
|
15611
|
+
auth: "admin",
|
|
15612
|
+
caller: "required"
|
|
15613
|
+
}), method(object({}), object({ purged: number().int() }), {
|
|
15614
|
+
kind: "mutation",
|
|
15615
|
+
auth: "admin",
|
|
15616
|
+
caller: "required"
|
|
15617
|
+
}), method(object({}), object({
|
|
15618
|
+
key: string(),
|
|
15619
|
+
fingerprint: string(),
|
|
15620
|
+
keySource: KeychainKeySourceSchema
|
|
15621
|
+
}), {
|
|
15622
|
+
kind: "mutation",
|
|
15623
|
+
auth: "admin",
|
|
15624
|
+
caller: "required"
|
|
15625
|
+
}), method(object({ confirm: literal("RESET KEYCHAIN") }), object({
|
|
15626
|
+
archivedCollection: string().nullable(),
|
|
15627
|
+
archived: number().int()
|
|
15628
|
+
}), {
|
|
15629
|
+
kind: "mutation",
|
|
15630
|
+
auth: "admin",
|
|
15631
|
+
caller: "required"
|
|
15632
|
+
});
|
|
14713
15633
|
method(_void(), object({
|
|
14714
15634
|
id: string(),
|
|
14715
15635
|
name: string(),
|
|
@@ -16048,7 +16968,11 @@ var DeviceRegisterPayloadSchema = object({
|
|
|
16048
16968
|
var DeviceRemovePayloadSchema = object({ deviceId: number() });
|
|
16049
16969
|
var DevicePersistConfigPayloadSchema = object({
|
|
16050
16970
|
deviceId: number(),
|
|
16051
|
-
data: record(string(), unknown())
|
|
16971
|
+
data: record(string(), unknown()),
|
|
16972
|
+
/** The paths the device's schema declares secret (D783), when the caller
|
|
16973
|
+
* knows them — those values are kept in the keychain, not the blob (D787).
|
|
16974
|
+
* Absent: the paths the device last reported at `registerDevice` apply. */
|
|
16975
|
+
secretConfigPaths: array(string()).optional()
|
|
16052
16976
|
});
|
|
16053
16977
|
/** What a migration actually did, per switch. `unreachable` is a first-class
|
|
16054
16978
|
* answer: a camera that could not be asked is not a camera that was silenced. */
|
|
@@ -23105,8 +24029,23 @@ var RetrainMacroClassSchema = _enum([
|
|
|
23105
24029
|
]);
|
|
23106
24030
|
/** A subject to learn, or a phantom to unlearn (taught by OMISSION). */
|
|
23107
24031
|
var RetrainAnnotationKindSchema = _enum(["subject", "model_error"]);
|
|
23108
|
-
/**
|
|
23109
|
-
|
|
24032
|
+
/**
|
|
24033
|
+
* Where a box came from. A machine-sourced box is a DRAFT on the page until
|
|
24034
|
+
* the operator confirms it; once saved it keeps its source as provenance.
|
|
24035
|
+
*
|
|
24036
|
+
* - `operator` — drawn by hand.
|
|
24037
|
+
* - `assist` — proposed by a detector run on the copy (the camera's own
|
|
24038
|
+
* model, or a larger teacher model).
|
|
24039
|
+
* - `pipeline` — the box the live pipeline actually drew on that frame, read
|
|
24040
|
+
* back from the track store (never a re-run).
|
|
24041
|
+
* - `llm` — proposed by a vision-capable LLM profile.
|
|
24042
|
+
*/
|
|
24043
|
+
var RetrainAnnotationSourceSchema = _enum([
|
|
24044
|
+
"operator",
|
|
24045
|
+
"assist",
|
|
24046
|
+
"pipeline",
|
|
24047
|
+
"llm"
|
|
24048
|
+
]);
|
|
23110
24049
|
/** Normalised `[0,1]` rectangle against the FULL frame — the canonical form. */
|
|
23111
24050
|
var RetrainBboxSchema = object({
|
|
23112
24051
|
x: number(),
|
|
@@ -23124,7 +24063,8 @@ var RetrainBboxSchema = object({
|
|
|
23124
24063
|
*/
|
|
23125
24064
|
var RetrainAnnotationSchema = object({
|
|
23126
24065
|
id: string(),
|
|
23127
|
-
|
|
24066
|
+
/** The frame's track. Absent on a recording still, which has none. */
|
|
24067
|
+
trackId: string().optional(),
|
|
23128
24068
|
deviceId: number(),
|
|
23129
24069
|
/** The COPY in retrain storage — never the source track's media key. */
|
|
23130
24070
|
mediaKey: string(),
|
|
@@ -23173,13 +24113,47 @@ var RetrainFrameCandidateSchema = object({
|
|
|
23173
24113
|
* fail, whatever became of the original. */
|
|
23174
24114
|
copied: boolean()
|
|
23175
24115
|
});
|
|
24116
|
+
/**
|
|
24117
|
+
* One box the live pipeline drew on a copied frame — what a correction starts
|
|
24118
|
+
* from. Derived when the frame is listed, from the track store: the subject
|
|
24119
|
+
* box recorded on the source media row when there is one, else the track
|
|
24120
|
+
* position nearest the frame's capture time. Never stored as an annotation
|
|
24121
|
+
* until the operator confirms it.
|
|
24122
|
+
*/
|
|
24123
|
+
var RetrainPipelineBoxSchema = object({
|
|
24124
|
+
/** Normalised `[0,1]` against the full frame. */
|
|
24125
|
+
bbox: RetrainBboxSchema,
|
|
24126
|
+
macroClass: RetrainMacroClassSchema,
|
|
24127
|
+
label: string().optional(),
|
|
24128
|
+
subLabel: string().optional(),
|
|
24129
|
+
/** The detection score of the position used, when it was recorded. */
|
|
24130
|
+
score: number().optional(),
|
|
24131
|
+
/** The root model that produced the track, when it was recorded. */
|
|
24132
|
+
modelId: string().optional(),
|
|
24133
|
+
trackId: string(),
|
|
24134
|
+
/** `subject-box`: recorded on this very frame. `position`: the track's
|
|
24135
|
+
* position nearest the capture time, `deltaMs` away. */
|
|
24136
|
+
basis: _enum(["subject-box", "position"]),
|
|
24137
|
+
deltaMs: number()
|
|
24138
|
+
});
|
|
24139
|
+
/**
|
|
24140
|
+
* Where a retrain frame came from: a TRACK's stored media (copy-on-select),
|
|
24141
|
+
* or the RECORDING at an instant — the frame a model saw nothing in has no
|
|
24142
|
+
* track at all.
|
|
24143
|
+
*/
|
|
24144
|
+
var RetrainFrameOriginSchema = _enum(["track", "recording"]);
|
|
23176
24145
|
/** A frame the dataset OWNS: bytes copied at selection time. */
|
|
23177
24146
|
var RetrainFrameSchema = object({
|
|
23178
24147
|
frameId: string(),
|
|
23179
24148
|
deviceId: number(),
|
|
23180
|
-
|
|
23181
|
-
/**
|
|
23182
|
-
|
|
24149
|
+
origin: RetrainFrameOriginSchema,
|
|
24150
|
+
/** The track it was copied from. Absent on a recording still. */
|
|
24151
|
+
trackId: string().optional(),
|
|
24152
|
+
/** Provenance only. It may already point at nothing — that is expected.
|
|
24153
|
+
* Absent on a recording still. */
|
|
24154
|
+
sourceMediaId: number().int().optional(),
|
|
24155
|
+
/** A recording still: the playhead instant it was taken at. */
|
|
24156
|
+
epochMs: number().optional(),
|
|
23183
24157
|
sourceKind: MediaFileKindEnum,
|
|
23184
24158
|
sizeBytes: number().int(),
|
|
23185
24159
|
width: number().int(),
|
|
@@ -23190,7 +24164,12 @@ var RetrainFrameSchema = object({
|
|
|
23190
24164
|
/** The operator's "every subject in this frame is boxed". Detector
|
|
23191
24165
|
* evaluation keeps only complete frames: an unboxed subject would count as
|
|
23192
24166
|
* a false positive. */
|
|
23193
|
-
complete: boolean()
|
|
24167
|
+
complete: boolean(),
|
|
24168
|
+
/** The boxes the pipeline drew on this frame. Present on list answers;
|
|
24169
|
+
* empty when nothing the track store holds can be placed on it. */
|
|
24170
|
+
pipelineBoxes: array(RetrainPipelineBoxSchema).readonly().optional(),
|
|
24171
|
+
/** The named collections this frame belongs to. Present on list answers. */
|
|
24172
|
+
collectionIds: array(string()).readonly().optional()
|
|
23194
24173
|
});
|
|
23195
24174
|
/** Why a copy-on-select could not be honoured — named, never a silent skip. */
|
|
23196
24175
|
var RetrainCopyRefusalSchema = _enum([
|
|
@@ -23221,6 +24200,8 @@ var RetrainFrameListSchema = object({
|
|
|
23221
24200
|
var RetrainExportFilterSchema = object({
|
|
23222
24201
|
deviceIds: array(number()).optional(),
|
|
23223
24202
|
frameIds: array(string()).max(2e4).optional(),
|
|
24203
|
+
/** Only frames in at least one of these named collections. */
|
|
24204
|
+
collectionIds: array(string()).max(200).optional(),
|
|
23224
24205
|
batchId: string().optional(),
|
|
23225
24206
|
/** Only frames the operator marked complete (all subjects boxed). */
|
|
23226
24207
|
completeOnly: boolean().optional()
|
|
@@ -23285,6 +24266,109 @@ var RetrainAssistResultSchema = discriminatedUnion("kind", [object({
|
|
|
23285
24266
|
reason: string(),
|
|
23286
24267
|
detail: string().optional()
|
|
23287
24268
|
})]);
|
|
24269
|
+
/** A named set over the retrain corpus — membership only, it owns no pixels. */
|
|
24270
|
+
var RetrainCollectionSchema = object({
|
|
24271
|
+
id: string(),
|
|
24272
|
+
name: string(),
|
|
24273
|
+
createdAt: number(),
|
|
24274
|
+
frameCount: number().int()
|
|
24275
|
+
});
|
|
24276
|
+
var RetrainCollectionCreateResultSchema = discriminatedUnion("kind", [object({
|
|
24277
|
+
kind: literal("created"),
|
|
24278
|
+
collection: RetrainCollectionSchema
|
|
24279
|
+
}), object({
|
|
24280
|
+
kind: literal("refused"),
|
|
24281
|
+
reason: _enum(["empty-name", "duplicate-name"])
|
|
24282
|
+
})]);
|
|
24283
|
+
var RetrainCollectionRenameResultSchema = discriminatedUnion("kind", [object({
|
|
24284
|
+
kind: literal("renamed"),
|
|
24285
|
+
collection: RetrainCollectionSchema
|
|
24286
|
+
}), object({
|
|
24287
|
+
kind: literal("refused"),
|
|
24288
|
+
reason: _enum([
|
|
24289
|
+
"empty-name",
|
|
24290
|
+
"duplicate-name",
|
|
24291
|
+
"unknown-collection"
|
|
24292
|
+
])
|
|
24293
|
+
})]);
|
|
24294
|
+
/**
|
|
24295
|
+
* The outcome of adding the frame at a recording instant. Every refusal is
|
|
24296
|
+
* named: `still-unavailable` (not recording, a gap, or an undecodable frame —
|
|
24297
|
+
* `detail` says which), `still-busy` (the recorder is at its decode bound; try
|
|
24298
|
+
* again), `unreadable-image`, `write-failed`, `unknown-collection`.
|
|
24299
|
+
*/
|
|
24300
|
+
var AddRetrainFrameFromRecordingResultSchema = discriminatedUnion("kind", [object({
|
|
24301
|
+
kind: literal("added"),
|
|
24302
|
+
collectionId: string(),
|
|
24303
|
+
frame: RetrainFrameSchema,
|
|
24304
|
+
/** The moment was already in the dataset; nothing was decoded. */
|
|
24305
|
+
reused: boolean()
|
|
24306
|
+
}), object({
|
|
24307
|
+
kind: literal("refused"),
|
|
24308
|
+
reason: _enum([
|
|
24309
|
+
"unknown-collection",
|
|
24310
|
+
"still-unavailable",
|
|
24311
|
+
"still-busy",
|
|
24312
|
+
"unreadable-image",
|
|
24313
|
+
"write-failed"
|
|
24314
|
+
]),
|
|
24315
|
+
detail: string().optional()
|
|
24316
|
+
})]);
|
|
24317
|
+
/** A vision LLM profile the AI assist may use, and where it sends the frame. */
|
|
24318
|
+
var RetrainAssistProfileSchema = object({
|
|
24319
|
+
id: string(),
|
|
24320
|
+
name: string(),
|
|
24321
|
+
model: string(),
|
|
24322
|
+
kind: string(),
|
|
24323
|
+
/** `true` when the frame would leave the house (a cloud vendor, or an
|
|
24324
|
+
* endpoint that is not on the local network). The page confirms each such
|
|
24325
|
+
* run, and the provider refuses one without `allowCloud`. */
|
|
24326
|
+
leavesHouse: boolean()
|
|
24327
|
+
});
|
|
24328
|
+
/** A box the AI assist proposed: a draft, plus the model's own reason. */
|
|
24329
|
+
var RetrainLlmProposalSchema = RetrainAnnotationDraftSchema.extend({ reason: string() });
|
|
24330
|
+
/** What the AI assist said about a box that was already on the canvas. */
|
|
24331
|
+
var RetrainLlmReviewSchema = object({
|
|
24332
|
+
/** The `ref` the page sent the box under. */
|
|
24333
|
+
ref: string(),
|
|
24334
|
+
verdict: _enum([
|
|
24335
|
+
"confirmed",
|
|
24336
|
+
"wrong-class",
|
|
24337
|
+
"not-an-object",
|
|
24338
|
+
"uncertain"
|
|
24339
|
+
]),
|
|
24340
|
+
suggestedClass: RetrainMacroClassSchema.optional(),
|
|
24341
|
+
reason: string()
|
|
24342
|
+
});
|
|
24343
|
+
/**
|
|
24344
|
+
* The AI assist's answer. `proposed` carries drafts (`source: 'llm'`, the
|
|
24345
|
+
* model and its confidence) and reviews; items the model got wrong (a box off
|
|
24346
|
+
* the frame, an unasked class, an unknown ref) are dropped and counted in
|
|
24347
|
+
* `rejected`. A whole answer that is not the schema is `malformed-answer`.
|
|
24348
|
+
*/
|
|
24349
|
+
var RetrainLlmAssistResultSchema = discriminatedUnion("kind", [object({
|
|
24350
|
+
kind: literal("proposed"),
|
|
24351
|
+
profileId: string(),
|
|
24352
|
+
model: string(),
|
|
24353
|
+
/** The frame was sent outside the house for this answer. */
|
|
24354
|
+
leftHouse: boolean(),
|
|
24355
|
+
proposals: array(RetrainLlmProposalSchema).readonly(),
|
|
24356
|
+
reviews: array(RetrainLlmReviewSchema).readonly(),
|
|
24357
|
+
rejected: number().int()
|
|
24358
|
+
}), object({
|
|
24359
|
+
kind: literal("refused"),
|
|
24360
|
+
reason: _enum([
|
|
24361
|
+
"unknown-frame",
|
|
24362
|
+
"unreadable-frame",
|
|
24363
|
+
"unknown-profile",
|
|
24364
|
+
"profile-disabled",
|
|
24365
|
+
"no-vision",
|
|
24366
|
+
"cloud-not-confirmed",
|
|
24367
|
+
"llm-error",
|
|
24368
|
+
"malformed-answer"
|
|
24369
|
+
]),
|
|
24370
|
+
detail: string().optional()
|
|
24371
|
+
})]);
|
|
23288
24372
|
/** The outcome of a lifecycle move owned by the retrain page. */
|
|
23289
24373
|
var RetrainTransitionResultSchema = object({
|
|
23290
24374
|
trackId: string(),
|
|
@@ -24002,7 +25086,7 @@ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).rea
|
|
|
24002
25086
|
auth: "admin"
|
|
24003
25087
|
}), method(object({
|
|
24004
25088
|
deviceId: number(),
|
|
24005
|
-
trackId: string(),
|
|
25089
|
+
trackId: string().optional(),
|
|
24006
25090
|
frameId: string()
|
|
24007
25091
|
}), object({
|
|
24008
25092
|
removed: boolean(),
|
|
@@ -24019,7 +25103,8 @@ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).rea
|
|
|
24019
25103
|
auth: "admin"
|
|
24020
25104
|
}), method(object({
|
|
24021
25105
|
deviceId: number(),
|
|
24022
|
-
|
|
25106
|
+
/** The frame's track, when it has one — checked against the frame. */
|
|
25107
|
+
trackId: string().optional(),
|
|
24023
25108
|
frameId: string(),
|
|
24024
25109
|
subject: RetrainAssistSubjectSchema,
|
|
24025
25110
|
/** Which node runs it. Absent ⇒ wherever an unowned call lands. */
|
|
@@ -24027,12 +25112,16 @@ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).rea
|
|
|
24027
25112
|
}), RetrainAssistResultSchema, {
|
|
24028
25113
|
kind: "mutation",
|
|
24029
25114
|
auth: "admin"
|
|
24030
|
-
}), method(object({
|
|
25115
|
+
}), method(object({
|
|
25116
|
+
trackId: string().optional(),
|
|
25117
|
+
frameIds: array(string()).max(2e3).optional()
|
|
25118
|
+
}), array(RetrainAnnotationSchema).readonly(), {
|
|
24031
25119
|
kind: "query",
|
|
24032
25120
|
auth: "admin"
|
|
24033
25121
|
}), method(object({
|
|
24034
25122
|
deviceId: number(),
|
|
24035
|
-
|
|
25123
|
+
/** The frame's track, when it has one — checked against the frame. */
|
|
25124
|
+
trackId: string().optional(),
|
|
24036
25125
|
frameId: string(),
|
|
24037
25126
|
annotations: array(RetrainAnnotationDraftSchema)
|
|
24038
25127
|
}), array(RetrainAnnotationSchema).readonly(), {
|
|
@@ -24055,7 +25144,7 @@ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).rea
|
|
|
24055
25144
|
auth: "admin"
|
|
24056
25145
|
}), method(object({
|
|
24057
25146
|
deviceId: number(),
|
|
24058
|
-
trackId: string(),
|
|
25147
|
+
trackId: string().optional(),
|
|
24059
25148
|
frameId: string(),
|
|
24060
25149
|
complete: boolean()
|
|
24061
25150
|
}), RetrainFrameSchema, {
|
|
@@ -24069,6 +25158,74 @@ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).rea
|
|
|
24069
25158
|
kind: "mutation",
|
|
24070
25159
|
auth: "admin",
|
|
24071
25160
|
timeoutMs: 60 * 6e4
|
|
25161
|
+
}), method(object({}), array(RetrainAssistProfileSchema).readonly(), {
|
|
25162
|
+
kind: "query",
|
|
25163
|
+
auth: "admin"
|
|
25164
|
+
}), method(object({
|
|
25165
|
+
deviceId: number(),
|
|
25166
|
+
trackId: string().optional(),
|
|
25167
|
+
frameId: string(),
|
|
25168
|
+
profileId: string(),
|
|
25169
|
+
classes: array(RetrainMacroClassSchema).min(1),
|
|
25170
|
+
boxes: array(object({
|
|
25171
|
+
ref: string(),
|
|
25172
|
+
bbox: RetrainBboxSchema,
|
|
25173
|
+
macroClass: RetrainMacroClassSchema,
|
|
25174
|
+
label: string().optional()
|
|
25175
|
+
})).max(50),
|
|
25176
|
+
allowCloud: boolean()
|
|
25177
|
+
}), RetrainLlmAssistResultSchema, {
|
|
25178
|
+
kind: "mutation",
|
|
25179
|
+
auth: "admin",
|
|
25180
|
+
timeoutMs: 18e4
|
|
25181
|
+
}), method(object({ name: string().max(120) }), RetrainCollectionCreateResultSchema, {
|
|
25182
|
+
kind: "mutation",
|
|
25183
|
+
auth: "admin"
|
|
25184
|
+
}), method(object({}), array(RetrainCollectionSchema).readonly(), {
|
|
25185
|
+
kind: "query",
|
|
25186
|
+
auth: "admin"
|
|
25187
|
+
}), method(object({
|
|
25188
|
+
id: string(),
|
|
25189
|
+
name: string().max(120)
|
|
25190
|
+
}), RetrainCollectionRenameResultSchema, {
|
|
25191
|
+
kind: "mutation",
|
|
25192
|
+
auth: "admin"
|
|
25193
|
+
}), method(object({ id: string() }), object({
|
|
25194
|
+
deleted: boolean(),
|
|
25195
|
+
removedFrames: number().int()
|
|
25196
|
+
}), {
|
|
25197
|
+
kind: "mutation",
|
|
25198
|
+
auth: "admin"
|
|
25199
|
+
}), method(object({
|
|
25200
|
+
collectionId: string(),
|
|
25201
|
+
deviceId: number(),
|
|
25202
|
+
epochMs: number()
|
|
25203
|
+
}), AddRetrainFrameFromRecordingResultSchema, {
|
|
25204
|
+
kind: "mutation",
|
|
25205
|
+
auth: "admin",
|
|
25206
|
+
timeoutMs: 6e4
|
|
25207
|
+
}), method(object({
|
|
25208
|
+
collectionId: string(),
|
|
25209
|
+
frameIds: array(string()).min(1).max(500)
|
|
25210
|
+
}), object({
|
|
25211
|
+
added: number().int(),
|
|
25212
|
+
alreadyMember: number().int(),
|
|
25213
|
+
unknownFrameIds: array(string()).readonly()
|
|
25214
|
+
}), {
|
|
25215
|
+
kind: "mutation",
|
|
25216
|
+
auth: "admin"
|
|
25217
|
+
}), method(object({
|
|
25218
|
+
collectionId: string(),
|
|
25219
|
+
frameId: string()
|
|
25220
|
+
}), object({
|
|
25221
|
+
removed: boolean(),
|
|
25222
|
+
deletedFrame: boolean()
|
|
25223
|
+
}), {
|
|
25224
|
+
kind: "mutation",
|
|
25225
|
+
auth: "admin"
|
|
25226
|
+
}), method(object({ collectionId: string() }), array(RetrainFrameSchema).readonly(), {
|
|
25227
|
+
kind: "query",
|
|
25228
|
+
auth: "admin"
|
|
24072
25229
|
}), method(object({
|
|
24073
25230
|
/** Which of the three event tables owns the row. */
|
|
24074
25231
|
ownerType: EventOwnerTypeSchema,
|
|
@@ -24692,13 +25849,31 @@ var RecommendationReasonSchema = discriminatedUnion("kind", [
|
|
|
24692
25849
|
object({
|
|
24693
25850
|
kind: literal("no-family-build"),
|
|
24694
25851
|
format: ModelFormatSchema$1
|
|
25852
|
+
}),
|
|
25853
|
+
object({
|
|
25854
|
+
kind: literal("kept-custom-pin"),
|
|
25855
|
+
modelId: string(),
|
|
25856
|
+
deviceKey: string()
|
|
24695
25857
|
})
|
|
24696
25858
|
]);
|
|
25859
|
+
/** Why a device is left exactly as it is, whatever the plan would pick (D786). */
|
|
25860
|
+
var KeptReasonSchema = _enum(["custom-pin"]);
|
|
25861
|
+
/**
|
|
25862
|
+
* Where a choice's latency came from (D791): this node's own benchmark
|
|
25863
|
+
* result, or the hardware-class table. Measured on the node beats the table.
|
|
25864
|
+
*/
|
|
25865
|
+
var LatencySourceSchema = discriminatedUnion("kind", [object({ kind: literal("table") }), object({
|
|
25866
|
+
kind: literal("node-benchmark"),
|
|
25867
|
+
resultId: string(),
|
|
25868
|
+
measuredAtMs: number()
|
|
25869
|
+
})]);
|
|
24697
25870
|
var DeviceModelChoiceSchema = object({
|
|
24698
25871
|
modelId: string(),
|
|
24699
25872
|
p50Ms: number(),
|
|
24700
25873
|
fps: number(),
|
|
24701
25874
|
measured: boolean(),
|
|
25875
|
+
/** Absent on a plan from before D791 — read as the table. */
|
|
25876
|
+
source: LatencySourceSchema.optional(),
|
|
24702
25877
|
/** Parallel sessions at the camera rate with the headroom kept free: ⌊fps × (1 − headroom) / camera fps⌋. */
|
|
24703
25878
|
capacitySessions: number(),
|
|
24704
25879
|
personRecall: number()
|
|
@@ -24709,6 +25884,8 @@ var DeviceRecommendationSchema = object({
|
|
|
24709
25884
|
enabled: boolean(),
|
|
24710
25885
|
available: boolean(),
|
|
24711
25886
|
chosen: DeviceModelChoiceSchema.nullable(),
|
|
25887
|
+
/** Present when the device is kept as is: Apply writes nothing on it. */
|
|
25888
|
+
kept: KeptReasonSchema.optional(),
|
|
24712
25889
|
reasons: array(RecommendationReasonSchema).readonly()
|
|
24713
25890
|
});
|
|
24714
25891
|
var NodeRecommendationSchema = object({
|
|
@@ -24762,6 +25939,17 @@ var AutoTuneWarningSchema = discriminatedUnion("kind", [
|
|
|
24762
25939
|
kind: literal("coral-enabled"),
|
|
24763
25940
|
nodeId: string(),
|
|
24764
25941
|
deviceKey: string()
|
|
25942
|
+
}),
|
|
25943
|
+
object({
|
|
25944
|
+
kind: literal("custom-pin-kept"),
|
|
25945
|
+
nodeId: string(),
|
|
25946
|
+
deviceKey: string().nullable(),
|
|
25947
|
+
deviceId: number().nullable(),
|
|
25948
|
+
modelId: string()
|
|
25949
|
+
}),
|
|
25950
|
+
object({
|
|
25951
|
+
kind: literal("custom-registry-unreadable"),
|
|
25952
|
+
error: string()
|
|
24765
25953
|
})
|
|
24766
25954
|
]);
|
|
24767
25955
|
var AutoTuneOptionsSchema = object({
|
|
@@ -24940,13 +26128,14 @@ var SuggestSharesResultSchema = object({
|
|
|
24940
26128
|
nodes: array(SuggestedNodeShareSchema).readonly()
|
|
24941
26129
|
});
|
|
24942
26130
|
/**
|
|
24943
|
-
* Where the node and device shares come from (D750, D755).
|
|
24944
|
-
* - `
|
|
24945
|
-
*
|
|
24946
|
-
*
|
|
24947
|
-
*
|
|
24948
|
-
*
|
|
24949
|
-
*
|
|
26131
|
+
* Where the node and device shares come from (D750, D755, D791).
|
|
26132
|
+
* - `benchmark` (default since D791) — each node's capacity as its own node
|
|
26133
|
+
* benchmark measured it; a node without fresh results is sized from
|
|
26134
|
+
* `hardware` and says so. Measured on the node beats the table.
|
|
26135
|
+
* - `hardware` — computed from each node's static capacity only (its
|
|
26136
|
+
* accelerators at their Auto tune models, from the latency table).
|
|
26137
|
+
* Both are recomputed whenever a node or device joins, leaves, is switched
|
|
26138
|
+
* on or off, changes model, or a benchmark result is written. No load input.
|
|
24950
26139
|
* - `manual` — the operator's stored sliders.
|
|
24951
26140
|
* Either way a node or device that cannot take sessions gives its share to
|
|
24952
26141
|
* the others in proportion; the stored values are never rewritten for that.
|
|
@@ -24995,6 +26184,362 @@ var EffectiveSharesSchema = object({
|
|
|
24995
26184
|
nodeWeights: record(string(), number()),
|
|
24996
26185
|
deviceWeights: record(string(), record(string(), number()))
|
|
24997
26186
|
});
|
|
26187
|
+
/**
|
|
26188
|
+
* Wire shapes of the node benchmark (D791): the operator's plan, the
|
|
26189
|
+
* preflight the confirmation shows, the run the orchestrator owns, what the
|
|
26190
|
+
* measuring runner reports, and the result rows Auto tune and the automatic
|
|
26191
|
+
* shares read.
|
|
26192
|
+
*
|
|
26193
|
+
* ONE node at a time, owned by the pipeline orchestrator. While a run is
|
|
26194
|
+
* active the cluster is in BENCHMARK MODE for that node: it is not a
|
|
26195
|
+
* detection candidate, camera pins naming it are ignored so its sessions move
|
|
26196
|
+
* elsewhere, and both come back when the mode ends — after a crash or a hub
|
|
26197
|
+
* restart too (a persisted manifest, reconciled against the registry).
|
|
26198
|
+
*
|
|
26199
|
+
* Two measurements, both on the node, driven by its own runner (frames never
|
|
26200
|
+
* cross a process at frame rate, D9):
|
|
26201
|
+
* - `device` — one accelerator × one candidate detector, root only, open
|
|
26202
|
+
* loop: how many streams at the camera rate it carries inside the frame
|
|
26203
|
+
* interval;
|
|
26204
|
+
* - `pipeline` — the chosen detector plus the operator's detail steps
|
|
26205
|
+
* (faces, plates, classifiers, CLIP…), on varied frames from the bench
|
|
26206
|
+
* clip: how many parallel sessions the node carries before latency, drops,
|
|
26207
|
+
* CPU, RAM or the event loop give out.
|
|
26208
|
+
*/
|
|
26209
|
+
/** Defaults and bounds, one place. */
|
|
26210
|
+
var NODE_BENCHMARK_DEFAULTS = {
|
|
26211
|
+
fpsPerStream: 10,
|
|
26212
|
+
budgetMinutes: 45,
|
|
26213
|
+
minBudgetMinutes: 10,
|
|
26214
|
+
maxBudgetMinutes: 120,
|
|
26215
|
+
/** A result older than this no longer beats the table. */
|
|
26216
|
+
staleAfterDays: 30,
|
|
26217
|
+
/** Warm-in per ramp step (not accounted). */
|
|
26218
|
+
settleSec: 5,
|
|
26219
|
+
/** Accounted window per ramp step. */
|
|
26220
|
+
measureSec: 20,
|
|
26221
|
+
/** Longest the drain may take before the run is refused. */
|
|
26222
|
+
drainTimeoutSec: 120,
|
|
26223
|
+
/** Candidate models per device in one run. */
|
|
26224
|
+
maxModelsPerDevice: 6
|
|
26225
|
+
};
|
|
26226
|
+
/** The two measurements a run can make. */
|
|
26227
|
+
var NodeBenchmarkPhaseSchema = _enum(["device", "pipeline"]);
|
|
26228
|
+
var NodeBenchmarkDevicePlanSchema = object({
|
|
26229
|
+
/** `<backend>:<device>` — `openvino:npu`, `coreml:all`, `cpu`. */
|
|
26230
|
+
deviceKey: string().min(1),
|
|
26231
|
+
/**
|
|
26232
|
+
* Root detector candidates for the `device` measurement, in the order
|
|
26233
|
+
* measured. The FIRST is the one the `pipeline` measurement runs.
|
|
26234
|
+
*/
|
|
26235
|
+
modelIds: array(string().min(1)).min(1).max(NODE_BENCHMARK_DEFAULTS.maxModelsPerDevice)
|
|
26236
|
+
});
|
|
26237
|
+
/** What the operator confirmed. */
|
|
26238
|
+
var NodeBenchmarkPlanSchema = object({
|
|
26239
|
+
nodeId: string().min(1),
|
|
26240
|
+
devices: array(NodeBenchmarkDevicePlanSchema).min(1),
|
|
26241
|
+
/** Which measurements run. At least one. */
|
|
26242
|
+
phases: array(NodeBenchmarkPhaseSchema).min(1).default(["device", "pipeline"]),
|
|
26243
|
+
/**
|
|
26244
|
+
* Detail steps (catalog step ids under the root: faces, plates,
|
|
26245
|
+
* classifiers, CLIP…) the `pipeline` measurement enables. The root
|
|
26246
|
+
* detector always runs.
|
|
26247
|
+
*/
|
|
26248
|
+
steps: array(string().min(1)).default([]),
|
|
26249
|
+
/** Offered rate of one stream / session. */
|
|
26250
|
+
fpsPerStream: number().int().min(1).max(30).default(NODE_BENCHMARK_DEFAULTS.fpsPerStream),
|
|
26251
|
+
/** Hard deadline: the mode ends and the cluster is restored when it passes. */
|
|
26252
|
+
budgetMinutes: number().int().min(NODE_BENCHMARK_DEFAULTS.minBudgetMinutes).max(NODE_BENCHMARK_DEFAULTS.maxBudgetMinutes).default(NODE_BENCHMARK_DEFAULTS.budgetMinutes),
|
|
26253
|
+
/** Keep the models the run downloaded (default: delete what was not installed before). */
|
|
26254
|
+
keepDownloadedModels: boolean().default(false),
|
|
26255
|
+
/** Start although the other nodes' capacity does not cover the sessions running now. */
|
|
26256
|
+
acceptInsufficientHeadroom: boolean().default(false)
|
|
26257
|
+
});
|
|
26258
|
+
var NodeBenchmarkRefusalSchema = object({
|
|
26259
|
+
kind: _enum([
|
|
26260
|
+
"benchmark-active",
|
|
26261
|
+
"node-offline",
|
|
26262
|
+
"unknown-device",
|
|
26263
|
+
"no-phase",
|
|
26264
|
+
"insufficient-headroom"
|
|
26265
|
+
]),
|
|
26266
|
+
detail: string(),
|
|
26267
|
+
overridable: boolean()
|
|
26268
|
+
});
|
|
26269
|
+
/** A camera whose detection leaves the node for the run. */
|
|
26270
|
+
var NodeBenchmarkMovingCameraSchema = object({
|
|
26271
|
+
deviceId: number(),
|
|
26272
|
+
/** Placed on the node now (a standing attach or a running session). */
|
|
26273
|
+
placedOnNode: boolean(),
|
|
26274
|
+
/** A node pin naming this node, ignored for the run. */
|
|
26275
|
+
pinnedToNode: boolean()
|
|
26276
|
+
});
|
|
26277
|
+
/** A camera that cannot leave: no other node can obtain its frames. */
|
|
26278
|
+
var NodeBenchmarkStayingCameraSchema = object({
|
|
26279
|
+
deviceId: number(),
|
|
26280
|
+
reason: literal("only-frame-source")
|
|
26281
|
+
});
|
|
26282
|
+
var NodeBenchmarkPreflightSchema = object({
|
|
26283
|
+
nodeId: string(),
|
|
26284
|
+
online: boolean(),
|
|
26285
|
+
moving: array(NodeBenchmarkMovingCameraSchema).readonly(),
|
|
26286
|
+
/** Keep running on the node during the run; the result is flagged contaminated. */
|
|
26287
|
+
staying: array(NodeBenchmarkStayingCameraSchema).readonly(),
|
|
26288
|
+
estimatedDurationMs: number(),
|
|
26289
|
+
/** The run ends and the cluster is restored at the latest after this long. */
|
|
26290
|
+
budgetMs: number(),
|
|
26291
|
+
phases: array(NodeBenchmarkPhaseSchema).readonly(),
|
|
26292
|
+
steps: array(string()).readonly(),
|
|
26293
|
+
devices: array(NodeBenchmarkDevicePlanSchema).readonly(),
|
|
26294
|
+
/** Parallel sessions the cluster runs now, and what the other nodes can carry. */
|
|
26295
|
+
headroom: object({
|
|
26296
|
+
sessionsNow: number(),
|
|
26297
|
+
otherNodesCapacitySessions: number().nullable()
|
|
26298
|
+
}),
|
|
26299
|
+
refusals: array(NodeBenchmarkRefusalSchema).readonly(),
|
|
26300
|
+
canStart: boolean()
|
|
26301
|
+
});
|
|
26302
|
+
/** Where the measuring runner is. */
|
|
26303
|
+
var NodeBenchProgressSchema = object({
|
|
26304
|
+
phase: _enum([
|
|
26305
|
+
"preparing",
|
|
26306
|
+
"device",
|
|
26307
|
+
"pipeline",
|
|
26308
|
+
"cleanup"
|
|
26309
|
+
]),
|
|
26310
|
+
deviceKey: string().nullable(),
|
|
26311
|
+
modelId: string().nullable(),
|
|
26312
|
+
/** Streams (device) or sessions (pipeline) of the step running now. */
|
|
26313
|
+
load: number().nullable(),
|
|
26314
|
+
cellsDone: number(),
|
|
26315
|
+
cellsTotal: number(),
|
|
26316
|
+
message: string()
|
|
26317
|
+
});
|
|
26318
|
+
/** What limited a ramp. `none` = the ramp ran out of steps still passing. */
|
|
26319
|
+
var NodeBenchLimitSchema = _enum([
|
|
26320
|
+
"p95",
|
|
26321
|
+
"drops",
|
|
26322
|
+
"errors",
|
|
26323
|
+
"stall",
|
|
26324
|
+
"cpu",
|
|
26325
|
+
"ram",
|
|
26326
|
+
"none"
|
|
26327
|
+
]);
|
|
26328
|
+
var NodeBenchRampStepSchema = object({
|
|
26329
|
+
load: number(),
|
|
26330
|
+
pass: boolean(),
|
|
26331
|
+
p95Ms: number(),
|
|
26332
|
+
dropRatio: number(),
|
|
26333
|
+
/** Completed frames per second over the accounted window. */
|
|
26334
|
+
fps: number(),
|
|
26335
|
+
cpuPct: number().nullable(),
|
|
26336
|
+
ramFreePct: number().nullable(),
|
|
26337
|
+
failReasons: array(string()).readonly()
|
|
26338
|
+
});
|
|
26339
|
+
var NodeBenchCellSchema = discriminatedUnion("phase", [object({
|
|
26340
|
+
phase: literal("device"),
|
|
26341
|
+
deviceKey: string(),
|
|
26342
|
+
modelId: string(),
|
|
26343
|
+
/** Single-stream latency (the K = 1 step). */
|
|
26344
|
+
p50Ms: number(),
|
|
26345
|
+
p95Ms: number(),
|
|
26346
|
+
p99Ms: number(),
|
|
26347
|
+
/** Frames per second sustained at the last passing step. */
|
|
26348
|
+
fps: number(),
|
|
26349
|
+
/** Streams at the camera rate the device carried inside the frame interval; 0 = not even one. */
|
|
26350
|
+
kMax: number(),
|
|
26351
|
+
limitedBy: NodeBenchLimitSchema,
|
|
26352
|
+
/** First call (model load + warm-up). */
|
|
26353
|
+
warmupMs: number(),
|
|
26354
|
+
ramp: array(NodeBenchRampStepSchema).readonly()
|
|
26355
|
+
}), object({
|
|
26356
|
+
phase: literal("pipeline"),
|
|
26357
|
+
deviceKey: string(),
|
|
26358
|
+
modelId: string(),
|
|
26359
|
+
steps: array(string()).readonly(),
|
|
26360
|
+
/** Parallel sessions at the camera rate the node carried; 0 = not even one. */
|
|
26361
|
+
maxSessions: number(),
|
|
26362
|
+
limitedBy: NodeBenchLimitSchema,
|
|
26363
|
+
/** Detail steps that produced at least one result on the clip — a step that never fired measured nothing. */
|
|
26364
|
+
stepsFired: array(string()).readonly(),
|
|
26365
|
+
warmupMs: number(),
|
|
26366
|
+
ramp: array(NodeBenchRampStepSchema).readonly()
|
|
26367
|
+
})]);
|
|
26368
|
+
/**
|
|
26369
|
+
* What a result was measured ON. A result whose fingerprint no longer matches
|
|
26370
|
+
* the node no longer beats the table.
|
|
26371
|
+
*/
|
|
26372
|
+
var NodeBenchFingerprintSchema = object({
|
|
26373
|
+
pipelineVersion: string().nullable(),
|
|
26374
|
+
cpuModel: string().nullable(),
|
|
26375
|
+
ramGb: number().nullable(),
|
|
26376
|
+
os: string().nullable(),
|
|
26377
|
+
/** Per device: the pool the cells ran on (runtime + tuning). */
|
|
26378
|
+
pools: record(string(), object({
|
|
26379
|
+
runtime: string(),
|
|
26380
|
+
numWorkers: number(),
|
|
26381
|
+
concurrency: number(),
|
|
26382
|
+
batchMode: string()
|
|
26383
|
+
})).default({})
|
|
26384
|
+
});
|
|
26385
|
+
/** The frames the run used. */
|
|
26386
|
+
var NodeBenchClipSchema = object({
|
|
26387
|
+
/** `camstack-bench-v1` or `reference-images` (the fallback when the clip is not reachable). */
|
|
26388
|
+
id: string(),
|
|
26389
|
+
revision: string().nullable(),
|
|
26390
|
+
frames: number(),
|
|
26391
|
+
width: number(),
|
|
26392
|
+
height: number()
|
|
26393
|
+
});
|
|
26394
|
+
var NodeBenchRunnerInputSchema = object({
|
|
26395
|
+
runId: string().min(1),
|
|
26396
|
+
devices: array(NodeBenchmarkDevicePlanSchema).min(1),
|
|
26397
|
+
phases: array(NodeBenchmarkPhaseSchema).min(1),
|
|
26398
|
+
/** The full detail step tree root for the `pipeline` measurement is built on the node from these ids. */
|
|
26399
|
+
steps: array(string()).default([]),
|
|
26400
|
+
fpsPerStream: number().int().min(1).max(30),
|
|
26401
|
+
/** The runner stops on its own past this instant, whatever the hub does. */
|
|
26402
|
+
deadlineAtMs: number(),
|
|
26403
|
+
settleSec: number().min(0).max(60).default(NODE_BENCHMARK_DEFAULTS.settleSec),
|
|
26404
|
+
measureSec: number().min(2).max(300).default(NODE_BENCHMARK_DEFAULTS.measureSec),
|
|
26405
|
+
keepDownloadedModels: boolean().default(false)
|
|
26406
|
+
});
|
|
26407
|
+
var NodeBenchRunnerStateSchema = _enum([
|
|
26408
|
+
"running",
|
|
26409
|
+
"done",
|
|
26410
|
+
"failed",
|
|
26411
|
+
"aborted"
|
|
26412
|
+
]);
|
|
26413
|
+
var NodeBenchRunnerStatusSchema = object({
|
|
26414
|
+
runId: string(),
|
|
26415
|
+
nodeId: string(),
|
|
26416
|
+
state: NodeBenchRunnerStateSchema,
|
|
26417
|
+
progress: NodeBenchProgressSchema.nullable(),
|
|
26418
|
+
/** Every finished cell so far — a run stopped half way keeps what it measured. */
|
|
26419
|
+
cells: array(NodeBenchCellSchema).readonly(),
|
|
26420
|
+
fingerprint: NodeBenchFingerprintSchema.nullable(),
|
|
26421
|
+
clip: NodeBenchClipSchema.nullable(),
|
|
26422
|
+
/** Cameras seen running on the node during the run (they share its pools). */
|
|
26423
|
+
activeCameraIds: array(number()).readonly(),
|
|
26424
|
+
/** Models the run downloaded and then deleted (not installed before). */
|
|
26425
|
+
deletedModels: array(string()).readonly(),
|
|
26426
|
+
error: string().nullable(),
|
|
26427
|
+
startedAtMs: number(),
|
|
26428
|
+
finishedAtMs: number().nullable()
|
|
26429
|
+
});
|
|
26430
|
+
var NodeBenchmarkStateSchema = _enum([
|
|
26431
|
+
"draining",
|
|
26432
|
+
"measuring",
|
|
26433
|
+
"restoring",
|
|
26434
|
+
"done",
|
|
26435
|
+
"failed",
|
|
26436
|
+
"aborted"
|
|
26437
|
+
]);
|
|
26438
|
+
/** Why a run ended. */
|
|
26439
|
+
var NodeBenchmarkEndReasonSchema = _enum([
|
|
26440
|
+
"completed",
|
|
26441
|
+
"operator-abort",
|
|
26442
|
+
"deadline",
|
|
26443
|
+
"node-lost",
|
|
26444
|
+
"runner-lost",
|
|
26445
|
+
"hub-restart",
|
|
26446
|
+
"drain-timeout",
|
|
26447
|
+
"failed"
|
|
26448
|
+
]);
|
|
26449
|
+
var NodeBenchmarkRunSchema = object({
|
|
26450
|
+
runId: string(),
|
|
26451
|
+
nodeId: string(),
|
|
26452
|
+
state: NodeBenchmarkStateSchema,
|
|
26453
|
+
plan: NodeBenchmarkPlanSchema,
|
|
26454
|
+
startedAtMs: number(),
|
|
26455
|
+
deadlineAtMs: number(),
|
|
26456
|
+
finishedAtMs: number().nullable(),
|
|
26457
|
+
endReason: NodeBenchmarkEndReasonSchema.nullable(),
|
|
26458
|
+
error: string().nullable(),
|
|
26459
|
+
/** Cameras moved off the node for the run. */
|
|
26460
|
+
moved: array(number()).readonly(),
|
|
26461
|
+
/** Cameras that stayed (their only frame source is the node). */
|
|
26462
|
+
staying: array(number()).readonly(),
|
|
26463
|
+
/** Something else ran on the node's pools during the run. */
|
|
26464
|
+
contaminated: boolean(),
|
|
26465
|
+
progress: NodeBenchProgressSchema.nullable(),
|
|
26466
|
+
resultIds: array(string()).readonly()
|
|
26467
|
+
});
|
|
26468
|
+
/** `getNodeBenchmarkStatus`: the active run (or the last one), and whether benchmark mode is on. */
|
|
26469
|
+
var NodeBenchmarkStatusSchema = object({
|
|
26470
|
+
/** The node the cluster is in benchmark mode for; null = none. */
|
|
26471
|
+
modeNodeId: string().nullable(),
|
|
26472
|
+
run: NodeBenchmarkRunSchema.nullable()
|
|
26473
|
+
});
|
|
26474
|
+
/**
|
|
26475
|
+
* One stored measurement — the only authority Auto tune and the automatic
|
|
26476
|
+
* shares read measured capacity from. Written by the orchestrator when a run
|
|
26477
|
+
* ends, never by anyone else.
|
|
26478
|
+
*/
|
|
26479
|
+
var NodeBenchmarkResultSchema = object({
|
|
26480
|
+
id: string(),
|
|
26481
|
+
runId: string(),
|
|
26482
|
+
nodeId: string(),
|
|
26483
|
+
cell: NodeBenchCellSchema,
|
|
26484
|
+
fpsPerStream: number(),
|
|
26485
|
+
fingerprint: NodeBenchFingerprintSchema.nullable(),
|
|
26486
|
+
clip: NodeBenchClipSchema.nullable(),
|
|
26487
|
+
/** Other work shared the node's pools (a camera that could not move, or the hub's own duties). */
|
|
26488
|
+
contaminated: boolean(),
|
|
26489
|
+
stayingCameras: array(number()).readonly(),
|
|
26490
|
+
/** The run ended early; the cell itself completed. */
|
|
26491
|
+
partialRun: boolean(),
|
|
26492
|
+
measuredAtMs: number()
|
|
26493
|
+
});
|
|
26494
|
+
var ListNodeBenchmarkResultsInputSchema = object({
|
|
26495
|
+
nodeId: string().optional(),
|
|
26496
|
+
deviceKey: string().optional()
|
|
26497
|
+
});
|
|
26498
|
+
/** A result with its standing today: does it still beat the table? */
|
|
26499
|
+
var NodeBenchmarkResultViewSchema = NodeBenchmarkResultSchema.extend({
|
|
26500
|
+
/** `fresh` beats the table; `stale` falls back to it; `superseded` = a newer row covers the same cell. */
|
|
26501
|
+
standing: _enum([
|
|
26502
|
+
"fresh",
|
|
26503
|
+
"stale",
|
|
26504
|
+
"superseded"
|
|
26505
|
+
]),
|
|
26506
|
+
staleWhy: _enum([
|
|
26507
|
+
"age",
|
|
26508
|
+
"runtime",
|
|
26509
|
+
"pool-tuning"
|
|
26510
|
+
]).nullable()
|
|
26511
|
+
});
|
|
26512
|
+
object({
|
|
26513
|
+
runId: string(),
|
|
26514
|
+
nodeId: string(),
|
|
26515
|
+
startedAtMs: number(),
|
|
26516
|
+
deadlineAtMs: number(),
|
|
26517
|
+
plan: NodeBenchmarkPlanSchema,
|
|
26518
|
+
moved: array(number()).readonly(),
|
|
26519
|
+
staying: array(number()).readonly()
|
|
26520
|
+
});
|
|
26521
|
+
/** Candidate detectors per device, for the plan editor. */
|
|
26522
|
+
var NodeBenchmarkCandidatesSchema = object({
|
|
26523
|
+
nodeId: string(),
|
|
26524
|
+
reachable: boolean(),
|
|
26525
|
+
devices: array(object({
|
|
26526
|
+
deviceKey: string(),
|
|
26527
|
+
enabled: boolean(),
|
|
26528
|
+
available: boolean(),
|
|
26529
|
+
/** Ordered: what Auto tune would pick first, then the rest of the family by accuracy. */
|
|
26530
|
+
suggested: array(string()).readonly(),
|
|
26531
|
+
/** Every root detector the device has a build for. */
|
|
26532
|
+
all: array(string()).readonly(),
|
|
26533
|
+
/** The model the device runs now, when pinned. */
|
|
26534
|
+
currentModelId: string().nullable()
|
|
26535
|
+
})).readonly(),
|
|
26536
|
+
/** Detail steps the node's catalog offers under the root (for the `pipeline` measurement). */
|
|
26537
|
+
steps: array(object({
|
|
26538
|
+
id: string(),
|
|
26539
|
+
name: string(),
|
|
26540
|
+
slot: string()
|
|
26541
|
+
})).readonly()
|
|
26542
|
+
});
|
|
24998
26543
|
object({
|
|
24999
26544
|
activeCameras: number(),
|
|
25000
26545
|
throttledCameras: number(),
|
|
@@ -26123,7 +27668,16 @@ method(RunnerCameraConfigSchema, object({ success: literal(true) }), { kind: "mu
|
|
|
26123
27668
|
}), ParkedTrackFrameSchema.nullable()), method(object({
|
|
26124
27669
|
deviceId: number(),
|
|
26125
27670
|
trackId: string()
|
|
26126
|
-
}), object({ released: number().int().nonnegative() }), { kind: "mutation" })
|
|
27671
|
+
}), object({ released: number().int().nonnegative() }), { kind: "mutation" }), method(NodeBenchRunnerInputSchema, object({
|
|
27672
|
+
accepted: literal(true),
|
|
27673
|
+
runId: string()
|
|
27674
|
+
}), {
|
|
27675
|
+
kind: "mutation",
|
|
27676
|
+
auth: "admin"
|
|
27677
|
+
}), method(object({ runId: string() }), NodeBenchRunnerStatusSchema.nullable(), { auth: "admin" }), method(object({ runId: string() }), object({ aborted: boolean() }), {
|
|
27678
|
+
kind: "mutation",
|
|
27679
|
+
auth: "admin"
|
|
27680
|
+
});
|
|
26127
27681
|
var CameraPipelineConfigSchema = object({
|
|
26128
27682
|
engine: PipelineEngineChoiceSchema.optional(),
|
|
26129
27683
|
steps: array(PipelineStepInputSchema).readonly(),
|
|
@@ -26762,6 +28316,21 @@ method(object({
|
|
|
26762
28316
|
}), method(PlacementStatsInputSchema, PlacementStatsSchema, { auth: "admin" }), method(SuggestSharesInputSchema, SuggestSharesResultSchema, { auth: "admin" }), method(_void(), EffectiveSharesSchema, { auth: "admin" }), method(SetShareSourceInputSchema, object({ success: literal(true) }), {
|
|
26763
28317
|
kind: "mutation",
|
|
26764
28318
|
auth: "admin"
|
|
28319
|
+
}), method(NodeBenchmarkPlanSchema, NodeBenchmarkPreflightSchema, { auth: "admin" }), method(NodeBenchmarkPlanSchema, discriminatedUnion("kind", [object({
|
|
28320
|
+
kind: literal("started"),
|
|
28321
|
+
runId: string()
|
|
28322
|
+
}), object({
|
|
28323
|
+
kind: literal("refused"),
|
|
28324
|
+
preflight: NodeBenchmarkPreflightSchema
|
|
28325
|
+
})]), {
|
|
28326
|
+
kind: "mutation",
|
|
28327
|
+
auth: "admin"
|
|
28328
|
+
}), method(_void(), NodeBenchmarkStatusSchema, { auth: "admin" }), method(object({ runId: string() }), object({ aborted: boolean() }), {
|
|
28329
|
+
kind: "mutation",
|
|
28330
|
+
auth: "admin"
|
|
28331
|
+
}), method(object({ nodeId: string() }), NodeBenchmarkCandidatesSchema, { auth: "admin" }), method(ListNodeBenchmarkResultsInputSchema, array(NodeBenchmarkResultViewSchema).readonly(), { auth: "admin" }), method(object({ id: string() }), object({ deleted: boolean() }), {
|
|
28332
|
+
kind: "mutation",
|
|
28333
|
+
auth: "admin"
|
|
26765
28334
|
}), method(object({ deviceId: number() }), CameraPipelineSettingsSchema.nullable()), method(object({
|
|
26766
28335
|
deviceId: number(),
|
|
26767
28336
|
addonId: string(),
|
|
@@ -33391,6 +34960,9 @@ var CreateIntegrationInputSchema = object({
|
|
|
33391
34960
|
enabled: boolean().optional(),
|
|
33392
34961
|
info: record(string(), unknown()).optional(),
|
|
33393
34962
|
settings: record(string(), unknown()).optional(),
|
|
34963
|
+
/** Keys of `settings` the form's schema declares secret (by type) — kept in
|
|
34964
|
+
* the keychain, not the table (D787). */
|
|
34965
|
+
secretKeys: array(string()).optional(),
|
|
33394
34966
|
skipRestart: boolean().optional()
|
|
33395
34967
|
});
|
|
33396
34968
|
var UpdateIntegrationInputSchema = object({
|
|
@@ -33414,7 +34986,9 @@ method(_void(), array(IntegrationWithStateSchema)), method(object({ id: string()
|
|
|
33414
34986
|
auth: "admin"
|
|
33415
34987
|
}), method(object({ id: string() }), record(string(), unknown()), { auth: "admin" }), method(object({
|
|
33416
34988
|
id: string(),
|
|
33417
|
-
settings: record(string(), unknown())
|
|
34989
|
+
settings: record(string(), unknown()),
|
|
34990
|
+
/** Keys the form's schema declares secret (by type) — keychain-stored (D787). */
|
|
34991
|
+
secretKeys: array(string()).optional()
|
|
33418
34992
|
}), object({ success: boolean() }), {
|
|
33419
34993
|
kind: "mutation",
|
|
33420
34994
|
auth: "admin"
|
|
@@ -42162,7 +43736,8 @@ var BaseDevice = class {
|
|
|
42162
43736
|
this.role = options.role;
|
|
42163
43737
|
this.parentDeviceId = ctx.parentDeviceId;
|
|
42164
43738
|
const seedData = ctx.persistedConfig ?? {};
|
|
42165
|
-
|
|
43739
|
+
const declaredSecretPaths = collectZodSecretPaths(schema);
|
|
43740
|
+
this.config = DeviceConfig.fromSchema(schema, (data) => ctx.persistConfig(data, { secretConfigPaths: declaredSecretPaths }), seedData, ({ droppedKeys, issues }) => {
|
|
42166
43741
|
ctx.logger.warn("Device config recovery: dropping invalid persisted fields", {
|
|
42167
43742
|
tags: {
|
|
42168
43743
|
deviceId: ctx.id,
|
|
@@ -45862,6 +47437,90 @@ Object.freeze({
|
|
|
45862
47437
|
addonId: null,
|
|
45863
47438
|
access: "create"
|
|
45864
47439
|
},
|
|
47440
|
+
"keychain.delete": {
|
|
47441
|
+
capName: "keychain",
|
|
47442
|
+
capScope: "system",
|
|
47443
|
+
addonId: null,
|
|
47444
|
+
access: "delete"
|
|
47445
|
+
},
|
|
47446
|
+
"keychain.getState": {
|
|
47447
|
+
capName: "keychain",
|
|
47448
|
+
capScope: "system",
|
|
47449
|
+
addonId: null,
|
|
47450
|
+
access: "view"
|
|
47451
|
+
},
|
|
47452
|
+
"keychain.listMeta": {
|
|
47453
|
+
capName: "keychain",
|
|
47454
|
+
capScope: "system",
|
|
47455
|
+
addonId: null,
|
|
47456
|
+
access: "view"
|
|
47457
|
+
},
|
|
47458
|
+
"keychain.put": {
|
|
47459
|
+
capName: "keychain",
|
|
47460
|
+
capScope: "system",
|
|
47461
|
+
addonId: null,
|
|
47462
|
+
access: "create"
|
|
47463
|
+
},
|
|
47464
|
+
"keychain.resolve": {
|
|
47465
|
+
capName: "keychain",
|
|
47466
|
+
capScope: "system",
|
|
47467
|
+
addonId: null,
|
|
47468
|
+
access: "view"
|
|
47469
|
+
},
|
|
47470
|
+
"keychainAdmin.deleteOrphans": {
|
|
47471
|
+
capName: "keychain-admin",
|
|
47472
|
+
capScope: "system",
|
|
47473
|
+
addonId: null,
|
|
47474
|
+
access: "delete"
|
|
47475
|
+
},
|
|
47476
|
+
"keychainAdmin.downloadRecoveryKey": {
|
|
47477
|
+
capName: "keychain-admin",
|
|
47478
|
+
capScope: "system",
|
|
47479
|
+
addonId: null,
|
|
47480
|
+
access: "create"
|
|
47481
|
+
},
|
|
47482
|
+
"keychainAdmin.listAudit": {
|
|
47483
|
+
capName: "keychain-admin",
|
|
47484
|
+
capScope: "system",
|
|
47485
|
+
addonId: null,
|
|
47486
|
+
access: "view"
|
|
47487
|
+
},
|
|
47488
|
+
"keychainAdmin.listSecrets": {
|
|
47489
|
+
capName: "keychain-admin",
|
|
47490
|
+
capScope: "system",
|
|
47491
|
+
addonId: null,
|
|
47492
|
+
access: "view"
|
|
47493
|
+
},
|
|
47494
|
+
"keychainAdmin.purgeRetiredKeys": {
|
|
47495
|
+
capName: "keychain-admin",
|
|
47496
|
+
capScope: "system",
|
|
47497
|
+
addonId: null,
|
|
47498
|
+
access: "delete"
|
|
47499
|
+
},
|
|
47500
|
+
"keychainAdmin.resetKeychain": {
|
|
47501
|
+
capName: "keychain-admin",
|
|
47502
|
+
capScope: "system",
|
|
47503
|
+
addonId: null,
|
|
47504
|
+
access: "delete"
|
|
47505
|
+
},
|
|
47506
|
+
"keychainAdmin.reveal": {
|
|
47507
|
+
capName: "keychain-admin",
|
|
47508
|
+
capScope: "system",
|
|
47509
|
+
addonId: null,
|
|
47510
|
+
access: "create"
|
|
47511
|
+
},
|
|
47512
|
+
"keychainAdmin.rotateMasterKey": {
|
|
47513
|
+
capName: "keychain-admin",
|
|
47514
|
+
capScope: "system",
|
|
47515
|
+
addonId: null,
|
|
47516
|
+
access: "create"
|
|
47517
|
+
},
|
|
47518
|
+
"keychainAdmin.status": {
|
|
47519
|
+
capName: "keychain-admin",
|
|
47520
|
+
capScope: "system",
|
|
47521
|
+
addonId: null,
|
|
47522
|
+
access: "view"
|
|
47523
|
+
},
|
|
45865
47524
|
"lawnMowerControl.dock": {
|
|
45866
47525
|
capName: "lawn-mower-control",
|
|
45867
47526
|
capScope: "device",
|
|
@@ -47236,6 +48895,18 @@ Object.freeze({
|
|
|
47236
48895
|
addonId: null,
|
|
47237
48896
|
access: "create"
|
|
47238
48897
|
},
|
|
48898
|
+
"pipelineAnalytics.addRetrainFrameFromRecording": {
|
|
48899
|
+
capName: "pipeline-analytics",
|
|
48900
|
+
capScope: "device",
|
|
48901
|
+
addonId: null,
|
|
48902
|
+
access: "create"
|
|
48903
|
+
},
|
|
48904
|
+
"pipelineAnalytics.addRetrainFramesToCollection": {
|
|
48905
|
+
capName: "pipeline-analytics",
|
|
48906
|
+
capScope: "device",
|
|
48907
|
+
addonId: null,
|
|
48908
|
+
access: "create"
|
|
48909
|
+
},
|
|
47239
48910
|
"pipelineAnalytics.applyDeviceSettingsPatch": {
|
|
47240
48911
|
capName: "pipeline-analytics",
|
|
47241
48912
|
capScope: "device",
|
|
@@ -47284,12 +48955,24 @@ Object.freeze({
|
|
|
47284
48955
|
addonId: null,
|
|
47285
48956
|
access: "view"
|
|
47286
48957
|
},
|
|
48958
|
+
"pipelineAnalytics.createRetrainCollection": {
|
|
48959
|
+
capName: "pipeline-analytics",
|
|
48960
|
+
capScope: "device",
|
|
48961
|
+
addonId: null,
|
|
48962
|
+
access: "create"
|
|
48963
|
+
},
|
|
47287
48964
|
"pipelineAnalytics.deleteDeviceEvents": {
|
|
47288
48965
|
capName: "pipeline-analytics",
|
|
47289
48966
|
capScope: "device",
|
|
47290
48967
|
addonId: null,
|
|
47291
48968
|
access: "delete"
|
|
47292
48969
|
},
|
|
48970
|
+
"pipelineAnalytics.deleteRetrainCollection": {
|
|
48971
|
+
capName: "pipeline-analytics",
|
|
48972
|
+
capScope: "device",
|
|
48973
|
+
addonId: null,
|
|
48974
|
+
access: "delete"
|
|
48975
|
+
},
|
|
47293
48976
|
"pipelineAnalytics.deleteTracks": {
|
|
47294
48977
|
capName: "pipeline-analytics",
|
|
47295
48978
|
capScope: "device",
|
|
@@ -47494,6 +49177,24 @@ Object.freeze({
|
|
|
47494
49177
|
addonId: null,
|
|
47495
49178
|
access: "view"
|
|
47496
49179
|
},
|
|
49180
|
+
"pipelineAnalytics.listRetrainAssistProfiles": {
|
|
49181
|
+
capName: "pipeline-analytics",
|
|
49182
|
+
capScope: "device",
|
|
49183
|
+
addonId: null,
|
|
49184
|
+
access: "view"
|
|
49185
|
+
},
|
|
49186
|
+
"pipelineAnalytics.listRetrainCollectionFrames": {
|
|
49187
|
+
capName: "pipeline-analytics",
|
|
49188
|
+
capScope: "device",
|
|
49189
|
+
addonId: null,
|
|
49190
|
+
access: "view"
|
|
49191
|
+
},
|
|
49192
|
+
"pipelineAnalytics.listRetrainCollections": {
|
|
49193
|
+
capName: "pipeline-analytics",
|
|
49194
|
+
capScope: "device",
|
|
49195
|
+
addonId: null,
|
|
49196
|
+
access: "view"
|
|
49197
|
+
},
|
|
47497
49198
|
"pipelineAnalytics.listRetrainFrames": {
|
|
47498
49199
|
capName: "pipeline-analytics",
|
|
47499
49200
|
capScope: "device",
|
|
@@ -47542,6 +49243,12 @@ Object.freeze({
|
|
|
47542
49243
|
addonId: null,
|
|
47543
49244
|
access: "create"
|
|
47544
49245
|
},
|
|
49246
|
+
"pipelineAnalytics.proposeRetrainAnnotationsWithLlm": {
|
|
49247
|
+
capName: "pipeline-analytics",
|
|
49248
|
+
capScope: "device",
|
|
49249
|
+
addonId: null,
|
|
49250
|
+
access: "create"
|
|
49251
|
+
},
|
|
47545
49252
|
"pipelineAnalytics.pruneEvents": {
|
|
47546
49253
|
capName: "pipeline-analytics",
|
|
47547
49254
|
capScope: "device",
|
|
@@ -47596,6 +49303,18 @@ Object.freeze({
|
|
|
47596
49303
|
addonId: null,
|
|
47597
49304
|
access: "create"
|
|
47598
49305
|
},
|
|
49306
|
+
"pipelineAnalytics.removeRetrainFrameFromCollection": {
|
|
49307
|
+
capName: "pipeline-analytics",
|
|
49308
|
+
capScope: "device",
|
|
49309
|
+
addonId: null,
|
|
49310
|
+
access: "delete"
|
|
49311
|
+
},
|
|
49312
|
+
"pipelineAnalytics.renameRetrainCollection": {
|
|
49313
|
+
capName: "pipeline-analytics",
|
|
49314
|
+
capScope: "device",
|
|
49315
|
+
addonId: null,
|
|
49316
|
+
access: "create"
|
|
49317
|
+
},
|
|
47599
49318
|
"pipelineAnalytics.restageRetrainTrack": {
|
|
47600
49319
|
capName: "pipeline-analytics",
|
|
47601
49320
|
capScope: "device",
|
|
@@ -47884,6 +49603,12 @@ Object.freeze({
|
|
|
47884
49603
|
addonId: null,
|
|
47885
49604
|
access: "view"
|
|
47886
49605
|
},
|
|
49606
|
+
"pipelineOrchestrator.abortNodeBenchmark": {
|
|
49607
|
+
capName: "pipeline-orchestrator",
|
|
49608
|
+
capScope: "system",
|
|
49609
|
+
addonId: null,
|
|
49610
|
+
access: "create"
|
|
49611
|
+
},
|
|
47887
49612
|
"pipelineOrchestrator.applyAutoTune": {
|
|
47888
49613
|
capName: "pipeline-orchestrator",
|
|
47889
49614
|
capScope: "system",
|
|
@@ -47908,6 +49633,12 @@ Object.freeze({
|
|
|
47908
49633
|
addonId: null,
|
|
47909
49634
|
access: "create"
|
|
47910
49635
|
},
|
|
49636
|
+
"pipelineOrchestrator.deleteNodeBenchmarkResult": {
|
|
49637
|
+
capName: "pipeline-orchestrator",
|
|
49638
|
+
capScope: "system",
|
|
49639
|
+
addonId: null,
|
|
49640
|
+
access: "delete"
|
|
49641
|
+
},
|
|
47911
49642
|
"pipelineOrchestrator.getAgentLoad": {
|
|
47912
49643
|
capName: "pipeline-orchestrator",
|
|
47913
49644
|
capScope: "system",
|
|
@@ -48016,6 +49747,24 @@ Object.freeze({
|
|
|
48016
49747
|
addonId: null,
|
|
48017
49748
|
access: "view"
|
|
48018
49749
|
},
|
|
49750
|
+
"pipelineOrchestrator.getNodeBenchmarkCandidates": {
|
|
49751
|
+
capName: "pipeline-orchestrator",
|
|
49752
|
+
capScope: "system",
|
|
49753
|
+
addonId: null,
|
|
49754
|
+
access: "view"
|
|
49755
|
+
},
|
|
49756
|
+
"pipelineOrchestrator.getNodeBenchmarkPreflight": {
|
|
49757
|
+
capName: "pipeline-orchestrator",
|
|
49758
|
+
capScope: "system",
|
|
49759
|
+
addonId: null,
|
|
49760
|
+
access: "view"
|
|
49761
|
+
},
|
|
49762
|
+
"pipelineOrchestrator.getNodeBenchmarkStatus": {
|
|
49763
|
+
capName: "pipeline-orchestrator",
|
|
49764
|
+
capScope: "system",
|
|
49765
|
+
addonId: null,
|
|
49766
|
+
access: "view"
|
|
49767
|
+
},
|
|
48019
49768
|
"pipelineOrchestrator.getNodeInferenceDevices": {
|
|
48020
49769
|
capName: "pipeline-orchestrator",
|
|
48021
49770
|
capScope: "system",
|
|
@@ -48058,6 +49807,12 @@ Object.freeze({
|
|
|
48058
49807
|
addonId: null,
|
|
48059
49808
|
access: "view"
|
|
48060
49809
|
},
|
|
49810
|
+
"pipelineOrchestrator.listNodeBenchmarkResults": {
|
|
49811
|
+
capName: "pipeline-orchestrator",
|
|
49812
|
+
capScope: "system",
|
|
49813
|
+
addonId: null,
|
|
49814
|
+
access: "view"
|
|
49815
|
+
},
|
|
48061
49816
|
"pipelineOrchestrator.pauseForStorageMigration": {
|
|
48062
49817
|
capName: "pipeline-orchestrator",
|
|
48063
49818
|
capScope: "system",
|
|
@@ -48202,6 +49957,12 @@ Object.freeze({
|
|
|
48202
49957
|
addonId: null,
|
|
48203
49958
|
access: "create"
|
|
48204
49959
|
},
|
|
49960
|
+
"pipelineOrchestrator.startNodeBenchmark": {
|
|
49961
|
+
capName: "pipeline-orchestrator",
|
|
49962
|
+
capScope: "system",
|
|
49963
|
+
addonId: null,
|
|
49964
|
+
access: "create"
|
|
49965
|
+
},
|
|
48205
49966
|
"pipelineOrchestrator.suggestShares": {
|
|
48206
49967
|
capName: "pipeline-orchestrator",
|
|
48207
49968
|
capScope: "system",
|
|
@@ -48220,6 +49981,12 @@ Object.freeze({
|
|
|
48220
49981
|
addonId: null,
|
|
48221
49982
|
access: "create"
|
|
48222
49983
|
},
|
|
49984
|
+
"pipelineRunner.abortNodeBench": {
|
|
49985
|
+
capName: "pipeline-runner",
|
|
49986
|
+
capScope: "system",
|
|
49987
|
+
addonId: null,
|
|
49988
|
+
access: "create"
|
|
49989
|
+
},
|
|
48223
49990
|
"pipelineRunner.attachCamera": {
|
|
48224
49991
|
capName: "pipeline-runner",
|
|
48225
49992
|
capScope: "system",
|
|
@@ -48268,6 +50035,12 @@ Object.freeze({
|
|
|
48268
50035
|
addonId: null,
|
|
48269
50036
|
access: "view"
|
|
48270
50037
|
},
|
|
50038
|
+
"pipelineRunner.getNodeBenchStatus": {
|
|
50039
|
+
capName: "pipeline-runner",
|
|
50040
|
+
capScope: "system",
|
|
50041
|
+
addonId: null,
|
|
50042
|
+
access: "view"
|
|
50043
|
+
},
|
|
48271
50044
|
"pipelineRunner.getParkedTrackFrame": {
|
|
48272
50045
|
capName: "pipeline-runner",
|
|
48273
50046
|
capScope: "system",
|
|
@@ -48310,6 +50083,12 @@ Object.freeze({
|
|
|
48310
50083
|
addonId: null,
|
|
48311
50084
|
access: "create"
|
|
48312
50085
|
},
|
|
50086
|
+
"pipelineRunner.startNodeBench": {
|
|
50087
|
+
capName: "pipeline-runner",
|
|
50088
|
+
capScope: "system",
|
|
50089
|
+
addonId: null,
|
|
50090
|
+
access: "create"
|
|
50091
|
+
},
|
|
48313
50092
|
"plateGallery.assignPlate": {
|
|
48314
50093
|
capName: "plate-gallery",
|
|
48315
50094
|
capScope: "system",
|
|
@@ -53391,6 +55170,11 @@ Object.freeze({
|
|
|
53391
55170
|
form: "single",
|
|
53392
55171
|
optional: false
|
|
53393
55172
|
}],
|
|
55173
|
+
"pipelineAnalytics.addRetrainFrameFromRecording": [{
|
|
55174
|
+
name: "deviceId",
|
|
55175
|
+
form: "single",
|
|
55176
|
+
optional: false
|
|
55177
|
+
}],
|
|
53394
55178
|
"pipelineAnalytics.applyDeviceSettingsPatch": [{
|
|
53395
55179
|
name: "deviceId",
|
|
53396
55180
|
form: "single",
|
|
@@ -53581,6 +55365,11 @@ Object.freeze({
|
|
|
53581
55365
|
form: "single",
|
|
53582
55366
|
optional: false
|
|
53583
55367
|
}],
|
|
55368
|
+
"pipelineAnalytics.proposeRetrainAnnotationsWithLlm": [{
|
|
55369
|
+
name: "deviceId",
|
|
55370
|
+
form: "single",
|
|
55371
|
+
optional: false
|
|
55372
|
+
}],
|
|
53584
55373
|
"pipelineAnalytics.pruneEventsBefore": [{
|
|
53585
55374
|
name: "deviceId",
|
|
53586
55375
|
form: "single",
|
|
@@ -165341,6 +167130,31 @@ function createAccessoryDevice(kind, ctx, parent) {
|
|
|
165341
167130
|
}
|
|
165342
167131
|
//#endregion
|
|
165343
167132
|
//#region src/accessory-probe-flags.ts
|
|
167133
|
+
/**
|
|
167134
|
+
* Pure helpers that decide which probe flags drive accessory-child
|
|
167135
|
+
* derivation, and whether a Reolink camera has *ever* been probed.
|
|
167136
|
+
*
|
|
167137
|
+
* Why this exists as its own module: the `feature-probe` runtime-state
|
|
167138
|
+
* slice is the live, in-session source of the camera's ability flags
|
|
167139
|
+
* (`hasSiren` / `hasFloodlight` / `hasPirSensor` / …). It is rehydrated
|
|
167140
|
+
* on restart, BUT a camera whose Baichuan `getDeviceCapabilities`
|
|
167141
|
+
* round-trip is slow or flaky (observed: a doorbell that times out the
|
|
167142
|
+
* kernel's 30s `onProbe` window on every boot) restores with an empty
|
|
167143
|
+
* slice (`lastProbedAt === 0`). The `deviceCache` config blob — written
|
|
167144
|
+
* alongside the slice on the LAST successful probe and preserved across
|
|
167145
|
+
* restarts by the camera schema's `.loose()` passthrough — still carries
|
|
167146
|
+
* that probe's flags plus a `probedAt` stamp.
|
|
167147
|
+
*
|
|
167148
|
+
* Deriving accessory specs from the `deviceCache` fallback lets the
|
|
167149
|
+
* kernel re-spawn the persisted accessory children (and therefore
|
|
167150
|
+
* re-mount their kernel-managed `device-ops` provider) even when this
|
|
167151
|
+
* session's live probe never completes. Without it, every accessory of
|
|
167152
|
+
* a slow-probing camera is left as a DB row with no live provider
|
|
167153
|
+
* ("device-ops not registered for device N").
|
|
167154
|
+
*
|
|
167155
|
+
* Kept pure (no `this`, no I/O) so the slice-vs-cache precedence is
|
|
167156
|
+
* unit-testable without standing up a full camera device.
|
|
167157
|
+
*/
|
|
165344
167158
|
var FLAG_KEYS = [
|
|
165345
167159
|
"hasBattery",
|
|
165346
167160
|
"hasPtz",
|
|
@@ -165378,6 +167192,43 @@ function resolveAccessoryProbeFlags(sliceProbed, sliceFlags, deviceCache) {
|
|
|
165378
167192
|
}
|
|
165379
167193
|
return out;
|
|
165380
167194
|
}
|
|
167195
|
+
/**
|
|
167196
|
+
* The `deviceCache` blob a successful feature probe leaves behind: the
|
|
167197
|
+
* previous blob, plus the `probedAt` stamp and every boolean ability flag
|
|
167198
|
+
* the probe resolved. This is what lets {@link resolveAccessoryProbeFlags}
|
|
167199
|
+
* fall back on the next boot — a battery camera asleep at boot skips its
|
|
167200
|
+
* probe, and the `feature-probe` slice alone does not carry the flags
|
|
167201
|
+
* across a provider restart. Returns a new object; `previous` is untouched.
|
|
167202
|
+
*/
|
|
167203
|
+
function withPersistedProbe(previous, flags, probedAt) {
|
|
167204
|
+
const persisted = {};
|
|
167205
|
+
for (const key of FLAG_KEYS) {
|
|
167206
|
+
const value = flags[key];
|
|
167207
|
+
if (typeof value === "boolean") persisted[key] = value;
|
|
167208
|
+
}
|
|
167209
|
+
return {
|
|
167210
|
+
...previous,
|
|
167211
|
+
...persisted,
|
|
167212
|
+
probedAt
|
|
167213
|
+
};
|
|
167214
|
+
}
|
|
167215
|
+
/** The accessory children a probe flag set spawns, in spawn order. */
|
|
167216
|
+
var ACCESSORY_FLAGS = [
|
|
167217
|
+
["hasSiren", AccessoryKind.Siren],
|
|
167218
|
+
["hasFloodlight", AccessoryKind.Floodlight],
|
|
167219
|
+
["hasPirSensor", AccessoryKind.PirSensor]
|
|
167220
|
+
];
|
|
167221
|
+
/**
|
|
167222
|
+
* Accessory kinds a camera should spawn: none until it has EVER probed
|
|
167223
|
+
* (live slice this session, or a persisted `probedAt`), then one per
|
|
167224
|
+
* ability flag that is exactly `true` — live slice first, persisted
|
|
167225
|
+
* `deviceCache` flags as the fallback.
|
|
167226
|
+
*/
|
|
167227
|
+
function accessoryKindsFor(sliceProbed, sliceFlags, deviceCache) {
|
|
167228
|
+
if (!hasEverProbed(sliceProbed, deviceCache)) return [];
|
|
167229
|
+
const flags = resolveAccessoryProbeFlags(sliceProbed, sliceFlags, deviceCache);
|
|
167230
|
+
return ACCESSORY_FLAGS.filter(([flag]) => flags[flag] === true).map(([, kind]) => kind);
|
|
167231
|
+
}
|
|
165381
167232
|
//#endregion
|
|
165382
167233
|
//#region src/metadata-populator.ts
|
|
165383
167234
|
var EXTENDED_INFO_TAGS = [
|
|
@@ -168193,9 +170044,7 @@ var ReolinkCamera = class ReolinkCamera extends BaseDevice {
|
|
|
168193
170044
|
* parent register.
|
|
168194
170045
|
*/
|
|
168195
170046
|
getAccessoryChildren() {
|
|
168196
|
-
const
|
|
168197
|
-
if (!hasEverProbed(this.hasProbed(), deviceCache)) return [];
|
|
168198
|
-
const probe = resolveAccessoryProbeFlags(this.hasProbed(), this.getProbeFlags(), deviceCache);
|
|
170047
|
+
const kinds = accessoryKindsFor(this.hasProbed(), this.getProbeFlags(), this.config.get("deviceCache"));
|
|
168199
170048
|
const out = [];
|
|
168200
170049
|
const push = (kind, type, label) => {
|
|
168201
170050
|
out.push({
|
|
@@ -168211,9 +170060,9 @@ var ReolinkCamera = class ReolinkCamera extends BaseDevice {
|
|
|
168211
170060
|
factory: (ctx) => createAccessoryDevice(kind, ctx, this)
|
|
168212
170061
|
});
|
|
168213
170062
|
};
|
|
168214
|
-
if (
|
|
168215
|
-
if (
|
|
168216
|
-
if (
|
|
170063
|
+
if (kinds.includes(AccessoryKind.Siren)) push(AccessoryKind.Siren, DeviceType.Siren, ACCESSORY_LABEL[AccessoryKind.Siren]);
|
|
170064
|
+
if (kinds.includes(AccessoryKind.Floodlight)) push(AccessoryKind.Floodlight, DeviceType.Light, ACCESSORY_LABEL[AccessoryKind.Floodlight]);
|
|
170065
|
+
if (kinds.includes(AccessoryKind.PirSensor)) push(AccessoryKind.PirSensor, DeviceType.Switch, ACCESSORY_LABEL[AccessoryKind.PirSensor]);
|
|
168217
170066
|
return out;
|
|
168218
170067
|
}
|
|
168219
170068
|
/**
|
|
@@ -172664,6 +174513,14 @@ var ReolinkCamera = class ReolinkCamera extends BaseDevice {
|
|
|
172664
174513
|
meta: { error: err instanceof Error ? err.message : String(err) }
|
|
172665
174514
|
});
|
|
172666
174515
|
}
|
|
174516
|
+
if (!this.hasProbed()) try {
|
|
174517
|
+
await this.reprobe();
|
|
174518
|
+
} catch (err) {
|
|
174519
|
+
this.ctx.logger.debug("onWakeTransition: feature probe failed — next wake retries", {
|
|
174520
|
+
tags: { deviceId: this.id },
|
|
174521
|
+
meta: { error: err instanceof Error ? err.message : String(err) }
|
|
174522
|
+
});
|
|
174523
|
+
}
|
|
172667
174524
|
await this.warmCapSlicesOnWake();
|
|
172668
174525
|
await this.warmSnapshotOnWake();
|
|
172669
174526
|
await this.alignAuxDevicesState("wake");
|
|
@@ -174732,6 +176589,7 @@ var ReolinkCamera = class ReolinkCamera extends BaseDevice {
|
|
|
174732
176589
|
let hasBattery;
|
|
174733
176590
|
let hasPirSensor;
|
|
174734
176591
|
let hasAutotrack;
|
|
176592
|
+
let capabilitiesRead = false;
|
|
174735
176593
|
try {
|
|
174736
176594
|
channelCount = await api.getChannelCount();
|
|
174737
176595
|
} catch {}
|
|
@@ -174745,6 +176603,7 @@ var ReolinkCamera = class ReolinkCamera extends BaseDevice {
|
|
|
174745
176603
|
hasBattery = capabilities.hasBattery;
|
|
174746
176604
|
hasPirSensor = capabilities.hasPir;
|
|
174747
176605
|
hasAutotrack = capabilities.hasAutotracking;
|
|
176606
|
+
capabilitiesRead = true;
|
|
174748
176607
|
} catch (err) {
|
|
174749
176608
|
this.ctx.logger.debug("getDeviceCapabilities failed — leaving flags unset", {
|
|
174750
176609
|
tags: { deviceId: this.id },
|
|
@@ -174781,12 +176640,12 @@ var ReolinkCamera = class ReolinkCamera extends BaseDevice {
|
|
|
174781
176640
|
};
|
|
174782
176641
|
this.runtimeState.setCapState("feature-probe", next);
|
|
174783
176642
|
try {
|
|
174784
|
-
const
|
|
174785
|
-
|
|
174786
|
-
...previous,
|
|
176643
|
+
const identity = {
|
|
176644
|
+
...this.config.get("deviceCache") ?? {},
|
|
174787
176645
|
...inferredDeviceType ? { deviceType: inferredDeviceType } : {},
|
|
174788
176646
|
...channelCount !== void 0 ? { channelCount } : {}
|
|
174789
|
-
}
|
|
176647
|
+
};
|
|
176648
|
+
await this.config.setAll({ deviceCache: capabilitiesRead ? withPersistedProbe(identity, flags, now) : identity });
|
|
174790
176649
|
} catch (err) {
|
|
174791
176650
|
this.ctx.logger.debug("deviceCache identity persist failed (non-fatal)", {
|
|
174792
176651
|
tags: { deviceId: this.id },
|
|
@@ -177237,6 +179096,8 @@ async function enrichHostIdentifiersFromLiveApi(detection, logger) {
|
|
|
177237
179096
|
}
|
|
177238
179097
|
}
|
|
177239
179098
|
var ReolinkProviderAddon = class extends BaseDeviceProvider {
|
|
179099
|
+
/** The email-push SMTP password is hidden state — kept in the keychain (D787). */
|
|
179100
|
+
secretStatePaths = ["emailPushAuthPassword"];
|
|
177240
179101
|
addonId = REOLINK_ADDON_ID;
|
|
177241
179102
|
providerName = "Reolink";
|
|
177242
179103
|
deviceClasses = {
|