@camstack/addon-provider-reolink 1.2.178 → 1.2.180
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 +2080 -66
- package/dist/addon.mjs +2080 -66
- package/package.json +1 -1
package/dist/addon.mjs
CHANGED
|
@@ -27,7 +27,7 @@ import { URL as URL$1 } from "url";
|
|
|
27
27
|
import { spawn as spawn$1 } from "node:child_process";
|
|
28
28
|
import os, { tmpdir } from "node:os";
|
|
29
29
|
import { createReadStream } from "node:fs";
|
|
30
|
-
//#region ../types/dist/event-category-
|
|
30
|
+
//#region ../types/dist/event-category-DaIZi00R.mjs
|
|
31
31
|
var EventCategory = /* @__PURE__ */ function(EventCategory) {
|
|
32
32
|
EventCategory["SystemBoot"] = "system.boot";
|
|
33
33
|
EventCategory["SystemAddonsReady"] = "system.addons-ready";
|
|
@@ -106,6 +106,13 @@ var EventCategory = /* @__PURE__ */ function(EventCategory) {
|
|
|
106
106
|
*/
|
|
107
107
|
EventCategory["AddonLoadFailed"] = "addon.load-failed";
|
|
108
108
|
/**
|
|
109
|
+
* A keychain value was stored or removed (D787). Carries the ref, its
|
|
110
|
+
* owner and the new version — NEVER the value. A process holding the ref
|
|
111
|
+
* drops its cached copy and the owning `BaseAddon` re-resolves its config.
|
|
112
|
+
* Telemetry (D8): a process that misses it still revalidates by version.
|
|
113
|
+
*/
|
|
114
|
+
EventCategory["KeychainChanged"] = "keychain.changed";
|
|
115
|
+
/**
|
|
109
116
|
* Addon recovered from a previous failure. Emitted when an addon
|
|
110
117
|
* transitions from `failed` back to `healthy` (typically via the
|
|
111
118
|
* monitor's auto-retry loop, or after manual `addons.retryLoad`).
|
|
@@ -5398,7 +5405,7 @@ var ZodIssueCode = {
|
|
|
5398
5405
|
var ZodFirstPartyTypeKind;
|
|
5399
5406
|
ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {});
|
|
5400
5407
|
//#endregion
|
|
5401
|
-
//#region ../types/dist/sleep-
|
|
5408
|
+
//#region ../types/dist/sleep-DujUvOcb.mjs
|
|
5402
5409
|
/**
|
|
5403
5410
|
* The audio chunk plane's byte format, and the ONE expansion from a coded
|
|
5404
5411
|
* window to float samples (D455).
|
|
@@ -5477,6 +5484,97 @@ function buildAlawTable() {
|
|
|
5477
5484
|
}
|
|
5478
5485
|
buildUlawTable();
|
|
5479
5486
|
buildAlawTable();
|
|
5487
|
+
/** Is this field's stored value a credential? */
|
|
5488
|
+
function isSecretConfigField(field) {
|
|
5489
|
+
if (field.type === "password") return true;
|
|
5490
|
+
return "secret" in field && field.secret === true;
|
|
5491
|
+
}
|
|
5492
|
+
/**
|
|
5493
|
+
* Is this field's value stored in the KEYCHAIN (D787)? Every secret field is,
|
|
5494
|
+
* by its TYPE, unless it opts out with `storage: 'inline'` — never by its name.
|
|
5495
|
+
*/
|
|
5496
|
+
function isKeychainStoredField(field) {
|
|
5497
|
+
if (!isSecretConfigField(field)) return false;
|
|
5498
|
+
if (field.type === "textarea" && field.isJson === true) return false;
|
|
5499
|
+
return !("storage" in field && field.storage === "inline");
|
|
5500
|
+
}
|
|
5501
|
+
/**
|
|
5502
|
+
* What a settings blob holds where a secret used to be.
|
|
5503
|
+
*
|
|
5504
|
+
* A keychain-stored field never holds its value. It holds a self-describing
|
|
5505
|
+
* MARKER, `{"$secret":"secret://…","v":1}` — an object, never a string, so no
|
|
5506
|
+
* code can mistake it for a credential and no form can send it to a camera as
|
|
5507
|
+
* a password. The empty state is `null` / absent, never `''`.
|
|
5508
|
+
*
|
|
5509
|
+
* The same shapes travel to and from the admin UI:
|
|
5510
|
+
*
|
|
5511
|
+
* - read: `hydrateSchema` hands a secret field a {@link SecretFieldView}
|
|
5512
|
+
* (`{ $secret, v, set: true }`) or `null` — the browser learns whether a
|
|
5513
|
+
* value is set, never the value.
|
|
5514
|
+
* - write: an untouched field submits the view back unchanged (KEEP); a typed
|
|
5515
|
+
* value is a plain non-empty string (CHANGE); the Clear button submits
|
|
5516
|
+
* {@link SECRET_CLEAR} (CLEAR). `''`, `null` and the legacy redaction tokens
|
|
5517
|
+
* are KEEP — an empty string is what a defaults-fallback pushes back, and
|
|
5518
|
+
* treating it as "clear" is how a save destroyed a stored credential before.
|
|
5519
|
+
*
|
|
5520
|
+
* Pure and browser-safe.
|
|
5521
|
+
*/
|
|
5522
|
+
var SECRET_CLEAR = { $secretClear: true };
|
|
5523
|
+
/** The `'***'` token D634 redaction writes for non-admins. */
|
|
5524
|
+
var LEGACY_DEVICE_REDACTION = "***";
|
|
5525
|
+
function isRecord$1(value) {
|
|
5526
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
5527
|
+
}
|
|
5528
|
+
function makeSecretMarker(ref) {
|
|
5529
|
+
return {
|
|
5530
|
+
$secret: ref,
|
|
5531
|
+
v: 1
|
|
5532
|
+
};
|
|
5533
|
+
}
|
|
5534
|
+
/** A stored marker: an object whose `$secret` is a non-empty string. */
|
|
5535
|
+
function isSecretMarker(value) {
|
|
5536
|
+
if (!isRecord$1(value)) return false;
|
|
5537
|
+
const ref = value["$secret"];
|
|
5538
|
+
return typeof ref === "string" && ref.length > 0;
|
|
5539
|
+
}
|
|
5540
|
+
function isSecretClear(value) {
|
|
5541
|
+
return isRecord$1(value) && value["$secretClear"] === true;
|
|
5542
|
+
}
|
|
5543
|
+
/**
|
|
5544
|
+
* The UI view of a stored secret field value: a marker becomes "set", inline
|
|
5545
|
+
* plaintext becomes "set (inline)", nothing becomes `null`. A value never
|
|
5546
|
+
* survives this function.
|
|
5547
|
+
*/
|
|
5548
|
+
function toSecretFieldView(stored) {
|
|
5549
|
+
if (isSecretMarker(stored)) return {
|
|
5550
|
+
$secret: stored.$secret,
|
|
5551
|
+
v: 1,
|
|
5552
|
+
set: true
|
|
5553
|
+
};
|
|
5554
|
+
if (typeof stored === "string" && stored.length > 0) return {
|
|
5555
|
+
$secret: null,
|
|
5556
|
+
v: 1,
|
|
5557
|
+
set: true,
|
|
5558
|
+
inline: true
|
|
5559
|
+
};
|
|
5560
|
+
return null;
|
|
5561
|
+
}
|
|
5562
|
+
/**
|
|
5563
|
+
* Classify an incoming value for a secret path. Only a non-empty string that is
|
|
5564
|
+
* not a redaction token sets a value; only {@link SECRET_CLEAR} clears.
|
|
5565
|
+
* Everything else — a marker (ours or anyone's), a UI view, `''`, `null`,
|
|
5566
|
+
* `undefined`, a redaction token, a non-string — keeps what is stored.
|
|
5567
|
+
*/
|
|
5568
|
+
function classifySecretWrite(incoming) {
|
|
5569
|
+
if (isSecretClear(incoming)) return { kind: "clear" };
|
|
5570
|
+
if (typeof incoming !== "string") return { kind: "keep" };
|
|
5571
|
+
if (incoming.length === 0) return { kind: "keep" };
|
|
5572
|
+
if (incoming === "__camstack_redacted__" || incoming === LEGACY_DEVICE_REDACTION) return { kind: "keep" };
|
|
5573
|
+
return {
|
|
5574
|
+
kind: "set",
|
|
5575
|
+
value: incoming
|
|
5576
|
+
};
|
|
5577
|
+
}
|
|
5480
5578
|
Object.fromEntries([
|
|
5481
5579
|
{
|
|
5482
5580
|
id: "overview",
|
|
@@ -5648,33 +5746,19 @@ Object.fromEntries([
|
|
|
5648
5746
|
function isValuelessField(field) {
|
|
5649
5747
|
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";
|
|
5650
5748
|
}
|
|
5651
|
-
|
|
5652
|
-
* Merge a `ConfigUISchema` with a raw `values` record into a
|
|
5653
|
-
* `ConfigUISchemaWithValues`. Used by every `get*Settings` backend endpoint
|
|
5654
|
-
* before returning to the admin UI. Groups are walked recursively.
|
|
5655
|
-
*
|
|
5656
|
-
* For each leaf field:
|
|
5657
|
-
* - structural fields (`separator`, `info`, `button`) pass through unchanged
|
|
5658
|
-
* - other fields get `value = values[key] ?? field.default ?? null`
|
|
5659
|
-
*
|
|
5660
|
-
* Unknown keys in `values` (keys not declared in the schema) are silently
|
|
5661
|
-
* ignored — they don't contribute to the output. Missing keys fall back to
|
|
5662
|
-
* the schema default or `null`. This mirrors the old backend behaviour where
|
|
5663
|
-
* `FormBuilder` rendered `values[key] ?? field.default`.
|
|
5664
|
-
*/
|
|
5665
|
-
function hydrateSchema(schema, values) {
|
|
5749
|
+
function hydrateSchema(schema, values, options = {}) {
|
|
5666
5750
|
return {
|
|
5667
5751
|
...schema.tabs ? { tabs: [...schema.tabs] } : {},
|
|
5668
5752
|
sections: schema.sections.map((section) => ({
|
|
5669
5753
|
...section,
|
|
5670
|
-
fields: section.fields.map((field) => hydrateField(field, values))
|
|
5754
|
+
fields: section.fields.map((field) => hydrateField(field, values, options))
|
|
5671
5755
|
}))
|
|
5672
5756
|
};
|
|
5673
5757
|
}
|
|
5674
|
-
function hydrateField(field, values) {
|
|
5758
|
+
function hydrateField(field, values, options) {
|
|
5675
5759
|
if (isValuelessField(field)) return field;
|
|
5676
5760
|
if (field.type === "group") {
|
|
5677
|
-
const hydratedChildren = field.fields.map((child) => hydrateField(child, values));
|
|
5761
|
+
const hydratedChildren = field.fields.map((child) => hydrateField(child, values, options));
|
|
5678
5762
|
return {
|
|
5679
5763
|
...field,
|
|
5680
5764
|
fields: hydratedChildren
|
|
@@ -5683,7 +5767,7 @@ function hydrateField(field, values) {
|
|
|
5683
5767
|
if (field.type === "sub-tabs") {
|
|
5684
5768
|
const hydratedTabs = field.tabs.map((tab) => ({
|
|
5685
5769
|
...tab,
|
|
5686
|
-
fields: tab.fields.map((child) => hydrateField(child, values))
|
|
5770
|
+
fields: tab.fields.map((child) => hydrateField(child, values, options))
|
|
5687
5771
|
}));
|
|
5688
5772
|
return {
|
|
5689
5773
|
...field,
|
|
@@ -5693,6 +5777,33 @@ function hydrateField(field, values) {
|
|
|
5693
5777
|
const key = field.key;
|
|
5694
5778
|
const storedValue = Object.prototype.hasOwnProperty.call(values, key) ? values[key] : void 0;
|
|
5695
5779
|
const defaultValue = field.default;
|
|
5780
|
+
const asView = (v) => isSecretMarker(v) || options.inlineSecretsAsViews === true && v !== void 0;
|
|
5781
|
+
if (isKeychainStoredField(field) && asView(storedValue)) return {
|
|
5782
|
+
...field,
|
|
5783
|
+
value: toSecretFieldView(storedValue)
|
|
5784
|
+
};
|
|
5785
|
+
if (isKeychainStoredField(field) && options.inlineSecretsAsViews === true) return {
|
|
5786
|
+
...field,
|
|
5787
|
+
value: null
|
|
5788
|
+
};
|
|
5789
|
+
if (field.type === "editable-array" && Array.isArray(storedValue)) {
|
|
5790
|
+
const secretItemKeys = field.itemFields.filter((item) => "key" in item && isKeychainStoredField(item)).map((item) => "key" in item ? item.key : "");
|
|
5791
|
+
if (secretItemKeys.length > 0) {
|
|
5792
|
+
const rows = storedValue.map((row) => {
|
|
5793
|
+
if (row === null || typeof row !== "object" || Array.isArray(row)) return row;
|
|
5794
|
+
const out = { ...row };
|
|
5795
|
+
for (const k of secretItemKeys) {
|
|
5796
|
+
const v = Reflect.get(row, k);
|
|
5797
|
+
if (asView(v)) out[k] = toSecretFieldView(v);
|
|
5798
|
+
}
|
|
5799
|
+
return out;
|
|
5800
|
+
});
|
|
5801
|
+
return {
|
|
5802
|
+
...field,
|
|
5803
|
+
value: rows
|
|
5804
|
+
};
|
|
5805
|
+
}
|
|
5806
|
+
}
|
|
5696
5807
|
if (field.multiple) {
|
|
5697
5808
|
const stored = Array.isArray(storedValue) ? storedValue : storedValue !== void 0 && storedValue !== null ? [storedValue] : [];
|
|
5698
5809
|
const itemFallback = field.multiple.itemDefault !== void 0 ? field.multiple.itemDefault : defaultValue !== void 0 ? defaultValue : typeOf(field) === "string" ? "" : null;
|
|
@@ -5935,6 +6046,431 @@ function projectStore(store, perNodeKeys, nodeId) {
|
|
|
5935
6046
|
}
|
|
5936
6047
|
return out;
|
|
5937
6048
|
}
|
|
6049
|
+
var GLOBAL_SCOPE = { kind: "global" };
|
|
6050
|
+
/** The scope every addon-wide (not per-node, not per-device) setting lives in. */
|
|
6051
|
+
function globalSecretScope() {
|
|
6052
|
+
return GLOBAL_SCOPE;
|
|
6053
|
+
}
|
|
6054
|
+
function encodeSegment(value) {
|
|
6055
|
+
return encodeURIComponent(value);
|
|
6056
|
+
}
|
|
6057
|
+
/**
|
|
6058
|
+
* The field path of a value inside an array item, addressed by the item's id:
|
|
6059
|
+
* `arrayItemFieldPath('providers', 'authentik', 'clientSecret')` →
|
|
6060
|
+
* `providers[authentik].clientSecret`.
|
|
6061
|
+
*/
|
|
6062
|
+
function arrayItemFieldPath(arrayKey, itemId, fieldKey) {
|
|
6063
|
+
return `${arrayKey}[${encodeSegment(itemId)}].${fieldKey}`;
|
|
6064
|
+
}
|
|
6065
|
+
/** A write to a secret path could not be stored in the keychain, so it was refused. */
|
|
6066
|
+
var KeychainWriteRefusedError = class extends Error {
|
|
6067
|
+
fieldPath;
|
|
6068
|
+
constructor(fieldPath, cause) {
|
|
6069
|
+
super(`secret "${fieldPath}" was not saved: the keychain could not store it (${cause instanceof Error ? cause.message : String(cause)}). Nothing was written.`);
|
|
6070
|
+
this.fieldPath = fieldPath;
|
|
6071
|
+
this.name = "KeychainWriteRefusedError";
|
|
6072
|
+
}
|
|
6073
|
+
};
|
|
6074
|
+
var KEEP = { kind: "keep" };
|
|
6075
|
+
function isRecord$2(value) {
|
|
6076
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
6077
|
+
}
|
|
6078
|
+
function defaultMintId() {
|
|
6079
|
+
return globalThis.crypto.randomUUID();
|
|
6080
|
+
}
|
|
6081
|
+
/** Every marker ref anywhere under `value`. */
|
|
6082
|
+
function collectSecretMarkerRefs(value, out = []) {
|
|
6083
|
+
if (isSecretMarker(value)) {
|
|
6084
|
+
out.push(value.$secret);
|
|
6085
|
+
return out;
|
|
6086
|
+
}
|
|
6087
|
+
if (Array.isArray(value)) for (const item of value) collectSecretMarkerRefs(item, out);
|
|
6088
|
+
else if (isRecord$2(value)) for (const child of Object.values(value)) collectSecretMarkerRefs(child, out);
|
|
6089
|
+
return out;
|
|
6090
|
+
}
|
|
6091
|
+
async function storedValueEquals(secrets, marker, candidate) {
|
|
6092
|
+
const resolved = (await secrets.resolve([marker.$secret]))[marker.$secret];
|
|
6093
|
+
return resolved?.kind === "value" && resolved.value === candidate;
|
|
6094
|
+
}
|
|
6095
|
+
async function writeLeaf(ctx, incoming, stored, fieldPath) {
|
|
6096
|
+
const intent = classifySecretWrite(incoming);
|
|
6097
|
+
const ref = ctx.secrets.ref(ctx.scope, fieldPath);
|
|
6098
|
+
const storedIsOurs = isSecretMarker(stored) && stored.$secret === ref;
|
|
6099
|
+
if (intent.kind === "keep") return KEEP;
|
|
6100
|
+
if (intent.kind === "set" && !ctx.operatorWrite && typeof stored === "string" && stored === intent.value) return KEEP;
|
|
6101
|
+
if (intent.kind === "clear") {
|
|
6102
|
+
if (storedIsOurs) ctx.deletes.push(ref);
|
|
6103
|
+
return {
|
|
6104
|
+
kind: "value",
|
|
6105
|
+
value: null
|
|
6106
|
+
};
|
|
6107
|
+
}
|
|
6108
|
+
if (storedIsOurs && await storedValueEquals(ctx.secrets, stored, intent.value)) return {
|
|
6109
|
+
kind: "value",
|
|
6110
|
+
value: stored
|
|
6111
|
+
};
|
|
6112
|
+
try {
|
|
6113
|
+
await ctx.secrets.put(ref, intent.value);
|
|
6114
|
+
} catch (err) {
|
|
6115
|
+
throw new KeychainWriteRefusedError(fieldPath, err);
|
|
6116
|
+
}
|
|
6117
|
+
return {
|
|
6118
|
+
kind: "value",
|
|
6119
|
+
value: makeSecretMarker(ref)
|
|
6120
|
+
};
|
|
6121
|
+
}
|
|
6122
|
+
/** Apply a member result onto `out`: KEEP restores the stored member, or removes it. */
|
|
6123
|
+
function applyMember(out, key, result, storedParent) {
|
|
6124
|
+
if (result.kind === "value") {
|
|
6125
|
+
out[key] = result.value;
|
|
6126
|
+
return;
|
|
6127
|
+
}
|
|
6128
|
+
if (Object.prototype.hasOwnProperty.call(storedParent, key)) out[key] = storedParent[key];
|
|
6129
|
+
else delete out[key];
|
|
6130
|
+
}
|
|
6131
|
+
async function writeMembers(ctx, children, incoming, stored, pathOf) {
|
|
6132
|
+
const out = { ...incoming };
|
|
6133
|
+
for (const [member, node] of children) applyMember(out, member, await writeNode(ctx, node, incoming[member], stored[member], pathOf(member)), stored);
|
|
6134
|
+
return out;
|
|
6135
|
+
}
|
|
6136
|
+
function rowId(row, idKey) {
|
|
6137
|
+
const raw = row[idKey];
|
|
6138
|
+
if (typeof raw === "string" && raw.length > 0) return raw;
|
|
6139
|
+
if (typeof raw === "number" && Number.isFinite(raw)) return String(raw);
|
|
6140
|
+
return null;
|
|
6141
|
+
}
|
|
6142
|
+
async function writeArray(ctx, node, incoming, stored, fieldPath) {
|
|
6143
|
+
const storedRows = Array.isArray(stored) ? stored.filter(isRecord$2) : [];
|
|
6144
|
+
if (!Array.isArray(incoming)) {
|
|
6145
|
+
ctx.deletes.push(...collectSecretMarkerRefs(storedRows));
|
|
6146
|
+
return {
|
|
6147
|
+
kind: "value",
|
|
6148
|
+
value: incoming
|
|
6149
|
+
};
|
|
6150
|
+
}
|
|
6151
|
+
const storedById = /* @__PURE__ */ new Map();
|
|
6152
|
+
for (const row of storedRows) {
|
|
6153
|
+
const id = rowId(row, node.idKey);
|
|
6154
|
+
if (id !== null) storedById.set(id, row);
|
|
6155
|
+
}
|
|
6156
|
+
const kept = /* @__PURE__ */ new Set();
|
|
6157
|
+
const rows = [];
|
|
6158
|
+
for (const row of incoming) {
|
|
6159
|
+
if (!isRecord$2(row)) {
|
|
6160
|
+
rows.push(row);
|
|
6161
|
+
continue;
|
|
6162
|
+
}
|
|
6163
|
+
const id = rowId(row, node.idKey) ?? ctx.mintId();
|
|
6164
|
+
kept.add(id);
|
|
6165
|
+
const withId = {
|
|
6166
|
+
...row,
|
|
6167
|
+
[node.idKey]: row[node.idKey] ?? id
|
|
6168
|
+
};
|
|
6169
|
+
if (rowId(withId, node.idKey) === null) withId[node.idKey] = id;
|
|
6170
|
+
const storedRow = storedById.get(id) ?? {};
|
|
6171
|
+
rows.push(await writeMembers(ctx, node.item, withId, storedRow, (member) => arrayItemFieldPath(fieldPath, id, member)));
|
|
6172
|
+
}
|
|
6173
|
+
for (const [id, row] of storedById) if (!kept.has(id)) ctx.deletes.push(...collectSecretMarkerRefs(row));
|
|
6174
|
+
return {
|
|
6175
|
+
kind: "value",
|
|
6176
|
+
value: rows
|
|
6177
|
+
};
|
|
6178
|
+
}
|
|
6179
|
+
async function writeNode(ctx, node, incoming, stored, fieldPath) {
|
|
6180
|
+
switch (node.kind) {
|
|
6181
|
+
case "leaf": return writeLeaf(ctx, incoming, stored, fieldPath);
|
|
6182
|
+
case "array": return writeArray(ctx, node, incoming, stored, fieldPath);
|
|
6183
|
+
case "object": {
|
|
6184
|
+
if (!isRecord$2(incoming)) {
|
|
6185
|
+
if (incoming === void 0) return KEEP;
|
|
6186
|
+
ctx.deletes.push(...collectSecretMarkerRefs(stored));
|
|
6187
|
+
return {
|
|
6188
|
+
kind: "value",
|
|
6189
|
+
value: incoming
|
|
6190
|
+
};
|
|
6191
|
+
}
|
|
6192
|
+
const storedObj = isRecord$2(stored) ? stored : {};
|
|
6193
|
+
return {
|
|
6194
|
+
kind: "value",
|
|
6195
|
+
value: await writeMembers(ctx, node.children, incoming, storedObj, (m) => `${fieldPath}.${m}`)
|
|
6196
|
+
};
|
|
6197
|
+
}
|
|
6198
|
+
}
|
|
6199
|
+
}
|
|
6200
|
+
/** Split a perNode-scoped key (`key@nodeId`). */
|
|
6201
|
+
function splitNodeKey(key) {
|
|
6202
|
+
const at = key.indexOf("@");
|
|
6203
|
+
return at <= 0 ? {
|
|
6204
|
+
base: key,
|
|
6205
|
+
nodeId: null
|
|
6206
|
+
} : {
|
|
6207
|
+
base: key.slice(0, at),
|
|
6208
|
+
nodeId: key.slice(at + 1)
|
|
6209
|
+
};
|
|
6210
|
+
}
|
|
6211
|
+
/** Rewrite a settings patch so no secret value reaches the blob. See the file doc. */
|
|
6212
|
+
async function transformSecretWrite(input) {
|
|
6213
|
+
const deletes = [];
|
|
6214
|
+
const base = {
|
|
6215
|
+
secrets: input.secrets,
|
|
6216
|
+
mintId: input.mintId ?? defaultMintId,
|
|
6217
|
+
deletes,
|
|
6218
|
+
operatorWrite: input.operatorWrite === true
|
|
6219
|
+
};
|
|
6220
|
+
const out = {};
|
|
6221
|
+
for (const [key, incoming] of Object.entries(input.patch)) {
|
|
6222
|
+
const { base: baseKey, nodeId } = splitNodeKey(key);
|
|
6223
|
+
const node = input.tree.get(baseKey);
|
|
6224
|
+
if (node === void 0) {
|
|
6225
|
+
out[key] = incoming;
|
|
6226
|
+
continue;
|
|
6227
|
+
}
|
|
6228
|
+
const scope = nodeId !== null && nodeId.length > 0 ? {
|
|
6229
|
+
kind: "node",
|
|
6230
|
+
nodeId
|
|
6231
|
+
} : input.scope ?? globalSecretScope();
|
|
6232
|
+
const result = await writeNode({
|
|
6233
|
+
...base,
|
|
6234
|
+
scope
|
|
6235
|
+
}, node, incoming, input.stored[key], baseKey);
|
|
6236
|
+
if (result.kind === "value") out[key] = result.value;
|
|
6237
|
+
}
|
|
6238
|
+
return {
|
|
6239
|
+
patch: out,
|
|
6240
|
+
afterWrite: async () => {
|
|
6241
|
+
if (deletes.length === 0) return { orphaned: [] };
|
|
6242
|
+
try {
|
|
6243
|
+
await input.secrets.delete([...new Set(deletes)]);
|
|
6244
|
+
return { orphaned: [] };
|
|
6245
|
+
} catch {
|
|
6246
|
+
return { orphaned: [...new Set(deletes)] };
|
|
6247
|
+
}
|
|
6248
|
+
}
|
|
6249
|
+
};
|
|
6250
|
+
}
|
|
6251
|
+
/**
|
|
6252
|
+
* Replace every marker in `value` with its keychain value. Returns the SAME
|
|
6253
|
+
* reference when there is no marker (no allocation, no keychain call).
|
|
6254
|
+
*/
|
|
6255
|
+
async function resolveSecretMarkers(value, secrets) {
|
|
6256
|
+
const refs = collectSecretMarkerRefs(value);
|
|
6257
|
+
if (refs.length === 0) return {
|
|
6258
|
+
value,
|
|
6259
|
+
unresolved: []
|
|
6260
|
+
};
|
|
6261
|
+
const answers = await secrets.resolve(refs);
|
|
6262
|
+
const unresolved = [];
|
|
6263
|
+
for (const ref of new Set(refs)) {
|
|
6264
|
+
const answer = answers[ref];
|
|
6265
|
+
if (answer === void 0) unresolved.push({
|
|
6266
|
+
ref,
|
|
6267
|
+
reason: "not-initialized"
|
|
6268
|
+
});
|
|
6269
|
+
else if (answer.kind === "unavailable") unresolved.push({
|
|
6270
|
+
ref,
|
|
6271
|
+
reason: answer.reason
|
|
6272
|
+
});
|
|
6273
|
+
else if (answer.kind === "missing" || answer.kind === "forbidden") unresolved.push({
|
|
6274
|
+
ref,
|
|
6275
|
+
reason: answer.kind
|
|
6276
|
+
});
|
|
6277
|
+
}
|
|
6278
|
+
const substitute = (v) => {
|
|
6279
|
+
if (isSecretMarker(v)) {
|
|
6280
|
+
const answer = answers[v.$secret];
|
|
6281
|
+
return answer?.kind === "value" ? {
|
|
6282
|
+
keep: true,
|
|
6283
|
+
value: answer.value
|
|
6284
|
+
} : {
|
|
6285
|
+
keep: false,
|
|
6286
|
+
value: void 0
|
|
6287
|
+
};
|
|
6288
|
+
}
|
|
6289
|
+
if (Array.isArray(v)) {
|
|
6290
|
+
const items = [];
|
|
6291
|
+
for (const item of v) {
|
|
6292
|
+
const s = substitute(item);
|
|
6293
|
+
if (s.keep) items.push(s.value);
|
|
6294
|
+
}
|
|
6295
|
+
return {
|
|
6296
|
+
keep: true,
|
|
6297
|
+
value: items
|
|
6298
|
+
};
|
|
6299
|
+
}
|
|
6300
|
+
if (isRecord$2(v)) {
|
|
6301
|
+
const out = {};
|
|
6302
|
+
for (const [k, child] of Object.entries(v)) {
|
|
6303
|
+
const s = substitute(child);
|
|
6304
|
+
if (s.keep) out[k] = s.value;
|
|
6305
|
+
}
|
|
6306
|
+
return {
|
|
6307
|
+
keep: true,
|
|
6308
|
+
value: out
|
|
6309
|
+
};
|
|
6310
|
+
}
|
|
6311
|
+
return {
|
|
6312
|
+
keep: true,
|
|
6313
|
+
value: v
|
|
6314
|
+
};
|
|
6315
|
+
};
|
|
6316
|
+
return {
|
|
6317
|
+
value: substitute(value).value,
|
|
6318
|
+
unresolved
|
|
6319
|
+
};
|
|
6320
|
+
}
|
|
6321
|
+
function touchesTree(tree, patch) {
|
|
6322
|
+
if (tree.size === 0) return false;
|
|
6323
|
+
for (const key of Object.keys(patch)) {
|
|
6324
|
+
const at = key.indexOf("@");
|
|
6325
|
+
if (tree.has(at > 0 ? key.slice(0, at) : key)) return true;
|
|
6326
|
+
}
|
|
6327
|
+
return false;
|
|
6328
|
+
}
|
|
6329
|
+
/** The blob as stored now; a failed read REFUSES the write instead of guessing. */
|
|
6330
|
+
async function readStoredAddonBlob(raw) {
|
|
6331
|
+
const threeWay = raw.readAddonStoreResult;
|
|
6332
|
+
if (threeWay === void 0) return raw.readAddonStore();
|
|
6333
|
+
const result = await threeWay.call(raw);
|
|
6334
|
+
if (result.kind === "failed") throw new Error(`settings write refused: the stored blob could not be read (${result.error})`);
|
|
6335
|
+
return result.kind === "missing" ? {} : result.value;
|
|
6336
|
+
}
|
|
6337
|
+
function createSecretAwareSettings(raw, opts) {
|
|
6338
|
+
const chains = /* @__PURE__ */ new Map();
|
|
6339
|
+
const serialize = (key, fn) => {
|
|
6340
|
+
const next = (chains.get(key) ?? Promise.resolve()).then(fn, fn);
|
|
6341
|
+
const tail = next.catch(() => void 0);
|
|
6342
|
+
chains.set(key, tail);
|
|
6343
|
+
tail.then(() => {
|
|
6344
|
+
if (chains.get(key) === tail) chains.delete(key);
|
|
6345
|
+
});
|
|
6346
|
+
return next;
|
|
6347
|
+
};
|
|
6348
|
+
const write = async (chainKey, tree, scope, patch, readStored, rawWrite) => {
|
|
6349
|
+
if (!touchesTree(tree, patch)) return rawWrite(patch);
|
|
6350
|
+
return serialize(chainKey, async () => {
|
|
6351
|
+
const stored = await readStored();
|
|
6352
|
+
const result = await transformSecretWrite({
|
|
6353
|
+
tree,
|
|
6354
|
+
secrets: opts.secrets,
|
|
6355
|
+
patch,
|
|
6356
|
+
stored,
|
|
6357
|
+
...scope !== void 0 ? { scope } : {},
|
|
6358
|
+
operatorWrite: opts.isOperatorWrite?.() === true
|
|
6359
|
+
});
|
|
6360
|
+
if (Object.keys(result.patch).length > 0) await rawWrite(result.patch);
|
|
6361
|
+
const { orphaned } = await result.afterWrite();
|
|
6362
|
+
if (orphaned.length > 0) opts.onOrphaned(orphaned);
|
|
6363
|
+
});
|
|
6364
|
+
};
|
|
6365
|
+
const wrapped = {
|
|
6366
|
+
writeAddonStore: (patch) => write("addon", opts.addonTree(), void 0, patch, () => readStoredAddonBlob(raw), (p) => raw.writeAddonStore(p)),
|
|
6367
|
+
writeDeviceStore: (deviceId, patch) => write(`device:${deviceId}`, opts.deviceTree(), {
|
|
6368
|
+
kind: "device",
|
|
6369
|
+
deviceId
|
|
6370
|
+
}, patch, () => raw.readDeviceStore(deviceId), (p) => raw.writeDeviceStore(deviceId, p))
|
|
6371
|
+
};
|
|
6372
|
+
return new Proxy(raw, { get(target, prop, receiver) {
|
|
6373
|
+
if (prop === "writeAddonStore") return wrapped.writeAddonStore;
|
|
6374
|
+
if (prop === "writeDeviceStore") return wrapped.writeDeviceStore;
|
|
6375
|
+
const value = Reflect.get(target, prop, receiver);
|
|
6376
|
+
return typeof value === "function" ? value.bind(target) : value;
|
|
6377
|
+
} });
|
|
6378
|
+
}
|
|
6379
|
+
/** The context the addon sees: identical, except that its settings writes are secret-aware. */
|
|
6380
|
+
function withSecretAwareSettings(context, opts) {
|
|
6381
|
+
const raw = context.settings;
|
|
6382
|
+
if (raw === void 0) return context;
|
|
6383
|
+
const settings = createSecretAwareSettings(raw, opts);
|
|
6384
|
+
return new Proxy(context, { get(target, prop, receiver) {
|
|
6385
|
+
if (prop === "settings") return settings;
|
|
6386
|
+
return Reflect.get(target, prop, receiver);
|
|
6387
|
+
} });
|
|
6388
|
+
}
|
|
6389
|
+
var LEAF = { kind: "leaf" };
|
|
6390
|
+
var DEFAULT_ITEM_ID_KEY = "id";
|
|
6391
|
+
function collectFields(fields, out) {
|
|
6392
|
+
for (const field of fields) {
|
|
6393
|
+
if (field.type === "group") {
|
|
6394
|
+
collectFields(field.fields, out);
|
|
6395
|
+
continue;
|
|
6396
|
+
}
|
|
6397
|
+
if (field.type === "sub-tabs") {
|
|
6398
|
+
for (const tab of field.tabs) collectFields(tab.fields, out);
|
|
6399
|
+
continue;
|
|
6400
|
+
}
|
|
6401
|
+
if (field.type === "editable-array") {
|
|
6402
|
+
const item = /* @__PURE__ */ new Map();
|
|
6403
|
+
for (const itemField of field.itemFields) if ("key" in itemField && isKeychainStoredField(itemField)) item.set(itemField.key, LEAF);
|
|
6404
|
+
if (item.size > 0) out.set(field.key, {
|
|
6405
|
+
kind: "array",
|
|
6406
|
+
idKey: field.itemIdKey ?? DEFAULT_ITEM_ID_KEY,
|
|
6407
|
+
item
|
|
6408
|
+
});
|
|
6409
|
+
continue;
|
|
6410
|
+
}
|
|
6411
|
+
if (!("key" in field) || typeof field.key !== "string") continue;
|
|
6412
|
+
if (isKeychainStoredField(field)) out.set(field.key, LEAF);
|
|
6413
|
+
}
|
|
6414
|
+
}
|
|
6415
|
+
/** The secret tree a settings schema declares. */
|
|
6416
|
+
function secretTreeFromSchema(schema) {
|
|
6417
|
+
const out = /* @__PURE__ */ new Map();
|
|
6418
|
+
if (schema === null) return out;
|
|
6419
|
+
for (const section of schema.sections) collectFields(section.fields, out);
|
|
6420
|
+
return out;
|
|
6421
|
+
}
|
|
6422
|
+
/** Parse `a.b[id].c` into segments; throws on a malformed path (a declaration bug). */
|
|
6423
|
+
function parseSecretStatePath(path) {
|
|
6424
|
+
const segments = [];
|
|
6425
|
+
for (const raw of path.split(".")) {
|
|
6426
|
+
const m = /^([^[\]]+)(?:\[([^[\]]+)\])?$/.exec(raw);
|
|
6427
|
+
if (m === null || m[1] === void 0) throw new Error(`secretStatePaths: malformed path "${path}"`);
|
|
6428
|
+
segments.push(m[2] !== void 0 ? {
|
|
6429
|
+
key: m[1],
|
|
6430
|
+
idKey: m[2]
|
|
6431
|
+
} : { key: m[1] });
|
|
6432
|
+
}
|
|
6433
|
+
if (segments.length === 0) throw new Error(`secretStatePaths: empty path`);
|
|
6434
|
+
if (segments[segments.length - 1]?.idKey !== void 0) throw new Error(`secretStatePaths: "${path}" ends on an array — name the member that is secret`);
|
|
6435
|
+
return segments;
|
|
6436
|
+
}
|
|
6437
|
+
function insert(into, segments) {
|
|
6438
|
+
const [head, ...rest] = segments;
|
|
6439
|
+
if (head === void 0) return;
|
|
6440
|
+
if (rest.length === 0) {
|
|
6441
|
+
into.set(head.key, LEAF);
|
|
6442
|
+
return;
|
|
6443
|
+
}
|
|
6444
|
+
const existing = into.get(head.key);
|
|
6445
|
+
if (head.idKey !== void 0) {
|
|
6446
|
+
const item = new Map(existing?.kind === "array" ? existing.item : []);
|
|
6447
|
+
insert(item, rest);
|
|
6448
|
+
into.set(head.key, {
|
|
6449
|
+
kind: "array",
|
|
6450
|
+
idKey: head.idKey,
|
|
6451
|
+
item
|
|
6452
|
+
});
|
|
6453
|
+
return;
|
|
6454
|
+
}
|
|
6455
|
+
const children = new Map(existing?.kind === "object" ? existing.children : []);
|
|
6456
|
+
insert(children, rest);
|
|
6457
|
+
into.set(head.key, {
|
|
6458
|
+
kind: "object",
|
|
6459
|
+
children
|
|
6460
|
+
});
|
|
6461
|
+
}
|
|
6462
|
+
/** Add hidden-state paths (`secretStatePaths`) to a schema-derived tree. */
|
|
6463
|
+
function mergeSecretStatePaths(tree, paths) {
|
|
6464
|
+
if (paths.length === 0) return tree;
|
|
6465
|
+
const out = new Map(tree);
|
|
6466
|
+
for (const path of paths) insert(out, parseSecretStatePath(path));
|
|
6467
|
+
return out;
|
|
6468
|
+
}
|
|
6469
|
+
/** First retry of a secret the keychain could not serve; doubles to {@link SECRET_RETRY_MAX_MS}. */
|
|
6470
|
+
var SECRET_RETRY_FIRST_MS = 5e3;
|
|
6471
|
+
var SECRET_RETRY_MAX_MS = 5 * 6e4;
|
|
6472
|
+
/** Coalesces a burst of `keychain.changed` events into one re-resolve. */
|
|
6473
|
+
var SECRET_CHANGE_DEBOUNCE_MS = 250;
|
|
5938
6474
|
/**
|
|
5939
6475
|
* Base class for CamStack addons. Eliminates settings boilerplate:
|
|
5940
6476
|
*
|
|
@@ -6004,6 +6540,25 @@ var BaseAddon = class {
|
|
|
6004
6540
|
settingsStoreReady = false;
|
|
6005
6541
|
/** Default config values. Provided via constructor. */
|
|
6006
6542
|
defaults;
|
|
6543
|
+
/**
|
|
6544
|
+
* Hidden-state paths that hold secrets (D787) — values the addon writes
|
|
6545
|
+
* itself (`updateGlobalSettings`, `state()`) that no form field declares.
|
|
6546
|
+
* Stored in the keychain exactly like a `password` field. Syntax:
|
|
6547
|
+
* `'snapshotSigningKey'`, `'identity.pincode'`, `'tokens[userId].accessToken'`
|
|
6548
|
+
* (`key[<id field>]` addresses array items by id, never by index).
|
|
6549
|
+
*/
|
|
6550
|
+
secretStatePaths = [];
|
|
6551
|
+
_addonSecretTree = null;
|
|
6552
|
+
_deviceSecretTree = null;
|
|
6553
|
+
/** Refs the last resolved config pointed at — a change to one re-resolves. */
|
|
6554
|
+
_configSecretRefs = /* @__PURE__ */ new Set();
|
|
6555
|
+
_unresolvedSecrets = [];
|
|
6556
|
+
_secretRetryTimer = null;
|
|
6557
|
+
_secretRetryDelayMs = SECRET_RETRY_FIRST_MS;
|
|
6558
|
+
_secretChangeTimer = null;
|
|
6559
|
+
_secretChangeUnsub = null;
|
|
6560
|
+
/** >0 while an OPERATOR's settings write is being applied. */
|
|
6561
|
+
_operatorWriteDepth = 0;
|
|
6007
6562
|
constructor(defaults) {
|
|
6008
6563
|
this.defaults = defaults;
|
|
6009
6564
|
this._config = { ...defaults };
|
|
@@ -6039,8 +6594,18 @@ var BaseAddon = class {
|
|
|
6039
6594
|
return this._config;
|
|
6040
6595
|
}
|
|
6041
6596
|
async initialize(context) {
|
|
6042
|
-
|
|
6597
|
+
const secrets = context.secrets;
|
|
6598
|
+
this._ctx = secrets !== void 0 ? withSecretAwareSettings(context, {
|
|
6599
|
+
secrets,
|
|
6600
|
+
addonTree: () => this.addonSecretTree(),
|
|
6601
|
+
deviceTree: () => this.deviceSecretTree(),
|
|
6602
|
+
onOrphaned: (refs) => context.logger.warn("keychain refs dropped by a settings write could not be deleted", { meta: { refs: [...refs] } }),
|
|
6603
|
+
isOperatorWrite: () => this._operatorWriteDepth > 0
|
|
6604
|
+
}) : context;
|
|
6043
6605
|
await this.resolveConfig();
|
|
6606
|
+
if (secrets !== void 0) this._secretChangeUnsub = secrets.onChange((ref) => {
|
|
6607
|
+
if (this._configSecretRefs.has(ref)) this.scheduleSecretReresolve(SECRET_CHANGE_DEBOUNCE_MS);
|
|
6608
|
+
});
|
|
6044
6609
|
const result = await this.onInitialize();
|
|
6045
6610
|
this.emitLifecycle(EventCategory.AddonStarted);
|
|
6046
6611
|
const normalized = normalizeAddonInitResult(result);
|
|
@@ -6073,6 +6638,12 @@ var BaseAddon = class {
|
|
|
6073
6638
|
*/
|
|
6074
6639
|
async onHubReachable() {}
|
|
6075
6640
|
async shutdown() {
|
|
6641
|
+
this._secretChangeUnsub?.();
|
|
6642
|
+
this._secretChangeUnsub = null;
|
|
6643
|
+
if (this._secretRetryTimer !== null) clearTimeout(this._secretRetryTimer);
|
|
6644
|
+
if (this._secretChangeTimer !== null) clearTimeout(this._secretChangeTimer);
|
|
6645
|
+
this._secretRetryTimer = null;
|
|
6646
|
+
this._secretChangeTimer = null;
|
|
6076
6647
|
this.emitLifecycle(EventCategory.AddonStopped);
|
|
6077
6648
|
if (this.autoEmitReadiness) this.emitReadinessForProviders("down");
|
|
6078
6649
|
await this.onShutdown();
|
|
@@ -6151,7 +6722,7 @@ var BaseAddon = class {
|
|
|
6151
6722
|
return hydrateSchema(schema, overlay ? {
|
|
6152
6723
|
...projected,
|
|
6153
6724
|
...overlay
|
|
6154
|
-
} : projected);
|
|
6725
|
+
} : projected, { inlineSecretsAsViews: true });
|
|
6155
6726
|
}
|
|
6156
6727
|
/**
|
|
6157
6728
|
* The integration-level view of this addon's settings: exactly the sections
|
|
@@ -6200,7 +6771,7 @@ var BaseAddon = class {
|
|
|
6200
6771
|
return hydrateSchema({
|
|
6201
6772
|
...schema,
|
|
6202
6773
|
sections
|
|
6203
|
-
}, projected);
|
|
6774
|
+
}, projected, { inlineSecretsAsViews: true });
|
|
6204
6775
|
}
|
|
6205
6776
|
/**
|
|
6206
6777
|
* The raw addon store PROJECTED onto the target node's bare per-node keys:
|
|
@@ -6254,18 +6825,50 @@ var BaseAddon = class {
|
|
|
6254
6825
|
value: result.value[key]
|
|
6255
6826
|
};
|
|
6256
6827
|
}
|
|
6828
|
+
/**
|
|
6829
|
+
* The OPERATOR's write — a settings form or an admin API call, dispatched by
|
|
6830
|
+
* the kernel. Identical to {@link updateGlobalSettings}, except that a secret
|
|
6831
|
+
* the operator sends is stored as sent even when it equals a pre-keychain
|
|
6832
|
+
* inline value: the operator re-entering a password is a change, an addon
|
|
6833
|
+
* writing back what it read is not (D787).
|
|
6834
|
+
*/
|
|
6835
|
+
async updateGlobalSettingsAsOperator(patch, nodeId) {
|
|
6836
|
+
this._operatorWriteDepth++;
|
|
6837
|
+
try {
|
|
6838
|
+
await this.applyGlobalPatch(patch, nodeId);
|
|
6839
|
+
} finally {
|
|
6840
|
+
this._operatorWriteDepth--;
|
|
6841
|
+
}
|
|
6842
|
+
}
|
|
6257
6843
|
async updateGlobalSettings(patch, nodeId) {
|
|
6844
|
+
await this.applyGlobalPatch(patch, nodeId);
|
|
6845
|
+
}
|
|
6846
|
+
/**
|
|
6847
|
+
* REMOVE stored secrets — their keychain values and their markers (D787).
|
|
6848
|
+
*
|
|
6849
|
+
* Writing `''` to a secret field KEEPS what is stored (an empty string is
|
|
6850
|
+
* what a defaults fallback writes back, and it must never destroy a
|
|
6851
|
+
* credential), so code that means "forget this token" says so here. Without
|
|
6852
|
+
* a keychain (an older kernel) it writes `''`, as such code always did.
|
|
6853
|
+
*/
|
|
6854
|
+
async clearSecrets(keys, nodeId) {
|
|
6855
|
+
const tree = this.addonSecretTree();
|
|
6856
|
+
const keychain = this._ctx?.secrets !== void 0;
|
|
6857
|
+
const patch = {};
|
|
6858
|
+
for (const key of keys) patch[key] = keychain && tree.has(key) ? SECRET_CLEAR : "";
|
|
6859
|
+
await this.applyGlobalPatch(patch, nodeId);
|
|
6860
|
+
}
|
|
6861
|
+
async applyGlobalPatch(barePatch, nodeId) {
|
|
6258
6862
|
const keys = this.perNodeKeys();
|
|
6259
6863
|
const localNode = normalizeNodeId(this._ctx?.kernel?.localNodeId);
|
|
6260
6864
|
const target = normalizeNodeId(nodeId ?? this._ctx?.kernel?.localNodeId);
|
|
6261
|
-
const barePatch = patch;
|
|
6262
6865
|
const scoped = keys.size > 0 ? scopePatch(barePatch, keys, target) : barePatch;
|
|
6263
6866
|
await this._ctx?.settings?.writeAddonStore(scoped);
|
|
6264
6867
|
if (target !== localNode) return;
|
|
6265
6868
|
await this.resolveConfig();
|
|
6266
6869
|
await this.onConfigChanged();
|
|
6267
6870
|
this.emitLifecycle(EventCategory.AddonUpdated, { level: "global" });
|
|
6268
|
-
this.maybeAutoRestart(
|
|
6871
|
+
this.maybeAutoRestart(Object.keys(barePatch), this.globalSettingsSchema());
|
|
6269
6872
|
}
|
|
6270
6873
|
/**
|
|
6271
6874
|
* The set of field keys the global settings schema declares `perNode: true`
|
|
@@ -6290,7 +6893,7 @@ var BaseAddon = class {
|
|
|
6290
6893
|
* time to return its response before the addon is torn down and
|
|
6291
6894
|
* re-initialised by `AddonRegistryService.restartAddon`.
|
|
6292
6895
|
*/
|
|
6293
|
-
maybeAutoRestart(
|
|
6896
|
+
maybeAutoRestart(patchKeys, schema) {
|
|
6294
6897
|
if (!schema) return;
|
|
6295
6898
|
const restartKeys = /* @__PURE__ */ new Set();
|
|
6296
6899
|
for (const section of schema.sections) for (const field of section.fields) {
|
|
@@ -6298,13 +6901,13 @@ var BaseAddon = class {
|
|
|
6298
6901
|
if (field.requiresRestart) restartKeys.add(field.key);
|
|
6299
6902
|
}
|
|
6300
6903
|
if (restartKeys.size === 0) return;
|
|
6301
|
-
if (!
|
|
6904
|
+
if (!patchKeys.some((k) => restartKeys.has(k))) return;
|
|
6302
6905
|
const ctx = this._ctx;
|
|
6303
6906
|
if (!ctx) return;
|
|
6304
6907
|
const addonId = ctx.id;
|
|
6305
6908
|
setImmediate(() => {
|
|
6306
6909
|
ctx.api.addons?.restartAddon?.mutate({ addonId }).then(() => {
|
|
6307
|
-
ctx.logger.info("addon auto-restart triggered by restart-required setting change", { meta: { changedFields:
|
|
6910
|
+
ctx.logger.info("addon auto-restart triggered by restart-required setting change", { meta: { changedFields: patchKeys.filter((k) => restartKeys.has(k)) } });
|
|
6308
6911
|
}).catch((err) => {
|
|
6309
6912
|
ctx.logger.error("addon auto-restart failed", { meta: { error: err instanceof Error ? err.message : String(err) } });
|
|
6310
6913
|
});
|
|
@@ -6313,7 +6916,7 @@ var BaseAddon = class {
|
|
|
6313
6916
|
async getDeviceSettings(deviceId) {
|
|
6314
6917
|
const schema = this.deviceSettingsSchema();
|
|
6315
6918
|
if (!schema) return { sections: [] };
|
|
6316
|
-
return hydrateSchema(schema, await this._ctx?.settings?.readDeviceStore(deviceId) ?? {});
|
|
6919
|
+
return hydrateSchema(schema, await this._ctx?.settings?.readDeviceStore(deviceId) ?? {}, { inlineSecretsAsViews: true });
|
|
6317
6920
|
}
|
|
6318
6921
|
async updateDeviceSettings(deviceId, patch) {
|
|
6319
6922
|
await this._ctx?.settings?.writeDeviceStore(deviceId, patch);
|
|
@@ -6443,7 +7046,7 @@ var BaseAddon = class {
|
|
|
6443
7046
|
* selection at boot (absent scoped key ⇒ the constructor default wins).
|
|
6444
7047
|
*/
|
|
6445
7048
|
async resolveConfig() {
|
|
6446
|
-
const stored = await this.readAddonStoreWithRetry();
|
|
7049
|
+
const stored = await this.resolveStoredSecrets(await this.readAddonStoreWithRetry());
|
|
6447
7050
|
const perNode = this.perNodeKeys();
|
|
6448
7051
|
const localNode = normalizeNodeId(this._ctx?.kernel?.localNodeId);
|
|
6449
7052
|
const resolved = { ...this.defaults };
|
|
@@ -6468,7 +7071,7 @@ var BaseAddon = class {
|
|
|
6468
7071
|
key,
|
|
6469
7072
|
schema,
|
|
6470
7073
|
fallback,
|
|
6471
|
-
read: () => this.readAddonStoreWithRetry(),
|
|
7074
|
+
read: async () => this.resolveStoredSecrets(await this.readAddonStoreWithRetry()),
|
|
6472
7075
|
write: async (patch) => {
|
|
6473
7076
|
await this._ctx?.settings?.writeAddonStore(patch);
|
|
6474
7077
|
},
|
|
@@ -6485,7 +7088,7 @@ var BaseAddon = class {
|
|
|
6485
7088
|
key,
|
|
6486
7089
|
schema,
|
|
6487
7090
|
fallback,
|
|
6488
|
-
read: async () => await this._ctx?.settings?.readDeviceStore(deviceId) ?? {},
|
|
7091
|
+
read: async () => this.resolveStoredSecrets(await this._ctx?.settings?.readDeviceStore(deviceId) ?? {}, false),
|
|
6489
7092
|
write: async (patch) => {
|
|
6490
7093
|
await this._ctx?.settings?.writeDeviceStore(deviceId, patch);
|
|
6491
7094
|
},
|
|
@@ -6497,6 +7100,70 @@ var BaseAddon = class {
|
|
|
6497
7100
|
} })
|
|
6498
7101
|
});
|
|
6499
7102
|
}
|
|
7103
|
+
/** The addon store's secret tree: schema fields by TYPE, plus `secretStatePaths`. */
|
|
7104
|
+
addonSecretTree() {
|
|
7105
|
+
this._addonSecretTree ??= mergeSecretStatePaths(secretTreeFromSchema(this.globalSettingsSchema()), this.secretStatePaths);
|
|
7106
|
+
return this._addonSecretTree;
|
|
7107
|
+
}
|
|
7108
|
+
deviceSecretTree() {
|
|
7109
|
+
this._deviceSecretTree ??= secretTreeFromSchema(this.deviceSettingsSchema());
|
|
7110
|
+
return this._deviceSecretTree;
|
|
7111
|
+
}
|
|
7112
|
+
/**
|
|
7113
|
+
* Secrets of this addon's stored config that could not be resolved on the
|
|
7114
|
+
* last read, with why. Non-empty means the addon is running WITHOUT them —
|
|
7115
|
+
* an addon whose function needs one should report itself degraded rather
|
|
7116
|
+
* than start on an empty credential.
|
|
7117
|
+
*/
|
|
7118
|
+
get unresolvedSecrets() {
|
|
7119
|
+
return this._unresolvedSecrets;
|
|
7120
|
+
}
|
|
7121
|
+
/**
|
|
7122
|
+
* Substitute every keychain marker in a stored blob with its value. With no
|
|
7123
|
+
* keychain (no `ctx.secrets`) or no marker, the blob comes back unchanged.
|
|
7124
|
+
* An unresolvable value is LEFT OUT (never `''`), logged by ref — never by
|
|
7125
|
+
* value — and, when the cause can pass, retried with backoff. Nothing is
|
|
7126
|
+
* ever written back from here.
|
|
7127
|
+
*/
|
|
7128
|
+
async resolveStoredSecrets(blob, trackForConfig = true) {
|
|
7129
|
+
const secrets = this._ctx?.secrets;
|
|
7130
|
+
if (secrets === void 0) return blob;
|
|
7131
|
+
const refs = collectSecretMarkerRefs(blob);
|
|
7132
|
+
if (trackForConfig) this._configSecretRefs = new Set(refs);
|
|
7133
|
+
if (refs.length === 0) {
|
|
7134
|
+
if (trackForConfig) this._unresolvedSecrets = [];
|
|
7135
|
+
return blob;
|
|
7136
|
+
}
|
|
7137
|
+
const { value, unresolved } = await resolveSecretMarkers(blob, secrets);
|
|
7138
|
+
if (trackForConfig) {
|
|
7139
|
+
this._unresolvedSecrets = unresolved;
|
|
7140
|
+
if (unresolved.length > 0) {
|
|
7141
|
+
this._ctx?.logger?.error?.("secret unavailable — running without it, will retry", { meta: { secrets: unresolved.map((u) => ({
|
|
7142
|
+
ref: u.ref,
|
|
7143
|
+
reason: u.reason
|
|
7144
|
+
})) } });
|
|
7145
|
+
if (unresolved.some((u) => u.reason !== "missing" && u.reason !== "forbidden")) {
|
|
7146
|
+
this.scheduleSecretReresolve(this._secretRetryDelayMs);
|
|
7147
|
+
this._secretRetryDelayMs = Math.min(this._secretRetryDelayMs * 2, SECRET_RETRY_MAX_MS);
|
|
7148
|
+
}
|
|
7149
|
+
} else this._secretRetryDelayMs = SECRET_RETRY_FIRST_MS;
|
|
7150
|
+
}
|
|
7151
|
+
return value;
|
|
7152
|
+
}
|
|
7153
|
+
/** Re-resolve the config (a keychain-only change, or a retry) and apply it. */
|
|
7154
|
+
scheduleSecretReresolve(delayMs) {
|
|
7155
|
+
const timerOf = delayMs === SECRET_CHANGE_DEBOUNCE_MS ? "_secretChangeTimer" : "_secretRetryTimer";
|
|
7156
|
+
if (this[timerOf] !== null) return;
|
|
7157
|
+
const timer = setTimeout(() => {
|
|
7158
|
+
this[timerOf] = null;
|
|
7159
|
+
if (this._ctx === null) return;
|
|
7160
|
+
this.resolveConfig().then(() => this.onConfigChanged()).catch((err) => {
|
|
7161
|
+
this._ctx?.logger?.error?.("re-resolving secrets failed", { meta: { error: err instanceof Error ? err.message : String(err) } });
|
|
7162
|
+
});
|
|
7163
|
+
}, delayMs);
|
|
7164
|
+
timer.unref?.();
|
|
7165
|
+
this[timerOf] = timer;
|
|
7166
|
+
}
|
|
6500
7167
|
/**
|
|
6501
7168
|
* Wrap `ctx.settings.readAddonStore()` with a short retry budget so a
|
|
6502
7169
|
* transient settings-store outage (mid-restart of sqlite-settings, tsx-watch
|
|
@@ -7106,6 +7773,69 @@ method(object({ deviceId: number() }), array(StreamSourceEntrySchema)), method(o
|
|
|
7106
7773
|
kind: "mutation",
|
|
7107
7774
|
auth: "admin"
|
|
7108
7775
|
}), method(object({ deviceId: number() }), unknown().nullable()), method(object({ deviceId: number() }), RawStateResultSchema.nullable(), { auth: "protected" });
|
|
7776
|
+
function defOf(schema) {
|
|
7777
|
+
return schema._zod?.def ?? {};
|
|
7778
|
+
}
|
|
7779
|
+
function declaredHere(schema) {
|
|
7780
|
+
return globalRegistry.get(schema)?.secret === true;
|
|
7781
|
+
}
|
|
7782
|
+
/** Wrapper kinds whose `innerType` is the field itself. */
|
|
7783
|
+
var WRAPPERS = new Set([
|
|
7784
|
+
"optional",
|
|
7785
|
+
"nullable",
|
|
7786
|
+
"default",
|
|
7787
|
+
"prefault",
|
|
7788
|
+
"catch",
|
|
7789
|
+
"readonly",
|
|
7790
|
+
"nonoptional"
|
|
7791
|
+
]);
|
|
7792
|
+
/**
|
|
7793
|
+
* The schema layers that make up ONE field: the schema itself and every
|
|
7794
|
+
* wrapper below it (optional / default / nullable / readonly / catch), plus
|
|
7795
|
+
* both sides of a pipe (`z.preprocess` puts the real schema on `out`,
|
|
7796
|
+
* `.transform` on `in`).
|
|
7797
|
+
*/
|
|
7798
|
+
function layersOf(schema) {
|
|
7799
|
+
const out = [];
|
|
7800
|
+
const queue = [schema];
|
|
7801
|
+
while (queue.length > 0) {
|
|
7802
|
+
const s = queue.shift();
|
|
7803
|
+
if (!s || out.includes(s)) continue;
|
|
7804
|
+
out.push(s);
|
|
7805
|
+
const def = defOf(s);
|
|
7806
|
+
if (def.type !== void 0 && WRAPPERS.has(def.type) && def.innerType) queue.push(def.innerType);
|
|
7807
|
+
if (def.type === "pipe") {
|
|
7808
|
+
if (def.in) queue.push(def.in);
|
|
7809
|
+
if (def.out) queue.push(def.out);
|
|
7810
|
+
}
|
|
7811
|
+
}
|
|
7812
|
+
return out;
|
|
7813
|
+
}
|
|
7814
|
+
/** True when any layer of this field declares `.meta({ secret: true })`. */
|
|
7815
|
+
function isZodSecret(schema) {
|
|
7816
|
+
return layersOf(schema).some(declaredHere);
|
|
7817
|
+
}
|
|
7818
|
+
/**
|
|
7819
|
+
* Every declared secret path in a config schema: dotted keys, `[]` for "each
|
|
7820
|
+
* element of this array" (`connection.password`, `rows[].token`). A declared
|
|
7821
|
+
* object or array is reported as one path and not descended into — everything
|
|
7822
|
+
* under it is secret.
|
|
7823
|
+
*/
|
|
7824
|
+
function collectZodSecretPaths(schema, prefix = "") {
|
|
7825
|
+
if (isZodSecret(schema)) return prefix.length > 0 ? [prefix] : [];
|
|
7826
|
+
const paths = [];
|
|
7827
|
+
for (const layer of layersOf(schema)) {
|
|
7828
|
+
const def = defOf(layer);
|
|
7829
|
+
if (def.type === "object" && def.shape) for (const [key, child] of Object.entries(def.shape)) paths.push(...collectZodSecretPaths(child, prefix ? `${prefix}.${key}` : key));
|
|
7830
|
+
else if (def.type === "array" && def.element) paths.push(...collectZodSecretPaths(def.element, `${prefix}[]`));
|
|
7831
|
+
else if (def.type === "union" && def.options) for (const option of def.options) paths.push(...collectZodSecretPaths(option, prefix));
|
|
7832
|
+
else if (def.type === "intersection") {
|
|
7833
|
+
if (def.left) paths.push(...collectZodSecretPaths(def.left, prefix));
|
|
7834
|
+
if (def.right) paths.push(...collectZodSecretPaths(def.right, prefix));
|
|
7835
|
+
}
|
|
7836
|
+
}
|
|
7837
|
+
return [...new Set(paths)];
|
|
7838
|
+
}
|
|
7109
7839
|
/**
|
|
7110
7840
|
* Promise-based timer helpers — used everywhere the codebase needs to
|
|
7111
7841
|
* wait, back off, or schedule a retry. Before these helpers landed, each
|
|
@@ -14702,6 +15432,196 @@ id: union([string(), number()]) }), {
|
|
|
14702
15432
|
kind: "mutation",
|
|
14703
15433
|
auth: "admin"
|
|
14704
15434
|
});
|
|
15435
|
+
/**
|
|
15436
|
+
* `keychain` — the hub's encrypted store of secret values (D787).
|
|
15437
|
+
*
|
|
15438
|
+
* Settings blobs never hold a secret: they hold a marker
|
|
15439
|
+
* `{"$secret":"secret://<owner>/<scope>/<fieldPath>","v":1}` and the value
|
|
15440
|
+
* lives here, AES-256-GCM under a data key that a master key wraps. This cap
|
|
15441
|
+
* is the OWNER's door to its own values: every method is owner-checked
|
|
15442
|
+
* against the CALLER, never against anything the caller claims.
|
|
15443
|
+
*
|
|
15444
|
+
* Who the caller is: the transport stamps `callerAddonId` into the args of a
|
|
15445
|
+
* call that crossed a process (the parent `LocalChildRegistry` from the UDS
|
|
15446
|
+
* connection, the agent from its child's connection carried in
|
|
15447
|
+
* `$hub-cap-fwd`'s envelope). A stamp always overwrites; a wire call with no
|
|
15448
|
+
* stamp has its claim stripped. Only a hub in-process caller may state its own
|
|
15449
|
+
* identity — `ctx.secrets` does that with the addon id closed over. This is
|
|
15450
|
+
* identity against BUGS and misrouting, not against a malicious addon (every
|
|
15451
|
+
* runner is the same OS user): see the threat model in
|
|
15452
|
+
* `docs/design/2026-10-08-secrets-keychain.md`.
|
|
15453
|
+
*
|
|
15454
|
+
* `callerAddonId` is deliberately NOT in any input schema: the tRPC router
|
|
15455
|
+
* parses the input, so a session can never supply it, and the internal mount
|
|
15456
|
+
* floors every method to admin anyway (D240).
|
|
15457
|
+
*
|
|
15458
|
+
* Internal: addons reach it through `ctx.secrets`, never directly.
|
|
15459
|
+
*/
|
|
15460
|
+
/** Why a value cannot be served right now. Never folded into "missing". */
|
|
15461
|
+
var KeychainUnavailableReasonSchema = _enum([
|
|
15462
|
+
"key-missing",
|
|
15463
|
+
"wrong-key",
|
|
15464
|
+
"key-file-unreadable",
|
|
15465
|
+
"store-unavailable",
|
|
15466
|
+
"not-initialized",
|
|
15467
|
+
"decrypt-failed"
|
|
15468
|
+
]);
|
|
15469
|
+
var KeychainStateSchema = discriminatedUnion("state", [object({ state: literal("ready") }), object({
|
|
15470
|
+
state: literal("locked"),
|
|
15471
|
+
reason: KeychainUnavailableReasonSchema
|
|
15472
|
+
})]);
|
|
15473
|
+
var KeychainResolveEntrySchema = discriminatedUnion("kind", [
|
|
15474
|
+
object({
|
|
15475
|
+
kind: literal("value"),
|
|
15476
|
+
value: string(),
|
|
15477
|
+
version: number().int()
|
|
15478
|
+
}),
|
|
15479
|
+
object({ kind: literal("missing") }),
|
|
15480
|
+
object({
|
|
15481
|
+
kind: literal("unavailable"),
|
|
15482
|
+
reason: KeychainUnavailableReasonSchema
|
|
15483
|
+
}),
|
|
15484
|
+
object({ kind: literal("forbidden") })
|
|
15485
|
+
]);
|
|
15486
|
+
var KeychainResolveResultSchema = record(string(), KeychainResolveEntrySchema);
|
|
15487
|
+
/** Metadata of one stored value — never the value. */
|
|
15488
|
+
var KeychainSecretMetaSchema = object({
|
|
15489
|
+
ref: string(),
|
|
15490
|
+
owner: string(),
|
|
15491
|
+
/** Formatted scope (`global`, `node/<id>`, `device/<id>`, …). */
|
|
15492
|
+
scope: string(),
|
|
15493
|
+
fieldPath: string(),
|
|
15494
|
+
version: number().int(),
|
|
15495
|
+
createdAt: number(),
|
|
15496
|
+
updatedAt: number(),
|
|
15497
|
+
/** `addon:<id>` | `user:<id>` | `system`. */
|
|
15498
|
+
updatedBy: string(),
|
|
15499
|
+
/** Coarse — written at most once an hour per ref. `null` = never read. */
|
|
15500
|
+
lastReadAt: number().nullable()
|
|
15501
|
+
});
|
|
15502
|
+
var RefListSchema = array(string().min(1)).max(512);
|
|
15503
|
+
method(object({
|
|
15504
|
+
ref: string().min(1),
|
|
15505
|
+
value: string().min(1)
|
|
15506
|
+
}), object({
|
|
15507
|
+
ref: string(),
|
|
15508
|
+
version: number().int()
|
|
15509
|
+
}), {
|
|
15510
|
+
kind: "mutation",
|
|
15511
|
+
auth: "admin"
|
|
15512
|
+
}), method(object({ refs: RefListSchema }), KeychainResolveResultSchema, { auth: "admin" }), method(object({ refs: RefListSchema }), object({ deleted: number().int() }), {
|
|
15513
|
+
kind: "mutation",
|
|
15514
|
+
auth: "admin"
|
|
15515
|
+
}), method(object({}), array(KeychainSecretMetaSchema).readonly(), { auth: "admin" }), method(object({}), KeychainStateSchema, { auth: "admin" });
|
|
15516
|
+
var KeychainKeySourceSchema = object({
|
|
15517
|
+
kind: _enum([
|
|
15518
|
+
"config-file",
|
|
15519
|
+
"previous-config-file",
|
|
15520
|
+
"platform",
|
|
15521
|
+
"default-file"
|
|
15522
|
+
]),
|
|
15523
|
+
/** File sources only — a path is not a secret. */
|
|
15524
|
+
path: string().optional(),
|
|
15525
|
+
/**
|
|
15526
|
+
* True when a whole-volume backup of the data directory carries this key
|
|
15527
|
+
* next to the database it protects (the default file). The page warns.
|
|
15528
|
+
*/
|
|
15529
|
+
sharesBackupWithDatabase: boolean()
|
|
15530
|
+
});
|
|
15531
|
+
var KeychainStatusSchema = object({
|
|
15532
|
+
keychain: KeychainStateSchema,
|
|
15533
|
+
/** The source of the master key in use; `null` while locked. */
|
|
15534
|
+
keySource: KeychainKeySourceSchema.nullable(),
|
|
15535
|
+
/** The source configured to be primary — differs from `keySource` while a rotation is pending. */
|
|
15536
|
+
configuredSource: KeychainKeySourceSchema,
|
|
15537
|
+
/** Short fingerprint of the master key in use (`HMAC(KEK, label)`, 16 hex). */
|
|
15538
|
+
fingerprint: string().nullable(),
|
|
15539
|
+
activeKeyId: string().nullable(),
|
|
15540
|
+
/**
|
|
15541
|
+
* The keychain unlocked with a NON-primary source: the configured primary
|
|
15542
|
+
* key is not the one that wraps the data key yet. `rotateMasterKey` moves it.
|
|
15543
|
+
*/
|
|
15544
|
+
rotationPending: boolean(),
|
|
15545
|
+
/** Wrapped copies of the data key under a previous master key, kept until purged. */
|
|
15546
|
+
retiredWraps: number().int(),
|
|
15547
|
+
recoveryKeyDownloadedAt: number().nullable(),
|
|
15548
|
+
secretCount: number().int()
|
|
15549
|
+
});
|
|
15550
|
+
/**
|
|
15551
|
+
* Whether a stored value is still pointed at by its owner's settings.
|
|
15552
|
+
* `unknown` is a first-class answer: a scope whose blob could not be read is
|
|
15553
|
+
* never reported as an orphan (and never deleted as one).
|
|
15554
|
+
*/
|
|
15555
|
+
var KeychainSecretUsageSchema = _enum([
|
|
15556
|
+
"in-use",
|
|
15557
|
+
"orphan",
|
|
15558
|
+
"unknown"
|
|
15559
|
+
]);
|
|
15560
|
+
var KeychainAdminSecretSchema = KeychainSecretMetaSchema.extend({ usage: KeychainSecretUsageSchema });
|
|
15561
|
+
var KeychainAuditActionSchema = _enum([
|
|
15562
|
+
"put",
|
|
15563
|
+
"delete",
|
|
15564
|
+
"reveal",
|
|
15565
|
+
"rotate-master-key",
|
|
15566
|
+
"purge-retired-keys",
|
|
15567
|
+
"download-recovery-key",
|
|
15568
|
+
"delete-orphans",
|
|
15569
|
+
"reset",
|
|
15570
|
+
"initialize"
|
|
15571
|
+
]);
|
|
15572
|
+
var KeychainAuditEntrySchema = object({
|
|
15573
|
+
id: string(),
|
|
15574
|
+
at: number(),
|
|
15575
|
+
action: KeychainAuditActionSchema,
|
|
15576
|
+
/** `addon:<id>` | `user:<id>` | `system`. */
|
|
15577
|
+
actor: string(),
|
|
15578
|
+
ref: string().nullable(),
|
|
15579
|
+
detail: string().nullable()
|
|
15580
|
+
});
|
|
15581
|
+
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({
|
|
15582
|
+
value: string(),
|
|
15583
|
+
version: number().int()
|
|
15584
|
+
}), {
|
|
15585
|
+
kind: "mutation",
|
|
15586
|
+
auth: "admin",
|
|
15587
|
+
caller: "required"
|
|
15588
|
+
}), method(object({ refs: array(string().min(1)).max(1e3) }), object({
|
|
15589
|
+
deleted: array(string()).readonly(),
|
|
15590
|
+
kept: array(object({
|
|
15591
|
+
ref: string(),
|
|
15592
|
+
usage: KeychainSecretUsageSchema
|
|
15593
|
+
})).readonly()
|
|
15594
|
+
}), {
|
|
15595
|
+
kind: "mutation",
|
|
15596
|
+
auth: "admin",
|
|
15597
|
+
caller: "required"
|
|
15598
|
+
}), method(object({}), object({
|
|
15599
|
+
fingerprint: string(),
|
|
15600
|
+
keySource: KeychainKeySourceSchema
|
|
15601
|
+
}), {
|
|
15602
|
+
kind: "mutation",
|
|
15603
|
+
auth: "admin",
|
|
15604
|
+
caller: "required"
|
|
15605
|
+
}), method(object({}), object({ purged: number().int() }), {
|
|
15606
|
+
kind: "mutation",
|
|
15607
|
+
auth: "admin",
|
|
15608
|
+
caller: "required"
|
|
15609
|
+
}), method(object({}), object({
|
|
15610
|
+
key: string(),
|
|
15611
|
+
fingerprint: string(),
|
|
15612
|
+
keySource: KeychainKeySourceSchema
|
|
15613
|
+
}), {
|
|
15614
|
+
kind: "mutation",
|
|
15615
|
+
auth: "admin",
|
|
15616
|
+
caller: "required"
|
|
15617
|
+
}), method(object({ confirm: literal("RESET KEYCHAIN") }), object({
|
|
15618
|
+
archivedCollection: string().nullable(),
|
|
15619
|
+
archived: number().int()
|
|
15620
|
+
}), {
|
|
15621
|
+
kind: "mutation",
|
|
15622
|
+
auth: "admin",
|
|
15623
|
+
caller: "required"
|
|
15624
|
+
});
|
|
14705
15625
|
method(_void(), object({
|
|
14706
15626
|
id: string(),
|
|
14707
15627
|
name: string(),
|
|
@@ -16040,7 +16960,11 @@ var DeviceRegisterPayloadSchema = object({
|
|
|
16040
16960
|
var DeviceRemovePayloadSchema = object({ deviceId: number() });
|
|
16041
16961
|
var DevicePersistConfigPayloadSchema = object({
|
|
16042
16962
|
deviceId: number(),
|
|
16043
|
-
data: record(string(), unknown())
|
|
16963
|
+
data: record(string(), unknown()),
|
|
16964
|
+
/** The paths the device's schema declares secret (D783), when the caller
|
|
16965
|
+
* knows them — those values are kept in the keychain, not the blob (D787).
|
|
16966
|
+
* Absent: the paths the device last reported at `registerDevice` apply. */
|
|
16967
|
+
secretConfigPaths: array(string()).optional()
|
|
16044
16968
|
});
|
|
16045
16969
|
/** What a migration actually did, per switch. `unreachable` is a first-class
|
|
16046
16970
|
* answer: a camera that could not be asked is not a camera that was silenced. */
|
|
@@ -23097,8 +24021,23 @@ var RetrainMacroClassSchema = _enum([
|
|
|
23097
24021
|
]);
|
|
23098
24022
|
/** A subject to learn, or a phantom to unlearn (taught by OMISSION). */
|
|
23099
24023
|
var RetrainAnnotationKindSchema = _enum(["subject", "model_error"]);
|
|
23100
|
-
/**
|
|
23101
|
-
|
|
24024
|
+
/**
|
|
24025
|
+
* Where a box came from. A machine-sourced box is a DRAFT on the page until
|
|
24026
|
+
* the operator confirms it; once saved it keeps its source as provenance.
|
|
24027
|
+
*
|
|
24028
|
+
* - `operator` — drawn by hand.
|
|
24029
|
+
* - `assist` — proposed by a detector run on the copy (the camera's own
|
|
24030
|
+
* model, or a larger teacher model).
|
|
24031
|
+
* - `pipeline` — the box the live pipeline actually drew on that frame, read
|
|
24032
|
+
* back from the track store (never a re-run).
|
|
24033
|
+
* - `llm` — proposed by a vision-capable LLM profile.
|
|
24034
|
+
*/
|
|
24035
|
+
var RetrainAnnotationSourceSchema = _enum([
|
|
24036
|
+
"operator",
|
|
24037
|
+
"assist",
|
|
24038
|
+
"pipeline",
|
|
24039
|
+
"llm"
|
|
24040
|
+
]);
|
|
23102
24041
|
/** Normalised `[0,1]` rectangle against the FULL frame — the canonical form. */
|
|
23103
24042
|
var RetrainBboxSchema = object({
|
|
23104
24043
|
x: number(),
|
|
@@ -23116,7 +24055,8 @@ var RetrainBboxSchema = object({
|
|
|
23116
24055
|
*/
|
|
23117
24056
|
var RetrainAnnotationSchema = object({
|
|
23118
24057
|
id: string(),
|
|
23119
|
-
|
|
24058
|
+
/** The frame's track. Absent on a recording still, which has none. */
|
|
24059
|
+
trackId: string().optional(),
|
|
23120
24060
|
deviceId: number(),
|
|
23121
24061
|
/** The COPY in retrain storage — never the source track's media key. */
|
|
23122
24062
|
mediaKey: string(),
|
|
@@ -23165,13 +24105,47 @@ var RetrainFrameCandidateSchema = object({
|
|
|
23165
24105
|
* fail, whatever became of the original. */
|
|
23166
24106
|
copied: boolean()
|
|
23167
24107
|
});
|
|
24108
|
+
/**
|
|
24109
|
+
* One box the live pipeline drew on a copied frame — what a correction starts
|
|
24110
|
+
* from. Derived when the frame is listed, from the track store: the subject
|
|
24111
|
+
* box recorded on the source media row when there is one, else the track
|
|
24112
|
+
* position nearest the frame's capture time. Never stored as an annotation
|
|
24113
|
+
* until the operator confirms it.
|
|
24114
|
+
*/
|
|
24115
|
+
var RetrainPipelineBoxSchema = object({
|
|
24116
|
+
/** Normalised `[0,1]` against the full frame. */
|
|
24117
|
+
bbox: RetrainBboxSchema,
|
|
24118
|
+
macroClass: RetrainMacroClassSchema,
|
|
24119
|
+
label: string().optional(),
|
|
24120
|
+
subLabel: string().optional(),
|
|
24121
|
+
/** The detection score of the position used, when it was recorded. */
|
|
24122
|
+
score: number().optional(),
|
|
24123
|
+
/** The root model that produced the track, when it was recorded. */
|
|
24124
|
+
modelId: string().optional(),
|
|
24125
|
+
trackId: string(),
|
|
24126
|
+
/** `subject-box`: recorded on this very frame. `position`: the track's
|
|
24127
|
+
* position nearest the capture time, `deltaMs` away. */
|
|
24128
|
+
basis: _enum(["subject-box", "position"]),
|
|
24129
|
+
deltaMs: number()
|
|
24130
|
+
});
|
|
24131
|
+
/**
|
|
24132
|
+
* Where a retrain frame came from: a TRACK's stored media (copy-on-select),
|
|
24133
|
+
* or the RECORDING at an instant — the frame a model saw nothing in has no
|
|
24134
|
+
* track at all.
|
|
24135
|
+
*/
|
|
24136
|
+
var RetrainFrameOriginSchema = _enum(["track", "recording"]);
|
|
23168
24137
|
/** A frame the dataset OWNS: bytes copied at selection time. */
|
|
23169
24138
|
var RetrainFrameSchema = object({
|
|
23170
24139
|
frameId: string(),
|
|
23171
24140
|
deviceId: number(),
|
|
23172
|
-
|
|
23173
|
-
/**
|
|
23174
|
-
|
|
24141
|
+
origin: RetrainFrameOriginSchema,
|
|
24142
|
+
/** The track it was copied from. Absent on a recording still. */
|
|
24143
|
+
trackId: string().optional(),
|
|
24144
|
+
/** Provenance only. It may already point at nothing — that is expected.
|
|
24145
|
+
* Absent on a recording still. */
|
|
24146
|
+
sourceMediaId: number().int().optional(),
|
|
24147
|
+
/** A recording still: the playhead instant it was taken at. */
|
|
24148
|
+
epochMs: number().optional(),
|
|
23175
24149
|
sourceKind: MediaFileKindEnum,
|
|
23176
24150
|
sizeBytes: number().int(),
|
|
23177
24151
|
width: number().int(),
|
|
@@ -23182,7 +24156,12 @@ var RetrainFrameSchema = object({
|
|
|
23182
24156
|
/** The operator's "every subject in this frame is boxed". Detector
|
|
23183
24157
|
* evaluation keeps only complete frames: an unboxed subject would count as
|
|
23184
24158
|
* a false positive. */
|
|
23185
|
-
complete: boolean()
|
|
24159
|
+
complete: boolean(),
|
|
24160
|
+
/** The boxes the pipeline drew on this frame. Present on list answers;
|
|
24161
|
+
* empty when nothing the track store holds can be placed on it. */
|
|
24162
|
+
pipelineBoxes: array(RetrainPipelineBoxSchema).readonly().optional(),
|
|
24163
|
+
/** The named collections this frame belongs to. Present on list answers. */
|
|
24164
|
+
collectionIds: array(string()).readonly().optional()
|
|
23186
24165
|
});
|
|
23187
24166
|
/** Why a copy-on-select could not be honoured — named, never a silent skip. */
|
|
23188
24167
|
var RetrainCopyRefusalSchema = _enum([
|
|
@@ -23213,6 +24192,11 @@ var RetrainFrameListSchema = object({
|
|
|
23213
24192
|
var RetrainExportFilterSchema = object({
|
|
23214
24193
|
deviceIds: array(number()).optional(),
|
|
23215
24194
|
frameIds: array(string()).max(2e4).optional(),
|
|
24195
|
+
/** Only frames in at least one of these named collections. */
|
|
24196
|
+
collectionIds: array(string()).max(200).optional(),
|
|
24197
|
+
/** Exactly the frames of this dataset version (and its completeOnly). An
|
|
24198
|
+
* unknown id selects nothing. */
|
|
24199
|
+
datasetVersionId: string().optional(),
|
|
23216
24200
|
batchId: string().optional(),
|
|
23217
24201
|
/** Only frames the operator marked complete (all subjects boxed). */
|
|
23218
24202
|
completeOnly: boolean().optional()
|
|
@@ -23277,6 +24261,170 @@ var RetrainAssistResultSchema = discriminatedUnion("kind", [object({
|
|
|
23277
24261
|
reason: string(),
|
|
23278
24262
|
detail: string().optional()
|
|
23279
24263
|
})]);
|
|
24264
|
+
/** A named set over the retrain corpus — membership only, it owns no pixels. */
|
|
24265
|
+
var RetrainCollectionSchema = object({
|
|
24266
|
+
id: string(),
|
|
24267
|
+
name: string(),
|
|
24268
|
+
createdAt: number(),
|
|
24269
|
+
frameCount: number().int()
|
|
24270
|
+
});
|
|
24271
|
+
var RetrainCollectionCreateResultSchema = discriminatedUnion("kind", [object({
|
|
24272
|
+
kind: literal("created"),
|
|
24273
|
+
collection: RetrainCollectionSchema
|
|
24274
|
+
}), object({
|
|
24275
|
+
kind: literal("refused"),
|
|
24276
|
+
reason: _enum(["empty-name", "duplicate-name"])
|
|
24277
|
+
})]);
|
|
24278
|
+
var RetrainCollectionRenameResultSchema = discriminatedUnion("kind", [object({
|
|
24279
|
+
kind: literal("renamed"),
|
|
24280
|
+
collection: RetrainCollectionSchema
|
|
24281
|
+
}), object({
|
|
24282
|
+
kind: literal("refused"),
|
|
24283
|
+
reason: _enum([
|
|
24284
|
+
"empty-name",
|
|
24285
|
+
"duplicate-name",
|
|
24286
|
+
"unknown-collection"
|
|
24287
|
+
])
|
|
24288
|
+
})]);
|
|
24289
|
+
/**
|
|
24290
|
+
* The outcome of adding the frame at a recording instant. Every refusal is
|
|
24291
|
+
* named: `still-unavailable` (not recording, a gap, or an undecodable frame —
|
|
24292
|
+
* `detail` says which), `still-busy` (the recorder is at its decode bound; try
|
|
24293
|
+
* again), `unreadable-image`, `write-failed`, `unknown-collection`.
|
|
24294
|
+
*/
|
|
24295
|
+
var AddRetrainFrameFromRecordingResultSchema = discriminatedUnion("kind", [object({
|
|
24296
|
+
kind: literal("added"),
|
|
24297
|
+
collectionId: string(),
|
|
24298
|
+
frame: RetrainFrameSchema,
|
|
24299
|
+
/** The moment was already in the dataset; nothing was decoded. */
|
|
24300
|
+
reused: boolean()
|
|
24301
|
+
}), object({
|
|
24302
|
+
kind: literal("refused"),
|
|
24303
|
+
reason: _enum([
|
|
24304
|
+
"unknown-collection",
|
|
24305
|
+
"still-unavailable",
|
|
24306
|
+
"still-busy",
|
|
24307
|
+
"unreadable-image",
|
|
24308
|
+
"write-failed"
|
|
24309
|
+
]),
|
|
24310
|
+
detail: string().optional()
|
|
24311
|
+
})]);
|
|
24312
|
+
/** A vision LLM profile the AI assist may use, and where it sends the frame. */
|
|
24313
|
+
var RetrainAssistProfileSchema = object({
|
|
24314
|
+
id: string(),
|
|
24315
|
+
name: string(),
|
|
24316
|
+
model: string(),
|
|
24317
|
+
kind: string(),
|
|
24318
|
+
/** `true` when the frame would leave the house (a cloud vendor, or an
|
|
24319
|
+
* endpoint that is not on the local network). The page confirms each such
|
|
24320
|
+
* run, and the provider refuses one without `allowCloud`. */
|
|
24321
|
+
leavesHouse: boolean()
|
|
24322
|
+
});
|
|
24323
|
+
/** A box the AI assist proposed: a draft, plus the model's own reason. */
|
|
24324
|
+
var RetrainLlmProposalSchema = RetrainAnnotationDraftSchema.extend({ reason: string() });
|
|
24325
|
+
/** What the AI assist said about a box that was already on the canvas. */
|
|
24326
|
+
var RetrainLlmReviewSchema = object({
|
|
24327
|
+
/** The `ref` the page sent the box under. */
|
|
24328
|
+
ref: string(),
|
|
24329
|
+
verdict: _enum([
|
|
24330
|
+
"confirmed",
|
|
24331
|
+
"wrong-class",
|
|
24332
|
+
"not-an-object",
|
|
24333
|
+
"uncertain"
|
|
24334
|
+
]),
|
|
24335
|
+
suggestedClass: RetrainMacroClassSchema.optional(),
|
|
24336
|
+
reason: string()
|
|
24337
|
+
});
|
|
24338
|
+
/**
|
|
24339
|
+
* The AI assist's answer. `proposed` carries drafts (`source: 'llm'`, the
|
|
24340
|
+
* model and its confidence) and reviews; items the model got wrong (a box off
|
|
24341
|
+
* the frame, an unasked class, an unknown ref) are dropped and counted in
|
|
24342
|
+
* `rejected`. A whole answer that is not the schema is `malformed-answer`.
|
|
24343
|
+
*/
|
|
24344
|
+
var RetrainLlmAssistResultSchema = discriminatedUnion("kind", [object({
|
|
24345
|
+
kind: literal("proposed"),
|
|
24346
|
+
profileId: string(),
|
|
24347
|
+
model: string(),
|
|
24348
|
+
/** The frame was sent outside the house for this answer. */
|
|
24349
|
+
leftHouse: boolean(),
|
|
24350
|
+
proposals: array(RetrainLlmProposalSchema).readonly(),
|
|
24351
|
+
reviews: array(RetrainLlmReviewSchema).readonly(),
|
|
24352
|
+
rejected: number().int()
|
|
24353
|
+
}), object({
|
|
24354
|
+
kind: literal("refused"),
|
|
24355
|
+
reason: _enum([
|
|
24356
|
+
"unknown-frame",
|
|
24357
|
+
"unreadable-frame",
|
|
24358
|
+
"unknown-profile",
|
|
24359
|
+
"profile-disabled",
|
|
24360
|
+
"no-vision",
|
|
24361
|
+
"cloud-not-confirmed",
|
|
24362
|
+
"llm-error",
|
|
24363
|
+
"malformed-answer"
|
|
24364
|
+
]),
|
|
24365
|
+
detail: string().optional()
|
|
24366
|
+
})]);
|
|
24367
|
+
/** What a dataset version is cut from. Every field narrows. */
|
|
24368
|
+
var RetrainDatasetSelectionSchema = object({
|
|
24369
|
+
deviceIds: array(number()).readonly().optional(),
|
|
24370
|
+
collectionIds: array(string()).max(200).readonly().optional(),
|
|
24371
|
+
frameIds: array(string()).max(2e4).readonly().optional()
|
|
24372
|
+
});
|
|
24373
|
+
/** The counts a dataset is judged by. */
|
|
24374
|
+
var RetrainDatasetStatsSchema = object({
|
|
24375
|
+
frames: number().int(),
|
|
24376
|
+
completeFrames: number().int(),
|
|
24377
|
+
/** `completeFrames / frames`, 0..1. */
|
|
24378
|
+
completeness: number(),
|
|
24379
|
+
/** Boxes to learn (model errors excluded). */
|
|
24380
|
+
subjects: number().int(),
|
|
24381
|
+
modelErrors: number().int(),
|
|
24382
|
+
/** Complete frames with no subject. */
|
|
24383
|
+
hardNegatives: number().int(),
|
|
24384
|
+
/** Subjects per class × camera × day/night. */
|
|
24385
|
+
cells: array(object({
|
|
24386
|
+
macroClass: string(),
|
|
24387
|
+
deviceId: number(),
|
|
24388
|
+
lighting: _enum([
|
|
24389
|
+
"day",
|
|
24390
|
+
"night",
|
|
24391
|
+
"unknown"
|
|
24392
|
+
]),
|
|
24393
|
+
subjects: number().int(),
|
|
24394
|
+
frames: number().int()
|
|
24395
|
+
})).readonly(),
|
|
24396
|
+
cameras: array(object({
|
|
24397
|
+
deviceId: number(),
|
|
24398
|
+
frames: number().int(),
|
|
24399
|
+
completeFrames: number().int()
|
|
24400
|
+
})).readonly()
|
|
24401
|
+
});
|
|
24402
|
+
/** An immutable dataset version, without its frame list. */
|
|
24403
|
+
var RetrainDatasetVersionSchema = object({
|
|
24404
|
+
id: string(),
|
|
24405
|
+
name: string(),
|
|
24406
|
+
createdAt: number(),
|
|
24407
|
+
selection: RetrainDatasetSelectionSchema,
|
|
24408
|
+
layout: RetrainExportLayoutSchema,
|
|
24409
|
+
completeOnly: boolean(),
|
|
24410
|
+
frameCount: number().int(),
|
|
24411
|
+
/** sha256 of what the frames taught when the version was frozen. */
|
|
24412
|
+
annotationHash: string(),
|
|
24413
|
+
/** The export manifest schema the version was cut under. */
|
|
24414
|
+
manifestSchema: string(),
|
|
24415
|
+
stats: RetrainDatasetStatsSchema
|
|
24416
|
+
});
|
|
24417
|
+
var CreateRetrainDatasetVersionResultSchema = discriminatedUnion("kind", [object({
|
|
24418
|
+
kind: literal("created"),
|
|
24419
|
+
version: RetrainDatasetVersionSchema
|
|
24420
|
+
}), object({
|
|
24421
|
+
kind: literal("refused"),
|
|
24422
|
+
reason: _enum([
|
|
24423
|
+
"empty-name",
|
|
24424
|
+
"duplicate-name",
|
|
24425
|
+
"no-frames"
|
|
24426
|
+
])
|
|
24427
|
+
})]);
|
|
23280
24428
|
/** The outcome of a lifecycle move owned by the retrain page. */
|
|
23281
24429
|
var RetrainTransitionResultSchema = object({
|
|
23282
24430
|
trackId: string(),
|
|
@@ -23994,7 +25142,7 @@ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).rea
|
|
|
23994
25142
|
auth: "admin"
|
|
23995
25143
|
}), method(object({
|
|
23996
25144
|
deviceId: number(),
|
|
23997
|
-
trackId: string(),
|
|
25145
|
+
trackId: string().optional(),
|
|
23998
25146
|
frameId: string()
|
|
23999
25147
|
}), object({
|
|
24000
25148
|
removed: boolean(),
|
|
@@ -24011,7 +25159,8 @@ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).rea
|
|
|
24011
25159
|
auth: "admin"
|
|
24012
25160
|
}), method(object({
|
|
24013
25161
|
deviceId: number(),
|
|
24014
|
-
|
|
25162
|
+
/** The frame's track, when it has one — checked against the frame. */
|
|
25163
|
+
trackId: string().optional(),
|
|
24015
25164
|
frameId: string(),
|
|
24016
25165
|
subject: RetrainAssistSubjectSchema,
|
|
24017
25166
|
/** Which node runs it. Absent ⇒ wherever an unowned call lands. */
|
|
@@ -24019,12 +25168,16 @@ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).rea
|
|
|
24019
25168
|
}), RetrainAssistResultSchema, {
|
|
24020
25169
|
kind: "mutation",
|
|
24021
25170
|
auth: "admin"
|
|
24022
|
-
}), method(object({
|
|
25171
|
+
}), method(object({
|
|
25172
|
+
trackId: string().optional(),
|
|
25173
|
+
frameIds: array(string()).max(2e3).optional()
|
|
25174
|
+
}), array(RetrainAnnotationSchema).readonly(), {
|
|
24023
25175
|
kind: "query",
|
|
24024
25176
|
auth: "admin"
|
|
24025
25177
|
}), method(object({
|
|
24026
25178
|
deviceId: number(),
|
|
24027
|
-
|
|
25179
|
+
/** The frame's track, when it has one — checked against the frame. */
|
|
25180
|
+
trackId: string().optional(),
|
|
24028
25181
|
frameId: string(),
|
|
24029
25182
|
annotations: array(RetrainAnnotationDraftSchema)
|
|
24030
25183
|
}), array(RetrainAnnotationSchema).readonly(), {
|
|
@@ -24047,7 +25200,7 @@ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).rea
|
|
|
24047
25200
|
auth: "admin"
|
|
24048
25201
|
}), method(object({
|
|
24049
25202
|
deviceId: number(),
|
|
24050
|
-
trackId: string(),
|
|
25203
|
+
trackId: string().optional(),
|
|
24051
25204
|
frameId: string(),
|
|
24052
25205
|
complete: boolean()
|
|
24053
25206
|
}), RetrainFrameSchema, {
|
|
@@ -24061,6 +25214,104 @@ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).rea
|
|
|
24061
25214
|
kind: "mutation",
|
|
24062
25215
|
auth: "admin",
|
|
24063
25216
|
timeoutMs: 60 * 6e4
|
|
25217
|
+
}), method(object({
|
|
25218
|
+
selection: RetrainDatasetSelectionSchema,
|
|
25219
|
+
completeOnly: boolean().optional()
|
|
25220
|
+
}), RetrainDatasetStatsSchema, {
|
|
25221
|
+
kind: "query",
|
|
25222
|
+
auth: "admin"
|
|
25223
|
+
}), method(object({
|
|
25224
|
+
name: string().max(120),
|
|
25225
|
+
selection: RetrainDatasetSelectionSchema,
|
|
25226
|
+
layout: RetrainExportLayoutSchema,
|
|
25227
|
+
completeOnly: boolean()
|
|
25228
|
+
}), CreateRetrainDatasetVersionResultSchema, {
|
|
25229
|
+
kind: "mutation",
|
|
25230
|
+
auth: "admin",
|
|
25231
|
+
timeoutMs: 12e4
|
|
25232
|
+
}), method(object({}), array(RetrainDatasetVersionSchema).readonly(), {
|
|
25233
|
+
kind: "query",
|
|
25234
|
+
auth: "admin"
|
|
25235
|
+
}), method(object({ id: string() }), object({ deleted: boolean() }), {
|
|
25236
|
+
kind: "mutation",
|
|
25237
|
+
auth: "admin"
|
|
25238
|
+
}), method(object({ id: string() }), object({
|
|
25239
|
+
found: boolean(),
|
|
25240
|
+
annotationHash: string(),
|
|
25241
|
+
matches: boolean(),
|
|
25242
|
+
missingFrames: number().int()
|
|
25243
|
+
}), {
|
|
25244
|
+
kind: "query",
|
|
25245
|
+
auth: "admin",
|
|
25246
|
+
timeoutMs: 12e4
|
|
25247
|
+
}), method(object({}), array(RetrainAssistProfileSchema).readonly(), {
|
|
25248
|
+
kind: "query",
|
|
25249
|
+
auth: "admin"
|
|
25250
|
+
}), method(object({
|
|
25251
|
+
deviceId: number(),
|
|
25252
|
+
trackId: string().optional(),
|
|
25253
|
+
frameId: string(),
|
|
25254
|
+
profileId: string(),
|
|
25255
|
+
classes: array(RetrainMacroClassSchema).min(1),
|
|
25256
|
+
boxes: array(object({
|
|
25257
|
+
ref: string(),
|
|
25258
|
+
bbox: RetrainBboxSchema,
|
|
25259
|
+
macroClass: RetrainMacroClassSchema,
|
|
25260
|
+
label: string().optional()
|
|
25261
|
+
})).max(50),
|
|
25262
|
+
allowCloud: boolean()
|
|
25263
|
+
}), RetrainLlmAssistResultSchema, {
|
|
25264
|
+
kind: "mutation",
|
|
25265
|
+
auth: "admin",
|
|
25266
|
+
timeoutMs: 18e4
|
|
25267
|
+
}), method(object({ name: string().max(120) }), RetrainCollectionCreateResultSchema, {
|
|
25268
|
+
kind: "mutation",
|
|
25269
|
+
auth: "admin"
|
|
25270
|
+
}), method(object({}), array(RetrainCollectionSchema).readonly(), {
|
|
25271
|
+
kind: "query",
|
|
25272
|
+
auth: "admin"
|
|
25273
|
+
}), method(object({
|
|
25274
|
+
id: string(),
|
|
25275
|
+
name: string().max(120)
|
|
25276
|
+
}), RetrainCollectionRenameResultSchema, {
|
|
25277
|
+
kind: "mutation",
|
|
25278
|
+
auth: "admin"
|
|
25279
|
+
}), method(object({ id: string() }), object({
|
|
25280
|
+
deleted: boolean(),
|
|
25281
|
+
removedFrames: number().int()
|
|
25282
|
+
}), {
|
|
25283
|
+
kind: "mutation",
|
|
25284
|
+
auth: "admin"
|
|
25285
|
+
}), method(object({
|
|
25286
|
+
collectionId: string(),
|
|
25287
|
+
deviceId: number(),
|
|
25288
|
+
epochMs: number()
|
|
25289
|
+
}), AddRetrainFrameFromRecordingResultSchema, {
|
|
25290
|
+
kind: "mutation",
|
|
25291
|
+
auth: "admin",
|
|
25292
|
+
timeoutMs: 6e4
|
|
25293
|
+
}), method(object({
|
|
25294
|
+
collectionId: string(),
|
|
25295
|
+
frameIds: array(string()).min(1).max(500)
|
|
25296
|
+
}), object({
|
|
25297
|
+
added: number().int(),
|
|
25298
|
+
alreadyMember: number().int(),
|
|
25299
|
+
unknownFrameIds: array(string()).readonly()
|
|
25300
|
+
}), {
|
|
25301
|
+
kind: "mutation",
|
|
25302
|
+
auth: "admin"
|
|
25303
|
+
}), method(object({
|
|
25304
|
+
collectionId: string(),
|
|
25305
|
+
frameId: string()
|
|
25306
|
+
}), object({
|
|
25307
|
+
removed: boolean(),
|
|
25308
|
+
deletedFrame: boolean()
|
|
25309
|
+
}), {
|
|
25310
|
+
kind: "mutation",
|
|
25311
|
+
auth: "admin"
|
|
25312
|
+
}), method(object({ collectionId: string() }), array(RetrainFrameSchema).readonly(), {
|
|
25313
|
+
kind: "query",
|
|
25314
|
+
auth: "admin"
|
|
24064
25315
|
}), method(object({
|
|
24065
25316
|
/** Which of the three event tables owns the row. */
|
|
24066
25317
|
ownerType: EventOwnerTypeSchema,
|
|
@@ -24684,13 +25935,31 @@ var RecommendationReasonSchema = discriminatedUnion("kind", [
|
|
|
24684
25935
|
object({
|
|
24685
25936
|
kind: literal("no-family-build"),
|
|
24686
25937
|
format: ModelFormatSchema$1
|
|
25938
|
+
}),
|
|
25939
|
+
object({
|
|
25940
|
+
kind: literal("kept-custom-pin"),
|
|
25941
|
+
modelId: string(),
|
|
25942
|
+
deviceKey: string()
|
|
24687
25943
|
})
|
|
24688
25944
|
]);
|
|
25945
|
+
/** Why a device is left exactly as it is, whatever the plan would pick (D786). */
|
|
25946
|
+
var KeptReasonSchema = _enum(["custom-pin"]);
|
|
25947
|
+
/**
|
|
25948
|
+
* Where a choice's latency came from (D791): this node's own benchmark
|
|
25949
|
+
* result, or the hardware-class table. Measured on the node beats the table.
|
|
25950
|
+
*/
|
|
25951
|
+
var LatencySourceSchema = discriminatedUnion("kind", [object({ kind: literal("table") }), object({
|
|
25952
|
+
kind: literal("node-benchmark"),
|
|
25953
|
+
resultId: string(),
|
|
25954
|
+
measuredAtMs: number()
|
|
25955
|
+
})]);
|
|
24689
25956
|
var DeviceModelChoiceSchema = object({
|
|
24690
25957
|
modelId: string(),
|
|
24691
25958
|
p50Ms: number(),
|
|
24692
25959
|
fps: number(),
|
|
24693
25960
|
measured: boolean(),
|
|
25961
|
+
/** Absent on a plan from before D791 — read as the table. */
|
|
25962
|
+
source: LatencySourceSchema.optional(),
|
|
24694
25963
|
/** Parallel sessions at the camera rate with the headroom kept free: ⌊fps × (1 − headroom) / camera fps⌋. */
|
|
24695
25964
|
capacitySessions: number(),
|
|
24696
25965
|
personRecall: number()
|
|
@@ -24701,6 +25970,8 @@ var DeviceRecommendationSchema = object({
|
|
|
24701
25970
|
enabled: boolean(),
|
|
24702
25971
|
available: boolean(),
|
|
24703
25972
|
chosen: DeviceModelChoiceSchema.nullable(),
|
|
25973
|
+
/** Present when the device is kept as is: Apply writes nothing on it. */
|
|
25974
|
+
kept: KeptReasonSchema.optional(),
|
|
24704
25975
|
reasons: array(RecommendationReasonSchema).readonly()
|
|
24705
25976
|
});
|
|
24706
25977
|
var NodeRecommendationSchema = object({
|
|
@@ -24754,6 +26025,17 @@ var AutoTuneWarningSchema = discriminatedUnion("kind", [
|
|
|
24754
26025
|
kind: literal("coral-enabled"),
|
|
24755
26026
|
nodeId: string(),
|
|
24756
26027
|
deviceKey: string()
|
|
26028
|
+
}),
|
|
26029
|
+
object({
|
|
26030
|
+
kind: literal("custom-pin-kept"),
|
|
26031
|
+
nodeId: string(),
|
|
26032
|
+
deviceKey: string().nullable(),
|
|
26033
|
+
deviceId: number().nullable(),
|
|
26034
|
+
modelId: string()
|
|
26035
|
+
}),
|
|
26036
|
+
object({
|
|
26037
|
+
kind: literal("custom-registry-unreadable"),
|
|
26038
|
+
error: string()
|
|
24757
26039
|
})
|
|
24758
26040
|
]);
|
|
24759
26041
|
var AutoTuneOptionsSchema = object({
|
|
@@ -24932,13 +26214,14 @@ var SuggestSharesResultSchema = object({
|
|
|
24932
26214
|
nodes: array(SuggestedNodeShareSchema).readonly()
|
|
24933
26215
|
});
|
|
24934
26216
|
/**
|
|
24935
|
-
* Where the node and device shares come from (D750, D755).
|
|
24936
|
-
* - `
|
|
24937
|
-
*
|
|
24938
|
-
*
|
|
24939
|
-
*
|
|
24940
|
-
*
|
|
24941
|
-
*
|
|
26217
|
+
* Where the node and device shares come from (D750, D755, D791).
|
|
26218
|
+
* - `benchmark` (default since D791) — each node's capacity as its own node
|
|
26219
|
+
* benchmark measured it; a node without fresh results is sized from
|
|
26220
|
+
* `hardware` and says so. Measured on the node beats the table.
|
|
26221
|
+
* - `hardware` — computed from each node's static capacity only (its
|
|
26222
|
+
* accelerators at their Auto tune models, from the latency table).
|
|
26223
|
+
* Both are recomputed whenever a node or device joins, leaves, is switched
|
|
26224
|
+
* on or off, changes model, or a benchmark result is written. No load input.
|
|
24942
26225
|
* - `manual` — the operator's stored sliders.
|
|
24943
26226
|
* Either way a node or device that cannot take sessions gives its share to
|
|
24944
26227
|
* the others in proportion; the stored values are never rewritten for that.
|
|
@@ -24987,6 +26270,362 @@ var EffectiveSharesSchema = object({
|
|
|
24987
26270
|
nodeWeights: record(string(), number()),
|
|
24988
26271
|
deviceWeights: record(string(), record(string(), number()))
|
|
24989
26272
|
});
|
|
26273
|
+
/**
|
|
26274
|
+
* Wire shapes of the node benchmark (D791): the operator's plan, the
|
|
26275
|
+
* preflight the confirmation shows, the run the orchestrator owns, what the
|
|
26276
|
+
* measuring runner reports, and the result rows Auto tune and the automatic
|
|
26277
|
+
* shares read.
|
|
26278
|
+
*
|
|
26279
|
+
* ONE node at a time, owned by the pipeline orchestrator. While a run is
|
|
26280
|
+
* active the cluster is in BENCHMARK MODE for that node: it is not a
|
|
26281
|
+
* detection candidate, camera pins naming it are ignored so its sessions move
|
|
26282
|
+
* elsewhere, and both come back when the mode ends — after a crash or a hub
|
|
26283
|
+
* restart too (a persisted manifest, reconciled against the registry).
|
|
26284
|
+
*
|
|
26285
|
+
* Two measurements, both on the node, driven by its own runner (frames never
|
|
26286
|
+
* cross a process at frame rate, D9):
|
|
26287
|
+
* - `device` — one accelerator × one candidate detector, root only, open
|
|
26288
|
+
* loop: how many streams at the camera rate it carries inside the frame
|
|
26289
|
+
* interval;
|
|
26290
|
+
* - `pipeline` — the chosen detector plus the operator's detail steps
|
|
26291
|
+
* (faces, plates, classifiers, CLIP…), on varied frames from the bench
|
|
26292
|
+
* clip: how many parallel sessions the node carries before latency, drops,
|
|
26293
|
+
* CPU, RAM or the event loop give out.
|
|
26294
|
+
*/
|
|
26295
|
+
/** Defaults and bounds, one place. */
|
|
26296
|
+
var NODE_BENCHMARK_DEFAULTS = {
|
|
26297
|
+
fpsPerStream: 10,
|
|
26298
|
+
budgetMinutes: 45,
|
|
26299
|
+
minBudgetMinutes: 10,
|
|
26300
|
+
maxBudgetMinutes: 120,
|
|
26301
|
+
/** A result older than this no longer beats the table. */
|
|
26302
|
+
staleAfterDays: 30,
|
|
26303
|
+
/** Warm-in per ramp step (not accounted). */
|
|
26304
|
+
settleSec: 5,
|
|
26305
|
+
/** Accounted window per ramp step. */
|
|
26306
|
+
measureSec: 20,
|
|
26307
|
+
/** Longest the drain may take before the run is refused. */
|
|
26308
|
+
drainTimeoutSec: 120,
|
|
26309
|
+
/** Candidate models per device in one run. */
|
|
26310
|
+
maxModelsPerDevice: 6
|
|
26311
|
+
};
|
|
26312
|
+
/** The two measurements a run can make. */
|
|
26313
|
+
var NodeBenchmarkPhaseSchema = _enum(["device", "pipeline"]);
|
|
26314
|
+
var NodeBenchmarkDevicePlanSchema = object({
|
|
26315
|
+
/** `<backend>:<device>` — `openvino:npu`, `coreml:all`, `cpu`. */
|
|
26316
|
+
deviceKey: string().min(1),
|
|
26317
|
+
/**
|
|
26318
|
+
* Root detector candidates for the `device` measurement, in the order
|
|
26319
|
+
* measured. The FIRST is the one the `pipeline` measurement runs.
|
|
26320
|
+
*/
|
|
26321
|
+
modelIds: array(string().min(1)).min(1).max(NODE_BENCHMARK_DEFAULTS.maxModelsPerDevice)
|
|
26322
|
+
});
|
|
26323
|
+
/** What the operator confirmed. */
|
|
26324
|
+
var NodeBenchmarkPlanSchema = object({
|
|
26325
|
+
nodeId: string().min(1),
|
|
26326
|
+
devices: array(NodeBenchmarkDevicePlanSchema).min(1),
|
|
26327
|
+
/** Which measurements run. At least one. */
|
|
26328
|
+
phases: array(NodeBenchmarkPhaseSchema).min(1).default(["device", "pipeline"]),
|
|
26329
|
+
/**
|
|
26330
|
+
* Detail steps (catalog step ids under the root: faces, plates,
|
|
26331
|
+
* classifiers, CLIP…) the `pipeline` measurement enables. The root
|
|
26332
|
+
* detector always runs.
|
|
26333
|
+
*/
|
|
26334
|
+
steps: array(string().min(1)).default([]),
|
|
26335
|
+
/** Offered rate of one stream / session. */
|
|
26336
|
+
fpsPerStream: number().int().min(1).max(30).default(NODE_BENCHMARK_DEFAULTS.fpsPerStream),
|
|
26337
|
+
/** Hard deadline: the mode ends and the cluster is restored when it passes. */
|
|
26338
|
+
budgetMinutes: number().int().min(NODE_BENCHMARK_DEFAULTS.minBudgetMinutes).max(NODE_BENCHMARK_DEFAULTS.maxBudgetMinutes).default(NODE_BENCHMARK_DEFAULTS.budgetMinutes),
|
|
26339
|
+
/** Keep the models the run downloaded (default: delete what was not installed before). */
|
|
26340
|
+
keepDownloadedModels: boolean().default(false),
|
|
26341
|
+
/** Start although the other nodes' capacity does not cover the sessions running now. */
|
|
26342
|
+
acceptInsufficientHeadroom: boolean().default(false)
|
|
26343
|
+
});
|
|
26344
|
+
var NodeBenchmarkRefusalSchema = object({
|
|
26345
|
+
kind: _enum([
|
|
26346
|
+
"benchmark-active",
|
|
26347
|
+
"node-offline",
|
|
26348
|
+
"unknown-device",
|
|
26349
|
+
"no-phase",
|
|
26350
|
+
"insufficient-headroom"
|
|
26351
|
+
]),
|
|
26352
|
+
detail: string(),
|
|
26353
|
+
overridable: boolean()
|
|
26354
|
+
});
|
|
26355
|
+
/** A camera whose detection leaves the node for the run. */
|
|
26356
|
+
var NodeBenchmarkMovingCameraSchema = object({
|
|
26357
|
+
deviceId: number(),
|
|
26358
|
+
/** Placed on the node now (a standing attach or a running session). */
|
|
26359
|
+
placedOnNode: boolean(),
|
|
26360
|
+
/** A node pin naming this node, ignored for the run. */
|
|
26361
|
+
pinnedToNode: boolean()
|
|
26362
|
+
});
|
|
26363
|
+
/** A camera that cannot leave: no other node can obtain its frames. */
|
|
26364
|
+
var NodeBenchmarkStayingCameraSchema = object({
|
|
26365
|
+
deviceId: number(),
|
|
26366
|
+
reason: literal("only-frame-source")
|
|
26367
|
+
});
|
|
26368
|
+
var NodeBenchmarkPreflightSchema = object({
|
|
26369
|
+
nodeId: string(),
|
|
26370
|
+
online: boolean(),
|
|
26371
|
+
moving: array(NodeBenchmarkMovingCameraSchema).readonly(),
|
|
26372
|
+
/** Keep running on the node during the run; the result is flagged contaminated. */
|
|
26373
|
+
staying: array(NodeBenchmarkStayingCameraSchema).readonly(),
|
|
26374
|
+
estimatedDurationMs: number(),
|
|
26375
|
+
/** The run ends and the cluster is restored at the latest after this long. */
|
|
26376
|
+
budgetMs: number(),
|
|
26377
|
+
phases: array(NodeBenchmarkPhaseSchema).readonly(),
|
|
26378
|
+
steps: array(string()).readonly(),
|
|
26379
|
+
devices: array(NodeBenchmarkDevicePlanSchema).readonly(),
|
|
26380
|
+
/** Parallel sessions the cluster runs now, and what the other nodes can carry. */
|
|
26381
|
+
headroom: object({
|
|
26382
|
+
sessionsNow: number(),
|
|
26383
|
+
otherNodesCapacitySessions: number().nullable()
|
|
26384
|
+
}),
|
|
26385
|
+
refusals: array(NodeBenchmarkRefusalSchema).readonly(),
|
|
26386
|
+
canStart: boolean()
|
|
26387
|
+
});
|
|
26388
|
+
/** Where the measuring runner is. */
|
|
26389
|
+
var NodeBenchProgressSchema = object({
|
|
26390
|
+
phase: _enum([
|
|
26391
|
+
"preparing",
|
|
26392
|
+
"device",
|
|
26393
|
+
"pipeline",
|
|
26394
|
+
"cleanup"
|
|
26395
|
+
]),
|
|
26396
|
+
deviceKey: string().nullable(),
|
|
26397
|
+
modelId: string().nullable(),
|
|
26398
|
+
/** Streams (device) or sessions (pipeline) of the step running now. */
|
|
26399
|
+
load: number().nullable(),
|
|
26400
|
+
cellsDone: number(),
|
|
26401
|
+
cellsTotal: number(),
|
|
26402
|
+
message: string()
|
|
26403
|
+
});
|
|
26404
|
+
/** What limited a ramp. `none` = the ramp ran out of steps still passing. */
|
|
26405
|
+
var NodeBenchLimitSchema = _enum([
|
|
26406
|
+
"p95",
|
|
26407
|
+
"drops",
|
|
26408
|
+
"errors",
|
|
26409
|
+
"stall",
|
|
26410
|
+
"cpu",
|
|
26411
|
+
"ram",
|
|
26412
|
+
"none"
|
|
26413
|
+
]);
|
|
26414
|
+
var NodeBenchRampStepSchema = object({
|
|
26415
|
+
load: number(),
|
|
26416
|
+
pass: boolean(),
|
|
26417
|
+
p95Ms: number(),
|
|
26418
|
+
dropRatio: number(),
|
|
26419
|
+
/** Completed frames per second over the accounted window. */
|
|
26420
|
+
fps: number(),
|
|
26421
|
+
cpuPct: number().nullable(),
|
|
26422
|
+
ramFreePct: number().nullable(),
|
|
26423
|
+
failReasons: array(string()).readonly()
|
|
26424
|
+
});
|
|
26425
|
+
var NodeBenchCellSchema = discriminatedUnion("phase", [object({
|
|
26426
|
+
phase: literal("device"),
|
|
26427
|
+
deviceKey: string(),
|
|
26428
|
+
modelId: string(),
|
|
26429
|
+
/** Single-stream latency (the K = 1 step). */
|
|
26430
|
+
p50Ms: number(),
|
|
26431
|
+
p95Ms: number(),
|
|
26432
|
+
p99Ms: number(),
|
|
26433
|
+
/** Frames per second sustained at the last passing step. */
|
|
26434
|
+
fps: number(),
|
|
26435
|
+
/** Streams at the camera rate the device carried inside the frame interval; 0 = not even one. */
|
|
26436
|
+
kMax: number(),
|
|
26437
|
+
limitedBy: NodeBenchLimitSchema,
|
|
26438
|
+
/** First call (model load + warm-up). */
|
|
26439
|
+
warmupMs: number(),
|
|
26440
|
+
ramp: array(NodeBenchRampStepSchema).readonly()
|
|
26441
|
+
}), object({
|
|
26442
|
+
phase: literal("pipeline"),
|
|
26443
|
+
deviceKey: string(),
|
|
26444
|
+
modelId: string(),
|
|
26445
|
+
steps: array(string()).readonly(),
|
|
26446
|
+
/** Parallel sessions at the camera rate the node carried; 0 = not even one. */
|
|
26447
|
+
maxSessions: number(),
|
|
26448
|
+
limitedBy: NodeBenchLimitSchema,
|
|
26449
|
+
/** Detail steps that produced at least one result on the clip — a step that never fired measured nothing. */
|
|
26450
|
+
stepsFired: array(string()).readonly(),
|
|
26451
|
+
warmupMs: number(),
|
|
26452
|
+
ramp: array(NodeBenchRampStepSchema).readonly()
|
|
26453
|
+
})]);
|
|
26454
|
+
/**
|
|
26455
|
+
* What a result was measured ON. A result whose fingerprint no longer matches
|
|
26456
|
+
* the node no longer beats the table.
|
|
26457
|
+
*/
|
|
26458
|
+
var NodeBenchFingerprintSchema = object({
|
|
26459
|
+
pipelineVersion: string().nullable(),
|
|
26460
|
+
cpuModel: string().nullable(),
|
|
26461
|
+
ramGb: number().nullable(),
|
|
26462
|
+
os: string().nullable(),
|
|
26463
|
+
/** Per device: the pool the cells ran on (runtime + tuning). */
|
|
26464
|
+
pools: record(string(), object({
|
|
26465
|
+
runtime: string(),
|
|
26466
|
+
numWorkers: number(),
|
|
26467
|
+
concurrency: number(),
|
|
26468
|
+
batchMode: string()
|
|
26469
|
+
})).default({})
|
|
26470
|
+
});
|
|
26471
|
+
/** The frames the run used. */
|
|
26472
|
+
var NodeBenchClipSchema = object({
|
|
26473
|
+
/** `camstack-bench-v1` or `reference-images` (the fallback when the clip is not reachable). */
|
|
26474
|
+
id: string(),
|
|
26475
|
+
revision: string().nullable(),
|
|
26476
|
+
frames: number(),
|
|
26477
|
+
width: number(),
|
|
26478
|
+
height: number()
|
|
26479
|
+
});
|
|
26480
|
+
var NodeBenchRunnerInputSchema = object({
|
|
26481
|
+
runId: string().min(1),
|
|
26482
|
+
devices: array(NodeBenchmarkDevicePlanSchema).min(1),
|
|
26483
|
+
phases: array(NodeBenchmarkPhaseSchema).min(1),
|
|
26484
|
+
/** The full detail step tree root for the `pipeline` measurement is built on the node from these ids. */
|
|
26485
|
+
steps: array(string()).default([]),
|
|
26486
|
+
fpsPerStream: number().int().min(1).max(30),
|
|
26487
|
+
/** The runner stops on its own past this instant, whatever the hub does. */
|
|
26488
|
+
deadlineAtMs: number(),
|
|
26489
|
+
settleSec: number().min(0).max(60).default(NODE_BENCHMARK_DEFAULTS.settleSec),
|
|
26490
|
+
measureSec: number().min(2).max(300).default(NODE_BENCHMARK_DEFAULTS.measureSec),
|
|
26491
|
+
keepDownloadedModels: boolean().default(false)
|
|
26492
|
+
});
|
|
26493
|
+
var NodeBenchRunnerStateSchema = _enum([
|
|
26494
|
+
"running",
|
|
26495
|
+
"done",
|
|
26496
|
+
"failed",
|
|
26497
|
+
"aborted"
|
|
26498
|
+
]);
|
|
26499
|
+
var NodeBenchRunnerStatusSchema = object({
|
|
26500
|
+
runId: string(),
|
|
26501
|
+
nodeId: string(),
|
|
26502
|
+
state: NodeBenchRunnerStateSchema,
|
|
26503
|
+
progress: NodeBenchProgressSchema.nullable(),
|
|
26504
|
+
/** Every finished cell so far — a run stopped half way keeps what it measured. */
|
|
26505
|
+
cells: array(NodeBenchCellSchema).readonly(),
|
|
26506
|
+
fingerprint: NodeBenchFingerprintSchema.nullable(),
|
|
26507
|
+
clip: NodeBenchClipSchema.nullable(),
|
|
26508
|
+
/** Cameras seen running on the node during the run (they share its pools). */
|
|
26509
|
+
activeCameraIds: array(number()).readonly(),
|
|
26510
|
+
/** Models the run downloaded and then deleted (not installed before). */
|
|
26511
|
+
deletedModels: array(string()).readonly(),
|
|
26512
|
+
error: string().nullable(),
|
|
26513
|
+
startedAtMs: number(),
|
|
26514
|
+
finishedAtMs: number().nullable()
|
|
26515
|
+
});
|
|
26516
|
+
var NodeBenchmarkStateSchema = _enum([
|
|
26517
|
+
"draining",
|
|
26518
|
+
"measuring",
|
|
26519
|
+
"restoring",
|
|
26520
|
+
"done",
|
|
26521
|
+
"failed",
|
|
26522
|
+
"aborted"
|
|
26523
|
+
]);
|
|
26524
|
+
/** Why a run ended. */
|
|
26525
|
+
var NodeBenchmarkEndReasonSchema = _enum([
|
|
26526
|
+
"completed",
|
|
26527
|
+
"operator-abort",
|
|
26528
|
+
"deadline",
|
|
26529
|
+
"node-lost",
|
|
26530
|
+
"runner-lost",
|
|
26531
|
+
"hub-restart",
|
|
26532
|
+
"drain-timeout",
|
|
26533
|
+
"failed"
|
|
26534
|
+
]);
|
|
26535
|
+
var NodeBenchmarkRunSchema = object({
|
|
26536
|
+
runId: string(),
|
|
26537
|
+
nodeId: string(),
|
|
26538
|
+
state: NodeBenchmarkStateSchema,
|
|
26539
|
+
plan: NodeBenchmarkPlanSchema,
|
|
26540
|
+
startedAtMs: number(),
|
|
26541
|
+
deadlineAtMs: number(),
|
|
26542
|
+
finishedAtMs: number().nullable(),
|
|
26543
|
+
endReason: NodeBenchmarkEndReasonSchema.nullable(),
|
|
26544
|
+
error: string().nullable(),
|
|
26545
|
+
/** Cameras moved off the node for the run. */
|
|
26546
|
+
moved: array(number()).readonly(),
|
|
26547
|
+
/** Cameras that stayed (their only frame source is the node). */
|
|
26548
|
+
staying: array(number()).readonly(),
|
|
26549
|
+
/** Something else ran on the node's pools during the run. */
|
|
26550
|
+
contaminated: boolean(),
|
|
26551
|
+
progress: NodeBenchProgressSchema.nullable(),
|
|
26552
|
+
resultIds: array(string()).readonly()
|
|
26553
|
+
});
|
|
26554
|
+
/** `getNodeBenchmarkStatus`: the active run (or the last one), and whether benchmark mode is on. */
|
|
26555
|
+
var NodeBenchmarkStatusSchema = object({
|
|
26556
|
+
/** The node the cluster is in benchmark mode for; null = none. */
|
|
26557
|
+
modeNodeId: string().nullable(),
|
|
26558
|
+
run: NodeBenchmarkRunSchema.nullable()
|
|
26559
|
+
});
|
|
26560
|
+
/**
|
|
26561
|
+
* One stored measurement — the only authority Auto tune and the automatic
|
|
26562
|
+
* shares read measured capacity from. Written by the orchestrator when a run
|
|
26563
|
+
* ends, never by anyone else.
|
|
26564
|
+
*/
|
|
26565
|
+
var NodeBenchmarkResultSchema = object({
|
|
26566
|
+
id: string(),
|
|
26567
|
+
runId: string(),
|
|
26568
|
+
nodeId: string(),
|
|
26569
|
+
cell: NodeBenchCellSchema,
|
|
26570
|
+
fpsPerStream: number(),
|
|
26571
|
+
fingerprint: NodeBenchFingerprintSchema.nullable(),
|
|
26572
|
+
clip: NodeBenchClipSchema.nullable(),
|
|
26573
|
+
/** Other work shared the node's pools (a camera that could not move, or the hub's own duties). */
|
|
26574
|
+
contaminated: boolean(),
|
|
26575
|
+
stayingCameras: array(number()).readonly(),
|
|
26576
|
+
/** The run ended early; the cell itself completed. */
|
|
26577
|
+
partialRun: boolean(),
|
|
26578
|
+
measuredAtMs: number()
|
|
26579
|
+
});
|
|
26580
|
+
var ListNodeBenchmarkResultsInputSchema = object({
|
|
26581
|
+
nodeId: string().optional(),
|
|
26582
|
+
deviceKey: string().optional()
|
|
26583
|
+
});
|
|
26584
|
+
/** A result with its standing today: does it still beat the table? */
|
|
26585
|
+
var NodeBenchmarkResultViewSchema = NodeBenchmarkResultSchema.extend({
|
|
26586
|
+
/** `fresh` beats the table; `stale` falls back to it; `superseded` = a newer row covers the same cell. */
|
|
26587
|
+
standing: _enum([
|
|
26588
|
+
"fresh",
|
|
26589
|
+
"stale",
|
|
26590
|
+
"superseded"
|
|
26591
|
+
]),
|
|
26592
|
+
staleWhy: _enum([
|
|
26593
|
+
"age",
|
|
26594
|
+
"runtime",
|
|
26595
|
+
"pool-tuning"
|
|
26596
|
+
]).nullable()
|
|
26597
|
+
});
|
|
26598
|
+
object({
|
|
26599
|
+
runId: string(),
|
|
26600
|
+
nodeId: string(),
|
|
26601
|
+
startedAtMs: number(),
|
|
26602
|
+
deadlineAtMs: number(),
|
|
26603
|
+
plan: NodeBenchmarkPlanSchema,
|
|
26604
|
+
moved: array(number()).readonly(),
|
|
26605
|
+
staying: array(number()).readonly()
|
|
26606
|
+
});
|
|
26607
|
+
/** Candidate detectors per device, for the plan editor. */
|
|
26608
|
+
var NodeBenchmarkCandidatesSchema = object({
|
|
26609
|
+
nodeId: string(),
|
|
26610
|
+
reachable: boolean(),
|
|
26611
|
+
devices: array(object({
|
|
26612
|
+
deviceKey: string(),
|
|
26613
|
+
enabled: boolean(),
|
|
26614
|
+
available: boolean(),
|
|
26615
|
+
/** Ordered: what Auto tune would pick first, then the rest of the family by accuracy. */
|
|
26616
|
+
suggested: array(string()).readonly(),
|
|
26617
|
+
/** Every root detector the device has a build for. */
|
|
26618
|
+
all: array(string()).readonly(),
|
|
26619
|
+
/** The model the device runs now, when pinned. */
|
|
26620
|
+
currentModelId: string().nullable()
|
|
26621
|
+
})).readonly(),
|
|
26622
|
+
/** Detail steps the node's catalog offers under the root (for the `pipeline` measurement). */
|
|
26623
|
+
steps: array(object({
|
|
26624
|
+
id: string(),
|
|
26625
|
+
name: string(),
|
|
26626
|
+
slot: string()
|
|
26627
|
+
})).readonly()
|
|
26628
|
+
});
|
|
24990
26629
|
object({
|
|
24991
26630
|
activeCameras: number(),
|
|
24992
26631
|
throttledCameras: number(),
|
|
@@ -26115,7 +27754,16 @@ method(RunnerCameraConfigSchema, object({ success: literal(true) }), { kind: "mu
|
|
|
26115
27754
|
}), ParkedTrackFrameSchema.nullable()), method(object({
|
|
26116
27755
|
deviceId: number(),
|
|
26117
27756
|
trackId: string()
|
|
26118
|
-
}), object({ released: number().int().nonnegative() }), { kind: "mutation" })
|
|
27757
|
+
}), object({ released: number().int().nonnegative() }), { kind: "mutation" }), method(NodeBenchRunnerInputSchema, object({
|
|
27758
|
+
accepted: literal(true),
|
|
27759
|
+
runId: string()
|
|
27760
|
+
}), {
|
|
27761
|
+
kind: "mutation",
|
|
27762
|
+
auth: "admin"
|
|
27763
|
+
}), method(object({ runId: string() }), NodeBenchRunnerStatusSchema.nullable(), { auth: "admin" }), method(object({ runId: string() }), object({ aborted: boolean() }), {
|
|
27764
|
+
kind: "mutation",
|
|
27765
|
+
auth: "admin"
|
|
27766
|
+
});
|
|
26119
27767
|
var CameraPipelineConfigSchema = object({
|
|
26120
27768
|
engine: PipelineEngineChoiceSchema.optional(),
|
|
26121
27769
|
steps: array(PipelineStepInputSchema).readonly(),
|
|
@@ -26754,6 +28402,21 @@ method(object({
|
|
|
26754
28402
|
}), method(PlacementStatsInputSchema, PlacementStatsSchema, { auth: "admin" }), method(SuggestSharesInputSchema, SuggestSharesResultSchema, { auth: "admin" }), method(_void(), EffectiveSharesSchema, { auth: "admin" }), method(SetShareSourceInputSchema, object({ success: literal(true) }), {
|
|
26755
28403
|
kind: "mutation",
|
|
26756
28404
|
auth: "admin"
|
|
28405
|
+
}), method(NodeBenchmarkPlanSchema, NodeBenchmarkPreflightSchema, { auth: "admin" }), method(NodeBenchmarkPlanSchema, discriminatedUnion("kind", [object({
|
|
28406
|
+
kind: literal("started"),
|
|
28407
|
+
runId: string()
|
|
28408
|
+
}), object({
|
|
28409
|
+
kind: literal("refused"),
|
|
28410
|
+
preflight: NodeBenchmarkPreflightSchema
|
|
28411
|
+
})]), {
|
|
28412
|
+
kind: "mutation",
|
|
28413
|
+
auth: "admin"
|
|
28414
|
+
}), method(_void(), NodeBenchmarkStatusSchema, { auth: "admin" }), method(object({ runId: string() }), object({ aborted: boolean() }), {
|
|
28415
|
+
kind: "mutation",
|
|
28416
|
+
auth: "admin"
|
|
28417
|
+
}), method(object({ nodeId: string() }), NodeBenchmarkCandidatesSchema, { auth: "admin" }), method(ListNodeBenchmarkResultsInputSchema, array(NodeBenchmarkResultViewSchema).readonly(), { auth: "admin" }), method(object({ id: string() }), object({ deleted: boolean() }), {
|
|
28418
|
+
kind: "mutation",
|
|
28419
|
+
auth: "admin"
|
|
26757
28420
|
}), method(object({ deviceId: number() }), CameraPipelineSettingsSchema.nullable()), method(object({
|
|
26758
28421
|
deviceId: number(),
|
|
26759
28422
|
addonId: string(),
|
|
@@ -33383,6 +35046,9 @@ var CreateIntegrationInputSchema = object({
|
|
|
33383
35046
|
enabled: boolean().optional(),
|
|
33384
35047
|
info: record(string(), unknown()).optional(),
|
|
33385
35048
|
settings: record(string(), unknown()).optional(),
|
|
35049
|
+
/** Keys of `settings` the form's schema declares secret (by type) — kept in
|
|
35050
|
+
* the keychain, not the table (D787). */
|
|
35051
|
+
secretKeys: array(string()).optional(),
|
|
33386
35052
|
skipRestart: boolean().optional()
|
|
33387
35053
|
});
|
|
33388
35054
|
var UpdateIntegrationInputSchema = object({
|
|
@@ -33406,7 +35072,9 @@ method(_void(), array(IntegrationWithStateSchema)), method(object({ id: string()
|
|
|
33406
35072
|
auth: "admin"
|
|
33407
35073
|
}), method(object({ id: string() }), record(string(), unknown()), { auth: "admin" }), method(object({
|
|
33408
35074
|
id: string(),
|
|
33409
|
-
settings: record(string(), unknown())
|
|
35075
|
+
settings: record(string(), unknown()),
|
|
35076
|
+
/** Keys the form's schema declares secret (by type) — keychain-stored (D787). */
|
|
35077
|
+
secretKeys: array(string()).optional()
|
|
33410
35078
|
}), object({ success: boolean() }), {
|
|
33411
35079
|
kind: "mutation",
|
|
33412
35080
|
auth: "admin"
|
|
@@ -42154,7 +43822,8 @@ var BaseDevice = class {
|
|
|
42154
43822
|
this.role = options.role;
|
|
42155
43823
|
this.parentDeviceId = ctx.parentDeviceId;
|
|
42156
43824
|
const seedData = ctx.persistedConfig ?? {};
|
|
42157
|
-
|
|
43825
|
+
const declaredSecretPaths = collectZodSecretPaths(schema);
|
|
43826
|
+
this.config = DeviceConfig.fromSchema(schema, (data) => ctx.persistConfig(data, { secretConfigPaths: declaredSecretPaths }), seedData, ({ droppedKeys, issues }) => {
|
|
42158
43827
|
ctx.logger.warn("Device config recovery: dropping invalid persisted fields", {
|
|
42159
43828
|
tags: {
|
|
42160
43829
|
deviceId: ctx.id,
|
|
@@ -45854,6 +47523,90 @@ Object.freeze({
|
|
|
45854
47523
|
addonId: null,
|
|
45855
47524
|
access: "create"
|
|
45856
47525
|
},
|
|
47526
|
+
"keychain.delete": {
|
|
47527
|
+
capName: "keychain",
|
|
47528
|
+
capScope: "system",
|
|
47529
|
+
addonId: null,
|
|
47530
|
+
access: "delete"
|
|
47531
|
+
},
|
|
47532
|
+
"keychain.getState": {
|
|
47533
|
+
capName: "keychain",
|
|
47534
|
+
capScope: "system",
|
|
47535
|
+
addonId: null,
|
|
47536
|
+
access: "view"
|
|
47537
|
+
},
|
|
47538
|
+
"keychain.listMeta": {
|
|
47539
|
+
capName: "keychain",
|
|
47540
|
+
capScope: "system",
|
|
47541
|
+
addonId: null,
|
|
47542
|
+
access: "view"
|
|
47543
|
+
},
|
|
47544
|
+
"keychain.put": {
|
|
47545
|
+
capName: "keychain",
|
|
47546
|
+
capScope: "system",
|
|
47547
|
+
addonId: null,
|
|
47548
|
+
access: "create"
|
|
47549
|
+
},
|
|
47550
|
+
"keychain.resolve": {
|
|
47551
|
+
capName: "keychain",
|
|
47552
|
+
capScope: "system",
|
|
47553
|
+
addonId: null,
|
|
47554
|
+
access: "view"
|
|
47555
|
+
},
|
|
47556
|
+
"keychainAdmin.deleteOrphans": {
|
|
47557
|
+
capName: "keychain-admin",
|
|
47558
|
+
capScope: "system",
|
|
47559
|
+
addonId: null,
|
|
47560
|
+
access: "delete"
|
|
47561
|
+
},
|
|
47562
|
+
"keychainAdmin.downloadRecoveryKey": {
|
|
47563
|
+
capName: "keychain-admin",
|
|
47564
|
+
capScope: "system",
|
|
47565
|
+
addonId: null,
|
|
47566
|
+
access: "create"
|
|
47567
|
+
},
|
|
47568
|
+
"keychainAdmin.listAudit": {
|
|
47569
|
+
capName: "keychain-admin",
|
|
47570
|
+
capScope: "system",
|
|
47571
|
+
addonId: null,
|
|
47572
|
+
access: "view"
|
|
47573
|
+
},
|
|
47574
|
+
"keychainAdmin.listSecrets": {
|
|
47575
|
+
capName: "keychain-admin",
|
|
47576
|
+
capScope: "system",
|
|
47577
|
+
addonId: null,
|
|
47578
|
+
access: "view"
|
|
47579
|
+
},
|
|
47580
|
+
"keychainAdmin.purgeRetiredKeys": {
|
|
47581
|
+
capName: "keychain-admin",
|
|
47582
|
+
capScope: "system",
|
|
47583
|
+
addonId: null,
|
|
47584
|
+
access: "delete"
|
|
47585
|
+
},
|
|
47586
|
+
"keychainAdmin.resetKeychain": {
|
|
47587
|
+
capName: "keychain-admin",
|
|
47588
|
+
capScope: "system",
|
|
47589
|
+
addonId: null,
|
|
47590
|
+
access: "delete"
|
|
47591
|
+
},
|
|
47592
|
+
"keychainAdmin.reveal": {
|
|
47593
|
+
capName: "keychain-admin",
|
|
47594
|
+
capScope: "system",
|
|
47595
|
+
addonId: null,
|
|
47596
|
+
access: "create"
|
|
47597
|
+
},
|
|
47598
|
+
"keychainAdmin.rotateMasterKey": {
|
|
47599
|
+
capName: "keychain-admin",
|
|
47600
|
+
capScope: "system",
|
|
47601
|
+
addonId: null,
|
|
47602
|
+
access: "create"
|
|
47603
|
+
},
|
|
47604
|
+
"keychainAdmin.status": {
|
|
47605
|
+
capName: "keychain-admin",
|
|
47606
|
+
capScope: "system",
|
|
47607
|
+
addonId: null,
|
|
47608
|
+
access: "view"
|
|
47609
|
+
},
|
|
45857
47610
|
"lawnMowerControl.dock": {
|
|
45858
47611
|
capName: "lawn-mower-control",
|
|
45859
47612
|
capScope: "device",
|
|
@@ -47228,6 +48981,18 @@ Object.freeze({
|
|
|
47228
48981
|
addonId: null,
|
|
47229
48982
|
access: "create"
|
|
47230
48983
|
},
|
|
48984
|
+
"pipelineAnalytics.addRetrainFrameFromRecording": {
|
|
48985
|
+
capName: "pipeline-analytics",
|
|
48986
|
+
capScope: "device",
|
|
48987
|
+
addonId: null,
|
|
48988
|
+
access: "create"
|
|
48989
|
+
},
|
|
48990
|
+
"pipelineAnalytics.addRetrainFramesToCollection": {
|
|
48991
|
+
capName: "pipeline-analytics",
|
|
48992
|
+
capScope: "device",
|
|
48993
|
+
addonId: null,
|
|
48994
|
+
access: "create"
|
|
48995
|
+
},
|
|
47231
48996
|
"pipelineAnalytics.applyDeviceSettingsPatch": {
|
|
47232
48997
|
capName: "pipeline-analytics",
|
|
47233
48998
|
capScope: "device",
|
|
@@ -47276,12 +49041,36 @@ Object.freeze({
|
|
|
47276
49041
|
addonId: null,
|
|
47277
49042
|
access: "view"
|
|
47278
49043
|
},
|
|
49044
|
+
"pipelineAnalytics.createRetrainCollection": {
|
|
49045
|
+
capName: "pipeline-analytics",
|
|
49046
|
+
capScope: "device",
|
|
49047
|
+
addonId: null,
|
|
49048
|
+
access: "create"
|
|
49049
|
+
},
|
|
49050
|
+
"pipelineAnalytics.createRetrainDatasetVersion": {
|
|
49051
|
+
capName: "pipeline-analytics",
|
|
49052
|
+
capScope: "device",
|
|
49053
|
+
addonId: null,
|
|
49054
|
+
access: "create"
|
|
49055
|
+
},
|
|
47279
49056
|
"pipelineAnalytics.deleteDeviceEvents": {
|
|
47280
49057
|
capName: "pipeline-analytics",
|
|
47281
49058
|
capScope: "device",
|
|
47282
49059
|
addonId: null,
|
|
47283
49060
|
access: "delete"
|
|
47284
49061
|
},
|
|
49062
|
+
"pipelineAnalytics.deleteRetrainCollection": {
|
|
49063
|
+
capName: "pipeline-analytics",
|
|
49064
|
+
capScope: "device",
|
|
49065
|
+
addonId: null,
|
|
49066
|
+
access: "delete"
|
|
49067
|
+
},
|
|
49068
|
+
"pipelineAnalytics.deleteRetrainDatasetVersion": {
|
|
49069
|
+
capName: "pipeline-analytics",
|
|
49070
|
+
capScope: "device",
|
|
49071
|
+
addonId: null,
|
|
49072
|
+
access: "delete"
|
|
49073
|
+
},
|
|
47285
49074
|
"pipelineAnalytics.deleteTracks": {
|
|
47286
49075
|
capName: "pipeline-analytics",
|
|
47287
49076
|
capScope: "device",
|
|
@@ -47486,6 +49275,30 @@ Object.freeze({
|
|
|
47486
49275
|
addonId: null,
|
|
47487
49276
|
access: "view"
|
|
47488
49277
|
},
|
|
49278
|
+
"pipelineAnalytics.listRetrainAssistProfiles": {
|
|
49279
|
+
capName: "pipeline-analytics",
|
|
49280
|
+
capScope: "device",
|
|
49281
|
+
addonId: null,
|
|
49282
|
+
access: "view"
|
|
49283
|
+
},
|
|
49284
|
+
"pipelineAnalytics.listRetrainCollectionFrames": {
|
|
49285
|
+
capName: "pipeline-analytics",
|
|
49286
|
+
capScope: "device",
|
|
49287
|
+
addonId: null,
|
|
49288
|
+
access: "view"
|
|
49289
|
+
},
|
|
49290
|
+
"pipelineAnalytics.listRetrainCollections": {
|
|
49291
|
+
capName: "pipeline-analytics",
|
|
49292
|
+
capScope: "device",
|
|
49293
|
+
addonId: null,
|
|
49294
|
+
access: "view"
|
|
49295
|
+
},
|
|
49296
|
+
"pipelineAnalytics.listRetrainDatasetVersions": {
|
|
49297
|
+
capName: "pipeline-analytics",
|
|
49298
|
+
capScope: "device",
|
|
49299
|
+
addonId: null,
|
|
49300
|
+
access: "view"
|
|
49301
|
+
},
|
|
47489
49302
|
"pipelineAnalytics.listRetrainFrames": {
|
|
47490
49303
|
capName: "pipeline-analytics",
|
|
47491
49304
|
capScope: "device",
|
|
@@ -47528,12 +49341,24 @@ Object.freeze({
|
|
|
47528
49341
|
addonId: null,
|
|
47529
49342
|
access: "create"
|
|
47530
49343
|
},
|
|
49344
|
+
"pipelineAnalytics.previewRetrainDataset": {
|
|
49345
|
+
capName: "pipeline-analytics",
|
|
49346
|
+
capScope: "device",
|
|
49347
|
+
addonId: null,
|
|
49348
|
+
access: "view"
|
|
49349
|
+
},
|
|
47531
49350
|
"pipelineAnalytics.proposeRetrainAnnotations": {
|
|
47532
49351
|
capName: "pipeline-analytics",
|
|
47533
49352
|
capScope: "device",
|
|
47534
49353
|
addonId: null,
|
|
47535
49354
|
access: "create"
|
|
47536
49355
|
},
|
|
49356
|
+
"pipelineAnalytics.proposeRetrainAnnotationsWithLlm": {
|
|
49357
|
+
capName: "pipeline-analytics",
|
|
49358
|
+
capScope: "device",
|
|
49359
|
+
addonId: null,
|
|
49360
|
+
access: "create"
|
|
49361
|
+
},
|
|
47537
49362
|
"pipelineAnalytics.pruneEvents": {
|
|
47538
49363
|
capName: "pipeline-analytics",
|
|
47539
49364
|
capScope: "device",
|
|
@@ -47588,6 +49413,18 @@ Object.freeze({
|
|
|
47588
49413
|
addonId: null,
|
|
47589
49414
|
access: "create"
|
|
47590
49415
|
},
|
|
49416
|
+
"pipelineAnalytics.removeRetrainFrameFromCollection": {
|
|
49417
|
+
capName: "pipeline-analytics",
|
|
49418
|
+
capScope: "device",
|
|
49419
|
+
addonId: null,
|
|
49420
|
+
access: "delete"
|
|
49421
|
+
},
|
|
49422
|
+
"pipelineAnalytics.renameRetrainCollection": {
|
|
49423
|
+
capName: "pipeline-analytics",
|
|
49424
|
+
capScope: "device",
|
|
49425
|
+
addonId: null,
|
|
49426
|
+
access: "create"
|
|
49427
|
+
},
|
|
47591
49428
|
"pipelineAnalytics.restageRetrainTrack": {
|
|
47592
49429
|
capName: "pipeline-analytics",
|
|
47593
49430
|
capScope: "device",
|
|
@@ -47648,6 +49485,12 @@ Object.freeze({
|
|
|
47648
49485
|
addonId: null,
|
|
47649
49486
|
access: "create"
|
|
47650
49487
|
},
|
|
49488
|
+
"pipelineAnalytics.verifyRetrainDatasetVersion": {
|
|
49489
|
+
capName: "pipeline-analytics",
|
|
49490
|
+
capScope: "device",
|
|
49491
|
+
addonId: null,
|
|
49492
|
+
access: "view"
|
|
49493
|
+
},
|
|
47651
49494
|
"pipelineAnalytics.wipeAllAnalytics": {
|
|
47652
49495
|
capName: "pipeline-analytics",
|
|
47653
49496
|
capScope: "device",
|
|
@@ -47876,6 +49719,12 @@ Object.freeze({
|
|
|
47876
49719
|
addonId: null,
|
|
47877
49720
|
access: "view"
|
|
47878
49721
|
},
|
|
49722
|
+
"pipelineOrchestrator.abortNodeBenchmark": {
|
|
49723
|
+
capName: "pipeline-orchestrator",
|
|
49724
|
+
capScope: "system",
|
|
49725
|
+
addonId: null,
|
|
49726
|
+
access: "create"
|
|
49727
|
+
},
|
|
47879
49728
|
"pipelineOrchestrator.applyAutoTune": {
|
|
47880
49729
|
capName: "pipeline-orchestrator",
|
|
47881
49730
|
capScope: "system",
|
|
@@ -47900,6 +49749,12 @@ Object.freeze({
|
|
|
47900
49749
|
addonId: null,
|
|
47901
49750
|
access: "create"
|
|
47902
49751
|
},
|
|
49752
|
+
"pipelineOrchestrator.deleteNodeBenchmarkResult": {
|
|
49753
|
+
capName: "pipeline-orchestrator",
|
|
49754
|
+
capScope: "system",
|
|
49755
|
+
addonId: null,
|
|
49756
|
+
access: "delete"
|
|
49757
|
+
},
|
|
47903
49758
|
"pipelineOrchestrator.getAgentLoad": {
|
|
47904
49759
|
capName: "pipeline-orchestrator",
|
|
47905
49760
|
capScope: "system",
|
|
@@ -48008,6 +49863,24 @@ Object.freeze({
|
|
|
48008
49863
|
addonId: null,
|
|
48009
49864
|
access: "view"
|
|
48010
49865
|
},
|
|
49866
|
+
"pipelineOrchestrator.getNodeBenchmarkCandidates": {
|
|
49867
|
+
capName: "pipeline-orchestrator",
|
|
49868
|
+
capScope: "system",
|
|
49869
|
+
addonId: null,
|
|
49870
|
+
access: "view"
|
|
49871
|
+
},
|
|
49872
|
+
"pipelineOrchestrator.getNodeBenchmarkPreflight": {
|
|
49873
|
+
capName: "pipeline-orchestrator",
|
|
49874
|
+
capScope: "system",
|
|
49875
|
+
addonId: null,
|
|
49876
|
+
access: "view"
|
|
49877
|
+
},
|
|
49878
|
+
"pipelineOrchestrator.getNodeBenchmarkStatus": {
|
|
49879
|
+
capName: "pipeline-orchestrator",
|
|
49880
|
+
capScope: "system",
|
|
49881
|
+
addonId: null,
|
|
49882
|
+
access: "view"
|
|
49883
|
+
},
|
|
48011
49884
|
"pipelineOrchestrator.getNodeInferenceDevices": {
|
|
48012
49885
|
capName: "pipeline-orchestrator",
|
|
48013
49886
|
capScope: "system",
|
|
@@ -48050,6 +49923,12 @@ Object.freeze({
|
|
|
48050
49923
|
addonId: null,
|
|
48051
49924
|
access: "view"
|
|
48052
49925
|
},
|
|
49926
|
+
"pipelineOrchestrator.listNodeBenchmarkResults": {
|
|
49927
|
+
capName: "pipeline-orchestrator",
|
|
49928
|
+
capScope: "system",
|
|
49929
|
+
addonId: null,
|
|
49930
|
+
access: "view"
|
|
49931
|
+
},
|
|
48053
49932
|
"pipelineOrchestrator.pauseForStorageMigration": {
|
|
48054
49933
|
capName: "pipeline-orchestrator",
|
|
48055
49934
|
capScope: "system",
|
|
@@ -48194,6 +50073,12 @@ Object.freeze({
|
|
|
48194
50073
|
addonId: null,
|
|
48195
50074
|
access: "create"
|
|
48196
50075
|
},
|
|
50076
|
+
"pipelineOrchestrator.startNodeBenchmark": {
|
|
50077
|
+
capName: "pipeline-orchestrator",
|
|
50078
|
+
capScope: "system",
|
|
50079
|
+
addonId: null,
|
|
50080
|
+
access: "create"
|
|
50081
|
+
},
|
|
48197
50082
|
"pipelineOrchestrator.suggestShares": {
|
|
48198
50083
|
capName: "pipeline-orchestrator",
|
|
48199
50084
|
capScope: "system",
|
|
@@ -48212,6 +50097,12 @@ Object.freeze({
|
|
|
48212
50097
|
addonId: null,
|
|
48213
50098
|
access: "create"
|
|
48214
50099
|
},
|
|
50100
|
+
"pipelineRunner.abortNodeBench": {
|
|
50101
|
+
capName: "pipeline-runner",
|
|
50102
|
+
capScope: "system",
|
|
50103
|
+
addonId: null,
|
|
50104
|
+
access: "create"
|
|
50105
|
+
},
|
|
48215
50106
|
"pipelineRunner.attachCamera": {
|
|
48216
50107
|
capName: "pipeline-runner",
|
|
48217
50108
|
capScope: "system",
|
|
@@ -48260,6 +50151,12 @@ Object.freeze({
|
|
|
48260
50151
|
addonId: null,
|
|
48261
50152
|
access: "view"
|
|
48262
50153
|
},
|
|
50154
|
+
"pipelineRunner.getNodeBenchStatus": {
|
|
50155
|
+
capName: "pipeline-runner",
|
|
50156
|
+
capScope: "system",
|
|
50157
|
+
addonId: null,
|
|
50158
|
+
access: "view"
|
|
50159
|
+
},
|
|
48263
50160
|
"pipelineRunner.getParkedTrackFrame": {
|
|
48264
50161
|
capName: "pipeline-runner",
|
|
48265
50162
|
capScope: "system",
|
|
@@ -48302,6 +50199,12 @@ Object.freeze({
|
|
|
48302
50199
|
addonId: null,
|
|
48303
50200
|
access: "create"
|
|
48304
50201
|
},
|
|
50202
|
+
"pipelineRunner.startNodeBench": {
|
|
50203
|
+
capName: "pipeline-runner",
|
|
50204
|
+
capScope: "system",
|
|
50205
|
+
addonId: null,
|
|
50206
|
+
access: "create"
|
|
50207
|
+
},
|
|
48305
50208
|
"plateGallery.assignPlate": {
|
|
48306
50209
|
capName: "plate-gallery",
|
|
48307
50210
|
capScope: "system",
|
|
@@ -53383,6 +55286,11 @@ Object.freeze({
|
|
|
53383
55286
|
form: "single",
|
|
53384
55287
|
optional: false
|
|
53385
55288
|
}],
|
|
55289
|
+
"pipelineAnalytics.addRetrainFrameFromRecording": [{
|
|
55290
|
+
name: "deviceId",
|
|
55291
|
+
form: "single",
|
|
55292
|
+
optional: false
|
|
55293
|
+
}],
|
|
53386
55294
|
"pipelineAnalytics.applyDeviceSettingsPatch": [{
|
|
53387
55295
|
name: "deviceId",
|
|
53388
55296
|
form: "single",
|
|
@@ -53573,6 +55481,11 @@ Object.freeze({
|
|
|
53573
55481
|
form: "single",
|
|
53574
55482
|
optional: false
|
|
53575
55483
|
}],
|
|
55484
|
+
"pipelineAnalytics.proposeRetrainAnnotationsWithLlm": [{
|
|
55485
|
+
name: "deviceId",
|
|
55486
|
+
form: "single",
|
|
55487
|
+
optional: false
|
|
55488
|
+
}],
|
|
53576
55489
|
"pipelineAnalytics.pruneEventsBefore": [{
|
|
53577
55490
|
name: "deviceId",
|
|
53578
55491
|
form: "single",
|
|
@@ -165333,6 +167246,31 @@ function createAccessoryDevice(kind, ctx, parent) {
|
|
|
165333
167246
|
}
|
|
165334
167247
|
//#endregion
|
|
165335
167248
|
//#region src/accessory-probe-flags.ts
|
|
167249
|
+
/**
|
|
167250
|
+
* Pure helpers that decide which probe flags drive accessory-child
|
|
167251
|
+
* derivation, and whether a Reolink camera has *ever* been probed.
|
|
167252
|
+
*
|
|
167253
|
+
* Why this exists as its own module: the `feature-probe` runtime-state
|
|
167254
|
+
* slice is the live, in-session source of the camera's ability flags
|
|
167255
|
+
* (`hasSiren` / `hasFloodlight` / `hasPirSensor` / …). It is rehydrated
|
|
167256
|
+
* on restart, BUT a camera whose Baichuan `getDeviceCapabilities`
|
|
167257
|
+
* round-trip is slow or flaky (observed: a doorbell that times out the
|
|
167258
|
+
* kernel's 30s `onProbe` window on every boot) restores with an empty
|
|
167259
|
+
* slice (`lastProbedAt === 0`). The `deviceCache` config blob — written
|
|
167260
|
+
* alongside the slice on the LAST successful probe and preserved across
|
|
167261
|
+
* restarts by the camera schema's `.loose()` passthrough — still carries
|
|
167262
|
+
* that probe's flags plus a `probedAt` stamp.
|
|
167263
|
+
*
|
|
167264
|
+
* Deriving accessory specs from the `deviceCache` fallback lets the
|
|
167265
|
+
* kernel re-spawn the persisted accessory children (and therefore
|
|
167266
|
+
* re-mount their kernel-managed `device-ops` provider) even when this
|
|
167267
|
+
* session's live probe never completes. Without it, every accessory of
|
|
167268
|
+
* a slow-probing camera is left as a DB row with no live provider
|
|
167269
|
+
* ("device-ops not registered for device N").
|
|
167270
|
+
*
|
|
167271
|
+
* Kept pure (no `this`, no I/O) so the slice-vs-cache precedence is
|
|
167272
|
+
* unit-testable without standing up a full camera device.
|
|
167273
|
+
*/
|
|
165336
167274
|
var FLAG_KEYS = [
|
|
165337
167275
|
"hasBattery",
|
|
165338
167276
|
"hasPtz",
|
|
@@ -165370,6 +167308,59 @@ function resolveAccessoryProbeFlags(sliceProbed, sliceFlags, deviceCache) {
|
|
|
165370
167308
|
}
|
|
165371
167309
|
return out;
|
|
165372
167310
|
}
|
|
167311
|
+
/**
|
|
167312
|
+
* The `deviceCache` blob a successful feature probe leaves behind: the
|
|
167313
|
+
* previous blob, plus the `probedAt` stamp and every boolean ability flag
|
|
167314
|
+
* the probe resolved. This is what lets {@link resolveAccessoryProbeFlags}
|
|
167315
|
+
* fall back on the next boot — a battery camera asleep at boot skips its
|
|
167316
|
+
* probe, and the `feature-probe` slice alone does not carry the flags
|
|
167317
|
+
* across a provider restart. Returns a new object; `previous` is untouched.
|
|
167318
|
+
*/
|
|
167319
|
+
function withPersistedProbe(previous, flags, probedAt) {
|
|
167320
|
+
const persisted = {};
|
|
167321
|
+
for (const key of FLAG_KEYS) {
|
|
167322
|
+
const value = flags[key];
|
|
167323
|
+
if (typeof value === "boolean") persisted[key] = value;
|
|
167324
|
+
}
|
|
167325
|
+
return {
|
|
167326
|
+
...previous,
|
|
167327
|
+
...persisted,
|
|
167328
|
+
probedAt
|
|
167329
|
+
};
|
|
167330
|
+
}
|
|
167331
|
+
/** The accessory children a probe flag set spawns, in spawn order. */
|
|
167332
|
+
var ACCESSORY_FLAGS = [
|
|
167333
|
+
["hasSiren", AccessoryKind.Siren],
|
|
167334
|
+
["hasFloodlight", AccessoryKind.Floodlight],
|
|
167335
|
+
["hasPirSensor", AccessoryKind.PirSensor]
|
|
167336
|
+
];
|
|
167337
|
+
/**
|
|
167338
|
+
* Accessory kinds a camera should spawn: none until it has EVER probed
|
|
167339
|
+
* (live slice this session, or a persisted `probedAt`), then one per
|
|
167340
|
+
* ability flag that is exactly `true` — live slice first, persisted
|
|
167341
|
+
* `deviceCache` flags as the fallback.
|
|
167342
|
+
*/
|
|
167343
|
+
function accessoryKindsFor(sliceProbed, sliceFlags, deviceCache) {
|
|
167344
|
+
if (!hasEverProbed(sliceProbed, deviceCache)) return [];
|
|
167345
|
+
const flags = resolveAccessoryProbeFlags(sliceProbed, sliceFlags, deviceCache);
|
|
167346
|
+
return ACCESSORY_FLAGS.filter(([flag]) => flags[flag] === true).map(([, kind]) => kind);
|
|
167347
|
+
}
|
|
167348
|
+
/**
|
|
167349
|
+
* The probe flags every probe-gated decision should read (PTZ, intercom,
|
|
167350
|
+
* doorbell, autotrack caps, the device features, accessory children):
|
|
167351
|
+
* the live slice once this session has probed; otherwise the slice
|
|
167352
|
+
* overlaid with the flags persisted by the last successful probe. A
|
|
167353
|
+
* battery camera asleep at boot skips its probe, so without the overlay
|
|
167354
|
+
* its probe-gated caps vanish across every provider restart. With no
|
|
167355
|
+
* persisted probe stamp, the slice is returned unchanged.
|
|
167356
|
+
*/
|
|
167357
|
+
function effectiveProbeFlags(sliceProbed, sliceFlags, deviceCache) {
|
|
167358
|
+
if (sliceProbed || deviceCache?.probedAt === void 0) return sliceFlags;
|
|
167359
|
+
return {
|
|
167360
|
+
...sliceFlags,
|
|
167361
|
+
...resolveAccessoryProbeFlags(false, {}, deviceCache)
|
|
167362
|
+
};
|
|
167363
|
+
}
|
|
165373
167364
|
//#endregion
|
|
165374
167365
|
//#region src/metadata-populator.ts
|
|
165375
167366
|
var EXTENDED_INFO_TAGS = [
|
|
@@ -167321,6 +169312,19 @@ var ReolinkCamera = class ReolinkCamera extends BaseDevice {
|
|
|
167321
169312
|
* underlying state. The set is small (≤6 entries) so allocation cost
|
|
167322
169313
|
* is negligible vs the staleness of caching.
|
|
167323
169314
|
*/
|
|
169315
|
+
/**
|
|
169316
|
+
* Probe flags with the persisted fallback: until this session has probed
|
|
169317
|
+
* (a battery camera asleep at boot skips `onProbe`), the flags of the last
|
|
169318
|
+
* successful probe stored in `deviceCache` stand in for the empty
|
|
169319
|
+
* `feature-probe` slice. Every probe-gated read — PTZ / intercom /
|
|
169320
|
+
* doorbell / autotrack registration, `features`, accessory children —
|
|
169321
|
+
* goes through here, so a sleeping camera keeps those caps across a
|
|
169322
|
+
* provider restart. `config` is read defensively: the base constructor
|
|
169323
|
+
* may read flags before this class's fields exist.
|
|
169324
|
+
*/
|
|
169325
|
+
getProbeFlags() {
|
|
169326
|
+
return effectiveProbeFlags(this.hasProbed(), super.getProbeFlags(), this.config?.get("deviceCache"));
|
|
169327
|
+
}
|
|
167324
169328
|
get features() {
|
|
167325
169329
|
return deriveReolinkCameraFeatures({
|
|
167326
169330
|
probe: this.getProbeFlags(),
|
|
@@ -168185,9 +170189,7 @@ var ReolinkCamera = class ReolinkCamera extends BaseDevice {
|
|
|
168185
170189
|
* parent register.
|
|
168186
170190
|
*/
|
|
168187
170191
|
getAccessoryChildren() {
|
|
168188
|
-
const
|
|
168189
|
-
if (!hasEverProbed(this.hasProbed(), deviceCache)) return [];
|
|
168190
|
-
const probe = resolveAccessoryProbeFlags(this.hasProbed(), this.getProbeFlags(), deviceCache);
|
|
170192
|
+
const kinds = accessoryKindsFor(this.hasProbed(), this.getProbeFlags(), this.config.get("deviceCache"));
|
|
168191
170193
|
const out = [];
|
|
168192
170194
|
const push = (kind, type, label) => {
|
|
168193
170195
|
out.push({
|
|
@@ -168203,9 +170205,9 @@ var ReolinkCamera = class ReolinkCamera extends BaseDevice {
|
|
|
168203
170205
|
factory: (ctx) => createAccessoryDevice(kind, ctx, this)
|
|
168204
170206
|
});
|
|
168205
170207
|
};
|
|
168206
|
-
if (
|
|
168207
|
-
if (
|
|
168208
|
-
if (
|
|
170208
|
+
if (kinds.includes(AccessoryKind.Siren)) push(AccessoryKind.Siren, DeviceType.Siren, ACCESSORY_LABEL[AccessoryKind.Siren]);
|
|
170209
|
+
if (kinds.includes(AccessoryKind.Floodlight)) push(AccessoryKind.Floodlight, DeviceType.Light, ACCESSORY_LABEL[AccessoryKind.Floodlight]);
|
|
170210
|
+
if (kinds.includes(AccessoryKind.PirSensor)) push(AccessoryKind.PirSensor, DeviceType.Switch, ACCESSORY_LABEL[AccessoryKind.PirSensor]);
|
|
168209
170211
|
return out;
|
|
168210
170212
|
}
|
|
168211
170213
|
/**
|
|
@@ -172656,6 +174658,14 @@ var ReolinkCamera = class ReolinkCamera extends BaseDevice {
|
|
|
172656
174658
|
meta: { error: err instanceof Error ? err.message : String(err) }
|
|
172657
174659
|
});
|
|
172658
174660
|
}
|
|
174661
|
+
if (!this.hasProbed()) try {
|
|
174662
|
+
await this.reprobe();
|
|
174663
|
+
} catch (err) {
|
|
174664
|
+
this.ctx.logger.debug("onWakeTransition: feature probe failed — next wake retries", {
|
|
174665
|
+
tags: { deviceId: this.id },
|
|
174666
|
+
meta: { error: err instanceof Error ? err.message : String(err) }
|
|
174667
|
+
});
|
|
174668
|
+
}
|
|
172659
174669
|
await this.warmCapSlicesOnWake();
|
|
172660
174670
|
await this.warmSnapshotOnWake();
|
|
172661
174671
|
await this.alignAuxDevicesState("wake");
|
|
@@ -174724,6 +176734,7 @@ var ReolinkCamera = class ReolinkCamera extends BaseDevice {
|
|
|
174724
176734
|
let hasBattery;
|
|
174725
176735
|
let hasPirSensor;
|
|
174726
176736
|
let hasAutotrack;
|
|
176737
|
+
let capabilitiesRead = false;
|
|
174727
176738
|
try {
|
|
174728
176739
|
channelCount = await api.getChannelCount();
|
|
174729
176740
|
} catch {}
|
|
@@ -174737,6 +176748,7 @@ var ReolinkCamera = class ReolinkCamera extends BaseDevice {
|
|
|
174737
176748
|
hasBattery = capabilities.hasBattery;
|
|
174738
176749
|
hasPirSensor = capabilities.hasPir;
|
|
174739
176750
|
hasAutotrack = capabilities.hasAutotracking;
|
|
176751
|
+
capabilitiesRead = true;
|
|
174740
176752
|
} catch (err) {
|
|
174741
176753
|
this.ctx.logger.debug("getDeviceCapabilities failed — leaving flags unset", {
|
|
174742
176754
|
tags: { deviceId: this.id },
|
|
@@ -174773,12 +176785,12 @@ var ReolinkCamera = class ReolinkCamera extends BaseDevice {
|
|
|
174773
176785
|
};
|
|
174774
176786
|
this.runtimeState.setCapState("feature-probe", next);
|
|
174775
176787
|
try {
|
|
174776
|
-
const
|
|
174777
|
-
|
|
174778
|
-
...previous,
|
|
176788
|
+
const identity = {
|
|
176789
|
+
...this.config.get("deviceCache") ?? {},
|
|
174779
176790
|
...inferredDeviceType ? { deviceType: inferredDeviceType } : {},
|
|
174780
176791
|
...channelCount !== void 0 ? { channelCount } : {}
|
|
174781
|
-
}
|
|
176792
|
+
};
|
|
176793
|
+
await this.config.setAll({ deviceCache: capabilitiesRead ? withPersistedProbe(identity, flags, now) : identity });
|
|
174782
176794
|
} catch (err) {
|
|
174783
176795
|
this.ctx.logger.debug("deviceCache identity persist failed (non-fatal)", {
|
|
174784
176796
|
tags: { deviceId: this.id },
|
|
@@ -177229,6 +179241,8 @@ async function enrichHostIdentifiersFromLiveApi(detection, logger) {
|
|
|
177229
179241
|
}
|
|
177230
179242
|
}
|
|
177231
179243
|
var ReolinkProviderAddon = class extends BaseDeviceProvider {
|
|
179244
|
+
/** The email-push SMTP password is hidden state — kept in the keychain (D787). */
|
|
179245
|
+
secretStatePaths = ["emailPushAuthPassword"];
|
|
177232
179246
|
addonId = REOLINK_ADDON_ID;
|
|
177233
179247
|
providerName = "Reolink";
|
|
177234
179248
|
deviceClasses = {
|