@camstack/addon-provider-rtsp 1.2.122 → 1.2.123
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/addon.js +1845 -56
- package/dist/addon.mjs +1845 -56
- package/package.json +1 -1
package/dist/addon.js
CHANGED
|
@@ -23,7 +23,7 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
23
23
|
//#endregion
|
|
24
24
|
let node_net = require("node:net");
|
|
25
25
|
node_net = __toESM(node_net);
|
|
26
|
-
//#region ../types/dist/event-category-
|
|
26
|
+
//#region ../types/dist/event-category-DaIZi00R.mjs
|
|
27
27
|
var EventCategory = /* @__PURE__ */ function(EventCategory) {
|
|
28
28
|
EventCategory["SystemBoot"] = "system.boot";
|
|
29
29
|
EventCategory["SystemAddonsReady"] = "system.addons-ready";
|
|
@@ -102,6 +102,13 @@ var EventCategory = /* @__PURE__ */ function(EventCategory) {
|
|
|
102
102
|
*/
|
|
103
103
|
EventCategory["AddonLoadFailed"] = "addon.load-failed";
|
|
104
104
|
/**
|
|
105
|
+
* A keychain value was stored or removed (D787). Carries the ref, its
|
|
106
|
+
* owner and the new version — NEVER the value. A process holding the ref
|
|
107
|
+
* drops its cached copy and the owning `BaseAddon` re-resolves its config.
|
|
108
|
+
* Telemetry (D8): a process that misses it still revalidates by version.
|
|
109
|
+
*/
|
|
110
|
+
EventCategory["KeychainChanged"] = "keychain.changed";
|
|
111
|
+
/**
|
|
105
112
|
* Addon recovered from a previous failure. Emitted when an addon
|
|
106
113
|
* transitions from `failed` back to `healthy` (typically via the
|
|
107
114
|
* monitor's auto-retry loop, or after manual `addons.retryLoad`).
|
|
@@ -5394,7 +5401,7 @@ var ZodIssueCode = {
|
|
|
5394
5401
|
var ZodFirstPartyTypeKind;
|
|
5395
5402
|
ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {});
|
|
5396
5403
|
//#endregion
|
|
5397
|
-
//#region ../types/dist/sleep-
|
|
5404
|
+
//#region ../types/dist/sleep-Cr5YOk3m.mjs
|
|
5398
5405
|
/**
|
|
5399
5406
|
* The audio chunk plane's byte format, and the ONE expansion from a coded
|
|
5400
5407
|
* window to float samples (D455).
|
|
@@ -5473,6 +5480,97 @@ function buildAlawTable() {
|
|
|
5473
5480
|
}
|
|
5474
5481
|
buildUlawTable();
|
|
5475
5482
|
buildAlawTable();
|
|
5483
|
+
/** Is this field's stored value a credential? */
|
|
5484
|
+
function isSecretConfigField(field) {
|
|
5485
|
+
if (field.type === "password") return true;
|
|
5486
|
+
return "secret" in field && field.secret === true;
|
|
5487
|
+
}
|
|
5488
|
+
/**
|
|
5489
|
+
* Is this field's value stored in the KEYCHAIN (D787)? Every secret field is,
|
|
5490
|
+
* by its TYPE, unless it opts out with `storage: 'inline'` — never by its name.
|
|
5491
|
+
*/
|
|
5492
|
+
function isKeychainStoredField(field) {
|
|
5493
|
+
if (!isSecretConfigField(field)) return false;
|
|
5494
|
+
if (field.type === "textarea" && field.isJson === true) return false;
|
|
5495
|
+
return !("storage" in field && field.storage === "inline");
|
|
5496
|
+
}
|
|
5497
|
+
/**
|
|
5498
|
+
* What a settings blob holds where a secret used to be.
|
|
5499
|
+
*
|
|
5500
|
+
* A keychain-stored field never holds its value. It holds a self-describing
|
|
5501
|
+
* MARKER, `{"$secret":"secret://…","v":1}` — an object, never a string, so no
|
|
5502
|
+
* code can mistake it for a credential and no form can send it to a camera as
|
|
5503
|
+
* a password. The empty state is `null` / absent, never `''`.
|
|
5504
|
+
*
|
|
5505
|
+
* The same shapes travel to and from the admin UI:
|
|
5506
|
+
*
|
|
5507
|
+
* - read: `hydrateSchema` hands a secret field a {@link SecretFieldView}
|
|
5508
|
+
* (`{ $secret, v, set: true }`) or `null` — the browser learns whether a
|
|
5509
|
+
* value is set, never the value.
|
|
5510
|
+
* - write: an untouched field submits the view back unchanged (KEEP); a typed
|
|
5511
|
+
* value is a plain non-empty string (CHANGE); the Clear button submits
|
|
5512
|
+
* {@link SECRET_CLEAR} (CLEAR). `''`, `null` and the legacy redaction tokens
|
|
5513
|
+
* are KEEP — an empty string is what a defaults-fallback pushes back, and
|
|
5514
|
+
* treating it as "clear" is how a save destroyed a stored credential before.
|
|
5515
|
+
*
|
|
5516
|
+
* Pure and browser-safe.
|
|
5517
|
+
*/
|
|
5518
|
+
var SECRET_CLEAR = { $secretClear: true };
|
|
5519
|
+
/** The `'***'` token D634 redaction writes for non-admins. */
|
|
5520
|
+
var LEGACY_DEVICE_REDACTION = "***";
|
|
5521
|
+
function isRecord$1(value) {
|
|
5522
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
5523
|
+
}
|
|
5524
|
+
function makeSecretMarker(ref) {
|
|
5525
|
+
return {
|
|
5526
|
+
$secret: ref,
|
|
5527
|
+
v: 1
|
|
5528
|
+
};
|
|
5529
|
+
}
|
|
5530
|
+
/** A stored marker: an object whose `$secret` is a non-empty string. */
|
|
5531
|
+
function isSecretMarker(value) {
|
|
5532
|
+
if (!isRecord$1(value)) return false;
|
|
5533
|
+
const ref = value["$secret"];
|
|
5534
|
+
return typeof ref === "string" && ref.length > 0;
|
|
5535
|
+
}
|
|
5536
|
+
function isSecretClear(value) {
|
|
5537
|
+
return isRecord$1(value) && value["$secretClear"] === true;
|
|
5538
|
+
}
|
|
5539
|
+
/**
|
|
5540
|
+
* The UI view of a stored secret field value: a marker becomes "set", inline
|
|
5541
|
+
* plaintext becomes "set (inline)", nothing becomes `null`. A value never
|
|
5542
|
+
* survives this function.
|
|
5543
|
+
*/
|
|
5544
|
+
function toSecretFieldView(stored) {
|
|
5545
|
+
if (isSecretMarker(stored)) return {
|
|
5546
|
+
$secret: stored.$secret,
|
|
5547
|
+
v: 1,
|
|
5548
|
+
set: true
|
|
5549
|
+
};
|
|
5550
|
+
if (typeof stored === "string" && stored.length > 0) return {
|
|
5551
|
+
$secret: null,
|
|
5552
|
+
v: 1,
|
|
5553
|
+
set: true,
|
|
5554
|
+
inline: true
|
|
5555
|
+
};
|
|
5556
|
+
return null;
|
|
5557
|
+
}
|
|
5558
|
+
/**
|
|
5559
|
+
* Classify an incoming value for a secret path. Only a non-empty string that is
|
|
5560
|
+
* not a redaction token sets a value; only {@link SECRET_CLEAR} clears.
|
|
5561
|
+
* Everything else — a marker (ours or anyone's), a UI view, `''`, `null`,
|
|
5562
|
+
* `undefined`, a redaction token, a non-string — keeps what is stored.
|
|
5563
|
+
*/
|
|
5564
|
+
function classifySecretWrite(incoming) {
|
|
5565
|
+
if (isSecretClear(incoming)) return { kind: "clear" };
|
|
5566
|
+
if (typeof incoming !== "string") return { kind: "keep" };
|
|
5567
|
+
if (incoming.length === 0) return { kind: "keep" };
|
|
5568
|
+
if (incoming === "__camstack_redacted__" || incoming === LEGACY_DEVICE_REDACTION) return { kind: "keep" };
|
|
5569
|
+
return {
|
|
5570
|
+
kind: "set",
|
|
5571
|
+
value: incoming
|
|
5572
|
+
};
|
|
5573
|
+
}
|
|
5476
5574
|
Object.fromEntries([
|
|
5477
5575
|
{
|
|
5478
5576
|
id: "overview",
|
|
@@ -5644,33 +5742,19 @@ Object.fromEntries([
|
|
|
5644
5742
|
function isValuelessField(field) {
|
|
5645
5743
|
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";
|
|
5646
5744
|
}
|
|
5647
|
-
|
|
5648
|
-
* Merge a `ConfigUISchema` with a raw `values` record into a
|
|
5649
|
-
* `ConfigUISchemaWithValues`. Used by every `get*Settings` backend endpoint
|
|
5650
|
-
* before returning to the admin UI. Groups are walked recursively.
|
|
5651
|
-
*
|
|
5652
|
-
* For each leaf field:
|
|
5653
|
-
* - structural fields (`separator`, `info`, `button`) pass through unchanged
|
|
5654
|
-
* - other fields get `value = values[key] ?? field.default ?? null`
|
|
5655
|
-
*
|
|
5656
|
-
* Unknown keys in `values` (keys not declared in the schema) are silently
|
|
5657
|
-
* ignored — they don't contribute to the output. Missing keys fall back to
|
|
5658
|
-
* the schema default or `null`. This mirrors the old backend behaviour where
|
|
5659
|
-
* `FormBuilder` rendered `values[key] ?? field.default`.
|
|
5660
|
-
*/
|
|
5661
|
-
function hydrateSchema(schema, values) {
|
|
5745
|
+
function hydrateSchema(schema, values, options = {}) {
|
|
5662
5746
|
return {
|
|
5663
5747
|
...schema.tabs ? { tabs: [...schema.tabs] } : {},
|
|
5664
5748
|
sections: schema.sections.map((section) => ({
|
|
5665
5749
|
...section,
|
|
5666
|
-
fields: section.fields.map((field) => hydrateField(field, values))
|
|
5750
|
+
fields: section.fields.map((field) => hydrateField(field, values, options))
|
|
5667
5751
|
}))
|
|
5668
5752
|
};
|
|
5669
5753
|
}
|
|
5670
|
-
function hydrateField(field, values) {
|
|
5754
|
+
function hydrateField(field, values, options) {
|
|
5671
5755
|
if (isValuelessField(field)) return field;
|
|
5672
5756
|
if (field.type === "group") {
|
|
5673
|
-
const hydratedChildren = field.fields.map((child) => hydrateField(child, values));
|
|
5757
|
+
const hydratedChildren = field.fields.map((child) => hydrateField(child, values, options));
|
|
5674
5758
|
return {
|
|
5675
5759
|
...field,
|
|
5676
5760
|
fields: hydratedChildren
|
|
@@ -5679,7 +5763,7 @@ function hydrateField(field, values) {
|
|
|
5679
5763
|
if (field.type === "sub-tabs") {
|
|
5680
5764
|
const hydratedTabs = field.tabs.map((tab) => ({
|
|
5681
5765
|
...tab,
|
|
5682
|
-
fields: tab.fields.map((child) => hydrateField(child, values))
|
|
5766
|
+
fields: tab.fields.map((child) => hydrateField(child, values, options))
|
|
5683
5767
|
}));
|
|
5684
5768
|
return {
|
|
5685
5769
|
...field,
|
|
@@ -5689,6 +5773,33 @@ function hydrateField(field, values) {
|
|
|
5689
5773
|
const key = field.key;
|
|
5690
5774
|
const storedValue = Object.prototype.hasOwnProperty.call(values, key) ? values[key] : void 0;
|
|
5691
5775
|
const defaultValue = field.default;
|
|
5776
|
+
const asView = (v) => isSecretMarker(v) || options.inlineSecretsAsViews === true && v !== void 0;
|
|
5777
|
+
if (isKeychainStoredField(field) && asView(storedValue)) return {
|
|
5778
|
+
...field,
|
|
5779
|
+
value: toSecretFieldView(storedValue)
|
|
5780
|
+
};
|
|
5781
|
+
if (isKeychainStoredField(field) && options.inlineSecretsAsViews === true) return {
|
|
5782
|
+
...field,
|
|
5783
|
+
value: null
|
|
5784
|
+
};
|
|
5785
|
+
if (field.type === "editable-array" && Array.isArray(storedValue)) {
|
|
5786
|
+
const secretItemKeys = field.itemFields.filter((item) => "key" in item && isKeychainStoredField(item)).map((item) => "key" in item ? item.key : "");
|
|
5787
|
+
if (secretItemKeys.length > 0) {
|
|
5788
|
+
const rows = storedValue.map((row) => {
|
|
5789
|
+
if (row === null || typeof row !== "object" || Array.isArray(row)) return row;
|
|
5790
|
+
const out = { ...row };
|
|
5791
|
+
for (const k of secretItemKeys) {
|
|
5792
|
+
const v = Reflect.get(row, k);
|
|
5793
|
+
if (asView(v)) out[k] = toSecretFieldView(v);
|
|
5794
|
+
}
|
|
5795
|
+
return out;
|
|
5796
|
+
});
|
|
5797
|
+
return {
|
|
5798
|
+
...field,
|
|
5799
|
+
value: rows
|
|
5800
|
+
};
|
|
5801
|
+
}
|
|
5802
|
+
}
|
|
5692
5803
|
if (field.multiple) {
|
|
5693
5804
|
const stored = Array.isArray(storedValue) ? storedValue : storedValue !== void 0 && storedValue !== null ? [storedValue] : [];
|
|
5694
5805
|
const itemFallback = field.multiple.itemDefault !== void 0 ? field.multiple.itemDefault : defaultValue !== void 0 ? defaultValue : typeOf(field) === "string" ? "" : null;
|
|
@@ -5931,6 +6042,431 @@ function projectStore(store, perNodeKeys, nodeId) {
|
|
|
5931
6042
|
}
|
|
5932
6043
|
return out;
|
|
5933
6044
|
}
|
|
6045
|
+
var GLOBAL_SCOPE = { kind: "global" };
|
|
6046
|
+
/** The scope every addon-wide (not per-node, not per-device) setting lives in. */
|
|
6047
|
+
function globalSecretScope() {
|
|
6048
|
+
return GLOBAL_SCOPE;
|
|
6049
|
+
}
|
|
6050
|
+
function encodeSegment(value) {
|
|
6051
|
+
return encodeURIComponent(value);
|
|
6052
|
+
}
|
|
6053
|
+
/**
|
|
6054
|
+
* The field path of a value inside an array item, addressed by the item's id:
|
|
6055
|
+
* `arrayItemFieldPath('providers', 'authentik', 'clientSecret')` →
|
|
6056
|
+
* `providers[authentik].clientSecret`.
|
|
6057
|
+
*/
|
|
6058
|
+
function arrayItemFieldPath(arrayKey, itemId, fieldKey) {
|
|
6059
|
+
return `${arrayKey}[${encodeSegment(itemId)}].${fieldKey}`;
|
|
6060
|
+
}
|
|
6061
|
+
/** A write to a secret path could not be stored in the keychain, so it was refused. */
|
|
6062
|
+
var KeychainWriteRefusedError = class extends Error {
|
|
6063
|
+
fieldPath;
|
|
6064
|
+
constructor(fieldPath, cause) {
|
|
6065
|
+
super(`secret "${fieldPath}" was not saved: the keychain could not store it (${cause instanceof Error ? cause.message : String(cause)}). Nothing was written.`);
|
|
6066
|
+
this.fieldPath = fieldPath;
|
|
6067
|
+
this.name = "KeychainWriteRefusedError";
|
|
6068
|
+
}
|
|
6069
|
+
};
|
|
6070
|
+
var KEEP = { kind: "keep" };
|
|
6071
|
+
function isRecord(value) {
|
|
6072
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
6073
|
+
}
|
|
6074
|
+
function defaultMintId() {
|
|
6075
|
+
return globalThis.crypto.randomUUID();
|
|
6076
|
+
}
|
|
6077
|
+
/** Every marker ref anywhere under `value`. */
|
|
6078
|
+
function collectSecretMarkerRefs(value, out = []) {
|
|
6079
|
+
if (isSecretMarker(value)) {
|
|
6080
|
+
out.push(value.$secret);
|
|
6081
|
+
return out;
|
|
6082
|
+
}
|
|
6083
|
+
if (Array.isArray(value)) for (const item of value) collectSecretMarkerRefs(item, out);
|
|
6084
|
+
else if (isRecord(value)) for (const child of Object.values(value)) collectSecretMarkerRefs(child, out);
|
|
6085
|
+
return out;
|
|
6086
|
+
}
|
|
6087
|
+
async function storedValueEquals(secrets, marker, candidate) {
|
|
6088
|
+
const resolved = (await secrets.resolve([marker.$secret]))[marker.$secret];
|
|
6089
|
+
return resolved?.kind === "value" && resolved.value === candidate;
|
|
6090
|
+
}
|
|
6091
|
+
async function writeLeaf(ctx, incoming, stored, fieldPath) {
|
|
6092
|
+
const intent = classifySecretWrite(incoming);
|
|
6093
|
+
const ref = ctx.secrets.ref(ctx.scope, fieldPath);
|
|
6094
|
+
const storedIsOurs = isSecretMarker(stored) && stored.$secret === ref;
|
|
6095
|
+
if (intent.kind === "keep") return KEEP;
|
|
6096
|
+
if (intent.kind === "set" && !ctx.operatorWrite && typeof stored === "string" && stored === intent.value) return KEEP;
|
|
6097
|
+
if (intent.kind === "clear") {
|
|
6098
|
+
if (storedIsOurs) ctx.deletes.push(ref);
|
|
6099
|
+
return {
|
|
6100
|
+
kind: "value",
|
|
6101
|
+
value: null
|
|
6102
|
+
};
|
|
6103
|
+
}
|
|
6104
|
+
if (storedIsOurs && await storedValueEquals(ctx.secrets, stored, intent.value)) return {
|
|
6105
|
+
kind: "value",
|
|
6106
|
+
value: stored
|
|
6107
|
+
};
|
|
6108
|
+
try {
|
|
6109
|
+
await ctx.secrets.put(ref, intent.value);
|
|
6110
|
+
} catch (err) {
|
|
6111
|
+
throw new KeychainWriteRefusedError(fieldPath, err);
|
|
6112
|
+
}
|
|
6113
|
+
return {
|
|
6114
|
+
kind: "value",
|
|
6115
|
+
value: makeSecretMarker(ref)
|
|
6116
|
+
};
|
|
6117
|
+
}
|
|
6118
|
+
/** Apply a member result onto `out`: KEEP restores the stored member, or removes it. */
|
|
6119
|
+
function applyMember(out, key, result, storedParent) {
|
|
6120
|
+
if (result.kind === "value") {
|
|
6121
|
+
out[key] = result.value;
|
|
6122
|
+
return;
|
|
6123
|
+
}
|
|
6124
|
+
if (Object.prototype.hasOwnProperty.call(storedParent, key)) out[key] = storedParent[key];
|
|
6125
|
+
else delete out[key];
|
|
6126
|
+
}
|
|
6127
|
+
async function writeMembers(ctx, children, incoming, stored, pathOf) {
|
|
6128
|
+
const out = { ...incoming };
|
|
6129
|
+
for (const [member, node] of children) applyMember(out, member, await writeNode(ctx, node, incoming[member], stored[member], pathOf(member)), stored);
|
|
6130
|
+
return out;
|
|
6131
|
+
}
|
|
6132
|
+
function rowId(row, idKey) {
|
|
6133
|
+
const raw = row[idKey];
|
|
6134
|
+
if (typeof raw === "string" && raw.length > 0) return raw;
|
|
6135
|
+
if (typeof raw === "number" && Number.isFinite(raw)) return String(raw);
|
|
6136
|
+
return null;
|
|
6137
|
+
}
|
|
6138
|
+
async function writeArray(ctx, node, incoming, stored, fieldPath) {
|
|
6139
|
+
const storedRows = Array.isArray(stored) ? stored.filter(isRecord) : [];
|
|
6140
|
+
if (!Array.isArray(incoming)) {
|
|
6141
|
+
ctx.deletes.push(...collectSecretMarkerRefs(storedRows));
|
|
6142
|
+
return {
|
|
6143
|
+
kind: "value",
|
|
6144
|
+
value: incoming
|
|
6145
|
+
};
|
|
6146
|
+
}
|
|
6147
|
+
const storedById = /* @__PURE__ */ new Map();
|
|
6148
|
+
for (const row of storedRows) {
|
|
6149
|
+
const id = rowId(row, node.idKey);
|
|
6150
|
+
if (id !== null) storedById.set(id, row);
|
|
6151
|
+
}
|
|
6152
|
+
const kept = /* @__PURE__ */ new Set();
|
|
6153
|
+
const rows = [];
|
|
6154
|
+
for (const row of incoming) {
|
|
6155
|
+
if (!isRecord(row)) {
|
|
6156
|
+
rows.push(row);
|
|
6157
|
+
continue;
|
|
6158
|
+
}
|
|
6159
|
+
const id = rowId(row, node.idKey) ?? ctx.mintId();
|
|
6160
|
+
kept.add(id);
|
|
6161
|
+
const withId = {
|
|
6162
|
+
...row,
|
|
6163
|
+
[node.idKey]: row[node.idKey] ?? id
|
|
6164
|
+
};
|
|
6165
|
+
if (rowId(withId, node.idKey) === null) withId[node.idKey] = id;
|
|
6166
|
+
const storedRow = storedById.get(id) ?? {};
|
|
6167
|
+
rows.push(await writeMembers(ctx, node.item, withId, storedRow, (member) => arrayItemFieldPath(fieldPath, id, member)));
|
|
6168
|
+
}
|
|
6169
|
+
for (const [id, row] of storedById) if (!kept.has(id)) ctx.deletes.push(...collectSecretMarkerRefs(row));
|
|
6170
|
+
return {
|
|
6171
|
+
kind: "value",
|
|
6172
|
+
value: rows
|
|
6173
|
+
};
|
|
6174
|
+
}
|
|
6175
|
+
async function writeNode(ctx, node, incoming, stored, fieldPath) {
|
|
6176
|
+
switch (node.kind) {
|
|
6177
|
+
case "leaf": return writeLeaf(ctx, incoming, stored, fieldPath);
|
|
6178
|
+
case "array": return writeArray(ctx, node, incoming, stored, fieldPath);
|
|
6179
|
+
case "object": {
|
|
6180
|
+
if (!isRecord(incoming)) {
|
|
6181
|
+
if (incoming === void 0) return KEEP;
|
|
6182
|
+
ctx.deletes.push(...collectSecretMarkerRefs(stored));
|
|
6183
|
+
return {
|
|
6184
|
+
kind: "value",
|
|
6185
|
+
value: incoming
|
|
6186
|
+
};
|
|
6187
|
+
}
|
|
6188
|
+
const storedObj = isRecord(stored) ? stored : {};
|
|
6189
|
+
return {
|
|
6190
|
+
kind: "value",
|
|
6191
|
+
value: await writeMembers(ctx, node.children, incoming, storedObj, (m) => `${fieldPath}.${m}`)
|
|
6192
|
+
};
|
|
6193
|
+
}
|
|
6194
|
+
}
|
|
6195
|
+
}
|
|
6196
|
+
/** Split a perNode-scoped key (`key@nodeId`). */
|
|
6197
|
+
function splitNodeKey(key) {
|
|
6198
|
+
const at = key.indexOf("@");
|
|
6199
|
+
return at <= 0 ? {
|
|
6200
|
+
base: key,
|
|
6201
|
+
nodeId: null
|
|
6202
|
+
} : {
|
|
6203
|
+
base: key.slice(0, at),
|
|
6204
|
+
nodeId: key.slice(at + 1)
|
|
6205
|
+
};
|
|
6206
|
+
}
|
|
6207
|
+
/** Rewrite a settings patch so no secret value reaches the blob. See the file doc. */
|
|
6208
|
+
async function transformSecretWrite(input) {
|
|
6209
|
+
const deletes = [];
|
|
6210
|
+
const base = {
|
|
6211
|
+
secrets: input.secrets,
|
|
6212
|
+
mintId: input.mintId ?? defaultMintId,
|
|
6213
|
+
deletes,
|
|
6214
|
+
operatorWrite: input.operatorWrite === true
|
|
6215
|
+
};
|
|
6216
|
+
const out = {};
|
|
6217
|
+
for (const [key, incoming] of Object.entries(input.patch)) {
|
|
6218
|
+
const { base: baseKey, nodeId } = splitNodeKey(key);
|
|
6219
|
+
const node = input.tree.get(baseKey);
|
|
6220
|
+
if (node === void 0) {
|
|
6221
|
+
out[key] = incoming;
|
|
6222
|
+
continue;
|
|
6223
|
+
}
|
|
6224
|
+
const scope = nodeId !== null && nodeId.length > 0 ? {
|
|
6225
|
+
kind: "node",
|
|
6226
|
+
nodeId
|
|
6227
|
+
} : input.scope ?? globalSecretScope();
|
|
6228
|
+
const result = await writeNode({
|
|
6229
|
+
...base,
|
|
6230
|
+
scope
|
|
6231
|
+
}, node, incoming, input.stored[key], baseKey);
|
|
6232
|
+
if (result.kind === "value") out[key] = result.value;
|
|
6233
|
+
}
|
|
6234
|
+
return {
|
|
6235
|
+
patch: out,
|
|
6236
|
+
afterWrite: async () => {
|
|
6237
|
+
if (deletes.length === 0) return { orphaned: [] };
|
|
6238
|
+
try {
|
|
6239
|
+
await input.secrets.delete([...new Set(deletes)]);
|
|
6240
|
+
return { orphaned: [] };
|
|
6241
|
+
} catch {
|
|
6242
|
+
return { orphaned: [...new Set(deletes)] };
|
|
6243
|
+
}
|
|
6244
|
+
}
|
|
6245
|
+
};
|
|
6246
|
+
}
|
|
6247
|
+
/**
|
|
6248
|
+
* Replace every marker in `value` with its keychain value. Returns the SAME
|
|
6249
|
+
* reference when there is no marker (no allocation, no keychain call).
|
|
6250
|
+
*/
|
|
6251
|
+
async function resolveSecretMarkers(value, secrets) {
|
|
6252
|
+
const refs = collectSecretMarkerRefs(value);
|
|
6253
|
+
if (refs.length === 0) return {
|
|
6254
|
+
value,
|
|
6255
|
+
unresolved: []
|
|
6256
|
+
};
|
|
6257
|
+
const answers = await secrets.resolve(refs);
|
|
6258
|
+
const unresolved = [];
|
|
6259
|
+
for (const ref of new Set(refs)) {
|
|
6260
|
+
const answer = answers[ref];
|
|
6261
|
+
if (answer === void 0) unresolved.push({
|
|
6262
|
+
ref,
|
|
6263
|
+
reason: "not-initialized"
|
|
6264
|
+
});
|
|
6265
|
+
else if (answer.kind === "unavailable") unresolved.push({
|
|
6266
|
+
ref,
|
|
6267
|
+
reason: answer.reason
|
|
6268
|
+
});
|
|
6269
|
+
else if (answer.kind === "missing" || answer.kind === "forbidden") unresolved.push({
|
|
6270
|
+
ref,
|
|
6271
|
+
reason: answer.kind
|
|
6272
|
+
});
|
|
6273
|
+
}
|
|
6274
|
+
const substitute = (v) => {
|
|
6275
|
+
if (isSecretMarker(v)) {
|
|
6276
|
+
const answer = answers[v.$secret];
|
|
6277
|
+
return answer?.kind === "value" ? {
|
|
6278
|
+
keep: true,
|
|
6279
|
+
value: answer.value
|
|
6280
|
+
} : {
|
|
6281
|
+
keep: false,
|
|
6282
|
+
value: void 0
|
|
6283
|
+
};
|
|
6284
|
+
}
|
|
6285
|
+
if (Array.isArray(v)) {
|
|
6286
|
+
const items = [];
|
|
6287
|
+
for (const item of v) {
|
|
6288
|
+
const s = substitute(item);
|
|
6289
|
+
if (s.keep) items.push(s.value);
|
|
6290
|
+
}
|
|
6291
|
+
return {
|
|
6292
|
+
keep: true,
|
|
6293
|
+
value: items
|
|
6294
|
+
};
|
|
6295
|
+
}
|
|
6296
|
+
if (isRecord(v)) {
|
|
6297
|
+
const out = {};
|
|
6298
|
+
for (const [k, child] of Object.entries(v)) {
|
|
6299
|
+
const s = substitute(child);
|
|
6300
|
+
if (s.keep) out[k] = s.value;
|
|
6301
|
+
}
|
|
6302
|
+
return {
|
|
6303
|
+
keep: true,
|
|
6304
|
+
value: out
|
|
6305
|
+
};
|
|
6306
|
+
}
|
|
6307
|
+
return {
|
|
6308
|
+
keep: true,
|
|
6309
|
+
value: v
|
|
6310
|
+
};
|
|
6311
|
+
};
|
|
6312
|
+
return {
|
|
6313
|
+
value: substitute(value).value,
|
|
6314
|
+
unresolved
|
|
6315
|
+
};
|
|
6316
|
+
}
|
|
6317
|
+
function touchesTree(tree, patch) {
|
|
6318
|
+
if (tree.size === 0) return false;
|
|
6319
|
+
for (const key of Object.keys(patch)) {
|
|
6320
|
+
const at = key.indexOf("@");
|
|
6321
|
+
if (tree.has(at > 0 ? key.slice(0, at) : key)) return true;
|
|
6322
|
+
}
|
|
6323
|
+
return false;
|
|
6324
|
+
}
|
|
6325
|
+
/** The blob as stored now; a failed read REFUSES the write instead of guessing. */
|
|
6326
|
+
async function readStoredAddonBlob(raw) {
|
|
6327
|
+
const threeWay = raw.readAddonStoreResult;
|
|
6328
|
+
if (threeWay === void 0) return raw.readAddonStore();
|
|
6329
|
+
const result = await threeWay.call(raw);
|
|
6330
|
+
if (result.kind === "failed") throw new Error(`settings write refused: the stored blob could not be read (${result.error})`);
|
|
6331
|
+
return result.kind === "missing" ? {} : result.value;
|
|
6332
|
+
}
|
|
6333
|
+
function createSecretAwareSettings(raw, opts) {
|
|
6334
|
+
const chains = /* @__PURE__ */ new Map();
|
|
6335
|
+
const serialize = (key, fn) => {
|
|
6336
|
+
const next = (chains.get(key) ?? Promise.resolve()).then(fn, fn);
|
|
6337
|
+
const tail = next.catch(() => void 0);
|
|
6338
|
+
chains.set(key, tail);
|
|
6339
|
+
tail.then(() => {
|
|
6340
|
+
if (chains.get(key) === tail) chains.delete(key);
|
|
6341
|
+
});
|
|
6342
|
+
return next;
|
|
6343
|
+
};
|
|
6344
|
+
const write = async (chainKey, tree, scope, patch, readStored, rawWrite) => {
|
|
6345
|
+
if (!touchesTree(tree, patch)) return rawWrite(patch);
|
|
6346
|
+
return serialize(chainKey, async () => {
|
|
6347
|
+
const stored = await readStored();
|
|
6348
|
+
const result = await transformSecretWrite({
|
|
6349
|
+
tree,
|
|
6350
|
+
secrets: opts.secrets,
|
|
6351
|
+
patch,
|
|
6352
|
+
stored,
|
|
6353
|
+
...scope !== void 0 ? { scope } : {},
|
|
6354
|
+
operatorWrite: opts.isOperatorWrite?.() === true
|
|
6355
|
+
});
|
|
6356
|
+
if (Object.keys(result.patch).length > 0) await rawWrite(result.patch);
|
|
6357
|
+
const { orphaned } = await result.afterWrite();
|
|
6358
|
+
if (orphaned.length > 0) opts.onOrphaned(orphaned);
|
|
6359
|
+
});
|
|
6360
|
+
};
|
|
6361
|
+
const wrapped = {
|
|
6362
|
+
writeAddonStore: (patch) => write("addon", opts.addonTree(), void 0, patch, () => readStoredAddonBlob(raw), (p) => raw.writeAddonStore(p)),
|
|
6363
|
+
writeDeviceStore: (deviceId, patch) => write(`device:${deviceId}`, opts.deviceTree(), {
|
|
6364
|
+
kind: "device",
|
|
6365
|
+
deviceId
|
|
6366
|
+
}, patch, () => raw.readDeviceStore(deviceId), (p) => raw.writeDeviceStore(deviceId, p))
|
|
6367
|
+
};
|
|
6368
|
+
return new Proxy(raw, { get(target, prop, receiver) {
|
|
6369
|
+
if (prop === "writeAddonStore") return wrapped.writeAddonStore;
|
|
6370
|
+
if (prop === "writeDeviceStore") return wrapped.writeDeviceStore;
|
|
6371
|
+
const value = Reflect.get(target, prop, receiver);
|
|
6372
|
+
return typeof value === "function" ? value.bind(target) : value;
|
|
6373
|
+
} });
|
|
6374
|
+
}
|
|
6375
|
+
/** The context the addon sees: identical, except that its settings writes are secret-aware. */
|
|
6376
|
+
function withSecretAwareSettings(context, opts) {
|
|
6377
|
+
const raw = context.settings;
|
|
6378
|
+
if (raw === void 0) return context;
|
|
6379
|
+
const settings = createSecretAwareSettings(raw, opts);
|
|
6380
|
+
return new Proxy(context, { get(target, prop, receiver) {
|
|
6381
|
+
if (prop === "settings") return settings;
|
|
6382
|
+
return Reflect.get(target, prop, receiver);
|
|
6383
|
+
} });
|
|
6384
|
+
}
|
|
6385
|
+
var LEAF = { kind: "leaf" };
|
|
6386
|
+
var DEFAULT_ITEM_ID_KEY = "id";
|
|
6387
|
+
function collectFields(fields, out) {
|
|
6388
|
+
for (const field of fields) {
|
|
6389
|
+
if (field.type === "group") {
|
|
6390
|
+
collectFields(field.fields, out);
|
|
6391
|
+
continue;
|
|
6392
|
+
}
|
|
6393
|
+
if (field.type === "sub-tabs") {
|
|
6394
|
+
for (const tab of field.tabs) collectFields(tab.fields, out);
|
|
6395
|
+
continue;
|
|
6396
|
+
}
|
|
6397
|
+
if (field.type === "editable-array") {
|
|
6398
|
+
const item = /* @__PURE__ */ new Map();
|
|
6399
|
+
for (const itemField of field.itemFields) if ("key" in itemField && isKeychainStoredField(itemField)) item.set(itemField.key, LEAF);
|
|
6400
|
+
if (item.size > 0) out.set(field.key, {
|
|
6401
|
+
kind: "array",
|
|
6402
|
+
idKey: field.itemIdKey ?? DEFAULT_ITEM_ID_KEY,
|
|
6403
|
+
item
|
|
6404
|
+
});
|
|
6405
|
+
continue;
|
|
6406
|
+
}
|
|
6407
|
+
if (!("key" in field) || typeof field.key !== "string") continue;
|
|
6408
|
+
if (isKeychainStoredField(field)) out.set(field.key, LEAF);
|
|
6409
|
+
}
|
|
6410
|
+
}
|
|
6411
|
+
/** The secret tree a settings schema declares. */
|
|
6412
|
+
function secretTreeFromSchema(schema) {
|
|
6413
|
+
const out = /* @__PURE__ */ new Map();
|
|
6414
|
+
if (schema === null) return out;
|
|
6415
|
+
for (const section of schema.sections) collectFields(section.fields, out);
|
|
6416
|
+
return out;
|
|
6417
|
+
}
|
|
6418
|
+
/** Parse `a.b[id].c` into segments; throws on a malformed path (a declaration bug). */
|
|
6419
|
+
function parseSecretStatePath(path) {
|
|
6420
|
+
const segments = [];
|
|
6421
|
+
for (const raw of path.split(".")) {
|
|
6422
|
+
const m = /^([^[\]]+)(?:\[([^[\]]+)\])?$/.exec(raw);
|
|
6423
|
+
if (m === null || m[1] === void 0) throw new Error(`secretStatePaths: malformed path "${path}"`);
|
|
6424
|
+
segments.push(m[2] !== void 0 ? {
|
|
6425
|
+
key: m[1],
|
|
6426
|
+
idKey: m[2]
|
|
6427
|
+
} : { key: m[1] });
|
|
6428
|
+
}
|
|
6429
|
+
if (segments.length === 0) throw new Error(`secretStatePaths: empty path`);
|
|
6430
|
+
if (segments[segments.length - 1]?.idKey !== void 0) throw new Error(`secretStatePaths: "${path}" ends on an array — name the member that is secret`);
|
|
6431
|
+
return segments;
|
|
6432
|
+
}
|
|
6433
|
+
function insert(into, segments) {
|
|
6434
|
+
const [head, ...rest] = segments;
|
|
6435
|
+
if (head === void 0) return;
|
|
6436
|
+
if (rest.length === 0) {
|
|
6437
|
+
into.set(head.key, LEAF);
|
|
6438
|
+
return;
|
|
6439
|
+
}
|
|
6440
|
+
const existing = into.get(head.key);
|
|
6441
|
+
if (head.idKey !== void 0) {
|
|
6442
|
+
const item = new Map(existing?.kind === "array" ? existing.item : []);
|
|
6443
|
+
insert(item, rest);
|
|
6444
|
+
into.set(head.key, {
|
|
6445
|
+
kind: "array",
|
|
6446
|
+
idKey: head.idKey,
|
|
6447
|
+
item
|
|
6448
|
+
});
|
|
6449
|
+
return;
|
|
6450
|
+
}
|
|
6451
|
+
const children = new Map(existing?.kind === "object" ? existing.children : []);
|
|
6452
|
+
insert(children, rest);
|
|
6453
|
+
into.set(head.key, {
|
|
6454
|
+
kind: "object",
|
|
6455
|
+
children
|
|
6456
|
+
});
|
|
6457
|
+
}
|
|
6458
|
+
/** Add hidden-state paths (`secretStatePaths`) to a schema-derived tree. */
|
|
6459
|
+
function mergeSecretStatePaths(tree, paths) {
|
|
6460
|
+
if (paths.length === 0) return tree;
|
|
6461
|
+
const out = new Map(tree);
|
|
6462
|
+
for (const path of paths) insert(out, parseSecretStatePath(path));
|
|
6463
|
+
return out;
|
|
6464
|
+
}
|
|
6465
|
+
/** First retry of a secret the keychain could not serve; doubles to {@link SECRET_RETRY_MAX_MS}. */
|
|
6466
|
+
var SECRET_RETRY_FIRST_MS = 5e3;
|
|
6467
|
+
var SECRET_RETRY_MAX_MS = 5 * 6e4;
|
|
6468
|
+
/** Coalesces a burst of `keychain.changed` events into one re-resolve. */
|
|
6469
|
+
var SECRET_CHANGE_DEBOUNCE_MS = 250;
|
|
5934
6470
|
/**
|
|
5935
6471
|
* Base class for CamStack addons. Eliminates settings boilerplate:
|
|
5936
6472
|
*
|
|
@@ -6000,6 +6536,25 @@ var BaseAddon = class {
|
|
|
6000
6536
|
settingsStoreReady = false;
|
|
6001
6537
|
/** Default config values. Provided via constructor. */
|
|
6002
6538
|
defaults;
|
|
6539
|
+
/**
|
|
6540
|
+
* Hidden-state paths that hold secrets (D787) — values the addon writes
|
|
6541
|
+
* itself (`updateGlobalSettings`, `state()`) that no form field declares.
|
|
6542
|
+
* Stored in the keychain exactly like a `password` field. Syntax:
|
|
6543
|
+
* `'snapshotSigningKey'`, `'identity.pincode'`, `'tokens[userId].accessToken'`
|
|
6544
|
+
* (`key[<id field>]` addresses array items by id, never by index).
|
|
6545
|
+
*/
|
|
6546
|
+
secretStatePaths = [];
|
|
6547
|
+
_addonSecretTree = null;
|
|
6548
|
+
_deviceSecretTree = null;
|
|
6549
|
+
/** Refs the last resolved config pointed at — a change to one re-resolves. */
|
|
6550
|
+
_configSecretRefs = /* @__PURE__ */ new Set();
|
|
6551
|
+
_unresolvedSecrets = [];
|
|
6552
|
+
_secretRetryTimer = null;
|
|
6553
|
+
_secretRetryDelayMs = SECRET_RETRY_FIRST_MS;
|
|
6554
|
+
_secretChangeTimer = null;
|
|
6555
|
+
_secretChangeUnsub = null;
|
|
6556
|
+
/** >0 while an OPERATOR's settings write is being applied. */
|
|
6557
|
+
_operatorWriteDepth = 0;
|
|
6003
6558
|
constructor(defaults) {
|
|
6004
6559
|
this.defaults = defaults;
|
|
6005
6560
|
this._config = { ...defaults };
|
|
@@ -6035,8 +6590,18 @@ var BaseAddon = class {
|
|
|
6035
6590
|
return this._config;
|
|
6036
6591
|
}
|
|
6037
6592
|
async initialize(context) {
|
|
6038
|
-
|
|
6593
|
+
const secrets = context.secrets;
|
|
6594
|
+
this._ctx = secrets !== void 0 ? withSecretAwareSettings(context, {
|
|
6595
|
+
secrets,
|
|
6596
|
+
addonTree: () => this.addonSecretTree(),
|
|
6597
|
+
deviceTree: () => this.deviceSecretTree(),
|
|
6598
|
+
onOrphaned: (refs) => context.logger.warn("keychain refs dropped by a settings write could not be deleted", { meta: { refs: [...refs] } }),
|
|
6599
|
+
isOperatorWrite: () => this._operatorWriteDepth > 0
|
|
6600
|
+
}) : context;
|
|
6039
6601
|
await this.resolveConfig();
|
|
6602
|
+
if (secrets !== void 0) this._secretChangeUnsub = secrets.onChange((ref) => {
|
|
6603
|
+
if (this._configSecretRefs.has(ref)) this.scheduleSecretReresolve(SECRET_CHANGE_DEBOUNCE_MS);
|
|
6604
|
+
});
|
|
6040
6605
|
const result = await this.onInitialize();
|
|
6041
6606
|
this.emitLifecycle(EventCategory.AddonStarted);
|
|
6042
6607
|
const normalized = normalizeAddonInitResult(result);
|
|
@@ -6069,6 +6634,12 @@ var BaseAddon = class {
|
|
|
6069
6634
|
*/
|
|
6070
6635
|
async onHubReachable() {}
|
|
6071
6636
|
async shutdown() {
|
|
6637
|
+
this._secretChangeUnsub?.();
|
|
6638
|
+
this._secretChangeUnsub = null;
|
|
6639
|
+
if (this._secretRetryTimer !== null) clearTimeout(this._secretRetryTimer);
|
|
6640
|
+
if (this._secretChangeTimer !== null) clearTimeout(this._secretChangeTimer);
|
|
6641
|
+
this._secretRetryTimer = null;
|
|
6642
|
+
this._secretChangeTimer = null;
|
|
6072
6643
|
this.emitLifecycle(EventCategory.AddonStopped);
|
|
6073
6644
|
if (this.autoEmitReadiness) this.emitReadinessForProviders("down");
|
|
6074
6645
|
await this.onShutdown();
|
|
@@ -6147,7 +6718,7 @@ var BaseAddon = class {
|
|
|
6147
6718
|
return hydrateSchema(schema, overlay ? {
|
|
6148
6719
|
...projected,
|
|
6149
6720
|
...overlay
|
|
6150
|
-
} : projected);
|
|
6721
|
+
} : projected, { inlineSecretsAsViews: true });
|
|
6151
6722
|
}
|
|
6152
6723
|
/**
|
|
6153
6724
|
* The integration-level view of this addon's settings: exactly the sections
|
|
@@ -6196,7 +6767,7 @@ var BaseAddon = class {
|
|
|
6196
6767
|
return hydrateSchema({
|
|
6197
6768
|
...schema,
|
|
6198
6769
|
sections
|
|
6199
|
-
}, projected);
|
|
6770
|
+
}, projected, { inlineSecretsAsViews: true });
|
|
6200
6771
|
}
|
|
6201
6772
|
/**
|
|
6202
6773
|
* The raw addon store PROJECTED onto the target node's bare per-node keys:
|
|
@@ -6250,18 +6821,50 @@ var BaseAddon = class {
|
|
|
6250
6821
|
value: result.value[key]
|
|
6251
6822
|
};
|
|
6252
6823
|
}
|
|
6824
|
+
/**
|
|
6825
|
+
* The OPERATOR's write — a settings form or an admin API call, dispatched by
|
|
6826
|
+
* the kernel. Identical to {@link updateGlobalSettings}, except that a secret
|
|
6827
|
+
* the operator sends is stored as sent even when it equals a pre-keychain
|
|
6828
|
+
* inline value: the operator re-entering a password is a change, an addon
|
|
6829
|
+
* writing back what it read is not (D787).
|
|
6830
|
+
*/
|
|
6831
|
+
async updateGlobalSettingsAsOperator(patch, nodeId) {
|
|
6832
|
+
this._operatorWriteDepth++;
|
|
6833
|
+
try {
|
|
6834
|
+
await this.applyGlobalPatch(patch, nodeId);
|
|
6835
|
+
} finally {
|
|
6836
|
+
this._operatorWriteDepth--;
|
|
6837
|
+
}
|
|
6838
|
+
}
|
|
6253
6839
|
async updateGlobalSettings(patch, nodeId) {
|
|
6840
|
+
await this.applyGlobalPatch(patch, nodeId);
|
|
6841
|
+
}
|
|
6842
|
+
/**
|
|
6843
|
+
* REMOVE stored secrets — their keychain values and their markers (D787).
|
|
6844
|
+
*
|
|
6845
|
+
* Writing `''` to a secret field KEEPS what is stored (an empty string is
|
|
6846
|
+
* what a defaults fallback writes back, and it must never destroy a
|
|
6847
|
+
* credential), so code that means "forget this token" says so here. Without
|
|
6848
|
+
* a keychain (an older kernel) it writes `''`, as such code always did.
|
|
6849
|
+
*/
|
|
6850
|
+
async clearSecrets(keys, nodeId) {
|
|
6851
|
+
const tree = this.addonSecretTree();
|
|
6852
|
+
const keychain = this._ctx?.secrets !== void 0;
|
|
6853
|
+
const patch = {};
|
|
6854
|
+
for (const key of keys) patch[key] = keychain && tree.has(key) ? SECRET_CLEAR : "";
|
|
6855
|
+
await this.applyGlobalPatch(patch, nodeId);
|
|
6856
|
+
}
|
|
6857
|
+
async applyGlobalPatch(barePatch, nodeId) {
|
|
6254
6858
|
const keys = this.perNodeKeys();
|
|
6255
6859
|
const localNode = normalizeNodeId(this._ctx?.kernel?.localNodeId);
|
|
6256
6860
|
const target = normalizeNodeId(nodeId ?? this._ctx?.kernel?.localNodeId);
|
|
6257
|
-
const barePatch = patch;
|
|
6258
6861
|
const scoped = keys.size > 0 ? scopePatch(barePatch, keys, target) : barePatch;
|
|
6259
6862
|
await this._ctx?.settings?.writeAddonStore(scoped);
|
|
6260
6863
|
if (target !== localNode) return;
|
|
6261
6864
|
await this.resolveConfig();
|
|
6262
6865
|
await this.onConfigChanged();
|
|
6263
6866
|
this.emitLifecycle(EventCategory.AddonUpdated, { level: "global" });
|
|
6264
|
-
this.maybeAutoRestart(
|
|
6867
|
+
this.maybeAutoRestart(Object.keys(barePatch), this.globalSettingsSchema());
|
|
6265
6868
|
}
|
|
6266
6869
|
/**
|
|
6267
6870
|
* The set of field keys the global settings schema declares `perNode: true`
|
|
@@ -6286,7 +6889,7 @@ var BaseAddon = class {
|
|
|
6286
6889
|
* time to return its response before the addon is torn down and
|
|
6287
6890
|
* re-initialised by `AddonRegistryService.restartAddon`.
|
|
6288
6891
|
*/
|
|
6289
|
-
maybeAutoRestart(
|
|
6892
|
+
maybeAutoRestart(patchKeys, schema) {
|
|
6290
6893
|
if (!schema) return;
|
|
6291
6894
|
const restartKeys = /* @__PURE__ */ new Set();
|
|
6292
6895
|
for (const section of schema.sections) for (const field of section.fields) {
|
|
@@ -6294,13 +6897,13 @@ var BaseAddon = class {
|
|
|
6294
6897
|
if (field.requiresRestart) restartKeys.add(field.key);
|
|
6295
6898
|
}
|
|
6296
6899
|
if (restartKeys.size === 0) return;
|
|
6297
|
-
if (!
|
|
6900
|
+
if (!patchKeys.some((k) => restartKeys.has(k))) return;
|
|
6298
6901
|
const ctx = this._ctx;
|
|
6299
6902
|
if (!ctx) return;
|
|
6300
6903
|
const addonId = ctx.id;
|
|
6301
6904
|
setImmediate(() => {
|
|
6302
6905
|
ctx.api.addons?.restartAddon?.mutate({ addonId }).then(() => {
|
|
6303
|
-
ctx.logger.info("addon auto-restart triggered by restart-required setting change", { meta: { changedFields:
|
|
6906
|
+
ctx.logger.info("addon auto-restart triggered by restart-required setting change", { meta: { changedFields: patchKeys.filter((k) => restartKeys.has(k)) } });
|
|
6304
6907
|
}).catch((err) => {
|
|
6305
6908
|
ctx.logger.error("addon auto-restart failed", { meta: { error: err instanceof Error ? err.message : String(err) } });
|
|
6306
6909
|
});
|
|
@@ -6309,7 +6912,7 @@ var BaseAddon = class {
|
|
|
6309
6912
|
async getDeviceSettings(deviceId) {
|
|
6310
6913
|
const schema = this.deviceSettingsSchema();
|
|
6311
6914
|
if (!schema) return { sections: [] };
|
|
6312
|
-
return hydrateSchema(schema, await this._ctx?.settings?.readDeviceStore(deviceId) ?? {});
|
|
6915
|
+
return hydrateSchema(schema, await this._ctx?.settings?.readDeviceStore(deviceId) ?? {}, { inlineSecretsAsViews: true });
|
|
6313
6916
|
}
|
|
6314
6917
|
async updateDeviceSettings(deviceId, patch) {
|
|
6315
6918
|
await this._ctx?.settings?.writeDeviceStore(deviceId, patch);
|
|
@@ -6439,7 +7042,7 @@ var BaseAddon = class {
|
|
|
6439
7042
|
* selection at boot (absent scoped key ⇒ the constructor default wins).
|
|
6440
7043
|
*/
|
|
6441
7044
|
async resolveConfig() {
|
|
6442
|
-
const stored = await this.readAddonStoreWithRetry();
|
|
7045
|
+
const stored = await this.resolveStoredSecrets(await this.readAddonStoreWithRetry());
|
|
6443
7046
|
const perNode = this.perNodeKeys();
|
|
6444
7047
|
const localNode = normalizeNodeId(this._ctx?.kernel?.localNodeId);
|
|
6445
7048
|
const resolved = { ...this.defaults };
|
|
@@ -6464,7 +7067,7 @@ var BaseAddon = class {
|
|
|
6464
7067
|
key,
|
|
6465
7068
|
schema,
|
|
6466
7069
|
fallback,
|
|
6467
|
-
read: () => this.readAddonStoreWithRetry(),
|
|
7070
|
+
read: async () => this.resolveStoredSecrets(await this.readAddonStoreWithRetry()),
|
|
6468
7071
|
write: async (patch) => {
|
|
6469
7072
|
await this._ctx?.settings?.writeAddonStore(patch);
|
|
6470
7073
|
},
|
|
@@ -6481,7 +7084,7 @@ var BaseAddon = class {
|
|
|
6481
7084
|
key,
|
|
6482
7085
|
schema,
|
|
6483
7086
|
fallback,
|
|
6484
|
-
read: async () => await this._ctx?.settings?.readDeviceStore(deviceId) ?? {},
|
|
7087
|
+
read: async () => this.resolveStoredSecrets(await this._ctx?.settings?.readDeviceStore(deviceId) ?? {}, false),
|
|
6485
7088
|
write: async (patch) => {
|
|
6486
7089
|
await this._ctx?.settings?.writeDeviceStore(deviceId, patch);
|
|
6487
7090
|
},
|
|
@@ -6493,6 +7096,70 @@ var BaseAddon = class {
|
|
|
6493
7096
|
} })
|
|
6494
7097
|
});
|
|
6495
7098
|
}
|
|
7099
|
+
/** The addon store's secret tree: schema fields by TYPE, plus `secretStatePaths`. */
|
|
7100
|
+
addonSecretTree() {
|
|
7101
|
+
this._addonSecretTree ??= mergeSecretStatePaths(secretTreeFromSchema(this.globalSettingsSchema()), this.secretStatePaths);
|
|
7102
|
+
return this._addonSecretTree;
|
|
7103
|
+
}
|
|
7104
|
+
deviceSecretTree() {
|
|
7105
|
+
this._deviceSecretTree ??= secretTreeFromSchema(this.deviceSettingsSchema());
|
|
7106
|
+
return this._deviceSecretTree;
|
|
7107
|
+
}
|
|
7108
|
+
/**
|
|
7109
|
+
* Secrets of this addon's stored config that could not be resolved on the
|
|
7110
|
+
* last read, with why. Non-empty means the addon is running WITHOUT them —
|
|
7111
|
+
* an addon whose function needs one should report itself degraded rather
|
|
7112
|
+
* than start on an empty credential.
|
|
7113
|
+
*/
|
|
7114
|
+
get unresolvedSecrets() {
|
|
7115
|
+
return this._unresolvedSecrets;
|
|
7116
|
+
}
|
|
7117
|
+
/**
|
|
7118
|
+
* Substitute every keychain marker in a stored blob with its value. With no
|
|
7119
|
+
* keychain (no `ctx.secrets`) or no marker, the blob comes back unchanged.
|
|
7120
|
+
* An unresolvable value is LEFT OUT (never `''`), logged by ref — never by
|
|
7121
|
+
* value — and, when the cause can pass, retried with backoff. Nothing is
|
|
7122
|
+
* ever written back from here.
|
|
7123
|
+
*/
|
|
7124
|
+
async resolveStoredSecrets(blob, trackForConfig = true) {
|
|
7125
|
+
const secrets = this._ctx?.secrets;
|
|
7126
|
+
if (secrets === void 0) return blob;
|
|
7127
|
+
const refs = collectSecretMarkerRefs(blob);
|
|
7128
|
+
if (trackForConfig) this._configSecretRefs = new Set(refs);
|
|
7129
|
+
if (refs.length === 0) {
|
|
7130
|
+
if (trackForConfig) this._unresolvedSecrets = [];
|
|
7131
|
+
return blob;
|
|
7132
|
+
}
|
|
7133
|
+
const { value, unresolved } = await resolveSecretMarkers(blob, secrets);
|
|
7134
|
+
if (trackForConfig) {
|
|
7135
|
+
this._unresolvedSecrets = unresolved;
|
|
7136
|
+
if (unresolved.length > 0) {
|
|
7137
|
+
this._ctx?.logger?.error?.("secret unavailable — running without it, will retry", { meta: { secrets: unresolved.map((u) => ({
|
|
7138
|
+
ref: u.ref,
|
|
7139
|
+
reason: u.reason
|
|
7140
|
+
})) } });
|
|
7141
|
+
if (unresolved.some((u) => u.reason !== "missing" && u.reason !== "forbidden")) {
|
|
7142
|
+
this.scheduleSecretReresolve(this._secretRetryDelayMs);
|
|
7143
|
+
this._secretRetryDelayMs = Math.min(this._secretRetryDelayMs * 2, SECRET_RETRY_MAX_MS);
|
|
7144
|
+
}
|
|
7145
|
+
} else this._secretRetryDelayMs = SECRET_RETRY_FIRST_MS;
|
|
7146
|
+
}
|
|
7147
|
+
return value;
|
|
7148
|
+
}
|
|
7149
|
+
/** Re-resolve the config (a keychain-only change, or a retry) and apply it. */
|
|
7150
|
+
scheduleSecretReresolve(delayMs) {
|
|
7151
|
+
const timerOf = delayMs === SECRET_CHANGE_DEBOUNCE_MS ? "_secretChangeTimer" : "_secretRetryTimer";
|
|
7152
|
+
if (this[timerOf] !== null) return;
|
|
7153
|
+
const timer = setTimeout(() => {
|
|
7154
|
+
this[timerOf] = null;
|
|
7155
|
+
if (this._ctx === null) return;
|
|
7156
|
+
this.resolveConfig().then(() => this.onConfigChanged()).catch((err) => {
|
|
7157
|
+
this._ctx?.logger?.error?.("re-resolving secrets failed", { meta: { error: err instanceof Error ? err.message : String(err) } });
|
|
7158
|
+
});
|
|
7159
|
+
}, delayMs);
|
|
7160
|
+
timer.unref?.();
|
|
7161
|
+
this[timerOf] = timer;
|
|
7162
|
+
}
|
|
6496
7163
|
/**
|
|
6497
7164
|
* Wrap `ctx.settings.readAddonStore()` with a short retry budget so a
|
|
6498
7165
|
* transient settings-store outage (mid-restart of sqlite-settings, tsx-watch
|
|
@@ -7068,6 +7735,69 @@ method(object({ deviceId: number() }), array(StreamSourceEntrySchema)), method(o
|
|
|
7068
7735
|
kind: "mutation",
|
|
7069
7736
|
auth: "admin"
|
|
7070
7737
|
}), method(object({ deviceId: number() }), unknown().nullable()), method(object({ deviceId: number() }), RawStateResultSchema.nullable(), { auth: "protected" });
|
|
7738
|
+
function defOf(schema) {
|
|
7739
|
+
return schema._zod?.def ?? {};
|
|
7740
|
+
}
|
|
7741
|
+
function declaredHere(schema) {
|
|
7742
|
+
return globalRegistry.get(schema)?.secret === true;
|
|
7743
|
+
}
|
|
7744
|
+
/** Wrapper kinds whose `innerType` is the field itself. */
|
|
7745
|
+
var WRAPPERS = new Set([
|
|
7746
|
+
"optional",
|
|
7747
|
+
"nullable",
|
|
7748
|
+
"default",
|
|
7749
|
+
"prefault",
|
|
7750
|
+
"catch",
|
|
7751
|
+
"readonly",
|
|
7752
|
+
"nonoptional"
|
|
7753
|
+
]);
|
|
7754
|
+
/**
|
|
7755
|
+
* The schema layers that make up ONE field: the schema itself and every
|
|
7756
|
+
* wrapper below it (optional / default / nullable / readonly / catch), plus
|
|
7757
|
+
* both sides of a pipe (`z.preprocess` puts the real schema on `out`,
|
|
7758
|
+
* `.transform` on `in`).
|
|
7759
|
+
*/
|
|
7760
|
+
function layersOf(schema) {
|
|
7761
|
+
const out = [];
|
|
7762
|
+
const queue = [schema];
|
|
7763
|
+
while (queue.length > 0) {
|
|
7764
|
+
const s = queue.shift();
|
|
7765
|
+
if (!s || out.includes(s)) continue;
|
|
7766
|
+
out.push(s);
|
|
7767
|
+
const def = defOf(s);
|
|
7768
|
+
if (def.type !== void 0 && WRAPPERS.has(def.type) && def.innerType) queue.push(def.innerType);
|
|
7769
|
+
if (def.type === "pipe") {
|
|
7770
|
+
if (def.in) queue.push(def.in);
|
|
7771
|
+
if (def.out) queue.push(def.out);
|
|
7772
|
+
}
|
|
7773
|
+
}
|
|
7774
|
+
return out;
|
|
7775
|
+
}
|
|
7776
|
+
/** True when any layer of this field declares `.meta({ secret: true })`. */
|
|
7777
|
+
function isZodSecret(schema) {
|
|
7778
|
+
return layersOf(schema).some(declaredHere);
|
|
7779
|
+
}
|
|
7780
|
+
/**
|
|
7781
|
+
* Every declared secret path in a config schema: dotted keys, `[]` for "each
|
|
7782
|
+
* element of this array" (`connection.password`, `rows[].token`). A declared
|
|
7783
|
+
* object or array is reported as one path and not descended into — everything
|
|
7784
|
+
* under it is secret.
|
|
7785
|
+
*/
|
|
7786
|
+
function collectZodSecretPaths(schema, prefix = "") {
|
|
7787
|
+
if (isZodSecret(schema)) return prefix.length > 0 ? [prefix] : [];
|
|
7788
|
+
const paths = [];
|
|
7789
|
+
for (const layer of layersOf(schema)) {
|
|
7790
|
+
const def = defOf(layer);
|
|
7791
|
+
if (def.type === "object" && def.shape) for (const [key, child] of Object.entries(def.shape)) paths.push(...collectZodSecretPaths(child, prefix ? `${prefix}.${key}` : key));
|
|
7792
|
+
else if (def.type === "array" && def.element) paths.push(...collectZodSecretPaths(def.element, `${prefix}[]`));
|
|
7793
|
+
else if (def.type === "union" && def.options) for (const option of def.options) paths.push(...collectZodSecretPaths(option, prefix));
|
|
7794
|
+
else if (def.type === "intersection") {
|
|
7795
|
+
if (def.left) paths.push(...collectZodSecretPaths(def.left, prefix));
|
|
7796
|
+
if (def.right) paths.push(...collectZodSecretPaths(def.right, prefix));
|
|
7797
|
+
}
|
|
7798
|
+
}
|
|
7799
|
+
return [...new Set(paths)];
|
|
7800
|
+
}
|
|
7071
7801
|
//#endregion
|
|
7072
7802
|
//#region ../types/dist/err-msg-DX6i_MY4.mjs
|
|
7073
7803
|
var DeviceType = /* @__PURE__ */ function(DeviceType) {
|
|
@@ -14130,6 +14860,196 @@ id: union([string(), number()]) }), {
|
|
|
14130
14860
|
kind: "mutation",
|
|
14131
14861
|
auth: "admin"
|
|
14132
14862
|
});
|
|
14863
|
+
/**
|
|
14864
|
+
* `keychain` — the hub's encrypted store of secret values (D787).
|
|
14865
|
+
*
|
|
14866
|
+
* Settings blobs never hold a secret: they hold a marker
|
|
14867
|
+
* `{"$secret":"secret://<owner>/<scope>/<fieldPath>","v":1}` and the value
|
|
14868
|
+
* lives here, AES-256-GCM under a data key that a master key wraps. This cap
|
|
14869
|
+
* is the OWNER's door to its own values: every method is owner-checked
|
|
14870
|
+
* against the CALLER, never against anything the caller claims.
|
|
14871
|
+
*
|
|
14872
|
+
* Who the caller is: the transport stamps `callerAddonId` into the args of a
|
|
14873
|
+
* call that crossed a process (the parent `LocalChildRegistry` from the UDS
|
|
14874
|
+
* connection, the agent from its child's connection carried in
|
|
14875
|
+
* `$hub-cap-fwd`'s envelope). A stamp always overwrites; a wire call with no
|
|
14876
|
+
* stamp has its claim stripped. Only a hub in-process caller may state its own
|
|
14877
|
+
* identity — `ctx.secrets` does that with the addon id closed over. This is
|
|
14878
|
+
* identity against BUGS and misrouting, not against a malicious addon (every
|
|
14879
|
+
* runner is the same OS user): see the threat model in
|
|
14880
|
+
* `docs/design/2026-10-08-secrets-keychain.md`.
|
|
14881
|
+
*
|
|
14882
|
+
* `callerAddonId` is deliberately NOT in any input schema: the tRPC router
|
|
14883
|
+
* parses the input, so a session can never supply it, and the internal mount
|
|
14884
|
+
* floors every method to admin anyway (D240).
|
|
14885
|
+
*
|
|
14886
|
+
* Internal: addons reach it through `ctx.secrets`, never directly.
|
|
14887
|
+
*/
|
|
14888
|
+
/** Why a value cannot be served right now. Never folded into "missing". */
|
|
14889
|
+
var KeychainUnavailableReasonSchema = _enum([
|
|
14890
|
+
"key-missing",
|
|
14891
|
+
"wrong-key",
|
|
14892
|
+
"key-file-unreadable",
|
|
14893
|
+
"store-unavailable",
|
|
14894
|
+
"not-initialized",
|
|
14895
|
+
"decrypt-failed"
|
|
14896
|
+
]);
|
|
14897
|
+
var KeychainStateSchema = discriminatedUnion("state", [object({ state: literal("ready") }), object({
|
|
14898
|
+
state: literal("locked"),
|
|
14899
|
+
reason: KeychainUnavailableReasonSchema
|
|
14900
|
+
})]);
|
|
14901
|
+
var KeychainResolveEntrySchema = discriminatedUnion("kind", [
|
|
14902
|
+
object({
|
|
14903
|
+
kind: literal("value"),
|
|
14904
|
+
value: string(),
|
|
14905
|
+
version: number().int()
|
|
14906
|
+
}),
|
|
14907
|
+
object({ kind: literal("missing") }),
|
|
14908
|
+
object({
|
|
14909
|
+
kind: literal("unavailable"),
|
|
14910
|
+
reason: KeychainUnavailableReasonSchema
|
|
14911
|
+
}),
|
|
14912
|
+
object({ kind: literal("forbidden") })
|
|
14913
|
+
]);
|
|
14914
|
+
var KeychainResolveResultSchema = record(string(), KeychainResolveEntrySchema);
|
|
14915
|
+
/** Metadata of one stored value — never the value. */
|
|
14916
|
+
var KeychainSecretMetaSchema = object({
|
|
14917
|
+
ref: string(),
|
|
14918
|
+
owner: string(),
|
|
14919
|
+
/** Formatted scope (`global`, `node/<id>`, `device/<id>`, …). */
|
|
14920
|
+
scope: string(),
|
|
14921
|
+
fieldPath: string(),
|
|
14922
|
+
version: number().int(),
|
|
14923
|
+
createdAt: number(),
|
|
14924
|
+
updatedAt: number(),
|
|
14925
|
+
/** `addon:<id>` | `user:<id>` | `system`. */
|
|
14926
|
+
updatedBy: string(),
|
|
14927
|
+
/** Coarse — written at most once an hour per ref. `null` = never read. */
|
|
14928
|
+
lastReadAt: number().nullable()
|
|
14929
|
+
});
|
|
14930
|
+
var RefListSchema = array(string().min(1)).max(512);
|
|
14931
|
+
method(object({
|
|
14932
|
+
ref: string().min(1),
|
|
14933
|
+
value: string().min(1)
|
|
14934
|
+
}), object({
|
|
14935
|
+
ref: string(),
|
|
14936
|
+
version: number().int()
|
|
14937
|
+
}), {
|
|
14938
|
+
kind: "mutation",
|
|
14939
|
+
auth: "admin"
|
|
14940
|
+
}), method(object({ refs: RefListSchema }), KeychainResolveResultSchema, { auth: "admin" }), method(object({ refs: RefListSchema }), object({ deleted: number().int() }), {
|
|
14941
|
+
kind: "mutation",
|
|
14942
|
+
auth: "admin"
|
|
14943
|
+
}), method(object({}), array(KeychainSecretMetaSchema).readonly(), { auth: "admin" }), method(object({}), KeychainStateSchema, { auth: "admin" });
|
|
14944
|
+
var KeychainKeySourceSchema = object({
|
|
14945
|
+
kind: _enum([
|
|
14946
|
+
"config-file",
|
|
14947
|
+
"previous-config-file",
|
|
14948
|
+
"platform",
|
|
14949
|
+
"default-file"
|
|
14950
|
+
]),
|
|
14951
|
+
/** File sources only — a path is not a secret. */
|
|
14952
|
+
path: string().optional(),
|
|
14953
|
+
/**
|
|
14954
|
+
* True when a whole-volume backup of the data directory carries this key
|
|
14955
|
+
* next to the database it protects (the default file). The page warns.
|
|
14956
|
+
*/
|
|
14957
|
+
sharesBackupWithDatabase: boolean()
|
|
14958
|
+
});
|
|
14959
|
+
var KeychainStatusSchema = object({
|
|
14960
|
+
keychain: KeychainStateSchema,
|
|
14961
|
+
/** The source of the master key in use; `null` while locked. */
|
|
14962
|
+
keySource: KeychainKeySourceSchema.nullable(),
|
|
14963
|
+
/** The source configured to be primary — differs from `keySource` while a rotation is pending. */
|
|
14964
|
+
configuredSource: KeychainKeySourceSchema,
|
|
14965
|
+
/** Short fingerprint of the master key in use (`HMAC(KEK, label)`, 16 hex). */
|
|
14966
|
+
fingerprint: string().nullable(),
|
|
14967
|
+
activeKeyId: string().nullable(),
|
|
14968
|
+
/**
|
|
14969
|
+
* The keychain unlocked with a NON-primary source: the configured primary
|
|
14970
|
+
* key is not the one that wraps the data key yet. `rotateMasterKey` moves it.
|
|
14971
|
+
*/
|
|
14972
|
+
rotationPending: boolean(),
|
|
14973
|
+
/** Wrapped copies of the data key under a previous master key, kept until purged. */
|
|
14974
|
+
retiredWraps: number().int(),
|
|
14975
|
+
recoveryKeyDownloadedAt: number().nullable(),
|
|
14976
|
+
secretCount: number().int()
|
|
14977
|
+
});
|
|
14978
|
+
/**
|
|
14979
|
+
* Whether a stored value is still pointed at by its owner's settings.
|
|
14980
|
+
* `unknown` is a first-class answer: a scope whose blob could not be read is
|
|
14981
|
+
* never reported as an orphan (and never deleted as one).
|
|
14982
|
+
*/
|
|
14983
|
+
var KeychainSecretUsageSchema = _enum([
|
|
14984
|
+
"in-use",
|
|
14985
|
+
"orphan",
|
|
14986
|
+
"unknown"
|
|
14987
|
+
]);
|
|
14988
|
+
var KeychainAdminSecretSchema = KeychainSecretMetaSchema.extend({ usage: KeychainSecretUsageSchema });
|
|
14989
|
+
var KeychainAuditActionSchema = _enum([
|
|
14990
|
+
"put",
|
|
14991
|
+
"delete",
|
|
14992
|
+
"reveal",
|
|
14993
|
+
"rotate-master-key",
|
|
14994
|
+
"purge-retired-keys",
|
|
14995
|
+
"download-recovery-key",
|
|
14996
|
+
"delete-orphans",
|
|
14997
|
+
"reset",
|
|
14998
|
+
"initialize"
|
|
14999
|
+
]);
|
|
15000
|
+
var KeychainAuditEntrySchema = object({
|
|
15001
|
+
id: string(),
|
|
15002
|
+
at: number(),
|
|
15003
|
+
action: KeychainAuditActionSchema,
|
|
15004
|
+
/** `addon:<id>` | `user:<id>` | `system`. */
|
|
15005
|
+
actor: string(),
|
|
15006
|
+
ref: string().nullable(),
|
|
15007
|
+
detail: string().nullable()
|
|
15008
|
+
});
|
|
15009
|
+
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({
|
|
15010
|
+
value: string(),
|
|
15011
|
+
version: number().int()
|
|
15012
|
+
}), {
|
|
15013
|
+
kind: "mutation",
|
|
15014
|
+
auth: "admin",
|
|
15015
|
+
caller: "required"
|
|
15016
|
+
}), method(object({ refs: array(string().min(1)).max(1e3) }), object({
|
|
15017
|
+
deleted: array(string()).readonly(),
|
|
15018
|
+
kept: array(object({
|
|
15019
|
+
ref: string(),
|
|
15020
|
+
usage: KeychainSecretUsageSchema
|
|
15021
|
+
})).readonly()
|
|
15022
|
+
}), {
|
|
15023
|
+
kind: "mutation",
|
|
15024
|
+
auth: "admin",
|
|
15025
|
+
caller: "required"
|
|
15026
|
+
}), method(object({}), object({
|
|
15027
|
+
fingerprint: string(),
|
|
15028
|
+
keySource: KeychainKeySourceSchema
|
|
15029
|
+
}), {
|
|
15030
|
+
kind: "mutation",
|
|
15031
|
+
auth: "admin",
|
|
15032
|
+
caller: "required"
|
|
15033
|
+
}), method(object({}), object({ purged: number().int() }), {
|
|
15034
|
+
kind: "mutation",
|
|
15035
|
+
auth: "admin",
|
|
15036
|
+
caller: "required"
|
|
15037
|
+
}), method(object({}), object({
|
|
15038
|
+
key: string(),
|
|
15039
|
+
fingerprint: string(),
|
|
15040
|
+
keySource: KeychainKeySourceSchema
|
|
15041
|
+
}), {
|
|
15042
|
+
kind: "mutation",
|
|
15043
|
+
auth: "admin",
|
|
15044
|
+
caller: "required"
|
|
15045
|
+
}), method(object({ confirm: literal("RESET KEYCHAIN") }), object({
|
|
15046
|
+
archivedCollection: string().nullable(),
|
|
15047
|
+
archived: number().int()
|
|
15048
|
+
}), {
|
|
15049
|
+
kind: "mutation",
|
|
15050
|
+
auth: "admin",
|
|
15051
|
+
caller: "required"
|
|
15052
|
+
});
|
|
14133
15053
|
method(_void(), object({
|
|
14134
15054
|
id: string(),
|
|
14135
15055
|
name: string(),
|
|
@@ -15355,7 +16275,11 @@ var DeviceRegisterPayloadSchema = object({
|
|
|
15355
16275
|
var DeviceRemovePayloadSchema = object({ deviceId: number() });
|
|
15356
16276
|
var DevicePersistConfigPayloadSchema = object({
|
|
15357
16277
|
deviceId: number(),
|
|
15358
|
-
data: record(string(), unknown())
|
|
16278
|
+
data: record(string(), unknown()),
|
|
16279
|
+
/** The paths the device's schema declares secret (D783), when the caller
|
|
16280
|
+
* knows them — those values are kept in the keychain, not the blob (D787).
|
|
16281
|
+
* Absent: the paths the device last reported at `registerDevice` apply. */
|
|
16282
|
+
secretConfigPaths: array(string()).optional()
|
|
15359
16283
|
});
|
|
15360
16284
|
/** What a migration actually did, per switch. `unreachable` is a first-class
|
|
15361
16285
|
* answer: a camera that could not be asked is not a camera that was silenced. */
|
|
@@ -22372,8 +23296,23 @@ var RetrainMacroClassSchema = _enum([
|
|
|
22372
23296
|
]);
|
|
22373
23297
|
/** A subject to learn, or a phantom to unlearn (taught by OMISSION). */
|
|
22374
23298
|
var RetrainAnnotationKindSchema = _enum(["subject", "model_error"]);
|
|
22375
|
-
/**
|
|
22376
|
-
|
|
23299
|
+
/**
|
|
23300
|
+
* Where a box came from. A machine-sourced box is a DRAFT on the page until
|
|
23301
|
+
* the operator confirms it; once saved it keeps its source as provenance.
|
|
23302
|
+
*
|
|
23303
|
+
* - `operator` — drawn by hand.
|
|
23304
|
+
* - `assist` — proposed by a detector run on the copy (the camera's own
|
|
23305
|
+
* model, or a larger teacher model).
|
|
23306
|
+
* - `pipeline` — the box the live pipeline actually drew on that frame, read
|
|
23307
|
+
* back from the track store (never a re-run).
|
|
23308
|
+
* - `llm` — proposed by a vision-capable LLM profile.
|
|
23309
|
+
*/
|
|
23310
|
+
var RetrainAnnotationSourceSchema = _enum([
|
|
23311
|
+
"operator",
|
|
23312
|
+
"assist",
|
|
23313
|
+
"pipeline",
|
|
23314
|
+
"llm"
|
|
23315
|
+
]);
|
|
22377
23316
|
/** Normalised `[0,1]` rectangle against the FULL frame — the canonical form. */
|
|
22378
23317
|
var RetrainBboxSchema = object({
|
|
22379
23318
|
x: number(),
|
|
@@ -22391,7 +23330,8 @@ var RetrainBboxSchema = object({
|
|
|
22391
23330
|
*/
|
|
22392
23331
|
var RetrainAnnotationSchema = object({
|
|
22393
23332
|
id: string(),
|
|
22394
|
-
|
|
23333
|
+
/** The frame's track. Absent on a recording still, which has none. */
|
|
23334
|
+
trackId: string().optional(),
|
|
22395
23335
|
deviceId: number(),
|
|
22396
23336
|
/** The COPY in retrain storage — never the source track's media key. */
|
|
22397
23337
|
mediaKey: string(),
|
|
@@ -22440,13 +23380,47 @@ var RetrainFrameCandidateSchema = object({
|
|
|
22440
23380
|
* fail, whatever became of the original. */
|
|
22441
23381
|
copied: boolean()
|
|
22442
23382
|
});
|
|
23383
|
+
/**
|
|
23384
|
+
* One box the live pipeline drew on a copied frame — what a correction starts
|
|
23385
|
+
* from. Derived when the frame is listed, from the track store: the subject
|
|
23386
|
+
* box recorded on the source media row when there is one, else the track
|
|
23387
|
+
* position nearest the frame's capture time. Never stored as an annotation
|
|
23388
|
+
* until the operator confirms it.
|
|
23389
|
+
*/
|
|
23390
|
+
var RetrainPipelineBoxSchema = object({
|
|
23391
|
+
/** Normalised `[0,1]` against the full frame. */
|
|
23392
|
+
bbox: RetrainBboxSchema,
|
|
23393
|
+
macroClass: RetrainMacroClassSchema,
|
|
23394
|
+
label: string().optional(),
|
|
23395
|
+
subLabel: string().optional(),
|
|
23396
|
+
/** The detection score of the position used, when it was recorded. */
|
|
23397
|
+
score: number().optional(),
|
|
23398
|
+
/** The root model that produced the track, when it was recorded. */
|
|
23399
|
+
modelId: string().optional(),
|
|
23400
|
+
trackId: string(),
|
|
23401
|
+
/** `subject-box`: recorded on this very frame. `position`: the track's
|
|
23402
|
+
* position nearest the capture time, `deltaMs` away. */
|
|
23403
|
+
basis: _enum(["subject-box", "position"]),
|
|
23404
|
+
deltaMs: number()
|
|
23405
|
+
});
|
|
23406
|
+
/**
|
|
23407
|
+
* Where a retrain frame came from: a TRACK's stored media (copy-on-select),
|
|
23408
|
+
* or the RECORDING at an instant — the frame a model saw nothing in has no
|
|
23409
|
+
* track at all.
|
|
23410
|
+
*/
|
|
23411
|
+
var RetrainFrameOriginSchema = _enum(["track", "recording"]);
|
|
22443
23412
|
/** A frame the dataset OWNS: bytes copied at selection time. */
|
|
22444
23413
|
var RetrainFrameSchema = object({
|
|
22445
23414
|
frameId: string(),
|
|
22446
23415
|
deviceId: number(),
|
|
22447
|
-
|
|
22448
|
-
/**
|
|
22449
|
-
|
|
23416
|
+
origin: RetrainFrameOriginSchema,
|
|
23417
|
+
/** The track it was copied from. Absent on a recording still. */
|
|
23418
|
+
trackId: string().optional(),
|
|
23419
|
+
/** Provenance only. It may already point at nothing — that is expected.
|
|
23420
|
+
* Absent on a recording still. */
|
|
23421
|
+
sourceMediaId: number().int().optional(),
|
|
23422
|
+
/** A recording still: the playhead instant it was taken at. */
|
|
23423
|
+
epochMs: number().optional(),
|
|
22450
23424
|
sourceKind: MediaFileKindEnum,
|
|
22451
23425
|
sizeBytes: number().int(),
|
|
22452
23426
|
width: number().int(),
|
|
@@ -22457,7 +23431,12 @@ var RetrainFrameSchema = object({
|
|
|
22457
23431
|
/** The operator's "every subject in this frame is boxed". Detector
|
|
22458
23432
|
* evaluation keeps only complete frames: an unboxed subject would count as
|
|
22459
23433
|
* a false positive. */
|
|
22460
|
-
complete: boolean()
|
|
23434
|
+
complete: boolean(),
|
|
23435
|
+
/** The boxes the pipeline drew on this frame. Present on list answers;
|
|
23436
|
+
* empty when nothing the track store holds can be placed on it. */
|
|
23437
|
+
pipelineBoxes: array(RetrainPipelineBoxSchema).readonly().optional(),
|
|
23438
|
+
/** The named collections this frame belongs to. Present on list answers. */
|
|
23439
|
+
collectionIds: array(string()).readonly().optional()
|
|
22461
23440
|
});
|
|
22462
23441
|
/** Why a copy-on-select could not be honoured — named, never a silent skip. */
|
|
22463
23442
|
var RetrainCopyRefusalSchema = _enum([
|
|
@@ -22488,6 +23467,8 @@ var RetrainFrameListSchema = object({
|
|
|
22488
23467
|
var RetrainExportFilterSchema = object({
|
|
22489
23468
|
deviceIds: array(number()).optional(),
|
|
22490
23469
|
frameIds: array(string()).max(2e4).optional(),
|
|
23470
|
+
/** Only frames in at least one of these named collections. */
|
|
23471
|
+
collectionIds: array(string()).max(200).optional(),
|
|
22491
23472
|
batchId: string().optional(),
|
|
22492
23473
|
/** Only frames the operator marked complete (all subjects boxed). */
|
|
22493
23474
|
completeOnly: boolean().optional()
|
|
@@ -22552,6 +23533,109 @@ var RetrainAssistResultSchema = discriminatedUnion("kind", [object({
|
|
|
22552
23533
|
reason: string(),
|
|
22553
23534
|
detail: string().optional()
|
|
22554
23535
|
})]);
|
|
23536
|
+
/** A named set over the retrain corpus — membership only, it owns no pixels. */
|
|
23537
|
+
var RetrainCollectionSchema = object({
|
|
23538
|
+
id: string(),
|
|
23539
|
+
name: string(),
|
|
23540
|
+
createdAt: number(),
|
|
23541
|
+
frameCount: number().int()
|
|
23542
|
+
});
|
|
23543
|
+
var RetrainCollectionCreateResultSchema = discriminatedUnion("kind", [object({
|
|
23544
|
+
kind: literal("created"),
|
|
23545
|
+
collection: RetrainCollectionSchema
|
|
23546
|
+
}), object({
|
|
23547
|
+
kind: literal("refused"),
|
|
23548
|
+
reason: _enum(["empty-name", "duplicate-name"])
|
|
23549
|
+
})]);
|
|
23550
|
+
var RetrainCollectionRenameResultSchema = discriminatedUnion("kind", [object({
|
|
23551
|
+
kind: literal("renamed"),
|
|
23552
|
+
collection: RetrainCollectionSchema
|
|
23553
|
+
}), object({
|
|
23554
|
+
kind: literal("refused"),
|
|
23555
|
+
reason: _enum([
|
|
23556
|
+
"empty-name",
|
|
23557
|
+
"duplicate-name",
|
|
23558
|
+
"unknown-collection"
|
|
23559
|
+
])
|
|
23560
|
+
})]);
|
|
23561
|
+
/**
|
|
23562
|
+
* The outcome of adding the frame at a recording instant. Every refusal is
|
|
23563
|
+
* named: `still-unavailable` (not recording, a gap, or an undecodable frame —
|
|
23564
|
+
* `detail` says which), `still-busy` (the recorder is at its decode bound; try
|
|
23565
|
+
* again), `unreadable-image`, `write-failed`, `unknown-collection`.
|
|
23566
|
+
*/
|
|
23567
|
+
var AddRetrainFrameFromRecordingResultSchema = discriminatedUnion("kind", [object({
|
|
23568
|
+
kind: literal("added"),
|
|
23569
|
+
collectionId: string(),
|
|
23570
|
+
frame: RetrainFrameSchema,
|
|
23571
|
+
/** The moment was already in the dataset; nothing was decoded. */
|
|
23572
|
+
reused: boolean()
|
|
23573
|
+
}), object({
|
|
23574
|
+
kind: literal("refused"),
|
|
23575
|
+
reason: _enum([
|
|
23576
|
+
"unknown-collection",
|
|
23577
|
+
"still-unavailable",
|
|
23578
|
+
"still-busy",
|
|
23579
|
+
"unreadable-image",
|
|
23580
|
+
"write-failed"
|
|
23581
|
+
]),
|
|
23582
|
+
detail: string().optional()
|
|
23583
|
+
})]);
|
|
23584
|
+
/** A vision LLM profile the AI assist may use, and where it sends the frame. */
|
|
23585
|
+
var RetrainAssistProfileSchema = object({
|
|
23586
|
+
id: string(),
|
|
23587
|
+
name: string(),
|
|
23588
|
+
model: string(),
|
|
23589
|
+
kind: string(),
|
|
23590
|
+
/** `true` when the frame would leave the house (a cloud vendor, or an
|
|
23591
|
+
* endpoint that is not on the local network). The page confirms each such
|
|
23592
|
+
* run, and the provider refuses one without `allowCloud`. */
|
|
23593
|
+
leavesHouse: boolean()
|
|
23594
|
+
});
|
|
23595
|
+
/** A box the AI assist proposed: a draft, plus the model's own reason. */
|
|
23596
|
+
var RetrainLlmProposalSchema = RetrainAnnotationDraftSchema.extend({ reason: string() });
|
|
23597
|
+
/** What the AI assist said about a box that was already on the canvas. */
|
|
23598
|
+
var RetrainLlmReviewSchema = object({
|
|
23599
|
+
/** The `ref` the page sent the box under. */
|
|
23600
|
+
ref: string(),
|
|
23601
|
+
verdict: _enum([
|
|
23602
|
+
"confirmed",
|
|
23603
|
+
"wrong-class",
|
|
23604
|
+
"not-an-object",
|
|
23605
|
+
"uncertain"
|
|
23606
|
+
]),
|
|
23607
|
+
suggestedClass: RetrainMacroClassSchema.optional(),
|
|
23608
|
+
reason: string()
|
|
23609
|
+
});
|
|
23610
|
+
/**
|
|
23611
|
+
* The AI assist's answer. `proposed` carries drafts (`source: 'llm'`, the
|
|
23612
|
+
* model and its confidence) and reviews; items the model got wrong (a box off
|
|
23613
|
+
* the frame, an unasked class, an unknown ref) are dropped and counted in
|
|
23614
|
+
* `rejected`. A whole answer that is not the schema is `malformed-answer`.
|
|
23615
|
+
*/
|
|
23616
|
+
var RetrainLlmAssistResultSchema = discriminatedUnion("kind", [object({
|
|
23617
|
+
kind: literal("proposed"),
|
|
23618
|
+
profileId: string(),
|
|
23619
|
+
model: string(),
|
|
23620
|
+
/** The frame was sent outside the house for this answer. */
|
|
23621
|
+
leftHouse: boolean(),
|
|
23622
|
+
proposals: array(RetrainLlmProposalSchema).readonly(),
|
|
23623
|
+
reviews: array(RetrainLlmReviewSchema).readonly(),
|
|
23624
|
+
rejected: number().int()
|
|
23625
|
+
}), object({
|
|
23626
|
+
kind: literal("refused"),
|
|
23627
|
+
reason: _enum([
|
|
23628
|
+
"unknown-frame",
|
|
23629
|
+
"unreadable-frame",
|
|
23630
|
+
"unknown-profile",
|
|
23631
|
+
"profile-disabled",
|
|
23632
|
+
"no-vision",
|
|
23633
|
+
"cloud-not-confirmed",
|
|
23634
|
+
"llm-error",
|
|
23635
|
+
"malformed-answer"
|
|
23636
|
+
]),
|
|
23637
|
+
detail: string().optional()
|
|
23638
|
+
})]);
|
|
22555
23639
|
/** The outcome of a lifecycle move owned by the retrain page. */
|
|
22556
23640
|
var RetrainTransitionResultSchema = object({
|
|
22557
23641
|
trackId: string(),
|
|
@@ -23269,7 +24353,7 @@ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).rea
|
|
|
23269
24353
|
auth: "admin"
|
|
23270
24354
|
}), method(object({
|
|
23271
24355
|
deviceId: number(),
|
|
23272
|
-
trackId: string(),
|
|
24356
|
+
trackId: string().optional(),
|
|
23273
24357
|
frameId: string()
|
|
23274
24358
|
}), object({
|
|
23275
24359
|
removed: boolean(),
|
|
@@ -23286,7 +24370,8 @@ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).rea
|
|
|
23286
24370
|
auth: "admin"
|
|
23287
24371
|
}), method(object({
|
|
23288
24372
|
deviceId: number(),
|
|
23289
|
-
|
|
24373
|
+
/** The frame's track, when it has one — checked against the frame. */
|
|
24374
|
+
trackId: string().optional(),
|
|
23290
24375
|
frameId: string(),
|
|
23291
24376
|
subject: RetrainAssistSubjectSchema,
|
|
23292
24377
|
/** Which node runs it. Absent ⇒ wherever an unowned call lands. */
|
|
@@ -23294,12 +24379,16 @@ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).rea
|
|
|
23294
24379
|
}), RetrainAssistResultSchema, {
|
|
23295
24380
|
kind: "mutation",
|
|
23296
24381
|
auth: "admin"
|
|
23297
|
-
}), method(object({
|
|
24382
|
+
}), method(object({
|
|
24383
|
+
trackId: string().optional(),
|
|
24384
|
+
frameIds: array(string()).max(2e3).optional()
|
|
24385
|
+
}), array(RetrainAnnotationSchema).readonly(), {
|
|
23298
24386
|
kind: "query",
|
|
23299
24387
|
auth: "admin"
|
|
23300
24388
|
}), method(object({
|
|
23301
24389
|
deviceId: number(),
|
|
23302
|
-
|
|
24390
|
+
/** The frame's track, when it has one — checked against the frame. */
|
|
24391
|
+
trackId: string().optional(),
|
|
23303
24392
|
frameId: string(),
|
|
23304
24393
|
annotations: array(RetrainAnnotationDraftSchema)
|
|
23305
24394
|
}), array(RetrainAnnotationSchema).readonly(), {
|
|
@@ -23322,7 +24411,7 @@ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).rea
|
|
|
23322
24411
|
auth: "admin"
|
|
23323
24412
|
}), method(object({
|
|
23324
24413
|
deviceId: number(),
|
|
23325
|
-
trackId: string(),
|
|
24414
|
+
trackId: string().optional(),
|
|
23326
24415
|
frameId: string(),
|
|
23327
24416
|
complete: boolean()
|
|
23328
24417
|
}), RetrainFrameSchema, {
|
|
@@ -23336,6 +24425,74 @@ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).rea
|
|
|
23336
24425
|
kind: "mutation",
|
|
23337
24426
|
auth: "admin",
|
|
23338
24427
|
timeoutMs: 60 * 6e4
|
|
24428
|
+
}), method(object({}), array(RetrainAssistProfileSchema).readonly(), {
|
|
24429
|
+
kind: "query",
|
|
24430
|
+
auth: "admin"
|
|
24431
|
+
}), method(object({
|
|
24432
|
+
deviceId: number(),
|
|
24433
|
+
trackId: string().optional(),
|
|
24434
|
+
frameId: string(),
|
|
24435
|
+
profileId: string(),
|
|
24436
|
+
classes: array(RetrainMacroClassSchema).min(1),
|
|
24437
|
+
boxes: array(object({
|
|
24438
|
+
ref: string(),
|
|
24439
|
+
bbox: RetrainBboxSchema,
|
|
24440
|
+
macroClass: RetrainMacroClassSchema,
|
|
24441
|
+
label: string().optional()
|
|
24442
|
+
})).max(50),
|
|
24443
|
+
allowCloud: boolean()
|
|
24444
|
+
}), RetrainLlmAssistResultSchema, {
|
|
24445
|
+
kind: "mutation",
|
|
24446
|
+
auth: "admin",
|
|
24447
|
+
timeoutMs: 18e4
|
|
24448
|
+
}), method(object({ name: string().max(120) }), RetrainCollectionCreateResultSchema, {
|
|
24449
|
+
kind: "mutation",
|
|
24450
|
+
auth: "admin"
|
|
24451
|
+
}), method(object({}), array(RetrainCollectionSchema).readonly(), {
|
|
24452
|
+
kind: "query",
|
|
24453
|
+
auth: "admin"
|
|
24454
|
+
}), method(object({
|
|
24455
|
+
id: string(),
|
|
24456
|
+
name: string().max(120)
|
|
24457
|
+
}), RetrainCollectionRenameResultSchema, {
|
|
24458
|
+
kind: "mutation",
|
|
24459
|
+
auth: "admin"
|
|
24460
|
+
}), method(object({ id: string() }), object({
|
|
24461
|
+
deleted: boolean(),
|
|
24462
|
+
removedFrames: number().int()
|
|
24463
|
+
}), {
|
|
24464
|
+
kind: "mutation",
|
|
24465
|
+
auth: "admin"
|
|
24466
|
+
}), method(object({
|
|
24467
|
+
collectionId: string(),
|
|
24468
|
+
deviceId: number(),
|
|
24469
|
+
epochMs: number()
|
|
24470
|
+
}), AddRetrainFrameFromRecordingResultSchema, {
|
|
24471
|
+
kind: "mutation",
|
|
24472
|
+
auth: "admin",
|
|
24473
|
+
timeoutMs: 6e4
|
|
24474
|
+
}), method(object({
|
|
24475
|
+
collectionId: string(),
|
|
24476
|
+
frameIds: array(string()).min(1).max(500)
|
|
24477
|
+
}), object({
|
|
24478
|
+
added: number().int(),
|
|
24479
|
+
alreadyMember: number().int(),
|
|
24480
|
+
unknownFrameIds: array(string()).readonly()
|
|
24481
|
+
}), {
|
|
24482
|
+
kind: "mutation",
|
|
24483
|
+
auth: "admin"
|
|
24484
|
+
}), method(object({
|
|
24485
|
+
collectionId: string(),
|
|
24486
|
+
frameId: string()
|
|
24487
|
+
}), object({
|
|
24488
|
+
removed: boolean(),
|
|
24489
|
+
deletedFrame: boolean()
|
|
24490
|
+
}), {
|
|
24491
|
+
kind: "mutation",
|
|
24492
|
+
auth: "admin"
|
|
24493
|
+
}), method(object({ collectionId: string() }), array(RetrainFrameSchema).readonly(), {
|
|
24494
|
+
kind: "query",
|
|
24495
|
+
auth: "admin"
|
|
23339
24496
|
}), method(object({
|
|
23340
24497
|
/** Which of the three event tables owns the row. */
|
|
23341
24498
|
ownerType: EventOwnerTypeSchema,
|
|
@@ -23959,13 +25116,31 @@ var RecommendationReasonSchema = discriminatedUnion("kind", [
|
|
|
23959
25116
|
object({
|
|
23960
25117
|
kind: literal("no-family-build"),
|
|
23961
25118
|
format: ModelFormatSchema$1
|
|
25119
|
+
}),
|
|
25120
|
+
object({
|
|
25121
|
+
kind: literal("kept-custom-pin"),
|
|
25122
|
+
modelId: string(),
|
|
25123
|
+
deviceKey: string()
|
|
23962
25124
|
})
|
|
23963
25125
|
]);
|
|
25126
|
+
/** Why a device is left exactly as it is, whatever the plan would pick (D786). */
|
|
25127
|
+
var KeptReasonSchema = _enum(["custom-pin"]);
|
|
25128
|
+
/**
|
|
25129
|
+
* Where a choice's latency came from (D791): this node's own benchmark
|
|
25130
|
+
* result, or the hardware-class table. Measured on the node beats the table.
|
|
25131
|
+
*/
|
|
25132
|
+
var LatencySourceSchema = discriminatedUnion("kind", [object({ kind: literal("table") }), object({
|
|
25133
|
+
kind: literal("node-benchmark"),
|
|
25134
|
+
resultId: string(),
|
|
25135
|
+
measuredAtMs: number()
|
|
25136
|
+
})]);
|
|
23964
25137
|
var DeviceModelChoiceSchema = object({
|
|
23965
25138
|
modelId: string(),
|
|
23966
25139
|
p50Ms: number(),
|
|
23967
25140
|
fps: number(),
|
|
23968
25141
|
measured: boolean(),
|
|
25142
|
+
/** Absent on a plan from before D791 — read as the table. */
|
|
25143
|
+
source: LatencySourceSchema.optional(),
|
|
23969
25144
|
/** Parallel sessions at the camera rate with the headroom kept free: ⌊fps × (1 − headroom) / camera fps⌋. */
|
|
23970
25145
|
capacitySessions: number(),
|
|
23971
25146
|
personRecall: number()
|
|
@@ -23976,6 +25151,8 @@ var DeviceRecommendationSchema = object({
|
|
|
23976
25151
|
enabled: boolean(),
|
|
23977
25152
|
available: boolean(),
|
|
23978
25153
|
chosen: DeviceModelChoiceSchema.nullable(),
|
|
25154
|
+
/** Present when the device is kept as is: Apply writes nothing on it. */
|
|
25155
|
+
kept: KeptReasonSchema.optional(),
|
|
23979
25156
|
reasons: array(RecommendationReasonSchema).readonly()
|
|
23980
25157
|
});
|
|
23981
25158
|
var NodeRecommendationSchema = object({
|
|
@@ -24029,6 +25206,17 @@ var AutoTuneWarningSchema = discriminatedUnion("kind", [
|
|
|
24029
25206
|
kind: literal("coral-enabled"),
|
|
24030
25207
|
nodeId: string(),
|
|
24031
25208
|
deviceKey: string()
|
|
25209
|
+
}),
|
|
25210
|
+
object({
|
|
25211
|
+
kind: literal("custom-pin-kept"),
|
|
25212
|
+
nodeId: string(),
|
|
25213
|
+
deviceKey: string().nullable(),
|
|
25214
|
+
deviceId: number().nullable(),
|
|
25215
|
+
modelId: string()
|
|
25216
|
+
}),
|
|
25217
|
+
object({
|
|
25218
|
+
kind: literal("custom-registry-unreadable"),
|
|
25219
|
+
error: string()
|
|
24032
25220
|
})
|
|
24033
25221
|
]);
|
|
24034
25222
|
var AutoTuneOptionsSchema = object({
|
|
@@ -24207,13 +25395,14 @@ var SuggestSharesResultSchema = object({
|
|
|
24207
25395
|
nodes: array(SuggestedNodeShareSchema).readonly()
|
|
24208
25396
|
});
|
|
24209
25397
|
/**
|
|
24210
|
-
* Where the node and device shares come from (D750, D755).
|
|
24211
|
-
* - `
|
|
24212
|
-
*
|
|
24213
|
-
*
|
|
24214
|
-
*
|
|
24215
|
-
*
|
|
24216
|
-
*
|
|
25398
|
+
* Where the node and device shares come from (D750, D755, D791).
|
|
25399
|
+
* - `benchmark` (default since D791) — each node's capacity as its own node
|
|
25400
|
+
* benchmark measured it; a node without fresh results is sized from
|
|
25401
|
+
* `hardware` and says so. Measured on the node beats the table.
|
|
25402
|
+
* - `hardware` — computed from each node's static capacity only (its
|
|
25403
|
+
* accelerators at their Auto tune models, from the latency table).
|
|
25404
|
+
* Both are recomputed whenever a node or device joins, leaves, is switched
|
|
25405
|
+
* on or off, changes model, or a benchmark result is written. No load input.
|
|
24217
25406
|
* - `manual` — the operator's stored sliders.
|
|
24218
25407
|
* Either way a node or device that cannot take sessions gives its share to
|
|
24219
25408
|
* the others in proportion; the stored values are never rewritten for that.
|
|
@@ -24262,6 +25451,362 @@ var EffectiveSharesSchema = object({
|
|
|
24262
25451
|
nodeWeights: record(string(), number()),
|
|
24263
25452
|
deviceWeights: record(string(), record(string(), number()))
|
|
24264
25453
|
});
|
|
25454
|
+
/**
|
|
25455
|
+
* Wire shapes of the node benchmark (D791): the operator's plan, the
|
|
25456
|
+
* preflight the confirmation shows, the run the orchestrator owns, what the
|
|
25457
|
+
* measuring runner reports, and the result rows Auto tune and the automatic
|
|
25458
|
+
* shares read.
|
|
25459
|
+
*
|
|
25460
|
+
* ONE node at a time, owned by the pipeline orchestrator. While a run is
|
|
25461
|
+
* active the cluster is in BENCHMARK MODE for that node: it is not a
|
|
25462
|
+
* detection candidate, camera pins naming it are ignored so its sessions move
|
|
25463
|
+
* elsewhere, and both come back when the mode ends — after a crash or a hub
|
|
25464
|
+
* restart too (a persisted manifest, reconciled against the registry).
|
|
25465
|
+
*
|
|
25466
|
+
* Two measurements, both on the node, driven by its own runner (frames never
|
|
25467
|
+
* cross a process at frame rate, D9):
|
|
25468
|
+
* - `device` — one accelerator × one candidate detector, root only, open
|
|
25469
|
+
* loop: how many streams at the camera rate it carries inside the frame
|
|
25470
|
+
* interval;
|
|
25471
|
+
* - `pipeline` — the chosen detector plus the operator's detail steps
|
|
25472
|
+
* (faces, plates, classifiers, CLIP…), on varied frames from the bench
|
|
25473
|
+
* clip: how many parallel sessions the node carries before latency, drops,
|
|
25474
|
+
* CPU, RAM or the event loop give out.
|
|
25475
|
+
*/
|
|
25476
|
+
/** Defaults and bounds, one place. */
|
|
25477
|
+
var NODE_BENCHMARK_DEFAULTS = {
|
|
25478
|
+
fpsPerStream: 10,
|
|
25479
|
+
budgetMinutes: 45,
|
|
25480
|
+
minBudgetMinutes: 10,
|
|
25481
|
+
maxBudgetMinutes: 120,
|
|
25482
|
+
/** A result older than this no longer beats the table. */
|
|
25483
|
+
staleAfterDays: 30,
|
|
25484
|
+
/** Warm-in per ramp step (not accounted). */
|
|
25485
|
+
settleSec: 5,
|
|
25486
|
+
/** Accounted window per ramp step. */
|
|
25487
|
+
measureSec: 20,
|
|
25488
|
+
/** Longest the drain may take before the run is refused. */
|
|
25489
|
+
drainTimeoutSec: 120,
|
|
25490
|
+
/** Candidate models per device in one run. */
|
|
25491
|
+
maxModelsPerDevice: 6
|
|
25492
|
+
};
|
|
25493
|
+
/** The two measurements a run can make. */
|
|
25494
|
+
var NodeBenchmarkPhaseSchema = _enum(["device", "pipeline"]);
|
|
25495
|
+
var NodeBenchmarkDevicePlanSchema = object({
|
|
25496
|
+
/** `<backend>:<device>` — `openvino:npu`, `coreml:all`, `cpu`. */
|
|
25497
|
+
deviceKey: string().min(1),
|
|
25498
|
+
/**
|
|
25499
|
+
* Root detector candidates for the `device` measurement, in the order
|
|
25500
|
+
* measured. The FIRST is the one the `pipeline` measurement runs.
|
|
25501
|
+
*/
|
|
25502
|
+
modelIds: array(string().min(1)).min(1).max(NODE_BENCHMARK_DEFAULTS.maxModelsPerDevice)
|
|
25503
|
+
});
|
|
25504
|
+
/** What the operator confirmed. */
|
|
25505
|
+
var NodeBenchmarkPlanSchema = object({
|
|
25506
|
+
nodeId: string().min(1),
|
|
25507
|
+
devices: array(NodeBenchmarkDevicePlanSchema).min(1),
|
|
25508
|
+
/** Which measurements run. At least one. */
|
|
25509
|
+
phases: array(NodeBenchmarkPhaseSchema).min(1).default(["device", "pipeline"]),
|
|
25510
|
+
/**
|
|
25511
|
+
* Detail steps (catalog step ids under the root: faces, plates,
|
|
25512
|
+
* classifiers, CLIP…) the `pipeline` measurement enables. The root
|
|
25513
|
+
* detector always runs.
|
|
25514
|
+
*/
|
|
25515
|
+
steps: array(string().min(1)).default([]),
|
|
25516
|
+
/** Offered rate of one stream / session. */
|
|
25517
|
+
fpsPerStream: number().int().min(1).max(30).default(NODE_BENCHMARK_DEFAULTS.fpsPerStream),
|
|
25518
|
+
/** Hard deadline: the mode ends and the cluster is restored when it passes. */
|
|
25519
|
+
budgetMinutes: number().int().min(NODE_BENCHMARK_DEFAULTS.minBudgetMinutes).max(NODE_BENCHMARK_DEFAULTS.maxBudgetMinutes).default(NODE_BENCHMARK_DEFAULTS.budgetMinutes),
|
|
25520
|
+
/** Keep the models the run downloaded (default: delete what was not installed before). */
|
|
25521
|
+
keepDownloadedModels: boolean().default(false),
|
|
25522
|
+
/** Start although the other nodes' capacity does not cover the sessions running now. */
|
|
25523
|
+
acceptInsufficientHeadroom: boolean().default(false)
|
|
25524
|
+
});
|
|
25525
|
+
var NodeBenchmarkRefusalSchema = object({
|
|
25526
|
+
kind: _enum([
|
|
25527
|
+
"benchmark-active",
|
|
25528
|
+
"node-offline",
|
|
25529
|
+
"unknown-device",
|
|
25530
|
+
"no-phase",
|
|
25531
|
+
"insufficient-headroom"
|
|
25532
|
+
]),
|
|
25533
|
+
detail: string(),
|
|
25534
|
+
overridable: boolean()
|
|
25535
|
+
});
|
|
25536
|
+
/** A camera whose detection leaves the node for the run. */
|
|
25537
|
+
var NodeBenchmarkMovingCameraSchema = object({
|
|
25538
|
+
deviceId: number(),
|
|
25539
|
+
/** Placed on the node now (a standing attach or a running session). */
|
|
25540
|
+
placedOnNode: boolean(),
|
|
25541
|
+
/** A node pin naming this node, ignored for the run. */
|
|
25542
|
+
pinnedToNode: boolean()
|
|
25543
|
+
});
|
|
25544
|
+
/** A camera that cannot leave: no other node can obtain its frames. */
|
|
25545
|
+
var NodeBenchmarkStayingCameraSchema = object({
|
|
25546
|
+
deviceId: number(),
|
|
25547
|
+
reason: literal("only-frame-source")
|
|
25548
|
+
});
|
|
25549
|
+
var NodeBenchmarkPreflightSchema = object({
|
|
25550
|
+
nodeId: string(),
|
|
25551
|
+
online: boolean(),
|
|
25552
|
+
moving: array(NodeBenchmarkMovingCameraSchema).readonly(),
|
|
25553
|
+
/** Keep running on the node during the run; the result is flagged contaminated. */
|
|
25554
|
+
staying: array(NodeBenchmarkStayingCameraSchema).readonly(),
|
|
25555
|
+
estimatedDurationMs: number(),
|
|
25556
|
+
/** The run ends and the cluster is restored at the latest after this long. */
|
|
25557
|
+
budgetMs: number(),
|
|
25558
|
+
phases: array(NodeBenchmarkPhaseSchema).readonly(),
|
|
25559
|
+
steps: array(string()).readonly(),
|
|
25560
|
+
devices: array(NodeBenchmarkDevicePlanSchema).readonly(),
|
|
25561
|
+
/** Parallel sessions the cluster runs now, and what the other nodes can carry. */
|
|
25562
|
+
headroom: object({
|
|
25563
|
+
sessionsNow: number(),
|
|
25564
|
+
otherNodesCapacitySessions: number().nullable()
|
|
25565
|
+
}),
|
|
25566
|
+
refusals: array(NodeBenchmarkRefusalSchema).readonly(),
|
|
25567
|
+
canStart: boolean()
|
|
25568
|
+
});
|
|
25569
|
+
/** Where the measuring runner is. */
|
|
25570
|
+
var NodeBenchProgressSchema = object({
|
|
25571
|
+
phase: _enum([
|
|
25572
|
+
"preparing",
|
|
25573
|
+
"device",
|
|
25574
|
+
"pipeline",
|
|
25575
|
+
"cleanup"
|
|
25576
|
+
]),
|
|
25577
|
+
deviceKey: string().nullable(),
|
|
25578
|
+
modelId: string().nullable(),
|
|
25579
|
+
/** Streams (device) or sessions (pipeline) of the step running now. */
|
|
25580
|
+
load: number().nullable(),
|
|
25581
|
+
cellsDone: number(),
|
|
25582
|
+
cellsTotal: number(),
|
|
25583
|
+
message: string()
|
|
25584
|
+
});
|
|
25585
|
+
/** What limited a ramp. `none` = the ramp ran out of steps still passing. */
|
|
25586
|
+
var NodeBenchLimitSchema = _enum([
|
|
25587
|
+
"p95",
|
|
25588
|
+
"drops",
|
|
25589
|
+
"errors",
|
|
25590
|
+
"stall",
|
|
25591
|
+
"cpu",
|
|
25592
|
+
"ram",
|
|
25593
|
+
"none"
|
|
25594
|
+
]);
|
|
25595
|
+
var NodeBenchRampStepSchema = object({
|
|
25596
|
+
load: number(),
|
|
25597
|
+
pass: boolean(),
|
|
25598
|
+
p95Ms: number(),
|
|
25599
|
+
dropRatio: number(),
|
|
25600
|
+
/** Completed frames per second over the accounted window. */
|
|
25601
|
+
fps: number(),
|
|
25602
|
+
cpuPct: number().nullable(),
|
|
25603
|
+
ramFreePct: number().nullable(),
|
|
25604
|
+
failReasons: array(string()).readonly()
|
|
25605
|
+
});
|
|
25606
|
+
var NodeBenchCellSchema = discriminatedUnion("phase", [object({
|
|
25607
|
+
phase: literal("device"),
|
|
25608
|
+
deviceKey: string(),
|
|
25609
|
+
modelId: string(),
|
|
25610
|
+
/** Single-stream latency (the K = 1 step). */
|
|
25611
|
+
p50Ms: number(),
|
|
25612
|
+
p95Ms: number(),
|
|
25613
|
+
p99Ms: number(),
|
|
25614
|
+
/** Frames per second sustained at the last passing step. */
|
|
25615
|
+
fps: number(),
|
|
25616
|
+
/** Streams at the camera rate the device carried inside the frame interval; 0 = not even one. */
|
|
25617
|
+
kMax: number(),
|
|
25618
|
+
limitedBy: NodeBenchLimitSchema,
|
|
25619
|
+
/** First call (model load + warm-up). */
|
|
25620
|
+
warmupMs: number(),
|
|
25621
|
+
ramp: array(NodeBenchRampStepSchema).readonly()
|
|
25622
|
+
}), object({
|
|
25623
|
+
phase: literal("pipeline"),
|
|
25624
|
+
deviceKey: string(),
|
|
25625
|
+
modelId: string(),
|
|
25626
|
+
steps: array(string()).readonly(),
|
|
25627
|
+
/** Parallel sessions at the camera rate the node carried; 0 = not even one. */
|
|
25628
|
+
maxSessions: number(),
|
|
25629
|
+
limitedBy: NodeBenchLimitSchema,
|
|
25630
|
+
/** Detail steps that produced at least one result on the clip — a step that never fired measured nothing. */
|
|
25631
|
+
stepsFired: array(string()).readonly(),
|
|
25632
|
+
warmupMs: number(),
|
|
25633
|
+
ramp: array(NodeBenchRampStepSchema).readonly()
|
|
25634
|
+
})]);
|
|
25635
|
+
/**
|
|
25636
|
+
* What a result was measured ON. A result whose fingerprint no longer matches
|
|
25637
|
+
* the node no longer beats the table.
|
|
25638
|
+
*/
|
|
25639
|
+
var NodeBenchFingerprintSchema = object({
|
|
25640
|
+
pipelineVersion: string().nullable(),
|
|
25641
|
+
cpuModel: string().nullable(),
|
|
25642
|
+
ramGb: number().nullable(),
|
|
25643
|
+
os: string().nullable(),
|
|
25644
|
+
/** Per device: the pool the cells ran on (runtime + tuning). */
|
|
25645
|
+
pools: record(string(), object({
|
|
25646
|
+
runtime: string(),
|
|
25647
|
+
numWorkers: number(),
|
|
25648
|
+
concurrency: number(),
|
|
25649
|
+
batchMode: string()
|
|
25650
|
+
})).default({})
|
|
25651
|
+
});
|
|
25652
|
+
/** The frames the run used. */
|
|
25653
|
+
var NodeBenchClipSchema = object({
|
|
25654
|
+
/** `camstack-bench-v1` or `reference-images` (the fallback when the clip is not reachable). */
|
|
25655
|
+
id: string(),
|
|
25656
|
+
revision: string().nullable(),
|
|
25657
|
+
frames: number(),
|
|
25658
|
+
width: number(),
|
|
25659
|
+
height: number()
|
|
25660
|
+
});
|
|
25661
|
+
var NodeBenchRunnerInputSchema = object({
|
|
25662
|
+
runId: string().min(1),
|
|
25663
|
+
devices: array(NodeBenchmarkDevicePlanSchema).min(1),
|
|
25664
|
+
phases: array(NodeBenchmarkPhaseSchema).min(1),
|
|
25665
|
+
/** The full detail step tree root for the `pipeline` measurement is built on the node from these ids. */
|
|
25666
|
+
steps: array(string()).default([]),
|
|
25667
|
+
fpsPerStream: number().int().min(1).max(30),
|
|
25668
|
+
/** The runner stops on its own past this instant, whatever the hub does. */
|
|
25669
|
+
deadlineAtMs: number(),
|
|
25670
|
+
settleSec: number().min(0).max(60).default(NODE_BENCHMARK_DEFAULTS.settleSec),
|
|
25671
|
+
measureSec: number().min(2).max(300).default(NODE_BENCHMARK_DEFAULTS.measureSec),
|
|
25672
|
+
keepDownloadedModels: boolean().default(false)
|
|
25673
|
+
});
|
|
25674
|
+
var NodeBenchRunnerStateSchema = _enum([
|
|
25675
|
+
"running",
|
|
25676
|
+
"done",
|
|
25677
|
+
"failed",
|
|
25678
|
+
"aborted"
|
|
25679
|
+
]);
|
|
25680
|
+
var NodeBenchRunnerStatusSchema = object({
|
|
25681
|
+
runId: string(),
|
|
25682
|
+
nodeId: string(),
|
|
25683
|
+
state: NodeBenchRunnerStateSchema,
|
|
25684
|
+
progress: NodeBenchProgressSchema.nullable(),
|
|
25685
|
+
/** Every finished cell so far — a run stopped half way keeps what it measured. */
|
|
25686
|
+
cells: array(NodeBenchCellSchema).readonly(),
|
|
25687
|
+
fingerprint: NodeBenchFingerprintSchema.nullable(),
|
|
25688
|
+
clip: NodeBenchClipSchema.nullable(),
|
|
25689
|
+
/** Cameras seen running on the node during the run (they share its pools). */
|
|
25690
|
+
activeCameraIds: array(number()).readonly(),
|
|
25691
|
+
/** Models the run downloaded and then deleted (not installed before). */
|
|
25692
|
+
deletedModels: array(string()).readonly(),
|
|
25693
|
+
error: string().nullable(),
|
|
25694
|
+
startedAtMs: number(),
|
|
25695
|
+
finishedAtMs: number().nullable()
|
|
25696
|
+
});
|
|
25697
|
+
var NodeBenchmarkStateSchema = _enum([
|
|
25698
|
+
"draining",
|
|
25699
|
+
"measuring",
|
|
25700
|
+
"restoring",
|
|
25701
|
+
"done",
|
|
25702
|
+
"failed",
|
|
25703
|
+
"aborted"
|
|
25704
|
+
]);
|
|
25705
|
+
/** Why a run ended. */
|
|
25706
|
+
var NodeBenchmarkEndReasonSchema = _enum([
|
|
25707
|
+
"completed",
|
|
25708
|
+
"operator-abort",
|
|
25709
|
+
"deadline",
|
|
25710
|
+
"node-lost",
|
|
25711
|
+
"runner-lost",
|
|
25712
|
+
"hub-restart",
|
|
25713
|
+
"drain-timeout",
|
|
25714
|
+
"failed"
|
|
25715
|
+
]);
|
|
25716
|
+
var NodeBenchmarkRunSchema = object({
|
|
25717
|
+
runId: string(),
|
|
25718
|
+
nodeId: string(),
|
|
25719
|
+
state: NodeBenchmarkStateSchema,
|
|
25720
|
+
plan: NodeBenchmarkPlanSchema,
|
|
25721
|
+
startedAtMs: number(),
|
|
25722
|
+
deadlineAtMs: number(),
|
|
25723
|
+
finishedAtMs: number().nullable(),
|
|
25724
|
+
endReason: NodeBenchmarkEndReasonSchema.nullable(),
|
|
25725
|
+
error: string().nullable(),
|
|
25726
|
+
/** Cameras moved off the node for the run. */
|
|
25727
|
+
moved: array(number()).readonly(),
|
|
25728
|
+
/** Cameras that stayed (their only frame source is the node). */
|
|
25729
|
+
staying: array(number()).readonly(),
|
|
25730
|
+
/** Something else ran on the node's pools during the run. */
|
|
25731
|
+
contaminated: boolean(),
|
|
25732
|
+
progress: NodeBenchProgressSchema.nullable(),
|
|
25733
|
+
resultIds: array(string()).readonly()
|
|
25734
|
+
});
|
|
25735
|
+
/** `getNodeBenchmarkStatus`: the active run (or the last one), and whether benchmark mode is on. */
|
|
25736
|
+
var NodeBenchmarkStatusSchema = object({
|
|
25737
|
+
/** The node the cluster is in benchmark mode for; null = none. */
|
|
25738
|
+
modeNodeId: string().nullable(),
|
|
25739
|
+
run: NodeBenchmarkRunSchema.nullable()
|
|
25740
|
+
});
|
|
25741
|
+
/**
|
|
25742
|
+
* One stored measurement — the only authority Auto tune and the automatic
|
|
25743
|
+
* shares read measured capacity from. Written by the orchestrator when a run
|
|
25744
|
+
* ends, never by anyone else.
|
|
25745
|
+
*/
|
|
25746
|
+
var NodeBenchmarkResultSchema = object({
|
|
25747
|
+
id: string(),
|
|
25748
|
+
runId: string(),
|
|
25749
|
+
nodeId: string(),
|
|
25750
|
+
cell: NodeBenchCellSchema,
|
|
25751
|
+
fpsPerStream: number(),
|
|
25752
|
+
fingerprint: NodeBenchFingerprintSchema.nullable(),
|
|
25753
|
+
clip: NodeBenchClipSchema.nullable(),
|
|
25754
|
+
/** Other work shared the node's pools (a camera that could not move, or the hub's own duties). */
|
|
25755
|
+
contaminated: boolean(),
|
|
25756
|
+
stayingCameras: array(number()).readonly(),
|
|
25757
|
+
/** The run ended early; the cell itself completed. */
|
|
25758
|
+
partialRun: boolean(),
|
|
25759
|
+
measuredAtMs: number()
|
|
25760
|
+
});
|
|
25761
|
+
var ListNodeBenchmarkResultsInputSchema = object({
|
|
25762
|
+
nodeId: string().optional(),
|
|
25763
|
+
deviceKey: string().optional()
|
|
25764
|
+
});
|
|
25765
|
+
/** A result with its standing today: does it still beat the table? */
|
|
25766
|
+
var NodeBenchmarkResultViewSchema = NodeBenchmarkResultSchema.extend({
|
|
25767
|
+
/** `fresh` beats the table; `stale` falls back to it; `superseded` = a newer row covers the same cell. */
|
|
25768
|
+
standing: _enum([
|
|
25769
|
+
"fresh",
|
|
25770
|
+
"stale",
|
|
25771
|
+
"superseded"
|
|
25772
|
+
]),
|
|
25773
|
+
staleWhy: _enum([
|
|
25774
|
+
"age",
|
|
25775
|
+
"runtime",
|
|
25776
|
+
"pool-tuning"
|
|
25777
|
+
]).nullable()
|
|
25778
|
+
});
|
|
25779
|
+
object({
|
|
25780
|
+
runId: string(),
|
|
25781
|
+
nodeId: string(),
|
|
25782
|
+
startedAtMs: number(),
|
|
25783
|
+
deadlineAtMs: number(),
|
|
25784
|
+
plan: NodeBenchmarkPlanSchema,
|
|
25785
|
+
moved: array(number()).readonly(),
|
|
25786
|
+
staying: array(number()).readonly()
|
|
25787
|
+
});
|
|
25788
|
+
/** Candidate detectors per device, for the plan editor. */
|
|
25789
|
+
var NodeBenchmarkCandidatesSchema = object({
|
|
25790
|
+
nodeId: string(),
|
|
25791
|
+
reachable: boolean(),
|
|
25792
|
+
devices: array(object({
|
|
25793
|
+
deviceKey: string(),
|
|
25794
|
+
enabled: boolean(),
|
|
25795
|
+
available: boolean(),
|
|
25796
|
+
/** Ordered: what Auto tune would pick first, then the rest of the family by accuracy. */
|
|
25797
|
+
suggested: array(string()).readonly(),
|
|
25798
|
+
/** Every root detector the device has a build for. */
|
|
25799
|
+
all: array(string()).readonly(),
|
|
25800
|
+
/** The model the device runs now, when pinned. */
|
|
25801
|
+
currentModelId: string().nullable()
|
|
25802
|
+
})).readonly(),
|
|
25803
|
+
/** Detail steps the node's catalog offers under the root (for the `pipeline` measurement). */
|
|
25804
|
+
steps: array(object({
|
|
25805
|
+
id: string(),
|
|
25806
|
+
name: string(),
|
|
25807
|
+
slot: string()
|
|
25808
|
+
})).readonly()
|
|
25809
|
+
});
|
|
24265
25810
|
object({
|
|
24266
25811
|
activeCameras: number(),
|
|
24267
25812
|
throttledCameras: number(),
|
|
@@ -25390,7 +26935,16 @@ method(RunnerCameraConfigSchema, object({ success: literal(true) }), { kind: "mu
|
|
|
25390
26935
|
}), ParkedTrackFrameSchema.nullable()), method(object({
|
|
25391
26936
|
deviceId: number(),
|
|
25392
26937
|
trackId: string()
|
|
25393
|
-
}), object({ released: number().int().nonnegative() }), { kind: "mutation" })
|
|
26938
|
+
}), object({ released: number().int().nonnegative() }), { kind: "mutation" }), method(NodeBenchRunnerInputSchema, object({
|
|
26939
|
+
accepted: literal(true),
|
|
26940
|
+
runId: string()
|
|
26941
|
+
}), {
|
|
26942
|
+
kind: "mutation",
|
|
26943
|
+
auth: "admin"
|
|
26944
|
+
}), method(object({ runId: string() }), NodeBenchRunnerStatusSchema.nullable(), { auth: "admin" }), method(object({ runId: string() }), object({ aborted: boolean() }), {
|
|
26945
|
+
kind: "mutation",
|
|
26946
|
+
auth: "admin"
|
|
26947
|
+
});
|
|
25394
26948
|
var CameraPipelineConfigSchema = object({
|
|
25395
26949
|
engine: PipelineEngineChoiceSchema.optional(),
|
|
25396
26950
|
steps: array(PipelineStepInputSchema).readonly(),
|
|
@@ -26029,6 +27583,21 @@ method(object({
|
|
|
26029
27583
|
}), method(PlacementStatsInputSchema, PlacementStatsSchema, { auth: "admin" }), method(SuggestSharesInputSchema, SuggestSharesResultSchema, { auth: "admin" }), method(_void(), EffectiveSharesSchema, { auth: "admin" }), method(SetShareSourceInputSchema, object({ success: literal(true) }), {
|
|
26030
27584
|
kind: "mutation",
|
|
26031
27585
|
auth: "admin"
|
|
27586
|
+
}), method(NodeBenchmarkPlanSchema, NodeBenchmarkPreflightSchema, { auth: "admin" }), method(NodeBenchmarkPlanSchema, discriminatedUnion("kind", [object({
|
|
27587
|
+
kind: literal("started"),
|
|
27588
|
+
runId: string()
|
|
27589
|
+
}), object({
|
|
27590
|
+
kind: literal("refused"),
|
|
27591
|
+
preflight: NodeBenchmarkPreflightSchema
|
|
27592
|
+
})]), {
|
|
27593
|
+
kind: "mutation",
|
|
27594
|
+
auth: "admin"
|
|
27595
|
+
}), method(_void(), NodeBenchmarkStatusSchema, { auth: "admin" }), method(object({ runId: string() }), object({ aborted: boolean() }), {
|
|
27596
|
+
kind: "mutation",
|
|
27597
|
+
auth: "admin"
|
|
27598
|
+
}), method(object({ nodeId: string() }), NodeBenchmarkCandidatesSchema, { auth: "admin" }), method(ListNodeBenchmarkResultsInputSchema, array(NodeBenchmarkResultViewSchema).readonly(), { auth: "admin" }), method(object({ id: string() }), object({ deleted: boolean() }), {
|
|
27599
|
+
kind: "mutation",
|
|
27600
|
+
auth: "admin"
|
|
26032
27601
|
}), method(object({ deviceId: number() }), CameraPipelineSettingsSchema.nullable()), method(object({
|
|
26033
27602
|
deviceId: number(),
|
|
26034
27603
|
addonId: string(),
|
|
@@ -32248,6 +33817,9 @@ var CreateIntegrationInputSchema = object({
|
|
|
32248
33817
|
enabled: boolean().optional(),
|
|
32249
33818
|
info: record(string(), unknown()).optional(),
|
|
32250
33819
|
settings: record(string(), unknown()).optional(),
|
|
33820
|
+
/** Keys of `settings` the form's schema declares secret (by type) — kept in
|
|
33821
|
+
* the keychain, not the table (D787). */
|
|
33822
|
+
secretKeys: array(string()).optional(),
|
|
32251
33823
|
skipRestart: boolean().optional()
|
|
32252
33824
|
});
|
|
32253
33825
|
var UpdateIntegrationInputSchema = object({
|
|
@@ -32271,7 +33843,9 @@ method(_void(), array(IntegrationWithStateSchema)), method(object({ id: string()
|
|
|
32271
33843
|
auth: "admin"
|
|
32272
33844
|
}), method(object({ id: string() }), record(string(), unknown()), { auth: "admin" }), method(object({
|
|
32273
33845
|
id: string(),
|
|
32274
|
-
settings: record(string(), unknown())
|
|
33846
|
+
settings: record(string(), unknown()),
|
|
33847
|
+
/** Keys the form's schema declares secret (by type) — keychain-stored (D787). */
|
|
33848
|
+
secretKeys: array(string()).optional()
|
|
32275
33849
|
}), object({ success: boolean() }), {
|
|
32276
33850
|
kind: "mutation",
|
|
32277
33851
|
auth: "admin"
|
|
@@ -40434,7 +42008,8 @@ var BaseDevice = class {
|
|
|
40434
42008
|
this.role = options.role;
|
|
40435
42009
|
this.parentDeviceId = ctx.parentDeviceId;
|
|
40436
42010
|
const seedData = ctx.persistedConfig ?? {};
|
|
40437
|
-
|
|
42011
|
+
const declaredSecretPaths = collectZodSecretPaths(schema);
|
|
42012
|
+
this.config = DeviceConfig.fromSchema(schema, (data) => ctx.persistConfig(data, { secretConfigPaths: declaredSecretPaths }), seedData, ({ droppedKeys, issues }) => {
|
|
40438
42013
|
ctx.logger.warn("Device config recovery: dropping invalid persisted fields", {
|
|
40439
42014
|
tags: {
|
|
40440
42015
|
deviceId: ctx.id,
|
|
@@ -44123,6 +45698,90 @@ Object.freeze({
|
|
|
44123
45698
|
addonId: null,
|
|
44124
45699
|
access: "create"
|
|
44125
45700
|
},
|
|
45701
|
+
"keychain.delete": {
|
|
45702
|
+
capName: "keychain",
|
|
45703
|
+
capScope: "system",
|
|
45704
|
+
addonId: null,
|
|
45705
|
+
access: "delete"
|
|
45706
|
+
},
|
|
45707
|
+
"keychain.getState": {
|
|
45708
|
+
capName: "keychain",
|
|
45709
|
+
capScope: "system",
|
|
45710
|
+
addonId: null,
|
|
45711
|
+
access: "view"
|
|
45712
|
+
},
|
|
45713
|
+
"keychain.listMeta": {
|
|
45714
|
+
capName: "keychain",
|
|
45715
|
+
capScope: "system",
|
|
45716
|
+
addonId: null,
|
|
45717
|
+
access: "view"
|
|
45718
|
+
},
|
|
45719
|
+
"keychain.put": {
|
|
45720
|
+
capName: "keychain",
|
|
45721
|
+
capScope: "system",
|
|
45722
|
+
addonId: null,
|
|
45723
|
+
access: "create"
|
|
45724
|
+
},
|
|
45725
|
+
"keychain.resolve": {
|
|
45726
|
+
capName: "keychain",
|
|
45727
|
+
capScope: "system",
|
|
45728
|
+
addonId: null,
|
|
45729
|
+
access: "view"
|
|
45730
|
+
},
|
|
45731
|
+
"keychainAdmin.deleteOrphans": {
|
|
45732
|
+
capName: "keychain-admin",
|
|
45733
|
+
capScope: "system",
|
|
45734
|
+
addonId: null,
|
|
45735
|
+
access: "delete"
|
|
45736
|
+
},
|
|
45737
|
+
"keychainAdmin.downloadRecoveryKey": {
|
|
45738
|
+
capName: "keychain-admin",
|
|
45739
|
+
capScope: "system",
|
|
45740
|
+
addonId: null,
|
|
45741
|
+
access: "create"
|
|
45742
|
+
},
|
|
45743
|
+
"keychainAdmin.listAudit": {
|
|
45744
|
+
capName: "keychain-admin",
|
|
45745
|
+
capScope: "system",
|
|
45746
|
+
addonId: null,
|
|
45747
|
+
access: "view"
|
|
45748
|
+
},
|
|
45749
|
+
"keychainAdmin.listSecrets": {
|
|
45750
|
+
capName: "keychain-admin",
|
|
45751
|
+
capScope: "system",
|
|
45752
|
+
addonId: null,
|
|
45753
|
+
access: "view"
|
|
45754
|
+
},
|
|
45755
|
+
"keychainAdmin.purgeRetiredKeys": {
|
|
45756
|
+
capName: "keychain-admin",
|
|
45757
|
+
capScope: "system",
|
|
45758
|
+
addonId: null,
|
|
45759
|
+
access: "delete"
|
|
45760
|
+
},
|
|
45761
|
+
"keychainAdmin.resetKeychain": {
|
|
45762
|
+
capName: "keychain-admin",
|
|
45763
|
+
capScope: "system",
|
|
45764
|
+
addonId: null,
|
|
45765
|
+
access: "delete"
|
|
45766
|
+
},
|
|
45767
|
+
"keychainAdmin.reveal": {
|
|
45768
|
+
capName: "keychain-admin",
|
|
45769
|
+
capScope: "system",
|
|
45770
|
+
addonId: null,
|
|
45771
|
+
access: "create"
|
|
45772
|
+
},
|
|
45773
|
+
"keychainAdmin.rotateMasterKey": {
|
|
45774
|
+
capName: "keychain-admin",
|
|
45775
|
+
capScope: "system",
|
|
45776
|
+
addonId: null,
|
|
45777
|
+
access: "create"
|
|
45778
|
+
},
|
|
45779
|
+
"keychainAdmin.status": {
|
|
45780
|
+
capName: "keychain-admin",
|
|
45781
|
+
capScope: "system",
|
|
45782
|
+
addonId: null,
|
|
45783
|
+
access: "view"
|
|
45784
|
+
},
|
|
44126
45785
|
"lawnMowerControl.dock": {
|
|
44127
45786
|
capName: "lawn-mower-control",
|
|
44128
45787
|
capScope: "device",
|
|
@@ -45497,6 +47156,18 @@ Object.freeze({
|
|
|
45497
47156
|
addonId: null,
|
|
45498
47157
|
access: "create"
|
|
45499
47158
|
},
|
|
47159
|
+
"pipelineAnalytics.addRetrainFrameFromRecording": {
|
|
47160
|
+
capName: "pipeline-analytics",
|
|
47161
|
+
capScope: "device",
|
|
47162
|
+
addonId: null,
|
|
47163
|
+
access: "create"
|
|
47164
|
+
},
|
|
47165
|
+
"pipelineAnalytics.addRetrainFramesToCollection": {
|
|
47166
|
+
capName: "pipeline-analytics",
|
|
47167
|
+
capScope: "device",
|
|
47168
|
+
addonId: null,
|
|
47169
|
+
access: "create"
|
|
47170
|
+
},
|
|
45500
47171
|
"pipelineAnalytics.applyDeviceSettingsPatch": {
|
|
45501
47172
|
capName: "pipeline-analytics",
|
|
45502
47173
|
capScope: "device",
|
|
@@ -45545,12 +47216,24 @@ Object.freeze({
|
|
|
45545
47216
|
addonId: null,
|
|
45546
47217
|
access: "view"
|
|
45547
47218
|
},
|
|
47219
|
+
"pipelineAnalytics.createRetrainCollection": {
|
|
47220
|
+
capName: "pipeline-analytics",
|
|
47221
|
+
capScope: "device",
|
|
47222
|
+
addonId: null,
|
|
47223
|
+
access: "create"
|
|
47224
|
+
},
|
|
45548
47225
|
"pipelineAnalytics.deleteDeviceEvents": {
|
|
45549
47226
|
capName: "pipeline-analytics",
|
|
45550
47227
|
capScope: "device",
|
|
45551
47228
|
addonId: null,
|
|
45552
47229
|
access: "delete"
|
|
45553
47230
|
},
|
|
47231
|
+
"pipelineAnalytics.deleteRetrainCollection": {
|
|
47232
|
+
capName: "pipeline-analytics",
|
|
47233
|
+
capScope: "device",
|
|
47234
|
+
addonId: null,
|
|
47235
|
+
access: "delete"
|
|
47236
|
+
},
|
|
45554
47237
|
"pipelineAnalytics.deleteTracks": {
|
|
45555
47238
|
capName: "pipeline-analytics",
|
|
45556
47239
|
capScope: "device",
|
|
@@ -45755,6 +47438,24 @@ Object.freeze({
|
|
|
45755
47438
|
addonId: null,
|
|
45756
47439
|
access: "view"
|
|
45757
47440
|
},
|
|
47441
|
+
"pipelineAnalytics.listRetrainAssistProfiles": {
|
|
47442
|
+
capName: "pipeline-analytics",
|
|
47443
|
+
capScope: "device",
|
|
47444
|
+
addonId: null,
|
|
47445
|
+
access: "view"
|
|
47446
|
+
},
|
|
47447
|
+
"pipelineAnalytics.listRetrainCollectionFrames": {
|
|
47448
|
+
capName: "pipeline-analytics",
|
|
47449
|
+
capScope: "device",
|
|
47450
|
+
addonId: null,
|
|
47451
|
+
access: "view"
|
|
47452
|
+
},
|
|
47453
|
+
"pipelineAnalytics.listRetrainCollections": {
|
|
47454
|
+
capName: "pipeline-analytics",
|
|
47455
|
+
capScope: "device",
|
|
47456
|
+
addonId: null,
|
|
47457
|
+
access: "view"
|
|
47458
|
+
},
|
|
45758
47459
|
"pipelineAnalytics.listRetrainFrames": {
|
|
45759
47460
|
capName: "pipeline-analytics",
|
|
45760
47461
|
capScope: "device",
|
|
@@ -45803,6 +47504,12 @@ Object.freeze({
|
|
|
45803
47504
|
addonId: null,
|
|
45804
47505
|
access: "create"
|
|
45805
47506
|
},
|
|
47507
|
+
"pipelineAnalytics.proposeRetrainAnnotationsWithLlm": {
|
|
47508
|
+
capName: "pipeline-analytics",
|
|
47509
|
+
capScope: "device",
|
|
47510
|
+
addonId: null,
|
|
47511
|
+
access: "create"
|
|
47512
|
+
},
|
|
45806
47513
|
"pipelineAnalytics.pruneEvents": {
|
|
45807
47514
|
capName: "pipeline-analytics",
|
|
45808
47515
|
capScope: "device",
|
|
@@ -45857,6 +47564,18 @@ Object.freeze({
|
|
|
45857
47564
|
addonId: null,
|
|
45858
47565
|
access: "create"
|
|
45859
47566
|
},
|
|
47567
|
+
"pipelineAnalytics.removeRetrainFrameFromCollection": {
|
|
47568
|
+
capName: "pipeline-analytics",
|
|
47569
|
+
capScope: "device",
|
|
47570
|
+
addonId: null,
|
|
47571
|
+
access: "delete"
|
|
47572
|
+
},
|
|
47573
|
+
"pipelineAnalytics.renameRetrainCollection": {
|
|
47574
|
+
capName: "pipeline-analytics",
|
|
47575
|
+
capScope: "device",
|
|
47576
|
+
addonId: null,
|
|
47577
|
+
access: "create"
|
|
47578
|
+
},
|
|
45860
47579
|
"pipelineAnalytics.restageRetrainTrack": {
|
|
45861
47580
|
capName: "pipeline-analytics",
|
|
45862
47581
|
capScope: "device",
|
|
@@ -46145,6 +47864,12 @@ Object.freeze({
|
|
|
46145
47864
|
addonId: null,
|
|
46146
47865
|
access: "view"
|
|
46147
47866
|
},
|
|
47867
|
+
"pipelineOrchestrator.abortNodeBenchmark": {
|
|
47868
|
+
capName: "pipeline-orchestrator",
|
|
47869
|
+
capScope: "system",
|
|
47870
|
+
addonId: null,
|
|
47871
|
+
access: "create"
|
|
47872
|
+
},
|
|
46148
47873
|
"pipelineOrchestrator.applyAutoTune": {
|
|
46149
47874
|
capName: "pipeline-orchestrator",
|
|
46150
47875
|
capScope: "system",
|
|
@@ -46169,6 +47894,12 @@ Object.freeze({
|
|
|
46169
47894
|
addonId: null,
|
|
46170
47895
|
access: "create"
|
|
46171
47896
|
},
|
|
47897
|
+
"pipelineOrchestrator.deleteNodeBenchmarkResult": {
|
|
47898
|
+
capName: "pipeline-orchestrator",
|
|
47899
|
+
capScope: "system",
|
|
47900
|
+
addonId: null,
|
|
47901
|
+
access: "delete"
|
|
47902
|
+
},
|
|
46172
47903
|
"pipelineOrchestrator.getAgentLoad": {
|
|
46173
47904
|
capName: "pipeline-orchestrator",
|
|
46174
47905
|
capScope: "system",
|
|
@@ -46277,6 +48008,24 @@ Object.freeze({
|
|
|
46277
48008
|
addonId: null,
|
|
46278
48009
|
access: "view"
|
|
46279
48010
|
},
|
|
48011
|
+
"pipelineOrchestrator.getNodeBenchmarkCandidates": {
|
|
48012
|
+
capName: "pipeline-orchestrator",
|
|
48013
|
+
capScope: "system",
|
|
48014
|
+
addonId: null,
|
|
48015
|
+
access: "view"
|
|
48016
|
+
},
|
|
48017
|
+
"pipelineOrchestrator.getNodeBenchmarkPreflight": {
|
|
48018
|
+
capName: "pipeline-orchestrator",
|
|
48019
|
+
capScope: "system",
|
|
48020
|
+
addonId: null,
|
|
48021
|
+
access: "view"
|
|
48022
|
+
},
|
|
48023
|
+
"pipelineOrchestrator.getNodeBenchmarkStatus": {
|
|
48024
|
+
capName: "pipeline-orchestrator",
|
|
48025
|
+
capScope: "system",
|
|
48026
|
+
addonId: null,
|
|
48027
|
+
access: "view"
|
|
48028
|
+
},
|
|
46280
48029
|
"pipelineOrchestrator.getNodeInferenceDevices": {
|
|
46281
48030
|
capName: "pipeline-orchestrator",
|
|
46282
48031
|
capScope: "system",
|
|
@@ -46319,6 +48068,12 @@ Object.freeze({
|
|
|
46319
48068
|
addonId: null,
|
|
46320
48069
|
access: "view"
|
|
46321
48070
|
},
|
|
48071
|
+
"pipelineOrchestrator.listNodeBenchmarkResults": {
|
|
48072
|
+
capName: "pipeline-orchestrator",
|
|
48073
|
+
capScope: "system",
|
|
48074
|
+
addonId: null,
|
|
48075
|
+
access: "view"
|
|
48076
|
+
},
|
|
46322
48077
|
"pipelineOrchestrator.pauseForStorageMigration": {
|
|
46323
48078
|
capName: "pipeline-orchestrator",
|
|
46324
48079
|
capScope: "system",
|
|
@@ -46463,6 +48218,12 @@ Object.freeze({
|
|
|
46463
48218
|
addonId: null,
|
|
46464
48219
|
access: "create"
|
|
46465
48220
|
},
|
|
48221
|
+
"pipelineOrchestrator.startNodeBenchmark": {
|
|
48222
|
+
capName: "pipeline-orchestrator",
|
|
48223
|
+
capScope: "system",
|
|
48224
|
+
addonId: null,
|
|
48225
|
+
access: "create"
|
|
48226
|
+
},
|
|
46466
48227
|
"pipelineOrchestrator.suggestShares": {
|
|
46467
48228
|
capName: "pipeline-orchestrator",
|
|
46468
48229
|
capScope: "system",
|
|
@@ -46481,6 +48242,12 @@ Object.freeze({
|
|
|
46481
48242
|
addonId: null,
|
|
46482
48243
|
access: "create"
|
|
46483
48244
|
},
|
|
48245
|
+
"pipelineRunner.abortNodeBench": {
|
|
48246
|
+
capName: "pipeline-runner",
|
|
48247
|
+
capScope: "system",
|
|
48248
|
+
addonId: null,
|
|
48249
|
+
access: "create"
|
|
48250
|
+
},
|
|
46484
48251
|
"pipelineRunner.attachCamera": {
|
|
46485
48252
|
capName: "pipeline-runner",
|
|
46486
48253
|
capScope: "system",
|
|
@@ -46529,6 +48296,12 @@ Object.freeze({
|
|
|
46529
48296
|
addonId: null,
|
|
46530
48297
|
access: "view"
|
|
46531
48298
|
},
|
|
48299
|
+
"pipelineRunner.getNodeBenchStatus": {
|
|
48300
|
+
capName: "pipeline-runner",
|
|
48301
|
+
capScope: "system",
|
|
48302
|
+
addonId: null,
|
|
48303
|
+
access: "view"
|
|
48304
|
+
},
|
|
46532
48305
|
"pipelineRunner.getParkedTrackFrame": {
|
|
46533
48306
|
capName: "pipeline-runner",
|
|
46534
48307
|
capScope: "system",
|
|
@@ -46571,6 +48344,12 @@ Object.freeze({
|
|
|
46571
48344
|
addonId: null,
|
|
46572
48345
|
access: "create"
|
|
46573
48346
|
},
|
|
48347
|
+
"pipelineRunner.startNodeBench": {
|
|
48348
|
+
capName: "pipeline-runner",
|
|
48349
|
+
capScope: "system",
|
|
48350
|
+
addonId: null,
|
|
48351
|
+
access: "create"
|
|
48352
|
+
},
|
|
46574
48353
|
"plateGallery.assignPlate": {
|
|
46575
48354
|
capName: "plate-gallery",
|
|
46576
48355
|
capScope: "system",
|
|
@@ -51566,6 +53345,11 @@ Object.freeze({
|
|
|
51566
53345
|
form: "single",
|
|
51567
53346
|
optional: false
|
|
51568
53347
|
}],
|
|
53348
|
+
"pipelineAnalytics.addRetrainFrameFromRecording": [{
|
|
53349
|
+
name: "deviceId",
|
|
53350
|
+
form: "single",
|
|
53351
|
+
optional: false
|
|
53352
|
+
}],
|
|
51569
53353
|
"pipelineAnalytics.applyDeviceSettingsPatch": [{
|
|
51570
53354
|
name: "deviceId",
|
|
51571
53355
|
form: "single",
|
|
@@ -51756,6 +53540,11 @@ Object.freeze({
|
|
|
51756
53540
|
form: "single",
|
|
51757
53541
|
optional: false
|
|
51758
53542
|
}],
|
|
53543
|
+
"pipelineAnalytics.proposeRetrainAnnotationsWithLlm": [{
|
|
53544
|
+
name: "deviceId",
|
|
53545
|
+
form: "single",
|
|
53546
|
+
optional: false
|
|
53547
|
+
}],
|
|
51759
53548
|
"pipelineAnalytics.pruneEventsBefore": [{
|
|
51760
53549
|
name: "deviceId",
|
|
51761
53550
|
form: "single",
|